From d164dd79b1c0f4731a299dfbad9f61040bea6ff6 Mon Sep 17 00:00:00 2001 From: hanzo-dev Date: Fri, 17 Jul 2026 17:18:33 -0700 Subject: [PATCH 1/2] feat: pure-Go SQLCipher encryption (zero modernc dep) The !cgo backend now ENCRYPTS at rest, byte-compatible with C SQLCipher, via a vendored pure-Go SQLite engine + the hanzoai/sqlcipher codec VFS. Both backends encrypt in the same SQLCipher-4 format; a DB written by one opens under the other. - internal/: fork of modernc.org/{sqlite,libc,memory,mathutil} (v1.53.0, SQLite 3.53.2), arch-trimmed to {linux,darwin}x{amd64,arm64}, imports rewritten into the hanzo namespace. go list -m all shows ZERO modernc.org/*. - internal/engine/vfs/codec.go: read-write, os-backed codec VFS applying the hanzoai/sqlcipher page format. Zeros the reserve on decrypt (WAL checksum invariant), in-process heap wal-index (shm), single-writer. Fail-closed on wrong key / tampered page; refuses rollback journals (WAL-only). - driver_nocgo.go: EncryptionAvailable()=true; keyed OpenDB opens through the codec VFS, creates via an in-memory journal then converts to WAL, unregisters the VFS (and wipes the DEK) on sql.DB.Close. - driver_cgo.go: migrated mattn/go-sqlite3 -> hanzoai/csqlite (no mattn dep). - Engine patches: _reserve_bytes fcntl, Connector accessor. - Tests (CGO=0): keyed encrypt+WAL round-trip+reopen, opens a C-written fixture, byte-compat both ways, wrong-key fail-closed. v0.3.0 -> v0.3.1 --- LLM.md | 169 +- README.md | 56 +- driver_cgo.go | 80 +- driver_nocgo.go | 156 +- encryption_proof_test.go | 49 +- go.mod | 21 +- go.sum | 48 +- internal/engine/LICENSE | 26 + internal/engine/backup.go | 88 + internal/engine/conn.go | 1361 + internal/engine/convert.go | 299 + internal/engine/dbstatus.go | 98 + internal/engine/doc.go | 214 + internal/engine/driver.go | 176 + internal/engine/error.go | 75 + internal/engine/fcntl.go | 73 + internal/engine/lib/defs.go | 16 + internal/engine/lib/hooks.go | 20 + internal/engine/lib/hooks_linux_arm64.go | 30 + internal/engine/lib/mutex.go | 345 + internal/engine/lib/sqlite.go | 49056 +++++ internal/engine/lib/sqlite_darwin_amd64.go | 658 + internal/engine/lib/sqlite_darwin_arm64.go | 231 + .../engine/lib/sqlite_g_0000000000000003.go | 105292 ++++++++++ .../engine/lib/sqlite_g_0000000000000007.go | 9 + .../engine/lib/sqlite_g_000000000000000b.go | 658 + .../engine/lib/sqlite_g_000000000000000f.go | 238 + .../engine/lib/sqlite_g_0000000000000012.go | 7 + .../engine/lib/sqlite_g_0000000000000017.go | 29 + .../engine/lib/sqlite_g_000000000000002b.go | 721 + .../engine/lib/sqlite_g_000000000000003f.go | 1471 + .../engine/lib/sqlite_g_0000000000000043.go | 63 + .../engine/lib/sqlite_g_00000000000000c0.go | 887 + .../engine/lib/sqlite_g_0000000000000202.go | 7 + .../engine/lib/sqlite_g_0000000000000280.go | 7 + .../engine/lib/sqlite_g_0000000000000300.go | 7 + .../engine/lib/sqlite_g_0000000000000330.go | 11 + .../engine/lib/sqlite_g_0000000000000332.go | 7 + .../engine/lib/sqlite_g_000000000000033c.go | 7 + .../engine/lib/sqlite_g_0000000000000488.go | 204 + .../engine/lib/sqlite_g_00000000000004c0.go | 11 + .../engine/lib/sqlite_g_0000000000000b00.go | 11 + .../engine/lib/sqlite_g_0000000000001200.go | 540 + .../engine/lib/sqlite_g_0000000000001600.go | 294 + .../engine/lib/sqlite_g_00000000000016c0.go | 7 + .../engine/lib/sqlite_g_0000000000001a00.go | 2491 + .../engine/lib/sqlite_g_0000000000001a80.go | 673 + .../engine/lib/sqlite_g_0000000000001bc0.go | 46 + .../engine/lib/sqlite_g_0000000000001fc0.go | 9 + .../engine/lib/sqlite_g_0000000000002112.go | 7 + .../engine/lib/sqlite_g_00000000000023c0.go | 9 + .../engine/lib/sqlite_g_0000000000002802.go | 7 + .../engine/lib/sqlite_g_0000000000002880.go | 640 + .../engine/lib/sqlite_g_00000000000028bc.go | 7 + .../engine/lib/sqlite_g_00000000000028c0.go | 124 + .../engine/lib/sqlite_g_00000000000034c0.go | 15 + .../engine/lib/sqlite_g_00000000000037c0.go | 99 + .../engine/lib/sqlite_g_0000000000003a00.go | 27840 +++ .../engine/lib/sqlite_g_0000000000003a20.go | 204 + .../engine/lib/sqlite_g_0000000000003a80.go | 31207 +++ .../engine/lib/sqlite_g_0000000000003a83.go | 282 + .../engine/lib/sqlite_g_0000000000003ac0.go | 9 + .../engine/lib/sqlite_g_0000000000003ac3.go | 9 + .../engine/lib/sqlite_g_0000000000003b00.go | 885 + .../engine/lib/sqlite_g_0000000000003b80.go | 81 + .../engine/lib/sqlite_g_0000000000003bc0.go | 5544 + .../engine/lib/sqlite_g_0000000000003bc3.go | 471 + .../engine/lib/sqlite_g_0000000000003e00.go | 11 + .../engine/lib/sqlite_g_0000000000003e80.go | 882 + .../engine/lib/sqlite_g_0000000000003e83.go | 9 + .../engine/lib/sqlite_g_0000000000003ea8.go | 231 + .../engine/lib/sqlite_g_0000000000003eab.go | 298 + .../engine/lib/sqlite_g_0000000000003ec0.go | 48 + .../engine/lib/sqlite_g_0000000000003eec.go | 33 + .../engine/lib/sqlite_g_0000000000003f80.go | 159 + .../engine/lib/sqlite_g_0000000000003fc0.go | 3114 + .../engine/lib/sqlite_g_0000000000003fc3.go | 28 + .../engine/lib/sqlite_g_0000000000003fd7.go | 7 + .../engine/lib/sqlite_g_0000000000003ffc.go | 46 + .../engine/lib/sqlite_g_0000000000003fff.go | 221 + .../engine/lib/sqlite_g_0000000000004003.go | 86 + .../engine/lib/sqlite_g_0000000000004007.go | 36 + .../engine/lib/sqlite_g_0000000000004017.go | 7 + .../engine/lib/sqlite_g_000000000000403f.go | 56 + .../engine/lib/sqlite_g_0000000000004080.go | 7 + .../engine/lib/sqlite_g_0000000000005ffc.go | 9 + .../engine/lib/sqlite_g_0000000000007cc0.go | 7 + .../engine/lib/sqlite_g_0000000000007f80.go | 9 + .../engine/lib/sqlite_g_0000000000007fc0.go | 15 + .../engine/lib/sqlite_g_0000000000007fc3.go | 7 + .../engine/lib/sqlite_g_0000000000007ffc.go | 25 + .../engine/lib/sqlite_g_0000000000007fff.go | 51 + .../engine/lib/sqlite_g_000000000000800d.go | 9 + .../engine/lib/sqlite_g_000000000000c089.go | 15 + .../engine/lib/sqlite_g_000000000000c08d.go | 7 + .../engine/lib/sqlite_g_000000000000c488.go | 3153 + .../engine/lib/sqlite_g_000000000000c48b.go | 4278 + .../engine/lib/sqlite_g_000000000000c4cf.go | 2244 + .../engine/lib/sqlite_g_0000000000010022.go | 19 + .../engine/lib/sqlite_g_0000000000010032.go | 9 + .../engine/lib/sqlite_g_0000000000010222.go | 27 + .../engine/lib/sqlite_g_0000000000010232.go | 13 + .../engine/lib/sqlite_g_0000000000010332.go | 11 + .../engine/lib/sqlite_g_0000000000011620.go | 21 + .../engine/lib/sqlite_g_0000000000011a20.go | 81 + .../engine/lib/sqlite_g_0000000000012a23.go | 7 + .../engine/lib/sqlite_g_0000000000013a00.go | 164 + .../engine/lib/sqlite_g_0000000000013a20.go | 8453 + .../engine/lib/sqlite_g_0000000000013b10.go | 253 + .../engine/lib/sqlite_g_0000000000013b30.go | 5143 + .../engine/lib/sqlite_g_0000000000013e02.go | 7 + .../engine/lib/sqlite_g_0000000000013e22.go | 9 + .../engine/lib/sqlite_g_0000000000013e3e.go | 7 + .../engine/lib/sqlite_g_0000000000018003.go | 47 + .../engine/lib/sqlite_g_0000000000018017.go | 17 + .../engine/lib/sqlite_g_000000000001802b.go | 33 + .../engine/lib/sqlite_g_000000000001803d.go | 7 + .../engine/lib/sqlite_g_000000000001803f.go | 327 + .../engine/lib/sqlite_g_000000000001843f.go | 7 + .../engine/lib/sqlite_g_000000000001883f.go | 7 + .../engine/lib/sqlite_g_00000000000192bb.go | 35 + .../engine/lib/sqlite_g_0000000000019600.go | 33 + .../engine/lib/sqlite_g_000000000001afff.go | 7 + .../engine/lib/sqlite_g_000000000001be80.go | 7 + .../engine/lib/sqlite_g_000000000001beab.go | 7 + .../engine/lib/sqlite_g_000000000001bfc0.go | 21 + .../engine/lib/sqlite_g_000000000001bfe8.go | 7 + .../engine/lib/sqlite_g_000000000001bff8.go | 7 + .../engine/lib/sqlite_g_000000000001bffc.go | 13 + .../engine/lib/sqlite_g_000000000001bfff.go | 45 + .../engine/lib/sqlite_g_000000000001c003.go | 115 + .../engine/lib/sqlite_g_000000000001c007.go | 9 + .../engine/lib/sqlite_g_000000000001c017.go | 7 + .../engine/lib/sqlite_g_000000000001c02b.go | 33 + .../engine/lib/sqlite_g_000000000001c03f.go | 530 + .../engine/lib/sqlite_g_000000000001c17f.go | 7 + .../engine/lib/sqlite_g_000000000001d740.go | 7 + .../engine/lib/sqlite_g_000000000001d77f.go | 7 + .../engine/lib/sqlite_g_000000000001dea8.go | 1468 + .../engine/lib/sqlite_g_000000000001deab.go | 577 + .../engine/lib/sqlite_g_000000000001dfff.go | 611 + .../engine/lib/sqlite_g_000000000001f7ff.go | 9 + .../engine/lib/sqlite_g_000000000001fc8f.go | 7 + .../engine/lib/sqlite_g_000000000001fccf.go | 11 + .../engine/lib/sqlite_g_000000000001fe80.go | 7 + .../engine/lib/sqlite_g_000000000001fe88.go | 242 + .../engine/lib/sqlite_g_000000000001fe8b.go | 63 + .../engine/lib/sqlite_g_000000000001fea8.go | 19873 ++ .../engine/lib/sqlite_g_000000000001feab.go | 31631 +++ .../engine/lib/sqlite_g_000000000001feec.go | 25 + .../engine/lib/sqlite_g_000000000001feef.go | 113 + .../engine/lib/sqlite_g_000000000001ffbb.go | 696 + .../engine/lib/sqlite_g_000000000001ffc0.go | 9 + .../engine/lib/sqlite_g_000000000001ffc3.go | 7 + .../engine/lib/sqlite_g_000000000001ffcf.go | 9 + .../engine/lib/sqlite_g_000000000001ffdf.go | 122 + .../engine/lib/sqlite_g_000000000001fffc.go | 316 + .../engine/lib/sqlite_g_000000000001ffff.go | 14227 ++ .../engine/lib/sqlite_g_000000000002002b.go | 7 + .../engine/lib/sqlite_g_0000000000023eab.go | 40 + .../engine/lib/sqlite_g_0000000000024080.go | 7 + .../engine/lib/sqlite_g_000000000002c088.go | 9 + .../engine/lib/sqlite_g_000000000002c089.go | 15 + .../engine/lib/sqlite_g_000000000002c488.go | 307 + .../engine/lib/sqlite_g_000000000002c48b.go | 835 + .../engine/lib/sqlite_g_000000000002c4cf.go | 141 + .../engine/lib/sqlite_g_000000000003c02b.go | 39 + .../engine/lib/sqlite_g_000000000003dea8.go | 152 + .../engine/lib/sqlite_g_000000000003fe8b.go | 104 + .../engine/lib/sqlite_g_000000000003fea8.go | 2841 + .../engine/lib/sqlite_g_000000000003feab.go | 16118 ++ .../engine/lib/sqlite_g_000000000003feef.go | 1615 + .../engine/lib/sqlite_g_000000000003ffbb.go | 7 + .../engine/lib/sqlite_g_000000000003fffb.go | 7 + .../engine/lib/sqlite_g_0000000000040003.go | 7 + .../engine/lib/sqlite_g_0000000000040045.go | 7 + .../engine/lib/sqlite_g_000000000005feff.go | 7 + .../engine/lib/sqlite_g_000000000005ffff.go | 7 + .../engine/lib/sqlite_g_0000000000060003.go | 151 + .../engine/lib/sqlite_g_000000000006003f.go | 19 + .../engine/lib/sqlite_g_00000000000600c0.go | 7 + .../engine/lib/sqlite_g_00000000000602c0.go | 9 + .../engine/lib/sqlite_g_0000000000060300.go | 7 + .../engine/lib/sqlite_g_00000000000623c0.go | 21 + .../engine/lib/sqlite_g_00000000000628c0.go | 47 + .../engine/lib/sqlite_g_0000000000063fc0.go | 23 + .../engine/lib/sqlite_g_0000000000063fc3.go | 17 + .../engine/lib/sqlite_g_0000000000063fff.go | 162 + .../engine/lib/sqlite_g_0000000000064003.go | 17 + .../engine/lib/sqlite_g_000000000006403f.go | 7 + .../engine/lib/sqlite_g_00000000000640c0.go | 11 + .../engine/lib/sqlite_g_0000000000065ec0.go | 65 + .../engine/lib/sqlite_g_0000000000065fc0.go | 7 + .../engine/lib/sqlite_g_0000000000066fc0.go | 7 + .../engine/lib/sqlite_g_0000000000067bc0.go | 7 + .../engine/lib/sqlite_g_0000000000067fc0.go | 109 + .../engine/lib/sqlite_g_0000000000067fc3.go | 7 + .../engine/lib/sqlite_g_0000000000067fff.go | 45 + .../engine/lib/sqlite_g_000000000006c0cd.go | 9 + .../engine/lib/sqlite_g_000000000006c4cf.go | 3150 + .../engine/lib/sqlite_g_000000000006c8cc.go | 7 + .../engine/lib/sqlite_g_000000000006e9df.go | 21 + .../engine/lib/sqlite_g_0000000000078003.go | 7 + .../engine/lib/sqlite_g_000000000007803f.go | 15 + .../engine/lib/sqlite_g_00000000000781fd.go | 7 + .../engine/lib/sqlite_g_00000000000783ff.go | 7 + .../engine/lib/sqlite_g_000000000007bfc0.go | 11 + .../engine/lib/sqlite_g_000000000007bfff.go | 17 + .../engine/lib/sqlite_g_000000000007c03f.go | 29 + .../engine/lib/sqlite_g_000000000007c17f.go | 13 + .../engine/lib/sqlite_g_000000000007c3ef.go | 7 + .../engine/lib/sqlite_g_000000000007deed.go | 7 + .../engine/lib/sqlite_g_000000000007dfff.go | 99 + .../engine/lib/sqlite_g_000000000007feec.go | 10 + .../engine/lib/sqlite_g_000000000007feff.go | 21 + .../engine/lib/sqlite_g_000000000007ffbb.go | 340 + .../engine/lib/sqlite_g_000000000007ffc3.go | 68 + .../engine/lib/sqlite_g_000000000007ffd7.go | 36 + .../engine/lib/sqlite_g_000000000007ffdf.go | 190 + .../engine/lib/sqlite_g_000000000007fffc.go | 23 + internal/engine/lib/sqlite_linux_amd64.go | 30407 +++ internal/engine/lib/sqlite_linux_arm64.go | 17 + internal/engine/mutex.go | 23 + internal/engine/nodmesg.go | 12 + internal/engine/pagecache.go | 359 + internal/engine/pagecache_trampolines.go | 388 + internal/engine/pre_update_hook.go | 227 + internal/engine/result.go | 42 + internal/engine/rows.go | 334 + internal/engine/rulimit.go | 19 + internal/engine/sqlite.go | 1144 + internal/engine/stmt.go | 500 + internal/engine/tx.go | 79 + internal/engine/vfs/codec.go | 750 + internal/engine/vfs/patches.go | 226 + internal/engine/vfs/patches64.go | 32 + internal/engine/vfs/vfs_darwin_amd64.go | 2959 + internal/engine/vfs/vfs_darwin_arm64.go | 1342 + internal/engine/vfs/vfs_linux_amd64.go | 1528 + internal/engine/vfs/vfs_linux_arm64.go | 1559 + internal/engine/vtab.go | 932 + internal/engine/vtab/doc.go | 59 + internal/engine/vtab/vtab.go | 328 + internal/libc/LICENSE | 27 + internal/libc/abi0_linux_amd64.go | 5765 + internal/libc/abi0_linux_amd64.s | 28760 +++ internal/libc/aliases.go | 109 + internal/libc/atomic.go | 117 + internal/libc/atomic64.go | 16 + internal/libc/builtin.go | 443 + internal/libc/builtin64.go | 29 + internal/libc/builtin_all.go | 13 + internal/libc/capi_darwin_amd64.go | 540 + internal/libc/capi_darwin_arm64.go | 540 + internal/libc/capi_linux_amd64.go | 528 + internal/libc/capi_linux_arm64.go | 512 + internal/libc/ccgo.go | 1892 + internal/libc/ccgo_linux_amd64.go | 154743 +++++++++++++++ internal/libc/ccgo_linux_arm64.go | 154065 ++++++++++++++ internal/libc/errno/capi_darwin_amd64.go | 7 + internal/libc/errno/capi_darwin_arm64.go | 7 + internal/libc/errno/capi_linux_amd64.go | 5 + internal/libc/errno/capi_linux_arm64.go | 5 + internal/libc/errno/errno_darwin_amd64.go | 654 + internal/libc/errno/errno_darwin_arm64.go | 680 + internal/libc/errno/errno_linux_amd64.go | 187 + internal/libc/errno/errno_linux_arm64.go | 187 + internal/libc/etc.go | 926 + internal/libc/etc_musl.go | 69 + internal/libc/fcntl/capi_darwin_amd64.go | 7 + internal/libc/fcntl/capi_darwin_arm64.go | 7 + internal/libc/fcntl/capi_linux_amd64.go | 5 + internal/libc/fcntl/capi_linux_arm64.go | 5 + internal/libc/fcntl/fcntl_darwin_amd64.go | 2064 + internal/libc/fcntl/fcntl_darwin_arm64.go | 2080 + internal/libc/fcntl/fcntl_linux_amd64.go | 1087 + internal/libc/fcntl/fcntl_linux_arm64.go | 1199 + internal/libc/fsync.go | 10 + internal/libc/fts/capi_darwin_amd64.go | 11 + internal/libc/fts/capi_darwin_arm64.go | 11 + internal/libc/fts/capi_linux_amd64.go | 5 + internal/libc/fts/capi_linux_arm64.go | 5 + internal/libc/fts/fts_darwin_amd64.go | 5132 + internal/libc/fts/fts_darwin_arm64.go | 5230 + internal/libc/fts/fts_linux_amd64.go | 1904 + internal/libc/fts/fts_linux_arm64.go | 2053 + internal/libc/grp/capi_darwin_amd64.go | 7 + internal/libc/grp/capi_darwin_arm64.go | 7 + internal/libc/grp/capi_linux_amd64.go | 5 + internal/libc/grp/capi_linux_arm64.go | 5 + internal/libc/grp/grp_darwin_amd64.go | 1001 + internal/libc/grp/grp_darwin_arm64.go | 1003 + internal/libc/grp/grp_linux_amd64.go | 783 + internal/libc/grp/grp_linux_arm64.go | 851 + internal/libc/honnef.co/go/netdb/netdb.go | 872 + internal/libc/int128.go | 331 + internal/libc/ioutil_darwin.go | 65 + internal/libc/langinfo/capi_darwin_amd64.go | 7 + internal/libc/langinfo/capi_darwin_arm64.go | 7 + internal/libc/langinfo/capi_linux_amd64.go | 5 + internal/libc/langinfo/capi_linux_arm64.go | 5 + .../libc/langinfo/langinfo_darwin_amd64.go | 916 + .../libc/langinfo/langinfo_darwin_arm64.go | 918 + .../libc/langinfo/langinfo_linux_amd64.go | 1058 + .../libc/langinfo/langinfo_linux_arm64.go | 1093 + internal/libc/libc.go | 3572 + internal/libc/libc64.go | 79 + internal/libc/libc_all.go | 122 + internal/libc/libc_amd64.go | 40 + internal/libc/libc_arm64.go | 40 + internal/libc/libc_darwin.go | 2803 + internal/libc/libc_darwin_amd64.go | 536 + internal/libc/libc_darwin_arm64.go | 536 + internal/libc/libc_linux.go | 5 + internal/libc/libc_linux_statfs.go | 13 + internal/libc/libc_musl.go | 1119 + internal/libc/libc_musl_linux_amd64.go | 29 + internal/libc/libc_musl_linux_arm64.go | 29 + internal/libc/libc_unix.go | 1375 + internal/libc/libc_unix1.go | 27 + internal/libc/libc_unix3.go | 46 + internal/libc/limits/capi_darwin_amd64.go | 7 + internal/libc/limits/capi_darwin_arm64.go | 7 + internal/libc/limits/capi_linux_amd64.go | 5 + internal/libc/limits/capi_linux_arm64.go | 5 + internal/libc/limits/limits_darwin_amd64.go | 935 + internal/libc/limits/limits_darwin_arm64.go | 932 + internal/libc/limits/limits_linux_amd64.go | 943 + internal/libc/limits/limits_linux_arm64.go | 995 + internal/libc/mem.go | 174 + internal/libc/mem_musl.go | 170 + internal/libc/musl_darwin_amd64.go | 4988 + internal/libc/musl_darwin_arm64.go | 4984 + internal/libc/netdb/capi_darwin_amd64.go | 11 + internal/libc/netdb/capi_darwin_arm64.go | 11 + internal/libc/netdb/capi_linux_amd64.go | 5 + internal/libc/netdb/capi_linux_arm64.go | 5 + internal/libc/netdb/netdb_darwin_amd64.go | 6364 + internal/libc/netdb/netdb_darwin_arm64.go | 6323 + internal/libc/netdb/netdb_linux_amd64.go | 3081 + internal/libc/netdb/netdb_linux_arm64.go | 3191 + internal/libc/netinet/in/capi_darwin_amd64.go | 11 + internal/libc/netinet/in/capi_darwin_arm64.go | 11 + internal/libc/netinet/in/capi_linux_amd64.go | 5 + internal/libc/netinet/in/capi_linux_arm64.go | 5 + internal/libc/netinet/in/in_darwin_amd64.go | 5514 + internal/libc/netinet/in/in_darwin_arm64.go | 5815 + internal/libc/netinet/in/in_linux_amd64.go | 2790 + internal/libc/netinet/in/in_linux_arm64.go | 2900 + internal/libc/nodmesg.go | 12 + internal/libc/poll/capi_darwin_amd64.go | 7 + internal/libc/poll/capi_darwin_arm64.go | 7 + internal/libc/poll/capi_linux_amd64.go | 5 + internal/libc/poll/capi_linux_arm64.go | 5 + internal/libc/poll/poll_darwin_amd64.go | 157 + internal/libc/poll/poll_darwin_arm64.go | 159 + internal/libc/poll/poll_linux_amd64.go | 540 + internal/libc/poll/poll_linux_arm64.go | 575 + internal/libc/printf.go | 684 + internal/libc/probes.go | 169 + internal/libc/pthread.go | 741 + internal/libc/pthread/capi_darwin_amd64.go | 7 + internal/libc/pthread/capi_darwin_arm64.go | 7 + internal/libc/pthread/capi_linux_amd64.go | 5 + internal/libc/pthread/capi_linux_arm64.go | 5 + internal/libc/pthread/pthread_darwin_amd64.go | 3062 + internal/libc/pthread/pthread_darwin_arm64.go | 3068 + internal/libc/pthread/pthread_linux_amd64.go | 1873 + internal/libc/pthread/pthread_linux_arm64.go | 1992 + internal/libc/pthread_all.go | 64 + internal/libc/pthread_musl.go | 547 + internal/libc/pwd/capi_darwin_amd64.go | 7 + internal/libc/pwd/capi_darwin_arm64.go | 7 + internal/libc/pwd/capi_linux_amd64.go | 5 + internal/libc/pwd/capi_linux_arm64.go | 5 + internal/libc/pwd/pwd_darwin_amd64.go | 1081 + internal/libc/pwd/pwd_darwin_arm64.go | 1083 + internal/libc/pwd/pwd_linux_amd64.go | 789 + internal/libc/pwd/pwd_linux_arm64.go | 857 + internal/libc/rtl.go | 2200 + internal/libc/scanf.go | 748 + internal/libc/signal/capi_darwin_amd64.go | 8 + internal/libc/signal/capi_darwin_arm64.go | 8 + internal/libc/signal/capi_linux_amd64.go | 5 + internal/libc/signal/capi_linux_arm64.go | 5 + internal/libc/signal/more_darwin_amd64.go | 12 + internal/libc/signal/more_darwin_arm64.go | 12 + internal/libc/signal/more_linux_amd64.go | 12 + internal/libc/signal/more_linux_arm64.go | 12 + internal/libc/signal/signal_darwin_amd64.go | 4796 + internal/libc/signal/signal_darwin_arm64.go | 3132 + internal/libc/signal/signal_linux_amd64.go | 2198 + internal/libc/signal/signal_linux_arm64.go | 3311 + internal/libc/stdatomic.go | 1114 + internal/libc/stdio/capi_darwin_amd64.go | 7 + internal/libc/stdio/capi_darwin_arm64.go | 7 + internal/libc/stdio/capi_linux_amd64.go | 5 + internal/libc/stdio/capi_linux_arm64.go | 5 + internal/libc/stdio/stdio_darwin_amd64.go | 1929 + internal/libc/stdio/stdio_darwin_arm64.go | 1944 + internal/libc/stdio/stdio_linux_amd64.go | 540 + internal/libc/stdio/stdio_linux_arm64.go | 573 + internal/libc/stdlib/capi_darwin_amd64.go | 7 + internal/libc/stdlib/capi_darwin_arm64.go | 7 + internal/libc/stdlib/capi_linux_amd64.go | 5 + internal/libc/stdlib/capi_linux_arm64.go | 5 + internal/libc/stdlib/stdlib_darwin_amd64.go | 6026 + internal/libc/stdlib/stdlib_darwin_arm64.go | 4430 + internal/libc/stdlib/stdlib_linux_amd64.go | 1541 + internal/libc/stdlib/stdlib_linux_arm64.go | 1617 + internal/libc/straceoff.go | 10 + internal/libc/sync.go | 22 + internal/libc/sys/socket/capi_darwin_amd64.go | 11 + internal/libc/sys/socket/capi_darwin_arm64.go | 11 + internal/libc/sys/socket/capi_linux_amd64.go | 5 + internal/libc/sys/socket/capi_linux_arm64.go | 5 + .../libc/sys/socket/socket_darwin_amd64.go | 5022 + .../libc/sys/socket/socket_darwin_arm64.go | 5111 + .../libc/sys/socket/socket_linux_amd64.go | 1848 + .../libc/sys/socket/socket_linux_arm64.go | 1923 + internal/libc/sys/stat/capi_darwin_amd64.go | 7 + internal/libc/sys/stat/capi_darwin_arm64.go | 7 + internal/libc/sys/stat/capi_linux_amd64.go | 5 + internal/libc/sys/stat/capi_linux_arm64.go | 5 + internal/libc/sys/stat/stat_darwin_amd64.go | 2352 + internal/libc/sys/stat/stat_darwin_arm64.go | 2332 + internal/libc/sys/stat/stat_linux_amd64.go | 947 + internal/libc/sys/stat/stat_linux_arm64.go | 1060 + internal/libc/sys/types/capi_darwin_amd64.go | 11 + internal/libc/sys/types/capi_darwin_arm64.go | 11 + internal/libc/sys/types/capi_linux_amd64.go | 5 + internal/libc/sys/types/capi_linux_arm64.go | 5 + internal/libc/sys/types/types_darwin_amd64.go | 4006 + internal/libc/sys/types/types_darwin_arm64.go | 4136 + internal/libc/sys/types/types_linux_amd64.go | 1511 + internal/libc/sys/types/types_linux_arm64.go | 1614 + internal/libc/syscall_musl.go | 90 + internal/libc/termios/capi_darwin_amd64.go | 7 + internal/libc/termios/capi_darwin_arm64.go | 7 + internal/libc/termios/capi_linux_amd64.go | 5 + internal/libc/termios/capi_linux_arm64.go | 5 + internal/libc/termios/termios_darwin_amd64.go | 1567 + internal/libc/termios/termios_darwin_arm64.go | 1570 + internal/libc/termios/termios_linux_amd64.go | 1024 + internal/libc/termios/termios_linux_arm64.go | 1092 + internal/libc/time/capi_darwin_amd64.go | 7 + internal/libc/time/capi_darwin_arm64.go | 7 + internal/libc/time/capi_linux_amd64.go | 5 + internal/libc/time/capi_linux_arm64.go | 5 + internal/libc/time/time_darwin_amd64.go | 1769 + internal/libc/time/time_darwin_arm64.go | 1768 + internal/libc/time/time_linux_amd64.go | 682 + internal/libc/time/time_linux_arm64.go | 713 + internal/libc/tls_linux_amd64.go | 33 + internal/libc/tls_linux_amd64.s | 40 + internal/libc/unistd/capi_darwin_amd64.go | 11 + internal/libc/unistd/capi_darwin_arm64.go | 11 + internal/libc/unistd/capi_linux_amd64.go | 5 + internal/libc/unistd/capi_linux_arm64.go | 5 + internal/libc/unistd/unistd_darwin_amd64.go | 3474 + internal/libc/unistd/unistd_darwin_arm64.go | 3489 + internal/libc/unistd/unistd_linux_amd64.go | 1592 + internal/libc/unistd/unistd_linux_arm64.go | 1672 + internal/libc/utime/capi_darwin_amd64.go | 7 + internal/libc/utime/capi_darwin_arm64.go | 7 + internal/libc/utime/capi_linux_amd64.go | 5 + internal/libc/utime/capi_linux_arm64.go | 5 + internal/libc/utime/utime_darwin_amd64.go | 1359 + internal/libc/utime/utime_darwin_arm64.go | 1315 + internal/libc/utime/utime_linux_amd64.go | 781 + internal/libc/utime/utime_linux_arm64.go | 849 + internal/libc/uuid/uuid/capi_darwin_amd64.go | 7 + internal/libc/uuid/uuid/capi_darwin_arm64.go | 7 + internal/libc/uuid/uuid/capi_linux_amd64.go | 5 + internal/libc/uuid/uuid/capi_linux_arm64.go | 5 + internal/libc/uuid/uuid/uuid_darwin_amd64.go | 818 + internal/libc/uuid/uuid/uuid_darwin_arm64.go | 820 + internal/libc/uuid/uuid/uuid_linux_amd64.go | 1986 + internal/libc/uuid/uuid/uuid_linux_arm64.go | 2089 + internal/libc/watch.go | 240 + internal/libc/wctype/capi_darwin_amd64.go | 55 + internal/libc/wctype/capi_darwin_arm64.go | 55 + internal/libc/wctype/capi_linux_amd64.go | 5 + internal/libc/wctype/capi_linux_arm64.go | 5 + internal/libc/wctype/wctype_darwin_amd64.go | 1414 + internal/libc/wctype/wctype_darwin_arm64.go | 1416 + internal/libc/wctype/wctype_linux_amd64.go | 953 + internal/libc/wctype/wctype_linux_arm64.go | 1021 + internal/mathutil/LICENSE | 27 + internal/mathutil/binarylog.go | 80 + internal/mathutil/bits.go | 207 + internal/mathutil/envelope.go | 46 + internal/mathutil/int.go | 279 + internal/mathutil/mathutil.go | 1606 + internal/mathutil/permute.go | 39 + internal/mathutil/poly.go | 248 + internal/mathutil/primes.go | 331 + internal/mathutil/rat.go | 26 + internal/mathutil/rnd.go | 383 + internal/mathutil/sqr.go | 12 + internal/mathutil/tables.go | 6995 + internal/mathutil/test_deps.go | 11 + internal/memory/LICENSE | 27 + internal/memory/memory.go | 469 + internal/memory/memory64.go | 10 + internal/memory/mmap_unix.go | 70 + internal/memory/nocounters.go | 10 + internal/memory/trace_disabled.go | 10 + sqlcipher_pure_test.go | 161 + sqlite.go | 51 +- testdata/c-sqlcipher-4.5.6.db | Bin 0 -> 28672 bytes 511 files changed, 979128 insertions(+), 286 deletions(-) create mode 100644 internal/engine/LICENSE create mode 100644 internal/engine/backup.go create mode 100644 internal/engine/conn.go create mode 100644 internal/engine/convert.go create mode 100644 internal/engine/dbstatus.go create mode 100644 internal/engine/doc.go create mode 100644 internal/engine/driver.go create mode 100644 internal/engine/error.go create mode 100644 internal/engine/fcntl.go create mode 100644 internal/engine/lib/defs.go create mode 100644 internal/engine/lib/hooks.go create mode 100644 internal/engine/lib/hooks_linux_arm64.go create mode 100644 internal/engine/lib/mutex.go create mode 100644 internal/engine/lib/sqlite.go create mode 100644 internal/engine/lib/sqlite_darwin_amd64.go create mode 100644 internal/engine/lib/sqlite_darwin_arm64.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000003.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000007.go create mode 100644 internal/engine/lib/sqlite_g_000000000000000b.go create mode 100644 internal/engine/lib/sqlite_g_000000000000000f.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000012.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000017.go create mode 100644 internal/engine/lib/sqlite_g_000000000000002b.go create mode 100644 internal/engine/lib/sqlite_g_000000000000003f.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000043.go create mode 100644 internal/engine/lib/sqlite_g_00000000000000c0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000202.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000280.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000300.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000330.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000332.go create mode 100644 internal/engine/lib/sqlite_g_000000000000033c.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000488.go create mode 100644 internal/engine/lib/sqlite_g_00000000000004c0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000000b00.go create mode 100644 internal/engine/lib/sqlite_g_0000000000001200.go create mode 100644 internal/engine/lib/sqlite_g_0000000000001600.go create mode 100644 internal/engine/lib/sqlite_g_00000000000016c0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000001a00.go create mode 100644 internal/engine/lib/sqlite_g_0000000000001a80.go create mode 100644 internal/engine/lib/sqlite_g_0000000000001bc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000001fc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000002112.go create mode 100644 internal/engine/lib/sqlite_g_00000000000023c0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000002802.go create mode 100644 internal/engine/lib/sqlite_g_0000000000002880.go create mode 100644 internal/engine/lib/sqlite_g_00000000000028bc.go create mode 100644 internal/engine/lib/sqlite_g_00000000000028c0.go create mode 100644 internal/engine/lib/sqlite_g_00000000000034c0.go create mode 100644 internal/engine/lib/sqlite_g_00000000000037c0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003a00.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003a20.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003a80.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003a83.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003ac0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003ac3.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003b00.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003b80.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003bc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003bc3.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003e00.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003e80.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003e83.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003ea8.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003eab.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003ec0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003eec.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003f80.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003fc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003fc3.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003fd7.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003ffc.go create mode 100644 internal/engine/lib/sqlite_g_0000000000003fff.go create mode 100644 internal/engine/lib/sqlite_g_0000000000004003.go create mode 100644 internal/engine/lib/sqlite_g_0000000000004007.go create mode 100644 internal/engine/lib/sqlite_g_0000000000004017.go create mode 100644 internal/engine/lib/sqlite_g_000000000000403f.go create mode 100644 internal/engine/lib/sqlite_g_0000000000004080.go create mode 100644 internal/engine/lib/sqlite_g_0000000000005ffc.go create mode 100644 internal/engine/lib/sqlite_g_0000000000007cc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000007f80.go create mode 100644 internal/engine/lib/sqlite_g_0000000000007fc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000007fc3.go create mode 100644 internal/engine/lib/sqlite_g_0000000000007ffc.go create mode 100644 internal/engine/lib/sqlite_g_0000000000007fff.go create mode 100644 internal/engine/lib/sqlite_g_000000000000800d.go create mode 100644 internal/engine/lib/sqlite_g_000000000000c089.go create mode 100644 internal/engine/lib/sqlite_g_000000000000c08d.go create mode 100644 internal/engine/lib/sqlite_g_000000000000c488.go create mode 100644 internal/engine/lib/sqlite_g_000000000000c48b.go create mode 100644 internal/engine/lib/sqlite_g_000000000000c4cf.go create mode 100644 internal/engine/lib/sqlite_g_0000000000010022.go create mode 100644 internal/engine/lib/sqlite_g_0000000000010032.go create mode 100644 internal/engine/lib/sqlite_g_0000000000010222.go create mode 100644 internal/engine/lib/sqlite_g_0000000000010232.go create mode 100644 internal/engine/lib/sqlite_g_0000000000010332.go create mode 100644 internal/engine/lib/sqlite_g_0000000000011620.go create mode 100644 internal/engine/lib/sqlite_g_0000000000011a20.go create mode 100644 internal/engine/lib/sqlite_g_0000000000012a23.go create mode 100644 internal/engine/lib/sqlite_g_0000000000013a00.go create mode 100644 internal/engine/lib/sqlite_g_0000000000013a20.go create mode 100644 internal/engine/lib/sqlite_g_0000000000013b10.go create mode 100644 internal/engine/lib/sqlite_g_0000000000013b30.go create mode 100644 internal/engine/lib/sqlite_g_0000000000013e02.go create mode 100644 internal/engine/lib/sqlite_g_0000000000013e22.go create mode 100644 internal/engine/lib/sqlite_g_0000000000013e3e.go create mode 100644 internal/engine/lib/sqlite_g_0000000000018003.go create mode 100644 internal/engine/lib/sqlite_g_0000000000018017.go create mode 100644 internal/engine/lib/sqlite_g_000000000001802b.go create mode 100644 internal/engine/lib/sqlite_g_000000000001803d.go create mode 100644 internal/engine/lib/sqlite_g_000000000001803f.go create mode 100644 internal/engine/lib/sqlite_g_000000000001843f.go create mode 100644 internal/engine/lib/sqlite_g_000000000001883f.go create mode 100644 internal/engine/lib/sqlite_g_00000000000192bb.go create mode 100644 internal/engine/lib/sqlite_g_0000000000019600.go create mode 100644 internal/engine/lib/sqlite_g_000000000001afff.go create mode 100644 internal/engine/lib/sqlite_g_000000000001be80.go create mode 100644 internal/engine/lib/sqlite_g_000000000001beab.go create mode 100644 internal/engine/lib/sqlite_g_000000000001bfc0.go create mode 100644 internal/engine/lib/sqlite_g_000000000001bfe8.go create mode 100644 internal/engine/lib/sqlite_g_000000000001bff8.go create mode 100644 internal/engine/lib/sqlite_g_000000000001bffc.go create mode 100644 internal/engine/lib/sqlite_g_000000000001bfff.go create mode 100644 internal/engine/lib/sqlite_g_000000000001c003.go create mode 100644 internal/engine/lib/sqlite_g_000000000001c007.go create mode 100644 internal/engine/lib/sqlite_g_000000000001c017.go create mode 100644 internal/engine/lib/sqlite_g_000000000001c02b.go create mode 100644 internal/engine/lib/sqlite_g_000000000001c03f.go create mode 100644 internal/engine/lib/sqlite_g_000000000001c17f.go create mode 100644 internal/engine/lib/sqlite_g_000000000001d740.go create mode 100644 internal/engine/lib/sqlite_g_000000000001d77f.go create mode 100644 internal/engine/lib/sqlite_g_000000000001dea8.go create mode 100644 internal/engine/lib/sqlite_g_000000000001deab.go create mode 100644 internal/engine/lib/sqlite_g_000000000001dfff.go create mode 100644 internal/engine/lib/sqlite_g_000000000001f7ff.go create mode 100644 internal/engine/lib/sqlite_g_000000000001fc8f.go create mode 100644 internal/engine/lib/sqlite_g_000000000001fccf.go create mode 100644 internal/engine/lib/sqlite_g_000000000001fe80.go create mode 100644 internal/engine/lib/sqlite_g_000000000001fe88.go create mode 100644 internal/engine/lib/sqlite_g_000000000001fe8b.go create mode 100644 internal/engine/lib/sqlite_g_000000000001fea8.go create mode 100644 internal/engine/lib/sqlite_g_000000000001feab.go create mode 100644 internal/engine/lib/sqlite_g_000000000001feec.go create mode 100644 internal/engine/lib/sqlite_g_000000000001feef.go create mode 100644 internal/engine/lib/sqlite_g_000000000001ffbb.go create mode 100644 internal/engine/lib/sqlite_g_000000000001ffc0.go create mode 100644 internal/engine/lib/sqlite_g_000000000001ffc3.go create mode 100644 internal/engine/lib/sqlite_g_000000000001ffcf.go create mode 100644 internal/engine/lib/sqlite_g_000000000001ffdf.go create mode 100644 internal/engine/lib/sqlite_g_000000000001fffc.go create mode 100644 internal/engine/lib/sqlite_g_000000000001ffff.go create mode 100644 internal/engine/lib/sqlite_g_000000000002002b.go create mode 100644 internal/engine/lib/sqlite_g_0000000000023eab.go create mode 100644 internal/engine/lib/sqlite_g_0000000000024080.go create mode 100644 internal/engine/lib/sqlite_g_000000000002c088.go create mode 100644 internal/engine/lib/sqlite_g_000000000002c089.go create mode 100644 internal/engine/lib/sqlite_g_000000000002c488.go create mode 100644 internal/engine/lib/sqlite_g_000000000002c48b.go create mode 100644 internal/engine/lib/sqlite_g_000000000002c4cf.go create mode 100644 internal/engine/lib/sqlite_g_000000000003c02b.go create mode 100644 internal/engine/lib/sqlite_g_000000000003dea8.go create mode 100644 internal/engine/lib/sqlite_g_000000000003fe8b.go create mode 100644 internal/engine/lib/sqlite_g_000000000003fea8.go create mode 100644 internal/engine/lib/sqlite_g_000000000003feab.go create mode 100644 internal/engine/lib/sqlite_g_000000000003feef.go create mode 100644 internal/engine/lib/sqlite_g_000000000003ffbb.go create mode 100644 internal/engine/lib/sqlite_g_000000000003fffb.go create mode 100644 internal/engine/lib/sqlite_g_0000000000040003.go create mode 100644 internal/engine/lib/sqlite_g_0000000000040045.go create mode 100644 internal/engine/lib/sqlite_g_000000000005feff.go create mode 100644 internal/engine/lib/sqlite_g_000000000005ffff.go create mode 100644 internal/engine/lib/sqlite_g_0000000000060003.go create mode 100644 internal/engine/lib/sqlite_g_000000000006003f.go create mode 100644 internal/engine/lib/sqlite_g_00000000000600c0.go create mode 100644 internal/engine/lib/sqlite_g_00000000000602c0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000060300.go create mode 100644 internal/engine/lib/sqlite_g_00000000000623c0.go create mode 100644 internal/engine/lib/sqlite_g_00000000000628c0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000063fc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000063fc3.go create mode 100644 internal/engine/lib/sqlite_g_0000000000063fff.go create mode 100644 internal/engine/lib/sqlite_g_0000000000064003.go create mode 100644 internal/engine/lib/sqlite_g_000000000006403f.go create mode 100644 internal/engine/lib/sqlite_g_00000000000640c0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000065ec0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000065fc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000066fc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000067bc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000067fc0.go create mode 100644 internal/engine/lib/sqlite_g_0000000000067fc3.go create mode 100644 internal/engine/lib/sqlite_g_0000000000067fff.go create mode 100644 internal/engine/lib/sqlite_g_000000000006c0cd.go create mode 100644 internal/engine/lib/sqlite_g_000000000006c4cf.go create mode 100644 internal/engine/lib/sqlite_g_000000000006c8cc.go create mode 100644 internal/engine/lib/sqlite_g_000000000006e9df.go create mode 100644 internal/engine/lib/sqlite_g_0000000000078003.go create mode 100644 internal/engine/lib/sqlite_g_000000000007803f.go create mode 100644 internal/engine/lib/sqlite_g_00000000000781fd.go create mode 100644 internal/engine/lib/sqlite_g_00000000000783ff.go create mode 100644 internal/engine/lib/sqlite_g_000000000007bfc0.go create mode 100644 internal/engine/lib/sqlite_g_000000000007bfff.go create mode 100644 internal/engine/lib/sqlite_g_000000000007c03f.go create mode 100644 internal/engine/lib/sqlite_g_000000000007c17f.go create mode 100644 internal/engine/lib/sqlite_g_000000000007c3ef.go create mode 100644 internal/engine/lib/sqlite_g_000000000007deed.go create mode 100644 internal/engine/lib/sqlite_g_000000000007dfff.go create mode 100644 internal/engine/lib/sqlite_g_000000000007feec.go create mode 100644 internal/engine/lib/sqlite_g_000000000007feff.go create mode 100644 internal/engine/lib/sqlite_g_000000000007ffbb.go create mode 100644 internal/engine/lib/sqlite_g_000000000007ffc3.go create mode 100644 internal/engine/lib/sqlite_g_000000000007ffd7.go create mode 100644 internal/engine/lib/sqlite_g_000000000007ffdf.go create mode 100644 internal/engine/lib/sqlite_g_000000000007fffc.go create mode 100644 internal/engine/lib/sqlite_linux_amd64.go create mode 100644 internal/engine/lib/sqlite_linux_arm64.go create mode 100644 internal/engine/mutex.go create mode 100644 internal/engine/nodmesg.go create mode 100644 internal/engine/pagecache.go create mode 100644 internal/engine/pagecache_trampolines.go create mode 100644 internal/engine/pre_update_hook.go create mode 100644 internal/engine/result.go create mode 100644 internal/engine/rows.go create mode 100644 internal/engine/rulimit.go create mode 100644 internal/engine/sqlite.go create mode 100644 internal/engine/stmt.go create mode 100644 internal/engine/tx.go create mode 100644 internal/engine/vfs/codec.go create mode 100644 internal/engine/vfs/patches.go create mode 100644 internal/engine/vfs/patches64.go create mode 100644 internal/engine/vfs/vfs_darwin_amd64.go create mode 100644 internal/engine/vfs/vfs_darwin_arm64.go create mode 100644 internal/engine/vfs/vfs_linux_amd64.go create mode 100644 internal/engine/vfs/vfs_linux_arm64.go create mode 100644 internal/engine/vtab.go create mode 100644 internal/engine/vtab/doc.go create mode 100644 internal/engine/vtab/vtab.go create mode 100644 internal/libc/LICENSE create mode 100644 internal/libc/abi0_linux_amd64.go create mode 100644 internal/libc/abi0_linux_amd64.s create mode 100644 internal/libc/aliases.go create mode 100644 internal/libc/atomic.go create mode 100644 internal/libc/atomic64.go create mode 100644 internal/libc/builtin.go create mode 100644 internal/libc/builtin64.go create mode 100644 internal/libc/builtin_all.go create mode 100644 internal/libc/capi_darwin_amd64.go create mode 100644 internal/libc/capi_darwin_arm64.go create mode 100644 internal/libc/capi_linux_amd64.go create mode 100644 internal/libc/capi_linux_arm64.go create mode 100644 internal/libc/ccgo.go create mode 100644 internal/libc/ccgo_linux_amd64.go create mode 100644 internal/libc/ccgo_linux_arm64.go create mode 100644 internal/libc/errno/capi_darwin_amd64.go create mode 100644 internal/libc/errno/capi_darwin_arm64.go create mode 100644 internal/libc/errno/capi_linux_amd64.go create mode 100644 internal/libc/errno/capi_linux_arm64.go create mode 100644 internal/libc/errno/errno_darwin_amd64.go create mode 100644 internal/libc/errno/errno_darwin_arm64.go create mode 100644 internal/libc/errno/errno_linux_amd64.go create mode 100644 internal/libc/errno/errno_linux_arm64.go create mode 100644 internal/libc/etc.go create mode 100644 internal/libc/etc_musl.go create mode 100644 internal/libc/fcntl/capi_darwin_amd64.go create mode 100644 internal/libc/fcntl/capi_darwin_arm64.go create mode 100644 internal/libc/fcntl/capi_linux_amd64.go create mode 100644 internal/libc/fcntl/capi_linux_arm64.go create mode 100644 internal/libc/fcntl/fcntl_darwin_amd64.go create mode 100644 internal/libc/fcntl/fcntl_darwin_arm64.go create mode 100644 internal/libc/fcntl/fcntl_linux_amd64.go create mode 100644 internal/libc/fcntl/fcntl_linux_arm64.go create mode 100644 internal/libc/fsync.go create mode 100644 internal/libc/fts/capi_darwin_amd64.go create mode 100644 internal/libc/fts/capi_darwin_arm64.go create mode 100644 internal/libc/fts/capi_linux_amd64.go create mode 100644 internal/libc/fts/capi_linux_arm64.go create mode 100644 internal/libc/fts/fts_darwin_amd64.go create mode 100644 internal/libc/fts/fts_darwin_arm64.go create mode 100644 internal/libc/fts/fts_linux_amd64.go create mode 100644 internal/libc/fts/fts_linux_arm64.go create mode 100644 internal/libc/grp/capi_darwin_amd64.go create mode 100644 internal/libc/grp/capi_darwin_arm64.go create mode 100644 internal/libc/grp/capi_linux_amd64.go create mode 100644 internal/libc/grp/capi_linux_arm64.go create mode 100644 internal/libc/grp/grp_darwin_amd64.go create mode 100644 internal/libc/grp/grp_darwin_arm64.go create mode 100644 internal/libc/grp/grp_linux_amd64.go create mode 100644 internal/libc/grp/grp_linux_arm64.go create mode 100644 internal/libc/honnef.co/go/netdb/netdb.go create mode 100644 internal/libc/int128.go create mode 100644 internal/libc/ioutil_darwin.go create mode 100644 internal/libc/langinfo/capi_darwin_amd64.go create mode 100644 internal/libc/langinfo/capi_darwin_arm64.go create mode 100644 internal/libc/langinfo/capi_linux_amd64.go create mode 100644 internal/libc/langinfo/capi_linux_arm64.go create mode 100644 internal/libc/langinfo/langinfo_darwin_amd64.go create mode 100644 internal/libc/langinfo/langinfo_darwin_arm64.go create mode 100644 internal/libc/langinfo/langinfo_linux_amd64.go create mode 100644 internal/libc/langinfo/langinfo_linux_arm64.go create mode 100644 internal/libc/libc.go create mode 100644 internal/libc/libc64.go create mode 100644 internal/libc/libc_all.go create mode 100644 internal/libc/libc_amd64.go create mode 100644 internal/libc/libc_arm64.go create mode 100644 internal/libc/libc_darwin.go create mode 100644 internal/libc/libc_darwin_amd64.go create mode 100644 internal/libc/libc_darwin_arm64.go create mode 100644 internal/libc/libc_linux.go create mode 100644 internal/libc/libc_linux_statfs.go create mode 100644 internal/libc/libc_musl.go create mode 100644 internal/libc/libc_musl_linux_amd64.go create mode 100644 internal/libc/libc_musl_linux_arm64.go create mode 100644 internal/libc/libc_unix.go create mode 100644 internal/libc/libc_unix1.go create mode 100644 internal/libc/libc_unix3.go create mode 100644 internal/libc/limits/capi_darwin_amd64.go create mode 100644 internal/libc/limits/capi_darwin_arm64.go create mode 100644 internal/libc/limits/capi_linux_amd64.go create mode 100644 internal/libc/limits/capi_linux_arm64.go create mode 100644 internal/libc/limits/limits_darwin_amd64.go create mode 100644 internal/libc/limits/limits_darwin_arm64.go create mode 100644 internal/libc/limits/limits_linux_amd64.go create mode 100644 internal/libc/limits/limits_linux_arm64.go create mode 100644 internal/libc/mem.go create mode 100644 internal/libc/mem_musl.go create mode 100644 internal/libc/musl_darwin_amd64.go create mode 100644 internal/libc/musl_darwin_arm64.go create mode 100644 internal/libc/netdb/capi_darwin_amd64.go create mode 100644 internal/libc/netdb/capi_darwin_arm64.go create mode 100644 internal/libc/netdb/capi_linux_amd64.go create mode 100644 internal/libc/netdb/capi_linux_arm64.go create mode 100644 internal/libc/netdb/netdb_darwin_amd64.go create mode 100644 internal/libc/netdb/netdb_darwin_arm64.go create mode 100644 internal/libc/netdb/netdb_linux_amd64.go create mode 100644 internal/libc/netdb/netdb_linux_arm64.go create mode 100644 internal/libc/netinet/in/capi_darwin_amd64.go create mode 100644 internal/libc/netinet/in/capi_darwin_arm64.go create mode 100644 internal/libc/netinet/in/capi_linux_amd64.go create mode 100644 internal/libc/netinet/in/capi_linux_arm64.go create mode 100644 internal/libc/netinet/in/in_darwin_amd64.go create mode 100644 internal/libc/netinet/in/in_darwin_arm64.go create mode 100644 internal/libc/netinet/in/in_linux_amd64.go create mode 100644 internal/libc/netinet/in/in_linux_arm64.go create mode 100644 internal/libc/nodmesg.go create mode 100644 internal/libc/poll/capi_darwin_amd64.go create mode 100644 internal/libc/poll/capi_darwin_arm64.go create mode 100644 internal/libc/poll/capi_linux_amd64.go create mode 100644 internal/libc/poll/capi_linux_arm64.go create mode 100644 internal/libc/poll/poll_darwin_amd64.go create mode 100644 internal/libc/poll/poll_darwin_arm64.go create mode 100644 internal/libc/poll/poll_linux_amd64.go create mode 100644 internal/libc/poll/poll_linux_arm64.go create mode 100644 internal/libc/printf.go create mode 100644 internal/libc/probes.go create mode 100644 internal/libc/pthread.go create mode 100644 internal/libc/pthread/capi_darwin_amd64.go create mode 100644 internal/libc/pthread/capi_darwin_arm64.go create mode 100644 internal/libc/pthread/capi_linux_amd64.go create mode 100644 internal/libc/pthread/capi_linux_arm64.go create mode 100644 internal/libc/pthread/pthread_darwin_amd64.go create mode 100644 internal/libc/pthread/pthread_darwin_arm64.go create mode 100644 internal/libc/pthread/pthread_linux_amd64.go create mode 100644 internal/libc/pthread/pthread_linux_arm64.go create mode 100644 internal/libc/pthread_all.go create mode 100644 internal/libc/pthread_musl.go create mode 100644 internal/libc/pwd/capi_darwin_amd64.go create mode 100644 internal/libc/pwd/capi_darwin_arm64.go create mode 100644 internal/libc/pwd/capi_linux_amd64.go create mode 100644 internal/libc/pwd/capi_linux_arm64.go create mode 100644 internal/libc/pwd/pwd_darwin_amd64.go create mode 100644 internal/libc/pwd/pwd_darwin_arm64.go create mode 100644 internal/libc/pwd/pwd_linux_amd64.go create mode 100644 internal/libc/pwd/pwd_linux_arm64.go create mode 100644 internal/libc/rtl.go create mode 100644 internal/libc/scanf.go create mode 100644 internal/libc/signal/capi_darwin_amd64.go create mode 100644 internal/libc/signal/capi_darwin_arm64.go create mode 100644 internal/libc/signal/capi_linux_amd64.go create mode 100644 internal/libc/signal/capi_linux_arm64.go create mode 100644 internal/libc/signal/more_darwin_amd64.go create mode 100644 internal/libc/signal/more_darwin_arm64.go create mode 100644 internal/libc/signal/more_linux_amd64.go create mode 100644 internal/libc/signal/more_linux_arm64.go create mode 100644 internal/libc/signal/signal_darwin_amd64.go create mode 100644 internal/libc/signal/signal_darwin_arm64.go create mode 100644 internal/libc/signal/signal_linux_amd64.go create mode 100644 internal/libc/signal/signal_linux_arm64.go create mode 100644 internal/libc/stdatomic.go create mode 100644 internal/libc/stdio/capi_darwin_amd64.go create mode 100644 internal/libc/stdio/capi_darwin_arm64.go create mode 100644 internal/libc/stdio/capi_linux_amd64.go create mode 100644 internal/libc/stdio/capi_linux_arm64.go create mode 100644 internal/libc/stdio/stdio_darwin_amd64.go create mode 100644 internal/libc/stdio/stdio_darwin_arm64.go create mode 100644 internal/libc/stdio/stdio_linux_amd64.go create mode 100644 internal/libc/stdio/stdio_linux_arm64.go create mode 100644 internal/libc/stdlib/capi_darwin_amd64.go create mode 100644 internal/libc/stdlib/capi_darwin_arm64.go create mode 100644 internal/libc/stdlib/capi_linux_amd64.go create mode 100644 internal/libc/stdlib/capi_linux_arm64.go create mode 100644 internal/libc/stdlib/stdlib_darwin_amd64.go create mode 100644 internal/libc/stdlib/stdlib_darwin_arm64.go create mode 100644 internal/libc/stdlib/stdlib_linux_amd64.go create mode 100644 internal/libc/stdlib/stdlib_linux_arm64.go create mode 100644 internal/libc/straceoff.go create mode 100644 internal/libc/sync.go create mode 100644 internal/libc/sys/socket/capi_darwin_amd64.go create mode 100644 internal/libc/sys/socket/capi_darwin_arm64.go create mode 100644 internal/libc/sys/socket/capi_linux_amd64.go create mode 100644 internal/libc/sys/socket/capi_linux_arm64.go create mode 100644 internal/libc/sys/socket/socket_darwin_amd64.go create mode 100644 internal/libc/sys/socket/socket_darwin_arm64.go create mode 100644 internal/libc/sys/socket/socket_linux_amd64.go create mode 100644 internal/libc/sys/socket/socket_linux_arm64.go create mode 100644 internal/libc/sys/stat/capi_darwin_amd64.go create mode 100644 internal/libc/sys/stat/capi_darwin_arm64.go create mode 100644 internal/libc/sys/stat/capi_linux_amd64.go create mode 100644 internal/libc/sys/stat/capi_linux_arm64.go create mode 100644 internal/libc/sys/stat/stat_darwin_amd64.go create mode 100644 internal/libc/sys/stat/stat_darwin_arm64.go create mode 100644 internal/libc/sys/stat/stat_linux_amd64.go create mode 100644 internal/libc/sys/stat/stat_linux_arm64.go create mode 100644 internal/libc/sys/types/capi_darwin_amd64.go create mode 100644 internal/libc/sys/types/capi_darwin_arm64.go create mode 100644 internal/libc/sys/types/capi_linux_amd64.go create mode 100644 internal/libc/sys/types/capi_linux_arm64.go create mode 100644 internal/libc/sys/types/types_darwin_amd64.go create mode 100644 internal/libc/sys/types/types_darwin_arm64.go create mode 100644 internal/libc/sys/types/types_linux_amd64.go create mode 100644 internal/libc/sys/types/types_linux_arm64.go create mode 100644 internal/libc/syscall_musl.go create mode 100644 internal/libc/termios/capi_darwin_amd64.go create mode 100644 internal/libc/termios/capi_darwin_arm64.go create mode 100644 internal/libc/termios/capi_linux_amd64.go create mode 100644 internal/libc/termios/capi_linux_arm64.go create mode 100644 internal/libc/termios/termios_darwin_amd64.go create mode 100644 internal/libc/termios/termios_darwin_arm64.go create mode 100644 internal/libc/termios/termios_linux_amd64.go create mode 100644 internal/libc/termios/termios_linux_arm64.go create mode 100644 internal/libc/time/capi_darwin_amd64.go create mode 100644 internal/libc/time/capi_darwin_arm64.go create mode 100644 internal/libc/time/capi_linux_amd64.go create mode 100644 internal/libc/time/capi_linux_arm64.go create mode 100644 internal/libc/time/time_darwin_amd64.go create mode 100644 internal/libc/time/time_darwin_arm64.go create mode 100644 internal/libc/time/time_linux_amd64.go create mode 100644 internal/libc/time/time_linux_arm64.go create mode 100644 internal/libc/tls_linux_amd64.go create mode 100644 internal/libc/tls_linux_amd64.s create mode 100644 internal/libc/unistd/capi_darwin_amd64.go create mode 100644 internal/libc/unistd/capi_darwin_arm64.go create mode 100644 internal/libc/unistd/capi_linux_amd64.go create mode 100644 internal/libc/unistd/capi_linux_arm64.go create mode 100644 internal/libc/unistd/unistd_darwin_amd64.go create mode 100644 internal/libc/unistd/unistd_darwin_arm64.go create mode 100644 internal/libc/unistd/unistd_linux_amd64.go create mode 100644 internal/libc/unistd/unistd_linux_arm64.go create mode 100644 internal/libc/utime/capi_darwin_amd64.go create mode 100644 internal/libc/utime/capi_darwin_arm64.go create mode 100644 internal/libc/utime/capi_linux_amd64.go create mode 100644 internal/libc/utime/capi_linux_arm64.go create mode 100644 internal/libc/utime/utime_darwin_amd64.go create mode 100644 internal/libc/utime/utime_darwin_arm64.go create mode 100644 internal/libc/utime/utime_linux_amd64.go create mode 100644 internal/libc/utime/utime_linux_arm64.go create mode 100644 internal/libc/uuid/uuid/capi_darwin_amd64.go create mode 100644 internal/libc/uuid/uuid/capi_darwin_arm64.go create mode 100644 internal/libc/uuid/uuid/capi_linux_amd64.go create mode 100644 internal/libc/uuid/uuid/capi_linux_arm64.go create mode 100644 internal/libc/uuid/uuid/uuid_darwin_amd64.go create mode 100644 internal/libc/uuid/uuid/uuid_darwin_arm64.go create mode 100644 internal/libc/uuid/uuid/uuid_linux_amd64.go create mode 100644 internal/libc/uuid/uuid/uuid_linux_arm64.go create mode 100644 internal/libc/watch.go create mode 100644 internal/libc/wctype/capi_darwin_amd64.go create mode 100644 internal/libc/wctype/capi_darwin_arm64.go create mode 100644 internal/libc/wctype/capi_linux_amd64.go create mode 100644 internal/libc/wctype/capi_linux_arm64.go create mode 100644 internal/libc/wctype/wctype_darwin_amd64.go create mode 100644 internal/libc/wctype/wctype_darwin_arm64.go create mode 100644 internal/libc/wctype/wctype_linux_amd64.go create mode 100644 internal/libc/wctype/wctype_linux_arm64.go create mode 100644 internal/mathutil/LICENSE create mode 100644 internal/mathutil/binarylog.go create mode 100644 internal/mathutil/bits.go create mode 100644 internal/mathutil/envelope.go create mode 100644 internal/mathutil/int.go create mode 100644 internal/mathutil/mathutil.go create mode 100644 internal/mathutil/permute.go create mode 100644 internal/mathutil/poly.go create mode 100644 internal/mathutil/primes.go create mode 100644 internal/mathutil/rat.go create mode 100644 internal/mathutil/rnd.go create mode 100644 internal/mathutil/sqr.go create mode 100644 internal/mathutil/tables.go create mode 100644 internal/mathutil/test_deps.go create mode 100644 internal/memory/LICENSE create mode 100644 internal/memory/memory.go create mode 100644 internal/memory/memory64.go create mode 100644 internal/memory/mmap_unix.go create mode 100644 internal/memory/nocounters.go create mode 100644 internal/memory/trace_disabled.go create mode 100644 sqlcipher_pure_test.go create mode 100644 testdata/c-sqlcipher-4.5.6.db diff --git a/LLM.md b/LLM.md index e251599..bacb358 100644 --- a/LLM.md +++ b/LLM.md @@ -1,54 +1,114 @@ # sqlite -**Org:** hanzoai · **Ecosystem:** hanzo · **Path:** `/Users/a/work/hanzo/hanzoai/sqlite` -**Origin:** https://github.com/hanzoai/sqlite.git · **Module:** `github.com/hanzoai/sqlite` +**Org:** hanzoai · **Ecosystem:** hanzo · **Module:** `github.com/hanzoai/sqlite` +**Origin:** https://github.com/hanzoai/sqlite.git -Dual-backend `database/sql` driver. Registers the driver name **`sqlite`** under -BOTH build configs with one public API: +Dual-backend `database/sql` driver registering the driver name **`sqlite`** under +BOTH build configs with one public API. **Both backends encrypt at rest, in the +SAME SQLCipher-4 on-disk format** — a database written by one opens under the +other. | Build | Backend | Encryption | |-------|---------|------------| -| `CGO_ENABLED=1` + `-tags libsqlite3` + libsqlcipher | mattn/go-sqlite3 → SQLCipher | AES-256 at rest | -| `CGO_ENABLED=0` | modernc.org/sqlite (pure Go) | none (fail-secure: keyed Open errors) | - -## File map (decomplected by what actually varies) - -- `sqlite.go` — tag-neutral: `Config`, `Option`, `WithKey/WithRawKey/WithPrincipalKey/…`, `DB`, `Open()`, `EncryptionAvailable()`, `CodecLinked()` (runtime codec probe). -- `cek.go` — tag-neutral, pure Go: `DeriveKey` (HKDF-SHA256, length-prefixed injective info → KEK), `DeriveChildKey` (hierarchy), envelope `NewDEK`/`WrapDEK`/`UnwrapDEK` (AES-256-GCM; take a principal-binding `aad`), `PrincipalAAD` (the injective `(type,id)` encoding reused as the GCM AAD — DRY), `PrincipalGlobal/Org/User`. -- `threshold.go` — tag-neutral, pure Go: `ThresholdManager` (t-of-n Ed25519 write attestation). -- `driver_cgo.go` (`//go:build cgo`) — registers `sqlite`→mattn; `EncryptionAvailable()=true`; `OpenDB`/`DSN` emit SQLCipher URI key; path is percent-escaped so `?`/`#` can't strip `key=`. -- `driver_nocgo.go` (`//go:build !cgo`) — blank-imports modernc (self-registers `sqlite`); `EncryptionAvailable()=false`; keyed open → `ErrEncryptionUnavailable`. -- `encryption_proof_test.go` — anti-silent-plaintext gate (real ciphertext + reopen + wrong-key rejection under cgo, SKIPs if codec unlinked) + envelope rotation/injectivity/hierarchy proofs (run under both tags). +| `CGO_ENABLED=0` (default) | **vendored pure-Go engine** (`internal/engine`) + **hanzoai/sqlcipher** codec VFS | AES-256 at rest, **no cgo, no external C lib** | +| `CGO_ENABLED=1` + `-tags libsqlite3` + libsqlcipher | **hanzoai/csqlite** → SQLCipher | AES-256 at rest (C engine, for speed) | + +The pure-Go backend is the primary one: it always encrypts, needs nothing linked, +and is what CI/tests/lint/pure-Go deployments use. **`go list -m all` shows ZERO +`modernc.org/*`** — the engine is vendored in-tree. + +## Self-containment (how the pure-Go engine is vendored) + +`internal/` is a fork of `modernc.org/{sqlite,libc,memory,mathutil}` — the exact +runtime import closure of `modernc.org/sqlite` + `/vfs`, arch-trimmed to +`{linux,darwin}×{amd64,arm64}` (all 64-bit), with every `modernc.org/*` import +rewritten into `github.com/hanzoai/sqlite/internal/*`. No `cc`/`ccgo`/`gc`/ +`goabi0`/`fileutil` (those are `//go:build ignore` codegen-only). Base: +**modernc.org/sqlite v1.53.0** (SQLite 3.53.2). + +**To re-vendor (bump the engine):** in `scratchpad`/a throwaway module, `go get +modernc.org/sqlite@vX`, then re-run the vendor script (copies the per-arch +`go list` file set for the 4 target arches, rewrites imports), then re-apply the +three engine patches below and drop `codec.go` back into `internal/engine/vfs/`. +The vfs ABI seam (`patches64.go` offsets, `sqlite3_vfs`/`sqlite3_io_methods`/ +`VFSFile`/`sqlite_int64` types) has been byte-stable v1.44.3→v1.53.0, so `codec.go` +drops in unchanged. + +### The three engine patches (minimal fork delta) +1. `internal/engine/fcntl.go` — `(*conn).fileControlReserveBytes(n)`: + `SQLITE_FCNTL_RESERVE_BYTES`, so page 1 is created with the 80-byte SQLCipher + trailer room. +2. `internal/engine/sqlite.go` `applyQueryParams` — handle `_reserve_bytes=N` + BEFORE any writing pragma (calls the above). +3. `internal/engine/driver.go` — `Connector(dsn)`: a `driver.Connector` so + `sql.OpenDB` can wrap it in an `io.Closer` (unregister the codec VFS on + `sql.DB.Close`). + +## The pure-Go codec VFS — `internal/engine/vfs/codec.go` + +The write side upstream modernc left null. It is a read-write, os-backed +`sqlite3_vfs` whose io_methods (`codecio`, wired via the ccgo reinterpret idiom) +apply the **hanzoai/sqlcipher** page codec on every read/write. `Register(dek)` +mallocs+registers a per-database VFS bound to the DEK and returns an unregister +closer; `driver_nocgo.OpenDB` opens through it with `sql.OpenDB(codecConnector{…})` +so the VFS (and the DEK) are torn down exactly when the `*sql.DB` closes. + +**Subtleties that will bite a refactor (all empirically established):** +- **Zero the reserve on decrypt.** SQLCipher's codec is normally a pager hook; + here it is a VFS shim UNDER the pager, so the engine computes WAL frame (and + rollback-journal) checksums over the PLAINTEXT page including its 80-byte + reserve. The codec overwrites that reserve with a fresh IV+HMAC each write, so + `codecRead` **zeros the reserve region** of every page it returns. The engine + zeros the full buffer of NEW pages; combined, every page the engine ever + checksums has a zero reserve → checksum is always over `[data‖zeros]` → + round-trips. Main-db pages carry no checksum, so zeroing the (pager-ignored) + reserve there is invisible and the on-disk bytes stay byte-identical to C. +- **In-process shm.** `codecio` is iVersion 2 with `xShmMap/xShmLock/xShmBarrier/ + xShmUnmap`: the wal-index is per-database heap memory (one `shm` per `codecVFS`), + locks are no-ops. This is why WAL — including the create-time DELETE→WAL + conversion — works with no `-shm` file. Correct for **exactly one connection**: + `OpenDB` sets `MaxOpenConns(1)`. A keyed DB is single-writer, single-process. +- **Create through an in-memory journal.** A new DB starts in DELETE mode; its + first writes and the DELETE→WAL switch need a rollback journal, which the codec + VFS **refuses** (MAIN_JOURNAL → CANTOPEN, fail-closed — it would put plaintext + page images on disk). So `openDB` → `ensureWAL`: read `journal_mode`; if not + `wal`, set `journal_mode=MEMORY` (in-memory rollback journal, no `-journal` + file) then `journal_mode=WAL`. Already-WAL DBs are left alone (no churn). The + DELETE→WAL step MUST run on an established connection, not during the + connection's own setup pragmas. +- **temp_store=MEMORY** keeps temp/statement spill in RAM — no plaintext temp + files. So the only files on disk are the encrypted main DB and `-wal`. +- **Page size fixed at 4096, reserve 80** (SQLCipher-4 defaults); salt = page 1's + first 16 bytes in the clear, read on open (existing) or freshly random (new). + +## File map + +- `sqlite.go` — tag-neutral: `Config`, `Option`, `WithKey/WithRawKey/WithPrincipalKey`, `DB`, `Open()`, `EncryptionAvailable()` (true both tags), `CodecLinked()` (runtime codec probe; true on pure-Go, true on a linked cgo build). +- `cek.go` — tag-neutral, pure Go: envelope key handling (below). +- `threshold.go` — tag-neutral: `ThresholdManager` (t-of-n Ed25519 write attestation). +- `driver_nocgo.go` (`//go:build !cgo`) — imports the vendored engine + codec VFS; `EncryptionAvailable()=true`; keyed `OpenDB` → codec VFS + `ensureWAL`; `DSN(path,nil)` = plain, `DSN(path,key)` panics (the key binds to the VFS, use OpenDB). +- `driver_cgo.go` (`//go:build cgo`) — registers `sqlite`→**hanzoai/csqlite**; keys via SQLCipher URI `key=x'HEX'`; path percent-escaped so `?`/`#` can't strip `key=`. +- `internal/engine/**` — the vendored pure-Go SQLite engine (fork; see above). +- `encryption_proof_test.go`, `sqlcipher_pure_test.go` — anti-silent-plaintext gate + pure-Go WAL round-trip + byte-compat both directions (opens a C-written fixture; decrypts driver-written bytes with the standalone codec). ## Envelope encryption — rotation-safe (read before touching key handling) -Each database has its OWN random 256-bit **DEK** (`NewDEK`), set once at -creation; SQLCipher encrypts pages with it and it NEVER changes. The DEK is -**wrapped** (AES-256-GCM) under a **KEK** = `DeriveKey(masterKey, principal, id)` -and the wrapped blob is stored beside the file (consumer owns the sidecar). To -open: unwrap with the KEK → DEK → SQLCipher. To **rotate the master key**: -unwrap with the old KEK, rewrap with the new KEK, replace the sidecar — the DEK -is unchanged so pages are untouched, O(1), never bricks. (The old "page key = -HKDF(master)" scheme could not rotate: a new master changed the page key and -SQLCipher rejected every existing file.) +Each database has its OWN random 256-bit **DEK** (`NewDEK`), set once at creation; +pages are encrypted with it and it NEVER changes. The DEK is **wrapped** +(AES-256-GCM) under a **KEK** = `DeriveKey(masterKey, principal, id)` and the +wrapped blob is stored beside the file (consumer owns the sidecar). Open: unwrap → +DEK → open. **Rotate the master key:** unwrap with old KEK, rewrap with new KEK, +replace the sidecar — the DEK is unchanged so pages are untouched, O(1), never +bricks. HKDF `info` is **length-prefixed** (`lp(type)||lp(id)`) → injective, so `(org,"a:b")` ≠ `("org:a","b")`. The SAME encoding is exposed as `PrincipalAAD` -and bound into the wrap as GCM **AAD** (`WrapDEK(kek, dek, aad)` / -`UnwrapDEK(kek, blob, aad)`), so a wrapped DEK is also cryptographically bound to -its principal — a sidecar moved to another principal fails the tag even if a KEK -ever collided (defense-in-depth). The on-disk AAD is `version-byte || aad`, so a -version downgrade is unforgeable too. `cache=shared` is applied ONLY to -unencrypted DSNs — on a keyed DB the shared page cache holds DECRYPTED pages and -a wrong-key reopen would read them (isolation break), so it is never set on -encrypted files. - -## CRITICAL — how SQLCipher actually works here (don't repeat the bug) - -mainline `mattn/go-sqlite3` has **NO `sqlcipher` build tag** and no `sqlite3_key` -binding. `-tags sqlcipher` is **inert → ships PLAINTEXT**. It also **cannot reopen** -a SQLCipher DB from a `ConnectHook` (mattn runs `PRAGMA busy_timeout/journal_mode/…` -before the hook → "file is not a database"). Proven dead ends. The working path: +and bound into the wrap as GCM **AAD**, so a wrapped DEK is cryptographically +bound to its principal (a sidecar moved to another principal fails the tag). The +on-disk AAD is `version-byte || aad`, so a version downgrade is unforgeable. +`cache=shared` is applied ONLY to unencrypted DSNs. + +## CGO backend recipe (secondary / perf path) ```sh CGO_ENABLED=1 \ @@ -57,29 +117,20 @@ CGO_LDFLAGS="-lsqlcipher" \ go build -tags "libsqlite3 sqlite_fts5" ./... ``` -The key rides the DSN as SQLCipher's **native URI param** `file:PATH?...&key=x'HEX'`, -applied inside `sqlite3_open_v2` before any pragma → create AND reopen work. -**Never log the DSN** (it contains the key). `TestEncryptionProof` fails a -mis-linked build instead of shipping plaintext. - -**The `Dockerfile` builds with this exact recipe** (`-tags "libsqlite3 -sqlite_fts5"` + the codec CFLAGS/LDFLAGS, headers under `/usr/include/sqlcipher` -from Debian `libsqlcipher-dev`) and runs the test stage with -`SQLITE_REQUIRE_CODEC=1`, which turns `TestEncryptionProof`'s "codec unlinked" -SKIP into a HARD FAILURE — so the image's own gate asserts real ciphertext and a -regression to the inert `-tags sqlcipher` recipe fails the build. (Earlier the -Dockerfile used the inert tags → `CodecLinked()=false` → the proof silently -skipped: a green build proving nothing.) +hanzoai/csqlite keys the DB through SQLCipher's native URI param +`file:PATH?...&key=x'HEX'` at `sqlite3_open_v2` time (create AND reopen work). +**Never log the DSN** (it contains the key). A cgo build that forgets to link +libsqlcipher silently writes plaintext; `CodecLinked()` proves the codec at +runtime and `TestEncryptionProof` (with `SQLITE_REQUIRE_CODEC=1` in the Dockerfile +stage) fails such a build. ## Consumers -Hanzo IAM (`object/orgdb.go`) per-org encrypted DBs: `OpenDB(path, DeriveKey(mk, -PrincipalOrg, slug))` → `xorm.NewEngineWithDB("sqlite", "", core.FromDB(db))`. +Hanzo IAM / cloud (`cek/cek.go`, per-principal encrypted stores): +`OpenDB(path, dek)` where `dek = UnwrapDEK(DeriveKey(masterKey, principal, id), blob, PrincipalAAD(principal, id))`. ## Versioning -PATCH bumps only (v0.1.x). Current: v0.1.4. - -- v0.1.4 — `WrapDEK`/`UnwrapDEK` take a principal-binding GCM `aad` + add - `PrincipalAAD` (defense-in-depth). Dockerfile fixed to link the codec and - self-assert via `SQLITE_REQUIRE_CODEC=1` (was inert-tag CI-theater). +PATCH bumps only. Current: **v0.3.1** — pure-Go backend now ENCRYPTS via the +vendored engine + hanzoai/sqlcipher codec VFS (was: `ErrEncryptionUnavailable`); +zero `modernc.org/*` modules; CGO backend migrated mattn/go-sqlite3 → hanzoai/csqlite. diff --git a/README.md b/README.md index 840c3bd..6062f38 100644 --- a/README.md +++ b/README.md @@ -4,35 +4,33 @@ Dual-backend SQLite driver for the Hanzo ecosystem. Registers the `database/sql` driver name **`sqlite`** under both build configurations and -exposes the same API either way: +exposes the same API either way. **Both backends encrypt at rest, in the same +SQLCipher-4 format** — a database written by one opens under the other. | Build | Backend | Encryption | Use | |-------|---------|------------|-----| -| `CGO_ENABLED=1` + `-tags libsqlite3` + libsqlcipher | mattn/go-sqlite3 → SQLCipher | AES-256 page-level, at rest | **production** | -| `CGO_ENABLED=0` | modernc.org/sqlite (pure Go) | none | CI tests / lint / local dev | +| `CGO_ENABLED=0` (default) | vendored pure-Go engine + **hanzoai/sqlcipher** codec VFS | AES-256 page-level, at rest | **default** — CI, tests, pure-Go deploys | +| `CGO_ENABLED=1` + `-tags libsqlite3` + libsqlcipher | **hanzoai/csqlite** → SQLCipher | AES-256 page-level, at rest | the C engine, for speed | -One import, one driver name, two backends: +One import, one driver name, two backends, one format: ```go import _ "github.com/hanzoai/sqlite" // registers "sqlite" under both tags -db, _ := sql.Open("sqlite", dsn) // mattn+SQLCipher (cgo) or modernc (!cgo) +db, _ := sql.Open("sqlite", dsn) // pure-Go codec VFS (!cgo) or csqlite+SQLCipher (cgo) ``` -The pure-Go backend **cannot encrypt**. Demanding a key on it -(`Open(path, WithKey(...))`, `OpenDB(path, key)`) returns -`ErrEncryptionUnavailable` and writes nothing — it never silently persists -plaintext. +The pure-Go backend **always encrypts** — no cgo, no external C library, nothing +to link, and **`go list -m all` shows zero `modernc.org/*`** (the engine is +vendored in-tree). A keyed database is single-writer, single-process (WAL on an +in-process wal-index). -## Building the encrypted (production) backend — READ THIS +## Building the CGO backend (optional, for the C engine's speed) -mainline `mattn/go-sqlite3` has **no `sqlcipher` build tag** and no -`sqlite3_key()` binding. SQLCipher works only when you: - -1. link the **system** sqlite (the `libsqlite3` tag) against **libsqlcipher**, and -2. enable the codec + URI keying via CGO flags, and -3. supply the key as SQLCipher's **native URI `key` parameter** so it is applied - inside `sqlite3_open_v2` — *before* mattn's pragma battery runs. +The default `CGO_ENABLED=0` build already encrypts and needs no flags. The CGO +backend uses hanzoai/csqlite linked against libsqlcipher, with the key supplied as +SQLCipher's native URI `key` parameter (applied inside `sqlite3_open_v2`, so create +and reopen both work): ```sh CGO_ENABLED=1 \ @@ -41,25 +39,13 @@ CGO_LDFLAGS="-L/lib -lsqlcipher" \ go build -tags "libsqlite3 sqlite_fts5" ./... ``` -Alpine: `apk add gcc musl-dev sqlcipher-dev pkgconfig`. - -### Why not `-tags sqlcipher` + `PRAGMA key` in a ConnectHook? - -Both are traps that ship **plaintext**: - -- `-tags sqlcipher` is inert in mainline mattn (no such tag) → links plain - sqlite → `PRAGMA key` is a silent no-op. -- mattn runs `PRAGMA busy_timeout/journal_mode/foreign_keys/...` via - `sqlite3_exec` **before** the ConnectHook fires. On an existing encrypted file - that touches the header before the key is set → `file is not a database` on - reopen. So a ConnectHook can *create* but never *reopen* a SQLCipher DB. - -The URI `key` parameter sidesteps both: SQLCipher's VFS keys the connection at -open time. `TestEncryptionProof` asserts real ciphertext on disk and a working -keyed reopen, so a mis-linked build **fails CI** instead of shipping plaintext. +Alpine: `apk add gcc musl-dev sqlcipher-dev pkgconfig`. A cgo build that forgets +to link libsqlcipher silently writes plaintext; `CodecLinked()` proves the codec +at runtime and `TestEncryptionProof` fails such a build. -> The key rides the DSN (`file:PATH?...&key=x'HEX'`). **Never log the DSN.** -> IAM keeps `showSql=false` and does not log it. +> On the CGO backend the key rides the DSN (`file:PATH?...&key=x'HEX'`). **Never +> log the DSN.** On the pure-Go backend the key never touches the DSN — it binds +> to the codec VFS. ## Encryption diff --git a/driver_cgo.go b/driver_cgo.go index 0a6ef5b..9150b8b 100644 --- a/driver_cgo.go +++ b/driver_cgo.go @@ -9,40 +9,38 @@ import ( "net/url" "strings" - sqlite3 "github.com/mattn/go-sqlite3" + csqlite "github.com/hanzoai/csqlite" ) -// ErrEncryptionUnavailable is returned when an encryption key is supplied to a -// backend that cannot encrypt. Never returned by the CGO backend. -var ErrEncryptionUnavailable = errors.New("sqlite: encryption requested but this build has no SQLCipher backend (build with CGO_ENABLED=1 -tags libsqlite3 linked against libsqlcipher)") +// ErrEncryptionUnavailable is retained for API symmetry with the pure-Go backend. +// It is never returned by the CGO backend, which encrypts through libsqlcipher. +var ErrEncryptionUnavailable = errors.New("sqlite: encryption unavailable") -// init registers the "sqlite" database/sql driver name — the same name -// modernc.org/sqlite registers under the !cgo backend — backed here by -// go-sqlite3 (CGO) linked against libsqlcipher. go-sqlite3 also registers -// "sqlite3" in its own init, so both names resolve to the same engine. +// init registers the "sqlite" database/sql driver name — the same name the pure-Go +// backend registers under !cgo — backed here by Hanzo's csqlite (a self-contained +// cgo SQLite binding) linked against libsqlcipher. csqlite also registers "sqlite3" +// in its own init, so both names resolve to the same engine. // // HOW ENCRYPTION WORKS (read before changing anything): // -// Real at-rest encryption requires the production build to: +// The production build links the SQLCipher codec: // // CGO_ENABLED=1 // -tags "libsqlite3 sqlite_fts5" # link the SYSTEM sqlite, not the vendored amalgamation // CGO_CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_USE_URI=1 -I/include/sqlcipher" // CGO_LDFLAGS="-L/lib -lsqlcipher" // -// mainline mattn/go-sqlite3 has NO `sqlcipher` build tag and no sqlite3_key() -// binding. It also CANNOT key a database from a ConnectHook: Open() runs a -// battery of PRAGMAs (busy_timeout, journal_mode, foreign_keys, ...) via -// sqlite3_exec BEFORE the ConnectHook fires, which touches the header of an -// existing encrypted file and fails with "file is not a database" on reopen. -// -// The working mechanism is SQLCipher's NATIVE URI key parameter: with +// csqlite keys a database through SQLCipher's NATIVE URI key parameter: with // SQLITE_USE_URI=1, a `file:PATH?...&key=x'HEX'` DSN is keyed by SQLCipher's VFS -// at sqlite3_open_v2 time — before mattn runs any pragma — so both create AND -// reopen succeed. The key therefore rides the DSN (see DSN below). Callers MUST -// keep that DSN out of logs (IAM sets showSql=false and never logs the DSN). +// at sqlite3_open_v2 time — before any connect-time pragma runs — so both create +// AND reopen succeed. The key therefore rides the DSN (see DSN below). Callers +// MUST keep that DSN out of logs (IAM sets showSql=false and never logs the DSN). +// +// Both backends write the SAME SQLCipher-4 on-disk format, so a database created +// by this CGO backend opens under the pure-Go backend (hanzoai/sqlite + +// hanzoai/sqlcipher) and vice versa. func init() { - sql.Register("sqlite", &sqlite3.SQLiteDriver{}) + sql.Register("sqlite", &csqlite.SQLiteDriver{}) } // EncryptionAvailable reports that this build's backend can encrypt at rest. @@ -50,9 +48,9 @@ func init() { // It returns true for the CGO backend, which is a BACKEND-capability flag, not a // proof that libsqlcipher is actually linked: a CGO build WITHOUT the codec links // plain sqlite and silently no-ops the key (writes plaintext). The production -// Dockerfile links libsqlcipher; the package's encryption-proof test verifies -// real ciphertext at runtime so a mis-linked build fails CI instead of shipping -// plaintext. +// Dockerfile links libsqlcipher; the package's encryption-proof test verifies real +// ciphertext at runtime (CodecLinked) so a mis-linked build fails CI instead of +// shipping plaintext. func EncryptionAvailable() bool { return true } // OpenDB opens *path* as a database/sql DB on the CGO/SQLCipher backend with the @@ -63,7 +61,7 @@ func OpenDB(path string, rawKey []byte) (*sql.DB, error) { return openDB(path, &Config{RawKey: rawKey}) } -// openDB opens the database on the mattn/SQLCipher backend using the SQLCipher +// openDB opens the database on the csqlite/SQLCipher backend using the SQLCipher // URI key parameter (keyed at open time, reopen-safe). func openDB(path string, cfg *Config) (*sql.DB, error) { db, err := sql.Open("sqlite", DSN(path, cfg.RawKey)) @@ -73,20 +71,19 @@ func openDB(path string, cfg *Config) (*sql.DB, error) { return db, nil } -// DSN builds a canonical IAM SQLite DSN for the active (CGO/mattn/SQLCipher) +// DSN builds a canonical IAM SQLite DSN for the active (CGO/csqlite/SQLCipher) // backend. // // When rawKey is non-nil it is emitted as SQLCipher's native `key=x'HEX'` URI -// parameter, which SQLCipher applies inside sqlite3_open_v2 — before mattn's -// pragma battery — making the connection reopen-safe. The DSN consequently -// CONTAINS the key; callers MUST NOT log it. +// parameter, which SQLCipher applies inside sqlite3_open_v2 — before any pragma — +// making the connection reopen-safe. The DSN consequently CONTAINS the key; +// callers MUST NOT log it. // -// rawKey must be exactly 32 bytes when non-nil (validated by Open; OpenDB -// trusts its caller). A nil key yields an unencrypted DSN for the global/dev/test -// engine. +// rawKey must be exactly 32 bytes when non-nil (validated by Open; OpenDB trusts +// its caller). A nil key yields an unencrypted DSN for the global/dev/test engine. // -// The path is percent-escaped (escapeDBPath): a path containing '?' or '#' -// would otherwise prematurely terminate the file portion of the DSN and DROP the +// The path is percent-escaped (escapeDBPath): a path containing '?' or '#' would +// otherwise prematurely terminate the file portion of the DSN and DROP the // trailing query params — including `key=` — which would silently open the // database UNENCRYPTED. Escaping makes that impossible regardless of caller input. func DSN(path string, rawKey []byte) string { @@ -102,20 +99,19 @@ func DSN(path string, rawKey []byte) string { params = append(params, fmt.Sprintf("key=x'%x'", rawKey)) } else { // cache=shared ONLY on the unencrypted path (parity with the legacy - // global/dev DSN). It is a SECURITY HAZARD on keyed databases: the - // shared in-process page cache holds DECRYPTED pages, so a later - // connection opened with the WRONG key reads cached plaintext instead - // of being rejected — defeating per-key isolation. Never share the - // cache across an encrypted file. + // global/dev DSN). It is a SECURITY HAZARD on keyed databases: the shared + // in-process page cache holds DECRYPTED pages, so a later connection opened + // with the WRONG key reads cached plaintext instead of being rejected — + // defeating per-key isolation. Never share the cache across an encrypted file. params = append(params, "cache=shared") } return fmt.Sprintf("file:%s?%s", escapeDBPath(path), strings.Join(params, "&")) } -// escapeDBPath percent-encodes a filesystem path for safe embedding in the -// opaque portion of a `file:PATH?query` SQLite DSN. It preserves '/' (path -// separators stay readable) but escapes '?' and '#' (and any other reserved -// character) so they can never terminate the path early and strip query params. +// escapeDBPath percent-encodes a filesystem path for safe embedding in the opaque +// portion of a `file:PATH?query` SQLite DSN. It preserves '/' (path separators stay +// readable) but escapes '?' and '#' (and any other reserved character) so they can +// never terminate the path early and strip query params. func escapeDBPath(path string) string { // url.PathEscape escapes '?' and '#' but also escapes '/'; restore '/'. return strings.ReplaceAll(url.PathEscape(path), "%2F", "/") diff --git a/driver_nocgo.go b/driver_nocgo.go index a952390..61f81f3 100644 --- a/driver_nocgo.go +++ b/driver_nocgo.go @@ -3,70 +3,143 @@ package sqlite import ( + "context" "database/sql" + "database/sql/driver" "errors" "fmt" "net/url" "strings" - // modernc.org/sqlite registers the "sqlite" database/sql driver in its own - // init(). Blank-importing it here gives the !cgo build a working pure-Go - // "sqlite" driver — the same driver name the CGO backend registers — so - // CGO-off CI (tests + lint) and local dev run without a C toolchain. - // - // NOTE: this backend does NOT encrypt. Open() rejects any encryption key - // before reaching openDB, so plaintext is never silently written when a - // caller asked for encryption. - _ "modernc.org/sqlite" + // engine is Hanzo's vendored pure-Go SQLite engine; importing it runs its + // init(), which registers the "sqlite" database/sql driver name — the same + // name the CGO backend registers — so one import + sql.Open("sqlite", …) + // works identically under both build tags. + engine "github.com/hanzoai/sqlite/internal/engine" + // vfs is the pure-Go SQLCipher codec VFS: it applies the hanzoai/sqlcipher + // page format on every read/write, giving this CGO-free build REAL at-rest + // encryption byte-compatible with C SQLCipher. + "github.com/hanzoai/sqlite/internal/engine/vfs" ) -// ErrEncryptionUnavailable is returned when an encryption key is supplied to -// this pure-Go backend, which cannot encrypt at rest. The remediation must NOT -// say `-tags sqlcipher` (that tag is inert in mainline mattn and ships -// plaintext) — the real recipe is the libsqlite3 tag linked against libsqlcipher. -var ErrEncryptionUnavailable = errors.New("sqlite: encryption requested but this build has no SQLCipher backend (build with CGO_ENABLED=1 -tags libsqlite3 linked against libsqlcipher)") +const driverName = "sqlite" -// EncryptionAvailable reports that this build CANNOT encrypt at rest (always -// false for the pure-Go backend). -func EncryptionAvailable() bool { return false } +// ErrEncryptionUnavailable is retained for API symmetry with the CGO backend. It +// is never returned now: the pure-Go backend encrypts via the vendored engine + +// the hanzoai/sqlcipher codec VFS, so encryption is always available. +var ErrEncryptionUnavailable = errors.New("sqlite: encryption unavailable") -// OpenDB opens *path* as a database/sql DB on the pure-Go backend. A non-nil key -// is a hard error: this backend cannot encrypt and must never silently persist -// plaintext when a caller asked for encryption. Mirrors the CGO backend's -// signature so callers compile identically under both build tags. +// EncryptionAvailable reports that this build can encrypt at rest. The pure-Go +// backend now encrypts through the hanzoai/sqlcipher codec VFS, so this is true +// under both build tags — there is no longer a plaintext-only backend. +func EncryptionAvailable() bool { return true } + +// OpenDB opens *path* as a database/sql DB on the pure-Go backend with the given +// raw 256-bit key. A nil key opens unencrypted; a non-nil key opens through the +// SQLCipher codec VFS (real page-level AES-256 encryption at rest). Mirrors the +// CGO backend's signature so callers compile identically under both build tags. func OpenDB(path string, rawKey []byte) (*sql.DB, error) { return openDB(path, &Config{RawKey: rawKey}) } -// openDB opens the database on the pure-Go modernc backend. A configured key is -// a programming error here: Open() returns ErrEncryptionUnavailable before this -// is reached, but we defend the invariant at the boundary too. +// openDB opens the database on the pure-Go engine. With a key it registers a +// per-database codec VFS and opens through it; the VFS is unregistered when the +// returned *sql.DB is closed (the connector implements io.Closer). func openDB(path string, cfg *Config) (*sql.DB, error) { - if cfg.RawKey != nil { - return nil, ErrEncryptionUnavailable + if cfg.RawKey == nil { + db, err := sql.Open(driverName, DSN(path, nil)) + if err != nil { + return nil, fmt.Errorf("sqlite: open %s: %w", path, err) + } + return db, nil } - db, err := sql.Open("sqlite", buildDSN(path, cfg)) + + vfsName, closer, err := vfs.Register(cfg.RawKey) if err != nil { - return nil, fmt.Errorf("sqlite: open %s: %w", path, err) + return nil, fmt.Errorf("sqlite: register codec vfs for %s: %w", path, err) + } + cc := &codecConnector{inner: engine.Connector(keyedDSN(path, vfsName)), closer: closer} + db := sql.OpenDB(cc) + // The codec VFS keeps the wal-index in per-database heap memory with no-op shm + // locks, which is correct for exactly one connection. Cap the pool at one (also + // how the encrypted stores are opened upstream). A keyed database is therefore + // single-writer, single-process. + db.SetMaxOpenConns(1) + if err := ensureWAL(db); err != nil { + db.Close() + return nil, fmt.Errorf("sqlite: enable WAL on %s: %w", path, err) } return db, nil } -func buildDSN(path string, cfg *Config) string { - return DSN(path, nil) +// ensureWAL puts a keyed database into WAL mode. A new or DELETE-mode database is +// converted through an IN-MEMORY rollback journal (journal_mode=MEMORY), so the +// conversion — and the create-time writes before it — never place a plaintext page +// image on a -journal file on disk. The codec VFS therefore never has to encrypt a +// rollback journal, and refuses one outright (fail-closed). An already-WAL database +// is left as is (no WAL→MEMORY→WAL churn). The DELETE→WAL step must run on an +// established connection, not during the connection's own setup pragmas. +func ensureWAL(db *sql.DB) error { + var mode string + if err := db.QueryRow("PRAGMA journal_mode").Scan(&mode); err != nil { + return err + } + if strings.EqualFold(mode, "wal") { + return nil + } + if _, err := db.Exec("PRAGMA journal_mode=MEMORY"); err != nil { + return err + } + if err := db.QueryRow("PRAGMA journal_mode=WAL").Scan(&mode); err != nil { + return err + } + if !strings.EqualFold(mode, "wal") { + return fmt.Errorf("journal_mode is %q, want wal", mode) + } + return nil +} + +// codecConnector wraps the engine connector with the codec VFS's unregister +// closer. database/sql calls Close on a connector that implements io.Closer when +// its *sql.DB is closed, so the per-database VFS is torn down at exactly the right +// time — and the DEK it holds is wiped. +type codecConnector struct { + inner driver.Connector + closer func() error +} + +func (c *codecConnector) Connect(ctx context.Context) (driver.Conn, error) { + return c.inner.Connect(ctx) +} +func (c *codecConnector) Driver() driver.Driver { return c.inner.Driver() } +func (c *codecConnector) Close() error { return c.closer() } + +// keyedDSN builds the DSN for an encrypted database: it selects the per-database +// codec VFS, declares the 80-byte SQLCipher reserve so page 1 is created with room +// for the IV+HMAC trailer, enables WAL (served by the codec VFS's in-process +// wal-index), and keeps temp storage in memory so no plaintext spill ever reaches +// disk. +func keyedDSN(path, vfsName string) string { + params := []string{ + "vfs=" + vfsName, + "_reserve_bytes=80", + "_pragma=busy_timeout(10000)", + "_pragma=synchronous(NORMAL)", + "_pragma=temp_store(MEMORY)", + "_pragma=foreign_keys(ON)", + } + return fmt.Sprintf("file:%s?%s", escapeDBPath(path), strings.Join(params, "&")) } -// DSN builds a canonical IAM SQLite DSN for the active (pure-Go modernc) -// backend. modernc uses the `_pragma=NAME(VALUE)` query form; the mattn-style -// `_busy_timeout=N` params it silently IGNORES, so emitting the correct form -// here is what actually applies WAL + busy_timeout on the !cgo path. -// -// rawKey MUST be nil — the pure-Go backend cannot encrypt. A non-nil key -// triggers a panic rather than emitting a plaintext DSN, because reaching here -// with a key means an upstream encryption guard was bypassed. +// DSN builds a canonical IAM SQLite DSN for the pure-Go engine. It is only for the +// UNENCRYPTED path (rawKey == nil): the engine uses the `_pragma=NAME(VALUE)` query +// form. On the pure-Go backend the encryption key does NOT ride the DSN — it is +// bound to the codec VFS — so a non-nil key here is a programming error (use +// OpenDB), and DSN panics rather than emit a DSN that would silently open the +// database unencrypted. func DSN(path string, rawKey []byte) string { if rawKey != nil { - panic("sqlite: DSN called with a key on the pure-Go backend — encryption is unavailable without CGO+SQLCipher") + panic("sqlite: DSN cannot carry a key on the pure-Go backend — the key binds to the codec VFS; use OpenDB(path, key)") } params := []string{ "_pragma=busy_timeout(10000)", @@ -75,13 +148,12 @@ func DSN(path string, rawKey []byte) string { "_pragma=foreign_keys(ON)", "cache=shared", } - // Escape the path so '?'/'#' in a path can't terminate it early and strip - // query params (parity with the cgo backend; defense in depth). return fmt.Sprintf("file:%s?%s", escapeDBPath(path), strings.Join(params, "&")) } // escapeDBPath percent-encodes a filesystem path for safe embedding in a -// `file:PATH?query` DSN, preserving '/' but escaping '?' and '#'. +// `file:PATH?query` DSN, preserving '/' but escaping '?' and '#' so they cannot +// terminate the path early and strip query params. func escapeDBPath(path string) string { return strings.ReplaceAll(url.PathEscape(path), "%2F", "/") } diff --git a/encryption_proof_test.go b/encryption_proof_test.go index ea59498..b5cc994 100644 --- a/encryption_proof_test.go +++ b/encryption_proof_test.go @@ -9,17 +9,17 @@ import ( // TestEncryptionProof is the anti-silent-plaintext gate. // -// On the !cgo (pure-Go) backend, encryption is unavailable: Open with a key MUST -// return ErrEncryptionUnavailable and never write a file. +// Both backends encrypt at rest now: the pure-Go (!cgo) backend through the +// vendored engine + the hanzoai/sqlcipher codec VFS, the cgo backend through +// libsqlcipher. EncryptionAvailable() is therefore true under both tags. // -// On the cgo backend, EncryptionAvailable() reports true — but that is only a -// backend-capability flag. A cgo build that forgot to link libsqlcipher (e.g. a -// regression back to the inert `-tags sqlcipher`) links plain sqlite and silently -// writes PLAINTEXT. This test forces the issue: under cgo it writes a known -// marker under a key and asserts the on-disk bytes are real ciphertext (no -// "SQLite format 3" header, marker absent) AND that the data survives a reopen -// with the same key. A mis-linked production build therefore FAILS CI instead of -// shipping a plaintext database. +// The one remaining silent-plaintext risk is a cgo build that forgot to LINK +// libsqlcipher (a regression to the inert `-tags sqlcipher`): it links plain +// sqlite and no-ops the key. CodecLinked() proves the codec at runtime and is +// always true on the pure-Go backend (nothing to mis-link) and on a correctly +// linked cgo build. This test writes a known marker under a key and asserts the +// on-disk bytes are real ciphertext (no "SQLite format 3" header, marker absent) +// AND that the data survives a reopen with the same key. func TestEncryptionProof(t *testing.T) { const marker = "anti-plaintext-canary-7f3a" key := make([]byte, 32) @@ -31,32 +31,21 @@ func TestEncryptionProof(t *testing.T) { dbPath := filepath.Join(dir, "proof.db") if !EncryptionAvailable() { - // Pure-Go backend: a keyed Open must be refused, with no file created. - if _, err := Open(dbPath, WithRawKey(key)); err != ErrEncryptionUnavailable { - t.Fatalf("!cgo Open with key: got err=%v, want ErrEncryptionUnavailable", err) - } - if _, statErr := os.Stat(dbPath); !os.IsNotExist(statErr) { - t.Fatalf("!cgo backend created a file for a refused encrypted open: %v", statErr) - } - return + t.Fatal("EncryptionAvailable() is false: every build encrypts now") } - // CGO build advertised as encryption-capable, but the codec may not be - // linked (a CGO build without libsqlcipher silently writes plaintext). SKIP - // rather than fail in that case — the hard ciphertext gate runs in the - // Dockerfile build, which links libsqlcipher. CI pins CGO_ENABLED=0 (the - // refuse branch above); a local `-tags libsqlite3` + libsqlcipher build runs - // the full ciphertext assertions below. + // A cgo build without libsqlcipher linked silently writes plaintext. SKIP the + // ciphertext assertions in that one case — the Dockerfile build links + // libsqlcipher and is the hard gate. The pure-Go backend and a correctly + // linked cgo build both report CodecLinked()=true and run the full proof. // - // EXCEPTION: when SQLITE_REQUIRE_CODEC=1 the skip becomes a HARD FAILURE. The - // Dockerfile sets it so the image's own test stage cannot go green on the - // inert-tag recipe (the V7 "CI-theater" footgun): a build that claims to ship - // encryption but didn't link the codec FAILS here instead of skipping. + // EXCEPTION: SQLITE_REQUIRE_CODEC=1 turns the skip into a HARD FAILURE, so an + // image that claims encryption but didn't link the codec fails here. if !CodecLinked() { if os.Getenv("SQLITE_REQUIRE_CODEC") == "1" { - t.Fatal("SQLITE_REQUIRE_CODEC=1 but CodecLinked()=false: this build advertises encryption (cgo) yet did NOT link libsqlcipher — it would ship PLAINTEXT. Build with -tags \"libsqlite3 sqlite_fts5\" + CGO_CFLAGS=-DSQLITE_HAS_CODEC -DSQLITE_USE_URI=1 + CGO_LDFLAGS=-lsqlcipher") + t.Fatal("SQLITE_REQUIRE_CODEC=1 but CodecLinked()=false: this cgo build advertises encryption yet did NOT link libsqlcipher — it would ship PLAINTEXT. Build with -tags \"libsqlite3 sqlite_fts5\" + CGO_CFLAGS=-DSQLITE_HAS_CODEC -DSQLITE_USE_URI=1 + CGO_LDFLAGS=-lsqlcipher, or build CGO_ENABLED=0 for the pure-Go codec") } - t.Skip("cgo build without libsqlcipher linked; encryption assertions skipped (Dockerfile build is the hard gate)") + t.Skip("cgo build without libsqlcipher linked; encryption assertions skipped (pure-Go build and the Dockerfile build are the hard gates)") } // cgo backend with codec linked: prove the bytes on disk are ciphertext. diff --git a/go.mod b/go.mod index 533332c..a0a066d 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,14 @@ module github.com/hanzoai/sqlite go 1.26.4 require ( - github.com/mattn/go-sqlite3 v1.14.47 + github.com/dustin/go-humanize v1.0.1 + github.com/google/uuid v1.6.0 + github.com/hanzoai/sqlcipher v0.1.0 + github.com/mattn/go-isatty v0.0.20 + github.com/ncruces/go-strftime v1.0.0 + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec golang.org/x/crypto v0.50.0 - modernc.org/sqlite v1.48.0 + golang.org/x/sys v0.46.0 ) -require ( - github.com/dustin/go-humanize v1.0.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/ncruces/go-strftime v1.0.0 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - golang.org/x/sys v0.43.0 // indirect - modernc.org/libc v1.70.0 // indirect - modernc.org/mathutil v1.7.1 // indirect - modernc.org/memory v1.11.0 // indirect -) +require github.com/hanzoai/csqlite v0.1.0 diff --git a/go.sum b/go.sum index e823012..15ea7d1 100644 --- a/go.sum +++ b/go.sum @@ -1,55 +1,19 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= -github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= -github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/hanzoai/csqlite v0.1.0 h1:suwC3dh0INlfP/U0Es6cDf6JNQ+2+GVLLATPWCUux6k= +github.com/hanzoai/csqlite v0.1.0/go.mod h1:H31a/O6VXuklR9UBkgY++bmAK5uzVfXPqU0F6P9Wsos= +github.com/hanzoai/sqlcipher v0.1.0 h1:V9gKG3ZltN2ZCteDrOnXWfOeEe/YDhhUm9AorQEAuBo= +github.com/hanzoai/sqlcipher v0.1.0/go.mod h1:F0soUYM1i4sawOZUpRvVnWoUayPbeGVlGq01VXy9Aqg= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.47 h1:jOBI62gS7nKeZv+as1oGEy0+1qISgXwH/QBlR6KbfIo= -github.com/mattn/go-sqlite3 v1.14.47/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w= github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI= golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= -golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8= -golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w= -golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= -golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= -golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k= -golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0= -modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis= -modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= -modernc.org/ccgo/v4 v4.32.0 h1:hjG66bI/kqIPX1b2yT6fr/jt+QedtP2fqojG2VrFuVw= -modernc.org/ccgo/v4 v4.32.0/go.mod h1:6F08EBCx5uQc38kMGl+0Nm0oWczoo1c7cgpzEry7Uc0= -modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM= -modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU= -modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= -modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= -modernc.org/gc/v3 v3.1.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo= -modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY= -modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= -modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= -modernc.org/libc v1.70.0 h1:U58NawXqXbgpZ/dcdS9kMshu08aiA6b7gusEusqzNkw= -modernc.org/libc v1.70.0/go.mod h1:OVmxFGP1CI/Z4L3E0Q3Mf1PDE0BucwMkcXjjLntvHJo= -modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= -modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= -modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= -modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= -modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= -modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= -modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= -modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= -modernc.org/sqlite v1.48.0 h1:ElZyLop3Q2mHYk5IFPPXADejZrlHu7APbpB0sF78bq4= -modernc.org/sqlite v1.48.0/go.mod h1:hWjRO6Tj/5Ik8ieqxQybiEOUXy0NJFNp2tpvVpKlvig= -modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= -modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= -modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= -modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= diff --git a/internal/engine/LICENSE b/internal/engine/LICENSE new file mode 100644 index 0000000..867b0f3 --- /dev/null +++ b/internal/engine/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2017 The Sqlite Authors. 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 copyright holder nor the names of its 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 HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/internal/engine/backup.go b/internal/engine/backup.go new file mode 100644 index 0000000..556c2d3 --- /dev/null +++ b/internal/engine/backup.go @@ -0,0 +1,88 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "database/sql/driver" + + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +// Backup object is used to manage progress and cleanup an online backup. It +// is returned by NewBackup or NewRestore. +type Backup struct { + srcConn *conn // source database connection + dstConn *conn // destination database connection + pBackup uintptr // sqlite3_backup object pointer +} + +// Step will copy up to n pages between the source and destination databases +// specified by the backup object. If n is negative, all remaining source +// pages are copied. +// If it successfully copies n pages and there are still more pages to be +// copied, then the function returns true with no error. If it successfully +// finishes copying all pages from source to destination, then it returns +// false with no error. If an error occurs while running, then an error is +// returned. +func (b *Backup) Step(n int32) (bool, error) { + rc := sqlite3.Xsqlite3_backup_step(b.srcConn.tls, b.pBackup, n) + if rc == sqlite3.SQLITE_OK { + return true, nil + } else if rc == sqlite3.SQLITE_DONE { + return false, nil + } else { + return false, b.srcConn.errstr(rc) + } +} + +// Finish releases all resources associated with the Backup object. The Backup +// object is invalid and may not be used following a call to Finish. +func (b *Backup) Finish() error { + rc := sqlite3.Xsqlite3_backup_finish(b.srcConn.tls, b.pBackup) + b.dstConn.Close() + if rc == sqlite3.SQLITE_OK { + return nil + } else { + return b.srcConn.errstr(rc) + } +} + +// Remaining returns the number of source-database pages still to be backed +// up at the conclusion of the most recent [Backup.Step] call. The value is +// useful for driving progress UIs that need to estimate how much work is +// left. +// +// If Step has not yet been called on this Backup, or if the most recent +// Step returned false (SQLITE_DONE), Remaining returns 0. +// +// See https://www.sqlite.org/c3ref/backup_finish.html. +func (b *Backup) Remaining() int { + return int(sqlite3.Xsqlite3_backup_remaining(b.srcConn.tls, b.pBackup)) +} + +// PageCount returns the total number of pages in the source database at the +// conclusion of the most recent [Backup.Step] call. Pair with [Backup.Remaining] +// to compute progress as a fraction (PageCount - Remaining) / PageCount. +// +// See https://www.sqlite.org/c3ref/backup_finish.html. +func (b *Backup) PageCount() int { + return int(sqlite3.Xsqlite3_backup_pagecount(b.srcConn.tls, b.pBackup)) +} + +// Commit releases all resources associated with the Backup object but does not +// close the destination database connection. +// +// The destination database connection is returned to the caller or an error if raised. +// It is the responsibility of the caller to handle the connection closure. +func (b *Backup) Commit() (driver.Conn, error) { + rc := sqlite3.Xsqlite3_backup_finish(b.srcConn.tls, b.pBackup) + + if rc == sqlite3.SQLITE_OK { + return b.dstConn, nil + } else { + b.dstConn.Close() + return nil, b.srcConn.errstr(rc) + } +} diff --git a/internal/engine/conn.go b/internal/engine/conn.go new file mode 100644 index 0000000..b080966 --- /dev/null +++ b/internal/engine/conn.go @@ -0,0 +1,1361 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "context" + "database/sql/driver" + "fmt" + "strconv" + "strings" + "sync" + "time" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +type conn struct { + db uintptr // *sqlite3.Xsqlite3 + tls *libc.TLS + + // Context handling can cause conn.Close and conn.interrupt to be invoked + // concurrently. + sync.Mutex + + writeTimeFormat string + beginMode string + loc *time.Location + intToTime bool + textToTime bool + integerTimeFormat string + + // inMemory records whether the underlying database resides only in + // memory (DSN like ":memory:", "file::memory:", or a shared-cache + // memory URI). For such databases, dropping the *only* connection + // also drops the database itself, so IsValid must not discard the + // connection just because an in-flight query was interrupted. + // See #196. + inMemory bool + + // errorRcMode is the opt-in error-string reporting mode toggled by + // the _error_rc DSN parameter. When true, error strings synthesised + // from a (rc, db) pair only append sqlite3_errmsg(db) when + // sqlite3_extended_errcode(db) matches the operation rc (full, then + // primary code); on mismatch the canonical sqlite3_errstr(rc) is used + // alone. Default false keeps the legacy "errstr: errmsg" form + // byte-for-byte so existing callers parsing error strings are + // unaffected. See #230. + errorRcMode bool +} + +func newConn(dsn string) (*conn, error) { + var query, vfsName string + + // Parse the query parameters from the dsn and them from the dsn if not prefixed by file: + // https://github.com/mattn/go-sqlite3/blob/3392062c729d77820afc1f5cae3427f0de39e954/sqlite3.go#L1046 + // https://github.com/mattn/go-sqlite3/blob/3392062c729d77820afc1f5cae3427f0de39e954/sqlite3.go#L1383 + pos := strings.IndexRune(dsn, '?') + if pos >= 1 { + query = dsn[pos+1:] + var err error + vfsName, err = getVFSName(query) + if err != nil { + return nil, err + } + + if !strings.HasPrefix(dsn, "file:") { + dsn = dsn[:pos] + } + } + + // _error_rc is parsed before openV2 so open-time failures (e.g. + // SQLITE_CANTOPEN on a path the process cannot create) get the + // conditional errmsg treatment too. The temporary db handle that + // sqlite3_open_v2 leaves behind on failure carries a stale + // errmsg from earlier initialisation, and the legacy "errstr: + // errmsg" form surfaces that as a misleading message. See #230. + errorRcMode, err := getErrorRcMode(query) + if err != nil { + return nil, err + } + c := &conn{tls: libc.NewTLS(), errorRcMode: errorRcMode} + // The withOpenGate wrapper marks the page-cache opened flag and holds + // pcacheState.openGate.RLock for the duration of sqlite3_open_v2, so + // any concurrent RegisterPageCache blocks until this Open + // completes. sqlite3_initialize fires implicitly inside openV2 the + // first time; after that point SQLITE_CONFIG_PCACHE2 can no longer be + // installed. See pagecache.go for the lifecycle contract. + var db uintptr + if gateErr := withOpenGate(func() error { + db, err = c.openV2( + dsn, + vfsName, + sqlite3.SQLITE_OPEN_READWRITE|sqlite3.SQLITE_OPEN_CREATE| + sqlite3.SQLITE_OPEN_FULLMUTEX| + sqlite3.SQLITE_OPEN_URI, + ) + return err + }); gateErr != nil { + c.tls.Close() + return nil, gateErr + } + + c.db = db + if err = c.extendedResultCodes(true); err != nil { + c.Close() + return nil, err + } + + // sqlite3_db_filename returns an empty string for databases that + // are not backed by a file (":memory:", "file::memory:", shared-cache + // memory URIs, temporary databases). Cache the answer once so we + // don't have to re-derive it on every IsValid call. + zMain, mainErr := libc.CString("main") + if mainErr != nil { + c.Close() + return nil, mainErr + } + defer libc.Xfree(c.tls, zMain) + c.inMemory = libc.GoString(sqlite3.Xsqlite3_db_filename(c.tls, c.db, zMain)) == "" + + // _dqs is applied before applyQueryParams because the SQLite contract + // requires sqlite3_db_config(SQLITE_DBCONFIG_DQS_*) to be set before + // any statement is prepared on the connection. applyQueryParams runs + // user-supplied PRAGMA statements, so it must come after. + if err = applyDQSConfig(c, query); err != nil { + c.Close() + return nil, err + } + + if err = applyQueryParams(c, query); err != nil { + c.Close() + return nil, err + } + + return c, nil +} + +// parseTime attempts to parse s as a time encoding. If hintIdx is a valid +// index into parseTimeFormats, that format is tried before the rest of the +// list; otherwise the search runs in declaration order. The returned int is +// the index of the format that matched, or -1 if the parseTimeString +// (t.String()) branch matched or all formats failed. Callers that scan many +// rows of a same-format column can feed the previous match back as hintIdx +// to skip the redundant time.Parse attempts that would otherwise run for +// every row. +// +// Return value contract is preserved: (parsed-value, ok). On failure the +// value is the original input string and ok is false. +func (c *conn) parseTime(s string, hintIdx int) (interface{}, bool, int) { + if v, ok := c.parseTimeString(s, strings.Index(s, "m=")); ok { + return v, true, -1 + } + + ts, hadZ := strings.CutSuffix(s, "Z") + + tryFormat := func(f string) (time.Time, error) { + if c.loc != nil && !hadZ { + return time.ParseInLocation(f, ts, c.loc) + } + return time.Parse(f, ts) + } + + // Try the caller's hint first, if any. + if hintIdx >= 0 && hintIdx < len(parseTimeFormats) { + if t, err := tryFormat(parseTimeFormats[hintIdx]); err == nil { + return c.applyTimezone(t), true, hintIdx + } + } + + // Sequential fallthrough, skipping the hint we already tried. + for i, f := range parseTimeFormats { + if i == hintIdx { + continue + } + if t, err := tryFormat(f); err == nil { + return c.applyTimezone(t), true, i + } + } + + return s, false, -1 +} + +// Attempt to parse s as a time string produced by t.String(). If x > 0 it's +// the index of substring "m=" within s. Return (s, false) if s is +// not recognized as a valid time encoding. +// This intentionally uses time.Parse, not time.ParseInLocation, +// because the format already contains timezone information (-0700 MST). +func (c *conn) parseTimeString(s0 string, x int) (interface{}, bool) { + s := s0 + if x > 0 { + s = s[:x] // "2006-01-02 15:04:05.999999999 -0700 MST m=+9999" -> "2006-01-02 15:04:05.999999999 -0700 MST " + } + s = strings.TrimSpace(s) + if t, err := time.Parse("2006-01-02 15:04:05.999999999 -0700 MST", s); err == nil { + return c.applyTimezone(t), true + } + + return s0, false +} + +func (c *conn) applyTimezone(t time.Time) time.Time { + if c.loc == nil { + return t + } + return t.In(c.loc) +} + +// writeTimeFormats are the names and formats supported +// by the `_time_format` DSN query param. +var writeTimeFormats = map[string]string{ + "sqlite": parseTimeFormats[0], + "datetime": "2006-01-02 15:04:05", +} + +func (c *conn) formatTime(t time.Time) string { + t = c.applyTimezone(t) + // Before configurable write time formats were supported, + // time.Time.String was used. Maintain that default to + // keep existing driver users formatting times the same. + if c.writeTimeFormat == "" { + return t.String() + } + return t.Format(c.writeTimeFormat) +} + +// C documentation +// +// const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); +func (c *conn) columnBlob(pstmt uintptr, iCol int) (v []byte, err error) { + p := sqlite3.Xsqlite3_column_blob(c.tls, pstmt, int32(iCol)) + len, err := c.columnBytes(pstmt, iCol) + if err != nil { + return nil, err + } + + if p == 0 || len == 0 { + return nil, nil + } + + v = make([]byte, len) + copy(v, (*libc.RawMem)(unsafe.Pointer(p))[:len:len]) + return v, nil +} + +// C documentation +// +// int sqlite3_column_bytes(sqlite3_stmt*, int iCol); +func (c *conn) columnBytes(pstmt uintptr, iCol int) (_ int, err error) { + v := sqlite3.Xsqlite3_column_bytes(c.tls, pstmt, int32(iCol)) + return int(v), nil +} + +// C documentation +// +// const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); +func (c *conn) columnText(pstmt uintptr, iCol int) (v string, err error) { + p := sqlite3.Xsqlite3_column_text(c.tls, pstmt, int32(iCol)) + len, err := c.columnBytes(pstmt, iCol) + if err != nil { + return "", err + } + + if p == 0 || len == 0 { + return "", nil + } + + // Copy the SQLite-owned UTF-8 bytes into a fresh Go-owned buffer, then + // reinterpret that buffer as a string without a second copy. The default + // string(b) conversion calls runtime.slicebytetostring, which mallocs a + // new backing array and memcpys b into it because the compiler must + // assume the caller could mutate b. Here b is local to this function and + // is never written to again after the copy above, so it is safe to view + // it as the string's backing memory directly. The string is immutable + // from Go's perspective, b becomes unreachable as a []byte after we + // return, and the GC keeps the underlying array alive for as long as the + // returned string is reachable. + b := make([]byte, len) + copy(b, (*libc.RawMem)(unsafe.Pointer(p))[:len:len]) + return unsafe.String(unsafe.SliceData(b), len), nil +} + +// C documentation +// +// double sqlite3_column_double(sqlite3_stmt*, int iCol); +func (c *conn) columnDouble(pstmt uintptr, iCol int) (v float64, err error) { + v = sqlite3.Xsqlite3_column_double(c.tls, pstmt, int32(iCol)) + return v, nil +} + +// C documentation +// +// sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); +func (c *conn) columnInt64(pstmt uintptr, iCol int) (v int64, err error) { + v = sqlite3.Xsqlite3_column_int64(c.tls, pstmt, int32(iCol)) + return v, nil +} + +// C documentation +// +// int sqlite3_column_type(sqlite3_stmt*, int iCol); +func (c *conn) columnType(pstmt uintptr, iCol int) (_ int, err error) { + v := sqlite3.Xsqlite3_column_type(c.tls, pstmt, int32(iCol)) + return int(v), nil +} + +// C documentation +// +// const char *sqlite3_column_decltype(sqlite3_stmt*,int); +func (c *conn) columnDeclType(pstmt uintptr, iCol int) string { + return libc.GoString(sqlite3.Xsqlite3_column_decltype(c.tls, pstmt, int32(iCol))) +} + +// C documentation +// +// const char *sqlite3_column_name(sqlite3_stmt*, int N); +func (c *conn) columnName(pstmt uintptr, n int) (string, error) { + p := sqlite3.Xsqlite3_column_name(c.tls, pstmt, int32(n)) + return libc.GoString(p), nil +} + +// ColumnInfo returns column information for query. +// It does not execute query. +// +// For output columns that are expressions, function calls, or constants — +// or otherwise do not resolve to a single column — the DatabaseName, +// TableName, and OriginName fields of the corresponding ColumnInfo are +// empty, per the sqlite3 contract. +// +// Sample usage: +// +// err := conn.Raw(func(driverConn any) error { +// ci, ok := driverConn.(interface{ ColumnInfo(query string) ([]sqlite.ColumnInfo, error) }) +// if !ok { +// return fmt.Errorf("driver does not support ColumnInfo") +// } +// info, err := ci.ColumnInfo(query) +// if err != nil { +// return err +// } +// // use info +// return nil +// }) +func (c *conn) ColumnInfo(query string) (_ []ColumnInfo, err error) { + p, err := libc.CString(query) + if err != nil { + return nil, err + } + defer c.free(p) + + psql := p + pstmt, err := c.prepareV2(&psql) + if err != nil { + return nil, err + } + if pstmt == 0 { + // Empty or comment-only query: no columns to describe. + return nil, nil + } + defer func() { + if e := c.finalize(pstmt); err == nil { + err = e + } + }() + + n, err := c.columnCount(pstmt) + if err != nil { + return nil, err + } + info := make([]ColumnInfo, n) + for i := range n { + name, err := c.columnName(pstmt, i) + if err != nil { + return nil, err + } + info[i] = ColumnInfo{ + Name: name, + DeclType: c.columnDeclType(pstmt, i), + DatabaseName: libc.GoString(sqlite3.Xsqlite3_column_database_name(c.tls, pstmt, int32(i))), + TableName: libc.GoString(sqlite3.Xsqlite3_column_table_name(c.tls, pstmt, int32(i))), + OriginName: libc.GoString(sqlite3.Xsqlite3_column_origin_name(c.tls, pstmt, int32(i))), + } + } + return info, nil +} + +// C documentation +// +// int sqlite3_column_count(sqlite3_stmt *pStmt); +func (c *conn) columnCount(pstmt uintptr) (_ int, err error) { + v := sqlite3.Xsqlite3_column_count(c.tls, pstmt) + return int(v), nil +} + +// C documentation +// +// sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); +func (c *conn) lastInsertRowID() (v int64, _ error) { + return sqlite3.Xsqlite3_last_insert_rowid(c.tls, c.db), nil +} + +// C documentation +// +// int sqlite3_changes(sqlite3*); +func (c *conn) changes() (int, error) { + v := sqlite3.Xsqlite3_changes(c.tls, c.db) + return int(v), nil +} + +// C documentation +// +// int sqlite3_step(sqlite3_stmt*); +func (c *conn) step(pstmt uintptr) (int, error) { + for { + switch rc := sqlite3.Xsqlite3_step(c.tls, pstmt); rc { + case sqliteLockedSharedcache: + if err := c.retry(pstmt); err != nil { + return sqlite3.SQLITE_LOCKED, err + } + case + sqlite3.SQLITE_DONE, + sqlite3.SQLITE_ROW: + + return int(rc), nil + default: + return int(rc), c.errstr(rc) + } + } +} + +func (c *conn) retry(pstmt uintptr) error { + mu := mutexAlloc(c.tls) + (*mutex)(unsafe.Pointer(mu)).Lock() + rc := sqlite3.Xsqlite3_unlock_notify( + c.tls, + c.db, + *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32) + }{unlockNotify})), + mu, + ) + if rc == sqlite3.SQLITE_LOCKED { // Deadlock, see https://www.sqlite.org/c3ref/unlock_notify.html + (*mutex)(unsafe.Pointer(mu)).Unlock() + mutexFree(c.tls, mu) + return c.errstr(rc) + } + + (*mutex)(unsafe.Pointer(mu)).Lock() + (*mutex)(unsafe.Pointer(mu)).Unlock() + mutexFree(c.tls, mu) + if pstmt != 0 { + sqlite3.Xsqlite3_reset(c.tls, pstmt) + } + return nil +} + +func (c *conn) bind(pstmt uintptr, n int, args []driver.NamedValue) (allocs []uintptr, err error) { + defer func() { + if err == nil { + return + } + + c.freeAllocs(allocs) + allocs = nil + }() + + for i := 1; i <= n; i++ { + name, err := c.bindParameterName(pstmt, i) + if err != nil { + return allocs, err + } + + var found bool + var v driver.NamedValue + for _, v = range args { + if name != "" { + // For ?NNN and $NNN params, match if NNN == v.Ordinal. + // + // Supporting this for $NNN is a special case that makes eg + // `select $1, $2, $3 ...` work without needing to use + // sql.Named. + if (name[0] == '?' || name[0] == '$') && name[1:] == strconv.Itoa(v.Ordinal) { + found = true + break + } + + // sqlite supports '$', '@' and ':' prefixes for string + // identifiers and '?' for numeric, so we cannot + // combine different prefixes with the same name + // because `database/sql` requires variable names + // to start with a letter + if name[1:] == v.Name[:] { + found = true + break + } + } else { + if v.Ordinal == i { + found = true + break + } + } + } + + if !found { + if name != "" { + return allocs, fmt.Errorf("missing named argument %q", name[1:]) + } + + return allocs, fmt.Errorf("missing argument with index %d", i) + } + + var p uintptr + switch x := v.Value.(type) { + case int64: + if err := c.bindInt64(pstmt, i, x); err != nil { + return allocs, err + } + case float64: + if err := c.bindDouble(pstmt, i, x); err != nil { + return allocs, err + } + case bool: + v := 0 + if x { + v = 1 + } + if err := c.bindInt(pstmt, i, v); err != nil { + return allocs, err + } + case []byte: + if p, err = c.bindBlob(pstmt, i, x); err != nil { + return allocs, err + } + case string: + if p, err = c.bindText(pstmt, i, x); err != nil { + return allocs, err + } + case time.Time: + switch c.integerTimeFormat { + case "unix": + if err := c.bindInt64(pstmt, i, x.Unix()); err != nil { + return allocs, err + } + case "unix_milli": + if err := c.bindInt64(pstmt, i, x.UnixMilli()); err != nil { + return allocs, err + } + case "unix_micro": + if err := c.bindInt64(pstmt, i, x.UnixMicro()); err != nil { + return allocs, err + } + case "unix_nano": + if err := c.bindInt64(pstmt, i, x.UnixNano()); err != nil { + return allocs, err + } + default: + if p, err = c.bindText(pstmt, i, c.formatTime(x)); err != nil { + return allocs, err + } + } + + case nil: + if p, err = c.bindNull(pstmt, i); err != nil { + return allocs, err + } + default: + return allocs, fmt.Errorf("sqlite: invalid driver.Value type %T", x) + } + if p != 0 { + allocs = append(allocs, p) + } + } + return allocs, nil +} + +// C documentation +// +// int sqlite3_bind_null(sqlite3_stmt*, int); +func (c *conn) bindNull(pstmt uintptr, idx1 int) (uintptr, error) { + if rc := sqlite3.Xsqlite3_bind_null(c.tls, pstmt, int32(idx1)); rc != sqlite3.SQLITE_OK { + return 0, c.errstr(rc) + } + + return 0, nil +} + +// C documentation +// +// int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); +func (c *conn) bindText(pstmt uintptr, idx1 int, value string) (uintptr, error) { + p, err := libc.CString(value) + if err != nil { + return 0, err + } + + if rc := sqlite3.Xsqlite3_bind_text(c.tls, pstmt, int32(idx1), p, int32(len(value)), 0); rc != sqlite3.SQLITE_OK { + c.free(p) + return 0, c.errstr(rc) + } + + return p, nil +} + +// C documentation +// +// int sqlite3_bind_int(sqlite3_stmt*, int, int); +func (c *conn) bindInt(pstmt uintptr, idx1, value int) (err error) { + if rc := sqlite3.Xsqlite3_bind_int(c.tls, pstmt, int32(idx1), int32(value)); rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + + return nil +} + +// C documentation +// +// int sqlite3_bind_double(sqlite3_stmt*, int, double); +func (c *conn) bindDouble(pstmt uintptr, idx1 int, value float64) (err error) { + if rc := sqlite3.Xsqlite3_bind_double(c.tls, pstmt, int32(idx1), value); rc != 0 { + return c.errstr(rc) + } + + return nil +} + +// C documentation +// +// int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); +func (c *conn) bindInt64(pstmt uintptr, idx1 int, value int64) (err error) { + if rc := sqlite3.Xsqlite3_bind_int64(c.tls, pstmt, int32(idx1), value); rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + + return nil +} + +// C documentation +// +// const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); +func (c *conn) bindParameterName(pstmt uintptr, i int) (string, error) { + p := sqlite3.Xsqlite3_bind_parameter_name(c.tls, pstmt, int32(i)) + return libc.GoString(p), nil +} + +// C documentation +// +// int sqlite3_bind_parameter_count(sqlite3_stmt*); +func (c *conn) bindParameterCount(pstmt uintptr) (_ int, err error) { + r := sqlite3.Xsqlite3_bind_parameter_count(c.tls, pstmt) + return int(r), nil +} + +// C documentation +// +// int sqlite3_finalize(sqlite3_stmt *pStmt); +func (c *conn) finalize(pstmt uintptr) error { + if rc := sqlite3.Xsqlite3_finalize(c.tls, pstmt); rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + + return nil +} + +// C documentation +// +// int sqlite3_prepare_v2( +// sqlite3 *db, /* Database handle */ +// const char *zSql, /* SQL statement, UTF-8 encoded */ +// int nByte, /* Maximum length of zSql in bytes. */ +// sqlite3_stmt **ppStmt, /* OUT: Statement handle */ +// const char **pzTail /* OUT: Pointer to unused portion of zSql */ +// ); +func (c *conn) prepareV2(zSQL *uintptr) (pstmt uintptr, err error) { + var ppstmt, pptail uintptr + + defer func() { + c.free(ppstmt) + c.free(pptail) + }() + + if ppstmt, err = c.malloc(int(ptrSize)); err != nil { + return 0, err + } + + if pptail, err = c.malloc(int(ptrSize)); err != nil { + return 0, err + } + + for { + // https://gitlab.com/cznic/sqlite/-/issues/236 + // trc("Xsqlite3_prepare_v2(`%s`)", libc.GoString(*zSQL)) + switch rc := sqlite3.Xsqlite3_prepare_v2(c.tls, c.db, *zSQL, -1, ppstmt, pptail); rc { + case sqlite3.SQLITE_OK: + *zSQL = *(*uintptr)(unsafe.Pointer(pptail)) + return *(*uintptr)(unsafe.Pointer(ppstmt)), nil + case sqliteLockedSharedcache: + if err := c.retry(0); err != nil { + return 0, err + } + default: + return 0, c.errstr(rc) + } + } +} + +// C documentation +// +// void sqlite3_interrupt(sqlite3*); +func (c *conn) interrupt(pdb uintptr) (err error) { + c.Lock() // Defend against race with .Close invoked by context handling. + + defer c.Unlock() + + if c.tls != nil { + sqlite3.Xsqlite3_interrupt(c.tls, pdb) + } + return nil +} + +// C documentation +// +// int sqlite3_extended_result_codes(sqlite3*, int onoff); +func (c *conn) extendedResultCodes(on bool) error { + if rc := sqlite3.Xsqlite3_extended_result_codes(c.tls, c.db, libc.Bool32(on)); rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + + return nil +} + +// C documentation +// +// int sqlite3_open_v2( +// const char *filename, /* Database filename (UTF-8) */ +// sqlite3 **ppDb, /* OUT: SQLite db handle */ +// int flags, /* Flags */ +// const char *zVfs /* Name of VFS module to use */ +// ); +func (c *conn) openV2(name, vfsName string, flags int32) (uintptr, error) { + var p, s, vfs uintptr + + defer func() { + if p != 0 { + c.free(p) + } + if s != 0 { + c.free(s) + } + if vfs != 0 { + c.free(vfs) + } + }() + + p, err := c.malloc(int(ptrSize)) + if err != nil { + return 0, err + } + + if s, err = libc.CString(name); err != nil { + return 0, err + } + + if vfsName != "" { + if vfs, err = libc.CString(vfsName); err != nil { + return 0, err + } + } + + if rc := sqlite3.Xsqlite3_open_v2(c.tls, s, p, flags, vfs); rc != sqlite3.SQLITE_OK { + dbh := *(*uintptr)(unsafe.Pointer(p)) + // Per SQLite docs, sqlite3_open_v2 may allocate a handle even on + // failure. The error message is stored on that handle, and it must + // be closed to avoid leaking resources. + var err error + if dbh != 0 { + err = errstrForDB(c.tls, rc, dbh, c.errorRcMode) + sqlite3.Xsqlite3_close_v2(c.tls, dbh) + } else { + err = c.errstr(rc) + } + return 0, err + } + + return *(*uintptr)(unsafe.Pointer(p)), nil +} + +func (c *conn) malloc(n int) (uintptr, error) { + if p := libc.Xmalloc(c.tls, types.Size_t(n)); p != 0 || n == 0 { + return p, nil + } + + return 0, fmt.Errorf("sqlite: cannot allocate %d bytes of memory", n) +} + +func (c *conn) free(p uintptr) { + if p != 0 { + libc.Xfree(c.tls, p) + } +} + +func (c *conn) freeAllocs(allocs []uintptr) { + for _, v := range allocs { + c.free(v) + } +} + +// dbConfigBool calls sqlite3_db_config with the (int onoff, int *pRes) +// vararg form, used by the boolean-toggle ops such as +// SQLITE_DBCONFIG_DQS_DDL / DQS_DML / ENABLE_FKEY / ENABLE_TRIGGER. pRes +// is passed as NULL because callers in this driver only need the side +// effect on the connection, not the post-set value. +// +// The vararg payload is one int followed by one pointer. libc.VaList packs +// every argument into a fixed 8-byte slot regardless of the target's pointer +// width (an int is widened to 8 bytes), so the two-argument list needs 2*8 +// bytes. Returns the underlying SQLite result code (SQLITE_OK on success). +func (c *conn) dbConfigBool(op int32, onoff bool) int32 { + var v int32 + if onoff { + v = 1 + } + const vaSlot = 8 // libc.VaList stride per argument, all targets + bp := libc.Xmalloc(c.tls, types.Size_t(2*vaSlot)) + if bp == 0 { + return sqlite3.SQLITE_NOMEM + } + defer libc.Xfree(c.tls, bp) + return sqlite3.Xsqlite3_db_config(c.tls, c.db, op, + libc.VaList(bp, v, uintptr(0))) +} + +// C documentation +// +// const char *sqlite3_errstr(int); +func (c *conn) errstr(rc int32) error { + return errstrForDB(c.tls, rc, c.db, c.errorRcMode) +} + +// errstrForDB synthesises a Go error from a (rc, db) pair. When +// errorRcMode is true, the appended sqlite3_errmsg(db) is suppressed if +// sqlite3_extended_errcode(db) is inconsistent with rc; the canonical +// sqlite3_errstr(rc) string is used alone in that case. The match check +// tries the full extended code first and falls back to the primary code +// (rc & 0xff), matching SQLite's own guidance that the operation return +// code is authoritative. When errorRcMode is false the legacy +// "errstr: errmsg" form is preserved byte-for-byte so existing callers +// parsing the error string are unaffected. See #230. +func errstrForDB(tls *libc.TLS, rc int32, db uintptr, errorRcMode bool) error { + pStr := sqlite3.Xsqlite3_errstr(tls, rc) + str := libc.GoString(pStr) + var s string + if rc == sqlite3.SQLITE_BUSY { + s = " (SQLITE_BUSY)" + } + if db == 0 { + return &Error{msg: fmt.Sprintf("%s (%v)%s", str, rc, s), code: int(rc)} + } + if errorRcMode { + ext := sqlite3.Xsqlite3_extended_errcode(tls, db) + if ext != rc && (ext&0xff) != (rc&0xff) { + // Mismatch: errmsg on the db handle reflects a different + // operation. Use the canonical errstr(rc) alone. + return &Error{msg: fmt.Sprintf("%s (%v)%s", str, rc, s), code: int(rc)} + } + } + pMsg := sqlite3.Xsqlite3_errmsg(tls, db) + switch msg := libc.GoString(pMsg); { + case msg == str: + return &Error{msg: fmt.Sprintf("%s (%v)%s", str, rc, s), code: int(rc)} + default: + return &Error{msg: fmt.Sprintf("%s: %s (%v)%s", str, msg, rc, s), code: int(rc)} + } +} + +// Begin starts a transaction. +// +// Deprecated: Drivers should implement ConnBeginTx instead (or additionally). +func (c *conn) Begin() (dt driver.Tx, err error) { + if dmesgs { + defer func() { + dmesg("conn %p: (driver.Tx %p, err %v)", c, dt, err) + }() + } + return c.begin(context.Background(), driver.TxOptions{}) +} + +func (c *conn) begin(ctx context.Context, opts driver.TxOptions) (t driver.Tx, err error) { + return newTx(ctx, c, opts) +} + +// Close invalidates and potentially stops any current prepared statements and +// transactions, marking this connection as no longer in use. +// +// Because the sql package maintains a free pool of connections and only calls +// Close when there's a surplus of idle connections, it shouldn't be necessary +// for drivers to do their own connection caching. +func (c *conn) Close() (err error) { + if dmesgs { + defer func() { + dmesg("conn %p: err %v", c, err) + }() + } + c.Lock() // Defend against race with .interrupt invoked by context handling. + + defer c.Unlock() + + if c.db != 0 { + if err := c.closeV2(c.db); err != nil { + return err + } + + c.db = 0 + } + + if c.tls != nil { + c.tls.Close() + c.tls = nil + } + return nil +} + +// C documentation +// +// int sqlite3_close_v2(sqlite3*); +func (c *conn) closeV2(db uintptr) error { + if rc := sqlite3.Xsqlite3_close_v2(c.tls, db); rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + + return nil +} + +// ResetSession is called prior to executing a query on the connection if the +// connection has been used before. If the driver returns ErrBadConn the +// connection is discarded. +func (c *conn) ResetSession(ctx context.Context) error { + if !c.usable() { + return driver.ErrBadConn + } + + return nil +} + +// IsValid is called prior to placing the connection into the connection pool. +// The connection will be discarded if false is returned. +func (c *conn) IsValid() bool { + return c.usable() +} + +func (c *conn) usable() bool { + if c.db == 0 { + return false + } + // For in-memory databases the connection is the database: discarding + // it because the previous query was interrupted destroys all the data. + // Treat an interrupted in-memory connection as still valid so that + // database/sql returns it to the pool instead of dropping it. See #196 + // (regressed by the fix for #198 which added the is_interrupted check). + if c.inMemory { + return true + } + return sqlite3.Xsqlite3_is_interrupted(c.tls, c.db) == 0 +} + +type userDefinedFunction struct { + zFuncName uintptr + nArg int32 + eTextRep int32 + pApp uintptr + + scalar bool + freeOnce sync.Once +} + +func (c *conn) createFunctionInternal(fun *userDefinedFunction) error { + var rc int32 + + if fun.scalar { + rc = sqlite3.Xsqlite3_create_function( + c.tls, + c.db, + fun.zFuncName, + fun.nArg, + fun.eTextRep, + fun.pApp, + cFuncPointer(funcTrampoline), + 0, + 0, + ) + } else { + rc = sqlite3.Xsqlite3_create_window_function( + c.tls, + c.db, + fun.zFuncName, + fun.nArg, + fun.eTextRep, + fun.pApp, + cFuncPointer(stepTrampoline), + cFuncPointer(finalTrampoline), + cFuncPointer(valueTrampoline), + cFuncPointer(inverseTrampoline), + 0, + ) + } + + if rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + return nil +} + +func (c *conn) createCollationInternal(coll *collation) error { + rc := sqlite3.Xsqlite3_create_collation_v2( + c.tls, + c.db, + coll.zName, + coll.enc, + coll.pApp, + cFuncPointer(collationTrampoline), + 0, + ) + if rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + return nil +} + +// Execer is an optional interface that may be implemented by a Conn. +// +// If a Conn does not implement Execer, the sql package's DB.Exec will first +// prepare a query, execute the statement, and then close the statement. +// +// Exec may return ErrSkip. +// +// Deprecated: Drivers should implement ExecerContext instead. +func (c *conn) Exec(query string, args []driver.Value) (dr driver.Result, err error) { + if dmesgs { + defer func() { + dmesg("conn %p, query %q, args %v: (driver.Result %p, err %v)", c, query, args, dr, err) + }() + } + return c.exec(context.Background(), query, toNamedValues(args)) +} + +func (c *conn) exec(ctx context.Context, query string, args []driver.NamedValue) (r driver.Result, err error) { + s, err := c.prepare(ctx, query) + if err != nil { + return nil, err + } + + defer func() { + if err2 := s.Close(); err2 != nil && err == nil { + err = err2 + } + }() + + return s.(*stmt).exec(ctx, args) +} + +// Prepare returns a prepared statement, bound to this connection. +func (c *conn) Prepare(query string) (ds driver.Stmt, err error) { + if dmesgs { + defer func() { + dmesg("conn %p, query %q: (driver.Stmt %p, err %v)", c, query, ds, err) + }() + } + return c.prepare(context.Background(), query) +} + +func (c *conn) prepare(ctx context.Context, query string) (s driver.Stmt, err error) { + //TODO use ctx + return newStmt(c, query) +} + +// Queryer is an optional interface that may be implemented by a Conn. +// +// If a Conn does not implement Queryer, the sql package's DB.Query will first +// prepare a query, execute the statement, and then close the statement. +// +// Query may return ErrSkip. +// +// Deprecated: Drivers should implement QueryerContext instead. +func (c *conn) Query(query string, args []driver.Value) (dr driver.Rows, err error) { + if dmesgs { + defer func() { + dmesg("conn %p, query %q, args %v: (driver.Rows %p, err %v)", c, query, args, dr, err) + }() + } + return c.query(context.Background(), query, toNamedValues(args)) +} + +func (c *conn) query(ctx context.Context, query string, args []driver.NamedValue) (r driver.Rows, err error) { + // Use newStmt directly. c.prepare wraps this, but we need the concrete *stmt type + // to manipulate the handle ownership below. + s, err := newStmt(c, query) + if err != nil { + return nil, err + } + + r, err = s.query(ctx, args) + if err != nil { + s.Close() + return nil, err + } + + // Fix for TestIssue118 / One-Shot Query Crash: + // If the statement was cached (optimized path in newStmt), s.pstmt is valid. + // s.query() sets r.reuseStmt = true by default for cached statements. + // + // However, since this is a transient statement created just for this query (db.Query), + // s.Close() will be called immediately below. We must transfer ownership of the + // sqlite statement handle to the rows object so it isn't finalized yet. + if s.pstmt != 0 { + // Steal the handle from the statement so s.Close() doesn't finalize it. + s.pstmt = 0 + + // Instruct rows to finalize the statement when done, rather than resetting it. + r.(*rows).reuseStmt = false + } + + // s.Close() now only frees the C-string allocation (psql), skipping the pstmt finalize + // because we set s.pstmt to 0. + if err := s.Close(); err != nil { + r.Close() + return nil, err + } + + return r, nil +} + +// Serialize returns a serialization of the main database. For an ordinary on-disk +// database file, the serialization is just a copy of the disk file. For an in-memory +// database or a "TEMP" database, the serialization is the same sequence of bytes +// which would be written to disk if that database where backed up to disk. +func (c *conn) Serialize() (v []byte, err error) { + pLen := c.tls.Alloc(8) + defer c.tls.Free(8) + + zSchema := sqlite3.Xsqlite3_db_name(c.tls, c.db, 0) + if zSchema == 0 { + return nil, fmt.Errorf("failed to get main db name") + } + + pBuf := sqlite3.Xsqlite3_serialize(c.tls, c.db, zSchema, pLen, 0) + bufLen := *(*sqlite3.Sqlite3_int64)(unsafe.Pointer(pLen)) + if pBuf != 0 { + defer sqlite3.Xsqlite3_free(c.tls, pBuf) + } + if bufLen <= 0 { + return nil, fmt.Errorf("invalid length returned: %d", bufLen) + } else if pBuf == 0 || bufLen == 0 { + return nil, nil + } + + v = make([]byte, bufLen) + copy(v, (*libc.RawMem)(unsafe.Pointer(pBuf))[:bufLen:bufLen]) + return v, nil +} + +// Deserialize restores a database from the content returned by Serialize. +func (c *conn) Deserialize(buf []byte) (err error) { + bufLen := len(buf) + if bufLen == 0 { + return fmt.Errorf("sqlite: empty buffer passed to Deserialize") + } + pBuf := sqlite3.Xsqlite3_malloc64(c.tls, uint64(bufLen)) + if pBuf == 0 { + return fmt.Errorf("sqlite: cannot allocate %d bytes for deserialize", bufLen) + } + + copy((*libc.RawMem)(unsafe.Pointer(pBuf))[:bufLen:bufLen], buf) + + zSchema := sqlite3.Xsqlite3_db_name(c.tls, c.db, 0) + if zSchema == 0 { + sqlite3.Xsqlite3_free(c.tls, pBuf) + return fmt.Errorf("failed to get main db name") + } + + rc := sqlite3.Xsqlite3_deserialize(c.tls, c.db, zSchema, pBuf, int64(bufLen), int64(bufLen), sqlite3.SQLITE_DESERIALIZE_RESIZEABLE|sqlite3.SQLITE_DESERIALIZE_FREEONCLOSE) + if rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + return nil +} + +// NewBackup returns a Backup object that will create an online backup of +// current database to the databased pointed by the passed URI. +func (c *conn) NewBackup(dstUri string) (*Backup, error) { + dstConn, err := newConn(dstUri) + if err != nil { + return nil, err + } + backup, err := c.backup(dstConn, false) + if err != nil { + dstConn.Close() + } + return backup, err +} + +// NewRestore returns a Backup object that will restore a backup to current +// database from the databased pointed by the passed URI. +func (c *conn) NewRestore(srcUri string) (*Backup, error) { + srcConn, err := newConn(srcUri) + if err != nil { + return nil, err + } + backup, err := c.backup(srcConn, true) + if err != nil { + srcConn.Close() + } + return backup, err +} + +func (c *conn) backup(remoteConn *conn, restore bool) (_ *Backup, finalErr error) { + srcSchema := sqlite3.Xsqlite3_db_name(c.tls, c.db, 0) + if srcSchema == 0 { + return nil, fmt.Errorf("failed to get main source db name") + } + + dstSchema := sqlite3.Xsqlite3_db_name(remoteConn.tls, remoteConn.db, 0) + if dstSchema == 0 { + return nil, fmt.Errorf("failed to get main destination db name") + } + + var pBackup uintptr + if restore { + pBackup = sqlite3.Xsqlite3_backup_init(c.tls, c.db, srcSchema, remoteConn.db, dstSchema) + } else { + pBackup = sqlite3.Xsqlite3_backup_init(c.tls, remoteConn.db, dstSchema, c.db, srcSchema) + } + if pBackup <= 0 { + destDb := remoteConn.db + destMode := remoteConn.errorRcMode + if restore { + destDb = c.db + destMode = c.errorRcMode + } + rc := sqlite3.Xsqlite3_errcode(c.tls, destDb) + return nil, errstrForDB(c.tls, rc, destDb, destMode) + } + + return &Backup{srcConn: c, dstConn: remoteConn, pBackup: pBackup}, nil +} + +// C documentation +// +// int sqlite3_limit(sqlite3*, int id, int newVal); +func (c *conn) limit(id int, newVal int) int { + return int(sqlite3.Xsqlite3_limit(c.tls, c.db, int32(id), int32(newVal))) +} + +// C documentation +// +// int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); +func (c *conn) bindBlob(pstmt uintptr, idx1 int, value []byte) (uintptr, error) { + if value == nil { + if rc := sqlite3.Xsqlite3_bind_null(c.tls, pstmt, int32(idx1)); rc != sqlite3.SQLITE_OK { + return 0, c.errstr(rc) + } + return 0, nil + } + + p, err := c.malloc(len(value)) + if err != nil { + return 0, err + } + if len(value) != 0 { + copy((*libc.RawMem)(unsafe.Pointer(p))[:len(value):len(value)], value) + } + if rc := sqlite3.Xsqlite3_bind_blob(c.tls, pstmt, int32(idx1), p, int32(len(value)), 0); rc != sqlite3.SQLITE_OK { + c.free(p) + return 0, c.errstr(rc) + } + + return p, nil +} + +// Ping implements driver.Pinger +func (c *conn) Ping(ctx context.Context) (err error) { + if dmesgs { + defer func() { + dmesg("conn %p, ctx %p: err %v", c, ctx, err) + }() + } + _, err = c.ExecContext(ctx, "select 1", nil) + return err +} + +// BeginTx implements driver.ConnBeginTx +func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (dt driver.Tx, err error) { + if dmesgs { + defer func() { + dmesg("conn %p, ctx %p, opts %+v: (driver.Tx %v, err %v)", c, ctx, opts, dt, err) + }() + } + return c.begin(ctx, opts) +} + +// PrepareContext implements driver.ConnPrepareContext +func (c *conn) PrepareContext(ctx context.Context, query string) (ds driver.Stmt, err error) { + if dmesgs { + defer func() { + dmesg("conn %p, ctx %p, query %q: (driver.Stmt %v, err %v)", c, ctx, query, ds, err) + }() + } + return c.prepare(ctx, query) +} + +// ExecContext implements driver.ExecerContext +func (c *conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (dr driver.Result, err error) { + if dmesgs { + defer func() { + dmesg("conn %p, ctx %p, query %q, args %v: (driver.Result %p, err %v)", c, ctx, query, args, dr, err) + }() + } + return c.exec(ctx, query, args) +} + +// QueryContext implements driver.QueryerContext +func (c *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (dr driver.Rows, err error) { + if dmesgs { + defer func() { + dmesg("conn %p, ctx %p, query %q, args %v: (driver.Rows %p, err %v)", c, ctx, query, args, dr, err) + }() + } + return c.query(ctx, query, args) +} + +// IsReadOnly reports whether the database schema specified by dbName is read-only. +// +// dbName is the internal name of the attached database, not the filename. +// Use "main" for the primary database, "temp" for the temporary database, +// or the name used in an ATTACH statement. +func (c *conn) IsReadOnly(schema string) (bool, error) { + if dmesgs { + defer func() { + dmesg("conn %p", c) + }() + } + cs, err := libc.CString(schema) + if err != nil { + return false, err + } + + defer libc.Xfree(c.tls, cs) + + switch r := sqlite3.Xsqlite3_db_readonly(c.tls, c.db, cs); r { + case 1: + return true, nil + case 0: + return false, nil + case -1: + return false, fmt.Errorf("not a name of a database on connection: '%s'", schema) + default: + return false, fmt.Errorf("unexpected sqlite3_db_readonly(%q) return value: %v", schema, r) + } +} diff --git a/internal/engine/convert.go b/internal/engine/convert.go new file mode 100644 index 0000000..1b19dc6 --- /dev/null +++ b/internal/engine/convert.go @@ -0,0 +1,299 @@ +// Extracted from Go database/sql source code + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Type conversions for Scan. + +package sqlite + +import ( + "database/sql" + "database/sql/driver" + "errors" + "fmt" + "reflect" + "strconv" + "time" +) + +var errNilPtr = errors.New("destination pointer is nil") // embedded in descriptive error + +// convertAssign copies to dest the value in src, converting it if possible. +// An error is returned if the copy would result in loss of information. +// dest should be a pointer type. +func convertAssign(dest, src interface{}) error { + // Common cases, without reflect. + switch s := src.(type) { + case string: + switch d := dest.(type) { + case *string: + if d == nil { + return errNilPtr + } + *d = s + return nil + case *[]byte: + if d == nil { + return errNilPtr + } + *d = []byte(s) + return nil + case *sql.RawBytes: + if d == nil { + return errNilPtr + } + *d = append((*d)[:0], s...) + return nil + } + case []byte: + switch d := dest.(type) { + case *string: + if d == nil { + return errNilPtr + } + *d = string(s) + return nil + case *interface{}: + if d == nil { + return errNilPtr + } + *d = cloneBytes(s) + return nil + case *[]byte: + if d == nil { + return errNilPtr + } + *d = cloneBytes(s) + return nil + case *sql.RawBytes: + if d == nil { + return errNilPtr + } + *d = s + return nil + } + case time.Time: + switch d := dest.(type) { + case *time.Time: + *d = s + return nil + case *string: + *d = s.Format(time.RFC3339Nano) + return nil + case *[]byte: + if d == nil { + return errNilPtr + } + *d = []byte(s.Format(time.RFC3339Nano)) + return nil + case *sql.RawBytes: + if d == nil { + return errNilPtr + } + *d = s.AppendFormat((*d)[:0], time.RFC3339Nano) + return nil + } + case nil: + switch d := dest.(type) { + case *interface{}: + if d == nil { + return errNilPtr + } + *d = nil + return nil + case *[]byte: + if d == nil { + return errNilPtr + } + *d = nil + return nil + case *sql.RawBytes: + if d == nil { + return errNilPtr + } + *d = nil + return nil + } + } + + var sv reflect.Value + + switch d := dest.(type) { + case *string: + sv = reflect.ValueOf(src) + switch sv.Kind() { + case reflect.Bool, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Float32, reflect.Float64: + *d = asString(src) + return nil + } + case *[]byte: + sv = reflect.ValueOf(src) + if b, ok := asBytes(nil, sv); ok { + *d = b + return nil + } + case *sql.RawBytes: + sv = reflect.ValueOf(src) + if b, ok := asBytes([]byte(*d)[:0], sv); ok { + *d = sql.RawBytes(b) + return nil + } + case *bool: + bv, err := driver.Bool.ConvertValue(src) + if err == nil { + *d = bv.(bool) + } + return err + case *interface{}: + *d = src + return nil + } + + if scanner, ok := dest.(sql.Scanner); ok { + return scanner.Scan(src) + } + + dpv := reflect.ValueOf(dest) + if dpv.Kind() != reflect.Ptr { + return errors.New("destination not a pointer") + } + if dpv.IsNil() { + return errNilPtr + } + + if !sv.IsValid() { + sv = reflect.ValueOf(src) + } + + dv := reflect.Indirect(dpv) + if sv.IsValid() && sv.Type().AssignableTo(dv.Type()) { + switch b := src.(type) { + case []byte: + dv.Set(reflect.ValueOf(cloneBytes(b))) + default: + dv.Set(sv) + } + return nil + } + + if dv.Kind() == sv.Kind() && sv.Type().ConvertibleTo(dv.Type()) { + dv.Set(sv.Convert(dv.Type())) + return nil + } + + // The following conversions use a string value as an intermediate representation + // to convert between various numeric types. + // + // This also allows scanning into user defined types such as "type Int int64". + // For symmetry, also check for string destination types. + switch dv.Kind() { + case reflect.Ptr: + if src == nil { + dv.Set(reflect.Zero(dv.Type())) + return nil + } + dv.Set(reflect.New(dv.Type().Elem())) + return convertAssign(dv.Interface(), src) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + s := asString(src) + i64, err := strconv.ParseInt(s, 10, dv.Type().Bits()) + if err != nil { + err = strconvErr(err) + return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err) + } + dv.SetInt(i64) + return nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + s := asString(src) + u64, err := strconv.ParseUint(s, 10, dv.Type().Bits()) + if err != nil { + err = strconvErr(err) + return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err) + } + dv.SetUint(u64) + return nil + case reflect.Float32, reflect.Float64: + s := asString(src) + f64, err := strconv.ParseFloat(s, dv.Type().Bits()) + if err != nil { + err = strconvErr(err) + return fmt.Errorf("converting driver.Value type %T (%q) to a %s: %v", src, s, dv.Kind(), err) + } + dv.SetFloat(f64) + return nil + case reflect.String: + switch v := src.(type) { + case string: + dv.SetString(v) + return nil + case []byte: + dv.SetString(string(v)) + return nil + } + } + + return fmt.Errorf("unsupported Scan, storing driver.Value type %T into type %T", src, dest) +} + +func strconvErr(err error) error { + if ne, ok := err.(*strconv.NumError); ok { + return ne.Err + } + return err +} + +func cloneBytes(b []byte) []byte { + if b == nil { + return nil + } + c := make([]byte, len(b)) + copy(c, b) + return c +} + +func asString(src interface{}) string { + switch v := src.(type) { + case string: + return v + case []byte: + return string(v) + } + rv := reflect.ValueOf(src) + switch rv.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return strconv.FormatInt(rv.Int(), 10) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return strconv.FormatUint(rv.Uint(), 10) + case reflect.Float64: + return strconv.FormatFloat(rv.Float(), 'g', -1, 64) + case reflect.Float32: + return strconv.FormatFloat(rv.Float(), 'g', -1, 32) + case reflect.Bool: + return strconv.FormatBool(rv.Bool()) + } + return fmt.Sprintf("%v", src) +} + +func asBytes(buf []byte, rv reflect.Value) (b []byte, ok bool) { + switch rv.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return strconv.AppendInt(buf, rv.Int(), 10), true + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return strconv.AppendUint(buf, rv.Uint(), 10), true + case reflect.Float32: + return strconv.AppendFloat(buf, rv.Float(), 'g', -1, 32), true + case reflect.Float64: + return strconv.AppendFloat(buf, rv.Float(), 'g', -1, 64), true + case reflect.Bool: + return strconv.AppendBool(buf, rv.Bool()), true + case reflect.String: + s := rv.String() + return append(buf, s...), true + } + return +} diff --git a/internal/engine/dbstatus.go b/internal/engine/dbstatus.go new file mode 100644 index 0000000..dc98e59 --- /dev/null +++ b/internal/engine/dbstatus.go @@ -0,0 +1,98 @@ +// Copyright 2026 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "unsafe" + + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +// DBStatusOp identifies a per-connection runtime counter readable through +// [DBStatus.Status]. The values mirror the SQLITE_DBSTATUS_* verbs of the C +// API; the distinct type keeps a counter from a different family (for example +// a file-control or db-config op) from compiling in its place. +// +// See https://www.sqlite.org/c3ref/c_dbstatus_options.html for the per-op +// semantics. +type DBStatusOp int32 + +// DBStatus* are the operations accepted by [DBStatus.Status]. They report +// their value differently depending on the op: +// +// - DBStatusLookasideUsed: current is the lookaside memory in use now; high +// is its high-water mark. The reset flag rebases the high-water mark to +// current. This is the only op that maintains a high-water mark. +// - Memory-usage ops (DBStatusCacheUsed, DBStatusSchemaUsed, +// DBStatusStmtUsed, DBStatusCacheUsedShared): current is the bytes in use +// now; high is always 0; the reset flag is ignored. +// - Running-counter ops (DBStatusCacheHit, DBStatusCacheMiss, +// DBStatusCacheWrite, DBStatusCacheSpill, DBStatusTempbufSpill): current +// is the cumulative count (bytes spilled, for DBStatusTempbufSpill); high +// is always 0. The reset flag zeroes current. +// - Lookaside event ops (DBStatusLookasideHit, DBStatusLookasideMissSize, +// DBStatusLookasideMissFull): the count is reported in high, not current +// (current is always 0). The reset flag zeroes high. +// - DBStatusDeferredFKs: current is 1 if the connection has unresolved +// deferred foreign-key constraints, else 0; high is always 0; the reset +// flag is ignored. +const ( + DBStatusLookasideUsed = DBStatusOp(sqlite3.SQLITE_DBSTATUS_LOOKASIDE_USED) + DBStatusCacheUsed = DBStatusOp(sqlite3.SQLITE_DBSTATUS_CACHE_USED) + DBStatusSchemaUsed = DBStatusOp(sqlite3.SQLITE_DBSTATUS_SCHEMA_USED) + DBStatusStmtUsed = DBStatusOp(sqlite3.SQLITE_DBSTATUS_STMT_USED) + DBStatusLookasideHit = DBStatusOp(sqlite3.SQLITE_DBSTATUS_LOOKASIDE_HIT) + DBStatusLookasideMissSize = DBStatusOp(sqlite3.SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE) + DBStatusLookasideMissFull = DBStatusOp(sqlite3.SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL) + DBStatusCacheHit = DBStatusOp(sqlite3.SQLITE_DBSTATUS_CACHE_HIT) + DBStatusCacheMiss = DBStatusOp(sqlite3.SQLITE_DBSTATUS_CACHE_MISS) + DBStatusCacheWrite = DBStatusOp(sqlite3.SQLITE_DBSTATUS_CACHE_WRITE) + DBStatusDeferredFKs = DBStatusOp(sqlite3.SQLITE_DBSTATUS_DEFERRED_FKS) + DBStatusCacheUsedShared = DBStatusOp(sqlite3.SQLITE_DBSTATUS_CACHE_USED_SHARED) + DBStatusCacheSpill = DBStatusOp(sqlite3.SQLITE_DBSTATUS_CACHE_SPILL) + DBStatusTempbufSpill = DBStatusOp(sqlite3.SQLITE_DBSTATUS_TEMPBUF_SPILL) +) + +// DBStatus exposes sqlite3_db_status, the per-connection runtime counters +// (cache hit/miss/write/spill rates, schema and prepared-statement memory, +// lookaside usage, deferred foreign keys). Reach it through the +// database/sql escape hatch, the same way as [FileControl]: +// +// err := sqlConn.Raw(func(dc any) error { +// cur, _, err := dc.(sqlite.DBStatus).Status(sqlite.DBStatusCacheSpill, false) +// if err != nil { +// return err +// } +// // use cur +// return nil +// }) +type DBStatus interface { + // Status returns the current and high-water values of the per-connection + // counter identified by op. When reset is true the counter is reset after + // the read; which value the reset affects depends on the op's family, see + // the DBStatus* constant documentation. The returned error is non-nil only + // when SQLite rejects op as out of range. + Status(op DBStatusOp, reset bool) (current, high int, err error) +} + +var _ DBStatus = (*conn)(nil) + +func (c *conn) Status(op DBStatusOp, reset bool) (current, high int, err error) { + // Two int32 out-params: pCurrent, pHighwater. sqlite3_db_status writes + // C int (32-bit) through both, so a single 8-byte buffer holds the pair. + p := c.tls.Alloc(8) + defer c.tls.Free(8) + + pCur, pHi := p, p+4 + resetFlag := int32(0) + if reset { + resetFlag = 1 + } + if rc := sqlite3.Xsqlite3_db_status(c.tls, c.db, int32(op), pCur, pHi, resetFlag); rc != sqlite3.SQLITE_OK { + return 0, 0, c.errstr(rc) + } + + return int(*(*int32)(unsafe.Pointer(pCur))), int(*(*int32)(unsafe.Pointer(pHi))), nil +} diff --git a/internal/engine/doc.go b/internal/engine/doc.go new file mode 100644 index 0000000..f8195ee --- /dev/null +++ b/internal/engine/doc.go @@ -0,0 +1,214 @@ +// Copyright 2017 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package sqlite is a sql/database driver using a CGo-free port of the C +// SQLite3 library. +// +// SQLite is an in-process implementation of a self-contained, serverless, +// zero-configuration, transactional SQL database engine. +// +// # Pluggable page cache +// +// The package exposes a Go-facing wrapper for SQLite's +// SQLITE_CONFIG_PCACHE2 mechanism. Applications can supply their own +// page cache implementation by registering a [PageCache] before the +// first [sql.Open] via [RegisterPageCache]. See the docstrings +// on [PageCache], [Cache], and [Page] for the contract; the binding +// owns the sqlite3_pcache_page stub on behalf of the implementation +// and re-consults Cache.Fetch on every SQLite request, so a bounded +// and evicting purgeable cache works as the C contract intends. +// +// # Fragile github.com/hanzoai/sqlite/internal/libc dependency +// +// When you import this package you should use in your go.mod file the exact +// same version of github.com/hanzoai/sqlite/internal/libc as seen in the go.mod file of this +// repository. +// +// See the discussion at https://gitlab.com/cznic/sqlite/-/issues/177 for more details. +// +// # Thanks +// +// This project is sponsored by Schleibinger Geräte Teubert u. Greim GmbH by +// allowing one of the maintainers to work on it also in office hours. +// +// # Supported platforms and architectures +// +// These combinations of GOOS and GOARCH are currently supported +// +// OS Arch SQLite version +// ------------------------------ +// darwin amd64 3.53.2 +// darwin arm64 3.53.2 +// freebsd amd64 3.53.2 +// freebsd arm64 3.53.2 +// linux 386 3.53.2 +// linux amd64 3.53.2 +// linux arm 3.53.2 +// linux arm64 3.53.2 +// linux loong64 3.53.2 +// linux ppc64le 3.53.2 +// linux riscv64 3.53.2 +// linux s390x 3.53.2 +// windows 386 3.53.2 +// windows amd64 3.53.2 +// windows arm64 3.53.2 +// +// # Benchmarks +// +// [The SQLite Drivers Benchmarks Game] +// +// # Builders +// +// Builder results available at: +// +// https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fsqlite +// +// # Connecting to a database +// +// To access a Sqlite database do something like +// +// import ( +// "database/sql" +// +// _ "github.com/hanzoai/sqlite/internal/engine" +// ) +// +// ... +// +// +// db, err := sql.Open("sqlite", dsnURI) +// +// ... +// +// # Debug and development versions +// +// A comma separated list of options can be passed to `go generate` via the +// environment variable GO_GENERATE. Some useful options include for example: +// +// -DSQLITE_DEBUG +// -DSQLITE_MEM_DEBUG +// -ccgo-verify-structs +// +// To create a debug/development version, issue for example: +// +// $ GO_GENERATE=-DSQLITE_DEBUG,-DSQLITE_MEM_DEBUG go generate +// +// Note: To run `go generate` you need to have modernc.org/ccgo/v3 installed. +// +// # Hacking +// +// This is an example of how to use the debug logs in github.com/hanzoai/sqlite/internal/libc when hunting a bug. +// +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ git status +// On branch master +// Your branch is up to date with 'origin/master'. +// +// nothing to commit, working tree clean +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ git log -1 +// commit df33b8d15107f3cc777799c0fe105f74ef499e62 (HEAD -> master, tag: v1.21.1, origin/master, origin/HEAD, wips, ok) +// Author: Jan Mercl <0xjnml@gmail.com> +// Date: Mon Mar 27 16:18:28 2023 +0200 +// +// upgrade to SQLite 3.41.2 +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ rm -f /tmp/libc.log ; go test -v -tags=libc.dmesg -run TestScalar ; ls -l /tmp/libc.log +// test binary compiled for linux/amd64 +// === RUN TestScalar +// --- PASS: TestScalar (0.09s) +// PASS +// ok github.com/hanzoai/sqlite/internal/engine 0.128s +// -rw-r--r-- 1 jnml jnml 76 Apr 6 11:22 /tmp/libc.log +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ cat /tmp/libc.log +// [10723 sqlite.test] 2023-04-06 11:22:48.288066057 +0200 CEST m=+0.000707150 +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ +// +// The /tmp/libc.log file is created as requested. No useful messages there because none are enabled in libc. Let's try to enable Xwrite as an example. +// +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/libc$ git status +// On branch master +// Your branch is up to date with 'origin/master'. +// +// Changes not staged for commit: +// (use "git add ..." to update what will be committed) +// (use "git restore ..." to discard changes in working directory) +// modified: libc_linux.go +// +// no changes added to commit (use "git add" and/or "git commit -a") +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/libc$ git log -1 +// commit 1e22c18cf2de8aa86d5b19b165f354f99c70479c (HEAD -> master, tag: v1.22.3, origin/master, origin/HEAD) +// Author: Jan Mercl <0xjnml@gmail.com> +// Date: Wed Feb 22 20:27:45 2023 +0100 +// +// support sqlite 3.41 on linux targets +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/libc$ git diff +// diff --git a/libc_linux.go b/libc_linux.go +// index 1c2f482..ac1f08d 100644 +// --- a/libc_linux.go +// +++ b/libc_linux.go +// @@ -332,19 +332,19 @@ func Xwrite(t *TLS, fd int32, buf uintptr, count types.Size_t) types.Ssize_t { +// var n uintptr +// switch n, _, err = unix.Syscall(unix.SYS_WRITE, uintptr(fd), buf, uintptr(count)); err { +// case 0: +// - // if dmesgs { +// - // // dmesg("%v: %d %#x: %#x\n%s", origin(1), fd, count, n, hex.Dump(GoBytes(buf, int(n)))) +// - // dmesg("%v: %d %#x: %#x", origin(1), fd, count, n) +// - // } +// + if dmesgs { +// + // dmesg("%v: %d %#x: %#x\n%s", origin(1), fd, count, n, hex.Dump(GoBytes(buf, int(n)))) +// + dmesg("%v: %d %#x: %#x", origin(1), fd, count, n) +// + } +// return types.Ssize_t(n) +// case errno.EAGAIN: +// // nop +// } +// } +// +// - // if dmesgs { +// - // dmesg("%v: fd %v, count %#x: %v", origin(1), fd, count, err) +// - // } +// + if dmesgs { +// + dmesg("%v: fd %v, count %#x: %v", origin(1), fd, count, err) +// + } +// t.setErrno(err) +// return -1 +// } +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/libc$ +// +// We need to tell the Go build system to use our local, patched/debug libc: +// +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ go work use $(go env GOPATH)/src/github.com/hanzoai/sqlite/internal/libc +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ go work use . +// +// And run the test again: +// +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ rm -f /tmp/libc.log ; go test -v -tags=libc.dmesg -run TestScalar ; ls -l /tmp/libc.log +// test binary compiled for linux/amd64 +// === RUN TestScalar +// --- PASS: TestScalar (0.26s) +// PASS +// ok github.com/hanzoai/sqlite/internal/engine 0.285s +// -rw-r--r-- 1 jnml jnml 918 Apr 6 11:29 /tmp/libc.log +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ cat /tmp/libc.log +// [11910 sqlite.test] 2023-04-06 11:29:13.143589542 +0200 CEST m=+0.000689270 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0x200: 0x200 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0xc: 0xc +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 7 0x1000: 0x1000 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 7 0x1000: 0x1000 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0x200: 0x200 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0x4: 0x4 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0x1000: 0x1000 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0x4: 0x4 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0x4: 0x4 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0x1000: 0x1000 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0x4: 0x4 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 8 0xc: 0xc +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 7 0x1000: 0x1000 +// [11910 sqlite.test] libc_linux.go:337:Xwrite: 7 0x1000: 0x1000 +// 0:jnml@e5-1650:~/src/github.com/hanzoai/sqlite/internal/engine$ +// +// # Sqlite documentation +// +// See https://sqlite.org/docs.html +// +// [The SQLite Drivers Benchmarks Game]: https://pkg.go.dev/github.com/hanzoai/sqlite/internal/engine-bench#readme-tl-dr-scorecard +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" diff --git a/internal/engine/driver.go b/internal/engine/driver.go new file mode 100644 index 0000000..05bec7d --- /dev/null +++ b/internal/engine/driver.go @@ -0,0 +1,176 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "context" + "database/sql/driver" + "fmt" + + "github.com/hanzoai/sqlite/internal/engine/vtab" +) + +// Driver implements database/sql/driver.Driver. +// +// Registration functions and methods must be called before the first call to Open. +type Driver struct { + // user defined functions that are added to every new connection on Open + udfs map[string]*userDefinedFunction + // collations that are added to every new connection on Open + collations map[string]*collation + // connection hooks are called after a connection is opened + connectionHooks []ConnectionHookFn + // modules holds registered virtual table modules that should be added to + // every new connection on Open. + modules map[string]vtab.Module +} + +var d = &Driver{ + udfs: make(map[string]*userDefinedFunction, 0), + collations: make(map[string]*collation, 0), + connectionHooks: make([]ConnectionHookFn, 0), + modules: make(map[string]vtab.Module, 0), +} + +func newDriver() *Driver { return d } + +// Connector returns a driver.Connector for dsn backed by the registered driver. +// sql.OpenDB(Connector(dsn)) is equivalent to sql.Open(driverName, dsn), but lets +// a caller wrap the returned connector in an io.Closer whose Close runs when the +// sql.DB is closed. The pure-Go SQLCipher codec path uses that to unregister the +// per-database codec VFS exactly when its *sql.DB closes. +func Connector(dsn string) driver.Connector { return &connector{dsn: dsn} } + +type connector struct{ dsn string } + +func (c *connector) Connect(_ context.Context) (driver.Conn, error) { return d.Open(c.dsn) } + +func (c *connector) Driver() driver.Driver { return d } + +// Open returns a new connection to the database. The name is a string in a +// driver-specific format. +// +// Open may return a cached connection (one previously closed), but doing so is +// unnecessary; the sql package maintains a pool of idle connections for +// efficient re-use. +// +// The returned connection is only used by one goroutine at a time. +// +// The name may be a filename, e.g., "/tmp/mydata.sqlite", or a URI, in which +// case it may include a '?' followed by one or more query parameters. +// For example, "file:///tmp/mydata.sqlite?_pragma=foreign_keys(1)&_time_format=sqlite". +// The supported query parameters are: +// +// _pragma: Each value will be run as a "PRAGMA ..." statement (with the PRAGMA +// keyword added for you). May be specified more than once, '&'-separated. For more +// information on supported PRAGMAs see: https://www.sqlite.org/pragma.html +// +// _time_format: The name of a format to use when writing time values to the database. +// The currently supported values are (1) "sqlite" for YYYY-MM-DD HH:MM:SS.SSS[+-]HH:MM +// (format 4 from https://www.sqlite.org/lang_datefunc.html#time_values with sub-second +// precision and timezone specifier) and (2) "datetime" for YYYY-MM-DD HH:MM:SS +// (format 3, matching the output of SQLite's datetime() function). +// If this parameter is not specified, then the default String() format will be used. +// +// _time_integer_format: The name of a integer format to use when writing time values. +// By default, the time is stored as string and the format can be set with _time_format +// parameter. If _time_integer_format is set, the time will be stored as an integer and +// the integer value will depend on the integer format. +// If you decide to set both _time_format and _time_integer_format, the time will be +// converted as integer and the _time_format value will be ignored. +// Currently the supported value are "unix","unix_milli", "unix_micro" and "unix_nano", +// which corresponds to seconds, milliseconds, microseconds or nanoseconds +// since unixepoch (1 January 1970 00:00:00 UTC). +// +// _inttotime: Enable conversion of time column (DATE, DATETIME,TIMESTAMP) from integer +// to time if the field contain integer (int64). +// +// _texttotime: Enable ColumnTypeScanType to report time.Time instead of string +// for TEXT columns declared as DATE, DATETIME, TIME, or TIMESTAMP. +// +// _timezone: A timezone to use for all time reads and writes, such as "UTC". +// The value is parsed by time.LoadLocation. +// Writes will convert to the timezone before formatting as a string; +// it does not impact _inttotime integer values, as they always use UTC. +// Reads will interpret timezone-less strings as being in this timezone. +// Values that are in a known timezone, such as a string with a timezone specifier +// or an integer with _inttotime (specified to be in UTC), will be converted to this timezone. +// +// _txlock: The locking behavior to use when beginning a transaction. May be +// "deferred" (the default), "immediate", or "exclusive" (case insensitive). See: +// https://www.sqlite.org/lang_transaction.html#deferred_immediate_and_exclusive_transactions +// +// _dqs: Opt-in toggle for SQLite's double-quoted string literal +// compatibility quirk on the connection. Accepts the values strconv.ParseBool +// understands ("0"/"1", "false"/"true", "f"/"t", case-insensitive). When +// absent or set to a true value, SQLite's built-in behavior is unchanged: +// a double-quoted identifier that fails to resolve is silently +// re-interpreted as a string literal. When set to a false value, +// SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML are both turned +// off via sqlite3_db_config so that mistakes hidden by the legacy +// fallback surface as a parse error instead. See: +// https://www.sqlite.org/quirks.html#dblquote and +// https://gitlab.com/cznic/sqlite/-/issues/61 +// +// _error_rc: Opt-in error-string reporting mode for synthesised errors. +// Accepts the values strconv.ParseBool understands ("0"/"1", +// "false"/"true", "f"/"t", case-insensitive). When absent or set to a +// false value, the legacy "errstr: errmsg (rc)" form is preserved +// byte-for-byte: the canonical sqlite3_errstr(rc) and the connection's +// sqlite3_errmsg(db) are concatenated even when the latter belongs to a +// different operation, which can read as misleading on open-time +// failures such as SQLITE_CANTOPEN reporting "out of memory". When set +// to a true value, the appended errmsg is suppressed if +// sqlite3_extended_errcode(db) is inconsistent with the operation rc +// (full match first, primary code as fallback); in that case the +// canonical errstr(rc) is used alone. The Code() returned by the +// driver's *Error is unchanged in either mode. The parameter is parsed +// before sqlite3_open_v2 so open-time errors are covered. See +// https://gitlab.com/cznic/sqlite/-/issues/230. +func (d *Driver) Open(name string) (conn driver.Conn, err error) { + if dmesgs { + defer func() { + dmesg("name %q: (driver.Conn %p, err %v)", name, conn, err) + }() + } + c, err := newConn(name) + if err != nil { + return nil, err + } + + for _, udf := range d.udfs { + if err = c.createFunctionInternal(udf); err != nil { + c.Close() + return nil, err + } + } + for _, coll := range d.collations { + if err = c.createCollationInternal(coll); err != nil { + c.Close() + return nil, err + } + } + for _, connHookFn := range d.connectionHooks { + if err = connHookFn(c, name); err != nil { + c.Close() + return nil, fmt.Errorf("connection hook: %w", err) + } + } + // Register any vtab modules with this connection. + // Note: vtab module registration applies to new connections only. If a + // module is registered after a connection has been opened, that existing + // connection will not see the module; open a new connection to use it. + if err := c.registerModules(); err != nil { + c.Close() + return nil, err + } + return c, nil +} + +// RegisterConnectionHook registers a function to be called after each connection +// is opened. This is called after all the connection has been set up. +func (d *Driver) RegisterConnectionHook(fn ConnectionHookFn) { + d.connectionHooks = append(d.connectionHooks, fn) +} diff --git a/internal/engine/error.go b/internal/engine/error.go new file mode 100644 index 0000000..05e71df --- /dev/null +++ b/internal/engine/error.go @@ -0,0 +1,75 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +// Error represents sqlite library error code. +type Error struct { + msg string + code int +} + +// Error implements error. +func (e *Error) Error() string { return e.msg } + +// Code returns the sqlite result code for this error. +func (e *Error) Code() int { return e.code } + +var ( + // ErrorCodeString maps Error.Code() to its string representation. + ErrorCodeString = map[int]string{ + sqlite3.SQLITE_ABORT: "Callback routine requested an abort (SQLITE_ABORT)", + sqlite3.SQLITE_AUTH: "Authorization denied (SQLITE_AUTH)", + sqlite3.SQLITE_BUSY: "The database file is locked (SQLITE_BUSY)", + sqlite3.SQLITE_CANTOPEN: "Unable to open the database file (SQLITE_CANTOPEN)", + sqlite3.SQLITE_CONSTRAINT: "Abort due to constraint violation (SQLITE_CONSTRAINT)", + sqlite3.SQLITE_CORRUPT: "The database disk image is malformed (SQLITE_CORRUPT)", + sqlite3.SQLITE_DONE: "sqlite3_step() has finished executing (SQLITE_DONE)", + sqlite3.SQLITE_EMPTY: "Internal use only (SQLITE_EMPTY)", + sqlite3.SQLITE_ERROR: "Generic error (SQLITE_ERROR)", + sqlite3.SQLITE_FORMAT: "Not used (SQLITE_FORMAT)", + sqlite3.SQLITE_FULL: "Insertion failed because database is full (SQLITE_FULL)", + sqlite3.SQLITE_INTERNAL: "Internal logic error in SQLite (SQLITE_INTERNAL)", + sqlite3.SQLITE_INTERRUPT: "Operation terminated by sqlite3_interrupt()(SQLITE_INTERRUPT)", + sqlite3.SQLITE_IOERR | (1 << 8): "(SQLITE_IOERR_READ)", + sqlite3.SQLITE_IOERR | (10 << 8): "(SQLITE_IOERR_DELETE)", + sqlite3.SQLITE_IOERR | (11 << 8): "(SQLITE_IOERR_BLOCKED)", + sqlite3.SQLITE_IOERR | (12 << 8): "(SQLITE_IOERR_NOMEM)", + sqlite3.SQLITE_IOERR | (13 << 8): "(SQLITE_IOERR_ACCESS)", + sqlite3.SQLITE_IOERR | (14 << 8): "(SQLITE_IOERR_CHECKRESERVEDLOCK)", + sqlite3.SQLITE_IOERR | (15 << 8): "(SQLITE_IOERR_LOCK)", + sqlite3.SQLITE_IOERR | (16 << 8): "(SQLITE_IOERR_CLOSE)", + sqlite3.SQLITE_IOERR | (17 << 8): "(SQLITE_IOERR_DIR_CLOSE)", + sqlite3.SQLITE_IOERR | (2 << 8): "(SQLITE_IOERR_SHORT_READ)", + sqlite3.SQLITE_IOERR | (3 << 8): "(SQLITE_IOERR_WRITE)", + sqlite3.SQLITE_IOERR | (4 << 8): "(SQLITE_IOERR_FSYNC)", + sqlite3.SQLITE_IOERR | (5 << 8): "(SQLITE_IOERR_DIR_FSYNC)", + sqlite3.SQLITE_IOERR | (6 << 8): "(SQLITE_IOERR_TRUNCATE)", + sqlite3.SQLITE_IOERR | (7 << 8): "(SQLITE_IOERR_FSTAT)", + sqlite3.SQLITE_IOERR | (8 << 8): "(SQLITE_IOERR_UNLOCK)", + sqlite3.SQLITE_IOERR | (9 << 8): "(SQLITE_IOERR_RDLOCK)", + sqlite3.SQLITE_IOERR: "Some kind of disk I/O error occurred (SQLITE_IOERR)", + sqlite3.SQLITE_LOCKED | (1 << 8): "(SQLITE_LOCKED_SHAREDCACHE)", + sqlite3.SQLITE_LOCKED: "A table in the database is locked (SQLITE_LOCKED)", + sqlite3.SQLITE_MISMATCH: "Data type mismatch (SQLITE_MISMATCH)", + sqlite3.SQLITE_MISUSE: "Library used incorrectly (SQLITE_MISUSE)", + sqlite3.SQLITE_NOLFS: "Uses OS features not supported on host (SQLITE_NOLFS)", + sqlite3.SQLITE_NOMEM: "A malloc() failed (SQLITE_NOMEM)", + sqlite3.SQLITE_NOTADB: "File opened that is not a database file (SQLITE_NOTADB)", + sqlite3.SQLITE_NOTFOUND: "Unknown opcode in sqlite3_file_control() (SQLITE_NOTFOUND)", + sqlite3.SQLITE_NOTICE: "Notifications from sqlite3_log() (SQLITE_NOTICE)", + sqlite3.SQLITE_PERM: "Access permission denied (SQLITE_PERM)", + sqlite3.SQLITE_PROTOCOL: "Database lock protocol error (SQLITE_PROTOCOL)", + sqlite3.SQLITE_RANGE: "2nd parameter to sqlite3_bind out of range (SQLITE_RANGE)", + sqlite3.SQLITE_READONLY: "Attempt to write a readonly database (SQLITE_READONLY)", + sqlite3.SQLITE_ROW: "sqlite3_step() has another row ready (SQLITE_ROW)", + sqlite3.SQLITE_SCHEMA: "The database schema changed (SQLITE_SCHEMA)", + sqlite3.SQLITE_TOOBIG: "String or BLOB exceeds size limit (SQLITE_TOOBIG)", + sqlite3.SQLITE_WARNING: "Warnings from sqlite3_log() (SQLITE_WARNING)", + } +) diff --git a/internal/engine/fcntl.go b/internal/engine/fcntl.go new file mode 100644 index 0000000..831da50 --- /dev/null +++ b/internal/engine/fcntl.go @@ -0,0 +1,73 @@ +// Copyright 2024 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "unsafe" + + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" + "github.com/hanzoai/sqlite/internal/libc" +) + +// Access to sqlite3_file_control +type FileControl interface { + // Set or query SQLITE_FCNTL_PERSIST_WAL, returns set mode or query result + FileControlPersistWAL(dbName string, mode int) (int, error) + // Query SQLITE_FCNTL_DATA_VERSION, returns the pager-cache data version + // for dbName. The value changes whenever the contents of the database + // file change, which makes it suitable for cache-invalidation use cases. + // See + // https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntldataversion. + FileControlDataVersion(dbName string) (uint32, error) +} + +var _ FileControl = (*conn)(nil) + +func (c *conn) FileControlPersistWAL(dbName string, mode int) (int, error) { + pi32 := c.tls.Alloc(4) + defer c.tls.Free(4) + + *(*int32)(unsafe.Pointer(pi32)) = int32(mode) + err := c.fileControl(dbName, sqlite3.SQLITE_FCNTL_PERSIST_WAL, pi32) + return int(*(*int32)(unsafe.Pointer(pi32))), err +} + +func (c *conn) FileControlDataVersion(dbName string) (uint32, error) { + pu32 := c.tls.Alloc(4) + defer c.tls.Free(4) + + *(*uint32)(unsafe.Pointer(pu32)) = 0 + err := c.fileControl(dbName, sqlite3.SQLITE_FCNTL_DATA_VERSION, pu32) + return *(*uint32)(unsafe.Pointer(pu32)), err +} + +// fileControlReserveBytes sets SQLITE_FCNTL_RESERVE_BYTES on "main" to n. The +// SQLCipher page format carries an 80-byte per-page trailer (IV+HMAC), so the +// pure-Go codec VFS needs SQLite to leave that many reserve bytes at the end of +// every page. This must run before the first page-1 write on a NEW database; on +// an existing one the reserve already travels in header byte 20 and this just +// confirms it. The DSN param `_reserve_bytes=N` (handled in applyQueryParams +// before any writing pragma) is how the keyed codec path sets it. +func (c *conn) fileControlReserveBytes(n int) error { + pi32 := c.tls.Alloc(4) + defer c.tls.Free(4) + + *(*int32)(unsafe.Pointer(pi32)) = int32(n) + return c.fileControl("main", sqlite3.SQLITE_FCNTL_RESERVE_BYTES, pi32) +} + +func (c *conn) fileControl(dbName string, op int, pArg uintptr) error { + zDbName, err := libc.CString(dbName) + if err != nil { + return err + } + defer c.free(zDbName) + + if rc := sqlite3.Xsqlite3_file_control(c.tls, c.db, zDbName, int32(op), pArg); rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + + return nil +} diff --git a/internal/engine/lib/defs.go b/internal/engine/lib/defs.go new file mode 100644 index 0000000..71557d8 --- /dev/null +++ b/internal/engine/lib/defs.go @@ -0,0 +1,16 @@ +// Copyright 2022 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite3 + +const ( + SQLITE_STATIC = uintptr(0) // ((sqlite3_destructor_type)0) + SQLITE_TRANSIENT = ^uintptr(0) // ((sqlite3_destructor_type)-1) +) + +type ( + Sqlite3_index_constraint = sqlite3_index_constraint + Sqlite3_index_orderby = sqlite3_index_orderby + Sqlite3_index_constraint_usage = sqlite3_index_constraint_usage +) diff --git a/internal/engine/lib/hooks.go b/internal/engine/lib/hooks.go new file mode 100644 index 0000000..5dd7d08 --- /dev/null +++ b/internal/engine/lib/hooks.go @@ -0,0 +1,20 @@ +// Copyright 2019 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !(linux && arm64) + +package sqlite3 + +import ( + "github.com/hanzoai/sqlite/internal/libc" +) + +// Format and write a message to the log if logging is enabled. +func X__ccgo_sqlite3_log(t *libc.TLS, iErrCode int32, zFormat uintptr, va uintptr) { /* sqlite3.c:29405:17: */ + libc.X__ccgo_sqlite3_log(t, iErrCode, zFormat, va) +} + +func PatchIssue199() { + // nop +} diff --git a/internal/engine/lib/hooks_linux_arm64.go b/internal/engine/lib/hooks_linux_arm64.go new file mode 100644 index 0000000..218e470 --- /dev/null +++ b/internal/engine/lib/hooks_linux_arm64.go @@ -0,0 +1,30 @@ +// Copyright 2019 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite3 + +import ( + "syscall" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// Format and write a message to the log if logging is enabled. +func X__ccgo_sqlite3_log(t *libc.TLS, iErrCode int32, zFormat uintptr, va uintptr) { /* sqlite3.c:29405:17: */ + libc.X__ccgo_sqlite3_log(t, iErrCode, zFormat, va) +} + +// https://gitlab.com/cznic/sqlite/-/issues/199 +// +// We are currently stuck on libc@v1.55.3. Until that is resolved - fix the +// problem at runtime. +func PatchIssue199() { + p := unsafe.Pointer(&_aSyscall) + *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(_unixGetpagesizeIssue199) +} + +func _unixGetpagesizeIssue199(tls *libc.TLS) (r int32) { + return int32(syscall.Getpagesize()) +} diff --git a/internal/engine/lib/mutex.go b/internal/engine/lib/mutex.go new file mode 100644 index 0000000..c38936e --- /dev/null +++ b/internal/engine/lib/mutex.go @@ -0,0 +1,345 @@ +// Copyright 2021 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !linux + +package sqlite3 + +import ( + "fmt" + "sync" + "sync/atomic" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" +) + +func init() { + tls := libc.NewTLS() + if Xsqlite3_threadsafe(tls) == 0 { + panic(fmt.Errorf("sqlite: thread safety configuration error")) + } + + varArgs := libc.Xmalloc(tls, types.Size_t(unsafe.Sizeof(uintptr(0)))) + if varArgs == 0 { + panic(fmt.Errorf("cannot allocate memory")) + } + + // int sqlite3_config(int, ...); + if rc := Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(varArgs, uintptr(unsafe.Pointer(&mutexMethods)))); rc != SQLITE_OK { + p := Xsqlite3_errstr(tls, rc) + str := libc.GoString(p) + panic(fmt.Errorf("sqlite: failed to configure mutex methods: %v", str)) + } + + libc.Xfree(tls, varArgs) + tls.Close() +} + +var ( + mutexMethods = Sqlite3_mutex_methods{ + FxMutexInit: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{mutexInit})), + FxMutexEnd: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{mutexEnd})), + FxMutexAlloc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, int32) uintptr + }{mutexAlloc})), + FxMutexFree: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{mutexFree})), + FxMutexEnter: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{mutexEnter})), + FxMutexTry: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr) int32 + }{mutexTry})), + FxMutexLeave: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{mutexLeave})), + FxMutexHeld: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr) int32 + }{mutexHeld})), + FxMutexNotheld: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr) int32 + }{mutexNotheld})), + } + + mutexApp10 mutex + mutexApp20 mutex + mutexApp30 mutex + mutexLRU0 mutex + mutexMaster0 mutex + mutexMem0 mutex + mutexOpen0 mutex + mutexPMem0 mutex + mutexPRNG0 mutex + mutexVFS10 mutex + mutexVFS20 mutex + mutexVFS30 mutex + + mutexApp1 = uintptr(unsafe.Pointer(&mutexApp10)) + mutexApp2 = uintptr(unsafe.Pointer(&mutexApp20)) + mutexApp3 = uintptr(unsafe.Pointer(&mutexApp30)) + mutexLRU = uintptr(unsafe.Pointer(&mutexLRU0)) + mutexMaster = uintptr(unsafe.Pointer(&mutexMaster0)) + mutexMem = uintptr(unsafe.Pointer(&mutexMem0)) + mutexOpen = uintptr(unsafe.Pointer(&mutexOpen0)) + mutexPMem = uintptr(unsafe.Pointer(&mutexPMem0)) + mutexPRNG = uintptr(unsafe.Pointer(&mutexPRNG0)) + mutexVFS1 = uintptr(unsafe.Pointer(&mutexVFS10)) + mutexVFS2 = uintptr(unsafe.Pointer(&mutexVFS20)) + mutexVFS3 = uintptr(unsafe.Pointer(&mutexVFS30)) +) + +type mutex struct { + sync.Mutex + cnt int32 + id int32 // tls.ID + recursive bool +} + +// int (*xMutexInit)(void); +// +// The xMutexInit method defined by this structure is invoked as part of system +// initialization by the sqlite3_initialize() function. The xMutexInit routine +// is called by SQLite exactly once for each effective call to +// sqlite3_initialize(). +// +// The xMutexInit() method must be threadsafe. It must be harmless to invoke +// xMutexInit() multiple times within the same process and without intervening +// calls to xMutexEnd(). Second and subsequent calls to xMutexInit() must be +// no-ops. xMutexInit() must not use SQLite memory allocation (sqlite3_malloc() +// and its associates). +// +// If xMutexInit fails in any way, it is expected to clean up after itself +// prior to returning. +func mutexInit(tls *libc.TLS) int32 { return SQLITE_OK } + +// int (*xMutexEnd)(void); +func mutexEnd(tls *libc.TLS) int32 { return SQLITE_OK } + +// sqlite3_mutex *(*xMutexAlloc)(int); +// +// The sqlite3_mutex_alloc() routine allocates a new mutex and returns a +// pointer to it. The sqlite3_mutex_alloc() routine returns NULL if it is +// unable to allocate the requested mutex. The argument to +// sqlite3_mutex_alloc() must one of these integer constants: +// +// SQLITE_MUTEX_FAST +// SQLITE_MUTEX_RECURSIVE +// SQLITE_MUTEX_STATIC_MASTER +// SQLITE_MUTEX_STATIC_MEM +// SQLITE_MUTEX_STATIC_OPEN +// SQLITE_MUTEX_STATIC_PRNG +// SQLITE_MUTEX_STATIC_LRU +// SQLITE_MUTEX_STATIC_PMEM +// SQLITE_MUTEX_STATIC_APP1 +// SQLITE_MUTEX_STATIC_APP2 +// SQLITE_MUTEX_STATIC_APP3 +// SQLITE_MUTEX_STATIC_VFS1 +// SQLITE_MUTEX_STATIC_VFS2 +// SQLITE_MUTEX_STATIC_VFS3 +// +// The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) cause +// sqlite3_mutex_alloc() to create a new mutex. The new mutex is recursive when +// SQLITE_MUTEX_RECURSIVE is used but not necessarily so when SQLITE_MUTEX_FAST +// is used. The mutex implementation does not need to make a distinction +// between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does not want to. +// SQLite will only request a recursive mutex in cases where it really needs +// one. If a faster non-recursive mutex implementation is available on the host +// platform, the mutex subsystem might return such a mutex in response to +// SQLITE_MUTEX_FAST. +// +// The other allowed parameters to sqlite3_mutex_alloc() (anything other than +// SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return a pointer to a +// static preexisting mutex. Nine static mutexes are used by the current +// version of SQLite. Future versions of SQLite may add additional static +// mutexes. Static mutexes are for internal use by SQLite only. Applications +// that use SQLite mutexes should use only the dynamic mutexes returned by +// SQLITE_MUTEX_FAST or SQLITE_MUTEX_RECURSIVE. +// +// Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST or +// SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() returns a +// different mutex on every call. For the static mutex types, the same mutex is +// returned on every call that has the same type number. +func mutexAlloc(tls *libc.TLS, typ int32) (r uintptr) { + switch typ { + case SQLITE_MUTEX_FAST: + r = libc.Xcalloc(tls, 1, types.Size_t(unsafe.Sizeof(mutex{}))) + return r + case SQLITE_MUTEX_RECURSIVE: + r = libc.Xcalloc(tls, 1, types.Size_t(unsafe.Sizeof(mutex{}))) + (*mutex)(unsafe.Pointer(r)).recursive = true + return r + case SQLITE_MUTEX_STATIC_MASTER: + return mutexMaster + case SQLITE_MUTEX_STATIC_MEM: + return mutexMem + case SQLITE_MUTEX_STATIC_OPEN: + return mutexOpen + case SQLITE_MUTEX_STATIC_PRNG: + return mutexPRNG + case SQLITE_MUTEX_STATIC_LRU: + return mutexLRU + case SQLITE_MUTEX_STATIC_PMEM: + return mutexPMem + case SQLITE_MUTEX_STATIC_APP1: + return mutexApp1 + case SQLITE_MUTEX_STATIC_APP2: + return mutexApp2 + case SQLITE_MUTEX_STATIC_APP3: + return mutexApp3 + case SQLITE_MUTEX_STATIC_VFS1: + return mutexVFS1 + case SQLITE_MUTEX_STATIC_VFS2: + return mutexVFS2 + case SQLITE_MUTEX_STATIC_VFS3: + return mutexVFS3 + default: + return 0 + } +} + +// void (*xMutexFree)(sqlite3_mutex *); +func mutexFree(tls *libc.TLS, m uintptr) { + libc.Xfree(tls, m) +} + +// The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt to enter +// a mutex. If another thread is already within the mutex, +// sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return +// SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK upon +// successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can be +// entered multiple times by the same thread. In such cases, the mutex must be +// exited an equal number of times before another thread can enter. If the same +// thread tries to enter any mutex other than an SQLITE_MUTEX_RECURSIVE more +// than once, the behavior is undefined. +// +// If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or +// sqlite3_mutex_leave() is a NULL pointer, then all three routines behave as +// no-ops. + +// void (*xMutexEnter)(sqlite3_mutex *); +func mutexEnter(tls *libc.TLS, m uintptr) { + if m == 0 { + return + } + + // Non-recursive mutex: Standard Go lock + if !(*mutex)(unsafe.Pointer(m)).recursive { + (*mutex)(unsafe.Pointer(m)).Lock() + atomic.StoreInt32(&(*mutex)(unsafe.Pointer(m)).id, tls.ID) + return + } + + // Recursive mutex: Check if we already own it (Fast Path) + // We can safely read ptr.id without a lock here because if it equals tls.ID, + // WE are the writer, so no other thread can be changing it. + if atomic.LoadInt32(&(*mutex)(unsafe.Pointer(m)).id) == tls.ID { + (*mutex)(unsafe.Pointer(m)).cnt++ + return + } + + // We don't own it. Acquire physical lock (Slow Path). + // This blocks until the mutex is free. + (*mutex)(unsafe.Pointer(m)).Lock() + + // Now that we have the lock, claim ownership. + atomic.StoreInt32(&(*mutex)(unsafe.Pointer(m)).id, tls.ID) + (*mutex)(unsafe.Pointer(m)).cnt = 1 +} + +// int (*xMutexTry)(sqlite3_mutex *); +func mutexTry(tls *libc.TLS, m uintptr) int32 { + if m == 0 { + return SQLITE_OK + } + + // Non-recursive mutex + if !(*mutex)(unsafe.Pointer(m)).recursive { + if (*mutex)(unsafe.Pointer(m)).TryLock() { + atomic.StoreInt32(&(*mutex)(unsafe.Pointer(m)).id, tls.ID) + return SQLITE_OK + } + + return SQLITE_BUSY + } + + // Recursive mutex: Check if we already own it (Fast Path) + if atomic.LoadInt32(&(*mutex)(unsafe.Pointer(m)).id) == tls.ID { + (*mutex)(unsafe.Pointer(m)).cnt++ + return SQLITE_OK + } + + // Try to acquire physical lock + if (*mutex)(unsafe.Pointer(m)).TryLock() { + atomic.StoreInt32(&(*mutex)(unsafe.Pointer(m)).id, tls.ID) + (*mutex)(unsafe.Pointer(m)).cnt = 1 + return SQLITE_OK + } + + return SQLITE_BUSY +} + +// void (*xMutexLeave)(sqlite3_mutex *); +func mutexLeave(tls *libc.TLS, m uintptr) { + if m == 0 { + return + } + + // Non-recursive mutex + if !(*mutex)(unsafe.Pointer(m)).recursive { + atomic.StoreInt32(&(*mutex)(unsafe.Pointer(m)).id, 0) + (*mutex)(unsafe.Pointer(m)).Unlock() + return + } + + // Recursive mutex: Decrement count + (*mutex)(unsafe.Pointer(m)).cnt-- + + // If count reaches zero, we are fully releasing the mutex. + if (*mutex)(unsafe.Pointer(m)).cnt == 0 { + atomic.StoreInt32(&(*mutex)(unsafe.Pointer(m)).id, 0) + (*mutex)(unsafe.Pointer(m)).Unlock() + } +} + +// The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines are intended +// for use inside assert() statements. The SQLite core never uses these +// routines except inside an assert() and applications are advised to follow +// the lead of the core. The SQLite core only provides implementations for +// these routines when it is compiled with the SQLITE_DEBUG flag. External +// mutex implementations are only required to provide these routines if +// SQLITE_DEBUG is defined and if NDEBUG is not defined. +// +// These routines should return true if the mutex in their argument is held or +// not held, respectively, by the calling thread. +// +// The implementation is not required to provide versions of these routines +// that actually work. If the implementation does not provide working versions +// of these routines, it should at least provide stubs that always return true +// so that one does not get spurious assertion failures. +// +// If the argument to sqlite3_mutex_held() is a NULL pointer then the routine +// should return 1. This seems counter-intuitive since clearly the mutex cannot +// be held if it does not exist. But the reason the mutex does not exist is +// because the build is not using mutexes. And we do not want the assert() +// containing the call to sqlite3_mutex_held() to fail, so a non-zero return is +// the appropriate thing to do. The sqlite3_mutex_notheld() interface should +// also return 1 when given a NULL pointer. + +// int (*xMutexHeld)(sqlite3_mutex *); +func mutexHeld(tls *libc.TLS, m uintptr) int32 { + if m == 0 { + return 1 + } + + // atomic.Load is required because we might be checking a mutex + // that we do not own (and thus another thread might be writing to). + return libc.Bool32(atomic.LoadInt32(&(*mutex)(unsafe.Pointer(m)).id) == tls.ID) +} + +// int (*xMutexNotheld)(sqlite3_mutex *); +func mutexNotheld(tls *libc.TLS, m uintptr) int32 { + if m == 0 { + return 1 + } + + // Returns True if ID is Zero (unheld) OR ID is some other thread's ID. + return libc.Bool32(atomic.LoadInt32(&(*mutex)(unsafe.Pointer(m)).id) != tls.ID) +} diff --git a/internal/engine/lib/sqlite.go b/internal/engine/lib/sqlite.go new file mode 100644 index 0000000..f67190e --- /dev/null +++ b/internal/engine/lib/sqlite.go @@ -0,0 +1,49056 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +package sqlite3 + +import ( + "reflect" + "sync" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const ALLBITS = -1 + +type AggInfo = TAggInfo + +type AggInfo_col = TAggInfo_col + +type AggInfo_func = TAggInfo_func + +type AsciiTokenizer = TAsciiTokenizer + +type AuthContext = TAuthContext + +type AutoincInfo = TAutoincInfo + +type AuxData = TAuxData + +const BITVEC_MXHASH = 0 + +const BITVEC_NBIT = 0 + +const BITVEC_NELEM = 0 + +const BITVEC_NINT = 0 + +const BITVEC_SZ = 512 + +const BITVEC_SZELEM = 8 + +const BITVEC_TELEM = 0 + +const BITVEC_USIZE = 0 + +const BTALLOC_ANY = 0 + +const BTALLOC_EXACT = 1 + +const BTALLOC_LE = 2 + +const BTCF_AtLast = 8 + +const BTCF_Incrblob = 16 + +const BTCF_Multiple = 32 + +const BTCF_Pinned = 64 + +const BTCF_ValidNKey = 2 + +const BTCF_ValidOvfl = 4 + +const BTCF_WriteFlag = 1 + +const BTCURSOR_FIRST_UNINIT = 0 + +const BTCURSOR_MAX_DEPTH = 20 + +const BTREE_APPEND = 8 + +const BTREE_APPLICATION_ID = 8 + +const BTREE_AUTOVACUUM_FULL = 1 + +const BTREE_AUTOVACUUM_INCR = 2 + +const BTREE_AUTOVACUUM_NONE = 0 + +const BTREE_AUXDELETE = 4 + +const BTREE_BLOBKEY = 2 + +const BTREE_BULKLOAD = 1 + +const BTREE_DATA_VERSION = 15 + +const BTREE_DEFAULT_CACHE_SIZE = 3 + +const BTREE_FDK_RANGE = 10 + +const BTREE_FILE_FORMAT = 2 + +const BTREE_FORDELETE = 8 + +const BTREE_FREE_PAGE_COUNT = 0 + +const BTREE_HINT_RANGE = 0 + +const BTREE_INCR_VACUUM = 7 + +const BTREE_INTKEY = 1 + +const BTREE_LARGEST_ROOT_PAGE = 4 + +const BTREE_MEMORY = 2 + +const BTREE_OMIT_JOURNAL = 1 + +const BTREE_PREFORMAT = 128 + +const BTREE_SAVEPOSITION = 2 + +const BTREE_SCHEMA_VERSION = 1 + +const BTREE_SEEK_EQ = 2 + +const BTREE_SINGLE = 4 + +const BTREE_TEXT_ENCODING = 5 + +const BTREE_ULPDISTORTION = 2 + +const BTREE_UNORDERED = 8 + +const BTREE_USER_VERSION = 6 + +const BTREE_WRCSR = 4 + +const BTS_EXCLUSIVE = 64 + +const BTS_FAST_SECURE = 12 + +const BTS_INITIALLY_EMPTY = 16 + +const BTS_NO_WAL = 32 + +const BTS_OVERWRITE = 8 + +const BTS_PAGESIZE_FIXED = 2 + +const BTS_PENDING = 128 + +const BTS_READ_ONLY = 1 + +const BTS_SECURE_DELETE = 4 + +const BT_MAX_LOCAL = 65501 + +type BenignMallocHooks = TBenignMallocHooks + +type Bitmask = TBitmask + +/* +** The number of bits in a Bitmask. "BMS" means "BitMask Size". + */ + +/* +** A bit in a Bitmask + */ + +type Bitvec = TBitvec + +type Bool = TBool + +type BtCursor = TBtCursor + +type BtLock = TBtLock + +type BtShared = TBtShared + +type Btree = TBtree + +type BtreePayload = TBtreePayload + +/************** End of btree.h ***********************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include vdbe.h in the middle of sqliteInt.h ******************/ +/************** Begin file vdbe.h ********************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** Header file for the Virtual DataBase Engine (VDBE) +** +** This header defines the interface to the virtual database engine +** or VDBE. The VDBE implements an abstract machine that runs a +** simple program to access and modify the underlying database. + */ +/* #include */ + +type BusyHandler = TBusyHandler + +/* +** Name of table that holds the database schema. +** +** The PREFERRED names are used wherever possible. But LEGACY is also +** used for backwards compatibility. +** +** 1. Queries can use either the PREFERRED or the LEGACY names +** 2. The sqlite3_set_authorizer() callback uses the LEGACY name +** 3. The PRAGMA table_list statement uses the PREFERRED name +** +** The LEGACY names are stored in the internal symbol hash table +** in support of (2). Names are translated using sqlite3PreferredTableName() +** for (3). The sqlite3FindTable() function takes care of translating +** names for (1). +** +** Note that "sqlite_temp_schema" can also be called "temp.sqlite_schema". + */ + +/* +** The root-page of the schema table. + */ + +/* +** The name of the schema table. The name is different for TEMP. + */ + +/* +** A convenience macro that returns the number of elements in +** an array. + */ + +/* +** Determine if the argument is a power of two + */ + +/* +** The following value as a destructor means to use sqlite3DbFree(). +** The sqlite3DbFree() routine requires two parameters instead of the +** one parameter that destructors normally want. So we have to introduce +** this magic value that the code knows to handle differently. Any +** pointer will work here as long as it is distinct from SQLITE_STATIC +** and SQLITE_TRANSIENT. + */ + +/* +** When SQLITE_OMIT_WSD is defined, it means that the target platform does +** not support Writable Static Data (WSD) such as global and static variables. +** All variables must either be on the stack or dynamically allocated from +** the heap. When WSD is unsupported, the variable declarations scattered +** throughout the SQLite code must become constants instead. The SQLITE_WSD +** macro is used for this purpose. And instead of referencing the variable +** directly, we use its constant as a key to lookup the run-time allocated +** buffer that holds real variable. The constant is also the initializer +** for the run-time allocated buffer. +** +** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL +** macros become no-ops and have zero performance impact. + */ + +/* +** The following macros are used to suppress compiler warnings and to +** make it clear to human readers when a function parameter is deliberately +** left unused within the body of a function. This usually happens when +** a function is called via a function pointer. For example the +** implementation of an SQL aggregate step callback may not use the +** parameter indicating the number of arguments passed to the aggregate, +** if it knows that this is enforced elsewhere. +** +** When a function parameter is not used at all within the body of a function, +** it is generally named "NotUsed" or "NotUsed2" to make things even clearer. +** However, these macros may also be used to suppress warnings related to +** parameters that may or may not be used depending on compilation options. +** For example those parameters only used in assert() statements. In these +** cases the parameters are named as per the usual conventions. + */ + +const CACHE_STALE = 0 + +const CARRAY_BLOB = 4 + +const CARRAY_DOUBLE = 2 + +const CARRAY_INT32 = 0 + +const CARRAY_INT64 = 1 + +const CARRAY_TEXT = 3 + +const CC_AND = 24 + +const CC_BANG = 15 + +const CC_BOM = 30 + +const CC_COMMA = 23 + +const CC_DIGIT = 3 + +const CC_DOLLAR = 4 + +const CC_DOT = 26 + +const CC_EQ = 14 + +const CC_GT = 13 + +const CC_ID = 27 + +const CC_ILLEGAL = 28 + +const CC_KYWD = 2 + +const CC_KYWD0 = 1 + +const CC_LP = 17 + +const CC_LT = 12 + +const CC_MINUS = 11 + +const CC_NUL = 29 + +const CC_PERCENT = 22 + +const CC_PIPE = 10 + +const CC_PLUS = 20 + +const CC_QUOTE = 8 + +const CC_QUOTE2 = 9 + +const CC_RP = 18 + +const CC_SEMI = 19 + +const CC_SLASH = 16 + +const CC_SPACE = 7 + +const CC_STAR = 21 + +const CC_TILDA = 25 + +const CC_VARALPHA = 5 + +const CC_VARNUM = 6 + +const CC_X = 0 + +type CInstIter = TCInstIter + +const CKCNSTRNT_COLUMN = 1 + +const CKCNSTRNT_ROWID = 2 + +const CLOCK_REALTIME = 0 + +const COLFLAG_BUSY = 256 + +const COLFLAG_GENERATED = 96 + +const COLFLAG_HASCOLL = 512 + +const COLFLAG_HASTYPE = 4 + +const COLFLAG_HIDDEN = 2 + +const COLFLAG_NOEXPAND = 1024 + +const COLFLAG_NOINSERT = 98 + +const COLFLAG_NOTAVAIL = 128 + +const COLFLAG_PRIMKEY = 1 + +const COLFLAG_SORTERREF = 16 + +const COLFLAG_STORED = 64 + +const COLFLAG_UNIQUE = 8 + +const COLFLAG_VIRTUAL = 32 + +const COLNAME_COLUMN = 4 + +const COLNAME_DATABASE = 2 + +const COLNAME_DECLTYPE = 1 + +const COLNAME_N = 5 + +const COLNAME_NAME = 0 + +const COLNAME_TABLE = 3 + +const COLTYPE_ANY = 1 + +const COLTYPE_BLOB = 2 + +const COLTYPE_CUSTOM = 0 + +const COLTYPE_INT = 3 + +const COLTYPE_INTEGER = 4 + +const COLTYPE_REAL = 5 + +const COLTYPE_TEXT = 6 + +const CURSOR_FAULT = 4 + +const CURSOR_INVALID = 1 + +const CURSOR_REQUIRESEEK = 3 + +const CURSOR_SKIPNEXT = 2 + +const CURSOR_VALID = 0 + +const CURTYPE_BTREE = 0 + +const CURTYPE_PSEUDO = 3 + +const CURTYPE_SORTER = 1 + +const CURTYPE_VTAB = 2 + +type CallCount = TCallCount + +type CellArray = TCellArray + +type CellInfo = TCellInfo + +/* +** Legal values for BtCursor.curFlags + */ + +/* +** Potential values for BtCursor.eState. +** +** CURSOR_INVALID: +** Cursor does not point to a valid entry. This can happen (for example) +** because the table is empty or because BtreeCursorFirst() has not been +** called. +** +** CURSOR_VALID: +** Cursor points to a valid entry. getPayload() etc. may be called. +** +** CURSOR_SKIPNEXT: +** Cursor is valid except that the Cursor.skipNext field is non-zero +** indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious() +** operation should be a no-op. +** +** CURSOR_REQUIRESEEK: +** The table that this cursor was opened on still exists, but has been +** modified since the cursor was last used. The cursor position is saved +** in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in +** this state, restoreCursorPosition() can be called to attempt to +** seek the cursor to the saved position. +** +** CURSOR_FAULT: +** An unrecoverable error (an I/O error or a malloc failure) has occurred +** on a different connection that shares the BtShared cache with this +** cursor. The error has left the cache in an inconsistent state. +** Do nothing else with this cursor. Any attempt to use the cursor +** should return the error code stored in BtCursor.skipNext + */ + +/* +** The database page the PENDING_BYTE occupies. This page is never used. + */ + +/* +** These macros define the location of the pointer-map entry for a +** database page. The first argument to each is the number of usable +** bytes on each page of the database (often 1024). The second is the +** page number to look up in the pointer map. +** +** PTRMAP_PAGENO returns the database page number of the pointer-map +** page that stores the required pointer. PTRMAP_PTROFFSET returns +** the offset of the requested map entry. +** +** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, +** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be +** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements +** this test. + */ + +/* +** The pointer map is a lookup table that identifies the parent page for +** each child page in the database file. The parent page is the page that +** contains a pointer to the child. Every page in the database contains +** 0 or 1 parent pages. (In this context 'database page' refers +** to any page that is not part of the pointer map itself.) Each pointer map +** entry consists of a single byte 'type' and a 4 byte parent page number. +** The PTRMAP_XXX identifiers below are the valid types. +** +** The purpose of the pointer map is to facility moving pages from one +** position in the file to another as part of autovacuum. When a page +** is moved, the pointer in its parent must be updated to point to the +** new location. The pointer map is used to locate the parent page quickly. +** +** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not +** used in this case. +** +** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number +** is not used in this case. +** +** PTRMAP_OVERFLOW1: The database page is the first page in a list of +** overflow pages. The page number identifies the page that +** contains the cell with a pointer to this overflow page. +** +** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of +** overflow pages. The page-number identifies the previous +** page in the overflow page list. +** +** PTRMAP_BTREE: The database page is a non-root btree page. The page number +** identifies the parent page in the btree. + */ + +/* A bunch of assert() statements to check the transaction state variables +** of handle p (type Btree*) are internally consistent. + */ + +/* +** The ISAUTOVACUUM macro is used within balance_nonroot() to determine +** if the database supports auto-vacuum or not. Because it is used +** within an expression that is an argument to another macro +** (sqliteMallocRaw), it is not possible to use conditional compilation. +** So, this macro is defined instead. + */ + +type ChangeData = TChangeData + +type CheckOnCtx = TCheckOnCtx + +/* +** True if the SrcList passed as the only argument contains at least +** one RIGHT or FULL JOIN. False otherwise. + */ + +type CollSeq = TCollSeq + +type Column = TColumn + +type CountCtx = TCountCtx + +type CoveringIndexCheck = TCoveringIndexCheck + +type Cte = TCte + +type CteUse = TCteUse + +const DBFLAG_EncodingFixed = 64 + +const DBFLAG_InternalFunc = 32 + +const DBFLAG_PreferBuiltin = 2 + +const DBFLAG_SchemaChange = 1 + +const DBFLAG_SchemaKnownOk = 16 + +const DBFLAG_Vacuum = 4 + +const DBFLAG_VacuumInto = 8 + +const DBPAGE_COLUMN_DATA = 1 + +const DBPAGE_COLUMN_PGNO = 0 + +const DBPAGE_COLUMN_SCHEMA = 2 + +const DBSTAT_PAGE_PADDING_BYTES = 256 + +const DB_ResetWanted = 8 + +const DB_SchemaLoaded = 1 + +const DB_UnresetViews = 2 + +const DIRECT_MODE = 0 + +type DateTime = TDateTime + +type Db = TDb + +type DbClientData = TDbClientData + +type DbFixer = TDbFixer + +type DbPage = TDbPage + +type DblquoteStr = TDblquoteStr + +type DbpageCursor = TDbpageCursor + +/* Columns */ + +type DbpageTable = TDbpageTable + +type DistinctCtx = TDistinctCtx + +const E2BIG = 7 + +const EACCES = 13 + +const EBADF = 9 + +const EBUSY = 16 + +const ECHILD = 10 + +const EDOM = 33 + +const EEXIST = 17 + +const EFAULT = 14 + +const EFBIG = 27 + +const EINTR = 4 + +const EINVAL = 22 + +const EIO = 5 + +const EISDIR = 21 + +const EMFILE = 24 + +const EMLINK = 31 + +const ENAME_NAME = 0 + +const ENAME_ROWID = 3 + +const ENAME_SPAN = 1 + +const ENAME_TAB = 2 + +const ENFILE = 23 + +const ENODEV = 19 + +const ENOENT = 2 + +const ENOEXEC = 8 + +const ENOMEM = 12 + +const ENOSPC = 28 + +const ENOTDIR = 20 + +const ENOTTY = 25 + +const ENXIO = 6 + +const EPERM = 1 + +const EPIPE = 32 + +const EP_Agg = 16 + +const EP_CanBeNull = 2097152 + +const EP_Collate = 512 + +const EP_Commuted = 1024 + +const EP_ConstFunc = 1048576 + +const EP_DblQuoted = 128 + +const EP_Distinct = 4 + +const EP_FixedCol = 32 + +const EP_FromDDL = 1073741824 + +const EP_FullSize = 131072 + +const EP_HasFunc = 8 + +const EP_IfNullRow = 262144 + +const EP_Immutable = 2 + +const EP_InfixFunc = 256 + +const EP_InnerON = 2 + +const EP_IntValue = 2048 + +const EP_IsFalse = 536870912 + +const EP_IsTrue = 268435456 + +const EP_Leaf = 8388608 + +const EP_NoReduce = 1 + +const EP_OuterON = 1 + +const EP_Propagate = 4194824 + +const EP_Quoted = 67108864 + +const EP_Reduced = 16384 + +const EP_Skip = 8192 + +const EP_Static = 134217728 + +const EP_Subquery = 4194304 + +const EP_Subrtn = 33554432 + +const EP_SubtArg = 2147483648 + +const EP_TokenOnly = 65536 + +const EP_Unlikely = 524288 + +const EP_VarSelect = 64 + +const EP_Win = 32768 + +const EP_WinFunc = 16777216 + +const EP_xIsSelect = 4096 + +const ERANGE = 34 + +const EROFS = 30 + +const ESPIPE = 29 + +const ESRCH = 3 + +const EU4_EXPR = 2 + +const EU4_IDX = 1 + +const EU4_NONE = 0 + +const EXCLUDED_TABLE_NUMBER = 2 + +const EXCLUSIVE_LOCK = 4 + +const EXDEV = 18 + +const EXIT_FAILURE = 1 + +const EXIT_SUCCESS = 0 + +const EXPRDUP_REDUCE = 1 + +const EXPR_FULLSIZE = 0 + +type EdupBuf = TEdupBuf + +type Expr = TExpr + +type ExprList = TExprList + +type ExprList_item = TExprList_item + +type FKey = TFKey + +const FLAG_SIGNED = 1 + +const FLAG_STRING = 4 + +const FTS5CSR_EOF = 1 + +const FTS5CSR_FREE_ZRANK = 16 + +const FTS5CSR_REQUIRE_CONTENT = 2 + +const FTS5CSR_REQUIRE_DOCSIZE = 4 + +const FTS5CSR_REQUIRE_INST = 8 + +const FTS5CSR_REQUIRE_POSLIST = 64 + +const FTS5CSR_REQUIRE_RESEEK = 32 + +const FTS5INDEX_QUERY_DESC = 2 + +const FTS5INDEX_QUERY_NOOUTPUT = 32 + +const FTS5INDEX_QUERY_NOTOKENDATA = 128 + +const FTS5INDEX_QUERY_PREFIX = 1 + +const FTS5INDEX_QUERY_SCAN = 8 + +const FTS5INDEX_QUERY_SCANONETERM = 256 + +const FTS5INDEX_QUERY_SKIPEMPTY = 16 + +const FTS5INDEX_QUERY_SKIPHASH = 64 + +const FTS5INDEX_QUERY_TEST_NOIDX = 4 + +const FTS5TOKEN = 0 + +const FTS5_AND = 2 + +const FTS5_AVERAGES_ROWID = 1 + +const FTS5_BI_MATCH = 1 + +const FTS5_BI_ORDER_DESC = 128 + +const FTS5_BI_ORDER_RANK = 32 + +const FTS5_BI_ORDER_ROWID = 64 + +const FTS5_BI_RANK = 2 + +const FTS5_BI_ROWID_EQ = 4 + +const FTS5_BI_ROWID_GE = 16 + +const FTS5_BI_ROWID_LE = 8 + +const FTS5_CARET = 12 + +const FTS5_COLON = 5 + +const FTS5_COMMA = 13 + +const FTS5_CONTENT_EXTERNAL = 2 + +const FTS5_CONTENT_NONE = 1 + +const FTS5_CONTENT_NORMAL = 0 + +const FTS5_CONTENT_UNINDEXED = 3 + +const FTS5_CORRUPT = 267 + +const FTS5_CURRENT_VERSION = 4 + +const FTS5_CURRENT_VERSION_SECUREDELETE = 5 + +const FTS5_DATA_DLI_B = 1 + +const FTS5_DATA_HEIGHT_B = 5 + +const FTS5_DATA_ID_B = 16 + +const FTS5_DATA_PADDING = 20 + +const FTS5_DATA_PAGE_B = 31 + +const FTS5_DATA_ZERO_PADDING = 8 + +const FTS5_DEFAULT_AUTOMERGE = 4 + +const FTS5_DEFAULT_CRISISMERGE = 16 + +const FTS5_DEFAULT_DELETE_AUTOMERGE = 10 + +const FTS5_DEFAULT_HASHSIZE = 1048576 + +const FTS5_DEFAULT_NEARDIST = 10 + +const FTS5_DEFAULT_PAGE_SIZE = 4050 + +const FTS5_DEFAULT_RANK = "bm25" + +const FTS5_DEFAULT_USERMERGE = 4 + +const FTS5_DETAIL_COLUMNS = 2 + +const FTS5_DETAIL_FULL = 0 + +const FTS5_DETAIL_NONE = 1 + +const FTS5_EOF = 0 + +const FTS5_INSTTOKEN_SUBTYPE = 73 + +const FTS5_LCP = 7 + +const FTS5_LP = 10 + +const FTS5_MAIN_PREFIX = 48 + +const FTS5_MAX_LEVEL = 64 + +const FTS5_MAX_PAGE_SIZE = 65536 + +const FTS5_MAX_PREFIX_INDEXES = 31 + +const FTS5_MAX_SEGMENT = 2000 + +const FTS5_MAX_TOKEN_SIZE = 32768 + +const FTS5_MERGE_NLIST = 16 + +const FTS5_MINUS = 6 + +const FTS5_MIN_DLIDX_SIZE = 4 + +const FTS5_NOINLINE = "SQLITE_NOINLINE" + +const FTS5_NOT = 3 + +const FTS5_OPT_WORK_UNIT = 1000 + +const FTS5_OR = 1 + +const FTS5_PATTERN_GLOB = 66 + +const FTS5_PATTERN_LIKE = 65 + +const FTS5_PATTERN_NONE = 0 + +const FTS5_PLAN_MATCH = 1 + +const FTS5_PLAN_ROWID = 6 + +const FTS5_PLAN_SCAN = 5 + +const FTS5_PLAN_SORTED_MATCH = 4 + +const FTS5_PLAN_SOURCE = 2 + +const FTS5_PLAN_SPECIAL = 3 + +const FTS5_PLUS = 14 + +const FTS5_PORTER_MAX_TOKEN = 64 + +const FTS5_RANK_NAME = "rank" + +const FTS5_RCP = 8 + +const FTS5_REMOVE_DIACRITICS_COMPLEX = 2 + +const FTS5_REMOVE_DIACRITICS_NONE = 0 + +const FTS5_REMOVE_DIACRITICS_SIMPLE = 1 + +const FTS5_ROWID_NAME = "rowid" + +const FTS5_RP = 11 + +const FTS5_SEGITER_ONETERM = 1 + +const FTS5_SEGITER_REVERSE = 2 + +const FTS5_STAR = 15 + +const FTS5_STMT_DELETE_CONTENT = 6 + +const FTS5_STMT_DELETE_DOCSIZE = 8 + +const FTS5_STMT_INSERT_CONTENT = 4 + +const FTS5_STMT_LOOKUP = 2 + +const FTS5_STMT_LOOKUP2 = 3 + +const FTS5_STMT_LOOKUP_DOCSIZE = 9 + +const FTS5_STMT_REPLACE_CONFIG = 10 + +const FTS5_STMT_REPLACE_CONTENT = 5 + +const FTS5_STMT_REPLACE_DOCSIZE = 7 + +const FTS5_STMT_SCAN = 11 + +const FTS5_STMT_SCAN_ASC = 0 + +const FTS5_STMT_SCAN_DESC = 1 + +const FTS5_STRING = 9 + +const FTS5_STRUCTURE_ROWID = 10 + +const FTS5_STRUCTURE_V2 = "\xff\x00\x00\x01" + +const FTS5_TERM = 4 + +const FTS5_TOKENIZE_AUX = 8 + +const FTS5_TOKENIZE_DOCUMENT = 4 + +const FTS5_TOKENIZE_PREFIX = 2 + +const FTS5_TOKENIZE_QUERY = 1 + +const FTS5_TOKEN_COLOCATED = 1 + +const FTS5_VOCAB_COL = 0 + +const FTS5_VOCAB_COLUSED_MASK = 255 + +const FTS5_VOCAB_COL_SCHEMA = "term, col, doc, cnt" + +const FTS5_VOCAB_INSTANCE = 2 + +const FTS5_VOCAB_INST_SCHEMA = "term, doc, col, offset" + +const FTS5_VOCAB_ROW = 1 + +const FTS5_VOCAB_ROW_SCHEMA = "term, doc, cnt" + +const FTS5_VOCAB_TERM_EQ = 256 + +const FTS5_VOCAB_TERM_GE = 512 + +const FTS5_VOCAB_TERM_LE = 1024 + +const FTS5_WORK_UNIT = 64 + +const FULLY_WITHIN = 2 + +const FUNC_PERFECT_MATCH = 6 + +type FileChunk = TFileChunk + +type FilePoint = TFilePoint + +type FpDecode = TFpDecode + +type FrameBound = TFrameBound + +type Fts5Auxdata = TFts5Auxdata + +type Fts5Auxiliary = TFts5Auxiliary + +type Fts5Bm25Data = TFts5Bm25Data + +type Fts5Buffer = TFts5Buffer + +type Fts5CResult = TFts5CResult + +type Fts5Colset = TFts5Colset + +/* Size (int bytes) of a complete Fts5Colset object with N columns. */ + +/************************************************************************** +** Interface to code in fts5_config.c. fts5_config.c contains contains code +** to parse the arguments passed to the CREATE VIRTUAL TABLE statement. + */ + +type Fts5Config = TFts5Config + +type Fts5Cursor = TFts5Cursor + +type Fts5Data = TFts5Data + +type Fts5DlidxIter = TFts5DlidxIter + +type Fts5DlidxLvl = TFts5DlidxLvl + +type Fts5DlidxWriter = TFts5DlidxWriter + +type Fts5DoclistIter = TFts5DoclistIter + +type Fts5Enum = TFts5Enum + +type Fts5Expr = TFts5Expr + +type Fts5ExprCtx = TFts5ExprCtx + +type Fts5ExprNearset = TFts5ExprNearset + +type Fts5ExprNode = TFts5ExprNode + +type Fts5ExprPhrase = TFts5ExprPhrase + +type Fts5ExprTerm = TFts5ExprTerm + +/* +** Check that the Fts5ExprNode.iHeight variables are set correctly in +** the expression tree passed as the only argument. + */ + +type Fts5ExtensionApi = TFts5ExtensionApi + +type Fts5FlushCtx = TFts5FlushCtx + +type Fts5FullTable = TFts5FullTable + +type Fts5Global = TFts5Global + +type Fts5Hash = TFts5Hash + +/* +** End of interface to code in fts5_hash.c. +**************************************************************************/ + +/************************************************************************** +** Interface to code in fts5_storage.c. fts5_storage.c contains contains +** code to access the data stored in the %_content and %_docsize tables. + */ + +type Fts5HashEntry = TFts5HashEntry + +/* +** Equivalent to: +** +** char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; } + */ + +type Fts5Index = TFts5Index + +type Fts5IndexIter = TFts5IndexIter + +/* +** End of interface to code in fts5_varint.c. +**************************************************************************/ + +/************************************************************************** +** Interface to code in fts5_main.c. + */ + +type Fts5InsertCtx = TFts5InsertCtx + +type Fts5IntegrityCtx = TFts5IntegrityCtx + +type Fts5Iter = TFts5Iter + +type Fts5LookaheadReader = TFts5LookaheadReader + +type Fts5MatchPhrase = TFts5MatchPhrase + +type Fts5NearTrimmer = TFts5NearTrimmer + +type Fts5PageWriter = TFts5PageWriter + +type Fts5Parse = TFts5Parse + +type Fts5PhraseIter = TFts5PhraseIter + +type Fts5PoslistPopulator = TFts5PoslistPopulator + +/* +** End of interface to code in fts5_unicode2.c. +**************************************************************************/ + +/* This file is automatically generated by Lemon from input grammar +** source file "fts5parse.y". + */ +/* +** 2000-05-29 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** Driver template for the LEMON parser generator. +** +** The "lemon" program processes an LALR(1) input grammar file, then uses +** this template to construct a parser. The "lemon" program inserts text +** at each "%%" line. Also, any "P-a-r-s-e" identifier prefix (without the +** interstitial "-" characters) contained in this template is changed into +** the value of the %name directive from the grammar. Otherwise, the content +** of this template is copied straight through into the generate parser +** source file. +** +** The following is the concatenation of all %include directives from the +** input grammar file: + */ +/************ Begin %include sections from the grammar ************************/ + +/* #include "fts5Int.h" */ +/* #include "fts5parse.h" */ + +/* +** Disable all error recovery processing in the parser push-down +** automaton. + */ + +/* +** Make fts5yytestcase() the same as testcase() + */ + +/* +** Indicate that sqlite3ParserFree() will never be called with a null +** pointer. + */ + +/* +** Alternative datatype for the argument to the malloc() routine passed +** into sqlite3ParserAlloc(). The default is size_t. + */ + +/**************** End of %include directives **********************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ +/**************** End token definitions ***************************************/ + +type Fts5PoslistReader = TFts5PoslistReader + +type Fts5PoslistWriter = TFts5PoslistWriter + +type Fts5SFinder = TFts5SFinder + +type Fts5SegIter = TFts5SegIter + +type Fts5SegWriter = TFts5SegWriter + +type Fts5Sorter = TFts5Sorter + +type Fts5Storage = TFts5Storage + +/* +** End of interface to code in fts5_storage.c. +**************************************************************************/ + +type Fts5Structure = TFts5Structure + +type Fts5StructureLevel = TFts5StructureLevel + +type Fts5StructureSegment = TFts5StructureSegment + +type Fts5Table = TFts5Table + +/* +** End of interface to code in fts5.c. +**************************************************************************/ + +type Fts5Termset = TFts5Termset + +/* +** End of interface to code in fts5_buffer.c. +**************************************************************************/ + +/************************************************************************** +** Interface to code in fts5_index.c. fts5_index.c contains contains code +** to access the data stored in the %_data table. + */ + +type Fts5TermsetEntry = TFts5TermsetEntry + +type Fts5Token = TFts5Token + +type Fts5TokenDataIter = TFts5TokenDataIter + +type Fts5TokenDataMap = TFts5TokenDataMap + +type Fts5TokenizerConfig = TFts5TokenizerConfig + +/* +** End of interface to code in fts5_config.c. +**************************************************************************/ + +/************************************************************************** +** Interface to code in fts5_buffer.c. + */ + +type Fts5TokenizerModule = TFts5TokenizerModule + +type Fts5TombstoneArray = TFts5TombstoneArray + +type Fts5TransactionState = TFts5TransactionState + +type Fts5VocabCursor = TFts5VocabCursor + +/* +** Bits for the mask used as the idxNum value by xBestIndex/xFilter. + */ + +type Fts5VocabTable = TFts5VocabTable + +type Fts5VtoVTokenizer = TFts5VtoVTokenizer + +type FuncDef = TFuncDef + +type FuncDefHash = TFuncDefHash + +type FuncDestructor = TFuncDestructor + +const GCC_VERSION = 0 + +const GEOPOLY_PI = 3.141592653589793 + +type GeoBBox = TGeoBBox + +type GeoCoord = TGeoCoord + +type GeoEvent = TGeoEvent + +type GeoOverlap = TGeoOverlap + +type GeoParse = TGeoParse + +type GeoPoly = TGeoPoly + +/* The size of a memory allocation needed for a GeoPoly object sufficient +** to hold N coordinate pairs. + */ + +/* Macros to access coordinates of a GeoPoly. +** We have to use these macros, rather than just say p->a[i] in order +** to silence (incorrect) UBSAN warnings if the array index is too large. + */ + +type GeoSegment = TGeoSegment + +type GroupConcatCtx = TGroupConcatCtx + +const HASHSIZE = 97 + +const HASHTABLE_HASH_1 = 383 + +const HASHTABLE_NPAGE = 4096 + +const HASHTABLE_NPAGE_ONE = 4096 + +const HASHTABLE_NSLOT = 8192 + +const HAVE_FCHOWN = 1 + +const HAVE_LSTAT = 1 + +const HAVE_READLINK = 1 + +const HAVE_USLEEP = 1 + +const HUGE_VALF = 0 + +type Hash = THash + +type HashElem = THashElem + +type HiddenIndexInfo = THiddenIndexInfo + +type HighlightContext = THighlightContext + +const INCRINIT_NORMAL = 0 + +const INCRINIT_ROOT = 2 + +const INCRINIT_TASK = 1 + +const INFINITY = 0 + +const INITFLAG_AlterAdd = 3 + +const INITFLAG_AlterDrop = 2 + +const INITFLAG_AlterDropCons = 4 + +const INITFLAG_AlterMask = 7 + +const INITFLAG_AlterRename = 1 + +const INLINEFUNC_affinity = 4 + +const INLINEFUNC_coalesce = 0 + +const INLINEFUNC_expr_compare = 3 + +const INLINEFUNC_expr_implies_expr = 2 + +const INLINEFUNC_iif = 5 + +const INLINEFUNC_implies_nonnull_row = 1 + +const INLINEFUNC_sqlite_offset = 6 + +const INLINEFUNC_unlikely = 99 + +const INT16_MAX = 32767 + +const INT16_MIN = -32768 + +const INT32_MAX = 2147483647 + +const INT32_MIN = -2147483648 + +const INT64_MAX = 9223372036854775807 + +const INT64_MIN = -9223372036854775808 + +const INT8_MAX = 127 + +const INT8_MIN = -128 + +const INTMAX_MAX = 9223372036854775807 + +const INTMAX_MIN = -9223372036854775808 + +const INT_FAST32_MAX = 2147483647 + +const INT_FAST32_MIN = -2147483648 + +const INT_FAST64_MAX = 9223372036854775807 + +const INT_FAST64_MIN = -9223372036854775808 + +const INT_LEAST16_MAX = 32767 + +const INT_LEAST16_MIN = -32768 + +const INT_LEAST32_MAX = 2147483647 + +const INT_LEAST32_MIN = -2147483648 + +const INT_LEAST64_MAX = 9223372036854775807 + +const INT_LEAST64_MIN = -9223372036854775808 + +const INT_LEAST8_MAX = 127 + +const INT_LEAST8_MIN = -128 + +const IN_INDEX_EPH = 2 + +const IN_INDEX_INDEX_ASC = 3 + +const IN_INDEX_INDEX_DESC = 4 + +const IN_INDEX_LOOP = 4 + +const IN_INDEX_MEMBERSHIP = 2 + +const IN_INDEX_NOOP = 5 + +const IN_INDEX_NOOP_OK = 1 + +const IN_INDEX_ROWID = 1 + +type IdList = TIdList + +type IdList_item = TIdList_item + +type IdxCover = TIdxCover + +type InLoop = TInLoop + +type IncrMerger = TIncrMerger + +type Incrblob = TIncrblob + +type Index = TIndex + +type IndexIterator = TIndexIterator + +type IndexListTerm = TIndexListTerm + +type IndexSample = TIndexSample + +type IndexedExpr = TIndexedExpr + +type InitData = TInitData + +/* +** Allowed values for mInitFlags + */ + +/* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled +** on debug-builds of the CLI using ".testctrl tune ID VALUE". Tuning +** parameters are for temporary use during development, to help find +** optimal values for parameters in the query planner. The should not +** be used on trunk check-ins. They are a temporary mechanism available +** for transient development builds only. +** +** Tuning parameters are numbered starting with 1. + */ + +type IntegrityCk = TIntegrityCk + +/* +** Routines to read or write a two- and four-byte big-endian integer values. + */ + +/* +** get2byteAligned(), unlike get2byte(), requires that its argument point to a +** two-byte aligned address. get2byteAligned() is only used for accessing the +** cell addresses in a btree header. + */ + +/************** End of btreeInt.h ********************************************/ +/************** Continuing where we left off in btmutex.c ********************/ + +const IsStat4 = 1 + +const JEACH_ATOM = 3 + +const JEACH_FULLKEY = 6 + +const JEACH_ID = 4 + +const JEACH_JSON = 8 + +const JEACH_KEY = 0 + +const JEACH_PARENT = 5 + +const JEACH_PATH = 7 + +const JEACH_ROOT = 9 + +const JEACH_TYPE = 2 + +const JEACH_VALUE = 1 + +const JEDIT_AINS = 5 + +const JEDIT_DEL = 1 + +const JEDIT_INS = 3 + +const JEDIT_REPL = 2 + +const JEDIT_SET = 4 + +const JSONB_ARRAY = 11 + +const JSONB_FALSE = 2 + +const JSONB_FLOAT = 5 + +const JSONB_FLOAT5 = 6 + +const JSONB_INT = 3 + +const JSONB_INT5 = 4 + +const JSONB_NULL = 0 + +const JSONB_OBJECT = 12 + +const JSONB_TEXT = 7 + +const JSONB_TEXT5 = 9 + +const JSONB_TEXTJ = 8 + +const JSONB_TEXTRAW = 10 + +const JSONB_TRUE = 1 + +const JSON_ABPATH = 3 + +const JSON_AINS = 8 + +const JSON_BLOB = 16 + +const JSON_CACHE_ID = -429938 + +const JSON_CACHE_SIZE = 4 + +const JSON_EDITABLE = 1 + +const JSON_INVALID_CHAR = 629145 + +const JSON_ISSET = 4 + +const JSON_JSON = 1 + +const JSON_KEEPERROR = 2 + +const JSON_LOOKUP_ERROR = 4294967295 + +const JSON_LOOKUP_NOTARRAY = 4294967293 + +const JSON_LOOKUP_NOTFOUND = 4294967294 + +const JSON_LOOKUP_PATHERROR = 4294967291 + +const JSON_LOOKUP_TOODEEP = 4294967292 + +const JSON_MAX_DEPTH = 1000 + +const JSON_MERGE_BADPATCH = 2 + +const JSON_MERGE_BADTARGET = 1 + +const JSON_MERGE_OK = 0 + +const JSON_MERGE_OOM = 3 + +const JSON_MERGE_TOODEEP = 4 + +const JSON_SQL = 2 + +const JSON_SUBTYPE = 74 + +const JSTRING_ERR = 8 + +const JSTRING_MALFORMED = 2 + +const JSTRING_OOM = 1 + +const JSTRING_TOODEEP = 4 + +const JT_CROSS = 2 + +const JT_ERROR = 128 + +const JT_INNER = 1 + +const JT_LEFT = 8 + +const JT_LTORJ = 64 + +const JT_NATURAL = 4 + +const JT_OUTER = 32 + +const JT_RIGHT = 16 + +type JsonCache = TJsonCache + +type JsonEachConnection = TJsonEachConnection + +type JsonEachCursor = TJsonEachCursor + +type JsonParent = TJsonParent + +type JsonParse = TJsonParse + +/************************************************************************** +** Utility routines for dealing with JsonCache objects +**************************************************************************/ + +type JsonPretty = TJsonPretty + +type JsonString = TJsonString + +const KEYINFO_ORDER_BIGNULL = 2 + +const KEYINFO_ORDER_DESC = 1 + +type KeyInfo = TKeyInfo + +const LEGACY_SCHEMA_TABLE = "sqlite_master" + +const LEGACY_TEMP_SCHEMA_TABLE = "sqlite_temp_master" + +const LOCATE_NOERR = 2 + +const LOCATE_VIEW = 1 + +const LOGEST_MAX = 32767 + +const LOGEST_MIN = -32768 + +const LONGDOUBLE_TYPE = 0 + +const LOOKASIDE_SMALL = 128 + +type LastValueCtx = TLastValueCtx + +type LogEst = TLogEst + +/* +** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer + */ + +type Lookaside = TLookaside + +type LookasideSlot = TLookasideSlot + +const M10d_Any = 1 + +const M10d_No = 2 + +const M10d_Yes = 0 + +const MAX_SECTOR_SIZE = 65536 + +const MEMJOURNAL_DFLT_FILECHUNKSIZE = 1024 + +const MEMTYPE_HEAP = 1 + +const MEMTYPE_LOOKASIDE = 2 + +const MEMTYPE_PCACHE = 4 + +const MEM_AffMask = 63 + +const MEM_Agg = 32768 + +const MEM_Blob = 16 + +const MEM_Cleared = 256 + +const MEM_Dyn = 4096 + +const MEM_Ephem = 16384 + +const MEM_FromBind = 64 + +const MEM_Int = 4 + +const MEM_IntReal = 32 + +const MEM_Null = 1 + +const MEM_Real = 8 + +const MEM_Static = 8192 + +const MEM_Str = 2 + +const MEM_Subtype = 2048 + +const MEM_Term = 512 + +const MEM_TypeMask = 3519 + +const MEM_Undefined = 0 + +const MEM_Zero = 1024 + +const MSVC_VERSION = 0 + +type Mem = TMem + +type Mem0Global = TMem0Global + +/* +** Default value of the hard heap limit. 0 means "no limit". + */ + +type MemFS = TMemFS + +type MemFile = TMemFile + +type MemJournal = TMemJournal + +type MemPage = TMemPage + +type MemStore = TMemStore + +type MemValue = TMemValue + +type MemVfs = TMemVfs + +type MergeEngine = TMergeEngine + +type Module = TModule + +const NAN = 0 + +const NB = 3 + +const NC_AllowAgg = 1 + +const NC_AllowWin = 16384 + +const NC_FromDDL = 262144 + +const NC_GenCol = 8 + +const NC_HasAgg = 16 + +const NC_HasWin = 32768 + +const NC_IdxExpr = 32 + +const NC_InAggFunc = 131072 + +const NC_IsCheck = 4 + +const NC_IsDDL = 65536 + +const NC_MinMaxAgg = 4096 + +const NC_NoSelect = 524288 + +const NC_OrderAgg = 134217728 + +const NC_PartIdx = 2 + +const NC_SelfRef = 46 + +const NC_Subquery = 64 + +const NC_UAggInfo = 256 + +const NC_UBaseReg = 1024 + +const NC_UEList = 128 + +const NC_UUpsert = 512 + +const NC_Where = 1048576 + +const NDEBUG = 1 + +const NN = 1 + +const NOT_WITHIN = 0 + +const NO_LOCK = 0 + +const N_OR_COST = 3 + +const N_SORT_BUCKET = 32 + +const N_STATEMENT = 8 + +type NameContext = TNameContext + +type NanInfName = TNanInfName + +type NthValueCtx = TNthValueCtx + +type NtileCtx = TNtileCtx + +const OE_Abort = 2 + +const OE_Cascade = 10 + +const OE_Default = 11 + +const OE_Fail = 3 + +const OE_Ignore = 4 + +const OE_None = 0 + +const OE_Replace = 5 + +const OE_Restrict = 7 + +const OE_Rollback = 1 + +const OE_SetDflt = 9 + +const OE_SetNull = 8 + +const OE_Update = 6 + +const OMIT_TEMPDB = 0 + +const ONEPASS_MULTI = 2 + +const ONEPASS_OFF = 0 + +const ONEPASS_SINGLE = 1 + +const OPFLAG_APPEND = 8 + +const OPFLAG_AUXDELETE = 4 + +const OPFLAG_BULKCSR = 1 + +const OPFLAG_BYTELENARG = 192 + +const OPFLAG_EPHEM = 1 + +const OPFLAG_FORDELETE = 8 + +const OPFLAG_ISNOOP = 64 + +const OPFLAG_ISUPDATE = 4 + +const OPFLAG_LASTROWID = 32 + +const OPFLAG_LENGTHARG = 64 + +const OPFLAG_NCHANGE = 1 + +const OPFLAG_NOCHNG = 1 + +const OPFLAG_NOCHNG_MAGIC = 109 + +const OPFLAG_P2ISREG = 16 + +const OPFLAG_PERMUTE = 1 + +const OPFLAG_PREFORMAT = 128 + +const OPFLAG_SAVEPOSITION = 2 + +const OPFLAG_SEEKEQ = 2 + +const OPFLAG_TYPEOFARG = 128 + +const OPFLAG_USESEEKRESULT = 16 + +const OPFLG_IN1 = 2 + +const OPFLG_IN2 = 4 + +const OPFLG_IN3 = 8 + +const OPFLG_JUMP = 1 + +const OPFLG_JUMP0 = 128 + +const OPFLG_NCYCLE = 64 + +const OPFLG_OUT2 = 16 + +const OPFLG_OUT3 = 32 + +const OP_Abortable = 191 + +const OP_Add = 107 + +const OP_AddImm = 88 + +const OP_Affinity = 98 + +const OP_AggFinal = 167 + +const OP_AggInverse = 163 + +const OP_AggStep = 164 + +const OP_AggStep1 = 165 + +const OP_AggValue = 166 + +const OP_And = 44 + +const OP_AutoCommit = 1 + +const OP_BeginSubrtn = 76 + +const OP_BitAnd = 103 + +const OP_BitNot = 115 + +const OP_BitOr = 104 + +const OP_Blob = 79 + +const OP_Cast = 90 + +const OP_Checkpoint = 3 + +const OP_Clear = 147 + +const OP_Close = 124 + +const OP_ClrSubtype = 182 + +const OP_CollSeq = 87 + +const OP_Column = 96 + +const OP_ColumnsUsed = 125 + +const OP_Compare = 92 + +const OP_Concat = 112 + +const OP_Copy = 82 + +const OP_Count = 100 + +const OP_CreateBtree = 149 + +const OP_CursorHint = 187 + +const OP_CursorLock = 169 + +const OP_CursorUnlock = 170 + +const OP_DecrJumpZero = 63 + +const OP_DeferredSeek = 143 + +const OP_Delete = 132 + +const OP_Destroy = 146 + +const OP_Divide = 110 + +const OP_DropIndex = 155 + +const OP_DropTable = 153 + +const OP_DropTrigger = 156 + +const OP_ElseEq = 59 + +const OP_EndCoroutine = 70 + +const OP_Eq = 54 + +const OP_Expire = 168 + +const OP_Explain = 190 + +const OP_Filter = 66 + +const OP_FilterAdd = 185 + +const OP_FinishSeek = 145 + +const OP_FkCheck = 85 + +const OP_FkCounter = 160 + +const OP_FkIfZero = 60 + +const OP_Found = 29 + +const OP_Function = 68 + +const OP_Ge = 58 + +const OP_GetSubtype = 183 + +const OP_Gosub = 10 + +const OP_Goto = 9 + +const OP_Gt = 55 + +const OP_Halt = 72 + +const OP_HaltIfNull = 71 + +const OP_IFindKey = 47 + +const OP_IdxDelete = 142 + +const OP_IdxGE = 46 + +const OP_IdxGT = 42 + +const OP_IdxInsert = 140 + +const OP_IdxLE = 41 + +const OP_IdxLT = 45 + +const OP_IdxRowid = 144 + +const OP_If = 16 + +const OP_IfEmpty = 37 + +const OP_IfNoHope = 26 + +const OP_IfNot = 17 + +const OP_IfNotOpen = 25 + +const OP_IfNotZero = 62 + +const OP_IfNullRow = 20 + +const OP_IfPos = 61 + +const OP_IfSizeBetween = 33 + +const OP_IncrVacuum = 64 + +const OP_Init = 8 + +const OP_InitCoroutine = 11 + +const OP_Insert = 130 + +const OP_Int64 = 74 + +const OP_IntCopy = 84 + +const OP_Integer = 73 + +const OP_IntegrityCk = 157 + +const OP_IsNull = 51 + +const OP_IsTrue = 93 + +const OP_IsType = 18 + +const OP_JournalMode = 4 + +const OP_Jump = 14 + +const OP_Last = 32 + +const OP_Le = 56 + +const OP_LoadAnalysis = 152 + +const OP_Lt = 57 + +const OP_MakeRecord = 99 + +const OP_MaxPgcnt = 181 + +const OP_MemMax = 161 + +const OP_Move = 81 + +const OP_Multiply = 109 + +const OP_MustBeInt = 13 + +const OP_Ne = 53 + +const OP_NewRowid = 129 + +const OP_Next = 40 + +const OP_NoConflict = 27 + +const OP_Noop = 189 + +const OP_Not = 19 + +const OP_NotExists = 31 + +const OP_NotFound = 28 + +const OP_NotNull = 52 + +const OP_Null = 77 + +const OP_NullRow = 138 + +const OP_Offset = 95 + +const OP_OffsetLimit = 162 + +const OP_Once = 15 + +const OP_OpenAutoindex = 119 + +const OP_OpenDup = 117 + +const OP_OpenEphemeral = 120 + +const OP_OpenPseudo = 123 + +const OP_OpenRead = 114 + +const OP_OpenWrite = 116 + +const OP_Or = 43 + +const OP_Pagecount = 180 + +const OP_Param = 159 + +const OP_ParseSchema = 151 + +const OP_Permutation = 91 + +const OP_Prev = 39 + +const OP_Program = 50 + +const OP_PureFunc = 67 + +const OP_ReadCookie = 101 + +const OP_Real = 154 + +const OP_RealAffinity = 89 + +const OP_ReleaseReg = 188 + +const OP_Remainder = 111 + +const OP_ReopenIdx = 113 + +const OP_ResetCount = 133 + +const OP_ResetSorter = 148 + +const OP_ResultRow = 86 + +const OP_Return = 69 + +const OP_Rewind = 36 + +const OP_RowCell = 131 + +const OP_RowData = 136 + +const OP_RowSetAdd = 158 + +const OP_RowSetRead = 48 + +const OP_RowSetTest = 49 + +const OP_Rowid = 137 + +const OP_SCopy = 83 + +const OP_Savepoint = 0 + +const OP_SeekEnd = 139 + +const OP_SeekGE = 23 + +const OP_SeekGT = 24 + +const OP_SeekHit = 127 + +const OP_SeekLE = 22 + +const OP_SeekLT = 21 + +const OP_SeekRowid = 30 + +const OP_SeekScan = 126 + +const OP_Sequence = 128 + +const OP_SequenceTest = 122 + +const OP_SetCookie = 102 + +const OP_SetSubtype = 184 + +const OP_ShiftLeft = 105 + +const OP_ShiftRight = 106 + +const OP_SoftNull = 78 + +const OP_Sort = 35 + +const OP_SorterCompare = 134 + +const OP_SorterData = 135 + +const OP_SorterInsert = 141 + +const OP_SorterNext = 38 + +const OP_SorterOpen = 121 + +const OP_SorterSort = 34 + +const OP_SqlExec = 150 + +const OP_String = 75 + +const OP_String8 = 118 + +const OP_Subtract = 108 + +const OP_TableLock = 171 + +const OP_Trace = 186 + +const OP_Transaction = 2 + +const OP_TypeCheck = 97 + +const OP_VBegin = 172 + +const OP_VCheck = 176 + +const OP_VColumn = 178 + +const OP_VCreate = 173 + +const OP_VDestroy = 174 + +const OP_VFilter = 6 + +const OP_VInitIn = 177 + +const OP_VNext = 65 + +const OP_VOpen = 175 + +const OP_VRename = 179 + +const OP_VUpdate = 7 + +const OP_Vacuum = 5 + +const OP_Variable = 80 + +const OP_Yield = 12 + +const OP_ZeroOrNull = 94 + +const OS_VXWORKS = 0 + +type OnOrUsing = TOnOrUsing + +type Op = TOp + +const P4_COLLSEQ = -2 + +const P4_DYNAMIC = -7 + +const P4_EXPR = -10 + +const P4_FREE_IF_LE = -7 + +const P4_FUNCCTX = -16 + +const P4_FUNCDEF = -8 + +const P4_INDEX = -6 + +const P4_INT32 = -3 + +const P4_INT64 = -14 + +const P4_INTARRAY = -15 + +const P4_KEYINFO = -9 + +const P4_MEM = -11 + +const P4_NOTUSED = 0 + +const P4_REAL = -13 + +const P4_STATIC = -1 + +const P4_SUBPROGRAM = -4 + +const P4_SUBRTNSIG = -18 + +const P4_TABLE = -5 + +const P4_TABLEREF = -17 + +const P4_TRANSIENT = 0 + +const P4_VTAB = -12 + +const P5_ConstraintCheck = 3 + +const P5_ConstraintFK = 4 + +const P5_ConstraintNotNull = 1 + +const P5_ConstraintUnique = 2 + +const PAGER_CACHESPILL = 32 + +const PAGER_CKPT_FULLFSYNC = 16 + +const PAGER_ERROR = 6 + +const PAGER_FLAGS_MASK = 56 + +const PAGER_FULLFSYNC = 8 + +const PAGER_GET_NOCONTENT = 1 + +const PAGER_GET_READONLY = 2 + +const PAGER_JOURNALMODE_DELETE = 0 + +const PAGER_JOURNALMODE_MEMORY = 4 + +const PAGER_JOURNALMODE_OFF = 2 + +const PAGER_JOURNALMODE_PERSIST = 1 + +const PAGER_JOURNALMODE_QUERY = -1 + +const PAGER_JOURNALMODE_TRUNCATE = 3 + +const PAGER_JOURNALMODE_WAL = 5 + +const PAGER_LOCKINGMODE_EXCLUSIVE = 1 + +const PAGER_LOCKINGMODE_NORMAL = 0 + +const PAGER_LOCKINGMODE_QUERY = -1 + +const PAGER_MEMORY = 2 + +const PAGER_OMIT_JOURNAL = 1 + +const PAGER_OPEN = 0 + +const PAGER_READER = 1 + +const PAGER_STAT_HIT = 0 + +const PAGER_STAT_MISS = 1 + +const PAGER_STAT_SPILL = 3 + +const PAGER_STAT_WRITE = 2 + +const PAGER_SYNCHRONOUS_EXTRA = 4 + +const PAGER_SYNCHRONOUS_FULL = 3 + +const PAGER_SYNCHRONOUS_MASK = 7 + +const PAGER_SYNCHRONOUS_NORMAL = 2 + +const PAGER_SYNCHRONOUS_OFF = 1 + +const PAGER_WRITER_CACHEMOD = 3 + +const PAGER_WRITER_DBMOD = 4 + +const PAGER_WRITER_FINISHED = 5 + +const PAGER_WRITER_LOCKED = 2 + +const PARSE_MODE_DECLARE_VTAB = 1 + +const PARSE_MODE_NORMAL = 0 + +const PARSE_MODE_RENAME = 2 + +const PARSE_MODE_UNMAP = 3 + +const PARTLY_WITHIN = 1 + +const PCACHE1_MIGHT_USE_GROUP_MUTEX = 1 + +const PCACHE_DIRTYLIST_ADD = 2 + +const PCACHE_DIRTYLIST_FRONT = 3 + +const PCACHE_DIRTYLIST_REMOVE = 1 + +type PCache = TPCache + +type PCache1 = TPCache1 + +type PCacheGlobal = TPCacheGlobal + +const PENDING_BYTE = 0 + +const PENDING_LOCK = 3 + +const PGHDR_CLEAN = 1 + +const PGHDR_DIRTY = 2 + +const PGHDR_DONT_WRITE = 16 + +const PGHDR_MMAP = 32 + +const PGHDR_NEED_SYNC = 8 + +const PGHDR_WAL_APPEND = 64 + +const PGHDR_WRITEABLE = 4 + +type PGroup = TPGroup + +const POWERSOF10_FIRST = -348 + +const POWERSOF10_LAST = 347 + +const PREFERRED_SCHEMA_TABLE = "sqlite_schema" + +const PREFERRED_TEMP_SCHEMA_TABLE = "sqlite_temp_schema" + +const PTF_INTKEY = 1 + +const PTF_LEAF = 8 + +const PTF_LEAFDATA = 4 + +const PTF_ZERODATA = 2 + +const PTRMAP_BTREE = 5 + +const PTRMAP_FREEPAGE = 2 + +const PTRMAP_OVERFLOW1 = 3 + +const PTRMAP_OVERFLOW2 = 4 + +const PTRMAP_ROOTPAGE = 1 + +type Pager = TPager + +type PagerSavepoint = TPagerSavepoint + +/* +** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains +** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS +** or CACHE_WRITE to sqlite3_db_status(). + */ + +/* +** The following global variables hold counters used for +** testing purposes only. These variables do not exist in +** a non-testing build. These variables are not thread-safe. + */ + +type Parse = TParse + +type ParseCleanup = TParseCleanup + +type PgFreeslot = TPgFreeslot + +type PgHdr = TPgHdr + +/* Functions to support testing and debugging. */ + +/************** End of pager.h ***********************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include btree.h in the middle of sqliteInt.h *****************/ +/************** Begin file btree.h *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the interface that the sqlite B-Tree file +** subsystem. See comments in the source code for a detailed description +** of what each interface routine does. + */ + +/* TODO: This definition is just included so other modules compile. It +** needs to be revisited. + */ + +/* +** If defined as non-zero, auto-vacuum is enabled by default. Otherwise +** it must be turned on for each database using "PRAGMA auto_vacuum = 1". + */ + +type PgHdr1 = TPgHdr1 + +type Pgno = TPgno + +type PmaReader = TPmaReader + +type PmaWriter = TPmaWriter + +type PorterContext = TPorterContext + +type PorterRule = TPorterRule + +type PorterTokenizer = TPorterTokenizer + +type PoslistCallbackCtx = TPoslistCallbackCtx + +type PoslistOffsetsCtx = TPoslistOffsetsCtx + +const PragFlg_NeedSchema = 1 + +const PragFlg_NoColumns = 2 + +const PragFlg_NoColumns1 = 4 + +const PragFlg_ReadOnly = 8 + +const PragFlg_Result0 = 16 + +const PragFlg_Result1 = 32 + +const PragFlg_SchemaOpt = 64 + +const PragFlg_SchemaReq = 128 + +const PragTyp_ACTIVATE_EXTENSIONS = 0 + +const PragTyp_ANALYSIS_LIMIT = 1 + +const PragTyp_AUTO_VACUUM = 3 + +const PragTyp_BUSY_TIMEOUT = 5 + +const PragTyp_CACHE_SIZE = 6 + +const PragTyp_CACHE_SPILL = 7 + +const PragTyp_CASE_SENSITIVE_LIKE = 8 + +const PragTyp_COLLATION_LIST = 9 + +const PragTyp_COMPILE_OPTIONS = 10 + +const PragTyp_DATABASE_LIST = 12 + +const PragTyp_DATA_STORE_DIRECTORY = 11 + +const PragTyp_DEFAULT_CACHE_SIZE = 13 + +const PragTyp_ENCODING = 14 + +const PragTyp_FLAG = 4 + +const PragTyp_FOREIGN_KEY_CHECK = 15 + +const PragTyp_FOREIGN_KEY_LIST = 16 + +const PragTyp_FUNCTION_LIST = 17 + +const PragTyp_HARD_HEAP_LIMIT = 18 + +const PragTyp_HEADER_VALUE = 2 + +const PragTyp_INCREMENTAL_VACUUM = 19 + +const PragTyp_INDEX_INFO = 20 + +const PragTyp_INDEX_LIST = 21 + +const PragTyp_INTEGRITY_CHECK = 22 + +const PragTyp_JOURNAL_MODE = 23 + +const PragTyp_JOURNAL_SIZE_LIMIT = 24 + +const PragTyp_LOCKING_MODE = 26 + +const PragTyp_LOCK_PROXY_FILE = 25 + +const PragTyp_LOCK_STATUS = 44 + +const PragTyp_MMAP_SIZE = 28 + +const PragTyp_MODULE_LIST = 29 + +const PragTyp_OPTIMIZE = 30 + +const PragTyp_PAGE_COUNT = 27 + +const PragTyp_PAGE_SIZE = 31 + +const PragTyp_PRAGMA_LIST = 32 + +const PragTyp_SECURE_DELETE = 33 + +const PragTyp_SHRINK_MEMORY = 34 + +const PragTyp_SOFT_HEAP_LIMIT = 35 + +const PragTyp_STATS = 45 + +const PragTyp_SYNCHRONOUS = 36 + +const PragTyp_TABLE_INFO = 37 + +const PragTyp_TABLE_LIST = 38 + +const PragTyp_TEMP_STORE = 39 + +const PragTyp_TEMP_STORE_DIRECTORY = 40 + +const PragTyp_THREADS = 41 + +const PragTyp_WAL_AUTOCHECKPOINT = 42 + +const PragTyp_WAL_CHECKPOINT = 43 + +type PragmaName = TPragmaName + +type PragmaVtab = TPragmaVtab + +type PragmaVtabCursor = TPragmaVtabCursor + +type PreUpdate = TPreUpdate + +type PrefixMerger = TPrefixMerger + +type PrefixSetupCtx = TPrefixSetupCtx + +type PrintfArguments = TPrintfArguments + +const RBU_CREATE_STATE = "CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)" + +const RBU_DELETE = 2 + +const RBU_ENABLE_DELTA_CKSUM = 0 + +const RBU_EXCLUSIVE_CHECKPOINT = "rbu_exclusive_checkpoint" + +const RBU_IDX_DELETE = 4 + +const RBU_IDX_INSERT = 5 + +const RBU_INSERT = 1 + +const RBU_PK_EXTERNAL = 3 + +const RBU_PK_IPK = 2 + +const RBU_PK_NONE = 1 + +const RBU_PK_NOTABLE = 0 + +const RBU_PK_VTAB = 5 + +const RBU_PK_WITHOUT_ROWID = 4 + +const RBU_REPLACE = 3 + +const RBU_STAGE_CAPTURE = 3 + +const RBU_STAGE_CKPT = 4 + +const RBU_STAGE_DONE = 5 + +const RBU_STAGE_MOVE = 2 + +const RBU_STAGE_OAL = 1 + +const RBU_STATE_CKPT = 6 + +const RBU_STATE_COOKIE = 7 + +const RBU_STATE_DATATBL = 10 + +const RBU_STATE_IDX = 3 + +const RBU_STATE_OALSZ = 8 + +const RBU_STATE_PHASEONESTEP = 9 + +const RBU_STATE_PROGRESS = 5 + +const RBU_STATE_ROW = 4 + +const RBU_STATE_STAGE = 1 + +const RBU_STATE_TBL = 2 + +const RBU_UPDATE = 6 + +const RBU_ZIPVFS_CTRL_FILE_POINTER = 230439 + +type RCStr = TRCStr + +const READMARK_NOT_USED = 4294967295 + +const READ_LOCK = 1 + +const RESERVED_BYTE = 1 + +const RESERVED_LOCK = 2 + +const RNDAWAY = 0 + +const RNDTOWARDS = 0 + +const ROWSET_ALLOCATION_SIZE = 1024 + +const ROWSET_ENTRY_PER_CHUNK = 1016 + +const ROWSET_NEXT = 2 + +const ROWSET_SORTED = 1 + +const RTREE_CACHE_SZ = 5 + +const RTREE_CHECK_MAX_ERROR = 100 + +const RTREE_COORD_INT32 = 1 + +const RTREE_COORD_REAL32 = 0 + +const RTREE_DEFAULT_ROWEST = 1048576 + +const RTREE_EQ = 65 + +const RTREE_FALSE = 64 + +const RTREE_GE = 68 + +const RTREE_GT = 69 + +const RTREE_LE = 66 + +const RTREE_LT = 67 + +const RTREE_MATCH = 70 + +const RTREE_MAXCELLS = 51 + +const RTREE_MAX_AUX_COLUMN = 100 + +const RTREE_MAX_DEPTH = 40 + +const RTREE_MAX_DIMENSIONS = 5 + +const RTREE_MIN_ROWEST = 100 + +const RTREE_QUERY = 71 + +const RTREE_TRUE = 63 + +const RTREE_ZERO = 0 + +type RbuFrame = TRbuFrame + +type RbuObjIter = TRbuObjIter + +type RbuSpan = TRbuSpan + +type RbuState = TRbuState + +type RbuUpdateStmt = TRbuUpdateStmt + +/* +** True for an RBU vacuum handle, or false otherwise. + */ + +/************************************************************************* +** The following three functions, found below: +** +** rbuDeltaGetInt() +** rbuDeltaChecksum() +** rbuDeltaApply() +** +** are lifted from the fossil source code (http://fossil-scm.org). They +** are used to implement the scalar SQL function rbu_fossil_delta(). + */ + +type RecordCompare = TRecordCompare + +type RefSrcList = TRefSrcList + +type RenameCtx = TRenameCtx + +type RenameToken = TRenameToken + +type Returning = TReturning + +type ReusableSpace = TReusableSpace + +type RowLoadInfo = TRowLoadInfo + +type RowSet = TRowSet + +type RowSetChunk = TRowSetChunk + +/* +** Allowed values for RowSet.rsFlags + */ + +type RowSetEntry = TRowSetEntry + +type Rtree = TRtree + +type RtreeCell = TRtreeCell + +type RtreeCheck = TRtreeCheck + +type RtreeConstraint = TRtreeConstraint + +type RtreeCoord = TRtreeCoord + +type RtreeCursor = TRtreeCursor + +type RtreeDValue = TRtreeDValue + +/* High accuracy coordinate */ + +type RtreeGeomCallback = TRtreeGeomCallback + +type RtreeMatchArg = TRtreeMatchArg + +type RtreeNode = TRtreeNode + +type RtreeSearchPoint = TRtreeSearchPoint + +/* Possible values for Rtree.eCoordType: */ + +type RtreeValue = TRtreeValue + +/* Size of an RtreeMatchArg object with N parameters */ + +/* What version of GCC is being used. 0 means GCC is not being used . +** Note that the GCC_VERSION macro will also be set correctly when using +** clang, since clang works hard to be gcc compatible. So the gcc +** optimizations will also work when compiling with clang. + */ + +/* The testcase() macro should already be defined in the amalgamation. If +** it is not, make it a no-op. + */ + +/* +** Make sure that the compiler intrinsics we desire are enabled when +** compiling with an appropriate version of MSVC unless prevented by +** the SQLITE_DISABLE_INTRINSIC define. + */ + +/* +** Macros to determine whether the machine is big or little endian, +** and whether or not that determination is run-time or compile-time. +** +** For best performance, an attempt is made to guess at the byte-order +** using C-preprocessor macros. If that is unsuccessful, or if +** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined +** at run-time. + */ + +/* What version of MSVC is being used. 0 means MSVC is not being used */ + +const SAVEPOINT_BEGIN = 0 + +const SAVEPOINT_RELEASE = 1 + +const SAVEPOINT_ROLLBACK = 2 + +const SCHEMA_ROOT = 1 + +const SESSIONS_ROWID = "_rowid_" + +const SESSIONS_STRM_CHUNK_SIZE = 1024 + +const SESSION_MAX_BUFFER_SZ = 2147483391 + +const SESSION_UPDATE_CACHE_SZ = 12 + +const SF_Aggregate = 8 + +const SF_All = 2 + +const SF_ClonedRhsIn = 32 + +const SF_ComplexResult = 262144 + +const SF_Compound = 256 + +const SF_Converted = 65536 + +const SF_CopyCte = 67108864 + +const SF_Correlated = 536870912 + +const SF_Distinct = 1 + +const SF_Expanded = 64 + +const SF_FixedLimit = 16384 + +const SF_HasAgg = 16 + +const SF_HasTypeInfo = 128 + +const SF_IncludeHidden = 131072 + +const SF_MinMaxAgg = 4096 + +const SF_MultiPart = 33554432 + +const SF_MultiValue = 1024 + +const SF_NestedFrom = 2048 + +const SF_OnToWhere = 1073741824 + +const SF_OrderByReqd = 134217728 + +const SF_PushDown = 16777216 + +const SF_Recursive = 8192 + +const SF_Resolved = 4 + +const SF_UFSrcCheck = 8388608 + +const SF_UpdateFrom = 268435456 + +const SF_Values = 512 + +const SF_View = 2097152 + +const SF_WhereBegin = 524288 + +const SF_WinRewrite = 1048576 + +const SHARED_FIRST = 2 + +const SHARED_LOCK = 1 + +const SHARED_SIZE = 510 + +const SLOT_2_0 = 2080895 + +const SLOT_4_2_0 = 4028612735 + +const SORTER_MAX_MERGE_COUNT = 16 + +const SORTER_TYPE_INTEGER = 1 + +const SORTER_TYPE_TEXT = 2 + +const SORTFLAG_UseSorter = 1 + +const SPILLFLAG_NOSYNC = 4 + +const SPILLFLAG_OFF = 1 + +const SPILLFLAG_ROLLBACK = 2 + +const SQLITE3_TEXT = 3 + +const SQLITE_ABORT = 4 + +const SQLITE_ABORT_ROLLBACK = 516 + +const SQLITE_ACCESS_EXISTS = 0 + +const SQLITE_ACCESS_READ = 2 + +const SQLITE_ACCESS_READWRITE = 1 + +const SQLITE_AFF_BLOB = 65 + +const SQLITE_AFF_DEFER = 88 + +const SQLITE_AFF_FLEXNUM = 70 + +const SQLITE_AFF_INTEGER = 68 + +const SQLITE_AFF_MASK = 71 + +const SQLITE_AFF_NONE = 64 + +const SQLITE_AFF_NUMERIC = 67 + +const SQLITE_AFF_REAL = 69 + +const SQLITE_AFF_TEXT = 66 + +const SQLITE_ALLOW_COVERING_INDEX_SCAN = 1 + +const SQLITE_ALTER_TABLE = 26 + +const SQLITE_AMALGAMATION = 1 + +const SQLITE_ANALYZE = 28 + +const SQLITE_ANY = 5 + +const SQLITE_ASCII = 1 + +const SQLITE_ATOMIC_INTRINSICS = 1 + +const SQLITE_ATTACH = 24 + +const SQLITE_AUTH = 23 + +const SQLITE_AUTH_USER = 279 + +const SQLITE_AllOpts = 4294967295 + +const SQLITE_AutoIndex = 32768 + +const SQLITE_BIG_DBL = 1e+99 + +const SQLITE_BLDF1_INDEXED = 1 + +const SQLITE_BLDF1_UNIQUE = 2 + +const SQLITE_BLDF2_2NDPASS = 4 + +const SQLITE_BLOB = 4 + +const SQLITE_BUSY = 5 + +const SQLITE_BUSY_RECOVERY = 261 + +const SQLITE_BUSY_SNAPSHOT = 517 + +const SQLITE_BUSY_TIMEOUT = 773 + +const SQLITE_BalancedMerge = 2097152 + +const SQLITE_BloomFilter = 524288 + +const SQLITE_BloomPulldown = 1048576 + +const SQLITE_CANTOPEN = 14 + +const SQLITE_CANTOPEN_BKPT = 0 + +const SQLITE_CANTOPEN_CONVPATH = 1038 + +const SQLITE_CANTOPEN_DIRTYWAL = 1294 + +const SQLITE_CANTOPEN_FULLPATH = 782 + +const SQLITE_CANTOPEN_ISDIR = 526 + +const SQLITE_CANTOPEN_NOTEMPDIR = 270 + +const SQLITE_CANTOPEN_SYMLINK = 1550 + +const SQLITE_CARRAY_BLOB = 4 + +const SQLITE_CARRAY_DOUBLE = 2 + +const SQLITE_CARRAY_INT32 = 0 + +const SQLITE_CARRAY_INT64 = 1 + +const SQLITE_CARRAY_TEXT = 3 + +const SQLITE_CHANGEGROUP_CONFIG_PATCHSET = 1 + +const SQLITE_CHANGESETAPPLY_FKNOACTION = 8 + +const SQLITE_CHANGESETAPPLY_IGNORENOOP = 4 + +const SQLITE_CHANGESETAPPLY_INVERT = 2 + +const SQLITE_CHANGESETAPPLY_NOSAVEPOINT = 1 + +const SQLITE_CHANGESETAPPLY_NOUPDATELOOP = 16 + +const SQLITE_CHANGESETSTART_INVERT = 2 + +const SQLITE_CHANGESET_ABORT = 2 + +const SQLITE_CHANGESET_CONFLICT = 3 + +const SQLITE_CHANGESET_CONSTRAINT = 4 + +const SQLITE_CHANGESET_DATA = 1 + +const SQLITE_CHANGESET_FOREIGN_KEY = 5 + +const SQLITE_CHANGESET_NOTFOUND = 2 + +const SQLITE_CHANGESET_OMIT = 0 + +const SQLITE_CHANGESET_REPLACE = 1 + +const SQLITE_CHECKPOINT_FULL = 1 + +const SQLITE_CHECKPOINT_NOOP = -1 + +const SQLITE_CHECKPOINT_PASSIVE = 0 + +const SQLITE_CHECKPOINT_RESTART = 2 + +const SQLITE_CHECKPOINT_TRUNCATE = 3 + +const SQLITE_CONFIG_COVERING_INDEX_SCAN = 20 + +const SQLITE_CONFIG_GETMALLOC = 5 + +const SQLITE_CONFIG_GETMUTEX = 11 + +const SQLITE_CONFIG_GETPCACHE = 15 + +const SQLITE_CONFIG_GETPCACHE2 = 19 + +const SQLITE_CONFIG_HEAP = 8 + +const SQLITE_CONFIG_LOG = 16 + +const SQLITE_CONFIG_LOOKASIDE = 13 + +const SQLITE_CONFIG_MALLOC = 4 + +const SQLITE_CONFIG_MEMDB_MAXSIZE = 29 + +const SQLITE_CONFIG_MEMSTATUS = 9 + +const SQLITE_CONFIG_MMAP_SIZE = 22 + +const SQLITE_CONFIG_MULTITHREAD = 2 + +const SQLITE_CONFIG_MUTEX = 10 + +const SQLITE_CONFIG_PAGECACHE = 7 + +const SQLITE_CONFIG_PCACHE = 14 + +const SQLITE_CONFIG_PCACHE2 = 18 + +const SQLITE_CONFIG_PCACHE_HDRSZ = 24 + +const SQLITE_CONFIG_PMASZ = 25 + +const SQLITE_CONFIG_ROWID_IN_VIEW = 30 + +const SQLITE_CONFIG_SCRATCH = 6 + +const SQLITE_CONFIG_SERIALIZED = 3 + +const SQLITE_CONFIG_SINGLETHREAD = 1 + +const SQLITE_CONFIG_SMALL_MALLOC = 27 + +const SQLITE_CONFIG_SORTERREF_SIZE = 28 + +const SQLITE_CONFIG_SQLLOG = 21 + +const SQLITE_CONFIG_STMTJRNL_SPILL = 26 + +const SQLITE_CONFIG_URI = 17 + +const SQLITE_CONFIG_WIN32_HEAPSIZE = 23 + +const SQLITE_CONSTRAINT = 19 + +const SQLITE_CONSTRAINT_CHECK = 275 + +const SQLITE_CONSTRAINT_COMMITHOOK = 531 + +const SQLITE_CONSTRAINT_DATATYPE = 3091 + +const SQLITE_CONSTRAINT_FOREIGNKEY = 787 + +const SQLITE_CONSTRAINT_FUNCTION = 1043 + +const SQLITE_CONSTRAINT_NOTNULL = 1299 + +const SQLITE_CONSTRAINT_PINNED = 2835 + +const SQLITE_CONSTRAINT_PRIMARYKEY = 1555 + +const SQLITE_CONSTRAINT_ROWID = 2579 + +const SQLITE_CONSTRAINT_TRIGGER = 1811 + +const SQLITE_CONSTRAINT_UNIQUE = 2067 + +const SQLITE_CONSTRAINT_VTAB = 2323 + +const SQLITE_COPY = 0 + +const SQLITE_CORE = 1 + +const SQLITE_CORRUPT = 11 + +const SQLITE_CORRUPT_BKPT = 0 + +const SQLITE_CORRUPT_INDEX = 779 + +const SQLITE_CORRUPT_SEQUENCE = 523 + +const SQLITE_CORRUPT_VTAB = 267 + +const SQLITE_CREATE_INDEX = 1 + +const SQLITE_CREATE_TABLE = 2 + +const SQLITE_CREATE_TEMP_INDEX = 3 + +const SQLITE_CREATE_TEMP_TABLE = 4 + +const SQLITE_CREATE_TEMP_TRIGGER = 5 + +const SQLITE_CREATE_TEMP_VIEW = 6 + +const SQLITE_CREATE_TRIGGER = 7 + +const SQLITE_CREATE_VIEW = 8 + +const SQLITE_CREATE_VTABLE = 29 + +const SQLITE_CacheSpill = 32 + +const SQLITE_CellSizeCk = 2097152 + +const SQLITE_CkptFullFSync = 16 + +const SQLITE_Coroutines = 33554432 + +const SQLITE_CountOfView = 512 + +const SQLITE_CoverIdxScan = 32 + +const SQLITE_CursorHints = 1024 + +const SQLITE_DBCONFIG_DEFENSIVE = 1010 + +const SQLITE_DBCONFIG_DQS_DDL = 1014 + +const SQLITE_DBCONFIG_DQS_DML = 1013 + +const SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE = 1020 + +const SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE = 1021 + +const SQLITE_DBCONFIG_ENABLE_COMMENTS = 1022 + +const SQLITE_DBCONFIG_ENABLE_FKEY = 1002 + +const SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004 + +const SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005 + +const SQLITE_DBCONFIG_ENABLE_QPSG = 1007 + +const SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003 + +const SQLITE_DBCONFIG_ENABLE_VIEW = 1015 + +const SQLITE_DBCONFIG_FP_DIGITS = 1023 + +const SQLITE_DBCONFIG_LEGACY_ALTER_TABLE = 1012 + +const SQLITE_DBCONFIG_LEGACY_FILE_FORMAT = 1016 + +const SQLITE_DBCONFIG_LOOKASIDE = 1001 + +const SQLITE_DBCONFIG_MAINDBNAME = 1000 + +const SQLITE_DBCONFIG_MAX = 1023 + +const SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE = 1006 + +const SQLITE_DBCONFIG_RESET_DATABASE = 1009 + +const SQLITE_DBCONFIG_REVERSE_SCANORDER = 1019 + +const SQLITE_DBCONFIG_STMT_SCANSTATUS = 1018 + +const SQLITE_DBCONFIG_TRIGGER_EQP = 1008 + +const SQLITE_DBCONFIG_TRUSTED_SCHEMA = 1017 + +const SQLITE_DBCONFIG_WRITABLE_SCHEMA = 1011 + +const SQLITE_DBSTATUS_CACHE_HIT = 7 + +const SQLITE_DBSTATUS_CACHE_MISS = 8 + +const SQLITE_DBSTATUS_CACHE_SPILL = 12 + +const SQLITE_DBSTATUS_CACHE_USED = 1 + +const SQLITE_DBSTATUS_CACHE_USED_SHARED = 11 + +const SQLITE_DBSTATUS_CACHE_WRITE = 9 + +const SQLITE_DBSTATUS_DEFERRED_FKS = 10 + +const SQLITE_DBSTATUS_LOOKASIDE_HIT = 4 + +const SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6 + +const SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5 + +const SQLITE_DBSTATUS_LOOKASIDE_USED = 0 + +const SQLITE_DBSTATUS_MAX = 13 + +const SQLITE_DBSTATUS_SCHEMA_USED = 2 + +const SQLITE_DBSTATUS_STMT_USED = 3 + +const SQLITE_DBSTATUS_TEMPBUF_SPILL = 13 + +const SQLITE_DEFAULT_AUTOVACUUM = 0 + +const SQLITE_DEFAULT_CACHE_SIZE = -2000 + +const SQLITE_DEFAULT_FILE_FORMAT = 4 + +const SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT = -1 + +const SQLITE_DEFAULT_LOOKASIDE = 40 + +const SQLITE_DEFAULT_MEMSTATUS = 0 + +const SQLITE_DEFAULT_MMAP_SIZE = 0 + +const SQLITE_DEFAULT_OPTIMIZE_LIMIT = 2000 + +const SQLITE_DEFAULT_PAGE_SIZE = 4096 + +const SQLITE_DEFAULT_PCACHE_INITSZ = 20 + +const SQLITE_DEFAULT_RECURSIVE_TRIGGERS = 0 + +const SQLITE_DEFAULT_SECTOR_SIZE = 4096 + +const SQLITE_DEFAULT_SORTERREF_SIZE = 2147483647 + +const SQLITE_DEFAULT_SYNCHRONOUS = 2 + +const SQLITE_DEFAULT_WAL_AUTOCHECKPOINT = 1000 + +const SQLITE_DEFAULT_WAL_SYNCHRONOUS = 2 + +const SQLITE_DEFAULT_WORKER_THREADS = 0 + +const SQLITE_DELETE = 9 + +const SQLITE_DENY = 1 + +const SQLITE_DESERIALIZE_FREEONCLOSE = 1 + +const SQLITE_DESERIALIZE_READONLY = 4 + +const SQLITE_DESERIALIZE_RESIZEABLE = 2 + +const SQLITE_DETACH = 25 + +const SQLITE_DETERMINISTIC = 2048 + +const SQLITE_DIGIT_SEPARATOR = 95 + +const SQLITE_DIRECTONLY = 524288 + +const SQLITE_DIRECT_OVERFLOW_READ = 1 + +const SQLITE_DISABLE_INTRINSIC = 1 + +const SQLITE_DONE = 101 + +const SQLITE_DQS = 3 + +const SQLITE_DROP_INDEX = 10 + +const SQLITE_DROP_TABLE = 11 + +const SQLITE_DROP_TEMP_INDEX = 12 + +const SQLITE_DROP_TEMP_TABLE = 13 + +const SQLITE_DROP_TEMP_TRIGGER = 14 + +const SQLITE_DROP_TEMP_VIEW = 15 + +const SQLITE_DROP_TRIGGER = 16 + +const SQLITE_DROP_VIEW = 17 + +const SQLITE_DROP_VTABLE = 30 + +const SQLITE_Defensive = 268435456 + +const SQLITE_DeferFKs = 524288 + +const SQLITE_DistinctOpt = 16 + +const SQLITE_DqsDDL = 536870912 + +const SQLITE_DqsDML = 1073741824 + +const SQLITE_ECEL_DUP = 1 + +const SQLITE_ECEL_FACTOR = 2 + +const SQLITE_ECEL_OMITREF = 8 + +const SQLITE_ECEL_REF = 4 + +const SQLITE_EMPTY = 16 + +const SQLITE_ENABLE_COLUMN_METADATA = 1 + +const SQLITE_ENABLE_DBPAGE_VTAB = 1 + +const SQLITE_ENABLE_DBSTAT_VTAB = 1 + +const SQLITE_ENABLE_FTS5 = 1 + +const SQLITE_ENABLE_GEOPOLY = 1 + +const SQLITE_ENABLE_JSON1 = 1 + +const SQLITE_ENABLE_MATH_FUNCTIONS = 1 + +const SQLITE_ENABLE_MEMORY_MANAGEMENT = 1 + +const SQLITE_ENABLE_OFFSET_SQL_FUNC = 1 + +const SQLITE_ENABLE_PREUPDATE_HOOK = 1 + +const SQLITE_ENABLE_RBU = 1 + +const SQLITE_ENABLE_RTREE = 1 + +const SQLITE_ENABLE_SESSION = 1 + +const SQLITE_ENABLE_SNAPSHOT = 1 + +const SQLITE_ENABLE_STAT4 = 1 + +const SQLITE_ENABLE_UNLOCK_NOTIFY = 1 + +const SQLITE_ERROR = 1 + +const SQLITE_ERROR_KEY = 1281 + +const SQLITE_ERROR_MISSING_COLLSEQ = 257 + +const SQLITE_ERROR_RESERVESIZE = 1025 + +const SQLITE_ERROR_RETRY = 513 + +const SQLITE_ERROR_SNAPSHOT = 769 + +const SQLITE_ERROR_UNABLE = 1537 + +const SQLITE_EXTERN = 0 + +const SQLITE_EnableQPSG = 8388608 + +const SQLITE_EnableTrigger = 262144 + +const SQLITE_EnableView = 2147483648 + +const SQLITE_ExistsToJoin = 1073741824 + +const SQLITE_FAIL = 3 + +const SQLITE_FAULTINJECTOR_COUNT = 1 + +const SQLITE_FAULTINJECTOR_MALLOC = 0 + +const SQLITE_FCNTL_BEGIN_ATOMIC_WRITE = 31 + +const SQLITE_FCNTL_BLOCK_ON_CONNECT = 44 + +const SQLITE_FCNTL_BUSYHANDLER = 15 + +const SQLITE_FCNTL_CHUNK_SIZE = 6 + +const SQLITE_FCNTL_CKPT_DONE = 37 + +const SQLITE_FCNTL_CKPT_START = 39 + +const SQLITE_FCNTL_CKSM_FILE = 41 + +const SQLITE_FCNTL_COMMIT_ATOMIC_WRITE = 32 + +const SQLITE_FCNTL_COMMIT_PHASETWO = 22 + +const SQLITE_FCNTL_DATA_VERSION = 35 + +const SQLITE_FCNTL_DB_UNCHANGED = 3389603744 + +const SQLITE_FCNTL_EXTERNAL_READER = 40 + +const SQLITE_FCNTL_FILESTAT = 45 + +const SQLITE_FCNTL_FILE_POINTER = 7 + +const SQLITE_FCNTL_GET_LOCKPROXYFILE = 2 + +const SQLITE_FCNTL_HAS_MOVED = 20 + +const SQLITE_FCNTL_JOURNAL_POINTER = 28 + +const SQLITE_FCNTL_LAST_ERRNO = 4 + +const SQLITE_FCNTL_LOCKSTATE = 1 + +const SQLITE_FCNTL_LOCK_TIMEOUT = 34 + +const SQLITE_FCNTL_MMAP_SIZE = 18 + +const SQLITE_FCNTL_NULL_IO = 43 + +const SQLITE_FCNTL_OVERWRITE = 11 + +const SQLITE_FCNTL_PDB = 30 + +const SQLITE_FCNTL_PERSIST_WAL = 10 + +const SQLITE_FCNTL_POWERSAFE_OVERWRITE = 13 + +const SQLITE_FCNTL_PRAGMA = 14 + +const SQLITE_FCNTL_RBU = 26 + +const SQLITE_FCNTL_RBUCNT = 5149216 + +const SQLITE_FCNTL_RESERVE_BYTES = 38 + +const SQLITE_FCNTL_RESET_CACHE = 42 + +const SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE = 33 + +const SQLITE_FCNTL_SET_LOCKPROXYFILE = 3 + +const SQLITE_FCNTL_SIZE_HINT = 5 + +const SQLITE_FCNTL_SIZE_LIMIT = 36 + +const SQLITE_FCNTL_SYNC = 21 + +const SQLITE_FCNTL_SYNC_OMITTED = 8 + +const SQLITE_FCNTL_TEMPFILENAME = 16 + +const SQLITE_FCNTL_TRACE = 19 + +const SQLITE_FCNTL_VFSNAME = 12 + +const SQLITE_FCNTL_VFS_POINTER = 27 + +const SQLITE_FCNTL_WAL_BLOCK = 24 + +const SQLITE_FCNTL_WIN32_AV_RETRY = 9 + +const SQLITE_FCNTL_WIN32_GET_HANDLE = 29 + +const SQLITE_FCNTL_WIN32_SET_HANDLE = 23 + +const SQLITE_FCNTL_ZIPVFS = 25 + +const SQLITE_FILE_HEADER = "SQLite format 3" + +const SQLITE_FLOAT = 2 + +const SQLITE_FORMAT = 24 + +const SQLITE_FP_PRECISION_LIMIT = 100000000 + +const SQLITE_FRAME_MAGIC = 2275391262 + +const SQLITE_FTS5_MAX_EXPR_DEPTH = 256 + +const SQLITE_FULL = 13 + +const SQLITE_FUNCTION = 31 + +const SQLITE_FUNC_ANYORDER = 134217728 + +const SQLITE_FUNC_BUILTIN = 8388608 + +const SQLITE_FUNC_BYTELEN = 192 + +const SQLITE_FUNC_CASE = 8 + +const SQLITE_FUNC_CONSTANT = 2048 + +const SQLITE_FUNC_COUNT = 256 + +const SQLITE_FUNC_DIRECT = 524288 + +const SQLITE_FUNC_ENCMASK = 3 + +const SQLITE_FUNC_EPHEM = 16 + +const SQLITE_FUNC_HASH_SZ = 23 + +const SQLITE_FUNC_INLINE = 4194304 + +const SQLITE_FUNC_INTERNAL = 262144 + +const SQLITE_FUNC_LENGTH = 64 + +const SQLITE_FUNC_LIKE = 4 + +const SQLITE_FUNC_MINMAX = 4096 + +const SQLITE_FUNC_NEEDCOLL = 32 + +const SQLITE_FUNC_RUNONLY = 32768 + +const SQLITE_FUNC_SLOCHNG = 8192 + +const SQLITE_FUNC_TEST = 16384 + +const SQLITE_FUNC_TYPEOF = 128 + +const SQLITE_FUNC_UNLIKELY = 1024 + +const SQLITE_FUNC_UNSAFE = 2097152 + +const SQLITE_FUNC_WINDOW = 65536 + +const SQLITE_FactorOutConst = 8 + +const SQLITE_FlttnUnionAll = 8388608 + +const SQLITE_ForeignKeys = 16384 + +const SQLITE_Fts3Tokenizer = 4194304 + +const SQLITE_FullColNames = 4 + +const SQLITE_FullFSync = 8 + +const SQLITE_GET_LOCKPROXYFILE = 2 + +const SQLITE_GroupByOrder = 4 + +const SQLITE_HAVE_C99_MATH_FUNCS = 1 + +const SQLITE_HAVE_ZLIB = 1 + +const SQLITE_IDXTYPE_APPDEF = 0 + +const SQLITE_IDXTYPE_IPK = 3 + +const SQLITE_IDXTYPE_PRIMARYKEY = 2 + +const SQLITE_IDXTYPE_UNIQUE = 1 + +const SQLITE_IGNORE = 2 + +const SQLITE_INDEX_CONSTRAINT_EQ = 2 + +const SQLITE_INDEX_CONSTRAINT_FUNCTION = 150 + +const SQLITE_INDEX_CONSTRAINT_GE = 32 + +const SQLITE_INDEX_CONSTRAINT_GLOB = 66 + +const SQLITE_INDEX_CONSTRAINT_GT = 4 + +const SQLITE_INDEX_CONSTRAINT_IS = 72 + +const SQLITE_INDEX_CONSTRAINT_ISNOT = 69 + +const SQLITE_INDEX_CONSTRAINT_ISNOTNULL = 70 + +const SQLITE_INDEX_CONSTRAINT_ISNULL = 71 + +const SQLITE_INDEX_CONSTRAINT_LE = 8 + +const SQLITE_INDEX_CONSTRAINT_LIKE = 65 + +const SQLITE_INDEX_CONSTRAINT_LIMIT = 73 + +const SQLITE_INDEX_CONSTRAINT_LT = 16 + +const SQLITE_INDEX_CONSTRAINT_MATCH = 64 + +const SQLITE_INDEX_CONSTRAINT_NE = 68 + +const SQLITE_INDEX_CONSTRAINT_OFFSET = 74 + +const SQLITE_INDEX_CONSTRAINT_REGEXP = 67 + +const SQLITE_INDEX_SCAN_HEX = 2 + +const SQLITE_INDEX_SCAN_UNIQUE = 1 + +const SQLITE_INNOCUOUS = 2097152 + +const SQLITE_INSERT = 18 + +const SQLITE_INTEGER = 1 + +const SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100 + +const SQLITE_INTERNAL = 2 + +const SQLITE_INTERRUPT = 9 + +const SQLITE_IOCAP_ATOMIC = 1 + +const SQLITE_IOCAP_ATOMIC16K = 64 + +const SQLITE_IOCAP_ATOMIC1K = 4 + +const SQLITE_IOCAP_ATOMIC2K = 8 + +const SQLITE_IOCAP_ATOMIC32K = 128 + +const SQLITE_IOCAP_ATOMIC4K = 16 + +const SQLITE_IOCAP_ATOMIC512 = 2 + +const SQLITE_IOCAP_ATOMIC64K = 256 + +const SQLITE_IOCAP_ATOMIC8K = 32 + +const SQLITE_IOCAP_BATCH_ATOMIC = 16384 + +const SQLITE_IOCAP_IMMUTABLE = 8192 + +const SQLITE_IOCAP_POWERSAFE_OVERWRITE = 4096 + +const SQLITE_IOCAP_SAFE_APPEND = 512 + +const SQLITE_IOCAP_SEQUENTIAL = 1024 + +const SQLITE_IOCAP_SUBPAGE_READ = 32768 + +const SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 2048 + +const SQLITE_IOERR = 10 + +const SQLITE_IOERR_ACCESS = 3338 + +const SQLITE_IOERR_AUTH = 7178 + +const SQLITE_IOERR_BADKEY = 8970 + +const SQLITE_IOERR_BEGIN_ATOMIC = 7434 + +const SQLITE_IOERR_BLOCKED = 2826 + +const SQLITE_IOERR_CHECKRESERVEDLOCK = 3594 + +const SQLITE_IOERR_CLOSE = 4106 + +const SQLITE_IOERR_CODEC = 9226 + +const SQLITE_IOERR_COMMIT_ATOMIC = 7690 + +const SQLITE_IOERR_CONVPATH = 6666 + +const SQLITE_IOERR_CORRUPTFS = 8458 + +const SQLITE_IOERR_DATA = 8202 + +const SQLITE_IOERR_DELETE = 2570 + +const SQLITE_IOERR_DELETE_NOENT = 5898 + +const SQLITE_IOERR_DIR_CLOSE = 4362 + +const SQLITE_IOERR_DIR_FSYNC = 1290 + +const SQLITE_IOERR_FSTAT = 1802 + +const SQLITE_IOERR_FSYNC = 1034 + +const SQLITE_IOERR_GETTEMPPATH = 6410 + +const SQLITE_IOERR_IN_PAGE = 8714 + +const SQLITE_IOERR_LOCK = 3850 + +const SQLITE_IOERR_MMAP = 6154 + +const SQLITE_IOERR_NOMEM = 3082 + +const SQLITE_IOERR_NOMEM_BKPT = 3082 + +const SQLITE_IOERR_RDLOCK = 2314 + +const SQLITE_IOERR_READ = 266 + +const SQLITE_IOERR_ROLLBACK_ATOMIC = 7946 + +const SQLITE_IOERR_SEEK = 5642 + +const SQLITE_IOERR_SHMLOCK = 5130 + +const SQLITE_IOERR_SHMMAP = 5386 + +const SQLITE_IOERR_SHMOPEN = 4618 + +const SQLITE_IOERR_SHMSIZE = 4874 + +const SQLITE_IOERR_SHORT_READ = 522 + +const SQLITE_IOERR_TRUNCATE = 1546 + +const SQLITE_IOERR_UNLOCK = 2058 + +const SQLITE_IOERR_VNODE = 6922 + +const SQLITE_IOERR_WRITE = 778 + +const SQLITE_IgnoreChecks = 512 + +const SQLITE_IndexedExpr = 16777216 + +const SQLITE_JUMPIFNULL = 16 + +const SQLITE_LAST_ERRNO = 4 + +const SQLITE_LIKE_DOESNT_MATCH_BLOBS = 1 + +const SQLITE_LIMIT_ATTACHED = 7 + +const SQLITE_LIMIT_COLUMN = 2 + +const SQLITE_LIMIT_COMPOUND_SELECT = 4 + +const SQLITE_LIMIT_EXPR_DEPTH = 3 + +const SQLITE_LIMIT_FUNCTION_ARG = 6 + +const SQLITE_LIMIT_LENGTH = 0 + +const SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8 + +const SQLITE_LIMIT_PARSER_DEPTH = 12 + +const SQLITE_LIMIT_SQL_LENGTH = 1 + +const SQLITE_LIMIT_TRIGGER_DEPTH = 10 + +const SQLITE_LIMIT_VARIABLE_NUMBER = 9 + +const SQLITE_LIMIT_VDBE_OP = 5 + +const SQLITE_LIMIT_WORKER_THREADS = 11 + +const SQLITE_LOCKED = 6 + +const SQLITE_LOCKED_SHAREDCACHE = 262 + +const SQLITE_LOCKED_VTAB = 518 + +const SQLITE_LOCK_EXCLUSIVE = 4 + +const SQLITE_LOCK_NONE = 0 + +const SQLITE_LOCK_PENDING = 3 + +const SQLITE_LOCK_RESERVED = 2 + +const SQLITE_LOCK_SHARED = 1 + +const SQLITE_LegacyAlter = 67108864 + +const SQLITE_LegacyFileFmt = 2 + +const SQLITE_LoadExtFunc = 131072 + +const SQLITE_LoadExtension = 65536 + +const SQLITE_MALLOC_SOFT_LIMIT = 1024 + +const SQLITE_MATCH = 0 + +const SQLITE_MAX_ALLOCATION_SIZE = 2147483391 + +const SQLITE_MAX_ATTACHED = 10 + +const SQLITE_MAX_COLUMN = 2000 + +const SQLITE_MAX_COMPOUND_SELECT = 500 + +const SQLITE_MAX_DB = 12 + +const SQLITE_MAX_DEFAULT_PAGE_SIZE = 8192 + +const SQLITE_MAX_EXPR_DEPTH = 1000 + +const SQLITE_MAX_FILE_FORMAT = 4 + +const SQLITE_MAX_FUNCTION_ARG = 1000 + +const SQLITE_MAX_LENGTH = 1000000000 + +const SQLITE_MAX_LIKE_PATTERN_LENGTH = 50000 + +const SQLITE_MAX_LOG_MESSAGE = 700 + +const SQLITE_MAX_MEMORY = 0 + +const SQLITE_MAX_PAGE_COUNT = 4294967294 + +const SQLITE_MAX_PAGE_SIZE = 65536 + +const SQLITE_MAX_PARSER_DEPTH = 2500 + +const SQLITE_MAX_PMASZ = 536870912 + +const SQLITE_MAX_PREPARE_RETRY = 25 + +const SQLITE_MAX_SCHEMA_RETRY = 50 + +const SQLITE_MAX_SQL_LENGTH = 1000000000 + +const SQLITE_MAX_SRCLIST = 200 + +const SQLITE_MAX_SYMLINK = 200 + +const SQLITE_MAX_TRIGGER_DEPTH = 1000 + +const SQLITE_MAX_VARIABLE_NUMBER = 32766 + +const SQLITE_MAX_VDBE_OP = 250000000 + +const SQLITE_MAX_WORKER_THREADS = 8 + +const SQLITE_MEMDB_DEFAULT_MAXSIZE = 1073741824 + +const SQLITE_MIN_LENGTH = 30 + +const SQLITE_MISMATCH = 20 + +const SQLITE_MISUSE = 21 + +const SQLITE_MISUSE_BKPT = 0 + +const SQLITE_MUTEX_FAST = 0 + +const SQLITE_MUTEX_RECURSIVE = 1 + +const SQLITE_MUTEX_STATIC_APP1 = 8 + +const SQLITE_MUTEX_STATIC_APP2 = 9 + +const SQLITE_MUTEX_STATIC_APP3 = 10 + +const SQLITE_MUTEX_STATIC_LRU = 6 + +const SQLITE_MUTEX_STATIC_LRU2 = 7 + +const SQLITE_MUTEX_STATIC_MAIN = 2 + +const SQLITE_MUTEX_STATIC_MASTER = 2 + +const SQLITE_MUTEX_STATIC_MEM = 3 + +const SQLITE_MUTEX_STATIC_MEM2 = 4 + +const SQLITE_MUTEX_STATIC_OPEN = 4 + +const SQLITE_MUTEX_STATIC_PMEM = 7 + +const SQLITE_MUTEX_STATIC_PRNG = 5 + +const SQLITE_MUTEX_STATIC_TEMPDIR = 11 + +const SQLITE_MUTEX_STATIC_VFS1 = 11 + +const SQLITE_MUTEX_STATIC_VFS2 = 12 + +const SQLITE_MUTEX_STATIC_VFS3 = 13 + +const SQLITE_MX_JUMP_OPCODE = 66 + +const SQLITE_MinMaxOpt = 65536 + +const SQLITE_NOLFS = 22 + +const SQLITE_NOMATCH = 1 + +const SQLITE_NOMEM = 7 + +const SQLITE_NOMEM_BKPT = 7 + +const SQLITE_NOTADB = 26 + +const SQLITE_NOTFOUND = 12 + +const SQLITE_NOTICE = 27 + +const SQLITE_NOTICE_RBU = 795 + +const SQLITE_NOTICE_RECOVER_ROLLBACK = 539 + +const SQLITE_NOTICE_RECOVER_WAL = 283 + +const SQLITE_NOTNULL = 144 + +const SQLITE_NOWILDCARDMATCH = 2 + +const SQLITE_NTUNE = 6 + +const SQLITE_NULL = 5 + +const SQLITE_NULLEQ = 128 + +const SQLITE_N_BTREE_META = 16 + +const SQLITE_N_KEYWORD = 147 + +const SQLITE_N_LIMIT = 13 + +const SQLITE_N_STDTYPE = 6 + +const SQLITE_NoCkptOnClose = 2048 + +const SQLITE_NoSchemaError = 134217728 + +const SQLITE_NullCallback = 256 + +const SQLITE_NullUnusedCols = 67108864 + +const SQLITE_OK = 0 + +const SQLITE_OK_LOAD_PERMANENTLY = 256 + +const SQLITE_OK_SYMLINK = 512 + +const SQLITE_OPEN_AUTOPROXY = 32 + +const SQLITE_OPEN_CREATE = 4 + +const SQLITE_OPEN_DELETEONCLOSE = 8 + +const SQLITE_OPEN_EXCLUSIVE = 16 + +const SQLITE_OPEN_EXRESCODE = 33554432 + +const SQLITE_OPEN_FULLMUTEX = 65536 + +const SQLITE_OPEN_MAIN_DB = 256 + +const SQLITE_OPEN_MAIN_JOURNAL = 2048 + +const SQLITE_OPEN_MASTER_JOURNAL = 16384 + +const SQLITE_OPEN_MEMORY = 128 + +const SQLITE_OPEN_NOFOLLOW = 16777216 + +const SQLITE_OPEN_NOMUTEX = 32768 + +const SQLITE_OPEN_PRIVATECACHE = 262144 + +const SQLITE_OPEN_READONLY = 1 + +const SQLITE_OPEN_READWRITE = 2 + +const SQLITE_OPEN_SHAREDCACHE = 131072 + +const SQLITE_OPEN_SUBJOURNAL = 8192 + +const SQLITE_OPEN_SUPER_JOURNAL = 16384 + +const SQLITE_OPEN_TEMP_DB = 512 + +const SQLITE_OPEN_TEMP_JOURNAL = 4096 + +const SQLITE_OPEN_TRANSIENT_DB = 1024 + +const SQLITE_OPEN_URI = 64 + +const SQLITE_OPEN_WAL = 524288 + +const SQLITE_OmitNoopJoin = 256 + +const SQLITE_OmitOrderBy = 262144 + +const SQLITE_OnePass = 134217728 + +const SQLITE_OrderByIdxJoin = 64 + +const SQLITE_OrderBySubq = 268435456 + +const SQLITE_PERM = 3 + +const SQLITE_POWERSAFE_OVERWRITE = 1 + +const SQLITE_PRAGMA = 19 + +const SQLITE_PREPARE_DONT_LOG = 16 + +const SQLITE_PREPARE_FROM_DDL = 32 + +const SQLITE_PREPARE_MASK = 63 + +const SQLITE_PREPARE_NORMALIZE = 2 + +const SQLITE_PREPARE_NO_VTAB = 4 + +const SQLITE_PREPARE_PERSISTENT = 1 + +const SQLITE_PREPARE_SAVESQL = 128 + +const SQLITE_PRINTF_INTERNAL = 1 + +const SQLITE_PRINTF_MALLOCED = 4 + +const SQLITE_PRINTF_SQLFUNC = 2 + +const SQLITE_PRINT_BUF_SIZE = 70 + +const SQLITE_PRIVATE = 0 + +const SQLITE_PROTOCOL = 15 + +const SQLITE_PropagateConst = 32768 + +const SQLITE_PushDown = 4096 + +const SQLITE_QUERY_PLANNER_LIMIT = 20000 + +const SQLITE_QUERY_PLANNER_LIMIT_INCR = 1000 + +const SQLITE_QueryFlattener = 1 + +const SQLITE_QueryOnly = 1048576 + +const SQLITE_RANGE = 25 + +const SQLITE_RBU_STATE_CHECKPOINT = 3 + +const SQLITE_RBU_STATE_DONE = 4 + +const SQLITE_RBU_STATE_ERROR = 5 + +const SQLITE_RBU_STATE_MOVE = 2 + +const SQLITE_RBU_STATE_OAL = 1 + +const SQLITE_RBU_UPDATE_CACHESIZE = 16 + +const SQLITE_READ = 20 + +const SQLITE_READONLY = 8 + +const SQLITE_READONLY_CANTINIT = 1288 + +const SQLITE_READONLY_CANTLOCK = 520 + +const SQLITE_READONLY_DBMOVED = 1032 + +const SQLITE_READONLY_DIRECTORY = 1544 + +const SQLITE_READONLY_RECOVERY = 264 + +const SQLITE_READONLY_ROLLBACK = 776 + +const SQLITE_RECURSIVE = 33 + +const SQLITE_REINDEX = 27 + +const SQLITE_REPLACE = 5 + +const SQLITE_RESULT_SUBTYPE = 16777216 + +const SQLITE_ROLLBACK = 1 + +const SQLITE_ROW = 100 + +const SQLITE_RecTriggers = 8192 + +const SQLITE_ReleaseReg = 4194304 + +const SQLITE_ResetDatabase = 33554432 + +const SQLITE_ReverseOrder = 4096 + +const SQLITE_SAVEPOINT = 32 + +const SQLITE_SCANSTAT_COMPLEX = 1 + +const SQLITE_SCANSTAT_EST = 2 + +const SQLITE_SCANSTAT_EXPLAIN = 4 + +const SQLITE_SCANSTAT_NAME = 3 + +const SQLITE_SCANSTAT_NCYCLE = 7 + +const SQLITE_SCANSTAT_NLOOP = 0 + +const SQLITE_SCANSTAT_NVISIT = 1 + +const SQLITE_SCANSTAT_PARENTID = 6 + +const SQLITE_SCANSTAT_SELECTID = 5 + +const SQLITE_SCHEMA = 17 + +const SQLITE_SCM_BRANCH = "branch-3.53" + +const SQLITE_SCM_DATETIME = "2026-06-03T19:12:13.350Z" + +const SQLITE_SCM_TAGS = "release version-3.53.2" + +const SQLITE_SELECT = 21 + +const SQLITE_SELFORDER1 = 33554432 + +const SQLITE_SERIALIZE_NOCOPY = 1 + +const SQLITE_SESSION_CONFIG_STRMSIZE = 1 + +const SQLITE_SESSION_OBJCONFIG_ROWID = 2 + +const SQLITE_SESSION_OBJCONFIG_SIZE = 1 + +const SQLITE_SETLK_BLOCK_ON_CONNECT = 1 + +const SQLITE_SET_LOCKPROXYFILE = 3 + +const SQLITE_SHM_EXCLUSIVE = 8 + +const SQLITE_SHM_LOCK = 2 + +const SQLITE_SHM_NLOCK = 8 + +const SQLITE_SHM_SHARED = 4 + +const SQLITE_SHM_UNLOCK = 1 + +const SQLITE_SORTER_PMASZ = 250 + +const SQLITE_SOUNDEX = 1 + +const SQLITE_SOURCE_ID = "2026-06-03 19:12:13 d6e03d8c777cfa2d35e3b60d8ec3e0187f3e9f99d8e2ee9cac695fd6fcdf1a24" + +const SQLITE_SO_ASC = 0 + +const SQLITE_SO_DESC = 1 + +const SQLITE_SO_UNDEFINED = -1 + +const SQLITE_STAT4_SAMPLES = 24 + +const SQLITE_STATE_BUSY = 109 + +const SQLITE_STATE_CLOSED = 206 + +const SQLITE_STATE_ERROR = 213 + +const SQLITE_STATE_OPEN = 118 + +const SQLITE_STATE_SICK = 186 + +const SQLITE_STATE_ZOMBIE = 167 + +const SQLITE_STATUS_MALLOC_COUNT = 9 + +const SQLITE_STATUS_MALLOC_SIZE = 5 + +const SQLITE_STATUS_MEMORY_USED = 0 + +const SQLITE_STATUS_PAGECACHE_OVERFLOW = 2 + +const SQLITE_STATUS_PAGECACHE_SIZE = 7 + +const SQLITE_STATUS_PAGECACHE_USED = 1 + +const SQLITE_STATUS_PARSER_STACK = 6 + +const SQLITE_STATUS_SCRATCH_OVERFLOW = 4 + +const SQLITE_STATUS_SCRATCH_SIZE = 8 + +const SQLITE_STATUS_SCRATCH_USED = 3 + +const SQLITE_STDCALL = 0 + +const SQLITE_STMTJRNL_SPILL = 65536 + +const SQLITE_STMTSTATUS_AUTOINDEX = 3 + +const SQLITE_STMTSTATUS_FILTER_HIT = 8 + +const SQLITE_STMTSTATUS_FILTER_MISS = 7 + +const SQLITE_STMTSTATUS_FULLSCAN_STEP = 1 + +const SQLITE_STMTSTATUS_MEMUSED = 99 + +const SQLITE_STMTSTATUS_REPREPARE = 5 + +const SQLITE_STMTSTATUS_RUN = 6 + +const SQLITE_STMTSTATUS_SORT = 2 + +const SQLITE_STMTSTATUS_VM_STEP = 4 + +const SQLITE_SUBTYPE = 1048576 + +const SQLITE_SYNC_DATAONLY = 16 + +const SQLITE_SYNC_FULL = 3 + +const SQLITE_SYNC_NORMAL = 2 + +const SQLITE_SYSTEM_MALLOC = 1 + +const SQLITE_SeekScan = 131072 + +const SQLITE_ShortColNames = 64 + +const SQLITE_SimplifyJoin = 8192 + +const SQLITE_SkipScan = 16384 + +const SQLITE_StarQuery = 536870912 + +const SQLITE_Stat4 = 2048 + +const SQLITE_StmtScanStatus = 1024 + +const SQLITE_TEMP_FILE_PREFIX = "etilqs_" + +const SQLITE_TEMP_STORE = 1 + +const SQLITE_TESTCTRL_ALWAYS = 13 + +const SQLITE_TESTCTRL_ASSERT = 12 + +const SQLITE_TESTCTRL_ATOF = 34 + +const SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10 + +const SQLITE_TESTCTRL_BITVEC_TEST = 8 + +const SQLITE_TESTCTRL_BYTEORDER = 22 + +const SQLITE_TESTCTRL_EXPLAIN_STMT = 19 + +const SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS = 29 + +const SQLITE_TESTCTRL_FAULT_INSTALL = 9 + +const SQLITE_TESTCTRL_FIRST = 5 + +const SQLITE_TESTCTRL_FK_NO_ACTION = 7 + +const SQLITE_TESTCTRL_GETOPT = 16 + +const SQLITE_TESTCTRL_IMPOSTER = 25 + +const SQLITE_TESTCTRL_INTERNAL_FUNCTIONS = 17 + +const SQLITE_TESTCTRL_ISINIT = 23 + +const SQLITE_TESTCTRL_ISKEYWORD = 16 + +const SQLITE_TESTCTRL_JSON_SELFCHECK = 14 + +const SQLITE_TESTCTRL_LAST = 34 + +const SQLITE_TESTCTRL_LOCALTIME_FAULT = 18 + +const SQLITE_TESTCTRL_LOGEST = 33 + +const SQLITE_TESTCTRL_NEVER_CORRUPT = 20 + +const SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD = 19 + +const SQLITE_TESTCTRL_OPTIMIZATIONS = 15 + +const SQLITE_TESTCTRL_PARSER_COVERAGE = 26 + +const SQLITE_TESTCTRL_PENDING_BYTE = 11 + +const SQLITE_TESTCTRL_PRNG_RESET = 7 + +const SQLITE_TESTCTRL_PRNG_RESTORE = 6 + +const SQLITE_TESTCTRL_PRNG_SAVE = 5 + +const SQLITE_TESTCTRL_PRNG_SEED = 28 + +const SQLITE_TESTCTRL_RESERVE = 14 + +const SQLITE_TESTCTRL_RESULT_INTREAL = 27 + +const SQLITE_TESTCTRL_SCRATCHMALLOC = 17 + +const SQLITE_TESTCTRL_SEEK_COUNT = 30 + +const SQLITE_TESTCTRL_SORTER_MMAP = 24 + +const SQLITE_TESTCTRL_TRACEFLAGS = 31 + +const SQLITE_TESTCTRL_TUNE = 32 + +const SQLITE_TESTCTRL_USELONGDOUBLE = 34 + +const SQLITE_TESTCTRL_VDBE_COVERAGE = 21 + +const SQLITE_TEXT = 3 + +const SQLITE_THREADSAFE = 1 + +const SQLITE_TOKEN_KEYWORD = 2 + +const SQLITE_TOKEN_QUOTED = 1 + +const SQLITE_TOOBIG = 18 + +const SQLITE_TRACE_CLOSE = 8 + +const SQLITE_TRACE_LEGACY = 64 + +const SQLITE_TRACE_NONLEGACY_MASK = 15 + +const SQLITE_TRACE_PROFILE = 2 + +const SQLITE_TRACE_ROW = 4 + +const SQLITE_TRACE_STMT = 1 + +const SQLITE_TRACE_XPROFILE = 128 + +const SQLITE_TRANSACTION = 22 + +const SQLITE_TXN_NONE = 0 + +const SQLITE_TXN_READ = 1 + +const SQLITE_TXN_WRITE = 2 + +const SQLITE_Transitive = 128 + +const SQLITE_TriggerEQP = 16777216 + +const SQLITE_TrustedSchema = 128 + +const SQLITE_U64_DIGITS = 20 + +const SQLITE_UPDATE = 23 + +const SQLITE_USE_URI = 0 + +const SQLITE_UTF16 = 4 + +const SQLITE_UTF16BE = 3 + +const SQLITE_UTF16LE = 2 + +const SQLITE_UTF16_ALIGNED = 8 + +const SQLITE_UTF8 = 1 + +const SQLITE_UTF8_ZT = 16 + +const SQLITE_VERSION = "3.53.2" + +const SQLITE_VERSION_NUMBER = 3053002 + +const SQLITE_VTABRISK_High = 2 + +const SQLITE_VTABRISK_Low = 0 + +const SQLITE_VTABRISK_Normal = 1 + +const SQLITE_VTAB_CONSTRAINT_SUPPORT = 1 + +const SQLITE_VTAB_DIRECTONLY = 3 + +const SQLITE_VTAB_INNOCUOUS = 2 + +const SQLITE_VTAB_USES_ALL_SCHEMAS = 4 + +const SQLITE_WARNING = 28 + +const SQLITE_WARNING_AUTOINDEX = 284 + +const SQLITE_WIN32_DATA_DIRECTORY_TYPE = 1 + +const SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2 + +const SQLITE_WITHOUT_ZONEMALLOC = 1 + +const SQLITE_WindowFunc = 2 + +const SQLITE_WriteSchema = 1 + +type SQLiteThread = TSQLiteThread + +const SRT_Coroutine = 11 + +const SRT_Discard = 2 + +const SRT_DistFifo = 3 + +const SRT_DistQueue = 4 + +const SRT_EphemTab = 10 + +const SRT_Exists = 1 + +const SRT_Fifo = 6 + +const SRT_Mem = 8 + +const SRT_Output = 7 + +const SRT_Queue = 5 + +const SRT_Set = 9 + +const SRT_Table = 12 + +const SRT_Upfrom = 13 + +const STAT_GET_NDLT = 4 + +const STAT_GET_NEQ = 2 + +const STAT_GET_NLT = 3 + +const STAT_GET_ROWID = 1 + +const STAT_GET_STAT1 = 0 + +const STDERR_FILENO = 2 + +const STDIN_FILENO = 0 + +const STDOUT_FILENO = 1 + +const SZ_KEYINFO_0 = 0 + +type Savepoint = TSavepoint + +type ScanStatus = TScanStatus + +type Schema = TSchema + +type Select = TSelect + +type SelectDest = TSelectDest + +type SessionApplyCtx = TSessionApplyCtx + +/* Number of prepared UPDATE statements to cache. */ + +type SessionBuffer = TSessionBuffer + +type SessionChange = TSessionChange + +type SessionDiffCtx = TSessionDiffCtx + +type SessionHook = TSessionHook + +type SessionInput = TSessionInput + +/* +** Minimum chunk size used by streaming versions of functions. + */ + +type SessionStat1Ctx = TSessionStat1Ctx + +type SessionTable = TSessionTable + +type SessionUpdate = TSessionUpdate + +type SortCtx = TSortCtx + +type SortSubtask = TSortSubtask + +type SorterCompare = TSorterCompare + +type SorterFile = TSorterFile + +type SorterList = TSorterList + +type SorterRecord = TSorterRecord + +type Sqlite3Config = TSqlite3Config + +/************** End of sqliteInt.h *******************************************/ +/************** Begin file os_common.h ***************************************/ +/* +** 2004 May 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains macros and a little bit of code that is common to +** all of the platform-specific files (os_*.c) and is #included into those +** files. +** +** This file should be #included by the os_*.c files only. It is not a +** general purpose header file. + */ + +/* +** At least two bugs have slipped in because we changed the MEMORY_DEBUG +** macro to SQLITE_DEBUG and some older makefiles have not yet made the +** switch. The following code should catch this problem at compile-time. + */ + +/* +** Macros for performance tracing. Normally turned off. Only works +** on i486 hardware. + */ + +/* +** If we compile with the SQLITE_TEST macro set, then the following block +** of code will give us the ability to simulate a disk I/O error. This +** is used for testing the I/O recovery logic. + */ + +/* +** When testing, keep a count of the number of open files. + */ + +/************** End of os_common.h *******************************************/ +/************** Begin file ctime.c *******************************************/ +/* DO NOT EDIT! +** This file is automatically generated by the script in the canonical +** SQLite source tree at tool/mkctimec.tcl. +** +** To modify this header, edit any of the various lists in that script +** which specify categories of generated conditionals in this file. + */ + +/* +** 2010 February 23 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file implements routines used to report what compile-time options +** SQLite was built with. + */ + +/* +** Include the configuration header output by 'configure' if we're using the +** autoconf-based build + */ + +/* These macros are provided to "stringify" the value of the define +** for those options in which the value is meaningful. */ + +/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This +** option requires a separate macro because legal values contain a single +** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */ +/* #include "sqliteInt.h" */ + +type Sqlite3_index_info = sqlite3_index_info + +type Sqlite3_int64 = sqlite3_int64 + +type Sqlite3_module = sqlite3_module + +type Sqlite3_mutex_methods = sqlite3_mutex_methods + +type Sqlite3_value = sqlite3_value + +type Sqlite3_vtab = sqlite3_vtab + +type Sqlite3_vtab_cursor = sqlite3_vtab_cursor + +type SrcItem = TSrcItem + +type SrcList = TSrcList + +type StatAccum = TStatAccum + +type StatCell = TStatCell + +type StatCursor = TStatCursor + +type StatPage = TStatPage + +type StatSample = TStatSample + +type StatTable = TStatTable + +type StrAccum = TStrAccum + +type SubProgram = TSubProgram + +type Subquery = TSubquery + +type SubrtnSig = TSubrtnSig + +type SubstContext = TSubstContext + +type SumCtx = TSumCtx + +const TABTYP_NORM = 0 + +const TABTYP_VIEW = 2 + +const TABTYP_VTAB = 1 + +// C documentation +// +// /* +// ** Forward references to structures +// */ +type TAggInfo = struct { + FdirectMode Tu8 + FuseSortingIdx Tu8 + FnSortingColumn Tu32 + FsortingIdx int32 + FsortingIdxPTab int32 + FiFirstReg int32 + FpGroupBy uintptr + FaCol uintptr + FnColumn int32 + FnAccumulator int32 + FaFunc uintptr + FnFunc int32 + FselId Tu32 +} + +type TAggInfo_col = struct { + FpTab uintptr + FpCExpr uintptr + FiTable int32 + FiColumn int32 + FiSorterColumn int32 +} + +type TAggInfo_func = struct { + FpFExpr uintptr + FpFunc uintptr + FiDistinct int32 + FiDistAddr int32 + FiOBTab int32 + FbOBPayload Tu8 + FbOBUnique Tu8 + FbUseSubtype Tu8 +} + +type TAsciiTokenizer = struct { + FaTokenChar [128]uint8 +} + +type TAuthContext = struct { + FzAuthContext uintptr + FpParse uintptr +} + +type TAutoincInfo = struct { + FpNext uintptr + FpTab uintptr + FiDb int32 + FregCtr int32 +} + +// C documentation +// +// /* Elements of the linked list at Vdbe.pAuxData */ +type TAuxData = struct { + FiAuxOp int32 + FiAuxArg int32 + FpAux uintptr + FxDeleteAux uintptr + FpNextAux uintptr +} + +// C documentation +// +// /* +// ** Global variables. +// */ +type TBenignMallocHooks = struct { + FxBenignBegin uintptr + FxBenignEnd uintptr +} + +// C documentation +// +// /* +// ** The bitmask datatype defined below is used for various optimizations. +// ** +// ** Changing this from a 64-bit to a 32-bit type limits the number of +// ** tables in a join to 32 instead of 64. But it also reduces the size +// ** of the library by 738 bytes on ix86. +// */ +type TBitmask = uint64 + +// C documentation +// +// /* +// ** Boolean values +// */ +type TBool = uint32 + +type TBtLock = struct { + FpBtree uintptr + FiTable TPgno + FeLock Tu8 + FpNext uintptr +} + +type TBtShared = struct { + FpPager uintptr + Fdb uintptr + FpCursor uintptr + FpPage1 uintptr + FopenFlags Tu8 + FautoVacuum Tu8 + FincrVacuum Tu8 + FbDoTruncate Tu8 + FinTransaction Tu8 + Fmax1bytePayload Tu8 + FnReserveWanted Tu8 + FbtsFlags Tu16 + FmaxLocal Tu16 + FminLocal Tu16 + FmaxLeaf Tu16 + FminLeaf Tu16 + FpageSize Tu32 + FusableSize Tu32 + FnTransaction int32 + FnPage Tu32 + FpSchema uintptr + FxFreeSchema uintptr + Fmutex uintptr + FpHasContent uintptr + FnRef int32 + FpNext uintptr + FpLock uintptr + FpWriter uintptr + FpTmpSpace uintptr + FnPreformatSize int32 +} + +// C documentation +// +// /* +// ** Forward declarations of structure +// */ +type TBtree = struct { + Fdb uintptr + FpBt uintptr + FinTrans Tu8 + Fsharable Tu8 + Flocked Tu8 + FhasIncrblobCur Tu8 + FwantToLock int32 + FnBackup int32 + FiBDataVersion Tu32 + FpNext uintptr + FpPrev uintptr + Flock TBtLock +} + +// C documentation +// +// /* +// ** An instance of the following structure is used to store the busy-handler +// ** callback for a given sqlite handle. +// ** +// ** The sqlite.busyHandler member of the sqlite struct contains the busy +// ** callback for the database handle. Each pager opened via the sqlite +// ** handle is passed a pointer to sqlite.busyHandler. The busy-handler +// ** callback is currently invoked only from within pager.c. +// */ +type TBusyHandler = struct { + FxBusyHandler uintptr + FpBusyArg uintptr + FnBusy int32 +} + +// C documentation +// +// /* +// ** Object used to iterate through all "coalesced phrase instances" in +// ** a single column of the current row. If the phrase instances in the +// ** column being considered do not overlap, this object simply iterates +// ** through them. Or, if they do overlap (share one or more tokens in +// ** common), each set of overlapping instances is treated as a single +// ** match. See documentation for the highlight() auxiliary function for +// ** details. +// ** +// ** Usage is: +// ** +// ** for(rc = fts5CInstIterNext(pApi, pFts, iCol, &iter); +// ** (rc==SQLITE_OK && 0==fts5CInstIterEof(&iter); +// ** rc = fts5CInstIterNext(&iter) +// ** ){ +// ** printf("instance starts at %d, ends at %d\n", iter.iStart, iter.iEnd); +// ** } +// ** +// */ +type TCInstIter = struct { + FpApi uintptr + FpFts uintptr + FiCol int32 + FiInst int32 + FnInst int32 + FiStart int32 + FiEnd int32 +} + +// C documentation +// +// /* +// ** A CellArray object contains a cache of pointers and sizes for a +// ** consecutive sequence of cells that might be held on multiple pages. +// ** +// ** The cells in this array are the divider cell or cells from the pParent +// ** page plus up to three child pages. There are a total of nCell cells. +// ** +// ** pRef is a pointer to one of the pages that contributes cells. This is +// ** used to access information such as MemPage.intKey and MemPage.pBt->pageSize +// ** which should be common to all pages that contribute cells to this array. +// ** +// ** apCell[] and szCell[] hold, respectively, pointers to the start of each +// ** cell and the size of each cell. Some of the apCell[] pointers might refer +// ** to overflow cells. In other words, some apCel[] pointers might not point +// ** to content area of the pages. +// ** +// ** A szCell[] of zero means the size of that cell has not yet been computed. +// ** +// ** The cells come from as many as four different pages: +// ** +// ** ----------- +// ** | Parent | +// ** ----------- +// ** / | ** / | ** --------- --------- --------- +// ** |Child-1| |Child-2| |Child-3| +// ** --------- --------- --------- +// ** +// ** The order of cells is in the array is for an index btree is: +// ** +// ** 1. All cells from Child-1 in order +// ** 2. The first divider cell from Parent +// ** 3. All cells from Child-2 in order +// ** 4. The second divider cell from Parent +// ** 5. All cells from Child-3 in order +// ** +// ** For a table-btree (with rowids) the items 2 and 4 are empty because +// ** content exists only in leaves and there are no divider cells. +// ** +// ** For an index btree, the apEnd[] array holds pointer to the end of page +// ** for Child-1, the Parent, Child-2, the Parent (again), and Child-3, +// ** respectively. The ixNx[] array holds the number of cells contained in +// ** each of these 5 stages, and all stages to the left. Hence: +// ** +// ** ixNx[0] = Number of cells in Child-1. +// ** ixNx[1] = Number of cells in Child-1 plus 1 for first divider. +// ** ixNx[2] = Number of cells in Child-1 and Child-2 + 1 for 1st divider. +// ** ixNx[3] = Number of cells in Child-1 and Child-2 + both divider cells +// ** ixNx[4] = Total number of cells. +// ** +// ** For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2] +// ** are used and they point to the leaf pages only, and the ixNx value are: +// ** +// ** ixNx[0] = Number of cells in Child-1. +// ** ixNx[1] = Number of cells in Child-1 and Child-2. +// ** ixNx[2] = Total number of cells. +// ** +// ** Sometimes when deleting, a child page can have zero cells. In those +// ** cases, ixNx[] entries with higher indexes, and the corresponding apEnd[] +// ** entries, shift down. The end result is that each ixNx[] entry should +// ** be larger than the previous +// */ +type TCellArray = struct { + FnCell int32 + FpRef uintptr + FapCell uintptr + FszCell uintptr + FapEnd [6]uintptr + FixNx [6]int32 +} + +// C documentation +// +// /* +// ** The parts of the sqlite3_changegroup structure used by the +// ** sqlite3changegroup_change_xxx() APIs. +// */ +type TChangeData = struct { + FpTab uintptr + FbIndirect int32 + FeOp int32 + FnBufAlloc int32 + FaBuf uintptr + Frecord TSessionBuffer +} + +// C documentation +// +// /* +// ** Type used for Walker callbacks by selectCheckOnClauses(). +// */ +type TCheckOnCtx = struct { + FpSrc uintptr + FiJoin int32 + FbFuncArg int32 + FpParent uintptr +} + +type TCollSeq = struct { + FzName uintptr + Fenc Tu8 + FpUser uintptr + FxCmp uintptr + FxDel uintptr +} + +// C documentation +// +// /* +// ** Structure passed to the whereIsCoveringIndex Walker callback. +// */ +type TCoveringIndexCheck = struct { + FpIdx uintptr + FiTabCur int32 + FbExpr Tu8 + FbUnidx Tu8 +} + +type TCte = struct { + FzName uintptr + FpCols uintptr + FpSelect uintptr + FzCteErr uintptr + FpUse uintptr + FeM10d Tu8 +} + +type TCteUse = struct { + FnUse int32 + FaddrM9e int32 + FregRtn int32 + FiCur int32 + FnRowEst TLogEst + FeM10d Tu8 +} + +type TDb = struct { + FzDbSName uintptr + FpBt uintptr + Fsafety_level Tu8 + FbSyncSet Tu8 + FpSchema uintptr +} + +type TDbClientData = struct { + FpNext uintptr + FpData uintptr + FxDestructor uintptr +} + +type TDbFixer = struct { + FpParse uintptr + Fw TWalker + FpSchema uintptr + FbTemp Tu8 + FzDb uintptr + FzType uintptr + FpName uintptr +} + +type TDbpageCursor = struct { + Fbase Tsqlite3_vtab_cursor + Fpgno TPgno + FmxPgno TPgno + FpPager uintptr + FpPage1 uintptr + FiDb int32 + FszPage int32 +} + +type TDbpageTable = struct { + Fbase Tsqlite3_vtab + Fdb uintptr + FiDbTrunc int32 + FpgnoTrunc TPgno +} + +// C documentation +// +// /* +// ** An instance of the following object is used to record information about +// ** how to process the DISTINCT keyword, to simplify passing that information +// ** into the selectInnerLoop() routine. +// */ +type TDistinctCtx = struct { + FisTnct Tu8 + FeTnctType Tu8 + FtabTnct int32 + FaddrTnct int32 +} + +const TERM_ANDINFO = 32 + +const TERM_CODED = 4 + +const TERM_COPIED = 8 + +const TERM_DYNAMIC = 1 + +const TERM_HEURTRUTH = 8192 + +const TERM_HIGHTRUTH = 16384 + +const TERM_IS = 2048 + +const TERM_LIKE = 1024 + +const TERM_LIKECOND = 512 + +const TERM_LIKEOPT = 256 + +const TERM_OK = 64 + +const TERM_ORINFO = 16 + +const TERM_SLICE = 32768 + +const TERM_VARSELECT = 4096 + +const TERM_VIRTUAL = 2 + +const TERM_VNULL = 128 + +// C documentation +// +// /* +// ** An EdupBuf is a memory allocation used to stored multiple Expr objects +// ** together with their Expr.zToken content. This is used to help implement +// ** compression while doing sqlite3ExprDup(). The top-level Expr does the +// ** allocation for itself and many of its decendents, then passes an instance +// ** of the structure down into exprDup() so that they decendents can have +// ** access to that memory. +// */ +type TEdupBuf = struct { + FzAlloc uintptr +} + +// C documentation +// +// /* +// ** Add a new element to the end of an expression list. If pList is +// ** initially NULL, then create a new expression list. +// ** +// ** The pList argument must be either NULL or a pointer to an ExprList +// ** obtained from a prior call to sqlite3ExprListAppend(). +// ** +// ** If a memory allocation error occurs, the entire list is freed and +// ** NULL is returned. If non-NULL is returned, then it is guaranteed +// ** that the new entry was successfully appended. +// */ +type TExprList_item = struct { + FpExpr uintptr + FzEName uintptr + Ffg struct { + F__ccgo_align [0]uint32 + FsortFlags Tu8 + F__ccgo_align1 [2]byte + F__ccgo4 uint16 + } + Fu struct { + FiConstExprReg [0]int32 + Fx struct { + FiOrderByCol Tu16 + FiAlias Tu16 + } + } +} + +type TFKey = struct { + FpFrom uintptr + FpNextFrom uintptr + FzTo uintptr + FpNextTo uintptr + FpPrevTo uintptr + FnCol int32 + FisDeferred Tu8 + FaAction [2]Tu8 + FapTrigger [2]uintptr +} + +const TF_Autoincrement = 8 + +const TF_Ephemeral = 16384 + +const TF_Eponymous = 32768 + +const TF_HasGenerated = 96 + +const TF_HasHidden = 2 + +const TF_HasNotNull = 2048 + +const TF_HasPrimaryKey = 4 + +const TF_HasStat1 = 16 + +const TF_HasStat4 = 8192 + +const TF_HasStored = 64 + +const TF_HasVirtual = 32 + +const TF_Imposter = 131072 + +const TF_MaybeReanalyze = 256 + +const TF_NoVisibleRowid = 512 + +const TF_OOOHidden = 1024 + +const TF_Readonly = 1 + +const TF_Shadow = 4096 + +const TF_Strict = 65536 + +const TF_WithoutRowid = 128 + +type TFileChunk = struct { + FpNext uintptr + FzChunk [8]Tu8 +} + +type TFrameBound = struct { + FeType int32 + FpExpr uintptr +} + +type TFts5Auxdata = struct { + FpAux uintptr + FpPtr uintptr + FxDelete uintptr + FpNext uintptr +} + +type TFts5Auxiliary = struct { + FpGlobal uintptr + FzFunc uintptr + FpUserData uintptr + FxFunc Tfts5_extension_function + FxDestroy uintptr + FpNext uintptr +} + +// C documentation +// +// /* +// ** Buffer object for the incremental building of string data. +// */ +type TFts5Buffer = struct { + Fp uintptr + Fn int32 + FnSpace int32 +} + +type TFts5CResult = struct { + FiFirst Tu16 + FbTermEq Tu8 +} + +type TFts5Colset = struct { + FnCol int32 +} + +type TFts5Config = struct { + Fdb uintptr + FpGlobal uintptr + FzDb uintptr + FzName uintptr + FnCol int32 + FazCol uintptr + FabUnindexed uintptr + FnPrefix int32 + FaPrefix uintptr + FeContent int32 + FbContentlessDelete int32 + FbContentlessUnindexed int32 + FzContent uintptr + FzContentRowid uintptr + FbColumnsize int32 + FbTokendata int32 + FbLocale int32 + FeDetail int32 + FzContentExprlist uintptr + Ft TFts5TokenizerConfig + FbLock int32 + FiVersion int32 + FiCookie int32 + Fpgsz int32 + FnAutomerge int32 + FnCrisisMerge int32 + FnUsermerge int32 + FnHashSize int32 + FzRank uintptr + FzRankArgs uintptr + FbSecureDelete int32 + FnDeleteMerge int32 + FbPrefixInsttoken int32 + FpzErrmsg uintptr +} + +type TFts5Data = struct { + Fp uintptr + Fnn int32 + FszLeaf int32 +} + +type TFts5Enum = struct { + FzName uintptr + FeVal int32 +} + +// C documentation +// +// /************************************************************************** +// ** Interface to code in fts5_expr.c. +// */ +type TFts5Expr = struct { + FpIndex uintptr + FpConfig uintptr + FpRoot uintptr + FbDesc int32 + FnPhrase int32 + FapExprPhrase uintptr +} + +type TFts5ExprNearset = struct { + FnNear int32 + FpColset uintptr + FnPhrase int32 +} + +type TFts5ExprPhrase = struct { + FpNode uintptr + Fposlist TFts5Buffer + FnTerm int32 +} + +type TFts5ExprTerm = struct { + FbPrefix Tu8 + FbFirst Tu8 + FpTerm uintptr + FnQueryTerm int32 + FnFullTerm int32 + FpIter uintptr + FpSynonym uintptr +} + +type TFts5ExtensionApi = struct { + FiVersion int32 + FxUserData uintptr + FxColumnCount uintptr + FxRowCount uintptr + FxColumnTotalSize uintptr + FxTokenize uintptr + FxPhraseCount uintptr + FxPhraseSize uintptr + FxInstCount uintptr + FxInst uintptr + FxRowid uintptr + FxColumnText uintptr + FxColumnSize uintptr + FxQueryPhrase uintptr + FxSetAuxdata uintptr + FxGetAuxdata uintptr + FxPhraseFirst uintptr + FxPhraseNext uintptr + FxPhraseFirstColumn uintptr + FxPhraseNextColumn uintptr + FxQueryToken uintptr + FxInstToken uintptr + FxColumnLocale uintptr + FxTokenize_v2 uintptr +} + +type TFts5FullTable = struct { + Fp TFts5Table + FpStorage uintptr + FpGlobal uintptr + FpSortCsr uintptr + FiSavepoint int32 +} + +// C documentation +// +// /************************************************************************** +// ** Interface to code in fts5_hash.c. +// */ +type TFts5Hash = struct { + FeDetail int32 + FpnByte uintptr + FnEntry int32 + FnSlot int32 + FpScan uintptr + FaSlot uintptr +} + +type TFts5InsertCtx = struct { + FpStorage uintptr + FiCol int32 + FszCol int32 +} + +type TFts5MatchPhrase = struct { + FpPoslist uintptr + FnTerm int32 +} + +type TFts5PageWriter = struct { + Fpgno int32 + FiPrevPgidx int32 + Fbuf TFts5Buffer + Fpgidx TFts5Buffer + Fterm TFts5Buffer +} + +type TFts5Parse = struct { + FpConfig uintptr + FzErr uintptr + Frc int32 + FnPhrase int32 + FapPhrase uintptr + FpExpr uintptr + FbPhraseToAnd int32 +} + +type TFts5PhraseIter = struct { + Fa uintptr + Fb uintptr +} + +// C documentation +// +// /* +// ** Context object passed to the fts5SentenceFinderCb() function. +// */ +type TFts5SFinder = struct { + FiPos int32 + FnFirstAlloc int32 + FnFirst int32 + FaFirst uintptr + FzDoc uintptr +} + +type TFts5StructureLevel = struct { + FnMerge int32 + FnSeg int32 + FaSeg uintptr +} + +// C documentation +// +// /* +// ** Virtual-table object. +// */ +type TFts5Table = struct { + Fbase Tsqlite3_vtab + FpConfig uintptr + FpIndex uintptr +} + +// C documentation +// +// /* Bucket of terms object used by the integrity-check in offsets=0 mode. */ +type TFts5Termset = struct { + FapHash [512]uintptr +} + +// C documentation +// +// /************************************************************************* +// */ +type TFts5TermsetEntry = struct { + FpTerm uintptr + FnTerm int32 + FiIdx int32 + FpNext uintptr +} + +type TFts5Token = struct { + Fp uintptr + Fn int32 +} + +type TFts5TokenizerConfig = struct { + FpTok uintptr + FpApi2 uintptr + FpApi1 uintptr + FazArg uintptr + FnArg int32 + FePattern int32 + FpLocale uintptr + FnLocale int32 +} + +type TFts5TokenizerModule = struct { + FzName uintptr + FpUserData uintptr + FbV2Native int32 + Fx1 Tfts5_tokenizer + Fx2 Tfts5_tokenizer_v2 + FxDestroy uintptr + FpNext uintptr +} + +/* +** NOTES ON TRANSACTIONS: +** +** SQLite invokes the following virtual table methods as transactions are +** opened and closed by the user: +** +** xBegin(): Start of a new transaction. +** xSync(): Initial part of two-phase commit. +** xCommit(): Final part of two-phase commit. +** xRollback(): Rollback the transaction. +** +** Anything that is required as part of a commit that may fail is performed +** in the xSync() callback. Current versions of SQLite ignore any errors +** returned by xCommit(). +** +** And as sub-transactions are opened/closed: +** +** xSavepoint(int S): Open savepoint S. +** xRelease(int S): Commit and close savepoint S. +** xRollbackTo(int S): Rollback to start of savepoint S. +** +** During a write-transaction the fts5_index.c module may cache some data +** in-memory. It is flushed to disk whenever xSync(), xRelease() or +** xSavepoint() is called. And discarded whenever xRollback() or xRollbackTo() +** is called. +** +** Additionally, if SQLITE_DEBUG is defined, an instance of the following +** structure is used to record the current transaction state. This information +** is not required, but it is used in the assert() statements executed by +** function fts5CheckTransactionState() (see below). + */ +type TFts5TransactionState = struct { + FeState int32 + FiSavepoint int32 +} + +type TFts5VocabTable = struct { + Fbase Tsqlite3_vtab + FzFts5Tbl uintptr + FzFts5Db uintptr + Fdb uintptr + FpGlobal uintptr + FeType int32 + FbBusy uint32 +} + +// C documentation +// +// /* +// ** An instance of this type is used as the Fts5Tokenizer object for +// ** wrapper tokenizers - those that provide access to a v1 tokenizer via +// ** the fts5_tokenizer_v2 API, and those that provide access to a v2 tokenizer +// ** via the fts5_tokenizer API. +// */ +type TFts5VtoVTokenizer = struct { + FbV2Native int32 + Fx1 Tfts5_tokenizer + Fx2 Tfts5_tokenizer_v2 + FpReal uintptr +} + +type TFuncDef = struct { + FnArg Ti16 + FfuncFlags Tu32 + FpUserData uintptr + FpNext uintptr + FxSFunc uintptr + FxFinalize uintptr + FxValue uintptr + FxInverse uintptr + FzName uintptr + Fu struct { + FpDestructor [0]uintptr + FpHash uintptr + } +} + +type TFuncDefHash = struct { + Fa [23]uintptr +} + +type TFuncDestructor = struct { + FnRef int32 + FxDestroy uintptr + FpUserData uintptr +} + +// C documentation +// +// /* +// ** State vector for the geopoly_group_bbox() aggregate function. +// */ +type TGeoBBox = struct { + FisInit int32 + Fa [4]TRtreeCoord +} + +// C documentation +// +// /* Datatype for coordinates +// */ +type TGeoCoord = float32 + +type TGeoOverlap = struct { + FaEvent uintptr + FaSegment uintptr + FnEvent int32 + FnSegment int32 +} + +// C documentation +// +// /* +// ** State of a parse of a GeoJSON input. +// */ +type TGeoParse = struct { + Fz uintptr + FnVertex int32 + FnAlloc int32 + FnErr int32 + Fa uintptr +} + +// C documentation +// +// /* +// ** Internal representation of a polygon. +// ** +// ** The polygon consists of a sequence of vertexes. There is a line +// ** segment between each pair of vertexes, and one final segment from +// ** the last vertex back to the first. (This differs from the GeoJSON +// ** standard in which the final vertex is a repeat of the first.) +// ** +// ** The polygon follows the right-hand rule. The area to the right of +// ** each segment is "outside" and the area to the left is "inside". +// ** +// ** The on-disk representation consists of a 4-byte header followed by +// ** the values. The 4-byte header is: +// ** +// ** encoding (1 byte) 0=big-endian, 1=little-endian +// ** nvertex (3 bytes) Number of vertexes as a big-endian integer +// ** +// ** Enough space is allocated for 4 coordinates, to work around over-zealous +// ** warnings coming from some compiler (notably, clang). In reality, the size +// ** of each GeoPoly memory allocate is adjusted as necessary so that the +// ** GeoPoly.a[] array at the end is the appropriate size. +// */ +type TGeoPoly = struct { + FnVertex int32 + Fhdr [4]uint8 + Fa [8]TGeoCoord +} + +// C documentation +// +// /* +// ** group_concat(EXPR, ?SEPARATOR?) +// ** string_agg(EXPR, SEPARATOR) +// ** +// ** Content is accumulated in GroupConcatCtx.str with the SEPARATOR +// ** coming before the EXPR value, except for the first entry which +// ** omits the SEPARATOR. +// ** +// ** It is tragic that the SEPARATOR goes before the EXPR string. The +// ** groupConcatInverse() implementation would have been easier if the +// ** SEPARATOR were appended after EXPR. And the order is undocumented, +// ** so we could change it, in theory. But the old behavior has been +// ** around for so long that we dare not, for fear of breaking something. +// */ +type TGroupConcatCtx = struct { + Fstr TStrAccum + FnAccum int32 + FnFirstSepLength int32 + FpnSepLengths uintptr +} + +// C documentation +// +// /* Forward declarations of structures. */ +type THash = struct { + Fhtsize uint32 + Fcount uint32 + Ffirst uintptr + Fht uintptr +} + +type THashElem = struct { + Fnext uintptr + Fprev uintptr + Fdata uintptr + FpKey uintptr + Fh uint32 +} + +// C documentation +// +// /* +// ** Extra information appended to the end of sqlite3_index_info but not +// ** visible to the xBestIndex function, at least not directly. The +// ** sqlite3_vtab_collation() interface knows how to reach it, however. +// ** +// ** This object is not an API and can be changed from one release to the +// ** next. As long as allocateIndexInfo() and sqlite3_vtab_collation() +// ** agree on the structure, all will be well. +// */ +type THiddenIndexInfo = struct { + FpWC uintptr + FpParse uintptr + FeDistinct int32 + FmIn Tu32 + FmHandleIn Tu32 +} + +// C documentation +// +// /************************************************************************* +// ** Start of highlight() implementation. +// */ +type THighlightContext = struct { + FiRangeStart int32 + FiRangeEnd int32 + FzOpen uintptr + FzClose uintptr + FzIn uintptr + FnIn int32 + Fiter TCInstIter + FiPos int32 + FiOff int32 + FbOpen int32 + FzOut uintptr +} + +type TIdList_item = struct { + FzName uintptr +} + +/* +** An instance of the following structure is used by the tree walker +** to determine if an expression can be evaluated by reference to the +** index only, without having to do a search for the corresponding +** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur +** is the cursor for the table. + */ +type TIdxCover = struct { + FpIdx uintptr + FiCur int32 +} + +type TInLoop = struct { + FiCur int32 + FaddrInTop int32 + FiBase int32 + FnPrefix int32 + FeEndLoopOp Tu8 +} + +// C documentation +// +// /* +// ** Valid sqlite3_blob* handles point to Incrblob structures. +// */ +type TIncrblob = struct { + FnByte int32 + FiOffset int32 + FiCol Tu16 + FpCsr uintptr + FpStmt uintptr + Fdb uintptr + FzDb uintptr + FpTab uintptr +} + +// C documentation +// +// /* +// ** The sqlite3GenerateConstraintChecks() routine usually wants to visit +// ** the indexes of a table in the order provided in the Table->pIndex list. +// ** However, sometimes (rarely - when there is an upsert) it wants to visit +// ** the indexes in a different order. The following data structures accomplish +// ** this. +// ** +// ** The IndexIterator object is used to walk through all of the indexes +// ** of a table in either Index.pNext order, or in some other order established +// ** by an array of IndexListTerm objects. +// */ +type TIndexListTerm = struct { + Fp uintptr + Fix int32 +} + +type TIndexSample = struct { + Fp uintptr + Fn int32 + FanEq uintptr + FanLt uintptr + FanDLt uintptr +} + +type TIndexedExpr = struct { + FpExpr uintptr + FiDataCur int32 + FiIdxCur int32 + FiIdxCol int32 + FbMaybeNullRow Tu8 + Faff Tu8 + FpIENext uintptr +} + +// C documentation +// +// /* +// ** A pointer to this structure is used to communicate information +// ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. +// */ +type TInitData = struct { + Fdb uintptr + FpzErrMsg uintptr + FiDb int32 + Frc int32 + FmInitFlags Tu32 + FnInitRow Tu32 + FmxPage TPgno +} + +// C documentation +// +// /* Objects */ +type TJsonCache = struct { + Fdb uintptr + FnUsed int32 + Fa [4]uintptr +} + +type TJsonEachConnection = struct { + Fbase Tsqlite3_vtab + Fdb uintptr + FeMode Tu8 + FbRecursive Tu8 +} + +type TJsonParse = struct { + FaBlob uintptr + FnBlob Tu32 + FnBlobAlloc Tu32 + FzJson uintptr + Fdb uintptr + FnJson int32 + FnJPRef Tu32 + FiErr Tu32 + FiDepth Tu16 + FnErr Tu8 + Foom Tu8 + FbJsonIsRCStr Tu8 + FhasNonstd Tu8 + FbReadOnly Tu8 + FeEdit Tu8 + Fdelta int32 + FnIns Tu32 + FiLabel Tu32 + FaIns uintptr +} + +// C documentation +// +// /* Context for recursion of json_pretty() +// */ +type TJsonPretty = struct { + FpParse uintptr + FpOut uintptr + FzIndent uintptr + FszIndent Tu32 + FnIndent Tu32 +} + +const TK_ABORT = 27 + +const TK_ACTION = 28 + +const TK_ADD = 164 + +const TK_AFTER = 29 + +const TK_AGG_COLUMN = 170 + +const TK_AGG_FUNCTION = 169 + +const TK_ALL = 136 + +const TK_ALTER = 163 + +const TK_ALWAYS = 97 + +const TK_ANALYZE = 30 + +const TK_AND = 44 + +const TK_ANY = 102 + +const TK_AS = 24 + +const TK_ASC = 31 + +const TK_ASTERISK = 180 + +const TK_ATTACH = 32 + +const TK_AUTOINCR = 127 + +const TK_BEFORE = 33 + +const TK_BEGIN = 5 + +const TK_BETWEEN = 49 + +const TK_BITAND = 103 + +const TK_BITNOT = 115 + +const TK_BITOR = 104 + +const TK_BLOB = 155 + +const TK_BY = 34 + +const TK_CASCADE = 35 + +const TK_CASE = 158 + +const TK_CAST = 36 + +const TK_CHECK = 125 + +const TK_COLLATE = 114 + +const TK_COLUMN = 168 + +const TK_COLUMNKW = 61 + +const TK_COMMA = 25 + +const TK_COMMENT = 185 + +const TK_COMMIT = 10 + +const TK_CONCAT = 112 + +const TK_CONFLICT = 37 + +const TK_CONSTRAINT = 120 + +const TK_CREATE = 17 + +const TK_CTIME_KW = 101 + +const TK_CURRENT = 86 + +const TK_DATABASE = 38 + +const TK_DEFAULT = 121 + +const TK_DEFERRABLE = 132 + +const TK_DEFERRED = 7 + +const TK_DELETE = 129 + +const TK_DESC = 39 + +const TK_DETACH = 40 + +const TK_DISTINCT = 141 + +const TK_DO = 62 + +const TK_DOT = 142 + +const TK_DROP = 134 + +const TK_EACH = 41 + +const TK_ELSE = 161 + +const TK_END = 11 + +const TK_EQ = 54 + +const TK_ERROR = 182 + +const TK_ESCAPE = 59 + +const TK_EXCEPT = 137 + +const TK_EXCLUDE = 92 + +const TK_EXCLUSIVE = 9 + +const TK_EXISTS = 20 + +const TK_EXPLAIN = 2 + +const TK_FAIL = 42 + +const TK_FILTER = 167 + +const TK_FIRST = 84 + +const TK_FLOAT = 154 + +const TK_FOLLOWING = 87 + +const TK_FOR = 63 + +const TK_FOREIGN = 133 + +const TK_FROM = 143 + +const TK_FUNCTION = 172 + +const TK_GE = 58 + +const TK_GENERATED = 96 + +const TK_GROUP = 147 + +const TK_GROUPS = 93 + +const TK_GT = 55 + +const TK_HAVING = 148 + +const TK_ID = 60 + +const TK_IF = 18 + +const TK_IF_NULL_ROW = 179 + +const TK_IGNORE = 64 + +const TK_ILLEGAL = 186 + +const TK_IMMEDIATE = 8 + +const TK_IN = 50 + +const TK_INDEX = 162 + +const TK_INDEXED = 117 + +const TK_INITIALLY = 65 + +const TK_INSERT = 128 + +const TK_INSTEAD = 66 + +const TK_INTEGER = 156 + +const TK_INTERSECT = 138 + +const TK_INTO = 152 + +const TK_IS = 45 + +const TK_ISNOT = 46 + +const TK_ISNULL = 51 + +const TK_JOIN = 144 + +const TK_JOIN_KW = 119 + +const TK_KEY = 68 + +const TK_LAST = 85 + +const TK_LE = 56 + +const TK_LIKE_KW = 48 + +const TK_LIMIT = 149 + +const TK_LP = 22 + +const TK_LSHIFT = 105 + +const TK_LT = 57 + +const TK_MATCH = 47 + +const TK_MATERIALIZED = 98 + +const TK_MINUS = 108 + +const TK_NE = 53 + +const TK_NO = 67 + +const TK_NOT = 19 + +const TK_NOTHING = 153 + +const TK_NOTNULL = 52 + +const TK_NULL = 122 + +const TK_NULLS = 83 + +const TK_OF = 69 + +const TK_OFFSET = 70 + +const TK_ON = 116 + +const TK_OR = 43 + +const TK_ORDER = 146 + +const TK_OTHERS = 94 + +const TK_OVER = 166 + +const TK_PARTITION = 88 + +const TK_PLAN = 4 + +const TK_PLUS = 107 + +const TK_PRAGMA = 71 + +const TK_PRECEDING = 89 + +const TK_PRIMARY = 123 + +const TK_PTR = 113 + +const TK_QNUMBER = 183 + +const TK_QUERY = 3 + +const TK_RAISE = 72 + +const TK_RANGE = 90 + +const TK_RECURSIVE = 73 + +const TK_REFERENCES = 126 + +const TK_REGISTER = 176 + +const TK_REINDEX = 99 + +const TK_RELEASE = 14 + +const TK_REM = 111 + +const TK_RENAME = 100 + +const TK_REPLACE = 74 + +const TK_RESTRICT = 75 + +const TK_RETURNING = 151 + +const TK_ROLLBACK = 12 + +const TK_ROW = 76 + +const TK_ROWS = 77 + +const TK_RP = 23 + +const TK_RSHIFT = 106 + +const TK_SAVEPOINT = 13 + +const TK_SELECT = 139 + +const TK_SELECT_COLUMN = 178 + +const TK_SEMI = 1 + +const TK_SET = 131 + +const TK_SLASH = 110 + +const TK_SPACE = 184 + +const TK_SPAN = 181 + +const TK_STAR = 109 + +const TK_STRING = 118 + +const TK_TABLE = 16 + +const TK_TEMP = 21 + +const TK_THEN = 160 + +const TK_TIES = 95 + +const TK_TO = 15 + +const TK_TRANSACTION = 6 + +const TK_TRIGGER = 78 + +const TK_TRUEFALSE = 171 + +const TK_TRUTH = 175 + +const TK_UMINUS = 174 + +const TK_UNBOUNDED = 91 + +const TK_UNION = 135 + +const TK_UNIQUE = 124 + +const TK_UPDATE = 130 + +const TK_UPLUS = 173 + +const TK_USING = 145 + +const TK_VACUUM = 79 + +const TK_VALUES = 140 + +const TK_VARIABLE = 157 + +const TK_VECTOR = 177 + +const TK_VIEW = 80 + +const TK_VIRTUAL = 81 + +const TK_WHEN = 159 + +const TK_WHERE = 150 + +const TK_WINDOW = 165 + +const TK_WITH = 82 + +const TK_WITHOUT = 26 + +type TKeyInfo = struct { + FnRef Tu32 + Fenc Tu8 + FnKeyField Tu16 + FnAllField Tu16 + Fdb uintptr + FaSortFlags uintptr +} + +/* +** Context object for last_value() window function. + */ +type TLastValueCtx = struct { + FpVal uintptr + FnVal int32 +} + +// C documentation +// +// /* +// ** Estimated quantities used for query planning are stored as 16-bit +// ** logarithms. For quantity X, the value stored is 10*log2(X). This +// ** gives a possible range of values of approximately 1.0e986 to 1e-986. +// ** But the allowed values are "grainy". Not every value is representable. +// ** For example, quantities 16 and 17 are both represented by a LogEst +// ** of 40. However, since LogEst quantities are suppose to be estimates, +// ** not exact values, this imprecision is not a problem. +// ** +// ** "LogEst" is short for "Logarithmic Estimate". +// ** +// ** Examples: +// ** 1 -> 0 20 -> 43 10000 -> 132 +// ** 2 -> 10 25 -> 46 25000 -> 146 +// ** 3 -> 16 100 -> 66 1000000 -> 199 +// ** 4 -> 20 1000 -> 99 1048576 -> 200 +// ** 10 -> 33 1024 -> 100 4294967296 -> 320 +// ** +// ** The LogEst can be negative to indicate fractional values. +// ** Examples: +// ** +// ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40 +// */ +type TLogEst = int16 + +type TLookaside = struct { + FbDisable Tu32 + Fsz Tu16 + FszTrue Tu16 + FbMalloced Tu8 + FnSlot Tu32 + FanStat [3]Tu32 + FpInit uintptr + FpFree uintptr + FpSmallInit uintptr + FpSmallFree uintptr + FpMiddle uintptr + FpStart uintptr + FpEnd uintptr + FpTrueEnd uintptr +} + +type TLookasideSlot = struct { + FpNext uintptr +} + +// C documentation +// +// /* +// ** File-scope variables for holding the memdb files that are accessible +// ** to multiple database connections in separate threads. +// ** +// ** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object. +// */ +type TMemFS = struct { + FnMemStore int32 + FapMemStore uintptr +} + +type TMemFile = struct { + Fbase Tsqlite3_file + FpStore uintptr + FeLock int32 +} + +// C documentation +// +// /* Forward declarations */ +type TMemPage = struct { + FisInit Tu8 + FintKey Tu8 + FintKeyLeaf Tu8 + Fpgno TPgno + Fleaf Tu8 + FhdrOffset Tu8 + FchildPtrSize Tu8 + Fmax1bytePayload Tu8 + FnOverflow Tu8 + FmaxLocal Tu16 + FminLocal Tu16 + FcellOffset Tu16 + FnFree int32 + FnCell Tu16 + FmaskPage Tu16 + FaiOvfl [4]Tu16 + FapOvfl [4]uintptr + FpBt uintptr + FaData uintptr + FaDataEnd uintptr + FaCellIdx uintptr + FaDataOfst uintptr + FpDbPage uintptr + FxCellSize uintptr + FxParseCell uintptr +} + +// C documentation +// +// /* +// ** Forward declaration of objects used by this utility +// */ +type TMemVfs = struct { + FiVersion int32 + FszOsFile int32 + FmxPathname int32 + FpNext uintptr + FzName uintptr + FpAppData uintptr + FxOpen uintptr + FxDelete uintptr + FxAccess uintptr + FxFullPathname uintptr + FxDlOpen uintptr + FxDlError uintptr + FxDlSym uintptr + FxDlClose uintptr + FxRandomness uintptr + FxSleep uintptr + FxCurrentTime uintptr + FxGetLastError uintptr + FxCurrentTimeInt64 uintptr + FxSetSystemCall uintptr + FxGetSystemCall uintptr + FxNextSystemCall uintptr +} + +// C documentation +// +// /* +// ** Private objects used by the sorter +// */ +type TMergeEngine = struct { + FnTree int32 + FpTask uintptr + FaTree uintptr + FaReadr uintptr +} + +type TModule = struct { + FpModule uintptr + FzName uintptr + FnRefModule int32 + FpAux uintptr + FxDestroy uintptr + FpEpoTab uintptr +} + +type TNameContext = struct { + FpParse uintptr + FpSrcList uintptr + FuNC struct { + FpAggInfo [0]uintptr + FpUpsert [0]uintptr + FiBaseReg [0]int32 + FpEList uintptr + } + FpNext uintptr + FnRef int32 + FnNcErr int32 + FncFlags int32 + FnNestedSelect Tu32 + FpWinSelect uintptr +} + +const TOKEN = 0 + +type TOnOrUsing = struct { + FpOn uintptr + FpUsing uintptr +} + +// C documentation +// +// /* +// ** SQL is translated into a sequence of instructions to be +// ** executed by a virtual machine. Each instruction is an instance +// ** of the following structure. +// */ +type TOp = struct { + Fopcode Tu8 + Fp4type int8 + Fp5 Tu16 + Fp1 int32 + Fp2 int32 + Fp3 int32 + Fp4 Tp4union +} + +type TPCache1 = struct { + FpGroup uintptr + FpnPurgeable uintptr + FszPage int32 + FszExtra int32 + FszAlloc int32 + FbPurgeable int32 + FnMin uint32 + FnMax uint32 + Fn90pct uint32 + FiMaxKey uint32 + FnPurgeableDummy uint32 + FnRecyclable uint32 + FnPage uint32 + FnHash uint32 + FapHash uintptr + FpFree uintptr + FpBulk uintptr +} + +// C documentation +// +// /* +// ** Global data used by this cache. +// */ +type TPCacheGlobal = struct { + Fgrp TPGroup + FisInit int32 + FseparateCache int32 + FnInitPage int32 + FszSlot int32 + FnSlot int32 + FnReserve int32 + FpStart uintptr + FpEnd uintptr + Fmutex uintptr + FpFree uintptr + FnFreeSlot int32 + FbUnderPressure int32 +} + +type TPGroup = struct { + Fmutex uintptr + FnMaxPage uint32 + FnMinPage uint32 + FmxPinned uint32 + FnPurgeable uint32 + Flru TPgHdr1 +} + +type TParseCleanup = struct { + FpNext uintptr + FpPtr uintptr + FxCleanup uintptr +} + +type TPgFreeslot = struct { + FpNext uintptr +} + +// C documentation +// +// /* +// ** Handle type for pages. +// */ +type TPgHdr = TDbPage + +type TPgHdr1 = struct { + Fpage Tsqlite3_pcache_page + FiKey uint32 + FisBulkLocal Tu16 + FisAnchor Tu16 + FpNext uintptr + FpCache uintptr + FpLruNext uintptr + FpLruPrev uintptr +} + +// C documentation +// +// /* +// ** The type used to represent a page number. The first page in a file +// ** is called page 1. 0 is used to represent "not a page". +// */ +type TPgno = uint32 + +type TPorterContext = struct { + FpCtx uintptr + FxToken uintptr + FaBuf uintptr +} + +type TPorterRule = struct { + FzSuffix uintptr + FnSuffix int32 + FxCond uintptr + FzOutput uintptr + FnOutput int32 +} + +type TPoslistCallbackCtx = struct { + FpBuf uintptr + FpColset uintptr + FeState int32 +} + +type TPoslistOffsetsCtx = struct { + FpBuf uintptr + FpColset uintptr + FiRead int32 + FiWrite int32 +} + +// C documentation +// +// /***************************************************************************** +// ** Implementation of an eponymous virtual table that runs a pragma. +// ** +// */ +type TPragmaVtab = struct { + Fbase Tsqlite3_vtab + Fdb uintptr + FpName uintptr + FnHidden Tu8 + FiHidden Tu8 +} + +type TPrintfArguments = struct { + FnArg int32 + FnUsed int32 + FapArg uintptr +} + +const TRANS_NONE = 0 + +const TRANS_READ = 1 + +const TRANS_WRITE = 2 + +const TREETRACE_ENABLED = 0 + +const TRIGGER_AFTER = 2 + +const TRIGGER_BEFORE = 1 + +type TRbuFrame = struct { + FiDbPage Tu32 + FiWalFrame Tu32 +} + +type TRbuObjIter = struct { + FpTblIter uintptr + FpIdxIter uintptr + FnTblCol int32 + FazTblCol uintptr + FazTblType uintptr + FaiSrcOrder uintptr + FabTblPk uintptr + FabNotNull uintptr + FabIndexed uintptr + FeType int32 + FbCleanup int32 + FzTbl uintptr + FzDataTbl uintptr + FzIdx uintptr + FiTnum int32 + FiPkTnum int32 + FbUnique int32 + FnIndex int32 + FnCol int32 + FpSelect uintptr + FpInsert uintptr + FpDelete uintptr + FpTmpInsert uintptr + FnIdxCol int32 + FaIdxCol uintptr + FzIdxSql uintptr + FpRbuUpdate uintptr +} + +type TRbuSpan = struct { + FzSpan uintptr + FnSpan int32 +} + +type TRbuUpdateStmt = struct { + FzMask uintptr + FpUpdate uintptr + FpNext uintptr +} + +type TRecordCompare = uintptr + +// C documentation +// +// /* +// ** The context of an ALTER TABLE RENAME COLUMN operation that gets passed +// ** down into the Walker. +// */ +type TRenameCtx = struct { + FpList uintptr + FnList int32 + FiCol int32 + FpTab uintptr + FzOld uintptr +} + +type TRenameToken = struct { + Fp uintptr + Ft TToken + FpNext uintptr +} + +// C documentation +// +// /* +// ** An instance of this object holds information (beyond pParse and pSelect) +// ** needed to load the next result row that is to be added to the sorter. +// */ +type TRowLoadInfo = struct { + FregResult int32 + FecelFlags Tu8 +} + +type TRowSet = struct { + FpChunk uintptr + Fdb uintptr + FpEntry uintptr + FpLast uintptr + FpFresh uintptr + FpForest uintptr + FnFresh Tu16 + FrsFlags Tu16 + FiBatch int32 +} + +// C documentation +// +// /* +// ** Context object passed between the various routines that make up the +// ** implementation of integrity-check function rtreecheck(). +// */ +type TRtreeCheck = struct { + Fdb uintptr + FzDb uintptr + FzTab uintptr + FbInt int32 + FnDim int32 + FpGetNode uintptr + FaCheckMapping [2]uintptr + FnLeaf int32 + FnNonLeaf int32 + Frc int32 + FzReport uintptr + FnErr int32 +} + +type TRtreeCoord = struct { + Fi [0]int32 + Fu [0]Tu32 + Ff TRtreeValue +} + +// C documentation +// +// /* +// ** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will +// ** only deal with integer coordinates. No floating point operations +// ** will be done. +// */ +type TRtreeDValue = float64 + +type TRtreeGeomCallback = struct { + FxGeom uintptr + FxQueryFunc uintptr + FxDestructor uintptr + FpContext uintptr +} + +type TRtreeValue = float32 + +// C documentation +// +// /* The ScanStatus object holds a single value for the +// ** sqlite3_stmt_scanstatus() interface. +// ** +// ** aAddrRange[]: +// ** This array is used by ScanStatus elements associated with EQP +// ** notes that make an SQLITE_SCANSTAT_NCYCLE value available. It is +// ** an array of up to 3 ranges of VM addresses for which the Vdbe.anCycle[] +// ** values should be summed to calculate the NCYCLE value. Each pair of +// ** integer addresses is a start and end address (both inclusive) for a range +// ** instructions. A start value of 0 indicates an empty range. +// */ +type TScanStatus = struct { + FaddrExplain int32 + FaAddrRange [6]int32 + FaddrLoop int32 + FaddrVisit int32 + FiSelectID int32 + FnEst TLogEst + FzName uintptr +} + +type TSchema = struct { + Fschema_cookie int32 + FiGeneration int32 + FtblHash THash + FidxHash THash + FtrigHash THash + FfkeyHash THash + FpSeqTab uintptr + Ffile_format Tu8 + Fenc Tu8 + FschemaFlags Tu16 + Fcache_size int32 +} + +type TSelect = struct { + Fop Tu8 + FnSelectRow TLogEst + FselFlags Tu32 + FiLimit int32 + FiOffset int32 + FselId Tu32 + FpEList uintptr + FpSrc uintptr + FpWhere uintptr + FpGroupBy uintptr + FpHaving uintptr + FpOrderBy uintptr + FpPrior uintptr + FpNext uintptr + FpLimit uintptr + FpWith uintptr + FpWin uintptr + FpWinDefn uintptr +} + +type TSelectDest = struct { + FeDest Tu8 + FiSDParm int32 + FiSDParm2 int32 + FiSdst int32 + FnSdst int32 + FzAffSdst uintptr + FpOrderBy uintptr +} + +type TSessionApplyCtx = struct { + Fdb uintptr + FpDelete uintptr + FpInsert uintptr + FpSelect uintptr + FnCol int32 + FazCol uintptr + FabPK uintptr + FaUpdateMask uintptr + FpUp uintptr + FbStat1 int32 + FbDeferConstraints int32 + FbInvertConstraints int32 + Fconstraints TSessionBuffer + Frebase TSessionBuffer + FbRebaseStarted Tu8 + FbRebase Tu8 + FbIgnoreNoop Tu8 + FbNoUpdateLoop Tu8 + FbRowid int32 + FzErr uintptr +} + +type TSessionBuffer = struct { + FaBuf uintptr + FnBuf int32 + FnAlloc int32 +} + +type TSessionChange = struct { + Fop Tu8 + FbIndirect Tu8 + FnRecordField Tu16 + FnMaxSize int32 + FnRecord int32 + FaRecord uintptr + FpNext uintptr +} + +type TSessionDiffCtx = struct { + FpStmt uintptr + FbRowid int32 + FnOldOff int32 +} + +type TSessionHook = struct { + FpCtx uintptr + FxOld uintptr + FxNew uintptr + FxCount uintptr + FxDepth uintptr +} + +type TSessionInput = struct { + FbNoDiscard int32 + FiCurrent int32 + FiNext int32 + FaData uintptr + FnData int32 + Fbuf TSessionBuffer + FxInput uintptr + FpIn uintptr + FbEof int32 +} + +// C documentation +// +// /* +// ** Versions of the four methods in object SessionHook for use with the +// ** sqlite_stat1 table. The purpose of this is to substitute a zero-length +// ** blob each time a NULL value is read from the "idx" column of the +// ** sqlite_stat1 table. +// */ +type TSessionStat1Ctx = struct { + Fhook TSessionHook + FpSession uintptr +} + +type TSessionTable = struct { + FpNext uintptr + FzName uintptr + FnCol int32 + FnTotalCol int32 + FbStat1 int32 + FbRowid int32 + FazCol uintptr + FazDflt uintptr + FaiIdx uintptr + FabPK uintptr + FnEntry int32 + FnChange int32 + FapChange uintptr + FpDfltStmt uintptr +} + +type TSessionUpdate = struct { + FpStmt uintptr + FaMask uintptr + FpNext uintptr +} + +// C documentation +// +// /* +// ** An instance of the following object is used to record information about +// ** the ORDER BY (or GROUP BY) clause of query is being coded. +// ** +// ** The aDefer[] array is used by the sorter-references optimization. For +// ** example, assuming there is no index that can be used for the ORDER BY, +// ** for the query: +// ** +// ** SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10; +// ** +// ** it may be more efficient to add just the "a" values to the sorter, and +// ** retrieve the associated "bigblob" values directly from table t1 as the +// ** 10 smallest "a" values are extracted from the sorter. +// ** +// ** When the sorter-reference optimization is used, there is one entry in the +// ** aDefer[] array for each database table that may be read as values are +// ** extracted from the sorter. +// */ +type TSortCtx = struct { + FpOrderBy uintptr + FnOBSat int32 + FiECursor int32 + FregReturn int32 + FlabelBkOut int32 + FaddrSortIndex int32 + FlabelDone int32 + FlabelOBLopt int32 + FsortFlags Tu8 + FpDeferredRowLoad uintptr +} + +// C documentation +// +// /* +// ** This object represents a single thread of control in a sort operation. +// ** Exactly VdbeSorter.nTask instances of this object are allocated +// ** as part of each VdbeSorter object. Instances are never allocated any +// ** other way. VdbeSorter.nTask is set to the number of worker threads allowed +// ** (see SQLITE_CONFIG_WORKER_THREADS) plus one (the main thread). Thus for +// ** single-threaded operation, there is exactly one instance of this object +// ** and for multi-threaded operation there are two or more instances. +// ** +// ** Essentially, this structure contains all those fields of the VdbeSorter +// ** structure for which each thread requires a separate instance. For example, +// ** each thread requeries its own UnpackedRecord object to unpack records in +// ** as part of comparison operations. +// ** +// ** Before a background thread is launched, variable bDone is set to 0. Then, +// ** right before it exits, the thread itself sets bDone to 1. This is used for +// ** two purposes: +// ** +// ** 1. When flushing the contents of memory to a level-0 PMA on disk, to +// ** attempt to select a SortSubtask for which there is not already an +// ** active background thread (since doing so causes the main thread +// ** to block until it finishes). +// ** +// ** 2. If SQLITE_DEBUG_SORTER_THREADS is defined, to determine if a call +// ** to sqlite3ThreadJoin() is likely to block. Cases that are likely to +// ** block provoke debugging output. +// ** +// ** In both cases, the effects of the main thread seeing (bDone==0) even +// ** after the thread has finished are not dire. So we don't worry about +// ** memory barriers and such here. +// */ +type TSorterCompare = uintptr + +/* Incrementally write one PMA */ +type TSorterRecord = struct { + FnVal int32 + Fu struct { + FiNext [0]int32 + FpNext uintptr + } +} + +type TStatCell = struct { + FnLocal int32 + FiChildPg Tu32 + FnOvfl int32 + FaOvfl uintptr + FnLastOvfl int32 + FiOvfl int32 +} + +type TStatPage = struct { + FiPgno Tu32 + FaPg uintptr + FiCell int32 + FzPath uintptr + Fflags Tu8 + FnCell int32 + FnUnused int32 + FaCell uintptr + FiRightChildPg Tu32 + FnMxPayload int32 +} + +// C documentation +// +// /* Forward reference to data structured used in this module */ +type TStatTable = struct { + Fbase Tsqlite3_vtab + Fdb uintptr + FiDb int32 +} + +type TStrAccum = struct { + Fdb uintptr + FzText uintptr + FnAlloc Tu32 + FmxAlloc Tu32 + FnChar Tu32 + FaccError Tu8 + FprintfFlags Tu8 +} + +type TSubProgram = struct { + FaOp uintptr + FnOp int32 + FnMem int32 + FnCsr int32 + FaOnce uintptr + Ftoken uintptr + FpNext uintptr +} + +type TSubquery = struct { + FpSelect uintptr + FaddrFillSub int32 + FregReturn int32 + FregResult int32 +} + +type TSubrtnSig = struct { + FselId int32 + FbComplete Tu8 + FzAff uintptr + FiTable int32 + FiAddr int32 + FregReturn int32 +} + +// C documentation +// +// /* An instance of the SubstContext object describes an substitution edit +// ** to be performed on a parse tree. +// ** +// ** All references to columns in table iTable are to be replaced by corresponding +// ** expressions in pEList. +// ** +// ** ## About "isOuterJoin": +// ** +// ** The isOuterJoin column indicates that the replacement will occur into a +// ** position in the parent that is NULL-able due to an OUTER JOIN. Either the +// ** target slot in the parent is the right operand of a LEFT JOIN, or one of +// ** the left operands of a RIGHT JOIN. In either case, we need to potentially +// ** bypass the substituted expression with OP_IfNullRow. +// ** +// ** Suppose the original expression is an integer constant. Even though the table +// ** has the nullRow flag set, because the expression is an integer constant, +// ** it will not be NULLed out. So instead, we insert an OP_IfNullRow opcode +// ** that checks to see if the nullRow flag is set on the table. If the nullRow +// ** flag is set, then the value in the register is set to NULL and the original +// ** expression is bypassed. If the nullRow flag is not set, then the original +// ** expression runs to populate the register. +// ** +// ** Example where this is needed: +// ** +// ** CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT); +// ** CREATE TABLE t2(x INT UNIQUE); +// ** +// ** SELECT a,b,m,x FROM t1 LEFT JOIN (SELECT 59 AS m,x FROM t2) ON b=x; +// ** +// ** When the subquery on the right side of the LEFT JOIN is flattened, we +// ** have to add OP_IfNullRow in front of the OP_Integer that implements the +// ** "m" value of the subquery so that a NULL will be loaded instead of 59 +// ** when processing a non-matched row of the left. +// */ +type TSubstContext = struct { + FpParse uintptr + FiTable int32 + FiNewTable int32 + FisOuterJoin int32 + FnSelDepth int32 + FpEList uintptr + FpCList uintptr +} + +// C documentation +// +// /* +// ** This structure is used to pass data from sqlite3_get_table() through +// ** to the callback function is uses to build the result. +// */ +type TTabResult = struct { + FazResult uintptr + FzErrMsg uintptr + FnAlloc Tu32 + FnRow Tu32 + FnColumn Tu32 + FnData Tu32 + Frc int32 +} + +/* Internal alias for sqlite3_str */ +type TTable = struct { + FzName uintptr + FaCol uintptr + FpIndex uintptr + FzColAff uintptr + FpCheck uintptr + Ftnum TPgno + FnTabRef Tu32 + FtabFlags Tu32 + FiPKey Ti16 + FnCol Ti16 + FnNVCol Ti16 + FnRowLogEst TLogEst + FszTabRow TLogEst + FkeyConf Tu8 + FeTabType Tu8 + Fu struct { + Fview [0]struct { + FpSelect uintptr + } + Fvtab [0]struct { + FnArg int32 + FazArg uintptr + Fp uintptr + } + Ftab struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + } + } + FpTrigger uintptr + FpSchema uintptr + FaHx [16]Tu8 +} + +type TTableLock = struct { + FiDb int32 + FiTab TPgno + FisWriteLock Tu8 + FzLockName uintptr +} + +type TToken = struct { + Fz uintptr + Fn uint32 +} + +type TTokenCtx = struct { + FpPhrase uintptr + FpConfig uintptr + Frc int32 +} + +// C documentation +// +// /* +// ** fts5VisitEntries() context object used by fts5SetupPrefixIterTokendata() +// ** to pass data to prefixIterSetupTokendataCb(). +// */ +type TTokendataSetupCtx = struct { + FpT uintptr + FiTermOff int32 + FnTermByte int32 +} + +/* +** An instance of the following structure describes the event of a +** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, +** TK_DELETE, or TK_INSTEAD. If the event is of the form +** +** UPDATE ON (a,b,c) +** +** Then the "b" IdList records the list "a,b,c". + */ +type TTrigEvent = struct { + Fa int32 + Fb uintptr +} + +type TTrigger = struct { + FzName uintptr + Ftable uintptr + Fop Tu8 + Ftr_tm Tu8 + FbReturning Tu8 + FpWhen uintptr + FpColumns uintptr + FpSchema uintptr + FpTabSchema uintptr + Fstep_list uintptr + FpNext uintptr +} + +type TTriggerPrg = struct { + FpTrigger uintptr + FpNext uintptr + FpProgram uintptr + Forconf int32 + FaColmask [2]Tu32 +} + +type TTriggerStep = struct { + Fop Tu8 + Forconf Tu8 + FpTrig uintptr + FpSelect uintptr + FpSrc uintptr + FpWhere uintptr + FpExprList uintptr + FpIdList uintptr + FpUpsert uintptr + FzSpan uintptr + FpNext uintptr + FpLast uintptr +} + +// C documentation +// +// /************************************************************************** +// ** Start of trigram implementation. +// */ +type TTrigramTokenizer = struct { + FbFold int32 + FiFoldParam int32 +} + +type TUnicode61Tokenizer = struct { + FaTokenChar [128]uint8 + FaFold uintptr + FnFold int32 + FeRemoveDiacritic int32 + FnException int32 + FaiException uintptr + FaCategory [32]uint8 +} + +type TUpsert = struct { + FpUpsertTarget uintptr + FpUpsertTargetWhere uintptr + FpUpsertSet uintptr + FpUpsertWhere uintptr + FpNextUpsert uintptr + FisDoUpdate Tu8 + FisDup Tu8 + FpToFree uintptr + FpUpsertIdx uintptr + FpUpsertSrc uintptr + FregData int32 + FiDataCur int32 + FiIdxCur int32 +} + +// C documentation +// +// /* A VList object records a mapping between parameters/variables/wildcards +// ** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer +// ** variable number associated with that parameter. See the format description +// ** on the sqlite3VListAdd() routine for more information. A VList is really +// ** just an array of integers. +// */ +type TVList = int32 + +type TVTable = struct { + Fdb uintptr + FpMod uintptr + FpVtab uintptr + FnRef int32 + FbConstraint Tu8 + FbAllSchemas Tu8 + FeVtabRisk Tu8 + FiSavepoint int32 + FpNext uintptr +} + +// C documentation +// +// /* +// ** An instance of this object is used to pass an vector of values into +// ** OP_VFilter, the xFilter method of a virtual table. The vector is the +// ** set of values on the right-hand side of an IN constraint. +// ** +// ** The value as passed into xFilter is an sqlite3_value with a "pointer" +// ** type, such as is generated by sqlite3_result_pointer() and read by +// ** sqlite3_value_pointer. Such values have MEM_Term|MEM_Subtype|MEM_Null +// ** and a subtype of 'p'. The sqlite3_vtab_in_first() and _next() interfaces +// ** know how to use this object to step through all the values in the +// ** right operand of the IN constraint. +// */ +type TValueList = struct { + FpCsr uintptr + FpOut uintptr +} + +/* +** Context object passed by sqlite3Stat4ProbeSetValue() through to +** valueNew(). See comments above valueNew() for details. + */ +type TValueNewStat4Ctx = struct { + FpParse uintptr + FpIdx uintptr + FppRec uintptr + FiVal int32 +} + +/* +** A single instruction of the virtual machine has an opcode +** and as many as three operands. The instruction is recorded +** as an instance of the following structure: + */ +type TVdbeOp = struct { + Fopcode Tu8 + Fp4type int8 + Fp5 Tu16 + Fp1 int32 + Fp2 int32 + Fp3 int32 + Fp4 Tp4union +} + +/* +** A smaller version of VdbeOp used for the VdbeAddOpList() function because +** it takes up less space. + */ +type TVdbeOpList = struct { + Fopcode Tu8 + Fp1 int8 + Fp2 int8 + Fp3 int8 +} + +type TVtabCtx = struct { + FpVTable uintptr + FpTab uintptr + FpPrior uintptr + FbDeclared int32 +} + +type TWalCkptInfo = struct { + FnBackfill Tu32 + FaReadMark [5]Tu32 + FaLock [8]Tu8 + FnBackfillAttempted Tu32 + FnotUsed0 Tu32 +} + +// C documentation +// +// /* +// ** An instance of the WalHashLoc object is used to describe the location +// ** of a page hash table in the wal-index. This becomes the return value +// ** from walHashGet(). +// */ +type TWalHashLoc = struct { + FaHash uintptr + FaPgno uintptr + FiZero Tu32 +} + +// C documentation +// +// /* Object declarations */ +type TWalIndexHdr = struct { + FiVersion Tu32 + Funused Tu32 + FiChange Tu32 + FisInit Tu8 + FbigEndCksum Tu8 + FszPage Tu16 + FmxFrame Tu32 + FnPage Tu32 + FaFrameCksum [2]Tu32 + FaSalt [2]Tu32 + FaCksum [2]Tu32 +} + +type TWalSegment = struct { + FiNext int32 + FaIndex uintptr + FaPgno uintptr + FnEntry int32 + FiZero int32 +} + +type TWalker = struct { + FpParse uintptr + FxExprCallback uintptr + FxSelectCallback uintptr + FxSelectCallback2 uintptr + FwalkerDepth int32 + FeCode Tu16 + FmWFlags Tu16 + Fu struct { + Fn [0]int32 + FiCur [0]int32 + Fsz [0]int32 + FpSrcList [0]uintptr + FpCCurHint [0]uintptr + FpRefSrcList [0]uintptr + FaiCol [0]uintptr + FpIdxCover [0]uintptr + FpGroupBy [0]uintptr + FpSelect [0]uintptr + FpRewrite [0]uintptr + FpConst [0]uintptr + FpRename [0]uintptr + FpTab [0]uintptr + FpCovIdxCk [0]uintptr + FpSrcItem [0]uintptr + FpFix [0]uintptr + FaMem [0]uintptr + FpCheckOnCtx [0]uintptr + FpNC uintptr + } +} + +// C documentation +// +// /* +// ** A structure to keep track of all of the column values that are fixed to +// ** a known value due to WHERE clause constraints of the form COLUMN=VALUE. +// */ +type TWhereConst = struct { + FpParse uintptr + FpOomFault uintptr + FnConst int32 + FnChng int32 + FbHasAffBlob int32 + FmExcludeOn Tu32 + FapExpr uintptr +} + +type TWhereLoopBuilder = struct { + FpWInfo uintptr + FpWC uintptr + FpNew uintptr + FpOrSet uintptr + FpRec uintptr + FnRecValid int32 + FbldFlags1 uint8 + FbldFlags2 uint8 + FiPlanLimit uint32 +} + +type TWhereMaskSet = struct { + FbVarSelect int32 + Fn int32 + Fix [64]int32 +} + +type TWhereRightJoin = struct { + FiMatch int32 + FregBloom int32 + FregReturn int32 + FaddrSubrtn int32 + FendSubrtn int32 +} + +type TWindow = struct { + FzName uintptr + FzBase uintptr + FpPartition uintptr + FpOrderBy uintptr + FeFrmType Tu8 + FeStart Tu8 + FeEnd Tu8 + FbImplicitFrame Tu8 + FeExclude Tu8 + FpStart uintptr + FpEnd uintptr + FppThis uintptr + FpNextWin uintptr + FpFilter uintptr + FpWFunc uintptr + FiEphCsr int32 + FregAccum int32 + FregResult int32 + FcsrApp int32 + FregApp int32 + FregPart int32 + FpOwner uintptr + FnBufferCol int32 + FiArgCol int32 + FregOne int32 + FregStartRowid int32 + FregEndRowid int32 + FbExprArgs Tu8 +} + +type TWindowCodeArg = struct { + FpParse uintptr + FpMWin uintptr + FpVdbe uintptr + FaddrGosub int32 + FregGosub int32 + FregArg int32 + FeDelete int32 + FregRowid int32 + Fstart TWindowCsrAndReg + Fcurrent TWindowCsrAndReg + Fend TWindowCsrAndReg +} + +type TWindowCsrAndReg = struct { + Fcsr int32 + Freg int32 +} + +// C documentation +// +// /* +// ** Context object passed through sqlite3WalkExprList() to +// ** selectWindowRewriteExprCb() by selectWindowRewriteEList(). +// */ +type TWindowRewrite = struct { + FpWin uintptr + FpSrc uintptr + FpSub uintptr + FpTab uintptr + FpSubSelect uintptr +} + +type TWith = struct { + FnCte int32 + FbView int32 + FpOuter uintptr +} + +type T_ht = struct { + Fcount uint32 + Fchain uintptr +} + +type TabResult = TTabResult + +type Table = TTable + +type TableLock = TTableLock + +// C documentation +// +// /* +// ** Used to pass information from the analyzer reader through to the +// ** callback routine. +// */ +type TanalysisInfo = struct { + Fdb uintptr + FzDatabase uintptr +} + +// C documentation +// +// /* A bitfield type for use inside of structures. Always follow with :N where +// ** N is the number of bits. +// */ +type Tbft = uint32 + +type Tclockid_t = int32 + +/* +** A structure defining how to do GLOB-style comparisons. + */ +type TcompareInfo = struct { + FmatchAll Tu8 + FmatchOne Tu8 + FmatchSet Tu8 + FnoCase Tu8 +} + +type Tdiv_t = struct { + Fquot int32 + Frem int32 +} + +type Tdouble_t = float64 + +// C documentation +// +// /* +// ** An "etByte" is an 8-bit unsigned value. +// */ +type TetByte = uint8 + +// C documentation +// +// /************************************************************************* +// ** FTS5 EXTENSION REGISTRATION API +// */ +type Tfts5_api = struct { + FiVersion int32 + FxCreateTokenizer uintptr + FxFindTokenizer uintptr + FxCreateFunction uintptr + FxCreateTokenizer_v2 uintptr + FxFindTokenizer_v2 uintptr +} + +type Tfts5_extension_function = uintptr + +// C documentation +// +// /* +// ** New code should use the fts5_tokenizer_v2 type to define tokenizer +// ** implementations. The following type is included for legacy applications +// ** that still use it. +// */ +type Tfts5_tokenizer = struct { + FxCreate uintptr + FxDelete uintptr + FxTokenize uintptr +} + +type Tfts5_tokenizer_v2 = struct { + FiVersion int32 + FxCreate uintptr + FxDelete uintptr + FxTokenize uintptr +} + +/* The state of the parser is completely contained in an instance of +** the following structure */ +type Tfts5yyParser = struct { + Ffts5yytos uintptr + FpParse uintptr + Ffts5yystackEnd uintptr + Ffts5yystack uintptr + Ffts5yystk0 [100]Tfts5yyStackEntry +} + +/* The following structure represents a single element of the +** parser's stack. Information stored includes: +** +** + The state number for the parser at this level of the stack. +** +** + The value of the token stored at this level of the stack. +** (In other words, the "major" token.) +** +** + The semantic value stored at this level of the stack. This is +** the information used by the action routines in the grammar. +** It is sometimes called the "minor" token. +** +** After the "shift" half of a SHIFTREDUCE action, the stateno field +** actually contains the reduce action for the second half of the +** SHIFTREDUCE. + */ +type Tfts5yyStackEntry = struct { + Fstateno uint8 + Fmajor uint8 + Fminor Tfts5YYMINORTYPE +} + +// C documentation +// +// /* +// ** Each page of the wal-index mapping contains a hash-table made up of +// ** an array of HASHTABLE_NSLOT elements of the following type. +// */ +type Tht_slot = uint16 + +/* 2-byte unsigned integer */ +type Ti16 = int16 + +// C documentation +// +// /* +// ** Integers of known sizes. These typedefs might change for architectures +// ** where the sizes very. Preprocessor macros are available so that the +// ** types can be conveniently redefined at compile-type. Like this: +// ** +// ** cc '-DUINTPTR_TYPE=long long int' ... +// */ +type Ti64 = int64 + +/* 1-byte unsigned integer */ +type Ti8 = int8 + +type Tint16_t = int16 + +type Tint32_t = int32 + +type Tint64_t = int64 + +type Tint8_t = int8 + +type Tint_fast32_t = int32 + +type Tint_fast64_t = int64 + +type Tint_least16_t = int16 + +type Tint_least32_t = int32 + +type Tint_least64_t = int64 + +type Tint_least8_t = int8 + +type Tintmax_t = int64 + +type Toff_t = int64 + +type Token = TToken + +type TokenCtx = TTokenCtx + +type TokendataSetupCtx = TTokendataSetupCtx + +type Trbu_vfs = struct { + Fbase Tsqlite3_vfs + FpRealVfs uintptr + Fmutex uintptr + FpRbu uintptr + FpMain uintptr + FpMainRbu uintptr +} + +type TrigEvent = TTrigEvent + +type Trigger = TTrigger + +type TriggerPrg = TTriggerPrg + +type TriggerStep = TTriggerStep + +type TrigramTokenizer = TTrigramTokenizer + +type TsColMap = struct { + FiFrom int32 + FzCol uintptr +} + +// C documentation +// +// /* +// ** The following object holds the list of automatically loaded +// ** extensions. +// ** +// ** This list is shared across threads. The SQLITE_MUTEX_STATIC_MAIN +// ** mutex must be held while accessing this list. +// */ +type Tsqlite3AutoExtList = struct { + FnExt Tu32 + FaExt uintptr +} + +type Tsqlite3InitInfo = struct { + FnewTnum TPgno + FiDb Tu8 + Fbusy Tu8 + F__ccgo_align3 [2]byte + F__ccgo8 uint8 + FazInit uintptr +} + +// C documentation +// +// /* All threads share a single random number generator. +// ** This structure is the current state of the generator. +// */ +type Tsqlite3PrngType = struct { + Fs [16]Tu32 + Fout [64]Tu8 + Fn Tu8 +} + +type Tsqlite3StatType = struct { + FnowValue [10]Tsqlite3StatValueType + FmxValue [10]Tsqlite3StatValueType +} + +// C documentation +// +// /* +// ** CAPI3REF: Loadable Extension Thunk +// ** +// ** A pointer to the opaque sqlite3_api_routines structure is passed as +// ** the third parameter to entry points of [loadable extensions]. This +// ** structure must be typedefed in order to work around compiler warnings +// ** on some platforms. +// */ +type Tsqlite3_api_routines = struct { + Faggregate_context uintptr + Faggregate_count uintptr + Fbind_blob uintptr + Fbind_double uintptr + Fbind_int uintptr + Fbind_int64 uintptr + Fbind_null uintptr + Fbind_parameter_count uintptr + Fbind_parameter_index uintptr + Fbind_parameter_name uintptr + Fbind_text uintptr + Fbind_text16 uintptr + Fbind_value uintptr + Fbusy_handler uintptr + Fbusy_timeout uintptr + Fchanges uintptr + Fclose1 uintptr + Fcollation_needed uintptr + Fcollation_needed16 uintptr + Fcolumn_blob uintptr + Fcolumn_bytes uintptr + Fcolumn_bytes16 uintptr + Fcolumn_count uintptr + Fcolumn_database_name uintptr + Fcolumn_database_name16 uintptr + Fcolumn_decltype uintptr + Fcolumn_decltype16 uintptr + Fcolumn_double uintptr + Fcolumn_int uintptr + Fcolumn_int64 uintptr + Fcolumn_name uintptr + Fcolumn_name16 uintptr + Fcolumn_origin_name uintptr + Fcolumn_origin_name16 uintptr + Fcolumn_table_name uintptr + Fcolumn_table_name16 uintptr + Fcolumn_text uintptr + Fcolumn_text16 uintptr + Fcolumn_type uintptr + Fcolumn_value uintptr + Fcommit_hook uintptr + Fcomplete uintptr + Fcomplete16 uintptr + Fcreate_collation uintptr + Fcreate_collation16 uintptr + Fcreate_function uintptr + Fcreate_function16 uintptr + Fcreate_module uintptr + Fdata_count uintptr + Fdb_handle uintptr + Fdeclare_vtab uintptr + Fenable_shared_cache uintptr + Ferrcode uintptr + Ferrmsg uintptr + Ferrmsg16 uintptr + Fexec uintptr + Fexpired uintptr + Ffinalize uintptr + Ffree uintptr + Ffree_table uintptr + Fget_autocommit uintptr + Fget_auxdata uintptr + Fget_table uintptr + Fglobal_recover uintptr + Finterruptx uintptr + Flast_insert_rowid uintptr + Flibversion uintptr + Flibversion_number uintptr + Fmalloc uintptr + Fmprintf uintptr + Fopen uintptr + Fopen16 uintptr + Fprepare uintptr + Fprepare16 uintptr + Fprofile uintptr + Fprogress_handler uintptr + Frealloc uintptr + Freset uintptr + Fresult_blob uintptr + Fresult_double uintptr + Fresult_error uintptr + Fresult_error16 uintptr + Fresult_int uintptr + Fresult_int64 uintptr + Fresult_null uintptr + Fresult_text uintptr + Fresult_text16 uintptr + Fresult_text16be uintptr + Fresult_text16le uintptr + Fresult_value uintptr + Frollback_hook uintptr + Fset_authorizer uintptr + Fset_auxdata uintptr + Fxsnprintf uintptr + Fstep uintptr + Ftable_column_metadata uintptr + Fthread_cleanup uintptr + Ftotal_changes uintptr + Ftrace uintptr + Ftransfer_bindings uintptr + Fupdate_hook uintptr + Fuser_data uintptr + Fvalue_blob uintptr + Fvalue_bytes uintptr + Fvalue_bytes16 uintptr + Fvalue_double uintptr + Fvalue_int uintptr + Fvalue_int64 uintptr + Fvalue_numeric_type uintptr + Fvalue_text uintptr + Fvalue_text16 uintptr + Fvalue_text16be uintptr + Fvalue_text16le uintptr + Fvalue_type uintptr + Fvmprintf uintptr + Foverload_function uintptr + Fprepare_v2 uintptr + Fprepare16_v2 uintptr + Fclear_bindings uintptr + Fcreate_module_v2 uintptr + Fbind_zeroblob uintptr + Fblob_bytes uintptr + Fblob_close uintptr + Fblob_open uintptr + Fblob_read uintptr + Fblob_write uintptr + Fcreate_collation_v2 uintptr + Ffile_control uintptr + Fmemory_highwater uintptr + Fmemory_used uintptr + Fmutex_alloc uintptr + Fmutex_enter uintptr + Fmutex_free uintptr + Fmutex_leave uintptr + Fmutex_try uintptr + Fopen_v2 uintptr + Frelease_memory uintptr + Fresult_error_nomem uintptr + Fresult_error_toobig uintptr + Fsleep uintptr + Fsoft_heap_limit uintptr + Fvfs_find uintptr + Fvfs_register uintptr + Fvfs_unregister uintptr + Fxthreadsafe uintptr + Fresult_zeroblob uintptr + Fresult_error_code uintptr + Ftest_control uintptr + Frandomness uintptr + Fcontext_db_handle uintptr + Fextended_result_codes uintptr + Flimit uintptr + Fnext_stmt uintptr + Fsql uintptr + Fstatus uintptr + Fbackup_finish uintptr + Fbackup_init uintptr + Fbackup_pagecount uintptr + Fbackup_remaining uintptr + Fbackup_step uintptr + Fcompileoption_get uintptr + Fcompileoption_used uintptr + Fcreate_function_v2 uintptr + Fdb_config uintptr + Fdb_mutex uintptr + Fdb_status uintptr + Fextended_errcode uintptr + Flog uintptr + Fsoft_heap_limit64 uintptr + Fsourceid uintptr + Fstmt_status uintptr + Fstrnicmp uintptr + Funlock_notify uintptr + Fwal_autocheckpoint uintptr + Fwal_checkpoint uintptr + Fwal_hook uintptr + Fblob_reopen uintptr + Fvtab_config uintptr + Fvtab_on_conflict uintptr + Fclose_v2 uintptr + Fdb_filename uintptr + Fdb_readonly uintptr + Fdb_release_memory uintptr + Ferrstr uintptr + Fstmt_busy uintptr + Fstmt_readonly uintptr + Fstricmp uintptr + Furi_boolean uintptr + Furi_int64 uintptr + Furi_parameter uintptr + Fxvsnprintf uintptr + Fwal_checkpoint_v2 uintptr + Fauto_extension uintptr + Fbind_blob64 uintptr + Fbind_text64 uintptr + Fcancel_auto_extension uintptr + Fload_extension uintptr + Fmalloc64 uintptr + Fmsize uintptr + Frealloc64 uintptr + Freset_auto_extension uintptr + Fresult_blob64 uintptr + Fresult_text64 uintptr + Fstrglob uintptr + Fvalue_dup uintptr + Fvalue_free uintptr + Fresult_zeroblob64 uintptr + Fbind_zeroblob64 uintptr + Fvalue_subtype uintptr + Fresult_subtype uintptr + Fstatus64 uintptr + Fstrlike uintptr + Fdb_cacheflush uintptr + Fsystem_errno uintptr + Ftrace_v2 uintptr + Fexpanded_sql uintptr + Fset_last_insert_rowid uintptr + Fprepare_v3 uintptr + Fprepare16_v3 uintptr + Fbind_pointer uintptr + Fresult_pointer uintptr + Fvalue_pointer uintptr + Fvtab_nochange uintptr + Fvalue_nochange uintptr + Fvtab_collation uintptr + Fkeyword_count uintptr + Fkeyword_name uintptr + Fkeyword_check uintptr + Fstr_new uintptr + Fstr_finish uintptr + Fstr_appendf uintptr + Fstr_vappendf uintptr + Fstr_append uintptr + Fstr_appendall uintptr + Fstr_appendchar uintptr + Fstr_reset uintptr + Fstr_errcode uintptr + Fstr_length uintptr + Fstr_value uintptr + Fcreate_window_function uintptr + Fnormalized_sql uintptr + Fstmt_isexplain uintptr + Fvalue_frombind uintptr + Fdrop_modules uintptr + Fhard_heap_limit64 uintptr + Furi_key uintptr + Ffilename_database uintptr + Ffilename_journal uintptr + Ffilename_wal uintptr + Fcreate_filename uintptr + Ffree_filename uintptr + Fdatabase_file_object uintptr + Ftxn_state uintptr + Fchanges64 uintptr + Ftotal_changes64 uintptr + Fautovacuum_pages uintptr + Ferror_offset uintptr + Fvtab_rhs_value uintptr + Fvtab_distinct uintptr + Fvtab_in uintptr + Fvtab_in_first uintptr + Fvtab_in_next uintptr + Fdeserialize uintptr + Fserialize uintptr + Fdb_name uintptr + Fvalue_encoding uintptr + Fis_interrupted uintptr + Fstmt_explain uintptr + Fget_clientdata uintptr + Fset_clientdata uintptr + Fsetlk_timeout uintptr + Fset_errmsg uintptr + Fdb_status64 uintptr + Fstr_truncate uintptr + Fstr_free uintptr + Fcarray_bind uintptr + Fcarray_bind_v2 uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: Online Backup Object +// ** +// ** The sqlite3_backup object records state information about an ongoing +// ** online backup operation. ^The sqlite3_backup object is created by +// ** a call to [sqlite3_backup_init()] and is destroyed by a call to +// ** [sqlite3_backup_finish()]. +// ** +// ** See Also: [Using the SQLite Online Backup API] +// */ +type Tsqlite3_backup = struct { + FpDestDb uintptr + FpDest uintptr + FiDestSchema Tu32 + FbDestLocked int32 + FiNext TPgno + FpSrcDb uintptr + FpSrc uintptr + Frc int32 + FnRemaining TPgno + FnPagecount TPgno + FisAttached int32 + FpNext uintptr +} + +// C documentation +// +// /* +// ** The type for a callback function. +// ** This is legacy and deprecated. It is included for historical +// ** compatibility and is not documented. +// */ +type Tsqlite3_callback = uintptr + +// C documentation +// +// /* +// ** CAPI3REF: Changegroup Handle +// ** +// ** A changegroup is an object used to combine two or more +// ** [changesets] or [patchsets] +// */ +type Tsqlite3_changegroup = struct { + Frc int32 + FbPatch int32 + FpList uintptr + Frec TSessionBuffer + Fdb uintptr + FzDb uintptr + Fcd TChangeData +} + +// C documentation +// +// /* +// ** CAPI3REF: Changeset Iterator Handle +// ** +// ** An instance of this object acts as a cursor for iterating +// ** over the elements of a [changeset] or [patchset]. +// */ +type Tsqlite3_changeset_iter = struct { + Fin TSessionInput + Ftblhdr TSessionBuffer + FbPatchset int32 + FbInvert int32 + FbSkipEmpty int32 + Frc int32 + FpConflict uintptr + FzTab uintptr + FnCol int32 + Fop int32 + FbIndirect int32 + FabPK uintptr + FapValue uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: SQL Function Context Object +// ** +// ** The context in which an SQL function executes is stored in an +// ** sqlite3_context object. ^A pointer to an sqlite3_context object +// ** is always the first parameter to [application-defined SQL functions]. +// ** The application-defined SQL function implementation will pass this +// ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], +// ** [sqlite3_aggregate_context()], [sqlite3_user_data()], +// ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], +// ** and/or [sqlite3_set_auxdata()]. +// */ +type Tsqlite3_context = struct { + FpOut uintptr + FpFunc uintptr + FpMem uintptr + FpVdbe uintptr + FiOp int32 + FisError int32 + Fenc Tu8 + FskipFlag Tu8 + Fargc Tu16 +} + +// C documentation +// +// /* +// ** CAPI3REF: Constants Defining Special Destructor Behavior +// ** +// ** These are special values for the destructor that is passed in as the +// ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor +// ** argument is SQLITE_STATIC, it means that the content pointer is constant +// ** and will never change. It does not need to be destroyed. ^The +// ** SQLITE_TRANSIENT value means that the content will likely change in +// ** the near future and that SQLite should make its own private copy of +// ** the content before returning. +// ** +// ** The typedef is necessary to work around problems in certain +// ** C++ compilers. +// */ +type Tsqlite3_destructor_type = uintptr + +// C documentation +// +// /* +// ** CAPI3REF: OS Interface Open File Handle +// ** +// ** An [sqlite3_file] object represents an open file in the +// ** [sqlite3_vfs | OS interface layer]. Individual OS interface +// ** implementations will +// ** want to subclass this object by appending additional fields +// ** for their own use. The pMethods entry is a pointer to an +// ** [sqlite3_io_methods] object that defines methods for performing +// ** I/O operations on the open file. +// */ +type Tsqlite3_file = struct { + FpMethods uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: File Name +// ** +// ** Type [sqlite3_filename] is used by SQLite to pass filenames to the +// ** xOpen method of a [VFS]. It may be cast to (const char*) and treated +// ** as a normal, nul-terminated, UTF-8 buffer containing the filename, but +// ** may also be passed to special APIs such as: +// ** +// **
    +// **
  • sqlite3_filename_database() +// **
  • sqlite3_filename_journal() +// **
  • sqlite3_filename_wal() +// **
  • sqlite3_uri_parameter() +// **
  • sqlite3_uri_boolean() +// **
  • sqlite3_uri_int64() +// **
  • sqlite3_uri_key() +// **
+// */ +type Tsqlite3_filename = uintptr + +type Tsqlite3_index_constraint = struct { + FiColumn int32 + Fop uint8 + Fusable uint8 + FiTermOffset int32 +} + +type Tsqlite3_index_constraint_usage = struct { + FargvIndex int32 + Fomit uint8 +} + +type Tsqlite3_index_orderby = struct { + FiColumn int32 + Fdesc uint8 +} + +type Tsqlite3_int64 = int64 + +// C documentation +// +// /* +// ** CAPI3REF: OS Interface File Virtual Methods Object +// ** +// ** Every file opened by the [sqlite3_vfs.xOpen] method populates an +// ** [sqlite3_file] object (or, more commonly, a subclass of the +// ** [sqlite3_file] object) with a pointer to an instance of this object. +// ** This object defines the methods used to perform various operations +// ** against the open file represented by the [sqlite3_file] object. +// ** +// ** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element +// ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method +// ** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The +// ** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen] +// ** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element +// ** to NULL. +// ** +// ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or +// ** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). +// ** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] +// ** flag may be ORed in to indicate that only the data of the file +// ** and not its inode needs to be synced. +// ** +// ** The integer values to xLock() and xUnlock() are one of +// **
    +// **
  • [SQLITE_LOCK_NONE], +// **
  • [SQLITE_LOCK_SHARED], +// **
  • [SQLITE_LOCK_RESERVED], +// **
  • [SQLITE_LOCK_PENDING], or +// **
  • [SQLITE_LOCK_EXCLUSIVE]. +// **
+// ** xLock() upgrades the database file lock. In other words, xLock() moves the +// ** database file lock in the direction NONE toward EXCLUSIVE. The argument to +// ** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never +// ** SQLITE_LOCK_NONE. If the database file lock is already at or above the +// ** requested lock, then the call to xLock() is a no-op. +// ** xUnlock() downgrades the database file lock to either SHARED or NONE. +// ** If the lock is already at or below the requested lock state, then the call +// ** to xUnlock() is a no-op. +// ** The xCheckReservedLock() method checks whether any database connection, +// ** either in this process or in some other process, is holding a RESERVED, +// ** PENDING, or EXCLUSIVE lock on the file. It returns, via its output +// ** pointer parameter, true if such a lock exists and false otherwise. +// ** +// ** The xFileControl() method is a generic interface that allows custom +// ** VFS implementations to directly control an open file using the +// ** [sqlite3_file_control()] interface. The second "op" argument is an +// ** integer opcode. The third argument is a generic pointer intended to +// ** point to a structure that may contain arguments or space in which to +// ** write return values. Potential uses for xFileControl() might be +// ** functions to enable blocking locks with timeouts, to change the +// ** locking strategy (for example to use dot-file locks), to inquire +// ** about the status of a lock, or to break stale locks. The SQLite +// ** core reserves all opcodes less than 100 for its own use. +// ** A [file control opcodes | list of opcodes] less than 100 is available. +// ** Applications that define a custom xFileControl method should use opcodes +// ** greater than 100 to avoid conflicts. VFS implementations should +// ** return [SQLITE_NOTFOUND] for file control opcodes that they do not +// ** recognize. +// ** +// ** The xSectorSize() method returns the sector size of the +// ** device that underlies the file. The sector size is the +// ** minimum write that can be performed without disturbing +// ** other bytes in the file. The xDeviceCharacteristics() +// ** method returns a bit vector describing behaviors of the +// ** underlying device: +// ** +// **
    +// **
  • [SQLITE_IOCAP_ATOMIC] +// **
  • [SQLITE_IOCAP_ATOMIC512] +// **
  • [SQLITE_IOCAP_ATOMIC1K] +// **
  • [SQLITE_IOCAP_ATOMIC2K] +// **
  • [SQLITE_IOCAP_ATOMIC4K] +// **
  • [SQLITE_IOCAP_ATOMIC8K] +// **
  • [SQLITE_IOCAP_ATOMIC16K] +// **
  • [SQLITE_IOCAP_ATOMIC32K] +// **
  • [SQLITE_IOCAP_ATOMIC64K] +// **
  • [SQLITE_IOCAP_SAFE_APPEND] +// **
  • [SQLITE_IOCAP_SEQUENTIAL] +// **
  • [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] +// **
  • [SQLITE_IOCAP_POWERSAFE_OVERWRITE] +// **
  • [SQLITE_IOCAP_IMMUTABLE] +// **
  • [SQLITE_IOCAP_BATCH_ATOMIC] +// **
  • [SQLITE_IOCAP_SUBPAGE_READ] +// **
+// ** +// ** The SQLITE_IOCAP_ATOMIC property means that all writes of +// ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values +// ** mean that writes of blocks that are nnn bytes in size and +// ** are aligned to an address which is an integer multiple of +// ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means +// ** that when data is appended to a file, the data is appended +// ** first then the size of the file is extended, never the other +// ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that +// ** information is written to disk in the same order as calls +// ** to xWrite(). +// ** +// ** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill +// ** in the unread portions of the buffer with zeros. A VFS that +// ** fails to zero-fill short reads might seem to work. However, +// ** failure to zero-fill short reads will eventually lead to +// ** database corruption. +// */ +type Tsqlite3_io_methods = struct { + FiVersion int32 + FxClose uintptr + FxRead uintptr + FxWrite uintptr + FxTruncate uintptr + FxSync uintptr + FxFileSize uintptr + FxLock uintptr + FxUnlock uintptr + FxCheckReservedLock uintptr + FxFileControl uintptr + FxSectorSize uintptr + FxDeviceCharacteristics uintptr + FxShmMap uintptr + FxShmLock uintptr + FxShmBarrier uintptr + FxShmUnmap uintptr + FxFetch uintptr + FxUnfetch uintptr +} + +// C documentation +// +// /* +// ** This is the function signature used for all extension entry points. It +// ** is also defined in the file "loadext.c". +// */ +type Tsqlite3_loadext_entry = uintptr + +// C documentation +// +// /* +// ** CAPI3REF: Memory Allocation Routines +// ** +// ** An instance of this object defines the interface between SQLite +// ** and low-level memory allocation routines. +// ** +// ** This object is used in only one place in the SQLite interface. +// ** A pointer to an instance of this object is the argument to +// ** [sqlite3_config()] when the configuration option is +// ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. +// ** By creating an instance of this object +// ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) +// ** during configuration, an application can specify an alternative +// ** memory allocation subsystem for SQLite to use for all of its +// ** dynamic memory needs. +// ** +// ** Note that SQLite comes with several [built-in memory allocators] +// ** that are perfectly adequate for the overwhelming majority of applications +// ** and that this object is only useful to a tiny minority of applications +// ** with specialized memory allocation requirements. This object is +// ** also used during testing of SQLite in order to specify an alternative +// ** memory allocator that simulates memory out-of-memory conditions in +// ** order to verify that SQLite recovers gracefully from such +// ** conditions. +// ** +// ** The xMalloc, xRealloc, and xFree methods must work like the +// ** malloc(), realloc() and free() functions from the standard C library. +// ** ^SQLite guarantees that the second argument to +// ** xRealloc is always a value returned by a prior call to xRoundup. +// ** +// ** xSize should return the allocated size of a memory allocation +// ** previously obtained from xMalloc or xRealloc. The allocated size +// ** is always at least as big as the requested size but may be larger. +// ** +// ** The xRoundup method returns what would be the allocated size of +// ** a memory allocation given a particular requested size. Most memory +// ** allocators round up memory allocations at least to the next multiple +// ** of 8. Some allocators round up to a larger multiple or to a power of 2. +// ** Every memory allocation request coming in through [sqlite3_malloc()] +// ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, +// ** that causes the corresponding memory allocation to fail. +// ** +// ** The xInit method initializes the memory allocator. For example, +// ** it might allocate any required mutexes or initialize internal data +// ** structures. The xShutdown method is invoked (indirectly) by +// ** [sqlite3_shutdown()] and should deallocate any resources acquired +// ** by xInit. The pAppData pointer is used as the only parameter to +// ** xInit and xShutdown. +// ** +// ** SQLite holds the [SQLITE_MUTEX_STATIC_MAIN] mutex when it invokes +// ** the xInit method, so the xInit method need not be threadsafe. The +// ** xShutdown method is only called from [sqlite3_shutdown()] so it does +// ** not need to be threadsafe either. For all other methods, SQLite +// ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the +// ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which +// ** it is by default) and so the methods are automatically serialized. +// ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other +// ** methods must be threadsafe or else make their own arrangements for +// ** serialization. +// ** +// ** SQLite will never invoke xInit() more than once without an intervening +// ** call to xShutdown(). +// */ +type Tsqlite3_mem_methods = struct { + FxMalloc uintptr + FxFree uintptr + FxRealloc uintptr + FxSize uintptr + FxRoundup uintptr + FxInit uintptr + FxShutdown uintptr + FpAppData uintptr +} + +type Tsqlite3_module = struct { + FiVersion int32 + FxCreate uintptr + FxConnect uintptr + FxBestIndex uintptr + FxDisconnect uintptr + FxDestroy uintptr + FxOpen uintptr + FxClose uintptr + FxFilter uintptr + FxNext uintptr + FxEof uintptr + FxColumn uintptr + FxRowid uintptr + FxUpdate uintptr + FxBegin uintptr + FxSync uintptr + FxCommit uintptr + FxRollback uintptr + FxFindFunction uintptr + FxRename uintptr + FxSavepoint uintptr + FxRelease uintptr + FxRollbackTo uintptr + FxShadowName uintptr + FxIntegrity uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: Mutex Methods Object +// ** +// ** An instance of this structure defines the low-level routines +// ** used to allocate and use mutexes. +// ** +// ** Usually, the default mutex implementations provided by SQLite are +// ** sufficient, however the application has the option of substituting a custom +// ** implementation for specialized deployments or systems for which SQLite +// ** does not provide a suitable implementation. In this case, the application +// ** creates and populates an instance of this structure to pass +// ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. +// ** Additionally, an instance of this structure can be used as an +// ** output variable when querying the system for the current mutex +// ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. +// ** +// ** ^The xMutexInit method defined by this structure is invoked as +// ** part of system initialization by the sqlite3_initialize() function. +// ** ^The xMutexInit routine is called by SQLite exactly once for each +// ** effective call to [sqlite3_initialize()]. +// ** +// ** ^The xMutexEnd method defined by this structure is invoked as +// ** part of system shutdown by the sqlite3_shutdown() function. The +// ** implementation of this method is expected to release all outstanding +// ** resources obtained by the mutex methods implementation, especially +// ** those obtained by the xMutexInit method. ^The xMutexEnd() +// ** interface is invoked exactly once for each call to [sqlite3_shutdown()]. +// ** +// ** ^(The remaining seven methods defined by this structure (xMutexAlloc, +// ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and +// ** xMutexNotheld) implement the following interfaces (respectively): +// ** +// **
    +// **
  • [sqlite3_mutex_alloc()]
  • +// **
  • [sqlite3_mutex_free()]
  • +// **
  • [sqlite3_mutex_enter()]
  • +// **
  • [sqlite3_mutex_try()]
  • +// **
  • [sqlite3_mutex_leave()]
  • +// **
  • [sqlite3_mutex_held()]
  • +// **
  • [sqlite3_mutex_notheld()]
  • +// **
)^ +// ** +// ** The only difference is that the public sqlite3_XXX functions enumerated +// ** above silently ignore any invocations that pass a NULL pointer instead +// ** of a valid mutex handle. The implementations of the methods defined +// ** by this structure are not required to handle this case. The results +// ** of passing a NULL pointer instead of a valid mutex handle are undefined +// ** (i.e. it is acceptable to provide an implementation that segfaults if +// ** it is passed a NULL pointer). +// ** +// ** The xMutexInit() method must be threadsafe. It must be harmless to +// ** invoke xMutexInit() multiple times within the same process and without +// ** intervening calls to xMutexEnd(). Second and subsequent calls to +// ** xMutexInit() must be no-ops. +// ** +// ** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] +// ** and its associates). Similarly, xMutexAlloc() must not use SQLite memory +// ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite +// ** memory allocation for a fast or recursive mutex. +// ** +// ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is +// ** called, but only if the prior call to xMutexInit returned SQLITE_OK. +// ** If xMutexInit fails in any way, it is expected to clean up after itself +// ** prior to returning. +// */ +type Tsqlite3_mutex_methods = struct { + FxMutexInit uintptr + FxMutexEnd uintptr + FxMutexAlloc uintptr + FxMutexFree uintptr + FxMutexEnter uintptr + FxMutexTry uintptr + FxMutexLeave uintptr + FxMutexHeld uintptr + FxMutexNotheld uintptr +} + +// C documentation +// +// /* +// ** This is the obsolete pcache_methods object that has now been replaced +// ** by sqlite3_pcache_methods2. This object is not used by SQLite. It is +// ** retained in the header file for backwards compatibility only. +// */ +type Tsqlite3_pcache_methods = struct { + FpArg uintptr + FxInit uintptr + FxShutdown uintptr + FxCreate uintptr + FxCachesize uintptr + FxPagecount uintptr + FxFetch uintptr + FxUnpin uintptr + FxRekey uintptr + FxTruncate uintptr + FxDestroy uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: Application Defined Page Cache. +// ** KEYWORDS: {page cache} +// ** +// ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can +// ** register an alternative page cache implementation by passing in an +// ** instance of the sqlite3_pcache_methods2 structure.)^ +// ** In many applications, most of the heap memory allocated by +// ** SQLite is used for the page cache. +// ** By implementing a +// ** custom page cache using this API, an application can better control +// ** the amount of memory consumed by SQLite, the way in which +// ** that memory is allocated and released, and the policies used to +// ** determine exactly which parts of a database file are cached and for +// ** how long. +// ** +// ** The alternative page cache mechanism is an +// ** extreme measure that is only needed by the most demanding applications. +// ** The built-in page cache is recommended for most uses. +// ** +// ** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an +// ** internal buffer by SQLite within the call to [sqlite3_config]. Hence +// ** the application may discard the parameter after the call to +// ** [sqlite3_config()] returns.)^ +// ** +// ** [[the xInit() page cache method]] +// ** ^(The xInit() method is called once for each effective +// ** call to [sqlite3_initialize()])^ +// ** (usually only once during the lifetime of the process). ^(The xInit() +// ** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ +// ** The intent of the xInit() method is to set up global data structures +// ** required by the custom page cache implementation. +// ** ^(If the xInit() method is NULL, then the +// ** built-in default page cache is used instead of the application defined +// ** page cache.)^ +// ** +// ** [[the xShutdown() page cache method]] +// ** ^The xShutdown() method is called by [sqlite3_shutdown()]. +// ** It can be used to clean up +// ** any outstanding resources before process shutdown, if required. +// ** ^The xShutdown() method may be NULL. +// ** +// ** ^SQLite automatically serializes calls to the xInit method, +// ** so the xInit method need not be threadsafe. ^The +// ** xShutdown method is only called from [sqlite3_shutdown()] so it does +// ** not need to be threadsafe either. All other methods must be threadsafe +// ** in multithreaded applications. +// ** +// ** ^SQLite will never invoke xInit() more than once without an intervening +// ** call to xShutdown(). +// ** +// ** [[the xCreate() page cache methods]] +// ** ^SQLite invokes the xCreate() method to construct a new cache instance. +// ** SQLite will typically create one cache instance for each open database file, +// ** though this is not guaranteed. ^The +// ** first parameter, szPage, is the size in bytes of the pages that must +// ** be allocated by the cache. ^szPage will always be a power of two. ^The +// ** second parameter szExtra is a number of bytes of extra storage +// ** associated with each page cache entry. ^The szExtra parameter will be +// ** a number less than 250. SQLite will use the +// ** extra szExtra bytes on each page to store metadata about the underlying +// ** database page on disk. The value passed into szExtra depends +// ** on the SQLite version, the target platform, and how SQLite was compiled. +// ** ^The third argument to xCreate(), bPurgeable, is true if the cache being +// ** created will be used to cache database pages of a file stored on disk, or +// ** false if it is used for an in-memory database. The cache implementation +// ** does not have to do anything special based upon the value of bPurgeable; +// ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will +// ** never invoke xUnpin() except to deliberately delete a page. +// ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to +// ** false will always have the "discard" flag set to true. +// ** ^Hence, a cache created with bPurgeable set to false will +// ** never contain any unpinned pages. +// ** +// ** [[the xCachesize() page cache method]] +// ** ^(The xCachesize() method may be called at any time by SQLite to set the +// ** suggested maximum cache-size (number of pages stored) for the cache +// ** instance passed as the first argument. This is the value configured using +// ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable +// ** parameter, the implementation is not required to do anything with this +// ** value; it is advisory only. +// ** +// ** [[the xPagecount() page cache methods]] +// ** The xPagecount() method must return the number of pages currently +// ** stored in the cache, both pinned and unpinned. +// ** +// ** [[the xFetch() page cache methods]] +// ** The xFetch() method locates a page in the cache and returns a pointer to +// ** an sqlite3_pcache_page object associated with that page, or a NULL pointer. +// ** The pBuf element of the returned sqlite3_pcache_page object will be a +// ** pointer to a buffer of szPage bytes used to store the content of a +// ** single database page. The pExtra element of sqlite3_pcache_page will be +// ** a pointer to the szExtra bytes of extra storage that SQLite has requested +// ** for each entry in the page cache. +// ** +// ** The page to be fetched is determined by the key. ^The minimum key value +// ** is 1. After it has been retrieved using xFetch, the page is considered +// ** to be "pinned". +// ** +// ** If the requested page is already in the page cache, then the page cache +// ** implementation must return a pointer to the page buffer with its content +// ** intact. If the requested page is not already in the cache, then the +// ** cache implementation should use the value of the createFlag +// ** parameter to help it determine what action to take: +// ** +// ** +// **
createFlag Behavior when page is not already in cache +// **
0 Do not allocate a new page. Return NULL. +// **
1 Allocate a new page if it is easy and convenient to do so. +// ** Otherwise return NULL. +// **
2 Make every effort to allocate a new page. Only return +// ** NULL if allocating a new page is effectively impossible. +// **
+// ** +// ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite +// ** will only use a createFlag of 2 after a prior call with a createFlag of 1 +// ** failed.)^ In between the xFetch() calls, SQLite may +// ** attempt to unpin one or more cache pages by spilling the content of +// ** pinned pages to disk and synching the operating system disk cache. +// ** +// ** [[the xUnpin() page cache method]] +// ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page +// ** as its second argument. If the third parameter, discard, is non-zero, +// ** then the page must be evicted from the cache. +// ** ^If the discard parameter is +// ** zero, then the page may be discarded or retained at the discretion of the +// ** page cache implementation. ^The page cache implementation +// ** may choose to evict unpinned pages at any time. +// ** +// ** The cache must not perform any reference counting. A single +// ** call to xUnpin() unpins the page regardless of the number of prior calls +// ** to xFetch(). +// ** +// ** [[the xRekey() page cache methods]] +// ** The xRekey() method is used to change the key value associated with the +// ** page passed as the second argument. If the cache +// ** previously contains an entry associated with newKey, it must be +// ** discarded. ^Any prior cache entry associated with newKey is guaranteed not +// ** to be pinned. +// ** +// ** When SQLite calls the xTruncate() method, the cache must discard all +// ** existing cache entries with page numbers (keys) greater than or equal +// ** to the value of the iLimit parameter passed to xTruncate(). If any +// ** of these pages are pinned, they become implicitly unpinned, meaning that +// ** they can be safely discarded. +// ** +// ** [[the xDestroy() page cache method]] +// ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). +// ** All resources associated with the specified cache should be freed. ^After +// ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] +// ** handle invalid, and will not use it with any other sqlite3_pcache_methods2 +// ** functions. +// ** +// ** [[the xShrink() page cache method]] +// ** ^SQLite invokes the xShrink() method when it wants the page cache to +// ** free up as much of heap memory as possible. The page cache implementation +// ** is not obligated to free any memory, but well-behaved implementations should +// ** do their best. +// */ +type Tsqlite3_pcache_methods2 = struct { + FiVersion int32 + FpArg uintptr + FxInit uintptr + FxShutdown uintptr + FxCreate uintptr + FxCachesize uintptr + FxPagecount uintptr + FxFetch uintptr + FxUnpin uintptr + FxRekey uintptr + FxTruncate uintptr + FxDestroy uintptr + FxShrink uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: Custom Page Cache Object +// ** +// ** The sqlite3_pcache_page object represents a single page in the +// ** page cache. The page cache will allocate instances of this +// ** object. Various methods of the page cache use pointers to instances +// ** of this object as parameters or as their return value. +// ** +// ** See [sqlite3_pcache_methods2] for additional information. +// */ +type Tsqlite3_pcache_page = struct { + FpBuf uintptr + FpExtra uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: Rebasing changesets +// ** EXPERIMENTAL +// ** +// ** Suppose there is a site hosting a database in state S0. And that +// ** modifications are made that move that database to state S1 and a +// ** changeset recorded (the "local" changeset). Then, a changeset based +// ** on S0 is received from another site (the "remote" changeset) and +// ** applied to the database. The database is then in state +// ** (S1+"remote"), where the exact state depends on any conflict +// ** resolution decisions (OMIT or REPLACE) made while applying "remote". +// ** Rebasing a changeset is to update it to take those conflict +// ** resolution decisions into account, so that the same conflicts +// ** do not have to be resolved elsewhere in the network. +// ** +// ** For example, if both the local and remote changesets contain an +// ** INSERT of the same key on "CREATE TABLE t1(a PRIMARY KEY, b)": +// ** +// ** local: INSERT INTO t1 VALUES(1, 'v1'); +// ** remote: INSERT INTO t1 VALUES(1, 'v2'); +// ** +// ** and the conflict resolution is REPLACE, then the INSERT change is +// ** removed from the local changeset (it was overridden). Or, if the +// ** conflict resolution was "OMIT", then the local changeset is modified +// ** to instead contain: +// ** +// ** UPDATE t1 SET b = 'v2' WHERE a=1; +// ** +// ** Changes within the local changeset are rebased as follows: +// ** +// **
+// **
Local INSERT
+// ** This may only conflict with a remote INSERT. If the conflict +// ** resolution was OMIT, then add an UPDATE change to the rebased +// ** changeset. Or, if the conflict resolution was REPLACE, add +// ** nothing to the rebased changeset. +// ** +// **
Local DELETE
+// ** This may conflict with a remote UPDATE or DELETE. In both cases the +// ** only possible resolution is OMIT. If the remote operation was a +// ** DELETE, then add no change to the rebased changeset. If the remote +// ** operation was an UPDATE, then the old.* fields of change are updated +// ** to reflect the new.* values in the UPDATE. +// ** +// **
Local UPDATE
+// ** This may conflict with a remote UPDATE or DELETE. If it conflicts +// ** with a DELETE, and the conflict resolution was OMIT, then the update +// ** is changed into an INSERT. Any undefined values in the new.* record +// ** from the update change are filled in using the old.* values from +// ** the conflicting DELETE. Or, if the conflict resolution was REPLACE, +// ** the UPDATE change is simply omitted from the rebased changeset. +// ** +// ** If conflict is with a remote UPDATE and the resolution is OMIT, then +// ** the old.* values are rebased using the new.* values in the remote +// ** change. Or, if the resolution is REPLACE, then the change is copied +// ** into the rebased changeset with updates to columns also updated by +// ** the conflicting remote UPDATE removed. If this means no columns would +// ** be updated, the change is omitted. +// **
+// ** +// ** A local change may be rebased against multiple remote changes +// ** simultaneously. If a single key is modified by multiple remote +// ** changesets, they are combined as follows before the local changeset +// ** is rebased: +// ** +// **
    +// **
  • If there has been one or more REPLACE resolutions on a +// ** key, it is rebased according to a REPLACE. +// ** +// **
  • If there have been no REPLACE resolutions on a key, then +// ** the local changeset is rebased according to the most recent +// ** of the OMIT resolutions. +// **
+// ** +// ** Note that conflict resolutions from multiple remote changesets are +// ** combined on a per-field basis, not per-row. This means that in the +// ** case of multiple remote UPDATE operations, some fields of a single +// ** local change may be rebased for REPLACE while others are rebased for +// ** OMIT. +// ** +// ** In order to rebase a local changeset, the remote changeset must first +// ** be applied to the local database using sqlite3changeset_apply_v2() and +// ** the buffer of rebase information captured. Then: +// ** +// **
    +// **
  1. An sqlite3_rebaser object is created by calling +// ** sqlite3rebaser_create(). +// **
  2. The new object is configured with the rebase buffer obtained from +// ** sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure(). +// ** If the local changeset is to be rebased against multiple remote +// ** changesets, then sqlite3rebaser_configure() should be called +// ** multiple times, in the same order that the multiple +// ** sqlite3changeset_apply_v2() calls were made. +// **
  3. Each local changeset is rebased by calling sqlite3rebaser_rebase(). +// **
  4. The sqlite3_rebaser object is deleted by calling +// ** sqlite3rebaser_delete(). +// **
+// */ +type Tsqlite3_rebaser = struct { + Fgrp Tsqlite3_changegroup +} + +// C documentation +// +// /* The double-precision datatype used by RTree depends on the +// ** SQLITE_RTREE_INT_ONLY compile-time option. +// */ +type Tsqlite3_rtree_dbl = float64 + +type Tsqlite3_rtree_geometry = struct { + FpContext uintptr + FnParam int32 + FaParam uintptr + FpUser uintptr + FxDelUser uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: Database Snapshot +// ** KEYWORDS: {snapshot} {sqlite3_snapshot} +// ** +// ** An instance of the snapshot object records the state of a [WAL mode] +// ** database for some specific point in history. +// ** +// ** In [WAL mode], multiple [database connections] that are open on the +// ** same database file can each be reading a different historical version +// ** of the database file. When a [database connection] begins a read +// ** transaction, that connection sees an unchanging copy of the database +// ** as it existed for the point in time when the transaction first started. +// ** Subsequent changes to the database from other connections are not seen +// ** by the reader until a new read transaction is started. +// ** +// ** The sqlite3_snapshot object records state information about an historical +// ** version of the database file so that it is possible to later open a new read +// ** transaction that sees that historical version of the database rather than +// ** the most recent version. +// */ +type Tsqlite3_snapshot = struct { + Fhidden [48]uint8 +} + +// C documentation +// +// /* +// ** CAPI3REF: Dynamic String Object +// ** KEYWORDS: {dynamic string} +// ** +// ** An instance of the sqlite3_str object contains a dynamically-sized +// ** string under construction. +// ** +// ** The lifecycle of an sqlite3_str object is as follows: +// **
    +// **
  1. ^The sqlite3_str object is created using [sqlite3_str_new()]. +// **
  2. ^Text is appended to the sqlite3_str object using various +// ** methods, such as [sqlite3_str_appendf()]. +// **
  3. ^The sqlite3_str object is destroyed and the string it created +// ** is returned using the [sqlite3_str_finish()] interface. +// **
+// */ +type Tsqlite3_str = struct { + Fdb uintptr + FzText uintptr + FnAlloc Tu32 + FmxAlloc Tu32 + FnChar Tu32 + FaccError Tu8 + FprintfFlags Tu8 +} + +type Tsqlite3_syscall_ptr = uintptr + +type Tsqlite3_uint64 = uint64 + +// C documentation +// +// /* +// ** CAPI3REF: OS Interface Object +// ** +// ** An instance of the sqlite3_vfs object defines the interface between +// ** the SQLite core and the underlying operating system. The "vfs" +// ** in the name of the object stands for "virtual file system". See +// ** the [VFS | VFS documentation] for further information. +// ** +// ** The VFS interface is sometimes extended by adding new methods onto +// ** the end. Each time such an extension occurs, the iVersion field +// ** is incremented. The iVersion value started out as 1 in +// ** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2 +// ** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased +// ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields +// ** may be appended to the sqlite3_vfs object and the iVersion value +// ** may increase again in future versions of SQLite. +// ** Note that due to an oversight, the structure +// ** of the sqlite3_vfs object changed in the transition from +// ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] +// ** and yet the iVersion field was not increased. +// ** +// ** The szOsFile field is the size of the subclassed [sqlite3_file] +// ** structure used by this VFS. mxPathname is the maximum length of +// ** a pathname in this VFS. +// ** +// ** Registered sqlite3_vfs objects are kept on a linked list formed by +// ** the pNext pointer. The [sqlite3_vfs_register()] +// ** and [sqlite3_vfs_unregister()] interfaces manage this list +// ** in a thread-safe way. The [sqlite3_vfs_find()] interface +// ** searches the list. Neither the application code nor the VFS +// ** implementation should use the pNext pointer. +// ** +// ** The pNext field is the only field in the sqlite3_vfs +// ** structure that SQLite will ever modify. SQLite will only access +// ** or modify this field while holding a particular static mutex. +// ** The application should never modify anything within the sqlite3_vfs +// ** object once the object has been registered. +// ** +// ** The zName field holds the name of the VFS module. The name must +// ** be unique across all VFS modules. +// ** +// ** [[sqlite3_vfs.xOpen]] +// ** ^SQLite guarantees that the zFilename parameter to xOpen +// ** is either a NULL pointer or string obtained +// ** from xFullPathname() with an optional suffix added. +// ** ^If a suffix is added to the zFilename parameter, it will +// ** consist of a single "-" character followed by no more than +// ** 11 alphanumeric and/or "-" characters. +// ** ^SQLite further guarantees that +// ** the string will be valid and unchanged until xClose() is +// ** called. Because of the previous sentence, +// ** the [sqlite3_file] can safely store a pointer to the +// ** filename if it needs to remember the filename for some reason. +// ** If the zFilename parameter to xOpen is a NULL pointer then xOpen +// ** must invent its own temporary name for the file. ^Whenever the +// ** xFilename parameter is NULL it will also be the case that the +// ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. +// ** +// ** The flags argument to xOpen() includes all bits set in +// ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] +// ** or [sqlite3_open16()] is used, then flags includes at least +// ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. +// ** If xOpen() opens a file read-only then it sets *pOutFlags to +// ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. +// ** +// ** ^(SQLite will also add one of the following flags to the xOpen() +// ** call, depending on the object being opened: +// ** +// **
    +// **
  • [SQLITE_OPEN_MAIN_DB] +// **
  • [SQLITE_OPEN_MAIN_JOURNAL] +// **
  • [SQLITE_OPEN_TEMP_DB] +// **
  • [SQLITE_OPEN_TEMP_JOURNAL] +// **
  • [SQLITE_OPEN_TRANSIENT_DB] +// **
  • [SQLITE_OPEN_SUBJOURNAL] +// **
  • [SQLITE_OPEN_SUPER_JOURNAL] +// **
  • [SQLITE_OPEN_WAL] +// **
)^ +// ** +// ** The file I/O implementation can use the object type flags to +// ** change the way it deals with files. For example, an application +// ** that does not care about crash recovery or rollback might make +// ** the open of a journal file a no-op. Writes to this journal would +// ** also be no-ops, and any attempt to read the journal would return +// ** SQLITE_IOERR. Or the implementation might recognize that a database +// ** file will be doing page-aligned sector reads and writes in a random +// ** order and set up its I/O subsystem accordingly. +// ** +// ** SQLite might also add one of the following flags to the xOpen method: +// ** +// **
    +// **
  • [SQLITE_OPEN_DELETEONCLOSE] +// **
  • [SQLITE_OPEN_EXCLUSIVE] +// **
+// ** +// ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be +// ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] +// ** will be set for TEMP databases and their journals, transient +// ** databases, and subjournals. +// ** +// ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction +// ** with the [SQLITE_OPEN_CREATE] flag, which are both directly +// ** analogous to the O_EXCL and O_CREAT flags of the POSIX open() +// ** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the +// ** SQLITE_OPEN_CREATE, is used to indicate that file should always +// ** be created, and that it is an error if it already exists. +// ** It is not used to indicate the file should be opened +// ** for exclusive access. +// ** +// ** ^At least szOsFile bytes of memory are allocated by SQLite +// ** to hold the [sqlite3_file] structure passed as the third +// ** argument to xOpen. The xOpen method does not have to +// ** allocate the structure; it should just fill it in. Note that +// ** the xOpen method must set the sqlite3_file.pMethods to either +// ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do +// ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods +// ** element will be valid after xOpen returns regardless of the success +// ** or failure of the xOpen call. +// ** +// ** [[sqlite3_vfs.xAccess]] +// ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] +// ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to +// ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] +// ** to test whether a file is at least readable. The SQLITE_ACCESS_READ +// ** flag is never actually used and is not implemented in the built-in +// ** VFSes of SQLite. The file is named by the second argument and can be a +// ** directory. The xAccess method returns [SQLITE_OK] on success or some +// ** non-zero error code if there is an I/O error or if the name of +// ** the file given in the second argument is illegal. If SQLITE_OK +// ** is returned, then non-zero or zero is written into *pResOut to indicate +// ** whether or not the file is accessible. +// ** +// ** ^SQLite will always allocate at least mxPathname+1 bytes for the +// ** output buffer xFullPathname. The exact size of the output buffer +// ** is also passed as a parameter to both methods. If the output buffer +// ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is +// ** handled as a fatal error by SQLite, vfs implementations should endeavor +// ** to prevent this by setting mxPathname to a sufficiently large value. +// ** +// ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() +// ** interfaces are not strictly a part of the filesystem, but they are +// ** included in the VFS structure for completeness. +// ** The xRandomness() function attempts to return nBytes bytes +// ** of good-quality randomness into zOut. The return value is +// ** the actual number of bytes of randomness obtained. +// ** The xSleep() method causes the calling thread to sleep for at +// ** least the number of microseconds given. ^The xCurrentTime() +// ** method returns a Julian Day Number for the current date and time as +// ** a floating point value. +// ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian +// ** Day Number multiplied by 86400000 (the number of milliseconds in +// ** a 24-hour day). +// ** ^SQLite will use the xCurrentTimeInt64() method to get the current +// ** date and time if that method is available (if iVersion is 2 or +// ** greater and the function pointer is not NULL) and will fall back +// ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. +// ** +// ** ^The xSetSystemCall(), xGetSystemCall(), and xNextSystemCall() interfaces +// ** are not used by the SQLite core. These optional interfaces are provided +// ** by some VFSes to facilitate testing of the VFS code. By overriding +// ** system calls with functions under its control, a test program can +// ** simulate faults and error conditions that would otherwise be difficult +// ** or impossible to induce. The set of system calls that can be overridden +// ** varies from one VFS to another, and from one version of the same VFS to the +// ** next. Applications that use these interfaces must be prepared for any +// ** or all of these interfaces to be NULL or for their behavior to change +// ** from one release to the next. Applications must not attempt to access +// ** any of these methods if the iVersion of the VFS is less than 3. +// */ +type Tsqlite3_vfs = struct { + FiVersion int32 + FszOsFile int32 + FmxPathname int32 + FpNext uintptr + FzName uintptr + FpAppData uintptr + FxOpen uintptr + FxDelete uintptr + FxAccess uintptr + FxFullPathname uintptr + FxDlOpen uintptr + FxDlError uintptr + FxDlSym uintptr + FxDlClose uintptr + FxRandomness uintptr + FxSleep uintptr + FxCurrentTime uintptr + FxGetLastError uintptr + FxCurrentTimeInt64 uintptr + FxSetSystemCall uintptr + FxGetSystemCall uintptr + FxNextSystemCall uintptr +} + +// C documentation +// +// /* +// ** Structures used by the virtual table interface +// */ +type Tsqlite3_vtab = struct { + FpModule uintptr + FnRef int32 + FzErrMsg uintptr +} + +type Tsqlite3_vtab_cursor = struct { + FpVtab uintptr +} + +// C documentation +// +// /* +// ** typedef for the authorization callback function. +// */ +type Tsqlite3_xauth = uintptr + +// C documentation +// +// /* +// ** CAPI3REF: 64-Bit Integer Types +// ** KEYWORDS: sqlite_int64 sqlite_uint64 +// ** +// ** Because there is no cross-platform way to specify 64-bit integer types +// ** SQLite includes typedefs for 64-bit signed and unsigned integers. +// ** +// ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. +// ** The sqlite_int64 and sqlite_uint64 types are supported for backwards +// ** compatibility only. +// ** +// ** ^The sqlite3_int64 and sqlite_int64 types can store integer values +// ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The +// ** sqlite3_uint64 and sqlite_uint64 types can store integer values +// ** between 0 and +18446744073709551615 inclusive. +// */ +type Tsqlite_int64 = int64 + +type Tsqlite_uint64 = uint64 + +// C documentation +// +// /* +// ** The datatype used to store estimates of the number of rows in a +// ** table or index. +// */ +type TtRowcnt = uint64 + +type Ttimezone = struct { + Ftz_minuteswest int32 + Ftz_dsttime int32 +} + +/* 4-byte unsigned integer */ +type Tu16 = uint16 + +/* 8-byte unsigned integer */ +type Tu32 = uint32 + +/* 8-byte signed integer */ +type Tu64 = uint64 + +/* 2-byte signed integer */ +type Tu8 = uint8 + +type Tu_char = uint8 + +type Tu_int = uint32 + +type Tu_short = uint16 + +type Tuint16_t = uint16 + +type Tuint32_t = uint32 + +type Tuint64_t = uint64 + +type Tuint8_t = uint8 + +type Tuint_fast32_t = uint32 + +type Tuint_fast64_t = uint64 + +type Tuint_least16_t = uint16 + +type Tuint_least32_t = uint32 + +type Tuint_least64_t = uint64 + +type Tuint_least8_t = uint8 + +type Tuintmax_t = uint64 + +type Tuseconds_t = uint32 + +type Tva_list = uintptr + +// C documentation +// +// /* +// ** The yDbMask datatype for the bitmask of all attached databases. +// */ +type TyDbMask = uint32 + +// C documentation +// +// /* +// ** The datatype ynVar is a signed integer, either 16-bit or 32-bit. +// ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater +// ** than 32767 we have to make it 32-bit. 16-bit is preferred because +// ** it uses less memory in the Expr object, which is a big memory user +// ** in systems with lots of prepared statements. And few applications +// ** need more than about 10 or 20 variables. But some extreme users want +// ** to have prepared statements with over 32766 variables, and for them +// ** the option is available (at compile-time). +// */ +type TynVar = int16 + +/* The state of the parser is completely contained in an instance of +** the following structure */ +type TyyParser = struct { + Fyytos uintptr + FpParse uintptr + FyystackEnd uintptr + Fyystack uintptr + Fyystk0 [50]TyyStackEntry +} + +/* The following structure represents a single element of the +** parser's stack. Information stored includes: +** +** + The state number for the parser at this level of the stack. +** +** + The value of the token stored at this level of the stack. +** (In other words, the "major" token.) +** +** + The semantic value stored at this level of the stack. This is +** the information used by the action routines in the grammar. +** It is sometimes called the "minor" token. +** +** After the "shift" half of a SHIFTREDUCE action, the stateno field +** actually contains the reduce action for the second half of the +** SHIFTREDUCE. + */ +type TyyStackEntry = struct { + Fstateno uint16 + Fmajor uint16 + Fminor TYYMINORTYPE +} + +const UINT16_MAX = 65535 + +const UINT32_MAX = 4294967295 + +const UINT64_MAX = 18446744073709551615 + +const UINT8_MAX = 255 + +const UINTMAX_MAX = 18446744073709551615 + +const UINT_FAST32_MAX = 4294967295 + +const UINT_FAST64_MAX = 18446744073709551615 + +const UINT_LEAST16_MAX = 65535 + +const UINT_LEAST32_MAX = 4294967295 + +const UINT_LEAST64_MAX = 18446744073709551615 + +const UINT_LEAST8_MAX = 255 + +const UNKNOWN_LOCK = 5 + +type Unicode61Tokenizer = TUnicode61Tokenizer + +/* Values for eRemoveDiacritic (must match internals of fts5_unicode2.c) */ + +type UnpackedRecord = TUnpackedRecord + +const UpperToLower = 0 + +type Upsert = TUpsert + +const VDBE_DISPLAY_P4 = 1 + +const VDBE_HALT_STATE = 3 + +const VDBE_INIT_STATE = 0 + +const VDBE_READY_STATE = 1 + +const VDBE_RUN_STATE = 2 + +type VList = TVList + +/************** End of os.h **************************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include pager.h in the middle of sqliteInt.h *****************/ +/************** Begin file pager.h *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the interface that the sqlite page cache +** subsystem. The page cache subsystem reads and writes a file a page +** at a time and provides a journal for rollback. + */ + +/* +** Default maximum size for persistent journal files. A negative +** value means no limit. This value may be overridden using the +** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". + */ + +type VTable = TVTable + +type ValueList = TValueList + +/************** End of vdbeInt.h *********************************************/ +/************** Continuing where we left off in status.c *********************/ + +type ValueNewStat4Ctx = TValueNewStat4Ctx + +type Vdbe = TVdbe + +type VdbeCursor = TVdbeCursor + +type VdbeFrame = TVdbeFrame + +/* +** The size (in bytes) of an sqlite3_context object that holds N +** argv[] arguments. + */ + +type VdbeOp = TVdbeOp + +type VdbeOpList = TVdbeOpList + +type VdbeSorter = TVdbeSorter + +type VdbeTxtBlbCache = TVdbeTxtBlbCache + +/* Types of VDBE cursors */ + +const ViewCanHaveRowid = 0 + +type VtabCtx = TVtabCtx + +const WALINDEX_HDR_SIZE = 0 + +const WALINDEX_MAX_VERSION = 3007000 + +const WALINDEX_PGSZ = 0 + +const WAL_ALL_BUT_WRITE = 1 + +const WAL_CKPT_LOCK = 1 + +const WAL_EXCLUSIVE_MODE = 1 + +const WAL_FRAME_HDRSIZE = 24 + +const WAL_HDRSIZE = 32 + +const WAL_HEAPMEMORY_MODE = 2 + +const WAL_LOCK_CKPT = 1 + +const WAL_LOCK_READ0 = 3 + +const WAL_LOCK_WRITE = 0 + +const WAL_MAGIC = 931071618 + +const WAL_MAX_VERSION = 3007000 + +const WAL_NORMAL_MODE = 0 + +const WAL_NREADER = 5 + +const WAL_RDONLY = 1 + +const WAL_RDWR = 0 + +const WAL_RECOVER_LOCK = 2 + +const WAL_RETRY = -1 + +const WAL_RETRY_BLOCKED_MASK = 0 + +const WAL_RETRY_PROTOCOL_LIMIT = 100 + +const WAL_SAVEPOINT_NDATA = 4 + +const WAL_SHM_RDONLY = 2 + +const WAL_WRITE_LOCK = 0 + +const WHERE_AGG_DISTINCT = 1024 + +const WHERE_AUTO_INDEX = 16384 + +const WHERE_BIGNULL_SORT = 524288 + +const WHERE_BLOOMFILTER = 4194304 + +const WHERE_BOTH_LIMIT = 48 + +const WHERE_BTM_LIMIT = 32 + +const WHERE_COLUMN_EQ = 1 + +const WHERE_COLUMN_IN = 4 + +const WHERE_COLUMN_NULL = 8 + +const WHERE_COLUMN_RANGE = 2 + +const WHERE_CONSTRAINT = 15 + +const WHERE_COROUTINE = 33554432 + +const WHERE_DISTINCTBY = 128 + +const WHERE_DISTINCT_NOOP = 0 + +const WHERE_DISTINCT_ORDERED = 2 + +const WHERE_DISTINCT_UNIQUE = 1 + +const WHERE_DISTINCT_UNORDERED = 3 + +const WHERE_DUPLICATES_OK = 16 + +const WHERE_EXPRIDX = 67108864 + +const WHERE_GROUPBY = 64 + +const WHERE_IDX_ONLY = 64 + +const WHERE_INDEXED = 512 + +const WHERE_IN_ABLE = 2048 + +const WHERE_IN_EARLYOUT = 262144 + +const WHERE_IN_SEEKSCAN = 1048576 + +const WHERE_IPK = 256 + +const WHERE_KEEP_ALL_JOINS = 8192 + +const WHERE_MULTI_OR = 8192 + +const WHERE_OMIT_OFFSET = 16777216 + +const WHERE_ONEPASS_DESIRED = 4 + +const WHERE_ONEPASS_MULTIROW = 8 + +const WHERE_ONEROW = 4096 + +const WHERE_ORDERBY_LIMIT = 2048 + +const WHERE_ORDERBY_MAX = 2 + +const WHERE_ORDERBY_MIN = 1 + +const WHERE_ORDERBY_NORMAL = 0 + +const WHERE_OR_SUBCLAUSE = 32 + +const WHERE_PARTIALIDX = 131072 + +const WHERE_RIGHT_JOIN = 4096 + +const WHERE_SELFCULL = 8388608 + +const WHERE_SKIPSCAN = 32768 + +const WHERE_SORTBYGROUP = 512 + +const WHERE_TOP_LIMIT = 16 + +const WHERE_TRANSCONS = 2097152 + +const WHERE_UNQ_WANTED = 65536 + +const WHERE_USE_LIMIT = 16384 + +const WHERE_VIRTUALTABLE = 1024 + +const WHERE_WANT_DISTINCT = 256 + +const WINDOW_AGGINVERSE = 2 + +const WINDOW_AGGSTEP = 3 + +const WINDOW_ENDING_INT = 1 + +const WINDOW_ENDING_NUM = 4 + +const WINDOW_NTH_VALUE_INT = 2 + +const WINDOW_RETURN_ROW = 1 + +const WINDOW_STARTING_INT = 0 + +const WINDOW_STARTING_NUM = 3 + +const WO_ALL = 16383 + +const WO_AND = 1024 + +const WO_AUX = 64 + +const WO_EQ = 2 + +const WO_EQUIV = 2048 + +const WO_GE = 32 + +const WO_GT = 4 + +const WO_IN = 1 + +const WO_IS = 128 + +const WO_ISNULL = 256 + +const WO_LE = 8 + +const WO_LT = 16 + +const WO_NOOP = 4096 + +const WO_OR = 512 + +const WO_ROWVAL = 8192 + +const WO_SINGLE = 511 + +const WRC_Abort = 2 + +const WRC_Continue = 0 + +const WRC_Prune = 1 + +const WRITE_LOCK = 2 + +type Wal = TWal + +/************** End of wal.h *************************************************/ +/************** Continuing where we left off in pager.c **********************/ + +/******************* NOTES ON THE DESIGN OF THE PAGER ************************ +** +** This comment block describes invariants that hold when using a rollback +** journal. These invariants do not apply for journal_mode=WAL, +** journal_mode=MEMORY, or journal_mode=OFF. +** +** Within this comment block, a page is deemed to have been synced +** automatically as soon as it is written when PRAGMA synchronous=OFF. +** Otherwise, the page is not synced until the xSync method of the VFS +** is called successfully on the file containing the page. +** +** Definition: A page of the database file is said to be "overwriteable" if +** one or more of the following are true about the page: +** +** (a) The original content of the page as it was at the beginning of +** the transaction has been written into the rollback journal and +** synced. +** +** (b) The page was a freelist leaf page at the start of the transaction. +** +** (c) The page number is greater than the largest page that existed in +** the database file at the start of the transaction. +** +** (1) A page of the database file is never overwritten unless one of the +** following are true: +** +** (a) The page and all other pages on the same sector are overwriteable. +** +** (b) The atomic page write optimization is enabled, and the entire +** transaction other than the update of the transaction sequence +** number consists of a single page change. +** +** (2) The content of a page written into the rollback journal exactly matches +** both the content in the database when the rollback journal was written +** and the content in the database at the beginning of the current +** transaction. +** +** (3) Writes to the database file are an integer multiple of the page size +** in length and are aligned on a page boundary. +** +** (4) Reads from the database file are either aligned on a page boundary and +** an integer multiple of the page size in length or are taken from the +** first 100 bytes of the database file. +** +** (5) All writes to the database file are synced prior to the rollback journal +** being deleted, truncated, or zeroed. +** +** (6) If a super-journal file is used, then all writes to the database file +** are synced prior to the super-journal being deleted. +** +** Definition: Two databases (or the same database at two points it time) +** are said to be "logically equivalent" if they give the same answer to +** all queries. Note in particular the content of freelist leaf +** pages can be changed arbitrarily without affecting the logical equivalence +** of the database. +** +** (7) At any time, if any subset, including the empty set and the total set, +** of the unsynced changes to a rollback journal are removed and the +** journal is rolled back, the resulting database file will be logically +** equivalent to the database file at the beginning of the transaction. +** +** (8) When a transaction is rolled back, the xTruncate method of the VFS +** is called to restore the database file to the same size it was at +** the beginning of the transaction. (In some VFSes, the xTruncate +** method is a no-op, but that does not change the fact the SQLite will +** invoke it.) +** +** (9) Whenever the database file is modified, at least one bit in the range +** of bytes from 24 through 39 inclusive will be changed prior to releasing +** the EXCLUSIVE lock, thus signaling other connections on the same +** database to flush their caches. +** +** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less +** than one billion transactions. +** +** (11) A database file is well-formed at the beginning and at the conclusion +** of every transaction. +** +** (12) An EXCLUSIVE lock is held on the database file when writing to +** the database file. +** +** (13) A SHARED lock is held on the database file while reading any +** content out of the database file. +** +******************************************************************************/ + +/* +** Macros for troubleshooting. Normally turned off + */ + +/* +** The following two macros are used within the PAGERTRACE() macros above +** to print out file-descriptors. +** +** PAGERID() takes a pointer to a Pager struct as its argument. The +** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file +** struct as its argument. + */ + +/* +** The Pager.eState variable stores the current 'state' of a pager. A +** pager may be in any one of the seven states shown in the following +** state diagram. +** +** OPEN <------+------+ +** | | | +** V | | +** +---------> READER-------+ | +** | | | +** | V | +** |<-------WRITER_LOCKED------> ERROR +** | | ^ +** | V | +** |<------WRITER_CACHEMOD-------->| +** | | | +** | V | +** |<-------WRITER_DBMOD---------->| +** | | | +** | V | +** +<------WRITER_FINISHED-------->+ +** +** +** List of state transitions and the C [function] that performs each: +** +** OPEN -> READER [sqlite3PagerSharedLock] +** READER -> OPEN [pager_unlock] +** +** READER -> WRITER_LOCKED [sqlite3PagerBegin] +** WRITER_LOCKED -> WRITER_CACHEMOD [pager_open_journal] +** WRITER_CACHEMOD -> WRITER_DBMOD [syncJournal] +** WRITER_DBMOD -> WRITER_FINISHED [sqlite3PagerCommitPhaseOne] +** WRITER_*** -> READER [pager_end_transaction] +** +** WRITER_*** -> ERROR [pager_error] +** ERROR -> OPEN [pager_unlock] +** +** +** OPEN: +** +** The pager starts up in this state. Nothing is guaranteed in this +** state - the file may or may not be locked and the database size is +** unknown. The database may not be read or written. +** +** * No read or write transaction is active. +** * Any lock, or no lock at all, may be held on the database file. +** * The dbSize, dbOrigSize and dbFileSize variables may not be trusted. +** +** READER: +** +** In this state all the requirements for reading the database in +** rollback (non-WAL) mode are met. Unless the pager is (or recently +** was) in exclusive-locking mode, a user-level read transaction is +** open. The database size is known in this state. +** +** A connection running with locking_mode=normal enters this state when +** it opens a read-transaction on the database and returns to state +** OPEN after the read-transaction is completed. However a connection +** running in locking_mode=exclusive (including temp databases) remains in +** this state even after the read-transaction is closed. The only way +** a locking_mode=exclusive connection can transition from READER to OPEN +** is via the ERROR state (see below). +** +** * A read transaction may be active (but a write-transaction cannot). +** * A SHARED or greater lock is held on the database file. +** * The dbSize variable may be trusted (even if a user-level read +** transaction is not active). The dbOrigSize and dbFileSize variables +** may not be trusted at this point. +** * If the database is a WAL database, then the WAL connection is open. +** * Even if a read-transaction is not open, it is guaranteed that +** there is no hot-journal in the file-system. +** +** WRITER_LOCKED: +** +** The pager moves to this state from READER when a write-transaction +** is first opened on the database. In WRITER_LOCKED state, all locks +** required to start a write-transaction are held, but no actual +** modifications to the cache or database have taken place. +** +** In rollback mode, a RESERVED or (if the transaction was opened with +** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when +** moving to this state, but the journal file is not written to or opened +** to in this state. If the transaction is committed or rolled back while +** in WRITER_LOCKED state, all that is required is to unlock the database +** file. +** +** IN WAL mode, WalBeginWriteTransaction() is called to lock the log file. +** If the connection is running with locking_mode=exclusive, an attempt +** is made to obtain an EXCLUSIVE lock on the database file. +** +** * A write transaction is active. +** * If the connection is open in rollback-mode, a RESERVED or greater +** lock is held on the database file. +** * If the connection is open in WAL-mode, a WAL write transaction +** is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully +** called). +** * The dbSize, dbOrigSize and dbFileSize variables are all valid. +** * The contents of the pager cache have not been modified. +** * The journal file may or may not be open. +** * Nothing (not even the first header) has been written to the journal. +** +** WRITER_CACHEMOD: +** +** A pager moves from WRITER_LOCKED state to this state when a page is +** first modified by the upper layer. In rollback mode the journal file +** is opened (if it is not already open) and a header written to the +** start of it. The database file on disk has not been modified. +** +** * A write transaction is active. +** * A RESERVED or greater lock is held on the database file. +** * The journal file is open and the first header has been written +** to it, but the header has not been synced to disk. +** * The contents of the page cache have been modified. +** +** WRITER_DBMOD: +** +** The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state +** when it modifies the contents of the database file. WAL connections +** never enter this state (since they do not modify the database file, +** just the log file). +** +** * A write transaction is active. +** * An EXCLUSIVE or greater lock is held on the database file. +** * The journal file is open and the first header has been written +** and synced to disk. +** * The contents of the page cache have been modified (and possibly +** written to disk). +** +** WRITER_FINISHED: +** +** It is not possible for a WAL connection to enter this state. +** +** A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD +** state after the entire transaction has been successfully written into the +** database file. In this state the transaction may be committed simply +** by finalizing the journal file. Once in WRITER_FINISHED state, it is +** not possible to modify the database further. At this point, the upper +** layer must either commit or rollback the transaction. +** +** * A write transaction is active. +** * An EXCLUSIVE or greater lock is held on the database file. +** * All writing and syncing of journal and database data has finished. +** If no error occurred, all that remains is to finalize the journal to +** commit the transaction. If an error did occur, the caller will need +** to rollback the transaction. +** +** ERROR: +** +** The ERROR state is entered when an IO or disk-full error (including +** SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it +** difficult to be sure that the in-memory pager state (cache contents, +** db size etc.) are consistent with the contents of the file-system. +** +** Temporary pager files may enter the ERROR state, but in-memory pagers +** cannot. +** +** For example, if an IO error occurs while performing a rollback, +** the contents of the page-cache may be left in an inconsistent state. +** At this point it would be dangerous to change back to READER state +** (as usually happens after a rollback). Any subsequent readers might +** report database corruption (due to the inconsistent cache), and if +** they upgrade to writers, they may inadvertently corrupt the database +** file. To avoid this hazard, the pager switches into the ERROR state +** instead of READER following such an error. +** +** Once it has entered the ERROR state, any attempt to use the pager +** to read or write data returns an error. Eventually, once all +** outstanding transactions have been abandoned, the pager is able to +** transition back to OPEN state, discarding the contents of the +** page-cache and any other in-memory state at the same time. Everything +** is reloaded from disk (and, if necessary, hot-journal rollback performed) +** when a read-transaction is next opened on the pager (transitioning +** the pager into READER state). At that point the system has recovered +** from the error. +** +** Specifically, the pager jumps into the ERROR state if: +** +** 1. An error occurs while attempting a rollback. This happens in +** function sqlite3PagerRollback(). +** +** 2. An error occurs while attempting to finalize a journal file +** following a commit in function sqlite3PagerCommitPhaseTwo(). +** +** 3. An error occurs while attempting to write to the journal or +** database file in function pagerStress() in order to free up +** memory. +** +** In other cases, the error is returned to the b-tree layer. The b-tree +** layer then attempts a rollback operation. If the error condition +** persists, the pager enters the ERROR state via condition (1) above. +** +** Condition (3) is necessary because it can be triggered by a read-only +** statement executed within a transaction. In this case, if the error +** code were simply returned to the user, the b-tree layer would not +** automatically attempt a rollback, as it assumes that an error in a +** read-only statement cannot leave the pager in an internally inconsistent +** state. +** +** * The Pager.errCode variable is set to something other than SQLITE_OK. +** * There are one or more outstanding references to pages (after the +** last reference is dropped the pager should move back to OPEN state). +** * The pager is not an in-memory pager. +** +** +** Notes: +** +** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the +** connection is open in WAL mode. A WAL connection is always in one +** of the first four states. +** +** * Normally, a connection open in exclusive mode is never in PAGER_OPEN +** state. There are two exceptions: immediately after exclusive-mode has +** been turned on (and before any read or write transactions are +** executed), and when the pager is leaving the "error state". +** +** * See also: assert_pager_state(). + */ + +/* +** The Pager.eLock variable is almost always set to one of the +** following locking-states, according to the lock currently held on +** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK. +** This variable is kept up to date as locks are taken and released by +** the pagerLockDb() and pagerUnlockDb() wrappers. +** +** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY +** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not +** the operation was successful. In these circumstances pagerLockDb() and +** pagerUnlockDb() take a conservative approach - eLock is always updated +** when unlocking the file, and only updated when locking the file if the +** VFS call is successful. This way, the Pager.eLock variable may be set +** to a less exclusive (lower) value than the lock that is actually held +** at the system level, but it is never set to a more exclusive value. +** +** This is usually safe. If an xUnlock fails or appears to fail, there may +** be a few redundant xLock() calls or a lock may be held for longer than +** required, but nothing really goes wrong. +** +** The exception is when the database file is unlocked as the pager moves +** from ERROR to OPEN state. At this point there may be a hot-journal file +** in the file-system that needs to be rolled back (as part of an OPEN->SHARED +** transition, by the same pager or any other). If the call to xUnlock() +** fails at this point and the pager is left holding an EXCLUSIVE lock, this +** can confuse the call to xCheckReservedLock() call made later as part +** of hot-journal detection. +** +** xCheckReservedLock() is defined as returning true "if there is a RESERVED +** lock held by this process or any others". So xCheckReservedLock may +** return true because the caller itself is holding an EXCLUSIVE lock (but +** doesn't know it because of a previous error in xUnlock). If this happens +** a hot-journal may be mistaken for a journal being created by an active +** transaction in another process, causing SQLite to read from the database +** without rolling it back. +** +** To work around this, if a call to xUnlock() fails when unlocking the +** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It +** is only changed back to a real locking state after a successful call +** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition +** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK +** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE +** lock on the database file before attempting to roll it back. See function +** PagerSharedLock() for more detail. +** +** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in +** PAGER_OPEN state. + */ + +/* +** The maximum allowed sector size. 64KiB. If the xSectorsize() method +** returns a value larger than this, then MAX_SECTOR_SIZE is used instead. +** This could conceivably cause corruption following a power failure on +** such a system. This is currently an undocumented limit. + */ + +type WalCkptInfo = TWalCkptInfo + +/* +** Candidate values for Wal.exclusiveMode. + */ + +/* +** Possible values for WAL.readOnly + */ + +type WalHashLoc = TWalHashLoc + +type WalIndexHdr = TWalIndexHdr + +type WalIterator = TWalIterator + +type WalSegment = TWalSegment + +type WalWriter = TWalWriter + +type Walker = TWalker + +type WhereAndInfo = TWhereAndInfo + +type WhereClause = TWhereClause + +type WhereConst = TWhereConst + +type WhereInfo = TWhereInfo + +type WhereLevel = TWhereLevel + +type WhereLoop = TWhereLoop + +type WhereLoopBuilder = TWhereLoopBuilder + +type WhereMaskSet = TWhereMaskSet + +type WhereMemBlock = TWhereMemBlock + +type WhereOrCost = TWhereOrCost + +type WhereOrInfo = TWhereOrInfo + +type WhereOrSet = TWhereOrSet + +type WherePath = TWherePath + +type WhereRightJoin = TWhereRightJoin + +/* +** Bitmasks for the operators on WhereTerm objects. These are all +** operators that are of interest to the query planner. An +** OR-ed combination of these values can be used when searching for +** particular WhereTerms within a WhereClause. +** +** Value constraints: +** WO_EQ == SQLITE_INDEX_CONSTRAINT_EQ +** WO_LT == SQLITE_INDEX_CONSTRAINT_LT +** WO_LE == SQLITE_INDEX_CONSTRAINT_LE +** WO_GT == SQLITE_INDEX_CONSTRAINT_GT +** WO_GE == SQLITE_INDEX_CONSTRAINT_GE + */ + +/* +** These are definitions of bits in the WhereLoop.wsFlags field. +** The particular combination of bits in each WhereLoop help to +** determine the algorithm that WhereLoop represents. + */ + +/************** End of whereInt.h ********************************************/ +/************** Continuing where we left off in wherecode.c ******************/ + +type WhereScan = TWhereScan + +type WhereTerm = TWhereTerm + +type Window = TWindow + +type WindowCodeArg = TWindowCodeArg + +type WindowCsrAndReg = TWindowCsrAndReg + +type WindowRewrite = TWindowRewrite + +type With = TWith + +const XN_EXPR = -2 + +const XN_ROWID = -1 + +// C documentation +// +// /* +// ** Return the number of times the Step function of an aggregate has been +// ** called. +// ** +// ** This function is deprecated. Do not use it for new code. It is +// ** provide only to avoid breaking legacy code. New aggregate function +// ** implementations should keep their own counts within their aggregate +// ** context. +// */ +func Xsqlite3_aggregate_count(tls *libc.TLS, p uintptr) (r int32) { + return (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpMem)).Fn +} + +// C documentation +// +// /* +// ** Register a function to be invoked prior to each autovacuum that +// ** determines the number of pages to vacuum. +// */ +func Xsqlite3_autovacuum_pages(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr, __ccgo_fp_xDestructor uintptr) (r int32) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if (*Tsqlite3)(unsafe.Pointer(db)).FxAutovacDestr != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxAutovacDestr})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpAutovacPagesArg) + } + (*Tsqlite3)(unsafe.Pointer(db)).FxAutovacPages = __ccgo_fp_xCallback + (*Tsqlite3)(unsafe.Pointer(db)).FpAutovacPagesArg = pArg + (*Tsqlite3)(unsafe.Pointer(db)).FxAutovacDestr = __ccgo_fp_xDestructor + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Bind a blob value to an SQL statement variable. +// */ +func Xsqlite3_bind_blob(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, __ccgo_fp_xDel uintptr) (r int32) { + return _bindText(tls, pStmt, i, zData, int64(nData), __ccgo_fp_xDel, uint8(0)) +} + +func Xsqlite3_bind_int(tls *libc.TLS, p uintptr, i int32, iValue int32) (r int32) { + return Xsqlite3_bind_int64(tls, p, i, int64(iValue)) +} + +// C documentation +// +// /* +// ** Return the number of wildcards that can be potentially bound to. +// ** This routine is added to support DBD::SQLite. +// */ +func Xsqlite3_bind_parameter_count(tls *libc.TLS, pStmt uintptr) (r int32) { + var p uintptr + var v1 int32 + _, _ = p, v1 + p = pStmt + if p != 0 { + v1 = int32((*TVdbe)(unsafe.Pointer(p)).FnVar) + } else { + v1 = 0 + } + return v1 +} + +func Xsqlite3_bind_parameter_index(tls *libc.TLS, pStmt uintptr, zName uintptr) (r int32) { + return _sqlite3VdbeParameterIndex(tls, pStmt, zName, _sqlite3Strlen30(tls, zName)) +} + +// C documentation +// +// /* +// ** Return the name of a wildcard parameter. Return NULL if the index +// ** is out of range or if the wildcard is unnamed. +// ** +// ** The result is always UTF-8. +// */ +func Xsqlite3_bind_parameter_name(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) { + var p uintptr + _ = p + p = pStmt + if p == uintptr(0) { + return uintptr(0) + } + return _sqlite3VListNumToName(tls, (*TVdbe)(unsafe.Pointer(p)).FpVList, i) +} + +func Xsqlite3_bind_text(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, __ccgo_fp_xDel uintptr) (r int32) { + return _bindText(tls, pStmt, i, zData, int64(nData), __ccgo_fp_xDel, uint8(SQLITE_UTF8)) +} + +// C documentation +// +// /* +// ** Query a blob handle for the size of the data. +// ** +// ** The Incrblob.nByte field is fixed for the lifetime of the Incrblob +// ** so no mutex is required for access. +// */ +func Xsqlite3_blob_bytes(tls *libc.TLS, pBlob uintptr) (r int32) { + var p uintptr + var v1 int32 + _, _ = p, v1 + p = pBlob + if p != 0 && (*TIncrblob)(unsafe.Pointer(p)).FpStmt != 0 { + v1 = (*TIncrblob)(unsafe.Pointer(p)).FnByte + } else { + v1 = 0 + } + return v1 +} + +// C documentation +// +// /* +// ** Close a blob handle that was previously created using +// ** sqlite3_blob_open(). +// */ +func Xsqlite3_blob_close(tls *libc.TLS, pBlob uintptr) (r int32) { + var db, p, pStmt uintptr + var rc int32 + _, _, _, _ = db, p, pStmt, rc + p = pBlob + if p != 0 { + pStmt = (*TIncrblob)(unsafe.Pointer(p)).FpStmt + db = (*TIncrblob)(unsafe.Pointer(p)).Fdb + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3DbFree(tls, db, p) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + rc = Xsqlite3_finalize(tls, pStmt) + } else { + rc = SQLITE_OK + } + return rc +} + +// C documentation +// +// /* +// ** Read data from a blob handle. +// */ +func Xsqlite3_blob_read(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int32) (r int32) { + return _blobReadWrite(tls, pBlob, z, n, iOffset, __ccgo_fp(_sqlite3BtreePayloadChecked)) +} + +// C documentation +// +// /* +// ** Write data to a blob handle. +// */ +func Xsqlite3_blob_write(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int32) (r int32) { + return _blobReadWrite(tls, pBlob, z, n, iOffset, __ccgo_fp(_sqlite3BtreePutData)) +} + +// C documentation +// +// /* +// ** This routine sets the busy callback for an Sqlite database to the +// ** given callback function with the given argument. +// */ +func Xsqlite3_busy_handler(tls *libc.TLS, db uintptr, __ccgo_fp_xBusy uintptr, pArg uintptr) (r int32) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FxBusyHandler = __ccgo_fp_xBusy + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FpBusyArg = pArg + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout = 0 + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This routine installs a default busy handler that waits for the +// ** specified number of milliseconds before returning 0. +// */ +func Xsqlite3_busy_timeout(tls *libc.TLS, db uintptr, ms int32) (r int32) { + if ms > 0 { + Xsqlite3_busy_handler(tls, db, __ccgo_fp(_sqliteDefaultBusyCallback), db) + (*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout = ms + } else { + Xsqlite3_busy_handler(tls, db, uintptr(0), uintptr(0)) + } + return SQLITE_OK +} + +func Xsqlite3_changes(tls *libc.TLS, db uintptr) (r int32) { + return int32(Xsqlite3_changes64(tls, db)) +} + +// C documentation +// +// /* +// ** Return the number of changes in the most recent call to sqlite3_exec(). +// */ +func Xsqlite3_changes64(tls *libc.TLS, db uintptr) (r Tsqlite3_int64) { + return (*Tsqlite3)(unsafe.Pointer(db)).FnChange +} + +// C documentation +// +// /* +// ** Two variations on the public interface for closing a database +// ** connection. The sqlite3_close() version returns SQLITE_BUSY and +// ** leaves the connection open if there are unfinalized prepared +// ** statements or unfinished sqlite3_backups. The sqlite3_close_v2() +// ** version forces the connection to become a zombie if there are +// ** unclosed resources, and arranges for deallocation when the last +// ** prepare statement or sqlite3_backup closes. +// */ +func Xsqlite3_close(tls *libc.TLS, db uintptr) (r int32) { + return _sqlite3Close(tls, db, 0) +} + +func Xsqlite3_close_v2(tls *libc.TLS, db uintptr) (r int32) { + return _sqlite3Close(tls, db, int32(1)) +} + +// C documentation +// +// /* +// ** Register a collation sequence factory callback with the database handle +// ** db. Replace any previously installed collation sequence factory. +// */ +func Xsqlite3_collation_needed(tls *libc.TLS, db uintptr, pCollNeededArg uintptr, __ccgo_fp_xCollNeeded uintptr) (r int32) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + (*Tsqlite3)(unsafe.Pointer(db)).FxCollNeeded = __ccgo_fp_xCollNeeded + (*Tsqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Register a collation sequence factory callback with the database handle +// ** db. Replace any previously installed collation sequence factory. +// */ +func Xsqlite3_collation_needed16(tls *libc.TLS, db uintptr, pCollNeededArg uintptr, __ccgo_fp_xCollNeeded16 uintptr) (r int32) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + (*Tsqlite3)(unsafe.Pointer(db)).FxCollNeeded = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = __ccgo_fp_xCollNeeded16 + (*Tsqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /**************************** sqlite3_column_ ******************************* +// ** The following routines are used to access elements of the current row +// ** in the result set. +// */ +func Xsqlite3_column_blob(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) { + var val uintptr + _ = val + val = Xsqlite3_value_blob(tls, _columnMem(tls, pStmt, i)) + /* Even though there is no encoding conversion, value_blob() might + ** need to call malloc() to expand the result of a zeroblob() + ** expression. + */ + _columnMallocFailure(tls, pStmt) + return val +} + +func Xsqlite3_column_bytes(tls *libc.TLS, pStmt uintptr, i int32) (r int32) { + var val int32 + _ = val + val = Xsqlite3_value_bytes(tls, _columnMem(tls, pStmt, i)) + _columnMallocFailure(tls, pStmt) + return val +} + +func Xsqlite3_column_bytes16(tls *libc.TLS, pStmt uintptr, i int32) (r int32) { + var val int32 + _ = val + val = Xsqlite3_value_bytes16(tls, _columnMem(tls, pStmt, i)) + _columnMallocFailure(tls, pStmt) + return val +} + +// C documentation +// +// /* +// ** Return the name of the database from which a result column derives. +// ** NULL is returned if the result column is an expression or constant or +// ** anything else which is not an unambiguous reference to a database column. +// */ +func Xsqlite3_column_database_name(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, 0, int32(COLNAME_DATABASE)) +} + +func Xsqlite3_column_database_name16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, int32(1), int32(COLNAME_DATABASE)) +} + +// C documentation +// +// /* +// ** Return the column declaration type (if applicable) of the 'i'th column +// ** of the result set of SQL statement pStmt. +// */ +func Xsqlite3_column_decltype(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, 0, int32(COLNAME_DECLTYPE)) +} + +func Xsqlite3_column_decltype16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, int32(1), int32(COLNAME_DECLTYPE)) +} + +func Xsqlite3_column_double(tls *libc.TLS, pStmt uintptr, i int32) (r float64) { + var val float64 + _ = val + val = Xsqlite3_value_double(tls, _columnMem(tls, pStmt, i)) + _columnMallocFailure(tls, pStmt) + return val +} + +func Xsqlite3_column_int(tls *libc.TLS, pStmt uintptr, i int32) (r int32) { + var val int32 + _ = val + val = Xsqlite3_value_int(tls, _columnMem(tls, pStmt, i)) + _columnMallocFailure(tls, pStmt) + return val +} + +func Xsqlite3_column_int64(tls *libc.TLS, pStmt uintptr, i int32) (r Tsqlite_int64) { + var val Tsqlite_int64 + _ = val + val = Xsqlite3_value_int64(tls, _columnMem(tls, pStmt, i)) + _columnMallocFailure(tls, pStmt) + return val +} + +// C documentation +// +// /* +// ** Return the name of the Nth column of the result set returned by SQL +// ** statement pStmt. +// */ +func Xsqlite3_column_name(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, 0, COLNAME_NAME) +} + +func Xsqlite3_column_name16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, int32(1), COLNAME_NAME) +} + +/* +** Constraint: If you have ENABLE_COLUMN_METADATA then you must +** not define OMIT_DECLTYPE. + */ + +// C documentation +// +// /* +// ** Return the name of the table column from which a result column derives. +// ** NULL is returned if the result column is an expression or constant or +// ** anything else which is not an unambiguous reference to a database column. +// */ +func Xsqlite3_column_origin_name(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, 0, int32(COLNAME_COLUMN)) +} + +func Xsqlite3_column_origin_name16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, int32(1), int32(COLNAME_COLUMN)) +} + +// C documentation +// +// /* +// ** Return the name of the table from which a result column derives. +// ** NULL is returned if the result column is an expression or constant or +// ** anything else which is not an unambiguous reference to a database column. +// */ +func Xsqlite3_column_table_name(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, 0, int32(COLNAME_TABLE)) +} + +func Xsqlite3_column_table_name16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) { + return _columnName(tls, pStmt, N, int32(1), int32(COLNAME_TABLE)) +} + +func Xsqlite3_column_text(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) { + var val uintptr + _ = val + val = Xsqlite3_value_text(tls, _columnMem(tls, pStmt, i)) + _columnMallocFailure(tls, pStmt) + return val +} + +func Xsqlite3_column_text16(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) { + var val uintptr + _ = val + val = Xsqlite3_value_text16(tls, _columnMem(tls, pStmt, i)) + _columnMallocFailure(tls, pStmt) + return val +} + +func Xsqlite3_column_type(tls *libc.TLS, pStmt uintptr, i int32) (r int32) { + var iType int32 + _ = iType + iType = Xsqlite3_value_type(tls, _columnMem(tls, pStmt, i)) + _columnMallocFailure(tls, pStmt) + return iType +} + +// C documentation +// +// /* +// ** Register a function to be invoked when a transaction commits. +// ** If the invoked function returns non-zero, then the commit becomes a +// ** rollback. +// */ +func Xsqlite3_commit_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) { + var pOld uintptr + _ = pOld + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pOld = (*Tsqlite3)(unsafe.Pointer(db)).FpCommitArg + (*Tsqlite3)(unsafe.Pointer(db)).FxCommitCallback = __ccgo_fp_xCallback + (*Tsqlite3)(unsafe.Pointer(db)).FpCommitArg = pArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return pOld +} + +// C documentation +// +// /* +// ** Extract the user data from a sqlite3_context structure and return a +// ** pointer to it. +// ** +// ** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface +// ** returns a copy of the pointer to the database connection (the 1st +// ** parameter) of the sqlite3_create_function() and +// ** sqlite3_create_function16() routines that originally registered the +// ** application defined function. +// */ +func Xsqlite3_context_db_handle(tls *libc.TLS, p uintptr) (r uintptr) { + return (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpOut)).Fdb +} + +// C documentation +// +// /* +// ** Register a new collation sequence with the database handle db. +// */ +func Xsqlite3_create_collation(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, __ccgo_fp_xCompare uintptr) (r int32) { + return Xsqlite3_create_collation_v2(tls, db, zName, enc, pCtx, __ccgo_fp_xCompare, uintptr(0)) +} + +// C documentation +// +// /* +// ** Create new user functions. +// */ +func Xsqlite3_create_function(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, __ccgo_fp_xSFunc uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr) (r int32) { + return _createFunctionApi(tls, db, zFunc, nArg, enc, p, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, uintptr(0), uintptr(0), uintptr(0)) +} + +func Xsqlite3_create_function_v2(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, __ccgo_fp_xSFunc uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr, __ccgo_fp_xDestroy uintptr) (r int32) { + return _createFunctionApi(tls, db, zFunc, nArg, enc, p, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, uintptr(0), uintptr(0), __ccgo_fp_xDestroy) +} + +// C documentation +// +// /* +// ** External API function used to create a new virtual-table module. +// */ +func Xsqlite3_create_module(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr) (r int32) { + return _createModule(tls, db, zName, pModule, pAux, uintptr(0)) +} + +// C documentation +// +// /* +// ** External API function used to create a new virtual-table module. +// */ +func Xsqlite3_create_module_v2(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, __ccgo_fp_xDestroy uintptr) (r int32) { + return _createModule(tls, db, zName, pModule, pAux, __ccgo_fp_xDestroy) +} + +func Xsqlite3_create_window_function(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr, __ccgo_fp_xValue uintptr, __ccgo_fp_xInverse uintptr, __ccgo_fp_xDestroy uintptr) (r int32) { + return _createFunctionApi(tls, db, zFunc, nArg, enc, p, uintptr(0), __ccgo_fp_xStep, __ccgo_fp_xFinal, __ccgo_fp_xValue, __ccgo_fp_xInverse, __ccgo_fp_xDestroy) +} + +// C documentation +// +// /* +// ** If the following global variable points to a string which is the +// ** name of a directory, then that directory will be used to store +// ** all database files specified with a relative pathname. +// ** +// ** See also the "PRAGMA data_store_directory" SQL command. +// */ +var Xsqlite3_data_directory uintptr + +/* +** When compiling the test fixture or with debugging enabled (on Win32), +** this variable being set to non-zero will cause OSTRACE macros to emit +** extra diagnostic information. + */ + +// C documentation +// +// /* +// ** Return the filename of the database associated with a database +// ** connection. +// */ +func Xsqlite3_db_filename(tls *libc.TLS, db uintptr, zDbName uintptr) (r uintptr) { + var pBt, v1 uintptr + _, _ = pBt, v1 + pBt = _sqlite3DbNameToBtree(tls, db, zDbName) + if pBt != 0 { + v1 = _sqlite3BtreeGetFilename(tls, pBt) + } else { + v1 = uintptr(0) + } + return v1 +} + +// C documentation +// +// /* +// ** Return the sqlite3* database handle to which the prepared statement given +// ** in the argument belongs. This is the same database handle that was +// ** the first argument to the sqlite3_prepare() that was used to create +// ** the statement in the first place. +// */ +func Xsqlite3_db_handle(tls *libc.TLS, pStmt uintptr) (r uintptr) { + var v1 uintptr + _ = v1 + if pStmt != 0 { + v1 = (*TVdbe)(unsafe.Pointer(pStmt)).Fdb + } else { + v1 = uintptr(0) + } + return v1 +} + +// C documentation +// +// /* +// ** Return the mutex associated with a database connection. +// */ +func Xsqlite3_db_mutex(tls *libc.TLS, db uintptr) (r uintptr) { + return (*Tsqlite3)(unsafe.Pointer(db)).Fmutex +} + +// C documentation +// +// /* +// ** Return 1 if database is read-only or 0 if read/write. Return -1 if +// ** no such database exists. +// */ +func Xsqlite3_db_readonly(tls *libc.TLS, db uintptr, zDbName uintptr) (r int32) { + var pBt uintptr + var v1 int32 + _, _ = pBt, v1 + pBt = _sqlite3DbNameToBtree(tls, db, zDbName) + if pBt != 0 { + v1 = _sqlite3BtreeIsReadonly(tls, pBt) + } else { + v1 = -int32(1) + } + return v1 +} + +// C documentation +// +// /* +// ** 32-bit variant of sqlite3_db_status64() +// */ +func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, pHighwtr uintptr, resetFlag int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* C at bp+0 */ Tsqlite3_int64 + var _ /* H at bp+8 */ Tsqlite3_int64 + _ = rc + **(**Tsqlite3_int64)(__ccgo_up(bp)) = 0 + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0 + rc = Xsqlite3_db_status64(tls, db, op, bp, bp+8, resetFlag) + if rc == 0 { + **(**int32)(__ccgo_up(pCurrent)) = int32(**(**Tsqlite3_int64)(__ccgo_up(bp)) & int64(0x7fffffff)) + **(**int32)(__ccgo_up(pHighwtr)) = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 8)) & int64(0x7fffffff)) + } + return rc +} + +// C documentation +// +// /* +// ** Enable or disable the shared pager and schema features. +// ** +// ** This routine has no effect on existing database connections. +// ** The shared cache setting effects only future calls to +// ** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2(). +// */ +func Xsqlite3_enable_shared_cache(tls *libc.TLS, enable int32) (r int32) { + _sqlite3Config.FsharedCacheEnabled = enable + return SQLITE_OK +} + +/* +** Implementation of the SQLITE_CORRUPT_PAGE() macro. Takes a single +** (MemPage*) as an argument. The (MemPage*) must not be NULL. +** +** If SQLITE_DEBUG is not defined, then this macro is equivalent to +** SQLITE_CORRUPT_BKPT. Or, if SQLITE_DEBUG is set, then the log message +** normally produced as a side-effect of SQLITE_CORRUPT_BKPT is augmented +** with the page number and filename associated with the (MemPage*). + */ + +/* Default value for SHARED_LOCK_TRACE macro if shared-cache is disabled +** or if the lock tracking is disabled. This is always the value for +** release builds. + */ + +// C documentation +// +// /* +// ** Return the most recent error code generated by an SQLite routine. If NULL is +// ** passed to this function, we assume a malloc() failed during sqlite3_open(). +// */ +func Xsqlite3_errcode(tls *libc.TLS, db uintptr) (r int32) { + if db != 0 && !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) { + return _sqlite3MisuseError(tls, int32(190018)) + } + if !(db != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(SQLITE_NOMEM) + } + return (*Tsqlite3)(unsafe.Pointer(db)).FerrCode & (*Tsqlite3)(unsafe.Pointer(db)).FerrMask +} + +// C documentation +// +// /* +// ** Return UTF-8 encoded English language explanation of the most recent +// ** error. +// */ +func Xsqlite3_errmsg(tls *libc.TLS, db uintptr) (r uintptr) { + var z, v1 uintptr + _, _ = z, v1 + if !(db != 0) { + return _sqlite3ErrStr(tls, int32(SQLITE_NOMEM)) + } + if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) { + return _sqlite3ErrStr(tls, _sqlite3MisuseError(tls, int32(189916))) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + z = _sqlite3ErrStr(tls, int32(SQLITE_NOMEM)) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FerrCode != 0 { + v1 = Xsqlite3_value_text(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr) + } else { + v1 = uintptr(0) + } + z = v1 + if z == uintptr(0) { + z = _sqlite3ErrStr(tls, (*Tsqlite3)(unsafe.Pointer(db)).FerrCode) + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return z +} + +// C documentation +// +// /* +// ** Return UTF-16 encoded English language explanation of the most recent +// ** error. +// */ +func Xsqlite3_errmsg16(tls *libc.TLS, db uintptr) (r uintptr) { + var z uintptr + _ = z + if !(db != 0) { + return uintptr(unsafe.Pointer(&_outOfMem)) + } + if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) { + return uintptr(unsafe.Pointer(&_misuse)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + z = uintptr(unsafe.Pointer(&_outOfMem)) + } else { + z = Xsqlite3_value_text16(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr) + if z == uintptr(0) { + _sqlite3ErrorWithMsg(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FerrCode, _sqlite3ErrStr(tls, (*Tsqlite3)(unsafe.Pointer(db)).FerrCode), 0) + z = Xsqlite3_value_text16(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr) + } + /* A malloc() may have failed within the call to sqlite3_value_text16() + ** above. If this is the case, then the db->mallocFailed flag needs to + ** be cleared before returning. Do this directly, instead of via + ** sqlite3ApiExit(), to avoid setting the database handle error message. + */ + _sqlite3OomClear(tls, db) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return z +} + +// C documentation +// +// /* +// ** Return the byte offset of the most recent error +// */ +func Xsqlite3_error_offset(tls *libc.TLS, db uintptr) (r int32) { + var iOffset int32 + _ = iOffset + iOffset = -int32(1) + if db != 0 && _sqlite3SafetyCheckSickOrOk(tls, db) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FerrCode != 0 { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + iOffset = (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + } + return iOffset +} + +// C documentation +// +// /* +// ** Return a string that describes the kind of error specified in the +// ** argument. For now, this simply calls the internal sqlite3ErrStr() +// ** function. +// */ +func Xsqlite3_errstr(tls *libc.TLS, rc int32) (r uintptr) { + return _sqlite3ErrStr(tls, rc) +} + +// C documentation +// +// /* +// ** Return the SQL associated with a prepared statement with +// ** bound parameters expanded. Space to hold the returned string is +// ** obtained from sqlite3_malloc(). The caller is responsible for +// ** freeing the returned string by passing it to sqlite3_free(). +// ** +// ** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of +// ** expanded bound parameters. +// */ +func Xsqlite3_expanded_sql(tls *libc.TLS, pStmt uintptr) (r uintptr) { + var p, z, zSql uintptr + _, _, _ = p, z, zSql + z = uintptr(0) + zSql = Xsqlite3_sql(tls, pStmt) + if zSql != 0 { + p = pStmt + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + z = _sqlite3VdbeExpandSql(tls, p, zSql) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + } + return z +} + +func Xsqlite3_extended_errcode(tls *libc.TLS, db uintptr) (r int32) { + if db != 0 && !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) { + return _sqlite3MisuseError(tls, int32(190027)) + } + if !(db != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(SQLITE_NOMEM) + } + return (*Tsqlite3)(unsafe.Pointer(db)).FerrCode +} + +// C documentation +// +// /* +// ** Invoke the xFileControl method on a particular database. +// */ +func Xsqlite3_file_control(tls *libc.TLS, db uintptr, zDbName uintptr, op int32, pArg uintptr) (r int32) { + var fd, pBtree, pPager uintptr + var iNew, nSave, rc int32 + _, _, _, _, _, _ = fd, iNew, nSave, pBtree, pPager, rc + rc = int32(SQLITE_ERROR) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pBtree = _sqlite3DbNameToBtree(tls, db, zDbName) + if pBtree != 0 { + _sqlite3BtreeEnter(tls, pBtree) + pPager = _sqlite3BtreePager(tls, pBtree) + fd = _sqlite3PagerFile(tls, pPager) + if op == int32(SQLITE_FCNTL_FILE_POINTER) { + **(**uintptr)(__ccgo_up(pArg)) = fd + rc = SQLITE_OK + } else { + if op == int32(SQLITE_FCNTL_VFS_POINTER) { + **(**uintptr)(__ccgo_up(pArg)) = _sqlite3PagerVfs(tls, pPager) + rc = SQLITE_OK + } else { + if op == int32(SQLITE_FCNTL_JOURNAL_POINTER) { + **(**uintptr)(__ccgo_up(pArg)) = _sqlite3PagerJrnlFile(tls, pPager) + rc = SQLITE_OK + } else { + if op == int32(SQLITE_FCNTL_DATA_VERSION) { + **(**uint32)(__ccgo_up(pArg)) = _sqlite3PagerDataVersion(tls, pPager) + rc = SQLITE_OK + } else { + if op == int32(SQLITE_FCNTL_RESERVE_BYTES) { + iNew = **(**int32)(__ccgo_up(pArg)) + **(**int32)(__ccgo_up(pArg)) = _sqlite3BtreeGetRequestedReserve(tls, pBtree) + if iNew >= 0 && iNew <= int32(255) { + _sqlite3BtreeSetPageSize(tls, pBtree, 0, iNew, 0) + } + rc = SQLITE_OK + } else { + if op == int32(SQLITE_FCNTL_RESET_CACHE) { + _sqlite3BtreeClearCache(tls, pBtree) + rc = SQLITE_OK + } else { + nSave = (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy + rc = _sqlite3OsFileControl(tls, fd, op, pArg) + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = nSave + } + } + } + } + } + } + _sqlite3BtreeLeave(tls, pBtree) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Translate a filename that was handed to a VFS routine into the corresponding +// ** database, journal, or WAL file. +// ** +// ** It is an error to pass this routine a filename string that was not +// ** passed into the VFS from the SQLite core. Doing so is similar to +// ** passing free() a pointer that was not obtained from malloc() - it is +// ** an error that we cannot easily detect but that will likely cause memory +// ** corruption. +// */ +func Xsqlite3_filename_database(tls *libc.TLS, zFilename uintptr) (r uintptr) { + if zFilename == uintptr(0) { + return uintptr(0) + } + return _databaseName(tls, zFilename) +} + +func Xsqlite3_filename_wal(tls *libc.TLS, zFilename uintptr) (r uintptr) { + zFilename = Xsqlite3_filename_journal(tls, zFilename) + if zFilename != 0 { + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + } + return zFilename +} + +// C documentation +// +// /* +// ** The following routine destroys a virtual machine that is created by +// ** the sqlite3_compile() routine. The integer returned is an SQLITE_ +// ** success/failure code that describes the result of executing the virtual +// ** machine. +// ** +// ** This routine sets the error code and string returned by +// ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). +// */ +func Xsqlite3_finalize(tls *libc.TLS, pStmt uintptr) (r int32) { + var db, v uintptr + var rc int32 + _, _, _ = db, rc, v + if pStmt == uintptr(0) { + /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL + ** pointer is a harmless no-op. */ + rc = SQLITE_OK + } else { + v = pStmt + db = (*TVdbe)(unsafe.Pointer(v)).Fdb + if _vdbeSafety(tls, v) != 0 { + return _sqlite3MisuseError(tls, int32(93666)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if (*TVdbe)(unsafe.Pointer(v)).FstartTime > 0 { + _invokeProfileCallback(tls, db, v) + } + rc = _sqlite3VdbeReset(tls, v) + _sqlite3VdbeDelete(tls, v) + rc = _sqlite3ApiExit(tls, db, rc) + _sqlite3LeaveMutexAndCloseZombie(tls, db) + } + return rc +} + +// C documentation +// +// /* +// ** Free memory previously obtained from sqlite3Malloc(). +// */ +func Xsqlite3_free(tls *libc.TLS, p uintptr) { + if p == uintptr(0) { + return + } /* IMP: R-49053-54554 */ + if _sqlite3Config.FbMemstat != 0 { + Xsqlite3_mutex_enter(tls, _mem0.Fmutex) + _sqlite3StatusDown(tls, SQLITE_STATUS_MEMORY_USED, _sqlite3MallocSize(tls, p)) + _sqlite3StatusDown(tls, int32(SQLITE_STATUS_MALLOC_COUNT), int32(1)) + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxFree})))(tls, p) + Xsqlite3_mutex_leave(tls, _mem0.Fmutex) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxFree})))(tls, p) + } +} + +// C documentation +// +// /* +// ** Free memory obtained from sqlite3_create_filename(). It is a severe +// ** error to call this routine with any parameter other than a pointer +// ** previously obtained from sqlite3_create_filename() or a NULL pointer. +// */ +func Xsqlite3_free_filename(tls *libc.TLS, p uintptr) { + if p == uintptr(0) { + return + } + p = _databaseName(tls, p) + Xsqlite3_free(tls, p-uintptr(4)) +} + +// C documentation +// +// /* +// ** Return the auxiliary data pointer, if any, for the iArg'th argument to +// ** the user-function defined by pCtx. +// ** +// ** The left-most argument is 0. +// ** +// ** Undocumented behavior: If iArg is negative then access a cache of +// ** auxiliary data pointers that is available to all functions within a +// ** single prepared statement. The iArg values must match. +// */ +func Xsqlite3_get_auxdata(tls *libc.TLS, pCtx uintptr, iArg int32) (r uintptr) { + var pAuxData uintptr + _ = pAuxData + if (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe == uintptr(0) { + return uintptr(0) + } + pAuxData = (*TVdbe)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe)).FpAuxData + for { + if !(pAuxData != 0) { + break + } + if (*TAuxData)(unsafe.Pointer(pAuxData)).FiAuxArg == iArg && ((*TAuxData)(unsafe.Pointer(pAuxData)).FiAuxOp == (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FiOp || iArg < 0) { + return (*TAuxData)(unsafe.Pointer(pAuxData)).FpAux + } + goto _1 + _1: + ; + pAuxData = (*TAuxData)(unsafe.Pointer(pAuxData)).FpNextAux + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** This function is now an anachronism. It used to be used to recover from a +// ** malloc() failure, but SQLite now does this automatically. +// */ +func Xsqlite3_global_recover(tls *libc.TLS) (r int32) { + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Set the hard heap-size limit for the library. An argument of zero +// ** disables the hard heap limit. A negative argument is a no-op used +// ** to obtain the return value without affecting the hard heap limit. +// ** +// ** The return value is the value of the hard heap limit just prior to +// ** calling this interface. +// ** +// ** Setting the hard heap limit will also activate the soft heap limit +// ** and constrain the soft heap limit to be no more than the hard heap +// ** limit. +// */ +func Xsqlite3_hard_heap_limit64(tls *libc.TLS, n Tsqlite3_int64) (r Tsqlite3_int64) { + var priorLimit Tsqlite3_int64 + var rc int32 + _, _ = priorLimit, rc + rc = Xsqlite3_initialize(tls) + if rc != 0 { + return int64(-int32(1)) + } + Xsqlite3_mutex_enter(tls, _mem0.Fmutex) + priorLimit = _mem0.FhardLimit + if n >= 0 { + _mem0.FhardLimit = n + if n < _mem0.FalarmThreshold || _mem0.FalarmThreshold == 0 { + _mem0.FalarmThreshold = n + } + } + Xsqlite3_mutex_leave(tls, _mem0.Fmutex) + return priorLimit +} + +func Xsqlite3_keyword_check(tls *libc.TLS, zName uintptr, nName int32) (r int32) { + return libc.BoolInt32(int32(TK_ID) != _sqlite3KeywordCode(tls, zName, nName)) +} + +/************** End of keywordhash.h *****************************************/ +/************** Continuing where we left off in tokenize.c *******************/ + +/* +** If X is a character that can be used in an identifier then +** IdChar(X) will be true. Otherwise it is false. +** +** For ASCII, any character with the high-order bit set is +** allowed in an identifier. For 7-bit characters, +** sqlite3IsIdChar[X] must be 1. +** +** For EBCDIC, the rules are more complex but have the same +** end result. +** +** Ticket #1066. the SQL standard does not allow '$' in the +** middle of identifiers. But many SQL implementations do. +** SQLite will allow '$' in identifiers for compatibility. +** But the feature is undocumented. + */ + +func Xsqlite3_keyword_count(tls *libc.TLS) (r int32) { + return int32(SQLITE_N_KEYWORD) +} + +// C documentation +// +// /* +// ** Return the ROWID of the most recent insert +// */ +func Xsqlite3_last_insert_rowid(tls *libc.TLS, db uintptr) (r Tsqlite_int64) { + return (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid +} + +// C documentation +// +// /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns +// ** a pointer to the to the sqlite3_version[] string constant. +// */ +func Xsqlite3_libversion(tls *libc.TLS) (r uintptr) { + return uintptr(unsafe.Pointer(&Xsqlite3_version)) +} + +/* IMPLEMENTATION-OF: R-25063-23286 The sqlite3_sourceid() function returns a +** pointer to a string constant whose value is the same as the +** SQLITE_SOURCE_ID C preprocessor macro. Except if SQLite is built using +** an edited copy of the amalgamation, then the last four characters of +** the hash might be different from SQLITE_SOURCE_ID. + */ +/* SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } */ + +// C documentation +// +// /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function +// ** returns an integer equal to SQLITE_VERSION_NUMBER. +// */ +func Xsqlite3_libversion_number(tls *libc.TLS) (r int32) { + return int32(SQLITE_VERSION_NUMBER) +} + +func Xsqlite3_load_extension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintptr, pzErrMsg uintptr) (r int32) { + var rc int32 + _ = rc + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + rc = _sqlite3LoadExtension(tls, db, zFile, zProc, pzErrMsg) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Format and write a message to the log if logging is enabled. +// */ +func Xsqlite3_log(tls *libc.TLS, iErrCode int32, zFormat uintptr, va uintptr) { + var ap Tva_list + _ = ap /* Vararg list */ + if _sqlite3Config.FxLog != 0 { + ap = va + _renderLogMsg(tls, iErrCode, zFormat, ap) + _ = ap + } +} + +func Xsqlite3_malloc64(tls *libc.TLS, n Tsqlite3_uint64) (r uintptr) { + if Xsqlite3_initialize(tls) != 0 { + return uintptr(0) + } + return _sqlite3Malloc(tls, n) +} + +// C documentation +// +// /* +// ** Deprecated external interface. It used to set an alarm callback +// ** that was invoked when memory usage grew too large. Now it is a +// ** no-op. +// */ +func Xsqlite3_memory_alarm(tls *libc.TLS, __ccgo_fp_xCallback uintptr, pArg uintptr, iThreshold Tsqlite3_int64) (r int32) { + _ = __ccgo_fp_xCallback + _ = pArg + _ = iThreshold + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return the maximum amount of memory that has ever been +// ** checked out since either the beginning of this process +// ** or since the most recent reset. +// */ +func Xsqlite3_memory_highwater(tls *libc.TLS, resetFlag int32) (r Tsqlite3_int64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* mx at bp+8 */ Tsqlite3_int64 + var _ /* res at bp+0 */ Tsqlite3_int64 + Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp, bp+8, resetFlag) + return **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) +} + +// C documentation +// +// /* +// ** Return the amount of memory currently checked out. +// */ +func Xsqlite3_memory_used(tls *libc.TLS) (r Tsqlite3_int64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* mx at bp+8 */ Tsqlite3_int64 + var _ /* res at bp+0 */ Tsqlite3_int64 + Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp, bp+8, 0) + return **(**Tsqlite3_int64)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Print into memory obtained from sqlite3_malloc()(). Omit the internal +// ** %-conversion extensions. +// */ +func Xsqlite3_mprintf(tls *libc.TLS, zFormat uintptr, va uintptr) (r uintptr) { + var ap Tva_list + var z uintptr + _, _ = ap, z + if Xsqlite3_initialize(tls) != 0 { + return uintptr(0) + } + ap = va + z = Xsqlite3_vmprintf(tls, zFormat, ap) + _ = ap + return z +} + +// C documentation +// +// /* +// ** Retrieve a pointer to a static mutex or allocate a new dynamic one. +// */ +func Xsqlite3_mutex_alloc(tls *libc.TLS, id int32) (r uintptr) { + if id <= int32(SQLITE_MUTEX_RECURSIVE) && Xsqlite3_initialize(tls) != 0 { + return uintptr(0) + } + if id > int32(SQLITE_MUTEX_RECURSIVE) && _sqlite3MutexInit(tls) != 0 { + return uintptr(0) + } + return (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexAlloc})))(tls, id) +} + +// C documentation +// +// /* +// ** Obtain the mutex p. If some other thread already has the mutex, block +// ** until it can be obtained. +// */ +func Xsqlite3_mutex_enter(tls *libc.TLS, p uintptr) { + if p != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexEnter})))(tls, p) + } +} + +// C documentation +// +// /* +// ** Free a dynamic mutex. +// */ +func Xsqlite3_mutex_free(tls *libc.TLS, p uintptr) { + if p != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexFree})))(tls, p) + } +} + +// C documentation +// +// /* +// ** The sqlite3_mutex_leave() routine exits a mutex that was previously +// ** entered by the same thread. The behavior is undefined if the mutex +// ** is not currently entered. If a NULL pointer is passed as an argument +// ** this function is a no-op. +// */ +func Xsqlite3_mutex_leave(tls *libc.TLS, p uintptr) { + if p != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexLeave})))(tls, p) + } +} + +/************** End of mutex.c ***********************************************/ +/************** Begin file mutex_noop.c **************************************/ +/* +** 2008 October 07 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the C functions that implement mutexes. +** +** This implementation in this file does not provide any mutual +** exclusion and is thus suitable for use only in applications +** that use SQLite in a single thread. The routines defined +** here are place-holders. Applications can substitute working +** mutex routines at start-time using the +** +** sqlite3_config(SQLITE_CONFIG_MUTEX,...) +** +** interface. +** +** If compiled with SQLITE_DEBUG, then additional logic is inserted +** that does error checking on mutexes to make sure they are being +** called correctly. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another +// ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. +// */ +func Xsqlite3_mutex_try(tls *libc.TLS, p uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if p != 0 { + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexTry})))(tls, p) + } + return rc +} + +// C documentation +// +// /* +// ** Return a pointer to the next prepared statement after pStmt associated +// ** with database connection pDb. If pStmt is NULL, return the first +// ** prepared statement for the database connection. Return NULL if there +// ** are no more. +// */ +func Xsqlite3_next_stmt(tls *libc.TLS, pDb uintptr, pStmt uintptr) (r uintptr) { + var pNext uintptr + _ = pNext + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(pDb)).Fmutex) + if pStmt == uintptr(0) { + pNext = (*Tsqlite3)(unsafe.Pointer(pDb)).FpVdbe + } else { + pNext = (*TVdbe)(unsafe.Pointer(pStmt)).FpVNext + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(pDb)).Fmutex) + return pNext +} + +// C documentation +// +// /* +// ** Two versions of the official API. Legacy and new use. In the legacy +// ** version, the original SQL text is not saved in the prepared statement +// ** and so if a schema change occurs, SQLITE_SCHEMA is returned by +// ** sqlite3_step(). In the new version, the original SQL text is retained +// ** and the statement is automatically recompiled if an schema change +// ** occurs. +// */ +func Xsqlite3_prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) { + var rc int32 + _ = rc + rc = _sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(0), uintptr(0), ppStmt, pzTail) + /* VERIFY: F13021 */ + return rc +} + +// C documentation +// +// /* +// ** Two versions of the official API. Legacy and new use. In the legacy +// ** version, the original SQL text is not saved in the prepared statement +// ** and so if a schema change occurs, SQLITE_SCHEMA is returned by +// ** sqlite3_step(). In the new version, the original SQL text is retained +// ** and the statement is automatically recompiled if an schema change +// ** occurs. +// */ +func Xsqlite3_prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) { + var rc int32 + _ = rc + rc = _sqlite3Prepare16(tls, db, zSql, nBytes, uint32(0), ppStmt, pzTail) + /* VERIFY: F13021 */ + return rc +} + +func Xsqlite3_prepare16_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) { + var rc int32 + _ = rc + rc = _sqlite3Prepare16(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL), ppStmt, pzTail) + /* VERIFY: F13021 */ + return rc +} + +func Xsqlite3_prepare16_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) (r int32) { + var rc int32 + _ = rc + rc = _sqlite3Prepare16(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL)|prepFlags&uint32(SQLITE_PREPARE_MASK), ppStmt, pzTail) + /* VERIFY: F13021 */ + return rc +} + +/************** End of prepare.c *********************************************/ +/************** Begin file select.c ******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains C code routines that are called by the parser +** to handle SELECT statements in SQLite. + */ +/* #include "sqliteInt.h" */ + +func Xsqlite3_prepare_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) { + var rc int32 + _ = rc + /* EVIDENCE-OF: R-37923-12173 The sqlite3_prepare_v2() interface works + ** exactly the same as sqlite3_prepare_v3() with a zero prepFlags + ** parameter. + ** + ** Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 */ + rc = _sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL), uintptr(0), ppStmt, pzTail) + return rc +} + +func Xsqlite3_prepare_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) (r int32) { + var rc int32 + _ = rc + /* EVIDENCE-OF: R-56861-42673 sqlite3_prepare_v3() differs from + ** sqlite3_prepare_v2() only in having the extra prepFlags parameter, + ** which is a bit array consisting of zero or more of the + ** SQLITE_PREPARE_* flags. + ** + ** Proof by comparison to the implementation of sqlite3_prepare_v2() + ** directly above. */ + rc = _sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL)|prepFlags&uint32(SQLITE_PREPARE_MASK), uintptr(0), ppStmt, pzTail) + return rc +} + +// C documentation +// +// /* +// ** This function is designed to be called from within a pre-update callback +// ** only. +// */ +func Xsqlite3_preupdate_blobwrite(tls *libc.TLS, db uintptr) (r int32) { + var p uintptr + var v1 int32 + _, _ = p, v1 + p = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate + if p != 0 { + v1 = (*TPreUpdate)(unsafe.Pointer(p)).FiBlobWrite + } else { + v1 = -int32(1) + } + return v1 +} + +// C documentation +// +// /* +// ** This function is designed to be called from within a pre-update callback +// ** only. It returns zero if the change that caused the callback was made +// ** immediately by a user SQL statement. Or, if the change was made by a +// ** trigger program, it returns the number of trigger programs currently +// ** on the stack (1 for a top-level trigger, 2 for a trigger fired by a +// ** top-level trigger etc.). +// ** +// ** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL +// ** or SET DEFAULT action is considered a trigger. +// */ +func Xsqlite3_preupdate_depth(tls *libc.TLS, db uintptr) (r int32) { + var p uintptr + var v1 int32 + _, _ = p, v1 + p = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate + if p != 0 { + v1 = (*TVdbe)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).Fv)).FnFrame + } else { + v1 = 0 + } + return v1 +} + +// C documentation +// +// /* +// ** Register a callback to be invoked each time a row is updated, +// ** inserted or deleted using this database connection. +// */ +func Xsqlite3_preupdate_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) { + var pRet uintptr + _ = pRet + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pRet = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdateArg + (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback = __ccgo_fp_xCallback + (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdateArg = pArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return pRet +} + +func Xsqlite3_realloc64(tls *libc.TLS, pOld uintptr, n Tsqlite3_uint64) (r uintptr) { + if Xsqlite3_initialize(tls) != 0 { + return uintptr(0) + } + return _sqlite3Realloc(tls, pOld, n) +} + +// C documentation +// +// /* +// ** Attempt to release up to n bytes of non-essential memory currently +// ** held by SQLite. An example of non-essential memory is memory used to +// ** cache database pages that are not currently in use. +// */ +func Xsqlite3_release_memory(tls *libc.TLS, n int32) (r int32) { + return _sqlite3PcacheReleaseMemory(tls, n) +} + +/* +** Default value of the hard heap limit. 0 means "no limit". + */ + +// C documentation +// +// /* +// ** Terminate the current execution of an SQL statement and reset it +// ** back to its starting state so that it can be reused. A success code from +// ** the prior execution is returned. +// ** +// ** This routine sets the error code and string returned by +// ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). +// */ +func Xsqlite3_reset(tls *libc.TLS, pStmt uintptr) (r int32) { + var db, v uintptr + var rc int32 + _, _, _ = db, rc, v + if pStmt == uintptr(0) { + rc = SQLITE_OK + } else { + v = pStmt + db = (*TVdbe)(unsafe.Pointer(v)).Fdb + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if (*TVdbe)(unsafe.Pointer(v)).FstartTime > 0 { + _invokeProfileCallback(tls, db, v) + } + rc = _sqlite3VdbeReset(tls, v) + _sqlite3VdbeRewind(tls, v) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + } + return rc +} + +// C documentation +// +// /* +// ** Reset the automatic extension loading mechanism. +// */ +func Xsqlite3_reset_auto_extension(tls *libc.TLS) { + var mutex uintptr + _ = mutex + if Xsqlite3_initialize(tls) == SQLITE_OK { + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + Xsqlite3_mutex_enter(tls, mutex) + Xsqlite3_free(tls, _sqlite3Autoext.FaExt) + _sqlite3Autoext.FaExt = uintptr(0) + _sqlite3Autoext.FnExt = uint32(0) + Xsqlite3_mutex_leave(tls, mutex) + } +} + +func Xsqlite3_result_blob(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, __ccgo_fp_xDel uintptr) { + _setResultStrOrError(tls, pCtx, z, n, uint8(0), __ccgo_fp_xDel) +} + +func Xsqlite3_result_double(tls *libc.TLS, pCtx uintptr, rVal float64) { + _sqlite3VdbeMemSetDouble(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, rVal) +} + +func Xsqlite3_result_error(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) { + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = int32(SQLITE_ERROR) + _sqlite3VdbeMemSetStr(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, int64(n), uint8(SQLITE_UTF8), uintptr(-libc.Int32FromInt32(1))) +} + +// C documentation +// +// /* An SQLITE_NOMEM error. */ +func Xsqlite3_result_error_nomem(tls *libc.TLS, pCtx uintptr) { + _sqlite3VdbeMemSetNull(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut) + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = int32(SQLITE_NOMEM) + _sqlite3OomFault(tls, (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fdb) +} + +func Xsqlite3_result_int(tls *libc.TLS, pCtx uintptr, iVal int32) { + _sqlite3VdbeMemSetInt64(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, int64(iVal)) +} + +func Xsqlite3_result_int64(tls *libc.TLS, pCtx uintptr, iVal Ti64) { + _sqlite3VdbeMemSetInt64(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, iVal) +} + +func Xsqlite3_result_null(tls *libc.TLS, pCtx uintptr) { + _sqlite3VdbeMemSetNull(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut) +} + +func Xsqlite3_result_pointer(tls *libc.TLS, pCtx uintptr, pPtr uintptr, zPType uintptr, __ccgo_fp_xDestructor uintptr) { + var pOut uintptr + _ = pOut + pOut = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut + _sqlite3VdbeMemRelease(tls, pOut) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + _sqlite3VdbeMemSetPointer(tls, pOut, pPtr, zPType, __ccgo_fp_xDestructor) +} + +func Xsqlite3_result_text(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, __ccgo_fp_xDel uintptr) { + _setResultStrOrError(tls, pCtx, z, n, uint8(SQLITE_UTF8), __ccgo_fp_xDel) +} + +// C documentation +// +// /* +// ** Register a callback to be invoked each time a transaction is rolled +// ** back by this database connection. +// */ +func Xsqlite3_rollback_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) { + var pRet uintptr + _ = pRet + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pRet = (*Tsqlite3)(unsafe.Pointer(db)).FpRollbackArg + (*Tsqlite3)(unsafe.Pointer(db)).FxRollbackCallback = __ccgo_fp_xCallback + (*Tsqlite3)(unsafe.Pointer(db)).FpRollbackArg = pArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return pRet +} + +// C documentation +// +// /* +// ** Set or clear the access authorization function. +// ** +// ** The access authorization function is be called during the compilation +// ** phase to verify that the user has read and/or write access permission on +// ** various fields of the database. The first argument to the auth function +// ** is a copy of the 3rd argument to this routine. The second argument +// ** to the auth function is one of these constants: +// ** +// ** SQLITE_CREATE_INDEX +// ** SQLITE_CREATE_TABLE +// ** SQLITE_CREATE_TEMP_INDEX +// ** SQLITE_CREATE_TEMP_TABLE +// ** SQLITE_CREATE_TEMP_TRIGGER +// ** SQLITE_CREATE_TEMP_VIEW +// ** SQLITE_CREATE_TRIGGER +// ** SQLITE_CREATE_VIEW +// ** SQLITE_DELETE +// ** SQLITE_DROP_INDEX +// ** SQLITE_DROP_TABLE +// ** SQLITE_DROP_TEMP_INDEX +// ** SQLITE_DROP_TEMP_TABLE +// ** SQLITE_DROP_TEMP_TRIGGER +// ** SQLITE_DROP_TEMP_VIEW +// ** SQLITE_DROP_TRIGGER +// ** SQLITE_DROP_VIEW +// ** SQLITE_INSERT +// ** SQLITE_PRAGMA +// ** SQLITE_READ +// ** SQLITE_SELECT +// ** SQLITE_TRANSACTION +// ** SQLITE_UPDATE +// ** +// ** The third and fourth arguments to the auth function are the name of +// ** the table and the column that are being accessed. The auth function +// ** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE. If +// ** SQLITE_OK is returned, it means that access is allowed. SQLITE_DENY +// ** means that the SQL statement will never-run - the sqlite3_exec() call +// ** will return with an error. SQLITE_IGNORE means that the SQL statement +// ** should run but attempts to read the specified column will return NULL +// ** and attempts to write the column will be ignored. +// ** +// ** Setting the auth function to NULL disables this hook. The default +// ** setting of the auth function is NULL. +// */ +func Xsqlite3_set_authorizer(tls *libc.TLS, db uintptr, __ccgo_fp_xAuth uintptr, pArg uintptr) (r int32) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = __ccgo_fp_xAuth + (*Tsqlite3)(unsafe.Pointer(db)).FpAuthArg = pArg + _sqlite3ExpirePreparedStatements(tls, db, int32(1)) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Set the value returned by the sqlite3_last_insert_rowid() API function. +// */ +func Xsqlite3_set_last_insert_rowid(tls *libc.TLS, db uintptr, iRowid Tsqlite3_int64) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = iRowid + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) +} + +// C documentation +// +// /* +// ** Set the setlk timeout value. +// */ +func Xsqlite3_setlk_timeout(tls *libc.TLS, db uintptr, ms int32, flags int32) (r int32) { + if ms < -int32(1) { + return int32(SQLITE_RANGE) + } + _ = db + _ = flags + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Sleep for a little while. Return the amount of time slept. +// */ +func Xsqlite3_sleep(tls *libc.TLS, ms int32) (r int32) { + var pVfs uintptr + var rc, v1 int32 + _, _, _ = pVfs, rc, v1 + pVfs = Xsqlite3_vfs_find(tls, uintptr(0)) + if pVfs == uintptr(0) { + return 0 + } + /* This function works in milliseconds, but the underlying OsSleep() + ** API uses microseconds. Hence the 1000's. + */ + if ms < 0 { + v1 = 0 + } else { + v1 = int32(1000) * ms + } + rc = _sqlite3OsSleep(tls, pVfs, v1) / int32(1000) + return rc +} + +// C documentation +// +// /* +// ** Return a +ve value if snapshot p1 is newer than p2. A -ve value if +// ** p1 is older than p2 and zero if p1 and p2 are the same snapshot. +// */ +func Xsqlite3_snapshot_cmp(tls *libc.TLS, p1 uintptr, p2 uintptr) (r int32) { + var pHdr1, pHdr2 uintptr + _, _ = pHdr1, pHdr2 + pHdr1 = p1 + pHdr2 = p2 + /* aSalt[0] is a copy of the value stored in the wal file header. It + ** is incremented each time the wal file is restarted. */ + if **(**Tu32)(__ccgo_up(pHdr1 + 32)) < **(**Tu32)(__ccgo_up(pHdr2 + 32)) { + return -int32(1) + } + if **(**Tu32)(__ccgo_up(pHdr1 + 32)) > **(**Tu32)(__ccgo_up(pHdr2 + 32)) { + return +libc.Int32FromInt32(1) + } + if (*TWalIndexHdr)(unsafe.Pointer(pHdr1)).FmxFrame < (*TWalIndexHdr)(unsafe.Pointer(pHdr2)).FmxFrame { + return -int32(1) + } + if (*TWalIndexHdr)(unsafe.Pointer(pHdr1)).FmxFrame > (*TWalIndexHdr)(unsafe.Pointer(pHdr2)).FmxFrame { + return +libc.Int32FromInt32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Free a snapshot handle obtained from sqlite3_snapshot_get(). +// */ +func Xsqlite3_snapshot_free(tls *libc.TLS, pSnapshot uintptr) { + Xsqlite3_free(tls, pSnapshot) +} + +func Xsqlite3_soft_heap_limit(tls *libc.TLS, n int32) { + if n < 0 { + n = 0 + } + Xsqlite3_soft_heap_limit64(tls, int64(n)) +} + +// C documentation +// +// /* +// ** Return the SQL associated with a prepared statement +// */ +func Xsqlite3_sql(tls *libc.TLS, pStmt uintptr) (r uintptr) { + var p, v1 uintptr + _, _ = p, v1 + p = pStmt + if p != 0 { + v1 = (*TVdbe)(unsafe.Pointer(p)).FzSql + } else { + v1 = uintptr(0) + } + return v1 +} + +func Xsqlite3_status(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uintptr, resetFlag int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* iCur at bp+0 */ Tsqlite3_int64 + var _ /* iHwtr at bp+8 */ Tsqlite3_int64 + _ = rc + **(**Tsqlite3_int64)(__ccgo_up(bp)) = 0 + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0 + rc = Xsqlite3_status64(tls, op, bp, bp+8, resetFlag) + if rc == 0 { + **(**int32)(__ccgo_up(pCurrent)) = int32(**(**Tsqlite3_int64)(__ccgo_up(bp))) + **(**int32)(__ccgo_up(pHighwater)) = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 8))) + } + return rc +} + +// C documentation +// +// /* +// ** This is the top-level implementation of sqlite3_step(). Call +// ** sqlite3Step() to do most of the work. If a schema error occurs, +// ** call sqlite3Reprepare() and try again. +// */ +func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) (r int32) { + var cnt, rc, savedPc, v1, v2 int32 + var db, v, zErr uintptr + var v3 bool + _, _, _, _, _, _, _, _, _ = cnt, db, rc, savedPc, v, zErr, v1, v2, v3 + rc = SQLITE_OK /* Result from sqlite3Step() */ + v = pStmt /* the prepared statement */ + cnt = 0 /* The database connection */ + if _vdbeSafetyNotNull(tls, v) != 0 { + return _sqlite3MisuseError(tls, int32(94478)) + } + db = (*TVdbe)(unsafe.Pointer(v)).Fdb + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + for { + v1 = _sqlite3Step(tls, v) + rc = v1 + if v3 = v1 == int32(SQLITE_SCHEMA); v3 { + v2 = cnt + cnt = cnt + 1 + } + if !(v3 && v2 < int32(SQLITE_MAX_SCHEMA_RETRY)) { + break + } + savedPc = (*TVdbe)(unsafe.Pointer(v)).Fpc + rc = _sqlite3Reprepare(tls, v) + if rc != SQLITE_OK { + /* This case occurs after failing to recompile an sql statement. + ** The error message from the SQL compiler has already been loaded + ** into the database handle. This block copies the error message + ** from the database handle into the statement and sets the statement + ** program counter to 0 to ensure that when the statement is + ** finalized or reset the parser error message is available via + ** sqlite3_errmsg() and sqlite3_errcode(). + */ + zErr = Xsqlite3_value_text(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr) + _sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(v)).FzErrMsg) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + (*TVdbe)(unsafe.Pointer(v)).FzErrMsg = _sqlite3DbStrDup(tls, db, zErr) + v1 = _sqlite3ApiExit(tls, db, rc) + rc = v1 + (*TVdbe)(unsafe.Pointer(v)).Frc = v1 + } else { + (*TVdbe)(unsafe.Pointer(v)).FzErrMsg = uintptr(0) + v1 = libc.Int32FromInt32(SQLITE_NOMEM) + rc = v1 + (*TVdbe)(unsafe.Pointer(v)).Frc = v1 + } + break + } + Xsqlite3_reset(tls, pStmt) + if savedPc >= 0 { + /* Setting minWriteFileFormat to 254 is a signal to the OP_Init and + ** OP_Trace opcodes to *not* perform SQLITE_TRACE_STMT because it has + ** already been done once on a prior invocation that failed due to + ** SQLITE_SCHEMA. tag-20220401a */ + (*TVdbe)(unsafe.Pointer(v)).FminWriteFileFormat = uint8(254) + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Append the complete text of zero-terminated string z[] to the p string. +// */ +func Xsqlite3_str_appendall(tls *libc.TLS, p uintptr, z uintptr) { + Xsqlite3_str_append(tls, p, z, _sqlite3Strlen30(tls, z)) +} + +// C documentation +// +// /* +// ** variable-argument wrapper around sqlite3_str_vappendf(). The bFlags argument +// ** can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats. +// */ +func Xsqlite3_str_appendf(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) { + var ap Tva_list + _ = ap + ap = va + Xsqlite3_str_vappendf(tls, p, zFormat, ap) + _ = ap +} + +/***************************************************************************** +** Reference counted string/blob storage +*****************************************************************************/ + +// C documentation +// +// /* Finalize a string created using sqlite3_str_new(). +// */ +func Xsqlite3_str_finish(tls *libc.TLS, p uintptr) (r uintptr) { + var z uintptr + _ = z + if p != uintptr(0) && p != uintptr(unsafe.Pointer(&_sqlite3OomStr)) { + z = _sqlite3StrAccumFinish(tls, p) + Xsqlite3_free(tls, p) + } else { + z = uintptr(0) + } + return z +} + +// C documentation +// +// /* +// ** Destroy a dynamically allocate sqlite3_str object and all +// ** of its content, all in one call. +// */ +func Xsqlite3_str_free(tls *libc.TLS, p uintptr) { + if p != uintptr(0) && p != uintptr(unsafe.Pointer(&_sqlite3OomStr)) { + Xsqlite3_str_reset(tls, p) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** The sqlite3_strglob() interface. Return 0 on a match (like strcmp()) and +// ** non-zero if there is no match. +// */ +func Xsqlite3_strglob(tls *libc.TLS, zGlobPattern uintptr, zString uintptr) (r int32) { + if zString == uintptr(0) { + return libc.BoolInt32(zGlobPattern != uintptr(0)) + } else { + if zGlobPattern == uintptr(0) { + return int32(1) + } else { + return _patternCompare(tls, zGlobPattern, zString, uintptr(unsafe.Pointer(&_globInfo)), uint32('[')) + } + } + return r +} + +// C documentation +// +// /* +// ** Some systems have stricmp(). Others have strcasecmp(). Because +// ** there is no consistency, we will define our own. +// ** +// ** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and +// ** sqlite3_strnicmp() APIs allow applications and extensions to compare +// ** the contents of two buffers containing UTF-8 strings in a +// ** case-independent fashion, using the same definition of "case +// ** independence" that SQLite uses internally when comparing identifiers. +// */ +func Xsqlite3_stricmp(tls *libc.TLS, zLeft uintptr, zRight uintptr) (r int32) { + var v1 int32 + _ = v1 + if zLeft == uintptr(0) { + if zRight != 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 + } else { + if zRight == uintptr(0) { + return int32(1) + } + } + return _sqlite3StrICmp(tls, zLeft, zRight) +} + +// C documentation +// +// /* +// ** The sqlite3_strlike() interface. Return 0 on a match and non-zero for +// ** a miss - like strcmp(). +// */ +func Xsqlite3_strlike(tls *libc.TLS, zPattern uintptr, zStr uintptr, esc uint32) (r int32) { + if zStr == uintptr(0) { + return libc.BoolInt32(zPattern != uintptr(0)) + } else { + if zPattern == uintptr(0) { + return int32(1) + } else { + return _patternCompare(tls, zPattern, zStr, uintptr(unsafe.Pointer(&_likeInfoNorm)), esc) + } + } + return r +} + +/* +** Count the number of times that the LIKE operator (or GLOB which is +** just a variation of LIKE) gets called. This is used for testing +** only. + */ + +func Xsqlite3_system_errno(tls *libc.TLS, db uintptr) (r int32) { + var v1 int32 + _ = v1 + if db != 0 { + v1 = (*Tsqlite3)(unsafe.Pointer(db)).FiSysErrno + } else { + v1 = 0 + } + return v1 +} + +// C documentation +// +// /* +// ** This is a convenience routine that makes sure that all thread-specific +// ** data for this thread has been deallocated. +// ** +// ** SQLite no longer uses thread-specific data so this routine is now a +// ** no-op. It is retained for historical compatibility. +// */ +func Xsqlite3_thread_cleanup(tls *libc.TLS) { +} + +// C documentation +// +// /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns +// ** zero if and only if SQLite was compiled with mutexing code omitted due to +// ** the SQLITE_THREADSAFE compile-time option being set to 0. +// */ +func Xsqlite3_threadsafe(tls *libc.TLS) (r int32) { + return int32(SQLITE_THREADSAFE) +} + +func Xsqlite3_total_changes(tls *libc.TLS, db uintptr) (r int32) { + return int32(Xsqlite3_total_changes64(tls, db)) +} + +// C documentation +// +// /* +// ** Return the number of changes since the database handle was opened. +// */ +func Xsqlite3_total_changes64(tls *libc.TLS, db uintptr) (r Tsqlite3_int64) { + return (*Tsqlite3)(unsafe.Pointer(db)).FnTotalChange +} + +// C documentation +// +// /* +// ** Register a callback to be invoked each time a row is updated, +// ** inserted or deleted using this database connection. +// */ +func Xsqlite3_update_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) { + var pRet uintptr + _ = pRet + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pRet = (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg + (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback = __ccgo_fp_xCallback + (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg = pArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return pRet +} + +// C documentation +// +// /* +// ** Return a 64-bit integer value for a query parameter. +// */ +func Xsqlite3_uri_int64(tls *libc.TLS, zFilename uintptr, zParam uintptr, bDflt Tsqlite3_int64) (r Tsqlite3_int64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var z uintptr + var _ /* v at bp+0 */ Tsqlite3_int64 + _ = z + z = Xsqlite3_uri_parameter(tls, zFilename, zParam) + if z != 0 && _sqlite3DecOrHexToI64(tls, z, bp) == 0 { + bDflt = **(**Tsqlite3_int64)(__ccgo_up(bp)) + } + return bDflt +} + +// C documentation +// +// /* +// ** This is a utility routine, useful to VFS implementations, that checks +// ** to see if a database file was a URI that contained a specific query +// ** parameter, and if so obtains the value of the query parameter. +// ** +// ** The zFilename argument is the filename pointer passed into the xOpen() +// ** method of a VFS implementation. The zParam argument is the name of the +// ** query parameter we seek. This routine returns the value of the zParam +// ** parameter if it exists. If the parameter does not exist, this routine +// ** returns a NULL pointer. +// */ +func Xsqlite3_uri_parameter(tls *libc.TLS, zFilename uintptr, zParam uintptr) (r uintptr) { + if zFilename == uintptr(0) || zParam == uintptr(0) { + return uintptr(0) + } + zFilename = _databaseName(tls, zFilename) + return _uriParameter(tls, zFilename, zParam) +} + +// C documentation +// +// /* +// ** Extract the user data from a sqlite3_context structure and return a +// ** pointer to it. +// */ +func Xsqlite3_user_data(tls *libc.TLS, p uintptr) (r uintptr) { + return (*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpFunc)).FpUserData +} + +func Xsqlite3_value_bytes(tls *libc.TLS, pVal uintptr) (r int32) { + return _sqlite3ValueBytes(tls, pVal, uint8(SQLITE_UTF8)) +} + +func Xsqlite3_value_double(tls *libc.TLS, pVal uintptr) (r float64) { + return _sqlite3VdbeRealValue(tls, pVal) +} + +// C documentation +// +// /* Destroy an sqlite3_value object previously obtained from +// ** sqlite3_value_dup(). +// */ +func Xsqlite3_value_free(tls *libc.TLS, pOld uintptr) { + _sqlite3ValueFree(tls, pOld) +} + +func Xsqlite3_value_int(tls *libc.TLS, pVal uintptr) (r int32) { + return int32(_sqlite3VdbeIntValue(tls, pVal)) +} + +func Xsqlite3_value_int64(tls *libc.TLS, pVal uintptr) (r Tsqlite_int64) { + return _sqlite3VdbeIntValue(tls, pVal) +} + +// C documentation +// +// /* +// ** Try to convert the type of a function argument or a result column +// ** into a numeric representation. Use either INTEGER or REAL whichever +// ** is appropriate. But only do the conversion if it is possible without +// ** loss of information and return the revised type of the argument. +// */ +func Xsqlite3_value_numeric_type(tls *libc.TLS, pVal uintptr) (r int32) { + var eType int32 + var pMem uintptr + _, _ = eType, pMem + eType = Xsqlite3_value_type(tls, pVal) + if eType == int32(SQLITE_TEXT) { + pMem = pVal + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TMem)(unsafe.Pointer(pMem)).Fdb)).Fmutex) + _applyNumericAffinity(tls, pMem, 0) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TMem)(unsafe.Pointer(pMem)).Fdb)).Fmutex) + eType = Xsqlite3_value_type(tls, pVal) + } + return eType +} + +func Xsqlite3_value_text(tls *libc.TLS, pVal uintptr) (r uintptr) { + return _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF8)) +} + +func Xsqlite3_value_text16be(tls *libc.TLS, pVal uintptr) (r uintptr) { + return _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF16BE)) +} + +func Xsqlite3_value_text16le(tls *libc.TLS, pVal uintptr) (r uintptr) { + return _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF16LE)) +} + +// C documentation +// +// /* +// ** Locate a VFS by name. If no name is given, simply return the +// ** first VFS on the list. +// */ +func Xsqlite3_vfs_find(tls *libc.TLS, zVfs uintptr) (r uintptr) { + var mutex, pVfs uintptr + var rc int32 + _, _, _ = mutex, pVfs, rc + pVfs = uintptr(0) + rc = Xsqlite3_initialize(tls) + if rc != 0 { + return uintptr(0) + } + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + Xsqlite3_mutex_enter(tls, mutex) + pVfs = _vfsList + for { + if !(pVfs != 0) { + break + } + if zVfs == uintptr(0) { + break + } + if libc.Xstrcmp(tls, zVfs, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FzName) == 0 { + break + } + goto _1 + _1: + ; + pVfs = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext + } + Xsqlite3_mutex_leave(tls, mutex) + return pVfs +} + +// C documentation +// +// /* +// ** Register a VFS with the system. It is harmless to register the same +// ** VFS multiple times. The new VFS becomes the default if makeDflt is +// ** true. +// */ +func Xsqlite3_vfs_register(tls *libc.TLS, pVfs uintptr, makeDflt int32) (r int32) { + var mutex uintptr + var rc int32 + _, _ = mutex, rc + rc = Xsqlite3_initialize(tls) + if rc != 0 { + return rc + } + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + Xsqlite3_mutex_enter(tls, mutex) + _vfsUnlink(tls, pVfs) + if makeDflt != 0 || _vfsList == uintptr(0) { + (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext = _vfsList + _vfsList = pVfs + } else { + (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext = (*Tsqlite3_vfs)(unsafe.Pointer(_vfsList)).FpNext + (*Tsqlite3_vfs)(unsafe.Pointer(_vfsList)).FpNext = pVfs + } + Xsqlite3_mutex_leave(tls, mutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Unregister a VFS so that it is no longer accessible. +// */ +func Xsqlite3_vfs_unregister(tls *libc.TLS, pVfs uintptr) (r int32) { + var mutex uintptr + var rc int32 + _, _ = mutex, rc + rc = Xsqlite3_initialize(tls) + if rc != 0 { + return rc + } + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + Xsqlite3_mutex_enter(tls, mutex) + _vfsUnlink(tls, pVfs) + Xsqlite3_mutex_leave(tls, mutex) + return SQLITE_OK +} + +/************** End of os.c **************************************************/ +/************** Begin file fault.c *******************************************/ +/* +** 2008 Jan 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code to support the concept of "benign" +** malloc failures (when the xMalloc() or xRealloc() method of the +** sqlite3_mem_methods structure fails to allocate a block of memory +** and returns 0). +** +** Most malloc failures are non-benign. After they occur, SQLite +** abandons the current operation and returns an error code (usually +** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily +** fatal. For example, if a malloc fails while resizing a hash table, this +** is completely recoverable simply by not carrying out the resize. The +** hash table will continue to function normally. So a malloc failure +** during a hash table resize is a benign fault. + */ + +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** Set the iterator value pVal to point to the first value in the set. +// ** Set (*ppOut) to point to this value before returning. +// */ +func Xsqlite3_vtab_in_first(tls *libc.TLS, pVal uintptr, ppOut uintptr) (r int32) { + return _valueFromValueList(tls, pVal, ppOut, 0) +} + +// C documentation +// +// /* +// ** Set the iterator value pVal to point to the next value in the set. +// ** Set (*ppOut) to point to this value before returning. +// */ +func Xsqlite3_vtab_in_next(tls *libc.TLS, pVal uintptr, ppOut uintptr) (r int32) { + return _valueFromValueList(tls, pVal, ppOut, int32(1)) +} + +// C documentation +// +// /* +// ** If this routine is invoked from within an xColumn method of a virtual +// ** table, then it returns true if and only if the the call is during an +// ** UPDATE operation and the value of the column will not be modified +// ** by the UPDATE. +// ** +// ** If this routine is called from any context other than within the +// ** xColumn method of a virtual table, then the return value is meaningless +// ** and arbitrary. +// ** +// ** Virtual table implements might use this routine to optimize their +// ** performance by substituting a NULL result, or some other light-weight +// ** value, as a signal to the xUpdate routine that the column is unchanged. +// */ +func Xsqlite3_vtab_nochange(tls *libc.TLS, p uintptr) (r int32) { + return Xsqlite3_value_nochange(tls, (*Tsqlite3_context)(unsafe.Pointer(p)).FpOut) +} + +// C documentation +// +// /* +// ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points +// ** to contains a zero-length string, all attached databases are +// ** checkpointed. +// */ +func Xsqlite3_wal_checkpoint(tls *libc.TLS, db uintptr, zDb uintptr) (r int32) { + /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to + ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */ + return Xsqlite3_wal_checkpoint_v2(tls, db, zDb, SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0)) +} + +// C documentation +// +// /* +// ** Register a callback to be invoked each time a transaction is written +// ** into the write-ahead-log by this database connection. +// */ +func Xsqlite3_wal_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) { + var pRet uintptr + _ = pRet + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pRet = (*Tsqlite3)(unsafe.Pointer(db)).FpWalArg + (*Tsqlite3)(unsafe.Pointer(db)).FxWalCallback = __ccgo_fp_xCallback + (*Tsqlite3)(unsafe.Pointer(db)).FpWalArg = pArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return pRet +} + +// C documentation +// +// /* +// ** Add the changeset currently stored in buffer pData, size nData bytes, +// ** to changeset-group p. +// */ +func Xsqlite3changegroup_add(tls *libc.TLS, pGrp uintptr, nData int32, pData uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pIter at bp+0 */ uintptr + _ = rc /* Return code */ + rc = Xsqlite3changeset_start(tls, bp, nData, pData) + if rc == SQLITE_OK { + rc = _sessionChangesetToHash(tls, **(**uintptr)(__ccgo_up(bp)), pGrp, 0) + } + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Add a single change to a changeset-group. +// */ +func Xsqlite3changegroup_add_change(tls *libc.TLS, pGrp uintptr, pIter uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiCurrent == (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiNext || (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Frc != SQLITE_OK || (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbInvert != 0 { + /* Iterator does not point to any valid entry or is an INVERT iterator. */ + rc = int32(SQLITE_ERROR) + } else { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FbNoDiscard = int32(1) + rc = _sessionOneChangeIterToHash(tls, pGrp, pIter, 0) + } + return rc +} + +// C documentation +// +// /* +// ** Streaming versions of changegroup_add(). +// */ +func Xsqlite3changegroup_add_strm(tls *libc.TLS, pGrp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pIter at bp+0 */ uintptr + _ = rc /* Return code */ + rc = Xsqlite3changeset_start_strm(tls, bp, __ccgo_fp_xInput, pIn) + if rc == SQLITE_OK { + rc = _sessionChangesetToHash(tls, **(**uintptr)(__ccgo_up(bp)), pGrp, 0) + } + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Configure the change currently under construction with a real value. +// */ +func Xsqlite3changegroup_change_double(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, fVal float64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc, v1 int32 + var _ /* pBuf at bp+0 */ uintptr + _, _ = rc, v1 + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + v1 = _checkChangeParams(tls, pGrp, bNew, iCol, int64(9), bp) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_FLOAT) + _sessionPutDouble(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+1, fVal) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Configure the change currently under construction with an integer value. +// */ +func Xsqlite3changegroup_change_int64(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, iVal Tsqlite3_int64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc, v1 int32 + var _ /* pBuf at bp+0 */ uintptr + _, _ = rc, v1 + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + v1 = _checkChangeParams(tls, pGrp, bNew, iCol, int64(9), bp) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_INTEGER) + _sessionPutI64(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+1, iVal) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Configure the change currently under construction with a null value. +// */ +func Xsqlite3changegroup_change_null(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc, v1 int32 + var _ /* pBuf at bp+0 */ uintptr + _, _ = rc, v1 + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + v1 = _checkChangeParams(tls, pGrp, bNew, iCol, int64(1), bp) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_NULL) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Configure a changegroup object. +// */ +func Xsqlite3changegroup_config(tls *libc.TLS, pGrp uintptr, op int32, pArg uintptr) (r int32) { + var arg, rc int32 + _, _ = arg, rc + rc = SQLITE_OK + switch op { + case int32(SQLITE_CHANGEGROUP_CONFIG_PATCHSET): + arg = **(**int32)(__ccgo_up(pArg)) + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList == uintptr(0) && arg >= 0 { + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch = libc.BoolInt32(arg > 0) + } + **(**int32)(__ccgo_up(pArg)) = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch + default: + rc = int32(SQLITE_MISUSE) + break + } + return rc +} + +// C documentation +// +// /* +// ** Obtain a buffer containing a changeset representing the concatenation +// ** of all changesets added to the group so far. +// */ +func Xsqlite3changegroup_output(tls *libc.TLS, pGrp uintptr, pnData uintptr, ppData uintptr) (r int32) { + return _sessionChangegroupOutput(tls, pGrp, uintptr(0), uintptr(0), pnData, ppData) +} + +// C documentation +// +// /* +// ** Streaming versions of changegroup_output(). +// */ +func Xsqlite3changegroup_output_strm(tls *libc.TLS, pGrp uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) { + return _sessionChangegroupOutput(tls, pGrp, __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0)) +} + +// C documentation +// +// /* +// ** Apply the changeset passed via pChangeset/nChangeset to the main database +// ** attached to handle "db". Invoke the supplied conflict handler callback +// ** to resolve any conflicts encountered while applying the change. +// */ +func Xsqlite3changeset_apply(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) { + return _sessionChangesetApplyV23(tls, db, nChangeset, pChangeset, uintptr(0), uintptr(0), __ccgo_fp_xFilter, uintptr(0), __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0), 0) +} + +func Xsqlite3changeset_apply_strm(tls *libc.TLS, db uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) { + return _sessionChangesetApplyV23(tls, db, 0, uintptr(0), __ccgo_fp_xInput, pIn, __ccgo_fp_xFilter, uintptr(0), __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0), 0) +} + +// C documentation +// +// /* +// ** Apply the changeset passed via pChangeset/nChangeset to the main +// ** database attached to handle "db". +// */ +func Xsqlite3changeset_apply_v2(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) { + return _sessionChangesetApplyV23(tls, db, nChangeset, pChangeset, uintptr(0), uintptr(0), __ccgo_fp_xFilter, uintptr(0), __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags) +} + +func Xsqlite3changeset_apply_v2_strm(tls *libc.TLS, db uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) { + return _sessionChangesetApplyV23(tls, db, 0, uintptr(0), __ccgo_fp_xInput, pIn, __ccgo_fp_xFilter, uintptr(0), __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags) +} + +// C documentation +// +// /* +// ** Apply the changeset passed via pChangeset/nChangeset to the main +// ** database attached to handle "db". +// */ +func Xsqlite3changeset_apply_v3(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) { + return _sessionChangesetApplyV23(tls, db, nChangeset, pChangeset, uintptr(0), uintptr(0), uintptr(0), __ccgo_fp_xFilter, __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags) +} + +// C documentation +// +// /* +// ** Apply the changeset passed via xInput/pIn to the main database +// ** attached to handle "db". Invoke the supplied conflict handler callback +// ** to resolve any conflicts encountered while applying the change. +// */ +func Xsqlite3changeset_apply_v3_strm(tls *libc.TLS, db uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) { + return _sessionChangesetApplyV23(tls, db, 0, uintptr(0), __ccgo_fp_xInput, pIn, uintptr(0), __ccgo_fp_xFilter, __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags) +} + +// C documentation +// +// /* +// ** Combine two changesets together. +// */ +func Xsqlite3changeset_concat(tls *libc.TLS, nLeft int32, pLeft uintptr, nRight int32, pRight uintptr, pnOut uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pGrp at bp+0 */ uintptr + _ = rc + rc = Xsqlite3changegroup_new(tls, bp) + if rc == SQLITE_OK { + rc = Xsqlite3changegroup_add(tls, **(**uintptr)(__ccgo_up(bp)), nLeft, pLeft) + } + if rc == SQLITE_OK { + rc = Xsqlite3changegroup_add(tls, **(**uintptr)(__ccgo_up(bp)), nRight, pRight) + } + if rc == SQLITE_OK { + rc = Xsqlite3changegroup_output(tls, **(**uintptr)(__ccgo_up(bp)), pnOut, ppOut) + } + Xsqlite3changegroup_delete(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Streaming version of sqlite3changeset_concat(). +// */ +func Xsqlite3changeset_concat_strm(tls *libc.TLS, __ccgo_fp_xInputA uintptr, pInA uintptr, __ccgo_fp_xInputB uintptr, pInB uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pGrp at bp+0 */ uintptr + _ = rc + rc = Xsqlite3changegroup_new(tls, bp) + if rc == SQLITE_OK { + rc = Xsqlite3changegroup_add_strm(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xInputA, pInA) + } + if rc == SQLITE_OK { + rc = Xsqlite3changegroup_add_strm(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xInputB, pInB) + } + if rc == SQLITE_OK { + rc = Xsqlite3changegroup_output_strm(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xOutput, pOut) + } + Xsqlite3changegroup_delete(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** This function may only be called with a changeset iterator that has been +// ** passed to an SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT +// ** conflict-handler function. Otherwise, SQLITE_MISUSE is returned. +// ** +// ** If successful, *ppValue is set to point to an sqlite3_value structure +// ** containing the iVal'th value of the conflicting record. +// ** +// ** If value iVal is out-of-range or some other error occurs, an SQLite error +// ** code is returned. Otherwise, SQLITE_OK. +// */ +func Xsqlite3changeset_conflict(tls *libc.TLS, pIter uintptr, iVal int32, ppValue uintptr) (r int32) { + if !((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict != 0) { + return int32(SQLITE_MISUSE) + } + if iVal < 0 || iVal >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol { + return int32(SQLITE_RANGE) + } + **(**uintptr)(__ccgo_up(ppValue)) = Xsqlite3_column_value(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict, iVal) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function may only be called with an iterator passed to an +// ** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case +// ** it sets the output variable to the total number of known foreign key +// ** violations in the destination database and returns SQLITE_OK. +// ** +// ** In all other cases this function returns SQLITE_MISUSE. +// */ +func Xsqlite3changeset_fk_conflicts(tls *libc.TLS, pIter uintptr, pnOut uintptr) (r int32) { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict != 0 || (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue != 0 { + return int32(SQLITE_MISUSE) + } + **(**int32)(__ccgo_up(pnOut)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Advance an iterator created by sqlite3changeset_start() to the next +// ** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE +// ** or SQLITE_CORRUPT. +// ** +// ** This function may not be called on iterators passed to a conflict handler +// ** callback by changeset_apply(). +// */ +func Xsqlite3changeset_next(tls *libc.TLS, p uintptr) (r int32) { + return _sessionChangesetNext(tls, p, uintptr(0), uintptr(0), uintptr(0)) +} + +// C documentation +// +// /* +// ** The following function extracts information on the current change +// ** from a changeset iterator. It may only be called after changeset_next() +// ** has returned SQLITE_ROW. +// */ +func Xsqlite3changeset_op(tls *libc.TLS, pIter uintptr, pzTab uintptr, pnCol uintptr, pOp uintptr, pbIndirect uintptr) (r int32) { + **(**int32)(__ccgo_up(pOp)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop + **(**int32)(__ccgo_up(pnCol)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol + **(**uintptr)(__ccgo_up(pzTab)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab + if pbIndirect != 0 { + **(**int32)(__ccgo_up(pbIndirect)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return information regarding the PRIMARY KEY and number of columns in +// ** the database table affected by the change that pIter currently points +// ** to. This function may only be called after changeset_next() returns +// ** SQLITE_ROW. +// */ +func Xsqlite3changeset_pk(tls *libc.TLS, pIter uintptr, pabPK uintptr, pnCol uintptr) (r int32) { + **(**uintptr)(__ccgo_up(pabPK)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + if pnCol != 0 { + **(**int32)(__ccgo_up(pnCol)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Create an iterator used to iterate through the contents of a changeset. +// */ +func Xsqlite3changeset_start(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr) (r int32) { + return _sessionChangesetStart(tls, pp, uintptr(0), uintptr(0), nChangeset, pChangeset, 0, 0) +} + +// C documentation +// +// /* +// ** Streaming version of sqlite3changeset_start(). +// */ +func Xsqlite3changeset_start_strm(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr) (r int32) { + return _sessionChangesetStart(tls, pp, __ccgo_fp_xInput, pIn, 0, uintptr(0), 0, 0) +} + +func Xsqlite3changeset_start_v2(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr, flags int32) (r int32) { + var bInvert int32 + _ = bInvert + bInvert = libc.BoolInt32(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETSTART_INVERT) != 0)) + return _sessionChangesetStart(tls, pp, uintptr(0), uintptr(0), nChangeset, pChangeset, bInvert, 0) +} + +func Xsqlite3changeset_start_v2_strm(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, flags int32) (r int32) { + var bInvert int32 + _ = bInvert + bInvert = libc.BoolInt32(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETSTART_INVERT) != 0)) + return _sessionChangesetStart(tls, pp, __ccgo_fp_xInput, pIn, 0, uintptr(0), bInvert, 0) +} + +// C documentation +// +// /* +// ** Return permyriadage progress indications for the two main stages of +// ** an RBU update. +// */ +func Xsqlite3rbu_bp_progress(tls *libc.TLS, p uintptr, pnOne uintptr, pnTwo uintptr) { + var MAX_PROGRESS int32 + _ = MAX_PROGRESS + MAX_PROGRESS = int32(10000) + switch (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage { + case int32(RBU_STAGE_OAL): + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep > 0 { + **(**int32)(__ccgo_up(pnOne)) = int32(int64(MAX_PROGRESS) * (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress / (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep) + } else { + **(**int32)(__ccgo_up(pnOne)) = -int32(1) + } + **(**int32)(__ccgo_up(pnTwo)) = 0 + case int32(RBU_STAGE_MOVE): + **(**int32)(__ccgo_up(pnOne)) = MAX_PROGRESS + **(**int32)(__ccgo_up(pnTwo)) = 0 + case int32(RBU_STAGE_CKPT): + **(**int32)(__ccgo_up(pnOne)) = MAX_PROGRESS + **(**int32)(__ccgo_up(pnTwo)) = int32(int64(MAX_PROGRESS) * int64((*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep) / int64((*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame)) + case int32(RBU_STAGE_DONE): + **(**int32)(__ccgo_up(pnOne)) = MAX_PROGRESS + **(**int32)(__ccgo_up(pnTwo)) = MAX_PROGRESS + default: + } +} + +// C documentation +// +// /* +// ** Return the database handle used by pRbu. +// */ +func Xsqlite3rbu_db(tls *libc.TLS, pRbu uintptr, bRbu int32) (r uintptr) { + var db, v1 uintptr + _, _ = db, v1 + db = uintptr(0) + if pRbu != 0 { + if bRbu != 0 { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FdbRbu + } else { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FdbMain + } + db = v1 + } + return db +} + +// C documentation +// +// /* +// ** Deregister and destroy an RBU vfs created by an earlier call to +// ** sqlite3rbu_create_vfs(). +// */ +func Xsqlite3rbu_destroy_vfs(tls *libc.TLS, zName uintptr) { + var pVfs uintptr + _ = pVfs + pVfs = Xsqlite3_vfs_find(tls, zName) + if pVfs != 0 && (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen == __ccgo_fp(_rbuVfsOpen) { + Xsqlite3_mutex_free(tls, (*Trbu_vfs)(unsafe.Pointer(pVfs)).Fmutex) + Xsqlite3_vfs_unregister(tls, pVfs) + Xsqlite3_free(tls, pVfs) + } +} + +// C documentation +// +// /* +// ** Open and return a new RBU handle. +// */ +func Xsqlite3rbu_open(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) (r uintptr) { + if zTarget == uintptr(0) || zRbu == uintptr(0) { + return _rbuMisuseError(tls) + } + return _openRbuHandle(tls, zTarget, zRbu, zState) +} + +// C documentation +// +// /* +// ** Return the total number of key-value operations (inserts, deletes or +// ** updates) that have been performed on the target database since the +// ** current RBU update was started. +// */ +func Xsqlite3rbu_progress(tls *libc.TLS, pRbu uintptr) (r Tsqlite3_int64) { + return (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FnProgress +} + +func Xsqlite3rbu_rename_handler(tls *libc.TLS, pRbu uintptr, pArg uintptr, __ccgo_fp_xRename uintptr) { + if __ccgo_fp_xRename != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FxRename = __ccgo_fp_xRename + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FpRenameArg = pArg + } else { + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FxRename = __ccgo_fp(_xDefaultRename) + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FpRenameArg = uintptr(0) + } +} + +/************************************************************************** +** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour +** of a standard VFS in the following ways: +** +** 1. Whenever the first page of a main database file is read or +** written, the value of the change-counter cookie is stored in +** rbu_file.iCookie. Similarly, the value of the "write-version" +** database header field is stored in rbu_file.iWriteVer. This ensures +** that the values are always trustworthy within an open transaction. +** +** 2. Whenever an SQLITE_OPEN_WAL file is opened, the (rbu_file.pWalFd) +** member variable of the associated database file descriptor is set +** to point to the new file. A mutex protected linked list of all main +** db fds opened using a particular RBU VFS is maintained at +** rbu_vfs.pMain to facilitate this. +** +** 3. Using a new file-control "SQLITE_FCNTL_RBU", a main db rbu_file +** object can be marked as the target database of an RBU update. This +** turns on the following extra special behaviour: +** +** 3a. If xAccess() is called to check if there exists a *-wal file +** associated with an RBU target database currently in RBU_STAGE_OAL +** stage (preparing the *-oal file), the following special handling +** applies: +** +** * if the *-wal file does exist, return SQLITE_CANTOPEN. An RBU +** target database may not be in wal mode already. +** +** * if the *-wal file does not exist, set the output parameter to +** non-zero (to tell SQLite that it does exist) anyway. +** +** Then, when xOpen() is called to open the *-wal file associated with +** the RBU target in RBU_STAGE_OAL stage, instead of opening the *-wal +** file, the rbu vfs opens the corresponding *-oal file instead. +** +** 3b. The *-shm pages returned by xShmMap() for a target db file in +** RBU_STAGE_OAL mode are actually stored in heap memory. This is to +** avoid creating a *-shm file on disk. Additionally, xShmLock() calls +** are no-ops on target database files in RBU_STAGE_OAL mode. This is +** because assert() statements in some VFS implementations fail if +** xShmLock() is called before xShmMap(). +** +** 3c. If an EXCLUSIVE lock is attempted on a target database file in any +** mode except RBU_STAGE_DONE (all work completed and checkpointed), it +** fails with an SQLITE_BUSY error. This is to stop RBU connections +** from automatically checkpointing a *-wal (or *-oal) file from within +** sqlite3_close(). +** +** 3d. In RBU_STAGE_CAPTURE mode, all xRead() calls on the wal file, and +** all xWrite() calls on the target database file perform no IO. +** Instead the frame and page numbers that would be read and written +** are recorded. Additionally, successful attempts to obtain exclusive +** xShmLock() WRITER, CHECKPOINTER and READ0 locks on the target +** database file are recorded. xShmLock() calls to unlock the same +** locks are no-ops (so that once obtained, these locks are never +** relinquished). Finally, calls to xSync() on the target database +** file fail with SQLITE_NOTICE errors. + */ + +// C documentation +// +// /* +// ** Return the current state of the RBU vacuum or update operation. +// */ +func Xsqlite3rbu_state(tls *libc.TLS, p uintptr) (r int32) { + var aRes [6]int32 + _ = aRes + aRes = [6]int32{ + 1: int32(SQLITE_RBU_STATE_OAL), + 2: int32(SQLITE_RBU_STATE_MOVE), + 4: int32(SQLITE_RBU_STATE_CHECKPOINT), + 5: int32(SQLITE_RBU_STATE_DONE), + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != int32(SQLITE_DONE) { + return int32(SQLITE_RBU_STATE_ERROR) + } else { + return aRes[(*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage] + } + return r +} + +func Xsqlite3rbu_temp_size(tls *libc.TLS, pRbu uintptr) (r Tsqlite3_int64) { + return (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTemp +} + +/**************************************************************************/ + +/************** End of sqlite3rbu.c ******************************************/ +/************** Begin file dbstat.c ******************************************/ +/* +** 2010 July 12 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains an implementation of the "dbstat" virtual table. +** +** The dbstat virtual table is used to extract low-level storage +** information from an SQLite database in order to implement the +** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script +** for an example implementation. +** +** Additional information is available on the "dbstat.html" page of the +** official SQLite documentation. + */ + +/* #include "sqliteInt.h" ** Requires access to internal data structures ** */ + +/* +** The pager and btree modules arrange objects in memory so that there are +** always approximately 200 bytes of addressable memory following each page +** buffer. This way small buffer overreads caused by corrupt database pages +** do not cause undefined behaviour. This module pads each page buffer +** by the following number of bytes for the same purpose. + */ + +// C documentation +// +// /* +// ** Configure the aggregate temp file size limit for this RBU handle. +// */ +func Xsqlite3rbu_temp_size_limit(tls *libc.TLS, pRbu uintptr, n Tsqlite3_int64) (r Tsqlite3_int64) { + if n >= 0 { + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit = n + } + return (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit +} + +// C documentation +// +// /* +// ** Call this one or more times to configure a rebaser. +// */ +func Xsqlite3rebaser_configure(tls *libc.TLS, p uintptr, nRebase int32, pRebase uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pIter at bp+0 */ uintptr + _ = rc + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Return code */ + rc = Xsqlite3changeset_start(tls, bp, nRebase, pRebase) + if rc == SQLITE_OK { + rc = _sessionChangesetToHash(tls, **(**uintptr)(__ccgo_up(bp)), p, int32(1)) + } + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Destroy a rebaser object +// */ +func Xsqlite3rebaser_delete(tls *libc.TLS, p uintptr) { + if p != 0 { + _sessionDeleteTable(tls, uintptr(0), (*Tsqlite3_rebaser)(unsafe.Pointer(p)).Fgrp.FpList) + Xsqlite3_free(tls, (*Tsqlite3_rebaser)(unsafe.Pointer(p)).Fgrp.Frec.FaBuf) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Rebase a changeset according to current rebaser configuration +// */ +func Xsqlite3rebaser_rebase(tls *libc.TLS, p uintptr, nIn int32, pIn uintptr, pnOut uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pIter at bp+0 */ uintptr + _ = rc + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Iterator to skip through input */ + rc = Xsqlite3changeset_start(tls, bp, nIn, pIn) + if rc == SQLITE_OK { + rc = _sessionRebase(tls, p, **(**uintptr)(__ccgo_up(bp)), uintptr(0), uintptr(0), pnOut, ppOut) + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Rebase a changeset according to current rebaser configuration +// */ +func Xsqlite3rebaser_rebase_strm(tls *libc.TLS, p uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pIter at bp+0 */ uintptr + _ = rc + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Iterator to skip through input */ + rc = Xsqlite3changeset_start_strm(tls, bp, __ccgo_fp_xInput, pIn) + if rc == SQLITE_OK { + rc = _sessionRebase(tls, p, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0)) + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Obtain a changeset object containing all changes recorded by the +// ** session object passed as the first argument. +// ** +// ** It is the responsibility of the caller to eventually free the buffer +// ** using sqlite3_free(). +// */ +func Xsqlite3session_changeset(tls *libc.TLS, pSession uintptr, pnChangeset uintptr, ppChangeset uintptr) (r int32) { + var rc int32 + _ = rc + if pnChangeset == uintptr(0) || ppChangeset == uintptr(0) { + return int32(SQLITE_MISUSE) + } + rc = _sessionGenerateChangeset(tls, pSession, 0, uintptr(0), uintptr(0), pnChangeset, ppChangeset) + return rc +} + +// C documentation +// +// /* +// ** Return the maximum size of sqlite3session_changeset() output. +// */ +func Xsqlite3session_changeset_size(tls *libc.TLS, pSession uintptr) (r Tsqlite3_int64) { + return (*Tsqlite3_session)(unsafe.Pointer(pSession)).FnMaxChangesetSize +} + +// C documentation +// +// /* +// ** Streaming version of sqlite3session_changeset(). +// */ +func Xsqlite3session_changeset_strm(tls *libc.TLS, pSession uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) { + if __ccgo_fp_xOutput == uintptr(0) { + return int32(SQLITE_MISUSE) + } + return _sessionGenerateChangeset(tls, pSession, 0, __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0)) +} + +// C documentation +// +// /* +// ** Global configuration +// */ +func Xsqlite3session_config(tls *libc.TLS, op int32, pArg uintptr) (r int32) { + var pInt uintptr + var rc int32 + _, _ = pInt, rc + rc = SQLITE_OK + switch op { + case int32(SQLITE_SESSION_CONFIG_STRMSIZE): + pInt = pArg + if **(**int32)(__ccgo_up(pInt)) > 0 { + _sessions_strm_chunk_size = **(**int32)(__ccgo_up(pInt)) + } + **(**int32)(__ccgo_up(pInt)) = _sessions_strm_chunk_size + default: + rc = int32(SQLITE_MISUSE) + break + } + return rc +} + +// C documentation +// +// /* +// ** Enable or disable the session object passed as the first argument. +// */ +func Xsqlite3session_enable(tls *libc.TLS, pSession uintptr, bEnable int32) (r int32) { + var ret int32 + _ = ret + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + if bEnable >= 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnable = bEnable + } + ret = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnable + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + return ret +} + +// C documentation +// +// /* +// ** Enable or disable the session object passed as the first argument. +// */ +func Xsqlite3session_indirect(tls *libc.TLS, pSession uintptr, bIndirect int32) (r int32) { + var ret int32 + _ = ret + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + if bIndirect >= 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbIndirect = bIndirect + } + ret = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbIndirect + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + return ret +} + +// C documentation +// +// /* +// ** Return true if there have been no changes to monitored tables recorded +// ** by the session object passed as the only argument. +// */ +func Xsqlite3session_isempty(tls *libc.TLS, pSession uintptr) (r int32) { + var pTab uintptr + var ret int32 + _, _ = pTab, ret + ret = 0 + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + pTab = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable + for { + if !(pTab != 0 && ret == 0) { + break + } + ret = libc.BoolInt32((*TSessionTable)(unsafe.Pointer(pTab)).FnEntry > 0) + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + return libc.BoolInt32(ret == 0) +} + +// C documentation +// +// /* +// ** Return the amount of heap memory in use. +// */ +func Xsqlite3session_memory_used(tls *libc.TLS, pSession uintptr) (r Tsqlite3_int64) { + return (*Tsqlite3_session)(unsafe.Pointer(pSession)).FnMalloc +} + +// C documentation +// +// /* +// ** Configure the session object passed as the first argument. +// */ +func Xsqlite3session_object_config(tls *libc.TLS, pSession uintptr, op int32, pArg uintptr) (r int32) { + var iArg, iArg1, rc int32 + _, _, _ = iArg, iArg1, rc + rc = SQLITE_OK + switch op { + case int32(SQLITE_SESSION_OBJCONFIG_SIZE): + iArg = **(**int32)(__ccgo_up(pArg)) + if iArg >= 0 { + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable != 0 { + rc = int32(SQLITE_MISUSE) + } else { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize = libc.BoolInt32(iArg != 0) + } + } + **(**int32)(__ccgo_up(pArg)) = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize + case int32(SQLITE_SESSION_OBJCONFIG_ROWID): + iArg1 = **(**int32)(__ccgo_up(pArg)) + if iArg1 >= 0 { + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable != 0 { + rc = int32(SQLITE_MISUSE) + } else { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK = libc.BoolInt32(iArg1 != 0) + } + } + **(**int32)(__ccgo_up(pArg)) = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK + default: + rc = int32(SQLITE_MISUSE) + } + return rc +} + +// C documentation +// +// /* +// ** Obtain a patchset object containing all changes recorded by the +// ** session object passed as the first argument. +// ** +// ** It is the responsibility of the caller to eventually free the buffer +// ** using sqlite3_free(). +// */ +func Xsqlite3session_patchset(tls *libc.TLS, pSession uintptr, pnPatchset uintptr, ppPatchset uintptr) (r int32) { + if pnPatchset == uintptr(0) || ppPatchset == uintptr(0) { + return int32(SQLITE_MISUSE) + } + return _sessionGenerateChangeset(tls, pSession, int32(1), uintptr(0), uintptr(0), pnPatchset, ppPatchset) +} + +// C documentation +// +// /* +// ** Streaming version of sqlite3session_patchset(). +// */ +func Xsqlite3session_patchset_strm(tls *libc.TLS, pSession uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) { + if __ccgo_fp_xOutput == uintptr(0) { + return int32(SQLITE_MISUSE) + } + return _sessionGenerateChangeset(tls, pSession, int32(1), __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0)) +} + +// C documentation +// +// /* +// ** Set a table filter on a Session Object. +// */ +func Xsqlite3session_table_filter(tls *libc.TLS, pSession uintptr, __ccgo_fp_xFilter uintptr, pCtx uintptr) { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = int32(1) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpFilterCtx = pCtx + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter = __ccgo_fp_xFilter +} + +const YYGROWABLESTACK = 1 + +const YYMALLOCARGTYPE = 0 + +type YYMINORTYPE = TYYMINORTYPE + +/************* End control #defines *******************************************/ + +/* Define the yytestcase() macro to be a no-op if is not already defined +** otherwise. +** +** Applications can choose to define yytestcase() in the %include section +** to a macro that can assist in verifying code coverage. For production +** code the yytestcase() macro should be turned off. But it is useful +** for testing. + */ + +/* Macro to determine if stack space has the ability to grow using +** heap memory. + */ + +/* Guarantee a minimum number of initial stack slots. + */ + +const YYNOCODE = 322 + +const YYNOERRORRECOVERY = 1 + +const YYNRULE = 412 + +const YYNRULE_WITH_ACTION = 348 + +const YYNSTATE = 600 + +const YYNTOKEN = 187 + +const YYPARSEFREENEVERNULL = 1 + +const YYSTACKDEPTH = 50 + +const YYWILDCARD = 102 + +const YY_ACCEPT_ACTION = 1280 + +const YY_ACTTAB_COUNT = 2379 + +const YY_ERROR_ACTION = 1279 + +const YY_MAX_DSTRCTR = 319 + +const YY_MAX_REDUCE = 1693 + +const YY_MAX_SHIFT = 599 + +const YY_MAX_SHIFTREDUCE = 1278 + +const YY_MIN_DSTRCTR = 206 + +const YY_MIN_REDUCE = 1282 + +const YY_MIN_SHIFTREDUCE = 867 + +const YY_NO_ACTION = 1281 + +const YY_REDUCE_COUNT = 423 + +const YY_REDUCE_MAX = 1825 + +const YY_REDUCE_MIN = -303 + +const YY_SHIFT_COUNT = 599 + +const YY_SHIFT_MAX = 2215 + +const YY_SHIFT_MIN = 0 + +// C documentation +// +// /* +// ** A cell with the same content as pCell has just been inserted into +// ** the node pNode. This function updates the bounding box cells in +// ** all ancestor elements. +// */ +func _AdjustTree(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var cnt, rc int32 + var p, pParent uintptr + var _ /* cell at bp+0 */ TRtreeCell + var _ /* iCell at bp+48 */ int32 + _, _, _, _ = cnt, p, pParent, rc + p = pNode + cnt = 0 + for (*TRtreeNode)(unsafe.Pointer(p)).FpParent != 0 { + pParent = (*TRtreeNode)(unsafe.Pointer(p)).FpParent + cnt = cnt + 1 + if cnt > int32(100) { + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<>1]) & 0xFFFF). + ** + ** The contents of this array are generated by parsing the CaseFolding.txt + ** file distributed as part of the "Unicode Character Database". See + ** http://www.unicode.org for details. + */ +var _aEntry = [163]struct { + FiCode uint16 + Fflags uint8 + FnRange uint8 +}{ + 0: { + FiCode: uint16(65), + Fflags: uint8(14), + FnRange: uint8(26), + }, + 1: { + FiCode: uint16(181), + Fflags: uint8(64), + FnRange: uint8(1), + }, + 2: { + FiCode: uint16(192), + Fflags: uint8(14), + FnRange: uint8(23), + }, + 3: { + FiCode: uint16(216), + Fflags: uint8(14), + FnRange: uint8(7), + }, + 4: { + FiCode: uint16(256), + Fflags: uint8(1), + FnRange: uint8(48), + }, + 5: { + FiCode: uint16(306), + Fflags: uint8(1), + FnRange: uint8(6), + }, + 6: { + FiCode: uint16(313), + Fflags: uint8(1), + FnRange: uint8(16), + }, + 7: { + FiCode: uint16(330), + Fflags: uint8(1), + FnRange: uint8(46), + }, + 8: { + FiCode: uint16(376), + Fflags: uint8(116), + FnRange: uint8(1), + }, + 9: { + FiCode: uint16(377), + Fflags: uint8(1), + FnRange: uint8(6), + }, + 10: { + FiCode: uint16(383), + Fflags: uint8(104), + FnRange: uint8(1), + }, + 11: { + FiCode: uint16(385), + Fflags: uint8(50), + FnRange: uint8(1), + }, + 12: { + FiCode: uint16(386), + Fflags: uint8(1), + FnRange: uint8(4), + }, + 13: { + FiCode: uint16(390), + Fflags: uint8(44), + FnRange: uint8(1), + }, + 14: { + FiCode: uint16(391), + FnRange: uint8(1), + }, + 15: { + FiCode: uint16(393), + Fflags: uint8(42), + FnRange: uint8(2), + }, + 16: { + FiCode: uint16(395), + FnRange: uint8(1), + }, + 17: { + FiCode: uint16(398), + Fflags: uint8(32), + FnRange: uint8(1), + }, + 18: { + FiCode: uint16(399), + Fflags: uint8(38), + FnRange: uint8(1), + }, + 19: { + FiCode: uint16(400), + Fflags: uint8(40), + FnRange: uint8(1), + }, + 20: { + FiCode: uint16(401), + FnRange: uint8(1), + }, + 21: { + FiCode: uint16(403), + Fflags: uint8(42), + FnRange: uint8(1), + }, + 22: { + FiCode: uint16(404), + Fflags: uint8(46), + FnRange: uint8(1), + }, + 23: { + FiCode: uint16(406), + Fflags: uint8(52), + FnRange: uint8(1), + }, + 24: { + FiCode: uint16(407), + Fflags: uint8(48), + FnRange: uint8(1), + }, + 25: { + FiCode: uint16(408), + FnRange: uint8(1), + }, + 26: { + FiCode: uint16(412), + Fflags: uint8(52), + FnRange: uint8(1), + }, + 27: { + FiCode: uint16(413), + Fflags: uint8(54), + FnRange: uint8(1), + }, + 28: { + FiCode: uint16(415), + Fflags: uint8(56), + FnRange: uint8(1), + }, + 29: { + FiCode: uint16(416), + Fflags: uint8(1), + FnRange: uint8(6), + }, + 30: { + FiCode: uint16(422), + Fflags: uint8(60), + FnRange: uint8(1), + }, + 31: { + FiCode: uint16(423), + FnRange: uint8(1), + }, + 32: { + FiCode: uint16(425), + Fflags: uint8(60), + FnRange: uint8(1), + }, + 33: { + FiCode: uint16(428), + FnRange: uint8(1), + }, + 34: { + FiCode: uint16(430), + Fflags: uint8(60), + FnRange: uint8(1), + }, + 35: { + FiCode: uint16(431), + FnRange: uint8(1), + }, + 36: { + FiCode: uint16(433), + Fflags: uint8(58), + FnRange: uint8(2), + }, + 37: { + FiCode: uint16(435), + Fflags: uint8(1), + FnRange: uint8(4), + }, + 38: { + FiCode: uint16(439), + Fflags: uint8(62), + FnRange: uint8(1), + }, + 39: { + FiCode: uint16(440), + FnRange: uint8(1), + }, + 40: { + FiCode: uint16(444), + FnRange: uint8(1), + }, + 41: { + FiCode: uint16(452), + Fflags: uint8(2), + FnRange: uint8(1), + }, + 42: { + FiCode: uint16(453), + FnRange: uint8(1), + }, + 43: { + FiCode: uint16(455), + Fflags: uint8(2), + FnRange: uint8(1), + }, + 44: { + FiCode: uint16(456), + FnRange: uint8(1), + }, + 45: { + FiCode: uint16(458), + Fflags: uint8(2), + FnRange: uint8(1), + }, + 46: { + FiCode: uint16(459), + Fflags: uint8(1), + FnRange: uint8(18), + }, + 47: { + FiCode: uint16(478), + Fflags: uint8(1), + FnRange: uint8(18), + }, + 48: { + FiCode: uint16(497), + Fflags: uint8(2), + FnRange: uint8(1), + }, + 49: { + FiCode: uint16(498), + Fflags: uint8(1), + FnRange: uint8(4), + }, + 50: { + FiCode: uint16(502), + Fflags: uint8(122), + FnRange: uint8(1), + }, + 51: { + FiCode: uint16(503), + Fflags: uint8(134), + FnRange: uint8(1), + }, + 52: { + FiCode: uint16(504), + Fflags: uint8(1), + FnRange: uint8(40), + }, + 53: { + FiCode: uint16(544), + Fflags: uint8(110), + FnRange: uint8(1), + }, + 54: { + FiCode: uint16(546), + Fflags: uint8(1), + FnRange: uint8(18), + }, + 55: { + FiCode: uint16(570), + Fflags: uint8(70), + FnRange: uint8(1), + }, + 56: { + FiCode: uint16(571), + FnRange: uint8(1), + }, + 57: { + FiCode: uint16(573), + Fflags: uint8(108), + FnRange: uint8(1), + }, + 58: { + FiCode: uint16(574), + Fflags: uint8(68), + FnRange: uint8(1), + }, + 59: { + FiCode: uint16(577), + FnRange: uint8(1), + }, + 60: { + FiCode: uint16(579), + Fflags: uint8(106), + FnRange: uint8(1), + }, + 61: { + FiCode: uint16(580), + Fflags: uint8(28), + FnRange: uint8(1), + }, + 62: { + FiCode: uint16(581), + Fflags: uint8(30), + FnRange: uint8(1), + }, + 63: { + FiCode: uint16(582), + Fflags: uint8(1), + FnRange: uint8(10), + }, + 64: { + FiCode: uint16(837), + Fflags: uint8(36), + FnRange: uint8(1), + }, + 65: { + FiCode: uint16(880), + Fflags: uint8(1), + FnRange: uint8(4), + }, + 66: { + FiCode: uint16(886), + FnRange: uint8(1), + }, + 67: { + FiCode: uint16(902), + Fflags: uint8(18), + FnRange: uint8(1), + }, + 68: { + FiCode: uint16(904), + Fflags: uint8(16), + FnRange: uint8(3), + }, + 69: { + FiCode: uint16(908), + Fflags: uint8(26), + FnRange: uint8(1), + }, + 70: { + FiCode: uint16(910), + Fflags: uint8(24), + FnRange: uint8(2), + }, + 71: { + FiCode: uint16(913), + Fflags: uint8(14), + FnRange: uint8(17), + }, + 72: { + FiCode: uint16(931), + Fflags: uint8(14), + FnRange: uint8(9), + }, + 73: { + FiCode: uint16(962), + FnRange: uint8(1), + }, + 74: { + FiCode: uint16(975), + Fflags: uint8(4), + FnRange: uint8(1), + }, + 75: { + FiCode: uint16(976), + Fflags: uint8(140), + FnRange: uint8(1), + }, + 76: { + FiCode: uint16(977), + Fflags: uint8(142), + FnRange: uint8(1), + }, + 77: { + FiCode: uint16(981), + Fflags: uint8(146), + FnRange: uint8(1), + }, + 78: { + FiCode: uint16(982), + Fflags: uint8(144), + FnRange: uint8(1), + }, + 79: { + FiCode: uint16(984), + Fflags: uint8(1), + FnRange: uint8(24), + }, + 80: { + FiCode: uint16(1008), + Fflags: uint8(136), + FnRange: uint8(1), + }, + 81: { + FiCode: uint16(1009), + Fflags: uint8(138), + FnRange: uint8(1), + }, + 82: { + FiCode: uint16(1012), + Fflags: uint8(130), + FnRange: uint8(1), + }, + 83: { + FiCode: uint16(1013), + Fflags: uint8(128), + FnRange: uint8(1), + }, + 84: { + FiCode: uint16(1015), + FnRange: uint8(1), + }, + 85: { + FiCode: uint16(1017), + Fflags: uint8(152), + FnRange: uint8(1), + }, + 86: { + FiCode: uint16(1018), + FnRange: uint8(1), + }, + 87: { + FiCode: uint16(1021), + Fflags: uint8(110), + FnRange: uint8(3), + }, + 88: { + FiCode: uint16(1024), + Fflags: uint8(34), + FnRange: uint8(16), + }, + 89: { + FiCode: uint16(1040), + Fflags: uint8(14), + FnRange: uint8(32), + }, + 90: { + FiCode: uint16(1120), + Fflags: uint8(1), + FnRange: uint8(34), + }, + 91: { + FiCode: uint16(1162), + Fflags: uint8(1), + FnRange: uint8(54), + }, + 92: { + FiCode: uint16(1216), + Fflags: uint8(6), + FnRange: uint8(1), + }, + 93: { + FiCode: uint16(1217), + Fflags: uint8(1), + FnRange: uint8(14), + }, + 94: { + FiCode: uint16(1232), + Fflags: uint8(1), + FnRange: uint8(88), + }, + 95: { + FiCode: uint16(1329), + Fflags: uint8(22), + FnRange: uint8(38), + }, + 96: { + FiCode: uint16(4256), + Fflags: uint8(66), + FnRange: uint8(38), + }, + 97: { + FiCode: uint16(4295), + Fflags: uint8(66), + FnRange: uint8(1), + }, + 98: { + FiCode: uint16(4301), + Fflags: uint8(66), + FnRange: uint8(1), + }, + 99: { + FiCode: uint16(7680), + Fflags: uint8(1), + FnRange: uint8(150), + }, + 100: { + FiCode: uint16(7835), + Fflags: uint8(132), + FnRange: uint8(1), + }, + 101: { + FiCode: uint16(7838), + Fflags: uint8(96), + FnRange: uint8(1), + }, + 102: { + FiCode: uint16(7840), + Fflags: uint8(1), + FnRange: uint8(96), + }, + 103: { + FiCode: uint16(7944), + Fflags: uint8(150), + FnRange: uint8(8), + }, + 104: { + FiCode: uint16(7960), + Fflags: uint8(150), + FnRange: uint8(6), + }, + 105: { + FiCode: uint16(7976), + Fflags: uint8(150), + FnRange: uint8(8), + }, + 106: { + FiCode: uint16(7992), + Fflags: uint8(150), + FnRange: uint8(8), + }, + 107: { + FiCode: uint16(8008), + Fflags: uint8(150), + FnRange: uint8(6), + }, + 108: { + FiCode: uint16(8025), + Fflags: uint8(151), + FnRange: uint8(8), + }, + 109: { + FiCode: uint16(8040), + Fflags: uint8(150), + FnRange: uint8(8), + }, + 110: { + FiCode: uint16(8072), + Fflags: uint8(150), + FnRange: uint8(8), + }, + 111: { + FiCode: uint16(8088), + Fflags: uint8(150), + FnRange: uint8(8), + }, + 112: { + FiCode: uint16(8104), + Fflags: uint8(150), + FnRange: uint8(8), + }, + 113: { + FiCode: uint16(8120), + Fflags: uint8(150), + FnRange: uint8(2), + }, + 114: { + FiCode: uint16(8122), + Fflags: uint8(126), + FnRange: uint8(2), + }, + 115: { + FiCode: uint16(8124), + Fflags: uint8(148), + FnRange: uint8(1), + }, + 116: { + FiCode: uint16(8126), + Fflags: uint8(100), + FnRange: uint8(1), + }, + 117: { + FiCode: uint16(8136), + Fflags: uint8(124), + FnRange: uint8(4), + }, + 118: { + FiCode: uint16(8140), + Fflags: uint8(148), + FnRange: uint8(1), + }, + 119: { + FiCode: uint16(8152), + Fflags: uint8(150), + FnRange: uint8(2), + }, + 120: { + FiCode: uint16(8154), + Fflags: uint8(120), + FnRange: uint8(2), + }, + 121: { + FiCode: uint16(8168), + Fflags: uint8(150), + FnRange: uint8(2), + }, + 122: { + FiCode: uint16(8170), + Fflags: uint8(118), + FnRange: uint8(2), + }, + 123: { + FiCode: uint16(8172), + Fflags: uint8(152), + FnRange: uint8(1), + }, + 124: { + FiCode: uint16(8184), + Fflags: uint8(112), + FnRange: uint8(2), + }, + 125: { + FiCode: uint16(8186), + Fflags: uint8(114), + FnRange: uint8(2), + }, + 126: { + FiCode: uint16(8188), + Fflags: uint8(148), + FnRange: uint8(1), + }, + 127: { + FiCode: uint16(8486), + Fflags: uint8(98), + FnRange: uint8(1), + }, + 128: { + FiCode: uint16(8490), + Fflags: uint8(92), + FnRange: uint8(1), + }, + 129: { + FiCode: uint16(8491), + Fflags: uint8(94), + FnRange: uint8(1), + }, + 130: { + FiCode: uint16(8498), + Fflags: uint8(12), + FnRange: uint8(1), + }, + 131: { + FiCode: uint16(8544), + Fflags: uint8(8), + FnRange: uint8(16), + }, + 132: { + FiCode: uint16(8579), + FnRange: uint8(1), + }, + 133: { + FiCode: uint16(9398), + Fflags: uint8(10), + FnRange: uint8(26), + }, + 134: { + FiCode: uint16(11264), + Fflags: uint8(22), + FnRange: uint8(47), + }, + 135: { + FiCode: uint16(11360), + FnRange: uint8(1), + }, + 136: { + FiCode: uint16(11362), + Fflags: uint8(88), + FnRange: uint8(1), + }, + 137: { + FiCode: uint16(11363), + Fflags: uint8(102), + FnRange: uint8(1), + }, + 138: { + FiCode: uint16(11364), + Fflags: uint8(90), + FnRange: uint8(1), + }, + 139: { + FiCode: uint16(11367), + Fflags: uint8(1), + FnRange: uint8(6), + }, + 140: { + FiCode: uint16(11373), + Fflags: uint8(84), + FnRange: uint8(1), + }, + 141: { + FiCode: uint16(11374), + Fflags: uint8(86), + FnRange: uint8(1), + }, + 142: { + FiCode: uint16(11375), + Fflags: uint8(80), + FnRange: uint8(1), + }, + 143: { + FiCode: uint16(11376), + Fflags: uint8(82), + FnRange: uint8(1), + }, + 144: { + FiCode: uint16(11378), + FnRange: uint8(1), + }, + 145: { + FiCode: uint16(11381), + FnRange: uint8(1), + }, + 146: { + FiCode: uint16(11390), + Fflags: uint8(78), + FnRange: uint8(2), + }, + 147: { + FiCode: uint16(11392), + Fflags: uint8(1), + FnRange: uint8(100), + }, + 148: { + FiCode: uint16(11499), + Fflags: uint8(1), + FnRange: uint8(4), + }, + 149: { + FiCode: uint16(11506), + FnRange: uint8(1), + }, + 150: { + FiCode: uint16(42560), + Fflags: uint8(1), + FnRange: uint8(46), + }, + 151: { + FiCode: uint16(42624), + Fflags: uint8(1), + FnRange: uint8(24), + }, + 152: { + FiCode: uint16(42786), + Fflags: uint8(1), + FnRange: uint8(14), + }, + 153: { + FiCode: uint16(42802), + Fflags: uint8(1), + FnRange: uint8(62), + }, + 154: { + FiCode: uint16(42873), + Fflags: uint8(1), + FnRange: uint8(4), + }, + 155: { + FiCode: uint16(42877), + Fflags: uint8(76), + FnRange: uint8(1), + }, + 156: { + FiCode: uint16(42878), + Fflags: uint8(1), + FnRange: uint8(10), + }, + 157: { + FiCode: uint16(42891), + FnRange: uint8(1), + }, + 158: { + FiCode: uint16(42893), + Fflags: uint8(74), + FnRange: uint8(1), + }, + 159: { + FiCode: uint16(42896), + Fflags: uint8(1), + FnRange: uint8(4), + }, + 160: { + FiCode: uint16(42912), + Fflags: uint8(1), + FnRange: uint8(10), + }, + 161: { + FiCode: uint16(42922), + Fflags: uint8(72), + FnRange: uint8(1), + }, + 162: { + FiCode: uint16(65313), + Fflags: uint8(14), + FnRange: uint8(26), + }, +} + +var _aFts5UnicodeBlock = [17]Tu16{ + 1: uint16(1471), + 2: uint16(1753), + 3: uint16(1760), + 4: uint16(1760), + 5: uint16(1760), + 6: uint16(1760), + 7: uint16(1760), + 8: uint16(1760), + 9: uint16(1760), + 10: uint16(1760), + 11: uint16(1760), + 12: uint16(1760), + 13: uint16(1760), + 14: uint16(1760), + 15: uint16(1763), + 16: uint16(1765), +} + +var _aFts5UnicodeData = [1765]Tu16{ + 0: uint16(1025), + 1: uint16(61), + 2: uint16(117), + 3: uint16(55), + 4: uint16(117), + 5: uint16(54), + 6: uint16(50), + 7: uint16(53), + 8: uint16(57), + 9: uint16(53), + 10: uint16(49), + 11: uint16(85), + 12: uint16(333), + 13: uint16(85), + 14: uint16(121), + 15: uint16(85), + 16: uint16(841), + 17: uint16(54), + 18: uint16(53), + 19: uint16(50), + 20: uint16(56), + 21: uint16(48), + 22: uint16(56), + 23: uint16(837), + 24: uint16(54), + 25: uint16(57), + 26: uint16(50), + 27: uint16(57), + 28: uint16(1057), + 29: uint16(61), + 30: uint16(53), + 31: uint16(151), + 32: uint16(58), + 33: uint16(53), + 34: uint16(56), + 35: uint16(58), + 36: uint16(39), + 37: uint16(52), + 38: uint16(57), + 39: uint16(34), + 40: uint16(58), + 41: uint16(56), + 42: uint16(58), + 43: uint16(57), + 44: uint16(79), + 45: uint16(56), + 46: uint16(37), + 47: uint16(85), + 48: uint16(56), + 49: uint16(47), + 50: uint16(39), + 51: uint16(51), + 52: uint16(111), + 53: uint16(53), + 54: uint16(745), + 55: uint16(57), + 56: uint16(233), + 57: uint16(773), + 58: uint16(57), + 59: uint16(261), + 60: uint16(1822), + 61: uint16(37), + 62: uint16(542), + 63: uint16(37), + 64: uint16(1534), + 65: uint16(222), + 66: uint16(69), + 67: uint16(73), + 68: uint16(37), + 69: uint16(126), + 70: uint16(126), + 71: uint16(73), + 72: uint16(69), + 73: uint16(137), + 74: uint16(37), + 75: uint16(73), + 76: uint16(37), + 77: uint16(105), + 78: uint16(101), + 79: uint16(73), + 80: uint16(37), + 81: uint16(73), + 82: uint16(37), + 83: uint16(190), + 84: uint16(158), + 85: uint16(37), + 86: uint16(126), + 87: uint16(126), + 88: uint16(73), + 89: uint16(37), + 90: uint16(126), + 91: uint16(94), + 92: uint16(37), + 93: uint16(39), + 94: uint16(94), + 95: uint16(69), + 96: uint16(135), + 97: uint16(41), + 98: uint16(40), + 99: uint16(37), + 100: uint16(41), + 101: uint16(40), + 102: uint16(37), + 103: uint16(41), + 104: uint16(40), + 105: uint16(37), + 106: uint16(542), + 107: uint16(37), + 108: uint16(606), + 109: uint16(37), + 110: uint16(41), + 111: uint16(40), + 112: uint16(37), + 113: uint16(126), + 114: uint16(73), + 115: uint16(37), + 116: uint16(1886), + 117: uint16(197), + 118: uint16(73), + 119: uint16(37), + 120: uint16(73), + 121: uint16(69), + 122: uint16(126), + 123: uint16(105), + 124: uint16(37), + 125: uint16(286), + 126: uint16(2181), + 127: uint16(39), + 128: uint16(869), + 129: uint16(582), + 130: uint16(152), + 131: uint16(390), + 132: uint16(472), + 133: uint16(166), + 134: uint16(248), + 135: uint16(38), + 136: uint16(56), + 137: uint16(38), + 138: uint16(568), + 139: uint16(3596), + 140: uint16(158), + 141: uint16(38), + 142: uint16(56), + 143: uint16(94), + 144: uint16(38), + 145: uint16(101), + 146: uint16(53), + 147: uint16(88), + 148: uint16(41), + 149: uint16(53), + 150: uint16(105), + 151: uint16(41), + 152: uint16(73), + 153: uint16(37), + 154: uint16(553), + 155: uint16(297), + 156: uint16(1125), + 157: uint16(94), + 158: uint16(37), + 159: uint16(105), + 160: uint16(101), + 161: uint16(798), + 162: uint16(133), + 163: uint16(94), + 164: uint16(57), + 165: uint16(126), + 166: uint16(94), + 167: uint16(37), + 168: uint16(1641), + 169: uint16(1541), + 170: uint16(1118), + 171: uint16(58), + 172: uint16(172), + 173: uint16(75), + 174: uint16(1790), + 175: uint16(478), + 176: uint16(37), + 177: uint16(2846), + 178: uint16(1225), + 179: uint16(38), + 180: uint16(213), + 181: uint16(1253), + 182: uint16(53), + 183: uint16(49), + 184: uint16(55), + 185: uint16(1452), + 186: uint16(49), + 187: uint16(44), + 188: uint16(53), + 189: uint16(76), + 190: uint16(53), + 191: uint16(76), + 192: uint16(53), + 193: uint16(44), + 194: uint16(871), + 195: uint16(103), + 196: uint16(85), + 197: uint16(162), + 198: uint16(121), + 199: uint16(85), + 200: uint16(55), + 201: uint16(85), + 202: uint16(90), + 203: uint16(364), + 204: uint16(53), + 205: uint16(85), + 206: uint16(1031), + 207: uint16(38), + 208: uint16(327), + 209: uint16(684), + 210: uint16(333), + 211: uint16(149), + 212: uint16(71), + 213: uint16(44), + 214: uint16(3175), + 215: uint16(53), + 216: uint16(39), + 217: uint16(236), + 218: uint16(34), + 219: uint16(58), + 220: uint16(204), + 221: uint16(70), + 222: uint16(76), + 223: uint16(58), + 224: uint16(140), + 225: uint16(71), + 226: uint16(333), + 227: uint16(103), + 228: uint16(90), + 229: uint16(39), + 230: uint16(469), + 231: uint16(34), + 232: uint16(39), + 233: uint16(44), + 234: uint16(967), + 235: uint16(876), + 236: uint16(2855), + 237: uint16(364), + 238: uint16(39), + 239: uint16(333), + 240: uint16(1063), + 241: uint16(300), + 242: uint16(70), + 243: uint16(58), + 244: uint16(117), + 245: uint16(38), + 246: uint16(711), + 247: uint16(140), + 248: uint16(38), + 249: uint16(300), + 250: uint16(38), + 251: uint16(108), + 252: uint16(38), + 253: uint16(172), + 254: uint16(501), + 255: uint16(807), + 256: uint16(108), + 257: uint16(53), + 258: uint16(39), + 259: uint16(359), + 260: uint16(876), + 261: uint16(108), + 262: uint16(42), + 263: uint16(1735), + 264: uint16(44), + 265: uint16(42), + 266: uint16(44), + 267: uint16(39), + 268: uint16(106), + 269: uint16(268), + 270: uint16(138), + 271: uint16(44), + 272: uint16(74), + 273: uint16(39), + 274: uint16(236), + 275: uint16(327), + 276: uint16(76), + 277: uint16(85), + 278: uint16(333), + 279: uint16(53), + 280: uint16(38), + 281: uint16(199), + 282: uint16(231), + 283: uint16(44), + 284: uint16(74), + 285: uint16(263), + 286: uint16(71), + 287: uint16(711), + 288: uint16(231), + 289: uint16(39), + 290: uint16(135), + 291: uint16(44), + 292: uint16(39), + 293: uint16(106), + 294: uint16(140), + 295: uint16(74), + 296: uint16(74), + 297: uint16(44), + 298: uint16(39), + 299: uint16(42), + 300: uint16(71), + 301: uint16(103), + 302: uint16(76), + 303: uint16(333), + 304: uint16(71), + 305: uint16(87), + 306: uint16(207), + 307: uint16(58), + 308: uint16(55), + 309: uint16(76), + 310: uint16(42), + 311: uint16(199), + 312: uint16(71), + 313: uint16(711), + 314: uint16(231), + 315: uint16(71), + 316: uint16(71), + 317: uint16(71), + 318: uint16(44), + 319: uint16(106), + 320: uint16(76), + 321: uint16(76), + 322: uint16(108), + 323: uint16(44), + 324: uint16(135), + 325: uint16(39), + 326: uint16(333), + 327: uint16(76), + 328: uint16(103), + 329: uint16(44), + 330: uint16(76), + 331: uint16(42), + 332: uint16(295), + 333: uint16(103), + 334: uint16(711), + 335: uint16(231), + 336: uint16(71), + 337: uint16(167), + 338: uint16(44), + 339: uint16(39), + 340: uint16(106), + 341: uint16(172), + 342: uint16(76), + 343: uint16(42), + 344: uint16(74), + 345: uint16(44), + 346: uint16(39), + 347: uint16(71), + 348: uint16(76), + 349: uint16(333), + 350: uint16(53), + 351: uint16(55), + 352: uint16(44), + 353: uint16(74), + 354: uint16(263), + 355: uint16(71), + 356: uint16(711), + 357: uint16(231), + 358: uint16(71), + 359: uint16(167), + 360: uint16(44), + 361: uint16(39), + 362: uint16(42), + 363: uint16(44), + 364: uint16(42), + 365: uint16(140), + 366: uint16(74), + 367: uint16(74), + 368: uint16(44), + 369: uint16(44), + 370: uint16(42), + 371: uint16(71), + 372: uint16(103), + 373: uint16(76), + 374: uint16(333), + 375: uint16(58), + 376: uint16(39), + 377: uint16(207), + 378: uint16(44), + 379: uint16(39), + 380: uint16(199), + 381: uint16(103), + 382: uint16(135), + 383: uint16(71), + 384: uint16(39), + 385: uint16(71), + 386: uint16(71), + 387: uint16(103), + 388: uint16(391), + 389: uint16(74), + 390: uint16(44), + 391: uint16(74), + 392: uint16(106), + 393: uint16(106), + 394: uint16(44), + 395: uint16(39), + 396: uint16(42), + 397: uint16(333), + 398: uint16(111), + 399: uint16(218), + 400: uint16(55), + 401: uint16(58), + 402: uint16(106), + 403: uint16(263), + 404: uint16(103), + 405: uint16(743), + 406: uint16(327), + 407: uint16(167), + 408: uint16(39), + 409: uint16(108), + 410: uint16(138), + 411: uint16(108), + 412: uint16(140), + 413: uint16(76), + 414: uint16(71), + 415: uint16(71), + 416: uint16(76), + 417: uint16(333), + 418: uint16(239), + 419: uint16(58), + 420: uint16(74), + 421: uint16(263), + 422: uint16(103), + 423: uint16(743), + 424: uint16(327), + 425: uint16(167), + 426: uint16(44), + 427: uint16(39), + 428: uint16(42), + 429: uint16(44), + 430: uint16(170), + 431: uint16(44), + 432: uint16(74), + 433: uint16(74), + 434: uint16(76), + 435: uint16(74), + 436: uint16(39), + 437: uint16(71), + 438: uint16(76), + 439: uint16(333), + 440: uint16(71), + 441: uint16(74), + 442: uint16(263), + 443: uint16(103), + 444: uint16(1319), + 445: uint16(39), + 446: uint16(106), + 447: uint16(140), + 448: uint16(106), + 449: uint16(106), + 450: uint16(44), + 451: uint16(39), + 452: uint16(42), + 453: uint16(71), + 454: uint16(76), + 455: uint16(333), + 456: uint16(207), + 457: uint16(58), + 458: uint16(199), + 459: uint16(74), + 460: uint16(583), + 461: uint16(775), + 462: uint16(295), + 463: uint16(39), + 464: uint16(231), + 465: uint16(44), + 466: uint16(106), + 467: uint16(108), + 468: uint16(44), + 469: uint16(266), + 470: uint16(74), + 471: uint16(53), + 472: uint16(1543), + 473: uint16(44), + 474: uint16(71), + 475: uint16(236), + 476: uint16(55), + 477: uint16(199), + 478: uint16(38), + 479: uint16(268), + 480: uint16(53), + 481: uint16(333), + 482: uint16(85), + 483: uint16(71), + 484: uint16(39), + 485: uint16(71), + 486: uint16(39), + 487: uint16(39), + 488: uint16(135), + 489: uint16(231), + 490: uint16(103), + 491: uint16(39), + 492: uint16(39), + 493: uint16(71), + 494: uint16(135), + 495: uint16(44), + 496: uint16(71), + 497: uint16(204), + 498: uint16(76), + 499: uint16(39), + 500: uint16(167), + 501: uint16(38), + 502: uint16(204), + 503: uint16(333), + 504: uint16(135), + 505: uint16(39), + 506: uint16(122), + 507: uint16(501), + 508: uint16(58), + 509: uint16(53), + 510: uint16(122), + 511: uint16(76), + 512: uint16(218), + 513: uint16(333), + 514: uint16(335), + 515: uint16(58), + 516: uint16(44), + 517: uint16(58), + 518: uint16(44), + 519: uint16(58), + 520: uint16(44), + 521: uint16(54), + 522: uint16(50), + 523: uint16(54), + 524: uint16(50), + 525: uint16(74), + 526: uint16(263), + 527: uint16(1159), + 528: uint16(460), + 529: uint16(42), + 530: uint16(172), + 531: uint16(53), + 532: uint16(76), + 533: uint16(167), + 534: uint16(364), + 535: uint16(1164), + 536: uint16(282), + 537: uint16(44), + 538: uint16(218), + 539: uint16(90), + 540: uint16(181), + 541: uint16(154), + 542: uint16(85), + 543: uint16(1383), + 544: uint16(74), + 545: uint16(140), + 546: uint16(42), + 547: uint16(204), + 548: uint16(42), + 549: uint16(76), + 550: uint16(74), + 551: uint16(76), + 552: uint16(39), + 553: uint16(333), + 554: uint16(213), + 555: uint16(199), + 556: uint16(74), + 557: uint16(76), + 558: uint16(135), + 559: uint16(108), + 560: uint16(39), + 561: uint16(106), + 562: uint16(71), + 563: uint16(234), + 564: uint16(103), + 565: uint16(140), + 566: uint16(423), + 567: uint16(44), + 568: uint16(74), + 569: uint16(76), + 570: uint16(202), + 571: uint16(44), + 572: uint16(39), + 573: uint16(42), + 574: uint16(333), + 575: uint16(106), + 576: uint16(44), + 577: uint16(90), + 578: uint16(1225), + 579: uint16(41), + 580: uint16(41), + 581: uint16(1383), + 582: uint16(53), + 583: uint16(38), + 584: uint16(10631), + 585: uint16(135), + 586: uint16(231), + 587: uint16(39), + 588: uint16(135), + 589: uint16(1319), + 590: uint16(135), + 591: uint16(1063), + 592: uint16(135), + 593: uint16(231), + 594: uint16(39), + 595: uint16(135), + 596: uint16(487), + 597: uint16(1831), + 598: uint16(135), + 599: uint16(2151), + 600: uint16(108), + 601: uint16(309), + 602: uint16(655), + 603: uint16(519), + 604: uint16(346), + 605: uint16(2727), + 606: uint16(49), + 607: uint16(19847), + 608: uint16(85), + 609: uint16(551), + 610: uint16(61), + 611: uint16(839), + 612: uint16(54), + 613: uint16(50), + 614: uint16(2407), + 615: uint16(117), + 616: uint16(110), + 617: uint16(423), + 618: uint16(135), + 619: uint16(108), + 620: uint16(583), + 621: uint16(108), + 622: uint16(85), + 623: uint16(583), + 624: uint16(76), + 625: uint16(423), + 626: uint16(103), + 627: uint16(76), + 628: uint16(1671), + 629: uint16(76), + 630: uint16(42), + 631: uint16(236), + 632: uint16(266), + 633: uint16(44), + 634: uint16(74), + 635: uint16(364), + 636: uint16(117), + 637: uint16(38), + 638: uint16(117), + 639: uint16(55), + 640: uint16(39), + 641: uint16(44), + 642: uint16(333), + 643: uint16(335), + 644: uint16(213), + 645: uint16(49), + 646: uint16(149), + 647: uint16(108), + 648: uint16(61), + 649: uint16(333), + 650: uint16(1127), + 651: uint16(38), + 652: uint16(1671), + 653: uint16(1319), + 654: uint16(44), + 655: uint16(39), + 656: uint16(2247), + 657: uint16(935), + 658: uint16(108), + 659: uint16(138), + 660: uint16(76), + 661: uint16(106), + 662: uint16(74), + 663: uint16(44), + 664: uint16(202), + 665: uint16(108), + 666: uint16(58), + 667: uint16(85), + 668: uint16(333), + 669: uint16(967), + 670: uint16(167), + 671: uint16(1415), + 672: uint16(554), + 673: uint16(231), + 674: uint16(74), + 675: uint16(333), + 676: uint16(47), + 677: uint16(1114), + 678: uint16(743), + 679: uint16(76), + 680: uint16(106), + 681: uint16(85), + 682: uint16(1703), + 683: uint16(42), + 684: uint16(44), + 685: uint16(42), + 686: uint16(236), + 687: uint16(44), + 688: uint16(42), + 689: uint16(44), + 690: uint16(74), + 691: uint16(268), + 692: uint16(202), + 693: uint16(332), + 694: uint16(44), + 695: uint16(333), + 696: uint16(333), + 697: uint16(245), + 698: uint16(38), + 699: uint16(213), + 700: uint16(140), + 701: uint16(42), + 702: uint16(1511), + 703: uint16(44), + 704: uint16(42), + 705: uint16(172), + 706: uint16(42), + 707: uint16(44), + 708: uint16(170), + 709: uint16(44), + 710: uint16(74), + 711: uint16(231), + 712: uint16(333), + 713: uint16(245), + 714: uint16(346), + 715: uint16(300), + 716: uint16(314), + 717: uint16(76), + 718: uint16(42), + 719: uint16(967), + 720: uint16(42), + 721: uint16(140), + 722: uint16(74), + 723: uint16(76), + 724: uint16(42), + 725: uint16(44), + 726: uint16(74), + 727: uint16(71), + 728: uint16(333), + 729: uint16(1415), + 730: uint16(44), + 731: uint16(42), + 732: uint16(76), + 733: uint16(106), + 734: uint16(44), + 735: uint16(42), + 736: uint16(108), + 737: uint16(74), + 738: uint16(149), + 739: uint16(1159), + 740: uint16(266), + 741: uint16(268), + 742: uint16(74), + 743: uint16(76), + 744: uint16(181), + 745: uint16(333), + 746: uint16(103), + 747: uint16(333), + 748: uint16(967), + 749: uint16(198), + 750: uint16(85), + 751: uint16(277), + 752: uint16(108), + 753: uint16(53), + 754: uint16(428), + 755: uint16(42), + 756: uint16(236), + 757: uint16(135), + 758: uint16(44), + 759: uint16(135), + 760: uint16(74), + 761: uint16(44), + 762: uint16(71), + 763: uint16(1413), + 764: uint16(2022), + 765: uint16(421), + 766: uint16(38), + 767: uint16(1093), + 768: uint16(1190), + 769: uint16(1260), + 770: uint16(140), + 771: uint16(4830), + 772: uint16(261), + 773: uint16(3166), + 774: uint16(261), + 775: uint16(265), + 776: uint16(197), + 777: uint16(201), + 778: uint16(261), + 779: uint16(265), + 780: uint16(261), + 781: uint16(265), + 782: uint16(197), + 783: uint16(201), + 784: uint16(261), + 785: uint16(41), + 786: uint16(41), + 787: uint16(41), + 788: uint16(94), + 789: uint16(229), + 790: uint16(265), + 791: uint16(453), + 792: uint16(261), + 793: uint16(264), + 794: uint16(261), + 795: uint16(264), + 796: uint16(261), + 797: uint16(264), + 798: uint16(165), + 799: uint16(69), + 800: uint16(137), + 801: uint16(40), + 802: uint16(56), + 803: uint16(37), + 804: uint16(120), + 805: uint16(101), + 806: uint16(69), + 807: uint16(137), + 808: uint16(40), + 809: uint16(120), + 810: uint16(133), + 811: uint16(69), + 812: uint16(137), + 813: uint16(120), + 814: uint16(261), + 815: uint16(169), + 816: uint16(120), + 817: uint16(101), + 818: uint16(69), + 819: uint16(137), + 820: uint16(40), + 821: uint16(88), + 822: uint16(381), + 823: uint16(162), + 824: uint16(209), + 825: uint16(85), + 826: uint16(52), + 827: uint16(51), + 828: uint16(54), + 829: uint16(84), + 830: uint16(51), + 831: uint16(54), + 832: uint16(52), + 833: uint16(277), + 834: uint16(59), + 835: uint16(60), + 836: uint16(162), + 837: uint16(61), + 838: uint16(309), + 839: uint16(52), + 840: uint16(51), + 841: uint16(149), + 842: uint16(80), + 843: uint16(117), + 844: uint16(57), + 845: uint16(54), + 846: uint16(50), + 847: uint16(373), + 848: uint16(57), + 849: uint16(53), + 850: uint16(48), + 851: uint16(341), + 852: uint16(61), + 853: uint16(162), + 854: uint16(194), + 855: uint16(47), + 856: uint16(38), + 857: uint16(207), + 858: uint16(121), + 859: uint16(54), + 860: uint16(50), + 861: uint16(38), + 862: uint16(335), + 863: uint16(121), + 864: uint16(54), + 865: uint16(50), + 866: uint16(422), + 867: uint16(855), + 868: uint16(428), + 869: uint16(139), + 870: uint16(44), + 871: uint16(107), + 872: uint16(396), + 873: uint16(90), + 874: uint16(41), + 875: uint16(154), + 876: uint16(41), + 877: uint16(90), + 878: uint16(37), + 879: uint16(105), + 880: uint16(69), + 881: uint16(105), + 882: uint16(37), + 883: uint16(58), + 884: uint16(41), + 885: uint16(90), + 886: uint16(57), + 887: uint16(169), + 888: uint16(218), + 889: uint16(41), + 890: uint16(58), + 891: uint16(41), + 892: uint16(58), + 893: uint16(41), + 894: uint16(58), + 895: uint16(137), + 896: uint16(58), + 897: uint16(37), + 898: uint16(137), + 899: uint16(37), + 900: uint16(135), + 901: uint16(37), + 902: uint16(90), + 903: uint16(69), + 904: uint16(73), + 905: uint16(185), + 906: uint16(94), + 907: uint16(101), + 908: uint16(58), + 909: uint16(57), + 910: uint16(90), + 911: uint16(37), + 912: uint16(58), + 913: uint16(527), + 914: uint16(1134), + 915: uint16(94), + 916: uint16(142), + 917: uint16(47), + 918: uint16(185), + 919: uint16(186), + 920: uint16(89), + 921: uint16(154), + 922: uint16(57), + 923: uint16(90), + 924: uint16(57), + 925: uint16(90), + 926: uint16(57), + 927: uint16(250), + 928: uint16(57), + 929: uint16(1018), + 930: uint16(89), + 931: uint16(90), + 932: uint16(57), + 933: uint16(58), + 934: uint16(57), + 935: uint16(1018), + 936: uint16(8601), + 937: uint16(282), + 938: uint16(153), + 939: uint16(666), + 940: uint16(89), + 941: uint16(250), + 942: uint16(54), + 943: uint16(50), + 944: uint16(2618), + 945: uint16(57), + 946: uint16(986), + 947: uint16(825), + 948: uint16(1306), + 949: uint16(217), + 950: uint16(602), + 951: uint16(1274), + 952: uint16(378), + 953: uint16(1935), + 954: uint16(2522), + 955: uint16(719), + 956: uint16(5882), + 957: uint16(57), + 958: uint16(314), + 959: uint16(57), + 960: uint16(1754), + 961: uint16(281), + 962: uint16(3578), + 963: uint16(57), + 964: uint16(4634), + 965: uint16(3322), + 966: uint16(54), + 967: uint16(50), + 968: uint16(54), + 969: uint16(50), + 970: uint16(54), + 971: uint16(50), + 972: uint16(54), + 973: uint16(50), + 974: uint16(54), + 975: uint16(50), + 976: uint16(54), + 977: uint16(50), + 978: uint16(54), + 979: uint16(50), + 980: uint16(975), + 981: uint16(1434), + 982: uint16(185), + 983: uint16(54), + 984: uint16(50), + 985: uint16(1017), + 986: uint16(54), + 987: uint16(50), + 988: uint16(54), + 989: uint16(50), + 990: uint16(54), + 991: uint16(50), + 992: uint16(54), + 993: uint16(50), + 994: uint16(54), + 995: uint16(50), + 996: uint16(537), + 997: uint16(8218), + 998: uint16(4217), + 999: uint16(54), + 1000: uint16(50), + 1001: uint16(54), + 1002: uint16(50), + 1003: uint16(54), + 1004: uint16(50), + 1005: uint16(54), + 1006: uint16(50), + 1007: uint16(54), + 1008: uint16(50), + 1009: uint16(54), + 1010: uint16(50), + 1011: uint16(54), + 1012: uint16(50), + 1013: uint16(54), + 1014: uint16(50), + 1015: uint16(54), + 1016: uint16(50), + 1017: uint16(54), + 1018: uint16(50), + 1019: uint16(54), + 1020: uint16(50), + 1021: uint16(2041), + 1022: uint16(54), + 1023: uint16(50), + 1024: uint16(54), + 1025: uint16(50), + 1026: uint16(1049), + 1027: uint16(54), + 1028: uint16(50), + 1029: uint16(8281), + 1030: uint16(1562), + 1031: uint16(697), + 1032: uint16(90), + 1033: uint16(217), + 1034: uint16(346), + 1035: uint16(1513), + 1036: uint16(1509), + 1037: uint16(126), + 1038: uint16(73), + 1039: uint16(69), + 1040: uint16(254), + 1041: uint16(105), + 1042: uint16(37), + 1043: uint16(94), + 1044: uint16(37), + 1045: uint16(94), + 1046: uint16(165), + 1047: uint16(70), + 1048: uint16(105), + 1049: uint16(37), + 1050: uint16(3166), + 1051: uint16(37), + 1052: uint16(218), + 1053: uint16(158), + 1054: uint16(108), + 1055: uint16(94), + 1056: uint16(149), + 1057: uint16(47), + 1058: uint16(85), + 1059: uint16(1221), + 1060: uint16(37), + 1061: uint16(37), + 1062: uint16(1799), + 1063: uint16(38), + 1064: uint16(53), + 1065: uint16(44), + 1066: uint16(743), + 1067: uint16(231), + 1068: uint16(231), + 1069: uint16(231), + 1070: uint16(231), + 1071: uint16(231), + 1072: uint16(231), + 1073: uint16(231), + 1074: uint16(231), + 1075: uint16(1036), + 1076: uint16(85), + 1077: uint16(52), + 1078: uint16(51), + 1079: uint16(52), + 1080: uint16(51), + 1081: uint16(117), + 1082: uint16(52), + 1083: uint16(51), + 1084: uint16(53), + 1085: uint16(52), + 1086: uint16(51), + 1087: uint16(309), + 1088: uint16(49), + 1089: uint16(85), + 1090: uint16(49), + 1091: uint16(53), + 1092: uint16(52), + 1093: uint16(51), + 1094: uint16(85), + 1095: uint16(52), + 1096: uint16(51), + 1097: uint16(54), + 1098: uint16(50), + 1099: uint16(54), + 1100: uint16(50), + 1101: uint16(54), + 1102: uint16(50), + 1103: uint16(54), + 1104: uint16(50), + 1105: uint16(181), + 1106: uint16(38), + 1107: uint16(341), + 1108: uint16(81), + 1109: uint16(858), + 1110: uint16(2874), + 1111: uint16(6874), + 1112: uint16(410), + 1113: uint16(61), + 1114: uint16(117), + 1115: uint16(58), + 1116: uint16(38), + 1117: uint16(39), + 1118: uint16(46), + 1119: uint16(54), + 1120: uint16(50), + 1121: uint16(54), + 1122: uint16(50), + 1123: uint16(54), + 1124: uint16(50), + 1125: uint16(54), + 1126: uint16(50), + 1127: uint16(54), + 1128: uint16(50), + 1129: uint16(90), + 1130: uint16(54), + 1131: uint16(50), + 1132: uint16(54), + 1133: uint16(50), + 1134: uint16(54), + 1135: uint16(50), + 1136: uint16(54), + 1137: uint16(50), + 1138: uint16(49), + 1139: uint16(54), + 1140: uint16(82), + 1141: uint16(58), + 1142: uint16(302), + 1143: uint16(140), + 1144: uint16(74), + 1145: uint16(49), + 1146: uint16(166), + 1147: uint16(90), + 1148: uint16(110), + 1149: uint16(38), + 1150: uint16(39), + 1151: uint16(53), + 1152: uint16(90), + 1153: uint16(2759), + 1154: uint16(76), + 1155: uint16(88), + 1156: uint16(70), + 1157: uint16(39), + 1158: uint16(49), + 1159: uint16(2887), + 1160: uint16(53), + 1161: uint16(102), + 1162: uint16(39), + 1163: uint16(1319), + 1164: uint16(3015), + 1165: uint16(90), + 1166: uint16(143), + 1167: uint16(346), + 1168: uint16(871), + 1169: uint16(1178), + 1170: uint16(519), + 1171: uint16(1018), + 1172: uint16(335), + 1173: uint16(986), + 1174: uint16(271), + 1175: uint16(58), + 1176: uint16(495), + 1177: uint16(1050), + 1178: uint16(335), + 1179: uint16(1274), + 1180: uint16(495), + 1181: uint16(2042), + 1182: uint16(8218), + 1183: uint16(39), + 1184: uint16(39), + 1185: uint16(2074), + 1186: uint16(39), + 1187: uint16(39), + 1188: uint16(679), + 1189: uint16(38), + 1190: uint16(36583), + 1191: uint16(1786), + 1192: uint16(1287), + 1193: uint16(198), + 1194: uint16(85), + 1195: uint16(8583), + 1196: uint16(38), + 1197: uint16(117), + 1198: uint16(519), + 1199: uint16(333), + 1200: uint16(71), + 1201: uint16(1502), + 1202: uint16(39), + 1203: uint16(44), + 1204: uint16(107), + 1205: uint16(53), + 1206: uint16(332), + 1207: uint16(53), + 1208: uint16(38), + 1209: uint16(798), + 1210: uint16(44), + 1211: uint16(2247), + 1212: uint16(334), + 1213: uint16(76), + 1214: uint16(213), + 1215: uint16(760), + 1216: uint16(294), + 1217: uint16(88), + 1218: uint16(478), + 1219: uint16(69), + 1220: uint16(2014), + 1221: uint16(38), + 1222: uint16(261), + 1223: uint16(190), + 1224: uint16(350), + 1225: uint16(38), + 1226: uint16(88), + 1227: uint16(158), + 1228: uint16(158), + 1229: uint16(382), + 1230: uint16(70), + 1231: uint16(37), + 1232: uint16(231), + 1233: uint16(44), + 1234: uint16(103), + 1235: uint16(44), + 1236: uint16(135), + 1237: uint16(44), + 1238: uint16(743), + 1239: uint16(74), + 1240: uint16(76), + 1241: uint16(42), + 1242: uint16(154), + 1243: uint16(207), + 1244: uint16(90), + 1245: uint16(55), + 1246: uint16(58), + 1247: uint16(1671), + 1248: uint16(149), + 1249: uint16(74), + 1250: uint16(1607), + 1251: uint16(522), + 1252: uint16(44), + 1253: uint16(85), + 1254: uint16(333), + 1255: uint16(588), + 1256: uint16(199), + 1257: uint16(117), + 1258: uint16(39), + 1259: uint16(333), + 1260: uint16(903), + 1261: uint16(268), + 1262: uint16(85), + 1263: uint16(743), + 1264: uint16(364), + 1265: uint16(74), + 1266: uint16(53), + 1267: uint16(935), + 1268: uint16(108), + 1269: uint16(42), + 1270: uint16(1511), + 1271: uint16(44), + 1272: uint16(74), + 1273: uint16(140), + 1274: uint16(74), + 1275: uint16(44), + 1276: uint16(138), + 1277: uint16(437), + 1278: uint16(38), + 1279: uint16(333), + 1280: uint16(85), + 1281: uint16(1319), + 1282: uint16(204), + 1283: uint16(74), + 1284: uint16(76), + 1285: uint16(74), + 1286: uint16(76), + 1287: uint16(103), + 1288: uint16(44), + 1289: uint16(263), + 1290: uint16(44), + 1291: uint16(42), + 1292: uint16(333), + 1293: uint16(149), + 1294: uint16(519), + 1295: uint16(38), + 1296: uint16(199), + 1297: uint16(122), + 1298: uint16(39), + 1299: uint16(42), + 1300: uint16(1543), + 1301: uint16(44), + 1302: uint16(39), + 1303: uint16(108), + 1304: uint16(71), + 1305: uint16(76), + 1306: uint16(167), + 1307: uint16(76), + 1308: uint16(39), + 1309: uint16(44), + 1310: uint16(39), + 1311: uint16(71), + 1312: uint16(38), + 1313: uint16(85), + 1314: uint16(359), + 1315: uint16(42), + 1316: uint16(76), + 1317: uint16(74), + 1318: uint16(85), + 1319: uint16(39), + 1320: uint16(70), + 1321: uint16(42), + 1322: uint16(44), + 1323: uint16(199), + 1324: uint16(199), + 1325: uint16(199), + 1326: uint16(231), + 1327: uint16(231), + 1328: uint16(1127), + 1329: uint16(74), + 1330: uint16(44), + 1331: uint16(74), + 1332: uint16(44), + 1333: uint16(74), + 1334: uint16(53), + 1335: uint16(42), + 1336: uint16(44), + 1337: uint16(333), + 1338: uint16(39), + 1339: uint16(39), + 1340: uint16(743), + 1341: uint16(1575), + 1342: uint16(36), + 1343: uint16(68), + 1344: uint16(68), + 1345: uint16(36), + 1346: uint16(63), + 1347: uint16(63), + 1348: uint16(11719), + 1349: uint16(3399), + 1350: uint16(229), + 1351: uint16(165), + 1352: uint16(39), + 1353: uint16(44), + 1354: uint16(327), + 1355: uint16(57), + 1356: uint16(423), + 1357: uint16(167), + 1358: uint16(39), + 1359: uint16(71), + 1360: uint16(71), + 1361: uint16(3463), + 1362: uint16(536), + 1363: uint16(11623), + 1364: uint16(54), + 1365: uint16(50), + 1366: uint16(2055), + 1367: uint16(1735), + 1368: uint16(391), + 1369: uint16(55), + 1370: uint16(58), + 1371: uint16(524), + 1372: uint16(245), + 1373: uint16(54), + 1374: uint16(50), + 1375: uint16(53), + 1376: uint16(236), + 1377: uint16(53), + 1378: uint16(81), + 1379: uint16(80), + 1380: uint16(54), + 1381: uint16(50), + 1382: uint16(54), + 1383: uint16(50), + 1384: uint16(54), + 1385: uint16(50), + 1386: uint16(54), + 1387: uint16(50), + 1388: uint16(54), + 1389: uint16(50), + 1390: uint16(54), + 1391: uint16(50), + 1392: uint16(54), + 1393: uint16(50), + 1394: uint16(54), + 1395: uint16(50), + 1396: uint16(85), + 1397: uint16(54), + 1398: uint16(50), + 1399: uint16(149), + 1400: uint16(112), + 1401: uint16(117), + 1402: uint16(149), + 1403: uint16(49), + 1404: uint16(54), + 1405: uint16(50), + 1406: uint16(54), + 1407: uint16(50), + 1408: uint16(54), + 1409: uint16(50), + 1410: uint16(117), + 1411: uint16(57), + 1412: uint16(49), + 1413: uint16(121), + 1414: uint16(53), + 1415: uint16(55), + 1416: uint16(85), + 1417: uint16(167), + 1418: uint16(4327), + 1419: uint16(34), + 1420: uint16(117), + 1421: uint16(55), + 1422: uint16(117), + 1423: uint16(54), + 1424: uint16(50), + 1425: uint16(53), + 1426: uint16(57), + 1427: uint16(53), + 1428: uint16(49), + 1429: uint16(85), + 1430: uint16(333), + 1431: uint16(85), + 1432: uint16(121), + 1433: uint16(85), + 1434: uint16(841), + 1435: uint16(54), + 1436: uint16(53), + 1437: uint16(50), + 1438: uint16(56), + 1439: uint16(48), + 1440: uint16(56), + 1441: uint16(837), + 1442: uint16(54), + 1443: uint16(57), + 1444: uint16(50), + 1445: uint16(57), + 1446: uint16(54), + 1447: uint16(50), + 1448: uint16(53), + 1449: uint16(54), + 1450: uint16(50), + 1451: uint16(85), + 1452: uint16(327), + 1453: uint16(38), + 1454: uint16(1447), + 1455: uint16(70), + 1456: uint16(999), + 1457: uint16(199), + 1458: uint16(199), + 1459: uint16(199), + 1460: uint16(103), + 1461: uint16(87), + 1462: uint16(57), + 1463: uint16(56), + 1464: uint16(58), + 1465: uint16(87), + 1466: uint16(58), + 1467: uint16(153), + 1468: uint16(90), + 1469: uint16(98), + 1470: uint16(90), + 1471: uint16(391), + 1472: uint16(839), + 1473: uint16(615), + 1474: uint16(71), + 1475: uint16(487), + 1476: uint16(455), + 1477: uint16(3943), + 1478: uint16(117), + 1479: uint16(1455), + 1480: uint16(314), + 1481: uint16(1710), + 1482: uint16(143), + 1483: uint16(570), + 1484: uint16(47), + 1485: uint16(410), + 1486: uint16(1466), + 1487: uint16(44), + 1488: uint16(935), + 1489: uint16(1575), + 1490: uint16(999), + 1491: uint16(143), + 1492: uint16(551), + 1493: uint16(46), + 1494: uint16(263), + 1495: uint16(46), + 1496: uint16(967), + 1497: uint16(53), + 1498: uint16(1159), + 1499: uint16(263), + 1500: uint16(53), + 1501: uint16(174), + 1502: uint16(1289), + 1503: uint16(1285), + 1504: uint16(2503), + 1505: uint16(333), + 1506: uint16(199), + 1507: uint16(39), + 1508: uint16(1415), + 1509: uint16(71), + 1510: uint16(39), + 1511: uint16(743), + 1512: uint16(53), + 1513: uint16(271), + 1514: uint16(711), + 1515: uint16(207), + 1516: uint16(53), + 1517: uint16(839), + 1518: uint16(53), + 1519: uint16(1799), + 1520: uint16(71), + 1521: uint16(39), + 1522: uint16(108), + 1523: uint16(76), + 1524: uint16(140), + 1525: uint16(135), + 1526: uint16(103), + 1527: uint16(871), + 1528: uint16(108), + 1529: uint16(44), + 1530: uint16(271), + 1531: uint16(309), + 1532: uint16(935), + 1533: uint16(79), + 1534: uint16(53), + 1535: uint16(1735), + 1536: uint16(245), + 1537: uint16(711), + 1538: uint16(271), + 1539: uint16(615), + 1540: uint16(271), + 1541: uint16(2343), + 1542: uint16(1007), + 1543: uint16(42), + 1544: uint16(44), + 1545: uint16(42), + 1546: uint16(1703), + 1547: uint16(492), + 1548: uint16(245), + 1549: uint16(655), + 1550: uint16(333), + 1551: uint16(76), + 1552: uint16(42), + 1553: uint16(1447), + 1554: uint16(106), + 1555: uint16(140), + 1556: uint16(74), + 1557: uint16(76), + 1558: uint16(85), + 1559: uint16(34), + 1560: uint16(149), + 1561: uint16(807), + 1562: uint16(333), + 1563: uint16(108), + 1564: uint16(1159), + 1565: uint16(172), + 1566: uint16(42), + 1567: uint16(268), + 1568: uint16(333), + 1569: uint16(149), + 1570: uint16(76), + 1571: uint16(42), + 1572: uint16(1543), + 1573: uint16(106), + 1574: uint16(300), + 1575: uint16(74), + 1576: uint16(135), + 1577: uint16(149), + 1578: uint16(333), + 1579: uint16(1383), + 1580: uint16(44), + 1581: uint16(42), + 1582: uint16(44), + 1583: uint16(74), + 1584: uint16(204), + 1585: uint16(42), + 1586: uint16(44), + 1587: uint16(333), + 1588: uint16(28135), + 1589: uint16(3182), + 1590: uint16(149), + 1591: uint16(34279), + 1592: uint16(18215), + 1593: uint16(2215), + 1594: uint16(39), + 1595: uint16(1482), + 1596: uint16(140), + 1597: uint16(422), + 1598: uint16(71), + 1599: uint16(7898), + 1600: uint16(1274), + 1601: uint16(1946), + 1602: uint16(74), + 1603: uint16(108), + 1604: uint16(122), + 1605: uint16(202), + 1606: uint16(258), + 1607: uint16(268), + 1608: uint16(90), + 1609: uint16(236), + 1610: uint16(986), + 1611: uint16(140), + 1612: uint16(1562), + 1613: uint16(2138), + 1614: uint16(108), + 1615: uint16(58), + 1616: uint16(2810), + 1617: uint16(591), + 1618: uint16(841), + 1619: uint16(837), + 1620: uint16(841), + 1621: uint16(229), + 1622: uint16(581), + 1623: uint16(841), + 1624: uint16(837), + 1625: uint16(41), + 1626: uint16(73), + 1627: uint16(41), + 1628: uint16(73), + 1629: uint16(137), + 1630: uint16(265), + 1631: uint16(133), + 1632: uint16(37), + 1633: uint16(229), + 1634: uint16(357), + 1635: uint16(841), + 1636: uint16(837), + 1637: uint16(73), + 1638: uint16(137), + 1639: uint16(265), + 1640: uint16(233), + 1641: uint16(837), + 1642: uint16(73), + 1643: uint16(137), + 1644: uint16(169), + 1645: uint16(41), + 1646: uint16(233), + 1647: uint16(837), + 1648: uint16(841), + 1649: uint16(837), + 1650: uint16(841), + 1651: uint16(837), + 1652: uint16(841), + 1653: uint16(837), + 1654: uint16(841), + 1655: uint16(837), + 1656: uint16(841), + 1657: uint16(837), + 1658: uint16(841), + 1659: uint16(901), + 1660: uint16(809), + 1661: uint16(57), + 1662: uint16(805), + 1663: uint16(57), + 1664: uint16(197), + 1665: uint16(809), + 1666: uint16(57), + 1667: uint16(805), + 1668: uint16(57), + 1669: uint16(197), + 1670: uint16(809), + 1671: uint16(57), + 1672: uint16(805), + 1673: uint16(57), + 1674: uint16(197), + 1675: uint16(809), + 1676: uint16(57), + 1677: uint16(805), + 1678: uint16(57), + 1679: uint16(197), + 1680: uint16(809), + 1681: uint16(57), + 1682: uint16(805), + 1683: uint16(57), + 1684: uint16(197), + 1685: uint16(94), + 1686: uint16(1613), + 1687: uint16(135), + 1688: uint16(871), + 1689: uint16(71), + 1690: uint16(39), + 1691: uint16(39), + 1692: uint16(327), + 1693: uint16(135), + 1694: uint16(39), + 1695: uint16(39), + 1696: uint16(39), + 1697: uint16(39), + 1698: uint16(39), + 1699: uint16(39), + 1700: uint16(103), + 1701: uint16(71), + 1702: uint16(39), + 1703: uint16(39), + 1704: uint16(39), + 1705: uint16(39), + 1706: uint16(39), + 1707: uint16(39), + 1708: uint16(71), + 1709: uint16(39), + 1710: uint16(135), + 1711: uint16(231), + 1712: uint16(135), + 1713: uint16(135), + 1714: uint16(39), + 1715: uint16(327), + 1716: uint16(551), + 1717: uint16(103), + 1718: uint16(167), + 1719: uint16(551), + 1720: uint16(89), + 1721: uint16(1434), + 1722: uint16(3226), + 1723: uint16(506), + 1724: uint16(474), + 1725: uint16(506), + 1726: uint16(506), + 1727: uint16(367), + 1728: uint16(1018), + 1729: uint16(1946), + 1730: uint16(1402), + 1731: uint16(954), + 1732: uint16(1402), + 1733: uint16(314), + 1734: uint16(90), + 1735: uint16(1082), + 1736: uint16(218), + 1737: uint16(2266), + 1738: uint16(666), + 1739: uint16(1210), + 1740: uint16(186), + 1741: uint16(570), + 1742: uint16(2042), + 1743: uint16(58), + 1744: uint16(5850), + 1745: uint16(154), + 1746: uint16(2010), + 1747: uint16(154), + 1748: uint16(794), + 1749: uint16(2266), + 1750: uint16(378), + 1751: uint16(2266), + 1752: uint16(3738), + 1753: uint16(39), + 1754: uint16(39), + 1755: uint16(39), + 1756: uint16(39), + 1757: uint16(39), + 1758: uint16(39), + 1759: uint16(17351), + 1760: uint16(34), + 1761: uint16(3074), + 1762: uint16(7692), + 1763: uint16(63), + 1764: uint16(63), +} + +var _aFts5UnicodeMap = [1765]Tu16{ + 1: uint16(32), + 2: uint16(33), + 3: uint16(36), + 4: uint16(37), + 5: uint16(40), + 6: uint16(41), + 7: uint16(42), + 8: uint16(43), + 9: uint16(44), + 10: uint16(45), + 11: uint16(46), + 12: uint16(48), + 13: uint16(58), + 14: uint16(60), + 15: uint16(63), + 16: uint16(65), + 17: uint16(91), + 18: uint16(92), + 19: uint16(93), + 20: uint16(94), + 21: uint16(95), + 22: uint16(96), + 23: uint16(97), + 24: uint16(123), + 25: uint16(124), + 26: uint16(125), + 27: uint16(126), + 28: uint16(127), + 29: uint16(160), + 30: uint16(161), + 31: uint16(162), + 32: uint16(166), + 33: uint16(167), + 34: uint16(168), + 35: uint16(169), + 36: uint16(170), + 37: uint16(171), + 38: uint16(172), + 39: uint16(173), + 40: uint16(174), + 41: uint16(175), + 42: uint16(176), + 43: uint16(177), + 44: uint16(178), + 45: uint16(180), + 46: uint16(181), + 47: uint16(182), + 48: uint16(184), + 49: uint16(185), + 50: uint16(186), + 51: uint16(187), + 52: uint16(188), + 53: uint16(191), + 54: uint16(192), + 55: uint16(215), + 56: uint16(216), + 57: uint16(223), + 58: uint16(247), + 59: uint16(248), + 60: uint16(256), + 61: uint16(312), + 62: uint16(313), + 63: uint16(329), + 64: uint16(330), + 65: uint16(377), + 66: uint16(383), + 67: uint16(385), + 68: uint16(387), + 69: uint16(388), + 70: uint16(391), + 71: uint16(394), + 72: uint16(396), + 73: uint16(398), + 74: uint16(402), + 75: uint16(403), + 76: uint16(405), + 77: uint16(406), + 78: uint16(409), + 79: uint16(412), + 80: uint16(414), + 81: uint16(415), + 82: uint16(417), + 83: uint16(418), + 84: uint16(423), + 85: uint16(427), + 86: uint16(428), + 87: uint16(431), + 88: uint16(434), + 89: uint16(436), + 90: uint16(437), + 91: uint16(440), + 92: uint16(442), + 93: uint16(443), + 94: uint16(444), + 95: uint16(446), + 96: uint16(448), + 97: uint16(452), + 98: uint16(453), + 99: uint16(454), + 100: uint16(455), + 101: uint16(456), + 102: uint16(457), + 103: uint16(458), + 104: uint16(459), + 105: uint16(460), + 106: uint16(461), + 107: uint16(477), + 108: uint16(478), + 109: uint16(496), + 110: uint16(497), + 111: uint16(498), + 112: uint16(499), + 113: uint16(500), + 114: uint16(503), + 115: uint16(505), + 116: uint16(506), + 117: uint16(564), + 118: uint16(570), + 119: uint16(572), + 120: uint16(573), + 121: uint16(575), + 122: uint16(577), + 123: uint16(580), + 124: uint16(583), + 125: uint16(584), + 126: uint16(592), + 127: uint16(660), + 128: uint16(661), + 129: uint16(688), + 130: uint16(706), + 131: uint16(710), + 132: uint16(722), + 133: uint16(736), + 134: uint16(741), + 135: uint16(748), + 136: uint16(749), + 137: uint16(750), + 138: uint16(751), + 139: uint16(768), + 140: uint16(880), + 141: uint16(884), + 142: uint16(885), + 143: uint16(886), + 144: uint16(890), + 145: uint16(891), + 146: uint16(894), + 147: uint16(900), + 148: uint16(902), + 149: uint16(903), + 150: uint16(904), + 151: uint16(908), + 152: uint16(910), + 153: uint16(912), + 154: uint16(913), + 155: uint16(931), + 156: uint16(940), + 157: uint16(975), + 158: uint16(977), + 159: uint16(978), + 160: uint16(981), + 161: uint16(984), + 162: uint16(1008), + 163: uint16(1012), + 164: uint16(1014), + 165: uint16(1015), + 166: uint16(1018), + 167: uint16(1020), + 168: uint16(1021), + 169: uint16(1072), + 170: uint16(1120), + 171: uint16(1154), + 172: uint16(1155), + 173: uint16(1160), + 174: uint16(1162), + 175: uint16(1217), + 176: uint16(1231), + 177: uint16(1232), + 178: uint16(1329), + 179: uint16(1369), + 180: uint16(1370), + 181: uint16(1377), + 182: uint16(1417), + 183: uint16(1418), + 184: uint16(1423), + 185: uint16(1425), + 186: uint16(1470), + 187: uint16(1471), + 188: uint16(1472), + 189: uint16(1473), + 190: uint16(1475), + 191: uint16(1476), + 192: uint16(1478), + 193: uint16(1479), + 194: uint16(1488), + 195: uint16(1520), + 196: uint16(1523), + 197: uint16(1536), + 198: uint16(1542), + 199: uint16(1545), + 200: uint16(1547), + 201: uint16(1548), + 202: uint16(1550), + 203: uint16(1552), + 204: uint16(1563), + 205: uint16(1566), + 206: uint16(1568), + 207: uint16(1600), + 208: uint16(1601), + 209: uint16(1611), + 210: uint16(1632), + 211: uint16(1642), + 212: uint16(1646), + 213: uint16(1648), + 214: uint16(1649), + 215: uint16(1748), + 216: uint16(1749), + 217: uint16(1750), + 218: uint16(1757), + 219: uint16(1758), + 220: uint16(1759), + 221: uint16(1765), + 222: uint16(1767), + 223: uint16(1769), + 224: uint16(1770), + 225: uint16(1774), + 226: uint16(1776), + 227: uint16(1786), + 228: uint16(1789), + 229: uint16(1791), + 230: uint16(1792), + 231: uint16(1807), + 232: uint16(1808), + 233: uint16(1809), + 234: uint16(1810), + 235: uint16(1840), + 236: uint16(1869), + 237: uint16(1958), + 238: uint16(1969), + 239: uint16(1984), + 240: uint16(1994), + 241: uint16(2027), + 242: uint16(2036), + 243: uint16(2038), + 244: uint16(2039), + 245: uint16(2042), + 246: uint16(2048), + 247: uint16(2070), + 248: uint16(2074), + 249: uint16(2075), + 250: uint16(2084), + 251: uint16(2085), + 252: uint16(2088), + 253: uint16(2089), + 254: uint16(2096), + 255: uint16(2112), + 256: uint16(2137), + 257: uint16(2142), + 258: uint16(2208), + 259: uint16(2210), + 260: uint16(2276), + 261: uint16(2304), + 262: uint16(2307), + 263: uint16(2308), + 264: uint16(2362), + 265: uint16(2363), + 266: uint16(2364), + 267: uint16(2365), + 268: uint16(2366), + 269: uint16(2369), + 270: uint16(2377), + 271: uint16(2381), + 272: uint16(2382), + 273: uint16(2384), + 274: uint16(2385), + 275: uint16(2392), + 276: uint16(2402), + 277: uint16(2404), + 278: uint16(2406), + 279: uint16(2416), + 280: uint16(2417), + 281: uint16(2418), + 282: uint16(2425), + 283: uint16(2433), + 284: uint16(2434), + 285: uint16(2437), + 286: uint16(2447), + 287: uint16(2451), + 288: uint16(2474), + 289: uint16(2482), + 290: uint16(2486), + 291: uint16(2492), + 292: uint16(2493), + 293: uint16(2494), + 294: uint16(2497), + 295: uint16(2503), + 296: uint16(2507), + 297: uint16(2509), + 298: uint16(2510), + 299: uint16(2519), + 300: uint16(2524), + 301: uint16(2527), + 302: uint16(2530), + 303: uint16(2534), + 304: uint16(2544), + 305: uint16(2546), + 306: uint16(2548), + 307: uint16(2554), + 308: uint16(2555), + 309: uint16(2561), + 310: uint16(2563), + 311: uint16(2565), + 312: uint16(2575), + 313: uint16(2579), + 314: uint16(2602), + 315: uint16(2610), + 316: uint16(2613), + 317: uint16(2616), + 318: uint16(2620), + 319: uint16(2622), + 320: uint16(2625), + 321: uint16(2631), + 322: uint16(2635), + 323: uint16(2641), + 324: uint16(2649), + 325: uint16(2654), + 326: uint16(2662), + 327: uint16(2672), + 328: uint16(2674), + 329: uint16(2677), + 330: uint16(2689), + 331: uint16(2691), + 332: uint16(2693), + 333: uint16(2703), + 334: uint16(2707), + 335: uint16(2730), + 336: uint16(2738), + 337: uint16(2741), + 338: uint16(2748), + 339: uint16(2749), + 340: uint16(2750), + 341: uint16(2753), + 342: uint16(2759), + 343: uint16(2761), + 344: uint16(2763), + 345: uint16(2765), + 346: uint16(2768), + 347: uint16(2784), + 348: uint16(2786), + 349: uint16(2790), + 350: uint16(2800), + 351: uint16(2801), + 352: uint16(2817), + 353: uint16(2818), + 354: uint16(2821), + 355: uint16(2831), + 356: uint16(2835), + 357: uint16(2858), + 358: uint16(2866), + 359: uint16(2869), + 360: uint16(2876), + 361: uint16(2877), + 362: uint16(2878), + 363: uint16(2879), + 364: uint16(2880), + 365: uint16(2881), + 366: uint16(2887), + 367: uint16(2891), + 368: uint16(2893), + 369: uint16(2902), + 370: uint16(2903), + 371: uint16(2908), + 372: uint16(2911), + 373: uint16(2914), + 374: uint16(2918), + 375: uint16(2928), + 376: uint16(2929), + 377: uint16(2930), + 378: uint16(2946), + 379: uint16(2947), + 380: uint16(2949), + 381: uint16(2958), + 382: uint16(2962), + 383: uint16(2969), + 384: uint16(2972), + 385: uint16(2974), + 386: uint16(2979), + 387: uint16(2984), + 388: uint16(2990), + 389: uint16(3006), + 390: uint16(3008), + 391: uint16(3009), + 392: uint16(3014), + 393: uint16(3018), + 394: uint16(3021), + 395: uint16(3024), + 396: uint16(3031), + 397: uint16(3046), + 398: uint16(3056), + 399: uint16(3059), + 400: uint16(3065), + 401: uint16(3066), + 402: uint16(3073), + 403: uint16(3077), + 404: uint16(3086), + 405: uint16(3090), + 406: uint16(3114), + 407: uint16(3125), + 408: uint16(3133), + 409: uint16(3134), + 410: uint16(3137), + 411: uint16(3142), + 412: uint16(3146), + 413: uint16(3157), + 414: uint16(3160), + 415: uint16(3168), + 416: uint16(3170), + 417: uint16(3174), + 418: uint16(3192), + 419: uint16(3199), + 420: uint16(3202), + 421: uint16(3205), + 422: uint16(3214), + 423: uint16(3218), + 424: uint16(3242), + 425: uint16(3253), + 426: uint16(3260), + 427: uint16(3261), + 428: uint16(3262), + 429: uint16(3263), + 430: uint16(3264), + 431: uint16(3270), + 432: uint16(3271), + 433: uint16(3274), + 434: uint16(3276), + 435: uint16(3285), + 436: uint16(3294), + 437: uint16(3296), + 438: uint16(3298), + 439: uint16(3302), + 440: uint16(3313), + 441: uint16(3330), + 442: uint16(3333), + 443: uint16(3342), + 444: uint16(3346), + 445: uint16(3389), + 446: uint16(3390), + 447: uint16(3393), + 448: uint16(3398), + 449: uint16(3402), + 450: uint16(3405), + 451: uint16(3406), + 452: uint16(3415), + 453: uint16(3424), + 454: uint16(3426), + 455: uint16(3430), + 456: uint16(3440), + 457: uint16(3449), + 458: uint16(3450), + 459: uint16(3458), + 460: uint16(3461), + 461: uint16(3482), + 462: uint16(3507), + 463: uint16(3517), + 464: uint16(3520), + 465: uint16(3530), + 466: uint16(3535), + 467: uint16(3538), + 468: uint16(3542), + 469: uint16(3544), + 470: uint16(3570), + 471: uint16(3572), + 472: uint16(3585), + 473: uint16(3633), + 474: uint16(3634), + 475: uint16(3636), + 476: uint16(3647), + 477: uint16(3648), + 478: uint16(3654), + 479: uint16(3655), + 480: uint16(3663), + 481: uint16(3664), + 482: uint16(3674), + 483: uint16(3713), + 484: uint16(3716), + 485: uint16(3719), + 486: uint16(3722), + 487: uint16(3725), + 488: uint16(3732), + 489: uint16(3737), + 490: uint16(3745), + 491: uint16(3749), + 492: uint16(3751), + 493: uint16(3754), + 494: uint16(3757), + 495: uint16(3761), + 496: uint16(3762), + 497: uint16(3764), + 498: uint16(3771), + 499: uint16(3773), + 500: uint16(3776), + 501: uint16(3782), + 502: uint16(3784), + 503: uint16(3792), + 504: uint16(3804), + 505: uint16(3840), + 506: uint16(3841), + 507: uint16(3844), + 508: uint16(3859), + 509: uint16(3860), + 510: uint16(3861), + 511: uint16(3864), + 512: uint16(3866), + 513: uint16(3872), + 514: uint16(3882), + 515: uint16(3892), + 516: uint16(3893), + 517: uint16(3894), + 518: uint16(3895), + 519: uint16(3896), + 520: uint16(3897), + 521: uint16(3898), + 522: uint16(3899), + 523: uint16(3900), + 524: uint16(3901), + 525: uint16(3902), + 526: uint16(3904), + 527: uint16(3913), + 528: uint16(3953), + 529: uint16(3967), + 530: uint16(3968), + 531: uint16(3973), + 532: uint16(3974), + 533: uint16(3976), + 534: uint16(3981), + 535: uint16(3993), + 536: uint16(4030), + 537: uint16(4038), + 538: uint16(4039), + 539: uint16(4046), + 540: uint16(4048), + 541: uint16(4053), + 542: uint16(4057), + 543: uint16(4096), + 544: uint16(4139), + 545: uint16(4141), + 546: uint16(4145), + 547: uint16(4146), + 548: uint16(4152), + 549: uint16(4153), + 550: uint16(4155), + 551: uint16(4157), + 552: uint16(4159), + 553: uint16(4160), + 554: uint16(4170), + 555: uint16(4176), + 556: uint16(4182), + 557: uint16(4184), + 558: uint16(4186), + 559: uint16(4190), + 560: uint16(4193), + 561: uint16(4194), + 562: uint16(4197), + 563: uint16(4199), + 564: uint16(4206), + 565: uint16(4209), + 566: uint16(4213), + 567: uint16(4226), + 568: uint16(4227), + 569: uint16(4229), + 570: uint16(4231), + 571: uint16(4237), + 572: uint16(4238), + 573: uint16(4239), + 574: uint16(4240), + 575: uint16(4250), + 576: uint16(4253), + 577: uint16(4254), + 578: uint16(4256), + 579: uint16(4295), + 580: uint16(4301), + 581: uint16(4304), + 582: uint16(4347), + 583: uint16(4348), + 584: uint16(4349), + 585: uint16(4682), + 586: uint16(4688), + 587: uint16(4696), + 588: uint16(4698), + 589: uint16(4704), + 590: uint16(4746), + 591: uint16(4752), + 592: uint16(4786), + 593: uint16(4792), + 594: uint16(4800), + 595: uint16(4802), + 596: uint16(4808), + 597: uint16(4824), + 598: uint16(4882), + 599: uint16(4888), + 600: uint16(4957), + 601: uint16(4960), + 602: uint16(4969), + 603: uint16(4992), + 604: uint16(5008), + 605: uint16(5024), + 606: uint16(5120), + 607: uint16(5121), + 608: uint16(5741), + 609: uint16(5743), + 610: uint16(5760), + 611: uint16(5761), + 612: uint16(5787), + 613: uint16(5788), + 614: uint16(5792), + 615: uint16(5867), + 616: uint16(5870), + 617: uint16(5888), + 618: uint16(5902), + 619: uint16(5906), + 620: uint16(5920), + 621: uint16(5938), + 622: uint16(5941), + 623: uint16(5952), + 624: uint16(5970), + 625: uint16(5984), + 626: uint16(5998), + 627: uint16(6002), + 628: uint16(6016), + 629: uint16(6068), + 630: uint16(6070), + 631: uint16(6071), + 632: uint16(6078), + 633: uint16(6086), + 634: uint16(6087), + 635: uint16(6089), + 636: uint16(6100), + 637: uint16(6103), + 638: uint16(6104), + 639: uint16(6107), + 640: uint16(6108), + 641: uint16(6109), + 642: uint16(6112), + 643: uint16(6128), + 644: uint16(6144), + 645: uint16(6150), + 646: uint16(6151), + 647: uint16(6155), + 648: uint16(6158), + 649: uint16(6160), + 650: uint16(6176), + 651: uint16(6211), + 652: uint16(6212), + 653: uint16(6272), + 654: uint16(6313), + 655: uint16(6314), + 656: uint16(6320), + 657: uint16(6400), + 658: uint16(6432), + 659: uint16(6435), + 660: uint16(6439), + 661: uint16(6441), + 662: uint16(6448), + 663: uint16(6450), + 664: uint16(6451), + 665: uint16(6457), + 666: uint16(6464), + 667: uint16(6468), + 668: uint16(6470), + 669: uint16(6480), + 670: uint16(6512), + 671: uint16(6528), + 672: uint16(6576), + 673: uint16(6593), + 674: uint16(6600), + 675: uint16(6608), + 676: uint16(6618), + 677: uint16(6622), + 678: uint16(6656), + 679: uint16(6679), + 680: uint16(6681), + 681: uint16(6686), + 682: uint16(6688), + 683: uint16(6741), + 684: uint16(6742), + 685: uint16(6743), + 686: uint16(6744), + 687: uint16(6752), + 688: uint16(6753), + 689: uint16(6754), + 690: uint16(6755), + 691: uint16(6757), + 692: uint16(6765), + 693: uint16(6771), + 694: uint16(6783), + 695: uint16(6784), + 696: uint16(6800), + 697: uint16(6816), + 698: uint16(6823), + 699: uint16(6824), + 700: uint16(6912), + 701: uint16(6916), + 702: uint16(6917), + 703: uint16(6964), + 704: uint16(6965), + 705: uint16(6966), + 706: uint16(6971), + 707: uint16(6972), + 708: uint16(6973), + 709: uint16(6978), + 710: uint16(6979), + 711: uint16(6981), + 712: uint16(6992), + 713: uint16(7002), + 714: uint16(7009), + 715: uint16(7019), + 716: uint16(7028), + 717: uint16(7040), + 718: uint16(7042), + 719: uint16(7043), + 720: uint16(7073), + 721: uint16(7074), + 722: uint16(7078), + 723: uint16(7080), + 724: uint16(7082), + 725: uint16(7083), + 726: uint16(7084), + 727: uint16(7086), + 728: uint16(7088), + 729: uint16(7098), + 730: uint16(7142), + 731: uint16(7143), + 732: uint16(7144), + 733: uint16(7146), + 734: uint16(7149), + 735: uint16(7150), + 736: uint16(7151), + 737: uint16(7154), + 738: uint16(7164), + 739: uint16(7168), + 740: uint16(7204), + 741: uint16(7212), + 742: uint16(7220), + 743: uint16(7222), + 744: uint16(7227), + 745: uint16(7232), + 746: uint16(7245), + 747: uint16(7248), + 748: uint16(7258), + 749: uint16(7288), + 750: uint16(7294), + 751: uint16(7360), + 752: uint16(7376), + 753: uint16(7379), + 754: uint16(7380), + 755: uint16(7393), + 756: uint16(7394), + 757: uint16(7401), + 758: uint16(7405), + 759: uint16(7406), + 760: uint16(7410), + 761: uint16(7412), + 762: uint16(7413), + 763: uint16(7424), + 764: uint16(7468), + 765: uint16(7531), + 766: uint16(7544), + 767: uint16(7545), + 768: uint16(7579), + 769: uint16(7616), + 770: uint16(7676), + 771: uint16(7680), + 772: uint16(7830), + 773: uint16(7838), + 774: uint16(7936), + 775: uint16(7944), + 776: uint16(7952), + 777: uint16(7960), + 778: uint16(7968), + 779: uint16(7976), + 780: uint16(7984), + 781: uint16(7992), + 782: uint16(8000), + 783: uint16(8008), + 784: uint16(8016), + 785: uint16(8025), + 786: uint16(8027), + 787: uint16(8029), + 788: uint16(8031), + 789: uint16(8033), + 790: uint16(8040), + 791: uint16(8048), + 792: uint16(8064), + 793: uint16(8072), + 794: uint16(8080), + 795: uint16(8088), + 796: uint16(8096), + 797: uint16(8104), + 798: uint16(8112), + 799: uint16(8118), + 800: uint16(8120), + 801: uint16(8124), + 802: uint16(8125), + 803: uint16(8126), + 804: uint16(8127), + 805: uint16(8130), + 806: uint16(8134), + 807: uint16(8136), + 808: uint16(8140), + 809: uint16(8141), + 810: uint16(8144), + 811: uint16(8150), + 812: uint16(8152), + 813: uint16(8157), + 814: uint16(8160), + 815: uint16(8168), + 816: uint16(8173), + 817: uint16(8178), + 818: uint16(8182), + 819: uint16(8184), + 820: uint16(8188), + 821: uint16(8189), + 822: uint16(8192), + 823: uint16(8203), + 824: uint16(8208), + 825: uint16(8214), + 826: uint16(8216), + 827: uint16(8217), + 828: uint16(8218), + 829: uint16(8219), + 830: uint16(8221), + 831: uint16(8222), + 832: uint16(8223), + 833: uint16(8224), + 834: uint16(8232), + 835: uint16(8233), + 836: uint16(8234), + 837: uint16(8239), + 838: uint16(8240), + 839: uint16(8249), + 840: uint16(8250), + 841: uint16(8251), + 842: uint16(8255), + 843: uint16(8257), + 844: uint16(8260), + 845: uint16(8261), + 846: uint16(8262), + 847: uint16(8263), + 848: uint16(8274), + 849: uint16(8275), + 850: uint16(8276), + 851: uint16(8277), + 852: uint16(8287), + 853: uint16(8288), + 854: uint16(8298), + 855: uint16(8304), + 856: uint16(8305), + 857: uint16(8308), + 858: uint16(8314), + 859: uint16(8317), + 860: uint16(8318), + 861: uint16(8319), + 862: uint16(8320), + 863: uint16(8330), + 864: uint16(8333), + 865: uint16(8334), + 866: uint16(8336), + 867: uint16(8352), + 868: uint16(8400), + 869: uint16(8413), + 870: uint16(8417), + 871: uint16(8418), + 872: uint16(8421), + 873: uint16(8448), + 874: uint16(8450), + 875: uint16(8451), + 876: uint16(8455), + 877: uint16(8456), + 878: uint16(8458), + 879: uint16(8459), + 880: uint16(8462), + 881: uint16(8464), + 882: uint16(8467), + 883: uint16(8468), + 884: uint16(8469), + 885: uint16(8470), + 886: uint16(8472), + 887: uint16(8473), + 888: uint16(8478), + 889: uint16(8484), + 890: uint16(8485), + 891: uint16(8486), + 892: uint16(8487), + 893: uint16(8488), + 894: uint16(8489), + 895: uint16(8490), + 896: uint16(8494), + 897: uint16(8495), + 898: uint16(8496), + 899: uint16(8500), + 900: uint16(8501), + 901: uint16(8505), + 902: uint16(8506), + 903: uint16(8508), + 904: uint16(8510), + 905: uint16(8512), + 906: uint16(8517), + 907: uint16(8519), + 908: uint16(8522), + 909: uint16(8523), + 910: uint16(8524), + 911: uint16(8526), + 912: uint16(8527), + 913: uint16(8528), + 914: uint16(8544), + 915: uint16(8579), + 916: uint16(8581), + 917: uint16(8585), + 918: uint16(8592), + 919: uint16(8597), + 920: uint16(8602), + 921: uint16(8604), + 922: uint16(8608), + 923: uint16(8609), + 924: uint16(8611), + 925: uint16(8612), + 926: uint16(8614), + 927: uint16(8615), + 928: uint16(8622), + 929: uint16(8623), + 930: uint16(8654), + 931: uint16(8656), + 932: uint16(8658), + 933: uint16(8659), + 934: uint16(8660), + 935: uint16(8661), + 936: uint16(8692), + 937: uint16(8960), + 938: uint16(8968), + 939: uint16(8972), + 940: uint16(8992), + 941: uint16(8994), + 942: uint16(9001), + 943: uint16(9002), + 944: uint16(9003), + 945: uint16(9084), + 946: uint16(9085), + 947: uint16(9115), + 948: uint16(9140), + 949: uint16(9180), + 950: uint16(9186), + 951: uint16(9216), + 952: uint16(9280), + 953: uint16(9312), + 954: uint16(9372), + 955: uint16(9450), + 956: uint16(9472), + 957: uint16(9655), + 958: uint16(9656), + 959: uint16(9665), + 960: uint16(9666), + 961: uint16(9720), + 962: uint16(9728), + 963: uint16(9839), + 964: uint16(9840), + 965: uint16(9985), + 966: uint16(10088), + 967: uint16(10089), + 968: uint16(10090), + 969: uint16(10091), + 970: uint16(10092), + 971: uint16(10093), + 972: uint16(10094), + 973: uint16(10095), + 974: uint16(10096), + 975: uint16(10097), + 976: uint16(10098), + 977: uint16(10099), + 978: uint16(10100), + 979: uint16(10101), + 980: uint16(10102), + 981: uint16(10132), + 982: uint16(10176), + 983: uint16(10181), + 984: uint16(10182), + 985: uint16(10183), + 986: uint16(10214), + 987: uint16(10215), + 988: uint16(10216), + 989: uint16(10217), + 990: uint16(10218), + 991: uint16(10219), + 992: uint16(10220), + 993: uint16(10221), + 994: uint16(10222), + 995: uint16(10223), + 996: uint16(10224), + 997: uint16(10240), + 998: uint16(10496), + 999: uint16(10627), + 1000: uint16(10628), + 1001: uint16(10629), + 1002: uint16(10630), + 1003: uint16(10631), + 1004: uint16(10632), + 1005: uint16(10633), + 1006: uint16(10634), + 1007: uint16(10635), + 1008: uint16(10636), + 1009: uint16(10637), + 1010: uint16(10638), + 1011: uint16(10639), + 1012: uint16(10640), + 1013: uint16(10641), + 1014: uint16(10642), + 1015: uint16(10643), + 1016: uint16(10644), + 1017: uint16(10645), + 1018: uint16(10646), + 1019: uint16(10647), + 1020: uint16(10648), + 1021: uint16(10649), + 1022: uint16(10712), + 1023: uint16(10713), + 1024: uint16(10714), + 1025: uint16(10715), + 1026: uint16(10716), + 1027: uint16(10748), + 1028: uint16(10749), + 1029: uint16(10750), + 1030: uint16(11008), + 1031: uint16(11056), + 1032: uint16(11077), + 1033: uint16(11079), + 1034: uint16(11088), + 1035: uint16(11264), + 1036: uint16(11312), + 1037: uint16(11360), + 1038: uint16(11363), + 1039: uint16(11365), + 1040: uint16(11367), + 1041: uint16(11374), + 1042: uint16(11377), + 1043: uint16(11378), + 1044: uint16(11380), + 1045: uint16(11381), + 1046: uint16(11383), + 1047: uint16(11388), + 1048: uint16(11390), + 1049: uint16(11393), + 1050: uint16(11394), + 1051: uint16(11492), + 1052: uint16(11493), + 1053: uint16(11499), + 1054: uint16(11503), + 1055: uint16(11506), + 1056: uint16(11513), + 1057: uint16(11517), + 1058: uint16(11518), + 1059: uint16(11520), + 1060: uint16(11559), + 1061: uint16(11565), + 1062: uint16(11568), + 1063: uint16(11631), + 1064: uint16(11632), + 1065: uint16(11647), + 1066: uint16(11648), + 1067: uint16(11680), + 1068: uint16(11688), + 1069: uint16(11696), + 1070: uint16(11704), + 1071: uint16(11712), + 1072: uint16(11720), + 1073: uint16(11728), + 1074: uint16(11736), + 1075: uint16(11744), + 1076: uint16(11776), + 1077: uint16(11778), + 1078: uint16(11779), + 1079: uint16(11780), + 1080: uint16(11781), + 1081: uint16(11782), + 1082: uint16(11785), + 1083: uint16(11786), + 1084: uint16(11787), + 1085: uint16(11788), + 1086: uint16(11789), + 1087: uint16(11790), + 1088: uint16(11799), + 1089: uint16(11800), + 1090: uint16(11802), + 1091: uint16(11803), + 1092: uint16(11804), + 1093: uint16(11805), + 1094: uint16(11806), + 1095: uint16(11808), + 1096: uint16(11809), + 1097: uint16(11810), + 1098: uint16(11811), + 1099: uint16(11812), + 1100: uint16(11813), + 1101: uint16(11814), + 1102: uint16(11815), + 1103: uint16(11816), + 1104: uint16(11817), + 1105: uint16(11818), + 1106: uint16(11823), + 1107: uint16(11824), + 1108: uint16(11834), + 1109: uint16(11904), + 1110: uint16(11931), + 1111: uint16(12032), + 1112: uint16(12272), + 1113: uint16(12288), + 1114: uint16(12289), + 1115: uint16(12292), + 1116: uint16(12293), + 1117: uint16(12294), + 1118: uint16(12295), + 1119: uint16(12296), + 1120: uint16(12297), + 1121: uint16(12298), + 1122: uint16(12299), + 1123: uint16(12300), + 1124: uint16(12301), + 1125: uint16(12302), + 1126: uint16(12303), + 1127: uint16(12304), + 1128: uint16(12305), + 1129: uint16(12306), + 1130: uint16(12308), + 1131: uint16(12309), + 1132: uint16(12310), + 1133: uint16(12311), + 1134: uint16(12312), + 1135: uint16(12313), + 1136: uint16(12314), + 1137: uint16(12315), + 1138: uint16(12316), + 1139: uint16(12317), + 1140: uint16(12318), + 1141: uint16(12320), + 1142: uint16(12321), + 1143: uint16(12330), + 1144: uint16(12334), + 1145: uint16(12336), + 1146: uint16(12337), + 1147: uint16(12342), + 1148: uint16(12344), + 1149: uint16(12347), + 1150: uint16(12348), + 1151: uint16(12349), + 1152: uint16(12350), + 1153: uint16(12353), + 1154: uint16(12441), + 1155: uint16(12443), + 1156: uint16(12445), + 1157: uint16(12447), + 1158: uint16(12448), + 1159: uint16(12449), + 1160: uint16(12539), + 1161: uint16(12540), + 1162: uint16(12543), + 1163: uint16(12549), + 1164: uint16(12593), + 1165: uint16(12688), + 1166: uint16(12690), + 1167: uint16(12694), + 1168: uint16(12704), + 1169: uint16(12736), + 1170: uint16(12784), + 1171: uint16(12800), + 1172: uint16(12832), + 1173: uint16(12842), + 1174: uint16(12872), + 1175: uint16(12880), + 1176: uint16(12881), + 1177: uint16(12896), + 1178: uint16(12928), + 1179: uint16(12938), + 1180: uint16(12977), + 1181: uint16(12992), + 1182: uint16(13056), + 1183: uint16(13312), + 1184: uint16(19893), + 1185: uint16(19904), + 1186: uint16(19968), + 1187: uint16(40908), + 1188: uint16(40960), + 1189: uint16(40981), + 1190: uint16(40982), + 1191: uint16(42128), + 1192: uint16(42192), + 1193: uint16(42232), + 1194: uint16(42238), + 1195: uint16(42240), + 1196: uint16(42508), + 1197: uint16(42509), + 1198: uint16(42512), + 1199: uint16(42528), + 1200: uint16(42538), + 1201: uint16(42560), + 1202: uint16(42606), + 1203: uint16(42607), + 1204: uint16(42608), + 1205: uint16(42611), + 1206: uint16(42612), + 1207: uint16(42622), + 1208: uint16(42623), + 1209: uint16(42624), + 1210: uint16(42655), + 1211: uint16(42656), + 1212: uint16(42726), + 1213: uint16(42736), + 1214: uint16(42738), + 1215: uint16(42752), + 1216: uint16(42775), + 1217: uint16(42784), + 1218: uint16(42786), + 1219: uint16(42800), + 1220: uint16(42802), + 1221: uint16(42864), + 1222: uint16(42865), + 1223: uint16(42873), + 1224: uint16(42878), + 1225: uint16(42888), + 1226: uint16(42889), + 1227: uint16(42891), + 1228: uint16(42896), + 1229: uint16(42912), + 1230: uint16(43000), + 1231: uint16(43002), + 1232: uint16(43003), + 1233: uint16(43010), + 1234: uint16(43011), + 1235: uint16(43014), + 1236: uint16(43015), + 1237: uint16(43019), + 1238: uint16(43020), + 1239: uint16(43043), + 1240: uint16(43045), + 1241: uint16(43047), + 1242: uint16(43048), + 1243: uint16(43056), + 1244: uint16(43062), + 1245: uint16(43064), + 1246: uint16(43065), + 1247: uint16(43072), + 1248: uint16(43124), + 1249: uint16(43136), + 1250: uint16(43138), + 1251: uint16(43188), + 1252: uint16(43204), + 1253: uint16(43214), + 1254: uint16(43216), + 1255: uint16(43232), + 1256: uint16(43250), + 1257: uint16(43256), + 1258: uint16(43259), + 1259: uint16(43264), + 1260: uint16(43274), + 1261: uint16(43302), + 1262: uint16(43310), + 1263: uint16(43312), + 1264: uint16(43335), + 1265: uint16(43346), + 1266: uint16(43359), + 1267: uint16(43360), + 1268: uint16(43392), + 1269: uint16(43395), + 1270: uint16(43396), + 1271: uint16(43443), + 1272: uint16(43444), + 1273: uint16(43446), + 1274: uint16(43450), + 1275: uint16(43452), + 1276: uint16(43453), + 1277: uint16(43457), + 1278: uint16(43471), + 1279: uint16(43472), + 1280: uint16(43486), + 1281: uint16(43520), + 1282: uint16(43561), + 1283: uint16(43567), + 1284: uint16(43569), + 1285: uint16(43571), + 1286: uint16(43573), + 1287: uint16(43584), + 1288: uint16(43587), + 1289: uint16(43588), + 1290: uint16(43596), + 1291: uint16(43597), + 1292: uint16(43600), + 1293: uint16(43612), + 1294: uint16(43616), + 1295: uint16(43632), + 1296: uint16(43633), + 1297: uint16(43639), + 1298: uint16(43642), + 1299: uint16(43643), + 1300: uint16(43648), + 1301: uint16(43696), + 1302: uint16(43697), + 1303: uint16(43698), + 1304: uint16(43701), + 1305: uint16(43703), + 1306: uint16(43705), + 1307: uint16(43710), + 1308: uint16(43712), + 1309: uint16(43713), + 1310: uint16(43714), + 1311: uint16(43739), + 1312: uint16(43741), + 1313: uint16(43742), + 1314: uint16(43744), + 1315: uint16(43755), + 1316: uint16(43756), + 1317: uint16(43758), + 1318: uint16(43760), + 1319: uint16(43762), + 1320: uint16(43763), + 1321: uint16(43765), + 1322: uint16(43766), + 1323: uint16(43777), + 1324: uint16(43785), + 1325: uint16(43793), + 1326: uint16(43808), + 1327: uint16(43816), + 1328: uint16(43968), + 1329: uint16(44003), + 1330: uint16(44005), + 1331: uint16(44006), + 1332: uint16(44008), + 1333: uint16(44009), + 1334: uint16(44011), + 1335: uint16(44012), + 1336: uint16(44013), + 1337: uint16(44016), + 1338: uint16(44032), + 1339: uint16(55203), + 1340: uint16(55216), + 1341: uint16(55243), + 1342: uint16(55296), + 1343: uint16(56191), + 1344: uint16(56319), + 1345: uint16(57343), + 1346: uint16(57344), + 1347: uint16(63743), + 1348: uint16(63744), + 1349: uint16(64112), + 1350: uint16(64256), + 1351: uint16(64275), + 1352: uint16(64285), + 1353: uint16(64286), + 1354: uint16(64287), + 1355: uint16(64297), + 1356: uint16(64298), + 1357: uint16(64312), + 1358: uint16(64318), + 1359: uint16(64320), + 1360: uint16(64323), + 1361: uint16(64326), + 1362: uint16(64434), + 1363: uint16(64467), + 1364: uint16(64830), + 1365: uint16(64831), + 1366: uint16(64848), + 1367: uint16(64914), + 1368: uint16(65008), + 1369: uint16(65020), + 1370: uint16(65021), + 1371: uint16(65024), + 1372: uint16(65040), + 1373: uint16(65047), + 1374: uint16(65048), + 1375: uint16(65049), + 1376: uint16(65056), + 1377: uint16(65072), + 1378: uint16(65073), + 1379: uint16(65075), + 1380: uint16(65077), + 1381: uint16(65078), + 1382: uint16(65079), + 1383: uint16(65080), + 1384: uint16(65081), + 1385: uint16(65082), + 1386: uint16(65083), + 1387: uint16(65084), + 1388: uint16(65085), + 1389: uint16(65086), + 1390: uint16(65087), + 1391: uint16(65088), + 1392: uint16(65089), + 1393: uint16(65090), + 1394: uint16(65091), + 1395: uint16(65092), + 1396: uint16(65093), + 1397: uint16(65095), + 1398: uint16(65096), + 1399: uint16(65097), + 1400: uint16(65101), + 1401: uint16(65104), + 1402: uint16(65108), + 1403: uint16(65112), + 1404: uint16(65113), + 1405: uint16(65114), + 1406: uint16(65115), + 1407: uint16(65116), + 1408: uint16(65117), + 1409: uint16(65118), + 1410: uint16(65119), + 1411: uint16(65122), + 1412: uint16(65123), + 1413: uint16(65124), + 1414: uint16(65128), + 1415: uint16(65129), + 1416: uint16(65130), + 1417: uint16(65136), + 1418: uint16(65142), + 1419: uint16(65279), + 1420: uint16(65281), + 1421: uint16(65284), + 1422: uint16(65285), + 1423: uint16(65288), + 1424: uint16(65289), + 1425: uint16(65290), + 1426: uint16(65291), + 1427: uint16(65292), + 1428: uint16(65293), + 1429: uint16(65294), + 1430: uint16(65296), + 1431: uint16(65306), + 1432: uint16(65308), + 1433: uint16(65311), + 1434: uint16(65313), + 1435: uint16(65339), + 1436: uint16(65340), + 1437: uint16(65341), + 1438: uint16(65342), + 1439: uint16(65343), + 1440: uint16(65344), + 1441: uint16(65345), + 1442: uint16(65371), + 1443: uint16(65372), + 1444: uint16(65373), + 1445: uint16(65374), + 1446: uint16(65375), + 1447: uint16(65376), + 1448: uint16(65377), + 1449: uint16(65378), + 1450: uint16(65379), + 1451: uint16(65380), + 1452: uint16(65382), + 1453: uint16(65392), + 1454: uint16(65393), + 1455: uint16(65438), + 1456: uint16(65440), + 1457: uint16(65474), + 1458: uint16(65482), + 1459: uint16(65490), + 1460: uint16(65498), + 1461: uint16(65504), + 1462: uint16(65506), + 1463: uint16(65507), + 1464: uint16(65508), + 1465: uint16(65509), + 1466: uint16(65512), + 1467: uint16(65513), + 1468: uint16(65517), + 1469: uint16(65529), + 1470: uint16(65532), + 1472: uint16(13), + 1473: uint16(40), + 1474: uint16(60), + 1475: uint16(63), + 1476: uint16(80), + 1477: uint16(128), + 1478: uint16(256), + 1479: uint16(263), + 1480: uint16(311), + 1481: uint16(320), + 1482: uint16(373), + 1483: uint16(377), + 1484: uint16(394), + 1485: uint16(400), + 1486: uint16(464), + 1487: uint16(509), + 1488: uint16(640), + 1489: uint16(672), + 1490: uint16(768), + 1491: uint16(800), + 1492: uint16(816), + 1493: uint16(833), + 1494: uint16(834), + 1495: uint16(842), + 1496: uint16(896), + 1497: uint16(927), + 1498: uint16(928), + 1499: uint16(968), + 1500: uint16(976), + 1501: uint16(977), + 1502: uint16(1024), + 1503: uint16(1064), + 1504: uint16(1104), + 1505: uint16(1184), + 1506: uint16(2048), + 1507: uint16(2056), + 1508: uint16(2058), + 1509: uint16(2103), + 1510: uint16(2108), + 1511: uint16(2111), + 1512: uint16(2135), + 1513: uint16(2136), + 1514: uint16(2304), + 1515: uint16(2326), + 1516: uint16(2335), + 1517: uint16(2336), + 1518: uint16(2367), + 1519: uint16(2432), + 1520: uint16(2494), + 1521: uint16(2560), + 1522: uint16(2561), + 1523: uint16(2565), + 1524: uint16(2572), + 1525: uint16(2576), + 1526: uint16(2581), + 1527: uint16(2585), + 1528: uint16(2616), + 1529: uint16(2623), + 1530: uint16(2624), + 1531: uint16(2640), + 1532: uint16(2656), + 1533: uint16(2685), + 1534: uint16(2687), + 1535: uint16(2816), + 1536: uint16(2873), + 1537: uint16(2880), + 1538: uint16(2904), + 1539: uint16(2912), + 1540: uint16(2936), + 1541: uint16(3072), + 1542: uint16(3680), + 1543: uint16(4096), + 1544: uint16(4097), + 1545: uint16(4098), + 1546: uint16(4099), + 1547: uint16(4152), + 1548: uint16(4167), + 1549: uint16(4178), + 1550: uint16(4198), + 1551: uint16(4224), + 1552: uint16(4226), + 1553: uint16(4227), + 1554: uint16(4272), + 1555: uint16(4275), + 1556: uint16(4279), + 1557: uint16(4281), + 1558: uint16(4283), + 1559: uint16(4285), + 1560: uint16(4286), + 1561: uint16(4304), + 1562: uint16(4336), + 1563: uint16(4352), + 1564: uint16(4355), + 1565: uint16(4391), + 1566: uint16(4396), + 1567: uint16(4397), + 1568: uint16(4406), + 1569: uint16(4416), + 1570: uint16(4480), + 1571: uint16(4482), + 1572: uint16(4483), + 1573: uint16(4531), + 1574: uint16(4534), + 1575: uint16(4543), + 1576: uint16(4545), + 1577: uint16(4549), + 1578: uint16(4560), + 1579: uint16(5760), + 1580: uint16(5803), + 1581: uint16(5804), + 1582: uint16(5805), + 1583: uint16(5806), + 1584: uint16(5808), + 1585: uint16(5814), + 1586: uint16(5815), + 1587: uint16(5824), + 1588: uint16(8192), + 1589: uint16(9216), + 1590: uint16(9328), + 1591: uint16(12288), + 1592: uint16(26624), + 1593: uint16(28416), + 1594: uint16(28496), + 1595: uint16(28497), + 1596: uint16(28559), + 1597: uint16(28563), + 1598: uint16(45056), + 1599: uint16(53248), + 1600: uint16(53504), + 1601: uint16(53545), + 1602: uint16(53605), + 1603: uint16(53607), + 1604: uint16(53610), + 1605: uint16(53613), + 1606: uint16(53619), + 1607: uint16(53627), + 1608: uint16(53635), + 1609: uint16(53637), + 1610: uint16(53644), + 1611: uint16(53674), + 1612: uint16(53678), + 1613: uint16(53760), + 1614: uint16(53826), + 1615: uint16(53829), + 1616: uint16(54016), + 1617: uint16(54112), + 1618: uint16(54272), + 1619: uint16(54298), + 1620: uint16(54324), + 1621: uint16(54350), + 1622: uint16(54358), + 1623: uint16(54376), + 1624: uint16(54402), + 1625: uint16(54428), + 1626: uint16(54430), + 1627: uint16(54434), + 1628: uint16(54437), + 1629: uint16(54441), + 1630: uint16(54446), + 1631: uint16(54454), + 1632: uint16(54459), + 1633: uint16(54461), + 1634: uint16(54469), + 1635: uint16(54480), + 1636: uint16(54506), + 1637: uint16(54532), + 1638: uint16(54535), + 1639: uint16(54541), + 1640: uint16(54550), + 1641: uint16(54558), + 1642: uint16(54584), + 1643: uint16(54587), + 1644: uint16(54592), + 1645: uint16(54598), + 1646: uint16(54602), + 1647: uint16(54610), + 1648: uint16(54636), + 1649: uint16(54662), + 1650: uint16(54688), + 1651: uint16(54714), + 1652: uint16(54740), + 1653: uint16(54766), + 1654: uint16(54792), + 1655: uint16(54818), + 1656: uint16(54844), + 1657: uint16(54870), + 1658: uint16(54896), + 1659: uint16(54922), + 1660: uint16(54952), + 1661: uint16(54977), + 1662: uint16(54978), + 1663: uint16(55003), + 1664: uint16(55004), + 1665: uint16(55010), + 1666: uint16(55035), + 1667: uint16(55036), + 1668: uint16(55061), + 1669: uint16(55062), + 1670: uint16(55068), + 1671: uint16(55093), + 1672: uint16(55094), + 1673: uint16(55119), + 1674: uint16(55120), + 1675: uint16(55126), + 1676: uint16(55151), + 1677: uint16(55152), + 1678: uint16(55177), + 1679: uint16(55178), + 1680: uint16(55184), + 1681: uint16(55209), + 1682: uint16(55210), + 1683: uint16(55235), + 1684: uint16(55236), + 1685: uint16(55242), + 1686: uint16(55246), + 1687: uint16(60928), + 1688: uint16(60933), + 1689: uint16(60961), + 1690: uint16(60964), + 1691: uint16(60967), + 1692: uint16(60969), + 1693: uint16(60980), + 1694: uint16(60985), + 1695: uint16(60987), + 1696: uint16(60994), + 1697: uint16(60999), + 1698: uint16(61001), + 1699: uint16(61003), + 1700: uint16(61005), + 1701: uint16(61009), + 1702: uint16(61012), + 1703: uint16(61015), + 1704: uint16(61017), + 1705: uint16(61019), + 1706: uint16(61021), + 1707: uint16(61023), + 1708: uint16(61025), + 1709: uint16(61028), + 1710: uint16(61031), + 1711: uint16(61036), + 1712: uint16(61044), + 1713: uint16(61049), + 1714: uint16(61054), + 1715: uint16(61056), + 1716: uint16(61067), + 1717: uint16(61089), + 1718: uint16(61093), + 1719: uint16(61099), + 1720: uint16(61168), + 1721: uint16(61440), + 1722: uint16(61488), + 1723: uint16(61600), + 1724: uint16(61617), + 1725: uint16(61633), + 1726: uint16(61649), + 1727: uint16(61696), + 1728: uint16(61712), + 1729: uint16(61744), + 1730: uint16(61808), + 1731: uint16(61926), + 1732: uint16(61968), + 1733: uint16(62016), + 1734: uint16(62032), + 1735: uint16(62208), + 1736: uint16(62256), + 1737: uint16(62263), + 1738: uint16(62336), + 1739: uint16(62368), + 1740: uint16(62406), + 1741: uint16(62432), + 1742: uint16(62464), + 1743: uint16(62528), + 1744: uint16(62530), + 1745: uint16(62713), + 1746: uint16(62720), + 1747: uint16(62784), + 1748: uint16(62800), + 1749: uint16(62971), + 1750: uint16(63045), + 1751: uint16(63104), + 1752: uint16(63232), + 1754: uint16(42710), + 1755: uint16(42752), + 1756: uint16(46900), + 1757: uint16(46912), + 1758: uint16(47133), + 1759: uint16(63488), + 1760: uint16(1), + 1761: uint16(32), + 1762: uint16(256), + 1764: uint16(65533), +} + +// C documentation +// +// /* +// ** This array defines hard upper bounds on limit values. The +// ** initializer must be kept in sync with the SQLITE_LIMIT_* +// ** #defines in sqlite3.h. +// */ +var _aHardLimit = [13]int32{ + 0: int32(SQLITE_MAX_LENGTH), + 1: int32(SQLITE_MAX_SQL_LENGTH), + 2: int32(SQLITE_MAX_COLUMN), + 3: int32(SQLITE_MAX_EXPR_DEPTH), + 4: int32(SQLITE_MAX_COMPOUND_SELECT), + 5: int32(SQLITE_MAX_VDBE_OP), + 6: int32(SQLITE_MAX_FUNCTION_ARG), + 7: int32(SQLITE_MAX_ATTACHED), + 8: int32(SQLITE_MAX_LIKE_PATTERN_LENGTH), + 9: int32(SQLITE_MAX_VARIABLE_NUMBER), + 10: int32(SQLITE_MAX_TRIGGER_DEPTH), + 11: int32(SQLITE_MAX_WORKER_THREADS), + 12: int32(SQLITE_MAX_PARSER_DEPTH), +} + +/* +** Make sure the hard limits are set to reasonable values + */ + +// C documentation +// +// /* +// ** Journal files begin with the following magic string. The data +// ** was obtained from /dev/random. It is used only as a sanity check. +// ** +// ** Since version 2.8.0, the journal format contains additional sanity +// ** checking information. If the power fails while the journal is being +// ** written, semi-random garbage data might appear in the journal +// ** file after power is restored. If an attempt is then made +// ** to roll the journal back, the database could be corrupted. The additional +// ** sanity checking data is an attempt to discover the garbage in the +// ** journal and ignore it. +// ** +// ** The sanity checking information for the new journal format consists +// ** of a 32-bit checksum on each page of data. The checksum covers both +// ** the page number and the pPager->pageSize bytes of data for the page. +// ** This cksum is initialized to a 32-bit random value that appears in the +// ** journal file right after the header. The random initializer is important, +// ** because garbage data that appears at the end of a journal is likely +// ** data that was once in other files that have now been deleted. If the +// ** garbage data came from an obsolete journal file, the checksums might +// ** be correct. But by initializing the checksum to random value which +// ** is different for every journal, we minimize that risk. +// */ +var _aJournalMagic = [8]uint8{ + 0: uint8(0xd9), + 1: uint8(0xd5), + 2: uint8(0x05), + 3: uint8(0xf9), + 4: uint8(0x20), + 5: uint8(0xa1), + 6: uint8(0x63), + 7: uint8(0xd7), +} + +/* +** The size of the of each page record in the journal is given by +** the following macro. + */ + +/* +** The journal header size for this pager. This is usually the same +** size as a single disk sector. See also setSectorSize(). + */ + +/* +** The macro MEMDB is true if we are dealing with an in-memory database. +** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set, +** the value of MEMDB will be a constant and the compiler will optimize +** out code that would never execute. + */ + +/* +** The macro USEFETCH is true if we are allowed to use the xFetch and xUnfetch +** interfaces to access the database using memory-mapped I/O. + */ + +// C documentation +// +// /* aKWCode[i] is the parser symbol code for the i-th keyword */ +var _aKWCode = [148]uint8{ + 1: uint8(TK_REINDEX), + 2: uint8(TK_INDEXED), + 3: uint8(TK_INDEX), + 4: uint8(TK_DESC), + 5: uint8(TK_ESCAPE), + 6: uint8(TK_EACH), + 7: uint8(TK_CHECK), + 8: uint8(TK_KEY), + 9: uint8(TK_BEFORE), + 10: uint8(TK_FOREIGN), + 11: uint8(TK_FOR), + 12: uint8(TK_IGNORE), + 13: uint8(TK_LIKE_KW), + 14: uint8(TK_EXPLAIN), + 15: uint8(TK_INSTEAD), + 16: uint8(TK_ADD), + 17: uint8(TK_DATABASE), + 18: uint8(TK_AS), + 19: uint8(TK_SELECT), + 20: uint8(TK_TABLE), + 21: uint8(TK_JOIN_KW), + 22: uint8(TK_THEN), + 23: uint8(TK_END), + 24: uint8(TK_DEFERRABLE), + 25: uint8(TK_ELSE), + 26: uint8(TK_EXCLUDE), + 27: uint8(TK_DELETE), + 28: uint8(TK_TEMP), + 29: uint8(TK_TEMP), + 30: uint8(TK_OR), + 31: uint8(TK_ISNULL), + 32: uint8(TK_NULLS), + 33: uint8(TK_SAVEPOINT), + 34: uint8(TK_INTERSECT), + 35: uint8(TK_TIES), + 36: uint8(TK_NOTNULL), + 37: uint8(TK_NOT), + 38: uint8(TK_NO), + 39: uint8(TK_NULL), + 40: uint8(TK_LIKE_KW), + 41: uint8(TK_EXCEPT), + 42: uint8(TK_TRANSACTION), + 43: uint8(TK_ACTION), + 44: uint8(TK_ON), + 45: uint8(TK_JOIN_KW), + 46: uint8(TK_ALTER), + 47: uint8(TK_RAISE), + 48: uint8(TK_EXCLUSIVE), + 49: uint8(TK_EXISTS), + 50: uint8(TK_CONSTRAINT), + 51: uint8(TK_INTO), + 52: uint8(TK_OFFSET), + 53: uint8(TK_OF), + 54: uint8(TK_SET), + 55: uint8(TK_TRIGGER), + 56: uint8(TK_RANGE), + 57: uint8(TK_GENERATED), + 58: uint8(TK_DETACH), + 59: uint8(TK_HAVING), + 60: uint8(TK_LIKE_KW), + 61: uint8(TK_BEGIN), + 62: uint8(TK_JOIN_KW), + 63: uint8(TK_REFERENCES), + 64: uint8(TK_UNIQUE), + 65: uint8(TK_QUERY), + 66: uint8(TK_WITHOUT), + 67: uint8(TK_WITH), + 68: uint8(TK_JOIN_KW), + 69: uint8(TK_RELEASE), + 70: uint8(TK_ATTACH), + 71: uint8(TK_BETWEEN), + 72: uint8(TK_NOTHING), + 73: uint8(TK_GROUPS), + 74: uint8(TK_GROUP), + 75: uint8(TK_CASCADE), + 76: uint8(TK_ASC), + 77: uint8(TK_DEFAULT), + 78: uint8(TK_CASE), + 79: uint8(TK_COLLATE), + 80: uint8(TK_CREATE), + 81: uint8(TK_CTIME_KW), + 82: uint8(TK_IMMEDIATE), + 83: uint8(TK_JOIN), + 84: uint8(TK_INSERT), + 85: uint8(TK_MATCH), + 86: uint8(TK_PLAN), + 87: uint8(TK_ANALYZE), + 88: uint8(TK_PRAGMA), + 89: uint8(TK_MATERIALIZED), + 90: uint8(TK_DEFERRED), + 91: uint8(TK_DISTINCT), + 92: uint8(TK_IS), + 93: uint8(TK_UPDATE), + 94: uint8(TK_VALUES), + 95: uint8(TK_VIRTUAL), + 96: uint8(TK_ALWAYS), + 97: uint8(TK_WHEN), + 98: uint8(TK_WHERE), + 99: uint8(TK_RECURSIVE), + 100: uint8(TK_ABORT), + 101: uint8(TK_AFTER), + 102: uint8(TK_RENAME), + 103: uint8(TK_AND), + 104: uint8(TK_DROP), + 105: uint8(TK_PARTITION), + 106: uint8(TK_AUTOINCR), + 107: uint8(TK_TO), + 108: uint8(TK_IN), + 109: uint8(TK_CAST), + 110: uint8(TK_COLUMNKW), + 111: uint8(TK_COMMIT), + 112: uint8(TK_CONFLICT), + 113: uint8(TK_JOIN_KW), + 114: uint8(TK_CTIME_KW), + 115: uint8(TK_CTIME_KW), + 116: uint8(TK_CURRENT), + 117: uint8(TK_PRECEDING), + 118: uint8(TK_FAIL), + 119: uint8(TK_LAST), + 120: uint8(TK_FILTER), + 121: uint8(TK_REPLACE), + 122: uint8(TK_FIRST), + 123: uint8(TK_FOLLOWING), + 124: uint8(TK_FROM), + 125: uint8(TK_JOIN_KW), + 126: uint8(TK_LIMIT), + 127: uint8(TK_IF), + 128: uint8(TK_ORDER), + 129: uint8(TK_RESTRICT), + 130: uint8(TK_OTHERS), + 131: uint8(TK_OVER), + 132: uint8(TK_RETURNING), + 133: uint8(TK_JOIN_KW), + 134: uint8(TK_ROLLBACK), + 135: uint8(TK_ROWS), + 136: uint8(TK_ROW), + 137: uint8(TK_UNBOUNDED), + 138: uint8(TK_UNION), + 139: uint8(TK_USING), + 140: uint8(TK_VACUUM), + 141: uint8(TK_VIEW), + 142: uint8(TK_WINDOW), + 143: uint8(TK_DO), + 144: uint8(TK_BY), + 145: uint8(TK_INITIALLY), + 146: uint8(TK_ALL), + 147: uint8(TK_PRIMARY), +} + +// C documentation +// +// /* aKWHash[i] is the hash value for the i-th keyword */ +var _aKWHash = [127]uint8{ + 0: uint8(84), + 1: uint8(92), + 2: uint8(134), + 3: uint8(82), + 4: uint8(105), + 5: uint8(29), + 8: uint8(94), + 10: uint8(85), + 11: uint8(72), + 13: uint8(53), + 14: uint8(35), + 15: uint8(86), + 16: uint8(15), + 18: uint8(42), + 19: uint8(97), + 20: uint8(54), + 21: uint8(89), + 22: uint8(135), + 23: uint8(19), + 26: uint8(140), + 28: uint8(40), + 29: uint8(129), + 31: uint8(22), + 32: uint8(107), + 34: uint8(9), + 37: uint8(123), + 38: uint8(80), + 40: uint8(78), + 41: uint8(6), + 43: uint8(65), + 44: uint8(103), + 45: uint8(147), + 47: uint8(136), + 48: uint8(115), + 51: uint8(48), + 53: uint8(90), + 54: uint8(24), + 56: uint8(17), + 58: uint8(27), + 59: uint8(70), + 60: uint8(23), + 61: uint8(26), + 62: uint8(5), + 63: uint8(60), + 64: uint8(142), + 65: uint8(110), + 66: uint8(122), + 68: uint8(73), + 69: uint8(91), + 70: uint8(71), + 71: uint8(145), + 72: uint8(61), + 73: uint8(120), + 74: uint8(74), + 76: uint8(49), + 78: uint8(11), + 79: uint8(41), + 81: uint8(113), + 85: uint8(109), + 86: uint8(10), + 87: uint8(111), + 88: uint8(116), + 89: uint8(125), + 90: uint8(14), + 91: uint8(50), + 92: uint8(124), + 94: uint8(100), + 96: uint8(18), + 97: uint8(121), + 98: uint8(144), + 99: uint8(56), + 100: uint8(130), + 101: uint8(139), + 102: uint8(88), + 103: uint8(83), + 104: uint8(37), + 105: uint8(30), + 106: uint8(126), + 109: uint8(108), + 110: uint8(51), + 111: uint8(131), + 112: uint8(128), + 114: uint8(34), + 117: uint8(132), + 119: uint8(98), + 120: uint8(38), + 121: uint8(39), + 123: uint8(20), + 124: uint8(45), + 125: uint8(117), + 126: uint8(93), +} + +// C documentation +// +// /* aKWLen[i] is the length (in bytes) of the i-th keyword */ +var _aKWLen = [148]uint8{ + 1: uint8(7), + 2: uint8(7), + 3: uint8(5), + 4: uint8(4), + 5: uint8(6), + 6: uint8(4), + 7: uint8(5), + 8: uint8(3), + 9: uint8(6), + 10: uint8(7), + 11: uint8(3), + 12: uint8(6), + 13: uint8(6), + 14: uint8(7), + 15: uint8(7), + 16: uint8(3), + 17: uint8(8), + 18: uint8(2), + 19: uint8(6), + 20: uint8(5), + 21: uint8(4), + 22: uint8(4), + 23: uint8(3), + 24: uint8(10), + 25: uint8(4), + 26: uint8(7), + 27: uint8(6), + 28: uint8(9), + 29: uint8(4), + 30: uint8(2), + 31: uint8(6), + 32: uint8(5), + 33: uint8(9), + 34: uint8(9), + 35: uint8(4), + 36: uint8(7), + 37: uint8(3), + 38: uint8(2), + 39: uint8(4), + 40: uint8(4), + 41: uint8(6), + 42: uint8(11), + 43: uint8(6), + 44: uint8(2), + 45: uint8(7), + 46: uint8(5), + 47: uint8(5), + 48: uint8(9), + 49: uint8(6), + 50: uint8(10), + 51: uint8(4), + 52: uint8(6), + 53: uint8(2), + 54: uint8(3), + 55: uint8(7), + 56: uint8(5), + 57: uint8(9), + 58: uint8(6), + 59: uint8(6), + 60: uint8(4), + 61: uint8(5), + 62: uint8(5), + 63: uint8(10), + 64: uint8(6), + 65: uint8(5), + 66: uint8(7), + 67: uint8(4), + 68: uint8(5), + 69: uint8(7), + 70: uint8(6), + 71: uint8(7), + 72: uint8(7), + 73: uint8(6), + 74: uint8(5), + 75: uint8(7), + 76: uint8(3), + 77: uint8(7), + 78: uint8(4), + 79: uint8(7), + 80: uint8(6), + 81: uint8(12), + 82: uint8(9), + 83: uint8(4), + 84: uint8(6), + 85: uint8(5), + 86: uint8(4), + 87: uint8(7), + 88: uint8(6), + 89: uint8(12), + 90: uint8(8), + 91: uint8(8), + 92: uint8(2), + 93: uint8(6), + 94: uint8(6), + 95: uint8(7), + 96: uint8(6), + 97: uint8(4), + 98: uint8(5), + 99: uint8(9), + 100: uint8(5), + 101: uint8(5), + 102: uint8(6), + 103: uint8(3), + 104: uint8(4), + 105: uint8(9), + 106: uint8(13), + 107: uint8(2), + 108: uint8(2), + 109: uint8(4), + 110: uint8(6), + 111: uint8(6), + 112: uint8(8), + 113: uint8(5), + 114: uint8(17), + 115: uint8(12), + 116: uint8(7), + 117: uint8(9), + 118: uint8(4), + 119: uint8(4), + 120: uint8(6), + 121: uint8(7), + 122: uint8(5), + 123: uint8(9), + 124: uint8(4), + 125: uint8(4), + 126: uint8(5), + 127: uint8(2), + 128: uint8(5), + 129: uint8(8), + 130: uint8(6), + 131: uint8(4), + 132: uint8(9), + 133: uint8(5), + 134: uint8(8), + 135: uint8(4), + 136: uint8(3), + 137: uint8(9), + 138: uint8(5), + 139: uint8(5), + 140: uint8(6), + 141: uint8(4), + 142: uint8(6), + 143: uint8(2), + 144: uint8(2), + 145: uint8(9), + 146: uint8(3), + 147: uint8(7), +} + +// C documentation +// +// /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0 +// ** then the i-th keyword has no more hash collisions. Otherwise, +// ** the next keyword with the same hash is aKWHash[i]-1. */ +var _aKWNext = [148]uint8{ + 5: uint8(4), + 7: uint8(43), + 10: uint8(106), + 11: uint8(114), + 15: uint8(2), + 18: uint8(143), + 22: uint8(13), + 27: uint8(141), + 30: uint8(119), + 31: uint8(52), + 34: uint8(137), + 35: uint8(12), + 38: uint8(62), + 40: uint8(138), + 42: uint8(133), + 45: uint8(36), + 48: uint8(28), + 49: uint8(77), + 54: uint8(59), + 56: uint8(47), + 67: uint8(69), + 73: uint8(146), + 74: uint8(3), + 76: uint8(58), + 78: uint8(1), + 79: uint8(75), + 83: uint8(31), + 89: uint8(127), + 91: uint8(104), + 93: uint8(64), + 94: uint8(66), + 95: uint8(63), + 101: uint8(46), + 103: uint8(16), + 104: uint8(8), + 115: uint8(81), + 116: uint8(101), + 118: uint8(112), + 119: uint8(21), + 120: uint8(7), + 121: uint8(67), + 123: uint8(79), + 124: uint8(96), + 125: uint8(118), + 128: uint8(68), + 131: uint8(99), + 132: uint8(44), + 134: uint8(55), + 136: uint8(76), + 138: uint8(95), + 139: uint8(32), + 140: uint8(33), + 141: uint8(57), + 142: uint8(25), + 144: uint8(102), + 147: uint8(87), +} + +// C documentation +// +// /* aKWOffset[i] is the index into zKWText[] of the start of +// ** the text for the i-th keyword. */ +var _aKWOffset = [148]uint16{ + 2: uint16(2), + 3: uint16(2), + 4: uint16(8), + 5: uint16(9), + 6: uint16(14), + 7: uint16(16), + 8: uint16(20), + 9: uint16(23), + 10: uint16(25), + 11: uint16(25), + 12: uint16(29), + 13: uint16(33), + 14: uint16(36), + 15: uint16(41), + 16: uint16(46), + 17: uint16(48), + 18: uint16(53), + 19: uint16(54), + 20: uint16(59), + 21: uint16(62), + 22: uint16(65), + 23: uint16(67), + 24: uint16(69), + 25: uint16(78), + 26: uint16(81), + 27: uint16(86), + 28: uint16(90), + 29: uint16(90), + 30: uint16(94), + 31: uint16(99), + 32: uint16(101), + 33: uint16(105), + 34: uint16(111), + 35: uint16(119), + 36: uint16(123), + 37: uint16(123), + 38: uint16(123), + 39: uint16(126), + 40: uint16(129), + 41: uint16(132), + 42: uint16(137), + 43: uint16(142), + 44: uint16(146), + 45: uint16(147), + 46: uint16(152), + 47: uint16(156), + 48: uint16(160), + 49: uint16(168), + 50: uint16(174), + 51: uint16(181), + 52: uint16(184), + 53: uint16(184), + 54: uint16(187), + 55: uint16(189), + 56: uint16(195), + 57: uint16(198), + 58: uint16(206), + 59: uint16(211), + 60: uint16(216), + 61: uint16(219), + 62: uint16(222), + 63: uint16(226), + 64: uint16(236), + 65: uint16(239), + 66: uint16(244), + 67: uint16(244), + 68: uint16(248), + 69: uint16(252), + 70: uint16(259), + 71: uint16(265), + 72: uint16(271), + 73: uint16(277), + 74: uint16(277), + 75: uint16(283), + 76: uint16(284), + 77: uint16(288), + 78: uint16(295), + 79: uint16(299), + 80: uint16(306), + 81: uint16(312), + 82: uint16(324), + 83: uint16(333), + 84: uint16(335), + 85: uint16(341), + 86: uint16(346), + 87: uint16(348), + 88: uint16(355), + 89: uint16(359), + 90: uint16(370), + 91: uint16(377), + 92: uint16(378), + 93: uint16(385), + 94: uint16(391), + 95: uint16(397), + 96: uint16(402), + 97: uint16(408), + 98: uint16(412), + 99: uint16(415), + 100: uint16(424), + 101: uint16(429), + 102: uint16(433), + 103: uint16(439), + 104: uint16(441), + 105: uint16(444), + 106: uint16(453), + 107: uint16(455), + 108: uint16(457), + 109: uint16(466), + 110: uint16(470), + 111: uint16(476), + 112: uint16(482), + 113: uint16(490), + 114: uint16(495), + 115: uint16(495), + 116: uint16(495), + 117: uint16(511), + 118: uint16(520), + 119: uint16(523), + 120: uint16(527), + 121: uint16(532), + 122: uint16(539), + 123: uint16(544), + 124: uint16(553), + 125: uint16(557), + 126: uint16(560), + 127: uint16(565), + 128: uint16(567), + 129: uint16(571), + 130: uint16(579), + 131: uint16(585), + 132: uint16(588), + 133: uint16(597), + 134: uint16(602), + 135: uint16(610), + 136: uint16(610), + 137: uint16(614), + 138: uint16(623), + 139: uint16(628), + 140: uint16(633), + 141: uint16(639), + 142: uint16(642), + 143: uint16(645), + 144: uint16(648), + 145: uint16(650), + 146: uint16(655), + 147: uint16(659), +} + +var _aKeyword1 = [3]Tu8{ + 0: uint8(TK_CREATE), + 1: uint8(TK_TABLE), +} + +/* The two values have the same sign. Compare using memcmp(). */ +var _aLen = [10]Tu8{ + 1: uint8(1), + 2: uint8(2), + 3: uint8(3), + 4: uint8(4), + 5: uint8(6), + 6: uint8(8), +} + +/* Whether or not a database might need a super-journal depends upon + ** its journal mode (among other things). This matrix determines which + ** journal modes use a super-journal and which do not */ +var _aMJNeeded = [6]Tu8{ + 0: uint8(1), + 1: uint8(1), + 3: uint8(1), +} + +/* +** This routine checks that the sqlite3.nVdbeActive count variable +** matches the number of vdbe's in the list sqlite3.pVdbe that are +** currently active. An assertion fails if the two counts do not match. +** This is an internal self-check only - it is not an essential processing +** step. +** +** This is a no-op if NDEBUG is defined. + */ + +var _aMask = [12]uint8{ + 0: uint8(0x10), + 1: uint8(0x01), + 2: uint8(0x01), + 3: uint8(0x01), + 4: uint8(0x01), + 5: uint8(0x01), + 6: uint8(0x01), + 7: uint8(0x2), + 8: uint8(0x01), + 9: uint8(0x01), + 10: uint8(0x10), + 11: uint8(0x10), +} + +/* The aMx[] array translates the 3rd character of each format + ** spec into a max size: a b c d e f */ +var _aMx = [6]Tu16{ + 0: uint16(12), + 1: uint16(14), + 2: uint16(24), + 3: uint16(31), + 4: uint16(59), + 5: uint16(14712), +} + +var _aNull = [1]Tu8{} + +var _aOp1 = [5]int32{ + 0: int32(OP_Ge), + 1: int32(OP_Ge), + 2: int32(OP_Gt), + 3: int32(OP_Ge), + 4: int32(OP_Ge), +} + +var _aScaleLo = [26]uint32{ + 0: uint32(0x205b896d), + 1: uint32(0x52064cad), + 2: uint32(0xaf2af2b8), + 3: uint32(0x5a7744a7), + 4: uint32(0xaf39a475), + 5: uint32(0xbd8d794e), + 6: uint32(0x547eb47b), + 7: uint32(0x0cb4a5a3), + 8: uint32(0x92f34d62), + 9: uint32(0x3a6a07f9), + 10: uint32(0xfae27299), + 11: uint32(0xaa97e14c), + 12: uint32(0x775ea265), + 13: uint32(0xcccccccc), + 15: uint32(0x999090b6), + 16: uint32(0x69a028bb), + 17: uint32(0xe80e6f48), + 18: uint32(0x5ec05dd0), + 19: uint32(0x14588f14), + 20: uint32(0x8f1668c9), + 21: uint32(0x6d953e2c), + 22: uint32(0x4abdaf10), + 23: uint32(0xbc633b39), + 24: uint32(0x0a862f81), + 25: uint32(0x6c07a2c2), +} + +var _aStart = [2]Tu8{ + 0: uint8(OP_Rewind), + 1: uint8(OP_Last), +} + +/* Case 4: Search using an index. + ** + ** The WHERE clause may contain zero or more equality + ** terms ("==" or "IN" or "IS" operators) that refer to the N + ** left-most columns of the index. It may also contain + ** inequality constraints (>, <, >= or <=) on the indexed + ** column that immediately follows the N equalities. Only + ** the right-most column can be an inequality - the rest must + ** use the "==", "IN", or "IS" operators. For example, if the + ** index is on (x,y,z), then the following clauses are all + ** optimized: + ** + ** x=5 + ** x=5 AND y=10 + ** x=5 AND y<10 + ** x=5 AND y>5 AND y<10 + ** x=5 AND y=5 AND z<=10 + ** + ** The z<10 term of the following cannot be used, only + ** the x=5 term: + ** + ** x=5 AND z<10 + ** + ** N may be zero if there are inequality constraints. + ** If there are no inequality constraints, then N is at + ** least one. + ** + ** This case is also used when there are no WHERE clause + ** constraints but an index is selected anyway, in order + ** to force the output order to conform to an ORDER BY. + */ +var _aStartOp = [8]Tu8{ + 2: uint8(OP_Rewind), + 3: uint8(OP_Last), + 4: uint8(OP_SeekGT), + 5: uint8(OP_SeekLT), + 6: uint8(OP_SeekGE), + 7: uint8(OP_SeekLE), +} + +/* (2) Datatype must be exact for non-ANY columns in STRICT tables*/ +var _aStdTypeMask = [6]uint8{ + 0: uint8(0x1f), + 1: uint8(0x18), + 2: uint8(0x11), + 3: uint8(0x11), + 4: uint8(0x13), + 5: uint8(0x14), +} + +/* Case 6: There is no usable index. We must do a complete + ** scan of the entire table. + */ +var _aStep = [2]Tu8{ + 0: uint8(OP_Next), + 1: uint8(OP_Prev), +} + +var _aType = [64]Tu8{ + 0: uint8(SQLITE_BLOB), + 1: uint8(SQLITE_NULL), + 2: uint8(SQLITE_TEXT), + 3: uint8(SQLITE_NULL), + 4: uint8(SQLITE_INTEGER), + 5: uint8(SQLITE_NULL), + 6: uint8(SQLITE_INTEGER), + 7: uint8(SQLITE_NULL), + 8: uint8(SQLITE_FLOAT), + 9: uint8(SQLITE_NULL), + 10: uint8(SQLITE_FLOAT), + 11: uint8(SQLITE_NULL), + 12: uint8(SQLITE_INTEGER), + 13: uint8(SQLITE_NULL), + 14: uint8(SQLITE_INTEGER), + 15: uint8(SQLITE_NULL), + 16: uint8(SQLITE_BLOB), + 17: uint8(SQLITE_NULL), + 18: uint8(SQLITE_TEXT), + 19: uint8(SQLITE_NULL), + 20: uint8(SQLITE_INTEGER), + 21: uint8(SQLITE_NULL), + 22: uint8(SQLITE_INTEGER), + 23: uint8(SQLITE_NULL), + 24: uint8(SQLITE_FLOAT), + 25: uint8(SQLITE_NULL), + 26: uint8(SQLITE_FLOAT), + 27: uint8(SQLITE_NULL), + 28: uint8(SQLITE_INTEGER), + 29: uint8(SQLITE_NULL), + 30: uint8(SQLITE_INTEGER), + 31: uint8(SQLITE_NULL), + 32: uint8(SQLITE_FLOAT), + 33: uint8(SQLITE_NULL), + 34: uint8(SQLITE_FLOAT), + 35: uint8(SQLITE_NULL), + 36: uint8(SQLITE_FLOAT), + 37: uint8(SQLITE_NULL), + 38: uint8(SQLITE_FLOAT), + 39: uint8(SQLITE_NULL), + 40: uint8(SQLITE_FLOAT), + 41: uint8(SQLITE_NULL), + 42: uint8(SQLITE_FLOAT), + 43: uint8(SQLITE_NULL), + 44: uint8(SQLITE_FLOAT), + 45: uint8(SQLITE_NULL), + 46: uint8(SQLITE_FLOAT), + 47: uint8(SQLITE_NULL), + 48: uint8(SQLITE_BLOB), + 49: uint8(SQLITE_NULL), + 50: uint8(SQLITE_TEXT), + 51: uint8(SQLITE_NULL), + 52: uint8(SQLITE_FLOAT), + 53: uint8(SQLITE_NULL), + 54: uint8(SQLITE_FLOAT), + 55: uint8(SQLITE_NULL), + 56: uint8(SQLITE_FLOAT), + 57: uint8(SQLITE_NULL), + 58: uint8(SQLITE_FLOAT), + 59: uint8(SQLITE_NULL), + 60: uint8(SQLITE_FLOAT), + 61: uint8(SQLITE_NULL), + 62: uint8(SQLITE_FLOAT), + 63: uint8(SQLITE_NULL), +} + +/* Lookup table for finding the upper 4 bits of the first byte of the + ** expanded aIns[], based on the size of the expanded aIns[] header: + ** + ** 2 3 4 5 6 7 8 9 */ +var _aType1 = [8]Tu8{ + 0: uint8(0xc0), + 1: uint8(0xd0), + 3: uint8(0xe0), + 7: uint8(0xf0), +} + +/* 10, 9, 8, 7, 6 */ +var _aVal = [5]TLogEst{ + 0: int16(33), + 1: int16(32), + 2: int16(30), + 3: int16(28), + 4: int16(26), +} + +var _aZero = [4]Tu32{} + +// C documentation +// +// /* +// ** Deallocate a single AggInfo object +// */ +func _agginfoFree(tls *libc.TLS, db uintptr, pArg uintptr) { + var p uintptr + _ = p + p = pArg + _sqlite3DbFree(tls, db, (*TAggInfo)(unsafe.Pointer(p)).FaCol) + _sqlite3DbFree(tls, db, (*TAggInfo)(unsafe.Pointer(p)).FaFunc) + _sqlite3DbFreeNN(tls, db, p) +} + +var _aiClass = [256]uint8{ + 0: uint8(29), + 1: uint8(28), + 2: uint8(28), + 3: uint8(28), + 4: uint8(28), + 5: uint8(28), + 6: uint8(28), + 7: uint8(28), + 8: uint8(28), + 9: uint8(7), + 10: uint8(7), + 11: uint8(28), + 12: uint8(7), + 13: uint8(7), + 14: uint8(28), + 15: uint8(28), + 16: uint8(28), + 17: uint8(28), + 18: uint8(28), + 19: uint8(28), + 20: uint8(28), + 21: uint8(28), + 22: uint8(28), + 23: uint8(28), + 24: uint8(28), + 25: uint8(28), + 26: uint8(28), + 27: uint8(28), + 28: uint8(28), + 29: uint8(28), + 30: uint8(28), + 31: uint8(28), + 32: uint8(7), + 33: uint8(15), + 34: uint8(8), + 35: uint8(5), + 36: uint8(4), + 37: uint8(22), + 38: uint8(24), + 39: uint8(8), + 40: uint8(17), + 41: uint8(18), + 42: uint8(21), + 43: uint8(20), + 44: uint8(23), + 45: uint8(11), + 46: uint8(26), + 47: uint8(16), + 48: uint8(3), + 49: uint8(3), + 50: uint8(3), + 51: uint8(3), + 52: uint8(3), + 53: uint8(3), + 54: uint8(3), + 55: uint8(3), + 56: uint8(3), + 57: uint8(3), + 58: uint8(5), + 59: uint8(19), + 60: uint8(12), + 61: uint8(14), + 62: uint8(13), + 63: uint8(6), + 64: uint8(5), + 65: uint8(1), + 66: uint8(1), + 67: uint8(1), + 68: uint8(1), + 69: uint8(1), + 70: uint8(1), + 71: uint8(1), + 72: uint8(1), + 73: uint8(1), + 74: uint8(1), + 75: uint8(1), + 76: uint8(1), + 77: uint8(1), + 78: uint8(1), + 79: uint8(1), + 80: uint8(1), + 81: uint8(1), + 82: uint8(1), + 83: uint8(1), + 84: uint8(1), + 85: uint8(1), + 86: uint8(1), + 87: uint8(1), + 89: uint8(2), + 90: uint8(2), + 91: uint8(9), + 92: uint8(28), + 93: uint8(28), + 94: uint8(28), + 95: uint8(2), + 96: uint8(8), + 97: uint8(1), + 98: uint8(1), + 99: uint8(1), + 100: uint8(1), + 101: uint8(1), + 102: uint8(1), + 103: uint8(1), + 104: uint8(1), + 105: uint8(1), + 106: uint8(1), + 107: uint8(1), + 108: uint8(1), + 109: uint8(1), + 110: uint8(1), + 111: uint8(1), + 112: uint8(1), + 113: uint8(1), + 114: uint8(1), + 115: uint8(1), + 116: uint8(1), + 117: uint8(1), + 118: uint8(1), + 119: uint8(1), + 121: uint8(2), + 122: uint8(2), + 123: uint8(28), + 124: uint8(10), + 125: uint8(28), + 126: uint8(25), + 127: uint8(28), + 128: uint8(27), + 129: uint8(27), + 130: uint8(27), + 131: uint8(27), + 132: uint8(27), + 133: uint8(27), + 134: uint8(27), + 135: uint8(27), + 136: uint8(27), + 137: uint8(27), + 138: uint8(27), + 139: uint8(27), + 140: uint8(27), + 141: uint8(27), + 142: uint8(27), + 143: uint8(27), + 144: uint8(27), + 145: uint8(27), + 146: uint8(27), + 147: uint8(27), + 148: uint8(27), + 149: uint8(27), + 150: uint8(27), + 151: uint8(27), + 152: uint8(27), + 153: uint8(27), + 154: uint8(27), + 155: uint8(27), + 156: uint8(27), + 157: uint8(27), + 158: uint8(27), + 159: uint8(27), + 160: uint8(27), + 161: uint8(27), + 162: uint8(27), + 163: uint8(27), + 164: uint8(27), + 165: uint8(27), + 166: uint8(27), + 167: uint8(27), + 168: uint8(27), + 169: uint8(27), + 170: uint8(27), + 171: uint8(27), + 172: uint8(27), + 173: uint8(27), + 174: uint8(27), + 175: uint8(27), + 176: uint8(27), + 177: uint8(27), + 178: uint8(27), + 179: uint8(27), + 180: uint8(27), + 181: uint8(27), + 182: uint8(27), + 183: uint8(27), + 184: uint8(27), + 185: uint8(27), + 186: uint8(27), + 187: uint8(27), + 188: uint8(27), + 189: uint8(27), + 190: uint8(27), + 191: uint8(27), + 192: uint8(27), + 193: uint8(27), + 194: uint8(27), + 195: uint8(27), + 196: uint8(27), + 197: uint8(27), + 198: uint8(27), + 199: uint8(27), + 200: uint8(27), + 201: uint8(27), + 202: uint8(27), + 203: uint8(27), + 204: uint8(27), + 205: uint8(27), + 206: uint8(27), + 207: uint8(27), + 208: uint8(27), + 209: uint8(27), + 210: uint8(27), + 211: uint8(27), + 212: uint8(27), + 213: uint8(27), + 214: uint8(27), + 215: uint8(27), + 216: uint8(27), + 217: uint8(27), + 218: uint8(27), + 219: uint8(27), + 220: uint8(27), + 221: uint8(27), + 222: uint8(27), + 223: uint8(27), + 224: uint8(27), + 225: uint8(27), + 226: uint8(27), + 227: uint8(27), + 228: uint8(27), + 229: uint8(27), + 230: uint8(27), + 231: uint8(27), + 232: uint8(27), + 233: uint8(27), + 234: uint8(27), + 235: uint8(27), + 236: uint8(27), + 237: uint8(27), + 238: uint8(27), + 239: uint8(30), + 240: uint8(27), + 241: uint8(27), + 242: uint8(27), + 243: uint8(27), + 244: uint8(27), + 245: uint8(27), + 246: uint8(27), + 247: uint8(27), + 248: uint8(27), + 249: uint8(27), + 250: uint8(27), + 251: uint8(27), + 252: uint8(27), + 253: uint8(27), + 254: uint8(27), + 255: uint8(27), +} + +/* +** The charMap() macro maps alphabetic characters (only) into their +** lower-case ASCII equivalent. On ASCII machines, this is just +** an upper-to-lower case map. On EBCDIC machines we also need +** to adjust the encoding. The mapping is only valid for alphabetics +** which are the only characters for which this feature is used. +** +** Used by keywordhash.h + */ + +var _aiOff = [77]uint16{ + 0: uint16(1), + 1: uint16(2), + 2: uint16(8), + 3: uint16(15), + 4: uint16(16), + 5: uint16(26), + 6: uint16(28), + 7: uint16(32), + 8: uint16(37), + 9: uint16(38), + 10: uint16(40), + 11: uint16(48), + 12: uint16(63), + 13: uint16(64), + 14: uint16(69), + 15: uint16(71), + 16: uint16(79), + 17: uint16(80), + 18: uint16(116), + 19: uint16(202), + 20: uint16(203), + 21: uint16(205), + 22: uint16(206), + 23: uint16(207), + 24: uint16(209), + 25: uint16(210), + 26: uint16(211), + 27: uint16(213), + 28: uint16(214), + 29: uint16(217), + 30: uint16(218), + 31: uint16(219), + 32: uint16(775), + 33: uint16(7264), + 34: uint16(10792), + 35: uint16(10795), + 36: uint16(23228), + 37: uint16(23256), + 38: uint16(30204), + 39: uint16(54721), + 40: uint16(54753), + 41: uint16(54754), + 42: uint16(54756), + 43: uint16(54787), + 44: uint16(54793), + 45: uint16(54809), + 46: uint16(57153), + 47: uint16(57274), + 48: uint16(57921), + 49: uint16(58019), + 50: uint16(58363), + 51: uint16(61722), + 52: uint16(65268), + 53: uint16(65341), + 54: uint16(65373), + 55: uint16(65406), + 56: uint16(65408), + 57: uint16(65410), + 58: uint16(65415), + 59: uint16(65424), + 60: uint16(65436), + 61: uint16(65439), + 62: uint16(65450), + 63: uint16(65462), + 64: uint16(65472), + 65: uint16(65476), + 66: uint16(65478), + 67: uint16(65480), + 68: uint16(65482), + 69: uint16(65488), + 70: uint16(65506), + 71: uint16(65511), + 72: uint16(65514), + 73: uint16(65521), + 74: uint16(65527), + 75: uint16(65528), + 76: uint16(65529), +} + +// C documentation +// +// /* +// ** Return true if the first nCons constraints in the pUsage array are +// ** marked as in-use (have argvIndex>0). False otherwise. +// */ +func _allConstraintsUsed(tls *libc.TLS, aUsage uintptr, nCons int32) (r int32) { + var ii int32 + _ = ii + ii = 0 + for { + if !(ii < nCons) { + break + } + if (**(**Tsqlite3_index_constraint_usage)(__ccgo_up(aUsage + uintptr(ii)*8))).FargvIndex <= 0 { + return 0 + } + goto _1 + _1: + ; + ii = ii + 1 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Return TRUE if the given operator is one of the operators that is +// ** allowed for an indexable WHERE clause term. The allowed operators are +// ** "=", "<", ">", "<=", ">=", "IN", "IS", and "IS NULL" +// */ +func _allowedOp(tls *libc.TLS, op int32) (r int32) { + if op > int32(TK_GE) { + return 0 + } + if op >= int32(TK_EQ) { + return int32(1) + } + return libc.BoolInt32(op == int32(TK_IN) || op == int32(TK_ISNULL) || op == int32(TK_IS)) +} + +// C documentation +// +// /* +// ** The string in pRec is known to look like an integer and to have a +// ** floating point value of rValue. Return true and set *piValue to the +// ** integer value if the string is in range to be an integer. Otherwise, +// ** return false. +// */ +func _alsoAnInt(tls *libc.TLS, pRec uintptr, rValue float64, piValue uintptr) (r int32) { + var iValue Ti64 + _ = iValue + iValue = _sqlite3RealToI64(tls, rValue) + if _sqlite3RealSameAsInt(tls, rValue, iValue) != 0 { + **(**Ti64)(__ccgo_up(piValue)) = iValue + return int32(1) + } + return libc.BoolInt32(0 == _sqlite3Atoi64(tls, (*TMem)(unsafe.Pointer(pRec)).Fz, piValue, (*TMem)(unsafe.Pointer(pRec)).Fn, (*TMem)(unsafe.Pointer(pRec)).Fenc)) +} + +func _analyzeFilterKeyword(tls *libc.TLS, _z uintptr, lastToken int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _z + if lastToken == int32(TK_RP) && _getToken(tls, bp) == int32(TK_LP) { + return int32(TK_FILTER) + } + return int32(TK_ID) +} + +func _analyzeOverKeyword(tls *libc.TLS, _z uintptr, lastToken int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _z + var t int32 + _ = t + if lastToken == int32(TK_RP) { + t = _getToken(tls, bp) + if t == int32(TK_LP) || t == int32(TK_ID) { + return int32(TK_OVER) + } + } + return int32(TK_ID) +} + +// C documentation +// +// /* +// ** The following three functions are called immediately after the tokenizer +// ** reads the keywords WINDOW, OVER and FILTER, respectively, to determine +// ** whether the token should be treated as a keyword or an SQL identifier. +// ** This cannot be handled by the usual lemon %fallback method, due to +// ** the ambiguity in some constructions. e.g. +// ** +// ** SELECT sum(x) OVER ... +// ** +// ** In the above, "OVER" might be a keyword, or it might be an alias for the +// ** sum(x) expression. If a "%fallback ID OVER" directive were added to +// ** grammar, then SQLite would always treat "OVER" as an alias, making it +// ** impossible to call a window-function without a FILTER clause. +// ** +// ** WINDOW is treated as a keyword if: +// ** +// ** * the following token is an identifier, or a keyword that can fallback +// ** to being an identifier, and +// ** * the token after than one is TK_AS. +// ** +// ** OVER is a keyword if: +// ** +// ** * the previous token was TK_RP, and +// ** * the next token is either TK_LP or an identifier. +// ** +// ** FILTER is a keyword if: +// ** +// ** * the previous token was TK_RP, and +// ** * the next token is TK_LP. +// */ +func _analyzeWindowKeyword(tls *libc.TLS, _z uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _z + var t int32 + _ = t + t = _getToken(tls, bp) + if t != int32(TK_ID) { + return int32(TK_ID) + } + t = _getToken(tls, bp) + if t != int32(TK_AS) { + return int32(TK_ID) + } + return int32(TK_WINDOW) +} + +var _and_logic = [9]uint8{ + 4: uint8(1), + 5: uint8(2), + 7: uint8(2), + 8: uint8(2), +} + +// C documentation +// +// /* +// ** Take actions at the end of an API call to deal with error codes. +// */ +func _apiHandleError(tls *libc.TLS, db uintptr, rc int32) (r int32) { + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)< 0 { + _sqlite3VdbeAddOp2(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_MemMax), memId, regRowid) + } +} + +func _avgFinalize(tls *libc.TLS, context uintptr) { + var p uintptr + var r float64 + _, _ = p, r + p = Xsqlite3_aggregate_context(tls, context, 0) + if p != 0 && (*TSumCtx)(unsafe.Pointer(p)).Fcnt > 0 { + if (*TSumCtx)(unsafe.Pointer(p)).Fapprox != 0 { + r = (*TSumCtx)(unsafe.Pointer(p)).FrSum + if !(_sqlite3IsOverflow(tls, (*TSumCtx)(unsafe.Pointer(p)).FrErr) != 0) { + r = r + (*TSumCtx)(unsafe.Pointer(p)).FrErr + } + } else { + r = float64((*TSumCtx)(unsafe.Pointer(p)).FiSum) + } + Xsqlite3_result_double(tls, context, r/float64((*TSumCtx)(unsafe.Pointer(p)).Fcnt)) + } +} + +var _azExplainColNames16data = [60]Tu16{ + 0: uint16('a'), + 1: uint16('d'), + 2: uint16('d'), + 3: uint16('r'), + 5: uint16('o'), + 6: uint16('p'), + 7: uint16('c'), + 8: uint16('o'), + 9: uint16('d'), + 10: uint16('e'), + 12: uint16('p'), + 13: uint16('1'), + 15: uint16('p'), + 16: uint16('2'), + 18: uint16('p'), + 19: uint16('3'), + 21: uint16('p'), + 22: uint16('4'), + 24: uint16('p'), + 25: uint16('5'), + 27: uint16('c'), + 28: uint16('o'), + 29: uint16('m'), + 30: uint16('m'), + 31: uint16('e'), + 32: uint16('n'), + 33: uint16('t'), + 35: uint16('i'), + 36: uint16('d'), + 38: uint16('p'), + 39: uint16('a'), + 40: uint16('r'), + 41: uint16('e'), + 42: uint16('n'), + 43: uint16('t'), + 45: uint16('n'), + 46: uint16('o'), + 47: uint16('t'), + 48: uint16('u'), + 49: uint16('s'), + 50: uint16('e'), + 51: uint16('d'), + 53: uint16('d'), + 54: uint16('e'), + 55: uint16('t'), + 56: uint16('a'), + 57: uint16('i'), + 58: uint16('l'), +} + +// C documentation +// +// /* +// ** If pFile is currently larger than iSize bytes, then truncate it to +// ** exactly iSize bytes. If pFile is not larger than iSize bytes, then +// ** this function is a no-op. +// ** +// ** Return SQLITE_OK if everything is successful, or an SQLite error +// ** code if an error occurs. +// */ +func _backupTruncateFile(tls *libc.TLS, pFile uintptr, iSize Ti64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* iCurrent at bp+0 */ Ti64 + _ = rc + rc = _sqlite3OsFileSize(tls, pFile, bp) + if rc == SQLITE_OK && **(**Ti64)(__ccgo_up(bp)) > iSize { + rc = _sqlite3OsTruncate(tls, pFile, iSize) + } + return rc +} + +// C documentation +// +// /* +// ** This function is called after the contents of page iPage of the +// ** source database have been modified. If page iPage has already been +// ** copied into the destination database, then the data written to the +// ** destination is now invalidated. The destination copy of iPage needs +// ** to be updated with the new data before the backup operation is +// ** complete. +// ** +// ** It is assumed that the mutex associated with the BtShared object +// ** corresponding to the source database is held when this function is +// ** called. +// */ +func _backupUpdate(tls *libc.TLS, p uintptr, iPage TPgno, aData uintptr) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + for { + if !(_isFatalError(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).Frc) != 0) && iPage < (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex) + rc = _backupOnePage(tls, p, iPage, aData, int32(1)) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex) + if rc != SQLITE_OK { + (*Tsqlite3_backup)(unsafe.Pointer(p)).Frc = rc + } + } + goto _2 + _2: + ; + v1 = (*Tsqlite3_backup)(unsafe.Pointer(p)).FpNext + p = v1 + if !(v1 != uintptr(0)) { + break + } + } +} + +// C documentation +// +// /* +// ** Clear (destroy) the BtShared.pHasContent bitvec. This should be +// ** invoked at the conclusion of each write-transaction. +// */ +func _btreeClearHasContent(tls *libc.TLS, pBt uintptr) { + _sqlite3BitvecDestroy(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent) + (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent = uintptr(0) +} + +// C documentation +// +// /* +// ** Create a new cursor for the BTree whose root is on the page +// ** iTable. If a read-only cursor is requested, it is assumed that +// ** the caller already has at least a read-only transaction open +// ** on the database already. If a write-cursor is requested, then +// ** the caller is assumed to have an open write transaction. +// ** +// ** If the BTREE_WRCSR bit of wrFlag is clear, then the cursor can only +// ** be used for reading. If the BTREE_WRCSR bit is set, then the cursor +// ** can be used for reading or for writing if other conditions for writing +// ** are also met. These are the conditions that must be met in order +// ** for writing to be allowed: +// ** +// ** 1: The cursor must have been opened with wrFlag containing BTREE_WRCSR +// ** +// ** 2: Other database connections that share the same pager cache +// ** but which are not in the READ_UNCOMMITTED state may not have +// ** cursors open with wrFlag==0 on the same table. Otherwise +// ** the changes made by this write cursor would be visible to +// ** the read cursors in the other database connection. +// ** +// ** 3: The database must be writable (not on read-only media) +// ** +// ** 4: There must be an active transaction. +// ** +// ** The BTREE_FORDELETE bit of wrFlag may optionally be set if BTREE_WRCSR +// ** is set. If FORDELETE is set, that is a hint to the implementation that +// ** this cursor will only be used to seek to and delete entries of an index +// ** as part of a larger DELETE statement. The FORDELETE hint is not used by +// ** this implementation. But in a hypothetical alternative storage engine +// ** in which index entries are automatically deleted when corresponding table +// ** rows are deleted, the FORDELETE flag is a hint that all SEEK and DELETE +// ** operations on this cursor can be no-ops and all READ operations can +// ** return a null row (2-bytes: 0x01 0x00). +// ** +// ** No checking is done to make sure that page iTable really is the +// ** root page of a b-tree. If it is not, then the cursor acquired +// ** will not work correctly. +// ** +// ** It is assumed that the sqlite3BtreeCursorZero() has been called +// ** on pCur to initialize the memory space prior to invoking this routine. +// */ +func _btreeCursor(tls *libc.TLS, p uintptr, iTable TPgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) (r int32) { + var pBt, pX, v2 uintptr + _, _, _ = pBt, pX, v2 + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt /* Looping over other all cursors */ + /* The following assert statements verify that if this is a sharable + ** b-tree database, the connection is holding the required table locks, + ** and that no other connection has any open cursor that conflicts with + ** this lock. The iTable<1 term disables the check for corrupt schemas. */ + /* Assert that the caller has opened the required transaction. */ + if iTable <= uint32(1) { + if iTable < uint32(1) { + return _sqlite3CorruptError(tls, int32(77858)) + } else { + if _btreePagecount(tls, pBt) == uint32(0) { + iTable = uint32(0) + } + } + } + /* Now that no other errors can occur, finish filling in the BtCursor + ** variables and link the cursor into the BtShared list. */ + (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot = iTable + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = int8(-int32(1)) + (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo = pKeyInfo + (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree = p + (*TBtCursor)(unsafe.Pointer(pCur)).FpBt = pBt + (*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags = uint8(0) + /* If there are two or more cursors on the same btree, then all such + ** cursors *must* have the BTCF_Multiple flag set. */ + pX = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor + for { + if !(pX != 0) { + break + } + if (*TBtCursor)(unsafe.Pointer(pX)).FpgnoRoot == iTable { + v2 = pX + 1 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(BTCF_Multiple)) + (*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags = uint8(BTCF_Multiple) + } + goto _1 + _1: + ; + pX = (*TBtCursor)(unsafe.Pointer(pX)).FpNext + } + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID) + (*TBtCursor)(unsafe.Pointer(pCur)).FpNext = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor + (*TBtShared)(unsafe.Pointer(pBt)).FpCursor = pCur + if wrFlag != 0 { + v2 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(BTCF_WriteFlag)) + (*TBtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags = uint8(0) + if (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace == uintptr(0) { + return _allocateTempSpace(tls, pBt) + } + } else { + (*TBtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags = uint8(PAGER_GET_READONLY) + } + return SQLITE_OK +} + +func _btreeCursorWithLock(tls *libc.TLS, p uintptr, iTable TPgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) (r int32) { + var rc int32 + _ = rc + _sqlite3BtreeEnter(tls, p) + rc = _btreeCursor(tls, p, iTable, wrFlag, pKeyInfo, pCur) + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Query the BtShared.pHasContent vector. +// ** +// ** This function is called when a free-list leaf page is removed from the +// ** free-list for reuse. It returns false if it is safe to retrieve the +// ** page from the pager layer with the 'no-content' flag set. True otherwise. +// */ +func _btreeGetHasContent(tls *libc.TLS, pBt uintptr, pgno TPgno) (r int32) { + var p uintptr + _ = p + p = (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent + return libc.BoolInt32(p != 0 && (pgno > _sqlite3BitvecSize(tls, p) || _sqlite3BitvecTestNotNull(tls, p, pgno) != 0)) +} + +// C documentation +// +// /* +// ** Get a page from the pager. Initialize the MemPage.pBt and +// ** MemPage.aData elements if needed. See also: btreeGetUnusedPage(). +// ** +// ** If the PAGER_GET_NOCONTENT flag is set, it means that we do not care +// ** about the content of the page at this time. So do not go to the disk +// ** to fetch the content. Just fill in the content with zeros for now. +// ** If in the future we call sqlite3PagerWrite() on this page, that +// ** means we have started to be concerned about content and the disk +// ** read should occur at that point. +// */ +func _btreeGetPage(tls *libc.TLS, pBt uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pDbPage at bp+0 */ uintptr + _ = rc + rc = _sqlite3PagerGet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pgno, bp, flags) + if rc != 0 { + return rc + } + **(**uintptr)(__ccgo_up(ppPage)) = _btreePageFromDbPage(tls, **(**uintptr)(__ccgo_up(bp)), pgno, pBt) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Get an unused page. +// ** +// ** This works just like btreeGetPage() with the addition: +// ** +// ** * If the page is already in use for some other purpose, immediately +// ** release it and return an SQLITE_CURRUPT error. +// ** * Make sure the isInit flag is clear +// */ +func _btreeGetUnusedPage(tls *libc.TLS, pBt uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) { + var rc int32 + _ = rc + rc = _btreeGetPage(tls, pBt, pgno, ppPage, flags) + if rc == SQLITE_OK { + if _sqlite3PagerPageRefcount(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppPage)))).FpDbPage) > int32(1) { + _releasePage(tls, **(**uintptr)(__ccgo_up(ppPage))) + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return _sqlite3CorruptError(tls, int32(75601)) + } + (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppPage)))).FisInit = uint8(0) + } else { + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + } + return rc +} + +// C documentation +// +// /* +// ** An implementation of a min-heap. +// ** +// ** aHeap[0] is the number of elements on the heap. aHeap[1] is the +// ** root element. The daughter nodes of aHeap[N] are aHeap[N*2] +// ** and aHeap[N*2+1]. +// ** +// ** The heap property is this: Every node is less than or equal to both +// ** of its daughter nodes. A consequence of the heap property is that the +// ** root node aHeap[1] is always the minimum value currently in the heap. +// ** +// ** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto +// ** the heap, preserving the heap property. The btreeHeapPull() routine +// ** removes the root element from the heap (the minimum value in the heap) +// ** and then moves other nodes around as necessary to preserve the heap +// ** property. +// ** +// ** This heap is used for cell overlap and coverage testing. Each u32 +// ** entry represents the span of a cell or freeblock on a btree page. +// ** The upper 16 bits are the index of the first byte of a range and the +// ** lower 16 bits are the index of the last byte of that range. +// */ +func _btreeHeapInsert(tls *libc.TLS, aHeap uintptr, x Tu32) { + var i, j, v1 Tu32 + var v2 uintptr + _, _, _, _ = i, j, v1, v2 + v2 = aHeap + *(*Tu32)(unsafe.Pointer(v2)) = *(*Tu32)(unsafe.Pointer(v2)) + 1 + v1 = *(*Tu32)(unsafe.Pointer(v2)) + i = v1 + **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) = x + for { + v1 = i / libc.Uint32FromInt32(2) + j = v1 + if !(v1 > uint32(0) && **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) > **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4))) { + break + } + x = **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) + **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) = **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) + **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) = x + i = j + } +} + +func _btreeHeapPull(tls *libc.TLS, aHeap uintptr, pOut uintptr) (r int32) { + var i, j, x, v1 Tu32 + _, _, _, _ = i, j, x, v1 + v1 = **(**Tu32)(__ccgo_up(aHeap)) + x = v1 + if v1 == uint32(0) { + return 0 + } + **(**Tu32)(__ccgo_up(pOut)) = **(**Tu32)(__ccgo_up(aHeap + 1*4)) + **(**Tu32)(__ccgo_up(aHeap + 1*4)) = **(**Tu32)(__ccgo_up(aHeap + uintptr(x)*4)) + **(**Tu32)(__ccgo_up(aHeap + uintptr(x)*4)) = uint32(0xffffffff) + **(**Tu32)(__ccgo_up(aHeap)) = **(**Tu32)(__ccgo_up(aHeap)) - 1 + i = uint32(1) + for { + v1 = i * libc.Uint32FromInt32(2) + j = v1 + if !(v1 <= **(**Tu32)(__ccgo_up(aHeap))) { + break + } + if **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) > **(**Tu32)(__ccgo_up(aHeap + uintptr(j+uint32(1))*4)) { + j = j + 1 + } + if **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) < **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) { + break + } + x = **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) + **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) = **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) + **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) = x + i = j + } + return int32(1) +} + +// C documentation +// +// /* Move the cursor to the last entry in the table. Return SQLITE_OK +// ** on success. Set *pRes to 0 if the cursor actually points to something +// ** or set *pRes to 1 if the table is empty. +// */ +func _btreeLast(tls *libc.TLS, pCur uintptr, pRes uintptr) (r int32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + rc = _moveToRoot(tls, pCur) + if rc == SQLITE_OK { + **(**int32)(__ccgo_up(pRes)) = 0 + rc = _moveToRightmost(tls, pCur) + if rc == SQLITE_OK { + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTCF_AtLast)) + } else { + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTCF_AtLast)) + } + } else { + if rc == int32(SQLITE_EMPTY) { + **(**int32)(__ccgo_up(pRes)) = int32(1) + rc = SQLITE_OK + } + } + return rc +} + +// C documentation +// +// /* This is a helper function for sqlite3BtreeLock(). By moving +// ** complex, but seldom used logic, out of sqlite3BtreeLock() and +// ** into this routine, we avoid unnecessary stack pointer changes +// ** and thus help the sqlite3BtreeLock() routine to run much faster +// ** in the common case. +// */ +func _btreeLockCarefully(tls *libc.TLS, p uintptr) { + var pLater uintptr + _ = pLater + /* In most cases, we should be able to acquire the lock we + ** want without having to go through the ascending lock + ** procedure that follows. Just be sure not to block. + */ + if Xsqlite3_mutex_try(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).Fmutex) == SQLITE_OK { + (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).Fdb = (*TBtree)(unsafe.Pointer(p)).Fdb + (*TBtree)(unsafe.Pointer(p)).Flocked = uint8(1) + return + } + /* To avoid deadlock, first release all locks with a larger + ** BtShared address. Then acquire our lock. Then reacquire + ** the other BtShared locks that we used to hold in ascending + ** order. + */ + pLater = (*TBtree)(unsafe.Pointer(p)).FpNext + for { + if !(pLater != 0) { + break + } + if (*TBtree)(unsafe.Pointer(pLater)).Flocked != 0 { + _unlockBtreeMutex(tls, pLater) + } + goto _1 + _1: + ; + pLater = (*TBtree)(unsafe.Pointer(pLater)).FpNext + } + _lockBtreeMutex(tls, p) + pLater = (*TBtree)(unsafe.Pointer(p)).FpNext + for { + if !(pLater != 0) { + break + } + if (*TBtree)(unsafe.Pointer(pLater)).FwantToLock != 0 { + _lockBtreeMutex(tls, pLater) + } + goto _2 + _2: + ; + pLater = (*TBtree)(unsafe.Pointer(pLater)).FpNext + } +} + +// C documentation +// +// /* +// ** Retrieve a page from the pager cache. If the requested page is not +// ** already in the pager cache return NULL. Initialize the MemPage.pBt and +// ** MemPage.aData elements if needed. +// */ +func _btreePageLookup(tls *libc.TLS, pBt uintptr, pgno TPgno) (r uintptr) { + var pDbPage uintptr + _ = pDbPage + pDbPage = _sqlite3PagerLookup(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pgno) + if pDbPage != 0 { + return _btreePageFromDbPage(tls, pDbPage, pgno, pBt) + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Return the size of the database file in pages. If there is any kind of +// ** error, return ((unsigned int)-1). +// */ +func _btreePagecount(tls *libc.TLS, pBt uintptr) (r TPgno) { + return (*TBtShared)(unsafe.Pointer(pBt)).FnPage +} + +// C documentation +// +// /* +// ** Set bit pgno of the BtShared.pHasContent bitvec. This is called +// ** when a page that previously contained data becomes a free-list leaf +// ** page. +// ** +// ** The BtShared.pHasContent bitvec exists to work around an obscure +// ** bug caused by the interaction of two useful IO optimizations surrounding +// ** free-list leaf pages: +// ** +// ** 1) When all data is deleted from a page and the page becomes +// ** a free-list leaf page, the page is not written to the database +// ** (as free-list leaf pages contain no meaningful data). Sometimes +// ** such a page is not even journalled (as it will not be modified, +// ** why bother journalling it?). +// ** +// ** 2) When a free-list leaf page is reused, its content is not read +// ** from the database or written to the journal file (why should it +// ** be, if it is not at all meaningful?). +// ** +// ** By themselves, these optimizations work fine and provide a handy +// ** performance boost to bulk delete or insert operations. However, if +// ** a page is moved to the free-list and then reused within the same +// ** transaction, a problem comes up. If the page is not journalled when +// ** it is moved to the free-list and it is also not journalled when it +// ** is extracted from the free-list and reused, then the original data +// ** may be lost. In the event of a rollback, it may not be possible +// ** to restore the database to its original configuration. +// ** +// ** The solution is the BtShared.pHasContent bitvec. Whenever a page is +// ** moved to become a free-list leaf page, the corresponding bit is +// ** set in the bitvec. Whenever a leaf page is extracted from the free-list, +// ** optimization 2 above is omitted if the corresponding bit is already +// ** set in BtShared.pHasContent. The contents of the bitvec are cleared +// ** at the end of every transaction. +// */ +func _btreeSetHasContent(tls *libc.TLS, pBt uintptr, pgno TPgno) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if !((*TBtShared)(unsafe.Pointer(pBt)).FpHasContent != 0) { + (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent = _sqlite3BitvecCreate(tls, (*TBtShared)(unsafe.Pointer(pBt)).FnPage) + if !((*TBtShared)(unsafe.Pointer(pBt)).FpHasContent != 0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc == SQLITE_OK && pgno <= _sqlite3BitvecSize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent) { + rc = _sqlite3BitvecSet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent, pgno) + } + return rc +} + +func _cachedCellSize(tls *libc.TLS, p uintptr, N int32) (r Tu16) { + if **(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2)) != 0 { + return **(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2)) + } + return _computeCellSize(tls, p, N) +} + +func _callStatGet(tls *libc.TLS, pParse uintptr, regStat int32, iParam int32, regOut int32) { + _sqlite3VdbeAddOp2(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Integer), iParam, regStat+int32(1)) + _sqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat, regOut, libc.Int32FromInt32(1)+libc.Int32FromInt32(IsStat4), uintptr(unsafe.Pointer(&_statGetFuncdef)), 0) +} + +// C documentation +// +// /* +// ** current_date() +// ** +// ** This function returns the same value as date('now'). +// */ +func _cdateFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + _ = NotUsed + _ = NotUsed2 + _dateFunc(tls, context, 0, uintptr(0)) +} + +// C documentation +// +// /* Extra math functions that require linking with -lm +// */ +// /* +// ** Implementation SQL functions: +// ** +// ** ceil(X) +// ** ceiling(X) +// ** floor(X) +// ** +// ** The sqlite3_user_data() pointer is a pointer to the libm implementation +// ** of the underlying C function. +// */ +func _ceilingFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var x uintptr + _ = x + switch Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_INTEGER): + Xsqlite3_result_int64(tls, context, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))) + case int32(SQLITE_FLOAT): + x = Xsqlite3_user_data(tls, context) + Xsqlite3_result_double(tls, context, (*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(&struct{ uintptr }{x})))(tls, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv))))) + default: + break + } +} + +var _chacha20_init = [4]Tu32{ + 0: uint32(0x61707865), + 1: uint32(0x3320646e), + 2: uint32(0x79622d32), + 3: uint32(0x6b206574), +} + +// C documentation +// +// /* +// ** Implementation of the changes() SQL function. +// ** +// ** IMP: R-32760-32347 The changes() SQL function is a wrapper +// ** around the sqlite3_changes64() C/C++ function and hence follows the +// ** same rules for counting changes. +// */ +func _changes(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + var db uintptr + _ = db + db = Xsqlite3_context_db_handle(tls, context) + _ = NotUsed + _ = NotUsed2 + Xsqlite3_result_int64(tls, context, Xsqlite3_changes64(tls, db)) +} + +// C documentation +// +// /* +// ** Record an OOM error during integrity_check +// */ +func _checkOom(tls *libc.TLS, pCheck uintptr) { + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM) + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = 0 /* Causes integrity_check processing to stop */ + if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr == 0 { + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr + 1 + } +} + +// C documentation +// +// /* +// ** Delete all the content of a Select structure. Deallocate the structure +// ** itself depending on the value of bFree +// ** +// ** If bFree==1, call sqlite3DbFree() on the p object. +// ** If bFree==0, Leave the first Select object unfreed +// */ +func _clearSelect(tls *libc.TLS, db uintptr, p uintptr, bFree int32) { + var pPrior uintptr + _ = pPrior + for p != 0 { + pPrior = (*TSelect)(unsafe.Pointer(p)).FpPrior + _sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpEList) + _sqlite3SrcListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpSrc) + _sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWhere) + _sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpGroupBy) + _sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpHaving) + _sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + _sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpLimit) + if (*TSelect)(unsafe.Pointer(p)).FpWith != 0 { + _sqlite3WithDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWith) + } + if (*TSelect)(unsafe.Pointer(p)).FpWinDefn != 0 { + _sqlite3WindowListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWinDefn) + } + for (*TSelect)(unsafe.Pointer(p)).FpWin != 0 { + _sqlite3WindowUnlinkFromSelect(tls, (*TSelect)(unsafe.Pointer(p)).FpWin) + } + if bFree != 0 { + _sqlite3DbNNFreeNN(tls, db, p) + } + p = pPrior + bFree = int32(1) + } +} + +// C documentation +// +// /* +// ** Add code to implement the OFFSET +// */ +func _codeOffset(tls *libc.TLS, v uintptr, iOffset int32, iContinue int32) { + if iOffset > 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_IfPos), iOffset, iContinue, int32(1)) + } +} + +// C documentation +// +// /* +// ** Generate an instruction that will put the floating point +// ** value described by z[0..n-1] into register iMem. +// ** +// ** The z[] string will probably not be zero-terminated. But the +// ** z[n] character is guaranteed to be something that does not look +// ** like the continuation of the number. +// */ +func _codeReal(tls *libc.TLS, v uintptr, z uintptr, negateFlag int32, iMem int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* value at bp+0 */ float64 + if z != uintptr(0) { + _sqlite3AtoF(tls, z, bp) + /* The new AtoF never returns NaN */ + if negateFlag != 0 { + **(**float64)(__ccgo_up(bp)) = -**(**float64)(__ccgo_up(bp)) + } + _sqlite3VdbeAddOp4Dup8(tls, v, int32(OP_Real), 0, iMem, 0, bp, -int32(13)) + } +} + +// C documentation +// +// /* +// ** Table pTab is a WITHOUT ROWID table that is being written to. The cursor +// ** number is iCur, and register regData contains the new record for the +// ** PK index. This function adds code to invoke the pre-update hook, +// ** if one is registered. +// */ +func _codeWithoutRowidPreupdate(tls *libc.TLS, pParse uintptr, pTab uintptr, iCur int32, regData int32) { + var r int32 + var v uintptr + _, _ = r, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + r = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, r) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Insert), iCur, regData, r, pTab, -int32(5)) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_ISNOOP)) + _sqlite3ReleaseTempReg(tls, pParse, r) +} + +var _colmask = int64(libc.Int32FromInt32(0x7FFFFFFF)) << libc.Int32FromInt32(32) + +// C documentation +// +// /* +// ** This function is called after invoking an sqlite3_value_XXX function on a +// ** column value (i.e. a value returned by evaluating an SQL expression in the +// ** select list of a SELECT statement) that may cause a malloc() failure. If +// ** malloc() has failed, the threads mallocFailed flag is cleared and the result +// ** code of statement pStmt set to SQLITE_NOMEM. +// ** +// ** Specifically, this is called from within: +// ** +// ** sqlite3_column_int() +// ** sqlite3_column_int64() +// ** sqlite3_column_text() +// ** sqlite3_column_text16() +// ** sqlite3_column_double() +// ** sqlite3_column_bytes() +// ** sqlite3_column_bytes16() +// ** sqlite3_column_blob() +// */ +func _columnMallocFailure(tls *libc.TLS, pStmt uintptr) { + var p uintptr + _ = p + /* If malloc() failed during an encoding conversion within an + ** sqlite3_column_XXX API, then set the return code of the statement to + ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR + ** and _finalize() will return NOMEM. + */ + p = pStmt + if p != 0 { + (*TVdbe)(unsafe.Pointer(p)).Frc = _sqlite3ApiExit(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, (*TVdbe)(unsafe.Pointer(p)).Frc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + } +} + +// C documentation +// +// /* +// ** Return a pointer to static memory containing an SQL NULL value. +// */ +func _columnNullValue(tls *libc.TLS) (r uintptr) { + return uintptr(unsafe.Pointer(&_nullMem)) +} + +// C documentation +// +// /* +// ** Implementation of the sqlite_compileoption_get() function. +// ** The result is a string that identifies the compiler options +// ** used to build SQLite. +// */ +func _compileoptiongetFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var n int32 + _ = n + _ = argc + /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function + ** is a wrapper around the sqlite3_compileoption_get() C/C++ function. + */ + n = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv))) + Xsqlite3_result_text(tls, context, Xsqlite3_compileoption_get(tls, n), -int32(1), libc.UintptrFromInt32(0)) +} + +// C documentation +// +// /* +// ** Implementation of the sqlite_compileoption_used() function. +// ** The result is an integer that identifies if the compiler option +// ** was used to build SQLite. +// */ +func _compileoptionusedFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var zOptName, v1 uintptr + _, _ = zOptName, v1 + _ = argc + /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL + ** function is a wrapper around the sqlite3_compileoption_used() C/C++ + ** function. + */ + v1 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zOptName = v1 + if v1 != uintptr(0) { + Xsqlite3_result_int(tls, context, Xsqlite3_compileoption_used(tls, zOptName)) + } +} + +// C documentation +// +// /* +// ** Compute both YMD and HMS +// */ +func _computeYMD_HMS(tls *libc.TLS, p uintptr) { + _computeYMD(tls, p) + _computeHMS(tls, p) +} + +func _countFinalize(tls *libc.TLS, context uintptr) { + var p uintptr + var v1 int64 + _, _ = p, v1 + p = Xsqlite3_aggregate_context(tls, context, 0) + if p != 0 { + v1 = (*TCountCtx)(unsafe.Pointer(p)).Fn + } else { + v1 = 0 + } + Xsqlite3_result_int64(tls, context, v1) +} + +func _countInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, ctx, int32(8)) + /* p is always non-NULL since countStep() will have been called first */ + if (argc == 0 || int32(SQLITE_NULL) != Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv)))) && p != 0 { + (*TCountCtx)(unsafe.Pointer(p)).Fn = (*TCountCtx)(unsafe.Pointer(p)).Fn - 1 + } +} + +// C documentation +// +// /* +// ** Count leading zeros for a 64-bit unsigned integer. +// */ +func _countLeadingZeros(tls *libc.TLS, m Tu64) (r int32) { + var n int32 + _ = n + n = 0 + if m <= uint64(0x00000000ffffffff) { + n = n + int32(32) + m = m << uint64(32) + } + if m <= uint64(0x0000ffffffffffff) { + n = n + int32(16) + m = m << uint64(16) + } + if m <= uint64(0x00ffffffffffffff) { + n = n + int32(8) + m = m << uint64(8) + } + if m <= uint64(0x0fffffffffffffff) { + n = n + int32(4) + m = m << uint64(4) + } + if m <= uint64(0x3fffffffffffffff) { + n = n + int32(2) + m = m << uint64(2) + } + if m <= uint64(0x7fffffffffffffff) { + n = n + int32(1) + } + return n +} + +// C documentation +// +// /* +// ** Return the number of LookasideSlot elements on the linked list +// */ +func _countLookasideSlots(tls *libc.TLS, p uintptr) (r Tu32) { + var cnt Tu32 + _ = cnt + cnt = uint32(0) + for p != 0 { + p = (*TLookasideSlot)(unsafe.Pointer(p)).FpNext + cnt = cnt + 1 + } + return cnt +} + +// C documentation +// +// /* +// ** Routines to implement the count() aggregate function. +// */ +func _countStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, context, int32(8)) + if (argc == 0 || int32(SQLITE_NULL) != Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv)))) && p != 0 { + (*TCountCtx)(unsafe.Pointer(p)).Fn = (*TCountCtx)(unsafe.Pointer(p)).Fn + 1 + } + /* The sqlite3_aggregate_count() function is deprecated. But just to make + ** sure it still operates correctly, verify that its count agrees with our + ** internal count when using count(*) and when the total count can be + ** expressed as a 32-bit integer. */ +} + +// C documentation +// +// /* +// ** Create a new mask for cursor iCursor. +// ** +// ** There is one cursor per table in the FROM clause. The number of +// ** tables in the FROM clause is limited by a test early in the +// ** sqlite3WhereBegin() routine. So we know that the pMaskSet->ix[] +// ** array will never overflow. +// */ +func _createMask(tls *libc.TLS, pMaskSet uintptr, iCursor int32) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + v2 = pMaskSet + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**int32)(__ccgo_up(pMaskSet + 8 + uintptr(v1)*4)) = iCursor +} + +// C documentation +// +// /* +// ** The actual function that does the work of creating a new module. +// ** This function implements the sqlite3_create_module() and +// ** sqlite3_create_module_v2() interfaces. +// */ +func _createModule(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, __ccgo_fp_xDestroy uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3VtabCreateModule(tls, db, zName, pModule, pAux, __ccgo_fp_xDestroy) + rc = _sqlite3ApiExit(tls, db, rc) + if rc != SQLITE_OK && __ccgo_fp_xDestroy != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDestroy})))(tls, pAux) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Clear information from a Cte object, but do not deallocate storage +// ** for the object itself. +// */ +func _cteClear(tls *libc.TLS, db uintptr, pCte uintptr) { + _sqlite3ExprListDelete(tls, db, (*TCte)(unsafe.Pointer(pCte)).FpCols) + _sqlite3SelectDelete(tls, db, (*TCte)(unsafe.Pointer(pCte)).FpSelect) + _sqlite3DbFree(tls, db, (*TCte)(unsafe.Pointer(pCte)).FzName) +} + +// C documentation +// +// /* +// ** current_time() +// ** +// ** This function returns the same value as time('now'). +// */ +func _ctimeFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + _ = NotUsed + _ = NotUsed2 + _timeFunc(tls, context, 0, uintptr(0)) +} + +// C documentation +// +// /* +// ** current_timestamp() +// ** +// ** This function returns the same value as datetime('now'). +// */ +func _ctimestampFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + _ = NotUsed + _ = NotUsed2 + _datetimeFunc(tls, context, 0, uintptr(0)) +} + +func _cume_distInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + _ = nArg + _ = apArg + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + (*TCallCount)(unsafe.Pointer(p)).FnStep = (*TCallCount)(unsafe.Pointer(p)).FnStep + 1 +} + +// C documentation +// +// /* +// ** Implementation of built-in window function cume_dist(). Assumes that +// ** the window frame has been set to: +// ** +// ** GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING +// */ +func _cume_distStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + _ = nArg + _ = apArg + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + if p != 0 { + (*TCallCount)(unsafe.Pointer(p)).FnTotal = (*TCallCount)(unsafe.Pointer(p)).FnTotal + 1 + } +} + +func _cume_distValueFunc(tls *libc.TLS, pCtx uintptr) { + var p uintptr + var r float64 + _, _ = p, r + p = Xsqlite3_aggregate_context(tls, pCtx, 0) + if p != 0 { + r = float64((*TCallCount)(unsafe.Pointer(p)).FnStep) / float64((*TCallCount)(unsafe.Pointer(p)).FnTotal) + Xsqlite3_result_double(tls, pCtx, r) + } +} + +// C documentation +// +// /* Verify that the database file has not be deleted or renamed out from +// ** under the pager. Return SQLITE_OK if the database is still where it ought +// ** to be on disk. Return non-zero (SQLITE_READONLY_DBMOVED or some other error +// ** code from sqlite3OsAccess()) if the database has gone missing. +// */ +func _databaseIsUnmoved(tls *libc.TLS, pPager uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* bHasMoved at bp+0 */ int32 + _ = rc + **(**int32)(__ccgo_up(bp)) = 0 + if (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 { + return SQLITE_OK + } + if (*TPager)(unsafe.Pointer(pPager)).FdbSize == uint32(0) { + return SQLITE_OK + } + rc = _sqlite3OsFileControl(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_HAS_MOVED), bp) + if rc == int32(SQLITE_NOTFOUND) { + /* If the HAS_MOVED file-control is unimplemented, assume that the file + ** has not been moved. That is the historical behavior of SQLite: prior to + ** version 3.8.3, it never checked */ + rc = SQLITE_OK + } else { + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp)) != 0 { + rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(4)< (*TDbpageCursor)(unsafe.Pointer(pCsr)).FmxPgno) +} + +// C documentation +// +// /* +// ** Move a dbpagevfs cursor to the next entry in the file. +// */ +func _dbpageNext(tls *libc.TLS, pCursor uintptr) (r int32) { + var pCsr uintptr + var rc int32 + _, _ = pCsr, rc + rc = SQLITE_OK + pCsr = pCursor + (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno = (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno + 1 + return rc +} + +// C documentation +// +// /* Cancel any pending truncate. +// */ +func _dbpageRollbackTo(tls *libc.TLS, pVtab uintptr, notUsed1 int32) (r int32) { + var pTab uintptr + _ = pTab + pTab = pVtab + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0) + _ = notUsed1 + return SQLITE_OK +} + +var _dbpage_module = Tsqlite3_module{ + FiVersion: int32(2), +} + +var _dbstat_module = Tsqlite3_module{} + +// C documentation +// +// /* +// ** Decode the flags byte (the first byte of the header) for a page +// ** and initialize fields of the MemPage structure accordingly. +// ** +// ** Only the following combinations are supported. Anything different +// ** indicates a corrupt database files: +// ** +// ** PTF_ZERODATA (0x02, 2) +// ** PTF_LEAFDATA | PTF_INTKEY (0x05, 5) +// ** PTF_ZERODATA | PTF_LEAF (0x0a, 10) +// ** PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF (0x0d, 13) +// */ +func _decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) (r int32) { + var pBt uintptr + _ = pBt /* A copy of pPage->pBt */ + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt + (*TMemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload = (*TBtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload + if flagByte >= libc.Int32FromInt32(PTF_ZERODATA)|libc.Int32FromInt32(PTF_LEAF) { + (*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).Fleaf = uint8(1) + if flagByte == libc.Int32FromInt32(PTF_LEAFDATA)|libc.Int32FromInt32(PTF_INTKEY)|libc.Int32FromInt32(PTF_LEAF) { + (*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(1) + (*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtrTableLeaf) + (*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtr) + (*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(1) + (*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*TBtShared)(unsafe.Pointer(pBt)).FmaxLeaf + (*TMemPage)(unsafe.Pointer(pPage)).FminLocal = (*TBtShared)(unsafe.Pointer(pBt)).FminLeaf + } else { + if flagByte == libc.Int32FromInt32(PTF_ZERODATA)|libc.Int32FromInt32(PTF_LEAF) { + (*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtrIdxLeaf) + (*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrIndex) + (*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal + (*TMemPage)(unsafe.Pointer(pPage)).FminLocal = (*TBtShared)(unsafe.Pointer(pBt)).FminLocal + } else { + (*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtrIdxLeaf) + (*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrIndex) + return _sqlite3CorruptError(tls, int32(75198)) + } + } + } else { + (*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize = uint8(4) + (*TMemPage)(unsafe.Pointer(pPage)).Fleaf = uint8(0) + if flagByte == int32(PTF_ZERODATA) { + (*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtr) + (*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrIndex) + (*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal + (*TMemPage)(unsafe.Pointer(pPage)).FminLocal = (*TBtShared)(unsafe.Pointer(pBt)).FminLocal + } else { + if flagByte == libc.Int32FromInt32(PTF_LEAFDATA)|libc.Int32FromInt32(PTF_INTKEY) { + (*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtrNoPayload) + (*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrNoPayload) + (*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(1) + (*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*TBtShared)(unsafe.Pointer(pBt)).FmaxLeaf + (*TMemPage)(unsafe.Pointer(pPage)).FminLocal = (*TBtShared)(unsafe.Pointer(pBt)).FminLeaf + } else { + (*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtr) + (*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrIndex) + return _sqlite3CorruptError(tls, int32(75222)) + } + } + } + return SQLITE_OK +} + +var _defaultMethods = Tsqlite3_mem_methods{} + +var _defaultMethods1 = Tsqlite3_pcache_methods2{ + FiVersion: int32(1), +} + +/* This case is for systems that have support for sleeping for fractions of + ** a second. Examples: All windows systems, unix systems with nanosleep() */ +var _delays = [12]Tu8{ + 0: uint8(1), + 1: uint8(2), + 2: uint8(5), + 3: uint8(10), + 4: uint8(15), + 5: uint8(20), + 6: uint8(25), + 7: uint8(25), + 8: uint8(25), + 9: uint8(50), + 10: uint8(50), + 11: uint8(100), +} + +// C documentation +// +// /* +// ** Implementation of built-in window function dense_rank(). Assumes that +// ** the window frame has been set to: +// ** +// ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW +// */ +func _dense_rankStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + if p != 0 { + (*TCallCount)(unsafe.Pointer(p)).FnStep = int64(1) + } + _ = nArg + _ = apArg +} + +func _dense_rankValueFunc(tls *libc.TLS, pCtx uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + if p != 0 { + if (*TCallCount)(unsafe.Pointer(p)).FnStep != 0 { + (*TCallCount)(unsafe.Pointer(p)).FnValue = (*TCallCount)(unsafe.Pointer(p)).FnValue + 1 + (*TCallCount)(unsafe.Pointer(p)).FnStep = 0 + } + Xsqlite3_result_int64(tls, pCtx, (*TCallCount)(unsafe.Pointer(p)).FnValue) + } +} + +/* C89 specifies that the constant "dummy" will be initialized to all + ** zeros, which is correct. MSVC generates a warning, nevertheless. */ +var _dummy TVdbeOp + +// C documentation +// +// /* +// ** Return the number of bytes required to create a duplicate of the +// ** expression passed as the first argument. +// ** +// ** The value returned includes space to create a copy of the Expr struct +// ** itself and the buffer referred to by Expr.u.zToken, if any. +// ** +// ** The return value includes space to duplicate all Expr nodes in the +// ** tree formed by Expr.pLeft and Expr.pRight, but not any other +// ** substructure such as Expr.x.pList, Expr.x.pSelect, and Expr.y.pWin. +// */ +func _dupedExprSize(tls *libc.TLS, p uintptr) (r int32) { + var nByte int32 + _ = nByte + nByte = _dupedExprNodeSize(tls, p, int32(EXPRDUP_REDUCE)) + if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 { + nByte = nByte + _dupedExprSize(tls, (*TExpr)(unsafe.Pointer(p)).FpLeft) + } + if (*TExpr)(unsafe.Pointer(p)).FpRight != 0 { + nByte = nByte + _dupedExprSize(tls, (*TExpr)(unsafe.Pointer(p)).FpRight) + } + return nByte +} + +var _emptyArray = uint8(0x0b) + +var _emptyObject = [2]Tu8{ + 0: uint8(JSONB_ARRAY), + 1: uint8(JSONB_OBJECT), +} + +var _emptyObject1 = uint8(0x0c) + +var _endCode = [7]TVdbeOpList{ + 0: { + Fopcode: uint8(OP_AddImm), + Fp1: int8(1), + }, + 1: { + Fopcode: uint8(OP_IfNotZero), + Fp1: int8(1), + Fp2: int8(4), + }, + 2: { + Fopcode: uint8(OP_String8), + Fp2: int8(3), + }, + 3: { + Fopcode: uint8(OP_ResultRow), + Fp1: int8(3), + Fp2: int8(1), + }, + 4: { + Fopcode: uint8(OP_Halt), + }, + 5: { + Fopcode: uint8(OP_String8), + Fp2: int8(3), + }, + 6: { + Fopcode: uint8(OP_Goto), + Fp2: int8(3), + }, +} + +// C documentation +// +// /* +// ** Obtain the STATIC_MAIN mutex. +// */ +func _enterMutex(tls *libc.TLS) { + Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN))) +} + +// C documentation +// +// /* +// ** Set the error message of the context passed as the first argument to +// ** the result of formatting zFmt using printf() style formatting. +// */ +func _errorMPrintf(tls *libc.TLS, pCtx uintptr, zFmt uintptr, va uintptr) { + var ap Tva_list + var db, zErr uintptr + _, _, _ = ap, db, zErr + db = Xsqlite3_context_db_handle(tls, pCtx) + zErr = uintptr(0) + ap = va + zErr = _sqlite3VMPrintf(tls, db, zFmt, ap) + _ = ap + if zErr != 0 { + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + _sqlite3DbFree(tls, db, zErr) + } else { + Xsqlite3_result_error_nomem(tls, pCtx) + } +} + +func _execSqlF(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr, va uintptr) (r int32) { + var ap Tva_list + var rc int32 + var z uintptr + _, _, _ = ap, rc, z + ap = va + z = _sqlite3VMPrintf(tls, db, zSql, ap) + _ = ap + if z == uintptr(0) { + return int32(SQLITE_NOMEM) + } + rc = _execSql(tls, db, pzErrMsg, z) + _sqlite3DbFree(tls, db, z) + return rc +} + +// C documentation +// +// /* +// ** Allocate and return a pointer to an expression of type TK_ROW with +// ** Expr.iColumn set to value (iCol+1). The resolver will modify the +// ** expression to be a TK_COLUMN reading column iCol of the first +// ** table in the source-list (pSrc->a[0]). +// */ +func _exprRowColumn(tls *libc.TLS, pParse uintptr, iCol int32) (r uintptr) { + var pRet uintptr + _ = pRet + pRet = _sqlite3PExpr(tls, pParse, int32(TK_ROW), uintptr(0), uintptr(0)) + if pRet != 0 { + (*TExpr)(unsafe.Pointer(pRet)).FiColumn = int16(iCol + int32(1)) + } + return pRet +} + +// C documentation +// +// /* +// ** This routine examines sub-SELECT statements as an expression is being +// ** walked as part of sqlite3ExprIsTableConstant(). Sub-SELECTs are considered +// ** constant as long as they are uncorrelated - meaning that they do not +// ** contain any terms from outer contexts. +// */ +func _exprSelectWalkTableConstant(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) { + if (*TSelect)(unsafe.Pointer(pSelect)).FselFlags&uint32(SF_Correlated) != uint32(0) { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) + } + return int32(WRC_Prune) +} + +var _fakeCursor Tu8 + +// C documentation +// +// /* +// ** Look up an index by name. Or, if the name of a WITHOUT ROWID table +// ** is supplied instead, find the PRIMARY KEY index for that table. +// */ +func _findIndexOrPrimaryKey(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr) (r uintptr) { + var pIdx, pTab uintptr + _, _ = pIdx, pTab + pIdx = _sqlite3FindIndex(tls, db, zName, zDb) + if pIdx == uintptr(0) { + pTab = _sqlite3FindTable(tls, db, zName, zDb) + if pTab != 0 && !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pIdx = _sqlite3PrimaryKeyIndex(tls, pTab) + } + } + return pIdx +} + +// C documentation +// +// /* +// ** Use nodeAcquire() to obtain the leaf node containing the record with +// ** rowid iRowid. If successful, set *ppLeaf to point to the node and +// ** return SQLITE_OK. If there is no such record in the table, set +// ** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf +// ** to zero and return an SQLite error code. +// */ +func _findLeafNode(tls *libc.TLS, pRtree uintptr, iRowid Ti64, ppLeaf uintptr, piNode uintptr) (r int32) { + var iNode Ti64 + var rc int32 + _, _ = iNode, rc + **(**uintptr)(__ccgo_up(ppLeaf)) = uintptr(0) + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid, int32(1), iRowid) + if Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) == int32(SQLITE_ROW) { + iNode = Xsqlite3_column_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid, 0) + if piNode != 0 { + **(**Tsqlite3_int64)(__ccgo_up(piNode)) = iNode + } + rc = _nodeAcquire(tls, pRtree, iNode, uintptr(0), ppLeaf) + Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + } else { + rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + } + return rc +} + +// C documentation +// +// /* +// ** If pSel is not part of a compound SELECT, return a pointer to its +// ** expression list. Otherwise, return a pointer to the expression list +// ** of the leftmost SELECT in the compound. +// */ +func _findLeftmostExprlist(tls *libc.TLS, pSel uintptr) (r uintptr) { + for (*TSelect)(unsafe.Pointer(pSel)).FpPrior != 0 { + pSel = (*TSelect)(unsafe.Pointer(pSel)).FpPrior + } + return (*TSelect)(unsafe.Pointer(pSel)).FpEList +} + +// C documentation +// +// /* +// ** Return a pointer to the right-most SELECT statement in a compound. +// */ +func _findRightmost(tls *libc.TLS, p uintptr) (r uintptr) { + for (*TSelect)(unsafe.Pointer(p)).FpNext != 0 { + p = (*TSelect)(unsafe.Pointer(p)).FpNext + } + return p +} + +// C documentation +// +// /* +// ** If node pLeaf is not the root of the r-tree and its pParent pointer is +// ** still NULL, load all ancestor nodes of pLeaf into memory and populate +// ** the pLeaf->pParent chain all the way up to the root node. +// ** +// ** This operation is required when a row is deleted (or updated - an update +// ** is implemented as a delete followed by an insert). SQLite provides the +// ** rowid of the row to delete, which can be used to find the leaf on which +// ** the entry resides (argument pLeaf). Once the leaf is located, this +// ** function is called to determine its ancestry. +// */ +func _fixLeafParent(tls *libc.TLS, pRtree uintptr, pLeaf uintptr) (r int32) { + var iNode Ti64 + var pChild, pTest uintptr + var rc, rc2 int32 + _, _, _, _, _ = iNode, pChild, pTest, rc, rc2 + rc = SQLITE_OK + pChild = pLeaf + for rc == SQLITE_OK && (*TRtreeNode)(unsafe.Pointer(pChild)).FiNode != int64(1) && (*TRtreeNode)(unsafe.Pointer(pChild)).FpParent == uintptr(0) { + rc2 = SQLITE_OK /* sqlite3_reset() return code */ + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent, int32(1), (*TRtreeNode)(unsafe.Pointer(pChild)).FiNode) + rc = Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent) + if rc == int32(SQLITE_ROW) { /* Node number of parent node */ + /* Before setting pChild->pParent, test that we are not creating a + ** loop of references (as we would if, say, pChild==pParent). We don't + ** want to do this as it leads to a memory leak when trying to delete + ** the referenced counted node structures. + */ + iNode = Xsqlite3_column_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent, 0) + pTest = pLeaf + for { + if !(pTest != 0 && (*TRtreeNode)(unsafe.Pointer(pTest)).FiNode != iNode) { + break + } + goto _1 + _1: + ; + pTest = (*TRtreeNode)(unsafe.Pointer(pTest)).FpParent + } + if pTest == uintptr(0) { + rc2 = _nodeAcquire(tls, pRtree, iNode, uintptr(0), pChild) + } + } + rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent) + if rc == SQLITE_OK { + rc = rc2 + } + if rc == SQLITE_OK && !((*TRtreeNode)(unsafe.Pointer(pChild)).FpParent != 0) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab)).FpConfig)).FnCol { + rc = int32(SQLITE_RANGE) + } else { + if _fts5IsContentless(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, 0) != 0 { + **(**uintptr)(__ccgo_up(pz)) = uintptr(0) + **(**int32)(__ccgo_up(pn)) = 0 + } else { + rc = _fts5SeekCursor(tls, pCsr, 0) + if rc == SQLITE_OK { + rc = _fts5TextFromStmt(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, iCol, pz, pn) + _sqlite3Fts5ClearLocale(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig) + } + } + } + return rc +} + +func _fts5ApiColumnTotalSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) (r int32) { + var pCsr, pTab uintptr + _, _ = pCsr, pTab + pCsr = pCtx + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + return _sqlite3Fts5StorageSize(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iCol, pnToken) +} + +func _fts5ApiGetAuxdata(tls *libc.TLS, pCtx uintptr, bClear int32) (r uintptr) { + var pCsr, pData, pRet uintptr + _, _, _ = pCsr, pData, pRet + pCsr = pCtx + pRet = uintptr(0) + pData = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata + for { + if !(pData != 0) { + break + } + if (*TFts5Auxdata)(unsafe.Pointer(pData)).FpAux == (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAux { + break + } + goto _1 + _1: + ; + pData = (*TFts5Auxdata)(unsafe.Pointer(pData)).FpNext + } + if pData != 0 { + pRet = (*TFts5Auxdata)(unsafe.Pointer(pData)).FpPtr + if bClear != 0 { + (*TFts5Auxdata)(unsafe.Pointer(pData)).FpPtr = uintptr(0) + (*TFts5Auxdata)(unsafe.Pointer(pData)).FxDelete = uintptr(0) + } + } + return pRet +} + +func _fts5ApiInst(tls *libc.TLS, pCtx uintptr, iIdx int32, piPhrase uintptr, piCol uintptr, piOff uintptr) (r int32) { + var pCsr uintptr + var rc, v1 int32 + var v2 bool + _, _, _, _ = pCsr, rc, v1, v2 + pCsr = pCtx + rc = SQLITE_OK + if v2 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_INST) == 0; !v2 { + v1 = _fts5CacheInstArray(tls, pCsr) + rc = v1 + } + if v2 || SQLITE_OK == v1 { + if iIdx < 0 || iIdx >= (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount { + rc = int32(SQLITE_RANGE) + } else { + **(**int32)(__ccgo_up(piPhrase)) = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3))*4)) + **(**int32)(__ccgo_up(piCol)) = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3)+int32(1))*4)) + **(**int32)(__ccgo_up(piOff)) = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3)+int32(2))*4)) + } + } + return rc +} + +func _fts5ApiInstCount(tls *libc.TLS, pCtx uintptr, pnInst uintptr) (r int32) { + var pCsr uintptr + var rc, v1 int32 + var v2 bool + _, _, _, _ = pCsr, rc, v1, v2 + pCsr = pCtx + rc = SQLITE_OK + if v2 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_INST) == 0; !v2 { + v1 = _fts5CacheInstArray(tls, pCsr) + rc = v1 + } + if v2 || SQLITE_OK == v1 { + **(**int32)(__ccgo_up(pnInst)) = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount + } + return rc +} + +// C documentation +// +// /* +// ** xInstToken() API implemenetation. +// */ +func _fts5ApiInstToken(tls *libc.TLS, pCtx uintptr, iIdx int32, iToken int32, ppOut uintptr, pnOut uintptr) (r int32) { + var iCol, iOff, iPhrase, rc, v1 int32 + var iRowid Ti64 + var pCsr uintptr + var v2 bool + _, _, _, _, _, _, _, _ = iCol, iOff, iPhrase, iRowid, pCsr, rc, v1, v2 + pCsr = pCtx + rc = SQLITE_OK + if v2 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_INST) == 0; !v2 { + v1 = _fts5CacheInstArray(tls, pCsr) + rc = v1 + } + if v2 || SQLITE_OK == v1 { + if iIdx < 0 || iIdx >= (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount { + rc = int32(SQLITE_RANGE) + } else { + iPhrase = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3))*4)) + iCol = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3)+int32(1))*4)) + iOff = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3)+int32(2))*4)) + iRowid = _fts5CursorRowid(tls, pCsr) + rc = _sqlite3Fts5ExprInstToken(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iRowid, iPhrase, iCol, iOff, iToken, ppOut, pnOut) + } + } + return rc +} + +func _fts5ApiInvoke(tls *libc.TLS, pAux uintptr, pCsr uintptr, context uintptr, argc int32, argv uintptr) { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAux = pAux + (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxFunc})))(tls, uintptr(unsafe.Pointer(&_sFts5Api)), pCsr, context, argc, argv) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAux = uintptr(0) +} + +func _fts5ApiPhraseCount(tls *libc.TLS, pCtx uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCtx + return _sqlite3Fts5ExprPhraseCount(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) +} + +func _fts5ApiPhraseFirst(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter uintptr, piCol uintptr, piOff uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pCsr, v1 uintptr + var rc int32 + var _ /* n at bp+0 */ int32 + _, _, _ = pCsr, rc, v1 + pCsr = pCtx + rc = _fts5CsrPoslist(tls, pCsr, iPhrase, pIter, bp) + if rc == SQLITE_OK { + if (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa != 0 { + v1 = (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(**(**int32)(__ccgo_up(bp))) + } else { + v1 = uintptr(0) + } + (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fb = v1 + **(**int32)(__ccgo_up(piCol)) = 0 + **(**int32)(__ccgo_up(piOff)) = 0 + _fts5ApiPhraseNext(tls, pCtx, pIter, piCol, piOff) + } + return rc +} + +func _fts5ApiPhraseNext(tls *libc.TLS, pCtx uintptr, pIter uintptr, piCol uintptr, piOff uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nCol, v1 int32 + var _ /* iVal at bp+0 */ int32 + _, _ = nCol, v1 + if (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fb { + **(**int32)(__ccgo_up(piCol)) = -int32(1) + **(**int32)(__ccgo_up(piOff)) = -int32(1) + } else { + **(**uintptr)(__ccgo_up(pIter)) += uintptr(_sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp)) + if **(**int32)(__ccgo_up(bp)) == int32(1) { + /* Avoid returning a (*piCol) value that is too large for the table, + ** even if the position-list is corrupt. The caller might not be + ** expecting it. */ + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCtx)).Fbase.FpVtab)).FpConfig)).FnCol + **(**uintptr)(__ccgo_up(pIter)) += uintptr(_sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp)) + if **(**int32)(__ccgo_up(bp)) >= nCol { + v1 = nCol - int32(1) + } else { + v1 = **(**int32)(__ccgo_up(bp)) + } + **(**int32)(__ccgo_up(piCol)) = v1 + **(**int32)(__ccgo_up(piOff)) = 0 + **(**uintptr)(__ccgo_up(pIter)) += uintptr(_sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp)) + } + **(**int32)(__ccgo_up(piOff)) += **(**int32)(__ccgo_up(bp)) - int32(2) + } +} + +func _fts5ApiPhraseSize(tls *libc.TLS, pCtx uintptr, iPhrase int32) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCtx + return _sqlite3Fts5ExprPhraseSize(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase) +} + +// C documentation +// +// /* +// ** xQueryToken() API implemenetation. +// */ +func _fts5ApiQueryToken(tls *libc.TLS, pCtx uintptr, iPhrase int32, iToken int32, ppOut uintptr, pnOut uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCtx + return _sqlite3Fts5ExprQueryToken(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, iToken, ppOut, pnOut) +} + +func _fts5ApiRowCount(tls *libc.TLS, pCtx uintptr, pnRow uintptr) (r int32) { + var pCsr, pTab uintptr + _, _ = pCsr, pTab + pCsr = pCtx + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + return _sqlite3Fts5StorageRowCount(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, pnRow) +} + +func _fts5ApiRowid(tls *libc.TLS, pCtx uintptr) (r Tsqlite3_int64) { + return _fts5CursorRowid(tls, pCtx) +} + +// C documentation +// +// /* +// ** Implementation of xTokenize() API. This is just xTokenize_v2() with NULL/0 +// ** passed as the locale. +// */ +func _fts5ApiTokenize(tls *libc.TLS, pCtx uintptr, pText uintptr, nText int32, pUserData uintptr, __ccgo_fp_xToken uintptr) (r int32) { + return _fts5ApiTokenize_v2(tls, pCtx, pText, nText, uintptr(0), 0, pUserData, __ccgo_fp_xToken) +} + +// C documentation +// +// /* +// ** Implementation of xTokenize_v2() API. +// */ +func _fts5ApiTokenize_v2(tls *libc.TLS, pCtx uintptr, pText uintptr, nText int32, pLoc uintptr, nLoc int32, pUserData uintptr, __ccgo_fp_xToken uintptr) (r int32) { + var pCsr, pTab uintptr + var rc int32 + _, _, _ = pCsr, pTab, rc + pCsr = pCtx + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + rc = SQLITE_OK + _sqlite3Fts5SetLocale(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig, pLoc, nLoc) + rc = _sqlite3Fts5Tokenize(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig, int32(FTS5_TOKENIZE_AUX), pText, nText, pUserData, __ccgo_fp_xToken) + _sqlite3Fts5SetLocale(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig, uintptr(0), 0) + return rc +} + +func _fts5ApiUserData(tls *libc.TLS, pCtx uintptr) (r uintptr) { + var pCsr uintptr + _ = pCsr + pCsr = pCtx + return (*TFts5Auxiliary)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAux)).FpUserData +} + +// C documentation +// +// /* +// ** Delete a "ascii" tokenizer. +// */ +func _fts5AsciiDelete(tls *libc.TLS, p uintptr) { + Xsqlite3_free(tls, p) +} + +// C documentation +// +// /* +// ** Implementation of xBegin() method. +// */ +func _fts5BeginMethod(tls *libc.TLS, pVtab uintptr) (r int32) { + var rc int32 + _ = rc + rc = _fts5NewTransaction(tls, pVtab) + if rc == SQLITE_OK { + } + return rc +} + +// C documentation +// +// /* +// ** Swap the contents of buffer *p1 with that of *p2. +// */ +func _fts5BufferSwap(tls *libc.TLS, p1 uintptr, p2 uintptr) { + var tmp TFts5Buffer + _ = tmp + tmp = **(**TFts5Buffer)(__ccgo_up(p1)) + **(**TFts5Buffer)(__ccgo_up(p1)) = **(**TFts5Buffer)(__ccgo_up(p2)) + **(**TFts5Buffer)(__ccgo_up(p2)) = tmp +} + +// C documentation +// +// /* +// ** Advance the iterator to the next coalesced phrase instance. Return +// ** an SQLite error code if an error occurs, or SQLITE_OK otherwise. +// */ +func _fts5CInstIterNext(tls *libc.TLS, pIter uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iEnd, rc int32 + var _ /* ic at bp+4 */ int32 + var _ /* io at bp+8 */ int32 + var _ /* ip at bp+0 */ int32 + _, _ = iEnd, rc + rc = SQLITE_OK + (*TCInstIter)(unsafe.Pointer(pIter)).FiStart = -int32(1) + (*TCInstIter)(unsafe.Pointer(pIter)).FiEnd = -int32(1) + for rc == SQLITE_OK && (*TCInstIter)(unsafe.Pointer(pIter)).FiInst < (*TCInstIter)(unsafe.Pointer(pIter)).FnInst { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer((*TCInstIter)(unsafe.Pointer(pIter)).FpApi)).FxInst})))(tls, (*TCInstIter)(unsafe.Pointer(pIter)).FpFts, (*TCInstIter)(unsafe.Pointer(pIter)).FiInst, bp, bp+4, bp+8) + if rc == SQLITE_OK { + if **(**int32)(__ccgo_up(bp + 4)) == (*TCInstIter)(unsafe.Pointer(pIter)).FiCol { + iEnd = **(**int32)(__ccgo_up(bp + 8)) - int32(1) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer((*TCInstIter)(unsafe.Pointer(pIter)).FpApi)).FxPhraseSize})))(tls, (*TCInstIter)(unsafe.Pointer(pIter)).FpFts, **(**int32)(__ccgo_up(bp))) + if (*TCInstIter)(unsafe.Pointer(pIter)).FiStart < 0 { + (*TCInstIter)(unsafe.Pointer(pIter)).FiStart = **(**int32)(__ccgo_up(bp + 8)) + (*TCInstIter)(unsafe.Pointer(pIter)).FiEnd = iEnd + } else { + if **(**int32)(__ccgo_up(bp + 8)) <= (*TCInstIter)(unsafe.Pointer(pIter)).FiEnd { + if iEnd > (*TCInstIter)(unsafe.Pointer(pIter)).FiEnd { + (*TCInstIter)(unsafe.Pointer(pIter)).FiEnd = iEnd + } + } else { + break + } + } + } + (*TCInstIter)(unsafe.Pointer(pIter)).FiInst = (*TCInstIter)(unsafe.Pointer(pIter)).FiInst + 1 + } + } + return rc +} + +func _fts5ChunkIterate(tls *libc.TLS, p uintptr, pSeg uintptr, pCtx uintptr, __ccgo_fp_xChunk uintptr) { + var nChunk, nRem, pgno, pgnoSave, v2 int32 + var pChunk, pData uintptr + var v1 int64 + _, _, _, _, _, _, _, _ = nChunk, nRem, pChunk, pData, pgno, pgnoSave, v1, v2 + nRem = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos /* Number of bytes still to come */ + pData = uintptr(0) + pChunk = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset) + if int64(nRem) < int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf)-(*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset { + v1 = int64(nRem) + } else { + v1 = int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf) - (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset + } + nChunk = int32(v1) + pgno = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno + pgnoSave = 0 + /* This function does not work with detail=none databases. */ + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).Fflags&int32(FTS5_SEGITER_REVERSE) == 0 { + pgnoSave = pgno + int32(1) + } + for int32(1) != 0 { + (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xChunk})))(tls, p, pCtx, pChunk, nChunk) + nRem = nRem - nChunk + _fts5DataRelease(tls, pData) + if nRem <= 0 { + break + } else { + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg == uintptr(0) { + _fts5IndexCorruptIdx(tls, p) + return + } else { + pgno = pgno + 1 + pData = _fts5LeafRead(tls, p, int64((*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))< int32(2) { + rc = int32(SQLITE_ERROR) + } else { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _fts5NewTokenizerModule(tls, pGlobal, zName, pUserData, __ccgo_fp_xDestroy, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + (*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx2 = **(**Tfts5_tokenizer_v2)(__ccgo_up(pTokenizer)) + (*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FbV2Native = int32(1) + (*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx1.FxCreate = __ccgo_fp(_fts5VtoVCreate) + (*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx1.FxTokenize = __ccgo_fp(_fts5V1toV2Tokenize) + (*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx1.FxDelete = __ccgo_fp(_fts5VtoVDelete) + } + } + return rc +} + +func _fts5CursorFromCsrid(tls *libc.TLS, pGlobal uintptr, iCsrId Ti64) (r uintptr) { + var pCsr uintptr + _ = pCsr + pCsr = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpCsr + for { + if !(pCsr != 0) { + break + } + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId == iCsrId { + break + } + goto _1 + _1: + ; + pCsr = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpNext + } + return pCsr +} + +// C documentation +// +// /* +// ** Return the rowid that the cursor currently points to. +// */ +func _fts5CursorRowid(tls *libc.TLS, pCsr uintptr) (r Ti64) { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 { + return (*TFts5Sorter)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter)).FiRowid + } else { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan >= int32(FTS5_PLAN_SCAN) { + return Xsqlite3_column_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 0) + } else { + return _sqlite3Fts5ExprRowid(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + } + } + return r +} + +// C documentation +// +// /* +// ** Release a reference to data record returned by an earlier call to +// ** fts5DataRead(). +// */ +func _fts5DataRelease(tls *libc.TLS, pData uintptr) { + Xsqlite3_free(tls, pData) +} + +// C documentation +// +// /* +// ** The xDestroy() virtual table method. +// */ +func _fts5DestroyMethod(tls *libc.TLS, pVtab uintptr) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = pVtab + rc = _sqlite3Fts5DropAll(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig) + if rc == SQLITE_OK { + _fts5FreeVtab(tls, pVtab) + } + return rc +} + +// C documentation +// +// /* +// ** The xDisconnect() virtual table method. +// */ +func _fts5DisconnectMethod(tls *libc.TLS, pVtab uintptr) (r int32) { + _fts5FreeVtab(tls, pVtab) + return SQLITE_OK +} + +func _fts5DlidxIterEof(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + return libc.BoolInt32((*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK || (*(*TFts5DlidxLvl)(unsafe.Pointer(pIter + 8))).FbEof != 0) +} + +func _fts5DlidxIterNext(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + return _fts5DlidxIterNextR(tls, p, pIter, 0) +} + +func _fts5DlidxIterPgno(tls *libc.TLS, pIter uintptr) (r int32) { + return (*(*TFts5DlidxLvl)(unsafe.Pointer(pIter + 8))).FiLeafPgno +} + +func _fts5DlidxIterPrev(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + return _fts5DlidxIterPrevR(tls, p, pIter, 0) +} + +func _fts5DlidxIterRowid(tls *libc.TLS, pIter uintptr) (r Ti64) { + return (*(*TFts5DlidxLvl)(unsafe.Pointer(pIter + 8))).FiRowid +} + +// C documentation +// +// /* +// ** This is the xEof method of the virtual table. SQLite calls this +// ** routine to find out if it has reached the end of a result set. +// */ +func _fts5EofMethod(tls *libc.TLS, pCursor uintptr) (r int32) { + var pCsr uintptr + var v1 int32 + _, _ = pCsr, v1 + pCsr = pCursor + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_EOF) != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + return v1 +} + +func _fts5ExecPrintf(tls *libc.TLS, db uintptr, pzErr uintptr, zFormat uintptr, va uintptr) (r int32) { + var ap Tva_list + var rc int32 + var zSql uintptr + _, _, _ = ap, rc, zSql + ap = va + zSql = Xsqlite3_vmprintf(tls, zFormat, ap) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), pzErr) + Xsqlite3_free(tls, zSql) + } + _ = ap + return rc +} + +// C documentation +// +// /* +// ** Advance iterator pIter until it points to a value equal to or laster +// ** than the initial value of *piLast. If this means the iterator points +// ** to a value laster than *piLast, update *piLast to the new lastest value. +// ** +// ** If the iterator reaches EOF, set *pbEof to true before returning. If +// ** an error occurs, set *pRc to an error code. If either *pbEof or *pRc +// ** are set, return a non-zero value. Otherwise, return zero. +// */ +func _fts5ExprAdvanceto(tls *libc.TLS, pIter uintptr, bDesc int32, piLast uintptr, pRc uintptr, pbEof uintptr) (r int32) { + var iLast, iRowid Ti64 + var rc int32 + _, _, _ = iLast, iRowid, rc + iLast = **(**Ti64)(__ccgo_up(piLast)) + iRowid = (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid + if bDesc == 0 && iLast > iRowid || bDesc != 0 && iLast < iRowid { + rc = _sqlite3Fts5IterNextFrom(tls, pIter, iLast) + if rc != 0 || (*TFts5IndexIter)(unsafe.Pointer(pIter)).FbEof != 0 { + **(**int32)(__ccgo_up(pRc)) = rc + **(**int32)(__ccgo_up(pbEof)) = int32(1) + return int32(1) + } + iRowid = (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid + } + **(**Ti64)(__ccgo_up(piLast)) = iRowid + return 0 +} + +// C documentation +// +// /* +// ** TODO: Make this more efficient! +// */ +func _fts5ExprColsetTest(tls *libc.TLS, pColset uintptr, iCol int32) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol) { + break + } + if *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) == iCol { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** If pNode currently points to a match, this function returns SQLITE_OK +// ** without modifying it. Otherwise, pNode is advanced until it does point +// ** to a match or EOF is reached. +// */ +func _fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 { + switch (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType { + case int32(FTS5_STRING): + rc = _fts5ExprNodeTest_STRING(tls, pExpr, pNode) + case int32(FTS5_TERM): + rc = _fts5ExprNodeTest_TERM(tls, pExpr, pNode) + case int32(FTS5_AND): + rc = _fts5ExprNodeTest_AND(tls, pExpr, pNode) + case int32(FTS5_OR): + _fts5ExprNodeTest_OR(tls, pExpr, pNode) + default: + rc = _fts5ExprNodeTest_NOT(tls, pExpr, pNode) + break + } + } + return rc +} + +// C documentation +// +// /* +// ** Search for an auxiliary function named zName that can be used with table +// ** pTab. If one is found, return a pointer to the corresponding Fts5Auxiliary +// ** structure. Otherwise, if no such function exists, return NULL. +// */ +func _fts5FindAuxiliary(tls *libc.TLS, pTab uintptr, zName uintptr) (r uintptr) { + var pAux uintptr + _ = pAux + pAux = (*TFts5Global)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpAux + for { + if !(pAux != 0) { + break + } + if Xsqlite3_stricmp(tls, zName, (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc) == 0 { + return pAux + } + goto _1 + _1: + ; + pAux = (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpNext + } + /* No function of the specified name was found. Return 0. */ + return uintptr(0) +} + +// C documentation +// +// /* +// ** This routine implements the xFindFunction method for the FTS3 +// ** virtual table. +// */ +func _fts5FindFunctionMethod(tls *libc.TLS, pVtab uintptr, nUnused int32, zName uintptr, __ccgo_fp_pxFunc uintptr, ppArg uintptr) (r int32) { + var pAux, pTab uintptr + _, _ = pAux, pTab + pTab = pVtab + _ = nUnused + pAux = _fts5FindAuxiliary(tls, pTab, zName) + if pAux != 0 { + **(**uintptr)(__ccgo_up(__ccgo_fp_pxFunc)) = __ccgo_fp(_fts5ApiCallback) + **(**uintptr)(__ccgo_up(ppArg)) = pAux + return int32(1) + } + /* No function of the specified name was found. Return 0. */ + return 0 +} + +// C documentation +// +// /* +// ** Delete a virtual table handle allocated by fts5InitVtab(). +// */ +func _fts5FreeVtab(tls *libc.TLS, pTab uintptr) { + if pTab != 0 { + _sqlite3Fts5IndexClose(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) + _sqlite3Fts5StorageClose(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage) + _sqlite3Fts5ConfigFree(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig) + Xsqlite3_free(tls, pTab) + } +} + +func _fts5GetRowidLimit(tls *libc.TLS, pVal uintptr, iDefault Ti64) (r Ti64) { + var eType int32 + _ = eType + if pVal != 0 { + eType = Xsqlite3_value_numeric_type(tls, pVal) + if eType == int32(SQLITE_INTEGER) { + return Xsqlite3_value_int64(tls, pVal) + } + } + return iDefault +} + +// C documentation +// +// /* +// ** The only argument points to a buffer at least 4 bytes in size. This +// ** function interprets the first 4 bytes of the buffer as a 32-bit big-endian +// ** unsigned integer and returns the result. +// */ +func _fts5GetU32(tls *libc.TLS, a uintptr) (r Tu32) { + return uint32(**(**Tu8)(__ccgo_up(a)))< (*TFts5Data)(unsafe.Pointer(pRet)).Fnn { + _fts5IndexCorruptRowid(tls, p, iRowid) + _fts5DataRelease(tls, pRet) + pRet = uintptr(0) + } + } + return pRet +} + +// C documentation +// +// /* +// ** Search the global context passed as the first argument for a tokenizer +// ** module named zName. If found, return a pointer to the Fts5TokenizerModule +// ** object. Otherwise, return NULL. +// */ +func _fts5LocateTokenizer(tls *libc.TLS, pGlobal uintptr, zName uintptr) (r uintptr) { + var pMod uintptr + _ = pMod + pMod = uintptr(0) + if zName == uintptr(0) { + pMod = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpDfltTok + } else { + pMod = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpTok + for { + if !(pMod != 0) { + break + } + if Xsqlite3_stricmp(tls, zName, (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FzName) == 0 { + break + } + goto _1 + _1: + ; + pMod = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FpNext + } + } + return pMod +} + +func _fts5MergeChunkCallback(tls *libc.TLS, p uintptr, pCtx uintptr, pChunk uintptr, nChunk int32) { + var pWriter uintptr + _ = pWriter + pWriter = pCtx + _fts5WriteAppendPoslistData(tls, p, pWriter, pChunk, nChunk) +} + +// C documentation +// +// /* +// ** Remove from colset pColset any columns that are not also in colset pMerge. +// */ +func _fts5MergeColset(tls *libc.TLS, pColset uintptr, pMerge uintptr) { + var iDiff, iIn, iMerge, iOut, v1 int32 + _, _, _, _, _ = iDiff, iIn, iMerge, iOut, v1 + iIn = 0 /* Next input in pColset */ + iMerge = 0 /* Next input in pMerge */ + iOut = 0 /* Next output slot in pColset */ + for iIn < (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol && iMerge < (*TFts5Colset)(unsafe.Pointer(pMerge)).FnCol { + iDiff = *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(iIn)*4)) - *(*int32)(unsafe.Pointer(pMerge + 4 + uintptr(iMerge)*4)) + if iDiff == 0 { + v1 = iOut + iOut = iOut + 1 + *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(v1)*4)) = *(*int32)(unsafe.Pointer(pMerge + 4 + uintptr(iMerge)*4)) + iMerge = iMerge + 1 + iIn = iIn + 1 + } else { + if iDiff > 0 { + iMerge = iMerge + 1 + } else { + iIn = iIn + 1 + } + } + } + (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol = iOut +} + +var _fts5Mod = Tsqlite3_module{ + FiVersion: int32(4), +} + +// C documentation +// +// /* +// ** xDestroy callback passed to sqlite3_create_module(). This is invoked +// ** when the db handle is being closed. Free memory associated with +// ** tokenizers and aux functions registered with this db handle. +// */ +func _fts5ModuleDestroy(tls *libc.TLS, pCtx uintptr) { + var pAux, pGlobal, pNextAux, pNextTok, pTok uintptr + _, _, _, _, _ = pAux, pGlobal, pNextAux, pNextTok, pTok + pGlobal = pCtx + pAux = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpAux + for { + if !(pAux != 0) { + break + } + pNextAux = (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpNext + if (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy})))(tls, (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpUserData) + } + Xsqlite3_free(tls, pAux) + goto _1 + _1: + ; + pAux = pNextAux + } + pTok = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpTok + for { + if !(pTok != 0) { + break + } + pNextTok = (*TFts5TokenizerModule)(unsafe.Pointer(pTok)).FpNext + if (*TFts5TokenizerModule)(unsafe.Pointer(pTok)).FxDestroy != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5TokenizerModule)(unsafe.Pointer(pTok)).FxDestroy})))(tls, (*TFts5TokenizerModule)(unsafe.Pointer(pTok)).FpUserData) + } + Xsqlite3_free(tls, pTok) + goto _2 + _2: + ; + pTok = pNextTok + } + Xsqlite3_free(tls, pGlobal) +} + +// C documentation +// +// /* +// ** Return true if the iterator is at EOF or if an error has occurred. +// ** False otherwise. +// */ +func _fts5MultiIterEof(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + return libc.BoolInt32((*TFts5Index)(unsafe.Pointer(p)).Frc != 0 || (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof != 0) +} + +// C documentation +// +// /* +// ** Move the iterator to the next entry at or following iMatch. +// */ +func _fts5MultiIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch Ti64) { + var iRowid Ti64 + _ = iRowid + for int32(1) != 0 { + _fts5MultiIterNext(tls, p, pIter, int32(1), iMatch) + if _fts5MultiIterEof(tls, p, pIter) != 0 { + break + } + iRowid = _fts5MultiIterRowid(tls, pIter) + if (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev == 0 && iRowid >= iMatch { + break + } + if (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev != 0 && iRowid <= iMatch { + break + } + } +} + +func _fts5NewTransaction(tls *libc.TLS, pTab uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = (*TFts5Global)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr + for { + if !(pCsr != 0) { + break + } + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab { + return SQLITE_OK + } + goto _1 + _1: + ; + pCsr = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpNext + } + return _sqlite3Fts5StorageReset(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage) +} + +// C documentation +// +// /* +// ** Compare the values currently indicated by the two nodes as follows: +// ** +// ** res = (*p1) - (*p2) +// ** +// ** Nodes that point to values that come later in the iteration order are +// ** considered to be larger. Nodes at EOF are the largest of all. +// ** +// ** This means that if the iteration order is ASC, then numerically larger +// ** rowids are considered larger. Or if it is the default DESC, numerically +// ** smaller rowids are larger. +// */ +func _fts5NodeCompare(tls *libc.TLS, pExpr uintptr, p1 uintptr, p2 uintptr) (r int32) { + if (*TFts5ExprNode)(unsafe.Pointer(p2)).FbEof != 0 { + return -int32(1) + } + if (*TFts5ExprNode)(unsafe.Pointer(p1)).FbEof != 0 { + return +libc.Int32FromInt32(1) + } + return _fts5RowidCmp(tls, pExpr, (*TFts5ExprNode)(unsafe.Pointer(p1)).FiRowid, (*TFts5ExprNode)(unsafe.Pointer(p2)).FiRowid) +} + +func _fts5ParseFree(tls *libc.TLS, p uintptr) { + Xsqlite3_free(tls, p) +} + +func _fts5ParseStringFromToken(tls *libc.TLS, pToken uintptr, pz uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* rc at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**uintptr)(__ccgo_up(pz)) = _sqlite3Fts5Strndup(tls, bp, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, (*TFts5Token)(unsafe.Pointer(pToken)).Fn) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Delete a "porter" tokenizer. +// */ +func _fts5PorterDelete(tls *libc.TLS, pTok uintptr) { + var p uintptr + _ = p + if pTok != 0 { + p = pTok + if (*TPorterTokenizer)(unsafe.Pointer(p)).FpTokenizer != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TPorterTokenizer)(unsafe.Pointer(p)).Ftokenizer_v2.FxDelete})))(tls, (*TPorterTokenizer)(unsafe.Pointer(p)).FpTokenizer) + } + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* porter rule condition: (m = 1) */ +func _fts5Porter_MEq1(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) { + var n int32 + _ = n + n = _fts5PorterGobbleVC(tls, zStem, nStem, 0) + if n != 0 && 0 == _fts5PorterGobbleVC(tls, zStem+uintptr(n), nStem-n, int32(1)) { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* porter rule condition: (m > 0) */ +func _fts5Porter_MGt0(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) { + return libc.BoolInt32(!!(_fts5PorterGobbleVC(tls, zStem, nStem, 0) != 0)) +} + +// C documentation +// +// /* porter rule condition: (m > 1) */ +func _fts5Porter_MGt1(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) { + var n int32 + _ = n + n = _fts5PorterGobbleVC(tls, zStem, nStem, 0) + if n != 0 && _fts5PorterGobbleVC(tls, zStem+uintptr(n), nStem-n, int32(1)) != 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Buffer aBuf[] contains a list of varints, all small enough to fit +// ** in a 32-bit integer. Return the size of the largest prefix of this +// ** list nMax bytes or less in size. +// */ +func _fts5PoslistPrefix(tls *libc.TLS, aBuf uintptr, nMax int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, ret int32 + var _ /* dummy at bp+0 */ Tu32 + _, _ = i, ret + ret = _sqlite3Fts5GetVarint32(tls, aBuf, bp) + if ret < nMax { + for int32(1) != 0 { + i = _sqlite3Fts5GetVarint32(tls, aBuf+uintptr(ret), bp) + if ret+i > nMax { + break + } + ret = ret + i + } + } + return ret +} + +// C documentation +// +// /* +// ** Write iVal, formated as a 32-bit big-endian unsigned integer, to the +// ** buffer indicated by the first argument. +// */ +func _fts5PutU32(tls *libc.TLS, a uintptr, iVal Tu32) { + **(**Tu8)(__ccgo_up(a)) = uint8(iVal >> libc.Int32FromInt32(24) & libc.Uint32FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 1)) = uint8(iVal >> libc.Int32FromInt32(16) & libc.Uint32FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(iVal >> libc.Int32FromInt32(8) & libc.Uint32FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 3)) = uint8(iVal >> libc.Int32FromInt32(0) & libc.Uint32FromInt32(0xFF)) +} + +// C documentation +// +// /* +// ** Write iVal, formated as a 64-bit big-endian unsigned integer, to the +// ** buffer indicated by the first argument. +// */ +func _fts5PutU64(tls *libc.TLS, a uintptr, iVal Tu64) { + **(**Tu8)(__ccgo_up(a)) = uint8(iVal >> libc.Int32FromInt32(56) & libc.Uint64FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 1)) = uint8(iVal >> libc.Int32FromInt32(48) & libc.Uint64FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(iVal >> libc.Int32FromInt32(40) & libc.Uint64FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 3)) = uint8(iVal >> libc.Int32FromInt32(32) & libc.Uint64FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 4)) = uint8(iVal >> libc.Int32FromInt32(24) & libc.Uint64FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 5)) = uint8(iVal >> libc.Int32FromInt32(16) & libc.Uint64FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 6)) = uint8(iVal >> libc.Int32FromInt32(8) & libc.Uint64FromInt32(0xFF)) + **(**Tu8)(__ccgo_up(a + 7)) = uint8(iVal >> libc.Int32FromInt32(0) & libc.Uint64FromInt32(0xFF)) +} + +// C documentation +// +// /* +// ** Write a 64-bit variable-length integer to memory starting at p[0]. +// ** The length of data write will be between 1 and 9 bytes. The number +// ** of bytes written is returned. +// ** +// ** A variable-length integer consists of the lower 7 bits of each byte +// ** for all bytes that have the 8th bit set and one byte with the 8th +// ** bit clear. Except, if we get to the 9th byte, it stores the full +// ** 8 bits and is the last byte. +// */ +func _fts5PutVarint64(tls *libc.TLS, p uintptr, v Tu64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j, n, v2 int32 + var v3 uintptr + var _ /* buf at bp+0 */ [10]Tu8 + _, _, _, _, _ = i, j, n, v2, v3 + if v&(libc.Uint64FromUint32(0xff000000)<> uint64(8) + i = int32(7) + for { + if !(i >= 0) { + break + } + **(**uint8)(__ccgo_up(p + uintptr(i))) = uint8(v&libc.Uint64FromInt32(0x7f) | libc.Uint64FromInt32(0x80)) + v = v >> uint64(7) + goto _1 + _1: + ; + i = i - 1 + } + return int32(9) + } + n = 0 + for cond := true; cond; cond = v != uint64(0) { + v2 = n + n = n + 1 + (**(**[10]Tu8)(__ccgo_up(bp)))[v2] = uint8(v&libc.Uint64FromInt32(0x7f) | libc.Uint64FromInt32(0x80)) + v = v >> uint64(7) + } + v3 = bp + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & libc.Int32FromInt32(0x7f)) + i = 0 + j = n - libc.Int32FromInt32(1) + for { + if !(j >= 0) { + break + } + **(**uint8)(__ccgo_up(p + uintptr(i))) = (**(**[10]Tu8)(__ccgo_up(bp)))[j] + goto _4 + _4: + ; + j = j - 1 + i = i + 1 + } + return n +} + +// C documentation +// +// /* +// ** The xRelease() method. +// ** +// ** This is a no-op. +// */ +func _fts5ReleaseMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = pVtab + rc = SQLITE_OK + if iSavepoint+int32(1) < (*TFts5FullTable)(unsafe.Pointer(pTab)).FiSavepoint { + rc = _sqlite3Fts5FlushToDisk(tls, pTab) + if rc == SQLITE_OK { + (*TFts5FullTable)(unsafe.Pointer(pTab)).FiSavepoint = iSavepoint + } + } + return rc +} + +// C documentation +// +// /* +// ** Implementation of FTS5 xRename method. Rename an fts5 table. +// */ +func _fts5RenameMethod(tls *libc.TLS, pVtab uintptr, zName uintptr) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = pVtab + rc = _sqlite3Fts5StorageRename(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, zName) + return rc +} + +// C documentation +// +// /* +// ** Parameter zFmt is a printf() style formatting string. This function +// ** formats it using the trailing arguments and returns the result as +// ** an error message to the context passed as the first argument. +// */ +func _fts5ResultError(tls *libc.TLS, pCtx uintptr, zFmt uintptr, va uintptr) { + var ap Tva_list + var zErr uintptr + _, _ = ap, zErr + zErr = uintptr(0) + ap = va + zErr = Xsqlite3_vmprintf(tls, zFmt, ap) + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + Xsqlite3_free(tls, zErr) + _ = ap +} + +// C documentation +// +// /* +// ** Implementation of xRollback(). Discard the contents of the pending-terms +// ** hash-table. Any changes made to the database are reverted by SQLite. +// */ +func _fts5RollbackMethod(tls *libc.TLS, pVtab uintptr) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = pVtab + rc = _sqlite3Fts5StorageRollback(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage) + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).Fpgsz = 0 + return rc +} + +// C documentation +// +// /* +// ** The xRollbackTo() method. +// ** +// ** Discard the contents of the pending terms table. +// */ +func _fts5RollbackToMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = pVtab + rc = SQLITE_OK + _fts5TripCursors(tls, pTab) + if iSavepoint+int32(1) <= (*TFts5FullTable)(unsafe.Pointer(pTab)).FiSavepoint { + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).Fpgsz = 0 + rc = _sqlite3Fts5StorageRollback(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage) + } + return rc +} + +// C documentation +// +// /* +// ** If pExpr is an ASC iterator, this function returns a value with the +// ** same sign as: +// ** +// ** (iLhs - iRhs) +// ** +// ** Otherwise, if this is a DESC iterator, the opposite is returned: +// ** +// ** (iRhs - iLhs) +// */ +func _fts5RowidCmp(tls *libc.TLS, pExpr uintptr, iLhs Ti64, iRhs Ti64) (r int32) { + if (*TFts5Expr)(unsafe.Pointer(pExpr)).FbDesc == 0 { + if iLhs < iRhs { + return -int32(1) + } + return libc.BoolInt32(iLhs > iRhs) + } else { + if iLhs > iRhs { + return -int32(1) + } + return libc.BoolInt32(iLhs < iRhs) + } + return r +} + +// C documentation +// +// /* +// ** This is the xRowid method. The SQLite core calls this routine to +// ** retrieve the rowid for the current row of the result set. fts5 +// ** exposes %_content.rowid as the rowid for the virtual table. The +// ** rowid should be written to *pRowid. +// */ +func _fts5RowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) (r int32) { + var ePlan int32 + var pCsr uintptr + _, _ = ePlan, pCsr + pCsr = pCursor + ePlan = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan + if ePlan == int32(FTS5_PLAN_SPECIAL) { + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = 0 + } else { + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = _fts5CursorRowid(tls, pCsr) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** The xSavepoint() method. +// ** +// ** Flush the contents of the pending-terms table to disk. +// */ +func _fts5SavepointMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = pVtab + rc = SQLITE_OK + rc = _sqlite3Fts5FlushToDisk(tls, pVtab) + if rc == SQLITE_OK { + (*TFts5FullTable)(unsafe.Pointer(pTab)).FiSavepoint = iSavepoint + int32(1) + } + return rc +} + +// C documentation +// +// /* +// ** Iterator pIter currently points to the first rowid of a doclist. +// ** There is a doclist-index associated with the final term on the current +// ** page. If the current term is the last term on the page, load the +// ** doclist-index from disk and initialize an iterator at (pIter->pDlidx). +// */ +func _fts5SegIterLoadDlidx(tls *libc.TLS, p uintptr, pIter uintptr) { + var bRev, iSeg int32 + var pLeaf uintptr + _, _, _ = bRev, iSeg, pLeaf + iSeg = (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid + bRev = (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags & int32(FTS5_SEGITER_REVERSE) + pLeaf = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf /* Current leaf data */ + /* Check if the current doclist ends on this page. If it does, return + ** early without loading the doclist-index (as it belongs to a different + ** term. */ + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno && (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist < (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + return + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpDlidx = _fts5DlidxIterInit(tls, p, bRev, iSeg, (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno) +} + +// C documentation +// +// /* +// ** Advance the iterator passed as the second argument until it is at or +// ** past rowid iFrom. Regardless of the value of iFrom, the iterator is +// ** always advanced at least once. +// */ +func _fts5SegIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch Ti64) { + var bMove, bRev, iLeafPgno int32 + var pDlidx uintptr + _, _, _, _ = bMove, bRev, iLeafPgno, pDlidx + bRev = (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags & int32(FTS5_SEGITER_REVERSE) + pDlidx = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpDlidx + iLeafPgno = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno + bMove = int32(1) + if bRev == 0 { + for !(_fts5DlidxIterEof(tls, p, pDlidx) != 0) && iMatch > _fts5DlidxIterRowid(tls, pDlidx) { + iLeafPgno = _fts5DlidxIterPgno(tls, pDlidx) + _fts5DlidxIterNext(tls, p, pDlidx) + } + if iLeafPgno > (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno { + _fts5SegIterGotoPage(tls, p, pIter, iLeafPgno) + bMove = 0 + } + } else { + for !(_fts5DlidxIterEof(tls, p, pDlidx) != 0) && iMatch < _fts5DlidxIterRowid(tls, pDlidx) { + _fts5DlidxIterPrev(tls, p, pDlidx) + } + iLeafPgno = _fts5DlidxIterPgno(tls, pDlidx) + if iLeafPgno < (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iLeafPgno + int32(1) + _fts5SegIterReverseNewPage(tls, p, pIter) + bMove = 0 + } + } + for cond := true; cond; cond = (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if bMove != 0 && (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5SegIter)(unsafe.Pointer(pIter)).FxNext})))(tls, p, pIter, uintptr(0)) + } + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { + break + } + if bRev == 0 && (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowid >= iMatch { + break + } + if bRev != 0 && (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowid <= iMatch { + break + } + bMove = int32(1) + } +} + +// C documentation +// +// /* +// ** Ensure the segment-iterator passed as the only argument points to EOF. +// */ +func _fts5SegIterSetEOF(tls *libc.TLS, pSeg uintptr) { + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf = uintptr(0) +} + +func _fts5SegIterSetNext(tls *libc.TLS, p uintptr, pIter uintptr) { + if (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags&int32(FTS5_SEGITER_REVERSE) != 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FxNext = __ccgo_fp(_fts5SegIterNext_Reverse) + } else { + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FxNext = __ccgo_fp(_fts5SegIterNext_None) + } else { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FxNext = __ccgo_fp(_fts5SegIterNext) + } + } +} + +func _fts5SegmentSize(tls *libc.TLS, pSeg uintptr) (r int32) { + return int32(1) + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast - (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst +} + +func _fts5SetEstimatedRows(tls *libc.TLS, pIdxInfo uintptr, nRow Ti64) { + var v1 int64 + _ = v1 + if int64(libc.Int32FromInt32(1)) > nRow { + v1 = int64(libc.Int32FromInt32(1)) + } else { + v1 = nRow + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = v1 +} + +// C documentation +// +// /* +// ** Set the error message on the virtual table passed as the first argument. +// */ +func _fts5SetVtabError(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) { + var ap Tva_list + _ = ap /* ... printf arguments */ + ap = va + Xsqlite3_free(tls, (*TFts5FullTable)(unsafe.Pointer(p)).Fp.Fbase.FzErrMsg) + (*TFts5FullTable)(unsafe.Pointer(p)).Fp.Fbase.FzErrMsg = Xsqlite3_vmprintf(tls, zFormat, ap) + _ = ap +} + +func _fts5SnippetScore(tls *libc.TLS, pApi uintptr, pFts uintptr, nDocsize int32, aSeen uintptr, iCol int32, iPos int32, nToken int32, pnScore uintptr, piPos uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iFirst, iLast, nScore, rc, v2 int32 + var iAdj, iEnd Tsqlite3_int64 + var _ /* iOff at bp+8 */ int32 + var _ /* ic at bp+4 */ int32 + var _ /* ip at bp+0 */ int32 + var _ /* nInst at bp+12 */ int32 + _, _, _, _, _, _, _, _ = i, iAdj, iEnd, iFirst, iLast, nScore, rc, v2 + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = 0 + iFirst = -int32(1) + nScore = 0 + iLast = 0 + iEnd = int64(iPos) + int64(nToken) + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})))(tls, pFts, bp+12) + i = 0 + for { + if !(i < **(**int32)(__ccgo_up(bp + 12)) && rc == SQLITE_OK) { + break + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})))(tls, pFts, i, bp, bp+4, bp+8) + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp + 4)) == iCol && **(**int32)(__ccgo_up(bp + 8)) >= iPos && int64(**(**int32)(__ccgo_up(bp + 8))) < iEnd { + if **(**uint8)(__ccgo_up(aSeen + uintptr(**(**int32)(__ccgo_up(bp))))) != 0 { + v2 = int32(1) + } else { + v2 = int32(1000) + } + nScore = nScore + v2 + **(**uint8)(__ccgo_up(aSeen + uintptr(**(**int32)(__ccgo_up(bp))))) = uint8(1) + if iFirst < 0 { + iFirst = **(**int32)(__ccgo_up(bp + 8)) + } + iLast = **(**int32)(__ccgo_up(bp + 8)) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseSize})))(tls, pFts, **(**int32)(__ccgo_up(bp))) + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(pnScore)) = nScore + if piPos != 0 { + iAdj = int64(iFirst - (nToken-(iLast-iFirst))/int32(2)) + if iAdj+int64(nToken) > int64(nDocsize) { + iAdj = int64(nDocsize - nToken) + } + if iAdj < 0 { + iAdj = 0 + } + **(**int32)(__ccgo_up(piPos)) = int32(iAdj) + } + return rc +} + +func _fts5StmtType(tls *libc.TLS, pCsr uintptr) (r int32) { + var v1 int32 + _ = v1 + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan == int32(FTS5_PLAN_SCAN) { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FbDesc != 0 { + v1 = int32(FTS5_STMT_SCAN_DESC) + } else { + v1 = FTS5_STMT_SCAN_ASC + } + return v1 + } + return int32(FTS5_STMT_LOOKUP) +} + +// C documentation +// +// /* +// ** This function is called to process a DELETE on a contentless_delete=1 +// ** table. It adds the tombstone required to delete the entry with rowid +// ** iDel. If successful, SQLITE_OK is returned. Or, if an error occurs, +// ** an SQLite error code. +// */ +func _fts5StorageContentlessDelete(tls *libc.TLS, p uintptr, iDel Ti64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iOrigin Ti64 + var rc int32 + var _ /* pLookup at bp+0 */ uintptr + _, _ = iOrigin, rc + iOrigin = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + /* Look up the origin of the document in the %_docsize table. Store + ** this in stack variable iOrigin. */ + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_LOOKUP_DOCSIZE), bp, uintptr(0)) + if rc == SQLITE_OK { + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iDel) + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iOrigin = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + } + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + } + if rc == SQLITE_OK && iOrigin != 0 { + rc = _sqlite3Fts5IndexContentlessDelete(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, iOrigin, iDel) + } + return rc +} + +func _fts5StorageDecodeSizeArray(tls *libc.TLS, aCol uintptr, nCol int32, aBlob uintptr, nBlob int32) (r int32) { + var i, iOff int32 + _, _ = i, iOff + iOff = 0 + i = 0 + for { + if !(i < nCol) { + break + } + if iOff >= nBlob { + return int32(1) + } + iOff = iOff + _sqlite3Fts5GetVarint32(tls, aBlob+uintptr(iOff), aCol+uintptr(i)*4) + goto _1 + _1: + ; + i = i + 1 + } + return libc.BoolInt32(iOff != nBlob) +} + +func _fts5StorageInsert(tls *libc.TLS, pRc uintptr, pTab uintptr, apVal uintptr, piRowid uintptr) { + var rc int32 + _ = rc + rc = **(**int32)(__ccgo_up(pRc)) + if rc == SQLITE_OK { + rc = _sqlite3Fts5StorageContentInsert(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, 0, apVal, piRowid) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5StorageIndexInsert(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, **(**Ti64)(__ccgo_up(piRowid))) + } + **(**int32)(__ccgo_up(pRc)) = rc +} + +// C documentation +// +// /* +// ** Tokenization callback used when inserting tokens into the FTS index. +// */ +func _fts5StorageInsertCallback(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) (r int32) { + var pCtx, pIdx uintptr + _, _ = pCtx, pIdx + pCtx = pContext + pIdx = (*TFts5Storage)(unsafe.Pointer((*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FpStorage)).FpIndex + _ = iUnused1 + _ = iUnused2 + if nToken > int32(FTS5_MAX_TOKEN_SIZE) { + nToken = int32(FTS5_MAX_TOKEN_SIZE) + } + if tflags&int32(FTS5_TOKEN_COLOCATED) == 0 || (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol == 0 { + (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol = (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol + 1 + } + return _sqlite3Fts5IndexWrite(tls, pIdx, (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FiCol, (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol-int32(1), pToken, nToken) +} + +// C documentation +// +// /* +// ** Insert a record into the %_docsize table. Specifically, do: +// ** +// ** INSERT OR REPLACE INTO %_docsize(id, sz) VALUES(iRowid, pBuf); +// ** +// ** If there is no %_docsize table (as happens if the columnsize=0 option +// ** is specified when the FTS5 table is created), this function is a no-op. +// */ +func _fts5StorageInsertDocsize(tls *libc.TLS, p uintptr, iRowid Ti64, pBuf uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* iOrigin at bp+8 */ Ti64 + var _ /* pReplace at bp+0 */ uintptr + _ = rc + rc = SQLITE_OK + if (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_REPLACE_DOCSIZE), bp, uintptr(0)) + if rc == SQLITE_OK { + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iRowid) + if (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbContentlessDelete != 0 { + **(**Ti64)(__ccgo_up(bp + 8)) = 0 + rc = _sqlite3Fts5IndexGetOrigin(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, bp+8) + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(3), **(**Ti64)(__ccgo_up(bp + 8))) + } + } + if rc == SQLITE_OK { + Xsqlite3_bind_blob(tls, **(**uintptr)(__ccgo_up(bp)), int32(2), (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn, libc.UintptrFromInt32(0)) + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + Xsqlite3_bind_null(tls, **(**uintptr)(__ccgo_up(bp)), int32(2)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Tokenization callback used by integrity check. +// */ +func _fts5StorageIntegrityCallback(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iCol, iPos, ii, nByte, nChar, rc int32 + var pCtx, pTermset uintptr + var _ /* bPresent at bp+0 */ int32 + _, _, _, _, _, _, _, _ = iCol, iPos, ii, nByte, nChar, pCtx, pTermset, rc + pCtx = pContext + pTermset = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpTermset + rc = SQLITE_OK + _ = iUnused1 + _ = iUnused2 + if nToken > int32(FTS5_MAX_TOKEN_SIZE) { + nToken = int32(FTS5_MAX_TOKEN_SIZE) + } + if tflags&int32(FTS5_TOKEN_COLOCATED) == 0 || (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol == 0 { + (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol + 1 + } + switch (*TFts5Config)(unsafe.Pointer((*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FeDetail { + case FTS5_DETAIL_FULL: + iPos = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol - int32(1) + iCol = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol + case int32(FTS5_DETAIL_COLUMNS): + iPos = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol + iCol = 0 + default: + iPos = 0 + iCol = 0 + break + } + rc = _sqlite3Fts5TermsetAdd(tls, pTermset, 0, pToken, nToken, bp) + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp)) == 0 { + **(**Tu64)(__ccgo_up(pCtx + 16)) ^= _sqlite3Fts5IndexEntryCksum(tls, (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiRowid, iCol, iPos, 0, pToken, nToken) + } + ii = 0 + for { + if !(rc == SQLITE_OK && ii < (*TFts5Config)(unsafe.Pointer((*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FnPrefix) { + break + } + nChar = **(**int32)(__ccgo_up((*TFts5Config)(unsafe.Pointer((*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FaPrefix + uintptr(ii)*4)) + nByte = _sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar) + if nByte != 0 { + rc = _sqlite3Fts5TermsetAdd(tls, pTermset, ii+int32(1), pToken, nByte, bp) + if **(**int32)(__ccgo_up(bp)) == 0 { + **(**Tu64)(__ccgo_up(pCtx + 16)) ^= _sqlite3Fts5IndexEntryCksum(tls, (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiRowid, iCol, iPos, ii+int32(1), pToken, nByte) + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + return rc +} + +// C documentation +// +// /* +// ** Allocate a new rowid. This is used for "external content" tables when +// ** a NULL value is inserted into the rowid column. The new rowid is allocated +// ** by inserting a dummy row into the %_docsize table. The dummy will be +// ** overwritten later. +// ** +// ** If the %_docsize table does not exist, SQLITE_MISMATCH is returned. In +// ** this case the user is required to provide a rowid explicitly. +// */ +func _fts5StorageNewRowid(tls *libc.TLS, p uintptr, piRowid uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pReplace at bp+0 */ uintptr + _ = rc + rc = int32(SQLITE_MISMATCH) + if (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_REPLACE_DOCSIZE), bp, uintptr(0)) + if rc == SQLITE_OK { + Xsqlite3_bind_null(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + Xsqlite3_bind_null(tls, **(**uintptr)(__ccgo_up(bp)), int32(2)) + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + } + if rc == SQLITE_OK { + **(**Ti64)(__ccgo_up(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb) + } + } + return rc +} + +func _fts5StructureInvalidate(tls *libc.TLS, p uintptr) { + if (*TFts5Index)(unsafe.Pointer(p)).FpStruct != 0 { + _fts5StructureRelease(tls, (*TFts5Index)(unsafe.Pointer(p)).FpStruct) + (*TFts5Index)(unsafe.Pointer(p)).FpStruct = uintptr(0) + } +} + +/* +** Return the total number of segments in index structure pStruct. This +** function is only ever used as part of assert() conditions. + */ + +// C documentation +// +// /* +// ** Read, deserialize and return the structure record. +// ** +// ** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array +// ** are over-allocated as described for function fts5StructureDecode() +// ** above. +// ** +// ** If an error occurs, NULL is returned and an error code left in the +// ** Fts5Index handle. If an error has already occurred when this function +// ** is called, it is a no-op. +// */ +func _fts5StructureRead(tls *libc.TLS, p uintptr) (r uintptr) { + if (*TFts5Index)(unsafe.Pointer(p)).FpStruct == uintptr(0) { + (*TFts5Index)(unsafe.Pointer(p)).FiStructVersion = _fts5IndexDataVersion(tls, p) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*TFts5Index)(unsafe.Pointer(p)).FpStruct = _fts5StructureReadUncached(tls, p) + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return uintptr(0) + } + _fts5StructureRef(tls, (*TFts5Index)(unsafe.Pointer(p)).FpStruct) + return (*TFts5Index)(unsafe.Pointer(p)).FpStruct +} + +func _fts5StructureRef(tls *libc.TLS, pStruct uintptr) { + (*TFts5Structure)(unsafe.Pointer(pStruct)).FnRef = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnRef + 1 +} + +// C documentation +// +// /* +// ** Free a trigram tokenizer. +// */ +func _fts5TriDelete(tls *libc.TLS, p uintptr) { + Xsqlite3_free(tls, p) +} + +// C documentation +// +// /* +// ** Delete a "unicode61" tokenizer. +// */ +func _fts5UnicodeDelete(tls *libc.TLS, pTok uintptr) { + var p uintptr + _ = p + if pTok != 0 { + p = pTok + Xsqlite3_free(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaiException) + Xsqlite3_free(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold) + Xsqlite3_free(tls, p) + } + return +} + +// C documentation +// +// /* +// ** Return true if the p->aiException[] array contains the value iCode. +// */ +func _fts5UnicodeIsException(tls *libc.TLS, p uintptr, iCode int32) (r int32) { + var a uintptr + var iHi, iLo, iTest int32 + _, _, _, _ = a, iHi, iLo, iTest + if (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException > 0 { + a = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaiException + iLo = 0 + iHi = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException - int32(1) + for iHi >= iLo { + iTest = (iHi + iLo) / int32(2) + if iCode == **(**int32)(__ccgo_up(a + uintptr(iTest)*4)) { + return int32(1) + } else { + if iCode > **(**int32)(__ccgo_up(a + uintptr(iTest)*4)) { + iLo = iTest + int32(1) + } else { + iHi = iTest - int32(1) + } + } + } + } + return 0 +} + +// C documentation +// +// /* +// ** xTokenizer method for a wrapper tokenizer that offers the v1 interface +// ** (no support for locales). +// */ +func _fts5V1toV2Tokenize(tls *libc.TLS, pTok uintptr, pCtx uintptr, flags int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + var p uintptr + _ = p + p = pTok + return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5VtoVTokenizer)(unsafe.Pointer(p)).Fx2.FxTokenize})))(tls, (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FpReal, pCtx, flags, pText, nText, uintptr(0), 0, __ccgo_fp_xToken) +} + +// C documentation +// +// /* +// ** xTokenizer method for a wrapper tokenizer that offers the v2 interface +// ** (with locale support). +// */ +func _fts5V2toV1Tokenize(tls *libc.TLS, pTok uintptr, pCtx uintptr, flags int32, pText uintptr, nText int32, pLocale uintptr, nLocale int32, __ccgo_fp_xToken uintptr) (r int32) { + var p uintptr + _ = p + p = pTok + _ = pLocale + _ = nLocale + return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5VtoVTokenizer)(unsafe.Pointer(p)).Fx1.FxTokenize})))(tls, (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FpReal, pCtx, flags, pText, nText, __ccgo_fp_xToken) +} + +var _fts5Vocab = Tsqlite3_module{ + FiVersion: int32(2), +} + +// C documentation +// +// /* +// ** The xConnect() and xCreate() methods for the virtual table. All the +// ** work is done in function fts5VocabInitVtab(). +// */ +func _fts5VocabConnectMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + return _fts5VocabInitVtab(tls, db, pAux, argc, argv, ppVtab, pzErr) +} + +func _fts5VocabCreateMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + return _fts5VocabInitVtab(tls, db, pAux, argc, argv, ppVtab, pzErr) +} + +// C documentation +// +// /* +// ** The xDestroy() virtual table method. +// */ +func _fts5VocabDestroyMethod(tls *libc.TLS, pVtab uintptr) (r int32) { + var pTab uintptr + _ = pTab + pTab = pVtab + Xsqlite3_free(tls, pTab) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** The xDisconnect() virtual table method. +// */ +func _fts5VocabDisconnectMethod(tls *libc.TLS, pVtab uintptr) (r int32) { + var pTab uintptr + _ = pTab + pTab = pVtab + Xsqlite3_free(tls, pTab) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This is the xEof method of the virtual table. SQLite calls this +// ** routine to find out if it has reached the end of a result set. +// */ +func _fts5VocabEofMethod(tls *libc.TLS, pCursor uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCursor + return (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof +} + +// C documentation +// +// /* +// ** This is the xRowid method. The SQLite core calls this routine to +// ** retrieve the rowid for the current row of the result set. The +// ** rowid should be written to *pRowid. +// */ +func _fts5VocabRowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCursor + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Delete an Fts5VtoVTokenizer wrapper tokenizer. +// */ +func _fts5VtoVDelete(tls *libc.TLS, pTok uintptr) { + var p uintptr + _ = p + p = pTok + if p != 0 { + if (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FbV2Native != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5VtoVTokenizer)(unsafe.Pointer(p)).Fx2.FxDelete})))(tls, (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FpReal) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5VtoVTokenizer)(unsafe.Pointer(p)).Fx1.FxDelete})))(tls, (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FpReal) + } + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** If the current doclist-index accumulating in pWriter->aDlidx[] is large +// ** enough, flush it to disk and return 1. Otherwise discard it and return +// ** zero. +// */ +func _fts5WriteFlushDlidx(tls *libc.TLS, p uintptr, pWriter uintptr) (r int32) { + var bFlag int32 + _ = bFlag + bFlag = 0 + /* If there were FTS5_MIN_DLIDX_SIZE or more empty leaf pages written + ** to the database, also write the doclist-index to disk. */ + if (**(**TFts5DlidxWriter)(__ccgo_up((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx))).Fbuf.Fn > 0 && (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty >= int32(FTS5_MIN_DLIDX_SIZE) { + bFlag = int32(1) + } + _fts5WriteDlidxClear(tls, p, pWriter, bFlag) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty = 0 + return bFlag +} + +// C documentation +// +// /* For rule J, fts5yyRuleInfoLhs[J] contains the symbol on the left-hand side +// ** of that rule */ +var _fts5yyRuleInfoLhs = [28]uint8{ + 0: uint8(16), + 1: uint8(20), + 2: uint8(20), + 3: uint8(20), + 4: uint8(20), + 5: uint8(21), + 6: uint8(21), + 7: uint8(17), + 8: uint8(17), + 9: uint8(17), + 10: uint8(17), + 11: uint8(17), + 12: uint8(17), + 13: uint8(19), + 14: uint8(19), + 15: uint8(18), + 16: uint8(18), + 17: uint8(22), + 18: uint8(22), + 19: uint8(22), + 20: uint8(23), + 21: uint8(23), + 22: uint8(25), + 23: uint8(25), + 24: uint8(24), + 25: uint8(24), + 26: uint8(26), + 27: uint8(26), +} + +// C documentation +// +// /* For rule J, fts5yyRuleInfoNRhs[J] contains the negative of the number +// ** of symbols on the right-hand side of that rule. */ +var _fts5yyRuleInfoNRhs = [28]int8{ + 0: int8(-int32(1)), + 1: int8(-int32(4)), + 2: int8(-int32(3)), + 3: int8(-int32(1)), + 4: int8(-int32(2)), + 5: int8(-int32(2)), + 6: int8(-int32(1)), + 7: int8(-int32(3)), + 8: int8(-int32(3)), + 9: int8(-int32(3)), + 10: int8(-int32(5)), + 11: int8(-int32(3)), + 12: int8(-int32(1)), + 13: int8(-int32(1)), + 14: int8(-int32(2)), + 15: int8(-int32(1)), + 16: int8(-int32(3)), + 17: int8(-int32(1)), + 18: int8(-int32(2)), + 19: int8(-int32(5)), + 20: int8(-int32(1)), + 21: int8(-int32(2)), + 23: int8(-int32(2)), + 24: int8(-int32(4)), + 25: int8(-int32(2)), + 26: int8(-int32(1)), +} + +// C documentation +// +// /* +// ** The following is executed when the parser accepts +// */ +func _fts5yy_accept(tls *libc.TLS, fts5yypParser uintptr) { + var pParse uintptr + _ = pParse + pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + /*********** Begin %parse_accept code *****************************************/ + /*********** End %parse_accept code *******************************************/ + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse /* Suppress warning about unused %extra_argument variable */ +} + +// C documentation +// +// /* Next are the tables used to determine what action to take based on the +// ** current state and lookahead token. These tables are used to implement +// ** functions that take a state number and lookahead value and return an +// ** action integer. +// ** +// ** Suppose the action integer is N. Then the action is determined as +// ** follows +// ** +// ** 0 <= N <= fts5YY_MAX_SHIFT Shift N. That is, push the lookahead +// ** token onto the stack and goto state N. +// ** +// ** N between fts5YY_MIN_SHIFTREDUCE Shift to an arbitrary state then +// ** and fts5YY_MAX_SHIFTREDUCE reduce by rule N-fts5YY_MIN_SHIFTREDUCE. +// ** +// ** N == fts5YY_ERROR_ACTION A syntax error has occurred. +// ** +// ** N == fts5YY_ACCEPT_ACTION The parser accepts its input. +// ** +// ** N == fts5YY_NO_ACTION No such action. Denotes unused +// ** slots in the fts5yy_action[] table. +// ** +// ** N between fts5YY_MIN_REDUCE Reduce by rule N-fts5YY_MIN_REDUCE +// ** and fts5YY_MAX_REDUCE +// ** +// ** The action table is constructed as a single large table named fts5yy_action[]. +// ** Given state S and lookahead X, the action is computed as either: +// ** +// ** (A) N = fts5yy_action[ fts5yy_shift_ofst[S] + X ] +// ** (B) N = fts5yy_default[S] +// ** +// ** The (A) formula is preferred. The B formula is used instead if +// ** fts5yy_lookahead[fts5yy_shift_ofst[S]+X] is not equal to X. +// ** +// ** The formulas above are for computing the action when the lookahead is +// ** a terminal symbol. If the lookahead is a non-terminal (as occurs after +// ** a reduce action) then the fts5yy_reduce_ofst[] array is used in place of +// ** the fts5yy_shift_ofst[] array. +// ** +// ** The following are the tables generated in this section: +// ** +// ** fts5yy_action[] A single table containing all actions. +// ** fts5yy_lookahead[] A table containing the lookahead for each entry in +// ** fts5yy_action. Used to detect hash collisions. +// ** fts5yy_shift_ofst[] For each state, the offset into fts5yy_action for +// ** shifting terminals. +// ** fts5yy_reduce_ofst[] For each state, the offset into fts5yy_action for +// ** shifting non-terminals after a reduce. +// ** fts5yy_default[] Default action for each state. +// ** +// *********** Begin parsing tables **********************************************/ +var _fts5yy_action = [105]uint8{ + 0: uint8(81), + 1: uint8(20), + 2: uint8(96), + 3: uint8(6), + 4: uint8(28), + 5: uint8(99), + 6: uint8(98), + 7: uint8(26), + 8: uint8(26), + 9: uint8(18), + 10: uint8(96), + 11: uint8(6), + 12: uint8(28), + 13: uint8(17), + 14: uint8(98), + 15: uint8(56), + 16: uint8(26), + 17: uint8(19), + 18: uint8(96), + 19: uint8(6), + 20: uint8(28), + 21: uint8(14), + 22: uint8(98), + 23: uint8(14), + 24: uint8(26), + 25: uint8(31), + 26: uint8(92), + 27: uint8(96), + 28: uint8(6), + 29: uint8(28), + 30: uint8(108), + 31: uint8(98), + 32: uint8(25), + 33: uint8(26), + 34: uint8(21), + 35: uint8(96), + 36: uint8(6), + 37: uint8(28), + 38: uint8(78), + 39: uint8(98), + 40: uint8(58), + 41: uint8(26), + 42: uint8(29), + 43: uint8(96), + 44: uint8(6), + 45: uint8(28), + 46: uint8(107), + 47: uint8(98), + 48: uint8(22), + 49: uint8(26), + 50: uint8(24), + 51: uint8(16), + 52: uint8(12), + 53: uint8(11), + 54: uint8(1), + 55: uint8(13), + 56: uint8(13), + 57: uint8(24), + 58: uint8(16), + 59: uint8(23), + 60: uint8(11), + 61: uint8(33), + 62: uint8(34), + 63: uint8(13), + 64: uint8(97), + 65: uint8(8), + 66: uint8(27), + 67: uint8(32), + 68: uint8(98), + 69: uint8(7), + 70: uint8(26), + 71: uint8(3), + 72: uint8(4), + 73: uint8(5), + 74: uint8(3), + 75: uint8(4), + 76: uint8(5), + 77: uint8(3), + 78: uint8(83), + 79: uint8(4), + 80: uint8(5), + 81: uint8(3), + 82: uint8(63), + 83: uint8(5), + 84: uint8(3), + 85: uint8(62), + 86: uint8(12), + 87: uint8(2), + 88: uint8(86), + 89: uint8(13), + 90: uint8(9), + 91: uint8(30), + 92: uint8(10), + 93: uint8(10), + 94: uint8(54), + 95: uint8(57), + 96: uint8(75), + 97: uint8(78), + 98: uint8(78), + 99: uint8(53), + 100: uint8(57), + 101: uint8(15), + 102: uint8(82), + 103: uint8(82), + 104: uint8(71), +} + +var _fts5yy_default = [35]uint8{ + 0: uint8(80), + 1: uint8(80), + 2: uint8(80), + 3: uint8(80), + 4: uint8(80), + 5: uint8(80), + 6: uint8(95), + 7: uint8(80), + 8: uint8(80), + 9: uint8(105), + 10: uint8(80), + 11: uint8(110), + 12: uint8(110), + 13: uint8(80), + 14: uint8(110), + 15: uint8(110), + 16: uint8(80), + 17: uint8(80), + 18: uint8(80), + 19: uint8(80), + 20: uint8(80), + 21: uint8(91), + 22: uint8(80), + 23: uint8(80), + 24: uint8(80), + 25: uint8(101), + 26: uint8(100), + 27: uint8(80), + 28: uint8(80), + 29: uint8(90), + 30: uint8(103), + 31: uint8(80), + 32: uint8(80), + 33: uint8(104), + 34: uint8(80), +} + +/********** End of lemon-generated parsing tables *****************************/ + +/* The next table maps tokens (terminal symbols) into fallback tokens. +** If a construct like the following: +** +** %fallback ID X Y Z. +** +** appears in the grammar, then ID becomes a fallback token for X, Y, +** and Z. Whenever one of the tokens X, Y, or Z is input to the parser +** but it does not parse, the type of the token is changed to ID and +** the parse is retried before an error is thrown. +** +** This feature can be used, for example, to cause some keywords in a language +** to revert to identifiers if they keyword does not apply in the context where +** it appears. + */ + +var _fts5yy_lookahead = [121]uint8{ + 0: uint8(16), + 1: uint8(17), + 2: uint8(18), + 3: uint8(19), + 4: uint8(20), + 5: uint8(22), + 6: uint8(22), + 7: uint8(24), + 8: uint8(24), + 9: uint8(17), + 10: uint8(18), + 11: uint8(19), + 12: uint8(20), + 13: uint8(7), + 14: uint8(22), + 15: uint8(9), + 16: uint8(24), + 17: uint8(17), + 18: uint8(18), + 19: uint8(19), + 20: uint8(20), + 21: uint8(9), + 22: uint8(22), + 23: uint8(9), + 24: uint8(24), + 25: uint8(13), + 26: uint8(17), + 27: uint8(18), + 28: uint8(19), + 29: uint8(20), + 30: uint8(26), + 31: uint8(22), + 32: uint8(24), + 33: uint8(24), + 34: uint8(17), + 35: uint8(18), + 36: uint8(19), + 37: uint8(20), + 38: uint8(15), + 39: uint8(22), + 40: uint8(9), + 41: uint8(24), + 42: uint8(17), + 43: uint8(18), + 44: uint8(19), + 45: uint8(20), + 46: uint8(26), + 47: uint8(22), + 48: uint8(21), + 49: uint8(24), + 50: uint8(6), + 51: uint8(7), + 52: uint8(9), + 53: uint8(9), + 54: uint8(10), + 55: uint8(12), + 56: uint8(12), + 57: uint8(6), + 58: uint8(7), + 59: uint8(21), + 60: uint8(9), + 61: uint8(24), + 62: uint8(25), + 63: uint8(12), + 64: uint8(18), + 65: uint8(5), + 66: uint8(20), + 67: uint8(14), + 68: uint8(22), + 69: uint8(5), + 70: uint8(24), + 71: uint8(3), + 72: uint8(1), + 73: uint8(2), + 74: uint8(3), + 75: uint8(1), + 76: uint8(2), + 77: uint8(3), + 79: uint8(1), + 80: uint8(2), + 81: uint8(3), + 82: uint8(11), + 83: uint8(2), + 84: uint8(3), + 85: uint8(11), + 86: uint8(9), + 87: uint8(10), + 88: uint8(5), + 89: uint8(12), + 90: uint8(23), + 91: uint8(24), + 92: uint8(10), + 93: uint8(10), + 94: uint8(8), + 95: uint8(9), + 96: uint8(9), + 97: uint8(15), + 98: uint8(15), + 99: uint8(8), + 100: uint8(9), + 101: uint8(9), + 102: uint8(27), + 103: uint8(27), + 104: uint8(11), + 105: uint8(27), + 106: uint8(27), + 107: uint8(27), + 108: uint8(27), + 109: uint8(27), + 110: uint8(27), + 111: uint8(27), + 112: uint8(27), + 113: uint8(27), + 114: uint8(27), + 115: uint8(27), + 116: uint8(27), + 117: uint8(27), + 118: uint8(27), + 119: uint8(27), + 120: uint8(27), +} + +var _fts5yy_reduce_ofst = [18]int8{ + 0: int8(-int32(16)), + 1: int8(-int32(8)), + 3: int8(9), + 4: int8(17), + 5: int8(25), + 6: int8(46), + 7: int8(-int32(17)), + 8: int8(-int32(17)), + 9: int8(37), + 10: int8(67), + 11: int8(4), + 12: int8(4), + 13: int8(8), + 14: int8(4), + 15: int8(20), + 16: int8(27), + 17: int8(38), +} + +var _fts5yy_shift_ofst = [35]uint8{ + 0: uint8(44), + 1: uint8(44), + 2: uint8(44), + 3: uint8(44), + 4: uint8(44), + 5: uint8(44), + 6: uint8(51), + 7: uint8(77), + 8: uint8(43), + 9: uint8(12), + 10: uint8(14), + 11: uint8(83), + 12: uint8(82), + 13: uint8(14), + 14: uint8(23), + 15: uint8(23), + 16: uint8(31), + 17: uint8(31), + 18: uint8(71), + 19: uint8(74), + 20: uint8(78), + 21: uint8(81), + 22: uint8(86), + 23: uint8(91), + 24: uint8(6), + 25: uint8(53), + 26: uint8(53), + 27: uint8(60), + 28: uint8(64), + 29: uint8(68), + 30: uint8(53), + 31: uint8(87), + 32: uint8(92), + 33: uint8(53), + 34: uint8(93), +} + +// C documentation +// +// /* +// ** Implementation of the geopoly_area(X) function. +// ** +// ** If the input is a well-formed Geopoly BLOB then return the area +// ** enclosed by the polygon. If the polygon circulates clockwise instead +// ** of counterclockwise (as it should) then return the negative of the +// ** enclosed area. Otherwise return NULL. +// */ +func _geopolyAreaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var p uintptr + _ = p + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + _ = argc + if p != 0 { + Xsqlite3_result_double(tls, context, _geopolyArea(tls, p)) + Xsqlite3_free(tls, p) + } +} + +func _geopolyBBoxFinal(tls *libc.TLS, context uintptr) { + var p, pBBox uintptr + _, _ = p, pBBox + pBBox = Xsqlite3_aggregate_context(tls, context, 0) + if pBBox == uintptr(0) { + return + } + p = _geopolyBBox(tls, context, uintptr(0), pBBox+4, uintptr(0)) + if p != 0 { + Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1))) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Implementation of the geopoly_bbox(X) SQL function. +// */ +func _geopolyBBoxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var p uintptr + _ = p + p = _geopolyBBox(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0), uintptr(0)) + _ = argc + if p != 0 { + Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1))) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Implementation of the geopoly_blob(X) function. +// ** +// ** If the input is a well-formed Geopoly BLOB or JSON string +// ** then return the BLOB representation of the polygon. Otherwise +// ** return NULL. +// */ +func _geopolyBlobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var p uintptr + _ = p + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + _ = argc + if p != 0 { + Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1))) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Implementation of the geopoly_ccw(X) function. +// ** +// ** If the rotation of polygon X is clockwise (incorrect) instead of +// ** counter-clockwise (the correct winding order according to RFC7946) +// ** then reverse the order of the vertexes in polygon X. +// ** +// ** In other words, this routine returns a CCW polygon regardless of the +// ** winding order of its input. +// ** +// ** Use this routine to sanitize historical inputs that that sometimes +// ** contain polygons that wind in the wrong direction. +// */ +func _geopolyCcwFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var ii, jj int32 + var p uintptr + var t TGeoCoord + _, _, _, _ = ii, jj, p, t + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + _ = argc + if p != 0 { + if _geopolyArea(tls, p) < float64(0) { + ii = int32(1) + jj = (*TGeoPoly)(unsafe.Pointer(p)).FnVertex - libc.Int32FromInt32(1) + for { + if !(ii < jj) { + break + } + t = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4)) + **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4)) = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(jj*int32(2))*4)) + **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(jj*int32(2))*4)) = t + t = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4)) + **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4)) = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(jj*int32(2)+int32(1))*4)) + **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(jj*int32(2)+int32(1))*4)) = t + goto _1 + _1: + ; + ii = ii + 1 + jj = jj - 1 + } + } + Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1))) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** GEOPOLY virtual table module xConnect method. +// */ +func _geopolyConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + return _geopolyInit(tls, db, pAux, argc, argv, ppVtab, pzErr, 0) +} + +// C documentation +// +// /* +// ** GEOPOLY virtual table module xCreate method. +// */ +func _geopolyCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + return _geopolyInit(tls, db, pAux, argc, argv, ppVtab, pzErr, int32(1)) +} + +// C documentation +// +// /* +// ** Enable or disable debugging output +// */ +func _geopolyDebugFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + _ = context + _ = argc + _ = argv +} + +// C documentation +// +// /* +// ** Merge two lists of sorted events by X coordinate +// */ +func _geopolyEventMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pLast, v1 uintptr + var _ /* head at bp+0 */ TGeoEvent + _, _ = pLast, v1 + (**(**TGeoEvent)(__ccgo_up(bp))).FpNext = uintptr(0) + pLast = bp + for pRight != 0 && pLeft != 0 { + if (*TGeoEvent)(unsafe.Pointer(pRight)).Fx <= (*TGeoEvent)(unsafe.Pointer(pLeft)).Fx { + (*TGeoEvent)(unsafe.Pointer(pLast)).FpNext = pRight + pLast = pRight + pRight = (*TGeoEvent)(unsafe.Pointer(pRight)).FpNext + } else { + (*TGeoEvent)(unsafe.Pointer(pLast)).FpNext = pLeft + pLast = pLeft + pLeft = (*TGeoEvent)(unsafe.Pointer(pLeft)).FpNext + } + } + if pRight != 0 { + v1 = pRight + } else { + v1 = pLeft + } + (*TGeoEvent)(unsafe.Pointer(pLast)).FpNext = v1 + return (**(**TGeoEvent)(__ccgo_up(bp))).FpNext +} + +var _geopolyModule = Tsqlite3_module{ + FiVersion: int32(3), +} + +// C documentation +// +// /* +// ** Merge two lists of sorted segments by Y, and then by C. +// */ +func _geopolySegmentMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) (r1 uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pLast, v1 uintptr + var r float64 + var _ /* head at bp+0 */ TGeoSegment + _, _, _ = pLast, r, v1 + (**(**TGeoSegment)(__ccgo_up(bp))).FpNext = uintptr(0) + pLast = bp + for pRight != 0 && pLeft != 0 { + r = (*TGeoSegment)(unsafe.Pointer(pRight)).Fy - (*TGeoSegment)(unsafe.Pointer(pLeft)).Fy + if r == float64(0) { + r = (*TGeoSegment)(unsafe.Pointer(pRight)).FC - (*TGeoSegment)(unsafe.Pointer(pLeft)).FC + } + if r < float64(0) { + (*TGeoSegment)(unsafe.Pointer(pLast)).FpNext = pRight + pLast = pRight + pRight = (*TGeoSegment)(unsafe.Pointer(pRight)).FpNext + } else { + (*TGeoSegment)(unsafe.Pointer(pLast)).FpNext = pLeft + pLast = pLeft + pLeft = (*TGeoSegment)(unsafe.Pointer(pLeft)).FpNext + } + } + if pRight != 0 { + v1 = pRight + } else { + v1 = pLeft + } + (*TGeoSegment)(unsafe.Pointer(pLast)).FpNext = v1 + return (**(**TGeoSegment)(__ccgo_up(bp))).FpNext +} + +// C documentation +// +// /* +// ** Sort a list of GeoSegments in order of increasing Y and in the event of +// ** a tie, increasing C (slope). +// */ +func _geopolySortSegmentsByYAndC(tls *libc.TLS, pList uintptr) (r uintptr) { + var a [50]uintptr + var i, mx int32 + var p uintptr + _, _, _, _ = a, i, mx, p + mx = 0 + for pList != 0 { + p = pList + pList = (*TGeoSegment)(unsafe.Pointer(pList)).FpNext + (*TGeoSegment)(unsafe.Pointer(p)).FpNext = uintptr(0) + i = 0 + for { + if !(i < mx && a[i] != 0) { + break + } + p = _geopolySegmentMerge(tls, a[i], p) + a[i] = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + a[i] = p + if i >= mx { + mx = i + int32(1) + } + } + p = uintptr(0) + i = 0 + for { + if !(i < mx) { + break + } + p = _geopolySegmentMerge(tls, a[i], p) + goto _2 + _2: + ; + i = i + 1 + } + return p +} + +// C documentation +// +// /* Do a 4-byte byte swap */ +func _geopolySwab32(tls *libc.TLS, a uintptr) { + var t uint8 + _ = t + t = **(**uint8)(__ccgo_up(a)) + **(**uint8)(__ccgo_up(a)) = **(**uint8)(__ccgo_up(a + 3)) + **(**uint8)(__ccgo_up(a + 3)) = t + t = **(**uint8)(__ccgo_up(a + 1)) + **(**uint8)(__ccgo_up(a + 1)) = **(**uint8)(__ccgo_up(a + 2)) + **(**uint8)(__ccgo_up(a + 2)) = t +} + +var _getCacheSize = [9]TVdbeOpList{ + 0: { + Fopcode: uint8(OP_Transaction), + }, + 1: { + Fopcode: uint8(OP_ReadCookie), + Fp2: int8(1), + Fp3: int8(BTREE_DEFAULT_CACHE_SIZE), + }, + 2: { + Fopcode: uint8(OP_IfPos), + Fp1: int8(1), + Fp2: int8(8), + }, + 3: { + Fopcode: uint8(OP_Integer), + Fp2: int8(2), + }, + 4: { + Fopcode: uint8(OP_Subtract), + Fp1: int8(1), + Fp2: int8(2), + Fp3: int8(1), + }, + 5: { + Fopcode: uint8(OP_IfPos), + Fp1: int8(1), + Fp2: int8(8), + }, + 6: { + Fopcode: uint8(OP_Integer), + Fp2: int8(1), + }, + 7: { + Fopcode: uint8(OP_Noop), + }, + 8: { + Fopcode: uint8(OP_ResultRow), + Fp1: int8(1), + Fp2: int8(1), + }, +} + +// C documentation +// +// /* +// ** Argument z points into the body of a constraint - specifically the +// ** second token of the constraint definition. For a named constraint, +// ** z points to the first token past the CONSTRAINT keyword. For an +// ** unnamed NOT NULL constraint, z points to the first byte past the NOT +// ** keyword. +// ** +// ** Return the number of bytes until the end of the constraint. +// */ +func _getConstraint(tls *libc.TLS, z uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iOff, n int32 + var _ /* t at bp+0 */ int32 + _, _ = iOff, n + iOff = 0 + **(**int32)(__ccgo_up(bp)) = 0 + /* Now, the current constraint proceeds until the next occurence of one + ** of the following tokens: + ** + ** CONSTRAINT, PRIMARY, NOT, UNIQUE, CHECK, DEFAULT, + ** COLLATE, REFERENCES, FOREIGN, GENERATED, AS, RP, or COMMA + ** + ** Also exit the loop if ILLEGAL turns up. + */ + for int32(1) != 0 { + n = _getConstraintToken(tls, z+uintptr(iOff), bp) + if **(**int32)(__ccgo_up(bp)) == int32(TK_CONSTRAINT) || **(**int32)(__ccgo_up(bp)) == int32(TK_PRIMARY) || **(**int32)(__ccgo_up(bp)) == int32(TK_NOT) || **(**int32)(__ccgo_up(bp)) == int32(TK_UNIQUE) || **(**int32)(__ccgo_up(bp)) == int32(TK_CHECK) || **(**int32)(__ccgo_up(bp)) == int32(TK_DEFAULT) || **(**int32)(__ccgo_up(bp)) == int32(TK_COLLATE) || **(**int32)(__ccgo_up(bp)) == int32(TK_REFERENCES) || **(**int32)(__ccgo_up(bp)) == int32(TK_FOREIGN) || **(**int32)(__ccgo_up(bp)) == int32(TK_RP) || **(**int32)(__ccgo_up(bp)) == int32(TK_COMMA) || **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) || **(**int32)(__ccgo_up(bp)) == int32(TK_AS) || **(**int32)(__ccgo_up(bp)) == int32(TK_GENERATED) { + break + } + iOff = iOff + n + } + return iOff +} + +// C documentation +// +// /* +// ** Return the number of bytes until the end of the next non-whitespace and +// ** non-comment token. For the purpose of this function, a "(" token includes +// ** all of the bytes through and including the matching ")", or until the +// ** first illegal token, whichever comes first. +// ** +// ** Write the token type into *piToken. +// ** +// ** The value returned is the number of bytes in the token itself plus +// ** the number of bytes of leading whitespace and comments skipped plus +// ** all bytes through the next matching ")" if the token is TK_LP. +// ** +// ** Example: (Note: '.' used in place of '*' in the example z[] text) +// ** +// ** ,--------- *piToken := TK_RP +// ** v +// ** z[] = " /.comment./ --comment\n (two three four) five" +// ** | | +// ** |<-------------------------------------->| +// ** | +// ** `--- return value +// */ +func _getConstraintToken(tls *libc.TLS, z uintptr, piToken uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iOff, nNest int32 + var _ /* t at bp+0 */ int32 + _, _ = iOff, nNest + iOff = 0 + **(**int32)(__ccgo_up(bp)) = 0 + for cond := true; cond; cond = **(**int32)(__ccgo_up(bp)) == int32(TK_SPACE) || **(**int32)(__ccgo_up(bp)) == int32(TK_COMMENT) { + iOff = int32(int64(iOff) + _sqlite3GetToken(tls, z+uintptr(iOff), bp)) + } + **(**int32)(__ccgo_up(piToken)) = **(**int32)(__ccgo_up(bp)) + if **(**int32)(__ccgo_up(bp)) == int32(TK_LP) { + nNest = int32(1) + for nNest > 0 { + iOff = int32(int64(iOff) + _sqlite3GetToken(tls, z+uintptr(iOff), bp)) + if **(**int32)(__ccgo_up(bp)) == int32(TK_LP) { + nNest = nNest + 1 + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_RP) { + **(**int32)(__ccgo_up(bp)) = int32(TK_LP) + nNest = nNest - 1 + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) { + break + } + } + } + } + } + **(**int32)(__ccgo_up(piToken)) = **(**int32)(__ccgo_up(bp)) + return iOff +} + +// C documentation +// +// /* +// ** The second argument to this function contains the text of an SQL statement +// ** that returns a single integer value. The statement is compiled and executed +// ** using database connection db. If successful, the integer value returned +// ** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error +// ** code is returned and the value of *piVal after returning is not defined. +// */ +func _getIntFromStmt(tls *libc.TLS, db uintptr, zSql uintptr, piVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pStmt at bp+0 */ uintptr + _ = rc + rc = int32(SQLITE_NOMEM) + if zSql != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + if rc == SQLITE_OK { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + **(**int32)(__ccgo_up(piVal)) = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + return rc +} + +// C documentation +// +// /* The page getter method for when the pager is an error state */ +func _getPageError(tls *libc.TLS, pPager uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) { + _ = pgno + _ = flags + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return (*TPager)(unsafe.Pointer(pPager)).FerrCode +} + +// C documentation +// +// /* +// ** Return a pointer to a TriggerPrg object containing the sub-program for +// ** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such +// ** TriggerPrg object exists, a new object is allocated and populated before +// ** being returned. +// */ +func _getRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintptr, orconf int32) (r uintptr) { + var pPrg, pRoot, v1 uintptr + _, _, _ = pPrg, pRoot, v1 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + pRoot = v1 + /* It may be that this trigger has already been coded (or is in the + ** process of being coded). If this is the case, then an entry with + ** a matching TriggerPrg.pTrigger field will be present somewhere + ** in the Parse.pTriggerPrg list. Search for such an entry. */ + pPrg = (*TParse)(unsafe.Pointer(pRoot)).FpTriggerPrg + for { + if !(pPrg != 0 && ((*TTriggerPrg)(unsafe.Pointer(pPrg)).FpTrigger != pTrigger || (*TTriggerPrg)(unsafe.Pointer(pPrg)).Forconf != orconf)) { + break + } + goto _2 + _2: + ; + pPrg = (*TTriggerPrg)(unsafe.Pointer(pPrg)).FpNext + } + /* If an existing TriggerPrg could not be located, create a new one. */ + if !(pPrg != 0) { + pPrg = _codeRowTrigger(tls, pParse, pTrigger, pTab, orconf) + (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FerrByteOffset = -int32(1) + } + return pPrg +} + +// C documentation +// +// /* +// ** Return the id of the next token in string (*pz). Before returning, set +// ** (*pz) to point to the byte following the parsed token. +// */ +func _getToken(tls *libc.TLS, pz uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var z uintptr + var _ /* t at bp+0 */ int32 + _ = z + z = **(**uintptr)(__ccgo_up(pz)) /* Token type to return */ + for cond := true; cond; cond = **(**int32)(__ccgo_up(bp)) == int32(TK_SPACE) || **(**int32)(__ccgo_up(bp)) == int32(TK_COMMENT) { + z = z + uintptr(_sqlite3GetToken(tls, z, bp)) + } + if **(**int32)(__ccgo_up(bp)) == int32(TK_ID) || **(**int32)(__ccgo_up(bp)) == int32(TK_STRING) || **(**int32)(__ccgo_up(bp)) == int32(TK_JOIN_KW) || **(**int32)(__ccgo_up(bp)) == int32(TK_WINDOW) || **(**int32)(__ccgo_up(bp)) == int32(TK_OVER) || _sqlite3ParserFallback(tls, **(**int32)(__ccgo_up(bp))) == int32(TK_ID) { + **(**int32)(__ccgo_up(bp)) = int32(TK_ID) + } + **(**uintptr)(__ccgo_up(pz)) = z + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Return the number of bytes of leading whitespace/comments in string z[]. +// */ +func _getWhitespace(tls *libc.TLS, z uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var n, nRet int32 + var _ /* t at bp+0 */ int32 + _, _ = n, nRet + nRet = 0 + for int32(1) != 0 { + **(**int32)(__ccgo_up(bp)) = 0 + n = int32(_sqlite3GetToken(tls, z+uintptr(nRet), bp)) + if **(**int32)(__ccgo_up(bp)) != int32(TK_SPACE) && **(**int32)(__ccgo_up(bp)) != int32(TK_COMMENT) { + break + } + nRet = nRet + n + } + return nRet +} + +var _globInfo = TcompareInfo{ + FmatchAll: uint8('*'), + FmatchOne: uint8('?'), + FmatchSet: uint8('['), +} + +func _groupConcatFinalize(tls *libc.TLS, context uintptr) { + var pGCC uintptr + _ = pGCC + pGCC = Xsqlite3_aggregate_context(tls, context, 0) + if pGCC != 0 { + _sqlite3ResultStrAccum(tls, context, pGCC) + Xsqlite3_free(tls, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths) + } +} + +// C documentation +// +// /* +// ** Slow paths for sqlite3VdbeAddOp3() and sqlite3VdbeAddOp4Int() for the +// ** unusual case when we need to increase the size of the Vdbe.aOp[] array +// ** before adding the new opcode. +// */ +func _growOp3(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32) (r int32) { + if _growOpArray(tls, p, int32(1)) != 0 { + return int32(1) + } + return _sqlite3VdbeAddOp3(tls, p, op, p1, p2, p3) +} + +// C documentation +// +// /* +// ** Return true if the SELECT statement which is known to be the recursive +// ** part of a recursive CTE still has its anchor terms attached. If the +// ** anchor terms have already been removed, then return false. +// */ +func _hasAnchor(tls *libc.TLS, p uintptr) (r int32) { + for p != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Recursive) != uint32(0) { + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + } + return libc.BoolInt32(p != uintptr(0)) +} + +// C documentation +// +// /* Return true if column number x is any of the first nCol entries of aiCol[]. +// ** This is used to determine if the column number x appears in any of the +// ** first nCol entries of an index. +// */ +func _hasColumn(tls *libc.TLS, aiCol uintptr, nCol int32, x int32) (r int32) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + for { + v1 = nCol + nCol = nCol - 1 + if !(v1 > 0) { + break + } + v2 = aiCol + aiCol += 2 + if x == int32(**(**Ti16)(__ccgo_up(v2))) { + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* The following three functions, heightOfExpr(), heightOfExprList() +// ** and heightOfSelect(), are used to determine the maximum height +// ** of any expression tree referenced by the structure passed as the +// ** first argument. +// ** +// ** If this maximum height is greater than the current value pointed +// ** to by pnHeight, the second parameter, then set *pnHeight to that +// ** value. +// */ +func _heightOfExpr(tls *libc.TLS, p uintptr, pnHeight uintptr) { + if p != 0 { + if (*TExpr)(unsafe.Pointer(p)).FnHeight > **(**int32)(__ccgo_up(pnHeight)) { + **(**int32)(__ccgo_up(pnHeight)) = (*TExpr)(unsafe.Pointer(p)).FnHeight + } + } +} + +func _heightOfSelect(tls *libc.TLS, pSelect uintptr, pnHeight uintptr) { + var p uintptr + _ = p + p = pSelect + for { + if !(p != 0) { + break + } + _heightOfExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpWhere, pnHeight) + _heightOfExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpHaving, pnHeight) + _heightOfExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpLimit, pnHeight) + _heightOfExprList(tls, (*TSelect)(unsafe.Pointer(p)).FpEList, pnHeight) + _heightOfExprList(tls, (*TSelect)(unsafe.Pointer(p)).FpGroupBy, pnHeight) + _heightOfExprList(tls, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, pnHeight) + goto _1 + _1: + ; + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + } +} + +type _ht = T_ht + +var _iCode = [128]uint8{ + 66: uint8(1), + 67: uint8(2), + 68: uint8(3), + 70: uint8(1), + 71: uint8(2), + 74: uint8(2), + 75: uint8(2), + 76: uint8(4), + 77: uint8(5), + 78: uint8(5), + 80: uint8(1), + 81: uint8(2), + 82: uint8(6), + 83: uint8(2), + 84: uint8(3), + 86: uint8(1), + 88: uint8(2), + 90: uint8(2), + 98: uint8(1), + 99: uint8(2), + 100: uint8(3), + 102: uint8(1), + 103: uint8(2), + 106: uint8(2), + 107: uint8(2), + 108: uint8(4), + 109: uint8(5), + 110: uint8(5), + 112: uint8(1), + 113: uint8(2), + 114: uint8(6), + 115: uint8(2), + 116: uint8(3), + 118: uint8(1), + 120: uint8(2), + 122: uint8(2), +} + +var _iExplainColNames16 = [12]Tu8{ + 1: uint8(5), + 2: uint8(12), + 3: uint8(15), + 4: uint8(18), + 5: uint8(21), + 6: uint8(24), + 7: uint8(27), + 8: uint8(35), + 9: uint8(38), + 10: uint8(45), + 11: uint8(53), +} + +var _iLength = [8]Tu8{ + 0: uint8(2), + 1: uint8(2), + 2: uint8(3), + 3: uint8(5), + 4: uint8(3), + 5: uint8(4), + 6: uint8(5), + 7: uint8(4), +} + +/* This VDBE program seeks a btree cursor to the identified + ** db/table/row entry. The reason for using a vdbe program instead + ** of writing code to use the b-tree layer directly is that the + ** vdbe program will take advantage of the various transaction, + ** locking and error handling infrastructure built into the vdbe. + ** + ** After seeking the cursor, the vdbe executes an OP_ResultRow. + ** Code external to the Vdbe then "borrows" the b-tree cursor and + ** uses it to implement the blob_read(), blob_write() and + ** blob_bytes() functions. + ** + ** The sqlite3_blob_close() function finalizes the vdbe program, + ** which closes the b-tree cursor and (possibly) commits the + ** transaction. + */ +var _iLn int32 + +var _iLn1 int32 + +/* When setting the auto_vacuum mode to either "full" or + ** "incremental", write the value of meta[6] in the database + ** file. Before writing to meta[6], check that meta[3] indicates + ** that this really is an auto-vacuum capable database. + */ +var _iLn11 int32 + +var _iLn2 int32 + +var _iLn21 int32 + +var _iLn3 int32 + +var _iOffset = [8]Tu8{ + 1: uint8(1), + 2: uint8(2), + 3: uint8(4), + 4: uint8(9), + 5: uint8(12), + 6: uint8(15), + 7: uint8(20), +} + +var _iValue = [8]Tu8{ + 0: uint8(1), + 4: uint8(1), + 5: uint8(1), + 6: uint8(3), + 7: uint8(2), +} + +// C documentation +// +// /* Return the first index on the list */ +func _indexIteratorFirst(tls *libc.TLS, pIter uintptr, pIx uintptr) (r uintptr) { + if (*TIndexIterator)(unsafe.Pointer(pIter)).FeType != 0 { + **(**int32)(__ccgo_up(pIx)) = (**(**TIndexListTerm)(__ccgo_up((*(*struct { + FnIdx int32 + FaIdx uintptr + })(unsafe.Pointer(pIter + 8))).FaIdx))).Fix + return (**(**TIndexListTerm)(__ccgo_up((*(*struct { + FnIdx int32 + FaIdx uintptr + })(unsafe.Pointer(pIter + 8))).FaIdx))).Fp + } else { + **(**int32)(__ccgo_up(pIx)) = 0 + return (*TIndexIterator)(unsafe.Pointer(pIter)).Fu.Flx.FpIdx + } + return r +} + +// C documentation +// +// /* +// ** Check to see if index pIdx is a partial index whose conditional +// ** expression might change values due to an UPDATE. Return true if +// ** the index is subject to change and false if the index is guaranteed +// ** to be unchanged. This is an optimization. False-positives are a +// ** performance degradation, but false-negatives can result in a corrupt +// ** index and incorrect answers. +// ** +// ** aXRef[j] will be non-negative if column j of the original table is +// ** being updated. chngRowid will be true if the rowid of the table is +// ** being updated. +// */ +func _indexWhereClauseMightChange(tls *libc.TLS, pIdx uintptr, aXRef uintptr, chngRowid int32) (r int32) { + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) { + return 0 + } + return _sqlite3ExprReferencesUpdatedColumn(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere, aXRef, chngRowid) +} + +// C documentation +// +// /* +// ** This routine does the work of loading query data into an array of +// ** registers so that it can be added to the sorter. +// */ +func _innerLoopLoadRow(tls *libc.TLS, pParse uintptr, pSelect uintptr, pInfo uintptr) { + _sqlite3ExprCodeExprList(tls, pParse, (*TSelect)(unsafe.Pointer(pSelect)).FpEList, (*TRowLoadInfo)(unsafe.Pointer(pInfo)).FregResult, 0, (*TRowLoadInfo)(unsafe.Pointer(pInfo)).FecelFlags) +} + +// C documentation +// +// /* Link pNew element into the hash table pH. If pEntry!=0 then also +// ** insert pNew into the pEntry hash bucket. +// */ +func _insertElement(tls *libc.TLS, pH uintptr, pEntry uintptr, pNew uintptr) { + var pHead, v1 uintptr + _, _ = pHead, v1 /* First element already in pEntry */ + if pEntry != 0 { + if (*T_ht)(unsafe.Pointer(pEntry)).Fcount != 0 { + v1 = (*T_ht)(unsafe.Pointer(pEntry)).Fchain + } else { + v1 = uintptr(0) + } + pHead = v1 + (*T_ht)(unsafe.Pointer(pEntry)).Fcount = (*T_ht)(unsafe.Pointer(pEntry)).Fcount + 1 + (*T_ht)(unsafe.Pointer(pEntry)).Fchain = pNew + } else { + pHead = uintptr(0) + } + if pHead != 0 { + (*THashElem)(unsafe.Pointer(pNew)).Fnext = pHead + (*THashElem)(unsafe.Pointer(pNew)).Fprev = (*THashElem)(unsafe.Pointer(pHead)).Fprev + if (*THashElem)(unsafe.Pointer(pHead)).Fprev != 0 { + (*THashElem)(unsafe.Pointer((*THashElem)(unsafe.Pointer(pHead)).Fprev)).Fnext = pNew + } else { + (*THash)(unsafe.Pointer(pH)).Ffirst = pNew + } + (*THashElem)(unsafe.Pointer(pHead)).Fprev = pNew + } else { + (*THashElem)(unsafe.Pointer(pNew)).Fnext = (*THash)(unsafe.Pointer(pH)).Ffirst + if (*THash)(unsafe.Pointer(pH)).Ffirst != 0 { + (*THashElem)(unsafe.Pointer((*THash)(unsafe.Pointer(pH)).Ffirst)).Fprev = pNew + } + (*THashElem)(unsafe.Pointer(pNew)).Fprev = uintptr(0) + (*THash)(unsafe.Pointer(pH)).Ffirst = pNew + } +} + +// C documentation +// +// /* +// ** Helper subroutine for PRAGMA integrity_check: +// ** +// ** Generate code to output a single-column result row with a value of the +// ** string held in register 3. Decrement the result count in register 1 +// ** and halt if the maximum number of result rows have been issued. +// */ +func _integrityCheckResultRow(tls *libc.TLS, v uintptr) (r int32) { + var addr int32 + _ = addr + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(3), int32(1)) + addr = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfPos), int32(1), _sqlite3VdbeCurrentAddr(tls, v)+int32(2), int32(1)) + _sqlite3VdbeAddOp0(tls, v, int32(OP_Halt)) + return addr +} + +// C documentation +// +// /* +// ** Invalidate the overflow page-list cache for all cursors opened +// ** on the shared btree structure pBt. +// */ +func _invalidateAllOverflowCache(tls *libc.TLS, pBt uintptr) { + var p, v2 uintptr + _, _ = p, v2 + p = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor + for { + if !(p != 0) { + break + } + v2 = p + 1 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) & ^libc.Int32FromInt32(BTCF_ValidOvfl)) + goto _1 + _1: + ; + p = (*TBtCursor)(unsafe.Pointer(p)).FpNext + } +} + +func _invokeValueDestructor(tls *libc.TLS, p uintptr, __ccgo_fp_xDel uintptr, pCtx uintptr) (r int32) { + if __ccgo_fp_xDel == uintptr(0) { + /* noop */ + } else { + if __ccgo_fp_xDel == uintptr(-libc.Int32FromInt32(1)) { + /* noop */ + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, p) + } + } + Xsqlite3_result_error_toobig(tls, pCtx) + return int32(SQLITE_TOOBIG) +} + +// C documentation +// +// /* +// ** Argument rc is an SQLite error code. Return true if this error is +// ** considered fatal if encountered during a backup operation. All errors +// ** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED. +// */ +func _isFatalError(tls *libc.TLS, rc int32) (r int32) { + return libc.BoolInt32(rc != SQLITE_OK && rc != int32(SQLITE_BUSY) && rc != int32(SQLITE_LOCKED)) +} + +// C documentation +// +// /* +// ** This function determines whether or not the atomic-write or +// ** atomic-batch-write optimizations can be used with this pager. The +// ** atomic-write optimization can be used if: +// ** +// ** (a) the value returned by OsDeviceCharacteristics() indicates that +// ** a database page may be written atomically, and +// ** (b) the value returned by OsSectorSize() is less than or equal +// ** to the page size. +// ** +// ** If it can be used, then the value returned is the size of the journal +// ** file when it contains rollback data for exactly one page. +// ** +// ** The atomic-batch-write optimization can be used if OsDeviceCharacteristics() +// ** returns a value with the SQLITE_IOCAP_BATCH_ATOMIC bit set. -1 is +// ** returned in this case. +// ** +// ** If neither optimization can be used, 0 is returned. +// */ +func _jrnlBufferSize(tls *libc.TLS, pPager uintptr) (r int32) { + _ = pPager + return 0 +} + +/* +** If SQLITE_CHECK_PAGES is defined then we do some sanity checking +** on the cache using a hash function. This is used for testing +** and debugging only. + */ + +func _jsonArrayFinal(tls *libc.TLS, ctx uintptr) { + _jsonArrayCompute(tls, ctx, int32(1)) +} + +func _jsonArrayValue(tls *libc.TLS, ctx uintptr) { + _jsonArrayCompute(tls, ctx, 0) +} + +// C documentation +// +// /* +// ** Expand pParse->aBlob so that it holds at least N bytes. +// ** +// ** Return the number of errors. +// */ +func _jsonBlobExpand(tls *libc.TLS, pParse uintptr, N Tu32) (r int32) { + var aNew uintptr + var t Tu64 + _, _ = aNew, t + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc == uint32(0) { + t = uint64(100) + } else { + t = uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc * uint32(2)) + } + if t < uint64(N) { + t = uint64(N + uint32(100)) + } + aNew = _sqlite3DbRealloc(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob, t) + if aNew == uintptr(0) { + (*TJsonParse)(unsafe.Pointer(pParse)).Foom = uint8(1) + return int32(1) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = aNew + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc = uint32(t) + return 0 +} + +func _jsonBlobExpandAndAppendNode(tls *libc.TLS, pParse uintptr, eType Tu8, szPayload Tu64, aPayload uintptr) { + if _jsonBlobExpand(tls, pParse, uint32(uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)+szPayload+uint64(9))) != 0 { + return + } + _jsonBlobAppendNode(tls, pParse, eType, szPayload, aPayload) +} + +func _jsonCacheDeleteGeneric(tls *libc.TLS, p uintptr) { + _jsonCacheDelete(tls, p) +} + +// C documentation +// +// /* Destructor for a jsonEachCursor object */ +func _jsonEachClose(tls *libc.TLS, cur uintptr) (r int32) { + var p uintptr + _ = p + p = cur + _jsonEachCursorReset(tls, p) + _sqlite3DbFree(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb, cur) + return SQLITE_OK +} + +// C documentation +// +// /* destructor for json_each virtual table */ +func _jsonEachDisconnect(tls *libc.TLS, pVtab uintptr) (r int32) { + var p uintptr + _ = p + p = pVtab + _sqlite3DbFree(tls, (*TJsonEachConnection)(unsafe.Pointer(p)).Fdb, pVtab) + return SQLITE_OK +} + +// C documentation +// +// /* Return TRUE if the jsonEachCursor object has been advanced off the end +// ** of the JSON object */ +func _jsonEachEof(tls *libc.TLS, cur uintptr) (r int32) { + var p uintptr + _ = p + p = cur + return libc.BoolInt32((*TJsonEachCursor)(unsafe.Pointer(p)).Fi >= (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd) +} + +// C documentation +// +// /* The methods of the json_each virtual table */ +var _jsonEachModule = Tsqlite3_module{} + +// C documentation +// +// /* +// ** Return true if z[] begins with 4 (or more) hexadecimal digits +// */ +func _jsonIs4Hex(tls *libc.TLS, z uintptr) (r int32) { + return libc.BoolInt32(_jsonIs2Hex(tls, z) != 0 && _jsonIs2Hex(tls, z+2) != 0) +} + +func _jsonObjectFinal(tls *libc.TLS, ctx uintptr) { + _jsonObjectCompute(tls, ctx, int32(1)) +} + +func _jsonObjectValue(tls *libc.TLS, ctx uintptr) { + _jsonObjectCompute(tls, ctx, 0) +} + +// C documentation +// +// /* +// ** Decrement the reference count on the JsonParse object. When the +// ** count reaches zero, free the object. +// */ +func _jsonParseFree(tls *libc.TLS, pParse uintptr) { + if pParse != 0 { + if (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef > uint32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef = (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef - 1 + } else { + _jsonParseReset(tls, pParse) + _sqlite3DbFree(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, pParse) + } + } +} + +/************************************************************************** +** Utility routines for the JSON text parser +**************************************************************************/ + +// C documentation +// +// /* +// ** Reclaim all memory allocated by a JsonParse object. But do not +// ** delete the JsonParse object itself. +// */ +func _jsonParseReset(tls *libc.TLS, pParse uintptr) { + if (*TJsonParse)(unsafe.Pointer(pParse)).FbJsonIsRCStr != 0 { + _sqlite3RCStrUnref(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FzJson) + (*TJsonParse)(unsafe.Pointer(pParse)).FzJson = uintptr(0) + (*TJsonParse)(unsafe.Pointer(pParse)).FnJson = 0 + (*TJsonParse)(unsafe.Pointer(pParse)).FbJsonIsRCStr = uint8(0) + } + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc != 0 { + _sqlite3DbFree(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob) + (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = uintptr(0) + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = uint32(0) + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc = uint32(0) + } +} + +// C documentation +// +// /* Append indentation to the pretty JSON under construction */ +func _jsonPrettyIndent(tls *libc.TLS, pPretty uintptr) { + var jj Tu32 + _ = jj + jj = uint32(0) + for { + if !(jj < (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent) { + break + } + _jsonAppendRaw(tls, (*TJsonPretty)(unsafe.Pointer(pPretty)).FpOut, (*TJsonPretty)(unsafe.Pointer(pPretty)).FzIndent, (*TJsonPretty)(unsafe.Pointer(pPretty)).FszIndent) + goto _1 + _1: + ; + jj = jj + 1 + } +} + +// C documentation +// +// /* Initialize the JsonString object +// */ +func _jsonStringInit(tls *libc.TLS, p uintptr, pCtx uintptr) { + (*TJsonString)(unsafe.Pointer(p)).FpCtx = pCtx + (*TJsonString)(unsafe.Pointer(p)).FeErr = uint8(0) + _jsonStringZero(tls, p) +} + +// C documentation +// +// /* Free all allocated memory and reset the JsonString object back to its +// ** initial state. +// */ +func _jsonStringReset(tls *libc.TLS, p uintptr) { + if !((*TJsonString)(unsafe.Pointer(p)).FbStatic != 0) { + _sqlite3RCStrUnref(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf) + } + _jsonStringZero(tls, p) +} + +// C documentation +// +// /* +// ** Given that a JSONB_ARRAY object starts at offset i, return +// ** the number of entries in that array. +// */ +func _jsonbArrayCount(tls *libc.TLS, pParse uintptr, iRoot Tu32) (r Tu32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iEnd, k, n Tu32 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _ = i, iEnd, k, n + k = uint32(0) + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + iEnd = iRoot + n + **(**Tu32)(__ccgo_up(bp)) + i = iRoot + n + for { + if !(n > uint32(0) && i < iEnd) { + break + } + n = _jsonbPayloadSize(tls, pParse, i, bp) + goto _1 + _1: + ; + i = i + (**(**Tu32)(__ccgo_up(bp)) + n) + k = k + 1 + } + return k +} + +// C documentation +// +// /* +// ** julianday( TIMESTRING, MOD, MOD, ...) +// ** +// ** Return the julian day number of the date specified in the arguments +// */ +func _juliandayFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* x at bp+0 */ TDateTime + if _isDate(tls, context, argc, argv, bp) == 0 { + _computeJD(tls, bp) + Xsqlite3_result_double(tls, context, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD)/float64(8.64e+07)) + } +} + +// C documentation +// +// /* +// ** Initialize the Kahan-Babaska-Neumaier sum from a 64-bit integer +// */ +func _kahanBabuskaNeumaierInit(tls *libc.TLS, p uintptr, iVal Ti64) { + var iSm Ti64 + _ = iSm + if iVal <= -int64(4503599627370496) || iVal >= +libc.Int64FromInt64(4503599627370496) { + iSm = iVal % int64(16384) + (*TSumCtx)(unsafe.Pointer(p)).FrSum = float64(iVal - iSm) + (*TSumCtx)(unsafe.Pointer(p)).FrErr = float64(iSm) + } else { + (*TSumCtx)(unsafe.Pointer(p)).FrSum = float64(iVal) + (*TSumCtx)(unsafe.Pointer(p)).FrErr = float64(0) + } +} + +// C documentation +// +// /* +// ** Do one step of the Kahan-Babushka-Neumaier summation. +// ** +// ** https://en.wikipedia.org/wiki/Kahan_summation_algorithm +// ** +// ** Variables are marked "volatile" to defeat c89 x86 floating point +// ** optimizations can mess up this algorithm. +// */ +func _kahanBabuskaNeumaierStep(tls *libc.TLS, pSum uintptr, r float64) { + var s, t float64 + _, _ = s, t + s = (*TSumCtx)(unsafe.Pointer(pSum)).FrSum + t = s + r + if libc.Xfabs(tls, s) > libc.Xfabs(tls, r) { + **(**float64)(__ccgo_up(pSum + 8)) += s - t + r + } else { + **(**float64)(__ccgo_up(pSum + 8)) += r - t + s + } + (*TSumCtx)(unsafe.Pointer(pSum)).FrSum = t +} + +// C documentation +// +// /* +// ** Add a (possibly large) integer to the running sum. +// */ +func _kahanBabuskaNeumaierStepInt64(tls *libc.TLS, pSum uintptr, iVal Ti64) { + var iBig, iSm Ti64 + _, _ = iBig, iSm + if iVal <= -int64(4503599627370496) || iVal >= +libc.Int64FromInt64(4503599627370496) { + iSm = iVal % int64(16384) + iBig = iVal - iSm + _kahanBabuskaNeumaierStep(tls, pSum, float64(iBig)) + _kahanBabuskaNeumaierStep(tls, pSum, float64(iSm)) + } else { + _kahanBabuskaNeumaierStep(tls, pSum, float64(iVal)) + } +} + +// C documentation +// +// /* +// ** Implementation of the last_insert_rowid() SQL function. The return +// ** value is the same as the sqlite3_last_insert_rowid() API function. +// */ +func _last_insert_rowid(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + var db uintptr + _ = db + db = Xsqlite3_context_db_handle(tls, context) + _ = NotUsed + _ = NotUsed2 + /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a + ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface + ** function. */ + Xsqlite3_result_int64(tls, context, Xsqlite3_last_insert_rowid(tls, db)) +} + +func _last_valueValueFunc(tls *libc.TLS, pCtx uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, pCtx, 0) + if p != 0 && (*TLastValueCtx)(unsafe.Pointer(p)).FpVal != 0 { + Xsqlite3_result_value(tls, pCtx, (*TLastValueCtx)(unsafe.Pointer(p)).FpVal) + } +} + +// C documentation +// +// /* +// ** Release the STATIC_MAIN mutex. +// */ +func _leaveMutex(tls *libc.TLS) { + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN))) +} + +var _lenOne = [1]uint32{ + 0: uint32(1), +} + +// C documentation +// +// /* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator +// ** is case sensitive causing 'a' LIKE 'A' to be false */ +var _likeInfoAlt = TcompareInfo{ + FmatchAll: uint8('%'), + FmatchOne: uint8('_'), +} + +/* +** Possible error returns from patternMatch() + */ + +// C documentation +// +// /* The correct SQL-92 behavior is for the LIKE operator to ignore +// ** case. Thus 'a' LIKE 'A' would be true. */ +var _likeInfoNorm = TcompareInfo{ + FmatchAll: uint8('%'), + FmatchOne: uint8('_'), + FnoCase: uint8(1), +} + +// C documentation +// +// /* +// ** Generate code that will cause the most recent index analysis to +// ** be loaded into internal hash tables where is can be used. +// */ +func _loadAnalysis(tls *libc.TLS, pParse uintptr, iDb int32) { + var v uintptr + _ = v + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_LoadAnalysis), iDb) + } +} + +// C documentation +// +// /* +// ** Obtain the BtShared mutex associated with B-Tree handle p. Also, +// ** set BtShared.db to the database handle associated with p and the +// ** p->locked boolean to true. +// */ +func _lockBtreeMutex(tls *libc.TLS, p uintptr) { + Xsqlite3_mutex_enter(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).Fmutex) + (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).Fdb = (*TBtree)(unsafe.Pointer(p)).Fdb + (*TBtree)(unsafe.Pointer(p)).Flocked = uint8(1) +} + +var _mAnytimeConfigOption = libc.Uint64FromInt32(0) | libc.Uint64FromInt32(1)<nArg +// ** is also -1. In other words, we are searching for a function that +// ** takes a variable number of arguments. +// ** +// ** If nArg is -2 that means that we are searching for any function +// ** regardless of the number of arguments it uses, so return a positive +// ** match score for any +// ** +// ** The returned value is always between 0 and 6, as follows: +// ** +// ** 0: Not a match. +// ** 1: UTF8/16 conversion required and function takes any number of arguments. +// ** 2: UTF16 byte order change required and function takes any number of args. +// ** 3: encoding matches and function takes any number of arguments +// ** 4: UTF8/16 conversion required - argument count matches exactly +// ** 5: UTF16 byte order conversion required - argument count matches exactly +// ** 6: Perfect match: encoding and argument count match exactly. +// ** +// ** If nArg==(-2) then any function with a non-null xSFunc is +// ** a perfect match and any function with xSFunc NULL is +// ** a non-match. +// */ +func _matchQuality(tls *libc.TLS, p uintptr, nArg int32, enc Tu8) (r int32) { + var match, v1 int32 + _, _ = match, v1 + /* Wrong number of arguments means "no match" */ + if int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) != nArg { + if nArg == -int32(2) { + if (*TFuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) { + v1 = 0 + } else { + v1 = int32(FUNC_PERFECT_MATCH) + } + return v1 + } + if int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) >= 0 { + return 0 + } + /* Special p->nArg values available to built-in functions only: + ** -3 1 or more arguments required + ** -4 2 or more arguments required + */ + if int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) < -int32(2) && nArg < -int32(2)-int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) { + return 0 + } + } + /* Give a better score to a function with a specific number of arguments + ** than to function that accepts any number of arguments. */ + if int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) == nArg { + match = int32(4) + } else { + match = int32(1) + } + /* Bonus points if the text encoding matches */ + if uint32(enc) == (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_ENCMASK) { + match = match + int32(2) /* Exact encoding match */ + } else { + if uint32(enc)&(*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(2) != uint32(0) { + match = match + int32(1) /* Both are UTF16, but with different byte orders */ + } + } + return match +} + +// C documentation +// +// /* +// ** Implementation of 1-argument SQL math functions: +// ** +// ** exp(X) - Compute e to the X-th power +// */ +func _math1Func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var ans, v0 float64 + var type0 int32 + var x uintptr + _, _, _, _ = ans, type0, v0, x + type0 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) + if type0 != int32(SQLITE_INTEGER) && type0 != int32(SQLITE_FLOAT) { + return + } + v0 = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv))) + x = Xsqlite3_user_data(tls, context) + ans = (*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(&struct{ uintptr }{x})))(tls, v0) + Xsqlite3_result_double(tls, context, ans) +} + +// C documentation +// +// /* +// ** Add the size of memory allocation "p" to the count in +// ** *db->pnBytesFreed. +// */ +func _measureAllocationSize(tls *libc.TLS, db uintptr, p uintptr) { + **(**int32)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed)) += _sqlite3DbMallocSize(tls, db, p) +} + +// C documentation +// +// /* +// ** State information local to the memory allocation subsystem. +// */ +var _mem0 = TMem0Global{} + +// C documentation +// +// /* +// ** Return some kind of integer value which is the best we can do +// ** at representing the value that *pMem describes as an integer. +// ** If pMem is an integer, then the value is exact. If pMem is +// ** a floating-point then the value returned is the integer part. +// ** If pMem is a string or blob, then we make an attempt to convert +// ** it into an integer and return that. If pMem represents an +// ** an SQL-NULL value, return 0. +// ** +// ** If pMem represents a string value, its encoding might be changed. +// */ +func _memIntValue(tls *libc.TLS, pMem uintptr) (r Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* value at bp+0 */ Ti64 + **(**Ti64)(__ccgo_up(bp)) = 0 + _sqlite3Atoi64(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, bp, (*TMem)(unsafe.Pointer(pMem)).Fn, (*TMem)(unsafe.Pointer(pMem)).Fenc) + return **(**Ti64)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Test for access permissions. Return true if the requested permission +// ** is available, or false otherwise. +// ** +// ** With memdb, no files ever exist on disk. So always return false. +// */ +func _memdbAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) (r int32) { + _ = pVfs + _ = zPath + _ = flags + **(**int32)(__ccgo_up(pResOut)) = 0 + return SQLITE_OK +} + +func _memdbCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, p uintptr) (r int32) { + return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxCurrentTimeInt64})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p) +} + +// C documentation +// +// /* +// ** Return the device characteristic flags supported by an memdb-file. +// */ +func _memdbDeviceCharacteristics(tls *libc.TLS, pFile uintptr) (r int32) { + _ = pFile + return libc.Int32FromInt32(SQLITE_IOCAP_ATOMIC) | libc.Int32FromInt32(SQLITE_IOCAP_POWERSAFE_OVERWRITE) | libc.Int32FromInt32(SQLITE_IOCAP_SAFE_APPEND) | libc.Int32FromInt32(SQLITE_IOCAP_SEQUENTIAL) +} + +// C documentation +// +// /* +// ** Close the dynamic library handle pHandle. +// */ +func _memdbDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlClose})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, pHandle) +} + +// C documentation +// +// /* +// ** Populate the buffer zErrMsg (size nByte bytes) with a human readable +// ** utf-8 string describing the most recent error encountered associated +// ** with dynamic libraries. +// */ +func _memdbDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlError})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zErrMsg) +} + +// C documentation +// +// /* +// ** Open the dynamic library located at zPath and return a handle. +// */ +func _memdbDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) (r uintptr) { + return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlOpen})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath) +} + +// C documentation +// +// /* +// ** Return a pointer to the symbol zSymbol in the dynamic library pHandle. +// */ +func _memdbDlSym(tls *libc.TLS, pVfs uintptr, p uintptr, zSym uintptr) (r uintptr) { + return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlSym})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p, zSym) +} + +// C documentation +// +// /* +// ** Enter/leave the mutex on a MemStore +// */ +func _memdbEnter(tls *libc.TLS, p uintptr) { + Xsqlite3_mutex_enter(tls, (*TMemStore)(unsafe.Pointer(p)).FpMutex) +} + +// C documentation +// +// /* Fetch a page of a memory-mapped file */ +func _memdbFetch(tls *libc.TLS, pFile uintptr, iOfst Tsqlite3_int64, iAmt int32, pp uintptr) (r int32) { + var p uintptr + _ = p + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + _memdbEnter(tls, p) + if iOfst+int64(iAmt) > (*TMemStore)(unsafe.Pointer(p)).Fsz || (*TMemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_RESIZEABLE) != uint32(0) { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } else { + (*TMemStore)(unsafe.Pointer(p)).FnMmap = (*TMemStore)(unsafe.Pointer(p)).FnMmap + 1 + **(**uintptr)(__ccgo_up(pp)) = (*TMemStore)(unsafe.Pointer(p)).FaData + uintptr(iOfst) + } + _memdbLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return the current file-size of an memdb-file. +// */ +func _memdbFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) (r int32) { + var p uintptr + _ = p + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + _memdbEnter(tls, p) + **(**Tsqlite_int64)(__ccgo_up(pSize)) = (*TMemStore)(unsafe.Pointer(p)).Fsz + _memdbLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Translate a database connection pointer and schema name into a +// ** MemFile pointer. +// */ +func _memdbFromDbSchema(tls *libc.TLS, db uintptr, zSchema uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pStore uintptr + var rc int32 + var _ /* p at bp+0 */ uintptr + _, _ = pStore, rc + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = Xsqlite3_file_control(tls, db, zSchema, int32(SQLITE_FCNTL_FILE_POINTER), bp) + if rc != 0 { + return uintptr(0) + } + if (*TMemFile)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fbase.FpMethods != uintptr(unsafe.Pointer(&_memdb_io_methods)) { + return uintptr(0) + } + pStore = (*TMemFile)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpStore + _memdbEnter(tls, pStore) + if (*TMemStore)(unsafe.Pointer(pStore)).FzFName != uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + _memdbLeave(tls, pStore) + return **(**uintptr)(__ccgo_up(bp)) +} + +func _memdbGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) (r int32) { + return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxGetLastError})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, a, b) +} + +func _memdbLeave(tls *libc.TLS, p uintptr) { + Xsqlite3_mutex_leave(tls, (*TMemStore)(unsafe.Pointer(p)).FpMutex) +} + +// C documentation +// +// /* +// ** Lock an memdb-file. +// */ +func _memdbLock(tls *libc.TLS, pFile uintptr, eLock int32) (r int32) { + var p, pThis uintptr + var rc int32 + _, _, _ = p, pThis, rc + pThis = pFile + p = (*TMemFile)(unsafe.Pointer(pThis)).FpStore + rc = SQLITE_OK + if eLock <= (*TMemFile)(unsafe.Pointer(pThis)).FeLock { + return SQLITE_OK + } + _memdbEnter(tls, p) + if eLock > int32(SQLITE_LOCK_SHARED) && (*TMemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_READONLY) != 0 { + rc = int32(SQLITE_READONLY) + } else { + switch eLock { + case int32(SQLITE_LOCK_SHARED): + if (*TMemStore)(unsafe.Pointer(p)).FnWrLock > 0 { + rc = int32(SQLITE_BUSY) + } else { + (*TMemStore)(unsafe.Pointer(p)).FnRdLock = (*TMemStore)(unsafe.Pointer(p)).FnRdLock + 1 + } + case int32(SQLITE_LOCK_RESERVED): + fallthrough + case int32(SQLITE_LOCK_PENDING): + if (*TMemFile)(unsafe.Pointer(pThis)).FeLock == int32(SQLITE_LOCK_SHARED) { + if (*TMemStore)(unsafe.Pointer(p)).FnWrLock > 0 { + rc = int32(SQLITE_BUSY) + } else { + (*TMemStore)(unsafe.Pointer(p)).FnWrLock = int32(1) + } + } + default: + if (*TMemStore)(unsafe.Pointer(p)).FnRdLock > int32(1) { + rc = int32(SQLITE_BUSY) + } else { + if (*TMemFile)(unsafe.Pointer(pThis)).FeLock == int32(SQLITE_LOCK_SHARED) { + (*TMemStore)(unsafe.Pointer(p)).FnWrLock = int32(1) + } + } + break + } + } + if rc == SQLITE_OK { + (*TMemFile)(unsafe.Pointer(pThis)).FeLock = eLock + } + _memdbLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Populate the buffer pointed to by zBufOut with nByte bytes of +// ** random data. +// */ +func _memdbRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) (r int32) { + return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxRandomness})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zBufOut) +} + +// C documentation +// +// /* +// ** Sleep for nMicro microseconds. Return the number of microseconds +// ** actually slept. +// */ +func _memdbSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) (r int32) { + return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxSleep})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nMicro) +} + +// C documentation +// +// /* +// ** Sync an memdb-file. +// */ +func _memdbSync(tls *libc.TLS, pFile uintptr, flags int32) (r int32) { + _ = pFile + _ = flags + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Truncate an memdb-file. +// ** +// ** In rollback mode (which is always the case for memdb, as it does not +// ** support WAL mode) the truncate() method is only used to reduce +// ** the size of a file, never to increase the size. +// */ +func _memdbTruncate(tls *libc.TLS, pFile uintptr, size Tsqlite_int64) (r int32) { + var p uintptr + var rc int32 + _, _ = p, rc + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + rc = SQLITE_OK + _memdbEnter(tls, p) + if size > (*TMemStore)(unsafe.Pointer(p)).Fsz { + /* This can only happen with a corrupt wal mode db */ + rc = int32(SQLITE_CORRUPT) + } else { + (*TMemStore)(unsafe.Pointer(p)).Fsz = size + } + _memdbLeave(tls, p) + return rc +} + +// C documentation +// +// /* Release a memory-mapped page */ +func _memdbUnfetch(tls *libc.TLS, pFile uintptr, iOfst Tsqlite3_int64, pPage uintptr) (r int32) { + var p uintptr + _ = p + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + _ = iOfst + _ = pPage + _memdbEnter(tls, p) + (*TMemStore)(unsafe.Pointer(p)).FnMmap = (*TMemStore)(unsafe.Pointer(p)).FnMmap - 1 + _memdbLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Unlock an memdb-file. +// */ +func _memdbUnlock(tls *libc.TLS, pFile uintptr, eLock int32) (r int32) { + var p, pThis uintptr + _, _ = p, pThis + pThis = pFile + p = (*TMemFile)(unsafe.Pointer(pThis)).FpStore + if eLock >= (*TMemFile)(unsafe.Pointer(pThis)).FeLock { + return SQLITE_OK + } + _memdbEnter(tls, p) + if eLock == int32(SQLITE_LOCK_SHARED) { + if (*TMemFile)(unsafe.Pointer(pThis)).FeLock > int32(SQLITE_LOCK_SHARED) { + (*TMemStore)(unsafe.Pointer(p)).FnWrLock = (*TMemStore)(unsafe.Pointer(p)).FnWrLock - 1 + } + } else { + if (*TMemFile)(unsafe.Pointer(pThis)).FeLock > int32(SQLITE_LOCK_SHARED) { + (*TMemStore)(unsafe.Pointer(p)).FnWrLock = (*TMemStore)(unsafe.Pointer(p)).FnWrLock - 1 + } + (*TMemStore)(unsafe.Pointer(p)).FnRdLock = (*TMemStore)(unsafe.Pointer(p)).FnRdLock - 1 + } + (*TMemFile)(unsafe.Pointer(pThis)).FeLock = eLock + _memdbLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** File-scope variables for holding the memdb files that are accessible +// ** to multiple database connections in separate threads. +// ** +// ** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object. +// */ +var _memdb_g TMemFS + +var _memdb_io_methods = Tsqlite3_io_methods{ + FiVersion: int32(3), +} + +// C documentation +// +// /* +// ** Close the file. +// */ +func _memjrnlClose(tls *libc.TLS, pJfd uintptr) (r int32) { + var p uintptr + _ = p + p = pJfd + _memjrnlFreeChunks(tls, (*TMemJournal)(unsafe.Pointer(p)).FpFirst) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Query the size of the file in bytes. +// */ +func _memjrnlFileSize(tls *libc.TLS, pJfd uintptr, pSize uintptr) (r int32) { + var p uintptr + _ = p + p = pJfd + **(**Tsqlite_int64)(__ccgo_up(pSize)) = (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Free the list of FileChunk structures headed at MemJournal.pFirst. +// */ +func _memjrnlFreeChunks(tls *libc.TLS, pFirst uintptr) { + var pIter, pNext uintptr + _, _ = pIter, pNext + pIter = pFirst + for { + if !(pIter != 0) { + break + } + pNext = (*TFileChunk)(unsafe.Pointer(pIter)).FpNext + Xsqlite3_free(tls, pIter) + goto _1 + _1: + ; + pIter = pNext + } +} + +// C documentation +// +// /* +// ** Sync the file. +// ** +// ** If the real file has been created, call its xSync method. Otherwise, +// ** syncing an in-memory journal is a no-op. +// */ +func _memjrnlSync(tls *libc.TLS, pJfd uintptr, flags int32) (r int32) { + _ = pJfd + _ = flags + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Truncate the in-memory file. +// */ +func _memjrnlTruncate(tls *libc.TLS, pJfd uintptr, size Tsqlite_int64) (r int32) { + var iOff Ti64 + var p, pIter uintptr + _, _, _ = iOff, p, pIter + p = pJfd + if size < (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset { + pIter = uintptr(0) + if size == 0 { + _memjrnlFreeChunks(tls, (*TMemJournal)(unsafe.Pointer(p)).FpFirst) + (*TMemJournal)(unsafe.Pointer(p)).FpFirst = uintptr(0) + } else { + iOff = int64((*TMemJournal)(unsafe.Pointer(p)).FnChunkSize) + pIter = (*TMemJournal)(unsafe.Pointer(p)).FpFirst + for { + if !(pIter != 0 && iOff < size) { + break + } + iOff = iOff + int64((*TMemJournal)(unsafe.Pointer(p)).FnChunkSize) + goto _1 + _1: + ; + pIter = (*TFileChunk)(unsafe.Pointer(pIter)).FpNext + } + if pIter != 0 { + _memjrnlFreeChunks(tls, (*TFileChunk)(unsafe.Pointer(pIter)).FpNext) + (*TFileChunk)(unsafe.Pointer(pIter)).FpNext = uintptr(0) + } + } + (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FpChunk = pIter + (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset = size + (*TMemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = uintptr(0) + (*TMemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset = 0 + } + return SQLITE_OK +} + +func _minMaxFinalize(tls *libc.TLS, context uintptr) { + _minMaxValueFinalize(tls, context, 0) +} + +func _minMaxValue(tls *libc.TLS, context uintptr) { + _minMaxValueFinalize(tls, context, int32(1)) +} + +func _minMaxValueFinalize(tls *libc.TLS, context uintptr, bValue int32) { + var pRes uintptr + _ = pRes + pRes = Xsqlite3_aggregate_context(tls, context, 0) + if pRes != 0 { + if (*Tsqlite3_value)(unsafe.Pointer(pRes)).Fflags != 0 { + Xsqlite3_result_value(tls, context, pRes) + } + if bValue == 0 { + _sqlite3VdbeMemRelease(tls, pRes) + } + } +} + +var _misuse = [34]Tu16{ + 0: uint16('b'), + 1: uint16('a'), + 2: uint16('d'), + 3: uint16(' '), + 4: uint16('p'), + 5: uint16('a'), + 6: uint16('r'), + 7: uint16('a'), + 8: uint16('m'), + 9: uint16('e'), + 10: uint16('t'), + 11: uint16('e'), + 12: uint16('r'), + 13: uint16(' '), + 14: uint16('o'), + 15: uint16('r'), + 16: uint16(' '), + 17: uint16('o'), + 18: uint16('t'), + 19: uint16('h'), + 20: uint16('e'), + 21: uint16('r'), + 22: uint16(' '), + 23: uint16('A'), + 24: uint16('P'), + 25: uint16('I'), + 26: uint16(' '), + 27: uint16('m'), + 28: uint16('i'), + 29: uint16('s'), + 30: uint16('u'), + 31: uint16('s'), + 32: uint16('e'), +} + +// C documentation +// +// /* +// ** Another built-in collating sequence: NOCASE. +// ** +// ** This collating sequence is intended to be used for "case independent +// ** comparison". SQLite's knowledge of upper and lower case equivalents +// ** extends only to the 26 characters used in the English language. +// ** +// ** At the moment there is only a UTF-8 implementation. +// */ +func _nocaseCollatingFunc(tls *libc.TLS, NotUsed uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) (r1 int32) { + var r, v1 int32 + _, _ = r, v1 + if nKey1 < nKey2 { + v1 = nKey1 + } else { + v1 = nKey2 + } + r = Xsqlite3_strnicmp(tls, pKey1, pKey2, v1) + _ = NotUsed + if 0 == r { + r = nKey1 - nKey2 + } + return r +} + +// C documentation +// +// /* +// ** Clear the Rtree.pNodeBlob object +// */ +func _nodeBlobReset(tls *libc.TLS, pRtree uintptr) { + var pBlob uintptr + _ = pBlob + pBlob = (*TRtree)(unsafe.Pointer(pRtree)).FpNodeBlob + (*TRtree)(unsafe.Pointer(pRtree)).FpNodeBlob = uintptr(0) + Xsqlite3_blob_close(tls, pBlob) +} + +// C documentation +// +// /* +// ** Return the index of the cell containing a pointer to node pNode +// ** in its parent. If pNode is the root node, return -1. +// */ +func _nodeParentIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, piIndex uintptr) (r int32) { + var pParent uintptr + _ = pParent + pParent = (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent + if pParent != 0 { + return _nodeRowidIndex(tls, pRtree, pParent, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode, piIndex) + } else { + **(**int32)(__ccgo_up(piIndex)) = -int32(1) + return SQLITE_OK + } + return r +} + +// C documentation +// +// /* +// ** Increment the reference count of node p. +// */ +func _nodeReference(tls *libc.TLS, p uintptr) { + if p != 0 { + (*TRtreeNode)(unsafe.Pointer(p)).FnRef = (*TRtreeNode)(unsafe.Pointer(p)).FnRef + 1 + } +} + +// C documentation +// +// /* +// ** Release a reference to a node. If the node is dirty and the reference +// ** count drops to zero, the node data is written to the database. +// */ +func _nodeRelease(tls *libc.TLS, pRtree uintptr, pNode uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if pNode != 0 { + (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef = (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef - 1 + if (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef == 0 { + (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef = (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef - 1 + if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) { + (*TRtree)(unsafe.Pointer(pRtree)).FiDepth = -int32(1) + } + if (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent != 0 { + rc = _nodeRelease(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent) + } + if rc == SQLITE_OK { + rc = _nodeWrite(tls, pRtree, pNode) + } + _nodeHashDelete(tls, pRtree, pNode) + Xsqlite3_free(tls, pNode) + } + } + return rc +} + +// C documentation +// +// /* +// ** One of the cells in node pNode is guaranteed to have a 64-bit +// ** integer value equal to iRowid. Return the index of this cell. +// */ +func _nodeRowidIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, iRowid Ti64, piIndex uintptr) (r int32) { + var ii, nCell int32 + _, _ = ii, nCell + nCell = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) + ii = 0 + for { + if !(ii < nCell) { + break + } + if _nodeGetRowid(tls, pRtree, pNode, ii) == iRowid { + **(**int32)(__ccgo_up(piIndex)) = ii + return SQLITE_OK + } + goto _1 + _1: + ; + ii = ii + 1 + } + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< 0 { + nSize = int32((*TNtileCtx)(unsafe.Pointer(p)).FnTotal / (*TNtileCtx)(unsafe.Pointer(p)).FnParam) + if nSize == 0 { + Xsqlite3_result_int64(tls, pCtx, (*TNtileCtx)(unsafe.Pointer(p)).FiRow+int64(1)) + } else { + nLarge = (*TNtileCtx)(unsafe.Pointer(p)).FnTotal - (*TNtileCtx)(unsafe.Pointer(p)).FnParam*int64(nSize) + iSmall = nLarge * int64(nSize+libc.Int32FromInt32(1)) + iRow = (*TNtileCtx)(unsafe.Pointer(p)).FiRow + if iRow < iSmall { + Xsqlite3_result_int64(tls, pCtx, int64(1)+iRow/int64(nSize+libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_int64(tls, pCtx, int64(1)+nLarge+(iRow-iSmall)/int64(nSize)) + } + } + } +} + +var _nullElement = THashElem{} + +/* Even though the Mem structure contains an element + ** of type i64, on certain architectures (x86) with certain compiler + ** switches (-Os), gcc may align this Mem object on a 4-byte boundary + ** instead of an 8-byte one. This all works fine, except that when + ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s + ** that a Mem structure is located on an 8-byte boundary. To prevent + ** these assert()s from failing, when building with SQLITE_DEBUG defined + ** using gcc, we force nullMem to be 8-byte aligned using the magical + ** __attribute__((aligned(8))) macro. */ +var _nullMem = TMem{ + Fflags: libc.Uint16FromInt32(MEM_Null), +} + +// C documentation +// +// /* +// ** Compute the number of pages of cache requested. p->szCache is the +// ** cache size requested by the "PRAGMA cache_size" statement. +// */ +func _numberOfCachePages(tls *libc.TLS, p uintptr) (r int32) { + var n Ti64 + _ = n + if (*TPCache)(unsafe.Pointer(p)).FszCache >= 0 { + /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the + ** suggested cache size is set to N. */ + return (*TPCache)(unsafe.Pointer(p)).FszCache + } else { + /* IMPLEMENTATION-OF: R-59858-46238 If the argument N is negative, then the + ** number of cache pages is adjusted to be a number of pages that would + ** use approximately abs(N*1024) bytes of memory based on the current + ** page size. */ + n = int64(-libc.Int32FromInt32(1024)) * int64((*TPCache)(unsafe.Pointer(p)).FszCache) / int64((*TPCache)(unsafe.Pointer(p)).FszPage+(*TPCache)(unsafe.Pointer(p)).FszExtra) + if n > int64(1000000000) { + n = int64(1000000000) + } + return int32(n) + } + return r +} + +var _openBlob = [6]TVdbeOpList{ + 0: { + Fopcode: uint8(OP_TableLock), + }, + 1: { + Fopcode: uint8(OP_OpenRead), + }, + 2: { + Fopcode: uint8(OP_NotExists), + Fp2: int8(5), + Fp3: int8(1), + }, + 3: { + Fopcode: uint8(OP_Column), + Fp3: int8(1), + }, + 4: { + Fopcode: uint8(OP_ResultRow), + Fp1: int8(1), + }, + 5: { + Fopcode: uint8(OP_Halt), + }, +} + +var _ops = [2]Tu8{ + 0: uint8(TK_GE), + 1: uint8(TK_LE), +} + +/*************************************************************************** +** Routines with file scope above. Interface to the rest of the where.c +** subsystem follows. +***************************************************************************/ + +var _or_logic = [9]uint8{ + 1: uint8(1), + 2: uint8(2), + 3: uint8(1), + 4: uint8(1), + 5: uint8(1), + 6: uint8(2), + 7: uint8(1), + 8: uint8(2), +} + +// C documentation +// +// /* +// ** Return the register of pOp->p2 after first preparing it to be +// ** overwritten with an integer value. +// */ +func _out2PrereleaseWithClear(tls *libc.TLS, pOut uintptr) (r uintptr) { + _sqlite3VdbeMemSetNull(tls, pOut) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) + return pOut +} + +var _outOfMem = [14]Tu16{ + 0: uint16('o'), + 1: uint16('u'), + 2: uint16('t'), + 3: uint16(' '), + 4: uint16('o'), + 5: uint16('f'), + 6: uint16(' '), + 7: uint16('m'), + 8: uint16('e'), + 9: uint16('m'), + 10: uint16('o'), + 11: uint16('r'), + 12: uint16('y'), +} + +// C documentation +// +// /* +// ** During a rollback, when the pager reloads information into the cache +// ** so that the cache is restored to its original state at the start of +// ** the transaction, for each page restored this routine is called. +// ** +// ** This routine needs to reset the extra data section at the end of the +// ** page to agree with the restored data. +// */ +func _pageReinit(tls *libc.TLS, pData uintptr) { + var pPage uintptr + _ = pPage + pPage = _sqlite3PagerGetExtra(tls, pData) + if (*TMemPage)(unsafe.Pointer(pPage)).FisInit != 0 { + (*TMemPage)(unsafe.Pointer(pPage)).FisInit = uint8(0) + if _sqlite3PagerPageRefcount(tls, pData) > int32(1) { + /* pPage might not be a btree page; it might be an overflow page + ** or ptrmap page or a free page. In those cases, the following + ** call to btreeInitPage() will likely return SQLITE_CORRUPT. + ** But no harm is done by this. And it is very important that + ** btreeInitPage() be called on every btree page so we make + ** the call for every page that comes in for re-initializing. */ + _btreeInitPage(tls, pPage) + } + } +} + +// C documentation +// +// /* +// ** Free all PgHdr objects stored in the Pager.pMmapFreelist list. +// */ +func _pagerFreeMapHdrs(tls *libc.TLS, pPager uintptr) { + var p, pNext uintptr + _, _ = p, pNext + p = (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist + for { + if !(p != 0) { + break + } + pNext = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + Xsqlite3_free(tls, p) + goto _1 + _1: + ; + p = pNext + } +} + +// C documentation +// +// /* +// ** Open a temporary file. +// ** +// ** Write the file descriptor into *pFile. Return SQLITE_OK on success +// ** or some other error code if we fail. The OS will automatically +// ** delete the temporary file when it is closed. +// ** +// ** The flags passed to the VFS layer xOpen() call are those specified +// ** by parameter vfsFlags ORed with the following: +// ** +// ** SQLITE_OPEN_READWRITE +// ** SQLITE_OPEN_CREATE +// ** SQLITE_OPEN_EXCLUSIVE +// ** SQLITE_OPEN_DELETEONCLOSE +// */ +func _pagerOpentemp(tls *libc.TLS, pPager uintptr, pFile uintptr, vfsFlags int32) (r int32) { + var rc int32 + _ = rc /* Return code */ + vfsFlags = vfsFlags | (libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE)) + rc = _sqlite3OsOpen(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), pFile, vfsFlags, uintptr(0)) + return rc +} + +// C documentation +// +// /* +// ** This function is called to rollback a transaction on a WAL database. +// */ +func _pagerRollbackWal(tls *libc.TLS, pPager uintptr) (r int32) { + var pList, pNext uintptr + var rc int32 + _, _, _ = pList, pNext, rc /* List of dirty pages to revert */ + /* For all pages in the cache that are currently dirty or have already + ** been written (but not committed) to the log file, do one of the + ** following: + ** + ** + Discard the cached page (if refcount==0), or + ** + Reload page content from the database (if refcount>0). + */ + (*TPager)(unsafe.Pointer(pPager)).FdbSize = (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize + rc = _sqlite3WalUndo(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, __ccgo_fp(_pagerUndoCallback), pPager) + pList = _sqlite3PcacheDirtyList(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + for pList != 0 && rc == SQLITE_OK { + pNext = (*TPgHdr)(unsafe.Pointer(pList)).FpDirty + rc = _pagerUndoCallback(tls, pPager, (*TPgHdr)(unsafe.Pointer(pList)).Fpgno) + pList = pNext + } + return rc +} + +// C documentation +// +// /* +// ** This function is invoked once for each page that has already been +// ** written into the log file when a WAL transaction is rolled back. +// ** Parameter iPg is the page number of said page. The pCtx argument +// ** is actually a pointer to the Pager structure. +// ** +// ** If page iPg is present in the cache, and has no outstanding references, +// ** it is discarded. Otherwise, if there are one or more outstanding +// ** references, the page content is reloaded from the database. If the +// ** attempt to reload content from the database is required and fails, +// ** return an SQLite error code. Otherwise, SQLITE_OK. +// */ +func _pagerUndoCallback(tls *libc.TLS, pCtx uintptr, iPg TPgno) (r int32) { + var pPager, pPg uintptr + var rc int32 + _, _, _ = pPager, pPg, rc + rc = SQLITE_OK + pPager = pCtx + pPg = _sqlite3PagerLookup(tls, pPager, iPg) + if pPg != 0 { + if _sqlite3PcachePageRefcount(tls, pPg) == int64(1) { + _sqlite3PcacheDrop(tls, pPg) + } else { + rc = _readDbPage(tls, pPg) + if rc == SQLITE_OK { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TPager)(unsafe.Pointer(pPager)).FxReiniter})))(tls, pPg) + } + _sqlite3PagerUnrefNotNull(tls, pPg) + } + } + /* Normally, if a transaction is rolled back, any backup processes are + ** updated as data is copied out of the rollback journal and into the + ** database. This is not generally possible with a WAL database, as + ** rollback involves simply truncating the log file. Therefore, if one + ** or more frames have already been written to the log (and therefore + ** also copied into the backup databases) as part of this transaction, + ** the backups must be restarted. + */ + _sqlite3BackupRestart(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup) + return rc +} + +// C documentation +// +// /* +// ** If the reference count has reached zero, rollback any active +// ** transaction and unlock the pager. +// ** +// ** Except, in locking_mode=EXCLUSIVE when there is nothing to in +// ** the rollback journal, the unlock is not performed and there is +// ** nothing to rollback, so this routine is a no-op. +// */ +func _pagerUnlockIfUnused(tls *libc.TLS, pPager uintptr) { + if _sqlite3PcacheRefCount(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) == 0 { + /* because page1 is never memory mapped */ + _pagerUnlockAndRollback(tls, pPager) + } +} + +// C documentation +// +// /* +// ** Parameter aData must point to a buffer of pPager->pageSize bytes +// ** of data. Compute and return a checksum based on the contents of the +// ** page of data and the current value of pPager->cksumInit. +// ** +// ** This is not a real checksum. It is really just the sum of the +// ** random initial value (pPager->cksumInit) and every 200th byte +// ** of the page data, starting with byte offset (pPager->pageSize%200). +// ** Each byte is interpreted as an 8-bit unsigned integer. +// ** +// ** Changing the formula used to compute this checksum results in an +// ** incompatible journal file format. +// ** +// ** If journal corruption occurs due to a power failure, the most likely +// ** scenario is that one end or the other of the record will be changed. +// ** It is much less likely that the two ends of the journal record will be +// ** correct and the middle be corrupt. Thus, this "checksum" scheme, +// ** though fast and simple, catches the mostly likely kind of corruption. +// */ +func _pager_cksum(tls *libc.TLS, pPager uintptr, aData uintptr) (r Tu32) { + var cksum Tu32 + var i int32 + _, _ = cksum, i + cksum = (*TPager)(unsafe.Pointer(pPager)).FcksumInit /* Checksum value to return */ + i = int32((*TPager)(unsafe.Pointer(pPager)).FpageSize - int64(200)) /* Loop counter */ + for i > 0 { + cksum = cksum + uint32(**(**Tu8)(__ccgo_up(aData + uintptr(i)))) + i = i - int32(200) + } + return cksum +} + +// C documentation +// +// /* +// ** This function is called whenever an IOERR or FULL error that requires +// ** the pager to transition into the ERROR state may have occurred. +// ** The first argument is a pointer to the pager structure, the second +// ** the error-code about to be returned by a pager API function. The +// ** value returned is a copy of the second argument to this function. +// ** +// ** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the +// ** IOERR sub-codes, the pager enters the ERROR state and the error code +// ** is stored in Pager.errCode. While the pager remains in the ERROR state, +// ** all major API calls on the Pager will immediately return Pager.errCode. +// ** +// ** The ERROR state indicates that the contents of the pager-cache +// ** cannot be trusted. This state can be cleared by completely discarding +// ** the contents of the pager-cache. If a transaction was active when +// ** the persistent error occurred, then the rollback journal may need +// ** to be replayed to restore the contents of the database file (as if +// ** it were a hot-journal). +// */ +func _pager_error(tls *libc.TLS, pPager uintptr, rc int32) (r int32) { + var rc2 int32 + _ = rc2 + rc2 = rc & int32(0xff) + if rc2 == int32(SQLITE_FULL) || rc2 == int32(SQLITE_IOERR) { + (*TPager)(unsafe.Pointer(pPager)).FerrCode = rc + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_ERROR) + _setGetterMethod(tls, pPager) + } + return rc +} + +// C documentation +// +// /* +// ** Discard the entire contents of the in-memory page-cache. +// */ +func _pager_reset(tls *libc.TLS, pPager uintptr) { + (*TPager)(unsafe.Pointer(pPager)).FiDataVersion = (*TPager)(unsafe.Pointer(pPager)).FiDataVersion + 1 + _sqlite3BackupRestart(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup) + _sqlite3PcacheClear(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) +} + +// C documentation +// +// /* +// ** Try to obtain a lock of type locktype on the database file. If +// ** a similar or greater lock is already held, this function is a no-op +// ** (returning SQLITE_OK immediately). +// ** +// ** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke +// ** the busy callback if the lock is currently not available. Repeat +// ** until the busy callback returns false or until the attempt to +// ** obtain the lock succeeds. +// ** +// ** Return SQLITE_OK on success and an error code if we cannot obtain +// ** the lock. If the lock is obtained successfully, set the Pager.state +// ** variable to locktype before returning. +// */ +func _pager_wait_on_lock(tls *libc.TLS, pPager uintptr, locktype int32) (r int32) { + var rc int32 + _ = rc /* Return code */ + /* Check that this is either a no-op (because the requested lock is + ** already held), or one of the transitions that the busy-handler + ** may be invoked during, according to the comment above + ** sqlite3PagerSetBusyhandler(). + */ + for cond := true; cond; cond = rc == int32(SQLITE_BUSY) && (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPager)(unsafe.Pointer(pPager)).FxBusyHandler})))(tls, (*TPager)(unsafe.Pointer(pPager)).FpBusyHandlerArg) != 0 { + rc = _pagerLockDb(tls, pPager, locktype) + } + return rc +} + +/* +** Function assertTruncateConstraint(pPager) checks that one of the +** following is true for all dirty pages currently in the page-cache: +** +** a) The page number is less than or equal to the size of the +** current database image, in pages, OR +** +** b) if the page content were written at this time, it would not +** be necessary to write the current content out to the sub-journal. +** +** If the condition asserted by this function were not true, and the +** dirty page were to be discarded from the cache via the pagerStress() +** routine, pagerStress() would not write the current page content to +** the database file. If a savepoint transaction were rolled back after +** this happened, the correct behavior would be to restore the current +** content of the page. However, since this content is not present in either +** the database file or the portion of the rollback journal and +** sub-journal rolled back the content could not be restored and the +** database image would become corrupt. It is therefore fortunate that +** this circumstance cannot arise. + */ + +// C documentation +// +// /* +// ** Write mapping (iNode->iPar) to the _parent table. +// */ +func _parentWrite(tls *libc.TLS, pRtree uintptr, iNode Tsqlite3_int64, iPar Tsqlite3_int64) (r int32) { + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent, int32(1), iNode) + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent, int32(2), iPar) + Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent) + return Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent) +} + +func _parserStackFree(tls *libc.TLS, pOld uintptr, pParse uintptr) { + _ = pParse + Xsqlite3_free(tls, pOld) +} + +func _pcache1Fetch(tls *libc.TLS, p uintptr, iKey uint32, createFlag int32) (r uintptr) { + var pCache uintptr + _ = pCache + pCache = p + if (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex != 0 { + return _pcache1FetchWithMutex(tls, p, iKey, createFlag) + } else { + return _pcache1FetchNoMutex(tls, p, iKey, createFlag) + } + return r +} + +func _pcache1FetchWithMutex(tls *libc.TLS, p uintptr, iKey uint32, createFlag int32) (r uintptr) { + var pCache, pPage uintptr + _, _ = pCache, pPage + pCache = p + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) + pPage = _pcache1FetchNoMutex(tls, p, iKey, createFlag) + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) + return pPage +} + +// C documentation +// +// /* +// ** Free a page object allocated by pcache1AllocPage(). +// */ +func _pcache1FreePage(tls *libc.TLS, p uintptr) { + var pCache uintptr + _ = pCache + pCache = (*TPgHdr1)(unsafe.Pointer(p)).FpCache + if (*TPgHdr1)(unsafe.Pointer(p)).FisBulkLocal != 0 { + (*TPgHdr1)(unsafe.Pointer(p)).FpNext = (*TPCache1)(unsafe.Pointer(pCache)).FpFree + (*TPCache1)(unsafe.Pointer(pCache)).FpFree = p + } else { + _pcache1Free(tls, (*TPgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf) + } + **(**uint32)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FpnPurgeable)) = **(**uint32)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FpnPurgeable)) - 1 +} + +// C documentation +// +// /* +// ** Return the size of a pcache allocation +// */ +func _pcache1MemSize(tls *libc.TLS, p uintptr) (r int32) { + var iSize int32 + _ = iSize + if p >= _pcache1_g.FpStart && p < _pcache1_g.FpEnd { + return _pcache1_g.FszSlot + } else { + iSize = _sqlite3MallocSize(tls, p) + return iSize + } + return r +} + +// C documentation +// +// /* +// ** This function is used internally to remove the page pPage from the +// ** PGroup LRU list, if is part of it. If pPage is not part of the PGroup +// ** LRU list, then this function is a no-op. +// ** +// ** The PGroup mutex must be held when this function is called. +// */ +func _pcache1PinPage(tls *libc.TLS, pPage uintptr) (r uintptr) { + (*TPgHdr1)(unsafe.Pointer((*TPgHdr1)(unsafe.Pointer(pPage)).FpLruPrev)).FpLruNext = (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext + (*TPgHdr1)(unsafe.Pointer((*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext)).FpLruPrev = (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruPrev + (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext = uintptr(0) + /* pPage->pLruPrev = 0; + ** No need to clear pLruPrev as it is never accessed if pLruNext is 0 */ + (*TPCache1)(unsafe.Pointer((*TPgHdr1)(unsafe.Pointer(pPage)).FpCache)).FnRecyclable = (*TPCache1)(unsafe.Pointer((*TPgHdr1)(unsafe.Pointer(pPage)).FpCache)).FnRecyclable - 1 + return pPage +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xShrink method. +// ** +// ** Free up as much memory as possible. +// */ +func _pcache1Shrink(tls *libc.TLS, p uintptr) { + var pCache, pGroup uintptr + var savedMaxPage uint32 + _, _, _ = pCache, pGroup, savedMaxPage + pCache = p + if (*TPCache1)(unsafe.Pointer(pCache)).FbPurgeable != 0 { + pGroup = (*TPCache1)(unsafe.Pointer(pCache)).FpGroup + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + savedMaxPage = (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage + (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage = uint32(0) + _pcache1EnforceMaxPage(tls, pCache) + (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage = savedMaxPage + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + } +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xTruncate method. +// ** +// ** Discard all unpinned pages in the cache with a page number equal to +// ** or greater than parameter iLimit. Any pinned pages with a page number +// ** equal to or greater than iLimit are implicitly unpinned. +// */ +func _pcache1Truncate(tls *libc.TLS, p uintptr, iLimit uint32) { + var pCache uintptr + _ = pCache + pCache = p + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) + if iLimit <= (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey { + _pcache1TruncateUnsafe(tls, pCache, iLimit) + (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey = iLimit - uint32(1) + } + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) +} + +// C documentation +// +// /* +// ** Global data used by this cache. +// */ +var _pcache1_g TPCacheGlobal + +/* +** All code in this file should access the global structure above via the +** alias "pcache1". This ensures that the WSD emulation is used when +** compiling for systems that do not support real WSD. + */ + +/* +** Macros to enter and leave the PCache LRU mutex. + */ + +/******************************************************************************/ +/******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/ + +// C documentation +// +// /* +// ** Wrapper around the pluggable caches xUnpin method. If the cache is +// ** being used for an in-memory database, this function is a no-op. +// */ +func _pcacheUnpin(tls *libc.TLS, p uintptr) { + if (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FbPurgeable != 0 { + (*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxUnpin})))(tls, (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FpCache, (*TPgHdr)(unsafe.Pointer(p)).FpPage, 0) + } +} + +func _percent_rankInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + _ = nArg + _ = apArg + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + (*TCallCount)(unsafe.Pointer(p)).FnStep = (*TCallCount)(unsafe.Pointer(p)).FnStep + 1 +} + +// C documentation +// +// /* +// ** Implementation of built-in window function percent_rank(). Assumes that +// ** the window frame has been set to: +// ** +// ** GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING +// */ +func _percent_rankStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + _ = nArg + _ = apArg + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + if p != 0 { + (*TCallCount)(unsafe.Pointer(p)).FnTotal = (*TCallCount)(unsafe.Pointer(p)).FnTotal + 1 + } +} + +func _percent_rankValueFunc(tls *libc.TLS, pCtx uintptr) { + var p uintptr + var r float64 + _, _ = p, r + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + if p != 0 { + (*TCallCount)(unsafe.Pointer(p)).FnValue = (*TCallCount)(unsafe.Pointer(p)).FnStep + if (*TCallCount)(unsafe.Pointer(p)).FnTotal > int64(1) { + r = float64((*TCallCount)(unsafe.Pointer(p)).FnValue) / float64((*TCallCount)(unsafe.Pointer(p)).FnTotal-libc.Int64FromInt32(1)) + Xsqlite3_result_double(tls, pCtx, r) + } else { + Xsqlite3_result_double(tls, pCtx, float64(0)) + } + } +} + +// C documentation +// +// /* +// ** For any p between -348 and +347, return the integer part of +// ** +// ** pow(10,p) * pow(2,63-pow10to2(p)) +// ** +// ** Or, in other words, for any p in range, return the most significant +// ** 64 bits of pow(10,p). The pow(10,p) value is shifted left or right, +// ** as appropriate so the most significant 64 bits fit exactly into a +// ** 64-bit unsigned integer. +// ** +// ** Write into *pLo the next 32 significant bits of the answer after +// ** the first 64. +// ** +// ** Algorithm: +// ** +// ** (1) For p between 0 and 26, return the value directly from the aBase[] +// ** lookup table. +// ** +// ** (2) For p outside the range 0 to 26, use aScale[] for the initial value +// ** then refine that result (if necessary) by a single multiplication +// ** against aBase[]. +// ** +// ** The constant tables aBase[], aScale[], and aScaleLo[] are generated +// ** by the C program at ../tool/mkfptab.c run with the --round option. +// */ +func _powerOfTen(tls *libc.TLS, p int32, pLo uintptr) (r Tu64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var g, n int32 + var s, x Tu64 + var _ /* lo at bp+0 */ Tu32 + _, _, _, _ = g, n, s, x + if p < 0 { + if p == -int32(1) { + **(**Tu32)(__ccgo_up(pLo)) = _aScaleLo[int32(13)] + return _aScale[int32(13)] + } + g = p / int32(27) + n = p % int32(27) + if n != 0 { + g = g - 1 + n = n + int32(27) + } + } else { + if p < int32(27) { + **(**Tu32)(__ccgo_up(pLo)) = uint32(0) + return _aBase[p] + } else { + g = p / int32(27) + n = p % int32(27) + } + } + s = _aScale[g+int32(13)] + if n == 0 { + **(**Tu32)(__ccgo_up(pLo)) = _aScaleLo[g+int32(13)] + return s + } + x = _sqlite3Multiply160(tls, s, _aScaleLo[g+int32(13)], _aBase[n], bp) + if libc.Uint64FromInt32(1)<>libc.Int32FromInt32(31)&libc.Uint32FromInt32(1)) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp))<> uint64(8) + i = int32(7) + for { + if !(i >= 0) { + break + } + **(**uint8)(__ccgo_up(p + uintptr(i))) = uint8(v&libc.Uint64FromInt32(0x7f) | libc.Uint64FromInt32(0x80)) + v = v >> uint64(7) + goto _1 + _1: + ; + i = i - 1 + } + return int32(9) + } + n = 0 + for cond := true; cond; cond = v != uint64(0) { + v2 = n + n = n + 1 + (**(**[10]Tu8)(__ccgo_up(bp)))[v2] = uint8(v&libc.Uint64FromInt32(0x7f) | libc.Uint64FromInt32(0x80)) + v = v >> uint64(7) + } + v3 = bp + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & libc.Int32FromInt32(0x7f)) + i = 0 + j = n - libc.Int32FromInt32(1) + for { + if !(j >= 0) { + break + } + **(**uint8)(__ccgo_up(p + uintptr(i))) = (**(**[10]Tu8)(__ccgo_up(bp)))[j] + goto _4 + _4: + ; + j = j - 1 + i = i + 1 + } + return n +} + +// C documentation +// +// /* +// ** pow10to2(x) computes floor(log2(pow(10,x))). +// ** pow2to10(y) computes floor(log10(pow(2,y))). +// ** +// ** Conceptually, pow10to2(p) converts a base-10 exponent p into +// ** a corresponding base-2 exponent, and pow2to10(e) converts a base-2 +// ** exponent into a base-10 exponent. +// ** +// ** The conversions are based on the observation that: +// ** +// ** ln(10.0)/ln(2.0) == 108853/32768 (approximately) +// ** ln(2.0)/ln(10.0) == 78913/262144 (approximately) +// ** +// ** These ratios are approximate, but they are accurate to 5 digits, +// ** which is close enough for the usage here. Right-shift is used +// ** for division so that rounding of negative numbers happens in the +// ** right direction. +// */ +func _pwr10to2(tls *libc.TLS, p int32) (r int32) { + return p * int32(108853) >> int32(15) +} + +func _pwr2to10(tls *libc.TLS, p int32) (r int32) { + return p * int32(78913) >> int32(18) +} + +// C documentation +// +// /* +// ** Implementation of randomblob(N). Return a random blob +// ** that is N bytes long. +// */ +func _randomBlob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var n Tsqlite3_int64 + var p uintptr + _, _ = n, p + _ = argc + n = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + if n < int64(1) { + n = int64(1) + } + p = _contextMalloc(tls, context, n) + if p != 0 { + Xsqlite3_randomness(tls, int32(n), p) + Xsqlite3_result_blob(tls, context, p, int32(n), __ccgo_fp(Xsqlite3_free)) + } +} + +// C documentation +// +// /* +// ** Implementation of random(). Return a random integer. +// */ +func _randomFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* r at bp+0 */ Tsqlite_int64 + _ = NotUsed + _ = NotUsed2 + Xsqlite3_randomness(tls, int32(8), bp) + if **(**Tsqlite_int64)(__ccgo_up(bp)) < 0 { + /* We need to prevent a random number of 0x8000000000000000 + ** (or -9223372036854775808) since when you do abs() of that + ** number of you get the same value back again. To do this + ** in a way that is testable, mask the sign bit off of negative + ** values, resulting in a positive value. Then take the + ** 2s complement of that positive value. The end result can + ** therefore be no less than -9223372036854775807. + */ + **(**Tsqlite_int64)(__ccgo_up(bp)) = -(**(**Tsqlite_int64)(__ccgo_up(bp)) & (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< test.nal +// ** test.db-wal => test.wal +// ** test.db-shm => test.shm +// ** test.db-mj7f3319fa => test.9fa +// */ +func _rbuFileSuffix3(tls *libc.TLS, zBase uintptr, z uintptr) { + _ = zBase + _ = z +} + +// C documentation +// +// /* +// ** Given that zWal points to a buffer containing a wal file name passed to +// ** either the xOpen() or xAccess() VFS method, search the main-db list for +// ** a file-handle opened by the same database connection on the corresponding +// ** database file. +// ** +// ** If parameter bRbu is true, only search for file-descriptors with +// ** rbu_file.pDb!=0. +// */ +func _rbuFindMaindb(tls *libc.TLS, pRbuVfs uintptr, zWal uintptr, bRbu int32) (r uintptr) { + var pDb uintptr + _ = pDb + Xsqlite3_mutex_enter(tls, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex) + if bRbu != 0 { + pDb = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu + for { + if !(pDb != 0 && (*Trbu_file)(unsafe.Pointer(pDb)).FzWal != zWal) { + break + } + goto _1 + _1: + ; + pDb = (*Trbu_file)(unsafe.Pointer(pDb)).FpMainRbuNext + } + } else { + pDb = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain + for { + if !(pDb != 0 && (*Trbu_file)(unsafe.Pointer(pDb)).FzWal != zWal) { + break + } + goto _2 + _2: + ; + pDb = (*Trbu_file)(unsafe.Pointer(pDb)).FpMainNext + } + } + Xsqlite3_mutex_leave(tls, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex) + return pDb +} + +// C documentation +// +// /* +// ** Free an RbuState object allocated by rbuLoadState(). +// */ +func _rbuFreeState(tls *libc.TLS, p uintptr) { + if p != 0 { + Xsqlite3_free(tls, (*TRbuState)(unsafe.Pointer(p)).FzTbl) + Xsqlite3_free(tls, (*TRbuState)(unsafe.Pointer(p)).FzDataTbl) + Xsqlite3_free(tls, (*TRbuState)(unsafe.Pointer(p)).FzIdx) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Read and return an unsigned 32-bit big-endian integer from the buffer +// ** passed as the only argument. +// */ +func _rbuGetU32(tls *libc.TLS, aBuf uintptr) (r Tu32) { + return uint32(**(**Tu8)(__ccgo_up(aBuf)))<rc is already set to something other +// ** than SQLITE_OK), then this function returns NULL without modifying the +// ** stored error code. In this case it still calls sqlite3_free() on any +// ** printf() parameters associated with %z conversions. +// */ +func _rbuMPrintf(tls *libc.TLS, p uintptr, zFmt uintptr, va uintptr) (r uintptr) { + var ap Tva_list + var zSql uintptr + _, _ = ap, zSql + zSql = uintptr(0) + ap = va + zSql = Xsqlite3_vmprintf(tls, zFmt, ap) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if zSql == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } + } else { + Xsqlite3_free(tls, zSql) + zSql = uintptr(0) + } + _ = ap + return zSql +} + +// C documentation +// +// /* +// ** Add an item to the main-db lists, if it is not already present. +// ** +// ** There are two main-db lists. One for all file descriptors, and one +// ** for all file descriptors with rbu_file.pDb!=0. If the argument has +// ** rbu_file.pDb!=0, then it is assumed to already be present on the +// ** main list and is only added to the pDb!=0 list. +// */ +func _rbuMainlistAdd(tls *libc.TLS, p uintptr) { + var pIter, pRbuVfs uintptr + _, _ = pIter, pRbuVfs + pRbuVfs = (*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs + Xsqlite3_mutex_enter(tls, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex) + if (*Trbu_file)(unsafe.Pointer(p)).FpRbu == uintptr(0) { + pIter = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain + for { + if !(pIter != 0) { + break + } + goto _1 + _1: + ; + pIter = (*Trbu_file)(unsafe.Pointer(pIter)).FpMainNext + } + (*Trbu_file)(unsafe.Pointer(p)).FpMainNext = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain + (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain = p + } else { + pIter = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu + for { + if !(pIter != 0 && pIter != p) { + break + } + goto _2 + _2: + ; + pIter = (*Trbu_file)(unsafe.Pointer(pIter)).FpMainRbuNext + } + if pIter == uintptr(0) { + (*Trbu_file)(unsafe.Pointer(p)).FpMainRbuNext = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu + (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu = p + } + } + Xsqlite3_mutex_leave(tls, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex) +} + +// C documentation +// +// /* +// ** Finalize all statements and free all allocations that are specific to +// ** the current object (table/index pair). +// */ +func _rbuObjIterClearStatements(tls *libc.TLS, pIter uintptr) { + var pTmp, pUp uintptr + _, _ = pTmp, pUp + Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect) + Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpInsert) + Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpDelete) + Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTmpInsert) + pUp = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate + for pUp != 0 { + pTmp = (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext + Xsqlite3_finalize(tls, (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate) + Xsqlite3_free(tls, pUp) + pUp = pTmp + } + Xsqlite3_free(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol) + Xsqlite3_free(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpInsert = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpDelete = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTmpInsert = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol = 0 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIdxCol = 0 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = uintptr(0) +} + +// C documentation +// +// /* +// ** Write an unsigned 32-bit value in big-endian format to the supplied +// ** buffer. +// */ +func _rbuPutU32(tls *libc.TLS, aBuf uintptr, iVal Tu32) { + **(**Tu8)(__ccgo_up(aBuf)) = uint8(iVal >> libc.Int32FromInt32(24) & uint32(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 1)) = uint8(iVal >> libc.Int32FromInt32(16) & uint32(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 2)) = uint8(iVal >> libc.Int32FromInt32(8) & uint32(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 3)) = uint8(iVal >> libc.Int32FromInt32(0) & uint32(0xFF)) +} + +// C documentation +// +// /* +// ** The SELECT statement iterating through the keys for the current object +// ** (p->objiter.pSelect) currently points to a valid row. This function +// ** determines the type of operation requested by this row and returns +// ** one of the following values to indicate the result: +// ** +// ** * RBU_INSERT +// ** * RBU_DELETE +// ** * RBU_IDX_DELETE +// ** * RBU_UPDATE +// ** +// ** If RBU_UPDATE is returned, then output variable *pzMask is set to +// ** point to the text value indicating the columns to update. +// ** +// ** If the rbu_control field contains an invalid value, an error code and +// ** message are left in the RBU handle and zero returned. +// */ +func _rbuStepType(tls *libc.TLS, p uintptr, pzMask uintptr) (r int32) { + var iCol, iVal, res int32 + var z uintptr + _, _, _, _ = iCol, iVal, res, z + iCol = (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnCol /* Index of rbu_control column */ + res = 0 /* Return value */ + switch Xsqlite3_column_type(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) { + case int32(SQLITE_INTEGER): + iVal = Xsqlite3_column_int(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) + switch iVal { + case 0: + res = int32(RBU_INSERT) + case int32(1): + res = int32(RBU_DELETE) + case int32(2): + res = int32(RBU_REPLACE) + case int32(3): + res = int32(RBU_IDX_DELETE) + case int32(4): + res = int32(RBU_IDX_INSERT) + break + } + case int32(SQLITE_TEXT): + z = Xsqlite3_column_text(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) + if z == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + **(**uintptr)(__ccgo_up(pzMask)) = z + } + res = int32(RBU_UPDATE) + default: + break + } + if res == 0 { + _rbuBadControlError(tls, p) + } + return res +} + +// C documentation +// +// /* +// ** Compare strings z1 and z2, returning 0 if they are identical, or non-zero +// ** otherwise. Either or both argument may be NULL. Two NULL values are +// ** considered equal, and NULL is considered distinct from all other values. +// */ +func _rbuStrCompare(tls *libc.TLS, z1 uintptr, z2 uintptr) (r int32) { + if z1 == uintptr(0) && z2 == uintptr(0) { + return 0 + } + if z1 == uintptr(0) || z2 == uintptr(0) { + return int32(1) + } + return libc.BoolInt32(Xsqlite3_stricmp(tls, z1, z2) != 0) +} + +// C documentation +// +// /* +// ** Test for access permissions. Return true if the requested permission +// ** is available, or false otherwise. +// */ +func _rbuVfsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pDb, pRbuVfs, pRealVfs uintptr + var rc int32 + var _ /* sz at bp+0 */ Tsqlite3_int64 + _, _, _, _ = pDb, pRbuVfs, pRealVfs, rc + pRbuVfs = pVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxAccess})))(tls, pRealVfs, zPath, flags, pResOut) + /* If this call is to check if a *-wal file associated with an RBU target + ** database connection exists, and the RBU update is in RBU_STAGE_OAL, + ** the following special handling is activated: + ** + ** a) if the *-wal file does exist, return SQLITE_CANTOPEN. This + ** ensures that the RBU extension never tries to update a database + ** in wal mode, even if the first page of the database file has + ** been damaged. + ** + ** b) if the *-wal file does not exist, claim that it does anyway, + ** causing SQLite to call xOpen() to open it. This call will also + ** be intercepted (see the rbuVfsOpen() function) and the *-oal + ** file opened instead. + */ + if rc == SQLITE_OK && flags == SQLITE_ACCESS_EXISTS { + pDb = _rbuFindMaindb(tls, pRbuVfs, zPath, int32(1)) + if pDb != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == int32(RBU_STAGE_OAL) { + if **(**int32)(__ccgo_up(pResOut)) != 0 { + rc = int32(SQLITE_CANTOPEN) + } else { + **(**Tsqlite3_int64)(__ccgo_up(bp)) = 0 + rc = _rbuVfsFileSize(tls, pDb, bp) + **(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32(**(**Tsqlite3_int64)(__ccgo_up(bp)) > 0) + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Check if another file-handle holds a RESERVED lock on an rbuVfs-file. +// */ +func _rbuVfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) (r int32) { + var p uintptr + _ = p + p = pFile + return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxCheckReservedLock})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, pResOut) +} + +// C documentation +// +// /* +// ** Return the current time as a Julian Day number in *pTimeOut. +// */ +func _rbuVfsCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) (r int32) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxCurrentTime})))(tls, pRealVfs, pTimeOut) +} + +// C documentation +// +// /* +// ** Delete the file located at zPath. +// */ +func _rbuVfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) (r int32) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + return (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDelete})))(tls, pRealVfs, zPath, dirSync) +} + +// C documentation +// +// /* +// ** Return the device characteristic flags supported by an rbuVfs-file. +// */ +func _rbuVfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) (r int32) { + var p uintptr + _ = p + p = pFile + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxDeviceCharacteristics})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal) +} + +// C documentation +// +// /* +// ** Close the dynamic library handle pHandle. +// */ +func _rbuVfsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlClose})))(tls, pRealVfs, pHandle) +} + +// C documentation +// +// /* +// ** Populate the buffer zErrMsg (size nByte bytes) with a human readable +// ** utf-8 string describing the most recent error encountered associated +// ** with dynamic libraries. +// */ +func _rbuVfsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlError})))(tls, pRealVfs, nByte, zErrMsg) +} + +// C documentation +// +// /* +// ** Open the dynamic library located at zPath and return a handle. +// */ +func _rbuVfsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) (r uintptr) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlOpen})))(tls, pRealVfs, zPath) +} + +// C documentation +// +// /* +// ** Return a pointer to the symbol zSymbol in the dynamic library pHandle. +// */ +func _rbuVfsDlSym(tls *libc.TLS, pVfs uintptr, pArg uintptr, zSym uintptr) (r uintptr) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlSym})))(tls, pRealVfs, pArg, zSym) +} + +// C documentation +// +// /* +// ** Return the current file-size of an rbuVfs-file. +// */ +func _rbuVfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) (r int32) { + var p uintptr + var rc int32 + _, _ = p, rc + p = pFile + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileSize})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, pSize) + /* If this is an RBU vacuum operation and this is the target database, + ** pretend that it has at least one page. Otherwise, SQLite will not + ** check for the existence of a *-wal file. rbuVfsRead() contains + ** similar logic. */ + if rc == SQLITE_OK && **(**Tsqlite_int64)(__ccgo_up(pSize)) == 0 && (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbu)).FzTarget == uintptr(0) && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + **(**Tsqlite_int64)(__ccgo_up(pSize)) = int64(1024) + } + return rc +} + +// C documentation +// +// /* +// ** Populate buffer zOut with the full canonical pathname corresponding +// ** to the pathname in zPath. zOut is guaranteed to point to a buffer +// ** of at least (DEVSYM_MAX_PATHNAME+1) bytes. +// */ +func _rbuVfsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) (r int32) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxFullPathname})))(tls, pRealVfs, zPath, nOut, zOut) +} + +// C documentation +// +// /* +// ** No-op. +// */ +func _rbuVfsGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) (r int32) { + _ = pVfs + _ = a + _ = b + return 0 +} + +// C documentation +// +// /* +// ** Lock an rbuVfs-file. +// */ +func _rbuVfsLock(tls *libc.TLS, pFile uintptr, eLock int32) (r int32) { + var p, pRbu uintptr + var rc int32 + _, _, _ = p, pRbu, rc + p = pFile + pRbu = (*Trbu_file)(unsafe.Pointer(p)).FpRbu + rc = SQLITE_OK + if eLock == int32(SQLITE_LOCK_EXCLUSIVE) && ((*Trbu_file)(unsafe.Pointer(p)).FbNolock != 0 || pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FeStage != int32(RBU_STAGE_DONE)) { + /* Do not allow EXCLUSIVE locks. Preventing SQLite from taking this + ** prevents it from checkpointing the database from sqlite3_close(). */ + rc = int32(SQLITE_BUSY) + } else { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxLock})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, eLock) + } + return rc +} + +// C documentation +// +// /* +// ** Populate the buffer pointed to by zBufOut with nByte bytes of +// ** random data. +// */ +func _rbuVfsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) (r int32) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxRandomness})))(tls, pRealVfs, nByte, zBufOut) +} + +// C documentation +// +// /* +// ** Return the sector-size in bytes for an rbuVfs-file. +// */ +func _rbuVfsSectorSize(tls *libc.TLS, pFile uintptr) (r int32) { + var p uintptr + _ = p + p = pFile + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxSectorSize})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal) +} + +// C documentation +// +// /* +// ** Memory barrier. +// */ +func _rbuVfsShmBarrier(tls *libc.TLS, pFile uintptr) { + var p uintptr + _ = p + p = pFile + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmBarrier})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal) +} + +// C documentation +// +// /* +// ** The xShmUnmap method. +// */ +func _rbuVfsShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) (r int32) { + var eStage, rc, v1 int32 + var p uintptr + _, _, _, _ = eStage, p, rc, v1 + p = pFile + rc = SQLITE_OK + if (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 { + v1 = (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage + } else { + v1 = 0 + } + eStage = v1 + if eStage == int32(RBU_STAGE_OAL) || eStage == int32(RBU_STAGE_MOVE) { + /* no-op */ + } else { + /* Release the checkpointer and writer locks */ + _rbuUnlockShm(tls, p) + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmUnmap})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, delFlag) + } + return rc +} + +// C documentation +// +// /* +// ** Sleep for nMicro microseconds. Return the number of microseconds +// ** actually slept. +// */ +func _rbuVfsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) (r int32) { + var pRealVfs uintptr + _ = pRealVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs + return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxSleep})))(tls, pRealVfs, nMicro) +} + +// C documentation +// +// /* +// ** Sync an rbuVfs-file. +// */ +func _rbuVfsSync(tls *libc.TLS, pFile uintptr, flags int32) (r int32) { + var p uintptr + _ = p + p = pFile + if (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage == int32(RBU_STAGE_CAPTURE) { + if (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + return libc.Int32FromInt32(SQLITE_NOTICE) | libc.Int32FromInt32(3)<= (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz { + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz = int64(iAmt) + iOfst + } else { + if (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_DELETEONCLOSE) != 0 { + szNew = int64(iAmt) + iOfst + if szNew > (*Trbu_file)(unsafe.Pointer(p)).Fsz { + rc = _rbuUpdateTempSize(tls, p, szNew) + if rc != SQLITE_OK { + return rc + } + } + } + } + } + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxWrite})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) + if rc == SQLITE_OK && iOfst == 0 && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + /* These look like magic numbers. But they are stable, as they are part + ** of the definition of the SQLite file format, which may not change. */ + pBuf = zBuf + (*Trbu_file)(unsafe.Pointer(p)).FiCookie = _rbuGetU32(tls, pBuf+24) + (*Trbu_file)(unsafe.Pointer(p)).FiWriteVer = **(**Tu8)(__ccgo_up(pBuf + 19)) + } + } + return rc +} + +var _rbuvfs_io_methods = Tsqlite3_io_methods{ + FiVersion: int32(2), +} + +var _rbuvfs_io_methods1 = Tsqlite3_io_methods{ + FiVersion: int32(1), +} + +// C documentation +// +// /* +// ** Read a 32-bit integer from the given file descriptor. Store the integer +// ** that is read in *pRes. Return SQLITE_OK if everything worked, or an +// ** error code is something goes wrong. +// ** +// ** All values are stored on disk as big-endian. +// */ +func _read32bits(tls *libc.TLS, fd uintptr, offset Ti64, pRes uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* ac at bp+0 */ [4]uint8 + _ = rc + rc = _sqlite3OsRead(tls, fd, bp, int32(4), offset) + if rc == SQLITE_OK { + **(**Tu32)(__ccgo_up(pRes)) = _sqlite3Get4byte(tls, bp) + } + return rc +} + +/* +** Write a 32-bit integer into a string buffer in big-endian byte order. + */ + +/* Read the specified cookie value */ +var _readCookie = [3]TVdbeOpList{ + 0: { + Fopcode: uint8(OP_Transaction), + }, + 1: { + Fopcode: uint8(OP_ReadCookie), + Fp2: int8(1), + }, + 2: { + Fopcode: uint8(OP_ResultRow), + Fp1: int8(1), + Fp2: int8(1), + }, +} + +func _releasePage(tls *libc.TLS, pPage uintptr) { + if pPage != 0 { + _releasePageNotNull(tls, pPage) + } +} + +// C documentation +// +// /* +// ** Release a MemPage. This should be called once for each prior +// ** call to btreeGetPage. +// ** +// ** Page1 is a special case and must be released using releasePageOne(). +// */ +func _releasePageNotNull(tls *libc.TLS, pPage uintptr) { + _sqlite3PagerUnrefNotNull(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) +} + +func _releasePageOne(tls *libc.TLS, pPage uintptr) { + _sqlite3PagerUnrefPageOne(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) +} + +// C documentation +// +// /* +// ** Decrement the BtShared.nRef counter. When it reaches zero, +// ** remove the BtShared structure from the sharing list. Return +// ** true if the BtShared.nRef counter reaches zero and return +// ** false if it is still positive. +// */ +func _removeFromSharingList(tls *libc.TLS, pBt uintptr) (r int32) { + var pList, pMainMtx uintptr + var removed int32 + _, _, _ = pList, pMainMtx, removed + removed = 0 + pMainMtx = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + Xsqlite3_mutex_enter(tls, pMainMtx) + (*TBtShared)(unsafe.Pointer(pBt)).FnRef = (*TBtShared)(unsafe.Pointer(pBt)).FnRef - 1 + if (*TBtShared)(unsafe.Pointer(pBt)).FnRef <= 0 { + if _sqlite3SharedCacheList == pBt { + _sqlite3SharedCacheList = (*TBtShared)(unsafe.Pointer(pBt)).FpNext + } else { + pList = _sqlite3SharedCacheList + for pList != 0 && (*TBtShared)(unsafe.Pointer(pList)).FpNext != pBt { + pList = (*TBtShared)(unsafe.Pointer(pList)).FpNext + } + if pList != 0 { + (*TBtShared)(unsafe.Pointer(pList)).FpNext = (*TBtShared)(unsafe.Pointer(pBt)).FpNext + } + } + if int32(SQLITE_THREADSAFE) != 0 { + Xsqlite3_mutex_free(tls, (*TBtShared)(unsafe.Pointer(pBt)).Fmutex) + } + removed = int32(1) + } + Xsqlite3_mutex_leave(tls, pMainMtx) + return removed +} + +func _removeNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, iHeight int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pParent uintptr + var rc, rc2, v1 int32 + var _ /* iCell at bp+0 */ int32 + _, _, _, _ = pParent, rc, rc2, v1 + pParent = uintptr(0) + /* Remove the entry in the parent cell. */ + rc = _nodeParentIndex(tls, pRtree, pNode, bp) + if rc == SQLITE_OK { + pParent = (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent + (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent = uintptr(0) + rc = _deleteCell(tls, pRtree, pParent, **(**int32)(__ccgo_up(bp)), iHeight+int32(1)) + } + rc2 = _nodeRelease(tls, pRtree, pParent) + if rc == SQLITE_OK { + rc = rc2 + } + if rc != SQLITE_OK { + return rc + } + /* Remove the xxx_node entry. */ + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteNode, int32(1), (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode) + Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteNode) + v1 = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteNode) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + /* Remove the xxx_parent entry. */ + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteParent, int32(1), (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode) + Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteParent) + v1 = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteParent) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + /* Remove the node from the in-memory hash table and link it into + ** the Rtree.pDeleted list. Its contents will be re-inserted later on. + */ + _nodeHashDelete(tls, pRtree, pNode) + (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode = int64(iHeight) + (*TRtreeNode)(unsafe.Pointer(pNode)).FpNext = (*TRtree)(unsafe.Pointer(pRtree)).FpDeleted + (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef = (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef + 1 + (*TRtree)(unsafe.Pointer(pRtree)).FpDeleted = pNode + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Free the contents of Parse object (*pParse). Do not free the memory +// ** occupied by the Parse object itself. +// */ +func _renameParseCleanup(tls *libc.TLS, pParse uintptr) { + var db, pIdx, v1 uintptr + _, _, _ = db, pIdx, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FpVdbe != 0 { + _sqlite3VdbeFinalize(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe) + } + _sqlite3DeleteTable(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTable) + for { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpNewIndex + pIdx = v1 + if !(v1 != uintptr(0)) { + break + } + (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + _sqlite3FreeIndex(tls, db, pIdx) + } + _sqlite3DeleteTrigger(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger) + _sqlite3DbFree(tls, db, (*TParse)(unsafe.Pointer(pParse)).FzErrMsg) + _renameTokenFree(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpRename) + _sqlite3ParseObjectReset(tls, pParse) +} + +// C documentation +// +// /* +// ** Generate code to reload the schema for database iDb. And, if iDb!=1, for +// ** the temp database as well. +// */ +func _renameReloadSchema(tls *libc.TLS, pParse uintptr, iDb int32, p5 Tu16) { + var v uintptr + _ = v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if v != 0 { + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddParseSchemaOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, iDb, uintptr(0), p5) + if iDb != int32(1) { + _sqlite3VdbeAddParseSchemaOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(1), uintptr(0), p5) + } + } +} + +// C documentation +// +// /* +// ** Free the list of RenameToken objects given in the second argument +// */ +func _renameTokenFree(tls *libc.TLS, db uintptr, pToken uintptr) { + var p, pNext uintptr + _, _ = p, pNext + p = pToken + for { + if !(p != 0) { + break + } + pNext = (*TRenameToken)(unsafe.Pointer(p)).FpNext + _sqlite3DbFree(tls, db, p) + goto _1 + _1: + ; + p = pNext + } +} + +// C documentation +// +// /* +// ** Generate code to return a single integer value. +// */ +func _returnSingleInt(tls *libc.TLS, v uintptr, _value Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*Ti64)(unsafe.Pointer(bp)) = _value + _sqlite3VdbeAddOp4Dup8(tls, v, int32(OP_Int64), 0, int32(1), 0, bp, -int32(14)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) +} + +// C documentation +// +// /* +// ** Generate code to return a single text value. +// */ +func _returnSingleText(tls *libc.TLS, v uintptr, zValue uintptr) { + if zValue != 0 { + _sqlite3VdbeLoadString(tls, v, int32(1), zValue) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) + } +} + +// C documentation +// +// /* +// ** Convert a sorted list of elements into a binary tree. Make the tree +// ** as deep as it needs to be in order to contain the entire list. +// */ +func _rowSetListToTree(tls *libc.TLS, _pList uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _pList + var iDepth int32 + var p, pLeft, v1 uintptr + _, _, _, _ = iDepth, p, pLeft, v1 /* Left subtree */ + p = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight + v1 = libc.UintptrFromInt32(0) + (*TRowSetEntry)(unsafe.Pointer(p)).FpRight = v1 + (*TRowSetEntry)(unsafe.Pointer(p)).FpLeft = v1 + iDepth = int32(1) + for { + if !(**(**uintptr)(__ccgo_up(bp)) != 0) { + break + } + pLeft = p + p = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight + (*TRowSetEntry)(unsafe.Pointer(p)).FpLeft = pLeft + (*TRowSetEntry)(unsafe.Pointer(p)).FpRight = _rowSetNDeepTree(tls, bp, iDepth) + goto _2 + _2: + ; + iDepth = iDepth + 1 + } + return p +} + +// C documentation +// +// /* +// ** Convert a sorted list of elements (connected by pRight) into a binary +// ** tree with depth of iDepth. A depth of 1 means the tree contains a single +// ** node taken from the head of *ppList. A depth of 2 means a tree with +// ** three nodes. And so forth. +// ** +// ** Use as many entries from the input list as required and update the +// ** *ppList to point to the unused elements of the list. If the input +// ** list contains too few elements, then construct an incomplete tree +// ** and leave *ppList set to NULL. +// ** +// ** Return a pointer to the root of the constructed binary tree. +// */ +func _rowSetNDeepTree(tls *libc.TLS, ppList uintptr, iDepth int32) (r uintptr) { + var p, pLeft, v1 uintptr + _, _, _ = p, pLeft, v1 /* Left subtree */ + if **(**uintptr)(__ccgo_up(ppList)) == uintptr(0) { /*OPTIMIZATION-IF-TRUE*/ + /* Prevent unnecessary deep recursion when we run out of entries */ + return uintptr(0) + } + if iDepth > int32(1) { /*OPTIMIZATION-IF-TRUE*/ + /* This branch causes a *balanced* tree to be generated. A valid tree + ** is still generated without this branch, but the tree is wildly + ** unbalanced and inefficient. */ + pLeft = _rowSetNDeepTree(tls, ppList, iDepth-int32(1)) + p = **(**uintptr)(__ccgo_up(ppList)) + if p == uintptr(0) { /*OPTIMIZATION-IF-FALSE*/ + /* It is safe to always return here, but the resulting tree + ** would be unbalanced */ + return pLeft + } + (*TRowSetEntry)(unsafe.Pointer(p)).FpLeft = pLeft + **(**uintptr)(__ccgo_up(ppList)) = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight + (*TRowSetEntry)(unsafe.Pointer(p)).FpRight = _rowSetNDeepTree(tls, ppList, iDepth-int32(1)) + } else { + p = **(**uintptr)(__ccgo_up(ppList)) + **(**uintptr)(__ccgo_up(ppList)) = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight + v1 = libc.UintptrFromInt32(0) + (*TRowSetEntry)(unsafe.Pointer(p)).FpRight = v1 + (*TRowSetEntry)(unsafe.Pointer(p)).FpLeft = v1 + } + return p +} + +// C documentation +// +// /* +// ** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects. +// ** Convert this tree into a linked list connected by the pRight pointers +// ** and return pointers to the first and last elements of the new list. +// */ +func _rowSetTreeToList(tls *libc.TLS, pIn uintptr, ppFirst uintptr, ppLast uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* p at bp+0 */ uintptr + if (*TRowSetEntry)(unsafe.Pointer(pIn)).FpLeft != 0 { + _rowSetTreeToList(tls, (*TRowSetEntry)(unsafe.Pointer(pIn)).FpLeft, ppFirst, bp) + (*TRowSetEntry)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpRight = pIn + } else { + **(**uintptr)(__ccgo_up(ppFirst)) = pIn + } + if (*TRowSetEntry)(unsafe.Pointer(pIn)).FpRight != 0 { + _rowSetTreeToList(tls, (*TRowSetEntry)(unsafe.Pointer(pIn)).FpRight, pIn+8, ppLast) + } else { + **(**uintptr)(__ccgo_up(ppLast)) = pIn + } +} + +// C documentation +// +// /* +// ** Implementation of built-in window function row_number(). Assumes that the +// ** window frame has been coerced to: +// ** +// ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW +// */ +func _row_numberStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, pCtx, int32(8)) + if p != 0 { + **(**Ti64)(__ccgo_up(p)) = **(**Ti64)(__ccgo_up(p)) + 1 + } + _ = nArg + _ = apArg +} + +func _row_numberValueFunc(tls *libc.TLS, pCtx uintptr) { + var p uintptr + var v1 int64 + _, _ = p, v1 + p = Xsqlite3_aggregate_context(tls, pCtx, int32(8)) + if p != 0 { + v1 = **(**Ti64)(__ccgo_up(p)) + } else { + v1 = 0 + } + Xsqlite3_result_int64(tls, pCtx, v1) +} + +// C documentation +// +// /* +// ** Write mapping (iRowid->iNode) to the _rowid table. +// */ +func _rowidWrite(tls *libc.TLS, pRtree uintptr, iRowid Tsqlite3_int64, iNode Tsqlite3_int64) (r int32) { + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid, int32(1), iRowid) + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid, int32(2), iNode) + Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid) + return Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid) +} + +// C documentation +// +// /* +// ** Called when a transaction starts. +// */ +func _rtreeBeginTransaction(tls *libc.TLS, pVtab uintptr) (r int32) { + var pRtree uintptr + _ = pRtree + pRtree = pVtab + (*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = uint8(1) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** The second and subsequent arguments to this function are a format string +// ** and printf style arguments. This function formats the string and attempts +// ** to compile it as an SQL statement. +// ** +// ** If successful, a pointer to the new SQL statement is returned. Otherwise, +// ** NULL is returned and an error code left in RtreeCheck.rc. +// */ +func _rtreeCheckPrepare(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var ap Tva_list + var z uintptr + var _ /* pRet at bp+0 */ uintptr + _, _ = ap, z + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + ap = va + z = Xsqlite3_vmprintf(tls, zFmt, ap) + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { + if z == uintptr(0) { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM) + } else { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_prepare_v2(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).Fdb, z, -int32(1), bp, uintptr(0)) + } + } + Xsqlite3_free(tls, z) + _ = ap + return **(**uintptr)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Reset SQL statement pStmt. If the sqlite3_reset() call returns an error, +// ** and RtreeCheck.rc==SQLITE_OK, set RtreeCheck.rc to the error code. +// */ +func _rtreeCheckReset(tls *libc.TLS, pCheck uintptr, pStmt uintptr) { + var rc int32 + _ = rc + rc = Xsqlite3_reset(tls, pStmt) + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = rc + } +} + +// C documentation +// +// /* +// ** Rtree virtual table module xConnect method. +// */ +func _rtreeConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + return _rtreeInit(tls, db, pAux, argc, argv, ppVtab, pzErr, 0) +} + +// C documentation +// +// /* +// ** Rtree virtual table module xCreate method. +// */ +func _rtreeCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + return _rtreeInit(tls, db, pAux, argc, argv, ppVtab, pzErr, int32(1)) +} + +// C documentation +// +// /* +// ** Rtree virtual table module xDisconnect method. +// */ +func _rtreeDisconnect(tls *libc.TLS, pVtab uintptr) (r int32) { + _rtreeRelease(tls, pVtab) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Called when a transaction completes (either by COMMIT or ROLLBACK). +// ** The sqlite3_blob object should be released at this point. +// */ +func _rtreeEndTransaction(tls *libc.TLS, pVtab uintptr) (r int32) { + var pRtree uintptr + _ = pRtree + pRtree = pVtab + (*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = uint8(0) + _nodeBlobReset(tls, pRtree) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This routine deletes the RtreeGeomCallback object that was attached +// ** one of the SQL functions create by sqlite3_rtree_geometry_callback() +// ** or sqlite3_rtree_query_callback(). In other words, this routine is the +// ** destructor for an RtreeGeomCallback objecct. This routine is called when +// ** the corresponding SQL function is deleted. +// */ +func _rtreeFreeCallback(tls *libc.TLS, p uintptr) { + var pInfo uintptr + _ = pInfo + pInfo = p + if (*TRtreeGeomCallback)(unsafe.Pointer(pInfo)).FxDestructor != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TRtreeGeomCallback)(unsafe.Pointer(pInfo)).FxDestructor})))(tls, (*TRtreeGeomCallback)(unsafe.Pointer(pInfo)).FpContext) + } + Xsqlite3_free(tls, p) +} + +// C documentation +// +// /* +// ** Insert cell pCell into node pNode. Node pNode is the head of a +// ** subtree iHeight high (leaf nodes have iHeight==0). +// */ +func _rtreeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) (r int32) { + var pChild uintptr + var rc int32 + _, _ = pChild, rc + rc = SQLITE_OK + if iHeight > 0 { + pChild = _nodeHashLookup(tls, pRtree, (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid) + if pChild != 0 { + _nodeRelease(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pChild)).FpParent) + _nodeReference(tls, pNode) + (*TRtreeNode)(unsafe.Pointer(pChild)).FpParent = pNode + } + } + if _nodeInsertCell(tls, pRtree, pNode, pCell) != 0 { + rc = _SplitNode(tls, pRtree, pNode, pCell, iHeight) + } else { + rc = _AdjustTree(tls, pRtree, pNode, pCell) + if rc == SQLITE_OK { + if iHeight == 0 { + rc = _rowidWrite(tls, pRtree, (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode) + } else { + rc = _parentWrite(tls, pRtree, (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode) + } + } + } + return rc +} + +var _rtreeModule = Tsqlite3_module{ + FiVersion: int32(4), +} + +// C documentation +// +// /* +// ** Select a currently unused rowid for a new r-tree record. +// */ +func _rtreeNewRowid(tls *libc.TLS, pRtree uintptr, piRowid uintptr) (r int32) { + var rc int32 + _ = rc + Xsqlite3_bind_null(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid, int32(1)) + Xsqlite3_bind_null(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid, int32(2)) + Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid) + rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid) + **(**Ti64)(__ccgo_up(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb) + return rc +} + +// C documentation +// +// /* +// ** Rtree virtual table module xNext method. +// */ +func _rtreeNext(tls *libc.TLS, pVtabCursor uintptr) (r int32) { + var pCsr uintptr + var rc int32 + _, _ = pCsr, rc + pCsr = pVtabCursor + rc = SQLITE_OK + /* Move to the next entry that matches the configured constraints. */ + if (*TRtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid != 0 { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = uint8(0) + Xsqlite3_reset(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) + } + _rtreeSearchPointPop(tls, pCsr) + rc = _rtreeStepToLeaf(tls, pCsr) + return rc +} + +// C documentation +// +// /* +// ** Increment the r-tree reference count. +// */ +func _rtreeReference(tls *libc.TLS, pRtree uintptr) { + (*TRtree)(unsafe.Pointer(pRtree)).FnBusy = (*TRtree)(unsafe.Pointer(pRtree)).FnBusy + 1 +} + +func _rtreeRollback(tls *libc.TLS, pVtab uintptr) (r int32) { + return _rtreeEndTransaction(tls, pVtab) +} + +// C documentation +// +// /* +// ** The xSavepoint method. +// ** +// ** This module does not need to do anything to support savepoints. However, +// ** it uses this hook to close any open blob handle. This is done because a +// ** DROP TABLE command - which fortunately always opens a savepoint - cannot +// ** succeed if there are any open blob handles. i.e. if the blob handle were +// ** not closed here, the following would fail: +// ** +// ** BEGIN; +// ** INSERT INTO rtree... +// ** DROP TABLE ; -- Would fail with SQLITE_LOCKED +// ** COMMIT; +// */ +func _rtreeSavepoint(tls *libc.TLS, pVtab uintptr, iSavepoint int32) (r int32) { + var iwt Tu8 + var pRtree uintptr + _, _ = iwt, pRtree + pRtree = pVtab + iwt = (*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans + _ = iSavepoint + (*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = uint8(0) + _nodeBlobReset(tls, pRtree) + (*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = iwt + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return the length of a token +// */ +func _rtreeTokenLength(tls *libc.TLS, z uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* dummy at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = 0 + return int32(_sqlite3GetToken(tls, z, bp)) +} + +var _sFts5Api = TFts5ExtensionApi{ + FiVersion: int32(4), +} + +var _sMutex = Tsqlite3_mutex_methods{} + +// C documentation +// +// /* +// ** Return true if pNew is to be preferred over pOld. +// ** +// ** This function assumes that for each argument sample, the contents of +// ** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid. +// */ +func _sampleIsBetter(tls *libc.TLS, pAccum uintptr, pNew uintptr, pOld uintptr) (r int32) { + var nEqNew, nEqOld TtRowcnt + _, _ = nEqNew, nEqOld + nEqNew = **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pNew)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pNew)).FiCol)*8)) + nEqOld = **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pOld)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pOld)).FiCol)*8)) + if nEqNew > nEqOld { + return int32(1) + } + if nEqNew == nEqOld { + if (*TStatSample)(unsafe.Pointer(pNew)).FiCol < (*TStatSample)(unsafe.Pointer(pOld)).FiCol { + return int32(1) + } + return libc.BoolInt32((*TStatSample)(unsafe.Pointer(pNew)).FiCol == (*TStatSample)(unsafe.Pointer(pOld)).FiCol && _sampleIsBetterPost(tls, pAccum, pNew, pOld) != 0) + } + return 0 +} + +// C documentation +// +// /* +// ** pNew and pOld are both candidate non-periodic samples selected for +// ** the same column (pNew->iCol==pOld->iCol). Ignoring this column and +// ** considering only any trailing columns and the sample hash value, this +// ** function returns true if sample pNew is to be preferred over pOld. +// ** In other words, if we assume that the cardinalities of the selected +// ** column for pNew and pOld are equal, is pNew to be preferred over pOld. +// ** +// ** This function assumes that for each argument sample, the contents of +// ** the anEq[] array from pSample->anEq[pSample->iCol+1] onwards are valid. +// */ +func _sampleIsBetterPost(tls *libc.TLS, pAccum uintptr, pNew uintptr, pOld uintptr) (r int32) { + var i, nCol int32 + _, _ = i, nCol + nCol = (*TStatAccum)(unsafe.Pointer(pAccum)).FnCol + i = (*TStatSample)(unsafe.Pointer(pNew)).FiCol + int32(1) + for { + if !(i < nCol) { + break + } + if **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pNew)).FanEq + uintptr(i)*8)) > **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pOld)).FanEq + uintptr(i)*8)) { + return int32(1) + } + if **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pNew)).FanEq + uintptr(i)*8)) < **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pOld)).FanEq + uintptr(i)*8)) { + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + if (*TStatSample)(unsafe.Pointer(pNew)).FiHash > (*TStatSample)(unsafe.Pointer(pOld)).FiHash { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Save the positions of all cursors (except pExcept) that are open on +// ** the table with root-page iRoot. "Saving the cursor position" means that +// ** the location in the btree is remembered in such a way that it can be +// ** moved back to the same spot after the btree has been modified. This +// ** routine is called just before cursor pExcept is used to modify the +// ** table, for example in BtreeDelete() or BtreeInsert(). +// ** +// ** If there are two or more cursors on the same btree, then all such +// ** cursors should have their BTCF_Multiple flag set. The btreeCursor() +// ** routine enforces that rule. This routine only needs to be called in +// ** the uncommon case when pExpect has the BTCF_Multiple flag set. +// ** +// ** If pExpect!=NULL and if no other cursors are found on the same root-page, +// ** then the BTCF_Multiple flag on pExpect is cleared, to avoid another +// ** pointless call to this routine. +// ** +// ** Implementation note: This routine merely checks to see if any cursors +// ** need to be saved. It calls out to saveCursorsOnList() in the (unusual) +// ** event that cursors are in need to being saved. +// */ +func _saveAllCursors(tls *libc.TLS, pBt uintptr, iRoot TPgno, pExcept uintptr) (r int32) { + var p, v2 uintptr + _, _ = p, v2 + p = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor + for { + if !(p != 0) { + break + } + if p != pExcept && (uint32(0) == iRoot || (*TBtCursor)(unsafe.Pointer(p)).FpgnoRoot == iRoot) { + break + } + goto _1 + _1: + ; + p = (*TBtCursor)(unsafe.Pointer(p)).FpNext + } + if p != 0 { + return _saveCursorsOnList(tls, p, iRoot, pExcept) + } + if pExcept != 0 { + v2 = pExcept + 1 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) & ^libc.Int32FromInt32(BTCF_Multiple)) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Format a string using printf() style formatting and then append it to the +// ** buffer using sessionAppendString(). +// */ +func _sessionAppendPrintf(tls *libc.TLS, p uintptr, pRc uintptr, zFmt uintptr, va uintptr) { + var ap Tva_list + var zApp uintptr + _, _ = ap, zApp + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + zApp = uintptr(0) + ap = va + zApp = Xsqlite3_vmprintf(tls, zFmt, ap) + if zApp == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } else { + _sessionAppendStr(tls, p, zApp, pRc) + } + _ = ap + Xsqlite3_free(tls, zApp) + } +} + +// C documentation +// +// /* +// ** Attempt to apply all the changes in retry buffer pRetry to the database. +// ** Except, if parameter iSkip is greater than or equal to 0, skip change +// ** iSkip. +// */ +func _sessionApplyRetryBuffer(tls *libc.TLS, pRetry uintptr, iSkip int32, db uintptr, bPatchset int32, zTab uintptr, pApply uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var ii, rc, rc2 int32 + var _ /* pIter at bp+0 */ uintptr + _, _, _ = ii, rc, rc2 + rc = SQLITE_OK + rc2 = SQLITE_OK + ii = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _sessionRetryIterInit(tls, pRetry, bPatchset, zTab, pApply, bp) + ii = 0 + for { + if !(rc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3changeset_next(tls, **(**uintptr)(__ccgo_up(bp)))) { + break + } + if ii != iSkip { + rc = _sessionApplyOneWithRetry(tls, db, **(**uintptr)(__ccgo_up(bp)), pApply, __ccgo_fp_xConflict, pCtx) + } + goto _1 + _1: + ; + ii = ii + 1 + } + rc2 = Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + rc = rc2 + } + return rc +} + +// C documentation +// +// /* +// ** Iterator pIter must point to an SQLITE_INSERT entry. This function +// ** transfers new.* values from the current iterator entry to statement +// ** pStmt. The table being inserted into has nCol columns. +// ** +// ** New.* value $i from the iterator is bound to variable ($i+1) of +// ** statement pStmt. If parameter abPK is NULL, all values from 0 to (nCol-1) +// ** are transfered to the statement. Otherwise, if abPK is not NULL, it points +// ** to an array nCol elements in size. In this case only those values for +// ** which abPK[$i] is true are read from the iterator and bound to the +// ** statement. +// ** +// ** An SQLite error code is returned if an error occurs. Otherwise, SQLITE_OK. +// */ +func _sessionBindRow(tls *libc.TLS, pIter uintptr, __ccgo_fp_xValue uintptr, nCol int32, abPK uintptr, pStmt uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, rc int32 + var _ /* pVal at bp+0 */ uintptr + _, _ = i, rc + rc = SQLITE_OK + /* Neither sqlite3changeset_old or sqlite3changeset_new can fail if the + ** argument iterator points to a suitable entry. Make sure that xValue + ** is one of these to guarantee that it is safe to ignore the return + ** in the code below. */ + i = 0 + for { + if !(rc == SQLITE_OK && i < nCol) { + break + } + if !(abPK != 0) || **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xValue})))(tls, pIter, i, bp) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + /* The value in the changeset was "undefined". This indicates a + ** corrupt changeset blob. */ + rc = _sqlite3CorruptError(tls, int32(238260)) + } else { + rc = _sessionBindValue(tls, pStmt, i+int32(1), **(**uintptr)(__ccgo_up(bp))) + } + } + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +// C documentation +// +// /* +// ** A wrapper around sqlite3_bind_value() that detects an extra problem. +// ** See comments in the body of this function for details. +// */ +func _sessionBindValue(tls *libc.TLS, pStmt uintptr, i int32, pVal uintptr) (r int32) { + var eType int32 + _ = eType + eType = Xsqlite3_value_type(tls, pVal) + /* COVERAGE: The (pVal->z==0) branch is never true using current versions + ** of SQLite. If a malloc fails in an sqlite3_value_xxx() function, either + ** the (pVal->z) variable remains as it was or the type of the value is + ** set to SQLITE_NULL. */ + if (eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB)) && (*Tsqlite3_value)(unsafe.Pointer(pVal)).Fz == uintptr(0) { + /* This condition occurs when an earlier OOM in a call to + ** sqlite3_value_text() or sqlite3_value_blob() (perhaps from within + ** a conflict-handler) has zeroed the pVal->z pointer. Return NOMEM. */ + return int32(SQLITE_NOMEM) + } + return Xsqlite3_bind_value(tls, pStmt, i, pVal) +} + +// C documentation +// +// /* +// ** This function is called by all six sqlite3changeset_apply() variants: +// ** +// ** + sqlite3changeset_apply() +// ** + sqlite3changeset_apply_v2() +// ** + sqlite3changeset_apply_v3() +// ** + sqlite3changeset_apply_strm() +// ** + sqlite3changeset_apply_strm_v2() +// ** + sqlite3changeset_apply_strm_v3() +// ** +// ** Arguments passed to this function are as follows: +// ** +// ** db: +// ** Database handle to apply changeset to main database of. +// ** +// ** nChangeset/pChangeset: +// ** These are both passed zero for the streaming variants. For the normal +// ** apply() functions, these are passed the size of and the buffer containing +// ** the changeset, respectively. +// ** +// ** xInput/pIn: +// ** These are both passed zero for the normal variants. For the streaming +// ** apply() functions, these are passed the input callback and context +// ** pointer, respectively. +// ** +// ** xFilter: +// ** The filter function as passed to apply() or apply_v2() (to filter by +// ** table name), if any. This is always NULL for apply_v3() calls. +// ** +// ** xFilterIter: +// ** The filter function as passed to apply_v3(), if any. +// ** +// ** xConflict: +// ** The conflict handler callback (must not be NULL). +// ** +// ** pCtx: +// ** The context pointer passed to the xFilter and xConflict handler callbacks. +// ** +// ** ppRebase, pnRebase: +// ** Zero for apply(). The rebase changeset output pointers, if any, for +// ** apply_v2() and apply_v3(). +// ** +// ** flags: +// ** Zero for apply(). The flags parameter for apply_v2() and apply_v3(). +// */ +func _sessionChangesetApplyV23(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xFilterIter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bInverse, rc int32 + var _ /* pIter at bp+0 */ uintptr + _, _ = bInverse, rc /* Iterator to skip through changeset */ + bInverse = libc.BoolInt32(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETAPPLY_INVERT) != 0)) + rc = _sessionChangesetStart(tls, bp, __ccgo_fp_xInput, pIn, nChangeset, pChangeset, bInverse, int32(1)) + if rc == SQLITE_OK { + rc = _sessionChangesetApply(tls, db, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xFilter, __ccgo_fp_xFilterIter, __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags) + } + return rc +} + +// C documentation +// +// /* +// ** The input pointer currently points to the second byte of a table-header. +// ** Specifically, to the following: +// ** +// ** + number of columns in table (varint) +// ** + array of PK flags (1 byte per column), +// ** + table name (nul terminated). +// ** +// ** This function ensures that all of the above is present in the input +// ** buffer (i.e. that it can be accessed without any calls to xInput()). +// ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code. +// ** The input pointer is not moved. +// */ +func _sessionChangesetBufferTblhdr(tls *libc.TLS, pIn uintptr, pnByte uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nBuf, nRead, rc int32 + var _ /* nCol at bp+0 */ int32 + _, _, _ = nBuf, nRead, rc + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp)) = 0 + nRead = 0 + rc = _sessionInputBuffer(tls, pIn, int32(9)) + if rc == SQLITE_OK { + nBuf = (*TSessionInput)(unsafe.Pointer(pIn)).FnData - (*TSessionInput)(unsafe.Pointer(pIn)).FiNext + nRead = nRead + _sessionVarintGetSafe(tls, (*TSessionInput)(unsafe.Pointer(pIn)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiNext), nBuf, bp) + /* The hard upper limit for the number of columns in an SQLite + ** database table is, according to sqliteLimit.h, 32676. So + ** consider any table-header that purports to have more than 65536 + ** columns to be corrupt. This is convenient because otherwise, + ** if the (nCol>65536) condition below were omitted, a sufficiently + ** large value for nCol may cause nRead to wrap around and become + ** negative. Leading to a crash. */ + if **(**int32)(__ccgo_up(bp)) < 0 || **(**int32)(__ccgo_up(bp)) > int32(65536) { + rc = _sqlite3CorruptError(tls, int32(237170)) + } else { + rc = _sessionInputBuffer(tls, pIn, nRead+**(**int32)(__ccgo_up(bp))+int32(100)) + nRead = nRead + **(**int32)(__ccgo_up(bp)) + } + } + for rc == SQLITE_OK { + for (*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nRead < (*TSessionInput)(unsafe.Pointer(pIn)).FnData && **(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pIn)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nRead))) != 0 { + nRead = nRead + 1 + } + /* Break out of the loop if if the nul-terminator byte has been found. + ** Otherwise, read some more input data and keep seeking. If there is + ** no more input data, consider the changeset corrupt. */ + if (*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nRead < (*TSessionInput)(unsafe.Pointer(pIn)).FnData { + break + } + rc = _sessionInputBuffer(tls, pIn, nRead+int32(100)) + if rc == SQLITE_OK && (*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nRead >= (*TSessionInput)(unsafe.Pointer(pIn)).FnData { + rc = _sqlite3CorruptError(tls, int32(237188)) + } + } + **(**int32)(__ccgo_up(pnByte)) = nRead + int32(1) + return rc +} + +// C documentation +// +// /* +// ** Advance the changeset iterator to the next change. +// ** +// ** If both paRec and pnRec are NULL, then this function works like the public +// ** API sqlite3changeset_next(). If SQLITE_ROW is returned, then the +// ** sqlite3changeset_new() and old() APIs may be used to query for values. +// ** +// ** Otherwise, if paRec and pnRec are not NULL, then a pointer to the change +// ** record is written to *paRec before returning and the number of bytes in +// ** the record to *pnRec. +// ** +// ** Either way, this function returns SQLITE_ROW if the iterator is +// ** successfully advanced to the next change in the changeset, an SQLite +// ** error code if an error occurs, or SQLITE_DONE if there are no further +// ** changes in the changeset. +// */ +func _sessionChangesetNext(tls *libc.TLS, p uintptr, paRec uintptr, pnRec uintptr, pbNew uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* bEmpty at bp+0 */ int32 + _ = rc + for cond := true; cond; cond = rc == int32(SQLITE_ROW) && (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbSkipEmpty != 0 && **(**int32)(__ccgo_up(bp)) != 0 { + **(**int32)(__ccgo_up(bp)) = 0 + rc = _sessionChangesetNextOne(tls, p, paRec, pnRec, pbNew, bp) + } + return rc +} + +func _sessionDiffCount(tls *libc.TLS, pCtx uintptr) (r int32) { + var p uintptr + var v1 int32 + _, _ = p, v1 + p = pCtx + if (*TSessionDiffCtx)(unsafe.Pointer(p)).FnOldOff != 0 { + v1 = (*TSessionDiffCtx)(unsafe.Pointer(p)).FnOldOff + } else { + v1 = Xsqlite3_column_count(tls, (*TSessionDiffCtx)(unsafe.Pointer(p)).FpStmt) + } + return v1 - (*TSessionDiffCtx)(unsafe.Pointer(p)).FbRowid +} + +func _sessionDiffDepth(tls *libc.TLS, pCtx uintptr) (r int32) { + _ = pCtx + return 0 +} + +func _sessionDiffFindNew(tls *libc.TLS, op int32, pSession uintptr, pTab uintptr, zDb1 uintptr, zDb2 uintptr, zExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iRowid Ti64 + var pDiffCtx, zStmt uintptr + var rc int32 + var v1 int64 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _ = iRowid, pDiffCtx, rc, zStmt, v1 + rc = SQLITE_OK + zStmt = _sessionSelectFindNew(tls, zDb1, zDb2, (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zExpr) + if zStmt == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, zStmt, -int32(1), bp, uintptr(0)) + if rc == SQLITE_OK { + pDiffCtx = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx + (*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FpStmt = **(**uintptr)(__ccgo_up(bp)) + (*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FnOldOff = 0 + (*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FbRowid = (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + v1 = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } else { + v1 = 0 + } + iRowid = v1 + _sessionPreupdateOneChange(tls, op, iRowid, pSession, pTab) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + Xsqlite3_free(tls, zStmt) + } + return rc +} + +// C documentation +// +// /* +// ** Install the diff hooks on the session object passed as the only +// ** argument. +// */ +func _sessionDiffHooks(tls *libc.TLS, pSession uintptr, pDiffCtx uintptr) { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx = pDiffCtx + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld = __ccgo_fp(_sessionDiffOld) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew = __ccgo_fp(_sessionDiffNew) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount = __ccgo_fp(_sessionDiffCount) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth = __ccgo_fp(_sessionDiffDepth) +} + +func _sessionDiffNew(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) (r int32) { + var p uintptr + _ = p + p = pCtx + **(**uintptr)(__ccgo_up(ppVal)) = Xsqlite3_column_value(tls, (*TSessionDiffCtx)(unsafe.Pointer(p)).FpStmt, iVal+(*TSessionDiffCtx)(unsafe.Pointer(p)).FbRowid) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** The diff hook implementations. +// */ +func _sessionDiffOld(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) (r int32) { + var p uintptr + _ = p + p = pCtx + **(**uintptr)(__ccgo_up(ppVal)) = Xsqlite3_column_value(tls, (*TSessionDiffCtx)(unsafe.Pointer(p)).FpStmt, iVal+(*TSessionDiffCtx)(unsafe.Pointer(p)).FnOldOff+(*TSessionDiffCtx)(unsafe.Pointer(p)).FbRowid) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Finalize statement pStmt. If (*pRc) is SQLITE_OK when this function is +// ** called, set it to the results of the sqlite3_finalize() call. Or, if +// ** it is already set to an error code, leave it as is. +// */ +func _sessionFinalizeStmt(tls *libc.TLS, pStmt uintptr, pRc uintptr) { + var rc int32 + _ = rc + rc = Xsqlite3_finalize(tls, pStmt) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + **(**int32)(__ccgo_up(pRc)) = rc + } +} + +func _sessionFindTable(tls *libc.TLS, pSession uintptr, zName uintptr, ppTab uintptr) (r int32) { + var nName, rc int32 + var pRet uintptr + _, _, _ = nName, pRet, rc + rc = SQLITE_OK + nName = _sqlite3Strlen30(tls, zName) + /* Search for an existing table */ + pRet = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable + for { + if !(pRet != 0) { + break + } + if 0 == Xsqlite3_strnicmp(tls, (*TSessionTable)(unsafe.Pointer(pRet)).FzName, zName, nName+int32(1)) { + break + } + goto _1 + _1: + ; + pRet = (*TSessionTable)(unsafe.Pointer(pRet)).FpNext + } + if pRet == uintptr(0) && (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach != 0 { + /* If there is a table-filter configured, invoke it. If it returns 0, + ** do not automatically add the new table. */ + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter == uintptr(0) || (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpFilterCtx, zName) != 0 { + rc = Xsqlite3session_attach(tls, pSession, zName) + if rc == SQLITE_OK { + pRet = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable + for pRet != 0 && (*TSessionTable)(unsafe.Pointer(pRet)).FpNext != 0 { + pRet = (*TSessionTable)(unsafe.Pointer(pRet)).FpNext + } + } + } + } + **(**uintptr)(__ccgo_up(ppTab)) = pRet + return rc +} + +// C documentation +// +// /* +// ** Append the hash of the blob passed via the second and third arguments to +// ** the hash-key value passed as the first. Return the new hash-key value. +// */ +func _sessionHashAppendBlob(tls *libc.TLS, h uint32, n int32, z uintptr) (r uint32) { + var i int32 + _ = i + i = 0 + for { + if !(i < n) { + break + } + h = h< float64(0) { + v2 = +libc.Int32FromInt32(1) + } else { + v2 = 0 + } + v1 = v2 + } + Xsqlite3_result_int(tls, context, v1) +} + +// C documentation +// +// /* +// ** zSql[] is a CREATE TABLE statement, supposedly. Find the offset +// ** into zSql[] of the first character past the first "(" and write +// ** that offset into *piOff and return SQLITE_OK. Or, if not found, +// ** set the SQLITE_CORRUPT error code and return SQLITE_ERROR. +// */ +func _skipCreateTable(tls *libc.TLS, ctx uintptr, zSql uintptr, piOff uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iOff int32 + var _ /* t at bp+0 */ int32 + _ = iOff + iOff = 0 + if zSql == uintptr(0) { + return int32(SQLITE_ERROR) + } + /* Jump past the "CREATE TABLE" bit. */ + for int32(1) != 0 { + **(**int32)(__ccgo_up(bp)) = 0 + iOff = int32(int64(iOff) + _sqlite3GetToken(tls, zSql+uintptr(iOff), bp)) + if **(**int32)(__ccgo_up(bp)) == int32(TK_LP) { + break + } + if **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) { + Xsqlite3_result_error_code(tls, ctx, _sqlite3CorruptError(tls, int32(122917))) + return int32(SQLITE_ERROR) + } + } + **(**int32)(__ccgo_up(piOff)) = iOff + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Implementation of the sqlite_source_id() function. The result is a string +// ** that identifies the particular version of the source code used to build +// ** SQLite. +// */ +func _sourceidFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + _ = NotUsed + _ = NotUsed2 + /* IMP: R-24470-31136 This function is an SQL wrapper around the + ** sqlite3_sourceid() C interface. */ + Xsqlite3_result_text(tls, context, Xsqlite3_sourceid(tls), -int32(1), libc.UintptrFromInt32(0)) +} + +// C documentation +// +// /* +// ** Compute the absolute value of a 32-bit signed integer, if possible. Or +// ** if the integer has a value of -2147483648, return +2147483647 +// */ +func _sqlite3AbsInt32(tls *libc.TLS, x int32) (r int32) { + if x >= 0 { + return x + } + if x == libc.Int32FromUint32(0x80000000) { + return int32(0x7fffffff) + } + return -x +} + +// C documentation +// +// /* +// ** Attempt to add, subtract, or multiply the 64-bit signed value iB against +// ** the other 64-bit signed integer at *pA and store the result in *pA. +// ** Return 0 on success. Or if the operation would have resulted in an +// ** overflow, leave *pA unchanged and return 1. +// */ +func _sqlite3AddInt64(tls *libc.TLS, pA uintptr, iB Ti64) (r int32) { + var iA Ti64 + _ = iA + iA = **(**Ti64)(__ccgo_up(pA)) + if iB >= 0 { + if iA > 0 && libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< iB+int64(1) { + return int32(1) + } + } + **(**Ti64)(__ccgo_up(pA)) += iB + return 0 +} + +// C documentation +// +// /* +// ** This function must be called before exiting any API function (i.e. +// ** returning control to the user) that has called sqlite3_malloc or +// ** sqlite3_realloc. +// ** +// ** The returned value is normally a copy of the second argument to this +// ** function. However, if a malloc() failure has occurred since the previous +// ** invocation SQLITE_NOMEM is returned instead. +// ** +// ** If an OOM as occurred, then the connection error-code (the value +// ** returned by sqlite3_errcode()) is set to SQLITE_NOMEM. +// */ +func _sqlite3ApiExit(tls *libc.TLS, db uintptr, rc int32) (r int32) { + /* If the db handle must hold the connection handle mutex here. + ** Otherwise the read (and possible write) of db->mallocFailed + ** is unsafe, as is the call to sqlite3Error(). + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || rc != 0 { + return _apiHandleError(tls, db, rc) + } + return 0 +} + +/************** End of malloc.c **********************************************/ +/************** Begin file printf.c ******************************************/ +/* +** The "printf" code that follows dates from the 1980's. It is in +** the public domain. +** +************************************************************************** +** +** This file contains code for a set of "printf"-like routines. These +** routines format strings much like the printf() from the standard C +** library, though the implementation here has enhancements to support +** SQLite. + */ +/* #include "sqliteInt.h" */ + +/* +** Conversion types fall into various categories as defined by the +** following enumeration. + */ +/* The rest are extensions, not normally found in printf() */ + +// C documentation +// +// /* +// ** The following structure contains pointers to all SQLite API routines. +// ** A pointer to this structure is passed into extensions when they are +// ** loaded so that the extension can make calls back into the SQLite +// ** library. +// ** +// ** When adding new APIs, add them to the bottom of this structure +// ** in order to preserve backwards compatibility. +// ** +// ** Extensions that use newer APIs should first call the +// ** sqlite3_libversion_number() to make sure that the API they +// ** intend to use is supported by the library. Extensions should +// ** also check to make sure that the pointer to the function is +// ** not NULL before calling it. +// */ +var _sqlite3Apis = Tsqlite3_api_routines{} + +// C documentation +// +// /* +// ** Return a 32-bit integer value extracted from a string. If the +// ** string is not an integer, just return 0. +// */ +func _sqlite3Atoi(tls *libc.TLS, z uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* x at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = 0 + _sqlite3GetInt32(tls, z, bp) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Called by the parser to compile an ATTACH statement. +// ** +// ** ATTACH p AS pDbname KEY pKey +// */ +func _sqlite3Attach(tls *libc.TLS, pParse uintptr, p uintptr, pDbname uintptr, pKey uintptr) { + _codeAttach(tls, pParse, int32(SQLITE_ATTACH), uintptr(unsafe.Pointer(&_attach_func)), p, p, pDbname, pKey) +} + +// C documentation +// +// /* +// ** Pop an authorization context that was previously pushed +// ** by sqlite3AuthContextPush +// */ +func _sqlite3AuthContextPop(tls *libc.TLS, pContext uintptr) { + if (*TAuthContext)(unsafe.Pointer(pContext)).FpParse != 0 { + (*TParse)(unsafe.Pointer((*TAuthContext)(unsafe.Pointer(pContext)).FpParse)).FzAuthContext = (*TAuthContext)(unsafe.Pointer(pContext)).FzAuthContext + (*TAuthContext)(unsafe.Pointer(pContext)).FpParse = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Push an authorization context. After this routine is called, the +// ** zArg3 argument to authorization callbacks will be zContext until +// ** popped. Or if pParse==0, this routine is a no-op. +// */ +func _sqlite3AuthContextPush(tls *libc.TLS, pParse uintptr, pContext uintptr, zContext uintptr) { + (*TAuthContext)(unsafe.Pointer(pContext)).FpParse = pParse + (*TAuthContext)(unsafe.Pointer(pContext)).FzAuthContext = (*TParse)(unsafe.Pointer(pParse)).FzAuthContext + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = zContext +} + +var _sqlite3Autoext = Tsqlite3AutoExtList{} + +func _sqlite3AutoincrementEnd(tls *libc.TLS, pParse uintptr) { + if (*TParse)(unsafe.Pointer(pParse)).FpAinc != 0 { + _autoIncrementEnd(tls, pParse) + } +} + +// C documentation +// +// /* +// ** Restart the backup process. This is called when the pager layer +// ** detects that the database has been modified by an external database +// ** connection. In this case there is no way of knowing which of the +// ** pages that have been copied into the destination database are still +// ** valid and which are not, so the entire process needs to be restarted. +// ** +// ** It is assumed that the mutex associated with the BtShared object +// ** corresponding to the source database is held when this function is +// ** called. +// */ +func _sqlite3BackupRestart(tls *libc.TLS, pBackup uintptr) { + var p uintptr + _ = p /* Iterator variable */ + p = pBackup + for { + if !(p != 0) { + break + } + (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext = uint32(1) + goto _1 + _1: + ; + p = (*Tsqlite3_backup)(unsafe.Pointer(p)).FpNext + } +} + +func _sqlite3BackupUpdate(tls *libc.TLS, pBackup uintptr, iPage TPgno, aData uintptr) { + if pBackup != 0 { + _backupUpdate(tls, pBackup, iPage, aData) + } +} + +// C documentation +// +// /* +// ** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that +// ** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc() +// ** indicates that subsequent malloc failures are non-benign. +// */ +func _sqlite3BeginBenignMalloc(tls *libc.TLS) { + if _sqlite3Hooks.FxBenignBegin != 0 { + (*(*func(*libc.TLS))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Hooks.FxBenignBegin})))(tls) + } +} + +// C documentation +// +// /* +// ** Register hooks to call when sqlite3BeginBenignMalloc() and +// ** sqlite3EndBenignMalloc() are called, respectively. +// */ +func _sqlite3BenignMallocHooks(tls *libc.TLS, __ccgo_fp_xBenignBegin uintptr, __ccgo_fp_xBenignEnd uintptr) { + _sqlite3Hooks.FxBenignBegin = __ccgo_fp_xBenignBegin + _sqlite3Hooks.FxBenignEnd = __ccgo_fp_xBenignEnd +} + +// C documentation +// +// /* +// ** Return a pointer to the collation sequence that should be used by +// ** a binary comparison operator comparing pLeft and pRight. +// ** +// ** If the left hand expression has a collating sequence type, then it is +// ** used. Otherwise the collation sequence for the right hand expression +// ** is used, or the default (BINARY) if neither expression has a collating +// ** type. +// ** +// ** Argument pRight (but not pLeft) may be a null pointer. In this case, +// ** it is not considered. +// */ +func _sqlite3BinaryCompareCollSeq(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) (r uintptr) { + var pColl uintptr + _ = pColl + if (*TExpr)(unsafe.Pointer(pLeft)).Fflags&uint32(EP_Collate) != 0 { + pColl = _sqlite3ExprCollSeq(tls, pParse, pLeft) + } else { + if pRight != 0 && (*TExpr)(unsafe.Pointer(pRight)).Fflags&uint32(EP_Collate) != uint32(0) { + pColl = _sqlite3ExprCollSeq(tls, pParse, pRight) + } else { + pColl = _sqlite3ExprCollSeq(tls, pParse, pLeft) + if !(pColl != 0) { + pColl = _sqlite3ExprCollSeq(tls, pParse, pRight) + } + } + } + return pColl +} + +// C documentation +// +// /* +// ** Create a new bitmap object able to handle bits between 0 and iSize, +// ** inclusive. Return a pointer to the new object. Return NULL if +// ** malloc fails. +// */ +func _sqlite3BitvecCreate(tls *libc.TLS, iSize Tu32) (r uintptr) { + var p uintptr + _ = p + p = _sqlite3MallocZero(tls, uint64(512)) + if p != 0 { + (*TBitvec)(unsafe.Pointer(p)).FiSize = iSize + } + return p +} + +// C documentation +// +// /* +// ** Return the value of the iSize parameter specified when Bitvec *p +// ** was created. +// */ +func _sqlite3BitvecSize(tls *libc.TLS, p uintptr) (r Tu32) { + return (*TBitvec)(unsafe.Pointer(p)).FiSize +} + +/* +** Let V[] be an array of unsigned characters sufficient to hold +** up to N bits. Let I be an integer between 0 and N. 0<=IpNext is a list of other +// ** Btrees belonging to the same database connection as the p Btree +// ** which need to be locked after p. If we cannot get a lock on +// ** p, then first unlock all of the others on p->pNext, then wait +// ** for the lock to become available on p, then relock all of the +// ** subsequent Btrees that desire a lock. +// */ +func _sqlite3BtreeEnter(tls *libc.TLS, p uintptr) { + /* Some basic sanity checking on the Btree. The list of Btrees + ** connected by pNext and pPrev should be in sorted order by + ** Btree.pBt value. All elements of the list should belong to + ** the same connection. Only shared Btrees are on the list. */ + /* Check for locking consistency */ + /* We should already hold a lock on the database connection */ + /* Unless the database is sharable and unlocked, then BtShared.db + ** should already be set correctly. */ + if !((*TBtree)(unsafe.Pointer(p)).Fsharable != 0) { + return + } + (*TBtree)(unsafe.Pointer(p)).FwantToLock = (*TBtree)(unsafe.Pointer(p)).FwantToLock + 1 + if (*TBtree)(unsafe.Pointer(p)).Flocked != 0 { + return + } + _btreeLockCarefully(tls, p) +} + +// C documentation +// +// /* +// ** Enter a mutex on a Btree given a cursor owned by that Btree. +// ** +// ** These entry points are used by incremental I/O only. Enter() is required +// ** any time OMIT_SHARED_CACHE is not defined, regardless of whether or not +// ** the build is threadsafe. Leave() is only required by threadsafe builds. +// */ +func _sqlite3BtreeEnterCursor(tls *libc.TLS, pCur uintptr) { + _sqlite3BtreeEnter(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree) +} + +// C documentation +// +// /* +// ** Return a pointer to a fake BtCursor object that will always answer +// ** false to the sqlite3BtreeCursorHasMoved() routine above. The fake +// ** cursor returned must not be used with any other Btree interface. +// */ +func _sqlite3BtreeFakeValidCursor(tls *libc.TLS) (r uintptr) { + return uintptr(unsafe.Pointer(&_fakeCursor)) +} + +// C documentation +// +// /* Move the cursor to the first entry in the table. Return SQLITE_OK +// ** on success. Set *pRes to 0 if the cursor actually points to something +// ** or set *pRes to 1 if the table is empty. +// */ +func _sqlite3BtreeFirst(tls *libc.TLS, pCur uintptr, pRes uintptr) (r int32) { + var rc int32 + _ = rc + rc = _moveToRoot(tls, pCur) + if rc == SQLITE_OK { + **(**int32)(__ccgo_up(pRes)) = 0 + rc = _moveToLeftmost(tls, pCur) + } else { + if rc == int32(SQLITE_EMPTY) { + **(**int32)(__ccgo_up(pRes)) = int32(1) + rc = SQLITE_OK + } + } + return rc +} + +// C documentation +// +// /* +// ** Return the value of the 'auto-vacuum' property. If auto-vacuum is +// ** enabled 1 is returned. Otherwise 0. +// */ +func _sqlite3BtreeGetAutoVacuum(tls *libc.TLS, p uintptr) (r int32) { + var rc, v1, v2 int32 + _, _, _ = rc, v1, v2 + _sqlite3BtreeEnter(tls, p) + if !((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FautoVacuum != 0) { + v1 = BTREE_AUTOVACUUM_NONE + } else { + if !((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FincrVacuum != 0) { + v2 = int32(BTREE_AUTOVACUUM_FULL) + } else { + v2 = int32(BTREE_AUTOVACUUM_INCR) + } + v1 = v2 + } + rc = v1 + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Return the full pathname of the underlying database file. Return +// ** an empty string if the database is in-memory or a TEMP database. +// ** +// ** The pager filename is invariant as long as the pager is +// ** open so it is safe to access without the BtShared mutex. +// */ +func _sqlite3BtreeGetFilename(tls *libc.TLS, p uintptr) (r uintptr) { + return _sqlite3PagerFilename(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpPager, int32(1)) +} + +// C documentation +// +// /* +// ** Return the pathname of the journal file for this database. The return +// ** value of this routine is the same regardless of whether the journal file +// ** has been created or not. +// ** +// ** The pager journal filename is invariant as long as the pager is +// ** open so it is safe to access without the BtShared mutex. +// */ +func _sqlite3BtreeGetJournalname(tls *libc.TLS, p uintptr) (r uintptr) { + return _sqlite3PagerJournalname(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpPager) +} + +// C documentation +// +// /* +// ** This function may only be called if the b-tree connection already +// ** has a read or write transaction open on the database. +// ** +// ** Read the meta-information out of a database file. Meta[0] +// ** is the number of free pages currently in the database. Meta[1] +// ** through meta[15] are available for use by higher layers. Meta[0] +// ** is read-only, the others are read/write. +// ** +// ** The schema layer numbers meta values differently. At the schema +// ** layer (and the SetCookie and ReadCookie opcodes) the number of +// ** free pages is not visible. So Cookie[0] is the same as Meta[1]. +// ** +// ** This routine treats Meta[BTREE_DATA_VERSION] as a special case. Instead +// ** of reading the value out of the header, it instead loads the "DataVersion" +// ** from the pager. The BTREE_DATA_VERSION value is not actually stored in the +// ** database file. It is a number computed by the pager. But its access +// ** pattern is the same as header meta values, and so it is convenient to +// ** read it from this routine. +// */ +func _sqlite3BtreeGetMeta(tls *libc.TLS, p uintptr, idx int32, pMeta uintptr) { + var pBt uintptr + _ = pBt + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + if idx == int32(BTREE_DATA_VERSION) { + **(**Tu32)(__ccgo_up(pMeta)) = _sqlite3PagerDataVersion(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + (*TBtree)(unsafe.Pointer(p)).FiBDataVersion + } else { + **(**Tu32)(__ccgo_up(pMeta)) = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(int32(36)+idx*int32(4))) + } + /* If auto-vacuum is disabled in this build and this is an auto-vacuum + ** database, mark the database as read-only. */ + _sqlite3BtreeLeave(tls, p) +} + +// C documentation +// +// /* +// ** A write-transaction must be opened before calling this function. +// ** It performs a single unit of work towards an incremental vacuum. +// ** +// ** If the incremental vacuum is finished after this function has run, +// ** SQLITE_DONE is returned. If it is not finished, but no error occurred, +// ** SQLITE_OK is returned. Otherwise an SQLite error code. +// */ +func _sqlite3BtreeIncrVacuum(tls *libc.TLS, p uintptr) (r int32) { + var nFin, nFree, nOrig TPgno + var pBt uintptr + var rc int32 + _, _, _, _, _ = nFin, nFree, nOrig, pBt, rc + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + if !((*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { + rc = int32(SQLITE_DONE) + } else { + nOrig = _btreePagecount(tls, pBt) + nFree = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36) + nFin = _finalDbSize(tls, pBt, nOrig, nFree) + if nOrig < nFin || nFree >= nOrig { + rc = _sqlite3CorruptError(tls, int32(77316)) + } else { + if nFree > uint32(0) { + rc = _saveAllCursors(tls, pBt, uint32(0), uintptr(0)) + if rc == SQLITE_OK { + _invalidateAllOverflowCache(tls, pBt) + rc = _incrVacuumStep(tls, pBt, nFin, nOrig, 0) + } + if rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+28, (*TBtShared)(unsafe.Pointer(pBt)).FnPage) + } + } else { + rc = int32(SQLITE_DONE) + } + } + } + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Mark this cursor as an incremental blob cursor. +// */ +func _sqlite3BtreeIncrblobCursor(tls *libc.TLS, pCur uintptr) { + var v1 uintptr + _ = v1 + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTCF_Incrblob)) + (*TBtree)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBtree)).FhasIncrblobCur = uint8(1) +} + +// C documentation +// +// /* +// ** Return the value of the integer key or "rowid" for a table btree. +// ** This routine is only valid for a cursor that is pointing into a +// ** ordinary table btree. If the cursor points to an index btree or +// ** is invalid, the result of this routine is undefined. +// */ +func _sqlite3BtreeIntegerKey(tls *libc.TLS, pCur uintptr) (r Ti64) { + _getCellInfo(tls, pCur) + return (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey +} + +// C documentation +// +// /* +// ** Return true if there is currently a backup running on Btree p. +// */ +func _sqlite3BtreeIsInBackup(tls *libc.TLS, p uintptr) (r int32) { + return libc.BoolInt32((*TBtree)(unsafe.Pointer(p)).FnBackup != 0) +} + +func _sqlite3BtreeLastPage(tls *libc.TLS, p uintptr) (r TPgno) { + return _btreePagecount(tls, (*TBtree)(unsafe.Pointer(p)).FpBt) +} + +// C documentation +// +// /* +// ** Exit the recursive mutex on a Btree. +// */ +func _sqlite3BtreeLeave(tls *libc.TLS, p uintptr) { + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + (*TBtree)(unsafe.Pointer(p)).FwantToLock = (*TBtree)(unsafe.Pointer(p)).FwantToLock - 1 + if (*TBtree)(unsafe.Pointer(p)).FwantToLock == 0 { + _unlockBtreeMutex(tls, p) + } + } +} + +func _sqlite3BtreeLeaveCursor(tls *libc.TLS, pCur uintptr) { + _sqlite3BtreeLeave(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree) +} + +/************** End of btmutex.c *********************************************/ +/************** Begin file btree.c *******************************************/ +/* +** 2004 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file implements an external (disk-based) database using BTrees. +** See the header comment on "btreeInt.h" for additional information. +** Including a description of file format and an overview of operation. + */ +/* #include "btreeInt.h" */ + +// C documentation +// +// /* +// ** Set the maximum page count for a database if mxPage is positive. +// ** No changes are made if mxPage is 0 or negative. +// ** Regardless of the value of mxPage, return the maximum page count. +// */ +func _sqlite3BtreeMaxPageCount(tls *libc.TLS, p uintptr, mxPage TPgno) (r TPgno) { + var n TPgno + _ = n + _sqlite3BtreeEnter(tls, p) + n = _sqlite3PagerMaxPageCount(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpPager, mxPage) + _sqlite3BtreeLeave(tls, p) + return n +} + +// C documentation +// +// /* +// ** Initialize the first page of the database file (creating a database +// ** consisting of a single page and no schema objects). Return SQLITE_OK +// ** if successful, or an SQLite error code otherwise. +// */ +func _sqlite3BtreeNewDb(tls *libc.TLS, p uintptr) (r int32) { + var rc int32 + _ = rc + _sqlite3BtreeEnter(tls, p) + (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FnPage = uint32(0) + rc = _newDatabase(tls, (*TBtree)(unsafe.Pointer(p)).FpBt) + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Return the pager associated with a BTree. This routine is used for +// ** testing and debugging only. +// */ +func _sqlite3BtreePager(tls *libc.TLS, p uintptr) (r uintptr) { + return (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpPager +} + +// C documentation +// +// /* +// ** Read part of the payload for the row at which that cursor pCur is currently +// ** pointing. "amt" bytes will be transferred into pBuf[]. The transfer +// ** begins at "offset". +// ** +// ** pCur can be pointing to either a table or an index b-tree. +// ** If pointing to a table btree, then the content section is read. If +// ** pCur is pointing to an index b-tree then the key section is read. +// ** +// ** For sqlite3BtreePayload(), the caller must ensure that pCur is pointing +// ** to a valid row in the table. For sqlite3BtreePayloadChecked(), the +// ** cursor might be invalid or might need to be restored before being read. +// ** +// ** Return SQLITE_OK on success or an error code if anything goes +// ** wrong. An error is returned if "offset+amt" is larger than +// ** the available payload. +// */ +func _sqlite3BtreePayload(tls *libc.TLS, pCur uintptr, offset Tu32, amt Tu32, pBuf uintptr) (r int32) { + return _accessPayload(tls, pCur, offset, amt, pBuf, 0) +} + +// C documentation +// +// /* +// ** For the entry that cursor pCur is point to, return as +// ** many bytes of the key or data as are available on the local +// ** b-tree page. Write the number of available bytes into *pAmt. +// ** +// ** The pointer returned is ephemeral. The key/data may move +// ** or be destroyed on the next call to any Btree routine, +// ** including calls from other threads against the same cache. +// ** Hence, a mutex on the BtShared should be held prior to calling +// ** this routine. +// ** +// ** These routines is used to get quick access to key and data +// ** in the common case where no overflow pages are used. +// */ +func _sqlite3BtreePayloadFetch(tls *libc.TLS, pCur uintptr, pAmt uintptr) (r uintptr) { + return _fetchPayload(tls, pCur, pAmt) +} + +// C documentation +// +// /* +// ** Return the number of bytes of payload for the entry that pCur is +// ** currently pointing to. For table btrees, this will be the amount +// ** of data. For index btrees, this will be the size of the key. +// ** +// ** The caller must guarantee that the cursor is pointing to a non-NULL +// ** valid entry. In other words, the calling procedure must guarantee +// ** that the cursor has Cursor.eState==CURSOR_VALID. +// */ +func _sqlite3BtreePayloadSize(tls *libc.TLS, pCur uintptr) (r Tu32) { + _getCellInfo(tls, pCur) + return (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload +} + +// C documentation +// +// /* +// ** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared +// ** btree as the argument handle holds an exclusive lock on the +// ** sqlite_schema table. Otherwise SQLITE_OK. +// */ +func _sqlite3BtreeSchemaLocked(tls *libc.TLS, p uintptr) (r int32) { + var rc int32 + _ = rc + _ = p /* only used in DEBUG builds */ + _sqlite3BtreeEnter(tls, p) + rc = _querySharedCacheTableLock(tls, p, uint32(SCHEMA_ROOT), uint8(READ_LOCK)) + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Change the "soft" limit on the number of pages in the cache. +// ** Unused and unmodified pages will be recycled when the number of +// ** pages in the cache exceeds this soft limit. But the size of the +// ** cache is allowed to grow larger than this limit if it contains +// ** dirty pages or pages still in active use. +// */ +func _sqlite3BtreeSetCacheSize(tls *libc.TLS, p uintptr, mxPage int32) (r int32) { + var pBt uintptr + _ = pBt + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + _sqlite3PagerSetCachesize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, mxPage) + _sqlite3BtreeLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Change the way data is synced to disk in order to increase or decrease +// ** how well the database resists damage due to OS crashes and power +// ** failures. Level 1 is the same as asynchronous (no syncs() occur and +// ** there is a high probability of damage) Level 2 is the default. There +// ** is a very low but non-zero probability of damage. Level 3 reduces the +// ** probability of damage to near zero but with a write performance reduction. +// */ +func _sqlite3BtreeSetPagerFlags(tls *libc.TLS, p uintptr, pgFlags uint32) (r int32) { + var pBt uintptr + _ = pBt + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + _sqlite3PagerSetFlags(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pgFlags) + _sqlite3BtreeLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Change the "spill" limit on the number of pages in the cache. +// ** If the number of pages exceeds this limit during a write transaction, +// ** the pager might attempt to "spill" pages to the journal early in +// ** order to free up memory. +// ** +// ** The value returned is the current spill size. If zero is passed +// ** as an argument, no changes are made to the spill size setting, so +// ** using mxPage of 0 is a way to query the current spill size. +// */ +func _sqlite3BtreeSetSpillSize(tls *libc.TLS, p uintptr, mxPage int32) (r int32) { + var pBt uintptr + var res int32 + _, _ = pBt, res + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + res = _sqlite3PagerSetSpillsize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, mxPage) + _sqlite3BtreeLeave(tls, p) + return res +} + +// C documentation +// +// /* +// ** Write meta-information back into the database. Meta[0] is +// ** read-only and may not be written. +// */ +func _sqlite3BtreeUpdateMeta(tls *libc.TLS, p uintptr, idx int32, iMeta Tu32) (r int32) { + var pBt, pP1 uintptr + var rc int32 + _, _, _ = pBt, pP1, rc + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + pP1 = (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) + if rc == SQLITE_OK { + _sqlite3Put4byte(tls, pP1+uintptr(int32(36)+idx*int32(4)), iMeta) + if idx == int32(BTREE_INCR_VACUUM) { + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = uint8(iMeta) + } + } + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** An array of pointers to extension initializer functions for +// ** built-in extensions. +// */ +var _sqlite3BuiltinExtensions = [5]uintptr{} + +// C documentation +// +// /* +// ** Hash table for global functions - functions common to all +// ** database connections. After initialization, this table is +// ** read-only. +// */ +var _sqlite3BuiltinFunctions TFuncDefHash + +// C documentation +// +// /* +// ** This routine is called on a collation sequence before it is used to +// ** check that it is defined. An undefined collation sequence exists when +// ** a database is loaded that contains references to collation sequences +// ** that have not been defined by sqlite3_create_collation() etc. +// ** +// ** If required, this routine calls the 'collation needed' callback to +// ** request a definition of the collating sequence. If this doesn't work, +// ** an equivalent collating sequence that uses a text encoding different +// ** from the main database is substituted, if one is available. +// */ +func _sqlite3CheckCollSeq(tls *libc.TLS, pParse uintptr, pColl uintptr) (r int32) { + var db, p, zName uintptr + _, _, _ = db, p, zName + if pColl != 0 && (*TCollSeq)(unsafe.Pointer(pColl)).FxCmp == uintptr(0) { + zName = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = _sqlite3GetCollSeq(tls, pParse, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, pColl, zName) + if !(p != 0) { + return int32(SQLITE_ERROR) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Clear both elements of an OnOrUsing object +// */ +func _sqlite3ClearOnOrUsing(tls *libc.TLS, db uintptr, p uintptr) { + if p == uintptr(0) { + /* Nothing to clear */ + } else { + if (*TOnOrUsing)(unsafe.Pointer(p)).FpOn != 0 { + _sqlite3ExprDeleteNN(tls, db, (*TOnOrUsing)(unsafe.Pointer(p)).FpOn) + } else { + if (*TOnOrUsing)(unsafe.Pointer(p)).FpUsing != 0 { + _sqlite3IdListDelete(tls, db, (*TOnOrUsing)(unsafe.Pointer(p)).FpUsing) + } + } + } +} + +// C documentation +// +// /* +// ** Mark all temporary registers as being unavailable for reuse. +// ** +// ** Always invoke this procedure after coding a subroutine or co-routine +// ** that might be invoked from other parts of the code, to ensure that +// ** the sub/co-routine does not use registers in common with the code that +// ** invokes the sub/co-routine. +// */ +func _sqlite3ClearTempRegCache(tls *libc.TLS, pParse uintptr) { + (*TParse)(unsafe.Pointer(pParse)).FnTempReg = uint8(0) + (*TParse)(unsafe.Pointer(pParse)).FnRangeReg = 0 +} + +// C documentation +// +// /* +// ** Close all open savepoints. This function only manipulates fields of the +// ** database handle object, it does not close any savepoints that may be open +// ** at the b-tree/pager level. +// */ +func _sqlite3CloseSavepoints(tls *libc.TLS, db uintptr) { + var pTmp uintptr + _ = pTmp + for (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint != 0 { + pTmp = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint + (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint = (*TSavepoint)(unsafe.Pointer(pTmp)).FpNext + _sqlite3DbFree(tls, db, pTmp) + } + (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(0) +} + +// C documentation +// +// /* Generate byte-code that will report the number of rows modified +// ** by a DELETE, INSERT, or UPDATE statement. +// */ +func _sqlite3CodeChangeCount(tls *libc.TLS, v uintptr, regCounter int32, zColName uintptr) { + _sqlite3VdbeAddOp0(tls, v, int32(OP_FkCheck)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), regCounter, int32(1)) + _sqlite3VdbeSetNumCols(tls, v, int32(1)) + _sqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, zColName, libc.UintptrFromInt32(0)) +} + +func _sqlite3CodeVerifySchema(tls *libc.TLS, pParse uintptr, iDb int32) { + var v1 uintptr + _ = v1 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + _sqlite3CodeVerifySchemaAtToplevel(tls, v1, iDb) +} + +// C documentation +// +// /* +// ** This function is called while stepping or preparing a statement +// ** associated with connection db. The operation will return SQLITE_LOCKED +// ** to the user because it requires a lock that will not be available +// ** until connection pBlocker concludes its current transaction. +// */ +func _sqlite3ConnectionBlocked(tls *libc.TLS, db uintptr, pBlocker uintptr) { + _enterMutex(tls) + if (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockConnection == uintptr(0) { + _addToBlockedList(tls, db) + } + (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection = pBlocker + _leaveMutex(tls) +} + +// C documentation +// +// /* +// ** This is called when the database connection passed as an argument is +// ** being closed. The connection is removed from the blocked list. +// */ +func _sqlite3ConnectionClosed(tls *libc.TLS, db uintptr) { + _sqlite3ConnectionUnlocked(tls, db) + _enterMutex(tls) + _removeFromBlockedList(tls, db) + _leaveMutex(tls) +} + +/************** End of notify.c **********************************************/ +/************** Begin file fts3.c ********************************************/ +/* +** 2006 Oct 10 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This is an SQLite module implementing full-text search. + */ + +/* +** The code in this file is only compiled if: +** +** * The FTS3 module is being built as an extension +** (in which case SQLITE_CORE is not defined), or +** +** * The FTS3 module is being built into the core of +** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). + */ + +/* The full-text index is stored in a series of b+tree (-like) +** structures called segments which map terms to doclists. The +** structures are like b+trees in layout, but are constructed from the +** bottom up in optimal fashion and are not updatable. Since trees +** are built from the bottom up, things will be described from the +** bottom up. +** +** +**** Varints **** +** The basic unit of encoding is a variable-length integer called a +** varint. We encode variable-length integers in little-endian order +** using seven bits * per byte as follows: +** +** KEY: +** A = 0xxxxxxx 7 bits of data and one flag bit +** B = 1xxxxxxx 7 bits of data and one flag bit +** +** 7 bits - A +** 14 bits - BA +** 21 bits - BBA +** and so on. +** +** This is similar in concept to how sqlite encodes "varints" but +** the encoding is not the same. SQLite varints are big-endian +** are are limited to 9 bytes in length whereas FTS3 varints are +** little-endian and can be up to 10 bytes in length (in theory). +** +** Example encodings: +** +** 1: 0x01 +** 127: 0x7f +** 128: 0x81 0x00 +** +** +**** Document lists **** +** A doclist (document list) holds a docid-sorted list of hits for a +** given term. Doclists hold docids and associated token positions. +** A docid is the unique integer identifier for a single document. +** A position is the index of a word within the document. The first +** word of the document has a position of 0. +** +** FTS3 used to optionally store character offsets using a compile-time +** option. But that functionality is no longer supported. +** +** A doclist is stored like this: +** +** array { +** varint docid; (delta from previous doclist) +** array { (position list for column 0) +** varint position; (2 more than the delta from previous position) +** } +** array { +** varint POS_COLUMN; (marks start of position list for new column) +** varint column; (index of new column) +** array { +** varint position; (2 more than the delta from previous position) +** } +** } +** varint POS_END; (marks end of positions for this document. +** } +** +** Here, array { X } means zero or more occurrences of X, adjacent in +** memory. A "position" is an index of a token in the token stream +** generated by the tokenizer. Note that POS_END and POS_COLUMN occur +** in the same logical place as the position element, and act as sentinels +** ending a position list array. POS_END is 0. POS_COLUMN is 1. +** The positions numbers are not stored literally but rather as two more +** than the difference from the prior position, or the just the position plus +** 2 for the first position. Example: +** +** label: A B C D E F G H I J K +** value: 123 5 9 1 1 14 35 0 234 72 0 +** +** The 123 value is the first docid. For column zero in this document +** there are two matches at positions 3 and 10 (5-2 and 9-2+3). The 1 +** at D signals the start of a new column; the 1 at E indicates that the +** new column is column number 1. There are two positions at 12 and 45 +** (14-2 and 35-2+12). The 0 at H indicate the end-of-document. The +** 234 at I is the delta to next docid (357). It has one position 70 +** (72-2) and then terminates with the 0 at K. +** +** A "position-list" is the list of positions for multiple columns for +** a single docid. A "column-list" is the set of positions for a single +** column. Hence, a position-list consists of one or more column-lists, +** a document record consists of a docid followed by a position-list and +** a doclist consists of one or more document records. +** +** A bare doclist omits the position information, becoming an +** array of varint-encoded docids. +** +**** Segment leaf nodes **** +** Segment leaf nodes store terms and doclists, ordered by term. Leaf +** nodes are written using LeafWriter, and read using LeafReader (to +** iterate through a single leaf node's data) and LeavesReader (to +** iterate through a segment's entire leaf layer). Leaf nodes have +** the format: +** +** varint iHeight; (height from leaf level, always 0) +** varint nTerm; (length of first term) +** char pTerm[nTerm]; (content of first term) +** varint nDoclist; (length of term's associated doclist) +** char pDoclist[nDoclist]; (content of doclist) +** array { +** (further terms are delta-encoded) +** varint nPrefix; (length of prefix shared with previous term) +** varint nSuffix; (length of unshared suffix) +** char pTermSuffix[nSuffix];(unshared suffix of next term) +** varint nDoclist; (length of term's associated doclist) +** char pDoclist[nDoclist]; (content of doclist) +** } +** +** Here, array { X } means zero or more occurrences of X, adjacent in +** memory. +** +** Leaf nodes are broken into blocks which are stored contiguously in +** the %_segments table in sorted order. This means that when the end +** of a node is reached, the next term is in the node with the next +** greater node id. +** +** New data is spilled to a new leaf node when the current node +** exceeds LEAF_MAX bytes (default 2048). New data which itself is +** larger than STANDALONE_MIN (default 1024) is placed in a standalone +** node (a leaf node with a single term and doclist). The goal of +** these settings is to pack together groups of small doclists while +** making it efficient to directly access large doclists. The +** assumption is that large doclists represent terms which are more +** likely to be query targets. +** +** TODO(shess) It may be useful for blocking decisions to be more +** dynamic. For instance, it may make more sense to have a 2.5k leaf +** node rather than splitting into 2k and .5k nodes. My intuition is +** that this might extend through 2x or 4x the pagesize. +** +** +**** Segment interior nodes **** +** Segment interior nodes store blockids for subtree nodes and terms +** to describe what data is stored by the each subtree. Interior +** nodes are written using InteriorWriter, and read using +** InteriorReader. InteriorWriters are created as needed when +** SegmentWriter creates new leaf nodes, or when an interior node +** itself grows too big and must be split. The format of interior +** nodes: +** +** varint iHeight; (height from leaf level, always >0) +** varint iBlockid; (block id of node's leftmost subtree) +** optional { +** varint nTerm; (length of first term) +** char pTerm[nTerm]; (content of first term) +** array { +** (further terms are delta-encoded) +** varint nPrefix; (length of shared prefix with previous term) +** varint nSuffix; (length of unshared suffix) +** char pTermSuffix[nSuffix]; (unshared suffix of next term) +** } +** } +** +** Here, optional { X } means an optional element, while array { X } +** means zero or more occurrences of X, adjacent in memory. +** +** An interior node encodes n terms separating n+1 subtrees. The +** subtree blocks are contiguous, so only the first subtree's blockid +** is encoded. The subtree at iBlockid will contain all terms less +** than the first term encoded (or all terms if no term is encoded). +** Otherwise, for terms greater than or equal to pTerm[i] but less +** than pTerm[i+1], the subtree for that term will be rooted at +** iBlockid+i. Interior nodes only store enough term data to +** distinguish adjacent children (if the rightmost term of the left +** child is "something", and the leftmost term of the right child is +** "wicked", only "w" is stored). +** +** New data is spilled to a new interior node at the same height when +** the current node exceeds INTERIOR_MAX bytes (default 2048). +** INTERIOR_MIN_TERMS (default 7) keeps large terms from monopolizing +** interior nodes and making the tree too skinny. The interior nodes +** at a given height are naturally tracked by interior nodes at +** height+1, and so on. +** +** +**** Segment directory **** +** The segment directory in table %_segdir stores meta-information for +** merging and deleting segments, and also the root node of the +** segment's tree. +** +** The root node is the top node of the segment's tree after encoding +** the entire segment, restricted to ROOT_MAX bytes (default 1024). +** This could be either a leaf node or an interior node. If the top +** node requires more than ROOT_MAX bytes, it is flushed to %_segments +** and a new root interior node is generated (which should always fit +** within ROOT_MAX because it only needs space for 2 varints, the +** height and the blockid of the previous root). +** +** The meta-information in the segment directory is: +** level - segment level (see below) +** idx - index within level +** - (level,idx uniquely identify a segment) +** start_block - first leaf node +** leaves_end_block - last leaf node +** end_block - last block (including interior nodes) +** root - contents of root node +** +** If the root node is a leaf node, then start_block, +** leaves_end_block, and end_block are all 0. +** +** +**** Segment merging **** +** To amortize update costs, segments are grouped into levels and +** merged in batches. Each increase in level represents exponentially +** more documents. +** +** New documents (actually, document updates) are tokenized and +** written individually (using LeafWriter) to a level 0 segment, with +** incrementing idx. When idx reaches MERGE_COUNT (default 16), all +** level 0 segments are merged into a single level 1 segment. Level 1 +** is populated like level 0, and eventually MERGE_COUNT level 1 +** segments are merged to a single level 2 segment (representing +** MERGE_COUNT^2 updates), and so on. +** +** A segment merge traverses all segments at a given level in +** parallel, performing a straightforward sorted merge. Since segment +** leaf nodes are written in to the %_segments table in order, this +** merge traverses the underlying sqlite disk structures efficiently. +** After the merge, all segment blocks from the merged level are +** deleted. +** +** MERGE_COUNT controls how often we merge segments. 16 seems to be +** somewhat of a sweet spot for insertion performance. 32 and 64 show +** very similar performance numbers to 16 on insertion, though they're +** a tiny bit slower (perhaps due to more overhead in merge-time +** sorting). 8 is about 20% slower than 16, 4 about 50% slower than +** 16, 2 about 66% slower than 16. +** +** At query time, high MERGE_COUNT increases the number of segments +** which need to be scanned and merged. For instance, with 100k docs +** inserted: +** +** MERGE_COUNT segments +** 16 25 +** 8 12 +** 4 10 +** 2 6 +** +** This appears to have only a moderate impact on queries for very +** frequent terms (which are somewhat dominated by segment merge +** costs), and infrequent and non-existent terms still seem to be fast +** even with many segments. +** +** TODO(shess) That said, it would be nice to have a better query-side +** argument for MERGE_COUNT of 16. Also, it is possible/likely that +** optimizations to things like doclist merging will swing the sweet +** spot around. +** +** +** +**** Handling of deletions and updates **** +** Since we're using a segmented structure, with no docid-oriented +** index into the term index, we clearly cannot simply update the term +** index when a document is deleted or updated. For deletions, we +** write an empty doclist (varint(docid) varint(POS_END)), for updates +** we simply write the new doclist. Segment merges overwrite older +** data for a particular docid with newer data, so deletes or updates +** will eventually overtake the earlier data and knock it out. The +** query logic likewise merges doclists so that newer data knocks out +** older data. + */ + +/************** Include fts3Int.h in the middle of fts3.c ********************/ +/************** Begin file fts3Int.h *****************************************/ +/* +** 2009 Nov 12 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** + */ + +/* +** Activate assert() only if SQLITE_TEST is enabled. + */ + +/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ +/* #include */ + +/* FTS3/FTS4 require virtual tables */ + +/* +** FTS4 is really an extension for FTS3. It is enabled using the +** SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all +** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. + */ + +/************** End of fts3Int.h *********************************************/ +/************** Continuing where we left off in fts3.c ***********************/ + +/************** End of fts3.c ************************************************/ +/************** Begin file fts3_aux.c ****************************************/ +/* +** 2011 Jan 27 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** + */ +/* #include "fts3Int.h" */ + +/************** End of fts3_aux.c ********************************************/ +/************** Begin file fts3_expr.c ***************************************/ +/* +** 2008 Nov 28 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This module contains code that implements a parser for fts3 query strings +** (the right-hand argument to the MATCH operator). Because the supported +** syntax is relatively simple, the whole tokenizer/parser system is +** hand-coded. + */ +/* #include "fts3Int.h" */ + +/************** End of fts3_expr.c *******************************************/ +/************** Begin file fts3_hash.c ***************************************/ +/* +** 2001 September 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This is the implementation of generic hash-tables used in SQLite. +** We've modified it slightly to serve as a standalone hash table +** implementation for the full-text indexing module. + */ + +/* +** The code in this file is only compiled if: +** +** * The FTS3 module is being built as an extension +** (in which case SQLITE_CORE is not defined), or +** +** * The FTS3 module is being built into the core of +** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). + */ +/* #include "fts3Int.h" */ + +/************** End of fts3_hash.c *******************************************/ +/************** Begin file fts3_porter.c *************************************/ +/* +** 2006 September 30 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** Implementation of the full-text-search tokenizer that implements +** a Porter stemmer. + */ + +/* +** The code in this file is only compiled if: +** +** * The FTS3 module is being built as an extension +** (in which case SQLITE_CORE is not defined), or +** +** * The FTS3 module is being built into the core of +** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). + */ +/* #include "fts3Int.h" */ + +/************** End of fts3_porter.c *****************************************/ +/************** Begin file fts3_tokenizer.c **********************************/ +/* +** 2007 June 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This is part of an SQLite module implementing full-text search. +** This particular file implements the generic tokenizer interface. + */ + +/* +** The code in this file is only compiled if: +** +** * The FTS3 module is being built as an extension +** (in which case SQLITE_CORE is not defined), or +** +** * The FTS3 module is being built into the core of +** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). + */ +/* #include "fts3Int.h" */ + +/************** End of fts3_tokenizer.c **************************************/ +/************** Begin file fts3_tokenizer1.c *********************************/ +/* +** 2006 Oct 10 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Implementation of the "simple" full-text-search tokenizer. + */ + +/* +** The code in this file is only compiled if: +** +** * The FTS3 module is being built as an extension +** (in which case SQLITE_CORE is not defined), or +** +** * The FTS3 module is being built into the core of +** SQLite (in which case SQLITE_ENABLE_FTS3 is defined). + */ +/* #include "fts3Int.h" */ + +/************** End of fts3_tokenizer1.c *************************************/ +/************** Begin file fts3_tokenize_vtab.c ******************************/ +/* +** 2013 Apr 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains code for the "fts3tokenize" virtual table module. +** An fts3tokenize virtual table is created as follows: +** +** CREATE VIRTUAL TABLE USING fts3tokenize( +** , , ... +** ); +** +** The table created has the following schema: +** +** CREATE TABLE (input, token, start, end, position) +** +** When queried, the query must include a WHERE clause of type: +** +** input = +** +** The virtual table module tokenizes this , using the FTS3 +** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE +** statement and returns one row for each token in the result. With +** fields set as follows: +** +** input: Always set to a copy of +** token: A token from the input. +** start: Byte offset of the token within the input . +** end: Byte offset of the byte immediately following the end of the +** token within the input string. +** pos: Token offset of token within input. +** + */ +/* #include "fts3Int.h" */ + +/************** End of fts3_tokenize_vtab.c **********************************/ +/************** Begin file fts3_write.c **************************************/ +/* +** 2009 Oct 23 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file is part of the SQLite FTS3 extension module. Specifically, +** this file contains code to insert, update and delete rows from FTS3 +** tables. It also contains code to merge FTS3 b-tree segments. Some +** of the sub-routines used to merge segments are also used by the query +** code in fts3.c. + */ + +/* #include "fts3Int.h" */ + +/************** End of fts3_write.c ******************************************/ +/************** Begin file fts3_snippet.c ************************************/ +/* +** 2009 Oct 23 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** + */ + +/* #include "fts3Int.h" */ + +/************** End of fts3_snippet.c ****************************************/ +/************** Begin file fts3_unicode.c ************************************/ +/* +** 2012 May 24 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Implementation of the "unicode" full-text-search tokenizer. + */ + +/* #include "fts3Int.h" */ + +/************** End of fts3_unicode.c ****************************************/ +/************** Begin file fts3_unicode2.c ***********************************/ +/* +** 2012-05-25 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** + */ + +/* +** DO NOT EDIT THIS MACHINE GENERATED FILE. + */ + +/************** End of fts3_unicode2.c ***************************************/ +/************** Begin file json.c ********************************************/ +/* +** 2015-08-12 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** SQLite JSON functions. +** +** This file began as an extension in ext/misc/json1.c in 2015. That +** extension proved so useful that it has now been moved into the core. +** +** The original design stored all JSON as pure text, canonical RFC-8259. +** Support for JSON-5 extensions was added with version 3.42.0 (2023-05-16). +** All generated JSON text still conforms strictly to RFC-8259, but text +** with JSON-5 extensions is accepted as input. +** +** Beginning with version 3.45.0 (circa 2024-01-01), these routines also +** accept BLOB values that have JSON encoded using a binary representation +** called "JSONB". The name JSONB comes from PostgreSQL, however the on-disk +** format for SQLite-JSONB is completely different and incompatible with +** PostgreSQL-JSONB. +** +** Decoding and interpreting JSONB is still O(N) where N is the size of +** the input, the same as text JSON. However, the constant of proportionality +** for JSONB is much smaller due to faster parsing. The size of each +** element in JSONB is encoded in its header, so there is no need to search +** for delimiters using persnickety syntax rules. JSONB seems to be about +** 3x faster than text JSON as a result. JSONB is also tends to be slightly +** smaller than text JSON, by 5% or 10%, but there are corner cases where +** JSONB can be slightly larger. So you are not far mistaken to say that +** a JSONB blob is the same size as the equivalent RFC-8259 text. +** +** +** THE JSONB ENCODING: +** +** Every JSON element is encoded in JSONB as a header and a payload. +** The header is between 1 and 9 bytes in size. The payload is zero +** or more bytes. +** +** The lower 4 bits of the first byte of the header determines the +** element type: +** +** 0: NULL +** 1: TRUE +** 2: FALSE +** 3: INT -- RFC-8259 integer literal +** 4: INT5 -- JSON5 integer literal +** 5: FLOAT -- RFC-8259 floating point literal +** 6: FLOAT5 -- JSON5 floating point literal +** 7: TEXT -- Text literal acceptable to both SQL and JSON +** 8: TEXTJ -- Text containing RFC-8259 escapes +** 9: TEXT5 -- Text containing JSON5 and/or RFC-8259 escapes +** 10: TEXTRAW -- Text containing unescaped syntax characters +** 11: ARRAY +** 12: OBJECT +** +** The other three possible values (13-15) are reserved for future +** enhancements. +** +** The upper 4 bits of the first byte determine the size of the header +** and sometimes also the size of the payload. If X is the first byte +** of the element and if X>>4 is between 0 and 11, then the payload +** will be that many bytes in size and the header is exactly one byte +** in size. Other four values for X>>4 (12-15) indicate that the header +** is more than one byte in size and that the payload size is determined +** by the remainder of the header, interpreted as a unsigned big-endian +** integer. +** +** Value of X>>4 Size integer Total header size +** ------------- -------------------- ----------------- +** 12 1 byte (0-255) 2 +** 13 2 byte (0-65535) 3 +** 14 4 byte (0-4294967295) 5 +** 15 8 byte (0-1.8e19) 9 +** +** The payload size need not be expressed in its minimal form. For example, +** if the payload size is 10, the size can be expressed in any of 5 different +** ways: (1) (X>>4)==10, (2) (X>>4)==12 following by one 0x0a byte, +** (3) (X>>4)==13 followed by 0x00 and 0x0a, (4) (X>>4)==14 followed by +** 0x00 0x00 0x00 0x0a, or (5) (X>>4)==15 followed by 7 bytes of 0x00 and +** a single byte of 0x0a. The shorter forms are preferred, of course, but +** sometimes when generating JSONB, the payload size is not known in advance +** and it is convenient to reserve sufficient header space to cover the +** largest possible payload size and then come back later and patch up +** the size when it becomes known, resulting in a non-minimal encoding. +** +** The value (X>>4)==15 is not actually used in the current implementation +** (as SQLite is currently unable to handle BLOBs larger than about 2GB) +** but is included in the design to allow for future enhancements. +** +** The payload follows the header. NULL, TRUE, and FALSE have no payload and +** their payload size must always be zero. The payload for INT, INT5, +** FLOAT, FLOAT5, TEXT, TEXTJ, TEXT5, and TEXTROW is text. Note that the +** "..." or '...' delimiters are omitted from the various text encodings. +** The payload for ARRAY and OBJECT is a list of additional elements that +** are the content for the array or object. The payload for an OBJECT +** must be an even number of elements. The first element of each pair is +** the label and must be of type TEXT, TEXTJ, TEXT5, or TEXTRAW. +** +** A valid JSONB blob consists of a single element, as described above. +** Usually this will be an ARRAY or OBJECT element which has many more +** elements as its content. But the overall blob is just a single element. +** +** Input validation for JSONB blobs simply checks that the element type +** code is between 0 and 12 and that the total size of the element +** (header plus payload) is the same as the size of the BLOB. If those +** checks are true, the BLOB is assumed to be JSONB and processing continues. +** Errors are only raised if some other miscoding is discovered during +** processing. +** +** Additional information can be found in the doc/jsonb.md file of the +** canonical SQLite source tree. + */ +/* #include "sqliteInt.h" */ + +/* JSONB element types + */ + +// C documentation +// +// /* +// ** Free the contents of the CTE object passed as the second argument. +// */ +func _sqlite3CteDelete(tls *libc.TLS, db uintptr, pCte uintptr) { + _cteClear(tls, db, pCte) + _sqlite3DbFree(tls, db, pCte) +} + +// C documentation +// +// /* +// ** The following 256 byte lookup table is used to support SQLites built-in +// ** equivalents to the following standard library functions: +// ** +// ** isspace() 0x01 +// ** isalpha() 0x02 +// ** isdigit() 0x04 +// ** isalnum() 0x06 +// ** isxdigit() 0x08 +// ** toupper() 0x20 +// ** SQLite identifier character 0x40 $, _, or non-ascii +// ** Quote character 0x80 +// ** +// ** Bit 0x20 is set if the mapped character requires translation to upper +// ** case. i.e. if the character is a lower-case ASCII character. +// ** If x is a lower-case ASCII character, then its upper-case equivalent +// ** is (x - 0x20). Therefore toupper() can be implemented as: +// ** +// ** (x & ~(map[x]&0x20)) +// ** +// ** The equivalent of tolower() is implemented using the sqlite3UpperToLower[] +// ** array. tolower() is used more often than toupper() by SQLite. +// ** +// ** Bit 0x40 is set if the character is non-alphanumeric and can be used in an +// ** SQLite identifier. Identifiers are alphanumerics, "_", "$", and any +// ** non-ASCII UTF character. Hence the test for whether or not a character is +// ** part of an identifier is 0x46. +// */ +var _sqlite3CtypeMap = [256]uint8{ + 9: uint8(0x01), + 10: uint8(0x01), + 11: uint8(0x01), + 12: uint8(0x01), + 13: uint8(0x01), + 32: uint8(0x01), + 34: uint8(0x80), + 36: uint8(0x40), + 39: uint8(0x80), + 48: uint8(0x0c), + 49: uint8(0x0c), + 50: uint8(0x0c), + 51: uint8(0x0c), + 52: uint8(0x0c), + 53: uint8(0x0c), + 54: uint8(0x0c), + 55: uint8(0x0c), + 56: uint8(0x0c), + 57: uint8(0x0c), + 65: uint8(0x0a), + 66: uint8(0x0a), + 67: uint8(0x0a), + 68: uint8(0x0a), + 69: uint8(0x0a), + 70: uint8(0x0a), + 71: uint8(0x02), + 72: uint8(0x02), + 73: uint8(0x02), + 74: uint8(0x02), + 75: uint8(0x02), + 76: uint8(0x02), + 77: uint8(0x02), + 78: uint8(0x02), + 79: uint8(0x02), + 80: uint8(0x02), + 81: uint8(0x02), + 82: uint8(0x02), + 83: uint8(0x02), + 84: uint8(0x02), + 85: uint8(0x02), + 86: uint8(0x02), + 87: uint8(0x02), + 88: uint8(0x02), + 89: uint8(0x02), + 90: uint8(0x02), + 91: uint8(0x80), + 95: uint8(0x40), + 96: uint8(0x80), + 97: uint8(0x2a), + 98: uint8(0x2a), + 99: uint8(0x2a), + 100: uint8(0x2a), + 101: uint8(0x2a), + 102: uint8(0x2a), + 103: uint8(0x22), + 104: uint8(0x22), + 105: uint8(0x22), + 106: uint8(0x22), + 107: uint8(0x22), + 108: uint8(0x22), + 109: uint8(0x22), + 110: uint8(0x22), + 111: uint8(0x22), + 112: uint8(0x22), + 113: uint8(0x22), + 114: uint8(0x22), + 115: uint8(0x22), + 116: uint8(0x22), + 117: uint8(0x22), + 118: uint8(0x22), + 119: uint8(0x22), + 120: uint8(0x22), + 121: uint8(0x22), + 122: uint8(0x22), + 128: uint8(0x40), + 129: uint8(0x40), + 130: uint8(0x40), + 131: uint8(0x40), + 132: uint8(0x40), + 133: uint8(0x40), + 134: uint8(0x40), + 135: uint8(0x40), + 136: uint8(0x40), + 137: uint8(0x40), + 138: uint8(0x40), + 139: uint8(0x40), + 140: uint8(0x40), + 141: uint8(0x40), + 142: uint8(0x40), + 143: uint8(0x40), + 144: uint8(0x40), + 145: uint8(0x40), + 146: uint8(0x40), + 147: uint8(0x40), + 148: uint8(0x40), + 149: uint8(0x40), + 150: uint8(0x40), + 151: uint8(0x40), + 152: uint8(0x40), + 153: uint8(0x40), + 154: uint8(0x40), + 155: uint8(0x40), + 156: uint8(0x40), + 157: uint8(0x40), + 158: uint8(0x40), + 159: uint8(0x40), + 160: uint8(0x40), + 161: uint8(0x40), + 162: uint8(0x40), + 163: uint8(0x40), + 164: uint8(0x40), + 165: uint8(0x40), + 166: uint8(0x40), + 167: uint8(0x40), + 168: uint8(0x40), + 169: uint8(0x40), + 170: uint8(0x40), + 171: uint8(0x40), + 172: uint8(0x40), + 173: uint8(0x40), + 174: uint8(0x40), + 175: uint8(0x40), + 176: uint8(0x40), + 177: uint8(0x40), + 178: uint8(0x40), + 179: uint8(0x40), + 180: uint8(0x40), + 181: uint8(0x40), + 182: uint8(0x40), + 183: uint8(0x40), + 184: uint8(0x40), + 185: uint8(0x40), + 186: uint8(0x40), + 187: uint8(0x40), + 188: uint8(0x40), + 189: uint8(0x40), + 190: uint8(0x40), + 191: uint8(0x40), + 192: uint8(0x40), + 193: uint8(0x40), + 194: uint8(0x40), + 195: uint8(0x40), + 196: uint8(0x40), + 197: uint8(0x40), + 198: uint8(0x40), + 199: uint8(0x40), + 200: uint8(0x40), + 201: uint8(0x40), + 202: uint8(0x40), + 203: uint8(0x40), + 204: uint8(0x40), + 205: uint8(0x40), + 206: uint8(0x40), + 207: uint8(0x40), + 208: uint8(0x40), + 209: uint8(0x40), + 210: uint8(0x40), + 211: uint8(0x40), + 212: uint8(0x40), + 213: uint8(0x40), + 214: uint8(0x40), + 215: uint8(0x40), + 216: uint8(0x40), + 217: uint8(0x40), + 218: uint8(0x40), + 219: uint8(0x40), + 220: uint8(0x40), + 221: uint8(0x40), + 222: uint8(0x40), + 223: uint8(0x40), + 224: uint8(0x40), + 225: uint8(0x40), + 226: uint8(0x40), + 227: uint8(0x40), + 228: uint8(0x40), + 229: uint8(0x40), + 230: uint8(0x40), + 231: uint8(0x40), + 232: uint8(0x40), + 233: uint8(0x40), + 234: uint8(0x40), + 235: uint8(0x40), + 236: uint8(0x40), + 237: uint8(0x40), + 238: uint8(0x40), + 239: uint8(0x40), + 240: uint8(0x40), + 241: uint8(0x40), + 242: uint8(0x40), + 243: uint8(0x40), + 244: uint8(0x40), + 245: uint8(0x40), + 246: uint8(0x40), + 247: uint8(0x40), + 248: uint8(0x40), + 249: uint8(0x40), + 250: uint8(0x40), + 251: uint8(0x40), + 252: uint8(0x40), + 253: uint8(0x40), + 254: uint8(0x40), + 255: uint8(0x40), +} + +/* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards +** compatibility for legacy applications, the URI filename capability is +** disabled by default. +** +** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled +** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options. +** +** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally +** disabled. The default value may be changed by compiling with the +** SQLITE_USE_URI symbol defined. + */ + +/* EVIDENCE-OF: R-38720-18127 The default setting is determined by the +** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is "on" if +** that compile-time option is omitted. + */ + +/* The minimum PMA size is set to this value multiplied by the database +** page size in bytes. + */ + +/* Statement journals spill to disk when their size exceeds the following +** threshold (in bytes). 0 means that statement journals are created and +** written to disk immediately (the default behavior for SQLite versions +** before 3.12.0). -1 means always keep the entire statement journal in +** memory. (The statement journal is also always held entirely in memory +** if journal_mode=MEMORY or if temp_store=MEMORY, regardless of this +** setting.) + */ + +/* +** The default lookaside-configuration, the format "SZ,N". SZ is the +** number of bytes in each lookaside slot (should be a multiple of 8) +** and N is the number of slots. The lookaside-configuration can be +** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE) +** or at run-time for an individual database connection using +** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE); +** +** With the two-size-lookaside enhancement, less lookaside is required. +** The default configuration of 1200,40 actually provides 30 1200-byte slots +** and 93 128-byte slots, which is more lookaside than is available +** using the older 1200,100 configuration without two-size-lookaside. + */ + +/* The default maximum size of an in-memory database created using +** sqlite3_deserialize() + */ + +func _sqlite3DbFree(tls *libc.TLS, db uintptr, p uintptr) { + if p != 0 { + _sqlite3DbFreeNN(tls, db, p) + } +} + +// C documentation +// +// /* +// ** Allocate memory, either lookaside (if possible) or heap. +// ** If the allocation fails, set the mallocFailed flag in +// ** the connection pointer. +// ** +// ** If db!=0 and db->mallocFailed is true (indicating a prior malloc +// ** failure on the same database connection) then always return 0. +// ** Hence for a particular database connection, once malloc starts +// ** failing, it fails consistently until mallocFailed is reset. +// ** This is an important assumption. There are many places in the +// ** code that do things like this: +// ** +// ** int *a = (int*)sqlite3DbMallocRaw(db, 100); +// ** int *b = (int*)sqlite3DbMallocRaw(db, 200); +// ** if( b ) a[10] = 9; +// ** +// ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed +// ** that all prior mallocs (ex: "a") worked too. +// ** +// ** The sqlite3MallocRawNN() variant guarantees that the "db" parameter is +// ** not a NULL pointer. +// */ +func _sqlite3DbMallocRaw(tls *libc.TLS, db uintptr, n Tu64) (r uintptr) { + var p uintptr + _ = p + if db != 0 { + return _sqlite3DbMallocRawNN(tls, db, n) + } + p = _sqlite3Malloc(tls, n) + return p +} + +// C documentation +// +// /* +// ** Attempt to reallocate p. If the reallocation fails, then free p +// ** and set the mallocFailed flag in the database connection. +// */ +func _sqlite3DbReallocOrFree(tls *libc.TLS, db uintptr, p uintptr, n Tu64) (r uintptr) { + var pNew uintptr + _ = pNew + pNew = _sqlite3DbRealloc(tls, db, p, n) + if !(pNew != 0) { + _sqlite3DbFree(tls, db, p) + } + return pNew +} + +func _sqlite3DeleteTableGeneric(tls *libc.TLS, db uintptr, pTable uintptr) { + _sqlite3DeleteTable(tls, db, pTable) +} + +// C documentation +// +// /* +// ** Recursively delete a Trigger structure +// */ +func _sqlite3DeleteTrigger(tls *libc.TLS, db uintptr, pTrigger uintptr) { + if pTrigger == uintptr(0) || (*TTrigger)(unsafe.Pointer(pTrigger)).FbReturning != 0 { + return + } + _sqlite3DeleteTriggerStep(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list) + _sqlite3DbFree(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName) + _sqlite3DbFree(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).Ftable) + _sqlite3ExprDelete(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen) + _sqlite3IdListDelete(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).FpColumns) + _sqlite3DbFree(tls, db, pTrigger) +} + +// C documentation +// +// /* +// ** Delete a linked list of TriggerStep structures. +// */ +func _sqlite3DeleteTriggerStep(tls *libc.TLS, db uintptr, pTriggerStep uintptr) { + var pTmp uintptr + _ = pTmp + for pTriggerStep != 0 { + pTmp = pTriggerStep + pTriggerStep = (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpNext + _sqlite3ExprDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpWhere) + _sqlite3ExprListDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpExprList) + _sqlite3SelectDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpSelect) + _sqlite3IdListDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpIdList) + _sqlite3UpsertDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpUpsert) + _sqlite3SrcListDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpSrc) + _sqlite3DbFree(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FzSpan) + _sqlite3DbFree(tls, db, pTmp) + } +} + +// C documentation +// +// /* +// ** Called by the parser to compile a DETACH statement. +// ** +// ** DETACH pDbname +// */ +func _sqlite3Detach(tls *libc.TLS, pParse uintptr, pDbname uintptr) { + _codeAttach(tls, pParse, int32(SQLITE_DETACH), uintptr(unsafe.Pointer(&_detach_func)), pDbname, uintptr(0), uintptr(0), pDbname) +} + +func _sqlite3EndBenignMalloc(tls *libc.TLS) { + if _sqlite3Hooks.FxBenignEnd != 0 { + (*(*func(*libc.TLS))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Hooks.FxBenignEnd})))(tls) + } +} + +/************** End of fault.c ***********************************************/ +/************** Begin file mem0.c ********************************************/ +/* +** 2008 October 28 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains a no-op memory allocation drivers for use when +** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented +** here always fail. SQLite will not operate with these drivers. These +** are merely placeholders. Real drivers must be substituted using +** sqlite3_config() before SQLite will operate. + */ +/* #include "sqliteInt.h" */ + +/* +** This version of the memory allocator is the default. It is +** used when no other memory allocator is specified using compile-time +** macros. + */ + +/************** End of mem0.c ************************************************/ +/************** Begin file mem1.c ********************************************/ +/* +** 2007 August 14 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains low-level memory allocation drivers for when +** SQLite will use the standard C-library malloc/realloc/free interface +** to obtain the memory it needs. +** +** This file contains implementations of the low-level memory allocation +** routines specified in the sqlite3_mem_methods object. The content of +** this file is only used if SQLITE_SYSTEM_MALLOC is defined. The +** SQLITE_SYSTEM_MALLOC macro is defined automatically if neither the +** SQLITE_MEMDEBUG nor the SQLITE_WIN32_MALLOC macros are defined. The +** default configuration is to use memory allocation routines in this +** file. +** +** C-preprocessor macro summary: +** +** HAVE_MALLOC_USABLE_SIZE The configure script sets this symbol if +** the malloc_usable_size() interface exists +** on the target platform. Or, this symbol +** can be set manually, if desired. +** If an equivalent interface exists by +** a different name, using a separate -D +** option to rename it. +** +** SQLITE_WITHOUT_ZONEMALLOC Some older macs lack support for the zone +** memory allocator. Set this symbol to enable +** building on older macs. +** +** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of +** _msize() on windows systems. This might +** be necessary when compiling for Delphi, +** for example. + */ +/* #include "sqliteInt.h" */ + +/* +** This version of the memory allocator is the default. It is +** used when no other memory allocator is specified using compile-time +** macros. + */ + +/* +** Use standard C library malloc and free on non-Apple systems. +** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined. + */ + +/* +** The malloc.h header file is needed for malloc_usable_size() function +** on some systems (e.g. Linux). + */ + +/* +** Include the malloc.h header file, if necessary. Also set define macro +** SQLITE_MALLOCSIZE to the appropriate function name, which is _msize() +** for MSVC and malloc_usable_size() for most other systems (e.g. Linux). +** The memory size function can always be overridden manually by defining +** the macro SQLITE_MALLOCSIZE to the desired function name. + */ + +// C documentation +// +// /* +// ** Set the current error code to err_code and clear any prior error message. +// ** Also set iSysErrno (by calling sqlite3System) if the err_code indicates +// ** that would be appropriate. +// */ +func _sqlite3Error(tls *libc.TLS, db uintptr, err_code int32) { + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = err_code + if err_code != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 { + _sqlite3ErrorFinish(tls, db, err_code) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(1) + } +} + +// C documentation +// +// /* +// ** The equivalent of sqlite3Error(db, SQLITE_OK). Clear the error state +// ** and error message. +// */ +func _sqlite3ErrorClear(tls *libc.TLS, db uintptr) { + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_OK + (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(1) + if (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 { + _sqlite3ValueSetNull(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr) + } +} + +// C documentation +// +// /* +// ** Helper function for sqlite3Error() - called rarely. Broken out into +// ** a separate routine to avoid unnecessary register saves on entry to +// ** sqlite3Error(). +// */ +func _sqlite3ErrorFinish(tls *libc.TLS, db uintptr, err_code int32) { + if (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 { + _sqlite3ValueSetNull(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr) + } + _sqlite3SystemError(tls, db, err_code) +} + +// C documentation +// +// /* +// ** Add an error message to pParse->zErrMsg and increment pParse->nErr. +// ** +// ** This function should be used to report any error that occurs while +// ** compiling an SQL statement (i.e. within sqlite3_prepare()). The +// ** last thing the sqlite3_prepare() function does is copy the error +// ** stored by this function into the database handle using sqlite3Error(). +// ** Functions sqlite3Error() or sqlite3ErrorWithMsg() should be used +// ** during statement execution (sqlite3_step() etc.). +// */ +func _sqlite3ErrorMsg(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr) { + var ap Tva_list + var db, zMsg uintptr + _, _, _ = ap, db, zMsg + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(2) + ap = va + zMsg = _sqlite3VMPrintf(tls, db, zFormat, ap) + _ = ap + if (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset < -int32(1) { + (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(1) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr != 0 { + _sqlite3DbFree(tls, db, zMsg) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + } + } else { + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + _sqlite3DbFree(tls, db, (*TParse)(unsafe.Pointer(pParse)).FzErrMsg) + (*TParse)(unsafe.Pointer(pParse)).FzErrMsg = zMsg + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) + (*TParse)(unsafe.Pointer(pParse)).FpWith = uintptr(0) + } +} + +// C documentation +// +// /* +// ** If database connection db is currently parsing SQL, then transfer +// ** error code errCode to that parser if the parser has not already +// ** encountered some other kind of error. +// */ +func _sqlite3ErrorToParser(tls *libc.TLS, db uintptr, errCode int32) (r int32) { + var pParse, v1 uintptr + var v2 bool + _, _, _ = pParse, v1, v2 + if v2 = db == uintptr(0); !v2 { + v1 = (*Tsqlite3)(unsafe.Pointer(db)).FpParse + pParse = v1 + } + if v2 || v1 == uintptr(0) { + return errCode + } + (*TParse)(unsafe.Pointer(pParse)).Frc = errCode + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + return errCode +} + +// C documentation +// +// /* +// ** Set the most recent error code and error string for the sqlite +// ** handle "db". The error code is set to "err_code". +// ** +// ** If it is not NULL, string zFormat specifies the format of the +// ** error string. zFormat and any string tokens that follow it are +// ** assumed to be encoded in UTF-8. +// ** +// ** To clear the most recent error for sqlite handle "db", sqlite3Error +// ** should be called with err_code set to SQLITE_OK and zFormat set +// ** to NULL. +// */ +func _sqlite3ErrorWithMsg(tls *libc.TLS, db uintptr, err_code int32, zFormat uintptr, va uintptr) { + var ap Tva_list + var z, v1 uintptr + var v2 bool + _, _, _, _ = ap, z, v1, v2 + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = err_code + _sqlite3SystemError(tls, db, err_code) + if zFormat == uintptr(0) { + _sqlite3Error(tls, db, err_code) + } else { + if v2 = (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0; !v2 { + v1 = _sqlite3ValueNew(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).FpErr = v1 + } + if v2 || v1 != uintptr(0) { + ap = va + z = _sqlite3VMPrintf(tls, db, zFormat, ap) + _ = ap + _sqlite3ValueSetStr(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr, -int32(1), z, uint8(SQLITE_UTF8), __ccgo_fp(_sqlite3RowSetClear)) + } + } +} + +func _sqlite3ExprAddCollateString(tls *libc.TLS, pParse uintptr, pExpr uintptr, zC uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* s at bp+0 */ TToken + _sqlite3TokenInit(tls, bp, zC) + return _sqlite3ExprAddCollateToken(tls, pParse, pExpr, bp, 0) +} + +// C documentation +// +// /* +// ** Make a transient copy of expression pExpr and then code it using +// ** sqlite3ExprCode(). This routine works just like sqlite3ExprCode() +// ** except that the input expression is guaranteed to be unchanged. +// */ +func _sqlite3ExprCodeCopy(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) { + var db uintptr + _ = db + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pExpr = _sqlite3ExprDup(tls, db, pExpr, 0) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + _sqlite3ExprCode(tls, pParse, pExpr, target) + } + _sqlite3ExprDelete(tls, db, pExpr) +} + +// C documentation +// +// /* +// ** Generate code to move content from registers iFrom...iFrom+nReg-1 +// ** over to iTo..iTo+nReg-1. +// */ +func _sqlite3ExprCodeMove(tls *libc.TLS, pParse uintptr, iFrom int32, iTo int32, nReg int32) { + _sqlite3VdbeAddOp3(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Move), iFrom, iTo, nReg) +} + +// C documentation +// +// /* +// ** Return TRUE if the two expressions have equivalent collating sequences. +// */ +func _sqlite3ExprCollSeqMatch(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uintptr) (r int32) { + var pColl1, pColl2 uintptr + _, _ = pColl1, pColl2 + pColl1 = _sqlite3ExprNNCollSeq(tls, pParse, pE1) + pColl2 = _sqlite3ExprNNCollSeq(tls, pParse, pE2) + return libc.BoolInt32(_sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pColl1)).FzName, (*TCollSeq)(unsafe.Pointer(pColl2)).FzName) == 0) +} + +// C documentation +// +// /* +// ** Like sqlite3ExprCompare() except COLLATE operators at the top-level +// ** are ignored. +// */ +func _sqlite3ExprCompareSkip(tls *libc.TLS, pA uintptr, pB uintptr, iTab int32) (r int32) { + return _sqlite3ExprCompare(tls, uintptr(0), _sqlite3ExprSkipCollate(tls, pA), _sqlite3ExprSkipCollate(tls, pB), iTab) +} + +// C documentation +// +// /* +// ** Arrange to cause pExpr to be deleted when the pParse is deleted. +// ** This is similar to sqlite3ExprDelete() except that the delete is +// ** deferred until the pParse is deleted. +// ** +// ** The pExpr might be deleted immediately on an OOM error. +// ** +// ** Return 0 if the delete was successfully deferred. Return non-zero +// ** if the delete happened immediately because of an OOM. +// */ +func _sqlite3ExprDeferredDelete(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) { + return libc.BoolInt32(uintptr(0) == _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprDeleteGeneric), pExpr)) +} + +func _sqlite3ExprDelete(tls *libc.TLS, db uintptr, p uintptr) { + if p != 0 { + _sqlite3ExprDeleteNN(tls, db, p) + } +} + +func _sqlite3ExprDeleteGeneric(tls *libc.TLS, db uintptr, p uintptr) { + if p != 0 { + _sqlite3ExprDeleteNN(tls, db, p) + } +} + +// C documentation +// +// /* +// ** The following group of routines make deep copies of expressions, +// ** expression lists, ID lists, and select statements. The copies can +// ** be deleted (by being passed to their respective ...Delete() routines) +// ** without effecting the originals. +// ** +// ** The expression list, ID, and source lists return by sqlite3ExprListDup(), +// ** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded +// ** by subsequent calls to sqlite*ListAppend() routines. +// ** +// ** Any tables that the SrcList might point to are not duplicated. +// ** +// ** The flags parameter contains a combination of the EXPRDUP_XXX flags. +// ** If the EXPRDUP_REDUCE flag is set, then the structure returned is a +// ** truncated version of the usual Expr structure that will be stored as +// ** part of the in-memory representation of the database schema. +// */ +func _sqlite3ExprDup(tls *libc.TLS, db uintptr, p uintptr, flags int32) (r uintptr) { + var v1 uintptr + _ = v1 + if p != 0 { + v1 = _exprDup(tls, db, p, flags, uintptr(0)) + } else { + v1 = uintptr(0) + } + return v1 +} + +// C documentation +// +// /* +// ** Walk an expression tree. Return non-zero if the expression is constant +// ** or return zero if the expression involves variables or function calls. +// ** +// ** For the purposes of this function, a double-quoted string (ex: "abc") +// ** is considered a variable but a single-quoted string (ex: 'abc') is +// ** a constant. +// ** +// ** The pParse parameter may be NULL. But if it is NULL, there is no way +// ** to determine if function calls are constant or not, and hence all +// ** function calls will be considered to be non-constant. If pParse is +// ** not NULL, then a function call might be constant, depending on the +// ** function and on its parameters. +// */ +func _sqlite3ExprIsConstant(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + return _exprIsConst(tls, pParse, p, int32(1)) +} + +// C documentation +// +// /* +// ** Walk an expression tree. Return non-zero if +// ** +// ** (1) the expression is constant, and +// ** (2) the expression does originate in the ON or USING clause +// ** of a LEFT JOIN, and +// ** (3) the expression does not contain any EP_FixedCol TK_COLUMN +// ** operands created by the constant propagation optimization. +// ** +// ** When this routine returns true, it indicates that the expression +// ** can be added to the pParse->pConstExpr list and evaluated once when +// ** the prepared statement starts up. See sqlite3ExprCodeRunJustOnce(). +// */ +func _sqlite3ExprIsConstantNotJoin(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + return _exprIsConst(tls, pParse, p, int32(2)) +} + +// C documentation +// +// /* +// ** Return true if expression pExpr is a vector, or false otherwise. +// ** +// ** A vector is defined as any expression that results in two or more +// ** columns of result. Every TK_VECTOR node is an vector because the +// ** parser will not generate a TK_VECTOR with fewer than two entries. +// ** But a TK_SELECT might be either a vector or a scalar. It is only +// ** considered a vector if it has two or more result columns. +// */ +func _sqlite3ExprIsVector(tls *libc.TLS, pExpr uintptr) (r int32) { + return libc.BoolInt32(_sqlite3ExprVectorSize(tls, pExpr) > int32(1)) +} + +func _sqlite3ExprListDelete(tls *libc.TLS, db uintptr, pList uintptr) { + if pList != 0 { + _exprListDeleteNN(tls, db, pList) + } +} + +func _sqlite3ExprListDeleteGeneric(tls *libc.TLS, db uintptr, pList uintptr) { + if pList != 0 { + _exprListDeleteNN(tls, db, pList) + } +} + +// C documentation +// +// /* +// ** Return the collation sequence for the expression pExpr. If +// ** there is no defined collating sequence, return a pointer to the +// ** default collation sequence. +// ** +// ** See also: sqlite3ExprCollSeq() +// ** +// ** The sqlite3ExprCollSeq() routine works the same except that it +// ** returns NULL if there is no defined collation. +// */ +func _sqlite3ExprNNCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r uintptr) { + var p uintptr + _ = p + p = _sqlite3ExprCollSeq(tls, pParse, pExpr) + if p == uintptr(0) { + p = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FpDfltColl + } + return p +} + +// C documentation +// +// /* +// ** Set the Expr.nHeight variable using the exprSetHeight() function. If +// ** the height is greater than the maximum allowed expression depth, +// ** leave an error in pParse. +// ** +// ** Also propagate all EP_Propagate flags from the Expr.x.pList into +// ** Expr.flags. +// */ +func _sqlite3ExprSetHeightAndFlags(tls *libc.TLS, pParse uintptr, p uintptr) { + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + _exprSetHeight(tls, p) + _sqlite3ExprCheckHeight(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FnHeight) +} + +// C documentation +// +// /* +// ** No-op routine for the parse-tree walker. +// ** +// ** When this routine is the Walker.xExprCallback then expression trees +// ** are walked without any actions being taken at each node. Presumably, +// ** when this routine is used for Walker.xExprCallback then +// ** Walker.xSelectCallback is set to do something useful for every +// ** subquery in the parser tree. +// */ +func _sqlite3ExprWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) (r int32) { + _ = NotUsed + _ = NotUsed2 + return WRC_Continue +} + +// C documentation +// +// /* +// ** Calls to sqlite3FaultSim() are used to simulate a failure during testing, +// ** or to bypass normal error detection during testing in order to let +// ** execute proceed further downstream. +// ** +// ** In deployment, sqlite3FaultSim() *always* return SQLITE_OK (0). The +// ** sqlite3FaultSim() function only returns non-zero during testing. +// ** +// ** During testing, if the test harness has set a fault-sim callback using +// ** a call to sqlite3_test_control(SQLITE_TESTCTRL_FAULT_INSTALL), then +// ** each call to sqlite3FaultSim() is relayed to that application-supplied +// ** callback and the integer return value form the application-supplied +// ** callback is returned by sqlite3FaultSim(). +// ** +// ** The integer argument to sqlite3FaultSim() is a code to identify which +// ** sqlite3FaultSim() instance is being invoked. Each call to sqlite3FaultSim() +// ** should have a unique code. To prevent legacy testing applications from +// ** breaking, the codes should not be changed or reused. +// */ +func _sqlite3FaultSim(tls *libc.TLS, iTest int32) (r int32) { + var xCallback uintptr + var v1 int32 + _, _ = xCallback, v1 + xCallback = _sqlite3Config.FxTestCallback + if xCallback != 0 { + v1 = (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{xCallback})))(tls, iTest) + } else { + v1 = SQLITE_OK + } + return v1 +} + +// C documentation +// +// /* +// ** The token *pName contains the name of a database (either "main" or +// ** "temp" or the name of an attached db). This routine returns the +// ** index of the named database in db->aDb[], or -1 if the named db +// ** does not exist. +// */ +func _sqlite3FindDb(tls *libc.TLS, db uintptr, pName uintptr) (r int32) { + var i int32 + var zName uintptr + _, _ = i, zName /* Name we are searching for */ + zName = _sqlite3NameFromToken(tls, db, pName) + i = _sqlite3FindDbName(tls, db, zName) + _sqlite3DbFree(tls, db, zName) + return i +} + +// C documentation +// +// /* +// ** This function is called when deleting or updating a row to implement +// ** any required CASCADE, SET NULL or SET DEFAULT actions. +// */ +func _sqlite3FkActions(tls *libc.TLS, pParse uintptr, pTab uintptr, pChanges uintptr, regOld int32, aChange uintptr, bChngRowid int32) { + var pAct, pFKey uintptr + _, _ = pAct, pFKey + /* If foreign-key support is enabled, iterate through all FKs that + ** refer to table pTab. If there is an action associated with the FK + ** for this operation (either update or delete), invoke the associated + ** trigger sub-program. */ + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_ForeignKeys) != 0 { /* Iterator variable */ + pFKey = _sqlite3FkReferences(tls, pTab) + for { + if !(pFKey != 0) { + break + } + if aChange == uintptr(0) || _fkParentIsModified(tls, pTab, pFKey, aChange, bChngRowid) != 0 { + pAct = _fkActionTrigger(tls, pParse, pTab, pFKey, pChanges) + if pAct != 0 { + _sqlite3CodeRowTriggerDirect(tls, pParse, pAct, pTab, regOld, int32(OE_Abort), 0) + } + } + goto _1 + _1: + ; + pFKey = (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo + } + } +} + +// C documentation +// +// /* +// ** Argument zFmt is a printf() style format string. This function performs +// ** the printf() style processing, then appends the results to buffer pBuf. +// ** +// ** Like sqlite3Fts5BufferAppendString(), this function ensures that the byte +// ** following the buffer data is set to 0x00, even though this byte is not +// ** included in the pBuf->n count. +// */ +func _sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFmt uintptr, va uintptr) { + var ap Tva_list + var zTmp uintptr + _, _ = ap, zTmp + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + ap = va + zTmp = Xsqlite3_vmprintf(tls, zFmt, ap) + _ = ap + if zTmp == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } else { + _sqlite3Fts5BufferAppendString(tls, pRc, pBuf, zTmp) + Xsqlite3_free(tls, zTmp) + } + } +} + +// C documentation +// +// /* +// ** Zero the contents of the buffer object. But do not free the associated +// ** memory allocation. +// */ +func _sqlite3Fts5BufferZero(tls *libc.TLS, pBuf uintptr) { + (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn = 0 +} + +// C documentation +// +// /* +// ** Clear any locale configured by an earlier call to sqlite3Fts5SetLocale(). +// */ +func _sqlite3Fts5ClearLocale(tls *libc.TLS, pConfig uintptr) { + _sqlite3Fts5SetLocale(tls, pConfig, uintptr(0), 0) +} + +// C documentation +// +// /* +// ** Set (*pConfig->pzErrmsg) to point to an sqlite3_malloc()ed buffer +// ** containing the error message created using printf() style formatting +// ** string zFmt and its trailing arguments. +// */ +func _sqlite3Fts5ConfigErrmsg(tls *libc.TLS, pConfig uintptr, zFmt uintptr, va uintptr) { + var ap Tva_list + var zMsg uintptr + _, _ = ap, zMsg /* ... printf arguments */ + zMsg = uintptr(0) + ap = va + zMsg = Xsqlite3_vmprintf(tls, zFmt, ap) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg != 0 { + **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = zMsg + } else { + Xsqlite3_free(tls, zMsg) + } + _ = ap +} + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** + */ + +/* #include "fts5Int.h" */ +/* #include "fts5parse.h" */ + +/* +** All token types in the generated fts5parse.h file are greater than 0. + */ + +func _sqlite3Fts5ExprCheckPoslists(tls *libc.TLS, pExpr uintptr, iRowid Ti64) { + _fts5ExprCheckPoslists(tls, (*TFts5Expr)(unsafe.Pointer(pExpr)).FpRoot, iRowid) +} + +func _sqlite3Fts5ExprEof(tls *libc.TLS, p uintptr) (r int32) { + return (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(p)).FpRoot)).FbEof +} + +// C documentation +// +// /* +// ** Begin iterating through the set of documents in index pIdx matched by +// ** the MATCH expression passed as the first argument. If the "bDesc" +// ** parameter is passed a non-zero value, iteration is in descending rowid +// ** order. Or, if it is zero, in ascending order. +// ** +// ** If iterating in ascending rowid order (bDesc==0), the first document +// ** visited is that with the smallest rowid that is larger than or equal +// ** to parameter iFirst. Or, if iterating in ascending order (bDesc==1), +// ** then the first document visited must have a rowid smaller than or +// ** equal to iFirst. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code otherwise. It +// ** is not considered an error if the query does not match any documents. +// */ +func _sqlite3Fts5ExprFirst(tls *libc.TLS, p uintptr, pIdx uintptr, iFirst Ti64, iLast Ti64, bDesc int32) (r int32) { + var pRoot uintptr + var rc int32 + _, _ = pRoot, rc + pRoot = (*TFts5Expr)(unsafe.Pointer(p)).FpRoot /* Return code */ + (*TFts5Expr)(unsafe.Pointer(p)).FpIndex = pIdx + (*TFts5Expr)(unsafe.Pointer(p)).FbDesc = bDesc + rc = _fts5ExprNodeFirst(tls, p, pRoot) + /* If not at EOF but the current rowid occurs earlier than iFirst in + ** the iteration order, move to document iFirst or later. */ + if rc == SQLITE_OK && 0 == (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbEof && _fts5RowidCmp(tls, p, (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iFirst) < 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})))(tls, p, pRoot, int32(1), iFirst) + } + /* If the iterator is not at a real match, skip forward until it is. */ + for (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbNomatch != 0 && rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})))(tls, p, pRoot, 0, int64(libc.Int32FromInt32(0))) + } + if _fts5RowidCmp(tls, p, (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iLast) > 0 { + (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbEof = int32(1) + } + return rc +} + +// C documentation +// +// /* +// ** Free the expression object passed as the only argument. +// */ +func _sqlite3Fts5ExprFree(tls *libc.TLS, p uintptr) { + if p != 0 { + _sqlite3Fts5ParseNodeFree(tls, (*TFts5Expr)(unsafe.Pointer(p)).FpRoot) + Xsqlite3_free(tls, (*TFts5Expr)(unsafe.Pointer(p)).FapExprPhrase) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** This is called during initialization to register the fts5_expr() scalar +// ** UDF with the SQLite handle passed as the only argument. +// */ +func _sqlite3Fts5ExprInit(tls *libc.TLS, pGlobal uintptr, db uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + _ = pGlobal + _ = db + /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and + ** sqlite3Fts5ParserFallback() are unused */ + _ = __ccgo_fp(_sqlite3Fts5ParserFallback) + return rc +} + +// C documentation +// +// /* +// ** Move to the next document +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code otherwise. It +// ** is not considered an error if the query does not match any documents. +// */ +func _sqlite3Fts5ExprNext(tls *libc.TLS, p uintptr, iLast Ti64) (r int32) { + var pRoot uintptr + var rc int32 + _, _ = pRoot, rc + pRoot = (*TFts5Expr)(unsafe.Pointer(p)).FpRoot + for cond := true; cond; cond = (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbNomatch != 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})))(tls, p, pRoot, 0, int64(libc.Int32FromInt32(0))) + } + if _fts5RowidCmp(tls, p, (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iLast) > 0 { + (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbEof = int32(1) + } + return rc +} + +// C documentation +// +// /* +// ** Return the number of phrases in expression pExpr. +// */ +func _sqlite3Fts5ExprPhraseCount(tls *libc.TLS, pExpr uintptr) (r int32) { + var v1 int32 + _ = v1 + if pExpr != 0 { + v1 = (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase + } else { + v1 = 0 + } + return v1 +} + +func _sqlite3Fts5ExprRowid(tls *libc.TLS, p uintptr) (r Ti64) { + return (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(p)).FpRoot)).FiRowid +} + +func _sqlite3Fts5FlushToDisk(tls *libc.TLS, pTab uintptr) (r int32) { + _fts5TripCursors(tls, pTab) + return _sqlite3Fts5StorageSync(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage) +} + +// C documentation +// +// /* +// ** Read a 64-bit variable-length integer from memory starting at p[0]. +// ** Return the number of bytes read. The value is stored in *v. +// */ +func _sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) (r Tu8) { + var a, b, s Tu32 + _, _, _ = a, b, s + a = uint32(**(**uint8)(__ccgo_up(p))) + /* a: p0 (unmasked) */ + if !(a&libc.Uint32FromInt32(0x80) != 0) { + **(**Tu64)(__ccgo_up(v)) = uint64(a) + return uint8(1) + } + p = p + 1 + b = uint32(**(**uint8)(__ccgo_up(p))) + /* b: p1 (unmasked) */ + if !(b&libc.Uint32FromInt32(0x80) != 0) { + a = a & uint32(0x7f) + a = a << int32(7) + a = a | b + **(**Tu64)(__ccgo_up(v)) = uint64(a) + return uint8(2) + } + /* Verify that constants are precomputed correctly */ + p = p + 1 + a = a << int32(14) + a = a | uint32(**(**uint8)(__ccgo_up(p))) + /* a: p0<<14 | p2 (unmasked) */ + if !(a&libc.Uint32FromInt32(0x80) != 0) { + a = a & uint32(SLOT_2_0) + b = b & uint32(0x7f) + b = b << int32(7) + a = a | b + **(**Tu64)(__ccgo_up(v)) = uint64(a) + return uint8(3) + } + /* CSE1 from below */ + a = a & uint32(SLOT_2_0) + p = p + 1 + b = b << int32(14) + b = b | uint32(**(**uint8)(__ccgo_up(p))) + /* b: p1<<14 | p3 (unmasked) */ + if !(b&libc.Uint32FromInt32(0x80) != 0) { + b = b & uint32(SLOT_2_0) + /* moved CSE1 up */ + /* a &= (0x7f<<14)|(0x7f); */ + a = a << int32(7) + a = a | b + **(**Tu64)(__ccgo_up(v)) = uint64(a) + return uint8(4) + } + /* a: p0<<14 | p2 (masked) */ + /* b: p1<<14 | p3 (unmasked) */ + /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */ + /* moved CSE1 up */ + /* a &= (0x7f<<14)|(0x7f); */ + b = b & uint32(SLOT_2_0) + s = a + /* s: p0<<14 | p2 (masked) */ + p = p + 1 + a = a << int32(14) + a = a | uint32(**(**uint8)(__ccgo_up(p))) + /* a: p0<<28 | p2<<14 | p4 (unmasked) */ + if !(a&libc.Uint32FromInt32(0x80) != 0) { + /* we can skip these cause they were (effectively) done above in calc'ing s */ + /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */ + /* b &= (0x7f<<14)|(0x7f); */ + b = b << int32(7) + a = a | b + s = s >> int32(18) + **(**Tu64)(__ccgo_up(v)) = uint64(s)<> int32(18) + **(**Tu64)(__ccgo_up(v)) = uint64(s)<> int32(11) + **(**Tu64)(__ccgo_up(v)) = uint64(s)<> int32(4) + **(**Tu64)(__ccgo_up(v)) = uint64(s)<> int32(3) + s = s | b + **(**Tu64)(__ccgo_up(v)) = uint64(s)<>libc.Int32FromInt32(7)&uint64(0x7f) | uint64(0x80)) + **(**uint8)(__ccgo_up(p + 1)) = uint8(v & uint64(0x7f)) + return int32(2) + } + return _fts5PutVarint64(tls, p, v) +} + +func _sqlite3Fts5StorageConfigValue(tls *libc.TLS, p uintptr, z uintptr, pVal uintptr, iVal int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iNew, rc int32 + var _ /* pReplace at bp+0 */ uintptr + _, _ = iNew, rc + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_REPLACE_CONFIG), bp, uintptr(0)) + if rc == SQLITE_OK { + Xsqlite3_bind_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), z, -int32(1), libc.UintptrFromInt32(0)) + if pVal != 0 { + Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp)), int32(2), pVal) + } else { + Xsqlite3_bind_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(2), iVal) + } + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + Xsqlite3_bind_null(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + } + if rc == SQLITE_OK && pVal != 0 { + iNew = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie + int32(1) + rc = _sqlite3Fts5IndexSetCookie(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, iNew) + if rc == SQLITE_OK { + (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie = iNew + } + } + return rc +} + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** + */ + +/* #include "fts5Int.h" */ + +/************************************************************************** +** Start of ascii tokenizer implementation. + */ + +// C documentation +// +// /* +// ** Remove a row from the FTS table. +// */ +func _sqlite3Fts5StorageDelete(tls *libc.TLS, p uintptr, iDel Ti64, apVal uintptr, bSaveRow int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pConfig uintptr + var rc int32 + var _ /* pDel at bp+0 */ uintptr + _, _ = pConfig, rc + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _fts5StorageLoadTotals(tls, p, int32(1)) + /* Delete the index records */ + if rc == SQLITE_OK { + rc = _sqlite3Fts5IndexBeginWrite(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, int32(1), iDel) + } + if rc == SQLITE_OK { + if (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbContentlessDelete != 0 { + rc = _fts5StorageContentlessDelete(tls, p, iDel) + if rc == SQLITE_OK && bSaveRow != 0 && (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FeContent == int32(FTS5_CONTENT_UNINDEXED) { + rc = _sqlite3Fts5StorageFindDeleteRow(tls, p, iDel) + } + } else { + rc = _fts5StorageDeleteFromIndex(tls, p, iDel, apVal, bSaveRow) + } + } + /* Delete the %_docsize record */ + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_DELETE_DOCSIZE), bp, uintptr(0)) + if rc == SQLITE_OK { + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iDel) + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + /* Delete the %_content record */ + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL || (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_UNINDEXED) { + if rc == SQLITE_OK { + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_DELETE_CONTENT), bp, uintptr(0)) + } + if rc == SQLITE_OK { + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iDel) + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + return rc +} + +// C documentation +// +// /* +// ** Argument aCol points to an array of integers containing one entry for +// ** each table column. This function reads the %_docsize record for the +// ** specified rowid and populates aCol[] with the results. +// ** +// ** An SQLite error code is returned if an error occurs, or SQLITE_OK +// ** otherwise. +// */ +func _sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid Ti64, aCol uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aBlob uintptr + var bCorrupt, nBlob, nCol, rc int32 + var _ /* pLookup at bp+0 */ uintptr + _, _, _, _, _ = aBlob, bCorrupt, nBlob, nCol, rc + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol /* Number of user columns in table */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Return Code */ + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_LOOKUP_DOCSIZE), bp, uintptr(0)) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + bCorrupt = int32(1) + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iRowid) + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + aBlob = Xsqlite3_column_blob(tls, **(**uintptr)(__ccgo_up(bp)), 0) + nBlob = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), 0) + if 0 == _fts5StorageDecodeSizeArray(tls, aCol, nCol, aBlob, nBlob) { + bCorrupt = 0 + } + } + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + if bCorrupt != 0 && rc == SQLITE_OK { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= float64(9.223372036854776e+18) { + return -int32(1) + } + y = int64(r) + if i < y { + return -int32(1) + } + if i > y { + return +libc.Int32FromInt32(1) + } + if float64(i) < r { + v1 = -int32(1) + } else { + v1 = libc.BoolInt32(float64(i) > r) + } + return v1 + } + return r1 +} + +// C documentation +// +// /* +// ** Invoke the given busy handler. +// ** +// ** This routine is called when an operation failed to acquire a +// ** lock on VFS file pFile. +// ** +// ** If this routine returns non-zero, the lock is retried. If it +// ** returns 0, the operation aborts with an SQLITE_BUSY error. +// */ +func _sqlite3InvokeBusyHandler(tls *libc.TLS, p uintptr) (r int32) { + var rc int32 + _ = rc + if (*TBusyHandler)(unsafe.Pointer(p)).FxBusyHandler == uintptr(0) || (*TBusyHandler)(unsafe.Pointer(p)).FnBusy < 0 { + return 0 + } + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TBusyHandler)(unsafe.Pointer(p)).FxBusyHandler})))(tls, (*TBusyHandler)(unsafe.Pointer(p)).FpBusyArg, (*TBusyHandler)(unsafe.Pointer(p)).FnBusy) + if rc == 0 { + (*TBusyHandler)(unsafe.Pointer(p)).FnBusy = -int32(1) + } else { + (*TBusyHandler)(unsafe.Pointer(p)).FnBusy = (*TBusyHandler)(unsafe.Pointer(p)).FnBusy + 1 + } + return rc +} + +// C documentation +// +// /* +// ** Return true if CollSeq is the default built-in BINARY. +// */ +func _sqlite3IsBinary(tls *libc.TLS, p uintptr) (r int32) { + return libc.BoolInt32(p == uintptr(0) || (*TCollSeq)(unsafe.Pointer(p)).FxCmp == __ccgo_fp(_binCollFunc)) +} + +// C documentation +// +// /* +// ** Return true if the VFS is the memvfs. +// */ +func _sqlite3IsMemdb(tls *libc.TLS, pVfs uintptr) (r int32) { + return libc.BoolInt32(pVfs == uintptr(unsafe.Pointer(&_memdb_vfs))) +} + +// C documentation +// +// /* +// ** The file-handle passed as the only argument is open on a journal file. +// ** Return true if this "journal file" is currently stored in heap memory, +// ** or false otherwise. +// */ +func _sqlite3JournalIsInMemory(tls *libc.TLS, p uintptr) (r int32) { + return libc.BoolInt32((*Tsqlite3_file)(unsafe.Pointer(p)).FpMethods == uintptr(unsafe.Pointer(&_MemJournalMethods))) +} + +// C documentation +// +// /* +// ** Make a new pointer to a KeyInfo object +// */ +func _sqlite3KeyInfoRef(tls *libc.TLS, p uintptr) (r uintptr) { + if p != 0 { + (*TKeyInfo)(unsafe.Pointer(p)).FnRef = (*TKeyInfo)(unsafe.Pointer(p)).FnRef + 1 + } + return p +} + +// C documentation +// +// /* +// ** Deallocate a KeyInfo object +// */ +func _sqlite3KeyInfoUnref(tls *libc.TLS, p uintptr) { + if p != 0 { + (*TKeyInfo)(unsafe.Pointer(p)).FnRef = (*TKeyInfo)(unsafe.Pointer(p)).FnRef - 1 + if (*TKeyInfo)(unsafe.Pointer(p)).FnRef == uint32(0) { + _sqlite3DbNNFreeNN(tls, (*TKeyInfo)(unsafe.Pointer(p)).Fdb, p) + } + } +} + +func _sqlite3KeywordCode(tls *libc.TLS, z uintptr, n int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* id at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = int32(TK_ID) + if n >= int32(2) { + _keywordCode(tls, z, int64(n), bp) + } + return **(**int32)(__ccgo_up(bp)) +} + +func _sqlite3LockAndPrepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags Tu32, pOld uintptr, ppStmt uintptr, pzTail uintptr) (r int32) { + var cnt, rc int32 + var v1, v2 bool + _, _, _, _ = cnt, rc, v1, v2 + cnt = 0 + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + if !(_sqlite3SafetyCheckOk(tls, db) != 0) || zSql == uintptr(0) { + return _sqlite3MisuseError(tls, int32(148620)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3BtreeEnterAll(tls, db) + for { + /* Make multiple attempts to compile the SQL, until it either succeeds + ** or encounters a permanent error. A schema problem after one schema + ** reset is considered a permanent error. */ + rc = _sqlite3Prepare(tls, db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail) + if rc == SQLITE_OK || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + break + } + cnt = cnt + 1 + goto _3 + _3: + ; + if v2 = rc == libc.Int32FromInt32(SQLITE_ERROR)|libc.Int32FromInt32(2)< uint64(255) { + y = int16(int32(y) + libc.Int32FromInt32(40)) + x = x >> uint64(4) + } /*OPTIMIZATION-IF-TRUE*/ + for x > uint64(15) { + y = int16(int32(y) + libc.Int32FromInt32(10)) + x = x >> uint64(1) + } + } + return int16(int32(_a[x&uint64(7)]) + int32(y) - int32(10)) +} + +// C documentation +// +// /* +// ** Print into memory obtained from sqliteMalloc(). Use the internal +// ** %-conversion extensions. +// */ +func _sqlite3MPrintf(tls *libc.TLS, db uintptr, zFormat uintptr, va uintptr) (r uintptr) { + var ap Tva_list + var z uintptr + _, _ = ap, z + ap = va + z = _sqlite3VMPrintf(tls, db, zFormat, ap) + _ = ap + return z +} + +// C documentation +// +// /* +// ** Trigger the alarm +// */ +func _sqlite3MallocAlarm(tls *libc.TLS, nByte int32) { + if _mem0.FalarmThreshold <= 0 { + return + } + Xsqlite3_mutex_leave(tls, _mem0.Fmutex) + Xsqlite3_release_memory(tls, nByte) + Xsqlite3_mutex_enter(tls, _mem0.Fmutex) +} + +// C documentation +// +// /* +// ** Return the memory allocator mutex. sqlite3_status() needs it. +// */ +func _sqlite3MallocMutex(tls *libc.TLS) (r uintptr) { + return _mem0.Fmutex +} + +// C documentation +// +// /* +// ** Return the size of a memory allocation previously obtained from +// ** sqlite3Malloc() or sqlite3_malloc(). +// */ +func _sqlite3MallocSize(tls *libc.TLS, p uintptr) (r int32) { + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxSize})))(tls, p) +} + +// C documentation +// +// /* +// ** Like free() but works for allocations obtained from sqlite3MemMalloc() +// ** or sqlite3MemRealloc(). +// ** +// ** For this low-level routine, we already know that pPrior!=0 since +// ** cases where pPrior==0 will have been intercepted and dealt with +// ** by higher-level routines. +// */ +func _sqlite3MemFree(tls *libc.TLS, pPrior uintptr) { + var p uintptr + _ = p + p = pPrior + p -= 8 + libc.Xfree(tls, p) +} + +// C documentation +// +// /* +// ** Initialize this module. +// */ +func _sqlite3MemInit(tls *libc.TLS, NotUsed uintptr) (r int32) { + _ = NotUsed + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Open an in-memory journal file. +// */ +func _sqlite3MemJournalOpen(tls *libc.TLS, pJfd uintptr) { + _sqlite3JournalOpen(tls, uintptr(0), uintptr(0), pJfd, 0, -int32(1)) +} + +// C documentation +// +// /* +// ** This routine acts as a bridge from sqlite3VdbeRealValue() to +// ** sqlite3VdbeRealValueRC, allowing sqlite3VdbeRealValue() to avoid +// ** stuffing values onto the stack. +// */ +func _sqlite3MemRealValueNoRC(tls *libc.TLS, pMem uintptr) (r float64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* r at bp+0 */ float64 + _sqlite3MemRealValueRC(tls, pMem, bp) + return **(**float64)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Round up a request size to the next valid allocation size. +// */ +func _sqlite3MemRoundup(tls *libc.TLS, n int32) (r int32) { + return (n + int32(7)) & ^libc.Int32FromInt32(7) +} + +// C documentation +// +// /* +// ** This routine is the only routine in this file with external linkage. +// ** +// ** Populate the low-level memory allocation function pointers in +// ** sqlite3GlobalConfig.m with pointers to the routines in this file. +// */ +func _sqlite3MemSetDefault(tls *libc.TLS) { + bp := tls.Alloc(16) + defer tls.Free(16) + Xsqlite3_config(tls, int32(SQLITE_CONFIG_MALLOC), libc.VaList(bp+8, uintptr(unsafe.Pointer(&_defaultMethods)))) +} + +// C documentation +// +// /* +// ** Deinitialize this module. +// */ +func _sqlite3MemShutdown(tls *libc.TLS, NotUsed uintptr) { + _ = NotUsed + return +} + +// C documentation +// +// /* +// ** Report the allocated size of a prior return from xMalloc() +// ** or xRealloc(). +// */ +func _sqlite3MemSize(tls *libc.TLS, pPrior uintptr) (r int32) { + var p uintptr + _ = p + p = pPrior + p -= 8 + return int32(**(**Tsqlite3_int64)(__ccgo_up(p))) +} + +func _sqlite3MulInt64(tls *libc.TLS, pA uintptr, iB Ti64) (r int32) { + var iA Ti64 + _ = iA + iA = **(**Ti64)(__ccgo_up(pA)) + if iB > 0 { + if iA > (libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< 0 { + if iB < (int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< (libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>64 & 0xffffffff) (the middle 32 bits of A*B) +// ** into *pLo. Return the upper 64 bits of A*B. +// ** +// ** The lower 64 bits of A*B are discarded. +// */ +func _sqlite3Multiply160(tls *libc.TLS, a Tu64, aLo Tu32, b Tu64, pLo uintptr) (r Tu64) { + var r1, r2, r3, r4, x0, x0y0, x0y1, x1, x1y0, x1y1, x2, x2y0, x2y1, y0, y1 Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = r1, r2, r3, r4, x0, x0y0, x0y1, x1, x1y0, x1y1, x2, x2y0, x2y1, y0, y1 + x2 = a >> int32(32) + x1 = a & uint64(0xffffffff) + x0 = uint64(aLo) + y1 = b >> int32(32) + y0 = b & uint64(0xffffffff) + x2y1 = x2 * y1 + r4 = x2y1 >> int32(32) + x2y0 = x2 * y0 + x1y1 = x1 * y1 + r3 = x2y1&uint64(0xffffffff) + x2y0>>libc.Int32FromInt32(32) + x1y1>>libc.Int32FromInt32(32) + x1y0 = x1 * y0 + x0y1 = x0 * y1 + r2 = x2y0&uint64(0xffffffff) + x1y1&uint64(0xffffffff) + x1y0>>libc.Int32FromInt32(32) + x0y1>>libc.Int32FromInt32(32) + x0y0 = x0 * y0 + r1 = x1y0&uint64(0xffffffff) + x0y1&uint64(0xffffffff) + x0y0>>libc.Int32FromInt32(32) + r2 = r2 + r1>>int32(32) + r3 = r3 + r2>>int32(32) + **(**Tu32)(__ccgo_up(pLo)) = uint32(r2 & uint64(0xffffffff)) + return r4<iDataVersion value +// */ +func _sqlite3PagerDataVersion(tls *libc.TLS, pPager uintptr) (r Tu32) { + return (*TPager)(unsafe.Pointer(pPager)).FiDataVersion +} + +// C documentation +// +// /* +// ** Return true if page pgno can be read directly from the database file +// ** by the b-tree layer. This is the case if: +// ** +// ** (1) the database file is open +// ** (2) the VFS for the database is able to do unaligned sub-page reads +// ** (3) there are no dirty pages in the cache, and +// ** (4) the desired page is not currently in the wal file. +// */ +func _sqlite3PagerDirectReadOk(tls *libc.TLS, pPager uintptr, pgno TPgno) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* iRead at bp+0 */ Tu32 + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods == uintptr(0) { + return 0 + } /* Case (1) */ + if _sqlite3PCacheIsDirty(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) != 0 { + return 0 + } /* Failed (3) */ + if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + _sqlite3WalFindFrame(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pgno, bp) + if **(**Tu32)(__ccgo_up(bp)) != 0 { + return 0 + } /* Case (4) */ + } + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods)).FxDeviceCharacteristics})))(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd)&int32(SQLITE_IOCAP_SUBPAGE_READ) == 0 { + return 0 /* Case (2) */ + } + return int32(1) +} + +// C documentation +// +// /* +// ** This function may only be called while a write-transaction is active in +// ** rollback. If the connection is in WAL mode, this call is a no-op. +// ** Otherwise, if the connection does not already have an EXCLUSIVE lock on +// ** the database file, an attempt is made to obtain one. +// ** +// ** If the EXCLUSIVE lock is already held or the attempt to obtain it is +// ** successful, or the connection is in WAL mode, SQLITE_OK is returned. +// ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is +// ** returned. +// */ +func _sqlite3PagerExclusiveLock(tls *libc.TLS, pPager uintptr) (r int32) { + var rc int32 + _ = rc + rc = (*TPager)(unsafe.Pointer(pPager)).FerrCode + if rc == SQLITE_OK { + if 0 == libc.BoolInt32((*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) { + rc = _pager_wait_on_lock(tls, pPager, int32(EXCLUSIVE_LOCK)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Return the file handle for the database file associated +// ** with the pager. This might return NULL if the file has +// ** not yet been opened. +// */ +func _sqlite3PagerFile(tls *libc.TLS, pPager uintptr) (r uintptr) { + return (*TPager)(unsafe.Pointer(pPager)).Ffd +} + +// C documentation +// +// /* +// ** Return the full pathname of the database file. +// ** +// ** Except, if the pager is in-memory only, then return an empty string if +// ** nullIfMemDb is true. This routine is called with nullIfMemDb==1 when +// ** used to report the filename to the user, for compatibility with legacy +// ** behavior. But when the Btree needs to know the filename for matching to +// ** shared cache, it uses nullIfMemDb==0 so that in-memory databases can +// ** participate in shared-cache. +// ** +// ** The return value to this routine is always safe to use with +// ** sqlite3_uri_parameter() and sqlite3_filename_database() and friends. +// */ +func _sqlite3PagerFilename(tls *libc.TLS, pPager uintptr, nullIfMemDb int32) (r uintptr) { + if nullIfMemDb != 0 && ((*TPager)(unsafe.Pointer(pPager)).FmemDb != 0 || _sqlite3IsMemdb(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs) != 0) { + return uintptr(unsafe.Pointer(&_zFake)) + 4 + } else { + return (*TPager)(unsafe.Pointer(pPager)).FzFilename + } + return r +} + +// C documentation +// +// /* +// ** Flush all unreferenced dirty pages to disk. +// */ +func _sqlite3PagerFlush(tls *libc.TLS, pPager uintptr) (r int32) { + var pList, pNext uintptr + var rc int32 + _, _, _ = pList, pNext, rc + rc = (*TPager)(unsafe.Pointer(pPager)).FerrCode + if !((*TPager)(unsafe.Pointer(pPager)).FmemDb != 0) { + pList = _sqlite3PcacheDirtyList(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + for rc == SQLITE_OK && pList != 0 { + pNext = (*TPgHdr)(unsafe.Pointer(pList)).FpDirty + if (*TPgHdr)(unsafe.Pointer(pList)).FnRef == 0 { + rc = _pagerStress(tls, pPager, pList) + } + pList = pNext + } + } + return rc +} + +// C documentation +// +// /* Dispatch all page fetch requests to the appropriate getter method. +// */ +func _sqlite3PagerGet(tls *libc.TLS, pPager uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) { + /* Normal, high-speed version of sqlite3PagerGet() */ + return (*(*func(*libc.TLS, uintptr, TPgno, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPager)(unsafe.Pointer(pPager)).FxGet})))(tls, pPager, pgno, ppPage, flags) +} + +// C documentation +// +// /* +// ** Return a pointer to the data for the specified page. +// */ +func _sqlite3PagerGetData(tls *libc.TLS, pPg uintptr) (r uintptr) { + return (*TDbPage)(unsafe.Pointer(pPg)).FpData +} + +// C documentation +// +// /* +// ** Return a pointer to the Pager.nExtra bytes of "extra" space +// ** allocated along with the specified page. +// */ +func _sqlite3PagerGetExtra(tls *libc.TLS, pPg uintptr) (r uintptr) { + return (*TDbPage)(unsafe.Pointer(pPg)).FpExtra +} + +// C documentation +// +// /* +// ** Return true if this is an in-memory or temp-file backed pager. +// */ +func _sqlite3PagerIsMemdb(tls *libc.TLS, pPager uintptr) (r int32) { + return libc.BoolInt32((*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 || (*TPager)(unsafe.Pointer(pPager)).FmemVfs != 0) +} + +// C documentation +// +// /* +// ** Return TRUE if the database file is opened read-only. Return FALSE +// ** if the database is (in theory) writable. +// */ +func _sqlite3PagerIsreadonly(tls *libc.TLS, pPager uintptr) (r Tu8) { + return (*TPager)(unsafe.Pointer(pPager)).FreadOnly +} + +// C documentation +// +// /* +// ** Get/set the size-limit used for persistent journal files. +// ** +// ** Setting the size limit to -1 means no limit is enforced. +// ** An attempt to set a limit smaller than -1 is a no-op. +// */ +func _sqlite3PagerJournalSizeLimit(tls *libc.TLS, pPager uintptr, iLimit Ti64) (r Ti64) { + if iLimit >= int64(-int32(1)) { + (*TPager)(unsafe.Pointer(pPager)).FjournalSizeLimit = iLimit + _sqlite3WalLimit(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, iLimit) + } + return (*TPager)(unsafe.Pointer(pPager)).FjournalSizeLimit +} + +// C documentation +// +// /* +// ** Return the full pathname of the journal file. +// */ +func _sqlite3PagerJournalname(tls *libc.TLS, pPager uintptr) (r uintptr) { + return (*TPager)(unsafe.Pointer(pPager)).FzJournal +} + +// C documentation +// +// /* +// ** Return the file handle for the journal file (if it exists). +// ** This will be either the rollback journal or the WAL file. +// */ +func _sqlite3PagerJrnlFile(tls *libc.TLS, pPager uintptr) (r uintptr) { + var v1 uintptr + _ = v1 + if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + v1 = _sqlite3WalFile(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) + } else { + v1 = (*TPager)(unsafe.Pointer(pPager)).Fjfd + } + return v1 +} + +// C documentation +// +// /* +// ** Acquire a page if it is already in the in-memory cache. Do +// ** not read the page from disk. Return a pointer to the page, +// ** or 0 if the page is not in cache. +// ** +// ** See also sqlite3PagerGet(). The difference between this routine +// ** and sqlite3PagerGet() is that _get() will go to the disk and read +// ** in the page if the page is not already in cache. This routine +// ** returns NULL if the page is not in cache or if a disk I/O error +// ** has ever happened. +// */ +func _sqlite3PagerLookup(tls *libc.TLS, pPager uintptr, pgno TPgno) (r uintptr) { + var pPage uintptr + _ = pPage + pPage = _sqlite3PcacheFetch(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, pgno, 0) + if pPage == uintptr(0) { + return uintptr(0) + } + return _sqlite3PcacheFetchFinish(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, pgno, pPage) +} + +// C documentation +// +// /* +// ** Attempt to set the maximum database page count if mxPage is positive. +// ** Make no changes if mxPage is zero or negative. And never reduce the +// ** maximum page count below the current size of the database. +// ** +// ** Regardless of mxPage, return the current maximum page count. +// */ +func _sqlite3PagerMaxPageCount(tls *libc.TLS, pPager uintptr, mxPage TPgno) (r TPgno) { + if mxPage > uint32(0) { + (*TPager)(unsafe.Pointer(pPager)).FmxPgno = mxPage + } + /* Called only by OP_MaxPgcnt */ + /* assert( pPager->mxPgno>=pPager->dbSize ); */ + /* OP_MaxPgcnt ensures that the parameter passed to this function is not + ** less than the total number of valid pages in the database. But this + ** may be less than Pager.dbSize, and so the assert() above is not valid */ + return (*TPager)(unsafe.Pointer(pPager)).FmxPgno +} + +/* +** The following set of routines are used to disable the simulated +** I/O error mechanism. These routines are used to avoid simulated +** errors in places where we do not care about errors. +** +** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops +** and generate no code. + */ + +func _sqlite3PagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) (r int32) { + if nSavepoint > (*TPager)(unsafe.Pointer(pPager)).FnSavepoint && (*TPager)(unsafe.Pointer(pPager)).FuseJournal != 0 { + return _pagerOpenSavepoint(tls, pPager, nSavepoint) + } else { + return SQLITE_OK + } + return r +} + +// C documentation +// +// /* +// ** The caller must be holding a SHARED lock on the database file to call +// ** this function. +// ** +// ** If the pager passed as the first argument is open on a real database +// ** file (not a temp file or an in-memory database), and the WAL file +// ** is not already open, make an attempt to open it now. If successful, +// ** return SQLITE_OK. If an error occurs or the VFS used by the pager does +// ** not support the xShmXXX() methods, return an error code. *pbOpen is +// ** not modified in either case. +// ** +// ** If the pager is open on a temp-file (or in-memory database), or if +// ** the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK +// ** without doing anything. +// */ +func _sqlite3PagerOpenWal(tls *libc.TLS, pPager uintptr, pbOpen uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK /* Return code */ + if !((*TPager)(unsafe.Pointer(pPager)).FtempFile != 0) && !((*TPager)(unsafe.Pointer(pPager)).FpWal != 0) { + if !(_sqlite3PagerWalSupported(tls, pPager) != 0) { + return int32(SQLITE_CANTOPEN) + } + /* Close any rollback journal previously open */ + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) + rc = _pagerOpenWal(tls, pPager) + if rc == SQLITE_OK { + (*TPager)(unsafe.Pointer(pPager)).FjournalMode = uint8(PAGER_JOURNALMODE_WAL) + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_OPEN) + } + } else { + **(**int32)(__ccgo_up(pbOpen)) = int32(1) + } + return rc +} + +// C documentation +// +// /* +// ** Return the number of references to the specified page. +// */ +func _sqlite3PagerPageRefcount(tls *libc.TLS, pPage uintptr) (r int32) { + return int32(_sqlite3PcachePageRefcount(tls, pPage)) +} + +// C documentation +// +// /* +// ** Increment the reference count for page pPg. +// */ +func _sqlite3PagerRef(tls *libc.TLS, pPg uintptr) { + _sqlite3PcacheRef(tls, pPg) +} + +// C documentation +// +// /* +// ** The page handle passed as the first argument refers to a dirty page +// ** with a page number other than iNew. This function changes the page's +// ** page number to iNew and sets the value of the PgHdr.flags field to +// ** the value passed as the third parameter. +// */ +func _sqlite3PagerRekey(tls *libc.TLS, pPg uintptr, iNew TPgno, flags Tu16) { + (*TDbPage)(unsafe.Pointer(pPg)).Fflags = flags + _sqlite3PcacheMove(tls, pPg, iNew) +} + +// C documentation +// +// /* +// ** Change the maximum number of in-memory pages that are allowed +// ** before attempting to recycle clean and unused pages. +// */ +func _sqlite3PagerSetCachesize(tls *libc.TLS, pPager uintptr, mxPage int32) { + _sqlite3PcacheSetCachesize(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, mxPage) +} + +// C documentation +// +// /* +// ** Change the maximum size of any memory mapping made of the database file. +// */ +func _sqlite3PagerSetMmapLimit(tls *libc.TLS, pPager uintptr, szMmap Tsqlite3_int64) { + (*TPager)(unsafe.Pointer(pPager)).FszMmap = szMmap + _pagerFixMaplimit(tls, pPager) +} + +// C documentation +// +// /* +// ** Change the maximum number of in-memory pages that are allowed +// ** before attempting to spill pages to journal. +// */ +func _sqlite3PagerSetSpillsize(tls *libc.TLS, pPager uintptr, mxPage int32) (r int32) { + return _sqlite3PcacheSetSpillsize(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, mxPage) +} + +// C documentation +// +// /* +// ** Free as much memory as possible from the pager. +// */ +func _sqlite3PagerShrink(tls *libc.TLS, pPager uintptr) { + _sqlite3PcacheShrink(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) +} + +// C documentation +// +// /* +// ** The caller currently has a read transaction open on the database. +// ** If this is not a WAL database, SQLITE_ERROR is returned. Otherwise, +// ** this function takes a SHARED lock on the CHECKPOINTER slot and then +// ** checks if the snapshot passed as the second argument is still +// ** available. If so, SQLITE_OK is returned. +// ** +// ** If the snapshot is not available, SQLITE_ERROR is returned. Or, if +// ** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error +// ** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER +// ** lock is released before returning. +// */ +func _sqlite3PagerSnapshotCheck(tls *libc.TLS, pPager uintptr, pSnapshot uintptr) (r int32) { + var rc int32 + _ = rc + if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + rc = _sqlite3WalSnapshotCheck(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pSnapshot) + } else { + rc = int32(SQLITE_ERROR) + } + return rc +} + +// C documentation +// +// /* +// ** If this is a WAL database, obtain a snapshot handle for the snapshot +// ** currently open. Otherwise, return an error. +// */ +func _sqlite3PagerSnapshotGet(tls *libc.TLS, pPager uintptr, ppSnapshot uintptr) (r int32) { + var rc int32 + _ = rc + rc = int32(SQLITE_ERROR) + if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + rc = _sqlite3WalSnapshotGet(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, ppSnapshot) + } + return rc +} + +// C documentation +// +// /* +// ** If this is a WAL database, store a pointer to pSnapshot. Next time a +// ** read transaction is opened, attempt to read from the snapshot it +// ** identifies. If this is not a WAL database, return an error. +// */ +func _sqlite3PagerSnapshotOpen(tls *libc.TLS, pPager uintptr, pSnapshot uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + _sqlite3WalSnapshotOpen(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pSnapshot) + } else { + rc = int32(SQLITE_ERROR) + } + return rc +} + +// C documentation +// +// /* +// ** If this is a WAL database, call sqlite3WalSnapshotRecover(). If this +// ** is not a WAL database, return an error. +// */ +func _sqlite3PagerSnapshotRecover(tls *libc.TLS, pPager uintptr) (r int32) { + var rc int32 + _ = rc + if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + rc = _sqlite3WalSnapshotRecover(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) + } else { + rc = int32(SQLITE_ERROR) + } + return rc +} + +// C documentation +// +// /* +// ** Release a lock obtained by an earlier successful call to +// ** sqlite3PagerSnapshotCheck(). +// */ +func _sqlite3PagerSnapshotUnlock(tls *libc.TLS, pPager uintptr) { + _sqlite3WalSnapshotUnlock(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) +} + +/************** End of pager.c ***********************************************/ +/************** Begin file wal.c *********************************************/ +/* +** 2010 February 1 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains the implementation of a write-ahead log (WAL) used in +** "journal_mode=WAL" mode. +** +** WRITE-AHEAD LOG (WAL) FILE FORMAT +** +** A WAL file consists of a header followed by zero or more "frames". +** Each frame records the revised content of a single page from the +** database file. All changes to the database are recorded by writing +** frames into the WAL. Transactions commit when a frame is written that +** contains a commit marker. A single WAL can and usually does record +** multiple transactions. Periodically, the content of the WAL is +** transferred back into the database file in an operation called a +** "checkpoint". +** +** A single WAL file can be used multiple times. In other words, the +** WAL can fill up with frames and then be checkpointed and then new +** frames can overwrite the old ones. A WAL always grows from beginning +** toward the end. Checksums and counters attached to each frame are +** used to determine which frames within the WAL are valid and which +** are leftovers from prior checkpoints. +** +** The WAL header is 32 bytes in size and consists of the following eight +** big-endian 32-bit unsigned integer values: +** +** 0: Magic number. 0x377f0682 or 0x377f0683 +** 4: File format version. Currently 3007000 +** 8: Database page size. Example: 1024 +** 12: Checkpoint sequence number +** 16: Salt-1, random integer incremented with each checkpoint +** 20: Salt-2, a different random integer changing with each ckpt +** 24: Checksum-1 (first part of checksum for first 24 bytes of header). +** 28: Checksum-2 (second part of checksum for first 24 bytes of header). +** +** Immediately following the wal-header are zero or more frames. Each +** frame consists of a 24-byte frame-header followed by bytes +** of page data. The frame-header is six big-endian 32-bit unsigned +** integer values, as follows: +** +** 0: Page number. +** 4: For commit records, the size of the database image in pages +** after the commit. For all other records, zero. +** 8: Salt-1 (copied from the header) +** 12: Salt-2 (copied from the header) +** 16: Checksum-1. +** 20: Checksum-2. +** +** A frame is considered valid if and only if the following conditions are +** true: +** +** (1) The salt-1 and salt-2 values in the frame-header match +** salt values in the wal-header +** +** (2) The checksum values in the final 8 bytes of the frame-header +** exactly match the checksum computed consecutively on the +** WAL header and the first 8 bytes and the content of all frames +** up to and including the current frame. +** +** The checksum is computed using 32-bit big-endian integers if the +** magic number in the first 4 bytes of the WAL is 0x377f0683 and it +** is computed using little-endian if the magic number is 0x377f0682. +** The checksum values are always stored in the frame header in a +** big-endian format regardless of which byte order is used to compute +** the checksum. The checksum is computed by interpreting the input as +** an even number of unsigned 32-bit integers: x[0] through x[N]. The +** algorithm used for the checksum is as follows: +** +** for i from 0 to n-1 step 2: +** s0 += x[i] + s1; +** s1 += x[i+1] + s0; +** endfor +** +** Note that s0 and s1 are both weighted checksums using fibonacci weights +** in reverse order (the largest fibonacci weight occurs on the first element +** of the sequence being summed.) The s1 value spans all 32-bit +** terms of the sequence whereas s0 omits the final term. +** +** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the +** WAL is transferred into the database, then the database is VFS.xSync-ed. +** The VFS.xSync operations serve as write barriers - all writes launched +** before the xSync must complete before any write that launches after the +** xSync begins. +** +** After each checkpoint, the salt-1 value is incremented and the salt-2 +** value is randomized. This prevents old and new frames in the WAL from +** being considered valid at the same time and being checkpointing together +** following a crash. +** +** READER ALGORITHM +** +** To read a page from the database (call it page number P), a reader +** first checks the WAL to see if it contains page P. If so, then the +** last valid instance of page P that is a followed by a commit frame +** or is a commit frame itself becomes the value read. If the WAL +** contains no copies of page P that are valid and which are a commit +** frame or are followed by a commit frame, then page P is read from +** the database file. +** +** To start a read transaction, the reader records the index of the last +** valid frame in the WAL. The reader uses this recorded "mxFrame" value +** for all subsequent read operations. New transactions can be appended +** to the WAL, but as long as the reader uses its original mxFrame value +** and ignores the newly appended content, it will see a consistent snapshot +** of the database from a single point in time. This technique allows +** multiple concurrent readers to view different versions of the database +** content simultaneously. +** +** The reader algorithm in the previous paragraphs works correctly, but +** because frames for page P can appear anywhere within the WAL, the +** reader has to scan the entire WAL looking for page P frames. If the +** WAL is large (multiple megabytes is typical) that scan can be slow, +** and read performance suffers. To overcome this problem, a separate +** data structure called the wal-index is maintained to expedite the +** search for frames of a particular page. +** +** WAL-INDEX FORMAT +** +** Conceptually, the wal-index is shared memory, though VFS implementations +** might choose to implement the wal-index using a mmapped file. Because +** the wal-index is shared memory, SQLite does not support journal_mode=WAL +** on a network filesystem. All users of the database must be able to +** share memory. +** +** In the default unix and windows implementation, the wal-index is a mmapped +** file whose name is the database name with a "-shm" suffix added. For that +** reason, the wal-index is sometimes called the "shm" file. +** +** The wal-index is transient. After a crash, the wal-index can (and should +** be) reconstructed from the original WAL file. In fact, the VFS is required +** to either truncate or zero the header of the wal-index when the last +** connection to it closes. Because the wal-index is transient, it can +** use an architecture-specific format; it does not have to be cross-platform. +** Hence, unlike the database and WAL file formats which store all values +** as big endian, the wal-index can store multi-byte values in the native +** byte order of the host computer. +** +** The purpose of the wal-index is to answer this question quickly: Given +** a page number P and a maximum frame index M, return the index of the +** last frame in the wal before frame M for page P in the WAL, or return +** NULL if there are no frames for page P in the WAL prior to M. +** +** The wal-index consists of a header region, followed by an one or +** more index blocks. +** +** The wal-index header contains the total number of frames within the WAL +** in the mxFrame field. +** +** Each index block except for the first contains information on +** HASHTABLE_NPAGE frames. The first index block contains information on +** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and +** HASHTABLE_NPAGE are selected so that together the wal-index header and +** first index block are the same size as all other index blocks in the +** wal-index. The values are: +** +** HASHTABLE_NPAGE 4096 +** HASHTABLE_NPAGE_ONE 4062 +** +** Each index block contains two sections, a page-mapping that contains the +** database page number associated with each wal frame, and a hash-table +** that allows readers to query an index block for a specific page number. +** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE +** for the first index block) 32-bit page numbers. The first entry in the +** first index-block contains the database page number corresponding to the +** first frame in the WAL file. The first entry in the second index block +** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in +** the log, and so on. +** +** The last index block in a wal-index usually contains less than the full +** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers, +** depending on the contents of the WAL file. This does not change the +** allocated size of the page-mapping array - the page-mapping array merely +** contains unused entries. +** +** Even without using the hash table, the last frame for page P +** can be found by scanning the page-mapping sections of each index block +** starting with the last index block and moving toward the first, and +** within each index block, starting at the end and moving toward the +** beginning. The first entry that equals P corresponds to the frame +** holding the content for that page. +** +** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers. +** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the +** hash table for each page number in the mapping section, so the hash +** table is never more than half full. The expected number of collisions +** prior to finding a match is 1. Each entry of the hash table is an +** 1-based index of an entry in the mapping section of the same +** index block. Let K be the 1-based index of the largest entry in +** the mapping section. (For index blocks other than the last, K will +** always be exactly HASHTABLE_NPAGE (4096) and for the last index block +** K will be (mxFrame%HASHTABLE_NPAGE).) Unused slots of the hash table +** contain a value of 0. +** +** To look for page P in the hash table, first compute a hash iKey on +** P as follows: +** +** iKey = (P * 383) % HASHTABLE_NSLOT +** +** Then start scanning entries of the hash table, starting with iKey +** (wrapping around to the beginning when the end of the hash table is +** reached) until an unused hash slot is found. Let the first unused slot +** be at index iUnused. (iUnused might be less than iKey if there was +** wrap-around.) Because the hash table is never more than half full, +** the search is guaranteed to eventually hit an unused entry. Let +** iMax be the value between iKey and iUnused, closest to iUnused, +** where aHash[iMax]==P. If there is no iMax entry (if there exists +** no hash slot such that aHash[i]==p) then page P is not in the +** current index block. Otherwise the iMax-th mapping entry of the +** current index block corresponds to the last entry that references +** page P. +** +** A hash search begins with the last index block and moves toward the +** first index block, looking for entries corresponding to page P. On +** average, only two or three slots in each index block need to be +** examined in order to either find the last entry for page P, or to +** establish that no such entry exists in the block. Each index block +** holds over 4000 entries. So two or three index blocks are sufficient +** to cover a typical 10 megabyte WAL file, assuming 1K pages. 8 or 10 +** comparisons (on average) suffice to either locate a frame in the +** WAL or to establish that the frame does not exist in the WAL. This +** is much faster than scanning the entire 10MB WAL. +** +** Note that entries are added in order of increasing K. Hence, one +** reader might be using some value K0 and a second reader that started +** at a later time (after additional transactions were added to the WAL +** and to the wal-index) might be using a different value K1, where K1>K0. +** Both readers can use the same hash table and mapping section to get +** the correct result. There may be entries in the hash table with +** K>K0 but to the first reader, those entries will appear to be unused +** slots in the hash table and so the first reader will get an answer as +** if no values greater than K0 had ever been inserted into the hash table +** in the first place - which is what reader one wants. Meanwhile, the +** second reader using K1 will see additional values that were inserted +** later, which is exactly what reader two wants. +** +** When a rollback occurs, the value of K is decreased. Hash table entries +** that correspond to frames greater than the new K value are removed +** from the hash table at this point. + */ + +/* #include "wal.h" */ + +/* +** Trace output macros + */ + +/* +** The maximum (and only) versions of the wal and wal-index formats +** that may be interpreted by this version of SQLite. +** +** If a client begins recovering a WAL file and finds that (a) the checksum +** values in the wal-header are correct and (b) the version field is not +** WAL_MAX_VERSION, recovery fails and SQLite returns SQLITE_CANTOPEN. +** +** Similarly, if a client successfully reads a wal-index header (i.e. the +** checksum test is successful) and finds that the version field is not +** WALINDEX_MAX_VERSION, then no read-transaction is opened and SQLite +** returns SQLITE_CANTOPEN. + */ + +/* +** Index numbers for various locking bytes. WAL_NREADER is the number +** of available reader locks and should be at least 3. The default +** is SQLITE_SHM_NLOCK==8 and WAL_NREADER==5. +** +** Technically, the various VFSes are free to implement these locks however +** they see fit. However, compatibility is encouraged so that VFSes can +** interoperate. The standard implementation used on both unix and windows +** is for the index number to indicate a byte offset into the +** WalCkptInfo.aLock[] array in the wal-index header. In other words, all +** locks are on the shm file. The WALINDEX_LOCK_OFFSET constant (which +** should be 120) is the location in the shm file for the first locking +** byte. + */ + +// C documentation +// +// /* +// ** Return a pointer to the "temporary page" buffer held internally +// ** by the pager. This is a buffer that is big enough to hold the +// ** entire content of a database page. This buffer is used internally +// ** during rollback and will be overwritten whenever a rollback +// ** occurs. But other modules are free to use it too, as long as +// ** no rollbacks are happening. +// */ +func _sqlite3PagerTempSpace(tls *libc.TLS, pPager uintptr) (r uintptr) { + return (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace +} + +// C documentation +// +// /* +// ** Truncate the in-memory database file image to nPage pages. This +// ** function does not actually modify the database file on disk. It +// ** just sets the internal state of the pager object so that the +// ** truncation will be done when the current transaction is committed. +// ** +// ** This function is only called right before committing a transaction. +// ** Once this function has been called, the transaction must either be +// ** rolled back or committed. It is not safe to call this function and +// ** then continue writing to the database. +// */ +func _sqlite3PagerTruncateImage(tls *libc.TLS, pPager uintptr, nPage TPgno) { + (*TPager)(unsafe.Pointer(pPager)).FdbSize = nPage + /* At one point the code here called assertTruncateConstraint() to + ** ensure that all pages being truncated away by this operation are, + ** if one or more savepoints are open, present in the savepoint + ** journal so that they can be restored if the savepoint is rolled + ** back. This is no longer necessary as this function is now only + ** called right before committing a transaction. So although the + ** Pager object may still have open savepoints (Pager.nSavepoint!=0), + ** they cannot be rolled back. So the assertTruncateConstraint() call + ** is no longer correct. */ +} + +func _sqlite3PagerUnref(tls *libc.TLS, pPg uintptr) { + if pPg != 0 { + _sqlite3PagerUnrefNotNull(tls, pPg) + } +} + +func _sqlite3PagerUnrefPageOne(tls *libc.TLS, pPg uintptr) { + var pPager uintptr + _ = pPager + /* Page1 is never memory mapped */ + pPager = (*TDbPage)(unsafe.Pointer(pPg)).FpPager + _sqlite3PcacheRelease(tls, pPg) + _pagerUnlockIfUnused(tls, pPager) +} + +// C documentation +// +// /* +// ** Return the VFS structure for the pager. +// */ +func _sqlite3PagerVfs(tls *libc.TLS, pPager uintptr) (r uintptr) { + return (*TPager)(unsafe.Pointer(pPager)).FpVfs +} + +func _sqlite3PagerWalCallback(tls *libc.TLS, pPager uintptr) (r int32) { + return _sqlite3WalCallback(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) +} + +// C documentation +// +// /* +// ** Return true if the underlying VFS for the given pager supports the +// ** primitives necessary for write-ahead logging. +// */ +func _sqlite3PagerWalSupported(tls *libc.TLS, pPager uintptr) (r int32) { + var pMethods uintptr + _ = pMethods + pMethods = (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods + if (*TPager)(unsafe.Pointer(pPager)).FnoLock != 0 { + return 0 + } + return libc.BoolInt32((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 || (*Tsqlite3_io_methods)(unsafe.Pointer(pMethods)).FiVersion >= int32(2) && (*Tsqlite3_io_methods)(unsafe.Pointer(pMethods)).FxShmMap != 0) +} + +// C documentation +// +// /* +// ** Return the global mutex used by this PCACHE implementation. The +// ** sqlite3_status() routine needs access to this mutex. +// */ +func _sqlite3Pcache1Mutex(tls *libc.TLS) (r uintptr) { + return _pcache1_g.Fmutex +} + +// C documentation +// +// /* +// ** Make every page in the cache clean. +// */ +func _sqlite3PcacheCleanAll(tls *libc.TLS, pCache uintptr) { + var p, v1 uintptr + _, _ = p, v1 + for { + v1 = (*TPCache)(unsafe.Pointer(pCache)).FpDirty + p = v1 + if !(v1 != uintptr(0)) { + break + } + _sqlite3PcacheMakeClean(tls, p) + } +} + +// C documentation +// +// /* +// ** Discard the contents of the cache. +// */ +func _sqlite3PcacheClear(tls *libc.TLS, pCache uintptr) { + _sqlite3PcacheTruncate(tls, pCache, uint32(0)) +} + +// C documentation +// +// /* +// ** Close a cache. +// */ +func _sqlite3PcacheClose(tls *libc.TLS, pCache uintptr) { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxDestroy})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache) +} + +// C documentation +// +// /* +// ** Return a list of all dirty pages in the cache, sorted by page number. +// */ +func _sqlite3PcacheDirtyList(tls *libc.TLS, pCache uintptr) (r uintptr) { + var p uintptr + _ = p + p = (*TPCache)(unsafe.Pointer(pCache)).FpDirty + for { + if !(p != 0) { + break + } + (*TPgHdr)(unsafe.Pointer(p)).FpDirty = (*TPgHdr)(unsafe.Pointer(p)).FpDirtyNext + goto _1 + _1: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirtyNext + } + return _pcacheSortDirtyList(tls, (*TPCache)(unsafe.Pointer(pCache)).FpDirty) +} + +// C documentation +// +// /* +// ** This routine converts the sqlite3_pcache_page object returned by +// ** sqlite3PcacheFetch() into an initialized PgHdr object. This routine +// ** must be called after sqlite3PcacheFetch() in order to get a usable +// ** result. +// */ +func _sqlite3PcacheFetchFinish(tls *libc.TLS, pCache uintptr, pgno TPgno, pPage uintptr) (r uintptr) { + var pPgHdr uintptr + _ = pPgHdr + pPgHdr = (*Tsqlite3_pcache_page)(unsafe.Pointer(pPage)).FpExtra + if !((*TPgHdr)(unsafe.Pointer(pPgHdr)).FpPage != 0) { + return _pcacheFetchFinishWithInit(tls, pCache, pgno, pPage) + } + (*TPCache)(unsafe.Pointer(pCache)).FnRefSum = (*TPCache)(unsafe.Pointer(pCache)).FnRefSum + 1 + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FnRef = (*TPgHdr)(unsafe.Pointer(pPgHdr)).FnRef + 1 + return pPgHdr +} + +// C documentation +// +// /*************************************************** General Interfaces ****** +// ** +// ** Initialize and shutdown the page cache subsystem. Neither of these +// ** functions are threadsafe. +// */ +func _sqlite3PcacheInitialize(tls *libc.TLS) (r int32) { + if _sqlite3Config.Fpcache2.FxInit == uintptr(0) { + /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the + ** built-in default page cache is used instead of the application defined + ** page cache. */ + _sqlite3PCacheSetDefault(tls) + } + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxInit})))(tls, _sqlite3Config.Fpcache2.FpArg) +} + +// C documentation +// +// /* +// ** Return the number of references to the page supplied as an argument. +// */ +func _sqlite3PcachePageRefcount(tls *libc.TLS, p uintptr) (r Ti64) { + return (*TPgHdr)(unsafe.Pointer(p)).FnRef +} + +// C documentation +// +// /* +// ** Return the total number of pages in the cache. +// */ +func _sqlite3PcachePagecount(tls *libc.TLS, pCache uintptr) (r int32) { + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxPagecount})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache) +} + +// C documentation +// +// /* +// ** Increase the reference count of a supplied page by 1. +// */ +func _sqlite3PcacheRef(tls *libc.TLS, p uintptr) { + (*TPgHdr)(unsafe.Pointer(p)).FnRef = (*TPgHdr)(unsafe.Pointer(p)).FnRef + 1 + (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum = (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum + 1 +} + +// C documentation +// +// /* +// ** Return the total number of references to all pages held by the cache. +// ** +// ** This is not the total number of pages referenced, but the sum of the +// ** reference count for all pages. +// */ +func _sqlite3PcacheRefCount(tls *libc.TLS, pCache uintptr) (r Ti64) { + return (*TPCache)(unsafe.Pointer(pCache)).FnRefSum +} + +// C documentation +// +// /* +// ** Set the suggested cache-size value. +// */ +func _sqlite3PcacheSetCachesize(tls *libc.TLS, pCache uintptr, mxPage int32) { + (*TPCache)(unsafe.Pointer(pCache)).FszCache = mxPage + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxCachesize})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, _numberOfCachePages(tls, pCache)) +} + +// C documentation +// +// /* +// ** Set the suggested cache-spill value. Make no changes if if the +// ** argument is zero. Return the effective cache-spill size, which will +// ** be the larger of the szSpill and szCache. +// */ +func _sqlite3PcacheSetSpillsize(tls *libc.TLS, p uintptr, mxPage int32) (r int32) { + var res int32 + _ = res + if mxPage != 0 { + if mxPage < 0 { + mxPage = int32(int64(-libc.Int32FromInt32(1024)) * int64(mxPage) / int64((*TPCache)(unsafe.Pointer(p)).FszPage+(*TPCache)(unsafe.Pointer(p)).FszExtra)) + } + (*TPCache)(unsafe.Pointer(p)).FszSpill = mxPage + } + res = _numberOfCachePages(tls, p) + if res < (*TPCache)(unsafe.Pointer(p)).FszSpill { + res = (*TPCache)(unsafe.Pointer(p)).FszSpill + } + return res +} + +// C documentation +// +// /* +// ** Free up as much memory as possible from the page cache. +// */ +func _sqlite3PcacheShrink(tls *libc.TLS, pCache uintptr) { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxShrink})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache) +} + +func _sqlite3PcacheShutdown(tls *libc.TLS) { + if _sqlite3Config.Fpcache2.FxShutdown != 0 { + /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */ + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxShutdown})))(tls, _sqlite3Config.Fpcache2.FpArg) + } +} + +// C documentation +// +// /* +// ** The value of the "pending" byte must be 0x40000000 (1 byte past the +// ** 1-gibabyte boundary) in a compatible database. SQLite never uses +// ** the database page that contains the pending byte. It never attempts +// ** to read or write that page. The pending byte page is set aside +// ** for use by the VFS layers as space for managing file locks. +// ** +// ** During testing, it is often desirable to move the pending byte to +// ** a different position in the file. This allows code that has to +// ** deal with the pending byte to run on files that are much smaller +// ** than 1 GiB. The sqlite3_test_control() interface can be used to +// ** move the pending byte. +// ** +// ** IMPORTANT: Changing the pending byte to any value other than +// ** 0x40000000 results in an incompatible database file format! +// ** Changing the pending byte during operation will result in undefined +// ** and incorrect behavior. +// */ +var _sqlite3PendingByte = int32(0x40000000) + +// C documentation +// +// /* All threads share a single random number generator. +// ** This structure is the current state of the generator. +// */ +var _sqlite3Prng Tsqlite3PrngType + +func _sqlite3PutVarint(tls *libc.TLS, p uintptr, v Tu64) (r int32) { + if v <= uint64(0x7f) { + **(**uint8)(__ccgo_up(p)) = uint8(v & uint64(0x7f)) + return int32(1) + } + if v <= uint64(0x3fff) { + **(**uint8)(__ccgo_up(p)) = uint8(v>>libc.Int32FromInt32(7)&uint64(0x7f) | uint64(0x80)) + **(**uint8)(__ccgo_up(p + 1)) = uint8(v & uint64(0x7f)) + return int32(2) + } + return _putVarint64(tls, p, v) +} + +/* +** Bitmasks used by sqlite3GetVarint(). These precomputed constants +** are defined here rather than simply putting the constant expressions +** inline in order to work around bugs in the RVT compiler. +** +** SLOT_2_0 A mask for (0x7f<<14) | 0x7f +** +** SLOT_4_2_0 A mask for (0x7f<<28) | SLOT_2_0 + */ + +// C documentation +// +// /* +// ** Create a new string that is capable of holding N bytes of text, not counting +// ** the zero byte at the end. The string is uninitialized. +// ** +// ** The reference count is initially 1. Call sqlite3RCStrUnref() to free the +// ** newly allocated string. +// ** +// ** This routine returns 0 on an OOM. +// */ +func _sqlite3RCStrNew(tls *libc.TLS, N Tu64) (r uintptr) { + var p uintptr + _ = p + p = Xsqlite3_malloc64(tls, N+uint64(8)+uint64(1)) + if p == uintptr(0) { + return uintptr(0) + } + (*TRCStr)(unsafe.Pointer(p)).FnRCRef = uint64(1) + return p + 1*8 +} + +// C documentation +// +// /* +// ** Increase the reference count of the string by one. +// ** +// ** The input parameter is returned. +// */ +func _sqlite3RCStrRef(tls *libc.TLS, z uintptr) (r uintptr) { + var p uintptr + _ = p + p = z + p -= 8 + (*TRCStr)(unsafe.Pointer(p)).FnRCRef = (*TRCStr)(unsafe.Pointer(p)).FnRCRef + 1 + return z +} + +// C documentation +// +// /* +// ** Change the size of the string so that it is able to hold N bytes. +// ** The string might be reallocated, so return the new allocation. +// */ +func _sqlite3RCStrResize(tls *libc.TLS, z uintptr, N Tu64) (r uintptr) { + var p, pNew uintptr + _, _ = p, pNew + p = z + p -= 8 + pNew = Xsqlite3_realloc64(tls, p, N+uint64(8)+uint64(1)) + if pNew == uintptr(0) { + Xsqlite3_free(tls, p) + return uintptr(0) + } else { + return pNew + 1*8 + } + return r +} + +/************** End of printf.c **********************************************/ +/************** Begin file treeview.c ****************************************/ +/* +** 2015-06-08 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains C code to implement the TreeView debugging routines. +** These routines print a parse tree to standard output for debugging and +** analysis. +** +** The interfaces in this file is only available when compiling +** with SQLITE_DEBUG. + */ +/* #include "sqliteInt.h" */ + +/************** End of treeview.c ********************************************/ +/************** Begin file random.c ******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code to implement a pseudo-random number +** generator (PRNG) for SQLite. +** +** Random numbers are used by some of the database backends in order +** to generate random integer keys for tables or random filenames. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** Decrease the reference count by one. Free the string when the +// ** reference count reaches zero. +// */ +func _sqlite3RCStrUnref(tls *libc.TLS, z uintptr) { + var p uintptr + _ = p + p = z + p -= 8 + if (*TRCStr)(unsafe.Pointer(p)).FnRCRef >= uint64(2) { + (*TRCStr)(unsafe.Pointer(p)).FnRCRef = (*TRCStr)(unsafe.Pointer(p)).FnRCRef - 1 + } else { + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Return TRUE if shadow tables should be read-only in the current +// ** context. +// */ +func _sqlite3ReadOnlyShadowTables(tls *libc.TLS, db uintptr) (r int32) { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) && (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec == 0 && !((*Tsqlite3)(unsafe.Pointer(db)).FnVTrans > 0 && (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans == uintptr(0)) { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* Convert a floating point value to its closest integer. Do so in +// ** a way that avoids 'outside the range of representable values' warnings +// ** from UBSAN. +// */ +func _sqlite3RealToI64(tls *libc.TLS, r float64) (r1 Ti64) { + if r < -libc.Float64FromFloat64(9.223372036854775e+18) { + return int64(-libc.Int32FromInt32(1)) - (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< +libc.Float64FromFloat64(9.223372036854775e+18) { + return libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< (*TParse)(unsafe.Pointer(pParse)).FnRangeReg { + (*TParse)(unsafe.Pointer(pParse)).FnRangeReg = nReg + (*TParse)(unsafe.Pointer(pParse)).FiRangeReg = iReg + } +} + +// C documentation +// +// /* +// ** It is assumed that there is already a RenameToken object associated +// ** with parse tree element pFrom. This function remaps the associated token +// ** to parse tree element pTo. +// */ +func _sqlite3RenameTokenRemap(tls *libc.TLS, pParse uintptr, pTo uintptr, pFrom uintptr) { + var p uintptr + _ = p + p = (*TParse)(unsafe.Pointer(pParse)).FpRename + for { + if !(p != 0) { + break + } + if (*TRenameToken)(unsafe.Pointer(p)).Fp == pFrom { + (*TRenameToken)(unsafe.Pointer(p)).Fp = pTo + break + } + goto _1 + _1: + ; + p = (*TRenameToken)(unsafe.Pointer(p)).FpNext + } +} + +// C documentation +// +// /* +// ** Rerun the compilation of a statement after a schema change. +// ** +// ** If the statement is successfully recompiled, return SQLITE_OK. Otherwise, +// ** if the statement cannot be recompiled because another connection has +// ** locked the sqlite3_schema table, return SQLITE_LOCKED. If any other error +// ** occurs, return SQLITE_SCHEMA. +// */ +func _sqlite3Reprepare(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, zSql uintptr + var prepFlags Tu8 + var rc int32 + var _ /* pNew at bp+0 */ uintptr + _, _, _, _ = db, prepFlags, rc, zSql + zSql = Xsqlite3_sql(tls, p) + /* Reprepare only called for prepare_v2() statements */ + db = _sqlite3VdbeDb(tls, p) + prepFlags = _sqlite3VdbePrepareFlags(tls, p) + rc = _sqlite3LockAndPrepare(tls, db, zSql, -int32(1), uint32(prepFlags), p, bp, uintptr(0)) + if rc != 0 { + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + return rc + } else { + } + _sqlite3VdbeSwap(tls, **(**uintptr)(__ccgo_up(bp)), p) + _sqlite3TransferBindings(tls, **(**uintptr)(__ccgo_up(bp)), p) + _sqlite3VdbeResetStepResult(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label +// ** because it was a partial index, then this routine should be called to +// ** resolve that label. +// */ +func _sqlite3ResolvePartIdxLabel(tls *libc.TLS, pParse uintptr, iLabel int32) { + if iLabel != 0 { + _sqlite3VdbeResolveLabel(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, iLabel) + } +} + +/************** End of delete.c **********************************************/ +/************** Begin file func.c ********************************************/ +/* +** 2002 February 23 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the C-language implementations for many of the SQL +** functions of SQLite. (Some function, and in particular the date and +** time functions, are implemented separately.) + */ +/* #include "sqliteInt.h" */ +/* #include */ +/* #include */ +/* #include */ +/* #include "vdbeInt.h" */ + +// C documentation +// +// /* +// ** Deallocate all chunks from a RowSet. This frees all memory that +// ** the RowSet has allocated over its lifetime. This routine is +// ** the destructor for the RowSet. +// */ +func _sqlite3RowSetClear(tls *libc.TLS, pArg uintptr) { + var p, pChunk, pNextChunk uintptr + _, _, _ = p, pChunk, pNextChunk + p = pArg + pChunk = (*TRowSet)(unsafe.Pointer(p)).FpChunk + for { + if !(pChunk != 0) { + break + } + pNextChunk = (*TRowSetChunk)(unsafe.Pointer(pChunk)).FpNextChunk + _sqlite3DbFree(tls, (*TRowSet)(unsafe.Pointer(p)).Fdb, pChunk) + goto _1 + _1: + ; + pChunk = pNextChunk + } + (*TRowSet)(unsafe.Pointer(p)).FpChunk = uintptr(0) + (*TRowSet)(unsafe.Pointer(p)).FnFresh = uint16(0) + (*TRowSet)(unsafe.Pointer(p)).FpEntry = uintptr(0) + (*TRowSet)(unsafe.Pointer(p)).FpLast = uintptr(0) + (*TRowSet)(unsafe.Pointer(p)).FpForest = uintptr(0) + (*TRowSet)(unsafe.Pointer(p)).FrsFlags = uint16(ROWSET_SORTED) +} + +// C documentation +// +// /* +// ** Deallocate all chunks from a RowSet. This frees all memory that +// ** the RowSet has allocated over its lifetime. This routine is +// ** the destructor for the RowSet. +// */ +func _sqlite3RowSetDelete(tls *libc.TLS, pArg uintptr) { + _sqlite3RowSetClear(tls, pArg) + _sqlite3DbFree(tls, (*TRowSet)(unsafe.Pointer(pArg)).Fdb, pArg) +} + +// C documentation +// +// /* +// ** For testing purposes, we sometimes want to preserve the state of +// ** PRNG and restore the PRNG to its saved state at a later time, or +// ** to reset the PRNG to its initial state. These routines accomplish +// ** those tasks. +// ** +// ** The sqlite3_test_control() interface calls these routines to +// ** control the PRNG. +// */ +var _sqlite3SavedPrng Tsqlite3PrngType + +// C documentation +// +// /* +// ** This function is called by the parser when it parses a command to create, +// ** release or rollback an SQL savepoint. +// */ +func _sqlite3Savepoint(tls *libc.TLS, pParse uintptr, op int32, pName uintptr) { + var v, zName uintptr + _, _ = v, zName + zName = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pName) + if zName != 0 { + v = _sqlite3GetVdbe(tls, pParse) + if !(v != 0) || _sqlite3AuthCheck(tls, pParse, int32(SQLITE_SAVEPOINT), _az[op], zName, uintptr(0)) != 0 { + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zName) + return + } + _sqlite3VdbeAddOp4(tls, v, OP_Savepoint, op, 0, 0, zName, -int32(7)) + } +} + +// C documentation +// +// /* +// ** Return a sanitized version of the sector-size of OS file pFile. The +// ** return value is guaranteed to lie between 32 and MAX_SECTOR_SIZE. +// */ +func _sqlite3SectorSize(tls *libc.TLS, pFile uintptr) (r int32) { + var iRet int32 + _ = iRet + iRet = _sqlite3OsSectorSize(tls, pFile) + if iRet < int32(32) { + iRet = int32(512) + } else { + if iRet > int32(MAX_SECTOR_SIZE) { + iRet = int32(MAX_SECTOR_SIZE) + } + } + return iRet +} + +// C documentation +// +// /* +// ** Delete the given Select structure and all of its substructures. +// */ +func _sqlite3SelectDelete(tls *libc.TLS, db uintptr, p uintptr) { + if p != 0 { + _clearSelect(tls, db, p, int32(1)) + } +} + +func _sqlite3SelectDeleteGeneric(tls *libc.TLS, db uintptr, p uintptr) { + if p != 0 { + _clearSelect(tls, db, p, int32(1)) + } +} + +// C documentation +// +// /* +// ** Return the maximum height of any expression tree referenced +// ** by the select statement passed as an argument. +// */ +func _sqlite3SelectExprHeight(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* nHeight at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = 0 + _heightOfSelect(tls, p, bp) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** If the SELECT passed as the second argument has an associated WITH +// ** clause, pop it from the stack stored as part of the Parse object. +// ** +// ** This function is used as the xSelectCallback2() callback by +// ** sqlite3SelectExpand() when walking a SELECT tree to resolve table +// ** names and other FROM clause elements. +// */ +func _sqlite3SelectPopWith(tls *libc.TLS, pWalker uintptr, p uintptr) { + var pParse, pWith uintptr + _, _ = pParse, pWith + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + if (*TParse)(unsafe.Pointer(pParse)).FpWith != 0 && (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) { + pWith = (*TSelect)(unsafe.Pointer(_findRightmost(tls, p))).FpWith + if pWith != uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).FpWith = (*TWith)(unsafe.Pointer(pWith)).FpOuter + } + } +} + +// C documentation +// +// /* +// ** This routine sets up a SELECT statement for processing. The +// ** following is accomplished: +// ** +// ** * VDBE Cursor numbers are assigned to all FROM-clause terms. +// ** * Ephemeral Table objects are created for all FROM-clause subqueries. +// ** * ON and USING clauses are shifted into WHERE statements +// ** * Wildcards "*" and "TABLE.*" in result sets are expanded. +// ** * Identifiers in expression are matched to tables. +// ** +// ** This routine acts recursively on all subqueries within the SELECT. +// */ +func _sqlite3SelectPrep(tls *libc.TLS, pParse uintptr, p uintptr, pOuterNC uintptr) { + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return + } + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_HasTypeInfo) != 0 { + return + } + _sqlite3SelectExpand(tls, pParse, p) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + _sqlite3ResolveSelectNames(tls, pParse, p, pOuterNC) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + _sqlite3SelectAddTypeInfo(tls, pParse, p) +} + +// C documentation +// +// /* +// ** This is a SELECT-node callback for the expression walker that +// ** always "fails". By "fail" in this case, we mean set +// ** pWalker->eCode to zero and abort. +// ** +// ** This callback is used by multiple expression walkers. +// */ +func _sqlite3SelectWalkFail(tls *libc.TLS, pWalker uintptr, NotUsed uintptr) (r int32) { + _ = NotUsed + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) +} + +// C documentation +// +// /* +// ** No-op routine for the parse-tree walker for SELECT statements. +// ** subquery in the parser tree. +// */ +func _sqlite3SelectWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) (r int32) { + _ = NotUsed + _ = NotUsed2 + return WRC_Continue +} + +/************** End of walker.c **********************************************/ +/************** Begin file resolve.c *****************************************/ +/* +** 2008 August 18 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains routines used for walking the parser tree and +** resolve all identifiers by associating them with a particular +** table and column. + */ +/* #include "sqliteInt.h" */ + +/* +** Magic table number to mean the EXCLUDED table in an UPSERT statement. + */ + +// C documentation +// +// /* +// ** Generate code that checks the left-most column of index table iCur to see if +// ** it contains any NULL entries. Cause the register at regHasNull to be set +// ** to a non-NULL value if iCur contains no NULLs. Cause register regHasNull +// ** to be set to NULL if iCur contains one or more NULL values. +// */ +func _sqlite3SetHasNullFlag(tls *libc.TLS, v uintptr, iCur int32, regHasNull int32) { + var addr1 int32 + _ = addr1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regHasNull) + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iCur) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iCur, 0, regHasNull) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_TYPEOFARG)) + _sqlite3VdbeJumpHere(tls, v, addr1) +} + +// C documentation +// +// /* +// ** Free any prior content in *pz and replace it with a copy of zNew. +// */ +func _sqlite3SetString(tls *libc.TLS, pz uintptr, db uintptr, zNew uintptr) { + var z uintptr + _ = z + z = _sqlite3DbStrDup(tls, db, zNew) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(pz))) + **(**uintptr)(__ccgo_up(pz)) = z +} + +// C documentation +// +// /* +// ** Change the text encoding for a database connection. This means that +// ** the pDfltColl must change as well. +// */ +func _sqlite3SetTextEncoding(tls *libc.TLS, db uintptr, enc Tu8) { + (*Tsqlite3)(unsafe.Pointer(db)).Fenc = enc + /* EVIDENCE-OF: R-08308-17224 The default collating function for all + ** strings is BINARY. + */ + (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl = _sqlite3FindCollSeq(tls, db, enc, uintptr(unsafe.Pointer(&_sqlite3StrBINARY)), 0) + _sqlite3ExpirePreparedStatements(tls, db, int32(1)) +} + +// C documentation +// +// /* +// ** A list of BtShared objects that are eligible for participation +// ** in shared cache. This variable has file scope during normal builds, +// ** but the test harness needs to access it so we make it global for +// ** test builds. +// ** +// ** Access to this variable is protected by SQLITE_MUTEX_STATIC_MAIN. +// */ +var _sqlite3SharedCacheList = uintptr(0) + +// C documentation +// +// /* +// ** Indicate that the accumulator load should be skipped on this +// ** iteration of the aggregate loop. +// */ +func _sqlite3SkipAccumulatorLoad(tls *libc.TLS, context uintptr) { + (*Tsqlite3_context)(unsafe.Pointer(context)).FisError = -int32(1) + (*Tsqlite3_context)(unsafe.Pointer(context)).FskipFlag = uint8(1) +} + +// C documentation +// +// /* +// ** The sizes for serial types less than 128 +// */ +var _sqlite3SmallTypeSizes = [128]Tu8{ + 1: uint8(1), + 2: uint8(2), + 3: uint8(3), + 4: uint8(4), + 5: uint8(6), + 6: uint8(8), + 7: uint8(8), + 14: uint8(1), + 15: uint8(1), + 16: uint8(2), + 17: uint8(2), + 18: uint8(3), + 19: uint8(3), + 20: uint8(4), + 21: uint8(4), + 22: uint8(5), + 23: uint8(5), + 24: uint8(6), + 25: uint8(6), + 26: uint8(7), + 27: uint8(7), + 28: uint8(8), + 29: uint8(8), + 30: uint8(9), + 31: uint8(9), + 32: uint8(10), + 33: uint8(10), + 34: uint8(11), + 35: uint8(11), + 36: uint8(12), + 37: uint8(12), + 38: uint8(13), + 39: uint8(13), + 40: uint8(14), + 41: uint8(14), + 42: uint8(15), + 43: uint8(15), + 44: uint8(16), + 45: uint8(16), + 46: uint8(17), + 47: uint8(17), + 48: uint8(18), + 49: uint8(18), + 50: uint8(19), + 51: uint8(19), + 52: uint8(20), + 53: uint8(20), + 54: uint8(21), + 55: uint8(21), + 56: uint8(22), + 57: uint8(22), + 58: uint8(23), + 59: uint8(23), + 60: uint8(24), + 61: uint8(24), + 62: uint8(25), + 63: uint8(25), + 64: uint8(26), + 65: uint8(26), + 66: uint8(27), + 67: uint8(27), + 68: uint8(28), + 69: uint8(28), + 70: uint8(29), + 71: uint8(29), + 72: uint8(30), + 73: uint8(30), + 74: uint8(31), + 75: uint8(31), + 76: uint8(32), + 77: uint8(32), + 78: uint8(33), + 79: uint8(33), + 80: uint8(34), + 81: uint8(34), + 82: uint8(35), + 83: uint8(35), + 84: uint8(36), + 85: uint8(36), + 86: uint8(37), + 87: uint8(37), + 88: uint8(38), + 89: uint8(38), + 90: uint8(39), + 91: uint8(39), + 92: uint8(40), + 93: uint8(40), + 94: uint8(41), + 95: uint8(41), + 96: uint8(42), + 97: uint8(42), + 98: uint8(43), + 99: uint8(43), + 100: uint8(44), + 101: uint8(44), + 102: uint8(45), + 103: uint8(45), + 104: uint8(46), + 105: uint8(46), + 106: uint8(47), + 107: uint8(47), + 108: uint8(48), + 109: uint8(48), + 110: uint8(49), + 111: uint8(49), + 112: uint8(50), + 113: uint8(50), + 114: uint8(51), + 115: uint8(51), + 116: uint8(52), + 117: uint8(52), + 118: uint8(53), + 119: uint8(53), + 120: uint8(54), + 121: uint8(54), + 122: uint8(55), + 123: uint8(55), + 124: uint8(56), + 125: uint8(56), + 126: uint8(57), + 127: uint8(57), +} + +var _sqlite3Stat = Tsqlite3StatType{} + +// C documentation +// +// /* +// ** Attempt to extract a value from expression pExpr using the methods +// ** as described for sqlite3Stat4ProbeSetValue() above. +// ** +// ** If successful, set *ppVal to point to a new value object and return +// ** SQLITE_OK. If no value can be extracted, but no other error occurs +// ** (e.g. OOM), return SQLITE_OK and set *ppVal to NULL. Or, if an error +// ** does occur, return an SQLite error code. The final value of *ppVal +// ** is undefined in this case. +// */ +func _sqlite3Stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity Tu8, ppVal uintptr) (r int32) { + return _stat4ValueFromExpr(tls, pParse, pExpr, affinity, uintptr(0), ppVal) +} + +// C documentation +// +// /* +// ** Standard typenames. These names must match the COLTYPE_* definitions. +// ** Adjust the SQLITE_N_STDTYPE value if adding or removing entries. +// ** +// ** sqlite3StdType[] The actual names of the datatypes. +// ** +// ** sqlite3StdTypeLen[] The length (in bytes) of each entry +// ** in sqlite3StdType[]. +// ** +// ** sqlite3StdTypeAffinity[] The affinity associated with each entry +// ** in sqlite3StdType[]. +// */ +var _sqlite3StdTypeLen = [6]uint8{ + 0: uint8(3), + 1: uint8(4), + 2: uint8(3), + 3: uint8(7), + 4: uint8(4), + 5: uint8(4), +} + +func _sqlite3SubInt64(tls *libc.TLS, pA uintptr, iB Ti64) (r int32) { + if iB == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= 0 { + return int32(1) + } + **(**Ti64)(__ccgo_up(pA)) -= iB + return 0 + } else { + return _sqlite3AddInt64(tls, pA, -iB) + } + return r +} + +// C documentation +// +// /* +// ** Delete a Subquery object and its substructure. +// */ +func _sqlite3SubqueryDelete(tls *libc.TLS, db uintptr, pSubq uintptr) { + _sqlite3SelectDelete(tls, db, (*TSubquery)(unsafe.Pointer(pSubq)).FpSelect) + _sqlite3DbFree(tls, db, pSubq) +} + +// C documentation +// +// /* +// ** Load the sqlite3.iSysErrno field if that is an appropriate thing +// ** to do based on the SQLite error code in rc. +// */ +func _sqlite3SystemError(tls *libc.TLS, db uintptr, rc int32) { + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<> uint64(7) + if !(v != uint64(0)) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + return i +} + +// C documentation +// +// /* +// ** Add a new instruction to the list of instructions current in the +// ** VDBE. Return the address of the new instruction. +// ** +// ** Parameters: +// ** +// ** p Pointer to the VDBE +// ** +// ** op The opcode for this instruction +// ** +// ** p1, p2, p3, p4 Operands +// */ +func _sqlite3VdbeAddOp0(tls *libc.TLS, p uintptr, op int32) (r int32) { + return _sqlite3VdbeAddOp3(tls, p, op, 0, 0, 0) +} + +func _sqlite3VdbeAddOp1(tls *libc.TLS, p uintptr, op int32, p1 int32) (r int32) { + return _sqlite3VdbeAddOp3(tls, p, op, p1, 0, 0) +} + +func _sqlite3VdbeAddOp2(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32) (r int32) { + return _sqlite3VdbeAddOp3(tls, p, op, p1, p2, 0) +} + +// C documentation +// +// /* +// ** Add an opcode that includes the p4 value as a pointer. +// */ +func _sqlite3VdbeAddOp4(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, zP4 uintptr, p4type int32) (r int32) { + var addr int32 + _ = addr + addr = _sqlite3VdbeAddOp3(tls, p, op, p1, p2, p3) + _sqlite3VdbeChangeP4(tls, p, addr, zP4, p4type) + return addr +} + +// C documentation +// +// /* +// ** Add an OP_ParseSchema opcode. This routine is broken out from +// ** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees +// ** as having been used. +// ** +// ** The zWhere string must have been obtained from sqlite3_malloc(). +// ** This routine will take ownership of the allocated memory. +// */ +func _sqlite3VdbeAddParseSchemaOp(tls *libc.TLS, p uintptr, iDb int32, zWhere uintptr, p5 Tu16) { + var j int32 + _ = j + _sqlite3VdbeAddOp4(tls, p, int32(OP_ParseSchema), iDb, 0, 0, zWhere, -int32(7)) + _sqlite3VdbeChangeP5(tls, p, p5) + j = 0 + for { + if !(j < (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FnDb) { + break + } + _sqlite3VdbeUsesBtree(tls, p, j) + goto _1 + _1: + ; + j = j + 1 + } + _sqlite3MayAbort(tls, (*TVdbe)(unsafe.Pointer(p)).FpParse) +} + +// C documentation +// +// /* +// ** Change the value of the opcode, or P1, P2, P3, or P5 operands +// ** for a specific instruction. +// */ +func _sqlite3VdbeChangeOpcode(tls *libc.TLS, p uintptr, addr int32, iNewOpcode Tu8) { + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, p, addr))).Fopcode = iNewOpcode +} + +func _sqlite3VdbeChangeP1(tls *libc.TLS, p uintptr, addr int32, val int32) { + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, p, addr))).Fp1 = val +} + +func _sqlite3VdbeChangeP2(tls *libc.TLS, p uintptr, addr int32, val int32) { + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, p, addr))).Fp2 = val +} + +func _sqlite3VdbeChangeP3(tls *libc.TLS, p uintptr, addr int32, val int32) { + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, p, addr))).Fp3 = val +} + +func _sqlite3VdbeCheckFkDeferred(tls *libc.TLS, p uintptr) (r int32) { + var db uintptr + _ = db + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons+(*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { + return SQLITE_OK + } + return _vdbeFkError(tls, p) +} + +func _sqlite3VdbeCheckFkImmediate(tls *libc.TLS, p uintptr) (r int32) { + if (*TVdbe)(unsafe.Pointer(p)).FnFkConstraint == 0 { + return SQLITE_OK + } + return _vdbeFkError(tls, p) +} + +func _sqlite3VdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) (r int32) { + if (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FnStatement != 0 && (*TVdbe)(unsafe.Pointer(p)).FiStatement != 0 { + return _vdbeCloseStatement(tls, p, eOp) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return the address of the next instruction to be inserted. +// */ +func _sqlite3VdbeCurrentAddr(tls *libc.TLS, p uintptr) (r int32) { + return (*TVdbe)(unsafe.Pointer(p)).FnOp +} + +/* +** Verify that at least N opcode slots are available in p without +** having to malloc for more space (except when compiled using +** SQLITE_TEST_REALLOC_STRESS). This interface is used during testing +** to verify that certain calls to sqlite3VdbeAddOpList() can never +** fail due to a OOM fault and hence that the return value from +** sqlite3VdbeAddOpList() will always be non-NULL. + */ + +/* +** Verify that the VM passed as the only argument does not contain +** an OP_ResultRow opcode. Fail an assert() if it does. This is used +** by code in pragma.c to ensure that the implementation of certain +** pragmas comports with the flags specified in the mkpragmatab.tcl +** script. + */ + +/* +** Generate code (a single OP_Abortable opcode) that will +** verify that the VDBE program can safely call Abort in the current +** context. + */ + +// C documentation +// +// /* +// ** Return the database associated with the Vdbe. +// */ +func _sqlite3VdbeDb(tls *libc.TLS, v uintptr) (r uintptr) { + return (*TVdbe)(unsafe.Pointer(v)).Fdb +} + +// C documentation +// +// /* +// ** Delete an entire VDBE. +// */ +func _sqlite3VdbeDelete(tls *libc.TLS, p uintptr) { + var db uintptr + _ = db + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + _sqlite3VdbeClearObject(tls, db, p) + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) { + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FppVPrev)) = (*TVdbe)(unsafe.Pointer(p)).FpVNext + if (*TVdbe)(unsafe.Pointer(p)).FpVNext != 0 { + (*TVdbe)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpVNext)).FppVPrev = (*TVdbe)(unsafe.Pointer(p)).FppVPrev + } + } + _sqlite3DbNNFreeNN(tls, db, p) +} + +// C documentation +// +// /* Insert the end of a co-routine +// */ +func _sqlite3VdbeEndCoroutine(tls *libc.TLS, v uintptr, regYield int32) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_EndCoroutine), regYield) + /* Clear the temporary register cache, thereby ensuring that each + ** co-routine has its own independent set of registers, because co-routines + ** might expect their registers to be preserved across an OP_Yield, and + ** that could cause problems if two or more co-routines are using the same + ** temporary register. + */ + (*TParse)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(v)).FpParse)).FnTempReg = uint8(0) + (*TParse)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(v)).FpParse)).FnRangeReg = 0 +} + +// C documentation +// +// /* +// ** Change the error string stored in Vdbe.zErrMsg +// */ +func _sqlite3VdbeError(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) { + var ap Tva_list + _ = ap + _sqlite3DbFree(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg) + ap = va + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3VMPrintf(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, zFormat, ap) + _ = ap +} + +// C documentation +// +// /* +// ** Return the address of the current EXPLAIN QUERY PLAN baseline. +// ** 0 means "none". +// */ +func _sqlite3VdbeExplainParent(tls *libc.TLS, pParse uintptr) (r int32) { + var pOp uintptr + _ = pOp + if (*TParse)(unsafe.Pointer(pParse)).FaddrExplain == 0 { + return 0 + } + pOp = _sqlite3VdbeGetOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, (*TParse)(unsafe.Pointer(pParse)).FaddrExplain) + return (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 +} + +/* +** Set a debugger breakpoint on the following routine in order to +** monitor the EXPLAIN QUERY PLAN code generation. + */ + +// C documentation +// +// /* +// ** Pop the EXPLAIN QUERY PLAN stack one level. +// */ +func _sqlite3VdbeExplainPop(tls *libc.TLS, pParse uintptr) { + (*TParse)(unsafe.Pointer(pParse)).FaddrExplain = _sqlite3VdbeExplainParent(tls, pParse) +} + +// C documentation +// +// /* +// ** This is a destructor on a Mem object (which is really an sqlite3_value) +// ** that deletes the Frame object that is attached to it as a blob. +// ** +// ** This routine does not delete the Frame right away. It merely adds the +// ** frame to a list of frames to be deleted when the Vdbe halts. +// */ +func _sqlite3VdbeFrameMemDel(tls *libc.TLS, pArg uintptr) { + var pFrame uintptr + _ = pFrame + pFrame = pArg + (*TVdbeFrame)(unsafe.Pointer(pFrame)).FpParent = (*TVdbe)(unsafe.Pointer((*TVdbeFrame)(unsafe.Pointer(pFrame)).Fv)).FpDelFrame + (*TVdbe)(unsafe.Pointer((*TVdbeFrame)(unsafe.Pointer(pFrame)).Fv)).FpDelFrame = pFrame +} + +// C documentation +// +// /* +// ** Close a VDBE cursor and release all the resources that cursor +// ** happens to hold. +// */ +func _sqlite3VdbeFreeCursor(tls *libc.TLS, p uintptr, pCx uintptr) { + if pCx != 0 { + _sqlite3VdbeFreeCursorNN(tls, p, pCx) + } +} + +// C documentation +// +// /* Return the most recently added opcode +// */ +func _sqlite3VdbeGetLastOp(tls *libc.TLS, p uintptr) (r uintptr) { + return _sqlite3VdbeGetOp(tls, p, (*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1)) +} + +// C documentation +// +// /* Generate code for an unconditional jump to instruction iDest +// */ +func _sqlite3VdbeGoto(tls *libc.TLS, p uintptr, iDest int32) (r int32) { + return _sqlite3VdbeAddOp3(tls, p, int32(OP_Goto), 0, iDest, 0) +} + +// C documentation +// +// /* +// ** Return true if the given Vdbe has any SubPrograms. +// */ +func _sqlite3VdbeHasSubProgram(tls *libc.TLS, pVdbe uintptr) (r int32) { + return libc.BoolInt32((*TVdbe)(unsafe.Pointer(pVdbe)).FpProgram != uintptr(0)) +} + +// C documentation +// +// /* +// ** Change the P2 operand of instruction addr so that it points to +// ** the address of the next instruction to be coded. +// */ +func _sqlite3VdbeJumpHere(tls *libc.TLS, p uintptr, addr int32) { + _sqlite3VdbeChangeP2(tls, p, addr, (*TVdbe)(unsafe.Pointer(p)).FnOp) +} + +// C documentation +// +// /* +// ** Change the P2 operand of the jump instruction at addr so that +// ** the jump lands on the next opcode. Or if the jump instruction was +// ** the previous opcode (and is thus a no-op) then simply back up +// ** the next instruction counter by one slot so that the jump is +// ** overwritten by the next inserted opcode. +// ** +// ** This routine is an optimization of sqlite3VdbeJumpHere() that +// ** strives to omit useless byte-code like this: +// ** +// ** 7 Once 0 8 0 +// ** 8 ... +// */ +func _sqlite3VdbeJumpHereOrPopInst(tls *libc.TLS, p uintptr, addr int32) { + if addr == (*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1) { + (*TVdbe)(unsafe.Pointer(p)).FnOp = (*TVdbe)(unsafe.Pointer(p)).FnOp - 1 + } else { + _sqlite3VdbeChangeP2(tls, p, addr, (*TVdbe)(unsafe.Pointer(p)).FnOp) + } +} + +func _sqlite3VdbeLeave(tls *libc.TLS, p uintptr) { + if (*TVdbe)(unsafe.Pointer(p)).FlockMask == uint32(0) { + return + } /* The common case */ + _vdbeLeave(tls, p) +} + +// C documentation +// +// /* +// ** Link the SubProgram object passed as the second argument into the linked +// ** list at Vdbe.pSubProgram. This list is used to delete all sub-program +// ** objects when the VM is no longer required. +// */ +func _sqlite3VdbeLinkSubProgram(tls *libc.TLS, pVdbe uintptr, p uintptr) { + (*TSubProgram)(unsafe.Pointer(p)).FpNext = (*TVdbe)(unsafe.Pointer(pVdbe)).FpProgram + (*TVdbe)(unsafe.Pointer(pVdbe)).FpProgram = p +} + +// C documentation +// +// /* Generate code to cause the string zStr to be loaded into +// ** register iDest +// */ +func _sqlite3VdbeLoadString(tls *libc.TLS, p uintptr, iDest int32, zStr uintptr) (r int32) { + return _sqlite3VdbeAddOp4(tls, p, int32(OP_String8), 0, iDest, 0, zStr, 0) +} + +// C documentation +// +// /* +// ** Initialize bulk memory to be a consistent Mem object. +// ** +// ** The minimum amount of initialization feasible is performed. +// */ +func _sqlite3VdbeMemInit(tls *libc.TLS, pMem uintptr, db uintptr, flags Tu16) { + (*TMem)(unsafe.Pointer(pMem)).Fflags = flags + (*TMem)(unsafe.Pointer(pMem)).Fdb = db + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = 0 +} + +// C documentation +// +// /* Like sqlite3VdbeMemRelease() but faster for cases where we +// ** know in advance that the Mem is not MEM_Dyn or MEM_Agg. +// */ +func _sqlite3VdbeMemReleaseMalloc(tls *libc.TLS, p uintptr) { + if (*TMem)(unsafe.Pointer(p)).FszMalloc != 0 { + _vdbeMemClear(tls, p) + } +} + +// C documentation +// +// /* +// ** Delete any previous value and set the value stored in *pMem to val, +// ** manifest type REAL. +// */ +func _sqlite3VdbeMemSetDouble(tls *libc.TLS, pMem uintptr, val float64) { + _sqlite3VdbeMemSetNull(tls, pMem) + if !(_sqlite3IsNaN(tls, val) != 0) { + *(*float64)(unsafe.Pointer(pMem)) = val + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Real) + } +} + +func _sqlite3VdbeOneByteSerialTypeLen(tls *libc.TLS, serial_type Tu8) (r Tu8) { + return _sqlite3SmallTypeSizes[serial_type] +} + +/* +** If we are on an architecture with mixed-endian floating +** points (ex: ARM7) then swap the lower 4 bytes with the +** upper 4 bytes. Return the result. +** +** For most architectures, this is a no-op. +** +** (later): It is reported to me that the mixed-endian problem +** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems +** that early versions of GCC stored the two words of a 64-bit +** float in the wrong order. And that error has been propagated +** ever since. The blame is not necessarily with GCC, though. +** GCC might have just copying the problem from a prior compiler. +** I am also told that newer versions of GCC that follow a different +** ABI get the byte order right. +** +** Developers using SQLite on an ARM7 should compile and run their +** application using -DSQLITE_DEBUG=1 at least once. With DEBUG +** enabled, some asserts below will ensure that the byte order of +** floating point values is correct. +** +** (2007-08-30) Frank van Vugt has studied this problem closely +** and has send his findings to the SQLite developers. Frank +** writes that some Linux kernels offer floating point hardware +** emulation that uses only 32-bit mantissas instead of a full +** 48-bits as required by the IEEE standard. (This is the +** CONFIG_FPE_FASTFPE option.) On such systems, floating point +** byte swapping becomes very complicated. To avoid problems, +** the necessary byte swapping is carried out using a 64-bit integer +** rather than a 64-bit float. Frank assures us that the code here +** works for him. We, the developers, have no way to independently +** verify this, but Frank seems to know what he is talking about +** so we trust him. + */ + +/* Input "x" is a sequence of unsigned characters that represent a +** big-endian integer. Return the equivalent native integer + */ + +// C documentation +// +// /* +// ** Given a wildcard parameter name, return the index of the variable +// ** with that name. If there is no variable with the given name, +// ** return 0. +// */ +func _sqlite3VdbeParameterIndex(tls *libc.TLS, p uintptr, zName uintptr, nName int32) (r int32) { + if p == uintptr(0) || zName == uintptr(0) { + return 0 + } + return _sqlite3VListNameToNum(tls, (*TVdbe)(unsafe.Pointer(p)).FpVList, zName, nName) +} + +// C documentation +// +// /* +// ** Return the Parse object that owns a Vdbe object. +// */ +func _sqlite3VdbeParser(tls *libc.TLS, p uintptr) (r uintptr) { + return (*TVdbe)(unsafe.Pointer(p)).FpParse +} + +// C documentation +// +// /* +// ** Return the SQLITE_PREPARE flags for a Vdbe. +// */ +func _sqlite3VdbePrepareFlags(tls *libc.TLS, v uintptr) (r Tu8) { + return (*TVdbe)(unsafe.Pointer(v)).FprepFlags +} + +func _sqlite3VdbeRecordCompare(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr) (r int32) { + return _sqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, 0) +} + +// C documentation +// +// /* +// ** Each VDBE holds the result of the most recent sqlite3_step() call +// ** in p->rc. This routine sets that result back to SQLITE_OK. +// */ +func _sqlite3VdbeResetStepResult(tls *libc.TLS, p uintptr) { + (*TVdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK +} + +func _sqlite3VdbeResolveLabel(tls *libc.TLS, v uintptr, x int32) { + var j int32 + var p uintptr + _, _ = j, p + p = (*TVdbe)(unsafe.Pointer(v)).FpParse + j = ^x + if (*TParse)(unsafe.Pointer(p)).FnLabelAlloc+(*TParse)(unsafe.Pointer(p)).FnLabel < 0 { + _resizeResolveLabel(tls, p, v, j) + } else { + /* Labels may only be resolved once */ + **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(p)).FaLabel + uintptr(j)*4)) = (*TVdbe)(unsafe.Pointer(v)).FnOp + } +} + +// C documentation +// +// /* +// ** Rewind the VDBE back to the beginning in preparation for +// ** running it. +// */ +func _sqlite3VdbeRewind(tls *libc.TLS, p uintptr) { + /* There should be at least one opcode. + */ + (*TVdbe)(unsafe.Pointer(p)).FeVdbeState = uint8(VDBE_READY_STATE) + (*TVdbe)(unsafe.Pointer(p)).Fpc = -int32(1) + (*TVdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + (*TVdbe)(unsafe.Pointer(p)).FerrorAction = uint8(OE_Abort) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + (*TVdbe)(unsafe.Pointer(p)).FcacheCtr = uint32(1) + (*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat = uint8(255) + (*TVdbe)(unsafe.Pointer(p)).FiStatement = 0 + (*TVdbe)(unsafe.Pointer(p)).FnFkConstraint = 0 +} + +// C documentation +// +// /* +// ** Mark the VDBE as one that can only be run one time. +// */ +func _sqlite3VdbeRunOnlyOnce(tls *libc.TLS, p uintptr) { + _sqlite3VdbeAddOp2(tls, p, int32(OP_Expire), int32(1), int32(1)) +} + +// C documentation +// +// /* +// ** Return the length of the data corresponding to the supplied serial-type. +// */ +func _sqlite3VdbeSerialTypeLen(tls *libc.TLS, serial_type Tu32) (r Tu32) { + if serial_type >= uint32(128) { + return (serial_type - uint32(12)) / uint32(2) + } else { + return uint32(_sqlite3SmallTypeSizes[serial_type]) + } + return r +} + +// C documentation +// +// /* +// ** Set the P4 on the most recently added opcode to the KeyInfo for the +// ** index given. +// */ +func _sqlite3VdbeSetP4KeyInfo(tls *libc.TLS, pParse uintptr, pIdx uintptr) { + var pKeyInfo, v uintptr + _, _ = pKeyInfo, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pKeyInfo = _sqlite3KeyInfoOfIndex(tls, pParse, pIdx) + if pKeyInfo != 0 { + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + } +} + +// C documentation +// +// /* +// ** This function returns a pointer to the array of opcodes associated with +// ** the Vdbe passed as the first argument. It is the callers responsibility +// ** to arrange for the returned array to be eventually freed using the +// ** vdbeFreeOpArray() function. +// ** +// ** Before returning, *pnOp is set to the number of entries in the returned +// ** array. Also, *pnMaxArg is set to the larger of its current value and +// ** the number of entries in the Vdbe.apArg[] array required to execute the +// ** returned program. +// */ +func _sqlite3VdbeTakeOpArray(tls *libc.TLS, p uintptr, pnOp uintptr, pnMaxArg uintptr) (r uintptr) { + var aOp uintptr + _ = aOp + aOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + /* Check that sqlite3VdbeUsesBtree() was not called on this VM */ + _resolveP2Values(tls, p, pnMaxArg) + **(**int32)(__ccgo_up(pnOp)) = (*TVdbe)(unsafe.Pointer(p)).FnOp + (*TVdbe)(unsafe.Pointer(p)).FaOp = uintptr(0) + return aOp +} + +// C documentation +// +// /* +// ** Copy the error code and error message belonging to the VDBE passed +// ** as the first argument to its database handle (so that they will be +// ** returned by calls to sqlite3_errcode() and sqlite3_errmsg()). +// ** +// ** This function does not clear the VDBE error code or message, just +// ** copies them to the database handle. +// */ +func _sqlite3VdbeTransferError(tls *libc.TLS, p uintptr) (r int32) { + var db uintptr + var rc int32 + _, _ = db, rc + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + rc = (*TVdbe)(unsafe.Pointer(p)).Frc + if (*TVdbe)(unsafe.Pointer(p)).FzErrMsg != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc = (*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc + 1 + _sqlite3BeginBenignMalloc(tls) + if (*Tsqlite3)(unsafe.Pointer(db)).FpErr == uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).FpErr = _sqlite3ValueNew(tls, db) + } + _sqlite3ValueSetStr(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr, -int32(1), (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, uint8(SQLITE_UTF8), uintptr(-libc.Int32FromInt32(1))) + _sqlite3EndBenignMalloc(tls) + (*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc = (*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc - 1 + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 { + _sqlite3ValueSetNull(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr) + } + } + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = rc + (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(1) + return rc +} + +// C documentation +// +// /* +// ** The destructor function for a ValueList object. This needs to be +// ** a separate function, unknowable to the application, to ensure that +// ** calls to sqlite3_vtab_in_first()/sqlite3_vtab_in_next() that are not +// ** preceded by activation of IN processing via sqlite3_vtab_int() do not +// ** try to access a fake ValueList object inserted by a hostile extension. +// */ +func _sqlite3VdbeValueListFree(tls *libc.TLS, pToDelete uintptr) { + Xsqlite3_free(tls, pToDelete) +} + +// C documentation +// +// /* +// ** The parser calls this routine when it sees the first token +// ** of an argument to the module name in a CREATE VIRTUAL TABLE statement. +// */ +func _sqlite3VtabArgInit(tls *libc.TLS, pParse uintptr) { + _addArgumentToVtab(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FsArg.Fz = uintptr(0) + (*TParse)(unsafe.Pointer(pParse)).FsArg.Fn = uint32(0) +} + +// C documentation +// +// /* +// ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored +// ** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored +// ** in memory obtained from sqlite3DbMalloc). +// */ +func _sqlite3VtabImportErrmsg(tls *libc.TLS, p uintptr, pVtab uintptr) { + var db uintptr + _ = db + if (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg != 0 { + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + _sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg) + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3DbStrDup(tls, db, (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Lock the virtual table so that it cannot be disconnected. +// ** Locks nest. Every lock should have a corresponding unlock. +// ** If an unlock is omitted, resources leaks will occur. +// ** +// ** If a disconnect is attempted while a virtual table is locked, +// ** the disconnect is deferred until all locks have been removed. +// */ +func _sqlite3VtabLock(tls *libc.TLS, pVTab uintptr) { + (*TVTable)(unsafe.Pointer(pVTab)).FnRef = (*TVTable)(unsafe.Pointer(pVTab)).FnRef + 1 +} + +// C documentation +// +// /* +// ** Decrement the reference count on a Module object. Destroy the +// ** module when the reference count reaches zero. +// */ +func _sqlite3VtabModuleUnref(tls *libc.TLS, db uintptr, pMod uintptr) { + (*TModule)(unsafe.Pointer(pMod)).FnRefModule = (*TModule)(unsafe.Pointer(pMod)).FnRefModule - 1 + if (*TModule)(unsafe.Pointer(pMod)).FnRefModule == 0 { + if (*TModule)(unsafe.Pointer(pMod)).FxDestroy != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TModule)(unsafe.Pointer(pMod)).FxDestroy})))(tls, (*TModule)(unsafe.Pointer(pMod)).FpAux) + } + _sqlite3DbFree(tls, db, pMod) + } +} + +// C documentation +// +// /* +// ** Decrement the ref-count on a virtual table object. When the ref-count +// ** reaches zero, call the xDisconnect() method to delete the object. +// */ +func _sqlite3VtabUnlock(tls *libc.TLS, pVTab uintptr) { + var db, p uintptr + _, _ = db, p + db = (*TVTable)(unsafe.Pointer(pVTab)).Fdb + (*TVTable)(unsafe.Pointer(pVTab)).FnRef = (*TVTable)(unsafe.Pointer(pVTab)).FnRef - 1 + if (*TVTable)(unsafe.Pointer(pVTab)).FnRef == 0 { + p = (*TVTable)(unsafe.Pointer(pVTab)).FpVtab + if p != 0 { + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(p)).FpModule)).FxDisconnect})))(tls, p) + } + _sqlite3VtabModuleUnref(tls, (*TVTable)(unsafe.Pointer(pVTab)).Fdb, (*TVTable)(unsafe.Pointer(pVTab)).FpMod) + _sqlite3DbFree(tls, db, pVTab) + } +} + +// C documentation +// +// /* +// ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list. +// ** +// ** This function may only be called when the mutexes associated with all +// ** shared b-tree databases opened using connection db are held by the +// ** caller. This is done to protect the sqlite3.pDisconnect list. The +// ** sqlite3.pDisconnect list is accessed only as follows: +// ** +// ** 1) By this function. In this case, all BtShared mutexes and the mutex +// ** associated with the database handle itself must be held. +// ** +// ** 2) By function vtabDisconnectAll(), when it adds a VTable entry to +// ** the sqlite3.pDisconnect list. In this case either the BtShared mutex +// ** associated with the database the virtual table is stored in is held +// ** or, if the virtual table is stored in a non-sharable database, then +// ** the database handle mutex is held. +// ** +// ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously +// ** by multiple threads. It is thread-safe. +// */ +func _sqlite3VtabUnlockList(tls *libc.TLS, db uintptr) { + var p, pNext uintptr + _, _ = p, pNext + p = (*Tsqlite3)(unsafe.Pointer(db)).FpDisconnect + if p != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FpDisconnect = uintptr(0) + for cond := true; cond; cond = p != 0 { + pNext = (*TVTable)(unsafe.Pointer(p)).FpNext + _sqlite3VtabUnlock(tls, p) + p = pNext + } + } +} + +// C documentation +// +// /* +// ** Cause the prepared statement that is associated with a call to +// ** xBestIndex to potentially use all schemas. If the statement being +// ** prepared is read-only, then just start read transactions on all +// ** schemas. But if this is a write operation, start writes on all +// ** schemas. +// ** +// ** This is used by the (built-in) sqlite_dbpage virtual table. +// */ +func _sqlite3VtabUsesAllSchemas(tls *libc.TLS, pParse uintptr) { + var i, nDb int32 + _, _ = i, nDb + nDb = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FnDb + i = 0 + for { + if !(i < nDb) { + break + } + _sqlite3CodeVerifySchema(tls, pParse, i) + goto _1 + _1: + ; + i = i + 1 + } + if (*TParse)(unsafe.Pointer(pParse)).FwriteMask != uint32(0) { + i = 0 + for { + if !(i < nDb) { + break + } + _sqlite3BeginWriteOperation(tls, pParse, 0, i) + goto _2 + _2: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** Begin a read transaction on the database. +// ** +// ** This routine used to be called sqlite3OpenSnapshot() and with good reason: +// ** it takes a snapshot of the state of the WAL and wal-index for the current +// ** instant in time. The current thread will continue to use this snapshot. +// ** Other threads might append new content to the WAL and wal-index but +// ** that extra content is ignored by the current thread. +// ** +// ** If the database contents have changes since the previous read +// ** transaction, then *pChanged is set to 1 before returning. The +// ** Pager layer will use this to know that its cache is stale and +// ** needs to be flushed. +// */ +func _sqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) { + var rc int32 + _ = rc + rc = _walBeginReadTransaction(tls, pWal, pChanged) + return rc +} + +// C documentation +// +// /* +// ** Return the size of the database in pages (or zero, if unknown). +// */ +func _sqlite3WalDbsize(tls *libc.TLS, pWal uintptr) (r TPgno) { + if pWal != 0 && int32((*TWal)(unsafe.Pointer(pWal)).FreadLock) >= 0 { + return (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage + } + return uint32(0) +} + +// C documentation +// +// /* +// ** Finish with a read transaction. All this does is release the +// ** read-lock. +// */ +func _sqlite3WalEndReadTransaction(tls *libc.TLS, pWal uintptr) { + if int32((*TWal)(unsafe.Pointer(pWal)).FreadLock) >= 0 { + _sqlite3WalEndWriteTransaction(tls, pWal) + _walUnlockShared(tls, pWal, int32(3)+int32((*TWal)(unsafe.Pointer(pWal)).FreadLock)) + (*TWal)(unsafe.Pointer(pWal)).FreadLock = int16(-int32(1)) + } +} + +// C documentation +// +// /* +// ** End a write transaction. The commit has already been done. This +// ** routine merely releases the lock. +// */ +func _sqlite3WalEndWriteTransaction(tls *libc.TLS, pWal uintptr) (r int32) { + if (*TWal)(unsafe.Pointer(pWal)).FwriteLock != 0 { + _walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, int32(1)) + (*TWal)(unsafe.Pointer(pWal)).FwriteLock = uint8(0) + (*TWal)(unsafe.Pointer(pWal)).FiReCksum = uint32(0) + (*TWal)(unsafe.Pointer(pWal)).FtruncateOnCommit = uint8(0) + } + return SQLITE_OK +} + +// C documentation +// +// /* Return the sqlite3_file object for the WAL file +// */ +func _sqlite3WalFile(tls *libc.TLS, pWal uintptr) (r uintptr) { + return (*TWal)(unsafe.Pointer(pWal)).FpWalFd +} + +/************** End of wal.c *************************************************/ +/************** Begin file btmutex.c *****************************************/ +/* +** 2007 August 27 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code used to implement mutexes on Btree objects. +** This code really belongs in btree.c. But btree.c is getting too +** big and we want to break it down some. This packaged seemed like +** a good breakout. + */ +/************** Include btreeInt.h in the middle of btmutex.c ****************/ +/************** Begin file btreeInt.h ****************************************/ +/* +** 2004 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file implements an external (disk-based) database using BTrees. +** For a detailed discussion of BTrees, refer to +** +** Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: +** "Sorting And Searching", pages 473-480. Addison-Wesley +** Publishing Company, Reading, Massachusetts. +** +** The basic idea is that each page of the file contains N database +** entries and N+1 pointers to subpages. +** +** ---------------------------------------------------------------- +** | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) | +** ---------------------------------------------------------------- +** +** All of the keys on the page that Ptr(0) points to have values less +** than Key(0). All of the keys on page Ptr(1) and its subpages have +** values greater than Key(0) and less than Key(1). All of the keys +** on Ptr(N) and its subpages have values greater than Key(N-1). And +** so forth. +** +** Finding a particular key requires reading O(log(M)) pages from the +** disk where M is the number of entries in the tree. +** +** In this implementation, a single file can hold one or more separate +** BTrees. Each BTree is identified by the index of its root page. The +** key and data for any entry are combined to form the "payload". A +** fixed amount of payload can be carried directly on the database +** page. If the payload is larger than the preset amount then surplus +** bytes are stored on overflow pages. The payload for an entry +** and the preceding pointer are combined to form a "Cell". Each +** page has a small header which contains the Ptr(N) pointer and other +** information such as the size of key and data. +** +** FORMAT DETAILS +** +** The file is divided into pages. The first page is called page 1, +** the second is page 2, and so forth. A page number of zero indicates +** "no such page". The page size can be any power of 2 between 512 and 65536. +** Each page can be either a btree page, a freelist page, an overflow +** page, or a pointer-map page. +** +** The first page is always a btree page. The first 100 bytes of the first +** page contain a special header (the "file header") that describes the file. +** The format of the file header is as follows: +** +** OFFSET SIZE DESCRIPTION +** 0 16 Header string: "SQLite format 3\000" +** 16 2 Page size in bytes. (1 means 65536) +** 18 1 File format write version +** 19 1 File format read version +** 20 1 Bytes of unused space at the end of each page +** 21 1 Max embedded payload fraction (must be 64) +** 22 1 Min embedded payload fraction (must be 32) +** 23 1 Min leaf payload fraction (must be 32) +** 24 4 File change counter +** 28 4 The size of the database in pages +** 32 4 First freelist page +** 36 4 Number of freelist pages in the file +** 40 60 15 4-byte meta values passed to higher layers +** +** 40 4 Schema cookie +** 44 4 File format of schema layer +** 48 4 Size of page cache +** 52 4 Largest root-page (auto/incr_vacuum) +** 56 4 1=UTF-8 2=UTF16le 3=UTF16be +** 60 4 User version +** 64 4 Incremental vacuum mode +** 68 4 Application-ID +** 72 20 unused +** 92 4 The version-valid-for number +** 96 4 SQLITE_VERSION_NUMBER +** +** All of the integer values are big-endian (most significant byte first). +** +** The file change counter is incremented when the database is changed +** This counter allows other processes to know when the file has changed +** and thus when they need to flush their cache. +** +** The max embedded payload fraction is the amount of the total usable +** space in a page that can be consumed by a single cell for standard +** B-tree (non-LEAFDATA) tables. A value of 255 means 100%. The default +** is to limit the maximum cell size so that at least 4 cells will fit +** on one page. Thus the default max embedded payload fraction is 64. +** +** If the payload for a cell is larger than the max payload, then extra +** payload is spilled to overflow pages. Once an overflow page is allocated, +** as many bytes as possible are moved into the overflow pages without letting +** the cell size drop below the min embedded payload fraction. +** +** The min leaf payload fraction is like the min embedded payload fraction +** except that it applies to leaf nodes in a LEAFDATA tree. The maximum +** payload fraction for a LEAFDATA tree is always 100% (or 255) and it +** not specified in the header. +** +** Each btree pages is divided into three sections: The header, the +** cell pointer array, and the cell content area. Page 1 also has a 100-byte +** file header that occurs before the page header. +** +** |----------------| +** | file header | 100 bytes. Page 1 only. +** |----------------| +** | page header | 8 bytes for leaves. 12 bytes for interior nodes +** |----------------| +** | cell pointer | | 2 bytes per cell. Sorted order. +** | array | | Grows downward +** | | v +** |----------------| +** | unallocated | +** | space | +** |----------------| ^ Grows upwards +** | cell content | | Arbitrary order interspersed with freeblocks. +** | area | | and free space fragments. +** |----------------| +** +** The page headers looks like this: +** +** OFFSET SIZE DESCRIPTION +** 0 1 Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf +** 1 2 byte offset to the first freeblock +** 3 2 number of cells on this page +** 5 2 first byte of the cell content area +** 7 1 number of fragmented free bytes +** 8 4 Right child (the Ptr(N) value). Omitted on leaves. +** +** The flags define the format of this btree page. The leaf flag means that +** this page has no children. The zerodata flag means that this page carries +** only keys and no data. The intkey flag means that the key is an integer +** which is stored in the key size entry of the cell header rather than in +** the payload area. +** +** The cell pointer array begins on the first byte after the page header. +** The cell pointer array contains zero or more 2-byte numbers which are +** offsets from the beginning of the page to the cell content in the cell +** content area. The cell pointers occur in sorted order. The system strives +** to keep free space after the last cell pointer so that new cells can +** be easily added without having to defragment the page. +** +** Cell content is stored at the very end of the page and grows toward the +** beginning of the page. +** +** Unused space within the cell content area is collected into a linked list of +** freeblocks. Each freeblock is at least 4 bytes in size. The byte offset +** to the first freeblock is given in the header. Freeblocks occur in +** increasing order. Because a freeblock must be at least 4 bytes in size, +** any group of 3 or fewer unused bytes in the cell content area cannot +** exist on the freeblock chain. A group of 3 or fewer free bytes is called +** a fragment. The total number of bytes in all fragments is recorded. +** in the page header at offset 7. +** +** SIZE DESCRIPTION +** 2 Byte offset of the next freeblock +** 2 Bytes in this freeblock +** +** Cells are of variable length. Cells are stored in the cell content area at +** the end of the page. Pointers to the cells are in the cell pointer array +** that immediately follows the page header. Cells is not necessarily +** contiguous or in order, but cell pointers are contiguous and in order. +** +** Cell content makes use of variable length integers. A variable +** length integer is 1 to 9 bytes where the lower 7 bits of each +** byte are used. The integer consists of all bytes that have bit 8 set and +** the first byte with bit 8 clear. The most significant byte of the integer +** appears first. A variable-length integer may not be more than 9 bytes long. +** As a special case, all 8 bits of the 9th byte are used as data. This +** allows a 64-bit integer to be encoded in 9 bytes. +** +** 0x00 becomes 0x00000000 +** 0x7f becomes 0x0000007f +** 0x81 0x00 becomes 0x00000080 +** 0x82 0x00 becomes 0x00000100 +** 0x80 0x7f becomes 0x0000007f +** 0x81 0x91 0xd1 0xac 0x78 becomes 0x12345678 +** 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081 +** +** Variable length integers are used for rowids and to hold the number of +** bytes of key and data in a btree cell. +** +** The content of a cell looks like this: +** +** SIZE DESCRIPTION +** 4 Page number of the left child. Omitted if leaf flag is set. +** var Number of bytes of data. Omitted if the zerodata flag is set. +** var Number of bytes of key. Or the key itself if intkey flag is set. +** * Payload +** 4 First page of the overflow chain. Omitted if no overflow +** +** Overflow pages form a linked list. Each page except the last is completely +** filled with data (pagesize - 4 bytes). The last page can have as little +** as 1 byte of data. +** +** SIZE DESCRIPTION +** 4 Page number of next overflow page +** * Data +** +** Freelist pages come in two subtypes: trunk pages and leaf pages. The +** file header points to the first in a linked list of trunk page. Each trunk +** page points to multiple leaf pages. The content of a leaf page is +** unspecified. A trunk page looks like this: +** +** SIZE DESCRIPTION +** 4 Page number of next trunk page +** 4 Number of leaf pointers on this page +** * zero or more pages numbers of leaves + */ +/* #include "sqliteInt.h" */ + +/* The following value is the maximum cell size assuming a maximum page +** size give above. + */ + +/* The maximum number of cells on a single page of the database. This +** assumes a minimum cell size of 6 bytes (4 bytes for the cell itself +** plus 2 bytes for the index to the cell in the page header). Such +** small cells will be rare, but they are possible. + */ + +// C documentation +// +// /* +// ** Search the wal file for page pgno. If found, set *piRead to the frame that +// ** contains the page. Otherwise, if pgno is not in the wal file, set *piRead +// ** to zero. +// ** +// ** Return SQLITE_OK if successful, or an error code if an error occurs. If an +// ** error does occur, the final value of *piRead is undefined. +// ** +// ** The difference between this function and walFindFrame() is that this +// ** function wraps walFindFrame() in an SEH_TRY{...} block. +// */ +func _sqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno TPgno, piRead uintptr) (r int32) { + var rc int32 + _ = rc + rc = _walFindFrame(tls, pWal, pgno, piRead) + return rc +} + +// C documentation +// +// /* +// ** Write a set of frames to the log. The caller must hold the write-lock +// ** on the log file (obtained using sqlite3WalBeginWriteTransaction()). +// ** +// ** The difference between this function and walFrames() is that this +// ** function wraps walFrames() in an SEH_TRY{...} block. +// */ +func _sqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, nTruncate TPgno, isCommit int32, sync_flags int32) (r int32) { + var rc int32 + _ = rc + rc = _walFrames(tls, pWal, szPage, pList, nTruncate, isCommit, sync_flags) + return rc +} + +// C documentation +// +// /* +// ** Change the size to which the WAL file is truncated on each reset. +// */ +func _sqlite3WalLimit(tls *libc.TLS, pWal uintptr, iLimit Ti64) { + if pWal != 0 { + (*TWal)(unsafe.Pointer(pWal)).FmxWalSize = iLimit + } +} + +// C documentation +// +// /* Try to open on pSnapshot when the next read-transaction starts +// */ +func _sqlite3WalSnapshotOpen(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) { + if pSnapshot != 0 && (*TWalIndexHdr)(unsafe.Pointer(pSnapshot)).FiVersion == uint32(0) { + /* iVersion==0 means that this is a call to sqlite3_snapshot_get(). In + ** this case set the bGetSnapshot flag so that if the call to + ** sqlite3_snapshot_get() is about to read transaction on this wal + ** file, it does not take read-lock 0 if the wal file has been completely + ** checkpointed. Taking read-lock 0 would work, but then it would be + ** possible for a subsequent writer to destroy the snapshot even while + ** this connection is holding its read-transaction open. This is contrary + ** to user expectations, so we avoid it by not taking read-lock 0. */ + (*TWal)(unsafe.Pointer(pWal)).FbGetSnapshot = int32(1) + } else { + (*TWal)(unsafe.Pointer(pWal)).FpSnapshot = pSnapshot + (*TWal)(unsafe.Pointer(pWal)).FbGetSnapshot = 0 + } +} + +// C documentation +// +// /* +// ** Release a lock obtained by an earlier successful call to +// ** sqlite3WalSnapshotCheck(). +// */ +func _sqlite3WalSnapshotUnlock(tls *libc.TLS, pWal uintptr) { + _walUnlockShared(tls, pWal, int32(WAL_CKPT_LOCK)) +} + +func _sqlite3WalkExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var v1 int32 + _ = v1 + if pExpr != 0 { + v1 = _sqlite3WalkExprNN(tls, pWalker, pExpr) + } else { + v1 = WRC_Continue + } + return v1 +} + +// C documentation +// +// /* +// ** Call sqlite3WalkExpr() for every expression in Select statement p. +// ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and +// ** on the compound select chain, p->pPrior. +// ** +// ** If it is not NULL, the xSelectCallback() callback is invoked before +// ** the walk of the expressions and FROM clause. The xSelectCallback2() +// ** method is invoked following the walk of the expressions and FROM clause, +// ** but only if both xSelectCallback and xSelectCallback2 are both non-NULL +// ** and if the expressions and FROM clause both return WRC_Continue; +// ** +// ** Return WRC_Continue under normal conditions. Return WRC_Abort if +// ** there is an abort request. +// ** +// ** If the Walker does not have an xSelectCallback() then this routine +// ** is a no-op returning WRC_Continue. +// */ +func _sqlite3WalkSelect(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + var rc int32 + _ = rc + if p == uintptr(0) { + return WRC_Continue + } + if (*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback == uintptr(0) { + return WRC_Continue + } + for cond := true; cond; cond = p != uintptr(0) { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback})))(tls, pWalker, p) + if rc != 0 { + return rc & int32(WRC_Abort) + } + if _sqlite3WalkSelectExpr(tls, pWalker, p) != 0 || _sqlite3WalkSelectFrom(tls, pWalker, p) != 0 { + return int32(WRC_Abort) + } + if (*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback2 != 0 { + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback2})))(tls, pWalker, p) + } + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** This is a no-op callback for Walker->xSelectCallback2. If this +// ** callback is set, then the Select->pWinDefn list is traversed. +// */ +func _sqlite3WalkWinDefnDummyCallback(tls *libc.TLS, pWalker uintptr, p uintptr) { + _ = pWalker + _ = p + /* No-op */ +} + +func _sqlite3WalkerDepthDecrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) { + _ = pSelect + (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth = (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth - 1 +} + +// C documentation +// +// /* Increase the walkerDepth when entering a subquery, and +// ** decrease when leaving the subquery. +// */ +func _sqlite3WalkerDepthIncrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) { + _ = pSelect + (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth = (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth + 1 + return WRC_Continue +} + +// C documentation +// +// /* +// ** Return the VDBE address or label to jump to in order to break +// ** out of a WHERE loop. +// */ +func _sqlite3WhereBreakLabel(tls *libc.TLS, pWInfo uintptr) (r int32) { + return (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak +} + +// C documentation +// +// /* +// ** Return the VDBE address or label to jump to in order to continue +// ** immediately with the next row of a WHERE clause. +// */ +func _sqlite3WhereContinueLabel(tls *libc.TLS, pWInfo uintptr) (r int32) { + return (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiContinue +} + +// C documentation +// +// /* +// ** Call exprAnalyze on all terms in a WHERE clause. +// ** +// ** Note that exprAnalyze() might add new virtual terms onto the +// ** end of the WHERE clause. We do not want to analyze these new +// ** virtual terms, so start analyzing at the end and work forward +// ** so that the added virtual terms are never processed. +// */ +func _sqlite3WhereExprAnalyze(tls *libc.TLS, pTabList uintptr, pWC uintptr) { + var i int32 + _ = i + i = (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm - int32(1) + for { + if !(i >= 0) { + break + } + _exprAnalyze(tls, pTabList, pWC, i) + goto _1 + _1: + ; + i = i - 1 + } +} + +func _sqlite3WhereExprUsage(tls *libc.TLS, pMaskSet uintptr, p uintptr) (r TBitmask) { + var v1 uint64 + _ = v1 + if p != 0 { + v1 = _sqlite3WhereExprUsageNN(tls, pMaskSet, p) + } else { + v1 = uint64(0) + } + return v1 +} + +// C documentation +// +// /* +// ** Return the bitmask for the given cursor number. Return 0 if +// ** iCursor is not in the set. +// */ +func _sqlite3WhereGetMask(tls *libc.TLS, pMaskSet uintptr, iCursor int32) (r TBitmask) { + var i int32 + _ = i + if **(**int32)(__ccgo_up(pMaskSet + 8)) == iCursor { + return uint64(1) + } + i = int32(1) + for { + if !(i < (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn) { + break + } + if **(**int32)(__ccgo_up(pMaskSet + 8 + uintptr(i)*4)) == iCursor { + return libc.Uint64FromInt32(1) << i + } + goto _1 + _1: + ; + i = i + 1 + } + return uint64(0) +} + +// C documentation +// +// /* +// ** Return the number of ORDER BY terms that are satisfied by the +// ** WHERE clause. A return of 0 means that the output must be +// ** completely sorted. A return equal to the number of ORDER BY +// ** terms means that no sorting is needed at all. A return that +// ** is positive but less than the number of ORDER BY terms means that +// ** block sorting is required. +// */ +func _sqlite3WhereIsOrdered(tls *libc.TLS, pWInfo uintptr) (r int32) { + var v1 int32 + _ = v1 + if int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) < 0 { + v1 = 0 + } else { + v1 = int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) + } + return v1 +} + +// C documentation +// +// /* +// ** Return the estimated number of output rows from a WHERE clause +// */ +func _sqlite3WhereOutputRowCount(tls *libc.TLS, pWInfo uintptr) (r TLogEst) { + return (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut +} + +var _sqlite3WhereTrace = uint32(0) + +// C documentation +// +// /* +// ** Attach PARTITION and ORDER BY clauses pPartition and pOrderBy to window +// ** pWin. Also, if parameter pBase is not NULL, set pWin->zBase to the +// ** equivalent nul-terminated string. +// */ +func _sqlite3WindowAssemble(tls *libc.TLS, pParse uintptr, pWin uintptr, pPartition uintptr, pOrderBy uintptr, pBase uintptr) (r uintptr) { + if pWin != 0 { + (*TWindow)(unsafe.Pointer(pWin)).FpPartition = pPartition + (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy = pOrderBy + if pBase != 0 { + (*TWindow)(unsafe.Pointer(pWin)).FzBase = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TToken)(unsafe.Pointer(pBase)).Fz, uint64((*TToken)(unsafe.Pointer(pBase)).Fn)) + } + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPartition) + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pOrderBy) + } + return pWin +} + +// C documentation +// +// /* +// ** Free the Window object passed as the second argument. +// */ +func _sqlite3WindowDelete(tls *libc.TLS, db uintptr, p uintptr) { + if p != 0 { + _sqlite3WindowUnlinkFromSelect(tls, p) + _sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpFilter) + _sqlite3ExprListDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpPartition) + _sqlite3ExprListDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpOrderBy) + _sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpEnd) + _sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpStart) + _sqlite3DbFree(tls, db, (*TWindow)(unsafe.Pointer(p)).FzName) + _sqlite3DbFree(tls, db, (*TWindow)(unsafe.Pointer(p)).FzBase) + _sqlite3DbFree(tls, db, p) + } +} + +// C documentation +// +// /* +// ** Free the linked list of Window objects starting at the second argument. +// */ +func _sqlite3WindowListDelete(tls *libc.TLS, db uintptr, p uintptr) { + var pNext uintptr + _ = pNext + for p != 0 { + pNext = (*TWindow)(unsafe.Pointer(p)).FpNextWin + _sqlite3WindowDelete(tls, db, p) + p = pNext + } +} + +// C documentation +// +// /* +// ** Unlink the Window object from the Select to which it is attached, +// ** if it is attached. +// */ +func _sqlite3WindowUnlinkFromSelect(tls *libc.TLS, p uintptr) { + if (*TWindow)(unsafe.Pointer(p)).FppThis != 0 { + **(**uintptr)(__ccgo_up((*TWindow)(unsafe.Pointer(p)).FppThis)) = (*TWindow)(unsafe.Pointer(p)).FpNextWin + if (*TWindow)(unsafe.Pointer(p)).FpNextWin != 0 { + (*TWindow)(unsafe.Pointer((*TWindow)(unsafe.Pointer(p)).FpNextWin)).FppThis = (*TWindow)(unsafe.Pointer(p)).FppThis + } + (*TWindow)(unsafe.Pointer(p)).FppThis = uintptr(0) + } +} + +func _sqlite3WithDeleteGeneric(tls *libc.TLS, db uintptr, pWith uintptr) { + _sqlite3WithDelete(tls, db, pWith) +} + +/************** End of build.c ***********************************************/ +/************** Begin file callback.c ****************************************/ +/* +** 2005 May 23 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains functions used to access the internal hash tables +** of user defined functions and collation sequences. + */ + +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* The code generator maintains a stack of active WITH clauses +// ** with the inner-most WITH clause being at the top of the stack. +// ** +// ** This routine pushes the WITH clause passed as the second argument +// ** onto the top of the stack. If argument bFree is true, then this +// ** WITH clause will never be popped from the stack but should instead +// ** be freed along with the Parse object. In other cases, when +// ** bFree==0, the With object will be freed along with the SELECT +// ** statement with which it is associated. +// ** +// ** This routine returns a copy of pWith. Or, if bFree is true and +// ** the pWith object is destroyed immediately due to an OOM condition, +// ** then this routine return NULL. +// ** +// ** If bFree is true, do not continue to use the pWith pointer after +// ** calling this routine, Instead, use only the return value. +// */ +func _sqlite3WithPush(tls *libc.TLS, pParse uintptr, pWith uintptr, bFree Tu8) (r uintptr) { + if pWith != 0 { + if bFree != 0 { + pWith = _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3WithDeleteGeneric), pWith) + if pWith == uintptr(0) { + return uintptr(0) + } + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + (*TWith)(unsafe.Pointer(pWith)).FpOuter = (*TParse)(unsafe.Pointer(pParse)).FpWith + (*TParse)(unsafe.Pointer(pParse)).FpWith = pWith + } + } + return pWith +} + +var _sqlite3aEQb = uintptr(unsafe.Pointer(&_sqlite3UpperToLower)) + uintptr(libc.Int32FromInt32(256)+libc.Int32FromInt32(6)-libc.Int32FromInt32(OP_Ne)) + +var _sqlite3aGTb = uintptr(unsafe.Pointer(&_sqlite3UpperToLower)) + uintptr(libc.Int32FromInt32(256)+libc.Int32FromInt32(12)-libc.Int32FromInt32(OP_Ne)) + +var _sqlite3aLTb = uintptr(unsafe.Pointer(&_sqlite3UpperToLower)) + uintptr(libc.Int32FromInt32(256)-libc.Int32FromInt32(OP_Ne)) + +// C documentation +// +// /* +// ** Close a DBSTAT cursor. +// */ +func _statClose(tls *libc.TLS, pCursor uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCursor + _statResetCsr(tls, pCsr) + Xsqlite3_finalize(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + Xsqlite3_free(tls, pCsr) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Disconnect from or destroy the DBSTAT virtual table. +// */ +func _statDisconnect(tls *libc.TLS, pVtab uintptr) (r int32) { + Xsqlite3_free(tls, pVtab) + return SQLITE_OK +} + +// C documentation +// +// /* Resize the space-used counters inside of the cursor */ +func _statResetCounts(tls *libc.TLS, pCsr uintptr) { + (*TStatCursor)(unsafe.Pointer(pCsr)).FnCell = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FnMxPayload = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FnUnused = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FnPayload = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FszPage = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage = 0 +} + +func _subjournalPageIfRequired(tls *libc.TLS, pPg uintptr) (r int32) { + if _subjRequiresPage(tls, pPg) != 0 { + return _subjournalPage(tls, pPg) + } else { + return SQLITE_OK + } + return r +} + +// C documentation +// +// /* +// ** Return a pointer to the Table structure for the table that a trigger +// ** is set on. +// */ +func _tableOfTrigger(tls *libc.TLS, pTrigger uintptr) (r uintptr) { + return _sqlite3HashFind(tls, (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema+8, (*TTrigger)(unsafe.Pointer(pTrigger)).Ftable) +} + +// C documentation +// +// /* +// ** Should table pTab be skipped when doing an integrity_check? +// ** Return true or false. +// ** +// ** If pObjTab is not null, the return true if pTab matches pObjTab. +// ** +// ** If pObjTab is null, then return true only if pTab is an imposter table. +// */ +func _tableSkipIntegrityCheck(tls *libc.TLS, pTab uintptr, pObjTab uintptr) (r int32) { + if pObjTab != 0 { + return libc.BoolInt32(pTab != pObjTab) + } else { + return libc.BoolInt32((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Imposter) != uint32(0)) + } + return r +} + +func _totalFinalize(tls *libc.TLS, context uintptr) { + var p uintptr + var r float64 + _, _ = p, r + r = float64(0) + p = Xsqlite3_aggregate_context(tls, context, 0) + if p != 0 { + if (*TSumCtx)(unsafe.Pointer(p)).Fapprox != 0 { + r = (*TSumCtx)(unsafe.Pointer(p)).FrSum + if !(_sqlite3IsOverflow(tls, (*TSumCtx)(unsafe.Pointer(p)).FrErr) != 0) { + r = r + (*TSumCtx)(unsafe.Pointer(p)).FrErr + } + } else { + r = float64((*TSumCtx)(unsafe.Pointer(p)).FiSum) + } + } + Xsqlite3_result_double(tls, context, r) +} + +// C documentation +// +// /* +// ** Implementation of the total_changes() SQL function. The return value is +// ** the same as the sqlite3_total_changes64() API function. +// */ +func _total_changes(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + var db uintptr + _ = db + db = Xsqlite3_context_db_handle(tls, context) + _ = NotUsed + _ = NotUsed2 + /* IMP: R-11217-42568 This function is a wrapper around the + ** sqlite3_total_changes64() C/C++ interface. */ + Xsqlite3_result_int64(tls, context, Xsqlite3_total_changes64(tls, db)) +} + +var _totals = [12]Tu8{ + 1: uint8(1), + 2: uint8(3), + 3: uint8(8), + 4: uint8(18), + 5: uint8(33), + 6: uint8(53), + 7: uint8(78), + 8: uint8(103), + 9: uint8(128), + 10: uint8(178), + 11: uint8(228), +} + +/* A complex statement machine used to detect the end of a CREATE TRIGGER + ** statement. This is the normal case. + */ +var _trans = [8][8]Tu8{ + 0: { + 0: uint8(1), + 2: uint8(2), + 3: uint8(3), + 4: uint8(4), + 5: uint8(2), + 6: uint8(2), + 7: uint8(2), + }, + 1: { + 0: uint8(1), + 1: uint8(1), + 2: uint8(2), + 3: uint8(3), + 4: uint8(4), + 5: uint8(2), + 6: uint8(2), + 7: uint8(2), + }, + 2: { + 0: uint8(1), + 1: uint8(2), + 2: uint8(2), + 3: uint8(2), + 4: uint8(2), + 5: uint8(2), + 6: uint8(2), + 7: uint8(2), + }, + 3: { + 0: uint8(1), + 1: uint8(3), + 2: uint8(3), + 3: uint8(2), + 4: uint8(4), + 5: uint8(2), + 6: uint8(2), + 7: uint8(2), + }, + 4: { + 0: uint8(1), + 1: uint8(4), + 2: uint8(2), + 3: uint8(2), + 4: uint8(2), + 5: uint8(4), + 6: uint8(5), + 7: uint8(2), + }, + 5: { + 0: uint8(6), + 1: uint8(5), + 2: uint8(5), + 3: uint8(5), + 4: uint8(5), + 5: uint8(5), + 6: uint8(5), + 7: uint8(5), + }, + 6: { + 0: uint8(6), + 1: uint8(6), + 2: uint8(5), + 3: uint8(5), + 4: uint8(5), + 5: uint8(5), + 6: uint8(5), + 7: uint8(7), + }, + 7: { + 0: uint8(1), + 1: uint8(7), + 2: uint8(5), + 3: uint8(5), + 4: uint8(5), + 5: uint8(5), + 6: uint8(5), + 7: uint8(5), + }, +} + +// C documentation +// +// /* +// ** Parse context structure pFrom has just been used to create a sub-vdbe +// ** (trigger program). If an error has occurred, transfer error information +// ** from pFrom to pTo. +// */ +func _transferParseError(tls *libc.TLS, pTo uintptr, pFrom uintptr) { + if (*TParse)(unsafe.Pointer(pTo)).FnErr == 0 { + (*TParse)(unsafe.Pointer(pTo)).FzErrMsg = (*TParse)(unsafe.Pointer(pFrom)).FzErrMsg + (*TParse)(unsafe.Pointer(pTo)).FnErr = (*TParse)(unsafe.Pointer(pFrom)).FnErr + (*TParse)(unsafe.Pointer(pTo)).Frc = (*TParse)(unsafe.Pointer(pFrom)).Frc + } else { + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pFrom)).Fdb, (*TParse)(unsafe.Pointer(pFrom)).FzErrMsg) + } +} + +// C documentation +// +// /* +// ** Return the type of the argument. +// */ +func _typeofFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + var i int32 + _ = i + i = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) - int32(1) + _ = NotUsed + /* EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns + ** the datatype code for the initial datatype of the sqlite3_value object + ** V. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT, + ** SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */ + Xsqlite3_result_text(tls, context, _azType2[i], -int32(1), libc.UintptrFromInt32(0)) +} + +// C documentation +// +// /* +// ** unixepoch( TIMESTRING, MOD, MOD, ...) +// ** +// ** Return the number of seconds (including fractional seconds) since +// ** the unix epoch of 1970-01-01 00:00:00 GMT. +// */ +func _unixepochFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* x at bp+0 */ TDateTime + if _isDate(tls, context, argc, argv, bp) == 0 { + _computeJD(tls, bp) + if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { + Xsqlite3_result_double(tls, context, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD-libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000000))/float64(1000)) + } else { + Xsqlite3_result_int64(tls, context, (**(**TDateTime)(__ccgo_up(bp))).FiJD/int64(1000)-libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) + } + } +} + +// C documentation +// +// /* +// ** Release the BtShared mutex associated with B-Tree handle p and +// ** clear the p->locked boolean. +// */ +func _unlockBtreeMutex(tls *libc.TLS, p uintptr) { + var pBt uintptr + _ = pBt + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + Xsqlite3_mutex_leave(tls, (*TBtShared)(unsafe.Pointer(pBt)).Fmutex) + (*TBtree)(unsafe.Pointer(p)).Flocked = uint8(0) +} + +func _updateMapping(tls *libc.TLS, pRtree uintptr, iRowid Ti64, pNode uintptr, iHeight int32) (r int32) { + var p, pChild, xSetMapping, v1 uintptr + _, _, _, _ = p, pChild, xSetMapping, v1 + if iHeight == 0 { + v1 = __ccgo_fp(_rowidWrite) + } else { + v1 = __ccgo_fp(_parentWrite) + } + xSetMapping = v1 + if iHeight > 0 { + pChild = _nodeHashLookup(tls, pRtree, iRowid) + p = pNode + for { + if !(p != 0) { + break + } + if p == pChild { + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= 0 && iJD <= libc.Int64FromInt32(0x1a640)<z field is not duplicated. If +// ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z +// ** and flags gets srcType (either MEM_Ephem or MEM_Static). +// */ +func _vdbeClrCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, eType int32) { + _vdbeMemClearExternAndSetNull(tls, pTo) + _sqlite3VdbeMemShallowCopy(tls, pTo, pFrom, eType) +} + +// C documentation +// +// /* +// ** Launch a background thread to populate aFile[1] of pIncr. +// */ +func _vdbeIncrBgPopulate(tls *libc.TLS, pIncr uintptr) (r int32) { + var p uintptr + _ = p + p = pIncr + return _vdbeSorterCreateThread(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask, __ccgo_fp(_vdbeIncrPopulateThread), p) +} + +// C documentation +// +// /* +// ** Set the "use-threads" flag on object pIncr. +// */ +func _vdbeIncrMergerSetThreads(tls *libc.TLS, pIncr uintptr) { + (*TIncrMerger)(unsafe.Pointer(pIncr)).FbUseThread = int32(1) + (*TSortSubtask)(unsafe.Pointer((*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask)).Ffile2.FiEof -= int64((*TIncrMerger)(unsafe.Pointer(pIncr)).FmxSz) +} + +// C documentation +// +// /* +// ** Return the symbolic name for the data type of a pMem +// */ +func _vdbeMemTypeName(tls *libc.TLS, pMem uintptr) (r uintptr) { + return _azTypes[Xsqlite3_value_type(tls, pMem)-int32(1)] +} + +// C documentation +// +// /* +// ** If the PmaReader passed as the first argument is not an incremental-reader +// ** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes +// ** the vdbePmaReaderIncrMergeInit() function with the parameters passed to +// ** this routine to initialize the incremental merge. +// ** +// ** If the IncrMerger object is multi-threaded (IncrMerger.bUseThread==1), +// ** then a background thread is launched to call vdbePmaReaderIncrMergeInit(). +// ** Or, if the IncrMerger is single threaded, the same function is called +// ** using the current thread. +// */ +func _vdbePmaReaderIncrInit(tls *libc.TLS, pReadr uintptr, eMode int32) (r int32) { + var pCtx, pIncr uintptr + var rc int32 + _, _, _ = pCtx, pIncr, rc + pIncr = (*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr /* Incremental merger */ + rc = SQLITE_OK /* Return code */ + if pIncr != 0 { + if (*TIncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { + pCtx = pReadr + rc = _vdbeSorterCreateThread(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask, __ccgo_fp(_vdbePmaReaderBgIncrInit), pCtx) + } else { + rc = _vdbePmaReaderIncrMergeInit(tls, pReadr, eMode) + } + } + return rc +} + +// C documentation +// +// /* +// ** Write value iVal encoded as a varint to the PMA. Return +// ** SQLITE_OK if successful, or an SQLite error code if an error occurs. +// */ +func _vdbePmaWriteVarint(tls *libc.TLS, p uintptr, iVal Tu64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte int32 + var _ /* aByte at bp+0 */ [10]Tu8 + _ = nByte + nByte = _sqlite3PutVarint(tls, bp, iVal) + _vdbePmaWriteBlob(tls, p, bp, nByte) +} + +// C documentation +// +// /* +// ** The pMem is known to contain content that needs to be destroyed prior +// ** to a value change. So invoke the destructor, then set the value to +// ** a 64-bit integer. +// */ +func _vdbeReleaseAndSetInt64(tls *libc.TLS, pMem uintptr, val Ti64) { + _sqlite3VdbeMemSetNull(tls, pMem) + *(*Ti64)(unsafe.Pointer(pMem)) = val + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Int) +} + +// C documentation +// +// /* +// ** If it has not already been allocated, allocate the UnpackedRecord +// ** structure at pTask->pUnpacked. Return SQLITE_OK if successful (or +// ** if no allocation was required), or SQLITE_NOMEM otherwise. +// */ +func _vdbeSortAllocUnpacked(tls *libc.TLS, pTask uintptr) (r int32) { + if (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) { + (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked = _sqlite3VdbeAllocUnpackedRecord(tls, (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo) + if (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TUnpackedRecord)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FnField = (*TKeyInfo)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField + (*TUnpackedRecord)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode = uint8(0) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2, +// ** size nKey2 bytes). Use (pTask->pKeyInfo) for the collation sequences +// ** used by the comparison. Return the result of the comparison. +// ** +// ** If IN/OUT parameter *pbKey2Cached is true when this function is called, +// ** it is assumed that (pTask->pUnpacked) contains the unpacked version +// ** of key2. If it is false, (pTask->pUnpacked) is populated with the unpacked +// ** version of key2 and *pbKey2Cached set to true before returning. +// ** +// ** If an OOM error is encountered, (pTask->pUnpacked->error_rc) is set +// ** to SQLITE_NOMEM. +// */ +func _vdbeSorterCompare(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) (r int32) { + var r2 uintptr + _ = r2 + r2 = (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked + if !(**(**int32)(__ccgo_up(pbKey2Cached)) != 0) { + _sqlite3VdbeRecordUnpack(tls, nKey2, pKey2, r2) + **(**int32)(__ccgo_up(pbKey2Cached)) = int32(1) + } + return _sqlite3VdbeRecordCompare(tls, nKey1, pKey1, r2) +} + +// C documentation +// +// /* +// ** A version of vdbeSorterCompare() that assumes that it has already been +// ** determined that the first field of key1 is equal to the first field of +// ** key2. +// */ +func _vdbeSorterCompareTail(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) (r int32) { + var r2 uintptr + _ = r2 + r2 = (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked + if **(**int32)(__ccgo_up(pbKey2Cached)) == 0 { + _sqlite3VdbeRecordUnpack(tls, nKey2, pKey2, r2) + **(**int32)(__ccgo_up(pbKey2Cached)) = int32(1) + } + return _sqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, r2, int32(1)) +} + +// C documentation +// +// /* +// ** Launch a background thread to run xTask(pIn). +// */ +func _vdbeSorterCreateThread(tls *libc.TLS, pTask uintptr, __ccgo_fp_xTask uintptr, pIn uintptr) (r int32) { + return _sqlite3ThreadCreate(tls, pTask, __ccgo_fp_xTask, pIn) +} + +// C documentation +// +// /* +// ** Attempt to memory map file pFile. If successful, set *pp to point to the +// ** new mapping and return SQLITE_OK. If the mapping is not attempted +// ** (because the file is too large or the VFS layer is configured not to use +// ** mmap), return SQLITE_OK and set *pp to NULL. +// ** +// ** Or, if an error occurs, return an SQLite error code. The final value of +// ** *pp is undefined in this case. +// */ +func _vdbeSorterMapFile(tls *libc.TLS, pTask uintptr, pFile uintptr, pp uintptr) (r int32) { + var pFd uintptr + var rc int32 + _, _ = pFd, rc + rc = SQLITE_OK + if (*TSorterFile)(unsafe.Pointer(pFile)).FiEof <= int64((*Tsqlite3)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb)).FnMaxSorterMmap) { + pFd = (*TSorterFile)(unsafe.Pointer(pFile)).FpFd + if (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= int32(3) { + rc = _sqlite3OsFetch(tls, pFd, 0, int32((*TSorterFile)(unsafe.Pointer(pFile)).FiEof), pp) + } + } + return rc +} + +// C documentation +// +// /* +// ** Return the depth of a tree comprising nPMA PMAs, assuming a fanout of +// ** SORTER_MAX_MERGE_COUNT. The returned value does not include leaf nodes. +// ** +// ** i.e. +// ** +// ** nPMA<=16 -> TreeDepth() == 0 +// ** nPMA<=256 -> TreeDepth() == 1 +// ** nPMA<=65536 -> TreeDepth() == 2 +// */ +func _vdbeSorterTreeDepth(tls *libc.TLS, nPMA int32) (r int32) { + var nDepth int32 + var nDiv Ti64 + _, _ = nDepth, nDiv + nDepth = 0 + nDiv = int64(SORTER_MAX_MERGE_COUNT) + for nDiv < int64(nPMA) { + nDiv = nDiv * int64(SORTER_MAX_MERGE_COUNT) + nDepth = nDepth + 1 + } + return nDepth +} + +// C documentation +// +// /* +// ** Implementation of the sqlite_version() function. The result is the version +// ** of the SQLite library that is running. +// */ +func _versionFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + _ = NotUsed + _ = NotUsed2 + /* IMP: R-48699-48617 This function is an SQL wrapper around the + ** sqlite3_libversion() C-interface. */ + Xsqlite3_result_text(tls, context, Xsqlite3_libversion(tls), -int32(1), libc.UintptrFromInt32(0)) +} + +var _vfsFlags = libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) | libc.Int32FromInt32(SQLITE_OPEN_TRANSIENT_DB) + +/************** End of vdbe.c ************************************************/ +/************** Begin file vdbeblob.c ****************************************/ +/* +** 2007 May 1 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code used to implement incremental BLOB I/O. + */ + +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +// C documentation +// +// /* +// ** The list of all registered VFS implementations. +// */ +var _vfsList = uintptr(0) + +// C documentation +// +// /* +// ** Unlink a VFS from the linked list +// */ +func _vfsUnlink(tls *libc.TLS, pVfs uintptr) { + var p uintptr + _ = p + if pVfs == uintptr(0) { + /* No-op */ + } else { + if _vfsList == pVfs { + _vfsList = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext + } else { + if _vfsList != 0 { + p = _vfsList + for (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext != 0 && (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext != pVfs { + p = (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext + } + if (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext == pVfs { + (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext + } + } + } + } +} + +/* Template for VFS */ +var _vfs_template = Tsqlite3_vfs{ + FiVersion: int32(1), +} + +// C documentation +// +// /* +// ** Attempt to obtain the exclusive WAL lock defined by parameters lockIdx and +// ** n. If the attempt fails and parameter xBusy is not NULL, then it is a +// ** busy-handler function. Invoke it and retry the lock until either the +// ** lock is successfully obtained or the busy-handler returns 0. +// */ +func _walBusyLock(tls *libc.TLS, pWal uintptr, __ccgo_fp_xBusy uintptr, pBusyArg uintptr, lockIdx int32, n int32) (r int32) { + var rc int32 + _ = rc + for cond := true; cond; cond = __ccgo_fp_xBusy != 0 && rc == int32(SQLITE_BUSY) && (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xBusy})))(tls, pBusyArg) != 0 { + rc = _walLockExclusive(tls, pWal, lockIdx, n) + } + return rc +} + +// C documentation +// +// /* +// ** Generate or extend an 8 byte checksum based on the data in +// ** array aByte[] and the initial values of aIn[0] and aIn[1] (or +// ** initial values of 0 and 0 if aIn==NULL). +// ** +// ** The checksum is written back into aOut[] before returning. +// ** +// ** nByte must be a positive multiple of 8. +// */ +func _walChecksumBytes(tls *libc.TLS, nativeCksum int32, a uintptr, nByte int32, aIn uintptr, aOut uintptr) { + var aData, aEnd, v2 uintptr + var s1, s2, v1 Tu32 + _, _, _, _, _, _ = aData, aEnd, s1, s2, v1, v2 + aData = a + aEnd = a + uintptr(nByte) + if aIn != 0 { + s1 = **(**Tu32)(__ccgo_up(aIn)) + s2 = **(**Tu32)(__ccgo_up(aIn + 1*4)) + } else { + v1 = libc.Uint32FromInt32(0) + s2 = v1 + s1 = v1 + } + /* nByte is a multiple of 8 between 8 and 65536 */ + if !(nativeCksum != 0) { + for cond := true; cond; cond = aData < aEnd { + s1 = s1 + (**(**Tu32)(__ccgo_up(aData))&uint32(0x000000FF)<>int32(8) + **(**Tu32)(__ccgo_up(aData))&uint32(0xFF000000)>>int32(24) + s2) + s2 = s2 + (**(**Tu32)(__ccgo_up(aData + 1*4))&uint32(0x000000FF)<>int32(8) + **(**Tu32)(__ccgo_up(aData + 1*4))&uint32(0xFF000000)>>int32(24) + s1) + aData = aData + uintptr(2)*4 + } + } else { + if nByte%int32(64) == 0 { + for cond := true; cond; cond = aData < aEnd { + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + } + } else { + for cond := true; cond; cond = aData < aEnd { + v2 = aData + aData += 4 + s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2) + v2 = aData + aData += 4 + s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1) + } + } + } + **(**Tu32)(__ccgo_up(aOut)) = s1 + **(**Tu32)(__ccgo_up(aOut + 1*4)) = s2 +} + +// C documentation +// +// /* +// ** Return a pointer to the WalIndexHdr structure in the wal-index. +// */ +func _walIndexHdr(tls *libc.TLS, pWal uintptr) (r uintptr) { + return **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData)) +} + +/* +** The argument to this macro must be of type u32. On a little-endian +** architecture, it returns the u32 value that results from interpreting +** the 4 bytes as a big-endian value. On a big-endian architecture, it +** returns the value that would be produced by interpreting the 4 bytes +** of the input value as a little-endian integer. + */ + +// C documentation +// +// /* +// ** Free an iterator allocated by walIteratorInit(). +// */ +func _walIteratorFree(tls *libc.TLS, p uintptr) { + Xsqlite3_free(tls, p) +} + +func _walLockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) (r int32) { + var rc int32 + _ = rc + if (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 { + return SQLITE_OK + } + rc = _sqlite3OsShmLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n, libc.Int32FromInt32(SQLITE_SHM_LOCK)|libc.Int32FromInt32(SQLITE_SHM_EXCLUSIVE)) + return rc +} + +// C documentation +// +// /* +// ** Set or release locks on the WAL. Locks are either shared or exclusive. +// ** A lock cannot be moved directly between shared and exclusive - it must go +// ** through the unlocked state first. +// ** +// ** In locking_mode=EXCLUSIVE, all of these routines become no-ops. +// */ +func _walLockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) (r int32) { + var rc int32 + _ = rc + if (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 { + return SQLITE_OK + } + rc = _sqlite3OsShmLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, int32(1), libc.Int32FromInt32(SQLITE_SHM_LOCK)|libc.Int32FromInt32(SQLITE_SHM_SHARED)) + return rc +} + +func _walNextHash(tls *libc.TLS, iPriorHash int32) (r int32) { + return (iPriorHash + int32(1)) & (libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2) - libc.Int32FromInt32(1)) +} + +// C documentation +// +// /* +// ** This function is called just before writing a set of frames to the log +// ** file (see sqlite3WalFrames()). It checks to see if, instead of appending +// ** to the current log file, it is possible to overwrite the start of the +// ** existing log file with the new frames (i.e. "reset" the log). If so, +// ** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left +// ** unchanged. +// ** +// ** SQLITE_OK is returned if no error is encountered (regardless of whether +// ** or not pWal->hdr.mxFrame is modified). An SQLite error code is returned +// ** if an error occurs. +// */ +func _walRestartLog(tls *libc.TLS, pWal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pInfo uintptr + var rc int32 + var _ /* cnt at bp+0 */ int32 + var _ /* notUsed at bp+8 */ int32 + var _ /* salt1 at bp+4 */ Tu32 + _, _ = pInfo, rc + rc = SQLITE_OK + if int32((*TWal)(unsafe.Pointer(pWal)).FreadLock) == 0 { + pInfo = _walCkptInfo(tls, pWal) + if (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill > uint32(0) { + Xsqlite3_randomness(tls, int32(4), bp+4) + rc = _walLockExclusive(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(1), libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)-libc.Int32FromInt32(1)) + if rc == SQLITE_OK { + /* If all readers are using WAL_READ_LOCK(0) (in other words if no + ** readers are currently using the WAL), then the transactions + ** frames will overwrite the start of the existing log. Update the + ** wal-index header to reflect this. + ** + ** In theory it would be Ok to update the cache of the header only + ** at this point. But updating the actual wal-index header is also + ** safe and means there is no special case for sqlite3WalUndo() + ** to handle if this transaction is rolled back. */ + _walRestartHdr(tls, pWal, **(**Tu32)(__ccgo_up(bp + 4))) + _walUnlockExclusive(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(1), libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)-libc.Int32FromInt32(1)) + } else { + if rc != int32(SQLITE_BUSY) { + return rc + } + } + } + _walUnlockShared(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(0)) + (*TWal)(unsafe.Pointer(pWal)).FreadLock = int16(-int32(1)) + **(**int32)(__ccgo_up(bp)) = 0 + for cond := true; cond; cond = rc == -int32(1) { + rc = _walTryBeginRead(tls, pWal, bp+8, int32(1), bp) + } + /* BUSY not possible when useWal==1 */ + } + return rc +} + +func _walUnlockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) { + if (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 { + return + } + _sqlite3OsShmLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n, libc.Int32FromInt32(SQLITE_SHM_UNLOCK)|libc.Int32FromInt32(SQLITE_SHM_EXCLUSIVE)) +} + +func _walUnlockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) { + if (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 { + return + } + _sqlite3OsShmLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, int32(1), libc.Int32FromInt32(SQLITE_SHM_UNLOCK)|libc.Int32FromInt32(SQLITE_SHM_SHARED)) +} + +// C documentation +// +// /* +// ** Write iAmt bytes of content into the WAL file beginning at iOffset. +// ** Do a sync when crossing the p->iSyncPoint boundary. +// ** +// ** In other words, if iSyncPoint is in between iOffset and iOffset+iAmt, +// ** first write the part before iSyncPoint, then sync, then write the +// ** rest. +// */ +func _walWriteToLog(tls *libc.TLS, p uintptr, pContent uintptr, iAmt int32, iOffset Tsqlite3_int64) (r int32) { + var iFirstAmt, rc int32 + _, _ = iFirstAmt, rc + if iOffset < (*TWalWriter)(unsafe.Pointer(p)).FiSyncPoint && iOffset+int64(iAmt) >= (*TWalWriter)(unsafe.Pointer(p)).FiSyncPoint { + iFirstAmt = int32((*TWalWriter)(unsafe.Pointer(p)).FiSyncPoint - iOffset) + rc = _sqlite3OsWrite(tls, (*TWalWriter)(unsafe.Pointer(p)).FpFd, pContent, iFirstAmt, iOffset) + if rc != 0 { + return rc + } + iOffset = iOffset + int64(iFirstAmt) + iAmt = iAmt - iFirstAmt + pContent = uintptr(iFirstAmt) + pContent + rc = _sqlite3OsSync(tls, (*TWalWriter)(unsafe.Pointer(p)).FpFd, (*TWalWriter)(unsafe.Pointer(p)).FsyncFlags&int32(0x03)) + if iAmt == 0 || rc != 0 { + return rc + } + } + rc = _sqlite3OsWrite(tls, (*TWalWriter)(unsafe.Pointer(p)).FpFd, pContent, iAmt, iOffset) + return rc +} + +// C documentation +// +// /* +// ** Walk all expressions linked into the list of Window objects passed +// ** as the second argument. +// */ +func _walkWindowList(tls *libc.TLS, pWalker uintptr, pList uintptr, bOneOnly int32) (r int32) { + var pWin uintptr + var rc int32 + _, _ = pWin, rc + pWin = pList + for { + if !(pWin != 0) { + break + } + rc = _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) + if rc != 0 { + return int32(WRC_Abort) + } + rc = _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) + if rc != 0 { + return int32(WRC_Abort) + } + rc = _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpFilter) + if rc != 0 { + return int32(WRC_Abort) + } + rc = _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpStart) + if rc != 0 { + return int32(WRC_Abort) + } + rc = _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpEnd) + if rc != 0 { + return int32(WRC_Abort) + } + if bOneOnly != 0 { + break + } + goto _1 + _1: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Deallocate all memory associated with a WhereAndInfo object. +// */ +func _whereAndInfoDelete(tls *libc.TLS, db uintptr, p uintptr) { + _sqlite3WhereClauseClear(tls, p) + _sqlite3DbFree(tls, db, p) +} + +// C documentation +// +// /* +// ** This is an sqlite3ParserAddCleanup() callback that is invoked to +// ** free the Parse->pIdxEpr list when the Parse object is destroyed. +// */ +func _whereIndexedExprCleanup(tls *libc.TLS, db uintptr, pObject uintptr) { + var p, pp uintptr + _, _ = p, pp + pp = pObject + for **(**uintptr)(__ccgo_up(pp)) != uintptr(0) { + p = **(**uintptr)(__ccgo_up(pp)) + **(**uintptr)(__ccgo_up(pp)) = (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext + _sqlite3ExprDelete(tls, db, (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr) + _sqlite3DbFreeNN(tls, db, p) + } +} + +// C documentation +// +// /* +// ** Delete a WhereLoop object +// */ +func _whereLoopDelete(tls *libc.TLS, db uintptr, p uintptr) { + _whereLoopClear(tls, db, p) + _sqlite3DbNNFreeNN(tls, db, p) +} + +// C documentation +// +// /* +// ** Two WhereLoop objects, pCandidate and pBaseline, are known to have the +// ** same cost. Look deep into each to see if pCandidate is even slightly +// ** better than pBaseline. Return false if it is, if pCandidate is is preferred. +// ** Return true if pBaseline is preferred or if we cannot tell the difference. +// ** +// ** Result Meaning +// ** -------- ---------------------------------------------------------- +// ** true We cannot tell the difference in pCandidate and pBaseline +// ** false pCandidate seems like a better choice than pBaseline +// */ +func _whereLoopIsNoBetter(tls *libc.TLS, pCandidate uintptr, pBaseline uintptr) (r int32) { + if (*TWhereLoop)(unsafe.Pointer(pCandidate)).FwsFlags&uint32(WHERE_INDEXED) == uint32(0) { + return int32(1) + } + if (*TWhereLoop)(unsafe.Pointer(pBaseline)).FwsFlags&uint32(WHERE_INDEXED) == uint32(0) { + return int32(1) + } + if int32((*TIndex)(unsafe.Pointer((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pCandidate + 24))).FpIndex)).FszIdxRow) < int32((*TIndex)(unsafe.Pointer((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pBaseline + 24))).FpIndex)).FszIdxRow) { + return 0 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Deallocate all memory associated with a WhereOrInfo object. +// */ +func _whereOrInfoDelete(tls *libc.TLS, db uintptr, p uintptr) { + _sqlite3WhereClauseClear(tls, p) + _sqlite3DbFree(tls, db, p) +} + +// C documentation +// +// /* +// ** This is whereScanInit() for the case of an index on an expression. +// ** It is factored out into a separate tail-recursion subroutine so that +// ** the normal whereScanInit() routine, which is a high-runner, does not +// ** need to push registers onto the stack as part of its prologue. +// */ +func _whereScanInitIndexExpr(tls *libc.TLS, pScan uintptr) (r uintptr) { + (*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff = _sqlite3ExprAffinity(tls, (*TWhereScan)(unsafe.Pointer(pScan)).FpIdxExpr) + return _whereScanNext(tls, pScan) +} + +// C documentation +// +// /* +// ** Return true if the current frame should be cached in the ephemeral table, +// ** even if there are no xInverse() calls required. +// */ +func _windowCacheFrame(tls *libc.TLS, pMWin uintptr) (r int32) { + var pFunc, pWin uintptr + _, _ = pFunc, pWin + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { + return int32(1) + } + pWin = pMWin + for { + if !(pWin != 0) { + break + } + pFunc = (*TWindow)(unsafe.Pointer(pWin)).FpWFunc + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_nth_valueName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_first_valueName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_leadName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_lagName)) { + return int32(1) + } + goto _1 + _1: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + return 0 +} + +// C documentation +// +// /* +// ** Return true if it can be determined at compile time that expression +// ** pExpr evaluates to a value that, when cast to an integer, is greater +// ** than zero. False otherwise. +// ** +// ** If an OOM error occurs, this function sets the Parse.db.mallocFailed +// ** flag and returns zero. +// */ +func _windowExprGtZero(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db uintptr + var ret int32 + var _ /* pVal at bp+0 */ uintptr + _, _ = db, ret + ret = 0 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _sqlite3ValueFromExpr(tls, db, pExpr, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, uint8(SQLITE_AFF_NUMERIC), bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 && Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(bp))) > 0 { + ret = int32(1) + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp))) + return ret +} + +// C documentation +// +// /* +// ** regOld and regNew are each the first register in an array of size +// ** pOrderBy->nExpr. This function generates code to compare the two +// ** arrays of registers using the collation sequences and other comparison +// ** parameters specified by pOrderBy. +// ** +// ** If the two arrays are not equal, the contents of regNew is copied to +// ** regOld and control falls through. Otherwise, if the contents of the arrays +// ** are equal, an OP_Goto is executed. The address of the OP_Goto is returned. +// */ +func _windowIfNewPeer(tls *libc.TLS, pParse uintptr, pOrderBy uintptr, regNew int32, regOld int32, addr int32) { + var nVal int32 + var pKeyInfo, v uintptr + _, _, _ = nVal, pKeyInfo, v + v = _sqlite3GetVdbe(tls, pParse) + if pOrderBy != 0 { + nVal = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, pOrderBy, 0, 0) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Compare), regOld, regNew, nVal) + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), _sqlite3VdbeCurrentAddr(tls, v)+int32(1), addr, _sqlite3VdbeCurrentAddr(tls, v)+int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regNew, regOld, nVal-int32(1)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addr) + } +} + +// C documentation +// +// /* +// ** Generate VM code to read the window frames peer values from cursor csr into +// ** an array of registers starting at reg. +// */ +func _windowReadPeerValues(tls *libc.TLS, p uintptr, csr int32, reg int32) { + var i, iColOff, v1 int32 + var pMWin, pOrderBy, pPart, v uintptr + _, _, _, _, _, _, _ = i, iColOff, pMWin, pOrderBy, pPart, v, v1 + pMWin = (*TWindowCodeArg)(unsafe.Pointer(p)).FpMWin + pOrderBy = (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy + if pOrderBy != 0 { + v = _sqlite3GetVdbe(tls, (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse) + pPart = (*TWindow)(unsafe.Pointer(pMWin)).FpPartition + if pPart != 0 { + v1 = (*TExprList)(unsafe.Pointer(pPart)).FnExpr + } else { + v1 = 0 + } + iColOff = (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol + v1 + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), csr, iColOff+i, reg+i) + goto _2 + _2: + ; + i = i + 1 + } + } +} + +var _x = [32]uint8{ + 0: uint8(10), + 1: uint8(10), + 2: uint8(9), + 3: uint8(9), + 4: uint8(8), + 5: uint8(8), + 6: uint8(7), + 7: uint8(7), + 8: uint8(7), + 9: uint8(6), + 10: uint8(6), + 11: uint8(6), + 12: uint8(5), + 13: uint8(5), + 14: uint8(5), + 15: uint8(4), + 16: uint8(4), + 17: uint8(4), + 18: uint8(4), + 19: uint8(3), + 20: uint8(3), + 21: uint8(3), + 22: uint8(3), + 23: uint8(3), + 24: uint8(3), + 25: uint8(2), + 26: uint8(2), + 27: uint8(2), + 28: uint8(2), + 29: uint8(2), + 30: uint8(2), + 31: uint8(2), +} + +// C documentation +// +// /* +// ** On some systems, ceil() and floor() are intrinsic function. You are +// ** unable to take a pointer to these functions. Hence, we here wrap them +// ** in our own actual functions. +// */ +func _xCeil(tls *libc.TLS, x float64) (r float64) { + return libc.Xceil(tls, x) +} + +// C documentation +// +// /* +// ** Default xRename callback for RBU. +// */ +func _xDefaultRename(tls *libc.TLS, pArg uintptr, zOld uintptr, zNew uintptr) (r int32) { + var rc, v1 int32 + _, _ = rc, v1 + rc = SQLITE_OK + _ = pArg + if libc.Xrename(tls, zOld, zNew) != 0 { + v1 = int32(SQLITE_IOERR) + } else { + v1 = SQLITE_OK + } + rc = v1 + return rc +} + +func _xFloor(tls *libc.TLS, x float64) (r float64) { + return libc.Xfloor(tls, x) +} + +/* +** Some systems do not have log2() and log10() in their standard math +** libraries. + */ + +// C documentation +// +// /* +// ** The 'pre-update' hook registered by this module with SQLite databases. +// */ +func _xPreUpdate(tls *libc.TLS, pCtx uintptr, db uintptr, op int32, zDb uintptr, zName uintptr, iKey1 Tsqlite3_int64, iKey2 Tsqlite3_int64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nDb int32 + var pSession uintptr + var _ /* pTab at bp+0 */ uintptr + _, _ = nDb, pSession + nDb = _sqlite3Strlen30(tls, zDb) + _ = iKey1 + _ = iKey2 + pSession = pCtx + for { + if !(pSession != 0) { + break + } + /* If this session is attached to a different database ("main", "temp" + ** etc.), or if it is not currently enabled, there is nothing to do. Skip + ** to the next session object attached to this database. */ + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnable == 0 { + goto _1 + } + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 { + goto _1 + } + if Xsqlite3_strnicmp(tls, zDb, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, nDb+int32(1)) != 0 { + goto _1 + } + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = _sessionFindTable(tls, pSession, zName, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + _sessionPreupdateOneChange(tls, op, iKey1, pSession, **(**uintptr)(__ccgo_up(bp))) + if op == int32(SQLITE_UPDATE) { + _sessionPreupdateOneChange(tls, int32(SQLITE_INSERT), iKey2, pSession, **(**uintptr)(__ccgo_up(bp))) + } + } + goto _1 + _1: + ; + pSession = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpNext + } +} + +// C documentation +// +// /* The next table maps tokens (terminal symbols) into fallback tokens. +// ** If a construct like the following: +// ** +// ** %fallback ID X Y Z. +// ** +// ** appears in the grammar, then ID becomes a fallback token for X, Y, +// ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser +// ** but it does not parse, the type of the token is changed to ID and +// ** the parse is retried before an error is thrown. +// ** +// ** This feature can be used, for example, to cause some keywords in a language +// ** to revert to identifiers if they keyword does not apply in the context where +// ** it appears. +// */ +var _yyFallback = [187]uint16{ + 2: uint16(60), + 3: uint16(60), + 4: uint16(60), + 5: uint16(60), + 7: uint16(60), + 8: uint16(60), + 9: uint16(60), + 11: uint16(60), + 12: uint16(60), + 13: uint16(60), + 14: uint16(60), + 18: uint16(60), + 21: uint16(60), + 26: uint16(60), + 27: uint16(60), + 28: uint16(60), + 29: uint16(60), + 30: uint16(60), + 31: uint16(60), + 32: uint16(60), + 33: uint16(60), + 34: uint16(60), + 35: uint16(60), + 36: uint16(60), + 37: uint16(60), + 38: uint16(60), + 39: uint16(60), + 40: uint16(60), + 41: uint16(60), + 42: uint16(60), + 47: uint16(60), + 48: uint16(60), + 61: uint16(60), + 62: uint16(60), + 63: uint16(60), + 64: uint16(60), + 65: uint16(60), + 66: uint16(60), + 67: uint16(60), + 68: uint16(60), + 69: uint16(60), + 70: uint16(60), + 71: uint16(60), + 72: uint16(60), + 73: uint16(60), + 74: uint16(60), + 75: uint16(60), + 76: uint16(60), + 77: uint16(60), + 78: uint16(60), + 79: uint16(60), + 80: uint16(60), + 81: uint16(60), + 82: uint16(60), + 83: uint16(60), + 84: uint16(60), + 85: uint16(60), + 86: uint16(60), + 87: uint16(60), + 88: uint16(60), + 89: uint16(60), + 90: uint16(60), + 91: uint16(60), + 92: uint16(60), + 93: uint16(60), + 94: uint16(60), + 95: uint16(60), + 96: uint16(60), + 97: uint16(60), + 98: uint16(60), + 99: uint16(60), + 100: uint16(60), + 101: uint16(60), +} + +// C documentation +// +// /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side +// ** of that rule */ +var _yyRuleInfoLhs = [412]uint16{ + 0: uint16(191), + 1: uint16(191), + 2: uint16(190), + 3: uint16(192), + 4: uint16(193), + 5: uint16(193), + 6: uint16(193), + 7: uint16(193), + 8: uint16(192), + 9: uint16(192), + 10: uint16(192), + 11: uint16(192), + 12: uint16(192), + 13: uint16(197), + 14: uint16(199), + 15: uint16(201), + 16: uint16(201), + 17: uint16(200), + 18: uint16(200), + 19: uint16(198), + 20: uint16(198), + 21: uint16(205), + 22: uint16(205), + 23: uint16(207), + 24: uint16(207), + 25: uint16(208), + 26: uint16(210), + 27: uint16(210), + 28: uint16(210), + 29: uint16(211), + 30: uint16(215), + 31: uint16(216), + 32: uint16(217), + 33: uint16(217), + 34: uint16(217), + 35: uint16(217), + 36: uint16(217), + 37: uint16(217), + 38: uint16(217), + 39: uint16(217), + 40: uint16(217), + 41: uint16(217), + 42: uint16(217), + 43: uint16(217), + 44: uint16(217), + 45: uint16(226), + 46: uint16(226), + 47: uint16(222), + 48: uint16(222), + 49: uint16(224), + 50: uint16(224), + 51: uint16(227), + 52: uint16(227), + 53: uint16(227), + 54: uint16(227), + 55: uint16(228), + 56: uint16(228), + 57: uint16(228), + 58: uint16(228), + 59: uint16(228), + 60: uint16(225), + 61: uint16(225), + 62: uint16(229), + 63: uint16(229), + 64: uint16(229), + 65: uint16(204), + 66: uint16(231), + 67: uint16(232), + 68: uint16(232), + 69: uint16(232), + 70: uint16(232), + 71: uint16(232), + 72: uint16(235), + 73: uint16(220), + 74: uint16(220), + 75: uint16(236), + 76: uint16(236), + 77: uint16(237), + 78: uint16(237), + 79: uint16(192), + 80: uint16(239), + 81: uint16(239), + 82: uint16(192), + 83: uint16(192), + 84: uint16(192), + 85: uint16(206), + 86: uint16(206), + 87: uint16(206), + 88: uint16(241), + 89: uint16(244), + 90: uint16(244), + 91: uint16(244), + 92: uint16(242), + 93: uint16(242), + 94: uint16(254), + 95: uint16(242), + 96: uint16(256), + 97: uint16(256), + 98: uint16(245), + 99: uint16(245), + 100: uint16(245), + 101: uint16(257), + 102: uint16(246), + 103: uint16(246), + 104: uint16(246), + 105: uint16(258), + 106: uint16(258), + 107: uint16(247), + 108: uint16(247), + 109: uint16(260), + 110: uint16(260), + 111: uint16(259), + 112: uint16(259), + 113: uint16(259), + 114: uint16(259), + 115: uint16(259), + 116: uint16(202), + 117: uint16(202), + 118: uint16(240), + 119: uint16(240), + 120: uint16(265), + 121: uint16(265), + 122: uint16(265), + 123: uint16(265), + 124: uint16(261), + 125: uint16(261), + 126: uint16(261), + 127: uint16(261), + 128: uint16(262), + 129: uint16(262), + 130: uint16(262), + 131: uint16(267), + 132: uint16(263), + 133: uint16(263), + 134: uint16(251), + 135: uint16(251), + 136: uint16(233), + 137: uint16(233), + 138: uint16(221), + 139: uint16(221), + 140: uint16(221), + 141: uint16(268), + 142: uint16(268), + 143: uint16(268), + 144: uint16(249), + 145: uint16(249), + 146: uint16(250), + 147: uint16(250), + 148: uint16(252), + 149: uint16(252), + 150: uint16(252), + 151: uint16(252), + 152: uint16(192), + 153: uint16(248), + 154: uint16(248), + 155: uint16(270), + 156: uint16(270), + 157: uint16(270), + 158: uint16(270), + 159: uint16(192), + 160: uint16(271), + 161: uint16(271), + 162: uint16(271), + 163: uint16(271), + 164: uint16(192), + 165: uint16(192), + 166: uint16(274), + 167: uint16(274), + 168: uint16(274), + 169: uint16(274), + 170: uint16(274), + 171: uint16(274), + 172: uint16(275), + 173: uint16(272), + 174: uint16(272), + 175: uint16(273), + 176: uint16(273), + 177: uint16(266), + 178: uint16(266), + 179: uint16(219), + 180: uint16(219), + 181: uint16(219), + 182: uint16(219), + 183: uint16(218), + 184: uint16(218), + 185: uint16(218), + 186: uint16(219), + 187: uint16(219), + 188: uint16(219), + 189: uint16(219), + 190: uint16(219), + 191: uint16(219), + 192: uint16(219), + 193: uint16(219), + 194: uint16(219), + 195: uint16(218), + 196: uint16(219), + 197: uint16(219), + 198: uint16(219), + 199: uint16(219), + 200: uint16(219), + 201: uint16(219), + 202: uint16(219), + 203: uint16(219), + 204: uint16(219), + 205: uint16(277), + 206: uint16(219), + 207: uint16(219), + 208: uint16(219), + 209: uint16(219), + 210: uint16(219), + 211: uint16(219), + 212: uint16(219), + 213: uint16(219), + 214: uint16(219), + 215: uint16(219), + 216: uint16(219), + 217: uint16(219), + 218: uint16(278), + 219: uint16(278), + 220: uint16(219), + 221: uint16(279), + 222: uint16(279), + 223: uint16(219), + 224: uint16(219), + 225: uint16(219), + 226: uint16(219), + 227: uint16(219), + 228: uint16(219), + 229: uint16(282), + 230: uint16(282), + 231: uint16(283), + 232: uint16(283), + 233: uint16(281), + 234: uint16(264), + 235: uint16(255), + 236: uint16(255), + 237: uint16(280), + 238: uint16(280), + 239: uint16(192), + 240: uint16(284), + 241: uint16(284), + 242: uint16(223), + 243: uint16(223), + 244: uint16(234), + 245: uint16(234), + 246: uint16(285), + 247: uint16(285), + 248: uint16(192), + 249: uint16(192), + 250: uint16(192), + 251: uint16(286), + 252: uint16(286), + 253: uint16(192), + 254: uint16(192), + 255: uint16(192), + 256: uint16(192), + 257: uint16(192), + 258: uint16(213), + 259: uint16(214), + 260: uint16(192), + 261: uint16(288), + 262: uint16(290), + 263: uint16(290), + 264: uint16(290), + 265: uint16(291), + 266: uint16(291), + 267: uint16(291), + 268: uint16(293), + 269: uint16(293), + 270: uint16(289), + 271: uint16(289), + 272: uint16(295), + 273: uint16(295), + 274: uint16(294), + 275: uint16(294), + 276: uint16(294), + 277: uint16(294), + 278: uint16(219), + 279: uint16(219), + 280: uint16(238), + 281: uint16(238), + 282: uint16(238), + 283: uint16(192), + 284: uint16(192), + 285: uint16(192), + 286: uint16(297), + 287: uint16(297), + 288: uint16(192), + 289: uint16(192), + 290: uint16(192), + 291: uint16(192), + 292: uint16(192), + 293: uint16(192), + 294: uint16(298), + 295: uint16(192), + 296: uint16(192), + 297: uint16(192), + 298: uint16(192), + 299: uint16(192), + 300: uint16(192), + 301: uint16(192), + 302: uint16(192), + 303: uint16(192), + 304: uint16(300), + 305: uint16(302), + 306: uint16(303), + 307: uint16(303), + 308: uint16(304), + 309: uint16(269), + 310: uint16(269), + 311: uint16(307), + 312: uint16(307), + 313: uint16(307), + 314: uint16(306), + 315: uint16(308), + 316: uint16(243), + 317: uint16(243), + 318: uint16(309), + 319: uint16(310), + 320: uint16(311), + 321: uint16(311), + 322: uint16(311), + 323: uint16(311), + 324: uint16(311), + 325: uint16(312), + 326: uint16(312), + 327: uint16(312), + 328: uint16(316), + 329: uint16(318), + 330: uint16(318), + 331: uint16(319), + 332: uint16(319), + 333: uint16(317), + 334: uint16(317), + 335: uint16(320), + 336: uint16(320), + 337: uint16(321), + 338: uint16(321), + 339: uint16(321), + 340: uint16(253), + 341: uint16(276), + 342: uint16(276), + 343: uint16(276), + 344: uint16(315), + 345: uint16(315), + 346: uint16(314), + 347: uint16(218), + 348: uint16(187), + 349: uint16(188), + 350: uint16(188), + 351: uint16(189), + 352: uint16(189), + 353: uint16(189), + 354: uint16(194), + 355: uint16(194), + 356: uint16(194), + 357: uint16(196), + 358: uint16(196), + 359: uint16(192), + 360: uint16(205), + 361: uint16(203), + 362: uint16(203), + 363: uint16(195), + 364: uint16(195), + 365: uint16(210), + 366: uint16(211), + 367: uint16(212), + 368: uint16(212), + 369: uint16(209), + 370: uint16(209), + 371: uint16(217), + 372: uint16(217), + 373: uint16(217), + 374: uint16(204), + 375: uint16(230), + 376: uint16(230), + 377: uint16(231), + 378: uint16(235), + 379: uint16(237), + 380: uint16(241), + 381: uint16(242), + 382: uint16(257), + 383: uint16(258), + 384: uint16(267), + 385: uint16(275), + 386: uint16(219), + 387: uint16(277), + 388: uint16(281), + 389: uint16(264), + 390: uint16(287), + 391: uint16(287), + 392: uint16(287), + 393: uint16(287), + 394: uint16(287), + 395: uint16(213), + 396: uint16(292), + 397: uint16(292), + 398: uint16(295), + 399: uint16(296), + 400: uint16(296), + 401: uint16(299), + 402: uint16(299), + 403: uint16(301), + 404: uint16(301), + 405: uint16(302), + 406: uint16(305), + 407: uint16(305), + 408: uint16(305), + 409: uint16(269), + 410: uint16(309), + 411: uint16(311), +} + +// C documentation +// +// /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number +// ** of symbols on the right-hand side of that rule. */ +var _yyRuleInfoNRhs = [412]int8{ + 0: int8(-int32(1)), + 1: int8(-int32(3)), + 2: int8(-int32(1)), + 3: int8(-int32(3)), + 5: int8(-int32(1)), + 6: int8(-int32(1)), + 7: int8(-int32(1)), + 8: int8(-int32(2)), + 9: int8(-int32(2)), + 10: int8(-int32(2)), + 11: int8(-int32(3)), + 12: int8(-int32(5)), + 13: int8(-int32(6)), + 14: int8(-int32(1)), + 16: int8(-int32(3)), + 17: int8(-int32(1)), + 19: int8(-int32(5)), + 20: int8(-int32(2)), + 22: int8(-int32(3)), + 23: int8(-int32(2)), + 24: int8(-int32(1)), + 25: int8(-int32(2)), + 27: int8(-int32(4)), + 28: int8(-int32(6)), + 29: int8(-int32(2)), + 32: int8(-int32(2)), + 33: int8(-int32(3)), + 34: int8(-int32(4)), + 35: int8(-int32(4)), + 36: int8(-int32(4)), + 37: int8(-int32(3)), + 38: int8(-int32(3)), + 39: int8(-int32(5)), + 40: int8(-int32(2)), + 41: int8(-int32(4)), + 42: int8(-int32(4)), + 43: int8(-int32(1)), + 44: int8(-int32(2)), + 45: int8(-int32(3)), + 46: int8(-int32(4)), + 48: int8(-int32(1)), + 50: int8(-int32(2)), + 51: int8(-int32(2)), + 52: int8(-int32(3)), + 53: int8(-int32(3)), + 54: int8(-int32(3)), + 55: int8(-int32(2)), + 56: int8(-int32(2)), + 57: int8(-int32(1)), + 58: int8(-int32(1)), + 59: int8(-int32(2)), + 60: int8(-int32(3)), + 61: int8(-int32(2)), + 63: int8(-int32(2)), + 64: int8(-int32(2)), + 66: int8(-int32(1)), + 67: int8(-int32(2)), + 68: int8(-int32(7)), + 69: int8(-int32(5)), + 70: int8(-int32(5)), + 71: int8(-int32(10)), + 74: int8(-int32(3)), + 76: int8(-int32(2)), + 77: int8(-int32(1)), + 78: int8(-int32(1)), + 79: int8(-int32(4)), + 80: int8(-int32(2)), + 82: int8(-int32(9)), + 83: int8(-int32(4)), + 84: int8(-int32(1)), + 85: int8(-int32(3)), + 86: int8(-int32(4)), + 87: int8(-int32(1)), + 88: int8(-int32(3)), + 89: int8(-int32(1)), + 90: int8(-int32(2)), + 91: int8(-int32(1)), + 92: int8(-int32(9)), + 93: int8(-int32(10)), + 94: int8(-int32(4)), + 95: int8(-int32(1)), + 96: int8(-int32(5)), + 97: int8(-int32(5)), + 98: int8(-int32(1)), + 99: int8(-int32(1)), + 102: int8(-int32(5)), + 103: int8(-int32(3)), + 104: int8(-int32(5)), + 105: int8(-int32(2)), + 108: int8(-int32(2)), + 109: int8(-int32(2)), + 111: int8(-int32(5)), + 112: int8(-int32(6)), + 113: int8(-int32(8)), + 114: int8(-int32(6)), + 115: int8(-int32(6)), + 117: int8(-int32(2)), + 118: int8(-int32(1)), + 119: int8(-int32(3)), + 120: int8(-int32(1)), + 121: int8(-int32(3)), + 122: int8(-int32(3)), + 123: int8(-int32(5)), + 124: int8(-int32(1)), + 125: int8(-int32(2)), + 126: int8(-int32(3)), + 127: int8(-int32(4)), + 128: int8(-int32(2)), + 129: int8(-int32(4)), + 132: int8(-int32(3)), + 133: int8(-int32(2)), + 135: int8(-int32(3)), + 136: int8(-int32(5)), + 137: int8(-int32(3)), + 138: int8(-int32(1)), + 139: int8(-int32(1)), + 141: int8(-int32(2)), + 142: int8(-int32(2)), + 145: int8(-int32(3)), + 147: int8(-int32(2)), + 149: int8(-int32(2)), + 150: int8(-int32(4)), + 151: int8(-int32(4)), + 152: int8(-int32(6)), + 154: int8(-int32(2)), + 156: int8(-int32(2)), + 157: int8(-int32(2)), + 158: int8(-int32(4)), + 159: int8(-int32(9)), + 160: int8(-int32(5)), + 161: int8(-int32(7)), + 162: int8(-int32(3)), + 163: int8(-int32(5)), + 164: int8(-int32(7)), + 165: int8(-int32(8)), + 167: int8(-int32(2)), + 168: int8(-int32(12)), + 169: int8(-int32(9)), + 170: int8(-int32(5)), + 171: int8(-int32(8)), + 172: int8(-int32(2)), + 173: int8(-int32(2)), + 174: int8(-int32(1)), + 176: int8(-int32(3)), + 177: int8(-int32(3)), + 178: int8(-int32(1)), + 179: int8(-int32(3)), + 180: int8(-int32(1)), + 181: int8(-int32(3)), + 182: int8(-int32(5)), + 183: int8(-int32(1)), + 184: int8(-int32(1)), + 185: int8(-int32(1)), + 186: int8(-int32(1)), + 187: int8(-int32(3)), + 188: int8(-int32(6)), + 189: int8(-int32(5)), + 190: int8(-int32(8)), + 191: int8(-int32(4)), + 192: int8(-int32(6)), + 193: int8(-int32(9)), + 194: int8(-int32(5)), + 195: int8(-int32(1)), + 196: int8(-int32(5)), + 197: int8(-int32(3)), + 198: int8(-int32(3)), + 199: int8(-int32(3)), + 200: int8(-int32(3)), + 201: int8(-int32(3)), + 202: int8(-int32(3)), + 203: int8(-int32(3)), + 204: int8(-int32(3)), + 205: int8(-int32(2)), + 206: int8(-int32(3)), + 207: int8(-int32(5)), + 208: int8(-int32(2)), + 209: int8(-int32(3)), + 210: int8(-int32(3)), + 211: int8(-int32(4)), + 212: int8(-int32(6)), + 213: int8(-int32(5)), + 214: int8(-int32(2)), + 215: int8(-int32(2)), + 216: int8(-int32(2)), + 217: int8(-int32(3)), + 218: int8(-int32(1)), + 219: int8(-int32(2)), + 220: int8(-int32(5)), + 221: int8(-int32(1)), + 222: int8(-int32(2)), + 223: int8(-int32(5)), + 224: int8(-int32(3)), + 225: int8(-int32(5)), + 226: int8(-int32(5)), + 227: int8(-int32(4)), + 228: int8(-int32(5)), + 229: int8(-int32(5)), + 230: int8(-int32(4)), + 231: int8(-int32(2)), + 235: int8(-int32(3)), + 236: int8(-int32(1)), + 238: int8(-int32(3)), + 239: int8(-int32(12)), + 240: int8(-int32(1)), + 243: int8(-int32(3)), + 244: int8(-int32(5)), + 245: int8(-int32(3)), + 247: int8(-int32(2)), + 248: int8(-int32(4)), + 249: int8(-int32(2)), + 250: int8(-int32(3)), + 251: int8(-int32(2)), + 253: int8(-int32(3)), + 254: int8(-int32(5)), + 255: int8(-int32(6)), + 256: int8(-int32(5)), + 257: int8(-int32(6)), + 258: int8(-int32(2)), + 259: int8(-int32(2)), + 260: int8(-int32(5)), + 261: int8(-int32(11)), + 262: int8(-int32(1)), + 263: int8(-int32(2)), + 265: int8(-int32(1)), + 266: int8(-int32(1)), + 267: int8(-int32(3)), + 269: int8(-int32(2)), + 270: int8(-int32(3)), + 271: int8(-int32(2)), + 272: int8(-int32(3)), + 273: int8(-int32(2)), + 274: int8(-int32(9)), + 275: int8(-int32(8)), + 276: int8(-int32(6)), + 277: int8(-int32(3)), + 278: int8(-int32(4)), + 279: int8(-int32(6)), + 280: int8(-int32(1)), + 281: int8(-int32(1)), + 282: int8(-int32(1)), + 283: int8(-int32(4)), + 284: int8(-int32(6)), + 285: int8(-int32(3)), + 287: int8(-int32(2)), + 288: int8(-int32(1)), + 289: int8(-int32(3)), + 290: int8(-int32(1)), + 291: int8(-int32(3)), + 292: int8(-int32(6)), + 293: int8(-int32(2)), + 294: int8(-int32(7)), + 295: int8(-int32(6)), + 296: int8(-int32(8)), + 297: int8(-int32(6)), + 298: int8(-int32(9)), + 299: int8(-int32(10)), + 300: int8(-int32(11)), + 301: int8(-int32(9)), + 302: int8(-int32(1)), + 303: int8(-int32(4)), + 304: int8(-int32(8)), + 306: int8(-int32(1)), + 307: int8(-int32(3)), + 308: int8(-int32(1)), + 309: int8(-int32(2)), + 310: int8(-int32(3)), + 311: int8(-int32(1)), + 312: int8(-int32(2)), + 313: int8(-int32(3)), + 314: int8(-int32(6)), + 315: int8(-int32(1)), + 316: int8(-int32(1)), + 317: int8(-int32(3)), + 318: int8(-int32(3)), + 319: int8(-int32(5)), + 320: int8(-int32(5)), + 321: int8(-int32(6)), + 322: int8(-int32(4)), + 323: int8(-int32(5)), + 324: int8(-int32(2)), + 326: int8(-int32(3)), + 327: int8(-int32(6)), + 328: int8(-int32(1)), + 329: int8(-int32(1)), + 330: int8(-int32(2)), + 331: int8(-int32(1)), + 332: int8(-int32(2)), + 333: int8(-int32(2)), + 334: int8(-int32(2)), + 336: int8(-int32(2)), + 337: int8(-int32(2)), + 338: int8(-int32(2)), + 339: int8(-int32(1)), + 340: int8(-int32(2)), + 341: int8(-int32(2)), + 342: int8(-int32(1)), + 343: int8(-int32(1)), + 344: int8(-int32(4)), + 345: int8(-int32(2)), + 346: int8(-int32(5)), + 347: int8(-int32(1)), + 348: int8(-int32(1)), + 349: int8(-int32(2)), + 350: int8(-int32(1)), + 351: int8(-int32(1)), + 352: int8(-int32(2)), + 353: int8(-int32(3)), + 355: int8(-int32(1)), + 356: int8(-int32(2)), + 357: int8(-int32(1)), + 359: int8(-int32(2)), + 360: int8(-int32(1)), + 361: int8(-int32(4)), + 362: int8(-int32(2)), + 363: int8(-int32(1)), + 364: int8(-int32(1)), + 365: int8(-int32(1)), + 366: int8(-int32(1)), + 367: int8(-int32(1)), + 368: int8(-int32(1)), + 369: int8(-int32(2)), + 371: int8(-int32(2)), + 372: int8(-int32(4)), + 373: int8(-int32(2)), + 374: int8(-int32(2)), + 375: int8(-int32(3)), + 376: int8(-int32(1)), + 378: int8(-int32(1)), + 379: int8(-int32(1)), + 380: int8(-int32(1)), + 381: int8(-int32(1)), + 382: int8(-int32(2)), + 383: int8(-int32(1)), + 384: int8(-int32(1)), + 386: int8(-int32(1)), + 387: int8(-int32(1)), + 388: int8(-int32(1)), + 389: int8(-int32(1)), + 390: int8(-int32(1)), + 391: int8(-int32(1)), + 392: int8(-int32(1)), + 393: int8(-int32(1)), + 394: int8(-int32(1)), + 395: int8(-int32(1)), + 397: int8(-int32(3)), + 399: int8(-int32(1)), + 402: int8(-int32(1)), + 403: int8(-int32(1)), + 404: int8(-int32(3)), + 405: int8(-int32(2)), + 407: int8(-int32(4)), + 408: int8(-int32(2)), + 410: int8(-int32(1)), + 411: int8(-int32(1)), +} + +// C documentation +// +// /* +// ** The following is executed when the parser accepts +// */ +func _yy_accept(tls *libc.TLS, yypParser uintptr) { + var pParse uintptr + _ = pParse + pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + /*********** Begin %parse_accept code *****************************************/ + /*********** End %parse_accept code *******************************************/ + /* Suppress warning about unused %extra_argument variable */ + (*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse +} + +// C documentation +// +// /* Next are the tables used to determine what action to take based on the +// ** current state and lookahead token. These tables are used to implement +// ** functions that take a state number and lookahead value and return an +// ** action integer. +// ** +// ** Suppose the action integer is N. Then the action is determined as +// ** follows +// ** +// ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead +// ** token onto the stack and goto state N. +// ** +// ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then +// ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE. +// ** +// ** N == YY_ERROR_ACTION A syntax error has occurred. +// ** +// ** N == YY_ACCEPT_ACTION The parser accepts its input. +// ** +// ** N == YY_NO_ACTION No such action. Denotes unused +// ** slots in the yy_action[] table. +// ** +// ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE +// ** and YY_MAX_REDUCE +// ** +// ** The action table is constructed as a single large table named yy_action[]. +// ** Given state S and lookahead X, the action is computed as either: +// ** +// ** (A) N = yy_action[ yy_shift_ofst[S] + X ] +// ** (B) N = yy_default[S] +// ** +// ** The (A) formula is preferred. The B formula is used instead if +// ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X. +// ** +// ** The formulas above are for computing the action when the lookahead is +// ** a terminal symbol. If the lookahead is a non-terminal (as occurs after +// ** a reduce action) then the yy_reduce_ofst[] array is used in place of +// ** the yy_shift_ofst[] array. +// ** +// ** The following are the tables generated in this section: +// ** +// ** yy_action[] A single table containing all actions. +// ** yy_lookahead[] A table containing the lookahead for each entry in +// ** yy_action. Used to detect hash collisions. +// ** yy_shift_ofst[] For each state, the offset into yy_action for +// ** shifting terminals. +// ** yy_reduce_ofst[] For each state, the offset into yy_action for +// ** shifting non-terminals after a reduce. +// ** yy_default[] Default action for each state. +// ** +// *********** Begin parsing tables **********************************************/ +var _yy_action = [2379]uint16{ + 0: uint16(134), + 1: uint16(131), + 2: uint16(238), + 3: uint16(290), + 4: uint16(290), + 5: uint16(1353), + 6: uint16(593), + 7: uint16(1332), + 8: uint16(478), + 9: uint16(1606), + 10: uint16(593), + 11: uint16(1315), + 12: uint16(593), + 13: uint16(7), + 14: uint16(593), + 15: uint16(1353), + 16: uint16(590), + 17: uint16(593), + 18: uint16(579), + 19: uint16(424), + 20: uint16(1566), + 21: uint16(134), + 22: uint16(131), + 23: uint16(238), + 24: uint16(1318), + 25: uint16(541), + 26: uint16(478), + 27: uint16(477), + 28: uint16(575), + 29: uint16(84), + 30: uint16(84), + 31: uint16(1005), + 32: uint16(303), + 33: uint16(84), + 34: uint16(84), + 35: uint16(51), + 36: uint16(51), + 37: uint16(63), + 38: uint16(63), + 39: uint16(1006), + 40: uint16(84), + 41: uint16(84), + 42: uint16(498), + 43: uint16(141), + 44: uint16(142), + 45: uint16(93), + 46: uint16(442), + 47: uint16(1254), + 48: uint16(1254), + 49: uint16(1085), + 50: uint16(1088), + 51: uint16(1075), + 52: uint16(1075), + 53: uint16(139), + 54: uint16(139), + 55: uint16(140), + 56: uint16(140), + 57: uint16(140), + 58: uint16(140), + 59: uint16(424), + 60: uint16(296), + 61: uint16(296), + 62: uint16(498), + 63: uint16(296), + 64: uint16(296), + 65: uint16(567), + 66: uint16(553), + 67: uint16(296), + 68: uint16(296), + 69: uint16(1306), + 70: uint16(574), + 71: uint16(1358), + 72: uint16(1358), + 73: uint16(590), + 74: uint16(542), + 75: uint16(579), + 76: uint16(590), + 77: uint16(574), + 78: uint16(579), + 79: uint16(548), + 80: uint16(590), + 81: uint16(1304), + 82: uint16(579), + 83: uint16(141), + 84: uint16(142), + 85: uint16(93), + 86: uint16(576), + 87: uint16(1254), + 88: uint16(1254), + 89: uint16(1085), + 90: uint16(1088), + 91: uint16(1075), + 92: uint16(1075), + 93: uint16(139), + 94: uint16(139), + 95: uint16(140), + 96: uint16(140), + 97: uint16(140), + 98: uint16(140), + 99: uint16(399), + 100: uint16(478), + 101: uint16(395), + 102: uint16(6), + 103: uint16(138), + 104: uint16(138), + 105: uint16(138), + 106: uint16(138), + 107: uint16(137), + 108: uint16(137), + 109: uint16(136), + 110: uint16(136), + 111: uint16(136), + 112: uint16(135), + 113: uint16(132), + 114: uint16(463), + 115: uint16(44), + 116: uint16(342), + 117: uint16(593), + 118: uint16(305), + 119: uint16(1127), + 120: uint16(1280), + 121: uint16(1), + 122: uint16(1), + 123: uint16(599), + 124: uint16(2), + 125: uint16(1284), + 126: uint16(598), + 127: uint16(1200), + 128: uint16(1284), + 129: uint16(1200), + 130: uint16(330), + 131: uint16(424), + 132: uint16(158), + 133: uint16(330), + 134: uint16(1613), + 135: uint16(158), + 136: uint16(390), + 137: uint16(116), + 138: uint16(308), + 139: uint16(1366), + 140: uint16(51), + 141: uint16(51), + 142: uint16(1366), + 143: uint16(138), + 144: uint16(138), + 145: uint16(138), + 146: uint16(138), + 147: uint16(137), + 148: uint16(137), + 149: uint16(136), + 150: uint16(136), + 151: uint16(136), + 152: uint16(135), + 153: uint16(132), + 154: uint16(463), + 155: uint16(141), + 156: uint16(142), + 157: uint16(93), + 158: uint16(515), + 159: uint16(1254), + 160: uint16(1254), + 161: uint16(1085), + 162: uint16(1088), + 163: uint16(1075), + 164: uint16(1075), + 165: uint16(139), + 166: uint16(139), + 167: uint16(140), + 168: uint16(140), + 169: uint16(140), + 170: uint16(140), + 171: uint16(1230), + 172: uint16(329), + 173: uint16(584), + 174: uint16(296), + 175: uint16(296), + 176: uint16(212), + 177: uint16(296), + 178: uint16(296), + 179: uint16(568), + 180: uint16(568), + 181: uint16(488), + 182: uint16(143), + 183: uint16(1072), + 184: uint16(1072), + 185: uint16(1086), + 186: uint16(1089), + 187: uint16(590), + 188: uint16(1195), + 189: uint16(579), + 190: uint16(590), + 191: uint16(340), + 192: uint16(579), + 193: uint16(140), + 194: uint16(140), + 195: uint16(140), + 196: uint16(140), + 197: uint16(133), + 198: uint16(392), + 199: uint16(564), + 200: uint16(536), + 201: uint16(1195), + 202: uint16(250), + 203: uint16(425), + 204: uint16(1195), + 205: uint16(250), + 206: uint16(137), + 207: uint16(137), + 208: uint16(136), + 209: uint16(136), + 210: uint16(136), + 211: uint16(135), + 212: uint16(132), + 213: uint16(463), + 214: uint16(291), + 215: uint16(138), + 216: uint16(138), + 217: uint16(138), + 218: uint16(138), + 219: uint16(137), + 220: uint16(137), + 221: uint16(136), + 222: uint16(136), + 223: uint16(136), + 224: uint16(135), + 225: uint16(132), + 226: uint16(463), + 227: uint16(966), + 228: uint16(1230), + 229: uint16(1231), + 230: uint16(1230), + 231: uint16(412), + 232: uint16(965), + 233: uint16(467), + 234: uint16(412), + 235: uint16(424), + 236: uint16(467), + 237: uint16(489), + 238: uint16(357), + 239: uint16(1611), + 240: uint16(391), + 241: uint16(138), + 242: uint16(138), + 243: uint16(138), + 244: uint16(138), + 245: uint16(137), + 246: uint16(137), + 247: uint16(136), + 248: uint16(136), + 249: uint16(136), + 250: uint16(135), + 251: uint16(132), + 252: uint16(463), + 253: uint16(463), + 254: uint16(134), + 255: uint16(131), + 256: uint16(238), + 257: uint16(555), + 258: uint16(1076), + 259: uint16(141), + 260: uint16(142), + 261: uint16(93), + 262: uint16(593), + 263: uint16(1254), + 264: uint16(1254), + 265: uint16(1085), + 266: uint16(1088), + 267: uint16(1075), + 268: uint16(1075), + 269: uint16(139), + 270: uint16(139), + 271: uint16(140), + 272: uint16(140), + 273: uint16(140), + 274: uint16(140), + 275: uint16(1317), + 276: uint16(134), + 277: uint16(131), + 278: uint16(238), + 279: uint16(424), + 280: uint16(549), + 281: uint16(1597), + 282: uint16(1531), + 283: uint16(333), + 284: uint16(97), + 285: uint16(83), + 286: uint16(83), + 287: uint16(140), + 288: uint16(140), + 289: uint16(140), + 290: uint16(140), + 291: uint16(138), + 292: uint16(138), + 293: uint16(138), + 294: uint16(138), + 295: uint16(137), + 296: uint16(137), + 297: uint16(136), + 298: uint16(136), + 299: uint16(136), + 300: uint16(135), + 301: uint16(132), + 302: uint16(463), + 303: uint16(141), + 304: uint16(142), + 305: uint16(93), + 306: uint16(1657), + 307: uint16(1254), + 308: uint16(1254), + 309: uint16(1085), + 310: uint16(1088), + 311: uint16(1075), + 312: uint16(1075), + 313: uint16(139), + 314: uint16(139), + 315: uint16(140), + 316: uint16(140), + 317: uint16(140), + 318: uint16(140), + 319: uint16(138), + 320: uint16(138), + 321: uint16(138), + 322: uint16(138), + 323: uint16(137), + 324: uint16(137), + 325: uint16(136), + 326: uint16(136), + 327: uint16(136), + 328: uint16(135), + 329: uint16(132), + 330: uint16(463), + 331: uint16(591), + 332: uint16(1230), + 333: uint16(958), + 334: uint16(958), + 335: uint16(138), + 336: uint16(138), + 337: uint16(138), + 338: uint16(138), + 339: uint16(137), + 340: uint16(137), + 341: uint16(136), + 342: uint16(136), + 343: uint16(136), + 344: uint16(135), + 345: uint16(132), + 346: uint16(463), + 347: uint16(44), + 348: uint16(398), + 349: uint16(547), + 350: uint16(1306), + 351: uint16(136), + 352: uint16(136), + 353: uint16(136), + 354: uint16(135), + 355: uint16(132), + 356: uint16(463), + 357: uint16(386), + 358: uint16(593), + 359: uint16(442), + 360: uint16(595), + 361: uint16(145), + 362: uint16(595), + 363: uint16(138), + 364: uint16(138), + 365: uint16(138), + 366: uint16(138), + 367: uint16(137), + 368: uint16(137), + 369: uint16(136), + 370: uint16(136), + 371: uint16(136), + 372: uint16(135), + 373: uint16(132), + 374: uint16(463), + 375: uint16(500), + 376: uint16(1230), + 377: uint16(112), + 378: uint16(550), + 379: uint16(460), + 380: uint16(459), + 381: uint16(51), + 382: uint16(51), + 383: uint16(424), + 384: uint16(296), + 385: uint16(296), + 386: uint16(479), + 387: uint16(334), + 388: uint16(1259), + 389: uint16(1230), + 390: uint16(1231), + 391: uint16(1230), + 392: uint16(1599), + 393: uint16(1261), + 394: uint16(388), + 395: uint16(312), + 396: uint16(444), + 397: uint16(590), + 398: uint16(246), + 399: uint16(579), + 400: uint16(546), + 401: uint16(1260), + 402: uint16(271), + 403: uint16(235), + 404: uint16(329), + 405: uint16(584), + 406: uint16(551), + 407: uint16(141), + 408: uint16(142), + 409: uint16(93), + 410: uint16(429), + 411: uint16(1254), + 412: uint16(1254), + 413: uint16(1085), + 414: uint16(1088), + 415: uint16(1075), + 416: uint16(1075), + 417: uint16(139), + 418: uint16(139), + 419: uint16(140), + 420: uint16(140), + 421: uint16(140), + 422: uint16(140), + 423: uint16(22), + 424: uint16(22), + 425: uint16(1230), + 426: uint16(1262), + 427: uint16(424), + 428: uint16(1262), + 429: uint16(216), + 430: uint16(296), + 431: uint16(296), + 432: uint16(98), + 433: uint16(1230), + 434: uint16(1231), + 435: uint16(1230), + 436: uint16(264), + 437: uint16(884), + 438: uint16(45), + 439: uint16(528), + 440: uint16(525), + 441: uint16(524), + 442: uint16(1041), + 443: uint16(590), + 444: uint16(1269), + 445: uint16(579), + 446: uint16(421), + 447: uint16(420), + 448: uint16(393), + 449: uint16(523), + 450: uint16(44), + 451: uint16(141), + 452: uint16(142), + 453: uint16(93), + 454: uint16(498), + 455: uint16(1254), + 456: uint16(1254), + 457: uint16(1085), + 458: uint16(1088), + 459: uint16(1075), + 460: uint16(1075), + 461: uint16(139), + 462: uint16(139), + 463: uint16(140), + 464: uint16(140), + 465: uint16(140), + 466: uint16(140), + 467: uint16(138), + 468: uint16(138), + 469: uint16(138), + 470: uint16(138), + 471: uint16(137), + 472: uint16(137), + 473: uint16(136), + 474: uint16(136), + 475: uint16(136), + 476: uint16(135), + 477: uint16(132), + 478: uint16(463), + 479: uint16(593), + 480: uint16(1611), + 481: uint16(561), + 482: uint16(1230), + 483: uint16(1231), + 484: uint16(1230), + 485: uint16(23), + 486: uint16(264), + 487: uint16(515), + 488: uint16(200), + 489: uint16(528), + 490: uint16(525), + 491: uint16(524), + 492: uint16(127), + 493: uint16(585), + 494: uint16(509), + 495: uint16(4), + 496: uint16(355), + 497: uint16(487), + 498: uint16(506), + 499: uint16(523), + 500: uint16(593), + 501: uint16(498), + 502: uint16(84), + 503: uint16(84), + 504: uint16(134), + 505: uint16(131), + 506: uint16(238), + 507: uint16(329), + 508: uint16(584), + 509: uint16(588), + 510: uint16(1627), + 511: uint16(138), + 512: uint16(138), + 513: uint16(138), + 514: uint16(138), + 515: uint16(137), + 516: uint16(137), + 517: uint16(136), + 518: uint16(136), + 519: uint16(136), + 520: uint16(135), + 521: uint16(132), + 522: uint16(463), + 523: uint16(19), + 524: uint16(19), + 525: uint16(435), + 526: uint16(1230), + 527: uint16(1460), + 528: uint16(297), + 529: uint16(297), + 530: uint16(311), + 531: uint16(424), + 532: uint16(1565), + 533: uint16(464), + 534: uint16(1631), + 535: uint16(599), + 536: uint16(2), + 537: uint16(1284), + 538: uint16(437), + 539: uint16(574), + 540: uint16(1107), + 541: uint16(590), + 542: uint16(330), + 543: uint16(579), + 544: uint16(158), + 545: uint16(582), + 546: uint16(489), + 547: uint16(357), + 548: uint16(573), + 549: uint16(593), + 550: uint16(592), + 551: uint16(1366), + 552: uint16(409), + 553: uint16(1274), + 554: uint16(1230), + 555: uint16(141), + 556: uint16(142), + 557: uint16(93), + 558: uint16(1364), + 559: uint16(1254), + 560: uint16(1254), + 561: uint16(1085), + 562: uint16(1088), + 563: uint16(1075), + 564: uint16(1075), + 565: uint16(139), + 566: uint16(139), + 567: uint16(140), + 568: uint16(140), + 569: uint16(140), + 570: uint16(140), + 571: uint16(389), + 572: uint16(84), + 573: uint16(84), + 574: uint16(1062), + 575: uint16(567), + 576: uint16(1230), + 577: uint16(313), + 578: uint16(1523), + 579: uint16(593), + 580: uint16(125), + 581: uint16(125), + 582: uint16(970), + 583: uint16(1230), + 584: uint16(1231), + 585: uint16(1230), + 586: uint16(296), + 587: uint16(296), + 588: uint16(126), + 589: uint16(46), + 590: uint16(464), + 591: uint16(594), + 592: uint16(464), + 593: uint16(296), + 594: uint16(296), + 595: uint16(1050), + 596: uint16(1230), + 597: uint16(218), + 598: uint16(439), + 599: uint16(590), + 600: uint16(1604), + 601: uint16(579), + 602: uint16(84), + 603: uint16(84), + 604: uint16(7), + 605: uint16(403), + 606: uint16(590), + 607: uint16(515), + 608: uint16(579), + 609: uint16(325), + 610: uint16(417), + 611: uint16(1230), + 612: uint16(1231), + 613: uint16(1230), + 614: uint16(250), + 615: uint16(138), + 616: uint16(138), + 617: uint16(138), + 618: uint16(138), + 619: uint16(137), + 620: uint16(137), + 621: uint16(136), + 622: uint16(136), + 623: uint16(136), + 624: uint16(135), + 625: uint16(132), + 626: uint16(463), + 627: uint16(1050), + 628: uint16(1050), + 629: uint16(1052), + 630: uint16(1053), + 631: uint16(35), + 632: uint16(1275), + 633: uint16(1230), + 634: uint16(1231), + 635: uint16(1230), + 636: uint16(424), + 637: uint16(1370), + 638: uint16(993), + 639: uint16(574), + 640: uint16(371), + 641: uint16(414), + 642: uint16(274), + 643: uint16(412), + 644: uint16(1597), + 645: uint16(467), + 646: uint16(1302), + 647: uint16(552), + 648: uint16(451), + 649: uint16(590), + 650: uint16(543), + 651: uint16(579), + 652: uint16(1530), + 653: uint16(1230), + 654: uint16(1231), + 655: uint16(1230), + 656: uint16(1214), + 657: uint16(201), + 658: uint16(409), + 659: uint16(1174), + 660: uint16(141), + 661: uint16(142), + 662: uint16(93), + 663: uint16(223), + 664: uint16(1254), + 665: uint16(1254), + 666: uint16(1085), + 667: uint16(1088), + 668: uint16(1075), + 669: uint16(1075), + 670: uint16(139), + 671: uint16(139), + 672: uint16(140), + 673: uint16(140), + 674: uint16(140), + 675: uint16(140), + 676: uint16(296), + 677: uint16(296), + 678: uint16(1250), + 679: uint16(593), + 680: uint16(424), + 681: uint16(296), + 682: uint16(296), + 683: uint16(236), + 684: uint16(529), + 685: uint16(296), + 686: uint16(296), + 687: uint16(515), + 688: uint16(100), + 689: uint16(590), + 690: uint16(1600), + 691: uint16(579), + 692: uint16(48), + 693: uint16(1605), + 694: uint16(590), + 695: uint16(1230), + 696: uint16(579), + 697: uint16(7), + 698: uint16(590), + 699: uint16(577), + 700: uint16(579), + 701: uint16(904), + 702: uint16(84), + 703: uint16(84), + 704: uint16(141), + 705: uint16(142), + 706: uint16(93), + 707: uint16(496), + 708: uint16(1254), + 709: uint16(1254), + 710: uint16(1085), + 711: uint16(1088), + 712: uint16(1075), + 713: uint16(1075), + 714: uint16(139), + 715: uint16(139), + 716: uint16(140), + 717: uint16(140), + 718: uint16(140), + 719: uint16(140), + 720: uint16(138), + 721: uint16(138), + 722: uint16(138), + 723: uint16(138), + 724: uint16(137), + 725: uint16(137), + 726: uint16(136), + 727: uint16(136), + 728: uint16(136), + 729: uint16(135), + 730: uint16(132), + 731: uint16(463), + 732: uint16(1365), + 733: uint16(1230), + 734: uint16(296), + 735: uint16(296), + 736: uint16(1250), + 737: uint16(115), + 738: uint16(1275), + 739: uint16(326), + 740: uint16(233), + 741: uint16(539), + 742: uint16(1062), + 743: uint16(40), + 744: uint16(282), + 745: uint16(127), + 746: uint16(585), + 747: uint16(590), + 748: uint16(4), + 749: uint16(579), + 750: uint16(329), + 751: uint16(584), + 752: uint16(1230), + 753: uint16(1231), + 754: uint16(1230), + 755: uint16(1598), + 756: uint16(593), + 757: uint16(388), + 758: uint16(904), + 759: uint16(1051), + 760: uint16(1356), + 761: uint16(1356), + 762: uint16(588), + 763: uint16(1050), + 764: uint16(138), + 765: uint16(138), + 766: uint16(138), + 767: uint16(138), + 768: uint16(137), + 769: uint16(137), + 770: uint16(136), + 771: uint16(136), + 772: uint16(136), + 773: uint16(135), + 774: uint16(132), + 775: uint16(463), + 776: uint16(185), + 777: uint16(593), + 778: uint16(1230), + 779: uint16(19), + 780: uint16(19), + 781: uint16(1230), + 782: uint16(971), + 783: uint16(1597), + 784: uint16(424), + 785: uint16(1651), + 786: uint16(464), + 787: uint16(129), + 788: uint16(908), + 789: uint16(1195), + 790: uint16(1230), + 791: uint16(1231), + 792: uint16(1230), + 793: uint16(1325), + 794: uint16(443), + 795: uint16(1050), + 796: uint16(1050), + 797: uint16(1052), + 798: uint16(582), + 799: uint16(1603), + 800: uint16(149), + 801: uint16(149), + 802: uint16(1195), + 803: uint16(7), + 804: uint16(5), + 805: uint16(1195), + 806: uint16(1687), + 807: uint16(410), + 808: uint16(141), + 809: uint16(142), + 810: uint16(93), + 811: uint16(1536), + 812: uint16(1254), + 813: uint16(1254), + 814: uint16(1085), + 815: uint16(1088), + 816: uint16(1075), + 817: uint16(1075), + 818: uint16(139), + 819: uint16(139), + 820: uint16(140), + 821: uint16(140), + 822: uint16(140), + 823: uint16(140), + 824: uint16(1214), + 825: uint16(397), + 826: uint16(593), + 827: uint16(1062), + 828: uint16(424), + 829: uint16(1536), + 830: uint16(1538), + 831: uint16(50), + 832: uint16(901), + 833: uint16(125), + 834: uint16(125), + 835: uint16(1230), + 836: uint16(1231), + 837: uint16(1230), + 838: uint16(1230), + 839: uint16(1231), + 840: uint16(1230), + 841: uint16(126), + 842: uint16(1230), + 843: uint16(464), + 844: uint16(594), + 845: uint16(464), + 846: uint16(515), + 847: uint16(1230), + 848: uint16(1050), + 849: uint16(84), + 850: uint16(84), + 851: uint16(3), + 852: uint16(141), + 853: uint16(142), + 854: uint16(93), + 855: uint16(924), + 856: uint16(1254), + 857: uint16(1254), + 858: uint16(1085), + 859: uint16(1088), + 860: uint16(1075), + 861: uint16(1075), + 862: uint16(139), + 863: uint16(139), + 864: uint16(140), + 865: uint16(140), + 866: uint16(140), + 867: uint16(140), + 868: uint16(138), + 869: uint16(138), + 870: uint16(138), + 871: uint16(138), + 872: uint16(137), + 873: uint16(137), + 874: uint16(136), + 875: uint16(136), + 876: uint16(136), + 877: uint16(135), + 878: uint16(132), + 879: uint16(463), + 880: uint16(1050), + 881: uint16(1050), + 882: uint16(1052), + 883: uint16(1053), + 884: uint16(35), + 885: uint16(442), + 886: uint16(457), + 887: uint16(532), + 888: uint16(433), + 889: uint16(1230), + 890: uint16(1062), + 891: uint16(1361), + 892: uint16(540), + 893: uint16(540), + 894: uint16(1598), + 895: uint16(925), + 896: uint16(388), + 897: uint16(7), + 898: uint16(1129), + 899: uint16(1230), + 900: uint16(1231), + 901: uint16(1230), + 902: uint16(1129), + 903: uint16(1536), + 904: uint16(1230), + 905: uint16(1231), + 906: uint16(1230), + 907: uint16(1051), + 908: uint16(570), + 909: uint16(1214), + 910: uint16(593), + 911: uint16(1050), + 912: uint16(138), + 913: uint16(138), + 914: uint16(138), + 915: uint16(138), + 916: uint16(137), + 917: uint16(137), + 918: uint16(136), + 919: uint16(136), + 920: uint16(136), + 921: uint16(135), + 922: uint16(132), + 923: uint16(463), + 924: uint16(6), + 925: uint16(185), + 926: uint16(1195), + 927: uint16(1230), + 928: uint16(231), + 929: uint16(593), + 930: uint16(382), + 931: uint16(992), + 932: uint16(424), + 933: uint16(151), + 934: uint16(151), + 935: uint16(510), + 936: uint16(1213), + 937: uint16(557), + 938: uint16(482), + 939: uint16(1195), + 940: uint16(381), + 941: uint16(160), + 942: uint16(1195), + 943: uint16(1050), + 944: uint16(1050), + 945: uint16(1052), + 946: uint16(1230), + 947: uint16(1231), + 948: uint16(1230), + 949: uint16(422), + 950: uint16(593), + 951: uint16(447), + 952: uint16(84), + 953: uint16(84), + 954: uint16(593), + 955: uint16(217), + 956: uint16(141), + 957: uint16(142), + 958: uint16(93), + 959: uint16(593), + 960: uint16(1254), + 961: uint16(1254), + 962: uint16(1085), + 963: uint16(1088), + 964: uint16(1075), + 965: uint16(1075), + 966: uint16(139), + 967: uint16(139), + 968: uint16(140), + 969: uint16(140), + 970: uint16(140), + 971: uint16(140), + 972: uint16(1214), + 973: uint16(19), + 974: uint16(19), + 975: uint16(593), + 976: uint16(424), + 977: uint16(19), + 978: uint16(19), + 979: uint16(442), + 980: uint16(1063), + 981: uint16(442), + 982: uint16(19), + 983: uint16(19), + 984: uint16(1230), + 985: uint16(1231), + 986: uint16(1230), + 987: uint16(515), + 988: uint16(445), + 989: uint16(458), + 990: uint16(1597), + 991: uint16(386), + 992: uint16(315), + 993: uint16(1175), + 994: uint16(1685), + 995: uint16(556), + 996: uint16(1685), + 997: uint16(450), + 998: uint16(84), + 999: uint16(84), + 1000: uint16(141), + 1001: uint16(142), + 1002: uint16(93), + 1003: uint16(505), + 1004: uint16(1254), + 1005: uint16(1254), + 1006: uint16(1085), + 1007: uint16(1088), + 1008: uint16(1075), + 1009: uint16(1075), + 1010: uint16(139), + 1011: uint16(139), + 1012: uint16(140), + 1013: uint16(140), + 1014: uint16(140), + 1015: uint16(140), + 1016: uint16(138), + 1017: uint16(138), + 1018: uint16(138), + 1019: uint16(138), + 1020: uint16(137), + 1021: uint16(137), + 1022: uint16(136), + 1023: uint16(136), + 1024: uint16(136), + 1025: uint16(135), + 1026: uint16(132), + 1027: uint16(463), + 1028: uint16(442), + 1029: uint16(1147), + 1030: uint16(454), + 1031: uint16(1597), + 1032: uint16(362), + 1033: uint16(1041), + 1034: uint16(593), + 1035: uint16(462), + 1036: uint16(1460), + 1037: uint16(1233), + 1038: uint16(47), + 1039: uint16(1393), + 1040: uint16(324), + 1041: uint16(565), + 1042: uint16(565), + 1043: uint16(115), + 1044: uint16(1148), + 1045: uint16(449), + 1046: uint16(7), + 1047: uint16(460), + 1048: uint16(459), + 1049: uint16(307), + 1050: uint16(375), + 1051: uint16(354), + 1052: uint16(593), + 1053: uint16(113), + 1054: uint16(593), + 1055: uint16(329), + 1056: uint16(584), + 1057: uint16(19), + 1058: uint16(19), + 1059: uint16(1149), + 1060: uint16(138), + 1061: uint16(138), + 1062: uint16(138), + 1063: uint16(138), + 1064: uint16(137), + 1065: uint16(137), + 1066: uint16(136), + 1067: uint16(136), + 1068: uint16(136), + 1069: uint16(135), + 1070: uint16(132), + 1071: uint16(463), + 1072: uint16(209), + 1073: uint16(1173), + 1074: uint16(563), + 1075: uint16(19), + 1076: uint16(19), + 1077: uint16(19), + 1078: uint16(19), + 1079: uint16(49), + 1080: uint16(424), + 1081: uint16(944), + 1082: uint16(1175), + 1083: uint16(1686), + 1084: uint16(1046), + 1085: uint16(1686), + 1086: uint16(218), + 1087: uint16(355), + 1088: uint16(484), + 1089: uint16(343), + 1090: uint16(210), + 1091: uint16(945), + 1092: uint16(569), + 1093: uint16(562), + 1094: uint16(1262), + 1095: uint16(1233), + 1096: uint16(1262), + 1097: uint16(490), + 1098: uint16(314), + 1099: uint16(423), + 1100: uint16(424), + 1101: uint16(1598), + 1102: uint16(1206), + 1103: uint16(388), + 1104: uint16(141), + 1105: uint16(142), + 1106: uint16(93), + 1107: uint16(440), + 1108: uint16(1254), + 1109: uint16(1254), + 1110: uint16(1085), + 1111: uint16(1088), + 1112: uint16(1075), + 1113: uint16(1075), + 1114: uint16(139), + 1115: uint16(139), + 1116: uint16(140), + 1117: uint16(140), + 1118: uint16(140), + 1119: uint16(140), + 1120: uint16(352), + 1121: uint16(316), + 1122: uint16(531), + 1123: uint16(316), + 1124: uint16(141), + 1125: uint16(142), + 1126: uint16(93), + 1127: uint16(549), + 1128: uint16(1254), + 1129: uint16(1254), + 1130: uint16(1085), + 1131: uint16(1088), + 1132: uint16(1075), + 1133: uint16(1075), + 1134: uint16(139), + 1135: uint16(139), + 1136: uint16(140), + 1137: uint16(140), + 1138: uint16(140), + 1139: uint16(140), + 1140: uint16(446), + 1141: uint16(10), + 1142: uint16(1598), + 1143: uint16(274), + 1144: uint16(388), + 1145: uint16(915), + 1146: uint16(281), + 1147: uint16(299), + 1148: uint16(383), + 1149: uint16(534), + 1150: uint16(378), + 1151: uint16(533), + 1152: uint16(269), + 1153: uint16(593), + 1154: uint16(1206), + 1155: uint16(587), + 1156: uint16(587), + 1157: uint16(587), + 1158: uint16(374), + 1159: uint16(293), + 1160: uint16(1579), + 1161: uint16(991), + 1162: uint16(1173), + 1163: uint16(302), + 1164: uint16(138), + 1165: uint16(138), + 1166: uint16(138), + 1167: uint16(138), + 1168: uint16(137), + 1169: uint16(137), + 1170: uint16(136), + 1171: uint16(136), + 1172: uint16(136), + 1173: uint16(135), + 1174: uint16(132), + 1175: uint16(463), + 1176: uint16(53), + 1177: uint16(53), + 1178: uint16(520), + 1179: uint16(1250), + 1180: uint16(593), + 1181: uint16(1147), + 1182: uint16(1576), + 1183: uint16(431), + 1184: uint16(138), + 1185: uint16(138), + 1186: uint16(138), + 1187: uint16(138), + 1188: uint16(137), + 1189: uint16(137), + 1190: uint16(136), + 1191: uint16(136), + 1192: uint16(136), + 1193: uint16(135), + 1194: uint16(132), + 1195: uint16(463), + 1196: uint16(1148), + 1197: uint16(301), + 1198: uint16(593), + 1199: uint16(1577), + 1200: uint16(593), + 1201: uint16(1307), + 1202: uint16(431), + 1203: uint16(54), + 1204: uint16(54), + 1205: uint16(593), + 1206: uint16(268), + 1207: uint16(593), + 1208: uint16(461), + 1209: uint16(461), + 1210: uint16(461), + 1211: uint16(1149), + 1212: uint16(347), + 1213: uint16(492), + 1214: uint16(424), + 1215: uint16(135), + 1216: uint16(132), + 1217: uint16(463), + 1218: uint16(1146), + 1219: uint16(1195), + 1220: uint16(474), + 1221: uint16(68), + 1222: uint16(68), + 1223: uint16(69), + 1224: uint16(69), + 1225: uint16(550), + 1226: uint16(332), + 1227: uint16(287), + 1228: uint16(21), + 1229: uint16(21), + 1230: uint16(55), + 1231: uint16(55), + 1232: uint16(1195), + 1233: uint16(581), + 1234: uint16(424), + 1235: uint16(1195), + 1236: uint16(309), + 1237: uint16(1250), + 1238: uint16(141), + 1239: uint16(142), + 1240: uint16(93), + 1241: uint16(119), + 1242: uint16(1254), + 1243: uint16(1254), + 1244: uint16(1085), + 1245: uint16(1088), + 1246: uint16(1075), + 1247: uint16(1075), + 1248: uint16(139), + 1249: uint16(139), + 1250: uint16(140), + 1251: uint16(140), + 1252: uint16(140), + 1253: uint16(140), + 1254: uint16(593), + 1255: uint16(237), + 1256: uint16(480), + 1257: uint16(1476), + 1258: uint16(141), + 1259: uint16(142), + 1260: uint16(93), + 1261: uint16(593), + 1262: uint16(1254), + 1263: uint16(1254), + 1264: uint16(1085), + 1265: uint16(1088), + 1266: uint16(1075), + 1267: uint16(1075), + 1268: uint16(139), + 1269: uint16(139), + 1270: uint16(140), + 1271: uint16(140), + 1272: uint16(140), + 1273: uint16(140), + 1274: uint16(344), + 1275: uint16(430), + 1276: uint16(346), + 1277: uint16(70), + 1278: uint16(70), + 1279: uint16(494), + 1280: uint16(991), + 1281: uint16(1132), + 1282: uint16(1132), + 1283: uint16(512), + 1284: uint16(56), + 1285: uint16(56), + 1286: uint16(1269), + 1287: uint16(593), + 1288: uint16(268), + 1289: uint16(593), + 1290: uint16(369), + 1291: uint16(374), + 1292: uint16(593), + 1293: uint16(481), + 1294: uint16(215), + 1295: uint16(384), + 1296: uint16(1624), + 1297: uint16(481), + 1298: uint16(138), + 1299: uint16(138), + 1300: uint16(138), + 1301: uint16(138), + 1302: uint16(137), + 1303: uint16(137), + 1304: uint16(136), + 1305: uint16(136), + 1306: uint16(136), + 1307: uint16(135), + 1308: uint16(132), + 1309: uint16(463), + 1310: uint16(71), + 1311: uint16(71), + 1312: uint16(72), + 1313: uint16(72), + 1314: uint16(225), + 1315: uint16(73), + 1316: uint16(73), + 1317: uint16(593), + 1318: uint16(138), + 1319: uint16(138), + 1320: uint16(138), + 1321: uint16(138), + 1322: uint16(137), + 1323: uint16(137), + 1324: uint16(136), + 1325: uint16(136), + 1326: uint16(136), + 1327: uint16(135), + 1328: uint16(132), + 1329: uint16(463), + 1330: uint16(586), + 1331: uint16(431), + 1332: uint16(593), + 1333: uint16(872), + 1334: uint16(873), + 1335: uint16(874), + 1336: uint16(593), + 1337: uint16(911), + 1338: uint16(593), + 1339: uint16(1602), + 1340: uint16(74), + 1341: uint16(74), + 1342: uint16(593), + 1343: uint16(7), + 1344: uint16(1460), + 1345: uint16(242), + 1346: uint16(593), + 1347: uint16(306), + 1348: uint16(424), + 1349: uint16(1578), + 1350: uint16(472), + 1351: uint16(306), + 1352: uint16(364), + 1353: uint16(219), + 1354: uint16(367), + 1355: uint16(75), + 1356: uint16(75), + 1357: uint16(430), + 1358: uint16(345), + 1359: uint16(57), + 1360: uint16(57), + 1361: uint16(58), + 1362: uint16(58), + 1363: uint16(432), + 1364: uint16(187), + 1365: uint16(59), + 1366: uint16(59), + 1367: uint16(593), + 1368: uint16(424), + 1369: uint16(61), + 1370: uint16(61), + 1371: uint16(1475), + 1372: uint16(141), + 1373: uint16(142), + 1374: uint16(93), + 1375: uint16(123), + 1376: uint16(1254), + 1377: uint16(1254), + 1378: uint16(1085), + 1379: uint16(1088), + 1380: uint16(1075), + 1381: uint16(1075), + 1382: uint16(139), + 1383: uint16(139), + 1384: uint16(140), + 1385: uint16(140), + 1386: uint16(140), + 1387: uint16(140), + 1388: uint16(424), + 1389: uint16(570), + 1390: uint16(62), + 1391: uint16(62), + 1392: uint16(141), + 1393: uint16(142), + 1394: uint16(93), + 1395: uint16(911), + 1396: uint16(1254), + 1397: uint16(1254), + 1398: uint16(1085), + 1399: uint16(1088), + 1400: uint16(1075), + 1401: uint16(1075), + 1402: uint16(139), + 1403: uint16(139), + 1404: uint16(140), + 1405: uint16(140), + 1406: uint16(140), + 1407: uint16(140), + 1408: uint16(161), + 1409: uint16(384), + 1410: uint16(1624), + 1411: uint16(1474), + 1412: uint16(141), + 1413: uint16(130), + 1414: uint16(93), + 1415: uint16(441), + 1416: uint16(1254), + 1417: uint16(1254), + 1418: uint16(1085), + 1419: uint16(1088), + 1420: uint16(1075), + 1421: uint16(1075), + 1422: uint16(139), + 1423: uint16(139), + 1424: uint16(140), + 1425: uint16(140), + 1426: uint16(140), + 1427: uint16(140), + 1428: uint16(267), + 1429: uint16(266), + 1430: uint16(265), + 1431: uint16(1460), + 1432: uint16(138), + 1433: uint16(138), + 1434: uint16(138), + 1435: uint16(138), + 1436: uint16(137), + 1437: uint16(137), + 1438: uint16(136), + 1439: uint16(136), + 1440: uint16(136), + 1441: uint16(135), + 1442: uint16(132), + 1443: uint16(463), + 1444: uint16(593), + 1445: uint16(1336), + 1446: uint16(593), + 1447: uint16(1269), + 1448: uint16(1460), + 1449: uint16(384), + 1450: uint16(1624), + 1451: uint16(231), + 1452: uint16(138), + 1453: uint16(138), + 1454: uint16(138), + 1455: uint16(138), + 1456: uint16(137), + 1457: uint16(137), + 1458: uint16(136), + 1459: uint16(136), + 1460: uint16(136), + 1461: uint16(135), + 1462: uint16(132), + 1463: uint16(463), + 1464: uint16(593), + 1465: uint16(163), + 1466: uint16(593), + 1467: uint16(76), + 1468: uint16(76), + 1469: uint16(77), + 1470: uint16(77), + 1471: uint16(593), + 1472: uint16(138), + 1473: uint16(138), + 1474: uint16(138), + 1475: uint16(138), + 1476: uint16(137), + 1477: uint16(137), + 1478: uint16(136), + 1479: uint16(136), + 1480: uint16(136), + 1481: uint16(135), + 1482: uint16(132), + 1483: uint16(463), + 1484: uint16(475), + 1485: uint16(593), + 1486: uint16(483), + 1487: uint16(78), + 1488: uint16(78), + 1489: uint16(20), + 1490: uint16(20), + 1491: uint16(1249), + 1492: uint16(424), + 1493: uint16(491), + 1494: uint16(79), + 1495: uint16(79), + 1496: uint16(495), + 1497: uint16(422), + 1498: uint16(295), + 1499: uint16(235), + 1500: uint16(1574), + 1501: uint16(38), + 1502: uint16(511), + 1503: uint16(896), + 1504: uint16(422), + 1505: uint16(335), + 1506: uint16(240), + 1507: uint16(422), + 1508: uint16(147), + 1509: uint16(147), + 1510: uint16(112), + 1511: uint16(593), + 1512: uint16(424), + 1513: uint16(593), + 1514: uint16(101), + 1515: uint16(222), + 1516: uint16(991), + 1517: uint16(142), + 1518: uint16(93), + 1519: uint16(455), + 1520: uint16(1254), + 1521: uint16(1254), + 1522: uint16(1085), + 1523: uint16(1088), + 1524: uint16(1075), + 1525: uint16(1075), + 1526: uint16(139), + 1527: uint16(139), + 1528: uint16(140), + 1529: uint16(140), + 1530: uint16(140), + 1531: uint16(140), + 1532: uint16(593), + 1533: uint16(39), + 1534: uint16(148), + 1535: uint16(148), + 1536: uint16(80), + 1537: uint16(80), + 1538: uint16(93), + 1539: uint16(551), + 1540: uint16(1254), + 1541: uint16(1254), + 1542: uint16(1085), + 1543: uint16(1088), + 1544: uint16(1075), + 1545: uint16(1075), + 1546: uint16(139), + 1547: uint16(139), + 1548: uint16(140), + 1549: uint16(140), + 1550: uint16(140), + 1551: uint16(140), + 1552: uint16(328), + 1553: uint16(923), + 1554: uint16(922), + 1555: uint16(64), + 1556: uint16(64), + 1557: uint16(502), + 1558: uint16(1656), + 1559: uint16(1005), + 1560: uint16(933), + 1561: uint16(896), + 1562: uint16(124), + 1563: uint16(422), + 1564: uint16(121), + 1565: uint16(254), + 1566: uint16(593), + 1567: uint16(1006), + 1568: uint16(593), + 1569: uint16(226), + 1570: uint16(593), + 1571: uint16(127), + 1572: uint16(585), + 1573: uint16(164), + 1574: uint16(4), + 1575: uint16(16), + 1576: uint16(138), + 1577: uint16(138), + 1578: uint16(138), + 1579: uint16(138), + 1580: uint16(137), + 1581: uint16(137), + 1582: uint16(136), + 1583: uint16(136), + 1584: uint16(136), + 1585: uint16(135), + 1586: uint16(132), + 1587: uint16(463), + 1588: uint16(588), + 1589: uint16(81), + 1590: uint16(81), + 1591: uint16(65), + 1592: uint16(65), + 1593: uint16(82), + 1594: uint16(82), + 1595: uint16(593), + 1596: uint16(138), + 1597: uint16(138), + 1598: uint16(138), + 1599: uint16(138), + 1600: uint16(137), + 1601: uint16(137), + 1602: uint16(136), + 1603: uint16(136), + 1604: uint16(136), + 1605: uint16(135), + 1606: uint16(132), + 1607: uint16(463), + 1608: uint16(593), + 1609: uint16(226), + 1610: uint16(237), + 1611: uint16(966), + 1612: uint16(464), + 1613: uint16(593), + 1614: uint16(298), + 1615: uint16(593), + 1616: uint16(965), + 1617: uint16(593), + 1618: uint16(66), + 1619: uint16(66), + 1620: uint16(593), + 1621: uint16(1170), + 1622: uint16(593), + 1623: uint16(411), + 1624: uint16(582), + 1625: uint16(353), + 1626: uint16(469), + 1627: uint16(115), + 1628: uint16(593), + 1629: uint16(471), + 1630: uint16(169), + 1631: uint16(173), + 1632: uint16(173), + 1633: uint16(593), + 1634: uint16(44), + 1635: uint16(991), + 1636: uint16(174), + 1637: uint16(174), + 1638: uint16(89), + 1639: uint16(89), + 1640: uint16(67), + 1641: uint16(67), + 1642: uint16(593), + 1643: uint16(85), + 1644: uint16(85), + 1645: uint16(150), + 1646: uint16(150), + 1647: uint16(1114), + 1648: uint16(1043), + 1649: uint16(593), + 1650: uint16(273), + 1651: uint16(86), + 1652: uint16(86), + 1653: uint16(1062), + 1654: uint16(593), + 1655: uint16(503), + 1656: uint16(171), + 1657: uint16(171), + 1658: uint16(593), + 1659: uint16(125), + 1660: uint16(125), + 1661: uint16(497), + 1662: uint16(593), + 1663: uint16(273), + 1664: uint16(336), + 1665: uint16(152), + 1666: uint16(152), + 1667: uint16(126), + 1668: uint16(1335), + 1669: uint16(464), + 1670: uint16(594), + 1671: uint16(464), + 1672: uint16(146), + 1673: uint16(146), + 1674: uint16(1050), + 1675: uint16(593), + 1676: uint16(545), + 1677: uint16(172), + 1678: uint16(172), + 1679: uint16(593), + 1680: uint16(1054), + 1681: uint16(165), + 1682: uint16(165), + 1683: uint16(256), + 1684: uint16(339), + 1685: uint16(156), + 1686: uint16(156), + 1687: uint16(127), + 1688: uint16(585), + 1689: uint16(1586), + 1690: uint16(4), + 1691: uint16(329), + 1692: uint16(584), + 1693: uint16(499), + 1694: uint16(358), + 1695: uint16(273), + 1696: uint16(115), + 1697: uint16(348), + 1698: uint16(155), + 1699: uint16(155), + 1700: uint16(930), + 1701: uint16(931), + 1702: uint16(153), + 1703: uint16(153), + 1704: uint16(588), + 1705: uint16(1114), + 1706: uint16(1050), + 1707: uint16(1050), + 1708: uint16(1052), + 1709: uint16(1053), + 1710: uint16(35), + 1711: uint16(1554), + 1712: uint16(521), + 1713: uint16(593), + 1714: uint16(270), + 1715: uint16(1008), + 1716: uint16(1009), + 1717: uint16(9), + 1718: uint16(593), + 1719: uint16(372), + 1720: uint16(593), + 1721: uint16(115), + 1722: uint16(593), + 1723: uint16(168), + 1724: uint16(593), + 1725: uint16(115), + 1726: uint16(593), + 1727: uint16(1110), + 1728: uint16(464), + 1729: uint16(270), + 1730: uint16(996), + 1731: uint16(964), + 1732: uint16(273), + 1733: uint16(129), + 1734: uint16(1645), + 1735: uint16(1214), + 1736: uint16(154), + 1737: uint16(154), + 1738: uint16(1054), + 1739: uint16(1404), + 1740: uint16(582), + 1741: uint16(88), + 1742: uint16(88), + 1743: uint16(90), + 1744: uint16(90), + 1745: uint16(87), + 1746: uint16(87), + 1747: uint16(52), + 1748: uint16(52), + 1749: uint16(60), + 1750: uint16(60), + 1751: uint16(1405), + 1752: uint16(504), + 1753: uint16(537), + 1754: uint16(559), + 1755: uint16(1179), + 1756: uint16(961), + 1757: uint16(507), + 1758: uint16(129), + 1759: uint16(558), + 1760: uint16(127), + 1761: uint16(585), + 1762: uint16(1126), + 1763: uint16(4), + 1764: uint16(1126), + 1765: uint16(1125), + 1766: uint16(894), + 1767: uint16(1125), + 1768: uint16(162), + 1769: uint16(1062), + 1770: uint16(963), + 1771: uint16(359), + 1772: uint16(129), + 1773: uint16(1401), + 1774: uint16(363), + 1775: uint16(125), + 1776: uint16(125), + 1777: uint16(588), + 1778: uint16(366), + 1779: uint16(368), + 1780: uint16(370), + 1781: uint16(1349), + 1782: uint16(1334), + 1783: uint16(126), + 1784: uint16(1333), + 1785: uint16(464), + 1786: uint16(594), + 1787: uint16(464), + 1788: uint16(377), + 1789: uint16(387), + 1790: uint16(1050), + 1791: uint16(1391), + 1792: uint16(1414), + 1793: uint16(1618), + 1794: uint16(1459), + 1795: uint16(1387), + 1796: uint16(1399), + 1797: uint16(208), + 1798: uint16(580), + 1799: uint16(1464), + 1800: uint16(1314), + 1801: uint16(464), + 1802: uint16(243), + 1803: uint16(516), + 1804: uint16(1305), + 1805: uint16(1293), + 1806: uint16(1384), + 1807: uint16(1292), + 1808: uint16(1294), + 1809: uint16(1638), + 1810: uint16(288), + 1811: uint16(170), + 1812: uint16(228), + 1813: uint16(582), + 1814: uint16(12), + 1815: uint16(408), + 1816: uint16(321), + 1817: uint16(322), + 1818: uint16(241), + 1819: uint16(323), + 1820: uint16(245), + 1821: uint16(1446), + 1822: uint16(1050), + 1823: uint16(1050), + 1824: uint16(1052), + 1825: uint16(1053), + 1826: uint16(35), + 1827: uint16(559), + 1828: uint16(304), + 1829: uint16(350), + 1830: uint16(351), + 1831: uint16(501), + 1832: uint16(560), + 1833: uint16(127), + 1834: uint16(585), + 1835: uint16(1441), + 1836: uint16(4), + 1837: uint16(1451), + 1838: uint16(1434), + 1839: uint16(310), + 1840: uint16(1450), + 1841: uint16(526), + 1842: uint16(1062), + 1843: uint16(1332), + 1844: uint16(415), + 1845: uint16(380), + 1846: uint16(232), + 1847: uint16(1527), + 1848: uint16(125), + 1849: uint16(125), + 1850: uint16(588), + 1851: uint16(1214), + 1852: uint16(1396), + 1853: uint16(356), + 1854: uint16(1526), + 1855: uint16(583), + 1856: uint16(126), + 1857: uint16(1397), + 1858: uint16(464), + 1859: uint16(594), + 1860: uint16(464), + 1861: uint16(1641), + 1862: uint16(535), + 1863: uint16(1050), + 1864: uint16(1581), + 1865: uint16(1395), + 1866: uint16(1269), + 1867: uint16(1583), + 1868: uint16(1582), + 1869: uint16(213), + 1870: uint16(402), + 1871: uint16(277), + 1872: uint16(214), + 1873: uint16(227), + 1874: uint16(464), + 1875: uint16(1573), + 1876: uint16(239), + 1877: uint16(1571), + 1878: uint16(1266), + 1879: uint16(1394), + 1880: uint16(434), + 1881: uint16(198), + 1882: uint16(100), + 1883: uint16(224), + 1884: uint16(96), + 1885: uint16(183), + 1886: uint16(582), + 1887: uint16(191), + 1888: uint16(485), + 1889: uint16(193), + 1890: uint16(486), + 1891: uint16(194), + 1892: uint16(195), + 1893: uint16(196), + 1894: uint16(519), + 1895: uint16(1050), + 1896: uint16(1050), + 1897: uint16(1052), + 1898: uint16(1053), + 1899: uint16(35), + 1900: uint16(559), + 1901: uint16(113), + 1902: uint16(252), + 1903: uint16(413), + 1904: uint16(1447), + 1905: uint16(558), + 1906: uint16(493), + 1907: uint16(13), + 1908: uint16(1455), + 1909: uint16(416), + 1910: uint16(1453), + 1911: uint16(1452), + 1912: uint16(14), + 1913: uint16(202), + 1914: uint16(1521), + 1915: uint16(1062), + 1916: uint16(1532), + 1917: uint16(508), + 1918: uint16(258), + 1919: uint16(106), + 1920: uint16(514), + 1921: uint16(125), + 1922: uint16(125), + 1923: uint16(99), + 1924: uint16(1214), + 1925: uint16(1543), + 1926: uint16(289), + 1927: uint16(260), + 1928: uint16(206), + 1929: uint16(126), + 1930: uint16(365), + 1931: uint16(464), + 1932: uint16(594), + 1933: uint16(464), + 1934: uint16(361), + 1935: uint16(517), + 1936: uint16(1050), + 1937: uint16(261), + 1938: uint16(448), + 1939: uint16(1295), + 1940: uint16(262), + 1941: uint16(418), + 1942: uint16(1352), + 1943: uint16(1351), + 1944: uint16(108), + 1945: uint16(1350), + 1946: uint16(1655), + 1947: uint16(1654), + 1948: uint16(1343), + 1949: uint16(915), + 1950: uint16(419), + 1951: uint16(1322), + 1952: uint16(233), + 1953: uint16(452), + 1954: uint16(319), + 1955: uint16(379), + 1956: uint16(1321), + 1957: uint16(453), + 1958: uint16(1623), + 1959: uint16(320), + 1960: uint16(1320), + 1961: uint16(275), + 1962: uint16(1653), + 1963: uint16(544), + 1964: uint16(276), + 1965: uint16(1609), + 1966: uint16(1608), + 1967: uint16(1342), + 1968: uint16(1050), + 1969: uint16(1050), + 1970: uint16(1052), + 1971: uint16(1053), + 1972: uint16(35), + 1973: uint16(1630), + 1974: uint16(1218), + 1975: uint16(466), + 1976: uint16(385), + 1977: uint16(456), + 1978: uint16(300), + 1979: uint16(1419), + 1980: uint16(144), + 1981: uint16(1418), + 1982: uint16(570), + 1983: uint16(407), + 1984: uint16(407), + 1985: uint16(406), + 1986: uint16(284), + 1987: uint16(404), + 1988: uint16(11), + 1989: uint16(1508), + 1990: uint16(881), + 1991: uint16(396), + 1992: uint16(120), + 1993: uint16(127), + 1994: uint16(585), + 1995: uint16(394), + 1996: uint16(4), + 1997: uint16(1214), + 1998: uint16(327), + 1999: uint16(114), + 2000: uint16(1375), + 2001: uint16(1374), + 2002: uint16(220), + 2003: uint16(247), + 2004: uint16(400), + 2005: uint16(338), + 2006: uint16(401), + 2007: uint16(554), + 2008: uint16(42), + 2009: uint16(1224), + 2010: uint16(588), + 2011: uint16(596), + 2012: uint16(283), + 2013: uint16(337), + 2014: uint16(285), + 2015: uint16(286), + 2016: uint16(188), + 2017: uint16(597), + 2018: uint16(1290), + 2019: uint16(1285), + 2020: uint16(175), + 2021: uint16(1558), + 2022: uint16(176), + 2023: uint16(1559), + 2024: uint16(1557), + 2025: uint16(1556), + 2026: uint16(159), + 2027: uint16(317), + 2028: uint16(229), + 2029: uint16(177), + 2030: uint16(868), + 2031: uint16(230), + 2032: uint16(91), + 2033: uint16(465), + 2034: uint16(464), + 2035: uint16(221), + 2036: uint16(331), + 2037: uint16(468), + 2038: uint16(1165), + 2039: uint16(470), + 2040: uint16(473), + 2041: uint16(94), + 2042: uint16(244), + 2043: uint16(95), + 2044: uint16(249), + 2045: uint16(189), + 2046: uint16(582), + 2047: uint16(1124), + 2048: uint16(1122), + 2049: uint16(341), + 2050: uint16(427), + 2051: uint16(190), + 2052: uint16(178), + 2053: uint16(1249), + 2054: uint16(179), + 2055: uint16(43), + 2056: uint16(192), + 2057: uint16(947), + 2058: uint16(349), + 2059: uint16(428), + 2060: uint16(1138), + 2061: uint16(197), + 2062: uint16(251), + 2063: uint16(180), + 2064: uint16(181), + 2065: uint16(436), + 2066: uint16(102), + 2067: uint16(182), + 2068: uint16(438), + 2069: uint16(103), + 2070: uint16(104), + 2071: uint16(199), + 2072: uint16(248), + 2073: uint16(1140), + 2074: uint16(253), + 2075: uint16(1062), + 2076: uint16(105), + 2077: uint16(255), + 2078: uint16(1137), + 2079: uint16(166), + 2080: uint16(24), + 2081: uint16(125), + 2082: uint16(125), + 2083: uint16(257), + 2084: uint16(1264), + 2085: uint16(273), + 2086: uint16(360), + 2087: uint16(513), + 2088: uint16(259), + 2089: uint16(126), + 2090: uint16(15), + 2091: uint16(464), + 2092: uint16(594), + 2093: uint16(464), + 2094: uint16(204), + 2095: uint16(883), + 2096: uint16(1050), + 2097: uint16(518), + 2098: uint16(263), + 2099: uint16(373), + 2100: uint16(381), + 2101: uint16(92), + 2102: uint16(585), + 2103: uint16(1130), + 2104: uint16(4), + 2105: uint16(203), + 2106: uint16(205), + 2107: uint16(426), + 2108: uint16(107), + 2109: uint16(522), + 2110: uint16(25), + 2111: uint16(26), + 2112: uint16(329), + 2113: uint16(584), + 2114: uint16(913), + 2115: uint16(572), + 2116: uint16(527), + 2117: uint16(376), + 2118: uint16(588), + 2119: uint16(926), + 2120: uint16(530), + 2121: uint16(109), + 2122: uint16(184), + 2123: uint16(318), + 2124: uint16(167), + 2125: uint16(110), + 2126: uint16(27), + 2127: uint16(538), + 2128: uint16(1050), + 2129: uint16(1050), + 2130: uint16(1052), + 2131: uint16(1053), + 2132: uint16(35), + 2133: uint16(1211), + 2134: uint16(1091), + 2135: uint16(17), + 2136: uint16(476), + 2137: uint16(111), + 2138: uint16(1181), + 2139: uint16(234), + 2140: uint16(292), + 2141: uint16(1180), + 2142: uint16(464), + 2143: uint16(294), + 2144: uint16(207), + 2145: uint16(994), + 2146: uint16(129), + 2147: uint16(1201), + 2148: uint16(272), + 2149: uint16(1000), + 2150: uint16(28), + 2151: uint16(1197), + 2152: uint16(29), + 2153: uint16(30), + 2154: uint16(582), + 2155: uint16(1199), + 2156: uint16(1205), + 2157: uint16(1214), + 2158: uint16(31), + 2159: uint16(1204), + 2160: uint16(32), + 2161: uint16(1186), + 2162: uint16(41), + 2163: uint16(566), + 2164: uint16(33), + 2165: uint16(1105), + 2166: uint16(211), + 2167: uint16(8), + 2168: uint16(115), + 2169: uint16(1092), + 2170: uint16(1090), + 2171: uint16(1094), + 2172: uint16(34), + 2173: uint16(278), + 2174: uint16(578), + 2175: uint16(1095), + 2176: uint16(117), + 2177: uint16(122), + 2178: uint16(118), + 2179: uint16(1145), + 2180: uint16(36), + 2181: uint16(18), + 2182: uint16(128), + 2183: uint16(1062), + 2184: uint16(1055), + 2185: uint16(895), + 2186: uint16(957), + 2187: uint16(37), + 2188: uint16(589), + 2189: uint16(125), + 2190: uint16(125), + 2191: uint16(279), + 2192: uint16(186), + 2193: uint16(280), + 2194: uint16(1646), + 2195: uint16(157), + 2196: uint16(405), + 2197: uint16(126), + 2198: uint16(1220), + 2199: uint16(464), + 2200: uint16(594), + 2201: uint16(464), + 2202: uint16(1218), + 2203: uint16(466), + 2204: uint16(1050), + 2205: uint16(1219), + 2206: uint16(300), + 2207: uint16(1281), + 2208: uint16(1281), + 2209: uint16(1281), + 2210: uint16(1281), + 2211: uint16(407), + 2212: uint16(407), + 2213: uint16(406), + 2214: uint16(284), + 2215: uint16(404), + 2216: uint16(1281), + 2217: uint16(1281), + 2218: uint16(881), + 2219: uint16(1281), + 2220: uint16(300), + 2221: uint16(1281), + 2222: uint16(1281), + 2223: uint16(571), + 2224: uint16(1281), + 2225: uint16(407), + 2226: uint16(407), + 2227: uint16(406), + 2228: uint16(284), + 2229: uint16(404), + 2230: uint16(1281), + 2231: uint16(247), + 2232: uint16(881), + 2233: uint16(338), + 2234: uint16(1281), + 2235: uint16(1281), + 2236: uint16(1050), + 2237: uint16(1050), + 2238: uint16(1052), + 2239: uint16(1053), + 2240: uint16(35), + 2241: uint16(337), + 2242: uint16(1281), + 2243: uint16(1281), + 2244: uint16(1281), + 2245: uint16(247), + 2246: uint16(1281), + 2247: uint16(338), + 2248: uint16(1281), + 2249: uint16(1281), + 2250: uint16(1281), + 2251: uint16(1281), + 2252: uint16(1281), + 2253: uint16(1281), + 2254: uint16(1281), + 2255: uint16(337), + 2256: uint16(1281), + 2257: uint16(1281), + 2258: uint16(1281), + 2259: uint16(1281), + 2260: uint16(1281), + 2261: uint16(1281), + 2262: uint16(1281), + 2263: uint16(1281), + 2264: uint16(1281), + 2265: uint16(1214), + 2266: uint16(1281), + 2267: uint16(1281), + 2268: uint16(1281), + 2269: uint16(1281), + 2270: uint16(1281), + 2271: uint16(1281), + 2272: uint16(249), + 2273: uint16(1281), + 2274: uint16(1281), + 2275: uint16(1281), + 2276: uint16(1281), + 2277: uint16(1281), + 2278: uint16(1281), + 2279: uint16(1281), + 2280: uint16(178), + 2281: uint16(1281), + 2282: uint16(1281), + 2283: uint16(43), + 2284: uint16(1281), + 2285: uint16(1281), + 2286: uint16(249), + 2287: uint16(1281), + 2288: uint16(1281), + 2289: uint16(1281), + 2290: uint16(1281), + 2291: uint16(1281), + 2292: uint16(1281), + 2293: uint16(1281), + 2294: uint16(178), + 2295: uint16(1281), + 2296: uint16(1281), + 2297: uint16(43), + 2298: uint16(1281), + 2299: uint16(1281), + 2300: uint16(248), + 2301: uint16(1281), + 2302: uint16(1281), + 2303: uint16(1281), + 2304: uint16(1281), + 2305: uint16(1281), + 2306: uint16(1281), + 2307: uint16(1281), + 2308: uint16(1281), + 2309: uint16(1281), + 2310: uint16(1281), + 2311: uint16(1281), + 2312: uint16(1281), + 2313: uint16(1281), + 2314: uint16(248), + 2315: uint16(1281), + 2316: uint16(1281), + 2317: uint16(1281), + 2318: uint16(1281), + 2319: uint16(1281), + 2320: uint16(1281), + 2321: uint16(1281), + 2322: uint16(1281), + 2323: uint16(1281), + 2324: uint16(1281), + 2325: uint16(1281), + 2326: uint16(1281), + 2327: uint16(1281), + 2328: uint16(1281), + 2329: uint16(1281), + 2330: uint16(1281), + 2331: uint16(1281), + 2332: uint16(1281), + 2333: uint16(1281), + 2334: uint16(1281), + 2335: uint16(426), + 2336: uint16(1281), + 2337: uint16(1281), + 2338: uint16(1281), + 2339: uint16(1281), + 2340: uint16(329), + 2341: uint16(584), + 2342: uint16(1281), + 2343: uint16(1281), + 2344: uint16(1281), + 2345: uint16(1281), + 2346: uint16(1281), + 2347: uint16(1281), + 2348: uint16(1281), + 2349: uint16(426), + 2350: uint16(1281), + 2351: uint16(1281), + 2352: uint16(1281), + 2353: uint16(1281), + 2354: uint16(329), + 2355: uint16(584), + 2356: uint16(1281), + 2357: uint16(1281), + 2358: uint16(1281), + 2359: uint16(1281), + 2360: uint16(1281), + 2361: uint16(1281), + 2362: uint16(1281), + 2363: uint16(1281), + 2364: uint16(476), + 2365: uint16(1281), + 2366: uint16(1281), + 2367: uint16(1281), + 2368: uint16(1281), + 2369: uint16(1281), + 2370: uint16(1281), + 2371: uint16(1281), + 2372: uint16(1281), + 2373: uint16(1281), + 2374: uint16(1281), + 2375: uint16(1281), + 2376: uint16(1281), + 2377: uint16(1281), + 2378: uint16(476), +} + +var _yy_default = [600]uint16{ + 0: uint16(1691), + 1: uint16(1691), + 2: uint16(1691), + 3: uint16(1516), + 4: uint16(1279), + 5: uint16(1392), + 6: uint16(1279), + 7: uint16(1279), + 8: uint16(1279), + 9: uint16(1279), + 10: uint16(1516), + 11: uint16(1516), + 12: uint16(1516), + 13: uint16(1279), + 14: uint16(1279), + 15: uint16(1279), + 16: uint16(1279), + 17: uint16(1279), + 18: uint16(1279), + 19: uint16(1422), + 20: uint16(1422), + 21: uint16(1568), + 22: uint16(1312), + 23: uint16(1279), + 24: uint16(1279), + 25: uint16(1279), + 26: uint16(1279), + 27: uint16(1279), + 28: uint16(1279), + 29: uint16(1279), + 30: uint16(1279), + 31: uint16(1279), + 32: uint16(1279), + 33: uint16(1279), + 34: uint16(1279), + 35: uint16(1515), + 36: uint16(1279), + 37: uint16(1279), + 38: uint16(1279), + 39: uint16(1279), + 40: uint16(1607), + 41: uint16(1607), + 42: uint16(1279), + 43: uint16(1279), + 44: uint16(1279), + 45: uint16(1279), + 46: uint16(1279), + 47: uint16(1592), + 48: uint16(1591), + 49: uint16(1279), + 50: uint16(1279), + 51: uint16(1279), + 52: uint16(1431), + 53: uint16(1279), + 54: uint16(1279), + 55: uint16(1279), + 56: uint16(1438), + 57: uint16(1279), + 58: uint16(1279), + 59: uint16(1279), + 60: uint16(1279), + 61: uint16(1279), + 62: uint16(1517), + 63: uint16(1518), + 64: uint16(1279), + 65: uint16(1279), + 66: uint16(1279), + 67: uint16(1279), + 68: uint16(1567), + 69: uint16(1569), + 70: uint16(1533), + 71: uint16(1445), + 72: uint16(1444), + 73: uint16(1443), + 74: uint16(1442), + 75: uint16(1551), + 76: uint16(1410), + 77: uint16(1436), + 78: uint16(1429), + 79: uint16(1433), + 80: uint16(1512), + 81: uint16(1513), + 82: uint16(1511), + 83: uint16(1670), + 84: uint16(1518), + 85: uint16(1517), + 86: uint16(1279), + 87: uint16(1432), + 88: uint16(1480), + 89: uint16(1496), + 90: uint16(1479), + 91: uint16(1279), + 92: uint16(1279), + 93: uint16(1279), + 94: uint16(1279), + 95: uint16(1279), + 96: uint16(1279), + 97: uint16(1279), + 98: uint16(1279), + 99: uint16(1279), + 100: uint16(1279), + 101: uint16(1279), + 102: uint16(1279), + 103: uint16(1279), + 104: uint16(1279), + 105: uint16(1279), + 106: uint16(1279), + 107: uint16(1279), + 108: uint16(1279), + 109: uint16(1279), + 110: uint16(1279), + 111: uint16(1279), + 112: uint16(1279), + 113: uint16(1279), + 114: uint16(1279), + 115: uint16(1279), + 116: uint16(1279), + 117: uint16(1279), + 118: uint16(1279), + 119: uint16(1279), + 120: uint16(1279), + 121: uint16(1279), + 122: uint16(1279), + 123: uint16(1279), + 124: uint16(1279), + 125: uint16(1279), + 126: uint16(1279), + 127: uint16(1279), + 128: uint16(1279), + 129: uint16(1279), + 130: uint16(1279), + 131: uint16(1279), + 132: uint16(1279), + 133: uint16(1279), + 134: uint16(1279), + 135: uint16(1279), + 136: uint16(1279), + 137: uint16(1279), + 138: uint16(1279), + 139: uint16(1279), + 140: uint16(1279), + 141: uint16(1279), + 142: uint16(1279), + 143: uint16(1279), + 144: uint16(1279), + 145: uint16(1279), + 146: uint16(1488), + 147: uint16(1495), + 148: uint16(1494), + 149: uint16(1493), + 150: uint16(1502), + 151: uint16(1492), + 152: uint16(1489), + 153: uint16(1482), + 154: uint16(1481), + 155: uint16(1483), + 156: uint16(1484), + 157: uint16(1303), + 158: uint16(1300), + 159: uint16(1354), + 160: uint16(1279), + 161: uint16(1279), + 162: uint16(1279), + 163: uint16(1279), + 164: uint16(1279), + 165: uint16(1485), + 166: uint16(1312), + 167: uint16(1473), + 168: uint16(1472), + 169: uint16(1471), + 170: uint16(1279), + 171: uint16(1499), + 172: uint16(1486), + 173: uint16(1498), + 174: uint16(1497), + 175: uint16(1575), + 176: uint16(1644), + 177: uint16(1643), + 178: uint16(1534), + 179: uint16(1279), + 180: uint16(1279), + 181: uint16(1279), + 182: uint16(1279), + 183: uint16(1279), + 184: uint16(1279), + 185: uint16(1607), + 186: uint16(1279), + 187: uint16(1279), + 188: uint16(1279), + 189: uint16(1279), + 190: uint16(1279), + 191: uint16(1279), + 192: uint16(1279), + 193: uint16(1279), + 194: uint16(1279), + 195: uint16(1279), + 196: uint16(1279), + 197: uint16(1279), + 198: uint16(1279), + 199: uint16(1279), + 200: uint16(1279), + 201: uint16(1279), + 202: uint16(1279), + 203: uint16(1279), + 204: uint16(1279), + 205: uint16(1279), + 206: uint16(1279), + 207: uint16(1279), + 208: uint16(1412), + 209: uint16(1607), + 210: uint16(1607), + 211: uint16(1279), + 212: uint16(1312), + 213: uint16(1607), + 214: uint16(1607), + 215: uint16(1308), + 216: uint16(1413), + 217: uint16(1413), + 218: uint16(1308), + 219: uint16(1308), + 220: uint16(1416), + 221: uint16(1587), + 222: uint16(1383), + 223: uint16(1383), + 224: uint16(1383), + 225: uint16(1383), + 226: uint16(1392), + 227: uint16(1383), + 228: uint16(1279), + 229: uint16(1279), + 230: uint16(1279), + 231: uint16(1279), + 232: uint16(1279), + 233: uint16(1279), + 234: uint16(1279), + 235: uint16(1279), + 236: uint16(1279), + 237: uint16(1279), + 238: uint16(1279), + 239: uint16(1279), + 240: uint16(1279), + 241: uint16(1279), + 242: uint16(1279), + 243: uint16(1279), + 244: uint16(1279), + 245: uint16(1279), + 246: uint16(1279), + 247: uint16(1572), + 248: uint16(1570), + 249: uint16(1279), + 250: uint16(1279), + 251: uint16(1279), + 252: uint16(1279), + 253: uint16(1279), + 254: uint16(1279), + 255: uint16(1279), + 256: uint16(1279), + 257: uint16(1279), + 258: uint16(1279), + 259: uint16(1279), + 260: uint16(1279), + 261: uint16(1279), + 262: uint16(1279), + 263: uint16(1279), + 264: uint16(1279), + 265: uint16(1279), + 266: uint16(1279), + 267: uint16(1279), + 268: uint16(1279), + 269: uint16(1279), + 270: uint16(1279), + 271: uint16(1279), + 272: uint16(1279), + 273: uint16(1279), + 274: uint16(1279), + 275: uint16(1388), + 276: uint16(1279), + 277: uint16(1279), + 278: uint16(1279), + 279: uint16(1279), + 280: uint16(1279), + 281: uint16(1279), + 282: uint16(1279), + 283: uint16(1279), + 284: uint16(1279), + 285: uint16(1279), + 286: uint16(1637), + 287: uint16(1683), + 288: uint16(1279), + 289: uint16(1546), + 290: uint16(1368), + 291: uint16(1388), + 292: uint16(1388), + 293: uint16(1388), + 294: uint16(1388), + 295: uint16(1390), + 296: uint16(1369), + 297: uint16(1367), + 298: uint16(1382), + 299: uint16(1313), + 300: uint16(1286), + 301: uint16(1683), + 302: uint16(1683), + 303: uint16(1448), + 304: uint16(1437), + 305: uint16(1389), + 306: uint16(1437), + 307: uint16(1680), + 308: uint16(1435), + 309: uint16(1448), + 310: uint16(1448), + 311: uint16(1435), + 312: uint16(1448), + 313: uint16(1389), + 314: uint16(1680), + 315: uint16(1329), + 316: uint16(1659), + 317: uint16(1324), + 318: uint16(1422), + 319: uint16(1422), + 320: uint16(1422), + 321: uint16(1412), + 322: uint16(1412), + 323: uint16(1412), + 324: uint16(1412), + 325: uint16(1416), + 326: uint16(1416), + 327: uint16(1514), + 328: uint16(1389), + 329: uint16(1382), + 330: uint16(1279), + 331: uint16(1355), + 332: uint16(1683), + 333: uint16(1355), + 334: uint16(1355), + 335: uint16(1398), + 336: uint16(1398), + 337: uint16(1682), + 338: uint16(1682), + 339: uint16(1398), + 340: uint16(1534), + 341: uint16(1667), + 342: uint16(1457), + 343: uint16(1357), + 344: uint16(1363), + 345: uint16(1363), + 346: uint16(1363), + 347: uint16(1363), + 348: uint16(1398), + 349: uint16(1297), + 350: uint16(1435), + 351: uint16(1667), + 352: uint16(1667), + 353: uint16(1435), + 354: uint16(1457), + 355: uint16(1357), + 356: uint16(1435), + 357: uint16(1357), + 358: uint16(1435), + 359: uint16(1398), + 360: uint16(1297), + 361: uint16(1550), + 362: uint16(1678), + 363: uint16(1398), + 364: uint16(1297), + 365: uint16(1524), + 366: uint16(1398), + 367: uint16(1297), + 368: uint16(1398), + 369: uint16(1297), + 370: uint16(1524), + 371: uint16(1355), + 372: uint16(1355), + 373: uint16(1355), + 374: uint16(1344), + 375: uint16(1279), + 376: uint16(1279), + 377: uint16(1524), + 378: uint16(1355), + 379: uint16(1329), + 380: uint16(1355), + 381: uint16(1344), + 382: uint16(1355), + 383: uint16(1355), + 384: uint16(1625), + 385: uint16(1279), + 386: uint16(1528), + 387: uint16(1528), + 388: uint16(1524), + 389: uint16(1398), + 390: uint16(1617), + 391: uint16(1617), + 392: uint16(1425), + 393: uint16(1425), + 394: uint16(1430), + 395: uint16(1416), + 396: uint16(1519), + 397: uint16(1398), + 398: uint16(1279), + 399: uint16(1430), + 400: uint16(1428), + 401: uint16(1426), + 402: uint16(1435), + 403: uint16(1347), + 404: uint16(1640), + 405: uint16(1640), + 406: uint16(1636), + 407: uint16(1636), + 408: uint16(1636), + 409: uint16(1688), + 410: uint16(1688), + 411: uint16(1587), + 412: uint16(1652), + 413: uint16(1312), + 414: uint16(1312), + 415: uint16(1312), + 416: uint16(1312), + 417: uint16(1652), + 418: uint16(1331), + 419: uint16(1331), + 420: uint16(1313), + 421: uint16(1313), + 422: uint16(1312), + 423: uint16(1652), + 424: uint16(1279), + 425: uint16(1279), + 426: uint16(1279), + 427: uint16(1279), + 428: uint16(1279), + 429: uint16(1279), + 430: uint16(1279), + 431: uint16(1647), + 432: uint16(1279), + 433: uint16(1279), + 434: uint16(1535), + 435: uint16(1279), + 436: uint16(1279), + 437: uint16(1279), + 438: uint16(1279), + 439: uint16(1279), + 440: uint16(1279), + 441: uint16(1279), + 442: uint16(1402), + 443: uint16(1279), + 444: uint16(1279), + 445: uint16(1279), + 446: uint16(1279), + 447: uint16(1279), + 448: uint16(1279), + 449: uint16(1279), + 450: uint16(1279), + 451: uint16(1279), + 452: uint16(1593), + 453: uint16(1279), + 454: uint16(1279), + 455: uint16(1279), + 456: uint16(1279), + 457: uint16(1279), + 458: uint16(1279), + 459: uint16(1279), + 460: uint16(1279), + 461: uint16(1279), + 462: uint16(1279), + 463: uint16(1279), + 464: uint16(1462), + 465: uint16(1279), + 466: uint16(1282), + 467: uint16(1584), + 468: uint16(1279), + 469: uint16(1279), + 470: uint16(1279), + 471: uint16(1279), + 472: uint16(1279), + 473: uint16(1279), + 474: uint16(1279), + 475: uint16(1279), + 476: uint16(1279), + 477: uint16(1279), + 478: uint16(1279), + 479: uint16(1279), + 480: uint16(1279), + 481: uint16(1279), + 482: uint16(1439), + 483: uint16(1440), + 484: uint16(1279), + 485: uint16(1279), + 486: uint16(1279), + 487: uint16(1279), + 488: uint16(1279), + 489: uint16(1279), + 490: uint16(1279), + 491: uint16(1454), + 492: uint16(1279), + 493: uint16(1279), + 494: uint16(1279), + 495: uint16(1449), + 496: uint16(1279), + 497: uint16(1279), + 498: uint16(1279), + 499: uint16(1279), + 500: uint16(1279), + 501: uint16(1279), + 502: uint16(1279), + 503: uint16(1279), + 504: uint16(1403), + 505: uint16(1279), + 506: uint16(1279), + 507: uint16(1279), + 508: uint16(1279), + 509: uint16(1279), + 510: uint16(1279), + 511: uint16(1549), + 512: uint16(1548), + 513: uint16(1279), + 514: uint16(1279), + 515: uint16(1400), + 516: uint16(1279), + 517: uint16(1279), + 518: uint16(1279), + 519: uint16(1279), + 520: uint16(1279), + 521: uint16(1279), + 522: uint16(1279), + 523: uint16(1279), + 524: uint16(1279), + 525: uint16(1279), + 526: uint16(1279), + 527: uint16(1279), + 528: uint16(1279), + 529: uint16(1327), + 530: uint16(1279), + 531: uint16(1279), + 532: uint16(1279), + 533: uint16(1279), + 534: uint16(1279), + 535: uint16(1279), + 536: uint16(1279), + 537: uint16(1279), + 538: uint16(1279), + 539: uint16(1279), + 540: uint16(1279), + 541: uint16(1279), + 542: uint16(1279), + 543: uint16(1279), + 544: uint16(1279), + 545: uint16(1279), + 546: uint16(1279), + 547: uint16(1279), + 548: uint16(1279), + 549: uint16(1279), + 550: uint16(1279), + 551: uint16(1279), + 552: uint16(1279), + 553: uint16(1427), + 554: uint16(1279), + 555: uint16(1279), + 556: uint16(1279), + 557: uint16(1279), + 558: uint16(1279), + 559: uint16(1279), + 560: uint16(1279), + 561: uint16(1279), + 562: uint16(1279), + 563: uint16(1279), + 564: uint16(1279), + 565: uint16(1279), + 566: uint16(1279), + 567: uint16(1279), + 568: uint16(1622), + 569: uint16(1417), + 570: uint16(1279), + 571: uint16(1279), + 572: uint16(1279), + 573: uint16(1279), + 574: uint16(1671), + 575: uint16(1279), + 576: uint16(1279), + 577: uint16(1279), + 578: uint16(1279), + 579: uint16(1377), + 580: uint16(1279), + 581: uint16(1279), + 582: uint16(1279), + 583: uint16(1279), + 584: uint16(1279), + 585: uint16(1279), + 586: uint16(1279), + 587: uint16(1279), + 588: uint16(1279), + 589: uint16(1279), + 590: uint16(1663), + 591: uint16(1371), + 592: uint16(1463), + 593: uint16(1279), + 594: uint16(1466), + 595: uint16(1301), + 596: uint16(1279), + 597: uint16(1291), + 598: uint16(1279), + 599: uint16(1279), +} + +/********** End of lemon-generated parsing tables *****************************/ + +var _yy_lookahead = [2566]uint16{ + 0: uint16(277), + 1: uint16(278), + 2: uint16(279), + 3: uint16(241), + 4: uint16(242), + 5: uint16(225), + 6: uint16(195), + 7: uint16(227), + 8: uint16(195), + 9: uint16(312), + 10: uint16(195), + 11: uint16(218), + 12: uint16(195), + 13: uint16(316), + 14: uint16(195), + 15: uint16(235), + 16: uint16(254), + 17: uint16(195), + 18: uint16(256), + 19: uint16(19), + 20: uint16(297), + 21: uint16(277), + 22: uint16(278), + 23: uint16(279), + 24: uint16(218), + 25: uint16(206), + 26: uint16(213), + 27: uint16(214), + 28: uint16(206), + 29: uint16(218), + 30: uint16(219), + 31: uint16(31), + 32: uint16(206), + 33: uint16(218), + 34: uint16(219), + 35: uint16(218), + 36: uint16(219), + 37: uint16(218), + 38: uint16(219), + 39: uint16(39), + 40: uint16(218), + 41: uint16(219), + 42: uint16(195), + 43: uint16(43), + 44: uint16(44), + 45: uint16(45), + 46: uint16(195), + 47: uint16(47), + 48: uint16(48), + 49: uint16(49), + 50: uint16(50), + 51: uint16(51), + 52: uint16(52), + 53: uint16(53), + 54: uint16(54), + 55: uint16(55), + 56: uint16(56), + 57: uint16(57), + 58: uint16(58), + 59: uint16(19), + 60: uint16(241), + 61: uint16(242), + 62: uint16(195), + 63: uint16(241), + 64: uint16(242), + 65: uint16(195), + 66: uint16(255), + 67: uint16(241), + 68: uint16(242), + 69: uint16(195), + 70: uint16(255), + 71: uint16(237), + 72: uint16(238), + 73: uint16(254), + 74: uint16(255), + 75: uint16(256), + 76: uint16(254), + 77: uint16(255), + 78: uint16(256), + 79: uint16(264), + 80: uint16(254), + 81: uint16(207), + 82: uint16(256), + 83: uint16(43), + 84: uint16(44), + 85: uint16(45), + 86: uint16(264), + 87: uint16(47), + 88: uint16(48), + 89: uint16(49), + 90: uint16(50), + 91: uint16(51), + 92: uint16(52), + 93: uint16(53), + 94: uint16(54), + 95: uint16(55), + 96: uint16(56), + 97: uint16(57), + 98: uint16(58), + 99: uint16(251), + 100: uint16(287), + 101: uint16(253), + 102: uint16(215), + 103: uint16(103), + 104: uint16(104), + 105: uint16(105), + 106: uint16(106), + 107: uint16(107), + 108: uint16(108), + 109: uint16(109), + 110: uint16(110), + 111: uint16(111), + 112: uint16(112), + 113: uint16(113), + 114: uint16(114), + 115: uint16(82), + 116: uint16(265), + 117: uint16(195), + 118: uint16(271), + 119: uint16(11), + 120: uint16(187), + 121: uint16(188), + 122: uint16(189), + 123: uint16(190), + 124: uint16(191), + 125: uint16(192), + 126: uint16(190), + 127: uint16(87), + 128: uint16(192), + 129: uint16(89), + 130: uint16(197), + 131: uint16(19), + 132: uint16(199), + 133: uint16(197), + 134: uint16(317), + 135: uint16(199), + 136: uint16(319), + 137: uint16(25), + 138: uint16(271), + 139: uint16(206), + 140: uint16(218), + 141: uint16(219), + 142: uint16(206), + 143: uint16(103), + 144: uint16(104), + 145: uint16(105), + 146: uint16(106), + 147: uint16(107), + 148: uint16(108), + 149: uint16(109), + 150: uint16(110), + 151: uint16(111), + 152: uint16(112), + 153: uint16(113), + 154: uint16(114), + 155: uint16(43), + 156: uint16(44), + 157: uint16(45), + 158: uint16(195), + 159: uint16(47), + 160: uint16(48), + 161: uint16(49), + 162: uint16(50), + 163: uint16(51), + 164: uint16(52), + 165: uint16(53), + 166: uint16(54), + 167: uint16(55), + 168: uint16(56), + 169: uint16(57), + 170: uint16(58), + 171: uint16(60), + 172: uint16(139), + 173: uint16(140), + 174: uint16(241), + 175: uint16(242), + 176: uint16(289), + 177: uint16(241), + 178: uint16(242), + 179: uint16(309), + 180: uint16(310), + 181: uint16(294), + 182: uint16(70), + 183: uint16(47), + 184: uint16(48), + 185: uint16(49), + 186: uint16(50), + 187: uint16(254), + 188: uint16(77), + 189: uint16(256), + 190: uint16(254), + 191: uint16(195), + 192: uint16(256), + 193: uint16(55), + 194: uint16(56), + 195: uint16(57), + 196: uint16(58), + 197: uint16(59), + 198: uint16(221), + 199: uint16(88), + 200: uint16(109), + 201: uint16(90), + 202: uint16(269), + 203: uint16(240), + 204: uint16(93), + 205: uint16(269), + 206: uint16(107), + 207: uint16(108), + 208: uint16(109), + 209: uint16(110), + 210: uint16(111), + 211: uint16(112), + 212: uint16(113), + 213: uint16(114), + 214: uint16(215), + 215: uint16(103), + 216: uint16(104), + 217: uint16(105), + 218: uint16(106), + 219: uint16(107), + 220: uint16(108), + 221: uint16(109), + 222: uint16(110), + 223: uint16(111), + 224: uint16(112), + 225: uint16(113), + 226: uint16(114), + 227: uint16(136), + 228: uint16(117), + 229: uint16(118), + 230: uint16(119), + 231: uint16(298), + 232: uint16(141), + 233: uint16(300), + 234: uint16(298), + 235: uint16(19), + 236: uint16(300), + 237: uint16(129), + 238: uint16(130), + 239: uint16(317), + 240: uint16(318), + 241: uint16(103), + 242: uint16(104), + 243: uint16(105), + 244: uint16(106), + 245: uint16(107), + 246: uint16(108), + 247: uint16(109), + 248: uint16(110), + 249: uint16(111), + 250: uint16(112), + 251: uint16(113), + 252: uint16(114), + 253: uint16(114), + 254: uint16(277), + 255: uint16(278), + 256: uint16(279), + 257: uint16(146), + 258: uint16(122), + 259: uint16(43), + 260: uint16(44), + 261: uint16(45), + 262: uint16(195), + 263: uint16(47), + 264: uint16(48), + 265: uint16(49), + 266: uint16(50), + 267: uint16(51), + 268: uint16(52), + 269: uint16(53), + 270: uint16(54), + 271: uint16(55), + 272: uint16(56), + 273: uint16(57), + 274: uint16(58), + 275: uint16(218), + 276: uint16(277), + 277: uint16(278), + 278: uint16(279), + 279: uint16(19), + 280: uint16(19), + 281: uint16(195), + 282: uint16(286), + 283: uint16(23), + 284: uint16(68), + 285: uint16(218), + 286: uint16(219), + 287: uint16(55), + 288: uint16(56), + 289: uint16(57), + 290: uint16(58), + 291: uint16(103), + 292: uint16(104), + 293: uint16(105), + 294: uint16(106), + 295: uint16(107), + 296: uint16(108), + 297: uint16(109), + 298: uint16(110), + 299: uint16(111), + 300: uint16(112), + 301: uint16(113), + 302: uint16(114), + 303: uint16(43), + 304: uint16(44), + 305: uint16(45), + 306: uint16(232), + 307: uint16(47), + 308: uint16(48), + 309: uint16(49), + 310: uint16(50), + 311: uint16(51), + 312: uint16(52), + 313: uint16(53), + 314: uint16(54), + 315: uint16(55), + 316: uint16(56), + 317: uint16(57), + 318: uint16(58), + 319: uint16(103), + 320: uint16(104), + 321: uint16(105), + 322: uint16(106), + 323: uint16(107), + 324: uint16(108), + 325: uint16(109), + 326: uint16(110), + 327: uint16(111), + 328: uint16(112), + 329: uint16(113), + 330: uint16(114), + 331: uint16(135), + 332: uint16(60), + 333: uint16(137), + 334: uint16(138), + 335: uint16(103), + 336: uint16(104), + 337: uint16(105), + 338: uint16(106), + 339: uint16(107), + 340: uint16(108), + 341: uint16(109), + 342: uint16(110), + 343: uint16(111), + 344: uint16(112), + 345: uint16(113), + 346: uint16(114), + 347: uint16(82), + 348: uint16(281), + 349: uint16(206), + 350: uint16(195), + 351: uint16(109), + 352: uint16(110), + 353: uint16(111), + 354: uint16(112), + 355: uint16(113), + 356: uint16(114), + 357: uint16(195), + 358: uint16(195), + 359: uint16(195), + 360: uint16(205), + 361: uint16(22), + 362: uint16(207), + 363: uint16(103), + 364: uint16(104), + 365: uint16(105), + 366: uint16(106), + 367: uint16(107), + 368: uint16(108), + 369: uint16(109), + 370: uint16(110), + 371: uint16(111), + 372: uint16(112), + 373: uint16(113), + 374: uint16(114), + 375: uint16(195), + 376: uint16(60), + 377: uint16(116), + 378: uint16(117), + 379: uint16(107), + 380: uint16(108), + 381: uint16(218), + 382: uint16(219), + 383: uint16(19), + 384: uint16(241), + 385: uint16(242), + 386: uint16(121), + 387: uint16(23), + 388: uint16(116), + 389: uint16(117), + 390: uint16(118), + 391: uint16(119), + 392: uint16(306), + 393: uint16(121), + 394: uint16(308), + 395: uint16(206), + 396: uint16(234), + 397: uint16(254), + 398: uint16(15), + 399: uint16(256), + 400: uint16(195), + 401: uint16(129), + 402: uint16(259), + 403: uint16(260), + 404: uint16(139), + 405: uint16(140), + 406: uint16(145), + 407: uint16(43), + 408: uint16(44), + 409: uint16(45), + 410: uint16(200), + 411: uint16(47), + 412: uint16(48), + 413: uint16(49), + 414: uint16(50), + 415: uint16(51), + 416: uint16(52), + 417: uint16(53), + 418: uint16(54), + 419: uint16(55), + 420: uint16(56), + 421: uint16(57), + 422: uint16(58), + 423: uint16(218), + 424: uint16(219), + 425: uint16(60), + 426: uint16(154), + 427: uint16(19), + 428: uint16(156), + 429: uint16(265), + 430: uint16(241), + 431: uint16(242), + 432: uint16(24), + 433: uint16(117), + 434: uint16(118), + 435: uint16(119), + 436: uint16(120), + 437: uint16(21), + 438: uint16(73), + 439: uint16(123), + 440: uint16(124), + 441: uint16(125), + 442: uint16(74), + 443: uint16(254), + 444: uint16(61), + 445: uint16(256), + 446: uint16(107), + 447: uint16(108), + 448: uint16(221), + 449: uint16(133), + 450: uint16(82), + 451: uint16(43), + 452: uint16(44), + 453: uint16(45), + 454: uint16(195), + 455: uint16(47), + 456: uint16(48), + 457: uint16(49), + 458: uint16(50), + 459: uint16(51), + 460: uint16(52), + 461: uint16(53), + 462: uint16(54), + 463: uint16(55), + 464: uint16(56), + 465: uint16(57), + 466: uint16(58), + 467: uint16(103), + 468: uint16(104), + 469: uint16(105), + 470: uint16(106), + 471: uint16(107), + 472: uint16(108), + 473: uint16(109), + 474: uint16(110), + 475: uint16(111), + 476: uint16(112), + 477: uint16(113), + 478: uint16(114), + 479: uint16(195), + 480: uint16(317), + 481: uint16(318), + 482: uint16(117), + 483: uint16(118), + 484: uint16(119), + 485: uint16(22), + 486: uint16(120), + 487: uint16(195), + 488: uint16(22), + 489: uint16(123), + 490: uint16(124), + 491: uint16(125), + 492: uint16(19), + 493: uint16(20), + 494: uint16(284), + 495: uint16(22), + 496: uint16(128), + 497: uint16(81), + 498: uint16(288), + 499: uint16(133), + 500: uint16(195), + 501: uint16(195), + 502: uint16(218), + 503: uint16(219), + 504: uint16(277), + 505: uint16(278), + 506: uint16(279), + 507: uint16(139), + 508: uint16(140), + 509: uint16(36), + 510: uint16(195), + 511: uint16(103), + 512: uint16(104), + 513: uint16(105), + 514: uint16(106), + 515: uint16(107), + 516: uint16(108), + 517: uint16(109), + 518: uint16(110), + 519: uint16(111), + 520: uint16(112), + 521: uint16(113), + 522: uint16(114), + 523: uint16(218), + 524: uint16(219), + 525: uint16(62), + 526: uint16(60), + 527: uint16(195), + 528: uint16(241), + 529: uint16(242), + 530: uint16(271), + 531: uint16(19), + 532: uint16(240), + 533: uint16(60), + 534: uint16(189), + 535: uint16(190), + 536: uint16(191), + 537: uint16(192), + 538: uint16(233), + 539: uint16(255), + 540: uint16(124), + 541: uint16(254), + 542: uint16(197), + 543: uint16(256), + 544: uint16(199), + 545: uint16(72), + 546: uint16(129), + 547: uint16(130), + 548: uint16(264), + 549: uint16(195), + 550: uint16(195), + 551: uint16(206), + 552: uint16(22), + 553: uint16(23), + 554: uint16(60), + 555: uint16(43), + 556: uint16(44), + 557: uint16(45), + 558: uint16(206), + 559: uint16(47), + 560: uint16(48), + 561: uint16(49), + 562: uint16(50), + 563: uint16(51), + 564: uint16(52), + 565: uint16(53), + 566: uint16(54), + 567: uint16(55), + 568: uint16(56), + 569: uint16(57), + 570: uint16(58), + 571: uint16(195), + 572: uint16(218), + 573: uint16(219), + 574: uint16(101), + 575: uint16(195), + 576: uint16(60), + 577: uint16(271), + 578: uint16(162), + 579: uint16(195), + 580: uint16(107), + 581: uint16(108), + 582: uint16(109), + 583: uint16(117), + 584: uint16(118), + 585: uint16(119), + 586: uint16(241), + 587: uint16(242), + 588: uint16(115), + 589: uint16(73), + 590: uint16(117), + 591: uint16(118), + 592: uint16(119), + 593: uint16(241), + 594: uint16(242), + 595: uint16(122), + 596: uint16(60), + 597: uint16(195), + 598: uint16(266), + 599: uint16(254), + 600: uint16(312), + 601: uint16(256), + 602: uint16(218), + 603: uint16(219), + 604: uint16(316), + 605: uint16(203), + 606: uint16(254), + 607: uint16(195), + 608: uint16(256), + 609: uint16(255), + 610: uint16(208), + 611: uint16(117), + 612: uint16(118), + 613: uint16(119), + 614: uint16(269), + 615: uint16(103), + 616: uint16(104), + 617: uint16(105), + 618: uint16(106), + 619: uint16(107), + 620: uint16(108), + 621: uint16(109), + 622: uint16(110), + 623: uint16(111), + 624: uint16(112), + 625: uint16(113), + 626: uint16(114), + 627: uint16(154), + 628: uint16(155), + 629: uint16(156), + 630: uint16(157), + 631: uint16(158), + 632: uint16(102), + 633: uint16(117), + 634: uint16(118), + 635: uint16(119), + 636: uint16(19), + 637: uint16(242), + 638: uint16(144), + 639: uint16(255), + 640: uint16(23), + 641: uint16(206), + 642: uint16(24), + 643: uint16(298), + 644: uint16(195), + 645: uint16(300), + 646: uint16(206), + 647: uint16(195), + 648: uint16(264), + 649: uint16(254), + 650: uint16(206), + 651: uint16(256), + 652: uint16(240), + 653: uint16(117), + 654: uint16(118), + 655: uint16(119), + 656: uint16(183), + 657: uint16(22), + 658: uint16(22), + 659: uint16(23), + 660: uint16(43), + 661: uint16(44), + 662: uint16(45), + 663: uint16(151), + 664: uint16(47), + 665: uint16(48), + 666: uint16(49), + 667: uint16(50), + 668: uint16(51), + 669: uint16(52), + 670: uint16(53), + 671: uint16(54), + 672: uint16(55), + 673: uint16(56), + 674: uint16(57), + 675: uint16(58), + 676: uint16(241), + 677: uint16(242), + 678: uint16(60), + 679: uint16(195), + 680: uint16(19), + 681: uint16(241), + 682: uint16(242), + 683: uint16(195), + 684: uint16(23), + 685: uint16(241), + 686: uint16(242), + 687: uint16(195), + 688: uint16(152), + 689: uint16(254), + 690: uint16(310), + 691: uint16(256), + 692: uint16(243), + 693: uint16(312), + 694: uint16(254), + 695: uint16(60), + 696: uint16(256), + 697: uint16(316), + 698: uint16(254), + 699: uint16(206), + 700: uint16(256), + 701: uint16(60), + 702: uint16(218), + 703: uint16(219), + 704: uint16(43), + 705: uint16(44), + 706: uint16(45), + 707: uint16(272), + 708: uint16(47), + 709: uint16(48), + 710: uint16(49), + 711: uint16(50), + 712: uint16(51), + 713: uint16(52), + 714: uint16(53), + 715: uint16(54), + 716: uint16(55), + 717: uint16(56), + 718: uint16(57), + 719: uint16(58), + 720: uint16(103), + 721: uint16(104), + 722: uint16(105), + 723: uint16(106), + 724: uint16(107), + 725: uint16(108), + 726: uint16(109), + 727: uint16(110), + 728: uint16(111), + 729: uint16(112), + 730: uint16(113), + 731: uint16(114), + 732: uint16(240), + 733: uint16(60), + 734: uint16(241), + 735: uint16(242), + 736: uint16(118), + 737: uint16(25), + 738: uint16(102), + 739: uint16(255), + 740: uint16(166), + 741: uint16(167), + 742: uint16(101), + 743: uint16(22), + 744: uint16(26), + 745: uint16(19), + 746: uint16(20), + 747: uint16(254), + 748: uint16(22), + 749: uint16(256), + 750: uint16(139), + 751: uint16(140), + 752: uint16(117), + 753: uint16(118), + 754: uint16(119), + 755: uint16(306), + 756: uint16(195), + 757: uint16(308), + 758: uint16(117), + 759: uint16(118), + 760: uint16(237), + 761: uint16(238), + 762: uint16(36), + 763: uint16(122), + 764: uint16(103), + 765: uint16(104), + 766: uint16(105), + 767: uint16(106), + 768: uint16(107), + 769: uint16(108), + 770: uint16(109), + 771: uint16(110), + 772: uint16(111), + 773: uint16(112), + 774: uint16(113), + 775: uint16(114), + 776: uint16(195), + 777: uint16(195), + 778: uint16(60), + 779: uint16(218), + 780: uint16(219), + 781: uint16(60), + 782: uint16(109), + 783: uint16(195), + 784: uint16(19), + 785: uint16(217), + 786: uint16(60), + 787: uint16(25), + 788: uint16(23), + 789: uint16(77), + 790: uint16(117), + 791: uint16(118), + 792: uint16(119), + 793: uint16(225), + 794: uint16(233), + 795: uint16(154), + 796: uint16(155), + 797: uint16(156), + 798: uint16(72), + 799: uint16(312), + 800: uint16(218), + 801: uint16(219), + 802: uint16(90), + 803: uint16(316), + 804: uint16(22), + 805: uint16(93), + 806: uint16(303), + 807: uint16(304), + 808: uint16(43), + 809: uint16(44), + 810: uint16(45), + 811: uint16(195), + 812: uint16(47), + 813: uint16(48), + 814: uint16(49), + 815: uint16(50), + 816: uint16(51), + 817: uint16(52), + 818: uint16(53), + 819: uint16(54), + 820: uint16(55), + 821: uint16(56), + 822: uint16(57), + 823: uint16(58), + 824: uint16(183), + 825: uint16(195), + 826: uint16(195), + 827: uint16(101), + 828: uint16(19), + 829: uint16(213), + 830: uint16(214), + 831: uint16(243), + 832: uint16(23), + 833: uint16(107), + 834: uint16(108), + 835: uint16(117), + 836: uint16(118), + 837: uint16(119), + 838: uint16(117), + 839: uint16(118), + 840: uint16(119), + 841: uint16(115), + 842: uint16(60), + 843: uint16(117), + 844: uint16(118), + 845: uint16(119), + 846: uint16(195), + 847: uint16(60), + 848: uint16(122), + 849: uint16(218), + 850: uint16(219), + 851: uint16(22), + 852: uint16(43), + 853: uint16(44), + 854: uint16(45), + 855: uint16(35), + 856: uint16(47), + 857: uint16(48), + 858: uint16(49), + 859: uint16(50), + 860: uint16(51), + 861: uint16(52), + 862: uint16(53), + 863: uint16(54), + 864: uint16(55), + 865: uint16(56), + 866: uint16(57), + 867: uint16(58), + 868: uint16(103), + 869: uint16(104), + 870: uint16(105), + 871: uint16(106), + 872: uint16(107), + 873: uint16(108), + 874: uint16(109), + 875: uint16(110), + 876: uint16(111), + 877: uint16(112), + 878: uint16(113), + 879: uint16(114), + 880: uint16(154), + 881: uint16(155), + 882: uint16(156), + 883: uint16(157), + 884: uint16(158), + 885: uint16(195), + 886: uint16(255), + 887: uint16(67), + 888: uint16(195), + 889: uint16(60), + 890: uint16(101), + 891: uint16(240), + 892: uint16(311), + 893: uint16(312), + 894: uint16(306), + 895: uint16(75), + 896: uint16(308), + 897: uint16(316), + 898: uint16(29), + 899: uint16(117), + 900: uint16(118), + 901: uint16(119), + 902: uint16(33), + 903: uint16(287), + 904: uint16(117), + 905: uint16(118), + 906: uint16(119), + 907: uint16(118), + 908: uint16(146), + 909: uint16(183), + 910: uint16(195), + 911: uint16(122), + 912: uint16(103), + 913: uint16(104), + 914: uint16(105), + 915: uint16(106), + 916: uint16(107), + 917: uint16(108), + 918: uint16(109), + 919: uint16(110), + 920: uint16(111), + 921: uint16(112), + 922: uint16(113), + 923: uint16(114), + 924: uint16(215), + 925: uint16(195), + 926: uint16(77), + 927: uint16(60), + 928: uint16(25), + 929: uint16(195), + 930: uint16(122), + 931: uint16(144), + 932: uint16(19), + 933: uint16(218), + 934: uint16(219), + 935: uint16(66), + 936: uint16(23), + 937: uint16(88), + 938: uint16(246), + 939: uint16(90), + 940: uint16(132), + 941: uint16(25), + 942: uint16(93), + 943: uint16(154), + 944: uint16(155), + 945: uint16(156), + 946: uint16(117), + 947: uint16(118), + 948: uint16(119), + 949: uint16(257), + 950: uint16(195), + 951: uint16(131), + 952: uint16(218), + 953: uint16(219), + 954: uint16(195), + 955: uint16(265), + 956: uint16(43), + 957: uint16(44), + 958: uint16(45), + 959: uint16(195), + 960: uint16(47), + 961: uint16(48), + 962: uint16(49), + 963: uint16(50), + 964: uint16(51), + 965: uint16(52), + 966: uint16(53), + 967: uint16(54), + 968: uint16(55), + 969: uint16(56), + 970: uint16(57), + 971: uint16(58), + 972: uint16(183), + 973: uint16(218), + 974: uint16(219), + 975: uint16(195), + 976: uint16(19), + 977: uint16(218), + 978: uint16(219), + 979: uint16(195), + 980: uint16(23), + 981: uint16(195), + 982: uint16(218), + 983: uint16(219), + 984: uint16(117), + 985: uint16(118), + 986: uint16(119), + 987: uint16(195), + 988: uint16(233), + 989: uint16(255), + 990: uint16(195), + 991: uint16(195), + 992: uint16(233), + 993: uint16(22), + 994: uint16(23), + 995: uint16(146), + 996: uint16(25), + 997: uint16(233), + 998: uint16(218), + 999: uint16(219), + 1000: uint16(43), + 1001: uint16(44), + 1002: uint16(45), + 1003: uint16(294), + 1004: uint16(47), + 1005: uint16(48), + 1006: uint16(49), + 1007: uint16(50), + 1008: uint16(51), + 1009: uint16(52), + 1010: uint16(53), + 1011: uint16(54), + 1012: uint16(55), + 1013: uint16(56), + 1014: uint16(57), + 1015: uint16(58), + 1016: uint16(103), + 1017: uint16(104), + 1018: uint16(105), + 1019: uint16(106), + 1020: uint16(107), + 1021: uint16(108), + 1022: uint16(109), + 1023: uint16(110), + 1024: uint16(111), + 1025: uint16(112), + 1026: uint16(113), + 1027: uint16(114), + 1028: uint16(195), + 1029: uint16(12), + 1030: uint16(234), + 1031: uint16(195), + 1032: uint16(240), + 1033: uint16(74), + 1034: uint16(195), + 1035: uint16(255), + 1036: uint16(195), + 1037: uint16(60), + 1038: uint16(243), + 1039: uint16(262), + 1040: uint16(263), + 1041: uint16(311), + 1042: uint16(312), + 1043: uint16(25), + 1044: uint16(27), + 1045: uint16(19), + 1046: uint16(316), + 1047: uint16(107), + 1048: uint16(108), + 1049: uint16(265), + 1050: uint16(24), + 1051: uint16(265), + 1052: uint16(195), + 1053: uint16(150), + 1054: uint16(195), + 1055: uint16(139), + 1056: uint16(140), + 1057: uint16(218), + 1058: uint16(219), + 1059: uint16(42), + 1060: uint16(103), + 1061: uint16(104), + 1062: uint16(105), + 1063: uint16(106), + 1064: uint16(107), + 1065: uint16(108), + 1066: uint16(109), + 1067: uint16(110), + 1068: uint16(111), + 1069: uint16(112), + 1070: uint16(113), + 1071: uint16(114), + 1072: uint16(233), + 1073: uint16(102), + 1074: uint16(67), + 1075: uint16(218), + 1076: uint16(219), + 1077: uint16(218), + 1078: uint16(219), + 1079: uint16(243), + 1080: uint16(19), + 1081: uint16(64), + 1082: uint16(22), + 1083: uint16(23), + 1084: uint16(23), + 1085: uint16(25), + 1086: uint16(195), + 1087: uint16(128), + 1088: uint16(129), + 1089: uint16(130), + 1090: uint16(233), + 1091: uint16(74), + 1092: uint16(233), + 1093: uint16(86), + 1094: uint16(154), + 1095: uint16(118), + 1096: uint16(156), + 1097: uint16(130), + 1098: uint16(265), + 1099: uint16(208), + 1100: uint16(19), + 1101: uint16(306), + 1102: uint16(95), + 1103: uint16(308), + 1104: uint16(43), + 1105: uint16(44), + 1106: uint16(45), + 1107: uint16(266), + 1108: uint16(47), + 1109: uint16(48), + 1110: uint16(49), + 1111: uint16(50), + 1112: uint16(51), + 1113: uint16(52), + 1114: uint16(53), + 1115: uint16(54), + 1116: uint16(55), + 1117: uint16(56), + 1118: uint16(57), + 1119: uint16(58), + 1120: uint16(153), + 1121: uint16(230), + 1122: uint16(96), + 1123: uint16(232), + 1124: uint16(43), + 1125: uint16(44), + 1126: uint16(45), + 1127: uint16(19), + 1128: uint16(47), + 1129: uint16(48), + 1130: uint16(49), + 1131: uint16(50), + 1132: uint16(51), + 1133: uint16(52), + 1134: uint16(53), + 1135: uint16(54), + 1136: uint16(55), + 1137: uint16(56), + 1138: uint16(57), + 1139: uint16(58), + 1140: uint16(114), + 1141: uint16(22), + 1142: uint16(306), + 1143: uint16(24), + 1144: uint16(308), + 1145: uint16(127), + 1146: uint16(120), + 1147: uint16(121), + 1148: uint16(122), + 1149: uint16(123), + 1150: uint16(124), + 1151: uint16(125), + 1152: uint16(126), + 1153: uint16(195), + 1154: uint16(147), + 1155: uint16(212), + 1156: uint16(213), + 1157: uint16(214), + 1158: uint16(132), + 1159: uint16(23), + 1160: uint16(195), + 1161: uint16(25), + 1162: uint16(102), + 1163: uint16(100), + 1164: uint16(103), + 1165: uint16(104), + 1166: uint16(105), + 1167: uint16(106), + 1168: uint16(107), + 1169: uint16(108), + 1170: uint16(109), + 1171: uint16(110), + 1172: uint16(111), + 1173: uint16(112), + 1174: uint16(113), + 1175: uint16(114), + 1176: uint16(218), + 1177: uint16(219), + 1178: uint16(19), + 1179: uint16(60), + 1180: uint16(195), + 1181: uint16(12), + 1182: uint16(210), + 1183: uint16(211), + 1184: uint16(103), + 1185: uint16(104), + 1186: uint16(105), + 1187: uint16(106), + 1188: uint16(107), + 1189: uint16(108), + 1190: uint16(109), + 1191: uint16(110), + 1192: uint16(111), + 1193: uint16(112), + 1194: uint16(113), + 1195: uint16(114), + 1196: uint16(27), + 1197: uint16(134), + 1198: uint16(195), + 1199: uint16(195), + 1200: uint16(195), + 1201: uint16(210), + 1202: uint16(211), + 1203: uint16(218), + 1204: uint16(219), + 1205: uint16(195), + 1206: uint16(47), + 1207: uint16(195), + 1208: uint16(212), + 1209: uint16(213), + 1210: uint16(214), + 1211: uint16(42), + 1212: uint16(16), + 1213: uint16(130), + 1214: uint16(19), + 1215: uint16(112), + 1216: uint16(113), + 1217: uint16(114), + 1218: uint16(23), + 1219: uint16(77), + 1220: uint16(195), + 1221: uint16(218), + 1222: uint16(219), + 1223: uint16(218), + 1224: uint16(219), + 1225: uint16(117), + 1226: uint16(163), + 1227: uint16(164), + 1228: uint16(218), + 1229: uint16(219), + 1230: uint16(218), + 1231: uint16(219), + 1232: uint16(90), + 1233: uint16(64), + 1234: uint16(19), + 1235: uint16(93), + 1236: uint16(153), + 1237: uint16(118), + 1238: uint16(43), + 1239: uint16(44), + 1240: uint16(45), + 1241: uint16(160), + 1242: uint16(47), + 1243: uint16(48), + 1244: uint16(49), + 1245: uint16(50), + 1246: uint16(51), + 1247: uint16(52), + 1248: uint16(53), + 1249: uint16(54), + 1250: uint16(55), + 1251: uint16(56), + 1252: uint16(57), + 1253: uint16(58), + 1254: uint16(195), + 1255: uint16(119), + 1256: uint16(272), + 1257: uint16(276), + 1258: uint16(43), + 1259: uint16(44), + 1260: uint16(45), + 1261: uint16(195), + 1262: uint16(47), + 1263: uint16(48), + 1264: uint16(49), + 1265: uint16(50), + 1266: uint16(51), + 1267: uint16(52), + 1268: uint16(53), + 1269: uint16(54), + 1270: uint16(55), + 1271: uint16(56), + 1272: uint16(57), + 1273: uint16(58), + 1274: uint16(78), + 1275: uint16(116), + 1276: uint16(80), + 1277: uint16(218), + 1278: uint16(219), + 1279: uint16(116), + 1280: uint16(144), + 1281: uint16(128), + 1282: uint16(129), + 1283: uint16(130), + 1284: uint16(218), + 1285: uint16(219), + 1286: uint16(61), + 1287: uint16(195), + 1288: uint16(47), + 1289: uint16(195), + 1290: uint16(16), + 1291: uint16(132), + 1292: uint16(195), + 1293: uint16(263), + 1294: uint16(195), + 1295: uint16(314), + 1296: uint16(315), + 1297: uint16(267), + 1298: uint16(103), + 1299: uint16(104), + 1300: uint16(105), + 1301: uint16(106), + 1302: uint16(107), + 1303: uint16(108), + 1304: uint16(109), + 1305: uint16(110), + 1306: uint16(111), + 1307: uint16(112), + 1308: uint16(113), + 1309: uint16(114), + 1310: uint16(218), + 1311: uint16(219), + 1312: uint16(218), + 1313: uint16(219), + 1314: uint16(151), + 1315: uint16(218), + 1316: uint16(219), + 1317: uint16(195), + 1318: uint16(103), + 1319: uint16(104), + 1320: uint16(105), + 1321: uint16(106), + 1322: uint16(107), + 1323: uint16(108), + 1324: uint16(109), + 1325: uint16(110), + 1326: uint16(111), + 1327: uint16(112), + 1328: uint16(113), + 1329: uint16(114), + 1330: uint16(210), + 1331: uint16(211), + 1332: uint16(195), + 1333: uint16(7), + 1334: uint16(8), + 1335: uint16(9), + 1336: uint16(195), + 1337: uint16(60), + 1338: uint16(195), + 1339: uint16(312), + 1340: uint16(218), + 1341: uint16(219), + 1342: uint16(195), + 1343: uint16(316), + 1344: uint16(195), + 1345: uint16(120), + 1346: uint16(195), + 1347: uint16(263), + 1348: uint16(19), + 1349: uint16(195), + 1350: uint16(125), + 1351: uint16(267), + 1352: uint16(78), + 1353: uint16(24), + 1354: uint16(80), + 1355: uint16(218), + 1356: uint16(219), + 1357: uint16(116), + 1358: uint16(162), + 1359: uint16(218), + 1360: uint16(219), + 1361: uint16(218), + 1362: uint16(219), + 1363: uint16(301), + 1364: uint16(302), + 1365: uint16(218), + 1366: uint16(219), + 1367: uint16(195), + 1368: uint16(19), + 1369: uint16(218), + 1370: uint16(219), + 1371: uint16(276), + 1372: uint16(43), + 1373: uint16(44), + 1374: uint16(45), + 1375: uint16(160), + 1376: uint16(47), + 1377: uint16(48), + 1378: uint16(49), + 1379: uint16(50), + 1380: uint16(51), + 1381: uint16(52), + 1382: uint16(53), + 1383: uint16(54), + 1384: uint16(55), + 1385: uint16(56), + 1386: uint16(57), + 1387: uint16(58), + 1388: uint16(19), + 1389: uint16(146), + 1390: uint16(218), + 1391: uint16(219), + 1392: uint16(43), + 1393: uint16(44), + 1394: uint16(45), + 1395: uint16(118), + 1396: uint16(47), + 1397: uint16(48), + 1398: uint16(49), + 1399: uint16(50), + 1400: uint16(51), + 1401: uint16(52), + 1402: uint16(53), + 1403: uint16(54), + 1404: uint16(55), + 1405: uint16(56), + 1406: uint16(57), + 1407: uint16(58), + 1408: uint16(165), + 1409: uint16(314), + 1410: uint16(315), + 1411: uint16(276), + 1412: uint16(43), + 1413: uint16(44), + 1414: uint16(45), + 1415: uint16(266), + 1416: uint16(47), + 1417: uint16(48), + 1418: uint16(49), + 1419: uint16(50), + 1420: uint16(51), + 1421: uint16(52), + 1422: uint16(53), + 1423: uint16(54), + 1424: uint16(55), + 1425: uint16(56), + 1426: uint16(57), + 1427: uint16(58), + 1428: uint16(128), + 1429: uint16(129), + 1430: uint16(130), + 1431: uint16(195), + 1432: uint16(103), + 1433: uint16(104), + 1434: uint16(105), + 1435: uint16(106), + 1436: uint16(107), + 1437: uint16(108), + 1438: uint16(109), + 1439: uint16(110), + 1440: uint16(111), + 1441: uint16(112), + 1442: uint16(113), + 1443: uint16(114), + 1444: uint16(195), + 1445: uint16(228), + 1446: uint16(195), + 1447: uint16(61), + 1448: uint16(195), + 1449: uint16(314), + 1450: uint16(315), + 1451: uint16(25), + 1452: uint16(103), + 1453: uint16(104), + 1454: uint16(105), + 1455: uint16(106), + 1456: uint16(107), + 1457: uint16(108), + 1458: uint16(109), + 1459: uint16(110), + 1460: uint16(111), + 1461: uint16(112), + 1462: uint16(113), + 1463: uint16(114), + 1464: uint16(195), + 1465: uint16(22), + 1466: uint16(195), + 1467: uint16(218), + 1468: uint16(219), + 1469: uint16(218), + 1470: uint16(219), + 1471: uint16(195), + 1472: uint16(103), + 1473: uint16(104), + 1474: uint16(105), + 1475: uint16(106), + 1476: uint16(107), + 1477: uint16(108), + 1478: uint16(109), + 1479: uint16(110), + 1480: uint16(111), + 1481: uint16(112), + 1482: uint16(113), + 1483: uint16(114), + 1484: uint16(195), + 1485: uint16(195), + 1486: uint16(246), + 1487: uint16(218), + 1488: uint16(219), + 1489: uint16(218), + 1490: uint16(219), + 1491: uint16(25), + 1492: uint16(19), + 1493: uint16(246), + 1494: uint16(218), + 1495: uint16(219), + 1496: uint16(246), + 1497: uint16(257), + 1498: uint16(259), + 1499: uint16(260), + 1500: uint16(195), + 1501: uint16(22), + 1502: uint16(266), + 1503: uint16(60), + 1504: uint16(257), + 1505: uint16(195), + 1506: uint16(120), + 1507: uint16(257), + 1508: uint16(218), + 1509: uint16(219), + 1510: uint16(116), + 1511: uint16(195), + 1512: uint16(19), + 1513: uint16(195), + 1514: uint16(150), + 1515: uint16(151), + 1516: uint16(25), + 1517: uint16(44), + 1518: uint16(45), + 1519: uint16(266), + 1520: uint16(47), + 1521: uint16(48), + 1522: uint16(49), + 1523: uint16(50), + 1524: uint16(51), + 1525: uint16(52), + 1526: uint16(53), + 1527: uint16(54), + 1528: uint16(55), + 1529: uint16(56), + 1530: uint16(57), + 1531: uint16(58), + 1532: uint16(195), + 1533: uint16(54), + 1534: uint16(218), + 1535: uint16(219), + 1536: uint16(218), + 1537: uint16(219), + 1538: uint16(45), + 1539: uint16(145), + 1540: uint16(47), + 1541: uint16(48), + 1542: uint16(49), + 1543: uint16(50), + 1544: uint16(51), + 1545: uint16(52), + 1546: uint16(53), + 1547: uint16(54), + 1548: uint16(55), + 1549: uint16(56), + 1550: uint16(57), + 1551: uint16(58), + 1552: uint16(246), + 1553: uint16(121), + 1554: uint16(122), + 1555: uint16(218), + 1556: uint16(219), + 1557: uint16(19), + 1558: uint16(23), + 1559: uint16(31), + 1560: uint16(25), + 1561: uint16(118), + 1562: uint16(159), + 1563: uint16(257), + 1564: uint16(161), + 1565: uint16(24), + 1566: uint16(195), + 1567: uint16(39), + 1568: uint16(195), + 1569: uint16(143), + 1570: uint16(195), + 1571: uint16(19), + 1572: uint16(20), + 1573: uint16(22), + 1574: uint16(22), + 1575: uint16(24), + 1576: uint16(103), + 1577: uint16(104), + 1578: uint16(105), + 1579: uint16(106), + 1580: uint16(107), + 1581: uint16(108), + 1582: uint16(109), + 1583: uint16(110), + 1584: uint16(111), + 1585: uint16(112), + 1586: uint16(113), + 1587: uint16(114), + 1588: uint16(36), + 1589: uint16(218), + 1590: uint16(219), + 1591: uint16(218), + 1592: uint16(219), + 1593: uint16(218), + 1594: uint16(219), + 1595: uint16(195), + 1596: uint16(103), + 1597: uint16(104), + 1598: uint16(105), + 1599: uint16(106), + 1600: uint16(107), + 1601: uint16(108), + 1602: uint16(109), + 1603: uint16(110), + 1604: uint16(111), + 1605: uint16(112), + 1606: uint16(113), + 1607: uint16(114), + 1608: uint16(195), + 1609: uint16(143), + 1610: uint16(119), + 1611: uint16(136), + 1612: uint16(60), + 1613: uint16(195), + 1614: uint16(22), + 1615: uint16(195), + 1616: uint16(141), + 1617: uint16(195), + 1618: uint16(218), + 1619: uint16(219), + 1620: uint16(195), + 1621: uint16(23), + 1622: uint16(195), + 1623: uint16(25), + 1624: uint16(72), + 1625: uint16(23), + 1626: uint16(131), + 1627: uint16(25), + 1628: uint16(195), + 1629: uint16(134), + 1630: uint16(23), + 1631: uint16(218), + 1632: uint16(219), + 1633: uint16(195), + 1634: uint16(82), + 1635: uint16(144), + 1636: uint16(218), + 1637: uint16(219), + 1638: uint16(218), + 1639: uint16(219), + 1640: uint16(218), + 1641: uint16(219), + 1642: uint16(195), + 1643: uint16(218), + 1644: uint16(219), + 1645: uint16(218), + 1646: uint16(219), + 1647: uint16(60), + 1648: uint16(23), + 1649: uint16(195), + 1650: uint16(25), + 1651: uint16(218), + 1652: uint16(219), + 1653: uint16(101), + 1654: uint16(195), + 1655: uint16(117), + 1656: uint16(218), + 1657: uint16(219), + 1658: uint16(195), + 1659: uint16(107), + 1660: uint16(108), + 1661: uint16(23), + 1662: uint16(195), + 1663: uint16(25), + 1664: uint16(195), + 1665: uint16(218), + 1666: uint16(219), + 1667: uint16(115), + 1668: uint16(228), + 1669: uint16(117), + 1670: uint16(118), + 1671: uint16(119), + 1672: uint16(218), + 1673: uint16(219), + 1674: uint16(122), + 1675: uint16(195), + 1676: uint16(19), + 1677: uint16(218), + 1678: uint16(219), + 1679: uint16(195), + 1680: uint16(60), + 1681: uint16(218), + 1682: uint16(219), + 1683: uint16(142), + 1684: uint16(195), + 1685: uint16(218), + 1686: uint16(219), + 1687: uint16(19), + 1688: uint16(20), + 1689: uint16(195), + 1690: uint16(22), + 1691: uint16(139), + 1692: uint16(140), + 1693: uint16(23), + 1694: uint16(23), + 1695: uint16(25), + 1696: uint16(25), + 1697: uint16(195), + 1698: uint16(218), + 1699: uint16(219), + 1700: uint16(7), + 1701: uint16(8), + 1702: uint16(218), + 1703: uint16(219), + 1704: uint16(36), + 1705: uint16(118), + 1706: uint16(154), + 1707: uint16(155), + 1708: uint16(156), + 1709: uint16(157), + 1710: uint16(158), + 1711: uint16(195), + 1712: uint16(23), + 1713: uint16(195), + 1714: uint16(25), + 1715: uint16(84), + 1716: uint16(85), + 1717: uint16(49), + 1718: uint16(195), + 1719: uint16(23), + 1720: uint16(195), + 1721: uint16(25), + 1722: uint16(195), + 1723: uint16(23), + 1724: uint16(195), + 1725: uint16(25), + 1726: uint16(195), + 1727: uint16(23), + 1728: uint16(60), + 1729: uint16(25), + 1730: uint16(23), + 1731: uint16(23), + 1732: uint16(25), + 1733: uint16(25), + 1734: uint16(142), + 1735: uint16(183), + 1736: uint16(218), + 1737: uint16(219), + 1738: uint16(118), + 1739: uint16(195), + 1740: uint16(72), + 1741: uint16(218), + 1742: uint16(219), + 1743: uint16(218), + 1744: uint16(219), + 1745: uint16(218), + 1746: uint16(219), + 1747: uint16(218), + 1748: uint16(219), + 1749: uint16(218), + 1750: uint16(219), + 1751: uint16(195), + 1752: uint16(195), + 1753: uint16(146), + 1754: uint16(86), + 1755: uint16(98), + 1756: uint16(23), + 1757: uint16(195), + 1758: uint16(25), + 1759: uint16(91), + 1760: uint16(19), + 1761: uint16(20), + 1762: uint16(154), + 1763: uint16(22), + 1764: uint16(156), + 1765: uint16(154), + 1766: uint16(23), + 1767: uint16(156), + 1768: uint16(25), + 1769: uint16(101), + 1770: uint16(23), + 1771: uint16(195), + 1772: uint16(25), + 1773: uint16(195), + 1774: uint16(195), + 1775: uint16(107), + 1776: uint16(108), + 1777: uint16(36), + 1778: uint16(195), + 1779: uint16(195), + 1780: uint16(195), + 1781: uint16(195), + 1782: uint16(228), + 1783: uint16(115), + 1784: uint16(195), + 1785: uint16(117), + 1786: uint16(118), + 1787: uint16(119), + 1788: uint16(195), + 1789: uint16(195), + 1790: uint16(122), + 1791: uint16(261), + 1792: uint16(195), + 1793: uint16(321), + 1794: uint16(195), + 1795: uint16(195), + 1796: uint16(195), + 1797: uint16(258), + 1798: uint16(238), + 1799: uint16(195), + 1800: uint16(195), + 1801: uint16(60), + 1802: uint16(299), + 1803: uint16(291), + 1804: uint16(195), + 1805: uint16(195), + 1806: uint16(258), + 1807: uint16(195), + 1808: uint16(195), + 1809: uint16(195), + 1810: uint16(290), + 1811: uint16(244), + 1812: uint16(216), + 1813: uint16(72), + 1814: uint16(245), + 1815: uint16(193), + 1816: uint16(258), + 1817: uint16(258), + 1818: uint16(299), + 1819: uint16(258), + 1820: uint16(299), + 1821: uint16(274), + 1822: uint16(154), + 1823: uint16(155), + 1824: uint16(156), + 1825: uint16(157), + 1826: uint16(158), + 1827: uint16(86), + 1828: uint16(247), + 1829: uint16(295), + 1830: uint16(248), + 1831: uint16(295), + 1832: uint16(91), + 1833: uint16(19), + 1834: uint16(20), + 1835: uint16(270), + 1836: uint16(22), + 1837: uint16(274), + 1838: uint16(270), + 1839: uint16(248), + 1840: uint16(274), + 1841: uint16(222), + 1842: uint16(101), + 1843: uint16(227), + 1844: uint16(274), + 1845: uint16(221), + 1846: uint16(231), + 1847: uint16(221), + 1848: uint16(107), + 1849: uint16(108), + 1850: uint16(36), + 1851: uint16(183), + 1852: uint16(262), + 1853: uint16(247), + 1854: uint16(221), + 1855: uint16(283), + 1856: uint16(115), + 1857: uint16(262), + 1858: uint16(117), + 1859: uint16(118), + 1860: uint16(119), + 1861: uint16(198), + 1862: uint16(116), + 1863: uint16(122), + 1864: uint16(220), + 1865: uint16(262), + 1866: uint16(61), + 1867: uint16(220), + 1868: uint16(220), + 1869: uint16(251), + 1870: uint16(247), + 1871: uint16(142), + 1872: uint16(251), + 1873: uint16(245), + 1874: uint16(60), + 1875: uint16(202), + 1876: uint16(299), + 1877: uint16(202), + 1878: uint16(38), + 1879: uint16(262), + 1880: uint16(202), + 1881: uint16(22), + 1882: uint16(152), + 1883: uint16(151), + 1884: uint16(296), + 1885: uint16(43), + 1886: uint16(72), + 1887: uint16(236), + 1888: uint16(18), + 1889: uint16(239), + 1890: uint16(202), + 1891: uint16(239), + 1892: uint16(239), + 1893: uint16(239), + 1894: uint16(18), + 1895: uint16(154), + 1896: uint16(155), + 1897: uint16(156), + 1898: uint16(157), + 1899: uint16(158), + 1900: uint16(86), + 1901: uint16(150), + 1902: uint16(201), + 1903: uint16(248), + 1904: uint16(275), + 1905: uint16(91), + 1906: uint16(248), + 1907: uint16(273), + 1908: uint16(236), + 1909: uint16(248), + 1910: uint16(275), + 1911: uint16(275), + 1912: uint16(273), + 1913: uint16(236), + 1914: uint16(248), + 1915: uint16(101), + 1916: uint16(286), + 1917: uint16(202), + 1918: uint16(201), + 1919: uint16(159), + 1920: uint16(63), + 1921: uint16(107), + 1922: uint16(108), + 1923: uint16(296), + 1924: uint16(183), + 1925: uint16(293), + 1926: uint16(202), + 1927: uint16(201), + 1928: uint16(22), + 1929: uint16(115), + 1930: uint16(202), + 1931: uint16(117), + 1932: uint16(118), + 1933: uint16(119), + 1934: uint16(292), + 1935: uint16(223), + 1936: uint16(122), + 1937: uint16(201), + 1938: uint16(65), + 1939: uint16(202), + 1940: uint16(201), + 1941: uint16(223), + 1942: uint16(220), + 1943: uint16(220), + 1944: uint16(22), + 1945: uint16(220), + 1946: uint16(226), + 1947: uint16(226), + 1948: uint16(229), + 1949: uint16(127), + 1950: uint16(223), + 1951: uint16(220), + 1952: uint16(166), + 1953: uint16(24), + 1954: uint16(285), + 1955: uint16(220), + 1956: uint16(222), + 1957: uint16(114), + 1958: uint16(315), + 1959: uint16(285), + 1960: uint16(220), + 1961: uint16(202), + 1962: uint16(220), + 1963: uint16(307), + 1964: uint16(92), + 1965: uint16(320), + 1966: uint16(320), + 1967: uint16(229), + 1968: uint16(154), + 1969: uint16(155), + 1970: uint16(156), + 1971: uint16(157), + 1972: uint16(158), + 1974: uint16(1), + 1975: uint16(2), + 1976: uint16(223), + 1977: uint16(83), + 1978: uint16(5), + 1979: uint16(268), + 1980: uint16(149), + 1981: uint16(268), + 1982: uint16(146), + 1983: uint16(10), + 1984: uint16(11), + 1985: uint16(12), + 1986: uint16(13), + 1987: uint16(14), + 1988: uint16(22), + 1989: uint16(280), + 1990: uint16(17), + 1991: uint16(202), + 1992: uint16(159), + 1993: uint16(19), + 1994: uint16(20), + 1995: uint16(251), + 1996: uint16(22), + 1997: uint16(183), + 1998: uint16(282), + 1999: uint16(148), + 2000: uint16(252), + 2001: uint16(252), + 2002: uint16(250), + 2003: uint16(30), + 2004: uint16(249), + 2005: uint16(32), + 2006: uint16(248), + 2007: uint16(147), + 2008: uint16(25), + 2009: uint16(13), + 2010: uint16(36), + 2011: uint16(204), + 2012: uint16(196), + 2013: uint16(40), + 2014: uint16(196), + 2015: uint16(6), + 2016: uint16(302), + 2017: uint16(194), + 2018: uint16(194), + 2019: uint16(194), + 2020: uint16(209), + 2021: uint16(215), + 2022: uint16(209), + 2023: uint16(215), + 2024: uint16(215), + 2025: uint16(215), + 2026: uint16(224), + 2027: uint16(224), + 2028: uint16(216), + 2029: uint16(209), + 2030: uint16(4), + 2031: uint16(216), + 2032: uint16(215), + 2033: uint16(3), + 2034: uint16(60), + 2035: uint16(22), + 2036: uint16(122), + 2037: uint16(19), + 2038: uint16(122), + 2039: uint16(19), + 2040: uint16(125), + 2041: uint16(22), + 2042: uint16(15), + 2043: uint16(22), + 2044: uint16(71), + 2045: uint16(16), + 2046: uint16(72), + 2047: uint16(23), + 2048: uint16(23), + 2049: uint16(140), + 2050: uint16(305), + 2051: uint16(152), + 2052: uint16(79), + 2053: uint16(25), + 2054: uint16(131), + 2055: uint16(82), + 2056: uint16(143), + 2057: uint16(20), + 2058: uint16(16), + 2059: uint16(305), + 2060: uint16(1), + 2061: uint16(143), + 2062: uint16(145), + 2063: uint16(131), + 2064: uint16(131), + 2065: uint16(62), + 2066: uint16(54), + 2067: uint16(131), + 2068: uint16(37), + 2069: uint16(54), + 2070: uint16(54), + 2071: uint16(152), + 2072: uint16(99), + 2073: uint16(117), + 2074: uint16(34), + 2075: uint16(101), + 2076: uint16(54), + 2077: uint16(24), + 2078: uint16(1), + 2079: uint16(5), + 2080: uint16(22), + 2081: uint16(107), + 2082: uint16(108), + 2083: uint16(116), + 2084: uint16(76), + 2085: uint16(25), + 2086: uint16(162), + 2087: uint16(41), + 2088: uint16(142), + 2089: uint16(115), + 2090: uint16(24), + 2091: uint16(117), + 2092: uint16(118), + 2093: uint16(119), + 2094: uint16(116), + 2095: uint16(20), + 2096: uint16(122), + 2097: uint16(19), + 2098: uint16(126), + 2099: uint16(23), + 2100: uint16(132), + 2101: uint16(19), + 2102: uint16(20), + 2103: uint16(69), + 2104: uint16(22), + 2105: uint16(69), + 2106: uint16(22), + 2107: uint16(134), + 2108: uint16(22), + 2109: uint16(68), + 2110: uint16(22), + 2111: uint16(22), + 2112: uint16(139), + 2113: uint16(140), + 2114: uint16(60), + 2115: uint16(141), + 2116: uint16(68), + 2117: uint16(24), + 2118: uint16(36), + 2119: uint16(28), + 2120: uint16(97), + 2121: uint16(22), + 2122: uint16(37), + 2123: uint16(68), + 2124: uint16(23), + 2125: uint16(150), + 2126: uint16(34), + 2127: uint16(22), + 2128: uint16(154), + 2129: uint16(155), + 2130: uint16(156), + 2131: uint16(157), + 2132: uint16(158), + 2133: uint16(23), + 2134: uint16(23), + 2135: uint16(22), + 2136: uint16(163), + 2137: uint16(25), + 2138: uint16(23), + 2139: uint16(142), + 2140: uint16(23), + 2141: uint16(98), + 2142: uint16(60), + 2143: uint16(23), + 2144: uint16(22), + 2145: uint16(144), + 2146: uint16(25), + 2147: uint16(76), + 2148: uint16(34), + 2149: uint16(117), + 2150: uint16(34), + 2151: uint16(89), + 2152: uint16(34), + 2153: uint16(34), + 2154: uint16(72), + 2155: uint16(87), + 2156: uint16(76), + 2157: uint16(183), + 2158: uint16(34), + 2159: uint16(94), + 2160: uint16(34), + 2161: uint16(23), + 2162: uint16(22), + 2163: uint16(24), + 2164: uint16(34), + 2165: uint16(23), + 2166: uint16(25), + 2167: uint16(44), + 2168: uint16(25), + 2169: uint16(23), + 2170: uint16(23), + 2171: uint16(23), + 2172: uint16(22), + 2173: uint16(22), + 2174: uint16(25), + 2175: uint16(11), + 2176: uint16(143), + 2177: uint16(25), + 2178: uint16(143), + 2179: uint16(23), + 2180: uint16(22), + 2181: uint16(22), + 2182: uint16(22), + 2183: uint16(101), + 2184: uint16(23), + 2185: uint16(23), + 2186: uint16(136), + 2187: uint16(22), + 2188: uint16(25), + 2189: uint16(107), + 2190: uint16(108), + 2191: uint16(142), + 2192: uint16(25), + 2193: uint16(142), + 2194: uint16(142), + 2195: uint16(23), + 2196: uint16(15), + 2197: uint16(115), + 2198: uint16(1), + 2199: uint16(117), + 2200: uint16(118), + 2201: uint16(119), + 2202: uint16(1), + 2203: uint16(2), + 2204: uint16(122), + 2205: uint16(1), + 2206: uint16(5), + 2207: uint16(322), + 2208: uint16(322), + 2209: uint16(322), + 2210: uint16(322), + 2211: uint16(10), + 2212: uint16(11), + 2213: uint16(12), + 2214: uint16(13), + 2215: uint16(14), + 2216: uint16(322), + 2217: uint16(322), + 2218: uint16(17), + 2219: uint16(322), + 2220: uint16(5), + 2221: uint16(322), + 2222: uint16(322), + 2223: uint16(141), + 2224: uint16(322), + 2225: uint16(10), + 2226: uint16(11), + 2227: uint16(12), + 2228: uint16(13), + 2229: uint16(14), + 2230: uint16(322), + 2231: uint16(30), + 2232: uint16(17), + 2233: uint16(32), + 2234: uint16(322), + 2235: uint16(322), + 2236: uint16(154), + 2237: uint16(155), + 2238: uint16(156), + 2239: uint16(157), + 2240: uint16(158), + 2241: uint16(40), + 2242: uint16(322), + 2243: uint16(322), + 2244: uint16(322), + 2245: uint16(30), + 2246: uint16(322), + 2247: uint16(32), + 2248: uint16(322), + 2249: uint16(322), + 2250: uint16(322), + 2251: uint16(322), + 2252: uint16(322), + 2253: uint16(322), + 2254: uint16(322), + 2255: uint16(40), + 2256: uint16(322), + 2257: uint16(322), + 2258: uint16(322), + 2259: uint16(322), + 2260: uint16(322), + 2261: uint16(322), + 2262: uint16(322), + 2263: uint16(322), + 2264: uint16(322), + 2265: uint16(183), + 2266: uint16(322), + 2267: uint16(322), + 2268: uint16(322), + 2269: uint16(322), + 2270: uint16(322), + 2271: uint16(322), + 2272: uint16(71), + 2273: uint16(322), + 2274: uint16(322), + 2275: uint16(322), + 2276: uint16(322), + 2277: uint16(322), + 2278: uint16(322), + 2279: uint16(322), + 2280: uint16(79), + 2281: uint16(322), + 2282: uint16(322), + 2283: uint16(82), + 2284: uint16(322), + 2285: uint16(322), + 2286: uint16(71), + 2287: uint16(322), + 2288: uint16(322), + 2289: uint16(322), + 2290: uint16(322), + 2291: uint16(322), + 2292: uint16(322), + 2293: uint16(322), + 2294: uint16(79), + 2295: uint16(322), + 2296: uint16(322), + 2297: uint16(82), + 2298: uint16(322), + 2299: uint16(322), + 2300: uint16(99), + 2301: uint16(322), + 2302: uint16(322), + 2303: uint16(322), + 2304: uint16(322), + 2305: uint16(322), + 2306: uint16(322), + 2307: uint16(322), + 2308: uint16(322), + 2309: uint16(322), + 2310: uint16(322), + 2311: uint16(322), + 2312: uint16(322), + 2313: uint16(322), + 2314: uint16(99), + 2315: uint16(322), + 2316: uint16(322), + 2317: uint16(322), + 2318: uint16(322), + 2319: uint16(322), + 2320: uint16(322), + 2321: uint16(322), + 2322: uint16(322), + 2323: uint16(322), + 2324: uint16(322), + 2325: uint16(322), + 2326: uint16(322), + 2327: uint16(322), + 2328: uint16(322), + 2329: uint16(322), + 2330: uint16(322), + 2331: uint16(322), + 2332: uint16(322), + 2333: uint16(322), + 2334: uint16(322), + 2335: uint16(134), + 2336: uint16(322), + 2337: uint16(322), + 2338: uint16(322), + 2339: uint16(322), + 2340: uint16(139), + 2341: uint16(140), + 2342: uint16(322), + 2343: uint16(322), + 2344: uint16(322), + 2345: uint16(322), + 2346: uint16(322), + 2347: uint16(322), + 2348: uint16(322), + 2349: uint16(134), + 2350: uint16(322), + 2351: uint16(322), + 2352: uint16(322), + 2353: uint16(322), + 2354: uint16(139), + 2355: uint16(140), + 2356: uint16(322), + 2357: uint16(322), + 2358: uint16(322), + 2359: uint16(322), + 2360: uint16(322), + 2361: uint16(322), + 2362: uint16(322), + 2363: uint16(322), + 2364: uint16(163), + 2365: uint16(322), + 2366: uint16(322), + 2367: uint16(322), + 2368: uint16(322), + 2369: uint16(322), + 2370: uint16(322), + 2371: uint16(322), + 2372: uint16(322), + 2373: uint16(322), + 2374: uint16(322), + 2375: uint16(322), + 2376: uint16(322), + 2377: uint16(322), + 2378: uint16(163), + 2379: uint16(322), + 2380: uint16(322), + 2381: uint16(322), + 2382: uint16(322), + 2383: uint16(322), + 2384: uint16(322), + 2385: uint16(322), + 2386: uint16(322), + 2387: uint16(322), + 2388: uint16(322), + 2389: uint16(322), + 2390: uint16(322), + 2391: uint16(322), + 2392: uint16(322), + 2393: uint16(322), + 2394: uint16(322), + 2395: uint16(322), + 2396: uint16(322), + 2397: uint16(322), + 2398: uint16(322), + 2399: uint16(322), + 2400: uint16(322), + 2401: uint16(322), + 2402: uint16(322), + 2403: uint16(322), + 2404: uint16(322), + 2405: uint16(322), + 2406: uint16(322), + 2407: uint16(322), + 2408: uint16(187), + 2409: uint16(187), + 2410: uint16(187), + 2411: uint16(187), + 2412: uint16(187), + 2413: uint16(187), + 2414: uint16(187), + 2415: uint16(187), + 2416: uint16(187), + 2417: uint16(187), + 2418: uint16(187), + 2419: uint16(187), + 2420: uint16(187), + 2421: uint16(187), + 2422: uint16(187), + 2423: uint16(187), + 2424: uint16(187), + 2425: uint16(187), + 2426: uint16(187), + 2427: uint16(187), + 2428: uint16(187), + 2429: uint16(187), + 2430: uint16(187), + 2431: uint16(187), + 2432: uint16(187), + 2433: uint16(187), + 2434: uint16(187), + 2435: uint16(187), + 2436: uint16(187), + 2437: uint16(187), + 2438: uint16(187), + 2439: uint16(187), + 2440: uint16(187), + 2441: uint16(187), + 2442: uint16(187), + 2443: uint16(187), + 2444: uint16(187), + 2445: uint16(187), + 2446: uint16(187), + 2447: uint16(187), + 2448: uint16(187), + 2449: uint16(187), + 2450: uint16(187), + 2451: uint16(187), + 2452: uint16(187), + 2453: uint16(187), + 2454: uint16(187), + 2455: uint16(187), + 2456: uint16(187), + 2457: uint16(187), + 2458: uint16(187), + 2459: uint16(187), + 2460: uint16(187), + 2461: uint16(187), + 2462: uint16(187), + 2463: uint16(187), + 2464: uint16(187), + 2465: uint16(187), + 2466: uint16(187), + 2467: uint16(187), + 2468: uint16(187), + 2469: uint16(187), + 2470: uint16(187), + 2471: uint16(187), + 2472: uint16(187), + 2473: uint16(187), + 2474: uint16(187), + 2475: uint16(187), + 2476: uint16(187), + 2477: uint16(187), + 2478: uint16(187), + 2479: uint16(187), + 2480: uint16(187), + 2481: uint16(187), + 2482: uint16(187), + 2483: uint16(187), + 2484: uint16(187), + 2485: uint16(187), + 2486: uint16(187), + 2487: uint16(187), + 2488: uint16(187), + 2489: uint16(187), + 2490: uint16(187), + 2491: uint16(187), + 2492: uint16(187), + 2493: uint16(187), + 2494: uint16(187), + 2495: uint16(187), + 2496: uint16(187), + 2497: uint16(187), + 2498: uint16(187), + 2499: uint16(187), + 2500: uint16(187), + 2501: uint16(187), + 2502: uint16(187), + 2503: uint16(187), + 2504: uint16(187), + 2505: uint16(187), + 2506: uint16(187), + 2507: uint16(187), + 2508: uint16(187), + 2509: uint16(187), + 2510: uint16(187), + 2511: uint16(187), + 2512: uint16(187), + 2513: uint16(187), + 2514: uint16(187), + 2515: uint16(187), + 2516: uint16(187), + 2517: uint16(187), + 2518: uint16(187), + 2519: uint16(187), + 2520: uint16(187), + 2521: uint16(187), + 2522: uint16(187), + 2523: uint16(187), + 2524: uint16(187), + 2525: uint16(187), + 2526: uint16(187), + 2527: uint16(187), + 2528: uint16(187), + 2529: uint16(187), + 2530: uint16(187), + 2531: uint16(187), + 2532: uint16(187), + 2533: uint16(187), + 2534: uint16(187), + 2535: uint16(187), + 2536: uint16(187), + 2537: uint16(187), + 2538: uint16(187), + 2539: uint16(187), + 2540: uint16(187), + 2541: uint16(187), + 2542: uint16(187), + 2543: uint16(187), + 2544: uint16(187), + 2545: uint16(187), + 2546: uint16(187), + 2547: uint16(187), + 2548: uint16(187), + 2549: uint16(187), + 2550: uint16(187), + 2551: uint16(187), + 2552: uint16(187), + 2553: uint16(187), + 2554: uint16(187), + 2555: uint16(187), + 2556: uint16(187), + 2557: uint16(187), + 2558: uint16(187), + 2559: uint16(187), + 2560: uint16(187), + 2561: uint16(187), + 2562: uint16(187), + 2563: uint16(187), + 2564: uint16(187), + 2565: uint16(187), +} + +var _yy_reduce_ofst = [424]int16{ + 0: int16(-int32(67)), + 1: int16(345), + 2: int16(-int32(64)), + 3: int16(-int32(178)), + 4: int16(-int32(181)), + 5: int16(143), + 6: int16(435), + 7: int16(-int32(78)), + 8: int16(-int32(183)), + 9: int16(163), + 10: int16(-int32(185)), + 11: int16(284), + 12: int16(384), + 13: int16(-int32(174)), + 14: int16(189), + 15: int16(352), + 16: int16(440), + 17: int16(444), + 18: int16(493), + 19: int16(-int32(23)), + 20: int16(227), + 21: int16(-int32(277)), + 22: int16(-int32(1)), + 23: int16(305), + 24: int16(561), + 25: int16(755), + 26: int16(759), + 27: int16(764), + 28: int16(-int32(189)), + 29: int16(839), + 30: int16(857), + 31: int16(354), + 32: int16(484), + 33: int16(859), + 34: int16(631), + 35: int16(67), + 36: int16(734), + 37: int16(780), + 38: int16(-int32(187)), + 39: int16(616), + 40: int16(581), + 41: int16(730), + 42: int16(891), + 43: int16(449), + 44: int16(588), + 45: int16(795), + 46: int16(836), + 47: int16(-int32(238)), + 48: int16(287), + 49: int16(-int32(238)), + 50: int16(287), + 51: int16(-int32(256)), + 52: int16(-int32(256)), + 53: int16(-int32(256)), + 54: int16(-int32(256)), + 55: int16(-int32(256)), + 56: int16(-int32(256)), + 57: int16(-int32(256)), + 58: int16(-int32(256)), + 59: int16(-int32(256)), + 60: int16(-int32(256)), + 61: int16(-int32(256)), + 62: int16(-int32(256)), + 63: int16(-int32(256)), + 64: int16(-int32(256)), + 65: int16(-int32(256)), + 66: int16(-int32(256)), + 67: int16(-int32(256)), + 68: int16(-int32(256)), + 69: int16(-int32(256)), + 70: int16(-int32(256)), + 71: int16(-int32(256)), + 72: int16(-int32(256)), + 73: int16(-int32(256)), + 74: int16(-int32(256)), + 75: int16(-int32(256)), + 76: int16(-int32(256)), + 77: int16(-int32(256)), + 78: int16(-int32(256)), + 79: int16(-int32(256)), + 80: int16(-int32(256)), + 81: int16(-int32(256)), + 82: int16(-int32(256)), + 83: int16(-int32(256)), + 84: int16(-int32(256)), + 85: int16(-int32(256)), + 86: int16(-int32(256)), + 87: int16(-int32(256)), + 88: int16(-int32(256)), + 89: int16(-int32(256)), + 90: int16(-int32(256)), + 91: int16(205), + 92: int16(582), + 93: int16(715), + 94: int16(958), + 95: int16(985), + 96: int16(1003), + 97: int16(1005), + 98: int16(1010), + 99: int16(1012), + 100: int16(1059), + 101: int16(1066), + 102: int16(1092), + 103: int16(1094), + 104: int16(1097), + 105: int16(1122), + 106: int16(1137), + 107: int16(1141), + 108: int16(1143), + 109: int16(1147), + 110: int16(1151), + 111: int16(1172), + 112: int16(1249), + 113: int16(1251), + 114: int16(1269), + 115: int16(1271), + 116: int16(1276), + 117: int16(1290), + 118: int16(1316), + 119: int16(1318), + 120: int16(1337), + 121: int16(1371), + 122: int16(1373), + 123: int16(1375), + 124: int16(1400), + 125: int16(1413), + 126: int16(1418), + 127: int16(1420), + 128: int16(1422), + 129: int16(1425), + 130: int16(1427), + 131: int16(1433), + 132: int16(1438), + 133: int16(1447), + 134: int16(1454), + 135: int16(1459), + 136: int16(1463), + 137: int16(1467), + 138: int16(1480), + 139: int16(1484), + 140: int16(1518), + 141: int16(1523), + 142: int16(1525), + 143: int16(1527), + 144: int16(1529), + 145: int16(1531), + 146: int16(-int32(256)), + 147: int16(-int32(256)), + 148: int16(-int32(256)), + 149: int16(-int32(256)), + 150: int16(-int32(256)), + 151: int16(-int32(256)), + 152: int16(-int32(256)), + 153: int16(-int32(256)), + 154: int16(-int32(256)), + 155: int16(-int32(256)), + 156: int16(-int32(256)), + 157: int16(155), + 158: int16(210), + 159: int16(-int32(220)), + 160: int16(86), + 161: int16(-int32(130)), + 162: int16(943), + 163: int16(996), + 164: int16(402), + 165: int16(-int32(256)), + 166: int16(-int32(113)), + 167: int16(981), + 168: int16(1095), + 169: int16(1135), + 170: int16(395), + 171: int16(-int32(256)), + 172: int16(-int32(256)), + 173: int16(-int32(256)), + 174: int16(-int32(256)), + 175: int16(568), + 176: int16(568), + 177: int16(568), + 178: int16(-int32(4)), + 179: int16(-int32(153)), + 180: int16(-int32(133)), + 181: int16(259), + 182: int16(306), + 183: int16(-int32(166)), + 184: int16(523), + 185: int16(-int32(303)), + 186: int16(-int32(126)), + 187: int16(503), + 188: int16(503), + 189: int16(-int32(37)), + 190: int16(-int32(149)), + 191: int16(164), + 192: int16(690), + 193: int16(292), + 194: int16(412), + 195: int16(492), + 196: int16(651), + 197: int16(784), + 198: int16(332), + 199: int16(786), + 200: int16(841), + 201: int16(1149), + 202: int16(833), + 203: int16(1236), + 204: int16(792), + 205: int16(162), + 206: int16(796), + 207: int16(1253), + 208: int16(777), + 209: int16(288), + 210: int16(381), + 211: int16(380), + 212: int16(709), + 213: int16(487), + 214: int16(1027), + 215: int16(972), + 216: int16(1030), + 217: int16(1084), + 218: int16(991), + 219: int16(1120), + 220: int16(-int32(152)), + 221: int16(1062), + 222: int16(692), + 223: int16(1240), + 224: int16(1247), + 225: int16(1250), + 226: int16(1239), + 227: int16(1306), + 228: int16(-int32(207)), + 229: int16(-int32(194)), + 230: int16(57), + 231: int16(180), + 232: int16(74), + 233: int16(315), + 234: int16(355), + 235: int16(376), + 236: int16(452), + 237: int16(488), + 238: int16(630), + 239: int16(693), + 240: int16(965), + 241: int16(1004), + 242: int16(1025), + 243: int16(1099), + 244: int16(1154), + 245: int16(1289), + 246: int16(1305), + 247: int16(1310), + 248: int16(1469), + 249: int16(1489), + 250: int16(984), + 251: int16(1494), + 252: int16(1502), + 253: int16(1516), + 254: int16(1544), + 255: int16(1556), + 256: int16(1557), + 257: int16(1562), + 258: int16(1576), + 259: int16(1578), + 260: int16(1579), + 261: int16(1583), + 262: int16(1584), + 263: int16(1585), + 264: int16(1586), + 265: int16(1217), + 266: int16(1440), + 267: int16(1554), + 268: int16(1589), + 269: int16(1593), + 270: int16(1594), + 271: int16(1530), + 272: int16(1597), + 273: int16(1599), + 274: int16(1600), + 275: int16(1539), + 276: int16(1472), + 277: int16(1601), + 278: int16(1560), + 279: int16(1604), + 280: int16(355), + 281: int16(1605), + 282: int16(1609), + 283: int16(1610), + 284: int16(1612), + 285: int16(1613), + 286: int16(1614), + 287: int16(1503), + 288: int16(1512), + 289: int16(1520), + 290: int16(1567), + 291: int16(1548), + 292: int16(1558), + 293: int16(1559), + 294: int16(1561), + 295: int16(1530), + 296: int16(1567), + 297: int16(1567), + 298: int16(1569), + 299: int16(1596), + 300: int16(1622), + 301: int16(1519), + 302: int16(1521), + 303: int16(1547), + 304: int16(1565), + 305: int16(1581), + 306: int16(1568), + 307: int16(1534), + 308: int16(1582), + 309: int16(1563), + 310: int16(1566), + 311: int16(1591), + 312: int16(1570), + 313: int16(1606), + 314: int16(1536), + 315: int16(1619), + 316: int16(1615), + 317: int16(1616), + 318: int16(1624), + 319: int16(1626), + 320: int16(1633), + 321: int16(1590), + 322: int16(1595), + 323: int16(1603), + 324: int16(1617), + 325: int16(1618), + 326: int16(1621), + 327: int16(1572), + 328: int16(1623), + 329: int16(1628), + 330: int16(1663), + 331: int16(1644), + 332: int16(1577), + 333: int16(1647), + 334: int16(1648), + 335: int16(1673), + 336: int16(1675), + 337: int16(1588), + 338: int16(1627), + 339: int16(1678), + 340: int16(1630), + 341: int16(1629), + 342: int16(1634), + 343: int16(1651), + 344: int16(1650), + 345: int16(1652), + 346: int16(1653), + 347: int16(1654), + 348: int16(1688), + 349: int16(1701), + 350: int16(1655), + 351: int16(1635), + 352: int16(1636), + 353: int16(1658), + 354: int16(1639), + 355: int16(1672), + 356: int16(1661), + 357: int16(1677), + 358: int16(1666), + 359: int16(1715), + 360: int16(1717), + 361: int16(1632), + 362: int16(1642), + 363: int16(1724), + 364: int16(1726), + 365: int16(1712), + 366: int16(1728), + 367: int16(1736), + 368: int16(1737), + 369: int16(1739), + 370: int16(1718), + 371: int16(1722), + 372: int16(1723), + 373: int16(1725), + 374: int16(1719), + 375: int16(1720), + 376: int16(1721), + 377: int16(1727), + 378: int16(1731), + 379: int16(1734), + 380: int16(1735), + 381: int16(1738), + 382: int16(1740), + 383: int16(1742), + 384: int16(1643), + 385: int16(1656), + 386: int16(1669), + 387: int16(1674), + 388: int16(1753), + 389: int16(1759), + 390: int16(1645), + 391: int16(1646), + 392: int16(1711), + 393: int16(1713), + 394: int16(1748), + 395: int16(1744), + 396: int16(1709), + 397: int16(1789), + 398: int16(1716), + 399: int16(1749), + 400: int16(1752), + 401: int16(1755), + 402: int16(1758), + 403: int16(1807), + 404: int16(1816), + 405: int16(1818), + 406: int16(1823), + 407: int16(1824), + 408: int16(1825), + 409: int16(1745), + 410: int16(1754), + 411: int16(1714), + 412: int16(1811), + 413: int16(1806), + 414: int16(1808), + 415: int16(1809), + 416: int16(1810), + 417: int16(1813), + 418: int16(1802), + 419: int16(1803), + 420: int16(1812), + 421: int16(1815), + 422: int16(1817), + 423: int16(1820), +} + +var _yy_shift_ofst = [600]uint16{ + 0: uint16(2201), + 1: uint16(1973), + 2: uint16(2215), + 3: uint16(1552), + 4: uint16(1552), + 5: uint16(33), + 6: uint16(368), + 7: uint16(1668), + 8: uint16(1741), + 9: uint16(1814), + 10: uint16(726), + 11: uint16(726), + 12: uint16(726), + 13: uint16(265), + 14: uint16(33), + 15: uint16(33), + 16: uint16(33), + 17: uint16(33), + 18: uint16(33), + 21: uint16(216), + 22: uint16(1349), + 23: uint16(726), + 24: uint16(726), + 25: uint16(726), + 26: uint16(726), + 27: uint16(726), + 28: uint16(726), + 29: uint16(726), + 30: uint16(726), + 31: uint16(726), + 32: uint16(726), + 33: uint16(726), + 34: uint16(726), + 35: uint16(726), + 36: uint16(726), + 37: uint16(726), + 38: uint16(272), + 39: uint16(272), + 40: uint16(111), + 41: uint16(111), + 42: uint16(316), + 43: uint16(365), + 44: uint16(516), + 45: uint16(867), + 46: uint16(867), + 47: uint16(916), + 48: uint16(916), + 49: uint16(916), + 50: uint16(916), + 51: uint16(40), + 52: uint16(112), + 53: uint16(260), + 54: uint16(364), + 55: uint16(408), + 56: uint16(512), + 57: uint16(617), + 58: uint16(661), + 59: uint16(765), + 60: uint16(809), + 61: uint16(913), + 62: uint16(957), + 63: uint16(1061), + 64: uint16(1081), + 65: uint16(1195), + 66: uint16(1215), + 67: uint16(1329), + 68: uint16(1349), + 69: uint16(1349), + 70: uint16(1349), + 71: uint16(1349), + 72: uint16(1349), + 73: uint16(1349), + 74: uint16(1349), + 75: uint16(1349), + 76: uint16(1349), + 77: uint16(1349), + 78: uint16(1349), + 79: uint16(1349), + 80: uint16(1349), + 81: uint16(1349), + 82: uint16(1349), + 83: uint16(1349), + 84: uint16(1349), + 85: uint16(1349), + 86: uint16(1369), + 87: uint16(1349), + 88: uint16(1473), + 89: uint16(1493), + 90: uint16(1493), + 91: uint16(473), + 92: uint16(1974), + 93: uint16(2082), + 94: uint16(726), + 95: uint16(726), + 96: uint16(726), + 97: uint16(726), + 98: uint16(726), + 99: uint16(726), + 100: uint16(726), + 101: uint16(726), + 102: uint16(726), + 103: uint16(726), + 104: uint16(726), + 105: uint16(726), + 106: uint16(726), + 107: uint16(726), + 108: uint16(726), + 109: uint16(726), + 110: uint16(726), + 111: uint16(726), + 112: uint16(726), + 113: uint16(726), + 114: uint16(726), + 115: uint16(726), + 116: uint16(726), + 117: uint16(726), + 118: uint16(726), + 119: uint16(726), + 120: uint16(726), + 121: uint16(726), + 122: uint16(726), + 123: uint16(726), + 124: uint16(726), + 125: uint16(726), + 126: uint16(726), + 127: uint16(726), + 128: uint16(726), + 129: uint16(726), + 130: uint16(726), + 131: uint16(726), + 132: uint16(726), + 133: uint16(726), + 134: uint16(726), + 135: uint16(726), + 136: uint16(726), + 137: uint16(726), + 138: uint16(726), + 139: uint16(726), + 140: uint16(726), + 141: uint16(726), + 142: uint16(726), + 143: uint16(726), + 144: uint16(726), + 145: uint16(726), + 146: uint16(138), + 147: uint16(232), + 148: uint16(232), + 149: uint16(232), + 150: uint16(232), + 151: uint16(232), + 152: uint16(232), + 153: uint16(232), + 154: uint16(188), + 155: uint16(99), + 156: uint16(242), + 157: uint16(718), + 158: uint16(416), + 159: uint16(1159), + 160: uint16(867), + 161: uint16(867), + 162: uint16(940), + 163: uint16(940), + 164: uint16(867), + 165: uint16(1103), + 166: uint16(417), + 167: uint16(574), + 168: uint16(574), + 169: uint16(574), + 170: uint16(611), + 171: uint16(139), + 172: uint16(139), + 173: uint16(2379), + 174: uint16(2379), + 175: uint16(1026), + 176: uint16(1026), + 177: uint16(1026), + 178: uint16(536), + 179: uint16(466), + 180: uint16(466), + 181: uint16(466), + 182: uint16(466), + 183: uint16(1017), + 184: uint16(1017), + 185: uint16(849), + 186: uint16(718), + 187: uint16(971), + 188: uint16(1060), + 189: uint16(867), + 190: uint16(867), + 191: uint16(867), + 192: uint16(867), + 193: uint16(867), + 194: uint16(867), + 195: uint16(867), + 196: uint16(867), + 197: uint16(867), + 198: uint16(867), + 199: uint16(867), + 200: uint16(867), + 201: uint16(867), + 202: uint16(867), + 203: uint16(867), + 204: uint16(867), + 205: uint16(867), + 206: uint16(867), + 207: uint16(867), + 208: uint16(261), + 209: uint16(712), + 210: uint16(712), + 211: uint16(867), + 212: uint16(108), + 213: uint16(1142), + 214: uint16(1142), + 215: uint16(977), + 216: uint16(1108), + 217: uint16(1108), + 218: uint16(977), + 219: uint16(977), + 220: uint16(1243), + 221: uint16(2379), + 222: uint16(2379), + 223: uint16(2379), + 224: uint16(2379), + 225: uint16(2379), + 226: uint16(2379), + 227: uint16(2379), + 228: uint16(641), + 229: uint16(789), + 230: uint16(789), + 231: uint16(635), + 232: uint16(366), + 233: uint16(721), + 234: uint16(673), + 235: uint16(782), + 236: uint16(494), + 237: uint16(787), + 238: uint16(829), + 239: uint16(867), + 240: uint16(867), + 241: uint16(867), + 242: uint16(867), + 243: uint16(867), + 244: uint16(867), + 245: uint16(867), + 246: uint16(867), + 247: uint16(867), + 248: uint16(867), + 249: uint16(867), + 250: uint16(959), + 251: uint16(867), + 252: uint16(867), + 253: uint16(867), + 254: uint16(867), + 255: uint16(867), + 256: uint16(867), + 257: uint16(867), + 258: uint16(867), + 259: uint16(867), + 260: uint16(867), + 261: uint16(867), + 262: uint16(867), + 263: uint16(867), + 264: uint16(867), + 265: uint16(820), + 266: uint16(820), + 267: uint16(820), + 268: uint16(867), + 269: uint16(867), + 270: uint16(867), + 271: uint16(1136), + 272: uint16(867), + 273: uint16(867), + 274: uint16(867), + 275: uint16(1119), + 276: uint16(1007), + 277: uint16(867), + 278: uint16(1169), + 279: uint16(867), + 280: uint16(867), + 281: uint16(867), + 282: uint16(867), + 283: uint16(867), + 284: uint16(867), + 285: uint16(867), + 286: uint16(867), + 287: uint16(1225), + 288: uint16(1153), + 289: uint16(869), + 290: uint16(196), + 291: uint16(618), + 292: uint16(618), + 293: uint16(618), + 294: uint16(618), + 295: uint16(1491), + 296: uint16(196), + 297: uint16(196), + 298: uint16(91), + 299: uint16(339), + 300: uint16(1326), + 301: uint16(1386), + 302: uint16(383), + 303: uint16(1163), + 304: uint16(1364), + 305: uint16(1426), + 306: uint16(1364), + 307: uint16(1538), + 308: uint16(903), + 309: uint16(1163), + 310: uint16(1163), + 311: uint16(903), + 312: uint16(1163), + 313: uint16(1426), + 314: uint16(1538), + 315: uint16(1018), + 316: uint16(1535), + 317: uint16(1241), + 318: uint16(1528), + 319: uint16(1528), + 320: uint16(1528), + 321: uint16(1394), + 322: uint16(1394), + 323: uint16(1394), + 324: uint16(1394), + 325: uint16(762), + 326: uint16(762), + 327: uint16(1403), + 328: uint16(1466), + 329: uint16(1475), + 330: uint16(1551), + 331: uint16(1746), + 332: uint16(1805), + 333: uint16(1746), + 334: uint16(1746), + 335: uint16(1729), + 336: uint16(1729), + 337: uint16(1840), + 338: uint16(1840), + 339: uint16(1729), + 340: uint16(1730), + 341: uint16(1732), + 342: uint16(1859), + 343: uint16(1842), + 344: uint16(1870), + 345: uint16(1870), + 346: uint16(1870), + 347: uint16(1870), + 348: uint16(1729), + 349: uint16(1876), + 350: uint16(1751), + 351: uint16(1732), + 352: uint16(1732), + 353: uint16(1751), + 354: uint16(1859), + 355: uint16(1842), + 356: uint16(1751), + 357: uint16(1842), + 358: uint16(1751), + 359: uint16(1729), + 360: uint16(1876), + 361: uint16(1760), + 362: uint16(1857), + 363: uint16(1729), + 364: uint16(1876), + 365: uint16(1906), + 366: uint16(1729), + 367: uint16(1876), + 368: uint16(1729), + 369: uint16(1876), + 370: uint16(1906), + 371: uint16(1746), + 372: uint16(1746), + 373: uint16(1746), + 374: uint16(1873), + 375: uint16(1922), + 376: uint16(1922), + 377: uint16(1906), + 378: uint16(1746), + 379: uint16(1822), + 380: uint16(1746), + 381: uint16(1873), + 382: uint16(1746), + 383: uint16(1746), + 384: uint16(1786), + 385: uint16(1929), + 386: uint16(1843), + 387: uint16(1843), + 388: uint16(1906), + 389: uint16(1729), + 390: uint16(1872), + 391: uint16(1872), + 392: uint16(1894), + 393: uint16(1894), + 394: uint16(1831), + 395: uint16(1836), + 396: uint16(1966), + 397: uint16(1729), + 398: uint16(1833), + 399: uint16(1831), + 400: uint16(1851), + 401: uint16(1860), + 402: uint16(1751), + 403: uint16(1983), + 404: uint16(1996), + 405: uint16(1996), + 406: uint16(2009), + 407: uint16(2009), + 408: uint16(2009), + 409: uint16(2379), + 410: uint16(2379), + 411: uint16(2379), + 412: uint16(2379), + 413: uint16(2379), + 414: uint16(2379), + 415: uint16(2379), + 416: uint16(2379), + 417: uint16(2379), + 418: uint16(2379), + 419: uint16(2379), + 420: uint16(2379), + 421: uint16(2379), + 422: uint16(2379), + 423: uint16(2379), + 424: uint16(136), + 425: uint16(1063), + 426: uint16(1196), + 427: uint16(530), + 428: uint16(636), + 429: uint16(1274), + 430: uint16(1300), + 431: uint16(1443), + 432: uint16(1598), + 433: uint16(1495), + 434: uint16(1479), + 435: uint16(967), + 436: uint16(1083), + 437: uint16(1602), + 438: uint16(463), + 439: uint16(1625), + 440: uint16(1638), + 441: uint16(1670), + 442: uint16(1541), + 443: uint16(1671), + 444: uint16(1689), + 445: uint16(1696), + 446: uint16(1277), + 447: uint16(1432), + 448: uint16(1693), + 449: uint16(808), + 450: uint16(1700), + 451: uint16(1607), + 452: uint16(1657), + 453: uint16(1587), + 454: uint16(1704), + 455: uint16(1707), + 456: uint16(1631), + 457: uint16(1708), + 458: uint16(1733), + 459: uint16(1608), + 460: uint16(1611), + 461: uint16(1743), + 462: uint16(1747), + 463: uint16(1620), + 464: uint16(1592), + 465: uint16(2026), + 466: uint16(2030), + 467: uint16(2013), + 468: uint16(1914), + 469: uint16(2018), + 470: uint16(1916), + 471: uint16(2020), + 472: uint16(2019), + 473: uint16(2021), + 474: uint16(1915), + 475: uint16(2027), + 476: uint16(2029), + 477: uint16(2024), + 478: uint16(2025), + 479: uint16(1909), + 480: uint16(1899), + 481: uint16(1923), + 482: uint16(2028), + 483: uint16(2028), + 484: uint16(1913), + 485: uint16(2037), + 486: uint16(1917), + 487: uint16(2042), + 488: uint16(2059), + 489: uint16(1918), + 490: uint16(1932), + 491: uint16(2028), + 492: uint16(1933), + 493: uint16(2003), + 494: uint16(2031), + 495: uint16(2028), + 496: uint16(1919), + 497: uint16(2012), + 498: uint16(2015), + 499: uint16(2016), + 500: uint16(2022), + 501: uint16(1936), + 502: uint16(1956), + 503: uint16(2040), + 504: uint16(2053), + 505: uint16(2077), + 506: uint16(2074), + 507: uint16(2058), + 508: uint16(1967), + 509: uint16(1924), + 510: uint16(2034), + 511: uint16(2060), + 512: uint16(2036), + 513: uint16(2008), + 514: uint16(2046), + 515: uint16(1946), + 516: uint16(1978), + 517: uint16(2066), + 518: uint16(2075), + 519: uint16(2078), + 520: uint16(1968), + 521: uint16(1972), + 522: uint16(2084), + 523: uint16(2041), + 524: uint16(2086), + 525: uint16(2088), + 526: uint16(2076), + 527: uint16(2089), + 528: uint16(2048), + 529: uint16(2054), + 530: uint16(2093), + 531: uint16(2023), + 532: uint16(2091), + 533: uint16(2099), + 534: uint16(2055), + 535: uint16(2085), + 536: uint16(2101), + 537: uint16(2092), + 538: uint16(1975), + 539: uint16(2105), + 540: uint16(2110), + 541: uint16(2111), + 542: uint16(2112), + 543: uint16(2115), + 544: uint16(2113), + 545: uint16(2043), + 546: uint16(1997), + 547: uint16(2117), + 548: uint16(2120), + 549: uint16(2032), + 550: uint16(2114), + 551: uint16(2122), + 552: uint16(2001), + 553: uint16(2121), + 554: uint16(2116), + 555: uint16(2118), + 556: uint16(2119), + 557: uint16(2124), + 558: uint16(2062), + 559: uint16(2071), + 560: uint16(2068), + 561: uint16(2123), + 562: uint16(2080), + 563: uint16(2065), + 564: uint16(2126), + 565: uint16(2138), + 566: uint16(2140), + 567: uint16(2139), + 568: uint16(2141), + 569: uint16(2143), + 570: uint16(2130), + 571: uint16(2033), + 572: uint16(2035), + 573: uint16(2142), + 574: uint16(2121), + 575: uint16(2146), + 576: uint16(2147), + 577: uint16(2148), + 578: uint16(2150), + 579: uint16(2149), + 580: uint16(2152), + 581: uint16(2156), + 582: uint16(2151), + 583: uint16(2164), + 584: uint16(2158), + 585: uint16(2159), + 586: uint16(2161), + 587: uint16(2162), + 588: uint16(2160), + 589: uint16(2165), + 590: uint16(2163), + 591: uint16(2050), + 592: uint16(2049), + 593: uint16(2051), + 594: uint16(2052), + 595: uint16(2167), + 596: uint16(2172), + 597: uint16(2181), + 598: uint16(2197), + 599: uint16(2204), +} + +var _zValue = [128]int8{ + 0: int8(-int32(1)), + 1: int8(-int32(1)), + 2: int8(-int32(1)), + 3: int8(-int32(1)), + 4: int8(-int32(1)), + 5: int8(-int32(1)), + 6: int8(-int32(1)), + 7: int8(-int32(1)), + 8: int8(-int32(1)), + 9: int8(-int32(1)), + 10: int8(-int32(1)), + 11: int8(-int32(1)), + 12: int8(-int32(1)), + 13: int8(-int32(1)), + 14: int8(-int32(1)), + 15: int8(-int32(1)), + 16: int8(-int32(1)), + 17: int8(-int32(1)), + 18: int8(-int32(1)), + 19: int8(-int32(1)), + 20: int8(-int32(1)), + 21: int8(-int32(1)), + 22: int8(-int32(1)), + 23: int8(-int32(1)), + 24: int8(-int32(1)), + 25: int8(-int32(1)), + 26: int8(-int32(1)), + 27: int8(-int32(1)), + 28: int8(-int32(1)), + 29: int8(-int32(1)), + 30: int8(-int32(1)), + 31: int8(-int32(1)), + 32: int8(-int32(1)), + 33: int8(-int32(1)), + 34: int8(-int32(1)), + 35: int8(-int32(1)), + 36: int8(-int32(1)), + 37: int8(-int32(1)), + 38: int8(-int32(1)), + 39: int8(-int32(1)), + 40: int8(-int32(1)), + 41: int8(-int32(1)), + 42: int8(-int32(1)), + 43: int8(-int32(1)), + 44: int8(-int32(1)), + 45: int8(-int32(1)), + 46: int8(-int32(1)), + 47: int8(-int32(1)), + 49: int8(1), + 50: int8(2), + 51: int8(3), + 52: int8(4), + 53: int8(5), + 54: int8(6), + 55: int8(7), + 56: int8(8), + 57: int8(9), + 58: int8(-int32(1)), + 59: int8(-int32(1)), + 60: int8(-int32(1)), + 61: int8(-int32(1)), + 62: int8(-int32(1)), + 63: int8(-int32(1)), + 64: int8(-int32(1)), + 65: int8(10), + 66: int8(11), + 67: int8(12), + 68: int8(13), + 69: int8(14), + 70: int8(15), + 71: int8(16), + 72: int8(17), + 73: int8(18), + 74: int8(19), + 75: int8(20), + 76: int8(21), + 77: int8(22), + 78: int8(23), + 79: int8(24), + 80: int8(25), + 81: int8(26), + 82: int8(27), + 83: int8(28), + 84: int8(29), + 85: int8(30), + 86: int8(31), + 87: int8(32), + 88: int8(33), + 89: int8(34), + 90: int8(35), + 91: int8(-int32(1)), + 92: int8(-int32(1)), + 93: int8(-int32(1)), + 94: int8(-int32(1)), + 95: int8(36), + 96: int8(-int32(1)), + 97: int8(37), + 98: int8(38), + 99: int8(39), + 100: int8(40), + 101: int8(41), + 102: int8(42), + 103: int8(43), + 104: int8(44), + 105: int8(45), + 106: int8(46), + 107: int8(47), + 108: int8(48), + 109: int8(49), + 110: int8(50), + 111: int8(51), + 112: int8(52), + 113: int8(53), + 114: int8(54), + 115: int8(55), + 116: int8(56), + 117: int8(57), + 118: int8(58), + 119: int8(59), + 120: int8(60), + 121: int8(61), + 122: int8(62), + 123: int8(-int32(1)), + 124: int8(-int32(1)), + 125: int8(-int32(1)), + 126: int8(63), + 127: int8(-int32(1)), +} + +var _zero = [4]Tu8{} + +// C documentation +// +// /* +// ** Add a new element to the end of an expression list. If pList is +// ** initially NULL, then create a new expression list. +// ** +// ** The pList argument must be either NULL or a pointer to an ExprList +// ** obtained from a prior call to sqlite3ExprListAppend(). +// ** +// ** If a memory allocation error occurs, the entire list is freed and +// ** NULL is returned. If non-NULL is returned, then it is guaranteed +// ** that the new entry was successfully appended. +// */ +var _zeroItem = TExprList_item{} + +var _zerobyte Tu8 + +type analysisInfo = TanalysisInfo + +const bBatch = 0 + +type bft = Tbft + +/* Bit Field Type */ + +/* +** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value +** that can be stored in a u32 without loss of data. The value +** is 0x00000000ffffffff. But because of quirks of some compilers, we +** have to specify the value in the less intuitive manner shown: + */ + +type clock_t = Tclock_t + +type compareInfo = TcompareInfo + +/* +** For LIKE and GLOB matching on EBCDIC machines, assume that every +** character is exactly one byte in size. Also, provide the Utf8Read() +** macro for fast reading of the next character in the common case where +** the next character is ASCII. + */ + +const cume_distFinalizeFunc = 0 + +type dev_t = Tdev_t + +type div_t = Tdiv_t + +const errno = 0 + +const etBUFSIZE = 70 + +type etByte = TetByte + +const etCHARX = 8 + +const etDECIMAL = 16 + +const etDYNSTRING = 6 + +const etESCAPE_Q = 10 + +const etESCAPE_q = 9 + +const etESCAPE_w = 14 + +const etEXP = 2 + +const etFLOAT = 1 + +const etGENERIC = 3 + +const etINVALID = 17 + +const etORDINAL = 15 + +const etPERCENT = 7 + +const etPOINTER = 13 + +const etRADIX = 0 + +const etSIZE = 4 + +const etSRCITEM = 12 + +const etSTRING = 5 + +const etTOKEN = 11 + +type et_info = Tet_info + +/* +** Allowed values for et_info.flags + */ + +/* +** The table is searched by hash. In the case of %C where C is the character +** and that character has ASCII value j, then the hash is j%23. +** +** The order of the entries in fmtinfo[] and the hash chain was entered +** manually, but based on the output of the following TCL script: + */ + +type fd_set = Tfd_set + +const first_valueInvFunc = 0 + +const first_valueValueFunc = 0 + +type float_t = Tfloat_t + +type fpos_t = Tfpos_t + +const fts5GetVarint = 0 + +const fts5YYGROWABLESTACK = 0 + +const fts5YYMALLOCARGTYPE = 0 + +type fts5YYMINORTYPE = Tfts5YYMINORTYPE + +/************* End control #defines *******************************************/ + +/* Define the fts5yytestcase() macro to be a no-op if is not already defined +** otherwise. +** +** Applications can choose to define fts5yytestcase() in the %include section +** to a macro that can assist in verifying code coverage. For production +** code the fts5yytestcase() macro should be turned off. But it is useful +** for testing. + */ + +/* Macro to determine if stack space has the ability to grow using +** heap memory. + */ + +/* Guarantee a minimum number of initial stack slots. + */ + +const fts5YYNFTS5TOKEN = 16 + +const fts5YYNOCODE = 27 + +const fts5YYNOERRORRECOVERY = 1 + +const fts5YYNRULE = 28 + +const fts5YYNRULE_WITH_ACTION = 28 + +const fts5YYNSTATE = 35 + +const fts5YYPARSEFREENOTNULL = 1 + +const fts5YYSTACKDEPTH = 100 + +const fts5YY_ACCEPT_ACTION = 81 + +const fts5YY_ACTTAB_COUNT = 105 + +const fts5YY_ERROR_ACTION = 80 + +const fts5YY_MAX_DSTRCTR = 24 + +const fts5YY_MAX_REDUCE = 110 + +const fts5YY_MAX_SHIFT = 34 + +const fts5YY_MAX_SHIFTREDUCE = 79 + +const fts5YY_MIN_DSTRCTR = 16 + +const fts5YY_MIN_REDUCE = 83 + +const fts5YY_MIN_SHIFTREDUCE = 52 + +const fts5YY_NO_ACTION = 82 + +const fts5YY_REDUCE_COUNT = 17 + +const fts5YY_REDUCE_MAX = 67 + +const fts5YY_REDUCE_MIN = -17 + +const fts5YY_SHIFT_COUNT = 34 + +const fts5YY_SHIFT_MAX = 93 + +const fts5YY_SHIFT_MIN = 0 + +type fts5_api = Tfts5_api + +type fts5_extension_function = Tfts5_extension_function + +type fts5_tokenizer = Tfts5_tokenizer + +/* Flags that may be passed as the third argument to xTokenize() */ + +/* Flags that may be passed by the tokenizer implementation back to FTS5 +** as the third argument to the supplied xToken callback. */ + +/* +** END OF CUSTOM TOKENIZERS +*************************************************************************/ + +type fts5_tokenizer_v2 = Tfts5_tokenizer_v2 + +type fts5yyParser = Tfts5yyParser + +/* #include */ + +/* For builds that do no have a growable stack, fts5yyGrowStack always +** returns an error. + */ + +/* Datatype of the argument to the memory allocated passed as the +** second argument to sqlite3Fts5ParserAlloc() below. This can be changed by +** putting an appropriate #define in the %include section of the input +** grammar. + */ + +type fts5yyStackEntry = Tfts5yyStackEntry + +const get4byte = 0 + +const getVarint = 0 + +type ht_slot = Tht_slot + +/* Size (in bytes) of a WalIterator object suitable for N or fewer segments */ + +/* +** Define the parameters of the hash tables in the wal-index file. There +** is a hash-table following every HASHTABLE_NPAGE page numbers in the +** wal-index. +** +** Changing any of these constants will alter the wal-index format and +** create incompatibilities. + */ + +/* +** The block of page numbers associated with the first hash-table in a +** wal-index is smaller than usual. This is so that there is a complete +** hash-table on each aligned 32KB page of the wal-index. + */ + +/* The wal-index is divided into pages of WALINDEX_PGSZ bytes each. */ + +/* +** Structured Exception Handling (SEH) is a Windows-specific technique +** for catching exceptions raised while accessing memory-mapped files. +** +** The -DSQLITE_USE_SEH compile-time option means to use SEH to catch and +** deal with system-level errors that arise during WAL -shm file processing. +** Without this compile-time option, any system-level faults that appear +** while accessing the memory-mapped -shm file will cause a process-wide +** signal to be deliver, which will more than likely cause the entire +** process to exit. + */ + +type i16 = Ti16 + +type i64 = Ti64 + +type i8 = Ti8 + +/* 1-byte signed integer */ + +type ino_t = Tino_t + +type int16_t = Tint16_t + +type int32_t = Tint32_t + +type int64_t = Tint64_t + +type int8_t = Tint8_t + +type int_fast16_t = Tint_fast16_t + +type int_fast32_t = Tint_fast32_t + +type int_fast64_t = Tint_fast64_t + +type int_fast8_t = Tint_fast8_t + +type int_least16_t = Tint_least16_t + +type int_least32_t = Tint_least32_t + +type int_least64_t = Tint_least64_t + +type int_least8_t = Tint_least8_t + +type intmax_t = Tintmax_t + +type intptr_t = Tintptr_t + +type ldiv_t = Tldiv_t + +type lldiv_t = Tlldiv_t + +const mem0 = 0 + +// C documentation +// +// /* +// ** Initialize the mutex system. +// */ +var mu sync.Mutex + +const noopFunc = 0 + +const nth_valueInvFunc = 0 + +const nth_valueValueFunc = 0 + +const ntileFinalizeFunc = 0 + +type p4union = Tp4union + +const pcache1 = 0 + +const percent_rankFinalizeFunc = 0 + +const put4byte = 0 + +const putVarint = 0 + +type rbu_file = Trbu_file + +type rbu_vfs = Trbu_vfs + +type sColMap = TsColMap + +type size_t = Tsize_t + +type sqlite3 = Tsqlite3 + +type sqlite3AutoExtList = Tsqlite3AutoExtList + +const sqlite3Fts5ParserARG_PARAM = 0 + +const sqlite3Fts5ParserARG_PDECL = 0 + +const sqlite3Fts5ParserFTS5TOKENTYPE = 0 + +const sqlite3GlobalConfig = 0 + +type sqlite3InitInfo = Tsqlite3InitInfo + +const sqlite3ParserCTX_PARAM = 0 + +const sqlite3ParserCTX_PDECL = 0 + +const sqlite3ParserTOKENTYPE = 0 + +const sqlite3Parser_ENGINEALWAYSONSTACK = 1 + +type sqlite3PrngType = Tsqlite3PrngType + +/************** End of printf.c **********************************************/ +/************** Begin file treeview.c ****************************************/ +/* +** 2015-06-08 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains C code to implement the TreeView debugging routines. +** These routines print a parse tree to standard output for debugging and +** analysis. +** +** The interfaces in this file is only available when compiling +** with SQLITE_DEBUG. + */ +/* #include "sqliteInt.h" */ + +/************** End of treeview.c ********************************************/ +/************** Begin file random.c ******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code to implement a pseudo-random number +** generator (PRNG) for SQLite. +** +** Random numbers are used by some of the database backends in order +** to generate random integer keys for tables or random filenames. + */ +/* #include "sqliteInt.h" */ + +type sqlite3StatType = Tsqlite3StatType + +type sqlite3StatValueType = Tsqlite3StatValueType + +const sqlite3StrNICmp = 0 + +type sqlite3_api_routines = Tsqlite3_api_routines + +type sqlite3_backup = Tsqlite3_backup + +type sqlite3_callback = Tsqlite3_callback + +/* +** CAPI3REF: Result Codes +** KEYWORDS: {result code definitions} +** +** Many SQLite functions return an integer result code from the set shown +** here in order to indicate success or failure. +** +** New error codes may be added in future versions of SQLite. +** +** See also: [extended result code definitions] + */ +/* beginning-of-error-codes */ +/* end-of-error-codes */ + +/* +** CAPI3REF: Extended Result Codes +** KEYWORDS: {extended result code definitions} +** +** In its default configuration, SQLite API routines return one of 30 integer +** [result codes]. However, experience has shown that many of +** these result codes are too coarse-grained. They do not provide as +** much information about problems as programmers might like. In an effort to +** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8] +** and later) include +** support for additional result codes that provide more detailed information +** about errors. These [extended result codes] are enabled or disabled +** on a per database connection basis using the +** [sqlite3_extended_result_codes()] API. Or, the extended code for +** the most recent error can be obtained using +** [sqlite3_extended_errcode()]. + */ + +/* +** CAPI3REF: Flags For File Open Operations +** +** These bit values are intended for use in the +** 3rd parameter to the [sqlite3_open_v2()] interface and +** in the 4th parameter to the [sqlite3_vfs.xOpen] method. +** +** Only those flags marked as "Ok for sqlite3_open_v2()" may be +** used as the third argument to the [sqlite3_open_v2()] interface. +** The other flags have historically been ignored by sqlite3_open_v2(), +** though future versions of SQLite might change so that an error is +** raised if any of the disallowed bits are passed into sqlite3_open_v2(). +** Applications should not depend on the historical behavior. +** +** Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into +** [sqlite3_open_v2()] does *not* cause the underlying database file +** to be opened using O_EXCL. Passing SQLITE_OPEN_EXCLUSIVE into +** [sqlite3_open_v2()] has historically been a no-op and might become an +** error in future versions of SQLite. + */ + +/* Reserved: 0x00F00000 */ +/* Legacy compatibility: */ + +/* +** CAPI3REF: Device Characteristics +** +** The xDeviceCharacteristics method of the [sqlite3_io_methods] +** object returns an integer which is a vector of these +** bit values expressing I/O characteristics of the mass storage +** device that holds the file that the [sqlite3_io_methods] +** refers to. +** +** The SQLITE_IOCAP_ATOMIC property means that all writes of +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values +** mean that writes of blocks that are nnn bytes in size and +** are aligned to an address which is an integer multiple of +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means +** that when data is appended to a file, the data is appended +** first then the size of the file is extended, never the other +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that +** information is written to disk in the same order as calls +** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that +** after reboot following a crash or power loss, the only bytes in a +** file that were written at the application level might have changed +** and that adjacent bytes, even bytes within the same sector are +** guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN +** flag indicates that a file cannot be deleted when open. The +** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on +** read-only media and cannot be changed even by processes with +** elevated privileges. +** +** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying +** filesystem supports doing multiple write operations atomically when those +** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and +** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. +** +** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read +** from the database file in amounts that are not a multiple of the +** page size and that do not begin at a page boundary. Without this +** property, SQLite is careful to only do full-page reads and write +** on aligned pages, with the one exception that it will do a sub-page +** read of the first page to access the database header. + */ + +/* +** CAPI3REF: File Locking Levels +** +** SQLite uses one of these integer values as the second +** argument to calls it makes to the xLock() and xUnlock() methods +** of an [sqlite3_io_methods] object. These values are ordered from +** least restrictive to most restrictive. +** +** The argument to xLock() is always SHARED or higher. The argument to +** xUnlock is either SHARED or NONE. + */ + +/* +** CAPI3REF: Synchronization Type Flags +** +** When SQLite invokes the xSync() method of an +** [sqlite3_io_methods] object it uses a combination of +** these integer values as the second argument. +** +** When the SQLITE_SYNC_DATAONLY flag is used, it means that the +** sync operation only needs to flush data to mass storage. Inode +** information need not be flushed. If the lower four bits of the flag +** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. +** If the lower four bits equal SQLITE_SYNC_FULL, that means +** to use Mac OS X style fullsync instead of fsync(). +** +** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags +** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL +** settings. The [synchronous pragma] determines when calls to the +** xSync VFS method occur and applies uniformly across all platforms. +** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how +** energetic or rigorous or forceful the sync operations are and +** only make a difference on Mac OSX for the default SQLite code. +** (Third-party VFS implementations might also make the distinction +** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the +** operating systems natively supported by SQLite, only Mac OSX +** cares about the difference.) + */ + +type sqlite3_changegroup = Tsqlite3_changegroup + +/* +** CAPI3REF: Flags for sqlite3changeset_apply_v2 +** +** The following flags may passed via the 9th parameter to +** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]: +** +**
+**
SQLITE_CHANGESETAPPLY_NOSAVEPOINT
+** Usually, the sessions module encloses all operations performed by +** a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The +** SAVEPOINT is committed if the changeset or patchset is successfully +** applied, or rolled back if an error occurs. Specifying this flag +** causes the sessions module to omit this savepoint. In this case, if the +** caller has an open transaction or savepoint when apply_v2() is called, +** it may revert the partially applied changeset by rolling it back. +** +**
SQLITE_CHANGESETAPPLY_INVERT
+** Invert the changeset before applying it. This is equivalent to inverting +** a changeset using sqlite3changeset_invert() before applying it. It is +** an error to specify this flag with a patchset. +** +**
SQLITE_CHANGESETAPPLY_IGNORENOOP
+** Do not invoke the conflict handler callback for any changes that +** would not actually modify the database even if they were applied. +** Specifically, this means that the conflict handler is not invoked +** for: +**
    +**
  • a delete change if the row being deleted cannot be found, +**
  • an update change if the modified fields are already set to +** their new values in the conflicting row, or +**
  • an insert change if all fields of the conflicting row match +** the row being inserted. +**
+** +**
SQLITE_CHANGESETAPPLY_FKNOACTION
+** If this flag it set, then all foreign key constraints in the target +** database behave as if they were declared with "ON UPDATE NO ACTION ON +** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL +** or SET DEFAULT. +** +**
SQLITE_CHANGESETAPPLY_NOUPDATELOOP
+** Sometimes, a changeset contains two or more update statements such that +** although after applying all updates the database will contain no +** constraint violations, no single update can be applied before the others. +** The simplest example of this is a pair of UPDATEs that have "swapped" +** two column values with a UNIQUE constraint. +**

+** Usually, sqlite3changeset_apply() and similar functions work hard to try +** to find a way to apply such a changeset. However, if this flag is set, +** then all such updates are considered CONSTRAINT conflicts. + */ + +/* +** CAPI3REF: Constants Passed To The Conflict Handler +** +** Values that may be passed as the second argument to a conflict-handler. +** +**

+**
SQLITE_CHANGESET_DATA
+** The conflict handler is invoked with CHANGESET_DATA as the second argument +** when processing a DELETE or UPDATE change if a row with the required +** PRIMARY KEY fields is present in the database, but one or more other +** (non primary-key) fields modified by the update do not contain the +** expected "before" values. +** +** The conflicting row, in this case, is the database row with the matching +** primary key. +** +**
SQLITE_CHANGESET_NOTFOUND
+** The conflict handler is invoked with CHANGESET_NOTFOUND as the second +** argument when processing a DELETE or UPDATE change if a row with the +** required PRIMARY KEY fields is not present in the database. +** +** There is no conflicting row in this case. The results of invoking the +** sqlite3changeset_conflict() API are undefined. +** +**
SQLITE_CHANGESET_CONFLICT
+** CHANGESET_CONFLICT is passed as the second argument to the conflict +** handler while processing an INSERT change if the operation would result +** in duplicate primary key values. +** +** The conflicting row in this case is the database row with the matching +** primary key. +** +**
SQLITE_CHANGESET_FOREIGN_KEY
+** If foreign key handling is enabled, and applying a changeset leaves the +** database in a state containing foreign key violations, the conflict +** handler is invoked with CHANGESET_FOREIGN_KEY as the second argument +** exactly once before the changeset is committed. If the conflict handler +** returns CHANGESET_OMIT, the changes, including those that caused the +** foreign key constraint violation, are committed. Or, if it returns +** CHANGESET_ABORT, the changeset is rolled back. +** +** No current or conflicting row information is provided. The only function +** it is possible to call on the supplied sqlite3_changeset_iter handle +** is sqlite3changeset_fk_conflicts(). +** +**
SQLITE_CHANGESET_CONSTRAINT
+** If any other constraint violation occurs while applying a change (i.e. +** a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is +** invoked with CHANGESET_CONSTRAINT as the second argument. +** +** There is no conflicting row in this case. The results of invoking the +** sqlite3changeset_conflict() API are undefined. +** +**
+ */ + +/* +** CAPI3REF: Constants Returned By The Conflict Handler +** +** A conflict handler callback must return one of the following three values. +** +**
+**
SQLITE_CHANGESET_OMIT
+** If a conflict handler returns this value no special action is taken. The +** change that caused the conflict is not applied. The session module +** continues to the next change in the changeset. +** +**
SQLITE_CHANGESET_REPLACE
+** This value may only be returned if the second argument to the conflict +** handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this +** is not the case, any changes applied so far are rolled back and the +** call to sqlite3changeset_apply() returns SQLITE_MISUSE. +** +** If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict +** handler, then the conflicting row is either updated or deleted, depending +** on the type of change. +** +** If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict +** handler, then the conflicting row is removed from the database and a +** second attempt to apply the change is made. If this second attempt fails, +** the original row is restored to the database before continuing. +** +**
SQLITE_CHANGESET_ABORT
+** If this value is returned, any changes applied so far are rolled back +** and the call to sqlite3changeset_apply() returns SQLITE_ABORT. +**
+ */ + +type sqlite3_changeset_iter = Tsqlite3_changeset_iter + +type sqlite3_context = Tsqlite3_context + +type sqlite3_destructor_type = Tsqlite3_destructor_type + +type sqlite3_file = Tsqlite3_file + +type sqlite3_filename = Tsqlite3_filename + +type sqlite3_index_constraint = Tsqlite3_index_constraint + +type sqlite3_index_constraint_usage = Tsqlite3_index_constraint_usage + +type sqlite3_index_info = Tsqlite3_index_info + +type sqlite3_index_orderby = Tsqlite3_index_orderby + +type sqlite3_int64 = Tsqlite3_int64 + +type sqlite3_loadext_entry = Tsqlite3_loadext_entry + +/* +** The following macros redefine the API routines so that they are +** redirected through the global sqlite3_api structure. +** +** This header file is also used by the loadext.c source file +** (part of the main SQLite library - not an extension) so that +** it can get access to the sqlite3_api_routines structure +** definition. But the main library does not want to redefine +** the API. So the redefinition macros are only valid if the +** SQLITE_CORE macros is undefined. + */ + +/* This case when the file is being statically linked into the + ** application */ + +/************** End of sqlite3ext.h ******************************************/ +/************** Continuing where we left off in loadext.c ********************/ +/* #include "sqliteInt.h" */ + +/* +** Some API routines are omitted when various features are +** excluded from a build of SQLite. Substitute a NULL pointer +** for any missing APIs. + */ + +type sqlite3_mem_methods = Tsqlite3_mem_methods + +type sqlite3_module = Tsqlite3_module + +type sqlite3_mutex_methods = Tsqlite3_mutex_methods + +type sqlite3_pcache_methods = Tsqlite3_pcache_methods + +type sqlite3_pcache_methods2 = Tsqlite3_pcache_methods2 + +type sqlite3_pcache_page = Tsqlite3_pcache_page + +type sqlite3_rebaser = Tsqlite3_rebaser + +/* +** Make sure we can call this stuff from C++. + */ + +/******** End of sqlite3session.h *********/ +/******** Begin file fts5.h *********/ +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Interfaces to extend FTS5. Using the interfaces defined in this file, +** FTS5 may be extended with: +** +** * custom tokenizers, and +** * custom auxiliary functions. + */ + +/************************************************************************* +** CUSTOM AUXILIARY FUNCTIONS +** +** Virtual table implementations may overload SQL functions by implementing +** the sqlite3_module.xFindFunction() method. + */ + +type sqlite3_rtree_dbl = Tsqlite3_rtree_dbl + +/* +** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin. + */ + +/******** End of sqlite3rtree.h *********/ +/******** Begin file sqlite3session.h *********/ + +/* +** Make sure we can call this stuff from C++. + */ + +type sqlite3_rtree_geometry = Tsqlite3_rtree_geometry + +type sqlite3_rtree_query_info = Tsqlite3_rtree_query_info + +type sqlite3_session = Tsqlite3_session + +type sqlite3_snapshot = Tsqlite3_snapshot + +/* +** CAPI3REF: Datatypes for the CARRAY table-valued function +** +** The fifth argument to the [sqlite3_carray_bind()] interface musts be +** one of the following constants, to specify the datatype of the array +** that is being bound into the [carray table-valued function]. + */ + +/* +** Versions of the above #defines that omit the initial SQLITE_, for +** legacy compatibility. + */ + +/* +** Undo the hack that converts floating point types to integer for +** builds on processors without floating point support. + */ + +/* #endif for SQLITE3_H will be added by mksqlite3.tcl */ + +/******** Begin file sqlite3rtree.h *********/ +/* +** 2010 August 30 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* + */ + +type sqlite3_str = Tsqlite3_str + +type sqlite3_syscall_ptr = Tsqlite3_syscall_ptr + +type sqlite3_uint64 = Tsqlite3_uint64 + +type sqlite3_value = Tsqlite3_value + +type sqlite3_vfs = Tsqlite3_vfs + +type sqlite3_vtab = Tsqlite3_vtab + +type sqlite3_vtab_cursor = Tsqlite3_vtab_cursor + +type sqlite3_xauth = Tsqlite3_xauth + +/* +** Macros to compute aCol[] and aFunc[] register numbers. +** +** These macros should not be used prior to the call to +** assignAggregateRegisters() that computes the value of pAggInfo->iFirstReg. +** The assert()s that are part of this macro verify that constraint. + */ + +type sqlite3rbu = Tsqlite3rbu + +/************** End of sqlite3rbu.h ******************************************/ +/************** Continuing where we left off in sqlite3rbu.c *****************/ + +/* Maximum number of prepared UPDATE statements held by this module */ + +/* Delta checksums disabled by default. Compile with -DRBU_ENABLE_DELTA_CKSUM +** to enable checksum verification. + */ + +/* +** Swap two objects of type TYPE. + */ + +/* +** Name of the URI option that causes RBU to take an exclusive lock as +** part of the incremental checkpoint operation. + */ + +/* +** The rbu_state table is used to save the state of a partially applied +** update so that it can be resumed later. The table consists of integer +** keys mapped to values as follows: +** +** RBU_STATE_STAGE: +** May be set to integer values 1, 2, 4 or 5. As follows: +** 1: the *-rbu file is currently under construction. +** 2: the *-rbu file has been constructed, but not yet moved +** to the *-wal path. +** 4: the checkpoint is underway. +** 5: the rbu update has been checkpointed. +** +** RBU_STATE_TBL: +** Only valid if STAGE==1. The target database name of the table +** currently being written. +** +** RBU_STATE_IDX: +** Only valid if STAGE==1. The target database name of the index +** currently being written, or NULL if the main table is currently being +** updated. +** +** RBU_STATE_ROW: +** Only valid if STAGE==1. Number of rows already processed for the current +** table/index. +** +** RBU_STATE_PROGRESS: +** Trbul number of sqlite3rbu_step() calls made so far as part of this +** rbu update. +** +** RBU_STATE_CKPT: +** Valid if STAGE==4. The 64-bit checksum associated with the wal-index +** header created by recovering the *-wal file. This is used to detect +** cases when another client appends frames to the *-wal file in the +** middle of an incremental checkpoint (an incremental checkpoint cannot +** be continued if this happens). +** +** RBU_STATE_COOKIE: +** Valid if STAGE==1. The current change-counter cookie value in the +** target db file. +** +** RBU_STATE_OALSZ: +** Valid if STAGE==1. The size in bytes of the *-oal file. +** +** RBU_STATE_DATATBL: +** Only valid if STAGE==1. The RBU database name of the table +** currently being read. + */ + +type sqlite_int64 = Tsqlite_int64 + +type sqlite_uint64 = Tsqlite_uint64 + +type ssize_t = Tssize_t + +type tRowcnt = TtRowcnt + +type t__builtin_va_list = uintptr + +type t__ccgo_fp__Xsqlite3_auto_extension_0 = func(*libc.TLS) + +/* The "wsdAutoext" macro will resolve to the autoextension +** state vector. If writable static data is unsupported on the target, +** we have to locate the state vector at run-time. In the more common +** case where writable static data is supported, wsdStat can refer directly +** to the "sqlite3Autoext" state vector declared above. + */ + +type t__ccgo_fp__Xsqlite3_autovacuum_pages_1 = func(*libc.TLS, uintptr, uintptr, uint32, uint32, uint32) uint32 + +type t__ccgo_fp__Xsqlite3_autovacuum_pages_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_bind_blob64_4 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_bind_blob_4 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_bind_pointer_4 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_bind_text16_4 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_bind_text64_4 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_bind_text_4 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_busy_handler_1 = func(*libc.TLS, uintptr, int32) int32 + +type t__ccgo_fp__Xsqlite3_cancel_auto_extension_0 = func(*libc.TLS) + +type t__ccgo_fp__Xsqlite3_collation_needed16_2 = func(*libc.TLS, uintptr, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_collation_needed_2 = func(*libc.TLS, uintptr, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_commit_hook_1 = func(*libc.TLS, uintptr) int32 + +type t__ccgo_fp__Xsqlite3_create_collation16_4 = func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3_create_collation_4 = func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3_create_collation_v2_4 = func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3_create_collation_v2_5 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function16_5 = func(*libc.TLS, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function16_6 = func(*libc.TLS, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function16_7 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function_5 = func(*libc.TLS, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function_6 = func(*libc.TLS, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function_7 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function_v2_5 = func(*libc.TLS, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function_v2_6 = func(*libc.TLS, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function_v2_7 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_create_function_v2_8 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_create_module_v2_4 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_create_window_function_5 = func(*libc.TLS, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_create_window_function_6 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_create_window_function_7 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_create_window_function_8 = func(*libc.TLS, uintptr, int32, uintptr) + +type t__ccgo_fp__Xsqlite3_create_window_function_9 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_exec_2 = func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 + +/************** End of insert.c **********************************************/ +/************** Begin file legacy.c ******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** Main file for the SQLite library. The routines in this file +** implement the programmer interface to the library. Routines in +** other files are for internal use by SQLite and should not be +** accessed by users of the library. + */ + +/* #include "sqliteInt.h" */ + +type t__ccgo_fp__Xsqlite3_memory_alarm_0 = func(*libc.TLS, uintptr, int64, int32) + +type t__ccgo_fp__Xsqlite3_preupdate_hook_1 = func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, int64, int64) + +type t__ccgo_fp__Xsqlite3_profile_1 = func(*libc.TLS, uintptr, uintptr, uint64) + +type t__ccgo_fp__Xsqlite3_progress_handler_2 = func(*libc.TLS, uintptr) int32 + +type t__ccgo_fp__Xsqlite3_result_blob64_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_result_blob_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_result_pointer_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_result_text16_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_result_text16be_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_result_text16le_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_result_text64_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_result_text_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_rollback_hook_1 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_rtree_geometry_callback_2 = func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3_rtree_query_callback_2 = func(*libc.TLS, uintptr) int32 + +type t__ccgo_fp__Xsqlite3_rtree_query_callback_4 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_set_authorizer_1 = func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32 + +/************** End of attach.c **********************************************/ +/************** Begin file auth.c ********************************************/ +/* +** 2003 January 11 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the sqlite3_set_authorizer() +** API. This facility is an optional feature of the library. Embedded +** systems that do not need this facility may omit it by recompiling +** the library with -DSQLITE_OMIT_AUTHORIZATION=1 + */ +/* #include "sqliteInt.h" */ + +/* +** All of the code in this file may be omitted by defining a single +** macro. + */ + +type t__ccgo_fp__Xsqlite3_set_auxdata_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_set_clientdata_3 = func(*libc.TLS, uintptr) + +type t__ccgo_fp__Xsqlite3_trace_1 = func(*libc.TLS, uintptr, uintptr) + +type t__ccgo_fp__Xsqlite3_trace_v2_2 = func(*libc.TLS, uint32, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3_unlock_notify_1 = func(*libc.TLS, uintptr, int32) + +type t__ccgo_fp__Xsqlite3_update_hook_1 = func(*libc.TLS, uintptr, int32, uintptr, uintptr, int64) + +type t__ccgo_fp__Xsqlite3_wal_hook_1 = func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32 + +type t__ccgo_fp__Xsqlite3changegroup_add_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changegroup_output_strm_1 = func(*libc.TLS, uintptr, uintptr, int32) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_3 = func(*libc.TLS, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_4 = func(*libc.TLS, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_strm_3 = func(*libc.TLS, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_strm_4 = func(*libc.TLS, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v2_3 = func(*libc.TLS, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v2_4 = func(*libc.TLS, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v2_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v2_strm_3 = func(*libc.TLS, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v2_strm_4 = func(*libc.TLS, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v3_3 = func(*libc.TLS, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v3_4 = func(*libc.TLS, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v3_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v3_strm_3 = func(*libc.TLS, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_apply_v3_strm_4 = func(*libc.TLS, uintptr, int32, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_concat_strm_0 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_concat_strm_2 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_concat_strm_4 = func(*libc.TLS, uintptr, uintptr, int32) int32 + +type t__ccgo_fp__Xsqlite3changeset_invert_strm_0 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_invert_strm_2 = func(*libc.TLS, uintptr, uintptr, int32) int32 + +type t__ccgo_fp__Xsqlite3changeset_start_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3changeset_start_v2_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3rbu_rename_handler_2 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3rebaser_rebase_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32 + +type t__ccgo_fp__Xsqlite3rebaser_rebase_strm_3 = func(*libc.TLS, uintptr, uintptr, int32) int32 + +type t__ccgo_fp__Xsqlite3session_changeset_strm_1 = func(*libc.TLS, uintptr, uintptr, int32) int32 + +type t__ccgo_fp__Xsqlite3session_patchset_strm_1 = func(*libc.TLS, uintptr, uintptr, int32) int32 + +type t__ccgo_fp__Xsqlite3session_table_filter_1 = func(*libc.TLS, uintptr, uintptr) int32 + +type time_t = Ttime_t + +type timespec = Ttimespec + +type timeval = Ttimeval + +const tkCREATE = 4 + +const tkEND = 7 + +const tkEXPLAIN = 3 + +const tkOTHER = 2 + +const tkSEMI = 0 + +const tkTEMP = 5 + +const tkTRIGGER = 6 + +const tkWS = 1 + +type u16 = Tu16 + +type u32 = Tu32 + +type u64 = Tu64 + +type u8 = Tu8 + +type u_char = Tu_char + +type u_int = Tu_int + +type u_long = Tu_long + +type u_short = Tu_short + +type uint16_t = Tuint16_t + +type uint32_t = Tuint32_t + +type uint64_t = Tuint64_t + +type uint8_t = Tuint8_t + +type uint_fast16_t = Tuint_fast16_t + +type uint_fast8_t = Tuint_fast8_t + +type uint_least16_t = Tuint_least16_t + +type uint_least32_t = Tuint_least32_t + +type uint_least64_t = Tuint_least64_t + +type uint_least8_t = Tuint_least8_t + +type uintptr_t = Tuintptr_t + +type uptr = Tuptr + +/* +** Bits for the sqlite3WhereTrace mask: +** +** (---any--) Top-level block structure +** 0x-------F High-level debug messages +** 0x----FFF- More detail +** 0xFFFF---- Low-level debug messages +** +** 0x00000001 Code generation +** 0x00000002 Solver (Use 0x40000 for less detail) +** 0x00000004 Solver costs +** 0x00000008 WhereLoop inserts +** +** 0x00000010 Display sqlite3_index_info xBestIndex calls +** 0x00000020 Range an equality scan metrics +** 0x00000040 IN operator decisions +** 0x00000080 WhereLoop cost adjustments +** 0x00000100 +** 0x00000200 Covering index decisions +** 0x00000400 OR optimization +** 0x00000800 Index scanner +** 0x00001000 More details associated with code generation +** 0x00002000 +** 0x00004000 Show all WHERE terms at key points +** 0x00008000 Show the full SELECT statement at key places +** +** 0x00010000 Show more detail when printing WHERE terms +** 0x00020000 Show WHERE terms returned from whereScanNext() +** 0x00040000 Solver overview messages +** 0x00080000 Star-query heuristic +** 0x00100000 Pointers are all shown as zero + */ + +type useconds_t = Tuseconds_t + +type va_list = Tva_list + +const vfsList = 0 + +type wchar_t = Twchar_t + +const wsdAutoext = 0 + +const wsdHooks = 0 + +const wsdPrng = 0 + +const wsdStat = 0 + +type yDbMask = TyDbMask + +type ynVar = TynVar + +type yyParser = TyyParser + +/* #include */ + +type yyStackEntry = TyyStackEntry diff --git a/internal/engine/lib/sqlite_darwin_amd64.go b/internal/engine/lib/sqlite_darwin_amd64.go new file mode 100644 index 0000000..38879f3 --- /dev/null +++ b/internal/engine/lib/sqlite_darwin_amd64.go @@ -0,0 +1,658 @@ +// Code generated for darwin/amd64 by 'generator -mlong-double-64 --package-name libsqlite3 --prefix-enumerator=_ --prefix-external=x_ --prefix-field=F --prefix-static-internal=_ --prefix-static-none=_ --prefix-tagged-enum=_ --prefix-tagged-struct=T --prefix-tagged-union=T --prefix-typename=T --prefix-undefined=_ -ignore-unsupported-alignment -ignore-link-errors -import=sync -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DNDEBUG -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DISABLE_INTRINSIC -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_RBU -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_HAVE_ZLIB=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_WITHOUT_ZONEMALLOC -D_LARGEFILE64_SOURCE -I /Users/jnml/src/modernc.org/builder/.exclude/github.com/hanzoai/sqlite/internal/libc/include/darwin/amd64 -I /Users/jnml/src/modernc.org/builder/.exclude/modernc.org/libz/include/darwin/amd64 -I /Users/jnml/src/modernc.org/builder/.exclude/modernc.org/libtcl8.6/include/darwin/amd64 -extended-errors -o sqlite3.go sqlite3.c -DSQLITE_MUTEX_NOOP -DSQLITE_OS_UNIX=1 -eval-all-macros', DO NOT EDIT. + +//go:build darwin && amd64 + +package sqlite3 + +const FP_CHOP = 3 + +const FP_PREC_24B = 0 + +const FP_PREC_53B = 2 + +const FP_PREC_64B = 3 + +const FP_RND_DOWN = 1 + +const FP_RND_NEAR = 0 + +const FP_RND_UP = 2 + +const FP_STATE_BYTES = 512 + +const MAXPHYS = 131072 + +const MAXPHYSIO = 131072 + +const NMBCLUSTERS = 512 + +const TARGET_ABI_USES_IOS_VALUES = 0 + +const TARGET_CPU_ARM64 = 0 + +const TARGET_CPU_X86_64 = 1 + +const TARGET_OS_ARROW = 0 + +type Tboolean_t = uint32 + +type Tstat64 = struct { + Fst_dev Tdev_t + Fst_mode Tmode_t + Fst_nlink Tnlink_t + Fst_ino t__darwin_ino64_t + Fst_uid Tuid_t + Fst_gid Tgid_t + Fst_rdev Tdev_t + Fst_atimespec Ttimespec + Fst_mtimespec Ttimespec + Fst_ctimespec Ttimespec + Fst_birthtimespec Ttimespec + Fst_size Toff_t + Fst_blocks Tblkcnt_t + Fst_blksize Tblksize_t + Fst_flags t__uint32_t + Fst_gen t__uint32_t + Fst_lspare t__int32_t + Fst_qspare [2]t__int64_t +} + +type Tstatfs64 = struct { + Ff_bsize Tuint32_t + Ff_iosize Tint32_t + Ff_blocks Tuint64_t + Ff_bfree Tuint64_t + Ff_bavail Tuint64_t + Ff_files Tuint64_t + Ff_ffree Tuint64_t + Ff_fsid Tfsid_t + Ff_owner Tuid_t + Ff_type Tuint32_t + Ff_flags Tuint32_t + Ff_fssubtype Tuint32_t + Ff_fstypename [16]int8 + Ff_mntonname [1024]int8 + Ff_mntfromname [1024]int8 + Ff_flags_ext Tuint32_t + Ff_reserved [7]Tuint32_t +} + +const _I386_SIGNAL_H_ = 1 + +const _X86_INSTRUCTION_STATE_CACHELINE_SIZE = 64 + +const _X86_INSTRUCTION_STATE_MAX_INSN_BYTES = 2380 + +const __DARWIN_ONLY_64_BIT_INO_T = 0 + +const __DARWIN_ONLY_VERS_1050 = 0 + +const __DARWIN_SUF_1050 = "$1050" + +const __DARWIN_SUF_64_BIT_INO_T = "$INODE64" + +const __LASTBRANCH_MAX = 32 + +const __SSE3__ = 1 + +const __SSE4_1__ = 1 + +const __SSSE3__ = 1 + +const __core2 = 1 + +const __core2__ = 1 + +const __tune_core2__ = 1 + +type stat64 = Tstat64 + +type statfs64 = Tstatfs64 + +type t__darwin_fp_control = struct { + F__ccgo0 uint16 +} + +type t__darwin_fp_control_t = struct { + F__ccgo0 uint16 +} + +type t__darwin_fp_status = struct { + F__ccgo0 uint16 +} + +type t__darwin_fp_status_t = struct { + F__ccgo0 uint16 +} + +type t__darwin_i386_avx512_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw t__darwin_fp_control + F__fpu_fsw t__darwin_fp_status + F__fpu_ftw t__uint8_t + F__fpu_rsrv1 t__uint8_t + F__fpu_fop t__uint16_t + F__fpu_ip t__uint32_t + F__fpu_cs t__uint16_t + F__fpu_rsrv2 t__uint16_t + F__fpu_dp t__uint32_t + F__fpu_ds t__uint16_t + F__fpu_rsrv3 t__uint16_t + F__fpu_mxcsr t__uint32_t + F__fpu_mxcsrmask t__uint32_t + F__fpu_stmm0 t__darwin_mmst_reg + F__fpu_stmm1 t__darwin_mmst_reg + F__fpu_stmm2 t__darwin_mmst_reg + F__fpu_stmm3 t__darwin_mmst_reg + F__fpu_stmm4 t__darwin_mmst_reg + F__fpu_stmm5 t__darwin_mmst_reg + F__fpu_stmm6 t__darwin_mmst_reg + F__fpu_stmm7 t__darwin_mmst_reg + F__fpu_xmm0 t__darwin_xmm_reg + F__fpu_xmm1 t__darwin_xmm_reg + F__fpu_xmm2 t__darwin_xmm_reg + F__fpu_xmm3 t__darwin_xmm_reg + F__fpu_xmm4 t__darwin_xmm_reg + F__fpu_xmm5 t__darwin_xmm_reg + F__fpu_xmm6 t__darwin_xmm_reg + F__fpu_xmm7 t__darwin_xmm_reg + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 t__darwin_xmm_reg + F__fpu_ymmh1 t__darwin_xmm_reg + F__fpu_ymmh2 t__darwin_xmm_reg + F__fpu_ymmh3 t__darwin_xmm_reg + F__fpu_ymmh4 t__darwin_xmm_reg + F__fpu_ymmh5 t__darwin_xmm_reg + F__fpu_ymmh6 t__darwin_xmm_reg + F__fpu_ymmh7 t__darwin_xmm_reg + F__fpu_k0 t__darwin_opmask_reg + F__fpu_k1 t__darwin_opmask_reg + F__fpu_k2 t__darwin_opmask_reg + F__fpu_k3 t__darwin_opmask_reg + F__fpu_k4 t__darwin_opmask_reg + F__fpu_k5 t__darwin_opmask_reg + F__fpu_k6 t__darwin_opmask_reg + F__fpu_k7 t__darwin_opmask_reg + F__fpu_zmmh0 t__darwin_ymm_reg + F__fpu_zmmh1 t__darwin_ymm_reg + F__fpu_zmmh2 t__darwin_ymm_reg + F__fpu_zmmh3 t__darwin_ymm_reg + F__fpu_zmmh4 t__darwin_ymm_reg + F__fpu_zmmh5 t__darwin_ymm_reg + F__fpu_zmmh6 t__darwin_ymm_reg + F__fpu_zmmh7 t__darwin_ymm_reg +} + +type t__darwin_i386_avx_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw t__darwin_fp_control + F__fpu_fsw t__darwin_fp_status + F__fpu_ftw t__uint8_t + F__fpu_rsrv1 t__uint8_t + F__fpu_fop t__uint16_t + F__fpu_ip t__uint32_t + F__fpu_cs t__uint16_t + F__fpu_rsrv2 t__uint16_t + F__fpu_dp t__uint32_t + F__fpu_ds t__uint16_t + F__fpu_rsrv3 t__uint16_t + F__fpu_mxcsr t__uint32_t + F__fpu_mxcsrmask t__uint32_t + F__fpu_stmm0 t__darwin_mmst_reg + F__fpu_stmm1 t__darwin_mmst_reg + F__fpu_stmm2 t__darwin_mmst_reg + F__fpu_stmm3 t__darwin_mmst_reg + F__fpu_stmm4 t__darwin_mmst_reg + F__fpu_stmm5 t__darwin_mmst_reg + F__fpu_stmm6 t__darwin_mmst_reg + F__fpu_stmm7 t__darwin_mmst_reg + F__fpu_xmm0 t__darwin_xmm_reg + F__fpu_xmm1 t__darwin_xmm_reg + F__fpu_xmm2 t__darwin_xmm_reg + F__fpu_xmm3 t__darwin_xmm_reg + F__fpu_xmm4 t__darwin_xmm_reg + F__fpu_xmm5 t__darwin_xmm_reg + F__fpu_xmm6 t__darwin_xmm_reg + F__fpu_xmm7 t__darwin_xmm_reg + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 t__darwin_xmm_reg + F__fpu_ymmh1 t__darwin_xmm_reg + F__fpu_ymmh2 t__darwin_xmm_reg + F__fpu_ymmh3 t__darwin_xmm_reg + F__fpu_ymmh4 t__darwin_xmm_reg + F__fpu_ymmh5 t__darwin_xmm_reg + F__fpu_ymmh6 t__darwin_xmm_reg + F__fpu_ymmh7 t__darwin_xmm_reg +} + +type t__darwin_i386_exception_state = struct { + F__trapno t__uint16_t + F__cpu t__uint16_t + F__err t__uint32_t + F__faultvaddr t__uint32_t +} + +type t__darwin_i386_float_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw t__darwin_fp_control + F__fpu_fsw t__darwin_fp_status + F__fpu_ftw t__uint8_t + F__fpu_rsrv1 t__uint8_t + F__fpu_fop t__uint16_t + F__fpu_ip t__uint32_t + F__fpu_cs t__uint16_t + F__fpu_rsrv2 t__uint16_t + F__fpu_dp t__uint32_t + F__fpu_ds t__uint16_t + F__fpu_rsrv3 t__uint16_t + F__fpu_mxcsr t__uint32_t + F__fpu_mxcsrmask t__uint32_t + F__fpu_stmm0 t__darwin_mmst_reg + F__fpu_stmm1 t__darwin_mmst_reg + F__fpu_stmm2 t__darwin_mmst_reg + F__fpu_stmm3 t__darwin_mmst_reg + F__fpu_stmm4 t__darwin_mmst_reg + F__fpu_stmm5 t__darwin_mmst_reg + F__fpu_stmm6 t__darwin_mmst_reg + F__fpu_stmm7 t__darwin_mmst_reg + F__fpu_xmm0 t__darwin_xmm_reg + F__fpu_xmm1 t__darwin_xmm_reg + F__fpu_xmm2 t__darwin_xmm_reg + F__fpu_xmm3 t__darwin_xmm_reg + F__fpu_xmm4 t__darwin_xmm_reg + F__fpu_xmm5 t__darwin_xmm_reg + F__fpu_xmm6 t__darwin_xmm_reg + F__fpu_xmm7 t__darwin_xmm_reg + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 +} + +type t__darwin_i386_thread_state = struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 +} + +type t__darwin_mcontext32 = struct { + F__es t__darwin_i386_exception_state + F__ss t__darwin_i386_thread_state + F__fs t__darwin_i386_float_state +} + +type t__darwin_mcontext64 = struct { + F__es t__darwin_x86_exception_state64 + F__ss t__darwin_x86_thread_state64 + F__fs t__darwin_x86_float_state64 +} + +type t__darwin_mcontext64_full = struct { + F__es t__darwin_x86_exception_state64 + F__ss t__darwin_x86_thread_full_state64 + F__fs t__darwin_x86_float_state64 +} + +type t__darwin_mcontext_avx32 = struct { + F__es t__darwin_i386_exception_state + F__ss t__darwin_i386_thread_state + F__fs t__darwin_i386_avx_state +} + +type t__darwin_mcontext_avx512_32 = struct { + F__es t__darwin_i386_exception_state + F__ss t__darwin_i386_thread_state + F__fs t__darwin_i386_avx512_state +} + +type t__darwin_mcontext_avx512_64 = struct { + F__es t__darwin_x86_exception_state64 + F__ss t__darwin_x86_thread_state64 + F__fs t__darwin_x86_avx512_state64 +} + +type t__darwin_mcontext_avx512_64_full = struct { + F__es t__darwin_x86_exception_state64 + F__ss t__darwin_x86_thread_full_state64 + F__fs t__darwin_x86_avx512_state64 +} + +type t__darwin_mcontext_avx64 = struct { + F__es t__darwin_x86_exception_state64 + F__ss t__darwin_x86_thread_state64 + F__fs t__darwin_x86_avx_state64 +} + +type t__darwin_mcontext_avx64_full = struct { + F__es t__darwin_x86_exception_state64 + F__ss t__darwin_x86_thread_full_state64 + F__fs t__darwin_x86_avx_state64 +} + +type t__darwin_mmst_reg = struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 +} + +type t__darwin_opmask_reg = struct { + F__opmask_reg [8]int8 +} + +type t__darwin_x86_avx512_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw t__darwin_fp_control + F__fpu_fsw t__darwin_fp_status + F__fpu_ftw t__uint8_t + F__fpu_rsrv1 t__uint8_t + F__fpu_fop t__uint16_t + F__fpu_ip t__uint32_t + F__fpu_cs t__uint16_t + F__fpu_rsrv2 t__uint16_t + F__fpu_dp t__uint32_t + F__fpu_ds t__uint16_t + F__fpu_rsrv3 t__uint16_t + F__fpu_mxcsr t__uint32_t + F__fpu_mxcsrmask t__uint32_t + F__fpu_stmm0 t__darwin_mmst_reg + F__fpu_stmm1 t__darwin_mmst_reg + F__fpu_stmm2 t__darwin_mmst_reg + F__fpu_stmm3 t__darwin_mmst_reg + F__fpu_stmm4 t__darwin_mmst_reg + F__fpu_stmm5 t__darwin_mmst_reg + F__fpu_stmm6 t__darwin_mmst_reg + F__fpu_stmm7 t__darwin_mmst_reg + F__fpu_xmm0 t__darwin_xmm_reg + F__fpu_xmm1 t__darwin_xmm_reg + F__fpu_xmm2 t__darwin_xmm_reg + F__fpu_xmm3 t__darwin_xmm_reg + F__fpu_xmm4 t__darwin_xmm_reg + F__fpu_xmm5 t__darwin_xmm_reg + F__fpu_xmm6 t__darwin_xmm_reg + F__fpu_xmm7 t__darwin_xmm_reg + F__fpu_xmm8 t__darwin_xmm_reg + F__fpu_xmm9 t__darwin_xmm_reg + F__fpu_xmm10 t__darwin_xmm_reg + F__fpu_xmm11 t__darwin_xmm_reg + F__fpu_xmm12 t__darwin_xmm_reg + F__fpu_xmm13 t__darwin_xmm_reg + F__fpu_xmm14 t__darwin_xmm_reg + F__fpu_xmm15 t__darwin_xmm_reg + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 t__darwin_xmm_reg + F__fpu_ymmh1 t__darwin_xmm_reg + F__fpu_ymmh2 t__darwin_xmm_reg + F__fpu_ymmh3 t__darwin_xmm_reg + F__fpu_ymmh4 t__darwin_xmm_reg + F__fpu_ymmh5 t__darwin_xmm_reg + F__fpu_ymmh6 t__darwin_xmm_reg + F__fpu_ymmh7 t__darwin_xmm_reg + F__fpu_ymmh8 t__darwin_xmm_reg + F__fpu_ymmh9 t__darwin_xmm_reg + F__fpu_ymmh10 t__darwin_xmm_reg + F__fpu_ymmh11 t__darwin_xmm_reg + F__fpu_ymmh12 t__darwin_xmm_reg + F__fpu_ymmh13 t__darwin_xmm_reg + F__fpu_ymmh14 t__darwin_xmm_reg + F__fpu_ymmh15 t__darwin_xmm_reg + F__fpu_k0 t__darwin_opmask_reg + F__fpu_k1 t__darwin_opmask_reg + F__fpu_k2 t__darwin_opmask_reg + F__fpu_k3 t__darwin_opmask_reg + F__fpu_k4 t__darwin_opmask_reg + F__fpu_k5 t__darwin_opmask_reg + F__fpu_k6 t__darwin_opmask_reg + F__fpu_k7 t__darwin_opmask_reg + F__fpu_zmmh0 t__darwin_ymm_reg + F__fpu_zmmh1 t__darwin_ymm_reg + F__fpu_zmmh2 t__darwin_ymm_reg + F__fpu_zmmh3 t__darwin_ymm_reg + F__fpu_zmmh4 t__darwin_ymm_reg + F__fpu_zmmh5 t__darwin_ymm_reg + F__fpu_zmmh6 t__darwin_ymm_reg + F__fpu_zmmh7 t__darwin_ymm_reg + F__fpu_zmmh8 t__darwin_ymm_reg + F__fpu_zmmh9 t__darwin_ymm_reg + F__fpu_zmmh10 t__darwin_ymm_reg + F__fpu_zmmh11 t__darwin_ymm_reg + F__fpu_zmmh12 t__darwin_ymm_reg + F__fpu_zmmh13 t__darwin_ymm_reg + F__fpu_zmmh14 t__darwin_ymm_reg + F__fpu_zmmh15 t__darwin_ymm_reg + F__fpu_zmm16 t__darwin_zmm_reg + F__fpu_zmm17 t__darwin_zmm_reg + F__fpu_zmm18 t__darwin_zmm_reg + F__fpu_zmm19 t__darwin_zmm_reg + F__fpu_zmm20 t__darwin_zmm_reg + F__fpu_zmm21 t__darwin_zmm_reg + F__fpu_zmm22 t__darwin_zmm_reg + F__fpu_zmm23 t__darwin_zmm_reg + F__fpu_zmm24 t__darwin_zmm_reg + F__fpu_zmm25 t__darwin_zmm_reg + F__fpu_zmm26 t__darwin_zmm_reg + F__fpu_zmm27 t__darwin_zmm_reg + F__fpu_zmm28 t__darwin_zmm_reg + F__fpu_zmm29 t__darwin_zmm_reg + F__fpu_zmm30 t__darwin_zmm_reg + F__fpu_zmm31 t__darwin_zmm_reg +} + +type t__darwin_x86_avx_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw t__darwin_fp_control + F__fpu_fsw t__darwin_fp_status + F__fpu_ftw t__uint8_t + F__fpu_rsrv1 t__uint8_t + F__fpu_fop t__uint16_t + F__fpu_ip t__uint32_t + F__fpu_cs t__uint16_t + F__fpu_rsrv2 t__uint16_t + F__fpu_dp t__uint32_t + F__fpu_ds t__uint16_t + F__fpu_rsrv3 t__uint16_t + F__fpu_mxcsr t__uint32_t + F__fpu_mxcsrmask t__uint32_t + F__fpu_stmm0 t__darwin_mmst_reg + F__fpu_stmm1 t__darwin_mmst_reg + F__fpu_stmm2 t__darwin_mmst_reg + F__fpu_stmm3 t__darwin_mmst_reg + F__fpu_stmm4 t__darwin_mmst_reg + F__fpu_stmm5 t__darwin_mmst_reg + F__fpu_stmm6 t__darwin_mmst_reg + F__fpu_stmm7 t__darwin_mmst_reg + F__fpu_xmm0 t__darwin_xmm_reg + F__fpu_xmm1 t__darwin_xmm_reg + F__fpu_xmm2 t__darwin_xmm_reg + F__fpu_xmm3 t__darwin_xmm_reg + F__fpu_xmm4 t__darwin_xmm_reg + F__fpu_xmm5 t__darwin_xmm_reg + F__fpu_xmm6 t__darwin_xmm_reg + F__fpu_xmm7 t__darwin_xmm_reg + F__fpu_xmm8 t__darwin_xmm_reg + F__fpu_xmm9 t__darwin_xmm_reg + F__fpu_xmm10 t__darwin_xmm_reg + F__fpu_xmm11 t__darwin_xmm_reg + F__fpu_xmm12 t__darwin_xmm_reg + F__fpu_xmm13 t__darwin_xmm_reg + F__fpu_xmm14 t__darwin_xmm_reg + F__fpu_xmm15 t__darwin_xmm_reg + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 t__darwin_xmm_reg + F__fpu_ymmh1 t__darwin_xmm_reg + F__fpu_ymmh2 t__darwin_xmm_reg + F__fpu_ymmh3 t__darwin_xmm_reg + F__fpu_ymmh4 t__darwin_xmm_reg + F__fpu_ymmh5 t__darwin_xmm_reg + F__fpu_ymmh6 t__darwin_xmm_reg + F__fpu_ymmh7 t__darwin_xmm_reg + F__fpu_ymmh8 t__darwin_xmm_reg + F__fpu_ymmh9 t__darwin_xmm_reg + F__fpu_ymmh10 t__darwin_xmm_reg + F__fpu_ymmh11 t__darwin_xmm_reg + F__fpu_ymmh12 t__darwin_xmm_reg + F__fpu_ymmh13 t__darwin_xmm_reg + F__fpu_ymmh14 t__darwin_xmm_reg + F__fpu_ymmh15 t__darwin_xmm_reg +} + +type t__darwin_x86_cpmu_state64 = struct { + F__ctrs [16]t__uint64_t +} + +type t__darwin_x86_debug_state32 = struct { + F__dr0 uint32 + F__dr1 uint32 + F__dr2 uint32 + F__dr3 uint32 + F__dr4 uint32 + F__dr5 uint32 + F__dr6 uint32 + F__dr7 uint32 +} + +type t__darwin_x86_debug_state64 = struct { + F__dr0 t__uint64_t + F__dr1 t__uint64_t + F__dr2 t__uint64_t + F__dr3 t__uint64_t + F__dr4 t__uint64_t + F__dr5 t__uint64_t + F__dr6 t__uint64_t + F__dr7 t__uint64_t +} + +type t__darwin_x86_exception_state64 = struct { + F__trapno t__uint16_t + F__cpu t__uint16_t + F__err t__uint32_t + F__faultvaddr t__uint64_t +} + +type t__darwin_x86_float_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw t__darwin_fp_control + F__fpu_fsw t__darwin_fp_status + F__fpu_ftw t__uint8_t + F__fpu_rsrv1 t__uint8_t + F__fpu_fop t__uint16_t + F__fpu_ip t__uint32_t + F__fpu_cs t__uint16_t + F__fpu_rsrv2 t__uint16_t + F__fpu_dp t__uint32_t + F__fpu_ds t__uint16_t + F__fpu_rsrv3 t__uint16_t + F__fpu_mxcsr t__uint32_t + F__fpu_mxcsrmask t__uint32_t + F__fpu_stmm0 t__darwin_mmst_reg + F__fpu_stmm1 t__darwin_mmst_reg + F__fpu_stmm2 t__darwin_mmst_reg + F__fpu_stmm3 t__darwin_mmst_reg + F__fpu_stmm4 t__darwin_mmst_reg + F__fpu_stmm5 t__darwin_mmst_reg + F__fpu_stmm6 t__darwin_mmst_reg + F__fpu_stmm7 t__darwin_mmst_reg + F__fpu_xmm0 t__darwin_xmm_reg + F__fpu_xmm1 t__darwin_xmm_reg + F__fpu_xmm2 t__darwin_xmm_reg + F__fpu_xmm3 t__darwin_xmm_reg + F__fpu_xmm4 t__darwin_xmm_reg + F__fpu_xmm5 t__darwin_xmm_reg + F__fpu_xmm6 t__darwin_xmm_reg + F__fpu_xmm7 t__darwin_xmm_reg + F__fpu_xmm8 t__darwin_xmm_reg + F__fpu_xmm9 t__darwin_xmm_reg + F__fpu_xmm10 t__darwin_xmm_reg + F__fpu_xmm11 t__darwin_xmm_reg + F__fpu_xmm12 t__darwin_xmm_reg + F__fpu_xmm13 t__darwin_xmm_reg + F__fpu_xmm14 t__darwin_xmm_reg + F__fpu_xmm15 t__darwin_xmm_reg + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 +} + +type t__darwin_x86_thread_full_state64 = struct { + F__ss64 t__darwin_x86_thread_state64 + F__ds t__uint64_t + F__es t__uint64_t + F__ss t__uint64_t + F__gsbase t__uint64_t +} + +type t__darwin_x86_thread_state64 = struct { + F__rax t__uint64_t + F__rbx t__uint64_t + F__rcx t__uint64_t + F__rdx t__uint64_t + F__rdi t__uint64_t + F__rsi t__uint64_t + F__rbp t__uint64_t + F__rsp t__uint64_t + F__r8 t__uint64_t + F__r9 t__uint64_t + F__r10 t__uint64_t + F__r11 t__uint64_t + F__r12 t__uint64_t + F__r13 t__uint64_t + F__r14 t__uint64_t + F__r15 t__uint64_t + F__rip t__uint64_t + F__rflags t__uint64_t + F__cs t__uint64_t + F__fs t__uint64_t + F__gs t__uint64_t +} + +type t__darwin_xmm_reg = struct { + F__xmm_reg [16]int8 +} + +type t__darwin_ymm_reg = struct { + F__ymm_reg [32]int8 +} + +type t__darwin_zmm_reg = struct { + F__zmm_reg [64]int8 +} + +type t__last_branch_record = struct { + F__from_ip t__uint64_t + F__to_ip t__uint64_t + F__ccgo16 uint32 +} + +type t__last_branch_state = struct { + F__lbr_count int32 + F__ccgo4 uint32 + F__lbrs [32]t__last_branch_record +} + +type t__x86_instruction_state = struct { + F__insn_stream_valid_bytes int32 + F__insn_offset int32 + F__out_of_synch int32 + F__insn_bytes [2380]t__uint8_t + F__insn_cacheline [64]t__uint8_t +} + +type t__x86_pagein_state = struct { + F__pagein_error int32 +} diff --git a/internal/engine/lib/sqlite_darwin_arm64.go b/internal/engine/lib/sqlite_darwin_arm64.go new file mode 100644 index 0000000..db2710b --- /dev/null +++ b/internal/engine/lib/sqlite_darwin_arm64.go @@ -0,0 +1,231 @@ +// Code generated for darwin/arm64 by 'generator --package-name libsqlite3 --prefix-enumerator=_ --prefix-external=x_ --prefix-field=F --prefix-static-internal=_ --prefix-static-none=_ --prefix-tagged-enum=_ --prefix-tagged-struct=T --prefix-tagged-union=T --prefix-typename=T --prefix-undefined=_ -ignore-unsupported-alignment -ignore-link-errors -import=sync -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DNDEBUG -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DISABLE_INTRINSIC -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_RBU -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_HAVE_ZLIB=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_WITHOUT_ZONEMALLOC -D_LARGEFILE64_SOURCE -I /Users/jnml/src/modernc.org/builder/.exclude/github.com/hanzoai/sqlite/internal/libc/include/darwin/arm64 -I /Users/jnml/src/modernc.org/builder/.exclude/modernc.org/libz/include/darwin/arm64 -I /Users/jnml/src/modernc.org/builder/.exclude/modernc.org/libtcl8.6/include/darwin/arm64 -extended-errors -o sqlite3.go sqlite3.c -DSQLITE_MUTEX_NOOP -DSQLITE_OS_UNIX=1 -eval-all-macros', DO NOT EDIT. + +//go:build darwin && arm64 + +package sqlite3 + +const MAXPHYS = 65536 + +const MAXPHYSIO = 65536 + +const NMBCLUSTERS = 0 + +const TARGET_ABI_USES_IOS_VALUES = 1 + +const TARGET_CPU_ARM64 = 1 + +const TARGET_CPU_X86_64 = 0 + +const TARGET_OS_ARROW = 1 + +type Tboolean_t = int32 + +type Tvm32_address_t = uint32 + +type Tvm32_offset_t = uint32 + +type Tvm32_size_t = uint32 + +const _ARM_SIGNAL_ = 1 + +const _DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 + +const _DARWIN_FEATURE_ONLY_VERS_1050 = 1 + +const __AARCH64_SIMD__ = 1 + +const __ARM64_ARCH_8__ = 1 + +const __ARM_ACLE = 202420 + +const __ARM_ARCH_8_2__ = 1 + +const __ARM_ARCH_8_3__ = 1 + +const __ARM_ARCH_8_4__ = 1 + +const __ARM_ARCH_8_5__ = 1 + +const __ARM_FEATURE_AES = 1 + +const __ARM_FEATURE_ATOMICS = 1 + +const __ARM_FEATURE_BTI = 1 + +const __ARM_FEATURE_COMPLEX = 1 + +const __ARM_FEATURE_CRC32 = 1 + +const __ARM_FEATURE_CRYPTO = 1 + +const __ARM_FEATURE_DOTPROD = 1 + +const __ARM_FEATURE_FP16_FML = 1 + +const __ARM_FEATURE_FP16_SCALAR_ARITHMETIC = 1 + +const __ARM_FEATURE_FP16_VECTOR_ARITHMETIC = 1 + +const __ARM_FEATURE_FRINT = 1 + +const __ARM_FEATURE_JCVT = 1 + +const __ARM_FEATURE_PAUTH = 1 + +const __ARM_FEATURE_QRDMX = 1 + +const __ARM_FEATURE_RCPC = 1 + +const __ARM_FEATURE_SHA2 = 1 + +const __ARM_FEATURE_SHA3 = 1 + +const __ARM_FEATURE_SHA512 = 1 + +const __ARM_NEON_SVE_BRIDGE = 1 + +const __DARWIN_ONLY_64_BIT_INO_T = 1 + +const __DARWIN_ONLY_VERS_1050 = 1 + +const __DARWIN_OPAQUE_ARM_THREAD_STATE64 = 0 + +const __FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL = 202430 + +const __OBJC_BOOL_IS_BOOL = 1 + +const __arm64 = 1 + +const __arm64__ = 1 + +type t__arm_legacy_debug_state = struct { + F__bvr [16]t__uint32_t + F__bcr [16]t__uint32_t + F__wvr [16]t__uint32_t + F__wcr [16]t__uint32_t +} + +type t__arm_pagein_state = struct { + F__pagein_error int32 +} + +type t__darwin_arm_cpmu_state64 = struct { + F__ctrs [16]t__uint64_t +} + +type t__darwin_arm_debug_state32 = struct { + F__bvr [16]t__uint32_t + F__bcr [16]t__uint32_t + F__wvr [16]t__uint32_t + F__wcr [16]t__uint32_t + F__mdscr_el1 t__uint64_t +} + +type t__darwin_arm_debug_state64 = struct { + F__bvr [16]t__uint64_t + F__bcr [16]t__uint64_t + F__wvr [16]t__uint64_t + F__wcr [16]t__uint64_t + F__mdscr_el1 t__uint64_t +} + +type t__darwin_arm_exception_state = struct { + F__exception t__uint32_t + F__fsr t__uint32_t + F__far t__uint32_t +} + +type t__darwin_arm_exception_state64 = struct { + F__far t__uint64_t + F__esr t__uint32_t + F__exception t__uint32_t +} + +type t__darwin_arm_exception_state64_v2 = struct { + F__far t__uint64_t + F__esr t__uint64_t +} + +type t__darwin_arm_neon_state = struct { + F__ccgo_align [0]uint64 + F__v [16][2]uint64 + F__fpsr t__uint32_t + F__fpcr t__uint32_t + F__ccgo_pad3 [8]byte +} + +type t__darwin_arm_neon_state64 = struct { + F__ccgo_align [0]uint64 + F__v [32][2]uint64 + F__fpsr t__uint32_t + F__fpcr t__uint32_t + F__ccgo_pad3 [8]byte +} + +type t__darwin_arm_sme2_state = struct { + F__ccgo_align [0]uint32 + F__zt0 [64]int8 +} + +type t__darwin_arm_sme_state = struct { + F__svcr t__uint64_t + F__tpidr2_el0 t__uint64_t + F__svl_b t__uint16_t +} + +type t__darwin_arm_sme_za_state = struct { + F__ccgo_align [0]uint32 + F__za [4096]int8 +} + +type t__darwin_arm_sve_p_state = struct { + F__ccgo_align [0]uint32 + F__p [16][32]int8 +} + +type t__darwin_arm_sve_z_state = struct { + F__ccgo_align [0]uint32 + F__z [16][256]int8 +} + +type t__darwin_arm_thread_state = struct { + F__r [13]t__uint32_t + F__sp t__uint32_t + F__lr t__uint32_t + F__pc t__uint32_t + F__cpsr t__uint32_t +} + +type t__darwin_arm_thread_state64 = struct { + F__x [29]t__uint64_t + F__fp t__uint64_t + F__lr t__uint64_t + F__sp t__uint64_t + F__pc t__uint64_t + F__cpsr t__uint32_t + F__pad t__uint32_t +} + +type t__darwin_arm_vfp_state = struct { + F__r [64]t__uint32_t + F__fpscr t__uint32_t +} + +type t__darwin_mcontext32 = struct { + F__es t__darwin_arm_exception_state + F__ss t__darwin_arm_thread_state + F__fs t__darwin_arm_vfp_state +} + +type t__darwin_mcontext64 = struct { + F__ccgo_align [0]uint64 + F__es t__darwin_arm_exception_state64 + F__ss t__darwin_arm_thread_state64 + F__ns t__darwin_arm_neon_state64 +} + +type vm32_address_t = Tvm32_address_t + +type vm32_offset_t = Tvm32_offset_t + +type vm32_size_t = Tvm32_size_t diff --git a/internal/engine/lib/sqlite_g_0000000000000003.go b/internal/engine/lib/sqlite_g_0000000000000003.go new file mode 100644 index 0000000..788e666 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000003.go @@ -0,0 +1,105292 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const ACCESSX_MAX_DESCRIPTORS = 100 + +const ACCESSX_MAX_TABLESIZE = 16384 + +const AF_CNT = 21 + +const AF_COIP = 20 + +const AF_E164 = 28 + +const AF_IEEE80211 = 37 + +const AF_INET6 = 30 + +const AF_IPX = 23 + +const AF_ISDN = 28 + +const AF_LINK = 18 + +const AF_LOCAL = 1 + +const AF_MAX = 41 + +const AF_NATM = 31 + +const AF_NDRV = 27 + +const AF_NETBIOS = 33 + +const AF_PPP = 34 + +const AF_RESERVED_36 = 36 + +const AF_ROUTE = 17 + +const AF_SIP = 24 + +const AF_SYSTEM = 32 + +const AF_UTUN = 38 + +const AF_VSOCK = 40 + +const ALIGNBYTES = -1 + +const APPLE_IF_FAM_BOND = 14 + +const APPLE_IF_FAM_CELLULAR = 15 + +const APPLE_IF_FAM_DISC = 8 + +const APPLE_IF_FAM_ETHERNET = 2 + +const APPLE_IF_FAM_FAITH = 11 + +const APPLE_IF_FAM_FIREWIRE = 13 + +const APPLE_IF_FAM_GIF = 10 + +const APPLE_IF_FAM_IPSEC = 18 + +const APPLE_IF_FAM_LOOPBACK = 1 + +const APPLE_IF_FAM_MDECAP = 9 + +const APPLE_IF_FAM_PPP = 6 + +const APPLE_IF_FAM_PVC = 7 + +const APPLE_IF_FAM_SLIP = 3 + +const APPLE_IF_FAM_STF = 12 + +const APPLE_IF_FAM_TUN = 4 + +const APPLE_IF_FAM_UNUSED_16 = 16 + +const APPLE_IF_FAM_UTUN = 17 + +const APPLE_IF_FAM_VLAN = 5 + +const AQ_BUFSZ = 32767 + +const AQ_HIWATER = 100 + +const AQ_LOWATER = 10 + +const AQ_MAXBUFSZ = 1048576 + +const AQ_MAXHIGH = 10000 + +const ARG_MAX = 1048576 + +const ATTRIBUTION_NAME_MAX = 255 + +const ATTR_BIT_MAP_COUNT = 5 + +const ATTR_BULK_REQUIRED = 2147483649 + +const ATTR_CMNEXT_ATTRIBUTION_TAG = 2048 + +const ATTR_CMNEXT_CLONEID = 256 + +const ATTR_CMNEXT_CLONE_REFCNT = 4096 + +const ATTR_CMNEXT_EXT_FLAGS = 512 + +const ATTR_CMNEXT_LINKID = 16 + +const ATTR_CMNEXT_NOFIRMLINKPATH = 32 + +const ATTR_CMNEXT_PRIVATESIZE = 8 + +const ATTR_CMNEXT_REALDEVID = 64 + +const ATTR_CMNEXT_REALFSID = 128 + +const ATTR_CMNEXT_RECURSIVE_GENCOUNT = 1024 + +const ATTR_CMNEXT_RELPATH = 4 + +const ATTR_CMNEXT_SETMASK = 0 + +const ATTR_CMNEXT_VALIDMASK = 8188 + +const ATTR_CMN_ACCESSMASK = 131072 + +const ATTR_CMN_ACCTIME = 4096 + +const ATTR_CMN_ADDEDTIME = 268435456 + +const ATTR_CMN_BKUPTIME = 8192 + +const ATTR_CMN_CHGTIME = 2048 + +const ATTR_CMN_CRTIME = 512 + +const ATTR_CMN_DATA_PROTECT_FLAGS = 1073741824 + +const ATTR_CMN_DEVID = 2 + +const ATTR_CMN_DOCUMENT_ID = 1048576 + +const ATTR_CMN_ERROR = 536870912 + +const ATTR_CMN_EXTENDED_SECURITY = 4194304 + +const ATTR_CMN_FILEID = 33554432 + +const ATTR_CMN_FLAGS = 262144 + +const ATTR_CMN_FNDRINFO = 16384 + +const ATTR_CMN_FSID = 4 + +const ATTR_CMN_FULLPATH = 134217728 + +const ATTR_CMN_GEN_COUNT = 524288 + +const ATTR_CMN_GRPID = 65536 + +const ATTR_CMN_GRPUUID = 16777216 + +const ATTR_CMN_MODTIME = 1024 + +const ATTR_CMN_NAME = 1 + +const ATTR_CMN_NAMEDATTRCOUNT = 524288 + +const ATTR_CMN_NAMEDATTRLIST = 1048576 + +const ATTR_CMN_OBJID = 32 + +const ATTR_CMN_OBJPERMANENTID = 64 + +const ATTR_CMN_OBJTAG = 16 + +const ATTR_CMN_OBJTYPE = 8 + +const ATTR_CMN_OWNERID = 32768 + +const ATTR_CMN_PARENTID = 67108864 + +const ATTR_CMN_PAROBJID = 128 + +const ATTR_CMN_RETURNED_ATTRS = 2147483648 + +const ATTR_CMN_SCRIPT = 256 + +const ATTR_CMN_SETMASK = 1372061440 + +const ATTR_CMN_USERACCESS = 2097152 + +const ATTR_CMN_UUID = 8388608 + +const ATTR_CMN_VALIDMASK = 4294967295 + +const ATTR_CMN_VOLSETMASK = 26368 + +const ATTR_DIR_ALLOCSIZE = 8 + +const ATTR_DIR_DATALENGTH = 32 + +const ATTR_DIR_ENTRYCOUNT = 2 + +const ATTR_DIR_IOBLOCKSIZE = 16 + +const ATTR_DIR_LINKCOUNT = 1 + +const ATTR_DIR_MOUNTSTATUS = 4 + +const ATTR_DIR_SETMASK = 0 + +const ATTR_DIR_VALIDMASK = 63 + +const ATTR_FILE_ALLOCSIZE = 4 + +const ATTR_FILE_CLUMPSIZE = 16 + +const ATTR_FILE_DATAALLOCSIZE = 1024 + +const ATTR_FILE_DATAEXTENTS = 2048 + +const ATTR_FILE_DATALENGTH = 512 + +const ATTR_FILE_DEVTYPE = 32 + +const ATTR_FILE_FILETYPE = 64 + +const ATTR_FILE_FORKCOUNT = 128 + +const ATTR_FILE_FORKLIST = 256 + +const ATTR_FILE_IOBLOCKSIZE = 8 + +const ATTR_FILE_LINKCOUNT = 1 + +const ATTR_FILE_RSRCALLOCSIZE = 8192 + +const ATTR_FILE_RSRCEXTENTS = 16384 + +const ATTR_FILE_RSRCLENGTH = 4096 + +const ATTR_FILE_SETMASK = 32 + +const ATTR_FILE_TOTALSIZE = 2 + +const ATTR_FILE_VALIDMASK = 14335 + +const ATTR_FORK_ALLOCSIZE = 2 + +const ATTR_FORK_RESERVED = 4294967295 + +const ATTR_FORK_SETMASK = 0 + +const ATTR_FORK_TOTALSIZE = 1 + +const ATTR_FORK_VALIDMASK = 3 + +const ATTR_MAX_BUFFER = 8192 + +const ATTR_MAX_BUFFER_LONGPATHS = 7168 + +const ATTR_VOL_ALLOCATIONCLUMP = 64 + +const ATTR_VOL_ATTRIBUTES = 1073741824 + +const ATTR_VOL_CAPABILITIES = 131072 + +const ATTR_VOL_DIRCOUNT = 1024 + +const ATTR_VOL_ENCODINGSUSED = 65536 + +const ATTR_VOL_FILECOUNT = 512 + +const ATTR_VOL_FSSUBTYPE = 2097152 + +const ATTR_VOL_FSTYPE = 1 + +const ATTR_VOL_FSTYPENAME = 1048576 + +const ATTR_VOL_INFO = 2147483648 + +const ATTR_VOL_IOBLOCKSIZE = 128 + +const ATTR_VOL_MAXOBJCOUNT = 2048 + +const ATTR_VOL_MINALLOCATION = 32 + +const ATTR_VOL_MOUNTEDDEVICE = 32768 + +const ATTR_VOL_MOUNTEXTFLAGS = 524288 + +const ATTR_VOL_MOUNTFLAGS = 16384 + +const ATTR_VOL_MOUNTPOINT = 4096 + +const ATTR_VOL_NAME = 8192 + +const ATTR_VOL_OBJCOUNT = 256 + +const ATTR_VOL_OWNER = 4194304 + +const ATTR_VOL_QUOTA_SIZE = 268435456 + +const ATTR_VOL_RESERVED_SIZE = 536870912 + +const ATTR_VOL_SETMASK = 2147491840 + +const ATTR_VOL_SIGNATURE = 2 + +const ATTR_VOL_SIZE = 4 + +const ATTR_VOL_SPACEAVAIL = 16 + +const ATTR_VOL_SPACEFREE = 8 + +const ATTR_VOL_SPACEUSED = 8388608 + +const ATTR_VOL_UUID = 262144 + +const ATTR_VOL_VALIDMASK = 4043309055 + +const AT_EACCESS = 16 + +const AT_FDCWD = -2 + +const AT_FDONLY = 1024 + +const AT_NODELETEBUSY = 16384 + +const AT_REALDEV = 512 + +const AT_REMOVEDIR = 128 + +const AT_SYMLINK_FOLLOW = 64 + +const AT_SYMLINK_NOFOLLOW = 32 + +const AT_SYMLINK_NOFOLLOW_ANY = 2048 + +const AT_UNIQUE = 32768 + +const AUC_AUDITING = 1 + +const AUC_DISABLED = -1 + +const AUC_NOAUDIT = 2 + +const AUC_UNSET = 0 + +const AUDITDEV_FILENAME = "audit" + +const AUDIT_AHLT = 2 + +const AUDIT_ARGE = 8 + +const AUDIT_ARGV = 4 + +const AUDIT_CNT = 1 + +const AUDIT_GROUP = 128 + +const AUDIT_HARD_LIMIT_FREE_BLOCKS = 4 + +const AUDIT_PATH = 512 + +const AUDIT_PERZONE = 8192 + +const AUDIT_PUBLIC = 2048 + +const AUDIT_RECORD_MAGIC = 2190085915 + +const AUDIT_SCNT = 1024 + +const AUDIT_SEQ = 16 + +const AUDIT_TRAIL = 256 + +const AUDIT_TRIGGER_CLOSE_AND_DIE = 4 + +const AUDIT_TRIGGER_EXPIRE_TRAILS = 8 + +const AUDIT_TRIGGER_INITIALIZE = 7 + +const AUDIT_TRIGGER_LOW_SPACE = 1 + +const AUDIT_TRIGGER_MAX = 8 + +const AUDIT_TRIGGER_MIN = 1 + +const AUDIT_TRIGGER_NO_SPACE = 5 + +const AUDIT_TRIGGER_READ_FILE = 3 + +const AUDIT_TRIGGER_ROTATE_KERNEL = 2 + +const AUDIT_TRIGGER_ROTATE_USER = 6 + +const AUDIT_USER = 64 + +const AUDIT_WINDATA = 32 + +const AUDIT_ZONENAME = 4096 + +const AUTH_OPEN_NOAUTHFD = -1 + +const AU_ASSIGN_ASID = -1 + +const AU_CLASS_MASK_RESERVED = 268435456 + +const AU_DEFAUDITSID = 0 + +const AU_FS_MINFREE = 20 + +const AU_IPv4 = 4 + +const AU_IPv6 = 16 + +const A_GETCAR = 9 + +const A_GETCLASS = 22 + +const A_GETCOND = 37 + +const A_GETCTLMODE = 41 + +const A_GETCWD = 8 + +const A_GETEXPAFTER = 43 + +const A_GETFSIZE = 27 + +const A_GETKAUDIT = 29 + +const A_GETKMASK = 4 + +const A_GETPINFO = 24 + +const A_GETPINFO_ADDR = 28 + +const A_GETPOLICY = 33 + +const A_GETQCTRL = 35 + +const A_GETSFLAGS = 39 + +const A_GETSINFO_ADDR = 32 + +const A_GETSTAT = 12 + +const A_OLDGETCOND = 20 + +const A_OLDGETPOLICY = 2 + +const A_OLDGETQCTRL = 6 + +const A_OLDSETCOND = 21 + +const A_OLDSETPOLICY = 3 + +const A_OLDSETQCTRL = 7 + +const A_SENDTRIGGER = 31 + +const A_SETCLASS = 23 + +const A_SETCOND = 38 + +const A_SETCTLMODE = 42 + +const A_SETEXPAFTER = 44 + +const A_SETFSIZE = 26 + +const A_SETKAUDIT = 30 + +const A_SETKMASK = 5 + +const A_SETPMASK = 25 + +const A_SETPOLICY = 34 + +const A_SETQCTRL = 36 + +const A_SETSFLAGS = 40 + +const A_SETSMASK = 15 + +const A_SETSTAT = 13 + +const A_SETUMASK = 14 + +const BADSIG = "SIG_ERR" + +const BC_BASE_MAX = 99 + +const BC_DIM_MAX = 2048 + +const BC_SCALE_MAX = 99 + +const BC_STRING_MAX = 1000 + +const BLKDEV_IOSIZE = 2048 + +const BSD = 199506 + +const BSD4_3 = 1 + +const BSD4_4 = 1 + +const BUS_ADRALN = 1 + +const BUS_ADRERR = 2 + +const BUS_NOOP = 0 + +const BUS_OBJERR = 3 + +type ByteRangeLockPB2 = TByteRangeLockPB2 + +const CBLOCK = 64 + +const CBQSIZE = 8 + +const CBSIZE = 56 + +const CHILD_MAX = 266 + +const CLBYTES = 4096 + +const CLD_CONTINUED = 6 + +const CLD_DUMPED = 3 + +const CLD_EXITED = 1 + +const CLD_KILLED = 2 + +const CLD_NOOP = 0 + +const CLD_STOPPED = 5 + +const CLD_TRAPPED = 4 + +const CLOCK_MONOTONIC = 0 + +const CLOCK_MONOTONIC_RAW = 0 + +const CLOCK_MONOTONIC_RAW_APPROX = 0 + +const CLOCK_PROCESS_CPUTIME_ID = 0 + +const CLOCK_THREAD_CPUTIME_ID = 0 + +const CLOCK_UPTIME_RAW = 0 + +const CLOCK_UPTIME_RAW_APPROX = 0 + +const CLOFF = 4095 + +const CLOFSET = 4095 + +const CLSHIFT = 12 + +const CLSIZE = 1 + +const CLSIZELOG2 = 0 + +const CMASK = 18 + +const CONNECT_DATA_AUTHENTICATED = 4 + +const CONNECT_DATA_IDEMPOTENT = 2 + +const CONNECT_RESUME_ON_READ_WRITE = 1 + +const CPF_IGNORE_MODE = 2 + +const CPF_MASK = 3 + +const CPF_OVERWRITE = 1 + +const CPUMON_MAKE_FATAL = 4096 + +const CRF_MAC_ENFORCE = 2 + +const CRF_NOMEMBERD = 1 + +const CROUND = 63 + +const CRYPTEX_AUTH_STRUCT_VERSION = 2 + +const DEV_BSHIFT = 9 + +const DEV_BSIZE = 512 + +const DIR_MNTSTATUS_MNTPOINT = 1 + +const DIR_MNTSTATUS_TRIGGER = 2 + +const DYNAMIC_TARGETS_ENABLED = 0 + +const EBADARCH = 86 + +const EBADEXEC = 85 + +const EBADMACHO = 88 + +const EBADMSG = 94 + +const ECANCELED = 89 + +const EDEVERR = 83 + +const EF_IS_PURGEABLE = 8 + +const EF_IS_SPARSE = 16 + +const EF_IS_SYNC_ROOT = 4 + +const EF_IS_SYNTHETIC = 32 + +const EF_MAY_SHARE_BLOCKS = 1 + +const EF_NO_XATTRS = 2 + +const EF_SHARES_ALL_BLOCKS = 64 + +const EIDRM = 90 + +const EILSEQ = 92 + +const ELAST = 107 + +const EMULTIHOP = 95 + +const ENODATA = 96 + +const ENOLINK = 97 + +const ENOMSG = 91 + +const ENOPOLICY = 103 + +const ENOSR = 98 + +const ENOSTR = 99 + +const ENOTCAPABLE = 107 + +const ENOTRECOVERABLE = 104 + +const EOPNOTSUPP = 102 + +const EOWNERDEAD = 105 + +const EPROTO = 100 + +const EPWROFF = 82 + +const EQFULL = 106 + +const EQUIV_CLASS_MAX = 2 + +const ESHLIBVERS = 87 + +const ETIME = 101 + +const FCNTL_FS_SPECIFIC_BASE = 65536 + +const FFDSYNC = 4194304 + +const FILESEC_GUID = 0 + +const FOOTPRINT_INTERVAL_RESET = 1 + +const FPE_FLTDIV = 1 + +const FPE_FLTINV = 5 + +const FPE_FLTOVF = 2 + +const FPE_FLTRES = 4 + +const FPE_FLTSUB = 6 + +const FPE_FLTUND = 3 + +const FPE_INTDIV = 7 + +const FPE_INTOVF = 8 + +const FPE_NOOP = 0 + +const FP_INFINITE = 2 + +const FP_QNAN = 1 + +const FP_SUBNORMAL = 5 + +const FP_SUPERNORMAL = 6 + +const FP_ZERO = 3 + +const FSCALE = 2048 + +const FSCRED = -1 + +const FSHIFT = 11 + +const FSOPT_ATTR_CMN_EXTENDED = 32 + +const FSOPT_NOFOLLOW = 1 + +const FSOPT_NOFOLLOW_ANY = 2048 + +const FSOPT_NOINMEMUPDATE = 2 + +const FSOPT_PACK_INVAL_ATTRS = 8 + +const FSOPT_REPORT_FULLSIZE = 4 + +const FSOPT_RESOLVE_BENEATH = 4096 + +const FSOPT_RETURN_REALDEV = 512 + +const FSOPT_UNIQUE = 8192 + +const FST_EOF = -1 + +const F_ADDFILESIGS = 61 + +const F_ADDFILESIGS_FOR_DYLD_SIM = 83 + +const F_ADDFILESIGS_INFO = 103 + +const F_ADDFILESIGS_RETURN = 97 + +const F_ADDFILESUPPL = 104 + +const F_ADDSIGS = 59 + +const F_ADDSIGS_MAIN_BINARY = 113 + +const F_ALLOCATEALL = 4 + +const F_ALLOCATECONTIG = 2 + +const F_ALLOCATEPERSIST = 8 + +const F_ATTRIBUTION_TAG = 111 + +const F_BARRIERFSYNC = 85 + +const F_CHECK_LV = 98 + +const F_CHKCLEAN = 41 + +const F_CREATE_TAG = 1 + +const F_DELETE_TAG = 2 + +const F_DUPFD_CLOEXEC = 67 + +const F_FINDSIGS = 78 + +const F_FLUSH_DATA = 40 + +const F_FREEZE_FS = 53 + +const F_FULLFSYNC = 51 + +const F_GETCODEDIR = 72 + +const F_GETLEASE = 107 + +const F_GETLKPID = 66 + +const F_GETNOSIGPIPE = 74 + +const F_GETPATH = 50 + +const F_GETPATH_MTMINFO = 71 + +const F_GETPATH_NOFIRMLINK = 102 + +const F_GETPROTECTIONCLASS = 63 + +const F_GETPROTECTIONLEVEL = 77 + +const F_GETSIGSINFO = 105 + +const F_GLOBAL_NOCACHE = 55 + +const F_LOG2PHYS = 49 + +const F_LOG2PHYS_EXT = 65 + +const F_NOCACHE = 48 + +const F_NOCACHE_EXT = 112 + +const F_NODIRECT = 62 + +const F_OFD_GETLK = 92 + +const F_OFD_SETLK = 90 + +const F_OFD_SETLKW = 91 + +const F_OFD_SETLKWTIMEOUT = 93 + +const F_PATHPKG_CHECK = 52 + +const F_PEOFPOSMODE = 3 + +const F_PREALLOCATE = 42 + +const F_PUNCHHOLE = 99 + +const F_QUERY_TAG = 4 + +const F_RDADVISE = 44 + +const F_RDAHEAD = 45 + +const F_SETBACKINGSTORE = 70 + +const F_SETLEASE = 106 + +const F_SETLKWTIMEOUT = 10 + +const F_SETNOSIGPIPE = 73 + +const F_SETPROTECTIONCLASS = 64 + +const F_SETSIZE = 43 + +const F_SINGLE_WRITER = 76 + +const F_SPECULATIVE_READ = 101 + +const F_THAW_FS = 54 + +const F_TRANSCODEKEY = 75 + +const F_TRANSFEREXTENTS = 110 + +const F_TRIM_ACTIVE_FILE = 100 + +const F_VOLPOSMODE = 4 + +const GETSIGSINFO_PLATFORM_BINARY = 1 + +const GRAFTDMG_SECURE_BOOT_CRYPTEX_ARGS_VERSION = 1 + +const GUARD_TYPE_MACH_PORT = 1 + +const HAVE_FULLFSYNC = 1 + +const IFCAP_AV = 256 + +const IFCAP_CSUM_PARTIAL = 8192 + +const IFCAP_CSUM_ZERO_INVERT = 16384 + +const IFCAP_HWCSUM = 3 + +const IFCAP_HW_TIMESTAMP = 2048 + +const IFCAP_JUMBO_MTU = 16 + +const IFCAP_LRO = 128 + +const IFCAP_LRO_NUM_SEG = 32768 + +const IFCAP_RXCSUM = 1 + +const IFCAP_SKYWALK = 1024 + +const IFCAP_SW_TIMESTAMP = 4096 + +const IFCAP_TSO = 96 + +const IFCAP_TSO4 = 32 + +const IFCAP_TSO6 = 64 + +const IFCAP_TXCSUM = 2 + +const IFCAP_TXSTATUS = 512 + +const IFCAP_VALID = 65535 + +const IFCAP_VLAN_HWTAGGING = 8 + +const IFCAP_VLAN_MTU = 4 + +const IFF_ALLMULTI = 512 + +const IFF_ALTPHYS = 16384 + +const IFF_BROADCAST = 2 + +const IFF_DEBUG = 4 + +const IFF_LINK0 = 4096 + +const IFF_LINK1 = 8192 + +const IFF_LINK2 = 16384 + +const IFF_LOOPBACK = 8 + +const IFF_MULTICAST = 32768 + +const IFF_NOARP = 128 + +const IFF_NOTRAILERS = 32 + +const IFF_OACTIVE = 1024 + +const IFF_POINTOPOINT = 16 + +const IFF_PROMISC = 256 + +const IFF_RUNNING = 64 + +const IFF_SIMPLEX = 2048 + +const IFF_UP = 1 + +const IFNAMSIZ = 16 + +const IFNET_SLOWHZ = 1 + +const IFQ_MAXLEN = 128 + +const IFRTYPE_FUNCTIONAL_CELLULAR = 5 + +const IFRTYPE_FUNCTIONAL_COMPANIONLINK = 7 + +const IFRTYPE_FUNCTIONAL_INTCOPROC = 6 + +const IFRTYPE_FUNCTIONAL_LAST = 8 + +const IFRTYPE_FUNCTIONAL_LOOPBACK = 1 + +const IFRTYPE_FUNCTIONAL_MANAGEMENT = 8 + +const IFRTYPE_FUNCTIONAL_UNKNOWN = 0 + +const IFRTYPE_FUNCTIONAL_WIFI_AWDL = 4 + +const IFRTYPE_FUNCTIONAL_WIFI_INFRA = 3 + +const IFRTYPE_FUNCTIONAL_WIRED = 2 + +const IFSTATMAX = 800 + +const IF_DATA_TIMEVAL = 0 + +const IF_MAXMTU = 65535 + +const IF_MINMTU = 72 + +const IF_NAMESIZE = 16 + +const IF_WAKE_ON_MAGIC_PACKET = 1 + +const ILL_BADSTK = 8 + +const ILL_COPROC = 7 + +const ILL_ILLADR = 5 + +const ILL_ILLOPC = 1 + +const ILL_ILLOPN = 4 + +const ILL_ILLTRP = 2 + +const ILL_NOOP = 0 + +const ILL_PRVOPC = 3 + +const ILL_PRVREG = 6 + +const IOPOL_APPLICATION = 5 + +const IOPOL_ATIME_UPDATES_DEFAULT = 0 + +const IOPOL_ATIME_UPDATES_OFF = 1 + +const IOPOL_DEFAULT = 0 + +const IOPOL_IMPORTANT = 1 + +const IOPOL_MATERIALIZE_DATALESS_FILES_BASIC_MASK = 3 + +const IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT = 0 + +const IOPOL_MATERIALIZE_DATALESS_FILES_OFF = 1 + +const IOPOL_MATERIALIZE_DATALESS_FILES_ON = 2 + +const IOPOL_MATERIALIZE_DATALESS_FILES_ORIG = 4 + +const IOPOL_NORMAL = 1 + +const IOPOL_PASSIVE = 2 + +const IOPOL_SCOPE_DARWIN_BG = 2 + +const IOPOL_SCOPE_PROCESS = 0 + +const IOPOL_SCOPE_THREAD = 1 + +const IOPOL_STANDARD = 5 + +const IOPOL_THROTTLE = 3 + +const IOPOL_TYPE_DISK = 0 + +const IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES = 9 + +const IOPOL_TYPE_VFS_ATIME_UPDATES = 2 + +const IOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY = 10 + +const IOPOL_TYPE_VFS_ENTITLED_RESERVE_ACCESS = 14 + +const IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION = 6 + +const IOPOL_TYPE_VFS_IGNORE_PERMISSIONS = 7 + +const IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES = 3 + +const IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE = 8 + +const IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME = 4 + +const IOPOL_TYPE_VFS_TRIGGER_RESOLVE = 5 + +const IOPOL_UTILITY = 4 + +const IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF = 0 + +const IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON = 1 + +const IOPOL_VFS_CONTENT_PROTECTION_DEFAULT = 0 + +const IOPOL_VFS_CONTENT_PROTECTION_IGNORE = 1 + +const IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT = 0 + +const IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON = 1 + +const IOPOL_VFS_ENTITLED_RESERVE_ACCESS_OFF = 0 + +const IOPOL_VFS_ENTITLED_RESERVE_ACCESS_ON = 1 + +const IOPOL_VFS_IGNORE_PERMISSIONS_OFF = 0 + +const IOPOL_VFS_IGNORE_PERMISSIONS_ON = 1 + +const IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT = 0 + +const IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON = 1 + +const IOPOL_VFS_SKIP_MTIME_UPDATE_IGNORE = 2 + +const IOPOL_VFS_SKIP_MTIME_UPDATE_OFF = 0 + +const IOPOL_VFS_SKIP_MTIME_UPDATE_ON = 1 + +const IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME = 1 + +const IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT = 0 + +const IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT = 0 + +const IOPOL_VFS_TRIGGER_RESOLVE_OFF = 1 + +const KEV_DL_ADDMULTI = 7 + +const KEV_DL_AWDL_RESTRICTED = 26 + +const KEV_DL_AWDL_UNRESTRICTED = 27 + +const KEV_DL_DELMULTI = 8 + +const KEV_DL_IFCAP_CHANGED = 19 + +const KEV_DL_IFDELEGATE_CHANGED = 25 + +const KEV_DL_IF_ATTACHED = 9 + +const KEV_DL_IF_DETACHED = 11 + +const KEV_DL_IF_DETACHING = 10 + +const KEV_DL_IF_IDLE_ROUTE_REFCNT = 18 + +const KEV_DL_ISSUES = 24 + +const KEV_DL_LINK_ADDRESS_CHANGED = 16 + +const KEV_DL_LINK_OFF = 12 + +const KEV_DL_LINK_ON = 13 + +const KEV_DL_LINK_QUALITY_METRIC_CHANGED = 20 + +const KEV_DL_LOW_POWER_MODE_CHANGED = 30 + +const KEV_DL_MASTER_ELECTED = 23 + +const KEV_DL_NODE_ABSENCE = 22 + +const KEV_DL_NODE_PRESENCE = 21 + +const KEV_DL_PRIMARY_ELECTED = 23 + +const KEV_DL_PROTO_ATTACHED = 14 + +const KEV_DL_PROTO_DETACHED = 15 + +const KEV_DL_QOS_MODE_CHANGED = 29 + +const KEV_DL_RRC_STATE_CHANGED = 28 + +const KEV_DL_SIFFLAGS = 1 + +const KEV_DL_SIFGENERIC = 6 + +const KEV_DL_SIFMEDIA = 5 + +const KEV_DL_SIFMETRICS = 2 + +const KEV_DL_SIFMTU = 3 + +const KEV_DL_SIFPHYS = 4 + +const KEV_DL_SUBCLASS = 2 + +const KEV_DL_WAKEFLAGS_CHANGED = 17 + +const KEV_INET6_ADDR_DELETED = 3 + +const KEV_INET6_CHANGED_ADDR = 2 + +const KEV_INET6_DEFROUTER = 6 + +const KEV_INET6_NEW_LL_ADDR = 4 + +const KEV_INET6_NEW_RTADV_ADDR = 5 + +const KEV_INET6_NEW_USER_ADDR = 1 + +const KEV_INET6_REQUEST_NAT64_PREFIX = 7 + +const KEV_INET6_SUBCLASS = 6 + +const KEV_INET_ADDR_DELETED = 3 + +const KEV_INET_ARPCOLLISION = 7 + +const KEV_INET_ARPRTRALIVE = 10 + +const KEV_INET_ARPRTRFAILURE = 9 + +const KEV_INET_CHANGED_ADDR = 2 + +const KEV_INET_NEW_ADDR = 1 + +const KEV_INET_PORTINUSE = 8 + +const KEV_INET_SIFBRDADDR = 5 + +const KEV_INET_SIFDSTADDR = 4 + +const KEV_INET_SIFNETMASK = 6 + +const KEV_INET_SUBCLASS = 1 + +const M16KCLBYTES = 16384 + +const M16KCLSHIFT = 14 + +const MACH_MSG_TYPE_INTEGER_T = 0 + +const MACH_PORT_CONNECTION_PORT_WITH_PORT_ARRAY = "com.apple.developer.allow-connection-port-with-port-array" + +const MACH_PORT_DENAP_RECEIVER = 6 + +const MACH_PORT_DNREQUESTS_SIZE = 3 + +const MACH_PORT_DNREQUESTS_SIZE_COUNT = 1 + +const MACH_PORT_GUARD_INFO = 8 + +const MACH_PORT_IMPORTANCE_RECEIVER = 5 + +const MACH_PORT_INFO_EXT = 7 + +const MACH_PORT_LIMITS_INFO = 1 + +const MACH_PORT_NULL = 0 + +const MACH_PORT_QLIMIT_BASIC = 5 + +const MACH_PORT_QLIMIT_DEFAULT = 5 + +const MACH_PORT_QLIMIT_KERNEL = 65534 + +const MACH_PORT_QLIMIT_LARGE = 1024 + +const MACH_PORT_QLIMIT_MAX = 1024 + +const MACH_PORT_QLIMIT_MIN = 0 + +const MACH_PORT_QLIMIT_SMALL = 16 + +const MACH_PORT_QLIMIT_ZERO = 0 + +const MACH_PORT_RECEIVE_STATUS = 2 + +const MACH_PORT_SERVICE_THROTTLED = 9 + +const MACH_PORT_SERVICE_THROTTLED_COUNT = 1 + +const MACH_PORT_SRIGHTS_NONE = 0 + +const MACH_PORT_SRIGHTS_PRESENT = 1 + +const MACH_PORT_STATUS_FLAG_GUARDED = 2 + +const MACH_PORT_STATUS_FLAG_GUARD_IMMOVABLE_RECEIVE = 64 + +const MACH_PORT_STATUS_FLAG_IMP_DONATION = 8 + +const MACH_PORT_STATUS_FLAG_NO_GRANT = 128 + +const MACH_PORT_STATUS_FLAG_REVIVE = 16 + +const MACH_PORT_STATUS_FLAG_STRICT_GUARD = 4 + +const MACH_PORT_STATUS_FLAG_TASKPTR = 32 + +const MACH_PORT_STATUS_FLAG_TEMPOWNER = 1 + +const MACH_PORT_TEMPOWNER = 4 + +const MACH_PORT_TYPE_DNREQUEST = 2147483648 + +const MACH_PORT_TYPE_SPREQUEST = 1073741824 + +const MACH_PORT_TYPE_SPREQUEST_DELAYED = 536870912 + +const MACH_PORT_WEAK_REPLY_ENTITLEMENT = "com.apple.private.allow-weak-reply-port" + +const MACH_SERVICE_PORT_INFO_STRING_NAME_MAX_BUF_LEN = 255 + +const MAC_OS_VERSION_11_0 = 110000 + +const MAC_OS_VERSION_11_1 = 110100 + +const MAC_OS_VERSION_11_3 = 110300 + +const MAC_OS_VERSION_11_4 = 110400 + +const MAC_OS_VERSION_11_5 = 110500 + +const MAC_OS_VERSION_11_6 = 110600 + +const MAC_OS_VERSION_12_0 = 120000 + +const MAC_OS_VERSION_12_1 = 120100 + +const MAC_OS_VERSION_12_2 = 120200 + +const MAC_OS_VERSION_12_3 = 120300 + +const MAC_OS_VERSION_12_4 = 120400 + +const MAC_OS_VERSION_12_5 = 120500 + +const MAC_OS_VERSION_12_6 = 120600 + +const MAC_OS_VERSION_12_7 = 120700 + +const MAC_OS_VERSION_13_0 = 130000 + +const MAC_OS_VERSION_13_1 = 130100 + +const MAC_OS_VERSION_13_2 = 130200 + +const MAC_OS_VERSION_13_3 = 130300 + +const MAC_OS_VERSION_13_4 = 130400 + +const MAC_OS_VERSION_13_5 = 130500 + +const MAC_OS_VERSION_13_6 = 130600 + +const MAC_OS_VERSION_13_7 = 130700 + +const MAC_OS_VERSION_14_0 = 140000 + +const MAC_OS_VERSION_14_1 = 140100 + +const MAC_OS_VERSION_14_2 = 140200 + +const MAC_OS_VERSION_14_3 = 140300 + +const MAC_OS_VERSION_14_4 = 140400 + +const MAC_OS_VERSION_14_5 = 140500 + +const MAC_OS_VERSION_14_6 = 140600 + +const MAC_OS_VERSION_14_7 = 140700 + +const MAC_OS_VERSION_15_0 = 150000 + +const MAC_OS_VERSION_15_1 = 150100 + +const MAC_OS_VERSION_15_2 = 150200 + +const MAC_OS_VERSION_15_3 = 150300 + +const MAC_OS_VERSION_15_4 = 150400 + +const MAC_OS_VERSION_15_5 = 150500 + +const MAC_OS_VERSION_15_6 = 150600 + +const MAC_OS_VERSION_16_0 = 160000 + +const MAC_OS_VERSION_26_0 = 260000 + +const MAC_OS_VERSION_26_1 = 260100 + +const MAC_OS_VERSION_26_2 = 260200 + +const MAC_OS_VERSION_26_3 = 260300 + +const MAC_OS_VERSION_26_4 = 260400 + +const MAC_OS_X_VERSION_10_0 = 1000 + +const MAC_OS_X_VERSION_10_1 = 1010 + +const MAC_OS_X_VERSION_10_10 = 101000 + +const MAC_OS_X_VERSION_10_10_2 = 101002 + +const MAC_OS_X_VERSION_10_10_3 = 101003 + +const MAC_OS_X_VERSION_10_11 = 101100 + +const MAC_OS_X_VERSION_10_11_2 = 101102 + +const MAC_OS_X_VERSION_10_11_3 = 101103 + +const MAC_OS_X_VERSION_10_11_4 = 101104 + +const MAC_OS_X_VERSION_10_12 = 101200 + +const MAC_OS_X_VERSION_10_12_1 = 101201 + +const MAC_OS_X_VERSION_10_12_2 = 101202 + +const MAC_OS_X_VERSION_10_12_4 = 101204 + +const MAC_OS_X_VERSION_10_13 = 101300 + +const MAC_OS_X_VERSION_10_13_1 = 101301 + +const MAC_OS_X_VERSION_10_13_2 = 101302 + +const MAC_OS_X_VERSION_10_13_4 = 101304 + +const MAC_OS_X_VERSION_10_14 = 101400 + +const MAC_OS_X_VERSION_10_14_1 = 101401 + +const MAC_OS_X_VERSION_10_14_4 = 101404 + +const MAC_OS_X_VERSION_10_14_5 = 101405 + +const MAC_OS_X_VERSION_10_14_6 = 101406 + +const MAC_OS_X_VERSION_10_15 = 101500 + +const MAC_OS_X_VERSION_10_15_1 = 101501 + +const MAC_OS_X_VERSION_10_15_4 = 101504 + +const MAC_OS_X_VERSION_10_16 = 101600 + +const MAC_OS_X_VERSION_10_2 = 1020 + +const MAC_OS_X_VERSION_10_3 = 1030 + +const MAC_OS_X_VERSION_10_4 = 1040 + +const MAC_OS_X_VERSION_10_5 = 1050 + +const MAC_OS_X_VERSION_10_6 = 1060 + +const MAC_OS_X_VERSION_10_7 = 1070 + +const MAC_OS_X_VERSION_10_8 = 1080 + +const MAC_OS_X_VERSION_10_9 = 1090 + +const MADV_CAN_REUSE = 9 + +const MADV_FREE_REUSABLE = 7 + +const MADV_FREE_REUSE = 8 + +const MADV_PAGEOUT = 10 + +const MADV_ZERO = 11 + +const MADV_ZERO_WIRED_PAGES = 6 + +const MAP_JIT = 2048 + +const MAP_NOCACHE = 1024 + +const MAP_NOEXTEND = 256 + +const MAP_RESILIENT_CODESIGN = 8192 + +const MAP_RESILIENT_MEDIA = 16384 + +const MAP_TPRO = 524288 + +const MAP_TRANSLATED_ALLOW_EXECUTE = 131072 + +const MAP_UNIX03 = 262144 + +const MAXAUDITDATA = 32767 + +const MAXBSIZE = 1048576 + +const MAXCOMLEN = 16 + +const MAXDOMNAMELEN = 256 + +const MAXFLOAT = 0 + +const MAXFRAG = 8 + +const MAXHOSTNAMELEN = 256 + +const MAXINTERP = 64 + +const MAXLOGNAME = 255 + +const MAXPATHLEN = 1024 + +const MAXPHYSIO_WIRED = 16777216 + +const MAXPRI = 127 + +const MAXSYMLINKS = 32 + +const MAXUPRC = 266 + +const MAX_AUDIT_RECORDS = 20 + +const MAX_AUDIT_RECORD_SIZE = 32767 + +const MAX_CANON = 1024 + +const MAX_FATAL_kGUARD_EXC_CODE = 0 + +const MAX_GRAFT_ARGS_SIZE = 512 + +const MAX_INPUT = 1024 + +const MAX_OPTIONAL_kGUARD_EXC_CODE = 0 + +const MBIGCLBYTES = 4096 + +const MBIGCLSHIFT = 12 + +const MB_LEN_MAX = 1 + +const MCLBYTES = 2048 + +const MCLOFSET = 2047 + +const MCLSHIFT = 11 + +const MFSNAMELEN = 15 + +const MFSTYPENAMELEN = 16 + +const MINCORE_ANONYMOUS = 128 + +const MINCORE_COPIED = 64 + +const MINCORE_PAGED_OUT = 32 + +const MINSIGSTKSZ = 32768 + +const MIN_AUDIT_FILE_SIZE = 524288 + +const MNAMELEN = 1024 + +const MNT_ASYNC = 64 + +const MNT_AUTOMOUNTED = 4194304 + +const MNT_CMDFLAGS = 983040 + +const MNT_CPROTECT = 128 + +const MNT_DEFWRITE = 33554432 + +const MNT_DONTBROWSE = 1048576 + +const MNT_DOVOLFS = 32768 + +const MNT_DWAIT = 4 + +const MNT_EXPORTED = 256 + +const MNT_EXT_FSKIT = 2 + +const MNT_EXT_ROOT_DATA_VOL = 1 + +const MNT_FORCE = 524288 + +const MNT_IGNORE_OWNERSHIP = 2097152 + +const MNT_JOURNALED = 8388608 + +const MNT_LOCAL = 4096 + +const MNT_MULTILABEL = 67108864 + +const MNT_NOATIME = 268435456 + +const MNT_NOBLOCK = 131072 + +const MNT_NODEV = 16 + +const MNT_NOEXEC = 4 + +const MNT_NOFOLLOW = 134217728 + +const MNT_NOSUID = 8 + +const MNT_NOUSERXATTR = 16777216 + +const MNT_NOWAIT = 2 + +const MNT_QUARANTINE = 1024 + +const MNT_QUOTA = 8192 + +const MNT_RDONLY = 1 + +const MNT_RELOAD = 262144 + +const MNT_REMOVABLE = 512 + +const MNT_ROOTFS = 16384 + +const MNT_SNAPSHOT = 1073741824 + +const MNT_STRICTATIME = 2147483648 + +const MNT_SYNCHRONOUS = 2 + +const MNT_UNION = 32 + +const MNT_UNKNOWNPERMISSIONS = 2097152 + +const MNT_UPDATE = 65536 + +const MNT_VISFLAGMASK = 3757111295 + +const MNT_WAIT = 1 + +const MPG_FLAGS_INVALID_OPTIONS_OOL_ARRAYS = 2 + +const MPG_FLAGS_INVALID_OPTIONS_OOL_DISP = 1 + +const MPG_FLAGS_INVALID_OPTIONS_OOL_RIGHT = 3 + +const MPG_FLAGS_INVALID_RIGHT_COPYIN = 4 + +const MPG_FLAGS_INVALID_RIGHT_DEALLOC = 5 + +const MPG_FLAGS_INVALID_RIGHT_DEALLOC_KERNEL = 6 + +const MPG_FLAGS_INVALID_RIGHT_DELTA = 2 + +const MPG_FLAGS_INVALID_RIGHT_DESTRUCT = 3 + +const MPG_FLAGS_INVALID_RIGHT_RECV = 1 + +const MPG_FLAGS_INVALID_RIGHT_TRANSLATE_PORT = 7 + +const MPG_FLAGS_INVALID_RIGHT_TRANSLATE_PSET = 8 + +const MPG_FLAGS_INVALID_VALUE_DELTA = 2 + +const MPG_FLAGS_INVALID_VALUE_DESTRUCT = 3 + +const MPG_FLAGS_INVALID_VALUE_PEEK = 1 + +const MPG_FLAGS_KERN_FAILURE_MULTI_NOTI = 4 + +const MPG_FLAGS_KERN_FAILURE_NOTIFY_RECV = 3 + +const MPG_FLAGS_KERN_FAILURE_NOTIFY_TYPE = 2 + +const MPG_FLAGS_KERN_FAILURE_TASK = 1 + +const MPG_FLAGS_MOD_REFS_PINNED_COPYIN = 3 + +const MPG_FLAGS_MOD_REFS_PINNED_DEALLOC = 1 + +const MPG_FLAGS_MOD_REFS_PINNED_DESTROY = 2 + +const MPG_FLAGS_NONE = 0 + +const MPG_FLAGS_SEND_INVALID_RIGHT_GUARDED = 3 + +const MPG_FLAGS_SEND_INVALID_RIGHT_OOL_PORT = 2 + +const MPG_FLAGS_SEND_INVALID_RIGHT_PORT = 1 + +const MPG_FLAGS_STRICT_REPLY_INVALID_VOUCHER = 4 + +const MPG_FLAGS_STRICT_REPLY_MISMATCHED_PERSONA = 16 + +const MPG_IMMOVABLE_RECEIVE = 2 + +const MPG_STRICT = 1 + +const MPO_CONTEXT_AS_GUARD = 1 + +const MPO_DENAP_RECEIVER = 64 + +const MPO_ENFORCE_REPLY_PORT_SEMANTICS = 8192 + +const MPO_FILTER_MSG = 256 + +const MPO_IMMOVABLE_RECEIVE = 128 + +const MPO_IMPORTANCE_RECEIVER = 8 + +const MPO_INSERT_SEND_RIGHT = 16 + +const MPO_OPTIONS_MASK = 9215 + +const MPO_PORT_TYPE_MASK = 121856 + +const MPO_PROVISIONAL_REPLY_PORT = 0 + +const MPO_QLIMIT = 2 + +const MPO_STRICT = 32 + +const MPO_STRICT_SERVICE_PORT = 8192 + +const MPO_TEMPOWNER = 4 + +const MPO_TG_BLOCK_TRACKING = 512 + +const MPO_UNUSED_BITS = -131072 + +const MSG_CTRUNC = 32 + +const MSG_DONTWAIT = 128 + +const MSG_EOF = 256 + +const MSG_EOR = 8 + +const MSG_FLUSH = 1024 + +const MSG_HAVEMORE = 8192 + +const MSG_HOLD = 2048 + +const MSG_NEEDSA = 65536 + +const MSG_NOSIGNAL = 524288 + +const MSG_RCVMORE = 16384 + +const MSG_SEND = 4096 + +const MSG_TRUNC = 16 + +const MSG_WAITALL = 64 + +const MSG_WAITSTREAM = 512 + +const MSIZE = 256 + +const MSIZESHIFT = 8 + +const MS_DEACTIVATE = 8 + +const MS_KILLPAGES = 4 + +const MS_SYNC = 16 + +const NAME_MAX = 255 + +const NBPG = 4096 + +const NBPW = 0 + +const NCARGS = 1048576 + +const NETSVC_MRKNG_LVL_L2 = 1 + +const NETSVC_MRKNG_LVL_L3L2_ALL = 2 + +const NETSVC_MRKNG_LVL_L3L2_BK = 3 + +const NETSVC_MRKNG_UNKNOWN = 0 + +const NET_MAXID = 41 + +const NET_RT_DUMP = 1 + +const NET_RT_DUMP2 = 7 + +const NET_RT_FLAGS = 2 + +const NET_RT_FLAGS_PRIV = 10 + +const NET_RT_IFLIST = 3 + +const NET_RT_IFLIST2 = 6 + +const NET_RT_MAXID = 11 + +const NET_RT_STAT = 4 + +const NET_RT_TRASH = 5 + +const NET_SERVICE_TYPE_AV = 6 + +const NET_SERVICE_TYPE_BE = 0 + +const NET_SERVICE_TYPE_BK = 1 + +const NET_SERVICE_TYPE_OAM = 7 + +const NET_SERVICE_TYPE_RD = 8 + +const NET_SERVICE_TYPE_RV = 5 + +const NET_SERVICE_TYPE_SIG = 2 + +const NET_SERVICE_TYPE_VI = 3 + +const NET_SERVICE_TYPE_VO = 4 + +const NFSV2_MAX_FH_SIZE = 32 + +const NFSV3_MAX_FH_SIZE = 64 + +const NFSV4_MAX_FH_SIZE = 128 + +const NFS_MAX_FH_SIZE = 128 + +const NGROUPS = 16 + +const NOFILE = 256 + +const NOGROUP = 65535 + +const NSIG = 32 + +const NeXTBSD = 1995064 + +const NeXTBSD4_0 = 0 + +const OPEN_MAX = 10240 + +const OS_ASSUME_PTR_ABI_SINGLE_BEGIN = 0 + +const OS_ASSUME_PTR_ABI_SINGLE_END = 0 + +const OS_HEADER_INDEXABLE = 0 + +const OS_UNSAFE_INDEXABLE = 0 + +const O_ALERT = 536870912 + +const O_CLOEXEC = 16777216 + +const O_DIRECTORY = 1048576 + +const O_DP_AUTHENTICATE = 4 + +const O_DP_GETRAWENCRYPTED = 1 + +const O_DP_GETRAWUNENCRYPTED = 2 + +const O_DSYNC = 4194304 + +const O_EVTONLY = 32768 + +const O_EXEC = 1073741824 + +const O_NOCTTY = 131072 + +const O_NOFOLLOW_ANY = 536870912 + +const O_POPUP = 2147483648 + +const O_RESOLVE_BENEATH = 4096 + +const O_SEARCH = 1074790400 + +const O_SYMLINK = 2097152 + +const O_UNIQUE = 8192 + +const PCATCH = 256 + +const PDROP = 1024 + +const PF_CNT = 21 + +const PF_COIP = 20 + +const PF_INET6 = 30 + +const PF_IPX = 23 + +const PF_ISDN = 28 + +const PF_KEY = 29 + +const PF_LINK = 18 + +const PF_LOCAL = 1 + +const PF_MAX = 41 + +const PF_NATM = 31 + +const PF_NDRV = 27 + +const PF_NETBIOS = 33 + +const PF_PIP = 25 + +const PF_PPP = 34 + +const PF_RESERVED_36 = 36 + +const PF_ROUTE = 17 + +const PF_RTIP = 22 + +const PF_SIP = 24 + +const PF_SYSTEM = 32 + +const PF_UTUN = 38 + +const PF_VSOCK = 40 + +const PF_XTP = 19 + +const PGOFSET = 4095 + +const PGSHIFT = 12 + +const PINOD = 8 + +const PLOCK = 36 + +const POLL_ERR = 4 + +const POLL_HUP = 6 + +const POLL_IN = 1 + +const POLL_MSG = 3 + +const POLL_OUT = 2 + +const POLL_PRI = 5 + +const PPAUSE = 40 + +const PRIBIO = 16 + +const PRIMASK = 255 + +const PRIO_DARWIN_BG = 4096 + +const PRIO_DARWIN_NONUI = 4097 + +const PRIO_DARWIN_PROCESS = 4 + +const PRIO_DARWIN_THREAD = 3 + +const PRIO_MAX = 20 + +const PRIO_MIN = -20 + +const PRIO_PGRP = 1 + +const PRIO_PROCESS = 0 + +const PRIO_USER = 2 + +const PROXY_CONCHVERSION = 2 + +const PROXY_HEADERLEN = 1 + +const PROXY_HOSTIDLEN = 16 + +const PROXY_MAXCONCHLEN = 1041 + +const PROXY_PATHINDEX = 17 + +const PSOCK = 24 + +const PSPIN = 2048 + +const PSWP = 0 + +const PTTYBLOCK = 512 + +const PUSER = 50 + +const PVFS = 20 + +const PVM = 4 + +const PWAIT = 32 + +const PZERO = 22 + +const P_tmpdir = "/var/tmp/" + +const RENAME_EXCL = 4 + +const RENAME_NOFOLLOW_ANY = 16 + +const RENAME_RESERVED1 = 8 + +const RENAME_RESOLVE_BENEATH = 32 + +const RENAME_SECLUDE = 1 + +const RENAME_SWAP = 2 + +const RLIMIT_AS = 5 + +const RLIMIT_CORE = 4 + +const RLIMIT_CPU = 0 + +const RLIMIT_CPU_USAGE_MONITOR = 2 + +const RLIMIT_DATA = 2 + +const RLIMIT_FOOTPRINT_INTERVAL = 4 + +const RLIMIT_FSIZE = 1 + +const RLIMIT_MEMLOCK = 6 + +const RLIMIT_NOFILE = 8 + +const RLIMIT_NPROC = 7 + +const RLIMIT_RSS = 5 + +const RLIMIT_STACK = 3 + +const RLIMIT_THREAD_CPULIMITS = 3 + +const RLIMIT_WAKEUPS_MONITOR = 1 + +const RLIM_NLIMITS = 9 + +const RLIM_SAVED_CUR = "RLIM_INFINITY" + +const RLIM_SAVED_MAX = "RLIM_INFINITY" + +const RTLD_FIRST = 256 + +const RTLD_GLOBAL = 8 + +const RTLD_LOCAL = 4 + +const RTLD_MAIN_ONLY = -5 + +const RTLD_NODELETE = 128 + +const RTLD_NOLOAD = 16 + +const RUSAGE_CHILDREN = -1 + +const RUSAGE_INFO_CURRENT = 6 + +const RUSAGE_INFO_V0 = 0 + +const RUSAGE_INFO_V1 = 1 + +const RUSAGE_INFO_V2 = 2 + +const RUSAGE_INFO_V3 = 3 + +const RUSAGE_INFO_V4 = 4 + +const RUSAGE_INFO_V5 = 5 + +const RUSAGE_INFO_V6 = 6 + +const RUSAGE_SELF = 0 + +const RU_PROC_RUNS_RESLIDE = 1 + +const SAE_ASSOCID_ANY = 0 + +const SAE_CONNID_ANY = 0 + +const SA_64REGSET = 512 + +const SA_NOCLDSTOP = 8 + +const SA_NOCLDWAIT = 32 + +const SA_NODEFER = 16 + +const SA_ONSTACK = 1 + +const SA_RESETHAND = 4 + +const SA_RESTART = 2 + +const SA_SIGINFO = 64 + +const SA_USERSPACE_MASK = 127 + +const SA_USERTRAMP = 256 + +const SBC_ALTERNATE_SHARED_REGION = 2 + +const SBC_PANIC_ON_AUTHFAIL = 8 + +const SBC_PRESERVE_GRAFT = 32 + +const SBC_PRESERVE_MOUNT = 1 + +const SBC_STRICT_AUTH = 16 + +const SBC_SYSTEM_CONTENT = 4 + +const SCM_CREDS = 3 + +const SCM_RIGHTS = 1 + +const SCM_TIMESTAMP = 2 + +const SCM_TIMESTAMP_MONOTONIC = 4 + +const SEARCHFS_MAX_SEARCHPARMS = 4096 + +const SEEK_DATA = 4 + +const SEEK_HOLE = 3 + +const SEGV_ACCERR = 2 + +const SEGV_MAPERR = 1 + +const SEGV_NOOP = 0 + +const SF_DATALESS = 1073741824 + +const SF_FIRMLINK = 8388608 + +const SF_RESTRICTED = 524288 + +const SF_SETTABLE = 1073676288 + +const SF_SUPPORTED = 10420224 + +const SF_SYNTHETIC = 3221225472 + +const SHUT_RD = 0 + +const SHUT_RDWR = 2 + +const SHUT_WR = 1 + +const SIGABRT = 6 + +const SIGALRM = 14 + +const SIGBUS = 10 + +const SIGCHLD = 20 + +const SIGCONT = 19 + +const SIGEMT = 7 + +const SIGEV_KEVENT = 4 + +const SIGEV_NONE = 0 + +const SIGEV_SIGNAL = 1 + +const SIGEV_THREAD = 3 + +const SIGFPE = 8 + +const SIGHUP = 1 + +const SIGILL = 4 + +const SIGINFO = 29 + +const SIGINT = 2 + +const SIGIO = 23 + +const SIGIOT = 6 + +const SIGKILL = 9 + +const SIGPIPE = 13 + +const SIGPROF = 27 + +const SIGQUIT = 3 + +const SIGSEGV = 11 + +const SIGSTKSZ = 131072 + +const SIGSTOP = 17 + +const SIGSYS = 12 + +const SIGTERM = 15 + +const SIGTRAP = 5 + +const SIGTSTP = 18 + +const SIGTTIN = 21 + +const SIGTTOU = 22 + +const SIGURG = 16 + +const SIGUSR1 = 30 + +const SIGUSR2 = 31 + +const SIGVTALRM = 26 + +const SIGWINCH = 28 + +const SIGXCPU = 24 + +const SIGXFSZ = 25 + +const SIG_BLOCK = 1 + +const SIG_SETMASK = 3 + +const SIG_UNBLOCK = 2 + +const SIOCGETVLAN = "SIOCGIFVLAN" + +const SIOCSETVLAN = "SIOCSIFVLAN" + +const SI_ASYNCIO = 65540 + +const SI_MESGQ = 65541 + +const SI_QUEUE = 65538 + +const SI_TIMER = 65539 + +const SI_USER = 65537 + +const SOCK_MAXADDRLEN = 255 + +const SOMAXCONN = 128 + +const SONPX_SETOPTSHUT = 1 + +const SO_BINDTODEVICE = 4404 + +const SO_DONTTRUNC = 8192 + +const SO_LABEL = 4112 + +const SO_LINGER_SEC = 4224 + +const SO_NETSVC_MARKING_LEVEL = 4377 + +const SO_NET_SERVICE_TYPE = 4374 + +const SO_NKE = 4129 + +const SO_NOADDRERR = 4131 + +const SO_NOSIGPIPE = 4130 + +const SO_NOTIFYCONFLICT = 4134 + +const SO_NP_EXTENSIONS = 4227 + +const SO_NREAD = 4128 + +const SO_NUMRCVPKT = 4370 + +const SO_NWRITE = 4132 + +const SO_PEERLABEL = 4113 + +const SO_RANDOMPORT = 4226 + +const SO_RESOLVER_SIGNATURE = 4401 + +const SO_REUSEPORT = 512 + +const SO_REUSESHAREUID = 4133 + +const SO_TIMESTAMP = 1024 + +const SO_TIMESTAMP_MONOTONIC = 2048 + +const SO_UPCALLCLOSEWAIT = 4135 + +const SO_WANTMORE = 16384 + +const SO_WANTOOBFLAG = 32768 + +const SQLITE_ENABLE_LOCKING_STYLE = 1 + +const SRCHFS_MATCHDIRS = 4 + +const SRCHFS_MATCHFILES = 8 + +const SRCHFS_MATCHPARTIALNAMES = 2 + +const SRCHFS_NEGATEPARAMS = 2147483648 + +const SRCHFS_NOFOLLOW = 256 + +const SRCHFS_NOFOLLOW_ANY = 512 + +const SRCHFS_SKIPINAPPROPRIATE = 128 + +const SRCHFS_SKIPINVISIBLE = 32 + +const SRCHFS_SKIPLINKS = 16 + +const SRCHFS_SKIPPACKAGES = 64 + +const SRCHFS_START = 1 + +const SRCHFS_VALIDOPTIONSMASK = 2147484671 + +const SS_DISABLE = 4 + +const SS_ONSTACK = 1 + +const SV_INTERRUPT = 2 + +const SV_NOCLDSTOP = 8 + +const SV_NODEFER = 16 + +const SV_ONSTACK = 1 + +const SV_RESETHAND = 4 + +const SV_SIGINFO = 64 + +const SYNC_VOLUME_FULLSYNC = 1 + +const SYNC_VOLUME_WAIT = 2 + +const TARGET_CPU_68K = 0 + +const TARGET_CPU_ALPHA = 0 + +const TARGET_CPU_ARM = 0 + +const TARGET_CPU_MIPS = 0 + +const TARGET_CPU_PPC = 0 + +const TARGET_CPU_PPC64 = 0 + +const TARGET_CPU_SPARC = 0 + +const TARGET_CPU_X86 = 0 + +const TARGET_IPHONE_SIMULATOR = 0 + +const TARGET_OS_BRIDGE = 0 + +const TARGET_OS_DRIVERKIT = 0 + +const TARGET_OS_EMBEDDED = 0 + +const TARGET_OS_IOS = 0 + +const TARGET_OS_IOSMAC = 0 + +const TARGET_OS_IPHONE = 0 + +const TARGET_OS_LINUX = 0 + +const TARGET_OS_MAC = 1 + +const TARGET_OS_MACCATALYST = 0 + +const TARGET_OS_NANO = 0 + +const TARGET_OS_OSX = 1 + +const TARGET_OS_RTKIT = 0 + +const TARGET_OS_SIMULATOR = 0 + +const TARGET_OS_TV = 0 + +const TARGET_OS_UEFI = 0 + +const TARGET_OS_UIKITFORMAC = 0 + +const TARGET_OS_UNIX = 0 + +const TARGET_OS_VISION = 0 + +const TARGET_OS_WATCH = 0 + +const TARGET_OS_WIN32 = 0 + +const TARGET_OS_WINDOWS = 0 + +const TARGET_OS_XR = 0 + +const TARGET_RT_64_BIT = 1 + +const TARGET_RT_BIG_ENDIAN = 0 + +const TARGET_RT_LITTLE_ENDIAN = 1 + +const TARGET_RT_MAC_CFM = 0 + +const TARGET_RT_MAC_MACHO = 1 + +type TByteRangeLockPB2 = struct { + Foffset uint64 + Flength uint64 + FretRangeStart uint64 + FunLockFlag uint8 + FstartEndFlag uint8 + Ffd int32 +} + +type TFILE = struct { + F_p uintptr + F_r int32 + F_w int32 + F_flags int16 + F_file int16 + F_bf t__sbuf + F_lbfsize int32 + F_cookie uintptr + F_close uintptr + F_read uintptr + F_seek uintptr + F_write uintptr + F_ub t__sbuf + F_extra uintptr + F_ur int32 + F_ubuf [3]uint8 + F_nbuf [1]uint8 + F_lb t__sbuf + F_blksize int32 + F_offset Tfpos_t +} + +const TRAP_BRKPT = 1 + +const TRAP_TRACE = 2 + +type T_RuneCharClass = struct { + F__name [14]int8 + F__mask t__uint32_t +} + +type T_RuneEntry = struct { + F__min t__darwin_rune_t + F__max t__darwin_rune_t + F__map t__darwin_rune_t + F__types uintptr +} + +type T_RuneLocale = struct { + F__magic [8]int8 + F__encoding [32]int8 + F__sgetrune uintptr + F__sputrune uintptr + F__invalid_rune t__darwin_rune_t + F__runetype [256]t__uint32_t + F__maplower [256]t__darwin_rune_t + F__mapupper [256]t__darwin_rune_t + F__runetype_ext T_RuneRange + F__maplower_ext T_RuneRange + F__mapupper_ext T_RuneRange + F__variable uintptr + F__variable_len int32 + F__ncharclasses int32 + F__charclasses uintptr +} + +type T_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} + +type T_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} + +type T_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type T_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} + +type T_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type T_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type T_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} + +type T_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} + +type T_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} + +type Taccessx_descriptor = struct { + Fad_name_offset uint32 + Fad_flags int32 + Fad_pad [2]int32 +} + +// C documentation +// +// /* +// ** The afpLockingContext structure contains all afp lock specific state +// */ +type TafpLockingContext = struct { + Freserved int32 + FdbPath uintptr +} + +type Tattrgroup_t = uint32 + +type Tattribute_set = Tattribute_set_t + +type Tattribute_set_t = struct { + Fcommonattr Tattrgroup_t + Fvolattr Tattrgroup_t + Fdirattr Tattrgroup_t + Ffileattr Tattrgroup_t + Fforkattr Tattrgroup_t +} + +type Tattrlist = struct { + Fbitmapcount Tu_short + Freserved Tu_int16_t + Fcommonattr Tattrgroup_t + Fvolattr Tattrgroup_t + Fdirattr Tattrgroup_t + Ffileattr Tattrgroup_t + Fforkattr Tattrgroup_t +} + +type Tattrreference = Tattrreference_t + +type Tattrreference_t = struct { + Fattr_dataoffset Tint32_t + Fattr_length Tu_int32_t +} + +type Tau_asflgs_t = uint64 + +type Tau_asid_t = int32 + +type Tau_class_t = uint32 + +type Tau_ctlmode_t = uint8 + +type Tau_emod_t = uint16 + +type Tau_evclass_map = struct { + Fec_number Tau_event_t + Fec_class Tau_class_t +} + +type Tau_evclass_map_t = struct { + Fec_number Tau_event_t + Fec_class Tau_class_t +} + +type Tau_event_t = uint16 + +type Tau_expire_after = struct { + Fage Ttime_t + Fsize Tsize_t + Fop_type uint8 +} + +type Tau_expire_after_t = struct { + Fage Ttime_t + Fsize Tsize_t + Fop_type uint8 +} + +type Tau_fstat_t = struct { + Faf_filesz Tu_int64_t + Faf_currsz Tu_int64_t +} + +type Tau_id_t = uint32 + +type Tau_mask = struct { + Fam_success uint32 + Fam_failure uint32 +} + +type Tau_mask_t = struct { + Fam_success uint32 + Fam_failure uint32 +} + +type Tau_qctrl = struct { + Faq_hiwater int32 + Faq_lowater int32 + Faq_bufsz int32 + Faq_delay int32 + Faq_minfree int32 +} + +type Tau_qctrl_t = struct { + Faq_hiwater int32 + Faq_lowater int32 + Faq_bufsz int32 + Faq_delay int32 + Faq_minfree int32 +} + +type Tau_session = struct { + Fas_aia_p uintptr + Fas_mask Tau_mask_t +} + +type Tau_session_t = struct { + Fas_aia_p uintptr + Fas_mask Tau_mask_t +} + +type Tau_stat_t = struct { + Fas_version uint32 + Fas_numevent uint32 + Fas_generated int32 + Fas_nonattrib int32 + Fas_kernel int32 + Fas_audit int32 + Fas_auditctl int32 + Fas_enqueue int32 + Fas_written int32 + Fas_wblocked int32 + Fas_rblocked int32 + Fas_dropped int32 + Fas_totalsize int32 + Fas_memused uint32 +} + +type Tau_tid = struct { + Fport Tdev_t + Fmachine Tu_int32_t +} + +type Tau_tid_addr = struct { + Fat_port Tdev_t + Fat_type Tu_int32_t + Fat_addr [4]Tu_int32_t +} + +type Tau_tid_addr_t = struct { + Fat_port Tdev_t + Fat_type Tu_int32_t + Fat_addr [4]Tu_int32_t +} + +type Tau_tid_t = struct { + Fport Tdev_t + Fmachine Tu_int32_t +} + +type Taudit_fstat = struct { + Faf_filesz Tu_int64_t + Faf_currsz Tu_int64_t +} + +type Taudit_stat = struct { + Fas_version uint32 + Fas_numevent uint32 + Fas_generated int32 + Fas_nonattrib int32 + Fas_kernel int32 + Fas_audit int32 + Fas_auditctl int32 + Fas_enqueue int32 + Fas_written int32 + Fas_wblocked int32 + Fas_rblocked int32 + Fas_dropped int32 + Fas_totalsize int32 + Fas_memused uint32 +} + +type Tauditinfo = struct { + Fai_auid Tau_id_t + Fai_mask Tau_mask_t + Fai_termid Tau_tid_t + Fai_asid Tau_asid_t +} + +type Tauditinfo_addr = struct { + Fai_auid Tau_id_t + Fai_mask Tau_mask_t + Fai_termid Tau_tid_addr_t + Fai_asid Tau_asid_t + Fai_flags Tau_asflgs_t +} + +type Tauditinfo_addr_t = struct { + Fai_auid Tau_id_t + Fai_mask Tau_mask_t + Fai_termid Tau_tid_addr_t + Fai_asid Tau_asid_t + Fai_flags Tau_asflgs_t +} + +type Tauditinfo_t = struct { + Fai_auid Tau_id_t + Fai_mask Tau_mask_t + Fai_termid Tau_tid_t + Fai_asid Tau_asid_t +} + +type Tauditpinfo = struct { + Fap_pid Tpid_t + Fap_auid Tau_id_t + Fap_mask Tau_mask_t + Fap_termid Tau_tid_t + Fap_asid Tau_asid_t +} + +type Tauditpinfo_addr = struct { + Fap_pid Tpid_t + Fap_auid Tau_id_t + Fap_mask Tau_mask_t + Fap_termid Tau_tid_addr_t + Fap_asid Tau_asid_t + Fap_flags Tau_asflgs_t +} + +type Tauditpinfo_addr_t = struct { + Fap_pid Tpid_t + Fap_auid Tau_id_t + Fap_mask Tau_mask_t + Fap_termid Tau_tid_addr_t + Fap_asid Tau_asid_t + Fap_flags Tau_asflgs_t +} + +type Tauditpinfo_t = struct { + Fap_pid Tpid_t + Fap_auid Tau_id_t + Fap_mask Tau_mask_t + Fap_termid Tau_tid_t + Fap_asid Tau_asid_t +} + +type Tclock_t = uint64 + +type Tclockinfo = struct { + Fhz int32 + Ftick int32 + Ftickadj int32 + Fstathz int32 + Fprofhz int32 +} + +type Tcmsghdr = struct { + Fcmsg_len Tsocklen_t + Fcmsg_level int32 + Fcmsg_type int32 +} + +type Tcryptex_auth_type_t = uint32 + +type Tct_rune_t = int32 + +type Tdaddr_t = int32 + +type Tdiskextent = struct { + Fstartblock Tu_int32_t + Fblockcount Tu_int32_t +} + +type Textentrecord = [8]Tdiskextent + +type Tfattributiontag = Tfattributiontag_t + +type Tfattributiontag_t = struct { + Fft_flags uint32 + Fft_hash uint64 + Fft_attribution_name [255]int8 +} + +type Tfchecklv = Tfchecklv_t + +type Tfchecklv_t = struct { + Flv_file_start Toff_t + Flv_error_message_size Tsize_t + Flv_error_message uintptr +} + +type Tfd_mask = int32 + +type Tfd_set = struct { + Ffds_bits [32]t__int32_t +} + +type Tfgetsigsinfo = Tfgetsigsinfo_t + +type Tfgetsigsinfo_t = struct { + Ffg_file_start Toff_t + Ffg_info_request int32 + Ffg_sig_is_platform int32 +} + +type Tfhandle = struct { + Ffh_len uint32 + Ffh_data [128]uint8 +} + +type Tfhandle_t = struct { + Ffh_len uint32 + Ffh_data [128]uint8 +} + +type Tfilesec_property_t = int32 + +type Tfilesec_t = uintptr + +type Tflocktimeout = struct { + Ffl Tflock + Ftimeout Ttimespec +} + +type Tfpunchhole = Tfpunchhole_t + +type Tfpunchhole_t = struct { + Ffp_flags uint32 + Freserved uint32 + Ffp_offset Toff_t + Ffp_length Toff_t +} + +type Tfsblkcnt_t = uint32 + +type Tfsfilcnt_t = uint32 + +type Tfsfile_type_t = uint32 + +type Tfsid = Tfsid_t + +type Tfsid_t = struct { + Fval [2]Tint32_t +} + +type Tfsignatures = Tfsignatures_t + +type Tfsignatures_t = struct { + Ffs_file_start Toff_t + Ffs_blob_start uintptr + Ffs_blob_size Tsize_t + Ffs_fsignatures_size Tsize_t + Ffs_cdhash [20]int8 + Ffs_hash_type int32 +} + +type Tfsobj_id = Tfsobj_id_t + +type Tfsobj_id_t = struct { + Ffid_objno Tu_int32_t + Ffid_generation Tu_int32_t +} + +type Tfsobj_tag_t = uint32 + +type Tfsobj_type_t = uint32 + +type Tfspecread = Tfspecread_t + +type Tfspecread_t = struct { + Ffsr_flags uint32 + Freserved uint32 + Ffsr_offset Toff_t + Ffsr_length Toff_t +} + +type Tfssearchblock = struct { + Freturnattrs uintptr + Freturnbuffer uintptr + Freturnbuffersize Tsize_t + Fmaxmatches Tu_long + Ftimelimit Ttimeval + Fsearchparams1 uintptr + Fsizeofsearchparams1 Tsize_t + Fsearchparams2 uintptr + Fsizeofsearchparams2 Tsize_t + Fsearchattrs Tattrlist +} + +type Tfstore = Tfstore_t + +type Tfstore_t = struct { + Ffst_flags uint32 + Ffst_posmode int32 + Ffst_offset Toff_t + Ffst_length Toff_t + Ffst_bytesalloc Toff_t +} + +type Tfsupplement = Tfsupplement_t + +type Tfsupplement_t = struct { + Ffs_file_start Toff_t + Ffs_blob_start Toff_t + Ffs_blob_size Tsize_t + Ffs_orig_fd int32 +} + +type Tfsvolid_t = uint32 + +type Tftrimactivefile = Tftrimactivefile_t + +type Tftrimactivefile_t = struct { + Ffta_offset Toff_t + Ffta_length Toff_t +} + +type Tgraft_args = Tgraftdmg_args_un + +type Tgraftdmg_args_un = struct { + Fsbc_args [0]Tsecure_boot_cryptex_args_t + Fmax_size [512]Tu_int8_t +} + +type Tgraftdmg_type_t = uint32 + +type Tif_clonereq = struct { + Fifcr_total int32 + Fifcr_count int32 + Fifcr_buffer uintptr +} + +type Tif_data = struct { + Fifi_type Tu_char + Fifi_typelen Tu_char + Fifi_physical Tu_char + Fifi_addrlen Tu_char + Fifi_hdrlen Tu_char + Fifi_recvquota Tu_char + Fifi_xmitquota Tu_char + Fifi_unused1 Tu_char + Fifi_mtu Tu_int32_t + Fifi_metric Tu_int32_t + Fifi_baudrate Tu_int32_t + Fifi_ipackets Tu_int32_t + Fifi_ierrors Tu_int32_t + Fifi_opackets Tu_int32_t + Fifi_oerrors Tu_int32_t + Fifi_collisions Tu_int32_t + Fifi_ibytes Tu_int32_t + Fifi_obytes Tu_int32_t + Fifi_imcasts Tu_int32_t + Fifi_omcasts Tu_int32_t + Fifi_iqdrops Tu_int32_t + Fifi_noproto Tu_int32_t + Fifi_recvtiming Tu_int32_t + Fifi_xmittiming Tu_int32_t + Fifi_lastchange Ttimeval32 + Fifi_unused2 Tu_int32_t + Fifi_hwassist Tu_int32_t + Fifi_reserved1 Tu_int32_t + Fifi_reserved2 Tu_int32_t +} + +type Tif_data64 = struct { + Fifi_type Tu_char + Fifi_typelen Tu_char + Fifi_physical Tu_char + Fifi_addrlen Tu_char + Fifi_hdrlen Tu_char + Fifi_recvquota Tu_char + Fifi_xmitquota Tu_char + Fifi_unused1 Tu_char + Fifi_mtu Tu_int32_t + Fifi_metric Tu_int32_t + Fifi_baudrate Tu_int64_t + Fifi_ipackets Tu_int64_t + Fifi_ierrors Tu_int64_t + Fifi_opackets Tu_int64_t + Fifi_oerrors Tu_int64_t + Fifi_collisions Tu_int64_t + Fifi_ibytes Tu_int64_t + Fifi_obytes Tu_int64_t + Fifi_imcasts Tu_int64_t + Fifi_omcasts Tu_int64_t + Fifi_iqdrops Tu_int64_t + Fifi_noproto Tu_int64_t + Fifi_recvtiming Tu_int32_t + Fifi_xmittiming Tu_int32_t + Fifi_lastchange Ttimeval32 +} + +type Tif_msghdr = struct { + Fifm_msglen uint16 + Fifm_version uint8 + Fifm_type uint8 + Fifm_addrs int32 + Fifm_flags int32 + Fifm_index uint16 + Fifm_data Tif_data +} + +type Tif_msghdr2 = struct { + Fifm_msglen Tu_short + Fifm_version Tu_char + Fifm_type Tu_char + Fifm_addrs int32 + Fifm_flags int32 + Fifm_index Tu_short + Fifm_snd_len int32 + Fifm_snd_maxlen int32 + Fifm_snd_drops int32 + Fifm_timer int32 + Fifm_data Tif_data64 +} + +type Tif_nameindex = struct { + Fif_index uint32 + Fif_name uintptr +} + +type Tifa_msghdr = struct { + Fifam_msglen uint16 + Fifam_version uint8 + Fifam_type uint8 + Fifam_addrs int32 + Fifam_flags int32 + Fifam_index uint16 + Fifam_metric int32 +} + +type Tifaliasreq = struct { + Fifra_name [16]int8 + Fifra_addr Tsockaddr + Fifra_broadaddr Tsockaddr + Fifra_mask Tsockaddr +} + +type Tifconf = struct { + Fifc_len int32 + Fifc_ifcu struct { + Fifcu_req [0]uintptr + Fifcu_buf Tcaddr_t + } +} + +type Tifdevmtu = struct { + Fifdm_current int32 + Fifdm_min int32 + Fifdm_max int32 +} + +type Tifdrv = struct { + Fifd_name [16]int8 + Fifd_cmd uint64 + Fifd_len Tsize_t + Fifd_data uintptr +} + +type Tifkpi = struct { + Fifk_module_id uint32 + Fifk_type uint32 + Fifk_data struct { + Fifk_value [0]int32 + Fifk_ptr uintptr + } +} + +type Tifma_msghdr = struct { + Fifmam_msglen uint16 + Fifmam_version uint8 + Fifmam_type uint8 + Fifmam_addrs int32 + Fifmam_flags int32 + Fifmam_index uint16 +} + +type Tifma_msghdr2 = struct { + Fifmam_msglen Tu_short + Fifmam_version Tu_char + Fifmam_type Tu_char + Fifmam_addrs int32 + Fifmam_flags int32 + Fifmam_index Tu_short + Fifmam_refcount Tint32_t +} + +type Tifmediareq = struct { + Fifm_name [16]int8 + Fifm_current int32 + Fifm_mask int32 + Fifm_status int32 + Fifm_active int32 + Fifm_count int32 + Fifm_ulist uintptr +} + +type Tifqueue = struct { + Fifq_head uintptr + Fifq_tail uintptr + Fifq_len int32 + Fifq_maxlen int32 + Fifq_drops int32 +} + +type Tifreq = struct { + Fifr_name [16]int8 + Fifr_ifru struct { + Fifru_dstaddr [0]Tsockaddr + Fifru_broadaddr [0]Tsockaddr + Fifru_flags [0]int16 + Fifru_metric [0]int32 + Fifru_mtu [0]int32 + Fifru_phys [0]int32 + Fifru_media [0]int32 + Fifru_intval [0]int32 + Fifru_data [0]Tcaddr_t + Fifru_devmtu [0]Tifdevmtu + Fifru_kpi [0]Tifkpi + Fifru_wake_flags [0]Tu_int32_t + Fifru_route_refcnt [0]Tu_int32_t + Fifru_cap [0][2]int32 + Fifru_functional_type [0]Tu_int32_t + Fifru_peer_egress_functional_type [0]Tu_int32_t + Fifru_is_directlink [0]Tu_int8_t + Fifru_is_vpn [0]Tu_int8_t + Fifru_is_companionlink [0]Tu_int8_t + Fifru_addr Tsockaddr + } +} + +type Tifstat = struct { + Fifs_name [16]int8 + Fascii [801]int8 +} + +type Tino64_t = uint64 + +type Tinteger_t = int32 + +type Tkev_dl_proto_data = struct { + Flink_data Tnet_event_data + Fproto_family Tu_int32_t + Fproto_remaining_count Tu_int32_t +} + +type Tlinger = struct { + Fl_onoff int32 + Fl_linger int32 +} + +type Tlog2phys = struct { + Fl2p_flags uint32 + Fl2p_contigbytes Toff_t + Fl2p_devoffset Toff_t +} + +type Tmach_port_array_t = uintptr + +type Tmach_port_context_t = uint64 + +type Tmach_port_delta_t = int32 + +type Tmach_port_flavor_t = int32 + +type Tmach_port_guard_info = Tmach_port_guard_info_t + +type Tmach_port_guard_info_t = struct { + Fmpgi_guard Tuint64_t +} + +type Tmach_port_info_ext = Tmach_port_info_ext_t + +type Tmach_port_info_ext_t = struct { + Fmpie_status Tmach_port_status_t + Fmpie_boost_cnt Tmach_port_msgcount_t + Freserved [6]Tuint32_t +} + +type Tmach_port_info_t = uintptr + +type Tmach_port_limits = Tmach_port_limits_t + +type Tmach_port_limits_t = struct { + Fmpl_qlimit Tmach_port_msgcount_t +} + +type Tmach_port_mscount_t = uint32 + +type Tmach_port_msgcount_t = uint32 + +type Tmach_port_name_array_t = uintptr + +type Tmach_port_name_t = uint32 + +type Tmach_port_options = Tmach_port_options_t + +type Tmach_port_options_ptr_t = uintptr + +type Tmach_port_options_t = struct { + Fflags Tuint32_t + Fmpl Tmach_port_limits_t + F__ccgo2_8 struct { + Fwork_interval_port [0]Tmach_port_name_t + Fservice_port_info [0]Tmach_service_port_info_t + Fservice_port_name [0]Tmach_port_name_t + Freserved [2]Tuint64_t + } +} + +type Tmach_port_qos = Tmach_port_qos_t + +type Tmach_port_qos_t = struct { + F__ccgo0 uint32 + Flen1 Tnatural_t +} + +type Tmach_port_right_t = uint32 + +type Tmach_port_rights_t = uint32 + +type Tmach_port_seqno_t = uint32 + +type Tmach_port_srights_t = uint32 + +type Tmach_port_status = Tmach_port_status_t + +type Tmach_port_status_t = struct { + Fmps_pset Tmach_port_rights_t + Fmps_seqno Tmach_port_seqno_t + Fmps_mscount Tmach_port_mscount_t + Fmps_qlimit Tmach_port_msgcount_t + Fmps_msgcount Tmach_port_msgcount_t + Fmps_sorights Tmach_port_rights_t + Fmps_srights Tboolean_t + Fmps_pdrequest Tboolean_t + Fmps_nsrequest Tboolean_t + Fmps_flags Tnatural_t +} + +type Tmach_port_t = uint32 + +type Tmach_port_type_array_t = uintptr + +type Tmach_port_type_t = uint32 + +type Tmach_port_urefs_t = uint32 + +type Tmach_service_port_info = Tmach_service_port_info_data_t + +type Tmach_service_port_info_data_t = struct { + Fmspi_string_name [255]int8 + Fmspi_domain_type Tuint8_t +} + +type Tmach_service_port_info_t = uintptr + +type Tmach_vm_address_t = uint64 + +type Tmach_vm_offset_t = uint64 + +type Tmach_vm_size_t = uint64 + +type Tmalloc_type_id_t = uint64 + +type Tmax_align_t = float64 + +type Tmcontext_t = uintptr + +type Tmount_t = uintptr + +type Tmpo_flags_t = uint32 + +type Tmsghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Tsocklen_t + Fmsg_iov uintptr + Fmsg_iovlen int32 + Fmsg_control uintptr + Fmsg_controllen Tsocklen_t + Fmsg_flags int32 +} + +type Tnatural_t = uint32 + +type Tnet_event_data = struct { + Fif_family Tu_int32_t + Fif_unit Tu_int32_t + Fif_name [16]int8 +} + +type Tnetfs_status = struct { + F__ccgo_align [0]uint64 + Fns_status Tu_int32_t + Fns_mountopts [512]int8 + Fns_waittime Tuint32_t + Fns_threadcount Tuint32_t +} + +type Tnlink_t = uint16 + +type Tos_block_t = uintptr + +type Tos_function_t = uintptr + +type Tostat = struct { + Fst_dev t__uint16_t + Fst_ino Tino_t + Fst_mode Tmode_t + Fst_nlink Tnlink_t + Fst_uid t__uint16_t + Fst_gid t__uint16_t + Fst_rdev t__uint16_t + Fst_size t__int32_t + Fst_atimespec Ttimespec + Fst_mtimespec Ttimespec + Fst_ctimespec Ttimespec + Fst_blksize t__int32_t + Fst_blocks t__int32_t + Fst_flags t__uint32_t + Fst_gen t__uint32_t +} + +type Tposix_cred_t = uintptr + +type Tproc_rlimit_control_wakeupmon = struct { + Fwm_flags Tuint32_t + Fwm_rate Tint32_t +} + +// C documentation +// +// /* +// ** The proxyLockingContext has the path and file structures for the remote +// ** and local proxy files in it +// */ +type TproxyLockingContext = struct { + FconchFile uintptr + FconchFilePath uintptr + FlockProxy uintptr + FlockProxyPath uintptr + FdbPath uintptr + FconchHeld int32 + FnFails int32 + FoldLockingContext uintptr + FpOldMethod uintptr +} + +type Tpthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} + +type Tpthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} + +type Tpthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type Tpthread_key_t = uint64 + +type Tpthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} + +type Tpthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type Tpthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type Tpthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} + +type Tpthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} + +type Tradvisory = struct { + Fra_offset Toff_t + Fra_count int32 +} + +type Trlimit = struct { + Frlim_cur Trlim_t + Frlim_max Trlim_t +} + +type Trslvmulti_req = struct { + Fsa uintptr + Fllsa uintptr +} + +type Trusage = struct { + Fru_utime Ttimeval + Fru_stime Ttimeval + Fru_maxrss int64 + Fru_ixrss int64 + Fru_idrss int64 + Fru_isrss int64 + Fru_minflt int64 + Fru_majflt int64 + Fru_nswap int64 + Fru_inblock int64 + Fru_oublock int64 + Fru_msgsnd int64 + Fru_msgrcv int64 + Fru_nsignals int64 + Fru_nvcsw int64 + Fru_nivcsw int64 +} + +type Trusage_info_current = struct { + Fri_uuid [16]Tuint8_t + Fri_user_time Tuint64_t + Fri_system_time Tuint64_t + Fri_pkg_idle_wkups Tuint64_t + Fri_interrupt_wkups Tuint64_t + Fri_pageins Tuint64_t + Fri_wired_size Tuint64_t + Fri_resident_size Tuint64_t + Fri_phys_footprint Tuint64_t + Fri_proc_start_abstime Tuint64_t + Fri_proc_exit_abstime Tuint64_t + Fri_child_user_time Tuint64_t + Fri_child_system_time Tuint64_t + Fri_child_pkg_idle_wkups Tuint64_t + Fri_child_interrupt_wkups Tuint64_t + Fri_child_pageins Tuint64_t + Fri_child_elapsed_abstime Tuint64_t + Fri_diskio_bytesread Tuint64_t + Fri_diskio_byteswritten Tuint64_t + Fri_cpu_time_qos_default Tuint64_t + Fri_cpu_time_qos_maintenance Tuint64_t + Fri_cpu_time_qos_background Tuint64_t + Fri_cpu_time_qos_utility Tuint64_t + Fri_cpu_time_qos_legacy Tuint64_t + Fri_cpu_time_qos_user_initiated Tuint64_t + Fri_cpu_time_qos_user_interactive Tuint64_t + Fri_billed_system_time Tuint64_t + Fri_serviced_system_time Tuint64_t + Fri_logical_writes Tuint64_t + Fri_lifetime_max_phys_footprint Tuint64_t + Fri_instructions Tuint64_t + Fri_cycles Tuint64_t + Fri_billed_energy Tuint64_t + Fri_serviced_energy Tuint64_t + Fri_interval_max_phys_footprint Tuint64_t + Fri_runnable_time Tuint64_t + Fri_flags Tuint64_t + Fri_user_ptime Tuint64_t + Fri_system_ptime Tuint64_t + Fri_pinstructions Tuint64_t + Fri_pcycles Tuint64_t + Fri_energy_nj Tuint64_t + Fri_penergy_nj Tuint64_t + Fri_secure_time_in_system Tuint64_t + Fri_secure_ptime_in_system Tuint64_t + Fri_neural_footprint Tuint64_t + Fri_lifetime_max_neural_footprint Tuint64_t + Fri_interval_max_neural_footprint Tuint64_t + Fri_reserved [9]Tuint64_t +} + +type Trusage_info_t = uintptr + +type Trusage_info_v0 = struct { + Fri_uuid [16]Tuint8_t + Fri_user_time Tuint64_t + Fri_system_time Tuint64_t + Fri_pkg_idle_wkups Tuint64_t + Fri_interrupt_wkups Tuint64_t + Fri_pageins Tuint64_t + Fri_wired_size Tuint64_t + Fri_resident_size Tuint64_t + Fri_phys_footprint Tuint64_t + Fri_proc_start_abstime Tuint64_t + Fri_proc_exit_abstime Tuint64_t +} + +type Trusage_info_v1 = struct { + Fri_uuid [16]Tuint8_t + Fri_user_time Tuint64_t + Fri_system_time Tuint64_t + Fri_pkg_idle_wkups Tuint64_t + Fri_interrupt_wkups Tuint64_t + Fri_pageins Tuint64_t + Fri_wired_size Tuint64_t + Fri_resident_size Tuint64_t + Fri_phys_footprint Tuint64_t + Fri_proc_start_abstime Tuint64_t + Fri_proc_exit_abstime Tuint64_t + Fri_child_user_time Tuint64_t + Fri_child_system_time Tuint64_t + Fri_child_pkg_idle_wkups Tuint64_t + Fri_child_interrupt_wkups Tuint64_t + Fri_child_pageins Tuint64_t + Fri_child_elapsed_abstime Tuint64_t +} + +type Trusage_info_v2 = struct { + Fri_uuid [16]Tuint8_t + Fri_user_time Tuint64_t + Fri_system_time Tuint64_t + Fri_pkg_idle_wkups Tuint64_t + Fri_interrupt_wkups Tuint64_t + Fri_pageins Tuint64_t + Fri_wired_size Tuint64_t + Fri_resident_size Tuint64_t + Fri_phys_footprint Tuint64_t + Fri_proc_start_abstime Tuint64_t + Fri_proc_exit_abstime Tuint64_t + Fri_child_user_time Tuint64_t + Fri_child_system_time Tuint64_t + Fri_child_pkg_idle_wkups Tuint64_t + Fri_child_interrupt_wkups Tuint64_t + Fri_child_pageins Tuint64_t + Fri_child_elapsed_abstime Tuint64_t + Fri_diskio_bytesread Tuint64_t + Fri_diskio_byteswritten Tuint64_t +} + +type Trusage_info_v3 = struct { + Fri_uuid [16]Tuint8_t + Fri_user_time Tuint64_t + Fri_system_time Tuint64_t + Fri_pkg_idle_wkups Tuint64_t + Fri_interrupt_wkups Tuint64_t + Fri_pageins Tuint64_t + Fri_wired_size Tuint64_t + Fri_resident_size Tuint64_t + Fri_phys_footprint Tuint64_t + Fri_proc_start_abstime Tuint64_t + Fri_proc_exit_abstime Tuint64_t + Fri_child_user_time Tuint64_t + Fri_child_system_time Tuint64_t + Fri_child_pkg_idle_wkups Tuint64_t + Fri_child_interrupt_wkups Tuint64_t + Fri_child_pageins Tuint64_t + Fri_child_elapsed_abstime Tuint64_t + Fri_diskio_bytesread Tuint64_t + Fri_diskio_byteswritten Tuint64_t + Fri_cpu_time_qos_default Tuint64_t + Fri_cpu_time_qos_maintenance Tuint64_t + Fri_cpu_time_qos_background Tuint64_t + Fri_cpu_time_qos_utility Tuint64_t + Fri_cpu_time_qos_legacy Tuint64_t + Fri_cpu_time_qos_user_initiated Tuint64_t + Fri_cpu_time_qos_user_interactive Tuint64_t + Fri_billed_system_time Tuint64_t + Fri_serviced_system_time Tuint64_t +} + +type Trusage_info_v4 = struct { + Fri_uuid [16]Tuint8_t + Fri_user_time Tuint64_t + Fri_system_time Tuint64_t + Fri_pkg_idle_wkups Tuint64_t + Fri_interrupt_wkups Tuint64_t + Fri_pageins Tuint64_t + Fri_wired_size Tuint64_t + Fri_resident_size Tuint64_t + Fri_phys_footprint Tuint64_t + Fri_proc_start_abstime Tuint64_t + Fri_proc_exit_abstime Tuint64_t + Fri_child_user_time Tuint64_t + Fri_child_system_time Tuint64_t + Fri_child_pkg_idle_wkups Tuint64_t + Fri_child_interrupt_wkups Tuint64_t + Fri_child_pageins Tuint64_t + Fri_child_elapsed_abstime Tuint64_t + Fri_diskio_bytesread Tuint64_t + Fri_diskio_byteswritten Tuint64_t + Fri_cpu_time_qos_default Tuint64_t + Fri_cpu_time_qos_maintenance Tuint64_t + Fri_cpu_time_qos_background Tuint64_t + Fri_cpu_time_qos_utility Tuint64_t + Fri_cpu_time_qos_legacy Tuint64_t + Fri_cpu_time_qos_user_initiated Tuint64_t + Fri_cpu_time_qos_user_interactive Tuint64_t + Fri_billed_system_time Tuint64_t + Fri_serviced_system_time Tuint64_t + Fri_logical_writes Tuint64_t + Fri_lifetime_max_phys_footprint Tuint64_t + Fri_instructions Tuint64_t + Fri_cycles Tuint64_t + Fri_billed_energy Tuint64_t + Fri_serviced_energy Tuint64_t + Fri_interval_max_phys_footprint Tuint64_t + Fri_runnable_time Tuint64_t +} + +type Trusage_info_v5 = struct { + Fri_uuid [16]Tuint8_t + Fri_user_time Tuint64_t + Fri_system_time Tuint64_t + Fri_pkg_idle_wkups Tuint64_t + Fri_interrupt_wkups Tuint64_t + Fri_pageins Tuint64_t + Fri_wired_size Tuint64_t + Fri_resident_size Tuint64_t + Fri_phys_footprint Tuint64_t + Fri_proc_start_abstime Tuint64_t + Fri_proc_exit_abstime Tuint64_t + Fri_child_user_time Tuint64_t + Fri_child_system_time Tuint64_t + Fri_child_pkg_idle_wkups Tuint64_t + Fri_child_interrupt_wkups Tuint64_t + Fri_child_pageins Tuint64_t + Fri_child_elapsed_abstime Tuint64_t + Fri_diskio_bytesread Tuint64_t + Fri_diskio_byteswritten Tuint64_t + Fri_cpu_time_qos_default Tuint64_t + Fri_cpu_time_qos_maintenance Tuint64_t + Fri_cpu_time_qos_background Tuint64_t + Fri_cpu_time_qos_utility Tuint64_t + Fri_cpu_time_qos_legacy Tuint64_t + Fri_cpu_time_qos_user_initiated Tuint64_t + Fri_cpu_time_qos_user_interactive Tuint64_t + Fri_billed_system_time Tuint64_t + Fri_serviced_system_time Tuint64_t + Fri_logical_writes Tuint64_t + Fri_lifetime_max_phys_footprint Tuint64_t + Fri_instructions Tuint64_t + Fri_cycles Tuint64_t + Fri_billed_energy Tuint64_t + Fri_serviced_energy Tuint64_t + Fri_interval_max_phys_footprint Tuint64_t + Fri_runnable_time Tuint64_t + Fri_flags Tuint64_t +} + +type Trusage_info_v6 = struct { + Fri_uuid [16]Tuint8_t + Fri_user_time Tuint64_t + Fri_system_time Tuint64_t + Fri_pkg_idle_wkups Tuint64_t + Fri_interrupt_wkups Tuint64_t + Fri_pageins Tuint64_t + Fri_wired_size Tuint64_t + Fri_resident_size Tuint64_t + Fri_phys_footprint Tuint64_t + Fri_proc_start_abstime Tuint64_t + Fri_proc_exit_abstime Tuint64_t + Fri_child_user_time Tuint64_t + Fri_child_system_time Tuint64_t + Fri_child_pkg_idle_wkups Tuint64_t + Fri_child_interrupt_wkups Tuint64_t + Fri_child_pageins Tuint64_t + Fri_child_elapsed_abstime Tuint64_t + Fri_diskio_bytesread Tuint64_t + Fri_diskio_byteswritten Tuint64_t + Fri_cpu_time_qos_default Tuint64_t + Fri_cpu_time_qos_maintenance Tuint64_t + Fri_cpu_time_qos_background Tuint64_t + Fri_cpu_time_qos_utility Tuint64_t + Fri_cpu_time_qos_legacy Tuint64_t + Fri_cpu_time_qos_user_initiated Tuint64_t + Fri_cpu_time_qos_user_interactive Tuint64_t + Fri_billed_system_time Tuint64_t + Fri_serviced_system_time Tuint64_t + Fri_logical_writes Tuint64_t + Fri_lifetime_max_phys_footprint Tuint64_t + Fri_instructions Tuint64_t + Fri_cycles Tuint64_t + Fri_billed_energy Tuint64_t + Fri_serviced_energy Tuint64_t + Fri_interval_max_phys_footprint Tuint64_t + Fri_runnable_time Tuint64_t + Fri_flags Tuint64_t + Fri_user_ptime Tuint64_t + Fri_system_ptime Tuint64_t + Fri_pinstructions Tuint64_t + Fri_pcycles Tuint64_t + Fri_energy_nj Tuint64_t + Fri_penergy_nj Tuint64_t + Fri_secure_time_in_system Tuint64_t + Fri_secure_ptime_in_system Tuint64_t + Fri_neural_footprint Tuint64_t + Fri_lifetime_max_neural_footprint Tuint64_t + Fri_interval_max_neural_footprint Tuint64_t + Fri_reserved [9]Tuint64_t +} + +type Tsa_endpoints = Tsa_endpoints_t + +type Tsa_endpoints_t = struct { + Fsae_srcif uint32 + Fsae_srcaddr uintptr + Fsae_srcaddrlen Tsocklen_t + Fsae_dstaddr uintptr + Fsae_dstaddrlen Tsocklen_t +} + +type Tsa_family_t = uint8 + +type Tsae_associd_t = uint32 + +type Tsae_connid_t = uint32 + +type Tsearchstate = struct { + Fss_union_flags Tuint32_t + Fss_union_layer Tuint32_t + Fss_fsstate [548]Tu_char +} + +type Tsecure_boot_cryptex_args = Tsecure_boot_cryptex_args_t + +type Tsecure_boot_cryptex_args_t = struct { + Fsbc_version Tu_int32_t + Fsbc_4cc Tu_int32_t + Fsbc_authentic_manifest_fd int32 + Fsbc_user_manifest_fd int32 + Fsbc_payload_fd int32 + Fsbc_flags Tu_int64_t +} + +type Tsf_hdtr = struct { + Fheaders uintptr + Fhdr_cnt int32 + Ftrailers uintptr + Ftrl_cnt int32 +} + +type Tsig_atomic_t = int32 + +type Tsig_t = uintptr + +type Tsigaction = struct { + F__sigaction_u t__sigaction_u + Fsa_mask Tsigset_t + Fsa_flags int32 +} + +type Tsigevent = struct { + Fsigev_notify int32 + Fsigev_signo int32 + Fsigev_value Tsigval + Fsigev_notify_function uintptr + Fsigev_notify_attributes uintptr +} + +type Tsiginfo_t = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + Fsi_pid Tpid_t + Fsi_uid Tuid_t + Fsi_status int32 + Fsi_addr uintptr + Fsi_value Tsigval + Fsi_band int64 + F__pad [7]uint64 +} + +type Tsigstack = struct { + Fss_sp uintptr + Fss_onstack int32 +} + +type Tsigval = struct { + Fsival_ptr [0]uintptr + Fsival_int int32 + F__ccgo_pad2 [4]byte +} + +type Tsigvec = struct { + Fsv_handler uintptr + Fsv_mask int32 + Fsv_flags int32 +} + +type Tso_np_extensions = struct { + Fnpx_flags Tu_int32_t + Fnpx_mask Tu_int32_t +} + +type Tsockaddr = struct { + Fsa_len t__uint8_t + Fsa_family Tsa_family_t + Fsa_data [14]int8 +} + +type Tsockaddr_storage = struct { + Fss_len t__uint8_t + Fss_family Tsa_family_t + F__ss_pad1 [6]int8 + F__ss_align t__int64_t + F__ss_pad2 [112]int8 +} + +type Tsocklen_t = uint32 + +type Tsockproto = struct { + Fsp_family t__uint16_t + Fsp_protocol t__uint16_t +} + +type Tstack_t = struct { + Fss_sp uintptr + Fss_size t__darwin_size_t + Fss_flags int32 +} + +type Tstat = struct { + Fst_dev Tdev_t + Fst_mode Tmode_t + Fst_nlink Tnlink_t + Fst_ino t__darwin_ino64_t + Fst_uid Tuid_t + Fst_gid Tgid_t + Fst_rdev Tdev_t + Fst_atimespec Ttimespec + Fst_mtimespec Ttimespec + Fst_ctimespec Ttimespec + Fst_birthtimespec Ttimespec + Fst_size Toff_t + Fst_blocks Tblkcnt_t + Fst_blksize Tblksize_t + Fst_flags t__uint32_t + Fst_gen t__uint32_t + Fst_lspare t__int32_t + Fst_qspare [2]t__int64_t +} + +type Tstatfs = struct { + Ff_bsize Tuint32_t + Ff_iosize Tint32_t + Ff_blocks Tuint64_t + Ff_bfree Tuint64_t + Ff_bavail Tuint64_t + Ff_files Tuint64_t + Ff_ffree Tuint64_t + Ff_fsid Tfsid_t + Ff_owner Tuid_t + Ff_type Tuint32_t + Ff_flags Tuint32_t + Ff_fssubtype Tuint32_t + Ff_fstypename [16]int8 + Ff_mntonname [1024]int8 + Ff_mntfromname [1024]int8 + Ff_flags_ext Tuint32_t + Ff_reserved [7]Tuint32_t +} + +type Tsyscall_arg_t = uint64 + +type Ttext_encoding_t = uint32 + +type Ttimespec = struct { + Ftv_sec t__darwin_time_t + Ftv_nsec int64 +} + +type Ttimeval = struct { + Ftv_sec t__darwin_time_t + Ftv_usec t__darwin_suseconds_t +} + +type Ttimeval32 = struct { + Ftv_sec t__int32_t + Ftv_usec t__int32_t +} + +type Ttimeval64 = struct { + Ftv_sec t__int64_t + Ftv_usec t__int64_t +} + +type Tucontext_t = struct { + Fuc_onstack int32 + Fuc_sigmask t__darwin_sigset_t + Fuc_stack t__darwin_sigaltstack + Fuc_link uintptr + Fuc_mcsize t__darwin_size_t + Fuc_mcontext uintptr +} + +// C documentation +// +// /* +// ** The unixFile structure is subclass of sqlite3_file specific to the unix +// ** VFS implementations. +// */ +type TunixFile = struct { + FpMethod uintptr + FpVfs uintptr + FpInode uintptr + Fh int32 + FeFileLock uint8 + FctrlFlags uint16 + FlastErrno int32 + FlockingContext uintptr + FpPreallocatedUnused uintptr + FzPath uintptr + FpShm uintptr + FszChunk int32 + FnFetchOut int32 + FmmapSize Tsqlite3_int64 + FmmapSizeActual Tsqlite3_int64 + FmmapSizeMax Tsqlite3_int64 + FpMapRegion uintptr + FsectorSize int32 + FdeviceCharacteristics int32 + FopenFlags int32 + FfsFlags uint32 +} + +/* Shared memory instance */ +type TunixInodeInfo = struct { + FfileId TunixFileId + FpLockMutex uintptr + FnShared int32 + FnLock int32 + FeFileLock uint8 + FbProcessLock uint8 + FpUnused uintptr + FnRef int32 + FpShmNode uintptr + FpNext uintptr + FpPrev uintptr + FsharedByte uint64 +} + +type Tuser_addr_t = uint64 + +type Tuser_long_t = int64 + +type Tuser_off_t = int64 + +type Tuser_size_t = uint64 + +type Tuser_ssize_t = int64 + +type Tuser_time_t = int64 + +type Tuser_ulong_t = uint64 + +type Tuuid_t = [16]uint8 + +type Tvfs_server = struct { + Fvs_minutes Tint32_t + Fvs_server_name [768]Tu_int8_t +} + +type Tvfsconf = struct { + Fvfc_reserved1 Tuint32_t + Fvfc_name [15]int8 + Fvfc_typenum int32 + Fvfc_refcount int32 + Fvfc_flags int32 + Fvfc_reserved2 Tuint32_t + Fvfc_reserved3 Tuint32_t +} + +type Tvfsidctl = struct { + Fvc_vers int32 + Fvc_fsid Tfsid_t + Fvc_ptr uintptr + Fvc_len Tsize_t + Fvc_spare [12]Tu_int32_t +} + +type Tvfsquery = struct { + Fvq_flags Tu_int32_t + Fvq_spare [31]Tu_int32_t +} + +type Tvfsstatfs = struct { + Ff_bsize Tuint32_t + Ff_iosize Tsize_t + Ff_blocks Tuint64_t + Ff_bfree Tuint64_t + Ff_bavail Tuint64_t + Ff_bused Tuint64_t + Ff_files Tuint64_t + Ff_ffree Tuint64_t + Ff_fsid Tfsid_t + Ff_owner Tuid_t + Ff_flags Tuint64_t + Ff_fstypename [16]int8 + Ff_mntonname [1024]int8 + Ff_mntfromname [1024]int8 + Ff_fssubtype Tuint32_t + Ff_reserved [2]uintptr +} + +type Tvm_map_address_t = uint64 + +type Tvm_map_offset_t = uint64 + +type Tvm_map_size_t = uint64 + +type Tvnode_t = uintptr + +type Tvol_attributes_attr = Tvol_attributes_attr_t + +type Tvol_attributes_attr_t = struct { + Fvalidattr Tattribute_set_t + Fnativeattr Tattribute_set_t +} + +type Tvol_capabilities_attr = Tvol_capabilities_attr_t + +type Tvol_capabilities_attr_t = struct { + Fcapabilities Tvol_capabilities_set_t + Fvalid Tvol_capabilities_set_t +} + +type Tvol_capabilities_set_t = [4]Tu_int32_t + +type Twait = struct { + Fw_T [0]struct { + F__ccgo0 uint32 + } + Fw_S [0]struct { + F__ccgo0 uint32 + } + Fw_status int32 +} + +type Txucred = struct { + Fcr_version Tu_int + Fcr_uid Tuid_t + Fcr_ngroups int16 + Fcr_groups [16]Tgid_t +} + +const UF_COMPRESSED = 32 + +const UF_DATAVAULT = 128 + +const UF_TRACKED = 64 + +const UNGRAFTDMG_NOFORCE = 2 + +const USER_FSIGNATURES_CDHASH_LEN = 20 + +const VFS_CONF = 2 + +const VFS_CTL_DISC = 65544 + +const VFS_CTL_NEWADDR = 65540 + +const VFS_CTL_NOLOCKS = 65542 + +const VFS_CTL_NSTATUS = 65546 + +const VFS_CTL_OSTATFS = 65537 + +const VFS_CTL_QUERY = 65539 + +const VFS_CTL_SADDR = 65543 + +const VFS_CTL_SERVERINFO = 65545 + +const VFS_CTL_STATFS = 65547 + +const VFS_CTL_STATFS64 = 65547 + +const VFS_CTL_TIMEO = 65541 + +const VFS_CTL_UMOUNT = 65538 + +const VFS_CTL_VERS1 = 1 + +const VFS_GENERIC = 0 + +const VFS_MAXTYPENUM = 1 + +const VFS_NUMMNTOPS = 1 + +const VOL_CAPABILITIES_FORMAT = 0 + +const VOL_CAPABILITIES_INTERFACES = 1 + +const VOL_CAPABILITIES_RESERVED1 = 2 + +const VOL_CAPABILITIES_RESERVED2 = 3 + +const VOL_CAP_FMT_2TB_FILESIZE = 2048 + +const VOL_CAP_FMT_64BIT_OBJECT_IDS = 131072 + +const VOL_CAP_FMT_CASE_PRESERVING = 512 + +const VOL_CAP_FMT_CASE_SENSITIVE = 256 + +const VOL_CAP_FMT_CLONE_MAPPING = 67108864 + +const VOL_CAP_FMT_DECMPFS_COMPRESSION = 65536 + +const VOL_CAP_FMT_DIR_HARDLINKS = 262144 + +const VOL_CAP_FMT_DOCUMENT_ID = 524288 + +const VOL_CAP_FMT_FAST_STATFS = 1024 + +const VOL_CAP_FMT_HARDLINKS = 4 + +const VOL_CAP_FMT_HIDDEN_FILES = 8192 + +const VOL_CAP_FMT_JOURNAL = 8 + +const VOL_CAP_FMT_JOURNAL_ACTIVE = 16 + +const VOL_CAP_FMT_NO_IMMUTABLE_FILES = 2097152 + +const VOL_CAP_FMT_NO_PERMISSIONS = 4194304 + +const VOL_CAP_FMT_NO_ROOT_TIMES = 32 + +const VOL_CAP_FMT_NO_VOLUME_SIZES = 32768 + +const VOL_CAP_FMT_OPENDENYMODES = 4096 + +const VOL_CAP_FMT_PATH_FROM_ID = 16384 + +const VOL_CAP_FMT_PERSISTENTOBJECTIDS = 1 + +const VOL_CAP_FMT_SEALED = 33554432 + +const VOL_CAP_FMT_SHARED_SPACE = 8388608 + +const VOL_CAP_FMT_SPARSE_FILES = 64 + +const VOL_CAP_FMT_SYMBOLICLINKS = 2 + +const VOL_CAP_FMT_VOL_GROUPS = 16777216 + +const VOL_CAP_FMT_WRITE_GENERATION_COUNT = 1048576 + +const VOL_CAP_FMT_ZERO_RUNS = 128 + +const VOL_CAP_INT_ADVLOCK = 256 + +const VOL_CAP_INT_ALLOCATE = 64 + +const VOL_CAP_INT_ATTRIBUTION_TAG = 4194304 + +const VOL_CAP_INT_ATTRLIST = 2 + +const VOL_CAP_INT_BARRIERFSYNC = 16777216 + +const VOL_CAP_INT_CLONE = 65536 + +const VOL_CAP_INT_COPYFILE = 32 + +const VOL_CAP_INT_EXCHANGEDATA = 16 + +const VOL_CAP_INT_EXTENDED_ATTR = 16384 + +const VOL_CAP_INT_EXTENDED_SECURITY = 1024 + +const VOL_CAP_INT_FLOCK = 512 + +const VOL_CAP_INT_MANLOCK = 4096 + +const VOL_CAP_INT_NAMEDSTREAMS = 8192 + +const VOL_CAP_INT_NFSEXPORT = 4 + +const VOL_CAP_INT_PUNCHHOLE = 8388608 + +const VOL_CAP_INT_READDIRATTR = 8 + +const VOL_CAP_INT_RENAME_EXCL = 524288 + +const VOL_CAP_INT_RENAME_OPENFAIL = 1048576 + +const VOL_CAP_INT_RENAME_SECLUDE = 2097152 + +const VOL_CAP_INT_RENAME_SWAP = 262144 + +const VOL_CAP_INT_SEARCHFS = 1 + +const VOL_CAP_INT_SNAPSHOT = 131072 + +const VOL_CAP_INT_USERACCESS = 2048 + +const VOL_CAP_INT_VOL_RENAME = 128 + +const VQ_ASSIST = 64 + +const VQ_DEAD = 32 + +const VQ_DESIRED_DISK = 16384 + +const VQ_FLAG40000 = 262144 + +const VQ_FREE_SPACE_CHANGE = 32768 + +const VQ_IDLE_PURGE_NOTIFY = 131072 + +const VQ_LOWDISK = 4 + +const VQ_MOUNT = 8 + +const VQ_NEARLOWDISK = 8192 + +const VQ_NEEDAUTH = 2 + +const VQ_NOTRESP = 1 + +const VQ_NOTRESPLOCK = 128 + +const VQ_PURGEABLE_SPACE_CHANGE = 65536 + +const VQ_QUOTA = 4096 + +const VQ_SERVEREVENT = 2048 + +const VQ_SYNCEVENT = 1024 + +const VQ_UNMOUNT = 16 + +const VQ_UPDATE = 256 + +const VQ_VERYLOWDISK = 512 + +const WAIT_ANY = -1 + +const WAIT_MYPGRP = 0 + +const WAKEMON_DISABLE = 2 + +const WAKEMON_ENABLE = 1 + +const WAKEMON_GET_PARAMS = 4 + +const WAKEMON_MAKE_FATAL = 16 + +const WAKEMON_SET_DEFAULTS = 8 + +const WCONTINUED = 16 + +const WCOREFLAG = 128 + +const WEXITED = 4 + +const WNOWAIT = 32 + +const WSTOPPED = 8 + +const XUCRED_VERSION = 0 + +// C documentation +// +// /* +// ** Create an sqlite3_backup process to copy the contents of zSrcDb from +// ** connection handle pSrcDb to zDestDb in pDestDb. If successful, return +// ** a pointer to the new sqlite3_backup object. +// ** +// ** If an error occurs, NULL is returned and an error code and error message +// ** stored in database handle pDestDb. +// */ +func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcDb uintptr, zSrcDb uintptr) (r uintptr) { + var p uintptr + _ = p /* Value to return */ + /* Lock the source database handle. The destination database + ** handle is not locked in this routine, but it is locked in + ** sqlite3_backup_step(). The user is required to ensure that no + ** other thread accesses the destination handle for the duration + ** of the backup operation. Any attempt to use the destination + ** database connection while a backup is in progress may cause + ** a malfunction or a deadlock. + */ + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(pSrcDb)).Fmutex) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(pDestDb)).Fmutex) + if pSrcDb == pDestDb { + _sqlite3ErrorWithMsg(tls, pDestDb, int32(SQLITE_ERROR), __ccgo_ts+5520, 0) + p = uintptr(0) + } else { + /* Allocate space for a new sqlite3_backup object... + ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a + ** call to sqlite3_backup_init() and is destroyed by a call to + ** sqlite3_backup_finish(). */ + p = _sqlite3MallocZero(tls, uint64(72)) + if !(p != 0) { + _sqlite3Error(tls, pDestDb, int32(SQLITE_NOMEM)) + } + } + /* If the allocation succeeded, populate the new object. */ + if p != 0 { + (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc = _findBtree(tls, pDestDb, pSrcDb, zSrcDb) + (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest = _findBtree(tls, pDestDb, pDestDb, zDestDb) + (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb = pDestDb + (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrcDb = pSrcDb + (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext = uint32(1) + (*Tsqlite3_backup)(unsafe.Pointer(p)).FisAttached = 0 + if uintptr(0) == (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc || uintptr(0) == (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest || _checkReadTransaction(tls, pDestDb, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest) != SQLITE_OK { + /* One (or both) of the named databases did not exist or an OOM + ** error was hit. Or there is a transaction open on the destination + ** database. The error has already been written into the pDestDb + ** handle. All that is left to do here is free the sqlite3_backup + ** structure. */ + Xsqlite3_free(tls, p) + p = uintptr(0) + } + } + if p != 0 { + (*TBtree)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FnBackup = (*TBtree)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FnBackup + 1 + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(pDestDb)).Fmutex) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(pSrcDb)).Fmutex) + return p +} + +// C documentation +// +// /* +// ** Open a blob handle. +// */ +func Xsqlite3_blob_open(tls *libc.TLS, db uintptr, zDb uintptr, zTable uintptr, zColumn uintptr, iRow Tsqlite_int64, wrFlag int32, ppBlob uintptr) (r int32) { + bp := tls.Alloc(448) + defer tls.Free(448) + var aOp, pBlob, pFKey, pIdx, pTab, v, zFault, v8 uintptr + var iCol, iDb, j, j1, nAttempt, rc, v1 int32 + var v2 bool + var _ /* sParse at bp+8 */ TParse + var _ /* zErr at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aOp, iCol, iDb, j, j1, nAttempt, pBlob, pFKey, pIdx, pTab, rc, v, zFault, v1, v2, v8 + nAttempt = 0 /* Index of zColumn in row-record */ + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pBlob = uintptr(0) + **(**uintptr)(__ccgo_up(ppBlob)) = uintptr(0) + wrFlag = libc.BoolInt32(!!(wrFlag != 0)) /* wrFlag = (wrFlag ? 1 : 0); */ + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pBlob = _sqlite3DbMallocZero(tls, db, uint64(56)) + for int32(1) != 0 { + _sqlite3ParseObjectInit(tls, bp+8, db) + if !(pBlob != 0) { + goto blob_open_out + } + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _sqlite3BtreeEnterAll(tls, db) + pTab = _sqlite3LocateTable(tls, bp+8, uint32(0), zTable, zDb) + if pTab != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + pTab = uintptr(0) + _sqlite3ErrorMsg(tls, bp+8, __ccgo_ts+6893, libc.VaList(bp+432, zTable)) + } + if pTab != 0 && !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pTab = uintptr(0) + _sqlite3ErrorMsg(tls, bp+8, __ccgo_ts+6923, libc.VaList(bp+432, zTable)) + } + if pTab != 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != uint32(0) { + pTab = uintptr(0) + _sqlite3ErrorMsg(tls, bp+8, __ccgo_ts+6959, libc.VaList(bp+432, zTable)) + } + if pTab != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + pTab = uintptr(0) + _sqlite3ErrorMsg(tls, bp+8, __ccgo_ts+7004, libc.VaList(bp+432, zTable)) + } + if v2 = pTab == uintptr(0); !v2 { + v1 = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + iDb = v1 + } + if v2 || v1 == int32(1) && _sqlite3OpenTempDatabase(tls, bp+8) != 0 { + if (**(**TParse)(__ccgo_up(bp + 8))).FzErrMsg != 0 { + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = (**(**TParse)(__ccgo_up(bp + 8))).FzErrMsg + (**(**TParse)(__ccgo_up(bp + 8))).FzErrMsg = uintptr(0) + } + rc = int32(SQLITE_ERROR) + _sqlite3BtreeLeaveAll(tls, db) + goto blob_open_out + } + (*TIncrblob)(unsafe.Pointer(pBlob)).FpTab = pTab + (*TIncrblob)(unsafe.Pointer(pBlob)).FzDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Now search pTab for the exact column. */ + iCol = _sqlite3ColumnIndex(tls, pTab, zColumn) + if iCol < 0 { + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = _sqlite3MPrintf(tls, db, __ccgo_ts+7025, libc.VaList(bp+432, zColumn)) + rc = int32(SQLITE_ERROR) + _sqlite3BtreeLeaveAll(tls, db) + goto blob_open_out + } + /* If the value is being opened for writing, check that the + ** column is not indexed, and that it is not part of a foreign key. + */ + if wrFlag != 0 { + zFault = uintptr(0) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 { + pFKey = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey + for { + if !(pFKey != 0) { + break + } + j = 0 + for { + if !(j < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + if (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(j)*16))).FiFrom == iCol { + zFault = __ccgo_ts + 7046 + } + goto _4 + _4: + ; + j = j + 1 + } + goto _3 + _3: + ; + pFKey = (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom + } + } + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + j1 = 0 + for { + if !(j1 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + /* FIXME: Be smarter about indexes that use expressions */ + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j1)*2))) == iCol || int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j1)*2))) == -int32(2) { + zFault = __ccgo_ts + 7058 + } + goto _6 + _6: + ; + j1 = j1 + 1 + } + goto _5 + _5: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if zFault != 0 { + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = _sqlite3MPrintf(tls, db, __ccgo_ts+7066, libc.VaList(bp+432, zFault)) + rc = int32(SQLITE_ERROR) + _sqlite3BtreeLeaveAll(tls, db) + goto blob_open_out + } + } + (*TIncrblob)(unsafe.Pointer(pBlob)).FpStmt = _sqlite3VdbeCreate(tls, bp+8) + if (*TIncrblob)(unsafe.Pointer(pBlob)).FpStmt != 0 { + v = (*TIncrblob)(unsafe.Pointer(pBlob)).FpStmt + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Transaction), iDb, wrFlag, (*TSchema)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FpSchema)).Fschema_cookie, (*TSchema)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FpSchema)).FiGeneration) + _sqlite3VdbeChangeP5(tls, v, uint16(1)) + aOp = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(24)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_openBlob)), _iLn) + /* Make sure a mutex is held on the table to be accessed */ + _sqlite3VdbeUsesBtree(tls, v, iDb) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + /* Configure the OP_TableLock instruction */ + (**(**TVdbeOp)(__ccgo_up(aOp))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp))).Fp2 = libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab)).Ftnum) + (**(**TVdbeOp)(__ccgo_up(aOp))).Fp3 = wrFlag + _sqlite3VdbeChangeP4(tls, v, int32(2), (*TTable)(unsafe.Pointer(pTab)).FzName, P4_TRANSIENT) + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + /* Remove either the OP_OpenWrite or OpenRead. Set the P2 + ** parameter of the other to pTab->tnum. */ + if wrFlag != 0 { + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fopcode = uint8(OP_OpenWrite) + } + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp2 = libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab)).Ftnum) + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp3 = iDb + /* Configure the number of columns. Configure the cursor to + ** think that the table has one more column than it really + ** does. An OP_Column to retrieve this imaginary column will + ** always return an SQL NULL. This is useful because it means + ** we can invoke OP_Column to fill in the vdbe cursors type + ** and offset cache without causing any IO. + */ + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp4type = int8(-libc.Int32FromInt32(3)) + *(*int32)(unsafe.Pointer(aOp + 1*24 + 16)) = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + int32(1) + (**(**TVdbeOp)(__ccgo_up(aOp + 3*24))).Fp2 = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + (**(**TParse)(__ccgo_up(bp + 8))).FnVar = 0 + (**(**TParse)(__ccgo_up(bp + 8))).FnMem = int32(1) + (**(**TParse)(__ccgo_up(bp + 8))).FnTab = int32(1) + _sqlite3VdbeMakeReady(tls, v, bp+8) + } + } + (*TIncrblob)(unsafe.Pointer(pBlob)).FiCol = libc.Uint16FromInt32(iCol) + (*TIncrblob)(unsafe.Pointer(pBlob)).Fdb = db + _sqlite3BtreeLeaveAll(tls, db) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto blob_open_out + } + rc = _blobSeekToRow(tls, pBlob, iRow, bp) + nAttempt = nAttempt + 1 + v1 = nAttempt + if v1 >= int32(SQLITE_MAX_SCHEMA_RETRY) || rc != int32(SQLITE_SCHEMA) { + break + } + _sqlite3ParseObjectReset(tls, bp+8) + } + goto blob_open_out +blob_open_out: + ; + if rc == SQLITE_OK && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + **(**uintptr)(__ccgo_up(ppBlob)) = pBlob + } else { + if pBlob != 0 && (*TIncrblob)(unsafe.Pointer(pBlob)).FpStmt != 0 { + _sqlite3VdbeFinalize(tls, (*TIncrblob)(unsafe.Pointer(pBlob)).FpStmt) + } + _sqlite3DbFree(tls, db, pBlob) + } + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v8 = __ccgo_ts + 3944 + } else { + v8 = libc.UintptrFromInt32(0) + } + _sqlite3ErrorWithMsg(tls, db, rc, v8, libc.VaList(bp+432, **(**uintptr)(__ccgo_up(bp)))) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + _sqlite3ParseObjectReset(tls, bp+8) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Given the name of a compile-time option, return true if that option +// ** was used and false if not. +// ** +// ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix +// ** is not required for a match. +// */ +func Xsqlite3_compileoption_used(tls *libc.TLS, zOptName uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azCompileOpt uintptr + var i, n int32 + var _ /* nOpt at bp+0 */ int32 + _, _, _ = azCompileOpt, i, n + azCompileOpt = _sqlite3CompileOptions(tls, bp) + if Xsqlite3_strnicmp(tls, zOptName, __ccgo_ts+26690, int32(7)) == 0 { + zOptName = zOptName + uintptr(7) + } + n = _sqlite3Strlen30(tls, zOptName) + /* Since nOpt is normally in single digits, a linear search is + ** adequate. No need for a binary search. */ + i = 0 + for { + if !(i < **(**int32)(__ccgo_up(bp))) { + break + } + if Xsqlite3_strnicmp(tls, zOptName, **(**uintptr)(__ccgo_up(azCompileOpt + uintptr(i)*8)), n) == 0 && _sqlite3IsIdChar(tls, libc.Uint8FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(azCompileOpt + uintptr(i)*8)) + uintptr(n))))) == 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Return TRUE if the given SQL string ends in a semicolon. +// ** +// ** Special handling is require for CREATE TRIGGER statements. +// ** Whenever the CREATE TRIGGER keywords are seen, the statement +// ** must end with ";END;". +// ** +// ** This implementation uses a state machine with 8 states: +// ** +// ** (0) INVALID We have not yet seen a non-whitespace character. +// ** +// ** (1) START At the beginning or end of an SQL statement. This routine +// ** returns 1 if it ends in the START state and 0 if it ends +// ** in any other state. +// ** +// ** (2) NORMAL We are in the middle of statement which ends with a single +// ** semicolon. +// ** +// ** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of +// ** a statement. +// ** +// ** (4) CREATE The keyword CREATE has been seen at the beginning of a +// ** statement, possibly preceded by EXPLAIN and/or followed by +// ** TEMP or TEMPORARY +// ** +// ** (5) TRIGGER We are in the middle of a trigger definition that must be +// ** ended by a semicolon, the keyword END, and another semicolon. +// ** +// ** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at +// ** the end of a trigger definition. +// ** +// ** (7) END We've seen the ";END" of the ";END;" that occurs at the end +// ** of a trigger definition. +// ** +// ** Transitions between states above are determined by tokens extracted +// ** from the input. The following tokens are significant: +// ** +// ** (0) tkSEMI A semicolon. +// ** (1) tkWS Whitespace. +// ** (2) tkOTHER Any other SQL token. +// ** (3) tkEXPLAIN The "explain" keyword. +// ** (4) tkCREATE The "create" keyword. +// ** (5) tkTEMP The "temp" or "temporary" keyword. +// ** (6) tkTRIGGER The "trigger" keyword. +// ** (7) tkEND The "end" keyword. +// ** +// ** Whitespace never causes a state transition and is always ignored. +// ** This means that a SQL string of all whitespace is invalid. +// ** +// ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed +// ** to recognize the end of a trigger can be omitted. All we have to do +// ** is look for a semicolon that is not part of an string or comment. +// */ +func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) (r int32) { + var c, nId int32 + var state, token Tu8 + _, _, _, _ = c, nId, state, token + state = uint8(0) /* Value of the next token */ + for **(**int8)(__ccgo_up(zSql)) != 0 { + switch int32(**(**int8)(__ccgo_up(zSql))) { + case int32(';'): /* A semicolon */ + token = uint8(tkSEMI) + case int32(' '): + fallthrough + case int32('\r'): + fallthrough + case int32('\t'): + fallthrough + case int32('\n'): + fallthrough + case int32('\f'): /* White space is ignored */ + token = uint8(tkWS) + case int32('/'): /* C-style comments */ + if int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('*') { + token = uint8(tkOTHER) + break + } + zSql = zSql + uintptr(2) + for **(**int8)(__ccgo_up(zSql)) != 0 && (int32(**(**int8)(__ccgo_up(zSql))) != int32('*') || int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('/')) { + zSql = zSql + 1 + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + return 0 + } + zSql = zSql + 1 + token = uint8(tkWS) + case int32('-'): /* SQL-style comments from "--" to end of line */ + if int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('-') { + token = uint8(tkOTHER) + break + } + for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != int32('\n') { + zSql = zSql + 1 + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + return libc.BoolInt32(libc.Int32FromUint8(state) == int32(1)) + } + token = uint8(tkWS) + case int32('['): /* Microsoft-style identifiers in [...] */ + zSql = zSql + 1 + for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != int32(']') { + zSql = zSql + 1 + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + return 0 + } + token = uint8(tkOTHER) + case int32('`'): /* Grave-accent quoted symbols used by MySQL */ + fallthrough + case int32('"'): /* single- and double-quoted strings */ + fallthrough + case int32('\''): + c = int32(**(**int8)(__ccgo_up(zSql))) + zSql = zSql + 1 + for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != c { + zSql = zSql + 1 + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + return 0 + } + token = uint8(tkOTHER) + default: + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zSql)))])&int32(0x46) != 0 { + nId = int32(1) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zSql + uintptr(nId))))])&int32(0x46) != 0) { + break + } + goto _1 + _1: + ; + nId = nId + 1 + } + switch int32(**(**int8)(__ccgo_up(zSql))) { + case int32('c'): + fallthrough + case int32('C'): + if nId == int32(6) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25579, int32(6)) == 0 { + token = uint8(tkCREATE) + } else { + token = uint8(tkOTHER) + } + case int32('t'): + fallthrough + case int32('T'): + if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+22233, int32(7)) == 0 { + token = uint8(tkTRIGGER) + } else { + if nId == int32(4) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25586, int32(4)) == 0 { + token = uint8(tkTEMP) + } else { + if nId == int32(9) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25591, int32(9)) == 0 { + token = uint8(tkTEMP) + } else { + token = uint8(tkOTHER) + } + } + } + case int32('e'): + fallthrough + case int32('E'): + if nId == int32(3) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25601, int32(3)) == 0 { + token = uint8(tkEND) + } else { + if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25605, int32(7)) == 0 { + token = uint8(tkEXPLAIN) + } else { + token = uint8(tkOTHER) + } + } + default: + token = uint8(tkOTHER) + break + } + zSql = zSql + uintptr(nId-int32(1)) + } else { + /* Operators and special symbols */ + token = uint8(tkOTHER) + } + break + } + state = **(**Tu8)(__ccgo_up(uintptr(unsafe.Pointer(&_trans)) + uintptr(state)*8 + uintptr(token))) + zSql = zSql + 1 + } + return libc.BoolInt32(libc.Int32FromUint8(state) == int32(1)) +} + +// C documentation +// +// /* +// ** Allocate memory to hold names for a database, journal file, WAL file, +// ** and query parameters. The pointer returned is valid for use by +// ** sqlite3_filename_database() and sqlite3_uri_parameter() and related +// ** functions. +// ** +// ** Memory layout must be compatible with that generated by the pager +// ** and expected by sqlite3_uri_parameter() and databaseName(). +// */ +func Xsqlite3_create_filename(tls *libc.TLS, zDatabase uintptr, zJournal uintptr, zWal uintptr, nParam int32, azParam uintptr) (r uintptr) { + var i int32 + var nByte Tsqlite3_int64 + var p, pResult, v2 uintptr + _, _, _, _, _ = i, nByte, p, pResult, v2 + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, zDatabase) + libc.Xstrlen(tls, zJournal) + libc.Xstrlen(tls, zWal) + uint64(10)) + i = 0 + for { + if !(i < nParam*int32(2)) { + break + } + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(azParam + uintptr(i)*8)))+libc.Uint64FromInt32(1))) + goto _1 + _1: + ; + i = i + 1 + } + v2 = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + p = v2 + pResult = v2 + if p == uintptr(0) { + return uintptr(0) + } + libc.X__builtin___memset_chk(tls, p, 0, uint64(4), ^t__predefined_size_t(0)) + p = p + uintptr(4) + p = _appendText(tls, p, zDatabase) + i = 0 + for { + if !(i < nParam*int32(2)) { + break + } + p = _appendText(tls, p, **(**uintptr)(__ccgo_up(azParam + uintptr(i)*8))) + goto _3 + _3: + ; + i = i + 1 + } + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = 0 + p = _appendText(tls, p, zJournal) + p = _appendText(tls, p, zWal) + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = 0 + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = 0 + return pResult + uintptr(4) +} + +// C documentation +// +// /* +// ** This function is used to set the schema of a virtual table. It is only +// ** valid to call this function from within the xCreate() or xConnect() of a +// ** virtual table module. +// */ +func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) (r int32) { + bp := tls.Alloc(448) + defer tls.Free(448) + var i, initBusy, rc int32 + var pCtx, pIdx, pNew, pTab, z, v3 uintptr + var v2 Ti16 + var _ /* sParse at bp+0 */ TParse + var _ /* tokenType at bp+416 */ int32 + _, _, _, _, _, _, _, _, _, _ = i, initBusy, pCtx, pIdx, pNew, pTab, rc, z, v2, v3 + rc = SQLITE_OK + /* Verify that the first two keywords in the CREATE TABLE statement + ** really are "CREATE" and "TABLE". If this is not the case, then + ** sqlite3_declare_vtab() is being misused. + */ + z = zCreateTable + i = 0 + for { + if !(_aKeyword1[i] != 0) { + break + } + **(**int32)(__ccgo_up(bp + 416)) = 0 + for cond := true; cond; cond = **(**int32)(__ccgo_up(bp + 416)) == int32(TK_SPACE) || **(**int32)(__ccgo_up(bp + 416)) == int32(TK_COMMENT) { + z = z + uintptr(_sqlite3GetToken(tls, z, bp+416)) + } + if **(**int32)(__ccgo_up(bp + 416)) != libc.Int32FromUint8(_aKeyword1[i]) { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_ERROR), __ccgo_ts+23931, 0) + return int32(SQLITE_ERROR) + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pCtx = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + if !(pCtx != 0) || (*TVtabCtx)(unsafe.Pointer(pCtx)).FbDeclared != 0 { + _sqlite3Error(tls, db, _sqlite3MisuseError(tls, int32(162573))) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return _sqlite3MisuseError(tls, int32(162575)) + } + pTab = (*TVtabCtx)(unsafe.Pointer(pCtx)).FpTab + _sqlite3ParseObjectInit(tls, bp, db) + (**(**TParse)(__ccgo_up(bp))).FeParseMode = uint8(PARSE_MODE_DECLARE_VTAB) + libc.SetBitFieldPtr16Uint32(bp+40, libc.Uint32FromInt32(1), 0, 0x1) + /* We should never be able to reach this point while loading the + ** schema. Nevertheless, defend against that (turn off db->init.busy) + ** in case a bug arises. */ + initBusy = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(0) + (**(**TParse)(__ccgo_up(bp))).FnQueryLoop = int16(1) + if SQLITE_OK == _sqlite3RunParser(tls, bp, zCreateTable) { + if !((*TTable)(unsafe.Pointer(pTab)).FaCol != 0) { + pNew = (**(**TParse)(__ccgo_up(bp))).FpNewTable + (*TTable)(unsafe.Pointer(pTab)).FaCol = (*TTable)(unsafe.Pointer(pNew)).FaCol + _sqlite3ExprListDelete(tls, db, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FpDfltList) + v2 = (*TTable)(unsafe.Pointer(pNew)).FnCol + (*TTable)(unsafe.Pointer(pTab)).FnCol = v2 + (*TTable)(unsafe.Pointer(pTab)).FnNVCol = v2 + **(**Tu32)(__ccgo_up(pTab + 48)) |= (*TTable)(unsafe.Pointer(pNew)).FtabFlags & libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid)|libc.Int32FromInt32(TF_NoVisibleRowid)) + (*TTable)(unsafe.Pointer(pNew)).FnCol = 0 + (*TTable)(unsafe.Pointer(pNew)).FaCol = uintptr(0) + if !((*TTable)(unsafe.Pointer(pNew)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer((*TVtabCtx)(unsafe.Pointer(pCtx)).FpVTable)).FpMod)).FpModule)).FxUpdate != uintptr(0) && libc.Int32FromUint16((*TIndex)(unsafe.Pointer(_sqlite3PrimaryKeyIndex(tls, pNew))).FnKeyCol) != int32(1) { + /* WITHOUT ROWID virtual tables must either be read-only (xUpdate==0) + ** or else must have a single-column PRIMARY KEY */ + rc = int32(SQLITE_ERROR) + } + pIdx = (*TTable)(unsafe.Pointer(pNew)).FpIndex + if pIdx != 0 { + (*TTable)(unsafe.Pointer(pTab)).FpIndex = pIdx + (*TTable)(unsafe.Pointer(pNew)).FpIndex = uintptr(0) + (*TIndex)(unsafe.Pointer(pIdx)).FpTable = pTab + } + } + (*TVtabCtx)(unsafe.Pointer(pCtx)).FbDeclared = int32(1) + } else { + if (**(**TParse)(__ccgo_up(bp))).FzErrMsg != 0 { + v3 = __ccgo_ts + 3944 + } else { + v3 = uintptr(0) + } + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_ERROR), v3, libc.VaList(bp+432, (**(**TParse)(__ccgo_up(bp))).FzErrMsg)) + _sqlite3DbFree(tls, db, (**(**TParse)(__ccgo_up(bp))).FzErrMsg) + rc = int32(SQLITE_ERROR) + } + (**(**TParse)(__ccgo_up(bp))).FeParseMode = uint8(PARSE_MODE_NORMAL) + if (**(**TParse)(__ccgo_up(bp))).FpVdbe != 0 { + _sqlite3VdbeFinalize(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe) + } + _sqlite3DeleteTable(tls, db, (**(**TParse)(__ccgo_up(bp))).FpNewTable) + _sqlite3ParseObjectReset(tls, bp) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = libc.Uint8FromInt32(initBusy) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* Convert zSchema to a MemDB and initialize its content. +// */ +func Xsqlite3_deserialize(tls *libc.TLS, db uintptr, zSchema uintptr, pData uintptr, szDb Tsqlite3_int64, szBuf Tsqlite3_int64, mFlags uint32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iDb, rc int32 + var p, pStore, zSql uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _ = iDb, p, pStore, rc, zSql + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if zSchema == uintptr(0) { + zSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName + } + iDb = _sqlite3FindDbName(tls, db, zSchema) + if iDb < int32(2) && iDb != 0 { + rc = int32(SQLITE_ERROR) + goto end_deserialize + } + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+4529, libc.VaList(bp+16, zSchema)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + Xsqlite3_free(tls, zSql) + } + if rc != 0 { + goto end_deserialize + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(iDb) + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(1), 3, 0x8) + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(0), 3, 0x8) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc != SQLITE_OK { + goto end_deserialize + } + p = _memdbFromDbSchema(tls, db, zSchema) + if p == uintptr(0) { + rc = int32(SQLITE_ERROR) + } else { + pStore = (*TMemFile)(unsafe.Pointer(p)).FpStore + (*TMemStore)(unsafe.Pointer(pStore)).FaData = pData + pData = uintptr(0) + (*TMemStore)(unsafe.Pointer(pStore)).Fsz = szDb + (*TMemStore)(unsafe.Pointer(pStore)).FszAlloc = szBuf + (*TMemStore)(unsafe.Pointer(pStore)).FszMax = szBuf + if (*TMemStore)(unsafe.Pointer(pStore)).FszMax < _sqlite3Config.FmxMemdbSize { + (*TMemStore)(unsafe.Pointer(pStore)).FszMax = _sqlite3Config.FmxMemdbSize + } + (*TMemStore)(unsafe.Pointer(pStore)).FmFlags = mFlags + rc = SQLITE_OK + } + goto end_deserialize +end_deserialize: + ; + if pData != 0 && mFlags&uint32(SQLITE_DESERIALIZE_FREEONCLOSE) != uint32(0) { + Xsqlite3_free(tls, pData) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Initialize SQLite. +// ** +// ** This routine must be called to initialize the memory allocation, +// ** VFS, and mutex subsystems prior to doing any serious work with +// ** SQLite. But as long as you do not compile with SQLITE_OMIT_AUTOINIT +// ** this routine will be called automatically by key routines such as +// ** sqlite3_open(). +// ** +// ** This routine is a no-op except on its very first call for the process, +// ** or for the first call after a call to sqlite3_shutdown. +// ** +// ** The first thread to call this routine runs the initialization to +// ** completion. If subsequent threads call this routine before the first +// ** thread has finished the initialization process, then the subsequent +// ** threads must block until the first thread finishes with the initialization. +// ** +// ** The first thread might call this routine recursively. Recursive +// ** calls to this routine should not block, of course. Otherwise the +// ** initialization process would never complete. +// ** +// ** Let X be the first thread to enter this routine. Let Y be some other +// ** thread. Then while the initial invocation of this routine by X is +// ** incomplete, it is required that: +// ** +// ** * Calls to this routine from Y must block until the outer-most +// ** call by X completes. +// ** +// ** * Recursive calls to this routine from thread X return immediately +// ** without blocking. +// */ +func Xsqlite3_initialize(tls *libc.TLS) (r int32) { + var pMainMtx uintptr + var rc int32 + _, _ = pMainMtx, rc /* Result code */ + /* If the following assert() fails on some obscure processor/compiler + ** combination, the work-around is to set the correct pointer + ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */ + /* If SQLite is already completely initialized, then this call + ** to sqlite3_initialize() should be a no-op. But the initialization + ** must be complete. So isInit must not be set until the very end + ** of this routine. + */ + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340) != 0 { + return SQLITE_OK + } + /* Make sure the mutex subsystem is initialized. If unable to + ** initialize the mutex subsystem, return early with the error. + ** If the system is so sick that we are unable to allocate a mutex, + ** there is not much SQLite is going to be able to do. + ** + ** The mutex subsystem must take care of serializing its own + ** initialization. + */ + rc = _sqlite3MutexInit(tls) + if rc != 0 { + return rc + } + /* Initialize the malloc() system and the recursive pInitMutex mutex. + ** This operation is protected by the STATIC_MAIN mutex. Note that + ** MutexAlloc() is called for a static mutex prior to initializing the + ** malloc subsystem - this implies that the allocation of a static + ** mutex must not require support from the malloc subsystem. + */ + pMainMtx = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + Xsqlite3_mutex_enter(tls, pMainMtx) + _sqlite3Config.FisMutexInit = int32(1) + if !(_sqlite3Config.FisMallocInit != 0) { + rc = _sqlite3MallocInit(tls) + } + if rc == SQLITE_OK { + _sqlite3Config.FisMallocInit = int32(1) + if !(_sqlite3Config.FpInitMutex != 0) { + _sqlite3Config.FpInitMutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_RECURSIVE)) + if _sqlite3Config.FbCoreMutex != 0 && !(_sqlite3Config.FpInitMutex != 0) { + rc = int32(SQLITE_NOMEM) + } + } + } + if rc == SQLITE_OK { + _sqlite3Config.FnRefInitMutex = _sqlite3Config.FnRefInitMutex + 1 + } + Xsqlite3_mutex_leave(tls, pMainMtx) + /* If rc is not SQLITE_OK at this point, then either the malloc + ** subsystem could not be initialized or the system failed to allocate + ** the pInitMutex mutex. Return an error in either case. */ + if rc != SQLITE_OK { + return rc + } + /* Do the rest of the initialization under the recursive mutex so + ** that we will be able to handle recursive calls into + ** sqlite3_initialize(). The recursive calls normally come through + ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other + ** recursive calls might also be possible. + ** + ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls + ** to the xInit method, so the xInit method need not be threadsafe. + ** + ** The following mutex is what serializes access to the appdef pcache xInit + ** methods. The sqlite3_pcache_methods.xInit() all is embedded in the + ** call to sqlite3PcacheInitialize(). + */ + Xsqlite3_mutex_enter(tls, _sqlite3Config.FpInitMutex) + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340) == 0 && _sqlite3Config.FinProgress == 0 { + _sqlite3Config.FinProgress = int32(1) + libc.X__builtin___memset_chk(tls, uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)), 0, uint64(184), ^t__predefined_size_t(0)) + _sqlite3RegisterBuiltinFunctions(tls) + if _sqlite3Config.FisPCacheInit == 0 { + rc = _sqlite3PcacheInitialize(tls) + } + if rc == SQLITE_OK { + _sqlite3Config.FisPCacheInit = int32(1) + rc = _sqlite3OsInit(tls) + } + if rc == SQLITE_OK { + rc = _sqlite3MemdbInit(tls) + } + if rc == SQLITE_OK { + _sqlite3PCacheBufferSetup(tls, _sqlite3Config.FpPage, _sqlite3Config.FszPage, _sqlite3Config.FnPage) + } + if rc == SQLITE_OK { + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340, int32(1)) + } + _sqlite3Config.FinProgress = 0 + } + Xsqlite3_mutex_leave(tls, _sqlite3Config.FpInitMutex) + /* Go back under the static mutex and clean up the recursive + ** mutex to prevent a resource leak. + */ + Xsqlite3_mutex_enter(tls, pMainMtx) + _sqlite3Config.FnRefInitMutex = _sqlite3Config.FnRefInitMutex - 1 + if _sqlite3Config.FnRefInitMutex <= 0 { + Xsqlite3_mutex_free(tls, _sqlite3Config.FpInitMutex) + _sqlite3Config.FpInitMutex = uintptr(0) + } + Xsqlite3_mutex_leave(tls, pMainMtx) + /* The following is just a sanity check to make sure SQLite has + ** been compiled correctly. It is important to run this code, but + ** we don't want to run it too often and soak up CPU cycles for no + ** reason. So we run it once during initialization. + */ + /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT + ** compile-time option. + */ + return rc +} + +// C documentation +// +// /* +// ** Open a new database handle. +// */ +func Xsqlite3_open16(tls *libc.TLS, zFilename uintptr, ppDb uintptr) (r int32) { + var pVal, zFilename8 uintptr + var rc int32 + var v1 Tu8 + _, _, _, _ = pVal, rc, zFilename8, v1 + **(**uintptr)(__ccgo_up(ppDb)) = uintptr(0) + rc = Xsqlite3_initialize(tls) + if rc != 0 { + return rc + } + if zFilename == uintptr(0) { + zFilename = __ccgo_ts + 26590 + } + pVal = _sqlite3ValueNew(tls, uintptr(0)) + _sqlite3ValueSetStr(tls, pVal, -int32(1), zFilename, uint8(SQLITE_UTF16LE), libc.UintptrFromInt32(0)) + zFilename8 = _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF8)) + if zFilename8 != 0 { + rc = _openDatabase(tls, zFilename8, ppDb, libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OPEN_READWRITE)|libc.Int32FromInt32(SQLITE_OPEN_CREATE)), uintptr(0)) + if rc == SQLITE_OK && !(libc.Int32FromUint16((*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppDb)))).FaDb))).FpSchema)).FschemaFlags)&libc.Int32FromInt32(DB_SchemaLoaded) == libc.Int32FromInt32(DB_SchemaLoaded)) { + v1 = libc.Uint8FromInt32(SQLITE_UTF16LE) + (*Tsqlite3)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppDb)))).Fenc = v1 + (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppDb)))).FaDb))).FpSchema)).Fenc = v1 + } + } else { + rc = int32(SQLITE_NOMEM) + } + _sqlite3ValueFree(tls, pVal) + return rc & int32(0xff) +} + +// C documentation +// +// /* +// ** Initialize the operating system interface. +// ** +// ** This routine registers all VFS implementations for unix-like operating +// ** systems. This routine, and the sqlite3_os_end() routine that follows, +// ** should be the only routines in this file that are visible from other +// ** files. +// ** +// ** This routine is called once during SQLite initialization and by a +// ** single thread. The memory allocation and mutex subsystems have not +// ** necessarily been initialized when this routine is called, and so they +// ** should not be used. +// */ +func Xsqlite3_os_init(tls *libc.TLS) (r int32) { + var i uint32 + _ = i + /* Double-check that the aSyscall[] array has been constructed + ** correctly. See ticket [bb3a86e890c8e96ab] */ + /* Register all VFSes defined in the aVfs[] array */ + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(1512)/libc.Uint64FromInt64(168)) { + break + } + Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&_aVfs))+uintptr(i)*168, libc.BoolInt32(i == uint32(0))) + goto _1 + _1: + ; + i = i + 1 + } + _unixBigLock = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1)) + /* Validate lock assumptions */ + /* Number of available locks */ + /* Start of locking area */ + /* Locks: + ** WRITE UNIX_SHM_BASE 120 + ** CKPT UNIX_SHM_BASE+1 121 + ** RECOVER UNIX_SHM_BASE+2 122 + ** READ-0 UNIX_SHM_BASE+3 123 + ** READ-1 UNIX_SHM_BASE+4 124 + ** READ-2 UNIX_SHM_BASE+5 125 + ** READ-3 UNIX_SHM_BASE+6 126 + ** READ-4 UNIX_SHM_BASE+7 127 + ** DMS UNIX_SHM_BASE+8 128 + */ + /* Byte offset of the deadman-switch */ + /* Initialize temp file dir array. */ + _unixTempFileInit(tls) + return SQLITE_OK +} + +/* + ** The following macro defines an initializer for an sqlite3_vfs object. + ** The name of the VFS is NAME. The pAppData is a pointer to a pointer + ** to the "finder" function. (pAppData is a pointer to a pointer because + ** silly C90 rules prohibit a void* from being cast to a function pointer + ** and so we have to go through the intermediate pointer to avoid problems + ** when compiling with -pedantic-errors on GCC.) + ** + ** The FINDER parameter to this macro is the name of the pointer to the + ** finder-function. The finder-function returns a pointer to the + ** sqlite_io_methods object that implements the desired locking + ** behaviors. See the division above that contains the IOMETHODS + ** macro for addition information on finder-functions. + ** + ** Most finders simply return a pointer to a fixed sqlite3_io_methods + ** object. But the "autolockIoFinder" available on MacOSX does a little + ** more than that; it looks at the filesystem type that hosts the + ** database file and tries to choose an locking method appropriate for + ** that filesystem time. + */ + +// C documentation +// +// /* +// ** Return N random bytes. +// */ +func Xsqlite3_randomness(tls *libc.TLS, N int32, pBuf uintptr) { + var mutex, pVfs, zBuf, v1 uintptr + _, _, _, _ = mutex, pVfs, zBuf, v1 + zBuf = pBuf + if Xsqlite3_initialize(tls) != 0 { + return + } + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_PRNG)) + Xsqlite3_mutex_enter(tls, mutex) + if N <= 0 || pBuf == uintptr(0) { + **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)))) = uint32(0) + Xsqlite3_mutex_leave(tls, mutex) + return + } + /* Initialize the state of the random number generator once, + ** the first time this routine is called. + */ + if **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)))) == uint32(0) { + pVfs = Xsqlite3_vfs_find(tls, uintptr(0)) + libc.X__builtin___memcpy_chk(tls, uintptr(unsafe.Pointer(&_sqlite3Prng)), uintptr(unsafe.Pointer(&_chacha20_init)), uint64(16), ^t__predefined_size_t(0)) + if pVfs == uintptr(0) { + libc.X__builtin___memset_chk(tls, uintptr(unsafe.Pointer(&_sqlite3Prng))+4*4, 0, uint64(44), ^t__predefined_size_t(0)) + } else { + _sqlite3OsRandomness(tls, pVfs, int32(44), uintptr(unsafe.Pointer(&_sqlite3Prng))+4*4) + } + **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 15*4)) = **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 12*4)) + **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 12*4)) = uint32(0) + _sqlite3Prng.Fn = uint8(0) + } + for int32(1) != 0 { + if N <= libc.Int32FromUint8(_sqlite3Prng.Fn) { + libc.X__builtin___memcpy_chk(tls, zBuf, uintptr(unsafe.Pointer(&_sqlite3Prng))+64+uintptr(libc.Int32FromUint8(_sqlite3Prng.Fn)-N), libc.Uint64FromInt32(N), ^t__predefined_size_t(0)) + v1 = uintptr(unsafe.Pointer(&_sqlite3Prng)) + 128 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) - N) + break + } + if libc.Int32FromUint8(_sqlite3Prng.Fn) > 0 { + libc.X__builtin___memcpy_chk(tls, zBuf, uintptr(unsafe.Pointer(&_sqlite3Prng))+64, uint64(_sqlite3Prng.Fn), ^t__predefined_size_t(0)) + N = N - libc.Int32FromUint8(_sqlite3Prng.Fn) + zBuf = zBuf + uintptr(_sqlite3Prng.Fn) + } + **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 12*4)) = **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 12*4)) + 1 + _chacha_block(tls, uintptr(unsafe.Pointer(&_sqlite3Prng))+64, uintptr(unsafe.Pointer(&_sqlite3Prng))) + _sqlite3Prng.Fn = uint8(64) + } + Xsqlite3_mutex_leave(tls, mutex) +} + +// C documentation +// +// /* Force an SQLITE_TOOBIG error. */ +func Xsqlite3_result_error_toobig(tls *libc.TLS, pCtx uintptr) { + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = int32(SQLITE_TOOBIG) + _sqlite3VdbeMemSetStr(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, __ccgo_ts+5934, int64(-int32(1)), uint8(SQLITE_UTF8), libc.UintptrFromInt32(0)) +} + +// C documentation +// +// /* +// ** Return the serialization of a database +// */ +func Xsqlite3_serialize(tls *libc.TLS, db uintptr, zSchema uintptr, piSize uintptr, mFlags uint32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iDb, nPage, pgno, rc, szPage, v1 int32 + var p, pBt, pOut, pPager, pStore, pTo, zSql uintptr + var sz Tsqlite3_int64 + var _ /* pPage at bp+8 */ uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iDb, nPage, p, pBt, pOut, pPager, pStore, pTo, pgno, rc, sz, szPage, zSql, v1 + szPage = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if zSchema == uintptr(0) { + zSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName + } + p = _memdbFromDbSchema(tls, db, zSchema) + iDb = _sqlite3FindDbName(tls, db, zSchema) + if piSize != 0 { + **(**Tsqlite3_int64)(__ccgo_up(piSize)) = int64(-int32(1)) + } + if iDb < 0 { + return uintptr(0) + } + if p != 0 { + pStore = (*TMemFile)(unsafe.Pointer(p)).FpStore + if piSize != 0 { + **(**Tsqlite3_int64)(__ccgo_up(piSize)) = (*TMemStore)(unsafe.Pointer(pStore)).Fsz + } + if mFlags&uint32(SQLITE_SERIALIZE_NOCOPY) != 0 { + pOut = (*TMemStore)(unsafe.Pointer(pStore)).FaData + } else { + pOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64((*TMemStore)(unsafe.Pointer(pStore)).Fsz)) + if pOut != 0 { + libc.X__builtin___memcpy_chk(tls, pOut, (*TMemStore)(unsafe.Pointer(pStore)).FaData, libc.Uint64FromInt64((*TMemStore)(unsafe.Pointer(pStore)).Fsz), ^t__predefined_size_t(0)) + } + } + return pOut + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if pBt == uintptr(0) { + return uintptr(0) + } + szPage = _sqlite3BtreeGetPageSize(tls, pBt) + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+4481, libc.VaList(bp+24, zSchema)) + if zSql != 0 { + v1 = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + } else { + v1 = int32(SQLITE_NOMEM) + } + rc = v1 + Xsqlite3_free(tls, zSql) + if rc != 0 { + return uintptr(0) + } + rc = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + if rc != int32(SQLITE_ROW) { + pOut = uintptr(0) + } else { + sz = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) * int64(szPage) + if sz == 0 { + Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + Xsqlite3_exec(tls, db, __ccgo_ts+4504, uintptr(0), uintptr(0), uintptr(0)) + rc = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == int32(SQLITE_ROW) { + sz = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) * int64(szPage) + } + } + if piSize != 0 { + **(**Tsqlite3_int64)(__ccgo_up(piSize)) = sz + } + if mFlags&uint32(SQLITE_SERIALIZE_NOCOPY) != 0 { + pOut = uintptr(0) + } else { + pOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(sz)) + if pOut != 0 { + nPage = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + pPager = _sqlite3BtreePager(tls, pBt) + pgno = int32(1) + for { + if !(pgno <= nPage) { + break + } + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pTo = pOut + uintptr(int64(szPage)*int64(pgno-libc.Int32FromInt32(1))) + rc = _sqlite3PagerGet(tls, pPager, libc.Uint32FromInt32(pgno), bp+8, 0) + if rc == SQLITE_OK { + libc.X__builtin___memcpy_chk(tls, pTo, _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 8))), libc.Uint64FromInt32(szPage), ^t__predefined_size_t(0)) + } else { + libc.X__builtin___memset_chk(tls, pTo, 0, libc.Uint64FromInt32(szPage), ^t__predefined_size_t(0)) + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + goto _2 + _2: + ; + pgno = pgno + 1 + } + } + } + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return pOut +} + +// C documentation +// +// /* +// ** Add new client data to a database connection. +// */ +func Xsqlite3_set_clientdata(tls *libc.TLS, db uintptr, zName uintptr, pData uintptr, __ccgo_fp_xDestructor uintptr) (r int32) { + var n Tsize_t + var p, pp uintptr + _, _, _ = n, p, pp + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pp = db + 808 + p = (*Tsqlite3)(unsafe.Pointer(db)).FpDbData + for { + if !(p != 0 && libc.Xstrcmp(tls, p+24, zName) != 0) { + break + } + pp = p + goto _1 + _1: + ; + p = (*TDbClientData)(unsafe.Pointer(p)).FpNext + } + if p != 0 { + if (*TDbClientData)(unsafe.Pointer(p)).FxDestructor != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TDbClientData)(unsafe.Pointer(p)).FxDestructor})))(tls, (*TDbClientData)(unsafe.Pointer(p)).FpData) + } + if pData == uintptr(0) { + **(**uintptr)(__ccgo_up(pp)) = (*TDbClientData)(unsafe.Pointer(p)).FpNext + Xsqlite3_free(tls, p) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK + } + } else { + if pData == uintptr(0) { + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK + } else { + n = libc.Xstrlen(tls, zName) + p = Xsqlite3_malloc64(tls, uint64(uint64(libc.UintptrFromInt32(0)+24)+(n+libc.Uint64FromInt32(1)))) + if p == uintptr(0) { + if __ccgo_fp_xDestructor != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDestructor})))(tls, pData) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, p+24, zName, n+uint64(1), ^t__predefined_size_t(0)) + (*TDbClientData)(unsafe.Pointer(p)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).FpDbData + (*Tsqlite3)(unsafe.Pointer(db)).FpDbData = p + } + } + (*TDbClientData)(unsafe.Pointer(p)).FpData = pData + (*TDbClientData)(unsafe.Pointer(p)).FxDestructor = __ccgo_fp_xDestructor + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /************** End of stmt.c ************************************************/ +// /* Return the source-id for this library */ +func Xsqlite3_sourceid(tls *libc.TLS) (r uintptr) { + return __ccgo_ts + 42859 +} + +// C documentation +// +// /* +// ** Append N bytes of text from z to the StrAccum object. Increase the +// ** size of the memory allocation for StrAccum if necessary. +// */ +func Xsqlite3_str_append(tls *libc.TLS, p uintptr, z uintptr, N int32) { + if (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar+libc.Uint32FromInt32(N) >= (*Tsqlite3_str)(unsafe.Pointer(p)).FnAlloc { + _enlargeAndAppend(tls, p, z, N) + } else { + if N != 0 { + **(**Tu32)(__ccgo_up(p + 24)) += libc.Uint32FromInt32(N) + libc.X__builtin___memcpy_chk(tls, (*Tsqlite3_str)(unsafe.Pointer(p)).FzText+uintptr((*Tsqlite3_str)(unsafe.Pointer(p)).FnChar-libc.Uint32FromInt32(N)), z, libc.Uint64FromInt32(N), ^t__predefined_size_t(0)) + } + } +} + +// C documentation +// +// /* +// ** Render a string given by "fmt" into the StrAccum object. +// */ +func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Tva_list) { + bp := tls.Alloc(128) + defer tls.Free(128) + var adj, c, e2, exp, iRound, idx, ii, ix, j, length, nOut, needQuote, nn, nn1, nn2, nn3, precision, width, x, v2, v3 int32 + var bArgList, base Tu8 + var bufpt, cset, escarg, infop, pArgList, pExpr, pItem, pSel, pToken, pre, z, zExtra, zOut, v4 uintptr + var cThousand, done, flag_alternateform, flag_altform2, flag_dp, flag_leftjustify, flag_long, flag_prefix, flag_rtz, flag_zeropad, xtype, v5, v6, v7, v8, v9 TetByte + var ch, px, wx uint32 + var ch1, prefix, q, x1, v54 int8 + var i, j1, k, n1, nBack, nCopyBytes, nCtrl, nPad, nPrior, szBufNeeded, v, v90 Ti64 + var longvalue Tsqlite_uint64 + var n Tu64 + var realvalue float64 + var v12 bool + var _ /* buf at bp+0 */ [70]int8 + var _ /* s at bp+72 */ TFpDecode + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = adj, bArgList, base, bufpt, c, cThousand, ch, ch1, cset, done, e2, escarg, exp, flag_alternateform, flag_altform2, flag_dp, flag_leftjustify, flag_long, flag_prefix, flag_rtz, flag_zeropad, i, iRound, idx, ii, infop, ix, j, j1, k, length, longvalue, n, n1, nBack, nCopyBytes, nCtrl, nOut, nPad, nPrior, needQuote, nn, nn1, nn2, nn3, pArgList, pExpr, pItem, pSel, pToken, pre, precision, prefix, px, q, realvalue, szBufNeeded, v, width, wx, x, x1, xtype, z, zExtra, zOut, v12, v2, v3, v4, v5, v54, v6, v7, v8, v9, v90 /* Thousands separator for %d and %u */ + xtype = uint8(etINVALID) /* Size of the rendering buffer */ + zExtra = uintptr(0) /* True if trailing zeros should be removed */ + pArgList = uintptr(0) /* Conversion buffer */ + /* pAccum never starts out with an empty buffer that was obtained from + ** malloc(). This precondition is required by the mprintf("%z...") + ** optimization. */ + bufpt = uintptr(0) + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_SQLFUNC) != 0 { + pArgList = libc.VaUintptr(&ap) + bArgList = uint8(1) + } else { + bArgList = uint8(0) + } + for { + v2 = int32(**(**int8)(__ccgo_up(fmt))) + c = v2 + if !(v2 != 0) { + break + } + if c != int32('%') { + bufpt = fmt + fmt = libc.Xstrchr(tls, fmt, int32('%')) + if fmt == uintptr(0) { + fmt = bufpt + uintptr(libc.Xstrlen(tls, bufpt)) + } + Xsqlite3_str_append(tls, pAccum, bufpt, int32(int64(fmt)-int64(bufpt))) + if int32(**(**int8)(__ccgo_up(fmt))) == 0 { + break + } + } + fmt = fmt + 1 + v4 = fmt + v2 = int32(**(**int8)(__ccgo_up(v4))) + c = v2 + if v2 == 0 { + Xsqlite3_str_append(tls, pAccum, __ccgo_ts+1686, int32(1)) + break + } + /* Find out what flags are present */ + v9 = libc.Uint8FromInt32(0) + flag_zeropad = v9 + v8 = v9 + flag_altform2 = v8 + v7 = v8 + flag_alternateform = v7 + v6 = v7 + cThousand = v6 + v5 = v6 + flag_prefix = v5 + flag_leftjustify = v5 + done = uint8(0) + width = 0 + flag_long = uint8(0) + precision = -int32(1) + for { + switch c { + case int32('-'): + flag_leftjustify = uint8(1) + case int32('+'): + flag_prefix = uint8('+') + case int32(' '): + flag_prefix = uint8(' ') + case int32('#'): + flag_alternateform = uint8(1) + case int32('!'): + flag_altform2 = uint8(1) + case int32('0'): + flag_zeropad = uint8(1) + case int32(','): + cThousand = uint8(',') + default: + done = uint8(1) + case int32('l'): + flag_long = uint8(1) + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + if c == int32('l') { + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + flag_long = uint8(2) + } + done = uint8(1) + case int32('1'): + fallthrough + case int32('2'): + fallthrough + case int32('3'): + fallthrough + case int32('4'): + fallthrough + case int32('5'): + fallthrough + case int32('6'): + fallthrough + case int32('7'): + fallthrough + case int32('8'): + fallthrough + case int32('9'): + wx = libc.Uint32FromInt32(c - int32('0')) + for { + fmt = fmt + 1 + v4 = fmt + v2 = int32(**(**int8)(__ccgo_up(v4))) + c = v2 + if !(v2 >= int32('0') && c <= int32('9')) { + break + } + wx = wx*uint32(10) + libc.Uint32FromInt32(c) - uint32('0') + } + width = libc.Int32FromUint32(wx & uint32(0x7fffffff)) + if c != int32('.') && c != int32('l') { + done = uint8(1) + } else { + fmt = fmt - 1 + } + case int32('*'): + if bArgList != 0 { + width = int32(_getIntArg(tls, pArgList)) + } else { + width = libc.VaInt32(&ap) + } + if width < 0 { + flag_leftjustify = uint8(1) + if width >= -int32(2147483647) { + v2 = -width + } else { + v2 = 0 + } + width = v2 + } + v2 = int32(**(**int8)(__ccgo_up(fmt + 1))) + c = v2 + if v2 != int32('.') && c != int32('l') { + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + done = uint8(1) + } + case int32('.'): + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + if c == int32('*') { + if bArgList != 0 { + precision = int32(_getIntArg(tls, pArgList)) + } else { + precision = libc.VaInt32(&ap) + } + if precision < 0 { + if precision >= -int32(2147483647) { + v2 = -precision + } else { + v2 = -int32(1) + } + precision = v2 + } + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + } else { + px = uint32(0) + for c >= int32('0') && c <= int32('9') { + px = px*uint32(10) + libc.Uint32FromInt32(c) - uint32('0') + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + } + precision = libc.Int32FromUint32(px & uint32(0x7fffffff)) + } + if c == int32('l') { + fmt = fmt - 1 + } else { + done = uint8(1) + } + break + } + goto _13 + _13: + ; + if v12 = !(done != 0); v12 { + fmt = fmt + 1 + v4 = fmt + v2 = int32(**(**int8)(__ccgo_up(v4))) + c = v2 + } + if !(v12 && v2 != 0) { + break + } + } + /* Fetch the info entry for the field */ + /* Fast hash-table lookup */ + idx = libc.Int32FromUint32(libc.Uint32FromInt32(c) % uint32(23)) + if v12 = int32(_fmtinfo[idx].Ffmttype) == c; !v12 { + v2 = int32(_fmtinfo[idx].FiNxt) + idx = v2 + } + if v12 || int32(_fmtinfo[v2].Ffmttype) == c { + infop = uintptr(unsafe.Pointer(&_fmtinfo)) + uintptr(idx)*7 + xtype = (*Tet_info)(unsafe.Pointer(infop)).Ftype1 + } else { + infop = uintptr(unsafe.Pointer(&_fmtinfo)) + xtype = uint8(etINVALID) + } + /* + ** At this point, variables are initialized as follows: + ** + ** flag_alternateform TRUE if a '#' is present. + ** flag_altform2 TRUE if a '!' is present. + ** flag_prefix '+' or ' ' or zero + ** flag_leftjustify TRUE if a '-' is present or if the + ** field width was negative. + ** flag_zeropad TRUE if the width began with 0. + ** flag_long 1 for "l", 2 for "ll" + ** width The specified field width. This is + ** always non-negative. Zero is the default. + ** precision The specified precision. The default + ** is -1. + ** xtype The class of the conversion. + ** infop Pointer to the appropriate info struct. + */ + switch libc.Int32FromUint8(xtype) { + case int32(etPOINTER): + goto _27 + case etRADIX: + goto _28 + case int32(etORDINAL): + goto _29 + case int32(etDECIMAL): + goto _30 + case int32(etGENERIC): + goto _31 + case int32(etEXP): + goto _32 + case int32(etFLOAT): + goto _33 + case int32(etSIZE): + goto _34 + case int32(etPERCENT): + goto _35 + case int32(etCHARX): + goto _36 + case int32(etDYNSTRING): + goto _37 + case int32(etSTRING): + goto _38 + case int32(etESCAPE_w): + goto _39 + case int32(etESCAPE_Q): + goto _40 + case int32(etESCAPE_q): + goto _41 + case int32(etTOKEN): + goto _42 + case int32(etSRCITEM): + goto _43 + default: + goto _44 + } + goto _45 + _27: + ; + flag_long = uint8(2) + _29: + ; + _28: + ; + cThousand = uint8(0) + _30: + ; + if libc.Int32FromUint8((*Tet_info)(unsafe.Pointer(infop)).Fflags)&int32(FLAG_SIGNED) != 0 { + if bArgList != 0 { + v = _getIntArg(tls, pArgList) + } else { + if flag_long != 0 { + if libc.Int32FromUint8(flag_long) == int32(2) { + v = libc.VaInt64(&ap) + } else { + v = int64(libc.VaInt64(&ap)) + } + } else { + v = int64(libc.VaInt32(&ap)) + } + } + if v < 0 { + longvalue = libc.Uint64FromInt64(^v) + longvalue = longvalue + 1 + prefix = int8('-') + } else { + longvalue = libc.Uint64FromInt64(v) + prefix = libc.Int8FromUint8(flag_prefix) + } + } else { + if bArgList != 0 { + longvalue = libc.Uint64FromInt64(_getIntArg(tls, pArgList)) + } else { + if flag_long != 0 { + if libc.Int32FromUint8(flag_long) == int32(2) { + longvalue = libc.VaUint64(&ap) + } else { + longvalue = uint64(libc.VaUint64(&ap)) + } + } else { + longvalue = uint64(libc.VaUint32(&ap)) + } + } + prefix = 0 + } + if longvalue == uint64(0) { + flag_alternateform = uint8(0) + } + if flag_zeropad != 0 && precision < width-libc.BoolInt32(int32(prefix) != 0) { + precision = width - libc.BoolInt32(int32(prefix) != 0) + } + if precision < libc.Int32FromInt32(SQLITE_PRINT_BUF_SIZE)-libc.Int32FromInt32(10)-libc.Int32FromInt32(SQLITE_PRINT_BUF_SIZE)/libc.Int32FromInt32(3) { + nOut = int32(SQLITE_PRINT_BUF_SIZE) + zOut = bp + } else { + n = libc.Uint64FromInt32(precision) + uint64(10) + if cThousand != 0 { + n = n + libc.Uint64FromInt32(precision/int32(3)) + } + v4 = _printfTempBuf(tls, pAccum, libc.Int64FromUint64(n)) + zExtra = v4 + zOut = v4 + if zOut == uintptr(0) { + return + } + nOut = libc.Int32FromUint64(n) + } + bufpt = zOut + uintptr(nOut-int32(1)) + if libc.Int32FromUint8(xtype) == int32(etORDINAL) { + x = libc.Int32FromUint64(longvalue % libc.Uint64FromInt32(10)) + if x >= int32(4) || longvalue/uint64(10)%uint64(10) == uint64(1) { + x = 0 + } + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = _zOrd[x*int32(2)+int32(1)] + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = _zOrd[x*int32(2)] + } + cset = uintptr(unsafe.Pointer(&_aDigits)) + uintptr((*Tet_info)(unsafe.Pointer(infop)).Fcharset) + base = (*Tet_info)(unsafe.Pointer(infop)).Fbase + for cond := true; cond; cond = longvalue > uint64(0) { /* Convert to ascii */ + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = **(**int8)(__ccgo_up(cset + uintptr(longvalue%uint64(base)))) + longvalue = longvalue / uint64(base) + } + length = int32(t__predefined_ptrdiff_t(zOut+uintptr(nOut-int32(1))) - int64(bufpt)) + if precision > length { /* zero pad */ + nn = precision - length + bufpt = bufpt - uintptr(nn) + libc.X__builtin___memset_chk(tls, bufpt, int32('0'), libc.Uint64FromInt32(nn), ^t__predefined_size_t(0)) + length = precision + } + if cThousand != 0 { + nn1 = (length - int32(1)) / int32(3) /* Number of "," to insert */ + ix = (length-int32(1))%int32(3) + int32(1) + bufpt = bufpt - uintptr(nn1) + idx = 0 + for { + if !(nn1 > 0) { + break + } + **(**int8)(__ccgo_up(bufpt + uintptr(idx))) = **(**int8)(__ccgo_up(bufpt + uintptr(idx+nn1))) + ix = ix - 1 + if ix == 0 { + idx = idx + 1 + v2 = idx + **(**int8)(__ccgo_up(bufpt + uintptr(v2))) = libc.Int8FromUint8(cThousand) + nn1 = nn1 - 1 + ix = int32(3) + } + goto _50 + _50: + ; + idx = idx + 1 + } + } + if prefix != 0 { + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = prefix + } /* Add sign */ + if flag_alternateform != 0 && (*Tet_info)(unsafe.Pointer(infop)).Fprefix != 0 { + pre = uintptr(unsafe.Pointer(&_aPrefix)) + uintptr((*Tet_info)(unsafe.Pointer(infop)).Fprefix) + for { + v54 = **(**int8)(__ccgo_up(pre)) + x1 = v54 + if !(int32(v54) != 0) { + break + } + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = x1 + goto _53 + _53: + ; + pre = pre + 1 + } + } + length = int32(t__predefined_ptrdiff_t(zOut+uintptr(nOut-int32(1))) - int64(bufpt)) + goto _45 + _33: + ; + _32: + ; + _31: + ; /* Size needed to hold the output */ + if bArgList != 0 { + realvalue = _getDoubleArg(tls, pArgList) + } else { + realvalue = libc.VaFloat64(&ap) + } + if precision < 0 { + precision = int32(6) + } /* Set default precision */ + if precision > int32(SQLITE_FP_PRECISION_LIMIT) { + precision = int32(SQLITE_FP_PRECISION_LIMIT) + } + if libc.Int32FromUint8(xtype) == int32(etFLOAT) { + iRound = -precision + } else { + if libc.Int32FromUint8(xtype) == int32(etGENERIC) { + if precision == 0 { + precision = int32(1) + } + iRound = precision + } else { + iRound = precision + int32(1) + } + } + if flag_altform2 != 0 { + v2 = int32(20) + } else { + v2 = int32(16) + } + _sqlite3FpDecode(tls, bp+72, realvalue, iRound, v2) + if (**(**TFpDecode)(__ccgo_up(bp + 72))).FisSpecial != 0 { + if int32((**(**TFpDecode)(__ccgo_up(bp + 72))).FisSpecial) == int32(2) { + if flag_zeropad != 0 { + v4 = __ccgo_ts + 1688 + } else { + v4 = __ccgo_ts + 1693 + } + bufpt = v4 + length = _sqlite3Strlen30(tls, bufpt) + goto _45 + } else { + if flag_zeropad != 0 { + **(**int8)(__ccgo_up((**(**TFpDecode)(__ccgo_up(bp + 72))).Fz)) = int8('9') + (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP = int32(1000) + (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn = int32(1) + } else { + libc.X__builtin___memcpy_chk(tls, bp, __ccgo_ts+1697, uint64(5), ^t__predefined_size_t(0)) + bufpt = bp + if int32((**(**TFpDecode)(__ccgo_up(bp + 72))).Fsign) == int32('-') { + /* no-op */ + } else { + if flag_prefix != 0 { + (**(**[70]int8)(__ccgo_up(bp)))[0] = libc.Int8FromUint8(flag_prefix) + } else { + bufpt = bufpt + 1 + } + } + length = _sqlite3Strlen30(tls, bufpt) + goto _45 + } + } + } + if int32((**(**TFpDecode)(__ccgo_up(bp + 72))).Fsign) == int32('-') { + if flag_alternateform != 0 && !(flag_prefix != 0) && libc.Int32FromUint8(xtype) == int32(etFLOAT) && (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP <= iRound { + /* Suppress the minus sign if all of the following are true: + ** * The value displayed is zero + ** * The '#' flag is used + ** * The '+' flag is not used, and + ** * The format is %f + */ + prefix = 0 + } else { + prefix = int8('-') + } + } else { + prefix = libc.Int8FromUint8(flag_prefix) + } + exp = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + /* + ** If the field type is etGENERIC, then convert to either etEXP + ** or etFLOAT, as appropriate. + */ + if libc.Int32FromUint8(xtype) == int32(etGENERIC) { + precision = precision - 1 + flag_rtz = libc.BoolUint8(!(flag_alternateform != 0)) + if exp < -int32(4) || exp > precision { + xtype = uint8(etEXP) + } else { + precision = precision - exp + xtype = uint8(etFLOAT) + } + } else { + flag_rtz = flag_altform2 + } + if libc.Int32FromUint8(xtype) == int32(etEXP) { + e2 = 0 + } else { + e2 = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + } + if e2 > 0 { + v2 = e2 + } else { + v2 = 0 + } + szBufNeeded = int64(v2) + int64(precision) + int64(width) + int64(10) + if cThousand != 0 && e2 > 0 { + szBufNeeded = szBufNeeded + int64((e2+int32(2))/int32(3)) + } + if szBufNeeded+libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) >= libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc) { + if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc == uint32(0) && libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0 { + /* Unable to allocate space in pAccum, perhaps because it + ** is coming from sqlite3_snprintf() or similar. We'll have + ** to render into temporary space and the memcpy() it over. */ + bufpt = Xsqlite3_malloc(tls, int32(szBufNeeded)) + if bufpt == uintptr(0) { + _sqlite3StrAccumSetError(tls, pAccum, uint8(SQLITE_NOMEM)) + return + } + zExtra = bufpt + } else { + if int64(_sqlite3StrAccumEnlarge(tls, pAccum, szBufNeeded)) < szBufNeeded { + v2 = libc.Int32FromInt32(0) + length = v2 + width = v2 + goto _45 + } else { + bufpt = (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + } + } else { + bufpt = (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + zOut = bufpt + if precision > 0 { + v2 = int32(1) + } else { + v2 = 0 + } + flag_dp = libc.Uint8FromInt32(v2 | libc.Int32FromUint8(flag_alternateform) | libc.Int32FromUint8(flag_altform2)) + /* The sign in front of the number */ + if prefix != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = prefix + } + /* Digits prior to the decimal point */ + j = 0 + if e2 < 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('0') + } else { + if cThousand != 0 { + for { + if !(e2 >= 0) { + break + } + v4 = bufpt + bufpt = bufpt + 1 + if j < (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn { + v3 = j + j = j + 1 + v2 = int32(**(**int8)(__ccgo_up((**(**TFpDecode)(__ccgo_up(bp + 72))).Fz + uintptr(v3)))) + } else { + v2 = int32('0') + } + **(**int8)(__ccgo_up(v4)) = int8(v2) + if e2%int32(3) == 0 && e2 > int32(1) { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8(',') + } + goto _63 + _63: + ; + e2 = e2 - 1 + } + } else { + j = e2 + int32(1) + if j > (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn { + j = (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn + } + libc.X__builtin___memcpy_chk(tls, bufpt, (**(**TFpDecode)(__ccgo_up(bp + 72))).Fz, libc.Uint64FromInt32(j), ^t__predefined_size_t(0)) + bufpt = bufpt + uintptr(j) + e2 = e2 - j + if e2 >= 0 { + libc.X__builtin___memset_chk(tls, bufpt, int32('0'), libc.Uint64FromInt32(e2+int32(1)), ^t__predefined_size_t(0)) + bufpt = bufpt + uintptr(e2+int32(1)) + e2 = -int32(1) + } + } + } + /* The decimal point */ + if flag_dp != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('.') + } + /* "0" digits after the decimal point but before the first + ** significant digit of the number */ + if e2 < -int32(1) && precision > 0 { + nn2 = -int32(1) - e2 + if nn2 > precision { + nn2 = precision + } + libc.X__builtin___memset_chk(tls, bufpt, int32('0'), libc.Uint64FromInt32(nn2), ^t__predefined_size_t(0)) + bufpt = bufpt + uintptr(nn2) + precision = precision - nn2 + } + /* Significant digits after the decimal point */ + if precision > 0 { + nn3 = (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn - j + if nn3 > precision { + nn3 = precision + } + if nn3 > 0 { + libc.X__builtin___memcpy_chk(tls, bufpt, (**(**TFpDecode)(__ccgo_up(bp + 72))).Fz+uintptr(j), libc.Uint64FromInt32(nn3), ^t__predefined_size_t(0)) + bufpt = bufpt + uintptr(nn3) + precision = precision - nn3 + } + if precision > 0 && !(flag_rtz != 0) { + libc.X__builtin___memset_chk(tls, bufpt, int32('0'), libc.Uint64FromInt32(precision), ^t__predefined_size_t(0)) + bufpt = bufpt + uintptr(precision) + } + } + /* Remove trailing zeros and the "." if no digits follow the "." */ + if flag_rtz != 0 && flag_dp != 0 { + for int32(**(**int8)(__ccgo_up(bufpt + uintptr(-libc.Int32FromInt32(1))))) == int32('0') { + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = 0 + } + if int32(**(**int8)(__ccgo_up(bufpt + uintptr(-libc.Int32FromInt32(1))))) == int32('.') { + if flag_altform2 != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('0') + } else { + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = 0 + } + } + } + /* Add the "eNNN" suffix */ + if libc.Int32FromUint8(xtype) == int32(etEXP) { + exp = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = _aDigits[(*Tet_info)(unsafe.Pointer(infop)).Fcharset] + if exp < 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('-') + exp = -exp + } else { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('+') + } + if exp >= int32(100) { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8(exp/libc.Int32FromInt32(100) + libc.Int32FromUint8('0')) /* 100's digit */ + exp = exp % int32(100) + } + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8(exp/libc.Int32FromInt32(10) + libc.Int32FromUint8('0')) /* 10's digit */ + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8(exp%libc.Int32FromInt32(10) + libc.Int32FromUint8('0')) /* 1's digit */ + } + length = int32(int64(bufpt) - int64(zOut)) + if length < width { + nPad = int64(width - length) + if flag_leftjustify != 0 { + libc.X__builtin___memset_chk(tls, bufpt, int32(' '), libc.Uint64FromInt64(nPad), ^t__predefined_size_t(0)) + } else { + if !(flag_zeropad != 0) { + libc.X__builtin___memmove_chk(tls, zOut+uintptr(nPad), zOut, libc.Uint64FromInt32(length), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, zOut, int32(' '), libc.Uint64FromInt64(nPad), ^t__predefined_size_t(0)) + } else { + adj = libc.BoolInt32(int32(prefix) != 0) + libc.X__builtin___memmove_chk(tls, zOut+uintptr(nPad)+uintptr(adj), zOut+uintptr(adj), libc.Uint64FromInt32(length-adj), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, zOut+uintptr(adj), int32('0'), libc.Uint64FromInt64(nPad), ^t__predefined_size_t(0)) + } + } + length = width + } + if zExtra == uintptr(0) { + /* The result is being rendered directory into pAccum. This + ** is the command and fast case */ + **(**Tu32)(__ccgo_up(pAccum + 24)) += libc.Uint32FromInt32(length) + **(**int8)(__ccgo_up(zOut + uintptr(length))) = 0 + goto _1 + } else { + /* We were unable to render directly into pAccum because we + ** couldn't allocate sufficient memory. We need to memcpy() + ** the rendering (or some prefix thereof) into the output + ** buffer. */ + **(**int8)(__ccgo_up(bufpt)) = 0 + bufpt = zExtra + goto _45 + } + _34: + ; + if !(bArgList != 0) { + **(**int32)(__ccgo_up(libc.VaUintptr(&ap))) = libc.Int32FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _35: + ; + (**(**[70]int8)(__ccgo_up(bp)))[0] = int8('%') + bufpt = bp + length = int32(1) + goto _45 + _36: + ; + if bArgList != 0 { + bufpt = _getTextArg(tls, pArgList) + length = int32(1) + if bufpt != 0 { + v4 = bufpt + bufpt = bufpt + 1 + v2 = int32(**(**int8)(__ccgo_up(v4))) + c = v2 + (**(**[70]int8)(__ccgo_up(bp)))[0] = int8(v2) + if c&int32(0xc0) == int32(0xc0) { + for length < int32(4) && int32(**(**int8)(__ccgo_up(bufpt)))&int32(0xc0) == int32(0x80) { + v2 = length + length = length + 1 + v4 = bufpt + bufpt = bufpt + 1 + (**(**[70]int8)(__ccgo_up(bp)))[v2] = **(**int8)(__ccgo_up(v4)) + } + } + } else { + (**(**[70]int8)(__ccgo_up(bp)))[0] = 0 + } + } else { + ch = libc.VaUint32(&ap) + length = _sqlite3AppendOneUtf8Character(tls, bp, ch) + } + if precision > int32(1) { + nPrior = int64(1) + width = width - (precision - int32(1)) + if width > int32(1) && !(flag_leftjustify != 0) { + Xsqlite3_str_appendchar(tls, pAccum, width-int32(1), int8(' ')) + width = 0 + } + Xsqlite3_str_append(tls, pAccum, bp, length) + precision = precision - 1 + for precision > int32(1) { + if nPrior > int64(precision-int32(1)) { + nPrior = int64(precision - int32(1)) + } + nCopyBytes = int64(length) * nPrior + if _sqlite3StrAccumEnlargeIfNeeded(tls, pAccum, nCopyBytes) != 0 { + break + } + Xsqlite3_str_append(tls, pAccum, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText+uintptr(libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar)-nCopyBytes), int32(nCopyBytes)) + precision = int32(int64(precision) - nPrior) + nPrior = nPrior * int64(2) + } + } + bufpt = bp + flag_altform2 = uint8(1) + goto adjust_width_for_utf8 + _38: + ; + _37: + ; + if bArgList != 0 { + bufpt = _getTextArg(tls, pArgList) + xtype = uint8(etSTRING) + } else { + bufpt = libc.VaUintptr(&ap) + } + if bufpt == uintptr(0) { + bufpt = __ccgo_ts + 1702 + } else { + if libc.Int32FromUint8(xtype) == int32(etDYNSTRING) { + if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar == uint32(0) && (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc != 0 && width == 0 && precision < 0 && libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0 { + /* Special optimization for sqlite3_mprintf("%z..."): + ** Extend an existing memory allocation rather than creating + ** a new one. */ + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText = bufpt + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc = libc.Uint32FromInt32(_sqlite3DbMallocSize(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, bufpt)) + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar = libc.Uint32FromInt32(int32(0x7fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, bufpt))) + v4 = pAccum + 29 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v4))) | libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) + length = 0 + goto _45 + } + zExtra = bufpt + } + } + if precision >= 0 { + if flag_altform2 != 0 { + /* Set length to the number of bytes needed in order to display + ** precision characters */ + z = bufpt + for { + v2 = precision + precision = precision - 1 + if !(v2 > 0 && **(**uint8)(__ccgo_up(z)) != 0) { + break + } + v4 = z + z = z + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { + z = z + 1 + } + } + } + length = int32(int64(z) - int64(bufpt)) + } else { + length = 0 + for { + if !(length < precision && **(**int8)(__ccgo_up(bufpt + uintptr(length))) != 0) { + break + } + goto _86 + _86: + ; + length = length + 1 + } + } + } else { + length = int32(0x7fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, bufpt)) + } + goto adjust_width_for_utf8 + adjust_width_for_utf8: + ; + if flag_altform2 != 0 && width > 0 { + /* Adjust width to account for extra bytes in UTF-8 characters */ + ii = length - int32(1) + for ii >= 0 { + v2 = ii + ii = ii - 1 + if int32(**(**int8)(__ccgo_up(bufpt + uintptr(v2))))&int32(0xc0) == int32(0x80) { + width = width + 1 + } + } + } + goto _45 + _41: + ; /* %q: Escape ' characters */ + _40: + ; /* %Q: Escape ' and enclose in '...' */ + _39: + ; + needQuote = 0 + if bArgList != 0 { + escarg = _getTextArg(tls, pArgList) + } else { + escarg = libc.VaUintptr(&ap) + } + if escarg == uintptr(0) { + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + v4 = __ccgo_ts + 1703 + } else { + v4 = __ccgo_ts + 1708 + } + escarg = v4 + } else { + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + needQuote = int32(1) + } + } + if libc.Int32FromUint8(xtype) == int32(etESCAPE_w) { + q = int8('"') + flag_alternateform = uint8(0) + } else { + q = int8('\'') + } + /* For %q, %Q, and %w, the precision is the number of bytes (or + ** characters if the ! flags is present) to use from the input. + ** Because of the extra quoting characters inserted, the number + ** of output characters may be larger than the precision. + */ + k = int64(precision) + v90 = libc.Int64FromInt32(0) + n1 = v90 + i = v90 + for { + if v12 = k != 0; v12 { + v54 = **(**int8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + } + if !(v12 && int32(v54) != 0) { + break + } + if int32(ch1) == int32(q) { + n1 = n1 + 1 + } + if flag_altform2 != 0 && int32(ch1)&int32(0xc0) == int32(0xc0) { + for int32(**(**int8)(__ccgo_up(escarg + uintptr(i+int64(1)))))&int32(0xc0) == int32(0x80) { + i = i + 1 + } + } + goto _89 + _89: + ; + i = i + 1 + k = k - 1 + } + if flag_alternateform != 0 { + /* For %#q, do unistr()-style backslash escapes for + ** all control characters, and for backslash itself. + ** For %#Q, do the same but only if there is at least + ** one control character. */ + nBack = 0 + nCtrl = 0 + k = 0 + for { + if !(k < i) { + break + } + if int32(**(**int8)(__ccgo_up(escarg + uintptr(k)))) == int32('\\') { + nBack = nBack + 1 + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(escarg + uintptr(k)))) <= int32(0x1f) { + nCtrl = nCtrl + 1 + } + } + goto _93 + _93: + ; + k = k + 1 + } + if nCtrl != 0 || libc.Int32FromUint8(xtype) == int32(etESCAPE_q) { + n1 = n1 + (nBack + int64(5)*nCtrl) + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + n1 = n1 + int64(10) + needQuote = int32(2) + } + } else { + flag_alternateform = uint8(0) + } + } + n1 = n1 + (i + int64(3)) + if n1 > int64(SQLITE_PRINT_BUF_SIZE) { + v4 = _printfTempBuf(tls, pAccum, n1) + zExtra = v4 + bufpt = v4 + if bufpt == uintptr(0) { + return + } + } else { + bufpt = bp + } + j1 = 0 + if needQuote != 0 { + if needQuote == int32(2) { + libc.X__builtin___memcpy_chk(tls, bufpt+uintptr(j1), __ccgo_ts+1715, uint64(8), ^t__predefined_size_t(0)) + j1 = j1 + int64(8) + } else { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('\'') + } + } + k = i + if flag_alternateform != 0 { + i = 0 + for { + if !(i < k) { + break + } + v90 = j1 + j1 = j1 + 1 + v54 = **(**int8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = v54 + if int32(ch1) == int32(q) { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = ch1 + } else { + if int32(ch1) == int32('\\') { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('\\') + } else { + if libc.Int32FromUint8(libc.Uint8FromInt8(ch1)) <= int32(0x1f) { + **(**int8)(__ccgo_up(bufpt + uintptr(j1-int64(1)))) = int8('\\') + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('u') + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('0') + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('0') + v90 = j1 + j1 = j1 + 1 + if int32(ch1) >= int32(0x10) { + v2 = int32('1') + } else { + v2 = int32('0') + } + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8(v2) + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = **(**int8)(__ccgo_up(__ccgo_ts + 1724 + uintptr(int32(ch1)&int32(0xf)))) + } + } + } + goto _96 + _96: + ; + i = i + 1 + } + } else { + i = 0 + for { + if !(i < k) { + break + } + v90 = j1 + j1 = j1 + 1 + v54 = **(**int8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = v54 + if int32(ch1) == int32(q) { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = ch1 + } + goto _107 + _107: + ; + i = i + 1 + } + } + if needQuote != 0 { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('\'') + if needQuote == int32(2) { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8(')') + } + } + **(**int8)(__ccgo_up(bufpt + uintptr(j1))) = 0 + length = int32(j1) + goto adjust_width_for_utf8 + _42: + ; + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_INTERNAL) == 0 { + return + } + if flag_alternateform != 0 { + /* %#T means an Expr pointer that uses Expr.u.zToken */ + pExpr = libc.VaUintptr(&ap) + if pExpr != 0 && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)) { + Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + _sqlite3RecordErrorOffsetOfExpr(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, pExpr) + } + } else { + /* %T means a Token pointer */ + pToken = libc.VaUintptr(&ap) + if pToken != 0 && (*TToken)(unsafe.Pointer(pToken)).Fn != 0 { + Xsqlite3_str_append(tls, pAccum, (*TToken)(unsafe.Pointer(pToken)).Fz, libc.Int32FromUint32((*TToken)(unsafe.Pointer(pToken)).Fn)) + _sqlite3RecordErrorByteOffset(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, (*TToken)(unsafe.Pointer(pToken)).Fz) + } + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _43: + ; + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_INTERNAL) == 0 { + return + } + pItem = libc.VaUintptr(&ap) + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 && !(flag_altform2 != 0) { + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) + } else { + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) == 0 && int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) == 0 && *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { + Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pItem + 72))) + Xsqlite3_str_append(tls, pAccum, __ccgo_ts+1741, int32(1)) + } + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzName) + } else { + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { /* Because of tag-20240424-1 */ + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_NestedFrom) != 0 { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1743, libc.VaList(bp+120, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + } else { + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_MultiValue) != 0 { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1753, libc.VaList(bp+120, *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(pItem)).Fu1)))) + } else { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1774, libc.VaList(bp+120, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + } + } + } + } + } + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _44: + ; + return + _45: + ; /* End switch over the format type */ + /* + ** The text of the conversion is pointed to by "bufpt" and is + ** "length" characters long. The field width is "width". Do + ** the output. Both length and width are in bytes, not characters, + ** at this point. If the "!" flag was present on string conversions + ** indicating that width and precision should be expressed in characters, + ** then the values have been translated prior to reaching this point. + */ + width = width - length + if width > 0 { + if !(flag_leftjustify != 0) { + Xsqlite3_str_appendchar(tls, pAccum, width, int8(' ')) + } + Xsqlite3_str_append(tls, pAccum, bufpt, length) + if flag_leftjustify != 0 { + Xsqlite3_str_appendchar(tls, pAccum, width, int8(' ')) + } + } else { + Xsqlite3_str_append(tls, pAccum, bufpt, length) + } + if zExtra != 0 { + _sqlite3DbFree(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, zExtra) + zExtra = uintptr(0) + } + goto _1 + _1: + ; + fmt = fmt + 1 + } /* End for loop over the format string */ +} + +// C documentation +// +// /* +// ** Return meta information about a specific column of a database table. +// ** See comment in sqlite3.h (sqlite.h.in) for details. +// */ +func Xsqlite3_table_column_metadata(tls *libc.TLS, db uintptr, zDbName uintptr, zTableName uintptr, zColumnName uintptr, pzDataType uintptr, pzCollSeq uintptr, pNotNull uintptr, pPrimaryKey uintptr, pAutoinc uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var autoinc, iCol, notnull, primarykey, rc int32 + var pCol, pTab, zCollSeq, zDataType, v1 uintptr + var _ /* zErrMsg at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = autoinc, iCol, notnull, pCol, pTab, primarykey, rc, zCollSeq, zDataType, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pTab = uintptr(0) + pCol = uintptr(0) + iCol = 0 + zDataType = uintptr(0) + zCollSeq = uintptr(0) + notnull = 0 + primarykey = 0 + autoinc = 0 + /* Ensure the database schema has been loaded */ + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3BtreeEnterAll(tls, db) + rc = _sqlite3Init(tls, db, bp) + if SQLITE_OK != rc { + goto error_out + } + /* Locate the table in question */ + pTab = _sqlite3FindTable(tls, db, zTableName, zDbName) + if !(pTab != 0) || libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + pTab = uintptr(0) + goto error_out + } + /* Find the column for which info is requested */ + if zColumnName == uintptr(0) { + /* Query for existence of table only */ + } else { + iCol = _sqlite3ColumnIndex(tls, pTab, zColumnName) + if iCol >= 0 { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + } else { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) && _sqlite3IsRowid(tls, zColumnName) != 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + if iCol >= 0 { + v1 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + } else { + v1 = uintptr(0) + } + pCol = v1 + } else { + pTab = uintptr(0) + goto error_out + } + } + } + /* The following block stores the meta information that will be returned + ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey + ** and autoinc. At this point there are two possibilities: + ** + ** 1. The specified column name was rowid", "oid" or "_rowid_" + ** and there is no explicitly declared IPK column. + ** + ** 2. The table is not a view and the column name identified an + ** explicitly declared column. Copy meta information from *pCol. + */ + if pCol != 0 { + zDataType = _sqlite3ColumnType(tls, pCol, uintptr(0)) + zCollSeq = _sqlite3ColumnColl(tls, pCol) + notnull = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0) + primarykey = libc.BoolInt32(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0) + autoinc = libc.BoolInt32(int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) == iCol && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Autoincrement) != uint32(0)) + } else { + zDataType = __ccgo_ts + 1176 + primarykey = int32(1) + } + if !(zCollSeq != 0) { + zCollSeq = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + goto error_out +error_out: + ; + _sqlite3BtreeLeaveAll(tls, db) + /* Whether the function call succeeded or failed, set the output parameters + ** to whatever their local counterparts contain. If an error did occur, + ** this has the effect of zeroing all output parameters. + */ + if pzDataType != 0 { + **(**uintptr)(__ccgo_up(pzDataType)) = zDataType + } + if pzCollSeq != 0 { + **(**uintptr)(__ccgo_up(pzCollSeq)) = zCollSeq + } + if pNotNull != 0 { + **(**int32)(__ccgo_up(pNotNull)) = notnull + } + if pPrimaryKey != 0 { + **(**int32)(__ccgo_up(pPrimaryKey)) = primarykey + } + if pAutoinc != 0 { + **(**int32)(__ccgo_up(pAutoinc)) = autoinc + } + if SQLITE_OK == rc && !(pTab != 0) { + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = _sqlite3MPrintf(tls, db, __ccgo_ts+26662, libc.VaList(bp+16, zTableName, zColumnName)) + rc = int32(SQLITE_ERROR) + } + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = __ccgo_ts + 3944 + } else { + v1 = uintptr(0) + } + _sqlite3ErrorWithMsg(tls, db, rc, v1, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp)))) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** If the following global variable points to a string which is the +// ** name of a directory, then that directory will be used to store +// ** temporary files. +// ** +// ** See also the "PRAGMA temp_store_directory" SQL command. +// */ +var Xsqlite3_temp_directory uintptr + +/*===---- __stdarg_va_arg.h - Definitions of va_start, va_arg, va_end-------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Versions before C23 do require the second parameter. */ + +/*===---- __stdarg___va_copy.h - Definition of __va_copy -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/*===---- __stdarg_va_copy.h - Definition of va_copy------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* +** Make sure we can call this stuff from C++. + */ + +/* +** Facilitate override of interface linkage and calling conventions. +** Be aware that these macros may not be used within this particular +** translation of the amalgamation and its associated header file. +** +** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the +** compiler that the target identifier should have external linkage. +** +** The SQLITE_CDECL macro is used to set the calling convention for +** public functions that accept a variable number of arguments. +** +** The SQLITE_APICALL macro is used to set the calling convention for +** public functions that accept a fixed number of arguments. +** +** The SQLITE_STDCALL macro is no longer used and is now deprecated. +** +** The SQLITE_CALLBACK macro is used to set the calling convention for +** function pointers. +** +** The SQLITE_SYSAPI macro is used to set the calling convention for +** functions provided by the operating system. +** +** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and +** SQLITE_SYSAPI macros are used only when building for environments +** that require non-default calling conventions. + */ + +/* +** These no-op macros are used in front of interfaces to mark those +** interfaces as either deprecated or experimental. New applications +** should not use deprecated interfaces - they are supported for backwards +** compatibility only. Application writers should be aware that +** experimental interfaces are subject to change in point releases. +** +** These macros used to resolve to various kinds of compiler magic that +** would generate warning messages when they were used. But that +** compiler magic ended up generating such a flurry of bug reports +** that we have taken it all out and gone back to using simple +** noop macros. + */ + +/* +** Ensure these symbols were not defined by some previous header file. + */ + +/* +** CAPI3REF: Compile-Time Library Version Numbers +** +** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header +** evaluates to a string literal that is the SQLite version in the +** format "X.Y.Z" where X is the major version number (always 3 for +** SQLite3) and Y is the minor version number and Z is the release number.)^ +** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer +** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same +** numbers used in [SQLITE_VERSION].)^ +** The SQLITE_VERSION_NUMBER for any given release of SQLite will also +** be larger than the release from which it is derived. Either Y will +** be held constant and Z will be incremented or else Y will be incremented +** and Z will be reset to zero. +** +** Since [version 3.6.18] ([dateof:3.6.18]), +** SQLite source code has been stored in the +** Fossil configuration management +** system. ^The SQLITE_SOURCE_ID macro evaluates to +** a string which identifies a particular check-in of SQLite +** within its configuration management system. ^The SQLITE_SOURCE_ID +** string contains the date and time of the check-in (UTC) and a SHA1 +** or SHA3-256 hash of the entire source tree. If the source code has +** been edited in any way since it was last checked in, then the last +** four hexadecimal digits of the hash may be modified. +** +** See also: [sqlite3_libversion()], +** [sqlite3_libversion_number()], [sqlite3_sourceid()], +** [sqlite_version()] and [sqlite_source_id()]. + */ + +// C documentation +// +// /* +// ** Register an unlock-notify callback. +// ** +// ** This is called after connection "db" has attempted some operation +// ** but has received an SQLITE_LOCKED error because another connection +// ** (call it pOther) in the same process was busy using the same shared +// ** cache. pOther is found by looking at db->pBlockingConnection. +// ** +// ** If there is no blocking connection, the callback is invoked immediately, +// ** before this routine returns. +// ** +// ** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate +// ** a deadlock. +// ** +// ** Otherwise, make arrangements to invoke xNotify when pOther drops +// ** its locks. +// ** +// ** Each call to this routine overrides any prior callbacks registered +// ** on the same "db". If xNotify==0 then any prior callbacks are immediately +// ** cancelled. +// */ +func Xsqlite3_unlock_notify(tls *libc.TLS, db uintptr, __ccgo_fp_xNotify uintptr, _pArg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _pArg + var p, v2 uintptr + var rc int32 + _, _, _ = p, rc, v2 + rc = SQLITE_OK + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _enterMutex(tls) + if __ccgo_fp_xNotify == uintptr(0) { + _removeFromBlockedList(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockConnection = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FxUnlockNotify = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockArg = uintptr(0) + } else { + if uintptr(0) == (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection { + /* The blocking transaction has been concluded. Or there never was a + ** blocking transaction. In either case, invoke the notify callback + ** immediately. + */ + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xNotify})))(tls, bp, int32(1)) + } else { + p = (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection + for { + if !(p != 0 && p != db) { + break + } + goto _1 + _1: + ; + p = (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection + } + if p != 0 { + rc = int32(SQLITE_LOCKED) /* Deadlock detected. */ + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockConnection = (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection + (*Tsqlite3)(unsafe.Pointer(db)).FxUnlockNotify = __ccgo_fp_xNotify + (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockArg = **(**uintptr)(__ccgo_up(bp)) + _removeFromBlockedList(tls, db) + _addToBlockedList(tls, db) + } + } + } + _leaveMutex(tls) + if rc != 0 { + v2 = __ccgo_ts + 26698 + } else { + v2 = uintptr(0) + } + _sqlite3ErrorWithMsg(tls, db, rc, v2, 0) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* Make a copy of an sqlite3_value object +// */ +func Xsqlite3_value_dup(tls *libc.TLS, pOrig uintptr) (r uintptr) { + var pNew, v1 uintptr + _, _ = pNew, v1 + if pOrig == uintptr(0) { + return uintptr(0) + } + pNew = Xsqlite3_malloc(tls, int32(56)) + if pNew == uintptr(0) { + return uintptr(0) + } + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(56), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, pNew, pOrig, uint64(libc.UintptrFromInt32(0)+24), ^t__predefined_size_t(0)) + v1 = pNew + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Dyn)) + (*Tsqlite3_value)(unsafe.Pointer(pNew)).Fdb = uintptr(0) + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pNew)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) != 0 { + v1 = pNew + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Dyn))) + v1 = pNew + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Ephem)) + if _sqlite3VdbeMemMakeWriteable(tls, pNew) != SQLITE_OK { + _sqlite3ValueFree(tls, pNew) + pNew = uintptr(0) + } + } else { + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pNew)).Fflags)&int32(MEM_Null) != 0 { + /* Do not duplicate pointer values */ + v1 = pNew + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Term) | libc.Int32FromInt32(MEM_Subtype))) + } + } + return pNew +} + +// C documentation +// +// /* +// ** Return the ON CONFLICT resolution mode in effect for the virtual +// ** table update operation currently in progress. +// ** +// ** The results of this routine are undefined unless it is called from +// ** within an xUpdate method. +// */ +func Xsqlite3_vtab_on_conflict(tls *libc.TLS, db uintptr) (r int32) { + return libc.Int32FromUint8(_aMap1[libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict)-int32(1)]) +} + +// C documentation +// +// /* +// ** Checkpoint database zDb. +// */ +func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDb, rc int32 + _, _ = iDb, rc /* Schema to checkpoint */ + /* Initialize the output variables to -1 in case an error occurs. */ + if pnLog != 0 { + **(**int32)(__ccgo_up(pnLog)) = -int32(1) + } + if pnCkpt != 0 { + **(**int32)(__ccgo_up(pnCkpt)) = -int32(1) + } + if eMode < -int32(1) || eMode > int32(SQLITE_CHECKPOINT_TRUNCATE) { + /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint + ** mode: */ + return _sqlite3MisuseError(tls, int32(189780)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if zDb != 0 && **(**int8)(__ccgo_up(zDb)) != 0 { + iDb = _sqlite3FindDbName(tls, db, zDb) + } else { + iDb = libc.Int32FromInt32(SQLITE_MAX_ATTACHED) + libc.Int32FromInt32(2) /* This means process all schemas */ + } + if iDb < 0 { + rc = int32(SQLITE_ERROR) + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_ERROR), __ccgo_ts+26351, libc.VaList(bp+8, zDb)) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 + rc = _sqlite3Checkpoint(tls, db, iDb, eMode, pnLog, pnCkpt) + _sqlite3Error(tls, db, rc) + } + rc = _sqlite3ApiExit(tls, db, rc) + /* If there are no active statements, clear the interrupt flag at this + ** point. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Begin adding a change to a changegroup object. +// */ +func Xsqlite3changegroup_change_begin(tls *libc.TLS, pGrp uintptr, eOp int32, zTab uintptr, bIndirect int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aBuf uintptr + var nReq, rc, v1 int32 + var _ /* pTab at bp+0 */ uintptr + _, _, _, _ = aBuf, nReq, rc, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab != 0 { + rc = int32(SQLITE_MISUSE) + } else { + if eOp != int32(SQLITE_INSERT) && eOp != int32(SQLITE_UPDATE) && eOp != int32(SQLITE_DELETE) { + rc = int32(SQLITE_ERROR) + } else { + rc = _sessionChangesetFindTable(tls, pGrp, zTab, uintptr(0), bp) + } + } + if rc == SQLITE_OK { + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + if pzErr != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+21690, libc.VaList(bp+16, zTab)) + } + rc = int32(SQLITE_ERROR) + } else { + if eOp == int32(SQLITE_UPDATE) { + v1 = int32(2) + } else { + v1 = int32(1) + } + nReq = (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnCol * v1 + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab = **(**uintptr)(__ccgo_up(bp)) + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp = eOp + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FbIndirect = bIndirect + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc < nReq { + aBuf = Xsqlite3_realloc(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf, libc.Int32FromUint64(libc.Uint64FromInt32(nReq)*uint64(16))) + if aBuf == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, aBuf+uintptr((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc)*16, 0, uint64(16)*libc.Uint64FromInt32(nReq-(*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc), ^t__predefined_size_t(0)) + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf = aBuf + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc = nReq + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Configure the change currently under construction with a blob value. +// */ +func Xsqlite3changegroup_change_blob(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, pVal uintptr, nVal int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte Tsqlite3_int64 + var rc, v1 int32 + var _ /* pBuf at bp+0 */ uintptr + _, _, _ = nByte, rc, v1 + nByte = int64(int32(1)+_sessionVarintLen(tls, nVal)) + int64(nVal) + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + v1 = _checkChangeParams(tls, pGrp, bNew, iCol, nByte, bp) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_BLOB) + (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnBuf = int32(1) + _sessionVarintPut(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+1, nVal) + libc.X__builtin___memcpy_chk(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnBuf), pVal, libc.Uint64FromInt32(nVal), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 8)) += nVal + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Finish any change currently being constructed by the changegroup object. +// */ +func Xsqlite3changegroup_change_finish(tls *libc.TLS, pGrp uintptr, bDiscard int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aBuf, p, v2, v3 uintptr + var eUndef Tu8 + var ii, isPK, nBuf, nZero, v7 int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = aBuf, eUndef, ii, isPK, nBuf, nZero, p, v2, v3, v7 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab != 0 { + aBuf = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf + if bDiscard == 0 { + nBuf = (*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol + eUndef = uint8(SQLITE_NULL) + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_UPDATE) { + ii = 0 + for { + if !(ii < nBuf) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FabPK + uintptr(ii))) != 0 { + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf <= int32(1) { + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf == int32(1) { + v2 = __ccgo_ts + 1688 + } else { + v2 = __ccgo_ts + 37150 + } + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37160, libc.VaList(bp+16, v2)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } else { + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii+nBuf)*16))).FnBuf > 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37207, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + } + } else { + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch == 0 && libc.BoolInt32((**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf > 0) != libc.BoolInt32((**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii+nBuf)*16))).FnBuf > 0) { + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf != 0 { + v2 = __ccgo_ts + 1702 + } else { + v2 = __ccgo_ts + 37259 + } + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii+nBuf)*16))).FnBuf != 0 { + v3 = __ccgo_ts + 1702 + } else { + v3 = __ccgo_ts + 37259 + } + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37262, libc.VaList(bp+16, ii, v2, v3)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + eUndef = uint8(0x00) + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch == 0 { + nBuf = nBuf * int32(2) + } + } else { + ii = 0 + for { + if !(ii < nBuf) { + break + } + isPK = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FabPK + uintptr(ii)))) + if ((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_INSERT) || (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch == 0 || isPK != 0) && (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37338, libc.VaList(bp+16, ii)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf == int32(1) && isPK != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37377, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + goto _5 + _5: + ; + ii = ii + 1 + } + } + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FnBuf = 0 + ii = 0 + for { + if !(ii < nBuf) { + break + } + p = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf + uintptr(ii)*16 + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FabPK + uintptr(ii)))) == 0 { + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_UPDATE) { + p = p + uintptr((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol)*16 + } else { + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_DELETE) { + goto _6 + } + } + } + } + if (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf != 0 { + v7 = (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf + } else { + v7 = int32(1) + } + if 0 == _sessionBufferGrow(tls, pGrp+48+32, int64(v7), bp) { + if (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf != 0 { + libc.X__builtin___memcpy_chk(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FaBuf+uintptr((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FnBuf), (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf, libc.Uint64FromInt32((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf), ^t__predefined_size_t(0)) + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FnBuf += (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf + } else { + v2 = pGrp + 48 + 32 + 8 + v7 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FaBuf + uintptr(v7))) = eUndef + } + } + goto _6 + _6: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionOneChangeToHash(tls, pGrp, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FbIndirect, (*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FaBuf, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FnBuf, 0) + } + } + /* Reset all aBuf[] entries to "undefined". */ + nZero = (*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_UPDATE) { + nZero = nZero + nZero + } + ii = 0 + for { + if !(ii < nZero) { + break + } + (**(**TSessionBuffer)(__ccgo_up((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf + uintptr(ii)*16))).FnBuf = 0 + goto _10 + _10: + ; + ii = ii + 1 + } + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab = uintptr(0) + } + return **(**int32)(__ccgo_up(bp)) +} + +/************** End of sqlite3session.c **************************************/ +/************** Begin file fts5.c ********************************************/ + +/* +** This, the "fts5.c" source file, is a composite file that is itself +** assembled from the following files: +** +** fts5.h +** fts5Int.h +** fts5parse.h <--- Generated from fts5parse.y by Lemon +** fts5parse.c <--- Generated from fts5parse.y by Lemon +** fts5_aux.c +** fts5_buffer.c +** fts5_config.c +** fts5_expr.c +** fts5_hash.c +** fts5_index.c +** fts5_main.c +** fts5_storage.c +** fts5_tokenize.c +** fts5_unicode2.c +** fts5_varint.c +** fts5_vocab.c + */ + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Interfaces to extend FTS5. Using the interfaces defined in this file, +** FTS5 may be extended with: +** +** * custom tokenizers, and +** * custom auxiliary functions. + */ + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** + */ + +/* #include "fts5.h" */ +/* #include "sqlite3ext.h" */ + +/* #include */ +/* #include */ +/* #include */ + +/* +** Constants for the largest and smallest possible 32-bit signed integers. + */ + +/* Truncate very long tokens to this many bytes. Hard limit is +** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset +** field that occurs at the start of each leaf page (see fts5_index.c). */ + +/* +** Maximum number of prefix indexes on single FTS5 table. This must be +** less than 32. If it is set to anything large than that, an #error +** directive in fts5_index.c will cause the build to fail. + */ + +/* +** Maximum segments permitted in a single index + */ + +/* Name of rank and rowid columns */ + +/* +** The assert_nc() macro is similar to the assert() macro, except that it +** is used for assert() conditions that are true only if it can be +** guranteed that the database is not corrupt. + */ + +/* +** A version of memcmp() that does not cause asan errors if one of the pointer +** parameters is NULL and the number of bytes to compare is zero. + */ + +/* Mark a function parameter as unused, to suppress nuisance compiler +** warnings. */ + +// C documentation +// +// /* +// ** Configure the change currently under construction with a text value. +// */ +func Xsqlite3changegroup_change_text(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, pVal uintptr, nVal int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte Tsqlite3_int64 + var nText, rc, v2 int32 + var v1 uint64 + var _ /* pBuf at bp+0 */ uintptr + _, _, _, _, _ = nByte, nText, rc, v1, v2 + if nVal >= 0 { + v1 = libc.Uint64FromInt32(nVal) + } else { + v1 = libc.Xstrlen(tls, pVal) + } + nText = libc.Int32FromUint64(v1) + nByte = int64(int32(1) + _sessionVarintLen(tls, nText) + nText) + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + v2 = _checkChangeParams(tls, pGrp, bNew, iCol, nByte, bp) + rc = v2 + if SQLITE_OK != v2 { + return rc + } + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_TEXT) + (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnBuf = int32(1) + _sessionVarintPut(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+1, nText) + libc.X__builtin___memcpy_chk(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnBuf), pVal, libc.Uint64FromInt32(nText), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 8)) += nText + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Allocate a new, empty, sqlite3_changegroup. +// */ +func Xsqlite3changegroup_new(tls *libc.TLS, pp uintptr) (r int32) { + var p uintptr + var rc int32 + _, _ = p, rc + rc = SQLITE_OK /* New object */ + p = Xsqlite3_malloc(tls, int32(96)) + if p == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, p, 0, uint64(96), ^t__predefined_size_t(0)) + } + **(**uintptr)(__ccgo_up(pp)) = p + return rc +} + +// C documentation +// +// /* +// ** Invert a changeset object. +// */ +func Xsqlite3changeset_invert(tls *libc.TLS, nChangeset int32, pChangeset uintptr, pnInverted uintptr, ppInverted uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var _ /* sInput at bp+0 */ TSessionInput + /* Set up the input stream */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TSessionInput)(__ccgo_up(bp))).FnData = nChangeset + (**(**TSessionInput)(__ccgo_up(bp))).FaData = pChangeset + return _sessionChangesetInvert(tls, bp, uintptr(0), uintptr(0), pnInverted, ppInverted) +} + +// C documentation +// +// /* +// ** Streaming version of sqlite3changeset_invert(). +// */ +func Xsqlite3changeset_invert_strm(tls *libc.TLS, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var rc int32 + var _ /* sInput at bp+0 */ TSessionInput + _ = rc + /* Set up the input stream */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TSessionInput)(__ccgo_up(bp))).FxInput = __ccgo_fp_xInput + (**(**TSessionInput)(__ccgo_up(bp))).FpIn = pIn + rc = _sessionChangesetInvert(tls, bp, __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0)) + Xsqlite3_free(tls, (**(**TSessionInput)(__ccgo_up(bp))).Fbuf.FaBuf) + return rc +} + +// C documentation +// +// /* +// ** Close the RBU handle. +// */ +func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) (r int32) { + var pDb uintptr + var rc, rc2 int32 + _, _, _ = pDb, rc, rc2 + if p != 0 { + /* Commit the transaction to the *-oal file. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+16462, uintptr(0), uintptr(0), p+64) + } + /* Sync the db file if currently doing an incremental checkpoint */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_CKPT) { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})))(tls, pDb, int32(SQLITE_SYNC_NORMAL)) + } + _rbuSaveState(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16462, uintptr(0), uintptr(0), p+64) + } + /* Close any open statement handles. */ + _rbuObjIterFinalize(tls, p+88) + /* If this is an RBU vacuum handle and the vacuum has either finished + ** successfully or encountered an error, delete the contents of the + ** state table. This causes the next call to sqlite3rbu_vacuum() + ** specifying the current target and state databases to start a new + ** vacuum from scratch. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu != 0 { + rc2 = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+35006, uintptr(0), uintptr(0), uintptr(0)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_DONE) && rc2 != SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc2 + } + } + /* Close the open database handle and VFS object. */ + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + _rbuDeleteVfs(tls, p) + Xsqlite3_free(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FaBuf) + Xsqlite3_free(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FaFrame) + _rbuEditErrmsg(tls, p) + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + if pzErrmsg != 0 { + **(**uintptr)(__ccgo_up(pzErrmsg)) = (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + } else { + Xsqlite3_free(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg) + } + Xsqlite3_free(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState) + Xsqlite3_free(tls, p) + } else { + rc = int32(SQLITE_NOMEM) + **(**uintptr)(__ccgo_up(pzErrmsg)) = uintptr(0) + } + return rc +} + +// C documentation +// +// /* +// ** Create an RBU VFS named zName that accesses the underlying file-system +// ** via existing VFS zParent. The new object is registered as a non-default +// ** VFS with SQLite before returning. +// */ +func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) (r int32) { + var nByte, nName Tsize_t + var pNew, pParent, zSpace, v1 uintptr + var rc int32 + _, _, _, _, _, _, _ = nByte, nName, pNew, pParent, rc, zSpace, v1 + pNew = uintptr(0) /* Newly allocated VFS */ + rc = SQLITE_OK + nName = libc.Xstrlen(tls, zName) + nByte = uint64(208) + nName + uint64(1) + pNew = Xsqlite3_malloc64(tls, nByte) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { /* Parent VFS */ + libc.X__builtin___memset_chk(tls, pNew, 0, nByte, ^t__predefined_size_t(0)) + pParent = Xsqlite3_vfs_find(tls, zParent) + if pParent == uintptr(0) { + rc = int32(SQLITE_NOTFOUND) + } else { + libc.X__builtin___memcpy_chk(tls, pNew, uintptr(unsafe.Pointer(&_vfs_template)), uint64(168), ^t__predefined_size_t(0)) + (*Trbu_vfs)(unsafe.Pointer(pNew)).Fbase.FmxPathname = (*Tsqlite3_vfs)(unsafe.Pointer(pParent)).FmxPathname + (*Trbu_vfs)(unsafe.Pointer(pNew)).Fbase.FszOsFile = libc.Int32FromUint64(uint64(104) + libc.Uint64FromInt32((*Tsqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile)) + (*Trbu_vfs)(unsafe.Pointer(pNew)).FpRealVfs = pParent + v1 = pNew + 1*208 + zSpace = v1 + (*Trbu_vfs)(unsafe.Pointer(pNew)).Fbase.FzName = v1 + libc.X__builtin___memcpy_chk(tls, zSpace, zName, nName, ^t__predefined_size_t(0)) + /* Allocate the mutex and register the new VFS (not as the default) */ + (*Trbu_vfs)(unsafe.Pointer(pNew)).Fmutex = Xsqlite3_mutex_alloc(tls, int32(SQLITE_MUTEX_RECURSIVE)) + if (*Trbu_vfs)(unsafe.Pointer(pNew)).Fmutex == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_vfs_register(tls, pNew, 0) + } + } + if rc != SQLITE_OK { + Xsqlite3_mutex_free(tls, (*Trbu_vfs)(unsafe.Pointer(pNew)).Fmutex) + Xsqlite3_free(tls, pNew) + } + } + return rc +} + +func Xsqlite3rbu_savestate(tls *libc.TLS, p uintptr) (r int32) { + var pDb, zBegin, v1 uintptr + var rc int32 + _, _, _, _ = pDb, rc, zBegin, v1 + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + if rc == int32(SQLITE_DONE) { + return SQLITE_OK + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+16462, uintptr(0), uintptr(0), uintptr(0)) + } + } + /* Sync the db file */ + if rc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_CKPT) { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})))(tls, pDb, int32(SQLITE_SYNC_NORMAL)) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + _rbuSaveState(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage) + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16462, uintptr(0), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = __ccgo_ts + 16447 + } else { + v1 = __ccgo_ts + 34958 + } + zBegin = v1 + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, zBegin, uintptr(0), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34958, uintptr(0), uintptr(0), uintptr(0)) + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + return rc +} + +// C documentation +// +// /* +// ** Step the RBU object. +// */ +func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iSector Tu32 + var pDb, pFrame, pIter uintptr + var rc int32 + var _ /* ptr at bp+0 */ uintptr + _, _, _, _, _ = iSector, pDb, pFrame, pIter, rc + if p != 0 { + switch (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage { + case int32(RBU_STAGE_OAL): + pIter = p + 88 + /* If this is an RBU vacuum operation and the state table was empty + ** when this handle was opened, create the target database schema. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress == 0 && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuCreateTargetSchema(tls, p) + _rbuCopyPragma(tls, p, __ccgo_ts+19299) + _rbuCopyPragma(tls, p, __ccgo_ts+18394) + } + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 { + /* Clean up the rbu_tmp_xxx table for the previous table. It + ** cannot be dropped as there are currently active SQL statements. + ** But the contents can be deleted. */ + if libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+34599, libc.VaList(bp+16, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl)) + } + } else { + _rbuObjIterPrepareAll(tls, p, pIter, 0) + /* Advance to the next row to process. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rc = Xsqlite3_step(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect) + if rc == int32(SQLITE_ROW) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress + 1 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep + 1 + return _rbuStep(tls, p) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = 0 + } + } + _rbuObjIterNext(tls, p, pIter) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuSaveState(tls, p, int32(RBU_STAGE_MOVE)) + _rbuIncrSchemaCookie(tls, p) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+16462, uintptr(0), uintptr(0), p+64) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16462, uintptr(0), uintptr(0), p+64) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_MOVE) + } + case int32(RBU_STAGE_MOVE): + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuMoveOalFile(tls, p) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress + 1 + } + case int32(RBU_STAGE_CKPT): + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep >= (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + /* Sync the db file */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})))(tls, pDb, int32(SQLITE_SYNC_NORMAL)) + /* Update nBackfill */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxShmMap})))(tls, pDb, 0, libc.Int32FromInt32(32)*libc.Int32FromInt32(1024), 0, bp) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**Tu32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 24*4)) = (*Tsqlite3rbu)(unsafe.Pointer(p)).FiMaxFrame + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE) + } + } else { + for cond := true; cond; cond = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep < (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame && iSector == ((**(**TRbuFrame)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(p)).FaFrame + uintptr((*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep)*8))).FiDbPage-uint32(1))/libc.Uint32FromInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector) && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pFrame = (*Tsqlite3rbu)(unsafe.Pointer(p)).FaFrame + uintptr((*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep)*8 + iSector = ((*TRbuFrame)(unsafe.Pointer(pFrame)).FiDbPage - uint32(1)) / libc.Uint32FromInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector) + _rbuCheckpointFrame(tls, p, pFrame) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep + 1 + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress + 1 + } + default: + break + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + } else { + return int32(SQLITE_NOMEM) + } + return r +} + +// C documentation +// +// /* +// ** Open a handle to begin or resume an RBU VACUUM operation. +// */ +func Xsqlite3rbu_vacuum(tls *libc.TLS, zTarget uintptr, zState uintptr) (r uintptr) { + var n Tsize_t + _ = n + if zTarget == uintptr(0) { + return _rbuMisuseError(tls) + } + if zState != 0 { + n = libc.Xstrlen(tls, zState) + if n >= uint64(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+34998, zState+uintptr(n-uint64(7)), uint64(7)) { + return _rbuMisuseError(tls) + } + } + /* TODO: Check that both arguments are non-NULL */ + return _openRbuHandle(tls, uintptr(0), zTarget, zState) +} + +// C documentation +// +// /* +// ** Create a new rebaser object. +// */ +func Xsqlite3rebaser_create(tls *libc.TLS, ppNew uintptr) (r int32) { + var pNew uintptr + var rc int32 + _, _ = pNew, rc + rc = SQLITE_OK + pNew = Xsqlite3_malloc(tls, int32(96)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(96), ^t__predefined_size_t(0)) + } + **(**uintptr)(__ccgo_up(ppNew)) = pNew + return rc +} + +// C documentation +// +// /* +// ** Attach a table to a session. All subsequent changes made to the table +// ** while the session object is enabled will be recorded. +// ** +// ** Only tables that have a PRIMARY KEY defined may be attached. It does +// ** not matter if the PRIMARY KEY is an "INTEGER PRIMARY KEY" (rowid alias) +// ** or not. +// */ +func Xsqlite3session_attach(tls *libc.TLS, pSession uintptr, zName uintptr) (r int32) { + var nByte, nName, rc int32 + var pTab, ppTab uintptr + _, _, _, _, _ = nByte, nName, pTab, ppTab, rc + rc = SQLITE_OK + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + if !(zName != 0) { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = int32(1) + } else { /* Number of bytes in string zName */ + /* First search for an existing entry. If one is found, this call is + ** a no-op. Return early. */ + nName = _sqlite3Strlen30(tls, zName) + pTab = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable + for { + if !(pTab != 0) { + break + } + if 0 == Xsqlite3_strnicmp(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zName, nName+int32(1)) { + break + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + if !(pTab != 0) { + /* Allocate new SessionTable object. */ + nByte = libc.Int32FromUint64(uint64(88) + libc.Uint64FromInt32(nName) + uint64(1)) + pTab = _sessionMalloc64(tls, pSession, int64(nByte)) + if !(pTab != 0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pTab, 0, uint64(88), ^t__predefined_size_t(0)) + (*TSessionTable)(unsafe.Pointer(pTab)).FzName = pTab + 1*88 + libc.X__builtin___memcpy_chk(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zName, libc.Uint64FromInt32(nName+int32(1)), ^t__predefined_size_t(0)) + ppTab = pSession + 88 + for { + if !(**(**uintptr)(__ccgo_up(ppTab)) != 0) { + break + } + goto _2 + _2: + ; + ppTab = **(**uintptr)(__ccgo_up(ppTab)) + } + **(**uintptr)(__ccgo_up(ppTab)) = pTab + } + } + } + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + return rc +} + +// C documentation +// +// /* +// ** Create a session object. This session object will record changes to +// ** database zDb attached to connection db. +// */ +func Xsqlite3session_create(tls *libc.TLS, db uintptr, zDb uintptr, ppSession uintptr) (r int32) { + var nDb int32 + var pNew, pOld uintptr + _, _, _ = nDb, pNew, pOld /* Session object already attached to db */ + nDb = _sqlite3Strlen30(tls, zDb) /* Length of zDb in bytes */ + /* Zero the output value in case an error occurs. */ + **(**uintptr)(__ccgo_up(ppSession)) = uintptr(0) + /* Allocate and populate the new session object. */ + pNew = Xsqlite3_malloc64(tls, uint64(uint64(136)+libc.Uint64FromInt32(nDb)+uint64(1))) + if !(pNew != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(136), ^t__predefined_size_t(0)) + (*Tsqlite3_session)(unsafe.Pointer(pNew)).Fdb = db + (*Tsqlite3_session)(unsafe.Pointer(pNew)).FzDb = pNew + 1*136 + (*Tsqlite3_session)(unsafe.Pointer(pNew)).FbEnable = int32(1) + libc.X__builtin___memcpy_chk(tls, (*Tsqlite3_session)(unsafe.Pointer(pNew)).FzDb, zDb, libc.Uint64FromInt32(nDb+int32(1)), ^t__predefined_size_t(0)) + _sessionPreupdateHooks(tls, pNew) + /* Add the new session object to the linked list of session objects + ** attached to database handle $db. Do this under the cover of the db + ** handle mutex. */ + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db)) + pOld = Xsqlite3_preupdate_hook(tls, db, __ccgo_fp(_xPreUpdate), pNew) + (*Tsqlite3_session)(unsafe.Pointer(pNew)).FpNext = pOld + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + **(**uintptr)(__ccgo_up(ppSession)) = pNew + return SQLITE_OK +} + +func Xsqlite3session_diff(tls *libc.TLS, pSession uintptr, zFrom uintptr, zTbl uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bHasPk, bMismatch, i, rc int32 + var db, zDb, zDbExists, zExpr, v1 uintptr + var _ /* abPK at bp+32 */ uintptr + var _ /* azCol at bp+40 */ uintptr + var _ /* bRowid at bp+28 */ int32 + var _ /* d at bp+0 */ TSessionDiffCtx + var _ /* nCol at bp+24 */ int32 + var _ /* pDbExists at bp+48 */ uintptr + var _ /* pTo at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _ = bHasPk, bMismatch, db, i, rc, zDb, zDbExists, zExpr, v1 + zDb = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb + rc = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc + libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^t__predefined_size_t(0)) + _sessionDiffHooks(tls, pSession, bp) + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + if rc == SQLITE_OK { + zExpr = uintptr(0) + db = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb /* Table zTbl */ + /* Locate and if necessary initialize the target table object */ + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach + 1 + rc = _sessionFindTable(tls, pSession, zTbl, bp+16) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach - 1 + if **(**uintptr)(__ccgo_up(bp + 16)) == uintptr(0) { + goto diff_out + } + if _sessionInitTable(tls, pSession, **(**uintptr)(__ccgo_up(bp + 16)), (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb) != 0 { + rc = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc + goto diff_out + } + /* Check the table schemas match */ + if rc == SQLITE_OK { + bHasPk = 0 + bMismatch = 0 + **(**int32)(__ccgo_up(bp + 24)) = 0 /* Columns in zFrom.zTbl */ + **(**int32)(__ccgo_up(bp + 28)) = 0 + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + zDbExists = uintptr(0) + /* Check that database zFrom is attached. */ + zDbExists = Xsqlite3_mprintf(tls, __ccgo_ts+35927, libc.VaList(bp+64, zFrom)) + if zDbExists == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) + rc = Xsqlite3_prepare_v2(tls, db, zDbExists, -int32(1), bp+48, uintptr(0)) + if rc == int32(SQLITE_ERROR) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 24)) = -int32(1) + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 48))) + Xsqlite3_free(tls, zDbExists) + } + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp + 24)) == 0 { + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK != 0 { + v1 = bp + 28 + } else { + v1 = uintptr(0) + } + rc = _sessionTableInfo(tls, uintptr(0), db, zFrom, zTbl, bp+24, uintptr(0), uintptr(0), bp+40, uintptr(0), uintptr(0), bp+32, v1) + } + if rc == SQLITE_OK { + if (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FnCol != **(**int32)(__ccgo_up(bp + 24)) { + if **(**int32)(__ccgo_up(bp + 24)) <= 0 { + rc = int32(SQLITE_SCHEMA) + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+35958, libc.VaList(bp+64, zFrom, zTbl)) + } + } else { + bMismatch = int32(1) + } + } else { + i = 0 + for { + if !(i < **(**int32)(__ccgo_up(bp + 24))) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FabPK + uintptr(i)))) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)) + uintptr(i)))) { + bMismatch = int32(1) + } + if Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 40)) + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FazCol + uintptr(i)*8))) != 0 { + bMismatch = int32(1) + } + if **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)) + uintptr(i))) != 0 { + bHasPk = int32(1) + } + goto _2 + _2: + ; + i = i + 1 + } + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 40))) + if bMismatch != 0 { + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+35979, 0) + } + rc = int32(SQLITE_SCHEMA) + } + if bHasPk == 0 { + /* Ignore tables with no primary keys */ + goto diff_out + } + } + if rc == SQLITE_OK { + zExpr = _sessionExprComparePK(tls, (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FnCol, zDb, zFrom, (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FzName, (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FazCol, (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FabPK) + } + /* Find new rows */ + if rc == SQLITE_OK { + rc = _sessionDiffFindNew(tls, int32(SQLITE_INSERT), pSession, **(**uintptr)(__ccgo_up(bp + 16)), zDb, zFrom, zExpr) + } + /* Find old rows */ + if rc == SQLITE_OK { + rc = _sessionDiffFindNew(tls, int32(SQLITE_DELETE), pSession, **(**uintptr)(__ccgo_up(bp + 16)), zFrom, zDb, zExpr) + } + /* Find modified rows */ + if rc == SQLITE_OK { + rc = _sessionDiffFindModified(tls, pSession, **(**uintptr)(__ccgo_up(bp + 16)), zFrom, zExpr) + } + Xsqlite3_free(tls, zExpr) + } + goto diff_out +diff_out: + ; + _sessionPreupdateHooks(tls, pSession) + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + return rc +} + +const _ACCESS_EXTENDED_MASK = 4193792 + +const _APPEND_OK = 8192 + +const _AU_SESSION_FLAG_HAS_AUTHENTICATED = 16384 + +const _AU_SESSION_FLAG_HAS_CONSOLE_ACCESS = 8192 + +const _AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS = 16 + +const _AU_SESSION_FLAG_HAS_TTY = 32 + +const _AU_SESSION_FLAG_IS_INITIAL = 1 + +const _AU_SESSION_FLAG_IS_REMOTE = 4096 + +const _CHOWN_OK = 2097152 + +const _CRYPTEX1_AUTH_ENV_GENERIC = 4 + +const _CRYPTEX1_AUTH_ENV_GENERIC_SUPPLEMENTAL = 5 + +const _CRYPTEX_AUTH_MAX = 9 + +/* +** Allowed values of unixFile.fsFlags + */ + +/* +** If we are to be thread-safe, include the pthreads header. + */ +/* # include */ + +/* +** Default permissions when creating a new file + */ + +/* +** Default permissions when creating auto proxy dir + */ + +/* +** Maximum supported path-length. + */ + +/* +** Maximum supported symbolic links + */ + +/* +** Remove and stub certain info for WASI (WebAssembly System +** Interface) builds. + */ + +/* Always cast the getpid() return type for compatibility with +** kernel modules in VxWorks. */ + +/* +** Only set the lastErrno if the error code is a real error and not +** a normal expected return code of SQLITE_BUSY or SQLITE_OK + */ + +const _CRYPTEX_AUTH_MOBILE_ASSET = 8 + +const _CRYPTEX_AUTH_MOBILE_ASSET_WITH_CODE = 9 + +const _CRYPTEX_AUTH_PDI_NONCE = 6 + +const _CS_DARWIN_USER_CACHE_DIR = 65538 + +const _CS_DARWIN_USER_DIR = 65536 + +const _CS_DARWIN_USER_TEMP_DIR = 65537 + +const _CS_XBS5_ILP32_OFF32_CFLAGS = 20 + +const _CS_XBS5_ILP32_OFF32_LDFLAGS = 21 + +const _CS_XBS5_ILP32_OFF32_LIBS = 22 + +const _CS_XBS5_ILP32_OFF32_LINTFLAGS = 23 + +const _CS_XBS5_ILP32_OFFBIG_CFLAGS = 24 + +const _CS_XBS5_ILP32_OFFBIG_LDFLAGS = 25 + +const _CS_XBS5_ILP32_OFFBIG_LIBS = 26 + +const _CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 27 + +const _CS_XBS5_LP64_OFF64_CFLAGS = 28 + +const _CS_XBS5_LP64_OFF64_LDFLAGS = 29 + +const _CS_XBS5_LP64_OFF64_LIBS = 30 + +const _CS_XBS5_LP64_OFF64_LINTFLAGS = 31 + +const _CS_XBS5_LPBIG_OFFBIG_CFLAGS = 32 + +const _CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 33 + +const _CS_XBS5_LPBIG_OFFBIG_LIBS = 34 + +const _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 35 + +const _DARWIN_FEATURE_64_BIT_INODE = 1 + +const _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 + +const _DARWIN_FEATURE_UNIX_CONFORMANCE = 3 + +const _DELETE_OK = 4096 + +const _EXECUTE_OK = 2048 + +const _FILESEC_ACL = 5 + +const _FILESEC_ACL_ALLOCSIZE = 101 + +const _FILESEC_ACL_RAW = 100 + +const _FILESEC_GROUP = 2 + +const _FILESEC_GRPUUID = 6 + +const _FILESEC_MODE = 4 + +const _FILESEC_OWNER = 1 + +const _FILESEC_UUID = 3 + +const _FORTIFY_SOURCE = 2 + +const _GRAFTDMG_CRYPTEX_AUTH_ENV_GENERIC = 4 + +const _GRAFTDMG_CRYPTEX_BOOT = 1 + +const _GRAFTDMG_CRYPTEX_DOWNLEVEL = 3 + +const _GRAFTDMG_CRYPTEX_EFFECTIVE_AP = 7 + +const _GRAFTDMG_CRYPTEX_MAX = 9 + +const _GRAFTDMG_CRYPTEX_MOBILE_ASSET = 8 + +const _GRAFTDMG_CRYPTEX_MOBILE_ASSET_WITH_CODE = 9 + +const _GRAFTDMG_CRYPTEX_PDI_NONCE = 6 + +const _GRAFTDMG_CRYPTEX_PREBOOT = 2 + +const _HAS_BUILTIN_AVAILABLE_FEATS = 1 + +const _LIBC_COUNT__MB_LEN_MAX = 0 + +const _LIBC_COUNT__PATH_MAX = 0 + +const _MALLOC_TYPE_MALLOC_BACKDEPLOY_PUBLIC = 1 + +const _MPO_CONNECTION_PORT = 2048 + +const _MPO_CONNECTION_PORT_WITH_PORT_ARRAY = 65536 + +const _MPO_EXCEPTION_PORT = 32768 + +const _MPO_NOTIFICATION_PORT = 17408 + +const _MPO_PORT = 0 + +const _MPO_REPLY_PORT = 4096 + +const _MPO_SERVICE_PORT = 1024 + +const _MPO_WEAK_REPLY_PORT = 16384 + +const _PC_2_SYMLINKS = 15 + +const _PC_ALLOC_SIZE_MIN = 16 + +const _PC_ASYNC_IO = 17 + +const _PC_AUTH_OPAQUE_NP = 14 + +const _PC_CASE_PRESERVING = 12 + +const _PC_CASE_SENSITIVE = 11 + +const _PC_EXTENDED_SECURITY_NP = 13 + +const _PC_FILESIZEBITS = 18 + +const _PC_MIN_HOLE_SIZE = 27 + +const _PC_NAME_CHARS_MAX = 10 + +const _PC_PRIO_IO = 19 + +const _PC_REC_INCR_XFER_SIZE = 20 + +const _PC_REC_MAX_XFER_SIZE = 21 + +const _PC_REC_MIN_XFER_SIZE = 22 + +const _PC_REC_XFER_ALIGN = 23 + +const _PC_SYMLINK_MAX = 24 + +const _PC_SYNC_IO = 25 + +const _PC_XATTR_SIZE_BITS = 26 + +const _POSIX2_CHAR_TERM = 200112 + +const _POSIX2_C_DEV = 200112 + +const _POSIX2_LOCALEDEF = 200112 + +const _POSIX_BARRIERS = -1 + +const _POSIX_CHOWN_RESTRICTED = 200112 + +const _POSIX_CPUTIME = -1 + +const _POSIX_IPV6 = 200112 + +const _POSIX_JOB_CONTROL = 200112 + +const _POSIX_MEMLOCK_RANGE = -1 + +const _POSIX_MONOTONIC_CLOCK = -1 + +const _POSIX_NO_TRUNC = 200112 + +const _POSIX_RAW_SOCKETS = -1 + +const _POSIX_REGEXP = 200112 + +const _POSIX_SAVED_IDS = 200112 + +const _POSIX_SEMAPHORES = -1 + +const _POSIX_SHARED_MEMORY_OBJECTS = -1 + +const _POSIX_SHELL = 200112 + +const _POSIX_SPIN_LOCKS = -1 + +const _POSIX_THREAD_CPUTIME = -1 + +const _POSIX_TIMEOUTS = -1 + +const _POSIX_V6_ILP32_OFFBIG = -1 + +const _POSIX_V6_LPBIG_OFFBIG = 1 + +const _POSIX_V7_ILP32_OFFBIG = -1 + +const _POSIX_V7_LPBIG_OFFBIG = 1 + +const _P_PGID = 2 + +const _RATTR_OK = 32768 + +const _READ_OK = 512 + +const _REXT_OK = 131072 + +const _RLIMIT_POSIX_FLAG = 4096 + +const _RMFILE_OK = 16384 + +const _RPERM_OK = 524288 + +const _RUNE_MAGIC_A = "RuneMagA" + +type _RuneCharClass = T_RuneCharClass + +type _RuneLocale = T_RuneLocale + +/* +** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY. +** This allows better measurements of where memcpy() is used when running +** cachegrind. But this macro version of memcpy() is very slow so it +** should not be used in production. This is a performance measurement +** hack only. + */ + +/* +** If compiling for a processor that lacks floating point support, +** substitute integer for floating-point + */ + +/* +** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0 +** afterward. Having this macro allows us to cause the C compiler +** to omit code used by TEMP tables without messy #ifndef statements. + */ + +/* +** The "file format" number is an integer that is incremented whenever +** the VDBE-level file format changes. The following macros define the +** the default file format for new databases and the maximum file format +** that the library can read. + */ + +/* +** Determine whether triggers are recursive by default. This can be +** changed at run-time using a pragma. + */ + +/* +** Provide a default value for SQLITE_TEMP_STORE in case it is not specified +** on the command-line + */ + +/* +** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if +** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it +** to zero. + */ + +/* +** The default initial allocation for the pagecache when using separate +** pagecaches for each database connection. A positive number is the +** number of pages. A negative number N translations means that a buffer +** of -1024*N bytes is allocated and used for as many pages as it will hold. +** +** The default value of "20" was chosen to minimize the run-time of the +** speedtest1 test program with options: --shrink-memory --reprepare + */ + +/* +** Default value for the SQLITE_CONFIG_SORTERREF_SIZE option. + */ + +/* +** The compile-time options SQLITE_MMAP_READWRITE and +** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another. +** You must choose one or the other (or neither) but not both. + */ + +/* +** GCC does not define the offsetof() macro so we'll have to do it +** ourselves. + */ + +/* +** Work around C99 "flex-array" syntax for pre-C99 compilers, so as +** to avoid complaints from -fsanitize=strict-bounds. + */ + +/* +** Macros to compute minimum and maximum of two numbers. + */ + +/* +** Swap two objects of type TYPE. + */ + +/* +** Check to see if this machine uses EBCDIC. (Yes, believe it or +** not, there are still machines out there that use EBCDIC.) + */ + +const _SC_MAPPED_FILES = 47 + +const _SC_PAGESIZE = 29 + +const _SC_PAGE_SIZE = 29 + +const _SC_PASS_MAX = 131 + +const _SC_PHYS_PAGES = 200 + +const _SC_SS_REPL_MAX = 126 + +const _SC_TRACE_EVENT_NAME_MAX = 127 + +const _SC_TRACE_NAME_MAX = 128 + +const _SC_TRACE_SYS_MAX = 129 + +const _SC_TRACE_USER_EVENT_MAX = 130 + +const _SC_XBS5_ILP32_OFF32 = 122 + +const _SC_XBS5_ILP32_OFFBIG = 123 + +const _SC_XBS5_LP64_OFF64 = 124 + +const _SC_XBS5_LPBIG_OFFBIG = 125 + +const _SC_XOPEN_XCU_VERSION = 121 + +const _SS_ALIGNSIZE = 0 + +const _SS_MAXSIZE = 128 + +const _SS_PAD1SIZE = 0 + +const _SS_PAD2SIZE = 128 + +const _STRUCT_MCONTEXT = "_STRUCT_MCONTEXT64" + +// C documentation +// +// /* +// ** Arguments aIdx, aCell and aSpare all point to arrays of size +// ** nIdx. The aIdx array contains the set of integers from 0 to +// ** (nIdx-1) in no particular order. This function sorts the values +// ** in aIdx according to dimension iDim of the cells in aCell. The +// ** minimum value of dimension iDim is considered first, the +// ** maximum used to break ties. +// ** +// ** The aSpare array is used as temporary working space by the +// ** sorting algorithm. +// */ +func _SortByDimension(tls *libc.TLS, pRtree uintptr, aIdx uintptr, nIdx int32, iDim int32, aCell uintptr, aSpare uintptr) { + var aLeft, aRight uintptr + var iLeft, iRight, nLeft, nRight int32 + var xleft1, xleft2, xright1, xright2 TRtreeDValue + var v1, v2, v3, v4 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aLeft, aRight, iLeft, iRight, nLeft, nRight, xleft1, xleft2, xright1, xright2, v1, v2, v3, v4 + if nIdx > int32(1) { + iLeft = 0 + iRight = 0 + nLeft = nIdx / int32(2) + nRight = nIdx - nLeft + aLeft = aIdx + aRight = aIdx + uintptr(nLeft)*4 + _SortByDimension(tls, pRtree, aLeft, nLeft, iDim, aCell, aSpare) + _SortByDimension(tls, pRtree, aRight, nRight, iDim, aCell, aSpare) + libc.X__builtin___memcpy_chk(tls, aSpare, aLeft, uint64(4)*libc.Uint64FromInt32(nLeft), ^t__predefined_size_t(0)) + aLeft = aSpare + for iLeft < nLeft || iRight < nRight { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v1 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*int32(2))*4))) + } else { + v1 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*int32(2))*4))) + } + xleft1 = v1 + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v2 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*int32(2)+int32(1))*4))) + } else { + v2 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*int32(2)+int32(1))*4))) + } + xleft2 = v2 + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v3 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*int32(2))*4))) + } else { + v3 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*int32(2))*4))) + } + xright1 = v3 + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v4 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*int32(2)+int32(1))*4))) + } else { + v4 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*int32(2)+int32(1))*4))) + } + xright2 = v4 + if iLeft != nLeft && (iRight == nRight || xleft1 < xright1 || xleft1 == xright1 && xleft2 < xright2) { + **(**int32)(__ccgo_up(aIdx + uintptr(iLeft+iRight)*4)) = **(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)) + iLeft = iLeft + 1 + } else { + **(**int32)(__ccgo_up(aIdx + uintptr(iLeft+iRight)*4)) = **(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)) + iRight = iRight + 1 + } + } + } +} + +func _SplitNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var aCell, aiUsed, pLeft, pParent, pRight uintptr + var i, nCell, newCellIsRight, rc, v2, v3 int32 + var iRowid, iRowid1 Ti64 + var v4, v5 bool + var _ /* iCell at bp+96 */ int32 + var _ /* leftbbox at bp+0 */ TRtreeCell + var _ /* rightbbox at bp+48 */ TRtreeCell + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCell, aiUsed, i, iRowid, iRowid1, nCell, newCellIsRight, pLeft, pParent, pRight, rc, v2, v3, v4, v5 + newCellIsRight = 0 + rc = SQLITE_OK + nCell = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) + pLeft = uintptr(0) + pRight = uintptr(0) + /* Allocate an array and populate it with a copy of pCell and + ** all cells from node pLeft. Then zero the original node. + */ + aCell = Xsqlite3_malloc64(tls, uint64((libc.Uint64FromInt64(48)+libc.Uint64FromInt64(4))*libc.Uint64FromInt32(nCell+libc.Int32FromInt32(1)))) + if !(aCell != 0) { + rc = int32(SQLITE_NOMEM) + goto splitnode_out + } + aiUsed = aCell + uintptr(nCell+int32(1))*48 + libc.X__builtin___memset_chk(tls, aiUsed, 0, uint64(4)*libc.Uint64FromInt32(nCell+libc.Int32FromInt32(1)), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < nCell) { + break + } + _nodeGetCell(tls, pRtree, pNode, i, aCell+uintptr(i)*48) + goto _1 + _1: + ; + i = i + 1 + } + _nodeZero(tls, pRtree, pNode) + libc.X__builtin___memcpy_chk(tls, aCell+uintptr(nCell)*48, pCell, uint64(48), ^t__predefined_size_t(0)) + nCell = nCell + 1 + if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) { + pRight = _nodeNew(tls, pRtree, pNode) + pLeft = _nodeNew(tls, pRtree, pNode) + (*TRtree)(unsafe.Pointer(pRtree)).FiDepth = (*TRtree)(unsafe.Pointer(pRtree)).FiDepth + 1 + (*TRtreeNode)(unsafe.Pointer(pNode)).FisDirty = int32(1) + _writeInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData, (*TRtree)(unsafe.Pointer(pRtree)).FiDepth) + } else { + pLeft = pNode + pRight = _nodeNew(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pLeft)).FpParent) + (*TRtreeNode)(unsafe.Pointer(pLeft)).FnRef = (*TRtreeNode)(unsafe.Pointer(pLeft)).FnRef + 1 + } + if !(pLeft != 0) || !(pRight != 0) { + rc = int32(SQLITE_NOMEM) + goto splitnode_out + } + libc.X__builtin___memset_chk(tls, (*TRtreeNode)(unsafe.Pointer(pLeft)).FzData, 0, libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, (*TRtreeNode)(unsafe.Pointer(pRight)).FzData, 0, libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize), ^t__predefined_size_t(0)) + rc = _splitNodeStartree(tls, pRtree, aCell, nCell, pLeft, pRight, bp, bp+48) + if rc != SQLITE_OK { + goto splitnode_out + } + /* Ensure both child nodes have node numbers assigned to them by calling + ** nodeWrite(). Node pRight always needs a node number, as it was created + ** by nodeNew() above. But node pLeft sometimes already has a node number. + ** In this case avoid the all to nodeWrite(). + */ + v2 = _nodeWrite(tls, pRtree, pRight) + rc = v2 + if v5 = SQLITE_OK != v2; !v5 { + if v4 = 0 == (*TRtreeNode)(unsafe.Pointer(pLeft)).FiNode; v4 { + v3 = _nodeWrite(tls, pRtree, pLeft) + rc = v3 + } + } + if v5 || v4 && SQLITE_OK != v3 { + goto splitnode_out + } + (**(**TRtreeCell)(__ccgo_up(bp + 48))).FiRowid = (*TRtreeNode)(unsafe.Pointer(pRight)).FiNode + (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid = (*TRtreeNode)(unsafe.Pointer(pLeft)).FiNode + if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) { + rc = _rtreeInsertCell(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pLeft)).FpParent, bp, iHeight+int32(1)) + if rc != SQLITE_OK { + goto splitnode_out + } + } else { + pParent = (*TRtreeNode)(unsafe.Pointer(pLeft)).FpParent + rc = _nodeParentIndex(tls, pRtree, pLeft, bp+96) + if rc == SQLITE_OK { + _nodeOverwriteCell(tls, pRtree, pParent, bp, **(**int32)(__ccgo_up(bp + 96))) + rc = _AdjustTree(tls, pRtree, pParent, bp) + } + if rc != SQLITE_OK { + goto splitnode_out + } + } + v2 = _rtreeInsertCell(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pRight)).FpParent, bp+48, iHeight+int32(1)) + rc = v2 + if v2 != 0 { + goto splitnode_out + } + i = 0 + for { + if !(i < _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pRight)).FzData+2)) { + break + } + iRowid = _nodeGetRowid(tls, pRtree, pRight, i) + rc = _updateMapping(tls, pRtree, iRowid, pRight, iHeight) + if iRowid == (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid { + newCellIsRight = int32(1) + } + if rc != SQLITE_OK { + goto splitnode_out + } + goto _7 + _7: + ; + i = i + 1 + } + if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) { + i = 0 + for { + if !(i < _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pLeft)).FzData+2)) { + break + } + iRowid1 = _nodeGetRowid(tls, pRtree, pLeft, i) + rc = _updateMapping(tls, pRtree, iRowid1, pLeft, iHeight) + if rc != SQLITE_OK { + goto splitnode_out + } + goto _8 + _8: + ; + i = i + 1 + } + } else { + if newCellIsRight == 0 { + rc = _updateMapping(tls, pRtree, (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid, pLeft, iHeight) + } + } + goto splitnode_out +splitnode_out: + ; + _nodeRelease(tls, pRtree, pRight) + _nodeRelease(tls, pRtree, pLeft) + Xsqlite3_free(tls, aCell) + return rc +} + +const _V6_ILP32_OFFBIG = -1 + +const _V6_LP64_OFF64 = 1 + +const _V6_LPBIG_OFFBIG = 1 + +const _WATTR_OK = 65536 + +const _WEXT_OK = 262144 + +const _WPERM_OK = 1048576 + +const _WRITE_OK = 1024 + +const _WSTOPPED = 127 + +const _XBS5_ILP32_OFF32 = -1 + +const _XBS5_ILP32_OFFBIG = -1 + +const _XBS5_LP64_OFF64 = 1 + +const _XBS5_LPBIG_OFFBIG = 1 + +const _XOPEN_VERSION = 600 + +const _XOPEN_XCU_VERSION = 4 + +const __API_TO_BE_DEPRECATED = 100000 + +const __API_TO_BE_DEPRECATED_DRIVERKIT = 100000 + +const __API_TO_BE_DEPRECATED_IOS = 100000 + +const __API_TO_BE_DEPRECATED_IOSAPPLICATIONEXTENSION = 100000 + +const __API_TO_BE_DEPRECATED_KERNELKIT = 100000 + +const __API_TO_BE_DEPRECATED_MACCATALYST = 100000 + +const __API_TO_BE_DEPRECATED_MACCATALYSTAPPLICATIONEXTENSION = 100000 + +const __API_TO_BE_DEPRECATED_MACOS = 100000 + +const __API_TO_BE_DEPRECATED_MACOSAPPLICATIONEXTENSION = 100000 + +const __API_TO_BE_DEPRECATED_TVOS = 100000 + +const __API_TO_BE_DEPRECATED_TVOSAPPLICATIONEXTENSION = 100000 + +const __API_TO_BE_DEPRECATED_VISIONOS = 100000 + +const __API_TO_BE_DEPRECATED_VISIONOSAPPLICATIONEXTENSION = 100000 + +const __API_TO_BE_DEPRECATED_WATCHOS = 100000 + +const __API_TO_BE_DEPRECATED_WATCHOSAPPLICATIONEXTENSION = 100000 + +const __APPLE_CC__ = 6000 + +const __APPLE__ = 1 + +const __ASSUME_PTR_ABI_SINGLE_BEGIN = 0 + +const __ASSUME_PTR_ABI_SINGLE_END = 0 + +const __AUDIT_API_DEPRECATED = 0 + +const __AVAILABILITY_FILE = "AvailabilityVersions.h" + +const __AVAILABILITY_VERSIONS_VERSION_HASH = 93585900 + +const __AVAILABILITY_VERSIONS_VERSION_STRING = "Local" + +const __BLOCKS__ = 1 + +const __BOOL_WIDTH__ = 1 + +const __BRIDGEOS_10_0 = 100000 + +const __BRIDGEOS_10_1 = 100100 + +const __BRIDGEOS_10_2 = 100200 + +const __BRIDGEOS_10_3 = 100300 + +const __BRIDGEOS_10_4 = 100400 + +const __BRIDGEOS_2_0 = 20000 + +const __BRIDGEOS_3_0 = 30000 + +const __BRIDGEOS_3_1 = 30100 + +const __BRIDGEOS_3_4 = 30400 + +const __BRIDGEOS_4_0 = 40000 + +const __BRIDGEOS_4_1 = 40100 + +const __BRIDGEOS_5_0 = 50000 + +const __BRIDGEOS_5_1 = 50100 + +const __BRIDGEOS_5_3 = 50300 + +const __BRIDGEOS_6_0 = 60000 + +const __BRIDGEOS_6_2 = 60200 + +const __BRIDGEOS_6_4 = 60400 + +const __BRIDGEOS_6_5 = 60500 + +const __BRIDGEOS_6_6 = 60600 + +const __BRIDGEOS_7_0 = 70000 + +const __BRIDGEOS_7_1 = 70100 + +const __BRIDGEOS_7_2 = 70200 + +const __BRIDGEOS_7_3 = 70300 + +const __BRIDGEOS_7_4 = 70400 + +const __BRIDGEOS_7_6 = 70600 + +const __BRIDGEOS_8_0 = 80000 + +const __BRIDGEOS_8_1 = 80100 + +const __BRIDGEOS_8_2 = 80200 + +const __BRIDGEOS_8_3 = 80300 + +const __BRIDGEOS_8_4 = 80400 + +const __BRIDGEOS_8_5 = 80500 + +const __BRIDGEOS_8_6 = 80600 + +const __BRIDGEOS_9_0 = 90000 + +const __BRIDGEOS_9_1 = 90100 + +const __BRIDGEOS_9_2 = 90200 + +const __BRIDGEOS_9_3 = 90300 + +const __BRIDGEOS_9_4 = 90400 + +const __BRIDGEOS_9_5 = 90500 + +const __BRIDGEOS_9_6 = 90600 + +const __CLOCK_MONOTONIC = 6 + +const __CLOCK_MONOTONIC_RAW = 4 + +const __CLOCK_MONOTONIC_RAW_APPROX = 5 + +const __CLOCK_PROCESS_CPUTIME_ID = 12 + +const __CLOCK_REALTIME = 0 + +const __CLOCK_THREAD_CPUTIME_ID = 16 + +/* +** The MSVC CRT on Windows CE may not have a localtime() function. +** So declare a substitute. The substitute function itself is +** defined in "os_win.c". + */ + +const __CLOCK_UPTIME_RAW = 8 + +const __CLOCK_UPTIME_RAW_APPROX = 9 + +const __DARWIN_64_BIT_INO_T = 1 + +const __DARWIN_ALIGNBYTES = -1 + +const __DARWIN_ALIGNBYTES32 = -1 + +const __DARWIN_BIG_ENDIAN = 4321 + +const __DARWIN_BYTE_ORDER = 1234 + +const __DARWIN_CTYPE_TOP_inline = 0 + +const __DARWIN_CTYPE_inline = 0 + +const __DARWIN_C_ANSI = 4096 + +const __DARWIN_C_FULL = 900000 + +const __DARWIN_C_LEVEL = 900000 + +const __DARWIN_FD_SETSIZE = 1024 + +const __DARWIN_LITTLE_ENDIAN = 1234 + +const __DARWIN_NBBY = 8 + +const __DARWIN_NFDBITS = 0 + +const __DARWIN_NON_CANCELABLE = 0 + +const __DARWIN_NO_LONG_LONG = 0 + +const __DARWIN_NSIG = 32 + +const __DARWIN_ONLY_UNIX_CONFORMANCE = 1 + +const __DARWIN_PDP_ENDIAN = 3412 + +const __DARWIN_SUF_EXTSN = "$DARWIN_EXTSN" + +const __DARWIN_UNIX03 = 1 + +const __DARWIN_VERS_1050 = 1 + +const __DARWIN_WCHAR_MAX = 2147483647 + +const __DARWIN_WCHAR_MIN = -2147483648 + +const __DARWIN_WEOF = -1 + +const __DBL_MIN__ = 2.2250738585072014e-308 + +const __DRIVERKIT_19_0 = 190000 + +const __DRIVERKIT_20_0 = 200000 + +const __DRIVERKIT_21_0 = 210000 + +const __DRIVERKIT_22_0 = 220000 + +const __DRIVERKIT_22_4 = 220400 + +const __DRIVERKIT_22_5 = 220500 + +const __DRIVERKIT_22_6 = 220600 + +const __DRIVERKIT_23_0 = 230000 + +const __DRIVERKIT_23_1 = 230100 + +const __DRIVERKIT_23_2 = 230200 + +const __DRIVERKIT_23_3 = 230300 + +const __DRIVERKIT_23_4 = 230400 + +const __DRIVERKIT_23_5 = 230500 + +const __DRIVERKIT_23_6 = 230600 + +const __DRIVERKIT_24_0 = 240000 + +const __DRIVERKIT_24_1 = 240100 + +const __DRIVERKIT_24_2 = 240200 + +const __DRIVERKIT_24_3 = 240300 + +const __DRIVERKIT_24_4 = 240400 + +const __DRIVERKIT_24_5 = 240500 + +const __DRIVERKIT_24_6 = 240600 + +const __DRIVERKIT_25_0 = 250000 + +const __DRIVERKIT_25_1 = 250100 + +const __DRIVERKIT_25_2 = 250200 + +const __DRIVERKIT_25_3 = 250300 + +const __DRIVERKIT_25_4 = 250400 + +const __DYLDDL_DLSYM_UNAVAILABLE = 0 + +const __DYLDDL_UNAVAILABLE = 0 + +const __DYNAMIC__ = 1 + +const __ENABLE_LEGACY_MAC_AVAILABILITY = 1 + +const __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 260000 + +const __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ = 260000 + +const __FLT_MIN__ = 1.17549435e-38 + +const __ILP32_OFF32 = -1 + +const __ILP32_OFFBIG = -1 + +const __INT_LEAST64_MAX = 9223372036854775807 + +const __INT_LEAST64_MIN = -9223372036854775808 + +const __IPHONE_10_0 = 100000 + +const __IPHONE_10_1 = 100100 + +const __IPHONE_10_2 = 100200 + +const __IPHONE_10_3 = 100300 + +const __IPHONE_11_0 = 110000 + +const __IPHONE_11_1 = 110100 + +const __IPHONE_11_2 = 110200 + +const __IPHONE_11_3 = 110300 + +const __IPHONE_11_4 = 110400 + +const __IPHONE_12_0 = 120000 + +const __IPHONE_12_1 = 120100 + +const __IPHONE_12_2 = 120200 + +const __IPHONE_12_3 = 120300 + +const __IPHONE_12_4 = 120400 + +const __IPHONE_13_0 = 130000 + +const __IPHONE_13_1 = 130100 + +const __IPHONE_13_2 = 130200 + +const __IPHONE_13_3 = 130300 + +const __IPHONE_13_4 = 130400 + +const __IPHONE_13_5 = 130500 + +const __IPHONE_13_6 = 130600 + +const __IPHONE_13_7 = 130700 + +const __IPHONE_14_0 = 140000 + +const __IPHONE_14_1 = 140100 + +const __IPHONE_14_2 = 140200 + +const __IPHONE_14_3 = 140300 + +const __IPHONE_14_5 = 140500 + +const __IPHONE_14_6 = 140600 + +const __IPHONE_14_7 = 140700 + +const __IPHONE_14_8 = 140800 + +const __IPHONE_15_0 = 150000 + +const __IPHONE_15_1 = 150100 + +const __IPHONE_15_2 = 150200 + +const __IPHONE_15_3 = 150300 + +const __IPHONE_15_4 = 150400 + +const __IPHONE_15_5 = 150500 + +const __IPHONE_15_6 = 150600 + +const __IPHONE_15_7 = 150700 + +const __IPHONE_15_8 = 150800 + +const __IPHONE_16_0 = 160000 + +const __IPHONE_16_1 = 160100 + +const __IPHONE_16_2 = 160200 + +const __IPHONE_16_3 = 160300 + +const __IPHONE_16_4 = 160400 + +const __IPHONE_16_5 = 160500 + +const __IPHONE_16_6 = 160600 + +const __IPHONE_16_7 = 160700 + +const __IPHONE_17_0 = 170000 + +const __IPHONE_17_1 = 170100 + +const __IPHONE_17_2 = 170200 + +const __IPHONE_17_3 = 170300 + +const __IPHONE_17_4 = 170400 + +const __IPHONE_17_5 = 170500 + +const __IPHONE_17_6 = 170600 + +const __IPHONE_17_7 = 170700 + +const __IPHONE_18_0 = 180000 + +const __IPHONE_18_1 = 180100 + +const __IPHONE_18_2 = 180200 + +const __IPHONE_18_3 = 180300 + +const __IPHONE_18_4 = 180400 + +const __IPHONE_18_5 = 180500 + +const __IPHONE_18_6 = 180600 + +const __IPHONE_19_0 = 190000 + +const __IPHONE_26_0 = 260000 + +const __IPHONE_26_1 = 260100 + +const __IPHONE_26_2 = 260200 + +const __IPHONE_26_3 = 260300 + +const __IPHONE_26_4 = 260400 + +const __IPHONE_2_0 = 20000 + +const __IPHONE_2_1 = 20100 + +const __IPHONE_2_2 = 20200 + +const __IPHONE_3_0 = 30000 + +const __IPHONE_3_1 = 30100 + +const __IPHONE_3_2 = 30200 + +const __IPHONE_4_0 = 40000 + +const __IPHONE_4_1 = 40100 + +const __IPHONE_4_2 = 40200 + +const __IPHONE_4_3 = 40300 + +const __IPHONE_5_0 = 50000 + +const __IPHONE_5_1 = 50100 + +const __IPHONE_6_0 = 60000 + +const __IPHONE_6_1 = 60100 + +const __IPHONE_7_0 = 70000 + +const __IPHONE_7_1 = 70100 + +const __IPHONE_8_0 = 80000 + +const __IPHONE_8_1 = 80100 + +const __IPHONE_8_2 = 80200 + +const __IPHONE_8_3 = 80300 + +const __IPHONE_8_4 = 80400 + +const __IPHONE_9_0 = 90000 + +const __IPHONE_9_1 = 90100 + +const __IPHONE_9_2 = 90200 + +const __IPHONE_9_3 = 90300 + +const __LDBL_MIN__ = 2.2250738585072014e-308 + +const __LP64_OFF64 = 1 + +const __LPBIG_OFFBIG = 1 + +const __MACH__ = 1 + +const __MAC_10_0 = 1000 + +const __MAC_10_1 = 1010 + +const __MAC_10_10 = 101000 + +const __MAC_10_10_2 = 101002 + +const __MAC_10_10_3 = 101003 + +const __MAC_10_11 = 101100 + +const __MAC_10_11_2 = 101102 + +const __MAC_10_11_3 = 101103 + +const __MAC_10_11_4 = 101104 + +const __MAC_10_12 = 101200 + +const __MAC_10_12_1 = 101201 + +const __MAC_10_12_2 = 101202 + +const __MAC_10_12_4 = 101204 + +const __MAC_10_13 = 101300 + +const __MAC_10_13_1 = 101301 + +const __MAC_10_13_2 = 101302 + +const __MAC_10_13_4 = 101304 + +const __MAC_10_14 = 101400 + +const __MAC_10_14_1 = 101401 + +const __MAC_10_14_4 = 101404 + +const __MAC_10_14_5 = 101405 + +const __MAC_10_14_6 = 101406 + +const __MAC_10_15 = 101500 + +const __MAC_10_15_1 = 101501 + +const __MAC_10_15_4 = 101504 + +const __MAC_10_16 = 101600 + +const __MAC_10_2 = 1020 + +const __MAC_10_3 = 1030 + +const __MAC_10_4 = 1040 + +const __MAC_10_5 = 1050 + +const __MAC_10_6 = 1060 + +const __MAC_10_7 = 1070 + +const __MAC_10_8 = 1080 + +const __MAC_10_9 = 1090 + +const __MAC_11_0 = 110000 + +const __MAC_11_1 = 110100 + +const __MAC_11_3 = 110300 + +const __MAC_11_4 = 110400 + +const __MAC_11_5 = 110500 + +const __MAC_11_6 = 110600 + +const __MAC_12_0 = 120000 + +const __MAC_12_1 = 120100 + +const __MAC_12_2 = 120200 + +const __MAC_12_3 = 120300 + +const __MAC_12_4 = 120400 + +const __MAC_12_5 = 120500 + +const __MAC_12_6 = 120600 + +const __MAC_12_7 = 120700 + +const __MAC_13_0 = 130000 + +const __MAC_13_1 = 130100 + +const __MAC_13_2 = 130200 + +const __MAC_13_3 = 130300 + +const __MAC_13_4 = 130400 + +const __MAC_13_5 = 130500 + +const __MAC_13_6 = 130600 + +const __MAC_13_7 = 130700 + +const __MAC_14_0 = 140000 + +const __MAC_14_1 = 140100 + +const __MAC_14_2 = 140200 + +const __MAC_14_3 = 140300 + +const __MAC_14_4 = 140400 + +const __MAC_14_5 = 140500 + +const __MAC_14_6 = 140600 + +const __MAC_14_7 = 140700 + +const __MAC_15_0 = 150000 + +const __MAC_15_1 = 150100 + +const __MAC_15_2 = 150200 + +const __MAC_15_3 = 150300 + +const __MAC_15_4 = 150400 + +const __MAC_15_5 = 150500 + +const __MAC_15_6 = 150600 + +const __MAC_16_0 = 160000 + +const __MAC_26_0 = 260000 + +const __MAC_26_1 = 260100 + +const __MAC_26_2 = 260200 + +const __MAC_26_3 = 260300 + +const __MAC_26_4 = 260400 + +const __NULLABILITY_COMPLETENESS_POP = 0 + +const __NULLABILITY_COMPLETENESS_PUSH = 0 + +const __PTHREAD_ATTR_SIZE__ = 56 + +const __PTHREAD_CONDATTR_SIZE__ = 8 + +const __PTHREAD_COND_SIZE__ = 40 + +const __PTHREAD_MUTEXATTR_SIZE__ = 8 + +const __PTHREAD_MUTEX_SIZE__ = 56 + +const __PTHREAD_ONCE_SIZE__ = 8 + +const __PTHREAD_RWLOCKATTR_SIZE__ = 16 + +const __PTHREAD_RWLOCK_SIZE__ = 192 + +const __PTHREAD_SIZE__ = 8176 + +const __SSP__ = 1 + +const __STDC_WANT_LIB_EXT1__ = 1 + +const __TVOS_10_0 = 100000 + +const __TVOS_10_0_1 = 100001 + +const __TVOS_10_1 = 100100 + +const __TVOS_10_2 = 100200 + +const __TVOS_11_0 = 110000 + +const __TVOS_11_1 = 110100 + +const __TVOS_11_2 = 110200 + +const __TVOS_11_3 = 110300 + +const __TVOS_11_4 = 110400 + +const __TVOS_12_0 = 120000 + +const __TVOS_12_1 = 120100 + +const __TVOS_12_2 = 120200 + +const __TVOS_12_3 = 120300 + +const __TVOS_12_4 = 120400 + +const __TVOS_13_0 = 130000 + +const __TVOS_13_2 = 130200 + +const __TVOS_13_3 = 130300 + +const __TVOS_13_4 = 130400 + +const __TVOS_14_0 = 140000 + +const __TVOS_14_1 = 140100 + +const __TVOS_14_2 = 140200 + +const __TVOS_14_3 = 140300 + +const __TVOS_14_5 = 140500 + +const __TVOS_14_6 = 140600 + +const __TVOS_14_7 = 140700 + +const __TVOS_15_0 = 150000 + +const __TVOS_15_1 = 150100 + +const __TVOS_15_2 = 150200 + +const __TVOS_15_3 = 150300 + +const __TVOS_15_4 = 150400 + +const __TVOS_15_5 = 150500 + +const __TVOS_15_6 = 150600 + +const __TVOS_16_0 = 160000 + +const __TVOS_16_1 = 160100 + +const __TVOS_16_2 = 160200 + +const __TVOS_16_3 = 160300 + +const __TVOS_16_4 = 160400 + +const __TVOS_16_5 = 160500 + +const __TVOS_16_6 = 160600 + +const __TVOS_17_0 = 170000 + +const __TVOS_17_1 = 170100 + +const __TVOS_17_2 = 170200 + +const __TVOS_17_3 = 170300 + +const __TVOS_17_4 = 170400 + +const __TVOS_17_5 = 170500 + +const __TVOS_17_6 = 170600 + +const __TVOS_18_0 = 180000 + +const __TVOS_18_1 = 180100 + +const __TVOS_18_2 = 180200 + +const __TVOS_18_3 = 180300 + +const __TVOS_18_4 = 180400 + +const __TVOS_18_5 = 180500 + +const __TVOS_18_6 = 180600 + +const __TVOS_19_0 = 190000 + +const __TVOS_26_0 = 260000 + +const __TVOS_26_1 = 260100 + +const __TVOS_26_2 = 260200 + +const __TVOS_26_3 = 260300 + +const __TVOS_26_4 = 260400 + +const __TVOS_9_0 = 90000 + +const __TVOS_9_1 = 90100 + +const __TVOS_9_2 = 90200 + +const __UINT_LEAST64_MAX = 18446744073709551615 + +const __VERSION__ = "Apple LLVM 21.0.0 (clang-2100.0.123.102)" + +const __VISIONOS_1_0 = 10000 + +const __VISIONOS_1_1 = 10100 + +const __VISIONOS_1_2 = 10200 + +const __VISIONOS_1_3 = 10300 + +const __VISIONOS_26_0 = 260000 + +const __VISIONOS_26_1 = 260100 + +const __VISIONOS_26_2 = 260200 + +const __VISIONOS_26_3 = 260300 + +const __VISIONOS_26_4 = 260400 + +const __VISIONOS_2_0 = 20000 + +const __VISIONOS_2_1 = 20100 + +const __VISIONOS_2_2 = 20200 + +const __VISIONOS_2_3 = 20300 + +const __VISIONOS_2_4 = 20400 + +const __VISIONOS_2_5 = 20500 + +const __VISIONOS_2_6 = 20600 + +const __VISIONOS_3_0 = 30000 + +const __WATCHOS_10_0 = 100000 + +const __WATCHOS_10_1 = 100100 + +const __WATCHOS_10_2 = 100200 + +const __WATCHOS_10_3 = 100300 + +const __WATCHOS_10_4 = 100400 + +const __WATCHOS_10_5 = 100500 + +const __WATCHOS_10_6 = 100600 + +const __WATCHOS_10_7 = 100700 + +const __WATCHOS_11_0 = 110000 + +const __WATCHOS_11_1 = 110100 + +const __WATCHOS_11_2 = 110200 + +const __WATCHOS_11_3 = 110300 + +const __WATCHOS_11_4 = 110400 + +const __WATCHOS_11_5 = 110500 + +const __WATCHOS_11_6 = 110600 + +const __WATCHOS_12_0 = 120000 + +const __WATCHOS_1_0 = 10000 + +const __WATCHOS_26_0 = 260000 + +const __WATCHOS_26_1 = 260100 + +const __WATCHOS_26_2 = 260200 + +const __WATCHOS_26_3 = 260300 + +const __WATCHOS_26_4 = 260400 + +const __WATCHOS_2_0 = 20000 + +const __WATCHOS_2_1 = 20100 + +const __WATCHOS_2_2 = 20200 + +const __WATCHOS_3_0 = 30000 + +const __WATCHOS_3_1 = 30100 + +const __WATCHOS_3_1_1 = 30101 + +const __WATCHOS_3_2 = 30200 + +const __WATCHOS_4_0 = 40000 + +const __WATCHOS_4_1 = 40100 + +const __WATCHOS_4_2 = 40200 + +const __WATCHOS_4_3 = 40300 + +const __WATCHOS_5_0 = 50000 + +const __WATCHOS_5_1 = 50100 + +const __WATCHOS_5_2 = 50200 + +const __WATCHOS_5_3 = 50300 + +const __WATCHOS_6_0 = 60000 + +const __WATCHOS_6_1 = 60100 + +const __WATCHOS_6_2 = 60200 + +const __WATCHOS_7_0 = 70000 + +const __WATCHOS_7_1 = 70100 + +const __WATCHOS_7_2 = 70200 + +const __WATCHOS_7_3 = 70300 + +const __WATCHOS_7_4 = 70400 + +const __WATCHOS_7_5 = 70500 + +const __WATCHOS_7_6 = 70600 + +const __WATCHOS_8_0 = 80000 + +const __WATCHOS_8_1 = 80100 + +const __WATCHOS_8_3 = 80300 + +const __WATCHOS_8_4 = 80400 + +const __WATCHOS_8_5 = 80500 + +const __WATCHOS_8_6 = 80600 + +const __WATCHOS_8_7 = 80700 + +const __WATCHOS_8_8 = 80800 + +const __WATCHOS_9_0 = 90000 + +const __WATCHOS_9_1 = 90100 + +const __WATCHOS_9_2 = 90200 + +const __WATCHOS_9_3 = 90300 + +const __WATCHOS_9_4 = 90400 + +const __WATCHOS_9_5 = 90500 + +const __WATCHOS_9_6 = 90600 + +const __apple_build_version__ = 21000099 + +const __bool_true_false_are_defined = 1 + +var __ccgo_ts1 = "ATOMIC_INTRINSICS=1\x00COMPILER=clang-21.0.0\x00DEFAULT_AUTOVACUUM\x00DEFAULT_CACHE_SIZE=-2000\x00DEFAULT_FILE_FORMAT=4\x00DEFAULT_JOURNAL_SIZE_LIMIT=-1\x00DEFAULT_MEMSTATUS=0\x00DEFAULT_MMAP_SIZE=0\x00DEFAULT_PAGE_SIZE=4096\x00DEFAULT_PCACHE_INITSZ=20\x00DEFAULT_RECURSIVE_TRIGGERS\x00DEFAULT_SECTOR_SIZE=4096\x00DEFAULT_SYNCHRONOUS=2\x00DEFAULT_WAL_AUTOCHECKPOINT=1000\x00DEFAULT_WAL_SYNCHRONOUS=2\x00DEFAULT_WORKER_THREADS=0\x00DIRECT_OVERFLOW_READ\x00DISABLE_INTRINSIC\x00ENABLE_COLUMN_METADATA\x00ENABLE_DBPAGE_VTAB\x00ENABLE_DBSTAT_VTAB\x00ENABLE_FTS5\x00ENABLE_GEOPOLY\x00ENABLE_MATH_FUNCTIONS\x00ENABLE_MEMORY_MANAGEMENT\x00ENABLE_OFFSET_SQL_FUNC\x00ENABLE_PREUPDATE_HOOK\x00ENABLE_RBU\x00ENABLE_RTREE\x00ENABLE_SESSION\x00ENABLE_SNAPSHOT\x00ENABLE_STAT4\x00ENABLE_UNLOCK_NOTIFY\x00LIKE_DOESNT_MATCH_BLOBS\x00MALLOC_SOFT_LIMIT=1024\x00MAX_ATTACHED=10\x00MAX_COLUMN=2000\x00MAX_COMPOUND_SELECT=500\x00MAX_DEFAULT_PAGE_SIZE=8192\x00MAX_EXPR_DEPTH=1000\x00MAX_FUNCTION_ARG=1000\x00MAX_LENGTH=1000000000\x00MAX_LIKE_PATTERN_LENGTH=50000\x00MAX_MMAP_SIZE=0x7fff0000\x00MAX_PAGE_COUNT=0xfffffffe\x00MAX_PAGE_SIZE=65536\x00MAX_SQL_LENGTH=1000000000\x00MAX_TRIGGER_DEPTH=1000\x00MAX_VARIABLE_NUMBER=32766\x00MAX_VDBE_OP=250000000\x00MAX_WORKER_THREADS=8\x00MUTEX_NOOP\x00SOUNDEX\x00SYSTEM_MALLOC\x00TEMP_STORE=1\x00THREADSAFE=1\x00ANY\x00BLOB\x00INT\x00INTEGER\x00REAL\x00TEXT\x0020b:20e\x0020c:20e\x0020e\x0040f-21a-21d\x00now\x00subsec\x00subsecond\x00local time unavailable\x00auto\x00ceiling\x00floor\x00julianday\x00localtime\x00unixepoch\x00utc\x00weekday \x00start of \x00month\x00year\x00day\x0040f\x0050f\x0040f-20a-20d\x0050f-20a-20d\x00%02d\x00%2d\x00%06.3f\x00%04d-%02d-%02d\x00%04d\x00%03d\x00%.16g\x00PM\x00pm\x00AM\x00am\x00%02d:%02d\x00%.3f\x00%lld\x00%02d:%02d:%02d\x00%c%04d-%02d-%02d %02d:%02d:%06.3f\x00date\x00time\x00datetime\x00strftime\x00timediff\x00current_time\x00current_timestamp\x00current_date\x00failed to allocate %u bytes of memory\x00failed memory resize %u to %u bytes\x00out of memory\x00%\x00null\x00NaN\x00-Inf\x00\x00NULL\x00(NULL)\x00unistr('\x000123456789abcdef\x00.\x00(join-%u)\x00%u-ROW VALUES CLAUSE\x00(subquery-%u)\x00unrecognized token: \"%s\"\x00922337203685477580\x00+- \n\t0123456789\x000\x00API call with %s database connection pointer\x00unopened\x00invalid\x00Savepoint\x00AutoCommit\x00Transaction\x00Checkpoint\x00JournalMode\x00Vacuum\x00VFilter\x00VUpdate\x00Init\x00Goto\x00Gosub\x00InitCoroutine\x00Yield\x00MustBeInt\x00Jump\x00Once\x00If\x00IfNot\x00IsType\x00Not\x00IfNullRow\x00SeekLT\x00SeekLE\x00SeekGE\x00SeekGT\x00IfNotOpen\x00IfNoHope\x00NoConflict\x00NotFound\x00Found\x00SeekRowid\x00NotExists\x00Last\x00IfSizeBetween\x00SorterSort\x00Sort\x00Rewind\x00IfEmpty\x00SorterNext\x00Prev\x00Next\x00IdxLE\x00IdxGT\x00Or\x00And\x00IdxLT\x00IdxGE\x00IFindKey\x00RowSetRead\x00RowSetTest\x00Program\x00IsNull\x00NotNull\x00Ne\x00Eq\x00Gt\x00Le\x00Lt\x00Ge\x00ElseEq\x00FkIfZero\x00IfPos\x00IfNotZero\x00DecrJumpZero\x00IncrVacuum\x00VNext\x00Filter\x00PureFunc\x00Function\x00Return\x00EndCoroutine\x00HaltIfNull\x00Halt\x00Integer\x00Int64\x00String\x00BeginSubrtn\x00Null\x00SoftNull\x00Blob\x00Variable\x00Move\x00Copy\x00SCopy\x00IntCopy\x00FkCheck\x00ResultRow\x00CollSeq\x00AddImm\x00RealAffinity\x00Cast\x00Permutation\x00Compare\x00IsTrue\x00ZeroOrNull\x00Offset\x00Column\x00TypeCheck\x00Affinity\x00MakeRecord\x00Count\x00ReadCookie\x00SetCookie\x00BitAnd\x00BitOr\x00ShiftLeft\x00ShiftRight\x00Add\x00Subtract\x00Multiply\x00Divide\x00Remainder\x00Concat\x00ReopenIdx\x00OpenRead\x00BitNot\x00OpenWrite\x00OpenDup\x00String8\x00OpenAutoindex\x00OpenEphemeral\x00SorterOpen\x00SequenceTest\x00OpenPseudo\x00Close\x00ColumnsUsed\x00SeekScan\x00SeekHit\x00Sequence\x00NewRowid\x00Insert\x00RowCell\x00Delete\x00ResetCount\x00SorterCompare\x00SorterData\x00RowData\x00Rowid\x00NullRow\x00SeekEnd\x00IdxInsert\x00SorterInsert\x00IdxDelete\x00DeferredSeek\x00IdxRowid\x00FinishSeek\x00Destroy\x00Clear\x00ResetSorter\x00CreateBtree\x00SqlExec\x00ParseSchema\x00LoadAnalysis\x00DropTable\x00Real\x00DropIndex\x00DropTrigger\x00IntegrityCk\x00RowSetAdd\x00Param\x00FkCounter\x00MemMax\x00OffsetLimit\x00AggInverse\x00AggStep\x00AggStep1\x00AggValue\x00AggFinal\x00Expire\x00CursorLock\x00CursorUnlock\x00TableLock\x00VBegin\x00VCreate\x00VDestroy\x00VOpen\x00VCheck\x00VInitIn\x00VColumn\x00VRename\x00Pagecount\x00MaxPgcnt\x00ClrSubtype\x00GetSubtype\x00SetSubtype\x00FilterAdd\x00Trace\x00CursorHint\x00ReleaseReg\x00Noop\x00Explain\x00Abortable\x00open\x00close\x00access\x00getcwd\x00stat\x00fstat\x00ftruncate\x00fcntl\x00read\x00pread\x00pread64\x00write\x00pwrite\x00pwrite64\x00fchmod\x00fallocate\x00unlink\x00openDirectory\x00mkdir\x00rmdir\x00fchown\x00geteuid\x00mmap\x00munmap\x00mremap\x00getpagesize\x00readlink\x00lstat\x00ioctl\x00attempt to open \"%s\" as file descriptor %d\x00/dev/null\x00os_unix.c:%d: (%d) %s(%s) - %s\x00S\x00cannot fstat db file %s\x00file unlinked while open: %s\x00multiple links to file: %s\x00file renamed while open: %s\x00%s\x00full_fsync\x00%s-shm\x00readonly_shm\x00hfs\x00ufs\x00afpfs\x00smbfs\x00webdav\x00nfs\x00psow\x00unix-excl\x00%s.lock\x00/var/tmp\x00/usr/tmp\x00/tmp\x00SQLITE_TMPDIR\x00TMPDIR\x00%s/etilqs_%llx%c\x00modeof\x00msdos\x00exfat\x00SQLITE_FORCE_PROXY_LOCKING\x00:auto:\x00fsync\x00/dev/urandom\x00sqliteplocks\x00/\x00dummy\x00break\x00path error (len %d)\x00read error (len %d)\x00create failed (%d)\x00write failed (%d)\x00rename failed (%d)\x00broke stale lock on %s\n\x00failed to break stale lock on %s, %s\n\x00-conch\x00.lock\x00:auto: (not held)\x00unix\x00unix-none\x00unix-dotfile\x00unix-posix\x00unix-flock\x00unix-afp\x00unix-nfs\x00unix-proxy\x00memdb\x00memdb(%p,%lld)\x00PRAGMA \"%w\".page_count\x00BEGIN IMMEDIATE; COMMIT;\x00ATTACH x AS %Q\x00recovered %d pages from %s\x00-journal\x00-wal\x00nolock\x00immutable\x00PRAGMA table_list\x00recovered %d frames from WAL file %s\x00cannot limit WAL size: %s\x00:memory:\x00@ \x00\n\x00invalid page number %u\x002nd reference to page %u\x00Failed to read ptrmap key=%u\x00Bad ptr map entry key=%u expected=(%u,%u) got=(%u,%u)\x00failed to get page %u\x00freelist leaf count too big on page %u\x00size\x00overflow list length\x00%s is %u but should be %u\x00Tree %u page %u: \x00unable to get the page. error code=%d\x00btreeInitPage() returns error code %d\x00free space corruption\x00Tree %u page %u cell %u: \x00Tree %u page %u right child: \x00Offset %u out of range %u..%u\x00Extends off end of page\x00Rowid %lld out of order\x00Child page depth differs\x00Multiple uses for byte %u of page %u\x00Fragmentation of %u bytes reported as %u on page %u\x00Freelist: \x00max rootpage (%u) disagrees with header (%u)\x00incremental_vacuum enabled with a max rootpage of zero\x00Page %u: never used\x00Page %u: pointer map referenced\x00unknown database %s\x00destination database is in use\x00source and destination must be distinct\x00.0\x00%!.*g\x00-\x00%s%s\x00k(%d\x00BINARY\x00B\x00N.\x00,%s%s%s\x00)\x00?\x008\x0016LE\x0016BE\x00%.18s-%s\x00%s(%d)\x00%d\x00(blob)\x00vtab:%p\x00%c%u\x00]\x00program\x00subrtnsig:%d,%s\x00%.4c%s%.16c\x00MJ delete: %s\x00MJ collide: %s\x00-mj%06X9%02X\x00FOREIGN KEY constraint failed\x00a CHECK constraint\x00a generated column\x00an index\x00non-deterministic use of %s() in %s\x00API called with finalized prepared statement\x00API called with NULL prepared statement\x00string or blob too big\x00addr\x00opcode\x00p1\x00p2\x00p3\x00p4\x00p5\x00comment\x00id\x00parent\x00notused\x00detail\x00bind on a busy prepared statement: [%s]\x00-- \x00%!.15g\x00'%.*q'\x00zeroblob(%d)\x00x'\x00%02x\x00'\x00/* %s */ \x00/* unknown trigger */ \x00statement aborts at %d: %s; [%s%s]\x00NOT NULL\x00UNIQUE\x00CHECK\x00FOREIGN KEY\x00%s constraint failed\x00%z: %s\x00cannot store %s value in %s column %s.%s\x00cannot open savepoint - SQL statements in progress\x00no such savepoint: %s\x00cannot release savepoint - SQL statements in progress\x00cannot commit transaction - SQL statements in progress\x00cannot start a transaction within a transaction\x00cannot rollback - no transaction is active\x00cannot commit - no transaction is active\x00database schema has changed\x00index corruption\x00sqlite_master\x00SELECT*FROM\"%w\".%s WHERE %s ORDER BY rowid\x00too many levels of trigger recursion\x00into\x00out of\x00cannot change %s wal mode from within a transaction\x00database table is locked: %s\x00ValueList\x00-- %s\x00real\x00integer\x00cannot open value of type %s\x00no such rowid: %lld\x00cannot open virtual table: %s\x00cannot open table without rowid: %s\x00cannot open table with generated columns: %s\x00cannot open view: %s\x00no such column: \"%s\"\x00foreign key\x00indexed\x00cannot open %s column for writing\x00sqlite_\x00sqlite_temp_master\x00sqlite_temp_schema\x00sqlite_schema\x00main\x00*\x00new\x00old\x00excluded\x00misuse of aliased aggregate %s\x00misuse of aliased window function %s\x00row value misused\x00double-quoted string literal: \"%w\"\x00coalesce\x00no such column\x00ambiguous column name\x00%s: %s.%s.%s\x00%s: %s.%s\x00%s: \"%s\" - should this be a string literal in single-quotes?\x00%s: %s\x00partial index WHERE clauses\x00index expressions\x00CHECK constraints\x00generated columns\x00%s prohibited in %s\x00the \".\" operator\x00second argument to %#T() must be a constant between 0.0 and 1.0\x00not authorized to use function: %#T\x00non-deterministic functions\x00%#T() may not be used as a window function\x00window\x00aggregate\x00misuse of %s function %#T()\x00no such function: %#T\x00wrong number of arguments to function %#T()\x00FILTER may not be used with non-aggregate %#T()\x00subqueries\x00parameters\x00%r %s BY term out of range - should be between 1 and %d\x00too many terms in ORDER BY clause\x00ORDER\x00%r ORDER BY term does not match any column in the result set\x00too many terms in %s BY clause\x00HAVING clause on a non-aggregate query\x00GROUP\x00aggregate functions are not allowed in the GROUP BY clause\x00Expression tree is too large (maximum depth %d)\x00s\x00IN(...) element has %d term%s - expected %d\x00too many arguments on function %T\x00ORDER BY may not be used with non-aggregate %#T()\x00unsafe use of %#T()\x00variable number must be between ?1 and ?%d\x00too many SQL variables\x00%d columns assigned %d values\x00too many columns in %s\x00true\x00false\x00_ROWID_\x00ROWID\x00OID\x00USING ROWID SEARCH ON TABLE %s FOR IN-OPERATOR\x00USING INDEX %s FOR IN-OPERATOR\x00sub-select returns %d columns - expected %d\x00REUSE LIST SUBQUERY %d\x00CORRELATED \x00%sLIST SUBQUERY %d\x00REUSE SUBQUERY %d\x00%sSCALAR SUBQUERY %d\x000x\x00hex literal too big: %s%#T\x00generated column loop on \"%s\"\x00blob\x00text\x00numeric\x00flexnum\x00none\x00misuse of aggregate: %#T()\x00unknown function: %#T()\x00RAISE() may only be used within a trigger-program\x00more than %d aggregate terms\x00table %s may not be altered\x00SELECT 1 FROM \"%w\".sqlite_master WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND sql NOT LIKE 'create virtual%%' AND sqlite_rename_test(%Q, sql, type, name, %d, %Q, %d)=NULL \x00SELECT 1 FROM temp.sqlite_master WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND sql NOT LIKE 'create virtual%%' AND sqlite_rename_test(%Q, sql, type, name, 1, %Q, %d)=NULL \x00UPDATE \"%w\".sqlite_master SET sql = sqlite_rename_quotefix(%Q, sql)WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND sql NOT LIKE 'create virtual%%'\x00UPDATE temp.sqlite_master SET sql = sqlite_rename_quotefix('temp', sql)WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND sql NOT LIKE 'create virtual%%'\x00there is already another table or index with this name: %s\x00table\x00view %s may not be altered\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, %d) WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)AND name NOT LIKE 'sqliteX_%%' ESCAPE 'X'\x00UPDATE %Q.sqlite_master SET tbl_name = %Q, name = CASE WHEN type='table' THEN %Q WHEN name LIKE 'sqliteX_autoindex%%' ESCAPE 'X' AND type='index' THEN 'sqlite_autoindex_' || %Q || substr(name,%d+18) ELSE name END WHERE tbl_name=%Q COLLATE nocase AND (type='table' OR type='index' OR type='trigger');\x00sqlite_sequence\x00UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q\x00UPDATE sqlite_temp_schema SET sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), tbl_name = CASE WHEN tbl_name=%Q COLLATE nocase AND sqlite_rename_test(%Q, sql, type, name, 1, 'after rename', 0) THEN %Q ELSE tbl_name END WHERE type IN ('view', 'trigger')\x00after rename\x00SELECT raise(ABORT,%Q) FROM \"%w\".\"%w\"\x00Cannot add a PRIMARY KEY column\x00Cannot add a UNIQUE column\x00Cannot add a REFERENCES column with non-NULL default value\x00Cannot add a NOT NULL column with default value NULL\x00Cannot add a column with non-constant default\x00cannot add a STORED column\x00UPDATE \"%w\".sqlite_master SET sql = printf('%%.%ds, ',sql) || %Q || substr(sql,1+length(printf('%%.%ds',sql))) WHERE type = 'table' AND name = %Q\x00SELECT CASE WHEN quick_check GLOB 'CHECK*' THEN raise(ABORT,'CHECK constraint failed') WHEN quick_check GLOB 'non-* value in*' THEN raise(ABORT,'type mismatch on DEFAULT') ELSE raise(ABORT,'NOT NULL constraint failed') END FROM pragma_quick_check(%Q,%Q) WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*' OR quick_check GLOB 'non-* value in*'\x00virtual tables may not be altered\x00Cannot add a column to a view\x00sqlite_altertab_%s\x00view\x00virtual table\x00rename columns of\x00drop column from\x00edit constraints of\x00cannot %s %s \"%s\"\x00no such column: \"%T\"\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND (type != 'index' OR tbl_name = %Q)\x00UPDATE temp.sqlite_master SET sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, 1) WHERE type IN ('trigger', 'view')\x00 \x00error in %s %s%s%s: %s\x00CREATE \x00\"%w\" \x00%Q%s\x00%.*s%s\x00PRIMARY KEY\x00cannot drop %s column: \"%s\"\x00cannot drop column \"%s\": no other columns exist\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_drop_column(%d, sql, %d) WHERE (type=='table' AND tbl_name=%Q COLLATE nocase)\x00after drop column\x00constraint may not be dropped: %s\x00no such constraint: %s\x00%.*s%s%s\x00%.*s, %s%s\x00%.*s %s%s\x00no such column: %s\x00%Q\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_drop_constraint(sql, %s) WHERE type='table' AND tbl_name=%Q COLLATE nocase\x00%.*s\x00SELECT sqlite_fail('constraint failed', %d) FROM %Q.%Q AS x WHERE x.%.*s IS NULL\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_add_constraint(sqlite_drop_constraint(sql, %d), %.*Q, %d) WHERE type='table' AND tbl_name=%Q COLLATE nocase\x00SELECT sqlite_fail('constraint %q already exists', %d) FROM \"%w\".sqlite_master WHERE type='table' AND tbl_name=%Q COLLATE nocase AND sqlite_find_constraint(sql, %Q)\x00SELECT sqlite_fail('constraint failed', %d) FROM %Q.%Q WHERE (%.*s) IS NOT TRUE\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_add_constraint(sql, %.*Q, -1) WHERE type='table' AND tbl_name=%Q COLLATE nocase\x00sqlite_rename_column\x00sqlite_rename_table\x00sqlite_rename_test\x00sqlite_drop_column\x00sqlite_rename_quotefix\x00sqlite_drop_constraint\x00sqlite_fail\x00sqlite_add_constraint\x00sqlite_find_constraint\x00sqlite_stat1\x00tbl,idx,stat\x00sqlite_stat4\x00tbl,idx,neq,nlt,ndlt,sample\x00sqlite_stat3\x00CREATE TABLE %Q.%s(%s)\x00DELETE FROM %Q.%s WHERE %s=%Q\x00DELETE FROM %Q.%s\x00stat_init\x00stat_push\x00%llu\x00 %llu\x00%llu \x00stat_get\x00sqlite\\_%\x00BBB\x00idx\x00tbl\x00unordered*\x00sz=[0-9]*\x00noskipscan*\x00SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx COLLATE nocase\x00SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4\x00SELECT tbl,idx,stat FROM %Q.sqlite_stat1\x00x\x00\x00too many attached databases - max %d\x00database %s is already in use\x00database is already attached\x00attached databases must use the same text encoding as main database\x00unable to open database: %s\x00no such database: %s\x00cannot detach database %s\x00database %s is locked\x00sqlite_detach\x00sqlite_attach\x00%s cannot use variables\x00%s %T cannot reference objects in database %s\x00authorizer malfunction\x00%s.%s\x00%s.%z\x00access to %z is prohibited\x00not authorized\x00pragma_\x00json\x00no such view\x00no such table\x00corrupt database\x00unknown database %T\x00object name reserved for internal use: %s\x00temporary table name must be unqualified\x00%s %T already exists\x00there is already an index named %s\x00cannot use RETURNING in a trigger\x00sqlite_returning_%p\x00too many columns on %s\x00always\x00generated\x00duplicate column name: %s\x00default value of column [%s] is not constant\x00cannot use DEFAULT on a generated column\x00generated columns cannot be part of the PRIMARY KEY\x00table \"%s\" has more than one primary key\x00AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY\x00virtual tables cannot use computed columns\x00virtual\x00stored\x00error in generated column \"%s\"\x00,\x00\n \x00,\n \x00\n)\x00CREATE TABLE \x00 TEXT\x00 NUM\x00 INT\x00 REAL\x00unknown datatype for %s.%s: \"%s\"\x00missing datatype for %s.%s\x00AUTOINCREMENT not allowed on WITHOUT ROWID tables\x00PRIMARY KEY missing on table %s\x00must have at least one non-generated column\x00TABLE\x00VIEW\x00CREATE %s %.*s\x00UPDATE %Q.sqlite_master SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q WHERE rowid=#%d\x00CREATE TABLE %Q.sqlite_sequence(name,seq)\x00tbl_name='%q' AND type!='trigger'\x00SELECT*FROM\"%w\".\"%w\"\x00parameters are not allowed in views\x00view %s is circularly defined\x00corrupt schema\x00UPDATE %Q.sqlite_master SET rootpage=%d WHERE #%d AND rootpage=#%d\x00sqlite_stat%d\x00DELETE FROM %Q.sqlite_sequence WHERE name=%Q\x00DELETE FROM %Q.sqlite_master WHERE tbl_name=%Q and type!='trigger'\x00table %s may not be dropped\x00use DROP TABLE to delete table %s\x00use DROP VIEW to delete view %s\x00foreign key on %s should reference only one column of table %T\x00number of columns in foreign key does not match the number of columns in the referenced table\x00unknown column \"%s\" in foreign key definition\x00FIRST\x00LAST\x00unsupported use of NULLS %s\x00index\x00cannot create a TEMP index on non-TEMP table \"%s\"\x00table %s may not be indexed\x00views may not be indexed\x00virtual tables may not be indexed\x00there is already a table named %s\x00index %s already exists\x00sqlite_autoindex_%s_%d\x00expressions prohibited in PRIMARY KEY and UNIQUE constraints\x00conflicting ON CONFLICT clauses specified\x00invalid rootpage\x00 UNIQUE\x00CREATE%s INDEX %.*s\x00INSERT INTO %Q.sqlite_master VALUES('index',%Q,%Q,#%d,%Q);\x00name='%q' AND type='index'\x00no such index: %S\x00index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped\x00DELETE FROM %Q.sqlite_master WHERE name=%Q AND type='index'\x00too many FROM clause terms, max: %d\x00ON\x00USING\x00a JOIN clause is required before %s\x00BEGIN\x00ROLLBACK\x00COMMIT\x00RELEASE\x00unable to open a temporary database file for storing temporary tables\x00index '%q'\x00, \x00%s.rowid\x00expressions\x00unable to identify the object to be reindexed\x00duplicate WITH table name: %s\x00no such collation sequence: %s\x00unsafe use of virtual table \"%s\"\x00table %s may not be modified\x00cannot modify %s because it is a view\x00rows deleted\x00integer overflow\x00%!.*f\x00LIKE or GLOB pattern too complex\x00ESCAPE expression must be a single character\x00%!0.17g\x00%#Q\x00invalid Unicode escape\x00?000\x00MATCH\x00like\x00implies_nonnull_row\x00expr_compare\x00expr_implies_expr\x00affinity\x00soundex\x00load_extension\x00sqlite_compileoption_used\x00sqlite_compileoption_get\x00unlikely\x00likelihood\x00likely\x00sqlite_offset\x00ltrim\x00rtrim\x00trim\x00min\x00max\x00typeof\x00subtype\x00length\x00octet_length\x00instr\x00printf\x00format\x00unicode\x00char\x00abs\x00round\x00upper\x00lower\x00hex\x00unhex\x00concat\x00concat_ws\x00ifnull\x00random\x00randomblob\x00nullif\x00sqlite_version\x00sqlite_source_id\x00sqlite_log\x00unistr\x00quote\x00unistr_quote\x00last_insert_rowid\x00changes\x00total_changes\x00replace\x00zeroblob\x00substr\x00substring\x00sum\x00total\x00avg\x00count\x00group_concat\x00string_agg\x00glob\x00ceil\x00trunc\x00ln\x00log\x00log10\x00log2\x00exp\x00pow\x00power\x00mod\x00acos\x00asin\x00atan\x00atan2\x00cos\x00sin\x00tan\x00cosh\x00sinh\x00tanh\x00acosh\x00asinh\x00atanh\x00sqrt\x00radians\x00degrees\x00pi\x00sign\x00iif\x00if\x00foreign key mismatch - \"%w\" referencing \"%w\"\x00cannot INSERT into generated column \"%s\"\x00table %S has no column named %s\x00SCAN %S\x00table %S has %d columns but %d values were supplied\x00%d values for %d columns\x00UPSERT not implemented for virtual table \"%s\"\x00cannot UPSERT a view\x00rows inserted\x00dylib\x00sqlite3_extension_init\x00sqlite3_\x00lib\x00_init\x00no entry point [%s] in shared library [%s]\x00error during initialization: %s\x00unable to open shared library [%.*s]\x00automatic extension loading failed: %s\x00seq\x00from\x00to\x00on_update\x00on_delete\x00match\x00cid\x00name\x00type\x00notnull\x00dflt_value\x00pk\x00hidden\x00builtin\x00enc\x00narg\x00flags\x00schema\x00ncol\x00wr\x00strict\x00seqno\x00desc\x00coll\x00key\x00unique\x00origin\x00partial\x00wdth\x00hght\x00flgs\x00rowid\x00fkid\x00busy\x00checkpointed\x00file\x00database\x00status\x00cache_size\x00timeout\x00analysis_limit\x00application_id\x00auto_vacuum\x00automatic_index\x00busy_timeout\x00cache_spill\x00case_sensitive_like\x00cell_size_check\x00checkpoint_fullfsync\x00collation_list\x00compile_options\x00count_changes\x00data_version\x00database_list\x00default_cache_size\x00defer_foreign_keys\x00empty_result_callbacks\x00encoding\x00foreign_key_check\x00foreign_key_list\x00foreign_keys\x00freelist_count\x00full_column_names\x00fullfsync\x00function_list\x00hard_heap_limit\x00ignore_check_constraints\x00incremental_vacuum\x00index_info\x00index_list\x00index_xinfo\x00integrity_check\x00journal_mode\x00journal_size_limit\x00legacy_alter_table\x00lock_proxy_file\x00locking_mode\x00max_page_count\x00mmap_size\x00module_list\x00optimize\x00page_count\x00page_size\x00pragma_list\x00query_only\x00quick_check\x00read_uncommitted\x00recursive_triggers\x00reverse_unordered_selects\x00schema_version\x00secure_delete\x00short_column_names\x00shrink_memory\x00soft_heap_limit\x00synchronous\x00table_info\x00table_list\x00table_xinfo\x00temp_store\x00temp_store_directory\x00threads\x00trusted_schema\x00user_version\x00wal_autocheckpoint\x00wal_checkpoint\x00writable_schema\x00exclusive\x00normal\x00full\x00incremental\x00memory\x00temporary storage cannot be changed from within a transaction\x00SET NULL\x00SET DEFAULT\x00CASCADE\x00RESTRICT\x00NO ACTION\x00delete\x00persist\x00off\x00truncate\x00wal\x00utf8\x00utf16le\x00utf16be\x00w\x00a\x00sissii\x00-%T\x00fast\x00not a writable directory\x00failed to set lock proxy file\x00Safety level may not be changed inside a transaction\x00reset\x00issisii\x00issisi\x00SELECT*FROM\"%w\"\x00shadow\x00sssiii\x00iisX\x00isiX\x00c\x00u\x00isisi\x00iss\x00is\x00iissssss\x00NONE\x00siX\x00*** in database %s ***\n\x00wrong # of entries in index \x00row not in PRIMARY KEY order for %s\x00NULL value in %s.%s\x00non-%s value in %s.%s\x00NUMERIC value in %s.%s\x00C\x00TEXT value in %s.%s\x00CHECK constraint failed in %s\x00index %s stores an imprecise floating-point value for row \x00row \x00 missing from index \x00rowid not at end-of-record for row \x00 of index \x00 values differ from index \x00non-unique entry in index \x00ok\x00UTF8\x00UTF-8\x00UTF-16le\x00UTF-16be\x00UTF16le\x00UTF16be\x00UTF-16\x00UTF16\x00unsupported encoding: %s\x00restart\x00noop\x00ANALYZE \"%w\".\"%w\"\x00CREATE TABLE x\x00%c\"%s\"\x00(\"%s\"\x00,arg HIDDEN\x00,schema HIDDEN\x00PRAGMA \x00%Q.\x00=%Q\x00rename\x00drop column\x00add column\x00drop constraint\x00error in %s %s after %s: %s\x00malformed database schema (%s)\x00%z - %s\x00orphan index\x001\x00CREATE TABLE x(type text,name text,tbl_name text,rootpage int,sql text)\x00unsupported file format\x00SELECT*FROM\"%w\".%s ORDER BY rowid\x00database schema is locked: %s\x00statement too long\x00unknown join type: %T%s%T%s%T\x00a NATURAL join may not have an ON or USING clause\x00cannot join using column %s - column not present in both tables\x00ambiguous reference to %s in USING()\x00CREATE BLOOM FILTER\x00UNION ALL\x00INTERSECT\x00EXCEPT\x00UNION\x00USE TEMP B-TREE FOR %s\x00LAST TERM OF \x00USE TEMP B-TREE FOR %sORDER BY\x00USE TEMP B-TREE FOR LAST %d TERMS OF ORDER BY\x00column%d\x00%.*z:%u\x00NUM\x00cannot use window functions in recursive queries\x00recursive aggregate queries not supported\x00SETUP\x00RECURSIVE STEP\x00SCAN %d CONSTANT ROW%s\x00COMPOUND QUERY\x00LEFT-MOST SUBQUERY\x00all VALUES must have the same number of terms\x00SELECTs to the left and right of %s do not have the same number of result columns\x00MERGE (%s)\x00LEFT\x00RIGHT\x00no such index: %s\x00'%s' is not a function\x00no such index: \"%s\"\x00multiple references to recursive table: %s\x00circular reference: %s\x00table %s has %d values for %d columns\x00multiple recursive references: %s\x00recursive reference in a subquery: %s\x00%!S\x00too many references to \"%s\": max 65535\x00access to view \"%s\" prohibited\x00..%s\x00%s.%s.%s\x00no such table: %s\x00no tables specified\x00too many columns in result set\x00DISTINCT aggregates must have exactly one argument\x00USE TEMP B-TREE FOR %s(DISTINCT)\x00USE TEMP B-TREE FOR %s(ORDER BY)\x00 USING COVERING INDEX \x00SCAN %s%s%s\x00table-function argument\x00ON clause\x00%s references tables to its right\x00target object/alias may not appear in FROM clause: %s\x00expected %d columns for '%s' but got %d\x00CO-ROUTINE %!S\x00MATERIALIZE %!S\x00DISTINCT\x00GROUP BY\x00sqlite3_get_table() called with two or more incompatible queries\x00temporary trigger may not have qualified name\x00trigger\x00cannot create triggers on virtual tables\x00cannot create triggers on shadow tables\x00trigger %T already exists\x00cannot create trigger on system table\x00BEFORE\x00AFTER\x00cannot create %s trigger on view: %S\x00cannot create INSTEAD OF trigger on table: %S\x00trigger \"%s\" may not write to shadow table \"%s\"\x00INSERT INTO %Q.sqlite_master VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')\x00type='trigger' AND name='%q'\x00qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers\x00no such trigger: %S\x00DELETE FROM %Q.sqlite_master WHERE name=%Q AND type='trigger'\x00DELETE\x00UPDATE\x00%s RETURNING is not available on virtual tables\x00RETURNING may not use \"TABLE.*\" wildcards\x00-- TRIGGER %s\x00cannot UPDATE generated column \"%s\"\x00rows updated\x00%r \x00%sON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint\x00CRE\x00INS\x00cannot VACUUM from within a transaction\x00cannot VACUUM - SQL statements in progress\x00non-text filename\x00vacuum_%016llx\x00ATTACH %Q AS %s\x00output file already exists\x00reserve\x00SELECT sql FROM \"%w\".sqlite_schema WHERE type='table'AND name<>'sqlite_sequence' AND coalesce(rootpage,1)>0\x00SELECT sql FROM \"%w\".sqlite_schema WHERE type='index'\x00SELECT'INSERT INTO %s.'||quote(name)||' SELECT*FROM\"%w\".'||quote(name)FROM %s.sqlite_schema WHERE type='table'AND coalesce(rootpage,1)>0\x00INSERT INTO %s.sqlite_schema SELECT*FROM \"%w\".sqlite_schema WHERE type IN('view','trigger') OR(type='table'AND rootpage=0)\x00CREATE VIRTUAL TABLE %T\x00UPDATE %Q.sqlite_master SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q WHERE rowid=#%d\x00name=%Q AND sql=%Q\x00vtable constructor called recursively: %s\x00vtable constructor failed: %s\x00vtable constructor did not declare schema: %s\x00no such module: %s\x00syntax error\x00\x00 AND \x00(\x00 (\x00%s=?\x00ANY(%s)\x00>\x00<\x00SEARCH\x00SCAN\x00 EXISTS\x00%s %S%s\x00AUTOMATIC PARTIAL COVERING INDEX\x00AUTOMATIC COVERING INDEX\x00COVERING INDEX %s\x00INDEX %s\x00 USING \x00 USING INTEGER PRIMARY KEY (%s\x00>? AND %s\x00%c?)\x00 VIRTUAL TABLE INDEX \x000x%x:%s\x00%d:%s\x00 LEFT-JOIN\x00BLOOM FILTER ON %S (\x00rowid=?\x00MULTI-INDEX OR\x00INDEX %d\x00RIGHT-JOIN %s\x00regexp\x00NOCASE\x00too many arguments on %s() - max %d\x00automatic index on %s(%s)\x00auto-index\x00%s.xBestIndex malfunction\x00abbreviated query algorithm search\x00no query solution\x00at most %d tables in a join\x00SCAN CONSTANT ROW\x00internal query planner error\x00second argument to nth_value must be a positive integer\x00argument of ntile must be a positive integer\x00no such window: %s\x00RANGE with offset PRECEDING/FOLLOWING requires one ORDER BY expression\x00FILTER clause may only be used with aggregate window functions\x00misuse of aggregate: %s()\x00unsupported frame specification\x00PARTITION clause\x00ORDER BY clause\x00frame specification\x00cannot override %s of window: %s\x00DISTINCT is not supported for window functions\x00frame starting offset must be a non-negative integer\x00frame ending offset must be a non-negative integer\x00frame starting offset must be a non-negative number\x00frame ending offset must be a non-negative number\x00near \"%T\": syntax error\x00ORDER BY\x00LIMIT\x00%s clause should come after %s not before\x00too many terms in compound SELECT\x00syntax error after column name \"%.*s\"\x00Recursion limit\x00unknown table option: %.*s\x00set list\x00the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers\x00the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers\x00incomplete input\x00unrecognized token: \"%T\"\x00%s in \"%s\"\x00create\x00temp\x00temporary\x00end\x00explain\x00unable to close due to unfinalized statements or unfinished backups\x00not an error\x00SQL logic error\x00access permission denied\x00query aborted\x00database is locked\x00database table is locked\x00attempt to write a readonly database\x00interrupted\x00disk I/O error\x00database disk image is malformed\x00unknown operation\x00database or disk is full\x00unable to open database file\x00locking protocol\x00constraint failed\x00datatype mismatch\x00bad parameter or other API misuse\x00authorization denied\x00column index out of range\x00file is not a database\x00notification message\x00warning message\x00unknown error\x00abort due to ROLLBACK\x00another row available\x00no more rows available\x00unable to delete/modify user-function due to active statements\x00unable to use function %s in the requested context\x00unknown database: %s\x00unable to delete/modify collation sequence due to active statements\x00file:\x00localhost\x00invalid uri authority: %.*s\x00vfs\x00cache\x00shared\x00private\x00mode\x00ro\x00rw\x00rwc\x00no such %s mode: %s\x00%s mode not allowed: %s\x00no such vfs: %s\x00RTRIM\x00\x00\x00\x00%s at line %d of [%.10s]\x00database corruption\x00misuse\x00cannot open file\x00no such table column: %s.%s\x00SQLITE_\x00database is deadlocked\x00array\x00object\x00JSON nested too deep\x00JSON cannot hold BLOB values\x00malformed JSON\x00inf\x009.0e999\x00infinity\x00QNaN\x00SNaN\x00json_%s() needs an odd number of arguments\x00\"\\/bfnrt\x00-9e999\x009e999\x00inity\x00\\\"\x00\\u000b\x00\\u00\x00\\u0000\x00,\n\x00: \x00*]\x00not an array element: %Q\x00JSON path too deep\x00bad JSON path: %Q\x00@\x00[\x00#\x00.\"\x00\"\x00json_object() requires an even number of arguments\x00json_object() labels must be TEXT\x00insert\x00set\x00array_insert\x00 \x00FLAGS parameter to json_valid() must be between 1 and 15\x00[]\x00}\x00{}\x00CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,json HIDDEN,root HIDDEN)\x00[%lld]\x00.\"%.*s\"\x00.%.*s\x00$\x00jsonb\x00json_array\x00jsonb_array\x00json_array_insert\x00jsonb_array_insert\x00json_array_length\x00json_error_position\x00json_extract\x00jsonb_extract\x00->\x00->>\x00json_insert\x00jsonb_insert\x00json_object\x00jsonb_object\x00json_patch\x00jsonb_patch\x00json_pretty\x00json_quote\x00json_remove\x00jsonb_remove\x00json_replace\x00jsonb_replace\x00json_set\x00jsonb_set\x00json_type\x00json_valid\x00json_group_array\x00jsonb_group_array\x00json_group_object\x00jsonb_group_object\x00json_each\x00json_tree\x00jsonb_each\x00jsonb_tree\x00data\x00DROP TABLE '%q'.'%q_node';DROP TABLE '%q'.'%q_rowid';DROP TABLE '%q'.'%q_parent';\x00RtreeMatchArg\x00SELECT * FROM %Q.%Q\x00UNIQUE constraint failed: %s.%s\x00rtree constraint failed: %s.(%s<=%s)\x00ALTER TABLE %Q.'%q_node' RENAME TO \"%w_node\";ALTER TABLE %Q.'%q_parent' RENAME TO \"%w_parent\";ALTER TABLE %Q.'%q_rowid' RENAME TO \"%w_rowid\";\x00SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'\x00node\x00INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_node' WHERE nodeno = ?1\x00SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = ?1\x00INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_rowid' WHERE rowid = ?1\x00SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = ?1\x00INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_parent' WHERE nodeno = ?1\x00CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY,nodeno\x00,a%d\x00);CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY,data);\x00CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,parentnode);\x00INSERT INTO \"%w\".\"%w_node\"VALUES(1,zeroblob(%d))\x00INSERT INTO\"%w\".\"%w_rowid\"(rowid,nodeno)VALUES(?1,?2)ON CONFLICT(rowid)DO UPDATE SET nodeno=excluded.nodeno\x00SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1\x00UPDATE \"%w\".\"%w_rowid\"SET \x00a%d=coalesce(?%d,a%d)\x00a%d=?%d\x00 WHERE rowid=?1\x00PRAGMA %Q.page_size\x00SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1\x00undersize RTree blobs in \"%q_node\"\x00Wrong number of columns for an rtree table\x00Too few columns for an rtree table\x00Too many columns for an rtree table\x00Auxiliary rtree columns must be last\x00_node\x00CREATE TABLE x(%.*s INT\x00,%.*s\x00,%.*s REAL\x00,%.*s INT\x00);\x00{%lld\x00 %g\x00Invalid argument to rtreedepth()\x00%z%s%z\x00SELECT data FROM %Q.'%q_node' WHERE nodeno=?\x00Node %lld missing from database\x00SELECT parentnode FROM %Q.'%q_parent' WHERE nodeno=?1\x00SELECT nodeno FROM %Q.'%q_rowid' WHERE rowid=?1\x00%_rowid\x00%_parent\x00Mapping (%lld -> %lld) missing from %s table\x00Found (%lld -> %lld) in %s table, expected (%lld -> %lld)\x00Dimension %d of cell %d on node %lld is corrupt\x00Dimension %d of cell %d on node %lld is corrupt relative to parent\x00Node %lld is too small (%d bytes)\x00Rtree depth out of range (%d)\x00Node %lld is too small for cell count of %d (%d bytes)\x00SELECT count(*) FROM %Q.'%q%s'\x00Wrong number of entries in %%%s table - expected %lld, actual %lld\x00SELECT * FROM %Q.'%q_rowid'\x00Schema corrupt or not an rtree\x00_rowid\x00_parent\x00In RTree %s.%s:\n%z\x00wrong number of arguments to function rtreecheck()\x00[%!g,%!g],\x00[%!g,%!g]]\x00\x00Too many columns for a geopoly table\x00CREATE TABLE x(_shape\x00,%s\x00rtree\x00fullscan\x00_shape does not contain a valid polygon\x00geopoly_overlap\x00geopoly_within\x00geopoly_area\x00geopoly_blob\x00geopoly_json\x00geopoly_svg\x00geopoly_contains_point\x00geopoly_debug\x00geopoly_bbox\x00geopoly_xform\x00geopoly_regular\x00geopoly_ccw\x00geopoly_group_bbox\x00geopoly\x00rtreenode\x00rtreedepth\x00rtreecheck\x00rtree_i32\x00corrupt fossil delta\x00DROP TRIGGER IF EXISTS temp.rbu_insert_tr;DROP TRIGGER IF EXISTS temp.rbu_update1_tr;DROP TRIGGER IF EXISTS temp.rbu_update2_tr;DROP TRIGGER IF EXISTS temp.rbu_delete_tr;\x00AND rootpage!=0 AND rootpage IS NOT NULL\x00SELECT rbu_target_name(name, type='view') AS target, name FROM sqlite_schema WHERE type IN ('table', 'view') AND target IS NOT NULL %s ORDER BY name\x00SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' FROM main.sqlite_schema WHERE type='index' AND tbl_name = ?\x00SELECT (sql COLLATE nocase BETWEEN 'CREATE VIRTUAL' AND 'CREATE VIRTUAM'), rootpage FROM sqlite_schema WHERE name=%Q\x00PRAGMA index_list=%Q\x00SELECT rootpage FROM sqlite_schema WHERE name = %Q\x00PRAGMA table_info=%Q\x00PRAGMA main.index_list = %Q\x00PRAGMA main.index_xinfo = %Q\x00SELECT * FROM '%q'\x00rbu_\x00rbu_rowid\x00may not have\x00requires\x00table %q %s rbu_rowid column\x00PRAGMA table_info(%Q)\x00column missing from %q: %s\x00%z%s\"%w\"\x00%z%s%s\"%w\"%s\x00SELECT max(_rowid_) FROM \"%s%w\"\x00 WHERE _rowid_ > %lld \x00 DESC\x00quote(\x00||','||\x00SELECT %s FROM \"%s%w\" ORDER BY %s LIMIT 1\x00 WHERE (%s) > (%s) \x00_rowid_\x00%z%s \"%w\" COLLATE %Q\x00%z%s \"rbu_imp_%d%w\" COLLATE %Q DESC\x00%z%s quote(\"rbu_imp_%d%w\")\x00SELECT %s FROM \"rbu_imp_%w\" ORDER BY %s LIMIT 1\x00%z%s%s\x00(%s) > (%s)\x00%z%s(%.*s) COLLATE %Q\x00%z%s\"%w\" COLLATE %Q\x00%z%s\"rbu_imp_%d%w\"%s\x00%z%s\"rbu_imp_%d%w\" %s COLLATE %Q\x00%z%s\"rbu_imp_%d%w\" IS ?\x00%z%s%s.\"%w\"\x00%z%sNULL\x00%z, %s._rowid_\x00_rowid_ = ?%d\x00%z%sc%d=?%d\x00_rowid_ = (SELECT id FROM rbu_imposter2 WHERE %z)\x00%z%s\"%w\"=?%d\x00invalid rbu_control value\x00%z%s\"%w\"=rbu_delta(\"%w\", ?%d)\x00%z%s\"%w\"=rbu_fossil_delta(\"%w\", ?%d)\x00PRIMARY KEY(\x00%z%s\"%w\"%s\x00%z)\x00SELECT name FROM sqlite_schema WHERE rootpage = ?\x00%z%sc%d %s COLLATE %Q\x00%z%sc%d%s\x00%z, id INTEGER\x00CREATE TABLE rbu_imposter2(%z, PRIMARY KEY(%z)) WITHOUT ROWID\x00PRIMARY KEY \x00 NOT NULL\x00%z%s\"%w\" %s %sCOLLATE %Q%s\x00%z, %z\x00 WITHOUT ROWID\x00CREATE TABLE \"rbu_imp_%w\"(%z)%s\x00INSERT INTO %s.'rbu_tmp_%q'(rbu_control,%s%s) VALUES(%z)\x00SELECT trim(sql) FROM sqlite_schema WHERE type='index' AND name=?\x00 LIMIT -1 OFFSET %d\x00CREATE TABLE \"rbu_imp_%w\"( %s, PRIMARY KEY( %s ) ) WITHOUT ROWID\x00INSERT INTO \"rbu_imp_%w\" VALUES(%s)\x00DELETE FROM \"rbu_imp_%w\" WHERE %s\x00AND\x00WHERE\x00SELECT %s, 0 AS rbu_control FROM '%q' %s %s %s ORDER BY %s%s\x00SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' %s ORDER BY %s%s\x00SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' %s UNION ALL SELECT %s, rbu_control FROM '%q' %s %s typeof(rbu_control)='integer' AND rbu_control!=1 ORDER BY %s%s\x00rbu_imp_\x00, _rowid_\x00INSERT INTO \"%s%w\"(%s%s) VALUES(%s)\x00DELETE FROM \"%s%w\" WHERE %s\x00, rbu_rowid\x00, 0 AS rbu_rowid\x00CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS SELECT *%s FROM '%q' WHERE 0;\x00CREATE TEMP TRIGGER rbu_delete_tr BEFORE DELETE ON \"%s%w\" BEGIN SELECT rbu_tmp_insert(3, %s);END;CREATE TEMP TRIGGER rbu_update1_tr BEFORE UPDATE ON \"%s%w\" BEGIN SELECT rbu_tmp_insert(3, %s);END;CREATE TEMP TRIGGER rbu_update2_tr AFTER UPDATE ON \"%s%w\" BEGIN SELECT rbu_tmp_insert(4, %s);END;\x00CREATE TEMP TRIGGER rbu_insert_tr AFTER INSERT ON \"%s%w\" BEGIN SELECT rbu_tmp_insert(0, %s);END;\x00,_rowid_ \x00,rbu_rowid\x000 AS \x00SELECT %s,%s rbu_control%s FROM '%q'%s %s %s %s\x00UPDATE \"%s%w\" SET %s WHERE %s\x00SELECT k, v FROM %s.rbu_state\x00file:///%s-vacuum?modeof=%s\x00ATTACH %Q AS stat\x00CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)\x00cannot vacuum wal mode database\x00&\x00file:%s-vactmp?rbu_memory=1%s%s\x00rbu_tmp_insert\x00rbu_fossil_delta\x00rbu_target_name\x00SELECT * FROM sqlite_schema\x00rbu vfs not found\x00PRAGMA main.wal_checkpoint=restart\x00rbu_exclusive_checkpoint\x00%s-oal\x00%s-wal\x00PRAGMA schema_version\x00PRAGMA schema_version = %d\x00INSERT OR REPLACE INTO %s.rbu_state(k, v) VALUES (%d, %d), (%d, %Q), (%d, %Q), (%d, %d), (%d, %lld), (%d, %lld), (%d, %lld), (%d, %lld), (%d, %lld), (%d, %Q) \x00PRAGMA main.%s\x00PRAGMA main.%s = %d\x00PRAGMA writable_schema=1\x00SELECT sql FROM sqlite_schema WHERE sql!='' AND rootpage!=0 AND name!='sqlite_sequence' ORDER BY type DESC\x00SELECT * FROM sqlite_schema WHERE rootpage=0 OR rootpage IS NULL\x00INSERT INTO sqlite_schema VALUES(?,?,?,?,?)\x00PRAGMA writable_schema=0\x00DELETE FROM %s.'rbu_tmp_%q'\x00rbu_state mismatch error\x00rbu_vfs_%d\x00SELECT count(*) FROM sqlite_schema WHERE type='index' AND tbl_name = %Q\x00rbu_index_cnt\x00SELECT 1 FROM sqlite_schema WHERE tbl_name = 'rbu_count'\x00SELECT sum(cnt * (1 + rbu_index_cnt(rbu_target_name(tbl))))FROM rbu_count\x00cannot update wal mode database\x00vacuum\x00update\x00database modified during rbu %s\x00BEGIN IMMEDIATE\x00PRAGMA journal_mode=off\x00-vactmp\x00DELETE FROM stat.rbu_state\x00rbu/zipvfs setup error\x00rbu(%s)/%z\x00rbu_memory\x00overflow\x00%s%.3x+%.6x\x00%s%.3x/\x00internal\x00leaf\x00corrupted\x00SELECT * FROM (SELECT 'sqlite_schema' AS name,1 AS rootpage,'table' AS type UNION ALL SELECT name,rootpage,type FROM \"%w\".sqlite_schema WHERE rootpage!=0)\x00WHERE name=%Q\x00 ORDER BY name\x00dbstat\x00CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)\x00read-only\x00cannot delete\x00cannot insert\x00no such schema\x00bad page number\x00bad page value\x00failed to open transaction\x00sqlite_dbpage\x00SELECT 0, 'tbl', '', 0, '', 1, 0 UNION ALL SELECT 1, 'idx', '', 0, '', 2, 0 UNION ALL SELECT 2, 'stat', '', 0, '', 0, 0\x00PRAGMA '%q'.table_xinfo('%q')\x00SELECT\x00%z%s\"%w\".\"%w\".\"%w\"=\"%w\".\"%w\".\"%w\"\x00%z%s\"%w\".\"%w\".\"%w\" IS NOT \"%w\".\"%w\".\"%w\"\x00 OR \x00_rowid_, *\x00SELECT %s FROM \"%w\".\"%w\" WHERE NOT EXISTS ( SELECT 1 FROM \"%w\".\"%w\" WHERE %s)\x00%z%s\"%w\".\"%w\".\"%w\"\x00SELECT %s,%s FROM \"%w\".\"%w\", \"%w\".\"%w\" WHERE %s AND (%z)\x00SELECT * FROM %Q.sqlite_schema\x00no such table: %s.%s\x00table schemas do not match\x00, 1\x00 AND (?6 OR ?3 IS stat)\x00tbl, idx\x00?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)\x00tbl, ?2, stat\x00?%d\x00 AND (?%d OR ?%d IS %w.%w)\x00SELECT %s%s FROM %Q.%Q WHERE (%s) IS (%s)\x00SAVEPOINT changeset\x00RELEASE changeset\x00UPDATE main.\x00 SET \x00 = ?\x00 WHERE \x00idx IS CASE WHEN length(?4)=0 AND typeof(?4)='blob' THEN NULL ELSE ?4 END \x00 IS ?\x00DELETE FROM main.\x00 AND (?\x00AND \x00INSERT INTO main.\x00) VALUES(?\x00, ?\x00INSERT INTO main.sqlite_stat1 VALUES(?1, CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END, ?3)\x00DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END AND (?4 OR stat IS ?3)\x00SAVEPOINT replace_op\x00RELEASE replace_op\x00PRAGMA table_list = %Q\x00SELECT %s FROM %Q WHERE (%s) IS (%s)\x00INSERT INTO %Q(%s) VALUES(%s)\x00SAVEPOINT update_op\x00ROLLBACK TO update_op\x00RELEASE update_op\x00SAVEPOINT changeset_apply\x00PRAGMA defer_foreign_keys = 1\x00sqlite3changeset_apply(): no such table: %s\x00sqlite3changeset_apply(): table %s has %d columns, expected %d or more\x00sqlite3changeset_apply(): primary key mismatch for table %s\x00PRAGMA defer_foreign_keys = 0\x00RELEASE changeset_apply\x00ROLLBACK TO changeset_apply\x00undefined\x00invalid change: %s value in PK of old.* record\x00invalid change: defined value in PK of new.* record\x00un\x00invalid change: column %d - old.* value is %sdefined but new.* is %sdefined\x00invalid change: column %d is undefined\x00invalid change: null value in PK\x00fts5: parser stack overflow\x00fts5: syntax error near \"%.*s\"\x00%z%.*s\x00wrong number of arguments to function highlight()\x00wrong number of arguments to function snippet()\x00wrong number of arguments to function fts5_get_locale()\x00non-integer argument passed to function fts5_get_locale()\x00snippet\x00highlight\x00bm25\x00fts5_get_locale\x00prefix\x00malformed prefix=... directive\x00too many prefix indexes (max %d)\x00prefix length out of range (max 999)\x00tokenize\x00multiple tokenize=... directives\x00parse error in tokenize directive\x00content\x00multiple content=... directives\x00%Q.%Q\x00contentless_delete\x00malformed contentless_delete=... directive\x00contentless_unindexed\x00content_rowid\x00multiple content_rowid=... directives\x00columnsize\x00malformed columnsize=... directive\x00locale\x00malformed locale=... directive\x00columns\x00malformed detail=... directive\x00tokendata\x00malformed tokendata=... directive\x00unrecognized option: \"%.*s\"\x00rank\x00reserved fts5 column name: %s\x00unindexed\x00unrecognized column option: %s\x00T.%Q\x00, T.%Q\x00, T.c%d\x00, NULL\x00, T.l%d\x00reserved fts5 table name: %s\x00parse error in \"%s\"\x00contentless_delete=1 requires a contentless table\x00contentless_delete=1 is incompatible with columnsize=0\x00contentless_unindexed=1 requires a contentless table\x00docsize\x00%Q.'%q_%s'\x00CREATE TABLE x(\x00%z%s%Q\x00%z, %Q HIDDEN, %s HIDDEN)\x00pgsz\x00hashsize\x00automerge\x00usermerge\x00crisismerge\x00deletemerge\x00secure-delete\x00insttoken\x00SELECT k, v FROM %Q.'%q_config'\x00version\x00invalid fts5 file format (found %d, expected %d or %d) - run 'rebuild'\x00unterminated string\x00fts5: syntax error near \"%.1s\"\x00OR\x00NOT\x00NEAR\x00expected integer, got \"%.*s\"\x00fts5: column queries are not supported (detail=none)\x00phrase\x00fts5: %s queries are not supported (detail!=full)\x00fts5 expression tree is too large (maximum depth %d)\x00fts5: corruption found reading blob %lld from table \"%s\"\x00fts5: corruption on page %d, segment %d, table \"%s\"\x00fts5: corruption in table \"%s\"\x00block\x00REPLACE INTO '%q'.'%q_data'(id, block) VALUES(?,?)\x00DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?\x00DELETE FROM '%q'.'%q_idx' WHERE segid=?\x00\xff\x00\x00\x01\x00fts5: corrupt structure record for table \"%s\"\x00PRAGMA %Q.data_version\x00SELECT pgno FROM '%q'.'%q_idx' WHERE segid=? AND term<=? ORDER BY term DESC LIMIT 1\x00SELECT pgno FROM '%q'.'%q_idx' WHERE segid=? AND term>? ORDER BY term ASC LIMIT 1\x00INSERT INTO '%q'.'%q_idx'(segid,term,pgno) VALUES(?,?,?)\x00DELETE FROM '%q'.'%q_idx' WHERE (segid, (pgno/2)) = (?1, ?2)\x00REPLACE INTO %Q.'%q_config' VALUES ('version', %d)\x00%s_data\x00id INTEGER PRIMARY KEY, block BLOB\x00segid, term, pgno, PRIMARY KEY(segid, term)\x00\x00\x00SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d ORDER BY 1, 2\x00\x00\x00\x00\x00\x00fts5: checksum mismatch for table \"%s\"\x00recursively defined fts5 content table\x00DESC\x00ASC\x00SELECT rowid, rank FROM %Q.%Q ORDER BY %s(\"%w\"%s%s) %s\x00reads\x00unknown special query: %.*s\x00SELECT %s\x00no such function: %s\x00parse error in rank function: %s\x00%s: table does not support scanning\x00fts5: missing row %lld from content table %s\x00delete-all\x00'delete-all' may only be used with a contentless or external content fts5 table\x00rebuild\x00'rebuild' may not be used with a contentless fts5 table\x00merge\x00integrity-check\x00flush\x00%s a subset of columns on fts5 contentless-delete table: %s\x00%s contentless fts5 table: %s\x00cannot UPDATE\x00'delete' may not be used with a contentless_delete=1 table\x00cannot DELETE from contentless fts5 table: %s\x00fts5_locale() requires locale=1\x00no such cursor: %lld\x00no such tokenizer: %s\x00error in tokenizer constructor\x00fts5_api_ptr\x00fts5: 2026-06-03 19:12:13 d6e03d8c777cfa2d35e3b60d8ec3e0187f3e9f99d8e2ee9cac695fd6fcdf1a24\x00config\x00malformed inverted index for FTS5 table %s.%s\x00unable to validate the inverted index for FTS5 table %s.%s: %s\x00fts5\x00fts5_source_id\x00fts5_locale\x00fts5_insttoken\x00SELECT %s FROM %s T WHERE T.%Q >= ? AND T.%Q <= ? ORDER BY T.%Q ASC\x00SELECT %s FROM %s T WHERE T.%Q <= ? AND T.%Q >= ? ORDER BY T.%Q DESC\x00SELECT %s FROM %s T WHERE T.%Q=?\x00INSERT INTO %Q.'%q_content' VALUES(%s)\x00REPLACE INTO %Q.'%q_content' VALUES(%s)\x00DELETE FROM %Q.'%q_content' WHERE id=?\x00REPLACE INTO %Q.'%q_docsize' VALUES(?,?%s)\x00DELETE FROM %Q.'%q_docsize' WHERE id=?\x00SELECT sz%s FROM %Q.'%q_docsize' WHERE id=?\x00REPLACE INTO %Q.'%q_config' VALUES(?,?)\x00SELECT %s FROM %s AS T\x00%z%s?%d\x00%z,?%d\x00,?\x00,origin\x00DROP TABLE IF EXISTS %Q.'%q_data';DROP TABLE IF EXISTS %Q.'%q_idx';DROP TABLE IF EXISTS %Q.'%q_config';\x00DROP TABLE IF EXISTS %Q.'%q_docsize';\x00DROP TABLE IF EXISTS %Q.'%q_content';\x00ALTER TABLE %Q.'%q_%s' RENAME TO '%q_%s';\x00CREATE TABLE %Q.'%q_%q'(%s)%s\x00fts5: error creating shadow table %q_%s: %s\x00id INTEGER PRIMARY KEY\x00, c%d\x00, l%d\x00id INTEGER PRIMARY KEY, sz BLOB\x00id INTEGER PRIMARY KEY, sz BLOB, origin INTEGER\x00k PRIMARY KEY, v\x00DELETE FROM %Q.'%q_data';DELETE FROM %Q.'%q_idx';\x00DELETE FROM %Q.'%q_docsize';\x00DELETE FROM %Q.'%q_content';\x00SELECT count(*) FROM %Q.'%q_%s'\x00tokenchars\x00separators\x00L* N* Co\x00categories\x00remove_diacritics\x00unicode61\x00porter\x00al\x00ance\x00ence\x00er\x00ic\x00able\x00ible\x00ant\x00ement\x00ment\x00ent\x00ion\x00ou\x00ism\x00ate\x00iti\x00ous\x00ive\x00ize\x00at\x00bl\x00ble\x00iz\x00ational\x00tional\x00tion\x00enci\x00anci\x00izer\x00logi\x00bli\x00alli\x00entli\x00eli\x00e\x00ousli\x00ization\x00ation\x00ator\x00alism\x00iveness\x00fulness\x00ful\x00ousness\x00aliti\x00iviti\x00biliti\x00ical\x00ness\x00icate\x00iciti\x00ative\x00alize\x00eed\x00ee\x00ed\x00ing\x00case_sensitive\x00trigram\x00ascii\x00col\x00row\x00instance\x00fts5vocab: unknown table type: %Q\x00CREATE TABlE vocab(term, col, doc, cnt)\x00CREATE TABlE vocab(term, doc, cnt)\x00CREATE TABlE vocab(term, doc, col, offset)\x00wrong number of vtable arguments\x00recursive definition for %s.%s\x00SELECT t.%Q FROM %Q.%Q AS t WHERE t.%Q MATCH '*id'\x00no such fts5 table: %s.%s\x00fts5vocab\x002026-06-03 19:12:13 d6e03d8c777cfa2d35e3b60d8ec3e0187f3e9f99d8e2ee9cac695fd6fcdf1a24\x00" + +const __clang_major__ = 21 + +const __clang_minor__ = 0 + +const __clang_patchlevel__ = 0 + +const __clang_version__ = "21.0.0 (clang-2100.0.123.102)" + +const __exported_hidden = 0 + +const __exported_pop = 0 + +const __exported_push = 0 + +const __exported_push_hidden = 0 + +const __has_bounds_safety_attributes = 0 + +const __has_ptrcheck = 0 + +const __has_safe_buffers = 0 + +const __header_inline = 0 + +const __nonnull = 0 + +const __null_unspecified = 0 + +const __nullable = 0 + +const __unreachable_ok_pop = 0 + +const __unreachable_ok_push = 0 + +var _aAgg = [1]struct { + FxStep uintptr + FxFinal uintptr + FzName uintptr +}{ + 0: { + FzName: __ccgo_ts + 30524, + }, +} + +var _aAlterTableFuncs = [9]TFuncDef{ + 0: { + FnArg: int16(9), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12995, + }, + 1: { + FnArg: int16(7), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 13016, + }, + 2: { + FnArg: int16(7), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 13036, + }, + 3: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 13055, + }, + 4: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 13074, + }, + 5: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 13097, + }, + 6: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 13120, + }, + 7: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 13132, + }, + 8: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 13154, + }, +} + +/* + ** The following array holds FuncDef structures for all of the functions + ** defined in this file. + ** + ** The array cannot be constant since changes are made to the + ** FuncDef.pHash elements at start-time. The elements of this array + ** are read-only after initialization is complete. + ** + ** For peak efficiency, put the most frequently used function last. + */ +var _aBuiltinFunc = [106]TFuncDef{ + 0: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_FUNC_TEST) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_implies_nonnull_row))), + FzName: __ccgo_ts + 16954, + }, + 1: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_FUNC_TEST) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_expr_compare))), + FzName: __ccgo_ts + 16974, + }, + 2: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_FUNC_TEST) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_expr_implies_expr))), + FzName: __ccgo_ts + 16987, + }, + 3: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_FUNC_TEST) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_affinity))), + FzName: __ccgo_ts + 17005, + }, + 4: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17014, + }, + 5: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DIRECTONLY) | libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)), + FzName: __ccgo_ts + 17022, + }, + 6: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DIRECTONLY) | libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)), + FzName: __ccgo_ts + 17022, + }, + 7: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17037, + }, + 8: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17063, + }, + 9: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_FUNC_UNLIKELY)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_unlikely))), + FzName: __ccgo_ts + 17088, + }, + 10: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_FUNC_UNLIKELY)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_unlikely))), + FzName: __ccgo_ts + 17097, + }, + 11: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_FUNC_UNLIKELY)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_unlikely))), + FzName: __ccgo_ts + 17108, + }, + 12: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_sqlite_offset))), + FzName: __ccgo_ts + 17115, + }, + 13: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17129, + }, + 14: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17129, + }, + 15: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(2))), + FzName: __ccgo_ts + 17135, + }, + 16: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(2))), + FzName: __ccgo_ts + 17135, + }, + 17: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(3))), + FzName: __ccgo_ts + 17141, + }, + 18: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(3))), + FzName: __ccgo_ts + 17141, + }, + 19: { + FnArg: int16(-int32(3)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17146, + }, + 20: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_MINMAX) | libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)), + FzName: __ccgo_ts + 17146, + }, + 21: { + FnArg: int16(-int32(3)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17150, + }, + 22: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_MINMAX) | libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17150, + }, + 23: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_TYPEOF)), + FzName: __ccgo_ts + 17154, + }, + 24: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_TYPEOF) | libc.Int32FromInt32(SQLITE_SUBTYPE)), + FzName: __ccgo_ts + 17161, + }, + 25: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_LENGTH)), + FzName: __ccgo_ts + 17169, + }, + 26: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_BYTELEN)), + FzName: __ccgo_ts + 17176, + }, + 27: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17189, + }, + 28: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17195, + }, + 29: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17202, + }, + 30: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17209, + }, + 31: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17217, + }, + 32: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17222, + }, + 33: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17226, + }, + 34: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17226, + }, + 35: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17232, + }, + 36: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17238, + }, + 37: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17244, + }, + 38: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17248, + }, + 39: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17248, + }, + 40: { + FnArg: int16(-int32(3)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17254, + }, + 41: { + FnArg: int16(-int32(4)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17261, + }, + 42: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17271, + }, + 43: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17278, + }, + 44: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17285, + }, + 45: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17296, + }, + 46: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17303, + }, + 47: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17318, + }, + 48: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17335, + }, + 49: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17346, + }, + 50: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17353, + }, + 51: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17359, + }, + 52: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17372, + }, + 53: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17390, + }, + 54: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17398, + }, + 55: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17412, + }, + 56: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17420, + }, + 57: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17429, + }, + 58: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17429, + }, + 59: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17436, + }, + 60: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17436, + }, + 61: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17446, + }, + 62: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17450, + }, + 63: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17456, + }, + 64: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_COUNT) | libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)), + FzName: __ccgo_ts + 17460, + }, + 65: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)), + FzName: __ccgo_ts + 17460, + }, + 66: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17466, + }, + 67: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17466, + }, + 68: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17479, + }, + 69: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_LIKE) | libc.Int32FromInt32(SQLITE_FUNC_CASE)), + FpUserData: uintptr(unsafe.Pointer(&_globInfo)), + FzName: __ccgo_ts + 17490, + }, + 70: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_LIKE)), + FpUserData: uintptr(unsafe.Pointer(&_likeInfoNorm)), + FzName: __ccgo_ts + 16949, + }, + 71: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_LIKE)), + FpUserData: uintptr(unsafe.Pointer(&_likeInfoNorm)), + FzName: __ccgo_ts + 16949, + }, + 72: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17495, + }, + 73: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1275, + }, + 74: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1283, + }, + 75: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17500, + }, + 76: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17506, + }, + 77: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17509, + }, + 78: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17513, + }, + 79: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(2))), + FzName: __ccgo_ts + 17519, + }, + 80: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17509, + }, + 81: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17524, + }, + 82: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17528, + }, + 83: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17532, + }, + 84: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17538, + }, + 85: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17542, + }, + 86: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17547, + }, + 87: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17552, + }, + 88: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17557, + }, + 89: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17563, + }, + 90: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17567, + }, + 91: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17571, + }, + 92: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17575, + }, + 93: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17580, + }, + 94: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17585, + }, + 95: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17590, + }, + 96: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17596, + }, + 97: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17602, + }, + 98: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17608, + }, + 99: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17613, + }, + 100: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17621, + }, + 101: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17629, + }, + 102: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17632, + }, + 103: { + FnArg: int16(-int32(4)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 7305, + }, + 104: { + FnArg: int16(-int32(4)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_iif))), + FzName: __ccgo_ts + 17637, + }, + 105: { + FnArg: int16(-int32(4)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_iif))), + FzName: __ccgo_ts + 17641, + }, +} + +var _aCacheMode = [3]struct { + Fz uintptr + Fmode int32 +}{ + 0: { + Fz: __ccgo_ts + 26494, + Fmode: int32(SQLITE_OPEN_SHAREDCACHE), + }, + 1: { + Fz: __ccgo_ts + 26501, + Fmode: int32(SQLITE_OPEN_PRIVATECACHE), + }, + 2: {}, +} + +var _aFunc = [12]struct { + FxFunc uintptr + FnArg int8 + FbPure uint8 + FzName uintptr +}{ + 0: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30381, + }, + 1: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30394, + }, + 2: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30407, + }, + 3: { + FnArg: int8(-int32(1)), + FbPure: uint8(1), + FzName: __ccgo_ts + 30420, + }, + 4: { + FnArg: int8(2), + FbPure: uint8(1), + FzName: __ccgo_ts + 30366, + }, + 5: { + FnArg: int8(3), + FbPure: uint8(1), + FzName: __ccgo_ts + 30432, + }, + 6: { + FnArg: int8(2), + FbPure: uint8(1), + FzName: __ccgo_ts + 30350, + }, + 7: { + FnArg: int8(1), + FzName: __ccgo_ts + 30455, + }, + 8: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30469, + }, + 9: { + FnArg: int8(7), + FbPure: uint8(1), + FzName: __ccgo_ts + 30482, + }, + 10: { + FnArg: int8(4), + FbPure: uint8(1), + FzName: __ccgo_ts + 30496, + }, + 11: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30512, + }, +} + +var _aJsonFunc = [36]TFuncDef{ + 0: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 14038, + }, + 1: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27290, + }, + 2: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27296, + }, + 3: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27307, + }, + 4: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_AINS) | libc.Int32FromInt32(0)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27319, + }, + 5: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_AINS) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27337, + }, + 6: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27356, + }, + 7: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27356, + }, + 8: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27374, + }, + 9: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27394, + }, + 10: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27407, + }, + 11: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_JSON) | libc.Int32FromInt32(0)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27421, + }, + 12: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_SQL) | libc.Int32FromInt32(0)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27424, + }, + 13: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27428, + }, + 14: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27440, + }, + 15: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27453, + }, + 16: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27465, + }, + 17: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27478, + }, + 18: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27489, + }, + 19: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27501, + }, + 20: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27501, + }, + 21: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27513, + }, + 22: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27524, + }, + 23: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27536, + }, + 24: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27549, + }, + 25: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27562, + }, + 26: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_ISSET) | libc.Int32FromInt32(0)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27576, + }, + 27: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_ISSET) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27585, + }, + 28: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27595, + }, + 29: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27595, + }, + 30: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27605, + }, + 31: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27605, + }, + 32: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC)), + FzName: __ccgo_ts + 27616, + }, + 33: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27633, + }, + 34: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC)), + FzName: __ccgo_ts + 27651, + }, + 35: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27669, + }, +} + +var _aMap = [6]struct { + FzFilesystem uintptr + FpMethods uintptr +}{ + 0: { + FzFilesystem: __ccgo_ts + 3978, + FpMethods: uintptr(unsafe.Pointer(&_posixIoMethods)), + }, + 1: { + FzFilesystem: __ccgo_ts + 3982, + FpMethods: uintptr(unsafe.Pointer(&_posixIoMethods)), + }, + 2: { + FzFilesystem: __ccgo_ts + 3986, + FpMethods: uintptr(unsafe.Pointer(&_afpIoMethods)), + }, + 3: { + FzFilesystem: __ccgo_ts + 3992, + FpMethods: uintptr(unsafe.Pointer(&_afpIoMethods)), + }, + 4: { + FzFilesystem: __ccgo_ts + 3998, + FpMethods: uintptr(unsafe.Pointer(&_nolockIoMethods)), + }, + 5: {}, +} + +var _aMap1 = [5]uint8{ + 0: uint8(SQLITE_ROLLBACK), + 1: uint8(SQLITE_ABORT), + 2: uint8(SQLITE_FAIL), + 3: uint8(SQLITE_IGNORE), + 4: uint8(SQLITE_REPLACE), +} + +var _aMsg = [29]uintptr{ + 0: __ccgo_ts + 25681, + 1: __ccgo_ts + 25694, + 3: __ccgo_ts + 25710, + 4: __ccgo_ts + 25735, + 5: __ccgo_ts + 25749, + 6: __ccgo_ts + 25768, + 7: __ccgo_ts + 1672, + 8: __ccgo_ts + 25793, + 9: __ccgo_ts + 25830, + 10: __ccgo_ts + 25842, + 11: __ccgo_ts + 25857, + 12: __ccgo_ts + 25890, + 13: __ccgo_ts + 25908, + 14: __ccgo_ts + 25933, + 15: __ccgo_ts + 25962, + 17: __ccgo_ts + 6583, + 18: __ccgo_ts + 5934, + 19: __ccgo_ts + 25979, + 20: __ccgo_ts + 25997, + 21: __ccgo_ts + 26015, + 23: __ccgo_ts + 26049, + 25: __ccgo_ts + 26070, + 26: __ccgo_ts + 26096, + 27: __ccgo_ts + 26119, + 28: __ccgo_ts + 26140, +} + +// C documentation +// +// /* +// ** Extra floating-point literals to allow in JSON. +// */ +var _aNanInfName = [5]TNanInfName{ + 0: { + Fc1: int8('i'), + Fc2: int8('I'), + Fn: int8(3), + FeType: int8(JSONB_FLOAT), + FnRepl: int8(7), + FzMatch: __ccgo_ts + 26799, + FzRepl: __ccgo_ts + 26803, + }, + 1: { + Fc1: int8('i'), + Fc2: int8('I'), + Fn: int8(8), + FeType: int8(JSONB_FLOAT), + FnRepl: int8(7), + FzMatch: __ccgo_ts + 26811, + FzRepl: __ccgo_ts + 26803, + }, + 2: { + Fc1: int8('n'), + Fc2: int8('N'), + Fn: int8(3), + FnRepl: int8(4), + FzMatch: __ccgo_ts + 1693, + FzRepl: __ccgo_ts + 1688, + }, + 3: { + Fc1: int8('q'), + Fc2: int8('Q'), + Fn: int8(4), + FnRepl: int8(4), + FzMatch: __ccgo_ts + 26820, + FzRepl: __ccgo_ts + 1688, + }, + 4: { + Fc1: int8('s'), + Fc2: int8('S'), + Fn: int8(4), + FnRepl: int8(4), + FzMatch: __ccgo_ts + 26825, + FzRepl: __ccgo_ts + 1688, + }, +} + +var _aOp = [4]struct { + FzOp uintptr + FeOp uint8 +}{ + 0: { + FzOp: __ccgo_ts + 18159, + FeOp: uint8(SQLITE_INDEX_CONSTRAINT_MATCH), + }, + 1: { + FzOp: __ccgo_ts + 17490, + FeOp: uint8(SQLITE_INDEX_CONSTRAINT_GLOB), + }, + 2: { + FzOp: __ccgo_ts + 16949, + FeOp: uint8(SQLITE_INDEX_CONSTRAINT_LIKE), + }, + 3: { + FzOp: __ccgo_ts + 24260, + FeOp: uint8(SQLITE_INDEX_CONSTRAINT_REGEXP), + }, +} + +var _aOpenMode = [5]struct { + Fz uintptr + Fmode int32 +}{ + 0: { + Fz: __ccgo_ts + 26514, + Fmode: int32(SQLITE_OPEN_READONLY), + }, + 1: { + Fz: __ccgo_ts + 26517, + Fmode: int32(SQLITE_OPEN_READWRITE), + }, + 2: { + Fz: __ccgo_ts + 26520, + Fmode: libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE), + }, + 3: { + Fz: __ccgo_ts + 19396, + Fmode: int32(SQLITE_OPEN_MEMORY), + }, + 4: {}, +} + +var _aPragmaName = [67]TPragmaName{ + 0: { + FzName: __ccgo_ts + 18379, + FePragTyp: uint8(PragTyp_ANALYSIS_LIMIT), + FmPragFlg: uint8(PragFlg_Result0), + }, + 1: { + FzName: __ccgo_ts + 18394, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)), + FiArg: uint64(BTREE_APPLICATION_ID), + }, + 2: { + FzName: __ccgo_ts + 18409, + FePragTyp: uint8(PragTyp_AUTO_VACUUM), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 3: { + FzName: __ccgo_ts + 18421, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_AutoIndex), + }, + 4: { + FzName: __ccgo_ts + 18437, + FePragTyp: uint8(PragTyp_BUSY_TIMEOUT), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(56), + FnPragCName: uint8(1), + }, + 5: { + FzName: __ccgo_ts + 18360, + FePragTyp: uint8(PragTyp_CACHE_SIZE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 6: { + FzName: __ccgo_ts + 18450, + FePragTyp: uint8(PragTyp_CACHE_SPILL), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 7: { + FzName: __ccgo_ts + 18462, + FePragTyp: uint8(PragTyp_CASE_SENSITIVE_LIKE), + FmPragFlg: uint8(PragFlg_NoColumns), + }, + 8: { + FzName: __ccgo_ts + 18482, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_CellSizeCk), + }, + 9: { + FzName: __ccgo_ts + 18498, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_CkptFullFSync), + }, + 10: { + FzName: __ccgo_ts + 18519, + FePragTyp: uint8(PragTyp_COLLATION_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(33), + FnPragCName: uint8(2), + }, + 11: { + FzName: __ccgo_ts + 18534, + FePragTyp: uint8(PragTyp_COMPILE_OPTIONS), + FmPragFlg: uint8(PragFlg_Result0), + }, + 12: { + FzName: __ccgo_ts + 18550, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(0x00001)) << libc.Int32FromInt32(32), + }, + 13: { + FzName: __ccgo_ts + 18564, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_ReadOnly) | libc.Int32FromInt32(PragFlg_Result0)), + FiArg: uint64(BTREE_DATA_VERSION), + }, + 14: { + FzName: __ccgo_ts + 18577, + FePragTyp: uint8(PragTyp_DATABASE_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(50), + FnPragCName: uint8(3), + }, + 15: { + FzName: __ccgo_ts + 18591, + FePragTyp: uint8(PragTyp_DEFAULT_CACHE_SIZE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiPragCName: uint8(55), + FnPragCName: uint8(1), + }, + 16: { + FzName: __ccgo_ts + 18610, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_DeferFKs), + }, + 17: { + FzName: __ccgo_ts + 18629, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_NullCallback), + }, + 18: { + FzName: __ccgo_ts + 18652, + FePragTyp: uint8(PragTyp_ENCODING), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 19: { + FzName: __ccgo_ts + 18661, + FePragTyp: uint8(PragTyp_FOREIGN_KEY_CHECK), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(43), + FnPragCName: uint8(4), + }, + 20: { + FzName: __ccgo_ts + 18679, + FePragTyp: uint8(PragTyp_FOREIGN_KEY_LIST), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FnPragCName: uint8(8), + }, + 21: { + FzName: __ccgo_ts + 18696, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_ForeignKeys), + }, + 22: { + FzName: __ccgo_ts + 18709, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_ReadOnly) | libc.Int32FromInt32(PragFlg_Result0)), + }, + 23: { + FzName: __ccgo_ts + 18724, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_FullColNames), + }, + 24: { + FzName: __ccgo_ts + 18742, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_FullFSync), + }, + 25: { + FzName: __ccgo_ts + 18752, + FePragTyp: uint8(PragTyp_FUNCTION_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(15), + FnPragCName: uint8(6), + }, + 26: { + FzName: __ccgo_ts + 18766, + FePragTyp: uint8(PragTyp_HARD_HEAP_LIMIT), + FmPragFlg: uint8(PragFlg_Result0), + }, + 27: { + FzName: __ccgo_ts + 18782, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_IgnoreChecks), + }, + 28: { + FzName: __ccgo_ts + 18807, + FePragTyp: uint8(PragTyp_INCREMENTAL_VACUUM), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_NoColumns)), + }, + 29: { + FzName: __ccgo_ts + 18826, + FePragTyp: uint8(PragTyp_INDEX_INFO), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(27), + FnPragCName: uint8(3), + }, + 30: { + FzName: __ccgo_ts + 18837, + FePragTyp: uint8(PragTyp_INDEX_LIST), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(33), + FnPragCName: uint8(5), + }, + 31: { + FzName: __ccgo_ts + 18848, + FePragTyp: uint8(PragTyp_INDEX_INFO), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(27), + FnPragCName: uint8(6), + FiArg: uint64(1), + }, + 32: { + FzName: __ccgo_ts + 18860, + FePragTyp: uint8(PragTyp_INTEGRITY_CHECK), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + }, + 33: { + FzName: __ccgo_ts + 18876, + FePragTyp: uint8(PragTyp_JOURNAL_MODE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 34: { + FzName: __ccgo_ts + 18889, + FePragTyp: uint8(PragTyp_JOURNAL_SIZE_LIMIT), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 35: { + FzName: __ccgo_ts + 18908, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_LegacyAlter), + }, + 36: { + FzName: __ccgo_ts + 18927, + FePragTyp: uint8(PragTyp_LOCK_PROXY_FILE), + FmPragFlg: uint8(PragFlg_NoColumns1), + }, + 37: { + FzName: __ccgo_ts + 18943, + FePragTyp: uint8(PragTyp_LOCKING_MODE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 38: { + FzName: __ccgo_ts + 18956, + FePragTyp: uint8(PragTyp_PAGE_COUNT), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 39: { + FzName: __ccgo_ts + 18971, + FePragTyp: uint8(PragTyp_MMAP_SIZE), + }, + 40: { + FzName: __ccgo_ts + 18981, + FePragTyp: uint8(PragTyp_MODULE_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(9), + FnPragCName: uint8(1), + }, + 41: { + FzName: __ccgo_ts + 18993, + FePragTyp: uint8(PragTyp_OPTIMIZE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_NeedSchema)), + }, + 42: { + FzName: __ccgo_ts + 19002, + FePragTyp: uint8(PragTyp_PAGE_COUNT), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 43: { + FzName: __ccgo_ts + 19013, + FePragTyp: uint8(PragTyp_PAGE_SIZE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 44: { + FzName: __ccgo_ts + 19023, + FePragTyp: uint8(PragTyp_PRAGMA_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(9), + FnPragCName: uint8(1), + }, + 45: { + FzName: __ccgo_ts + 19035, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_QueryOnly), + }, + 46: { + FzName: __ccgo_ts + 19046, + FePragTyp: uint8(PragTyp_INTEGRITY_CHECK), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + }, + 47: { + FzName: __ccgo_ts + 19058, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(0x00004)) << libc.Int32FromInt32(32), + }, + 48: { + FzName: __ccgo_ts + 19075, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_RecTriggers), + }, + 49: { + FzName: __ccgo_ts + 19094, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_ReverseOrder), + }, + 50: { + FzName: __ccgo_ts + 19120, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)), + FiArg: uint64(BTREE_SCHEMA_VERSION), + }, + 51: { + FzName: __ccgo_ts + 19135, + FePragTyp: uint8(PragTyp_SECURE_DELETE), + FmPragFlg: uint8(PragFlg_Result0), + }, + 52: { + FzName: __ccgo_ts + 19149, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_ShortColNames), + }, + 53: { + FzName: __ccgo_ts + 19168, + FePragTyp: uint8(PragTyp_SHRINK_MEMORY), + FmPragFlg: uint8(PragFlg_NoColumns), + }, + 54: { + FzName: __ccgo_ts + 19182, + FePragTyp: uint8(PragTyp_SOFT_HEAP_LIMIT), + FmPragFlg: uint8(PragFlg_Result0), + }, + 55: { + FzName: __ccgo_ts + 19198, + FePragTyp: uint8(PragTyp_SYNCHRONOUS), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 56: { + FzName: __ccgo_ts + 19210, + FePragTyp: uint8(PragTyp_TABLE_INFO), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(8), + FnPragCName: uint8(6), + }, + 57: { + FzName: __ccgo_ts + 19221, + FePragTyp: uint8(PragTyp_TABLE_LIST), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1)), + FiPragCName: uint8(21), + FnPragCName: uint8(6), + }, + 58: { + FzName: __ccgo_ts + 19232, + FePragTyp: uint8(PragTyp_TABLE_INFO), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(8), + FnPragCName: uint8(7), + FiArg: uint64(1), + }, + 59: { + FzName: __ccgo_ts + 19244, + FePragTyp: uint8(PragTyp_TEMP_STORE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 60: { + FzName: __ccgo_ts + 19255, + FePragTyp: uint8(PragTyp_TEMP_STORE_DIRECTORY), + FmPragFlg: uint8(PragFlg_NoColumns1), + }, + 61: { + FzName: __ccgo_ts + 19276, + FePragTyp: uint8(PragTyp_THREADS), + FmPragFlg: uint8(PragFlg_Result0), + }, + 62: { + FzName: __ccgo_ts + 19284, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_TrustedSchema), + }, + 63: { + FzName: __ccgo_ts + 19299, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)), + FiArg: uint64(BTREE_USER_VERSION), + }, + 64: { + FzName: __ccgo_ts + 19312, + FePragTyp: uint8(PragTyp_WAL_AUTOCHECKPOINT), + }, + 65: { + FzName: __ccgo_ts + 19331, + FePragTyp: uint8(PragTyp_WAL_CHECKPOINT), + FmPragFlg: uint8(PragFlg_NeedSchema), + FiPragCName: uint8(47), + FnPragCName: uint8(3), + }, + 66: { + FzName: __ccgo_ts + 19346, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_WriteSchema) | libc.Int32FromInt32(SQLITE_NoSchemaError)), + }, +} + +/* Number of pragmas: 68 on by default, 78 total. */ + +/************** End of pragma.h **********************************************/ +/************** Continuing where we left off in pragma.c *********************/ + +/* +** When the 0x10 bit of PRAGMA optimize is set, any ANALYZE commands +** will be run with an analysis_limit set to the lessor of the value of +** the following macro or to the actual analysis_limit if it is non-zero, +** in order to prevent PRAGMA optimize from running for too long. +** +** The value of 2000 is chosen empirically so that the worst-case run-time +** for PRAGMA optimize does not exceed 100 milliseconds against a variety +** of test databases on a RaspberryPI-4 compiled using -Os and without +** -DSQLITE_DEBUG. Of course, your mileage may vary. For the purpose of +** this paragraph, "worst-case" means that ANALYZE ends up being +** run on every table in the database. The worst case typically only +** happens if PRAGMA optimize is run on a database file for which ANALYZE +** has not been previously run and the 0x10000 flag is included so that +** all tables are analyzed. The usual case for PRAGMA optimize is that +** no ANALYZE commands will be run at all, or if any ANALYZE happens it +** will be against a single table, so that expected timing for PRAGMA +** optimize on a PI-4 is more like 1 millisecond or less with the 0x10000 +** flag or less than 100 microseconds without the 0x10000 flag. +** +** An analysis limit of 2000 is almost always sufficient for the query +** planner to fully characterize an index. The additional accuracy from +** a larger analysis is not usually helpful. + */ + +var _aTable = [3]struct { + FzName uintptr + FzCols uintptr +}{ + 0: { + FzName: __ccgo_ts + 13177, + FzCols: __ccgo_ts + 13190, + }, + 1: { + FzName: __ccgo_ts + 13203, + FzCols: __ccgo_ts + 13216, + }, + 2: { + FzName: __ccgo_ts + 13244, + }, +} + +/* +** Recommended number of samples for sqlite_stat4 + */ + +/* + ** All default VFSes for unix are contained in the following array. + ** + ** Note that the sqlite3_vfs.pNext field of the VFS object is modified + ** by the SQLite core when the VFS is registered. So the following + ** array cannot be const. + */ +var _aVfs = [9]Tsqlite3_vfs{ + 0: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4381, + }, + 1: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4386, + }, + 2: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4396, + }, + 3: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4014, + }, + 4: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4409, + }, + 5: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4420, + }, + 6: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4431, + }, + 7: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4440, + }, + 8: { + FiVersion: int32(3), + FszOsFile: int32(128), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4449, + }, +} + +// C documentation +// +// /* +// ** Implementation of the abs() function. +// ** +// ** IMP: R-23979-26855 The abs(X) function returns the absolute value of +// ** the numeric argument X. +// */ +func _absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var iVal Ti64 + var rVal float64 + _, _ = iVal, rVal + _ = argc + switch Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_INTEGER): + iVal = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + if iVal < 0 { + if iVal == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + return _sqlite3CorruptError(tls, int32(78282)) + } + _getCellInfo(tls, pCur) + aPayload = (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload + if libc.Uint64FromInt64(int64(aPayload)-int64((*TMemPage)(unsafe.Pointer(pPage)).FaData)) > uint64((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) { + /* Trying to read or write past the end of the data is an error. The + ** conditional above is really: + ** &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize] + ** but is recast into its current form to avoid integer overflow problems + */ + return _sqlite3CorruptError(tls, int32(78297)) + } + /* Check if data must be read/written to/from the btree page itself. */ + if offset < uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) { + a = libc.Int32FromUint32(amt) + if libc.Uint32FromInt32(a)+offset > uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) { + a = libc.Int32FromUint32(uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) - offset) + } + rc = _copyPayload(tls, aPayload+uintptr(offset), pBuf, a, eOp, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + offset = uint32(0) + pBuf = pBuf + uintptr(a) + amt = amt - libc.Uint32FromInt32(a) + } else { + offset = offset - uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) + } + if rc == SQLITE_OK && amt > uint32(0) { + ovflSize = (*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32(4) + **(**TPgno)(__ccgo_up(bp)) = _sqlite3Get4byte(tls, aPayload+uintptr((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) + /* If the BtCursor.aOverflow[] has not been allocated, allocate it now. + ** + ** The aOverflow[] array is sized at one entry for each overflow page + ** in the overflow chain. The page number of the first overflow page is + ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array + ** means "not yet known" (the cache is lazily populated). + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_ValidOvfl) == 0 { + nOvfl = libc.Int64FromUint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload) + nOvfl = (nOvfl - libc.Int64FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) + libc.Int64FromUint32(ovflSize) - int64(1)) / libc.Int64FromUint32(ovflSize) + if (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow == uintptr(0) || nOvfl*int64(libc.Int32FromInt64(4)) > int64(_sqlite3MallocSize(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow)) { + if _sqlite3FaultSim(tls, int32(413)) != 0 { + aNew = uintptr(0) + } else { + aNew = _sqlite3Realloc(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow, libc.Uint64FromInt64(nOvfl*int64(2))*uint64(4)) + } + if aNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow = aNew + } + } + libc.X__builtin___memset_chk(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow, 0, uint64(libc.Uint64FromInt64(nOvfl)*uint64(4)), ^t__predefined_size_t(0)) + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTCF_ValidOvfl)) + } else { + /* Sanity check the validity of the overflow page cache */ + /* If the overflow page-list cache has been allocated and the + ** entry for the first required overflow page is valid, skip + ** directly to it. + */ + if **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(offset/ovflSize)*4)) != 0 { + iIdx = libc.Int32FromUint32(offset / ovflSize) + **(**TPgno)(__ccgo_up(bp)) = **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx)*4)) + offset = offset % ovflSize + } + } + for **(**TPgno)(__ccgo_up(bp)) != 0 { + /* If required, populate the overflow page-list cache. */ + if **(**TPgno)(__ccgo_up(bp)) > (*TBtShared)(unsafe.Pointer(pBt)).FnPage { + return _sqlite3CorruptError(tls, int32(78370)) + } + **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx)*4)) = **(**TPgno)(__ccgo_up(bp)) + if offset >= ovflSize { + /* The only reason to read this page is to obtain the page + ** number for the next page in the overflow chain. The page + ** data is not required. So first try to lookup the overflow + ** page-list cache, if any, then fall back to the getOverflowPage() + ** function. + */ + if **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx+int32(1))*4)) != 0 { + **(**TPgno)(__ccgo_up(bp)) = **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx+int32(1))*4)) + } else { + rc = _getOverflowPage(tls, pBt, **(**TPgno)(__ccgo_up(bp)), uintptr(0), bp) + } + offset = offset - ovflSize + } else { + /* Need to read this page properly. It contains some of the + ** range of data that is being read (eOp==0) or written (eOp!=0). + */ + a1 = libc.Int32FromUint32(amt) + if libc.Uint32FromInt32(a1)+offset > ovflSize { + a1 = libc.Int32FromUint32(ovflSize - offset) + } + /* If all the following are true: + ** + ** 1) this is a read operation, and + ** 2) data is required from the start of this overflow page, and + ** 3) there are no dirty pages in the page-cache + ** 4) the database is file-backed, and + ** 5) the page is not in the WAL file + ** 6) at least 4 bytes have already been read into the output buffer + ** + ** then data can be read directly from the database file into the + ** output buffer, bypassing the page-cache altogether. This speeds + ** up loading large records that span many overflow pages. + */ + if eOp == 0 && offset == uint32(0) && _sqlite3PagerDirectReadOk(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, **(**TPgno)(__ccgo_up(bp))) != 0 && pBuf+uintptr(-libc.Int32FromInt32(4)) >= pBufStart { + fd = _sqlite3PagerFile(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + aWrite = pBuf + uintptr(-libc.Int32FromInt32(4)) + /* due to (6) */ + libc.X__builtin___memcpy_chk(tls, bp+4, aWrite, uint64(4), ^t__predefined_size_t(0)) + rc = _sqlite3OsRead(tls, fd, aWrite, a1+int32(4), libc.Int64FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FpageSize)*libc.Int64FromUint32(**(**TPgno)(__ccgo_up(bp))-libc.Uint32FromInt32(1))) + **(**TPgno)(__ccgo_up(bp)) = _sqlite3Get4byte(tls, aWrite) + libc.X__builtin___memcpy_chk(tls, aWrite, bp+4, uint64(4), ^t__predefined_size_t(0)) + } else { + if eOp == 0 { + v2 = int32(PAGER_GET_READONLY) + } else { + v2 = 0 + } + rc = _sqlite3PagerGet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, **(**TPgno)(__ccgo_up(bp)), bp+8, v2) + if rc == SQLITE_OK { + if eOp != 0 && (_sqlite3PagerPageRefcount(tls, **(**uintptr)(__ccgo_up(bp + 8))) != int32(1) || (*TMemPage)(unsafe.Pointer(_sqlite3PagerGetExtra(tls, **(**uintptr)(__ccgo_up(bp + 8))))).FisInit != 0) { + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return _sqlite3CorruptError(tls, int32(78440)) + } + aPayload = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**TPgno)(__ccgo_up(bp)) = _sqlite3Get4byte(tls, aPayload) + rc = _copyPayload(tls, aPayload+uintptr(offset+uint32(4)), pBuf, a1, eOp, **(**uintptr)(__ccgo_up(bp + 8))) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + offset = uint32(0) + } + } + amt = amt - libc.Uint32FromInt32(a1) + if amt == uint32(0) { + return rc + } + pBuf = pBuf + uintptr(a1) + } + if rc != 0 { + break + } + iIdx = iIdx + 1 + } + } + if rc == SQLITE_OK && amt > uint32(0) { + /* Overflow chain ends prematurely */ + return _sqlite3CorruptError(tls, int32(78460)) + } + return rc +} + +// C documentation +// +// /* +// ** Return a human-readable name for a constraint resolution action. +// */ +func _actionName(tls *libc.TLS, action Tu8) (r uintptr) { + var zName uintptr + _ = zName + switch libc.Int32FromUint8(action) { + case int32(OE_SetNull): + zName = __ccgo_ts + 19465 + case int32(OE_SetDflt): + zName = __ccgo_ts + 19474 + case int32(OE_Cascade): + zName = __ccgo_ts + 19486 + case int32(OE_Restrict): + zName = __ccgo_ts + 19494 + default: + zName = __ccgo_ts + 19503 + break + } + return zName +} + +// C documentation +// +// /* +// ** Internal SQL function: +// ** +// ** sqlite_add_constraint(SQL, CONSTRAINT-TEXT, ICOL) +// ** +// ** SQL is a CREATE TABLE statement. Return a modified version of +// ** SQL that adds CONSTRAINT-TEXT at the end of the ICOL-th column +// ** definition. (The left-most column defintion is 0.) +// */ +func _addConstraintFunc(tls *libc.TLS, ctx uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var db, zCons, zNew, zSql uintptr + var iCol, ii, nTok int32 + var _ /* iOff at bp+0 */ int32 + var _ /* t at bp+4 */ int32 + _, _, _, _, _, _, _ = db, iCol, ii, nTok, zCons, zNew, zSql + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zCons = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + **(**int32)(__ccgo_up(bp)) = 0 + zNew = uintptr(0) + **(**int32)(__ccgo_up(bp + 4)) = 0 + _ = NotUsed + if _skipCreateTable(tls, ctx, zSql, bp) != 0 { + return + } + ii = 0 + for { + if !(ii <= iCol || iCol < 0 && **(**int32)(__ccgo_up(bp + 4)) != int32(TK_RP)) { + break + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + for int32(1) != 0 { + nTok = _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COMMA) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_RP) { + break + } + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_ILLEGAL) { + Xsqlite3_result_error_code(tls, ctx, _sqlite3CorruptError(tls, int32(123095))) + return + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + nTok + } + goto _1 + _1: + ; + ii = ii + 1 + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getWhitespace(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp)))) + db = Xsqlite3_context_db_handle(tls, ctx) + if iCol < 0 { + zNew = _sqlite3MPrintf(tls, db, __ccgo_ts+12229, libc.VaList(bp+16, **(**int32)(__ccgo_up(bp)), zSql, zCons, zSql+uintptr(**(**int32)(__ccgo_up(bp))))) + } else { + zNew = _sqlite3MPrintf(tls, db, __ccgo_ts+12240, libc.VaList(bp+16, **(**int32)(__ccgo_up(bp)), zSql, zCons, zSql+uintptr(**(**int32)(__ccgo_up(bp))))) + } + Xsqlite3_result_text(tls, ctx, zNew, -int32(1), __ccgo_fp(_sqlite3RowSetClear)) +} + +// C documentation +// +// /* +// ** Add a new module argument to pTable->u.vtab.azArg[]. +// ** The string is not copied - the pointer is stored. The +// ** string will be freed automatically when the table is +// ** deleted. +// */ +func _addModuleArgument(tls *libc.TLS, pParse uintptr, pTable uintptr, zArg uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azModuleArg, db, v2 uintptr + var i, v1 int32 + var nBytes Tsqlite3_int64 + _, _, _, _, _, _ = azModuleArg, db, i, nBytes, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + nBytes = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt32(libc.Int32FromInt32(2)+(*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FnArg)) + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FnArg+int32(3) >= **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14300, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTable)).FzName)) + } + azModuleArg = _sqlite3DbRealloc(tls, db, (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FazArg, libc.Uint64FromInt64(nBytes)) + if azModuleArg == uintptr(0) { + _sqlite3DbFree(tls, db, zArg) + } else { + v2 = pTable + 64 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + i = v1 + **(**uintptr)(__ccgo_up(azModuleArg + uintptr(i)*8)) = zArg + **(**uintptr)(__ccgo_up(azModuleArg + uintptr(i+int32(1))*8)) = uintptr(0) + (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FazArg = azModuleArg + } +} + +// C documentation +// +// /* +// ** This routine checks if there is a RESERVED lock held on the specified +// ** file by this or any other process. If such a lock is held, set *pResOut +// ** to a non-zero value otherwise *pResOut is set to zero. The return value +// ** is set to SQLITE_OK unless an I/O error occurs during lock checking. +// */ +func _afpCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) (r int32) { + var context, pFile uintptr + var lrc, rc, reserved int32 + _, _, _, _, _ = context, lrc, pFile, rc, reserved + rc = SQLITE_OK + reserved = 0 + pFile = id + context = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + if (*TafpLockingContext)(unsafe.Pointer(context)).Freserved != 0 { + **(**int32)(__ccgo_up(pResOut)) = int32(1) + return SQLITE_OK + } + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex) + /* Check if a thread in this process holds such a lock */ + if libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FeFileLock) > int32(SHARED_LOCK) { + reserved = int32(1) + } + /* Otherwise see if some other process holds it. + */ + if !(reserved != 0) { + /* lock the RESERVED byte */ + lrc = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(1)), uint64(1), int32(1)) + if SQLITE_OK == lrc { + /* if we succeeded in taking the reserved lock, unlock it to restore + ** the original state */ + lrc = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(1)), uint64(1), 0) + } else { + /* if we failed to get the lock then someone else must have it */ + reserved = int32(1) + } + if lrc != SQLITE_OK && lrc != int32(SQLITE_BUSY) { + rc = lrc + } + } + Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex) + **(**int32)(__ccgo_up(pResOut)) = reserved + return rc +} + +// C documentation +// +// /* +// ** Close a file & cleanup AFP specific locking context +// */ +func _afpClose(tls *libc.TLS, id uintptr) (r int32) { + var pFile, pInode uintptr + var rc int32 + _, _, _ = pFile, pInode, rc + rc = SQLITE_OK + pFile = id + _afpUnlock(tls, id, NO_LOCK) + _unixEnterMutex(tls) + if (*TunixFile)(unsafe.Pointer(pFile)).FpInode != 0 { + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + if (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock != 0 { + /* If there are outstanding locks, do not actually close the file just + ** yet because that would clear those locks. Instead, add the file + ** descriptor to pInode->aPending. It will be automatically closed when + ** the last lock is cleared. + */ + _setPendingFd(tls, pFile) + } + Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + } + _releaseInodeInfo(tls, pFile) + Xsqlite3_free(tls, (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext) + rc = _closeUnixFile(tls, id) + _unixLeaveMutex(tls) + return rc +} + +/* +** The code above is the AFP lock implementation. The code is specific +** to MacOSX and does not work on other unix platforms. No alternative +** is available. If you don't compile for a mac, then the "unix-afp" +** VFS is not available. +** +********************* End of the AFP lock implementation ********************** +******************************************************************************/ + +/****************************************************************************** +*************************** Begin NFS Locking ********************************/ + +var _afpIoFinder = uintptr(0) + +func _afpIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) (r uintptr) { + _ = z + _ = p + return uintptr(unsafe.Pointer(&_afpIoMethods)) +} + +var _afpIoMethods = Tsqlite3_io_methods{ + FiVersion: int32(1), +} + +// C documentation +// +// /* +// ** Lock the file with the lock specified by parameter eFileLock - one +// ** of the following: +// ** +// ** (1) SHARED_LOCK +// ** (2) RESERVED_LOCK +// ** (3) PENDING_LOCK +// ** (4) EXCLUSIVE_LOCK +// ** +// ** Sometimes when requesting one lock state, additional lock states +// ** are inserted in between. The locking might fail on one of the later +// ** transitions leaving the lock state different from what it started but +// ** still short of its goal. The following chart shows the allowed +// ** transitions and the inserted intermediate states: +// ** +// ** UNLOCKED -> SHARED +// ** SHARED -> RESERVED +// ** SHARED -> (PENDING) -> EXCLUSIVE +// ** RESERVED -> (PENDING) -> EXCLUSIVE +// ** PENDING -> EXCLUSIVE +// ** +// ** This routine will only increase a lock. Use the sqlite3OsUnlock() +// ** routine to lower a locking level. +// */ +func _afpLock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + var context, pFile, pInode uintptr + var failed, failed1, failed2, lrc1, lrc1Errno, lrc2, rc, v1, v2 int32 + var lk, mask int64 + var v3 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = context, failed, failed1, failed2, lk, lrc1, lrc1Errno, lrc2, mask, pFile, pInode, rc, v1, v2, v3 + rc = SQLITE_OK + pFile = id + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + context = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + /* If there is already a lock of this type or more restrictive on the + ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as + ** unixEnterMutex() hasn't been called yet. + */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) >= eFileLock { + return SQLITE_OK + } + /* Make sure the locking sequence is correct + ** (1) We never move from unlocked to anything higher than shared lock. + ** (2) SQLite never explicitly requests a pending lock. + ** (3) A shared lock is always held when a reserve lock is requested. + */ + /* This mutex is needed because pFile->pInode is shared across threads + */ + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + /* If some thread using this PID has a lock via a different unixFile* + ** handle that precludes the requested lock, return BUSY. + */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) != libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) && (libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) >= int32(PENDING_LOCK) || eFileLock > int32(SHARED_LOCK)) { + rc = int32(SQLITE_BUSY) + goto afp_end_lock + } + /* If a SHARED lock is requested, and some thread using this PID already + ** has a SHARED or RESERVED lock, then increment reference counts and + ** return SQLITE_OK. + */ + if eFileLock == int32(SHARED_LOCK) && (libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == int32(SHARED_LOCK) || libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == int32(RESERVED_LOCK)) { + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK) + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared + 1 + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock + 1 + goto afp_end_lock + } + /* A PENDING lock is needed before acquiring a SHARED lock and before + ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will + ** be released. + */ + if eFileLock == int32(SHARED_LOCK) || eFileLock == int32(EXCLUSIVE_LOCK) && libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) < int32(PENDING_LOCK) { + failed = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte), uint64(1), int32(1)) + if failed != 0 { + rc = failed + goto afp_end_lock + } + } + /* If control gets to this point, then actually go ahead and make + ** operating system calls for the specified lock. + */ + if eFileLock == int32(SHARED_LOCK) { + lrc1Errno = 0 + mask = int64(libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< int32(1) { + /* We are trying for an exclusive lock but another thread in this + ** same process is still holding a shared lock. */ + rc = int32(SQLITE_BUSY) + } else { + /* The request was for a RESERVED or EXCLUSIVE lock. It is + ** assumed that there is a SHARED or greater lock on the file + ** already. + */ + failed1 = 0 + if eFileLock >= int32(RESERVED_LOCK) && libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) < int32(RESERVED_LOCK) { + /* Acquire a RESERVED lock */ + failed1 = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(1)), uint64(1), int32(1)) + if !(failed1 != 0) { + (*TafpLockingContext)(unsafe.Pointer(context)).Freserved = int32(1) + } + } + if !(failed1 != 0) && eFileLock == int32(EXCLUSIVE_LOCK) { + /* Acquire an EXCLUSIVE lock */ + /* Remove the shared lock before trying the range. we'll need to + ** reestablish the shared lock if we can't get the afpUnlock + */ + v1 = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(2))+(*TunixInodeInfo)(unsafe.Pointer(pInode)).FsharedByte, uint64(1), 0) + failed1 = v1 + if !(v1 != 0) { + failed2 = SQLITE_OK + /* now attempt to get the exclusive lock range */ + failed1 = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(2)), uint64(SHARED_SIZE), int32(1)) + if v3 = failed1 != 0; v3 { + v1 = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(2))+(*TunixInodeInfo)(unsafe.Pointer(pInode)).FsharedByte, uint64(1), int32(1)) + failed2 = v1 + } + if v3 && v1 != 0 { + /* Can't reestablish the shared lock. Sqlite can't deal, this is + ** a critical I/O error + */ + if failed1&int32(0xff) == int32(SQLITE_IOERR) { + v2 = failed2 + } else { + v2 = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(15)< int32(SHARED_LOCK) { + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) == int32(EXCLUSIVE_LOCK) { + rc = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(2)), uint64(SHARED_SIZE), 0) + if rc == SQLITE_OK && (eFileLock == int32(SHARED_LOCK) || (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared > int32(1)) { + /* only re-establish the shared lock if necessary */ + sharedLockByte = libc.Int32FromUint64(libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(2)) + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FsharedByte) + rc = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(sharedLockByte), uint64(1), int32(1)) + } else { + skipShared = int32(1) + } + } + if rc == SQLITE_OK && libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) >= int32(PENDING_LOCK) { + rc = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte), uint64(1), 0) + } + if rc == SQLITE_OK && libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) >= int32(RESERVED_LOCK) && (*TafpLockingContext)(unsafe.Pointer(context)).Freserved != 0 { + rc = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(1)), uint64(1), 0) + if !(rc != 0) { + (*TafpLockingContext)(unsafe.Pointer(context)).Freserved = 0 + } + } + if rc == SQLITE_OK && (eFileLock == int32(SHARED_LOCK) || (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared > int32(1)) { + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(SHARED_LOCK) + } + } + if rc == SQLITE_OK && eFileLock == NO_LOCK { + /* Decrement the shared lock counter. Release the lock using an + ** OS call only when all threads in this same process have released + ** the lock. + */ + sharedLockByte1 = libc.Uint64FromInt32(_sqlite3PendingByte+libc.Int32FromInt32(2)) + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FsharedByte + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared - 1 + if (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared == 0 { + if !(skipShared != 0) { + rc = _afpSetLock(tls, (*TafpLockingContext)(unsafe.Pointer(context)).FdbPath, pFile, sharedLockByte1, uint64(1), 0) + } + if !(rc != 0) { + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(NO_LOCK) + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(NO_LOCK) + } + } + if rc == SQLITE_OK { + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock - 1 + if (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock == 0 { + _closePendingFds(tls, pFile) + } + } + } + Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + if rc == SQLITE_OK { + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = libc.Uint8FromInt32(eFileLock) + } + return rc +} + +// C documentation +// +// /* +// ** Convert every pAggInfo->aFunc[].pExpr such that any node within +// ** those expressions that has pAppInfo set is changed into a TK_AGG_COLUMN +// ** opcode. +// */ +func _aggregateConvertIndexedExprRefToColumn(tls *libc.TLS, pAggInfo uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var _ /* w at bp+0 */ TWalker + _ = i + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_aggregateIdxEprRefToColCallback) + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + _sqlite3WalkExpr(tls, bp, (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32))).FpFExpr) + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Allocate a new page from the database file. +// ** +// ** The new page is marked as dirty. (In other words, sqlite3PagerWrite() +// ** has already been called on the new page.) The new page has also +// ** been referenced and the calling routine is responsible for calling +// ** sqlite3PagerUnref() on the new page when it is done. +// ** +// ** SQLITE_OK is returned on success. Any other return value indicates +// ** an error. *ppPage is set to NULL in the event of an error. +// ** +// ** If the "nearby" parameter is not 0, then an effort is made to +// ** locate a page close to the page number "nearby". This can be used in an +// ** attempt to keep related pages close to each other in the database file, +// ** which in turn can make database access faster. +// ** +// ** If the eMode parameter is BTALLOC_EXACT and the nearby page exists +// ** anywhere on the free-list, then it is guaranteed to be returned. If +// ** eMode is BTALLOC_LT then the page returned will be less than or equal +// ** to nearby if any such page exists. If eMode is BTALLOC_ANY then there +// ** are no restrictions on which page is returned. +// */ +func _allocateBtreePage(tls *libc.TLS, pBt uintptr, ppPage uintptr, pPgno uintptr, nearby TPgno, eMode Tu8) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aData, pPage1, pPrevTrunk uintptr + var bNoContent, d2, dist, noContent, rc, v5 int32 + var closest, i, k, n, nSearch, v1 Tu32 + var iNewTrunk, iPage, iTrunk, mxPage TPgno + var searchList Tu8 + var v2 bool + var _ /* eType at bp+8 */ Tu8 + var _ /* pNewTrunk at bp+16 */ uintptr + var _ /* pPg at bp+24 */ uintptr + var _ /* pTrunk at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, bNoContent, closest, d2, dist, i, iNewTrunk, iPage, iTrunk, k, mxPage, n, nSearch, noContent, pPage1, pPrevTrunk, rc, searchList, v1, v2, v5 /* Number of leaves on the trunk of the freelist */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pPrevTrunk = uintptr(0) /* Total size of the database file */ + pPage1 = (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 + mxPage = _btreePagecount(tls, pBt) + /* EVIDENCE-OF: R-21003-45125 The 4-byte big-endian integer at offset 36 + ** stores the total number of pages on the freelist. */ + n = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+36) + if n >= mxPage { + return _sqlite3CorruptError(tls, int32(79672)) + } + if n > uint32(0) { + searchList = uint8(0) /* If the free-list must be searched for 'nearby' */ + nSearch = uint32(0) /* Count of the number of search attempts */ + /* If eMode==BTALLOC_EXACT and a query of the pointer-map + ** shows that the page 'nearby' is somewhere on the free-list, then + ** the entire-list will be searched for that page. + */ + if libc.Int32FromUint8(eMode) == int32(BTALLOC_EXACT) { + if nearby <= mxPage { + rc = _ptrmapGet(tls, pBt, nearby, bp+8, uintptr(0)) + if rc != 0 { + return rc + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp + 8))) == int32(PTRMAP_FREEPAGE) { + searchList = uint8(1) + } + } + } else { + if libc.Int32FromUint8(eMode) == int32(BTALLOC_LE) { + searchList = uint8(1) + } + } + /* Decrement the free-list count by 1. Set iTrunk to the index of the + ** first free-list trunk page. iPrevTrunk is initially 1. + */ + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FpDbPage) + if rc != 0 { + return rc + } + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+36, n-uint32(1)) + /* The code within this loop is run only once if the 'searchList' variable + ** is not true. Otherwise, it runs once for each trunk-page on the + ** free-list until the page 'nearby' is located (eMode==BTALLOC_EXACT) + ** or until a page less than 'nearby' is located (eMode==BTALLOC_LT) + */ + for cond := true; cond; cond = searchList != 0 { + pPrevTrunk = **(**uintptr)(__ccgo_up(bp)) + if pPrevTrunk != 0 { + /* EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page + ** is the page number of the next freelist trunk page in the list or + ** zero if this is the last freelist trunk page. */ + iTrunk = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FaData) + } else { + /* EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32 + ** stores the page number of the first page of the freelist, or zero if + ** the freelist is empty. */ + iTrunk = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32) + } + if v2 = iTrunk > mxPage; !v2 { + v1 = nSearch + nSearch = nSearch + 1 + } + if v2 || v1 > n { + rc = _sqlite3CorruptError(tls, int32(79728)) + } else { + rc = _btreeGetUnusedPage(tls, pBt, iTrunk, bp, 0) + } + if rc != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + goto end_allocate_page + } + /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page + ** is the number of leaf page pointers to follow. */ + k = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+4) + if k == uint32(0) && !(searchList != 0) { + /* The trunk has no leaves and the list is not being searched. + ** So extract the trunk page itself and use it as the newly + ** allocated page */ + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if rc != 0 { + goto end_allocate_page + } + **(**TPgno)(__ccgo_up(pPgno)) = iTrunk + libc.X__builtin___memcpy_chk(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if k > (*TBtShared)(unsafe.Pointer(pBt)).FusableSize/libc.Uint32FromInt32(4)-libc.Uint32FromInt32(2) { + /* Value of k is out of range. Database corruption */ + rc = _sqlite3CorruptError(tls, int32(79757)) + goto end_allocate_page + } else { + if searchList != 0 && (nearby == iTrunk || iTrunk < nearby && libc.Int32FromUint8(eMode) == int32(BTALLOC_LE)) { + /* The list is being searched and this trunk page is the page + ** to allocate, regardless of whether it has leaves. + */ + **(**TPgno)(__ccgo_up(pPgno)) = iTrunk + **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up(bp)) + searchList = uint8(0) + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if rc != 0 { + goto end_allocate_page + } + if k == uint32(0) { + if !(pPrevTrunk != 0) { + libc.X__builtin___memcpy_chk(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4), ^t__predefined_size_t(0)) + } else { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage) + if rc != SQLITE_OK { + goto end_allocate_page + } + libc.X__builtin___memcpy_chk(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FaData, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4), ^t__predefined_size_t(0)) + } + } else { + iNewTrunk = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+8) + if iNewTrunk > mxPage { + rc = _sqlite3CorruptError(tls, int32(79791)) + goto end_allocate_page + } + rc = _btreeGetUnusedPage(tls, pBt, iNewTrunk, bp+16, 0) + if rc != SQLITE_OK { + goto end_allocate_page + } + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FpDbPage) + if rc != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 16))) + goto end_allocate_page + } + libc.X__builtin___memcpy_chk(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FaData, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4), ^t__predefined_size_t(0)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FaData+4, k-uint32(1)) + libc.X__builtin___memcpy_chk(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FaData+8, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+12, uint64((k-uint32(1))*uint32(4)), ^t__predefined_size_t(0)) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 16))) + if !(pPrevTrunk != 0) { + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32, iNewTrunk) + } else { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage) + if rc != 0 { + goto end_allocate_page + } + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FaData, iNewTrunk) + } + } + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if k > uint32(0) { + aData = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData + if nearby > uint32(0) { + closest = uint32(0) + if libc.Int32FromUint8(eMode) == int32(BTALLOC_LE) { + i = uint32(0) + for { + if !(i < k) { + break + } + iPage = _sqlite3Get4byte(tls, aData+uintptr(uint32(8)+i*uint32(4))) + if iPage <= nearby { + closest = i + break + } + goto _3 + _3: + ; + i = i + 1 + } + } else { + dist = _sqlite3AbsInt32(tls, libc.Int32FromUint32(_sqlite3Get4byte(tls, aData+8)-nearby)) + i = uint32(1) + for { + if !(i < k) { + break + } + d2 = _sqlite3AbsInt32(tls, libc.Int32FromUint32(_sqlite3Get4byte(tls, aData+uintptr(uint32(8)+i*uint32(4)))-nearby)) + if d2 < dist { + closest = i + dist = d2 + } + goto _4 + _4: + ; + i = i + 1 + } + } + } else { + closest = uint32(0) + } + iPage = _sqlite3Get4byte(tls, aData+uintptr(uint32(8)+closest*uint32(4))) + if iPage > mxPage || iPage < uint32(2) { + rc = _sqlite3CorruptError(tls, int32(79856)) + goto end_allocate_page + } + if !(searchList != 0) || (iPage == nearby || iPage < nearby && libc.Int32FromUint8(eMode) == int32(BTALLOC_LE)) { + **(**TPgno)(__ccgo_up(pPgno)) = iPage + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if rc != 0 { + goto end_allocate_page + } + if closest < k-uint32(1) { + libc.X__builtin___memcpy_chk(tls, aData+uintptr(uint32(8)+closest*uint32(4)), aData+uintptr(uint32(4)+k*uint32(4)), uint64(4), ^t__predefined_size_t(0)) + } + _sqlite3Put4byte(tls, aData+4, k-uint32(1)) + if !(_btreeGetHasContent(tls, pBt, **(**TPgno)(__ccgo_up(pPgno))) != 0) { + v5 = int32(PAGER_GET_NOCONTENT) + } else { + v5 = 0 + } + noContent = v5 + rc = _btreeGetUnusedPage(tls, pBt, **(**TPgno)(__ccgo_up(pPgno)), ppPage, noContent) + if rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppPage)))).FpDbPage) + if rc != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(ppPage))) + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + } + } + searchList = uint8(0) + } + } + } + } + } + _releasePage(tls, pPrevTrunk) + pPrevTrunk = uintptr(0) + } + } else { + if 0 == libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FbDoTruncate) { + v5 = int32(PAGER_GET_NOCONTENT) + } else { + v5 = 0 + } + /* There are no pages on the freelist, so append a new page to the + ** database image. + ** + ** Normally, new pages allocated by this block can be requested from the + ** pager layer with the 'no-content' flag set. This prevents the pager + ** from trying to read the pages content from disk. However, if the + ** current transaction has already run one or more incremental-vacuum + ** steps, then the page we are about to allocate may contain content + ** that is required in the event of a rollback. In this case, do + ** not set the no-content flag. This causes the pager to load and journal + ** the current page content before overwriting it. + ** + ** Note that the pager will not actually attempt to load or journal + ** content for any page that really does lie past the end of the database + ** file on disk. So the effects of disabling the no-content optimization + ** here are confined to those pages that lie between the end of the + ** database image and the end of the database file. + */ + bNoContent = v5 + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) + if rc != 0 { + return rc + } + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + 1 + if (*TBtShared)(unsafe.Pointer(pBt)).FnPage == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + 1 + } + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && _ptrmapPageno(tls, pBt, (*TBtShared)(unsafe.Pointer(pBt)).FnPage) == (*TBtShared)(unsafe.Pointer(pBt)).FnPage { + /* If *pPgno refers to a pointer-map page, allocate two new pages + ** at the end of the file instead of one. The first allocated page + ** becomes a new pointer-map page, the second is used by the caller. + */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + rc = _btreeGetUnusedPage(tls, pBt, (*TBtShared)(unsafe.Pointer(pBt)).FnPage, bp+24, bNoContent) + if rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 24)))).FpDbPage) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 24))) + } + if rc != 0 { + return rc + } + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + 1 + if (*TBtShared)(unsafe.Pointer(pBt)).FnPage == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + 1 + } + } + _sqlite3Put4byte(tls, uintptr(28)+(*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData, (*TBtShared)(unsafe.Pointer(pBt)).FnPage) + **(**TPgno)(__ccgo_up(pPgno)) = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + rc = _btreeGetUnusedPage(tls, pBt, **(**TPgno)(__ccgo_up(pPgno)), ppPage, bNoContent) + if rc != 0 { + return rc + } + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppPage)))).FpDbPage) + if rc != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(ppPage))) + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + } + } + goto end_allocate_page +end_allocate_page: + ; + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + _releasePage(tls, pPrevTrunk) + return rc +} + +// C documentation +// +// /* +// ** Allocate VdbeCursor number iCur. Return a pointer to it. Return NULL +// ** if we run out of memory. +// */ +func _allocateCursor(tls *libc.TLS, p uintptr, iCur int32, nField int32, eCurType Tu8) (r uintptr) { + var nByte Ti64 + var pCx, pMem, v1 uintptr + _, _, _, _ = nByte, pCx, pMem, v1 + if iCur > 0 { + v1 = (*TVdbe)(unsafe.Pointer(p)).FaMem + uintptr((*TVdbe)(unsafe.Pointer(p)).FnMem-iCur)*56 + } else { + v1 = (*TVdbe)(unsafe.Pointer(p)).FaMem + } + /* Find the memory cell that will be used to store the blob of memory + ** required for this VdbeCursor structure. It is convenient to use a + ** vdbe memory cell to manage the memory allocation required for a + ** VdbeCursor structure for the following reasons: + ** + ** * Sometimes cursor numbers are used for a couple of different + ** purposes in a vdbe program. The different uses might require + ** different sized allocations. Memory cells provide growable + ** allocations. + ** + ** * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can + ** be freed lazily via the sqlite3_release_memory() API. This + ** minimizes the number of malloc calls made by the system. + ** + ** The memory cell for cursor 0 is aMem[0]. The rest are allocated from + ** the top of the register space. Cursor 1 is at Mem[p->nMem-1]. + ** Cursor 2 is at Mem[p->nMem-2]. And so forth. + */ + pMem = v1 + pCx = uintptr(0) + nByte = libc.Int64FromUint64((uint64(libc.UintptrFromInt32(0)+120)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7)) + libc.Uint64FromInt32(nField+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + if libc.Int32FromUint8(eCurType) == CURTYPE_BTREE { + nByte = nByte + int64(_sqlite3BtreeCursorSize(tls)) + } + if **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) != 0 { /*OPTIMIZATION-IF-FALSE*/ + _sqlite3VdbeFreeCursorNN(tls, p, **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8))) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) = uintptr(0) + } + /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure + ** the pMem used to hold space for the cursor has enough storage available + ** in pMem->zMalloc. But for the special case of the aMem[] entries used + ** to hold cursors, it is faster to in-line the logic. */ + if int64((*TMem)(unsafe.Pointer(pMem)).FszMalloc) < nByte { + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc > 0 { + _sqlite3DbFreeNN(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } + v1 = _sqlite3DbMallocRaw(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, libc.Uint64FromInt64(nByte)) + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = v1 + (*TMem)(unsafe.Pointer(pMem)).Fz = v1 + if (*TMem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) { + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = 0 + return uintptr(0) + } + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = int32(nByte) + } + v1 = (*TMem)(unsafe.Pointer(pMem)).FzMalloc + pCx = v1 + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) = v1 + libc.X__builtin___memset_chk(tls, pCx, 0, uint64(libc.UintptrFromInt32(0)+40), ^t__predefined_size_t(0)) + (*TVdbeCursor)(unsafe.Pointer(pCx)).FeCurType = eCurType + (*TVdbeCursor)(unsafe.Pointer(pCx)).FnField = int16(nField) + (*TVdbeCursor)(unsafe.Pointer(pCx)).FaOffset = pCx + 120 + uintptr(nField)*4 + if libc.Int32FromUint8(eCurType) == CURTYPE_BTREE { + *(*uintptr)(unsafe.Pointer(pCx + 48)) = (*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((uint64(libc.UintptrFromInt32(0)+120)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32(nField+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + _sqlite3BtreeCursorZero(tls, *(*uintptr)(unsafe.Pointer(pCx + 48))) + } + return pCx +} + +// C documentation +// +// /* +// ** Make sure pBt->pTmpSpace points to an allocation of +// ** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child +// ** pointer. +// */ +func _allocateTempSpace(tls *libc.TLS, pBt uintptr) (r int32) { + var pCur uintptr + _ = pCur + /* This routine is called only by btreeCursor() when allocating the + ** first write cursor for the BtShared object */ + (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace = _sqlite3PageMalloc(tls, libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FpageSize)) + if (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace == uintptr(0) { + pCur = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor + (*TBtShared)(unsafe.Pointer(pBt)).FpCursor = (*TBtCursor)(unsafe.Pointer(pCur)).FpNext /* Unlink the cursor */ + libc.X__builtin___memset_chk(tls, pCur, 0, uint64(296), ^t__predefined_size_t(0)) + return int32(SQLITE_NOMEM) + } + /* One of the uses of pBt->pTmpSpace is to format cells before + ** inserting them into a leaf page (function fillInCell()). If + ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes + ** by the various routines that manipulate binary cells. Which + ** can mean that fillInCell() only initializes the first 2 or 3 + ** bytes of pTmpSpace, but that the first 4 bytes are copied from + ** it into a database page. This is not actually a problem, but it + ** does cause a valgrind error when the 1 or 2 bytes of uninitialized + ** data is passed to system call write(). So to avoid this error, + ** zero the first 4 bytes of temp space here. + ** + ** Also: Provide four bytes of initialized space before the + ** beginning of pTmpSpace as an area available to prepend the + ** left-child pointer to the beginning of a cell. + */ + libc.X__builtin___memset_chk(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace, 0, uint64(8), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(pBt + 136)) += uintptr(4) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Find a column named pCol in table pTab. If successful, set output +// ** parameter *piCol to the index of the column in the table and return +// ** SQLITE_OK. Otherwise, set *piCol to -1 and return an SQLite error +// ** code. +// */ +func _alterFindCol(tls *libc.TLS, pParse uintptr, pTab uintptr, pCol uintptr, piCol uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, zCol, zDb, zName uintptr + var iCol, rc int32 + _, _, _, _, _, _ = db, iCol, rc, zCol, zDb, zName + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + zName = _sqlite3NameFromToken(tls, db, pCol) + rc = int32(SQLITE_NOMEM) + iCol = -int32(1) + if zName != 0 { + iCol = _sqlite3ColumnIndex(tls, pTab, zName) + if iCol < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+12250, libc.VaList(bp+8, zName)) + rc = int32(SQLITE_ERROR) + } else { + rc = SQLITE_OK + } + } + if rc == SQLITE_OK { + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(_sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema))*32))).FzDbSName + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, zCol) != 0 { + pTab = uintptr(0) + } + } + _sqlite3DbFree(tls, db, zName) + **(**int32)(__ccgo_up(piCol)) = iCol + return rc +} + +// C documentation +// +// /* +// ** Buffer pCons, which is nCons bytes in size, contains the text of a +// ** NOT NULL or CHECK constraint that will be inserted into a CREATE TABLE +// ** statement. If successful, this function returns the size of the buffer in +// ** bytes not including any trailing whitespace or "--" style comments. Or, +// ** if an OOM occurs, it returns 0 and sets db->mallocFailed to true. +// ** +// ** C-style comments at the end are preserved. "--" style comments are +// ** removed because the comment terminator might be \000, and we are about +// ** to insert the pCons[] text into the middle of a larger string, and that +// ** will have the effect of removing the comment terminator and messing up +// ** the syntax. +// */ +func _alterRtrimConstraint(tls *libc.TLS, db uintptr, pCons uintptr, nCons int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iEnd, iOff, nToken int32 + var zTmp uintptr + var _ /* t at bp+0 */ int32 + _, _, _, _ = iEnd, iOff, nToken, zTmp + zTmp = _sqlite3MPrintf(tls, db, __ccgo_ts+12390, libc.VaList(bp+16, nCons, pCons)) + iOff = 0 + iEnd = 0 + if zTmp == uintptr(0) { + return 0 + } + for int32(1) != 0 { + **(**int32)(__ccgo_up(bp)) = 0 + nToken = int32(_sqlite3GetToken(tls, zTmp+uintptr(iOff), bp)) + if **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) { + break + } + if **(**int32)(__ccgo_up(bp)) != int32(TK_SPACE) && (**(**int32)(__ccgo_up(bp)) != int32(TK_COMMENT) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zTmp + uintptr(iOff)))) != int32('-')) { + iEnd = iOff + nToken + } + iOff = iOff + nToken + } + _sqlite3DbFree(tls, db, zTmp) + return iEnd +} + +// C documentation +// +// /* +// ** This is the xExprCallback for a tree walker. It is used to +// ** implement sqlite3ExprAnalyzeAggregates(). See sqlite3ExprAnalyzeAggregates +// ** for additional information. +// */ +func _analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var enc Tu8 + var i, iDataCur, mxTerm, nArg, v5 int32 + var pAggInfo, pIEpr, pItem, pItem1, pNC, pOBList, pParse, pSrcList, v7 uintptr + var _ /* tmp at bp+0 */ TExpr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = enc, i, iDataCur, mxTerm, nArg, pAggInfo, pIEpr, pItem, pItem1, pNC, pOBList, pParse, pSrcList, v5, v7 + pNC = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + pAggInfo = *(*uintptr)(unsafe.Pointer(pNC + 16)) + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + default: + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_InAggFunc) == 0 { + break + } + if (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr == uintptr(0) { + break + } + pIEpr = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + for { + if !(pIEpr != 0) { + break + } + iDataCur = (*TIndexedExpr)(unsafe.Pointer(pIEpr)).FiDataCur + if iDataCur < 0 { + goto _1 + } + if _sqlite3ExprCompare(tls, uintptr(0), pExpr, (*TIndexedExpr)(unsafe.Pointer(pIEpr)).FpExpr, iDataCur) == 0 { + break + } + goto _1 + _1: + ; + pIEpr = (*TIndexedExpr)(unsafe.Pointer(pIEpr)).FpIENext + } + if pIEpr == uintptr(0) { + break + } + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == libc.Uint32FromInt32(0)) { + break + } + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc) { + break + } + if (*(*TSrcItem)(unsafe.Pointer(pSrcList + 8 + uintptr(i)*80))).FiCursor == (*TIndexedExpr)(unsafe.Pointer(pIEpr)).FiDataCur { + break + } + goto _2 + _2: + ; + i = i + 1 + } + if i >= (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo != uintptr(0) { + break + } /* Resolved by outer context */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + /* If we reach this point, it means that expression pExpr can be + ** translated into a reference to an index column as described by + ** pIEpr. + */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_AGG_COLUMN) + (**(**TExpr)(__ccgo_up(bp))).FiTable = (*TIndexedExpr)(unsafe.Pointer(pIEpr)).FiIdxCur + (**(**TExpr)(__ccgo_up(bp))).FiColumn = int16((*TIndexedExpr)(unsafe.Pointer(pIEpr)).FiIdxCol) + _findOrCreateAggInfoColumn(tls, pParse, pAggInfo, bp) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((**(**TExpr)(__ccgo_up(bp))).FiAgg)*32))).FpCExpr = pExpr + (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo + (*TExpr)(unsafe.Pointer(pExpr)).FiAgg = (**(**TExpr)(__ccgo_up(bp))).FiAgg + return int32(WRC_Prune) + case int32(TK_IF_NULL_ROW): + fallthrough + case int32(TK_AGG_COLUMN): + fallthrough + case int32(TK_COLUMN): + /* Check to see if the column is in one of the tables in the FROM + ** clause of the aggregate query */ + if pSrcList != uintptr(0) { + pItem = pSrcList + 8 + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc) { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor { + _findOrCreateAggInfoColumn(tls, pParse, pAggInfo, pExpr) + break + } /* endif pExpr->iTable==pItem->iCursor */ + goto _3 + _3: + ; + i = i + 1 + pItem += 80 + } /* end loop over pSrcList */ + } + return WRC_Continue + case int32(TK_AGG_FUNCTION): + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_InAggFunc) == 0 && (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth == libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) && (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) { + /* Check to see if pExpr is a duplicate of another aggregate + ** function that is already in the pAggInfo structure + */ + pItem1 = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + mxTerm = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 2*4)) + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + if (*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFExpr == pExpr { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), (*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFExpr, pExpr, -int32(1)) == 0 { + break + } + goto _4 + _4: + ; + i = i + 1 + pItem1 += 32 + } + if i > mxTerm { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8958, libc.VaList(bp+80, mxTerm)) + i = mxTerm + } else { + if i >= (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc { + /* pExpr is original. Make a new entry in pAggInfo->aFunc[] + */ + enc = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc + i = _addAggInfoFunc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pAggInfo) + if i >= 0 { + pItem1 = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32 + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFExpr = pExpr + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != 0 { + v5 = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + } else { + v5 = 0 + } + nArg = v5 + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFunc = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(pExpr + 8)), nArg, enc, uint8(0)) + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 && (*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFunc)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) == uint32(0) { + v7 = pParse + 56 + v5 = *(*int32)(unsafe.Pointer(v7)) + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FiOBTab = v5 + pOBList = *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32)) + if (*TExprList)(unsafe.Pointer(pOBList)).FnExpr == int32(1) && nArg == int32(1) && _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pOBList + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr, 0) == 0 { + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FbOBPayload = uint8(0) + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FbOBUnique = libc.BoolUint8((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)) != libc.Uint32FromInt32(0)) + } else { + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FbOBPayload = uint8(1) + } + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FbUseSubtype = libc.BoolUint8((*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFunc)).FfuncFlags&uint32(SQLITE_SUBTYPE) != uint32(0)) + } else { + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FiOBTab = -int32(1) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)) != uint32(0) && !((*TAggInfo_func)(unsafe.Pointer(pItem1)).FbOBUnique != 0) { + v7 = pParse + 56 + v5 = *(*int32)(unsafe.Pointer(v7)) + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FiDistinct = v5 + } else { + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FiDistinct = -int32(1) + } + } + } + } + /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry + */ + (*TExpr)(unsafe.Pointer(pExpr)).FiAgg = int16(i) + (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo + return int32(WRC_Prune) + } else { + return WRC_Continue + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Generate code to do an analysis of all indices associated with +// ** a single table. +// */ +func _analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintptr, iStatCur int32, iMem int32, iTab int32) { + var aGotoChng, db, pColl, pIdx, pPk, pStat1, pX, v, zIdxName uintptr + var addrGotoEnd, addrIsNull, addrNext, addrNextRow, doOnce, endDistinctTest, i, iDb, iIdxCur, iTabCur, j, j1, j2, j3, jZeroRows, k, mxCol, nCol, nColTest, nColX, regChng, regCol, regDLt, regEq, regIdxname, regKey, regLt, regNewRowid, regPrev, regRowid, regSample, regSampleRowid, regStat, regStat1, regTabname, regTemp, regTemp2, v1, v2, v3, v4, v5, v6, v7, v8, v9 int32 + var needTableCnt, seekOp Tu8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aGotoChng, addrGotoEnd, addrIsNull, addrNext, addrNextRow, db, doOnce, endDistinctTest, i, iDb, iIdxCur, iTabCur, j, j1, j2, j3, jZeroRows, k, mxCol, nCol, nColTest, nColX, needTableCnt, pColl, pIdx, pPk, pStat1, pX, regChng, regCol, regDLt, regEq, regIdxname, regKey, regLt, regNewRowid, regPrev, regRowid, regSample, regSampleRowid, regStat, regStat1, regTabname, regTemp, regTemp2, seekOp, v, zIdxName, v1, v2, v3, v4, v5, v6, v7, v8, v9 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Loop counter */ + jZeroRows = -int32(1) /* Index of database containing pTab */ + needTableCnt = uint8(1) + v1 = iMem + iMem = iMem + 1 /* True to count the table */ + regNewRowid = v1 + v2 = iMem + iMem = iMem + 1 /* Rowid for the inserted record */ + regStat = v2 + v3 = iMem + iMem = iMem + 1 /* Register to hold StatAccum object */ + regChng = v3 + v4 = iMem + iMem = iMem + 1 /* Index of changed index field */ + regRowid = v4 + v5 = iMem + iMem = iMem + 1 /* Rowid argument passed to stat_push() */ + regTemp = v5 + v6 = iMem + iMem = iMem + 1 /* Temporary use register */ + regTemp2 = v6 + v7 = iMem + iMem = iMem + 1 /* Second temporary use register */ + regTabname = v7 + v8 = iMem + iMem = iMem + 1 /* Register containing table name */ + regIdxname = v8 + v9 = iMem + iMem = iMem + 1 /* Register containing index name */ + regStat1 = v9 /* Value for the stat column of sqlite_stat1 */ + regPrev = iMem /* MUST BE LAST (see below) */ + doOnce = int32(1) /* Flag for a one-time computation */ + pStat1 = uintptr(0) + _sqlite3TouchRegister(tls, pParse, iMem) + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) || pTab == uintptr(0) { + return + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + /* Do not gather statistics on views or virtual tables */ + return + } + if Xsqlite3_strlike(tls, __ccgo_ts+13374, (*TTable)(unsafe.Pointer(pTab)).FzName, uint32('\\')) == 0 { + /* Do not gather statistics on system tables */ + return + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ANALYZE), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) != 0 { + return + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 { + pStat1 = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt64(120)+libc.Uint64FromInt32(13))) + if pStat1 == uintptr(0) { + return + } + (*TTable)(unsafe.Pointer(pStat1)).FzName = pStat1 + 1*120 + libc.X__builtin___memcpy_chk(tls, (*TTable)(unsafe.Pointer(pStat1)).FzName, __ccgo_ts+13177, uint64(13), ^t__predefined_size_t(0)) + (*TTable)(unsafe.Pointer(pStat1)).FnCol = int16(3) + (*TTable)(unsafe.Pointer(pStat1)).FiPKey = int16(-int32(1)) + _sqlite3VdbeAddOp4(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Noop), 0, 0, 0, pStat1, -int32(7)) + } + /* Establish a read-lock on the table at the shared-cache level. + ** Open a read-only cursor on the table. Also allocate a cursor number + ** to use for scanning indexes (iIdxCur). No index cursor is opened at + ** this time though. */ + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab)).FzName) + v1 = iTab + iTab = iTab + 1 + iTabCur = v1 + v1 = iTab + iTab = iTab + 1 + iIdxCur = v1 + if (*TParse)(unsafe.Pointer(pParse)).FnTab > iTab { + v1 = (*TParse)(unsafe.Pointer(pParse)).FnTab + } else { + v1 = iTab + } + (*TParse)(unsafe.Pointer(pParse)).FnTab = v1 + _sqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab, int32(OP_OpenRead)) + _sqlite3VdbeLoadString(tls, v, regTabname, (*TTable)(unsafe.Pointer(pTab)).FzName) + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } /* Number of columns to test for changes */ + if pOnlyIdx != 0 && pOnlyIdx != pIdx { + goto _13 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) { + needTableCnt = uint8(0) + } + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + nCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + zIdxName = (*TTable)(unsafe.Pointer(pTab)).FzName + nColTest = nCol - int32(1) + } else { + nCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + zIdxName = (*TIndex)(unsafe.Pointer(pIdx)).FzName + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x8>>3)) != 0 { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) - int32(1) + } else { + v1 = nCol - int32(1) + } + nColTest = v1 + } + /* Populate the register containing the index name. */ + _sqlite3VdbeLoadString(tls, v, regIdxname, zIdxName) + /* + ** Pseudo-code for loop that calls stat_push(): + ** + ** regChng = 0 + ** Rewind csr + ** if eof(csr){ + ** stat_init() with count = 0; + ** goto end_of_scan; + ** } + ** count() + ** stat_init() + ** goto chng_addr_0; + ** + ** next_row: + ** regChng = 0 + ** if( idx(0) != regPrev(0) ) goto chng_addr_0 + ** regChng = 1 + ** if( idx(1) != regPrev(1) ) goto chng_addr_1 + ** ... + ** regChng = N + ** goto chng_addr_N + ** + ** chng_addr_0: + ** regPrev(0) = idx(0) + ** chng_addr_1: + ** regPrev(1) = idx(1) + ** ... + ** + ** endDistinctTest: + ** regRowid = idx(rowid) + ** stat_push(P, regChng, regRowid) + ** Next csr + ** if !eof(csr) goto next_row; + ** + ** end_of_scan: + */ + /* Make sure there are enough memory cells allocated to accommodate + ** the regPrev array and a trailing rowid (the rowid slot is required + ** when building a record to insert into the sample column of + ** the sqlite_stat4 table. */ + _sqlite3TouchRegister(tls, pParse, regPrev+nColTest) + /* Open a read-only cursor on the index being analyzed. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), iIdxCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) + /* Implementation of the following: + ** + ** regChng = 0 + ** Rewind csr + ** if eof(csr){ + ** stat_init() with count = 0; + ** goto end_of_scan; + ** } + ** count() + ** stat_init() + ** goto chng_addr_0; + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit, regTemp2) + /* Arguments to stat_init(): + ** (1) the number of columns in the index including the rowid + ** (or for a WITHOUT ROWID table, the number of PK columns), + ** (2) the number of columns in the key without the rowid/pk + ** (3) estimated number of rows in the index. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), nCol, regStat+int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol), regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Count), iIdxCur, regTemp, libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) != uint32(0))) + _sqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat+int32(1), regStat, int32(4), uintptr(unsafe.Pointer(&_statInitFuncdef)), 0) + addrGotoEnd = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iIdxCur) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regChng) + addrNextRow = _sqlite3VdbeCurrentAddr(tls, v) + if nColTest > 0 { + endDistinctTest = _sqlite3VdbeMakeLabel(tls, pParse) /* Array of jump instruction addresses */ + aGotoChng = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(nColTest))) + if aGotoChng == uintptr(0) { + goto _13 + } + /* + ** next_row: + ** regChng = 0 + ** if( idx(0) != regPrev(0) ) goto chng_addr_0 + ** regChng = 1 + ** if( idx(1) != regPrev(1) ) goto chng_addr_1 + ** ... + ** regChng = N + ** goto endDistinctTest + */ + _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + addrNextRow = _sqlite3VdbeCurrentAddr(tls, v) + if nColTest == int32(1) && libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) == int32(1) && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != OE_None { + /* For a single-column UNIQUE index, once we have found a non-NULL + ** row, we know that all the rest will be distinct, so skip + ** subsequent distinctness tests. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), regPrev, endDistinctTest) + } + i = 0 + for { + if !(i < nColTest) { + break + } + pColl = _sqlite3LocateCollSeq(tls, pParse, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*8))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), i, regChng) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, i, regTemp) + **(**int32)(__ccgo_up(aGotoChng + uintptr(i)*4)) = _sqlite3VdbeAddOp4(tls, v, int32(OP_Ne), regTemp, 0, regPrev+i, pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NULLEQ)) + goto _15 + _15: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), nColTest, regChng) + _sqlite3VdbeGoto(tls, v, endDistinctTest) + /* + ** chng_addr_0: + ** regPrev(0) = idx(0) + ** chng_addr_1: + ** regPrev(1) = idx(1) + ** ... + */ + _sqlite3VdbeJumpHere(tls, v, addrNextRow-int32(1)) + i = 0 + for { + if !(i < nColTest) { + break + } + _sqlite3VdbeJumpHere(tls, v, **(**int32)(__ccgo_up(aGotoChng + uintptr(i)*4))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, i, regPrev+i) + goto _16 + _16: + ; + i = i + 1 + } + _sqlite3VdbeResolveLabel(tls, v, endDistinctTest) + _sqlite3DbFree(tls, db, aGotoChng) + } + /* + ** chng_addr_N: + ** regRowid = idx(rowid) // STAT4 only + ** stat_push(P, regChng, regRowid) // 3rd parameter STAT4 only + ** Next csr + ** if !eof(csr) goto next_row; + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), iIdxCur, regRowid) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpTable) + regKey = _sqlite3GetTempRange(tls, pParse, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + k = _sqlite3TableColumnToIndex(tls, pIdx, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, k, regKey+j) + goto _17 + _17: + ; + j = j + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regKey, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol), regRowid) + _sqlite3ReleaseTempRange(tls, pParse, regKey, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + } + } + _sqlite3VdbeAddFunctionCall(tls, pParse, int32(1), regStat, regTemp, libc.Int32FromInt32(2)+libc.Int32FromInt32(IsStat4), uintptr(unsafe.Pointer(&_statPushFuncdef)), 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit != 0 { + j1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), regTemp) + j2 = _sqlite3VdbeAddOp1(tls, v, int32(OP_If), regTemp) + j3 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_SeekGT), iIdxCur, 0, regPrev, int32(1)) + _sqlite3VdbeJumpHere(tls, v, j1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iIdxCur, addrNextRow) + _sqlite3VdbeJumpHere(tls, v, j2) + _sqlite3VdbeJumpHere(tls, v, j3) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iIdxCur, addrNextRow) + } + /* Add the entry to the stat1 table. */ + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + /* Partial indexes might get a zero-entry in sqlite_stat1. But + ** an empty table is omitted from sqlite_stat1. */ + _sqlite3VdbeJumpHere(tls, v, addrGotoEnd) + addrGotoEnd = 0 + } + _callStatGet(tls, pParse, regStat, STAT_GET_STAT1, regStat1) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), regTabname, int32(3), regTemp, __ccgo_ts+13384, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iStatCur, regNewRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iStatCur, regTemp, regNewRowid) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pStat1, -int32(5)) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + /* Add the entries to the stat4 table. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) && (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit == 0 { + regEq = regStat1 + regLt = regStat1 + int32(1) + regDLt = regStat1 + int32(2) + regSample = regStat1 + int32(3) + regCol = regStat1 + int32(4) + regSampleRowid = regCol + nCol + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v1 = int32(OP_NotExists) + } else { + v1 = int32(OP_NotFound) + } + seekOp = libc.Uint8FromInt32(v1) + /* No STAT4 data is generated if the number of rows is zero */ + if addrGotoEnd == 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Cast), regStat1, int32(SQLITE_AFF_INTEGER)) + addrGotoEnd = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), regStat1) + } + if doOnce != 0 { + mxCol = nCol + /* Compute the maximum number of columns in any index */ + pX = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pX != 0) { + break + } /* Number of columns in pX */ + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pX + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + nColX = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pX)).FnKeyCol) + } else { + nColX = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pX)).FnColumn) + } + if nColX > mxCol { + mxCol = nColX + } + goto _19 + _19: + ; + pX = (*TIndex)(unsafe.Pointer(pX)).FpNext + } + /* Allocate space to compute results for the largest index */ + _sqlite3TouchRegister(tls, pParse, regCol+mxCol) + doOnce = 0 + _sqlite3ClearTempRegCache(tls, pParse) /* tag-20230325-1 */ + } + addrNext = _sqlite3VdbeCurrentAddr(tls, v) + _callStatGet(tls, pParse, regStat, int32(STAT_GET_ROWID), regSampleRowid) + addrIsNull = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), regSampleRowid) + _callStatGet(tls, pParse, regStat, int32(STAT_GET_NEQ), regEq) + _callStatGet(tls, pParse, regStat, int32(STAT_GET_NLT), regLt) + _callStatGet(tls, pParse, regStat, int32(STAT_GET_NDLT), regDLt) + _sqlite3VdbeAddOp4Int(tls, v, libc.Int32FromUint8(seekOp), iTabCur, addrNext, regSampleRowid, 0) + i = 0 + for { + if !(i < nCol) { + break + } + _sqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iTabCur, i, regCol+i) + goto _20 + _20: + ; + i = i + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regCol, nCol, regSample) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regTabname, int32(6), regTemp) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iStatCur+int32(1), regNewRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iStatCur+int32(1), regTemp, regNewRowid) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), int32(1), addrNext) /* P1==1 for end-of-loop */ + _sqlite3VdbeJumpHere(tls, v, addrIsNull) + } + /* End of analysis */ + if addrGotoEnd != 0 { + _sqlite3VdbeJumpHere(tls, v, addrGotoEnd) + } + goto _13 + _13: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + /* Create a single sqlite_stat1 entry containing NULL as the index + ** name and the row count as the content. + */ + if pOnlyIdx == uintptr(0) && needTableCnt != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Count), iTabCur, regStat1) + jZeroRows = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), regStat1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regIdxname) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), regTabname, int32(3), regTemp, __ccgo_ts+13384, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iStatCur, regNewRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iStatCur, regTemp, regNewRowid) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pStat1, -int32(5)) + _sqlite3VdbeJumpHere(tls, v, jZeroRows) + } +} + +// C documentation +// +// /* +// ** Generate code that will do an analysis of a single table in +// ** a database. If pOnlyIdx is not NULL then it is a single index +// ** in pTab that should be analyzed. +// */ +func _analyzeTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintptr) { + var iDb, iStatCur int32 + _, _ = iDb, iStatCur + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + iStatCur = (*TParse)(unsafe.Pointer(pParse)).FnTab + **(**int32)(__ccgo_up(pParse + 56)) += int32(3) + if pOnlyIdx != 0 { + _openStatTable(tls, pParse, iDb, iStatCur, (*TIndex)(unsafe.Pointer(pOnlyIdx)).FzName, __ccgo_ts+13388) + } else { + _openStatTable(tls, pParse, iDb, iStatCur, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+13392) + } + _analyzeOneTable(tls, pParse, pTab, pOnlyIdx, iStatCur, (*TParse)(unsafe.Pointer(pParse)).FnMem+int32(1), (*TParse)(unsafe.Pointer(pParse)).FnTab) + _loadAnalysis(tls, pParse, iDb) +} + +// C documentation +// +// /* +// ** Append a single path element to the DbPath under construction +// */ +func _appendOnePathElement(tls *libc.TLS, pPath uintptr, zName uintptr, nName int32) { + bp := tls.Alloc(1184) + defer tls.Free(1184) + var got Tssize_t + var zIn, v2 uintptr + var v1 int32 + var _ /* buf at bp+0 */ Tstat + var _ /* zLnk at bp+144 */ [1026]int8 + _, _, _, _ = got, zIn, v1, v2 + if int32(**(**int8)(__ccgo_up(zName))) == int32('.') { + if nName == int32(1) { + return + } + if int32(**(**int8)(__ccgo_up(zName + 1))) == int32('.') && nName == int32(2) { + if (*TDbPath)(unsafe.Pointer(pPath)).FnUsed > int32(1) { + for { + v2 = pPath + 20 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + if !(int32(**(**int8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr(v1)))) != int32('/')) { + break + } + } + } + return + } + } + if (*TDbPath)(unsafe.Pointer(pPath)).FnUsed+nName+int32(2) >= (*TDbPath)(unsafe.Pointer(pPath)).FnOut { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = int32(SQLITE_ERROR) + return + } + v2 = pPath + 20 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr(v1))) = int8('/') + libc.X__builtin___memcpy_chk(tls, (*TDbPath)(unsafe.Pointer(pPath)).FzOut+uintptr((*TDbPath)(unsafe.Pointer(pPath)).FnUsed), zName, libc.Uint64FromInt32(nName), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pPath + 20)) += nName + if (*TDbPath)(unsafe.Pointer(pPath)).Frc == SQLITE_OK { + **(**int8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr((*TDbPath)(unsafe.Pointer(pPath)).FnUsed))) = 0 + zIn = (*TDbPath)(unsafe.Pointer(pPath)).FzOut + if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(27)].FpCurrent})))(tls, zIn, bp) != 0 { + if **(**int32)(__ccgo_up(libc.X__error(tls))) != int32(ENOENT) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47142)), __ccgo_ts+3738, zIn, int32(47142)) + } + } else { + if libc.Int32FromUint16((**(**Tstat)(__ccgo_up(bp))).Fst_mode)&int32(S_IFMT) == int32(S_IFLNK) { + v2 = pPath + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + if v1 > int32(SQLITE_MAX_SYMLINK) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _sqlite3CantopenError(tls, int32(47148)) + return + } + got = (*(*func(*libc.TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(26)].FpCurrent})))(tls, zIn, bp+144, libc.Uint64FromInt64(1026)-libc.Uint64FromInt32(2)) + if got <= 0 || got >= libc.Int64FromInt64(1026)-libc.Int64FromInt32(2) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47153)), __ccgo_ts+3729, zIn, int32(47153)) + return + } + (**(**[1026]int8)(__ccgo_up(bp + 144)))[got] = 0 + if int32((**(**[1026]int8)(__ccgo_up(bp + 144)))[0]) == int32('/') { + (*TDbPath)(unsafe.Pointer(pPath)).FnUsed = 0 + } else { + **(**int32)(__ccgo_up(pPath + 20)) -= nName + int32(1) + } + _appendAllPathElements(tls, pPath, bp+144) + } + } + } +} + +// C documentation +// +// /* +// ** Append text z[] to the end of p[]. Return a pointer to the first +// ** character after then zero terminator on the new text in p[]. +// */ +func _appendText(tls *libc.TLS, p uintptr, z uintptr) (r uintptr) { + var n Tsize_t + _ = n + n = libc.Xstrlen(tls, z) + libc.X__builtin___memcpy_chk(tls, p, z, n+uint64(1), ^t__predefined_size_t(0)) + return p + uintptr(n) + uintptr(1) +} + +// C documentation +// +// /* +// ** An SQL user-function registered to do the work of an ATTACH statement. The +// ** three arguments to the function come directly from an attach statement: +// ** +// ** ATTACH DATABASE x AS y KEY z +// ** +// ** SELECT sqlite_attach(x, y, z) +// ** +// ** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the +// ** third argument. +// ** +// ** If the db->init.reopenMemdb flags is set, then instead of attaching a +// ** new database, close the database on db->init.iDb and reopen it as an +// ** empty MemDB. +// */ +func _attachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var aNew, db, pNew, pNewSchema, pPager, zFile, zName uintptr + var i, iDb, rc int32 + var _ /* flags at bp+16 */ uint32 + var _ /* pNewBt at bp+40 */ uintptr + var _ /* pVfs at bp+32 */ uintptr + var _ /* zErr at bp+8 */ uintptr + var _ /* zErrDyn at bp+24 */ uintptr + var _ /* zPath at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aNew, db, i, iDb, pNew, pNewSchema, pPager, rc, zFile, zName + rc = 0 + db = Xsqlite3_context_db_handle(tls, context) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* New array of Db pointers */ + pNew = uintptr(0) /* Db object for the newly attached database */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + _ = NotUsed + zFile = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zName = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zFile == uintptr(0) { + zFile = __ccgo_ts + 1702 + } + if zName == uintptr(0) { + zName = __ccgo_ts + 1702 + } + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x8>>3)) != 0 { + /* This is not a real ATTACH. Instead, this routine is being called + ** from sqlite3_deserialize() to close database db->init.iDb and + ** reopen it as a MemDB */ + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + pNew = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb)*32 + if _sqlite3BtreeTxnState(tls, (*TDb)(unsafe.Pointer(pNew)).FpBt) != SQLITE_TXN_NONE || _sqlite3BtreeIsInBackup(tls, (*TDb)(unsafe.Pointer(pNew)).FpBt) != 0 { + rc = int32(SQLITE_BUSY) + goto attach_error + } + **(**uintptr)(__ccgo_up(bp + 32)) = Xsqlite3_vfs_find(tls, __ccgo_ts+4460) + if **(**uintptr)(__ccgo_up(bp + 32)) == uintptr(0) { + return + } + rc = _sqlite3BtreeOpen(tls, **(**uintptr)(__ccgo_up(bp + 32)), __ccgo_ts+13591, db, bp+40, 0, int32(SQLITE_OPEN_MAIN_DB)) + if rc == SQLITE_OK { + pNewSchema = _sqlite3SchemaGet(tls, db, **(**uintptr)(__ccgo_up(bp + 40))) + if pNewSchema != 0 { + /* Both the Btree and the new Schema were allocated successfully. + ** Close the old db and update the aDb[] slot with the new memdb + ** values. */ + _sqlite3BtreeClose(tls, (*TDb)(unsafe.Pointer(pNew)).FpBt) + (*TDb)(unsafe.Pointer(pNew)).FpBt = **(**uintptr)(__ccgo_up(bp + 40)) + (*TDb)(unsafe.Pointer(pNew)).FpSchema = pNewSchema + } else { + _sqlite3BtreeClose(tls, **(**uintptr)(__ccgo_up(bp + 40))) + rc = int32(SQLITE_NOMEM) + } + } + if rc != 0 { + goto attach_error + } + } else { + /* This is a real ATTACH + ** + ** Check for the following errors: + ** + ** * Too many attached databases, + ** * Transaction currently open + ** * Specified database name already being used. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnDb >= **(**int32)(__ccgo_up(db + 136 + 7*4))+int32(2) { + **(**uintptr)(__ccgo_up(bp + 24)) = _sqlite3MPrintf(tls, db, __ccgo_ts+13594, libc.VaList(bp+56, **(**int32)(__ccgo_up(db + 136 + 7*4)))) + goto attach_error + } + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if _sqlite3DbIsNamed(tls, db, i, zName) != 0 { + **(**uintptr)(__ccgo_up(bp + 24)) = _sqlite3MPrintf(tls, db, __ccgo_ts+13631, libc.VaList(bp+56, zName)) + goto attach_error + } + goto _1 + _1: + ; + i = i + 1 + } + /* Allocate the new entry in the db->aDb[] array and initialize the schema + ** hash tables. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FaDb == db+696 { + aNew = _sqlite3DbMallocRawNN(tls, db, uint64(libc.Uint64FromInt64(32)*libc.Uint64FromInt32(3))) + if aNew == uintptr(0) { + return + } + libc.X__builtin___memcpy_chk(tls, aNew, (*Tsqlite3)(unsafe.Pointer(db)).FaDb, libc.Uint64FromInt64(32)*libc.Uint64FromInt32(2), ^t__predefined_size_t(0)) + } else { + aNew = _sqlite3DbRealloc(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaDb, uint64(32)*libc.Uint64FromInt64(libc.Int64FromInt32(1)+int64((*Tsqlite3)(unsafe.Pointer(db)).FnDb))) + if aNew == uintptr(0) { + return + } + } + (*Tsqlite3)(unsafe.Pointer(db)).FaDb = aNew + pNew = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Tsqlite3)(unsafe.Pointer(db)).FnDb)*32 + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(32), ^t__predefined_size_t(0)) + /* Open the database file. If the btree is successfully opened, use + ** it to obtain the database schema. At this point the schema may + ** or may not be initialized. + */ + **(**uint32)(__ccgo_up(bp + 16)) = (*Tsqlite3)(unsafe.Pointer(db)).FopenFlags + rc = _sqlite3ParseUri(tls, (*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpVfs)).FzName, zFile, bp+16, bp+32, bp, bp+8) + if rc != SQLITE_OK { + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + Xsqlite3_result_error(tls, context, **(**uintptr)(__ccgo_up(bp + 8)), -int32(1)) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00020))<aDb[] array. i.e. put everything back the + ** way we found it. + */ + if rc == SQLITE_OK { + _sqlite3BtreeEnterAll(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_SchemaKnownOk)) + if !(int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x8>>3)) != 0) { + rc = _sqlite3Init(tls, db, bp+24) + } + _sqlite3BtreeLeaveAll(tls, db) + } + if rc != 0 { + if !(int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x8>>3)) != 0) { + iDb = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt != 0 { + _sqlite3BtreeClose(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt) + (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt = uintptr(0) + (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema = uintptr(0) + } + _sqlite3ResetAllSchemasOfConnection(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).FnDb = iDb + if rc == int32(SQLITE_NOMEM) || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)< */ + +/* +** If building separately, we will need some setup that is normally +** found in sqliteInt.h + */ + +/* Macro to check for 4-byte alignment. Only used inside of assert() */ + +/* #include */ +/* #include */ +/* #include */ +/* #include */ + +/* The following macro is used to suppress compiler warnings. + */ + +var _azName1 = [3]uintptr{ + 0: __ccgo_ts + 28121, + 1: __ccgo_ts + 5995, + 2: __ccgo_ts + 18310, +} + +var _azName2 = [5]uintptr{ + 0: __ccgo_ts + 40920, + 1: __ccgo_ts + 37911, + 2: __ccgo_ts + 27730, + 3: __ccgo_ts + 38606, + 4: __ccgo_ts + 13388, +} + +var _azOne = [1]uintptr{ + 0: __ccgo_ts + 11885, +} + +var _azSql = [8]uintptr{ + 0: __ccgo_ts + 28126, + 1: __ccgo_ts + 28179, + 2: __ccgo_ts + 28224, + 3: __ccgo_ts + 28276, + 4: __ccgo_ts + 28330, + 5: __ccgo_ts + 28375, + 6: __ccgo_ts + 28433, + 7: __ccgo_ts + 28488, +} + +// C documentation +// +// /* +// ** Directories to consider for temp files. +// */ +var _azTempDirs = [6]uintptr{ + 2: __ccgo_ts + 4032, + 3: __ccgo_ts + 4041, + 4: __ccgo_ts + 4050, + 5: __ccgo_ts + 1741, +} + +var _azType = [4]uintptr{ + 0: __ccgo_ts + 6166, + 1: __ccgo_ts + 6175, + 2: __ccgo_ts + 6182, + 3: __ccgo_ts + 6188, +} + +var _azType1 = [6]uintptr{ + 0: __ccgo_ts + 1702, + 1: __ccgo_ts + 14718, + 2: __ccgo_ts + 14724, + 3: __ccgo_ts + 14729, + 4: __ccgo_ts + 14734, + 5: __ccgo_ts + 14724, +} + +var _azType2 = [5]uintptr{ + 0: __ccgo_ts + 6836, + 1: __ccgo_ts + 6831, + 2: __ccgo_ts + 8831, + 3: __ccgo_ts + 8826, + 4: __ccgo_ts + 1688, +} + +// C documentation +// +// /* +// ** Parameter zSrcData points to a buffer containing the data for +// ** page iSrcPg from the source database. Copy this data into the +// ** destination database. +// */ +func _backupOnePage(tls *libc.TLS, p uintptr, iSrcPg TPgno, zSrcData uintptr, bUpdate int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDest TPgno + var iEnd, iOff Ti64 + var nCopy, nDestPgsz, nSrcPgsz, rc, v1, v3 int32 + var pDestPager, zDestData, zIn, zOut uintptr + var v5 bool + var _ /* pDestPg at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iDest, iEnd, iOff, nCopy, nDestPgsz, nSrcPgsz, pDestPager, rc, zDestData, zIn, zOut, v1, v3, v5 + pDestPager = _sqlite3BtreePager(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest) + nSrcPgsz = _sqlite3BtreeGetPageSize(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc) + nDestPgsz = _sqlite3BtreeGetPageSize(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest) + if nSrcPgsz < nDestPgsz { + v1 = nSrcPgsz + } else { + v1 = nDestPgsz + } + nCopy = v1 + iEnd = libc.Int64FromUint32(iSrcPg) * int64(nSrcPgsz) + rc = SQLITE_OK + /* This loop runs once for each destination page spanned by the source + ** page. For each iteration, variable iOff is set to the byte offset + ** of the destination page. + */ + iOff = iEnd - int64(nSrcPgsz) + for { + if !(rc == SQLITE_OK && iOff < iEnd) { + break + } + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + iDest = libc.Uint32FromInt64(iOff/int64(nDestPgsz)) + uint32(1) + if iDest == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize+libc.Uint32FromInt32(1) { + goto _2 + } + v1 = _sqlite3PagerGet(tls, pDestPager, iDest, bp, 0) + rc = v1 + if v5 = SQLITE_OK == v1; v5 { + v3 = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp))) + rc = v3 + } + if v5 && SQLITE_OK == v3 { + zIn = zSrcData + uintptr(iOff%int64(nSrcPgsz)) + zDestData = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + zOut = zDestData + uintptr(iOff%int64(nDestPgsz)) + /* Copy the data from the source page into the destination page. + ** Then clear the Btree layer MemPage.isInit flag. Both this module + ** and the pager code use this trick (clearing the first byte + ** of the page 'extra' space to invalidate the Btree layers + ** cached parse of the page). MemPage.isInit is marked + ** "MUST BE FIRST" for this purpose. + */ + libc.X__builtin___memcpy_chk(tls, zOut, zIn, libc.Uint64FromInt32(nCopy), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up(_sqlite3PagerGetExtra(tls, **(**uintptr)(__ccgo_up(bp))))) = uint8(0) + if iOff == 0 && bUpdate == 0 { + _sqlite3Put4byte(tls, zOut+28, _sqlite3BtreeLastPage(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc)) + } + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + goto _2 + _2: + ; + iOff = iOff + int64(nDestPgsz) + } + return rc +} + +// C documentation +// +// /* +// ** This function is called when the root page of a b-tree structure is +// ** overfull (has one or more overflow pages). +// ** +// ** A new child page is allocated and the contents of the current root +// ** page, including overflow cells, are copied into the child. The root +// ** page is then overwritten to make it an empty page with the right-child +// ** pointer pointing to the new page. +// ** +// ** Before returning, all pointer-map entries corresponding to pages +// ** that the new child-page now contains pointers to are updated. The +// ** entry corresponding to the new right-child pointer of the root +// ** page is also updated. +// ** +// ** If successful, *ppChild is set to contain a reference to the child +// ** page and SQLITE_OK is returned. In this case the caller is required +// ** to call releasePage() on *ppChild exactly once. If an error occurs, +// ** an error code is returned and *ppChild is set to 0. +// */ +func _balance_deeper(tls *libc.TLS, pRoot uintptr, ppChild uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pBt uintptr + var _ /* pChild at bp+8 */ uintptr + var _ /* pgnoChild at bp+16 */ TPgno + var _ /* rc at bp+0 */ int32 + _ = pBt /* Return value from subprocedures */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Pointer to a new child page */ + **(**TPgno)(__ccgo_up(bp + 16)) = uint32(0) /* Page number of the new child page */ + pBt = (*TMemPage)(unsafe.Pointer(pRoot)).FpBt /* The BTree */ + /* Make pRoot, the root page of the b-tree, writable. Allocate a new + ** page that will become the new right-child of pPage. Copy the contents + ** of the node stored on pRoot into the new child page. + */ + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pRoot)).FpDbPage) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _allocateBtreePage(tls, pBt, bp+8, bp+16, (*TMemPage)(unsafe.Pointer(pRoot)).Fpgno, uint8(0)) + _copyNodeContent(tls, pRoot, **(**uintptr)(__ccgo_up(bp + 8)), bp) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _ptrmapPut(tls, pBt, **(**TPgno)(__ccgo_up(bp + 16)), uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(pRoot)).Fpgno, bp) + } + } + if **(**int32)(__ccgo_up(bp)) != 0 { + **(**uintptr)(__ccgo_up(ppChild)) = uintptr(0) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return **(**int32)(__ccgo_up(bp)) + } + /* Copy the overflow cells from pRoot to pChild */ + libc.X__builtin___memcpy_chk(tls, **(**uintptr)(__ccgo_up(bp + 8))+28, pRoot+28, uint64((*TMemPage)(unsafe.Pointer(pRoot)).FnOverflow)*uint64(2), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, **(**uintptr)(__ccgo_up(bp + 8))+40, pRoot+40, uint64((*TMemPage)(unsafe.Pointer(pRoot)).FnOverflow)*uint64(8), ^t__predefined_size_t(0)) + (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FnOverflow = (*TMemPage)(unsafe.Pointer(pRoot)).FnOverflow + /* Zero the contents of pRoot. Then install pChild as the right-child. */ + _zeroPage(tls, pRoot, libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData))) & ^libc.Int32FromInt32(PTF_LEAF)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pRoot)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pRoot)).FhdrOffset)+int32(8)), **(**TPgno)(__ccgo_up(bp + 16))) + **(**uintptr)(__ccgo_up(ppChild)) = **(**uintptr)(__ccgo_up(bp + 8)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This routine redistributes cells on the iParentIdx'th child of pParent +// ** (hereafter "the page") and up to 2 siblings so that all pages have about the +// ** same amount of free space. Usually a single sibling on either side of the +// ** page are used in the balancing, though both siblings might come from one +// ** side if the page is the first or last child of its parent. If the page +// ** has fewer than 2 siblings (something which can only happen if the page +// ** is a root page or a child of a root page) then all available siblings +// ** participate in the balancing. +// ** +// ** The number of siblings of the page might be increased or decreased by +// ** one or two in an effort to keep pages nearly full but not over full. +// ** +// ** Note that when this routine is called, some of the cells on the page +// ** might not actually be stored in MemPage.aData[]. This can happen +// ** if the page is overfull. This routine ensures that all cells allocated +// ** to the page and its siblings fit into MemPage.aData[] before returning. +// ** +// ** In the course of balancing the page and its siblings, cells may be +// ** inserted into or removed from the parent page (pParent). Doing so +// ** may cause the parent page to become overfull or underfull. If this +// ** happens, it is the responsibility of the caller to invoke the correct +// ** balancing routine to fix this problem (see the balance() routine). +// ** +// ** If this routine fails for any reason, it might leave the database +// ** in a corrupted state. So if this routine fails, the database should +// ** be rolled back. +// ** +// ** The third argument to this function, aOvflSpace, is a pointer to a +// ** buffer big enough to hold one page. If while inserting cells into the parent +// ** page (pParent) the parent page becomes overfull, this buffer is +// ** used to store the parent's overflow cells. Because this function inserts +// ** a maximum of four divider cells into the parent page, and the maximum +// ** size of a cell stored within an internal node is always less than 1/4 +// ** of the page-size, the aOvflSpace[] buffer is guaranteed to be large +// ** enough for all overflow cells. +// ** +// ** If aOvflSpace is set to a null pointer, this function returns +// ** SQLITE_NOMEM. +// */ +func _balance_nonroot(tls *libc.TLS, pParent uintptr, iParentIdx int32, aOvflSpace uintptr, isRoot int32, bBulk int32) (r1 int32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var aData, aSpace1, p, pBt, pCell, pCell1, pNew1, pNew2, pOld, pOld1, pOld2, pRight, pSrcEnd, pTemp, pTemp1, piCell, piEnd, v17 uintptr + var aPgno [5]TPgno + var apDiv [2]uintptr + var apNew [5]uintptr + var cntNew, cntOld [5]int32 + var cntOldNext, d, i, iB, iNew, iNew1, iOff, iOld, iOld1, iOvflSpace, iPg, iSpace1, j, k, leafData, limit, nMaxCells, nNew, nNewCell, nOld, nxDiv, pageFlags, r, sz1, sz2, szD, szLeft, szR, szRight, usableSpace, v1 int32 + var fgA, fgB, leafCorrection, maskPage, sz Tu16 + var key Tu32 + var pgnoA, pgnoB, pgnoTemp TPgno + var szScratch Tu64 + var v13, v14 bool + var v18 uint32 + var _ /* abDone at bp+60 */ [5]Tu8 + var _ /* apOld at bp+8 */ [3]uintptr + var _ /* b at bp+72 */ TCellArray + var _ /* info at bp+184 */ TCellInfo + var _ /* pNew at bp+176 */ uintptr + var _ /* pgno at bp+52 */ TPgno + var _ /* rc at bp+0 */ int32 + var _ /* szNew at bp+32 */ [5]int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, aPgno, aSpace1, apDiv, apNew, cntNew, cntOld, cntOldNext, d, fgA, fgB, i, iB, iNew, iNew1, iOff, iOld, iOld1, iOvflSpace, iPg, iSpace1, j, k, key, leafCorrection, leafData, limit, maskPage, nMaxCells, nNew, nNewCell, nOld, nxDiv, p, pBt, pCell, pCell1, pNew1, pNew2, pOld, pOld1, pOld2, pRight, pSrcEnd, pTemp, pTemp1, pageFlags, pgnoA, pgnoB, pgnoTemp, piCell, piEnd, r, sz, sz1, sz2, szD, szLeft, szR, szRight, szScratch, usableSpace, v1, v13, v14, v17, v18 /* The whole database */ + nMaxCells = 0 /* Allocated size of apCell, szCell, aFrom. */ + nNew = 0 /* Next divider slot in pParent->aCell[] */ + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Value of pPage->aData[0] */ + iSpace1 = 0 /* First unused byte of aSpace1[] */ + iOvflSpace = 0 /* Parsed information on cells being balanced */ + libc.X__builtin___memset_chk(tls, bp+60, 0, uint64(5), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+72, 0, libc.Uint64FromInt64(104)-libc.Uint64FromInt64(4), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp + 72 + 80 + uintptr(libc.Int32FromInt32(NB)*libc.Int32FromInt32(2)-libc.Int32FromInt32(1))*4)) = int32(0x7fffffff) + pBt = (*TMemPage)(unsafe.Pointer(pParent)).FpBt + /* At this point pParent may have at most one overflow cell. And if + ** this overflow cell is present, it must be the cell with + ** index iParentIdx. This scenario comes about when this function + ** is called (indirectly) from sqlite3BtreeDelete(). + */ + if !(aOvflSpace != 0) { + return int32(SQLITE_NOMEM) + } + /* Find the sibling pages to balance. Also locate the cells in pParent + ** that divide the siblings. An attempt is made to find NN siblings on + ** either side of pPage. More siblings are taken from one side, however, + ** if there are fewer than NN siblings on the other side. If pParent + ** has NB or fewer children then all children of pParent are taken. + ** + ** This loop also drops the divider cells from the parent page. This + ** way, the remainder of the function does not have to deal with any + ** overflow cells in the parent page, since if any existed they will + ** have already been removed. + */ + i = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FnOverflow) + libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FnCell) + if i < int32(2) { + nxDiv = 0 + } else { + if iParentIdx == 0 { + nxDiv = 0 + } else { + if iParentIdx == i { + nxDiv = i - int32(2) + bBulk + } else { + nxDiv = iParentIdx - int32(1) + } + } + i = int32(2) - bBulk + } + nOld = i + int32(1) + if i+nxDiv-libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FnOverflow) == libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FnCell) { + pRight = (*TMemPage)(unsafe.Pointer(pParent)).FaData + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FhdrOffset)+int32(8)) + } else { + pRight = (*TMemPage)(unsafe.Pointer(pParent)).FaData + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pParent)).FaCellIdx + uintptr(int32(2)*(i+nxDiv-libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FnOverflow))))))< 0 { + if limit < libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pOld + 28))) { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81599)) + goto balance_cleanup + } + limit = libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pOld + 28))) + j = 0 + for { + if !(j < limit) { + break + } + **(**uintptr)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FapCell + uintptr((**(**TCellArray)(__ccgo_up(bp + 72))).FnCell)*8)) = aData + uintptr(libc.Int32FromUint16(maskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(piCell)))< usableSpace { + if i+int32(1) >= k { + k = i + int32(2) + if k > libc.Int32FromInt32(NB)+libc.Int32FromInt32(2) { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81700)) + goto balance_cleanup + } + (**(**[5]int32)(__ccgo_up(bp + 32)))[k-int32(1)] = 0 + cntNew[k-int32(1)] = (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell + } + sz1 = int32(2) + libc.Int32FromUint16(_cachedCellSize(tls, bp+72, cntNew[i]-int32(1))) + **(**int32)(__ccgo_up(bp + 32 + uintptr(i)*4)) -= sz1 + if !(leafData != 0) { + if cntNew[i] < (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell { + sz1 = int32(2) + libc.Int32FromUint16(_cachedCellSize(tls, bp+72, cntNew[i])) + } else { + sz1 = 0 + } + } + **(**int32)(__ccgo_up(bp + 32 + uintptr(i+int32(1))*4)) += sz1 + cntNew[i] = cntNew[i] - 1 + } + for cntNew[i] < (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell { + sz1 = int32(2) + libc.Int32FromUint16(_cachedCellSize(tls, bp+72, cntNew[i])) + if (**(**[5]int32)(__ccgo_up(bp + 32)))[i]+sz1 > usableSpace { + break + } + **(**int32)(__ccgo_up(bp + 32 + uintptr(i)*4)) += sz1 + cntNew[i] = cntNew[i] + 1 + if !(leafData != 0) { + if cntNew[i] < (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell { + sz1 = int32(2) + libc.Int32FromUint16(_cachedCellSize(tls, bp+72, cntNew[i])) + } else { + sz1 = 0 + } + } + **(**int32)(__ccgo_up(bp + 32 + uintptr(i+int32(1))*4)) -= sz1 + } + if cntNew[i] >= (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell { + k = i + int32(1) + } else { + if i > 0 { + v1 = cntNew[i-int32(1)] + } else { + v1 = 0 + } + if cntNew[i] <= v1 { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81733)) + goto balance_cleanup + } + } + goto _9 + _9: + ; + i = i + 1 + } + /* + ** The packing computed by the previous block is biased toward the siblings + ** on the left side (siblings with smaller keys). The left siblings are + ** always nearly full, while the right-most sibling might be nearly empty. + ** The next block of code attempts to adjust the packing of siblings to + ** get a better balance. + ** + ** This adjustment is more than an optimization. The packing above might + ** be so out of balance as to be illegal. For example, the right-most + ** sibling might be completely empty. This adjustment is not optional. + */ + i = k - int32(1) + for { + if !(i > 0) { + break + } + szRight = (**(**[5]int32)(__ccgo_up(bp + 32)))[i] /* Size of sibling on the right */ + szLeft = (**(**[5]int32)(__ccgo_up(bp + 32)))[i-int32(1)] /* Index of first cell to the left of right sibling */ + r = cntNew[i-int32(1)] - int32(1) + d = r + int32(1) - leafData + _cachedCellSize(tls, bp+72, d) + for cond := true; cond; cond = r >= 0 { + szR = libc.Int32FromUint16(_cachedCellSize(tls, bp+72, r)) + szD = libc.Int32FromUint16(**(**Tu16)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FszCell + uintptr(d)*2))) + if v14 = szRight != 0; v14 { + if v13 = bBulk != 0; !v13 { + if i == k-int32(1) { + v1 = 0 + } else { + v1 = int32(2) + } + } + } + if v14 && (v13 || szRight+szD+int32(2) > szLeft-(szR+v1)) { + break + } + szRight = szRight + (szD + int32(2)) + szLeft = szLeft - (szR + int32(2)) + cntNew[i-int32(1)] = r + r = r - 1 + d = d - 1 + } + (**(**[5]int32)(__ccgo_up(bp + 32)))[i] = szRight + (**(**[5]int32)(__ccgo_up(bp + 32)))[i-int32(1)] = szLeft + if i > int32(1) { + v1 = cntNew[i-int32(2)] + } else { + v1 = 0 + } + if cntNew[i-int32(1)] <= v1 { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81777)) + goto balance_cleanup + } + goto _11 + _11: + ; + i = i - 1 + } + /* Sanity check: For a non-corrupt database file one of the following + ** must be true: + ** (1) We found one or more cells (cntNew[0])>0), or + ** (2) pPage is a virtual root page. A virtual root page is when + ** the real root page is page 1 and we are the only child of + ** that page. + */ + /* + ** Allocate k new pages. Reuse old pages where possible. + */ + pageFlags = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer((**(**[3]uintptr)(__ccgo_up(bp + 8)))[0])).FaData))) + i = 0 + for { + if !(i < k) { + break + } + if i < nOld { + v17 = (**(**[3]uintptr)(__ccgo_up(bp + 8)))[i] + apNew[i] = v17 + **(**uintptr)(__ccgo_up(bp + 176)) = v17 + (**(**[3]uintptr)(__ccgo_up(bp + 8)))[i] = uintptr(0) + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 176)))).FpDbPage) + nNew = nNew + 1 + if _sqlite3PagerPageRefcount(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 176)))).FpDbPage) != int32(1)+libc.BoolInt32(i == iParentIdx-nxDiv) && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81810)) + } + if **(**int32)(__ccgo_up(bp)) != 0 { + goto balance_cleanup + } + } else { + if bBulk != 0 { + v18 = uint32(1) + } else { + v18 = **(**TPgno)(__ccgo_up(bp + 52)) + } + **(**int32)(__ccgo_up(bp)) = _allocateBtreePage(tls, pBt, bp+176, bp+52, v18, uint8(0)) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto balance_cleanup + } + _zeroPage(tls, **(**uintptr)(__ccgo_up(bp + 176)), pageFlags) + apNew[i] = **(**uintptr)(__ccgo_up(bp + 176)) + nNew = nNew + 1 + cntOld[i] = (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell + /* Set the pointer-map entry for the new sibling page. */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _ptrmapPut(tls, pBt, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 176)))).Fpgno, uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(pParent)).Fpgno, bp) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto balance_cleanup + } + } + } + goto _16 + _16: + ; + i = i + 1 + } + /* + ** Reassign page numbers so that the new pages are in ascending order. + ** This helps to keep entries in the disk file in order so that a scan + ** of the table is closer to a linear scan through the file. That in turn + ** helps the operating system to deliver pages from the disk more rapidly. + ** + ** An O(N*N) sort algorithm is used, but since N is never more than NB+2 + ** (5), that is not a performance concern. + ** + ** When NB==3, this one optimization makes the database about 25% faster + ** for large insertions and deletions. + */ + i = 0 + for { + if !(i < nNew) { + break + } + aPgno[i] = (*TMemPage)(unsafe.Pointer(apNew[i])).Fpgno + goto _19 + _19: + ; + i = i + 1 + } + i = 0 + for { + if !(i < nNew-int32(1)) { + break + } + iB = i + j = i + int32(1) + for { + if !(j < nNew) { + break + } + if (*TMemPage)(unsafe.Pointer(apNew[j])).Fpgno < (*TMemPage)(unsafe.Pointer(apNew[iB])).Fpgno { + iB = j + } + goto _21 + _21: + ; + j = j + 1 + } + /* If apNew[i] has a page number that is bigger than any of the + ** subsequence apNew[i] entries, then swap apNew[i] with the subsequent + ** entry that has the smallest page number (which we know to be + ** entry apNew[iB]). + */ + if iB != i { + pgnoA = (*TMemPage)(unsafe.Pointer(apNew[i])).Fpgno + pgnoB = (*TMemPage)(unsafe.Pointer(apNew[iB])).Fpgno + pgnoTemp = libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize + uint32(1) + fgA = (*TDbPage)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(apNew[i])).FpDbPage)).Fflags + fgB = (*TDbPage)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(apNew[iB])).FpDbPage)).Fflags + _sqlite3PagerRekey(tls, (*TMemPage)(unsafe.Pointer(apNew[i])).FpDbPage, pgnoTemp, fgB) + _sqlite3PagerRekey(tls, (*TMemPage)(unsafe.Pointer(apNew[iB])).FpDbPage, pgnoA, fgA) + _sqlite3PagerRekey(tls, (*TMemPage)(unsafe.Pointer(apNew[i])).FpDbPage, pgnoB, fgB) + (*TMemPage)(unsafe.Pointer(apNew[i])).Fpgno = pgnoB + (*TMemPage)(unsafe.Pointer(apNew[iB])).Fpgno = pgnoA + } + goto _20 + _20: + ; + i = i + 1 + } + _sqlite3Put4byte(tls, pRight, (*TMemPage)(unsafe.Pointer(apNew[nNew-int32(1)])).Fpgno) + /* If the sibling pages are not leaves, ensure that the right-child pointer + ** of the right-most new sibling page is set to the value that was + ** originally in the same field of the right-most old sibling page. */ + if pageFlags&int32(PTF_LEAF) == 0 && nOld != nNew { + if nNew > nOld { + pOld1 = apNew[nOld-int32(1)] + } else { + pOld1 = (**(**[3]uintptr)(__ccgo_up(bp + 8)))[nOld-int32(1)] + } + libc.X__builtin___memcpy_chk(tls, (*TMemPage)(unsafe.Pointer(apNew[nNew-int32(1)])).FaData+8, (*TMemPage)(unsafe.Pointer(pOld1)).FaData+8, uint64(4), ^t__predefined_size_t(0)) + } + /* Make any required updates to pointer map entries associated with + ** cells stored on sibling pages following the balance operation. Pointer + ** map entries associated with divider cells are set by the insertCell() + ** routine. The associated pointer map entries are: + ** + ** a) if the cell contains a reference to an overflow chain, the + ** entry associated with the first page in the overflow chain, and + ** + ** b) if the sibling pages are not leaves, the child page associated + ** with the cell. + ** + ** If the sibling pages are not leaves, then the pointer map entry + ** associated with the right-child of each sibling may also need to be + ** updated. This happens below, after the sibling pages have been + ** populated, not here. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + v17 = apNew[0] + pOld2 = v17 + pNew1 = v17 + cntOldNext = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pNew1)).FnCell) + libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pNew1)).FnOverflow) + iNew = 0 + iOld = 0 + i = 0 + for { + if !(i < (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell) { + break + } + pCell = **(**uintptr)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FapCell + uintptr(i)*8)) + for i == cntOldNext { + iOld = iOld + 1 + if iOld < nNew { + v17 = apNew[iOld] + } else { + v17 = (**(**[3]uintptr)(__ccgo_up(bp + 8)))[iOld] + } + pOld2 = v17 + cntOldNext = cntOldNext + (libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pOld2)).FnCell) + libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pOld2)).FnOverflow) + libc.BoolInt32(!(leafData != 0))) + } + if i == cntNew[iNew] { + iNew = iNew + 1 + v1 = iNew + pNew1 = apNew[v1] + if !(leafData != 0) { + goto _23 + } + } + /* Cell pCell is destined for new sibling page pNew. Originally, it + ** was either part of sibling page iOld (possibly an overflow cell), + ** or else the divider cell to the left of sibling page iOld. So, + ** if sibling page iOld had the same page number as pNew, and if + ** pCell really was a part of sibling page iOld (not a divider or + ** overflow cell), we can skip updating the pointer map entries. */ + if iOld >= nNew || (*TMemPage)(unsafe.Pointer(pNew1)).Fpgno != aPgno[iOld] || !(uint64(pCell) >= uint64((*TMemPage)(unsafe.Pointer(pOld2)).FaData) && uint64(pCell) < uint64((*TMemPage)(unsafe.Pointer(pOld2)).FaDataEnd)) { + if !(leafCorrection != 0) { + _ptrmapPut(tls, pBt, _sqlite3Get4byte(tls, pCell), uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(pNew1)).Fpgno, bp) + } + if libc.Int32FromUint16(_cachedCellSize(tls, bp+72, i)) > libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pNew1)).FminLocal) { + _ptrmapPutOvflPtr(tls, pNew1, pOld2, pCell, bp) + } + if **(**int32)(__ccgo_up(bp)) != 0 { + goto balance_cleanup + } + } + goto _23 + _23: + ; + i = i + 1 + } + } + /* Insert new divider cells into pParent. */ + i = 0 + for { + if !(i < nNew-int32(1)) { + break + } + pNew2 = apNew[i] + j = cntNew[i] + pCell1 = **(**uintptr)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FapCell + uintptr(j)*8)) + sz2 = libc.Int32FromUint16(**(**Tu16)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FszCell + uintptr(j)*2))) + libc.Int32FromUint16(leafCorrection) + pTemp1 = aOvflSpace + uintptr(iOvflSpace) + if !((*TMemPage)(unsafe.Pointer(pNew2)).Fleaf != 0) { + libc.X__builtin___memcpy_chk(tls, (*TMemPage)(unsafe.Pointer(pNew2)).FaData+8, pCell1, uint64(4), ^t__predefined_size_t(0)) + } else { + if leafData != 0 { + j = j - 1 + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pNew2)).FxParseCell})))(tls, pNew2, **(**uintptr)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FapCell + uintptr(j)*8)), bp+184) + pCell1 = pTemp1 + sz2 = int32(4) + _sqlite3PutVarint(tls, pCell1+4, libc.Uint64FromInt64((**(**TCellInfo)(__ccgo_up(bp + 184))).FnKey)) + pTemp1 = uintptr(0) + } else { + pCell1 = pCell1 - uintptr(4) + /* Obscure case for non-leaf-data trees: If the cell at pCell was + ** previously stored on a leaf node, and its reported size was 4 + ** bytes, then it may actually be smaller than this + ** (see btreeParseCellPtr(), 4 bytes is the minimum size of + ** any cell). But it is important to pass the correct size to + ** insertCell(), so reparse the cell now. + ** + ** This can only happen for b-trees used to evaluate "IN (SELECT ...)" + ** and WITHOUT ROWID tables with exactly one column which is the + ** primary key. + */ + if libc.Int32FromUint16(**(**Tu16)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FszCell + uintptr(j)*2))) == int32(4) { + sz2 = libc.Int32FromUint16((*(*func(*libc.TLS, uintptr, uintptr) Tu16)(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pParent)).FxCellSize})))(tls, pParent, pCell1)) + } + } + } + iOvflSpace = iOvflSpace + sz2 + k = 0 + for { + if !(**(**int32)(__ccgo_up(bp + 72 + 80 + uintptr(k)*4)) <= j) { + break + } + goto _27 + _27: + ; + k = k + 1 + } + pSrcEnd = **(**uintptr)(__ccgo_up(bp + 72 + 32 + uintptr(k)*8)) + if uint64(pCell1) < uint64(pSrcEnd) && uint64(pCell1+uintptr(sz2)) > uint64(pSrcEnd) { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(82016)) + goto balance_cleanup + } + **(**int32)(__ccgo_up(bp)) = _insertCell(tls, pParent, nxDiv+i, pCell1, sz2, pTemp1, (*TMemPage)(unsafe.Pointer(pNew2)).Fpgno) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto balance_cleanup + } + goto _26 + _26: + ; + i = i + 1 + } + /* Now update the actual sibling pages. The order in which they are updated + ** is important, as this code needs to avoid disrupting any page from which + ** cells may still to be read. In practice, this means: + ** + ** (1) If cells are moving left (from apNew[iPg] to apNew[iPg-1]) + ** then it is not safe to update page apNew[iPg] until after + ** the left-hand sibling apNew[iPg-1] has been updated. + ** + ** (2) If cells are moving right (from apNew[iPg] to apNew[iPg+1]) + ** then it is not safe to update page apNew[iPg] until after + ** the right-hand sibling apNew[iPg+1] has been updated. + ** + ** If neither of the above apply, the page is safe to update. + ** + ** The iPg value in the following loop starts at nNew-1 goes down + ** to 0, then back up to nNew-1 again, thus making two passes over + ** the pages. On the initial downward pass, only condition (1) above + ** needs to be tested because (2) will always be true from the previous + ** step. On the upward pass, both conditions are always true, so the + ** upwards pass simply processes pages that were missed on the downward + ** pass. + */ + i = int32(1) - nNew + for { + if !(i < nNew) { + break + } + if i < 0 { + v1 = -i + } else { + v1 = i + } + iPg = v1 + if (**(**[5]Tu8)(__ccgo_up(bp + 60)))[iPg] != 0 { + goto _28 + } /* Skip pages already processed */ + if i >= 0 || cntOld[iPg-int32(1)] >= cntNew[iPg-int32(1)] { + /* Verify condition (1): If cells are moving left, update iPg + ** only after iPg-1 has already been updated. */ + /* Verify condition (2): If cells are moving right, update iPg + ** only after iPg+1 has already been updated. */ + if iPg == 0 { + v1 = libc.Int32FromInt32(0) + iOld1 = v1 + iNew1 = v1 + nNewCell = cntNew[0] + } else { + if iPg < nOld { + v1 = cntOld[iPg-int32(1)] + libc.BoolInt32(!(leafData != 0)) + } else { + v1 = (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell + } + iOld1 = v1 + iNew1 = cntNew[iPg-int32(1)] + libc.BoolInt32(!(leafData != 0)) + nNewCell = cntNew[iPg] - iNew1 + } + **(**int32)(__ccgo_up(bp)) = _editPage(tls, apNew[iPg], iOld1, iNew1, nNewCell, bp+72) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto balance_cleanup + } + (**(**[5]Tu8)(__ccgo_up(bp + 60)))[iPg] = (**(**[5]Tu8)(__ccgo_up(bp + 60)))[iPg] + 1 + (*TMemPage)(unsafe.Pointer(apNew[iPg])).FnFree = usableSpace - (**(**[5]int32)(__ccgo_up(bp + 32)))[iPg] + } + goto _28 + _28: + ; + i = i + 1 + } + /* All pages have been processed exactly once */ + if isRoot != 0 && libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FnCell) == 0 && libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FhdrOffset) <= (*TMemPage)(unsafe.Pointer(apNew[0])).FnFree { + /* The root page of the b-tree now contains no cells. The only sibling + ** page is the right-child of the parent. Copy the contents of the + ** child page into the parent, decreasing the overall height of the + ** b-tree structure by one. This is described as the "balance-shallower" + ** sub-algorithm in some documentation. + ** + ** If this is an auto-vacuum database, the call to copyNodeContent() + ** sets all pointer-map entries corresponding to database image pages + ** for which the pointer is stored within the content being copied. + ** + ** It is critical that the child page be defragmented before being + ** copied into the parent, because if the parent is page 1 then it will + ** by smaller than the child due to the database header, and so all the + ** free space needs to be up front. + */ + **(**int32)(__ccgo_up(bp)) = _defragmentPage(tls, apNew[0], -int32(1)) + _copyNodeContent(tls, apNew[0], pParent, bp) + _freePage(tls, apNew[0], bp) + } else { + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && !(leafCorrection != 0) { + /* Fix the pointer map entries associated with the right-child of each + ** sibling page. All other pointer map entries have already been taken + ** care of. */ + i = 0 + for { + if !(i < nNew) { + break + } + key = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(apNew[i])).FaData+8) + _ptrmapPut(tls, pBt, key, uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(apNew[i])).Fpgno, bp) + goto _32 + _32: + ; + i = i + 1 + } + } + } + /* Free any old pages that were not reused as new pages. + */ + i = nNew + for { + if !(i < nOld) { + break + } + _freePage(tls, (**(**[3]uintptr)(__ccgo_up(bp + 8)))[i], bp) + goto _33 + _33: + ; + i = i + 1 + } + /* + ** Cleanup before returning. + */ + goto balance_cleanup +balance_cleanup: + ; + _sqlite3DbFree(tls, uintptr(0), (**(**TCellArray)(__ccgo_up(bp + 72))).FapCell) + i = 0 + for { + if !(i < nOld) { + break + } + _releasePage(tls, (**(**[3]uintptr)(__ccgo_up(bp + 8)))[i]) + goto _34 + _34: + ; + i = i + 1 + } + i = 0 + for { + if !(i < nNew) { + break + } + _releasePage(tls, apNew[i]) + goto _35 + _35: + ; + i = i + 1 + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This function is used by both blob_open() and blob_reopen(). It seeks +// ** the b-tree cursor associated with blob handle p to point to row iRow. +// ** If successful, SQLITE_OK is returned and subsequent calls to +// ** sqlite3_blob_read() or sqlite3_blob_write() access the specified row. +// ** +// ** If an error occurs, or if the specified row does not exist or does not +// ** contain a value of type TEXT or BLOB in the column nominated when the +// ** blob handle was opened, then an error code is returned and *pzErr may +// ** be set to point to a buffer containing an error message. It is the +// ** responsibility of the caller to free the error message buffer using +// ** sqlite3DbFree(). +// ** +// ** If an error does occur, then the b-tree cursor is closed. All subsequent +// ** calls to sqlite3_blob_read(), blob_write() or blob_reopen() will +// ** immediately return SQLITE_ABORT. +// */ +func _blobSeekToRow(tls *libc.TLS, p uintptr, iRow Tsqlite3_int64, pzErr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pC, v, zErr, v2, v3 uintptr + var rc int32 + var type1 Tu32 + var v1 uint32 + _, _, _, _, _, _, _, _ = pC, rc, type1, v, zErr, v1, v2, v3 /* Error code */ + zErr = uintptr(0) /* Error message */ + v = (*TIncrblob)(unsafe.Pointer(p)).FpStmt + /* Set the value of register r[1] in the SQL statement to integer iRow. + ** This is done directly as a performance optimization + */ + _sqlite3VdbeMemSetInt64(tls, (*TVdbe)(unsafe.Pointer(v)).FaMem+1*56, iRow) + /* If the statement has been run before (and is paused at the OP_ResultRow) + ** then back it up to the point where it does the OP_NotExists. This could + ** have been down with an extra OP_Goto, but simply setting the program + ** counter is faster. */ + if (*TVdbe)(unsafe.Pointer(v)).Fpc > int32(4) { + (*TVdbe)(unsafe.Pointer(v)).Fpc = int32(4) + rc = _sqlite3VdbeExec(tls, v) + } else { + rc = Xsqlite3_step(tls, (*TIncrblob)(unsafe.Pointer(p)).FpStmt) + } + if rc == int32(SQLITE_ROW) { + pC = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(v)).FapCsr)) + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) > libc.Int32FromUint16((*TIncrblob)(unsafe.Pointer(p)).FiCol) { + v1 = *(*Tu32)(unsafe.Pointer(pC + 120 + uintptr((*TIncrblob)(unsafe.Pointer(p)).FiCol)*4)) + } else { + v1 = uint32(0) + } + type1 = v1 + if type1 < uint32(12) { + if type1 == uint32(0) { + v2 = __ccgo_ts + 1688 + } else { + if type1 == uint32(7) { + v3 = __ccgo_ts + 6831 + } else { + v3 = __ccgo_ts + 6836 + } + v2 = v3 + } + zErr = _sqlite3MPrintf(tls, (*TIncrblob)(unsafe.Pointer(p)).Fdb, __ccgo_ts+6844, libc.VaList(bp+8, v2)) + rc = int32(SQLITE_ERROR) + Xsqlite3_finalize(tls, (*TIncrblob)(unsafe.Pointer(p)).FpStmt) + (*TIncrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) + } else { + (*TIncrblob)(unsafe.Pointer(p)).FiOffset = libc.Int32FromUint32(*(*Tu32)(unsafe.Pointer(pC + 120 + uintptr(libc.Int32FromUint16((*TIncrblob)(unsafe.Pointer(p)).FiCol)+int32((*TVdbeCursor)(unsafe.Pointer(pC)).FnField))*4))) + (*TIncrblob)(unsafe.Pointer(p)).FnByte = libc.Int32FromUint32(_sqlite3VdbeSerialTypeLen(tls, type1)) + (*TIncrblob)(unsafe.Pointer(p)).FpCsr = *(*uintptr)(unsafe.Pointer(pC + 48)) + _sqlite3BtreeIncrblobCursor(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr) + } + } + if rc == int32(SQLITE_ROW) { + rc = SQLITE_OK + } else { + if (*TIncrblob)(unsafe.Pointer(p)).FpStmt != 0 { + rc = Xsqlite3_finalize(tls, (*TIncrblob)(unsafe.Pointer(p)).FpStmt) + (*TIncrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) + if rc == SQLITE_OK { + zErr = _sqlite3MPrintf(tls, (*TIncrblob)(unsafe.Pointer(p)).Fdb, __ccgo_ts+6873, libc.VaList(bp+8, iRow)) + rc = int32(SQLITE_ERROR) + } else { + zErr = _sqlite3MPrintf(tls, (*TIncrblob)(unsafe.Pointer(p)).Fdb, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, (*TIncrblob)(unsafe.Pointer(p)).Fdb))) + } + } + } + **(**uintptr)(__ccgo_up(pzErr)) = zErr + return rc +} + +// C documentation +// +// /* Overwrite content from pX into pDest. Only do the write if the +// ** content is different from what is already there. +// */ +func _btreeOverwriteContent(tls *libc.TLS, pPage uintptr, pDest uintptr, pX uintptr, iOffset int32, iAmt int32) (r int32) { + var i, nData, rc, rc1, rc2 int32 + _, _, _, _, _ = i, nData, rc, rc1, rc2 + nData = (*TBtreePayload)(unsafe.Pointer(pX)).FnData - iOffset + if nData <= 0 { + i = 0 + for { + if !(i < iAmt && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pDest + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i < iAmt { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if rc != 0 { + return rc + } + libc.X__builtin___memset_chk(tls, pDest+uintptr(i), 0, libc.Uint64FromInt32(iAmt-i), ^t__predefined_size_t(0)) + } + } else { + if nData < iAmt { + /* Mixed read data and zeros at the end. Make a recursive call + ** to write the zeros then fall through to write the real data */ + rc1 = _btreeOverwriteContent(tls, pPage, pDest+uintptr(nData), pX, iOffset+nData, iAmt-nData) + if rc1 != 0 { + return rc1 + } + iAmt = nData + } + if libc.Xmemcmp(tls, pDest, (*TBtreePayload)(unsafe.Pointer(pX)).FpData+uintptr(iOffset), libc.Uint64FromInt32(iAmt)) != 0 { + rc2 = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if rc2 != 0 { + return rc2 + } + /* In a corrupt database, it is possible for the source and destination + ** buffers to overlap. This is harmless since the database is already + ** corrupt but it does cause valgrind and ASAN warnings. So use + ** memmove(). */ + libc.X__builtin___memmove_chk(tls, pDest, (*TBtreePayload)(unsafe.Pointer(pX)).FpData+uintptr(iOffset), libc.Uint64FromInt32(iAmt), ^t__predefined_size_t(0)) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Check to see if the FROM clause term pFrom has table-valued function +// ** arguments. If it does, leave an error message in pParse and return +// ** non-zero, since pFrom is not allowed to be a table-valued function. +// */ +func _cannotBeFunction(tls *libc.TLS, pParse uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x8>>3) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21383, libc.VaList(bp+8, (*TSrcItem)(unsafe.Pointer(pFrom)).FzName)) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* The RFC-7539 ChaCha20 block function +// */ +func _chacha_block(tls *libc.TLS, out uintptr, in uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i int32 + var _ /* x at bp+0 */ [16]Tu32 + _ = i + libc.X__builtin___memcpy_chk(tls, bp, in, uint64(64), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < int32(10)) { + break + } + **(**Tu32)(__ccgo_up(bp)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] + **(**Tu32)(__ccgo_up(bp + 12*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[0] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 8*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] + **(**Tu32)(__ccgo_up(bp + 4*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(8)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] + **(**Tu32)(__ccgo_up(bp + 12*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[0] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 8*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] + **(**Tu32)(__ccgo_up(bp + 4*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(8)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 1*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] + **(**Tu32)(__ccgo_up(bp + 13*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(1)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 9*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] + **(**Tu32)(__ccgo_up(bp + 5*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(9)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 1*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] + **(**Tu32)(__ccgo_up(bp + 13*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(1)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 9*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] + **(**Tu32)(__ccgo_up(bp + 5*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(9)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 2*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] + **(**Tu32)(__ccgo_up(bp + 14*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(2)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 10*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] + **(**Tu32)(__ccgo_up(bp + 6*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(10)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 2*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] + **(**Tu32)(__ccgo_up(bp + 14*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(2)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 10*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] + **(**Tu32)(__ccgo_up(bp + 6*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(10)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 3*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] + **(**Tu32)(__ccgo_up(bp + 15*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(3)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 11*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] + **(**Tu32)(__ccgo_up(bp + 7*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(11)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 3*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] + **(**Tu32)(__ccgo_up(bp + 15*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(3)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 11*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] + **(**Tu32)(__ccgo_up(bp + 7*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(11)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] + **(**Tu32)(__ccgo_up(bp + 15*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[0] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 10*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] + **(**Tu32)(__ccgo_up(bp + 5*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(10)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] + **(**Tu32)(__ccgo_up(bp + 15*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[0] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 10*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] + **(**Tu32)(__ccgo_up(bp + 5*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(10)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 1*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] + **(**Tu32)(__ccgo_up(bp + 12*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(1)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 11*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] + **(**Tu32)(__ccgo_up(bp + 6*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(11)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 1*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] + **(**Tu32)(__ccgo_up(bp + 12*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(1)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 11*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] + **(**Tu32)(__ccgo_up(bp + 6*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(11)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 2*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] + **(**Tu32)(__ccgo_up(bp + 13*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(2)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 8*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] + **(**Tu32)(__ccgo_up(bp + 7*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(8)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 2*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] + **(**Tu32)(__ccgo_up(bp + 13*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(2)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 8*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] + **(**Tu32)(__ccgo_up(bp + 7*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(8)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 3*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] + **(**Tu32)(__ccgo_up(bp + 14*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(3)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 9*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] + **(**Tu32)(__ccgo_up(bp + 4*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(9)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 3*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] + **(**Tu32)(__ccgo_up(bp + 14*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(3)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 9*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] + **(**Tu32)(__ccgo_up(bp + 4*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(9)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < int32(16)) { + break + } + **(**Tu32)(__ccgo_up(out + uintptr(i)*4)) = (**(**[16]Tu32)(__ccgo_up(bp)))[i] + **(**Tu32)(__ccgo_up(in + uintptr(i)*4)) + goto _2 + _2: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Append a message to the error message string. +// */ +func _checkAppendMsg(tls *libc.TLS, pCheck uintptr, zFormat uintptr, va uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ap Tva_list + _ = ap + _checkProgress(tls, pCheck) + if !((*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0) { + return + } + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr - 1 + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr + 1 + ap = va + if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FnChar != 0 { + Xsqlite3_str_append(tls, pCheck+72, __ccgo_ts+4696, int32(1)) + } + if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx != 0 { + Xsqlite3_str_appendf(tls, pCheck+72, (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx, libc.VaList(bp+8, (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv0, (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv1, (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv2)) + } + Xsqlite3_str_vappendf(tls, pCheck+72, zFormat, ap) + _ = ap + if libc.Int32FromUint8((*TIntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FaccError) == int32(SQLITE_NOMEM) { + _checkOom(tls, pCheck) + } +} + +// C documentation +// +// /* +// ** Check the integrity of the freelist or of an overflow page list. +// ** Verify that the number of pages on the list is N. +// */ +func _checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage TPgno, N Tu32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var expected, n Tu32 + var i, nErrAtStart int32 + var iFreePage TPgno + var pOvflData, v2 uintptr + var _ /* pOvflPage at bp+0 */ uintptr + _, _, _, _, _, _, _ = expected, i, iFreePage, n, nErrAtStart, pOvflData, v2 + expected = N + nErrAtStart = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr + for iPage != uint32(0) && (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0 { + if _checkRef(tls, pCheck, iPage) != 0 { + break + } + N = N - 1 + if _sqlite3PagerGet(tls, (*TIntegrityCk)(unsafe.Pointer(pCheck)).FpPager, iPage, bp, 0) != 0 { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4829, libc.VaList(bp+16, iPage)) + break + } + pOvflData = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + if isFreeList != 0 { + n = _sqlite3Get4byte(tls, pOvflData+4) + if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 { + _checkPtrmap(tls, pCheck, iPage, uint8(PTRMAP_FREEPAGE), uint32(0)) + } + if n > (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FusableSize/uint32(4)-uint32(2) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4851, libc.VaList(bp+16, iPage)) + N = N - 1 + } else { + i = 0 + for { + if !(i < libc.Int32FromUint32(n)) { + break + } + iFreePage = _sqlite3Get4byte(tls, pOvflData+uintptr(int32(8)+i*int32(4))) + if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 { + _checkPtrmap(tls, pCheck, iFreePage, uint8(PTRMAP_FREEPAGE), uint32(0)) + } + _checkRef(tls, pCheck, iFreePage) + goto _1 + _1: + ; + i = i + 1 + } + N = N - n + } + } else { + /* If this database supports auto-vacuum and iPage is not the last + ** page in this overflow list, check that the pointer-map entry for + ** the following page matches iPage. + */ + if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 && N > uint32(0) { + i = libc.Int32FromUint32(_sqlite3Get4byte(tls, pOvflData)) + _checkPtrmap(tls, pCheck, libc.Uint32FromInt32(i), uint8(PTRMAP_OVERFLOW2), iPage) + } + } + iPage = _sqlite3Get4byte(tls, pOvflData) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + } + if N != 0 && nErrAtStart == (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr { + if isFreeList != 0 { + v2 = __ccgo_ts + 4890 + } else { + v2 = __ccgo_ts + 4895 + } + _checkAppendMsg(tls, pCheck, __ccgo_ts+4916, libc.VaList(bp+16, v2, expected-N, expected)) + } +} + +// C documentation +// +// /* +// ** Check that the entry in the pointer-map for page iChild maps to +// ** page iParent, pointer type ptrType. If not, append an error message +// ** to pCheck. +// */ +func _checkPtrmap(tls *libc.TLS, pCheck uintptr, iChild TPgno, eType Tu8, iParent TPgno) { + bp := tls.Alloc(64) + defer tls.Free(64) + var rc int32 + var _ /* ePtrmapType at bp+0 */ Tu8 + var _ /* iPtrmapParent at bp+4 */ TPgno + _ = rc + rc = _ptrmapGet(tls, (*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt, iChild, bp, bp+4) + if rc != SQLITE_OK { + if rc == int32(SQLITE_NOMEM) || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<zErrMsg. +// ** Return 1 if there are 2 or more references to the page and 0 if +// ** if this is the first reference to the page. +// ** +// ** Also check that the page number is in bounds. +// */ +func _checkRef(tls *libc.TLS, pCheck uintptr, iPage TPgno) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if iPage > (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnCkPage || iPage == uint32(0) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4698, libc.VaList(bp+8, iPage)) + return int32(1) + } + if _getPageReferenced(tls, pCheck, iPage) != 0 { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4721, libc.VaList(bp+8, iPage)) + return int32(1) + } + _setPageReferenced(tls, pCheck, iPage) + return 0 +} + +// C documentation +// +// /* +// ** Do various sanity checks on a single page of a tree. Return +// ** the tree depth. Root pages return 0. Parents of root pages +// ** return 1, and so forth. +// ** +// ** These checks are done: +// ** +// ** 1. Make sure that cells and freeblocks do not overlap +// ** but combine to completely cover the page. +// ** 2. Make sure integer cell keys are in order. +// ** 3. Check the integrity of overflow pages. +// ** 4. Recursively call checkTreePage on all children. +// ** 5. Verify that the depth of all children is the same. +// */ +func _checkTreePage(tls *libc.TLS, pCheck uintptr, iPage TPgno, piMinKey uintptr, _maxKey Ti64) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + *(*Ti64)(unsafe.Pointer(bp)) = _maxKey + var cellStart, d2, depth, doCoverageCheck, hdr, i, j, keyCanBeEqual, nCell, nFrag, pgno, rc, saved_v1, saved_v2, size1, v1 int32 + var contentOffset, nPage, pc, prev, size, usableSize Tu32 + var data, heap, pBt, pCell, pCellIdx, saved_zPfx uintptr + var pgnoOvfl TPgno + var savedIsInit Tu8 + var _ /* info at bp+24 */ TCellInfo + var _ /* pPage at bp+8 */ uintptr + var _ /* x at bp+16 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cellStart, contentOffset, d2, data, depth, doCoverageCheck, hdr, heap, i, j, keyCanBeEqual, nCell, nFrag, nPage, pBt, pCell, pCellIdx, pc, pgno, pgnoOvfl, prev, rc, savedIsInit, saved_v1, saved_v2, saved_zPfx, size, size1, usableSize, v1 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Result code from subroutine call */ + depth = -int32(1) /* Number of cells */ + doCoverageCheck = int32(1) /* True if cell coverage checking should be done */ + keyCanBeEqual = int32(1) /* Offset to the start of the cell content area */ + heap = uintptr(0) + prev = uint32(0) /* Next and previous entry on the min-heap */ + saved_zPfx = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx + saved_v1 = libc.Int32FromUint32((*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv1) + saved_v2 = (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv2 + savedIsInit = uint8(0) + /* Check that the page exists + */ + _checkProgress(tls, pCheck) + if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr == 0 { + goto end_of_check + } + pBt = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt + usableSize = (*TBtShared)(unsafe.Pointer(pBt)).FusableSize + if iPage == uint32(0) { + return 0 + } + if _checkRef(tls, pCheck, iPage) != 0 { + return 0 + } + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = __ccgo_ts + 4942 + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv1 = iPage + v1 = _btreeGetPage(tls, pBt, iPage, bp+8, 0) + rc = v1 + if v1 != 0 { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4960, libc.VaList(bp+56, rc)) + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<= 0 && (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0) { + break + } + /* Check cell size */ + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv2 = i + pc = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pCellIdx)))< usableSize-uint32(4) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+5114, libc.VaList(bp+56, pc, contentOffset, usableSize-uint32(4))) + doCoverageCheck = 0 + goto _4 + } + pCell = data + uintptr(pc) + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FxParseCell})))(tls, **(**uintptr)(__ccgo_up(bp + 8)), pCell, bp+24) + if pc+uint32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnSize) > usableSize { + _checkAppendMsg(tls, pCheck, __ccgo_ts+5144, 0) + doCoverageCheck = 0 + goto _4 + } + /* Check for integer primary key out of range */ + if (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FintKey != 0 { + if keyCanBeEqual != 0 { + v1 = libc.BoolInt32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnKey > **(**Ti64)(__ccgo_up(bp))) + } else { + v1 = libc.BoolInt32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnKey >= **(**Ti64)(__ccgo_up(bp))) + } + if v1 != 0 { + _checkAppendMsg(tls, pCheck, __ccgo_ts+5168, libc.VaList(bp+56, (**(**TCellInfo)(__ccgo_up(bp + 24))).FnKey)) + } + **(**Ti64)(__ccgo_up(bp)) = (**(**TCellInfo)(__ccgo_up(bp + 24))).FnKey + keyCanBeEqual = 0 /* Only the first key on the page may ==maxKey */ + } + /* Check the content overflow list */ + if (**(**TCellInfo)(__ccgo_up(bp + 24))).FnPayload > uint32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnLocal) { /* First page of the overflow chain */ + nPage = ((**(**TCellInfo)(__ccgo_up(bp + 24))).FnPayload - uint32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnLocal) + usableSize - uint32(5)) / (usableSize - uint32(4)) + pgnoOvfl = _sqlite3Get4byte(tls, pCell+uintptr(libc.Int32FromUint16((**(**TCellInfo)(__ccgo_up(bp + 24))).FnSize)-int32(4))) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _checkPtrmap(tls, pCheck, pgnoOvfl, uint8(PTRMAP_OVERFLOW1), iPage) + } + _checkList(tls, pCheck, 0, pgnoOvfl, nPage) + } + if !((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).Fleaf != 0) { + /* Check sanity of left child page for internal pages */ + pgno = libc.Int32FromUint32(_sqlite3Get4byte(tls, pCell)) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _checkPtrmap(tls, pCheck, libc.Uint32FromInt32(pgno), uint8(PTRMAP_BTREE), iPage) + } + d2 = _checkTreePage(tls, pCheck, libc.Uint32FromInt32(pgno), bp, **(**Ti64)(__ccgo_up(bp))) + keyCanBeEqual = 0 + if d2 != depth { + _checkAppendMsg(tls, pCheck, __ccgo_ts+5192, 0) + depth = d2 + } + } else { + /* Populate the coverage-checking heap for leaf pages */ + _btreeHeapInsert(tls, heap, pc< 0 { + /* For leaf pages, the min-heap has already been initialized and the + ** cells have already been inserted. But for internal pages, that has + ** not yet been done, so do it now */ + if !((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).Fleaf != 0) { + heap = (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fheap + **(**Tu32)(__ccgo_up(heap)) = uint32(0) + i = nCell - int32(1) + for { + if !(i >= 0) { + break + } + pc = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(cellStart+i*int32(2)))))< 0 { + /* Enforced by btreeComputeFreeSpace() */ + size1 = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(i+int32(2)))))<= **(**Tu32)(__ccgo_up(bp + 16))>>libc.Int32FromInt32(16) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+5217, libc.VaList(bp+56, **(**Tu32)(__ccgo_up(bp + 16))>>int32(16), iPage)) + break + } else { + nFrag = libc.Int32FromUint32(uint32(nFrag) + (**(**Tu32)(__ccgo_up(bp + 16))>>libc.Int32FromInt32(16) - prev&libc.Uint32FromInt32(0xffff) - libc.Uint32FromInt32(1))) + prev = **(**Tu32)(__ccgo_up(bp + 16)) + } + } + nFrag = libc.Int32FromUint32(uint32(nFrag) + (usableSize - prev&libc.Uint32FromInt32(0xffff) - libc.Uint32FromInt32(1))) + /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments + ** is stored in the fifth field of the b-tree page header. + ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the + ** number of fragmented free bytes within the cell content area. + */ + if **(**Tu32)(__ccgo_up(heap)) == uint32(0) && nFrag != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(7))))) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+5254, libc.VaList(bp+56, nFrag, libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(7))))), iPage)) + } + } + goto end_of_check +end_of_check: + ; + if !(doCoverageCheck != 0) { + (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FisInit = savedIsInit + } + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = saved_zPfx + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv1 = libc.Uint32FromInt32(saved_v1) + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv2 = saved_v2 + return depth + int32(1) +} + +// C documentation +// +// /* +// ** This function performs the parts of the "close file" operation +// ** common to all locking schemes. It closes the directory and file +// ** handles, if they are valid, and sets all fields of the unixFile +// ** structure to 0. +// ** +// ** It is *not* necessary to hold the mutex when this routine is called, +// ** even on VxWorks. A mutex will be acquired on VxWorks by the +// ** vxworksReleaseFileId() routine. +// */ +func _closeUnixFile(tls *libc.TLS, id uintptr) (r int32) { + var pFile uintptr + _ = pFile + pFile = id + _unixUnmapfile(tls, pFile) + if (*TunixFile)(unsafe.Pointer(pFile)).Fh >= 0 { + _robust_close(tls, pFile, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(42499)) + (*TunixFile)(unsafe.Pointer(pFile)).Fh = -int32(1) + } + Xsqlite3_free(tls, (*TunixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused) + libc.X__builtin___memset_chk(tls, pFile, 0, uint64(128), ^t__predefined_size_t(0)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This procedure generates VDBE code for a single invocation of either the +// ** sqlite_detach() or sqlite_attach() SQL user functions. +// */ +func _codeAttach(tls *libc.TLS, pParse uintptr, type1 int32, pFunc uintptr, pAuthArg uintptr, pFilename uintptr, pDbname uintptr, pKey uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, v, zAuthArg uintptr + var rc, regArgs int32 + var _ /* sName at bp+0 */ TNameContext + _, _, _, _, _ = db, rc, regArgs, v, zAuthArg + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto attach_end + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto attach_end + } + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + if SQLITE_OK != _resolveAttachExpr(tls, bp, pFilename) || SQLITE_OK != _resolveAttachExpr(tls, bp, pDbname) || SQLITE_OK != _resolveAttachExpr(tls, bp, pKey) { + goto attach_end + } + if pAuthArg != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pAuthArg)).Fop) == int32(TK_STRING) { + zAuthArg = *(*uintptr)(unsafe.Pointer(pAuthArg + 8)) + } else { + zAuthArg = uintptr(0) + } + rc = _sqlite3AuthCheck(tls, pParse, type1, zAuthArg, uintptr(0), uintptr(0)) + if rc != SQLITE_OK { + goto attach_end + } + } + v = _sqlite3GetVdbe(tls, pParse) + regArgs = _sqlite3GetTempRange(tls, pParse, int32(4)) + _sqlite3ExprCode(tls, pParse, pFilename, regArgs) + _sqlite3ExprCode(tls, pParse, pDbname, regArgs+int32(1)) + _sqlite3ExprCode(tls, pParse, pKey, regArgs+int32(2)) + if v != 0 { + _sqlite3VdbeAddFunctionCall(tls, pParse, 0, regArgs+int32(3)-int32((*TFuncDef)(unsafe.Pointer(pFunc)).FnArg), regArgs+int32(3), int32((*TFuncDef)(unsafe.Pointer(pFunc)).FnArg), pFunc, 0) + /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this + ** statement only). For DETACH, set it to false (expire all existing + ** statements). + */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_Expire), libc.BoolInt32(type1 == int32(SQLITE_ATTACH))) + } + goto attach_end +attach_end: + ; + _sqlite3ExprDelete(tls, db, pFilename) + _sqlite3ExprDelete(tls, db, pDbname) + _sqlite3ExprDelete(tls, db, pKey) +} + +// C documentation +// +// /* +// ** Generate an instruction that will put the integer describe by +// ** text z[0..n-1] into register iMem. +// ** +// ** Expr.u.zToken is always UTF8 and zero-terminated. +// */ +func _codeInteger(tls *libc.TLS, pParse uintptr, pExpr uintptr, negFlag int32, iMem int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, i int32 + var v, z, v1 uintptr + var v2 int64 + var _ /* value at bp+0 */ Ti64 + _, _, _, _, _, _ = c, i, v, z, v1, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_IntValue) != 0 { + i = *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fu)) + if negFlag != 0 { + i = -i + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), i, iMem) + } else { + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + c = _sqlite3DecOrHexToI64(tls, z, bp) + if c == int32(3) && !(negFlag != 0) || c == int32(2) || negFlag != 0 && **(**Ti64)(__ccgo_up(bp)) == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>3)) != 0) { + /* This RETURNING trigger must be for a different statement as + ** this statement lacks a RETURNING clause. */ + return + } + pReturning = (*(*struct { + FpReturning uintptr + })(unsafe.Pointer(&(*TParse)(unsafe.Pointer(pParse)).Fu1))).FpReturning + if pTrigger != pReturning+16 { + /* This RETURNING trigger is for a different statement */ + return + } + libc.X__builtin___memset_chk(tls, bp, 0, uint64(120), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+120, 0, uint64(88), ^t__predefined_size_t(0)) + pFrom = bp + 120 + (**(**TSelect)(__ccgo_up(bp))).FpEList = _sqlite3ExprListDup(tls, db, (*TReturning)(unsafe.Pointer(pReturning)).FpReturnEL, 0) + (**(**TSelect)(__ccgo_up(bp))).FpSrc = pFrom + (*TSrcList)(unsafe.Pointer(pFrom)).FnSrc = int32(1) + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FpSTab = pTab + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FzName = (*TTable)(unsafe.Pointer(pTab)).FzName /* tag-20240424-1 */ + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FiCursor = -int32(1) + _sqlite3SelectPrep(tls, pParse, bp, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + _sqlite3GenerateColumnNames(tls, pParse, bp) + } + _sqlite3ExprListDelete(tls, db, (**(**TSelect)(__ccgo_up(bp))).FpEList) + pNew = _sqlite3ExpandReturning(tls, pParse, (*TReturning)(unsafe.Pointer(pReturning)).FpReturnEL, pTab) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + libc.X__builtin___memset_chk(tls, bp+208, 0, uint64(56), ^t__predefined_size_t(0)) + if (*TReturning)(unsafe.Pointer(pReturning)).FnRetCol == 0 { + (*TReturning)(unsafe.Pointer(pReturning)).FnRetCol = (*TExprList)(unsafe.Pointer(pNew)).FnExpr + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur = v1 + } + (**(**TNameContext)(__ccgo_up(bp + 208))).FpParse = pParse + *(*int32)(unsafe.Pointer(bp + 208 + 16)) = regIn + (**(**TNameContext)(__ccgo_up(bp + 208))).FncFlags = int32(NC_UBaseReg) + (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = (*TTrigger)(unsafe.Pointer(pTrigger)).Fop + (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = pTab + if _sqlite3ResolveExprListNames(tls, bp+208, pNew) == SQLITE_OK && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + nCol = (*TExprList)(unsafe.Pointer(pNew)).FnExpr + reg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + _sqlite3ProcessReturningSubqueries(tls, pNew, pTab) + **(**int32)(__ccgo_up(pParse + 60)) += nCol + int32(2) + (*TReturning)(unsafe.Pointer(pReturning)).FiRetReg = reg + i = 0 + for { + if !(i < nCol) { + break + } + pCol = (*(*TExprList_item)(unsafe.Pointer(pNew + 8 + uintptr(i)*32))).FpExpr + /* Due to !db->mallocFailed ~9 lines above */ + _sqlite3ExprCodeFactorable(tls, pParse, pCol, reg+i) + if int32(_sqlite3ExprAffinity(tls, pCol)) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), reg+i) + } + goto _3 + _3: + ; + i = i + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), reg, i, reg+i) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur, reg+i+int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur, reg+i, reg+i+int32(1)) + } + } + _sqlite3ExprListDelete(tls, db, pNew) + (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = uint8(0) + (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = uintptr(0) +} + +// C documentation +// +// /* +// ** Create and populate a new TriggerPrg object with a sub-program +// ** implementing trigger pTrigger with ON CONFLICT policy orconf. +// */ +func _codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintptr, orconf int32) (r uintptr) { + bp := tls.Alloc(496) + defer tls.Free(496) + var db, pPrg, pProgram, pTop, pWhen, v, v1 uintptr + var iEndTrigger int32 + var _ /* sNC at bp+0 */ TNameContext + var _ /* sSubParse at bp+56 */ TParse + _, _, _, _, _, _, _, _ = db, iEndTrigger, pPrg, pProgram, pTop, pWhen, v, v1 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + pTop = v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Value to return */ + pWhen = uintptr(0) /* Name context for sub-vdbe */ + pProgram = uintptr(0) /* Sub-vdbe for trigger program */ + iEndTrigger = 0 /* Parse context for sub-vdbe */ + /* Allocate the TriggerPrg and SubProgram objects. To ensure that they + ** are freed if an error occurs, link them into the Parse.pTriggerPrg + ** list of the top-level Parse object sooner rather than later. */ + pPrg = _sqlite3DbMallocZero(tls, db, uint64(40)) + if !(pPrg != 0) { + return uintptr(0) + } + (*TTriggerPrg)(unsafe.Pointer(pPrg)).FpNext = (*TParse)(unsafe.Pointer(pTop)).FpTriggerPrg + (*TParse)(unsafe.Pointer(pTop)).FpTriggerPrg = pPrg + v1 = _sqlite3DbMallocZero(tls, db, uint64(48)) + pProgram = v1 + (*TTriggerPrg)(unsafe.Pointer(pPrg)).FpProgram = v1 + if !(pProgram != 0) { + return uintptr(0) + } + _sqlite3VdbeLinkSubProgram(tls, (*TParse)(unsafe.Pointer(pTop)).FpVdbe, pProgram) + (*TTriggerPrg)(unsafe.Pointer(pPrg)).FpTrigger = pTrigger + (*TTriggerPrg)(unsafe.Pointer(pPrg)).Forconf = orconf + **(**Tu32)(__ccgo_up(pPrg + 28)) = uint32(0xffffffff) + **(**Tu32)(__ccgo_up(pPrg + 28 + 1*4)) = uint32(0xffffffff) + /* Allocate and populate a new Parse context to use for coding the + ** trigger sub-program. */ + _sqlite3ParseObjectInit(tls, bp+56, db) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = bp + 56 + (**(**TParse)(__ccgo_up(bp + 56))).FpTriggerTab = pTab + (**(**TParse)(__ccgo_up(bp + 56))).FpToplevel = pTop + (**(**TParse)(__ccgo_up(bp + 56))).FzAuthContext = (*TTrigger)(unsafe.Pointer(pTrigger)).FzName + (**(**TParse)(__ccgo_up(bp + 56))).FeTriggerOp = (*TTrigger)(unsafe.Pointer(pTrigger)).Fop + (**(**TParse)(__ccgo_up(bp + 56))).FnQueryLoop = (*TParse)(unsafe.Pointer(pParse)).FnQueryLoop + (**(**TParse)(__ccgo_up(bp + 56))).FprepFlags = (*TParse)(unsafe.Pointer(pParse)).FprepFlags + (**(**TParse)(__ccgo_up(bp + 56))).Foldmask = uint32(0) + (**(**TParse)(__ccgo_up(bp + 56))).Fnewmask = uint32(0) + v = _sqlite3GetVdbe(tls, bp+56) + if v != 0 { + if (*TTrigger)(unsafe.Pointer(pTrigger)).FzName != 0 { + _sqlite3VdbeChangeP4(tls, v, -int32(1), _sqlite3MPrintf(tls, db, __ccgo_ts+22915, libc.VaList(bp+480, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName)), -int32(7)) + } + /* If one was specified, code the WHEN clause. If it evaluates to false + ** (or NULL) the sub-vdbe is immediately halted by jumping to the + ** OP_Halt inserted at the end of the program. */ + if (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen != 0 { + pWhen = _sqlite3ExprDup(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen, 0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 && SQLITE_OK == _sqlite3ResolveExprNames(tls, bp, pWhen) { + iEndTrigger = _sqlite3VdbeMakeLabel(tls, bp+56) + _sqlite3ExprIfFalse(tls, bp+56, pWhen, iEndTrigger, int32(SQLITE_JUMPIFNULL)) + } + _sqlite3ExprDelete(tls, db, pWhen) + } + /* Code the trigger program into the sub-vdbe. */ + _codeTriggerProgram(tls, bp+56, (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list, orconf) + /* Insert an OP_Halt at the end of the sub-program. */ + if iEndTrigger != 0 { + _sqlite3VdbeResolveLabel(tls, v, iEndTrigger) + } + _sqlite3VdbeAddOp0(tls, v, int32(OP_Halt)) + _transferParseError(tls, pParse, bp+56) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + (*TSubProgram)(unsafe.Pointer(pProgram)).FaOp = _sqlite3VdbeTakeOpArray(tls, v, pProgram+8, pTop+120) + } + (*TSubProgram)(unsafe.Pointer(pProgram)).FnMem = (**(**TParse)(__ccgo_up(bp + 56))).FnMem + (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr = (**(**TParse)(__ccgo_up(bp + 56))).FnTab + (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken = pTrigger + **(**Tu32)(__ccgo_up(pPrg + 28)) = (**(**TParse)(__ccgo_up(bp + 56))).Foldmask + **(**Tu32)(__ccgo_up(pPrg + 28 + 1*4)) = (**(**TParse)(__ccgo_up(bp + 56))).Fnewmask + _sqlite3VdbeDelete(tls, v) + } else { + _transferParseError(tls, pParse, bp+56) + } + _sqlite3ParseObjectReset(tls, bp+56) + return pPrg +} + +// C documentation +// +// /* +// ** Generate VDBE code for the statements inside the body of a single +// ** trigger. +// */ +func _codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf int32) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pSelect, pStep, v uintptr + var v2 int32 + var _ /* sDest at bp+0 */ TSelectDest + _, _, _, _, _ = db, pSelect, pStep, v, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pStep = pStepList + for { + if !(pStep != 0) { + break + } + /* Figure out the ON CONFLICT policy that will be used for this step + ** of the trigger program. If the statement that caused this trigger + ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use + ** the ON CONFLICT policy that was specified as part of the trigger + ** step statement. Example: + ** + ** CREATE TRIGGER AFTER INSERT ON t1 BEGIN; + ** INSERT OR REPLACE INTO t2 VALUES(new.a, new.b); + ** END; + ** + ** INSERT INTO t1 ... ; -- insert into t2 uses REPLACE policy + ** INSERT OR IGNORE INTO t1 ... ; -- insert into t2 uses IGNORE policy + */ + if orconf == int32(OE_Default) { + v2 = libc.Int32FromUint8((*TTriggerStep)(unsafe.Pointer(pStep)).Forconf) + } else { + v2 = libc.Int32FromUint8(libc.Uint8FromInt32(orconf)) + } + (*TParse)(unsafe.Pointer(pParse)).FeOrconf = libc.Uint8FromInt32(v2) + if (*TTriggerStep)(unsafe.Pointer(pStep)).FzSpan != 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Trace), int32(0x7fffffff), int32(1), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+6825, libc.VaList(bp+48, (*TTriggerStep)(unsafe.Pointer(pStep)).FzSpan)), -int32(7)) + } + switch libc.Int32FromUint8((*TTriggerStep)(unsafe.Pointer(pStep)).Fop) { + case int32(TK_UPDATE): + _sqlite3Update(tls, pParse, _sqlite3SrcListDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc, 0), _sqlite3ExprListDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, 0), _sqlite3ExprDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere, 0), libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeOrconf), uintptr(0), uintptr(0), uintptr(0)) + _sqlite3VdbeAddOp0(tls, v, int32(OP_ResetCount)) + case int32(TK_INSERT): + _sqlite3Insert(tls, pParse, _sqlite3SrcListDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc, 0), _sqlite3SelectDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect, 0), _sqlite3IdListDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpIdList), libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeOrconf), _sqlite3UpsertDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert)) + _sqlite3VdbeAddOp0(tls, v, int32(OP_ResetCount)) + case int32(TK_DELETE): + _sqlite3DeleteFrom(tls, pParse, _sqlite3SrcListDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc, 0), _sqlite3ExprDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere, 0), uintptr(0), uintptr(0)) + _sqlite3VdbeAddOp0(tls, v, int32(OP_ResetCount)) + default: + pSelect = _sqlite3SelectDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect, 0) + _sqlite3SelectDestInit(tls, bp, int32(SRT_Discard), 0) + _sqlite3Select(tls, pParse, pSelect, bp) + _sqlite3SelectDelete(tls, db, pSelect) + break + } + goto _1 + _1: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + return 0 +} + +// C documentation +// +// /* +// ** Expression pExpr is a comparison between two vector values. Compute +// ** the result of the comparison (1, 0, or NULL) and write that +// ** result into register dest. +// ** +// ** The caller must satisfy the following preconditions: +// ** +// ** if pExpr->op==TK_IS: op==TK_EQ and p5==SQLITE_NULLEQ +// ** if pExpr->op==TK_ISNOT: op==TK_NE and p5==SQLITE_NULLEQ +// ** otherwise: op==pExpr->op and p5==0 +// */ +func _codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, op Tu8, p5 Tu8) { + bp := tls.Alloc(32) + defer tls.Free(32) + var addrCmp, addrDone, i, isCommuted, nLeft, r1, r2, regLeft, regRight int32 + var opx Tu8 + var pLeft, pRight, v uintptr + var _ /* pL at bp+8 */ uintptr + var _ /* pR at bp+16 */ uintptr + var _ /* regFree1 at bp+0 */ int32 + var _ /* regFree2 at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCmp, addrDone, i, isCommuted, nLeft, opx, pLeft, pRight, r1, r2, regLeft, regRight, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + nLeft = _sqlite3ExprVectorSize(tls, pLeft) + regLeft = 0 + regRight = 0 + opx = op + addrCmp = 0 + addrDone = _sqlite3VdbeMakeLabel(tls, pParse) + isCommuted = libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + if nLeft != _sqlite3ExprVectorSize(tls, pRight) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7252, 0) + return + } + if libc.Int32FromUint8(op) == int32(TK_LE) { + opx = uint8(TK_LT) + } + if libc.Int32FromUint8(op) == int32(TK_GE) { + opx = uint8(TK_GT) + } + if libc.Int32FromUint8(op) == int32(TK_NE) { + opx = uint8(TK_EQ) + } + regLeft = _exprCodeSubselect(tls, pParse, pLeft) + regRight = _exprCodeSubselect(tls, pParse, pRight) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), dest) + i = 0 + for { + if !(int32(1) != 0) { + break + } + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + if addrCmp != 0 { + _sqlite3VdbeJumpHere(tls, v, addrCmp) + } + r1 = _exprVectorRegister(tls, pParse, pLeft, i, regLeft, bp+8, bp) + r2 = _exprVectorRegister(tls, pParse, pRight, i, regRight, bp+16, bp+4) + addrCmp = _sqlite3VdbeCurrentAddr(tls, v) + _codeCompare(tls, pParse, **(**uintptr)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp + 16)), libc.Int32FromUint8(opx), r1, r2, addrDone, libc.Int32FromUint8(p5), isCommuted) + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp))) + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp + 4))) + if (libc.Int32FromUint8(opx) == int32(TK_LT) || libc.Int32FromUint8(opx) == int32(TK_GT)) && i < nLeft-int32(1) { + addrCmp = _sqlite3VdbeAddOp0(tls, v, int32(OP_ElseEq)) + } + if libc.Int32FromUint8(p5) == int32(SQLITE_NULLEQ) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, dest) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_ZeroOrNull), r1, dest, r2) + } + if i == nLeft-int32(1) { + break + } + if libc.Int32FromUint8(opx) == int32(TK_EQ) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), dest, addrDone) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrDone) + if i == nLeft-int32(2) { + opx = op + } + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3VdbeJumpHere(tls, v, addrCmp) + _sqlite3VdbeResolveLabel(tls, v, addrDone) + if libc.Int32FromUint8(op) == int32(TK_NE) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Not), dest, dest) + } +} + +// C documentation +// +// /* +// ** Return a pointer to a string containing the 'declaration type' of the +// ** expression pExpr. The string may be treated as static by the caller. +// ** +// ** The declaration type is the exact datatype definition extracted from the +// ** original CREATE TABLE statement if the expression is a column. The +// ** declaration type for a ROWID field is INTEGER. Exactly when an expression +// ** is considered a column can be complex in the presence of subqueries. The +// ** result-set expression in all of the following SELECT statements is +// ** considered a column by this function. +// ** +// ** SELECT col FROM tbl; +// ** SELECT (SELECT col FROM tbl; +// ** SELECT (SELECT col FROM tbl); +// ** SELECT abc FROM (SELECT col AS abc FROM tbl); +// ** +// ** The declaration type for any expression other than a column is NULL. +// ** +// ** This routine has either 3 or 6 parameters depending on whether or not +// ** the SQLITE_ENABLE_COLUMN_METADATA compile-time option is used. +// */ +func _columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, pzOrigTab uintptr, pzOrigCol uintptr) (r uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var iCol, iDb, j int32 + var p, p1, pS, pS1, pTab, pTabList, zType uintptr + var _ /* sNC at bp+24 */ TNameContext + var _ /* sNC at bp+80 */ TNameContext + var _ /* zOrigCol at bp+16 */ uintptr + var _ /* zOrigDb at bp+0 */ uintptr + var _ /* zOrigTab at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _ = iCol, iDb, j, p, p1, pS, pS1, pTab, pTabList, zType + zType = uintptr(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + case int32(TK_COLUMN): + /* The expression is a column. Locate the table the column is being + ** extracted from in NameContext.pSrcList. This table may be real + ** database table or a subquery. + */ + pTab = uintptr(0) /* Table structure column is extracted from */ + pS = uintptr(0) /* Select the column is extracted from */ + iCol = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) /* Index of column in pTab */ + for pNC != 0 && !(pTab != 0) { + pTabList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + j = 0 + for { + if !(j < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc && (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80))).FiCursor != (*TExpr)(unsafe.Pointer(pExpr)).FiTable) { + break + } + goto _1 + _1: + ; + j = j + 1 + } + if j < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc { + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80))).FpSTab + if int32(*(*uint32)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80 + 24 + 4))&0x4>>2) != 0 { + pS = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80 + 72)))).FpSelect + } else { + pS = uintptr(0) + } + } else { + pNC = (*TNameContext)(unsafe.Pointer(pNC)).FpNext + } + } + if pTab == uintptr(0) { + /* At one time, code such as "SELECT new.x" within a trigger would + ** cause this condition to run. Since then, we have restructured how + ** trigger code is generated and so this condition is no longer + ** possible. However, it can still be true for statements like + ** the following: + ** + ** CREATE TABLE t1(col INTEGER); + ** SELECT (SELECT t1.col) FROM FROM t1; + ** + ** when columnType() is called on the expression "t1.col" in the + ** sub-select. In this case, set the column type to NULL, even + ** though it should really be "INTEGER". + ** + ** This is not a problem, as the column type of "t1.col" is never + ** used. When columnType() is called on the expression + ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT + ** branch below. */ + break + } + if pS != 0 { + /* The "table" is actually a sub-select or a view in the FROM clause + ** of the SELECT statement. Return the declaration type and origin + ** data for the result-set column of the sub-select. + */ + if iCol < (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS)).FpEList)).FnExpr && libc.Bool(libc.Bool(!(libc.Int32FromInt32(ViewCanHaveRowid) != 0)) || iCol >= 0) { + p = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS)).FpEList + 8 + uintptr(iCol)*32))).FpExpr + (**(**TNameContext)(__ccgo_up(bp + 24))).FpSrcList = (*TSelect)(unsafe.Pointer(pS)).FpSrc + (**(**TNameContext)(__ccgo_up(bp + 24))).FpNext = pNC + (**(**TNameContext)(__ccgo_up(bp + 24))).FpParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + zType = _columnTypeImpl(tls, bp+24, p, bp, bp+8, bp+16) + } + } else { + /* A real table or a CTE table */ + if iCol < 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + if iCol < 0 { + zType = __ccgo_ts + 1176 + **(**uintptr)(__ccgo_up(bp + 16)) = __ccgo_ts + 18310 + } else { + **(**uintptr)(__ccgo_up(bp + 16)) = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + zType = _sqlite3ColumnType(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16, uintptr(0)) + } + **(**uintptr)(__ccgo_up(bp + 8)) = (*TTable)(unsafe.Pointer(pTab)).FzName + if (*TNameContext)(unsafe.Pointer(pNC)).FpParse != 0 && (*TTable)(unsafe.Pointer(pTab)).FpSchema != 0 { + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer((*TNameContext)(unsafe.Pointer(pNC)).FpParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + **(**uintptr)(__ccgo_up(bp)) = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TNameContext)(unsafe.Pointer(pNC)).FpParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName + } + } + case int32(TK_SELECT): + pS1 = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + p1 = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS1)).FpEList + 8))).FpExpr + (**(**TNameContext)(__ccgo_up(bp + 80))).FpSrcList = (*TSelect)(unsafe.Pointer(pS1)).FpSrc + (**(**TNameContext)(__ccgo_up(bp + 80))).FpNext = pNC + (**(**TNameContext)(__ccgo_up(bp + 80))).FpParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + zType = _columnTypeImpl(tls, bp+80, p1, bp, bp+8, bp+16) + break + } + if pzOrigDb != 0 { + **(**uintptr)(__ccgo_up(pzOrigDb)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(pzOrigTab)) = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(pzOrigCol)) = **(**uintptr)(__ccgo_up(bp + 16)) + } + return zType +} + +// C documentation +// +// /* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...) +// ** functions. +// ** +// ** Return a string value that is the concatenation of all non-null +// ** entries in argv[]. Use zSep as the separator. +// */ +func _concatFuncCore(tls *libc.TLS, context uintptr, argc int32, argv uintptr, nSep int32, zSep uintptr) { + var bNotNull, i, k int32 + var j, n Ti64 + var v, z uintptr + _, _, _, _, _, _, _ = bNotNull, i, j, k, n, v, z + n = 0 + bNotNull = 0 + i = 0 + for { + if !(i < argc) { + break + } + n = n + int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)))) + goto _1 + _1: + ; + i = i + 1 + } + n = n + int64(argc-libc.Int32FromInt32(1))*int64(nSep) + z = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(n+int64(1))) + if z == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + j = 0 + i = 0 + for { + if !(i < argc) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) != int32(SQLITE_NULL) { + k = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + v = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if v != uintptr(0) { + if bNotNull != 0 && nSep > 0 { + libc.X__builtin___memcpy_chk(tls, z+uintptr(j), zSep, libc.Uint64FromInt32(nSep), ^t__predefined_size_t(0)) + j = j + int64(nSep) + } + libc.X__builtin___memcpy_chk(tls, z+uintptr(j), v, libc.Uint64FromInt32(k), ^t__predefined_size_t(0)) + j = j + int64(k) + bNotNull = int32(1) + } + } + goto _2 + _2: + ; + i = i + 1 + } + **(**int8)(__ccgo_up(z + uintptr(j))) = 0 + Xsqlite3_result_text64(tls, context, z, libc.Uint64FromInt64(j), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) +} + +// C documentation +// +// /* +// ** Generate code to construct the Index object for an automatic index +// ** and to set up the WhereLevel object pLevel so that the code generator +// ** makes use of the automatic index. +// */ +func _constructAutomaticIndex(tls *libc.TLS, pParse uintptr, pWC uintptr, notReady TBitmask, pLevel uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var addrCounter, addrInit, addrTop, i, iCol, iCol1, iContinue, mxBitCol, n, nKeyCol, regBase, regRecord, regYield, v3 int32 + var cMask, cMask1, extraCols, idxCols TBitmask + var pColl, pExpr, pIdx, pLoop, pPartial, pSrc, pSubq, pTabList, pTable, pTerm, pWCEnd, pX, v, v10 uintptr + var sentWarning, useBloomFilter Tu8 + var v2 uint64 + var v4 Tu16 + var _ /* zNotUsed at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCounter, addrInit, addrTop, cMask, cMask1, extraCols, i, iCol, iCol1, iContinue, idxCols, mxBitCol, n, nKeyCol, pColl, pExpr, pIdx, pLoop, pPartial, pSrc, pSubq, pTabList, pTable, pTerm, pWCEnd, pX, regBase, regRecord, regYield, sentWarning, useBloomFilter, v, v10, v2, v3, v4 /* Bitmap of additional columns */ + sentWarning = uint8(0) /* True if a warning has been issued */ + useBloomFilter = uint8(0) /* True to also add a Bloom filter */ + pPartial = uintptr(0) /* Partial Index Expression */ + iContinue = 0 /* The FROM clause term to get the next index */ + addrCounter = 0 /* Array of registers where record is assembled */ + /* Generate code to skip over the creation and initialization of the + ** transient index on 2nd and subsequent iterations of the loop. */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + addrInit = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + /* Count the number of columns that will be added to the index + ** and used to match WHERE clause constraints */ + nKeyCol = 0 + pTabList = (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpTabList + pSrc = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + pTable = (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab + pWCEnd = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)*56 + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + idxCols = uint64(0) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(pTerm < pWCEnd) { + break + } + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + /* Make the automatic index a partial index if there are terms in the + ** WHERE clause (or the ON clause of a LEFT join) that constrain which + ** rows of the target table (pSrc) that can be used. */ + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VIRTUAL) == 0 && _sqlite3ExprIsSingleTableConstraint(tls, pExpr, pTabList, libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom), 0) != 0 { + pPartial = _sqlite3ExprAnd(tls, pParse, pPartial, _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0)) + } + if _termCanDriveIndex(tls, pTerm, pSrc, notReady) != 0 { + iCol = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn + if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v2 = libc.Uint64FromInt32(1) << (libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1)) + } else { + v2 = libc.Uint64FromInt32(1) << iCol + } + cMask = v2 + if !(sentWarning != 0) { + Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_WARNING)|libc.Int32FromInt32(1)<= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + extraCols = extraCols | libc.Uint64FromInt32(1)<<(libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1)) + break + } + if idxCols&(libc.Uint64FromInt32(1)<= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v2 = libc.Uint64FromInt32(1) << (libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1)) + } else { + v2 = libc.Uint64FromInt32(1) << iCol1 + } + cMask1 = v2 + if idxCols&cMask1 == uint64(0) { + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + idxCols = idxCols | cMask1 + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) = int16((*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn) + pColl = _sqlite3ExprCompareCollSeq(tls, pParse, pX) + /* TH3 collate01.800 */ + if pColl != 0 { + v10 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v10 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(n)*8)) = v10 + n = n + 1 + if (*TExpr)(unsafe.Pointer(pX)).FpLeft != uintptr(0) && int32(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft)) != int32(SQLITE_AFF_TEXT) { + /* TUNING: only use a Bloom filter on an automatic index + ** if one or more key columns has the ability to hold numeric + ** values, since strings all have the same hash in the Bloom + ** filter implementation and hence a Bloom filter on a text column + ** is not usually helpful. */ + useBloomFilter = uint8(1) + } + } + } + goto _8 + _8: + ; + pTerm += 56 + } + /* Add additional columns needed to make the automatic index into + ** a covering index */ + i = 0 + for { + if !(i < mxBitCol) { + break + } + if extraCols&(libc.Uint64FromInt32(1)<>6) != 0 { + pSubq = *(*uintptr)(unsafe.Pointer(pSrc + 72)) + regYield = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + addrCounter = _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, 0) + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) + addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), regYield) + } else { + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt) + } + if pPartial != 0 { + iContinue = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, int32(SQLITE_JUMPIFNULL)) + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_PARTIALIDX) + } + regRecord = _sqlite3GetTempReg(tls, pParse) + regBase = _sqlite3GenerateIndexKey(tls, pParse, pIdx, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, regRecord, 0, uintptr(0), uintptr(0), 0) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0, regBase, libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq)) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + if pPartial != 0 { + _sqlite3VdbeResolveLabel(tls, v, iContinue) + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40>>6) != 0 { + _sqlite3VdbeChangeP2(tls, v, addrCounter, regBase+n) + _translateColumnToCopy(tls, pParse, addrTop, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FregResult, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + _sqlite3VdbeGoto(tls, v, addrTop) + libc.SetBitFieldPtr32Uint32(pSrc+24+4, libc.Uint32FromInt32(0), 6, 0x40) + _sqlite3VdbeJumpHere(tls, v, addrTop) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, addrTop+int32(1)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_STMTSTATUS_AUTOINDEX)) + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + _sqlite3VdbeJumpHere(tls, v, addrTop) + } + } + _sqlite3ReleaseTempReg(tls, pParse, regRecord) + /* Jump here when skipping the initialization */ + _sqlite3VdbeJumpHere(tls, v, addrInit) + goto end_auto_index_create +end_auto_index_create: + ; + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPartial) +} + +// C documentation +// +// /* +// ** Detect compound SELECT statements that use an ORDER BY clause with +// ** an alternative collating sequence. +// ** +// ** SELECT ... FROM t1 EXCEPT SELECT ... FROM t2 ORDER BY .. COLLATE ... +// ** +// ** These are rewritten as a subquery: +// ** +// ** SELECT * FROM (SELECT ... FROM t1 EXCEPT SELECT ... FROM t2) +// ** ORDER BY ... COLLATE ... +// ** +// ** This transformation is necessary because the multiSelectByMerge() routine +// ** above that generates the code for a compound SELECT with an ORDER BY clause +// ** uses a merge algorithm that requires the same collating sequence on the +// ** result columns as on the ORDER BY clause. See ticket +// ** http://sqlite.org/src/info/6709574d2a +// ** +// ** This transformation is only needed for EXCEPT, INTERSECT, and UNION. +// ** The UNION ALL operator works fine with multiSelectByMerge() even when +// ** there are COLLATE terms in the ORDER BY. +// */ +func _convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, db, pNew, pNewSrc, pParse, pX uintptr + var i int32 + var _ /* dummy at bp+0 */ TToken + _, _, _, _, _, _, _ = a, db, i, pNew, pNewSrc, pParse, pX + if (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) { + return WRC_Continue + } + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy == uintptr(0) { + return WRC_Continue + } + pX = p + for { + if !(pX != 0 && (libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pX)).Fop) == int32(TK_ALL) || libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pX)).Fop) == int32(TK_SELECT))) { + break + } + goto _1 + _1: + ; + pX = (*TSelect)(unsafe.Pointer(pX)).FpPrior + } + if pX == uintptr(0) { + return WRC_Continue + } + a = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + 8 + /* If iOrderByCol is already non-zero, then it has already been matched + ** to a result column of the SELECT statement. This occurs when the + ** SELECT is rewritten for window-functions processing and then passed + ** to sqlite3SelectPrep() and similar a second time. The rewriting done + ** by this function is not required in this case. */ + if *(*Tu16)(unsafe.Pointer(a + 24)) != 0 { + return WRC_Continue + } + i = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr - int32(1) + for { + if !(i >= 0) { + break + } + if (*TExpr)(unsafe.Pointer((**(**TExprList_item)(__ccgo_up(a + uintptr(i)*32))).FpExpr)).Fflags&uint32(EP_Collate) != 0 { + break + } + goto _2 + _2: + ; + i = i - 1 + } + if i < 0 { + return WRC_Continue + } + /* If we reach this point, that means the transformation is required. */ + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pNew = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pNew == uintptr(0) { + return int32(WRC_Abort) + } + libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^t__predefined_size_t(0)) + pNewSrc = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp, pNew, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + _sqlite3SrcListDelete(tls, db, pNewSrc) + return int32(WRC_Abort) + } + **(**TSelect)(__ccgo_up(pNew)) = **(**TSelect)(__ccgo_up(p)) + (*TSelect)(unsafe.Pointer(p)).FpSrc = pNewSrc + (*TSelect)(unsafe.Pointer(p)).FpEList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3Expr(tls, db, int32(TK_ASTERISK), uintptr(0))) + (*TSelect)(unsafe.Pointer(p)).Fop = uint8(TK_SELECT) + (*TSelect)(unsafe.Pointer(p)).FpWhere = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpGroupBy = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpHaving = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpOrderBy = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpNext = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpWith = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpWinDefn = uintptr(0) + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Compound) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_Converted) + (*TSelect)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pNew)).FpPrior)).FpNext = pNew + (*TSelect)(unsafe.Pointer(pNew)).FpLimit = uintptr(0) + return WRC_Continue +} + +// C documentation +// +// /* +// ** This function is used to copy the contents of the b-tree node stored +// ** on page pFrom to page pTo. If page pFrom was not a leaf page, then +// ** the pointer-map entries for each child page are updated so that the +// ** parent page stored in the pointer map is page pTo. If pFrom contained +// ** any cells with overflow page pointers, then the corresponding pointer +// ** map entries are also updated so that the parent page is page pTo. +// ** +// ** If pFrom is currently carrying any overflow cells (entries in the +// ** MemPage.apOvfl[] array), they are not copied to pTo. +// ** +// ** Before returning, page pTo is reinitialized using btreeInitPage(). +// ** +// ** The performance of this function is not critical. It is only used by +// ** the balance_shallower() and balance_deeper() procedures, neither of +// ** which are called often under normal circumstances. +// */ +func _copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) { + var aFrom, aTo, pBt uintptr + var iData, iFromHdr, iToHdr, rc, v1 int32 + _, _, _, _, _, _, _, _ = aFrom, aTo, iData, iFromHdr, iToHdr, pBt, rc, v1 + if **(**int32)(__ccgo_up(pRC)) == SQLITE_OK { + pBt = (*TMemPage)(unsafe.Pointer(pFrom)).FpBt + aFrom = (*TMemPage)(unsafe.Pointer(pFrom)).FaData + aTo = (*TMemPage)(unsafe.Pointer(pTo)).FaData + iFromHdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pFrom)).FhdrOffset) + if (*TMemPage)(unsafe.Pointer(pTo)).Fpgno == uint32(1) { + v1 = int32(100) + } else { + v1 = 0 + } + iToHdr = v1 + /* Copy the b-tree node content from page pFrom to page pTo. */ + iData = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aFrom + uintptr(iFromHdr+int32(5)))))<>2) == 0 { + return 0 + } /* FROM is a subquery */ + pSub = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + if (*TSelect)(unsafe.Pointer(pSub)).FpPrior == uintptr(0) { + return 0 + } /* Must be a compound */ + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&uint32(SF_CopyCte) != 0 { + return 0 + } /* Not a CTE */ + for cond := true; cond; cond = pSub != 0 { + if libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSub)).Fop) != int32(TK_ALL) && (*TSelect)(unsafe.Pointer(pSub)).FpPrior != 0 { + return 0 + } /* Must be UNION ALL */ + if (*TSelect)(unsafe.Pointer(pSub)).FpWhere != 0 { + return 0 + } /* No WHERE clause */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 { + return 0 + } /* No LIMIT clause */ + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Aggregate)|libc.Int32FromInt32(SF_Distinct)) != 0 { + return 0 /* Not an aggregate nor DISTINCT */ + } + /* Due to the previous */ + pSub = (*TSelect)(unsafe.Pointer(pSub)).FpPrior /* Repeat over compound */ + } + /* If we reach this point then it is OK to perform the transformation */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pCount = pExpr + pExpr = uintptr(0) + pSub = _sqlite3SubqueryDetach(tls, db, pFrom) + _sqlite3SrcListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpSrc) + (*TSelect)(unsafe.Pointer(p)).FpSrc = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt64(80))) + for pSub != 0 { + pPrior = (*TSelect)(unsafe.Pointer(pSub)).FpPrior + (*TSelect)(unsafe.Pointer(pSub)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(pSub)).FpNext = uintptr(0) + **(**Tu32)(__ccgo_up(pSub + 4)) |= uint32(SF_Aggregate) + **(**Tu32)(__ccgo_up(pSub + 4)) &= ^libc.Uint32FromInt32(SF_Compound) + (*TSelect)(unsafe.Pointer(pSub)).FnSelectRow = 0 + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprListDeleteGeneric), (*TSelect)(unsafe.Pointer(pSub)).FpEList) + if pPrior != 0 { + v1 = _sqlite3ExprDup(tls, db, pCount, 0) + } else { + v1 = pCount + } + pTerm = v1 + (*TSelect)(unsafe.Pointer(pSub)).FpEList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), pTerm) + pTerm = _sqlite3PExpr(tls, pParse, int32(TK_SELECT), uintptr(0), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, pTerm, pSub) + if pExpr == uintptr(0) { + pExpr = pTerm + } else { + pExpr = _sqlite3PExpr(tls, pParse, int32(TK_PLUS), pTerm, pExpr) + } + pSub = pPrior + } + (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8))).FpExpr = pExpr + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Aggregate) + return int32(1) +} + +// C documentation +// +// /* +// ** Create a new aggregate context for p and return a pointer to +// ** its pMem->z element. +// */ +func _createAggContext(tls *libc.TLS, p uintptr, nByte int32) (r uintptr) { + var pMem uintptr + _ = pMem + pMem = (*Tsqlite3_context)(unsafe.Pointer(p)).FpMem + if nByte <= 0 { + _sqlite3VdbeMemSetNull(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = uintptr(0) + } else { + _sqlite3VdbeMemClearAndResize(tls, pMem, nByte) + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Agg) + *(*uintptr)(unsafe.Pointer(pMem)) = (*Tsqlite3_context)(unsafe.Pointer(p)).FpFunc + if (*TMem)(unsafe.Pointer(pMem)).Fz != 0 { + libc.X__builtin___memset_chk(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, 0, libc.Uint64FromInt32(nByte), ^t__predefined_size_t(0)) + } + } + return (*TMem)(unsafe.Pointer(pMem)).Fz +} + +// C documentation +// +// /* +// ** Create a new collating function for database "db". The name is zName +// ** and the encoding is enc. +// */ +func _createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc Tu8, pCtx uintptr, __ccgo_fp_xCompare uintptr, __ccgo_fp_xDel uintptr) (r int32) { + var aColl, p, pColl uintptr + var enc2, j int32 + _, _, _, _, _ = aColl, enc2, j, p, pColl + /* If SQLITE_UTF16 is specified as the encoding type, transform this + ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the + ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. + */ + enc2 = libc.Int32FromUint8(enc) + if enc2 == int32(SQLITE_UTF16) || enc2 == int32(SQLITE_UTF16_ALIGNED) { + enc2 = int32(SQLITE_UTF16LE) + } + if enc2 < int32(SQLITE_UTF8) || enc2 > int32(SQLITE_UTF16BE) { + return _sqlite3MisuseError(tls, int32(190075)) + } + /* Check if this call is removing or replacing an existing collation + ** sequence. If so, and there are active VMs, return busy. If there + ** are no active VMs, invalidate any pre-compiled statements. + */ + pColl = _sqlite3FindCollSeq(tls, db, libc.Uint8FromInt32(enc2), zName, 0) + if pColl != 0 && (*TCollSeq)(unsafe.Pointer(pColl)).FxCmp != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_BUSY), __ccgo_ts+26372, 0) + return int32(SQLITE_BUSY) + } + _sqlite3ExpirePreparedStatements(tls, db, 0) + /* If collation sequence pColl was created directly by a call to + ** sqlite3_create_collation, and not generated by synthCollSeq(), + ** then any copies made by synthCollSeq() need to be invalidated. + ** Also, collation destructor - CollSeq.xDel() - function may need + ** to be called. + */ + if libc.Int32FromUint8((*TCollSeq)(unsafe.Pointer(pColl)).Fenc) & ^libc.Int32FromInt32(SQLITE_UTF16_ALIGNED) == enc2 { + aColl = _sqlite3HashFind(tls, db+648, zName) + j = 0 + for { + if !(j < int32(3)) { + break + } + p = aColl + uintptr(j)*40 + if libc.Int32FromUint8((*TCollSeq)(unsafe.Pointer(p)).Fenc) == libc.Int32FromUint8((*TCollSeq)(unsafe.Pointer(pColl)).Fenc) { + if (*TCollSeq)(unsafe.Pointer(p)).FxDel != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TCollSeq)(unsafe.Pointer(p)).FxDel})))(tls, (*TCollSeq)(unsafe.Pointer(p)).FpUser) + } + (*TCollSeq)(unsafe.Pointer(p)).FxCmp = uintptr(0) + } + goto _1 + _1: + ; + j = j + 1 + } + } + } + pColl = _sqlite3FindCollSeq(tls, db, libc.Uint8FromInt32(enc2), zName, int32(1)) + if pColl == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TCollSeq)(unsafe.Pointer(pColl)).FxCmp = __ccgo_fp_xCompare + (*TCollSeq)(unsafe.Pointer(pColl)).FpUser = pCtx + (*TCollSeq)(unsafe.Pointer(pColl)).FxDel = __ccgo_fp_xDel + (*TCollSeq)(unsafe.Pointer(pColl)).Fenc = libc.Uint8FromInt32(enc2 | libc.Int32FromUint8(enc)&libc.Int32FromInt32(SQLITE_UTF16_ALIGNED)) + _sqlite3Error(tls, db, SQLITE_OK) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Generate a CREATE TABLE statement appropriate for the given +// ** table. Memory to hold the text of the statement is obtained +// ** from sqliteMalloc() and must be freed by the calling function. +// */ +func _createTableStmt(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, len1, v2 int32 + var n Ti64 + var pCol, zEnd, zSep, zSep2, zStmt, zType uintptr + var _ /* k at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = i, len1, n, pCol, zEnd, zSep, zSep2, zStmt, zType, v2 + n = 0 + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + i = libc.Int32FromInt32(0) + for { + if !(i < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + n = n + (_identLength(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + int64(5)) + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + n = n + _identLength(tls, (*TTable)(unsafe.Pointer(p)).FzName) + if n < int64(50) { + zSep = __ccgo_ts + 1702 + zSep2 = __ccgo_ts + 14690 + zEnd = __ccgo_ts + 5601 + } else { + zSep = __ccgo_ts + 14692 + zSep2 = __ccgo_ts + 14696 + zEnd = __ccgo_ts + 14701 + } + n = n + int64(int32(35)+int32(6)*int32((*TTable)(unsafe.Pointer(p)).FnCol)) + zStmt = _sqlite3DbMallocRaw(tls, uintptr(0), libc.Uint64FromInt64(n)) + if zStmt == uintptr(0) { + _sqlite3OomFault(tls, db) + return uintptr(0) + } + libc.X__builtin___memcpy_chk(tls, zStmt, __ccgo_ts+14704, uint64(13), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp)) = int32(13) + _identPut(tls, zStmt, bp, (*TTable)(unsafe.Pointer(p)).FzName) + v2 = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(zStmt + uintptr(v2))) = int8('(') + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + i = libc.Int32FromInt32(0) + for { + if !(i < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + len1 = _sqlite3Strlen30(tls, zSep) + libc.X__builtin___memcpy_chk(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zSep, libc.Uint64FromInt32(len1), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + len1 + zSep = zSep2 + _identPut(tls, zStmt, bp, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + zType = _azType1[int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity)-int32(SQLITE_AFF_BLOB)] + len1 = _sqlite3Strlen30(tls, zType) + libc.X__builtin___memcpy_chk(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zType, libc.Uint64FromInt32(len1), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + len1 + goto _3 + _3: + ; + i = i + 1 + pCol += 16 + } + len1 = _sqlite3Strlen30(tls, zEnd) + libc.X__builtin___memcpy_chk(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zEnd, libc.Uint64FromInt32(len1+int32(1)), ^t__predefined_size_t(0)) + return zStmt +} + +// C documentation +// +// /* +// ** Put the DateTime object into its error state. +// */ +func _datetimeError(tls *libc.TLS, p uintptr) { + libc.X__builtin___memset_chk(tls, p, 0, uint64(48), ^t__predefined_size_t(0)) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 1, 0x2) +} + +func _dbReallocFinish(tls *libc.TLS, db uintptr, p uintptr, n Tu64) (r uintptr) { + var pNew uintptr + _ = pNew + pNew = uintptr(0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + if _isLookaside(tls, db, p) != 0 { + pNew = _sqlite3DbMallocRawNN(tls, db, n) + if pNew != 0 { + libc.X__builtin___memcpy_chk(tls, pNew, p, libc.Uint64FromInt32(_lookasideMallocSize(tls, db, p)), ^t__predefined_size_t(0)) + _sqlite3DbFree(tls, db, p) + } + } else { + pNew = _sqlite3Realloc(tls, p, n) + if !(pNew != 0) { + _sqlite3OomFault(tls, db) + } + } + } + return pNew +} + +// C documentation +// +// /* +// ** Connect to or create a dbpagevfs virtual table. +// */ +func _dbpageConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = uintptr(0) + rc = SQLITE_OK + _ = pAux + _ = argc + _ = argv + _ = pzErr + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_DIRECTONLY), 0) + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_USES_ALL_SCHEMAS), 0) + rc = Xsqlite3_declare_vtab(tls, db, __ccgo_ts+35322) + if rc == SQLITE_OK { + pTab = Xsqlite3_malloc64(tls, uint64(40)) + if pTab == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc == SQLITE_OK { + libc.X__builtin___memset_chk(tls, pTab, 0, uint64(40), ^t__predefined_size_t(0)) + (*TDbpageTable)(unsafe.Pointer(pTab)).Fdb = db + } + **(**uintptr)(__ccgo_up(ppVtab)) = pTab + return rc +} + +// C documentation +// +// /* +// ** Open a new dbpagevfs cursor. +// */ +func _dbpageOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = Xsqlite3_malloc64(tls, uint64(40)) + if pCsr == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pCsr, 0, uint64(40), ^t__predefined_size_t(0)) + (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab + (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno = uint32(0) + } + **(**uintptr)(__ccgo_up(ppCursor)) = pCsr + return SQLITE_OK +} + +func _dbpageUpdate(tls *libc.TLS, pVtab uintptr, argc int32, argv uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aPage, pBt, pData, pPager, pTab, zErr, zSchema uintptr + var iDb, isInsert, rc, szPage, v1 int32 + var pgno TPgno + var _ /* pDbPage at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = aPage, iDb, isInsert, pBt, pData, pPager, pTab, pgno, rc, szPage, zErr, zSchema, v1 + pTab = pVtab + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + zErr = uintptr(0) + _ = pRowid + if (*Tsqlite3)(unsafe.Pointer((*TDbpageTable)(unsafe.Pointer(pTab)).Fdb)).Fflags&uint64(SQLITE_Defensive) != 0 { + zErr = __ccgo_ts + 35389 + goto update_fail + } + if argc == int32(1) { + zErr = __ccgo_ts + 35399 + goto update_fail + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + pgno = libc.Uint32FromInt64(Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + isInsert = int32(1) + } else { + pgno = libc.Uint32FromInt64(Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))) + if libc.Uint32FromInt32(Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8)))) != pgno { + zErr = __ccgo_ts + 35413 + goto update_fail + } + isInsert = 0 + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) == int32(SQLITE_NULL) { + iDb = 0 + } else { + zSchema = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + iDb = _sqlite3FindDbName(tls, (*TDbpageTable)(unsafe.Pointer(pTab)).Fdb, zSchema) + if iDb < 0 { + zErr = __ccgo_ts + 35427 + goto update_fail + } + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TDbpageTable)(unsafe.Pointer(pTab)).Fdb)).FaDb + uintptr(iDb)*32))).FpBt + if pgno < uint32(1) || pBt == uintptr(0) { + zErr = __ccgo_ts + 35442 + goto update_fail + } + szPage = _sqlite3BtreeGetPageSize(tls, pBt) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) != int32(SQLITE_BLOB) || Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) != szPage { + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) == int32(SQLITE_NULL) && isInsert != 0 && pgno > uint32(1) { + /* "INSERT INTO dbpage($PGNO,NULL)" causes page number $PGNO and + ** all subsequent pages to be deleted. */ + (*TDbpageTable)(unsafe.Pointer(pTab)).FiDbTrunc = iDb + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = pgno - uint32(1) + pgno = uint32(1) + } else { + zErr = __ccgo_ts + 35458 + goto update_fail + } + } + if _dbpageBeginTrans(tls, pTab) != SQLITE_OK { + zErr = __ccgo_ts + 35473 + goto update_fail + } + pPager = _sqlite3BtreePager(tls, pBt) + rc = _sqlite3PagerGet(tls, pPager, pgno, bp, 0) + if rc == SQLITE_OK { + pData = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + v1 = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp))) + rc = v1 + if v1 == SQLITE_OK && pData != 0 { + aPage = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + libc.X__builtin___memcpy_chk(tls, aPage, pData, libc.Uint64FromInt32(szPage), ^t__predefined_size_t(0)) + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0) + } + } + if rc != SQLITE_OK { + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0) + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + return rc + goto update_fail +update_fail: + ; + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0) + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, zErr)) + return int32(SQLITE_ERROR) +} + +// C documentation +// +// /* +// ** The first argument points to a nul-terminated string containing a +// ** list of space separated integers. Read the first nOut of these into +// ** the array aOut[]. +// */ +func _decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, aLog uintptr, pIndex uintptr) { + var c, i, sz, v2 int32 + var v TtRowcnt + var z uintptr + _, _, _, _, _, _ = c, i, sz, v, z, v2 + z = zIntArray + if z == uintptr(0) { + z = __ccgo_ts + 1702 + } + i = 0 + for { + if !(**(**int8)(__ccgo_up(z)) != 0 && i < nOut) { + break + } + v = uint64(0) + for { + v2 = int32(**(**int8)(__ccgo_up(z))) + c = v2 + if !(v2 >= int32('0') && c <= int32('9')) { + break + } + v = v*uint64(10) + libc.Uint64FromInt32(c) - uint64('0') + z = z + 1 + } + if aOut != 0 { + **(**TtRowcnt)(__ccgo_up(aOut + uintptr(i)*8)) = v + } + if aLog != 0 { + **(**TLogEst)(__ccgo_up(aLog + uintptr(i)*2)) = _sqlite3LogEst(tls, v) + } + if int32(**(**int8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + if pIndex != 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 2, 0x4) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 6, 0x40) + for **(**int8)(__ccgo_up(z)) != 0 { + if Xsqlite3_strglob(tls, __ccgo_ts+13396, z) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 2, 0x4) + } else { + if Xsqlite3_strglob(tls, __ccgo_ts+13407, z) == 0 { + sz = _sqlite3Atoi(tls, z+uintptr(3)) + if sz < int32(2) { + sz = int32(2) + } + (*TIndex)(unsafe.Pointer(pIndex)).FszIdxRow = _sqlite3LogEst(tls, libc.Uint64FromInt32(sz)) + } else { + if Xsqlite3_strglob(tls, __ccgo_ts+13417, z) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 6, 0x40) + } + } + } + for int32(**(**int8)(__ccgo_up(z))) != 0 && int32(**(**int8)(__ccgo_up(z))) != int32(' ') { + z = z + 1 + } + for int32(**(**int8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + } + } +} + +// C documentation +// +// /* +// ** Defragment the page given. This routine reorganizes cells within the +// ** page so that there are no free-blocks on the free-block list. +// ** +// ** Parameter nMaxFrag is the maximum amount of fragmented space that may be +// ** present in the page after this routine returns. +// ** +// ** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a +// ** b-tree page so that there are no freeblocks or fragment bytes, all +// ** unused bytes are contained in the unallocated space region, and all +// ** cells are packed tightly at the end of the page. +// */ +func _defragmentPage(tls *libc.TLS, pPage uintptr, nMaxFrag int32) (r int32) { + var cbrk, cellOffset, hdr, i, iCellFirst, iCellLast, iCellStart, iFree, iFree2, nCell, pc, size, sz, sz2, top, usableSize int32 + var data, pAddr, pAddr1, pEnd, src, temp uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cbrk, cellOffset, data, hdr, i, iCellFirst, iCellLast, iCellStart, iFree, iFree2, nCell, pAddr, pAddr1, pEnd, pc, size, src, sz, sz2, temp, top, usableSize /* First cell offset in input */ + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) + cellOffset = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FcellOffset) + nCell = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) + iCellFirst = cellOffset + int32(2)*nCell + usableSize = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) + /* This block handles pages with two or fewer free blocks and nMaxFrag + ** or fewer fragmented bytes. In this case it is faster to move the + ** two (or one) blocks of cells using memmove() and add the required + ** offsets to each pointer in the cell-pointer array than it is to + ** reconstruct the entire page. */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7))))) <= nMaxFrag { + iFree = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(hdr+int32(1)))))< usableSize-int32(4) { + return _sqlite3CorruptError(tls, int32(74790)) + } + if iFree != 0 { + iFree2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree))))< usableSize-int32(4) { + return _sqlite3CorruptError(tls, int32(74793)) + } + if 0 == iFree2 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree2)))) == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree2+int32(1))))) == 0 { + pEnd = data + uintptr(cellOffset+nCell*int32(2)) + sz2 = 0 + sz = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree+int32(2)))))<= iFree { + return _sqlite3CorruptError(tls, int32(74801)) + } + if iFree2 != 0 { + if iFree+sz > iFree2 { + return _sqlite3CorruptError(tls, int32(74804)) + } + sz2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree2+int32(2)))))< usableSize { + return _sqlite3CorruptError(tls, int32(74806)) + } + libc.X__builtin___memmove_chk(tls, data+uintptr(iFree+sz+sz2), data+uintptr(iFree+sz), libc.Uint64FromInt32(iFree2-(iFree+sz)), ^t__predefined_size_t(0)) + sz = sz + sz2 + } else { + if iFree+sz > usableSize { + return _sqlite3CorruptError(tls, int32(74810)) + } + } + cbrk = top + sz + libc.X__builtin___memmove_chk(tls, data+uintptr(cbrk), data+uintptr(top), libc.Uint64FromInt32(iFree-top), ^t__predefined_size_t(0)) + pAddr = data + uintptr(cellOffset) + for { + if !(pAddr < pEnd) { + break + } + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pAddr)))<> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pAddr + 1)) = libc.Uint8FromInt32(pc + sz) + } else { + if pc < iFree2 { + **(**Tu8)(__ccgo_up(pAddr)) = libc.Uint8FromInt32((pc + sz2) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pAddr + 1)) = libc.Uint8FromInt32(pc + sz2) + } + } + goto _1 + _1: + ; + pAddr = pAddr + uintptr(2) + } + goto defragment_out + } + } + } + cbrk = usableSize + iCellLast = usableSize - int32(4) + iCellStart = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)))))< 0 { + temp = _sqlite3PagerTempSpace(tls, (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FpPager) + libc.X__builtin___memcpy_chk(tls, temp, data, libc.Uint64FromInt32(usableSize), ^t__predefined_size_t(0)) + src = temp + i = 0 + for { + if !(i < nCell) { + break + } /* The i-th cell pointer */ + pAddr1 = data + uintptr(cellOffset+i*int32(2)) + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pAddr1)))< iCellLast { + return _sqlite3CorruptError(tls, int32(74843)) + } + size = libc.Int32FromUint16((*(*func(*libc.TLS, uintptr, uintptr) Tu16)(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize})))(tls, pPage, src+uintptr(pc))) + cbrk = cbrk - size + if cbrk < iCellStart || pc+size > usableSize { + return _sqlite3CorruptError(tls, int32(74849)) + } + **(**Tu8)(__ccgo_up(pAddr1)) = libc.Uint8FromInt32(cbrk >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pAddr1 + 1)) = libc.Uint8FromInt32(cbrk) + libc.X__builtin___memcpy_chk(tls, data+uintptr(cbrk), src+uintptr(pc), libc.Uint64FromInt32(size), ^t__predefined_size_t(0)) + goto _2 + _2: + ; + i = i + 1 + } + } + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7)))) = uint8(0) + goto defragment_out +defragment_out: + ; + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7)))))+cbrk-iCellFirst != (*TMemPage)(unsafe.Pointer(pPage)).FnFree { + return _sqlite3CorruptError(tls, int32(74863)) + } + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)))) = libc.Uint8FromInt32(cbrk >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)) + 1)) = libc.Uint8FromInt32(cbrk) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(1)))) = uint8(0) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(2)))) = uint8(0) + libc.X__builtin___memset_chk(tls, data+uintptr(iCellFirst), 0, libc.Uint64FromInt32(cbrk-iCellFirst), ^t__predefined_size_t(0)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is called to configure the RtreeConstraint object passed +// ** as the second argument for a MATCH constraint. The value passed as the +// ** first argument to this function is the right-hand operand to the MATCH +// ** operator. +// */ +func _deserializeGeometry(tls *libc.TLS, pValue uintptr, pCons uintptr) (r int32) { + var pBlob, pInfo, pSrc uintptr + _, _, _ = pBlob, pInfo, pSrc /* Callback information */ + pSrc = Xsqlite3_value_pointer(tls, pValue, __ccgo_ts+27817) + if pSrc == uintptr(0) { + return int32(SQLITE_ERROR) + } + pInfo = Xsqlite3_malloc64(tls, uint64(112)+uint64((*TRtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize)) + if !(pInfo != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pInfo, 0, uint64(112), ^t__predefined_size_t(0)) + pBlob = pInfo + 1*112 + libc.X__builtin___memcpy_chk(tls, pBlob, pSrc, uint64((*TRtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize), ^t__predefined_size_t(0)) + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FpContext = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FpContext + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FnParam = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FaParam = pBlob + 56 + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FapSqlParam = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam + if (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom != 0 { + *(*uintptr)(unsafe.Pointer(pCons + 8)) = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom + } else { + (*TRtreeConstraint)(unsafe.Pointer(pCons)).Fop = int32(RTREE_QUERY) + *(*uintptr)(unsafe.Pointer(pCons + 8)) = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxQueryFunc + } + (*TRtreeConstraint)(unsafe.Pointer(pCons)).FpInfo = pInfo + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Write code to erase the table with root-page iTable from database iDb. +// ** Also write code to modify the sqlite_schema table and internal schema +// ** if a root-page of another table is moved by the btree-layer whilst +// ** erasing iTable (this can happen with an auto-vacuum database). +// */ +func _destroyRootPage(tls *libc.TLS, pParse uintptr, iTable int32, iDb int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var r1 int32 + var v uintptr + _, _ = r1, v + v = _sqlite3GetVdbe(tls, pParse) + r1 = _sqlite3GetTempReg(tls, pParse) + if iTable < int32(2) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15213, 0) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Destroy), iTable, r1, iDb) + _sqlite3MayAbort(tls, pParse) + /* OP_Destroy stores an in integer r1. If this integer + ** is non-zero, then it is the root page number of a table moved to + ** location iTable. The following code modifies the sqlite_schema table to + ** reflect this. + ** + ** The "#NNN" in the SQL is a special constant that means whatever value + ** is in register NNN. See grammar rules associated with the TK_REGISTER + ** token for additional information. + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+15228, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName, iTable, r1, r1)) + _sqlite3ReleaseTempReg(tls, pParse, r1) +} + +// C documentation +// +// /* +// ** An SQL user-function registered to do the work of an DETACH statement. The +// ** three arguments to the function come directly from a detach statement: +// ** +// ** DETACH DATABASE x +// ** +// ** SELECT sqlite_detach(x) +// */ +func _detachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var db, pDb, pEntry, pTrig, zName uintptr + var i int32 + var _ /* zErr at bp+0 */ [128]int8 + _, _, _, _, _, _ = db, i, pDb, pEntry, pTrig, zName + zName = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + db = Xsqlite3_context_db_handle(tls, context) + pDb = uintptr(0) + _ = NotUsed + if zName == uintptr(0) { + zName = __ccgo_ts + 1702 + } + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpBt == uintptr(0) { + goto _1 + } + if _sqlite3DbIsNamed(tls, db, i, zName) != 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i >= (*Tsqlite3)(unsafe.Pointer(db)).FnDb { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13786, libc.VaList(bp+136, zName)) + goto detach_error + } + if i < int32(2) { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13807, libc.VaList(bp+136, zName)) + goto detach_error + } + if _sqlite3BtreeTxnState(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) != SQLITE_TXN_NONE || _sqlite3BtreeIsInBackup(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) != 0 { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13833, libc.VaList(bp+136, zName)) + goto detach_error + } + /* If any TEMP triggers reference the schema being detached, move those + ** triggers to reference the TEMP schema itself. */ + pEntry = (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 56)).Ffirst + for pEntry != 0 { + pTrig = (*THashElem)(unsafe.Pointer(pEntry)).Fdata + if (*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema == (*TDb)(unsafe.Pointer(pDb)).FpSchema { + (*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema = (*TTrigger)(unsafe.Pointer(pTrig)).FpSchema + } + pEntry = (*THashElem)(unsafe.Pointer(pEntry)).Fnext + } + _sqlite3BtreeClose(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + (*TDb)(unsafe.Pointer(pDb)).FpBt = uintptr(0) + (*TDb)(unsafe.Pointer(pDb)).FpSchema = uintptr(0) + _sqlite3CollapseDatabaseArray(tls, db) + return + goto detach_error +detach_error: + ; + Xsqlite3_result_error(tls, context, bp, -int32(1)) +} + +var _detach_func = TFuncDef{ + FnArg: int16(1), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 13855, +} + +// C documentation +// +// /* +// ** Disable lookaside memory allocation for objects that might be +// ** shared across database connections. +// */ +func _disableLookaside(tls *libc.TLS, pParse uintptr) { + var db uintptr + _ = db + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + (*TParse)(unsafe.Pointer(pParse)).FdisableLookaside = (*TParse)(unsafe.Pointer(pParse)).FdisableLookaside + 1 + libc.X__builtin___memset_chk(tls, pParse+248, 0, uint64(32), ^t__predefined_size_t(0)) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) +} + +func _disallowAggregatesInOrderByCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_FUNCTION) && (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) { + _sqlite3ErrorMsg(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, __ccgo_ts+24755, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(pExpr + 8)))) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Close a file. Make sure the lock has been released before closing. +// */ +func _dotlockClose(tls *libc.TLS, id uintptr) (r int32) { + var pFile uintptr + _ = pFile + pFile = id + _dotlockUnlock(tls, id, NO_LOCK) + Xsqlite3_free(tls, (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext) + return _closeUnixFile(tls, id) +} + +/****************** End of the dot-file lock implementation ******************* +******************************************************************************/ + +/****************************************************************************** +************************** Begin flock Locking ******************************** +** +** Use the flock() system call to do file locking. +** +** flock() locking is like dot-file locking in that the various +** fine-grain locking levels supported by SQLite are collapsed into +** a single exclusive lock. In other words, SHARED, RESERVED, and +** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite +** still works when you do this, but concurrency is reduced since +** only a single process can be reading the database at a time. +** +** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off + */ + +// C documentation +// +// /* +// ** Remove the i-th cell from pPage. This routine effects pPage only. +// ** The cell content is not freed or deallocated. It is assumed that +// ** the cell content has been copied someplace else. This routine just +// ** removes the reference to the cell from pPage. +// ** +// ** "sz" must be the number of bytes in the cell. +// */ +func _dropCell(tls *libc.TLS, pPage uintptr, idx int32, sz int32, pRC uintptr) { + var data, ptr uintptr + var hdr, rc int32 + var pc Tu32 + _, _, _, _, _ = data, hdr, pc, ptr, rc /* Beginning of the header. 0 most pages. 100 page 1 */ + if **(**int32)(__ccgo_up(pRC)) != 0 { + return + } + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + ptr = (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*idx) + pc = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(ptr)))< (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize { + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(80423)) + return + } + rc = _freeSpace(tls, pPage, libc.Int32FromUint32(pc), sz) + if rc != 0 { + **(**int32)(__ccgo_up(pRC)) = rc + return + } + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = (*TMemPage)(unsafe.Pointer(pPage)).FnCell - 1 + if libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) == 0 { + libc.X__builtin___memset_chk(tls, data+uintptr(hdr+int32(1)), 0, uint64(4), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(7)))) = uint8(0) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(5)))) = uint8((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(5)) + 1)) = uint8((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) + (*TMemPage)(unsafe.Pointer(pPage)).FnFree = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize - uint32((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) - uint32((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) - uint32(8)) + } else { + libc.X__builtin___memmove_chk(tls, ptr, ptr+uintptr(2), libc.Uint64FromInt32(int32(2)*(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell)-idx)), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(3)))) = libc.Uint8FromInt32(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(3)) + 1)) = uint8((*TMemPage)(unsafe.Pointer(pPage)).FnCell) + **(**int32)(__ccgo_up(pPage + 20)) += int32(2) + } +} + +// C documentation +// +// /* +// ** The implementation of internal UDF sqlite_drop_column(). +// ** +// ** Arguments: +// ** +// ** argv[0]: An integer - the index of the schema containing the table +// ** argv[1]: CREATE TABLE statement to modify. +// ** argv[2]: An integer - the index of the column to remove. +// ** +// ** The value returned is a string containing the CREATE TABLE statement +// ** with column argv[2] removed. +// */ +func _dropColumnFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(464) + defer tls.Free(464) + var db, pCol, pEnd, pTab, zDb, zEnd, zNew, zSql uintptr + var iCol, iSchema, rc int32 + var xAuth Tsqlite3_xauth + var _ /* eTok at bp+416 */ int32 + var _ /* sParse at bp+0 */ TParse + _, _, _, _, _, _, _, _, _, _, _, _ = db, iCol, iSchema, pCol, pEnd, pTab, rc, xAuth, zDb, zEnd, zNew, zSql + db = Xsqlite3_context_db_handle(tls, context) + iSchema = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv))) + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*32))).FzDbSName + zNew = uintptr(0) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + _ = NotUsed + rc = _renameParseSql(tls, bp, zDb, db, zSql, libc.BoolInt32(iSchema == int32(1))) + if rc != SQLITE_OK { + goto drop_column_done + } + pTab = (**(**TParse)(__ccgo_up(bp))).FpNewTable + if pTab == uintptr(0) || int32((*TTable)(unsafe.Pointer(pTab)).FnCol) == int32(1) || iCol >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + /* This can happen if the sqlite_schema table is corrupt */ + rc = _sqlite3CorruptError(tls, int32(122622)) + goto drop_column_done + } + if iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1) { + pCol = _renameTokenFind(tls, bp, uintptr(0), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName) + pEnd = _renameTokenFind(tls, bp, uintptr(0), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol+int32(1))*16))).FzCnName) + zEnd = (*TRenameToken)(unsafe.Pointer(pEnd)).Ft.Fz + } else { + /* Point pCol->t.z at the "," immediately preceding the definition of + ** the column being dropped. To do this, start at the name of the + ** previous column, and tokenize until the next ",". */ + pCol = _renameTokenFind(tls, bp, uintptr(0), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol-int32(1))*16))).FzCnName) + for cond := true; cond; cond = **(**int32)(__ccgo_up(bp + 416)) != int32(TK_COMMA) { + (*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz += uintptr(_getConstraintToken(tls, (*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz, bp+416)) + } + (*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz = (*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz - 1 + zEnd = zSql + uintptr((*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FaddColOffset) + } + zNew = _sqlite3MPrintf(tls, db, __ccgo_ts+11929, libc.VaList(bp+432, int64((*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz)-int64(zSql), zSql, zEnd)) + Xsqlite3_result_text(tls, context, zNew, -int32(1), uintptr(-libc.Int32FromInt32(1))) + Xsqlite3_free(tls, zNew) + goto drop_column_done +drop_column_done: + ; + _renameParseCleanup(tls, bp) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + if rc != SQLITE_OK { + Xsqlite3_result_error_code(tls, context, rc) + } +} + +// C documentation +// +// /* +// ** Internal SQL function sqlite3_drop_constraint(): Given an input +// ** CREATE TABLE statement, return a revised CREATE TABLE statement +// ** with a constraint removed. Two forms, depending on the datatype +// ** of argv[2]: +// ** +// ** sqlite_drop_constraint(SQL, INT) -- Omit NOT NULL from the INT-th column +// ** sqlite_drop_constraint(SQL, TEXT) -- OMIT constraint with name TEXT +// ** +// ** In the first case, the left-most column is 0. +// */ +func _dropConstraintFunc(tls *libc.TLS, ctx uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, zCons, zNew, zSpace, zSql uintptr + var iEnd, iNotNull, iStart, ii, nTok int32 + var _ /* cmp at bp+8 */ int32 + var _ /* iOff at bp+0 */ int32 + var _ /* t at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _ = db, iEnd, iNotNull, iStart, ii, nTok, zCons, zNew, zSpace, zSql + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zCons = uintptr(0) + iNotNull = -int32(1) + **(**int32)(__ccgo_up(bp)) = 0 + iStart = 0 + iEnd = 0 + zNew = uintptr(0) + **(**int32)(__ccgo_up(bp + 4)) = 0 + _ = NotUsed + if zSql == uintptr(0) { + return + } + /* Jump past the "CREATE TABLE" bit. */ + if _skipCreateTable(tls, ctx, zSql, bp) != 0 { + return + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) == int32(SQLITE_INTEGER) { + iNotNull = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + zCons = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } + /* Search for the named constraint within column definitions. */ + ii = 0 + for { + if !(iEnd == 0) { + break + } + /* Now parse the column or table constraint definition. Search + ** for the token CONSTRAINT if this is a DROP CONSTRAINT command, or + ** NOT in the right column if this is a DROP NOT NULL. */ + for int32(1) != 0 { + iStart = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_CONSTRAINT) && (zCons != 0 || iNotNull == ii) { + /* Check if this is the constraint we are searching for. */ + nTok = 0 + **(**int32)(__ccgo_up(bp + 8)) = int32(1) + /* Skip past any whitespace. */ + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getWhitespace(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp)))) + /* Compare the next token - which may be quoted - with the name of + ** the constraint being dropped. */ + nTok = _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + if zCons != 0 { + if _quotedCompare(tls, ctx, **(**int32)(__ccgo_up(bp + 4)), zSql+uintptr(**(**int32)(__ccgo_up(bp))), nTok, zCons, bp+8) != 0 { + return + } + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + nTok + /* The next token is usually the first token of the constraint + ** definition. This is enough to tell the type of the constraint - + ** TK_NOT means it is a NOT NULL, TK_CHECK a CHECK constraint etc. + ** + ** There is also the chance that the next token is TK_CONSTRAINT + ** (or TK_DEFAULT or TK_COLLATE), for example if a table has been + ** created as follows: + ** + ** CREATE TABLE t1(cols, CONSTRAINT one CONSTRAINT two NOT NULL); + ** + ** In this case, allow the "CONSTRAINT one" bit to be dropped by + ** this command if that is what is requested, or to advance to + ** the next iteration of the loop with &zSql[iOff] still pointing + ** to the CONSTRAINT keyword. */ + nTok = _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_CONSTRAINT) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_DEFAULT) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COLLATE) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COMMA) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_RP) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_GENERATED) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_AS) { + **(**int32)(__ccgo_up(bp + 4)) = int32(TK_CHECK) + } else { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + nTok + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getConstraint(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp)))) + } + if **(**int32)(__ccgo_up(bp + 8)) == 0 || iNotNull >= 0 && **(**int32)(__ccgo_up(bp + 4)) == int32(TK_NOT) { + if **(**int32)(__ccgo_up(bp + 4)) != int32(TK_NOT) && **(**int32)(__ccgo_up(bp + 4)) != int32(TK_CHECK) { + _errorMPrintf(tls, ctx, __ccgo_ts+12163, libc.VaList(bp+24, zCons)) + return + } + iEnd = **(**int32)(__ccgo_up(bp)) + break + } + } else { + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_NOT) && iNotNull == ii { + iEnd = **(**int32)(__ccgo_up(bp)) + _getConstraint(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp)))) + break + } else { + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_RP) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_ILLEGAL) { + iEnd = -int32(1) + break + } else { + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COMMA) { + break + } + } + } + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + /* If the constraint has not been found it is an error. */ + if iEnd <= 0 { + if zCons != 0 { + _errorMPrintf(tls, ctx, __ccgo_ts+12197, libc.VaList(bp+24, zCons)) + } else { + /* SQLite follows postgres in that a DROP NOT NULL on a column that is + ** not NOT NULL is not an error. So just return the original SQL here. */ + Xsqlite3_result_text(tls, ctx, zSql, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } + } else { + /* Figure out if an extra space should be inserted after the constraint + ** is removed. And if an additional comma preceding the constraint + ** should be removed. */ + zSpace = __ccgo_ts + 11885 + iEnd = iEnd + _getWhitespace(tls, zSql+uintptr(iEnd)) + _sqlite3GetToken(tls, zSql+uintptr(iEnd), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_RP) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COMMA) { + zSpace = __ccgo_ts + 1702 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zSql + uintptr(iStart-int32(1))))) == int32(',') { + iStart = iStart - 1 + } + } + db = Xsqlite3_context_db_handle(tls, ctx) + zNew = _sqlite3MPrintf(tls, db, __ccgo_ts+12220, libc.VaList(bp+24, iStart, zSql, zSpace, zSql+uintptr(iEnd))) + Xsqlite3_result_text(tls, ctx, zNew, -int32(1), __ccgo_fp(_sqlite3RowSetClear)) + } +} + +// C documentation +// +// /* +// ** pCArray contains pointers to and sizes of all cells in the page being +// ** balanced. The current page, pPg, has pPg->nCell cells starting with +// ** pCArray->apCell[iOld]. After balancing, this page should hold nNew cells +// ** starting at apCell[iNew]. +// ** +// ** This routine makes the necessary adjustments to pPg so that it contains +// ** the correct cells after being balanced. +// ** +// ** The pPg->nFree field is invalid when this function returns. It is the +// ** responsibility of the caller to set it correctly. +// */ +func _editPage(tls *libc.TLS, pPg uintptr, iOld int32, iNew int32, nNew int32, pCArray uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aData, pBegin, pCellptr uintptr + var hdr, i, iCell, iNewEnd, iOldEnd, nAdd, nCell, nShift, nTail, v1 int32 + var _ /* pData at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, hdr, i, iCell, iNewEnd, iOldEnd, nAdd, nCell, nShift, nTail, pBegin, pCellptr, v1 + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FhdrOffset) + pBegin = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(nNew*int32(2)) + nCell = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPg)).FnCell) + iOldEnd = iOld + libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPg)).FnCell) + libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FnOverflow) + iNewEnd = iNew + nNew + /* Remove cells from the start and end of the page */ + if iOld < iNew { + nShift = _pageFreeArray(tls, pPg, iOld, iNew-iOld, pCArray) + if nShift > nCell { + return _sqlite3CorruptError(tls, int32(81033)) + } + libc.X__builtin___memmove_chk(tls, (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx, (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx+uintptr(nShift*int32(2)), libc.Uint64FromInt32(nCell*int32(2)), ^t__predefined_size_t(0)) + nCell = nCell - nShift + } + if iNewEnd < iOldEnd { + nTail = _pageFreeArray(tls, pPg, iNewEnd, iOldEnd-iNewEnd, pCArray) + nCell = nCell - nTail + } + **(**uintptr)(__ccgo_up(bp)) = aData + uintptr(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)))))< (*TMemPage)(unsafe.Pointer(pPg)).FaDataEnd { + goto editpage_fail + } + /* Add cells to the start of the page */ + if iNew < iOld { + if nNew < iOld-iNew { + v1 = nNew + } else { + v1 = iOld - iNew + } + nAdd = v1 + pCellptr = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + libc.X__builtin___memmove_chk(tls, pCellptr+uintptr(nAdd*int32(2)), pCellptr, libc.Uint64FromInt32(nCell*int32(2)), ^t__predefined_size_t(0)) + if _pageInsertArray(tls, pPg, pBegin, bp, pCellptr, iNew, nAdd, pCArray) != 0 { + goto editpage_fail + } + nCell = nCell + nAdd + } + /* Add any overflow cells */ + i = 0 + for { + if !(i < libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FnOverflow)) { + break + } + iCell = iOld + libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pPg + 28 + uintptr(i)*2))) - iNew + if iCell >= 0 && iCell < nNew { + pCellptr = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(iCell*int32(2)) + if nCell > iCell { + libc.X__builtin___memmove_chk(tls, pCellptr+2, pCellptr, libc.Uint64FromInt32((nCell-iCell)*int32(2)), ^t__predefined_size_t(0)) + } + nCell = nCell + 1 + _cachedCellSize(tls, pCArray, iCell+iNew) + if _pageInsertArray(tls, pPg, pBegin, bp, pCellptr, iCell+iNew, int32(1), pCArray) != 0 { + goto editpage_fail + } + } + goto _2 + _2: + ; + i = i + 1 + } + /* Append cells to the end of the page */ + pCellptr = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(nCell*int32(2)) + if _pageInsertArray(tls, pPg, pBegin, bp, pCellptr, iNew+nCell, nNew-nCell, pCArray) != 0 { + goto editpage_fail + } + (*TMemPage)(unsafe.Pointer(pPg)).FnCell = libc.Uint16FromInt32(nNew) + (*TMemPage)(unsafe.Pointer(pPg)).FnOverflow = uint8(0) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(3)))) = libc.Uint8FromInt32(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPg)).FnCell) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(3)) + 1)) = uint8((*TMemPage)(unsafe.Pointer(pPg)).FnCell) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)))) = libc.Uint8FromInt64((int64(**(**uintptr)(__ccgo_up(bp))) - int64(aData)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)) + 1)) = libc.Uint8FromInt64(int64(**(**uintptr)(__ccgo_up(bp))) - int64(aData)) + return SQLITE_OK + goto editpage_fail +editpage_fail: + ; + /* Unable to edit this page. Rebuild it from scratch instead. */ + if nNew < int32(1) { + return _sqlite3CorruptError(tls, int32(81111)) + } + _populateCellCache(tls, pCArray, iNew, nNew) + return _rebuildPage(tls, pCArray, iNew, nNew, pPg) +} + +var _encnames = [4]uintptr{ + 0: __ccgo_ts + 5603, + 1: __ccgo_ts + 5605, + 2: __ccgo_ts + 5607, + 3: __ccgo_ts + 5612, +} + +var _encnames1 = [9]struct { + FzName uintptr + Fenc Tu8 +}{ + 0: { + FzName: __ccgo_ts + 20185, + Fenc: uint8(SQLITE_UTF8), + }, + 1: { + FzName: __ccgo_ts + 20190, + Fenc: uint8(SQLITE_UTF8), + }, + 2: { + FzName: __ccgo_ts + 20196, + Fenc: uint8(SQLITE_UTF16LE), + }, + 3: { + FzName: __ccgo_ts + 20205, + Fenc: uint8(SQLITE_UTF16BE), + }, + 4: { + FzName: __ccgo_ts + 20214, + Fenc: uint8(SQLITE_UTF16LE), + }, + 5: { + FzName: __ccgo_ts + 20222, + Fenc: uint8(SQLITE_UTF16BE), + }, + 6: { + FzName: __ccgo_ts + 20230, + }, + 7: { + FzName: __ccgo_ts + 20237, + }, + 8: {}, +} + +// C documentation +// +// /* +// ** The StrAccum "p" is not large enough to accept N new bytes of z[]. +// ** So enlarge if first, then do the append. +// ** +// ** This is a helper routine to sqlite3_str_append() that does special-case +// ** work (enlarging the buffer) using tail recursion, so that the +// ** sqlite3_str_append() routine can use fast calling semantics. +// */ +func _enlargeAndAppend(tls *libc.TLS, p uintptr, z uintptr, N int32) { + N = _sqlite3StrAccumEnlarge(tls, p, int64(N)) + if N > 0 { + libc.X__builtin___memcpy_chk(tls, (*TStrAccum)(unsafe.Pointer(p)).FzText+uintptr((*TStrAccum)(unsafe.Pointer(p)).FnChar), z, libc.Uint64FromInt32(N), ^t__predefined_size_t(0)) + **(**Tu32)(__ccgo_up(p + 24)) += libc.Uint32FromInt32(N) + } +} + +// C documentation +// +// /* +// ** Execute zSql on database db. +// ** +// ** If zSql returns rows, then each row will have exactly one +// ** column. (This will only happen if zSql begins with "SELECT".) +// ** Take each row of result and call execSql() again recursively. +// ** +// ** The execSqlF() routine does the same thing, except it accepts +// ** a format string as its third argument +// */ +func _execSql(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc, v1 int32 + var zSubSql uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _ = rc, zSubSql, v1 + /* printf("SQL: [%s]\n", zSql); fflush(stdout); */ + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + if rc != SQLITE_OK { + return rc + } + for { + v1 = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = v1 + if !(int32(SQLITE_ROW) == v1) { + break + } + zSubSql = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + /* The secondary SQL must be one of CREATE TABLE, CREATE INDEX, + ** or INSERT. Historically there have been attacks that first + ** corrupt the sqlite_schema.sql field with other kinds of statements + ** then run VACUUM to get those statements to execute at inappropriate + ** times. */ + if zSubSql != 0 && (libc.Xstrncmp(tls, zSubSql, __ccgo_ts+23055, uint64(3)) == 0 || libc.Xstrncmp(tls, zSubSql, __ccgo_ts+23059, uint64(3)) == 0) { + rc = _execSql(tls, db, pzErrMsg, zSubSql) + if rc != SQLITE_OK { + break + } + } + } + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + if rc != 0 { + _sqlite3SetString(tls, pzErrMsg, db, Xsqlite3_errmsg(tls, db)) + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Argument pWhere is the WHERE clause belonging to SELECT statement p. This +// ** function attempts to transform expressions of the form: +// ** +// ** EXISTS (SELECT ...) +// ** +// ** into joins. For example, given +// ** +// ** CREATE TABLE sailors(sid INTEGER PRIMARY KEY, name TEXT); +// ** CREATE TABLE reserves(sid INT, day DATE, PRIMARY KEY(sid, day)); +// ** +// ** SELECT name FROM sailors AS S WHERE EXISTS ( +// ** SELECT * FROM reserves AS R WHERE S.sid = R.sid AND R.day = '2022-10-25' +// ** ); +// ** +// ** the SELECT statement may be transformed as follows: +// ** +// ** SELECT name FROM sailors AS S, reserves AS R +// ** WHERE S.sid = R.sid AND R.day = '2022-10-25'; +// ** +// ** **Approximately**. Really, we have to ensure that the FROM-clause term +// ** that was formerly inside the EXISTS is only executed once. This is handled +// ** by setting the SrcItem.fg.fromExists flag, which then causes code in +// ** the where.c file to exit the corresponding loop after the first successful +// ** match (if any). +// */ +func _existsToJoin(tls *libc.TLS, pParse uintptr, p uintptr, pWhere uintptr) { + var aCsrMap, db, pRight, pSub, pSubWhere uintptr + _, _, _, _, _ = aCsrMap, db, pRight, pSub, pSubWhere + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && pWhere != uintptr(0) && !((*TExpr)(unsafe.Pointer(pWhere)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != libc.Uint32FromInt32(0)) && (*TSelect)(unsafe.Pointer(p)).FpSrc != uintptr(0) && (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) && ((*TSelect)(unsafe.Pointer(p)).FpLimit == uintptr(0) || (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpLimit)).FpRight == uintptr(0)) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pWhere)).Fop) == int32(TK_AND) { + pRight = (*TExpr)(unsafe.Pointer(pWhere)).FpRight + _existsToJoin(tls, pParse, p, (*TExpr)(unsafe.Pointer(pWhere)).FpLeft) + _existsToJoin(tls, pParse, p, pRight) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pWhere)).Fop) == int32(TK_EXISTS) { + pSub = *(*uintptr)(unsafe.Pointer(pWhere + 32)) + pSubWhere = (*TSelect)(unsafe.Pointer(pSub)).FpWhere + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpSrc)).FnSrc == int32(1) && (*TSelect)(unsafe.Pointer(pSub)).FselFlags&uint32(SF_Aggregate) == uint32(0) && !(int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpSrc + 8 + 24 + 4))&0x4>>2) != 0) && (*TSelect)(unsafe.Pointer(pSub)).FpLimit == uintptr(0) && (*TSelect)(unsafe.Pointer(pSub)).FpPrior == uintptr(0) { + /* Before combining the sub-select with the parent, renumber the + ** cursor used by the subselect. This is because the EXISTS expression + ** might be a copy of another EXISTS expression from somewhere + ** else in the tree, and in this case it is important that it use + ** a unique cursor number. */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + aCsrMap = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt32((*TParse)(unsafe.Pointer(pParse)).FnTab+libc.Int32FromInt32(2))*uint64(4))) + if aCsrMap == uintptr(0) { + return + } + **(**int32)(__ccgo_up(aCsrMap)) = (*TParse)(unsafe.Pointer(pParse)).FnTab + int32(1) + _renumberCursors(tls, pParse, pSub, -int32(1), aCsrMap) + _sqlite3DbFree(tls, db, aCsrMap) + libc.X__builtin___memset_chk(tls, pWhere, 0, uint64(72), ^t__predefined_size_t(0)) + (*TExpr)(unsafe.Pointer(pWhere)).Fop = uint8(TK_INTEGER) + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pWhere)).Fu)) = int32(1) + **(**Tu32)(__ccgo_up(pWhere + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) + libc.SetBitFieldPtr32Uint32((*TSelect)(unsafe.Pointer(pSub)).FpSrc+8+24+4, libc.Uint32FromInt32(1), 18, 0x40000) + (*TSelect)(unsafe.Pointer(p)).FpSrc = _sqlite3SrcListAppendList(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpSrc, (*TSelect)(unsafe.Pointer(pSub)).FpSrc) + if pSubWhere != 0 { + (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3PExpr(tls, pParse, int32(TK_AND), (*TSelect)(unsafe.Pointer(p)).FpWhere, pSubWhere) + (*TSelect)(unsafe.Pointer(pSub)).FpWhere = uintptr(0) + } + (*TSelect)(unsafe.Pointer(pSub)).FpSrc = uintptr(0) + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3SelectDeleteGeneric), pSub) + } + } + } + } +} + +// C documentation +// +// /* +// ** This routine is a helper for explainIndexRange() below +// ** +// ** pStr holds the text of an expression that we are building up one term +// ** at a time. This routine adds a new term to the end of the expression. +// ** Terms are separated by AND so add the "AND" text for second and subsequent +// ** terms only. +// */ +func _explainAppendTerm(tls *libc.TLS, pStr uintptr, pIdx uintptr, nTerm int32, iTerm int32, bAnd int32, zOp uintptr) { + var i int32 + _ = i + if bAnd != 0 { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23951, int32(5)) + } + if nTerm > int32(1) { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23957, int32(1)) + } + i = 0 + for { + if !(i < nTerm) { + break + } + if i != 0 { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+14690, int32(1)) + } + Xsqlite3_str_appendall(tls, pStr, _explainIndexColumnName(tls, pIdx, iTerm+i)) + goto _1 + _1: + ; + i = i + 1 + } + if nTerm > int32(1) { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+5601, int32(1)) + } + Xsqlite3_str_append(tls, pStr, zOp, int32(1)) + if nTerm > int32(1) { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23957, int32(1)) + } + i = 0 + for { + if !(i < nTerm) { + break + } + if i != 0 { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+14690, int32(1)) + } + Xsqlite3_str_append(tls, pStr, __ccgo_ts+5603, int32(1)) + goto _2 + _2: + ; + i = i + 1 + } + if nTerm > int32(1) { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+5601, int32(1)) + } +} + +// C documentation +// +// /* +// ** Return the name of the i-th column of the pIdx index. +// */ +func _explainIndexColumnName(tls *libc.TLS, pIdx uintptr, i int32) (r uintptr) { + i = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) + if i == -int32(2) { + return __ccgo_ts + 23944 + } + if i == -int32(1) { + return __ccgo_ts + 18310 + } + return (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(i)*16))).FzCnName +} + +// C documentation +// +// /* +// ** Argument pLevel describes a strategy for scanning table pTab. This +// ** function appends text to pStr that describes the subset of table +// ** rows scanned by the strategy in the form of an SQL expression. +// ** +// ** For example, if the query: +// ** +// ** SELECT * FROM t1 WHERE a=1 AND b>2; +// ** +// ** is run and there is an index on (a, b), then this function returns a +// ** string similar to: +// ** +// ** "a=? AND b>?" +// */ +func _explainIndexRange(tls *libc.TLS, pStr uintptr, pLoop uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j int32 + var nEq, nSkip Tu16 + var pIndex, z, v2 uintptr + _, _, _, _, _, _, _ = i, j, nEq, nSkip, pIndex, z, v2 + pIndex = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + nEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq + nSkip = (*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip + if libc.Int32FromUint16(nEq) == 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_BTM_LIMIT)|libc.Int32FromInt32(WHERE_TOP_LIMIT)) == uint32(0) { + return + } + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23959, int32(2)) + i = 0 + for { + if !(i < libc.Int32FromUint16(nEq)) { + break + } + z = _explainIndexColumnName(tls, pIndex, i) + if i != 0 { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23951, int32(5)) + } + if i >= libc.Int32FromUint16(nSkip) { + v2 = __ccgo_ts + 23962 + } else { + v2 = __ccgo_ts + 23967 + } + Xsqlite3_str_appendf(tls, pStr, v2, libc.VaList(bp+8, z)) + goto _1 + _1: + ; + i = i + 1 + } + j = i + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BTM_LIMIT) != 0 { + _explainAppendTerm(tls, pStr, pIndex, libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm), j, i, __ccgo_ts+23975) + i = int32(1) + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_TOP_LIMIT) != 0 { + _explainAppendTerm(tls, pStr, pIndex, libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop), j, i, __ccgo_ts+23977) + } + Xsqlite3_str_append(tls, pStr, __ccgo_ts+5601, int32(1)) +} + +// C documentation +// +// /* +// ** Add a single OP_Explain instruction to the VDBE to explain a simple +// ** count(*) query ("SELECT count(*) FROM pTab"). +// */ +func _explainSimpleCount(tls *libc.TLS, pParse uintptr, pTab uintptr, pIdx uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bCover int32 + var v1, v2 uintptr + _, _, _ = bCover, v1, v2 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fexplain) == int32(2) { + bCover = libc.BoolInt32(pIdx != uintptr(0) && ((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || !(int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == libc.Int32FromInt32(SQLITE_IDXTYPE_PRIMARYKEY)))) + if bCover != 0 { + v1 = __ccgo_ts + 21876 + } else { + v1 = __ccgo_ts + 1702 + } + if bCover != 0 { + v2 = (*TIndex)(unsafe.Pointer(pIdx)).FzName + } else { + v2 = __ccgo_ts + 1702 + } + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+21899, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, v1, v2)) + } +} + +// C documentation +// +// /* +// ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function +// ** is a no-op. Otherwise, it adds a single row of output to the EQP result, +// ** where the caption is of the form: +// ** +// ** "USE TEMP B-TREE FOR xxx" +// ** +// ** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which +// ** is determined by the zUsage argument. +// */ +func _explainTempTable(tls *libc.TLS, pParse uintptr, zUsage uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20911, libc.VaList(bp+8, zUsage)) +} + +/* +** Assign expression b to lvalue a. A second, no-op, version of this macro +** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code +** in sqlite3Select() to assign values to structure member variables that +** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the +** code with #ifndef directives. + */ + +// C documentation +// +// /* +// ** The input to this routine is an WhereTerm structure with only the +// ** "pExpr" field filled in. The job of this routine is to analyze the +// ** subexpression and populate all the other fields of the WhereTerm +// ** structure. +// ** +// ** If the expression is of the form " X" it gets commuted +// ** to the standard form of "X ". +// ** +// ** If the expression is of the form "X Y" where both X and Y are +// ** columns, then the original expression is unchanged and a new virtual +// ** term of the form "Y X" is added to the WHERE clause and +// ** analyzed separately. The original term is marked with TERM_COPIED +// ** and the new term is marked with TERM_DYNAMIC (because it's pExpr +// ** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it +// ** is a commuted copy of a prior term.) The original term has nChild=1 +// ** and the copy has idxParent set to the index of the original term. +// */ +func _exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var c, v12 int8 + var db, pC, pDup, pExpr, pLeft, pLeft1, pLeft2, pLeft3, pList, pMaskSet, pNew, pNew1, pNewExpr, pNewExpr1, pNewExpr11, pNewExpr2, pNewExpr21, pNewTerm, pNewTerm1, pParse, pRight, pRight1, pStr2, pTerm, pWInfo, t, zCollSeqName, v1 uintptr + var eExtraOp, opMask, wtFlags Tu16 + var extraRight, prereqAll, prereqColumn, prereqExpr, prereqLeft, x TBitmask + var i, i1, i2, i3, idxNew, idxNew1, idxNew11, idxNew2, idxNew21, idxNew3, idxNew4, idxNew5, nLeft, op, res, v2 int32 + var v15 bool + var _ /* aiCurCol at bp+24 */ [2]int32 + var _ /* eOp2 at bp+16 */ uint8 + var _ /* isComplete at bp+8 */ int32 + var _ /* noCase at bp+12 */ int32 + var _ /* pLeft at bp+40 */ uintptr + var _ /* pRight at bp+32 */ uintptr + var _ /* pStr1 at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, db, eExtraOp, extraRight, i, i1, i2, i3, idxNew, idxNew1, idxNew11, idxNew2, idxNew21, idxNew3, idxNew4, idxNew5, nLeft, op, opMask, pC, pDup, pExpr, pLeft, pLeft1, pLeft2, pLeft3, pList, pMaskSet, pNew, pNew1, pNewExpr, pNewExpr1, pNewExpr11, pNewExpr2, pNewExpr21, pNewTerm, pNewTerm1, pParse, pRight, pRight1, pStr2, pTerm, pWInfo, prereqAll, prereqColumn, prereqExpr, prereqLeft, res, t, wtFlags, x, zCollSeqName, v1, v12, v15, v2 + pWInfo = (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo /* Prerequisites of pExpr */ + extraRight = uint64(0) /* Extra dependencies on LEFT JOIN */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* RHS of LIKE/GLOB operator */ + **(**int32)(__ccgo_up(bp + 8)) = 0 /* RHS of LIKE/GLOB ends with wildcard */ + **(**int32)(__ccgo_up(bp + 12)) = 0 /* Top-level operator. pExpr->op */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parsing context */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + **(**uint8)(__ccgo_up(bp + 16)) = uint8(0) /* Number of elements on left side vector */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + pMaskSet = pWInfo + 592 + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + /* Because malloc() has not failed */ + (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 0 + prereqLeft = _sqlite3WhereExprUsage(tls, pMaskSet, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + if op == int32(TK_IN) { + if _sqlite3ExprCheckIN(tls, pParse, pExpr) != 0 { + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } else { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _sqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } + prereqAll = prereqLeft | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight + } else { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _sqlite3WhereExprUsage(tls, pMaskSet, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft == uintptr(0) || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_xIsSelect)|libc.Int32FromInt32(EP_IfNullRow)) != uint32(0) || *(*uintptr)(unsafe.Pointer(pExpr + 32)) != uintptr(0) { + prereqAll = _sqlite3WhereExprUsageNN(tls, pMaskSet, pExpr) + } else { + prereqAll = prereqLeft | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight + } + } + if (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect != 0 { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_VARSELECT)) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + x = _sqlite3WhereGetMask(tls, pMaskSet, *(*int32)(unsafe.Pointer(pExpr + 52))) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) { + prereqAll = prereqAll | x + extraRight = x - uint64(1) /* ON clause terms may not be used with an index + ** on left table of a LEFT JOIN. Ticket #3015 */ + } else { + if prereqAll>>libc.Int32FromInt32(1) >= x { + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) + } + } + } + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = prereqAll + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = -int32(1) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FiParent = -int32(1) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(0) + if _allowedOp(tls, op) != 0 { + pLeft = _sqlite3ExprSkipCollate(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + pRight = _sqlite3ExprSkipCollate(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&prereqLeft == uint64(0) { + v2 = int32(WO_ALL) + } else { + v2 = int32(WO_EQUIV) + } + opMask = libc.Uint16FromInt32(v2) + if (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField > 0 { + pLeft = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 32)) + 8 + uintptr((*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField-int32(1))*32))).FpExpr + } + if _exprMightBeIndexed(tls, pSrc, bp+24, pLeft, op) != 0 { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = (**(**[2]int32)(__ccgo_up(bp + 24)))[0] + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn = (**(**[2]int32)(__ccgo_up(bp + 24)))[int32(1)] + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = libc.Uint16FromInt32(libc.Int32FromUint16(_operatorMask(tls, op)) & libc.Int32FromUint16(opMask)) + } + if op == int32(TK_IS) { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_IS)) + } + if pRight != 0 && _exprMightBeIndexed(tls, pSrc, bp+24, pRight, op) != 0 && !((*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != libc.Uint32FromInt32(0)) { + eExtraOp = uint16(0) /* Extra bits for pNew->eOperator */ + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor >= 0 { + pDup = _sqlite3ExprDup(tls, db, pExpr, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pDup) + return + } + idxNew = _whereClauseInsert(tls, pWC, pDup, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + if idxNew == 0 { + return + } + pNew = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*56 + _markTermAsChild(tls, pWC, idxNew, idxTerm) + if op == int32(TK_IS) { + v1 = pNew + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_IS)) + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + if _termIsEquivalence(tls, pParse, pDup, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList) != 0 { + v1 = pTerm + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(WO_EQUIV)) + eExtraOp = uint16(WO_EQUIV) + } + } else { + pDup = pExpr + pNew = pTerm + } + v1 = pNew + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16(_exprCommute(tls, pParse, pDup))) + (*TWhereTerm)(unsafe.Pointer(pNew)).FleftCursor = (**(**[2]int32)(__ccgo_up(bp + 24)))[0] + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNew + 32))).FleftColumn = (**(**[2]int32)(__ccgo_up(bp + 24)))[int32(1)] + (*TWhereTerm)(unsafe.Pointer(pNew)).FprereqRight = prereqLeft | extraRight + (*TWhereTerm)(unsafe.Pointer(pNew)).FprereqAll = prereqAll + (*TWhereTerm)(unsafe.Pointer(pNew)).FeOperator = libc.Uint16FromInt32((libc.Int32FromUint16(_operatorMask(tls, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pDup)).Fop))) + libc.Int32FromUint16(eExtraOp)) & libc.Int32FromUint16(opMask)) + } else { + if op == int32(TK_ISNULL) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) && 0 == _sqlite3ExprCanBeNull(tls, pLeft) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_TRUEFALSE) /* See tag-20230504-1 */ + *(*uintptr)(unsafe.Pointer(pExpr + 8)) = __ccgo_ts + 8527 + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_IsFalse)) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = uint64(0) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(0) + } + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_BETWEEN) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + i = 0 + for { + if !(i < int32(2)) { + break + } + pNewExpr = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8(_ops[i]), _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, 0), _sqlite3ExprDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr, 0)) + _transferJoinMarkings(tls, pNewExpr, pExpr) + idxNew1 = _whereClauseInsert(tls, pWC, pNewExpr, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + _exprAnalyze(tls, pSrc, pWC, idxNew1) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + _markTermAsChild(tls, pWC, idxNew1, idxTerm) + goto _8 + _8: + ; + i = i + 1 + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_OR) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != libc.Uint32FromInt32(0)) { + _exprAnalyzeOrTerm(tls, pSrc, pWC, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == int32(TK_COLUMN) && int32((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).FiColumn) >= 0 && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) { + pLeft1 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pNewExpr1 = _sqlite3PExpr(tls, pParse, int32(TK_GT), _sqlite3ExprDup(tls, db, pLeft1, 0), _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0)) + idxNew2 = _whereClauseInsert(tls, pWC, pNewExpr1, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC)|libc.Int32FromInt32(TERM_VNULL))) + if idxNew2 != 0 { + pNewTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew2)*56 + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = uint64(0) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*TExpr)(unsafe.Pointer(pLeft1)).FiTable + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNewTerm + 32))).FleftColumn = int32((*TExpr)(unsafe.Pointer(pLeft1)).FiColumn) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ) << (libc.Int32FromInt32(TK_GT) - libc.Int32FromInt32(TK_EQ))) + _markTermAsChild(tls, pWC, idxNew2, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll + } + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_FUNCTION) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) && _isLikeOrGlob(tls, pParse, pExpr, bp, bp+8, bp+12) != 0 { /* Name of collating sequence */ + wtFlags = libc.Uint16FromInt32(libc.Int32FromInt32(TERM_LIKEOPT) | libc.Int32FromInt32(TERM_VIRTUAL) | libc.Int32FromInt32(TERM_DYNAMIC)) + pLeft2 = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr + pStr2 = _sqlite3ExprDup(tls, db, **(**uintptr)(__ccgo_up(bp)), 0) + /* Convert the lower bound to upper-case and the upper bound to + ** lower-case (upper-case is less than lower-case in ASCII) so that + ** the range constraints also work for BLOBs + */ + if **(**int32)(__ccgo_up(bp + 12)) != 0 && !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_LIKE)) + i1 = 0 + for { + v12 = **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 8)) + uintptr(i1))) + c = v12 + if !(int32(v12) != 0) { + break + } + **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 8)) + uintptr(i1))) = int8(int32(c) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(c)]) & libc.Int32FromInt32(0x20))) + **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pStr2 + 8)) + uintptr(i1))) = libc.Int8FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(c)]) + goto _11 + _11: + ; + i1 = i1 + 1 + } + } + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { /* Last character before the first wildcard */ + pC = *(*uintptr)(unsafe.Pointer(pStr2 + 8)) + uintptr(_sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pStr2 + 8)))-int32(1)) + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + /* The point is to increment the last character before the first + ** wildcard. But if we increment '@', that will push it into the + ** alphabetic range where case conversions will mess up the + ** inequality. To avoid this, make sure to also run the full + ** LIKE on all candidate expressions by clearing the isComplete flag + */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pC))) == libc.Int32FromUint8('A')-libc.Int32FromInt32(1) { + **(**int32)(__ccgo_up(bp + 8)) = 0 + } + **(**Tu8)(__ccgo_up(pC)) = _sqlite3UpperToLower[**(**Tu8)(__ccgo_up(pC))] + } + /* Increment the value of the last utf8 character in the prefix. */ + for libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pC))) == int32(0xBF) && pC > *(*uintptr)(unsafe.Pointer(pStr2 + 8)) { + **(**Tu8)(__ccgo_up(pC)) = uint8(0x80) + pC = pC - 1 + } + /* isLikeOrGlob() guarantees this */ + **(**Tu8)(__ccgo_up(pC)) = **(**Tu8)(__ccgo_up(pC)) + 1 + } + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + v1 = __ccgo_ts + 24267 + } else { + v1 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + zCollSeqName = v1 + pNewExpr11 = _sqlite3ExprDup(tls, db, pLeft2, 0) + pNewExpr11 = _sqlite3PExpr(tls, pParse, int32(TK_GE), _sqlite3ExprAddCollateString(tls, pParse, pNewExpr11, zCollSeqName), **(**uintptr)(__ccgo_up(bp))) + _transferJoinMarkings(tls, pNewExpr11, pExpr) + idxNew11 = _whereClauseInsert(tls, pWC, pNewExpr11, wtFlags) + pNewExpr21 = _sqlite3ExprDup(tls, db, pLeft2, 0) + pNewExpr21 = _sqlite3PExpr(tls, pParse, int32(TK_LT), _sqlite3ExprAddCollateString(tls, pParse, pNewExpr21, zCollSeqName), pStr2) + _transferJoinMarkings(tls, pNewExpr21, pExpr) + idxNew21 = _whereClauseInsert(tls, pWC, pNewExpr21, wtFlags) + _exprAnalyze(tls, pSrc, pWC, idxNew11) + _exprAnalyze(tls, pSrc, pWC, idxNew21) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + _markTermAsChild(tls, pWC, idxNew11, idxTerm) + _markTermAsChild(tls, pWC, idxNew21, idxTerm) + } + } + } + } + } + } + /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create + ** new terms for each component comparison - "a = ?" and "b = ?". The + ** new terms completely replace the original vector comparison, which is + ** no longer used. + ** + ** This is only required if at least one side of the comparison operation + ** is not a sub-select. + ** + ** tag-20220128a + */ + if v15 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_EQ) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IS); v15 { + v2 = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + nLeft = v2 + } + if v15 && v2 > int32(1) && _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) == nLeft && ((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags&uint32(EP_xIsSelect) == uint32(0) || (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpRight)).Fflags&uint32(EP_xIsSelect) == uint32(0)) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + i2 = 0 + for { + if !(i2 < nLeft) { + break + } + pLeft3 = _sqlite3ExprForVectorField(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, i2, nLeft) + pRight1 = _sqlite3ExprForVectorField(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, i2, nLeft) + pNew1 = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop), pLeft3, pRight1) + _transferJoinMarkings(tls, pNew1, pExpr) + idxNew3 = _whereClauseInsert(tls, pWC, pNew1, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_DYNAMIC)|libc.Int32FromInt32(TERM_SLICE))) + _exprAnalyze(tls, pSrc, pWC, idxNew3) + goto _16 + _16: + ; + i2 = i2 + 1 + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | (libc.Int32FromInt32(TERM_CODED) | libc.Int32FromInt32(TERM_VIRTUAL))) /* Disable the original */ + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(WO_ROWVAL) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IN) && (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField == 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == int32(TK_VECTOR) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && ((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpPrior == uintptr(0) || (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselFlags&uint32(SF_Values) != 0) && (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpWin == uintptr(0) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + i3 = 0 + for { + if !(i3 < _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft)) { + break + } + idxNew4 = _whereClauseInsert(tls, pWC, pExpr, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_SLICE))) + *(*int32)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew4)*56 + 32 + 4)) = i3 + int32(1) + _exprAnalyze(tls, pSrc, pWC, idxNew4) + _markTermAsChild(tls, pWC, idxNew4, idxTerm) + goto _18 + _18: + ; + i3 = i3 + 1 + } + } else { + if libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + res = _isAuxiliaryVtabOperator(tls, db, pExpr, bp+16, bp+40, bp+32) + for { + v2 = res + res = res - 1 + if !(v2 > 0) { + break + } + prereqExpr = _sqlite3WhereExprUsage(tls, pMaskSet, **(**uintptr)(__ccgo_up(bp + 32))) + prereqColumn = _sqlite3WhereExprUsage(tls, pMaskSet, **(**uintptr)(__ccgo_up(bp + 40))) + if prereqExpr&prereqColumn == uint64(0) { + pNewExpr2 = _sqlite3PExpr(tls, pParse, int32(TK_MATCH), uintptr(0), _sqlite3ExprDup(tls, db, **(**uintptr)(__ccgo_up(bp + 32)), 0)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) && pNewExpr2 != 0 { + **(**Tu32)(__ccgo_up(pNewExpr2 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) + *(*int32)(unsafe.Pointer(pNewExpr2 + 52)) = *(*int32)(unsafe.Pointer(pExpr + 52)) + } + idxNew5 = _whereClauseInsert(tls, pWC, pNewExpr2, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + pNewTerm1 = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew5)*56 + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FprereqRight = prereqExpr | extraRight + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FleftCursor = (*TExpr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 40)))).FiTable + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNewTerm1 + 32))).FleftColumn = int32((*TExpr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 40)))).FiColumn) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FeOperator = uint16(WO_AUX) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FeMatchOp = **(**uint8)(__ccgo_up(bp + 16)) + _markTermAsChild(tls, pWC, idxNew5, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FprereqAll = (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll + } + t = **(**uintptr)(__ccgo_up(bp + 40)) + **(**uintptr)(__ccgo_up(bp + 40)) = **(**uintptr)(__ccgo_up(bp + 32)) + **(**uintptr)(__ccgo_up(bp + 32)) = t + } + } + } + } + /* Prevent ON clause terms of a LEFT JOIN from being used to drive + ** an index for tables to the left of the join. + */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + **(**TBitmask)(__ccgo_up(pTerm + 40)) |= extraRight +} + +// C documentation +// +// /* +// ** Analyze a term that consists of two or more OR-connected +// ** subterms. So in: +// ** +// ** ... WHERE (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13) +// ** ^^^^^^^^^^^^^^^^^^^^ +// ** +// ** This routine analyzes terms such as the middle term in the above example. +// ** A WhereOrTerm object is computed and attached to the term under +// ** analysis, regardless of the outcome of the analysis. Hence: +// ** +// ** WhereTerm.wtFlags |= TERM_ORINFO +// ** WhereTerm.u.pOrInfo = a dynamically allocated WhereOrTerm object +// ** +// ** The term being analyzed must have two or more of OR-connected subterms. +// ** A single subterm might be a set of AND-connected sub-subterms. +// ** Examples of terms under analysis: +// ** +// ** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5 +// ** (B) x=expr1 OR expr2=x OR x=expr3 +// ** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15) +// ** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*') +// ** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6) +// ** (F) x>A OR (x=A AND y>=B) +// ** +// ** CASE 1: +// ** +// ** If all subterms are of the form T.C=expr for some single column of C and +// ** a single table T (as shown in example B above) then create a new virtual +// ** term that is an equivalent IN expression. In other words, if the term +// ** being analyzed is: +// ** +// ** x = expr1 OR expr2 = x OR x = expr3 +// ** +// ** then create a new virtual term like this: +// ** +// ** x IN (expr1,expr2,expr3) +// ** +// ** CASE 2: +// ** +// ** If there are exactly two disjuncts and one side has x>A and the other side +// ** has x=A (for the same x and A) then add a new virtual conjunct term to the +// ** WHERE clause of the form "x>=A". Example: +// ** +// ** x>A OR (x=A AND y>B) adds: x>=A +// ** +// ** The added conjunct can sometimes be helpful in query planning. +// ** +// ** CASE 3: +// ** +// ** If all subterms are indexable by a single table T, then set +// ** +// ** WhereTerm.eOperator = WO_OR +// ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T +// ** +// ** A subterm is "indexable" if it is of the form +// ** "T.C " where C is any column of table T and +// ** is one of "=", "<", "<=", ">", ">=", "IS NULL", or "IN". +// ** A subterm is also indexable if it is an AND of two or more +// ** subsubterms at least one of which is indexable. Indexable AND +// ** subterms have their eOperator set to WO_AND and they have +// ** u.pAndInfo set to a dynamically allocated WhereAndTerm object. +// ** +// ** From another point of view, "indexable" means that the subterm could +// ** potentially be used with an index if an appropriate index exists. +// ** This analysis does not consider whether or not the index exists; that +// ** is decided elsewhere. This analysis only looks at whether subterms +// ** appropriate for indexing exist. +// ** +// ** All examples A through E above satisfy case 3. But if a term +// ** also satisfies case 1 (such as B) we know that the optimizer will +// ** always prefer case 1, so in that case we pretend that case 3 is not +// ** satisfied. +// ** +// ** It might be the case that multiple tables are indexable. For example, +// ** (E) above is indexable on tables P, Q, and R. +// ** +// ** Terms that satisfy case 3 are candidates for lookup by using +// ** separate indices to find rowids for each subterm and composing +// ** the union of all rowids using a RowSet object. This is similar +// ** to "bitmap indices" in other database engines. +// ** +// ** OTHERWISE: +// ** +// ** If none of cases 1, 2, or 3 apply, then leave the eOperator set to +// ** zero. This term is not useful for search. +// */ +func _exprAnalyzeOrTerm(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { + var affLeft, affRight, i, iColumn, iCursor, iOne, iTwo, idxNew, j, j1, okToChngToIN, v7, v9 int32 + var b, b1, chngToIN, indexable TBitmask + var db, pAndInfo, pAndTerm, pAndWC, pDup, pExpr, pLeft, pLeft1, pList, pNew, pOne, pOrInfo, pOrTerm, pOrWc, pOther, pParse, pTerm, pTwo, pWInfo, v1, v2 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = affLeft, affRight, b, b1, chngToIN, db, i, iColumn, iCursor, iOne, iTwo, idxNew, indexable, j, j1, okToChngToIN, pAndInfo, pAndTerm, pAndWC, pDup, pExpr, pLeft, pLeft1, pList, pNew, pOne, pOrInfo, pOrTerm, pOrWc, pOther, pParse, pTerm, pTwo, pWInfo, v1, v2, v7, v9 + pWInfo = (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo /* WHERE clause processing context */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parser context */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 /* The term to be analyzed */ + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr /* Tables that are indexable, satisfying case 2 */ + /* + ** Break the OR clause into its separate subterms. The subterms are + ** stored in a WhereClause structure containing within the WhereOrInfo + ** object that is attached to the original OR clause term. + */ + v1 = _sqlite3DbMallocZero(tls, db, uint64(496)) + pOrInfo = v1 + *(*uintptr)(unsafe.Pointer(pTerm + 32)) = v1 + if pOrInfo == uintptr(0) { + return + } + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_ORINFO)) + pOrWc = pOrInfo + libc.X__builtin___memset_chk(tls, pOrWc+40, 0, uint64(448), ^t__predefined_size_t(0)) + _sqlite3WhereClauseInit(tls, pOrWc, pWInfo) + _sqlite3WhereSplit(tls, pOrWc, pExpr, uint8(TK_OR)) + _sqlite3WhereExprAnalyze(tls, pSrc, pOrWc) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + /* + ** Compute the set of tables that might satisfy cases 1 or 3. + */ + indexable = ^libc.Uint64FromInt32(0) + chngToIN = ^libc.Uint64FromInt32(0) + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + for { + if !(i >= 0 && indexable != 0) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_SINGLE) == 0 { + chngToIN = uint64(0) + pAndInfo = _sqlite3DbMallocRawNN(tls, db, uint64(488)) + if pAndInfo != 0 { + b = uint64(0) + *(*uintptr)(unsafe.Pointer(pOrTerm + 32)) = pAndInfo + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_ANDINFO)) + (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator = uint16(WO_AND) + (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor = -int32(1) + pAndWC = pAndInfo + libc.X__builtin___memset_chk(tls, pAndWC+40, 0, uint64(448), ^t__predefined_size_t(0)) + _sqlite3WhereClauseInit(tls, pAndWC, (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo) + _sqlite3WhereSplit(tls, pAndWC, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr, uint8(TK_AND)) + _sqlite3WhereExprAnalyze(tls, pSrc, pAndWC) + (*TWhereClause)(unsafe.Pointer(pAndWC)).FpOuter = pWC + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + j = 0 + pAndTerm = (*TWhereClause)(unsafe.Pointer(pAndWC)).Fa + for { + if !(j < (*TWhereClause)(unsafe.Pointer(pAndWC)).FnTerm) { + break + } + if _allowedOp(tls, libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAndTerm)).FpExpr)).Fop)) != 0 || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pAndTerm)).FeOperator) == int32(WO_AUX) { + b = b | _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pAndTerm)).FleftCursor) + } + goto _5 + _5: + ; + j = j + 1 + pAndTerm += 56 + } + } + indexable = indexable & b + } + } else { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_COPIED) != 0 { + /* Skip this term for now. We revisit it when we process the + ** corresponding TERM_VIRTUAL term */ + } else { + b1 = _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_VIRTUAL) != 0 { + pOther = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FiParent)*56 + b1 = b1 | _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOther)).FleftCursor) + } + indexable = indexable & b1 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_EQ) == 0 { + chngToIN = uint64(0) + } else { + chngToIN = chngToIN & b1 + } + } + } + goto _3 + _3: + ; + i = i - 1 + pOrTerm += 56 + } + /* + ** Record the set of tables that satisfy case 3. The set might be + ** empty. + */ + (*TWhereOrInfo)(unsafe.Pointer(pOrInfo)).Findexable = indexable + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(WO_OR) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = -int32(1) + if indexable != 0 { + (*TWhereClause)(unsafe.Pointer(pWC)).FhasOr = uint8(1) + } + /* For a two-way OR, attempt to implementation case 2. + */ + if indexable != 0 && (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm == int32(2) { + iOne = 0 + for { + v7 = iOne + iOne = iOne + 1 + v1 = _whereNthSubterm(tls, (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa, v7) + pOne = v1 + if !(v1 != uintptr(0)) { + break + } + iTwo = 0 + for { + v9 = iTwo + iTwo = iTwo + 1 + v2 = _whereNthSubterm(tls, (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa+1*56, v9) + pTwo = v2 + if !(v2 != uintptr(0)) { + break + } + _whereCombineDisjuncts(tls, pSrc, pWC, pOne, pTwo) + } + } + } + /* + ** chngToIN holds a set of tables that *might* satisfy case 1. But + ** we have to do some additional checking to see if case 1 really + ** is satisfied. + ** + ** chngToIN will hold either 0, 1, or 2 bits. The 0-bit case means + ** that there is no possibility of transforming the OR clause into an + ** IN operator because one or more terms in the OR clause contain + ** something other than == on a column in the single table. The 1-bit + ** case means that every term of the OR clause is of the form + ** "table.column=expr" for some single table. The one bit that is set + ** will correspond to the common table. We still need to check to make + ** sure the same column is used on all terms. The 2-bit case is when + ** the all terms are of the form "table1.column=table2.column". It + ** might be possible to form an IN operator with either table1.column + ** or table2.column as the LHS if either is common to every term of + ** the OR clause. + ** + ** Note that terms of the form "table.column1=table.column2" (the + ** same table on both sizes of the ==) cannot be optimized. + */ + if chngToIN != 0 { + okToChngToIN = 0 /* True if the conversion to IN is valid */ + iColumn = -int32(1) /* Column index on lhs of IN operator */ + iCursor = -int32(1) /* Table cursor common to all terms */ + j1 = 0 /* Loop counter */ + /* Search for a table and column that appears on one side or the + ** other of the == operator in every subterm. That table and column + ** will be recorded in iCursor and iColumn. There might not be any + ** such table and column. Set okToChngToIN if an appropriate table + ** and column is found but leave okToChngToIN false if not found. + */ + j1 = 0 + for { + if !(j1 < int32(2) && !(okToChngToIN != 0)) { + break + } + pLeft = uintptr(0) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + for { + if !(i >= 0) { + break + } + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(TERM_OK)) + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCursor { + /* This is the 2-bit case and we are on the second iteration and + ** current term is from the first iteration. So skip this term. */ + goto _11 + } + if chngToIN&_sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) == uint64(0) { + /* This term must be of the form t1.a==t2.b where t2 is in the + ** chngToIN set but t1 is not. This term will be either preceded + ** or followed by an inverted copy (t2.b==t1.a). Skip this term + ** and use its inversion. */ + goto _11 + } + iColumn = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pOrTerm + 32))).FleftColumn + iCursor = (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor + pLeft = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft + break + goto _11 + _11: + ; + i = i - 1 + pOrTerm += 56 + } + if i < 0 { + /* No candidate table+column was found. This can only occur + ** on the second iteration */ + break + } + /* We have found a candidate table and column. Check to see if that + ** table and column is common to every term in the OR clause */ + okToChngToIN = int32(1) + for { + if !(i >= 0 && okToChngToIN != 0) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor != iCursor { + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(TERM_OK)) + } else { + if (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pOrTerm + 32))).FleftColumn != iColumn || iColumn == -int32(2) && _sqlite3ExprCompare(tls, pParse, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft, pLeft, -int32(1)) != 0 { + okToChngToIN = 0 + } else { + /* If the right-hand side is also a column, then the affinities + ** of both right and left sides must be such that no type + ** conversions are required on the right. (Ticket #2249) + */ + affRight = int32(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpRight)) + affLeft = int32(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft)) + if affRight != 0 && affRight != affLeft { + okToChngToIN = 0 + } else { + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_OK)) + } + } + } + goto _13 + _13: + ; + i = i - 1 + pOrTerm += 56 + } + goto _10 + _10: + ; + j1 = j1 + 1 + } + /* At this point, okToChngToIN is true if original pTerm satisfies + ** case 1. In that case, construct a new virtual term that is + ** pTerm converted into an IN operator. + */ + if okToChngToIN != 0 { /* A transient duplicate expression */ + pList = uintptr(0) /* The RHS of the IN operator */ + pLeft1 = uintptr(0) /* The complete IN operator */ + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + for { + if !(i >= 0) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_OK) == 0 { + goto _16 + } + pDup = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpRight, 0) + pList = _sqlite3ExprListAppend(tls, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse, pList, pDup) + pLeft1 = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft + goto _16 + _16: + ; + i = i - 1 + pOrTerm += 56 + } + pDup = _sqlite3ExprDup(tls, db, pLeft1, 0) + pNew = _sqlite3PExpr(tls, pParse, int32(TK_IN), pDup, uintptr(0)) + if pNew != 0 { + _transferJoinMarkings(tls, pNew, pExpr) + *(*uintptr)(unsafe.Pointer(pNew + 32)) = pList + idxNew = _whereClauseInsert(tls, pWC, pNew, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + _exprAnalyze(tls, pSrc, pWC, idxNew) + /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where reused */ + _markTermAsChild(tls, pWC, idxNew, idxTerm) + } else { + _sqlite3ExprListDelete(tls, db, pList) + } + } + } +} + +// C documentation +// +// /* +// ** Generate code for a BETWEEN operator. +// ** +// ** x BETWEEN y AND z +// ** +// ** The above is equivalent to +// ** +// ** x>=y AND x<=z +// ** +// ** Code it as such, taking care to do the common subexpression +// ** elimination of x. +// ** +// ** The xJumpIf parameter determines details: +// ** +// ** NULL: Store the boolean result in reg[dest] +// ** sqlite3ExprIfTrue: Jump to dest if true +// ** sqlite3ExprIfFalse: Jump to dest if false +// ** +// ** The jumpIfNull parameter is ignored if xJumpIf is NULL. +// */ +func _exprCodeBetween(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, __ccgo_fp_xJump uintptr, jumpIfNull int32) { + bp := tls.Alloc(224) + defer tls.Free(224) + var db, pDel uintptr + var _ /* compLeft at bp+72 */ TExpr + var _ /* compRight at bp+144 */ TExpr + var _ /* exprAnd at bp+0 */ TExpr + var _ /* regFree1 at bp+216 */ int32 + _, _ = db, pDel /* The x<=z term */ + **(**int32)(__ccgo_up(bp + 216)) = 0 /* Temporary use register */ + pDel = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + libc.X__builtin___memset_chk(tls, bp+72, 0, uint64(72), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+144, 0, uint64(72), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + pDel = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, 0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_AND) + (**(**TExpr)(__ccgo_up(bp))).FpLeft = bp + 72 + (**(**TExpr)(__ccgo_up(bp))).FpRight = bp + 144 + (**(**TExpr)(__ccgo_up(bp + 72))).Fop = uint8(TK_GE) + (**(**TExpr)(__ccgo_up(bp + 72))).FpLeft = pDel + (**(**TExpr)(__ccgo_up(bp + 72))).FpRight = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr + (**(**TExpr)(__ccgo_up(bp + 144))).Fop = uint8(TK_LE) + (**(**TExpr)(__ccgo_up(bp + 144))).FpLeft = pDel + (**(**TExpr)(__ccgo_up(bp + 144))).FpRight = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr + _sqlite3ExprToRegister(tls, pDel, _exprCodeVector(tls, pParse, pDel, bp+216)) + if __ccgo_fp_xJump != 0 { + (*(*func(*libc.TLS, uintptr, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xJump})))(tls, pParse, bp, dest, jumpIfNull) + } else { + /* Mark the expression is being from the ON or USING clause of a join + ** so that the sqlite3ExprCodeTarget() routine will not attempt to move + ** it into the Parse.pConstExpr list. We should use a new bit for this, + ** for clarity, but we are out of bits in the Expr.flags field so we + ** have to reuse the EP_OuterON bit. Bummer. */ + **(**Tu32)(__ccgo_up(pDel + 4)) |= uint32(EP_OuterON) + _sqlite3ExprCodeTarget(tls, pParse, bp, dest) + } + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp + 216))) + } + _sqlite3ExprDelete(tls, db, pDel) + /* Ensure adequate test coverage */ +} + +// C documentation +// +// /* +// ** Generate code to implement special SQL functions that are implemented +// ** in-line rather than by using the usual callbacks. +// */ +func _exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncId int32, target int32) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var aff int8 + var azAff [6]uintptr + var endCoalesce, i, nFarg int32 + var pA1, pArg, v, v2 uintptr + var _ /* caseExpr at bp+0 */ TExpr + _, _, _, _, _, _, _, _, _ = aff, azAff, endCoalesce, i, nFarg, pA1, pArg, v, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + nFarg = (*TExprList)(unsafe.Pointer(pFarg)).FnExpr + /* All in-line functions have at least one argument */ + switch iFuncId { + case INLINEFUNC_coalesce: + /* Attempt a direct implementation of the built-in COALESCE() and + ** IFNULL() functions. This avoids unnecessary evaluation of + ** arguments past the first non-NULL argument. + */ + endCoalesce = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, target) + i = int32(1) + for { + if !(i < nFarg) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), target, endCoalesce) + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + uintptr(i)*32))).FpExpr, target) + goto _1 + _1: + ; + i = i + 1 + } + _setDoNotMergeFlagOnCopy(tls, v) + _sqlite3VdbeResolveLabel(tls, v, endCoalesce) + case int32(INLINEFUNC_iif): + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_CASE) + *(*uintptr)(unsafe.Pointer(bp + 32)) = pFarg + return _sqlite3ExprCodeTarget(tls, pParse, bp, target) + case int32(INLINEFUNC_sqlite_offset): + pArg = (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pArg)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pArg)).FiTable >= 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Offset), (*TExpr)(unsafe.Pointer(pArg)).FiTable, int32((*TExpr)(unsafe.Pointer(pArg)).FiColumn), target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + default: + /* The UNLIKELY() function is a no-op. The result is the value + ** of the first argument. + */ + target = _sqlite3ExprCodeTarget(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, target) + break + /*********************************************************************** + ** Test-only SQL functions that are only usable if enabled + ** via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS + */ + fallthrough + case int32(INLINEFUNC_expr_compare): + /* Compare two expressions using sqlite3ExprCompare() */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr, -int32(1)), target) + case int32(INLINEFUNC_expr_implies_expr): + /* Compare two expressions using sqlite3ExprImpliesExpr() */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprImpliesExpr(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr, -int32(1)), target) + case int32(INLINEFUNC_implies_nonnull_row): + pA1 = (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA1)).Fop) == int32(TK_COLUMN) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprImpliesNonNullRow(tls, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*TExpr)(unsafe.Pointer(pA1)).FiTable, int32(1)), target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + case int32(INLINEFUNC_affinity): + /* The AFFINITY() function evaluates to a string that describes + ** the type affinity of the argument. This is used for testing of + ** the SQLite type logic. + */ + azAff = [6]uintptr{ + 0: __ccgo_ts + 8826, + 1: __ccgo_ts + 8831, + 2: __ccgo_ts + 8836, + 3: __ccgo_ts + 6836, + 4: __ccgo_ts + 6831, + 5: __ccgo_ts + 8844, + } + aff = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr) + if int32(aff) <= int32(SQLITE_AFF_NONE) { + v2 = __ccgo_ts + 8852 + } else { + v2 = azAff[int32(aff)-int32(SQLITE_AFF_BLOB)] + } + _sqlite3VdbeLoadString(tls, v, target, v2) + break + } + return target +} + +// C documentation +// +// /* +// ** This function is similar to sqlite3ExprDup(), except that if pEdupBuf +// ** is not NULL then it points to memory that can be used to store a copy +// ** of the input Expr p together with its p->u.zToken (if any). pEdupBuf +// ** is updated with the new buffer tail prior to returning. +// */ +func _exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pEdupBuf uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nAlloc, nNewSize, nToken, v2 int32 + var nSize, staticFlag Tu32 + var nStructSize uint32 + var pNew, zToken, v1 uintptr + var _ /* sEdupBuf at bp+0 */ TEdupBuf + _, _, _, _, _, _, _, _, _, _ = nAlloc, nNewSize, nSize, nStructSize, nToken, pNew, staticFlag, zToken, v1, v2 /* EP_Static if space not obtained from malloc */ + nToken = -int32(1) /* Space needed for p->u.zToken. -1 means unknown */ + /* Figure out where to write the new Expr structure. */ + if pEdupBuf != 0 { + (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc = (*TEdupBuf)(unsafe.Pointer(pEdupBuf)).FzAlloc + staticFlag = uint32(EP_Static) + } else { + if dupFlags != 0 { + nAlloc = _dupedExprSize(tls, p) + } else { + if !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)) && *(*uintptr)(unsafe.Pointer(p + 8)) != 0 { + nToken = libc.Int32FromUint64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(p + 8)))&uint64(0x3fffffff) + uint64(1)) + nAlloc = libc.Int32FromUint64((libc.Uint64FromInt64(72) + libc.Uint64FromInt32(nToken) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + } else { + nToken = 0 + nAlloc = libc.Int32FromUint64((libc.Uint64FromInt64(72) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + } + } + (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(nAlloc)) + staticFlag = uint32(0) + } + pNew = (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc + if pNew != 0 { + /* Set nNewSize to the size allocated for the structure pointed to + ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or + ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed + ** by the copy of the p->u.zToken string (if any). + */ + nStructSize = libc.Uint32FromInt32(_dupedExprStructSize(tls, p, dupFlags)) + nNewSize = libc.Int32FromUint32(nStructSize & uint32(0xfff)) + if nToken < 0 { + if !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)) && *(*uintptr)(unsafe.Pointer(p + 8)) != 0 { + nToken = _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8))) + int32(1) + } else { + nToken = 0 + } + } + if dupFlags != 0 { + libc.X__builtin___memcpy_chk(tls, (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc, p, libc.Uint64FromInt32(nNewSize), ^t__predefined_size_t(0)) + } else { + nSize = libc.Uint32FromInt32(_exprStructSize(tls, p)) + libc.X__builtin___memcpy_chk(tls, (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc, p, uint64(nSize), ^t__predefined_size_t(0)) + if uint64(nSize) < uint64(72) { + libc.X__builtin___memset_chk(tls, (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc+uintptr(nSize), 0, uint64(72)-uint64(nSize), ^t__predefined_size_t(0)) + } + nNewSize = int32(72) + } + /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ + **(**Tu32)(__ccgo_up(pNew + 4)) &= libc.Uint32FromInt32(^(libc.Int32FromInt32(EP_Reduced) | libc.Int32FromInt32(EP_TokenOnly) | libc.Int32FromInt32(EP_Static))) + **(**Tu32)(__ccgo_up(pNew + 4)) |= nStructSize & libc.Uint32FromInt32(libc.Int32FromInt32(EP_Reduced)|libc.Int32FromInt32(EP_TokenOnly)) + **(**Tu32)(__ccgo_up(pNew + 4)) |= staticFlag + if dupFlags != 0 { + } + /* Copy the p->u.zToken string, if any. */ + if nToken > 0 { + v1 = (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc + uintptr(nNewSize) + *(*uintptr)(unsafe.Pointer(pNew + 8)) = v1 + zToken = v1 + libc.X__builtin___memcpy_chk(tls, zToken, *(*uintptr)(unsafe.Pointer(p + 8)), libc.Uint64FromInt32(nToken), ^t__predefined_size_t(0)) + nNewSize = nNewSize + nToken + } + (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc += uintptr((nNewSize + libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)) + if ((*TExpr)(unsafe.Pointer(p)).Fflags|(*TExpr)(unsafe.Pointer(pNew)).Fflags)&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) == uint32(0) { + /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + *(*uintptr)(unsafe.Pointer(pNew + 32)) = _sqlite3SelectDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 32)), dupFlags) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) != int32(TK_ORDER) { + v2 = dupFlags + } else { + v2 = 0 + } + *(*uintptr)(unsafe.Pointer(pNew + 32)) = _sqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 32)), v2) + } + if (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + *(*uintptr)(unsafe.Pointer(pNew + 64)) = _sqlite3WindowDup(tls, db, pNew, *(*uintptr)(unsafe.Pointer(p + 64))) + } + /* Fill in pNew->pLeft and pNew->pRight. */ + if dupFlags != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_SELECT_COLUMN) { + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = (*TExpr)(unsafe.Pointer(p)).FpLeft + } else { + if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 { + v1 = _exprDup(tls, db, (*TExpr)(unsafe.Pointer(p)).FpLeft, int32(EXPRDUP_REDUCE), bp) + } else { + v1 = uintptr(0) + } + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = v1 + } + if (*TExpr)(unsafe.Pointer(p)).FpRight != 0 { + v1 = _exprDup(tls, db, (*TExpr)(unsafe.Pointer(p)).FpRight, int32(EXPRDUP_REDUCE), bp) + } else { + v1 = uintptr(0) + } + (*TExpr)(unsafe.Pointer(pNew)).FpRight = v1 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_SELECT_COLUMN) { + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = (*TExpr)(unsafe.Pointer(p)).FpLeft + } else { + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(p)).FpLeft, 0) + } + (*TExpr)(unsafe.Pointer(pNew)).FpRight = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(p)).FpRight, 0) + } + } + } + if pEdupBuf != 0 { + libc.X__builtin___memcpy_chk(tls, pEdupBuf, bp, uint64(8), ^t__predefined_size_t(0)) + } + return pNew +} + +// C documentation +// +// /* +// ** Return true if the expression contains no non-deterministic SQL +// ** functions. Do not consider non-deterministic SQL functions that are +// ** part of sub-select statements. +// */ +func _exprIsDeterministic(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(1) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprNodeIsDeterministic) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkFail) + _sqlite3WalkExpr(tls, bp, p) + return libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) +} + +// C documentation +// +// /* +// ** This function is called to handle the SQLITE_FCNTL_SIZE_HINT +// ** file-control operation. Enlarge the database to nBytes in size +// ** (rounded up to the next chunk-size). If the database is already +// ** nBytes or larger, this routine is a no-op. +// */ +func _fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte Ti64) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var iWrite, nSize Ti64 + var nBlk, nWrite, rc int32 + var _ /* buf at bp+0 */ Tstat + _, _, _, _, _ = iWrite, nBlk, nSize, nWrite, rc + if (*TunixFile)(unsafe.Pointer(pFile)).FszChunk > 0 { /* Used to hold return values of fstat() */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, bp) != 0 { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)< (**(**Tstat)(__ccgo_up(bp))).Fst_size { + /* If the OS does not have posix_fallocate(), fake it. Write a + ** single byte to the last byte in each block that falls entirely + ** within the extended region. Then, if required, a single byte + ** at offset (nSize-1), to set the size of the file correctly. + ** This is a similar technique to that used by glibc on systems + ** that do not have a real fallocate() call. + */ + nBlk = (**(**Tstat)(__ccgo_up(bp))).Fst_blksize /* File-system block size */ + nWrite = 0 /* Next offset to write to */ + iWrite = (**(**Tstat)(__ccgo_up(bp))).Fst_size/int64(nBlk)*int64(nBlk) + int64(nBlk) - int64(1) + for { + if !(iWrite < nSize+int64(nBlk)-int64(1)) { + break + } + if iWrite >= nSize { + iWrite = nSize - int64(1) + } + nWrite = _seekAndWrite(tls, pFile, iWrite, __ccgo_ts+1702, int32(1)) + if nWrite != int32(1) { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(3)< 0 && nByte > (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize { + if (*TunixFile)(unsafe.Pointer(pFile)).FszChunk <= 0 { + if _robust_ftruncate(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, nByte) != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__error(tls)))) + return _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(6)<aData +// ** area. pCell might point to some temporary storage. The cell will +// ** be constructed in this temporary area then copied into pPage->aData +// ** later. +// */ +func _fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType Tu8 + var mn, n, nHeader, nPayload, nSrc, spaceLeft, v1 int32 + var pBt, pPayload, pPrior, pSrc, pToRelease uintptr + var pgnoPtrmap TPgno + var _ /* pOvfl at bp+8 */ uintptr + var _ /* pgnoOvfl at bp+4 */ TPgno + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = eType, mn, n, nHeader, nPayload, nSrc, pBt, pPayload, pPrior, pSrc, pToRelease, pgnoPtrmap, spaceLeft, v1 + /* pPage is not necessarily writeable since pCell might be auxiliary + ** buffer space that is separate from the pPage buffer area */ + /* Fill in the header. */ + nHeader = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + if (*TMemPage)(unsafe.Pointer(pPage)).FintKey != 0 { + nPayload = (*TBtreePayload)(unsafe.Pointer(pX)).FnData + (*TBtreePayload)(unsafe.Pointer(pX)).FnZero + pSrc = (*TBtreePayload)(unsafe.Pointer(pX)).FpData + nSrc = (*TBtreePayload)(unsafe.Pointer(pX)).FnData + /* fillInCell() only called for leaves */ + if libc.Uint32FromInt32(nPayload) < libc.Uint32FromInt32(0x80) { + **(**uint8)(__ccgo_up(pCell + uintptr(nHeader))) = libc.Uint8FromInt32(nPayload) + v1 = libc.Int32FromInt32(1) + } else { + v1 = _sqlite3PutVarint(tls, pCell+uintptr(nHeader), libc.Uint64FromInt32(nPayload)) + } + nHeader = nHeader + libc.Int32FromUint8(libc.Uint8FromInt32(v1)) + nHeader = nHeader + _sqlite3PutVarint(tls, pCell+uintptr(nHeader), **(**Tu64)(__ccgo_up(pX + 8))) + } else { + v1 = int32((*TBtreePayload)(unsafe.Pointer(pX)).FnKey) + nPayload = v1 + nSrc = v1 + pSrc = (*TBtreePayload)(unsafe.Pointer(pX)).FpKey + if libc.Uint32FromInt32(nPayload) < libc.Uint32FromInt32(0x80) { + **(**uint8)(__ccgo_up(pCell + uintptr(nHeader))) = libc.Uint8FromInt32(nPayload) + v1 = libc.Int32FromInt32(1) + } else { + v1 = _sqlite3PutVarint(tls, pCell+uintptr(nHeader), libc.Uint64FromInt32(nPayload)) + } + nHeader = nHeader + libc.Int32FromUint8(libc.Uint8FromInt32(v1)) + } + /* Fill in the payload */ + pPayload = pCell + uintptr(nHeader) + if nPayload <= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + /* This is the common case where everything fits on the btree page + ** and no overflow pages are required. */ + n = nHeader + nPayload + if n < int32(4) { + n = int32(4) + **(**uint8)(__ccgo_up(pPayload + uintptr(nPayload))) = uint8(0) + } + **(**int32)(__ccgo_up(pnSize)) = n + libc.X__builtin___memcpy_chk(tls, pPayload, pSrc, libc.Uint64FromInt32(nSrc), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, pPayload+uintptr(nSrc), 0, libc.Uint64FromInt32(nPayload-nSrc), ^t__predefined_size_t(0)) + return SQLITE_OK + } + /* If we reach this point, it means that some of the content will need + ** to spill onto overflow pages. + */ + mn = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FminLocal) + n = libc.Int32FromUint32(libc.Uint32FromInt32(mn) + libc.Uint32FromInt32(nPayload-mn)%((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-uint32(4))) + if n > libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + n = mn + } + spaceLeft = n + **(**int32)(__ccgo_up(pnSize)) = n + nHeader + int32(4) + pPrior = pCell + uintptr(nHeader+n) + pToRelease = uintptr(0) + **(**TPgno)(__ccgo_up(bp + 4)) = uint32(0) + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt + /* At this point variables should be set as follows: + ** + ** nPayload Total payload size in bytes + ** pPayload Begin writing payload here + ** spaceLeft Space available at pPayload. If nPayload>spaceLeft, + ** that means content must spill into overflow pages. + ** *pnSize Size of the local cell (not counting overflow pages) + ** pPrior Where to write the pgno of the first overflow page + ** + ** Use a call to btreeParseCellPtr() to verify that the values above + ** were computed correctly. + */ + /* Write the payload into the local Cell and any extra into overflow pages */ + for int32(1) != 0 { + n = nPayload + if n > spaceLeft { + n = spaceLeft + } + /* If pToRelease is not zero than pPayload points into the data area + ** of pToRelease. Make sure pToRelease is still writeable. */ + /* If pPayload is part of the data area of pPage, then make sure pPage + ** is still writeable */ + if nSrc >= n { + libc.X__builtin___memcpy_chk(tls, pPayload, pSrc, libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + } else { + if nSrc > 0 { + n = nSrc + libc.X__builtin___memcpy_chk(tls, pPayload, pSrc, libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + } else { + libc.X__builtin___memset_chk(tls, pPayload, 0, libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + } + } + nPayload = nPayload - n + if nPayload <= 0 { + break + } + pPayload = pPayload + uintptr(n) + pSrc = pSrc + uintptr(n) + nSrc = nSrc - n + spaceLeft = spaceLeft - n + if spaceLeft == 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pgnoPtrmap = **(**TPgno)(__ccgo_up(bp + 4)) /* Overflow page pointer-map entry page */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + for cond := true; cond; cond = _ptrmapPageno(tls, pBt, **(**TPgno)(__ccgo_up(bp + 4))) == **(**TPgno)(__ccgo_up(bp + 4)) || **(**TPgno)(__ccgo_up(bp + 4)) == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + **(**TPgno)(__ccgo_up(bp + 4)) = **(**TPgno)(__ccgo_up(bp + 4)) + 1 + } + } + **(**int32)(__ccgo_up(bp)) = _allocateBtreePage(tls, pBt, bp+8, bp+4, **(**TPgno)(__ccgo_up(bp + 4)), uint8(0)) + /* If the database supports auto-vacuum, and the second or subsequent + ** overflow page is being allocated, add an entry to the pointer-map + ** for that page now. + ** + ** If this is the first overflow page, then write a partial entry + ** to the pointer-map. If we write nothing to this pointer-map slot, + ** then the optimistic overflow chain processing in clearCell() + ** may misinterpret the uninitialized values and delete the + ** wrong pages from the database. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if pgnoPtrmap != 0 { + v1 = int32(PTRMAP_OVERFLOW2) + } else { + v1 = int32(PTRMAP_OVERFLOW1) + } + eType = libc.Uint8FromInt32(v1) + _ptrmapPut(tls, pBt, **(**TPgno)(__ccgo_up(bp + 4)), eType, pgnoPtrmap, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + } + if **(**int32)(__ccgo_up(bp)) != 0 { + _releasePage(tls, pToRelease) + return **(**int32)(__ccgo_up(bp)) + } + /* If pToRelease is not zero than pPrior points into the data area + ** of pToRelease. Make sure pToRelease is still writeable. */ + /* If pPrior is part of the data area of pPage, then make sure pPage + ** is still writeable */ + _sqlite3Put4byte(tls, pPrior, **(**TPgno)(__ccgo_up(bp + 4))) + _releasePage(tls, pToRelease) + pToRelease = **(**uintptr)(__ccgo_up(bp + 8)) + pPrior = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData + _sqlite3Put4byte(tls, pPrior, uint32(0)) + pPayload = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData + 4 + spaceLeft = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32(4)) + } + } + _releasePage(tls, pToRelease) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Initialize the contents of the unixFile structure pointed to by pId. +// */ +func _fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename uintptr, ctrlFlags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nFilename, rc int32 + var pCtx, pLockingStyle, pNew, zLockFile, v1, v2 uintptr + _, _, _, _, _, _, _, _ = nFilename, pCtx, pLockingStyle, pNew, rc, zLockFile, v1, v2 + pNew = pId + rc = SQLITE_OK + /* No locking occurs in temporary files */ + (*TunixFile)(unsafe.Pointer(pNew)).Fh = h + (*TunixFile)(unsafe.Pointer(pNew)).FpVfs = pVfs + (*TunixFile)(unsafe.Pointer(pNew)).FzPath = zFilename + (*TunixFile)(unsafe.Pointer(pNew)).FctrlFlags = uint16(libc.Uint8FromInt32(ctrlFlags)) + (*TunixFile)(unsafe.Pointer(pNew)).FmmapSizeMax = _sqlite3Config.FszMmap + if ctrlFlags&int32(UNIXFILE_URI) != 0 { + v1 = zFilename + } else { + v1 = uintptr(0) + } + if Xsqlite3_uri_boolean(tls, v1, __ccgo_ts+4009, int32(SQLITE_POWERSAFE_OVERWRITE)) != 0 { + v2 = pNew + 30 + *(*uint16)(unsafe.Pointer(v2)) = uint16(int32(*(*uint16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(UNIXFILE_PSOW)) + } + if libc.Xstrcmp(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, __ccgo_ts+4014) == 0 { + v1 = pNew + 30 + *(*uint16)(unsafe.Pointer(v1)) = uint16(int32(*(*uint16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(UNIXFILE_EXCL)) + } + if ctrlFlags&int32(UNIXFILE_NOLOCK) != 0 { + pLockingStyle = uintptr(unsafe.Pointer(&_nolockIoMethods)) + } else { + pLockingStyle = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData))})))(tls, zFilename, pNew) + /* Cache zFilename in the locking context (AFP and dotlock override) for + ** proxyLock activation is possible (remote proxy is based on db name) + ** zFilename remains valid until file is closed, to support */ + (*TunixFile)(unsafe.Pointer(pNew)).FlockingContext = zFilename + } + if pLockingStyle == uintptr(unsafe.Pointer(&_posixIoMethods)) || pLockingStyle == uintptr(unsafe.Pointer(&_nfsIoMethods)) { + _unixEnterMutex(tls) + rc = _findInodeInfo(tls, pNew, pNew+16) + if rc != SQLITE_OK { + /* If an error occurred in findInodeInfo(), close the file descriptor + ** immediately, before releasing the mutex. findInodeInfo() may fail + ** in two scenarios: + ** + ** (a) A call to fstat() failed. + ** (b) A malloc failed. + ** + ** Scenario (b) may only occur if the process is holding no other + ** file descriptors open on the same file. If there were other file + ** descriptors on this file, then no malloc would be required by + ** findInodeInfo(). If this is the case, it is quite safe to close + ** handle h - as it is guaranteed that no posix locks will be released + ** by doing so. + ** + ** If scenario (a) caused the error then things are not so safe. The + ** implicit assumption here is that if fstat() fails, things are in + ** such bad shape that dropping a lock or two doesn't matter much. + */ + _robust_close(tls, pNew, h, int32(46345)) + h = -int32(1) + } + _unixLeaveMutex(tls) + } else { + if pLockingStyle == uintptr(unsafe.Pointer(&_afpIoMethods)) { + v1 = Xsqlite3_malloc64(tls, uint64(16)) + pCtx = v1 + (*TunixFile)(unsafe.Pointer(pNew)).FlockingContext = v1 + if pCtx == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + /* NB: zFilename exists and remains valid until the file is closed + ** according to requirement F11141. So we do not need to make a + ** copy of the filename. */ + (*TafpLockingContext)(unsafe.Pointer(pCtx)).FdbPath = zFilename + (*TafpLockingContext)(unsafe.Pointer(pCtx)).Freserved = 0 + libc.Xsrandomdev(tls) + _unixEnterMutex(tls) + rc = _findInodeInfo(tls, pNew, pNew+16) + if rc != SQLITE_OK { + Xsqlite3_free(tls, (*TunixFile)(unsafe.Pointer(pNew)).FlockingContext) + _robust_close(tls, pNew, h, int32(46371)) + h = -int32(1) + } + _unixLeaveMutex(tls) + } + } else { + if pLockingStyle == uintptr(unsafe.Pointer(&_dotlockIoMethods)) { + nFilename = libc.Int32FromUint64(libc.Xstrlen(tls, zFilename)) + int32(6) + zLockFile = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nFilename)) + if zLockFile == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + Xsqlite3_snprintf(tls, nFilename, zLockFile, __ccgo_ts+4024, libc.VaList(bp+8, zFilename)) + } + (*TunixFile)(unsafe.Pointer(pNew)).FlockingContext = zLockFile + } + } + } + _storeLastErrno(tls, pNew, 0) + if rc != SQLITE_OK { + if h >= 0 { + _robust_close(tls, pNew, h, int32(46437)) + } + } else { + (*Tsqlite3_file)(unsafe.Pointer(pId)).FpMethods = pLockingStyle + _verifyDbFile(tls, pNew) + } + return rc +} + +// C documentation +// +// /* +// ** Return a pointer corresponding to database zDb (i.e. "main", "temp") +// ** in connection handle pDb. If such a database cannot be found, return +// ** a NULL pointer and write an error message to pErrorDb. +// ** +// ** If the "temp" database is requested, it may need to be opened by this +// ** function. If an error occurs while doing so, return 0 and write an +// ** error message to pErrorDb. +// */ +func _findBtree(tls *libc.TLS, pErrorDb uintptr, pDb uintptr, zDb uintptr) (r uintptr) { + bp := tls.Alloc(432) + defer tls.Free(432) + var i, rc int32 + var _ /* sParse at bp+0 */ TParse + _, _ = i, rc + i = _sqlite3FindDbName(tls, pDb, zDb) + if i == int32(1) { + rc = 0 + _sqlite3ParseObjectInit(tls, bp, pDb) + if _sqlite3OpenTempDatabase(tls, bp) != 0 { + _sqlite3ErrorWithMsg(tls, pErrorDb, (**(**TParse)(__ccgo_up(bp))).Frc, __ccgo_ts+3944, libc.VaList(bp+424, (**(**TParse)(__ccgo_up(bp))).FzErrMsg)) + rc = int32(SQLITE_ERROR) + } + _sqlite3DbFree(tls, pErrorDb, (**(**TParse)(__ccgo_up(bp))).FzErrMsg) + _sqlite3ParseObjectReset(tls, bp) + if rc != 0 { + return uintptr(0) + } + } + if i < 0 { + _sqlite3ErrorWithMsg(tls, pErrorDb, int32(SQLITE_ERROR), __ccgo_ts+5469, libc.VaList(bp+424, zDb)) + return uintptr(0) + } + return (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(pDb)).FaDb + uintptr(i)*32))).FpBt +} + +// C documentation +// +// /* +// ** Locate and return an entry from the db.aCollSeq hash table. If the entry +// ** specified by zName and nName is not found and parameter 'create' is +// ** true, then create a new entry. Otherwise return NULL. +// ** +// ** Each pointer stored in the sqlite3.aCollSeq hash table contains an +// ** array of three CollSeq structures. The first is the collation sequence +// ** preferred for UTF-8, the second UTF-16le, and the third UTF-16be. +// ** +// ** Stored immediately after the three collation sequences is a copy of +// ** the collation sequence name. A pointer to this string is stored in +// ** each collation sequence structure. +// */ +func _findCollSeqEntry(tls *libc.TLS, db uintptr, zName uintptr, create int32) (r uintptr) { + var nName int32 + var pColl, pDel uintptr + _, _, _ = nName, pColl, pDel + pColl = _sqlite3HashFind(tls, db+648, zName) + if uintptr(0) == pColl && create != 0 { + nName = _sqlite3Strlen30(tls, zName) + int32(1) + pColl = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt32(3)*libc.Uint64FromInt64(40)+libc.Uint64FromInt32(nName))) + if pColl != 0 { + pDel = uintptr(0) + (**(**TCollSeq)(__ccgo_up(pColl))).FzName = pColl + 3*40 + (**(**TCollSeq)(__ccgo_up(pColl))).Fenc = uint8(SQLITE_UTF8) + (**(**TCollSeq)(__ccgo_up(pColl + 1*40))).FzName = pColl + 3*40 + (**(**TCollSeq)(__ccgo_up(pColl + 1*40))).Fenc = uint8(SQLITE_UTF16LE) + (**(**TCollSeq)(__ccgo_up(pColl + 2*40))).FzName = pColl + 3*40 + (**(**TCollSeq)(__ccgo_up(pColl + 2*40))).Fenc = uint8(SQLITE_UTF16BE) + libc.X__builtin___memcpy_chk(tls, (**(**TCollSeq)(__ccgo_up(pColl))).FzName, zName, libc.Uint64FromInt32(nName), ^t__predefined_size_t(0)) + pDel = _sqlite3HashInsert(tls, db+648, (**(**TCollSeq)(__ccgo_up(pColl))).FzName, pColl) + /* If a malloc() failure occurred in sqlite3HashInsert(), it will + ** return the pColl pointer to be deleted (because it wasn't added + ** to the hash table). + */ + if pDel != uintptr(0) { + _sqlite3OomFault(tls, db) + _sqlite3DbFree(tls, db, pDel) + pColl = uintptr(0) + } + } + } + return pColl +} + +// C documentation +// +// /* +// ** This function is called by unixOpen() to determine the unix permissions +// ** to create new files with. If no error occurs, then SQLITE_OK is returned +// ** and a value suitable for passing as the third argument to open(2) is +// ** written to *pMode. If an IO error occurs, an SQLite error code is +// ** returned and the value of *pMode is not modified. +// ** +// ** In most cases, this routine sets *pMode to 0, which will become +// ** an indication to robust_open() to create the file using +// ** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask. +// ** But if the file being opened is a WAL or regular journal file, then +// ** this function queries the file-system for the permissions on the +// ** corresponding database file and sets *pMode to this value. Whenever +// ** possible, WAL and journal files are created using the same permissions +// ** as the associated database file. +// ** +// ** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the +// ** original filename is unavailable. But 8_3_NAMES is only used for +// ** FAT filesystems and permissions do not matter there, so just use +// ** the default permissions. In 8_3_NAMES mode, leave *pMode set to zero. +// */ +func _findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr, pUid uintptr, pGid uintptr) (r int32) { + bp := tls.Alloc(528) + defer tls.Free(528) + var nDb, rc int32 + var z uintptr + var _ /* zDb at bp+0 */ [513]int8 + _, _, _ = nDb, rc, z + rc = SQLITE_OK /* Return Code */ + **(**Tmode_t)(__ccgo_up(pMode)) = uint16(0) + **(**Tuid_t)(__ccgo_up(pUid)) = uint32(0) + **(**Tgid_t)(__ccgo_up(pGid)) = uint32(0) + if flags&(libc.Int32FromInt32(SQLITE_OPEN_WAL)|libc.Int32FromInt32(SQLITE_OPEN_MAIN_JOURNAL)) != 0 { /* Number of valid bytes in zDb */ + /* zPath is a path to a WAL or journal file. The following block derives + ** the path to the associated database file from zPath. This block handles + ** the following naming conventions: + ** + ** "-journal" + ** "-wal" + ** "-journalNN" + ** "-walNN" + ** + ** where NN is a decimal number. The NN naming schemes are + ** used by the test_multiplex.c module. + ** + ** In normal operation, the journal file name will always contain + ** a '-' character. However in 8+3 filename mode, or if a corrupt + ** rollback journal specifies a super-journal with a goofy name, then + ** the '-' might be missing or the '-' might be the first character in + ** the filename. In that case, just return SQLITE_OK with *pMode==0. + */ + nDb = _sqlite3Strlen30(tls, zPath) - int32(1) + for nDb > 0 && int32(**(**int8)(__ccgo_up(zPath + uintptr(nDb)))) != int32('.') { + if int32(**(**int8)(__ccgo_up(zPath + uintptr(nDb)))) == int32('-') { + libc.X__builtin___memcpy_chk(tls, bp, zPath, libc.Uint64FromInt32(nDb), ^t__predefined_size_t(0)) + (**(**[513]int8)(__ccgo_up(bp)))[nDb] = int8('\000') + rc = _getFileMode(tls, bp, pMode, pUid, pGid) + break + } + nDb = nDb - 1 + } + } else { + if flags&int32(SQLITE_OPEN_DELETEONCLOSE) != 0 { + **(**Tmode_t)(__ccgo_up(pMode)) = uint16(0600) + } else { + if flags&int32(SQLITE_OPEN_URI) != 0 { + /* If this is a main database file and the file was opened using a URI + ** filename, check for the "modeof" parameter. If present, interpret + ** its value as a filename and try to copy the mode, uid and gid from + ** that file. */ + z = Xsqlite3_uri_parameter(tls, zPath, __ccgo_ts+4093) + if z != 0 { + rc = _getFileMode(tls, z, pMode, pUid, pGid) + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Given a file descriptor, locate the unixInodeInfo object that +// ** describes that file descriptor. Create a new one if necessary. The +// ** return value might be uninitialized if an error occurs. +// ** +// ** The global mutex must held when calling this routine. +// ** +// ** Return an appropriate error code. +// */ +func _findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var fd, rc int32 + var pInode uintptr + var _ /* fileId at bp+0 */ TunixFileId + var _ /* statbuf at bp+16 */ Tstat + _, _, _ = fd, pInode, rc /* Low-level file information */ + pInode = uintptr(0) /* Candidate unixInodeInfo object */ + /* Get low-level information about the file that we can used to + ** create a unique name for the file. + */ + fd = (*TunixFile)(unsafe.Pointer(pFile)).Fh + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, fd, bp+16) + if rc != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__error(tls)))) + return int32(SQLITE_IOERR) + } + /* On OS X on an msdos filesystem, the inode number is reported + ** incorrectly for zero-size files. See ticket #3260. To work + ** around this problem (we consider it a bug in OS X, not SQLite) + ** we always increase the file size to 1 by writing a single byte + ** prior to accessing the inode number. The one byte written is + ** an ASCII 'S' character which also happens to be the first byte + ** in the header of every SQLite database. In this way, if there + ** is a race condition such that another thread has already populated + ** the first page of the database, no damage is done. + */ + if (**(**Tstat)(__ccgo_up(bp + 16))).Fst_size == 0 && (*TunixFile)(unsafe.Pointer(pFile)).FfsFlags&uint32(SQLITE_FSFLAGS_IS_MSDOS) != uint32(0) { + for cond := true; cond; cond = rc < 0 && **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(EINTR) { + rc = int32((*(*func(*libc.TLS, int32, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(11)].FpCurrent})))(tls, fd, __ccgo_ts+3834, uint64(1))) + } + if rc != int32(1) { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__error(tls)))) + return int32(SQLITE_IOERR) + } + if libc.Xfsync(tls, fd) != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__error(tls)))) + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(4)<nColumn-1. +// */ +func _findOrCreateAggInfoColumn(tls *libc.TLS, pParse uintptr, pAggInfo uintptr, pExpr uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var j, k, mxTerm, n int32 + var pCol, pE, pGB, pTerm, v4 uintptr + var v3 Tu32 + _, _, _, _, _, _, _, _, _, _ = j, k, mxTerm, n, pCol, pE, pGB, pTerm, v3, v4 + mxTerm = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 2*4)) + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + k = 0 + for { + if !(k < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) { + break + } + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FpCExpr == pExpr { + return + } + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiTable == (*TExpr)(unsafe.Pointer(pExpr)).FiTable && (*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn == int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_IF_NULL_ROW) { + goto fix_up_expr + } + goto _1 + _1: + ; + k = k + 1 + pCol += 32 + } + k = _addAggInfoColumn(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pAggInfo) + if k < 0 { + /* OOM on resize */ + return + } + if k > mxTerm { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8958, libc.VaList(bp+8, mxTerm)) + k = mxTerm + } + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(k)*32 + (*TAggInfo_col)(unsafe.Pointer(pCol)).FpTab = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiTable = (*TExpr)(unsafe.Pointer(pExpr)).FiTable + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = -int32(1) + (*TAggInfo_col)(unsafe.Pointer(pCol)).FpCExpr = pExpr + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_IF_NULL_ROW) { + pGB = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy + pTerm = pGB + 8 + n = (*TExprList)(unsafe.Pointer(pGB)).FnExpr + j = 0 + for { + if !(j < n) { + break + } + pE = (*TExprList_item)(unsafe.Pointer(pTerm)).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pE)).FiTable == (*TExpr)(unsafe.Pointer(pExpr)).FiTable && int32((*TExpr)(unsafe.Pointer(pE)).FiColumn) == int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) { + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = j + break + } + goto _2 + _2: + ; + j = j + 1 + pTerm += 32 + } + } + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn < 0 { + v4 = pAggInfo + 4 + v3 = *(*Tu32)(unsafe.Pointer(v4)) + *(*Tu32)(unsafe.Pointer(v4)) = *(*Tu32)(unsafe.Pointer(v4)) + 1 + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = libc.Int32FromUint32(v3) + } + goto fix_up_expr +fix_up_expr: + ; + (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_AGG_COLUMN) + } + (*TExpr)(unsafe.Pointer(pExpr)).FiAgg = int16(k) +} + +// C documentation +// +// /* +// ** Search for an unused file descriptor that was opened on the database +// ** file (not a journal or super-journal file) identified by pathname +// ** zPath with SQLITE_OPEN_XXX flags matching those passed as the second +// ** argument to this function. +// ** +// ** Such a file descriptor may exist if a database connection was closed +// ** but the associated file descriptor could not be closed because some +// ** other file descriptor open on the same file is holding a file-lock. +// ** Refer to comments in the unixClose() function and the lengthy comment +// ** describing "Posix Advisory Locking" at the start of this file for +// ** further details. Also, ticket #4018. +// ** +// ** If a suitable file descriptor is found, then it is returned. If no +// ** such file descriptor is located, -1 is returned. +// */ +func _findReusableFd(tls *libc.TLS, zPath uintptr, flags int32) (r uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var pInode, pUnused, pp uintptr + var _ /* sStat at bp+0 */ Tstat + _, _, _ = pInode, pUnused, pp + pUnused = uintptr(0) /* Results of stat() call */ + _unixEnterMutex(tls) + /* A stat() call may fail for various reasons. If this happens, it is + ** almost certain that an open() call on the same path will also fail. + ** For this reason, if an error occurs in the stat() call here, it is + ** ignored and -1 is returned. The caller will try to open a new file + ** descriptor on the same path, fail, and return an error to SQLite. + ** + ** Even if a subsequent open() call does succeed, the consequences of + ** not searching for a reusable file descriptor are not dire. */ + if _inodeList != uintptr(0) && 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zPath, bp) { + pInode = _inodeList + for pInode != 0 && ((*TunixInodeInfo)(unsafe.Pointer(pInode)).FfileId.Fdev != (**(**Tstat)(__ccgo_up(bp))).Fst_dev || (*TunixInodeInfo)(unsafe.Pointer(pInode)).FfileId.Fino != (**(**Tstat)(__ccgo_up(bp))).Fst_ino) { + pInode = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpNext + } + if pInode != 0 { + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + flags = flags & (libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE)) + pp = pInode + 40 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0 && (*TUnixUnusedFd)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).Fflags != flags) { + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 8 + } + pUnused = **(**uintptr)(__ccgo_up(pp)) + if pUnused != 0 { + **(**uintptr)(__ccgo_up(pp)) = (*TUnixUnusedFd)(unsafe.Pointer(pUnused)).FpNext + } + Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + } + } + _unixLeaveMutex(tls) + return pUnused +} + +// C documentation +// +// /* +// ** Expression callback used by sqlite3FixAAAA() routines. +// */ +func _fixExprCb(tls *libc.TLS, p uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pFix uintptr + _ = pFix + pFix = *(*uintptr)(unsafe.Pointer(p + 40)) + if !((*TDbFixer)(unsafe.Pointer(pFix)).FbTemp != 0) { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_VARIABLE) { + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TDbFixer)(unsafe.Pointer(pFix)).FpParse)).Fdb)).Finit1.Fbusy != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + } else { + _sqlite3ErrorMsg(tls, (*TDbFixer)(unsafe.Pointer(pFix)).FpParse, __ccgo_ts+13883, libc.VaList(bp+8, (*TDbFixer)(unsafe.Pointer(pFix)).FzType)) + return int32(WRC_Abort) + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Select callback used by sqlite3FixAAAA() routines. +// */ +func _fixSelectCb(tls *libc.TLS, p uintptr, pSelect uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pFix, pItem, pList uintptr + var i, iDb int32 + _, _, _, _, _, _ = db, i, iDb, pFix, pItem, pList + pFix = *(*uintptr)(unsafe.Pointer(p + 40)) + db = (*TParse)(unsafe.Pointer((*TDbFixer)(unsafe.Pointer(pFix)).FpParse)).Fdb + iDb = _sqlite3FindDbName(tls, db, (*TDbFixer)(unsafe.Pointer(pFix)).FzDb) + pList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + if pList == uintptr(0) { + return WRC_Continue + } + i = 0 + pItem = pList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pList)).FnSrc) { + break + } + if libc.Int32FromUint8((*TDbFixer)(unsafe.Pointer(pFix)).FbTemp) == 0 && int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) == 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) == 0 && *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { + if iDb != _sqlite3FindDbName(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 72))) { + _sqlite3ErrorMsg(tls, (*TDbFixer)(unsafe.Pointer(pFix)).FpParse, __ccgo_ts+13907, libc.VaList(bp+8, (*TDbFixer)(unsafe.Pointer(pFix)).FzType, (*TDbFixer)(unsafe.Pointer(pFix)).FpName, *(*uintptr)(unsafe.Pointer(pItem + 72)))) + return int32(WRC_Abort) + } + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 72))) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 10, 0x400) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 17, 0x20000) + } + *(*uintptr)(unsafe.Pointer(pItem + 72)) = (*TDbFixer)(unsafe.Pointer(pFix)).FpSchema + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 8, 0x100) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 16, 0x10000) + } + if int32(*(*uint32)(unsafe.Pointer(pList + 8 + uintptr(i)*80 + 24 + 4))&0x800>>11) == 0 && _sqlite3WalkExpr(tls, pFix+8, *(*uintptr)(unsafe.Pointer(pList + 8 + uintptr(i)*80 + 64))) != 0 { + return int32(WRC_Abort) + } + goto _1 + _1: + ; + i = i + 1 + pItem += 80 + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpWith != 0 { + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpWith)).FnCte) { + break + } + if _sqlite3WalkSelect(tls, p, (*(*TCte)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpWith + 16 + uintptr(i)*48))).FpSelect) != 0 { + return int32(WRC_Abort) + } + goto _2 + _2: + ; + i = i + 1 + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** This function is called when an UPDATE or DELETE operation is being +// ** compiled on table pTab, which is the parent table of foreign-key pFKey. +// ** If the current operation is an UPDATE, then the pChanges parameter is +// ** passed a pointer to the list of columns being modified. If it is a +// ** DELETE, pChanges is passed a NULL pointer. +// ** +// ** It returns a pointer to a Trigger structure containing a trigger +// ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. +// ** If the action is "NO ACTION" then a NULL pointer is returned (these actions +// ** require no special handling by the triggers sub-system, code for them is +// ** created by fkScanChildren()). +// ** +// ** For example, if pFKey is the foreign key and pTab is table "p" in +// ** the following schema: +// ** +// ** CREATE TABLE p(pk PRIMARY KEY); +// ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE); +// ** +// ** then the returned trigger structure is equivalent to: +// ** +// ** CREATE TRIGGER ... DELETE ON p BEGIN +// ** DELETE FROM c WHERE ck = old.pk; +// ** END; +// ** +// ** The returned pointer is cached as part of the foreign key object. It +// ** is eventually freed along with the rest of the foreign key object by +// ** sqlite3FkDelete(). +// */ +func _fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, pChanges uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var action, i, iAction, iFromCol, nFrom, v2 int32 + var db, pCol, pDflt, pEq, pItem, pItem1, pList, pNew, pRaise, pSelect, pSrc, pStep, pTrigger, pWhen, pWhere, zFrom, v4 uintptr + var _ /* aiCol at bp+8 */ uintptr + var _ /* pIdx at bp+0 */ uintptr + var _ /* tFromCol at bp+48 */ TToken + var _ /* tNew at bp+32 */ TToken + var _ /* tOld at bp+16 */ TToken + var _ /* tToCol at bp+64 */ TToken + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = action, db, i, iAction, iFromCol, nFrom, pCol, pDflt, pEq, pItem, pItem1, pList, pNew, pRaise, pSelect, pSrc, pStep, pTrigger, pWhen, pWhere, zFrom, v2, v4 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Trigger definition to return */ + iAction = libc.BoolInt32(pChanges != uintptr(0)) /* 1 for UPDATE, 0 for DELETE */ + action = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pFKey + 45 + uintptr(iAction)))) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008))< parent key cols */ + pStep = uintptr(0) /* First (only) step of trigger program */ + pWhere = uintptr(0) /* WHERE clause of trigger step */ + pList = uintptr(0) /* Changes list if ON UPDATE CASCADE */ + pSelect = uintptr(0) /* Iterator variable */ + pWhen = uintptr(0) /* WHEN clause for the trigger */ + if _sqlite3FkLocateIndex(tls, pParse, pTab, pFKey, bp, bp+8) != 0 { + return uintptr(0) + } + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + **(**TToken)(__ccgo_up(bp + 16)) = TToken{ + Fz: __ccgo_ts + 7171, + Fn: uint32(3), + } /* Literal "old" token */ + **(**TToken)(__ccgo_up(bp + 32)) = TToken{ + Fz: __ccgo_ts + 7167, + Fn: uint32(3), + } /* tFromCol = OLD.tToCol */ + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v2 = **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + uintptr(i)*4)) + } else { + v2 = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom + } + iFromCol = v2 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v2 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaiColumn + uintptr(i)*2))) + } else { + v2 = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + _sqlite3TokenInit(tls, bp+64, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(v2)*16))).FzCnName) + _sqlite3TokenInit(tls, bp+48, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16))).FzCnName) + /* Create the expression "OLD.zToCol = zFromCol". It is important + ** that the "OLD.zToCol" term is on the LHS of the = operator, so + ** that the affinity and collation sequence associated with the + ** parent table are used for the comparison. */ + pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+16, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+48, 0)) + pWhere = _sqlite3ExprAnd(tls, pParse, pWhere, pEq) + /* For ON UPDATE, construct the next term of the WHEN clause. + ** The final WHEN clause will be like this: + ** + ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) + */ + if pChanges != 0 { + pEq = _sqlite3PExpr(tls, pParse, int32(TK_IS), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+16, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+32, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0))) + pWhen = _sqlite3ExprAnd(tls, pParse, pWhen, pEq) + } + if action != int32(OE_Restrict) && (action != int32(OE_Cascade) || pChanges != 0) { + if action == int32(OE_Cascade) { + pNew = _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+32, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)) + } else { + if action == int32(OE_SetDflt) { + pCol = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + pDflt = uintptr(0) + } else { + pDflt = _sqlite3ColumnExpr(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, pCol) + } + if pDflt != 0 { + pNew = _sqlite3ExprDup(tls, db, pDflt, 0) + } else { + pNew = _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0) + } + } else { + pNew = _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0) + } + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, pNew) + _sqlite3ExprListSetName(tls, pParse, pList, bp+48, 0) + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 8))) + zFrom = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName + nFrom = _sqlite3Strlen30(tls, zFrom) + if action == int32(OE_Restrict) { + pRaise = _sqlite3Expr(tls, db, int32(TK_STRING), __ccgo_ts+5736) + pRaise = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), pRaise, uintptr(0)) + if pRaise != 0 { + (*TExpr)(unsafe.Pointer(pRaise)).FaffExpr = int8(OE_Abort) + } + pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + if pSrc != 0 { + pItem = pSrc + 8 + (*TSrcItem)(unsafe.Pointer(pItem)).FzName = _sqlite3DbStrDup(tls, db, zFrom) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 16, 0x10000) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = (*TTable)(unsafe.Pointer(pTab)).FpSchema + } + pSelect = _sqlite3SelectNew(tls, pParse, _sqlite3ExprListAppend(tls, pParse, uintptr(0), pRaise), pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + pWhere = uintptr(0) + } + /* Disable lookaside memory allocation */ + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + pTrigger = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt64(72)+libc.Uint64FromInt64(88))) + if pTrigger != 0 { + v4 = pTrigger + 1*72 + (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list = v4 + pStep = v4 + (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + pItem1 = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 + (*TSrcItem)(unsafe.Pointer(pItem1)).FzName = _sqlite3DbStrNDup(tls, db, zFrom, libc.Uint64FromInt32(nFrom)) + *(*uintptr)(unsafe.Pointer(pItem1 + 72)) = (*TTable)(unsafe.Pointer(pTab)).FpSchema + libc.SetBitFieldPtr32Uint32(pItem1+24+4, libc.Uint32FromInt32(1), 16, 0x10000) + } + (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere = _sqlite3ExprDup(tls, db, pWhere, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList = _sqlite3ExprListDup(tls, db, pList, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect = _sqlite3SelectDup(tls, db, pSelect, int32(EXPRDUP_REDUCE)) + if pWhen != 0 { + pWhen = _sqlite3PExpr(tls, pParse, int32(TK_NOT), pWhen, uintptr(0)) + (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen = _sqlite3ExprDup(tls, db, pWhen, int32(EXPRDUP_REDUCE)) + } + } + /* Re-enable the lookaside buffer, if it was disabled earlier. */ + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v2 = 0 + } else { + v2 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v2) + _sqlite3ExprDelete(tls, db, pWhere) + _sqlite3ExprDelete(tls, db, pWhen) + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3SelectDelete(tls, db, pSelect) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == int32(1) { + _fkTriggerDelete(tls, db, pTrigger) + return uintptr(0) + } + switch action { + case int32(OE_Restrict): + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_SELECT) + case int32(OE_Cascade): + if !(pChanges != 0) { + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_DELETE) + break + } + fallthrough + default: + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_UPDATE) + } + (*TTriggerStep)(unsafe.Pointer(pStep)).FpTrig = pTrigger + (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + **(**uintptr)(__ccgo_up(pFKey + 48 + uintptr(iAction)*8)) = pTrigger + if pChanges != 0 { + v2 = int32(TK_UPDATE) + } else { + v2 = int32(TK_DELETE) + } + (*TTrigger)(unsafe.Pointer(pTrigger)).Fop = libc.Uint8FromInt32(v2) + } + return pTrigger +} + +// C documentation +// +// /* +// ** This function is called to generate code executed when a row is deleted +// ** from the parent table of foreign key constraint pFKey and, if pFKey is +// ** deferred, when a row is inserted into the same table. When generating +// ** code for an SQL UPDATE operation, this function may be called twice - +// ** once to "delete" the old row and once to "insert" the new row. +// ** +// ** Parameter nIncr is passed -1 when inserting a row (as this may decrease +// ** the number of FK violations in the db) or +1 when deleting one (as this +// ** may increase the number of FK constraint problems). +// ** +// ** The code generated by this function scans through the rows in the child +// ** table that correspond to the parent table row being deleted or inserted. +// ** For each child row found, one of the following actions is taken: +// ** +// ** Operation | FK type | Action taken +// ** -------------------------------------------------------------------------- +// ** DELETE immediate Increment the "immediate constraint counter". +// ** +// ** INSERT immediate Decrement the "immediate constraint counter". +// ** +// ** DELETE deferred Increment the "deferred constraint counter". +// ** +// ** INSERT deferred Decrement the "deferred constraint counter". +// ** +// ** These operations are identified in the comment at the top of this file +// ** (fkey.c) as "I.2" and "D.2". +// */ +func _fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, pIdx uintptr, pFKey uintptr, aiCol uintptr, regData int32, nIncr int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pAll, pEq, pEq1, pLeft, pLeft1, pNe, pRight, pRight1, pWInfo, pWhere, v, zCol uintptr + var i, iFkIfZero, v2 int32 + var iCol, iCol1 Ti16 + var _ /* sNameContext at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iCol, iCol1, iFkIfZero, pAll, pEq, pEq1, pLeft, pLeft1, pNe, pRight, pRight1, pWInfo, pWhere, v, zCol, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Iterator variable */ + pWhere = uintptr(0) /* Context used by sqlite3WhereXXX() */ + iFkIfZero = 0 /* Address of OP_FkIfZero */ + v = _sqlite3GetVdbe(tls, pParse) + if nIncr < 0 { + iFkIfZero = _sqlite3VdbeAddOp2(tls, v, int32(OP_FkIfZero), libc.Int32FromUint8((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred), 0) + } + /* Create an Expr object representing an SQL expression like: + ** + ** = AND = ... + ** + ** The collation sequence used for the comparison should be that of + ** the parent key columns. The affinity of the parent key column should + ** be applied to each child key value before the comparison takes place. + */ + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } /* Name of column in child table */ + if pIdx != 0 { + v2 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) + } else { + v2 = -int32(1) + } + iCol = int16(v2) + pLeft = _exprTableRegister(tls, pParse, pTab, regData, iCol) + if aiCol != 0 { + v2 = **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) + } else { + v2 = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom + } + iCol = int16(v2) + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iCol)*16))).FzCnName + pRight = _sqlite3Expr(tls, db, int32(TK_ID), zCol) + pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), pLeft, pRight) + pWhere = _sqlite3ExprAnd(tls, pParse, pWhere, pEq) + goto _1 + _1: + ; + i = i + 1 + } + /* If the child table is the same as the parent table, then add terms + ** to the WHERE clause that prevent this entry from being scanned. + ** The added WHERE clause terms are like this: + ** + ** $current_rowid!=rowid + ** NOT( $current_a==a AND $current_b==b AND ... ) + ** + ** The first form is used for rowid tables. The second form is used + ** for WITHOUT ROWID tables. In the second form, the *parent* key is + ** (a,b,...). Either the parent or primary key could be used to + ** uniquely identify the current row, but the parent key is more convenient + ** as the required values have already been loaded into registers + ** by the caller. + */ + if pTab == (*TFKey)(unsafe.Pointer(pFKey)).FpFrom && nIncr > 0 { /* Column ref to child table */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + pLeft1 = _exprTableRegister(tls, pParse, pTab, regData, int16(-int32(1))) + pRight1 = _exprTableColumn(tls, db, pTab, (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FiCursor, int16(-int32(1))) + pNe = _sqlite3PExpr(tls, pParse, int32(TK_NE), pLeft1, pRight1) + } else { + pAll = uintptr(0) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + iCol1 = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)) + pLeft1 = _exprTableRegister(tls, pParse, pTab, regData, iCol1) + pRight1 = _sqlite3Expr(tls, db, int32(TK_ID), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol1)*16))).FzCnName) + pEq1 = _sqlite3PExpr(tls, pParse, int32(TK_IS), pLeft1, pRight1) + pAll = _sqlite3ExprAnd(tls, pParse, pAll, pEq1) + goto _4 + _4: + ; + i = i + 1 + } + pNe = _sqlite3PExpr(tls, pParse, int32(TK_NOT), pAll, uintptr(0)) + } + pWhere = _sqlite3ExprAnd(tls, pParse, pWhere, pNe) + } + /* Resolve the references in the WHERE clause. */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pSrc + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + _sqlite3ResolveExprNames(tls, bp, pWhere) + /* Create VDBE to loop through the entries in pSrc that match the WHERE + ** clause. For each row found, increment either the deferred or immediate + ** foreign key constraint counter. */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + pWInfo = _sqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint16(0), 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_FkCounter), libc.Int32FromUint8((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) + if pWInfo != 0 { + _sqlite3WhereEnd(tls, pWInfo) + } + } + /* Clean up the WHERE clause constructed above. */ + _sqlite3ExprDelete(tls, db, pWhere) + if iFkIfZero != 0 { + _sqlite3VdbeJumpHereOrPopInst(tls, v, iFkIfZero) + } +} + +// C documentation +// +// /* +// ** This routine attempts to flatten subqueries as a performance optimization. +// ** This routine returns 1 if it makes changes and 0 if no flattening occurs. +// ** +// ** To understand the concept of flattening, consider the following +// ** query: +// ** +// ** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5 +// ** +// ** The default way of implementing this query is to execute the +// ** subquery first and store the results in a temporary table, then +// ** run the outer query on that temporary table. This requires two +// ** passes over the data. Furthermore, because the temporary table +// ** has no indices, the WHERE clause on the outer query cannot be +// ** optimized. +// ** +// ** This routine attempts to rewrite queries such as the above into +// ** a single flat select, like this: +// ** +// ** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5 +// ** +// ** The code generated for this simplification gives the same result +// ** but only has to scan the data once. And because indices might +// ** exist on the table t1, a complete scan of the data might be +// ** avoided. +// ** +// ** Flattening is subject to the following constraints: +// ** +// ** (**) We no longer attempt to flatten aggregate subqueries. Was: +// ** The subquery and the outer query cannot both be aggregates. +// ** +// ** (**) We no longer attempt to flatten aggregate subqueries. Was: +// ** (2) If the subquery is an aggregate then +// ** (2a) the outer query must not be a join and +// ** (2b) the outer query must not use subqueries +// ** other than the one FROM-clause subquery that is a candidate +// ** for flattening. (This is due to ticket [2f7170d73bf9abf80] +// ** from 2015-02-09.) +// ** +// ** (3) If the subquery is the right operand of a LEFT JOIN then +// ** (3a) the subquery may not be a join +// ** (**) Was (3b): "the FROM clause of the subquery may not contain +// ** a virtual table" +// ** (**) Was: "The outer query may not have a GROUP BY." This case +// ** is now managed correctly +// ** (3d) the outer query may not be DISTINCT. +// ** See also (26) for restrictions on RIGHT JOIN. +// ** +// ** (4) The subquery can not be DISTINCT. +// ** +// ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT +// ** sub-queries that were excluded from this optimization. Restriction +// ** (4) has since been expanded to exclude all DISTINCT subqueries. +// ** +// ** (**) We no longer attempt to flatten aggregate subqueries. Was: +// ** If the subquery is aggregate, the outer query may not be DISTINCT. +// ** +// ** (7) The subquery must have a FROM clause. TODO: For subqueries without +// ** A FROM clause, consider adding a FROM clause with the special +// ** table sqlite_once that consists of a single row containing a +// ** single NULL. +// ** +// ** (8) If the subquery uses LIMIT then the outer query may not be a join. +// ** +// ** (9) If the subquery uses LIMIT then the outer query may not be aggregate. +// ** +// ** (**) Restriction (10) was removed from the code on 2005-02-05 but we +// ** accidentally carried the comment forward until 2014-09-15. Original +// ** constraint: "If the subquery is aggregate then the outer query +// ** may not use LIMIT." +// ** +// ** (11) The subquery and the outer query may not both have ORDER BY clauses. +// ** +// ** (**) Not implemented. Subsumed into restriction (3). Was previously +// ** a separate restriction deriving from ticket #350. +// ** +// ** (13) The subquery and outer query may not both use LIMIT. +// ** +// ** (14) The subquery may not use OFFSET. +// ** +// ** (15) If the outer query is part of a compound select, then the +// ** subquery may not use LIMIT. +// ** (See ticket #2339 and ticket [02a8e81d44]). +// ** +// ** (16) If the outer query is aggregate, then the subquery may not +// ** use ORDER BY. (Ticket #2942) This used to not matter +// ** until we introduced the group_concat() function. +// ** +// ** (17) If the subquery is a compound select, then +// ** (17a) all compound operators must be a UNION ALL, and +// ** (17b) no terms within the subquery compound may be aggregate +// ** or DISTINCT, and +// ** (17c) every term within the subquery compound must have a FROM clause +// ** (17d) the outer query may not be +// ** (17d1) aggregate, or +// ** (17d2) DISTINCT +// ** (17e) the subquery may not contain window functions, and +// ** (17f) the subquery must not be the RHS of a LEFT JOIN. +// ** (17g) either the subquery is the first element of the outer +// ** query or there are no RIGHT or FULL JOINs in any arm +// ** of the subquery. (This is a duplicate of condition (27b).) +// ** (17h) The corresponding result set expressions in all arms of the +// ** compound must have the same affinity. +// ** +// ** The parent and sub-query may contain WHERE clauses. Subject to +// ** rules (11), (13) and (14), they may also contain ORDER BY, +// ** LIMIT and OFFSET clauses. The subquery cannot use any compound +// ** operator other than UNION ALL because all the other compound +// ** operators have an implied DISTINCT which is disallowed by +// ** restriction (4). +// ** +// ** Also, each component of the sub-query must return the same number +// ** of result columns. This is actually a requirement for any compound +// ** SELECT statement, but all the code here does is make sure that no +// ** such (illegal) sub-query is flattened. The caller will detect the +// ** syntax error and return a detailed message. +// ** +// ** (18) If the sub-query is a compound select, then all terms of the +// ** ORDER BY clause of the parent must be copies of a term returned +// ** by the parent query. +// ** +// ** (19) If the subquery uses LIMIT then the outer query may not +// ** have a WHERE clause. +// ** +// ** (20) If the sub-query is a compound select, then it must not use +// ** an ORDER BY clause. Ticket #3773. We could relax this constraint +// ** somewhat by saying that the terms of the ORDER BY clause must +// ** appear as unmodified result columns in the outer query. But we +// ** have other optimizations in mind to deal with that case. +// ** +// ** (21) If the subquery uses LIMIT then the outer query may not be +// ** DISTINCT. (See ticket [752e1646fc]). +// ** +// ** (22) The subquery may not be a recursive CTE. +// ** +// ** (23) If the outer query is a recursive CTE, then the sub-query may not be +// ** a compound query. This restriction is because transforming the +// ** parent to a compound query confuses the code that handles +// ** recursive queries in multiSelect(). +// ** +// ** (**) We no longer attempt to flatten aggregate subqueries. Was: +// ** The subquery may not be an aggregate that uses the built-in min() or +// ** or max() functions. (Without this restriction, a query like: +// ** "SELECT x FROM (SELECT max(y), x FROM t1)" would not necessarily +// ** return the value X for which Y was maximal.) +// ** +// ** (25) If either the subquery or the parent query contains a window +// ** function in the select list or ORDER BY clause, flattening +// ** is not attempted. +// ** +// ** (26) The subquery may not be the right operand of a RIGHT JOIN. +// ** See also (3) for restrictions on LEFT JOIN. +// ** +// ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it +// ** is the first element of the parent query. Two subcases: +// ** (27a) the subquery is not a compound query. +// ** (27b) the subquery is a compound query and the RIGHT JOIN occurs +// ** in any arm of the compound query. (See also (17g).) +// ** +// ** (28) The subquery is not a MATERIALIZED CTE. (This is handled +// ** in the caller before ever reaching this routine.) +// ** +// ** +// ** In this routine, the "p" parameter is a pointer to the outer query. +// ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query +// ** uses aggregates. +// ** +// ** If flattening is not attempted, this routine is a no-op and returns 0. +// ** If flattening is attempted this routine returns 1. +// ** +// ** All of the expression analysis must occur on both the outer query and +// ** the subquery before this routine runs. +// */ +func _flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAgg int32) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aCsrMap, db, pItem, pItemTab, pLimit, pNew, pOrderBy, pOrderBy1, pParent, pPrior, pSrc, pSub, pSub1, pSubSrc, pSubitem, pTabToDel, pToplevel, pWhere, zSavedAuthContext, v5 uintptr + var i, iNewParent, iParent, ii, isOuterJoin, nSubSrc, v4 int32 + var jointype Tu8 + var _ /* w at bp+0 */ TWalker + var _ /* x at bp+48 */ TSubstContext + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCsrMap, db, i, iNewParent, iParent, ii, isOuterJoin, jointype, nSubSrc, pItem, pItemTab, pLimit, pNew, pOrderBy, pOrderBy1, pParent, pPrior, pSrc, pSub, pSub1, pSubSrc, pSubitem, pTabToDel, pToplevel, pWhere, zSavedAuthContext, v4, v5 + zSavedAuthContext = (*TParse)(unsafe.Pointer(pParse)).FzAuthContext /* VDBE cursor number of the pSub result set temp table */ + iNewParent = -int32(1) /* Replacement table for iParent */ + isOuterJoin = 0 /* The subquery */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Walker to persist agginfo data */ + aCsrMap = uintptr(0) + /* Check to see if flattening is permitted. Return 0 if not. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_QueryFlattener)) != uint32(0) { + return 0 + } + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + pSubitem = pSrc + 8 + uintptr(iFrom)*80 + iParent = (*TSrcItem)(unsafe.Pointer(pSubitem)).FiCursor + pSub = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSubitem + 72)))).FpSelect + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 || (*TSelect)(unsafe.Pointer(pSub)).FpWin != 0 { + return 0 + } /* Restriction (25) */ + pSubSrc = (*TSelect)(unsafe.Pointer(pSub)).FpSrc + /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, + ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET + ** because they could be computed at compile-time. But when LIMIT and OFFSET + ** became arbitrary expressions, we were forced to add restrictions (13) + ** and (14). */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && (*TSelect)(unsafe.Pointer(p)).FpLimit != 0 { + return 0 + } /* Restriction (13) */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpLimit)).FpRight != 0 { + return 0 + } /* Restriction (14) */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Compound) != uint32(0) && (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 { + return 0 /* Restriction (15) */ + } + if (*TSrcList)(unsafe.Pointer(pSubSrc)).FnSrc == 0 { + return 0 + } /* Restriction (7) */ + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&uint32(SF_Distinct) != 0 { + return 0 + } /* Restriction (4) */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && ((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc > int32(1) || isAgg != 0) { + return 0 /* Restrictions (8)(9) */ + } + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 && (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + return 0 /* Restriction (11) */ + } + if isAgg != 0 && (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + return 0 + } /* Restriction (16) */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && (*TSelect)(unsafe.Pointer(p)).FpWhere != 0 { + return 0 + } /* Restriction (19) */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != uint32(0) { + return 0 /* Restriction (21) */ + } + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Recursive)) != 0 { + return 0 /* Restrictions (22) */ + } + /* + ** If the subquery is the right operand of a LEFT JOIN, then the + ** subquery may not be a join itself (3a). Example of why this is not + ** allowed: + ** + ** t1 LEFT OUTER JOIN (t2 JOIN t3) + ** + ** If we flatten the above, we would get + ** + ** (t1 LEFT OUTER JOIN t2) JOIN t3 + ** + ** which is not at all the same thing. + ** + ** See also tickets #306, #350, and #3300. + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_LTORJ)) != 0 { + if (*TSrcList)(unsafe.Pointer(pSubSrc)).FnSrc > int32(1) || (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != uint32(0) || libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + return 0 + } + isOuterJoin = int32(1) + } + /* True by restriction (7) */ + if iFrom > 0 && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSubSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + return 0 /* Restriction (27a) */ + } + /* Condition (28) is blocked by the caller */ + /* Restriction (17): If the sub-query is a compound SELECT, then it must + ** use only the UNION ALL operator. And none of the simple select queries + ** that make up the compound SELECT are allowed to be aggregate or distinct + ** queries. + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpPrior != 0 { + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + return 0 /* Restriction (20) */ + } + if isAgg != 0 || (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != uint32(0) || isOuterJoin > 0 { + return 0 /* (17d1), (17d2), or (17f) */ + } + pSub1 = pSub + for { + if !(pSub1 != 0) { + break + } + if (*TSelect)(unsafe.Pointer(pSub1)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Distinct)|libc.Int32FromInt32(SF_Aggregate)) != uint32(0) || (*TSelect)(unsafe.Pointer(pSub1)).FpPrior != 0 && libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSub1)).Fop) != int32(TK_ALL) || (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub1)).FpSrc)).FnSrc < int32(1) || (*TSelect)(unsafe.Pointer(pSub1)).FpWin != 0 { + return 0 + } + if iFrom > 0 && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub1)).FpSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + /* Without this restriction, the JT_LTORJ flag would end up being + ** omitted on left-hand tables of the right join that is being + ** flattened. */ + return 0 /* Restrictions (17g), (27b) */ + } + goto _1 + _1: + ; + pSub1 = (*TSelect)(unsafe.Pointer(pSub1)).FpPrior + } + /* Restriction (18). */ + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 { + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr) { + break + } + if libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy + 8 + uintptr(ii)*32 + 24))) == 0 { + return 0 + } + goto _2 + _2: + ; + ii = ii + 1 + } + } + /* Restriction (23) */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Recursive) != 0 { + return 0 + } + /* Restriction (17h) */ + if _compoundHasDifferentAffinities(tls, pSub) != 0 { + return 0 + } + if (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc > int32(1) { + if (*TParse)(unsafe.Pointer(pParse)).FnSelect > int32(500) { + return 0 + } + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FlttnUnionAll)) != uint32(0) { + return 0 + } + aCsrMap = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(int64((*TParse)(unsafe.Pointer(pParse)).FnTab)+libc.Int64FromInt32(1))*uint64(4)) + if aCsrMap != 0 { + **(**int32)(__ccgo_up(aCsrMap)) = (*TParse)(unsafe.Pointer(pParse)).FnTab + } + } + } + /***** If we reach this point, flattening is permitted. *****/ + /* Authorize the subquery */ + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = (*TSrcItem)(unsafe.Pointer(pSubitem)).FzName + _sqlite3AuthCheck(tls, pParse, int32(SQLITE_SELECT), uintptr(0), uintptr(0), uintptr(0)) + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedAuthContext + /* Delete the transient structures associated with the subquery */ + if int32(*(*uint32)(unsafe.Pointer(pSubitem + 24 + 4))&0x4>>2) != 0 { + pSub1 = _sqlite3SubqueryDetach(tls, db, pSubitem) + } else { + pSub1 = uintptr(0) + } + _sqlite3DbFree(tls, db, (*TSrcItem)(unsafe.Pointer(pSubitem)).FzName) + _sqlite3DbFree(tls, db, (*TSrcItem)(unsafe.Pointer(pSubitem)).FzAlias) + (*TSrcItem)(unsafe.Pointer(pSubitem)).FzName = uintptr(0) + (*TSrcItem)(unsafe.Pointer(pSubitem)).FzAlias = uintptr(0) + /* If the sub-query is a compound SELECT statement, then (by restrictions + ** 17 and 18 above) it must be a UNION ALL and the parent query must + ** be of the form: + ** + ** SELECT FROM () + ** + ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block + ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or + ** OFFSET clauses and joins them to the left-hand-side of the original + ** using UNION ALL operators. In this case N is the number of simple + ** select statements in the compound sub-query. + ** + ** Example: + ** + ** SELECT a+1 FROM ( + ** SELECT x FROM tab + ** UNION ALL + ** SELECT y FROM tab + ** UNION ALL + ** SELECT abs(z*2) FROM tab2 + ** ) WHERE a!=5 ORDER BY 1 + ** + ** Transformed into: + ** + ** SELECT x+1 FROM tab WHERE x+1!=5 + ** UNION ALL + ** SELECT y+1 FROM tab WHERE y+1!=5 + ** UNION ALL + ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5 + ** ORDER BY 1 + ** + ** We call this the "compound-subquery flattening". + */ + pSub = (*TSelect)(unsafe.Pointer(pSub)).FpPrior + for { + if !(pSub != 0) { + break + } + pOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + pLimit = (*TSelect)(unsafe.Pointer(p)).FpLimit + pPrior = (*TSelect)(unsafe.Pointer(p)).FpPrior + pItemTab = (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab + (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpLimit = uintptr(0) + pNew = _sqlite3SelectDup(tls, db, p, 0) + (*TSelect)(unsafe.Pointer(p)).FpLimit = pLimit + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = pOrderBy + (*TSelect)(unsafe.Pointer(p)).Fop = uint8(TK_ALL) + (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab = pItemTab + if pNew == uintptr(0) { + (*TSelect)(unsafe.Pointer(p)).FpPrior = pPrior + } else { + v5 = pParse + 124 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + (*TSelect)(unsafe.Pointer(pNew)).FselId = libc.Uint32FromInt32(v4) + if aCsrMap != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + _renumberCursors(tls, pParse, pNew, iFrom, aCsrMap) + } + (*TSelect)(unsafe.Pointer(pNew)).FpPrior = pPrior + if pPrior != 0 { + (*TSelect)(unsafe.Pointer(pPrior)).FpNext = pNew + } + (*TSelect)(unsafe.Pointer(pNew)).FpNext = p + (*TSelect)(unsafe.Pointer(p)).FpPrior = pNew + } + goto _3 + _3: + ; + pSub = (*TSelect)(unsafe.Pointer(pSub)).FpPrior + } + _sqlite3DbFree(tls, db, aCsrMap) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3SrcItemAttachSubquery(tls, pParse, pSubitem, pSub1, 0) + return int32(1) + } + /* Defer deleting the Table object associated with the + ** subquery until code generation is + ** complete, since there may still exist Expr.pTab entries that + ** refer to the subquery even after flattening. Ticket #3346. + ** + ** pSubitem->pSTab is always non-NULL by test restrictions and tests above. + */ + if (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab != uintptr(0) { + pTabToDel = (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab + if (*TTable)(unsafe.Pointer(pTabToDel)).FnTabRef == uint32(1) { + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v5 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v5 = pParse + } + pToplevel = v5 + _sqlite3ParserAddCleanup(tls, pToplevel, __ccgo_fp(_sqlite3DeleteTableGeneric), pTabToDel) + } else { + (*TTable)(unsafe.Pointer(pTabToDel)).FnTabRef = (*TTable)(unsafe.Pointer(pTabToDel)).FnTabRef - 1 + } + (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab = uintptr(0) + } + /* The following loop runs once for each term in a compound-subquery + ** flattening (as described above). If we are doing a different kind + ** of flattening - a flattening other than a compound-subquery flattening - + ** then this loop only runs once. + ** + ** This loop moves all of the FROM elements of the subquery into the + ** the FROM clause of the outer query. Before doing this, remember + ** the cursor number for the original outer query FROM element in + ** iParent. The iParent cursor will never be used. Subsequent code + ** will scan expressions looking for iParent references and replace + ** those references with expressions that resolve to the subquery FROM + ** elements we are now copying in. + */ + pSub = pSub1 + pParent = p + for { + if !(pParent != 0) { + break + } + jointype = (*TSrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype + pSubSrc = (*TSelect)(unsafe.Pointer(pSub)).FpSrc /* FROM clause of subquery */ + nSubSrc = (*TSrcList)(unsafe.Pointer(pSubSrc)).FnSrc /* Number of terms in subquery FROM clause */ + pSrc = (*TSelect)(unsafe.Pointer(pParent)).FpSrc /* FROM clause of the outer query */ + /* The subquery uses a single slot of the FROM clause of the outer + ** query. If the subquery has more than one element in its FROM clause, + ** then expand the outer query to make space for it to hold all elements + ** of the subquery. + ** + ** Example: + ** + ** SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB; + ** + ** The outer query has 3 slots in its FROM clause. One slot of the + ** outer query (the middle slot) is used by the subquery. The next + ** block of code will expand the outer query FROM clause to 4 slots. + ** The middle slot is expanded to two slots in order to make space + ** for the two elements in the FROM clause of the subquery. + */ + if nSubSrc > int32(1) { + pSrc = _sqlite3SrcListEnlarge(tls, pParse, pSrc, nSubSrc-int32(1), iFrom+int32(1)) + if pSrc == uintptr(0) { + break + } + (*TSelect)(unsafe.Pointer(pParent)).FpSrc = pSrc + pSubitem = pSrc + 8 + uintptr(iFrom)*80 + } + /* Transfer the FROM clause terms from the subquery into the + ** outer query. + */ + iNewParent = (*(*TSrcItem)(unsafe.Pointer(pSubSrc + 8))).FiCursor + i = 0 + for { + if !(i < nSubSrc) { + break + } + pItem = pSrc + 8 + uintptr(i+iFrom)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) != 0 { + _sqlite3IdListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 64))) + } + **(**TSrcItem)(__ccgo_up(pItem)) = *(*TSrcItem)(unsafe.Pointer(pSubSrc + 8 + uintptr(i)*80)) + v5 = pItem + 24 + *(*Tu8)(unsafe.Pointer(v5)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v5))) | libc.Int32FromUint8(jointype)&libc.Int32FromInt32(JT_LTORJ)) + libc.X__builtin___memset_chk(tls, pSubSrc+8+uintptr(i)*80, 0, uint64(80), ^t__predefined_size_t(0)) + goto _8 + _8: + ; + i = i + 1 + } + v5 = pSubitem + 24 + *(*Tu8)(unsafe.Pointer(v5)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v5))) | libc.Int32FromUint8(jointype)) + /* Begin substituting subquery result set expressions for + ** references to the iParent in the outer query. + ** + ** Example: + ** + ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; + ** \ \_____________ subquery __________/ / + ** \_____________________ outer query ______________________________/ + ** + ** We look at every expression in the outer query and every place we see + ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + /* At this point, any non-zero iOrderByCol values indicate that the + ** ORDER BY column expression is identical to the iOrderByCol'th + ** expression returned by SELECT statement pSub. Since these values + ** do not necessarily correspond to columns in SELECT statement pParent, + ** zero them before transferring the ORDER BY clause. + ** + ** Not doing this may cause an error if a subsequent call to this + ** function attempts to flatten a compound sub-query into pParent. + ** See ticket [d11a6e908f]. + */ + pOrderBy1 = (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy1)).FnExpr) { + break + } + *(*Tu16)(unsafe.Pointer(pOrderBy1 + 8 + uintptr(i)*32 + 24)) = uint16(0) + goto _11 + _11: + ; + i = i + 1 + } + (*TSelect)(unsafe.Pointer(pParent)).FpOrderBy = pOrderBy1 + (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0) + } + pWhere = (*TSelect)(unsafe.Pointer(pSub)).FpWhere + (*TSelect)(unsafe.Pointer(pSub)).FpWhere = uintptr(0) + if isOuterJoin > 0 { + _sqlite3SetJoinExpr(tls, pWhere, iNewParent, uint32(EP_OuterON)) + } + if pWhere != 0 { + if (*TSelect)(unsafe.Pointer(pParent)).FpWhere != 0 { + (*TSelect)(unsafe.Pointer(pParent)).FpWhere = _sqlite3PExpr(tls, pParse, int32(TK_AND), pWhere, (*TSelect)(unsafe.Pointer(pParent)).FpWhere) + } else { + (*TSelect)(unsafe.Pointer(pParent)).FpWhere = pWhere + } + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + (**(**TSubstContext)(__ccgo_up(bp + 48))).FpParse = pParse + (**(**TSubstContext)(__ccgo_up(bp + 48))).FiTable = iParent + (**(**TSubstContext)(__ccgo_up(bp + 48))).FiNewTable = iNewParent + (**(**TSubstContext)(__ccgo_up(bp + 48))).FisOuterJoin = isOuterJoin + (**(**TSubstContext)(__ccgo_up(bp + 48))).FnSelDepth = 0 + (**(**TSubstContext)(__ccgo_up(bp + 48))).FpEList = (*TSelect)(unsafe.Pointer(pSub)).FpEList + (**(**TSubstContext)(__ccgo_up(bp + 48))).FpCList = _findLeftmostExprlist(tls, pSub) + _substSelect(tls, bp+48, pParent, 0) + } + /* The flattened query is a compound if either the inner or the + ** outer query is a compound. */ + **(**Tu32)(__ccgo_up(pParent + 4)) |= (*TSelect)(unsafe.Pointer(pSub)).FselFlags & uint32(SF_Compound) + /* restriction (17b) */ + /* + ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; + ** + ** One is tempted to try to add a and b to combine the limits. But this + ** does not work if either limit is negative. + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 { + (*TSelect)(unsafe.Pointer(pParent)).FpLimit = (*TSelect)(unsafe.Pointer(pSub)).FpLimit + (*TSelect)(unsafe.Pointer(pSub)).FpLimit = uintptr(0) + } + /* Recompute the SrcItem.colUsed masks for the flattened + ** tables. */ + i = 0 + for { + if !(i < nSubSrc) { + break + } + _recomputeColumnsUsed(tls, pParent, pSrc+8+uintptr(i+iFrom)*80) + goto _12 + _12: + ; + i = i + 1 + } + goto _7 + _7: + ; + pParent = (*TSelect)(unsafe.Pointer(pParent)).FpPrior + pSub = (*TSelect)(unsafe.Pointer(pSub)).FpPrior + } + /* Finally, delete what is left of the subquery and return success. + */ + _sqlite3AggInfoPersistWalkerInit(tls, bp, pParse) + _sqlite3WalkSelect(tls, bp, pSub1) + _sqlite3SelectDelete(tls, db, pSub1) + return int32(1) +} + +// C documentation +// +// /* +// ** This routine checks if there is a RESERVED lock held on the specified +// ** file by this or any other process. If such a lock is held, set *pResOut +// ** to a non-zero value otherwise *pResOut is set to zero. The return value +// ** is set to SQLITE_OK unless an I/O error occurs during lock checking. +// */ +func _flockCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) (r int32) { + _ = id + /* The flock VFS only ever takes exclusive locks (see function flockLock). + ** Therefore, if this connection is holding any lock at all, no other + ** connection may be holding a RESERVED lock. So set *pResOut to 0 + ** in this case. + ** + ** Or, this connection may be holding no lock. In that case, set *pResOut to + ** 0 as well. The caller will then attempt to take an EXCLUSIVE lock on the + ** db in order to roll the hot journal back. If there is another connection + ** holding a lock, that attempt will fail and an SQLITE_BUSY returned to + ** the user. With other VFS, we try to avoid this, in order to allow a reader + ** to proceed while a writer is preparing its transaction. But that won't + ** work with the flock VFS - as it always takes EXCLUSIVE locks - so it is + ** not a problem in this case. */ + **(**int32)(__ccgo_up(pResOut)) = 0 + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Close a file. +// */ +func _flockClose(tls *libc.TLS, id uintptr) (r int32) { + _flockUnlock(tls, id, NO_LOCK) + return _closeUnixFile(tls, id) +} + +/******************* End of the flock lock implementation ********************* +******************************************************************************/ + +/****************************************************************************** +************************ Begin Named Semaphore Locking ************************ +** +** Named semaphore locking is only supported on VxWorks. +** +** Semaphore locking is like dot-lock and flock in that it really only +** supports EXCLUSIVE locking. Only a single process can read or write +** the database file at a time. This reduces potential concurrency, but +** makes the lock implementation much easier. + */ +/* +** Named semaphore locking is only available on VxWorks. +** +*************** End of the named semaphore lock implementation **************** +******************************************************************************/ + +/****************************************************************************** +*************************** Begin AFP Locking ********************************* +** +** AFP is the Apple Filing Protocol. AFP is a network filesystem found +** on Apple Macintosh computers - both OS9 and OSX. +** +** Third-party implementations of AFP are available. But this code here +** only works on OSX. + */ + +var _flockIoFinder = uintptr(0) + +func _flockIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) (r uintptr) { + _ = z + _ = p + return uintptr(unsafe.Pointer(&_flockIoMethods)) +} + +var _flockIoMethods = Tsqlite3_io_methods{ + FiVersion: int32(1), +} + +// C documentation +// +// /* +// ** Lock the file with the lock specified by parameter eFileLock - one +// ** of the following: +// ** +// ** (1) SHARED_LOCK +// ** (2) RESERVED_LOCK +// ** (3) PENDING_LOCK +// ** (4) EXCLUSIVE_LOCK +// ** +// ** Sometimes when requesting one lock state, additional lock states +// ** are inserted in between. The locking might fail on one of the later +// ** transitions leaving the lock state different from what it started but +// ** still short of its goal. The following chart shows the allowed +// ** transitions and the inserted intermediate states: +// ** +// ** UNLOCKED -> SHARED +// ** SHARED -> RESERVED +// ** SHARED -> (PENDING) -> EXCLUSIVE +// ** RESERVED -> (PENDING) -> EXCLUSIVE +// ** PENDING -> EXCLUSIVE +// ** +// ** flock() only really support EXCLUSIVE locks. We track intermediate +// ** lock states in the sqlite3_file structure, but all locks SHARED or +// ** above are really EXCLUSIVE locks and exclude all other processes from +// ** access the file. +// ** +// ** This routine will only increase a lock. Use the sqlite3OsUnlock() +// ** routine to lower a locking level. +// */ +func _flockLock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + var pFile uintptr + var rc, tErrno int32 + _, _, _ = pFile, rc, tErrno + rc = SQLITE_OK + pFile = id + /* if we already have a lock, it is exclusive. + ** Just adjust level and punt on outta here. */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) > NO_LOCK { + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = libc.Uint8FromInt32(eFileLock) + return SQLITE_OK + } + /* grab an exclusive lock */ + if _robust_flock(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, libc.Int32FromInt32(LOCK_EX)|libc.Int32FromInt32(LOCK_NB)) != 0 { + tErrno = **(**int32)(__ccgo_up(libc.X__error(tls))) + /* didn't get, must be busy */ + rc = _sqliteErrorFromPosixError(tls, tErrno, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(15)< (*TBtShared)(unsafe.Pointer(pBt)).FnPage { + return _sqlite3CorruptError(tls, int32(79983)) + } + if pMemPage != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = pMemPage + _sqlite3PagerRef(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + } else { + **(**uintptr)(__ccgo_up(bp + 8)) = _btreePageLookup(tls, pBt, iPage) + } + /* Increment the free page count on pPage1 */ + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FpDbPage) + if **(**int32)(__ccgo_up(bp + 16)) != 0 { + goto freepage_out + } + nFree = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+36) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+36, nFree+uint32(1)) + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_SECURE_DELETE) != 0 { + /* If the secure_delete option is enabled, then + ** always fully overwrite deleted information with zeros. + */ + if v2 = !(**(**uintptr)(__ccgo_up(bp + 8)) != 0); v2 { + v1 = _btreeGetPage(tls, pBt, iPage, bp+8, 0) + **(**int32)(__ccgo_up(bp + 16)) = v1 + } + if v4 = v2 && v1 != 0; !v4 { + v3 = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + **(**int32)(__ccgo_up(bp + 16)) = v3 + } + if v4 || v3 != 0 { + goto freepage_out + } + libc.X__builtin___memset_chk(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData, 0, uint64((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpBt)).FpageSize), ^t__predefined_size_t(0)) + } + /* If the database supports auto-vacuum, write an entry in the pointer-map + ** to indicate that the page is free. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _ptrmapPut(tls, pBt, iPage, uint8(PTRMAP_FREEPAGE), uint32(0), bp+16) + if **(**int32)(__ccgo_up(bp + 16)) != 0 { + goto freepage_out + } + } + /* Now manipulate the actual database free-list structure. There are two + ** possibilities. If the free-list is currently empty, or if the first + ** trunk page in the free-list is full, then this page will become a + ** new free-list trunk page. Otherwise, it will become a leaf of the + ** first trunk page in the current free-list. This block tests if it + ** is possible to add the page as a new free-list leaf. + */ + if nFree != uint32(0) { /* Initial number of leaf cells on trunk page */ + iTrunk = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32) + if iTrunk > _btreePagecount(tls, pBt) { + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3CorruptError(tls, int32(80030)) + goto freepage_out + } + **(**int32)(__ccgo_up(bp + 16)) = _btreeGetPage(tls, pBt, iTrunk, bp, 0) + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + goto freepage_out + } + nLeaf = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+4) + if nLeaf > (*TBtShared)(unsafe.Pointer(pBt)).FusableSize/uint32(4)-uint32(2) { + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3CorruptError(tls, int32(80041)) + goto freepage_out + } + if nLeaf < (*TBtShared)(unsafe.Pointer(pBt)).FusableSize/uint32(4)-uint32(8) { + /* In this case there is room on the trunk page to insert the page + ** being freed as a new leaf. + ** + ** Note that the trunk page is not really full until it contains + ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have + ** coded. But due to a coding error in versions of SQLite prior to + ** 3.6.0, databases with freelist trunk pages holding more than + ** usableSize/4 - 8 entries will be reported as corrupt. In order + ** to maintain backwards compatibility with older versions of SQLite, + ** we will continue to restrict the number of entries to usableSize/4 - 8 + ** for now. At some point in the future (once everyone has upgraded + ** to 3.6.0 or later) we should consider fixing the conditional above + ** to read "usableSize/4-2" instead of "usableSize/4-8". + ** + ** EVIDENCE-OF: R-19920-11576 However, newer versions of SQLite still + ** avoid using the last six entries in the freelist trunk page array in + ** order that database files created by newer versions of SQLite can be + ** read by older versions of SQLite. + */ + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+4, nLeaf+uint32(1)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+uintptr(uint32(8)+nLeaf*uint32(4)), iPage) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 && libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_SECURE_DELETE) == 0 { + _sqlite3PagerDontWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + } + **(**int32)(__ccgo_up(bp + 16)) = _btreeSetHasContent(tls, pBt, iPage) + } + goto freepage_out + } + } + /* If control flows to this point, then it was not possible to add the + ** the page being freed as a leaf page of the first trunk in the free-list. + ** Possibly because the free-list is empty, or possibly because the + ** first trunk in the free-list is full. Either way, the page being freed + ** will become the new first trunk page in the free-list. + */ + if v2 = **(**uintptr)(__ccgo_up(bp + 8)) == uintptr(0); v2 { + v1 = _btreeGetPage(tls, pBt, iPage, bp+8, 0) + **(**int32)(__ccgo_up(bp + 16)) = v1 + } + if v2 && SQLITE_OK != v1 { + goto freepage_out + } + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + goto freepage_out + } + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData, iTrunk) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData+4, uint32(0)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32, iPage) + goto freepage_out +freepage_out: + ; + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FisInit = uint8(0) + } + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** Return a section of the pPage->aData to the freelist. +// ** The first byte of the new free block is pPage->aData[iStart] +// ** and the size of the block is iSize bytes. +// ** +// ** Adjacent freeblocks are coalesced. +// ** +// ** Even though the freeblock list was checked by btreeComputeFreeSpace(), +// ** that routine will not detect overlap between cells or freeblocks. Nor +// ** does it detect cells or freeblocks that encroach into the reserved bytes +// ** at the end of the page. So do additional corruption checks inside this +// ** routine and return SQLITE_CORRUPT if any problems are found. +// */ +func _freeSpace(tls *libc.TLS, pPage uintptr, iStart int32, iSize int32) (r int32) { + var data, pTmp, v2 uintptr + var hdr Tu8 + var iEnd, iFreeBlk, iOrigSize, iPtr, iPtrEnd, nFrag, x, v1 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = data, hdr, iEnd, iFreeBlk, iOrigSize, iPtr, iPtrEnd, nFrag, pTmp, x, v1, v2 /* Page header size. 0 or 100 */ + nFrag = 0 /* Reduction in fragmentation */ + iOrigSize = iSize /* Offset to cell content area */ + iEnd = iStart + iSize /* First byte past the iStart buffer */ + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData /* Temporary ptr into data[] */ + /* Minimum cell size is 4 */ + /* The list of freeblocks must be in ascending order. Find the + ** spot on the list where iStart should be inserted. + */ + hdr = (*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset + iPtr = libc.Int32FromUint8(hdr) + int32(1) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iPtr+int32(1))))) == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iPtr)))) == 0 { + iFreeBlk = 0 /* Shortcut for the case when the freelist is empty */ + } else { + for { + v1 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iPtr))))< libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize)-int32(4) { /* TH3: corrupt081.100 */ + return _sqlite3CorruptError(tls, int32(75094)) + } + /* At this point: + ** iFreeBlk: First freeblock after iStart, or zero if none + ** iPtr: The address of a pointer to iFreeBlk + ** + ** Check to see if iFreeBlk should be coalesced onto the end of iStart. + */ + if iFreeBlk != 0 && iEnd+int32(3) >= iFreeBlk { + nFrag = iFreeBlk - iEnd + if iEnd > iFreeBlk { + return _sqlite3CorruptError(tls, int32(75106)) + } + iEnd = iFreeBlk + (libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFreeBlk+int32(2)))))< libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) { + return _sqlite3CorruptError(tls, int32(75109)) + } + iSize = iEnd - iStart + iFreeBlk = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFreeBlk))))< libc.Int32FromUint8(hdr)+int32(1) { + iPtrEnd = iPtr + (libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iPtr+int32(2)))))<= iStart { + if iPtrEnd > iStart { + return _sqlite3CorruptError(tls, int32(75122)) + } + nFrag = nFrag + (iStart - iPtrEnd) + iSize = iEnd - iPtr + iStart = iPtr + } + } + if nFrag > libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(7))))) { + return _sqlite3CorruptError(tls, int32(75128)) + } + v2 = data + uintptr(libc.Int32FromUint8(hdr)+int32(7)) + *(*uint8)(unsafe.Pointer(v2)) = uint8(int32(*(*uint8)(unsafe.Pointer(v2))) - libc.Int32FromUint8(libc.Uint8FromInt32(nFrag))) + } + pTmp = data + uintptr(libc.Int32FromUint8(hdr)+int32(5)) + x = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTmp)))<> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(1)) + 1)) = libc.Uint8FromInt32(iFreeBlk) + **(**uint8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(5)))) = libc.Uint8FromInt32(iEnd >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(5)) + 1)) = libc.Uint8FromInt32(iEnd) + } else { + /* Insert the new freeblock into the freelist */ + **(**uint8)(__ccgo_up(data + uintptr(iPtr))) = libc.Uint8FromInt32(iStart >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(iPtr) + 1)) = libc.Uint8FromInt32(iStart) + **(**uint8)(__ccgo_up(data + uintptr(iStart))) = libc.Uint8FromInt32(iFreeBlk >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(iStart) + 1)) = libc.Uint8FromInt32(iFreeBlk) + **(**uint8)(__ccgo_up(data + uintptr(iStart+int32(2)))) = libc.Uint8FromInt32(libc.Int32FromUint16(libc.Uint16FromInt32(iSize)) >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(iStart+int32(2)) + 1)) = uint8(libc.Uint16FromInt32(iSize)) + } + **(**int32)(__ccgo_up(pPage + 20)) += iOrigSize + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Allocate a new segment-id for the structure pStruct. The new segment +// ** id must be between 1 and 65335 inclusive, and must not be used by +// ** any currently existing segment. If a free segment id cannot be found, +// ** SQLITE_FULL is returned. +// ** +// ** If an error has already occurred, this function is a no-op. 0 is +// ** returned in this case. +// */ +func _fts5AllocateSegid(tls *libc.TLS, p uintptr, pStruct uintptr) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var i, iId, iLvl, iSeg, iSegid int32 + var mask Tu32 + var _ /* aUsed at bp+0 */ [63]Tu32 + _, _, _, _, _, _ = i, iId, iLvl, iSeg, iSegid, mask + iSegid = 0 + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment >= int32(FTS5_MAX_SEGMENT) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = int32(SQLITE_FULL) + } else { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(252), ^t__predefined_size_t(0)) + iLvl = 0 + for { + if !(iLvl < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + iSeg = 0 + for { + if !(iSeg < (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg) { + break + } + iId = (**(**TFts5StructureSegment)(__ccgo_up((*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr(iSeg)*56))).FiSegid + if iId <= int32(FTS5_MAX_SEGMENT) && iId > 0 { + **(**Tu32)(__ccgo_up(bp + uintptr((iId-int32(1))/int32(32))*4)) |= libc.Uint32FromInt32(1) << ((iId - int32(1)) % int32(32)) + } + goto _2 + _2: + ; + iSeg = iSeg + 1 + } + goto _1 + _1: + ; + iLvl = iLvl + 1 + } + i = 0 + for { + if !((**(**[63]Tu32)(__ccgo_up(bp)))[i] == uint32(0xFFFFFFFF)) { + break + } + goto _3 + _3: + ; + i = i + 1 + } + mask = (**(**[63]Tu32)(__ccgo_up(bp)))[i] + iSegid = 0 + for { + if !(mask&(libc.Uint32FromInt32(1)< or >= constraint against the rowid column. +// ** +// ** Within the ORDER BY, the following are supported: +// ** +// ** 5. ORDER BY rank [ASC|DESC] +// ** 6. ORDER BY rowid [ASC|DESC] +// ** +// ** Information for the xFilter call is passed via both the idxNum and +// ** idxStr variables. Specifically, idxNum is a bitmask of the following +// ** flags used to encode the ORDER BY clause: +// ** +// ** FTS5_BI_ORDER_RANK +// ** FTS5_BI_ORDER_ROWID +// ** FTS5_BI_ORDER_DESC +// ** +// ** idxStr is used to encode data from the WHERE clause. For each argument +// ** passed to the xFilter method, the following is appended to idxStr: +// ** +// ** Match against table column: "m" +// ** Match against rank column: "r" +// ** Match against other column: "M" +// ** LIKE against other column: "L" +// ** GLOB against other column: "G" +// ** Equality constraint against the rowid: "=" +// ** A < or <= against the rowid: "<" +// ** A > or >= against the rowid: ">" +// ** +// ** This function ensures that there is at most one "r" or "=". And that if +// ** there exists an "=" then there is no "<" or ">". +// ** +// ** If an unusable MATCH operator is present in the WHERE clause, then +// ** SQLITE_CONSTRAINT is returned. +// ** +// ** Costs are assigned as follows: +// ** +// ** a) If a MATCH operator is present, the cost depends on the other +// ** constraints also present. As follows: +// ** +// ** * No other constraints: cost=50000.0 +// ** * One rowid range constraint: cost=37500.0 +// ** * Both rowid range constraints: cost=30000.0 +// ** * An == rowid constraint: cost=25000.0 +// ** +// ** b) Otherwise, if there is no MATCH: +// ** +// ** * No other constraints: cost=3000000.0 +// ** * One rowid range constraints: cost=2250000.0 +// ** * Both rowid range constraint: cost=750000.0 +// ** * An == rowid constraint: cost=25.0 +// ** +// ** Costs are not modified by the ORDER BY clause. +// ** +// ** The ratios used in case (a) are based on informal results obtained from +// ** the tool/fts5cost.tcl script. The "MATCH and ==" combination has the +// ** cost set quite high because the query may be a prefix query. Unless +// ** there is a prefix index, prefix queries with rowid constraints are much +// ** more expensive than non-prefix queries with rowid constraints. +// ** +// ** The estimated rows returned is set to the cost/40. For simple queries, +// ** experimental results show that cost/4 might be about right. But for +// ** more complex queries that use multiple terms the number of rows might +// ** be far fewer than this. So we compromise and use cost/40. +// */ +func _fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bSeenEq, bSeenGt, bSeenLt, bSeenRank, i, iCol, iCons, iIdxStr, iSort, idxFlags, nCol, nSeenMatch, op, v2, v3 int32 + var idxStr, p, p1, pConfig, pTab uintptr + var nEstRows Ti64 + var v15 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bSeenEq, bSeenGt, bSeenLt, bSeenRank, i, iCol, iCons, iIdxStr, iSort, idxFlags, idxStr, nCol, nEstRows, nSeenMatch, op, p, p1, pConfig, pTab, v15, v2, v3 + pTab = pVTab + pConfig = (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig + nCol = (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + idxFlags = 0 + iIdxStr = 0 + iCons = 0 + bSeenEq = 0 + bSeenGt = 0 + bSeenLt = 0 + nSeenMatch = 0 + bSeenRank = 0 + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLock != 0 { + (*TFts5Table)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+40036, 0) + return int32(SQLITE_ERROR) + } + idxStr = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint)*int64(8)+int64(1))) + if idxStr == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FidxStr = idxStr + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FneedToFreeIdxStr = int32(1) + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12 + iCol = (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) && iCol >= nCol { + /* A MATCH operator or equivalent */ + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0 || iCol < 0 { + /* As there exists an unusable MATCH constraint this is an + ** unusable plan. Return SQLITE_CONSTRAINT. */ + **(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr))) = 0 + return int32(SQLITE_CONSTRAINT) + } else { + if iCol == nCol+int32(1) { + if bSeenRank != 0 { + goto _1 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('r') + bSeenRank = int32(1) + } else { + nSeenMatch = nSeenMatch + 1 + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('M') + Xsqlite3_snprintf(tls, int32(6), idxStr+uintptr(iIdxStr), __ccgo_ts+5633, libc.VaList(bp+8, iCol)) + iIdxStr = iIdxStr + libc.Int32FromUint64(libc.Xstrlen(tls, idxStr+uintptr(iIdxStr))) + } + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + } + } else { + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 { + if iCol >= 0 && iCol < nCol && _fts5UsePatternMatch(tls, pConfig, p) != 0 { + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(FTS5_PATTERN_LIKE) { + v3 = int32('L') + } else { + v3 = int32('G') + } + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8(v3) + Xsqlite3_snprintf(tls, int32(6), idxStr+uintptr(iIdxStr), __ccgo_ts+5633, libc.VaList(bp+8, iCol)) + idxStr = idxStr + uintptr(libc.Xstrlen(tls, idxStr+uintptr(iIdxStr))) + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + nSeenMatch = nSeenMatch + 1 + } else { + if bSeenEq == 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) && iCol < 0 { + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('=') + bSeenEq = int32(1) + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + } + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + if bSeenEq == 0 { + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint) { + break + } + p1 = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12 + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).FiColumn < 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).Fusable != 0 { + op = libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).Fop) + if op == int32(SQLITE_INDEX_CONSTRAINT_LT) || op == int32(SQLITE_INDEX_CONSTRAINT_LE) { + if bSeenLt != 0 { + goto _10 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('<') + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + bSeenLt = int32(1) + } else { + if op == int32(SQLITE_INDEX_CONSTRAINT_GT) || op == int32(SQLITE_INDEX_CONSTRAINT_GE) { + if bSeenGt != 0 { + goto _10 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('>') + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + bSeenGt = int32(1) + } + } + } + goto _10 + _10: + ; + i = i + 1 + } + } + **(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr))) = int8('\000') + /* Set idxFlags flags for the ORDER BY clause + ** + ** Note that tokendata=1 tables cannot currently handle "ORDER BY rowid DESC". + */ + if (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == int32(1) { + iSort = (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).FiColumn + if iSort == (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol+int32(1) && nSeenMatch > 0 { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_RANK) + } else { + if iSort == -int32(1) && (!((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).Fdesc != 0) || !((*TFts5Config)(unsafe.Pointer(pConfig)).FbTokendata != 0)) { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_ROWID) + } + } + if idxFlags&(libc.Int32FromInt32(FTS5_BI_ORDER_RANK)|libc.Int32FromInt32(FTS5_BI_ORDER_ROWID)) != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = int32(1) + if (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).Fdesc != 0 { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_DESC) + } + } + } + /* Calculate the estimated cost based on the flags set in idxFlags. */ + if bSeenEq != 0 { + if nSeenMatch != 0 { + v15 = float64(25000) + } else { + v15 = float64(25) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = v15 + _fts5SetEstimatedRows(tls, pInfo, int64(1)) + _fts5SetUniqueFlag(tls, pInfo) + } else { + if nSeenMatch != 0 { + if bSeenLt != 0 && bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(50000) + } else { + if bSeenLt != 0 || bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(37500) + } else { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(50000) + } + } + nEstRows = int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / libc.Float64FromFloat64(40)) + i = int32(1) + for { + if !(i < nSeenMatch) { + break + } + **(**float64)(__ccgo_up(pInfo + 64)) *= float64(2.5) + nEstRows = nEstRows / int64(2) + goto _16 + _16: + ; + i = i + 1 + } + } else { + if bSeenLt != 0 && bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(750000) + } else { + if bSeenLt != 0 || bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(2.25e+06) + } else { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(3e+06) + } + } + nEstRows = int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / libc.Float64FromFloat64(4)) + } + _fts5SetEstimatedRows(tls, pInfo, nEstRows) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxFlags + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Implementation of bm25() function. +// */ +func _fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var D, b, k1, score, w, v2 float64 + var aFreq uintptr + var i, rc int32 + var _ /* ic at bp+16 */ int32 + var _ /* io at bp+20 */ int32 + var _ /* ip at bp+12 */ int32 + var _ /* nInst at bp+8 */ int32 + var _ /* nTok at bp+24 */ int32 + var _ /* pData at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _ = D, aFreq, b, i, k1, rc, score, w, v2 + k1 = float64(1.2) /* Constant "k1" from BM25 formula */ + b = float64(0.75) /* Error code */ + score = float64(0) /* Iterator variable */ + **(**int32)(__ccgo_up(bp + 8)) = 0 /* Value returned by xInstCount() */ + D = float64(0) /* Total number of tokens in row */ + aFreq = uintptr(0) /* Array of phrase freq. for current row */ + /* Calculate the phrase frequency (symbol "f(qi,D)" in the documentation) + ** for each phrase in the query for the current row. */ + rc = _fts5Bm25GetData(tls, pApi, pFts, bp) + if rc == SQLITE_OK { + aFreq = (*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaFreq + libc.X__builtin___memset_chk(tls, aFreq, 0, uint64(8)*libc.Uint64FromInt32((*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnPhrase), ^t__predefined_size_t(0)) + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})))(tls, pFts, bp+8) + } + i = 0 + for { + if !(rc == SQLITE_OK && i < **(**int32)(__ccgo_up(bp + 8))) { + break + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})))(tls, pFts, i, bp+12, bp+16, bp+20) + if rc == SQLITE_OK { + if nVal > **(**int32)(__ccgo_up(bp + 16)) { + v2 = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(**(**int32)(__ccgo_up(bp + 16)))*8))) + } else { + v2 = float64(1) + } + w = v2 + **(**float64)(__ccgo_up(aFreq + uintptr(**(**int32)(__ccgo_up(bp + 12)))*8)) += w + } + goto _1 + _1: + ; + i = i + 1 + } + /* Figure out the total size of the current row in tokens. */ + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})))(tls, pFts, -int32(1), bp+24) + D = float64(**(**int32)(__ccgo_up(bp + 24))) + } + /* Determine and return the BM25 score for the current row. Or, if an + ** error has occurred, throw an exception. */ + if rc == SQLITE_OK { + i = 0 + for { + if !(i < (*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnPhrase) { + break + } + score = score + float64(**(**float64)(__ccgo_up((*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaIDF + uintptr(i)*8))*(float64(**(**float64)(__ccgo_up(aFreq + uintptr(i)*8))*(k1+libc.Float64FromFloat64(1)))/(**(**float64)(__ccgo_up(aFreq + uintptr(i)*8))+float64(k1*(libc.Float64FromInt32(1)-b+float64(b*D)/(*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Favgdl))))) + goto _3 + _3: + ; + i = i + 1 + } + Xsqlite3_result_double(tls, pCtx, float64(-libc.Float64FromFloat64(1)*score)) + } else { + Xsqlite3_result_error_code(tls, pCtx, rc) + } +} + +// C documentation +// +// /* +// ** Set *ppData to point to the Fts5Bm25Data object for the current query. +// ** If the object has not already been allocated, allocate and populate it +// ** now. +// */ +func _fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, nPhrase, rc int32 + var idf float64 + var nByte Tsqlite3_int64 + var p uintptr + var _ /* nHit at bp+16 */ Tsqlite3_int64 + var _ /* nRow at bp+0 */ Tsqlite3_int64 + var _ /* nToken at bp+8 */ Tsqlite3_int64 + _, _, _, _, _, _ = i, idf, nByte, nPhrase, p, rc + rc = SQLITE_OK /* Object to return */ + p = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxGetAuxdata})))(tls, pFts, 0) + if p == uintptr(0) { /* Number of phrases in query */ + **(**Tsqlite3_int64)(__ccgo_up(bp)) = 0 /* Number of rows in table */ + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0 + /* Allocate the Fts5Bm25Data object */ + nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseCount})))(tls, pFts) + nByte = libc.Int64FromUint64(uint64(32) + libc.Uint64FromInt32(nPhrase*int32(2))*uint64(8)) + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if p == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, p, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + (*TFts5Bm25Data)(unsafe.Pointer(p)).FnPhrase = nPhrase + (*TFts5Bm25Data)(unsafe.Pointer(p)).FaIDF = p + 1*32 + (*TFts5Bm25Data)(unsafe.Pointer(p)).FaFreq = (*TFts5Bm25Data)(unsafe.Pointer(p)).FaIDF + uintptr(nPhrase)*8 + } + /* Calculate the average document length for this FTS5 table */ + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxRowCount})))(tls, pFts, bp) + } + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnTotalSize})))(tls, pFts, -int32(1), bp+8) + } + if rc == SQLITE_OK { + (*TFts5Bm25Data)(unsafe.Pointer(p)).Favgdl = float64(**(**Tsqlite3_int64)(__ccgo_up(bp + 8))) / float64(**(**Tsqlite3_int64)(__ccgo_up(bp))) + } + /* Calculate an IDF for each phrase in the query */ + i = 0 + for { + if !(rc == SQLITE_OK && i < nPhrase) { + break + } + **(**Tsqlite3_int64)(__ccgo_up(bp + 16)) = 0 + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxQueryPhrase})))(tls, pFts, i, bp+16, __ccgo_fp(_fts5CountCb)) + if rc == SQLITE_OK { + /* Calculate the IDF (Inverse Document Frequency) for phrase i. + ** This is done using the standard BM25 formula as found on wikipedia: + ** + ** IDF = log( (N - nHit + 0.5) / (nHit + 0.5) ) + ** + ** where "N" is the total number of documents in the set and nHit + ** is the number that contain at least one instance of the phrase + ** under consideration. + ** + ** The problem with this is that if (N < 2*nHit), the IDF is + ** negative. Which is undesirable. So the minimum allowable IDF is + ** (1e-6) - roughly the same as a term that appears in just over + ** half of set of 5,000,000 documents. */ + idf = libc.Xlog(tls, (float64(**(**Tsqlite3_int64)(__ccgo_up(bp))-**(**Tsqlite3_int64)(__ccgo_up(bp + 16)))+float64(0.5))/(float64(**(**Tsqlite3_int64)(__ccgo_up(bp + 16)))+float64(0.5))) + if idf <= float64(0) { + idf = float64(1e-06) + } + **(**float64)(__ccgo_up((*TFts5Bm25Data)(unsafe.Pointer(p)).FaIDF + uintptr(i)*8)) = idf + } + goto _1 + _1: + ; + i = i + 1 + } + if rc != SQLITE_OK { + Xsqlite3_free(tls, p) + } else { + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxSetAuxdata})))(tls, pFts, p, __ccgo_fp(Xsqlite3_free)) + } + if rc != SQLITE_OK { + p = uintptr(0) + } + } + **(**uintptr)(__ccgo_up(ppData)) = p + return rc +} + +// C documentation +// +// /* +// ** Initialize the iterator object indicated by the final parameter to +// ** iterate through coalesced phrase instances in column iCol. +// */ +func _fts5CInstIterInit(tls *libc.TLS, pApi uintptr, pFts uintptr, iCol int32, pIter uintptr) (r int32) { + var rc int32 + _ = rc + libc.X__builtin___memset_chk(tls, pIter, 0, uint64(40), ^t__predefined_size_t(0)) + (*TCInstIter)(unsafe.Pointer(pIter)).FpApi = pApi + (*TCInstIter)(unsafe.Pointer(pIter)).FpFts = pFts + (*TCInstIter)(unsafe.Pointer(pIter)).FiCol = iCol + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})))(tls, pFts, pIter+24) + if rc == SQLITE_OK { + rc = _fts5CInstIterNext(tls, pIter) + } + return rc +} + +// C documentation +// +// /* +// ** If argument pOrig is NULL, or if (*pRc) is set to anything other than +// ** SQLITE_OK when this function is called, NULL is returned. +// ** +// ** Otherwise, a copy of (*pOrig) is made into memory obtained from +// ** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation +// ** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned. +// */ +func _fts5CloneColset(tls *libc.TLS, pRc uintptr, pOrig uintptr) (r uintptr) { + var nByte Tsqlite3_int64 + var pRet uintptr + _, _ = nByte, pRet + if pOrig != 0 { + nByte = libc.Int64FromUint64(libc.Uint64FromInt64(8) * libc.Uint64FromInt32(((*TFts5Colset)(unsafe.Pointer(pOrig)).FnCol+libc.Int32FromInt32(2))/libc.Int32FromInt32(2))) + pRet = _sqlite3Fts5MallocZero(tls, pRc, nByte) + if pRet != 0 { + libc.X__builtin___memcpy_chk(tls, pRet, pOrig, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + } + } else { + pRet = uintptr(0) + } + return pRet +} + +// C documentation +// +// /* +// ** Gobble up the first bareword or quoted word from the input buffer zIn. +// ** Return a pointer to the character immediately following the last in +// ** the gobbled word if successful, or a NULL pointer otherwise (failed +// ** to find close-quote character). +// ** +// ** Before returning, set pzOut to point to a new buffer containing a +// ** nul-terminated, dequoted copy of the gobbled word. If the word was +// ** quoted, *pbQuoted is also set to 1 before returning. +// ** +// ** If *pRc is other than SQLITE_OK when this function is called, it is +// ** a no-op (NULL is returned). Otherwise, if an OOM occurs within this +// ** function, *pRc is set to SQLITE_NOMEM before returning. *pRc is *not* +// ** set if a parse error (failed to find close quote) occurs. +// */ +func _fts5ConfigGobbleWord(tls *libc.TLS, pRc uintptr, zIn uintptr, pzOut uintptr, pbQuoted uintptr) (r uintptr) { + var ii int32 + var nIn Tsqlite3_int64 + var zOut, zRet uintptr + _, _, _, _ = ii, nIn, zOut, zRet + zRet = uintptr(0) + nIn = libc.Int64FromUint64(libc.Xstrlen(tls, zIn)) + zOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nIn+int64(1))) + **(**int32)(__ccgo_up(pbQuoted)) = 0 + **(**uintptr)(__ccgo_up(pzOut)) = uintptr(0) + if zOut == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memcpy_chk(tls, zOut, zIn, libc.Uint64FromInt64(nIn+libc.Int64FromInt32(1)), ^t__predefined_size_t(0)) + if _fts5_isopenquote(tls, **(**int8)(__ccgo_up(zOut))) != 0 { + ii = _fts5Dequote(tls, zOut) + zRet = zIn + uintptr(ii) + **(**int32)(__ccgo_up(pbQuoted)) = int32(1) + } else { + zRet = _fts5ConfigSkipBareword(tls, zIn) + if zRet != 0 { + **(**int8)(__ccgo_up(zOut + uintptr(int64(zRet)-int64(zIn)))) = int8('\000') + } + } + } + if zRet == uintptr(0) { + Xsqlite3_free(tls, zOut) + } else { + **(**uintptr)(__ccgo_up(pzOut)) = zOut + } + return zRet +} + +// C documentation +// +// /* +// ** Populate the Fts5Config.zContentExprlist string. +// */ +func _fts5ConfigMakeExprlist(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var _ /* buf at bp+8 */ TFts5Buffer + var _ /* rc at bp+0 */ int32 + _ = i + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TFts5Buffer)(__ccgo_up(bp + 8)) = TFts5Buffer{} + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+38364, libc.VaList(bp+32, (*TFts5Config)(unsafe.Pointer(p)).FzContentRowid)) + if (*TFts5Config)(unsafe.Pointer(p)).FeContent != int32(FTS5_CONTENT_NONE) { + i = 0 + for { + if !(i < (*TFts5Config)(unsafe.Pointer(p)).FnCol) { + break + } + if (*TFts5Config)(unsafe.Pointer(p)).FeContent == int32(FTS5_CONTENT_EXTERNAL) { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+38369, libc.VaList(bp+32, **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)))) + } else { + if (*TFts5Config)(unsafe.Pointer(p)).FeContent == FTS5_CONTENT_NORMAL || **(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr(i))) != 0 { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+38376, libc.VaList(bp+32, i)) + } else { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+38384, 0) + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + if (*TFts5Config)(unsafe.Pointer(p)).FeContent == FTS5_CONTENT_NORMAL && (*TFts5Config)(unsafe.Pointer(p)).FbLocale != 0 { + i = 0 + for { + if !(i < (*TFts5Config)(unsafe.Pointer(p)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr(i)))) == 0 { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+38391, libc.VaList(bp+32, i)) + } else { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+38384, 0) + } + goto _2 + _2: + ; + i = i + 1 + } + } + (*TFts5Config)(unsafe.Pointer(p)).FzContentExprlist = (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5ConfigParseColumn(tls *libc.TLS, p uintptr, zCol uintptr, zArg uintptr, pzErr uintptr, pbUnindexed uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc, v1 int32 + var v2 uintptr + _, _, _ = rc, v1, v2 + rc = SQLITE_OK + if 0 == Xsqlite3_stricmp(tls, zCol, __ccgo_ts+38288) || 0 == Xsqlite3_stricmp(tls, zCol, __ccgo_ts+18310) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38293, libc.VaList(bp+8, zCol)) + rc = int32(SQLITE_ERROR) + } else { + if zArg != 0 { + if 0 == Xsqlite3_stricmp(tls, zArg, __ccgo_ts+38323) { + **(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr((*TFts5Config)(unsafe.Pointer(p)).FnCol))) = uint8(1) + **(**int32)(__ccgo_up(pbUnindexed)) = int32(1) + } else { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38333, libc.VaList(bp+8, zArg)) + rc = int32(SQLITE_ERROR) + } + } + } + v2 = p + 32 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FazCol + uintptr(v1)*8)) = zCol + return rc +} + +// C documentation +// +// /* +// ** Parse a "special" CREATE VIRTUAL TABLE directive and update +// ** configuration object pConfig as appropriate. +// ** +// ** If successful, object pConfig is updated and SQLITE_OK returned. If +// ** an error occurs, an SQLite error code is returned and an error message +// ** may be left in *pzErr. It is the responsibility of the caller to +// ** eventually free any such error message using sqlite3_free(). +// */ +func _fts5ConfigParseSpecial(tls *libc.TLS, pConfig uintptr, zCmd uintptr, zArg uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var azArg, p, p1, p2, pSpace uintptr + var bFirst, nByte, nCmd, nPre, v2 int32 + var nArg Tsqlite3_int64 + var _ /* aDetail at bp+8 */ [4]TFts5Enum + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = azArg, bFirst, nArg, nByte, nCmd, nPre, p, p1, p2, pSpace, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + nCmd = libc.Int32FromUint64(libc.Xstrlen(tls, zCmd)) + if Xsqlite3_strnicmp(tls, __ccgo_ts+37727, zCmd, nCmd) == 0 { + nByte = libc.Int32FromUint64(libc.Uint64FromInt64(4) * libc.Uint64FromInt32(FTS5_MAX_PREFIX_INDEXES)) + bFirst = int32(1) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix == uintptr(0) { + (*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix = _sqlite3Fts5MallocZero(tls, bp, int64(nByte)) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + p = zArg + for int32(1) != 0 { + nPre = 0 + for int32(**(**int8)(__ccgo_up(p))) == int32(' ') { + p = p + 1 + } + if bFirst == 0 && int32(**(**int8)(__ccgo_up(p))) == int32(',') { + p = p + 1 + for int32(**(**int8)(__ccgo_up(p))) == int32(' ') { + p = p + 1 + } + } else { + if int32(**(**int8)(__ccgo_up(p))) == int32('\000') { + break + } + } + if int32(**(**int8)(__ccgo_up(p))) < int32('0') || int32(**(**int8)(__ccgo_up(p))) > int32('9') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37734, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + if (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix == int32(FTS5_MAX_PREFIX_INDEXES) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37765, libc.VaList(bp+80, int32(FTS5_MAX_PREFIX_INDEXES))) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + for int32(**(**int8)(__ccgo_up(p))) >= int32('0') && int32(**(**int8)(__ccgo_up(p))) <= int32('9') && nPre < int32(1000) { + nPre = nPre*int32(10) + (int32(**(**int8)(__ccgo_up(p))) - int32('0')) + p = p + 1 + } + if nPre <= 0 || nPre >= int32(1000) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37798, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + **(**int32)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr((*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix)*4)) = nPre + (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix = (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix + 1 + bFirst = 0 + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37835, zCmd, nCmd) == 0 { + p1 = zArg + nArg = libc.Int64FromUint64(libc.Xstrlen(tls, zArg) + uint64(1)) + azArg = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(2))*libc.Uint64FromInt64(nArg))) + if azArg != 0 { + pSpace = azArg + uintptr(nArg)*8 + if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FazArg != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37844, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + nArg = 0 + for { + if !(p1 != 0 && **(**int8)(__ccgo_up(p1)) != 0) { + break + } + p2 = _fts5ConfigSkipWhitespace(tls, p1) + if int32(**(**int8)(__ccgo_up(p2))) == int32('\'') { + p1 = _fts5ConfigSkipLiteral(tls, p2) + } else { + p1 = _fts5ConfigSkipBareword(tls, p2) + } + if p1 != 0 { + libc.X__builtin___memcpy_chk(tls, pSpace, p2, libc.Uint64FromInt64(int64(p1)-int64(p2)), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(azArg + uintptr(nArg)*8)) = pSpace + _sqlite3Fts5Dequote(tls, pSpace) + pSpace = pSpace + uintptr(int64(p1)-int64(p2)+int64(1)) + p1 = _fts5ConfigSkipWhitespace(tls, p1) + } + goto _1 + _1: + ; + nArg = nArg + 1 + } + if p1 == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37877, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FazArg = azArg + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FnArg = int32(nArg) + azArg = uintptr(0) + } + } + } + Xsqlite3_free(tls, azArg) + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37911, zCmd, nCmd) == 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37919, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + if **(**int8)(__ccgo_up(zArg)) != 0 { + (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent = int32(FTS5_CONTENT_EXTERNAL) + (*TFts5Config)(unsafe.Pointer(pConfig)).FzContent = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+37951, libc.VaList(bp+80, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, zArg)) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent = int32(FTS5_CONTENT_NONE) + } + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37957, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37976, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+38019, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37976, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessUnindexed = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+38041, zCmd, nCmd) == 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FzContentRowid != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38055, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FzContentRowid = _sqlite3Fts5Strndup(tls, bp, zArg, -int32(1)) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+38093, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38104, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+38139, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38146, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+6010, zCmd, nCmd) == 0 { + **(**[4]TFts5Enum)(__ccgo_up(bp + 8)) = [4]TFts5Enum{ + 0: { + FzName: __ccgo_ts + 8852, + FeVal: int32(FTS5_DETAIL_NONE), + }, + 1: { + FzName: __ccgo_ts + 19379, + }, + 2: { + FzName: __ccgo_ts + 38177, + FeVal: int32(FTS5_DETAIL_COLUMNS), + }, + 3: {}, + } + v2 = _fts5ConfigSetEnum(tls, bp+8, zArg, pConfig+116) + **(**int32)(__ccgo_up(bp)) = v2 + if v2 != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38185, 0) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+38216, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38226, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbTokendata = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38260, libc.VaList(bp+80, nCmd, zCmd)) + return int32(SQLITE_ERROR) +} + +// C documentation +// +// /* +// ** +// ** This function is called when the user attempts an UPDATE on a contentless +// ** table. Parameter bRowidModified is true if the UPDATE statement modifies +// ** the rowid value. Parameter apVal[] contains the new values for each user +// ** defined column of the fts5 table. pConfig is the configuration object of the +// ** table being updated (guaranteed to be contentless). The contentless_delete=1 +// ** and contentless_unindexed=1 options may or may not be set. +// ** +// ** This function returns SQLITE_OK if the UPDATE can go ahead, or an SQLite +// ** error code if it cannot. In this case an error message is also loaded into +// ** pConfig. Output parameter (*pbContent) is set to true if the caller should +// ** update the %_content table only - not the FTS index or any other shadow +// ** table. This occurs when an UPDATE modifies only UNINDEXED columns of the +// ** table. +// ** +// ** An UPDATE may proceed if: +// ** +// ** * The only columns modified are UNINDEXED columns, or +// ** +// ** * The contentless_delete=1 option was specified and all of the indexed +// ** columns (not a subset) have been modified. +// */ +func _fts5ContentlessUpdate(tls *libc.TLS, pConfig uintptr, apVal uintptr, bRowidModified int32, pbContent uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bSeenIndex, bSeenIndexNC, ii, rc int32 + var v2 uintptr + _, _, _, _, _ = bSeenIndex, bSeenIndexNC, ii, rc, v2 + bSeenIndex = 0 /* Have seen modified indexed column */ + bSeenIndexNC = 0 /* Have seen unmodified indexed column */ + rc = SQLITE_OK + ii = 0 + for { + if !(ii < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(ii)))) == 0 { + if Xsqlite3_value_nochange(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(ii)*8))) != 0 { + bSeenIndexNC = bSeenIndexNC + 1 + } else { + bSeenIndex = bSeenIndex + 1 + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + if bSeenIndex == 0 && bRowidModified == 0 { + **(**int32)(__ccgo_up(pbContent)) = int32(1) + } else { + if bSeenIndexNC != 0 || (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete == 0 { + rc = int32(SQLITE_ERROR) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete != 0 { + v2 = __ccgo_ts + 40501 + } else { + v2 = __ccgo_ts + 40561 + } + _sqlite3Fts5ConfigErrmsg(tls, pConfig, v2, libc.VaList(bp+8, __ccgo_ts+40591, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Register a new auxiliary function with global context pGlobal. +// */ +func _fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr, __ccgo_fp_xFunc Tfts5_extension_function, __ccgo_fp_xDestroy uintptr) (r int32) { + var nByte, nName Tsqlite3_int64 + var pAux, pGlobal uintptr + var rc int32 + _, _, _, _, _ = nByte, nName, pAux, pGlobal, rc + pGlobal = pApi + rc = Xsqlite3_overload_function(tls, (*TFts5Global)(unsafe.Pointer(pGlobal)).Fdb, zName, -int32(1)) + if rc == SQLITE_OK { /* Bytes of space to allocate */ + nName = libc.Int64FromUint64(libc.Xstrlen(tls, zName) + uint64(1)) + nByte = libc.Int64FromUint64(uint64(48) + libc.Uint64FromInt64(nName)) + pAux = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pAux != 0 { + libc.X__builtin___memset_chk(tls, pAux, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc = pAux + 1*48 + libc.X__builtin___memcpy_chk(tls, (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc, zName, libc.Uint64FromInt64(nName), ^t__predefined_size_t(0)) + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal = pGlobal + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpUserData = pUserData + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxFunc = __ccgo_fp_xFunc + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy = __ccgo_fp_xDestroy + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpNext = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpAux + (*TFts5Global)(unsafe.Pointer(pGlobal)).FpAux = pAux + } else { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +func _fts5CursorFirstSorted(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int32) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var nByte Tsqlite3_int64 + var nPhrase, rc int32 + var pConfig, pSorter, zRank, zRankArgs, v1, v2, v3 uintptr + _, _, _, _, _, _, _, _, _, _ = nByte, nPhrase, pConfig, pSorter, rc, zRank, zRankArgs, v1, v2, v3 + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + zRank = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank + zRankArgs = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs + nPhrase = _sqlite3Fts5ExprPhraseCount(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+24) + libc.Uint64FromInt32((nPhrase+libc.Int32FromInt32(2))/libc.Int32FromInt32(2))*libc.Uint64FromInt64(8)) + pSorter = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pSorter == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pSorter, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + (*TFts5Sorter)(unsafe.Pointer(pSorter)).FnIdx = nPhrase + /* TODO: It would be better to have some system for reusing statement + ** handles here, rather than preparing a new one for each query. But that + ** is not possible as SQLite reference counts the virtual table objects. + ** And since the statement required here reads from this very virtual + ** table, saving it creates a circular reference. + ** + ** If SQLite a built-in statement cache, this wouldn't be a problem. */ + if zRankArgs != 0 { + v1 = __ccgo_ts + 16558 + } else { + v1 = __ccgo_ts + 1702 + } + if zRankArgs != 0 { + v2 = zRankArgs + } else { + v2 = __ccgo_ts + 1702 + } + if bDesc != 0 { + v3 = __ccgo_ts + 40075 + } else { + v3 = __ccgo_ts + 40080 + } + rc = _fts5PrepareStatement(tls, pSorter, pConfig, __ccgo_ts+40084, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zRank, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, v1, v2, v3)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = pSorter + if rc == SQLITE_OK { + (*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = pCsr + rc = _fts5SorterNext(tls, pCsr) + (*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = uintptr(0) + } + if rc != SQLITE_OK { + Xsqlite3_finalize(tls, (*TFts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) + Xsqlite3_free(tls, pSorter) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = uintptr(0) + } + return rc +} + +func _fts5CursorParseRank(tls *libc.TLS, pConfig uintptr, pCsr uintptr, pRank uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc int32 + var z uintptr + var _ /* zRank at bp+0 */ uintptr + var _ /* zRankArgs at bp+8 */ uintptr + _, _ = rc, z + rc = SQLITE_OK + if pRank != 0 { + z = Xsqlite3_value_text(tls, pRank) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if z == uintptr(0) { + if Xsqlite3_value_type(tls, pRank) == int32(SQLITE_NULL) { + rc = int32(SQLITE_ERROR) + } + } else { + rc = _sqlite3Fts5ConfigParseRank(tls, z, bp, bp+8) + } + if rc == SQLITE_OK { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank = **(**uintptr)(__ccgo_up(bp)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = **(**uintptr)(__ccgo_up(bp + 8)) + **(**int32)(__ccgo_up(pCsr + 80)) |= int32(FTS5CSR_FREE_ZRANK) + } else { + if rc == int32(SQLITE_ERROR) { + (*Tsqlite3_vtab)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+40204, libc.VaList(bp+24, z)) + } + } + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank = (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = (*TFts5Config)(unsafe.Pointer(pConfig)).FzRankArgs + } else { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank = __ccgo_ts + 37706 + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = uintptr(0) + } + } + return rc +} + +// C documentation +// +// /* +// ** Execute the following SQL: +// ** +// ** DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast +// */ +func _fts5DataDelete(tls *libc.TLS, p uintptr, iFirst Ti64, iLast Ti64) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pConfig, zSql uintptr + _, _ = pConfig, zSql + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return + } + if (*TFts5Index)(unsafe.Pointer(p)).FpDeleter == uintptr(0) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+39319, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + if _fts5IndexPrepareStmt(tls, p, p+88, zSql) != 0 { + return + } + } + Xsqlite3_bind_int64(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter, int32(1), iFirst) + Xsqlite3_bind_int64(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter, int32(2), iLast) + Xsqlite3_step(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter) + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter) +} + +// C documentation +// +// /* +// ** Retrieve a record from the %_data table. +// ** +// ** If an error occurs, NULL is returned and an error left in the +// ** Fts5Index object. +// */ +func _fts5DataRead(tls *libc.TLS, p uintptr, iRowid Ti64) (r uintptr) { + var aOut, pBlob, pConfig, pRet, v1 uintptr + var nAlloc, nByte, szData Ti64 + var rc int32 + _, _, _, _, _, _, _, _, _ = aOut, nAlloc, nByte, pBlob, pConfig, pRet, rc, szData, v1 + pRet = uintptr(0) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rc = SQLITE_OK + if (*TFts5Index)(unsafe.Pointer(p)).FpReader != 0 { + /* This call may return SQLITE_ABORT if there has been a savepoint + ** rollback since it was last used. In this case a new blob handle + ** is required. */ + pBlob = (*TFts5Index)(unsafe.Pointer(p)).FpReader + (*TFts5Index)(unsafe.Pointer(p)).FpReader = uintptr(0) + rc = Xsqlite3_blob_reopen(tls, pBlob, iRowid) + (*TFts5Index)(unsafe.Pointer(p)).FpReader = pBlob + if rc != SQLITE_OK { + _fts5IndexCloseReader(tls, p) + } + if rc == int32(SQLITE_ABORT) { + rc = SQLITE_OK + } + } + /* If the blob handle is not open at this point, open it and seek + ** to the requested entry. */ + if (*TFts5Index)(unsafe.Pointer(p)).FpReader == uintptr(0) && rc == SQLITE_OK { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + rc = Xsqlite3_blob_open(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Index)(unsafe.Pointer(p)).FzDataTbl, __ccgo_ts+39262, iRowid, 0, p+72) + } + /* If either of the sqlite3_blob_open() or sqlite3_blob_reopen() calls + ** above returned SQLITE_ERROR, return SQLITE_CORRUPT_VTAB instead. + ** All the reasons those functions might return SQLITE_ERROR - missing + ** table, missing row, non-blob/text in block column - indicate + ** backing store corruption. */ + if rc == int32(SQLITE_ERROR) { + rc = _fts5IndexCorruptRowid(tls, p, iRowid) + } + if rc == SQLITE_OK { + aOut = uintptr(0) /* Read blob data into this buffer */ + nByte = int64(Xsqlite3_blob_bytes(tls, (*TFts5Index)(unsafe.Pointer(p)).FpReader)) + szData = libc.Int64FromUint64((libc.Uint64FromInt64(16) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + nAlloc = szData + nByte + int64(FTS5_DATA_PADDING) + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nAlloc)) + if pRet != 0 { + (*TFts5Data)(unsafe.Pointer(pRet)).Fnn = int32(nByte) + v1 = pRet + uintptr(szData) + (*TFts5Data)(unsafe.Pointer(pRet)).Fp = v1 + aOut = v1 + } else { + rc = int32(SQLITE_NOMEM) + } + if rc == SQLITE_OK { + rc = Xsqlite3_blob_read(tls, (*TFts5Index)(unsafe.Pointer(p)).FpReader, aOut, int32(nByte), 0) + } + if rc != SQLITE_OK { + Xsqlite3_free(tls, pRet) + pRet = uintptr(0) + } else { + /* TODO1: Fix this */ + **(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(nByte))) = uint8(0x00) + **(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(nByte+int64(1)))) = uint8(0x00) + (*TFts5Data)(unsafe.Pointer(pRet)).FszLeaf = libc.Int32FromUint16(_fts5GetU16(tls, (*TFts5Data)(unsafe.Pointer(pRet)).Fp+2)) + } + } + (*TFts5Index)(unsafe.Pointer(p)).Frc = rc + (*TFts5Index)(unsafe.Pointer(p)).FnRead = (*TFts5Index)(unsafe.Pointer(p)).FnRead + 1 + } + return pRet +} + +// C documentation +// +// /* +// ** Remove all records associated with segment iSegid. +// */ +func _fts5DataRemoveSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iFirst, iLast, iTomb1, iTomb2 Ti64 + var iSegid int32 + var pConfig uintptr + _, _, _, _, _, _ = iFirst, iLast, iSegid, iTomb1, iTomb2, pConfig + iSegid = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid + iFirst = int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= 0) { + break + } + pLvl = pIter + 8 + uintptr(i)*32 + for _fts5DlidxLvlNext(tls, pLvl) == 0 { + } + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof = 0 + if i > 0 { + pChild = pLvl + uintptr(-libc.Int32FromInt32(1))*32 + _fts5DataRelease(tls, (*TFts5DlidxLvl)(unsafe.Pointer(pChild)).FpData) + libc.X__builtin___memset_chk(tls, pChild, 0, uint64(32), ^t__predefined_size_t(0)) + (*TFts5DlidxLvl)(unsafe.Pointer(pChild)).FpData = _fts5DataRead(tls, p, int64((*TFts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(1))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(i-libc.Int32FromInt32(1))<iLeafOffset is the + ** offset of the first byte in the position-list for the entry to + ** remove. Immediately before this comes two varints that will also + ** need to be removed: + ** + ** + the rowid or delta rowid value for the entry, and + ** + the size of the position list in bytes. + ** + ** Or, in detail=none mode, there is a single varint prior to + ** pSeg->iLeafOffset - the rowid or delta rowid value. + ** + ** This block sets the following variables: + ** + ** iStart: + ** The offset of the first byte of the rowid or delta-rowid + ** value for the doclist entry being removed. + ** + ** iDelta: + ** The value of the rowid or delta-rowid value for the doclist + ** entry being removed. + ** + ** iNextOff: + ** The offset of the next entry following the position list + ** for the one being removed. If the position list for this + ** entry overflows onto the next leaf page, this value will be + ** greater than pLeaf->szLeaf. + */ + /* Start-Of-Position-list */ + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno { + iStart = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafOffset + } else { + iStart = libc.Int32FromUint16(_fts5GetU16(tls, aPg)) + } + if iStart > nPg { + _fts5IndexCorruptIdx(tls, p) + Xsqlite3_free(tls, aIdx) + return + } + iSOP = iStart + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iStart), bp)) + if bDetailNone != 0 { + for int64(iSOP) < (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aPg + uintptr(iSOP)))) == 0x00 { + iSOP = iSOP + 1 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aPg + uintptr(iSOP)))) == 0x00 { + iSOP = iSOP + 1 + } + iStart = iSOP + iSOP = iStart + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iStart), bp)) + } + iNextOff = iSOP + if iNextOff < (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aPg + uintptr(iNextOff)))) == 0x00 { + iNextOff = iNextOff + 1 + } + if iNextOff < (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aPg + uintptr(iNextOff)))) == 0x00 { + iNextOff = iNextOff + 1 + } + } else { + **(**int32)(__ccgo_up(bp + 12)) = 0 + iSOP = iSOP + _sqlite3Fts5GetVarint32(tls, aPg+uintptr(iSOP), bp+12) + for int64(iSOP) < (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset { + iStart = iSOP + **(**int32)(__ccgo_up(bp + 12))/int32(2) + iSOP = iStart + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iStart), bp)) + iSOP = iSOP + _sqlite3Fts5GetVarint32(tls, aPg+uintptr(iSOP), bp+12) + } + iNextOff = iSOP + (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos + } + iOff = iStart + /* If the position-list for the entry being removed flows over past + ** the end of this page, delete the portion of the position-list on the + ** next page and beyond. + ** + ** Set variable bLastInDoclist to true if this entry happens + ** to be the last rowid in the doclist for its term. */ + if iNextOff >= iPgIdx { + pgno = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno + int32(1) + _fts5SecureDeleteOverflow(tls, p, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg, pgno, bp+8) + iNextOff = iPgIdx + } + if libc.Int32FromUint8((*TFts5SegIter)(unsafe.Pointer(pSeg)).FbDel) == 0 { + if iNextOff != iPgIdx { + /* Loop through the page-footer. If iNextOff (offset of the + ** entry following the one we are removing) is equal to the + ** offset of a key on this page, then the entry is the last + ** in its doclist. */ + iKeyOff = 0 + iIdx = 0 + for { + if !(iIdx < nIdx) { + break + } + **(**Tu32)(__ccgo_up(bp + 16)) = uint32(0) + iIdx = iIdx + _sqlite3Fts5GetVarint32(tls, aIdx+uintptr(iIdx), bp+16) + iKeyOff = libc.Int32FromUint32(uint32(iKeyOff) + **(**Tu32)(__ccgo_up(bp + 16))) + if iKeyOff == iNextOff { + **(**int32)(__ccgo_up(bp + 8)) = int32(1) + } + goto _1 + _1: + } + } + /* If this is (a) the first rowid on a page and (b) is not followed by + ** another position list on the same page, set the "first-rowid" field + ** of the header to 0. */ + if libc.Int32FromUint16(_fts5GetU16(tls, aPg)) == iStart && (**(**int32)(__ccgo_up(bp + 8)) != 0 || iNextOff == iPgIdx) { + _fts5PutU16(tls, aPg, uint16(0)) + } + } + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FbDel != 0 { + iOff = iOff + _sqlite3Fts5PutVarint(tls, aPg+uintptr(iOff), **(**Tu64)(__ccgo_up(bp))) + v2 = iOff + iOff = iOff + 1 + **(**Tu8)(__ccgo_up(aPg + uintptr(v2))) = uint8(0x01) + } else { + if **(**int32)(__ccgo_up(bp + 8)) == 0 { + if iNextOff != iPgIdx { + **(**Tu64)(__ccgo_up(bp + 24)) = uint64(0) + iNextOff = iNextOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iNextOff), bp+24)) + iOff = iOff + _sqlite3Fts5PutVarint(tls, aPg+uintptr(iOff), **(**Tu64)(__ccgo_up(bp))+**(**Tu64)(__ccgo_up(bp + 24))) + } + } else { + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno && iStart == (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafOffset { + /* The entry being removed was the only position list in its + ** doclist. Therefore the term needs to be removed as well. */ + iKey = 0 + iKeyOff1 = 0 + /* Set iKeyOff to the offset of the term that will be removed - the + ** last offset in the footer that is not greater than iStart. */ + iIdx = 0 + for { + if !(iIdx < nIdx) { + break + } + **(**Tu32)(__ccgo_up(bp + 32)) = uint32(0) + iIdx = iIdx + _sqlite3Fts5GetVarint32(tls, aIdx+uintptr(iIdx), bp+32) + if libc.Uint32FromInt32(iKeyOff1)+**(**Tu32)(__ccgo_up(bp + 32)) > libc.Uint32FromInt32(iStart) { + break + } + iKeyOff1 = libc.Int32FromUint32(uint32(iKeyOff1) + **(**Tu32)(__ccgo_up(bp + 32))) + goto _3 + _3: + ; + iKey = iKey + 1 + } + /* Set iDelKeyOff to the value of the footer entry to remove from + ** the page. */ + v2 = iKeyOff1 + iOff = v2 + iDelKeyOff = v2 + if iNextOff != iPgIdx { + /* This is the only position-list associated with the term, and there + ** is another term following it on this page. So the subsequent term + ** needs to be moved to replace the term associated with the entry + ** being removed. */ + **(**Tu64)(__ccgo_up(bp + 40)) = uint64(0) + **(**Tu64)(__ccgo_up(bp + 48)) = uint64(0) + **(**Tu64)(__ccgo_up(bp + 56)) = uint64(0) + **(**Tu64)(__ccgo_up(bp + 64)) = uint64(0) + iDelKeyOff = iNextOff + iNextOff = iNextOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iNextOff), bp+56)) + iNextOff = iNextOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iNextOff), bp+64)) + if iKey != int32(1) { + iKeyOff1 = iKeyOff1 + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iKeyOff1), bp+40)) + } + iKeyOff1 = iKeyOff1 + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iKeyOff1), bp+48)) + if **(**Tu64)(__ccgo_up(bp + 40)) < **(**Tu64)(__ccgo_up(bp + 56)) { + v5 = **(**Tu64)(__ccgo_up(bp + 40)) + } else { + v5 = **(**Tu64)(__ccgo_up(bp + 56)) + } + **(**Tu64)(__ccgo_up(bp + 40)) = v5 + **(**Tu64)(__ccgo_up(bp + 48)) = **(**Tu64)(__ccgo_up(bp + 56)) + **(**Tu64)(__ccgo_up(bp + 64)) - **(**Tu64)(__ccgo_up(bp + 40)) + if libc.Uint64FromInt32(iKeyOff1)+**(**Tu64)(__ccgo_up(bp + 48)) > libc.Uint64FromInt32(iPgIdx) || libc.Uint64FromInt32(iNextOff)+**(**Tu64)(__ccgo_up(bp + 64)) > libc.Uint64FromInt32(iPgIdx) { + _fts5IndexCorruptIdx(tls, p) + } else { + if iKey != int32(1) { + iOff = iOff + _sqlite3Fts5PutVarint(tls, aPg+uintptr(iOff), **(**Tu64)(__ccgo_up(bp + 40))) + } + iOff = iOff + _sqlite3Fts5PutVarint(tls, aPg+uintptr(iOff), **(**Tu64)(__ccgo_up(bp + 48))) + if **(**Tu64)(__ccgo_up(bp + 56)) > libc.Uint64FromInt32((*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn) { + _fts5IndexCorruptIdx(tls, p) + } else { + if **(**Tu64)(__ccgo_up(bp + 56)) > **(**Tu64)(__ccgo_up(bp + 40)) { + libc.X__builtin___memcpy_chk(tls, aPg+uintptr(iOff), (*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp+uintptr(**(**Tu64)(__ccgo_up(bp + 40))), uint64(**(**Tu64)(__ccgo_up(bp + 56))-**(**Tu64)(__ccgo_up(bp + 40))), ^t__predefined_size_t(0)) + iOff = libc.Int32FromUint64(uint64(iOff) + (**(**Tu64)(__ccgo_up(bp + 56)) - **(**Tu64)(__ccgo_up(bp + 40)))) + } + } + libc.X__builtin___memmove_chk(tls, aPg+uintptr(iOff), aPg+uintptr(iNextOff), uint64(**(**Tu64)(__ccgo_up(bp + 64))), ^t__predefined_size_t(0)) + iOff = libc.Int32FromUint64(uint64(iOff) + **(**Tu64)(__ccgo_up(bp + 64))) + iNextOff = libc.Int32FromUint64(uint64(iNextOff) + **(**Tu64)(__ccgo_up(bp + 64))) + } + } + } else { + if iStart == int32(4) { + /* The entry being removed may be the only position list in + ** its doclist. */ + iPgno = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno - int32(1) + for { + if !(iPgno > (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno) { + break + } + pPg = _fts5DataRead(tls, p, int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))<= nTermIdx { + break + } + iTermIdx = iTermIdx + nByte + } + nTermIdx = iTermIdx + if iTermOff > int64((*TFts5Data)(unsafe.Pointer(pTerm)).FszLeaf) { + _fts5IndexCorruptIdx(tls, p) + } else { + libc.X__builtin___memmove_chk(tls, (*TFts5Data)(unsafe.Pointer(pTerm)).Fp+uintptr(iTermOff), (*TFts5Data)(unsafe.Pointer(pTerm)).Fp+uintptr((*TFts5Data)(unsafe.Pointer(pTerm)).FszLeaf), libc.Uint64FromInt32(nTermIdx), ^t__predefined_size_t(0)) + _fts5PutU16(tls, (*TFts5Data)(unsafe.Pointer(pTerm)).Fp+2, libc.Uint16FromInt64(iTermOff)) + _fts5DataWrite(tls, p, iId, (*TFts5Data)(unsafe.Pointer(pTerm)).Fp, int32(iTermOff+int64(nTermIdx))) + if nTermIdx == 0 { + _fts5SecureDeleteIdxEntry(tls, p, iSegid, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno) + } + } + } + _fts5DataRelease(tls, pTerm) + } + } + } + } + } + /* Assuming no error has occurred, this block does final edits to the + ** leaf page before writing it back to disk. Input variables are: + ** + ** nPg: Total initial size of leaf page. + ** iPgIdx: Initial offset of page footer. + ** + ** iOff: Offset to move data to + ** iNextOff: Offset to move data from + */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + nMove = nPg - iNextOff /* Number of bytes to move */ + nShift = iNextOff - iOff /* Distance to move them */ + iPrevKeyOut = 0 + iKeyIn = 0 + if nMove > 0 { + libc.X__builtin___memmove_chk(tls, aPg+uintptr(iOff), aPg+uintptr(iNextOff), libc.Uint64FromInt32(nMove), ^t__predefined_size_t(0)) + } + iPgIdx = iPgIdx - nShift + nPg = iPgIdx + _fts5PutU16(tls, aPg+2, libc.Uint16FromInt32(iPgIdx)) + iIdx = 0 + for { + if !(iIdx < nIdx) { + break + } + **(**Tu32)(__ccgo_up(bp + 76)) = uint32(0) + iIdx = iIdx + _sqlite3Fts5GetVarint32(tls, aIdx+uintptr(iIdx), bp+76) + iKeyIn = libc.Int32FromUint32(uint32(iKeyIn) + **(**Tu32)(__ccgo_up(bp + 76))) + if iKeyIn != iDelKeyOff { + if iKeyIn > iOff { + v2 = nShift + } else { + v2 = 0 + } + iKeyOut = iKeyIn - v2 + nPg = nPg + _sqlite3Fts5PutVarint(tls, aPg+uintptr(nPg), libc.Uint64FromInt32(iKeyOut-iPrevKeyOut)) + iPrevKeyOut = iKeyOut + } + goto _7 + _7: + } + if iPgIdx == nPg && nIdx > 0 && (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno != int32(1) { + _fts5SecureDeleteIdxEntry(tls, p, iSegid, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno) + } + _fts5DataWrite(tls, p, int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))< 0 { + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaEof = (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn) + _fts5DoclistIterNext(tls, pIter) + } +} + +// C documentation +// +// /* +// ** Add pSub as a child of p. +// */ +func _fts5ExprAddChildren(tls *libc.TLS, p uintptr, pSub uintptr) { + var ii, nByte, v1 int32 + var v2 uintptr + _, _, _, _ = ii, nByte, v1, v2 + ii = (*TFts5ExprNode)(unsafe.Pointer(p)).FnChild + if (*TFts5ExprNode)(unsafe.Pointer(p)).FeType != int32(FTS5_NOT) && (*TFts5ExprNode)(unsafe.Pointer(pSub)).FeType == (*TFts5ExprNode)(unsafe.Pointer(p)).FeType { + nByte = libc.Int32FromUint64(uint64(8) * libc.Uint64FromInt32((*TFts5ExprNode)(unsafe.Pointer(pSub)).FnChild)) + libc.X__builtin___memcpy_chk(tls, p+48+uintptr((*TFts5ExprNode)(unsafe.Pointer(p)).FnChild)*8, pSub+48, libc.Uint64FromInt32(nByte), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(p + 40)) += (*TFts5ExprNode)(unsafe.Pointer(pSub)).FnChild + Xsqlite3_free(tls, pSub) + } else { + v2 = p + 40 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + *(*uintptr)(unsafe.Pointer(p + 48 + uintptr(v1)*8)) = pSub + } + for { + if !(ii < (*TFts5ExprNode)(unsafe.Pointer(p)).FnChild) { + break + } + if (*TFts5ExprNode)(unsafe.Pointer(p)).FiHeight > (*TFts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 48 + uintptr(ii)*8)))).FiHeight+int32(1) { + v1 = (*TFts5ExprNode)(unsafe.Pointer(p)).FiHeight + } else { + v1 = (*TFts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 48 + uintptr(ii)*8)))).FiHeight + int32(1) + } + (*TFts5ExprNode)(unsafe.Pointer(p)).FiHeight = v1 + goto _3 + _3: + ; + ii = ii + 1 + } +} + +// C documentation +// +// /* +// ** Read the first token from the nul-terminated string at *pz. +// */ +func _fts5ExprGetToken(tls *libc.TLS, pParse uintptr, pz uintptr, pToken uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var tok int32 + var z, z2, z21 uintptr + _, _, _, _ = tok, z, z2, z21 + z = **(**uintptr)(__ccgo_up(pz)) + /* Skip past any whitespace */ + for _fts5ExprIsspace(tls, **(**int8)(__ccgo_up(z))) != 0 { + z = z + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fp = z + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(1) + switch int32(**(**int8)(__ccgo_up(z))) { + case int32('('): + tok = int32(FTS5_LP) + case int32(')'): + tok = int32(FTS5_RP) + case int32('{'): + tok = int32(FTS5_LCP) + case int32('}'): + tok = int32(FTS5_RCP) + case int32(':'): + tok = int32(FTS5_COLON) + case int32(','): + tok = int32(FTS5_COMMA) + case int32('+'): + tok = int32(FTS5_PLUS) + case int32('*'): + tok = int32(FTS5_STAR) + case int32('-'): + tok = int32(FTS5_MINUS) + case int32('^'): + tok = int32(FTS5_CARET) + case int32('\000'): + tok = FTS5_EOF + case int32('"'): + tok = int32(FTS5_STRING) + z2 = z + 1 + for { + if !(int32(1) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(z2))) == int32('"') { + z2 = z2 + 1 + if int32(**(**int8)(__ccgo_up(z2))) != int32('"') { + break + } + } + if int32(**(**int8)(__ccgo_up(z2))) == int32('\000') { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38867, 0) + return FTS5_EOF + } + goto _1 + _1: + ; + z2 = z2 + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(int64(z2) - int64(z)) + default: + if _sqlite3Fts5IsBareword(tls, **(**int8)(__ccgo_up(z))) == 0 { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38887, libc.VaList(bp+8, z)) + return FTS5_EOF + } + tok = int32(FTS5_STRING) + z21 = z + 1 + for { + if !(_sqlite3Fts5IsBareword(tls, **(**int8)(__ccgo_up(z21))) != 0) { + break + } + goto _2 + _2: + ; + z21 = z21 + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(int64(z21) - int64(z)) + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(2) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+38918, uint64(2)) == 0 { + tok = int32(FTS5_OR) + } + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(3) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+38921, uint64(3)) == 0 { + tok = int32(FTS5_NOT) + } + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(3) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+32730, uint64(3)) == 0 { + tok = int32(FTS5_AND) + } + break + } + **(**uintptr)(__ccgo_up(pz)) = (*TFts5Token)(unsafe.Pointer(pToken)).Fp + uintptr((*TFts5Token)(unsafe.Pointer(pToken)).Fn) + return tok +} + +// C documentation +// +// /* +// ** The near-set object passed as the first argument contains more than +// ** one phrase. All phrases currently point to the same row. The +// ** Fts5ExprPhrase.poslist buffers are populated accordingly. This function +// ** tests if the current row contains instances of each phrase sufficiently +// ** close together to meet the NEAR constraint. Non-zero is returned if it +// ** does, or zero otherwise. +// ** +// ** If in/out parameter (*pRc) is set to other than SQLITE_OK when this +// ** function is called, it is a no-op. Or, if an error (e.g. SQLITE_NOMEM) +// ** occurs within this function (*pRc) is set accordingly before returning. +// ** The return value is undefined in both these cases. +// ** +// ** If no error occurs and non-zero (a match) is returned, the position-list +// ** of each phrase object is edited to contain only those entries that +// ** meet the constraint before returning. +// */ +func _fts5ExprNearIsMatch(tls *libc.TLS, pRc uintptr, pNear uintptr) (r int32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var a, apPhrase, pPos, pPoslist, pWriter uintptr + var bMatch, bRet, i, iAdv int32 + var iMax, iMin, iPos Ti64 + var nByte Tsqlite3_int64 + var _ /* aStatic at bp+0 */ [4]TFts5NearTrimmer + var _ /* rc at bp+192 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = a, apPhrase, bMatch, bRet, i, iAdv, iMax, iMin, iPos, nByte, pPos, pPoslist, pWriter + a = bp + apPhrase = pNear + 24 + **(**int32)(__ccgo_up(bp + 192)) = **(**int32)(__ccgo_up(pRc)) + /* If the aStatic[] array is not large enough, allocate a large array + ** using sqlite3_malloc(). This approach could be improved upon. */ + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase > libc.Int32FromUint64(libc.Uint64FromInt64(192)/libc.Uint64FromInt64(48)) { + nByte = libc.Int64FromUint64(uint64(48) * libc.Uint64FromInt32((*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase)) + a = _sqlite3Fts5MallocZero(tls, bp+192, nByte) + } else { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(192), ^t__predefined_size_t(0)) + } + if **(**int32)(__ccgo_up(bp + 192)) != SQLITE_OK { + **(**int32)(__ccgo_up(pRc)) = **(**int32)(__ccgo_up(bp + 192)) + return 0 + } + /* Initialize a lookahead iterator for each phrase. After passing the + ** buffer and buffer size to the lookaside-reader init function, zero + ** the phrase poslist buffer. The new poslist for the phrase (containing + ** the same entries as the original with some entries removed on account + ** of the NEAR constraint) is written over the original even as it is + ** being read. This is safe as the entries for the new poslist are a + ** subset of the old, so it is not possible for data yet to be read to + ** be overwritten. */ + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + pPoslist = **(**uintptr)(__ccgo_up(apPhrase + uintptr(i)*8)) + 8 + _fts5LookaheadReaderInit(tls, (*TFts5Buffer)(unsafe.Pointer(pPoslist)).Fp, (*TFts5Buffer)(unsafe.Pointer(pPoslist)).Fn, a+uintptr(i)*48) + (*TFts5Buffer)(unsafe.Pointer(pPoslist)).Fn = 0 + (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).FpOut = pPoslist + goto _1 + _1: + ; + i = i + 1 + } + for int32(1) != 0 { + /* This block advances the phrase iterators until they point to a set of + ** entries that together comprise a match. */ + iMax = (**(**TFts5NearTrimmer)(__ccgo_up(a))).Freader.FiPos + for cond := true; cond; cond = bMatch == 0 { + bMatch = int32(1) + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + pPos = a + uintptr(i)*48 + iMin = iMax - int64((*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(i)*8)))).FnTerm) - int64((*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnNear) + if (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos < iMin || (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos > iMax { + bMatch = 0 + for (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos < iMin { + if _fts5LookaheadReaderNext(tls, pPos) != 0 { + goto ismatch_out + } + } + if (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos > iMax { + iMax = (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + /* Add an entry to each output position list */ + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + iPos = (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).Freader.FiPos + pWriter = a + uintptr(i)*48 + 32 + if (*TFts5Buffer)(unsafe.Pointer((**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).FpOut)).Fn == 0 || iPos != (*TFts5PoslistWriter)(unsafe.Pointer(pWriter)).FiPrev { + _sqlite3Fts5PoslistWriterAppend(tls, (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).FpOut, pWriter, iPos) + } + goto _3 + _3: + ; + i = i + 1 + } + iAdv = 0 + iMin = (**(**TFts5NearTrimmer)(__ccgo_up(a))).Freader.FiLookahead + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + if (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).Freader.FiLookahead < iMin { + iMin = (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).Freader.FiLookahead + iAdv = i + } + goto _4 + _4: + ; + i = i + 1 + } + if _fts5LookaheadReaderNext(tls, a+uintptr(iAdv)*48) != 0 { + goto ismatch_out + } + } + goto ismatch_out +ismatch_out: + ; + bRet = libc.BoolInt32((*TFts5Buffer)(unsafe.Pointer((**(**TFts5NearTrimmer)(__ccgo_up(a))).FpOut)).Fn > 0) + **(**int32)(__ccgo_up(pRc)) = **(**int32)(__ccgo_up(bp + 192)) + if a != bp { + Xsqlite3_free(tls, a) + } + return bRet + return r +} + +// C documentation +// +// /* +// ** All individual term iterators in pPhrase are guaranteed to be valid and +// ** pointing to the same rowid when this function is called. This function +// ** checks if the current rowid really is a match, and if so populates +// ** the pPhrase->poslist buffer accordingly. Output parameter *pbMatch +// ** is set to true if this is really a match, or false otherwise. +// ** +// ** SQLITE_OK is returned if an error occurs, or an SQLite error code +// ** otherwise. It is not considered an error code if the current rowid is +// ** not a match. +// */ +func _fts5ExprPhraseIsMatch(tls *libc.TLS, pNode uintptr, pPhrase uintptr, pbMatch uintptr) (r int32) { + bp := tls.Alloc(176) + defer tls.Free(176) + var aIter, pPos, pTerm uintptr + var bFirst, bFlag, bMatch, i, rc int32 + var iAdj, iPos Ti64 + var nByte Tsqlite3_int64 + var _ /* a at bp+144 */ uintptr + var _ /* aStatic at bp+8 */ [4]TFts5PoslistReader + var _ /* buf at bp+152 */ TFts5Buffer + var _ /* n at bp+136 */ int32 + var _ /* writer at bp+0 */ TFts5PoslistWriter + _, _, _, _, _, _, _, _, _, _, _ = aIter, bFirst, bFlag, bMatch, i, iAdj, iPos, nByte, pPos, pTerm, rc + **(**TFts5PoslistWriter)(__ccgo_up(bp)) = TFts5PoslistWriter{} + aIter = bp + 8 + rc = SQLITE_OK + bFirst = libc.Int32FromUint8((*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32))).FbFirst) + _sqlite3Fts5BufferZero(tls, pPhrase+8) + /* If the aStatic[] array is not large enough, allocate a large array + ** using sqlite3_malloc(). This approach could be improved upon. */ + if (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > libc.Int32FromUint64(libc.Uint64FromInt64(128)/libc.Uint64FromInt64(32)) { + nByte = libc.Int64FromUint64(uint64(32) * libc.Uint64FromInt32((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm)) + aIter = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if !(aIter != 0) { + return int32(SQLITE_NOMEM) + } + } + libc.X__builtin___memset_chk(tls, aIter, 0, uint64(32)*libc.Uint64FromInt32((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm), ^t__predefined_size_t(0)) + /* Initialize a term iterator for each term in the phrase */ + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + pTerm = pPhrase + 32 + uintptr(i)*40 + **(**int32)(__ccgo_up(bp + 136)) = 0 + bFlag = 0 + **(**uintptr)(__ccgo_up(bp + 144)) = uintptr(0) + if (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { + **(**TFts5Buffer)(__ccgo_up(bp + 152)) = TFts5Buffer{} + rc = _fts5ExprSynonymList(tls, pTerm, (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid, bp+152, bp+144, bp+136) + if rc != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 144))) + goto ismatch_out + } + if **(**uintptr)(__ccgo_up(bp + 144)) == (**(**TFts5Buffer)(__ccgo_up(bp + 152))).Fp { + bFlag = int32(1) + } + } else { + **(**uintptr)(__ccgo_up(bp + 144)) = (*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter)).FpData + **(**int32)(__ccgo_up(bp + 136)) = (*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter)).FnData + } + _sqlite3Fts5PoslistReaderInit(tls, **(**uintptr)(__ccgo_up(bp + 144)), **(**int32)(__ccgo_up(bp + 136)), aIter+uintptr(i)*32) + (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).FbFlag = libc.Uint8FromInt32(bFlag) + if (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).FbEof != 0 { + goto ismatch_out + } + goto _1 + _1: + ; + i = i + 1 + } + for int32(1) != 0 { + iPos = (**(**TFts5PoslistReader)(__ccgo_up(aIter))).FiPos + for cond := true; cond; cond = bMatch == 0 { + bMatch = int32(1) + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + pPos = aIter + uintptr(i)*32 + iAdj = iPos + int64(i) + if (*TFts5PoslistReader)(unsafe.Pointer(pPos)).FiPos != iAdj { + bMatch = 0 + for (*TFts5PoslistReader)(unsafe.Pointer(pPos)).FiPos < iAdj { + if _sqlite3Fts5PoslistReaderNext(tls, pPos) != 0 { + goto ismatch_out + } + } + if (*TFts5PoslistReader)(unsafe.Pointer(pPos)).FiPos > iAdj { + iPos = (*TFts5PoslistReader)(unsafe.Pointer(pPos)).FiPos - int64(i) + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + /* Append position iPos to the output */ + if bFirst == 0 || int32(iPos&libc.Int64FromInt32(0x7FFFFFFF)) == 0 { + rc = _sqlite3Fts5PoslistWriterAppend(tls, pPhrase+8, bp, iPos) + if rc != SQLITE_OK { + goto ismatch_out + } + } + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + if _sqlite3Fts5PoslistReaderNext(tls, aIter+uintptr(i)*32) != 0 { + goto ismatch_out + } + goto _3 + _3: + ; + i = i + 1 + } + } + goto ismatch_out +ismatch_out: + ; + **(**int32)(__ccgo_up(pbMatch)) = libc.BoolInt32((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn > 0) + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + if (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).FbFlag != 0 { + Xsqlite3_free(tls, (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).Fa) + } + goto _4 + _4: + ; + i = i + 1 + } + if aIter != bp+8 { + Xsqlite3_free(tls, aIter) + } + return rc +} + +// C documentation +// +// /* +// ** Argument pTerm must be a synonym iterator. +// */ +func _fts5ExprSynonymList(tls *libc.TLS, pTerm uintptr, iRowid Ti64, pBuf uintptr, pa uintptr, pn uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var aIter, aNew, p, pIter uintptr + var i, nAlloc, nIter, rc int32 + var iMin, iPrev Ti64 + var nByte Tsqlite3_int64 + var _ /* aStatic at bp+0 */ [4]TFts5PoslistReader + var _ /* writer at bp+128 */ TFts5PoslistWriter + _, _, _, _, _, _, _, _, _, _, _ = aIter, aNew, i, iMin, iPrev, nAlloc, nByte, nIter, p, pIter, rc + aIter = bp + nIter = 0 + nAlloc = int32(4) + rc = SQLITE_OK + p = pTerm + for { + if !(p != 0) { + break + } + pIter = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter + if libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer(pIter)).FbEof) == 0 && (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == iRowid { + if (*TFts5IndexIter)(unsafe.Pointer(pIter)).FnData == 0 { + goto _1 + } + if nIter == nAlloc { + nByte = libc.Int64FromUint64(uint64(32) * libc.Uint64FromInt32(nAlloc) * uint64(2)) + aNew = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if aNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto synonym_poslist_out + } + libc.X__builtin___memcpy_chk(tls, aNew, aIter, uint64(32)*libc.Uint64FromInt32(nIter), ^t__predefined_size_t(0)) + nAlloc = nAlloc * int32(2) + if aIter != bp { + Xsqlite3_free(tls, aIter) + } + aIter = aNew + } + _sqlite3Fts5PoslistReaderInit(tls, (*TFts5IndexIter)(unsafe.Pointer(pIter)).FpData, (*TFts5IndexIter)(unsafe.Pointer(pIter)).FnData, aIter+uintptr(nIter)*32) + nIter = nIter + 1 + } + goto _1 + _1: + ; + p = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpSynonym + } + if nIter == int32(1) { + **(**uintptr)(__ccgo_up(pa)) = (**(**TFts5PoslistReader)(__ccgo_up(aIter))).Fa + **(**int32)(__ccgo_up(pn)) = (**(**TFts5PoslistReader)(__ccgo_up(aIter))).Fn + } else { + **(**TFts5PoslistWriter)(__ccgo_up(bp + 128)) = TFts5PoslistWriter{} + iPrev = int64(-int32(1)) + _sqlite3Fts5BufferZero(tls, pBuf) + for int32(1) != 0 { + iMin = libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)<= int32('0') && int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) <= int32('9') { + iCol = iCol*int32(10) + (int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) - int32('0')) + iIdxStr = iIdxStr + 1 + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) == int32('*') { + /* The user has issued a query of the form "MATCH '*...'". This + ** indicates that the MATCH expression is not a full text query, + ** but a request for an internal parameter. */ + rc = _fts5SpecialMatch(tls, pTab, pCsr, **(**uintptr)(__ccgo_up(bp + 8))+1) + bInternal = int32(1) + } else { + pzErr = pTab + 16 + rc = _sqlite3Fts5ExprNew(tls, pConfig, 0, iCol, **(**uintptr)(__ccgo_up(bp + 8)), bp, pzErr) + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprAnd(tls, pCsr+64, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + if **(**int32)(__ccgo_up(bp + 16)) != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + _sqlite3Fts5ClearLocale(tls, pConfig) + } + if bInternal != 0 || rc != SQLITE_OK { + goto filter_out + } + case int32('L'): + fallthrough + case int32('G'): + bGlob = libc.BoolInt32(int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr-int32(1))))) == int32('G')) + zText1 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8))) + iCol = 0 + for cond := true; cond; cond = int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) >= int32('0') && int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) <= int32('9') { + iCol = iCol*int32(10) + (int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) - int32('0')) + iIdxStr = iIdxStr + 1 + } + if zText1 != 0 { + rc = _sqlite3Fts5ExprPattern(tls, pConfig, bGlob, iCol, zText1, bp) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprAnd(tls, pCsr+64, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + if rc != SQLITE_OK { + goto filter_out + } + case int32('='): + pRowidEq = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + case int32('<'): + pRowidLe = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + default: + pRowidGe = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + break + } + goto _1 + _1: + ; + i = i + 1 + } + if idxNum&int32(FTS5_BI_ORDER_RANK) != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + bOrderByRank = v2 + if idxNum&int32(FTS5_BI_ORDER_DESC) != 0 { + v3 = int32(1) + } else { + v3 = 0 + } + v2 = v3 + bDesc = v2 + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FbDesc = v2 + /* Set the cursor upper and lower rowid limits. Only some strategies + ** actually use them. This is ok, as the xBestIndex() method leaves the + ** sqlite3_index_constraint.omit flag clear for range constraints + ** on the rowid field. */ + if pRowidEq != 0 { + v6 = pRowidEq + pRowidGe = v6 + pRowidLe = v6 + } + if bDesc != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = _fts5GetRowidLimit(tls, pRowidLe, libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< ORDER BY rank" query (ePlan is + ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will + ** return results to the user for this query. The current cursor + ** (pCursor) is used to execute the query issued by function + ** fts5CursorFirstSorted() above. */ + if (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FbDesc != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiLastRowid + } else { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiLastRowid + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SOURCE) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FpExpr + rc = _fts5CursorFirst(tls, pTab, pCsr, bDesc) + } else { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr != 0 { + rc = _fts5CursorParseRank(tls, pConfig, pCsr, pRank) + if rc == SQLITE_OK { + if bOrderByRank != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SORTED_MATCH) + rc = _fts5CursorFirstSorted(tls, pTab, pCsr, bDesc) + } else { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_MATCH) + rc = _fts5CursorFirst(tls, pTab, pCsr, bDesc) + } + } + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FzContent == uintptr(0) { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40237, libc.VaList(bp+32, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + rc = int32(SQLITE_ERROR) + } else { + /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup + ** by rowid (ePlan==FTS5_PLAN_ROWID). */ + if pRowidEq != 0 { + v2 = int32(FTS5_PLAN_ROWID) + } else { + v2 = int32(FTS5_PLAN_SCAN) + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = v2 + rc = _sqlite3Fts5StorageStmt(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, _fts5StmtType(tls, pCsr), pCsr+56, pTab+16) + if rc == SQLITE_OK { + if pRowidEq != uintptr(0) { + Xsqlite3_bind_value(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1), pRowidEq) + } else { + Xsqlite3_bind_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1), (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid) + Xsqlite3_bind_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(2), (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid) + } + rc = _fts5NextMethod(tls, pCursor) + } + } + } + } + goto filter_out +filter_out: + ; + _sqlite3Fts5ExprFree(tls, **(**uintptr)(__ccgo_up(bp))) + (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = pzErrmsg + (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken = bPrefixInsttoken + return rc +} + +func _fts5FindRankFunction(tls *libc.TLS, pCsr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var nByte Tsqlite3_int64 + var pAux, pConfig, pTab, zRank, zRankArgs, zSql uintptr + var _ /* pStmt at bp+8 */ uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _ = i, nByte, pAux, pConfig, pTab, zRank, zRankArgs, zSql + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + pAux = uintptr(0) + zRank = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank + zRankArgs = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs + if zRankArgs != 0 { + zSql = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+40173, libc.VaList(bp+24, zRankArgs)) + if zSql != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp)) = Xsqlite3_prepare_v3(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -int32(1), uint32(SQLITE_PREPARE_PERSISTENT), bp+8, uintptr(0)) + Xsqlite3_free(tls, zSql) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg = Xsqlite3_column_count(tls, **(**uintptr)(__ccgo_up(bp + 8))) + nByte = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt32((*TFts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg = _sqlite3Fts5MallocZero(tls, bp, nByte) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + i = 0 + for { + if !(i < (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg) { + break + } + **(**uintptr)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg + uintptr(i)*8)) = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) + goto _1 + _1: + ; + i = i + 1 + } + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpRankArgStmt = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + } + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + pAux = _fts5FindAuxiliary(tls, pTab, zRank) + if pAux == uintptr(0) { + (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+40183, libc.VaList(bp+24, zRank)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpRank = pAux + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Find a tokenizer. This is the implementation of the +// ** fts5_api.xFindTokenizer() method. +// */ +func _fts5FindTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, ppUserData uintptr, pTokenizer uintptr) (r int32) { + var pMod uintptr + var rc int32 + _, _ = pMod, rc + rc = SQLITE_OK + pMod = _fts5LocateTokenizer(tls, pApi, zName) + if pMod != 0 { + if (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FbV2Native == 0 { + **(**uintptr)(__ccgo_up(ppUserData)) = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData + } else { + **(**uintptr)(__ccgo_up(ppUserData)) = pMod + } + **(**Tfts5_tokenizer)(__ccgo_up(pTokenizer)) = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx1 + } else { + libc.X__builtin___memset_chk(tls, pTokenizer, 0, uint64(24), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(ppUserData)) = uintptr(0) + rc = int32(SQLITE_ERROR) + } + return rc +} + +// C documentation +// +// /* +// ** Flush the contents of in-memory hash table iHash to a new level-0 +// ** segment on disk. Also update the corresponding structure record. +// ** +// ** If an error occurs, set the Fts5Index.rc error code. If an error has +// ** already occurred, this function is a no-op. +// */ +func _fts5FlushOneHash(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(192) + defer tls.Free(192) + var bSecureDelete, bTermWritten, eDetail, iOff, iPos, iSegid, n, nCopy, nSpace, pgsz, v1 int32 + var iPrev, iRowid Ti64 + var iRowidDelta Tu64 + var pBuf, pHash, pPgidx, pPoslist, pSeg, v2 uintptr + var _ /* bDel at bp+176 */ int32 + var _ /* iDelta at bp+168 */ Tu64 + var _ /* nDoclist at bp+160 */ int32 + var _ /* nPos at bp+180 */ int32 + var _ /* nTerm at bp+144 */ int32 + var _ /* pDoclist at bp+152 */ uintptr + var _ /* pStruct at bp+0 */ uintptr + var _ /* pgnoLast at bp+8 */ int32 + var _ /* writer at bp+16 */ TFts5SegWriter + var _ /* zTerm at bp+136 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bSecureDelete, bTermWritten, eDetail, iOff, iPos, iPrev, iRowid, iRowidDelta, iSegid, n, nCopy, nSpace, pBuf, pHash, pPgidx, pPoslist, pSeg, pgsz, v1, v2 + pHash = (*TFts5Index)(unsafe.Pointer(p)).FpHash + **(**int32)(__ccgo_up(bp + 8)) = 0 /* Last leaf page number in segment */ + /* Obtain a reference to the index structure and allocate a new segment-id + ** for the new level-0 segment. */ + **(**uintptr)(__ccgo_up(bp)) = _fts5StructureRead(tls, p) + _fts5StructureInvalidate(tls, p) + if _sqlite3Fts5HashIsEmpty(tls, pHash) == 0 { + iSegid = _fts5AllocateSegid(tls, p, **(**uintptr)(__ccgo_up(bp))) + if iSegid != 0 { + pgsz = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail + bSecureDelete = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FbSecureDelete + _fts5WriteInit(tls, p, bp+16, iSegid) + pBuf = bp + 16 + 8 + 8 + pPgidx = bp + 16 + 8 + 24 + /* fts5WriteInit() should have initialized the buffers to (most likely) + ** the maximum space required. */ + /* Begin scanning through hash table entries. This loop runs once for each + ** term/doclist currently stored within the hash table. */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*TFts5Index)(unsafe.Pointer(p)).Frc = _sqlite3Fts5HashScanInit(tls, pHash, uintptr(0), 0) + } + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && 0 == _sqlite3Fts5HashScanEof(tls, pHash) { /* Size of doclist in bytes */ + /* Get the term and doclist for this entry. */ + _sqlite3Fts5HashScanEntry(tls, pHash, bp+136, bp+144, bp+152, bp+160) + if bSecureDelete == 0 { + _fts5WriteAppendTerm(tls, p, bp+16, **(**int32)(__ccgo_up(bp + 144)), **(**uintptr)(__ccgo_up(bp + 136))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { + break + } + } + if !(bSecureDelete != 0) && pgsz >= (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn+**(**int32)(__ccgo_up(bp + 160))+int32(1) { + /* The entire doclist will fit on the current leaf. */ + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), **(**uintptr)(__ccgo_up(bp + 152)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 160))), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pBuf + 8)) += **(**int32)(__ccgo_up(bp + 160)) + } else { + bTermWritten = libc.BoolInt32(!(bSecureDelete != 0)) + iRowid = 0 + iPrev = 0 + iOff = 0 + /* The entire doclist will not fit on this leaf. The following + ** loop iterates through the poslists that make up the current + ** doclist. */ + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && iOff < **(**int32)(__ccgo_up(bp + 160)) { + **(**Tu64)(__ccgo_up(bp + 168)) = uint64(0) + iOff = iOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, **(**uintptr)(__ccgo_up(bp + 152))+uintptr(iOff), bp+168)) + iRowid = libc.Int64FromUint64(uint64(iRowid) + **(**Tu64)(__ccgo_up(bp + 168))) + /* If in secure delete mode, and if this entry in the poslist is + ** in fact a delete, then edit the existing segments directly + ** using fts5FlushSecureDelete(). */ + if bSecureDelete != 0 { + if eDetail == int32(FTS5_DETAIL_NONE) { + if iOff < **(**int32)(__ccgo_up(bp + 160)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == 0x00 && !(_fts5FlushSecureDelete(tls, p, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 136)), **(**int32)(__ccgo_up(bp + 144)), iRowid) != 0) { + iOff = iOff + 1 + if iOff < **(**int32)(__ccgo_up(bp + 160)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == 0x00 { + iOff = iOff + 1 + **(**int32)(__ccgo_up(bp + 160)) = 0 + } else { + continue + } + } + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff))))&int32(0x01) != 0 && !(_fts5FlushSecureDelete(tls, p, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 136)), **(**int32)(__ccgo_up(bp + 144)), iRowid) != 0) { + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == int32(0x01) { + iOff = iOff + 1 + continue + } + } + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bTermWritten == 0 { + _fts5WriteAppendTerm(tls, p, bp+16, **(**int32)(__ccgo_up(bp + 144)), **(**uintptr)(__ccgo_up(bp + 136))) + bTermWritten = int32(1) + } + if (**(**TFts5SegWriter)(__ccgo_up(bp + 16))).FbFirstRowidInPage != 0 { + _fts5PutU16(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp, libc.Uint16FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)) /* first rowid on page */ + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), libc.Uint64FromInt64(iRowid)) + (**(**TFts5SegWriter)(__ccgo_up(bp + 16))).FbFirstRowidInPage = uint8(0) + _fts5WriteDlidxAppend(tls, p, bp+16, iRowid) + } else { + iRowidDelta = libc.Uint64FromInt64(iRowid) - libc.Uint64FromInt64(iPrev) + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), iRowidDelta) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { + break + } + iPrev = iRowid + if eDetail == int32(FTS5_DETAIL_NONE) { + if iOff < **(**int32)(__ccgo_up(bp + 160)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == 0 { + v2 = pBuf + 8 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(v1))) = uint8(0) + iOff = iOff + 1 + if iOff < **(**int32)(__ccgo_up(bp + 160)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == 0 { + v2 = pBuf + 8 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(v1))) = uint8(0) + iOff = iOff + 1 + } + } + if (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn >= pgsz { + _fts5WriteFlushLeaf(tls, p, bp+16) + } + } else { + **(**int32)(__ccgo_up(bp + 176)) = 0 + **(**int32)(__ccgo_up(bp + 180)) = 0 + nCopy = _fts5GetPoslistSize(tls, **(**uintptr)(__ccgo_up(bp + 152))+uintptr(iOff), bp+180, bp+176) + if **(**int32)(__ccgo_up(bp + 176)) != 0 && bSecureDelete != 0 { + _sqlite3Fts5BufferAppendVarint(tls, p+60, pBuf, int64(**(**int32)(__ccgo_up(bp + 180)))*int64(2)) + iOff = iOff + nCopy + nCopy = **(**int32)(__ccgo_up(bp + 180)) + } else { + nCopy = nCopy + **(**int32)(__ccgo_up(bp + 180)) + } + if (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn+nCopy <= pgsz { + /* The entire poslist will fit on the current leaf. So copy + ** it in one go. */ + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), **(**uintptr)(__ccgo_up(bp + 152))+uintptr(iOff), libc.Uint64FromInt32(nCopy), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pBuf + 8)) += nCopy + } else { + /* The entire poslist will not fit on this leaf. So it needs + ** to be broken into sections. The only qualification being + ** that each varint must be stored contiguously. */ + pPoslist = **(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff) + iPos = 0 + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + nSpace = pgsz - (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn - (*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn + n = 0 + if nCopy-iPos <= nSpace { + n = nCopy - iPos + } else { + n = _fts5PoslistPrefix(tls, pPoslist+uintptr(iPos), nSpace) + } + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), pPoslist+uintptr(iPos), libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pBuf + 8)) += n + iPos = iPos + n + if (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn >= pgsz { + _fts5WriteFlushLeaf(tls, p, bp+16) + } + if iPos >= nCopy { + break + } + } + } + iOff = iOff + nCopy + } + } + } + /* TODO2: Doclist terminator written here. */ + /* pBuf->p[pBuf->n++] = '\0'; */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _sqlite3Fts5HashScanNext(tls, pHash) + } + } + _fts5WriteFinish(tls, p, bp+16, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) > 0 { + /* Update the Fts5Structure. It is written back to the database by the + ** fts5StructureRelease() call below. */ + if (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnLevel == 0 { + _fts5StructureAddLevel(tls, p+60, bp) + } + _fts5StructureExtendLevel(tls, p+60, **(**uintptr)(__ccgo_up(bp)), 0, int32(1), 0) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + v2 = **(**uintptr)(__ccgo_up(bp)) + 32 + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + pSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 32))).FaSeg + uintptr(v1)*56 + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid = iSegid + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst = int32(1) + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast = **(**int32)(__ccgo_up(bp + 8)) + if (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr > uint64(0) { + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin1 = (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 = (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnEntry = libc.Uint64FromInt32((*TFts5Index)(unsafe.Pointer(p)).FnPendingRow) + (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr = (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr + 1 + } + (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnSegment = (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnSegment + 1 + } + _fts5StructurePromote(tls, p, 0, **(**uintptr)(__ccgo_up(bp))) + } + } + } + _fts5IndexAutomerge(tls, p, bp, **(**int32)(__ccgo_up(bp + 8))+(*TFts5Index)(unsafe.Pointer(p)).FnContentlessDelete) + _fts5IndexCrisismerge(tls, p, bp) + _fts5StructureWrite(tls, p, **(**uintptr)(__ccgo_up(bp))) + _fts5StructureRelease(tls, **(**uintptr)(__ccgo_up(bp))) +} + +// C documentation +// +// /* +// ** This is called as part of flushing a delete to disk in 'secure-delete' +// ** mode. It edits the segments within the database described by argument +// ** pStruct to remove the entries for term zTerm, rowid iRowid. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code if an error +// ** has occurred. Any error code is also stored in the Fts5Index handle. +// */ +func _fts5FlushSecureDelete(tls *libc.TLS, p uintptr, pStruct uintptr, zTerm uintptr, nTerm int32, iRowid Ti64) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var f, rc int32 + var iThis Ti64 + var pConfig, pSeg uintptr + var _ /* pIter at bp+0 */ uintptr + var _ /* pStmt at bp+8 */ uintptr + _, _, _, _, _ = f, iThis, pConfig, pSeg, rc + f = int32(FTS5INDEX_QUERY_SKIPHASH) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Used to find term instance */ + /* If the version number has not been set to SECUREDELETE, do so now. */ + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FiVersion != int32(FTS5_CURRENT_VERSION_SECUREDELETE) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + _fts5IndexPrepareStmt(tls, p, bp+8, Xsqlite3_mprintf(tls, __ccgo_ts+39766, libc.VaList(bp+24, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, int32(FTS5_CURRENT_VERSION_SECUREDELETE)))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*TFts5Index)(unsafe.Pointer(p)).Frc = rc + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FiCookie = (*TFts5Config)(unsafe.Pointer(pConfig)).FiCookie + 1 + (*TFts5Config)(unsafe.Pointer(pConfig)).FiVersion = int32(FTS5_CURRENT_VERSION_SECUREDELETE) + } + } + _fts5MultiIterNew(tls, p, pStruct, f, uintptr(0), zTerm, nTerm, -int32(1), 0, bp) + if _fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp))) == 0 { + iThis = _fts5MultiIterRowid(tls, **(**uintptr)(__ccgo_up(bp))) + if iThis < iRowid { + _fts5MultiIterNextFrom(tls, p, **(**uintptr)(__ccgo_up(bp)), iRowid) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && _fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp))) == 0 && iRowid == _fts5MultiIterRowid(tls, **(**uintptr)(__ccgo_up(bp))) { + pSeg = **(**uintptr)(__ccgo_up(bp)) + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaFirst + 1*4))).FiFirst)*128 + _fts5DoSecureDelete(tls, p, pSeg) + } + } + _fts5MultiIterFree(tls, **(**uintptr)(__ccgo_up(bp))) + return (*TFts5Index)(unsafe.Pointer(p)).Frc +} + +func _fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) { + var eStmt int32 + var pData, pNext, pSorter, pTab uintptr + _, _, _, _, _ = eStmt, pData, pNext, pSorter, pTab + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter) + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst) + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt != 0 { + eStmt = _fts5StmtType(tls, pCsr) + _sqlite3Fts5StorageStmtRelease(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, eStmt, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + } + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 { + pSorter = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter + Xsqlite3_finalize(tls, (*TFts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) + Xsqlite3_free(tls, pSorter) + } + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan != int32(FTS5_PLAN_SOURCE) { + _sqlite3Fts5ExprFree(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + } + pData = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata + for { + if !(pData != 0) { + break + } + pNext = (*TFts5Auxdata)(unsafe.Pointer(pData)).FpNext + if (*TFts5Auxdata)(unsafe.Pointer(pData)).FxDelete != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Auxdata)(unsafe.Pointer(pData)).FxDelete})))(tls, (*TFts5Auxdata)(unsafe.Pointer(pData)).FpPtr) + } + Xsqlite3_free(tls, pData) + goto _1 + _1: + ; + pData = pNext + } + Xsqlite3_finalize(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpRankArgStmt) + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg) + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_FREE_ZRANK) != 0 { + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank) + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs) + } + _sqlite3Fts5IndexCloseReader(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) + libc.X__builtin___memset_chk(tls, pCsr+32, 0, uint64(184)-libc.Uint64FromInt64(int64(pCsr+32)-int64(pCsr)), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Implementation of the fts5() function used by clients to obtain the +// ** API pointer. +// */ +func _fts5Fts5Func(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var pGlobal, ppApi uintptr + _, _ = pGlobal, ppApi + pGlobal = Xsqlite3_user_data(tls, pCtx) + _ = nArg + ppApi = Xsqlite3_value_pointer(tls, **(**uintptr)(__ccgo_up(apArg)), __ccgo_ts+40816) + if ppApi != 0 { + **(**uintptr)(__ccgo_up(ppApi)) = pGlobal + } +} + +// C documentation +// +// /* +// ** Implementation of fts5_get_locale() function. +// */ +func _fts5GetLocaleFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType, iCol, rc int32 + var z, z1 uintptr + var _ /* nLocale at bp+8 */ int32 + var _ /* zLocale at bp+0 */ uintptr + _, _, _, _, _ = eType, iCol, rc, z, z1 + iCol = 0 + eType = 0 + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = 0 + /* xColumnLocale() must be available */ + if nVal != int32(1) { + z = __ccgo_ts + 37574 + Xsqlite3_result_error(tls, pCtx, z, -int32(1)) + return + } + eType = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(apVal))) + if eType != int32(SQLITE_INTEGER) { + z1 = __ccgo_ts + 37630 + Xsqlite3_result_error(tls, pCtx, z1, -int32(1)) + return + } + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apVal))) + if iCol < 0 || iCol >= (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnCount})))(tls, pFts) { + Xsqlite3_result_error_code(tls, pCtx, int32(SQLITE_RANGE)) + return + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnLocale})))(tls, pFts, iCol, bp, bp+8) + if rc != SQLITE_OK { + Xsqlite3_result_error_code(tls, pCtx, rc) + return + } + Xsqlite3_result_text(tls, pCtx, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), uintptr(-libc.Int32FromInt32(1))) +} + +func _fts5HashAddPoslistSize(tls *libc.TLS, pHash uintptr, p uintptr, p2 uintptr) (r int32) { + var nByte, nData, nPos, nRet, nSz, v2 int32 + var pPtr, v1 uintptr + _, _, _, _, _, _, _, _ = nByte, nData, nPos, nRet, nSz, pPtr, v1, v2 + nRet = 0 + if (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist != 0 { + if p2 != 0 { + v1 = p2 + } else { + v1 = p + } + pPtr = v1 + nData = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == int32(FTS5_DETAIL_NONE) { + if (*TFts5HashEntry)(unsafe.Pointer(p)).FbDel != 0 { + v2 = nData + nData = nData + 1 + **(**Tu8)(__ccgo_up(pPtr + uintptr(v2))) = uint8(0x00) + if (*TFts5HashEntry)(unsafe.Pointer(p)).FbContent != 0 { + v2 = nData + nData = nData + 1 + **(**Tu8)(__ccgo_up(pPtr + uintptr(v2))) = uint8(0x00) + } + } + } else { + nSz = nData - (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist - int32(1) /* Size in bytes */ + nPos = nSz*int32(2) + libc.Int32FromUint8((*TFts5HashEntry)(unsafe.Pointer(p)).FbDel) /* Value of nPos field */ + if nPos <= int32(127) { + **(**Tu8)(__ccgo_up(pPtr + uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist))) = libc.Uint8FromInt32(nPos) + } else { + nByte = _sqlite3Fts5GetVarintLen(tls, libc.Uint32FromInt32(nPos)) + libc.X__builtin___memmove_chk(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist+nByte), pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist+int32(1)), libc.Uint64FromInt32(nSz), ^t__predefined_size_t(0)) + _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist), libc.Uint64FromInt32(nPos)) + nData = nData + (nByte - int32(1)) + } + } + nRet = nData - (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if p2 == uintptr(0) { + (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = 0 + (*TFts5HashEntry)(unsafe.Pointer(p)).FbDel = uint8(0) + (*TFts5HashEntry)(unsafe.Pointer(p)).FbContent = uint8(0) + (*TFts5HashEntry)(unsafe.Pointer(p)).FnData = nData + } + } + return nRet +} + +// C documentation +// +// /* +// ** Link all tokens from hash table iHash into a list in sorted order. The +// ** tokens are not removed from the hash table. +// */ +func _fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, ppSorted uintptr) (r int32) { + var ap, pEntry, pIter, pList uintptr + var i, iSlot, nMergeSlot int32 + _, _, _, _, _, _, _ = ap, i, iSlot, nMergeSlot, pEntry, pIter, pList + nMergeSlot = int32(32) + **(**uintptr)(__ccgo_up(ppSorted)) = uintptr(0) + ap = Xsqlite3_malloc64(tls, uint64(uint64(8)*libc.Uint64FromInt32(nMergeSlot))) + if !(ap != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, ap, 0, uint64(8)*libc.Uint64FromInt32(nMergeSlot), ^t__predefined_size_t(0)) + iSlot = 0 + for { + if !(iSlot < (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot) { + break + } + pIter = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iSlot)*8)) + for { + if !(pIter != 0) { + break + } + if pTerm == uintptr(0) || (*TFts5HashEntry)(unsafe.Pointer(pIter)).FnKey >= nTerm && 0 == libc.Xmemcmp(tls, pIter+1*48, pTerm, libc.Uint64FromInt32(nTerm)) { + pEntry = pIter + (*TFts5HashEntry)(unsafe.Pointer(pEntry)).FpScanNext = uintptr(0) + i = 0 + for { + if !(**(**uintptr)(__ccgo_up(ap + uintptr(i)*8)) != 0) { + break + } + pEntry = _fts5HashEntryMerge(tls, pEntry, **(**uintptr)(__ccgo_up(ap + uintptr(i)*8))) + **(**uintptr)(__ccgo_up(ap + uintptr(i)*8)) = uintptr(0) + goto _3 + _3: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up(ap + uintptr(i)*8)) = pEntry + } + goto _2 + _2: + ; + pIter = (*TFts5HashEntry)(unsafe.Pointer(pIter)).FpHashNext + } + goto _1 + _1: + ; + iSlot = iSlot + 1 + } + pList = uintptr(0) + i = 0 + for { + if !(i < nMergeSlot) { + break + } + pList = _fts5HashEntryMerge(tls, pList, **(**uintptr)(__ccgo_up(ap + uintptr(i)*8))) + goto _4 + _4: + ; + i = i + 1 + } + Xsqlite3_free(tls, ap) + **(**uintptr)(__ccgo_up(ppSorted)) = pList + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Resize the hash table by doubling the number of slots. +// */ +func _fts5HashResize(tls *libc.TLS, pHash uintptr) (r int32) { + var apNew, apOld, p uintptr + var i, nNew int32 + var iHash uint32 + _, _, _, _, _, _ = apNew, apOld, i, iHash, nNew, p + nNew = (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot * int32(2) + apOld = (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + apNew = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32(nNew)*uint64(8))) + if !(apNew != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, apNew, 0, libc.Uint64FromInt32(nNew)*uint64(8), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot) { + break + } + for **(**uintptr)(__ccgo_up(apOld + uintptr(i)*8)) != 0 { + p = **(**uintptr)(__ccgo_up(apOld + uintptr(i)*8)) + **(**uintptr)(__ccgo_up(apOld + uintptr(i)*8)) = (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext + iHash = _fts5HashKey(tls, nNew, p+1*48, (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey) + (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext = **(**uintptr)(__ccgo_up(apNew + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up(apNew + uintptr(iHash)*8)) = p + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, apOld) + (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot = nNew + (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot = apNew + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Append text to the HighlightContext output string - p->zOut. Argument +// ** z points to a buffer containing n bytes of text to append. If n is +// ** negative, everything up until the first '\0' is appended to the output. +// ** +// ** If *pRc is set to any value other than SQLITE_OK when this function is +// ** called, it is a no-op. If an error (i.e. an OOM condition) is encountered, +// ** *pRc is set to an error code before returning. +// */ +func _fts5HighlightAppend(tls *libc.TLS, pRc uintptr, p uintptr, z uintptr, n int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK && z != 0 { + if n < 0 { + n = libc.Int32FromUint64(libc.Xstrlen(tls, z)) + } + (*THighlightContext)(unsafe.Pointer(p)).FzOut = Xsqlite3_mprintf(tls, __ccgo_ts+37469, libc.VaList(bp+8, (*THighlightContext)(unsafe.Pointer(p)).FzOut, n, z)) + if (*THighlightContext)(unsafe.Pointer(p)).FzOut == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } +} + +// C documentation +// +// /* +// ** Implementation of highlight() function. +// */ +func _fts5HighlightFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var iCol int32 + var zErr uintptr + var _ /* ctx at bp+0 */ THighlightContext + var _ /* nLoc at bp+120 */ int32 + var _ /* pLoc at bp+112 */ uintptr + var _ /* rc at bp+104 */ int32 + _, _ = iCol, zErr + if nVal != int32(3) { + zErr = __ccgo_ts + 37476 + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + return + } + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apVal))) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(104), ^t__predefined_size_t(0)) + (**(**THighlightContext)(__ccgo_up(bp))).FzOpen = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + (**(**THighlightContext)(__ccgo_up(bp))).FzClose = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + 2*8))) + (**(**THighlightContext)(__ccgo_up(bp))).FiRangeEnd = -int32(1) + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})))(tls, pFts, iCol, bp+24, bp+32) + if **(**int32)(__ccgo_up(bp + 104)) == int32(SQLITE_RANGE) { + Xsqlite3_result_text(tls, pCtx, __ccgo_ts+1702, -int32(1), libc.UintptrFromInt32(0)) + **(**int32)(__ccgo_up(bp + 104)) = SQLITE_OK + } else { + if (**(**THighlightContext)(__ccgo_up(bp))).FzIn != 0 { + **(**uintptr)(__ccgo_up(bp + 112)) = uintptr(0) /* Locale of column iCol */ + **(**int32)(__ccgo_up(bp + 120)) = 0 /* Size of pLoc in bytes */ + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = _fts5CInstIterInit(tls, pApi, pFts, iCol, bp+40) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnLocale})))(tls, pFts, iCol, bp+112, bp+120) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize_v2})))(tls, pFts, (**(**THighlightContext)(__ccgo_up(bp))).FzIn, (**(**THighlightContext)(__ccgo_up(bp))).FnIn, **(**uintptr)(__ccgo_up(bp + 112)), **(**int32)(__ccgo_up(bp + 120)), bp, __ccgo_fp(_fts5HighlightCb)) + } + if (**(**THighlightContext)(__ccgo_up(bp))).FbOpen != 0 { + _fts5HighlightAppend(tls, bp+104, bp, (**(**THighlightContext)(__ccgo_up(bp))).FzClose, -int32(1)) + } + _fts5HighlightAppend(tls, bp+104, bp, (**(**THighlightContext)(__ccgo_up(bp))).FzIn+uintptr((**(**THighlightContext)(__ccgo_up(bp))).FiOff), (**(**THighlightContext)(__ccgo_up(bp))).FnIn-(**(**THighlightContext)(__ccgo_up(bp))).FiOff) + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + Xsqlite3_result_text(tls, pCtx, (**(**THighlightContext)(__ccgo_up(bp))).FzOut, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } + Xsqlite3_free(tls, (**(**THighlightContext)(__ccgo_up(bp))).FzOut) + } + } + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + Xsqlite3_result_error_code(tls, pCtx, **(**int32)(__ccgo_up(bp + 104))) + } +} + +/* +** End of highlight() implementation. +**************************************************************************/ + +// C documentation +// +// /* +// ** SQL used by fts5SegIterNextInit() to find the page to open. +// */ +func _fts5IdxNextStmt(tls *libc.TLS, p uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pConfig uintptr + _ = pConfig + if (*TFts5Index)(unsafe.Pointer(p)).FpIdxNextSelect == uintptr(0) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + _fts5IndexPrepareStmt(tls, p, p+120, Xsqlite3_mprintf(tls, __ccgo_ts+39566, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))) + } + return (*TFts5Index)(unsafe.Pointer(p)).FpIdxNextSelect +} + +func _fts5IdxSelectStmt(tls *libc.TLS, p uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pConfig uintptr + _ = pConfig + if (*TFts5Index)(unsafe.Pointer(p)).FpIdxSelect == uintptr(0) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + _fts5IndexPrepareStmt(tls, p, p+112, Xsqlite3_mprintf(tls, __ccgo_ts+39482, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))) + } + return (*TFts5Index)(unsafe.Pointer(p)).FpIdxSelect +} + +func _fts5IndexCorruptIdx(tls *libc.TLS, pIdx uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + (*TFts5Index)(unsafe.Pointer(pIdx)).Frc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<base.pData/nData to point to the new position list. +// ** If memory is required for the new position list, use buffer pIter->poslist. +// ** Or, if the new position list is a contiguous subset of the input, set +// ** pIter->base.pData/nData to point directly to it. +// ** +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. If an OOM error is encountered, *pRc is set to SQLITE_NOMEM +// ** before returning. +// */ +func _fts5IndexExtractColset(tls *libc.TLS, pRc uintptr, pColset uintptr, pPos uintptr, nPos int32, pIter uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aCopy, p, pEnd, v1 uintptr + var i int32 + var v2 bool + var _ /* iCurrent at bp+0 */ int32 + _, _, _, _, _, _ = aCopy, i, p, pEnd, v1, v2 + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + p = pPos + aCopy = p + pEnd = p + uintptr(nPos) /* One byte past end of position list */ + i = 0 + **(**int32)(__ccgo_up(bp)) = 0 + if (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol > int32(1) && _sqlite3Fts5BufferSize(tls, pRc, pIter+40, libc.Uint32FromInt32(nPos)) != 0 { + return + } + for int32(1) != 0 { + for *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) < **(**int32)(__ccgo_up(bp)) { + i = i + 1 + if i == (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol { + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn + return + } + } + /* Advance pointer p until it points to pEnd or an 0x01 byte that is + ** not part of a varint */ + for p < pEnd && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(p))) != int32(0x01) { + for { + if v2 = p < pEnd; v2 { + v1 = p + p = p + 1 + } + if !(v2 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v1)))&int32(0x80) != 0) { + break + } + } + } + if *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) == **(**int32)(__ccgo_up(bp)) { + if (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol == int32(1) { + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = aCopy + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = int32(int64(p) - int64(aCopy)) + return + } + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(pIter+40)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pIter+40)).Fn), aCopy, libc.Uint64FromInt64(int64(p)-int64(aCopy)), ^t__predefined_size_t(0)) + v1 = pIter + 40 + 8 + *(*int32)(unsafe.Pointer(v1)) = int32(int64(*(*int32)(unsafe.Pointer(v1))) + (int64(p) - int64(aCopy))) + } + if p >= pEnd { + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn + return + } + v1 = p + p = p + 1 + aCopy = v1 + v1 = p + p = p + 1 + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v1))) + if **(**int32)(__ccgo_up(bp))&int32(0x80) != 0 { + p = p - 1 + p = p + uintptr(_sqlite3Fts5GetVarint32(tls, p, bp)) + } + } + } +} + +func _fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bIdxDlidx, bSecureDelete, iDlidxPrevLeaf, iIdxLeaf, iIdxPrevLeaf, iOff, iPg, iPrevLeaf, iRowidOff, iRowidOff1, iSegid, nIdxTerm, rc2, res, v1, v2, v3 int32 + var iDlRowid, iKey, iRow Ti64 + var pConfig, pDlidx, pLeaf, zIdxTerm uintptr + var _ /* iRowid at bp+16 */ Ti64 + var _ /* nTerm at bp+8 */ int32 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bIdxDlidx, bSecureDelete, iDlRowid, iDlidxPrevLeaf, iIdxLeaf, iIdxPrevLeaf, iKey, iOff, iPg, iPrevLeaf, iRow, iRowidOff, iRowidOff1, iSegid, nIdxTerm, pConfig, pDlidx, pLeaf, rc2, res, zIdxTerm, v1, v2, v3 + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + bSecureDelete = libc.BoolInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FiVersion == int32(FTS5_CURRENT_VERSION_SECUREDELETE)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + iIdxPrevLeaf = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst - int32(1) + iDlidxPrevLeaf = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst == 0 { + return + } + _fts5IndexPrepareStmt(tls, p, bp, Xsqlite3_mprintf(tls, __ccgo_ts+39906, libc.VaList(bp+32, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid))) + /* Iterate through the b-tree hierarchy. */ + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { /* Data for this leaf */ + zIdxTerm = Xsqlite3_column_blob(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + nIdxTerm = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + iIdxLeaf = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(2)) + bIdxDlidx = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) + /* If the leaf in question has already been trimmed from the segment, + ** ignore this b-tree entry. Otherwise, load it into memory. */ + if iIdxLeaf < (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { + continue + } + iRow = int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= iOff || iOff >= (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + _fts5IndexCorruptRowid(tls, p, iRow) + } else { + iOff = iOff + _sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+8) + if **(**int32)(__ccgo_up(bp + 8)) < nIdxTerm { + v2 = **(**int32)(__ccgo_up(bp + 8)) + } else { + v2 = nIdxTerm + } + if v2 <= 0 { + v1 = 0 + } else { + if **(**int32)(__ccgo_up(bp + 8)) < nIdxTerm { + v3 = **(**int32)(__ccgo_up(bp + 8)) + } else { + v3 = nIdxTerm + } + v1 = libc.Xmemcmp(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), zIdxTerm, libc.Uint64FromInt32(v3)) + } + res = v1 + if res == 0 { + res = **(**int32)(__ccgo_up(bp + 8)) - nIdxTerm + } + if res < 0 { + _fts5IndexCorruptRowid(tls, p, iRow) + } + } + _fts5IntegrityCheckPgidx(tls, p, iRow, pLeaf) + } + _fts5DataRelease(tls, pLeaf) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + /* Now check that the iter.nEmpty leaves following the current leaf + ** (a) exist and (b) contain no terms. */ + _fts5IndexIntegrityCheckEmpty(tls, p, pSeg, iIdxPrevLeaf+int32(1), iDlidxPrevLeaf+int32(1), iIdxLeaf-int32(1)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + /* If there is a doclist-index, check that it looks right. */ + if bIdxDlidx != 0 { + pDlidx = uintptr(0) /* For iterating through doclist index */ + iPrevLeaf = iIdxLeaf + iSegid = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid + iPg = 0 + pDlidx = _fts5DlidxIterInit(tls, p, 0, iSegid, iIdxLeaf) + for { + if !(_fts5DlidxIterEof(tls, p, pDlidx) == 0) { + break + } + /* Check any rowid-less pages that occur before the current leaf. */ + iPg = iPrevLeaf + int32(1) + for { + if !(iPg < _fts5DlidxIterPgno(tls, pDlidx)) { + break + } + iKey = int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + _fts5IndexCorruptRowid(tls, p, iKey) + } else { + if bSecureDelete == 0 || iRowidOff1 > 0 { + iDlRowid = _fts5DlidxIterRowid(tls, pDlidx) + _sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iRowidOff1), bp+16) + if **(**Ti64)(__ccgo_up(bp + 16)) < iDlRowid || bSecureDelete == 0 && **(**Ti64)(__ccgo_up(bp + 16)) != iDlRowid { + _fts5IndexCorruptRowid(tls, p, iKey) + } + } + } + _fts5DataRelease(tls, pLeaf) + } + goto _4 + _4: + ; + _fts5DlidxIterNext(tls, p, pDlidx) + } + iDlidxPrevLeaf = iPg + _fts5DlidxIterFree(tls, pDlidx) + } else { + iDlidxPrevLeaf = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast + /* TODO: Check there is no doclist index */ + } + iIdxPrevLeaf = iIdxLeaf + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*TFts5Index)(unsafe.Pointer(p)).Frc = rc2 + } + /* Page iter.iLeaf must now be the rightmost leaf-page in the segment */ +} + +// C documentation +// +// /* +// ** +// */ +func _fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, pnRem uintptr) { + bp := tls.Alloc(160) + defer tls.Free(160) + var bOldest, bTermWritten, eDetail, flags, i, iSegid, nInput, nMove, nPos, nRem, v1 int32 + var pLvl, pLvlOut, pOld, pSeg, pSegIter, pStruct, pTerm uintptr + var v4 bool + var _ /* nTerm at bp+144 */ int32 + var _ /* pIter at bp+0 */ uintptr + var _ /* term at bp+128 */ TFts5Buffer + var _ /* writer at bp+8 */ TFts5SegWriter + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bOldest, bTermWritten, eDetail, flags, i, iSegid, nInput, nMove, nPos, nRem, pLvl, pLvlOut, pOld, pSeg, pSegIter, pStruct, pTerm, v1, v4 + pStruct = **(**uintptr)(__ccgo_up(ppStruct)) + pLvl = pStruct + 32 + uintptr(iLvl)*16 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if pnRem != 0 { + v1 = **(**int32)(__ccgo_up(pnRem)) + } else { + v1 = 0 + } /* Iterator to read input data */ + nRem = v1 /* True if the output segment is the oldest */ + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail + flags = int32(FTS5INDEX_QUERY_NOOUTPUT) + bTermWritten = 0 /* True if current term already output */ + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(120), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+128, 0, uint64(16), ^t__predefined_size_t(0)) + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 { + pLvlOut = pStruct + 32 + uintptr(iLvl+int32(1))*16 + nInput = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge + pSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FaSeg + uintptr((*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg-int32(1))*56 + _fts5WriteInit(tls, p, bp+8, (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid) + (**(**TFts5SegWriter)(__ccgo_up(bp + 8))).Fwriter.Fpgno = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast + int32(1) + (**(**TFts5SegWriter)(__ccgo_up(bp + 8))).FiBtPage = 0 + } else { + iSegid = _fts5AllocateSegid(tls, p, pStruct) + /* Extend the Fts5Structure object as required to ensure the output + ** segment exists. */ + if iLvl == (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel-int32(1) { + _fts5StructureAddLevel(tls, p+60, ppStruct) + pStruct = **(**uintptr)(__ccgo_up(ppStruct)) + } + _fts5StructureExtendLevel(tls, p+60, pStruct, iLvl+int32(1), int32(1), 0) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + pLvl = pStruct + 32 + uintptr(iLvl)*16 + pLvlOut = pStruct + 32 + uintptr(iLvl+int32(1))*16 + _fts5WriteInit(tls, p, bp+8, iSegid) + /* Add the new segment to the output level */ + pSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FaSeg + uintptr((*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg)*56 + (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg + 1 + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst = int32(1) + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid = iSegid + (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment + 1 + /* Read input from all segments in the input level */ + nInput = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg + /* Set the range of origins that will go into the output segment. */ + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnOriginCntr > uint64(0) { + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin1 = (**(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg))).FiOrigin1 + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 = (**(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg-int32(1))*56))).FiOrigin2 + } + } + bOldest = libc.BoolInt32((*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg == int32(1) && (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel == iLvl+int32(2)) + _fts5MultiIterNew(tls, p, pStruct, flags, uintptr(0), uintptr(0), 0, iLvl, nInput, bp) + for { + if !(_fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp))) == 0) { + break + } + pSegIter = **(**uintptr)(__ccgo_up(bp)) + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaFirst + 1*4))).FiFirst)*128 + pTerm = _fts5MultiIterTerm(tls, **(**uintptr)(__ccgo_up(bp)), bp+144) + if v4 = **(**int32)(__ccgo_up(bp + 144)) != (**(**TFts5Buffer)(__ccgo_up(bp + 128))).Fn; !v4 { + if **(**int32)(__ccgo_up(bp + 144)) <= 0 { + v1 = 0 + } else { + v1 = libc.Xmemcmp(tls, pTerm, (**(**TFts5Buffer)(__ccgo_up(bp + 128))).Fp, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 144)))) + } + } + if v4 || v1 != 0 { + if pnRem != 0 && (**(**TFts5SegWriter)(__ccgo_up(bp + 8))).FnLeafWritten > nRem { + break + } + _sqlite3Fts5BufferSet(tls, p+60, bp+128, **(**int32)(__ccgo_up(bp + 144)), pTerm) + bTermWritten = 0 + } + /* Check for key annihilation. */ + if (*TFts5SegIter)(unsafe.Pointer(pSegIter)).FnPos == 0 && (bOldest != 0 || libc.Int32FromUint8((*TFts5SegIter)(unsafe.Pointer(pSegIter)).FbDel) == 0) { + goto _2 + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bTermWritten == 0 { + /* This is a new term. Append a term to the output segment. */ + _fts5WriteAppendTerm(tls, p, bp+8, **(**int32)(__ccgo_up(bp + 144)), pTerm) + bTermWritten = int32(1) + } + /* Append the rowid to the output */ + /* WRITEPOSLISTSIZE */ + _fts5WriteAppendRowid(tls, p, bp+8, _fts5MultiIterRowid(tls, **(**uintptr)(__ccgo_up(bp)))) + if eDetail == int32(FTS5_DETAIL_NONE) { + if (*TFts5SegIter)(unsafe.Pointer(pSegIter)).FbDel != 0 { + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp+8+8+8, libc.Int64FromInt32(0)) + if (*TFts5SegIter)(unsafe.Pointer(pSegIter)).FnPos > 0 { + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp+8+8+8, libc.Int64FromInt32(0)) + } + } + } else { + /* Append the position-list data to the output */ + nPos = (*TFts5SegIter)(unsafe.Pointer(pSegIter)).FnPos*int32(2) + libc.Int32FromUint8((*TFts5SegIter)(unsafe.Pointer(pSegIter)).FbDel) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp+8+8+8, int64(nPos)) + _fts5ChunkIterate(tls, p, pSegIter, bp+8, __ccgo_fp(_fts5MergeChunkCallback)) + } + goto _2 + _2: + ; + _fts5MultiIterNext(tls, p, **(**uintptr)(__ccgo_up(bp)), 0, 0) + } + /* Flush the last leaf page to disk. Set the output segment b-tree height + ** and last leaf page number at the same time. */ + _fts5WriteFinish(tls, p, bp+8, pSeg+8) + if _fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp))) != 0 { + /* Remove the redundant segments from the %_data table */ + i = 0 + for { + if !(i < nInput) { + break + } + pOld = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(i)*56 + **(**Tu64)(__ccgo_up(pSeg + 48)) += (*TFts5StructureSegment)(unsafe.Pointer(pOld)).FnEntry - (*TFts5StructureSegment)(unsafe.Pointer(pOld)).FnEntryTombstone + _fts5DataRemoveSegment(tls, p, pOld) + goto _5 + _5: + ; + i = i + 1 + } + /* Remove the redundant segments from the input level */ + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg != nInput { + nMove = libc.Int32FromUint64(libc.Uint64FromInt32((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg-nInput) * uint64(56)) + libc.X__builtin___memmove_chk(tls, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(nInput)*56, libc.Uint64FromInt32(nMove), ^t__predefined_size_t(0)) + } + **(**int32)(__ccgo_up(pStruct + 24)) -= nInput + **(**int32)(__ccgo_up(pLvl + 4)) -= nInput + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge = 0 + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast == 0 { + (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg - 1 + (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment - 1 + } + } else { + _fts5TrimSegments(tls, p, **(**uintptr)(__ccgo_up(bp))) + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge = nInput + } + _fts5MultiIterFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3Fts5BufferFree(tls, bp+128) + if pnRem != 0 { + **(**int32)(__ccgo_up(pnRem)) -= (**(**TFts5SegWriter)(__ccgo_up(bp + 8))).FnLeafWritten + } +} + +func _fts5Init(tls *libc.TLS, db uintptr) (r int32) { + var p, pGlobal uintptr + var rc int32 + _, _, _ = p, pGlobal, rc + pGlobal = uintptr(0) + pGlobal = Xsqlite3_malloc64(tls, uint64(112)) + if pGlobal == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + p = pGlobal + libc.X__builtin___memset_chk(tls, pGlobal, 0, uint64(112), ^t__predefined_size_t(0)) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fdb = db + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FiVersion = int32(3) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxCreateFunction = __ccgo_fp(_fts5CreateAux) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxCreateTokenizer = __ccgo_fp(_fts5CreateTokenizer) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxFindTokenizer = __ccgo_fp(_fts5FindTokenizer) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxCreateTokenizer_v2 = __ccgo_fp(_fts5CreateTokenizer_v2) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxFindTokenizer_v2 = __ccgo_fp(_fts5FindTokenizer_v2) + /* Initialize pGlobal->aLocaleHdr[] to a 128-bit pseudo-random vector. + ** The constants below were generated randomly. */ + Xsqlite3_randomness(tls, int32(16), pGlobal+96) + **(**Tu32)(__ccgo_up(pGlobal + 96)) ^= uint32(0xF924976D) + **(**Tu32)(__ccgo_up(pGlobal + 96 + 1*4)) ^= uint32(0x16596E13) + **(**Tu32)(__ccgo_up(pGlobal + 96 + 2*4)) ^= uint32(0x7C80BEAA) + **(**Tu32)(__ccgo_up(pGlobal + 96 + 3*4)) ^= uint32(0x9B03A67F) + rc = Xsqlite3_create_module_v2(tls, db, __ccgo_ts+41036, uintptr(unsafe.Pointer(&_fts5Mod)), p, __ccgo_fp(_fts5ModuleDestroy)) + if rc == SQLITE_OK { + rc = _sqlite3Fts5IndexInit(tls, db) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprInit(tls, pGlobal, db) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5AuxInit(tls, pGlobal) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5TokenizerInit(tls, pGlobal) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5VocabInit(tls, pGlobal, db) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+41036, int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_fts5Fts5Func), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+41041, 0, libc.Int32FromInt32(SQLITE_UTF8)|libc.Int32FromInt32(SQLITE_DETERMINISTIC)|libc.Int32FromInt32(SQLITE_INNOCUOUS), p, __ccgo_fp(_fts5SourceIdFunc), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+41056, int32(2), libc.Int32FromInt32(SQLITE_UTF8)|libc.Int32FromInt32(SQLITE_INNOCUOUS)|libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)|libc.Int32FromInt32(SQLITE_SUBTYPE), p, __ccgo_fp(_fts5LocaleFunc), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+41068, int32(1), libc.Int32FromInt32(SQLITE_UTF8)|libc.Int32FromInt32(SQLITE_INNOCUOUS)|libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE), p, __ccgo_fp(_fts5InsttokenFunc), uintptr(0), uintptr(0)) + } + } + /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file + ** fts5_test_mi.c is compiled and linked into the executable. And call + ** its entry point to enable the matchinfo() demo. */ + return rc +} + +// C documentation +// +// /* +// ** Run an integrity check on the FTS5 data structures. Return a string +// ** if anything is found amiss. Return a NULL pointer if everything is +// ** OK. +// */ +func _fts5IntegrityMethod(tls *libc.TLS, pVtab uintptr, zSchema uintptr, zTabname uintptr, isQuick int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pTab uintptr + var rc, v1 int32 + _, _, _ = pTab, rc, v1 + pTab = pVtab + _ = isQuick + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = pzErr + rc = _sqlite3Fts5StorageIntegrity(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, 0) + if **(**uintptr)(__ccgo_up(pzErr)) == uintptr(0) && rc != SQLITE_OK { + if rc&int32(0xff) == int32(SQLITE_CORRUPT) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+40927, libc.VaList(bp+8, zSchema, zTabname)) + if **(**uintptr)(__ccgo_up(pzErr)) != 0 { + v1 = SQLITE_OK + } else { + v1 = int32(SQLITE_NOMEM) + } + rc = v1 + } else { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+40973, libc.VaList(bp+8, zSchema, zTabname, Xsqlite3_errstr(tls, rc))) + } + } else { + if rc&int32(0xff) == int32(SQLITE_CORRUPT) { + rc = SQLITE_OK + } + } + _sqlite3Fts5IndexCloseReader(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = uintptr(0) + return rc +} + +// C documentation +// +// /* +// ** Implementation of fts5_locale(LOCALE, TEXT) function. +// ** +// ** If parameter LOCALE is NULL, or a zero-length string, then a copy of +// ** TEXT is returned. Otherwise, both LOCALE and TEXT are interpreted as +// ** text, and the value returned is a blob consisting of: +// ** +// ** * The 4 bytes 0x00, 0xE0, 0xB2, 0xEb (FTS5_LOCALE_HEADER). +// ** * The LOCALE, as utf-8 text, followed by +// ** * 0x00, followed by +// ** * The TEXT, as utf-8 text. +// ** +// ** There is no final nul-terminator following the TEXT value. +// */ +func _fts5LocaleFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var nBlob, nLocale, nText Ti64 + var p, pBlob, pCsr, zLocale, zText, v1 uintptr + _, _, _, _, _, _, _, _, _ = nBlob, nLocale, nText, p, pBlob, pCsr, zLocale, zText, v1 + zLocale = uintptr(0) + nLocale = 0 + zText = uintptr(0) + nText = 0 + _ = nArg + zLocale = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg))) + nLocale = int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg)))) + zText = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + nText = int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg + 1*8)))) + if zLocale == uintptr(0) || int32(**(**int8)(__ccgo_up(zLocale))) == int32('\000') { + Xsqlite3_result_text(tls, pCtx, zText, int32(nText), uintptr(-libc.Int32FromInt32(1))) + } else { + p = Xsqlite3_user_data(tls, pCtx) + pBlob = uintptr(0) + pCsr = uintptr(0) + nBlob = 0 + nBlob = int64(libc.Int32FromInt64(16)) + nLocale + int64(1) + nText + pBlob = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nBlob)) + if pBlob == uintptr(0) { + Xsqlite3_result_error_nomem(tls, pCtx) + return + } + pCsr = pBlob + libc.X__builtin___memcpy_chk(tls, pCsr, p+96, libc.Uint64FromInt32(libc.Int32FromInt64(16)), ^t__predefined_size_t(0)) + pCsr = pCsr + uintptr(libc.Int32FromInt64(16)) + libc.X__builtin___memcpy_chk(tls, pCsr, zLocale, libc.Uint64FromInt64(nLocale), ^t__predefined_size_t(0)) + pCsr = pCsr + uintptr(nLocale) + v1 = pCsr + pCsr = pCsr + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8(0x00) + if zText != 0 { + libc.X__builtin___memcpy_chk(tls, pCsr, zText, libc.Uint64FromInt64(nText), ^t__predefined_size_t(0)) + } + Xsqlite3_result_blob(tls, pCtx, pBlob, int32(nBlob), __ccgo_fp(Xsqlite3_free)) + } +} + +func _fts5LookaheadReaderInit(tls *libc.TLS, a uintptr, n int32, p uintptr) (r int32) { + libc.X__builtin___memset_chk(tls, p, 0, uint64(32), ^t__predefined_size_t(0)) + (*TFts5LookaheadReader)(unsafe.Pointer(p)).Fa = a + (*TFts5LookaheadReader)(unsafe.Pointer(p)).Fn = n + _fts5LookaheadReaderNext(tls, p) + return _fts5LookaheadReaderNext(tls, p) +} + +// C documentation +// +// /* +// ** Array aBuf[] contains nBuf doclists. These are all merged in with the +// ** doclist in buffer p1. +// */ +func _fts5MergePrefixLists(tls *libc.TLS, p uintptr, p1 uintptr, nBuf int32, aBuf uintptr) { + bp := tls.Alloc(1072) + defer tls.Free(1072) + var i, nMerge, nOut, nTail, nTmp int32 + var iLastRowid Ti64 + var pI, pNext, pSave, pThis, pThis1, pX uintptr + var _ /* aMerger at bp+0 */ [16]TPrefixMerger + var _ /* iPrev at bp+1064 */ Ti64 + var _ /* out at bp+1032 */ TFts5Buffer + var _ /* pHead at bp+1024 */ uintptr + var _ /* tmp at bp+1048 */ TFts5Buffer + _, _, _, _, _, _, _, _, _, _, _, _ = i, iLastRowid, nMerge, nOut, nTail, nTmp, pI, pNext, pSave, pThis, pThis1, pX + **(**uintptr)(__ccgo_up(bp + 1024)) = uintptr(0) + nOut = 0 + **(**TFts5Buffer)(__ccgo_up(bp + 1032)) = TFts5Buffer{} + **(**TFts5Buffer)(__ccgo_up(bp + 1048)) = TFts5Buffer{} + iLastRowid = 0 + /* Initialize a doclist-iterator for each input buffer. Arrange them in + ** a linked-list starting at pHead in ascending order of rowid. Avoid + ** linking any iterators already at EOF into the linked list at all. */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(64)*libc.Uint64FromInt32(nBuf+libc.Int32FromInt32(1)), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(bp + 1024)) = bp + uintptr(nBuf)*64 + _fts5DoclistIterInit(tls, p1, **(**uintptr)(__ccgo_up(bp + 1024))) + i = 0 + for { + if !(i < nBuf) { + break + } + _fts5DoclistIterInit(tls, aBuf+uintptr(i)*16, bp+uintptr(i)*64) + _fts5PrefixMergerInsertByRowid(tls, bp+1024, bp+uintptr(i)*64) + nOut = nOut + (**(**TFts5Buffer)(__ccgo_up(aBuf + uintptr(i)*16))).Fn + goto _1 + _1: + ; + i = i + 1 + } + if nOut == 0 { + return + } + nOut = nOut + ((*TFts5Buffer)(unsafe.Pointer(p1)).Fn + int32(9) + int32(10)*nBuf) + /* The maximum size of the output is equal to the sum of the + ** input sizes + 1 varint (9 bytes). The extra varint is because if the + ** first rowid in one input is a large negative number, and the first in + ** the other a non-negative number, the delta for the non-negative + ** number will be larger on disk than the literal integer value + ** was. + ** + ** Or, if the input position-lists are corrupt, then the output might + ** include up to (nBuf+1) extra 10-byte positions created by interpreting -1 + ** (the value PoslistNext64() uses for EOF) as a position and appending + ** it to the output. This can happen at most once for each input + ** position-list, hence (nBuf+1) 10 byte paddings. */ + if _sqlite3Fts5BufferSize(tls, p+60, bp+1032, libc.Uint32FromInt32(nOut)) != 0 { + return + } + for **(**uintptr)(__ccgo_up(bp + 1024)) != 0 { + **(**int32)(__ccgo_up(bp + 1032 + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), libc.Uint64FromInt64((*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).Fiter.FiRowid)-libc.Uint64FromInt64(iLastRowid)) + iLastRowid = (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).Fiter.FiRowid + if (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FpNext != 0 && iLastRowid == (*TPrefixMerger)(unsafe.Pointer((*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FpNext)).Fiter.FiRowid { + /* Merge data from two or more poslists */ + **(**Ti64)(__ccgo_up(bp + 1064)) = 0 + nTmp = int32(FTS5_DATA_ZERO_PADDING) + nMerge = 0 + pSave = **(**uintptr)(__ccgo_up(bp + 1024)) + pThis = uintptr(0) + nTail = 0 + **(**uintptr)(__ccgo_up(bp + 1024)) = uintptr(0) + for pSave != 0 && (*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FiRowid == iLastRowid { + pNext = (*TPrefixMerger)(unsafe.Pointer(pSave)).FpNext + (*TPrefixMerger)(unsafe.Pointer(pSave)).FiOff = 0 + (*TPrefixMerger)(unsafe.Pointer(pSave)).FiPos = 0 + (*TPrefixMerger)(unsafe.Pointer(pSave)).FaPos = (*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FaPoslist + uintptr((*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnSize) + _sqlite3Fts5PoslistNext64(tls, (*TPrefixMerger)(unsafe.Pointer(pSave)).FaPos, (*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnPoslist, pSave+40, pSave+32) + nTmp = nTmp + ((*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnPoslist + int32(10)) + nMerge = nMerge + 1 + _fts5PrefixMergerInsertByPosition(tls, bp+1024, pSave) + pSave = pNext + } + if **(**uintptr)(__ccgo_up(bp + 1024)) == uintptr(0) || (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FpNext == uintptr(0) { + _fts5IndexCorruptIdx(tls, p) + break + } + /* See the earlier comment in this function for an explanation of why + ** corrupt input position lists might cause the output to consume + ** at most nMerge*10 bytes of unexpected space. */ + if _sqlite3Fts5BufferSize(tls, p+60, bp+1048, libc.Uint32FromInt32(nTmp+nMerge*int32(10))) != 0 { + break + } + _sqlite3Fts5BufferZero(tls, bp+1048) + pThis = **(**uintptr)(__ccgo_up(bp + 1024)) + **(**uintptr)(__ccgo_up(bp + 1024)) = (*TPrefixMerger)(unsafe.Pointer(pThis)).FpNext + _sqlite3Fts5PoslistSafeAppend(tls, bp+1048, bp+1064, (*TPrefixMerger)(unsafe.Pointer(pThis)).FiPos) + _sqlite3Fts5PoslistNext64(tls, (*TPrefixMerger)(unsafe.Pointer(pThis)).FaPos, (*TPrefixMerger)(unsafe.Pointer(pThis)).Fiter.FnPoslist, pThis+40, pThis+32) + _fts5PrefixMergerInsertByPosition(tls, bp+1024, pThis) + for (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FpNext != 0 { + pThis = **(**uintptr)(__ccgo_up(bp + 1024)) + if (*TPrefixMerger)(unsafe.Pointer(pThis)).FiPos != **(**Ti64)(__ccgo_up(bp + 1064)) { + _sqlite3Fts5PoslistSafeAppend(tls, bp+1048, bp+1064, (*TPrefixMerger)(unsafe.Pointer(pThis)).FiPos) + } + _sqlite3Fts5PoslistNext64(tls, (*TPrefixMerger)(unsafe.Pointer(pThis)).FaPos, (*TPrefixMerger)(unsafe.Pointer(pThis)).Fiter.FnPoslist, pThis+40, pThis+32) + **(**uintptr)(__ccgo_up(bp + 1024)) = (*TPrefixMerger)(unsafe.Pointer(pThis)).FpNext + _fts5PrefixMergerInsertByPosition(tls, bp+1024, pThis) + } + if (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FiPos != **(**Ti64)(__ccgo_up(bp + 1064)) { + _sqlite3Fts5PoslistSafeAppend(tls, bp+1048, bp+1064, (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FiPos) + } + nTail = (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).Fiter.FnPoslist - (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FiOff + /* WRITEPOSLISTSIZE */ + if (**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fn+nTail > nTmp-int32(FTS5_DATA_ZERO_PADDING) { + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _fts5IndexCorruptIdx(tls, p) + } + break + } + **(**int32)(__ccgo_up(bp + 1032 + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), libc.Uint64FromInt32(((**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fn+nTail)*libc.Int32FromInt32(2))) + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), (**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fp, libc.Uint64FromInt32((**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fn), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp + 1032 + 8)) += (**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fn + if nTail > 0 { + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FaPos+uintptr((*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FiOff), libc.Uint64FromInt32(nTail), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp + 1032 + 8)) += nTail + } + **(**uintptr)(__ccgo_up(bp + 1024)) = pSave + i = 0 + for { + if !(i < nBuf+int32(1)) { + break + } + pX = bp + uintptr(i)*64 + if (*TPrefixMerger)(unsafe.Pointer(pX)).Fiter.FaPoslist != 0 && (*TPrefixMerger)(unsafe.Pointer(pX)).Fiter.FiRowid == iLastRowid { + _fts5DoclistIterNext(tls, pX) + _fts5PrefixMergerInsertByRowid(tls, bp+1024, pX) + } + goto _2 + _2: + ; + i = i + 1 + } + } else { + /* Copy poslist from pHead to output */ + pThis1 = **(**uintptr)(__ccgo_up(bp + 1024)) + pI = pThis1 + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), (*TFts5DoclistIter)(unsafe.Pointer(pI)).FaPoslist, libc.Uint64FromInt32((*TFts5DoclistIter)(unsafe.Pointer(pI)).FnPoslist+(*TFts5DoclistIter)(unsafe.Pointer(pI)).FnSize), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp + 1032 + 8)) += (*TFts5DoclistIter)(unsafe.Pointer(pI)).FnPoslist + (*TFts5DoclistIter)(unsafe.Pointer(pI)).FnSize + _fts5DoclistIterNext(tls, pI) + **(**uintptr)(__ccgo_up(bp + 1024)) = (*TPrefixMerger)(unsafe.Pointer(pThis1)).FpNext + _fts5PrefixMergerInsertByRowid(tls, bp+1024, pThis1) + } + } + _sqlite3Fts5BufferFree(tls, p1) + _sqlite3Fts5BufferFree(tls, bp+1048) + libc.X__builtin___memset_chk(tls, (**(**TFts5Buffer)(__ccgo_up(bp + 1032))).Fp+uintptr((**(**TFts5Buffer)(__ccgo_up(bp + 1032))).Fn), 0, uint64(FTS5_DATA_ZERO_PADDING), ^t__predefined_size_t(0)) + **(**TFts5Buffer)(__ccgo_up(p1)) = **(**TFts5Buffer)(__ccgo_up(bp + 1032)) +} + +// C documentation +// +// /* +// ** This is the equivalent of fts5MergePrefixLists() for detail=none mode. +// ** In this case the buffers consist of a delta-encoded list of rowids only. +// */ +func _fts5MergeRowidLists(tls *libc.TLS, p uintptr, p1 uintptr, nBuf int32, aBuf uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iOut Ti64 + var p2 uintptr + var _ /* i1 at bp+0 */ int32 + var _ /* i2 at bp+4 */ int32 + var _ /* iRowid1 at bp+8 */ Ti64 + var _ /* iRowid2 at bp+16 */ Ti64 + var _ /* out at bp+24 */ TFts5Buffer + _, _ = iOut, p2 + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**Ti64)(__ccgo_up(bp + 8)) = 0 + **(**Ti64)(__ccgo_up(bp + 16)) = 0 + iOut = 0 + p2 = aBuf + _ = nBuf + libc.X__builtin___memset_chk(tls, bp+24, 0, uint64(16), ^t__predefined_size_t(0)) + _sqlite3Fts5BufferSize(tls, p+60, bp+24, libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(p1)).Fn+(*TFts5Buffer)(unsafe.Pointer(p2)).Fn)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + _fts5NextRowid(tls, p1, bp, bp+8) + _fts5NextRowid(tls, p2, bp+4, bp+16) + for **(**int32)(__ccgo_up(bp)) >= 0 || **(**int32)(__ccgo_up(bp + 4)) >= 0 { + if **(**int32)(__ccgo_up(bp)) >= 0 && (**(**int32)(__ccgo_up(bp + 4)) < 0 || **(**Ti64)(__ccgo_up(bp + 8)) < **(**Ti64)(__ccgo_up(bp + 16))) { + **(**int32)(__ccgo_up(bp + 24 + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp+24)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+24)).Fn), libc.Uint64FromInt64(**(**Ti64)(__ccgo_up(bp + 8))-iOut)) + iOut = **(**Ti64)(__ccgo_up(bp + 8)) + _fts5NextRowid(tls, p1, bp, bp+8) + } else { + **(**int32)(__ccgo_up(bp + 24 + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp+24)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+24)).Fn), libc.Uint64FromInt64(**(**Ti64)(__ccgo_up(bp + 16))-iOut)) + iOut = **(**Ti64)(__ccgo_up(bp + 16)) + if **(**int32)(__ccgo_up(bp)) >= 0 && **(**Ti64)(__ccgo_up(bp + 8)) == **(**Ti64)(__ccgo_up(bp + 16)) { + _fts5NextRowid(tls, p1, bp, bp+8) + } + _fts5NextRowid(tls, p2, bp+4, bp+16) + } + } + _fts5BufferSwap(tls, bp+24, p1) + _sqlite3Fts5BufferFree(tls, bp+24) +} + +// C documentation +// +// /* +// ** This function is used by xCreateTokenizer_v2() and xCreateTokenizer(). +// ** It allocates and partially populates a new Fts5TokenizerModule object. +// ** The new object is already linked into the Fts5Global context before +// ** returning. +// ** +// ** If successful, SQLITE_OK is returned and a pointer to the new +// ** Fts5TokenizerModule object returned via output parameter (*ppNew). All +// ** that is required is for the caller to fill in the methods in +// ** Fts5TokenizerModule.x1 and x2, and to set Fts5TokenizerModule.bV2Native +// ** as appropriate. +// ** +// ** If an error occurs, an SQLite error code is returned and the final value +// ** of (*ppNew) undefined. +// */ +func _fts5NewTokenizerModule(tls *libc.TLS, pGlobal uintptr, zName uintptr, pUserData uintptr, __ccgo_fp_xDestroy uintptr, ppNew uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte, nName Tsqlite3_int64 + var pNew, v1 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _ = nByte, nName, pNew, v1 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Bytes of space to allocate */ + nName = libc.Int64FromUint64(libc.Xstrlen(tls, zName) + uint64(1)) + nByte = libc.Int64FromUint64(uint64(96) + libc.Uint64FromInt64(nName)) + v1 = _sqlite3Fts5MallocZero(tls, bp, nByte) + pNew = v1 + **(**uintptr)(__ccgo_up(ppNew)) = v1 + if pNew != 0 { + (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FzName = pNew + 1*96 + libc.X__builtin___memcpy_chk(tls, (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FzName, zName, libc.Uint64FromInt64(nName), ^t__predefined_size_t(0)) + (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FpUserData = pUserData + (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FxDestroy = __ccgo_fp_xDestroy + (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FpNext = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpTok + (*TFts5Global)(unsafe.Pointer(pGlobal)).FpTok = pNew + if (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FpNext == uintptr(0) { + (*TFts5Global)(unsafe.Pointer(pGlobal)).FpDfltTok = pNew + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Implementation of xOpen method. +// */ +func _fts5OpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) (r int32) { + var nByte Tsqlite3_int64 + var pConfig, pCsr, pGlobal, pTab, v2 uintptr + var rc int32 + var v1 Ti64 + _, _, _, _, _, _, _, _ = nByte, pConfig, pCsr, pGlobal, pTab, rc, v1, v2 + pTab = pVTab + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + pCsr = uintptr(0) /* Return code */ + rc = _fts5NewTransaction(tls, pTab) + if rc == SQLITE_OK { + nByte = libc.Int64FromUint64(uint64(184) + libc.Uint64FromInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*uint64(4)) + pCsr = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pCsr != 0 { + pGlobal = (*TFts5FullTable)(unsafe.Pointer(pTab)).FpGlobal + libc.X__builtin___memset_chk(tls, pCsr, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize = pCsr + 1*184 + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpNext = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpCsr + (*TFts5Global)(unsafe.Pointer(pGlobal)).FpCsr = pCsr + v2 = pGlobal + 56 + *(*Ti64)(unsafe.Pointer(v2)) = *(*Ti64)(unsafe.Pointer(v2)) + 1 + v1 = *(*Ti64)(unsafe.Pointer(v2)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId = v1 + } else { + rc = int32(SQLITE_NOMEM) + } + } + **(**uintptr)(__ccgo_up(ppCsr)) = pCsr + return rc +} + +// C documentation +// +// /* +// ** Callback for tokenizing terms used by ParseTerm(). +// */ +func _fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var SZALLOC, nNew, v1 int32 + var nByte Tsqlite3_int64 + var pCtx, pNew, pPhrase, pSyn, pTerm, v3 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = SZALLOC, nByte, nNew, pCtx, pNew, pPhrase, pSyn, pTerm, v1, v3 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + SZALLOC = int32(8) + pCtx = pContext + pPhrase = (*TTokenCtx)(unsafe.Pointer(pCtx)).FpPhrase + _ = iUnused1 + _ = iUnused2 + /* If an error has already occurred, this is a no-op */ + if (*TTokenCtx)(unsafe.Pointer(pCtx)).Frc != SQLITE_OK { + return (*TTokenCtx)(unsafe.Pointer(pCtx)).Frc + } + if nToken > int32(FTS5_MAX_TOKEN_SIZE) { + nToken = int32(FTS5_MAX_TOKEN_SIZE) + } + if pPhrase != 0 && (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0 && tflags&int32(FTS5_TOKEN_COLOCATED) != 0 { + nByte = libc.Int64FromUint64(libc.Uint64FromInt64(40) + libc.Uint64FromInt64(16) + libc.Uint64FromInt32(nToken) + uint64(1)) + pSyn = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pSyn == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pSyn, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpTerm = pSyn + uintptr(40) + uintptr(16) + v1 = nToken + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FnQueryTerm = v1 + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FnFullTerm = v1 + if (*TFts5Config)(unsafe.Pointer((*TTokenCtx)(unsafe.Pointer(pCtx)).FpConfig)).FbTokendata != 0 { + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FnQueryTerm = libc.Int32FromUint64(libc.Xstrlen(tls, (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpTerm)) + } + libc.X__builtin___memcpy_chk(tls, (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpTerm, pToken, libc.Uint64FromInt32(nToken), ^t__predefined_size_t(0)) + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpSynonym = (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32 + uintptr((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm-int32(1))*40))).FpSynonym + (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32 + uintptr((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm-int32(1))*40))).FpSynonym = pSyn + } + } else { + if pPhrase == uintptr(0) || (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm%SZALLOC == 0 { + if pPhrase != 0 { + v1 = (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm + } else { + v1 = 0 + } + nNew = SZALLOC + v1 + pNew = Xsqlite3_realloc64(tls, pPhrase, uint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(nNew+libc.Int32FromInt32(1))*libc.Uint64FromInt64(40))) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + if pPhrase == uintptr(0) { + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(40), ^t__predefined_size_t(0)) + } + v3 = pNew + pPhrase = v3 + (*TTokenCtx)(unsafe.Pointer(pCtx)).FpPhrase = v3 + (*TFts5ExprPhrase)(unsafe.Pointer(pNew)).FnTerm = nNew - SZALLOC + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + v3 = pPhrase + 24 + v1 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + pTerm = pPhrase + 32 + uintptr(v1)*40 + libc.X__builtin___memset_chk(tls, pTerm, 0, uint64(40), ^t__predefined_size_t(0)) + (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpTerm = _sqlite3Fts5Strndup(tls, bp, pToken, nToken) + v1 = nToken + (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FnQueryTerm = v1 + (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FnFullTerm = v1 + if (*TFts5Config)(unsafe.Pointer((*TTokenCtx)(unsafe.Pointer(pCtx)).FpConfig)).FbTokendata != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FnQueryTerm = libc.Int32FromUint64(libc.Xstrlen(tls, (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpTerm)) + } + } + } + (*TTokenCtx)(unsafe.Pointer(pCtx)).Frc = **(**int32)(__ccgo_up(bp)) + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5PorterCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken int32, iStart int32, iEnd int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aBuf, p uintptr + var c int8 + var v1 int32 + var _ /* nBuf at bp+0 */ int32 + _, _, _, _ = aBuf, c, p, v1 + p = pCtx + if nToken > int32(FTS5_PORTER_MAX_TOKEN) || nToken < int32(3) { + goto pass_through + } + aBuf = (*TPorterContext)(unsafe.Pointer(p)).FaBuf + **(**int32)(__ccgo_up(bp)) = nToken + libc.X__builtin___memcpy_chk(tls, aBuf, pToken, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))), ^t__predefined_size_t(0)) + /* Step 1. */ + _fts5PorterStep1A(tls, aBuf, bp) + if _fts5PorterStep1B(tls, aBuf, bp) != 0 { + if _fts5PorterStep1B2(tls, aBuf, bp) == 0 { + c = **(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1)))) + if _fts5PorterIsVowel(tls, c, 0) == 0 && int32(c) != int32('l') && int32(c) != int32('s') && int32(c) != int32('z') && int32(c) == int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(2))))) { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } else { + if _fts5Porter_MEq1(tls, aBuf, **(**int32)(__ccgo_up(bp))) != 0 && _fts5Porter_Ostar(tls, aBuf, **(**int32)(__ccgo_up(bp))) != 0 { + v1 = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(aBuf + uintptr(v1))) = int8('e') + } + } + } + } + /* Step 1C. */ + if int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('y') && _fts5Porter_Vowel(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 { + **(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1)))) = int8('i') + } + /* Steps 2 through 4. */ + _fts5PorterStep2(tls, aBuf, bp) + _fts5PorterStep3(tls, aBuf, bp) + _fts5PorterStep4(tls, aBuf, bp) + /* Step 5a. */ + if int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('e') { + if _fts5Porter_MGt1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 || _fts5Porter_MEq1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 && !(_fts5Porter_Ostar(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0) { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } + } + /* Step 5b. */ + if **(**int32)(__ccgo_up(bp)) > int32(1) && int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('l') && int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(2))))) == int32('l') && _fts5Porter_MGt1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } + return (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterContext)(unsafe.Pointer(p)).FxToken})))(tls, (*TPorterContext)(unsafe.Pointer(p)).FpCtx, tflags, aBuf, **(**int32)(__ccgo_up(bp)), iStart, iEnd) + goto pass_through +pass_through: + ; + return (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterContext)(unsafe.Pointer(p)).FxToken})))(tls, (*TPorterContext)(unsafe.Pointer(p)).FpCtx, tflags, pToken, nToken, iStart, iEnd) + return r +} + +// C documentation +// +// /* +// ** Create a "porter" tokenizer. +// */ +func _fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var az2, pApi, pRet, zBase, v2 uintptr + var nArg2, rc, v1 int32 + var _ /* pUserdata at bp+0 */ uintptr + var _ /* pV2 at bp+8 */ uintptr + _, _, _, _, _, _, _, _ = az2, nArg2, pApi, pRet, rc, zBase, v1, v2 + pApi = pCtx + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zBase = __ccgo_ts + 42214 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + for nArg > 0 { + if Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg)), __ccgo_ts+42224) == 0 { + nArg = nArg - 1 + azArg += 8 + } else { + zBase = **(**uintptr)(__ccgo_up(azArg)) + break + } + } + pRet = Xsqlite3_malloc64(tls, uint64(168)) + if pRet != 0 { + libc.X__builtin___memset_chk(tls, pRet, 0, uint64(168), ^t__predefined_size_t(0)) + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfts5_api)(unsafe.Pointer(pApi)).FxFindTokenizer_v2})))(tls, pApi, zBase, bp, bp+8) + } else { + rc = int32(SQLITE_NOMEM) + } + if rc == SQLITE_OK { + if nArg > 0 { + v1 = nArg - int32(1) + } else { + v1 = 0 + } + nArg2 = v1 + if nArg2 != 0 { + v2 = azArg + 1*8 + } else { + v2 = uintptr(0) + } + az2 = v2 + libc.X__builtin___memcpy_chk(tls, pRet, **(**uintptr)(__ccgo_up(bp + 8)), uint64(32), ^t__predefined_size_t(0)) + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterTokenizer)(unsafe.Pointer(pRet)).Ftokenizer_v2.FxCreate})))(tls, **(**uintptr)(__ccgo_up(bp)), az2, nArg2, pRet+32) + } + if rc != SQLITE_OK { + _fts5PorterDelete(tls, pRet) + pRet = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppOut)) = pRet + return rc +} + +func _fts5PorterStep1B(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('e'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42496, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+42500, uint64(2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(2) + } + } else { + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42503, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_Vowel(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + ret = int32(1) + } + } + } + case int32('n'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42506, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_Vowel(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + ret = int32(1) + } + } + break + } + return ret +} + +/* +** GENERATED CODE ENDS HERE (mkportersteps.tcl) +*************************************************************************** +**************************************************************************/ + +func _fts5PorterStep1B2(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42310, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+42290, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + case int32('b'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42313, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+42316, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + case int32('i'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42320, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+42306, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + break + } + return ret +} + +func _fts5PorterStep2(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42323, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+42290, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(6) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42331, aBuf+uintptr(nBuf-int32(6)), uint64(6)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(6)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(6)), __ccgo_ts+42338, uint64(4), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(6) + int32(4) + } + } + } + case int32('c'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42343, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+42239, uint64(4), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42348, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+42234, uint64(4), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(4) + } + } + } + case int32('e'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42353, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+42306, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + case int32('g'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42358, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+17509, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + case int32('l'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42363, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+42316, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(3) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42367, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+42231, uint64(2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42372, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42275, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42378, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+42382, uint64(1), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(1) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42384, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42298, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } + } + } + } + } + case int32('o'): + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42390, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+42306, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42398, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42290, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42404, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+42290, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + } + } + case int32('s'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42409, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42231, uint64(2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42415, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+42302, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42423, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+42431, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42435, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+42298, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } + } + } + } + case int32('t'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42443, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42231, uint64(2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42449, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42302, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(6) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42455, aBuf+uintptr(nBuf-int32(6)), uint64(6)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(6)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(6)), __ccgo_ts+42316, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(6) + int32(3) + } + } + } + } + break + } + return ret +} + +func _fts5PorterStep3(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42462, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+42247, uint64(2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(2) + } + } + case int32('s'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42467, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + case int32('t'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42472, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42247, uint64(2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42478, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42247, uint64(2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } + } + case int32('u'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42431, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('v'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42484, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + } + } + case int32('z'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42490, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+42231, uint64(2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } + break + } + return ret +} + +func _fts5PorterStep4(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42231, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('c'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42234, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42239, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + } + case int32('e'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42244, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('i'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42247, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('l'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42250, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42255, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + } + case int32('n'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42260, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42264, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(5)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42270, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42275, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + } + } + } + case int32('o'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42279, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1_and_S_or_T(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42283, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + } + case int32('s'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42286, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('t'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42290, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42294, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + } + case int32('u'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42298, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('v'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42302, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('z'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42306, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + break + } + return ret +} + +// C documentation +// +// /* +// ** Return a "position-list blob" corresponding to the current position of +// ** cursor pCsr via sqlite3_result_blob(). A position-list blob contains +// ** the current position-list for each phrase in the query associated with +// ** cursor pCsr. +// ** +// ** A position-list blob begins with (nPhrase-1) varints, where nPhrase is +// ** the number of phrases in the query. Following the varints are the +// ** concatenated position lists for each phrase, in order. +// ** +// ** The first varint (if it exists) contains the size of the position list +// ** for phrase 0. The second (same disclaimer) contains the size of position +// ** list 1. And so on. There is no size field for the final position list, +// ** as it can be derived from the total size of the blob. +// */ +func _fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var i, nByte, nPhrase, nPoslist int32 + var _ /* dummy at bp+24 */ uintptr + var _ /* dummy at bp+40 */ uintptr + var _ /* nByte at bp+48 */ int32 + var _ /* nPoslist at bp+64 */ int32 + var _ /* pPoslist at bp+32 */ uintptr + var _ /* pPoslist at bp+56 */ uintptr + var _ /* rc at bp+0 */ int32 + var _ /* val at bp+8 */ TFts5Buffer + _, _, _, _ = i, nByte, nPhrase, nPoslist + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + nPhrase = _sqlite3Fts5ExprPhraseCount(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(16), ^t__predefined_size_t(0)) + switch (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FeDetail { + case FTS5_DETAIL_FULL: + goto _1 + case int32(FTS5_DETAIL_COLUMNS): + goto _2 + default: + goto _3 + } + goto _4 +_1: + ; + /* Append the varints */ + i = 0 +_7: + ; + if !(i < nPhrase-int32(1)) { + goto _5 + } + nByte = _sqlite3Fts5ExprPoslist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+24) + _sqlite3Fts5BufferAppendVarint(tls, bp, bp+8, int64(nByte)) + goto _6 +_6: + ; + i = i + 1 + goto _7 + goto _5 +_5: + ; + /* Append the position lists */ + i = 0 + for { + if !(i < nPhrase) { + break + } + nPoslist = _sqlite3Fts5ExprPoslist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+32) + _sqlite3Fts5BufferAppendBlob(tls, bp, bp+8, libc.Uint32FromInt32(nPoslist), **(**uintptr)(__ccgo_up(bp + 32))) + goto _8 + _8: + ; + i = i + 1 + } + goto _4 +_2: + ; + /* Append the varints */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < nPhrase-int32(1)) { + break + } + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ExprPhraseCollist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+40, bp+48) + _sqlite3Fts5BufferAppendVarint(tls, bp, bp+8, int64(**(**int32)(__ccgo_up(bp + 48)))) + goto _9 + _9: + ; + i = i + 1 + } + /* Append the position lists */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < nPhrase) { + break + } + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ExprPhraseCollist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+56, bp+64) + _sqlite3Fts5BufferAppendBlob(tls, bp, bp+8, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 64))), **(**uintptr)(__ccgo_up(bp + 56))) + goto _10 + _10: + ; + i = i + 1 + } + goto _4 +_3: + ; + goto _4 +_4: + ; + Xsqlite3_result_blob(tls, pCtx, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fn, __ccgo_fp(Xsqlite3_free)) + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5PoslistCallback(tls *libc.TLS, pUnused uintptr, pContext uintptr, pChunk uintptr, nChunk int32) { + _ = pUnused + if nChunk > 0 { + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(pContext)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pContext)).Fn), pChunk, libc.Uint64FromInt32(nChunk), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pContext + 8)) += nChunk + } +} + +func _fts5PoslistFilterCallback(tls *libc.TLS, pUnused uintptr, pContext uintptr, pChunk uintptr, nChunk int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iEnd, iStart, v1 int32 + var pCtx uintptr + var _ /* iCol at bp+0 */ int32 + var _ /* iCol at bp+4 */ int32 + _, _, _, _, _ = i, iEnd, iStart, pCtx, v1 + pCtx = pContext + _ = pUnused + if nChunk > 0 { + /* Search through to find the first varint with value 1. This is the + ** start of the next columns hits. */ + i = 0 + iStart = 0 + if (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState == int32(2) { + v1 = i + i = i + 1 + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pChunk + uintptr(v1)))) + if **(**int32)(__ccgo_up(bp))&int32(0x80) != 0 { + i = i - 1 + i = i + _sqlite3Fts5GetVarint32(tls, pChunk+uintptr(i), bp) + } + if _fts5IndexColsetTest(tls, (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpColset, **(**int32)(__ccgo_up(bp))) != 0 { + (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = int32(1) + **(**int32)(__ccgo_up((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), libc.Uint64FromInt32(libc.Int32FromInt32(1))) + } else { + (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = 0 + } + } + for cond := true; cond; cond = i < nChunk { + for i < nChunk && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pChunk + uintptr(i)))) != int32(0x01) { + iEnd = i + int32(9) + for { + v1 = i + i = i + 1 + if !(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pChunk + uintptr(v1))))&int32(0x80) != 0 && i < iEnd) { + break + } + } + } + if (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState != 0 { + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), pChunk+uintptr(iStart), libc.Uint64FromInt32(i-iStart), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 8)) += i - iStart + } + if i < nChunk { + iStart = i + i = i + 1 + if i >= nChunk { + (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = int32(2) + } else { + v1 = i + i = i + 1 + **(**int32)(__ccgo_up(bp + 4)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pChunk + uintptr(v1)))) + if **(**int32)(__ccgo_up(bp + 4))&int32(0x80) != 0 { + i = i - 1 + i = i + _sqlite3Fts5GetVarint32(tls, pChunk+uintptr(i), bp+4) + } + (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = _fts5IndexColsetTest(tls, (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpColset, **(**int32)(__ccgo_up(bp + 4))) + if (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState != 0 { + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), pChunk+uintptr(iStart), libc.Uint64FromInt32(i-iStart), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 8)) += i - iStart + iStart = i + } + } + } + } + } +} + +// C documentation +// +// /* +// ** Execute the SQL statement: +// ** +// ** DELETE FROM %_idx WHERE (segid, (pgno/2)) = ($iSegid, $iPgno); +// ** +// ** This is used when a secure-delete operation removes the last term +// ** from a segment leaf page. In that case the %_idx entry is removed +// ** too. This is done to ensure that if all instances of a token are +// ** removed from an fts5 database in secure-delete mode, no trace of +// ** the token itself remains in the database. +// */ +func _fts5SecureDeleteIdxEntry(tls *libc.TLS, p uintptr, iSegid int32, iPgno int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + if iPgno != int32(1) { + if (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx == uintptr(0) { + _fts5IndexPrepareStmt(tls, p, p+136, Xsqlite3_mprintf(tls, __ccgo_ts+39705, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FzDb, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FzName))) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_bind_int(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx, int32(1), iSegid) + Xsqlite3_bind_int(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx, int32(2), iPgno) + Xsqlite3_step(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx) + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx) + } + } +} + +// C documentation +// +// /* +// ** This is called when a secure-delete operation removes a position-list +// ** that overflows onto segment page iPgno of segment pSeg. This function +// ** rewrites node iPgno, and possibly one or more of its right-hand peers, +// ** to remove this portion of the position list. +// ** +// ** Output variable (*pbLastInDoclist) is set to true if the position-list +// ** removed is followed by a new term or the end-of-segment, or false if +// ** it is followed by another rowid/position list. +// */ +func _fts5SecureDeleteOverflow(tls *libc.TLS, p uintptr, pSeg uintptr, iPgno int32, pbLastInDoclist uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aIdx, aPg, pLeaf uintptr + var bDetailNone, i1, i2, nIdx, nPg, nShift, pgno int32 + var iRowid Ti64 + var _ /* aEmpty at bp+4 */ [4]Tu8 + var _ /* iFirst at bp+8 */ int32 + var _ /* iNext at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = aIdx, aPg, bDetailNone, i1, i2, iRowid, nIdx, nPg, nShift, pLeaf, pgno + bDetailNone = libc.BoolInt32((*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == libc.Int32FromInt32(FTS5_DETAIL_NONE)) + pLeaf = uintptr(0) + **(**int32)(__ccgo_up(pbLastInDoclist)) = int32(1) + pgno = iPgno + for { + if !((*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && pgno <= (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast) { + break + } + iRowid = int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf || (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn < (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf || **(**int32)(__ccgo_up(bp)) < int32(4) { + _fts5IndexCorruptRowid(tls, p, iRowid) + break + } else { + nShift = **(**int32)(__ccgo_up(bp)) - int32(4) + nIdx = 0 + aIdx = uintptr(0) + /* Unless the current page footer is 0 bytes in size (in which case + ** the new page footer will be as well), allocate and populate a + ** buffer containing the new page footer. Set stack variables aIdx + ** and nIdx accordingly. */ + if (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn > (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + **(**int32)(__ccgo_up(bp + 8)) = 0 + i1 = (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf + i2 = 0 + i1 = i1 + _sqlite3Fts5GetVarint32(tls, aPg+uintptr(i1), bp+8) + if **(**int32)(__ccgo_up(bp + 8)) < **(**int32)(__ccgo_up(bp)) { + _fts5IndexCorruptRowid(tls, p, iRowid) + break + } + aIdx = _sqlite3Fts5MallocZero(tls, p+60, int64((*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn-(*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf+int32(2))) + if aIdx == uintptr(0) { + break + } + i2 = _sqlite3Fts5PutVarint(tls, aIdx, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 8))-nShift)) + if i1 < (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn { + libc.X__builtin___memcpy_chk(tls, aIdx+uintptr(i2), aPg+uintptr(i1), libc.Uint64FromInt32((*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn-i1), ^t__predefined_size_t(0)) + i2 = i2 + ((*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn - i1) + } + nIdx = i2 + } + /* Modify the contents of buffer aPg[]. Set nPg to the new size + ** in bytes. The new page is always smaller than the old. */ + nPg = (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf - nShift + libc.X__builtin___memmove_chk(tls, aPg+4, aPg+uintptr(int32(4)+nShift), libc.Uint64FromInt32(nPg-int32(4)), ^t__predefined_size_t(0)) + _fts5PutU16(tls, aPg+2, libc.Uint16FromInt32(nPg)) + if _fts5GetU16(tls, aPg) != 0 { + _fts5PutU16(tls, aPg, uint16(4)) + } + if nIdx > 0 { + libc.X__builtin___memcpy_chk(tls, aPg+uintptr(nPg), aIdx, libc.Uint64FromInt32(nIdx), ^t__predefined_size_t(0)) + nPg = nPg + nIdx + } + Xsqlite3_free(tls, aIdx) + /* Write the new page to disk and exit the loop */ + _fts5DataWrite(tls, p, iRowid, aPg, nPg) + break + } + } + } + goto _1 + _1: + ; + pgno = pgno + 1 + } + _fts5DataRelease(tls, pLeaf) +} + +// C documentation +// +// /* +// ** If the cursor requires seeking (bSeekRequired flag is set), seek it. +// ** Return SQLITE_OK if no error occurs, or an SQLite error code otherwise. +// ** +// ** If argument bErrormsg is true and an error occurs, an error message may +// ** be left in sqlite3_vtab.zErrMsg. +// */ +func _fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eStmt, rc int32 + var pTab, pTab1, v1 uintptr + _, _, _, _, _ = eStmt, pTab, pTab1, rc, v1 + rc = SQLITE_OK + /* If the cursor does not yet have a statement handle, obtain one now. */ + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt == uintptr(0) { + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + eStmt = _fts5StmtType(tls, pCsr) + if bErrormsg != 0 { + v1 = pTab + 16 + } else { + v1 = uintptr(0) + } + rc = _sqlite3Fts5StorageStmt(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, eStmt, pCsr+56, v1) + } + if rc == SQLITE_OK && (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_CONTENT) != 0 { + pTab1 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + Xsqlite3_reset(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + Xsqlite3_bind_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1), _fts5CursorRowid(tls, pCsr)) + (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab1)).FpConfig)).FbLock = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab1)).FpConfig)).FbLock + 1 + rc = Xsqlite3_step(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab1)).FpConfig)).FbLock = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab1)).FpConfig)).FbLock - 1 + if rc == int32(SQLITE_ROW) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(pCsr + 80)) &= ^libc.Int32FromInt32(FTS5CSR_REQUIRE_CONTENT) + } else { + rc = Xsqlite3_reset(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + if rc == SQLITE_OK { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<pLeaf==0) and assume the iterator is + ** at EOF already. */ + return + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + libc.X__builtin___memset_chk(tls, pIter, 0, uint64(128), ^t__predefined_size_t(0)) + _fts5SegIterSetNext(tls, p, pIter) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst - int32(1) + for cond := true; cond; cond = (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 && (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn == int32(4) { + _fts5SegIterNextPage(tls, p, pIter) + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(4) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + int32(1) + _fts5SegIterLoadTerm(tls, p, pIter, 0) + _fts5SegIterLoadNPos(tls, p, pIter) + _fts5SegIterAllocTombstone(tls, p, pIter) + } +} + +// C documentation +// +// /* +// ** This is similar to fts5SegIterSeekInit(), except that it initializes +// ** the segment iterator to point to the first term following the page +// ** with pToken/nToken on it. +// */ +func _fts5SegIterNextInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, pSeg uintptr, pIter uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, pSel uintptr + var bDlidx, iPg int32 + var val Ti64 + var _ /* iTermOff at bp+0 */ int32 + _, _, _, _, _ = a, bDlidx, iPg, pSel, val + iPg = -int32(1) /* Page of segment to open */ + bDlidx = 0 + pSel = uintptr(0) /* SELECT to find iPg */ + pSel = _fts5IdxNextStmt(tls, p) + if pSel != 0 { + Xsqlite3_bind_int(tls, pSel, int32(1), (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid) + Xsqlite3_bind_blob(tls, pSel, int32(2), pTerm, nTerm, libc.UintptrFromInt32(0)) + if Xsqlite3_step(tls, pSel) == int32(SQLITE_ROW) { + val = Xsqlite3_column_int64(tls, pSel, 0) + iPg = int32(val >> libc.Int32FromInt32(1)) + bDlidx = int32(val & libc.Int64FromInt32(0x0001)) + } + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, pSel) + Xsqlite3_bind_null(tls, pSel, int32(2)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + } + libc.X__builtin___memset_chk(tls, pIter, 0, uint64(128), ^t__predefined_size_t(0)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_ONETERM) + if iPg >= 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iPg - int32(1) + _fts5SegIterNextPage(tls, p, pIter) + _fts5SegIterSetNext(tls, p, pIter) + } + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + **(**int32)(__ccgo_up(bp)) = 0 + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + **(**int32)(__ccgo_up(pIter + 64)) += _sqlite3Fts5GetVarint32(tls, a+uintptr((*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff), bp) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(**(**int32)(__ccgo_up(bp))) + _fts5SegIterLoadTerm(tls, p, pIter, 0) + _fts5SegIterLoadNPos(tls, p, pIter) + if bDlidx != 0 { + _fts5SegIterLoadDlidx(tls, p, pIter) + } + } +} + +// C documentation +// +// /* +// ** Initialize the object pIter to point to term pTerm/nTerm within segment +// ** pSeg. If there is no such term in the index, the iterator is set to EOF. +// ** +// ** If an error occurs, Fts5Index.rc is set to an appropriate error code. If +// ** an error has already occurred when this function is called, it is a no-op. +// */ +func _fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, flags int32, pSeg uintptr, pIter uintptr) { + var bDlidx, bGe, iPg int32 + var pIdxSelect uintptr + var val Ti64 + _, _, _, _, _ = bDlidx, bGe, iPg, pIdxSelect, val + iPg = int32(1) + bGe = flags & int32(FTS5INDEX_QUERY_SCAN) + bDlidx = 0 /* True if there is a doclist-index */ + pIdxSelect = uintptr(0) + libc.X__builtin___memset_chk(tls, pIter, 0, uint64(128), ^t__predefined_size_t(0)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg + /* This block sets stack variable iPg to the leaf page number that may + ** contain term (pTerm/nTerm), if it is present in the segment. */ + pIdxSelect = _fts5IdxSelectStmt(tls, p) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + Xsqlite3_bind_int(tls, pIdxSelect, int32(1), (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid) + Xsqlite3_bind_blob(tls, pIdxSelect, int32(2), pTerm, nTerm, libc.UintptrFromInt32(0)) + if int32(SQLITE_ROW) == Xsqlite3_step(tls, pIdxSelect) { + val = int64(Xsqlite3_column_int(tls, pIdxSelect, 0)) + iPg = int32(val >> libc.Int32FromInt32(1)) + bDlidx = int32(val & libc.Int64FromInt32(0x0001)) + } + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, pIdxSelect) + Xsqlite3_bind_null(tls, pIdxSelect, int32(2)) + if iPg < (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { + iPg = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst + bDlidx = 0 + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iPg - int32(1) + _fts5SegIterNextPage(tls, p, pIter) + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + _fts5LeafSeek(tls, p, bGe, pIter, pTerm, nTerm) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (bGe == 0 || flags&int32(FTS5INDEX_QUERY_SCANONETERM) != 0) { + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_ONETERM) + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + if flags&int32(FTS5INDEX_QUERY_DESC) != 0 { + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_REVERSE) + } + if bDlidx != 0 { + _fts5SegIterLoadDlidx(tls, p, pIter) + } + if flags&int32(FTS5INDEX_QUERY_DESC) != 0 { + _fts5SegIterReverse(tls, p, pIter) + } + } + } + _fts5SegIterSetNext(tls, p, pIter) + if 0 == flags&int32(FTS5INDEX_QUERY_SCANONETERM) { + _fts5SegIterAllocTombstone(tls, p, pIter) + } + /* Either: + ** + ** 1) an error has occurred, or + ** 2) the iterator points to EOF, or + ** 3) the iterator points to an entry with term (pTerm/nTerm), or + ** 4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points + ** to an entry with a term greater than or equal to (pTerm/nTerm). + */ +} + +// C documentation +// +// /* +// ** Iterator pIter currently points to a valid entry (not EOF). This +// ** function appends the position list data for the current entry to +// ** buffer pBuf. It does not make a copy of the position-list size +// ** field. +// */ +func _fts5SegiterPoslist(tls *libc.TLS, p uintptr, pSeg uintptr, pColset uintptr, pBuf uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var v1 int32 + var _ /* sCtx at bp+0 */ TPoslistCallbackCtx + var _ /* sCtx at bp+24 */ TPoslistOffsetsCtx + _ = v1 + if libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)+libc.Uint32FromInt32((*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos+libc.Int32FromInt32(FTS5_DATA_ZERO_PADDING)) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) { + v1 = 0 + } else { + v1 = _sqlite3Fts5BufferSize(tls, p+60, pBuf, libc.Uint32FromInt32((*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos+int32(FTS5_DATA_ZERO_PADDING)+(*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + } + if 0 == v1 { + libc.X__builtin___memset_chk(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos), 0, uint64(FTS5_DATA_ZERO_PADDING), ^t__predefined_size_t(0)) + if pColset == uintptr(0) { + _fts5ChunkIterate(tls, p, pSeg, pBuf, __ccgo_fp(_fts5PoslistCallback)) + } else { + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_FULL { + (**(**TPoslistCallbackCtx)(__ccgo_up(bp))).FpBuf = pBuf + (**(**TPoslistCallbackCtx)(__ccgo_up(bp))).FpColset = pColset + (**(**TPoslistCallbackCtx)(__ccgo_up(bp))).FeState = _fts5IndexColsetTest(tls, pColset, 0) + _fts5ChunkIterate(tls, p, pSeg, bp, __ccgo_fp(_fts5PoslistFilterCallback)) + } else { + libc.X__builtin___memset_chk(tls, bp+24, 0, uint64(24), ^t__predefined_size_t(0)) + (**(**TPoslistOffsetsCtx)(__ccgo_up(bp + 24))).FpBuf = pBuf + (**(**TPoslistOffsetsCtx)(__ccgo_up(bp + 24))).FpColset = pColset + _fts5ChunkIterate(tls, p, pSeg, bp+24, __ccgo_fp(_fts5PoslistOffsetsCallback)) + } + } + } +} + +func _fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, iIdx int32, pToken uintptr, nToken int32, pColset uintptr, ppIter uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var i, iFree, v3 int32 + var pCtx, pData, pStruct uintptr + var _ /* s at bp+0 */ TPrefixSetupCtx + var _ /* s2 at bp+72 */ TTokendataSetupCtx + _, _, _, _, _, _ = i, iFree, pCtx, pData, pStruct, v3 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+72, 0, uint64(16), ^t__predefined_size_t(0)) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge = int32(1) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FiLastRowid = 0 + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnBuf = int32(32) + if iIdx == 0 && (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_FULL && (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FbPrefixInsttoken != 0 { + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FpTokendata = bp + 72 + (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT = _fts5IdxMalloc(tls, p, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+72)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(104))) + } + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxMerge = __ccgo_fp(_fts5MergeRowidLists) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxAppend = __ccgo_fp(_fts5AppendRowid) + } else { + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge = libc.Int32FromInt32(FTS5_MERGE_NLIST) - libc.Int32FromInt32(1) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnBuf = (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge * int32(8) /* Sufficient to merge (16^8)==(2^32) lists */ + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxMerge = __ccgo_fp(_fts5MergePrefixLists) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxAppend = __ccgo_fp(_fts5AppendPoslist) + } + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FaBuf = _fts5IdxMalloc(tls, p, libc.Int64FromUint64(uint64(16)*libc.Uint64FromInt32((**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnBuf))) + pStruct = _fts5StructureRead(tls, p) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pCtx = bp + /* If iIdx is non-zero, then it is the number of a prefix-index for + ** prefixes 1 character longer than the prefix being queried for. That + ** index contains all the doclists required, except for the one + ** corresponding to the prefix itself. That one is extracted from the + ** main term index here. */ + if iIdx != 0 { + **(**Tu8)(__ccgo_up(pToken)) = uint8('0') + _fts5VisitEntries(tls, p, pColset, pToken, nToken, 0, __ccgo_fp(_prefixIterSetupCb), pCtx) + } + **(**Tu8)(__ccgo_up(pToken)) = libc.Uint8FromInt32(int32('0') + iIdx) + _fts5VisitEntries(tls, p, pColset, pToken, nToken, int32(1), __ccgo_fp(_prefixIterSetupCb), pCtx) + i = 0 + for { + if !(i < (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnBuf) { + break + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxMerge})))(tls, p, bp+48, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FaBuf+uintptr(i)*16) + } + iFree = i + for { + if !(iFree < i+(**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge) { + break + } + _sqlite3Fts5BufferFree(tls, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FaBuf+uintptr(iFree)*16) + goto _2 + _2: + ; + iFree = iFree + 1 + } + goto _1 + _1: + ; + i = i + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge + } + pData = _fts5IdxMalloc(tls, p, libc.Int64FromUint64(uint64(16)+libc.Uint64FromInt64(int64((**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fn))+uint64(FTS5_DATA_ZERO_PADDING))) + if pData != 0 { + (*TFts5Data)(unsafe.Pointer(pData)).Fp = pData + 1*16 + v3 = (**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fn + (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf = v3 + (*TFts5Data)(unsafe.Pointer(pData)).Fnn = v3 + if (**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fn != 0 { + libc.X__builtin___memcpy_chk(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fp, libc.Uint64FromInt32((**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fn), ^t__predefined_size_t(0)) + } + _fts5MultiIterNew2(tls, p, pData, bDesc, ppIter) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FpTokendata != 0 { + _fts5TokendataIterSortMap(tls, p, (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT) + (*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppIter)))).FpTokenDataIter = (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT + (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT = uintptr(0) + } + } + _fts5TokendataIterDelete(tls, (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT) + _sqlite3Fts5BufferFree(tls, bp+48) + _fts5StructureRelease(tls, pStruct) + Xsqlite3_free(tls, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FaBuf) +} + +// C documentation +// +// /* +// ** pIter is a prefix query. This function populates pIter->pTokenDataIter +// ** with an Fts5TokenDataIter object containing mappings for all rows +// ** matched by the query. +// */ +func _fts5SetupPrefixIterTokendata(tls *libc.TLS, pIter uintptr, pToken uintptr, nToken int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p uintptr + var _ /* ctx at bp+16 */ TTokendataSetupCtx + var _ /* token at bp+0 */ TFts5Buffer + _ = p + p = (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex + **(**TFts5Buffer)(__ccgo_up(bp)) = TFts5Buffer{} + libc.X__builtin___memset_chk(tls, bp+16, 0, uint64(16), ^t__predefined_size_t(0)) + if !(libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(bp)).Fn)+libc.Uint32FromInt32(nToken+libc.Int32FromInt32(1)) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(bp)).FnSpace)) { + _sqlite3Fts5BufferSize(tls, p+60, bp, libc.Uint32FromInt32(nToken+int32(1)+(*TFts5Buffer)(unsafe.Pointer(bp)).Fn)) + } + (**(**TTokendataSetupCtx)(__ccgo_up(bp + 16))).FpT = _sqlite3Fts5MallocZero(tls, p+60, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+72)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(104))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* Fill in the token prefix to search for */ + **(**Tu8)(__ccgo_up((**(**TFts5Buffer)(__ccgo_up(bp))).Fp)) = uint8('0') + libc.X__builtin___memcpy_chk(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp+1, pToken, libc.Uint64FromInt32(nToken), ^t__predefined_size_t(0)) + (**(**TFts5Buffer)(__ccgo_up(bp))).Fn = nToken + int32(1) + _fts5VisitEntries(tls, p, uintptr(0), (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn, int32(1), __ccgo_fp(_prefixIterSetupTokendataCb), bp+16) + _fts5TokendataIterSortMap(tls, p, (**(**TTokendataSetupCtx)(__ccgo_up(bp + 16))).FpT) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter = (**(**TTokendataSetupCtx)(__ccgo_up(bp + 16))).FpT + } else { + _fts5TokendataIterDelete(tls, (**(**TTokendataSetupCtx)(__ccgo_up(bp + 16))).FpT) + } + _sqlite3Fts5BufferFree(tls, bp) + return _fts5IndexReturn(tls, p) +} + +// C documentation +// +// /* +// ** This function sets up an iterator to use for a non-prefix query on a +// ** tokendata=1 table. +// */ +func _fts5SetupTokendataIter(tls *libc.TLS, p uintptr, pToken uintptr, nToken int32, pColset uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bDone, flags, iLvl, iSeg, iSeg1, ii, ii1 int32 + var pII, pIter, pNew, pNewIter, pPrev, pPrevIter, pRet, pSeg, pSet, pSmall, pStruct, v1 uintptr + var _ /* bSeek at bp+0 */ TFts5Buffer + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bDone, flags, iLvl, iSeg, iSeg1, ii, ii1, pII, pIter, pNew, pNewIter, pPrev, pPrevIter, pRet, pSeg, pSet, pSmall, pStruct, v1 + pRet = uintptr(0) + pSet = uintptr(0) + pStruct = uintptr(0) + flags = libc.Int32FromInt32(FTS5INDEX_QUERY_SCANONETERM) | libc.Int32FromInt32(FTS5INDEX_QUERY_SCAN) + **(**TFts5Buffer)(__ccgo_up(bp)) = TFts5Buffer{} + pSmall = uintptr(0) + _fts5IndexFlush(tls, p) + pStruct = _fts5StructureRead(tls, p) + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if pSet != 0 { + v1 = *(*uintptr)(unsafe.Pointer(pSet + 72 + uintptr((*TFts5TokenDataIter)(unsafe.Pointer(pSet)).FnIter-int64(1))*8)) + } else { + v1 = uintptr(0) + } + pPrev = v1 + pNew = uintptr(0) + pNewIter = uintptr(0) + pPrevIter = uintptr(0) + pNew = _fts5MultiIterAlloc(tls, p, (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment) + if pSmall != 0 { + _sqlite3Fts5BufferSet(tls, p+60, bp, (*TFts5Buffer)(unsafe.Pointer(pSmall)).Fn, (*TFts5Buffer)(unsafe.Pointer(pSmall)).Fp) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, uint32(1), __ccgo_ts+39904) + } else { + _sqlite3Fts5BufferSet(tls, p+60, bp, nToken, pToken) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + _fts5IterClose(tls, pNew) + break + } + pNewIter = pNew + 104 + if pPrev != 0 { + v1 = pPrev + 104 + } else { + v1 = uintptr(0) + } + pPrevIter = v1 + iLvl = 0 + for { + if !(iLvl < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + iSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg - int32(1) + for { + if !(iSeg >= 0) { + break + } + pSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr(iSeg)*56 + bDone = 0 + if pPrevIter != 0 { + if _fts5BufferCompare(tls, pSmall, pPrevIter+96) != 0 { + libc.X__builtin___memcpy_chk(tls, pNewIter, pPrevIter, uint64(128), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, pPrevIter, 0, uint64(128), ^t__predefined_size_t(0)) + bDone = int32(1) + } else { + if (*TFts5SegIter)(unsafe.Pointer(pPrevIter)).FiEndofDoclist > (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pPrevIter)).FpLeaf)).FszLeaf { + _fts5SegIterNextInit(tls, p, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn-int32(1), pSeg, pNewIter) + bDone = int32(1) + } + } + } + if bDone == 0 { + _fts5SegIterSeekInit(tls, p, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn, flags, pSeg, pNewIter) + } + if pPrevIter != 0 { + if (*TFts5SegIter)(unsafe.Pointer(pPrevIter)).FpTombArray != 0 { + (*TFts5SegIter)(unsafe.Pointer(pNewIter)).FpTombArray = (*TFts5SegIter)(unsafe.Pointer(pPrevIter)).FpTombArray + (*TFts5TombstoneArray)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pNewIter)).FpTombArray)).FnRef = (*TFts5TombstoneArray)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pNewIter)).FpTombArray)).FnRef + 1 + } + } else { + _fts5SegIterAllocTombstone(tls, p, pNewIter) + } + pNewIter += 128 + if pPrevIter != 0 { + pPrevIter += 128 + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + goto _4 + _4: + ; + iSeg = iSeg - 1 + } + goto _3 + _3: + ; + iLvl = iLvl + 1 + } + _fts5TokendataSetTermIfEof(tls, pPrev, pSmall) + (*TFts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty = uint8(1) + (*TFts5Iter)(unsafe.Pointer(pNew)).FpColset = pColset + _fts5IterSetOutputCb(tls, p+60, pNew) + /* Loop through all segments in the new iterator. Find the smallest + ** term that any segment-iterator points to. Iterator pNew will be + ** used for this term. Also, set any iterator that points to a term that + ** does not match pToken/nToken to point to EOF */ + pSmall = uintptr(0) + ii = 0 + for { + if !(ii < (*TFts5Iter)(unsafe.Pointer(pNew)).FnSeg) { + break + } + pII = pNew + 104 + uintptr(ii)*128 + if 0 == _fts5IsTokendataPrefix(tls, pII+96, pToken, nToken) { + _fts5SegIterSetEOF(tls, pII) + } + if (*TFts5SegIter)(unsafe.Pointer(pII)).FpLeaf != 0 && (!(pSmall != 0) || _fts5BufferCompare(tls, pSmall, pII+96) > 0) { + pSmall = pII + 96 + } + goto _5 + _5: + ; + ii = ii + 1 + } + /* If pSmall is still NULL at this point, then the new iterator does + ** not point to any terms that match the query. So delete it and break + ** out of the loop - all required iterators have been collected. */ + if pSmall == uintptr(0) { + _fts5IterClose(tls, pNew) + break + } + /* Append this iterator to the set and continue. */ + pSet = _fts5AppendTokendataIter(tls, p, pSet, pNew) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && pSet != 0 { + ii1 = 0 + for { + if !(int64(ii1) < (*TFts5TokenDataIter)(unsafe.Pointer(pSet)).FnIter) { + break + } + pIter = *(*uintptr)(unsafe.Pointer(pSet + 72 + uintptr(ii1)*8)) + iSeg1 = 0 + for { + if !(iSeg1 < (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg) { + break + } + (*(*TFts5SegIter)(unsafe.Pointer(pIter + 104 + uintptr(iSeg1)*128))).Fflags |= int32(FTS5_SEGITER_ONETERM) + goto _7 + _7: + ; + iSeg1 = iSeg1 + 1 + } + _fts5MultiIterFinishSetup(tls, p, pIter) + goto _6 + _6: + ; + ii1 = ii1 + 1 + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pRet = _fts5MultiIterAlloc(tls, p, 0) + } + if pRet != 0 { + (*TFts5Iter)(unsafe.Pointer(pRet)).FnSeg = 0 + (*TFts5Iter)(unsafe.Pointer(pRet)).FpTokenDataIter = pSet + if pSet != 0 { + _fts5IterSetOutputsTokendata(tls, pRet) + } else { + (*TFts5Iter)(unsafe.Pointer(pRet)).Fbase.FbEof = uint8(1) + } + } else { + _fts5TokendataIterDelete(tls, pSet) + } + _fts5StructureRelease(tls, pStruct) + _sqlite3Fts5BufferFree(tls, bp) + return pRet +} + +// C documentation +// +// /* +// ** Implementation of snippet() function. +// */ +func _fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(208) + defer tls.Free(208) + var aSeen, zEllips, zErr uintptr + var i, iBestCol, iBestStart, iCol, ii, jj, nBestScore, nCol, nPhrase, nToken, v1 int32 + var _ /* ctx at bp+0 */ THighlightContext + var _ /* iAdj at bp+184 */ int32 + var _ /* ic at bp+176 */ int32 + var _ /* io at bp+180 */ int32 + var _ /* ip at bp+172 */ int32 + var _ /* nColSize at bp+112 */ int32 + var _ /* nDoc at bp+164 */ int32 + var _ /* nDocsize at bp+168 */ int32 + var _ /* nInst at bp+108 */ int32 + var _ /* nLoc at bp+160 */ int32 + var _ /* nLoc at bp+200 */ int32 + var _ /* nScore at bp+188 */ int32 + var _ /* pLoc at bp+152 */ uintptr + var _ /* pLoc at bp+192 */ uintptr + var _ /* rc at bp+104 */ int32 + var _ /* sFinder at bp+120 */ TFts5SFinder + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aSeen, i, iBestCol, iBestStart, iCol, ii, jj, nBestScore, nCol, nPhrase, nToken, zEllips, zErr, v1 + **(**int32)(__ccgo_up(bp + 104)) = SQLITE_OK /* 5th argument to snippet() */ + **(**int32)(__ccgo_up(bp + 108)) = 0 /* Column containing best snippet */ + iBestStart = 0 /* First token of best snippet */ + nBestScore = 0 /* Score of best snippet */ + **(**int32)(__ccgo_up(bp + 112)) = 0 + if nVal != int32(5) { + zErr = __ccgo_ts + 37526 + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + return + } + nCol = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnCount})))(tls, pFts) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(104), ^t__predefined_size_t(0)) + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apVal))) + (**(**THighlightContext)(__ccgo_up(bp))).FzOpen = _fts5ValueToText(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + (**(**THighlightContext)(__ccgo_up(bp))).FzClose = _fts5ValueToText(tls, **(**uintptr)(__ccgo_up(apVal + 2*8))) + (**(**THighlightContext)(__ccgo_up(bp))).FiRangeEnd = -int32(1) + zEllips = _fts5ValueToText(tls, **(**uintptr)(__ccgo_up(apVal + 3*8))) + nToken = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apVal + 4*8))) + if iCol >= 0 { + v1 = iCol + } else { + v1 = 0 + } + iBestCol = v1 + nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseCount})))(tls, pFts) + aSeen = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nPhrase)) + if aSeen == uintptr(0) { + **(**int32)(__ccgo_up(bp + 104)) = int32(SQLITE_NOMEM) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})))(tls, pFts, bp+108) + } + libc.X__builtin___memset_chk(tls, bp+120, 0, uint64(32), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < nCol) { + break + } + if iCol < 0 || iCol == i { + **(**uintptr)(__ccgo_up(bp + 152)) = uintptr(0) /* Locale of column iCol */ + **(**int32)(__ccgo_up(bp + 160)) = 0 + (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FiPos = 0 + (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FnFirst = 0 + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})))(tls, pFts, i, bp+120+24, bp+164) + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + break + } + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnLocale})))(tls, pFts, i, bp+152, bp+160) + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + break + } + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize_v2})))(tls, pFts, (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FzDoc, **(**int32)(__ccgo_up(bp + 164)), **(**uintptr)(__ccgo_up(bp + 152)), **(**int32)(__ccgo_up(bp + 160)), bp+120, __ccgo_fp(_fts5SentenceFinderCb)) + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + break + } + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})))(tls, pFts, i, bp+168) + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + break + } + ii = 0 + for { + if !(**(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK && ii < **(**int32)(__ccgo_up(bp + 108))) { + break + } + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})))(tls, pFts, ii, bp+172, bp+176, bp+180) + if **(**int32)(__ccgo_up(bp + 176)) != i { + goto _3 + } + if **(**int32)(__ccgo_up(bp + 180)) > **(**int32)(__ccgo_up(bp + 168)) { + **(**int32)(__ccgo_up(bp + 104)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< nBestScore { + nBestScore = **(**int32)(__ccgo_up(bp + 188)) + iBestCol = i + iBestStart = **(**int32)(__ccgo_up(bp + 184)) + **(**int32)(__ccgo_up(bp + 112)) = **(**int32)(__ccgo_up(bp + 168)) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK && (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FnFirst != 0 && **(**int32)(__ccgo_up(bp + 168)) > nToken { + jj = 0 + for { + if !(jj < (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FnFirst-int32(1)) { + break + } + if **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj+int32(1))*4)) > **(**int32)(__ccgo_up(bp + 180)) { + break + } + goto _4 + _4: + ; + jj = jj + 1 + } + if **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj)*4)) < **(**int32)(__ccgo_up(bp + 180)) { + libc.X__builtin___memset_chk(tls, aSeen, 0, libc.Uint64FromInt32(nPhrase), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp + 104)) = _fts5SnippetScore(tls, pApi, pFts, **(**int32)(__ccgo_up(bp + 168)), aSeen, i, **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj)*4)), nToken, bp+188, uintptr(0)) + if **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj)*4)) == 0 { + v1 = int32(120) + } else { + v1 = int32(100) + } + **(**int32)(__ccgo_up(bp + 188)) = **(**int32)(__ccgo_up(bp + 188)) + v1 + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK && **(**int32)(__ccgo_up(bp + 188)) > nBestScore { + nBestScore = **(**int32)(__ccgo_up(bp + 188)) + iBestCol = i + iBestStart = **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj)*4)) + **(**int32)(__ccgo_up(bp + 112)) = **(**int32)(__ccgo_up(bp + 168)) + } + } + } + goto _3 + _3: + ; + ii = ii + 1 + } + } + goto _2 + _2: + ; + i = i + 1 + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})))(tls, pFts, iBestCol, bp+24, bp+32) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK && **(**int32)(__ccgo_up(bp + 112)) == 0 { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})))(tls, pFts, iBestCol, bp+112) + } + if (**(**THighlightContext)(__ccgo_up(bp))).FzIn != 0 { + **(**uintptr)(__ccgo_up(bp + 192)) = uintptr(0) /* Locale of column iBestCol */ + **(**int32)(__ccgo_up(bp + 200)) = 0 /* Bytes in pLoc */ + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = _fts5CInstIterInit(tls, pApi, pFts, iBestCol, bp+40) + } + (**(**THighlightContext)(__ccgo_up(bp))).FiRangeStart = iBestStart + (**(**THighlightContext)(__ccgo_up(bp))).FiRangeEnd = iBestStart + nToken - int32(1) + if iBestStart > 0 { + _fts5HighlightAppend(tls, bp+104, bp, zEllips, -int32(1)) + } + /* Advance iterator ctx.iter so that it points to the first coalesced + ** phrase instance at or following position iBestStart. */ + for (**(**THighlightContext)(__ccgo_up(bp))).Fiter.FiStart >= 0 && (**(**THighlightContext)(__ccgo_up(bp))).Fiter.FiStart < iBestStart && **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = _fts5CInstIterNext(tls, bp+40) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnLocale})))(tls, pFts, iBestCol, bp+192, bp+200) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize_v2})))(tls, pFts, (**(**THighlightContext)(__ccgo_up(bp))).FzIn, (**(**THighlightContext)(__ccgo_up(bp))).FnIn, **(**uintptr)(__ccgo_up(bp + 192)), **(**int32)(__ccgo_up(bp + 200)), bp, __ccgo_fp(_fts5HighlightCb)) + } + if (**(**THighlightContext)(__ccgo_up(bp))).FbOpen != 0 { + _fts5HighlightAppend(tls, bp+104, bp, (**(**THighlightContext)(__ccgo_up(bp))).FzClose, -int32(1)) + } + if (**(**THighlightContext)(__ccgo_up(bp))).FiRangeEnd >= **(**int32)(__ccgo_up(bp + 112))-int32(1) { + _fts5HighlightAppend(tls, bp+104, bp, (**(**THighlightContext)(__ccgo_up(bp))).FzIn+uintptr((**(**THighlightContext)(__ccgo_up(bp))).FiOff), (**(**THighlightContext)(__ccgo_up(bp))).FnIn-(**(**THighlightContext)(__ccgo_up(bp))).FiOff) + } else { + _fts5HighlightAppend(tls, bp+104, bp, zEllips, -int32(1)) + } + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + Xsqlite3_result_text(tls, pCtx, (**(**THighlightContext)(__ccgo_up(bp))).FzOut, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_error_code(tls, pCtx, **(**int32)(__ccgo_up(bp + 104))) + } + Xsqlite3_free(tls, (**(**THighlightContext)(__ccgo_up(bp))).FzOut) + Xsqlite3_free(tls, aSeen) + Xsqlite3_free(tls, (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst) +} + +/************************************************************************/ + +// C documentation +// +// /* +// ** Implementation of fts5_source_id() function. +// */ +func _fts5SourceIdFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apUnused uintptr) { + _ = nArg + _ = apUnused + Xsqlite3_result_text(tls, pCtx, __ccgo_ts+40829, -int32(1), uintptr(-libc.Int32FromInt32(1))) +} + +// C documentation +// +// /* +// ** This function is called to handle an FTS INSERT command. In other words, +// ** an INSERT statement of the form: +// ** +// ** INSERT INTO fts(fts) VALUES($pCmd) +// ** INSERT INTO fts(fts, rank) VALUES($pCmd, $pVal) +// ** +// ** Argument pVal is the value assigned to column "fts" by the INSERT +// ** statement. This function returns SQLITE_OK if successful, or an SQLite +// ** error code if an error occurs. +// ** +// ** The commands implemented by this function are documented in the "Special +// ** INSERT Directives" section of the documentation. It should be updated if +// ** more commands are added to this function. +// */ +func _fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bLoadConfig, iArg, nMerge, rc int32 + var pConfig uintptr + var _ /* bError at bp+0 */ int32 + _, _, _, _, _ = bLoadConfig, iArg, nMerge, pConfig, rc + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp)) = 0 + bLoadConfig = 0 + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40318, zCmd) { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40329, 0) + rc = int32(SQLITE_ERROR) + } else { + rc = _sqlite3Fts5StorageDeleteAll(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage) + } + bLoadConfig = int32(1) + } else { + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40409, zCmd) { + if _fts5IsContentless(tls, pTab, int32(1)) != 0 { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40417, 0) + rc = int32(SQLITE_ERROR) + } else { + rc = _sqlite3Fts5StorageRebuild(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage) + } + bLoadConfig = int32(1) + } else { + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+18993, zCmd) { + rc = _sqlite3Fts5StorageOptimize(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage) + } else { + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40473, zCmd) { + nMerge = Xsqlite3_value_int(tls, pVal) + rc = _sqlite3Fts5StorageMerge(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, nMerge) + } else { + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40479, zCmd) { + iArg = Xsqlite3_value_int(tls, pVal) + rc = _sqlite3Fts5StorageIntegrity(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iArg) + } else { + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40495, zCmd) { + rc = _sqlite3Fts5FlushToDisk(tls, pTab) + } else { + rc = _sqlite3Fts5FlushToDisk(tls, pTab) + if rc == SQLITE_OK { + rc = _sqlite3Fts5IndexLoadConfig(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5ConfigSetValue(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig, zCmd, pVal, bp) + } + if rc == SQLITE_OK { + if **(**int32)(__ccgo_up(bp)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + rc = _sqlite3Fts5StorageConfigValue(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, zCmd, pVal, 0) + } + } + } + } + } + } + } + } + if rc == SQLITE_OK && bLoadConfig != 0 { + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FiCookie = (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FiCookie - 1 + rc = _sqlite3Fts5IndexLoadConfig(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) + } + return rc +} + +// C documentation +// +// /* +// ** Process a "special" query. A special query is identified as one with a +// ** MATCH expression that begins with a '*' character. The remainder of +// ** the text passed to the MATCH operator are used as the special query +// ** parameters. +// */ +func _fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var n, rc int32 + var z uintptr + _, _, _ = n, rc, z + rc = SQLITE_OK /* Return code */ + z = zQuery /* Number of bytes in text at z */ + for int32(**(**int8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + n = 0 + for { + if !(**(**int8)(__ccgo_up(z + uintptr(n))) != 0 && int32(**(**int8)(__ccgo_up(z + uintptr(n)))) != int32(' ')) { + break + } + goto _1 + _1: + ; + n = n + 1 + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SPECIAL) + if n == int32(5) && 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+40139, z, n) { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = int64(_sqlite3Fts5IndexReads(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)) + } else { + if n == int32(2) && 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+5992, z, n) { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId + } else { + /* An unrecognized directive. Return an error message. */ + (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+40145, libc.VaList(bp+8, n, z)) + rc = int32(SQLITE_ERROR) + } + } + return rc +} + +func _fts5StorageCount(tls *libc.TLS, p uintptr, zSuffix uintptr, pnRow uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pConfig, zSql uintptr + var rc int32 + var _ /* pCnt at bp+0 */ uintptr + _, _, _ = pConfig, rc, zSql + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+42122, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zSuffix)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = Xsqlite3_prepare_v2(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -int32(1), bp, uintptr(0)) + if rc == SQLITE_OK { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + **(**Ti64)(__ccgo_up(pnRow)) = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + Xsqlite3_free(tls, zSql) + return rc +} + +// C documentation +// +// /* +// ** Prepare the two insert statements - Fts5Storage.pInsertContent and +// ** Fts5Storage.pInsertDocsize - if they have not already been prepared. +// ** Return SQLITE_OK if successful, or an SQLite error code if an error +// ** occurs. +// */ +func _fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var azStmt [12]uintptr + var f, i int32 + var pC, zBind, zSql, v2 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _ = azStmt, f, i, pC, zBind, zSql, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + /* If there is no %_docsize table, there should be no requests for + ** statements to operate on it. */ + if **(**uintptr)(__ccgo_up(p + 48 + uintptr(eStmt)*8)) == uintptr(0) { + azStmt = [12]uintptr{ + 0: __ccgo_ts + 41083, + 1: __ccgo_ts + 41151, + 2: __ccgo_ts + 41220, + 3: __ccgo_ts + 41220, + 4: __ccgo_ts + 41253, + 5: __ccgo_ts + 41292, + 6: __ccgo_ts + 41332, + 7: __ccgo_ts + 41371, + 8: __ccgo_ts + 41414, + 9: __ccgo_ts + 41453, + 10: __ccgo_ts + 41497, + 11: __ccgo_ts + 41537, + } + pC = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + zSql = uintptr(0) + switch eStmt { + case int32(FTS5_STMT_SCAN): + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*TFts5Config)(unsafe.Pointer(pC)).FzContent)) + case FTS5_STMT_SCAN_ASC: + fallthrough + case int32(FTS5_STMT_SCAN_DESC): + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*TFts5Config)(unsafe.Pointer(pC)).FzContent, (*TFts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*TFts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*TFts5Config)(unsafe.Pointer(pC)).FzContentRowid)) + case int32(FTS5_STMT_LOOKUP): + fallthrough + case int32(FTS5_STMT_LOOKUP2): + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*TFts5Config)(unsafe.Pointer(pC)).FzContent, (*TFts5Config)(unsafe.Pointer(pC)).FzContentRowid)) + case int32(FTS5_STMT_INSERT_CONTENT): + fallthrough + case int32(FTS5_STMT_REPLACE_CONTENT): + zBind = uintptr(0) + /* Add bindings for the "c*" columns - those that store the actual + ** table content. If eContent==NORMAL, then there is one binding + ** for each column. Or, if eContent==UNINDEXED, then there are only + ** bindings for the UNINDEXED columns. */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < (*TFts5Config)(unsafe.Pointer(pC)).FnCol+int32(1)) { + break + } + if !(i != 0) || (*TFts5Config)(unsafe.Pointer(pC)).FeContent == FTS5_CONTENT_NORMAL || **(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pC)).FabUnindexed + uintptr(i-int32(1)))) != 0 { + if zBind != 0 { + v2 = __ccgo_ts + 14690 + } else { + v2 = __ccgo_ts + 1702 + } + zBind = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+41560, libc.VaList(bp+16, zBind, v2, i+int32(1))) + } + goto _1 + _1: + ; + i = i + 1 + } + /* Add bindings for any "l*" columns. Only non-UNINDEXED columns + ** require these. */ + if (*TFts5Config)(unsafe.Pointer(pC)).FbLocale != 0 && (*TFts5Config)(unsafe.Pointer(pC)).FeContent == FTS5_CONTENT_NORMAL { + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < (*TFts5Config)(unsafe.Pointer(pC)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pC)).FabUnindexed + uintptr(i)))) == 0 { + zBind = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+41568, libc.VaList(bp+16, zBind, (*TFts5Config)(unsafe.Pointer(pC)).FnCol+i+int32(2))) + } + goto _3 + _3: + ; + i = i + 1 + } + } + zSql = _sqlite3Fts5Mprintf(tls, bp, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzDb, (*TFts5Config)(unsafe.Pointer(pC)).FzName, zBind)) + Xsqlite3_free(tls, zBind) + case int32(FTS5_STMT_REPLACE_DOCSIZE): + if (*TFts5Config)(unsafe.Pointer(pC)).FbContentlessDelete != 0 { + v2 = __ccgo_ts + 41575 + } else { + v2 = __ccgo_ts + 1702 + } + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzDb, (*TFts5Config)(unsafe.Pointer(pC)).FzName, v2)) + case int32(FTS5_STMT_LOOKUP_DOCSIZE): + if (*TFts5Config)(unsafe.Pointer(pC)).FbContentlessDelete != 0 { + v2 = __ccgo_ts + 41578 + } else { + v2 = __ccgo_ts + 1702 + } + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, v2, (*TFts5Config)(unsafe.Pointer(pC)).FzDb, (*TFts5Config)(unsafe.Pointer(pC)).FzName)) + default: + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzDb, (*TFts5Config)(unsafe.Pointer(pC)).FzName)) + break + } + if zSql == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + f = int32(SQLITE_PREPARE_PERSISTENT) + if eStmt > int32(FTS5_STMT_LOOKUP2) { + f = f | int32(SQLITE_PREPARE_NO_VTAB) + } + (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock + 1 + **(**int32)(__ccgo_up(bp)) = Xsqlite3_prepare_v3(tls, (*TFts5Config)(unsafe.Pointer(pC)).Fdb, zSql, -int32(1), libc.Uint32FromInt32(f), p+48+uintptr(eStmt)*8, uintptr(0)) + (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock - 1 + Xsqlite3_free(tls, zSql) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK && pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, (*TFts5Config)(unsafe.Pointer(pC)).Fdb))) + } + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_ERROR) && eStmt > int32(FTS5_STMT_LOOKUP2) && eStmt < int32(FTS5_STMT_SCAN) { + /* One of the internal tables - not the %_content table - is missing. + ** This counts as a corrupted table. */ + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_CORRUPT) + } + } + } + **(**uintptr)(__ccgo_up(ppStmt)) = **(**uintptr)(__ccgo_up(p + 48 + uintptr(eStmt)*8)) + Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(ppStmt))) + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5StorageRenameOne(tls *libc.TLS, pConfig uintptr, pRc uintptr, zTail uintptr, zName uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + **(**int32)(__ccgo_up(pRc)) = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41766, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zTail, zName, zTail)) + } +} + +// C documentation +// +// /* +// ** Store the current contents of the p->nTotalRow and p->aTotalSize[] +// ** variables in the "averages" record on disk. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code if an error +// ** occurs. +// */ +func _fts5StorageSaveTotals(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, nCol int32 + var _ /* buf at bp+0 */ TFts5Buffer + var _ /* rc at bp+16 */ int32 + _, _ = i, nCol + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol + **(**int32)(__ccgo_up(bp + 16)) = SQLITE_OK + libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^t__predefined_size_t(0)) + _sqlite3Fts5BufferAppendVarint(tls, bp+16, bp, (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow) + i = 0 + for { + if !(i < nCol) { + break + } + _sqlite3Fts5BufferAppendVarint(tls, bp+16, bp, **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3Fts5IndexSetAverages(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn) + } + Xsqlite3_free(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** Add a level to the Fts5Structure.aLevel[] array of structure object +// ** (*ppStruct). +// */ +func _fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) { + var nByte Tsqlite3_int64 + var nLevel int32 + var pStruct uintptr + _, _, _ = nByte, nLevel, pStruct + _fts5StructureMakeWritable(tls, pRc, ppStruct) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + pStruct = **(**uintptr)(__ccgo_up(ppStruct)) + nLevel = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32) + libc.Uint64FromInt32(nLevel+libc.Int32FromInt32(2))*libc.Uint64FromInt64(16)) + pStruct = Xsqlite3_realloc64(tls, pStruct, libc.Uint64FromInt64(nByte)) + if pStruct != 0 { + libc.X__builtin___memset_chk(tls, pStruct+32+uintptr(nLevel)*16, 0, uint64(16), ^t__predefined_size_t(0)) + (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel + 1 + **(**uintptr)(__ccgo_up(ppStruct)) = pStruct + } else { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } +} + +// C documentation +// +// /* +// ** Deserialize and return the structure record currently stored in serialized +// ** form within buffer pData/nData. +// ** +// ** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array +// ** are over-allocated by one slot. This allows the structure contents +// ** to be more easily edited. +// ** +// ** If an error occurs, *ppOut is set to NULL and an SQLite error code +// ** returned. Otherwise, *ppOut is set to point to the new object and +// ** SQLITE_OK returned. +// */ +func _fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bStructureV2, i, iLvl, iSeg int32 + var nByte Tsqlite3_int64 + var nOriginCntr Tu64 + var pLvl, pRet, pSeg uintptr + var v3 uint64 + var _ /* nLevel at bp+4 */ int32 + var _ /* nSegment at bp+8 */ int32 + var _ /* nTotal at bp+12 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = bStructureV2, i, iLvl, iSeg, nByte, nOriginCntr, pLvl, pRet, pSeg, v3 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + i = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = 0 /* Bytes of space to allocate at pRet */ + pRet = uintptr(0) /* Structure object to return */ + bStructureV2 = 0 /* True for FTS5_STRUCTURE_V2 */ + nOriginCntr = uint64(0) /* Largest origin value seen so far */ + /* Grab the cookie value */ + if piCookie != 0 { + **(**int32)(__ccgo_up(piCookie)) = _sqlite3Fts5Get32(tls, pData) + } + i = int32(4) + /* Check if this is a V2 structure record. Set bStructureV2 if it is. */ + if 0 == libc.Xmemcmp(tls, pData+uintptr(i), __ccgo_ts+39408, uint64(4)) { + i = i + int32(4) + bStructureV2 = int32(1) + } + /* Read the total number of levels and segments from the start of the + ** structure record. */ + i = i + _sqlite3Fts5GetVarint32(tls, pData+uintptr(i), bp+4) + i = i + _sqlite3Fts5GetVarint32(tls, pData+uintptr(i), bp+8) + if **(**int32)(__ccgo_up(bp + 4)) > int32(FTS5_MAX_SEGMENT) || **(**int32)(__ccgo_up(bp + 4)) < 0 || **(**int32)(__ccgo_up(bp + 8)) > int32(FTS5_MAX_SEGMENT) || **(**int32)(__ccgo_up(bp + 8)) < 0 { + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= nData { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= nData { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 { + v3 = nOriginCntr + } else { + v3 = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 + } + nOriginCntr = v3 + } + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast < (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< 0 && (**(**TFts5StructureLevel)(__ccgo_up(pLvl + uintptr(-libc.Int32FromInt32(1))*16))).FnMerge != 0 && **(**int32)(__ccgo_up(bp + 12)) == 0 { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< int32(1) { + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32) + libc.Uint64FromInt32((*TFts5Structure)(unsafe.Pointer(p)).FnLevel)*libc.Uint64FromInt64(16)) + pNew = _sqlite3Fts5MallocZero(tls, pRc, nByte) + if pNew != 0 { + libc.X__builtin___memcpy_chk(tls, pNew, p, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < (*TFts5Structure)(unsafe.Pointer(p)).FnLevel) { + break + } + (*(*TFts5StructureLevel)(unsafe.Pointer(pNew + 32 + uintptr(i)*16))).FaSeg = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < (*TFts5Structure)(unsafe.Pointer(p)).FnLevel) { + break + } + pLvl = pNew + 32 + uintptr(i)*16 + nByte = libc.Int64FromUint64(uint64(56) * libc.Uint64FromInt32((*(*TFts5StructureLevel)(unsafe.Pointer(pNew + 32 + uintptr(i)*16))).FnSeg)) + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = _sqlite3Fts5MallocZero(tls, pRc, nByte) + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg == uintptr(0) { + i = 0 + for { + if !(i < (*TFts5Structure)(unsafe.Pointer(p)).FnLevel) { + break + } + Xsqlite3_free(tls, (*(*TFts5StructureLevel)(unsafe.Pointer(pNew + 32 + uintptr(i)*16))).FaSeg) + goto _3 + _3: + ; + i = i + 1 + } + Xsqlite3_free(tls, pNew) + return + } + libc.X__builtin___memcpy_chk(tls, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg, (*(*TFts5StructureLevel)(unsafe.Pointer(p + 32 + uintptr(i)*16))).FaSeg, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + goto _2 + _2: + ; + i = i + 1 + } + (*TFts5Structure)(unsafe.Pointer(p)).FnRef = (*TFts5Structure)(unsafe.Pointer(p)).FnRef - 1 + (*TFts5Structure)(unsafe.Pointer(pNew)).FnRef = int32(1) + } + **(**uintptr)(__ccgo_up(pp)) = pNew + } +} + +// C documentation +// +// /* +// ** Return a copy of index structure pStruct. Except, promote as many +// ** segments as possible to level iPromote. If an OOM occurs, NULL is +// ** returned. +// */ +func _fts5StructurePromoteTo(tls *libc.TLS, p uintptr, iPromote int32, szPromote int32, pStruct uintptr) { + var il, is, sz int32 + var pLvl, pOut uintptr + _, _, _, _, _ = il, is, pLvl, pOut, sz + pOut = pStruct + 32 + uintptr(iPromote)*16 + if (*TFts5StructureLevel)(unsafe.Pointer(pOut)).FnMerge == 0 { + il = iPromote + int32(1) + for { + if !(il < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + pLvl = pStruct + 32 + uintptr(il)*16 + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 { + return + } + is = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - int32(1) + for { + if !(is >= 0) { + break + } + sz = _fts5SegmentSize(tls, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(is)*56) + if sz > szPromote { + return + } + _fts5StructureExtendLevel(tls, p+60, pStruct, iPromote, int32(1), int32(1)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + libc.X__builtin___memcpy_chk(tls, (*TFts5StructureLevel)(unsafe.Pointer(pOut)).FaSeg, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(is)*56, uint64(56), ^t__predefined_size_t(0)) + (*TFts5StructureLevel)(unsafe.Pointer(pOut)).FnSeg = (*TFts5StructureLevel)(unsafe.Pointer(pOut)).FnSeg + 1 + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - 1 + goto _2 + _2: + ; + is = is - 1 + } + goto _1 + _1: + ; + il = il + 1 + } + } +} + +func _fts5StructureReadUncached(tls *libc.TLS, p uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pConfig, pData uintptr + var _ /* iCookie at bp+8 */ int32 + var _ /* pRet at bp+0 */ uintptr + _, _ = pConfig, pData + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + pData = _fts5DataRead(tls, p, int64(FTS5_STRUCTURE_ROWID)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* TODO: Do we need this if the leaf-index is appended? Probably... */ + libc.X__builtin___memset_chk(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr((*TFts5Data)(unsafe.Pointer(pData)).Fnn), 0, uint64(FTS5_DATA_PADDING), ^t__predefined_size_t(0)) + (*TFts5Index)(unsafe.Pointer(p)).Frc = _fts5StructureDecode(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp, (*TFts5Data)(unsafe.Pointer(pData)).Fnn, bp+8, bp) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*TFts5Config)(unsafe.Pointer(pConfig)).Fpgsz == 0 || (*TFts5Config)(unsafe.Pointer(pConfig)).FiCookie != **(**int32)(__ccgo_up(bp + 8)) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = _sqlite3Fts5ConfigLoad(tls, pConfig, **(**int32)(__ccgo_up(bp + 8))) + } + } else { + if (*TFts5Index)(unsafe.Pointer(p)).Frc == libc.Int32FromInt32(SQLITE_CORRUPT)|libc.Int32FromInt32(1)< uint64(0) { + v1 = libc.Int32FromInt32(4) + libc.Int32FromInt32(4) + libc.Int32FromInt32(9) + libc.Int32FromInt32(9) + libc.Int32FromInt32(9) + } else { + v1 = libc.Int32FromInt32(4) + libc.Int32FromInt32(9) + libc.Int32FromInt32(9) + } /* Cookie value to store */ + nHdr = v1 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^t__predefined_size_t(0)) + /* Append the current configuration cookie */ + iCookie = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FiCookie + if iCookie < 0 { + iCookie = 0 + } + if 0 == _sqlite3Fts5BufferSize(tls, p+60, bp, libc.Uint32FromInt32(nHdr)) { + _sqlite3Fts5Put32(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, iCookie) + (**(**TFts5Buffer)(__ccgo_up(bp))).Fn = int32(4) + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnOriginCntr > uint64(0) { + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp)).Fn), __ccgo_ts+39408, uint64(4), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp + 8)) += int32(4) + } + **(**int32)(__ccgo_up(bp + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp)).Fn), libc.Uint64FromInt32((*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel)) + **(**int32)(__ccgo_up(bp + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp)).Fn), libc.Uint64FromInt32((*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment)) + **(**int32)(__ccgo_up(bp + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp)).Fn), libc.Uint64FromInt64(libc.Int64FromUint64((*TFts5Structure)(unsafe.Pointer(pStruct)).FnWriteCounter))) + } + iLvl = 0 + for { + if !(iLvl < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } /* Used to iterate through segments */ + pLvl = pStruct + 32 + uintptr(iLvl)*16 + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg)) + iSeg = 0 + for { + if !(iSeg < (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg) { + break + } + pSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*56 + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast)) + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnOriginCntr > uint64(0) { + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromUint64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin1)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromUint64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnPgTombstone)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromUint64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnEntryTombstone)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromUint64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnEntry)) + } + goto _3 + _3: + ; + iSeg = iSeg + 1 + } + goto _2 + _2: + ; + iLvl = iLvl + 1 + } + _fts5DataWrite(tls, p, int64(FTS5_STRUCTURE_ROWID), (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn) + _sqlite3Fts5BufferFree(tls, bp) + } +} + +// C documentation +// +// /* +// ** Sort the contents of the pT->aMap[] array. +// ** +// ** The sorting algorithm requires a malloc(). If this fails, an error code +// ** is left in Fts5Index.rc before returning. +// */ +func _fts5TokendataIterSortMap(tls *libc.TLS, p uintptr, pT uintptr) { + var a1, a2, aTmp, tmp uintptr + var i1, n1, n2 int32 + var nByte, nHalf Ti64 + var v3, v4 int64 + _, _, _, _, _, _, _, _, _, _, _ = a1, a2, aTmp, i1, n1, n2, nByte, nHalf, tmp, v3, v4 + aTmp = uintptr(0) + nByte = libc.Int64FromUint64(libc.Uint64FromInt64((*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap) * uint64(24)) + aTmp = _sqlite3Fts5MallocZero(tls, p+60, nByte) + if aTmp != 0 { + a1 = (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaMap + a2 = aTmp + nHalf = int64(1) + for { + if !(nHalf < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap) { + break + } + i1 = 0 + for { + if !(int64(i1) < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap) { + break + } + if nHalf < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap-int64(i1) { + v3 = nHalf + } else { + v3 = (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap - int64(i1) + } + n1 = int32(v3) + if nHalf < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap-int64(i1)-int64(n1) { + v4 = nHalf + } else { + v4 = (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap - int64(i1) - int64(n1) + } + n2 = int32(v4) + _fts5TokendataMerge(tls, a1+uintptr(i1)*24, n1, a1+uintptr(i1+n1)*24, n2, a2+uintptr(i1)*24) + goto _2 + _2: + ; + i1 = int32(int64(i1) + nHalf*libc.Int64FromInt32(2)) + } + tmp = a1 + a1 = a2 + a2 = tmp + goto _1 + _1: + ; + nHalf = nHalf * int64(2) + } + if a1 != (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaMap { + libc.X__builtin___memcpy_chk(tls, (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaMap, a1, uint64(libc.Uint64FromInt64((*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap)*uint64(24)), ^t__predefined_size_t(0)) + } + Xsqlite3_free(tls, aTmp) + } +} + +// C documentation +// +// /* +// ** The two input arrays - a1[] and a2[] - are in sorted order. This function +// ** merges the two arrays together and writes the result to output array +// ** aOut[]. aOut[] is guaranteed to be large enough to hold the result. +// ** +// ** Duplicate entries are copied into the output. So the size of the output +// ** array is always (n1+n2) entries. +// */ +func _fts5TokendataMerge(tls *libc.TLS, a1 uintptr, n1 int32, a2 uintptr, n2 int32, aOut uintptr) { + var i1, i2 int32 + var pOut uintptr + _, _, _ = i1, i2, pOut + i1 = 0 + i2 = 0 + for i1 < n1 || i2 < n2 { + pOut = aOut + uintptr(i1+i2)*24 + if i2 >= n2 || i1 < n1 && ((**(**TFts5TokenDataMap)(__ccgo_up(a1 + uintptr(i1)*24))).FiRowid < (**(**TFts5TokenDataMap)(__ccgo_up(a2 + uintptr(i2)*24))).FiRowid || (**(**TFts5TokenDataMap)(__ccgo_up(a1 + uintptr(i1)*24))).FiRowid == (**(**TFts5TokenDataMap)(__ccgo_up(a2 + uintptr(i2)*24))).FiRowid && (**(**TFts5TokenDataMap)(__ccgo_up(a1 + uintptr(i1)*24))).FiPos <= (**(**TFts5TokenDataMap)(__ccgo_up(a2 + uintptr(i2)*24))).FiPos) { + libc.X__builtin___memcpy_chk(tls, pOut, a1+uintptr(i1)*24, uint64(24), ^t__predefined_size_t(0)) + i1 = i1 + 1 + } else { + libc.X__builtin___memcpy_chk(tls, pOut, a2+uintptr(i2)*24, uint64(24), ^t__predefined_size_t(0)) + i2 = i2 + 1 + } + } +} + +// C documentation +// +// /* +// ** Allocate a trigram tokenizer. +// */ +func _fts5TriCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + var i, rc, v2 int32 + var pNew, zArg uintptr + _, _, _, _, _ = i, pNew, rc, zArg, v2 + rc = SQLITE_OK + pNew = uintptr(0) + _ = pUnused + if nArg%int32(2) != 0 { + rc = int32(SQLITE_ERROR) + } else { + pNew = Xsqlite3_malloc64(tls, uint64(8)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold = int32(1) + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam = 0 + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + zArg = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42510) { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || **(**int8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('0')) + } + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42196) { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') && int32(**(**int8)(__ccgo_up(zArg))) != int32('2') || **(**int8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') { + v2 = int32(2) + } else { + v2 = 0 + } + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam = v2 + } + } else { + rc = int32(SQLITE_ERROR) + } + } + goto _1 + _1: + ; + i = i + int32(2) + } + if (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam != 0 && (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold == 0 { + rc = int32(SQLITE_ERROR) + } + if rc != SQLITE_OK { + _fts5TriDelete(tls, pNew) + pNew = uintptr(0) + } + } + } + **(**uintptr)(__ccgo_up(ppOut)) = pNew + return rc +} + +// C documentation +// +// /* +// ** Trigram tokenizer tokenize routine. +// */ +func _fts5TriTokenize(tls *libc.TLS, pTok uintptr, pCtx uintptr, unusedFlags int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aStart [3]int32 + var iCode Tu32 + var iNext, ii, rc int32 + var p, z1, zEof, zIn, zOut, v1 uintptr + var _ /* aBuf at bp+0 */ [32]int8 + _, _, _, _, _, _, _, _, _, _, _ = aStart, iCode, iNext, ii, p, rc, z1, zEof, zIn, zOut, v1 + p = pTok + rc = SQLITE_OK + zOut = bp + zIn = pText + if zIn != 0 { + v1 = zIn + uintptr(nText) + } else { + v1 = uintptr(0) + } + zEof = v1 + iCode = uint32(0) /* Input offset of each character in aBuf[] */ + _ = unusedFlags + /* Populate aBuf[] with the characters for the first trigram. */ + ii = 0 + for { + if !(ii < int32(3)) { + break + } + for cond := true; cond; cond = iCode == uint32(0) { + aStart[ii] = int32(int64(zIn) - int64(pText)) + if zIn >= zEof { + return SQLITE_OK + } + v1 = zIn + zIn = zIn + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v1))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zIn < zEof && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn)))&int32(0xc0) == int32(0x80) { + v1 = zIn + zIn = zIn + 1 + iCode = iCode<>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + /* At the start of each iteration of this loop: + ** + ** aBuf: Contains 3 characters. The 3 characters of the next trigram. + ** zOut: Points to the byte following the last character in aBuf. + ** aStart[3]: Contains the byte offset in the input text corresponding + ** to the start of each of the three characters in the buffer. + */ + for int32(1) != 0 { + /* Read characters from the input up until the first non-diacritic */ + for cond := true; cond; cond = iCode == uint32(0) { + iNext = int32(int64(zIn) - int64(pText)) + if zIn >= zEof { + iCode = uint32(0) + break + } + v1 = zIn + zIn = zIn + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v1))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zIn < zEof && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn)))&int32(0xc0) == int32(0x80) { + v1 = zIn + zIn = zIn + 1 + iCode = iCode<= int32(0xc0) { + for libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z1))))&int32(0xc0) == int32(0x80) { + z1 = z1 + 1 + } + } + libc.X__builtin___memmove_chk(tls, bp, z1, libc.Uint64FromInt64(int64(zOut)-int64(z1)), ^t__predefined_size_t(0)) + zOut = zOut - uintptr(int64(z1)-t__predefined_ptrdiff_t(bp)) + if iCode < uint32(0x00080) { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = libc.Int8FromUint8(uint8(iCode & libc.Uint32FromInt32(0xFF))) + } else { + if iCode < uint32(0x00800) { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xC0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + /* Update the aStart[] array */ + aStart[0] = aStart[int32(1)] + aStart[int32(1)] = aStart[int32(2)] + aStart[int32(2)] = iNext + } + return rc +} + +// C documentation +// +// /* +// ** Iterator pIter was used to iterate through the input segments of on an +// ** incremental merge operation. This function is called if the incremental +// ** merge step has finished but the input has not been completely exhausted. +// */ +func _fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, iId, iOff, nDiff int32 + var iLeafRowid Ti64 + var pData, pSeg uintptr + var _ /* aHdr at bp+16 */ [4]Tu8 + var _ /* buf at bp+0 */ TFts5Buffer + _, _, _, _, _, _, _ = i, iId, iLeafRowid, iOff, nDiff, pData, pSeg + libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg && (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { + break + } + pSeg = pIter + 104 + uintptr(i)*128 + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg == uintptr(0) { + /* no-op */ + } else { + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf == uintptr(0) { + /* All keys from this input segment have been transfered to the output. + ** Set both the first and last page-numbers to 0 to indicate that the + ** segment is now empty. */ + (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoLast = 0 + (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoFirst = 0 + } else { + iOff = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafOffset + iId = (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid + **(**[4]Tu8)(__ccgo_up(bp + 16)) = [4]Tu8{} + iLeafRowid = int64(iId)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))< (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf { + /* This can occur if the pages that the segments occupy overlap - if + ** a single page has been assigned to more than one segment. In + ** this case a prior iteration of this loop may have corrupted the + ** segment currently being trimmed. */ + _fts5IndexCorruptRowid(tls, p, iLeafRowid) + } else { + _sqlite3Fts5BufferZero(tls, bp) + if !(libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(bp)).Fn)+libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer(pData)).Fnn) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(bp)).FnSpace)) { + _sqlite3Fts5BufferSize(tls, p+60, bp, libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer(pData)).Fnn+(*TFts5Buffer)(unsafe.Pointer(bp)).Fn)) + } + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, uint32(4), bp+16) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn)) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, libc.Uint32FromInt32((*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn), (*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer(pData)).FszLeaf-iOff), (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr(iOff)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* Set the szLeaf field */ + _fts5PutU16(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp+2, libc.Uint16FromInt32((**(**TFts5Buffer)(__ccgo_up(bp))).Fn)) + } + /* Set up the new page-index array */ + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromInt32(4)) + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno && (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist < (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf && (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff <= (*TFts5Data)(unsafe.Pointer(pData)).Fnn { + nDiff = (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf - (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((**(**TFts5Buffer)(__ccgo_up(bp))).Fn)-int64(1)-int64(nDiff)-int64(4)) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer(pData)).Fnn-(*TFts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff), (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr((*TFts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff)) + } + (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoFirst = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno + _fts5DataDelete(tls, p, int64(iId)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))< 0 { + aNew = Xsqlite3_realloc64(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaiException, uint64(libc.Uint64FromInt32(n+(*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException)*uint64(4))) + if aNew != 0 { + nNew = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException + zCsr = z + zTerm = z + uintptr(n) + for zCsr < zTerm { + v1 = zCsr + zCsr = zCsr + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v1))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zCsr < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0xc0) == int32(0x80) { + v1 = zCsr + zCsr = zCsr + 1 + iCode = iCode< iCode { + break + } + goto _3 + _3: + ; + i = i + 1 + } + libc.X__builtin___memmove_chk(tls, aNew+uintptr(i+int32(1))*4, aNew+uintptr(i)*4, libc.Uint64FromInt32(nNew-i)*uint64(4), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(aNew + uintptr(i)*4)) = libc.Int32FromUint32(iCode) + nNew = nNew + 1 + } + } + } + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaiException = aNew + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException = nNew + } else { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +// C documentation +// +// /* +// ** Create a "unicode61" tokenizer. +// */ +func _fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + var i, rc int32 + var p, zArg, zCat uintptr + _, _, _, _, _ = i, p, rc, zArg, zCat + rc = SQLITE_OK /* Return code */ + p = uintptr(0) /* New tokenizer object */ + _ = pUnused + if nArg%int32(2) != 0 { + rc = int32(SQLITE_ERROR) + } else { + p = Xsqlite3_malloc64(tls, uint64(192)) + if p != 0 { + zCat = __ccgo_ts + 42176 + libc.X__builtin___memset_chk(tls, p, 0, uint64(192), ^t__predefined_size_t(0)) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = int32(FTS5_REMOVE_DIACRITICS_SIMPLE) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold = int32(64) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold)*uint64(1))) + if (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + /* Search for a "categories" argument */ + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42185) { + zCat = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + } + goto _1 + _1: + ; + i = i + int32(2) + } + if rc == SQLITE_OK { + rc = _unicodeSetCategories(tls, p, zCat) + } + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + zArg = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42196) { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') && int32(**(**int8)(__ccgo_up(zArg))) != int32('2') || **(**int8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = int32(**(**int8)(__ccgo_up(zArg))) - int32('0') + } + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42154) { + rc = _fts5UnicodeAddExceptions(tls, p, zArg, int32(1)) + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42165) { + rc = _fts5UnicodeAddExceptions(tls, p, zArg, 0) + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42185) { + /* no-op */ + } else { + rc = int32(SQLITE_ERROR) + } + } + } + } + goto _2 + _2: + ; + i = i + int32(2) + } + } else { + rc = int32(SQLITE_NOMEM) + } + if rc != SQLITE_OK { + _fts5UnicodeDelete(tls, p) + p = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppOut)) = p + } + return rc +} + +func _fts5UnicodeTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + var a, aFold, p, pEnd, zCsr, zOut, zTerm, v3 uintptr + var iCode Tu32 + var ie, is, nFold, rc, v7 int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, aFold, iCode, ie, is, nFold, p, pEnd, rc, zCsr, zOut, zTerm, v3, v7 + p = pTokenizer + rc = SQLITE_OK + a = p + zTerm = pText + uintptr(nText) + zCsr = pText + /* Output buffer */ + aFold = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold + nFold = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold + pEnd = aFold + uintptr(nFold-int32(6)) + _ = iUnused + /* Each iteration of this loop gobbles up a contiguous run of separators, + ** then the next token. */ +_2: + ; + if !(rc == SQLITE_OK) { + goto _1 + } /* non-ASCII codepoint read from input */ + zOut = aFold + /* Skip any separator characters. */ + for int32(1) != 0 { + if zCsr >= zTerm { + goto tokenize_done + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0x80) != 0 { + /* A character outside of the ascii range. Skip past it if it is + ** a separator character. Or break out of the loop if it is not. */ + is = int32(int64(zCsr) - int64(pText)) + v3 = zCsr + zCsr = zCsr + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v3))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zCsr < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0xc0) == int32(0x80) { + v3 = zCsr + zCsr = zCsr + 1 + iCode = iCode< pEnd { + aFold = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nFold)*int64(2))) + if aFold == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto tokenize_done + } + zOut = aFold + uintptr(int64(zOut)-int64((*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold)) + libc.X__builtin___memcpy_chk(tls, aFold, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold, libc.Uint64FromInt32(nFold), ^t__predefined_size_t(0)) + Xsqlite3_free(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold = aFold + v7 = nFold * libc.Int32FromInt32(2) + nFold = v7 + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold = v7 + pEnd = aFold + uintptr(nFold-int32(6)) + } + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0x80) != 0) { + goto _8 + } + /* An non-ascii-range character. Fold it into the output buffer if + ** it is a token character, or break out of the loop if it is not. */ + v3 = zCsr + zCsr = zCsr + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v3))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zCsr < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0xc0) == int32(0x80) { + v3 = zCsr + zCsr = zCsr + 1 + iCode = iCode<>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + } + goto _13 +_12: + ; + goto _5 +_13: + ; + goto _9 +_8: + ; + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(a + uintptr(**(**uint8)(__ccgo_up(zCsr)))))) == 0) { + goto _24 + } + /* An ascii-range separator character. End of token. */ + goto _5 + goto _25 +_24: + ; + goto ascii_tokenchar +ascii_tokenchar: + ; + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) >= int32('A') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) <= int32('Z') { + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) + int32(32)) + } else { + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = libc.Int8FromUint8(**(**uint8)(__ccgo_up(zCsr))) + } + zCsr = zCsr + 1 +_25: + ; +_9: + ; + ie = int32(int64(zCsr) - int64(pText)) + goto _6 +_5: + ; + /* Invoke the token callback */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xToken})))(tls, pCtx, 0, aFold, int32(int64(zOut)-int64(aFold)), is, ie) + goto _2 +_1: + ; + goto tokenize_done +tokenize_done: + ; + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + return rc +} + +/************************************************************************** +** Start of porter stemmer implementation. + */ + +/* Any tokens larger than this (in bytes) are passed through without +** stemming. */ + +// C documentation +// +// /* +// ** This function is the implementation of the xUpdate callback used by +// ** FTS3 virtual tables. It is invoked by SQLite each time a row is to be +// ** inserted, updated or deleted. +// ** +// ** A delete specifies a single argument - the rowid of the row to remove. +// ** +// ** Update and insert operations pass: +// ** +// ** 1. The "old" rowid, or NULL. +// ** 2. The "new" rowid. +// ** 3. Values for each of the nCol matchable columns. +// ** 4. Values for the two hidden columns ( and "rank"). +// */ +func _fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eConflict, eType0, eType1, ii int32 + var iDel, iNew, iNew1, iOld Ti64 + var pConfig, pStorage, pTab, pVal, z uintptr + var _ /* bContent at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = eConflict, eType0, eType1, iDel, iNew, iNew1, iOld, ii, pConfig, pStorage, pTab, pVal, z + pTab = pVtab + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig /* value_type() of apVal[0] */ + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Return code */ + /* A transaction must be open when this is called. */ + if (*TFts5Config)(unsafe.Pointer(pConfig)).Fpgsz == 0 { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ConfigLoad(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig, (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FiCookie) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp)) + } + } + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = pTab + 16 + /* Put any active cursors into REQUIRE_SEEK state. */ + _fts5TripCursors(tls, pTab) + eType0 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apVal))) + if eType0 == int32(SQLITE_NULL) && Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(int32(2)+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*8))) != int32(SQLITE_NULL) { + /* A "special" INSERT op. These are handled separately. */ + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(int32(2)+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*8))) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL && 0 == Xsqlite3_stricmp(tls, __ccgo_ts+19513, z) { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete != 0 { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40605, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + **(**int32)(__ccgo_up(bp)) = _fts5SpecialDelete(tls, pTab, apVal) + } + } else { + **(**int32)(__ccgo_up(bp)) = _fts5SpecialInsert(tls, pTab, z, **(**uintptr)(__ccgo_up(apVal + uintptr(int32(2)+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol+int32(1))*8))) + } + } else { + /* A regular INSERT, UPDATE or DELETE statement. The trick here is that + ** any conflict on the rowid value must be detected before any + ** modifications are made to the database file. There are 4 cases: + ** + ** 1) DELETE + ** 2) UPDATE (rowid not modified) + ** 3) UPDATE (rowid modified) + ** 4) INSERT + ** + ** Cases 3 and 4 may violate the rowid constraint. + */ + eConflict = int32(SQLITE_ABORT) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL || (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete != 0 { + eConflict = Xsqlite3_vtab_on_conflict(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb) + } + /* DELETE */ + if nArg == int32(1) { + /* It is only possible to DELETE from a contentless table if the + ** contentless_delete=1 flag is set. */ + if _fts5IsContentless(tls, pTab, int32(1)) != 0 && (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete == 0 { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40664, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + iDel = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal))) /* Rowid to delete */ + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, uintptr(0), 0) + } + } else { + eType1 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + /* It is an error to write an fts5_locale() value to a table without + ** the locale=1 option. */ + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale == 0 { + ii = 0 + for { + if !(ii < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr(ii+int32(2))*8)) + if _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40710, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_MISMATCH) + goto update_out + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + if eType0 != int32(SQLITE_INTEGER) { + /* An INSERT statement. If the conflict-mode is REPLACE, first remove + ** the current entry (if any). */ + if eConflict == int32(SQLITE_REPLACE) && eType1 == int32(SQLITE_INTEGER) { + iNew = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) /* Rowid to delete */ + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iNew, uintptr(0), 0) + } + _fts5StorageInsert(tls, bp, pTab, apVal, pRowid) + } else { + pStorage = (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage + iOld = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal))) /* Old rowid */ + iNew1 = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) /* New rowid */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* Content only update */ + /* If this is a contentless table (including contentless_unindexed=1 + ** tables), check if the UPDATE may proceed. */ + if _fts5IsContentless(tls, pTab, int32(1)) != 0 { + **(**int32)(__ccgo_up(bp)) = _fts5ContentlessUpdate(tls, pConfig, apVal+2*8, libc.BoolInt32(iOld != iNew1), bp+4) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto update_out + } + } + if eType1 != int32(SQLITE_INTEGER) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_MISMATCH) + } else { + if iOld != iNew1 { + if eConflict == int32(SQLITE_REPLACE) { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, pStorage, iOld, uintptr(0), int32(1)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, pStorage, iNew1, uintptr(0), 0) + } + _fts5StorageInsert(tls, bp, pTab, apVal, pRowid) + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageFindDeleteRow(tls, pStorage, iOld) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageContentInsert(tls, pStorage, 0, apVal, pRowid) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, pStorage, iOld, uintptr(0), 0) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageIndexInsert(tls, pStorage, apVal, **(**Tsqlite_int64)(__ccgo_up(pRowid))) + } + } + } else { + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + /* This occurs when an UPDATE on a contentless table affects *only* + ** UNINDEXED columns. This is a no-op for contentless_unindexed=0 + ** tables, or a write to the %_content table only for =1 tables. */ + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageFindDeleteRow(tls, pStorage, iOld) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageContentInsert(tls, pStorage, int32(1), apVal, pRowid) + } + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, pStorage, iOld, uintptr(0), int32(1)) + _fts5StorageInsert(tls, bp, pTab, apVal, pRowid) + } + } + } + _sqlite3Fts5StorageReleaseDeleteRow(tls, pStorage) + } + } + } + goto update_out +update_out: + ; + _sqlite3Fts5IndexCloseReader(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = uintptr(0) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This is the xFilter implementation for the virtual table. +// */ +func _fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused uintptr, nUnused int32, apVal uintptr) (r int32) { + var eType, f, iVal, nTerm, rc, v1 int32 + var pCsr, pEq, pGe, pIndex, pLe, pTab, zCopy, zTerm uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = eType, f, iVal, nTerm, pCsr, pEq, pGe, pIndex, pLe, pTab, rc, zCopy, zTerm, v1 + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + pCsr = pCursor + eType = (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType + rc = SQLITE_OK + iVal = 0 + f = int32(FTS5INDEX_QUERY_SCAN) + zTerm = uintptr(0) + nTerm = 0 + pEq = uintptr(0) + pGe = uintptr(0) + pLe = uintptr(0) + _ = zUnused + _ = nUnused + _fts5VocabResetCursor(tls, pCsr) + if idxNum&int32(FTS5_VOCAB_TERM_EQ) != 0 { + v1 = iVal + iVal = iVal + 1 + pEq = **(**uintptr)(__ccgo_up(apVal + uintptr(v1)*8)) + } + if idxNum&int32(FTS5_VOCAB_TERM_GE) != 0 { + v1 = iVal + iVal = iVal + 1 + pGe = **(**uintptr)(__ccgo_up(apVal + uintptr(v1)*8)) + } + if idxNum&int32(FTS5_VOCAB_TERM_LE) != 0 { + v1 = iVal + iVal = iVal + 1 + pLe = **(**uintptr)(__ccgo_up(apVal + uintptr(v1)*8)) + } + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FcolUsed = idxNum & int32(FTS5_VOCAB_COLUSED_MASK) + if pEq != 0 { + zTerm = Xsqlite3_value_text(tls, pEq) + nTerm = Xsqlite3_value_bytes(tls, pEq) + f = int32(FTS5INDEX_QUERY_NOTOKENDATA) + } else { + if pGe != 0 { + zTerm = Xsqlite3_value_text(tls, pGe) + nTerm = Xsqlite3_value_bytes(tls, pGe) + } + if pLe != 0 { + zCopy = Xsqlite3_value_text(tls, pLe) + if zCopy == uintptr(0) { + zCopy = __ccgo_ts + 1702 + } + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm = Xsqlite3_value_bytes(tls, pLe) + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm)+int64(1))) + if (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memcpy_chk(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zCopy, libc.Uint64FromInt32((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm+int32(1)), ^t__predefined_size_t(0)) + } + } + } + if rc == SQLITE_OK { + pIndex = (*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpIndex + rc = _sqlite3Fts5IndexQuery(tls, pIndex, zTerm, nTerm, f, uintptr(0), pCsr+32) + if rc == SQLITE_OK { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpStruct = _sqlite3Fts5StructureRef(tls, pIndex) + } + } + if rc == SQLITE_OK && eType == int32(FTS5_VOCAB_INSTANCE) { + rc = _fts5VocabInstanceNewTerm(tls, pCsr) + } + if rc == SQLITE_OK && !((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0) && (eType != int32(FTS5_VOCAB_INSTANCE) || (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail != int32(FTS5_DETAIL_NONE)) { + rc = _fts5VocabNextMethod(tls, pCursor) + } + return rc +} + +// C documentation +// +// /* +// ** This function is the implementation of both the xConnect and xCreate +// ** methods of the FTS3 virtual table. +// ** +// ** The argv[] array contains the following: +// ** +// ** argv[0] -> module name ("fts5vocab") +// ** argv[1] -> database name +// ** argv[2] -> table name +// ** +// ** then: +// ** +// ** argv[3] -> name of fts5 table +// ** argv[4] -> type of fts5vocab table +// ** +// ** or, for tables in the TEMP schema only. +// ** +// ** argv[3] -> name of fts5 tables database +// ** argv[4] -> name of fts5 table +// ** argv[5] -> type of fts5vocab table +// */ +func _fts5VocabInitVtab(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVTab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azSchema [3]uintptr + var bDb int32 + var nByte, nDb, nTab Ti64 + var pRet, zDb, zTab, zType, v1, v2, v3 uintptr + var _ /* eType at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _ = azSchema, bDb, nByte, nDb, nTab, pRet, zDb, zTab, zType, v1, v2, v3 + azSchema = [3]uintptr{ + 0: __ccgo_ts + 42590, + 1: __ccgo_ts + 42630, + 2: __ccgo_ts + 42665, + } + pRet = uintptr(0) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + bDb = libc.BoolInt32(argc == int32(6) && libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) == uint64(4) && libc.Xmemcmp(tls, __ccgo_ts+25586, **(**uintptr)(__ccgo_up(argv + 1*8)), uint64(4)) == 0) + if argc != int32(5) && bDb == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+42708, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + if bDb != 0 { + v1 = **(**uintptr)(__ccgo_up(argv + 3*8)) + } else { + v1 = **(**uintptr)(__ccgo_up(argv + 1*8)) + } /* Bytes of space to allocate */ + zDb = v1 + if bDb != 0 { + v2 = **(**uintptr)(__ccgo_up(argv + 4*8)) + } else { + v2 = **(**uintptr)(__ccgo_up(argv + 3*8)) + } + zTab = v2 + if bDb != 0 { + v3 = **(**uintptr)(__ccgo_up(argv + 5*8)) + } else { + v3 = **(**uintptr)(__ccgo_up(argv + 4*8)) + } + zType = v3 + nDb = libc.Int64FromUint64(libc.Xstrlen(tls, zDb) + uint64(1)) + nTab = libc.Int64FromUint64(libc.Xstrlen(tls, zTab) + uint64(1)) + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**int32)(__ccgo_up(bp)) = _fts5VocabTableType(tls, zType, pzErr, bp+4) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_declare_vtab(tls, db, azSchema[**(**int32)(__ccgo_up(bp + 4))]) + } + nByte = libc.Int64FromUint64(uint64(64) + libc.Uint64FromInt64(nDb) + libc.Uint64FromInt64(nTab)) + pRet = _sqlite3Fts5MallocZero(tls, bp, nByte) + if pRet != 0 { + (*TFts5VocabTable)(unsafe.Pointer(pRet)).FpGlobal = pAux + (*TFts5VocabTable)(unsafe.Pointer(pRet)).FeType = **(**int32)(__ccgo_up(bp + 4)) + (*TFts5VocabTable)(unsafe.Pointer(pRet)).Fdb = db + (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl = pRet + 1*64 + (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db = (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl + uintptr(nTab) + libc.X__builtin___memcpy_chk(tls, (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl, zTab, libc.Uint64FromInt64(nTab), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db, zDb, libc.Uint64FromInt64(nDb), ^t__predefined_size_t(0)) + _sqlite3Fts5Dequote(tls, (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl) + _sqlite3Fts5Dequote(tls, (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db) + } + } + **(**uintptr)(__ccgo_up(ppVTab)) = pRet + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Advance the cursor to the next row in the table. +// */ +func _fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bCmp, eDetail, iCol, ii1, nCmp, nCol, nPos, v2 int32 + var pCsr, pPos, pTab, zTerm uintptr + var v3 Ti64 + var _ /* iOff at bp+16 */ int32 + var _ /* iPos at bp+8 */ Ti64 + var _ /* ii at bp+20 */ Tu32 + var _ /* nTerm at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = bCmp, eDetail, iCol, ii1, nCmp, nCol, nPos, pCsr, pPos, pTab, zTerm, v2, v3 + pCsr = pCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StructureTest(tls, (*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpIndex, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpStruct) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp)) + } + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid + 1 + if (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType == int32(FTS5_VOCAB_INSTANCE) { + return _fts5VocabInstanceNext(tls, pCsr) + } + if (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol + 1 + for { + if !((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol) { + break + } + if **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) != 0 { + break + } + goto _1 + _1: + ; + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol + 1 + } + } + if (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType != FTS5_VOCAB_COL || (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol >= nCol { + if (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = int32(1) + } else { + zTerm = _sqlite3Fts5IterTerm(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter, bp+4) + if (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm >= 0 { + if **(**int32)(__ccgo_up(bp + 4)) < (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm { + v2 = **(**int32)(__ccgo_up(bp + 4)) + } else { + v2 = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm + } + nCmp = v2 + bCmp = libc.Xmemcmp(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zTerm, libc.Uint64FromInt32(nCmp)) + if bCmp < 0 || bCmp == 0 && (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm < **(**int32)(__ccgo_up(bp + 4)) { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = int32(1) + return SQLITE_OK + } + } + _sqlite3Fts5BufferSet(tls, bp, pCsr+96, **(**int32)(__ccgo_up(bp + 4)), zTerm) + libc.X__builtin___memset_chk(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt, 0, libc.Uint64FromInt32(nCol)*uint64(8), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc, 0, libc.Uint64FromInt32(nCol)*uint64(8), ^t__predefined_size_t(0)) + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = 0 + for **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail /* Position list */ + **(**Ti64)(__ccgo_up(bp + 8)) = 0 /* 64-bit position read from poslist */ + **(**int32)(__ccgo_up(bp + 16)) = 0 /* Current offset within position list */ + pPos = (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FpData + nPos = (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FnData + switch (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType { + case int32(FTS5_VOCAB_ROW): + /* Do not bother counting the number of instances if the "cnt" + ** column is not being read (according to colUsed). */ + if eDetail == FTS5_DETAIL_FULL && (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FcolUsed&int32(0x04) != 0 { + for **(**Ti64)(__ccgo_up(bp + 8)) < int64(nPos) { + v3 = **(**Ti64)(__ccgo_up(bp + 8)) + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) + 1 + **(**Tu32)(__ccgo_up(bp + 20)) = uint32(**(**Tu8)(__ccgo_up(pPos + uintptr(v3)))) + if **(**Tu32)(__ccgo_up(bp + 20))&uint32(0x80) != 0 { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) - 1 + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) + int64(_sqlite3Fts5GetVarint32(tls, pPos+uintptr(**(**Ti64)(__ccgo_up(bp + 8))), bp+20)) + } + if **(**Tu32)(__ccgo_up(bp + 20)) == uint32(1) { + /* New column in the position list */ + v3 = **(**Ti64)(__ccgo_up(bp + 8)) + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) + 1 + **(**Tu32)(__ccgo_up(bp + 20)) = uint32(**(**Tu8)(__ccgo_up(pPos + uintptr(v3)))) + if **(**Tu32)(__ccgo_up(bp + 20))&uint32(0x80) != 0 { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) - 1 + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) + int64(_sqlite3Fts5GetVarint32(tls, pPos+uintptr(**(**Ti64)(__ccgo_up(bp + 8))), bp+20)) + } + } else { + /* An instance - increment pCsr->aCnt[] */ + **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt)) = **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt)) + 1 + } + } + } + **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc)) = **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc)) + 1 + case FTS5_VOCAB_COL: + if eDetail == FTS5_DETAIL_FULL { + iCol = -int32(1) + for 0 == _sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+16, bp+8) { + ii1 = int32(**(**Ti64)(__ccgo_up(bp + 8)) >> libc.Int32FromInt32(32) & libc.Int64FromInt32(0x7FFFFFFF)) + if iCol != ii1 { + if ii1 >= nCol { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= int64(nCol) { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< 0 && libc.Xmemcmp(tls, zTerm, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 4)))) != 0 { + break + } + if (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { + break + } + } + } + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof == 0 && (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL { + for { + if !((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol && **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) == 0) { + break + } + goto _5 + _5: + ; + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol + 1 + } + if (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol == nCol { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<aDlidx[] array to at least nLvl elements in size. +// ** Any new array elements are zeroed before returning. +// */ +func _fts5WriteDlidxGrow(tls *libc.TLS, p uintptr, pWriter uintptr, nLvl int32) (r int32) { + var aDlidx uintptr + var nByte Tsize_t + _, _ = aDlidx, nByte + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && nLvl >= (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx { + aDlidx = Xsqlite3_realloc64(tls, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx, uint64(uint64(32)*libc.Uint64FromInt32(nLvl))) + if aDlidx == uintptr(0) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + nByte = uint64(32) * libc.Uint64FromInt32(nLvl-(*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx) + libc.X__builtin___memset_chk(tls, aDlidx+uintptr((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx)*32, 0, nByte, ^t__predefined_size_t(0)) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx = aDlidx + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx = nLvl + } + } + return (*TFts5Index)(unsafe.Pointer(p)).Frc +} + +func _fts5WriteInit(tls *libc.TLS, p uintptr, pWriter uintptr, iSegid int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nBuffer int32 + var pConfig uintptr + _, _ = nBuffer, pConfig + nBuffer = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz + int32(FTS5_DATA_PADDING) + libc.X__builtin___memset_chk(tls, pWriter, 0, uint64(120), ^t__predefined_size_t(0)) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid = iSegid + _fts5WriteDlidxGrow(tls, p, pWriter, int32(1)) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fpgno = int32(1) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage = uint8(1) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = int32(1) + /* Grow the two buffers to pgsz + padding bytes in size. */ + _sqlite3Fts5BufferSize(tls, p+60, pWriter+8+24, libc.Uint32FromInt32(nBuffer)) + _sqlite3Fts5BufferSize(tls, p+60, pWriter+8+8, libc.Uint32FromInt32(nBuffer)) + if (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter == uintptr(0) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + _fts5IndexPrepareStmt(tls, p, p+96, Xsqlite3_mprintf(tls, __ccgo_ts+39648, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* Initialize the 4-byte leaf-page header to 0x00. */ + libc.X__builtin___memset_chk(tls, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fp, 0, uint64(4), ^t__predefined_size_t(0)) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fn = int32(4) + /* Bind the current output segment id to the index-writer. This is an + ** optimization over binding the same value over and over as rows are + ** inserted into %_idx by the current writer. */ + Xsqlite3_bind_int(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(1), (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid) + } +} + +// C documentation +// +// /* +// ** The following routine is called if the stack overflows. +// */ +func _fts5yyStackOverflow(tls *libc.TLS, fts5yypParser uintptr) { + var pParse uintptr + _ = pParse + pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse + for (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos > (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystack { + _fts5yy_pop_parser_stack(tls, fts5yypParser) + } + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + /******** Begin %stack_overflow code ******************************************/ + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+37410, 0) + /******** End %stack_overflow code ********************************************/ + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse /* Suppress warning about unused %extra_argument var */ +} + +/* +** Print tracing information for a SHIFT action + */ + +// C documentation +// +// /* +// ** The following code executes when a syntax error first occurs. +// */ +func _fts5yy_syntax_error(tls *libc.TLS, fts5yypParser uintptr, fts5yymajor int32, fts5yyminor TFts5Token) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pParse uintptr + _ = pParse + pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse + /************ Begin %syntax_error code ****************************************/ + _ = fts5yymajor /* Silence a compiler warning */ + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+37438, libc.VaList(bp+8, fts5yyminor.Fn, fts5yyminor.Fp)) + /************ End %syntax_error code ******************************************/ + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse /* Suppress warning about unused %extra_argument variable */ +} + +// C documentation +// +// /* +// ** The fsync() system call does not work as advertised on many +// ** unix systems. The following procedure is an attempt to make +// ** it work better. +// ** +// ** The SQLITE_NO_SYNC macro disables all fsync()s. This is useful +// ** for testing when we want to run through the test suite quickly. +// ** You are strongly advised *not* to deploy with SQLITE_NO_SYNC +// ** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash +// ** or power failure will likely corrupt the database file. +// ** +// ** SQLite sets the dataOnly flag if the size of the file is unchanged. +// ** The idea behind dataOnly is that it should only write the file content +// ** to disk, not the inode. We only set dataOnly if the file size is +// ** unchanged since the file size is part of the inode. However, +// ** Ted Ts'o tells us that fdatasync() will also write the inode if the +// ** file size has changed. The only real difference between fdatasync() +// ** and fsync(), Ted tells us, is that fdatasync() will not flush the +// ** inode if the mtime or owner or other inode attributes have changed. +// ** We only care about the file size, not the other file attributes, so +// ** as far as SQLite is concerned, an fdatasync() is always adequate. +// ** So, we always use fdatasync() if it is available, regardless of +// ** the value of the dataOnly flag. +// */ +func _full_fsync(tls *libc.TLS, fd int32, fullSync int32, dataOnly int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + _ = rc + /* The following "ifdef/elif/else/" block has the same structure as + ** the one below. It is replicated here solely to avoid cluttering + ** up the real code with the UNUSED_PARAMETER() macros. + */ + _ = dataOnly + /* Record the number of times that we do a normal fsync() and + ** FULLSYNC. This is used during testing to verify that this procedure + ** gets called with the correct arguments. + */ + /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a + ** no-op. But go ahead and call fstat() to validate the file + ** descriptor as we need a method to provoke a failure during + ** coverage testing. + */ + if fullSync != 0 { + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, fd, int32(F_FULLFSYNC), libc.VaList(bp+8, 0)) + } else { + rc = int32(1) + } + /* If the FULLFSYNC failed, fall back to attempting an fsync(). + ** It shouldn't be possible for fullfsync to fail on the local + ** file system (on OSX), so failure indicates that FULLFSYNC + ** isn't supported for this file system. So, attempt an fsync + ** and (for now) ignore the overhead of a superfluous fcntl call. + ** It'd be better to detect fullfsync support once and avoid + ** the fcntl call every time sync is called. + */ + if rc != 0 { + rc = libc.Xfsync(tls, fd) + } + if libc.Bool(OS_VXWORKS != 0) && rc != -int32(1) { + rc = 0 + } + return rc +} + +// C documentation +// +// /* +// ** Code an output subroutine for a coroutine implementation of a +// ** SELECT statement. +// ** +// ** The data to be output is contained in an array of pIn->nSdst registers +// ** starting at register pIn->iSdst. pDest is where the output should +// ** be sent. +// ** +// ** regReturn is the number of the register holding the subroutine +// ** return address. +// ** +// ** If regPrev>0 then it is the first register in a vector that +// ** records the previous output. mem[regPrev] is a flag that is false +// ** if there has been no previous output. If regPrev>0 then code is +// ** generated to suppress duplicates. pKeyInfo is used for comparing +// ** keys. +// ** +// ** If the LIMIT found in p->iLimit is reached, jump immediately to +// ** iBreak. +// */ +func _generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uintptr, pDest uintptr, regReturn int32, regPrev int32, pKeyInfo uintptr, iBreak int32) (r int32) { + var addr, addr1, addr2, iContinue, iParm, iParm1, ii, nKey, r1, r11, r12, r2, r21, r3 int32 + var pSO, v uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addr1, addr2, iContinue, iParm, iParm1, ii, nKey, pSO, r1, r11, r12, r2, r21, r3, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + addr = _sqlite3VdbeCurrentAddr(tls, v) + iContinue = _sqlite3VdbeMakeLabel(tls, pParse) + /* Suppress duplicates for UNION, EXCEPT, and INTERSECT + */ + if regPrev != 0 { + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), regPrev) + addr2 = _sqlite3VdbeAddOp4(tls, v, int32(OP_Compare), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, regPrev+int32(1), (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst, _sqlite3KeyInfoRef(tls, pKeyInfo), -int32(9)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addr2+int32(2), iContinue, addr2+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, regPrev+int32(1), (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst-int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), regPrev) + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return 0 + } + /* Suppress the first OFFSET entries if there is an OFFSET clause + */ + _codeOffset(tls, v, (*TSelect)(unsafe.Pointer(p)).FiOffset, iContinue) + switch libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) { + /* Store the result as data using a unique key. + */ + case int32(SRT_Fifo): + fallthrough + case int32(SRT_DistFifo): + fallthrough + case int32(SRT_Table): + fallthrough + case int32(SRT_EphemTab): + r1 = _sqlite3GetTempReg(tls, pParse) + r2 = _sqlite3GetTempReg(tls, pParse) + iParm = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst, r1) + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) == int32(SRT_DistFifo) { + /* If the destination is DistFifo, then cursor (iParm+1) is open + ** on an ephemeral index that is used to enforce uniqueness on the + ** total result. At this point, we are processing the setup portion + ** of the recursive CTE using the merge algorithm, so the results are + ** guaranteed to be unique anyhow. But we still need to populate the + ** (iParm+1) cursor for use by the subsequent recursive phase. + */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm+int32(1), r1, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iParm, r2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, r1, r2) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + _sqlite3ReleaseTempReg(tls, pParse, r2) + _sqlite3ReleaseTempReg(tls, pParse, r1) + break + /* If any row exist in the result set, record that fact and abort. + */ + fallthrough + case int32(SRT_Exists): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm) + /* The LIMIT clause will terminate the loop for us */ + break + /* If we are creating a set for an "expr IN (SELECT ...)". + */ + fallthrough + case int32(SRT_Set): + r11 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst, r11, (*TSelectDest)(unsafe.Pointer(pDest)).FzAffSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm, r11, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 > 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2, 0, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20858, 0) + } + _sqlite3ReleaseTempReg(tls, pParse, r11) + break + /* If this is a scalar select that is part of an expression, then + ** store the results in the appropriate memory cell and break out + ** of the scan loop. Note that the select might return multiple columns + ** if it is the RHS of a row-value IN operator. + */ + fallthrough + case int32(SRT_Mem): + _sqlite3ExprCodeMove(tls, pParse, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + /* The LIMIT clause will jump out of the loop for us */ + break + /* The results are stored in a sequence of registers + ** starting at pDest->iSdst. Then the co-routine yields. + */ + fallthrough + case int32(SRT_Coroutine): + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 { + (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst = _sqlite3GetTempRange(tls, pParse, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + (*TSelectDest)(unsafe.Pointer(pDest)).FnSdst = (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst + } + _sqlite3ExprCodeMove(tls, pParse, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm) + break + /* Write the results into a priority queue that is order according to + ** pDest->pOrderBy (in pSO). pDest->iSDParm (in iParm) is the cursor for an + ** index with pSO->nExpr+2 columns. Build a key using pSO for the first + ** pSO->nExpr columns, then make sure all keys are unique by adding a + ** final OP_Sequence column. The last column is the record as a blob. + */ + fallthrough + case int32(SRT_DistQueue): + fallthrough + case int32(SRT_Queue): + iParm1 = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm + pSO = (*TSelectDest)(unsafe.Pointer(pDest)).FpOrderBy + nKey = (*TExprList)(unsafe.Pointer(pSO)).FnExpr + r12 = _sqlite3GetTempReg(tls, pParse) + r21 = _sqlite3GetTempRange(tls, pParse, nKey+int32(2)) + r3 = r21 + nKey + int32(1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst, r3) + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) == int32(SRT_DistQueue) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), iParm1+int32(1), r3) + } + ii = 0 + for { + if !(ii < nKey) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst+libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pSO + 8 + uintptr(ii)*32 + 24)))-int32(1), r21+ii) + goto _1 + _1: + ; + ii = ii + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sequence), iParm1, r21+nKey) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), r21, nKey+int32(2), r12) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm1, r12, r21, nKey+int32(2)) + _sqlite3ReleaseTempReg(tls, pParse, r12) + _sqlite3ReleaseTempRange(tls, pParse, r21, nKey+int32(2)) + break + /* Ignore the output */ + fallthrough + case int32(SRT_Discard): + break + /* If none of the above, then the result destination must be + ** SRT_Output. + ** + ** For SRT_Output, results are stored in a sequence of registers. + ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to + ** return the next row of result. + */ + fallthrough + default: + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + break + } + /* Jump to the end of the loop if the LIMIT is reached. + */ + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_DecrJumpZero), (*TSelect)(unsafe.Pointer(p)).FiLimit, iBreak) + } + /* Generate the subroutine return + */ + _sqlite3VdbeResolveLabel(tls, v, iContinue) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regReturn) + return addr +} + +// C documentation +// +// /* +// ** If the inner loop was generated using a non-null pOrderBy argument, +// ** then the results were placed in a sorter. After the loop is terminated +// ** we need to run the sorter and output the results. The following +// ** routine generates the code needed to do that. +// */ +func _generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, nColumn int32, pDest uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aOutEx, pOrderBy, v, v1, v3 uintptr + var addr, addrBreak, addrContinue, addrOnce, bSeq, eDest, i, i2, iCol, iParm, iRead, iSortTab, iTab, nKey, nRefKey, r1, regRow, regRowid, regSortOut, v2, v4 int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aOutEx, addr, addrBreak, addrContinue, addrOnce, bSeq, eDest, i, i2, iCol, iParm, iRead, iSortTab, iTab, nKey, nRefKey, pOrderBy, r1, regRow, regRowid, regSortOut, v, v1, v2, v3, v4 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* The prepared statement */ + addrBreak = (*TSortCtx)(unsafe.Pointer(pSort)).FlabelDone /* Jump here to exit loop */ + addrContinue = _sqlite3VdbeMakeLabel(tls, pParse) /* Top of output loop. Jump for Next. */ + addrOnce = 0 + pOrderBy = (*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy + eDest = libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) + iParm = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm /* True if sorter record includes seq. no. */ + nRefKey = 0 + aOutEx = (*TSelect)(unsafe.Pointer(p)).FpEList + 8 + nKey = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr - (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + if (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat == 0 || nKey == int32(1) { + if (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat != 0 { + v1 = __ccgo_ts + 20934 + } else { + v1 = __ccgo_ts + 1702 + } + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20948, libc.VaList(bp+8, v1)) + } else { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20979, libc.VaList(bp+8, nKey)) + } + if (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn, (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + _sqlite3VdbeGoto(tls, v, addrBreak) + _sqlite3VdbeResolveLabel(tls, v, (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + } + iTab = (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor + if eDest == int32(SRT_Output) || eDest == int32(SRT_Coroutine) || eDest == int32(SRT_Mem) { + if eDest == int32(SRT_Mem) && (*TSelect)(unsafe.Pointer(p)).FiOffset != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst) + } + regRowid = 0 + regRow = (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst + } else { + regRowid = _sqlite3GetTempReg(tls, pParse) + if eDest == int32(SRT_EphemTab) || eDest == int32(SRT_Table) { + regRow = _sqlite3GetTempReg(tls, pParse) + nColumn = 0 + } else { + regRow = _sqlite3GetTempRange(tls, pParse, nColumn) + } + } + if libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&int32(SORTFLAG_UseSorter) != 0 { + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + regSortOut = v2 + v3 = pParse + 56 + v4 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + iSortTab = v4 + if (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenPseudo), iSortTab, regSortOut, nKey+int32(1)+nColumn+nRefKey) + if addrOnce != 0 { + _sqlite3VdbeJumpHere(tls, v, addrOnce) + } + addr = int32(1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterSort), iTab, addrBreak) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SorterData), iTab, regSortOut, iSortTab) + bSeq = 0 + } else { + addr = int32(1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sort), iTab, addrBreak) + _codeOffset(tls, v, (*TSelect)(unsafe.Pointer(p)).FiOffset, addrContinue) + iSortTab = iTab + bSeq = int32(1) + if (*TSelect)(unsafe.Pointer(p)).FiOffset > 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), (*TSelect)(unsafe.Pointer(p)).FiLimit, -int32(1)) + } + } + i = 0 + iCol = nKey + bSeq - libc.Int32FromInt32(1) + for { + if !(i < nColumn) { + break + } + if libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(aOutEx + uintptr(i)*32 + 24))) == 0 { + iCol = iCol + 1 + } + goto _6 + _6: + ; + i = i + 1 + } + i = nColumn - int32(1) + for { + if !(i >= 0) { + break + } + if *(*Tu16)(unsafe.Pointer(aOutEx + uintptr(i)*32 + 24)) != 0 { + iRead = libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(aOutEx + uintptr(i)*32 + 24))) - int32(1) + } else { + v2 = iCol + iCol = iCol - 1 + iRead = v2 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iSortTab, iRead, regRow+i) + goto _7 + _7: + ; + i = i - 1 + } + switch eDest { + case int32(SRT_Table): + fallthrough + case int32(SRT_EphemTab): + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iSortTab, nKey+bSeq, regRow) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iParm, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, regRow, regRowid) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + case int32(SRT_Set): + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), regRow, nColumn, regRowid, (*TSelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nColumn) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, regRowid, regRow, nColumn) + case int32(SRT_Mem): + /* The LIMIT clause will terminate the loop for us */ + case int32(SRT_Upfrom): + i2 = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regRow+libc.BoolInt32(i2 < 0), nColumn-libc.BoolInt32(i2 < 0), r1) + if i2 < 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, r1, regRow) + } else { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, r1, regRow, i2) + } + default: + if eDest == int32(SRT_Output) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst, nColumn) + } else { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm) + } + break + } + if regRowid != 0 { + if eDest == int32(SRT_Set) { + _sqlite3ReleaseTempRange(tls, pParse, regRow, nColumn) + } else { + _sqlite3ReleaseTempReg(tls, pParse, regRow) + } + _sqlite3ReleaseTempReg(tls, pParse, regRowid) + } + /* The bottom of the loop + */ + _sqlite3VdbeResolveLabel(tls, v, addrContinue) + if libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&int32(SORTFLAG_UseSorter) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterNext), iTab, addr) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iTab, addr) + } + if (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn) + } + _sqlite3VdbeResolveLabel(tls, v, addrBreak) +} + +// C documentation +// +// /* +// ** This routine generates VDBE code to compute the content of a WITH RECURSIVE +// ** query of the form: +// ** +// ** AS ( UNION [ALL] ) +// ** \___________/ \_______________/ +// ** p->pPrior p +// ** +// ** +// ** There is exactly one reference to the recursive-table in the FROM clause +// ** of recursive-query, marked with the SrcList->a[].fg.isRecursive flag. +// ** +// ** The setup-query runs once to generate an initial set of rows that go +// ** into a Queue table. Rows are extracted from the Queue table one by +// ** one. Each row extracted from Queue is output to pDest. Then the single +// ** extracted row (now in the iCurrent table) becomes the content of the +// ** recursive-table for a recursive-query run. The output of the recursive-query +// ** is added back into the Queue table. Then another row is extracted from Queue +// ** and the iteration continues until the Queue table is empty. +// ** +// ** If the compound query operator is UNION then no duplicate rows are ever +// ** inserted into the Queue table. The iDistinct table keeps a copy of all rows +// ** that have ever been inserted into Queue and causes duplicates to be +// ** discarded. If the operator is UNION ALL, then duplicates are allowed. +// ** +// ** If the query has an ORDER BY, then entries in the Queue table are kept in +// ** ORDER BY order and the first entry is extracted for each cycle. Without +// ** an ORDER BY, the Queue table is just a FIFO. +// ** +// ** If a LIMIT clause is provided, then the iteration stops after LIMIT rows +// ** have been output to pDest. A LIMIT of zero means to output no rows and a +// ** negative LIMIT means to output all rows. If there is also an OFFSET clause +// ** with a positive value, then the first OFFSET outputs are discarded rather +// ** than being sent to pDest. The LIMIT count does not begin until after OFFSET +// ** rows have been skipped. +// */ +func _generateWithRecursiveQuery(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var addrBreak, addrCont, addrTop, eDest, i, iCurrent, iDistinct, iQueue, nCol, rc, regCurrent, regLimit, regOffset, v1 int32 + var apColl, pFirstRec, pKeyInfo, pKeyInfo1, pLimit, pOrderBy, pSetup, pSrc, v, v4 uintptr + var _ /* destQueue at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrBreak, addrCont, addrTop, apColl, eDest, i, iCurrent, iDistinct, iQueue, nCol, pFirstRec, pKeyInfo, pKeyInfo1, pLimit, pOrderBy, pSetup, pSrc, rc, regCurrent, regLimit, regOffset, v, v1, v4 + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc /* The FROM clause of the recursive query */ + nCol = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr /* Number of columns in the recursive table */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* CONTINUE and BREAK addresses */ + iCurrent = 0 /* The Queue table */ + iDistinct = 0 /* To ensure unique results if UNION */ + eDest = int32(SRT_Fifo) /* Registers used by LIMIT and OFFSET */ + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21046, 0) + return + } + /* Obtain authorization to do a recursive query */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_RECURSIVE), uintptr(0), uintptr(0), uintptr(0)) != 0 { + return + } + /* Process the LIMIT and OFFSET clauses, if they exist */ + addrBreak = _sqlite3VdbeMakeLabel(tls, pParse) + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(320) /* 4 billion rows */ + _computeLimitRegisters(tls, pParse, p, addrBreak) + pLimit = (*TSelect)(unsafe.Pointer(p)).FpLimit + regLimit = (*TSelect)(unsafe.Pointer(p)).FiLimit + regOffset = (*TSelect)(unsafe.Pointer(p)).FiOffset + (*TSelect)(unsafe.Pointer(p)).FpLimit = uintptr(0) + v1 = libc.Int32FromInt32(0) + (*TSelect)(unsafe.Pointer(p)).FiOffset = v1 + (*TSelect)(unsafe.Pointer(p)).FiLimit = v1 + pOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + /* Locate the cursor number of the Current table */ + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 24 + 4))&0x80>>7) != 0 { + iCurrent = (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FiCursor + break + } + goto _2 + _2: + ; + i = i + 1 + } + /* Allocate cursors numbers for Queue and Distinct. The cursor number for + ** the Distinct table must be exactly one greater than Queue in order + ** for the SRT_DistFifo and SRT_DistQueue destinations to work. */ + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iQueue = v1 + if libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop) == int32(TK_UNION) { + if pOrderBy != 0 { + v1 = int32(SRT_DistQueue) + } else { + v1 = int32(SRT_DistFifo) + } + eDest = v1 + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iDistinct = v1 + } else { + if pOrderBy != 0 { + v1 = int32(SRT_Queue) + } else { + v1 = int32(SRT_Fifo) + } + eDest = v1 + } + _sqlite3SelectDestInit(tls, bp, eDest, iQueue) + /* Allocate cursors for Current, Queue, and Distinct. */ + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regCurrent = v1 + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenPseudo), iCurrent, regCurrent, nCol) + if pOrderBy != 0 { + pKeyInfo = _multiSelectByMergeKeyInfo(tls, pParse, p, int32(1)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), iQueue, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr+int32(2), 0, pKeyInfo, -int32(9)) + (**(**TSelectDest)(__ccgo_up(bp))).FpOrderBy = pOrderBy + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), iQueue, nCol) + } + if iDistinct != 0 { /* For looping through pKeyInfo->aColl[] */ + nCol = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr + pKeyInfo1 = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, nCol, int32(1)) + if pKeyInfo1 != 0 { + i = 0 + apColl = pKeyInfo1 + 32 + for { + if !(i < nCol) { + break + } + **(**uintptr)(__ccgo_up(apColl)) = _multiSelectCollSeq(tls, pParse, p, i) + if uintptr(0) == **(**uintptr)(__ccgo_up(apColl)) { + **(**uintptr)(__ccgo_up(apColl)) = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FpDfltColl + } + goto _11 + _11: + ; + i = i + 1 + apColl += 8 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), iDistinct, nCol, 0, pKeyInfo1, -int32(9)) + } else { + } + } + /* Detach the ORDER BY clause from the compound SELECT */ + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + /* Figure out how many elements of the compound SELECT are part of the + ** recursive query. Make sure no recursive elements use aggregate + ** functions. Mark the recursive elements as UNION ALL even if they + ** are really UNION because the distinctness will be enforced by the + ** iDistinct table. pFirstRec is left pointing to the left-most + ** recursive term of the CTE. + */ + pFirstRec = p + for { + if !(pFirstRec != uintptr(0)) { + break + } + if (*TSelect)(unsafe.Pointer(pFirstRec)).FselFlags&uint32(SF_Aggregate) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21095, 0) + goto end_of_recursive_query + } + (*TSelect)(unsafe.Pointer(pFirstRec)).Fop = uint8(TK_ALL) + if (*TSelect)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior)).FselFlags&uint32(SF_Recursive) == uint32(0) { + break + } + goto _12 + _12: + ; + pFirstRec = (*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior + } + /* Store the results of the setup-query in Queue. */ + pSetup = (*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior + (*TSelect)(unsafe.Pointer(pSetup)).FpNext = uintptr(0) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21137, 0) + rc = _sqlite3Select(tls, pParse, pSetup, bp) + (*TSelect)(unsafe.Pointer(pSetup)).FpNext = p + if rc != 0 { + goto end_of_recursive_query + } + /* Find the next row in the Queue and output that row */ + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iQueue, addrBreak) + /* Transfer the next row in Queue over to Current */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iCurrent) /* To reset column cache */ + if pOrderBy != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iQueue, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr+int32(1), regCurrent) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowData), iQueue, regCurrent) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_Delete), iQueue) + /* Output the single row in Current */ + addrCont = _sqlite3VdbeMakeLabel(tls, pParse) + _codeOffset(tls, v, regOffset, addrCont) + _selectInnerLoop(tls, pParse, p, iCurrent, uintptr(0), uintptr(0), pDest, addrCont, addrBreak) + if regLimit != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_DecrJumpZero), regLimit, addrBreak) + } + _sqlite3VdbeResolveLabel(tls, v, addrCont) + /* Execute the recursive SELECT taking the single row in Current as + ** the value for the recursive-table. Store the results in the Queue. + */ + (*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior = uintptr(0) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21143, 0) + _sqlite3Select(tls, pParse, p, bp) + (*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior = pSetup + /* Keep running the loop until the Queue is empty */ + _sqlite3VdbeGoto(tls, v, addrTop) + _sqlite3VdbeResolveLabel(tls, v, addrBreak) + goto end_of_recursive_query +end_of_recursive_query: + ; + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = pOrderBy + (*TSelect)(unsafe.Pointer(p)).FpLimit = pLimit + return +} + +// C documentation +// +// /* +// ** Each call to sqlite3_rtree_geometry_callback() or +// ** sqlite3_rtree_query_callback() creates an ordinary SQLite +// ** scalar function that is implemented by this routine. +// ** +// ** All this function does is construct an RtreeMatchArg object that +// ** contains the geometry-checking callback routines and a list of +// ** parameters to this function, then return that RtreeMatchArg object +// ** as a BLOB. +// ** +// ** The R-Tree MATCH operator will read the returned BLOB, deserialize +// ** the RtreeMatchArg object, and use the RtreeMatchArg object to figure +// ** out which elements of the R-Tree should be returned by the query. +// */ +func _geomCallback(tls *libc.TLS, ctx uintptr, nArg int32, aArg uintptr) { + var i, memErr int32 + var nBlob Tsqlite3_int64 + var pBlob, pGeomCtx uintptr + _, _, _, _, _ = i, memErr, nBlob, pBlob, pGeomCtx + pGeomCtx = Xsqlite3_user_data(tls, ctx) + memErr = 0 + nBlob = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+56) + libc.Uint64FromInt32(nArg)*uint64(8) + libc.Uint64FromInt32(nArg)*uint64(8)) + pBlob = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nBlob)) + if !(pBlob != 0) { + Xsqlite3_result_error_nomem(tls, ctx) + } else { + (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FiSize = libc.Uint32FromInt64(nBlob) + (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb = **(**TRtreeGeomCallback)(__ccgo_up(pGeomCtx)) + (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam = pBlob + 56 + uintptr(nArg)*8 + (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam = nArg + i = 0 + for { + if !(i < nArg) { + break + } + **(**uintptr)(__ccgo_up((*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam + uintptr(i)*8)) = Xsqlite3_value_dup(tls, **(**uintptr)(__ccgo_up(aArg + uintptr(i)*8))) + if **(**uintptr)(__ccgo_up((*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam + uintptr(i)*8)) == uintptr(0) { + memErr = int32(1) + } + *(*TRtreeDValue)(unsafe.Pointer(pBlob + 56 + uintptr(i)*8)) = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(aArg + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + if memErr != 0 { + Xsqlite3_result_error_nomem(tls, ctx) + _rtreeMatchArgFree(tls, pBlob) + } else { + Xsqlite3_result_pointer(tls, ctx, pBlob, __ccgo_ts+27817, __ccgo_fp(_rtreeMatchArgFree)) + } + } +} + +// C documentation +// +// /* +// ** If pPoly is a polygon, compute its bounding box. Then: +// ** +// ** (1) if aCoord!=0 store the bounding box in aCoord, returning NULL +// ** (2) otherwise, compute a GeoPoly for the bounding box and return the +// ** new GeoPoly +// ** +// ** If pPoly is NULL but aCoord is not NULL, then compute a new GeoPoly from +// ** the bounding box in aCoord and return a pointer to that GeoPoly. +// */ +func _geopolyBBox(tls *libc.TLS, context uintptr, pPoly uintptr, aCoord uintptr, pRc uintptr) (r1 uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var mnX, mnY, mxX, mxY, v3 float32 + var p, pOut uintptr + var r float64 + var _ /* ii at bp+0 */ int32 + _, _, _, _, _, _, _, _ = mnX, mnY, mxX, mxY, p, pOut, r, v3 + pOut = uintptr(0) + if pPoly == uintptr(0) && aCoord != uintptr(0) { + p = uintptr(0) + mnX = *(*TRtreeValue)(unsafe.Pointer(aCoord)) + mxX = *(*TRtreeValue)(unsafe.Pointer(aCoord + 1*4)) + mnY = *(*TRtreeValue)(unsafe.Pointer(aCoord + 2*4)) + mxY = *(*TRtreeValue)(unsafe.Pointer(aCoord + 3*4)) + goto geopolyBboxFill + } else { + p = _geopolyFuncParam(tls, context, pPoly, pRc) + } + if !(p != 0) { + goto _1 + } + v3 = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4)) + mxX = v3 + mnX = v3 + v3 = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) + mxY = v3 + mnY = v3 + **(**int32)(__ccgo_up(bp)) = int32(1) + for { + if !(**(**int32)(__ccgo_up(bp)) < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) { + break + } + r = float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(**(**int32)(__ccgo_up(bp))*int32(2))*4))) + if r < float64(mnX) { + mnX = float32(r) + } else { + if r > float64(mxX) { + mxX = float32(r) + } + } + r = float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(**(**int32)(__ccgo_up(bp))*int32(2)+int32(1))*4))) + if r < float64(mnY) { + mnY = float32(r) + } else { + if r > float64(mxY) { + mxY = float32(r) + } + } + goto _5 + _5: + ; + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + } + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = SQLITE_OK + } + if !(aCoord == uintptr(0)) { + goto _6 + } + goto geopolyBboxFill +geopolyBboxFill: + ; + pOut = Xsqlite3_realloc64(tls, p, uint64(libc.Uint64FromInt64(40)+libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)*libc.Uint64FromInt32(libc.Int32FromInt32(4)-libc.Int32FromInt32(4)))) + if pOut == uintptr(0) { + Xsqlite3_free(tls, p) + if context != 0 { + Xsqlite3_result_error_nomem(tls, context) + } + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + return uintptr(0) + } + (*TGeoPoly)(unsafe.Pointer(pOut)).FnVertex = int32(4) + **(**int32)(__ccgo_up(bp)) = int32(1) + **(**uint8)(__ccgo_up(pOut + 4)) = **(**uint8)(__ccgo_up(bp)) + **(**uint8)(__ccgo_up(pOut + 4 + 1)) = uint8(0) + **(**uint8)(__ccgo_up(pOut + 4 + 2)) = uint8(0) + **(**uint8)(__ccgo_up(pOut + 4 + 3)) = uint8(4) + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4)) = mnX + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) = mnY + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(2))*4)) = mxX + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) = mnY + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(2))*4)) = mxX + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) = mxY + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(2))*4)) = mnX + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) = mxY + goto _7 +_6: + ; + Xsqlite3_free(tls, p) + *(*TRtreeValue)(unsafe.Pointer(aCoord)) = mnX + *(*TRtreeValue)(unsafe.Pointer(aCoord + 1*4)) = mxX + *(*TRtreeValue)(unsafe.Pointer(aCoord + 2*4)) = mnY + *(*TRtreeValue)(unsafe.Pointer(aCoord + 3*4)) = mxY +_7: + ; + goto _2 +_1: + ; + if aCoord != 0 { + libc.X__builtin___memset_chk(tls, aCoord, 0, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(4), ^t__predefined_size_t(0)) + } +_2: + ; + return pOut +} + +// C documentation +// +// /* +// ** Implementation of the geopoly_group_bbox(X) aggregate SQL function. +// */ +func _geopolyBBoxStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pBBox uintptr + var _ /* a at bp+0 */ [4]TRtreeCoord + var _ /* rc at bp+16 */ int32 + _ = pBBox + **(**int32)(__ccgo_up(bp + 16)) = SQLITE_OK + _ = argc + _geopolyBBox(tls, context, **(**uintptr)(__ccgo_up(argv)), bp, bp+16) + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + pBBox = Xsqlite3_aggregate_context(tls, context, int32(20)) + if pBBox == uintptr(0) { + return + } + if libc.AtomicLoadPInt32(pBBox) == 0 { + libc.AtomicStorePInt32(pBBox, int32(1)) + libc.X__builtin___memcpy_chk(tls, pBBox+4, bp, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(4), ^t__predefined_size_t(0)) + } else { + if *(*TRtreeValue)(unsafe.Pointer(bp)) < *(*TRtreeValue)(unsafe.Pointer(pBBox + 4)) { + **(**TRtreeCoord)(__ccgo_up(pBBox + 4)) = (**(**[4]TRtreeCoord)(__ccgo_up(bp)))[0] + } + if *(*TRtreeValue)(unsafe.Pointer(bp + 1*4)) > *(*TRtreeValue)(unsafe.Pointer(pBBox + 4 + 1*4)) { + **(**TRtreeCoord)(__ccgo_up(pBBox + 4 + 1*4)) = (**(**[4]TRtreeCoord)(__ccgo_up(bp)))[int32(1)] + } + if *(*TRtreeValue)(unsafe.Pointer(bp + 2*4)) < *(*TRtreeValue)(unsafe.Pointer(pBBox + 4 + 2*4)) { + **(**TRtreeCoord)(__ccgo_up(pBBox + 4 + 2*4)) = (**(**[4]TRtreeCoord)(__ccgo_up(bp)))[int32(2)] + } + if *(*TRtreeValue)(unsafe.Pointer(bp + 3*4)) > *(*TRtreeValue)(unsafe.Pointer(pBBox + 4 + 3*4)) { + **(**TRtreeCoord)(__ccgo_up(pBBox + 4 + 3*4)) = (**(**[4]TRtreeCoord)(__ccgo_up(bp)))[int32(3)] + } + } + } +} + +// C documentation +// +// /* +// ** Rtree virtual table module xBestIndex method. There are three +// ** table scan strategies to choose from (in order from most to +// ** least desirable): +// ** +// ** idxNum idxStr Strategy +// ** ------------------------------------------------ +// ** 1 "rowid" Direct lookup by rowid. +// ** 2 "rtree" R-tree overlap query using geopoly_overlap() +// ** 3 "rtree" R-tree within query using geopoly_within() +// ** 4 "fullscan" full-table scan. +// ** ------------------------------------------------ +// */ +func _geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + var iFuncTerm, iRowidTerm, idxNum, ii int32 + var p uintptr + _, _, _, _, _ = iFuncTerm, iRowidTerm, idxNum, ii, p + iRowidTerm = -int32(1) + iFuncTerm = -int32(1) + idxNum = 0 + _ = tab + ii = 0 + for { + if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12 + if !((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) { + goto _1 + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) { + iRowidTerm = ii + break + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) >= int32(SQLITE_INDEX_CONSTRAINT_FUNCTION) { + /* p->op==SQLITE_INDEX_CONSTRAINT_FUNCTION for geopoly_overlap() + ** p->op==(SQLITE_INDEX_CONTRAINT_FUNCTION+1) for geopoly_within(). + ** See geopolyFindFunction() */ + iFuncTerm = ii + idxNum = libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - int32(SQLITE_INDEX_CONSTRAINT_FUNCTION) + int32(2) + } + goto _1 + _1: + ; + ii = ii + 1 + } + if iRowidTerm >= 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 18310 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8))).Fomit = uint8(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(30) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = int32(SQLITE_INDEX_SCAN_UNIQUE) + return SQLITE_OK + } + if iFuncTerm >= 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 30295 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8))).Fomit = uint8(0) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(300) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10) + return SQLITE_OK + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(4) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 30301 + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(3e+06) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100000) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** GEOPOLY virtual table module xFilter method. +// ** +// ** Query plans: +// ** +// ** 1 rowid lookup +// ** 2 search for objects overlapping the same bounding box +// ** that contains polygon argv[0] +// ** 3 search for objects overlapping the same bounding box +// ** that contains polygon argv[0] +// ** 4 full table scan +// */ +func _geopolyFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iRowid Ti64 + var p, p1, pCsr, pNew, pRtree, v1 uintptr + var _ /* bbox at bp+32 */ [4]TRtreeCoord + var _ /* iCell at bp+12 */ int32 + var _ /* iNode at bp+24 */ Ti64 + var _ /* pLeaf at bp+16 */ uintptr + var _ /* pRoot at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _, _, _, _, _, _ = iRowid, p, p1, pCsr, pNew, pRtree, v1 + pRtree = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab + pCsr = pVtabCursor + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 12)) = 0 + _ = idxStr + _rtreeReference(tls, pRtree) + /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ + _resetCursor(tls, pCsr) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FiStrategy = idxNum + if idxNum == int32(1) { /* Search point for the leaf */ + iRowid = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + **(**Ti64)(__ccgo_up(bp + 24)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = _findLeafNode(tls, pRtree, iRowid, bp+16, bp+24) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 16)) != uintptr(0) { + p = _rtreeSearchPointNew(tls, pCsr, float64(0), uint8(0)) + /* Always returns pCsr->sPoint */ + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp + 16)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).Fid = **(**Ti64)(__ccgo_up(bp + 24)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = uint8(PARTLY_WITHIN) + **(**int32)(__ccgo_up(bp + 8)) = _nodeRowidIndex(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 16)), iRowid, bp+12) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 12))) + } else { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FatEOF = uint8(1) + } + } else { + /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array + ** with the configured constraints. + */ + **(**int32)(__ccgo_up(bp + 8)) = _nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && idxNum <= int32(3) { + _geopolyBBox(tls, uintptr(0), **(**uintptr)(__ccgo_up(argv)), bp+32, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + goto geopoly_filter_end + } + v1 = Xsqlite3_malloc(tls, libc.Int32FromUint64(libc.Uint64FromInt64(24)*libc.Uint64FromInt32(4))) + p1 = v1 + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = v1 + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = int32(4) + if p1 == uintptr(0) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, libc.Uint64FromInt64(24)*libc.Uint64FromInt32(4), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, pCsr+128, 0, uint64(4)*libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiDepth+libc.Int32FromInt32(1)), ^t__predefined_size_t(0)) + if idxNum == int32(2) { + /* Overlap query */ + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('B') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0 + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 1*4))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('D') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(1) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('B') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(2) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 3*4))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('D') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(3) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 2*4))) + } else { + /* Within query */ + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('D') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0 + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('B') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(1) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 1*4))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('D') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(2) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 2*4))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('B') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(3) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 3*4))) + } + } + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + pNew = _rtreeSearchPointNew(tls, pCsr, float64(0), libc.Uint8FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiDepth+libc.Int32FromInt32(1))) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_NOMEM) + goto geopoly_filter_end + } + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = uint8(0) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = uint8(PARTLY_WITHIN) + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = _rtreeStepToLeaf(tls, pCsr) + } + } + goto geopoly_filter_end +geopoly_filter_end: + ; + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + _rtreeRelease(tls, pRtree) + return **(**int32)(__ccgo_up(bp + 8)) +} + +// C documentation +// +// /* +// ** Report that geopoly_overlap() is an overloaded function suitable +// ** for use in xBestIndex. +// */ +func _geopolyFindFunction(tls *libc.TLS, pVtab uintptr, nArg int32, zName uintptr, __ccgo_fp_pxFunc uintptr, ppArg uintptr) (r int32) { + _ = pVtab + _ = nArg + if Xsqlite3_stricmp(tls, zName, __ccgo_ts+30350) == 0 { + **(**uintptr)(__ccgo_up(__ccgo_fp_pxFunc)) = __ccgo_fp(_geopolyOverlapFunc) + **(**uintptr)(__ccgo_up(ppArg)) = uintptr(0) + return int32(SQLITE_INDEX_CONSTRAINT_FUNCTION) + } + if Xsqlite3_stricmp(tls, zName, __ccgo_ts+30366) == 0 { + **(**uintptr)(__ccgo_up(__ccgo_fp_pxFunc)) = __ccgo_fp(_geopolyWithinFunc) + **(**uintptr)(__ccgo_up(ppArg)) = uintptr(0) + return libc.Int32FromInt32(SQLITE_INDEX_CONSTRAINT_FUNCTION) + libc.Int32FromInt32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Given a function parameter, try to interpret it as a polygon, either +// ** in the binary format or JSON text. Compute a GeoPoly object and +// ** return a pointer to that object. Or if the input is not a well-formed +// ** polygon, put an error message in sqlite3_context and return NULL. +// */ +func _geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, p, zJson, v4 uintptr + var ii, nByte, nVertex, v1 int32 + var v2 bool + var _ /* x at bp+0 */ int32 + _, _, _, _, _, _, _, _, _ = a, ii, nByte, nVertex, p, zJson, v1, v2, v4 + p = uintptr(0) + if v2 = Xsqlite3_value_type(tls, pVal) == int32(SQLITE_BLOB); v2 { + v1 = Xsqlite3_value_bytes(tls, pVal) + nByte = v1 + } + if v2 && v1 >= libc.Int32FromUint64(libc.Uint64FromInt32(4)+libc.Uint64FromInt32(6)*libc.Uint64FromInt64(4)) { + a = Xsqlite3_value_blob(tls, pVal) + if a == uintptr(0) { + if pCtx != 0 { + Xsqlite3_result_error_nomem(tls, pCtx) + } + return uintptr(0) + } + nVertex = libc.Int32FromUint8(**(**uint8)(__ccgo_up(a + 1)))< module name +// ** argv[1] -> database name +// ** argv[2] -> table name +// ** argv[...] -> column names... +// */ +func _geopolyInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr, isCreate int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var ii, rc, v2 int32 + var nDb, nName Tsqlite3_int64 + var pRtree, pSql, zSql uintptr + _, _, _, _, _, _, _, _ = ii, nDb, nName, pRtree, pSql, rc, zSql, v2 + rc = SQLITE_OK + _ = pAux + if argc >= libc.Int32FromInt32(RTREE_MAX_AUX_COLUMN)+libc.Int32FromInt32(4) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+30232, 0) + return int32(SQLITE_ERROR) + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_CONSTRAINT_SUPPORT), libc.VaList(bp+8, int32(1))) + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + /* Allocate the sqlite3_vtab structure */ + nDb = libc.Int64FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 1*8)))) + nName = libc.Int64FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + pRtree = Xsqlite3_malloc64(tls, uint64(976)+libc.Uint64FromInt64(nDb)+libc.Uint64FromInt64(nName*int64(2))+uint64(8)) + if !(pRtree != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pRtree, 0, uint64(uint64(976)+libc.Uint64FromInt64(nDb)+libc.Uint64FromInt64(nName*int64(2))+uint64(8)), ^t__predefined_size_t(0)) + (*TRtree)(unsafe.Pointer(pRtree)).FnBusy = uint32(1) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&_rtreeModule)) + (*TRtree)(unsafe.Pointer(pRtree)).FzDb = pRtree + 1*976 + (*TRtree)(unsafe.Pointer(pRtree)).FzName = (*TRtree)(unsafe.Pointer(pRtree)).FzDb + uintptr(nDb+int64(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName = (*TRtree)(unsafe.Pointer(pRtree)).FzName + uintptr(nName+int64(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FeCoordType = uint8(RTREE_COORD_REAL32) + (*TRtree)(unsafe.Pointer(pRtree)).FnDim = uint8(2) + (*TRtree)(unsafe.Pointer(pRtree)).FnDim2 = uint8(4) + libc.X__builtin___memcpy_chk(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, **(**uintptr)(__ccgo_up(argv + 1*8)), libc.Uint64FromInt64(nDb), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt64(nName), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt64(nName), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName+uintptr(nName), __ccgo_ts+29274, uint64(6), ^t__predefined_size_t(0)) + /* Create/Connect to the underlying relational database schema. If + ** that is successful, call sqlite3_declare_vtab() to configure + ** the r-tree table schema. + */ + pSql = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+30269, 0) + (*TRtree)(unsafe.Pointer(pRtree)).FnAux = uint16(1) /* Add one for _shape */ + (*TRtree)(unsafe.Pointer(pRtree)).FnAuxNotNull = uint8(1) /* The _shape column is always not-null */ + ii = int32(3) + for { + if !(ii < argc) { + break + } + (*TRtree)(unsafe.Pointer(pRtree)).FnAux = (*TRtree)(unsafe.Pointer(pRtree)).FnAux + 1 + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+30291, libc.VaList(bp+8, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8)))) + goto _1 + _1: + ; + ii = ii + 1 + } + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+29331, 0) + zSql = Xsqlite3_str_finish(tls, pSql) + if !(zSql != 0) { + rc = int32(SQLITE_NOMEM) + } else { + v2 = Xsqlite3_declare_vtab(tls, db, zSql) + rc = v2 + if SQLITE_OK != v2 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + } + } + Xsqlite3_free(tls, zSql) + if rc != 0 { + goto geopolyInit_fail + } + (*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell = libc.Uint8FromInt32(int32(8) + libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)*int32(4)) + /* Figure out the node size to use. */ + rc = _getNodeSize(tls, db, pRtree, isCreate, pzErr) + if rc != 0 { + goto geopolyInit_fail + } + rc = _rtreeSqlInit(tls, pRtree, db, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), isCreate) + if rc != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + goto geopolyInit_fail + } + **(**uintptr)(__ccgo_up(ppVtab)) = pRtree + return SQLITE_OK + goto geopolyInit_fail +geopolyInit_fail: + ; + if rc == SQLITE_OK { + rc = int32(SQLITE_ERROR) + } + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** SQL function: geopoly_json(X) +// ** +// ** Interpret X as a polygon and render it as a JSON array +// ** of coordinates. Or, if X is not a valid polygon, return NULL. +// */ +func _geopolyJsonFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, x uintptr + var i int32 + _, _, _, _ = db, i, p, x + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + _ = argc + if p != 0 { + db = Xsqlite3_context_db_handle(tls, context) + x = Xsqlite3_str_new(tls, db) + Xsqlite3_str_append(tls, x, __ccgo_ts+26996, int32(1)) + i = 0 + for { + if !(i < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) { + break + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+30159, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2)+int32(1))*4))))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+30170, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4))))) + Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -int32(1), __ccgo_fp(Xsqlite3_free)) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Determine the overlap between two polygons +// */ +func _geopolyOverlap(tls *libc.TLS, p1 uintptr, p2 uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iMask, needSort, rc, v1 int32 + var nByte, nVertex Tsqlite3_int64 + var p, pActive, pPrev, pSeg, pThisEvent, v5 uintptr + var rX, y, v2 float64 + var _ /* aOverlap at bp+0 */ [4]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iMask, nByte, nVertex, needSort, p, pActive, pPrev, pSeg, pThisEvent, rX, rc, y, v1, v2, v5 + nVertex = int64((*TGeoPoly)(unsafe.Pointer(p1)).FnVertex + (*TGeoPoly)(unsafe.Pointer(p2)).FnVertex + int32(2)) + rc = 0 + needSort = 0 + pActive = uintptr(0) + nByte = libc.Int64FromUint64(uint64(32)*libc.Uint64FromInt64(nVertex)*uint64(2) + uint64(48)*libc.Uint64FromInt64(nVertex) + uint64(24)) + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if p == uintptr(0) { + return -int32(1) + } + (*TGeoOverlap)(unsafe.Pointer(p)).FaEvent = p + 1*24 + (*TGeoOverlap)(unsafe.Pointer(p)).FaSegment = (*TGeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr(nVertex*int64(2))*32 + v1 = libc.Int32FromInt32(0) + (*TGeoOverlap)(unsafe.Pointer(p)).FnSegment = v1 + (*TGeoOverlap)(unsafe.Pointer(p)).FnEvent = v1 + _geopolyAddSegments(tls, p, p1, uint8(1)) + _geopolyAddSegments(tls, p, p2, uint8(2)) + pThisEvent = _geopolySortEventsByX(tls, (*TGeoOverlap)(unsafe.Pointer(p)).FaEvent, (*TGeoOverlap)(unsafe.Pointer(p)).FnEvent) + if pThisEvent != 0 && (*TGeoEvent)(unsafe.Pointer(pThisEvent)).Fx == float64(0) { + v2 = -libc.Float64FromFloat64(1) + } else { + v2 = float64(0) + } + rX = v2 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(4), ^t__predefined_size_t(0)) + for pThisEvent != 0 { + if (*TGeoEvent)(unsafe.Pointer(pThisEvent)).Fx != rX { + pPrev = uintptr(0) + iMask = 0 + rX = (*TGeoEvent)(unsafe.Pointer(pThisEvent)).Fx + if needSort != 0 { + pActive = _geopolySortSegmentsByYAndC(tls, pActive) + needSort = 0 + } + pSeg = pActive + for { + if !(pSeg != 0) { + break + } + if pPrev != 0 { + if (*TGeoSegment)(unsafe.Pointer(pPrev)).Fy != (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy { + (**(**[4]uint8)(__ccgo_up(bp)))[iMask] = uint8(1) + } + } + iMask = iMask ^ libc.Int32FromUint8((*TGeoSegment)(unsafe.Pointer(pSeg)).Fside) + pPrev = pSeg + goto _3 + _3: + ; + pSeg = (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext + } + pPrev = uintptr(0) + pSeg = pActive + for { + if !(pSeg != 0) { + break + } + y = float64((*TGeoSegment)(unsafe.Pointer(pSeg)).FC*rX) + (*TGeoSegment)(unsafe.Pointer(pSeg)).FB + (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy = y + if pPrev != 0 { + if (*TGeoSegment)(unsafe.Pointer(pPrev)).Fy > (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy && libc.Int32FromUint8((*TGeoSegment)(unsafe.Pointer(pPrev)).Fside) != libc.Int32FromUint8((*TGeoSegment)(unsafe.Pointer(pSeg)).Fside) { + rc = int32(1) + goto geopolyOverlapDone + } else { + if (*TGeoSegment)(unsafe.Pointer(pPrev)).Fy != (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy { + (**(**[4]uint8)(__ccgo_up(bp)))[iMask] = uint8(1) + } + } + } + iMask = iMask ^ libc.Int32FromUint8((*TGeoSegment)(unsafe.Pointer(pSeg)).Fside) + pPrev = pSeg + goto _4 + _4: + ; + pSeg = (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext + } + } + if (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FeType == 0 { + /* Add a segment */ + pSeg = (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg + (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy = float64((*TGeoSegment)(unsafe.Pointer(pSeg)).Fy0) + (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext = pActive + pActive = pSeg + needSort = int32(1) + } else { + /* Remove a segment */ + if pActive == (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg { + if pActive != 0 { + v5 = (*TGeoSegment)(unsafe.Pointer(pActive)).FpNext + } else { + v5 = uintptr(0) + } + pActive = v5 + } else { + pSeg = pActive + for { + if !(pSeg != 0) { + break + } + if (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext == (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg { + if (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext != 0 { + v5 = (*TGeoSegment)(unsafe.Pointer((*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext)).FpNext + } else { + v5 = uintptr(0) + } + (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext = v5 + break + } + goto _6 + _6: + ; + pSeg = (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext + } + } + } + pThisEvent = (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FpNext + } + if libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(3)]) == 0 { + rc = 0 + } else { + if libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(1)]) != 0 && libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(2)]) == 0 { + rc = int32(3) + } else { + if libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(1)]) == 0 && libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(2)]) != 0 { + rc = int32(2) + } else { + if libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(1)]) == 0 && libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(2)]) == 0 { + rc = int32(4) + } else { + rc = int32(1) + } + } + } + } + goto geopolyOverlapDone +geopolyOverlapDone: + ; + Xsqlite3_free(tls, p) + return rc +} + +// C documentation +// +// /* +// ** If the input is a well-formed JSON array of coordinates with at least +// ** four coordinates and where each coordinate is itself a two-value array, +// ** then convert the JSON into a GeoPoly object and return a pointer to +// ** that object. +// ** +// ** If any error occurs, return NULL. +// */ +func _geopolyParseJson(tls *libc.TLS, z uintptr, pRc uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aNew, pOut, v1 uintptr + var c int8 + var ii, rc int32 + var v2 bool + var _ /* s at bp+0 */ TGeoParse + var _ /* x at bp+32 */ int32 + _, _, _, _, _, _, _ = aNew, c, ii, pOut, rc, v1, v2 + rc = SQLITE_OK + libc.X__builtin___memset_chk(tls, bp, 0, uint64(32), ^t__predefined_size_t(0)) + (**(**TGeoParse)(__ccgo_up(bp))).Fz = z + if int32(_geopolySkipSpace(tls, bp)) == int32('[') { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + for int32(_geopolySkipSpace(tls, bp)) == int32('[') { + ii = 0 + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + if (**(**TGeoParse)(__ccgo_up(bp))).FnVertex >= (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc { + (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc = (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc*int32(2) + int32(16) + aNew = Xsqlite3_realloc64(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa, uint64(libc.Uint64FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnAlloc)*uint64(4)*uint64(2))) + if aNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + break + } + (**(**TGeoParse)(__ccgo_up(bp))).Fa = aNew + } + for { + if ii <= int32(1) { + v1 = (**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)+ii)*4 + } else { + v1 = uintptr(0) + } + if !(_geopolyParseNumber(tls, bp, v1) != 0) { + break + } + ii = ii + 1 + if ii == int32(2) { + (**(**TGeoParse)(__ccgo_up(bp))).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex + 1 + } + c = _geopolySkipSpace(tls, bp) + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + if int32(c) == int32(',') { + continue + } + if int32(c) == int32(']') && ii >= int32(2) { + break + } + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + rc = int32(SQLITE_ERROR) + goto parse_json_err + } + if int32(_geopolySkipSpace(tls, bp)) == int32(',') { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + continue + } + break + } + if v2 = int32(_geopolySkipSpace(tls, bp)) == int32(']') && (**(**TGeoParse)(__ccgo_up(bp))).FnVertex >= int32(4) && **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa)) == **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)-int32(2))*4)) && **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + 1*4)) == **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)-int32(1))*4)); v2 { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + } + if v2 && int32(_geopolySkipSpace(tls, bp)) == libc.Int32FromInt32(0) { + **(**int32)(__ccgo_up(bp + 32)) = int32(1) + (**(**TGeoParse)(__ccgo_up(bp))).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex - 1 /* Remove the redundant vertex at the end */ + pOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(40)+uint64(libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2))*libc.Uint64FromInt64(int64((**(**TGeoParse)(__ccgo_up(bp))).FnVertex)-libc.Int64FromInt32(4))) + **(**int32)(__ccgo_up(bp + 32)) = int32(1) + if pOut == uintptr(0) { + goto parse_json_err + } + (*TGeoPoly)(unsafe.Pointer(pOut)).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex + libc.X__builtin___memcpy_chk(tls, pOut+8, (**(**TGeoParse)(__ccgo_up(bp))).Fa, libc.Uint64FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2))*uint64(4), ^t__predefined_size_t(0)) + **(**uint8)(__ccgo_up(pOut + 4)) = **(**uint8)(__ccgo_up(bp + 32)) + **(**uint8)(__ccgo_up(pOut + 4 + 1)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex >> int32(16) & int32(0xff)) + **(**uint8)(__ccgo_up(pOut + 4 + 2)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex >> int32(8) & int32(0xff)) + **(**uint8)(__ccgo_up(pOut + 4 + 3)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex & int32(0xff)) + Xsqlite3_free(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa) + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = SQLITE_OK + } + return pOut + } else { + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + rc = int32(SQLITE_ERROR) + } + } + goto parse_json_err +parse_json_err: + ; + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = rc + } + Xsqlite3_free(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa) + return uintptr(0) +} + +// C documentation +// +// /* +// ** SQL function: geopoly_svg(X, ....) +// ** +// ** Interpret X as a polygon and render it as a SVG . +// ** Additional arguments are added as attributes to the . +// */ +func _geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var cSep int8 + var db, p, x, z uintptr + var i int32 + _, _, _, _, _, _ = cSep, db, i, p, x, z + if argc < int32(1) { + return + } + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + if p != 0 { + db = Xsqlite3_context_db_handle(tls, context) + x = Xsqlite3_str_new(tls, db) + cSep = int8('\'') + Xsqlite3_str_appendf(tls, x, __ccgo_ts+30181, 0) + i = 0 + for { + if !(i < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) { + break + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+30199, libc.VaList(bp+8, int32(cSep), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2)+int32(1))*4))))) + cSep = int8(' ') + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+30207, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4))))) + i = int32(1) + for { + if !(i < argc) { + break + } + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if z != 0 && **(**int8)(__ccgo_up(z)) != 0 { + Xsqlite3_str_appendf(tls, x, __ccgo_ts+30215, libc.VaList(bp+8, z)) + } + goto _2 + _2: + ; + i = i + 1 + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+30219, 0) + Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -int32(1), __ccgo_fp(Xsqlite3_free)) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** The xUpdate method for GEOPOLY module virtual tables. +// ** +// ** For DELETE: +// ** +// ** argv[0] = the rowid to be deleted +// ** +// ** For INSERT: +// ** +// ** argv[0] = SQL NULL +// ** argv[1] = rowid to insert, or an SQL NULL to select automatically +// ** argv[2] = _shape column +// ** argv[3] = first application-defined column.... +// ** +// ** For UPDATE: +// ** +// ** argv[0] = rowid to modify. Never NULL +// ** argv[1] = rowid after the change. Never NULL +// ** argv[2] = new value for _shape +// ** argv[3] = new value for first application-defined column.... +// */ +func _geopolyUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var coordChange, jj, nChange, newRowidValid, oldRowidValid, rc2, steprc int32 + var newRowid, oldRowid Ti64 + var p, pRtree, pUp, v3 uintptr + var v1 int64 + var v4 bool + var _ /* cell at bp+8 */ TRtreeCell + var _ /* pLeaf at bp+56 */ uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = coordChange, jj, nChange, newRowid, newRowidValid, oldRowid, oldRowidValid, p, pRtree, pUp, rc2, steprc, v1, v3, v4 + pRtree = pVtab + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* True if newRowid is valid */ + coordChange = 0 /* Change in coordinates */ + if (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0 { + /* Unable to write to the btree while another cursor is reading from it, + ** since the write might do a rebalance which would disrupt the read + ** cursor. */ + return libc.Int32FromInt32(SQLITE_LOCKED) | libc.Int32FromInt32(2)< int32(1) && Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData + 1*8))) != int32(SQLITE_NULL)) + if newRowidValid != 0 { + v1 = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(aData + 1*8))) + } else { + v1 = 0 + } + newRowid = v1 + (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid = newRowid + if nData > int32(1) && (!(oldRowidValid != 0) || !(Xsqlite3_value_nochange(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) != 0) || oldRowid != newRowid) { + _geopolyBBox(tls, uintptr(0), **(**uintptr)(__ccgo_up(aData + 2*8)), bp+8+8, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_ERROR) { + (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+30310, 0) + } + goto geopoly_update_end + } + coordChange = int32(1) + /* If a rowid value was supplied, check if it is already present in + ** the table. If so, the constraint has failed. */ + if newRowidValid != 0 && (!(oldRowidValid != 0) || oldRowid != newRowid) { + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid, int32(1), (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid) + steprc = Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + **(**int32)(__ccgo_up(bp)) = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + if int32(SQLITE_ROW) == steprc { + if Xsqlite3_vtab_on_conflict(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb) == int32(SQLITE_REPLACE) { + **(**int32)(__ccgo_up(bp)) = _rtreeDeleteRowid(tls, pRtree, (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid) + } else { + **(**int32)(__ccgo_up(bp)) = _rtreeConstraintError(tls, pRtree, 0) + } + } + } + } + /* If aData[0] is not an SQL NULL value, it is the rowid of a + ** record to delete from the r-tree table. The following block does + ** just that. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (nData == int32(1) || coordChange != 0 && oldRowidValid != 0) { + **(**int32)(__ccgo_up(bp)) = _rtreeDeleteRowid(tls, pRtree, oldRowid) + } + /* If the aData[] array contains more than one element, elements + ** (aData[2]..aData[argc-1]) contain a new record to insert into + ** the r-tree structure. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && nData > int32(1) && coordChange != 0 { + /* Insert the new record into the r-tree */ + **(**uintptr)(__ccgo_up(bp + 56)) = uintptr(0) + if !(newRowidValid != 0) { + **(**int32)(__ccgo_up(bp)) = _rtreeNewRowid(tls, pRtree, bp+8) + } + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _ChooseLeaf(tls, pRtree, bp+8, 0, bp+56) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _rtreeInsertCell(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 56)), bp+8, 0) + rc2 = _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 56))) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = rc2 + } + } + } + /* Change the data */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && nData > int32(1) { + pUp = (*TRtree)(unsafe.Pointer(pRtree)).FpWriteAux + nChange = 0 + Xsqlite3_bind_int64(tls, pUp, int32(1), (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid) + if Xsqlite3_value_nochange(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) != 0 { + Xsqlite3_bind_null(tls, pUp, int32(2)) + } else { + p = uintptr(0) + if v4 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) == int32(SQLITE_TEXT); v4 { + v3 = _geopolyFuncParam(tls, uintptr(0), **(**uintptr)(__ccgo_up(aData + 2*8)), bp) + p = v3 + } + if v4 && v3 != uintptr(0) && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + Xsqlite3_bind_blob(tls, pUp, int32(2), p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_bind_value(tls, pUp, int32(2), **(**uintptr)(__ccgo_up(aData + 2*8))) + } + Xsqlite3_free(tls, p) + nChange = int32(1) + } + jj = int32(1) + for { + if !(jj < nData-int32(2)) { + break + } + nChange = nChange + 1 + Xsqlite3_bind_value(tls, pUp, jj+int32(2), **(**uintptr)(__ccgo_up(aData + uintptr(jj+int32(2))*8))) + goto _5 + _5: + ; + jj = jj + 1 + } + if nChange != 0 { + Xsqlite3_step(tls, pUp) + **(**int32)(__ccgo_up(bp)) = Xsqlite3_reset(tls, pUp) + } + } + goto geopoly_update_end +geopoly_update_end: + ; + _rtreeRelease(tls, pRtree) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Interpret the given string as an auto-vacuum mode value. +// ** +// ** The following strings, "none", "full" and "incremental" are +// ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively. +// */ +func _getAutoVacuum(tls *libc.TLS, z uintptr) (r int32) { + var i, v1 int32 + _, _ = i, v1 + if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+8852) { + return BTREE_AUTOVACUUM_NONE + } + if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19379) { + return int32(BTREE_AUTOVACUUM_FULL) + } + if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19384) { + return int32(BTREE_AUTOVACUUM_INCR) + } + i = _sqlite3Atoi(tls, z) + if i >= 0 && i <= int32(2) { + v1 = i + } else { + v1 = 0 + } + return libc.Int32FromUint8(libc.Uint8FromInt32(v1)) +} + +// C documentation +// +// /* +// ** Find the mode, uid and gid of file zFile. +// */ +func _getFileMode(tls *libc.TLS, zFile uintptr, pMode uintptr, pUid uintptr, pGid uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var rc int32 + var _ /* sStat at bp+0 */ Tstat + _ = rc /* Output of stat() on database file */ + rc = SQLITE_OK + if 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zFile, bp) { + **(**Tmode_t)(__ccgo_up(pMode)) = libc.Uint16FromInt32(libc.Int32FromUint16((**(**Tstat)(__ccgo_up(bp))).Fst_mode) & int32(0777)) + **(**Tuid_t)(__ccgo_up(pUid)) = (**(**Tstat)(__ccgo_up(bp))).Fst_uid + **(**Tgid_t)(__ccgo_up(pGid)) = (**(**Tstat)(__ccgo_up(bp))).Fst_gid + } else { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)<iNodeSize is populated and SQLITE_OK returned. +// ** Otherwise, an SQLite error code is returned. +// ** +// ** If this function is being called as part of an xConnect(), then the rtree +// ** table already exists. In this case the node-size is determined by inspecting +// ** the root node of the tree. +// ** +// ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size. +// ** This ensures that each node is stored on a single database page. If the +// ** database page-size is so large that more than RTREE_MAXCELLS entries +// ** would fit in a single node, use a smaller node-size. +// */ +func _getNodeSize(tls *libc.TLS, db uintptr, pRtree uintptr, isCreate int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc int32 + var zSql uintptr + var _ /* iPageSize at bp+0 */ int32 + _, _ = rc, zSql + if isCreate != 0 { + **(**int32)(__ccgo_up(bp)) = 0 + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+29011, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb)) + rc = _getIntFromStmt(tls, db, zSql, bp) + if rc == SQLITE_OK { + (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize = **(**int32)(__ccgo_up(bp)) - int32(64) + if int32(4)+libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*int32(RTREE_MAXCELLS) < (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize { + (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize = int32(4) + libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*int32(RTREE_MAXCELLS) + } + } else { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, db))) + } + } else { + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+29031, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName)) + rc = _getIntFromStmt(tls, db, zSql, pRtree+32) + if rc != SQLITE_OK { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, db))) + } else { + if (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize < libc.Int32FromInt32(512)-libc.Int32FromInt32(64) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< (*TPager)(unsafe.Pointer(pPager)).FmxPgno { + rc = int32(SQLITE_FULL) + if pgno <= (*TPager)(unsafe.Pointer(pPager)).FdbSize { + _sqlite3PcacheRelease(tls, pPg) + pPg = uintptr(0) + } + goto pager_acquire_err + } + if noContent != 0 { + /* Failure to set the bits in the InJournal bit-vectors is benign. + ** It merely means that we might do some extra work to journal a + ** page that does not need to be journaled. Nevertheless, be sure + ** to test the case where a malloc error occurs while trying to set + ** a bit in a bit vector. + */ + _sqlite3BeginBenignMalloc(tls) + if pgno <= (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize { + _sqlite3BitvecSet(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal, pgno) + } + _addToSavepointBitvecs(tls, pPager, pgno) + _sqlite3EndBenignMalloc(tls) + } + libc.X__builtin___memset_chk(tls, (*TPgHdr)(unsafe.Pointer(pPg)).FpData, 0, libc.Uint64FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize), ^t__predefined_size_t(0)) + } else { + **(**Tu32)(__ccgo_up(pPager + 248 + 1*4)) = **(**Tu32)(__ccgo_up(pPager + 248 + 1*4)) + 1 + rc = _readDbPage(tls, pPg) + if rc != SQLITE_OK { + goto pager_acquire_err + } + } + } + return SQLITE_OK + goto pager_acquire_err +pager_acquire_err: + ; + if pPg != 0 { + _sqlite3PcacheDrop(tls, pPg) + } + _pagerUnlockIfUnused(tls, pPager) + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return rc +} + +// C documentation +// +// /* +// ** Interpret the given string as a temp db location. Return 1 for file +// ** backed temporary databases, 2 for the Red-Black tree in memory database +// ** and 0 to use the compile-time default. +// */ +func _getTempStore(tls *libc.TLS, z uintptr) (r int32) { + if int32(**(**int8)(__ccgo_up(z))) >= int32('0') && int32(**(**int8)(__ccgo_up(z))) <= int32('2') { + return int32(**(**int8)(__ccgo_up(z))) - int32('0') + } else { + if _sqlite3StrICmp(tls, z, __ccgo_ts+18339) == 0 { + return int32(1) + } else { + if _sqlite3StrICmp(tls, z, __ccgo_ts+19396) == 0 { + return int32(2) + } else { + return 0 + } + } + } + return r +} + +func _groupConcatInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var nVS int32 + var pGCC uintptr + _, _ = nVS, pGCC + _ = argc /* Suppress unused parameter warning */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + return + } + pGCC = Xsqlite3_aggregate_context(tls, context, int32(48)) + /* pGCC is always non-NULL since groupConcatStep() will have always + ** run first to initialize it */ + if pGCC != 0 { /* Number of characters to remove */ + /* Must call sqlite3_value_text() to convert the argument into text prior + ** to invoking sqlite3_value_bytes(), in case the text encoding is UTF16 */ + Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + nVS = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + **(**int32)(__ccgo_up(pGCC + 32)) -= int32(1) + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths != uintptr(0) { + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum > 0 { + nVS = nVS + **(**int32)(__ccgo_up((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths)) + libc.X__builtin___memmove_chk(tls, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths+uintptr(1)*4, libc.Uint64FromInt32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum-libc.Int32FromInt32(1))*uint64(4), ^t__predefined_size_t(0)) + } + } else { + /* If removing single accumulated string, harmlessly over-do. */ + nVS = nVS + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength + } + if nVS >= libc.Int32FromUint32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar) { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar = uint32(0) + } else { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar -= libc.Uint32FromInt32(nVS) + libc.X__builtin___memmove_chk(tls, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FzText, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FzText+uintptr(nVS), uint64((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar), ^t__predefined_size_t(0)) + } + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar == uint32(0) { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc = uint32(0) + Xsqlite3_free(tls, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths) + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths = uintptr(0) + } + } +} + +// C documentation +// +// /* +// ** Grow the db->aVTrans[] array so that there is room for at least one +// ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise. +// */ +func _growVTrans(tls *libc.TLS, db uintptr) (r int32) { + var ARRAY_INCR int32 + var aVTrans uintptr + var nBytes Tsqlite3_int64 + _, _, _ = ARRAY_INCR, aVTrans, nBytes + ARRAY_INCR = int32(5) + /* Grow the sqlite3.aVTrans array if required */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnVTrans%ARRAY_INCR == 0 { + nBytes = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt64(int64((*Tsqlite3)(unsafe.Pointer(db)).FnVTrans)+int64(ARRAY_INCR))) + aVTrans = _sqlite3DbRealloc(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans, libc.Uint64FromInt64(nBytes)) + if !(aVTrans != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, aVTrans+uintptr((*Tsqlite3)(unsafe.Pointer(db)).FnVTrans)*8, 0, uint64(8)*libc.Uint64FromInt32(ARRAY_INCR), ^t__predefined_size_t(0)) + (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans = aVTrans + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Transfer eligible terms from the HAVING clause of a query, which is +// ** processed after grouping, to the WHERE clause, which is processed before +// ** grouping. For example, the query: +// ** +// ** SELECT * FROM WHERE a=? GROUP BY b HAVING b=? AND c=? +// ** +// ** can be rewritten as: +// ** +// ** SELECT * FROM WHERE a=? AND b=? GROUP BY b HAVING c=? +// ** +// ** A term of the HAVING expression is eligible for transfer if it consists +// ** entirely of constants and expressions that are also GROUP BY terms that +// ** use the "BINARY" collation sequence. +// */ +func _havingToWhere(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* sWalker at bp+0 */ TWalker + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_havingToWhereExprCb) + *(*uintptr)(unsafe.Pointer(bp + 40)) = p + _sqlite3WalkExpr(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpHaving) +} + +func _incrAggFunctionDepth(tls *libc.TLS, pExpr uintptr, N int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + if N > 0 { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_incrAggDepth) + *(*int32)(unsafe.Pointer(bp + 40)) = N + _sqlite3WalkExpr(tls, bp, pExpr) + } +} + +// C documentation +// +// /* +// ** Insert a new cell on pPage at cell index "i". pCell points to the +// ** content of the cell. +// ** +// ** If the cell content will fit on the page, then put it there. If it +// ** will not fit, then make a copy of the cell content into pTemp if +// ** pTemp is not null. Regardless of pTemp, allocate a new entry +// ** in pPage->apOvfl[] and make it point to the cell content (either +// ** in pTemp or the original pCell) and also record its index. +// ** Allocating a new entry in pPage->aCell[] implies that +// ** pPage->nOverflow is incremented. +// ** +// ** The insertCellFast() routine below works exactly the same as +// ** insertCell() except that it lacks the pTemp and iChild parameters +// ** which are assumed zero. Other than that, the two routines are the +// ** same. +// ** +// ** Fixes or enhancements to this routine should be reflected in +// ** insertCellFast()! +// */ +func _insertCell(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32, pTemp uintptr, iChild TPgno) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var data, pIns, v2 uintptr + var j, rc int32 + var v1 Tu8 + var _ /* idx at bp+0 */ int32 + var _ /* rc2 at bp+4 */ int32 + _, _, _, _, _, _ = data, j, pIns, rc, v1, v2 + **(**int32)(__ccgo_up(bp)) = 0 /* The point in pPage->aCellIdx[] where no cell inserted */ + if (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow != 0 || sz+int32(2) > (*TMemPage)(unsafe.Pointer(pPage)).FnFree { + if pTemp != 0 { + libc.X__builtin___memcpy_chk(tls, pTemp, pCell, libc.Uint64FromInt32(sz), ^t__predefined_size_t(0)) + pCell = pTemp + } + _sqlite3Put4byte(tls, pCell, iChild) + v2 = pPage + 12 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + j = libc.Int32FromUint8(v1) + /* Comparison against ArraySize-1 since we hold back one extra slot + ** as a contingency. In other words, never need more than 3 overflow + ** slots but 4 are allocated, just to be safe. */ + **(**uintptr)(__ccgo_up(pPage + 40 + uintptr(j)*8)) = pCell + **(**Tu16)(__ccgo_up(pPage + 28 + uintptr(j)*2)) = libc.Uint16FromInt32(i) + /* When multiple overflows occur, they are always sequential and in + ** sorted order. This invariants arise because multiple overflows can + ** only occur when inserting divider cells into the parent page during + ** balancing, and the dividers are adjacent and sorted. + */ + /* Overflows in sorted order */ + /* Overflows are sequential */ + } else { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if rc != SQLITE_OK { + return rc + } + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + rc = _allocateSpace(tls, pPage, sz, bp) + if rc != 0 { + return rc + } + /* The allocateSpace() routine guarantees the following properties + ** if it returns successfully */ + **(**int32)(__ccgo_up(pPage + 20)) -= libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(2) + sz)) + /* In a corrupt database where an entry in the cell index section of + ** a btree page has a value of 3 or less, the pCell value might point + ** as many as 4 bytes in front of the start of the aData buffer for + ** the source page. Make sure this does not cause problems by not + ** reading the first 4 bytes */ + libc.X__builtin___memcpy_chk(tls, data+uintptr(**(**int32)(__ccgo_up(bp))+int32(4)), pCell+uintptr(4), libc.Uint64FromInt32(sz-int32(4)), ^t__predefined_size_t(0)) + _sqlite3Put4byte(tls, data+uintptr(**(**int32)(__ccgo_up(bp))), iChild) + pIns = (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(i*int32(2)) + libc.X__builtin___memmove_chk(tls, pIns+uintptr(2), pIns, libc.Uint64FromInt32(int32(2)*(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell)-i)), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up(pIns)) = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pIns + 1)) = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))) + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = (*TMemPage)(unsafe.Pointer(pPage)).FnCell + 1 + /* increment the cell count */ + v2 = data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(4)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + if libc.Int32FromUint8(v1) == 0 { + **(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(3)))) = **(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(3)))) + 1 + } + if (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FautoVacuum != 0 { + **(**int32)(__ccgo_up(bp + 4)) = SQLITE_OK + /* The cell may contain a pointer to an overflow page. If so, write + ** the entry for the overflow page into the pointer map. + */ + _ptrmapPutOvflPtr(tls, pPage, pPage, pCell, bp+4) + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + return **(**int32)(__ccgo_up(bp + 4)) + } + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This variant of insertCell() assumes that the pTemp and iChild +// ** parameters are both zero. Use this variant in sqlite3BtreeInsert() +// ** for performance improvement, and also so that this variant is only +// ** called from that one place, and is thus inlined, and thus runs must +// ** faster. +// ** +// ** Fixes or enhancements to this routine should be reflected into +// ** the insertCell() routine. +// */ +func _insertCellFast(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var data, pIns, v2 uintptr + var j, rc int32 + var v1 Tu8 + var _ /* idx at bp+0 */ int32 + var _ /* rc2 at bp+4 */ int32 + _, _, _, _, _, _ = data, j, pIns, rc, v1, v2 + **(**int32)(__ccgo_up(bp)) = 0 /* The point in pPage->aCellIdx[] where no cell inserted */ + if sz+int32(2) > (*TMemPage)(unsafe.Pointer(pPage)).FnFree { + v2 = pPage + 12 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + j = libc.Int32FromUint8(v1) + /* Comparison against ArraySize-1 since we hold back one extra slot + ** as a contingency. In other words, never need more than 3 overflow + ** slots but 4 are allocated, just to be safe. */ + **(**uintptr)(__ccgo_up(pPage + 40 + uintptr(j)*8)) = pCell + **(**Tu16)(__ccgo_up(pPage + 28 + uintptr(j)*2)) = libc.Uint16FromInt32(i) + /* When multiple overflows occur, they are always sequential and in + ** sorted order. This invariants arise because multiple overflows can + ** only occur when inserting divider cells into the parent page during + ** balancing, and the dividers are adjacent and sorted. + */ + /* Overflows in sorted order */ + /* Overflows are sequential */ + } else { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if rc != SQLITE_OK { + return rc + } + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + rc = _allocateSpace(tls, pPage, sz, bp) + if rc != 0 { + return rc + } + /* The allocateSpace() routine guarantees the following properties + ** if it returns successfully */ + **(**int32)(__ccgo_up(pPage + 20)) -= libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(2) + sz)) + libc.X__builtin___memcpy_chk(tls, data+uintptr(**(**int32)(__ccgo_up(bp))), pCell, libc.Uint64FromInt32(sz), ^t__predefined_size_t(0)) + pIns = (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(i*int32(2)) + libc.X__builtin___memmove_chk(tls, pIns+uintptr(2), pIns, libc.Uint64FromInt32(int32(2)*(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell)-i)), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up(pIns)) = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pIns + 1)) = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))) + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = (*TMemPage)(unsafe.Pointer(pPage)).FnCell + 1 + /* increment the cell count */ + v2 = data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(4)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + if libc.Int32FromUint8(v1) == 0 { + **(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(3)))) = **(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(3)))) + 1 + } + if (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FautoVacuum != 0 { + **(**int32)(__ccgo_up(bp + 4)) = SQLITE_OK + /* The cell may contain a pointer to an overflow page. If so, write + ** the entry for the overflow page into the pointer map. + */ + _ptrmapPutOvflPtr(tls, pPage, pPage, pCell, bp+4) + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + return **(**int32)(__ccgo_up(bp + 4)) + } + } + } + return SQLITE_OK +} + +/* +** The following parameters determine how many adjacent pages get involved +** in a balancing operation. NN is the number of neighbors on either side +** of the page that participate in the balancing operation. NB is the +** total number of pages that participate, including the target page and +** NN neighbors on either side. +** +** The minimum value of NN is 1 (of course). Increasing NN above 1 +** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance +** in exchange for a larger degradation in INSERT and UPDATE performance. +** The value of NN appears to give the best results overall. +** +** (Later:) The description above makes it seem as if these values are +** tunable - as if you could change them and recompile and it would all work. +** But that is unlikely. NB has been 3 since the inception of SQLite and +** we have never tested any other value. + */ + +// C documentation +// +// /* +// ** Invalidate temp storage, either when the temp storage is changed +// ** from default, or when 'file' and the temp_store_directory has changed +// */ +func _invalidateTempStorage(tls *libc.TLS, pParse uintptr) (r int32) { + var db uintptr + _ = db + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt != uintptr(0) { + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) || _sqlite3BtreeTxnState(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt) != SQLITE_TXN_NONE { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19403, 0) + return int32(SQLITE_ERROR) + } + _sqlite3BtreeClose(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt) + (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt = uintptr(0) + _sqlite3ResetAllSchemasOfConnection(tls, db) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Parameter zName is the name of a table that is about to be altered +// ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN). +// ** If the table is a system table, this function leaves an error message +// ** in pParse->zErr (system tables may not be altered) and returns non-zero. +// ** +// ** Or, if zName is not a system table, zero is returned. +// */ +func _isAlterableTable(tls *libc.TLS, pParse uintptr, pTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if 0 == Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+7100, int32(7)) || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Eponymous) != uint32(0) || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Shadow) != uint32(0) && _sqlite3ReadOnlyShadowTables(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8987, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Return true if the pExpr term from the RETURNING clause argument +// ** list is of the form "*". Raise an error if the terms if of the +// ** form "table.*". +// */ +func _isAsteriskTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr) (r int32) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pTerm)).Fop) == int32(TK_ASTERISK) { + return int32(1) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pTerm)).Fop) != int32(TK_DOT) { + return 0 + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pTerm)).FpRight)).Fop) != int32(TK_ASTERISK) { + return 0 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22873, 0) + return int32(1) +} + +// C documentation +// +// /* +// ** Process time function arguments. argv[0] is a date-time stamp. +// ** argv[1] and following are modifiers. Parse them all and write +// ** the resulting time into the DateTime structure p. Return 0 +// ** on success and 1 if there are any errors. +// ** +// ** If there are zero parameters (if even argv[0] is undefined) +// ** then assume a default value of "now" for argv[0]. +// */ +func _isDate(tls *libc.TLS, context uintptr, argc int32, argv uintptr, p uintptr) (r int32) { + var eType, i, n, v1 int32 + var z uintptr + _, _, _, _, _ = eType, i, n, z, v1 + libc.X__builtin___memset_chk(tls, p, 0, uint64(48), ^t__predefined_size_t(0)) + if argc == 0 { + if !(_sqlite3NotPureFunc(tls, context) != 0) { + return int32(1) + } + return _setDateTimeToCurrent(tls, context, p) + } + v1 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) + eType = v1 + if v1 == int32(SQLITE_FLOAT) || eType == int32(SQLITE_INTEGER) { + _setRawDateNumber(tls, p, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))) + } else { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if !(z != 0) || _parseDateOrTime(tls, context, z, p) != 0 { + return int32(1) + } + } + i = int32(1) + for { + if !(i < argc) { + break + } + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if z == uintptr(0) || _parseModifier(tls, context, z, n, p, i) != 0 { + return int32(1) + } + goto _2 + _2: + ; + i = i + 1 + } + _computeJD(tls, p) + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x2>>1)) != 0 || !(_validJulianDay(tls, (*TDateTime)(unsafe.Pointer(p)).FiJD) != 0) { + return int32(1) + } + if argc == int32(1) && (*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0 && (*TDateTime)(unsafe.Pointer(p)).FD > int32(28) { + /* Make sure a YYYY-MM-DD is normalized. + ** Example: 2023-02-31 -> 2023-03-03 */ + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = 0 + } + return 0 +} + +/* +** The following routines implement the various date and time functions +** of SQLite. + */ + +// C documentation +// +// /* +// ** Parameter pTab is the subject of an ALTER TABLE ... RENAME COLUMN +// ** command. This function checks if the table is a view or virtual +// ** table (columns of views or virtual tables may not be renamed). If so, +// ** it loads an error message into pParse and returns non-zero. +// ** +// ** Or, if pTab is not a view or virtual table, zero is returned. +// */ +func _isRealTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iOp int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var azMsg [3]uintptr + var zType uintptr + _, _ = azMsg, zType + zType = uintptr(0) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + zType = __ccgo_ts + 11459 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + zType = __ccgo_ts + 11464 + } + if zType != 0 { + azMsg = [3]uintptr{ + 0: __ccgo_ts + 11478, + 1: __ccgo_ts + 11496, + 2: __ccgo_ts + 11513, + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11533, libc.VaList(bp+8, azMsg[iOp], zType, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Return TRUE (non-zero) if zTab is a valid name for the schema table pTab. +// */ +func _isValidSchemaTableName(tls *libc.TLS, zTab uintptr, pTab uintptr, zDb uintptr) (r int32) { + var zLegacy uintptr + _ = zLegacy + if Xsqlite3_strnicmp(tls, zTab, __ccgo_ts+7100, int32(7)) != 0 { + return 0 + } + zLegacy = (*TTable)(unsafe.Pointer(pTab)).FzName + if libc.Xstrcmp(tls, zLegacy+uintptr(7), __ccgo_ts+7108+7) == 0 { + if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+7127+7) == 0 { + return int32(1) + } + if zDb == uintptr(0) { + return 0 + } + if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6628+7) == 0 { + return int32(1) + } + if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+7146+7) == 0 { + return int32(1) + } + } else { + if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+7146+7) == 0 { + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** Append the path name for the current element. +// */ +func _jsonAppendPathName(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, k, n Tu32 + var needQuote int32 + var z uintptr + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _ = i, k, n, needQuote, z + if libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeType) == int32(JSONB_ARRAY) { + _jsonPrintf(tls, int32(30), p+56, __ccgo_ts+27267, libc.VaList(bp+16, (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiKey)) + } else { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + needQuote = 0 + n = _jsonbPayloadSize(tls, p+192, (*TJsonEachCursor)(unsafe.Pointer(p)).Fi, bp) + k = (*TJsonEachCursor)(unsafe.Pointer(p)).Fi + n + z = (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(k) + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z)))])&libc.Int32FromInt32(0x02) != 0) { + needQuote = int32(1) + } else { + i = uint32(0) + for { + if !(i < **(**Tu32)(__ccgo_up(bp))) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i))))])&libc.Int32FromInt32(0x06) != 0) { + needQuote = int32(1) + break + } + goto _1 + _1: + ; + i = i + 1 + } + } + if needQuote != 0 { + _jsonPrintf(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+uint32(4)), p+56, __ccgo_ts+27274, libc.VaList(bp+16, **(**Tu32)(__ccgo_up(bp)), z)) + } else { + _jsonPrintf(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+uint32(2)), p+56, __ccgo_ts+27282, libc.VaList(bp+16, **(**Tu32)(__ccgo_up(bp)), z)) + } + } +} + +func _jsonAppendRaw(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + if N == uint32(0) { + return + } + if uint64(N)+(*TJsonString)(unsafe.Pointer(p)).FnUsed >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc { + _jsonStringExpandAndAppend(tls, p, zIn, N) + } else { + libc.X__builtin___memcpy_chk(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), zIn, uint64(N), ^t__predefined_size_t(0)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(N) + } +} + +func _jsonAppendRawNZ(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + if uint64(N)+(*TJsonString)(unsafe.Pointer(p)).FnUsed >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc { + _jsonStringExpandAndAppend(tls, p, zIn, N) + } else { + libc.X__builtin___memcpy_chk(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), zIn, uint64(N), ^t__predefined_size_t(0)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(N) + } +} + +// C documentation +// +// /* +// ** Append an sqlite3_value (such as a function parameter) to the JSON +// ** string under construction in p. +// */ +func _jsonAppendSqlValue(tls *libc.TLS, p uintptr, pValue uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var n, n1 Tu32 + var z, z1 uintptr + var _ /* px at bp+0 */ TJsonParse + _, _, _, _ = n, n1, z, z1 + switch Xsqlite3_value_type(tls, pValue) { + case int32(SQLITE_NULL): + _jsonAppendRawNZ(tls, p, __ccgo_ts+1688, uint32(4)) + case int32(SQLITE_FLOAT): + _jsonPrintf(tls, int32(100), p, __ccgo_ts+16903, libc.VaList(bp+80, Xsqlite3_value_double(tls, pValue))) + case int32(SQLITE_INTEGER): + z = Xsqlite3_value_text(tls, pValue) + n = libc.Uint32FromInt32(Xsqlite3_value_bytes(tls, pValue)) + _jsonAppendRaw(tls, p, z, n) + case int32(SQLITE_TEXT): + z1 = Xsqlite3_value_text(tls, pValue) + n1 = libc.Uint32FromInt32(Xsqlite3_value_bytes(tls, pValue)) + if Xsqlite3_value_subtype(tls, pValue) == uint32(JSON_SUBTYPE) { + _jsonAppendRaw(tls, p, z1, n1) + } else { + _jsonAppendString(tls, p, z1, n1) + } + default: + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + if _jsonArgIsJsonb(tls, pValue, bp) != 0 { + _jsonTranslateBlobToText(tls, bp, uint32(0), p) + } else { + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr) == 0 { + Xsqlite3_result_error(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx, __ccgo_ts+26755, -int32(1)) + (*TJsonString)(unsafe.Pointer(p)).FeErr = uint8(JSTRING_ERR) + _jsonStringReset(tls, p) + } + } + break + } +} + +// C documentation +// +// /* Append the N-byte string in zIn to the end of the JsonString string +// ** under construction. Enclose the string in double-quotes ("...") and +// ** escape any double-quotes or backslash characters contained within the +// ** string. +// ** +// ** This routine is a high-runner. There is a measurable performance +// ** increase associated with unwinding the jsonIsOk[] loop. +// */ +func _jsonAppendString(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + var c Tu8 + var k Tu32 + var z, v2 uintptr + var v1 Tu64 + _, _, _, _, _ = c, k, z, v1, v2 + z = zIn + if z == uintptr(0) { + return + } + if uint64(N)+(*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(2) >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(2)) != 0 { + return + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = int8('"') + for int32(1) != 0 { + k = uint32(0) + /* The following while() is the 4-way unwound equivalent of + ** + ** while( k= N { + for k < N && _jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k)))] != 0 { + k = k + 1 + } + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k)))] != 0) { + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(1))))] != 0) { + k = k + uint32(1) + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(2))))] != 0) { + k = k + uint32(2) + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(3))))] != 0) { + k = k + uint32(3) + break + } else { + k = k + uint32(4) + } + } + if k >= N { + if k > uint32(0) { + libc.X__builtin___memcpy_chk(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), z, uint64(k), ^t__predefined_size_t(0)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(k) + } + break + } + if k > uint32(0) { + libc.X__builtin___memcpy_chk(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), z, uint64(k), ^t__predefined_size_t(0)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(k) + z = z + uintptr(k) + N = N - k + } + c = **(**Tu8)(__ccgo_up(z)) + if libc.Int32FromUint8(c) == int32('"') || libc.Int32FromUint8(c) == int32('\\') { + if (*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(N)+uint64(3) > (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(3)) != 0 { + return + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = int8('\\') + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = libc.Int8FromUint8(c) + } else { + if libc.Int32FromUint8(c) == int32('\'') { + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = libc.Int8FromUint8(c) + } else { + if (*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(N)+uint64(7) > (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(7)) != 0 { + return + } + _jsonAppendControlChar(tls, p, c) + } + } + z = z + 1 + N = N - 1 + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = int8('"') +} + +func _jsonArrayCompute(tls *libc.TLS, ctx uintptr, isFinal int32) { + var flags int32 + var pStr uintptr + var v1 Tsqlite3_destructor_type + _, _, _ = flags, pStr, v1 + flags = int32(int64(Xsqlite3_user_data(tls, ctx))) + pStr = Xsqlite3_aggregate_context(tls, ctx, 0) + if pStr != 0 { + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + _jsonAppendRawNZ(tls, pStr, __ccgo_ts+5656, uint32(2)) + _jsonStringTrimOneChar(tls, pStr) + if (*TJsonString)(unsafe.Pointer(pStr)).FeErr != 0 { + _jsonReturnString(tls, pStr, uintptr(0), uintptr(0)) + return + } else { + if flags&int32(JSON_BLOB) != 0 { + _jsonReturnStringAsBlob(tls, pStr) + if isFinal != 0 { + if !((*TJsonString)(unsafe.Pointer(pStr)).FbStatic != 0) { + _sqlite3RCStrUnref(tls, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf) + } + } else { + _jsonStringTrimOneChar(tls, pStr) + } + return + } else { + if isFinal != 0 { + if (*TJsonString)(unsafe.Pointer(pStr)).FbStatic != 0 { + v1 = uintptr(-libc.Int32FromInt32(1)) + } else { + v1 = __ccgo_fp(_sqlite3RCStrUnref) + } + Xsqlite3_result_text(tls, ctx, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed), v1) + (*TJsonString)(unsafe.Pointer(pStr)).FbStatic = uint8(1) + } else { + Xsqlite3_result_text(tls, ctx, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed), uintptr(-libc.Int32FromInt32(1))) + _jsonStringTrimOneChar(tls, pStr) + } + } + } + } else { + if flags&int32(JSON_BLOB) != 0 { + Xsqlite3_result_blob(tls, ctx, uintptr(unsafe.Pointer(&_emptyArray)), int32(1), libc.UintptrFromInt32(0)) + } else { + Xsqlite3_result_text(tls, ctx, __ccgo_ts+27176, int32(2), libc.UintptrFromInt32(0)) + } + } + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /* +// ** json_array_length(JSON) +// ** json_array_length(JSON, PATH) +// ** +// ** Return the number of elements in the top-level JSON array. +// ** Return 0 if the input is not a well-formed JSON array. +// */ +func _jsonArrayLengthFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var cnt Tsqlite3_int64 + var eErr Tu8 + var i Tu32 + var p, zPath, v1 uintptr + _, _, _, _, _, _ = cnt, eErr, i, p, zPath, v1 /* The parse */ + cnt = 0 + eErr = uint8(0) + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if p == uintptr(0) { + return + } + if argc == int32(2) { + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zPath == uintptr(0) { + _jsonParseFree(tls, p) + return + } + if int32(**(**int8)(__ccgo_up(zPath))) == int32('$') { + v1 = zPath + uintptr(1) + } else { + v1 = __ccgo_ts + 26994 + } + i = _jsonLookupStep(tls, p, uint32(0), v1, uint32(0)) + if i >= uint32(JSON_LOOKUP_PATHERROR) { + if i == uint32(JSON_LOOKUP_NOTFOUND) { + /* no-op */ + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(i)) + } + eErr = uint8(1) + i = uint32(0) + } + } else { + i = uint32(0) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob + uintptr(i))))&int32(0x0f) == int32(JSONB_ARRAY) { + cnt = libc.Int64FromUint32(_jsonbArrayCount(tls, p, i)) + } + if !(eErr != 0) { + Xsqlite3_result_int64(tls, ctx, cnt) + } + _jsonParseFree(tls, p) +} + +// C documentation +// +// /* +// ** Generate a path error. +// ** +// ** The specifics of the error are determined by the rc argument. +// ** +// ** rc error +// ** ----------------- ---------------------- +// ** JSON_LOOKUP_ARRAY "not an array" +// ** JSON_LOOKUP_TOODEEP "JSON nested too deep" +// ** JSON_LOOKUP_ERROR "malformed JSON" +// ** otherwise... "bad JSON path" +// ** +// ** If ctx is not NULL then push the error message into ctx and return NULL. +// ** If ctx is NULL, then return the text of the error message. +// */ +func _jsonBadPathError(tls *libc.TLS, ctx uintptr, zPath uintptr, rc int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var zMsg uintptr + _ = zMsg + if rc == libc.Int32FromUint32(JSON_LOOKUP_NOTARRAY) { + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26932, libc.VaList(bp+8, zPath)) + } else { + if rc == libc.Int32FromUint32(JSON_LOOKUP_ERROR) { + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26784, 0) + } else { + if rc == libc.Int32FromUint32(JSON_LOOKUP_TOODEEP) { + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26957, 0) + } else { + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26976, libc.VaList(bp+8, zPath)) + } + } + } + if ctx == uintptr(0) { + return zMsg + } + if zMsg != 0 { + Xsqlite3_result_error(tls, ctx, zMsg, -int32(1)) + Xsqlite3_free(tls, zMsg) + } else { + Xsqlite3_result_error_nomem(tls, ctx) + } + return uintptr(0) +} + +// C documentation +// +// /* Append a node type byte together with the payload size and +// ** possibly also the payload. +// ** +// ** If aPayload is not NULL, then it is a pointer to the payload which +// ** is also appended. If aPayload is NULL, the pParse->aBlob[] array +// ** is resized (if necessary) so that it is big enough to hold the +// ** payload, but the payload is not appended and pParse->nBlob is left +// ** pointing to where the first byte of payload will eventually be. +// */ +func _jsonBlobAppendNode(tls *libc.TLS, pParse uintptr, eType Tu8, szPayload Tu64, aPayload uintptr) { + var a, v1 uintptr + _, _ = a, v1 + if uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)+szPayload+uint64(9) > uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc) { + _jsonBlobExpandAndAppendNode(tls, pParse, eType, szPayload, aPayload) + return + } + a = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob) + if szPayload <= uint64(11) { + **(**Tu8)(__ccgo_up(a)) = uint8(uint64(eType) | szPayload<> libc.Int32FromInt32(8) & uint64(0xff)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(szPayload & uint64(0xff)) + **(**Tu32)(__ccgo_up(pParse + 8)) += uint32(3) + } else { + **(**Tu8)(__ccgo_up(a)) = libc.Uint8FromInt32(libc.Int32FromUint8(eType) | int32(0xe0)) + **(**Tu8)(__ccgo_up(a + 1)) = uint8(szPayload >> libc.Int32FromInt32(24) & uint64(0xff)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(szPayload >> libc.Int32FromInt32(16) & uint64(0xff)) + **(**Tu8)(__ccgo_up(a + 3)) = uint8(szPayload >> libc.Int32FromInt32(8) & uint64(0xff)) + **(**Tu8)(__ccgo_up(a + 4)) = uint8(szPayload & uint64(0xff)) + **(**Tu32)(__ccgo_up(pParse + 8)) += uint32(5) + } + } + } + if aPayload != 0 { + v1 = pParse + 8 + *(*Tu32)(unsafe.Pointer(v1)) = Tu32(uint64(*(*Tu32)(unsafe.Pointer(v1))) + szPayload) + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)-szPayload), aPayload, szPayload, ^t__predefined_size_t(0)) + } +} + +// C documentation +// +// /* Change the payload size for the node at index i to be szPayload. +// */ +func _jsonBlobChangePayloadSize(tls *libc.TLS, pParse uintptr, i Tu32, szPayload Tu32) (r int32) { + var a uintptr + var delta int32 + var nExtra, nNeeded, szType Tu8 + var newSize Tu32 + _, _, _, _, _, _ = a, delta, nExtra, nNeeded, newSize, szType + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return 0 + } + a = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i) + szType = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a))) >> int32(4)) + if libc.Int32FromUint8(szType) <= int32(11) { + nExtra = uint8(0) + } else { + if libc.Int32FromUint8(szType) == int32(12) { + nExtra = uint8(1) + } else { + if libc.Int32FromUint8(szType) == int32(13) { + nExtra = uint8(2) + } else { + if libc.Int32FromUint8(szType) == int32(14) { + nExtra = uint8(4) + } else { + nExtra = uint8(8) + } + } + } + } + if szPayload <= uint32(11) { + nNeeded = uint8(0) + } else { + if szPayload <= uint32(0xff) { + nNeeded = uint8(1) + } else { + if szPayload <= uint32(0xffff) { + nNeeded = uint8(2) + } else { + nNeeded = uint8(4) + } + } + } + delta = libc.Int32FromUint8(nNeeded) - libc.Int32FromUint8(nExtra) + if delta != 0 { + newSize = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + libc.Uint32FromInt32(delta) + if delta > 0 { + if newSize > (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc && _jsonBlobExpand(tls, pParse, newSize) != 0 { + return 0 /* OOM error. Error state recorded in pParse->oom. */ + } + a = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i) + libc.X__builtin___memmove_chk(tls, a+uintptr(int32(1)+delta), a+1, uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-(i+uint32(1))), ^t__predefined_size_t(0)) + } else { + libc.X__builtin___memmove_chk(tls, a+1, a+uintptr(int32(1)-delta), uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-(i+uint32(1)-libc.Uint32FromInt32(delta))), ^t__predefined_size_t(0)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = newSize + } + if libc.Int32FromUint8(nNeeded) == 0 { + **(**Tu8)(__ccgo_up(a)) = uint8(libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a)))&libc.Int32FromInt32(0x0f)) | szPayload<> libc.Int32FromInt32(8) & uint32(0xff)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(szPayload & uint32(0xff)) + } else { + **(**Tu8)(__ccgo_up(a)) = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a)))&int32(0x0f) | int32(0xe0)) + **(**Tu8)(__ccgo_up(a + 1)) = uint8(szPayload >> libc.Int32FromInt32(24) & uint32(0xff)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(szPayload >> libc.Int32FromInt32(16) & uint32(0xff)) + **(**Tu8)(__ccgo_up(a + 3)) = uint8(szPayload >> libc.Int32FromInt32(8) & uint32(0xff)) + **(**Tu8)(__ccgo_up(a + 4)) = uint8(szPayload & uint32(0xff)) + } + } + } + return delta +} + +// C documentation +// +// /* +// ** Modify the JSONB blob at pParse->aBlob by removing nDel bytes of +// ** content beginning at iDel, and replacing them with nIns bytes of +// ** content given by aIns. +// ** +// ** nDel may be zero, in which case no bytes are removed. But iDel is +// ** still important as new bytes will be insert beginning at iDel. +// ** +// ** aIns may be zero, in which case space is created to hold nIns bytes +// ** beginning at iDel, but that space is uninitialized. +// ** +// ** Set pParse->oom if an OOM occurs. +// */ +func _jsonBlobEdit(tls *libc.TLS, pParse uintptr, iDel Tu32, nDel Tu32, aIns uintptr, nIns Tu32) { + var d Ti64 + var v1 uintptr + _, _ = d, v1 + d = libc.Int64FromUint32(nIns) - libc.Int64FromUint32(nDel) + if d < 0 && d >= int64(-libc.Int32FromInt32(8)) && aIns != uintptr(0) && _jsonBlobOverwrite(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(iDel), aIns, nIns, libc.Uint32FromInt32(int32(-d))) != 0 { + return + } + if d != 0 { + if libc.Int64FromUint32((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)+d > libc.Int64FromUint32((*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc) { + _jsonBlobExpand(tls, pParse, libc.Uint32FromInt64(libc.Int64FromUint32((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)+d)) + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return + } + } + libc.X__builtin___memmove_chk(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(iDel+nIns), (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(iDel+nDel), uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-(iDel+nDel)), ^t__predefined_size_t(0)) + v1 = pParse + 8 + *(*Tu32)(unsafe.Pointer(v1)) = Tu32(int64(*(*Tu32)(unsafe.Pointer(v1))) + d) + v1 = pParse + 52 + *(*int32)(unsafe.Pointer(v1)) = int32(int64(*(*int32)(unsafe.Pointer(v1))) + d) + } + if nIns != 0 && aIns != 0 { + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(iDel), aIns, uint64(nIns), ^t__predefined_size_t(0)) + } +} + +// C documentation +// +// /* +// ** If pParse->aBlob is not previously editable (because it is taken +// ** from sqlite3_value_blob(), as indicated by the fact that +// ** pParse->nBlobAlloc==0 and pParse->nBlob>0) then make it editable +// ** by making a copy into space obtained from malloc. +// ** +// ** Return true on success. Return false on OOM. +// */ +func _jsonBlobMakeEditable(tls *libc.TLS, pParse uintptr, nExtra Tu32) (r int32) { + var aOld uintptr + var nSize Tu32 + _, _ = aOld, nSize + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return 0 + } + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc > uint32(0) { + return int32(1) + } + aOld = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + nSize = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + nExtra + (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = uintptr(0) + if _jsonBlobExpand(tls, pParse, nSize) != 0 { + return 0 + } + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob, aOld, uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob), ^t__predefined_size_t(0)) + return int32(1) +} + +// C documentation +// +// /* +// ** If the JSONB at aIns[0..nIns-1] can be expanded (by denormalizing the +// ** size field) by d bytes, then write the expansion into aOut[] and +// ** return true. In this way, an overwrite happens without changing the +// ** size of the JSONB, which reduces memcpy() operations and also make it +// ** faster and easier to update the B-Tree entry that contains the JSONB +// ** in the database. +// ** +// ** If the expansion of aIns[] by d bytes cannot be (easily) accomplished +// ** then return false. +// ** +// ** The d parameter is guaranteed to be between 1 and 8. +// ** +// ** This routine is an optimization. A correct answer is obtained if it +// ** always leaves the output unchanged and returns false. +// */ +func _jsonBlobOverwrite(tls *libc.TLS, aOut uintptr, aIns uintptr, nIns Tu32, d Tu32) (r int32) { + var i, szPayload Tu32 + var szHdr Tu8 + _, _, _ = i, szHdr, szPayload /* Size of header before expansion */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aIns)))&int32(0x0f) <= int32(2) { + return 0 + } /* Cannot enlarge NULL, true, false */ + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aIns))) >> libc.Int32FromInt32(4) { + default: /* aIns[] header size 1 */ + if int32(1)<> uint32(8) + } + return int32(1) +} + +// C documentation +// +// /* +// ** Insert a new entry into the cache. If the cache is full, expel +// ** the least recently used entry. Return SQLITE_OK on success or a +// ** result code otherwise. +// ** +// ** Cache entries are stored in age order, oldest first. +// */ +func _jsonCacheInsert(tls *libc.TLS, ctx uintptr, pParse uintptr) (r int32) { + var db, p uintptr + _, _ = db, p + p = Xsqlite3_get_auxdata(tls, ctx, -int32(429938)) + if p == uintptr(0) { + db = Xsqlite3_context_db_handle(tls, ctx) + p = _sqlite3DbMallocZero(tls, db, uint64(48)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TJsonCache)(unsafe.Pointer(p)).Fdb = db + Xsqlite3_set_auxdata(tls, ctx, -int32(429938), p, __ccgo_fp(_jsonCacheDeleteGeneric)) + p = Xsqlite3_get_auxdata(tls, ctx, -int32(429938)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + } + if (*TJsonCache)(unsafe.Pointer(p)).FnUsed >= int32(JSON_CACHE_SIZE) { + _jsonParseFree(tls, **(**uintptr)(__ccgo_up(p + 16))) + libc.X__builtin___memmove_chk(tls, p+16, p+16+1*8, libc.Uint64FromInt32(libc.Int32FromInt32(JSON_CACHE_SIZE)-libc.Int32FromInt32(1))*libc.Uint64FromInt64(8), ^t__predefined_size_t(0)) + (*TJsonCache)(unsafe.Pointer(p)).FnUsed = libc.Int32FromInt32(JSON_CACHE_SIZE) - libc.Int32FromInt32(1) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FeEdit = uint8(0) + (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef = (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef + 1 + (*TJsonParse)(unsafe.Pointer(pParse)).FbReadOnly = uint8(1) + **(**uintptr)(__ccgo_up(p + 16 + uintptr((*TJsonCache)(unsafe.Pointer(p)).FnUsed)*8)) = pParse + (*TJsonCache)(unsafe.Pointer(p)).FnUsed = (*TJsonCache)(unsafe.Pointer(p)).FnUsed + 1 + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Search for a cached translation the json text supplied by pArg. Return +// ** the JsonParse object if found. Return NULL if not found. +// ** +// ** When a match if found, the matching entry is moved to become the +// ** most-recently used entry if it isn't so already. +// ** +// ** The JsonParse object returned still belongs to the Cache and might +// ** be deleted at any moment. If the caller wants the JsonParse to +// ** linger, it needs to increment the nPJRef reference counter. +// */ +func _jsonCacheSearch(tls *libc.TLS, ctx uintptr, pArg uintptr) (r uintptr) { + var i, nJson int32 + var p, tmp, zJson uintptr + _, _, _, _, _ = i, nJson, p, tmp, zJson + if Xsqlite3_value_type(tls, pArg) != int32(SQLITE_TEXT) { + return uintptr(0) + } + zJson = Xsqlite3_value_text(tls, pArg) + if zJson == uintptr(0) { + return uintptr(0) + } + nJson = Xsqlite3_value_bytes(tls, pArg) + p = Xsqlite3_get_auxdata(tls, ctx, -int32(429938)) + if p == uintptr(0) { + return uintptr(0) + } + i = 0 + for { + if !(i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed) { + break + } + if (*TJsonParse)(unsafe.Pointer(**(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)))).FzJson == zJson { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i >= (*TJsonCache)(unsafe.Pointer(p)).FnUsed { + i = 0 + for { + if !(i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed) { + break + } + if (*TJsonParse)(unsafe.Pointer(**(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)))).FnJson != nJson { + goto _2 + } + if libc.Xmemcmp(tls, (*TJsonParse)(unsafe.Pointer(**(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)))).FzJson, zJson, libc.Uint64FromInt32(nJson)) == 0 { + break + } + goto _2 + _2: + ; + i = i + 1 + } + } + if i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed { + if i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed-int32(1) { + /* Make the matching entry the most recently used entry */ + tmp = **(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)) + libc.X__builtin___memmove_chk(tls, p+16+uintptr(i)*8, p+16+uintptr(i+int32(1))*8, libc.Uint64FromInt32((*TJsonCache)(unsafe.Pointer(p)).FnUsed-i-libc.Int32FromInt32(1))*uint64(8), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(p + 16 + uintptr((*TJsonCache)(unsafe.Pointer(p)).FnUsed-int32(1))*8)) = tmp + i = (*TJsonCache)(unsafe.Pointer(p)).FnUsed - int32(1) + } + return **(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)) + } else { + return uintptr(0) + } + return r +} + +/************************************************************************** +** Utility routines for dealing with JsonString objects +**************************************************************************/ + +// C documentation +// +// /* +// ** Parse a complete JSON string. Return 0 on success or non-zero if there +// ** are any errors. If an error occurs, free all memory held by pParse, +// ** but not pParse itself. +// ** +// ** pParse must be initialized to an empty parse object prior to calling +// ** this routine. +// */ +func _jsonConvertTextToBlob(tls *libc.TLS, pParse uintptr, pCtx uintptr) (r int32) { + var i int32 + var zJson uintptr + _, _ = i, zJson + zJson = (*TJsonParse)(unsafe.Pointer(pParse)).FzJson + i = _jsonTranslateTextToBlob(tls, pParse, uint32(0)) + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + i = -int32(1) + } + if i > 0 { + for _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zJson + uintptr(i))))] != 0 { + i = i + 1 + } + if **(**int8)(__ccgo_up(zJson + uintptr(i))) != 0 { + i = i + _json5Whitespace(tls, zJson+uintptr(i)) + if **(**int8)(__ccgo_up(zJson + uintptr(i))) != 0 { + if pCtx != 0 { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26784, -int32(1)) + } + _jsonParseReset(tls, pParse) + return int32(1) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + } + if i <= 0 { + if pCtx != uintptr(0) { + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, pCtx) + } else { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26784, -int32(1)) + } + } + _jsonParseReset(tls, pParse) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* This helper routine for jsonLookupStep() populates pIns with +// ** binary data that is to be inserted into pParse. +// ** +// ** In the common case, pIns just points to pParse->aIns and pParse->nIns. +// ** But if the zPath of the original edit operation includes path elements +// ** that go deeper, additional substructure must be created. +// ** +// ** For example: +// ** +// ** json_insert('{}', '$.a.b.c', 123); +// ** +// ** The search stops at '$.a' But additional substructure must be +// ** created for the ".b.c" part of the patch so that the final result +// ** is: {"a":{"b":{"c"::123}}}. This routine populates pIns with +// ** the binary equivalent of {"b":{"c":123}} so that it can be inserted. +// ** +// ** The caller is responsible for resetting pIns when it has finished +// ** using the substructure. +// */ +func _jsonCreateEditSubstructure(tls *libc.TLS, pParse uintptr, pIns uintptr, zTail uintptr) (r Tu32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + libc.X__builtin___memset_chk(tls, pIns, 0, uint64(72), ^t__predefined_size_t(0)) + (*TJsonParse)(unsafe.Pointer(pIns)).Fdb = (*TJsonParse)(unsafe.Pointer(pParse)).Fdb + if int32(**(**int8)(__ccgo_up(zTail))) == 0 { + /* No substructure. Just insert what is given in pParse. */ + (*TJsonParse)(unsafe.Pointer(pIns)).FaBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FaIns + (*TJsonParse)(unsafe.Pointer(pIns)).FnBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FnIns + rc = 0 + } else { + /* Construct the binary substructure */ + (*TJsonParse)(unsafe.Pointer(pIns)).FnBlob = uint32(1) + (*TJsonParse)(unsafe.Pointer(pIns)).FaBlob = uintptr(unsafe.Pointer(&_emptyObject)) + libc.BoolUintptr(int32(**(**int8)(__ccgo_up(zTail))) == int32('.')) + (*TJsonParse)(unsafe.Pointer(pIns)).FeEdit = (*TJsonParse)(unsafe.Pointer(pParse)).FeEdit + (*TJsonParse)(unsafe.Pointer(pIns)).FnIns = (*TJsonParse)(unsafe.Pointer(pParse)).FnIns + (*TJsonParse)(unsafe.Pointer(pIns)).FaIns = (*TJsonParse)(unsafe.Pointer(pParse)).FaIns + (*TJsonParse)(unsafe.Pointer(pIns)).FiDepth = libc.Uint16FromInt32(libc.Int32FromUint16((*TJsonParse)(unsafe.Pointer(pParse)).FiDepth) + int32(1)) + if libc.Int32FromUint16((*TJsonParse)(unsafe.Pointer(pIns)).FiDepth) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = libc.Int32FromUint32(_jsonLookupStep(tls, pIns, uint32(0), zTail, uint32(0))) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + v1 = pParse + 47 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pIns)).Foom)) + } + return libc.Uint32FromInt32(rc) /* Error code only */ +} + +// C documentation +// +// /* Constructor for the json_each virtual table */ +func _jsonEachConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + var pNew uintptr + var rc, v1 int32 + _, _, _ = pNew, rc, v1 + /* Column numbers */ + /* The xBestIndex method assumes that the JSON and ROOT columns are + ** the last two columns in the table. Should this ever changes, be + ** sure to update the xBestIndex method. */ + _ = pzErr + _ = argv + _ = argc + _ = pAux + rc = Xsqlite3_declare_vtab(tls, db, __ccgo_ts+27184) + if rc == SQLITE_OK { + pNew = _sqlite3DbMallocZero(tls, db, uint64(40)) + **(**uintptr)(__ccgo_up(ppVtab)) = pNew + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + (*TJsonEachConnection)(unsafe.Pointer(pNew)).Fdb = db + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv)) + 4))) == int32('b') { + v1 = int32(2) + } else { + v1 = int32(1) + } + (*TJsonEachConnection)(unsafe.Pointer(pNew)).FeMode = libc.Uint8FromInt32(v1) + (*TJsonEachConnection)(unsafe.Pointer(pNew)).FbRecursive = libc.BoolUint8(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv)) + uintptr(int32(4)+libc.Int32FromUint8((*TJsonEachConnection)(unsafe.Pointer(pNew)).FeMode))))) == int32('t')) + } + return rc +} + +// C documentation +// +// /* Start a search on a new JSON string */ +func _jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, n, v1 Tu32 + var p, zRoot uintptr + var v2 int32 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _ = i, n, p, zRoot, v1, v2 + p = cur + zRoot = uintptr(0) + _ = idxStr + _ = argc + _jsonEachCursorReset(tls, p) + if idxNum == 0 { + return SQLITE_OK + } + libc.X__builtin___memset_chk(tls, p+192, 0, uint64(72), ^t__predefined_size_t(0)) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FnJPRef = uint32(1) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.Fdb = (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb + if _jsonArgIsJsonb(tls, **(**uintptr)(__ccgo_up(argv)), p+192) != 0 { + /* We have JSONB */ + } else { + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FnJson = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson == uintptr(0) { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + return SQLITE_OK + } + if _jsonConvertTextToBlob(tls, p+192, uintptr(0)) != 0 { + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.Foom != 0 { + return int32(SQLITE_NOMEM) + } + goto json_each_malformed_input + } + } + if idxNum == int32(3) { + zRoot = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zRoot == uintptr(0) { + return SQLITE_OK + } + if int32(**(**int8)(__ccgo_up(zRoot))) != int32('$') { + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = _jsonBadPathError(tls, uintptr(0), zRoot, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot = libc.Uint32FromInt32(_sqlite3Strlen30(tls, zRoot)) + if int32(**(**int8)(__ccgo_up(zRoot + 1))) == 0 { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + i = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + } else { + i = _jsonLookupStep(tls, p+192, uint32(0), zRoot+uintptr(1), uint32(0)) + if i >= uint32(JSON_LOOKUP_PATHERROR) { + if i == uint32(JSON_LOOKUP_NOTFOUND) { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = uint32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = uint32(0) + return SQLITE_OK + } + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = _jsonBadPathError(tls, uintptr(0), zRoot, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 + } + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FiLabel != 0 { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FiLabel + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(JSONB_OBJECT) + } else { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(JSONB_ARRAY) + } + } + _jsonAppendRaw(tls, p+56, zRoot, (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot) + } else { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + i = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot = uint32(1) + _jsonAppendRaw(tls, p+56, __ccgo_ts+27288, uint32(1)) + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = uint32(0) + n = _jsonbPayloadSize(tls, p+192, i, bp) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = i + n + **(**Tu32)(__ccgo_up(bp)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i))))&int32(0x0f) >= int32(JSONB_ARRAY) && !((*TJsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0) { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i + n + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i)))) & int32(0x0f)) + (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent = _sqlite3DbMallocZero(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb, uint64(24)) + if (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = uint32(1) + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParentAlloc = uint32(1) + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiKey = 0 + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiEnd = (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiHead = (*TJsonEachCursor)(unsafe.Pointer(p)).Fi + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiValue = i + } + return SQLITE_OK + goto json_each_malformed_input +json_each_malformed_input: + ; + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26784, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 +} + +// C documentation +// +// /* +// ** json_error_position(JSON) +// ** +// ** If the argument is NULL, return NULL +// ** +// ** If the argument is BLOB, do a full validity check and return non-zero +// ** if the check fails. The return value is the approximate 1-based offset +// ** to the byte of the element that contains the first error. +// ** +// ** Otherwise interpret the argument is TEXT (even if it is numeric) and +// ** return the 1-based character position for where the parser first recognized +// ** that the input was not valid JSON, or return 0 if the input text looks +// ** ok. JSON-5 extensions are accepted. +// */ +func _jsonErrorFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iErrPos Ti64 + var k Tu32 + var _ /* s at bp+0 */ TJsonParse + _, _ = iErrPos, k + iErrPos = 0 + _ = argc + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TJsonParse)(__ccgo_up(bp))).Fdb = Xsqlite3_context_db_handle(tls, ctx) + if _jsonArgIsJsonb(tls, **(**uintptr)(__ccgo_up(argv)), bp) != 0 { + iErrPos = libc.Int64FromUint32(_jsonbValidityCheck(tls, bp, uint32(0), (**(**TJsonParse)(__ccgo_up(bp))).FnBlob, uint32(1))) + } else { + (**(**TJsonParse)(__ccgo_up(bp))).FzJson = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if (**(**TJsonParse)(__ccgo_up(bp))).FzJson == uintptr(0) { + return + } /* NULL input or OOM */ + (**(**TJsonParse)(__ccgo_up(bp))).FnJson = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if _jsonConvertTextToBlob(tls, bp, uintptr(0)) != 0 { + if (**(**TJsonParse)(__ccgo_up(bp))).Foom != 0 { + iErrPos = int64(-int32(1)) + } else { + /* Because s.oom is false */ + k = uint32(0) + for { + if !(k < (**(**TJsonParse)(__ccgo_up(bp))).FiErr && **(**int8)(__ccgo_up((**(**TJsonParse)(__ccgo_up(bp))).FzJson + uintptr(k))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up((**(**TJsonParse)(__ccgo_up(bp))).FzJson + uintptr(k))))&int32(0xc0) != int32(0x80) { + iErrPos = iErrPos + 1 + } + goto _1 + _1: + ; + k = k + 1 + } + iErrPos = iErrPos + 1 + } + } + } + _jsonParseReset(tls, bp) + if iErrPos < 0 { + Xsqlite3_result_error_nomem(tls, ctx) + } else { + Xsqlite3_result_int64(tls, ctx, iErrPos) + } +} + +// C documentation +// +// /* +// ** json_extract(JSON, PATH, ...) +// ** "->"(JSON,PATH) +// ** "->>"(JSON,PATH) +// ** +// ** Return the element described by PATH. Return NULL if that PATH element +// ** is not found. +// ** +// ** If JSON_JSON is set or if more that one PATH argument is supplied then +// ** always return a JSON representation of the result. If JSON_SQL is set, +// ** then always return an SQL representation of the result. If neither flag +// ** is present and argc==2, then return JSON for objects and arrays and SQL +// ** for all other values. +// ** +// ** When multiple PATH arguments are supplied, the result is a JSON array +// ** containing the result of each PATH. +// ** +// ** Abbreviated JSON path expressions are allows if JSON_ABPATH, for +// ** compatibility with PG. +// */ +func _jsonExtractFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var flags, i, nPath int32 + var j Tu32 + var p, zPath uintptr + var _ /* jx at bp+0 */ TJsonString + _, _, _, _, _, _ = flags, i, j, nPath, p, zPath + p = uintptr(0) /* String for array result */ + if argc < int32(2) { + return + } + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if p == uintptr(0) { + return + } + flags = int32(int64(Xsqlite3_user_data(tls, ctx))) + _jsonStringInit(tls, bp, ctx) + if argc > int32(2) { + _jsonAppendChar(tls, bp, int8('[')) + } + i = int32(1) + for { + if !(i < argc) { + break + } + /* With a single PATH argument */ + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zPath == uintptr(0) { + goto json_extract_error + } + nPath = _sqlite3Strlen30(tls, zPath) + if int32(**(**int8)(__ccgo_up(zPath))) == int32('$') { + j = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + } else { + if flags&int32(JSON_ABPATH) != 0 { + /* The -> and ->> operators accept abbreviated PATH arguments. This + ** is mostly for compatibility with PostgreSQL, but also for + ** convenience. + ** + ** NUMBER ==> $[NUMBER] // PG compatible + ** LABEL ==> $.LABEL // PG compatible + ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience + ** + ** Updated 2024-05-27: If the NUMBER is negative, then PG counts from + ** the right of the array. Hence for negative NUMBER: + ** + ** NUMBER ==> $[#NUMBER] // PG compatible + */ + _jsonStringInit(tls, bp, ctx) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) == int32(SQLITE_INTEGER) { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26996, uint32(1)) + if int32(**(**int8)(__ccgo_up(zPath))) == int32('-') { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26998, uint32(1)) + } + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+5656, uint32(2)) + } else { + if _jsonAllAlphanum(tls, zPath, nPath) != 0 { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+1741, uint32(1)) + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + } else { + if int32(**(**int8)(__ccgo_up(zPath))) == int32('[') && nPath >= int32(3) && int32(**(**int8)(__ccgo_up(zPath + uintptr(nPath-int32(1))))) == int32(']') { + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + } else { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+27000, uint32(2)) + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+27003, uint32(1)) + } + } + } + _jsonStringTerminate(tls, bp) + j = _jsonLookupStep(tls, p, uint32(0), (**(**TJsonString)(__ccgo_up(bp))).FzBuf, uint32(0)) + _jsonStringReset(tls, bp) + } else { + _jsonBadPathError(tls, ctx, zPath, 0) + goto json_extract_error + } + } + if j < (*TJsonParse)(unsafe.Pointer(p)).FnBlob { + if argc == int32(2) { + if flags&int32(JSON_JSON) != 0 { + _jsonStringInit(tls, bp, ctx) + _jsonTranslateBlobToText(tls, p, j, bp) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + _jsonStringReset(tls, bp) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } else { + _jsonReturnFromBlob(tls, p, j, ctx, 0) + if flags&(libc.Int32FromInt32(JSON_SQL)|libc.Int32FromInt32(JSON_BLOB)) == 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob + uintptr(j))))&int32(0x0f) >= int32(JSONB_ARRAY) { + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } + } + } else { + _jsonAppendSeparator(tls, bp) + _jsonTranslateBlobToText(tls, p, j, bp) + } + } else { + if j == uint32(JSON_LOOKUP_NOTFOUND) { + if argc == int32(2) { + goto json_extract_error /* Return NULL if not found */ + } else { + _jsonAppendSeparator(tls, bp) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+1688, uint32(4)) + } + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(j)) + goto json_extract_error + } + } + goto _1 + _1: + ; + i = i + 1 + } + if argc > int32(2) { + _jsonAppendChar(tls, bp, int8(']')) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + if flags&int32(JSON_BLOB) == 0 { + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } + } + goto json_extract_error +json_extract_error: + ; + _jsonStringReset(tls, bp) + _jsonParseFree(tls, p) + return +} + +/* +** Return codes for jsonMergePatch() + */ + +// C documentation +// +// /* +// ** pArg is a function argument that might be an SQL value or a JSON +// ** value. Figure out what it is and encode it as a JSONB blob. +// ** Return the results in pParse. +// ** +// ** pParse is uninitialized upon entry. This routine will handle the +// ** initialization of pParse. The result will be contained in +// ** pParse->aBlob and pParse->nBlob. pParse->aBlob might be dynamically +// ** allocated (if pParse->nBlobAlloc is greater than zero) in which case +// ** the caller is responsible for freeing the space allocated to pParse->aBlob +// ** when it has finished with it. Or pParse->aBlob might be a static string +// ** or a value obtained from sqlite3_value_blob(pArg). +// ** +// ** If the argument is a BLOB that is clearly not a JSONB, then this +// ** function might set an error message in ctx and return non-zero. +// ** It might also set an error message and return non-zero on an OOM error. +// */ +func _jsonFunctionArgToBlob(tls *libc.TLS, ctx uintptr, pArg uintptr, pParse uintptr) (r1 int32) { + var eType, n, n1, nJson int32 + var r float64 + var z, z1, zJson uintptr + _, _, _, _, _, _, _, _ = eType, n, n1, nJson, r, z, z1, zJson + eType = Xsqlite3_value_type(tls, pArg) + libc.X__builtin___memset_chk(tls, pParse, 0, uint64(72), ^t__predefined_size_t(0)) + (*TJsonParse)(unsafe.Pointer(pParse)).Fdb = Xsqlite3_context_db_handle(tls, ctx) + switch eType { + default: + (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = uintptr(unsafe.Pointer(&_aNull)) + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = uint32(1) + return 0 + case int32(SQLITE_BLOB): + if !(_jsonArgIsJsonb(tls, pArg, pParse) != 0) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26755, -int32(1)) + return int32(1) + } + case int32(SQLITE_TEXT): + zJson = Xsqlite3_value_text(tls, pArg) + nJson = Xsqlite3_value_bytes(tls, pArg) + if zJson == uintptr(0) { + return int32(1) + } + if Xsqlite3_value_subtype(tls, pArg) == uint32(JSON_SUBTYPE) { + (*TJsonParse)(unsafe.Pointer(pParse)).FzJson = zJson + (*TJsonParse)(unsafe.Pointer(pParse)).FnJson = nJson + if _jsonConvertTextToBlob(tls, pParse, ctx) != 0 { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26784, -int32(1)) + _sqlite3DbFree(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob) + libc.X__builtin___memset_chk(tls, pParse, 0, uint64(72), ^t__predefined_size_t(0)) + return int32(1) + } + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_TEXTRAW), libc.Uint64FromInt32(nJson), zJson) + } + case int32(SQLITE_FLOAT): + r = Xsqlite3_value_double(tls, pArg) + if _sqlite3IsNaN(tls, r) != 0 { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_NULL), uint64(0), uintptr(0)) + } else { + n = Xsqlite3_value_bytes(tls, pArg) + z = Xsqlite3_value_text(tls, pArg) + if z == uintptr(0) { + return int32(1) + } + if int32(**(**int8)(__ccgo_up(z))) == int32('I') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26889) + } else { + if int32(**(**int8)(__ccgo_up(z))) == int32('-') && int32(**(**int8)(__ccgo_up(z + 1))) == int32('I') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(6), __ccgo_ts+26882) + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), libc.Uint64FromInt32(n), z) + } + } + } + case int32(SQLITE_INTEGER): + n1 = Xsqlite3_value_bytes(tls, pArg) + z1 = Xsqlite3_value_text(tls, pArg) + if z1 == uintptr(0) { + return int32(1) + } + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_INT), libc.Uint64FromInt32(n1), z1) + break + } + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, ctx) + return int32(1) + } else { + return 0 + } + return r1 +} + +// C documentation +// +// /* +// ** This method works for both json_group_array() and json_group_object(). +// ** It works by removing the first element of the group by searching forward +// ** to the first comma (",") that is not within a string and deleting all +// ** text through that comma. +// */ +func _jsonGroupInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var c, v2 int8 + var i uint32 + var inStr, nNest int32 + var pStr, z uintptr + var v3 bool + _, _, _, _, _, _, _, _ = c, i, inStr, nNest, pStr, z, v2, v3 + inStr = 0 + nNest = 0 + _ = argc + _ = argv + pStr = Xsqlite3_aggregate_context(tls, ctx, 0) + /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will + ** always have been called to initialize it */ + if !(pStr != 0) { + return + } + z = (*TJsonString)(unsafe.Pointer(pStr)).FzBuf + i = uint32(1) + for { + if v3 = uint64(i) < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed; v3 { + v2 = **(**int8)(__ccgo_up(z + uintptr(i))) + c = v2 + } + if !(v3 && (int32(v2) != int32(',') || inStr != 0 || nNest != 0)) { + break + } + if int32(c) == int32('"') { + inStr = libc.BoolInt32(!(inStr != 0)) + } else { + if int32(c) == int32('\\') { + i = i + 1 + } else { + if !(inStr != 0) { + if int32(c) == int32('{') || int32(c) == int32('[') { + nNest = nNest + 1 + } + if int32(c) == int32('}') || int32(c) == int32(']') { + nNest = nNest - 1 + } + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + if uint64(i) < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed { + **(**Tu64)(__ccgo_up(pStr + 24)) -= uint64(i) + libc.X__builtin___memmove_chk(tls, z+1, z+uintptr(i+uint32(1)), (*TJsonString)(unsafe.Pointer(pStr)).FnUsed-uint64(1), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(z + uintptr((*TJsonString)(unsafe.Pointer(pStr)).FnUsed))) = 0 + } else { + (*TJsonString)(unsafe.Pointer(pStr)).FnUsed = uint64(1) + } +} + +// C documentation +// +// /* +// ** Search along zPath to find the Json element specified. Return an +// ** index into pParse->aBlob[] for the start of that element's value. +// ** +// ** If the value found by this routine is the value half of label/value pair +// ** within an object, then set pPath->iLabel to the start of the corresponding +// ** label, before returning. +// ** +// ** Return one of the JSON_LOOKUP error codes if problems are seen. +// ** +// ** This routine will also modify the blob. If pParse->eEdit is one of +// ** JEDIT_DEL, JEDIT_REPL, JEDIT_INS, JEDIT_SET, or JEDIT_AINS, then changes +// ** might be made to the selected value. If an edit is performed, then the +// ** return value does not necessarily point to the select element. If an edit +// ** is performed, the return value is only useful for detecting error +// ** conditions. +// */ +func _jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot Tu32, zPath uintptr, iLabel Tu32) (r Tu32) { + bp := tls.Alloc(224) + defer tls.Free(224) + var i, iEnd, j, k, n, nIns, nKey, rc, v Tu32 + var kk, nn Tu64 + var rawKey, rawLabel, v5 int32 + var x Tu8 + var zKey, zLabel, v4 uintptr + var v3 Tu16 + var _ /* ix at bp+80 */ TJsonParse + var _ /* sz at bp+0 */ Tu32 + var _ /* v at bp+152 */ TJsonParse + var _ /* v at bp+8 */ TJsonParse + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iEnd, j, k, kk, n, nIns, nKey, nn, rawKey, rawLabel, rc, v, x, zKey, zLabel, v3, v4, v5 + if int32(**(**int8)(__ccgo_up(zPath))) == 0 { + if (*TJsonParse)(unsafe.Pointer(pParse)).FeEdit != 0 && _jsonBlobMakeEditable(tls, pParse, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) != 0 { + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + n + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_DEL) { + if iLabel > uint32(0) { + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + (iRoot - iLabel) + iRoot = iLabel + } + _jsonBlobEdit(tls, pParse, iRoot, **(**Tu32)(__ccgo_up(bp)), uintptr(0), uint32(0)) + } else { + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_INS) { + /* Already exists, so json_insert() is a no-op */ + } else { + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_AINS) { + /* json_array_insert() */ + if int32(**(**int8)(__ccgo_up(zPath + uintptr(-libc.Int32FromInt32(1))))) != int32(']') { + return uint32(JSON_LOOKUP_NOTARRAY) + } else { + _jsonBlobEdit(tls, pParse, iRoot, uint32(0), (*TJsonParse)(unsafe.Pointer(pParse)).FaIns, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) + } + } else { + /* json_set() or json_replace() */ + _jsonBlobEdit(tls, pParse, iRoot, **(**Tu32)(__ccgo_up(bp)), (*TJsonParse)(unsafe.Pointer(pParse)).FaIns, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) + } + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiLabel = iLabel + return iRoot + } + if int32(**(**int8)(__ccgo_up(zPath))) == int32('.') { + rawKey = int32(1) + x = **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iRoot))) + zPath = zPath + 1 + if int32(**(**int8)(__ccgo_up(zPath))) == int32('"') { + zKey = zPath + uintptr(1) + i = uint32(1) + for { + if !(**(**int8)(__ccgo_up(zPath + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32('"')) { + break + } + if int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) == int32('\\') && int32(**(**int8)(__ccgo_up(zPath + uintptr(i+uint32(1))))) != 0 { + i = i + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + nKey = i - uint32(1) + if **(**int8)(__ccgo_up(zPath + uintptr(i))) != 0 { + i = i + 1 + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + rawKey = libc.BoolInt32(libc.Xmemchr(tls, zKey, int32('\\'), uint64(nKey)) == uintptr(0)) + } else { + zKey = zPath + i = uint32(0) + for { + if !(**(**int8)(__ccgo_up(zPath + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32('.') && int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32('[')) { + break + } + goto _2 + _2: + ; + i = i + 1 + } + nKey = i + if nKey == uint32(0) { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + if libc.Int32FromUint8(x)&int32(0x0f) != int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + j = iRoot + n /* j is the index of a label */ + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + for j < iEnd { + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(j)))) & int32(0x0f)) + if libc.Int32FromUint8(x) < int32(JSONB_TEXT) || libc.Int32FromUint8(x) > int32(JSONB_TEXTRAW) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + k = j + n /* k is the index of the label text */ + if k+**(**Tu32)(__ccgo_up(bp)) >= iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + zLabel = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(k) + rawLabel = libc.BoolInt32(libc.Int32FromUint8(x) == int32(JSONB_TEXT) || libc.Int32FromUint8(x) == int32(JSONB_TEXTRAW)) + if _jsonLabelCompare(tls, zKey, nKey, rawKey, zLabel, **(**Tu32)(__ccgo_up(bp)), rawLabel) != 0 { + v = k + **(**Tu32)(__ccgo_up(bp)) /* v is the index of the value */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(v))))&int32(0x0f) > int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, v, bp) + if n == uint32(0) || v+n+**(**Tu32)(__ccgo_up(bp)) > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + v4 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v4)) = *(*Tu16)(unsafe.Pointer(v4)) + 1 + v3 = *(*Tu16)(unsafe.Pointer(v4)) + if libc.Int32FromUint16(v3) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = _jsonLookupStep(tls, pParse, v, zPath+uintptr(i), j) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + j = k + **(**Tu32)(__ccgo_up(bp)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(j))))&int32(0x0f) > int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + if j > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) >= int32(JEDIT_INS) { /* Header of the label to be inserted */ + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_AINS) && Xsqlite3_strglob(tls, __ccgo_ts+26929, zPath+uintptr(i)) != 0 { + return uint32(JSON_LOOKUP_NOTARRAY) + } + libc.X__builtin___memset_chk(tls, bp+80, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TJsonParse)(__ccgo_up(bp + 80))).Fdb = (*TJsonParse)(unsafe.Pointer(pParse)).Fdb + if rawKey != 0 { + v5 = int32(JSONB_TEXTRAW) + } else { + v5 = int32(JSONB_TEXT5) + } + _jsonBlobAppendNode(tls, bp+80, libc.Uint8FromInt32(v5), uint64(nKey), uintptr(0)) + v4 = pParse + 47 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v4))) | libc.Int32FromUint8((**(**TJsonParse)(__ccgo_up(bp + 80))).Foom)) + rc = _jsonCreateEditSubstructure(tls, pParse, bp+8, zPath+uintptr(i)) + if !(rc >= libc.Uint32FromUint32(JSON_LOOKUP_PATHERROR)) && _jsonBlobMakeEditable(tls, pParse, (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob+nKey+(**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob) != 0 { + nIns = (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob + nKey + (**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob + _jsonBlobEdit(tls, pParse, j, uint32(0), uintptr(0), nIns) + if !((*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0) { + /* Because pParse->oom!=0 */ + /* Because pPasre->oom!=0 */ + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(j), (**(**TJsonParse)(__ccgo_up(bp + 80))).FaBlob, uint64((**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob), ^t__predefined_size_t(0)) + k = j + (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(k), zKey, uint64(nKey), ^t__predefined_size_t(0)) + k = k + nKey + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(k), (**(**TJsonParse)(__ccgo_up(bp + 8))).FaBlob, uint64((**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob), ^t__predefined_size_t(0)) + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + } + } + _jsonParseReset(tls, bp+8) + _jsonParseReset(tls, bp+80) + return rc + } + } else { + if int32(**(**int8)(__ccgo_up(zPath))) == int32('[') { + kk = uint64(0) + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iRoot)))) & int32(0x0f)) + if libc.Int32FromUint8(x) != int32(JSONB_ARRAY) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + i = uint32(1) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zPath + uintptr(i))))])&int32(0x04) != 0 { + if kk < uint64(0xffffffff) { + kk = kk*uint64(10) + libc.Uint64FromInt8(**(**int8)(__ccgo_up(zPath + uintptr(i)))) - uint64('0') + } + /* ^^^^^^^^^^--- Allow kk to be bigger than any JSON array so that + ** we get NOTFOUND instead of PATHERROR, without overflowing kk. */ + i = i + 1 + } + if i < uint32(2) || int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32(']') { + if int32(**(**int8)(__ccgo_up(zPath + 1))) == int32('#') { + kk = uint64(_jsonbArrayCount(tls, pParse, iRoot)) + i = uint32(2) + if int32(**(**int8)(__ccgo_up(zPath + 2))) == int32('-') && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zPath + 3)))])&int32(0x04) != 0 { + nn = uint64(0) + i = uint32(3) + for cond := true; cond; cond = libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zPath + uintptr(i))))])&int32(0x04) != 0 { + if nn < uint64(0xffffffff) { + nn = nn*uint64(10) + libc.Uint64FromInt8(**(**int8)(__ccgo_up(zPath + uintptr(i)))) - uint64('0') + } + /* ^^^^^^^^^^--- Allow nn to be bigger than any JSON array to + ** get NOTFOUND instead of PATHERROR, without overflowing nn. */ + i = i + 1 + } + if nn > kk { + return uint32(JSON_LOOKUP_NOTFOUND) + } + kk = kk - nn + } + if int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32(']') { + return uint32(JSON_LOOKUP_PATHERROR) + } + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + j = iRoot + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + for j < iEnd { + if kk == uint64(0) { + v4 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v4)) = *(*Tu16)(unsafe.Pointer(v4)) + 1 + v3 = *(*Tu16)(unsafe.Pointer(v4)) + if libc.Int32FromUint16(v3) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = _jsonLookupStep(tls, pParse, j, zPath+uintptr(i+uint32(1)), uint32(0)) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + kk = kk - 1 + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + if j > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + if kk > uint64(0) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) >= int32(JEDIT_INS) { + rc = _jsonCreateEditSubstructure(tls, pParse, bp+152, zPath+uintptr(i+uint32(1))) + if !(rc >= libc.Uint32FromUint32(JSON_LOOKUP_PATHERROR)) && _jsonBlobMakeEditable(tls, pParse, (**(**TJsonParse)(__ccgo_up(bp + 152))).FnBlob) != 0 { + _jsonBlobEdit(tls, pParse, j, uint32(0), (**(**TJsonParse)(__ccgo_up(bp + 152))).FaBlob, (**(**TJsonParse)(__ccgo_up(bp + 152))).FnBlob) + } + _jsonParseReset(tls, bp+152) + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + return uint32(JSON_LOOKUP_NOTFOUND) +} + +// C documentation +// +// /* +// ** RFC-7396 MergePatch for two JSONB blobs. +// ** +// ** pTarget is the target. pPatch is the patch. The target is updated +// ** in place. The patch is read-only. +// ** +// ** The original RFC-7396 algorithm is this: +// ** +// ** define MergePatch(Target, Patch): +// ** if Patch is an Object: +// ** if Target is not an Object: +// ** Target = {} # Ignore the contents and set it to an empty Object +// ** for each Name/Value pair in Patch: +// ** if Value is null: +// ** if Name exists in Target: +// ** remove the Name/Value pair from Target +// ** else: +// ** Target[Name] = MergePatch(Target[Name], Value) +// ** return Target +// ** else: +// ** return Patch +// ** +// ** Here is an equivalent algorithm restructured to show the actual +// ** implementation: +// ** +// ** 01 define MergePatch(Target, Patch): +// ** 02 if Patch is not an Object: +// ** 03 return Patch +// ** 04 else: // if Patch is an Object +// ** 05 if Target is not an Object: +// ** 06 Target = {} +// ** 07 for each Name/Value pair in Patch: +// ** 08 if Name exists in Target: +// ** 09 if Value is null: +// ** 10 remove the Name/Value pair from Target +// ** 11 else +// ** 12 Target[name] = MergePatch(Target[Name], Value) +// ** 13 else if Value is not NULL: +// ** 14 if Value is not an Object: +// ** 15 Target[name] = Value +// ** 16 else: +// ** 17 Target[name] = MergePatch('{}',value) +// ** 18 return Target +// ** | +// ** ^---- Line numbers referenced in comments in the implementation +// */ +func _jsonMergePatch(tls *libc.TLS, pTarget uintptr, iTarget Tu32, pPatch uintptr, iPatch Tu32, iDepth Tu32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ePLabel, eTLabel, x Tu8 + var iPCursor, iPEnd, iPLabel, iPValue, iTCursor, iTEnd, iTEndBE, iTLabel, iTStart, iTValue, n, nPLabel, nPValue, nTLabel, nTValue, szNew, szPatch, szTarget Tu32 + var isEqual, rc, rc1, savedDelta, savedDelta1, v1 int32 + var _ /* sz at bp+0 */ Tu32 + var _ /* szPLabel at bp+12 */ Tu32 + var _ /* szPValue at bp+16 */ Tu32 + var _ /* szTLabel at bp+4 */ Tu32 + var _ /* szTValue at bp+8 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ePLabel, eTLabel, iPCursor, iPEnd, iPLabel, iPValue, iTCursor, iTEnd, iTEndBE, iTLabel, iTStart, iTValue, isEqual, n, nPLabel, nPValue, nTLabel, nTValue, rc, rc1, savedDelta, savedDelta1, szNew, szPatch, szTarget, x, v1 + **(**Tu32)(__ccgo_up(bp)) = uint32(0) /* Node type of the target label */ + iTLabel = uint32(0) /* Index of the label */ + nTLabel = uint32(0) /* Header size in bytes for the target label */ + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) /* Size of the target label payload */ + iTValue = uint32(0) /* Index of the target value */ + nTValue = uint32(0) /* Header size of the target value */ + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(0) /* Payload size of the patch value */ + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob + uintptr(iPatch)))) & int32(0x0f)) + if libc.Int32FromUint8(x) != int32(JSONB_OBJECT) { /* Total size of the target, header+payload */ + n = _jsonbPayloadSize(tls, pPatch, iPatch, bp) + szPatch = n + **(**Tu32)(__ccgo_up(bp)) + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, pTarget, iTarget, bp) + szTarget = n + **(**Tu32)(__ccgo_up(bp)) + _jsonBlobEdit(tls, pTarget, iTarget, szTarget, (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPatch), szPatch) + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + v1 = int32(JSON_MERGE_OOM) + } else { + v1 = JSON_MERGE_OK + } + return v1 /* Line 03 */ + } + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTarget)))) & int32(0x0f)) + if libc.Int32FromUint8(x) != int32(JSONB_OBJECT) { /* Algorithm line 05 */ + n = _jsonbPayloadSize(tls, pTarget, iTarget, bp) + _jsonBlobEdit(tls, pTarget, iTarget+n, **(**Tu32)(__ccgo_up(bp)), uintptr(0), uint32(0)) + x = **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTarget))) + **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTarget))) = libc.Uint8FromInt32(libc.Int32FromUint8(x)&int32(0xf0) | int32(JSONB_OBJECT)) + } + n = _jsonbPayloadSize(tls, pPatch, iPatch, bp) + if n == uint32(0) { + return int32(JSON_MERGE_BADPATCH) + } + iPCursor = iPatch + n + iPEnd = iPCursor + **(**Tu32)(__ccgo_up(bp)) + n = _jsonbPayloadSize(tls, pTarget, iTarget, bp) + if n == uint32(0) { + return int32(JSON_MERGE_BADTARGET) + } + iTStart = iTarget + n + iTEndBE = iTStart + **(**Tu32)(__ccgo_up(bp)) + for iPCursor < iPEnd { /* Algorithm line 07 */ + iPLabel = iPCursor + ePLabel = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob + uintptr(iPCursor)))) & int32(0x0f)) + if libc.Int32FromUint8(ePLabel) < int32(JSONB_TEXT) || libc.Int32FromUint8(ePLabel) > int32(JSONB_TEXTRAW) { + return int32(JSON_MERGE_BADPATCH) + } + nPLabel = _jsonbPayloadSize(tls, pPatch, iPCursor, bp+12) + if nPLabel == uint32(0) { + return int32(JSON_MERGE_BADPATCH) + } + iPValue = iPCursor + nPLabel + **(**Tu32)(__ccgo_up(bp + 12)) + if iPValue >= iPEnd { + return int32(JSON_MERGE_BADPATCH) + } + nPValue = _jsonbPayloadSize(tls, pPatch, iPValue, bp+16) + if nPValue == uint32(0) { + return int32(JSON_MERGE_BADPATCH) + } + iPCursor = iPValue + nPValue + **(**Tu32)(__ccgo_up(bp + 16)) + if iPCursor > iPEnd { + return int32(JSON_MERGE_BADPATCH) + } + iTCursor = iTStart + iTEnd = iTEndBE + libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta) + for iTCursor < iTEnd { /* true if the patch and target labels match */ + iTLabel = iTCursor + eTLabel = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTCursor)))) & int32(0x0f)) + if libc.Int32FromUint8(eTLabel) < int32(JSONB_TEXT) || libc.Int32FromUint8(eTLabel) > int32(JSONB_TEXTRAW) { + return int32(JSON_MERGE_BADTARGET) + } + nTLabel = _jsonbPayloadSize(tls, pTarget, iTCursor, bp+4) + if nTLabel == uint32(0) { + return int32(JSON_MERGE_BADTARGET) + } + iTValue = iTLabel + nTLabel + **(**Tu32)(__ccgo_up(bp + 4)) + if iTValue >= iTEnd { + return int32(JSON_MERGE_BADTARGET) + } + nTValue = _jsonbPayloadSize(tls, pTarget, iTValue, bp+8) + if nTValue == uint32(0) { + return int32(JSON_MERGE_BADTARGET) + } + if iTValue+nTValue+**(**Tu32)(__ccgo_up(bp + 8)) > iTEnd { + return int32(JSON_MERGE_BADTARGET) + } + isEqual = _jsonLabelCompare(tls, (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPLabel+nPLabel), **(**Tu32)(__ccgo_up(bp + 12)), libc.BoolInt32(libc.Int32FromUint8(ePLabel) == int32(JSONB_TEXT) || libc.Int32FromUint8(ePLabel) == int32(JSONB_TEXTRAW)), (*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob+uintptr(iTLabel+nTLabel), **(**Tu32)(__ccgo_up(bp + 4)), libc.BoolInt32(libc.Int32FromUint8(eTLabel) == int32(JSONB_TEXT) || libc.Int32FromUint8(eTLabel) == int32(JSONB_TEXTRAW))) + if isEqual != 0 { + break + } + iTCursor = iTValue + nTValue + **(**Tu32)(__ccgo_up(bp + 8)) + } + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob + uintptr(iPValue)))) & int32(0x0f)) + if iTCursor < iTEnd { + /* A match was found. Algorithm line 08 */ + if libc.Int32FromUint8(x) == 0 { + /* Patch value is NULL. Algorithm line 09 */ + _jsonBlobEdit(tls, pTarget, iTLabel, nTLabel+**(**Tu32)(__ccgo_up(bp + 4))+nTValue+**(**Tu32)(__ccgo_up(bp + 8)), uintptr(0), uint32(0)) + /* vvvvvv----- No OOM on a delete-only edit */ + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + return int32(JSON_MERGE_OOM) + } + } else { + savedDelta = (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta + (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta = 0 + if iDepth >= uint32(JSON_MAX_DEPTH) { + return int32(JSON_MERGE_TOODEEP) + } + rc = _jsonMergePatch(tls, pTarget, iTValue, pPatch, iPValue, iDepth+uint32(1)) + if rc != 0 { + return rc + } + **(**int32)(__ccgo_up(pTarget + 52)) += savedDelta + } + } else { + if libc.Int32FromUint8(x) > 0 { /* Algorithm line 13 */ + /* No match and patch value is not NULL */ + szNew = **(**Tu32)(__ccgo_up(bp + 12)) + nPLabel + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob + uintptr(iPValue))))&int32(0x0f) != int32(JSONB_OBJECT) { /* Line 14 */ + _jsonBlobEdit(tls, pTarget, iTEnd, uint32(0), uintptr(0), **(**Tu32)(__ccgo_up(bp + 16))+nPValue+szNew) + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + return int32(JSON_MERGE_OOM) + } + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob+uintptr(iTEnd), (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPLabel), uint64(szNew), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob+uintptr(iTEnd+szNew), (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPValue), uint64(**(**Tu32)(__ccgo_up(bp + 16))+nPValue), ^t__predefined_size_t(0)) + } else { + _jsonBlobEdit(tls, pTarget, iTEnd, uint32(0), uintptr(0), szNew+uint32(1)) + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + return int32(JSON_MERGE_OOM) + } + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob+uintptr(iTEnd), (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPLabel), uint64(szNew), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTEnd+szNew))) = uint8(0x00) + savedDelta1 = (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta + (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta = 0 + if iDepth >= uint32(JSON_MAX_DEPTH) { + return int32(JSON_MERGE_TOODEEP) + } + rc1 = _jsonMergePatch(tls, pTarget, iTEnd+szNew, pPatch, iPValue, iDepth+uint32(1)) + if rc1 != 0 { + return rc1 + } + **(**int32)(__ccgo_up(pTarget + 52)) += savedDelta1 + } + } + } + } + if (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pTarget, iTarget) + } + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + v1 = int32(JSON_MERGE_OOM) + } else { + v1 = JSON_MERGE_OK + } + return v1 +} + +func _jsonObjectCompute(tls *libc.TLS, ctx uintptr, isFinal int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var c int8 + var flags, inStr int32 + var i, j, v2, v3 Tu64 + var pOgStr, pStr uintptr + var v8 Tsqlite3_destructor_type + var _ /* tmpStr at bp+0 */ TJsonString + _, _, _, _, _, _, _, _, _, _ = c, flags, i, inStr, j, pOgStr, pStr, v2, v3, v8 + flags = int32(int64(Xsqlite3_user_data(tls, ctx))) + pStr = Xsqlite3_aggregate_context(tls, ctx, 0) + if pStr != 0 { + pOgStr = pStr + _jsonAppendRawNZ(tls, pOgStr, __ccgo_ts+27179, uint32(2)) /* Ensure it is zero-terminated */ + _jsonStringTrimOneChar(tls, pOgStr) /* Remove the zero terminator */ + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + if (*TJsonString)(unsafe.Pointer(pStr)).FeErr != 0 { + _jsonReturnString(tls, pStr, uintptr(0), uintptr(0)) + return + } + if int32(**(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf))) != int32('{') { + inStr = 0 + if !(isFinal != 0) { + /* Work with a temporary copy of the string if this is not the + ** final result */ + _jsonStringInit(tls, bp, ctx) + _jsonAppendRawNZ(tls, bp, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, uint32((*TJsonString)(unsafe.Pointer(pStr)).FnUsed+uint64(1))) + pStr = bp + if (*TJsonString)(unsafe.Pointer(pStr)).FeErr != 0 { + _jsonReturnString(tls, pStr, uintptr(0), uintptr(0)) + return + } + _jsonStringTrimOneChar(tls, pStr) /* Remove zero terminator */ + } + /* Fix up the string by changing the initial "@" flag back to + ** to "{" and removing all subsequence "@" entries, with their + ** associated comma delimeters. */ + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf)) = int8('{') + v2 = libc.Uint64FromInt32(1) + j = v2 + i = v2 + for { + if !(i < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed) { + break + } + c = **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(i))) + if int32(c) == int32('"') { + inStr = libc.BoolInt32(!(inStr != 0)) + v2 = j + j = j + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = int8('"') + } else { + if int32(c) == int32('\\') { + v2 = j + j = j + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = int8('\\') + v2 = j + j = j + 1 + i = i + 1 + v3 = i + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v3))) + } else { + if int32(c) == int32('@') && !(inStr != 0) { + if int32(**(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(i+uint64(1))))) == int32(',') { + i = i + 1 + } else { + if int32(**(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(j-uint64(1))))) == int32(',') { + j = j - 1 + } + } + } else { + v2 = j + j = j + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = c + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(j))) = 0 /* Restore zero terminator */ + (*TJsonString)(unsafe.Pointer(pStr)).FnUsed = j /* Truncate the string */ + } + if flags&int32(JSON_BLOB) != 0 { + _jsonReturnStringAsBlob(tls, pStr) + if isFinal != 0 { + if !((*TJsonString)(unsafe.Pointer(pStr)).FbStatic != 0) { + _sqlite3RCStrUnref(tls, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf) + } + } else { + _jsonStringTrimOneChar(tls, pOgStr) + } + } else { + if isFinal != 0 { + if (*TJsonString)(unsafe.Pointer(pStr)).FbStatic != 0 { + v8 = uintptr(-libc.Int32FromInt32(1)) + } else { + v8 = __ccgo_fp(_sqlite3RCStrUnref) + } + Xsqlite3_result_text(tls, ctx, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed), v8) + (*TJsonString)(unsafe.Pointer(pStr)).FbStatic = uint8(1) + } else { + Xsqlite3_result_text(tls, ctx, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed), uintptr(-libc.Int32FromInt32(1))) + _jsonStringTrimOneChar(tls, pOgStr) + } + } + if pStr != pOgStr { + _jsonStringReset(tls, pStr) + } + } else { + if flags&int32(JSON_BLOB) != 0 { + Xsqlite3_result_blob(tls, ctx, uintptr(unsafe.Pointer(&_emptyObject1)), int32(1), libc.UintptrFromInt32(0)) + } else { + Xsqlite3_result_text(tls, ctx, __ccgo_ts+27181, int32(2), libc.UintptrFromInt32(0)) + } + } + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /* +// ** Implementation of the json_object(NAME,VALUE,...) function. Return a JSON +// ** object that contains all name/value given in arguments. Or if any name +// ** is not a string or if any value is a BLOB, throw an error. +// */ +func _jsonObjectFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var i int32 + var n Tu32 + var z uintptr + var _ /* jx at bp+0 */ TJsonString + _, _, _ = i, n, z + if argc&int32(1) != 0 { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+27005, -int32(1)) + return + } + _jsonStringInit(tls, bp, ctx) + _jsonAppendChar(tls, bp, int8('{')) + i = 0 + for { + if !(i < argc) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) != int32(SQLITE_TEXT) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+27056, -int32(1)) + _jsonStringReset(tls, bp) + return + } + _jsonAppendSeparator(tls, bp) + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + n = libc.Uint32FromInt32(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)))) + _jsonAppendString(tls, bp, z, n) + _jsonAppendChar(tls, bp, int8(':')) + _jsonAppendSqlValue(tls, bp, **(**uintptr)(__ccgo_up(argv + uintptr(i+int32(1))*8))) + goto _1 + _1: + ; + i = i + int32(2) + } + _jsonAppendChar(tls, bp, int8('}')) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /* +// ** json_group_obj(NAME,VALUE) +// ** +// ** Return a JSON object composed of all names and values in the aggregate. +// ** +// ** Rows for which NAME is NULL do not result in a new entry. However, we +// ** do initially insert a "@" entry into the growing string for each null entry +// ** and change the first character of the string to "@" to signal that the +// ** string contains null entries. The "@" markers are needed in order to +// ** correctly process xInverse() requests. The initial "@" is converted +// ** back into "{" and the "@" null values are removed by jsonObjectCompute(). +// */ +func _jsonObjectStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var n Tu32 + var pStr, z uintptr + _, _, _ = n, pStr, z + _ = argc + pStr = Xsqlite3_aggregate_context(tls, ctx, int32(136)) + if pStr != 0 { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + n = libc.Uint32FromInt32(_sqlite3Strlen30(tls, z)) + if (*TJsonString)(unsafe.Pointer(pStr)).FzBuf == uintptr(0) { + _jsonStringInit(tls, pStr, ctx) + _jsonAppendChar(tls, pStr, int8('{')) + } else { + if (*TJsonString)(unsafe.Pointer(pStr)).FnUsed > uint64(1) { + _jsonAppendChar(tls, pStr, int8(',')) + } + } + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + if z != uintptr(0) { + _jsonAppendString(tls, pStr, z, n) + _jsonAppendChar(tls, pStr, int8(':')) + _jsonAppendSqlValue(tls, pStr, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf)) = int8('@') + _jsonAppendRawNZ(tls, pStr, __ccgo_ts+26994, uint32(1)) + } + } +} + +// C documentation +// +// /* +// ** Generate a JsonParse object, containing valid JSONB in aBlob and nBlob, +// ** from the SQL function argument pArg. Return a pointer to the new +// ** JsonParse object. +// ** +// ** Ownership of the new JsonParse object is passed to the caller. The +// ** caller should invoke jsonParseFree() on the return value when it +// ** has finished using it. +// ** +// ** If any errors are detected, an appropriate error messages is set +// ** using sqlite3_result_error() or the equivalent and this routine +// ** returns NULL. This routine also returns NULL if the pArg argument +// ** is an SQL NULL value, but no error message is set in that case. This +// ** is so that SQL functions that are given NULL arguments will return +// ** a NULL value. +// */ +func _jsonParseFuncArg(tls *libc.TLS, ctx uintptr, pArg uintptr, flgs Tu32) (r uintptr) { + var db, p, pFromCache, zNew, v2 uintptr + var eType, isRCStr, rc int32 + var nBlob, v1 Tu32 + _, _, _, _, _, _, _, _, _, _ = db, eType, isRCStr, nBlob, p, pFromCache, rc, zNew, v1, v2 /* Datatype of pArg */ + p = uintptr(0) /* Value to be returned */ + pFromCache = uintptr(0) /* The database connection */ + eType = Xsqlite3_value_type(tls, pArg) + if eType == int32(SQLITE_NULL) { + return uintptr(0) + } + pFromCache = _jsonCacheSearch(tls, ctx, pArg) + if pFromCache != 0 { + (*TJsonParse)(unsafe.Pointer(pFromCache)).FnJPRef = (*TJsonParse)(unsafe.Pointer(pFromCache)).FnJPRef + 1 + if flgs&uint32(JSON_EDITABLE) == uint32(0) { + return pFromCache + } + } + db = Xsqlite3_context_db_handle(tls, ctx) + goto rebuild_from_cache +rebuild_from_cache: + ; + p = _sqlite3DbMallocZero(tls, db, uint64(72)) + if p == uintptr(0) { + goto json_pfa_oom + } + libc.X__builtin___memset_chk(tls, p, 0, uint64(72), ^t__predefined_size_t(0)) + (*TJsonParse)(unsafe.Pointer(p)).Fdb = db + (*TJsonParse)(unsafe.Pointer(p)).FnJPRef = uint32(1) + if pFromCache != uintptr(0) { + nBlob = (*TJsonParse)(unsafe.Pointer(pFromCache)).FnBlob + (*TJsonParse)(unsafe.Pointer(p)).FaBlob = _sqlite3DbMallocRaw(tls, db, uint64(nBlob)) + if (*TJsonParse)(unsafe.Pointer(p)).FaBlob == uintptr(0) { + goto json_pfa_oom + } + libc.X__builtin___memcpy_chk(tls, (*TJsonParse)(unsafe.Pointer(p)).FaBlob, (*TJsonParse)(unsafe.Pointer(pFromCache)).FaBlob, uint64(nBlob), ^t__predefined_size_t(0)) + v1 = nBlob + (*TJsonParse)(unsafe.Pointer(p)).FnBlob = v1 + (*TJsonParse)(unsafe.Pointer(p)).FnBlobAlloc = v1 + (*TJsonParse)(unsafe.Pointer(p)).FhasNonstd = (*TJsonParse)(unsafe.Pointer(pFromCache)).FhasNonstd + _jsonParseFree(tls, pFromCache) + return p + } + if eType == int32(SQLITE_BLOB) { + if _jsonArgIsJsonb(tls, pArg, p) != 0 { + if flgs&uint32(JSON_EDITABLE) != uint32(0) && _jsonBlobMakeEditable(tls, p, uint32(0)) == 0 { + goto json_pfa_oom + } + return p + } + /* If the blob is not valid JSONB, fall through into trying to cast + ** the blob into text which is then interpreted as JSON. (tag-20240123-a) + ** + ** This goes against all historical documentation about how the SQLite + ** JSON functions were suppose to work. From the beginning, blob was + ** reserved for expansion and a blob value should have raised an error. + ** But it did not, due to a bug. And many applications came to depend + ** upon this buggy behavior, especially when using the CLI and reading + ** JSON text using readfile(), which returns a blob. For this reason + ** we will continue to support the bug moving forward. + ** See for example https://sqlite.org/forum/forumpost/012136abd5292b8d + */ + } + (*TJsonParse)(unsafe.Pointer(p)).FzJson = Xsqlite3_value_text(tls, pArg) + (*TJsonParse)(unsafe.Pointer(p)).FnJson = Xsqlite3_value_bytes(tls, pArg) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto json_pfa_oom + } + if (*TJsonParse)(unsafe.Pointer(p)).FnJson == 0 { + goto json_pfa_malformed + } + if flgs&uint32(JSON_KEEPERROR) != 0 { + v2 = uintptr(0) + } else { + v2 = ctx + } + if _jsonConvertTextToBlob(tls, p, v2) != 0 { + if flgs&uint32(JSON_KEEPERROR) != 0 { + (*TJsonParse)(unsafe.Pointer(p)).FnErr = uint8(1) + return p + } else { + _jsonParseFree(tls, p) + return uintptr(0) + } + } else { + isRCStr = _sqlite3ValueIsOfClass(tls, pArg, __ccgo_fp(_sqlite3RCStrUnref)) + if !(isRCStr != 0) { + zNew = _sqlite3RCStrNew(tls, libc.Uint64FromInt32((*TJsonParse)(unsafe.Pointer(p)).FnJson)) + if zNew == uintptr(0) { + goto json_pfa_oom + } + libc.X__builtin___memcpy_chk(tls, zNew, (*TJsonParse)(unsafe.Pointer(p)).FzJson, libc.Uint64FromInt32((*TJsonParse)(unsafe.Pointer(p)).FnJson), ^t__predefined_size_t(0)) + (*TJsonParse)(unsafe.Pointer(p)).FzJson = zNew + **(**int8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FzJson + uintptr((*TJsonParse)(unsafe.Pointer(p)).FnJson))) = 0 + } else { + _sqlite3RCStrRef(tls, (*TJsonParse)(unsafe.Pointer(p)).FzJson) + } + (*TJsonParse)(unsafe.Pointer(p)).FbJsonIsRCStr = uint8(1) + rc = _jsonCacheInsert(tls, ctx, p) + if rc == int32(SQLITE_NOMEM) { + goto json_pfa_oom + } + if flgs&uint32(JSON_EDITABLE) != 0 { + pFromCache = p + p = uintptr(0) + goto rebuild_from_cache + } + } + return p + goto json_pfa_malformed +json_pfa_malformed: + ; + if flgs&uint32(JSON_KEEPERROR) != 0 { + (*TJsonParse)(unsafe.Pointer(p)).FnErr = uint8(1) + return p + } else { + _jsonParseFree(tls, p) + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26784, -int32(1)) + return uintptr(0) + } + goto json_pfa_oom +json_pfa_oom: + ; + _jsonParseFree(tls, pFromCache) + _jsonParseFree(tls, p) + Xsqlite3_result_error_nomem(tls, ctx) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Implementation of the json_mergepatch(JSON1,JSON2) function. Return a JSON +// ** object that is the result of running the RFC 7396 MergePatch() algorithm +// ** on the two arguments. +// */ +func _jsonPatchFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var pPatch, pTarget uintptr + var rc int32 + _, _, _ = pPatch, pTarget, rc /* Result code */ + _ = argc + pTarget = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(JSON_EDITABLE)) + if pTarget == uintptr(0) { + return + } + pPatch = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv + 1*8)), uint32(0)) + if pPatch != 0 { + rc = _jsonMergePatch(tls, pTarget, uint32(0), pPatch, uint32(0), uint32(0)) + if rc == JSON_MERGE_OK { + _jsonReturnParse(tls, ctx, pTarget) + } else { + if rc == int32(JSON_MERGE_OOM) { + Xsqlite3_result_error_nomem(tls, ctx) + } else { + if rc == int32(JSON_MERGE_TOODEEP) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26734, -int32(1)) + } else { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26784, -int32(1)) + } + } + } + _jsonParseFree(tls, pPatch) + } + _jsonParseFree(tls, pTarget) +} + +// C documentation +// +// /* +// ** json_pretty(JSON) +// ** json_pretty(JSON, INDENT) +// ** +// ** Return text that is a pretty-printed rendering of the input JSON. +// ** If the argument is not valid JSON, return NULL. +// ** +// ** The INDENT argument is text that is used for indentation. If omitted, +// ** it defaults to four spaces (the same as PostgreSQL). +// */ +func _jsonPrettyFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(176) + defer tls.Free(176) + var v1 uintptr + var v2 bool + var _ /* s at bp+0 */ TJsonString + var _ /* x at bp+136 */ TJsonPretty + _, _ = v1, v2 /* Pretty printing context */ + libc.X__builtin___memset_chk(tls, bp+136, 0, uint64(32), ^t__predefined_size_t(0)) + (**(**TJsonPretty)(__ccgo_up(bp + 136))).FpParse = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if (**(**TJsonPretty)(__ccgo_up(bp + 136))).FpParse == uintptr(0) { + return + } + (**(**TJsonPretty)(__ccgo_up(bp + 136))).FpOut = bp + _jsonStringInit(tls, bp, ctx) + if v2 = argc == int32(1); !v2 { + v1 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + (**(**TJsonPretty)(__ccgo_up(bp + 136))).FzIndent = v1 + } + if v2 || v1 == uintptr(0) { + (**(**TJsonPretty)(__ccgo_up(bp + 136))).FzIndent = __ccgo_ts + 27114 + (**(**TJsonPretty)(__ccgo_up(bp + 136))).FszIndent = uint32(4) + } else { + (**(**TJsonPretty)(__ccgo_up(bp + 136))).FszIndent = uint32(libc.Xstrlen(tls, (**(**TJsonPretty)(__ccgo_up(bp + 136))).FzIndent)) + } + _jsonTranslateBlobToPrettyText(tls, bp+136, uint32(0)) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + _jsonParseFree(tls, (**(**TJsonPretty)(__ccgo_up(bp + 136))).FpParse) +} + +// C documentation +// +// /* +// ** json_replace(JSON, PATH, VALUE, ...) +// ** +// ** Replace the value at PATH with VALUE. If PATH does not already exist, +// ** this routine is a no-op. If JSON or PATH is malformed, throw an error. +// */ +func _jsonReplaceFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + if argc < int32(1) { + return + } + if argc&int32(1) == 0 { + _jsonWrongNumArgs(tls, ctx, __ccgo_ts+17412) + return + } + _jsonInsertIntoBlob(tls, ctx, argc, argv, int32(JEDIT_REPL)) +} + +// C documentation +// +// /* +// ** Return the value of the BLOB node at index i. +// ** +// ** If the value is a primitive, return it as an SQL value. +// ** If the value is an array or object, return it as either +// ** JSON text or the BLOB encoding, depending on the eMode flag +// ** as follows: +// ** +// ** eMode==0 JSONB if the JSON_B flag is set in userdata or +// ** text if the JSON_B flag is omitted from userdata. +// ** +// ** eMode==1 Text +// ** +// ** eMode==2 JSONB +// */ +func _jsonReturnFromBlob(tls *libc.TLS, pParse uintptr, i Tu32, pCtx uintptr, eMode int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bNeg, rc int32 + var c, x int8 + var db, z, z1, z2, zOut uintptr + var iIn, iOut, n, nOut, szEscape, v19, v20 Tu32 + var r, v16 float64 + var v17 int64 + var _ /* iRes at bp+8 */ Tsqlite3_int64 + var _ /* r at bp+16 */ float64 + var _ /* sz at bp+0 */ Tu32 + var _ /* v at bp+24 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNeg, c, db, iIn, iOut, n, nOut, r, rc, szEscape, x, z, z1, z2, zOut, v16, v17, v19, v20 + db = Xsqlite3_context_db_handle(tls, pCtx) + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26784, -int32(1)) + return + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case JSONB_NULL: + goto _1 + case int32(JSONB_TRUE): + goto _2 + case int32(JSONB_FALSE): + goto _3 + case int32(JSONB_INT): + goto _4 + case int32(JSONB_INT5): + goto _5 + case int32(JSONB_FLOAT): + goto _6 + case int32(JSONB_FLOAT5): + goto _7 + case int32(JSONB_TEXT): + goto _8 + case int32(JSONB_TEXTRAW): + goto _9 + case int32(JSONB_TEXTJ): + goto _10 + case int32(JSONB_TEXT5): + goto _11 + case int32(JSONB_OBJECT): + goto _12 + case int32(JSONB_ARRAY): + goto _13 + default: + goto _14 + } + goto _15 +_1: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_null(tls, pCtx) + goto _15 +_2: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_int(tls, pCtx, int32(1)) + goto _15 +_3: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_int(tls, pCtx, 0) + goto _15 +_5: + ; +_4: + ; + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0 + bNeg = 0 + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto returnfromblob_malformed + } + x = libc.Int8FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n)))) + if int32(x) == int32('-') { + if **(**Tu32)(__ccgo_up(bp)) < uint32(2) { + goto returnfromblob_malformed + } + n = n + 1 + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) - 1 + bNeg = int32(1) + } + z = _sqlite3DbStrNDup(tls, db, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), libc.Uint64FromInt32(libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))))) + if z == uintptr(0) { + goto returnfromblob_oom + } + rc = _sqlite3DecOrHexToI64(tls, z, bp+8) + _sqlite3DbFree(tls, db, z) + if rc == 0 { + if **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) < 0 { + r = float64(**(**Tsqlite3_uint64)(__ccgo_up(bp + 8))) + if bNeg != 0 { + v16 = -r + } else { + v16 = r + } + Xsqlite3_result_double(tls, pCtx, v16) + } else { + if bNeg != 0 { + v17 = -**(**Tsqlite3_int64)(__ccgo_up(bp + 8)) + } else { + v17 = **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) + } + Xsqlite3_result_int64(tls, pCtx, v17) + } + } else { + if rc == int32(3) && bNeg != 0 { + Xsqlite3_result_int64(tls, pCtx, int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>libc.Int32FromInt32(6)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } else { + if **(**Tu32)(__ccgo_up(bp + 24)) < uint32(0x10000) { + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0xe0) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(12)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(6)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } else { + if **(**Tu32)(__ccgo_up(bp + 24)) == uint32(JSON_INVALID_CHAR) { + /* Silently ignore illegal unicode */ + } else { + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0xf0) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(18)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(12)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(6)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } + } + } + } + iIn = iIn + (szEscape - uint32(1)) + } else { + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = c + } + goto _18 + _18: + ; + iIn = iIn + 1 + } /* end for() */ + **(**int8)(__ccgo_up(zOut + uintptr(iOut))) = 0 + Xsqlite3_result_text(tls, pCtx, zOut, libc.Int32FromUint32(iOut), __ccgo_fp(_sqlite3RowSetClear)) + goto _15 +_13: + ; +_12: + ; + if eMode == 0 { + if int32(int64(Xsqlite3_user_data(tls, pCtx)))&int32(JSON_BLOB) != 0 { + eMode = int32(2) + } else { + eMode = int32(1) + } + } + if eMode == int32(2) { + Xsqlite3_result_blob(tls, pCtx, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i), libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+n), uintptr(-libc.Int32FromInt32(1))) + } else { + _jsonReturnTextJsonFromBlob(tls, pCtx, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i), **(**Tu32)(__ccgo_up(bp))+n) + } + goto _15 +_14: + ; + goto returnfromblob_malformed +_15: + ; + return + goto returnfromblob_oom +returnfromblob_oom: + ; + Xsqlite3_result_error_nomem(tls, pCtx) + return + goto returnfromblob_malformed +returnfromblob_malformed: + ; + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26784, -int32(1)) + return +} + +// C documentation +// +// /* Make the text in p (which is probably a generated JSON text string) +// ** the result of the SQL function. +// ** +// ** The JsonString is reset. +// ** +// ** If pParse and ctx are both non-NULL, then the SQL string in p is +// ** loaded into the zJson field of the pParse object as a RCStr and the +// ** pParse is added to the cache. +// */ +func _jsonReturnString(tls *libc.TLS, p uintptr, pParse uintptr, ctx uintptr) { + var flags, rc int32 + _, _ = flags, rc + _jsonStringTerminate(tls, p) + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr) == 0 { + flags = int32(int64(Xsqlite3_user_data(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx))) + if flags&int32(JSON_BLOB) != 0 { + _jsonReturnStringAsBlob(tls, p) + } else { + if (*TJsonString)(unsafe.Pointer(p)).FbStatic != 0 { + Xsqlite3_result_text64(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx, (*TJsonString)(unsafe.Pointer(p)).FzBuf, (*TJsonString)(unsafe.Pointer(p)).FnUsed, uintptr(-libc.Int32FromInt32(1)), uint8(SQLITE_UTF8)) + } else { + if pParse != 0 && libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FbJsonIsRCStr) == 0 && (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc > uint32(0) { + (*TJsonParse)(unsafe.Pointer(pParse)).FzJson = _sqlite3RCStrRef(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf) + (*TJsonParse)(unsafe.Pointer(pParse)).FnJson = libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(p)).FnUsed) + (*TJsonParse)(unsafe.Pointer(pParse)).FbJsonIsRCStr = uint8(1) + rc = _jsonCacheInsert(tls, ctx, pParse) + if rc == int32(SQLITE_NOMEM) { + Xsqlite3_result_error_nomem(tls, ctx) + _jsonStringReset(tls, p) + return + } + } + Xsqlite3_result_text64(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx, _sqlite3RCStrRef(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf), (*TJsonString)(unsafe.Pointer(p)).FnUsed, __ccgo_fp(_sqlite3RCStrUnref), uint8(SQLITE_UTF8)) + } + } + } else { + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr)&int32(JSTRING_OOM) != 0 { + Xsqlite3_result_error_nomem(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx) + } else { + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr)&int32(JSTRING_TOODEEP) != 0 { + /* error already in p->pCtx */ + } else { + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr)&int32(JSTRING_MALFORMED) != 0 { + Xsqlite3_result_error(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx, __ccgo_ts+26784, -int32(1)) + } + } + } + } + _jsonStringReset(tls, p) +} + +/************************************************************************** +** Utility routines for dealing with JsonParse objects +**************************************************************************/ + +// C documentation +// +// /* +// ** The input string pStr is a well-formed JSON text string. Convert +// ** this into the JSONB format and make it the return value of the +// ** SQL function. +// */ +func _jsonReturnStringAsBlob(tls *libc.TLS, pStr uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var _ /* px at bp+0 */ TJsonParse + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TJsonParse)(__ccgo_up(bp))).FzJson = (*TJsonString)(unsafe.Pointer(pStr)).FzBuf + (**(**TJsonParse)(__ccgo_up(bp))).FnJson = libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed) + (**(**TJsonParse)(__ccgo_up(bp))).Fdb = Xsqlite3_context_db_handle(tls, (*TJsonString)(unsafe.Pointer(pStr)).FpCtx) + _jsonTranslateTextToBlob(tls, bp, uint32(0)) + if (**(**TJsonParse)(__ccgo_up(bp))).Foom != 0 { + _sqlite3DbFree(tls, (**(**TJsonParse)(__ccgo_up(bp))).Fdb, (**(**TJsonParse)(__ccgo_up(bp))).FaBlob) + Xsqlite3_result_error_nomem(tls, (*TJsonString)(unsafe.Pointer(pStr)).FpCtx) + } else { + Xsqlite3_result_blob(tls, (*TJsonString)(unsafe.Pointer(pStr)).FpCtx, (**(**TJsonParse)(__ccgo_up(bp))).FaBlob, libc.Int32FromUint32((**(**TJsonParse)(__ccgo_up(bp))).FnBlob), __ccgo_fp(_sqlite3RowSetClear)) + } +} + +// C documentation +// +// /* +// ** Convert a JSON BLOB into text and make that text the return value +// ** of an SQL function. +// */ +func _jsonReturnTextJsonFromBlob(tls *libc.TLS, ctx uintptr, aBlob uintptr, nBlob Tu32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var _ /* s at bp+72 */ TJsonString + var _ /* x at bp+0 */ TJsonParse + if aBlob == uintptr(0) { + return + } + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TJsonParse)(__ccgo_up(bp))).FaBlob = aBlob + (**(**TJsonParse)(__ccgo_up(bp))).FnBlob = nBlob + _jsonStringInit(tls, bp+72, ctx) + _jsonTranslateBlobToText(tls, bp, uint32(0), bp+72) + _jsonReturnString(tls, bp+72, uintptr(0), uintptr(0)) +} + +// C documentation +// +// /* Append N bytes from zIn onto the end of the JsonString string. +// */ +func _jsonStringExpandAndAppend(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + if _jsonStringGrow(tls, p, N) != 0 { + return + } + libc.X__builtin___memcpy_chk(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), zIn, uint64(N), ^t__predefined_size_t(0)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(N) +} + +// C documentation +// +// /* Enlarge pJson->zBuf so that it can hold at least N more bytes. +// ** Return zero on success. Return non-zero on an OOM error +// */ +func _jsonStringGrow(tls *libc.TLS, p uintptr, N Tu32) (r int32) { + var nTotal Tu64 + var zNew, v2 uintptr + var v1 uint64 + _, _, _, _ = nTotal, zNew, v1, v2 + if uint64(N) < (*TJsonString)(unsafe.Pointer(p)).FnAlloc { + v1 = (*TJsonString)(unsafe.Pointer(p)).FnAlloc * uint64(2) + } else { + v1 = (*TJsonString)(unsafe.Pointer(p)).FnAlloc + uint64(N) + uint64(10) + } + nTotal = v1 + if (*TJsonString)(unsafe.Pointer(p)).FbStatic != 0 { + if (*TJsonString)(unsafe.Pointer(p)).FeErr != 0 { + return int32(1) + } + zNew = _sqlite3RCStrNew(tls, nTotal) + if zNew == uintptr(0) { + _jsonStringOom(tls, p) + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, zNew, (*TJsonString)(unsafe.Pointer(p)).FzBuf, (*TJsonString)(unsafe.Pointer(p)).FnUsed, ^t__predefined_size_t(0)) + (*TJsonString)(unsafe.Pointer(p)).FzBuf = zNew + (*TJsonString)(unsafe.Pointer(p)).FbStatic = uint8(0) + } else { + (*TJsonString)(unsafe.Pointer(p)).FzBuf = _sqlite3RCStrResize(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf, nTotal) + if (*TJsonString)(unsafe.Pointer(p)).FzBuf == uintptr(0) { + v2 = p + 33 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(JSTRING_OOM)) + _jsonStringZero(tls, p) + return int32(SQLITE_NOMEM) + } + } + (*TJsonString)(unsafe.Pointer(p)).FnAlloc = nTotal + return SQLITE_OK +} + +// C documentation +// +// /* Report JSON nested too deep +// */ +func _jsonStringTooDeep(tls *libc.TLS, p uintptr) { + var v1 uintptr + _ = v1 + v1 = p + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_TOODEEP)) + Xsqlite3_result_error(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx, __ccgo_ts+26734, -int32(1)) + _jsonStringReset(tls, p) +} + +// C documentation +// +// /* +// ** Translate the binary JSONB representation of JSON beginning at +// ** pParse->aBlob[i] into a JSON text string. Append the JSON +// ** text onto the end of pOut. Return the index in pParse->aBlob[] +// ** of the first byte past the end of the element that is translated. +// ** +// ** This is a variant of jsonTranslateBlobToText() that "pretty-prints" +// ** the output. Extra whitespace is inserted to make the JSON easier +// ** for humans to read. +// ** +// ** If an error is detected in the BLOB input, the pOut->eErr flag +// ** might get set to JSTRING_MALFORMED. But not all BLOB input errors +// ** are detected. So a malformed JSONB input might either result +// ** in an error, or in incorrect JSON. +// ** +// ** The pOut->eErr JSTRING_OOM flag is set on a OOM. +// */ +func _jsonTranslateBlobToPrettyText(tls *libc.TLS, pPretty uintptr, i Tu32) (r Tu32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iEnd, j, n Tu32 + var pOut, pParse, v1 uintptr + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _ = iEnd, j, n, pOut, pParse, v1 + pParse = (*TJsonPretty)(unsafe.Pointer(pPretty)).FpParse + pOut = (*TJsonPretty)(unsafe.Pointer(pPretty)).FpOut + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + return (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + uint32(1) + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case int32(JSONB_ARRAY): + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + _jsonAppendChar(tls, pOut, int8('[')) + if j < iEnd { + _jsonAppendChar(tls, pOut, int8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent + 1 + if (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent >= uint32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + _jsonPrettyIndent(tls, pPretty) + j = _jsonTranslateBlobToPrettyText(tls, pPretty, j) + if j >= iEnd { + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26923, uint32(2)) + } + _jsonAppendChar(tls, pOut, int8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent - 1 + _jsonPrettyIndent(tls, pPretty) + } + _jsonAppendChar(tls, pOut, int8(']')) + i = iEnd + case int32(JSONB_OBJECT): + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + _jsonAppendChar(tls, pOut, int8('{')) + if j < iEnd { + _jsonAppendChar(tls, pOut, int8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent + 1 + if (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent >= uint32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = uint16((*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent) + for libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + _jsonPrettyIndent(tls, pPretty) + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + if j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26926, uint32(2)) + j = _jsonTranslateBlobToPrettyText(tls, pPretty, j) + if j >= iEnd { + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26923, uint32(2)) + } + _jsonAppendChar(tls, pOut, int8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent - 1 + _jsonPrettyIndent(tls, pPretty) + } + _jsonAppendChar(tls, pOut, int8('}')) + i = iEnd + default: + i = _jsonTranslateBlobToText(tls, pParse, i, pOut) + break + } + return i +} + +// C documentation +// +// /* +// ** Translate the binary JSONB representation of JSON beginning at +// ** pParse->aBlob[i] into a JSON text string. Append the JSON +// ** text onto the end of pOut. Return the index in pParse->aBlob[] +// ** of the first byte past the end of the element that is translated. +// ** +// ** If an error is detected in the BLOB input, the pOut->eErr flag +// ** might get set to JSTRING_MALFORMED. But not all BLOB input errors +// ** are detected. So a malformed JSONB input might either result +// ** in an error, or in incorrect JSON. +// ** +// ** The pOut->eErr JSTRING_OOM flag is set on a OOM. +// */ +func _jsonTranslateBlobToText(tls *libc.TLS, pParse uintptr, i Tu32, pOut uintptr) (r Tu32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOverflow, x, v30, v31 int32 + var iEnd, j, k, k1, k2, n, sz2 Tu32 + var u Tsqlite3_uint64 + var zIn, zIn1, zIn2, v1 uintptr + var v25 Tu16 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bOverflow, iEnd, j, k, k1, k2, n, sz2, u, x, zIn, zIn1, zIn2, v1, v25, v30, v31 + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + return (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + uint32(1) + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case JSONB_NULL: + goto _2 + case int32(JSONB_TRUE): + goto _3 + case int32(JSONB_FALSE): + goto _4 + case int32(JSONB_FLOAT): + goto _5 + case int32(JSONB_INT): + goto _6 + case int32(JSONB_INT5): + goto _7 + case int32(JSONB_FLOAT5): + goto _8 + case int32(JSONB_TEXTJ): + goto _9 + case int32(JSONB_TEXT): + goto _10 + case int32(JSONB_TEXT5): + goto _11 + case int32(JSONB_TEXTRAW): + goto _12 + case int32(JSONB_ARRAY): + goto _13 + case int32(JSONB_OBJECT): + goto _14 + default: + goto _15 + } + goto _16 +_2: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+1688, uint32(4)) + return i + uint32(1) +_3: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+8522, uint32(4)) + return i + uint32(1) +_4: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+8527, uint32(5)) + return i + uint32(1) +_6: + ; +_5: + ; + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + _jsonAppendRaw(tls, pOut, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), **(**Tu32)(__ccgo_up(bp))) + goto _16 +_7: + ; /* Integer literal in hexadecimal notation */ + k = uint32(2) + u = uint64(0) + zIn = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + bOverflow = 0 + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + if int32(**(**int8)(__ccgo_up(zIn))) == int32('-') { + _jsonAppendChar(tls, pOut, int8('-')) + k = k + 1 + } else { + if int32(**(**int8)(__ccgo_up(zIn))) == int32('+') { + k = k + 1 + } + } + for { + if !(k < **(**Tu32)(__ccgo_up(bp))) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn + uintptr(k))))])&libc.Int32FromInt32(0x08) != 0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } else { + if u>>libc.Int32FromInt32(60) != uint64(0) { + bOverflow = int32(1) + } else { + u = u*uint64(16) + uint64(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(zIn + uintptr(k)))))) + } + } + goto _17 + _17: + ; + k = k + 1 + } + if bOverflow != 0 { + v1 = __ccgo_ts + 26803 + } else { + v1 = __ccgo_ts + 13348 + } + _jsonPrintf(tls, int32(100), pOut, v1, libc.VaList(bp+16, u)) + goto _16 +_8: + ; /* Float literal missing digits beside "." */ + k1 = uint32(0) + zIn1 = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + if int32(**(**int8)(__ccgo_up(zIn1))) == int32('-') { + _jsonAppendChar(tls, pOut, int8('-')) + k1 = k1 + 1 + } + if int32(**(**int8)(__ccgo_up(zIn1 + uintptr(k1)))) == int32('.') { + _jsonAppendChar(tls, pOut, int8('0')) + } + for { + if !(k1 < **(**Tu32)(__ccgo_up(bp))) { + break + } + _jsonAppendChar(tls, pOut, **(**int8)(__ccgo_up(zIn1 + uintptr(k1)))) + if int32(**(**int8)(__ccgo_up(zIn1 + uintptr(k1)))) == int32('.') && (k1+uint32(1) == **(**Tu32)(__ccgo_up(bp)) || !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn1 + uintptr(k1+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0)) { + _jsonAppendChar(tls, pOut, int8('0')) + } + goto _20 + _20: + ; + k1 = k1 + 1 + } + goto _16 +_10: + ; +_9: + ; + if (*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(**(**Tu32)(__ccgo_up(bp)))+uint64(2) <= (*TJsonString)(unsafe.Pointer(pOut)).FnAlloc || _jsonStringGrow(tls, pOut, **(**Tu32)(__ccgo_up(bp))+uint32(2)) == 0 { + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pOut)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed))) = int8('"') + libc.X__builtin___memcpy_chk(tls, (*TJsonString)(unsafe.Pointer(pOut)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed)+uintptr(1), (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), uint64(**(**Tu32)(__ccgo_up(bp))), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pOut)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(**(**Tu32)(__ccgo_up(bp)))+uint64(1)))) = int8('"') + **(**Tu64)(__ccgo_up(pOut + 24)) += uint64(**(**Tu32)(__ccgo_up(bp)) + uint32(2)) + } + goto _16 +_11: + ; + sz2 = **(**Tu32)(__ccgo_up(bp)) + zIn2 = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + _jsonAppendChar(tls, pOut, int8('"')) + for sz2 > uint32(0) { + k2 = uint32(0) + for { + if !(k2 < sz2 && (_jsonIsOk[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + uintptr(k2))))] != 0 || int32(**(**int8)(__ccgo_up(zIn2 + uintptr(k2)))) == int32('\''))) { + break + } + goto _21 + _21: + ; + k2 = k2 + 1 + } + if k2 > uint32(0) { + _jsonAppendRawNZ(tls, pOut, zIn2, k2) + if k2 >= sz2 { + break + } + zIn2 = zIn2 + uintptr(k2) + sz2 = sz2 - k2 + } + if int32(**(**int8)(__ccgo_up(zIn2))) == int32('"') { + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26901, uint32(2)) + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + continue + } + if int32(**(**int8)(__ccgo_up(zIn2))) <= int32(0x1f) { + if (*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(7) > (*TJsonString)(unsafe.Pointer(pOut)).FnAlloc && _jsonStringGrow(tls, pOut, uint32(7)) != 0 { + break + } + _jsonAppendControlChar(tls, pOut, libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2)))) + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + continue + } + if sz2 < uint32(2) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } + switch libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + 1)))) { + case int32('\''): + _jsonAppendChar(tls, pOut, int8('\'')) + case int32('v'): + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26904, uint32(6)) + case int32('x'): + if sz2 < uint32(4) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + sz2 = uint32(2) + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26911, uint32(4)) + _jsonAppendRawNZ(tls, pOut, zIn2+2, uint32(2)) + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + case int32('0'): + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26916, uint32(6)) + case int32('\r'): + if sz2 > uint32(2) && int32(**(**int8)(__ccgo_up(zIn2 + 2))) == int32('\n') { + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + } + case int32('\n'): + case int32(0xe2): + /* '\' followed by either U+2028 or U+2029 is ignored as + ** whitespace. Not that in UTF8, U+2028 is 0xe2 0x80 0x29. + ** U+2029 is the same except for the last byte */ + if sz2 < uint32(4) || int32(0x80) != libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + 2)))) || int32(0xa8) != libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + 3)))) && int32(0xa9) != libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + 3)))) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + sz2 = uint32(2) + break + } + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + default: + _jsonAppendRawNZ(tls, pOut, zIn2, uint32(2)) + break + } + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + } + _jsonAppendChar(tls, pOut, int8('"')) + goto _16 +_12: + ; + _jsonAppendString(tls, pOut, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), **(**Tu32)(__ccgo_up(bp))) + goto _16 +_13: + ; + _jsonAppendChar(tls, pOut, int8('[')) + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + v1 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v25 = *(*Tu16)(unsafe.Pointer(v1)) + if libc.Int32FromUint16(v25) > int32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for j < iEnd && libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + _jsonAppendChar(tls, pOut, int8(',')) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + } + if **(**Tu32)(__ccgo_up(bp)) > uint32(0) { + _jsonStringTrimOneChar(tls, pOut) + } + _jsonAppendChar(tls, pOut, int8(']')) + goto _16 +_14: + ; + x = 0 + _jsonAppendChar(tls, pOut, int8('{')) + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + v1 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v25 = *(*Tu16)(unsafe.Pointer(v1)) + if libc.Int32FromUint16(v25) > int32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for j < iEnd && libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + v31 = x + x = x + 1 + if v31&int32(1) != 0 { + v30 = int32(',') + } else { + v30 = int32(':') + } + _jsonAppendChar(tls, pOut, int8(v30)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if x&int32(1) != 0 || j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + } + if **(**Tu32)(__ccgo_up(bp)) > uint32(0) { + _jsonStringTrimOneChar(tls, pOut) + } + _jsonAppendChar(tls, pOut, int8('}')) + goto _16 +_15: + ; + goto malformed_jsonb +malformed_jsonb: + ; + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + goto _16 +_16: + ; + return i + n + **(**Tu32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Translate a single element of JSON text at pParse->zJson[i] into +// ** its equivalent binary JSONB representation. Append the translation into +// ** pParse->aBlob[] beginning at pParse->nBlob. The size of +// ** pParse->aBlob[] is increased as necessary. +// ** +// ** Return the index of the first character past the end of the element parsed, +// ** or one of the following special result codes: +// ** +// ** 0 End of input +// ** -1 Syntax error or OOM +// ** -2 '}' seen ** -3 ']' seen \___ For these returns, pParse->iErr is set to +// ** -4 ',' seen / the index in zJson[] of the seen character +// ** -5 ':' seen / +// */ +func _jsonTranslateTextToBlob(tls *libc.TLS, pParse uintptr, i Tu32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, cDelim int8 + var iBlob, iStart, iThis, j, k1, v46 Tu32 + var k, nn, x, v48 int32 + var opcode, seenE, t Tu8 + var z, v41 uintptr + var v40 Tu16 + var _ /* op at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, cDelim, iBlob, iStart, iThis, j, k, k1, nn, opcode, seenE, t, x, z, v40, v41, v46, v48 + z = (*TJsonParse)(unsafe.Pointer(pParse)).FzJson + goto json_parse_restart +json_parse_restart: + ; + switch libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i))))) { + case int32('{'): + goto _1 + case int32('['): + goto _2 + case int32('"'): + goto _3 + case int32('\''): + goto _4 + case int32('t'): + goto _5 + case int32('f'): + goto _6 + case int32('.'): + goto _7 + case int32('9'): + goto _8 + case int32('8'): + goto _9 + case int32('7'): + goto _10 + case int32('6'): + goto _11 + case int32('5'): + goto _12 + case int32('4'): + goto _13 + case int32('3'): + goto _14 + case int32('2'): + goto _15 + case int32('1'): + goto _16 + case int32('0'): + goto _17 + case int32('-'): + goto _18 + case int32('+'): + goto _19 + case int32('}'): + goto _20 + case int32(']'): + goto _21 + case int32(','): + goto _22 + case int32(':'): + goto _23 + case 0: + goto _24 + case int32(0x20): + goto _25 + case int32(0x0d): + goto _26 + case int32(0x0a): + goto _27 + case int32(0x09): + goto _28 + case int32(0xef): + goto _29 + case int32(0xe3): + goto _30 + case int32(0xe2): + goto _31 + case int32(0xe1): + goto _32 + case int32(0xc2): + goto _33 + case int32('/'): + goto _34 + case int32(0x0c): + goto _35 + case int32(0x0b): + goto _36 + case int32('n'): + goto _37 + default: + goto _38 + } + goto _39 +_1: + ; + /* Parse object */ + iThis = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_OBJECT), uint64(libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pParse)).FnJson)-i), uintptr(0)) + v41 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v41)) = *(*Tu16)(unsafe.Pointer(v41)) + 1 + v40 = *(*Tu16)(unsafe.Pointer(v41)) + if libc.Int32FromUint16(v40) > int32(JSON_MAX_DEPTH) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + iStart = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + j = i + uint32(1) + for { + iBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x == -int32(2) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob != iStart { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + break + } + j = j + libc.Uint32FromInt32(_json5Whitespace(tls, z+uintptr(j))) + **(**int32)(__ccgo_up(bp)) = int32(JSONB_TEXT) + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))])&int32(0x42) != 0 || int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32('\\') && _jsonIs4HexB(tls, z+uintptr(j+uint32(1)), bp) != 0 { + k = libc.Int32FromUint32(j + uint32(1)) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(k))))])&int32(0x46) != 0 && _json5Whitespace(tls, z+uintptr(k)) == 0 || int32(**(**int8)(__ccgo_up(z + uintptr(k)))) == int32('\\') && _jsonIs4HexB(tls, z+uintptr(k+int32(1)), bp) != 0 { + k = k + 1 + } + _jsonBlobAppendNode(tls, pParse, libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))), uint64(libc.Uint32FromInt32(k)-j), z+uintptr(j)) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + x = k + } else { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + } + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return -int32(1) + } + t = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iBlob)))) & int32(0x0f)) + if libc.Int32FromUint8(t) < int32(JSONB_TEXT) || libc.Int32FromUint8(t) > int32(JSONB_TEXTRAW) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(':') { + j = j + 1 + } else { + if _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + /* strspn() is not helpful here */ + for cond := true; cond; cond = _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + 1 + } + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(':') { + j = j + 1 + goto parse_object_value + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x != -int32(5) { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + uint32(1) + } + goto parse_object_value + parse_object_value: + ; + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _42 + } else { + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32('}') { + break + } else { + if _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(j+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _42 + } else { + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32('}') { + break + } + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x == -int32(4) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + goto _42 + } + if x == -int32(2) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + break + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + goto _42 + _42: + ; + j = j + 1 + } + _jsonBlobChangePayloadSize(tls, pParse, iThis, (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-iStart) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + return libc.Int32FromUint32(j + uint32(1)) +_2: + ; + /* Parse array */ + iThis = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_ARRAY), uint64(libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pParse)).FnJson)-i), uintptr(0)) + iStart = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return -int32(1) + } + v41 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v41)) = *(*Tu16)(unsafe.Pointer(v41)) + 1 + v40 = *(*Tu16)(unsafe.Pointer(v41)) + if libc.Int32FromUint16(v40) > int32(JSON_MAX_DEPTH) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + j = i + uint32(1) + for { + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x == -int32(3) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob != iStart { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + break + } + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _45 + } else { + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(']') { + break + } else { + if _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(j+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _45 + } else { + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(']') { + break + } + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x == -int32(4) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + goto _45 + } + if x == -int32(3) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + break + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + goto _45 + _45: + ; + j = j + 1 + } + _jsonBlobChangePayloadSize(tls, pParse, iThis, (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-iStart) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + return libc.Int32FromUint32(j + uint32(1)) +_4: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + opcode = uint8(JSONB_TEXT) + goto parse_string +_3: + ; + /* Parse string */ + opcode = uint8(JSONB_TEXT) + goto parse_string +parse_string: + ; + cDelim = **(**int8)(__ccgo_up(z + uintptr(i))) + j = i + uint32(1) + for int32(1) != 0 { + if _jsonIsOk[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + if !(_jsonIsOk[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))))] != 0) { + j = j + uint32(1) + } else { + if !(_jsonIsOk[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(2)))))] != 0) { + j = j + uint32(2) + } else { + j = j + uint32(3) + continue + } + } + } + c = **(**int8)(__ccgo_up(z + uintptr(j))) + if int32(c) == int32(cDelim) { + break + } else { + if int32(c) == int32('\\') { + j = j + 1 + v46 = j + c = **(**int8)(__ccgo_up(z + uintptr(v46))) + if int32(c) == int32('"') || int32(c) == int32('\\') || int32(c) == int32('/') || int32(c) == int32('b') || int32(c) == int32('f') || int32(c) == int32('n') || int32(c) == int32('r') || int32(c) == int32('t') || int32(c) == int32('u') && _jsonIs4Hex(tls, z+uintptr(j+uint32(1))) != 0 { + if libc.Int32FromUint8(opcode) == int32(JSONB_TEXT) { + opcode = uint8(JSONB_TEXTJ) + } + } else { + if int32(c) == int32('\'') || int32(c) == int32('v') || int32(c) == int32('\n') || int32(c) == int32('0') && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0) || int32(0xe2) == libc.Int32FromUint8(libc.Uint8FromInt8(c)) && int32(0x80) == libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))))) && (int32(0xa8) == libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(2)))))) || int32(0xa9) == libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(2))))))) || int32(c) == int32('x') && _jsonIs2Hex(tls, z+uintptr(j+uint32(1))) != 0 { + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + if int32(c) == int32('\r') { + if int32(**(**int8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('\n') { + j = j + 1 + } + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + } + } else { + if int32(c) <= int32(0x1f) { + if int32(c) == 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + /* Control characters are not allowed in canonical JSON string + ** literals, but are allowed in JSON5 string literals. */ + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + if int32(c) == int32('"') { + opcode = uint8(JSONB_TEXT5) + } + } + } + } + j = j + 1 + } + _jsonBlobAppendNode(tls, pParse, opcode, uint64(j-uint32(1)-i), z+uintptr(i+uint32(1))) + return libc.Int32FromUint32(j + uint32(1)) +_5: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+8522, uint64(4)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(4)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_TRUE)) + return libc.Int32FromUint32(i + uint32(4)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_6: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+8527, uint64(5)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(5)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_FALSE)) + return libc.Int32FromUint32(i + uint32(5)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_19: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x00) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + goto parse_number +_7: + ; + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x03) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + seenE = uint8(0) + goto parse_number_2 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_18: + ; +_17: + ; +_16: + ; +_15: + ; +_14: + ; +_13: + ; +_12: + ; +_11: + ; +_10: + ; +_9: + ; +_8: + ; + /* Parse number */ + t = uint8(0x00) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + goto parse_number +parse_number: + ; + seenE = uint8(0) + c = **(**int8)(__ccgo_up(z + uintptr(i))) + if int32(c) <= int32('0') { + if int32(c) == int32('0') { + if (int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('x') || int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('X')) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(2)))))])&int32(0x08) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x01) + j = i + uint32(3) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))])&int32(0x08) != 0) { + break + } + goto _47 + _47: + ; + j = j + 1 + } + goto parse_number_finish + } else { + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + uint32(1) + return -int32(1) + } + } + } else { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0) { + /* JSON5 allows for "+Infinity" and "-Infinity" using exactly + ** that case. SQLite also allows these in any case and it allows + ** "+inf" and "-inf". */ + if (int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('I') || int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('i')) && Xsqlite3_strnicmp(tls, z+uintptr(i+uint32(1)), __ccgo_ts+26799, int32(3)) == 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + if int32(**(**int8)(__ccgo_up(z + uintptr(i)))) == int32('-') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(6), __ccgo_ts+26882) + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26889) + } + if Xsqlite3_strnicmp(tls, z+uintptr(i+uint32(4)), __ccgo_ts+26895, int32(5)) == 0 { + v48 = int32(9) + } else { + v48 = int32(4) + } + return libc.Int32FromUint32(i + libc.Uint32FromInt32(v48)) + } + if int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('.') { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + goto parse_number_2 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + if int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('0') { + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + uint32(1) + return -int32(1) + } else { + if (int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(2))))) == int32('x') || int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(2))))) == int32('X')) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(3)))))])&int32(0x08) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + j = i + uint32(4) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))])&int32(0x08) != 0) { + break + } + goto _49 + _49: + ; + j = j + 1 + } + goto parse_number_finish + } + } + } + } + } + goto parse_number_2 +parse_number_2: + ; + j = i + uint32(1) + for { + c = **(**int8)(__ccgo_up(z + uintptr(j))) + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(c)])&int32(0x04) != 0 { + goto _50 + } + if int32(c) == int32('.') { + if libc.Int32FromUint8(t)&int32(0x02) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x02)) + goto _50 + } + if int32(c) == int32('e') || int32(c) == int32('E') { + if int32(**(**int8)(__ccgo_up(z + uintptr(j-uint32(1))))) < int32('0') { + if int32(**(**int8)(__ccgo_up(z + uintptr(j-uint32(1))))) == int32('.') && j-uint32(2) >= i && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j-uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + if seenE != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x02)) + seenE = uint8(1) + c = **(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))) + if int32(c) == int32('+') || int32(c) == int32('-') { + j = j + 1 + c = **(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))) + } + if int32(c) < int32('0') || int32(c) > int32('9') { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + goto _50 + } + break + goto _50 + _50: + ; + j = j + 1 + } + if int32(**(**int8)(__ccgo_up(z + uintptr(j-uint32(1))))) < int32('0') { + if int32(**(**int8)(__ccgo_up(z + uintptr(j-uint32(1))))) == int32('.') && j-uint32(2) >= i && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j-uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + goto parse_number_finish +parse_number_finish: + ; + if int32(**(**int8)(__ccgo_up(z + uintptr(i)))) == int32('+') { + i = i + 1 + } + _jsonBlobAppendNode(tls, pParse, libc.Uint8FromInt32(int32(JSONB_INT)+libc.Int32FromUint8(t)), uint64(j-i), z+uintptr(i)) + return libc.Int32FromUint32(j) +_20: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(2) /* End of {...} */ +_21: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(3) /* End of [...] */ +_22: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(4) /* List separator */ +_23: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(5) /* Object label/value separator */ +_24: + ; + return 0 /* End of file */ +_28: + ; +_27: + ; +_26: + ; +_25: + ; + i = i + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(i+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + goto json_parse_restart +_36: + ; +_35: + ; +_34: + ; +_33: + ; +_32: + ; +_31: + ; +_30: + ; +_29: + ; + j = libc.Uint32FromInt32(_json5Whitespace(tls, z+uintptr(i))) + if j > uint32(0) { + i = i + j + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + goto json_parse_restart + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_37: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+1688, uint64(4)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(4)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_NULL)) + return libc.Int32FromUint32(i + uint32(4)) + } + /* fall-through into the default case that checks for NaN */ +_38: + ; + c = **(**int8)(__ccgo_up(z + uintptr(i))) + k1 = uint32(0) + for { + if !(uint64(k1) < libc.Uint64FromInt64(120)/libc.Uint64FromInt64(24)) { + break + } + if int32(c) != int32(_aNanInfName[k1].Fc1) && int32(c) != int32(_aNanInfName[k1].Fc2) { + goto _51 + } + nn = int32(_aNanInfName[k1].Fn) + if Xsqlite3_strnicmp(tls, z+uintptr(i), _aNanInfName[k1].FzMatch, nn) != 0 { + goto _51 + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+libc.Uint32FromInt32(nn)))))])&int32(0x06) != 0 { + goto _51 + } + if int32(_aNanInfName[k1].FeType) == int32(JSONB_FLOAT) { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26889) + } else { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_NULL)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + return libc.Int32FromUint32(i + libc.Uint32FromInt32(nn)) + goto _51 + _51: + ; + k1 = k1 + 1 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) /* Syntax error */ +_39: + ; /* End switch(z[i]) */ + return r +} + +// C documentation +// +// /* +// ** json_valid(JSON) +// ** json_valid(JSON, FLAGS) +// ** +// ** Check the JSON argument to see if it is well-formed. The FLAGS argument +// ** encodes the various constraints on what is meant by "well-formed": +// ** +// ** 0x01 Canonical RFC-8259 JSON text +// ** 0x02 JSON text with optional JSON-5 extensions +// ** 0x04 Superficially appears to be JSONB +// ** 0x08 Strictly well-formed JSONB +// ** +// ** If the FLAGS argument is omitted, it defaults to 1. Useful values for +// ** FLAGS include: +// ** +// ** 1 Strict canonical JSON text +// ** 2 JSON text perhaps with JSON-5 extensions +// ** 4 Superficially appears to be JSONB +// ** 5 Canonical JSON text or superficial JSONB +// ** 6 JSON-5 text or superficial JSONB +// ** 8 Strict JSONB +// ** 9 Canonical JSON text or strict JSONB +// ** 10 JSON-5 text or strict JSONB +// ** +// ** Other flag combinations are redundant. For example, every canonical +// ** JSON text is also well-formed JSON-5 text, so FLAG values 2 and 3 +// ** are the same. Similarly, any input that passes a strict JSONB validation +// ** will also pass the superficial validation so 12 through 15 are the same +// ** as 8 through 11 respectively. +// ** +// ** This routine runs in linear time to validate text and when doing strict +// ** JSONB validation. Superficial JSONB validation is constant time, +// ** assuming the BLOB is already in memory. The performance advantage +// ** of superficial JSONB validation is why that option is provided. +// ** Application developers can choose to do fast superficial validation or +// ** slower strict validation, according to their specific needs. +// ** +// ** Only the lower four bits of the FLAGS argument are currently used. +// ** Higher bits are reserved for future expansion. To facilitate +// ** compatibility, the current implementation raises an error if any bit +// ** in FLAGS is set other than the lower four bits. +// ** +// ** The original circa 2015 implementation of the JSON routines in +// ** SQLite only supported canonical RFC-8259 JSON text and the json_valid() +// ** function only accepted one argument. That is why the default value +// ** for the FLAGS argument is 1, since FLAGS=1 causes this routine to only +// ** recognize canonical RFC-8259 JSON text as valid. The extra FLAGS +// ** argument was added when the JSON routines were extended to support +// ** JSON5-like extensions and binary JSONB stored in BLOBs. +// ** +// ** Return Values: +// ** +// ** * Raise an error if FLAGS is outside the range of 1 to 15. +// ** * Return NULL if the input is NULL +// ** * Return 1 if the input is well-formed. +// ** * Return 0 if the input is not well-formed. +// */ +func _jsonValidFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var f Ti64 + var flags, res Tu8 + var p uintptr + var _ /* px at bp+72 */ TJsonParse + var _ /* py at bp+0 */ TJsonParse + _, _, _, _ = f, flags, p, res /* The parse */ + flags = uint8(1) + res = uint8(0) + if argc == int32(2) { + f = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if f < int64(1) || f > int64(15) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+27119, -int32(1)) + return + } + flags = libc.Uint8FromInt64(f & int64(0x0f)) + } + switch Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_NULL): + return + case int32(SQLITE_BLOB): + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + if _jsonArgIsJsonb(tls, **(**uintptr)(__ccgo_up(argv)), bp) != 0 { + if libc.Int32FromUint8(flags)&int32(0x04) != 0 { + /* Superficial checking only - accomplished by the + ** jsonArgIsJsonb() call above. */ + res = uint8(1) + } else { + if libc.Int32FromUint8(flags)&int32(0x08) != 0 { + /* Strict checking. Check by translating BLOB->TEXT->BLOB. If + ** no errors occur, call that a "strict check". */ + res = libc.BoolUint8(uint32(0) == _jsonbValidityCheck(tls, bp, uint32(0), (**(**TJsonParse)(__ccgo_up(bp))).FnBlob, uint32(1))) + } + } + break + } + /* Fall through into interpreting the input as text. See note + ** above at tag-20240123-a. */ + fallthrough + default: + if libc.Int32FromUint8(flags)&int32(0x3) == 0 { + break + } + libc.X__builtin___memset_chk(tls, bp+72, 0, uint64(72), ^t__predefined_size_t(0)) + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(JSON_KEEPERROR)) + if p != 0 { + if (*TJsonParse)(unsafe.Pointer(p)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, ctx) + } else { + if (*TJsonParse)(unsafe.Pointer(p)).FnErr != 0 { + /* no-op */ + } else { + if libc.Int32FromUint8(flags)&int32(0x02) != 0 || libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(p)).FhasNonstd) == 0 { + res = uint8(1) + } + } + } + _jsonParseFree(tls, p) + } else { + Xsqlite3_result_error_nomem(tls, ctx) + } + break + } + Xsqlite3_result_int(tls, ctx, libc.Int32FromUint8(res)) +} + +// C documentation +// +// /* +// ** Report the wrong number of arguments for json_insert(), json_replace() +// ** or json_set(). +// */ +func _jsonWrongNumArgs(tls *libc.TLS, pCtx uintptr, zFuncName uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var zMsg uintptr + _ = zMsg + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26830, libc.VaList(bp+8, zFuncName)) + Xsqlite3_result_error(tls, pCtx, zMsg, -int32(1)) + Xsqlite3_free(tls, zMsg) +} + +/**************************************************************************** +** Utility routines for dealing with the binary BLOB representation of JSON +****************************************************************************/ + +// C documentation +// +// /* Human-readable names for the JSONB values. The index for each +// ** string must correspond to the JSONB_* integer above. +// */ +var _jsonbType = [17]uintptr{ + 0: __ccgo_ts + 1688, + 1: __ccgo_ts + 8522, + 2: __ccgo_ts + 8527, + 3: __ccgo_ts + 6836, + 4: __ccgo_ts + 6836, + 5: __ccgo_ts + 6831, + 6: __ccgo_ts + 6831, + 7: __ccgo_ts + 8831, + 8: __ccgo_ts + 8831, + 9: __ccgo_ts + 8831, + 10: __ccgo_ts + 8831, + 11: __ccgo_ts + 26721, + 12: __ccgo_ts + 26727, + 13: __ccgo_ts + 1702, + 14: __ccgo_ts + 1702, + 15: __ccgo_ts + 1702, + 16: __ccgo_ts + 1702, +} + +// C documentation +// +// /* +// ** Check a single element of the JSONB in pParse for validity. +// ** +// ** The element to be checked starts at offset i and must end at on the +// ** last byte before iEnd. +// ** +// ** Return 0 if everything is correct. Return the 1-based byte offset of the +// ** error if a problem is detected. (In other words, if the error is at offset +// ** 0, return 1). +// */ +func _jsonbValidityCheck(tls *libc.TLS, pParse uintptr, i Tu32, iEnd Tu32, iDepth Tu32) (r Tu32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var cnt, j, k, n, sub, sub1, szC Tu32 + var seen, x Tu8 + var z uintptr + var v1 uint32 + var _ /* c at bp+4 */ Tu32 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _ = cnt, j, k, n, seen, sub, sub1, szC, x, z, v1 + if iDepth > uint32(JSON_MAX_DEPTH) { + return i + uint32(1) + } + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + return i + uint32(1) + } /* Checked by caller */ + if i+n+**(**Tu32)(__ccgo_up(bp)) != iEnd { + return i + uint32(1) + } /* Checked by caller */ + z = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(i)))) & int32(0x0f)) + switch libc.Int32FromUint8(x) { + case JSONB_NULL: + fallthrough + case int32(JSONB_TRUE): + fallthrough + case int32(JSONB_FALSE): + if n+**(**Tu32)(__ccgo_up(bp)) == uint32(1) { + v1 = uint32(0) + } else { + v1 = i + uint32(1) + } + return v1 + case int32(JSONB_INT): + if **(**Tu32)(__ccgo_up(bp)) < uint32(1) { + return i + uint32(1) + } + j = i + n + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') { + j = j + 1 + if **(**Tu32)(__ccgo_up(bp)) < uint32(2) { + return i + uint32(1) + } + } + k = i + n + **(**Tu32)(__ccgo_up(bp)) + for j < k { + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x04) != 0 { + j = j + 1 + } else { + return j + uint32(1) + } + } + return uint32(0) + case int32(JSONB_INT5): + if **(**Tu32)(__ccgo_up(bp)) < uint32(3) { + return i + uint32(1) + } + j = i + n + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') { + if **(**Tu32)(__ccgo_up(bp)) < uint32(4) { + return i + uint32(1) + } + j = j + 1 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('0') { + return i + uint32(1) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('x') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('X') { + return j + uint32(2) + } + j = j + uint32(2) + k = i + n + **(**Tu32)(__ccgo_up(bp)) + for j < k { + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x08) != 0 { + j = j + 1 + } else { + return j + uint32(1) + } + } + return uint32(0) + case int32(JSONB_FLOAT): + fallthrough + case int32(JSONB_FLOAT5): + seen = uint8(0) /* 0: initial. 1: '.' seen 2: 'e' seen */ + if **(**Tu32)(__ccgo_up(bp)) < uint32(2) { + return i + uint32(1) + } + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') { + j = j + 1 + if **(**Tu32)(__ccgo_up(bp)) < uint32(3) { + return i + uint32(1) + } + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('.') { + if libc.Int32FromUint8(x) == int32(JSONB_FLOAT) { + return j + uint32(1) + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))])&libc.Int32FromInt32(0x04) != 0) { + return j + uint32(1) + } + j = j + uint32(2) + seen = uint8(1) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('0') && libc.Int32FromUint8(x) == int32(JSONB_FLOAT) { + if j+uint32(3) > k { + return j + uint32(1) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('.') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('e') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('E') { + return j + uint32(1) + } + j = j + 1 + } + } + for { + if !(j < k) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x04) != 0 { + goto _2 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('.') { + if libc.Int32FromUint8(seen) > 0 { + return j + uint32(1) + } + if libc.Int32FromUint8(x) == int32(JSONB_FLOAT) && (j == k-uint32(1) || !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))])&libc.Int32FromInt32(0x04) != 0)) { + return j + uint32(1) + } + seen = uint8(1) + goto _2 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('e') || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('E') { + if libc.Int32FromUint8(seen) == int32(2) { + return j + uint32(1) + } + if j == k-uint32(1) { + return j + uint32(1) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('+') || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('-') { + j = j + 1 + if j == k-uint32(1) { + return j + uint32(1) + } + } + seen = uint8(2) + goto _2 + } + return j + uint32(1) + goto _2 + _2: + ; + j = j + 1 + } + if libc.Int32FromUint8(seen) == 0 { + return i + uint32(1) + } + return uint32(0) + case int32(JSONB_TEXT): + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + for j < k { + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(j)))] != 0) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\'') { + return j + uint32(1) + } + j = j + 1 + } + return uint32(0) + case int32(JSONB_TEXTJ): + fallthrough + case int32(JSONB_TEXT5): + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + for j < k { + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(j)))] != 0) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\'') { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('"') { + if libc.Int32FromUint8(x) == int32(JSONB_TEXTJ) { + return j + uint32(1) + } + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) <= int32(0x1f) { + /* Control characters in JSON5 string literals are ok */ + if libc.Int32FromUint8(x) == int32(JSONB_TEXTJ) { + return j + uint32(1) + } + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\\') || j+uint32(1) >= k { + return j + uint32(1) + } else { + if libc.Xstrchr(tls, __ccgo_ts+26873, libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1)))))) != uintptr(0) { + j = j + 1 + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('u') { + if j+uint32(5) >= k { + return j + uint32(1) + } + if !(_jsonIs4Hex(tls, z+uintptr(j+uint32(2))) != 0) { + return j + uint32(1) + } + j = j + 1 + } else { + if libc.Int32FromUint8(x) != int32(JSONB_TEXT5) { + return j + uint32(1) + } else { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) + szC = _jsonUnescapeOneChar(tls, z+uintptr(j), k-j, bp+4) + if **(**Tu32)(__ccgo_up(bp + 4)) == uint32(JSON_INVALID_CHAR) { + return j + uint32(1) + } + j = j + (szC - uint32(1)) + } + } + } + } + } + } + } + j = j + 1 + } + return uint32(0) + case int32(JSONB_TEXTRAW): + return uint32(0) + case int32(JSONB_ARRAY): + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + for j < k { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return j + uint32(1) + } + if j+n+**(**Tu32)(__ccgo_up(bp)) > k { + return j + uint32(1) + } + sub = _jsonbValidityCheck(tls, pParse, j, j+n+**(**Tu32)(__ccgo_up(bp)), iDepth+uint32(1)) + if sub != 0 { + return sub + } + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + return uint32(0) + case int32(JSONB_OBJECT): + cnt = uint32(0) + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + for j < k { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return j + uint32(1) + } + if j+n+**(**Tu32)(__ccgo_up(bp)) > k { + return j + uint32(1) + } + if cnt&uint32(1) == uint32(0) { + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) & int32(0x0f)) + if libc.Int32FromUint8(x) < int32(JSONB_TEXT) || libc.Int32FromUint8(x) > int32(JSONB_TEXTRAW) { + return j + uint32(1) + } + } + sub1 = _jsonbValidityCheck(tls, pParse, j, j+n+**(**Tu32)(__ccgo_up(bp)), iDepth+uint32(1)) + if sub1 != 0 { + return sub1 + } + cnt = cnt + 1 + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + if cnt&uint32(1) != uint32(0) { + return j + uint32(1) + } + return uint32(0) + default: + return i + uint32(1) + } + return r +} + +const _kGUARD_EXC_CV_NOTIFICATION_PORT_REQ = 1048584 + +const _kGUARD_EXC_DESCRIPTOR_VIOLATION = 67 + +const _kGUARD_EXC_DESTROY = 1 + +const _kGUARD_EXC_EXCEPTION_BEHAVIOR_ENFORCE = 6 + +const _kGUARD_EXC_IMMOVABLE = 32 + +const _kGUARD_EXC_IMMOVABLE_NON_FATAL = 4194304 + +const _kGUARD_EXC_INCORRECT_GUARD = 16 + +const _kGUARD_EXC_INVALID_ARGUMENT = 2048 + +const _kGUARD_EXC_INVALID_MPO_ENTITLEMENT = 66 + +const _kGUARD_EXC_INVALID_NAME = 512 + +const _kGUARD_EXC_INVALID_NOTIFICATION_PORT = 1048582 + +const _kGUARD_EXC_INVALID_NOTIFICATION_REQ = 65 + +const _kGUARD_EXC_INVALID_OPTIONS = 3 + +const _kGUARD_EXC_INVALID_RIGHT = 256 + +const _kGUARD_EXC_INVALID_VALUE = 1024 + +const _kGUARD_EXC_KERN_FAILURE = 16384 + +const _kGUARD_EXC_KERN_NO_SPACE = 8192 + +const _kGUARD_EXC_KERN_RESOURCE = 32768 + +const _kGUARD_EXC_KOBJECT_REPLY_PORT_SEMANTICS = 9 + +const _kGUARD_EXC_MACH_EXC_THREAD_SET_STATE = 1048583 + +const _kGUARD_EXC_MOD_REFS = 2 + +const _kGUARD_EXC_MOD_REFS_NON_FATAL = 2097152 + +const _kGUARD_EXC_MOVE_WEAK_REPLY_PORT = 1048580 + +const _kGUARD_EXC_MSG_FILTERED = 128 + +const _kGUARD_EXC_NONE = 0 + +const _kGUARD_EXC_OOL_PORT_ARRAY_CREATION = 1048579 + +const _kGUARD_EXC_RCV_GUARDED_DESC = 1048576 + +const _kGUARD_EXC_RCV_INVALID_NAME = 524288 + +const _kGUARD_EXC_REPLY_PORT_SINGLE_SO_RIGHT = 1048581 + +const _kGUARD_EXC_REQUIRE_REPLY_PORT_SEMANTICS = 10 + +const _kGUARD_EXC_RIGHT_EXISTS = 4096 + +const _kGUARD_EXC_SEND_INVALID_REPLY = 65536 + +const _kGUARD_EXC_SEND_INVALID_RIGHT = 262144 + +const _kGUARD_EXC_SEND_INVALID_VOUCHER = 131072 + +const _kGUARD_EXC_SERVICE_PORT_VIOLATION_FATAL = 7 + +const _kGUARD_EXC_SERVICE_PORT_VIOLATION_NON_FATAL = 1048577 + +const _kGUARD_EXC_SET_CONTEXT = 4 + +const _kGUARD_EXC_STRICT_REPLY = 64 + +const _kGUARD_EXC_THREAD_SET_STATE = 5 + +const _kGUARD_EXC_UNGUARDED = 8 + +const _kGUARD_EXC_WEAK_REPLY_PORT = 1048578 + +// C documentation +// +// /* +// ** Implementation of the like() SQL function. This function implements +// ** the built-in LIKE operator. The first argument to the function is the +// ** pattern and the second argument is the string. So, the SQL statements: +// ** +// ** A LIKE B +// ** +// ** is implemented as like(B,A). +// ** +// ** This same function (with a different compareInfo structure) computes +// ** the GLOB operator. +// */ +func _likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pInfo, zA, zB uintptr + var escape Tu32 + var nPat int32 + var _ /* backupInfo at bp+0 */ TcompareInfo + var _ /* zEsc at bp+8 */ uintptr + _, _, _, _, _, _ = db, escape, nPat, pInfo, zA, zB + db = Xsqlite3_context_db_handle(tls, context) + pInfo = Xsqlite3_user_data(tls, context) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_BLOB) || Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) == int32(SQLITE_BLOB) { + Xsqlite3_result_int(tls, context, 0) + return + } + /* Limit the length of the LIKE or GLOB pattern to avoid problems + ** of deep recursion and N*N behavior in patternCompare(). + */ + nPat = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if nPat > **(**int32)(__ccgo_up(db + 136 + 8*4)) { + Xsqlite3_result_error(tls, context, __ccgo_ts+16825, -int32(1)) + return + } + if argc == int32(3) { + /* The escape character string must consist of a single UTF-8 character. + ** Otherwise, return an error. + */ + **(**uintptr)(__ccgo_up(bp + 8)) = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + if **(**uintptr)(__ccgo_up(bp + 8)) == uintptr(0) { + return + } + if _sqlite3Utf8CharLen(tls, **(**uintptr)(__ccgo_up(bp + 8)), -int32(1)) != int32(1) { + Xsqlite3_result_error(tls, context, __ccgo_ts+16858, -int32(1)) + return + } + escape = _sqlite3Utf8Read(tls, bp+8) + if escape == uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchAll) || escape == uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchOne) { + libc.X__builtin___memcpy_chk(tls, bp, pInfo, uint64(4), ^t__predefined_size_t(0)) + pInfo = bp + if escape == uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchAll) { + (*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchAll = uint8(0) + } + if escape == uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchOne) { + (*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchOne = uint8(0) + } + } + } else { + escape = uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchSet) + } + zB = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zA = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zA != 0 && zB != 0 { + Xsqlite3_result_int(tls, context, libc.BoolInt32(_patternCompare(tls, zB, zA, pInfo, escape) == SQLITE_MATCH)) + } +} + +// C documentation +// +// /* +// ** A function that loads a shared-library extension then returns NULL. +// */ +func _loadExt(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, zFile, zProc uintptr + var _ /* zErrMsg at bp+0 */ uintptr + _, _, _ = db, zFile, zProc + zFile = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + db = Xsqlite3_context_db_handle(tls, context) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + /* Disallow the load_extension() SQL function unless the SQLITE_LoadExtFunc + ** flag is set. See the sqlite3_enable_load_extension() API. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LoadExtFunc) == uint64(0) { + Xsqlite3_result_error(tls, context, __ccgo_ts+14015, -int32(1)) + return + } + if argc == int32(2) { + zProc = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + zProc = uintptr(0) + } + if zFile != 0 && Xsqlite3_load_extension(tls, db, zFile, zProc, bp) != 0 { + Xsqlite3_result_error(tls, context, **(**uintptr)(__ccgo_up(bp)), -int32(1)) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + } +} + +// C documentation +// +// /* +// ** Load content from the sqlite_stat4 table into +// ** the Index.aSample[] arrays of all indices. +// */ +func _loadStat4(tls *libc.TLS, db uintptr, zDb uintptr) (r int32) { + var pStat4, v1 uintptr + var rc int32 + var v2 bool + _, _, _, _ = pStat4, rc, v1, v2 + rc = SQLITE_OK + if v2 = (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0); v2 { + v1 = _sqlite3FindTable(tls, db, __ccgo_ts+13203, zDb) + pStat4 = v1 + } + if v2 && v1 != uintptr(0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pStat4)).FeTabType) == TABTYP_NORM { + rc = _loadStatTbl(tls, db, __ccgo_ts+13429, __ccgo_ts+13498, zDb) + } + return rc +} + +// C documentation +// +// /* +// ** Load the content from either the sqlite_stat4 +// ** into the relevant Index.aSample[] arrays. +// ** +// ** Arguments zSql1 and zSql2 must point to SQL statements that return +// ** data equivalent to the following: +// ** +// ** zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx +// ** zSql2: SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4 +// ** +// ** where %Q is replaced with the database name before the SQL is executed. +// */ +func _loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, nByte Ti64 + var nCol, nIdxCol, nSample, rc int32 + var pIdx, pIdx1, pPrevIdx, pPtr, pSample, pSpace, zIndex, zIndex1, zSql uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, nByte, nCol, nIdxCol, nSample, pIdx, pIdx1, pPrevIdx, pPtr, pSample, pSpace, rc, zIndex, zIndex1, zSql /* Result codes from subroutines */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Text of the SQL statement */ + pPrevIdx = uintptr(0) /* A slot in pIdx->aSample[] */ + zSql = _sqlite3MPrintf(tls, db, zSql1, libc.VaList(bp+16, zDb)) + if !(zSql != 0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_prepare(tls, db, zSql, -int32(1), bp, uintptr(0)) + _sqlite3DbFree(tls, db, zSql) + if rc != 0 { + return rc + } + for Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { + nIdxCol = int32(1) /* Available memory as a u8 for easier manipulation */ + zIndex = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + if zIndex == uintptr(0) { + continue + } + nSample = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + pIdx = _findIndexOrPrimaryKey(tls, db, zIndex, zDb) + if pIdx == uintptr(0) { + continue + } + if (*TIndex)(unsafe.Pointer(pIdx)).FaSample != uintptr(0) { + /* The same index appears in sqlite_stat4 under multiple names */ + continue + } + if !((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + nIdxCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + } else { + nIdxCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } + (*TIndex)(unsafe.Pointer(pIdx)).FnSampleCol = nIdxCol + (*TIndex)(unsafe.Pointer(pIdx)).FmxSample = nSample + nByte = libc.Int64FromUint64((libc.Uint64FromInt64(40)*libc.Uint64FromInt32(nSample) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(nIdxCol)*libc.Uint64FromInt32(3)*libc.Uint64FromInt32(nSample))) + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Uint64FromInt32(nIdxCol)*libc.Uint64FromInt64(8))) /* Space for Index.aAvgEq[] */ + (*TIndex)(unsafe.Pointer(pIdx)).FaSample = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte)) + if (*TIndex)(unsafe.Pointer(pIdx)).FaSample == uintptr(0) { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return int32(SQLITE_NOMEM) + } + pPtr = (*TIndex)(unsafe.Pointer(pIdx)).FaSample + pPtr = pPtr + uintptr((libc.Uint64FromInt32(nSample)*libc.Uint64FromInt64(40)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + pSpace = pPtr + (*TIndex)(unsafe.Pointer(pIdx)).FaAvgEq = pSpace + pSpace = pSpace + uintptr(nIdxCol)*8 + **(**Tu32)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FpTable + 48)) |= uint32(TF_HasStat4) + i = 0 + for { + if !(i < int64(nSample)) { + break + } + (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*40))).FanEq = pSpace + pSpace = pSpace + uintptr(nIdxCol)*8 + (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*40))).FanLt = pSpace + pSpace = pSpace + uintptr(nIdxCol)*8 + (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*40))).FanDLt = pSpace + pSpace = pSpace + uintptr(nIdxCol)*8 + goto _1 + _1: + ; + i = i + 1 + } + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc != 0 { + return rc + } + zSql = _sqlite3MPrintf(tls, db, zSql2, libc.VaList(bp+16, zDb)) + if !(zSql != 0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_prepare(tls, db, zSql, -int32(1), bp, uintptr(0)) + _sqlite3DbFree(tls, db, zSql) + if rc != 0 { + return rc + } + for Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { /* Pointer to the index object */ + nCol = int32(1) /* Number of columns in index */ + zIndex1 = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + if zIndex1 == uintptr(0) { + continue + } + pIdx1 = _findIndexOrPrimaryKey(tls, db, zIndex1, zDb) + if pIdx1 == uintptr(0) { + continue + } + if (*TIndex)(unsafe.Pointer(pIdx1)).FnSample >= (*TIndex)(unsafe.Pointer(pIdx1)).FmxSample { + /* Too many slots used because the same index appears in + ** sqlite_stat4 using multiple names */ + continue + } + /* This next condition is true if data has already been loaded from + ** the sqlite_stat4 table. */ + nCol = (*TIndex)(unsafe.Pointer(pIdx1)).FnSampleCol + if pIdx1 != pPrevIdx { + _initAvgEq(tls, pPrevIdx) + pPrevIdx = pIdx1 + } + pSample = (*TIndex)(unsafe.Pointer(pIdx1)).FaSample + uintptr((*TIndex)(unsafe.Pointer(pIdx1)).FnSample)*40 + _decodeIntArray(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)), nCol, (*TIndexSample)(unsafe.Pointer(pSample)).FanEq, uintptr(0), uintptr(0)) + _decodeIntArray(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(2)), nCol, (*TIndexSample)(unsafe.Pointer(pSample)).FanLt, uintptr(0), uintptr(0)) + _decodeIntArray(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)), nCol, (*TIndexSample)(unsafe.Pointer(pSample)).FanDLt, uintptr(0), uintptr(0)) + /* Take a copy of the sample. Add 8 extra 0x00 bytes the end of the buffer. + ** This is in case the sample record is corrupted. In that case, the + ** sqlite3VdbeRecordCompare() may read up to two varints past the + ** end of the allocated buffer before it realizes it is dealing with + ** a corrupt record. Or it might try to read a large integer from the + ** buffer. In any case, eight 0x00 bytes prevents this from causing + ** a buffer overread. */ + (*TIndexSample)(unsafe.Pointer(pSample)).Fn = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + (*TIndexSample)(unsafe.Pointer(pSample)).Fp = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt32((*TIndexSample)(unsafe.Pointer(pSample)).Fn+int32(8))) + if (*TIndexSample)(unsafe.Pointer(pSample)).Fp == uintptr(0) { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return int32(SQLITE_NOMEM) + } + if (*TIndexSample)(unsafe.Pointer(pSample)).Fn != 0 { + libc.X__builtin___memcpy_chk(tls, (*TIndexSample)(unsafe.Pointer(pSample)).Fp, Xsqlite3_column_blob(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)), libc.Uint64FromInt32((*TIndexSample)(unsafe.Pointer(pSample)).Fn), ^t__predefined_size_t(0)) + } + (*TIndex)(unsafe.Pointer(pIdx1)).FnSample = (*TIndex)(unsafe.Pointer(pIdx1)).FnSample + 1 + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + _initAvgEq(tls, pPrevIdx) + } + return rc +} + +// C documentation +// +// /* +// ** Get a reference to pPage1 of the database file. This will +// ** also acquire a readlock on that file. +// ** +// ** SQLITE_OK is returned on success. If the file is not a +// ** well-formed database file, then SQLITE_CORRUPT is returned. +// ** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM +// ** is returned if we run out of memory. +// */ +func _lockBtree(tls *libc.TLS, pBt uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nPage, pageSize, usableSize Tu32 + var page1, v1 uintptr + var rc, v4 int32 + var _ /* isOpen at bp+12 */ int32 + var _ /* nPageFile at bp+8 */ Tu32 + var _ /* pPage1 at bp+0 */ uintptr + _, _, _, _, _, _, _ = nPage, page1, pageSize, rc, usableSize, v1, v4 /* Number of pages in the database */ + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(0) /* Number of pages in the database file */ + rc = _sqlite3PagerSharedLock(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + if rc != SQLITE_OK { + return rc + } + rc = _btreeGetPage(tls, pBt, uint32(1), bp, 0) + if rc != SQLITE_OK { + return rc + } + /* Do some checking to help insure the file we opened really is + ** a valid database file. + */ + nPage = _sqlite3Get4byte(tls, uintptr(28)+(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData) + _sqlite3PagerPagecount(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, bp+8) + if nPage == uint32(0) || libc.Xmemcmp(tls, uintptr(24)+(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uintptr(92)+(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4)) != 0 { + nPage = **(**Tu32)(__ccgo_up(bp + 8)) + } + if (*Tsqlite3)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags&uint64(SQLITE_ResetDatabase) != uint64(0) { + nPage = uint32(0) + } + if nPage > uint32(0) { + page1 = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData + rc = int32(SQLITE_NOTADB) + /* EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins + ** with the following 16 bytes (in hex): 53 51 4c 69 74 65 20 66 6f 72 6d + ** 61 74 20 33 00. */ + if libc.Xmemcmp(tls, page1, uintptr(unsafe.Pointer(&_zMagicHeader)), uint64(16)) != 0 { + goto page1_init_failed + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(page1 + 18))) > int32(2) { + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_READ_ONLY)) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(page1 + 19))) > int32(2) { + goto page1_init_failed + } + /* If the read version is set to 2, this database should be accessed + ** in WAL mode. If the log is not already open, open it now. Then + ** return SQLITE_OK and return without populating BtShared.pPage1. + ** The caller detects this and calls this function again. This is + ** required as the version of page 1 currently in the page1 buffer + ** may not be the latest version - there may be a newer one in the log + ** file. + */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(page1 + 19))) == int32(2) && libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_NO_WAL) == 0 { + **(**int32)(__ccgo_up(bp + 12)) = 0 + rc = _sqlite3PagerOpenWal(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, bp+12) + if rc != SQLITE_OK { + goto page1_init_failed + } else { + if **(**int32)(__ccgo_up(bp + 12)) == 0 { + _releasePageOne(tls, **(**uintptr)(__ccgo_up(bp))) + return SQLITE_OK + } + } + rc = int32(SQLITE_NOTADB) + } else { + } + /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload + ** fractions and the leaf payload fraction values must be 64, 32, and 32. + ** + ** The original design allowed these amounts to vary, but as of + ** version 3.6.0, we require them to be fixed. + */ + if libc.Xmemcmp(tls, page1+21, __ccgo_ts+4692, uint64(3)) != 0 { + goto page1_init_failed + } + /* EVIDENCE-OF: R-51873-39618 The page size for a database file is + ** determined by the 2-byte integer located at an offset of 16 bytes from + ** the beginning of the database file. */ + pageSize = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(page1 + 16)))< uint32(SQLITE_MAX_PAGE_SIZE) || pageSize <= uint32(256) { + goto page1_init_failed + } + /* EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte + ** integer at offset 20 is the number of bytes of space at the end of + ** each page to reserve for extensions. + ** + ** EVIDENCE-OF: R-37497-42412 The size of the reserved region is + ** determined by the one-byte unsigned integer found at an offset of 20 + ** into the database file header. */ + usableSize = pageSize - uint32(**(**Tu8)(__ccgo_up(page1 + 20))) + if pageSize != (*TBtShared)(unsafe.Pointer(pBt)).FpageSize { + /* After reading the first page of the database assuming a page size + ** of BtShared.pageSize, we have discovered that the page-size is + ** actually pageSize. Unlock the database, leave pBt->pPage1 at + ** zero and return SQLITE_OK. The caller will call this function + ** again with the correct page-size. + */ + _releasePageOne(tls, **(**uintptr)(__ccgo_up(bp))) + (*TBtShared)(unsafe.Pointer(pBt)).FusableSize = usableSize + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = pageSize + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + _freeTempSpace(tls, pBt) + rc = _sqlite3PagerSetPagesize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pBt+52, libc.Int32FromUint32(pageSize-usableSize)) + return rc + } + if nPage > **(**Tu32)(__ccgo_up(bp + 8)) { + if _sqlite3WritableSchema(tls, (*TBtShared)(unsafe.Pointer(pBt)).Fdb) == 0 { + rc = _sqlite3CorruptError(tls, int32(76544)) + goto page1_init_failed + } else { + nPage = **(**Tu32)(__ccgo_up(bp + 8)) + } + } + /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to + ** be less than 480. In other words, if the page size is 512, then the + ** reserved space size cannot exceed 32. */ + if usableSize < uint32(480) { + goto page1_init_failed + } + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = pageSize + (*TBtShared)(unsafe.Pointer(pBt)).FusableSize = usableSize + if _sqlite3Get4byte(tls, page1+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(4)*libc.Int32FromInt32(4))) != 0 { + v4 = int32(1) + } else { + v4 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(v4) + if _sqlite3Get4byte(tls, page1+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(7)*libc.Int32FromInt32(4))) != 0 { + v4 = int32(1) + } else { + v4 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(v4) + } + /* maxLocal is the maximum amount of payload to store locally for + ** a cell. Make sure it is small enough so that at least minFanout + ** cells can will fit on one page. We assume a 10-byte page header. + ** Besides the payload, the cell must store: + ** 2-byte pointer to the cell + ** 4-byte child pointer + ** 9-byte nKey value + ** 4-byte nData value + ** 4-byte overflow page pointer + ** So a cell consists of a 2-byte pointer, a header which is as much as + ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow + ** page pointer. + */ + (*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal = uint16(((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(12))*libc.Uint32FromInt32(64)/libc.Uint32FromInt32(255) - libc.Uint32FromInt32(23)) + (*TBtShared)(unsafe.Pointer(pBt)).FminLocal = uint16(((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(12))*libc.Uint32FromInt32(32)/libc.Uint32FromInt32(255) - libc.Uint32FromInt32(23)) + (*TBtShared)(unsafe.Pointer(pBt)).FmaxLeaf = uint16((*TBtShared)(unsafe.Pointer(pBt)).FusableSize - libc.Uint32FromInt32(35)) + (*TBtShared)(unsafe.Pointer(pBt)).FminLeaf = uint16(((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(12))*libc.Uint32FromInt32(32)/libc.Uint32FromInt32(255) - libc.Uint32FromInt32(23)) + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal) > int32(127) { + (*TBtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload = uint8(127) + } else { + (*TBtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload = uint8((*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal) + } + (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 = **(**uintptr)(__ccgo_up(bp)) + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = nPage + return SQLITE_OK + goto page1_init_failed +page1_init_failed: + ; + _releasePageOne(tls, **(**uintptr)(__ccgo_up(bp))) + (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0) + return rc +} + +// C documentation +// +// /* +// ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up +// ** that name in the set of source tables in pSrcList and make the pExpr +// ** expression node refer back to that source column. The following changes +// ** are made to pExpr: +// ** +// ** pExpr->iDb Set the index in db->aDb[] of the database X +// ** (even if X is implied). +// ** pExpr->iTable Set to the cursor number for the table obtained +// ** from pSrcList. +// ** pExpr->y.pTab Points to the Table structure of X.Y (even if +// ** X and/or Y are implied.) +// ** pExpr->iColumn Set to the column number within the table. +// ** pExpr->op Set to TK_COLUMN. +// ** pExpr->pLeft Any expression this points to is deleted +// ** pExpr->pRight Any expression this points to is deleted. +// ** +// ** The zDb variable is the name of the database (the "X"). This value may be +// ** NULL meaning that name is of the form Y.Z or Z. Any available database +// ** can be used. The zTable variable is the name of the table (the "Y"). This +// ** value can be NULL if zDb is also NULL. If zTable is NULL it +// ** means that the form of the name is Z and that columns from any table +// ** can be used. +// ** +// ** If the name cannot be resolved unambiguously, leave an error message +// ** in pParse and return WRC_Abort. Return WRC_Prune on success. +// */ +func _lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, pRight uintptr, pNC uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var cnt, cntTab, eNewExprOp, hit, i, iCol, j, nSubquery, op, v4 int32 + var db, pEList, pItem, pMatch, pOrig, pSchema, pSel, pSrcList, pTab, pTopNC, pUpsert, zAs, zCol, zErr, v8 uintptr + var v5 uint32 + var _ /* bRowid at bp+8 */ int32 + var _ /* pFJMatch at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cnt, cntTab, db, eNewExprOp, hit, i, iCol, j, nSubquery, op, pEList, pItem, pMatch, pOrig, pSchema, pSel, pSrcList, pTab, pTopNC, pUpsert, zAs, zCol, zErr, v4, v5, v8 /* Loop counters */ + cnt = 0 /* Number of matching column names */ + cntTab = 0 /* Number of potential "rowid" matches */ + nSubquery = 0 /* How many levels of subquery */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Use for looping over pSrcList items */ + pMatch = uintptr(0) /* The matching pSrcList item */ + pTopNC = pNC /* First namecontext in the list */ + pSchema = uintptr(0) /* Schema of the expression */ + eNewExprOp = int32(TK_COLUMN) /* New value for pExpr->op on success */ + pTab = uintptr(0) /* Table holding the row */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Matches for FULL JOIN .. USING */ + zCol = *(*uintptr)(unsafe.Pointer(pRight + 8)) + /* the name context cannot be NULL. */ + /* The Z in X.Y.Z cannot be NULL */ + /* Initialize the node to no-match */ + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = -int32(1) + /* Translate the schema name in zDb into a pointer to the corresponding + ** schema. If not found, pSchema will remain NULL and nothing will match + ** resulting in an appropriate error message toward the end of this routine + */ + if zDb != 0 { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_IsCheck)) != 0 { + /* Silently ignore database qualifiers inside CHECK constraints and + ** partial indices. Do not raise errors because that might break + ** legacy and because it does not hurt anything to just ignore the + ** database name. */ + zDb = uintptr(0) + } else { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if _sqlite3StrICmp(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName, zDb) == 0 { + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i == (*Tsqlite3)(unsafe.Pointer(db)).FnDb && _sqlite3StrICmp(tls, __ccgo_ts+7160, zDb) == 0 { + /* This branch is taken when the main database has been renamed + ** using SQLITE_DBCONFIG_MAINDBNAME. */ + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName + } + } + } + /* Start at the inner-most context and move outward until a match is found */ + for cond := true; cond; cond = pNC != 0 { + pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + if pSrcList != 0 { + i = 0 + pItem = pSrcList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc) { + break + } + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { + /* In this case, pItem is a subquery that has been formed from a + ** parenthesized subset of the FROM clause terms. Example: + ** .... FROM t1 LEFT JOIN (t2 RIGHT JOIN t3 USING(x)) USING(y) ... + ** \_________________________/ + ** This pItem -------------^ + */ + hit = 0 + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + pEList = (*TSelect)(unsafe.Pointer(pSel)).FpEList + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + **(**int32)(__ccgo_up(bp + 8)) = 0 /* True if possible rowid match */ + if !(_sqlite3MatchEName(tls, pEList+8+uintptr(j)*32, zCol, zTab, zDb, bp+8) != 0) { + goto _3 + } + if **(**int32)(__ccgo_up(bp + 8)) == 0 { + if cnt > 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 64)), zCol) < 0 || pMatch == pItem { + /* Two or more tables have the same column name which is + ** not joined by USING. Or, a single table has two columns + ** that match a USING term (if pMatch==pItem). These are both + ** "ambiguous column name" errors. Signal as much by clearing + ** pFJMatch and letting cnt go above 1. */ + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + /* An INNER or LEFT JOIN. Use the left-most table */ + goto _3 + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) == 0 { + /* A RIGHT JOIN. Use the right-most table */ + cnt = 0 + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + /* For a FULL JOIN, we must construct a coalesce() func */ + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + } + } + } + } + cnt = cnt + 1 + hit = int32(1) + } else { + if cnt > 0 { + /* This is a potential rowid match, but there has already been + ** a real match found. So this can be ignored. */ + goto _3 + } + } + cntTab = cntTab + 1 + pMatch = pItem + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(j) + libc.SetBitFieldPtr16Uint32(pEList+8+uintptr(j)*32+16+4, libc.Uint32FromInt32(1), 6, 0x40) + /* rowid cannot be part of a USING clause - assert() this. */ + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 16 + 4))&0x80>>7)) != 0 { + break + } + goto _3 + _3: + ; + j = j + 1 + } + if hit != 0 || zTab == uintptr(0) { + goto _2 + } + } + if zTab != 0 { + if zDb != 0 { + if (*TTable)(unsafe.Pointer(pTab)).FpSchema != pSchema { + goto _2 + } + if pSchema == uintptr(0) && libc.Xstrcmp(tls, zDb, __ccgo_ts+7165) != 0 { + goto _2 + } + } + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != uintptr(0) { + if _sqlite3StrICmp(tls, zTab, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) != 0 { + goto _2 + } + } else { + if _sqlite3StrICmp(tls, zTab, (*TTable)(unsafe.Pointer(pTab)).FzName) != 0 { + if (*TTable)(unsafe.Pointer(pTab)).Ftnum != uint32(1) { + goto _2 + } + if !(_isValidSchemaTableName(tls, zTab, pTab, zDb) != 0) { + goto _2 + } + } + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr+64) + } + } + j = _sqlite3ColumnIndex(tls, pTab, zCol) + if j >= 0 { + if cnt > 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 64)), zCol) < 0 { + /* Two or more tables have the same column name which is + ** not joined by USING. This is an error. Signal as much + ** by clearing pFJMatch and letting cnt go above 1. */ + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + /* An INNER or LEFT JOIN. Use the left-most table */ + goto _2 + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) == 0 { + /* A RIGHT JOIN. Use the right-most table */ + cnt = 0 + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + /* For a FULL JOIN, we must construct a coalesce() func */ + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + } + } + } + } + cnt = cnt + 1 + pMatch = pItem + /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + v4 = -int32(1) + } else { + v4 = int32(int16(j)) + } + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(v4) + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { + _sqlite3SrcItemColumnUsed(tls, pItem, j) + } + } + if 0 == cnt && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) { + /* pTab is a potential ROWID match. Keep track of it and match + ** the ROWID later if that seems appropriate. (Search for "cntTab" + ** to find related code.) Only allow a ROWID match if there is + ** a single ROWID match candidate. + */ + /* The (much more common) non-SQLITE_ALLOW_ROWID_IN_VIEW case is + ** simpler since we require exactly one candidate, which will + ** always be a non-VIEW + */ + cntTab = cntTab + 1 + pMatch = pItem + } + goto _2 + _2: + ; + i = i + 1 + pItem += 80 + } + if pMatch != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSrcItem)(unsafe.Pointer(pMatch)).FiCursor + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pMatch)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + pSchema = (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpSchema + } + } /* if( pSrcList ) */ + /* If we have not already resolved the name, then maybe + ** it is a new.* or old.* trigger argument reference. Or + ** maybe it is an excluded.* from an upsert. Or maybe it is + ** a reference in the RETURNING clause to a table being modified. + */ + if cnt == 0 && zDb == uintptr(0) { + pTab = uintptr(0) + if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != uintptr(0) { + op = libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeTriggerOp) + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UBaseReg) != 0 && (zTab == uintptr(0) || _sqlite3StrICmp(tls, zTab, (*TTable)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).FpTriggerTab)).FzName) == 0 || _isValidSchemaTableName(tls, zTab, (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab, uintptr(0)) != 0) { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = libc.BoolInt32(op != int32(TK_DELETE)) + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } + } else { + if op != int32(TK_DELETE) && zTab != 0 && _sqlite3StrICmp(tls, __ccgo_ts+7167, zTab) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = int32(1) + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } else { + if op != int32(TK_INSERT) && zTab != 0 && _sqlite3StrICmp(tls, __ccgo_ts+7171, zTab) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = 0 + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } + } + } + } + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UUpsert) != 0 && zTab != uintptr(0) { + pUpsert = *(*uintptr)(unsafe.Pointer(pNC + 16)) + if pUpsert != 0 && _sqlite3StrICmp(tls, __ccgo_ts+7175, zTab) == 0 { + pTab = (*(*TSrcItem)(unsafe.Pointer((*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8))).FpSTab + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = int32(EXCLUDED_TABLE_NUMBER) + } + } + if pTab != 0 { + pSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + cntTab = cntTab + 1 + iCol = _sqlite3ColumnIndex(tls, pTab, zCol) + if iCol >= 0 { + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) == iCol { + iCol = -int32(1) + } + } else { + if _sqlite3IsRowid(tls, zCol) != 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) { + iCol = -int32(1) + } else { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } + } + if iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + cnt = cnt + 1 + pMatch = uintptr(0) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == int32(EXCLUDED_TABLE_NUMBER) { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab + eNewExprOp = int32(TK_COLUMN) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TUpsert)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNC + 16)))).FregData + int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + eNewExprOp = int32(TK_REGISTER) + } + } else { + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { + eNewExprOp = int32(TK_REGISTER) + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = uint8(TK_COLUMN) + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = *(*int32)(unsafe.Pointer(&(*TNameContext)(unsafe.Pointer(pNC)).FuNC)) + (int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1))*(*TExpr)(unsafe.Pointer(pExpr)).FiTable + int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + int32(1) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + eNewExprOp = int32(TK_TRIGGER) + if iCol < 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_INTEGER) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == 0 { + if iCol >= int32(32) { + v5 = uint32(0xffffffff) + } else { + v5 = libc.Uint32FromInt32(1) << iCol + } + **(**Tu32)(__ccgo_up(pParse + 240)) |= v5 + } else { + if iCol >= int32(32) { + v5 = uint32(0xffffffff) + } else { + v5 = libc.Uint32FromInt32(1) << iCol + } + **(**Tu32)(__ccgo_up(pParse + 244)) |= v5 + } + } + } + } + } + } + } + /* + ** Perhaps the name is a reference to the ROWID + */ + if cnt == 0 && cntTab >= int32(1) && pMatch != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) == 0 && _sqlite3IsRowid(tls, zCol) != 0 && ((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) || int32(*(*uint32)(unsafe.Pointer(pMatch + 24 + 4))&0x4000>>14) != 0) { + cnt = cntTab + if int32(*(*uint32)(unsafe.Pointer(pMatch + 24 + 4))&0x4000>>14) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(-int32(1)) + } + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_INTEGER) + } + /* + ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z + ** might refer to an result-set alias. This happens, for example, when + ** we are resolving names in the WHERE clause of the following command: + ** + ** SELECT a+b AS x FROM table WHERE x<10; + ** + ** In cases like this, replace pExpr with a copy of the expression that + ** forms the result set entry ("a+b" in the example) and return immediately. + ** Note that the expression in the result set should have already been + ** resolved by the time the WHERE clause is resolved. + ** + ** The ability to use an output result-set column in the WHERE, GROUP BY, + ** or HAVING clauses, or as part of a larger expression in the ORDER BY + ** clause is not standard SQL. This is a (goofy) SQLite extension, that + ** is supported for backwards compatibility only. Hence, we issue a warning + ** on sqlite3_log() whenever the capability is used. + */ + if cnt == 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UEList) != 0 && zTab == uintptr(0) { + pEList = *(*uintptr)(unsafe.Pointer(pNC + 16)) + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + zAs = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*32))).FzEName + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME && Xsqlite3_stricmp(tls, zAs, zCol) == 0 { + pOrig = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*32))).FpExpr + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowAgg) == 0 && (*TExpr)(unsafe.Pointer(pOrig)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Agg)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7184, libc.VaList(bp+24, zAs)) + return int32(WRC_Abort) + } + if (*TExpr)(unsafe.Pointer(pOrig)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Win)) != uint32(0) && ((*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowWin) == 0 || pNC != pTopNC) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7215, libc.VaList(bp+24, zAs)) + return int32(WRC_Abort) + } + if _sqlite3ExprVectorSize(tls, pOrig) != int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7252, 0) + return int32(WRC_Abort) + } + _resolveAlias(tls, pParse, pEList, j, pExpr, nSubquery) + cnt = int32(1) + pMatch = uintptr(0) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) + } + goto lookupname_end + } + goto _7 + _7: + ; + j = j + 1 + } + } + /* Advance to the next name context. The loop will exit when either + ** we have a match (cnt>0) or when we run out of name contexts. + */ + if cnt != 0 { + break + } + pNC = (*TNameContext)(unsafe.Pointer(pNC)).FpNext + nSubquery = nSubquery + 1 + } + /* + ** If X and Y are NULL (in other words if only the column name Z is + ** supplied) and the value of Z is enclosed in double-quotes, then + ** Z is a string literal if it doesn't match any column names. In that + ** case, we need to return right away and not make any changes to + ** pExpr. + ** + ** Because no reference was made to outer contexts, the pNC->nRef + ** fields are not changed in any context. + */ + if cnt == 0 && zTab == uintptr(0) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_DblQuoted)) != uint32(0) && _areDoubleQuotedStringsEnabled(tls, db, pTopNC) != 0 { + /* If a double-quoted identifier does not match any known column name, + ** then treat it as a string. + ** + ** This hack was added in the early days of SQLite in a misguided attempt + ** to be compatible with MySQL 3.x, which used double-quotes for strings. + ** I now sorely regret putting in this hack. The effect of this hack is + ** that misspelled identifier names are silently converted into strings + ** rather than causing an error, to the frustration of countless + ** programmers. To all those frustrated programmers, my apologies. + ** + ** Someday, I hope to get rid of this hack. Unfortunately there is + ** a huge amount of legacy SQL that uses it. So for now, we just + ** issue a warning. + */ + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+7270, libc.VaList(bp+24, zCol)) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_STRING) + libc.X__builtin___memset_chk(tls, pExpr+64, 0, uint64(8), ^t__predefined_size_t(0)) + return int32(WRC_Prune) + } + if _sqlite3ExprIdToTrueFalse(tls, pExpr) != 0 { + return int32(WRC_Prune) + } + } + /* + ** cnt==0 means there was not match. + ** cnt>1 means there were two or more matches. + ** + ** cnt==0 is always an error. cnt>1 is often an error, but might + ** be multiple matches for a NATURAL LEFT JOIN or a LEFT JOIN USING. + */ + if cnt != int32(1) { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + if (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr == cnt-int32(1) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) != uint32(0) { + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) + } else { + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) + } + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_FUNCTION) + *(*uintptr)(unsafe.Pointer(pExpr + 8)) = __ccgo_ts + 7305 + *(*uintptr)(unsafe.Pointer(pExpr + 32)) = **(**uintptr)(__ccgo_up(bp)) + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_DEFER) + cnt = int32(1) + goto lookupname_end + } else { + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + if cnt == 0 { + v8 = __ccgo_ts + 7314 + } else { + v8 = __ccgo_ts + 7329 + } + zErr = v8 + if zDb != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7351, libc.VaList(bp+24, zErr, zDb, zTab, zCol)) + } else { + if zTab != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7364, libc.VaList(bp+24, zErr, zTab, zCol)) + } else { + if cnt == 0 && (*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_DblQuoted)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7374, libc.VaList(bp+24, zErr, zCol)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7435, libc.VaList(bp+24, zErr, zCol)) + } + } + } + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + (*TNameContext)(unsafe.Pointer(pTopNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pTopNC)).FnNcErr + 1 + eNewExprOp = int32(TK_NULL) + } + /* Remove all substructure from pExpr */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)) { + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) + } + /* If a column from a table in pSrcList is referenced, then record + ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes + ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is + ** set if the 63rd or any subsequent column is used. + ** + ** The colUsed mask is an optimization used to help determine if an + ** index is a covering index. The correct answer is still obtained + ** if the mask contains extra set bits. However, it is important to + ** avoid setting bits beyond the maximum column number of the table. + ** (See ticket [b92e5e8ec2cdbaa1]). + ** + ** If a generated column is referenced, set bits for every column + ** of the table. + */ + if pMatch != 0 { + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 { + **(**TBitmask)(__ccgo_up(pMatch + 40)) |= _sqlite3ExprColUsed(tls, pExpr) + } else { + libc.SetBitFieldPtr32Uint32(pMatch+24+4, libc.Uint32FromInt32(1), 15, 0x8000) + } + } + (*TExpr)(unsafe.Pointer(pExpr)).Fop = libc.Uint8FromInt32(eNewExprOp) + goto lookupname_end +lookupname_end: + ; + if cnt == int32(1) { + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FxAuth != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_TRIGGER)) { + _sqlite3AuthRead(tls, pParse, pExpr, pSchema, (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList) + } + /* Increment the nRef value on all name contexts from TopNC up to + ** the point where the name matched. */ + for { + (*TNameContext)(unsafe.Pointer(pTopNC)).FnRef = (*TNameContext)(unsafe.Pointer(pTopNC)).FnRef + 1 + if pTopNC == pNC { + break + } + pTopNC = (*TNameContext)(unsafe.Pointer(pTopNC)).FpNext + goto _9 + _9: + } + return int32(WRC_Prune) + } else { + return int32(WRC_Abort) + } + return r +} + +type _mach_port_guard_exception_codes = int32 + +// C documentation +// +// /* +// ** Tag the given column as being part of the PRIMARY KEY +// */ +func _makeColumnPartOfPrimaryKey(tls *libc.TLS, pParse uintptr, pCol uintptr) { + var v1 uintptr + _ = v1 + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_PRIMKEY)) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14452, 0) + } +} + +// C documentation +// +// /* +// ** File control method. For custom operations on an memdb-file. +// */ +func _memdbFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iLimit Tsqlite3_int64 + var p uintptr + var rc int32 + _, _, _ = iLimit, p, rc + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + rc = int32(SQLITE_NOTFOUND) + _memdbEnter(tls, p) + if op == int32(SQLITE_FCNTL_VFSNAME) { + **(**uintptr)(__ccgo_up(pArg)) = Xsqlite3_mprintf(tls, __ccgo_ts+4466, libc.VaList(bp+8, (*TMemStore)(unsafe.Pointer(p)).FaData, (*TMemStore)(unsafe.Pointer(p)).Fsz)) + rc = SQLITE_OK + } + if op == int32(SQLITE_FCNTL_SIZE_LIMIT) { + iLimit = **(**Tsqlite3_int64)(__ccgo_up(pArg)) + if iLimit < (*TMemStore)(unsafe.Pointer(p)).Fsz { + if iLimit < 0 { + iLimit = (*TMemStore)(unsafe.Pointer(p)).FszMax + } else { + iLimit = (*TMemStore)(unsafe.Pointer(p)).Fsz + } + } + (*TMemStore)(unsafe.Pointer(p)).FszMax = iLimit + **(**Tsqlite3_int64)(__ccgo_up(pArg)) = iLimit + rc = SQLITE_OK + } + _memdbLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Open an mem file handle. +// */ +func _memdbOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFd uintptr, flags int32, pOutFlags uintptr) (r int32) { + var apNew, p, pFile, pVfsMutex, v3 uintptr + var i, szName, v2 int32 + _, _, _, _, _, _, _, _ = apNew, i, p, pFile, pVfsMutex, szName, v2, v3 + pFile = pFd + p = uintptr(0) + _ = pVfs + libc.X__builtin___memset_chk(tls, pFile, 0, uint64(24), ^t__predefined_size_t(0)) + szName = _sqlite3Strlen30(tls, zName) + if szName > int32(1) && (int32(**(**int8)(__ccgo_up(zName))) == int32('/') || int32(**(**int8)(__ccgo_up(zName))) == int32('\\')) { + pVfsMutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1)) + Xsqlite3_mutex_enter(tls, pVfsMutex) + i = 0 + for { + if !(i < _memdb_g.FnMemStore) { + break + } + if libc.Xstrcmp(tls, (*TMemStore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(i)*8)))).FzFName, zName) == 0 { + p = **(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(i)*8)) + break + } + goto _1 + _1: + ; + i = i + 1 + } + if p == uintptr(0) { + p = _sqlite3Malloc(tls, uint64(72)+libc.Uint64FromInt64(int64(szName))+uint64(3)) + if p == uintptr(0) { + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + apNew = _sqlite3Realloc(tls, _memdb_g.FapMemStore, uint64(8)*libc.Uint64FromInt64(libc.Int64FromInt32(1)+int64(_memdb_g.FnMemStore))) + if apNew == uintptr(0) { + Xsqlite3_free(tls, p) + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + v3 = uintptr(unsafe.Pointer(&_memdb_g)) + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up(apNew + uintptr(v2)*8)) = p + _memdb_g.FapMemStore = apNew + libc.X__builtin___memset_chk(tls, p, 0, uint64(72), ^t__predefined_size_t(0)) + (*TMemStore)(unsafe.Pointer(p)).FmFlags = libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DESERIALIZE_RESIZEABLE) | libc.Int32FromInt32(SQLITE_DESERIALIZE_FREEONCLOSE)) + (*TMemStore)(unsafe.Pointer(p)).FszMax = _sqlite3Config.FmxMemdbSize + (*TMemStore)(unsafe.Pointer(p)).FzFName = p + 1*72 + libc.X__builtin___memcpy_chk(tls, (*TMemStore)(unsafe.Pointer(p)).FzFName, zName, libc.Uint64FromInt32(szName+int32(1)), ^t__predefined_size_t(0)) + (*TMemStore)(unsafe.Pointer(p)).FpMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) + if (*TMemStore)(unsafe.Pointer(p)).FpMutex == uintptr(0) { + _memdb_g.FnMemStore = _memdb_g.FnMemStore - 1 + Xsqlite3_free(tls, p) + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + (*TMemStore)(unsafe.Pointer(p)).FnRef = int32(1) + _memdbEnter(tls, p) + } else { + _memdbEnter(tls, p) + (*TMemStore)(unsafe.Pointer(p)).FnRef = (*TMemStore)(unsafe.Pointer(p)).FnRef + 1 + } + Xsqlite3_mutex_leave(tls, pVfsMutex) + } else { + p = _sqlite3Malloc(tls, uint64(72)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, p, 0, uint64(72), ^t__predefined_size_t(0)) + (*TMemStore)(unsafe.Pointer(p)).FmFlags = libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DESERIALIZE_RESIZEABLE) | libc.Int32FromInt32(SQLITE_DESERIALIZE_FREEONCLOSE)) + (*TMemStore)(unsafe.Pointer(p)).FszMax = _sqlite3Config.FmxMemdbSize + } + (*TMemFile)(unsafe.Pointer(pFile)).FpStore = p + if pOutFlags != uintptr(0) { + **(**int32)(__ccgo_up(pOutFlags)) = flags | int32(SQLITE_OPEN_MEMORY) + } + (*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods = uintptr(unsafe.Pointer(&_memdb_io_methods)) + _memdbLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Read data from an memdb-file. +// */ +func _memdbRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) { + var p uintptr + _ = p + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + _memdbEnter(tls, p) + if iOfst+int64(iAmt) > (*TMemStore)(unsafe.Pointer(p)).Fsz { + libc.X__builtin___memset_chk(tls, zBuf, 0, libc.Uint64FromInt32(iAmt), ^t__predefined_size_t(0)) + if iOfst < (*TMemStore)(unsafe.Pointer(p)).Fsz { + libc.X__builtin___memcpy_chk(tls, zBuf, (*TMemStore)(unsafe.Pointer(p)).FaData+uintptr(iOfst), libc.Uint64FromInt64((*TMemStore)(unsafe.Pointer(p)).Fsz-iOfst), ^t__predefined_size_t(0)) + } + _memdbLeave(tls, p) + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(2)< (*TMemStore)(unsafe.Pointer(p)).Fsz { + if v2 = iOfst+int64(iAmt) > (*TMemStore)(unsafe.Pointer(p)).FszAlloc; v2 { + v1 = _memdbEnlarge(tls, p, iOfst+int64(iAmt)) + rc = v1 + } + if v2 && v1 != SQLITE_OK { + _memdbLeave(tls, p) + return rc + } + if iOfst > (*TMemStore)(unsafe.Pointer(p)).Fsz { + libc.X__builtin___memset_chk(tls, (*TMemStore)(unsafe.Pointer(p)).FaData+uintptr((*TMemStore)(unsafe.Pointer(p)).Fsz), 0, libc.Uint64FromInt64(iOfst-(*TMemStore)(unsafe.Pointer(p)).Fsz), ^t__predefined_size_t(0)) + } + (*TMemStore)(unsafe.Pointer(p)).Fsz = iOfst + int64(iAmt) + } + libc.X__builtin___memcpy_chk(tls, (*TMemStore)(unsafe.Pointer(p)).FaData+uintptr(iOfst), z, libc.Uint64FromInt32(iAmt), ^t__predefined_size_t(0)) + _memdbLeave(tls, p) + return SQLITE_OK +} + +var _memdb_vfs = Tsqlite3_vfs{ + FiVersion: int32(2), + FmxPathname: int32(1024), + FzName: __ccgo_ts + 4460, +} + +// C documentation +// +// /* +// ** Flush the contents of memory to a real file on disk. +// */ +func _memjrnlCreateFile(tls *libc.TLS, p uintptr) (r int32) { + var copy1 TMemJournal + var iOff Ti64 + var nChunk, rc int32 + var pIter, pReal uintptr + _, _, _, _, _, _ = copy1, iOff, nChunk, pIter, pReal, rc + pReal = p + copy1 = **(**TMemJournal)(__ccgo_up(p)) + libc.X__builtin___memset_chk(tls, p, 0, uint64(80), ^t__predefined_size_t(0)) + rc = _sqlite3OsOpen(tls, copy1.FpVfs, copy1.FzJournal, pReal, copy1.Fflags, uintptr(0)) + if rc == SQLITE_OK { + nChunk = copy1.FnChunkSize + iOff = 0 + pIter = copy1.FpFirst + for { + if !(pIter != 0) { + break + } + if iOff+int64(nChunk) > copy1.Fendpoint.FiOffset { + nChunk = int32(copy1.Fendpoint.FiOffset - iOff) + } + rc = _sqlite3OsWrite(tls, pReal, pIter+8, nChunk, iOff) + if rc != 0 { + break + } + iOff = iOff + int64(nChunk) + goto _1 + _1: + ; + pIter = (*TFileChunk)(unsafe.Pointer(pIter)).FpNext + } + if rc == SQLITE_OK { + /* No error has occurred. Free the in-memory buffers. */ + _memjrnlFreeChunks(tls, copy1.FpFirst) + } + } + if rc != SQLITE_OK { + /* If an error occurred while creating or writing to the file, restore + ** the original before returning. This way, SQLite uses the in-memory + ** journal data to roll back changes made to the internal page-cache + ** before this function was called. */ + _sqlite3OsClose(tls, pReal) + **(**TMemJournal)(__ccgo_up(p)) = copy1 + } + return rc +} + +// C documentation +// +// /* +// ** Read data from the in-memory journal file. This is the implementation +// ** of the sqlite3_vfs.xRead method. +// */ +func _memjrnlRead(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) { + var iChunkOffset, iSpace, nCopy, nRead, v5 int32 + var iOff Tsqlite3_int64 + var p, pChunk, zOut, v2 uintptr + var v3 bool + var v6 int64 + _, _, _, _, _, _, _, _, _, _, _, _ = iChunkOffset, iOff, iSpace, nCopy, nRead, p, pChunk, zOut, v2, v3, v5, v6 + p = pJfd + zOut = zBuf + nRead = iAmt + if int64(iAmt)+iOfst > (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(2)<= 0; v3 { + v2 = (*TFileChunk)(unsafe.Pointer(pChunk)).FpNext + pChunk = v2 + } + if !(v3 && v2 != uintptr(0) && nRead > 0) { + break + } + } + if pChunk != 0 { + v6 = iOfst + int64(iAmt) + } else { + v6 = 0 + } + (*TMemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset = v6 + (*TMemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = pChunk + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Write data to the file. +// */ +func _memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) { + var iChunkOffset, iSpace, nWrite, rc, v1 int32 + var p, pChunk, pNew, zWrite, v2 uintptr + _, _, _, _, _, _, _, _, _, _ = iChunkOffset, iSpace, nWrite, p, pChunk, pNew, rc, zWrite, v1, v2 + p = pJfd + nWrite = iAmt + zWrite = zBuf + /* If the file should be created now, create it and write the new data + ** into the file on disk. */ + if (*TMemJournal)(unsafe.Pointer(p)).FnSpill > 0 && int64(iAmt)+iOfst > int64((*TMemJournal)(unsafe.Pointer(p)).FnSpill) { + rc = _memjrnlCreateFile(tls, p) + if rc == SQLITE_OK { + rc = _sqlite3OsWrite(tls, pJfd, zBuf, iAmt, iOfst) + } + return rc + } else { + /* An in-memory journal file should only ever be appended to. Random + ** access writes are not required. The only exception to this is when + ** the in-memory journal is being used by a connection using the + ** atomic-write optimization. In this case the first 28 bytes of the + ** journal file may be written as part of committing the transaction. */ + if iOfst > 0 && iOfst != (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset { + _memjrnlTruncate(tls, pJfd, iOfst) + } + if iOfst == 0 && (*TMemJournal)(unsafe.Pointer(p)).FpFirst != 0 { + libc.X__builtin___memcpy_chk(tls, (*TMemJournal)(unsafe.Pointer(p)).FpFirst+8, zBuf, libc.Uint64FromInt32(iAmt), ^t__predefined_size_t(0)) + } else { + for nWrite > 0 { + pChunk = (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FpChunk + iChunkOffset = int32((*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset % int64((*TMemJournal)(unsafe.Pointer(p)).FnChunkSize)) + if nWrite < (*TMemJournal)(unsafe.Pointer(p)).FnChunkSize-iChunkOffset { + v1 = nWrite + } else { + v1 = (*TMemJournal)(unsafe.Pointer(p)).FnChunkSize - iChunkOffset + } + iSpace = v1 + if iChunkOffset == 0 { + /* New chunk is required to extend the file. */ + pNew = Xsqlite3_malloc(tls, libc.Int32FromUint64(libc.Uint64FromInt64(16)+libc.Uint64FromInt32((*TMemJournal)(unsafe.Pointer(p)).FnChunkSize-libc.Int32FromInt32(8)))) + if !(pNew != 0) { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(12)<pPrior. The left query could also be a compound query +// ** in which case this routine will be called recursively. +// ** +// ** The results of the total query are to be written into a destination +// ** of type eDest with parameter iParm. +// ** +// ** Example 1: Consider a three-way compound SQL statement. +// ** +// ** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3 +// ** +// ** This statement is parsed up as follows: +// ** +// ** SELECT c FROM t3 +// ** | +// ** `-----> SELECT b FROM t2 +// ** | +// ** `------> SELECT a FROM t1 +// ** +// ** The arrows in the diagram above represent the Select.pPrior pointer. +// ** So if this routine is called with p equal to the t3 query, then +// ** pPrior will be the t2 query. p->op will be TK_UNION in this case. +// ** +// ** Notice that because of the way SQLite parses compound SELECTs, the +// ** individual selects always group from left to right. +// */ +func _multiSelect(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var addr, rc int32 + var db, pDelete, pOne, pPrior, v uintptr + var _ /* dest at bp+0 */ TSelectDest + var _ /* nLimit at bp+40 */ int32 + _, _, _, _, _, _, _ = addr, db, pDelete, pOne, pPrior, rc, v + rc = SQLITE_OK /* Alternative data destination */ + pDelete = uintptr(0) /* Database connection */ + /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only + ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT. + */ + /* Calling function guarantees this much */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pPrior = (*TSelect)(unsafe.Pointer(p)).FpPrior + **(**TSelectDest)(__ccgo_up(bp)) = **(**TSelectDest)(__ccgo_up(pDest)) + v = _sqlite3GetVdbe(tls, pParse) + /* The VDBE already created by calling function */ + /* Create the destination temporary table if necessary + */ + if libc.Int32FromUint8((**(**TSelectDest)(__ccgo_up(bp))).FeDest) == int32(SRT_EphemTab) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm, (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr) + (**(**TSelectDest)(__ccgo_up(bp))).FeDest = uint8(SRT_Table) + } + /* Special handling for a compound-select that originates as a VALUES clause. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_MultiValue) != 0 { + rc = _multiSelectValues(tls, pParse, p, bp) + if rc >= 0 { + goto multi_select_end + } + rc = SQLITE_OK + } + /* Make sure all SELECTs in the statement have the same number of elements + ** in their result sets. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Recursive) != uint32(0) && _hasAnchor(tls, p) != 0 { + _generateWithRecursiveQuery(tls, pParse, p, bp) + } else { + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 { + /* If the compound has an ORDER BY clause, then always use the merge + ** algorithm. */ + return _multiSelectByMerge(tls, pParse, p, pDest) + } else { + if libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop) != int32(TK_ALL) { + /* If the compound is EXCEPT, INTERSECT, or UNION (anything other than + ** UNION ALL) then also always use the merge algorithm. However, the + ** multiSelectByMerge() routine requires that the compound have an + ** ORDER BY clause, and it doesn't right now. So invent one first. */ + pOne = _sqlite3ExprInt32(tls, db, int32(1)) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = _sqlite3ExprListAppend(tls, pParse, uintptr(0), pOne) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto multi_select_end + } + *(*Tu16)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy + 8 + 24)) = uint16(1) + return _multiSelectByMerge(tls, pParse, p, pDest) + } else { + /* For a UNION ALL compound without ORDER BY, simply run the left + ** query, then run the right query */ + addr = 0 + **(**int32)(__ccgo_up(bp + 40)) = 0 /* Initialize to suppress harmless compiler warning */ + if (*TSelect)(unsafe.Pointer(pPrior)).FpPrior == uintptr(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21181, 0) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21196, 0) + } + (*TSelect)(unsafe.Pointer(pPrior)).FiLimit = (*TSelect)(unsafe.Pointer(p)).FiLimit + (*TSelect)(unsafe.Pointer(pPrior)).FiOffset = (*TSelect)(unsafe.Pointer(p)).FiOffset + (*TSelect)(unsafe.Pointer(pPrior)).FpLimit = _sqlite3ExprDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpLimit, 0) + rc = _sqlite3Select(tls, pParse, pPrior, bp) + _sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(pPrior)).FpLimit) + (*TSelect)(unsafe.Pointer(pPrior)).FpLimit = uintptr(0) + if rc != 0 { + goto multi_select_end + } + (*TSelect)(unsafe.Pointer(p)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FiLimit = (*TSelect)(unsafe.Pointer(pPrior)).FiLimit + (*TSelect)(unsafe.Pointer(p)).FiOffset = (*TSelect)(unsafe.Pointer(pPrior)).FiOffset + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 { + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), (*TSelect)(unsafe.Pointer(p)).FiLimit) + if (*TSelect)(unsafe.Pointer(p)).FiOffset != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_OffsetLimit), (*TSelect)(unsafe.Pointer(p)).FiLimit, (*TSelect)(unsafe.Pointer(p)).FiOffset+int32(1), (*TSelect)(unsafe.Pointer(p)).FiOffset) + } + } + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20878, 0) + rc = _sqlite3Select(tls, pParse, p, bp) + pDelete = (*TSelect)(unsafe.Pointer(p)).FpPrior + (*TSelect)(unsafe.Pointer(p)).FpPrior = pPrior + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3LogEstAdd(tls, (*TSelect)(unsafe.Pointer(p)).FnSelectRow, (*TSelect)(unsafe.Pointer(pPrior)).FnSelectRow) + if (*TSelect)(unsafe.Pointer(p)).FpLimit != 0 && _sqlite3ExprIsInteger(tls, (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpLimit)).FpLeft, bp+40, pParse) != 0 && **(**int32)(__ccgo_up(bp + 40)) > 0 && int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) > int32(_sqlite3LogEst(tls, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 40))))) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3LogEst(tls, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 40)))) + } + if addr != 0 { + _sqlite3VdbeJumpHere(tls, v, addr) + } + if (*TSelect)(unsafe.Pointer(p)).FpNext == uintptr(0) { + _sqlite3VdbeExplainPop(tls, pParse) + } + } + } + } + goto multi_select_end +multi_select_end: + ; + (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst = (**(**TSelectDest)(__ccgo_up(bp))).FiSdst + (*TSelectDest)(unsafe.Pointer(pDest)).FnSdst = (**(**TSelectDest)(__ccgo_up(bp))).FnSdst + (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 + if pDelete != 0 { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3SelectDeleteGeneric), pDelete) + } + return rc +} + +// C documentation +// +// /* +// ** Generate code for a compound SELECT statement using a merge +// ** algorithm. The compound must have an ORDER BY clause for this +// ** to work. +// ** +// ** We assume a query of the following form: +// ** +// ** ORDER BY +// ** +// ** is one of UNION ALL, UNION, EXCEPT, or INTERSECT. The idea +// ** is to code both and with the ORDER BY clause as +// ** co-routines. Then run the co-routines in parallel and merge the results +// ** into the output. In addition to the two coroutines (called selectA and +// ** selectB) there are 7 subroutines: +// ** +// ** outA: Move the output of the selectA coroutine into the output +// ** of the compound query. +// ** +// ** outB: Move the output of the selectB coroutine into the output +// ** of the compound query. (Only generated for UNION and +// ** UNION ALL. EXCEPT and INTERSECT never output a row that +// ** appears only in B.) +// ** +// ** AltB: Called when there is data from both coroutines and AB. +// ** +// ** EofA: Called when data is exhausted from selectA. +// ** +// ** EofB: Called when data is exhausted from selectB. +// ** +// ** The implementation of the latter five subroutines depend on which +// ** is used: +// ** +// ** +// ** UNION ALL UNION EXCEPT INTERSECT +// ** ------------- ----------------- -------------- ----------------- +// ** AltB: outA, nextA outA, nextA outA, nextA nextA +// ** +// ** AeqB: outA, nextA nextA nextA outA, nextA +// ** +// ** AgtB: outB, nextB outB, nextB nextB nextB +// ** +// ** EofA: outB, nextB outB, nextB halt halt +// ** +// ** EofB: outA, nextA outA, nextA outA, nextA halt +// ** +// ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA +// ** causes an immediate jump to EofA and an EOF on B following nextB causes +// ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or +// ** following nextX causes a jump to the end of the select processing. +// ** +// ** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled +// ** within the output subroutine. The regPrev register set holds the previously +// ** output value. A comparison is made against this value and the output +// ** is skipped if the next results would be the same as the previous. +// ** +// ** The implementation plan is to implement the two coroutines and seven +// ** subroutines first, then put the control logic at the bottom. Like this: +// ** +// ** goto Init +// ** coA: coroutine for left query (A) +// ** coB: coroutine for right query (B) +// ** outA: output one row of A +// ** outB: output one row of B (UNION and UNION ALL only) +// ** EofA: ... +// ** EofB: ... +// ** AltB: ... +// ** AeqB: ... +// ** AgtB: ... +// ** Init: initialize coroutine registers +// ** yield coA, on eof goto EofA +// ** yield coB, on eof goto EofB +// ** Cmpr: Compare A, B +// ** Jump AltB, AeqB, AgtB +// ** End: ... +// ** +// ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not +// ** actually called using Gosub and they do not Return. EofA and EofB loop +// ** until all data is exhausted then jump to the "end" label. AltB, AeqB, +// ** and AgtB jump to either Cmpr or to one of EofA or EofB. +// */ +func _multiSelectByMerge(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aPermute, db, pItem, pItem1, pKeyDup, pKeyMerge, pNew, pOrderBy, pPrior, pSplit, v, v3 uintptr + var addr1, addrAeqB, addrAgtB, addrAltB, addrEofA, addrEofA_noB, addrEofB, addrOutA, addrOutB, addrSelectA, addrSelectB, bKeep, i, j, labelCmpr, labelEnd, nExpr, nOrderBy, nSelect, op, regAddrA, regAddrB, regLimitA, regLimitB, regOutA, regOutB, regPrev, savedLimit, savedOffset, v4 int32 + var _ /* destA at bp+0 */ TSelectDest + var _ /* destB at bp+40 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aPermute, addr1, addrAeqB, addrAgtB, addrAltB, addrEofA, addrEofA_noB, addrEofB, addrOutA, addrOutB, addrSelectA, addrSelectB, bKeep, db, i, j, labelCmpr, labelEnd, nExpr, nOrderBy, nSelect, op, pItem, pItem1, pKeyDup, pKeyMerge, pNew, pOrderBy, pPrior, pSplit, regAddrA, regAddrB, regLimitA, regLimitB, regOutA, regOutB, regPrev, savedLimit, savedOffset, v, v3, v4 /* Address of the output-A subroutine */ + addrOutB = 0 /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */ + pKeyDup = uintptr(0) /* Mapping from ORDER BY terms to result set columns */ + /* "Managed" code needs this. Ticket #3382. */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* Already thrown the error if VDBE alloc failed */ + labelEnd = _sqlite3VdbeMakeLabel(tls, pParse) + labelCmpr = _sqlite3VdbeMakeLabel(tls, pParse) + /* Patch up the ORDER BY clause + */ + op = libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop) + pOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + nOrderBy = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr + /* For operators other than UNION ALL we have to make sure that + ** the ORDER BY clause covers every term of the result set. Add + ** terms to the ORDER BY clause as necessary. + */ + if op != int32(TK_ALL) { + i = int32(1) + for { + if !(libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 && i <= (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr) { + break + } + j = 0 + pItem = pOrderBy + 8 + for { + if !(j < nOrderBy) { + break + } + if libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol) == i { + break + } + goto _2 + _2: + ; + j = j + 1 + pItem += 32 + } + if j == nOrderBy { + pNew = _sqlite3ExprInt32(tls, db, i) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + v3 = _sqlite3ExprListAppend(tls, pParse, pOrderBy, pNew) + pOrderBy = v3 + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = v3 + if pOrderBy != 0 { + v4 = nOrderBy + nOrderBy = nOrderBy + 1 + *(*Tu16)(unsafe.Pointer(pOrderBy + 8 + uintptr(v4)*32 + 24)) = libc.Uint16FromInt32(i) + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + /* Compute the comparison permutation and keyinfo that is used with + ** the permutation to determine if the next row of results comes + ** from selectA or selectB. Also add literal collations to the + ** ORDER BY clause terms so that when selectA and selectB are + ** evaluated, they use the correct collation. + */ + aPermute = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(nOrderBy+libc.Int32FromInt32(1)))) + if aPermute != 0 { + bKeep = 0 + **(**Tu32)(__ccgo_up(aPermute)) = libc.Uint32FromInt32(nOrderBy) + i = int32(1) + pItem1 = pOrderBy + 8 + for { + if !(i <= nOrderBy) { + break + } + **(**Tu32)(__ccgo_up(aPermute + uintptr(i)*4)) = libc.Uint32FromInt32(libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem1 + 24))).FiOrderByCol) - int32(1)) + if **(**Tu32)(__ccgo_up(aPermute + uintptr(i)*4)) != libc.Uint32FromInt32(i)-uint32(1) { + bKeep = int32(1) + } + goto _5 + _5: + ; + i = i + 1 + pItem1 += 32 + } + if bKeep == 0 { + _sqlite3DbFreeNN(tls, db, aPermute) + aPermute = uintptr(0) + } + } + pKeyMerge = _multiSelectByMergeKeyInfo(tls, pParse, p, int32(1)) + /* Allocate a range of temporary registers and the KeyInfo needed + ** for the logic that removes duplicate result rows when the + ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL). + */ + if op == int32(TK_ALL) { + regPrev = 0 + } else { + nExpr = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr + regPrev = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nExpr + int32(1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regPrev) + pKeyDup = _sqlite3KeyInfoAlloc(tls, db, nExpr, int32(1)) + if pKeyDup != 0 { + i = 0 + for { + if !(i < nExpr) { + break + } + *(*uintptr)(unsafe.Pointer(pKeyDup + 32 + uintptr(i)*8)) = _multiSelectCollSeq(tls, pParse, p, i) + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyDup)).FaSortFlags + uintptr(i))) = uint8(0) + goto _6 + _6: + ; + i = i + 1 + } + } + } + /* Separate the left and the right query from one another + */ + nSelect = int32(1) + if (op == int32(TK_ALL) || op == int32(TK_UNION)) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_BalancedMerge)) == uint32(0) { + pSplit = p + for { + if !((*TSelect)(unsafe.Pointer(pSplit)).FpPrior != uintptr(0) && libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSplit)).Fop) == op) { + break + } + nSelect = nSelect + 1 + goto _7 + _7: + ; + pSplit = (*TSelect)(unsafe.Pointer(pSplit)).FpPrior + } + } + if nSelect <= int32(3) { + pSplit = p + } else { + pSplit = p + i = int32(2) + for { + if !(i < nSelect) { + break + } + pSplit = (*TSelect)(unsafe.Pointer(pSplit)).FpPrior + goto _8 + _8: + ; + i = i + int32(2) + } + } + pPrior = (*TSelect)(unsafe.Pointer(pSplit)).FpPrior + (*TSelect)(unsafe.Pointer(pSplit)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(pPrior)).FpNext = uintptr(0) + (*TSelect)(unsafe.Pointer(pPrior)).FpOrderBy = _sqlite3ExprListDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pOrderBy, 0) + _sqlite3ResolveOrderGroupBy(tls, pParse, p, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, __ccgo_ts+8003) + _sqlite3ResolveOrderGroupBy(tls, pParse, pPrior, (*TSelect)(unsafe.Pointer(pPrior)).FpOrderBy, __ccgo_ts+8003) + /* Compute the limit registers */ + _computeLimitRegisters(tls, pParse, p, labelEnd) + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 && op == int32(TK_ALL) { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regLimitA = v4 + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regLimitB = v4 + if (*TSelect)(unsafe.Pointer(p)).FiOffset != 0 { + v4 = (*TSelect)(unsafe.Pointer(p)).FiOffset + int32(1) + } else { + v4 = (*TSelect)(unsafe.Pointer(p)).FiLimit + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), v4, regLimitA) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), regLimitA, regLimitB) + } else { + v4 = libc.Int32FromInt32(0) + regLimitB = v4 + regLimitA = v4 + } + _sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpLimit) + (*TSelect)(unsafe.Pointer(p)).FpLimit = uintptr(0) + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regAddrA = v4 + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regAddrB = v4 + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regOutA = v4 + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regOutB = v4 + _sqlite3SelectDestInit(tls, bp, int32(SRT_Coroutine), regAddrA) + _sqlite3SelectDestInit(tls, bp+40, int32(SRT_Coroutine), regAddrB) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21343, libc.VaList(bp+88, _sqlite3SelectOpName(tls, libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop)))) + /* Generate a coroutine to evaluate the SELECT statement to the + ** left of the compound operator - the "A" select. + */ + addrSelectA = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regAddrA, 0, addrSelectA) + (*TSelect)(unsafe.Pointer(pPrior)).FiLimit = regLimitA + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21354, 0) + _sqlite3Select(tls, pParse, pPrior, bp) + _sqlite3VdbeEndCoroutine(tls, v, regAddrA) + _sqlite3VdbeJumpHere(tls, v, addr1) + /* Generate a coroutine to evaluate the SELECT statement on + ** the right - the "B" select + */ + addrSelectB = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regAddrB, 0, addrSelectB) + savedLimit = (*TSelect)(unsafe.Pointer(p)).FiLimit + savedOffset = (*TSelect)(unsafe.Pointer(p)).FiOffset + (*TSelect)(unsafe.Pointer(p)).FiLimit = regLimitB + (*TSelect)(unsafe.Pointer(p)).FiOffset = 0 + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21359, 0) + _sqlite3Select(tls, pParse, p, bp+40) + (*TSelect)(unsafe.Pointer(p)).FiLimit = savedLimit + (*TSelect)(unsafe.Pointer(p)).FiOffset = savedOffset + _sqlite3VdbeEndCoroutine(tls, v, regAddrB) + /* Generate a subroutine that outputs the current row of the A + ** select as the next output row of the compound select. + */ + addrOutA = _generateOutputSubroutine(tls, pParse, p, bp, pDest, regOutA, regPrev, pKeyDup, labelEnd) + /* Generate a subroutine that outputs the current row of the B + ** select as the next output row of the compound select. + */ + if op == int32(TK_ALL) || op == int32(TK_UNION) { + addrOutB = _generateOutputSubroutine(tls, pParse, p, bp+40, pDest, regOutB, regPrev, pKeyDup, labelEnd) + } + _sqlite3KeyInfoUnref(tls, pKeyDup) + /* Generate a subroutine to run when the results from select A + ** are exhausted and only data in select B remains. + */ + if op == int32(TK_EXCEPT) || op == int32(TK_INTERSECT) { + v4 = labelEnd + addrEofA = v4 + addrEofA_noB = v4 + } else { + addrEofA = _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutB, addrOutB) + addrEofA_noB = _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrB, labelEnd) + _sqlite3VdbeGoto(tls, v, addrEofA) + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3LogEstAdd(tls, (*TSelect)(unsafe.Pointer(p)).FnSelectRow, (*TSelect)(unsafe.Pointer(pPrior)).FnSelectRow) + } + /* Generate a subroutine to run when the results from select B + ** are exhausted and only data in select A remains. + */ + if op == int32(TK_INTERSECT) { + addrEofB = addrEofA + if int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) > int32((*TSelect)(unsafe.Pointer(pPrior)).FnSelectRow) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = (*TSelect)(unsafe.Pointer(pPrior)).FnSelectRow + } + } else { + addrEofB = _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutA, addrOutA) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrA, labelEnd) + _sqlite3VdbeGoto(tls, v, addrEofB) + } + /* Generate code to handle the case of AB + */ + addrAgtB = _sqlite3VdbeCurrentAddr(tls, v) + if op == int32(TK_ALL) || op == int32(TK_UNION) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutB, addrOutB) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrB, addrEofB) + _sqlite3VdbeGoto(tls, v, labelCmpr) + } else { + addrAgtB = addrAgtB + 1 /* Just do next-B. Might as well use the next-B call + ** in the next code block */ + } + /* This code runs once to initialize everything. + */ + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrA, addrEofA_noB) + /* v--- Also the A>B case for EXCEPT and INTERSECT */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrB, addrEofB) + /* Implement the main merge loop + */ + if aPermute != uintptr(0) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Permutation), 0, 0, 0, aPermute, -int32(15)) + } + _sqlite3VdbeResolveLabel(tls, v, labelCmpr) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Compare), (**(**TSelectDest)(__ccgo_up(bp))).FiSdst, (**(**TSelectDest)(__ccgo_up(bp + 40))).FiSdst, nOrderBy, pKeyMerge, -int32(9)) + if aPermute != uintptr(0) { + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_PERMUTE)) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addrAltB, addrAeqB, addrAgtB) + /* Jump to the this point in order to terminate the query. + */ + _sqlite3VdbeResolveLabel(tls, v, labelEnd) + /* Make arrangements to free the 2nd and subsequent arms of the compound + ** after the parse has finished */ + if (*TSelect)(unsafe.Pointer(pSplit)).FpPrior != 0 { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3SelectDeleteGeneric), (*TSelect)(unsafe.Pointer(pSplit)).FpPrior) + } + (*TSelect)(unsafe.Pointer(pSplit)).FpPrior = pPrior + (*TSelect)(unsafe.Pointer(pPrior)).FpNext = pSplit + _sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(pPrior)).FpOrderBy) + (*TSelect)(unsafe.Pointer(pPrior)).FpOrderBy = uintptr(0) + /*** TBD: Insert subroutine calls to close cursors on incomplete + **** subqueries ****/ + _sqlite3VdbeExplainPop(tls, pParse) + return libc.BoolInt32((*TParse)(unsafe.Pointer(pParse)).FnErr != 0) +} + +// C documentation +// +// /* +// ** Handle the special case of a compound-select that originates from a +// ** VALUES clause. By handling this as a special case, we avoid deep +// ** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT +// ** on a VALUES clause. +// ** +// ** Because the Select object originates from a VALUES clause: +// ** (1) There is no LIMIT or OFFSET or else there is a LIMIT of exactly 1 +// ** (2) All terms are UNION ALL +// ** (3) There is no ORDER BY clause +// ** +// ** The "LIMIT of exactly 1" case of condition (1) comes about when a VALUES +// ** clause occurs within scalar expression (ex: "SELECT (VALUES(1),(2),(3))"). +// ** The sqlite3CodeSubselect will have added the LIMIT 1 clause in tht case. +// ** Since the limit is exactly 1, we only need to evaluate the left-most VALUES. +// */ +func _multiSelectValues(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bShowAll, nRow, rc int32 + var v1 uintptr + _, _, _, _ = bShowAll, nRow, rc, v1 + nRow = int32(1) + rc = 0 + bShowAll = libc.BoolInt32((*TSelect)(unsafe.Pointer(p)).FpLimit == uintptr(0)) + for cond := true; cond; cond = int32(1) != 0 { + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 { + return -int32(1) + } + if (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) { + break + } + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + nRow = nRow + bShowAll + } + if nRow == int32(1) { + v1 = __ccgo_ts + 1702 + } else { + v1 = __ccgo_ts + 3834 + } + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+21158, libc.VaList(bp+8, nRow, v1)) + for p != 0 { + _selectInnerLoop(tls, pParse, p, -int32(1), uintptr(0), uintptr(0), pDest, int32(1), int32(1)) + if !(bShowAll != 0) { + break + } + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(nRow) + p = (*TSelect)(unsafe.Pointer(p)).FpNext + } + return rc +} + +// C documentation +// +// /* +// ** If pBt points to an empty file then convert that empty file +// ** into a new empty database by initializing the first page of +// ** the database. +// */ +func _newDatabase(tls *libc.TLS, pBt uintptr) (r int32) { + var data, pP1, v1 uintptr + var rc int32 + _, _, _, _ = data, pP1, rc, v1 + if (*TBtShared)(unsafe.Pointer(pBt)).FnPage > uint32(0) { + return SQLITE_OK + } + pP1 = (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 + data = (*TMemPage)(unsafe.Pointer(pP1)).FaData + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pP1)).FpDbPage) + if rc != 0 { + return rc + } + libc.X__builtin___memcpy_chk(tls, data, uintptr(unsafe.Pointer(&_zMagicHeader)), uint64(16), ^t__predefined_size_t(0)) + **(**uint8)(__ccgo_up(data + 16)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FpageSize >> libc.Int32FromInt32(8) & libc.Uint32FromInt32(0xff)) + **(**uint8)(__ccgo_up(data + 17)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FpageSize >> libc.Int32FromInt32(16) & libc.Uint32FromInt32(0xff)) + **(**uint8)(__ccgo_up(data + 18)) = uint8(1) + **(**uint8)(__ccgo_up(data + 19)) = uint8(1) + **(**uint8)(__ccgo_up(data + 20)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FpageSize - (*TBtShared)(unsafe.Pointer(pBt)).FusableSize) + **(**uint8)(__ccgo_up(data + 21)) = uint8(64) + **(**uint8)(__ccgo_up(data + 22)) = uint8(32) + **(**uint8)(__ccgo_up(data + 23)) = uint8(32) + libc.X__builtin___memset_chk(tls, data+24, 0, libc.Uint64FromInt32(libc.Int32FromInt32(100)-libc.Int32FromInt32(24)), ^t__predefined_size_t(0)) + _zeroPage(tls, pP1, libc.Int32FromInt32(PTF_INTKEY)|libc.Int32FromInt32(PTF_LEAF)|libc.Int32FromInt32(PTF_LEAFDATA)) + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + _sqlite3Put4byte(tls, data+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(4)*libc.Int32FromInt32(4)), uint32((*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum)) + _sqlite3Put4byte(tls, data+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(7)*libc.Int32FromInt32(4)), uint32((*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum)) + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = uint32(1) + **(**uint8)(__ccgo_up(data + 31)) = uint8(1) + return SQLITE_OK +} + +var _nfsIoFinder = uintptr(0) + +func _nfsIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) (r uintptr) { + _ = z + _ = p + return uintptr(unsafe.Pointer(&_nfsIoMethods)) +} + +// C documentation +// +// /* nfs lockd on OSX 10.3+ doesn't clear write locks when a read lock is set */ +var _nfsIoMethods = Tsqlite3_io_methods{ + FiVersion: int32(1), +} + +// C documentation +// +// /* +// ** Lower the locking level on file descriptor pFile to eFileLock. eFileLock +// ** must be either NO_LOCK or SHARED_LOCK. +// ** +// ** If the locking level of the file descriptor is already at or below +// ** the requested locking level, this routine is a no-op. +// */ +func _nfsUnlock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + return _posixUnlock(tls, id, eFileLock, int32(1)) +} + +/* +** The code above is the NFS lock implementation. The code is specific +** to MacOSX and does not work on other unix platforms. No alternative +** is available. +** +********************* End of the NFS lock implementation ********************** +******************************************************************************/ + +/****************************************************************************** +**************** Non-locking sqlite3_file methods ***************************** +** +** The next division contains implementations for all methods of the +** sqlite3_file object other than the locking methods. The locking +** methods were defined in divisions above (one locking method per +** division). Those methods that are common to all locking modes +** are gather together into this division. + */ + +// C documentation +// +// /* +// ** Obtain a reference to an r-tree node. +// */ +func _nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode Ti64, pParent uintptr, ppNode uintptr) (r int32) { + var pBlob, pNode, v1 uintptr + var rc int32 + _, _, _, _ = pBlob, pNode, rc, v1 + rc = SQLITE_OK + pNode = uintptr(0) + /* Check if the requested node is already in the hash table. If so, + ** increase its reference count and return it. + */ + v1 = _nodeHashLookup(tls, pRtree, iNode) + pNode = v1 + if v1 != uintptr(0) { + if pParent != 0 && pParent != (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent { + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<iDepth to the height + ** of the r-tree structure. A height of zero means all data is stored on + ** the root node. A height of one means the children of the root node + ** are the leaves, and so on. If the depth as specified on the root node + ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt. + */ + if rc == SQLITE_OK && pNode != 0 && iNode == int64(1) { + (*TRtree)(unsafe.Pointer(pRtree)).FiDepth = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData) + if (*TRtree)(unsafe.Pointer(pRtree)).FiDepth > int32(RTREE_MAX_DEPTH) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< ((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize-int32(4))/libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<ncFlags values determined by validMask. +// ** +// ** static void notValid( +// ** Parse *pParse, // Leave error message here +// ** NameContext *pNC, // The name context +// ** const char *zMsg, // Type of error +// ** int validMask, // Set of contexts for which prohibited +// ** Expr *pExpr // Invalidate this expression on error +// ** ){...} +// ** +// ** As an optimization, since the conditional is almost always false +// ** (because errors are rare), the conditional is moved outside of the +// ** function call using a macro. +// */ +func _notValidImpl(tls *libc.TLS, pParse uintptr, pNC uintptr, zMsg uintptr, pExpr uintptr, pError uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var zIn uintptr + _ = zIn + zIn = __ccgo_ts + 7442 + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_IdxExpr) != 0 { + zIn = __ccgo_ts + 7470 + } else { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_IsCheck) != 0 { + zIn = __ccgo_ts + 7488 + } else { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_GenCol) != 0 { + zIn = __ccgo_ts + 7506 + } + } + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7524, libc.VaList(bp+8, zMsg, zIn)) + if pExpr != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + } + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pError) +} + +func _nth_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var fVal float64 + var iVal Ti64 + var p uintptr + _, _, _ = fVal, iVal, p + p = Xsqlite3_aggregate_context(tls, pCtx, int32(16)) + if p != 0 { + switch Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) { + case int32(SQLITE_INTEGER): + iVal = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + case int32(SQLITE_FLOAT): + fVal = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + if float64(int64(fVal)) != fVal { + goto error_out + } + iVal = int64(fVal) + default: + goto error_out + } + if iVal <= 0 { + goto error_out + } + (*TNthValueCtx)(unsafe.Pointer(p)).FnStep = (*TNthValueCtx)(unsafe.Pointer(p)).FnStep + 1 + if iVal == (*TNthValueCtx)(unsafe.Pointer(p)).FnStep { + (*TNthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, **(**uintptr)(__ccgo_up(apArg))) + if !((*TNthValueCtx)(unsafe.Pointer(p)).FpValue != 0) { + Xsqlite3_result_error_nomem(tls, pCtx) + } + } + } + _ = nArg + _ = apArg + return + goto error_out +error_out: + ; + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+24501, -int32(1)) +} + +// C documentation +// +// /* +// ** Implementation of ntile(). This assumes that the window frame has +// ** been coerced to: +// ** +// ** ROWS CURRENT ROW AND UNBOUNDED FOLLOWING +// */ +func _ntileStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + _ = nArg + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + if p != 0 { + if (*TNtileCtx)(unsafe.Pointer(p)).FnTotal == 0 { + (*TNtileCtx)(unsafe.Pointer(p)).FnParam = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apArg))) + if (*TNtileCtx)(unsafe.Pointer(p)).FnParam <= 0 { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+24557, -int32(1)) + } + } + (*TNtileCtx)(unsafe.Pointer(p)).FnTotal = (*TNtileCtx)(unsafe.Pointer(p)).FnTotal + 1 + } +} + +type _opaque_pthread_attr_t = T_opaque_pthread_attr_t + +type _opaque_pthread_cond_t = T_opaque_pthread_cond_t + +type _opaque_pthread_condattr_t = T_opaque_pthread_condattr_t + +type _opaque_pthread_mutex_t = T_opaque_pthread_mutex_t + +type _opaque_pthread_mutexattr_t = T_opaque_pthread_mutexattr_t + +type _opaque_pthread_once_t = T_opaque_pthread_once_t + +type _opaque_pthread_rwlock_t = T_opaque_pthread_rwlock_t + +type _opaque_pthread_rwlockattr_t = T_opaque_pthread_rwlockattr_t + +type _opaque_pthread_t = T_opaque_pthread_t + +// C documentation +// +// /* +// ** This routine does the work of opening a database on behalf of +// ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename" +// ** is UTF-8 encoded. +// */ +func _openDatabase(tls *libc.TLS, zFilename uintptr, ppDb uintptr, _flags uint32, zVfs uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + *(*uint32)(unsafe.Pointer(bp)) = _flags + var db, v2 uintptr + var i, isThreadsafe, rc int32 + var v1 uint32 + var _ /* zErrMsg at bp+16 */ uintptr + var _ /* zOpen at bp+8 */ uintptr + _, _, _, _, _, _ = db, i, isThreadsafe, rc, v1, v2 /* True for threadsafe connections */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Filename argument to pass to BtreeOpen() */ + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) /* Loop counter */ + **(**uintptr)(__ccgo_up(ppDb)) = uintptr(0) + rc = Xsqlite3_initialize(tls) + if rc != 0 { + return rc + } + if libc.Int32FromUint8(_sqlite3Config.FbCoreMutex) == 0 { + isThreadsafe = 0 + } else { + if **(**uint32)(__ccgo_up(bp))&uint32(SQLITE_OPEN_NOMUTEX) != 0 { + isThreadsafe = 0 + } else { + if **(**uint32)(__ccgo_up(bp))&uint32(SQLITE_OPEN_FULLMUTEX) != 0 { + isThreadsafe = int32(1) + } else { + isThreadsafe = libc.Int32FromUint8(_sqlite3Config.FbFullMutex) + } + } + } + if **(**uint32)(__ccgo_up(bp))&uint32(SQLITE_OPEN_PRIVATECACHE) != 0 { + **(**uint32)(__ccgo_up(bp)) = **(**uint32)(__ccgo_up(bp)) & libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_OPEN_SHAREDCACHE)) + } else { + if _sqlite3Config.FsharedCacheEnabled != 0 { + **(**uint32)(__ccgo_up(bp)) = **(**uint32)(__ccgo_up(bp)) | uint32(SQLITE_OPEN_SHAREDCACHE) + } + } + /* Remove harmful bits from the flags parameter + ** + ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were + ** dealt with in the previous code block. Besides these, the only + ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, + ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, + ** SQLITE_OPEN_PRIVATECACHE, SQLITE_OPEN_EXRESCODE, and some reserved + ** bits. Silently mask off all other flags. + */ + **(**uint32)(__ccgo_up(bp)) = **(**uint32)(__ccgo_up(bp)) & libc.Uint32FromInt32(^(libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_MAIN_DB) | libc.Int32FromInt32(SQLITE_OPEN_TEMP_DB) | libc.Int32FromInt32(SQLITE_OPEN_TRANSIENT_DB) | libc.Int32FromInt32(SQLITE_OPEN_MAIN_JOURNAL) | libc.Int32FromInt32(SQLITE_OPEN_TEMP_JOURNAL) | libc.Int32FromInt32(SQLITE_OPEN_SUBJOURNAL) | libc.Int32FromInt32(SQLITE_OPEN_SUPER_JOURNAL) | libc.Int32FromInt32(SQLITE_OPEN_NOMUTEX) | libc.Int32FromInt32(SQLITE_OPEN_FULLMUTEX) | libc.Int32FromInt32(SQLITE_OPEN_WAL))) + /* Allocate the sqlite data structure */ + db = _sqlite3MallocZero(tls, uint64(864)) + if db == uintptr(0) { + goto opendb_out + } + if isThreadsafe != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).Fmutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_RECURSIVE)) + if (*Tsqlite3)(unsafe.Pointer(db)).Fmutex == uintptr(0) { + Xsqlite3_free(tls, db) + db = uintptr(0) + goto opendb_out + } + if isThreadsafe == 0 { + } + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if **(**uint32)(__ccgo_up(bp))&uint32(SQLITE_OPEN_EXRESCODE) != uint32(0) { + v1 = uint32(0xffffffff) + } else { + v1 = uint32(0xff) + } + (*Tsqlite3)(unsafe.Pointer(db)).FerrMask = libc.Int32FromUint32(v1) + (*Tsqlite3)(unsafe.Pointer(db)).FnDb = int32(2) + (*Tsqlite3)(unsafe.Pointer(db)).FeOpenState = uint8(SQLITE_STATE_BUSY) + (*Tsqlite3)(unsafe.Pointer(db)).FaDb = db + 696 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = uint32(1) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + (*Tsqlite3)(unsafe.Pointer(db)).FnFpDigit = uint8(17) + libc.X__builtin___memcpy_chk(tls, db+136, uintptr(unsafe.Pointer(&_aHardLimit)), uint64(52), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(db + 136 + 11*4)) = SQLITE_DEFAULT_WORKER_THREADS + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(1) + (*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac = int8(-int32(1)) + (*Tsqlite3)(unsafe.Pointer(db)).FszMmap = _sqlite3Config.FszMmap + (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize = 0 + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = uintptr(unsafe.Pointer(&_sqlite3StdType)) /* Any array of string ptrs will do */ + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_ShortColNames)|libc.Int32FromInt32(SQLITE_EnableTrigger))|libc.Uint32FromUint32(SQLITE_EnableView)|libc.Uint32FromInt32(SQLITE_CacheSpill)) | libc.Uint64FromInt32(libc.Int32FromInt32(0x00010))< 0 && int32((**(**[513]int8)(__ccgo_up(bp)))[ii]) != int32('/')) { + break + } + goto _1 + _1: + ; + ii = ii - 1 + } + if ii > 0 { + (**(**[513]int8)(__ccgo_up(bp)))[ii] = int8('\000') + } else { + if int32((**(**[513]int8)(__ccgo_up(bp)))[0]) != int32('/') { + (**(**[513]int8)(__ccgo_up(bp)))[0] = int8('.') + } + (**(**[513]int8)(__ccgo_up(bp)))[int32(1)] = 0 + } + fd = _robust_open(tls, bp, libc.Int32FromInt32(O_RDONLY)|libc.Int32FromInt32(O_BINARY), uint16(0)) + if fd >= 0 { + } + **(**int32)(__ccgo_up(pFd)) = fd + if fd >= 0 { + return SQLITE_OK + } + return _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(44080)), __ccgo_ts+3657, bp, int32(44080)) +} + +func _openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pCsr, pFd, pState, v2 uintptr + var frc int32 + var nByte, nRbu, nTarget Tsize_t + var v1 uint64 + var _ /* bRetry at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = db, frc, nByte, nRbu, nTarget, p, pCsr, pFd, pState, v1, v2 + if zTarget != 0 { + v1 = libc.Xstrlen(tls, zTarget) + } else { + v1 = uint64(0) + } + nTarget = v1 + nRbu = libc.Xstrlen(tls, zRbu) + nByte = uint64(416) + nTarget + uint64(1) + nRbu + uint64(1) + p = Xsqlite3_malloc64(tls, nByte) + if p != 0 { + pState = uintptr(0) + /* Create the custom VFS. */ + libc.X__builtin___memset_chk(tls, p, 0, uint64(416), ^t__predefined_size_t(0)) + Xsqlite3rbu_rename_handler(tls, p, uintptr(0), uintptr(0)) + _rbuCreateVfs(tls, p) + /* Open the target, RBU and state databases */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pCsr = p + 1*416 + **(**int32)(__ccgo_up(bp)) = 0 + if zTarget != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget = pCsr + libc.X__builtin___memcpy_chk(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget, zTarget, nTarget+uint64(1), ^t__predefined_size_t(0)) + pCsr = pCsr + uintptr(nTarget+uint64(1)) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu = pCsr + libc.X__builtin___memcpy_chk(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, zRbu, nRbu+uint64(1), ^t__predefined_size_t(0)) + pCsr = pCsr + uintptr(nRbu+uint64(1)) + if zState != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState = _rbuMPrintf(tls, p, __ccgo_ts+3944, libc.VaList(bp+16, zState)) + } + /* If the first attempt to open the database file fails and the bRetry + ** flag it set, this means that the db was not opened because it seemed + ** to be a wal-mode db. But, this may have happened due to an earlier + ** RBU vacuum operation leaving an old wal file in the directory. + ** If this is the case, it will have been checkpointed and deleted + ** when the handle was closed and a second attempt to open the + ** database may succeed. */ + _rbuOpenDatabase(tls, p, uintptr(0), bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + _rbuOpenDatabase(tls, p, uintptr(0), uintptr(0)) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pState = _rbuLoadState(tls, p) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*TRbuState)(unsafe.Pointer(pState)).FeStage == 0 { + _rbuDeleteOalFile(tls, p) + _rbuInitPhaseOneSteps(tls, p) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_OAL) + } else { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = (*TRbuState)(unsafe.Pointer(pState)).FeStage + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = (*TRbuState)(unsafe.Pointer(pState)).FnPhaseOneStep + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress = (*TRbuState)(unsafe.Pointer(pState)).FnProgress + (*Tsqlite3rbu)(unsafe.Pointer(p)).FiOalSz = (*TRbuState)(unsafe.Pointer(pState)).FiOalSz + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd != 0 { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+34880, 0) + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_MOVE) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CKPT) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = 0 + } + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && ((*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) || (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_MOVE)) && (*TRbuState)(unsafe.Pointer(pState)).FeStage != 0 { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v2 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd + } else { + v2 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd + } + pFd = v2 + if (*Trbu_file)(unsafe.Pointer(pFd)).FiCookie != (*TRbuState)(unsafe.Pointer(pState)).FiCookie { + /* At this point (pTargetFd->iCookie) contains the value of the + ** change-counter cookie (the thing that gets incremented when a + ** transaction is committed in rollback mode) currently stored on + ** page 1 of the database file. */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_BUSY) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v2 = __ccgo_ts + 34912 + } else { + v2 = __ccgo_ts + 34919 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+34926, libc.VaList(bp+16, v2)) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + db = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16447, uintptr(0), uintptr(0), p+64) + /* Point the object iterator at the first object */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _rbuObjIterFirst(tls, p, p+88) + } + /* If the RBU database contains no data_xxx tables, declare the RBU + ** update finished. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE) + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuState)(unsafe.Pointer(pState)).FeStage == 0 && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + _rbuCopyPragma(tls, p, __ccgo_ts+19013) + _rbuCopyPragma(tls, p, __ccgo_ts+18409) + } + /* Open transactions both databases. The *-oal file is opened or + ** created at this point. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, __ccgo_ts+34958, uintptr(0), uintptr(0), p+64) + } + /* Check if the main database is a zipvfs db. If it is, set the upper + ** level pager to use "journal_mode=off". This prevents it from + ** generating a large journal using a temp file. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + frc = Xsqlite3_file_control(tls, db, __ccgo_ts+7160, int32(SQLITE_FCNTL_ZIPVFS), uintptr(0)) + if frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, __ccgo_ts+34974, uintptr(0), uintptr(0), p+64) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuSetupOal(tls, p, pState) + } + } + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_MOVE) { + /* no-op */ + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_CKPT) { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == libc.UintptrFromInt32(0)) && _rbuExclusiveCheckpoint(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) != 0 { + /* If the rbu_exclusive_checkpoint=1 URI parameter was specified + ** and an incremental checkpoint is being resumed, attempt an + ** exclusive lock on the db file. If this fails, so be it. */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE) + _rbuLockDatabase(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CKPT) + } + _rbuSetupCheckpoint(tls, p, pState) + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_DONE) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE) + } else { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_CORRUPT) + } + } + } + } + } + _rbuFreeState(tls, pState) + } + return p +} + +// C documentation +// +// /* +// ** This routine generates code that opens the sqlite_statN tables. +// ** The sqlite_stat1 table is always relevant. sqlite_stat2 is now +// ** obsolete. sqlite_stat3 and sqlite_stat4 are only opened when +// ** appropriate compile-time options are provided. +// ** +// ** If the sqlite_statN tables do not previously exist, it is created. +// ** +// ** Argument zWhere may be a pointer to a buffer containing a table name, +// ** or it may be a NULL pointer. If it is not NULL, then all entries in +// ** the sqlite_statN tables associated with the named table are deleted. +// ** If zWhere==0, then code is generated to delete all stat table entries. +// */ +func _openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWhere uintptr, zWhereType uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aCreateTbl [3]Tu8 + var aRoot [3]Tu32 + var db, pDb, pStat, v, zTab, v3 uintptr + var i, nToOpen, v1 int32 + _, _, _, _, _, _, _, _, _, _, _ = aCreateTbl, aRoot, db, i, nToOpen, pDb, pStat, v, zTab, v1, v3 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = _sqlite3GetVdbe(tls, pParse) + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) { + v1 = int32(2) + } else { + v1 = int32(1) + } + nToOpen = v1 + if v == uintptr(0) { + return + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + /* Create new statistic tables if they do not exist, or clear them + ** if they do already exist. + */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(48)/libc.Uint64FromInt64(16))) { + break + } + zTab = _aTable[i].FzName + aCreateTbl[i] = uint8(0) + v3 = _sqlite3FindTable(tls, db, zTab, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) + pStat = v3 + if v3 == uintptr(0) { + if i < nToOpen { + /* The sqlite_statN table does not exist. Create it. Note that a + ** side-effect of the CREATE TABLE statement is to leave the rootpage + ** of the new table in register pParse->regRoot. This is important + ** because the OpenWrite opcode below will be needing it. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+13257, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, zTab, _aTable[i].FzCols)) + aRoot[i] = libc.Uint32FromInt32((*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot) + aCreateTbl[i] = uint8(OPFLAG_P2ISREG) + } + } else { + /* The table already exists. If zWhere is not NULL, delete all entries + ** associated with the table zWhere. If zWhere is NULL, delete the + ** entire contents of the table. */ + aRoot[i] = (*TTable)(unsafe.Pointer(pStat)).Ftnum + _sqlite3TableLock(tls, pParse, iDb, aRoot[i], uint8(1), zTab) + if zWhere != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+13280, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, zTab, zWhereType, zWhere)) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+13310, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, zTab)) + } else { + /* The sqlite_stat[134] table already exists. Delete all rows. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Clear), libc.Int32FromUint32(aRoot[i]), iDb) + } + } + } + goto _2 + _2: + ; + i = i + 1 + } + /* Open the sqlite_stat[134] tables for writing. */ + i = 0 + for { + if !(i < nToOpen) { + break + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_OpenWrite), iStatCur+i, libc.Int32FromUint32(aRoot[i]), iDb, int32(3)) + _sqlite3VdbeChangeP5(tls, v, uint16(aCreateTbl[i])) + goto _4 + _4: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Search the free-list on page pPg for space to store a cell nByte bytes in +// ** size. If one can be found, return a pointer to the space and remove it +// ** from the free-list. +// ** +// ** If no suitable space can be found on the free-list, return NULL. +// ** +// ** This function may detect corruption within pPg. If corruption is +// ** detected then *pRc is set to SQLITE_CORRUPT and NULL is returned. +// ** +// ** Slots on the free list that are between 1 and 3 bytes larger than nByte +// ** will be ignored if adding the extra space to the fragmentation count +// ** causes the fragmentation count to exceed 60. +// */ +func _pageFindSlot(tls *libc.TLS, pPg uintptr, nByte int32, pRc uintptr) (r uintptr) { + var aData, pTmp, v2 uintptr + var hdr, iAddr, maxPC, pc, size, x, v1 int32 + _, _, _, _, _, _, _, _, _, _ = aData, hdr, iAddr, maxPC, pTmp, pc, size, x, v1, v2 + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FhdrOffset) /* Offset to page header */ + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData /* Page data */ + iAddr = hdr + int32(1) /* Address of ptr to pc */ + pTmp = aData + uintptr(iAddr) /* Temporary ptr into aData[] */ + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTmp)))<= 0 { + if x < int32(4) { + /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total + ** number of bytes in fragments may not exceed 60. */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(7))))) > int32(57) { + return uintptr(0) + } + /* Remove the slot from the free-list. Update the number of + ** fragmented bytes within the page. */ + libc.X__builtin___memcpy_chk(tls, aData+uintptr(iAddr), aData+uintptr(pc), uint64(2), ^t__predefined_size_t(0)) + v2 = aData + uintptr(hdr+int32(7)) + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) + libc.Int32FromUint8(libc.Uint8FromInt32(x))) + return aData + uintptr(pc) + } else { + if x+pc > maxPC { + /* This slot extends off the end of the usable part of the page */ + **(**int32)(__ccgo_up(pRc)) = _sqlite3CorruptError(tls, int32(74920)) + return uintptr(0) + } else { + /* The slot remains on the free-list. Reduce its size to account + ** for the portion used by the new allocation. */ + **(**Tu8)(__ccgo_up(aData + uintptr(pc+int32(2)))) = libc.Uint8FromInt32(x >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(pc+int32(2)) + 1)) = libc.Uint8FromInt32(x) + } + } + return aData + uintptr(pc+x) + } + iAddr = pc + pTmp = aData + uintptr(pc) + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTmp)))< maxPC+nByte-int32(4) { + /* The free slot chain extends off the end of the page */ + **(**int32)(__ccgo_up(pRc)) = _sqlite3CorruptError(tls, int32(74942)) + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** The pCArray objects contains pointers to b-tree cells and the cell sizes. +// ** This function attempts to add the cells stored in the array to page pPg. +// ** If it cannot (because the page needs to be defragmented before the cells +// ** will fit), non-zero is returned. Otherwise, if the cells are added +// ** successfully, zero is returned. +// ** +// ** Argument pCellptr points to the first entry in the cell-pointer array +// ** (part of page pPg) to populate. After cell apCell[0] is written to the +// ** page body, a 16-bit offset is written to pCellptr. And so on, for each +// ** cell in the array. It is the responsibility of the caller to ensure +// ** that it is safe to overwrite this part of the cell-pointer array. +// ** +// ** When this function is called, *ppData points to the start of the +// ** content area on page pPg. If the size of the content area is extended, +// ** *ppData is updated to point to the new start of the content area +// ** before returning. +// ** +// ** Finally, argument pBegin points to the byte immediately following the +// ** end of the space required by this page for the cell-pointer area (for +// ** all cells - not just those inserted by the current call). If the content +// ** area must be extended to before this point in order to accommodate all +// ** cells in apCell[], then the cells do not fit and non-zero is returned. +// */ +func _pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, pCellptr uintptr, iFirst int32, nCell int32, pCArray uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aData, pData, pEnd, pSlot, v2 uintptr + var i, iEnd, k, sz int32 + var v3 bool + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = aData, i, iEnd, k, pData, pEnd, pSlot, sz, v2, v3 + i = iFirst /* Loop counter - cell index to insert */ + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData /* Complete page */ + pData = **(**uintptr)(__ccgo_up(ppData)) /* Content area. A subset of aData[] */ + iEnd = iFirst + nCell /* Maximum extent of cell data */ + /* Never called on page 1 */ + if iEnd <= iFirst { + return 0 + } + k = 0 + for { + if !(**(**int32)(__ccgo_up(pCArray + 80 + uintptr(k)*4)) <= i) { + break + } + goto _1 + _1: + ; + k = k + 1 + } + pEnd = **(**uintptr)(__ccgo_up(pCArray + 32 + uintptr(k)*8)) + for int32(1) != 0 { + sz = libc.Int32FromUint16(**(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2))) + if v3 = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + 1))) == 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + 2))) == 0; !v3 { + v2 = _pageFindSlot(tls, pPg, sz, bp) + pSlot = v2 + } + if v3 || v2 == uintptr(0) { + if int64(pData)-int64(pBegin) < int64(sz) { + return int32(1) + } + pData = pData - uintptr(sz) + pSlot = pData + } + /* pSlot and pCArray->apCell[i] will never overlap on a well-formed + ** database. But they might for a corrupt database. Hence use memmove() + ** since memcpy() sends SIGABORT with overlapping buffers on OpenBSD */ + if uint64(**(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8))+uintptr(sz)) > uint64(pEnd) && uint64(**(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8))) < uint64(pEnd) { + _sqlite3CorruptError(tls, int32(80911)) + return int32(1) + } + libc.X__builtin___memmove_chk(tls, pSlot, **(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8)), libc.Uint64FromInt32(sz), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up(pCellptr)) = libc.Uint8FromInt64((int64(pSlot) - int64(aData)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pCellptr + 1)) = libc.Uint8FromInt64(int64(pSlot) - int64(aData)) + pCellptr = pCellptr + uintptr(2) + i = i + 1 + if i >= iEnd { + break + } + if **(**int32)(__ccgo_up(pCArray + 80 + uintptr(k)*4)) <= i { + k = k + 1 + pEnd = **(**uintptr)(__ccgo_up(pCArray + 32 + uintptr(k)*8)) + } + } + **(**uintptr)(__ccgo_up(ppData)) = pData + return 0 +} + +// C documentation +// +// /* +// ** Obtain a reference to a memory mapped page object for page number pgno. +// ** The new object will use the pointer pData, obtained from xFetch(). +// ** If successful, set *ppPage to point to the new page reference +// ** and return SQLITE_OK. Otherwise, return an SQLite error code and set +// ** *ppPage to zero. +// ** +// ** Page references obtained by calling this function should be released +// ** by calling pagerReleaseMapPage(). +// */ +func _pagerAcquireMapPage(tls *libc.TLS, pPager uintptr, pgno TPgno, pData uintptr, ppPage uintptr) (r int32) { + var p, v1 uintptr + _, _ = p, v1 /* Memory mapped page to return */ + if (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist != 0 { + v1 = (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist + p = v1 + **(**uintptr)(__ccgo_up(ppPage)) = v1 + (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + (*TPgHdr)(unsafe.Pointer(p)).FpDirty = uintptr(0) + libc.X__builtin___memset_chk(tls, (*TPgHdr)(unsafe.Pointer(p)).FpExtra, 0, uint64(8), ^t__predefined_size_t(0)) + } else { + v1 = _sqlite3MallocZero(tls, uint64(80)+uint64((*TPager)(unsafe.Pointer(pPager)).FnExtra)) + p = v1 + **(**uintptr)(__ccgo_up(ppPage)) = v1 + if p == uintptr(0) { + _sqlite3OsUnfetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1))*(*TPager)(unsafe.Pointer(pPager)).FpageSize, pData) + return int32(SQLITE_NOMEM) + } + (*TPgHdr)(unsafe.Pointer(p)).FpExtra = p + 1*80 + (*TPgHdr)(unsafe.Pointer(p)).Fflags = uint16(PGHDR_MMAP) + (*TPgHdr)(unsafe.Pointer(p)).FnRef = int64(1) + (*TPgHdr)(unsafe.Pointer(p)).FpPager = pPager + } + (*TPgHdr)(unsafe.Pointer(p)).Fpgno = pgno + (*TPgHdr)(unsafe.Pointer(p)).FpData = pData + (*TPager)(unsafe.Pointer(pPager)).FnMmapOut = (*TPager)(unsafe.Pointer(pPager)).FnMmapOut + 1 + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Check that there are at least nSavepoint savepoints open. If there are +// ** currently less than nSavepoints open, then open one or more savepoints +// ** to make up the difference. If the number of savepoints is already +// ** equal to nSavepoint, then this function is a no-op. +// ** +// ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error +// ** occurs while opening the sub-journal file, then an IO error code is +// ** returned. Otherwise, SQLITE_OK. +// */ +func _pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) (r int32) { + var aNew uintptr + var ii, nCurrent, rc int32 + _, _, _, _ = aNew, ii, nCurrent, rc + rc = SQLITE_OK /* Return code */ + nCurrent = (*TPager)(unsafe.Pointer(pPager)).FnSavepoint /* New Pager.aSavepoint array */ + /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM + ** if the allocation fails. Otherwise, zero the new portion in case a + ** malloc failure occurs while populating it in the for(...) loop below. + */ + aNew = _sqlite3Realloc(tls, (*TPager)(unsafe.Pointer(pPager)).FaSavepoint, uint64(uint64(56)*libc.Uint64FromInt32(nSavepoint))) + if !(aNew != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, aNew+uintptr(nCurrent)*56, 0, libc.Uint64FromInt32(nSavepoint-nCurrent)*uint64(56), ^t__predefined_size_t(0)) + (*TPager)(unsafe.Pointer(pPager)).FaSavepoint = aNew + /* Populate the PagerSavepoint structures just allocated. */ + ii = nCurrent + for { + if !(ii < nSavepoint) { + break + } + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FnOrig = (*TPager)(unsafe.Pointer(pPager)).FdbSize + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) && (*TPager)(unsafe.Pointer(pPager)).FjournalOff > 0 { + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FiOffset = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + } else { + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FiOffset = libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) + } + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FiSubRec = (*TPager)(unsafe.Pointer(pPager)).FnSubRec + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FpInSavepoint = _sqlite3BitvecCreate(tls, (*TPager)(unsafe.Pointer(pPager)).FdbSize) + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FbTruncateOnRelease = int32(1) + if !((**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FpInSavepoint != 0) { + return int32(SQLITE_NOMEM) + } + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + _sqlite3WalSavepoint(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, aNew+uintptr(ii)*56+36) + } + (*TPager)(unsafe.Pointer(pPager)).FnSavepoint = ii + int32(1) + goto _1 + _1: + ; + ii = ii + 1 + } + return rc +} + +// C documentation +// +// /* +// ** This routine is called to increment the value of the database file +// ** change-counter, stored as a 4-byte big-endian integer starting at +// ** byte offset 24 of the pager file. The secondary change counter at +// ** 92 is also updated, as is the SQLite version number at offset 96. +// ** +// ** But this only happens if the pPager->changeCountDone flag is false. +// ** To avoid excess churning of page 1, the update only happens once. +// ** See also the pager_write_changecounter() routine that does an +// ** unconditional update of the change counters. +// ** +// ** If the isDirectMode flag is zero, then this is done by calling +// ** sqlite3PagerWrite() on page 1, then modifying the contents of the +// ** page data. In this case the file will be updated when the current +// ** transaction is committed. +// ** +// ** The isDirectMode flag may only be non-zero if the library was compiled +// ** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case, +// ** if isDirect is non-zero, then the database file is updated directly +// ** by writing an updated version of page 1 using a call to the +// ** sqlite3OsWrite() function. +// */ +func _pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pCopy, zBuf uintptr + var rc int32 + var _ /* pPgHdr at bp+0 */ uintptr + _, _, _ = pCopy, rc, zBuf + rc = SQLITE_OK + /* Declare and initialize constant integer 'isDirect'. If the + ** atomic-write optimization is enabled in this build, then isDirect + ** is initialized to the value passed as the isDirectMode parameter + ** to this function. Otherwise, it is always set to zero. + ** + ** The idea is that if the atomic-write optimization is not + ** enabled at compile time, the compiler can omit the tests of + ** 'isDirect' below, as well as the block enclosed in the + ** "if( isDirect )" condition. + */ + _ = isDirectMode + if !((*TPager)(unsafe.Pointer(pPager)).FchangeCountDone != 0) && (*TPager)(unsafe.Pointer(pPager)).FdbSize > uint32(0) { /* Reference to page 1 */ + /* Open page 1 of the file for writing. */ + rc = _sqlite3PagerGet(tls, pPager, uint32(1), bp, 0) + /* If page one was fetched successfully, and this function is not + ** operating in direct-mode, make page 1 writable. When not in + ** direct mode, page 1 is always held in cache and hence the PagerGet() + ** above is always successful - hence the ALWAYS on rc==SQLITE_OK. + */ + if libc.Bool(!(libc.Int32FromInt32(DIRECT_MODE) != 0)) && rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp))) + } + if rc == SQLITE_OK { + /* Actually do the update of the change counter */ + _pager_write_changecounter(tls, **(**uintptr)(__ccgo_up(bp))) + /* If running in direct mode, write the contents of page 1 to the file. */ + if DIRECT_MODE != 0 { + zBuf = (*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpData + if rc == SQLITE_OK { + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, zBuf, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), 0) + **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) = **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) + 1 + } + if rc == SQLITE_OK { + /* Update the pager's copy of the change-counter. Otherwise, the + ** next time a read transaction is opened the cache will be + ** flushed (as the change-counter values will not match). */ + pCopy = zBuf + 24 + libc.X__builtin___memcpy_chk(tls, pPager+136, pCopy, uint64(16), ^t__predefined_size_t(0)) + (*TPager)(unsafe.Pointer(pPager)).FchangeCountDone = uint8(1) + } + } else { + (*TPager)(unsafe.Pointer(pPager)).FchangeCountDone = uint8(1) + } + } + /* Release the page reference. */ + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Playback the journal and thus restore the database file to +// ** the state it was in before we started making changes. +// ** +// ** The journal file format is as follows: +// ** +// ** (1) 8 byte prefix. A copy of aJournalMagic[]. +// ** (2) 4 byte big-endian integer which is the number of valid page records +// ** in the journal. If this value is 0xffffffff, then compute the +// ** number of page records from the journal size. +// ** (3) 4 byte big-endian integer which is the initial value for the +// ** sanity checksum. +// ** (4) 4 byte integer which is the number of pages to truncate the +// ** database to during a rollback. +// ** (5) 4 byte big-endian integer which is the sector size. The header +// ** is this many bytes in size. +// ** (6) 4 byte big-endian integer which is the page size. +// ** (7) zero padding out to the next sector size. +// ** (8) Zero or more pages instances, each as follows: +// ** + 4 byte page number. +// ** + pPager->pageSize bytes of data. +// ** + 4 byte checksum +// ** +// ** When we speak of the journal header, we mean the first 7 items above. +// ** Each entry in the journal is an instance of the 8th item. +// ** +// ** Call the value from the second bullet "nRec". nRec is the number of +// ** valid page entries in the journal. In most cases, you can compute the +// ** value of nRec from the size of the journal file. But if a power +// ** failure occurred while the journal was being written, it could be the +// ** case that the size of the journal file had already been increased but +// ** the extra entries had not yet made it safely to disk. In such a case, +// ** the value of nRec computed from the file size would be too large. For +// ** that reason, we always use the nRec value in the header. +// ** +// ** If the nRec value is 0xffffffff it means that nRec should be computed +// ** from the file size. This value is used when the user selects the +// ** no-sync option for the journal. A power failure could lead to corruption +// ** in this case. But for things like temporary table (which will be +// ** deleted when the power is restored) we don't care. +// ** +// ** If the file opened as the journal file is not a well-formed +// ** journal file then all pages up to the first corrupted page are rolled +// ** back (or no pages if the journal header is corrupted). The journal file +// ** is then deleted and SQLITE_OK returned, just as if no corruption had +// ** been encountered. +// ** +// ** If an I/O or malloc() error occurs, the journal-file is not deleted +// ** and an error code is returned. +// ** +// ** The isHot parameter indicates that we are trying to rollback a journal +// ** that might be a hot journal. Or, it could be that the journal is +// ** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE. +// ** If the journal really is hot, reset the pager cache prior rolling +// ** back any content. If the journal is merely persistent, no reset is +// ** needed. +// */ +func _pager_playback(tls *libc.TLS, pPager uintptr, isHot int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var nPlayback, needPagerReset, rc int32 + var pVfs, zSuper uintptr + var u Tu32 + var _ /* mxPg at bp+12 */ TPgno + var _ /* nRec at bp+8 */ Tu32 + var _ /* res at bp+16 */ int32 + var _ /* savedPageSize at bp+20 */ Tu32 + var _ /* szJ at bp+0 */ Ti64 + _, _, _, _, _, _ = nPlayback, needPagerReset, pVfs, rc, u, zSuper + pVfs = (*TPager)(unsafe.Pointer(pPager)).FpVfs /* Unsigned loop counter */ + **(**TPgno)(__ccgo_up(bp + 12)) = uint32(0) /* Result code of a subroutine */ + **(**int32)(__ccgo_up(bp + 16)) = int32(1) /* Value returned by sqlite3OsAccess() */ + zSuper = uintptr(0) /* True to reset page prior to first page rollback */ + nPlayback = 0 /* Total number of pages restored from journal */ + **(**Tu32)(__ccgo_up(bp + 20)) = libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) + /* Figure out how many records are in the journal. Abort early if + ** the journal is empty. + */ + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp) + if rc != SQLITE_OK { + goto end_playback + } + /* Read the super-journal name from the journal, if it is present. + ** If a super-journal file name is specified, but the file is not + ** present on disk, then the journal is not hot and does not need to be + ** played back. + ** + ** TODO: Technically the following is an error because it assumes that + ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that + ** ((pPager->pageSize+8) >= pPager->pVfs->mxPathname+1). Using os_unix.c, + ** mxPathname is 512, which is the same as the minimum allowable value + ** for pageSize, and so this assumption holds. But it might not for some + ** custom VFS. */ + zSuper = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace + rc = _readSuperJournal(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, zSuper, libc.Uint64FromInt64(int64(1)+int64((*Tsqlite3_vfs)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).FpVfs)).FmxPathname))) + if rc == SQLITE_OK && **(**int8)(__ccgo_up(zSuper)) != 0 { + rc = _sqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+16) + } + zSuper = uintptr(0) + if rc != SQLITE_OK || !(**(**int32)(__ccgo_up(bp + 16)) != 0) { + goto end_playback + } + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + needPagerReset = isHot + /* This loop terminates either when a readJournalHdr() or + ** pager_playback_one_page() call returns SQLITE_DONE or an IO error + ** occurs. + */ + for int32(1) != 0 { + /* Read the next journal header from the journal file. If there are + ** not enough bytes left in the journal file for a complete header, or + ** it is corrupted, then a process must have failed while writing it. + ** This indicates nothing more needs to be rolled back. + */ + rc = _readJournalHdr(tls, pPager, isHot, **(**Ti64)(__ccgo_up(bp)), bp+8, bp+12) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + goto end_playback + } + /* If nRec is 0xffffffff, then this journal was created by a process + ** working in no-sync mode. This means that the rest of the journal + ** file consists of pages, there are no more journal headers. Compute + ** the value of nRec based on this assumption. + */ + if **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0xffffffff) { + **(**Tu32)(__ccgo_up(bp + 8)) = libc.Uint32FromInt32(int32((**(**Ti64)(__ccgo_up(bp)) - libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize)) / ((*TPager)(unsafe.Pointer(pPager)).FpageSize + libc.Int64FromInt32(8)))) + } + /* If nRec is 0 and this rollback is of a transaction created by this + ** process and if this is the final header in the journal, then it means + ** that this part of the journal was being filled but has not yet been + ** synced to disk. Compute the number of pages based on the remaining + ** size of the file. + ** + ** The third term of the test was added to fix ticket #2565. + ** When rolling back a hot journal, nRec==0 always means that the next + ** chunk of the journal contains zero pages to be rolled back. But + ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in + ** the journal, it means that the journal might contain additional + ** pages that need to be rolled back and that the number of pages + ** should be computed based on the journal file size. + */ + if **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0) && !(isHot != 0) && (*TPager)(unsafe.Pointer(pPager)).FjournalHdr+libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) == (*TPager)(unsafe.Pointer(pPager)).FjournalOff { + **(**Tu32)(__ccgo_up(bp + 8)) = libc.Uint32FromInt32(int32((**(**Ti64)(__ccgo_up(bp)) - (*TPager)(unsafe.Pointer(pPager)).FjournalOff) / ((*TPager)(unsafe.Pointer(pPager)).FpageSize + libc.Int64FromInt32(8)))) + } + /* If this is the first header read from the journal, truncate the + ** database file back to its original size. + */ + if (*TPager)(unsafe.Pointer(pPager)).FjournalOff == libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) { + rc = _pager_truncate(tls, pPager, **(**TPgno)(__ccgo_up(bp + 12))) + if rc != SQLITE_OK { + goto end_playback + } + (*TPager)(unsafe.Pointer(pPager)).FdbSize = **(**TPgno)(__ccgo_up(bp + 12)) + if (*TPager)(unsafe.Pointer(pPager)).FmxPgno < **(**TPgno)(__ccgo_up(bp + 12)) { + (*TPager)(unsafe.Pointer(pPager)).FmxPgno = **(**TPgno)(__ccgo_up(bp + 12)) + } + } + /* Copy original pages out of the journal and back into the + ** database file and/or page cache. + */ + u = uint32(0) + for { + if !(u < **(**Tu32)(__ccgo_up(bp + 8))) { + break + } + if needPagerReset != 0 { + _pager_reset(tls, pPager) + needPagerReset = 0 + } + rc = _pager_playback_one_page(tls, pPager, pPager+96, uintptr(0), int32(1), 0) + if rc == SQLITE_OK { + nPlayback = nPlayback + 1 + } else { + if rc == int32(SQLITE_DONE) { + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = **(**Ti64)(__ccgo_up(bp)) + break + } else { + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)<= int32(PAGER_WRITER_DBMOD) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) { + rc = _sqlite3PagerSync(tls, pPager, uintptr(0)) + } + if rc == SQLITE_OK { + rc = _pager_end_transaction(tls, pPager, libc.BoolInt32(int32(**(**int8)(__ccgo_up(zSuper))) != int32('\000')), 0) + } + if rc == SQLITE_OK && **(**int8)(__ccgo_up(zSuper)) != 0 && **(**int32)(__ccgo_up(bp + 16)) != 0 { + /* If there was a super-journal and this routine will return success, + ** see if it is possible to delete the super-journal. + */ + libc.X__builtin___memset_chk(tls, (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace, 0, uint64(4), ^t__predefined_size_t(0)) + rc = _pager_delsuper(tls, pPager, zSuper) + } + if isHot != 0 && nPlayback != 0 { + Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_NOTICE)|libc.Int32FromInt32(2)< (*TPager)(unsafe.Pointer(pPager)).FdbSize || _sqlite3BitvecTest(tls, pDone, **(**TPgno)(__ccgo_up(bp + 8))) != 0 { + return SQLITE_OK + } + if isMainJrnl != 0 { + rc = _read32bits(tls, jfd, **(**Ti64)(__ccgo_up(pOffset))-int64(4), bp+12) + if rc != 0 { + return rc + } + if !(isSavepnt != 0) && _pager_cksum(tls, pPager, aData) != **(**Tu32)(__ccgo_up(bp + 12)) { + return int32(SQLITE_DONE) + } + } + /* If this page has already been played back before during the current + ** rollback, then don't bother to play it back again. + */ + if v3 = pDone != 0; v3 { + v2 = _sqlite3BitvecSet(tls, pDone, **(**TPgno)(__ccgo_up(bp + 8))) + rc = v2 + } + if v3 && v2 != SQLITE_OK { + return rc + } + /* When playing back page 1, restore the nReserve setting + */ + if **(**TPgno)(__ccgo_up(bp + 8)) == uint32(1) && int32((*TPager)(unsafe.Pointer(pPager)).FnReserve) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + 20))) { + (*TPager)(unsafe.Pointer(pPager)).FnReserve = libc.Int16FromUint8(**(**Tu8)(__ccgo_up(aData + 20))) + } + /* If the pager is in CACHEMOD state, then there must be a copy of this + ** page in the pager cache. In this case just update the pager cache, + ** not the database file. The page is left marked dirty in this case. + ** + ** An exception to the above rule: If the database is in no-sync mode + ** and a page is moved during an incremental vacuum then the page may + ** not be in the pager cache. Later: if a malloc() or IO error occurs + ** during a Movepage() call, then the page may not be in the cache + ** either. So the condition described in the above paragraph is not + ** assert()able. + ** + ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the + ** pager cache if it exists and the main file. The page is then marked + ** not dirty. Since this code is only executed in PAGER_OPEN state for + ** a hot-journal rollback, it is guaranteed that the page-cache is empty + ** if the pager is in OPEN state. + ** + ** Ticket #1171: The statement journal might contain page content that is + ** different from the page content at the start of the transaction. + ** This occurs when a page is changed prior to the start of a statement + ** then changed again within the statement. When rolling back such a + ** statement we must not write to the original database unless we know + ** for certain that original page contents are synced into the main rollback + ** journal. Otherwise, a power loss might leave modified data in the + ** database file without an entry in the rollback journal that can + ** restore the database to its original form. Two conditions must be + ** met before writing to the database files. (1) the database must be + ** locked. (2) we know that the original page content is fully synced + ** in the main journal either because the page is not in cache or else + ** the page is marked as needSync==0. + ** + ** 2008-04-14: When attempting to vacuum a corrupt database file, it + ** is possible to fail a statement on a database that does not yet exist. + ** Do not attempt to write if database file has never been opened. + */ + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + **(**uintptr)(__ccgo_up(bp)) = _sqlite3PagerLookup(tls, pPager, **(**TPgno)(__ccgo_up(bp + 8))) + } + if isMainJrnl != 0 { + isSynced = libc.BoolInt32((*TPager)(unsafe.Pointer(pPager)).FnoSync != 0 || **(**Ti64)(__ccgo_up(pOffset)) <= (*TPager)(unsafe.Pointer(pPager)).FjournalHdr) + } else { + isSynced = libc.BoolInt32(**(**uintptr)(__ccgo_up(bp)) == uintptr(0) || 0 == libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fflags)&int32(PGHDR_NEED_SYNC)) + } + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) && (libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) >= int32(PAGER_WRITER_DBMOD) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) && isSynced != 0 { + ofst = libc.Int64FromUint32(**(**TPgno)(__ccgo_up(bp + 8))-libc.Uint32FromInt32(1)) * (*TPager)(unsafe.Pointer(pPager)).FpageSize + /* Write the data read from the journal back into the database file. + ** This is usually safe even for an encrypted database - as the data + ** was encrypted before it was written to the journal file. The exception + ** is if the data was just read from an in-memory sub-journal. In that + ** case it must be encrypted here before it is copied into the database + ** file. */ + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, aData, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), ofst) + if **(**TPgno)(__ccgo_up(bp + 8)) > (*TPager)(unsafe.Pointer(pPager)).FdbFileSize { + (*TPager)(unsafe.Pointer(pPager)).FdbFileSize = **(**TPgno)(__ccgo_up(bp + 8)) + } + if (*TPager)(unsafe.Pointer(pPager)).FpBackup != 0 { + _sqlite3BackupUpdate(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup, **(**TPgno)(__ccgo_up(bp + 8)), aData) + } + } else { + if !(isMainJrnl != 0) && **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + /* If this is a rollback of a savepoint and data was not written to + ** the database and the page is not in-memory, there is a potential + ** problem. When the page is next fetched by the b-tree layer, it + ** will be read from the database file, which may or may not be + ** current. + ** + ** There are a couple of different ways this can happen. All are quite + ** obscure. When running in synchronous mode, this can only happen + ** if the page is on the free-list at the start of the transaction, then + ** populated, then moved using sqlite3PagerMovepage(). + ** + ** The solution is to add an in-memory page to the cache containing + ** the data just read from the sub-journal. Mark the page as dirty + ** and if the pager requires a journal-sync, then mark the page as + ** requiring a journal-sync before it is written. + */ + v1 = pPager + 25 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SPILLFLAG_ROLLBACK)) + rc = _sqlite3PagerGet(tls, pPager, **(**TPgno)(__ccgo_up(bp + 8)), bp, int32(1)) + v1 = pPager + 25 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(SPILLFLAG_ROLLBACK)) + if rc != SQLITE_OK { + return rc + } + _sqlite3PcacheMakeDirty(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + if **(**uintptr)(__ccgo_up(bp)) != 0 { + pData = (*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpData + libc.X__builtin___memcpy_chk(tls, pData, aData, libc.Uint64FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize), ^t__predefined_size_t(0)) + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TPager)(unsafe.Pointer(pPager)).FxReiniter})))(tls, **(**uintptr)(__ccgo_up(bp))) + /* It used to be that sqlite3PcacheMakeClean(pPg) was called here. But + ** that call was dangerous and had no detectable benefit since the cache + ** is normally cleaned by sqlite3PcacheCleanAll() after rollback and so + ** has been removed. */ + /* If this was page 1, then restore the value of Pager.dbFileVers. + ** Do this before any decoding. */ + if **(**TPgno)(__ccgo_up(bp + 8)) == uint32(1) { + libc.X__builtin___memcpy_chk(tls, pPager+136, pData+24, uint64(16), ^t__predefined_size_t(0)) + } + _sqlite3PcacheRelease(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** This function is used to change the actual size of the database +// ** file in the file-system. This only happens when committing a transaction, +// ** or rolling back a transaction (including rolling back a hot-journal). +// ** +// ** If the main database file is not open, or the pager is not in either +// ** DBMOD or OPEN state, this function is a no-op. Otherwise, the size +// ** of the file is changed to nPage pages (nPage*pPager->pageSize bytes). +// ** If the file on disk is currently larger than nPage pages, then use the VFS +// ** xTruncate() method to truncate it. +// ** +// ** Or, it might be the case that the file on disk is smaller than +// ** nPage pages. Some operating system implementations can get confused if +// ** you try to truncate a file to some size that is larger than it +// ** currently is, so detect this case and write a single zero byte to +// ** the end of the new file instead. +// ** +// ** If successful, return SQLITE_OK. If an IO error occurs while modifying +// ** the database file, return the error code to the caller. +// */ +func _pager_truncate(tls *libc.TLS, pPager uintptr, nPage TPgno) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pTmp uintptr + var rc, szPage int32 + var _ /* currentSize at bp+0 */ Ti64 + var _ /* newSize at bp+8 */ Ti64 + _, _, _ = pTmp, rc, szPage + rc = SQLITE_OK + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) && (libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) >= int32(PAGER_WRITER_DBMOD) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) { + szPage = int32((*TPager)(unsafe.Pointer(pPager)).FpageSize) + /* TODO: Is it safe to use Pager.dbFileSize here? */ + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, bp) + **(**Ti64)(__ccgo_up(bp + 8)) = int64(szPage) * libc.Int64FromUint32(nPage) + if rc == SQLITE_OK && **(**Ti64)(__ccgo_up(bp)) != **(**Ti64)(__ccgo_up(bp + 8)) { + if **(**Ti64)(__ccgo_up(bp)) > **(**Ti64)(__ccgo_up(bp + 8)) { + rc = _sqlite3OsTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, **(**Ti64)(__ccgo_up(bp + 8))) + } else { + if **(**Ti64)(__ccgo_up(bp))+int64(szPage) <= **(**Ti64)(__ccgo_up(bp + 8)) { + pTmp = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace + libc.X__builtin___memset_chk(tls, pTmp, 0, libc.Uint64FromInt32(szPage), ^t__predefined_size_t(0)) + _sqlite3OsFileControlHint(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_SIZE_HINT), bp+8) + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, pTmp, szPage, **(**Ti64)(__ccgo_up(bp + 8))-int64(szPage)) + } + } + if rc == SQLITE_OK { + (*TPager)(unsafe.Pointer(pPager)).FdbFileSize = nPage + } + } + } + return rc +} + +// C documentation +// +// /* +// ** The argument is the first in a linked list of dirty pages connected +// ** by the PgHdr.pDirty pointer. This function writes each one of the +// ** in-memory pages in the list to the database file. The argument may +// ** be NULL, representing an empty list. In this case this function is +// ** a no-op. +// ** +// ** The pager must hold at least a RESERVED lock when this function +// ** is called. Before writing anything to the database file, this lock +// ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained, +// ** SQLITE_BUSY is returned and no data is written to the database file. +// ** +// ** If the pager is a temp-file pager and the actual file-system file +// ** is not yet open, it is created and opened before any data is +// ** written out. +// ** +// ** Once the lock has been upgraded and, if necessary, the file opened, +// ** the pages are written out to the database file in list order. Writing +// ** a page is skipped if it meets either of the following criteria: +// ** +// ** * The page number is greater than Pager.dbSize, or +// ** * The PGHDR_DONT_WRITE flag is set on the page. +// ** +// ** If writing out a page causes the database file to grow, Pager.dbFileSize +// ** is updated accordingly. If page 1 is written out, then the value cached +// ** in Pager.dbFileVers[] is updated to match the new value stored in +// ** the database file. +// ** +// ** If everything is successful, SQLITE_OK is returned. If an IO error +// ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot +// ** be obtained, SQLITE_BUSY is returned. +// */ +func _pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var offset Ti64 + var pData uintptr + var pgno TPgno + var rc int32 + var _ /* szFile at bp+0 */ Tsqlite3_int64 + _, _, _, _ = offset, pData, pgno, rc + rc = SQLITE_OK /* Return code */ + /* This function is only called for rollback pagers in WRITER_DBMOD state. */ + /* If the file is a temp-file has not yet been opened, open it now. It + ** is not possible for rc to be other than SQLITE_OK if this branch + ** is taken, as pager_wait_on_lock() is a no-op for temp-files. + */ + if !((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != libc.UintptrFromInt32(0)) { + rc = _pagerOpentemp(tls, pPager, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int32FromUint32((*TPager)(unsafe.Pointer(pPager)).FvfsFlags)) + } + /* Before the first write, give the VFS a hint of what the final + ** file size will be. + */ + if rc == SQLITE_OK && (*TPager)(unsafe.Pointer(pPager)).FdbHintSize < (*TPager)(unsafe.Pointer(pPager)).FdbSize && ((*TPgHdr)(unsafe.Pointer(pList)).FpDirty != 0 || (*TPgHdr)(unsafe.Pointer(pList)).Fpgno > (*TPager)(unsafe.Pointer(pPager)).FdbHintSize) { + **(**Tsqlite3_int64)(__ccgo_up(bp)) = (*TPager)(unsafe.Pointer(pPager)).FpageSize * libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FdbSize) + _sqlite3OsFileControlHint(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_SIZE_HINT), bp) + (*TPager)(unsafe.Pointer(pPager)).FdbHintSize = (*TPager)(unsafe.Pointer(pPager)).FdbSize + } + for rc == SQLITE_OK && pList != 0 { + pgno = (*TPgHdr)(unsafe.Pointer(pList)).Fpgno + /* If there are dirty pages in the page cache with page numbers greater + ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to + ** make the file smaller (presumably by auto-vacuum code). Do not write + ** any such pages to the file. + ** + ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag + ** set (set by sqlite3PagerDontWrite()). + */ + if pgno <= (*TPager)(unsafe.Pointer(pPager)).FdbSize && 0 == libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pList)).Fflags)&int32(PGHDR_DONT_WRITE) { + offset = libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1)) * (*TPager)(unsafe.Pointer(pPager)).FpageSize /* Data to write */ + if (*TPgHdr)(unsafe.Pointer(pList)).Fpgno == uint32(1) { + _pager_write_changecounter(tls, pList) + } + pData = (*TPgHdr)(unsafe.Pointer(pList)).FpData + /* Write out the page data. */ + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, pData, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), offset) + /* If page 1 was just written, update Pager.dbFileVers to match + ** the value now stored in the database file. If writing this + ** page caused the database file to grow, update dbFileSize. + */ + if pgno == uint32(1) { + libc.X__builtin___memcpy_chk(tls, pPager+136, pData+24, uint64(16), ^t__predefined_size_t(0)) + } + if pgno > (*TPager)(unsafe.Pointer(pPager)).FdbFileSize { + (*TPager)(unsafe.Pointer(pPager)).FdbFileSize = pgno + } + **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) = **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) + 1 + /* Update any backup objects copying the contents of this pager. */ + _sqlite3BackupUpdate(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup, pgno, (*TPgHdr)(unsafe.Pointer(pList)).FpData) + } else { + } + pList = (*TPgHdr)(unsafe.Pointer(pList)).FpDirty + } + return rc +} + +// C documentation +// +// /* +// ** Process a modifier to a date-time stamp. The modifiers are +// ** as follows: +// ** +// ** NNN days +// ** NNN hours +// ** NNN minutes +// ** NNN.NNNN seconds +// ** NNN months +// ** NNN years +// ** +/-YYYY-MM-DD HH:MM:SS.SSS +// ** ceiling +// ** floor +// ** start of month +// ** start of year +// ** start of week +// ** start of day +// ** weekday N +// ** unixepoch +// ** auto +// ** localtime +// ** utc +// ** subsec +// ** subsecond +// ** +// ** Return 0 on success and 1 if there is any kind of error. If the error +// ** is in a system call (i.e. localtime()), then an error message is written +// ** to context pCtx. If the error is an unrecognized modifier, no error is +// ** written to pCtx. +// */ +func _parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr, idx int32) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var Z, day Tsqlite3_int64 + var cnt, i, rc, rx, x, y, v1 int32 + var db, z2, zCopy uintptr + var iErr, iGuess, iOrigJD, v2 Ti64 + var rRounder, v11 float64 + var z0 int8 + var v4 bool + var _ /* D at bp+64 */ int32 + var _ /* M at bp+60 */ int32 + var _ /* Y at bp+56 */ int32 + var _ /* h at bp+68 */ int32 + var _ /* m at bp+72 */ int32 + var _ /* new at bp+8 */ TDateTime + var _ /* r at bp+0 */ float64 + var _ /* tx at bp+80 */ TDateTime + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = Z, cnt, day, db, i, iErr, iGuess, iOrigJD, rRounder, rc, rx, x, y, z0, z2, zCopy, v1, v11, v2, v4 + rc = int32(1) + switch libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z)))]) { + case int32('a'): + /* + ** auto + ** + ** If rawS is available, then interpret as a julian day number, or + ** a unix timestamp, depending on its magnitude. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1270) == 0 { + if idx > int32(1) { + return int32(1) + } /* IMP: R-33611-57934 */ + _autoAdjustDate(tls, p) + rc = 0 + } + case int32('c'): + /* + ** ceiling + ** + ** Resolve day-of-month overflow by rolling forward into the next + ** month. As this is the default action, this modifier is really + ** a no-op that is only included for symmetry. See "floor". + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1275) == 0 { + _computeJD(tls, p) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + (*TDateTime)(unsafe.Pointer(p)).FnFloor = 0 + } + case int32('f'): + /* + ** floor + ** + ** Resolve day-of-month overflow by rolling back to the end of the + ** previous month. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1283) == 0 { + _computeJD(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) -= int64(int32((*TDateTime)(unsafe.Pointer(p)).FnFloor) * int32(86400000)) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + } + case int32('j'): + /* + ** julianday + ** + ** Always interpret the prior number as a julian-day value. If this + ** is not the first modifier, or if the prior argument is not a numeric + ** value in the allowed range of julian day numbers understood by + ** SQLite (0..5373484.5) then the result will be NULL. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1289) == 0 { + if idx > int32(1) { + return int32(1) + } /* IMP: R-31176-64601 */ + if (*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0 && int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { + rc = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + } + } + case int32('l'): + /* localtime + ** + ** Assuming the current time value is UTC (a.k.a. GMT), shift it to + ** show local time. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1299) == 0 && _sqlite3NotPureFunc(tls, pCtx) != 0 { + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x10>>4)) != 0 { + v1 = SQLITE_OK + } else { + v1 = _toLocaltime(tls, p, pCtx) + } + rc = v1 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 4, 0x10) + } + case int32('u'): + /* + ** unixepoch + ** + ** Treat the current value of p->s as the number of + ** seconds since 1970. Convert to a real julian day number. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1309) == 0 && int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { + if idx > int32(1) { + return int32(1) + } /* IMP: R-49255-55373 */ + **(**float64)(__ccgo_up(bp)) = float64((*TDateTime)(unsafe.Pointer(p)).Fs*float64(1000)) + float64(2.1086676e+14) + if **(**float64)(__ccgo_up(bp)) >= float64(0) && **(**float64)(__ccgo_up(bp)) < float64(4.642690608e+14) { + _clearYMD_HMS_TZ(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(**(**float64)(__ccgo_up(bp)) + libc.Float64FromFloat64(0.5)) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = int8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + rc = 0 + } + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1319) == 0 && _sqlite3NotPureFunc(tls, pCtx) != 0 { + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x8>>3)) == 0 { /* Guess at the corresponding utc time */ + cnt = 0 /* Guess is off by this much */ + _computeJD(tls, p) + v2 = (*TDateTime)(unsafe.Pointer(p)).FiJD + iOrigJD = v2 + iGuess = v2 + iErr = 0 + for { + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(48), ^t__predefined_size_t(0)) + iGuess = iGuess - iErr + (**(**TDateTime)(__ccgo_up(bp + 8))).FiJD = iGuess + (**(**TDateTime)(__ccgo_up(bp + 8))).FvalidJD = int8(1) + rc = _toLocaltime(tls, bp+8, pCtx) + if rc != 0 { + return rc + } + _computeJD(tls, bp+8) + iErr = (**(**TDateTime)(__ccgo_up(bp + 8))).FiJD - iOrigJD + goto _5 + _5: + ; + if v4 = iErr != 0; v4 { + v1 = cnt + cnt = cnt + 1 + } + if !(v4 && v1 < int32(3)) { + break + } + } + libc.X__builtin___memset_chk(tls, p, 0, uint64(48), ^t__predefined_size_t(0)) + (*TDateTime)(unsafe.Pointer(p)).FiJD = iGuess + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = int8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + } + rc = SQLITE_OK + } + } + case int32('w'): + /* + ** weekday N + ** + ** Move the date to the same time on the next occurrence of + ** weekday N where 0==Sunday, 1==Monday, and so forth. If the + ** date is already on the appropriate weekday, this is a no-op. + */ + if v4 = Xsqlite3_strnicmp(tls, z, __ccgo_ts+1323, int32(8)) == 0 && _sqlite3AtoF(tls, z+8, bp) > 0 && **(**float64)(__ccgo_up(bp)) >= float64(0) && **(**float64)(__ccgo_up(bp)) < float64(7); v4 { + v1 = int32(**(**float64)(__ccgo_up(bp))) + n = v1 + } + if v4 && float64(v1) == **(**float64)(__ccgo_up(bp)) { + _computeYMD_HMS(tls, p) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + _computeJD(tls, p) + Z = ((*TDateTime)(unsafe.Pointer(p)).FiJD + int64(129600000)) / int64(86400000) % int64(7) + if Z > int64(n) { + Z = Z - int64(7) + } + **(**Tsqlite3_int64)(__ccgo_up(p)) += (int64(n) - Z) * int64(86400000) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + } + case int32('s'): + /* + ** start of TTTTT + ** + ** Move the date backwards to the beginning of the current day, + ** or month or year. + ** + ** subsecond + ** subsec + ** + ** Show subsecond precision in the output of datetime() and + ** unixepoch() and strftime('%s'). + */ + if Xsqlite3_strnicmp(tls, z, __ccgo_ts+1332, int32(9)) != 0 { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1230) == 0 || Xsqlite3_stricmp(tls, z, __ccgo_ts+1237) == 0 { + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 2, 0x4) + rc = 0 + } + break + } + if !((*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0) && !((*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0) && !((*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0) { + break + } + z = z + uintptr(9) + _computeYMD(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = int8(1) + v1 = libc.Int32FromInt32(0) + (*TDateTime)(unsafe.Pointer(p)).Fm = v1 + (*TDateTime)(unsafe.Pointer(p)).Fh = v1 + (*TDateTime)(unsafe.Pointer(p)).Fs = float64(0) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1342) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) + rc = 0 + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1348) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FM = int32(1) + (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) + rc = 0 + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1353) == 0 { + rc = 0 + } + } + } + case int32('+'): + fallthrough + case int32('-'): + fallthrough + case int32('0'): + fallthrough + case int32('1'): + fallthrough + case int32('2'): + fallthrough + case int32('3'): + fallthrough + case int32('4'): + fallthrough + case int32('5'): + fallthrough + case int32('6'): + fallthrough + case int32('7'): + fallthrough + case int32('8'): + fallthrough + case int32('9'): + z2 = z + db = Xsqlite3_context_db_handle(tls, pCtx) + z0 = **(**int8)(__ccgo_up(z)) + n = int32(1) + for { + if !(**(**int8)(__ccgo_up(z + uintptr(n))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(z + uintptr(n)))) == int32(':') { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(n))))])&int32(0x01) != 0 { + break + } + if int32(**(**int8)(__ccgo_up(z + uintptr(n)))) == int32('-') { + if n == int32(5) && _getDigits(tls, z+1, __ccgo_ts+1357, libc.VaList(bp+136, bp+56)) == int32(1) { + break + } + if n == int32(6) && _getDigits(tls, z+1, __ccgo_ts+1361, libc.VaList(bp+136, bp+56)) == int32(1) { + break + } + } + goto _9 + _9: + ; + n = n + 1 + } + zCopy = _sqlite3DbStrNDup(tls, db, z, libc.Uint64FromInt32(n)) + if zCopy == uintptr(0) { + break + } + rx = libc.BoolInt32(_sqlite3AtoF(tls, zCopy, bp) <= 0) + _sqlite3DbFree(tls, db, zCopy) + if rx != 0 { + break + } + if int32(**(**int8)(__ccgo_up(z + uintptr(n)))) == int32('-') { + /* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the + ** specified number of years, months, and days. MM is limited to + ** the range 0-11 and DD is limited to 0-30. + */ + if int32(z0) != int32('+') && int32(z0) != int32('-') { + break + } /* Must start with +/- */ + if n == int32(5) { + if _getDigits(tls, z+1, __ccgo_ts+1365, libc.VaList(bp+136, bp+56, bp+60, bp+64)) != int32(3) { + break + } + } else { + if _getDigits(tls, z+1, __ccgo_ts+1377, libc.VaList(bp+136, bp+56, bp+60, bp+64)) != int32(3) { + break + } + z = z + 1 + } + if **(**int32)(__ccgo_up(bp + 60)) >= int32(12) { + break + } /* M range 0..11 */ + if **(**int32)(__ccgo_up(bp + 64)) >= int32(31) { + break + } /* D range 0..30 */ + _computeYMD_HMS(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + if int32(z0) == int32('-') { + **(**int32)(__ccgo_up(p + 8)) -= **(**int32)(__ccgo_up(bp + 56)) + **(**int32)(__ccgo_up(p + 12)) -= **(**int32)(__ccgo_up(bp + 60)) + **(**int32)(__ccgo_up(bp + 64)) = -**(**int32)(__ccgo_up(bp + 64)) + } else { + **(**int32)(__ccgo_up(p + 8)) += **(**int32)(__ccgo_up(bp + 56)) + **(**int32)(__ccgo_up(p + 12)) += **(**int32)(__ccgo_up(bp + 60)) + } + if (*TDateTime)(unsafe.Pointer(p)).FM > 0 { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(1)) / int32(12) + } else { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(12)) / int32(12) + } + x = v1 + **(**int32)(__ccgo_up(p + 8)) += x + **(**int32)(__ccgo_up(p + 12)) -= x * int32(12) + _computeFloor(tls, p) + _computeJD(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = 0 + **(**Tsqlite3_int64)(__ccgo_up(p)) += int64(**(**int32)(__ccgo_up(bp + 64))) * int64(86400000) + if int32(**(**int8)(__ccgo_up(z + 11))) == 0 { + rc = 0 + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + 11)))])&int32(0x01) != 0 && _getDigits(tls, z+12, __ccgo_ts+1202, libc.VaList(bp+136, bp+68, bp+72)) == int32(2) { + z2 = z + 12 + n = int32(2) + } else { + break + } + } + if int32(**(**int8)(__ccgo_up(z2 + uintptr(n)))) == int32(':') { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z2)))])&libc.Int32FromInt32(0x04) != 0) { + z2 = z2 + 1 + } + libc.X__builtin___memset_chk(tls, bp+80, 0, uint64(48), ^t__predefined_size_t(0)) + if _parseHhMmSs(tls, z2, bp+80) != 0 { + break + } + _computeJD(tls, bp+80) + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD -= int64(43200000) + day = (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD / int64(86400000) + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD -= day * int64(86400000) + if int32(z0) == int32('-') { + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD = -(**(**TDateTime)(__ccgo_up(bp + 80))).FiJD + } + _computeJD(tls, p) + _clearYMD_HMS_TZ(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) += (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD + rc = 0 + break + } + /* If control reaches this point, it means the transformation is + ** one of the forms like "+NNN days". */ + z = z + uintptr(n) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z)))])&int32(0x01) != 0 { + z = z + 1 + } + n = _sqlite3Strlen30(tls, z) + if n < int32(3) || n > int32(10) { + break + } + if libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(n-int32(1)))))]) == int32('s') { + n = n - 1 + } + _computeJD(tls, p) + if **(**float64)(__ccgo_up(bp)) < libc.Float64FromInt32(0) { + v11 = -libc.Float64FromFloat64(0.5) + } else { + v11 = +libc.Float64FromFloat64(0.5) + } + rRounder = v11 + (*TDateTime)(unsafe.Pointer(p)).FnFloor = 0 + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(96)/libc.Uint64FromInt64(16))) { + break + } + if libc.Int32FromUint8(_aXformType[i].FnName) == n && Xsqlite3_strnicmp(tls, uintptr(unsafe.Pointer(&_aXformType))+uintptr(i)*16+1, z, n) == 0 && **(**float64)(__ccgo_up(bp)) > float64(-_aXformType[i].FrLimit) && **(**float64)(__ccgo_up(bp)) < float64(_aXformType[i].FrLimit) { + switch i { + case int32(4): /* Special processing to add months */ + _computeYMD_HMS(tls, p) + **(**int32)(__ccgo_up(p + 12)) += int32(**(**float64)(__ccgo_up(bp))) + if (*TDateTime)(unsafe.Pointer(p)).FM > 0 { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(1)) / int32(12) + } else { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(12)) / int32(12) + } + x = v1 + **(**int32)(__ccgo_up(p + 8)) += x + **(**int32)(__ccgo_up(p + 12)) -= x * int32(12) + _computeFloor(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + **(**float64)(__ccgo_up(bp)) = **(**float64)(__ccgo_up(bp)) - float64(int32(**(**float64)(__ccgo_up(bp)))) + case int32(5): /* Special processing to add years */ + y = int32(**(**float64)(__ccgo_up(bp))) + _computeYMD_HMS(tls, p) + **(**int32)(__ccgo_up(p + 8)) += y + _computeFloor(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + **(**float64)(__ccgo_up(bp)) = **(**float64)(__ccgo_up(bp)) - float64(int32(**(**float64)(__ccgo_up(bp)))) + break + } + _computeJD(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) += int64(float64(float64(**(**float64)(__ccgo_up(bp))*libc.Float64FromFloat64(1000))*float64(_aXformType[i].FrXform)) + rRounder) + rc = 0 + break + } + goto _12 + _12: + ; + i = i + 1 + } + _clearYMD_HMS_TZ(tls, p) + default: + break + } + return rc +} + +// C documentation +// +// /* Add a single new term to an ExprList that is used to store a +// ** list of identifiers. Report an error if the ID list contains +// ** a COLLATE clause or an ASC or DESC keyword, except ignore the +// ** error while parsing a legacy schema. +// */ +func _parserAddExprIdListTerm(tls *libc.TLS, pParse uintptr, pPrior uintptr, pIdToken uintptr, hasCollate int32, sortOrder int32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p uintptr + _ = p + p = _sqlite3ExprListAppend(tls, pParse, pPrior, uintptr(0)) + if (hasCollate != 0 || sortOrder != -int32(1)) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25267, libc.VaList(bp+8, (*TToken)(unsafe.Pointer(pIdToken)).Fn, (*TToken)(unsafe.Pointer(pIdToken)).Fz)) + } + _sqlite3ExprListSetName(tls, pParse, p, pIdToken, int32(1)) + return p +} + +/**************** End of %include directives **********************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ +/**************** End token definitions ***************************************/ + +// C documentation +// +// /* +// ** For a compound SELECT statement, make sure p->pPrior->pNext==p for +// ** all elements in the list. And make sure list length does not exceed +// ** SQLITE_LIMIT_COMPOUND_SELECT. +// */ +func _parserDoubleLinkSelect(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var cnt, mxSelect, v2 int32 + var pLoop, pNext, v1 uintptr + var v3 bool + _, _, _, _, _, _, _ = cnt, mxSelect, pLoop, pNext, v1, v2, v3 + if (*TSelect)(unsafe.Pointer(p)).FpPrior != 0 { + pNext = uintptr(0) + pLoop = p + cnt = int32(1) + for int32(1) != 0 { + (*TSelect)(unsafe.Pointer(pLoop)).FpNext = pNext + **(**Tu32)(__ccgo_up(pLoop + 4)) |= uint32(SF_Compound) + pNext = pLoop + pLoop = (*TSelect)(unsafe.Pointer(pLoop)).FpPrior + if pLoop == uintptr(0) { + break + } + cnt = cnt + 1 + if (*TSelect)(unsafe.Pointer(pLoop)).FpOrderBy != 0 || (*TSelect)(unsafe.Pointer(pLoop)).FpLimit != 0 { + if (*TSelect)(unsafe.Pointer(pLoop)).FpOrderBy != uintptr(0) { + v1 = __ccgo_ts + 25176 + } else { + v1 = __ccgo_ts + 25185 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25191, libc.VaList(bp+8, v1, _sqlite3SelectOpName(tls, libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pNext)).Fop)))) + break + } + } + if v3 = (*TSelect)(unsafe.Pointer(p)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_MultiValue)|libc.Int32FromInt32(SF_Values)) == uint32(0); v3 { + v2 = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 4*4)) + mxSelect = v2 + } + if v3 && v2 > 0 && cnt > mxSelect { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25233, 0) + } + } +} + +// C documentation +// +// /* +// ** Generate a syntax error +// */ +func _parserSyntaxError(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25152, libc.VaList(bp+8, p)) +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xInit method. +// */ +func _pcache1Init(tls *libc.TLS, NotUsed uintptr) (r int32) { + _ = NotUsed + libc.X__builtin___memset_chk(tls, uintptr(unsafe.Pointer(&_pcache1_g)), 0, uint64(144), ^t__predefined_size_t(0)) + /* + ** The pcache1.separateCache variable is true if each PCache has its own + ** private PGroup (mode-1). pcache1.separateCache is false if the single + ** PGroup in pcache1.grp is used for all page caches (mode-2). + ** + ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT + ** + ** * Use a unified cache in single-threaded applications that have + ** configured a start-time buffer for use as page-cache memory using + ** sqlite3_config(SQLITE_CONFIG_PAGECACHE, pBuf, sz, N) with non-NULL + ** pBuf argument. + ** + ** * Otherwise use separate caches (mode-1) + */ + _pcache1_g.FseparateCache = 0 + if _sqlite3Config.FbCoreMutex != 0 { + _pcache1_g.Fgrp.Fmutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_LRU)) + _pcache1_g.Fmutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_PMEM)) + } + if _pcache1_g.FseparateCache != 0 && _sqlite3Config.FnPage != 0 && _sqlite3Config.FpPage == uintptr(0) { + _pcache1_g.FnInitPage = _sqlite3Config.FnPage + } else { + _pcache1_g.FnInitPage = 0 + } + _pcache1_g.Fgrp.FmxPinned = uint32(10) + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_pcache1_g))+80, int32(1)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xShutdown method. +// ** Note that the static mutex allocated in xInit does +// ** not need to be freed. +// */ +func _pcache1Shutdown(tls *libc.TLS, NotUsed uintptr) { + _ = NotUsed + libc.X__builtin___memset_chk(tls, uintptr(unsafe.Pointer(&_pcache1_g)), 0, uint64(144), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** This is a helper routine for sqlite3PcacheFetchFinish() +// ** +// ** In the uncommon case where the page being fetched has not been +// ** initialized, this routine is invoked to do the initialization. +// ** This routine is broken out into a separate function since it +// ** requires extra stack manipulation that can be avoided in the common +// ** case. +// */ +func _pcacheFetchFinishWithInit(tls *libc.TLS, pCache uintptr, pgno TPgno, pPage uintptr) (r uintptr) { + var pPgHdr uintptr + _ = pPgHdr + pPgHdr = (*Tsqlite3_pcache_page)(unsafe.Pointer(pPage)).FpExtra + libc.X__builtin___memset_chk(tls, pPgHdr+32, 0, libc.Uint64FromInt64(80)-uint64(libc.UintptrFromInt32(0)+32), ^t__predefined_size_t(0)) + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpPage = pPage + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpData = (*Tsqlite3_pcache_page)(unsafe.Pointer(pPage)).FpBuf + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpExtra = pPgHdr + 1*80 + libc.X__builtin___memset_chk(tls, (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpExtra, 0, uint64(8), ^t__predefined_size_t(0)) + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpCache = pCache + (*TPgHdr)(unsafe.Pointer(pPgHdr)).Fpgno = pgno + (*TPgHdr)(unsafe.Pointer(pPgHdr)).Fflags = uint16(PGHDR_CLEAN) + return _sqlite3PcacheFetchFinish(tls, pCache, pgno, pPage) +} + +// C documentation +// +// /* +// ** Sort the list of pages in ascending order by pgno. Pages are +// ** connected by pDirty pointers. The pDirtyPrev pointers are +// ** corrupted by this sort. +// ** +// ** Since there cannot be more than 2^31 distinct pages in a database, +// ** there cannot be more than 31 buckets required by the merge sorter. +// ** One extra bucket is added to catch overflow in case something +// ** ever changes to make the previous sentence incorrect. +// */ +func _pcacheSortDirtyList(tls *libc.TLS, pIn uintptr) (r uintptr) { + bp := tls.Alloc(256) + defer tls.Free(256) + var i int32 + var p, v3 uintptr + var _ /* a at bp+0 */ [32]uintptr + _, _, _ = i, p, v3 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(256), ^t__predefined_size_t(0)) + for pIn != 0 { + p = pIn + pIn = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + (*TPgHdr)(unsafe.Pointer(p)).FpDirty = uintptr(0) + i = 0 + for { + if !(i < libc.Int32FromInt32(N_SORT_BUCKET)-libc.Int32FromInt32(1)) { + break + } + if (**(**[32]uintptr)(__ccgo_up(bp)))[i] == uintptr(0) { + (**(**[32]uintptr)(__ccgo_up(bp)))[i] = p + break + } else { + p = _pcacheMergeDirtyList(tls, (**(**[32]uintptr)(__ccgo_up(bp)))[i], p) + (**(**[32]uintptr)(__ccgo_up(bp)))[i] = uintptr(0) + } + goto _1 + _1: + ; + i = i + 1 + } + if i == libc.Int32FromInt32(N_SORT_BUCKET)-libc.Int32FromInt32(1) { + /* To get here, there need to be 2^(N_SORT_BUCKET) elements in + ** the input list. But that is impossible. + */ + (**(**[32]uintptr)(__ccgo_up(bp)))[i] = _pcacheMergeDirtyList(tls, (**(**[32]uintptr)(__ccgo_up(bp)))[i], p) + } + } + p = (**(**[32]uintptr)(__ccgo_up(bp)))[0] + i = int32(1) + for { + if !(i < int32(N_SORT_BUCKET)) { + break + } + if (**(**[32]uintptr)(__ccgo_up(bp)))[i] == uintptr(0) { + goto _2 + } + if p != 0 { + v3 = _pcacheMergeDirtyList(tls, p, (**(**[32]uintptr)(__ccgo_up(bp)))[i]) + } else { + v3 = (**(**[32]uintptr)(__ccgo_up(bp)))[i] + } + p = v3 + goto _2 + _2: + ; + i = i + 1 + } + return p +} + +// C documentation +// +// /* +// ** Lower the locking level on file descriptor pFile to eFileLock. eFileLock +// ** must be either NO_LOCK or SHARED_LOCK. +// ** +// ** If the locking level of the file descriptor is already at or below +// ** the requested locking level, this routine is a no-op. +// ** +// ** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED +// ** the byte range is divided into 2 parts and the first part is unlocked then +// ** set to a read lock, then the other part is simply unlocked. This works +// ** around a bug in BSD NFS lockd (also seen on MacOSX 10.3+) that fails to +// ** remove the write lock on a region when a read lock is set. +// */ +func _posixUnlock(tls *libc.TLS, id uintptr, eFileLock int32, handleNFSUnlock int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var divSize, v1 Toff_t + var pFile, pInode uintptr + var rc, tErrno int32 + var _ /* lock at bp+0 */ Tflock + _, _, _, _, _, _ = divSize, pFile, pInode, rc, tErrno, v1 + pFile = id + rc = SQLITE_OK + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) <= eFileLock { + return SQLITE_OK + } + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) > int32(SHARED_LOCK) { + /* downgrading to a shared lock on NFS involves clearing the write lock + ** before establishing the readlock - to avoid a race condition we downgrade + ** the lock in 2 blocks, so that part of the range will be covered by a + ** write lock until the rest is covered by a read lock: + ** 1: [WWWWW] + ** 2: [....W] + ** 3: [RRRRW] + ** 4: [RRRR.] + */ + if eFileLock == int32(SHARED_LOCK) { + if handleNFSUnlock != 0 { /* Error code from system call errors */ + divSize = int64(libc.Int32FromInt32(SHARED_SIZE) - libc.Int32FromInt32(1)) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_UNLCK) + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = SEEK_SET + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(2)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = divSize + if _unixFileLock(tls, pFile, bp) == -int32(1) { + tErrno = **(**int32)(__ccgo_up(libc.X__error(tls))) + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(8)< upr { + v1 = uintptr(0) + } else { + v1 = uintptr(unsafe.Pointer(&_aPragmaName)) + uintptr(mid)*24 + } + return v1 +} + +// C documentation +// +// /* +// ** Pragma virtual table module xConnect method. +// */ +func _pragmaVtabConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var cSep int8 + var i, j, rc int32 + var pPragma, pTab uintptr + var _ /* acc at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [200]int8 + _, _, _, _, _, _ = cSep, i, j, pPragma, pTab, rc + pPragma = pAux + pTab = uintptr(0) + cSep = int8('(') + _ = argc + _ = argv + _sqlite3StrAccumInit(tls, bp, uintptr(0), bp+32, int32(200), 0) + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+20299) + i = 0 + j = libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FiPragCName) + for { + if !(i < libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FnPragCName)) { + break + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+20314, libc.VaList(bp+240, int32(cSep), _pragCName[j])) + cSep = int8(',') + goto _1 + _1: + ; + i = i + 1 + j = j + 1 + } + if i == 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+20321, libc.VaList(bp+240, (*TPragmaName)(unsafe.Pointer(pPragma)).FzName)) + i = i + 1 + } + j = 0 + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_Result1) != 0 { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+20327) + j = j + 1 + } + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&(libc.Int32FromInt32(PragFlg_SchemaOpt)|libc.Int32FromInt32(PragFlg_SchemaReq)) != 0 { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+20339) + j = j + 1 + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5601, int32(1)) + _sqlite3StrAccumFinish(tls, bp) + rc = Xsqlite3_declare_vtab(tls, db, bp+32) + if rc == SQLITE_OK { + pTab = Xsqlite3_malloc(tls, int32(48)) + if pTab == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pTab, 0, uint64(48), ^t__predefined_size_t(0)) + (*TPragmaVtab)(unsafe.Pointer(pTab)).FpName = pPragma + (*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb = db + (*TPragmaVtab)(unsafe.Pointer(pTab)).FiHidden = libc.Uint8FromInt32(i) + (*TPragmaVtab)(unsafe.Pointer(pTab)).FnHidden = libc.Uint8FromInt32(j) + } + } else { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+240, Xsqlite3_errmsg(tls, db))) + } + **(**uintptr)(__ccgo_up(ppVtab)) = pTab + return rc +} + +// C documentation +// +// /* +// ** Pragma virtual table module xFilter method. +// */ +func _pragmaVtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, j, rc, v1 int32 + var pCsr, pTab, zSql, zText uintptr + var _ /* acc at bp+0 */ TStrAccum + _, _, _, _, _, _, _, _ = i, j, pCsr, pTab, rc, zSql, zText, v1 + pCsr = pVtabCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab + _ = idxNum + _ = idxStr + _pragmaVtabCursorClear(tls, pCsr) + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer((*TPragmaVtab)(unsafe.Pointer(pTab)).FpName)).FmPragFlg)&int32(PragFlg_Result1) != 0 { + v1 = 0 + } else { + v1 = int32(1) + } + j = v1 + i = 0 + for { + if !(i < argc) { + break + } + zText = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zText != 0 { + **(**uintptr)(__ccgo_up(pCsr + 24 + uintptr(j)*8)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+40, zText)) + if **(**uintptr)(__ccgo_up(pCsr + 24 + uintptr(j)*8)) == uintptr(0) { + return int32(SQLITE_NOMEM) + } + } + goto _2 + _2: + ; + i = i + 1 + j = j + 1 + } + _sqlite3StrAccumInit(tls, bp, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up((*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb + 136 + 1*4))) + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+20354) + if **(**uintptr)(__ccgo_up(pCsr + 24 + 1*8)) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+20362, libc.VaList(bp+40, **(**uintptr)(__ccgo_up(pCsr + 24 + 1*8)))) + } + Xsqlite3_str_appendall(tls, bp, (*TPragmaName)(unsafe.Pointer((*TPragmaVtab)(unsafe.Pointer(pTab)).FpName)).FzName) + if **(**uintptr)(__ccgo_up(pCsr + 24)) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+20366, libc.VaList(bp+40, **(**uintptr)(__ccgo_up(pCsr + 24)))) + } + zSql = _sqlite3StrAccumFinish(tls, bp) + if zSql == uintptr(0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_prepare_v2(tls, (*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb, zSql, -int32(1), pCsr+8, uintptr(0)) + Xsqlite3_free(tls, zSql) + if rc != SQLITE_OK { + (*TPragmaVtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+40, Xsqlite3_errmsg(tls, (*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb))) + return rc + } + return _pragmaVtabNext(tls, pVtabCursor) +} + +// C documentation +// +// /* Create a new cursor for the pragma virtual table */ +func _pragmaVtabOpen(tls *libc.TLS, pVtab uintptr, ppCursor uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = Xsqlite3_malloc(tls, int32(40)) + if pCsr == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pCsr, 0, uint64(40), ^t__predefined_size_t(0)) + (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVtab + **(**uintptr)(__ccgo_up(ppCursor)) = pCsr + return SQLITE_OK +} + +// C documentation +// +// /* +// ** The WHERE-clause constant propagation optimization. +// ** +// ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or +// ** CONSTANT=COLUMN that are top-level AND-connected terms that are not +// ** part of a ON clause from a LEFT JOIN, then throughout the query +// ** replace all other occurrences of COLUMN with CONSTANT. +// ** +// ** For example, the query: +// ** +// ** SELECT * FROM t1, t2, t3 WHERE t1.a=39 AND t2.b=t1.a AND t3.c=t2.b +// ** +// ** Is transformed into +// ** +// ** SELECT * FROM t1, t2, t3 WHERE t1.a=39 AND t2.b=39 AND t3.c=39 +// ** +// ** Return true if any transformations where made and false if not. +// ** +// ** Implementation note: Constant propagation is tricky due to affinity +// ** and collating sequence interactions. Consider this example: +// ** +// ** CREATE TABLE t1(a INT,b TEXT); +// ** INSERT INTO t1 VALUES(123,'0123'); +// ** SELECT * FROM t1 WHERE a=123 AND b=a; +// ** SELECT * FROM t1 WHERE a=123 AND b=123; +// ** +// ** The two SELECT statements above should return different answers. b=a +// ** is always true because the comparison uses numeric affinity, but b=123 +// ** is false because it uses text affinity and '0123' is not the same as '123'. +// ** To work around this, the expression tree is not actually changed from +// ** "b=a" to "b=123" but rather the "a" in "b=a" is tagged with EP_FixedCol +// ** and the "123" value is hung off of the pLeft pointer. Code generator +// ** routines know to generate the constant "123" instead of looking up the +// ** column value. Also, to avoid collation problems, this optimization is +// ** only attempted if the "a=123" term uses the default BINARY collation. +// ** +// ** 2021-05-25 forum post 6a06202608: Another troublesome case is... +// ** +// ** CREATE TABLE t1(x); +// ** INSERT INTO t1 VALUES(10.0); +// ** SELECT 1 FROM t1 WHERE x=10 AND x LIKE 10; +// ** +// ** The query should return no rows, because the t1.x value is '10.0' not '10' +// ** and '10.0' is not LIKE '10'. But if we are not careful, the first WHERE +// ** term "x=10" will cause the second WHERE term to become "10 LIKE 10", +// ** resulting in a false positive. To avoid this, constant propagation for +// ** columns with BLOB affinity is only allowed if the constant is used with +// ** operators ==, <=, <, >=, >, or IS in a way that will cause the correct +// ** type conversions to occur. See logic associated with the bHasAffBlob flag +// ** for details. +// */ +func _propagateConstants(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var nChng int32 + var _ /* w at bp+40 */ TWalker + var _ /* x at bp+0 */ TWhereConst + _ = nChng + nChng = 0 + (**(**TWhereConst)(__ccgo_up(bp))).FpParse = pParse + (**(**TWhereConst)(__ccgo_up(bp))).FpOomFault = (*TParse)(unsafe.Pointer(pParse)).Fdb + 103 + for cond := true; cond; cond = (**(**TWhereConst)(__ccgo_up(bp))).FnChng != 0 { + (**(**TWhereConst)(__ccgo_up(bp))).FnConst = 0 + (**(**TWhereConst)(__ccgo_up(bp))).FnChng = 0 + (**(**TWhereConst)(__ccgo_up(bp))).FapExpr = uintptr(0) + (**(**TWhereConst)(__ccgo_up(bp))).FbHasAffBlob = 0 + if (*TSelect)(unsafe.Pointer(p)).FpSrc != uintptr(0) && (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc > 0 && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + /* Do not propagate constants on any ON clause if there is a + ** RIGHT JOIN anywhere in the query */ + (**(**TWhereConst)(__ccgo_up(bp))).FmExcludeOn = libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON) | libc.Int32FromInt32(EP_OuterON)) + } else { + /* Do not propagate constants through the ON clause of a LEFT JOIN */ + (**(**TWhereConst)(__ccgo_up(bp))).FmExcludeOn = uint32(EP_OuterON) + } + _findConstInWhere(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpWhere) + if (**(**TWhereConst)(__ccgo_up(bp))).FnConst != 0 { + libc.X__builtin___memset_chk(tls, bp+40, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp + 40))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp + 40))).FxExprCallback = __ccgo_fp(_propagateConstantExprRewrite) + (**(**TWalker)(__ccgo_up(bp + 40))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + (**(**TWalker)(__ccgo_up(bp + 40))).FxSelectCallback2 = uintptr(0) + (**(**TWalker)(__ccgo_up(bp + 40))).FwalkerDepth = 0 + *(*uintptr)(unsafe.Pointer(bp + 40 + 40)) = bp + _sqlite3WalkExpr(tls, bp+40, (*TSelect)(unsafe.Pointer(p)).FpWhere) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer((**(**TWhereConst)(__ccgo_up(bp))).FpParse)).Fdb, (**(**TWhereConst)(__ccgo_up(bp))).FapExpr) + nChng = nChng + (**(**TWhereConst)(__ccgo_up(bp))).FnChng + } + } + return nChng +} + +// C documentation +// +// /* +// ** Takes an open conch file, copies the contents to a new path and then moves +// ** it back. The newly created file's file descriptor is assigned to the +// ** conch file structure and finally the original conch file descriptor is +// ** closed. Returns zero if successful. +// */ +func _proxyBreakConchLock(tls *libc.TLS, pFile uintptr, myHostID uintptr) (r int32) { + bp := tls.Alloc(2160) + defer tls.Free(2160) + var cPath, conchFile, pCtx uintptr + var fd, rc int32 + var pathLen, readLen Tsize_t + var _ /* buf at bp+1024 */ [1041]int8 + var _ /* errmsg at bp+2065 */ [64]int8 + var _ /* tPath at bp+0 */ [1024]int8 + _, _, _, _, _, _, _ = cPath, conchFile, fd, pCtx, pathLen, rc, readLen + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + conchFile = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile + cPath = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFilePath + readLen = uint64(0) + pathLen = uint64(0) + **(**[64]int8)(__ccgo_up(bp + 2065)) = [64]int8{} + fd = -int32(1) + rc = -int32(1) + _ = myHostID + /* create a new path by replace the trailing '-conch' with '-break' */ + pathLen = libc.Xstrlcpy(tls, bp, cPath, uint64(PATH_MAX)) + if pathLen > uint64(PATH_MAX) || pathLen < uint64(6) || libc.Xstrlcpy(tls, bp+uintptr(pathLen-uint64(5)), __ccgo_ts+4186, uint64(6)) != uint64(5) { + Xsqlite3_snprintf(tls, int32(64), bp+2065, __ccgo_ts+4192, libc.VaList(bp+2144, libc.Int32FromUint64(pathLen))) + goto end_breaklock + } + /* read the conch content */ + readLen = libc.Uint64FromInt64((*(*func(*libc.TLS, int32, uintptr, Tsize_t, Toff_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(9)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(conchFile)).Fh, bp+1024, libc.Uint64FromInt32(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)+libc.Int32FromInt32(PATH_MAX)), 0)) + if readLen < libc.Uint64FromInt32(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)) { + Xsqlite3_snprintf(tls, int32(64), bp+2065, __ccgo_ts+4212, libc.VaList(bp+2144, libc.Int32FromUint64(readLen))) + goto end_breaklock + } + /* write it out to the temporary break file */ + fd = _robust_open(tls, bp, libc.Int32FromInt32(O_RDWR)|libc.Int32FromInt32(O_CREAT)|libc.Int32FromInt32(O_EXCL)|libc.Int32FromInt32(O_NOFOLLOW), uint16(0)) + if fd < 0 { + Xsqlite3_snprintf(tls, int32(64), bp+2065, __ccgo_ts+4232, libc.VaList(bp+2144, **(**int32)(__ccgo_up(libc.X__error(tls))))) + goto end_breaklock + } + if (*(*func(*libc.TLS, int32, uintptr, Tsize_t, Toff_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(12)].FpCurrent})))(tls, fd, bp+1024, readLen, 0) != libc.Int64FromUint64(readLen) { + Xsqlite3_snprintf(tls, int32(64), bp+2065, __ccgo_ts+4251, libc.VaList(bp+2144, **(**int32)(__ccgo_up(libc.X__error(tls))))) + goto end_breaklock + } + if libc.Xrename(tls, bp, cPath) != 0 { + Xsqlite3_snprintf(tls, int32(64), bp+2065, __ccgo_ts+4269, libc.VaList(bp+2144, **(**int32)(__ccgo_up(libc.X__error(tls))))) + goto end_breaklock + } + rc = 0 + libc.Xfprintf(tls, libc.X__stderrp, __ccgo_ts+4288, libc.VaList(bp+2144, cPath)) + _robust_close(tls, pFile, (*TunixFile)(unsafe.Pointer(conchFile)).Fh, int32(47880)) + (*TunixFile)(unsafe.Pointer(conchFile)).Fh = fd + (*TunixFile)(unsafe.Pointer(conchFile)).FopenFlags = libc.Int32FromInt32(O_RDWR) | libc.Int32FromInt32(O_CREAT) + goto end_breaklock +end_breaklock: + ; + if rc != 0 { + if fd >= 0 { + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(16)].FpCurrent})))(tls, bp) + _robust_close(tls, pFile, fd, int32(47888)) + } + libc.Xfprintf(tls, libc.X__stderrp, __ccgo_ts+4312, libc.VaList(bp+2144, cPath, bp+2065)) + } + return rc +} + +// C documentation +// +// /* +// ** This routine checks if there is a RESERVED lock held on the specified +// ** file by this or any other process. If such a lock is held, set *pResOut +// ** to a non-zero value otherwise *pResOut is set to zero. The return value +// ** is set to SQLITE_OK unless an I/O error occurs during lock checking. +// */ +func _proxyCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) (r int32) { + var pCtx, pFile, proxy uintptr + var rc int32 + _, _, _, _ = pCtx, pFile, proxy, rc + pFile = id + rc = _proxyTakeConch(tls, pFile) + if rc == SQLITE_OK { + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld > 0 { + proxy = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy + return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(proxy)).FpMethod)).FxCheckReservedLock})))(tls, proxy, pResOut) + } else { /* conchHeld < 0 is lockless */ + pResOut = uintptr(0) + } + } + return rc +} + +// C documentation +// +// /* +// ** Close a file that uses proxy locks. +// */ +func _proxyClose(tls *libc.TLS, id uintptr) (r int32) { + var conchFile, lockProxy, pCtx, pFile uintptr + var rc int32 + _, _, _, _, _ = conchFile, lockProxy, pCtx, pFile, rc + if id != 0 { + pFile = id + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + lockProxy = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy + conchFile = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile + rc = SQLITE_OK + if lockProxy != 0 { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(lockProxy)).FpMethod)).FxUnlock})))(tls, lockProxy, NO_LOCK) + if rc != 0 { + return rc + } + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(lockProxy)).FpMethod)).FxClose})))(tls, lockProxy) + if rc != 0 { + return rc + } + Xsqlite3_free(tls, lockProxy) + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy = uintptr(0) + } + if conchFile != 0 { + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld != 0 { + rc = _proxyReleaseConch(tls, pFile) + if rc != 0 { + return rc + } + } + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(conchFile)).FpMethod)).FxClose})))(tls, conchFile) + if rc != 0 { + return rc + } + Xsqlite3_free(tls, conchFile) + } + _sqlite3DbFree(tls, uintptr(0), (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath) + Xsqlite3_free(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFilePath) + _sqlite3DbFree(tls, uintptr(0), (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FdbPath) + /* restore the original locking context and pMethod then close it */ + (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FoldLockingContext + (*TunixFile)(unsafe.Pointer(pFile)).FpMethod = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FpOldMethod + Xsqlite3_free(tls, pCtx) + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpMethod)).FxClose})))(tls, id) + } + return SQLITE_OK +} + +/* +** The proxy locking style is intended for use with AFP filesystems. +** And since AFP is only supported on MacOSX, the proxy locking is also +** restricted to MacOSX. +** +** +******************* End of the proxy lock implementation ********************** +******************************************************************************/ + +// C documentation +// +// /* Take the requested lock on the conch file and break a stale lock if the +// ** host id matches. +// */ +func _proxyConchLock(tls *libc.TLS, pFile uintptr, myHostID uintptr, lockType int32) (r int32) { + bp := tls.Alloc(1216) + defer tls.Free(1216) + var conchFile, pCtx uintptr + var len1, nTries, rc int32 + var _ /* buf at bp+16 */ Tstat + var _ /* conchModTime at bp+0 */ Ttimespec + var _ /* tBuf at bp+160 */ [1041]int8 + _, _, _, _, _ = conchFile, len1, nTries, pCtx, rc + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + conchFile = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile + rc = SQLITE_OK + nTries = 0 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^t__predefined_size_t(0)) + for cond := true; cond; cond = rc == int32(SQLITE_BUSY) && nTries < int32(3) { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(conchFile)).FpMethod)).FxLock})))(tls, conchFile, lockType) + nTries = nTries + 1 + if rc == int32(SQLITE_BUSY) { + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(conchFile)).Fh, bp+16) != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__error(tls)))) + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(15)< libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN) && int32((**(**[1041]int8)(__ccgo_up(bp + 160)))[0]) == int32(libc.Int8FromInt32(PROXY_CONCHVERSION)) { + /* don't break the lock if the host id doesn't match */ + if 0 != libc.Xmemcmp(tls, bp+160+1, myHostID, uint64(PROXY_HOSTIDLEN)) { + return int32(SQLITE_BUSY) + } + } else { + /* don't break the lock on short read or a version mismatch */ + return int32(SQLITE_BUSY) + } + _unixSleep(tls, uintptr(0), int32(10000000)) /* wait 10 sec and try the lock again */ + continue + } + if 0 == _proxyBreakConchLock(tls, pFile, myHostID) { + rc = SQLITE_OK + if lockType == int32(EXCLUSIVE_LOCK) { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(conchFile)).FpMethod)).FxLock})))(tls, conchFile, int32(SHARED_LOCK)) + } + if !(rc != 0) { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(conchFile)).FpMethod)).FxLock})))(tls, conchFile, lockType) + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Given the name of a database file, compute the name of its conch file. +// ** Store the conch filename in memory obtained from sqlite3_malloc64(). +// ** Make *pConchPath point to the new name. Return SQLITE_OK on success +// ** or SQLITE_NOMEM if unable to obtain memory. +// ** +// ** The caller is responsible for ensuring that the allocated memory +// ** space is eventually freed. +// ** +// ** *pConchPath is set to NULL if a memory allocation error occurs. +// */ +func _proxyCreateConchPathname(tls *libc.TLS, dbPath uintptr, pConchPath uintptr) (r int32) { + var conchPath, v1 uintptr + var i, len1 int32 + _, _, _, _ = conchPath, i, len1, v1 /* Loop counter */ + len1 = libc.Int32FromUint64(libc.Xstrlen(tls, dbPath)) /* buffer in which to construct conch name */ + /* Allocate space for the conch filename and initialize the name to + ** the name of the original database file. */ + v1 = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(len1+int32(8))) + conchPath = v1 + **(**uintptr)(__ccgo_up(pConchPath)) = v1 + if conchPath == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, conchPath, dbPath, libc.Uint64FromInt32(len1+int32(1)), ^t__predefined_size_t(0)) + /* now insert a "." before the last / character */ + i = len1 - int32(1) + for { + if !(i >= 0) { + break + } + if int32(**(**int8)(__ccgo_up(conchPath + uintptr(i)))) == int32('/') { + i = i + 1 + break + } + goto _2 + _2: + ; + i = i - 1 + } + **(**int8)(__ccgo_up(conchPath + uintptr(i))) = int8('.') + for i < len1 { + **(**int8)(__ccgo_up(conchPath + uintptr(i+int32(1)))) = **(**int8)(__ccgo_up(dbPath + uintptr(i))) + i = i + 1 + } + /* append the "-conch" suffix to the file */ + libc.X__builtin___memcpy_chk(tls, conchPath+uintptr(i+int32(1)), __ccgo_ts+4350, uint64(7), ^t__predefined_size_t(0)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Creates the lock file and any missing directories in lockPath +// */ +func _proxyCreateLockPath(tls *libc.TLS, lockPath uintptr) (r int32) { + bp := tls.Alloc(1024) + defer tls.Free(1024) + var err, i, len1, start int32 + var _ /* buf at bp+0 */ [1024]int8 + _, _, _, _ = err, i, len1, start + start = 0 + /* try to create all the intermediate directories */ + len1 = libc.Int32FromUint64(libc.Xstrlen(tls, lockPath)) + (**(**[1024]int8)(__ccgo_up(bp)))[0] = **(**int8)(__ccgo_up(lockPath)) + i = int32(1) + for { + if !(i < len1) { + break + } + if int32(**(**int8)(__ccgo_up(lockPath + uintptr(i)))) == int32('/') && i-start > 0 { + /* only mkdir if leaf dir != "." or "/" or ".." */ + if i-start > int32(2) || i-start == int32(1) && int32((**(**[1024]int8)(__ccgo_up(bp)))[start]) != int32('.') && int32((**(**[1024]int8)(__ccgo_up(bp)))[start]) != int32('/') || i-start == int32(2) && int32((**(**[1024]int8)(__ccgo_up(bp)))[start]) != int32('.') && int32((**(**[1024]int8)(__ccgo_up(bp)))[start+int32(1)]) != int32('.') { + (**(**[1024]int8)(__ccgo_up(bp)))[i] = int8('\000') + if (*(*func(*libc.TLS, uintptr, Tmode_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(18)].FpCurrent})))(tls, bp, uint16(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS)) != 0 { + err = **(**int32)(__ccgo_up(libc.X__error(tls))) + if err != int32(EEXIST) { + return err + } + } + } + start = i + int32(1) + } + (**(**[1024]int8)(__ccgo_up(bp)))[i] = **(**int8)(__ccgo_up(lockPath + uintptr(i))) + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Create a new VFS file descriptor (stored in memory obtained from +// ** sqlite3_malloc) and open the file named "path" in the file descriptor. +// ** +// ** The caller is responsible not only for closing the file descriptor +// ** but also for freeing the memory associated with the file descriptor. +// */ +func _proxyCreateUnixFile(tls *libc.TLS, path uintptr, ppFile uintptr, islockfile int32) (r int32) { + bp := tls.Alloc(176) + defer tls.Free(176) + var fd, openFlags, rc, terrno int32 + var pNew, pUnused uintptr + var _ /* dummyVfs at bp+0 */ Tsqlite3_vfs + _, _, _, _, _, _ = fd, openFlags, pNew, pUnused, rc, terrno + fd = -int32(1) + rc = SQLITE_OK + openFlags = libc.Int32FromInt32(O_RDWR) | libc.Int32FromInt32(O_CREAT) | libc.Int32FromInt32(O_NOFOLLOW) + terrno = 0 + pUnused = libc.UintptrFromInt32(0) + /* 1. first try to open/create the file + ** 2. if that fails, and this is a lock file (not-conch), try creating + ** the parent directories and then try again. + ** 3. if that fails, try to open the file read-only + ** otherwise return BUSY (if lock file) or CANTOPEN for the conch file + */ + pUnused = _findReusableFd(tls, path, openFlags) + if pUnused != 0 { + fd = (*TUnixUnusedFd)(unsafe.Pointer(pUnused)).Ffd + } else { + pUnused = Xsqlite3_malloc64(tls, uint64(16)) + if !(pUnused != 0) { + return int32(SQLITE_NOMEM) + } + } + if fd < 0 { + fd = _robust_open(tls, path, openFlags, uint16(0)) + terrno = **(**int32)(__ccgo_up(libc.X__error(tls))) + if fd < 0 && **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(ENOENT) && islockfile != 0 { + if _proxyCreateLockPath(tls, path) == SQLITE_OK { + fd = _robust_open(tls, path, openFlags, uint16(0)) + } + } + } + if fd < 0 { + openFlags = libc.Int32FromInt32(O_RDONLY) | libc.Int32FromInt32(O_NOFOLLOW) + fd = _robust_open(tls, path, openFlags, uint16(0)) + terrno = **(**int32)(__ccgo_up(libc.X__error(tls))) + } + if fd < 0 { + if islockfile != 0 { + return int32(SQLITE_BUSY) + } + switch terrno { + case int32(EACCES): + return int32(SQLITE_PERM) + case int32(EIO): + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(15)< SHARED +// ** SHARED -> RESERVED +// ** SHARED -> (PENDING) -> EXCLUSIVE +// ** RESERVED -> (PENDING) -> EXCLUSIVE +// ** PENDING -> EXCLUSIVE +// ** +// ** This routine will only increase a lock. Use the sqlite3OsUnlock() +// ** routine to lower a locking level. +// */ +func _proxyLock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + var pCtx, pFile, proxy uintptr + var rc int32 + _, _, _, _ = pCtx, pFile, proxy, rc + pFile = id + rc = _proxyTakeConch(tls, pFile) + if rc == SQLITE_OK { + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld > 0 { + proxy = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(proxy)).FpMethod)).FxLock})))(tls, proxy, eFileLock) + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = (*TunixFile)(unsafe.Pointer(proxy)).FeFileLock + } else { + /* conchHeld < 0 is lockless */ + } + } + return rc +} + +// C documentation +// +// /* +// ** If pFile holds a lock on a conch file, then release that lock. +// */ +func _proxyReleaseConch(tls *libc.TLS, pFile uintptr) (r int32) { + var conchFile, pCtx uintptr + var rc int32 + _, _, _ = conchFile, pCtx, rc + rc = SQLITE_OK /* Name of the conch file */ + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + conchFile = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld > 0 { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(conchFile)).FpMethod)).FxUnlock})))(tls, conchFile, NO_LOCK) + } + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld = 0 + return rc +} + +// C documentation +// +// /* Takes the conch by taking a shared lock and read the contents conch, if +// ** lockPath is non-NULL, the host ID and lock file path must match. A NULL +// ** lockPath means that the lockPath in the conch file will be used if the +// ** host IDs match, or a new lock path will be generated automatically +// ** and written to the conch file. +// */ +func _proxyTakeConch(tls *libc.TLS, pFile uintptr) (r int32) { + bp := tls.Alloc(3280) + defer tls.Free(3280) + var afpCtx, conchFile, pCtx, path, tempLockPath, v4 uintptr + var cmode Tmode_t + var createConch, err, fd, forceNewLockPath, hostIdMatch, rc, readLen, tryOldLockPath, writeSize int32 + var pathLen Tsize_t + var _ /* buf at bp+3128 */ Tstat + var _ /* lockPath at bp+1061 */ [1024]int8 + var _ /* myHostID at bp+0 */ Tuuid_t + var _ /* pError at bp+16 */ int32 + var _ /* readBuf at bp+20 */ [1041]int8 + var _ /* writeBuffer at bp+2085 */ [1041]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = afpCtx, cmode, conchFile, createConch, err, fd, forceNewLockPath, hostIdMatch, pCtx, path, pathLen, rc, readLen, tempLockPath, tryOldLockPath, writeSize, v4 + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld != 0 { + return SQLITE_OK + } else { + conchFile = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile + **(**int32)(__ccgo_up(bp + 16)) = 0 + tempLockPath = libc.UintptrFromInt32(0) + rc = SQLITE_OK + createConch = 0 + hostIdMatch = 0 + readLen = 0 + tryOldLockPath = 0 + forceNewLockPath = 0 + rc = _proxyGetHostID(tls, bp, bp+16) + if rc&int32(0xff) == int32(SQLITE_IOERR) { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(bp + 16))) + goto end_takeconch + } + rc = _proxyConchLock(tls, pFile, bp, int32(SHARED_LOCK)) + if rc != SQLITE_OK { + goto end_takeconch + } + /* read the existing conch file */ + readLen = _seekAndRead(tls, conchFile, 0, bp+20, libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)+libc.Int32FromInt32(PATH_MAX)) + if readLen < 0 { + /* I/O error: lastErrno set by seekAndRead */ + _storeLastErrno(tls, pFile, (*TunixFile)(unsafe.Pointer(conchFile)).FlastErrno) + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(1)<= uint64(PATH_MAX) { + pathLen = libc.Uint64FromInt32(libc.Int32FromInt32(PATH_MAX) - libc.Int32FromInt32(1)) + } + libc.X__builtin___memcpy_chk(tls, bp+1061, bp+20+uintptr(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)), pathLen, ^t__predefined_size_t(0)) + (**(**[1024]int8)(__ccgo_up(bp + 1061)))[pathLen] = 0 + tempLockPath = bp + 1061 + tryOldLockPath = int32(1) + /* create a copy of the lock path if the conch is taken */ + goto end_takeconch + } + } else { + if hostIdMatch != 0 && !(libc.Xstrncmp(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath, bp+20+uintptr(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)), libc.Uint64FromInt32(readLen-(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)))) != 0) { + /* conch host and lock path match */ + goto end_takeconch + } + } + } + /* if the conch isn't writable and doesn't match, we can't take it */ + if (*TunixFile)(unsafe.Pointer(conchFile)).FopenFlags&int32(O_RDWR) == 0 { + rc = int32(SQLITE_BUSY) + goto end_takeconch + } + /* either the conch didn't match or we need to create a new one */ + if !((*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath != 0) { + _proxyGetLockPath(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FdbPath, bp+1061, uint64(PATH_MAX)) + tempLockPath = bp + 1061 + /* create a copy of the lock path _only_ if the conch is taken */ + } + /* update conch with host and path (this will fail if other process + ** has a shared lock already), if the host id matches, use the big + ** stick. + */ + libc.Xfutimes(tls, (*TunixFile)(unsafe.Pointer(conchFile)).Fh, libc.UintptrFromInt32(0)) + if hostIdMatch != 0 && !(createConch != 0) { + if (*TunixFile)(unsafe.Pointer(conchFile)).FpInode != 0 && (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(conchFile)).FpInode)).FnShared > int32(1) { + /* We are trying for an exclusive lock but another thread in this + ** same process is still holding a shared lock. */ + rc = int32(SQLITE_BUSY) + } else { + rc = _proxyConchLock(tls, pFile, bp, int32(EXCLUSIVE_LOCK)) + } + } else { + rc = _proxyConchLock(tls, pFile, bp, int32(EXCLUSIVE_LOCK)) + } + if rc == SQLITE_OK { + writeSize = 0 + (**(**[1041]int8)(__ccgo_up(bp + 2085)))[0] = libc.Int8FromInt32(PROXY_CONCHVERSION) + libc.X__builtin___memcpy_chk(tls, bp+2085+1, bp, uint64(PROXY_HOSTIDLEN), ^t__predefined_size_t(0)) + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath != libc.UintptrFromInt32(0) { + libc.Xstrlcpy(tls, bp+2085+uintptr(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)), (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath, uint64(PATH_MAX)) + } else { + libc.Xstrlcpy(tls, bp+2085+uintptr(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)), tempLockPath, uint64(PATH_MAX)) + } + writeSize = libc.Int32FromUint64(libc.Uint64FromInt32(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)) + libc.Xstrlen(tls, bp+2085+uintptr(libc.Int32FromInt32(PROXY_HEADERLEN)+libc.Int32FromInt32(PROXY_HOSTIDLEN)))) + _robust_ftruncate(tls, (*TunixFile)(unsafe.Pointer(conchFile)).Fh, int64(writeSize)) + rc = _unixWrite(tls, conchFile, bp+2085, writeSize, 0) + _full_fsync(tls, (*TunixFile)(unsafe.Pointer(conchFile)).Fh, 0, 0) + /* If we created a new conch file (not just updated the contents of a + ** valid conch file), try to match the permissions of the database + */ + if rc == SQLITE_OK && createConch != 0 { + err = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, bp+3128) + if err == 0 { + cmode = libc.Uint16FromInt32(libc.Int32FromUint16((**(**Tstat)(__ccgo_up(bp + 3128))).Fst_mode) & (libc.Int32FromInt32(S_IRUSR) | libc.Int32FromInt32(S_IWUSR) | libc.Int32FromInt32(S_IRGRP) | libc.Int32FromInt32(S_IWGRP) | libc.Int32FromInt32(S_IROTH) | libc.Int32FromInt32(S_IWOTH))) + /* try to match the database file R/W permissions, ignore failure */ + (*(*func(*libc.TLS, int32, Tmode_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(14)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(conchFile)).Fh, cmode) + } + } + } + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(conchFile)).FpMethod)).FxUnlock})))(tls, conchFile, int32(SHARED_LOCK)) + goto end_takeconch + end_takeconch: + ; + if rc == SQLITE_OK && (*TunixFile)(unsafe.Pointer(pFile)).FopenFlags != 0 { + if (*TunixFile)(unsafe.Pointer(pFile)).Fh >= 0 { + _robust_close(tls, pFile, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(48141)) + } + (*TunixFile)(unsafe.Pointer(pFile)).Fh = -int32(1) + fd = _robust_open(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FdbPath, (*TunixFile)(unsafe.Pointer(pFile)).FopenFlags, uint16(0)) + if fd >= 0 { + (*TunixFile)(unsafe.Pointer(pFile)).Fh = fd + } else { + rc = _sqlite3CantopenError(tls, int32(48149)) /* SQLITE_BUSY? proxyTakeConch called + during locking */ + } + } + if rc == SQLITE_OK && !((*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy != 0) { + if tempLockPath != 0 { + v4 = tempLockPath + } else { + v4 = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath + } + path = v4 + rc = _proxyCreateUnixFile(tls, path, pCtx+16, int32(1)) + if rc != SQLITE_OK && rc != int32(SQLITE_NOMEM) && tryOldLockPath != 0 { + /* we couldn't create the proxy lock file with the old lock file path + ** so try again via auto-naming + */ + forceNewLockPath = int32(1) + tryOldLockPath = 0 + goto _2 /* go back to the do {} while start point, try again */ + } + } + if rc == SQLITE_OK { + /* Need to make a copy of path if we extracted the value + ** from the conch file or the path was allocated on the stack + */ + if tempLockPath != 0 { + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath = _sqlite3DbStrDup(tls, uintptr(0), tempLockPath) + if !((*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath != 0) { + rc = int32(SQLITE_NOMEM) + } + } + } + if rc == SQLITE_OK { + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld = int32(1) + if (*TunixFile)(unsafe.Pointer((*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy)).FpMethod == uintptr(unsafe.Pointer(&_afpIoMethods)) { + afpCtx = (*TunixFile)(unsafe.Pointer((*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy)).FlockingContext + (*TafpLockingContext)(unsafe.Pointer(afpCtx)).FdbPath = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath + } + } else { + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(conchFile)).FpMethod)).FxUnlock})))(tls, conchFile, NO_LOCK) + } + return rc + goto _2 + _2: + ; + if int32(1) != 0 { + goto _3 + } + goto _1 + _1: + /* in case we need to retry the :auto: lock file - + ** we should never get here except via the 'continue' call. */ + } + return r +} + +// C documentation +// +// /* +// ** Takes an already filled in unix file and alters it so all file locking +// ** will be performed on the local proxy lock file. The following fields +// ** are preserved in the locking context so that they can be restored and +// ** the unix structure properly cleaned up at close time: +// ** ->lockingContext +// ** ->pMethod +// */ +func _proxyTransformUnixFile(tls *libc.TLS, pFile uintptr, path uintptr) (r int32) { + bp := tls.Alloc(3344) + defer tls.Free(3344) + var err, goLockless, rc int32 + var lockPath, pCtx uintptr + var _ /* conchInfo at bp+3200 */ Tstat + var _ /* dbPath at bp+0 */ [1025]int8 + var _ /* fsInfo at bp+1032 */ Tstatfs + _, _, _, _, _ = err, goLockless, lockPath, pCtx, rc /* Name of the database file */ + lockPath = libc.UintptrFromInt32(0) + rc = SQLITE_OK + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) != NO_LOCK { + return int32(SQLITE_BUSY) + } + _proxyGetDbPathForUnixFile(tls, pFile, bp) + if !(path != 0) || int32(**(**int8)(__ccgo_up(path))) == int32('\000') || !(libc.Xstrcmp(tls, path, __ccgo_ts+4139) != 0) { + lockPath = libc.UintptrFromInt32(0) + } else { + lockPath = path + } + pCtx = Xsqlite3_malloc64(tls, uint64(64)) + if pCtx == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pCtx, 0, uint64(64), ^t__predefined_size_t(0)) + rc = _proxyCreateConchPathname(tls, bp, pCtx+8) + if rc == SQLITE_OK { + rc = _proxyCreateUnixFile(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFilePath, pCtx, 0) + if rc == int32(SQLITE_CANTOPEN) && (*TunixFile)(unsafe.Pointer(pFile)).FopenFlags&int32(O_RDWR) == 0 { + goLockless = 0 + if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFilePath, bp+3200) == -int32(1) { + err = **(**int32)(__ccgo_up(libc.X__error(tls))) + if err == int32(ENOENT) && libc.Xstatfs(tls, bp, bp+1032) != -int32(1) { + goLockless = libc.BoolInt32((**(**Tstatfs)(__ccgo_up(bp + 1032))).Ff_flags&uint32(MNT_RDONLY) == uint32(MNT_RDONLY)) + } + } + if goLockless != 0 { + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld = -int32(1) /* read only FS/ lockless */ + rc = SQLITE_OK + } + } + } + if rc == SQLITE_OK && lockPath != 0 { + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath = _sqlite3DbStrDup(tls, uintptr(0), lockPath) + } + if rc == SQLITE_OK { + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FdbPath = _sqlite3DbStrDup(tls, uintptr(0), bp) + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FdbPath == libc.UintptrFromInt32(0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc == SQLITE_OK { + /* all memory is allocated, proxys are created and assigned, + ** switch the locking context and pMethod then return. + */ + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FoldLockingContext = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext = pCtx + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FpOldMethod = (*TunixFile)(unsafe.Pointer(pFile)).FpMethod + (*TunixFile)(unsafe.Pointer(pFile)).FpMethod = uintptr(unsafe.Pointer(&_proxyIoMethods)) + } else { + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile != 0 { + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer((*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile)).FpMethod)).FxClose})))(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile) + Xsqlite3_free(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFile) + } + _sqlite3DbFree(tls, uintptr(0), (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath) + Xsqlite3_free(tls, (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchFilePath) + Xsqlite3_free(tls, pCtx) + } + return rc +} + +// C documentation +// +// /* +// ** Lower the locking level on file descriptor pFile to eFileLock. eFileLock +// ** must be either NO_LOCK or SHARED_LOCK. +// ** +// ** If the locking level of the file descriptor is already at or below +// ** the requested locking level, this routine is a no-op. +// */ +func _proxyUnlock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + var pCtx, pFile, proxy uintptr + var rc int32 + _, _, _, _ = pCtx, pFile, proxy, rc + pFile = id + rc = _proxyTakeConch(tls, pFile) + if rc == SQLITE_OK { + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + if (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld > 0 { + proxy = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(proxy)).FpMethod)).FxUnlock})))(tls, proxy, eFileLock) + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = (*TunixFile)(unsafe.Pointer(proxy)).FeFileLock + } else { + /* conchHeld < 0 is lockless */ + } + } + return rc +} + +// C documentation +// +// /* +// ** Generate code that will push the record in registers regData +// ** through regData+nData-1 onto the sorter. +// */ +func _pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintptr, regData int32, regOrigData int32, nData int32, nPrefixReg int32) { + var addrFirst, addrJmp, bSeq, iCsr, iLimit, iSkip, nBase, nExpr, nKey, nOBSat, op, regBase, regPrevKey, regRecord, v1 int32 + var pKI, pOp, v, v4 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrFirst, addrJmp, bSeq, iCsr, iLimit, iSkip, nBase, nExpr, nKey, nOBSat, op, pKI, pOp, regBase, regPrevKey, regRecord, v, v1, v4 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Stmt under construction */ + bSeq = libc.BoolInt32(libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&int32(SORTFLAG_UseSorter) == 0) + nExpr = (*TExprList)(unsafe.Pointer((*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr /* No. of ORDER BY terms */ + nBase = nExpr + bSeq + nData /* Regs for sorter record */ + regRecord = 0 /* Assembled sorter record */ + nOBSat = (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat /* LIMIT counter */ + iSkip = 0 /* End of the sorter insert loop */ + /* Three cases: + ** (1) The data to be sorted has already been packed into a Record + ** by a prior OP_MakeRecord. In this case nData==1 and regData + ** will be completely unrelated to regOrigData. + ** (2) All output columns are included in the sort record. In that + ** case regData==regOrigData. + ** (3) Some output columns are omitted from the sort record due to + ** the SQLITE_ENABLE_SORTER_REFERENCES optimization, or due to the + ** SQLITE_ECEL_OMITREF optimization, or due to the + ** SortCtx.pDeferredRowLoad optimization. In any of these cases + ** regOrigData is 0 to prevent this routine from trying to copy + ** values that might not yet exist. + */ + if nPrefixReg != 0 { + regBase = regData - nPrefixReg + } else { + regBase = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nBase + } + if (*TSelect)(unsafe.Pointer(pSelect)).FiOffset != 0 { + v1 = (*TSelect)(unsafe.Pointer(pSelect)).FiOffset + int32(1) + } else { + v1 = (*TSelect)(unsafe.Pointer(pSelect)).FiLimit + } + iLimit = v1 + (*TSortCtx)(unsafe.Pointer(pSort)).FlabelDone = _sqlite3VdbeMakeLabel(tls, pParse) + if regOrigData != 0 { + v1 = int32(SQLITE_ECEL_REF) + } else { + v1 = 0 + } + _sqlite3ExprCodeExprList(tls, pParse, (*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy, regBase, regOrigData, libc.Uint8FromInt32(int32(SQLITE_ECEL_DUP)|v1)) + if bSeq != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sequence), (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor, regBase+nExpr) + } + if nPrefixReg == 0 && nData > 0 { + _sqlite3ExprCodeMove(tls, pParse, regData, regBase+nExpr+bSeq, nData) + } + if nOBSat > 0 { /* Original KeyInfo on the sorter table */ + regRecord = _makeSorterRecord(tls, pParse, pSort, pSelect, regBase, nBase) + regPrevKey = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + nKey = nExpr - (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + bSeq + if bSeq != 0 { + addrFirst = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), regBase+nExpr) + } else { + addrFirst = _sqlite3VdbeAddOp1(tls, v, int32(OP_SequenceTest), (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Compare), regPrevKey, regBase, (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat) + pOp = _sqlite3VdbeGetOp(tls, v, (*TSortCtx)(unsafe.Pointer(pSort)).FaddrSortIndex) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return + } + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 = nKey + nData + pKI = *(*uintptr)(unsafe.Pointer(pOp + 16)) + libc.X__builtin___memset_chk(tls, (*TKeyInfo)(unsafe.Pointer(pKI)).FaSortFlags, 0, uint64((*TKeyInfo)(unsafe.Pointer(pKI)).FnKeyField), ^t__predefined_size_t(0)) /* Makes OP_Jump testable */ + _sqlite3VdbeChangeP4(tls, v, -int32(1), pKI, -int32(9)) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = _sqlite3KeyInfoFromExprList(tls, pParse, (*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy, nOBSat, libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKI)).FnAllField)-libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKI)).FnKeyField)-int32(1)) + pOp = uintptr(0) /* Ensure pOp not used after sqlite3VdbeAddOp3() */ + addrJmp = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addrJmp+int32(1), 0, addrJmp+int32(1)) + (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut = _sqlite3VdbeMakeLabel(tls, pParse) + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn, (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResetSorter), (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor) + if iLimit != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNot), iLimit, (*TSortCtx)(unsafe.Pointer(pSort)).FlabelDone) + } + _sqlite3VdbeJumpHere(tls, v, addrFirst) + _sqlite3ExprCodeMove(tls, pParse, regBase, regPrevKey, (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat) + _sqlite3VdbeJumpHere(tls, v, addrJmp) + } + if iLimit != 0 { + /* At this point the values for the new sorter entry are stored + ** in an array of registers. They need to be composed into a record + ** and inserted into the sorter if either (a) there are currently + ** less than LIMIT+OFFSET items or (b) the new record is smaller than + ** the largest record currently in the sorter. If (b) is true and there + ** are already LIMIT+OFFSET items in the sorter, delete the largest + ** entry before inserting the new one. This way there are never more + ** than LIMIT+OFFSET items in the sorter. + ** + ** If the new record does not need to be inserted into the sorter, + ** jump to the next iteration of the loop. If the pSort->labelOBLopt + ** value is not zero, then it is a label of where to jump. Otherwise, + ** just bypass the row insert logic. See the header comment on the + ** sqlite3WhereOrderByLimitOptLabel() function for additional info. + */ + iCsr = (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNotZero), iLimit, _sqlite3VdbeCurrentAddr(tls, v)+int32(4)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Last), iCsr, 0) + iSkip = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxLE), iCsr, 0, regBase+nOBSat, nExpr-nOBSat) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Delete), iCsr) + } + if regRecord == 0 { + regRecord = _makeSorterRecord(tls, pParse, pSort, pSelect, regBase, nBase) + } + if libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&int32(SORTFLAG_UseSorter) != 0 { + op = int32(OP_SorterInsert) + } else { + op = int32(OP_IdxInsert) + } + _sqlite3VdbeAddOp4Int(tls, v, op, (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor, regRecord, regBase+nOBSat, nBase-nOBSat) + if iSkip != 0 { + if (*TSortCtx)(unsafe.Pointer(pSort)).FlabelOBLopt != 0 { + v1 = (*TSortCtx)(unsafe.Pointer(pSort)).FlabelOBLopt + } else { + v1 = _sqlite3VdbeCurrentAddr(tls, v) + } + _sqlite3VdbeChangeP2(tls, v, iSkip, v1) + } +} + +// C documentation +// +// /* +// ** Compare two constraint names. +// ** +// ** Summary: *pRes := zQuote != zCmp +// ** +// ** Details: +// ** Compare the (possibly quoted) constraint name zQuote[0..nQuote-1] +// ** against zCmp[]. Write zero into *pRes if they are the same and +// ** non-zero if they differ. Normally return SQLITE_OK, except if there +// ** is an OOM, set the OOM error condition on ctx and return SQLITE_NOMEM. +// */ +func _quotedCompare(tls *libc.TLS, ctx uintptr, t int32, zQuote uintptr, nQuote int32, zCmp uintptr, pRes uintptr) (r int32) { + var zCopy uintptr + _ = zCopy + zCopy = uintptr(0) /* De-quoted, zero-terminated copy of zQuote[] */ + if t == int32(TK_ILLEGAL) { + **(**int32)(__ccgo_up(pRes)) = int32(1) + return SQLITE_OK + } + zCopy = _sqlite3MallocZero(tls, libc.Uint64FromInt32(nQuote+int32(1))) + if zCopy == uintptr(0) { + Xsqlite3_result_error_nomem(tls, ctx) + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, zCopy, zQuote, libc.Uint64FromInt32(nQuote), ^t__predefined_size_t(0)) + _sqlite3Dequote(tls, zCopy) + **(**int32)(__ccgo_up(pRes)) = Xsqlite3_stricmp(tls, zCopy, zCmp) + Xsqlite3_free(tls, zCopy) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** The SELECT statement iterating through the keys for the current object +// ** (p->objiter.pSelect) currently points to a valid row. However, there +// ** is something wrong with the rbu_control value in the rbu_control value +// ** stored in the (p->nCol+1)'th column. Set the error code and error message +// ** of the RBU handle to something reflecting this. +// */ +func _rbuBadControlError(tls *libc.TLS, p uintptr) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+32068, 0) +} + +// C documentation +// +// /* +// ** The second argument passed to this function is the name of a PRAGMA +// ** setting - "page_size", "auto_vacuum", "user_version" or "application_id". +// ** This function executes the following on sqlite3rbu.dbRbu: +// ** +// ** "PRAGMA main.$zPragma" +// ** +// ** where $zPragma is the string passed as the second argument, then +// ** on sqlite3rbu.dbMain: +// ** +// ** "PRAGMA main.$zPragma = $val" +// ** +// ** where $val is the value returned by the first PRAGMA invocation. +// ** +// ** In short, it copies the value of the specified PRAGMA setting from +// ** dbRbu to dbMain. +// */ +func _rbuCopyPragma(tls *libc.TLS, p uintptr, zPragma uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* pPragma at bp+0 */ uintptr + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+34297, libc.VaList(bp+16, zPragma))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34312, libc.VaList(bp+16, zPragma, Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0))) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + } +} + +// C documentation +// +// /* +// ** If an error has already occurred when this function is called, it +// ** immediately returns zero (without doing any work). Or, if an error +// ** occurs during the execution of this function, it sets the error code +// ** in the sqlite3rbu object indicated by the first argument and returns +// ** zero. +// ** +// ** The iterator passed as the second argument is guaranteed to point to +// ** a table (not an index) when this function is called. This function +// ** attempts to create any imposter table required to write to the main +// ** table b-tree of the table before returning. Non-zero is returned if +// ** an imposter table are created, or zero otherwise. +// ** +// ** An imposter table is required in all cases except RBU_PK_VTAB. Only +// ** virtual tables are written to directly. The imposter table has the +// ** same schema as the actual target table (less any UNIQUE constraints). +// ** More precisely, the "same schema" means the same columns, types, +// ** collation sequences. For tables that do not have an external PRIMARY +// ** KEY, it also means the same PRIMARY KEY declaration. +// */ +func _rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iCol, tnum int32 + var zCol, zComma, zPk, zPk1, zSql, v2 uintptr + var _ /* zColl at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = iCol, tnum, zCol, zComma, zPk, zPk1, zSql, v2 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType != int32(RBU_PK_VTAB) { + tnum = (*TRbuObjIter)(unsafe.Pointer(pIter)).FiTnum + zComma = __ccgo_ts + 1702 + zSql = uintptr(0) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, 0, int32(1))) + iCol = 0 + for { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && iCol < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + zPk = __ccgo_ts + 1702 + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCol)*8)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_table_column_metadata(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zCol, uintptr(0), bp, uintptr(0), uintptr(0), uintptr(0)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) && **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iCol))) != 0 { + /* If the target table column is an "INTEGER PRIMARY KEY", add + ** "PRIMARY KEY" to the imposter table column declaration. */ + zPk = __ccgo_ts + 32348 + } + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabNotNull + uintptr(iCol))) != 0 { + v2 = __ccgo_ts + 32361 + } else { + v2 = __ccgo_ts + 1702 + } + zSql = _rbuMPrintf(tls, p, __ccgo_ts+32371, libc.VaList(bp+16, zSql, zComma, zCol, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCol)*8)), zPk, **(**uintptr)(__ccgo_up(bp)), v2)) + zComma = __ccgo_ts + 16558 + goto _1 + _1: + ; + iCol = iCol + 1 + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_WITHOUT_ROWID) { + zPk1 = _rbuWithoutRowidPK(tls, p, pIter) + if zPk1 != 0 { + zSql = _rbuMPrintf(tls, p, __ccgo_ts+32398, libc.VaList(bp+16, zSql, zPk1)) + } + } + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, int32(1), tnum)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_WITHOUT_ROWID) { + v2 = __ccgo_ts + 32405 + } else { + v2 = __ccgo_ts + 1702 + } + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+32420, libc.VaList(bp+16, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zSql, v2)) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, 0, 0)) + } +} + +// C documentation +// +// /* +// ** This function creates the second imposter table used when writing to +// ** a table b-tree where the table has an external primary key. If the +// ** iterator passed as the second argument does not currently point to +// ** a table (not index) with an external primary key, this function is a +// ** no-op. +// ** +// ** Assuming the iterator does point to a table with an external PK, this +// ** function creates a WITHOUT ROWID imposter table named "rbu_imposter2" +// ** used to access that PK index. For example, if the target table is +// ** declared as follows: +// ** +// ** CREATE TABLE t1(a, b TEXT, c REAL, PRIMARY KEY(b, c)); +// ** +// ** then the imposter table schema is: +// ** +// ** CREATE TABLE rbu_imposter2(c1 TEXT, c2 REAL, id INTEGER) WITHOUT ROWID; +// ** +// */ +func _rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bDesc, bKey, iCid, tnum int32 + var zCollate, zCols, zComma, zIdx, zPk, v1 uintptr + var _ /* pQuery at bp+0 */ uintptr + var _ /* pXInfo at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _ = bDesc, bKey, iCid, tnum, zCollate, zCols, zComma, zIdx, zPk, v1 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) { + tnum = (*TRbuObjIter)(unsafe.Pointer(pIter)).FiPkTnum /* Root page of PK index */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* SELECT name ... WHERE rootpage = $tnum */ + zIdx = uintptr(0) /* Name of PK index */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* PRAGMA main.index_xinfo = $zIdx */ + zComma = __ccgo_ts + 1702 + zCols = uintptr(0) /* Used to build up list of table cols */ + zPk = uintptr(0) /* Used to build up table PK declaration */ + /* Figure out the name of the primary key index for the current table. + ** This is needed for the argument to "PRAGMA index_xinfo". Set + ** zIdx to point to a nul-terminated string containing this name. */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, __ccgo_ts+32189) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_bind_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), tnum) + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zIdx = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + } + if zIdx != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31341, libc.VaList(bp+24, zIdx))) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + bKey = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(5)) + if bKey != 0 { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(1)) + bDesc = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(3)) + zCollate = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(4)) + zCols = _rbuMPrintf(tls, p, __ccgo_ts+32239, libc.VaList(bp+24, zCols, zComma, iCid, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCid)*8)), zCollate)) + if bDesc != 0 { + v1 = __ccgo_ts + 31581 + } else { + v1 = __ccgo_ts + 1702 + } + zPk = _rbuMPrintf(tls, p, __ccgo_ts+32261, libc.VaList(bp+24, zPk, zComma, iCid, v1)) + zComma = __ccgo_ts + 16558 + } + } + zCols = _rbuMPrintf(tls, p, __ccgo_ts+32271, libc.VaList(bp+24, zCols)) + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+24, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, int32(1), tnum)) + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+32286, libc.VaList(bp+24, zCols, zPk)) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+24, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, 0, 0)) + } +} + +// C documentation +// +// /* +// ** The RBU handle passed as the only argument has just been opened and +// ** the state database is empty. If this RBU handle was opened for an +// ** RBU vacuum operation, create the schema in the target db. +// */ +func _rbuCreateTargetSchema(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var zSql uintptr + var _ /* pInsert at bp+8 */ uintptr + var _ /* pSql at bp+0 */ uintptr + _, _ = i, zSql + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34332, uintptr(0), uintptr(0), p+64) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, __ccgo_ts+34357) + } + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { + zSql = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, zSql, uintptr(0), uintptr(0), p+64) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, __ccgo_ts+34465) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, __ccgo_ts+34530) + } + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { + i = 0 + for { + if !(i < int32(5)) { + break + } + Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), i+int32(1), Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp)), i)) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34574, uintptr(0), uintptr(0), p+64) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) +} + +// C documentation +// +// /* +// ** Allocate a private rbu VFS for the rbu handle passed as the only +// ** argument. This VFS will be used unless the call to sqlite3rbu_open() +// ** specified a URI with a vfs=? option in place of a target database +// ** file name. +// */ +func _rbuCreateVfs(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var pVfs uintptr + var _ /* rnd at bp+0 */ int32 + var _ /* zRnd at bp+4 */ [64]int8 + _ = pVfs + Xsqlite3_randomness(tls, int32(4), bp) + Xsqlite3_snprintf(tls, int32(64), bp+4, __ccgo_ts+34652, libc.VaList(bp+80, **(**int32)(__ccgo_up(bp)))) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3rbu_create_vfs(tls, bp+4, uintptr(0)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pVfs = Xsqlite3_vfs_find(tls, bp+4) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FzName + (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRbu = p + } +} + +// C documentation +// +// /* +// ** If there is a "*-oal" file in the file-system corresponding to the +// ** target database in the file-system, delete it. If an error occurs, +// ** leave an error code and error message in the rbu handle. +// */ +func _rbuDeleteOalFile(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var zOal uintptr + var _ /* pVfs at bp+0 */ uintptr + _ = zOal + zOal = _rbuMPrintf(tls, p, __ccgo_ts+34074, libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget)) + if zOal != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, int32(SQLITE_FCNTL_VFS_POINTER), bp) + (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxDelete})))(tls, **(**uintptr)(__ccgo_up(bp)), zOal, 0) + Xsqlite3_free(tls, zOal) + } +} + +// C documentation +// +// /* +// ** Apply a delta. +// ** +// ** The output buffer should be big enough to hold the whole output +// ** file and a NUL terminator at the end. The delta_output_size() +// ** routine will determine this size for you. +// ** +// ** The delta string should be null-terminated. But the delta string +// ** may contain embedded NUL characters (if the input and output are +// ** binary files) so we also have to pass in the length of the delta in +// ** the lenDelta parameter. +// ** +// ** This function returns the size of the output file in bytes (excluding +// ** the final NUL terminator character). Except, if the delta string is +// ** malformed or intended for use with a source file other than zSrc, +// ** then this routine returns -1. +// ** +// ** Refer to the delta_create() documentation above for a description +// ** of the delta file format. +// */ +func _rbuDeltaApply(tls *libc.TLS, zSrc uintptr, lenSrc int32, _zDelta uintptr, _lenDelta int32, zOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _zDelta + *(*int32)(unsafe.Pointer(bp + 8)) = _lenDelta + var cnt, limit, ofst, total uint32 + _, _, _, _ = cnt, limit, ofst, total + total = uint32(0) + limit = _rbuDeltaGetInt(tls, bp, bp+8) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32('\n') { + /* ERROR: size integer not terminated by "\n" */ + return -int32(1) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + for **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0 && **(**int32)(__ccgo_up(bp + 8)) > 0 { + cnt = _rbuDeltaGetInt(tls, bp, bp+8) + switch int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) { + case int32('@'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + ofst = _rbuDeltaGetInt(tls, bp, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) > 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(',') { + /* ERROR: copy command not terminated by ',' */ + return -int32(1) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + total = total + cnt + if total > limit { + /* ERROR: copy exceeds output file size */ + return -int32(1) + } + if uint64(ofst)+uint64(cnt) > libc.Uint64FromInt32(lenSrc) { + /* ERROR: copy extends past end of input */ + return -int32(1) + } + libc.X__builtin___memcpy_chk(tls, zOut, zSrc+uintptr(ofst), uint64(cnt), ^t__predefined_size_t(0)) + zOut = zOut + uintptr(cnt) + case int32(':'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + total = total + cnt + if total > limit { + /* ERROR: insert command gives an output larger than predicted */ + return -int32(1) + } + if libc.Int32FromUint32(cnt) > **(**int32)(__ccgo_up(bp + 8)) { + /* ERROR: insert count exceeds size of delta */ + return -int32(1) + } + libc.X__builtin___memcpy_chk(tls, zOut, **(**uintptr)(__ccgo_up(bp)), uint64(cnt), ^t__predefined_size_t(0)) + zOut = zOut + uintptr(cnt) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(cnt) + **(**int32)(__ccgo_up(bp + 8)) = libc.Int32FromUint32(uint32(**(**int32)(__ccgo_up(bp + 8))) - cnt) + case int32(';'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + **(**int8)(__ccgo_up(zOut)) = 0 + if total != limit { + /* ERROR: generated size does not match predicted size */ + return -int32(1) + } + return libc.Int32FromUint32(total) + default: + /* ERROR: unknown delta operator */ + return -int32(1) + } + } + /* ERROR: unterminated delta */ + return -int32(1) +} + +// C documentation +// +// /* +// ** If the error code currently stored in the RBU handle is SQLITE_CONSTRAINT, +// ** then edit any error message string so as to remove all occurrences of +// ** the pattern "rbu_imp_[0-9]*". +// */ +func _rbuEditErrmsg(tls *libc.TLS, p uintptr) { + var i uint32 + var nDel int32 + var nErrmsg Tsize_t + _, _, _ = i, nDel, nErrmsg + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_CONSTRAINT) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg != 0 { + nErrmsg = libc.Xstrlen(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg) + i = uint32(0) + for { + if !(uint64(i) < nErrmsg-uint64(8)) { + break + } + if libc.Xmemcmp(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i), __ccgo_ts+33021, uint64(8)) == 0 { + nDel = int32(8) + for int32(**(**int8)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + uintptr(i+libc.Uint32FromInt32(nDel))))) >= int32('0') && int32(**(**int8)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + uintptr(i+libc.Uint32FromInt32(nDel))))) <= int32('9') { + nDel = nDel + 1 + } + libc.X__builtin___memmove_chk(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i), (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i+libc.Uint32FromInt32(nDel)), nErrmsg+uint64(1)-uint64(i)-libc.Uint64FromInt32(nDel), ^t__predefined_size_t(0)) + nErrmsg = nErrmsg - libc.Uint64FromInt32(nDel) + } + goto _1 + _1: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** Return true if the database handle passed as the only argument +// ** was opened with the rbu_exclusive_checkpoint=1 URI parameter +// ** specified. Or false otherwise. +// */ +func _rbuExclusiveCheckpoint(tls *libc.TLS, db uintptr) (r int32) { + var zUri uintptr + _ = zUri + zUri = Xsqlite3_db_filename(tls, db, uintptr(0)) + return Xsqlite3_uri_boolean(tls, zUri, __ccgo_ts+34049, 0) +} + +// C documentation +// +// /* +// ** Implementation of SQL scalar function rbu_fossil_delta(). +// ** +// ** This function applies a fossil delta patch to a blob. Exactly two +// ** arguments must be passed to this function. The first is the blob to +// ** patch and the second the patch to apply. If no error occurs, this +// ** function returns the patched blob. +// */ +func _rbuFossilDeltaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var aDelta, aOrig, aOut uintptr + var nDelta, nOrig, nOut, nOut2 int32 + _, _, _, _, _, _, _ = aDelta, aOrig, aOut, nDelta, nOrig, nOut, nOut2 + _ = argc + nOrig = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + aOrig = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + nDelta = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + aDelta = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + /* Figure out the size of the output */ + nOut = _rbuDeltaOutputSize(tls, aDelta, nDelta) + if nOut < 0 { + Xsqlite3_result_error(tls, context, __ccgo_ts+30593, -int32(1)) + return + } + aOut = Xsqlite3_malloc(tls, nOut+int32(1)) + if aOut == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + } else { + nOut2 = _rbuDeltaApply(tls, aOrig, nOrig, aDelta, nDelta, aOut) + if nOut2 != nOut { + Xsqlite3_free(tls, aOut) + Xsqlite3_result_error(tls, context, __ccgo_ts+30593, -int32(1)) + } else { + Xsqlite3_result_blob(tls, context, aOut, nOut, __ccgo_fp(Xsqlite3_free)) + } + } +} + +// C documentation +// +// /* +// ** Set output variable *ppStmt to point to an UPDATE statement that may +// ** be used to update the imposter table for the main table b-tree of the +// ** table object that pIter currently points to, assuming that the +// ** rbu_control column of the data_xyz table contains zMask. +// ** +// ** If the zMask string does not specify any columns to update, then this +// ** is not an error. Output variable *ppStmt is set to NULL in this case. +// */ +func _rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, ppStmt uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var nUp int32 + var pUp, pp, zPrefix, zSet, zUpdate, zWhere uintptr + _, _, _, _, _, _, _ = nUp, pUp, pp, zPrefix, zSet, zUpdate, zWhere + pUp = uintptr(0) + nUp = 0 + /* In case an error occurs */ + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + /* Search for an existing statement. If one is found, shift it to the front + ** of the LRU queue and return immediately. Otherwise, leave nUp pointing + ** to the number of statements currently in the cache and pUp to the + ** last object in the list. */ + pp = pIter + 184 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + pUp = **(**uintptr)(__ccgo_up(pp)) + if libc.Xstrcmp(tls, (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask, zMask) == 0 { + **(**uintptr)(__ccgo_up(pp)) = (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext + (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp + **(**uintptr)(__ccgo_up(ppStmt)) = (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate + return SQLITE_OK + } + nUp = nUp + 1 + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 16 + } + if nUp >= int32(SQLITE_RBU_UPDATE_CACHESIZE) { + pp = pIter + 184 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != pUp) { + break + } + goto _2 + _2: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 16 + } + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + Xsqlite3_finalize(tls, (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate) + (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate = uintptr(0) + } else { + pUp = _rbuMalloc(tls, p, libc.Int64FromUint64(uint64(24)+libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)+uint64(1))) + } + if pUp != 0 { + zWhere = _rbuObjIterGetWhere(tls, p, pIter) + zSet = _rbuObjIterGetSetlist(tls, p, pIter, zMask) + zUpdate = uintptr(0) + (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask = pUp + 1*24 + libc.X__builtin___memcpy_chk(tls, (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask, zMask, libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol), ^t__predefined_size_t(0)) + (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp + if zSet != 0 { + zPrefix = __ccgo_ts + 1702 + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType != int32(RBU_PK_VTAB) { + zPrefix = __ccgo_ts + 33021 + } + zUpdate = Xsqlite3_mprintf(tls, __ccgo_ts+33682, libc.VaList(bp+8, zPrefix, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zSet, zWhere)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pUp+8, p+64, zUpdate) + **(**uintptr)(__ccgo_up(ppStmt)) = (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate + } + Xsqlite3_free(tls, zWhere) + Xsqlite3_free(tls, zSet) + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** Increment the schema cookie of the main database opened by p->dbMain. +// ** +// ** Or, if this is an RBU vacuum, set the schema cookie of the main db +// ** opened by p->dbMain to one more than the schema cookie of the main +// ** db opened by p->dbRbu. +// */ +func _rbuIncrSchemaCookie(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var dbread, v1 uintptr + var iCookie int32 + var _ /* pStmt at bp+0 */ uintptr + _, _, _ = dbread, iCookie, v1 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu + } else { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain + } + dbread = v1 + iCookie = int32(1000000) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, dbread, bp, p+64, __ccgo_ts+34088) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* Coverage: it may be that this sqlite3_step() cannot fail. There + ** is already a transaction open, so the prepared statement cannot + ** throw an SQLITE_SCHEMA exception. The only database page the + ** statement reads is page 1, which is guaranteed to be in the cache. + ** And no memory allocations are required. */ + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iCookie = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34110, libc.VaList(bp+16, iCookie+int32(1))) + } + } +} + +// C documentation +// +// /* +// ** This user-defined SQL function is invoked with a single argument - the +// ** name of a table expected to appear in the target database. It returns +// ** the number of auxilliary indexes on the table. +// */ +func _rbuIndexCntFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, v1 uintptr + var nIndex, rc int32 + var _ /* pStmt at bp+0 */ uintptr + var _ /* zErrmsg at bp+8 */ uintptr + _, _, _, _, _ = db, nIndex, p, rc, v1 + p = Xsqlite3_user_data(tls, pCtx) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu + } else { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain + } + db = v1 + _ = nVal + rc = _prepareFreeAndCollectError(tls, db, bp, bp+8, Xsqlite3_mprintf(tls, __ccgo_ts+34663, libc.VaList(bp+24, Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal)))))) + if rc != SQLITE_OK { + Xsqlite3_result_error(tls, pCtx, **(**uintptr)(__ccgo_up(bp + 8)), -int32(1)) + } else { + nIndex = 0 + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + nIndex = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + Xsqlite3_result_int(tls, pCtx, nIndex) + } else { + Xsqlite3_result_error(tls, pCtx, Xsqlite3_errmsg(tls, db), -int32(1)) + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) +} + +// C documentation +// +// /* +// ** If the RBU database contains the rbu_count table, use it to initialize +// ** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table +// ** is assumed to contain the same columns as: +// ** +// ** CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID; +// ** +// ** There should be one row in the table for each data_xxx table in the +// ** database. The 'tbl' column should contain the name of a data_xxx table, +// ** and the cnt column the number of rows it contains. +// ** +// ** sqlite3rbu.nPhaseOneStep is initialized to the sum of (1 + nIndex) * cnt +// ** for all rows in the rbu_count table, where nIndex is the number of +// ** indexes on the corresponding target database table. +// */ +func _rbuInitPhaseOneSteps(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bExists int32 + var _ /* pStmt at bp+0 */ uintptr + _ = bExists + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + bExists = 0 /* True if rbu_count exists */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = int64(-int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+34735, int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_rbuIndexCntFunc), uintptr(0), uintptr(0)) + /* Check for the rbu_count table. If it does not exist, or if an error + ** occurs, nPhaseOneStep will be left set to -1. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, __ccgo_ts+34749) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + bExists = int32(1) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && bExists != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, __ccgo_ts+34806) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + } +} + +// C documentation +// +// /* +// ** Allocate an RbuState object and load the contents of the rbu_state +// ** table into it. Return a pointer to the new object. It is the +// ** responsibility of the caller to eventually free the object using +// ** sqlite3_free(). +// ** +// ** If an error occurs, leave an error code and message in the rbu handle +// ** and return NULL. +// */ +func _rbuLoadState(tls *libc.TLS, p uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pRet uintptr + var rc2 int32 + var _ /* pStmt at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _ = pRet, rc2 + pRet = uintptr(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pRet = _rbuMalloc(tls, p, int64(80)) + if pRet == uintptr(0) { + return uintptr(0) + } + **(**int32)(__ccgo_up(bp + 8)) = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+33712, libc.VaList(bp+24, p+48))) + for **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + switch Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) { + case int32(RBU_STATE_STAGE): + (*TRbuState)(unsafe.Pointer(pRet)).FeStage = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + if (*TRbuState)(unsafe.Pointer(pRet)).FeStage != int32(RBU_STAGE_OAL) && (*TRbuState)(unsafe.Pointer(pRet)).FeStage != int32(RBU_STAGE_MOVE) && (*TRbuState)(unsafe.Pointer(pRet)).FeStage != int32(RBU_STAGE_CKPT) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_CORRUPT) + } + case int32(RBU_STATE_TBL): + (*TRbuState)(unsafe.Pointer(pRet)).FzTbl = _rbuStrndup(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)), bp+8) + case int32(RBU_STATE_IDX): + (*TRbuState)(unsafe.Pointer(pRet)).FzIdx = _rbuStrndup(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)), bp+8) + case int32(RBU_STATE_ROW): + (*TRbuState)(unsafe.Pointer(pRet)).FnRow = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_PROGRESS): + (*TRbuState)(unsafe.Pointer(pRet)).FnProgress = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_CKPT): + (*TRbuState)(unsafe.Pointer(pRet)).FiWalCksum = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_COOKIE): + (*TRbuState)(unsafe.Pointer(pRet)).FiCookie = libc.Uint32FromInt64(Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1))) + case int32(RBU_STATE_OALSZ): + (*TRbuState)(unsafe.Pointer(pRet)).FiOalSz = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_PHASEONESTEP): + (*TRbuState)(unsafe.Pointer(pRet)).FnPhaseOneStep = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_DATATBL): + (*TRbuState)(unsafe.Pointer(pRet)).FzDataTbl = _rbuStrndup(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)), bp+8) + default: + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_CORRUPT) + break + } + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = rc2 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = **(**int32)(__ccgo_up(bp + 8)) + return pRet +} + +// C documentation +// +// /* +// ** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if +// ** successful, or an SQLite error code otherwise. +// */ +func _rbuLockDatabase(tls *libc.TLS, db uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* fd at bp+0 */ uintptr + _ = rc + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + Xsqlite3_file_control(tls, db, __ccgo_ts+7160, int32(RBU_ZIPVFS_CTRL_FILE_POINTER), bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + Xsqlite3_file_control(tls, db, __ccgo_ts+7160, int32(SQLITE_FCNTL_FILE_POINTER), bp) + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_SHARED)) + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxUnlock})))(tls, **(**uintptr)(__ccgo_up(bp)), SQLITE_LOCK_NONE) + } + Xsqlite3_file_control(tls, db, __ccgo_ts+7160, int32(RBU_ZIPVFS_CTRL_FILE_POINTER), bp) + } else { + Xsqlite3_file_control(tls, db, __ccgo_ts+7160, int32(SQLITE_FCNTL_FILE_POINTER), bp) + } + if rc == SQLITE_OK && (*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods != 0 { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_SHARED)) + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_EXCLUSIVE)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Attempt to allocate and return a pointer to a zeroed block of nByte +// ** bytes. +// ** +// ** If an error (i.e. an OOM condition) occurs, return NULL and leave an +// ** error code in the rbu handle passed as the first argument. Or, if an +// ** error has already occurred when this function is called, return NULL +// ** immediately without attempting the allocation or modifying the stored +// ** error code. +// */ +func _rbuMalloc(tls *libc.TLS, p uintptr, nByte Tsqlite3_int64) (r uintptr) { + var pRet uintptr + _ = pRet + pRet = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pRet == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pRet, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + } + } + return pRet +} + +// C documentation +// +// /* +// ** Allocate and return an RBU handle with all fields zeroed except for the +// ** error code, which is set to SQLITE_MISUSE. +// */ +func _rbuMisuseError(tls *libc.TLS) (r uintptr) { + var pRet uintptr + _ = pRet + pRet = Xsqlite3_malloc64(tls, uint64(416)) + if pRet != 0 { + libc.X__builtin___memset_chk(tls, pRet, 0, uint64(416), ^t__predefined_size_t(0)) + (*Tsqlite3rbu)(unsafe.Pointer(pRet)).Frc = int32(SQLITE_MISUSE) + } + return pRet +} + +// C documentation +// +// /* +// ** The RBU handle is currently in RBU_STAGE_OAL state, with a SHARED lock +// ** on the database file. This proc moves the *-oal file to the *-wal path, +// ** then reopens the database file (this time in vanilla, non-oal, WAL mode). +// ** If an error occurs, leave an error code and error message in the rbu +// ** handle. +// */ +func _rbuMoveOalFile(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var dbMain, zBase, zMove, zOal, zWal uintptr + _, _, _, _, _ = dbMain, zBase, zMove, zOal, zWal + zBase = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160) + zMove = zBase + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + zMove = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+7160) + } + zOal = Xsqlite3_mprintf(tls, __ccgo_ts+34074, libc.VaList(bp+8, zMove)) + zWal = Xsqlite3_mprintf(tls, __ccgo_ts+34081, libc.VaList(bp+8, zMove)) + if zWal == uintptr(0) || zOal == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + /* Move the *-oal file to *-wal. At this point connection p->db is + ** holding a SHARED lock on the target database file (because it is + ** in WAL mode). So no other connection may be writing the db. + ** + ** In order to ensure that there are no database readers, an EXCLUSIVE + ** lock is obtained here before the *-oal is moved to *-wal. + */ + dbMain = uintptr(0) + _rbuFileSuffix3(tls, zBase, zWal) + _rbuFileSuffix3(tls, zBase, zOal) + /* Re-open the databases. */ + _rbuObjIterFinalize(tls, p+88) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu = uintptr(0) + dbMain = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget, int32(1)) + if dbMain != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _rbuLockDatabase(tls, dbMain) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3rbu)(unsafe.Pointer(p)).FxRename})))(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FpRenameArg, zOal, zWal) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK || (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) || _rbuExclusiveCheckpoint(tls, dbMain) == 0 { + Xsqlite3_close(tls, dbMain) + dbMain = uintptr(0) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuOpenDatabase(tls, p, dbMain, uintptr(0)) + _rbuSetupCheckpoint(tls, p, uintptr(0)) + } + } + Xsqlite3_free(tls, zWal) + Xsqlite3_free(tls, zOal) +} + +// C documentation +// +// /* +// ** This is a helper function for rbuObjIterCacheTableInfo(). It populates +// ** the pIter->abIndexed[] array. +// */ +func _rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bIndex, bPartial, iCid int32 + var zIdx uintptr + var _ /* pList at bp+0 */ uintptr + var _ /* pXInfo at bp+8 */ uintptr + _, _, _, _ = bIndex, bPartial, iCid, zIdx + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + bIndex = 0 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + libc.X__builtin___memcpy_chk(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, (*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk, uint64(1)*libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol), ^t__predefined_size_t(0)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31313, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex = 0 + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zIdx = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + bPartial = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if zIdx == uintptr(0) { + break + } + if bPartial != 0 { + libc.X__builtin___memset_chk(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, int32(0x01), uint64(1)*libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol), ^t__predefined_size_t(0)) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31341, libc.VaList(bp+24, zIdx))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(1)) + if iCid >= 0 { + **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed + uintptr(iCid))) = uint8(1) + } + if iCid == -int32(2) { + libc.X__builtin___memset_chk(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, int32(0x01), uint64(1)*libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol), ^t__predefined_size_t(0)) + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + bIndex = int32(1) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex = (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex + 1 + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_WITHOUT_ROWID) { + /* "PRAGMA index_list" includes the main PK b-tree */ + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex = (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex - 1 + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + if bIndex == 0 { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed = uintptr(0) + } +} + +// C documentation +// +// /* +// ** If they are not already populated, populate the pIter->azTblCol[], +// ** pIter->abTblPk[], pIter->nTblCol and pIter->bRowid variables according to +// ** the table (not index) that the iterator currently points to. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code otherwise. If +// ** an error does occur, an error code and error message are also left in +// ** the RBU handle. +// */ +func _rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bNotNull, bRbuRowid, i, iOrder, iPk, nCol, t, v2 int32 + var t1, zCopy, zName, zName1, zType, v3 uintptr + var _ /* iTnum at bp+8 */ int32 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNotNull, bRbuRowid, i, iOrder, iPk, nCol, t, t1, zCopy, zName, zName1, zType, v2, v3 + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol == uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + nCol = 0 /* for() loop iterator variable */ + bRbuRowid = 0 /* If input table has column "rbu_rowid" */ + iOrder = 0 + **(**int32)(__ccgo_up(bp + 8)) = 0 + /* Figure out the type of table this step will deal with. */ + _rbuTableType(tls, p, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, pIter+72, bp+8, pIter+108) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NOTABLE { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+21690, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FiTnum = **(**int32)(__ccgo_up(bp + 8)) + } + /* Populate the azTblCol[] and nTblCol variables based on the columns + ** of the input table. Ignore any input table columns that begin with + ** "rbu_". */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31370, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + nCol = Xsqlite3_column_count(tls, **(**uintptr)(__ccgo_up(bp))) + _rbuAllocateIterArrays(tls, p, pIter, nCol) + } + i = 0 + for { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && i < nCol) { + break + } + zName = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), i) + if Xsqlite3_strnicmp(tls, __ccgo_ts+31389, zName, int32(4)) != 0 { + zCopy = _rbuStrndup(tls, zName, p+56) + **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)*4)) = (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol + v3 = pIter + 16 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(v2)*8)) = zCopy + } else { + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+31394, zName) { + bRbuRowid = int32(1) + } + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && bRbuRowid != libc.BoolInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE)) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + if bRbuRowid != 0 { + v3 = __ccgo_ts + 31404 + } else { + v3 = __ccgo_ts + 31417 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+31426, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, v3)) + } + /* Check that all non-HIDDEN columns in the destination table are also + ** present in the input table. Populate the abTblPk[], azTblType[] and + ** aiTblOrder[] arrays at the same time. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31455, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) + } + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zName1 = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + if zName1 == uintptr(0) { + break + } /* An OOM - finalize() below returns S_NOMEM */ + i = iOrder + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if 0 == libc.Xstrcmp(tls, zName1, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8))) { + break + } + goto _5 + _5: + ; + i = i + 1 + } + if i == (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+31477, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zName1)) + } else { + iPk = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(5)) + bNotNull = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) + zType = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(2)) + if i != iOrder { + t = **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4)) + **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4)) = **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(iOrder)*4)) + **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(iOrder)*4)) = t + t1 = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iOrder)*8)) + **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iOrder)*8)) = t1 + } + **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iOrder)*8)) = _rbuStrndup(tls, zType, p+56) + **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iOrder))) = libc.Uint8FromInt32(iPk) + **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabNotNull + uintptr(iOrder))) = libc.BoolUint8(libc.Uint8FromInt32(bNotNull) != 0 || iPk != 0) + iOrder = iOrder + 1 + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + _rbuObjIterCacheIndexedCols(tls, p, pIter) + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** Clean up any resources allocated as part of the iterator object passed +// ** as the only argument. +// */ +func _rbuObjIterFinalize(tls *libc.TLS, pIter uintptr) { + _rbuObjIterClearStatements(tls, pIter) + Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter) + Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter) + _rbuObjIterFreeCols(tls, pIter) + libc.X__builtin___memset_chk(tls, pIter, 0, uint64(192), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Initialize the iterator structure passed as the second argument. +// ** +// ** If no error occurs, SQLITE_OK is returned and the iterator is left +// ** pointing to the first entry. Otherwise, an error code and message is +// ** left in the RBU handle passed as the first argument. A copy of the +// ** error code is returned. +// */ +func _rbuObjIterFirst(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var v1 uintptr + _, _ = rc, v1 + libc.X__builtin___memset_chk(tls, pIter, 0, uint64(192), ^t__predefined_size_t(0)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = __ccgo_ts + 30785 + } else { + v1 = __ccgo_ts + 1702 + } + rc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30826, libc.VaList(bp+8, v1))) + if rc == SQLITE_OK { + rc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+8, p+64, __ccgo_ts+30976) + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = int32(1) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + return _rbuObjIterNext(tls, p, pIter) +} + +// C documentation +// +// /* +// ** This function constructs and returns a pointer to a nul-terminated +// ** string containing some SQL clause or list based on one or more of the +// ** column names currently stored in the pIter->azTblCol[] array. +// */ +func _rbuObjIterGetCollist(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var z, zList, zSep uintptr + _, _, _, _ = i, z, zList, zSep + zList = uintptr(0) + zSep = __ccgo_ts + 1702 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + z = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + zList = _rbuMPrintf(tls, p, __ccgo_ts+31504, libc.VaList(bp+8, zList, zSep, z)) + zSep = __ccgo_ts + 16558 + goto _1 + _1: + ; + i = i + 1 + } + return zList +} + +// C documentation +// +// /* +// ** This function is used to create a SELECT list (the list of SQL +// ** expressions that follows a SELECT keyword) for a SELECT statement +// ** used to read from an data_xxx or rbu_tmp_xxx table while updating the +// ** index object currently indicated by the iterator object passed as the +// ** second argument. A "PRAGMA index_xinfo = " statement is used +// ** to obtain the required information. +// ** +// ** If the index is of the following form: +// ** +// ** CREATE INDEX i1 ON t1(c, b COLLATE nocase); +// ** +// ** and "t1" is a table with an explicit INTEGER PRIMARY KEY column +// ** "ipk", the returned string is: +// ** +// ** "`c` COLLATE 'BINARY', `b` COLLATE 'NOCASE', `ipk` COLLATE 'BINARY'" +// ** +// ** As well as the returned string, three other malloc'd strings are +// ** returned via output parameters. As follows: +// ** +// ** pzImposterCols: ... +// ** pzImposterPk: ... +// ** pzWhere: ... +// */ +func _rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterCols uintptr, pzImposterPk uintptr, pzWhere uintptr, pnBind uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bDesc, i, iCid, iSeq, nBind, rc, rc2 int32 + var zAnd, zCol, zCollate, zCom, zImpCols, zImpPK, zOrder, zRet, zType, zWhere, v2 uintptr + var _ /* pXInfo at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bDesc, i, iCid, iSeq, nBind, rc, rc2, zAnd, zCol, zCollate, zCom, zImpCols, zImpPK, zOrder, zRet, zType, zWhere, v2 + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc /* sqlite3_finalize() return code */ + zRet = uintptr(0) /* String to return */ + zImpCols = uintptr(0) /* String to return via *pzImposterCols */ + zImpPK = uintptr(0) /* String to return via *pzImposterPK */ + zWhere = uintptr(0) /* String to return via *pzWhere */ + nBind = 0 /* Value to return via *pnBind */ + zCom = __ccgo_ts + 1702 /* Set to ", " later on */ + zAnd = __ccgo_ts + 1702 /* Set to " AND " later on */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* PRAGMA index_xinfo = ? */ + if rc == SQLITE_OK { + rc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31341, libc.VaList(bp+16, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) + } + for rc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + bDesc = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) + zCollate = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + zCol = uintptr(0) + if iCid == -int32(2) { + iSeq = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+31823, libc.VaList(bp+16, zRet, zCom, (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iSeq)*16))).FnSpan, (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iSeq)*16))).FzSpan, zCollate)) + zType = __ccgo_ts + 1702 + } else { + if iCid < 0 { + /* An integer primary key. If the table has an explicit IPK, use + ** its name. Otherwise, use "rbu_rowid". */ + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) { + i = 0 + for { + if !(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + zCol = __ccgo_ts + 31664 + } else { + zCol = __ccgo_ts + 31394 + } + } + zType = __ccgo_ts + 1176 + } else { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCid)*8)) + zType = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCid)*8)) + } + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+31845, libc.VaList(bp+16, zRet, zCom, zCol, zCollate)) + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FbUnique == 0 || Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(5)) != 0 { + if bDesc != 0 { + v2 = __ccgo_ts + 31581 + } else { + v2 = __ccgo_ts + 1702 + } + zOrder = v2 + zImpPK = Xsqlite3_mprintf(tls, __ccgo_ts+31865, libc.VaList(bp+16, zImpPK, zCom, nBind, zCol, zOrder)) + } + zImpCols = Xsqlite3_mprintf(tls, __ccgo_ts+31886, libc.VaList(bp+16, zImpCols, zCom, nBind, zCol, zType, zCollate)) + zWhere = Xsqlite3_mprintf(tls, __ccgo_ts+31919, libc.VaList(bp+16, zWhere, zAnd, nBind, zCol)) + if zRet == uintptr(0) || zImpPK == uintptr(0) || zImpCols == uintptr(0) || zWhere == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + zCom = __ccgo_ts + 16558 + zAnd = __ccgo_ts + 23951 + nBind = nBind + 1 + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + rc = rc2 + } + if rc != SQLITE_OK { + Xsqlite3_free(tls, zRet) + Xsqlite3_free(tls, zImpCols) + Xsqlite3_free(tls, zImpPK) + Xsqlite3_free(tls, zWhere) + zRet = uintptr(0) + zImpCols = uintptr(0) + zImpPK = uintptr(0) + zWhere = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + **(**uintptr)(__ccgo_up(pzImposterCols)) = zImpCols + **(**uintptr)(__ccgo_up(pzImposterPk)) = zImpPK + **(**uintptr)(__ccgo_up(pzWhere)) = zWhere + **(**int32)(__ccgo_up(pnBind)) = nBind + return zRet +} + +func _rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aIdxCol, zRet, zSql, v1 uintptr + var c int8 + var i, iIdxCol, nIdxAlloc, nParen, nSpan, nSpan1, rc2, v3 int32 + var _ /* pStmt at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = aIdxCol, c, i, iIdxCol, nIdxAlloc, nParen, nSpan, nSpan1, rc2, zRet, zSql, v1, v3 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + zRet = uintptr(0) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, __ccgo_ts+32509) + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = Xsqlite3_bind_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx, -int32(1), libc.UintptrFromInt32(0)) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zSql = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + if zSql != 0 { + v1 = _rbuStrndup(tls, zSql, bp+8) + zSql = v1 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = v1 + } + if zSql != 0 { + nParen = 0 + iIdxCol = 0 + nIdxAlloc = 0 + i = 0 + for { + if !(**(**int8)(__ccgo_up(zSql + uintptr(i))) != 0) { + break + } + c = **(**int8)(__ccgo_up(zSql + uintptr(i))) + /* If necessary, grow the pIter->aIdxCol[] array */ + if iIdxCol == nIdxAlloc { + aIdxCol = Xsqlite3_realloc64(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol, uint64(libc.Uint64FromInt32(nIdxAlloc)*uint64(16)+libc.Uint64FromInt32(16)*libc.Uint64FromInt64(16))) + if aIdxCol == uintptr(0) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_NOMEM) + break + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = aIdxCol + nIdxAlloc = nIdxAlloc + int32(16) + } + if int32(c) == int32('(') { + if nParen == 0 { + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol))).FzSpan = zSql + uintptr(i+int32(1)) + } + nParen = nParen + 1 + } else { + if int32(c) == int32(')') { + nParen = nParen - 1 + if nParen == 0 { + nSpan = int32(t__predefined_ptrdiff_t(zSql+uintptr(i)) - int64((**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan)) + v3 = iIdxCol + iIdxCol = iIdxCol + 1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(v3)*16))).FnSpan = nSpan + i = i + 1 + break + } + } else { + if int32(c) == int32(',') && nParen == int32(1) { + nSpan1 = int32(t__predefined_ptrdiff_t(zSql+uintptr(i)) - int64((**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan)) + v3 = iIdxCol + iIdxCol = iIdxCol + 1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(v3)*16))).FnSpan = nSpan1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan = zSql + uintptr(i+int32(1)) + } else { + if int32(c) == int32('"') || int32(c) == int32('\'') || int32(c) == int32('`') { + i = i + 1 + for { + if !(int32(1) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) == int32(c) { + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i+int32(1))))) != int32(c) { + break + } + i = i + 1 + } + goto _5 + _5: + ; + i = i + 1 + } + } else { + if int32(c) == int32('[') { + i = i + 1 + for { + if !(int32(1) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) == int32(']') { + break + } + goto _6 + _6: + ; + i = i + 1 + } + } else { + if int32(c) == int32('-') && int32(**(**int8)(__ccgo_up(zSql + uintptr(i+int32(1))))) == int32('-') { + i = i + int32(2) + for { + if !(**(**int8)(__ccgo_up(zSql + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) != int32('\n')) { + break + } + goto _7 + _7: + ; + i = i + 1 + } + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) == int32('\000') { + break + } + } else { + if int32(c) == int32('/') && int32(**(**int8)(__ccgo_up(zSql + uintptr(i+int32(1))))) == int32('*') { + i = i + int32(2) + for { + if !(**(**int8)(__ccgo_up(zSql + uintptr(i))) != 0 && (int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) != int32('*') || int32(**(**int8)(__ccgo_up(zSql + uintptr(i+int32(1))))) != int32('/'))) { + break + } + goto _8 + _8: + ; + i = i + 1 + } + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) == int32('\000') { + break + } + i = i + 1 + } + } + } + } + } + } + } + goto _2 + _2: + ; + i = i + 1 + } + if **(**int8)(__ccgo_up(zSql + uintptr(i))) != 0 { + zRet = _rbuStrndup(tls, zSql+uintptr(i), bp+8) + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIdxCol = iIdxCol + } + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = rc2 + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = **(**int32)(__ccgo_up(bp + 8)) + return zRet +} + +// C documentation +// +// /* +// ** Assuming the current table columns are "a", "b" and "c", and the zObj +// ** paramter is passed "old", return a string of the form: +// ** +// ** "old.a, old.b, old.b" +// ** +// ** With the column names escaped. +// ** +// ** For tables with implicit rowids - RBU_PK_EXTERNAL and RBU_PK_NONE, append +// ** the text ", old._rowid_" to the returned value. +// */ +func _rbuObjIterGetOldlist(tls *libc.TLS, p uintptr, pIter uintptr, zObj uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var zCol, zList, zS uintptr + _, _, _, _ = i, zCol, zList, zS + zList = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 { + zS = __ccgo_ts + 1702 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed + uintptr(i))) != 0 { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + zList = Xsqlite3_mprintf(tls, __ccgo_ts+31943, libc.VaList(bp+8, zList, zS, zObj, zCol)) + } else { + zList = Xsqlite3_mprintf(tls, __ccgo_ts+31955, libc.VaList(bp+8, zList, zS)) + } + zS = __ccgo_ts + 16558 + if zList == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + break + } + goto _1 + _1: + ; + i = i + 1 + } + /* For a table with implicit rowids, append "old._rowid_" to the list. */ + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31964, libc.VaList(bp+8, zList, zObj)) + } + } + return zList +} + +// C documentation +// +// /* +// ** Return a comma separated list of the quoted PRIMARY KEY column names, +// ** in order, for the current table. Before each column name, add the text +// ** zPre. After each column name, add the zPost text. Use zSeparator as +// ** the separator text (usually ", "). +// */ +func _rbuObjIterGetPkList(tls *libc.TLS, p uintptr, pIter uintptr, zPre uintptr, zSeparator uintptr, zPost uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, iPk int32 + var zCol, zRet, zSep uintptr + _, _, _, _, _ = i, iPk, zCol, zRet, zSep + iPk = int32(1) + zRet = uintptr(0) + zSep = __ccgo_ts + 1702 + for int32(1) != 0 { + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == iPk { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31513, libc.VaList(bp+8, zRet, zSep, zPre, zCol, zPost)) + zSep = zSeparator + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i == (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { + break + } + iPk = iPk + 1 + } + return zRet +} + +// C documentation +// +// /* +// ** Return a nul-terminated string containing the comma separated list of +// ** assignments that should be included following the "SET" keyword of +// ** an UPDATE statement used to update the table object that the iterator +// ** passed as the second argument currently points to if the rbu_control +// ** column of the data_xxx table entry is set to zMask. +// ** +// ** The memory for the returned string is obtained from sqlite3_malloc(). +// ** It is the responsibility of the caller to eventually free it using +// ** sqlite3_free(). +// ** +// ** If an OOM error is encountered when allocating space for the new +// ** string, an error code is left in the rbu handle passed as the first +// ** argument and NULL is returned. Or, if an error has already occurred +// ** when this function is called, NULL is returned immediately, without +// ** attempting the allocation or modifying the stored error code. +// */ +func _rbuObjIterGetSetlist(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var c int8 + var i int32 + var zList, zSep uintptr + _, _, _, _ = c, i, zList, zSep + zList = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if libc.Int32FromUint64(libc.Xstrlen(tls, zMask)) != (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { + _rbuBadControlError(tls, p) + } else { + zSep = __ccgo_ts + 1702 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + c = **(**int8)(__ccgo_up(zMask + uintptr(**(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4))))) + if int32(c) == int32('x') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+32055, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16558 + } else { + if int32(c) == int32('d') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+32094, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16558 + } else { + if int32(c) == int32('f') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+32124, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16558 + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + } + return zList +} + +// C documentation +// +// /* +// ** Return an expression that can be used in a WHERE clause to match the +// ** primary key of the current table. For example, if the table is: +// ** +// ** CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c)); +// ** +// ** Return the string: +// ** +// ** "b = ?1 AND c = ?2" +// */ +func _rbuObjIterGetWhere(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, i1 int32 + var zCol, zList, zSep, zSep1 uintptr + _, _, _, _, _, _ = i, i1, zCol, zList, zSep, zSep1 + zList = uintptr(0) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31979, libc.VaList(bp+8, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+int32(1))) + } else { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) { + zSep = __ccgo_ts + 1702 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31993, libc.VaList(bp+8, zList, zSep, i, i+int32(1))) + zSep = __ccgo_ts + 23951 + } + goto _1 + _1: + ; + i = i + 1 + } + zList = _rbuMPrintf(tls, p, __ccgo_ts+32005, libc.VaList(bp+8, zList)) + } else { + zSep1 = __ccgo_ts + 1702 + i1 = 0 + for { + if !(i1 < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i1))) != 0 { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i1)*8)) + zList = _rbuMPrintf(tls, p, __ccgo_ts+32055, libc.VaList(bp+8, zList, zSep1, zCol, i1+int32(1))) + zSep1 = __ccgo_ts + 23951 + } + goto _2 + _2: + ; + i1 = i1 + 1 + } + } + } + return zList +} + +// C documentation +// +// /* +// ** Advance the iterator to the next position. +// ** +// ** If no error occurs, SQLITE_OK is returned and the iterator is left +// ** pointing to the next entry. Otherwise, an error code and message is +// ** left in the RBU handle passed as the first argument. A copy of the +// ** error code is returned. +// */ +func _rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + var pIdx uintptr + var rc, v1 int32 + _, _, _ = pIdx, rc, v1 + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + if rc == SQLITE_OK { + /* Free any SQLite statements used while processing the previous object */ + _rbuObjIterClearStatements(tls, pIter) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+30614, uintptr(0), uintptr(0), p+64) + } + if rc == SQLITE_OK { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 { + _rbuObjIterFreeCols(tls, pIter) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 0 + rc = Xsqlite3_step(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter) + if rc != int32(SQLITE_ROW) { + rc = _resetAndCollectError(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, p+64) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl = uintptr(0) + } else { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl = Xsqlite3_column_text(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, 0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl = Xsqlite3_column_text(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, int32(1)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl != 0 && (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 { + v1 = SQLITE_OK + } else { + v1 = int32(SQLITE_NOMEM) + } + rc = v1 + } + } else { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + pIdx = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter + rc = Xsqlite3_bind_text(tls, pIdx, int32(1), (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, -int32(1), libc.UintptrFromInt32(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_step(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter) + if rc != int32(SQLITE_ROW) { + rc = _resetAndCollectError(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, p+64) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = int32(1) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx = uintptr(0) + } else { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx = Xsqlite3_column_text(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FiTnum = Xsqlite3_column_int(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, int32(1)) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FbUnique = Xsqlite3_column_int(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, int32(2)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx != 0 { + v1 = SQLITE_OK + } else { + v1 = int32(SQLITE_NOMEM) + } + rc = v1 + } + } + } + } + } + if rc != SQLITE_OK { + _rbuObjIterFinalize(tls, pIter) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + return rc +} + +// C documentation +// +// /* +// ** Ensure that the SQLite statement handles required to update the +// ** target database object currently indicated by the iterator passed +// ** as the second argument are available. +// */ +func _rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var bRbuRowid, tnum int32 + var pz, zBind, zBindings, zCollist, zIdx, zLimit, zNewlist, zOldlist, zOrder, zPart, zRbuRowid, zRbuRowid1, zSql, zStart, zStart1, zTbl, zTbl1, zWhere1, zWrite, v1, v2, v3 uintptr + var _ /* nBind at bp+24 */ int32 + var _ /* zImposterCols at bp+0 */ uintptr + var _ /* zImposterPK at bp+8 */ uintptr + var _ /* zWhere at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bRbuRowid, pz, tnum, zBind, zBindings, zCollist, zIdx, zLimit, zNewlist, zOldlist, zOrder, zPart, zRbuRowid, zRbuRowid1, zSql, zStart, zStart1, zTbl, zTbl1, zWhere1, zWrite, v1, v2, v3 + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect == uintptr(0) && _rbuObjIterCacheTableInfo(tls, p, pIter) == SQLITE_OK { + tnum = (*TRbuObjIter)(unsafe.Pointer(pIter)).FiTnum + zCollist = uintptr(0) /* List of indexed columns */ + pz = p + 64 + zIdx = (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx + zLimit = uintptr(0) + if nOffset != 0 { + zLimit = Xsqlite3_mprintf(tls, __ccgo_ts+32575, libc.VaList(bp+40, nOffset)) + if !(zLimit != 0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } + } + if zIdx != 0 { + zTbl = (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Columns for imposter table */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Primary key declaration for imposter */ + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) /* WHERE clause on PK columns */ + zBind = uintptr(0) + zPart = uintptr(0) + **(**int32)(__ccgo_up(bp + 24)) = 0 + zPart = _rbuObjIterGetIndexWhere(tls, p, pIter) + zCollist = _rbuObjIterGetIndexCols(tls, p, pIter, bp, bp+8, bp+16, bp+24) + zBind = _rbuObjIterGetBindlist(tls, p, **(**int32)(__ccgo_up(bp + 24))) + /* Create the imposter table used to write to this index. */ + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+40, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, 0, int32(1))) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+40, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, int32(1), tnum)) + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+32595, libc.VaList(bp+40, zTbl, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 8)))) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+40, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, 0, 0)) + /* Create the statement to insert index entries */ + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol = **(**int32)(__ccgo_up(bp + 24)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+136, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+32660, libc.VaList(bp+40, zTbl, zBind))) + } + /* And to delete index entries */ + if libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+144, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+32696, libc.VaList(bp+40, zTbl, **(**uintptr)(__ccgo_up(bp + 16))))) + } + /* Create the SELECT statement to read keys in sorted order */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + zStart = uintptr(0) + if nOffset != 0 { + zStart = _rbuVacuumIndexStart(tls, p, pIter) + if zStart != 0 { + Xsqlite3_free(tls, zLimit) + zLimit = uintptr(0) + } + } + if zStart != 0 { + if zPart != 0 { + v2 = __ccgo_ts + 32730 + } else { + v2 = __ccgo_ts + 32734 + } + v1 = v2 + } else { + v1 = __ccgo_ts + 1702 + } + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+32740, libc.VaList(bp+40, zCollist, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart, v1, zStart, zCollist, zLimit)) + Xsqlite3_free(tls, zStart) + } else { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+32801, libc.VaList(bp+40, zCollist, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart, zCollist, zLimit)) + } else { + if zPart != 0 { + v1 = __ccgo_ts + 32730 + } else { + v1 = __ccgo_ts + 32734 + } + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+32862, libc.VaList(bp+40, zCollist, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart, zCollist, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart, v1, zCollist, zLimit)) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+128, pz, zSql) + } else { + Xsqlite3_free(tls, zSql) + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 16))) + Xsqlite3_free(tls, zBind) + Xsqlite3_free(tls, zPart) + } else { + bRbuRowid = libc.BoolInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) + zTbl1 = (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl /* Imposter table name */ + zBindings = _rbuObjIterGetBindlist(tls, p, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+bRbuRowid) + zWhere1 = _rbuObjIterGetWhere(tls, p, pIter) + zOldlist = _rbuObjIterGetOldlist(tls, p, pIter, __ccgo_ts+7171) + zNewlist = _rbuObjIterGetOldlist(tls, p, pIter, __ccgo_ts+7167) + zCollist = _rbuObjIterGetCollist(tls, p, pIter) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol = (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol + /* Create the imposter table or tables (if required). */ + _rbuCreateImposterTable(tls, p, pIter) + _rbuCreateImposterTable2(tls, p, pIter) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) { + v1 = __ccgo_ts + 1702 + } else { + v1 = __ccgo_ts + 33021 + } + zWrite = v1 + /* Create the INSERT statement to write to the target PK b-tree */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if bRbuRowid != 0 { + v1 = __ccgo_ts + 33030 + } else { + v1 = __ccgo_ts + 1702 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+136, pz, Xsqlite3_mprintf(tls, __ccgo_ts+33040, libc.VaList(bp+40, zWrite, zTbl1, zCollist, v1, zBindings))) + } + /* Create the DELETE statement to write to the target PK b-tree. + ** Because it only performs INSERT operations, this is not required for + ** an rbu vacuum handle. */ + if libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+144, pz, Xsqlite3_mprintf(tls, __ccgo_ts+33076, libc.VaList(bp+40, zWrite, zTbl1, zWhere1))) + } + if libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 { + zRbuRowid = __ccgo_ts + 1702 + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + zRbuRowid = __ccgo_ts + 33104 + } + /* Create the rbu_tmp_xxx table and the triggers to populate it. */ + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) { + v1 = __ccgo_ts + 33116 + } else { + v1 = __ccgo_ts + 1702 + } + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33133, libc.VaList(bp+40, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, v1, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl)) + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33209, libc.VaList(bp+40, zWrite, zTbl1, zOldlist, zWrite, zTbl1, zOldlist, zWrite, zTbl1, zNewlist)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33508, libc.VaList(bp+40, zWrite, zTbl1, zNewlist)) + } + _rbuObjIterPrepareTmpInsert(tls, p, pIter, zCollist, zRbuRowid) + } + /* Create the SELECT statement to read keys from data_xxx */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + zRbuRowid1 = __ccgo_ts + 1702 + zStart1 = uintptr(0) + zOrder = uintptr(0) + if bRbuRowid != 0 { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = __ccgo_ts + 33607 + } else { + v1 = __ccgo_ts + 33617 + } + zRbuRowid1 = v1 + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + if nOffset != 0 { + zStart1 = _rbuVacuumTableStart(tls, p, pIter, bRbuRowid, zWrite) + if zStart1 != 0 { + Xsqlite3_free(tls, zLimit) + zLimit = uintptr(0) + } + } + if bRbuRowid != 0 { + zOrder = _rbuMPrintf(tls, p, __ccgo_ts+31664, 0) + } else { + zOrder = _rbuObjIterGetPkList(tls, p, pIter, __ccgo_ts+1702, __ccgo_ts+16558, __ccgo_ts+1702) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = __ccgo_ts + 33628 + } else { + v1 = __ccgo_ts + 1702 + } + if zStart1 != 0 { + v2 = zStart1 + } else { + v2 = __ccgo_ts + 1702 + } + if zOrder != 0 { + v3 = __ccgo_ts + 25176 + } else { + v3 = __ccgo_ts + 1702 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+128, pz, Xsqlite3_mprintf(tls, __ccgo_ts+33634, libc.VaList(bp+40, zCollist, v1, zRbuRowid1, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, v2, v3, zOrder, zLimit))) + } + Xsqlite3_free(tls, zStart1) + Xsqlite3_free(tls, zOrder) + } + Xsqlite3_free(tls, zWhere1) + Xsqlite3_free(tls, zOldlist) + Xsqlite3_free(tls, zNewlist) + Xsqlite3_free(tls, zBindings) + } + Xsqlite3_free(tls, zCollist) + Xsqlite3_free(tls, zLimit) + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** Prepare a statement used to insert rows into the "rbu_tmp_xxx" table. +// ** Specifically a statement of the form: +// ** +// ** INSERT INTO rbu_tmp_xxx VALUES(?, ?, ? ...); +// ** +// ** The number of bound variables is equal to the number of columns in +// ** the target table, plus one (for the rbu_control column), plus one more +// ** (for the rbu_rowid column) if the target table is an implicit IPK or +// ** virtual table. +// */ +func _rbuObjIterPrepareTmpInsert(tls *libc.TLS, p uintptr, pIter uintptr, zCollist uintptr, zRbuRowid uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bRbuRowid int32 + var zBind uintptr + _, _ = bRbuRowid, zBind + bRbuRowid = libc.BoolInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE)) + zBind = _rbuObjIterGetBindlist(tls, p, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+int32(1)+bRbuRowid) + if zBind != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+152, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+32452, libc.VaList(bp+8, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zCollist, zRbuRowid, zBind))) + } +} + +// C documentation +// +// /* +// ** Open the database handle and attach the RBU database as "rbu". If an +// ** error occurs, leave an error code and message in the RBU handle. +// ** +// ** If argument dbMain is not NULL, then it is a database handle already +// ** open on the target database. Use this handle instead of opening a new +// ** one. +// */ +func _rbuOpenDatabase(tls *libc.TLS, p uintptr, dbMain uintptr, pbRetry uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOpen, rc int32 + var pState, zExtra, zFile, zTarget, v1, v2 uintptr + _, _, _, _, _, _, _, _ = bOpen, pState, rc, zExtra, zFile, zTarget, v1, v2 + /* Open the RBU database */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = dbMain + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+7160, int32(SQLITE_FCNTL_RBUCNT), p) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState == uintptr(0) { + zFile = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+7160) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState = _rbuMPrintf(tls, p, __ccgo_ts+33742, libc.VaList(bp+8, zFile, zFile)) + } + } + /* If using separate RBU and state databases, attach the state database to + ** the RBU db handle now. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState != 0 { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33770, libc.VaList(bp+8, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState)) + libc.X__builtin___memcpy_chk(tls, p+48, __ccgo_ts+3565, uint64(4), ^t__predefined_size_t(0)) + } else { + libc.X__builtin___memcpy_chk(tls, p+48, __ccgo_ts+7160, uint64(4), ^t__predefined_size_t(0)) + } + /* If it has not already been created, create the rbu_state table */ + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33788, libc.VaList(bp+8, p+48)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + bOpen = 0 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu = 0 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd = uintptr(0) + rc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+7160, int32(SQLITE_FCNTL_RBUCNT), p) + if rc != int32(SQLITE_NOTFOUND) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage >= int32(RBU_STAGE_MOVE) { + bOpen = int32(1) + } else { + pState = _rbuLoadState(tls, p) + if pState != 0 { + bOpen = libc.BoolInt32((*TRbuState)(unsafe.Pointer(pState)).FeStage >= int32(RBU_STAGE_MOVE)) + _rbuFreeState(tls, pState) + } + } + if bOpen != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu <= int32(1))) + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain == uintptr(0) { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == libc.UintptrFromInt32(0)) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget, int32(1)) + } else { + if (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FpWalFd != 0 { + if pbRetry != 0 { + (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FbNolock = uint8(0) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu = uintptr(0) + **(**int32)(__ccgo_up(pbRetry)) = int32(1) + return + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+33854, 0) + } else { + zExtra = uintptr(0) + if libc.Xstrlen(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu) >= uint64(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+26440, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, uint64(5)) { + zExtra = (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu + 5 + for **(**int8)(__ccgo_up(zExtra)) != 0 { + v1 = zExtra + zExtra = zExtra + 1 + if int32(**(**int8)(__ccgo_up(v1))) == int32('?') { + break + } + } + if int32(**(**int8)(__ccgo_up(zExtra))) == int32('\000') { + zExtra = uintptr(0) + } + } + if zExtra == uintptr(0) { + v1 = __ccgo_ts + 1702 + } else { + v1 = __ccgo_ts + 33886 + } + if zExtra == uintptr(0) { + v2 = __ccgo_ts + 1702 + } else { + v2 = zExtra + } + zTarget = Xsqlite3_mprintf(tls, __ccgo_ts+33888, libc.VaList(bp+8, Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+7160), v1, v2)) + if zTarget == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + return + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, zTarget, libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu <= int32(1))) + Xsqlite3_free(tls, zTarget) + } + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33920, -int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_rbuTmpInsertFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33935, int32(2), int32(SQLITE_UTF8), uintptr(0), __ccgo_fp(_rbuFossilDeltaFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33952, -int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_rbuTargetNameFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, int32(SQLITE_FCNTL_RBU), p) + } + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33968, 0) + /* Mark the database file just opened as an RBU target database. If + ** this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use. + ** This is an error. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+7160, int32(SQLITE_FCNTL_RBU), p) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_NOTFOUND) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+33996, 0) + } +} + +// C documentation +// +// /* +// ** Update the contents of the rbu_state table within the rbu database. The +// ** value stored in the RBU_STATE_STAGE column is eStage. All other values +// ** are determined by inspecting the rbu handle passed as the first argument. +// */ +func _rbuSaveState(tls *libc.TLS, p uintptr, eStage int32) { + bp := tls.Alloc(192) + defer tls.Free(192) + var pFd, v1 uintptr + var rc int32 + var _ /* pInsert at bp+0 */ uintptr + _, _, _ = pFd, rc, v1 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK || (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_DONE) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd + } else { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd + } + pFd = v1 + rc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+34137, libc.VaList(bp+16, p+48, int32(RBU_STATE_STAGE), eStage, int32(RBU_STATE_TBL), (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl, int32(RBU_STATE_IDX), (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzIdx, int32(RBU_STATE_ROW), (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep, int32(RBU_STATE_PROGRESS), (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress, int32(RBU_STATE_CKPT), (*Tsqlite3rbu)(unsafe.Pointer(p)).FiWalCksum, int32(RBU_STATE_COOKIE), libc.Int64FromUint32((*Trbu_file)(unsafe.Pointer(pFd)).FiCookie), int32(RBU_STATE_OALSZ), (*Tsqlite3rbu)(unsafe.Pointer(p)).FiOalSz, int32(RBU_STATE_PHASEONESTEP), (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep, int32(RBU_STATE_DATATBL), (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzDataTbl))) + if rc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + if rc != SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + } +} + +// C documentation +// +// /* +// ** This function is called as part of initializing or reinitializing an +// ** incremental checkpoint. +// ** +// ** It populates the sqlite3rbu.aFrame[] array with the set of +// ** (wal frame -> db page) copy operations required to checkpoint the +// ** current wal file, and obtains the set of shm locks required to safely +// ** perform the copy operations directly on the file-system. +// ** +// ** If argument pState is not NULL, then the incremental checkpoint is +// ** being resumed. In this case, if the checksum of the wal-index-header +// ** following recovery is not the same as the checksum saved in the RbuState +// ** object, then the rbu handle is set to DONE state. This occurs if some +// ** other client appends a transaction to the wal file in the middle of +// ** an incremental checkpoint. +// */ +func _rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { + var nSectorSize, rc2, v1 int32 + var pDb, pWal uintptr + _, _, _, _, _ = nSectorSize, pDb, pWal, rc2, v1 + /* If pState is NULL, then the wal file may not have been opened and + ** recovered. Running a read-statement here to ensure that doing so + ** does not interfere with the "capture" process below. */ + if pState == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33968, uintptr(0), uintptr(0), uintptr(0)) + } + } + /* Assuming no error has occurred, run a "restart" checkpoint with the + ** sqlite3rbu.eStage variable set to CAPTURE. This turns on the following + ** special behaviour in the rbu VFS: + ** + ** * If the exclusive shm WRITER or READ0 lock cannot be obtained, + ** the checkpoint fails with SQLITE_BUSY (normally SQLite would + ** proceed with running a passive checkpoint instead of failing). + ** + ** * Attempts to read from the *-wal file or write to the database file + ** do not perform any IO. Instead, the frame/page combinations that + ** would be read/written are recorded in the sqlite3rbu.aFrame[] + ** array. + ** + ** * Calls to xShmLock(UNLOCK) to release the exclusive shm WRITER, + ** READ0 and CHECKPOINT locks taken as part of the checkpoint are + ** no-ops. These locks will not be released until the connection + ** is closed. + ** + ** * Attempting to xSync() the database file causes an SQLITE_NOTICE + ** error. + ** + ** As a result, unless an error (i.e. OOM or SQLITE_BUSY) occurs, the + ** checkpoint below fails with SQLITE_NOTICE, and leaves the aFrame[] + ** array populated with a set of (frame -> page) mappings. Because the + ** WRITER, CHECKPOINT and READ0 locks are still held, it is safe to copy + ** data from the wal file into the database file according to the + ** contents of aFrame[]. + */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CAPTURE) + rc2 = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34014, uintptr(0), uintptr(0), uintptr(0)) + if rc2 != int32(SQLITE_NOTICE) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc2 + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame > 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CKPT) + if pState != 0 { + v1 = (*TRbuState)(unsafe.Pointer(pState)).FnRow + } else { + v1 = 0 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = v1 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FaBuf = _rbuMalloc(tls, p, int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FiWalCksum = _rbuShmChecksum(tls, p) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame == 0 || pState != 0 && (*TRbuState)(unsafe.Pointer(pState)).FiWalCksum != (*Tsqlite3rbu)(unsafe.Pointer(p)).FiWalCksum { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE) + } else { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + pWal = (*Trbu_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd)).FpReal + nSectorSize = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSectorSize})))(tls, pDb) + if nSectorSize > (*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector = nSectorSize / (*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz + } else { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector = int32(1) + } + /* Call xSync() on the wal file. This causes SQLite to sync the + ** directory in which the target database and the wal file reside, in + ** case it has not been synced since the rename() call in + ** rbuMoveOalFile(). */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pWal)).FpMethods)).FxSync})))(tls, pWal, int32(SQLITE_SYNC_NORMAL)) + } + } +} + +// C documentation +// +// /* +// ** This function is called as part of sqlite3rbu_open() when initializing +// ** an rbu handle in OAL stage. If the rbu update has not started (i.e. +// ** the rbu_state table was empty) it is a no-op. Otherwise, it arranges +// ** things so that the next call to sqlite3rbu_step() continues on from +// ** where the previous rbu handle left off. +// ** +// ** If an error occurs, an error code and error message are left in the +// ** rbu handle passed as the first argument. +// */ +func _rbuSetupOal(tls *libc.TLS, p uintptr, pState uintptr) { + var pIter uintptr + var rc int32 + _, _ = pIter, rc + if (*TRbuState)(unsafe.Pointer(pState)).FzTbl != 0 { + pIter = p + 88 + rc = SQLITE_OK + for rc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 && ((*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 || _rbuStrCompare(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx, (*TRbuState)(unsafe.Pointer(pState)).FzIdx) != 0 || (*TRbuState)(unsafe.Pointer(pState)).FzDataTbl == uintptr(0) && _rbuStrCompare(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, (*TRbuState)(unsafe.Pointer(pState)).FzTbl) != 0 || (*TRbuState)(unsafe.Pointer(pState)).FzDataTbl != 0 && _rbuStrCompare(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, (*TRbuState)(unsafe.Pointer(pState)).FzDataTbl) != 0) { + rc = _rbuObjIterNext(tls, p, pIter) + } + if rc == SQLITE_OK && !((*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0) { + rc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+34627, 0) + } + if rc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = (*TRbuState)(unsafe.Pointer(pState)).FnRow + rc = _rbuObjIterPrepareAll(tls, p, p+88, (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } +} + +// C documentation +// +// /* +// ** Argument eType must be one of RBU_INSERT, RBU_DELETE, RBU_IDX_INSERT or +// ** RBU_IDX_DELETE. This function performs the work of a single +// ** sqlite3rbu_step() call for the type of operation specified by eType. +// */ +func _rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { + var i int32 + var pIter, pVal, pWriter uintptr + _, _, _, _ = i, pIter, pVal, pWriter + pIter = p + 88 + /* If this is a delete, decrement nPhaseOneStep by nIndex. If the DELETE + ** statement below does actually delete a row, nPhaseOneStep will be + ** incremented by the same amount when SQL function rbu_tmp_insert() + ** is invoked by the trigger. */ + if eType == int32(RBU_DELETE) { + **(**Ti64)(__ccgo_up(p + 312)) -= int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex) + } + if eType == int32(RBU_IDX_DELETE) || eType == int32(RBU_DELETE) { + pWriter = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpDelete + } else { + pWriter = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpInsert + } + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol) { + break + } + /* If this is an INSERT into a table b-tree and the table has an + ** explicit INTEGER PRIMARY KEY, check that this is not an attempt + ** to write a NULL into the IPK column. That is not permitted. */ + if eType == int32(RBU_INSERT) && (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) && (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) && **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 && Xsqlite3_column_type(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) == int32(SQLITE_NULL) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_MISMATCH) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+25997, 0) + return + } + if eType == int32(RBU_DELETE) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0 { + goto _1 + } + pVal = Xsqlite3_column_value(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, pWriter, i+int32(1), pVal) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + return + } + goto _1 + _1: + ; + i = i + 1 + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + /* For a virtual table, or a table with no primary key, the + ** SELECT statement is: + ** + ** SELECT , rbu_control, rbu_rowid FROM .... + ** + ** Hence column_value(pIter->nCol+1). + */ + pVal = Xsqlite3_column_value(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol+int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, pWriter, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol+int32(1), pVal) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_step(tls, pWriter) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _resetAndCollectError(tls, pWriter, p+64) + } +} + +// C documentation +// +// /* +// ** The first argument must be a nul-terminated string. This function +// ** returns a copy of the string in memory obtained from sqlite3_malloc(). +// ** It is the responsibility of the caller to eventually free this memory +// ** using sqlite3_free(). +// ** +// ** If an OOM condition is encountered when attempting to allocate memory, +// ** output variable (*pRc) is set to SQLITE_NOMEM before returning. Otherwise, +// ** if the allocation succeeds, (*pRc) is left unchanged. +// */ +func _rbuStrndup(tls *libc.TLS, zStr uintptr, pRc uintptr) (r uintptr) { + var nCopy Tsize_t + var zRet uintptr + _, _ = nCopy, zRet + zRet = uintptr(0) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + if zStr != 0 { + nCopy = libc.Xstrlen(tls, zStr) + uint64(1) + zRet = Xsqlite3_malloc64(tls, nCopy) + if zRet != 0 { + libc.X__builtin___memcpy_chk(tls, zRet, zStr, nCopy, ^t__predefined_size_t(0)) + } else { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } + } + return zRet +} + +// C documentation +// +// /* Determine the type of a table. +// ** +// ** peType is of type (int*), a pointer to an output parameter of type +// ** (int). This call sets the output parameter as follows, depending +// ** on the type of the table specified by parameters dbName and zTbl. +// ** +// ** RBU_PK_NOTABLE: No such table. +// ** RBU_PK_NONE: Table has an implicit rowid. +// ** RBU_PK_IPK: Table has an explicit IPK column. +// ** RBU_PK_EXTERNAL: Table has an external PK index. +// ** RBU_PK_WITHOUT_ROWID: Table is WITHOUT ROWID. +// ** RBU_PK_VTAB: Table is a virtual table. +// ** +// ** Argument *piPk is also of type (int*), and also points to an output +// ** parameter. Unless the table has an external primary key index +// ** (i.e. unless *peType is set to 3), then *piPk is set to zero. Or, +// ** if the table does have an external primary key index, then *piPk +// ** is set to the root page number of the primary key index before +// ** returning. +// ** +// ** ALGORITHM: +// ** +// ** if( no entry exists in sqlite_schema ){ +// ** return RBU_PK_NOTABLE +// ** }else if( sql for the entry starts with "CREATE VIRTUAL" ){ +// ** return RBU_PK_VTAB +// ** }else if( "PRAGMA index_list()" for the table contains a "pk" index ){ +// ** if( the index that is the pk exists in sqlite_schema ){ +// ** *piPK = rootpage of that index. +// ** return RBU_PK_EXTERNAL +// ** }else{ +// ** return RBU_PK_WITHOUT_ROWID +// ** } +// ** }else if( "PRAGMA table_info()" lists one or more "pk" columns ){ +// ** return RBU_PK_IPK +// ** }else{ +// ** return RBU_PK_NONE +// ** } +// */ +func _rbuTableType(tls *libc.TLS, p uintptr, zTab uintptr, peType uintptr, piTnum uintptr, piPk uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i uint32 + var zIdx, zOrig uintptr + var _ /* aStmt at bp+0 */ [4]uintptr + _, _, _ = i, zIdx, zOrig + /* + ** 0) SELECT count(*) FROM sqlite_schema where name=%Q AND IsVirtual(%Q) + ** 1) PRAGMA index_list = ? + ** 2) SELECT count(*) FROM sqlite_schema where name=%Q + ** 3) PRAGMA table_info = ? + */ + **(**[4]uintptr)(__ccgo_up(bp)) = [4]uintptr{} + **(**int32)(__ccgo_up(peType)) = RBU_PK_NOTABLE + **(**int32)(__ccgo_up(piPk)) = 0 + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31101, libc.VaList(bp+40, zTab))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK || Xsqlite3_step(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[0]) != int32(SQLITE_ROW) { + /* Either an error, or no such table. */ + goto rbuTableType_end + } + if Xsqlite3_column_int(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[0], 0) != 0 { + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_VTAB) /* virtual table */ + goto rbuTableType_end + } + **(**int32)(__ccgo_up(piTnum)) = Xsqlite3_column_int(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[0], int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+1*8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31220, libc.VaList(bp+40, zTab))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + goto rbuTableType_end + } + for Xsqlite3_step(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(1)]) == int32(SQLITE_ROW) { + zOrig = Xsqlite3_column_text(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(1)], int32(3)) + zIdx = Xsqlite3_column_text(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(1)], int32(1)) + if zOrig != 0 && zIdx != 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zOrig))) == int32('p') { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+2*8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31241, libc.VaList(bp+40, zIdx))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if Xsqlite3_step(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(2)]) == int32(SQLITE_ROW) { + **(**int32)(__ccgo_up(piPk)) = Xsqlite3_column_int(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(2)], 0) + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_EXTERNAL) + } else { + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_WITHOUT_ROWID) + } + } + goto rbuTableType_end + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+3*8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31292, libc.VaList(bp+40, zTab))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + for Xsqlite3_step(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(3)]) == int32(SQLITE_ROW) { + if Xsqlite3_column_int(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(3)], int32(5)) > 0 { + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_IPK) /* explicit IPK column */ + goto rbuTableType_end + } + } + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_NONE) + } + goto rbuTableType_end +rbuTableType_end: + ; + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(32)/libc.Uint64FromInt64(8)) { + break + } + _rbuFinalize(tls, p, (**(**[4]uintptr)(__ccgo_up(bp)))[i]) + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** The implementation of the rbu_target_name() SQL function. This function +// ** accepts one or two arguments. The first argument is the name of a table - +// ** the name of a table in the RBU database. The second, if it is present, is 1 +// ** for a view or 0 for a table. +// ** +// ** For a non-vacuum RBU handle, if the table name matches the pattern: +// ** +// ** data[0-9]_ +// ** +// ** where is any sequence of 1 or more characters, is returned. +// ** Otherwise, if the only argument does not match the above pattern, an SQL +// ** NULL is returned. +// ** +// ** "data_t1" -> "t1" +// ** "data0123_t2" -> "t2" +// ** "dataAB_t3" -> NULL +// ** +// ** For an rbu vacuum handle, a copy of the first argument is returned if +// ** the second argument is either missing or 0 (not a view). +// */ +func _rbuTargetNameFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { + var i int32 + var p, zIn uintptr + _, _, _ = i, p, zIn + p = Xsqlite3_user_data(tls, pCtx) + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn != 0 { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + if argc == int32(1) || 0 == Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) { + Xsqlite3_result_text(tls, pCtx, zIn, -int32(1), libc.UintptrFromInt32(0)) + } + } else { + if libc.Xstrlen(tls, zIn) > uint64(4) && libc.Xmemcmp(tls, __ccgo_ts+27730, zIn, uint64(4)) == 0 { + i = int32(4) + for { + if !(int32(**(**int8)(__ccgo_up(zIn + uintptr(i)))) >= int32('0') && int32(**(**int8)(__ccgo_up(zIn + uintptr(i)))) <= int32('9')) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i)))) == int32('_') && **(**int8)(__ccgo_up(zIn + uintptr(i+int32(1)))) != 0 { + Xsqlite3_result_text(tls, pCtx, zIn+uintptr(i+int32(1)), -int32(1), libc.UintptrFromInt32(0)) + } + } + } + } +} + +// C documentation +// +// /* +// ** This function is called as part of restating an RBU vacuum when the +// ** current operation is writing content to an index. If possible, it +// ** queries the target index b-tree for the largest key already written to +// ** it, then composes and returns an expression that can be used in a WHERE +// ** clause to select the remaining required rows from the source table. +// ** It is only possible to return such an expression if: +// ** +// ** * The index contains no DESC columns, and +// ** * The last key written to the index before the operation was +// ** suspended does not contain any NULL values. +// ** +// ** The expression is of the form: +// ** +// ** (index-field1, index-field2, ...) > (?, ?, ...) +// ** +// ** except that the "?" placeholders are replaced with literal values. +// ** +// ** If the expression cannot be created, NULL is returned. In this case, +// ** the caller has to use an OFFSET clause to extract only the required +// ** rows from the sourct table, just as it does for an RBU update operation. +// */ +func _rbuVacuumIndexStart(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bFailed, i, iCid, iCol int32 + var zCol, zCollate, zLhs, zOrder, zQuoted, zRet, zSelect, zSep, zVector uintptr + var _ /* pSel at bp+8 */ uintptr + var _ /* pXInfo at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = bFailed, i, iCid, iCol, zCol, zCollate, zLhs, zOrder, zQuoted, zRet, zSelect, zSep, zVector + zOrder = uintptr(0) + zLhs = uintptr(0) + zSelect = uintptr(0) + zVector = uintptr(0) + zRet = uintptr(0) + bFailed = 0 + zSep = __ccgo_ts + 1702 + iCol = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31341, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + zCollate = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) != 0 { + bFailed = int32(1) + break + } + if iCid < 0 { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) { + i = 0 + for { + if !(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + } else { + zCol = __ccgo_ts + 31664 + } + } else { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCid)*8)) + } + zLhs = _rbuMPrintf(tls, p, __ccgo_ts+31672, libc.VaList(bp+24, zLhs, zSep, zCol, zCollate)) + zOrder = _rbuMPrintf(tls, p, __ccgo_ts+31693, libc.VaList(bp+24, zOrder, zSep, iCol, zCol, zCollate)) + zSelect = _rbuMPrintf(tls, p, __ccgo_ts+31729, libc.VaList(bp+24, zSelect, zSep, iCol, zCol)) + zSep = __ccgo_ts + 16558 + iCol = iCol + 1 + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + if bFailed != 0 { + goto index_start_out + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31756, libc.VaList(bp+24, zSelect, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + zSep = __ccgo_ts + 1702 + iCol = 0 + for { + if !(iCol < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol) { + break + } + zQuoted = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), iCol) + if zQuoted == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + if int32(**(**int8)(__ccgo_up(zQuoted))) == int32('N') { + bFailed = int32(1) + break + } + } + zVector = _rbuMPrintf(tls, p, __ccgo_ts+31804, libc.VaList(bp+24, zVector, zSep, zQuoted)) + zSep = __ccgo_ts + 16558 + goto _2 + _2: + ; + iCol = iCol + 1 + } + if !(bFailed != 0) { + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31811, libc.VaList(bp+24, zLhs, zVector)) + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + } + goto index_start_out +index_start_out: + ; + Xsqlite3_free(tls, zOrder) + Xsqlite3_free(tls, zSelect) + Xsqlite3_free(tls, zVector) + Xsqlite3_free(tls, zLhs) + return zRet +} + +// C documentation +// +// /* +// ** This function is called as part of restarting an RBU vacuum within +// ** stage 1 of the process (while the *-oal file is being built) while +// ** updating a table (not an index). The table may be a rowid table or +// ** a WITHOUT ROWID table. It queries the target database to find the +// ** largest key that has already been written to the target table and +// ** constructs a WHERE clause that can be used to extract the remaining +// ** rows from the source table. For a rowid table, the WHERE clause +// ** is of the form: +// ** +// ** "WHERE _rowid_ > ?" +// ** +// ** and for WITHOUT ROWID tables: +// ** +// ** "WHERE (key1, key2) > (?, ?)" +// ** +// ** Instead of "?" placeholders, the actual WHERE clauses created by +// ** this function contain literal SQL values. +// */ +func _rbuVacuumTableStart(tls *libc.TLS, p uintptr, pIter uintptr, bRowid int32, zWrite uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iMax Tsqlite3_int64 + var zList, zOrder, zRet, zSelect, zVal uintptr + var _ /* pMax at bp+0 */ uintptr + _, _, _, _, _, _ = iMax, zList, zOrder, zRet, zSelect, zVal + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zRet = uintptr(0) + if bRowid != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31526, libc.VaList(bp+16, zWrite, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iMax = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31558, libc.VaList(bp+16, iMax)) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + } else { + zOrder = _rbuObjIterGetPkList(tls, p, pIter, __ccgo_ts+1702, __ccgo_ts+16558, __ccgo_ts+31581) + zSelect = _rbuObjIterGetPkList(tls, p, pIter, __ccgo_ts+31587, __ccgo_ts+31594, __ccgo_ts+5601) + zList = _rbuObjIterGetPkList(tls, p, pIter, __ccgo_ts+1702, __ccgo_ts+16558, __ccgo_ts+1702) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31602, libc.VaList(bp+16, zSelect, zWrite, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zVal = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31644, libc.VaList(bp+16, zList, zVal)) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + } + Xsqlite3_free(tls, zOrder) + Xsqlite3_free(tls, zSelect) + Xsqlite3_free(tls, zList) + } + return zRet +} + +// C documentation +// +// /* +// ** File control method. For custom operations on an rbuVfs-file. +// */ +func _rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p, pRbu, pRbu1, pRbuVfs, xControl, zIn, zOut uintptr + var rc int32 + var _ /* dummy at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = p, pRbu, pRbu1, pRbuVfs, rc, xControl, zIn, zOut + p = pFile + xControl = (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileControl + if op == int32(SQLITE_FCNTL_RBU) { + pRbu = pArg + /* First try to find another RBU vfs lower down in the vfs stack. If + ** one is found, this vfs will operate in pass-through mode. The lower + ** level vfs will do the special RBU handling. */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, op, pArg) + if rc == int32(SQLITE_NOTFOUND) { + /* Now search for a zipvfs instance lower down in the VFS stack. If + ** one is found, this is an error. */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, int32(SQLITE_FCNTL_ZIPVFS), bp) + if rc == SQLITE_OK { + rc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+35033, 0) + } else { + if rc == int32(SQLITE_NOTFOUND) { + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FpTargetFd = p + (*Trbu_file)(unsafe.Pointer(p)).FpRbu = pRbu + _rbuMainlistAdd(tls, p) + if (*Trbu_file)(unsafe.Pointer(p)).FpWalFd != 0 { + (*Trbu_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpWalFd)).FpRbu = pRbu + } + rc = SQLITE_OK + } + } + } + return rc + } else { + if op == int32(SQLITE_FCNTL_RBUCNT) { + pRbu1 = pArg + (*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FnRbu = (*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FnRbu + 1 + (*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FpRbuFd = p + (*Trbu_file)(unsafe.Pointer(p)).FbNolock = uint8(1) + } + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, op, pArg) + if rc == SQLITE_OK && op == int32(SQLITE_FCNTL_VFSNAME) { + pRbuVfs = (*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs + zIn = **(**uintptr)(__ccgo_up(pArg)) + zOut = Xsqlite3_mprintf(tls, __ccgo_ts+35056, libc.VaList(bp+16, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fbase.FzName, zIn)) + **(**uintptr)(__ccgo_up(pArg)) = zOut + if zOut == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +// C documentation +// +// /* +// ** Open an rbu file handle. +// */ +func _rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) (r int32) { + var nOpen Tsize_t + var oflags, rc int32 + var pDb, pFd, pMeth, pRbuVfs, pRealVfs, zOpen uintptr + _, _, _, _, _, _, _, _, _ = nOpen, oflags, pDb, pFd, pMeth, pRbuVfs, pRealVfs, rc, zOpen + pRbuVfs = pVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs + pFd = pFile + rc = SQLITE_OK + zOpen = zName + oflags = flags + libc.X__builtin___memset_chk(tls, pFd, 0, uint64(104), ^t__predefined_size_t(0)) + (*Trbu_file)(unsafe.Pointer(pFd)).FpReal = pFd + 1*104 + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbuVfs = pRbuVfs + (*Trbu_file)(unsafe.Pointer(pFd)).FopenFlags = flags + if zName != 0 { + if flags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + /* A main database has just been opened. The following block sets + ** (pFd->zWal) to point to a buffer owned by SQLite that contains + ** the name of the *-wal file this db connection will use. SQLite + ** happens to pass a pointer to this buffer when using xAccess() + ** or xOpen() to operate on the *-wal file. */ + (*Trbu_file)(unsafe.Pointer(pFd)).FzWal = Xsqlite3_filename_wal(tls, zName) + } else { + if flags&int32(SQLITE_OPEN_WAL) != 0 { + pDb = _rbuFindMaindb(tls, pRbuVfs, zName, 0) + if pDb != 0 { + if (*Trbu_file)(unsafe.Pointer(pDb)).FpRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == int32(RBU_STAGE_OAL) { + if (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FzTarget == uintptr(0) { + zOpen = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FdbRbu, __ccgo_ts+7160) + zOpen = Xsqlite3_filename_wal(tls, zOpen) + } + nOpen = libc.Xstrlen(tls, zOpen) + **(**int8)(__ccgo_up(zOpen + uintptr(nOpen-uint64(3)))) = int8('o') + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Trbu_file)(unsafe.Pointer(pDb)).FpRbu + } + (*Trbu_file)(unsafe.Pointer(pDb)).FpWalFd = pFd + } + } + } + } else { + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRbu + } + if oflags&int32(SQLITE_OPEN_MAIN_DB) != 0 && Xsqlite3_uri_boolean(tls, zName, __ccgo_ts+35067, 0) != 0 { + oflags = libc.Int32FromInt32(SQLITE_OPEN_TEMP_DB) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) + zOpen = uintptr(0) + } + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, Tsqlite3_filename, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxOpen})))(tls, pRealVfs, zOpen, (*Trbu_file)(unsafe.Pointer(pFd)).FpReal, oflags, pOutFlags) + } + if (*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods != 0 { + pMeth = (*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods + /* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods + ** pointer and, if the file is a main database file, link it into the + ** mutex protected linked list of all such files. */ + if (*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FiVersion < int32(2) || (*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FxShmLock == uintptr(0) { + (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&_rbuvfs_io_methods1)) + } else { + (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&_rbuvfs_io_methods)) + } + if flags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + _rbuMainlistAdd(tls, pFd) + } + } else { + Xsqlite3_free(tls, (*Trbu_file)(unsafe.Pointer(pFd)).FzDel) + } + return rc +} + +// C documentation +// +// /* +// ** Read data from an rbuVfs-file. +// */ +func _rbuVfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) { + var aBuf, p, pBuf, pFd, pRbu uintptr + var iRoot Tu32 + var rc, v1 int32 + _, _, _, _, _, _, _, _ = aBuf, iRoot, p, pBuf, pFd, pRbu, rc, v1 + p = pFile + pRbu = (*Trbu_file)(unsafe.Pointer(p)).FpRbu + if pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == int32(RBU_STAGE_CAPTURE) { + rc = _rbuCaptureWalRead(tls, (*Trbu_file)(unsafe.Pointer(p)).FpRbu, iOfst, iAmt) + } else { + if pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == int32(RBU_STAGE_OAL) && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_WAL) != 0 && iOfst >= (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz { + rc = SQLITE_OK + libc.X__builtin___memset_chk(tls, zBuf, 0, libc.Uint64FromInt32(iAmt), ^t__predefined_size_t(0)) + } else { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxRead})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) + /* If this is being called to read the first page of the target + ** database as part of an rbu vacuum operation, synthesize the + ** contents of the first page if it does not yet exist. Otherwise, + ** SQLite will not check for a *-wal file. */ + if pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FzTarget == uintptr(0) && rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)< int32(100) { + libc.X__builtin___memset_chk(tls, aBuf+100, 0, libc.Uint64FromInt32(iAmt-int32(100)), ^t__predefined_size_t(0)) + _rbuPutU16(tls, aBuf+105, libc.Uint16FromInt32(iAmt&int32(0xFFFF))) + **(**Tu8)(__ccgo_up(aBuf + 100)) = uint8(0x0D) + } + } + } + } + if rc == SQLITE_OK && iOfst == 0 && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + /* These look like magic numbers. But they are stable, as they are part + ** of the definition of the SQLite file format, which may not change. */ + pBuf = zBuf + (*Trbu_file)(unsafe.Pointer(p)).FiCookie = _rbuGetU32(tls, pBuf+24) + (*Trbu_file)(unsafe.Pointer(p)).FiWriteVer = **(**Tu8)(__ccgo_up(pBuf + 19)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Obtain a pointer to a mapping of a single 32KiB page of the *-shm file. +// */ +func _rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, isWrite int32, pp uintptr) (r int32) { + var apNew, p, pNew uintptr + var eStage, rc, v1 int32 + var nByte Tsqlite3_int64 + _, _, _, _, _, _, _ = apNew, eStage, nByte, p, pNew, rc, v1 + p = pFile + rc = SQLITE_OK + if (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 { + v1 = (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage + } else { + v1 = 0 + } + eStage = v1 + /* If not in RBU_STAGE_OAL, allow this call to pass through. Or, if this + ** rbu is in the RBU_STAGE_OAL state, use heap memory for *-shm space + ** instead of a file on disk. */ + if eStage == int32(RBU_STAGE_OAL) { + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(iRegion+libc.Int32FromInt32(1)) * uint64(8)) + apNew = Xsqlite3_realloc64(tls, (*Trbu_file)(unsafe.Pointer(p)).FapShm, libc.Uint64FromInt64(nByte)) + /* This is an RBU connection that uses its own heap memory for the + ** pages of the *-shm file. Since no other process can have run + ** recovery, the connection must request *-shm pages in order + ** from start to finish. */ + if apNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, apNew+uintptr((*Trbu_file)(unsafe.Pointer(p)).FnShm)*8, 0, uint64(8)*libc.Uint64FromInt32(libc.Int32FromInt32(1)+iRegion-(*Trbu_file)(unsafe.Pointer(p)).FnShm), ^t__predefined_size_t(0)) + (*Trbu_file)(unsafe.Pointer(p)).FapShm = apNew + (*Trbu_file)(unsafe.Pointer(p)).FnShm = iRegion + int32(1) + } + if rc == SQLITE_OK { + pNew = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(szRegion)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pNew, 0, libc.Uint64FromInt32(szRegion), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up((*Trbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*8)) = pNew + } + } + if rc == SQLITE_OK { + **(**uintptr)(__ccgo_up(pp)) = **(**uintptr)(__ccgo_up((*Trbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*8)) + } else { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + } else { + rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmMap})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, iRegion, szRegion, isWrite, pp) + } + return rc +} + +// C documentation +// +// /* +// ** The iterator currently points to a table (not index) of type +// ** RBU_PK_WITHOUT_ROWID. This function creates the PRIMARY KEY +// ** declaration for the corresponding imposter table. For example, +// ** if the iterator points to a table created as: +// ** +// ** CREATE TABLE t1(a, b, c, PRIMARY KEY(b, a DESC)) WITHOUT ROWID +// ** +// ** this function returns: +// ** +// ** PRIMARY KEY("b", "a" DESC) +// */ +func _rbuWithoutRowidPK(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var z, zCol, zDesc, zIdx, zOrig, zSep, v1 uintptr + var _ /* pXInfo at bp+8 */ uintptr + var _ /* pXList at bp+0 */ uintptr + _, _, _, _, _, _, _ = z, zCol, zDesc, zIdx, zOrig, zSep, v1 + z = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + zSep = __ccgo_ts + 32161 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* PRAGMA index_list = (pIter->zTbl) */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* PRAGMA index_xinfo = */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31313, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zOrig = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) + if zOrig != 0 && libc.Xstrcmp(tls, zOrig, __ccgo_ts+18198) == 0 { + zIdx = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + if zIdx != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31341, libc.VaList(bp+24, zIdx))) + } + break + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(5)) != 0 { + /* int iCid = sqlite3_column_int(pXInfo, 0); */ + zCol = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(2)) + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(3)) != 0 { + v1 = __ccgo_ts + 31581 + } else { + v1 = __ccgo_ts + 1702 + } + zDesc = v1 + z = _rbuMPrintf(tls, p, __ccgo_ts+32174, libc.VaList(bp+24, z, zSep, zCol, zDesc)) + zSep = __ccgo_ts + 16558 + } + } + z = _rbuMPrintf(tls, p, __ccgo_ts+32185, libc.VaList(bp+24, z)) + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + } + return z +} + +// C documentation +// +// /* +// ** Read the content for page pPg out of the database file (or out of +// ** the WAL if that is where the most recent copy if found) into +// ** pPg->pData. A shared lock or greater must be held on the database +// ** file before this function is called. +// ** +// ** If page 1 is read, then the value of Pager.dbFileVers[] is set to +// ** the value read from the database file. +// ** +// ** If an IO error occurs, then the IO error is returned to the caller. +// ** Otherwise, SQLITE_OK is returned. +// */ +func _readDbPage(tls *libc.TLS, pPg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var dbFileVers, pPager uintptr + var iOffset Ti64 + var rc int32 + var _ /* iFrame at bp+0 */ Tu32 + _, _, _, _ = dbFileVers, iOffset, pPager, rc + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager /* Pager object associated with page pPg */ + rc = SQLITE_OK /* Return code */ + **(**Tu32)(__ccgo_up(bp)) = uint32(0) /* Frame of WAL containing pgno */ + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + rc = _sqlite3WalFindFrame(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno, bp) + if rc != 0 { + return rc + } + } + if **(**Tu32)(__ccgo_up(bp)) != 0 { + rc = _sqlite3WalReadFrame(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, **(**Tu32)(__ccgo_up(bp)), int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), (*TPgHdr)(unsafe.Pointer(pPg)).FpData) + } else { + iOffset = libc.Int64FromUint32((*TPgHdr)(unsafe.Pointer(pPg)).Fpgno-libc.Uint32FromInt32(1)) * (*TPager)(unsafe.Pointer(pPager)).FpageSize + rc = _sqlite3OsRead(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, (*TPgHdr)(unsafe.Pointer(pPg)).FpData, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), iOffset) + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)<dbFileVers[] with all 0xff bytes should suffice. + ** + ** For an encrypted database, the situation is more complex: bytes + ** 24..39 of the database are white noise. But the probability of + ** white noise equaling 16 bytes of 0xff is vanishingly small so + ** we should still be ok. + */ + libc.X__builtin___memset_chk(tls, pPager+136, int32(0xff), uint64(16), ^t__predefined_size_t(0)) + } else { + dbFileVers = (*TPgHdr)(unsafe.Pointer(pPg)).FpData + 24 + libc.X__builtin___memcpy_chk(tls, pPager+136, dbFileVers, uint64(16), ^t__predefined_size_t(0)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Array apCell[] contains pointers to nCell b-tree page cells. The +// ** szCell[] array contains the size in bytes of each cell. This function +// ** replaces the current contents of page pPg with the contents of the cell +// ** array. +// ** +// ** Some of the cells in apCell[] may currently be stored in pPg. This +// ** function works around problems caused by this by making a copy of any +// ** such cells before overwriting the page data. +// ** +// ** The MemPage.nFree field is invalidated by this function. It is the +// ** responsibility of the caller to set it correctly. +// */ +func _rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg uintptr) (r int32) { + var aData, pCell, pCellptr, pData, pEnd, pSrcEnd, pTmp uintptr + var hdr, i, iEnd, k, usableSize int32 + var j Tu32 + var sz Tu16 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, hdr, i, iEnd, j, k, pCell, pCellptr, pData, pEnd, pSrcEnd, pTmp, sz, usableSize + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FhdrOffset) /* Offset of header on pPg */ + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData /* Pointer to data for pPg */ + usableSize = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize) + pEnd = aData + uintptr(usableSize) + i = iFirst /* Start of cell content area */ + iEnd = i + nCell /* Loop terminator */ + pCellptr = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + pTmp = _sqlite3PagerTempSpace(tls, (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPg)).FpBt)).FpPager) /* Current pCArray->apEnd[k] value */ + j = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)))))< libc.Uint32FromInt32(usableSize) { + j = uint32(0) + } + libc.X__builtin___memcpy_chk(tls, pTmp+uintptr(j), aData+uintptr(j), uint64(libc.Uint32FromInt32(usableSize)-j), ^t__predefined_size_t(0)) + k = 0 + for { + if !(**(**int32)(__ccgo_up(pCArray + 80 + uintptr(k)*4)) <= i) { + break + } + goto _1 + _1: + ; + k = k + 1 + } + pSrcEnd = **(**uintptr)(__ccgo_up(pCArray + 32 + uintptr(k)*8)) + pData = pEnd + for int32(1) != 0 { + pCell = **(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8)) + sz = **(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2)) + if uint64(pCell) >= uint64(aData+uintptr(j)) && uint64(pCell) < uint64(pEnd) { + if uint64(pCell+uintptr(sz)) > uint64(pEnd) { + return _sqlite3CorruptError(tls, int32(80813)) + } + pCell = pTmp + uintptr(int64(pCell)-int64(aData)) + } else { + if uint64(pCell+uintptr(sz)) > uint64(pSrcEnd) && uint64(pCell) < uint64(pSrcEnd) { + return _sqlite3CorruptError(tls, int32(80818)) + } + } + pData = pData - uintptr(sz) + **(**Tu8)(__ccgo_up(pCellptr)) = libc.Uint8FromInt64((int64(pData) - int64(aData)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pCellptr + 1)) = libc.Uint8FromInt64(int64(pData) - int64(aData)) + pCellptr = pCellptr + uintptr(2) + if pData < pCellptr { + return _sqlite3CorruptError(tls, int32(80824)) + } + libc.X__builtin___memmove_chk(tls, pData, pCell, uint64(sz), ^t__predefined_size_t(0)) + i = i + 1 + if i >= iEnd { + break + } + if **(**int32)(__ccgo_up(pCArray + 80 + uintptr(k)*4)) <= i { + k = k + 1 + pSrcEnd = **(**uintptr)(__ccgo_up(pCArray + 32 + uintptr(k)*8)) + } + } + /* The pPg->nFree field is now set incorrectly. The caller will fix it. */ + (*TMemPage)(unsafe.Pointer(pPg)).FnCell = libc.Uint16FromInt32(nCell) + (*TMemPage)(unsafe.Pointer(pPg)).FnOverflow = uint8(0) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(1)))) = libc.Uint8FromInt32(libc.Int32FromInt32(0) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(1)) + 1)) = libc.Uint8FromInt32(libc.Int32FromInt32(0)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(3)))) = libc.Uint8FromInt32(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPg)).FnCell) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(3)) + 1)) = uint8((*TMemPage)(unsafe.Pointer(pPg)).FnCell) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)))) = libc.Uint8FromInt64((int64(pData) - int64(aData)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)) + 1)) = libc.Uint8FromInt64(int64(pData) - int64(aData)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(7)))) = uint8(0x00) + return SQLITE_OK +} + +func _recomputeColumnsUsed(tls *libc.TLS, pSelect uintptr, pSrcItem uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + if (*TSrcItem)(unsafe.Pointer(pSrcItem)).FpSTab == uintptr(0) { + return + } + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_recomputeColumnsUsedExpr) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + *(*uintptr)(unsafe.Pointer(bp + 40)) = pSrcItem + (*TSrcItem)(unsafe.Pointer(pSrcItem)).FcolUsed = uint64(0) + _sqlite3WalkSelect(tls, bp, pSelect) +} + +// C documentation +// +// /* Resize the hash table so that it contains "new_size" buckets. +// ** +// ** The hash table might fail to resize if sqlite3_malloc() fails or +// ** if the new size is the same as the prior size. +// ** Return TRUE if the resize occurs and false if not. +// */ +func _rehash(tls *libc.TLS, pH uintptr, new_size uint32) (r int32) { + var elem, new_ht, next_elem uintptr + var v1 uint32 + _, _, _, _ = elem, new_ht, next_elem, v1 /* For looping over existing elements */ + if uint64(new_size)*uint64(16) > uint64(SQLITE_MALLOC_SOFT_LIMIT) { + new_size = uint32(libc.Uint64FromInt32(SQLITE_MALLOC_SOFT_LIMIT) / libc.Uint64FromInt64(16)) + } + if new_size == (*THash)(unsafe.Pointer(pH)).Fhtsize { + return 0 + } + /* The inability to allocates space for a larger hash table is + ** a performance hit but it is not a fatal error. So mark the + ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of + ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero() + ** only zeroes the requested number of bytes whereas this module will + ** use the actual amount of space allocated for the hash table (which + ** may be larger than the requested amount). + */ + _sqlite3BeginBenignMalloc(tls) + new_ht = _sqlite3Malloc(tls, uint64(new_size)*uint64(16)) + _sqlite3EndBenignMalloc(tls) + if new_ht == uintptr(0) { + return 0 + } + Xsqlite3_free(tls, (*THash)(unsafe.Pointer(pH)).Fht) + (*THash)(unsafe.Pointer(pH)).Fht = new_ht + v1 = uint32(libc.Uint64FromInt32(_sqlite3MallocSize(tls, new_ht)) / libc.Uint64FromInt64(16)) + new_size = v1 + (*THash)(unsafe.Pointer(pH)).Fhtsize = v1 + libc.X__builtin___memset_chk(tls, new_ht, 0, uint64(new_size)*uint64(16), ^t__predefined_size_t(0)) + elem = (*THash)(unsafe.Pointer(pH)).Ffirst + (*THash)(unsafe.Pointer(pH)).Ffirst = libc.UintptrFromInt32(0) + for { + if !(elem != 0) { + break + } + next_elem = (*THashElem)(unsafe.Pointer(elem)).Fnext + _insertElement(tls, pH, new_ht+uintptr((*THashElem)(unsafe.Pointer(elem)).Fh%new_size)*16, elem) + goto _2 + _2: + ; + elem = next_elem + } + return int32(1) +} + +// C documentation +// +// /* +// ** SQL function: +// ** +// ** sqlite_rename_column(SQL,TYPE,OBJ,DB,TABLE,COL,NEWNAME,QUOTE,TEMP) +// ** +// ** 0. zSql: SQL statement to rewrite +// ** 1. type: Type of object ("table", "view" etc.) +// ** 2. object: Name of object +// ** 3. Database: Database name (e.g. "main") +// ** 4. Table: Table name +// ** 5. iCol: Index of column to rename +// ** 6. zNew: New column name +// ** 7. bQuote: Non-zero if the new column name should be quoted. +// ** 8. bTemp: True if zSql comes from temp schema +// ** +// ** Do a column rename operation on the CREATE statement given in zSql. +// ** The iCol-th column (left-most is 0) of table zTable is renamed from zCol +// ** into zNew. The name should be quoted if bQuote is true. +// ** +// ** This function is used internally by the ALTER TABLE RENAME COLUMN command. +// ** It is only accessible to SQL created using sqlite3NestedParse(). It is +// ** not reachable from ordinary SQL passed into sqlite3_prepare() unless the +// ** SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test setting is enabled. +// */ +func _renameColumnFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(496) + defer tls.Free(496) + var bFKOnly, bQuote, bTemp, i, iCol, rc, v1 int32 + var db, pExpr, pFKey, pIdx, pSelect, pStep, pTab, pTarget, pUpsertSet, zDb, zNew, zOld, zSql, zTable uintptr + var xAuth Tsqlite3_xauth + var _ /* sCtx at bp+0 */ TRenameCtx + var _ /* sParse at bp+32 */ TParse + var _ /* sWalker at bp+448 */ TWalker + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bFKOnly, bQuote, bTemp, db, i, iCol, pExpr, pFKey, pIdx, pSelect, pStep, pTab, pTarget, pUpsertSet, rc, xAuth, zDb, zNew, zOld, zSql, zTable, v1 + db = Xsqlite3_context_db_handle(tls, context) + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + zTable = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 5*8))) + zNew = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 6*8))) + bQuote = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 7*8))) + bTemp = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 8*8))) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + _ = NotUsed + if zSql == uintptr(0) { + return + } + if zTable == uintptr(0) { + return + } + if zNew == uintptr(0) { + return + } + if iCol < 0 { + return + } + _sqlite3BtreeEnterAll(tls, db) + pTab = _sqlite3FindTable(tls, db, zTable, zDb) + if pTab == uintptr(0) || iCol >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + _sqlite3BtreeLeaveAll(tls, db) + return + } + zOld = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + libc.X__builtin___memset_chk(tls, bp, 0, uint64(32), ^t__predefined_size_t(0)) + if iCol == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + v1 = -int32(1) + } else { + v1 = iCol + } + (**(**TRenameCtx)(__ccgo_up(bp))).FiCol = v1 + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + rc = _renameParseSql(tls, bp+32, zDb, db, zSql, bTemp) + /* Find tokens that need to be replaced. */ + libc.X__builtin___memset_chk(tls, bp+448, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp + 448))).FpParse = bp + 32 + (**(**TWalker)(__ccgo_up(bp + 448))).FxExprCallback = __ccgo_fp(_renameColumnExprCb) + (**(**TWalker)(__ccgo_up(bp + 448))).FxSelectCallback = __ccgo_fp(_renameColumnSelectCb) + *(*uintptr)(unsafe.Pointer(bp + 448 + 40)) = bp + (**(**TRenameCtx)(__ccgo_up(bp))).FpTab = pTab + if rc != SQLITE_OK { + goto renameColumnFunc_done + } + if (**(**TParse)(__ccgo_up(bp + 32))).FpNewTable != 0 { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FeTabType) == int32(TABTYP_VIEW) { + pSelect = (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).Fu))).FpSelect + **(**Tu32)(__ccgo_up(pSelect + 4)) &= ^libc.Uint32FromInt32(SF_View) + (**(**TParse)(__ccgo_up(bp + 32))).Frc = SQLITE_OK + _sqlite3SelectPrep(tls, bp+32, pSelect, uintptr(0)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + v1 = int32(SQLITE_NOMEM) + } else { + v1 = (**(**TParse)(__ccgo_up(bp + 32))).Frc + } + rc = v1 + if rc == SQLITE_OK { + _sqlite3WalkSelect(tls, bp+448, pSelect) + } + if rc != SQLITE_OK { + goto renameColumnFunc_done + } + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FeTabType) == TABTYP_NORM { + /* A regular table */ + bFKOnly = Xsqlite3_stricmp(tls, zTable, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FzName) + (**(**TRenameCtx)(__ccgo_up(bp))).FpTab = (**(**TParse)(__ccgo_up(bp + 32))).FpNewTable + if bFKOnly == 0 { + if iCol < int32((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FnCol) { + _renameTokenFind(tls, bp+32, bp, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FaCol + uintptr(iCol)*16))).FzCnName) + } + if (**(**TRenameCtx)(__ccgo_up(bp))).FiCol < 0 { + _renameTokenFind(tls, bp+32, bp, (**(**TParse)(__ccgo_up(bp + 32))).FpNewTable+52) + } + _sqlite3WalkExprList(tls, bp+448, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FpCheck) + pIdx = (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FpIndex + for { + if !(pIdx != 0) { + break + } + _sqlite3WalkExprList(tls, bp+448, (*TIndex)(unsafe.Pointer(pIdx)).FaColExpr) + goto _3 + _3: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + pIdx = (**(**TParse)(__ccgo_up(bp + 32))).FpNewIndex + for { + if !(pIdx != 0) { + break + } + _sqlite3WalkExprList(tls, bp+448, (*TIndex)(unsafe.Pointer(pIdx)).FaColExpr) + goto _4 + _4: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FnCol)) { + break + } + pExpr = _sqlite3ColumnExpr(tls, (**(**TParse)(__ccgo_up(bp + 32))).FpNewTable, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FaCol+uintptr(i)*16) + _sqlite3WalkExpr(tls, bp+448, pExpr) + goto _5 + _5: + ; + i = i + 1 + } + } + pFKey = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable + 64))).FpFKey + for { + if !(pFKey != 0) { + break + } + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + if bFKOnly == 0 && (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FiFrom == iCol { + _renameTokenFind(tls, bp+32, bp, pFKey+64+uintptr(i)*16) + } + if 0 == Xsqlite3_stricmp(tls, (*TFKey)(unsafe.Pointer(pFKey)).FzTo, zTable) && 0 == Xsqlite3_stricmp(tls, (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FzCol, zOld) { + _renameTokenFind(tls, bp+32, bp, (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FzCol) + } + goto _7 + _7: + ; + i = i + 1 + } + goto _6 + _6: + ; + pFKey = (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom + } + } + } + } else { + if (**(**TParse)(__ccgo_up(bp + 32))).FpNewIndex != 0 { + _sqlite3WalkExprList(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewIndex)).FaColExpr) + _sqlite3WalkExpr(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewIndex)).FpPartIdxWhere) + } else { + rc = _renameResolveTrigger(tls, bp+32) + if rc != SQLITE_OK { + goto renameColumnFunc_done + } + pStep = (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTrigger)).Fstep_list + for { + if !(pStep != 0) { + break + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + pTarget = _sqlite3LocateTableItem(tls, bp+32, uint32(0), (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc+8) + if pTarget == pTab { + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0 { + pUpsertSet = (*TUpsert)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert)).FpUpsertSet + _renameColumnElistNames(tls, bp+32, bp, pUpsertSet, zOld) + } + _renameColumnIdlistNames(tls, bp+32, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpIdList, zOld) + _renameColumnElistNames(tls, bp+32, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, zOld) + } + } + goto _8 + _8: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + /* Find tokens to edit in UPDATE OF clause */ + if (**(**TParse)(__ccgo_up(bp + 32))).FpTriggerTab == pTab { + _renameColumnIdlistNames(tls, bp+32, bp, (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTrigger)).FpColumns, zOld) + } + /* Find tokens to edit in various expressions and selects */ + _renameWalkTrigger(tls, bp+448, (**(**TParse)(__ccgo_up(bp + 32))).FpNewTrigger) + } + } + rc = _renameEditSql(tls, context, bp, zSql, zNew, bQuote) + goto renameColumnFunc_done +renameColumnFunc_done: + ; + if rc != SQLITE_OK { + if rc == int32(SQLITE_ERROR) && _sqlite3WritableSchema(tls, db) != 0 { + Xsqlite3_result_value(tls, context, **(**uintptr)(__ccgo_up(argv))) + } else { + if (**(**TParse)(__ccgo_up(bp + 32))).FzErrMsg != 0 { + _renameColumnParseError(tls, context, __ccgo_ts+1702, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), bp+32) + } else { + Xsqlite3_result_error_code(tls, context, rc) + } + } + } + _renameParseCleanup(tls, bp+32) + _renameTokenFree(tls, db, (**(**TRenameCtx)(__ccgo_up(bp))).FpList) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + _sqlite3BtreeLeaveAll(tls, db) +} + +// C documentation +// +// /* +// ** An error occurred while parsing or otherwise processing a database +// ** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an +// ** ALTER TABLE RENAME COLUMN program. The error message emitted by the +// ** sub-routine is currently stored in pParse->zErrMsg. This function +// ** adds context to the error message and then stores it in pCtx. +// */ +func _renameColumnParseError(tls *libc.TLS, pCtx uintptr, zWhen uintptr, pType uintptr, pObject uintptr, pParse uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var zErr, zN, zT, v1 uintptr + _, _, _, _ = zErr, zN, zT, v1 + zT = Xsqlite3_value_text(tls, pType) + zN = Xsqlite3_value_text(tls, pObject) + if **(**int8)(__ccgo_up(zWhen)) != 0 { + v1 = __ccgo_ts + 11885 + } else { + v1 = __ccgo_ts + 1702 + } + zErr = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+11887, libc.VaList(bp+8, zT, zN, v1, zWhen, (*TParse)(unsafe.Pointer(pParse)).FzErrMsg)) + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zErr) +} + +// C documentation +// +// /* +// ** This function edits SQL statement zSql, replacing each token identified +// ** by the linked list pRename with the text of zNew. If argument bQuote is +// ** true, then zNew is always quoted first. If no error occurs, the result +// ** is loaded into context object pCtx as the result. +// ** +// ** Or, if an error occurs (i.e. an OOM condition), an error is left in +// ** pCtx and an SQLite error code returned. +// */ +func _renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, zNew uintptr, bQuote int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pBest, zBuf1, zBuf2, zOut, zQuot, zReplace, v1 uintptr + var iOff, rc int32 + var nNew, nOut, nQuot, nReplace, nSql Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, iOff, nNew, nOut, nQuot, nReplace, nSql, pBest, rc, zBuf1, zBuf2, zOut, zQuot, zReplace, v1 + nNew = int64(_sqlite3Strlen30(tls, zNew)) + nSql = int64(_sqlite3Strlen30(tls, zSql)) + db = Xsqlite3_context_db_handle(tls, pCtx) + rc = SQLITE_OK + zQuot = uintptr(0) + nQuot = 0 + zBuf1 = uintptr(0) + zBuf2 = uintptr(0) + if zNew != 0 { + /* Set zQuot to point to a buffer containing a quoted copy of the + ** identifier zNew. If the corresponding identifier in the original + ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to + ** point to zQuot so that all substitutions are made using the + ** quoted version of the new column name. */ + zQuot = _sqlite3MPrintf(tls, db, __ccgo_ts+11918, libc.VaList(bp+8, zNew)) + if zQuot == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + nQuot = int64(_sqlite3Strlen30(tls, zQuot) - int32(1)) + } + zOut = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nSql)+libc.Uint64FromInt32((*TRenameCtx)(unsafe.Pointer(pRename)).FnList)*libc.Uint64FromInt64(nQuot)+uint64(1)) + } else { + zOut = _sqlite3DbMallocZero(tls, db, (uint64(2)*libc.Uint64FromInt64(nSql)+uint64(1))*uint64(3)) + if zOut != 0 { + zBuf1 = zOut + uintptr(nSql*int64(2)+int64(1)) + zBuf2 = zOut + uintptr(nSql*int64(4)+int64(2)) + } + } + /* At this point pRename->pList contains a list of RenameToken objects + ** corresponding to all tokens in the input SQL that must be replaced + ** with the new column name, or with single-quoted versions of themselves. + ** All that remains is to construct and return the edited SQL string. */ + if zOut != 0 { + nOut = nSql + libc.X__builtin___memcpy_chk(tls, zOut, zSql, libc.Uint64FromInt64(nSql), ^t__predefined_size_t(0)) + for (*TRenameCtx)(unsafe.Pointer(pRename)).FpList != 0 { + pBest = _renameColumnTokenNext(tls, pRename) + if zNew != 0 { + if bQuote == 0 && _sqlite3IsIdChar(tls, **(**Tu8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz))) != 0 { + nReplace = nNew + zReplace = zNew + } else { + nReplace = nQuot + zReplace = zQuot + if int32(**(**int8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)))) == int32('"') { + nReplace = nReplace + 1 + } + } + } else { + /* Dequote the double-quoted token. Then requote it again, this time + ** using single quotes. If the character immediately following the + ** original token within the input SQL was a single quote ('), then + ** add another space after the new, single-quoted version of the + ** token. This is so that (SELECT "string"'alias') maps to + ** (SELECT 'string' 'alias'), and not (SELECT 'string''alias'). */ + libc.X__builtin___memcpy_chk(tls, zBuf1, (*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz, uint64((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(zBuf1 + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn))) = 0 + _sqlite3Dequote(tls, zBuf1) + if int32(**(**int8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)))) == int32('\'') { + v1 = __ccgo_ts + 11885 + } else { + v1 = __ccgo_ts + 1702 + } + Xsqlite3_snprintf(tls, int32(nSql*libc.Int64FromInt32(2)), zBuf2, __ccgo_ts+11924, libc.VaList(bp+8, zBuf1, v1)) + zReplace = zBuf2 + nReplace = int64(_sqlite3Strlen30(tls, zReplace)) + } + iOff = int32(int64((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz) - int64(zSql)) + if libc.Int64FromUint32((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn) != nReplace { + libc.X__builtin___memmove_chk(tls, zOut+uintptr(int64(iOff)+nReplace), zOut+uintptr(libc.Uint32FromInt32(iOff)+(*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn), libc.Uint64FromInt64(nOut-libc.Int64FromUint32(libc.Uint32FromInt32(iOff)+(*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)), ^t__predefined_size_t(0)) + nOut = nOut + (nReplace - libc.Int64FromUint32((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)) + **(**int8)(__ccgo_up(zOut + uintptr(nOut))) = int8('\000') + } + libc.X__builtin___memcpy_chk(tls, zOut+uintptr(iOff), zReplace, libc.Uint64FromInt64(nReplace), ^t__predefined_size_t(0)) + _sqlite3DbFree(tls, db, pBest) + } + Xsqlite3_result_text(tls, pCtx, zOut, -int32(1), uintptr(-libc.Int32FromInt32(1))) + _sqlite3DbFree(tls, db, zOut) + } else { + rc = int32(SQLITE_NOMEM) + } + Xsqlite3_free(tls, zQuot) + return rc +} + +// C documentation +// +// /* +// ** Generate VM code to replace any double-quoted strings (but not double-quoted +// ** identifiers) within the "sql" column of the sqlite_schema table in +// ** database zDb with their single-quoted equivalents. If argument bTemp is +// ** not true, similarly update all SQL statements in the sqlite_schema table +// ** of the temp db. +// */ +func _renameFixQuotes(tls *libc.TLS, pParse uintptr, zDb uintptr, bTemp int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9364, libc.VaList(bp+8, zDb, zDb)) + if bTemp == 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9511, 0) + } +} + +// C documentation +// +// /* +// ** Parse the SQL statement zSql using Parse object (*p). The Parse object +// ** is initialized by this function before it is used. +// */ +func _renameParseSql(tls *libc.TLS, p uintptr, zDb uintptr, db uintptr, zSql uintptr, bTemp int32) (r int32) { + var flags Tu64 + var iDb, rc int32 + _, _, _ = flags, iDb, rc + _sqlite3ParseObjectInit(tls, p, db) + if zSql == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+11910, int32(7)) != 0 { + return _sqlite3CorruptError(tls, int32(121586)) + } + if bTemp != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(1) + } else { + iDb = _sqlite3FindDbName(tls, db, zDb) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(iDb) + } + (*TParse)(unsafe.Pointer(p)).FeParseMode = uint8(PARSE_MODE_RENAME) + (*TParse)(unsafe.Pointer(p)).Fdb = db + (*TParse)(unsafe.Pointer(p)).FnQueryLoop = int16(1) + flags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + **(**Tu64)(__ccgo_up(db + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(0x00040)) << libc.Int32FromInt32(32) + rc = _sqlite3RunParser(tls, p, zSql) + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = flags + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } + if rc == SQLITE_OK && ((*TParse)(unsafe.Pointer(p)).FpNewTable == uintptr(0) && (*TParse)(unsafe.Pointer(p)).FpNewIndex == uintptr(0) && (*TParse)(unsafe.Pointer(p)).FpNewTrigger == uintptr(0)) { + rc = _sqlite3CorruptError(tls, int32(121607)) + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + return rc +} + +// C documentation +// +// /* SQL function: sqlite_rename_quotefix(DB,SQL) +// ** +// ** Rewrite the DDL statement "SQL" so that any string literals that use +// ** double-quotes use single quotes instead. +// ** +// ** Two arguments must be passed: +// ** +// ** 0: Database name ("main", "temp" etc.). +// ** 1: SQL statement to edit. +// ** +// ** The returned value is the modified SQL statement. For example, given +// ** the database schema: +// ** +// ** CREATE TABLE t1(a, b, c); +// ** +// ** SELECT sqlite_rename_quotefix('main', +// ** 'CREATE VIEW v1 AS SELECT "a", "string" FROM t1' +// ** ); +// ** +// ** returns the string: +// ** +// ** CREATE VIEW v1 AS SELECT "a", 'string' FROM t1 +// ** +// ** If there is a error in the input SQL, then raise an error, except +// ** if PRAGMA writable_schema=ON, then just return the input string +// ** unmodified following an error. +// */ +func _renameQuotefixFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(496) + defer tls.Free(496) + var db, pSelect, zDb, zInput uintptr + var i, rc, v1 int32 + var xAuth Tsqlite3_xauth + var _ /* sCtx at bp+416 */ TRenameCtx + var _ /* sParse at bp+0 */ TParse + var _ /* sWalker at bp+448 */ TWalker + _, _, _, _, _, _, _, _ = db, i, pSelect, rc, xAuth, zDb, zInput, v1 + db = Xsqlite3_context_db_handle(tls, context) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zInput = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + _sqlite3BtreeEnterAll(tls, db) + _ = NotUsed + if zDb != 0 && zInput != 0 { + rc = _renameParseSql(tls, bp, zDb, db, zInput, 0) + if rc == SQLITE_OK { + /* Walker to find tokens that need to be replaced. */ + libc.X__builtin___memset_chk(tls, bp+416, 0, uint64(32), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+448, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp + 448))).FpParse = bp + (**(**TWalker)(__ccgo_up(bp + 448))).FxExprCallback = __ccgo_fp(_renameQuotefixExprCb) + (**(**TWalker)(__ccgo_up(bp + 448))).FxSelectCallback = __ccgo_fp(_renameColumnSelectCb) + *(*uintptr)(unsafe.Pointer(bp + 448 + 40)) = bp + 416 + if (**(**TParse)(__ccgo_up(bp))).FpNewTable != 0 { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FeTabType) == int32(TABTYP_VIEW) { + pSelect = (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).Fu))).FpSelect + **(**Tu32)(__ccgo_up(pSelect + 4)) &= ^libc.Uint32FromInt32(SF_View) + (**(**TParse)(__ccgo_up(bp))).Frc = SQLITE_OK + _sqlite3SelectPrep(tls, bp, pSelect, uintptr(0)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + v1 = int32(SQLITE_NOMEM) + } else { + v1 = (**(**TParse)(__ccgo_up(bp))).Frc + } + rc = v1 + if rc == SQLITE_OK { + _sqlite3WalkSelect(tls, bp+448, pSelect) + } + } else { + _sqlite3WalkExprList(tls, bp+448, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FpCheck) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FnCol)) { + break + } + _sqlite3WalkExpr(tls, bp+448, _sqlite3ColumnExpr(tls, (**(**TParse)(__ccgo_up(bp))).FpNewTable, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FaCol+uintptr(i)*16)) + goto _2 + _2: + ; + i = i + 1 + } + } + } else { + if (**(**TParse)(__ccgo_up(bp))).FpNewIndex != 0 { + _sqlite3WalkExprList(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewIndex)).FaColExpr) + _sqlite3WalkExpr(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewIndex)).FpPartIdxWhere) + } else { + rc = _renameResolveTrigger(tls, bp) + if rc == SQLITE_OK { + _renameWalkTrigger(tls, bp+448, (**(**TParse)(__ccgo_up(bp))).FpNewTrigger) + } + } + } + if rc == SQLITE_OK { + rc = _renameEditSql(tls, context, bp+416, zInput, uintptr(0), 0) + } + _renameTokenFree(tls, db, (**(**TRenameCtx)(__ccgo_up(bp + 416))).FpList) + } + if rc != SQLITE_OK { + if _sqlite3WritableSchema(tls, db) != 0 && rc == int32(SQLITE_ERROR) { + Xsqlite3_result_value(tls, context, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + Xsqlite3_result_error_code(tls, context, rc) + } + } + _renameParseCleanup(tls, bp) + } + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + _sqlite3BtreeLeaveAll(tls, db) +} + +// C documentation +// +// /* +// ** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming +// ** it was read from the schema of database zDb. Return SQLITE_OK if +// ** successful. Otherwise, return an SQLite error code and leave an error +// ** message in the Parse object. +// */ +func _renameResolveTrigger(tls *libc.TLS, pParse uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, p, pNew, pSel, pSrc, pStep, pUpsert, pUpsertSet uintptr + var i, rc, v2 int32 + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _ = db, i, p, pNew, pSel, pSrc, pStep, pUpsert, pUpsertSet, rc, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger + rc = SQLITE_OK + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = _sqlite3FindTable(tls, db, (*TTrigger)(unsafe.Pointer(pNew)).Ftable, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(_sqlite3SchemaToIndex(tls, db, (*TTrigger)(unsafe.Pointer(pNew)).FpTabSchema))*32))).FzDbSName) + (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = (*TTrigger)(unsafe.Pointer(pNew)).Fop + /* ALWAYS() because if the table of the trigger does not exist, the + ** error would have been hit before this point */ + if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { + rc = libc.BoolInt32(_sqlite3ViewGetColumnNames(tls, pParse, (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab) != 0) + } + /* Resolve symbols in WHEN clause */ + if rc == SQLITE_OK && (*TTrigger)(unsafe.Pointer(pNew)).FpWhen != 0 { + rc = _sqlite3ResolveExprNames(tls, bp, (*TTrigger)(unsafe.Pointer(pNew)).FpWhen) + } + pStep = (*TTrigger)(unsafe.Pointer(pNew)).Fstep_list + for { + if !(rc == SQLITE_OK && pStep != 0) { + break + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect != 0 { + _sqlite3SelectPrep(tls, pParse, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect, bp) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + rc = (*TParse)(unsafe.Pointer(pParse)).Frc + } + } + if rc == SQLITE_OK && (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + pSrc = _sqlite3SrcListDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc, 0) + if pSrc != 0 { + pSel = _sqlite3SelectNew(tls, pParse, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + if pSel == uintptr(0) { + (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList = uintptr(0) + pSrc = uintptr(0) + rc = int32(SQLITE_NOMEM) + } else { + /* pStep->pExprList contains an expression-list used for an UPDATE + ** statement. So the a[].zEName values are the RHS of the + ** " = " clauses of the UPDATE statement. So, before + ** running SelectPrep(), change all the eEName values in + ** pStep->pExprList to ENAME_SPAN (from their current value of + ** ENAME_NAME). This is to prevent any ids in ON() clauses that are + ** part of pSrc from being incorrectly resolved against the + ** a[].zEName values as if they were column aliases. */ + _renameSetENames(tls, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, int32(ENAME_SPAN)) + _sqlite3SelectPrep(tls, pParse, pSel, uintptr(0)) + _renameSetENames(tls, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, ENAME_NAME) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = SQLITE_OK + } + rc = v2 + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList != 0 { + (*TSelect)(unsafe.Pointer(pSel)).FpEList = uintptr(0) + } + (*TSelect)(unsafe.Pointer(pSel)).FpSrc = uintptr(0) + _sqlite3SelectDelete(tls, db, pSel) + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc)).FnSrc && rc == SQLITE_OK) { + break + } + p = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 + uintptr(i)*80 + if int32(*(*uint32)(unsafe.Pointer(p + 24 + 4))&0x4>>2) != 0 { + _sqlite3SelectPrep(tls, pParse, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 72)))).FpSelect, uintptr(0)) + } + goto _3 + _3: + ; + i = i + 1 + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pSrc + if rc == SQLITE_OK && (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere != 0 { + rc = _sqlite3ResolveExprNames(tls, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere) + } + if rc == SQLITE_OK { + rc = _sqlite3ResolveExprListNames(tls, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList) + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0 && rc == SQLITE_OK { + pUpsert = (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert + (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc = pSrc + *(*uintptr)(unsafe.Pointer(bp + 16)) = pUpsert + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = int32(NC_UUpsert) + rc = _sqlite3ResolveExprListNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) + if rc == SQLITE_OK { + pUpsertSet = (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSet + rc = _sqlite3ResolveExprListNames(tls, bp, pUpsertSet) + } + if rc == SQLITE_OK { + rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere) + } + if rc == SQLITE_OK { + rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = 0 + } + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = uintptr(0) + _sqlite3SrcListDelete(tls, db, pSrc) + } else { + rc = int32(SQLITE_NOMEM) + } + } + goto _1 + _1: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + return rc +} + +// C documentation +// +// /* +// ** This C function implements an SQL user function that is used by SQL code +// ** generated by the ALTER TABLE ... RENAME command to modify the definition +// ** of any foreign key constraints that use the table being renamed as the +// ** parent table. It is passed three arguments: +// ** +// ** 0: The database containing the table being renamed. +// ** 1. type: Type of object ("table", "view" etc.) +// ** 2. object: Name of object +// ** 3: The complete text of the schema statement being modified, +// ** 4: The old name of the table being renamed, and +// ** 5: The new name of the table being renamed. +// ** 6: True if the schema statement comes from the temp db. +// ** +// ** It returns the new schema statement. For example: +// ** +// ** sqlite_rename_table('main', 'CREATE TABLE t1(a REFERENCES t2)','t2','t3',0) +// ** -> 'CREATE TABLE t1(a REFERENCES t3)' +// */ +func _renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(560) + defer tls.Free(560) + var bQuote, bTemp, i, isLegacy, rc int32 + var db, pFKey, pItem, pSelect, pStep, pTab, pTrigger, zDb, zInput, zNew, zOld uintptr + var xAuth Tsqlite3_xauth + var _ /* sCtx at bp+416 */ TRenameCtx + var _ /* sNC at bp+496 */ TNameContext + var _ /* sParse at bp+0 */ TParse + var _ /* sWalker at bp+448 */ TWalker + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bQuote, bTemp, db, i, isLegacy, pFKey, pItem, pSelect, pStep, pTab, pTrigger, rc, xAuth, zDb, zInput, zNew, zOld + db = Xsqlite3_context_db_handle(tls, context) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zInput = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + zOld = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + zNew = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 5*8))) + bTemp = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 6*8))) + _ = NotUsed + if zInput != 0 && zOld != 0 && zNew != 0 { + bQuote = int32(1) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + _sqlite3BtreeEnterAll(tls, db) + libc.X__builtin___memset_chk(tls, bp+416, 0, uint64(32), ^t__predefined_size_t(0)) + (**(**TRenameCtx)(__ccgo_up(bp + 416))).FpTab = _sqlite3FindTable(tls, db, zOld, zDb) + libc.X__builtin___memset_chk(tls, bp+448, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp + 448))).FpParse = bp + (**(**TWalker)(__ccgo_up(bp + 448))).FxExprCallback = __ccgo_fp(_renameTableExprCb) + (**(**TWalker)(__ccgo_up(bp + 448))).FxSelectCallback = __ccgo_fp(_renameTableSelectCb) + *(*uintptr)(unsafe.Pointer(bp + 448 + 40)) = bp + 416 + rc = _renameParseSql(tls, bp, zDb, db, zInput, bTemp) + if rc == SQLITE_OK { + isLegacy = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_LegacyAlter)) + if (**(**TParse)(__ccgo_up(bp))).FpNewTable != 0 { + pTab = (**(**TParse)(__ccgo_up(bp))).FpNewTable + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + if isLegacy == 0 { + pSelect = (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTab)).Fu))).FpSelect + libc.X__builtin___memset_chk(tls, bp+496, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp + 496))).FpParse = bp + **(**Tu32)(__ccgo_up(pSelect + 4)) &= ^libc.Uint32FromInt32(SF_View) + _sqlite3SelectPrep(tls, bp, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTab)).Fu))).FpSelect, bp+496) + if (**(**TParse)(__ccgo_up(bp))).FnErr != 0 { + rc = (**(**TParse)(__ccgo_up(bp))).Frc + } else { + _sqlite3WalkSelect(tls, bp+448, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTab)).Fu))).FpSelect) + } + } + } else { + /* Modify any FK definitions to point to the new table. */ + if (isLegacy == 0 || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + pFKey = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey + for { + if !(pFKey != 0) { + break + } + if Xsqlite3_stricmp(tls, (*TFKey)(unsafe.Pointer(pFKey)).FzTo, zOld) == 0 { + _renameTokenFind(tls, bp, bp+416, (*TFKey)(unsafe.Pointer(pFKey)).FzTo) + } + goto _1 + _1: + ; + pFKey = (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom + } + } + /* If this is the table being altered, fix any table refs in CHECK + ** expressions. Also update the name that appears right after the + ** "CREATE [VIRTUAL] TABLE" bit. */ + if Xsqlite3_stricmp(tls, zOld, (*TTable)(unsafe.Pointer(pTab)).FzName) == 0 { + (**(**TRenameCtx)(__ccgo_up(bp + 416))).FpTab = pTab + if isLegacy == 0 { + _sqlite3WalkExprList(tls, bp+448, (*TTable)(unsafe.Pointer(pTab)).FpCheck) + } + _renameTokenFind(tls, bp, bp+416, (*TTable)(unsafe.Pointer(pTab)).FzName) + } + } + } else { + if (**(**TParse)(__ccgo_up(bp))).FpNewIndex != 0 { + _renameTokenFind(tls, bp, bp+416, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewIndex)).FzName) + if isLegacy == 0 { + _sqlite3WalkExpr(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewIndex)).FpPartIdxWhere) + } + } else { + pTrigger = (**(**TParse)(__ccgo_up(bp))).FpNewTrigger + if 0 == Xsqlite3_stricmp(tls, (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTrigger)).Ftable, zOld) && (*TTable)(unsafe.Pointer((**(**TRenameCtx)(__ccgo_up(bp + 416))).FpTab)).FpSchema == (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema { + _renameTokenFind(tls, bp, bp+416, (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTrigger)).Ftable) + } + if isLegacy == 0 { + rc = _renameResolveTrigger(tls, bp) + if rc == SQLITE_OK { + _renameWalkTrigger(tls, bp+448, pTrigger) + pStep = (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list + for { + if !(pStep != 0) { + break + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc)).FnSrc) { + break + } + pItem = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 + uintptr(i)*80 + if 0 == Xsqlite3_stricmp(tls, (*TSrcItem)(unsafe.Pointer(pItem)).FzName, zOld) { + _renameTokenFind(tls, bp, bp+416, (*TSrcItem)(unsafe.Pointer(pItem)).FzName) + } + goto _3 + _3: + ; + i = i + 1 + } + } + goto _2 + _2: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + } + } + } + } + } + if rc == SQLITE_OK { + rc = _renameEditSql(tls, context, bp+416, zInput, zNew, bQuote) + } + if rc != SQLITE_OK { + if rc == int32(SQLITE_ERROR) && _sqlite3WritableSchema(tls, db) != 0 { + Xsqlite3_result_value(tls, context, **(**uintptr)(__ccgo_up(argv + 3*8))) + } else { + if (**(**TParse)(__ccgo_up(bp))).FzErrMsg != 0 { + _renameColumnParseError(tls, context, __ccgo_ts+1702, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), bp) + } else { + Xsqlite3_result_error_code(tls, context, rc) + } + } + } + _renameParseCleanup(tls, bp) + _renameTokenFree(tls, db, (**(**TRenameCtx)(__ccgo_up(bp + 416))).FpList) + _sqlite3BtreeLeaveAll(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + } + return +} + +// C documentation +// +// /* Function: sqlite_rename_test(DB,SQL,TYPE,NAME,ISTEMP,WHEN,DQS) +// ** +// ** An SQL user function that checks that there are no parse or symbol +// ** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement. +// ** After an ALTER TABLE .. RENAME operation is performed and the schema +// ** reloaded, this function is called on each SQL statement in the schema +// ** to ensure that it is still usable. +// ** +// ** 0: Database name ("main", "temp" etc.). +// ** 1: SQL statement. +// ** 2: Object type ("view", "table", "trigger" or "index"). +// ** 3: Object name. +// ** 4: True if object is from temp schema. +// ** 5: "when" part of error message. +// ** 6: True to disable the DQS quirk when parsing SQL. +// ** +// ** The return value is computed as follows: +// ** +// ** A. If an error is seen and not in PRAGMA writable_schema=ON mode, +// ** then raise the error. +// ** B. Else if a trigger is created and the the table that the trigger is +// ** attached to is in database zDb, then return 1. +// ** C. Otherwise return NULL. +// */ +func _renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(480) + defer tls.Free(480) + var bNoDQS, bTemp, i1, i2, isLegacy, rc int32 + var db, zDb, zInput, zWhen uintptr + var flags Tu64 + var xAuth Tsqlite3_xauth + var _ /* sNC at bp+416 */ TNameContext + var _ /* sParse at bp+0 */ TParse + _, _, _, _, _, _, _, _, _, _, _, _ = bNoDQS, bTemp, db, flags, i1, i2, isLegacy, rc, xAuth, zDb, zInput, zWhen + db = Xsqlite3_context_db_handle(tls, context) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zInput = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + bTemp = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + isLegacy = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_LegacyAlter)) + zWhen = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 5*8))) + bNoDQS = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 6*8))) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + _ = NotUsed + if zDb != 0 && zInput != 0 { + flags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + if bNoDQS != 0 { + **(**Tu64)(__ccgo_up(db + 48)) &= libc.Uint64FromInt32(^(libc.Int32FromInt32(SQLITE_DqsDML) | libc.Int32FromInt32(SQLITE_DqsDDL))) + } + rc = _renameParseSql(tls, bp, zDb, db, zInput, bTemp) + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = flags + if rc == SQLITE_OK { + if isLegacy == 0 && (**(**TParse)(__ccgo_up(bp))).FpNewTable != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FeTabType) == int32(TABTYP_VIEW) { + libc.X__builtin___memset_chk(tls, bp+416, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp + 416))).FpParse = bp + _sqlite3SelectPrep(tls, bp, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).Fu))).FpSelect, bp+416) + if (**(**TParse)(__ccgo_up(bp))).FnErr != 0 { + rc = (**(**TParse)(__ccgo_up(bp))).Frc + } + } else { + if (**(**TParse)(__ccgo_up(bp))).FpNewTrigger != 0 { + if isLegacy == 0 { + rc = _renameResolveTrigger(tls, bp) + } + if rc == SQLITE_OK { + i1 = _sqlite3SchemaToIndex(tls, db, (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTrigger)).FpTabSchema) + i2 = _sqlite3FindDbName(tls, db, zDb) + if i1 == i2 { + /* Handle output case B */ + Xsqlite3_result_int(tls, context, int32(1)) + } + } + } + } + } + if rc != SQLITE_OK && zWhen != 0 && !(_sqlite3WritableSchema(tls, db) != 0) { + /* Output case A */ + _renameColumnParseError(tls, context, zWhen, **(**uintptr)(__ccgo_up(argv + 2*8)), **(**uintptr)(__ccgo_up(argv + 3*8)), bp) + } + _renameParseCleanup(tls, bp) + } + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth +} + +// C documentation +// +// /* +// ** Generate code to verify that the schemas of database zDb and, if +// ** bTemp is not true, database "temp", can still be parsed. This is +// ** called at the end of the generation of an ALTER TABLE ... RENAME ... +// ** statement to ensure that the operation has not rendered any schema +// ** objects unusable. +// */ +func _renameTestSchema(tls *libc.TLS, pParse uintptr, zDb uintptr, bTemp int32, zWhen uintptr, bNoDQS int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 5, 0x20) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9015, libc.VaList(bp+8, zDb, zDb, bTemp, zWhen, bNoDQS)) + if bTemp == 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9190, libc.VaList(bp+8, zDb, zWhen, bNoDQS)) + } +} + +// C documentation +// +// /* +// ** Iterate through the Select objects that are part of WITH clauses attached +// ** to select statement pSelect. +// */ +func _renameWalkWith(tls *libc.TLS, pWalker uintptr, pSelect uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i int32 + var p, pCopy, pParse, pWith uintptr + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _ = i, p, pCopy, pParse, pWith + pWith = (*TSelect)(unsafe.Pointer(pSelect)).FpWith + if pWith != 0 { + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + pCopy = uintptr(0) + if (*TSelect)(unsafe.Pointer((*(*TCte)(unsafe.Pointer(pWith + 16))).FpSelect)).FselFlags&uint32(SF_Expanded) == uint32(0) { + /* Push a copy of the With object onto the with-stack. We use a copy + ** here as the original will be expanded and resolved (flags SF_Expanded + ** and SF_Resolved) below. And the parser code that uses the with-stack + ** fails if the Select objects on it have already been expanded and + ** resolved. */ + pCopy = _sqlite3WithDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pWith) + pCopy = _sqlite3WithPush(tls, pParse, pCopy, uint8(1)) + } + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer(pWith)).FnCte) { + break + } + p = (*(*TCte)(unsafe.Pointer(pWith + 16 + uintptr(i)*48))).FpSelect + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + if pCopy != 0 { + _sqlite3SelectPrep(tls, (**(**TNameContext)(__ccgo_up(bp))).FpParse, p, bp) + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((**(**TNameContext)(__ccgo_up(bp))).FpParse)).Fdb)).FmallocFailed != 0 { + return + } + _sqlite3WalkSelect(tls, pWalker, p) + _sqlite3RenameExprlistUnmap(tls, pParse, (*(*TCte)(unsafe.Pointer(pWith + 16 + uintptr(i)*48))).FpCols) + goto _1 + _1: + ; + i = i + 1 + } + if pCopy != 0 && (*TParse)(unsafe.Pointer(pParse)).FpWith == pCopy { + (*TParse)(unsafe.Pointer(pParse)).FpWith = (*TWith)(unsafe.Pointer(pCopy)).FpOuter + } + } +} + +// C documentation +// +// /* +// ** Assign a new cursor number to each cursor in the FROM clause (Select.pSrc) +// ** of the SELECT statement passed as the second argument, and to each +// ** cursor in the FROM clause of any FROM clause sub-selects, recursively. +// ** Except, do not assign a new cursor number to the iExcept'th element in +// ** the FROM clause of (*p). Update all expressions and other references +// ** to refer to the new cursor numbers. +// ** +// ** Argument aCsrMap is an array that may be used for temporary working +// ** space. Two guarantees are made by the caller: +// ** +// ** * the array is larger than the largest cursor number used within the +// ** select statement passed as an argument, and +// ** +// ** * the array entries for all cursor numbers that do *not* appear in +// ** FROM clauses of the select statement as described above are +// ** initialized to zero. +// */ +func _renumberCursors(tls *libc.TLS, pParse uintptr, p uintptr, iExcept int32, aCsrMap uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + _srclistRenumberCursors(tls, pParse, aCsrMap, (*TSelect)(unsafe.Pointer(p)).FpSrc, iExcept) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + *(*uintptr)(unsafe.Pointer(bp + 40)) = aCsrMap + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_renumberCursorsCb) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + _sqlite3WalkSelect(tls, bp, p) +} + +// C documentation +// +// /* +// ** The replace() function. Three arguments are all strings: call +// ** them A, B, and C. The result is also a string which is derived +// ** from A by replacing every occurrence of B with C. The match +// ** must be exact. Collating sequences are not used. +// */ +func _replaceFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var cntExpand uint32 + var db, zOld, zOut, zPattern, zRep, zStr uintptr + var i, j, loopLimit, nPattern, nRep, nStr, v2, v3 int32 + var nOut Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cntExpand, db, i, j, loopLimit, nOut, nPattern, nRep, nStr, zOld, zOut, zPattern, zRep, zStr, v2, v3 /* Number zOut expansions */ + db = Xsqlite3_context_db_handle(tls, context) + _ = argc + zStr = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zStr == uintptr(0) { + return + } + nStr = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + /* No encoding change */ + zPattern = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zPattern == uintptr(0) { + return + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPattern))) == 0 { + Xsqlite3_result_text(tls, context, zStr, nStr, uintptr(-libc.Int32FromInt32(1))) + return + } + nPattern = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + /* No encoding change */ + zRep = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + if zRep == uintptr(0) { + return + } + nRep = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + nOut = int64(nStr + int32(1)) + zOut = _contextMalloc(tls, context, nOut) + if zOut == uintptr(0) { + return + } + loopLimit = nStr - nPattern + cntExpand = uint32(0) + v2 = libc.Int32FromInt32(0) + j = v2 + i = v2 + for { + if !(i <= loopLimit) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zStr + uintptr(i)))) != libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPattern))) || libc.Xmemcmp(tls, zStr+uintptr(i), zPattern, libc.Uint64FromInt32(nPattern)) != 0 { + v3 = j + j = j + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v3))) = **(**uint8)(__ccgo_up(zStr + uintptr(i))) + } else { + if nRep > nPattern { + nOut = nOut + int64(nRep-nPattern) + if nOut-int64(1) > int64(**(**int32)(__ccgo_up(db + 136))) { + Xsqlite3_result_error_toobig(tls, context) + Xsqlite3_free(tls, zOut) + return + } + cntExpand = cntExpand + 1 + if cntExpand&(cntExpand-uint32(1)) == uint32(0) { + zOld = zOut + zOut = _sqlite3Realloc(tls, zOut, libc.Uint64FromInt64(int64(int32(nOut))+(nOut-int64(nStr)-int64(1)))) + if zOut == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + Xsqlite3_free(tls, zOld) + return + } + } + } + libc.X__builtin___memcpy_chk(tls, zOut+uintptr(j), zRep, libc.Uint64FromInt32(nRep), ^t__predefined_size_t(0)) + j = j + nRep + i = i + (nPattern - int32(1)) + } + goto _1 + _1: + ; + i = i + 1 + } + libc.X__builtin___memcpy_chk(tls, zOut+uintptr(j), zStr+uintptr(i), libc.Uint64FromInt32(nStr-i), ^t__predefined_size_t(0)) + j = j + (nStr - i) + **(**uint8)(__ccgo_up(zOut + uintptr(j))) = uint8(0) + Xsqlite3_result_text(tls, context, zOut, j, __ccgo_fp(Xsqlite3_free)) +} + +// C documentation +// +// /* +// ** Reset the aggregate accumulator. +// ** +// ** The aggregate accumulator is a set of memory cells that hold +// ** intermediate results while calculating an aggregate. This +// ** routine generates code that stores NULLs in all of those memory +// ** cells. +// */ +func _resetAccumulator(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, nExtra, nReg int32 + var pE, pFunc, pKeyInfo, pKeyInfo1, pOBList, v uintptr + _, _, _, _, _, _, _, _, _ = i, nExtra, nReg, pE, pFunc, pKeyInfo, pKeyInfo1, pOBList, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + nReg = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + if nReg == 0 { + return + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+nReg-int32(1)) + pFunc = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + i = libc.Int32FromInt32(0) + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + if (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct >= 0 { + pE = (*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr + if *(*uintptr)(unsafe.Pointer(pE + 32)) == uintptr(0) || (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pE + 32)))).FnExpr != int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21759, 0) + (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct = -int32(1) + } else { + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, *(*uintptr)(unsafe.Pointer(pE + 32)), 0, 0) + (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiDistAddr = _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct, 0, 0, pKeyInfo, -int32(9)) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+21810, libc.VaList(bp+8, (*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFunc)).FzName)) + } + } + if (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiOBTab >= 0 { + nExtra = 0 + pOBList = *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr)).FpLeft + 32)) + if !((*TAggInfo_func)(unsafe.Pointer(pFunc)).FbOBUnique != 0) { + nExtra = nExtra + 1 /* One extra column for the OP_Sequence */ + } + if (*TAggInfo_func)(unsafe.Pointer(pFunc)).FbOBPayload != 0 { + /* extra columns for the function arguments */ + nExtra = nExtra + (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr + 32)))).FnExpr + } + if (*TAggInfo_func)(unsafe.Pointer(pFunc)).FbUseSubtype != 0 { + nExtra = nExtra + (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr + 32)))).FnExpr + } + pKeyInfo1 = _sqlite3KeyInfoFromExprList(tls, pParse, pOBList, 0, nExtra) + if !((*TAggInfo_func)(unsafe.Pointer(pFunc)).FbOBUnique != 0) && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + (*TKeyInfo)(unsafe.Pointer(pKeyInfo1)).FnKeyField = (*TKeyInfo)(unsafe.Pointer(pKeyInfo1)).FnKeyField + 1 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiOBTab, (*TExprList)(unsafe.Pointer(pOBList)).FnExpr+nExtra, 0, pKeyInfo1, -int32(9)) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+21843, libc.VaList(bp+8, (*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFunc)).FzName)) + } + goto _1 + _1: + ; + i = i + 1 + pFunc += 32 + } +} + +// C documentation +// +// /* +// ** Reset a cursor back to its initial state. +// */ +func _resetCursor(tls *libc.TLS, pCsr uintptr) { + var i, ii int32 + var pInfo, pRtree, pStmt uintptr + _, _, _, _, _ = i, ii, pInfo, pRtree, pStmt + pRtree = (*TRtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + if (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint != 0 { /* Used to iterate through constraint array */ + i = 0 + for { + if !(i < (*TRtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint) { + break + } + pInfo = (**(**TRtreeConstraint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint + uintptr(i)*24))).FpInfo + if pInfo != 0 { + if (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FxDelUser != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FxDelUser})))(tls, (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FpUser) + } + Xsqlite3_free(tls, pInfo) + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = uintptr(0) + } + ii = 0 + for { + if !(ii < int32(RTREE_CACHE_SZ)) { + break + } + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(pCsr + 88 + uintptr(ii)*8))) + goto _2 + _2: + ; + ii = ii + 1 + } + Xsqlite3_free(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaPoint) + pStmt = (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux + libc.X__builtin___memset_chk(tls, pCsr, 0, uint64(296), ^t__predefined_size_t(0)) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pRtree + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux = pStmt + /* The following will only fail if the previous sqlite3_step() call failed, + ** in which case the error has already been caught. This statement never + ** encounters an error within an sqlite3_column_xxx() function, as it + ** calls sqlite3_column_value(), which does not use malloc(). So it is safe + ** to ignore the error code here. */ + Xsqlite3_reset(tls, pStmt) +} + +// C documentation +// +// /* +// ** Resize an Index object to hold N columns total. Return SQLITE_OK +// ** on success and SQLITE_NOMEM on an OOM error. +// */ +func _resizeIndexObject(tls *libc.TLS, pParse uintptr, pIdx uintptr, N int32) (r int32) { + var db, zExtra uintptr + var nByte Tu64 + _, _, _ = db, nByte, zExtra + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) >= N { + return SQLITE_OK + } + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + nByte = uint64(libc.Uint64FromInt64(8)+libc.Uint64FromInt64(2)+libc.Uint64FromInt64(2)+libc.Uint64FromInt32(1)) * libc.Uint64FromInt32(N) + zExtra = _sqlite3DbMallocZero(tls, db, nByte) + if zExtra == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, zExtra, (*TIndex)(unsafe.Pointer(pIdx)).FazColl, uint64(8)*uint64((*TIndex)(unsafe.Pointer(pIdx)).FnColumn), ^t__predefined_size_t(0)) + (*TIndex)(unsafe.Pointer(pIdx)).FazColl = zExtra + zExtra = zExtra + uintptr(uint64(8)*libc.Uint64FromInt32(N)) + libc.X__builtin___memcpy_chk(tls, zExtra, (*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst, uint64(2)*libc.Uint64FromInt32(libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)+libc.Int32FromInt32(1)), ^t__predefined_size_t(0)) + (*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst = zExtra + zExtra = zExtra + uintptr(uint64(2)*libc.Uint64FromInt32(N)) + libc.X__builtin___memcpy_chk(tls, zExtra, (*TIndex)(unsafe.Pointer(pIdx)).FaiColumn, uint64(2)*uint64((*TIndex)(unsafe.Pointer(pIdx)).FnColumn), ^t__predefined_size_t(0)) + (*TIndex)(unsafe.Pointer(pIdx)).FaiColumn = zExtra + zExtra = zExtra + uintptr(uint64(2)*libc.Uint64FromInt32(N)) + libc.X__builtin___memcpy_chk(tls, zExtra, (*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder, uint64((*TIndex)(unsafe.Pointer(pIdx)).FnColumn), ^t__predefined_size_t(0)) + (*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder = zExtra + (*TIndex)(unsafe.Pointer(pIdx)).FnColumn = libc.Uint16FromInt32(N) /* See tag-20250221-1 above for proof of safety */ + libc.SetBitFieldPtr16Uint32(pIdx+100, libc.Uint32FromInt32(1), 4, 0x10) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Turn the pExpr expression into an alias for the iCol-th column of the +// ** result set in pEList. +// ** +// ** If the reference is followed by a COLLATE operator, then make sure +// ** the COLLATE operator is preserved. For example: +// ** +// ** SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase; +// ** +// ** Should be transformed into: +// ** +// ** SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase; +// ** +// ** The nSubquery parameter specifies how many levels of subquery the +// ** alias is removed from the original expression. The usual value is +// ** zero but it might be more if the alias is contained within a subquery +// ** of the original expression. The Expr.op2 field of TK_AGG_FUNCTION +// ** structures must be increased by the nSubquery amount. +// */ +func _resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pExpr uintptr, nSubquery int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var db, pDup, pOrig uintptr + var _ /* temp at bp+0 */ TExpr + _, _, _ = db, pDup, pOrig /* The database connection */ + pOrig = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(iCol)*32))).FpExpr + if (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo != 0 { + return + } + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pDup = _sqlite3ExprDup(tls, db, pOrig, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pDup) + pDup = uintptr(0) + } else { + _incrAggFunctionDepth(tls, pDup, nSubquery) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE) { + pDup = _sqlite3ExprAddCollateString(tls, pParse, pDup, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + } + libc.X__builtin___memcpy_chk(tls, bp, pDup, uint64(72), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, pDup, pExpr, uint64(72), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, pExpr, bp, uint64(72), ^t__predefined_size_t(0)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + if *(*uintptr)(unsafe.Pointer(pExpr + 64)) != uintptr(0) { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpOwner = pExpr + } + } + _sqlite3ExprDeferredDelete(tls, pParse, pDup) + } +} + +// C documentation +// +// /* +// ** Analyze the ORDER BY clause in a compound SELECT statement. Modify +// ** each term of the ORDER BY clause is a constant integer between 1 +// ** and N where N is the number of columns in the compound SELECT. +// ** +// ** ORDER BY terms that are already an integer between 1 and N are +// ** unmodified. ORDER BY terms that are integers outside the range of +// ** 1 through N generate an error. ORDER BY terms that are expressions +// ** are matched against result set expressions of compound SELECT +// ** beginning with the left-most SELECT and working toward the right. +// ** At the first match, the ORDER BY expression is transformed into +// ** the integer column number. +// ** +// ** Return the number of errors seen. +// */ +func _resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pDup, pE, pEList, pItem, pNew, pOrderBy, pParent uintptr + var i, moreToDo int32 + var _ /* iCol at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = db, i, moreToDo, pDup, pE, pEList, pItem, pNew, pOrderBy, pParent + moreToDo = int32(1) + pOrderBy = (*TSelect)(unsafe.Pointer(pSelect)).FpOrderBy + if pOrderBy == uintptr(0) { + return 0 + } + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7969, 0) + return int32(1) + } + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + libc.SetBitFieldPtr16Uint32(pOrderBy+8+uintptr(i)*32+16+4, libc.Uint32FromInt32(0), 2, 0x4) + goto _1 + _1: + ; + i = i + 1 + } + (*TSelect)(unsafe.Pointer(pSelect)).FpNext = uintptr(0) + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + (*TSelect)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpPrior)).FpNext = pSelect + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + for pSelect != 0 && moreToDo != 0 { + moreToDo = 0 + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + i = 0 + pItem = pOrderBy + 8 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + **(**int32)(__ccgo_up(bp)) = -int32(1) + if int32(uint32(*(*uint16)(unsafe.Pointer(pItem + 16 + 4))&0x4>>2)) != 0 { + goto _2 + } + pE = _sqlite3ExprSkipCollateAndLikely(tls, (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr) + if pE == uintptr(0) { + goto _2 + } + if _sqlite3ExprIsInteger(tls, pE, bp, uintptr(0)) != 0 { + if **(**int32)(__ccgo_up(bp)) <= 0 || **(**int32)(__ccgo_up(bp)) > (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + _resolveOutOfRangeError(tls, pParse, __ccgo_ts+8003, i+int32(1), (*TExprList)(unsafe.Pointer(pEList)).FnExpr, pE) + return int32(1) + } + } else { + **(**int32)(__ccgo_up(bp)) = _resolveAsName(tls, pParse, pEList, pE) + if **(**int32)(__ccgo_up(bp)) == 0 { + /* Now test if expression pE matches one of the values returned + ** by pSelect. In the usual case this is done by duplicating the + ** expression, resolving any symbols in it, and then comparing + ** it against each expression returned by the SELECT statement. + ** Once the comparisons are finished, the duplicate expression + ** is deleted. + ** + ** If this is running as part of an ALTER TABLE operation and + ** the symbols resolve successfully, also resolve the symbols in the + ** actual expression. This allows the code in alter.c to modify + ** column references within the ORDER BY expression as required. */ + pDup = _sqlite3ExprDup(tls, db, pE, 0) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + **(**int32)(__ccgo_up(bp)) = _resolveOrderByTermToExprList(tls, pParse, pSelect, pDup) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && **(**int32)(__ccgo_up(bp)) > 0 { + _resolveOrderByTermToExprList(tls, pParse, pSelect, pE) + } + } + _sqlite3ExprDelete(tls, db, pDup) + } + } + if **(**int32)(__ccgo_up(bp)) > 0 { + /* Convert the ORDER BY term into an integer column number iCol, + ** taking care to preserve the COLLATE clause if it exists. */ + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + pNew = _sqlite3ExprInt32(tls, db, **(**int32)(__ccgo_up(bp))) + if pNew == uintptr(0) { + return int32(1) + } + if (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr == pE { + (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr = pNew + } else { + pParent = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pParent)).FpLeft)).Fop) == int32(TK_COLLATE) { + pParent = (*TExpr)(unsafe.Pointer(pParent)).FpLeft + } + (*TExpr)(unsafe.Pointer(pParent)).FpLeft = pNew + } + _sqlite3ExprDelete(tls, db, pE) + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = libc.Uint16FromInt32(**(**int32)(__ccgo_up(bp))) + } + libc.SetBitFieldPtr16Uint32(pItem+16+4, libc.Uint32FromInt32(1), 2, 0x4) + } else { + moreToDo = int32(1) + } + goto _2 + _2: + ; + i = i + 1 + pItem += 32 + } + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpNext + } + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32 + 16 + 4))&0x4>>2)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8009, libc.VaList(bp+16, i+int32(1))) + return int32(1) + } + goto _3 + _3: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** This routine is callback for sqlite3WalkExpr(). +// ** +// ** Resolve symbolic names into TK_COLUMN operators for the current +// ** node in the expression tree. Return 0 to continue the search down +// ** the tree or 2 to abort the tree walk. +// ** +// ** This routine also does error checking and name resolution for +// ** function names. The operator for aggregate functions is changed +// ** to TK_AGG_FUNCTION. +// */ +func _resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var anRef [8]int32 + var auth, i, is_agg, n, nLeft, nRef, nRight, no_such_func, rc, savedAllowFlags, wrong_num_args, v5 int32 + var enc Tu8 + var p, pDef, pItem, pLeft, pList, pNC, pNC2, pParse, pRight, pRight1, pSel, pSrcList, pWin, zDb, zId, zTable, zType, v4 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = anRef, auth, enc, i, is_agg, n, nLeft, nRef, nRight, no_such_func, p, pDef, pItem, pLeft, pList, pNC, pNC2, pParse, pRight, pRight1, pSel, pSrcList, pWin, rc, savedAllowFlags, wrong_num_args, zDb, zId, zTable, zType, v4, v5 + pNC = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + /* The special operator TK_ROW means use the rowid for the first + ** column in the FROM clause. This is used by the LIMIT and ORDER BY + ** clause processing on UPDATE and DELETE statements, and by + ** UPDATE ... FROM statement processing. + */ + case int32(TK_ROW): + pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + pItem = pSrcList + 8 + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_COLUMN) + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = (*TExpr)(unsafe.Pointer(pExpr)).FiColumn - 1 + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_INTEGER) + break + /* An optimization: Attempt to convert + ** + ** "expr IS NOT NULL" --> "TRUE" + ** "expr IS NULL" --> "FALSE" + ** + ** if we can prove that "expr" is never NULL. Call this the + ** "NOT NULL strength reduction optimization". + ** + ** If this optimization occurs, also restore the NameContext ref-counts + ** to the state they where in before the "column" LHS expression was + ** resolved. This prevents "column" from being counted as having been + ** referenced, which might prevent a SELECT from being erroneously + ** marked as correlated. + ** + ** 2024-03-28: Beware of aggregates. A bare column of aggregated table + ** can still evaluate to NULL even though it is marked as NOT NULL. + ** Example: + ** + ** CREATE TABLE t1(a INT NOT NULL); + ** SELECT a, a IS NULL, a IS NOT NULL, count(*) FROM t1; + ** + ** The "a IS NULL" and "a IS NOT NULL" expressions cannot be optimized + ** here because at the time this case is hit, we do not yet know whether + ** or not t1 is being aggregated. We have to assume the worst and omit + ** the optimization. The only time it is safe to apply this optimization + ** is within the WHERE clause. + */ + fallthrough + case int32(TK_NOTNULL): + fallthrough + case int32(TK_ISNULL): + i = 0 + p = pNC + for { + if !(p != 0 && i < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) { + break + } + anRef[i] = (*TNameContext)(unsafe.Pointer(p)).FnRef + goto _1 + _1: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + _sqlite3WalkExpr(tls, pWalker, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return int32(WRC_Prune) + } + if _sqlite3ExprCanBeNull(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) != 0 { + /* The expression can be NULL. So the optimization does not apply */ + return int32(WRC_Prune) + } + i = 0 + p = pNC + for { + if !(p != 0) { + break + } + if (*TNameContext)(unsafe.Pointer(p)).FncFlags&int32(NC_Where) == 0 { + return int32(WRC_Prune) /* Not in a WHERE clause. Unsafe to optimize. */ + } + goto _2 + _2: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fu)) = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL)) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= uint32(EP_IntValue) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_INTEGER) + i = 0 + p = pNC + for { + if !(p != 0 && i < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) { + break + } + (*TNameContext)(unsafe.Pointer(p)).FnRef = anRef[i] + goto _3 + _3: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + return int32(WRC_Prune) + /* A column name: ID + ** Or table name and column name: ID.ID + ** Or a database, table and column: ID.ID.ID + ** + ** The TK_ID and TK_OUT cases are combined so that there will only + ** be one call to lookupName(). Then the compiler will in-line + ** lookupName() for a size reduction and performance increase. + */ + fallthrough + case int32(TK_ID): + fallthrough + case int32(TK_DOT): + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_ID) { + zDb = uintptr(0) + zTable = uintptr(0) + pRight = pExpr + } else { + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7544, uintptr(0), pExpr) + } + pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) == int32(TK_ID) { + zDb = uintptr(0) + } else { + zDb = *(*uintptr)(unsafe.Pointer(pLeft + 8)) + pLeft = (*TExpr)(unsafe.Pointer(pRight)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pRight)).FpRight + } + zTable = *(*uintptr)(unsafe.Pointer(pLeft + 8)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, pExpr, pRight) + _sqlite3RenameTokenRemap(tls, pParse, pExpr+64, pLeft) + } + } + return _lookupName(tls, pParse, zDb, zTable, pRight, pNC, pExpr) + /* Resolve function names + */ + fallthrough + case int32(TK_FUNCTION): /* Number of arguments */ + no_such_func = 0 /* True if no such function exists */ + wrong_num_args = 0 /* True if wrong number of arguments */ + is_agg = 0 /* Information about the function */ + enc = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc /* The database encoding */ + savedAllowFlags = (*TNameContext)(unsafe.Pointer(pNC)).FncFlags & (libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_AllowWin)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FeFrmType) != int32(TK_FILTER) { + v4 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + } else { + v4 = uintptr(0) + } + pWin = v4 + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if pList != 0 { + v5 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v5 = 0 + } + n = v5 + zId = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + pDef = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zId, n, enc, uint8(0)) + if pDef == uintptr(0) { + pDef = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zId, -int32(2), enc, uint8(0)) + if pDef == uintptr(0) { + no_such_func = int32(1) + } else { + wrong_num_args = int32(1) + } + } else { + is_agg = libc.BoolInt32((*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0)) + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_UNLIKELY) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Unlikely)) + if n == int32(2) { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = _exprProbability(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7561, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + } else { + /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is + ** equivalent to likelihood(X, 0.0625). + ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is + ** short-hand for likelihood(X,0.0625). + ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand + ** for likelihood(X,0.9375). + ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent + ** to likelihood(X,0.9375). */ + /* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */ + if int32(**(**int8)(__ccgo_up((*TFuncDef)(unsafe.Pointer(pDef)).FzName))) == int32('u') { + v5 = int32(8388608) + } else { + v5 = int32(125829120) + } + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = v5 + } + } + auth = _sqlite3AuthCheck(tls, pParse, int32(SQLITE_FUNCTION), uintptr(0), (*TFuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0)) + if auth != SQLITE_OK { + if auth == int32(SQLITE_DENY) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7625, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + return int32(WRC_Prune) + } + /* If the function may call sqlite3_value_subtype(), then set the + ** EP_SubtArg flag on all of its argument expressions. This prevents + ** where.c from replacing the expression with a value read from an + ** index on the same expression, which will not have the correct + ** subtype. Also set the flag if the function expression itself is + ** an EP_SubtArg expression. In this case subtypes are required as + ** the function may return a value with a subtype back to its + ** caller using sqlite3_result_value(). */ + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_SUBTYPE) != 0 || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromUint32(EP_SubtArg) != uint32(0) { + _resolveSetExprSubtypeArg(tls, pList) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)|libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG)) != 0 { + /* For the purposes of the EP_ConstFunc flag, date and time + ** functions and other functions that change slowly are considered + ** constant because they are constant for the duration of one query. + ** This allows them to be factored out of inner loops. */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_ConstFunc)) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_CONSTANT) == uint32(0) { + /* Clearly non-deterministic functions like random(), but also + ** date/time functions that use 'now', and other functions like + ** sqlite_version() that might change over time cannot be used + ** in an index or generated column. Curiously, they can be used + ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all + ** allow this. */ + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7661, uintptr(0), pExpr) + } + } else { + /* Must fit in 8 bits */ + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = libc.Uint8FromInt32((*TNameContext)(unsafe.Pointer(pNC)).FncFlags & int32(NC_SelfRef)) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INTERNAL) != uint32(0) && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_InternalFunc) == uint32(0) { + /* Internal-use-only functions are disallowed unless the + ** SQL is being compiled using sqlite3NestedParse() or + ** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be + ** used to activate internal functions for testing purposes */ + no_such_func = int32(1) + pDef = uintptr(0) + } else { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_DIRECT)|libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) != uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_FromDDL) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) + } + _sqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) + } + } + } + if 0 == libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME)) { + if pDef != 0 && (*TFuncDef)(unsafe.Pointer(pDef)).FxValue == uintptr(0) && pWin != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7689, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowAgg) == 0 || is_agg != 0 && (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 && !(pWin != 0) || is_agg != 0 && pWin != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowWin) == 0 { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 || pWin != 0 { + zType = __ccgo_ts + 7732 + } else { + zType = __ccgo_ts + 7739 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7749, libc.VaList(bp+8, zType, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + is_agg = 0 + } else { + if no_such_func != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7777, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if wrong_num_args != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7799, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg == 0 && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7843, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg == 0 && (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3ExprOrderByAggregateError(tls, pParse, pExpr) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + } + } + } + } + } + if is_agg != 0 { + /* Window functions may not be arguments of aggregate functions. + ** Or arguments of other window functions. But aggregate functions + ** may be arguments for window functions. */ + if !(pWin != 0) { + v5 = int32(NC_AllowAgg) + } else { + v5 = 0 + } + **(**int32)(__ccgo_up(pNC + 40)) &= ^(libc.Int32FromInt32(NC_AllowWin) | v5) + } + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) || (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + is_agg = int32(1) + } + } + _sqlite3WalkExprList(tls, pWalker, pList) + if is_agg != 0 { + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32))) + } + if pWin != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + pSel = (*TNameContext)(unsafe.Pointer(pNC)).FpWinSelect + if libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME)) == 0 { + if pSel != 0 { + v4 = (*TSelect)(unsafe.Pointer(pSel)).FpWinDefn + } else { + v4 = uintptr(0) + } + _sqlite3WindowUpdate(tls, pParse, v4, pWin, pDef) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + break + } + } + _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) + _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) + _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpFilter) + _sqlite3WindowLink(tls, pSel, pWin) + **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_HasWin) + } else { + /* For looping up thru outer contexts */ + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_AGG_FUNCTION) + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = uint8(0) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpFilter) + } + pNC2 = pNC + for pNC2 != 0 && _sqlite3ReferencesSrcList(tls, pParse, pExpr, (*TNameContext)(unsafe.Pointer(pNC2)).FpSrcList) == 0 { + v4 = pExpr + 2 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(uint32(*(*Tu8)(unsafe.Pointer(v4))) + (libc.Uint32FromInt32(1) + (*TNameContext)(unsafe.Pointer(pNC2)).FnNestedSelect)) + pNC2 = (*TNameContext)(unsafe.Pointer(pNC2)).FpNext + } + if pNC2 != 0 && pDef != 0 { + v4 = pExpr + 2 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(uint32(*(*Tu8)(unsafe.Pointer(v4))) + (*TNameContext)(unsafe.Pointer(pNC2)).FnNestedSelect) + v4 = pNC2 + 40 + *(*int32)(unsafe.Pointer(v4)) = int32(uint32(*(*int32)(unsafe.Pointer(v4))) | (libc.Uint32FromInt32(NC_HasAgg) | ((*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags^libc.Uint32FromInt32(SQLITE_FUNC_ANYORDER))&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_MINMAX)|libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)))) + } + } + **(**int32)(__ccgo_up(pNC + 40)) |= savedAllowFlags + } + /* FIX ME: Compute pExpr->affinity based on the expected return + ** type of the function + */ + return int32(WRC_Prune) + case int32(TK_EXISTS): + fallthrough + case int32(TK_SELECT): + fallthrough + case int32(TK_IN): + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + nRef = (*TNameContext)(unsafe.Pointer(pNC)).FnRef + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_EXISTS) { + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 4, 0x10) + } + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_SelfRef) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7891, pExpr, pExpr) + } else { + _sqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } + if nRef != (*TNameContext)(unsafe.Pointer(pNC)).FnRef { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 4)) |= uint32(SF_Correlated) + } + **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_Subquery) + } + case int32(TK_VARIABLE): + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IsCheck)|libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7902, pExpr, pExpr) + } + case int32(TK_IS): + fallthrough + case int32(TK_ISNOT): + pRight1 = _sqlite3ExprSkipCollateAndLikely(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", + ** and "x IS NOT FALSE". */ + if pRight1 != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_ID) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_TRUEFALSE)) { + rc = _resolveExprStep(tls, pWalker, pRight1) + if rc == int32(WRC_Abort) { + return int32(WRC_Abort) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_TRUEFALSE) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_TRUTH) + return WRC_Continue + } + } + fallthrough + case int32(TK_BETWEEN): + fallthrough + case int32(TK_EQ): + fallthrough + case int32(TK_NE): + fallthrough + case int32(TK_LT): + fallthrough + case int32(TK_LE): + fallthrough + case int32(TK_GT): + fallthrough + case int32(TK_GE): + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + break + } + nLeft = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_BETWEEN) { + nRight = _sqlite3ExprVectorSize(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr) + if nRight == nLeft { + nRight = _sqlite3ExprVectorSize(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr) + } + } else { + nRight = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + } + if nLeft != nRight { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7252, 0) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + } + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v5 = int32(WRC_Abort) + } else { + v5 = WRC_Continue + } + return v5 +} + +// C documentation +// +// /* +// ** This function checks if argument pFrom refers to a CTE declared by +// ** a WITH clause on the stack currently maintained by the parser (on the +// ** pParse->pWith linked list). And if currently processing a CTE +// ** CTE expression, through routine checks to see if the reference is +// ** a recursive reference to the CTE. +// ** +// ** If pFrom matches a CTE according to either of these two above, pFrom->pSTab +// ** and other fields are populated accordingly. +// ** +// ** Return 0 if no match is found. +// ** Return 1 if a match is found. +// ** Return 2 if an error condition is detected. +// */ +func _resolveFromTermToCte(tls *libc.TLS, pParse uintptr, pWalker uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bMayRecursive, i, iRecTab, rc, v3 int32 + var db, pCte, pCteUse, pEList, pItem, pLeft, pRecTerm, pSavedWith, pSel, pSrc, pTab, v1 uintptr + var _ /* pWith at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bMayRecursive, db, i, iRecTab, pCte, pCteUse, pEList, pItem, pLeft, pRecTerm, pSavedWith, pSel, pSrc, pTab, rc, v1, v3 /* The matching WITH */ + if (*TParse)(unsafe.Pointer(pParse)).FpWith == uintptr(0) { + /* There are no WITH clauses in the stack. No match is possible */ + return 0 + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + /* Prior errors might have left pParse->pWith in a goofy state, so + ** go no further. */ + return 0 + } + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x10000>>16) == 0 && *(*uintptr)(unsafe.Pointer(pFrom + 72)) != uintptr(0) { + /* The FROM term contains a schema qualifier (ex: main.t1) and so + ** it cannot possibly be a CTE reference. */ + return 0 + } + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x400>>10) != 0 { + /* The FROM term is specifically excluded from matching a CTE. + ** (1) It is part of a trigger that used to have zDatabase but had + ** zDatabase removed by sqlite3FixTriggerStep(). + ** (2) This is the first term in the FROM clause of an UPDATE. + */ + return 0 + } + pCte = _searchWith(tls, (*TParse)(unsafe.Pointer(pParse)).FpWith, pFrom, bp) + if pCte != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Initial value of pParse->pWith */ + iRecTab = -int32(1) + /* If pCte->zCteErr is non-NULL at this point, then this is an illegal + ** recursive reference to CTE pCte. Leave an error in pParse and return + ** early. If pCte->zCteErr is NULL, then this is not a recursive reference. + ** In this case, proceed. */ + if (*TCte)(unsafe.Pointer(pCte)).FzCteErr != 0 { + _sqlite3ErrorMsg(tls, pParse, (*TCte)(unsafe.Pointer(pCte)).FzCteErr, libc.VaList(bp+16, (*TCte)(unsafe.Pointer(pCte)).FzName)) + return int32(2) + } + if _cannotBeFunction(tls, pParse, pFrom) != 0 { + return int32(2) + } + pTab = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTab == uintptr(0) { + return int32(2) + } + pCteUse = (*TCte)(unsafe.Pointer(pCte)).FpUse + if pCteUse == uintptr(0) { + v1 = _sqlite3DbMallocZero(tls, db, uint64(20)) + pCteUse = v1 + (*TCte)(unsafe.Pointer(pCte)).FpUse = v1 + if pCteUse == uintptr(0) || _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3DbFree), pCteUse) == uintptr(0) { + _sqlite3DbFree(tls, db, pTab) + return int32(2) + } + (*TCteUse)(unsafe.Pointer(pCteUse)).FeM10d = (*TCte)(unsafe.Pointer(pCte)).FeM10d + } + (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab = pTab + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pTab)).FzName = _sqlite3DbStrDup(tls, db, (*TCte)(unsafe.Pointer(pCte)).FzName) + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(-int32(1)) + (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TF_Ephemeral) | libc.Int32FromInt32(TF_NoVisibleRowid)) + _sqlite3SrcItemAttachSubquery(tls, pParse, pFrom, (*TCte)(unsafe.Pointer(pCte)).FpSelect, int32(1)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(2) + } + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + **(**Tu32)(__ccgo_up(pSel + 4)) |= uint32(SF_CopyCte) + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x2>>1) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21406, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(pFrom + 48)))) + return int32(2) + } + libc.SetBitFieldPtr32Uint32(pFrom+24+4, libc.Uint32FromInt32(1), 9, 0x200) + *(*uintptr)(unsafe.Pointer(pFrom + 56)) = pCteUse + (*TCteUse)(unsafe.Pointer(pCteUse)).FnUse = (*TCteUse)(unsafe.Pointer(pCteUse)).FnUse + 1 + /* Check if this is a recursive CTE. */ + pRecTerm = pSel + bMayRecursive = libc.BoolInt32(libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSel)).Fop) == int32(TK_ALL) || libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSel)).Fop) == int32(TK_UNION)) + for bMayRecursive != 0 && libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pRecTerm)).Fop) == libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSel)).Fop) { + pSrc = (*TSelect)(unsafe.Pointer(pRecTerm)).FpSrc + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + pItem = pSrc + 8 + uintptr(i)*80 + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != uintptr(0) && !(int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x20000>>17) != 0) && !(int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0) && (int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) != 0 || *(*uintptr)(unsafe.Pointer(pItem + 72)) == uintptr(0)) && 0 == _sqlite3StrICmp(tls, (*TSrcItem)(unsafe.Pointer(pItem)).FzName, (*TCte)(unsafe.Pointer(pCte)).FzName) { + (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab = pTab + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 7, 0x80) + if (*TSelect)(unsafe.Pointer(pRecTerm)).FselFlags&uint32(SF_Recursive) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21426, libc.VaList(bp+16, (*TCte)(unsafe.Pointer(pCte)).FzName)) + return int32(2) + } + **(**Tu32)(__ccgo_up(pRecTerm + 4)) |= uint32(SF_Recursive) + if iRecTab < 0 { + v1 = pParse + 56 + v3 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + iRecTab = v3 + } + (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor = iRecTab + } + goto _2 + _2: + ; + i = i + 1 + } + if (*TSelect)(unsafe.Pointer(pRecTerm)).FselFlags&uint32(SF_Recursive) == uint32(0) { + break + } + pRecTerm = (*TSelect)(unsafe.Pointer(pRecTerm)).FpPrior + } + (*TCte)(unsafe.Pointer(pCte)).FzCteErr = __ccgo_ts + 21469 + pSavedWith = (*TParse)(unsafe.Pointer(pParse)).FpWith + (*TParse)(unsafe.Pointer(pParse)).FpWith = **(**uintptr)(__ccgo_up(bp)) + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_Recursive) != 0 { + (*TSelect)(unsafe.Pointer(pRecTerm)).FpWith = (*TSelect)(unsafe.Pointer(pSel)).FpWith + rc = _sqlite3WalkSelect(tls, pWalker, pRecTerm) + (*TSelect)(unsafe.Pointer(pRecTerm)).FpWith = uintptr(0) + if rc != 0 { + (*TParse)(unsafe.Pointer(pParse)).FpWith = pSavedWith + return int32(2) + } + } else { + if _sqlite3WalkSelect(tls, pWalker, pSel) != 0 { + (*TParse)(unsafe.Pointer(pParse)).FpWith = pSavedWith + return int32(2) + } + } + (*TParse)(unsafe.Pointer(pParse)).FpWith = **(**uintptr)(__ccgo_up(bp)) + pLeft = pSel + for { + if !((*TSelect)(unsafe.Pointer(pLeft)).FpPrior != 0) { + break + } + goto _5 + _5: + ; + pLeft = (*TSelect)(unsafe.Pointer(pLeft)).FpPrior + } + pEList = (*TSelect)(unsafe.Pointer(pLeft)).FpEList + if (*TCte)(unsafe.Pointer(pCte)).FpCols != 0 { + if pEList != 0 && (*TExprList)(unsafe.Pointer(pEList)).FnExpr != (*TExprList)(unsafe.Pointer((*TCte)(unsafe.Pointer(pCte)).FpCols)).FnExpr { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21492, libc.VaList(bp+16, (*TCte)(unsafe.Pointer(pCte)).FzName, (*TExprList)(unsafe.Pointer(pEList)).FnExpr, (*TExprList)(unsafe.Pointer((*TCte)(unsafe.Pointer(pCte)).FpCols)).FnExpr)) + (*TParse)(unsafe.Pointer(pParse)).FpWith = pSavedWith + return int32(2) + } + pEList = (*TCte)(unsafe.Pointer(pCte)).FpCols + } + _sqlite3ColumnsFromExprList(tls, pParse, pEList, pTab+54, pTab+8) + if bMayRecursive != 0 { + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_Recursive) != 0 { + (*TCte)(unsafe.Pointer(pCte)).FzCteErr = __ccgo_ts + 21530 + } else { + (*TCte)(unsafe.Pointer(pCte)).FzCteErr = __ccgo_ts + 21564 + } + _sqlite3WalkSelect(tls, pWalker, pSel) + } + (*TCte)(unsafe.Pointer(pCte)).FzCteErr = uintptr(0) + (*TParse)(unsafe.Pointer(pParse)).FpWith = pSavedWith + return int32(1) /* Success */ + } + return 0 /* No match */ +} + +// C documentation +// +// /* +// ** pE is a pointer to an expression which is a single term in the +// ** ORDER BY of a compound SELECT. The expression has not been +// ** name resolved. +// ** +// ** At the point this routine is called, we already know that the +// ** ORDER BY term is not an integer index into the result set. That +// ** case is handled by the calling routine. +// ** +// ** Attempt to match pE against result set columns in the left-most +// ** SELECT statement. Return the index i of the matching column, +// ** as an indication to the caller that it should sort by the i-th column. +// ** The left-most column is 1. In other words, the value returned is the +// ** same integer value that would be used in the SQL statement to indicate +// ** the column. +// ** +// ** If there is no match, return 0. Return -1 if an error occurs. +// */ +func _resolveOrderByTermToExprList(tls *libc.TLS, pParse uintptr, pSelect uintptr, pE uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pEList uintptr + var i, rc int32 + var savedSuppErr Tu8 + var _ /* nc at bp+0 */ TNameContext + _, _, _, _, _ = db, i, pEList, rc, savedSuppErr /* Saved value of db->suppressErr */ + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + /* Resolve all names in the ORDER BY term expression + */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + *(*uintptr)(unsafe.Pointer(bp + 16)) = pEList + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_UEList) | libc.Int32FromInt32(NC_NoSelect) + (**(**TNameContext)(__ccgo_up(bp))).FnNcErr = 0 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + savedSuppErr = (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr + (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr = uint8(1) + rc = _sqlite3ResolveExprNames(tls, bp, pE) + (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr = savedSuppErr + if rc != 0 { + return 0 + } + /* Try to match the ORDER BY expression against an expression + ** in the result set. Return an 1-based index of the matching + ** result-set entry. + */ + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr, pE, -int32(1)) < int32(2) { + return i + int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + /* If no match, return 0. */ + return 0 +} + +// C documentation +// +// /* +// ** Generate an ORDER BY or GROUP BY term out-of-range error. +// */ +func _resolveOutOfRangeError(tls *libc.TLS, pParse uintptr, zType uintptr, i int32, mx int32, pError uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7913, libc.VaList(bp+8, i, zType, mx)) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pError) +} + +// C documentation +// +// /* +// ** Resolve names in the SELECT statement p and all of its descendants. +// */ +func _resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pGroupBy, pItem, pItem1, pItem2, pLeftmost, pOuterNC, pParse, pSub, pSub1, pWin, zSavedContext uintptr + var i, isCompound, nCompound, nRef, v1 int32 + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, isCompound, nCompound, nRef, pGroupBy, pItem, pItem1, pItem2, pLeftmost, pOuterNC, pParse, pSub, pSub1, pWin, zSavedContext, v1 /* Database connection */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Resolved) != 0 { + return int32(WRC_Prune) + } + pOuterNC = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Normally sqlite3SelectExpand() will be called first and will have + ** already expanded this SELECT. However, if this is a subquery within + ** an expression, sqlite3ResolveExprNames() will be called without a + ** prior call to sqlite3SelectExpand(). When that happens, let + ** sqlite3SelectPrep() do all of the processing for this SELECT. + ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and + ** this routine in the correct order. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Expanded) == uint32(0) { + _sqlite3SelectPrep(tls, pParse, p, pOuterNC) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v1 = int32(WRC_Abort) + } else { + v1 = int32(WRC_Prune) + } + return v1 + } + isCompound = libc.BoolInt32((*TSelect)(unsafe.Pointer(p)).FpPrior != uintptr(0)) + nCompound = 0 + pLeftmost = p + for p != 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_Resolved) + /* Resolve the expressions in the LIMIT and OFFSET clauses. These + ** are not allowed to refer to any names, so pass an empty NameContext. + */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpWinSelect = p + if _sqlite3ResolveExprNames(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpLimit) != 0 { + return int32(WRC_Abort) + } + /* If the SF_Converted flags is set, then this Select object was + ** was created by the convertCompoundSelectToSubquery() function. + ** In this case the ORDER BY clause (p->pOrderBy) should be resolved + ** as if it were part of the sub-query, not the parent. This block + ** moves the pOrderBy down to the sub-query. It will be moved back + ** after the names have been resolved. */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Converted) != 0 { + pSub = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + 72)))).FpSelect + (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + } + /* Recursively resolve names in all subqueries in the FROM clause + */ + if pOuterNC != 0 { + (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect = (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect + 1 + } + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc) { + break + } + pItem = (*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + uintptr(i)*80 + /* Test of tag-20240424-1*/ + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 && (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect)).FselFlags&uint32(SF_Resolved) == uint32(0) { + if pOuterNC != 0 { + v1 = (*TNameContext)(unsafe.Pointer(pOuterNC)).FnRef + } else { + v1 = 0 + } + nRef = v1 + zSavedContext = (*TParse)(unsafe.Pointer(pParse)).FzAuthContext + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = (*TSrcItem)(unsafe.Pointer(pItem)).FzName + } + _sqlite3ResolveSelectNames(tls, pParse, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect, pOuterNC) + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedContext + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + /* If the number of references to the outer context changed when + ** expressions in the sub-select were resolved, the sub-select + ** is correlated. It is not required to check the refcount on any + ** but the innermost outer context object, as lookupName() increments + ** the refcount on all contexts between the current one and the + ** context containing the column when it resolves a name. */ + if pOuterNC != 0 { + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.BoolUint32((*TNameContext)(unsafe.Pointer(pOuterNC)).FnRef > nRef), 4, 0x10) + } + } + goto _2 + _2: + ; + i = i + 1 + } + if pOuterNC != 0 && (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect > uint32(0) { + (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect = (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect - 1 + } + /* Set up the local name-context to pass to sqlite3ResolveExprNames() to + ** resolve the result-set expression list. + */ + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_AllowWin) + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = (*TSelect)(unsafe.Pointer(p)).FpSrc + (**(**TNameContext)(__ccgo_up(bp))).FpNext = pOuterNC + /* Resolve names in the result set. */ + if _sqlite3ResolveExprListNames(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpEList) != 0 { + return int32(WRC_Abort) + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags &= ^libc.Int32FromInt32(NC_AllowWin) + /* If there are no aggregate functions in the result-set, and no GROUP BY + ** expression, do not allow aggregates in any of the other expressions. + */ + pGroupBy = (*TSelect)(unsafe.Pointer(p)).FpGroupBy + if pGroupBy != 0 || (**(**TNameContext)(__ccgo_up(bp))).FncFlags&int32(NC_HasAgg) != 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= libc.Uint32FromInt32(int32(SF_Aggregate) | (**(**TNameContext)(__ccgo_up(bp))).FncFlags&(libc.Int32FromInt32(NC_MinMaxAgg)|libc.Int32FromInt32(NC_OrderAgg))) + } else { + (**(**TNameContext)(__ccgo_up(bp))).FncFlags &= ^libc.Int32FromInt32(NC_AllowAgg) + } + /* Add the output column list to the name-context before parsing the + ** other expressions in the SELECT statement. This is so that + ** expressions in the WHERE clause (etc.) can refer to expressions by + ** aliases in the result set. + ** + ** Minor point: If this is the case, then the expression will be + ** re-evaluated for each reference to it. + */ + *(*uintptr)(unsafe.Pointer(bp + 16)) = (*TSelect)(unsafe.Pointer(p)).FpEList + (**(**TNameContext)(__ccgo_up(bp))).FncFlags |= int32(NC_UEList) + if (*TSelect)(unsafe.Pointer(p)).FpHaving != 0 { + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Aggregate) == uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8101, 0) + return int32(WRC_Abort) + } + if _sqlite3ResolveExprNames(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpHaving) != 0 { + return int32(WRC_Abort) + } + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags |= int32(NC_Where) + if _sqlite3ResolveExprNames(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpWhere) != 0 { + return int32(WRC_Abort) + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags &= ^libc.Int32FromInt32(NC_Where) + /* Resolve names in table-valued-function arguments */ + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc) { + break + } + pItem1 = (*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + uintptr(i)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x8>>3) != 0 && _sqlite3ResolveExprListNames(tls, bp, *(*uintptr)(unsafe.Pointer(pItem1 + 48))) != 0 { + return int32(WRC_Abort) + } + goto _4 + _4: + ; + i = i + 1 + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + pWin = (*TSelect)(unsafe.Pointer(p)).FpWinDefn + for { + if !(pWin != 0) { + break + } + if _sqlite3ResolveExprListNames(tls, bp, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) != 0 || _sqlite3ResolveExprListNames(tls, bp, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) != 0 { + return int32(WRC_Abort) + } + goto _5 + _5: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags |= libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_AllowWin) + /* If this is a converted compound query, move the ORDER BY clause from + ** the sub-query back to the parent query. At this point each term + ** within the ORDER BY clause has been transformed to an integer value. + ** These integers will be replaced by copies of the corresponding result + ** set expressions by the call to resolveOrderGroupBy() below. */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Converted) != 0 { + pSub1 = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + 72)))).FpSelect + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = (*TSelect)(unsafe.Pointer(pSub1)).FpOrderBy + (*TSelect)(unsafe.Pointer(pSub1)).FpOrderBy = uintptr(0) + } + /* Process the ORDER BY clause for singleton SELECT statements. + ** The ORDER BY clause for compounds SELECT statements is handled + ** below, after all of the result-sets for all of the elements of + ** the compound have been resolved. + ** + ** If there is an ORDER BY clause on a term of a compound-select other + ** than the right-most term, then that is a syntax error. But the error + ** is not detected until much later, and so we need to go ahead and + ** resolve those symbols on the incorrect ORDER BY for consistency. + */ + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != uintptr(0) && isCompound <= nCompound && _resolveOrderGroupBy(tls, bp, p, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, __ccgo_ts+8003) != 0 { + return int32(WRC_Abort) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags &= ^libc.Int32FromInt32(NC_AllowWin) + /* Resolve the GROUP BY clause. At the same time, make sure + ** the GROUP BY clause does not contain aggregate functions. + */ + if pGroupBy != 0 { + if _resolveOrderGroupBy(tls, bp, p, pGroupBy, __ccgo_ts+8140) != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + i = 0 + pItem2 = pGroupBy + 8 + for { + if !(i < (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { + break + } + if (*TExpr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pItem2)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Agg)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8146, 0) + return int32(WRC_Abort) + } + goto _6 + _6: + ; + i = i + 1 + pItem2 += 32 + } + } + /* If this is part of a compound SELECT, check that it has the right + ** number of expressions in the select list. */ + if (*TSelect)(unsafe.Pointer(p)).FpNext != 0 && (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr != (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpNext)).FpEList)).FnExpr { + _sqlite3SelectWrongNumTermsError(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpNext) + return int32(WRC_Abort) + } + /* If the SELECT statement contains ON clauses that were moved into + ** the WHERE clause, go through and verify that none of the terms + ** in the ON clauses reference tables to the right of the ON clause. */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_OnToWhere) != 0 { + _sqlite3SelectCheckOnClauses(tls, pParse, p) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + } + /* Advance to the next term of the compound + */ + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + nCompound = nCompound + 1 + } + /* Resolve the ORDER BY on a compound SELECT after all terms of + ** the compound have been resolved. + */ + if isCompound != 0 && _resolveCompoundOrderBy(tls, pParse, pLeftmost) != 0 { + return int32(WRC_Abort) + } + return int32(WRC_Prune) +} + +// C documentation +// +// /* +// ** Retry flock() calls that fail with EINTR +// */ +func _robust_flock(tls *libc.TLS, fd int32, op int32) (r int32) { + var rc int32 + _ = rc + for cond := true; cond; cond = rc < 0 && **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(EINTR) { + rc = libc.Xflock(tls, fd, op) + } + return rc +} + +// C documentation +// +// /* +// ** Invoke open(). Do so multiple times, until it either succeeds or +// ** fails for some reason other than EINTR. +// ** +// ** If the file creation mode "m" is 0 then set it to the default for +// ** SQLite. The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally +// ** 0644) as modified by the system umask. If m is not 0, then +// ** make the file creation mode be exactly m ignoring the umask. +// ** +// ** The m parameter will be non-zero only when creating -wal, -journal, +// ** and -shm files. We want those files to have *exactly* the same +// ** permissions as their original database, unadulterated by the umask. +// ** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a +// ** transaction crashes and leaves behind hot journals, then any +// ** process that is able to write to the database will also be able to +// ** recover the hot journals. +// */ +func _robust_open(tls *libc.TLS, z uintptr, f int32, m Tmode_t) (r int32) { + bp := tls.Alloc(176) + defer tls.Free(176) + var fd, v1 int32 + var m2 Tmode_t + var _ /* statbuf at bp+0 */ Tstat + _, _, _ = fd, m2, v1 + if m != 0 { + v1 = libc.Int32FromUint16(m) + } else { + v1 = int32(SQLITE_DEFAULT_FILE_PERMISSIONS) + } + m2 = libc.Uint16FromInt32(v1) + for int32(1) != 0 { + fd = (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[0].FpCurrent})))(tls, z, f|int32(O_CLOEXEC), libc.Int32FromUint16(m2)) + if fd < 0 { + if **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(EINTR) { + continue + } + break + } + if fd >= int32(SQLITE_MINIMUM_FILE_DESCRIPTOR) { + break + } + if f&(libc.Int32FromInt32(O_EXCL)|libc.Int32FromInt32(O_CREAT)) == libc.Int32FromInt32(O_EXCL)|libc.Int32FromInt32(O_CREAT) { + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(16)].FpCurrent})))(tls, z) + } + (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(1)].FpCurrent})))(tls, fd) + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3750, libc.VaList(bp+152, z, fd)) + fd = -int32(1) + if (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[0].FpCurrent})))(tls, __ccgo_ts+3793, O_RDONLY, libc.Int32FromUint16(m)) < 0 { + break + } + } + if fd >= 0 { + if libc.Int32FromUint16(m) != 0 { + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, fd, bp) == 0 && (**(**Tstat)(__ccgo_up(bp))).Fst_size == 0 && libc.Int32FromUint16((**(**Tstat)(__ccgo_up(bp))).Fst_mode)&int32(0777) != libc.Int32FromUint16(m) { + (*(*func(*libc.TLS, int32, Tmode_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(14)].FpCurrent})))(tls, fd, m) + } + } + } + return fd +} + +// C documentation +// +// /* +// ** Implementation of the round() function +// */ +func _roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var n Ti64 + var zBuf uintptr + var v1 float64 + var _ /* r at bp+0 */ float64 + _, _, _ = n, zBuf, v1 + n = 0 + if argc == int32(2) { + if int32(SQLITE_NULL) == Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) { + return + } + n = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if n > int64(30) { + n = int64(30) + } + if n < 0 { + n = 0 + } + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + return + } + **(**float64)(__ccgo_up(bp)) = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv))) + /* If Y==0 and X will fit in a 64-bit int, + ** handle the rounding directly, + ** otherwise use printf. + */ + if **(**float64)(__ccgo_up(bp)) < -libc.Float64FromFloat64(4.503599627370496e+15) || **(**float64)(__ccgo_up(bp)) > +libc.Float64FromFloat64(4.503599627370496e+15) { + /* The value has no fractional part so there is nothing to round */ + } else { + if n == 0 { + if **(**float64)(__ccgo_up(bp)) < libc.Float64FromInt32(0) { + v1 = -libc.Float64FromFloat64(0.5) + } else { + v1 = +libc.Float64FromFloat64(0.5) + } + **(**float64)(__ccgo_up(bp)) = float64(int64(**(**float64)(__ccgo_up(bp)) + v1)) + } else { + zBuf = Xsqlite3_mprintf(tls, __ccgo_ts+16819, libc.VaList(bp+16, int32(n), **(**float64)(__ccgo_up(bp)))) + if zBuf == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + _sqlite3AtoF(tls, zBuf, bp) + Xsqlite3_free(tls, zBuf) + } + } + Xsqlite3_result_double(tls, context, **(**float64)(__ccgo_up(bp))) +} + +// C documentation +// +// /* +// ** Sort all elements on the list of RowSetEntry objects into order of +// ** increasing v. +// */ +func _rowSetEntrySort(tls *libc.TLS, pIn uintptr) (r uintptr) { + bp := tls.Alloc(320) + defer tls.Free(320) + var i uint32 + var pNext, v3 uintptr + var _ /* aBucket at bp+0 */ [40]uintptr + _, _, _ = i, pNext, v3 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(320), ^t__predefined_size_t(0)) + for pIn != 0 { + pNext = (*TRowSetEntry)(unsafe.Pointer(pIn)).FpRight + (*TRowSetEntry)(unsafe.Pointer(pIn)).FpRight = uintptr(0) + i = uint32(0) + for { + if !((**(**[40]uintptr)(__ccgo_up(bp)))[i] != 0) { + break + } + pIn = _rowSetEntryMerge(tls, (**(**[40]uintptr)(__ccgo_up(bp)))[i], pIn) + (**(**[40]uintptr)(__ccgo_up(bp)))[i] = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + (**(**[40]uintptr)(__ccgo_up(bp)))[i] = pIn + pIn = pNext + } + pIn = (**(**[40]uintptr)(__ccgo_up(bp)))[0] + i = uint32(1) + for { + if !(uint64(i) < libc.Uint64FromInt64(320)/libc.Uint64FromInt64(8)) { + break + } + if (**(**[40]uintptr)(__ccgo_up(bp)))[i] == uintptr(0) { + goto _2 + } + if pIn != 0 { + v3 = _rowSetEntryMerge(tls, pIn, (**(**[40]uintptr)(__ccgo_up(bp)))[i]) + } else { + v3 = (**(**[40]uintptr)(__ccgo_up(bp)))[i] + } + pIn = v3 + goto _2 + _2: + ; + i = i + 1 + } + return pIn +} + +// C documentation +// +// /* +// ** Rtree virtual table module xBestIndex method. There are three +// ** table scan strategies to choose from (in order from most to +// ** least desirable): +// ** +// ** idxNum idxStr Strategy +// ** ------------------------------------------------ +// ** 1 Unused Direct lookup by rowid. +// ** 2 See below R-tree query or full-table scan. +// ** ------------------------------------------------ +// ** +// ** If strategy 1 is used, then idxStr is not meaningful. If strategy +// ** 2 is used, idxStr is formatted to contain 2 bytes for each +// ** constraint used. The first two bytes of idxStr correspond to +// ** the constraint in sqlite3_index_info.aConstraintUsage[] with +// ** (argvIndex==1) etc. +// ** +// ** The first of each pair of bytes in idxStr identifies the constraint +// ** operator as follows: +// ** +// ** Operator Byte Value +// ** ---------------------- +// ** = 0x41 ('A') +// ** <= 0x42 ('B') +// ** < 0x43 ('C') +// ** >= 0x44 ('D') +// ** > 0x45 ('E') +// ** MATCH 0x46 ('F') +// ** ---------------------- +// ** +// ** The second of each pair of bytes identifies the coordinate column +// ** to which the constraint applies. The leftmost coordinate column +// ** is 'a', the second from the left 'b' etc. +// */ +func _rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bMatch, iIdx, ii, jj, rc, v4 int32 + var doOmit, op Tu8 + var nRow Ti64 + var p, pRtree uintptr + var _ /* zIdxStr at bp+0 */ [41]int8 + _, _, _, _, _, _, _, _, _, _, _ = bMatch, doOmit, iIdx, ii, jj, nRow, op, p, pRtree, rc, v4 + pRtree = tab + rc = SQLITE_OK + bMatch = 0 /* Estimated rows returned by this scan */ + iIdx = 0 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(41), ^t__predefined_size_t(0)) + /* Check if there exists a MATCH constraint - even an unusable one. If there + ** is, do not consider the lookup-by-rowid plan as using such a plan would + ** require the VDBE to evaluate the MATCH constraint, which is not currently + ** possible. */ + ii = 0 + for { + if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + if libc.Int32FromUint8((**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12))).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH) { + bMatch = int32(1) + } + goto _1 + _1: + ; + ii = ii + 1 + } + ii = 0 + for { + if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint && iIdx < libc.Int32FromUint64(libc.Uint64FromInt64(41)-libc.Uint64FromInt32(1))) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12 + if bMatch == 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) { + jj = 0 + for { + if !(jj < ii) { + break + } + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).FargvIndex = 0 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).Fomit = uint8(0) + goto _3 + _3: + ; + jj = jj + 1 + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).Fomit = uint8(1) + /* This strategy involves a two rowid lookups on an B-Tree structures + ** and then a linear search of an R-Tree node. This should be + ** considered almost as quick as a direct rowid lookup (for which + ** sqlite uses an internal cost of 0.0). It is expected to return + ** a single row. + */ + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(30) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = int32(SQLITE_INDEX_SCAN_UNIQUE) + return SQLITE_OK + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 && ((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn > 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH)) { + doOmit = uint8(1) + switch libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) { + case int32(SQLITE_INDEX_CONSTRAINT_EQ): + op = uint8(RTREE_EQ) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_GT): + op = uint8(RTREE_GT) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_LE): + op = uint8(RTREE_LE) + case int32(SQLITE_INDEX_CONSTRAINT_LT): + op = uint8(RTREE_LT) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_GE): + op = uint8(RTREE_GE) + case int32(SQLITE_INDEX_CONSTRAINT_MATCH): + op = uint8(RTREE_MATCH) + default: + op = uint8(0) + break + } + if op != 0 { + v4 = iIdx + iIdx = iIdx + 1 + (**(**[41]int8)(__ccgo_up(bp)))[v4] = libc.Int8FromUint8(op) + v4 = iIdx + iIdx = iIdx + 1 + (**(**[41]int8)(__ccgo_up(bp)))[v4] = int8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn - libc.Int32FromInt32(1) + libc.Int32FromUint8('0')) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).FargvIndex = iIdx / int32(2) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).Fomit = doOmit + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(2) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = int32(1) + if iIdx > 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = Xsqlite3_malloc(tls, iIdx+int32(1)) + if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr, bp, libc.Uint64FromInt32(iIdx+int32(1)), ^t__predefined_size_t(0)) + } + nRow = (*TRtree)(unsafe.Pointer(pRtree)).FnRowEst >> (iIdx / int32(2)) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(libc.Float64FromFloat64(6) * float64(nRow)) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = nRow + return rc +} + +// C documentation +// +// /* +// ** The second and subsequent arguments to this function are a printf() +// ** style format string and arguments. This function formats the string and +// ** appends it to the report being accumulated in pCheck. +// */ +func _rtreeCheckAppendMsg(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ap Tva_list + var z, v1 uintptr + _, _, _ = ap, z, v1 + ap = va + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnErr < int32(RTREE_CHECK_MAX_ERROR) { + z = Xsqlite3_vmprintf(tls, zFmt, ap) + if z == uintptr(0) { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM) + } else { + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzReport != 0 { + v1 = __ccgo_ts + 4696 + } else { + v1 = __ccgo_ts + 1702 + } + (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzReport = Xsqlite3_mprintf(tls, __ccgo_ts+29377, libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzReport, v1, z)) + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzReport == uintptr(0) { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM) + } + } + (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnErr = (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnErr + 1 + } + _ = ap +} + +// C documentation +// +// /* +// ** Argument pCell points to an array of coordinates stored on an rtree page. +// ** This function checks that the coordinates are internally consistent (no +// ** x1>x2 conditions) and adds an error message to the RtreeCheck object +// ** if they are not. +// ** +// ** Additionally, if pParent is not NULL, then it is assumed to point to +// ** the array of coordinates on the parent page that bound the page +// ** containing pCell. In this case it is also verified that the two +// ** sets of coordinates are mutually consistent and an error message added +// ** to the RtreeCheck object if they are not. +// */ +func _rtreeCheckCellCoord(tls *libc.TLS, pCheck uintptr, iNode Ti64, iCell int32, pCell uintptr, pParent uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, v2, v3 int32 + var v5 bool + var _ /* c1 at bp+0 */ TRtreeCoord + var _ /* c2 at bp+4 */ TRtreeCoord + var _ /* p1 at bp+8 */ TRtreeCoord + var _ /* p2 at bp+12 */ TRtreeCoord + _, _, _, _ = i, v2, v3, v5 + i = 0 + for { + if !(i < (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim) { + break + } + _readCoord(tls, pCell+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(2)*i), bp) + _readCoord(tls, pCell+uintptr(int32(4)*(int32(2)*i+int32(1))), bp+4) + /* printf("%e, %e\n", c1.u.f, c2.u.f); */ + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 { + v2 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp)) > *(*int32)(unsafe.Pointer(bp + 4))) + } else { + v2 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp)) > *(*TRtreeValue)(unsafe.Pointer(bp + 4))) + } + if v2 != 0 { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29683, libc.VaList(bp+24, i, iCell, iNode)) + } + if pParent != 0 { + _readCoord(tls, pParent+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(2)*i), bp+8) + _readCoord(tls, pParent+uintptr(int32(4)*(int32(2)*i+int32(1))), bp+12) + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 { + v2 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp)) < *(*int32)(unsafe.Pointer(bp + 8))) + } else { + v2 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp)) < *(*TRtreeValue)(unsafe.Pointer(bp + 8))) + } + if v5 = v2 != 0; !v5 { + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 { + v3 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp + 4)) > *(*int32)(unsafe.Pointer(bp + 12))) + } else { + v3 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp + 4)) > *(*TRtreeValue)(unsafe.Pointer(bp + 12))) + } + } + if v5 || v3 != 0 { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29731, libc.VaList(bp+24, i, iCell, iNode)) + } + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** The second argument to this function must be either "_rowid" or +// ** "_parent". This function checks that the number of entries in the +// ** %_rowid or %_parent table is exactly nExpect. If not, it adds +// ** an error message to the report in the RtreeCheck object indicated +// ** by the first argument. +// */ +func _rtreeCheckCount(tls *libc.TLS, pCheck uintptr, zTbl uintptr, nExpect Ti64) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nActual Ti64 + var pCount uintptr + _, _ = nActual, pCount + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { + pCount = _rtreeCheckPrepare(tls, pCheck, __ccgo_ts+29917, libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzTab, zTbl)) + if pCount != 0 { + if Xsqlite3_step(tls, pCount) == int32(SQLITE_ROW) { + nActual = Xsqlite3_column_int64(tls, pCount, 0) + if nActual != nExpect { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29948, libc.VaList(bp+8, zTbl, nExpect, nActual)) + } + } + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_finalize(tls, pCount) + } + } +} + +// C documentation +// +// /* +// ** This function is a no-op if there is already an error code stored +// ** in the RtreeCheck object indicated by the first argument. NULL is +// ** returned in this case. +// ** +// ** Otherwise, the contents of rtree table node iNode are loaded from +// ** the database and copied into a buffer obtained from sqlite3_malloc(). +// ** If no error occurs, a pointer to the buffer is returned and (*pnNode) +// ** is set to the size of the buffer in bytes. +// ** +// ** Or, if an error does occur, NULL is returned and an error code left +// ** in the RtreeCheck object. The final value of *pnNode is undefined in +// ** this case. +// */ +func _rtreeCheckGetNode(tls *libc.TLS, pCheck uintptr, iNode Ti64, pnNode uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nNode int32 + var pNode, pRet uintptr + _, _, _ = nNode, pNode, pRet + pRet = uintptr(0) /* Return value */ + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode == uintptr(0) { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode = _rtreeCheckPrepare(tls, pCheck, __ccgo_ts+29384, libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzTab)) + } + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { + Xsqlite3_bind_int64(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, int32(1), iNode) + if Xsqlite3_step(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) == int32(SQLITE_ROW) { + nNode = Xsqlite3_column_bytes(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0) + pNode = Xsqlite3_column_blob(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0) + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nNode)) + if pRet == uintptr(0) { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memcpy_chk(tls, pRet, pNode, libc.Uint64FromInt32(nNode), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnNode)) = nNode + } + } + _rtreeCheckReset(tls, pCheck, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && pRet == uintptr(0) { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29429, libc.VaList(bp+8, iNode)) + } + } + return pRet +} + +// C documentation +// +// /* +// ** This function is used to check that the %_parent (if bLeaf==0) or %_rowid +// ** (if bLeaf==1) table contains a specified entry. The schemas of the +// ** two tables are: +// ** +// ** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER) +// ** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER, ...) +// ** +// ** In both cases, this function checks that there exists an entry with +// ** IPK value iKey and the second column set to iVal. +// ** +// */ +func _rtreeCheckMapping(tls *libc.TLS, pCheck uintptr, bLeaf int32, iKey Ti64, iVal Ti64) { + bp := tls.Alloc(48) + defer tls.Free(48) + var azSql [2]uintptr + var ii Ti64 + var pStmt, v1 uintptr + var rc int32 + _, _, _, _, _ = azSql, ii, pStmt, rc, v1 + azSql = [2]uintptr{ + 0: __ccgo_ts + 29461, + 1: __ccgo_ts + 29515, + } + if **(**uintptr)(__ccgo_up(pCheck + 40 + uintptr(bLeaf)*8)) == uintptr(0) { + **(**uintptr)(__ccgo_up(pCheck + 40 + uintptr(bLeaf)*8)) = _rtreeCheckPrepare(tls, pCheck, azSql[bLeaf], libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzTab)) + } + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc != SQLITE_OK { + return + } + pStmt = **(**uintptr)(__ccgo_up(pCheck + 40 + uintptr(bLeaf)*8)) + Xsqlite3_bind_int64(tls, pStmt, int32(1), iKey) + rc = Xsqlite3_step(tls, pStmt) + if rc == int32(SQLITE_DONE) { + if bLeaf != 0 { + v1 = __ccgo_ts + 29563 + } else { + v1 = __ccgo_ts + 29571 + } + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29580, libc.VaList(bp+8, iKey, iVal, v1)) + } else { + if rc == int32(SQLITE_ROW) { + ii = Xsqlite3_column_int64(tls, pStmt, 0) + if ii != iVal { + if bLeaf != 0 { + v1 = __ccgo_ts + 29563 + } else { + v1 = __ccgo_ts + 29571 + } + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29625, libc.VaList(bp+8, iKey, ii, v1, iKey, iVal)) + } + } + } + _rtreeCheckReset(tls, pCheck, pStmt) +} + +// C documentation +// +// /* +// ** Run rtreecheck() checks on node iNode, which is at depth iDepth within +// ** the r-tree structure. Argument aParent points to the array of coordinates +// ** that bound node iNode on the parent node. +// ** +// ** If any problems are discovered, an error message is appended to the +// ** report accumulated in the RtreeCheck object. +// */ +func _rtreeCheckNode(tls *libc.TLS, pCheck uintptr, iDepth int32, aParent uintptr, iNode Ti64) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aNode, pCell uintptr + var i, nCell int32 + var iVal Ti64 + var _ /* nNode at bp+0 */ int32 + _, _, _, _, _ = aNode, i, iVal, nCell, pCell + aNode = uintptr(0) + **(**int32)(__ccgo_up(bp)) = 0 + aNode = _rtreeCheckGetNode(tls, pCheck, iNode, bp) + if aNode != 0 { + if **(**int32)(__ccgo_up(bp)) < int32(4) { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29798, libc.VaList(bp+16, iNode, **(**int32)(__ccgo_up(bp)))) + } else { /* Used to iterate through cells */ + if aParent == uintptr(0) { + iDepth = _readInt16(tls, aNode) + if iDepth > int32(RTREE_MAX_DEPTH) { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29832, libc.VaList(bp+16, iDepth)) + Xsqlite3_free(tls, aNode) + return + } + } + nCell = _readInt16(tls, aNode+2) + if int32(4)+nCell*(int32(8)+(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim*int32(2)*int32(4)) > **(**int32)(__ccgo_up(bp)) { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29862, libc.VaList(bp+16, iNode, nCell, **(**int32)(__ccgo_up(bp)))) + } else { + i = 0 + for { + if !(i < nCell) { + break + } + pCell = aNode + uintptr(int32(4)+i*(int32(8)+(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim*int32(2)*int32(4))) + iVal = _readInt64(tls, pCell) + _rtreeCheckCellCoord(tls, pCheck, iNode, i, pCell+8, aParent) + if iDepth > 0 { + _rtreeCheckMapping(tls, pCheck, 0, iVal, iNode) + _rtreeCheckNode(tls, pCheck, iDepth-int32(1), pCell+8, iVal) + (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf = (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf + 1 + } else { + _rtreeCheckMapping(tls, pCheck, int32(1), iVal, iNode) + (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnLeaf = (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnLeaf + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + } + } + Xsqlite3_free(tls, aNode) + } +} + +// C documentation +// +// /* +// ** This function does the bulk of the work for the rtree integrity-check. +// ** It is called by rtreecheck(), which is the SQL function implementation. +// */ +func _rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzReport uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var nAux, rc int32 + var pStmt uintptr + var _ /* check at bp+0 */ TRtreeCheck + _, _, _ = nAux, pStmt, rc /* Common context for various routines */ + pStmt = uintptr(0) /* Used to find column count of rtree table */ + nAux = 0 /* Number of extra columns. */ + /* Initialize the context object */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(88), ^t__predefined_size_t(0)) + (**(**TRtreeCheck)(__ccgo_up(bp))).Fdb = db + (**(**TRtreeCheck)(__ccgo_up(bp))).FzDb = zDb + (**(**TRtreeCheck)(__ccgo_up(bp))).FzTab = zTab + /* Find the number of auxiliary columns */ + pStmt = _rtreeCheckPrepare(tls, bp, __ccgo_ts+30015, libc.VaList(bp+96, zDb, zTab)) + if pStmt != 0 { + nAux = Xsqlite3_column_count(tls, pStmt) - int32(2) + Xsqlite3_finalize(tls, pStmt) + } else { + if (**(**TRtreeCheck)(__ccgo_up(bp))).Frc != int32(SQLITE_NOMEM) { + (**(**TRtreeCheck)(__ccgo_up(bp))).Frc = SQLITE_OK + } + } + /* Find number of dimensions in the rtree table. */ + pStmt = _rtreeCheckPrepare(tls, bp, __ccgo_ts+27831, libc.VaList(bp+96, zDb, zTab)) + if pStmt != 0 { + (**(**TRtreeCheck)(__ccgo_up(bp))).FnDim = (Xsqlite3_column_count(tls, pStmt) - int32(1) - nAux) / int32(2) + if (**(**TRtreeCheck)(__ccgo_up(bp))).FnDim < int32(1) { + _rtreeCheckAppendMsg(tls, bp, __ccgo_ts+30043, 0) + } else { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, pStmt) { + (**(**TRtreeCheck)(__ccgo_up(bp))).FbInt = libc.BoolInt32(Xsqlite3_column_type(tls, pStmt, int32(1)) == int32(SQLITE_INTEGER)) + } + } + rc = Xsqlite3_finalize(tls, pStmt) + if rc != int32(SQLITE_CORRUPT) { + (**(**TRtreeCheck)(__ccgo_up(bp))).Frc = rc + } + } + /* Do the actual integrity-check */ + if (**(**TRtreeCheck)(__ccgo_up(bp))).FnDim >= int32(1) { + if (**(**TRtreeCheck)(__ccgo_up(bp))).Frc == SQLITE_OK { + _rtreeCheckNode(tls, bp, 0, uintptr(0), int64(1)) + } + _rtreeCheckCount(tls, bp, __ccgo_ts+30074, int64((**(**TRtreeCheck)(__ccgo_up(bp))).FnLeaf)) + _rtreeCheckCount(tls, bp, __ccgo_ts+30081, int64((**(**TRtreeCheck)(__ccgo_up(bp))).FnNonLeaf)) + } + /* Finalize SQL statements used by the integrity-check */ + Xsqlite3_finalize(tls, (**(**TRtreeCheck)(__ccgo_up(bp))).FpGetNode) + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 40))) + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 40 + 1*8))) + **(**uintptr)(__ccgo_up(pzReport)) = (**(**TRtreeCheck)(__ccgo_up(bp))).FzReport + return (**(**TRtreeCheck)(__ccgo_up(bp))).Frc +} + +// C documentation +// +// /* +// ** A constraint has failed while inserting a row into an rtree table. +// ** Assuming no OOM error occurs, this function sets the error message +// ** (at pRtree->base.zErrMsg) to an appropriate value and returns +// ** SQLITE_CONSTRAINT. +// ** +// ** Parameter iCol is the index of the leftmost column involved in the +// ** constraint failure. If it is 0, then the constraint that failed is +// ** the unique constraint on the id column. Otherwise, it is the rtree +// ** (c1<=c2) constraint on columns iCol and iCol+1 that has failed. +// ** +// ** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT. +// */ +func _rtreeConstraintError(tls *libc.TLS, pRtree uintptr, iCol int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var rc, v1 int32 + var zCol, zCol1, zCol2, zSql uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _ = rc, zCol, zCol1, zCol2, zSql, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+27831, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName)) + if zSql != 0 { + rc = Xsqlite3_prepare_v2(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zSql, -int32(1), bp, uintptr(0)) + } else { + rc = int32(SQLITE_NOMEM) + } + Xsqlite3_free(tls, zSql) + if rc == SQLITE_OK { + if iCol == 0 { + zCol = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), 0) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+27851, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zCol)) + } else { + zCol1 = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), iCol) + zCol2 = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), iCol+int32(1)) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+27883, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zCol1, zCol2)) + } + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + v1 = int32(SQLITE_CONSTRAINT) + } else { + v1 = rc + } + return v1 +} + +// C documentation +// +// /* +// ** Rtree virtual table module xDestroy method. +// */ +func _rtreeDestroy(tls *libc.TLS, pVtab uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var pRtree, zCreate uintptr + var rc int32 + _, _, _ = pRtree, rc, zCreate + pRtree = pVtab + zCreate = Xsqlite3_mprintf(tls, __ccgo_ts+27735, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName)) + if !(zCreate != 0) { + rc = int32(SQLITE_NOMEM) + } else { + _nodeBlobReset(tls, pRtree) + rc = Xsqlite3_exec(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zCreate, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_free(tls, zCreate) + } + if rc == SQLITE_OK { + _rtreeRelease(tls, pRtree) + } + return rc +} + +// C documentation +// +// /* +// ** Rtree virtual table module xFilter method. +// */ +func _rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eType, eType1, ii, rc int32 + var iRowid Ti64 + var iVal Tsqlite3_int64 + var p, p1, pCsr, pNew, pRtree uintptr + var _ /* iCell at bp+8 */ int32 + var _ /* iNode at bp+24 */ Ti64 + var _ /* pLeaf at bp+16 */ uintptr + var _ /* pRoot at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = eType, eType1, iRowid, iVal, ii, p, p1, pCsr, pNew, pRtree, rc + pRtree = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab + pCsr = pVtabCursor + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 8)) = 0 + _rtreeReference(tls, pRtree) + /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ + _resetCursor(tls, pCsr) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FiStrategy = idxNum + if idxNum == int32(1) { /* Search point for the leaf */ + iRowid = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + **(**Ti64)(__ccgo_up(bp + 24)) = 0 + eType = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) && 0 == _sqlite3IntFloatCompare(tls, iRowid, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))) { + rc = _findLeafNode(tls, pRtree, iRowid, bp+16, bp+24) + } else { + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + } + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 16)) != uintptr(0) { + p = _rtreeSearchPointNew(tls, pCsr, float64(0), uint8(0)) + /* Always returns pCsr->sPoint */ + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp + 16)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).Fid = **(**Ti64)(__ccgo_up(bp + 24)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = uint8(PARTLY_WITHIN) + rc = _nodeRowidIndex(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 16)), iRowid, bp+8) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 8))) + } else { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FatEOF = uint8(1) + } + } else { + /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array + ** with the configured constraints. + */ + rc = _nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp) + if rc == SQLITE_OK && argc > 0 { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = Xsqlite3_malloc64(tls, uint64(uint64(24)*libc.Uint64FromInt32(argc))) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = argc + if !((*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint != 0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, uint64(24)*libc.Uint64FromInt32(argc), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, pCsr+128, 0, uint64(4)*libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiDepth+libc.Int32FromInt32(1)), ^t__predefined_size_t(0)) + ii = 0 + for { + if !(ii < argc) { + break + } + p1 = (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint + uintptr(ii)*24 + eType1 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8))) + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32(**(**int8)(__ccgo_up(idxStr + uintptr(ii*int32(2))))) + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(**(**int8)(__ccgo_up(idxStr + uintptr(ii*int32(2)+int32(1))))) - int32('0') + if (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop >= int32(RTREE_MATCH) { + /* A MATCH operator. The right-hand-side must be a blob that + ** can be cast into an RtreeMatchArg object. One created using + ** an sqlite3_rtree_geometry_callback() SQL user function. + */ + rc = _deserializeGeometry(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8)), p1) + if rc != SQLITE_OK { + break + } + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FnCoord = libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FanQueue = pCsr + 128 + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FmxLevel = (*TRtree)(unsafe.Pointer(pRtree)).FiDepth + int32(1) + } else { + if eType1 == int32(SQLITE_INTEGER) { + iVal = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8))) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(iVal) + if iVal >= libc.Int64FromInt32(1)<bPoint was FALSE */ + return int32(SQLITE_NOMEM) + } + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = uint8(0) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = uint8(PARTLY_WITHIN) + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _rtreeStepToLeaf(tls, pCsr) + } + } + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** This function is the implementation of both the xConnect and xCreate +// ** methods of the r-tree virtual table. +// ** +// ** argv[0] -> module name +// ** argv[1] -> database name +// ** argv[2] -> table name +// ** argv[...] -> column names... +// */ +func _rtreeInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr, isCreate int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aErrMsg [5]uintptr + var eCoordType, iErr, ii, nDb, nName, rc, v1 int32 + var pRtree, pSql, zArg, zSql uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = aErrMsg, eCoordType, iErr, ii, nDb, nName, pRtree, pSql, rc, zArg, zSql, v1 + rc = SQLITE_OK + if pAux != 0 { + v1 = int32(RTREE_COORD_INT32) + } else { + v1 = RTREE_COORD_REAL32 + } /* Length of string argv[2] */ + eCoordType = v1 + ii = int32(4) + aErrMsg = [5]uintptr{ + 1: __ccgo_ts + 29123, + 2: __ccgo_ts + 29166, + 3: __ccgo_ts + 29201, + 4: __ccgo_ts + 29237, + } + if argc < int32(6) || argc > libc.Int32FromInt32(RTREE_MAX_AUX_COLUMN)+libc.Int32FromInt32(3) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[int32(2)+libc.BoolInt32(argc >= int32(6))])) + return int32(SQLITE_ERROR) + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_CONSTRAINT_SUPPORT), libc.VaList(bp+8, int32(1))) + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + /* Allocate the sqlite3_vtab structure */ + nDb = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 1*8)))) + nName = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + pRtree = Xsqlite3_malloc64(tls, uint64(uint64(976)+libc.Uint64FromInt32(nDb)+libc.Uint64FromInt32(nName*int32(2))+uint64(8))) + if !(pRtree != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pRtree, 0, uint64(976)+libc.Uint64FromInt32(nDb)+libc.Uint64FromInt32(nName*int32(2))+uint64(8), ^t__predefined_size_t(0)) + (*TRtree)(unsafe.Pointer(pRtree)).FnBusy = uint32(1) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&_rtreeModule)) + (*TRtree)(unsafe.Pointer(pRtree)).FzDb = pRtree + 1*976 + (*TRtree)(unsafe.Pointer(pRtree)).FzName = (*TRtree)(unsafe.Pointer(pRtree)).FzDb + uintptr(nDb+int32(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName = (*TRtree)(unsafe.Pointer(pRtree)).FzName + uintptr(nName+int32(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FeCoordType = libc.Uint8FromInt32(eCoordType) + libc.X__builtin___memcpy_chk(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, **(**uintptr)(__ccgo_up(argv + 1*8)), libc.Uint64FromInt32(nDb), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt32(nName), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt32(nName), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName+uintptr(nName), __ccgo_ts+29274, uint64(6), ^t__predefined_size_t(0)) + /* Create/Connect to the underlying relational database schema. If + ** that is successful, call sqlite3_declare_vtab() to configure + ** the r-tree table schema. + */ + pSql = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+29280, libc.VaList(bp+8, _rtreeTokenLength(tls, **(**uintptr)(__ccgo_up(argv + 3*8))), **(**uintptr)(__ccgo_up(argv + 3*8)))) + ii = int32(4) + for { + if !(ii < argc) { + break + } + zArg = **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8)) + if int32(**(**int8)(__ccgo_up(zArg))) == int32('+') { + (*TRtree)(unsafe.Pointer(pRtree)).FnAux = (*TRtree)(unsafe.Pointer(pRtree)).FnAux + 1 + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+29304, libc.VaList(bp+8, _rtreeTokenLength(tls, zArg+uintptr(1)), zArg+uintptr(1))) + } else { + if libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux) > 0 { + break + } else { + (*TRtree)(unsafe.Pointer(pRtree)).FnDim2 = (*TRtree)(unsafe.Pointer(pRtree)).FnDim2 + 1 + Xsqlite3_str_appendf(tls, pSql, _azFormat[eCoordType], libc.VaList(bp+8, _rtreeTokenLength(tls, zArg), zArg)) + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+29331, 0) + zSql = Xsqlite3_str_finish(tls, pSql) + if !(zSql != 0) { + rc = int32(SQLITE_NOMEM) + } else { + if ii < argc { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[int32(4)])) + rc = int32(SQLITE_ERROR) + } else { + v1 = Xsqlite3_declare_vtab(tls, db, zSql) + rc = v1 + if SQLITE_OK != v1 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + } + } + } + Xsqlite3_free(tls, zSql) + if rc != 0 { + goto rtreeInit_fail + } + (*TRtree)(unsafe.Pointer(pRtree)).FnDim = libc.Uint8FromInt32(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) / int32(2)) + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim) < int32(1) { + iErr = int32(2) + } else { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) > libc.Int32FromInt32(RTREE_MAX_DIMENSIONS)*libc.Int32FromInt32(2) { + iErr = int32(3) + } else { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)%int32(2) != 0 { + iErr = int32(1) + } else { + iErr = 0 + } + } + } + if iErr != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[iErr])) + goto rtreeInit_fail + } + (*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell = libc.Uint8FromInt32(int32(8) + libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)*int32(4)) + /* Figure out the node size to use. */ + rc = _getNodeSize(tls, db, pRtree, isCreate, pzErr) + if rc != 0 { + goto rtreeInit_fail + } + rc = _rtreeSqlInit(tls, pRtree, db, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), isCreate) + if rc != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + goto rtreeInit_fail + } + **(**uintptr)(__ccgo_up(ppVtab)) = pRtree + return SQLITE_OK + goto rtreeInit_fail +rtreeInit_fail: + ; + if rc == SQLITE_OK { + rc = int32(SQLITE_ERROR) + } + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** Implementation of the xIntegrity method for Rtree. +// */ +func _rtreeIntegrity(tls *libc.TLS, pVtab uintptr, zSchema uintptr, zName uintptr, isQuick int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pRtree uintptr + var rc int32 + _, _ = pRtree, rc + pRtree = pVtab + _ = zSchema + _ = zName + _ = isQuick + rc = _rtreeCheckTable(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, pzErr) + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(pzErr)) != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+30089, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, **(**uintptr)(__ccgo_up(pzErr)))) + if **(**uintptr)(__ccgo_up(pzErr)) == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +// C documentation +// +// /* +// ** Check the leaf RTree cell given by pCellData against constraint p. +// ** If this constraint is not satisfied, set *peWithin to NOT_WITHIN. +// ** If the constraint is satisfied, leave *peWithin unchanged. +// ** +// ** The constraint is of the form: xN op $val +// ** +// ** The op is given by p->op. The xN is p->iCoord-th coordinate in +// ** pCellData. $val is given by p->u.rValue. +// */ +func _rtreeLeafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr, peWithin uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var xN TRtreeDValue + var v1 Tsqlite3_rtree_dbl + var _ /* c at bp+0 */ TRtreeCoord + _, _ = xN, v1 /* Coordinate value converted to a double */ + pCellData = pCellData + uintptr(int32(8)+(*TRtreeConstraint)(unsafe.Pointer(p)).FiCoord*int32(4)) + libc.X__builtin___memcpy_chk(tls, bp, pCellData, uint64(4), ^t__predefined_size_t(0)) + *(*Tu32)(unsafe.Pointer(bp)) = *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp))&uint32(0xff)<= *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { + return + } + case int32(RTREE_GT): + if xN > *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { + return + } + default: + if xN == *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { + return + } + break + } + **(**int32)(__ccgo_up(peWithin)) = NOT_WITHIN +} + +// C documentation +// +// /* +// ** Check the internal RTree node given by pCellData against constraint p. +// ** If this constraint cannot be satisfied by any child within the node, +// ** set *peWithin to NOT_WITHIN. +// */ +func _rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr, peWithin uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var val, v1 Tsqlite3_rtree_dbl + var _ /* c at bp+0 */ TRtreeCoord + var _ /* c at bp+12 */ TRtreeCoord + var _ /* c at bp+4 */ TRtreeCoord + var _ /* c at bp+8 */ TRtreeCoord + _, _ = val, v1 /* Coordinate value convert to a double */ + /* p->iCoord might point to either a lower or upper bound coordinate + ** in a coordinate pair. But make pCellData point to the lower bound. + */ + pCellData = pCellData + uintptr(int32(8)+int32(4)*((*TRtreeConstraint)(unsafe.Pointer(p)).FiCoord&int32(0xfe))) + switch (*TRtreeConstraint)(unsafe.Pointer(p)).Fop { + case int32(RTREE_TRUE): + return /* Always satisfied */ + case int32(RTREE_FALSE): + case int32(RTREE_EQ): + libc.X__builtin___memcpy_chk(tls, bp, pCellData, uint64(4), ^t__predefined_size_t(0)) + *(*Tu32)(unsafe.Pointer(bp)) = *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp))&uint32(0xff)<= val { + pCellData = pCellData + uintptr(4) + libc.X__builtin___memcpy_chk(tls, bp+4, pCellData, uint64(4), ^t__predefined_size_t(0)) + *(*Tu32)(unsafe.Pointer(bp + 4)) = *(*Tu32)(unsafe.Pointer(bp + 4))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 4))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 4))&uint32(0xff)<>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 8))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 8))&uint32(0xff)<= val { + return + } + default: + pCellData = pCellData + uintptr(4) + libc.X__builtin___memcpy_chk(tls, bp+12, pCellData, uint64(4), ^t__predefined_size_t(0)) + *(*Tu32)(unsafe.Pointer(bp + 12)) = *(*Tu32)(unsafe.Pointer(bp + 12))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 12))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 12))&uint32(0xff)<nRowEst variable with an estimate +// ** of the number of rows in the virtual table. If possible, this is based +// ** on sqlite_stat1 data. Otherwise, use RTREE_DEFAULT_ROWEST. +// */ +func _rtreeQueryStat1(tls *libc.TLS, db uintptr, pRtree uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nRow Ti64 + var rc, v1 int32 + var zFmt, zSql uintptr + var v2 int64 + var _ /* p at bp+0 */ uintptr + _, _, _, _, _, _ = nRow, rc, zFmt, zSql, v1, v2 + zFmt = __ccgo_ts + 28065 + nRow = int64(RTREE_MIN_ROWEST) + rc = Xsqlite3_table_column_metadata(tls, db, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, __ccgo_ts+13177, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + if rc != SQLITE_OK { + (*TRtree)(unsafe.Pointer(pRtree)).FnRowEst = int64(RTREE_DEFAULT_ROWEST) + if rc == int32(SQLITE_ERROR) { + v1 = SQLITE_OK + } else { + v1 = rc + } + return v1 + } + zSql = Xsqlite3_mprintf(tls, zFmt, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + if rc == SQLITE_OK { + if Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { + nRow = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + Xsqlite3_free(tls, zSql) + } + if nRow > int64(libc.Int32FromInt32(RTREE_MIN_ROWEST)) { + v2 = nRow + } else { + v2 = int64(libc.Int32FromInt32(RTREE_MIN_ROWEST)) + } + (*TRtree)(unsafe.Pointer(pRtree)).FnRowEst = v2 + return rc +} + +// C documentation +// +// /* +// ** The xRename method for rtree module virtual tables. +// */ +func _rtreeRename(tls *libc.TLS, pVtab uintptr, zNewName uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var pRtree, zSql uintptr + var rc int32 + _, _, _ = pRtree, rc, zSql + pRtree = pVtab + rc = int32(SQLITE_NOMEM) + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+27920, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName)) + if zSql != 0 { + _nodeBlobReset(tls, pRtree) + rc = Xsqlite3_exec(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zSql, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_free(tls, zSql) + } + return rc +} + +func _rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefix uintptr, isCreate int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var appStmt [8]uintptr + var f, i, ii, ii1, rc int32 + var p, p1, zCreate, zFormat, zSql, zSql1 uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = appStmt, f, i, ii, ii1, p, p1, rc, zCreate, zFormat, zSql, zSql1 + rc = SQLITE_OK + f = libc.Int32FromInt32(SQLITE_PREPARE_PERSISTENT) | libc.Int32FromInt32(SQLITE_PREPARE_NO_VTAB) + (*TRtree)(unsafe.Pointer(pRtree)).Fdb = db + if isCreate != 0 { + p = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28535, libc.VaList(bp+8, zDb, zPrefix)) + ii = 0 + for { + if !(ii < libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux)) { + break + } + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28597, libc.VaList(bp+8, ii)) + goto _1 + _1: + ; + ii = ii + 1 + } + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28602, libc.VaList(bp+8, zDb, zPrefix)) + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28666, libc.VaList(bp+8, zDb, zPrefix)) + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28736, libc.VaList(bp+8, zDb, zPrefix, (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize)) + zCreate = Xsqlite3_str_finish(tls, p) + if !(zCreate != 0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_exec(tls, db, zCreate, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_free(tls, zCreate) + if rc != SQLITE_OK { + return rc + } + } + appStmt[0] = pRtree + 128 + appStmt[int32(1)] = pRtree + 136 + appStmt[int32(2)] = pRtree + 144 + appStmt[int32(3)] = pRtree + 152 + appStmt[int32(4)] = pRtree + 160 + appStmt[int32(5)] = pRtree + 168 + appStmt[int32(6)] = pRtree + 176 + appStmt[int32(7)] = pRtree + 184 + rc = _rtreeQueryStat1(tls, db, pRtree) + i = 0 + for { + if !(i < int32(N_STATEMENT) && rc == SQLITE_OK) { + break + } + if i != int32(3) || libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux) == 0 { + zFormat = _azSql[i] + } else { + /* An UPSERT is very slightly slower than REPLACE, but it is needed + ** if there are auxiliary columns */ + zFormat = __ccgo_ts + 28785 + } + zSql = Xsqlite3_mprintf(tls, zFormat, libc.VaList(bp+8, zDb, zPrefix)) + if zSql != 0 { + rc = Xsqlite3_prepare_v3(tls, db, zSql, -int32(1), libc.Uint32FromInt32(f), appStmt[i], uintptr(0)) + } else { + rc = int32(SQLITE_NOMEM) + } + Xsqlite3_free(tls, zSql) + goto _2 + _2: + ; + i = i + 1 + } + if (*TRtree)(unsafe.Pointer(pRtree)).FnAux != 0 && rc != int32(SQLITE_NOMEM) { + (*TRtree)(unsafe.Pointer(pRtree)).FzReadAuxSql = Xsqlite3_mprintf(tls, __ccgo_ts+28893, libc.VaList(bp+8, zDb, zPrefix)) + if (*TRtree)(unsafe.Pointer(pRtree)).FzReadAuxSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + p1 = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, p1, __ccgo_ts+28938, libc.VaList(bp+8, zDb, zPrefix)) + ii1 = 0 + for { + if !(ii1 < libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux)) { + break + } + if ii1 != 0 { + Xsqlite3_str_append(tls, p1, __ccgo_ts+14690, int32(1)) + } + if ii1 < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnAuxNotNull) { + Xsqlite3_str_appendf(tls, p1, __ccgo_ts+28965, libc.VaList(bp+8, ii1, ii1+int32(2), ii1)) + } else { + Xsqlite3_str_appendf(tls, p1, __ccgo_ts+28987, libc.VaList(bp+8, ii1, ii1+int32(2))) + } + goto _3 + _3: + ; + ii1 = ii1 + 1 + } + Xsqlite3_str_appendf(tls, p1, __ccgo_ts+28995, 0) + zSql1 = Xsqlite3_str_finish(tls, p1) + if zSql1 == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v3(tls, db, zSql1, -int32(1), libc.Uint32FromInt32(f), pRtree+192, uintptr(0)) + Xsqlite3_free(tls, zSql1) + } + } + } + return rc +} + +// C documentation +// +// /* +// ** The xUpdate method for rtree module virtual tables. +// */ +func _rtreeUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bHaveRowid, ii, jj, nn, rc, rc2, steprc int32 + var pRtree, pUp uintptr + var _ /* cell at bp+0 */ TRtreeCell + var _ /* pLeaf at bp+48 */ uintptr + _, _, _, _, _, _, _, _, _ = bHaveRowid, ii, jj, nn, pRtree, pUp, rc, rc2, steprc + pRtree = pVtab + rc = SQLITE_OK /* New cell to insert if nData>1 */ + bHaveRowid = 0 /* Set to 1 after new rowid is determined */ + if (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0 { + /* Unable to write to the btree while another cursor is reading from it, + ** since the write might do a rebalance which would disrupt the read + ** cursor. */ + return libc.Int32FromInt32(SQLITE_LOCKED) | libc.Int32FromInt32(2)<=x1" constraint. + ** + ** In the first case, if the conflict-handling mode is REPLACE, then + ** the conflicting row can be removed before proceeding. In the second + ** case, SQLITE_CONSTRAINT must be returned regardless of the + ** conflict-handling mode specified by the user. + */ + if nData > int32(1) { + nn = nData - int32(4) + if nn > libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) { + nn = libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) + } + /* Populate the cell.aCoord[] array. The first coordinate is aData[3]. + ** + ** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared + ** with "column" that are interpreted as table constraints. + ** Example: CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5)); + ** This problem was discovered after years of use, so we silently ignore + ** these kinds of misdeclared tables to avoid breaking any legacy. + */ + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + ii = 0 + for { + if !(ii < nn) { + break + } + *(*TRtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) = _rtreeValueDown(tls, **(**uintptr)(__ccgo_up(aData + uintptr(ii+int32(3))*8))) + *(*TRtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii+int32(1))*4)) = _rtreeValueUp(tls, **(**uintptr)(__ccgo_up(aData + uintptr(ii+int32(4))*8))) + if *(*TRtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) > *(*TRtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii+int32(1))*4)) { + rc = _rtreeConstraintError(tls, pRtree, ii+int32(1)) + goto constraint + } + goto _1 + _1: + ; + ii = ii + int32(2) + } + } else { + ii = 0 + for { + if !(ii < nn) { + break + } + *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(aData + uintptr(ii+int32(3))*8))) + *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii+int32(1))*4)) = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(aData + uintptr(ii+int32(4))*8))) + if *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) > *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii+int32(1))*4)) { + rc = _rtreeConstraintError(tls, pRtree, ii+int32(1)) + goto constraint + } + goto _2 + _2: + ; + ii = ii + int32(2) + } + } + /* If a rowid value was supplied, check if it is already present in + ** the table. If so, the constraint has failed. */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) != int32(SQLITE_NULL) { + (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData))) == int32(SQLITE_NULL) || Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(aData))) != (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid { + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid, int32(1), (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid) + steprc = Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + if int32(SQLITE_ROW) == steprc { + if Xsqlite3_vtab_on_conflict(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb) == int32(SQLITE_REPLACE) { + rc = _rtreeDeleteRowid(tls, pRtree, (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid) + } else { + rc = _rtreeConstraintError(tls, pRtree, 0) + goto constraint + } + } + } + bHaveRowid = int32(1) + } + } + /* If aData[0] is not an SQL NULL value, it is the rowid of a + ** record to delete from the r-tree table. The following block does + ** just that. + */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData))) != int32(SQLITE_NULL) { + rc = _rtreeDeleteRowid(tls, pRtree, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(aData)))) + } + /* If the aData[] array contains more than one element, elements + ** (aData[2]..aData[argc-1]) contain a new record to insert into + ** the r-tree structure. + */ + if rc == SQLITE_OK && nData > int32(1) { + /* Insert the new record into the r-tree */ + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) + /* Figure out the rowid of the new row. */ + if bHaveRowid == 0 { + rc = _rtreeNewRowid(tls, pRtree, bp) + } + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid + if rc == SQLITE_OK { + rc = _ChooseLeaf(tls, pRtree, bp, 0, bp+48) + } + if rc == SQLITE_OK { + rc = _rtreeInsertCell(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 48)), bp, 0) + rc2 = _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 48))) + if rc == SQLITE_OK { + rc = rc2 + } + } + if rc == SQLITE_OK && (*TRtree)(unsafe.Pointer(pRtree)).FnAux != 0 { + pUp = (*TRtree)(unsafe.Pointer(pRtree)).FpWriteAux + Xsqlite3_bind_int64(tls, pUp, int32(1), **(**Tsqlite_int64)(__ccgo_up(pRowid))) + jj = 0 + for { + if !(jj < libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux)) { + break + } + Xsqlite3_bind_value(tls, pUp, jj+int32(2), **(**uintptr)(__ccgo_up(aData + uintptr(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)+int32(3)+jj)*8))) + goto _3 + _3: + ; + jj = jj + 1 + } + Xsqlite3_step(tls, pUp) + rc = Xsqlite3_reset(tls, pUp) + } + } + goto constraint +constraint: + ; + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** Usage: +// ** +// ** rtreecheck(); +// ** rtreecheck(, ); +// ** +// ** Invoking this SQL function runs an integrity-check on the named rtree +// ** table. The integrity-check verifies the following: +// ** +// ** 1. For each cell in the r-tree structure (%_node table), that: +// ** +// ** a) for each dimension, (coord1 <= coord2). +// ** +// ** b) unless the cell is on the root node, that the cell is bounded +// ** by the parent cell on the parent node. +// ** +// ** c) for leaf nodes, that there is an entry in the %_rowid +// ** table corresponding to the cell's rowid value that +// ** points to the correct node. +// ** +// ** d) for cells on non-leaf nodes, that there is an entry in the +// ** %_parent table mapping from the cell's child node to the +// ** node that it resides on. +// ** +// ** 2. That there are the same number of entries in the %_rowid table +// ** as there are leaf cells in the r-tree structure, and that there +// ** is a leaf cell that corresponds to each entry in the %_rowid table. +// ** +// ** 3. That there are the same number of entries in the %_parent table +// ** as there are non-leaf cells in the r-tree structure, and that +// ** there is a non-leaf cell that corresponds to each entry in the +// ** %_parent table. +// */ +func _rtreecheck(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var zDb, zTab, v1 uintptr + var _ /* zReport at bp+0 */ uintptr + _, _, _, _ = rc, zDb, zTab, v1 + if nArg != int32(1) && nArg != int32(2) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+30108, -int32(1)) + } else { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg))) + if nArg == int32(1) { + zTab = zDb + zDb = __ccgo_ts + 7160 + } else { + zTab = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + } + rc = _rtreeCheckTable(tls, Xsqlite3_context_db_handle(tls, ctx), zDb, zTab, bp) + if rc == SQLITE_OK { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = **(**uintptr)(__ccgo_up(bp)) + } else { + v1 = __ccgo_ts + 20182 + } + Xsqlite3_result_text(tls, ctx, v1, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_error_code(tls, ctx, rc) + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + } +} + +/* Conditionally include the geopoly code */ +/************** Include geopoly.c in the middle of rtree.c *******************/ +/************** Begin file geopoly.c *****************************************/ +/* +** 2018-05-25 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file implements an alternative R-Tree virtual table that +** uses polygons to express the boundaries of 2-dimensional objects. +** +** This file is #include-ed onto the end of "rtree.c" so that it has +** access to all of the R-Tree internals. + */ +/* #include */ + +/* Enable -DGEOPOLY_ENABLE_DEBUG for debugging facilities */ + +/* Character class routines */ +/* Use the SQLite core versions if this routine is part of the + ** SQLite amalgamation */ + +// C documentation +// +// /* This routine implements an SQL function that returns the "depth" parameter +// ** from the front of a blob that is an r-tree node. For example: +// ** +// ** SELECT rtreedepth(data) FROM rt_node WHERE nodeno=1; +// ** +// ** The depth value is 0 for all nodes other than the root node, and the root +// ** node always has nodeno=1, so the example above is the primary use for this +// ** routine. This routine is intended for testing and analysis only. +// */ +func _rtreedepth(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { + var zBlob uintptr + _ = zBlob + _ = nArg + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apArg))) != int32(SQLITE_BLOB) || Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg))) < int32(2) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+29344, -int32(1)) + } else { + zBlob = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(apArg))) + if zBlob != 0 { + Xsqlite3_result_int(tls, ctx, _readInt16(tls, zBlob)) + } else { + Xsqlite3_result_error_nomem(tls, ctx) + } + } +} + +// C documentation +// +// /* +// ** Implementation of a scalar function that decodes r-tree nodes to +// ** human readable strings. This can be used for debugging and analysis. +// ** +// ** The scalar function takes two arguments: (1) the number of dimensions +// ** to the rtree (between 1 and 5, inclusive) and (2) a blob of data containing +// ** an r-tree node. For a two-dimensional r-tree structure called "rt", to +// ** deserialize all nodes, a statement like: +// ** +// ** SELECT rtreenode(2, data) FROM rt_node; +// ** +// ** The human readable string takes the form of a Tcl list with one +// ** entry for each cell in the r-tree node. Each entry is itself a +// ** list, containing the 8-byte rowid/pageno followed by the +// ** *2 coordinates. +// */ +func _rtreenode(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { + bp := tls.Alloc(1088) + defer tls.Free(1088) + var errCode, ii, jj, nData int32 + var pOut uintptr + var _ /* cell at bp+1016 */ TRtreeCell + var _ /* node at bp+0 */ TRtreeNode + var _ /* tree at bp+40 */ TRtree + _, _, _, _, _ = errCode, ii, jj, nData, pOut + _ = nArg + libc.X__builtin___memset_chk(tls, bp, 0, uint64(40), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+40, 0, uint64(976), ^t__predefined_size_t(0)) + (**(**TRtree)(__ccgo_up(bp + 40))).FnDim = libc.Uint8FromInt32(Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apArg)))) + if libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim) < int32(1) || libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim) > int32(5) { + return + } + (**(**TRtree)(__ccgo_up(bp + 40))).FnDim2 = libc.Uint8FromInt32(libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim) * int32(2)) + (**(**TRtree)(__ccgo_up(bp + 40))).FnBytesPerCell = libc.Uint8FromInt32(int32(8) + int32(8)*libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim)) + (**(**TRtreeNode)(__ccgo_up(bp))).FzData = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + if (**(**TRtreeNode)(__ccgo_up(bp))).FzData == uintptr(0) { + return + } + nData = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + if nData < int32(4) { + return + } + if nData < int32(4)+_readInt16(tls, (*TRtreeNode)(unsafe.Pointer(bp)).FzData+2)*libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnBytesPerCell) { + return + } + pOut = Xsqlite3_str_new(tls, uintptr(0)) + ii = 0 + for { + if !(ii < _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(bp)).FzData+2)) { + break + } + _nodeGetCell(tls, bp+40, bp, ii, bp+1016) + if ii > 0 { + Xsqlite3_str_append(tls, pOut, __ccgo_ts+11885, int32(1)) + } + Xsqlite3_str_appendf(tls, pOut, __ccgo_ts+29334, libc.VaList(bp+1072, (**(**TRtreeCell)(__ccgo_up(bp + 1016))).FiRowid)) + jj = 0 + for { + if !(jj < libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim2)) { + break + } + Xsqlite3_str_appendf(tls, pOut, __ccgo_ts+29340, libc.VaList(bp+1072, float64(*(*TRtreeValue)(unsafe.Pointer(bp + 1016 + 8 + uintptr(jj)*4))))) + goto _2 + _2: + ; + jj = jj + 1 + } + Xsqlite3_str_append(tls, pOut, __ccgo_ts+27179, int32(1)) + goto _1 + _1: + ; + ii = ii + 1 + } + errCode = Xsqlite3_str_errcode(tls, pOut) + Xsqlite3_result_error_code(tls, ctx, errCode) + Xsqlite3_result_text(tls, ctx, Xsqlite3_str_finish(tls, pOut), -int32(1), __ccgo_fp(Xsqlite3_free)) +} + +// C documentation +// +// /* +// ** Copy the contents of object (*pFrom) into (*pTo). +// */ +func _sampleCopy(tls *libc.TLS, p uintptr, pTo uintptr, pFrom uintptr) { + (*TStatSample)(unsafe.Pointer(pTo)).FisPSample = (*TStatSample)(unsafe.Pointer(pFrom)).FisPSample + (*TStatSample)(unsafe.Pointer(pTo)).FiCol = (*TStatSample)(unsafe.Pointer(pFrom)).FiCol + (*TStatSample)(unsafe.Pointer(pTo)).FiHash = (*TStatSample)(unsafe.Pointer(pFrom)).FiHash + libc.X__builtin___memcpy_chk(tls, (*TStatSample)(unsafe.Pointer(pTo)).FanEq, (*TStatSample)(unsafe.Pointer(pFrom)).FanEq, uint64(8)*libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnCol), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TStatSample)(unsafe.Pointer(pTo)).FanLt, (*TStatSample)(unsafe.Pointer(pFrom)).FanLt, uint64(8)*libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnCol), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TStatSample)(unsafe.Pointer(pTo)).FanDLt, (*TStatSample)(unsafe.Pointer(pFrom)).FanDLt, uint64(8)*libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnCol), ^t__predefined_size_t(0)) + if (*TStatSample)(unsafe.Pointer(pFrom)).FnRowid != 0 { + _sampleSetRowid(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, pTo, libc.Int32FromUint32((*TStatSample)(unsafe.Pointer(pFrom)).FnRowid), *(*uintptr)(unsafe.Pointer(pFrom + 24))) + } else { + _sampleSetRowidInt64(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, pTo, *(*Ti64)(unsafe.Pointer(pFrom + 24))) + } +} + +// C documentation +// +// /* +// ** Copy the contents of sample *pNew into the p->a[] array. If necessary, +// ** remove the least desirable sample from p->a[] to make room. +// */ +func _sampleInsert(tls *libc.TLS, p uintptr, pNew uintptr, nEqZero int32) { + var anDLt, anEq, anLt, pMin, pOld, pSample, pUpgrade uintptr + var i, iMin int32 + _, _, _, _, _, _, _, _, _ = anDLt, anEq, anLt, i, iMin, pMin, pOld, pSample, pUpgrade + pSample = uintptr(0) + /* StatAccum.nMaxEqZero is set to the maximum number of leading 0 + ** values in the anEq[] array of any sample in StatAccum.a[]. In + ** other words, if nMaxEqZero is n, then it is guaranteed that there + ** are no samples with StatSample.anEq[m]==0 for (m>=n). */ + if nEqZero > (*TStatAccum)(unsafe.Pointer(p)).FnMaxEqZero { + (*TStatAccum)(unsafe.Pointer(p)).FnMaxEqZero = nEqZero + } + if libc.Int32FromUint8((*TStatSample)(unsafe.Pointer(pNew)).FisPSample) == 0 { + pUpgrade = uintptr(0) + /* This sample is being added because the prefix that ends in column + ** iCol occurs many times in the table. However, if we have already + ** added a sample that shares this prefix, there is no need to add + ** this one. Instead, upgrade the priority of the highest priority + ** existing sample that shares this prefix. */ + i = (*TStatAccum)(unsafe.Pointer(p)).FnSample - int32(1) + for { + if !(i >= 0) { + break + } + pOld = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48 + if **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pOld)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pNew)).FiCol)*8)) == uint64(0) { + if (*TStatSample)(unsafe.Pointer(pOld)).FisPSample != 0 { + return + } + if pUpgrade == uintptr(0) || _sampleIsBetter(tls, p, pOld, pUpgrade) != 0 { + pUpgrade = pOld + } + } + goto _1 + _1: + ; + i = i - 1 + } + if pUpgrade != 0 { + (*TStatSample)(unsafe.Pointer(pUpgrade)).FiCol = (*TStatSample)(unsafe.Pointer(pNew)).FiCol + **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pUpgrade)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pUpgrade)).FiCol)*8)) = **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pNew)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pUpgrade)).FiCol)*8)) + goto find_new_min + } + } + /* If necessary, remove sample iMin to make room for the new sample. */ + if (*TStatAccum)(unsafe.Pointer(p)).FnSample >= (*TStatAccum)(unsafe.Pointer(p)).FmxSample { + pMin = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiMin)*48 + anEq = (*TStatSample)(unsafe.Pointer(pMin)).FanEq + anLt = (*TStatSample)(unsafe.Pointer(pMin)).FanLt + anDLt = (*TStatSample)(unsafe.Pointer(pMin)).FanDLt + _sampleClear(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, pMin) + libc.X__builtin___memmove_chk(tls, pMin, pMin+1*48, uint64(48)*libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnSample-(*TStatAccum)(unsafe.Pointer(p)).FiMin-libc.Int32FromInt32(1)), ^t__predefined_size_t(0)) + pSample = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FnSample-int32(1))*48 + (*TStatSample)(unsafe.Pointer(pSample)).FnRowid = uint32(0) + (*TStatSample)(unsafe.Pointer(pSample)).FanEq = anEq + (*TStatSample)(unsafe.Pointer(pSample)).FanDLt = anDLt + (*TStatSample)(unsafe.Pointer(pSample)).FanLt = anLt + (*TStatAccum)(unsafe.Pointer(p)).FnSample = (*TStatAccum)(unsafe.Pointer(p)).FmxSample - int32(1) + } + /* The "rows less-than" for the rowid column must be greater than that + ** for the last sample in the p->a[] array. Otherwise, the samples would + ** be out of order. */ + /* Insert the new sample */ + pSample = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FnSample)*48 + _sampleCopy(tls, p, pSample, pNew) + (*TStatAccum)(unsafe.Pointer(p)).FnSample = (*TStatAccum)(unsafe.Pointer(p)).FnSample + 1 + /* Zero the first nEqZero entries in the anEq[] array. */ + libc.X__builtin___memset_chk(tls, (*TStatSample)(unsafe.Pointer(pSample)).FanEq, 0, uint64(8)*libc.Uint64FromInt32(nEqZero), ^t__predefined_size_t(0)) + goto find_new_min +find_new_min: + ; + if (*TStatAccum)(unsafe.Pointer(p)).FnSample >= (*TStatAccum)(unsafe.Pointer(p)).FmxSample { + iMin = -int32(1) + i = 0 + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FmxSample) { + break + } + if (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48))).FisPSample != 0 { + goto _2 + } + if iMin < 0 || _sampleIsBetter(tls, p, (*TStatAccum)(unsafe.Pointer(p)).Fa+uintptr(iMin)*48, (*TStatAccum)(unsafe.Pointer(p)).Fa+uintptr(i)*48) != 0 { + iMin = i + } + goto _2 + _2: + ; + i = i + 1 + } + (*TStatAccum)(unsafe.Pointer(p)).FiMin = iMin + } +} + +// C documentation +// +// /* Initialize the BLOB value of a ROWID +// */ +func _sampleSetRowid(tls *libc.TLS, db uintptr, p uintptr, n int32, pData uintptr) { + if (*TStatSample)(unsafe.Pointer(p)).FnRowid != 0 { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 24))) + } + *(*uintptr)(unsafe.Pointer(p + 24)) = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(n)) + if *(*uintptr)(unsafe.Pointer(p + 24)) != 0 { + (*TStatSample)(unsafe.Pointer(p)).FnRowid = libc.Uint32FromInt32(n) + libc.X__builtin___memcpy_chk(tls, *(*uintptr)(unsafe.Pointer(p + 24)), pData, libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + } else { + (*TStatSample)(unsafe.Pointer(p)).FnRowid = uint32(0) + } +} + +// C documentation +// +// /* +// ** The cursor passed as the only argument must point to a valid entry +// ** when this function is called (i.e. have eState==CURSOR_VALID). This +// ** function saves the current cursor key in variables pCur->nKey and +// ** pCur->pKey. SQLITE_OK is returned if successful or an SQLite error +// ** code otherwise. +// ** +// ** If the cursor is open on an intkey table, then the integer key +// ** (the rowid) is stored in pCur->nKey and pCur->pKey is left set to +// ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is +// ** set to point to a malloced buffer pCur->nKey bytes in size containing +// ** the key. +// */ +func _saveCursorKey(tls *libc.TLS, pCur uintptr) (r int32) { + var pKey uintptr + var rc int32 + _, _ = pKey, rc + rc = SQLITE_OK + if (*TBtCursor)(unsafe.Pointer(pCur)).FcurIntKey != 0 { + /* Only the rowid is required for a table btree */ + (*TBtCursor)(unsafe.Pointer(pCur)).FnKey = _sqlite3BtreeIntegerKey(tls, pCur) + } else { + (*TBtCursor)(unsafe.Pointer(pCur)).FnKey = libc.Int64FromUint32(_sqlite3BtreePayloadSize(tls, pCur)) + pKey = _sqlite3Malloc(tls, libc.Uint64FromInt64((*TBtCursor)(unsafe.Pointer(pCur)).FnKey+int64(9)+int64(8))) + if pKey != 0 { + rc = _sqlite3BtreePayload(tls, pCur, uint32(0), libc.Uint32FromInt32(int32((*TBtCursor)(unsafe.Pointer(pCur)).FnKey)), pKey) + if rc == SQLITE_OK { + libc.X__builtin___memset_chk(tls, pKey+uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FnKey), 0, libc.Uint64FromInt32(libc.Int32FromInt32(9)+libc.Int32FromInt32(8)), ^t__predefined_size_t(0)) + (*TBtCursor)(unsafe.Pointer(pCur)).FpKey = pKey + } else { + Xsqlite3_free(tls, pKey) + } + } else { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +// C documentation +// +// /* +// ** Seek to the offset passed as the second argument, then read cnt +// ** bytes into pBuf. Return the number of bytes actually read. +// ** +// ** To avoid stomping the errno value on a failed read the lastErrno value +// ** is set before returning. +// */ +func _seekAndRead(tls *libc.TLS, id uintptr, offset Tsqlite3_int64, pBuf uintptr, cnt int32) (r int32) { + var got, prior int32 + _, _ = got, prior + prior = 0 + for cond := true; cond; cond = got > 0 { + got = int32((*(*func(*libc.TLS, int32, uintptr, Tsize_t, Toff_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(9)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(id)).Fh, pBuf, libc.Uint64FromInt32(cnt), offset)) + if got == cnt { + break + } + if got < 0 { + if **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(EINTR) { + got = int32(1) + continue + } + prior = 0 + _storeLastErrno(tls, id, **(**int32)(__ccgo_up(libc.X__error(tls)))) + break + } else { + if got > 0 { + cnt = cnt - got + offset = offset + int64(got) + prior = prior + got + pBuf = uintptr(got) + pBuf + } + } + } + return got + prior +} + +// C documentation +// +// /* +// ** Attempt to seek the file-descriptor passed as the first argument to +// ** absolute offset iOff, then attempt to write nBuf bytes of data from +// ** pBuf to it. If an error occurs, return -1 and set *piErrno. Otherwise, +// ** return the actual number of bytes written (which may be less than +// ** nBuf). +// */ +func _seekAndWriteFd(tls *libc.TLS, fd int32, iOff Ti64, pBuf uintptr, nBuf int32, piErrno uintptr) (r int32) { + var rc int32 + _ = rc + rc = 0 /* Value returned by system call */ + nBuf = nBuf & int32(0x1ffff) + for cond := true; cond; cond = rc < 0 && **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(EINTR) { + rc = int32((*(*func(*libc.TLS, int32, uintptr, Tsize_t, Toff_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(12)].FpCurrent})))(tls, fd, pBuf, libc.Uint64FromInt32(nBuf), iOff)) + } + if rc < 0 { + **(**int32)(__ccgo_up(piErrno)) = **(**int32)(__ccgo_up(libc.X__error(tls))) + } + return rc +} + +// C documentation +// +// /* +// ** The xExpr callback for the search of invalid ON clause terms. +// */ +func _selectCheckOnClausesExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iTab, ii, nSrc int32 + var pCtx, pSrc, v2 uintptr + _, _, _, _, _, _ = iTab, ii, nSrc, pCtx, pSrc, v2 + pCtx = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + /* Check if pExpr is root or near-root of an ON clause constraint that needs + ** to be checked to ensure that it does not refer to tables in its FROM + ** clause to the right of itself. i.e. it is either: + ** + ** + an ON clause on an OUTER join, or + ** + an ON clause on an INNER join within a FROM that features at + ** least one RIGHT or FULL join. + */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) != uint32(0) && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TCheckOnCtx)(unsafe.Pointer(pCtx)).FpSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + /* If CheckOnCtx.iJoin is already set, then fall through and process + ** this expression node as normal. Or, if CheckOnCtx.iJoin is still 0, + ** set it to the cursor number of the RHS of the join to which this + ** ON expression was attached and then iterate through the entire + ** expression. */ + if (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin == 0 { + (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin = *(*int32)(unsafe.Pointer(pExpr + 52)) + _sqlite3WalkExprNN(tls, pWalker, pExpr) + (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin = 0 + return int32(WRC_Prune) + } + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) { + /* A column expression. Find the SrcList (if any) to which it refers. + ** Then, if CheckOnCtx.iJoin indicates that this expression is part of an + ** ON clause from that SrcList (i.e. if iJoin is non-zero), check that it + ** does not refer to a table to the right of CheckOnCtx.iJoin. */ + for cond := true; cond; cond = pCtx != 0 { + pSrc = (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FpSrc + nSrc = (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc + iTab = (*TExpr)(unsafe.Pointer(pExpr)).FiTable + ii = 0 + for { + if !(ii < nSrc && (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(ii)*80))).FiCursor != iTab) { + break + } + goto _1 + _1: + ; + ii = ii + 1 + } + if ii < nSrc { + if (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin != 0 && iTab > (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin { + if (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FbFuncArg != 0 { + v2 = __ccgo_ts + 21911 + } else { + v2 = __ccgo_ts + 21935 + } + _sqlite3ErrorMsg(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, __ccgo_ts+21945, libc.VaList(bp+8, v2)) + return int32(WRC_Abort) + } + break + } + pCtx = (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FpParent + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** The xSelect callback for the search of invalid ON clause terms. +// */ +func _selectCheckOnClausesSelect(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pCtx uintptr + var _ /* sCtx at bp+0 */ TCheckOnCtx + _ = pCtx + pCtx = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + if (*TSelect)(unsafe.Pointer(pSelect)).FpSrc == (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FpSrc || (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc == 0 { + return WRC_Continue + } else { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(24), ^t__predefined_size_t(0)) + (**(**TCheckOnCtx)(__ccgo_up(bp))).FpSrc = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + (**(**TCheckOnCtx)(__ccgo_up(bp))).FpParent = pCtx + *(*uintptr)(unsafe.Pointer(pWalker + 40)) = bp + _sqlite3WalkSelect(tls, pWalker, pSelect) + *(*uintptr)(unsafe.Pointer(pWalker + 40)) = pCtx + **(**Tu32)(__ccgo_up(pSelect + 4)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SF_OnToWhere)) + return int32(WRC_Prune) + } + return r +} + +// C documentation +// +// /* +// ** This routine is a Walker callback for "expanding" a SELECT statement. +// ** "Expanding" means to do the following: +// ** +// ** (1) Make sure VDBE cursor numbers have been assigned to every +// ** element of the FROM clause. +// ** +// ** (2) Fill in the pTabList->a[].pTab fields in the SrcList that +// ** defines FROM clause. When views appear in the FROM clause, +// ** fill pTabList->a[].pSelect with a copy of the SELECT statement +// ** that implements the view. A copy is made of the view's SELECT +// ** statement so that we can freely modify or delete that statement +// ** without worrying about messing up the persistent representation +// ** of the view. +// ** +// ** (3) Add terms to the WHERE clause to accommodate the NATURAL keyword +// ** on joins and the ON and USING clause of joins. +// ** +// ** (4) Scan the list of columns in the result set (pEList) looking +// ** for instances of the "*" operator or the TABLE.* operator. +// ** If found, expand each "*" to be every column in every table +// ** and TABLE.* to be every column in TABLE. +// ** +// */ +func _selectExpander(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a, db, pE, pEList, pExpr, pFrom, pLeft, pNestedFrom, pNew, pParse, pRight, pSel, pTab, pTab1, pTabList, pUsing, pX, pX1, zName, zSchemaName, zTName, zTabName, zUName, v2 uintptr + var eCodeOrig Tu8 + var elistFlags Tu32 + var flags, i, iDb, iErrOfst, ii, j, k, longNames, nAdd, rc, tableSeen, v1 int32 + var nCol Ti16 + var selFlags Tu16 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, db, eCodeOrig, elistFlags, flags, i, iDb, iErrOfst, ii, j, k, longNames, nAdd, nCol, pE, pEList, pExpr, pFrom, pLeft, pNestedFrom, pNew, pParse, pRight, pSel, pTab, pTab1, pTabList, pUsing, pX, pX1, rc, selFlags, tableSeen, zName, zSchemaName, zTName, zTabName, zUName, v1, v2 + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + selFlags = uint16((*TSelect)(unsafe.Pointer(p)).FselFlags) + elistFlags = uint32(0) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_Expanded) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + if libc.Int32FromUint16(selFlags)&int32(SF_Expanded) != 0 { + return int32(WRC_Prune) + } + if (*TWalker)(unsafe.Pointer(pWalker)).FeCode != 0 { + /* Renumber selId because it has been copied from a view */ + v2 = pParse + 124 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TSelect)(unsafe.Pointer(p)).FselId = libc.Uint32FromInt32(v1) + } + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + pEList = (*TSelect)(unsafe.Pointer(p)).FpEList + if (*TParse)(unsafe.Pointer(pParse)).FpWith != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_View) != 0 { + if (*TSelect)(unsafe.Pointer(p)).FpWith == uintptr(0) { + (*TSelect)(unsafe.Pointer(p)).FpWith = _sqlite3DbMallocZero(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+16)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(48))) + if (*TSelect)(unsafe.Pointer(p)).FpWith == uintptr(0) { + return int32(WRC_Abort) + } + } + (*TWith)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpWith)).FbView = int32(1) + } + _sqlite3WithPush(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWith, uint8(0)) + /* Make sure cursor numbers have been assigned to all entries in + ** the FROM clause of the SELECT statement. + */ + _sqlite3SrcListAssignCursors(tls, pParse, pTabList) + /* Look up every table named in the FROM clause of the select. If + ** an entry of the FROM clause is a subquery instead of a table or view, + ** then create a transient table structure to describe the subquery. + */ + i = 0 + pFrom = pTabList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + if (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab != 0 { + goto _3 + } + if (*TSrcItem)(unsafe.Pointer(pFrom)).FzName == uintptr(0) { + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + /* A sub-query in the FROM clause of a SELECT */ + if _sqlite3WalkSelect(tls, pWalker, pSel) != 0 { + return int32(WRC_Abort) + } + if _sqlite3ExpandSubquery(tls, pParse, pFrom) != 0 { + return int32(WRC_Abort) + } + } else { + v1 = _resolveFromTermToCte(tls, pParse, pWalker, pFrom) + rc = v1 + if v1 != 0 { + if rc > int32(1) { + return int32(WRC_Abort) + } + pTab = (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab + } else { + /* An ordinary table or view name in the FROM clause */ + v2 = _sqlite3LocateTableItem(tls, pParse, uint32(0), pFrom) + pTab = v2 + (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab = v2 + if pTab == uintptr(0) { + return int32(WRC_Abort) + } + if (*TTable)(unsafe.Pointer(pTab)).FnTabRef >= uint32(0xffff) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21606, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab = uintptr(0) + return int32(WRC_Abort) + } + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) && _cannotBeFunction(tls, pParse, pFrom) != 0 { + return int32(WRC_Abort) + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + eCodeOrig = uint8((*TWalker)(unsafe.Pointer(pWalker)).FeCode) + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + return int32(WRC_Abort) + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_EnableView) == uint64(0) && (*TTable)(unsafe.Pointer(pTab)).FpSchema != (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21645, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + _sqlite3SrcItemAttachSubquery(tls, pParse, pFrom, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTab)).Fu))).FpSelect, int32(1)) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) && (int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x100>>8) != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_FROM_DDL) != 0) && (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp != uintptr(0) && libc.Int32FromUint8((*TVTable)(unsafe.Pointer((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp)).FeVtabRisk) > libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_TrustedSchema) != uint64(0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16689, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + } + nCol = (*TTable)(unsafe.Pointer(pTab)).FnCol + (*TTable)(unsafe.Pointer(pTab)).FnCol = int16(-int32(1)) + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(1) /* Turn on Select.selId renumbering */ + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x4>>2) != 0 { + _sqlite3WalkSelect(tls, pWalker, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect) + } + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(eCodeOrig) + (*TTable)(unsafe.Pointer(pTab)).FnCol = nCol + } + } + } + /* Locate the index named by the INDEXED BY clause, if any. */ + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x2>>1) != 0 && _sqlite3IndexedByLookup(tls, pParse, pFrom) != 0 { + return int32(WRC_Abort) + } + goto _3 + _3: + ; + i = i + 1 + pFrom += 80 + } + /* Process NATURAL keywords, and ON and USING clauses of joins. + */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 || _sqlite3ProcessJoin(tls, pParse, p) != 0 { + return int32(WRC_Abort) + } + /* For every "*" that occurs in the column list, insert the names of + ** all columns in all tables. And for every TABLE.* insert the names + ** of all columns in TABLE. The parser inserted a special expression + ** with the TK_ASTERISK operator for each "*" that it found in the column + ** list. The following code just has to locate the TK_ASTERISK + ** expressions and expand each one to the list of all columns in + ** all tables. + ** + ** The first loop just checks to see if there are any "*" operators + ** that need expanding. + */ + k = 0 + for { + if !(k < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + pE = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(k)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_ASTERISK) { + break + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_DOT) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pE)).FpRight)).Fop) == int32(TK_ASTERISK) { + break + } + elistFlags = elistFlags | (*TExpr)(unsafe.Pointer(pE)).Fflags + goto _6 + _6: + ; + k = k + 1 + } + if k < (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + /* + ** If we get here it means the result set contains one or more "*" + ** operators that need to be expanded. Loop through each expression + ** in the result set and expand them one by one. + */ + a = pEList + 8 + pNew = uintptr(0) + flags = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags) + longNames = libc.BoolInt32(flags&int32(SQLITE_FullColNames) != 0 && flags&int32(SQLITE_ShortColNames) == 0) + k = 0 + for { + if !(k < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + pE = (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FpExpr + elistFlags = elistFlags | (*TExpr)(unsafe.Pointer(pE)).Fflags + pRight = (*TExpr)(unsafe.Pointer(pE)).FpRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) != int32(TK_ASTERISK) && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) != int32(TK_DOT) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) != int32(TK_ASTERISK)) { + /* This particular expression does not need to be expanded. + */ + pNew = _sqlite3ExprListAppend(tls, pParse, pNew, (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FpExpr) + if pNew != 0 { + (*(*TExprList_item)(unsafe.Pointer(pNew + 8 + uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32))).FzEName = (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FzEName + libc.SetBitFieldPtr16Uint32(pNew+8+uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32+16+4, libc.Uint32FromInt32(int32(uint32(*(*uint16)(unsafe.Pointer(a + uintptr(k)*32 + 16 + 4))&0x3>>0))), 0, 0x3) + (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FzEName = uintptr(0) + } + (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FpExpr = uintptr(0) + } else { + /* This expression is a "*" or a "TABLE.*" and needs to be + ** expanded. */ + tableSeen = 0 /* Set to 1 when TABLE matches */ + zTName = uintptr(0) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_DOT) { + zTName = *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pE)).FpLeft + 8)) + iErrOfst = *(*int32)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pE)).FpRight + 52)) + } else { + iErrOfst = *(*int32)(unsafe.Pointer(pE + 52)) + } + i = 0 + pFrom = pTabList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } /* Number of cols including rowid */ + pTab1 = (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab /* AS name for this data source */ + zSchemaName = uintptr(0) /* USING clause for pFrom[1] */ + v2 = (*TSrcItem)(unsafe.Pointer(pFrom)).FzAlias + zTabName = v2 + if v2 == uintptr(0) { + zTabName = (*TTable)(unsafe.Pointer(pTab1)).FzName + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + break + } + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x4000>>14) != 0 { + pNestedFrom = (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect)).FpEList + } else { + if zTName != 0 && _sqlite3StrICmp(tls, zTName, zTabName) != 0 { + goto _8 + } + pNestedFrom = uintptr(0) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab1)).FpSchema) + if iDb >= 0 { + v2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + v2 = __ccgo_ts + 7165 + } + zSchemaName = v2 + } + if i+int32(1) < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc && int32(*(*uint32)(unsafe.Pointer(pFrom + 1*80 + 24 + 4))&0x800>>11) != 0 && libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) != 0 { + pUsing = *(*uintptr)(unsafe.Pointer(pFrom + 1*80 + 64)) + ii = 0 + for { + if !(ii < (*TIdList)(unsafe.Pointer(pUsing)).FnId) { + break + } + zUName = (*(*TIdList_item)(unsafe.Pointer(pUsing + 8 + uintptr(ii)*8))).FzName + pRight = _sqlite3Expr(tls, db, int32(TK_ID), zUName) + _sqlite3ExprSetErrorOffset(tls, pRight, iErrOfst) + pNew = _sqlite3ExprListAppend(tls, pParse, pNew, pRight) + if pNew != 0 { + pX = pNew + 8 + uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32 + (*TExprList_item)(unsafe.Pointer(pX)).FzEName = _sqlite3MPrintf(tls, db, __ccgo_ts+21676, libc.VaList(bp+8, zUName)) + libc.SetBitFieldPtr16Uint32(pX+16+4, libc.Uint32FromInt32(ENAME_TAB), 0, 0x3) + libc.SetBitFieldPtr16Uint32(pX+16+4, libc.Uint32FromInt32(1), 7, 0x80) + } + goto _11 + _11: + ; + ii = ii + 1 + } + } else { + pUsing = uintptr(0) + } + nAdd = int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) + if (*TTable)(unsafe.Pointer(pTab1)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) && libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) != 0 { + nAdd = nAdd + 1 + } + j = 0 + for { + if !(j < nAdd) { + break + } /* Newly added ExprList term */ + if j == int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) { + zName = _sqlite3RowidAlias(tls, pTab1) + if zName == uintptr(0) { + goto _12 + } + } else { + zName = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(j)*16))).FzCnName + /* If pTab is actually an SF_NestedFrom sub-select, do not + ** expand any ENAME_ROWID columns. */ + if pNestedFrom != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pNestedFrom + 8 + uintptr(j)*32 + 16 + 4))&0x3>>0)) == int32(ENAME_ROWID) { + goto _12 + } + if zTName != 0 && pNestedFrom != 0 && _sqlite3MatchEName(tls, pNestedFrom+8+uintptr(j)*32, uintptr(0), zTName, uintptr(0), uintptr(0)) == 0 { + goto _12 + } + /* If a column is marked as 'hidden', omit it from the expanded + ** result-set list unless the SELECT has the SF_IncludeHidden + ** bit set. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_IncludeHidden) == uint32(0) && libc.Int32FromUint16((*TColumn)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab1)).FaCol+uintptr(j)*16)).FcolFlags)&int32(COLFLAG_HIDDEN) != 0 { + goto _12 + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_NOEXPAND) != 0 && zTName == uintptr(0) && libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) == 0 { + goto _12 + } + } + tableSeen = int32(1) + if i > 0 && zTName == uintptr(0) && libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) == 0 { + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x800>>11) != 0 && _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pFrom + 64)), zName) >= 0 { + /* In a join with a USING clause, omit columns in the + ** using clause from the table on the right. */ + goto _12 + } + } + pRight = _sqlite3Expr(tls, db, int32(TK_ID), zName) + if (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc > int32(1) && (libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pFrom)).Ffg.Fjointype)&int32(JT_LTORJ) == 0 || libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) != 0 || !(_inAnyUsingClause(tls, zName, pFrom, (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc-i-int32(1)) != 0)) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + pLeft = _sqlite3Expr(tls, db, int32(TK_ID), zTabName) + pExpr = _sqlite3PExpr(tls, pParse, int32(TK_DOT), pLeft, pRight) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TExpr)(unsafe.Pointer(pE)).FpLeft != 0 { + _sqlite3RenameTokenRemap(tls, pParse, pLeft, (*TExpr)(unsafe.Pointer(pE)).FpLeft) + } + if zSchemaName != 0 { + pLeft = _sqlite3Expr(tls, db, int32(TK_ID), zSchemaName) + pExpr = _sqlite3PExpr(tls, pParse, int32(TK_DOT), pLeft, pExpr) + } + } else { + pExpr = pRight + } + _sqlite3ExprSetErrorOffset(tls, pExpr, iErrOfst) + pNew = _sqlite3ExprListAppend(tls, pParse, pNew, pExpr) + if pNew == uintptr(0) { + break /* OOM */ + } + pX1 = pNew + 8 + uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32 + if libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) != 0 && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if pNestedFrom != 0 && libc.Bool(libc.Bool(!(libc.Int32FromInt32(ViewCanHaveRowid) != 0)) || j < (*TExprList)(unsafe.Pointer(pNestedFrom)).FnExpr) { + (*TExprList_item)(unsafe.Pointer(pX1)).FzEName = _sqlite3DbStrDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pNestedFrom + 8 + uintptr(j)*32))).FzEName) + } else { + (*TExprList_item)(unsafe.Pointer(pX1)).FzEName = _sqlite3MPrintf(tls, db, __ccgo_ts+21681, libc.VaList(bp+8, zSchemaName, zTabName, zName)) + } + if j == int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) { + v1 = int32(ENAME_ROWID) + } else { + v1 = int32(ENAME_TAB) + } + libc.SetBitFieldPtr16Uint32(pX1+16+4, libc.Uint32FromInt32(v1), 0, 0x3) + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x800>>11) != 0 && _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pFrom + 64)), zName) >= 0 || pUsing != 0 && _sqlite3IdListIndex(tls, pUsing, zName) >= 0 || j < int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_NOEXPAND) != 0 { + libc.SetBitFieldPtr16Uint32(pX1+16+4, libc.Uint32FromInt32(1), 8, 0x100) + } + } else { + if longNames != 0 { + (*TExprList_item)(unsafe.Pointer(pX1)).FzEName = _sqlite3MPrintf(tls, db, __ccgo_ts+13976, libc.VaList(bp+8, zTabName, zName)) + libc.SetBitFieldPtr16Uint32(pX1+16+4, libc.Uint32FromInt32(ENAME_NAME), 0, 0x3) + } else { + (*TExprList_item)(unsafe.Pointer(pX1)).FzEName = _sqlite3DbStrDup(tls, db, zName) + libc.SetBitFieldPtr16Uint32(pX1+16+4, libc.Uint32FromInt32(ENAME_NAME), 0, 0x3) + } + } + goto _12 + _12: + ; + j = j + 1 + } + goto _8 + _8: + ; + i = i + 1 + pFrom += 80 + } + if !(tableSeen != 0) { + if zTName != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21690, libc.VaList(bp+8, zTName)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21708, 0) + } + } + } + goto _7 + _7: + ; + k = k + 1 + } + _sqlite3ExprListDelete(tls, db, pEList) + (*TSelect)(unsafe.Pointer(p)).FpEList = pNew + } + if (*TSelect)(unsafe.Pointer(p)).FpEList != 0 { + if (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21728, 0) + return int32(WRC_Abort) + } + if elistFlags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)|libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_ComplexResult) + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** This routine generates the code for the inside of the inner loop +// ** of a SELECT. +// ** +// ** If srcTab is negative, then the p->pEList expressions +// ** are evaluated in order to get the data for this row. If srcTab is +// ** zero or more, then data is pulled from srcTab and p->pEList is used only +// ** to get the number of columns and the collation sequence for each column. +// */ +func _selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSort uintptr, pDistinct uintptr, pDest uintptr, iContinue int32, iBreak int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var addr, addrTest, eDest, eType, hasDistinct, i, i2, iParm, iTab, j, nKey, nPrefixReg, nResultCol, r1, r11, r12, r13, r2, r21, r3, regOrig, regResult, v1 int32 + var ecelFlags Tu8 + var pEList, pSO, v uintptr + var _ /* sRowLoadInfo at bp+0 */ TRowLoadInfo + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrTest, eDest, eType, ecelFlags, hasDistinct, i, i2, iParm, iTab, j, nKey, nPrefixReg, nResultCol, pEList, pSO, r1, r11, r12, r13, r2, r21, r3, regOrig, regResult, v, v1 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* True if the DISTINCT keyword is present */ + eDest = libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) /* How to dispose of results */ + iParm = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm /* Number of result columns */ + nPrefixReg = 0 /* Start of memory holding full result (or 0) */ + if pDistinct != 0 { + v1 = libc.Int32FromUint8((*TDistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType) + } else { + v1 = WHERE_DISTINCT_NOOP + } + hasDistinct = v1 + if pSort != 0 && (*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy == uintptr(0) { + pSort = uintptr(0) + } + if pSort == uintptr(0) && !(hasDistinct != 0) { + _codeOffset(tls, v, (*TSelect)(unsafe.Pointer(p)).FiOffset, iContinue) + } + /* Pull the requested columns. + */ + nResultCol = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 { + if pSort != 0 { + nPrefixReg = (*TExprList)(unsafe.Pointer((*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr + if !(libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&libc.Int32FromInt32(SORTFLAG_UseSorter) != 0) { + nPrefixReg = nPrefixReg + 1 + } + **(**int32)(__ccgo_up(pParse + 60)) += nPrefixReg + } + (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nResultCol + } else { + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst+nResultCol > (*TParse)(unsafe.Pointer(pParse)).FnMem { + /* This is an error condition that can result, for example, when a SELECT + ** on the right-hand side of an INSERT contains more result columns than + ** there are columns in the table on the left. The error will be caught + ** and reported later. But we need to make sure enough memory is allocated + ** to avoid other spurious errors in the meantime. */ + **(**int32)(__ccgo_up(pParse + 60)) += nResultCol + } + } + (*TSelectDest)(unsafe.Pointer(pDest)).FnSdst = nResultCol + v1 = (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst + regResult = v1 + regOrig = v1 + if srcTab >= 0 { + i = 0 + for { + if !(i < nResultCol) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), srcTab, i, regResult+i) + goto _3 + _3: + ; + i = i + 1 + } + } else { + if eDest != int32(SRT_Exists) { + if eDest == int32(SRT_Mem) || eDest == int32(SRT_Output) || eDest == int32(SRT_Coroutine) { + ecelFlags = uint8(SQLITE_ECEL_DUP) + } else { + ecelFlags = uint8(0) + } + if pSort != 0 && hasDistinct == 0 && eDest != int32(SRT_EphemTab) && eDest != int32(SRT_Table) { + /* For each expression in p->pEList that is a copy of an expression in + ** the ORDER BY clause (pSort->pOrderBy), set the associated + ** iOrderByCol value to one more than the index of the ORDER BY + ** expression within the sort-key that pushOntoSorter() will generate. + ** This allows the p->pEList field to be omitted from the sorted record, + ** saving space and CPU cycles. */ + ecelFlags = libc.Uint8FromInt32(int32(ecelFlags) | (libc.Int32FromInt32(SQLITE_ECEL_OMITREF) | libc.Int32FromInt32(SQLITE_ECEL_REF))) + i = (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + for { + if !(i < (*TExprList)(unsafe.Pointer((*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr) { + break + } + v1 = libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer((*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy + 8 + uintptr(i)*32 + 24))) + j = v1 + if v1 > 0 { + *(*Tu16)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8 + uintptr(j-int32(1))*32 + 24)) = libc.Uint16FromInt32(i + int32(1) - (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat) + } + goto _4 + _4: + ; + i = i + 1 + } + /* Adjust nResultCol to account for columns that are omitted + ** from the sorter by the optimizations in this branch */ + pEList = (*TSelect)(unsafe.Pointer(p)).FpEList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pEList + 8 + uintptr(i)*32 + 24))) > 0 { + nResultCol = nResultCol - 1 + regOrig = 0 + } + goto _6 + _6: + ; + i = i + 1 + } + } + (**(**TRowLoadInfo)(__ccgo_up(bp))).FregResult = regResult + (**(**TRowLoadInfo)(__ccgo_up(bp))).FecelFlags = ecelFlags + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 && libc.Int32FromUint8(ecelFlags)&int32(SQLITE_ECEL_OMITREF) != 0 && nPrefixReg > 0 { + (*TSortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad = bp + regOrig = 0 + } else { + _innerLoopLoadRow(tls, pParse, p, bp) + } + } + } + /* If the DISTINCT keyword was present on the SELECT statement + ** and this row has been seen before, then do not make this row + ** part of the result. + */ + if hasDistinct != 0 { + eType = libc.Int32FromUint8((*TDistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType) + iTab = (*TDistinctCtx)(unsafe.Pointer(pDistinct)).FtabTnct + iTab = _codeDistinct(tls, pParse, eType, iTab, iContinue, (*TSelect)(unsafe.Pointer(p)).FpEList, regResult) + _fixDistinctOpenEph(tls, pParse, eType, iTab, (*TDistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct) + if pSort == uintptr(0) { + _codeOffset(tls, v, (*TSelect)(unsafe.Pointer(p)).FiOffset, iContinue) + } + } + switch eDest { + /* Store the result as data using a unique key. + */ + case int32(SRT_Fifo): + fallthrough + case int32(SRT_DistFifo): + fallthrough + case int32(SRT_Table): + fallthrough + case int32(SRT_EphemTab): + r1 = _sqlite3GetTempRange(tls, pParse, nPrefixReg+int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regResult, nResultCol, r1+nPrefixReg) + if eDest == int32(SRT_DistFifo) { + /* If the destination is DistFifo, then cursor (iParm+1) is open + ** on an ephemeral index. If the current row is already present + ** in the index, do not write it to the output. If not, add the + ** current row to the index and proceed with writing it to the + ** output table as well. */ + addr = _sqlite3VdbeCurrentAddr(tls, v) + int32(4) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iParm+int32(1), addr, r1, 0) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm+int32(1), r1, regResult, nResultCol) + } + if pSort != 0 { + _pushOntoSorter(tls, pParse, pSort, p, r1+nPrefixReg, regOrig, int32(1), nPrefixReg) + } else { + r2 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iParm, r2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, r1, r2) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + _sqlite3ReleaseTempReg(tls, pParse, r2) + } + _sqlite3ReleaseTempRange(tls, pParse, r1, nPrefixReg+int32(1)) + case int32(SRT_Upfrom): + if pSort != 0 { + _pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) + } else { + i2 = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 + r11 = _sqlite3GetTempReg(tls, pParse) + /* If the UPDATE FROM join is an aggregate that matches no rows, it + ** might still be trying to return one row, because that is what + ** aggregates do. Don't record that empty row in the output table. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regResult, iBreak) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regResult+libc.BoolInt32(i2 < 0), nResultCol-libc.BoolInt32(i2 < 0), r11) + if i2 < 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, r11, regResult) + } else { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, r11, regResult, i2) + } + } + break + /* If we are creating a set for an "expr IN (SELECT ...)" construct, + ** then there should be a single item on the stack. Write this + ** item into the set table with bogus data. + */ + fallthrough + case int32(SRT_Set): + if pSort != 0 { + /* At first glance you would think we could optimize out the + ** ORDER BY in this case since the order of entries in the set + ** does not matter. But there might be a LIMIT clause, in which + ** case the order does matter */ + _pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) + (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 = 0 /* Signal that any Bloom filter is unpopulated */ + } else { + r12 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), regResult, nResultCol, r12, (*TSelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nResultCol) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, r12, regResult, nResultCol) + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2, 0, regResult, nResultCol) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20858, 0) + } + _sqlite3ReleaseTempReg(tls, pParse, r12) + } + break + /* If any row exist in the result set, record that fact and abort. + */ + fallthrough + case int32(SRT_Exists): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), iParm) + /* The LIMIT clause will terminate the loop for us */ + break + /* If this is a scalar select that is part of an expression, then + ** store the results in the appropriate memory cell or array of + ** memory cells and break out of the scan loop. + */ + fallthrough + case int32(SRT_Mem): + if pSort != 0 { + _pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) + (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm = regResult + } else { + if regResult != iParm { + /* This occurs in cases where the SELECT had both a DISTINCT and + ** an OFFSET clause. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regResult, iParm, nResultCol-int32(1)) + } + /* The LIMIT clause will jump out of the loop for us */ + } + case int32(SRT_Coroutine): /* Send data to a co-routine */ + fallthrough + case int32(SRT_Output): /* Return the results */ + if pSort != 0 { + _pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) + } else { + if eDest == int32(SRT_Coroutine) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), regResult, nResultCol) + } + } + break + /* Write the results into a priority queue that is order according to + ** pDest->pOrderBy (in pSO). pDest->iSDParm (in iParm) is the cursor for an + ** index with pSO->nExpr+2 columns. Build a key using pSO for the first + ** pSO->nExpr columns, then make sure all keys are unique by adding a + ** final OP_Sequence column. The last column is the record as a blob. + */ + fallthrough + case int32(SRT_DistQueue): + fallthrough + case int32(SRT_Queue): + addrTest = 0 + pSO = (*TSelectDest)(unsafe.Pointer(pDest)).FpOrderBy + nKey = (*TExprList)(unsafe.Pointer(pSO)).FnExpr + r13 = _sqlite3GetTempReg(tls, pParse) + r21 = _sqlite3GetTempRange(tls, pParse, nKey+int32(2)) + r3 = r21 + nKey + int32(1) + if eDest == int32(SRT_DistQueue) { + /* If the destination is DistQueue, then cursor (iParm+1) is open + ** on a second ephemeral index that holds all values every previously + ** added to the queue. */ + addrTest = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iParm+int32(1), 0, regResult, nResultCol) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regResult, nResultCol, r3) + if eDest == int32(SRT_DistQueue) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), iParm+int32(1), r3) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + } + i = 0 + for { + if !(i < nKey) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), regResult+libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pSO + 8 + uintptr(i)*32 + 24)))-int32(1), r21+i) + goto _7 + _7: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sequence), iParm, r21+nKey) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), r21, nKey+int32(2), r13) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, r13, r21, nKey+int32(2)) + if addrTest != 0 { + _sqlite3VdbeJumpHere(tls, v, addrTest) + } + _sqlite3ReleaseTempReg(tls, pParse, r13) + _sqlite3ReleaseTempRange(tls, pParse, r21, nKey+int32(2)) + break + /* Discard the results. This is used for SELECT statements inside + ** the body of a TRIGGER. The purpose of such selects is to call + ** user-defined functions that have side effects. We do not care + ** about the actual results of the select. + */ + fallthrough + default: + break + } + /* Jump to the end of the loop if the LIMIT is reached. Except, if + ** there is a sorter, in which case the sorter has already limited + ** the output for us. + */ + if pSort == uintptr(0) && (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_DecrJumpZero), (*TSelect)(unsafe.Pointer(p)).FiLimit, iBreak) + } +} + +// C documentation +// +// /* +// ** Iterate through each expression in expression-list pEList. For each: +// ** +// ** * TK_COLUMN, +// ** * aggregate function, or +// ** * window function with a Window object that is not a member of the +// ** Window list passed as the second argument (pWin). +// ** +// ** Append the node to output expression-list (*ppSub). And replace it +// ** with a TK_COLUMN that reads the (N-1)th element of table +// ** pWin->iEphCsr, where N is the number of elements in (*ppSub) after +// ** appending the new one. +// */ +func _selectWindowRewriteEList(tls *libc.TLS, pParse uintptr, pWin uintptr, pSrc uintptr, pEList uintptr, pTab uintptr, ppSub uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var _ /* sRewrite at bp+48 */ TWindowRewrite + var _ /* sWalker at bp+0 */ TWalker + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+48, 0, uint64(40), ^t__predefined_size_t(0)) + (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpSub = **(**uintptr)(__ccgo_up(ppSub)) + (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpWin = pWin + (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpSrc = pSrc + (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpTab = pTab + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_selectWindowRewriteExprCb) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_selectWindowRewriteSelectCb) + *(*uintptr)(unsafe.Pointer(bp + 40)) = bp + 48 + _sqlite3WalkExprList(tls, bp, pEList) + **(**uintptr)(__ccgo_up(ppSub)) = (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpSub +} + +// C documentation +// +// /* +// ** Callback function used by selectWindowRewriteEList(). If necessary, +// ** this function appends to the output expression-list and updates +// ** expression (*ppExpr) in place. +// */ +func _selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var f, i, i1, iCol, nSrc, v4 int32 + var p, pDup, pParse, pWin uintptr + _, _, _, _, _, _, _, _, _, _ = f, i, i1, iCol, nSrc, p, pDup, pParse, pWin, v4 + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + /* If this function is being called from within a scalar sub-select + ** that used by the SELECT statement being processed, only process + ** TK_COLUMN expressions that refer to it (the outer SELECT). Do + ** not process aggregates or window functions at all, as they belong + ** to the scalar sub-select. */ + if (*TWindowRewrite)(unsafe.Pointer(p)).FpSubSelect != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLUMN) { + return WRC_Continue + } else { + nSrc = (*TSrcList)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSrc)).FnSrc + i = 0 + for { + if !(i < nSrc) { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*(*TSrcItem)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSrc + 8 + uintptr(i)*80))).FiCursor { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i == nSrc { + return WRC_Continue + } + } + } + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + case int32(TK_FUNCTION): + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != libc.Uint32FromInt32(0)) { + break + } else { + pWin = (*TWindowRewrite)(unsafe.Pointer(p)).FpWin + for { + if !(pWin != 0) { + break + } + if *(*uintptr)(unsafe.Pointer(pExpr + 64)) == pWin { + return int32(WRC_Prune) + } + goto _2 + _2: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + } + fallthrough + case int32(TK_IF_NULL_ROW): + fallthrough + case int32(TK_AGG_FUNCTION): + fallthrough + case int32(TK_COLUMN): + iCol = -int32(1) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + if (*TWindowRewrite)(unsafe.Pointer(p)).FpSub != 0 { + i1 = 0 + for { + if !(i1 < (*TExprList)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSub)).FnExpr) { + break + } + if 0 == _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSub + 8 + uintptr(i1)*32))).FpExpr, pExpr, -int32(1)) { + iCol = i1 + break + } + goto _3 + _3: + ; + i1 = i1 + 1 + } + } + if iCol < 0 { + pDup = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) + if pDup != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pDup)).Fop) == int32(TK_AGG_FUNCTION) { + (*TExpr)(unsafe.Pointer(pDup)).Fop = uint8(TK_FUNCTION) + } + (*TWindowRewrite)(unsafe.Pointer(p)).FpSub = _sqlite3ExprListAppend(tls, pParse, (*TWindowRewrite)(unsafe.Pointer(p)).FpSub, pDup) + } + if (*TWindowRewrite)(unsafe.Pointer(p)).FpSub != 0 { + f = libc.Int32FromUint32((*TExpr)(unsafe.Pointer(pExpr)).Fflags & uint32(EP_Collate)) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Static)) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Static)) + libc.X__builtin___memset_chk(tls, pExpr, 0, uint64(72), ^t__predefined_size_t(0)) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_COLUMN) + if iCol < 0 { + v4 = (*TExprList)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSub)).FnExpr - int32(1) + } else { + v4 = iCol + } + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(v4) + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TWindow)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpWin)).FiEphCsr + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TWindowRewrite)(unsafe.Pointer(p)).FpTab + (*TExpr)(unsafe.Pointer(pExpr)).Fflags = libc.Uint32FromInt32(f) + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + default: /* no-op */ + break + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Deserialize the data blob pointed to by buf as serial type serial_type +// ** and store the result in pMem. +// ** +// ** This function is implemented as two separate routines for performance. +// ** The few cases that require local variables are broken out into a separate +// ** routine so that in most cases the overhead of moving the stack pointer +// ** is avoided. +// */ +func _serialGet(tls *libc.TLS, buf uintptr, serial_type Tu32, pMem uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var y Tu32 + var v1 int32 + var _ /* x at bp+0 */ Tu64 + _, _ = y, v1 + **(**Tu64)(__ccgo_up(bp)) = uint64(uint32(**(**uint8)(__ccgo_up(buf)))< 0 && 0 == _sessionBufferGrow(tls, p, int64(nBlob), pRc) { + libc.X__builtin___memcpy_chk(tls, (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf), aBlob, libc.Uint64FromInt32(nBlob), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(p + 8)) += nBlob + } +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append the string representation of integer iVal +// ** to the buffer. No nul-terminator is written. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendInteger(tls *libc.TLS, p uintptr, iVal int32, pRc uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* aBuf at bp+0 */ [24]int8 + Xsqlite3_snprintf(tls, libc.Int32FromUint64(libc.Uint64FromInt64(24)-libc.Uint64FromInt32(1)), bp, __ccgo_ts+5633, libc.VaList(bp+32, iVal)) + _sessionAppendStr(tls, p, bp, pRc) +} + +// C documentation +// +// /* +// ** This function is called when rebasing a local UPDATE change against one +// ** or more remote UPDATE changes. The aRec/nRec buffer contains the current +// ** old.* and new.* records for the change. The rebase buffer (a single +// ** record) is in aChange/nChange. The rebased change is appended to buffer +// ** pBuf. +// ** +// ** Rebasing the UPDATE involves: +// ** +// ** * Removing any changes to fields for which the corresponding field +// ** in the rebase buffer is set to "replaced" (type 0xFF). If this +// ** means the UPDATE change updates no fields, nothing is appended +// ** to the output buffer. +// ** +// ** * For each field modified by the local change for which the +// ** corresponding field in the rebase buffer is not "undefined" (0x00) +// ** or "replaced" (0xFF), the old.* value is replaced by the value +// ** in the rebase buffer. +// */ +func _sessionAppendPartialUpdate(tls *libc.TLS, pBuf uintptr, pIter uintptr, aRec uintptr, nRec int32, aChange uintptr, nChange int32, pRc uintptr) { + var a1, a2, pOut, v1 uintptr + var bData, i, n1, n11, n2, n21 int32 + _, _, _, _, _, _, _, _, _, _ = a1, a2, bData, i, n1, n11, n2, n21, pOut, v1 + _sessionBufferGrow(tls, pBuf, int64(int32(2)+nRec+nChange), pRc) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + bData = 0 + pOut = (*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf) + a1 = aRec + a2 = aChange + v1 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8(SQLITE_UPDATE) + v1 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v1)) = libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect) + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + n1 = _sessionSerialLen(tls, a1) + n2 = _sessionSerialLen(tls, a2) + if **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i))) != 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a2))) == 0 { + if !(**(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i))) != 0) && **(**Tu8)(__ccgo_up(a1)) != 0 { + bData = int32(1) + } + libc.X__builtin___memcpy_chk(tls, pOut, a1, libc.Uint64FromInt32(n1), ^t__predefined_size_t(0)) + pOut = pOut + uintptr(n1) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a2))) != int32(0xFF) && **(**Tu8)(__ccgo_up(a1)) != 0 { + bData = int32(1) + libc.X__builtin___memcpy_chk(tls, pOut, a2, libc.Uint64FromInt32(n2), ^t__predefined_size_t(0)) + pOut = pOut + uintptr(n2) + } else { + v1 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8('\000') + } + } + a1 = a1 + uintptr(n1) + a2 = a2 + uintptr(n2) + goto _3 + _3: + ; + i = i + 1 + } + if bData != 0 { + a2 = aChange + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + n11 = _sessionSerialLen(tls, a1) + n21 = _sessionSerialLen(tls, a2) + if **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i))) != 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a2))) != int32(0xFF) { + libc.X__builtin___memcpy_chk(tls, pOut, a1, libc.Uint64FromInt32(n11), ^t__predefined_size_t(0)) + pOut = pOut + uintptr(n11) + } else { + v1 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8('\000') + } + a1 = a1 + uintptr(n11) + a2 = a2 + uintptr(n21) + goto _5 + _5: + ; + i = i + 1 + } + (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = int32(int64(pOut) - int64((*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf)) + } + } +} + +// C documentation +// +// /* +// ** Buffers a1 and a2 must both contain a sessions module record nCol +// ** fields in size. This function appends an nCol sessions module +// ** record to buffer pBuf that is a copy of a1, except that for +// ** each field that is undefined in a1[], swap in the field from a2[]. +// */ +func _sessionAppendRecordMerge(tls *libc.TLS, pBuf uintptr, nCol int32, a1 uintptr, n1 int32, a2 uintptr, n2 int32, pRc uintptr) { + var i, nn1, nn2 int32 + var pOut uintptr + _, _, _, _ = i, nn1, nn2, pOut + _sessionBufferGrow(tls, pBuf, int64(n1+n2), pRc) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + pOut = (*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf) + i = 0 + for { + if !(i < nCol) { + break + } + nn1 = _sessionSerialLen(tls, a1) + nn2 = _sessionSerialLen(tls, a2) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a1))) == 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a1))) == int32(0xFF) { + libc.X__builtin___memcpy_chk(tls, pOut, a2, libc.Uint64FromInt32(nn2), ^t__predefined_size_t(0)) + pOut = pOut + uintptr(nn2) + } else { + libc.X__builtin___memcpy_chk(tls, pOut, a1, libc.Uint64FromInt32(nn1), ^t__predefined_size_t(0)) + pOut = pOut + uintptr(nn1) + } + a1 = a1 + uintptr(nn1) + a2 = a2 + uintptr(nn2) + goto _1 + _1: + ; + i = i + 1 + } + (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = int32(int64(pOut) - int64((*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf)) + } +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append a string to the buffer. All bytes in the string +// ** up to (but not including) the nul-terminator are written to the buffer. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendStr(tls *libc.TLS, p uintptr, zStr uintptr, pRc uintptr) { + var nStr int32 + _ = nStr + nStr = _sqlite3Strlen30(tls, zStr) + if 0 == _sessionBufferGrow(tls, p, int64(nStr+int32(1)), pRc) { + libc.X__builtin___memcpy_chk(tls, (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf), zStr, libc.Uint64FromInt32(nStr), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(p + 8)) += nStr + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf))) = uint8(0x00) + } +} + +// C documentation +// +// /* +// ** +// ** This function appends an update change to the buffer (see the comments +// ** under "CHANGESET FORMAT" at the top of the file). An update change +// ** consists of: +// ** +// ** 1 byte: SQLITE_UPDATE (0x17) +// ** n bytes: old.* record (see RECORD FORMAT) +// ** m bytes: new.* record (see RECORD FORMAT) +// ** +// ** The SessionChange object passed as the third argument contains the +// ** values that were stored in the row when the session began (the old.* +// ** values). The statement handle passed as the second argument points +// ** at the current version of the row (the new.* values). +// ** +// ** If all of the old.* values are equal to their corresponding new.* value +// ** (i.e. nothing has changed), then no data at all is appended to the buffer. +// ** +// ** Otherwise, the old.* record contains all primary key values and the +// ** original values of any fields that have been modified. The new.* record +// ** contains the new values of only those fields that have been modified. +// */ +func _sessionAppendUpdate(tls *libc.TLS, pBuf uintptr, bPatchset int32, pStmt uintptr, p uintptr, abPK uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bChanged, bNoop, eType, i, nAdvance, nHdr, nRewind int32 + var pCsr uintptr + var _ /* buf2 at bp+8 */ TSessionBuffer + var _ /* dVal at bp+32 */ float64 + var _ /* iVal at bp+24 */ Tsqlite3_int64 + var _ /* n at bp+40 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _ = bChanged, bNoop, eType, i, nAdvance, nHdr, nRewind, pCsr + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} /* Buffer to accumulate new.* record in */ + bNoop = int32(1) /* Set to zero if any values are modified */ + nRewind = (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf /* Used to iterate through columns */ + pCsr = (*TSessionChange)(unsafe.Pointer(p)).FaRecord /* Used to iterate through old.* values */ + _sessionAppendByte(tls, pBuf, uint8(SQLITE_UPDATE), bp) + _sessionAppendByte(tls, pBuf, (*TSessionChange)(unsafe.Pointer(p)).FbIndirect, bp) + i = 0 + for { + if !(i < Xsqlite3_column_count(tls, pStmt)) { + break + } + bChanged = 0 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pCsr))) + switch eType { + case int32(SQLITE_NULL): + nAdvance = int32(1) + if Xsqlite3_column_type(tls, pStmt, i) != int32(SQLITE_NULL) { + bChanged = int32(1) + } + case int32(SQLITE_FLOAT): + fallthrough + case int32(SQLITE_INTEGER): + nAdvance = int32(9) + if eType == Xsqlite3_column_type(tls, pStmt, i) { + **(**Tsqlite3_int64)(__ccgo_up(bp + 24)) = _sessionGetI64(tls, pCsr+1) + if eType == int32(SQLITE_INTEGER) { + if **(**Tsqlite3_int64)(__ccgo_up(bp + 24)) == Xsqlite3_column_int64(tls, pStmt, i) { + break + } + } else { + libc.X__builtin___memcpy_chk(tls, bp+32, bp+24, uint64(8), ^t__predefined_size_t(0)) + if **(**float64)(__ccgo_up(bp + 32)) == Xsqlite3_column_double(tls, pStmt, i) { + break + } + } + } + bChanged = int32(1) + default: + nHdr = int32(1) + _sessionVarintGet(tls, pCsr+1, bp+40) + nAdvance = nHdr + **(**int32)(__ccgo_up(bp + 40)) + if eType == Xsqlite3_column_type(tls, pStmt, i) && **(**int32)(__ccgo_up(bp + 40)) == Xsqlite3_column_bytes(tls, pStmt, i) && (**(**int32)(__ccgo_up(bp + 40)) == 0 || 0 == libc.Xmemcmp(tls, pCsr+uintptr(nHdr), Xsqlite3_column_blob(tls, pStmt, i), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 40))))) { + break + } + bChanged = int32(1) + } + /* If at least one field has been modified, this is not a no-op. */ + if bChanged != 0 { + bNoop = 0 + } + /* Add a field to the old.* record. This is omitted if this module is + ** currently generating a patchset. */ + if bPatchset == 0 { + if bChanged != 0 || **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + _sessionAppendBlob(tls, pBuf, pCsr, nAdvance, bp) + } else { + _sessionAppendByte(tls, pBuf, uint8(0), bp) + } + } + /* Add a field to the new.* record. Or the only record if currently + ** generating a patchset. */ + if bChanged != 0 || bPatchset != 0 && **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + _sessionAppendCol(tls, bp+8, pStmt, i, bp) + } else { + _sessionAppendByte(tls, bp+8, uint8(0), bp) + } + pCsr = pCsr + uintptr(nAdvance) + goto _1 + _1: + ; + i = i + 1 + } + if bNoop != 0 { + (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = nRewind + } else { + _sessionAppendBlob(tls, pBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf, bp) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Attempt to apply the change that the iterator passed as the first argument +// ** currently points to to the database. If a conflict is encountered, invoke +// ** the conflict handler callback. +// ** +// ** The difference between this function and sessionApplyOne() is that this +// ** function handles the case where the conflict-handler is invoked and +// ** returns SQLITE_CHANGESET_REPLACE - indicating that the change should be +// ** retried in some manner. +// */ +func _sessionApplyOneWithRetry(tls *libc.TLS, db uintptr, pIter uintptr, pApply uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* bReplace at bp+0 */ int32 + var _ /* bRetry at bp+4 */ int32 + _ = rc + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, bp, bp+4) + if rc == SQLITE_OK { + /* If the bRetry flag is set, the change has not been applied due to an + ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and + ** a row with the correct PK is present in the db, but one or more other + ** fields do not contain the expected values) and the conflict handler + ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation, + ** but pass NULL as the final argument so that sessionApplyOneOp() ignores + ** the SQLITE_CHANGESET_DATA problem. */ + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0)) + } else { + if **(**int32)(__ccgo_up(bp)) != 0 { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36647, uintptr(0), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + rc = _sessionBindRow(tls, pIter, __ccgo_fp(Xsqlite3changeset_new), (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + Xsqlite3_bind_int(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol+int32(1), int32(1)) + } + if rc == SQLITE_OK { + Xsqlite3_step(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + rc = Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + } + if rc == SQLITE_OK { + rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36668, uintptr(0), uintptr(0), uintptr(0)) + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** This function is called to merge two changes to the same row together as +// ** part of an sqlite3changeset_concat() operation. A new change object is +// ** allocated and a pointer to it stored in *ppNew. +// ** +// ** Because they have been vetted by sqlite3changegroup_add() or similar, +// ** both the aRec[] change and the pExist change are safe to use without +// ** checking for buffer overflows. +// */ +func _sessionChangeMerge(tls *libc.TLS, pTab uintptr, bRebase int32, bPatchset int32, pExist uintptr, op2 int32, bIndirect int32, aRec uintptr, nRec int32, ppNew uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a1, a2, aExist, pIn, pNew, pOut, pOut1, v2 uintptr + var i, i1, n1, n2, nIn, op1, rc int32 + var nByte, nByte1 Tsqlite3_int64 + var _ /* a1 at bp+16 */ uintptr + var _ /* a1 at bp+8 */ uintptr + var _ /* a2 at bp+24 */ uintptr + var _ /* aCsr at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a1, a2, aExist, i, i1, n1, n2, nByte, nByte1, nIn, op1, pIn, pNew, pOut, pOut1, rc, v2 + pNew = uintptr(0) + rc = SQLITE_OK + if !(pExist != 0) { + pNew = Xsqlite3_malloc64(tls, uint64(uint64(32)+libc.Uint64FromInt32(nRec))) + if !(pNew != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(32), ^t__predefined_size_t(0)) + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = libc.Uint8FromInt32(op2) + (*TSessionChange)(unsafe.Pointer(pNew)).FbIndirect = libc.Uint8FromInt32(bIndirect) + (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord = pNew + 1*32 + if bIndirect == 0 || bRebase == 0 { + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecord = nRec + libc.X__builtin___memcpy_chk(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord, aRec, libc.Uint64FromInt32(nRec), ^t__predefined_size_t(0)) + } else { + pIn = aRec + pOut = (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + nIn = _sessionSerialLen(tls, pIn) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pIn))) == 0 { + v2 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8(0) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i)))) == 0 { + v2 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8(0xFF) + } else { + libc.X__builtin___memcpy_chk(tls, pOut, pIn, libc.Uint64FromInt32(nIn), ^t__predefined_size_t(0)) + pOut = pOut + uintptr(nIn) + } + } + pIn = pIn + uintptr(nIn) + goto _1 + _1: + ; + i = i + 1 + } + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecord = int32(int64(pOut) - int64((*TSessionChange)(unsafe.Pointer(pNew)).FaRecord)) + } + } else { + if bRebase != 0 { + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pExist)).Fop) == int32(SQLITE_DELETE) && (*TSessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0 { + **(**uintptr)(__ccgo_up(ppNew)) = pExist + } else { + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(nRec+(*TSessionChange)(unsafe.Pointer(pExist)).FnRecord) + uint64(32)) + pNew = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + a1 = (*TSessionChange)(unsafe.Pointer(pExist)).FaRecord + a2 = aRec + libc.X__builtin___memset_chk(tls, pNew, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + (*TSessionChange)(unsafe.Pointer(pNew)).FbIndirect = libc.BoolUint8(bIndirect != 0 || (*TSessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0) + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = libc.Uint8FromInt32(op2) + v2 = pNew + 1*32 + (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord = v2 + pOut1 = v2 + i1 = 0 + for { + if !(i1 < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + n1 = _sessionSerialLen(tls, a1) + n2 = _sessionSerialLen(tls, a2) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a1))) == int32(0xFF) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i1)))) == 0 && bIndirect != 0 { + v2 = pOut1 + pOut1 = pOut1 + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8(0xFF) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a2))) == 0 { + libc.X__builtin___memcpy_chk(tls, pOut1, a1, libc.Uint64FromInt32(n1), ^t__predefined_size_t(0)) + pOut1 = pOut1 + uintptr(n1) + } else { + libc.X__builtin___memcpy_chk(tls, pOut1, a2, libc.Uint64FromInt32(n2), ^t__predefined_size_t(0)) + pOut1 = pOut1 + uintptr(n2) + } + } + a1 = a1 + uintptr(n1) + a2 = a2 + uintptr(n2) + goto _5 + _5: + ; + i1 = i1 + 1 + } + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecord = int32(int64(pOut1) - int64((*TSessionChange)(unsafe.Pointer(pNew)).FaRecord)) + } + Xsqlite3_free(tls, pExist) + } + } else { + op1 = libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pExist)).Fop) + /* + ** op1=INSERT, op2=INSERT -> Unsupported. Discard op2. + ** op1=INSERT, op2=UPDATE -> INSERT. + ** op1=INSERT, op2=DELETE -> (none) + ** + ** op1=UPDATE, op2=INSERT -> Unsupported. Discard op2. + ** op1=UPDATE, op2=UPDATE -> UPDATE. + ** op1=UPDATE, op2=DELETE -> DELETE. + ** + ** op1=DELETE, op2=INSERT -> UPDATE. + ** op1=DELETE, op2=UPDATE -> Unsupported. Discard op2. + ** op1=DELETE, op2=DELETE -> Unsupported. Discard op2. + */ + if op1 == int32(SQLITE_INSERT) && op2 == int32(SQLITE_INSERT) || op1 == int32(SQLITE_UPDATE) && op2 == int32(SQLITE_INSERT) || op1 == int32(SQLITE_DELETE) && op2 == int32(SQLITE_UPDATE) || op1 == int32(SQLITE_DELETE) && op2 == int32(SQLITE_DELETE) { + pNew = pExist + } else { + if op1 == int32(SQLITE_INSERT) && op2 == int32(SQLITE_DELETE) { + Xsqlite3_free(tls, pExist) + } else { + aExist = (*TSessionChange)(unsafe.Pointer(pExist)).FaRecord + /* Allocate a new SessionChange object. Ensure that the aRecord[] + ** buffer of the new object is large enough to hold any record that + ** may be generated by combining the input records. */ + nByte1 = libc.Int64FromUint64(uint64(32) + libc.Uint64FromInt32((*TSessionChange)(unsafe.Pointer(pExist)).FnRecord) + libc.Uint64FromInt32(nRec)) + pNew = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte1)) + if !(pNew != 0) { + Xsqlite3_free(tls, pExist) + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(32), ^t__predefined_size_t(0)) + (*TSessionChange)(unsafe.Pointer(pNew)).FbIndirect = libc.BoolUint8(bIndirect != 0 && (*TSessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0) + v2 = pNew + 1*32 + (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord = v2 + **(**uintptr)(__ccgo_up(bp)) = v2 + if op1 == int32(SQLITE_INSERT) { /* INSERT + UPDATE */ + **(**uintptr)(__ccgo_up(bp + 8)) = aRec + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = uint8(SQLITE_INSERT) + if bPatchset == 0 { + _sessionSkipRecord(tls, bp+8, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) + } + _sessionMergeRecord(tls, bp, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, aExist, **(**uintptr)(__ccgo_up(bp + 8))) + } else { + if op1 == int32(SQLITE_DELETE) { /* DELETE + INSERT */ + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = uint8(SQLITE_UPDATE) + if bPatchset != 0 { + libc.X__builtin___memcpy_chk(tls, **(**uintptr)(__ccgo_up(bp)), aRec, libc.Uint64FromInt32(nRec), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(nRec) + } else { + if 0 == _sessionMergeUpdate(tls, bp, pTab, bPatchset, aExist, uintptr(0), aRec, uintptr(0)) { + Xsqlite3_free(tls, pNew) + pNew = uintptr(0) + } + } + } else { + if op2 == int32(SQLITE_UPDATE) { /* UPDATE + UPDATE */ + **(**uintptr)(__ccgo_up(bp + 16)) = aExist + **(**uintptr)(__ccgo_up(bp + 24)) = aRec + if bPatchset == 0 { + _sessionSkipRecord(tls, bp+16, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) + _sessionSkipRecord(tls, bp+24, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) + } + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = uint8(SQLITE_UPDATE) + if 0 == _sessionMergeUpdate(tls, bp, pTab, bPatchset, aRec, aExist, **(**uintptr)(__ccgo_up(bp + 16)), **(**uintptr)(__ccgo_up(bp + 24))) { + Xsqlite3_free(tls, pNew) + pNew = uintptr(0) + } + } else { /* UPDATE + DELETE */ + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = uint8(SQLITE_DELETE) + if bPatchset != 0 { + libc.X__builtin___memcpy_chk(tls, **(**uintptr)(__ccgo_up(bp)), aRec, libc.Uint64FromInt32(nRec), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(nRec) + } else { + _sessionMergeRecord(tls, bp, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, aRec, aExist) + } + } + } + } + if pNew != 0 { + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecord = int32(int64(**(**uintptr)(__ccgo_up(bp))) - int64((*TSessionChange)(unsafe.Pointer(pNew)).FaRecord)) + } + Xsqlite3_free(tls, pExist) + } + } + } + } + **(**uintptr)(__ccgo_up(ppNew)) = pNew + return rc +} + +// C documentation +// +// /* +// ** Argument pIter is a changeset iterator that has been initialized, but +// ** not yet passed to sqlite3changeset_next(). This function applies the +// ** changeset to the main database attached to handle "db". The supplied +// ** conflict handler callback is invoked to resolve any conflicts encountered +// ** while applying the change. +// */ +func _sessionChangesetApply(tls *libc.TLS, db uintptr, pIter uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xFilterIter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) { + bp := tls.Alloc(368) + defer tls.Free(368) + var bPatchset, i, nMinCol, nTab, rc, rc2, res, schemaMismatch, v2, v3, v4 int32 + var savedFlag Tu64 + var v5, v7 bool + var _ /* abPK at bp+160 */ uintptr + var _ /* nCol at bp+144 */ int32 + var _ /* nFk at bp+168 */ int32 + var _ /* notUsed at bp+172 */ int32 + var _ /* op at bp+148 */ int32 + var _ /* sApply at bp+8 */ TSessionApplyCtx + var _ /* sIter at bp+176 */ Tsqlite3_changeset_iter + var _ /* zNew at bp+152 */ uintptr + var _ /* zTab at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bPatchset, i, nMinCol, nTab, rc, rc2, res, savedFlag, schemaMismatch, v2, v3, v4, v5, v7 + schemaMismatch = 0 + rc = SQLITE_OK /* Return code */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Name of current table */ + nTab = 0 + savedFlag = (*Tsqlite3)(unsafe.Pointer(db)).Fflags & (libc.Uint64FromInt32(libc.Int32FromInt32(0x00008)) << libc.Int32FromInt32(32)) + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db)) + if flags&int32(SQLITE_CHANGESETAPPLY_FKNOACTION) != 0 { + **(**Tu64)(__ccgo_up(db + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(0x00008)) << libc.Int32FromInt32(32) + **(**int32)(__ccgo_up((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)) -= int32(32) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FbNoDiscard = int32(1) + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(136), ^t__predefined_size_t(0)) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbRebase = libc.BoolUint8(ppRebase != 0 && pnRebase != 0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbInvertConstraints = libc.BoolInt32(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETAPPLY_INVERT) != 0)) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbIgnoreNoop = libc.BoolUint8(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETAPPLY_IGNORENOOP) != 0)) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbNoUpdateLoop = libc.BoolUint8(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETAPPLY_NOUPDATELOOP) != 0)) + if flags&int32(SQLITE_CHANGESETAPPLY_NOSAVEPOINT) == 0 { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36837, uintptr(0), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36863, uintptr(0), uintptr(0), uintptr(0)) + } + for rc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3changeset_next(tls, pIter) { + Xsqlite3changeset_op(tls, pIter, bp+152, bp+144, bp+148, uintptr(0)) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) || Xsqlite3_strnicmp(tls, **(**uintptr)(__ccgo_up(bp + 152)), **(**uintptr)(__ccgo_up(bp)), nTab+int32(1)) != 0 { + rc = _sessionRetryConstraints(tls, db, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset, **(**uintptr)(__ccgo_up(bp)), bp+8, __ccgo_fp_xConflict, pCtx) + if rc != SQLITE_OK { + break + } + _sessionUpdateFree(tls, bp+8) + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FazCol) /* cast works around VC++ bug */ + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpDelete) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpInsert) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpSelect) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Fdb = db + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpDelete = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpInsert = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpSelect = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol = 0 + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FazCol = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FabPK = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbStat1 = 0 + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbDeferConstraints = int32(1) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbRebaseStarted = uint8(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbRowid = 0 + libc.X__builtin___memset_chk(tls, bp+8+88, 0, uint64(16), ^t__predefined_size_t(0)) + /* If an xFilter() callback was specified, invoke it now. If the + ** xFilter callback returns zero, skip this table. If it returns + ** non-zero, proceed. */ + schemaMismatch = libc.BoolInt32(__ccgo_fp_xFilter != 0 && 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xFilter})))(tls, pCtx, **(**uintptr)(__ccgo_up(bp + 152)))) + if schemaMismatch != 0 { + **(**uintptr)(__ccgo_up(bp)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+336, **(**uintptr)(__ccgo_up(bp + 152)))) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + rc = int32(SQLITE_NOMEM) + break + } + nTab = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(bp)))) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FazCol = **(**uintptr)(__ccgo_up(bp)) + } else { + nMinCol = 0 + Xsqlite3changeset_pk(tls, pIter, bp+160, uintptr(0)) + rc = _sessionTableInfo(tls, uintptr(0), db, __ccgo_ts+7160, **(**uintptr)(__ccgo_up(bp + 152)), bp+8+32, uintptr(0), bp, bp+8+40, uintptr(0), uintptr(0), bp+8+48, bp+8+124) + if rc != SQLITE_OK { + break + } + i = 0 + for { + if !(i < (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FabPK + uintptr(i))) != 0 { + nMinCol = i + int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + if (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol == 0 { + schemaMismatch = int32(1) + Xsqlite3_log(tls, int32(SQLITE_SCHEMA), __ccgo_ts+36893, libc.VaList(bp+336, **(**uintptr)(__ccgo_up(bp)))) + } else { + if (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol < **(**int32)(__ccgo_up(bp + 144)) { + schemaMismatch = int32(1) + Xsqlite3_log(tls, int32(SQLITE_SCHEMA), __ccgo_ts+36937, libc.VaList(bp+336, **(**uintptr)(__ccgo_up(bp)), (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol, **(**int32)(__ccgo_up(bp + 144)))) + } else { + if **(**int32)(__ccgo_up(bp + 144)) < nMinCol || libc.Xmemcmp(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FabPK, **(**uintptr)(__ccgo_up(bp + 160)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 144)))) != 0 { + schemaMismatch = int32(1) + Xsqlite3_log(tls, int32(SQLITE_SCHEMA), __ccgo_ts+37008, libc.VaList(bp+336, **(**uintptr)(__ccgo_up(bp)))) + } else { + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol = **(**int32)(__ccgo_up(bp + 144)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+13177) { + v2 = _sessionStat1Sql(tls, db, bp+8) + rc = v2 + if v2 != 0 { + break + } + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbStat1 = int32(1) + } else { + v2 = _sessionSelectRow(tls, db, **(**uintptr)(__ccgo_up(bp)), bp+8) + rc = v2 + if v5 = v2 != 0; !v5 { + v3 = _sessionDeleteRow(tls, db, **(**uintptr)(__ccgo_up(bp)), bp+8) + rc = v3 + } + if v7 = v5 || v3 != 0; !v7 { + v4 = _sessionInsertRow(tls, db, **(**uintptr)(__ccgo_up(bp)), bp+8) + rc = v4 + } + if v7 || v4 != 0 { + break + } + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbStat1 = 0 + } + } + } + } + nTab = _sqlite3Strlen30(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + /* If there is a schema mismatch on the current table, proceed to the + ** next change. A log message has already been issued. */ + if schemaMismatch != 0 { + continue + } + /* If this is a call to apply_v3(), invoke xFilterIter here. */ + if __ccgo_fp_xFilterIter != 0 && 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xFilterIter})))(tls, pCtx, pIter) { + continue + } + rc = _sessionApplyOneWithRetry(tls, db, pIter, bp+8, __ccgo_fp_xConflict, pCtx) + } + bPatchset = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset + if rc == SQLITE_OK { + rc = Xsqlite3changeset_finalize(tls, pIter) + } else { + Xsqlite3changeset_finalize(tls, pIter) + } + if rc == SQLITE_OK { + rc = _sessionRetryConstraints(tls, db, bPatchset, **(**uintptr)(__ccgo_up(bp)), bp+8, __ccgo_fp_xConflict, pCtx) + } + if rc == SQLITE_OK { + Xsqlite3_db_status(tls, db, int32(SQLITE_DBSTATUS_DEFERRED_FKS), bp+168, bp+172, 0) + if **(**int32)(__ccgo_up(bp + 168)) != 0 { + res = int32(SQLITE_CHANGESET_ABORT) + libc.X__builtin___memset_chk(tls, bp+176, 0, uint64(152), ^t__predefined_size_t(0)) + (**(**Tsqlite3_changeset_iter)(__ccgo_up(bp + 176))).FnCol = **(**int32)(__ccgo_up(bp + 168)) + res = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xConflict})))(tls, pCtx, int32(SQLITE_CHANGESET_FOREIGN_KEY), bp+176) + if res != SQLITE_CHANGESET_OMIT { + rc = int32(SQLITE_CONSTRAINT) + } + } + } + rc2 = Xsqlite3_exec(tls, db, __ccgo_ts+37068, uintptr(0), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + rc = rc2 + } + if flags&int32(SQLITE_CHANGESETAPPLY_NOSAVEPOINT) == 0 { + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+37098, uintptr(0), uintptr(0), uintptr(0)) + } + if rc != SQLITE_OK { + Xsqlite3_exec(tls, db, __ccgo_ts+37122, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_exec(tls, db, __ccgo_ts+37098, uintptr(0), uintptr(0), uintptr(0)) + } + } + if rc == SQLITE_OK && bPatchset == 0 && (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbRebase != 0 { + **(**uintptr)(__ccgo_up(ppRebase)) = (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Frebase.FaBuf + **(**int32)(__ccgo_up(pnRebase)) = (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Frebase.FnBuf + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Frebase.FaBuf = uintptr(0) + } + _sessionUpdateFree(tls, bp+8) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpInsert) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpDelete) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpSelect) + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FazCol) /* cast works around VC++ bug */ + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Fconstraints.FaBuf) + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Frebase.FaBuf) + if flags&int32(SQLITE_CHANGESETAPPLY_FKNOACTION) != 0 && savedFlag == uint64(0) { + **(**Tu64)(__ccgo_up(db + 48)) &= ^(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008)) << libc.Int32FromInt32(32)) + **(**int32)(__ccgo_up((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)) -= int32(32) + } + Xsqlite3_set_errmsg(tls, db, rc, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FzErr) + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FzErr) + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + return rc +} + +// C documentation +// +// /* +// ** Locate or create a SessionTable object that may be used to add the +// ** change currently pointed to by iterator pIter to changegroup pGrp. +// ** If successful, set output variable (*ppTab) to point to the table +// ** object and return SQLITE_OK. Otherwise, if some error occurs, return +// ** an SQLite error code and leave (*ppTab) set to NULL. +// */ +func _sessionChangesetFindTable(tls *libc.TLS, pGrp uintptr, zTab uintptr, pIter uintptr, ppTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nTab, rc int32 + var pTab, ppNew uintptr + var _ /* abPK at bp+0 */ uintptr + var _ /* nCol at bp+8 */ int32 + _, _, _, _ = nTab, pTab, ppNew, rc + rc = SQLITE_OK + pTab = uintptr(0) + nTab = libc.Int32FromUint64(libc.Xstrlen(tls, zTab)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = 0 + **(**uintptr)(__ccgo_up(ppTab)) = uintptr(0) + /* Search the list for an existing table */ + pTab = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList + for { + if !(pTab != 0) { + break + } + if 0 == Xsqlite3_strnicmp(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zTab, nTab+int32(1)) { + break + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + if pIter != 0 { + Xsqlite3changeset_pk(tls, pIter, bp, bp+8) + } else { + if !(pTab != 0) && !((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb != 0) { + return SQLITE_OK + } + } + /* If one was not found above, create a new table now */ + if !(pTab != 0) { + pTab = Xsqlite3_malloc64(tls, uint64(uint64(88)+libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 8)))+libc.Uint64FromInt32(nTab)+uint64(1))) + if !(pTab != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pTab, 0, uint64(88), ^t__predefined_size_t(0)) + (*TSessionTable)(unsafe.Pointer(pTab)).FnCol = **(**int32)(__ccgo_up(bp + 8)) + (*TSessionTable)(unsafe.Pointer(pTab)).FabPK = pTab + 1*88 + if **(**int32)(__ccgo_up(bp + 8)) > 0 { + libc.X__builtin___memcpy_chk(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK, **(**uintptr)(__ccgo_up(bp)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 8))), ^t__predefined_size_t(0)) + } + (*TSessionTable)(unsafe.Pointer(pTab)).FzName = (*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(**(**int32)(__ccgo_up(bp + 8))) + libc.X__builtin___memcpy_chk(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zTab, libc.Uint64FromInt32(nTab+int32(1)), ^t__predefined_size_t(0)) + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb != 0 { + (*TSessionTable)(unsafe.Pointer(pTab)).FnCol = 0 + rc = _sessionInitTable(tls, uintptr(0), pTab, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FzDb) + if rc != 0 || (*TSessionTable)(unsafe.Pointer(pTab)).FnCol == 0 { + Xsqlite3_free(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol) + Xsqlite3_free(tls, pTab) + return rc + } + } + /* The new object must be linked on to the end of the list, not + ** simply added to the start of it. This is to ensure that the + ** tables within the output of sqlite3changegroup_output() are in + ** the right order. */ + ppNew = pGrp + 8 + for { + if !(**(**uintptr)(__ccgo_up(ppNew)) != 0) { + break + } + goto _2 + _2: + ; + ppNew = **(**uintptr)(__ccgo_up(ppNew)) + } + **(**uintptr)(__ccgo_up(ppNew)) = pTab + } + /* Check that the table is compatible. */ + if pIter != 0 && !(_sessionChangesetCheckCompat(tls, pTab, **(**int32)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp))) != 0) { + rc = int32(SQLITE_SCHEMA) + } + **(**uintptr)(__ccgo_up(ppTab)) = pTab + return rc +} + +func _sessionChangesetInvert(tls *libc.TLS, pInput uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr, pnInverted uintptr, ppInverted uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var abPK, apVal, pVal, pVal1, v7 uintptr + var bIndirect, eType2, iCol, nVar, v1 int32 + var eType Tu8 + var _ /* nByte at bp+48 */ int32 + var _ /* nByte at bp+52 */ int32 + var _ /* nCol at bp+24 */ int32 + var _ /* rc at bp+0 */ int32 + var _ /* sOut at bp+8 */ TSessionBuffer + var _ /* sPK at bp+32 */ TSessionBuffer + _, _, _, _, _, _, _, _, _, _, _ = abPK, apVal, bIndirect, eType, eType2, iCol, nVar, pVal, pVal1, v1, v7 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Output buffer */ + **(**int32)(__ccgo_up(bp + 24)) = 0 /* Number of cols in current table */ + abPK = uintptr(0) /* PK array for current table */ + apVal = uintptr(0) /* Space for values for UPDATE inversion */ + **(**TSessionBuffer)(__ccgo_up(bp + 32)) = TSessionBuffer{} /* PK array for current table */ + /* Initialize the output buffer */ + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(16), ^t__predefined_size_t(0)) + /* Zero the output variables in case an error occurs. */ + if ppInverted != 0 { + **(**uintptr)(__ccgo_up(ppInverted)) = uintptr(0) + **(**int32)(__ccgo_up(pnInverted)) = 0 + } + for int32(1) != 0 { + /* Test for EOF. */ + v1 = _sessionInputBuffer(tls, pInput, int32(2)) + **(**int32)(__ccgo_up(bp)) = v1 + if v1 != 0 { + goto finished_invert + } + if (*TSessionInput)(unsafe.Pointer(pInput)).FiNext+int32(1) >= (*TSessionInput)(unsafe.Pointer(pInput)).FnData { + if (*TSessionInput)(unsafe.Pointer(pInput)).FiNext != (*TSessionInput)(unsafe.Pointer(pInput)).FnData { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(237677)) + goto finished_invert + } + break + } + eType = **(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext))) + switch libc.Int32FromUint8(eType) { + case int32('T'): + (*TSessionInput)(unsafe.Pointer(pInput)).FiNext = (*TSessionInput)(unsafe.Pointer(pInput)).FiNext + 1 + v1 = _sessionChangesetBufferTblhdr(tls, pInput, bp+48) + **(**int32)(__ccgo_up(bp)) = v1 + if v1 != 0 { + goto finished_invert + } + nVar = _sessionVarintGet(tls, (*TSessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext), bp+24) + (**(**TSessionBuffer)(__ccgo_up(bp + 32))).FnBuf = 0 + _sessionAppendBlob(tls, bp+32, (*TSessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext+nVar), **(**int32)(__ccgo_up(bp + 24)), bp) + _sessionAppendByte(tls, bp+8, eType, bp) + _sessionAppendBlob(tls, bp+8, (*TSessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext), **(**int32)(__ccgo_up(bp + 48)), bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto finished_invert + } + **(**int32)(__ccgo_up(pInput + 8)) += **(**int32)(__ccgo_up(bp + 48)) + Xsqlite3_free(tls, apVal) + apVal = uintptr(0) + abPK = (**(**TSessionBuffer)(__ccgo_up(bp + 32))).FaBuf + case int32(SQLITE_INSERT): + fallthrough + case int32(SQLITE_DELETE): + bIndirect = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext+int32(1))))) + if libc.Int32FromUint8(eType) == int32(SQLITE_DELETE) { + v1 = int32(SQLITE_INSERT) + } else { + v1 = int32(SQLITE_DELETE) + } + eType2 = v1 + **(**int32)(__ccgo_up(pInput + 8)) += int32(2) + **(**int32)(__ccgo_up(bp)) = _sessionChangesetBufferRecord(tls, pInput, **(**int32)(__ccgo_up(bp + 24)), bp+52) + _sessionAppendByte(tls, bp+8, libc.Uint8FromInt32(eType2), bp) + _sessionAppendByte(tls, bp+8, libc.Uint8FromInt32(bIndirect), bp) + _sessionAppendBlob(tls, bp+8, (*TSessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext), **(**int32)(__ccgo_up(bp + 52)), bp) + **(**int32)(__ccgo_up(pInput + 8)) += **(**int32)(__ccgo_up(bp + 52)) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto finished_invert + } + case int32(SQLITE_UPDATE): + if uintptr(0) == apVal { + apVal = Xsqlite3_malloc64(tls, uint64(uint64(8)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 24)))*uint64(2))) + if uintptr(0) == apVal { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + goto finished_invert + } + libc.X__builtin___memset_chk(tls, apVal, 0, uint64(8)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 24)))*uint64(2), ^t__predefined_size_t(0)) + } + /* Write the header for the new UPDATE change. Same as the original. */ + _sessionAppendByte(tls, bp+8, eType, bp) + _sessionAppendByte(tls, bp+8, **(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext+int32(1)))), bp) + /* Read the old.* and new.* records for the update change. */ + **(**int32)(__ccgo_up(pInput + 8)) += int32(2) + **(**int32)(__ccgo_up(bp)) = _sessionReadRecord(tls, pInput, **(**int32)(__ccgo_up(bp + 24)), uintptr(0), apVal, uintptr(0)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionReadRecord(tls, pInput, **(**int32)(__ccgo_up(bp + 24)), uintptr(0), apVal+uintptr(**(**int32)(__ccgo_up(bp + 24)))*8, uintptr(0)) + } + /* Write the new old.* record. Consists of the PK columns from the + ** original old.* record, and the other values from the original + ** new.* record. */ + iCol = 0 + for { + if !(iCol < **(**int32)(__ccgo_up(bp + 24))) { + break + } + if **(**Tu8)(__ccgo_up(abPK + uintptr(iCol))) != 0 { + v1 = 0 + } else { + v1 = **(**int32)(__ccgo_up(bp + 24)) + } + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr(iCol+v1)*8)) + _sessionAppendValue(tls, bp+8, pVal, bp) + goto _4 + _4: + ; + iCol = iCol + 1 + } + /* Write the new new.* record. Consists of a copy of all values + ** from the original old.* record, except for the PK columns, which + ** are set to "undefined". */ + iCol = 0 + for { + if !(iCol < **(**int32)(__ccgo_up(bp + 24))) { + break + } + if **(**Tu8)(__ccgo_up(abPK + uintptr(iCol))) != 0 { + v7 = uintptr(0) + } else { + v7 = **(**uintptr)(__ccgo_up(apVal + uintptr(iCol)*8)) + } + pVal1 = v7 + _sessionAppendValue(tls, bp+8, pVal1, bp) + goto _6 + _6: + ; + iCol = iCol + 1 + } + iCol = 0 + for { + if !(iCol < **(**int32)(__ccgo_up(bp + 24))*int32(2)) { + break + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(iCol)*8))) + goto _8 + _8: + ; + iCol = iCol + 1 + } + libc.X__builtin___memset_chk(tls, apVal, 0, uint64(8)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 24)))*uint64(2), ^t__predefined_size_t(0)) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto finished_invert + } + default: + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(237780)) + goto finished_invert + } + if __ccgo_fp_xOutput != 0 && (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf >= _sessions_strm_chunk_size { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf) + (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf = 0 + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto finished_invert + } + } + } + if pnInverted != 0 && ppInverted != 0 { + **(**int32)(__ccgo_up(pnInverted)) = (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf + **(**uintptr)(__ccgo_up(ppInverted)) = (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf + (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf = uintptr(0) + } else { + if (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf > 0 && __ccgo_fp_xOutput != uintptr(0) { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf) + } + } + goto finished_invert +finished_invert: + ; + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + Xsqlite3_free(tls, apVal) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 32))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Advance the changeset iterator to the next change. The differences between +// ** this function and sessionChangesetNext() are that +// ** +// ** * If pbEmpty is not NULL and the change is a no-op UPDATE (an UPDATE +// ** that modifies no columns), this function sets (*pbEmpty) to 1. +// ** +// ** * If the iterator is configured to skip no-op UPDATEs, +// ** sessionChangesetNext() does that. This function does not. +// */ +func _sessionChangesetNextOne(tls *libc.TLS, p uintptr, paRec uintptr, pnRec uintptr, pbNew uintptr, pbEmpty uintptr) (r int32) { + var abPK, apNew, apOld, v10, v3, v6 uintptr + var i, nVal, v2 int32 + var op Tu8 + _, _, _, _, _, _, _, _, _, _ = abPK, apNew, apOld, i, nVal, op, v10, v2, v3, v6 + /* If the iterator is in the error-state, return immediately. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + /* Free the current contents of p->apValue[], if any. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue != 0 { + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol*int32(2)) { + break + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + libc.X__builtin___memset_chk(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue, 0, uint64(8)*libc.Uint64FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*uint64(2), ^t__predefined_size_t(0)) + } + /* Make sure the buffer contains at least 2 bytes of input data, or all + ** remaining data if there are less than 2 bytes available. This is + ** sufficient either for the 'T' or 'P' byte that begins a new table, + ** or for the "op" and "bIndirect" single bytes otherwise. */ + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = _sessionInputBuffer(tls, p, int32(2)) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiCurrent = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext + _sessionDiscardData(tls, p) + /* If the iterator is already at the end of the changeset, return DONE. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FnData { + return int32(SQLITE_DONE) + } + v3 = p + 8 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + op = **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(v2))) + for libc.Int32FromUint8(op) == int32('T') || libc.Int32FromUint8(op) == int32('P') { + if pbNew != 0 { + **(**int32)(__ccgo_up(pbNew)) = int32(1) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset = libc.BoolInt32(libc.Int32FromUint8(op) == int32('P')) + if _sessionChangesetReadTblhdr(tls, p) != 0 { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + v2 = _sessionInputBuffer(tls, p, int32(2)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + if v2 != 0 { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiCurrent = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FnData { + return int32(SQLITE_DONE) + } + v3 = p + 8 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + op = **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(v2))) + } + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab == uintptr(0) || (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 && (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 { + /* The first record in the changeset is not a table header. Must be a + ** corrupt changeset. */ + v2 = _sqlite3CorruptError(tls, int32(237357)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + return v2 + } + if libc.Int32FromUint8(op) != int32(SQLITE_UPDATE) && libc.Int32FromUint8(op) != int32(SQLITE_DELETE) && libc.Int32FromUint8(op) != int32(SQLITE_INSERT) || (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FnData { + v2 = _sqlite3CorruptError(tls, int32(237363)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + return v2 + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = libc.Int32FromUint8(op) + v3 = p + 8 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbIndirect = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(v2)))) + if paRec != 0 { /* Number of values to buffer */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 && libc.Int32FromUint8(op) == int32(SQLITE_UPDATE) { + nVal = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol * int32(2) + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 && libc.Int32FromUint8(op) == int32(SQLITE_DELETE) { + nVal = 0 + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 { + nVal = nVal + 1 + } + goto _11 + _11: + ; + i = i + 1 + } + } else { + nVal = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol + } + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = _sessionChangesetBufferRecord(tls, p, nVal, pnRec) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + **(**uintptr)(__ccgo_up(paRec)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext += **(**int32)(__ccgo_up(pnRec)) + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 { + v3 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8 + } else { + v3 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + } + apOld = v3 + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 { + v6 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + } else { + v6 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8 + } + apNew = v6 + /* If this is an UPDATE or DELETE, read the old.* record. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != int32(SQLITE_INSERT) && ((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 || (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_DELETE)) { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 { + v10 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + } else { + v10 = uintptr(0) + } + abPK = v10 + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = _sessionReadRecord(tls, p, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol, abPK, apOld, uintptr(0)) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + } + /* If this is an INSERT or UPDATE, read the new.* record. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != int32(SQLITE_DELETE) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = _sessionReadRecord(tls, p, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol, uintptr(0), apNew, pbEmpty) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + } + if ((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 || (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0) && (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_UPDATE) { + /* If this is an UPDATE that is part of a patchset, then all PK and + ** modified fields are present in the new.* record. The old.* record + ** is currently completely empty. This block shifts the PK fields from + ** new.* to old.*, to accommodate the code that reads these arrays. */ + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 { + **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8)) + if **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8)) == uintptr(0) { + v2 = _sqlite3CorruptError(tls, int32(237409)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + return v2 + } + **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8)) = uintptr(0) + } + goto _15 + _15: + ; + i = i + 1 + } + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_INSERT) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = int32(SQLITE_DELETE) + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_DELETE) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = int32(SQLITE_INSERT) + } + } + } + } + /* If this is an UPDATE that is part of a changeset, then check that + ** there are no fields in the old.* record that are not (a) PK fields, + ** or (b) also present in the new.* record. + ** + ** Such records are technically corrupt, but the rebaser was at one + ** point generating them. Under most circumstances this is benign, but + ** can cause spurious SQLITE_RANGE errors when applying the changeset. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 && (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_UPDATE) { + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i)))) == 0 && **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8)) == uintptr(0) { + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8))) + **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8)) = uintptr(0) + } + goto _17 + _17: + ; + i = i + 1 + } + } + } + return int32(SQLITE_ROW) +} + +// C documentation +// +// /* +// ** The input pointer currently points to the second byte of a table-header. +// ** Specifically, to the following: +// ** +// ** + number of columns in table (varint) +// ** + array of PK flags (1 byte per column), +// ** + table name (nul terminated). +// ** +// ** This function decodes the table-header and populates the p->nCol, +// ** p->zTab and p->abPK[] variables accordingly. The p->apValue[] array is +// ** also allocated or resized according to the new value of p->nCol. The +// ** input pointer is left pointing to the byte following the table header. +// ** +// ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code +// ** is returned and the final values of the various fields enumerated above +// ** are undefined. +// */ +func _sessionChangesetReadTblhdr(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iPK Tsize_t + var nByte, nVarint, v2 int32 + var v1 uintptr + var _ /* nCopy at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _ = iPK, nByte, nVarint, v1, v2 + **(**int32)(__ccgo_up(bp)) = _sessionChangesetBufferTblhdr(tls, p, bp+4) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + nVarint = _sessionVarintGet(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData+uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext), p+120) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol > 0 { + **(**int32)(__ccgo_up(bp + 4)) = **(**int32)(__ccgo_up(bp + 4)) - nVarint + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext += nVarint + nByte = libc.Int32FromUint64(libc.Uint64FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*uint64(8)*uint64(2) + libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 4)))) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FnBuf = 0 + _sessionBufferGrow(tls, p+72, int64(nByte), bp) + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(237271)) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + iPK = uint64(8) * libc.Uint64FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) * uint64(2) + libc.X__builtin___memset_chk(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf, 0, iPK, ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf+uintptr(iPK), (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData+uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 4))), ^t__predefined_size_t(0)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext += **(**int32)(__ccgo_up(bp + 4)) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue == uintptr(0) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK = uintptr(0) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab = uintptr(0) + } else { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol*int32(2))*8 + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK != 0 { + v1 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) + } else { + v1 = uintptr(0) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab = v1 + } + v2 = **(**int32)(__ccgo_up(bp)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + return v2 +} + +// C documentation +// +// /* +// ** Do the work for either sqlite3changeset_start() or start_strm(). +// */ +func _sessionChangesetStart(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, nChangeset int32, pChangeset uintptr, bInvert int32, bSkipEmpty int32) (r int32) { + var nByte, v1 int32 + var pRet uintptr + _, _, _ = nByte, pRet, v1 /* Number of bytes to allocate for iterator */ + /* Zero the output variable in case an error occurs. */ + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + /* Allocate and initialize the iterator structure. */ + nByte = int32(152) + pRet = Xsqlite3_malloc(tls, nByte) + if !(pRet != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pRet, 0, uint64(152), ^t__predefined_size_t(0)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FaData = pChangeset + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FnData = nChangeset + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FxInput = __ccgo_fp_xInput + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FpIn = pIn + if __ccgo_fp_xInput != 0 { + v1 = 0 + } else { + v1 = int32(1) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FbEof = v1 + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).FbInvert = bInvert + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).FbSkipEmpty = bSkipEmpty + /* Populate the output variable and return success. */ + **(**uintptr)(__ccgo_up(pp)) = pRet + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Formulate a statement to DELETE a row from database db. Assuming a table +// ** structure like this: +// ** +// ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c)); +// ** +// ** The DELETE statement looks like this: +// ** +// ** DELETE FROM x WHERE a = :1 AND c = :3 AND (:5 OR b IS :2 AND d IS :4) +// ** +// ** Variable :5 (nCol+1) is a boolean. It should be set to 0 if we require +// ** matching b and d values, or 1 otherwise. The second case comes up if the +// ** conflict handler is invoked with NOTFOUND and returns CHANGESET_REPLACE. +// ** +// ** If successful, SQLITE_OK is returned and SessionApplyCtx.pDelete is left +// ** pointing to the prepared version of the SQL statement. +// */ +func _sessionDeleteRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, nPk int32 + var zSep uintptr + var _ /* buf at bp+8 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _, _, _ = i, nPk, zSep + zSep = __ccgo_ts + 1702 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} + nPk = 0 + _sessionAppendStr(tls, bp+8, __ccgo_ts+36326, bp) + _sessionAppendIdent(tls, bp+8, zTab, bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+36237, bp) + i = 0 + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 { + nPk = nPk + 1 + _sessionAppendStr(tls, bp+8, zSep, bp) + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+36232, bp) + _sessionAppendInteger(tls, bp+8, i+int32(1), bp) + zSep = __ccgo_ts + 23951 + } + goto _1 + _1: + ; + i = i + 1 + } + if nPk < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol { + _sessionAppendStr(tls, bp+8, __ccgo_ts+36344, bp) + _sessionAppendInteger(tls, bp+8, (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol+int32(1), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35756, bp) + zSep = __ccgo_ts + 1702 + i = 0 + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + if !(**(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0) { + _sessionAppendStr(tls, bp+8, zSep, bp) + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+36320, bp) + _sessionAppendInteger(tls, bp+8, i+int32(1), bp) + zSep = __ccgo_ts + 36352 + } + goto _2 + _2: + ; + i = i + 1 + } + _sessionAppendStr(tls, bp+8, __ccgo_ts+5601, bp) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionPrepare(tls, db, p+8, p+128, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +func _sessionDiffFindModified(tls *libc.TLS, pSession uintptr, pTab uintptr, zFrom uintptr, zExpr uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iRowid Ti64 + var pDiffCtx, z1, z2, zExpr2, zStmt uintptr + var rc int32 + var v1 int64 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = iRowid, pDiffCtx, rc, z1, z2, zExpr2, zStmt, v1 + rc = SQLITE_OK + zExpr2 = _sessionExprCompareOther(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, zFrom, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK) + if zExpr2 == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + z1 = _sessionAllCols(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, pTab) + z2 = _sessionAllCols(tls, zFrom, pTab) + zStmt = Xsqlite3_mprintf(tls, __ccgo_ts+35870, libc.VaList(bp+16, z1, z2, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zFrom, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zExpr, zExpr2)) + if zStmt == uintptr(0) || z1 == uintptr(0) || z2 == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, zStmt, -int32(1), bp, uintptr(0)) + if rc == SQLITE_OK { + pDiffCtx = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx + (*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FpStmt = **(**uintptr)(__ccgo_up(bp)) + (*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FnOldOff = (*TSessionTable)(unsafe.Pointer(pTab)).FnCol + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + v1 = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } else { + v1 = 0 + } + iRowid = v1 + _sessionPreupdateOneChange(tls, int32(SQLITE_UPDATE), iRowid, pSession, pTab) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + Xsqlite3_free(tls, zStmt) + Xsqlite3_free(tls, z1) + Xsqlite3_free(tls, z2) + } + return rc +} + +// C documentation +// +// /* +// ** If the SessionInput object passed as the only argument is a streaming +// ** object and the buffer is full, discard some data to free up space. +// */ +func _sessionDiscardData(tls *libc.TLS, pIn uintptr) { + var nMove int32 + _ = nMove + if (*TSessionInput)(unsafe.Pointer(pIn)).FxInput != 0 && (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent >= _sessions_strm_chunk_size { + nMove = (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf - (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent + if nMove > 0 { + libc.X__builtin___memmove_chk(tls, (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf, (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf+uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent), libc.Uint64FromInt32(nMove), ^t__predefined_size_t(0)) + } + (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf -= (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent + **(**int32)(__ccgo_up(pIn + 8)) -= (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent + (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent = 0 + (*TSessionInput)(unsafe.Pointer(pIn)).FnData = (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf + } +} + +func _sessionExprCompareOther(tls *libc.TLS, nCol int32, zDb1 uintptr, zDb2 uintptr, zTab uintptr, azCol uintptr, abPK uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bHave, i int32 + var zRet, zSep uintptr + _, _, _, _ = bHave, i, zRet, zSep + zSep = __ccgo_ts + 1702 + zRet = uintptr(0) + bHave = 0 + i = 0 + for { + if !(i < nCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(abPK + uintptr(i)))) == 0 { + bHave = int32(1) + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+35715, libc.VaList(bp+8, zRet, zSep, zDb1, zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)), zDb2, zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)))) + zSep = __ccgo_ts + 35756 + if zRet == uintptr(0) { + break + } + } + goto _1 + _1: + ; + i = i + 1 + } + if bHave == 0 { + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+1848, 0) + } + return zRet +} + +func _sessionExprComparePK(tls *libc.TLS, nCol int32, zDb1 uintptr, zDb2 uintptr, zTab uintptr, azCol uintptr, abPK uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var i int32 + var zRet, zSep uintptr + _, _, _ = i, zRet, zSep + zSep = __ccgo_ts + 1702 + zRet = uintptr(0) + i = 0 + for { + if !(i < nCol) { + break + } + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+35681, libc.VaList(bp+8, zRet, zSep, zDb1, zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)), zDb2, zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)))) + zSep = __ccgo_ts + 23951 + if zRet == uintptr(0) { + break + } + } + goto _1 + _1: + ; + i = i + 1 + } + return zRet +} + +// C documentation +// +// /* +// ** Generate either a changeset (if argument bPatchset is zero) or a patchset +// ** (if it is non-zero) based on the current contents of the session object +// ** passed as the first argument. +// ** +// ** If no error occurs, SQLITE_OK is returned and the new changeset/patchset +// ** stored in output variables *pnChangeset and *ppChangeset. Or, if an error +// ** occurs, an SQLite error code is returned and both output variables set +// ** to 0. +// */ +func _sessionGenerateChangeset(tls *libc.TLS, pSession uintptr, bPatchset int32, __ccgo_fp_xOutput uintptr, pOut uintptr, pnChangeset uintptr, ppChangeset uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pTab, zName uintptr + var i, iCol, nNoop, nOldCol, nRewind int32 + var _ /* buf at bp+0 */ TSessionBuffer + var _ /* pSel at bp+24 */ uintptr + var _ /* rc at bp+16 */ int32 + _, _, _, _, _, _, _, _, _ = db, i, iCol, nNoop, nOldCol, nRewind, p, pTab, zName + db = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb /* Used to iterate through attached tables */ + **(**TSessionBuffer)(__ccgo_up(bp)) = TSessionBuffer{} /* Return code */ + /* Zero the output variables in case an error occurs. If this session + ** object is already in the error state (sqlite3_session.rc != SQLITE_OK), + ** this call will be a no-op. */ + if __ccgo_fp_xOutput == uintptr(0) { + **(**int32)(__ccgo_up(pnChangeset)) = 0 + **(**uintptr)(__ccgo_up(ppChangeset)) = uintptr(0) + } + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 { + return (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc + } + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db)) + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_exec(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, __ccgo_ts+36175, uintptr(0), uintptr(0), uintptr(0)) + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + return **(**int32)(__ccgo_up(bp + 16)) + } + pTab = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable + for { + if !(**(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && pTab != 0) { + break + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry != 0 { + zName = (*TSessionTable)(unsafe.Pointer(pTab)).FzName /* Used to iterate through hash buckets */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) /* SELECT statement to query table pTab */ + nRewind = (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf /* Size of buffer after writing tbl header */ + nOldCol = (*TSessionTable)(unsafe.Pointer(pTab)).FnCol + /* Check the table schema is still Ok. */ + **(**int32)(__ccgo_up(bp + 16)) = _sessionReinitTable(tls, pSession, pTab) + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && (*TSessionTable)(unsafe.Pointer(pTab)).FnCol != nOldCol { + **(**int32)(__ccgo_up(bp + 16)) = _sessionUpdateChanges(tls, pSession, pTab) + } + /* Write a table header */ + _sessionAppendTableHdr(tls, bp, bPatchset, pTab, bp+16) + /* Build and compile a statement to execute: */ + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionSelectStmt(tls, db, 0, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, zName, (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK, bp+24, uintptr(0)) + } + nNoop = (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnChange && **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK) { + break + } /* Used to iterate through changes */ + p = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*8)) + for { + if !(**(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && p != 0) { + break + } + **(**int32)(__ccgo_up(bp + 16)) = _sessionSelectBind(tls, **(**uintptr)(__ccgo_up(bp + 24)), (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK, p) + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + goto _3 + } + if Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 24))) == int32(SQLITE_ROW) { + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INSERT) { + _sessionAppendByte(tls, bp, uint8(SQLITE_INSERT), bp+16) + _sessionAppendByte(tls, bp, (*TSessionChange)(unsafe.Pointer(p)).FbIndirect, bp+16) + iCol = 0 + for { + if !(iCol < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + _sessionAppendCol(tls, bp, **(**uintptr)(__ccgo_up(bp + 24)), iCol, bp+16) + goto _4 + _4: + ; + iCol = iCol + 1 + } + } else { + **(**int32)(__ccgo_up(bp + 16)) = _sessionAppendUpdate(tls, bp, bPatchset, **(**uintptr)(__ccgo_up(bp + 24)), p, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK) + } + } else { + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(p)).Fop) != int32(SQLITE_INSERT) { + **(**int32)(__ccgo_up(bp + 16)) = _sessionAppendDelete(tls, bp, bPatchset, p, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK) + } + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp + 24))) + } + /* If the buffer is now larger than sessions_strm_chunk_size, pass + ** its contents to the xOutput() callback. */ + if __ccgo_fp_xOutput != 0 && **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf > nNoop && (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf > _sessions_strm_chunk_size { + **(**int32)(__ccgo_up(bp + 16)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf) + nNoop = -int32(1) + (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf = 0 + } + goto _3 + _3: + ; + p = (*TSessionChange)(unsafe.Pointer(p)).FpNext + } + goto _2 + _2: + ; + i = i + 1 + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 24))) + if (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf == nNoop { + (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf = nRewind + } + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + if __ccgo_fp_xOutput == uintptr(0) { + **(**int32)(__ccgo_up(pnChangeset)) = (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf + **(**uintptr)(__ccgo_up(ppChangeset)) = (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf + (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf = uintptr(0) + } else { + if (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf > 0 { + **(**int32)(__ccgo_up(bp + 16)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf) + } + } + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf) + Xsqlite3_exec(tls, db, __ccgo_ts+36195, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** If required, grow the hash table used to store changes on table pTab +// ** (part of the session pSession). If a fatal OOM error occurs, set the +// ** session object to failed and return SQLITE_ERROR. Otherwise, return +// ** SQLITE_OK. +// ** +// ** It is possible that a non-fatal OOM error occurs in this function. In +// ** that case the hash-table does not grow, but SQLITE_OK is returned anyway. +// ** Growing the hash table in this case is a performance optimization only, +// ** it is not required for correct operation. +// */ +func _sessionGrowHash(tls *libc.TLS, pSession uintptr, bPatchset int32, pTab uintptr) (r int32) { + var apNew, p, pNext uintptr + var bPkOnly, i, iHash, v1 int32 + var nNew Tsqlite3_int64 + _, _, _, _, _, _, _, _ = apNew, bPkOnly, i, iHash, nNew, p, pNext, v1 + if (*TSessionTable)(unsafe.Pointer(pTab)).FnChange == 0 || (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry >= (*TSessionTable)(unsafe.Pointer(pTab)).FnChange/int32(2) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FnChange != 0 { + v1 = (*TSessionTable)(unsafe.Pointer(pTab)).FnChange + } else { + v1 = int32(128) + } + nNew = int64(2) * int64(v1) + apNew = _sessionMalloc64(tls, pSession, libc.Int64FromUint64(uint64(8)*libc.Uint64FromInt64(nNew))) + if apNew == uintptr(0) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FnChange == 0 { + return int32(SQLITE_ERROR) + } + return SQLITE_OK + } + libc.X__builtin___memset_chk(tls, apNew, 0, uint64(uint64(8)*libc.Uint64FromInt64(nNew)), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnChange) { + break + } + p = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*8)) + for { + if !(p != 0) { + break + } + bPkOnly = libc.BoolInt32(libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(p)).Fop) == int32(SQLITE_DELETE) && bPatchset != 0) + iHash = libc.Int32FromUint32(_sessionChangeHash(tls, pTab, bPkOnly, (*TSessionChange)(unsafe.Pointer(p)).FaRecord, int32(nNew))) + pNext = (*TSessionChange)(unsafe.Pointer(p)).FpNext + (*TSessionChange)(unsafe.Pointer(p)).FpNext = **(**uintptr)(__ccgo_up(apNew + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up(apNew + uintptr(iHash)*8)) = p + goto _3 + _3: + ; + p = pNext + } + goto _2 + _2: + ; + i = i + 1 + } + _sessionFree(tls, pSession, (*TSessionTable)(unsafe.Pointer(pTab)).FapChange) + (*TSessionTable)(unsafe.Pointer(pTab)).FnChange = int32(nNew) + (*TSessionTable)(unsafe.Pointer(pTab)).FapChange = apNew + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is called to initialize the SessionTable.nCol, azCol[] +// ** abPK[] and azDflt[] members of SessionTable object pTab. If these +// ** fields are already initialized, this function is a no-op. +// ** +// ** If an error occurs, an error code is stored in sqlite3_session.rc and +// ** non-zero returned. Or, if no error occurs but the table has no primary +// ** key, sqlite3_session.rc is left set to SQLITE_OK and non-zero returned to +// ** indicate that updates on this table should be ignored. SessionTable.abPK +// ** is set to NULL in this case. +// */ +func _sessionInitTable(tls *libc.TLS, pSession uintptr, pTab uintptr, db uintptr, zDb uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, rc int32 + var v1 uintptr + var _ /* abPK at bp+0 */ uintptr + _, _, _ = i, rc, v1 + rc = SQLITE_OK + if (*TSessionTable)(unsafe.Pointer(pTab)).FnCol == 0 { + Xsqlite3_free(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol) + (*TSessionTable)(unsafe.Pointer(pTab)).FabPK = uintptr(0) + if pSession == uintptr(0) || (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK != 0 { + v1 = pTab + 28 + } else { + v1 = uintptr(0) + } + rc = _sessionTableInfo(tls, pSession, db, zDb, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, pTab+16, pTab+20, uintptr(0), pTab+32, pTab+40, pTab+48, bp, v1) + if rc == SQLITE_OK { + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i))) != 0 { + (*TSessionTable)(unsafe.Pointer(pTab)).FabPK = **(**uintptr)(__ccgo_up(bp)) + break + } + goto _2 + _2: + ; + i = i + 1 + } + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+13177, (*TSessionTable)(unsafe.Pointer(pTab)).FzName) { + (*TSessionTable)(unsafe.Pointer(pTab)).FbStat1 = int32(1) + } + if pSession != 0 && (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize != 0 { + v1 = pSession + 64 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + uint64(libc.Uint64FromInt32(libc.Int32FromInt32(1)+_sessionVarintLen(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol)+(*TSessionTable)(unsafe.Pointer(pTab)).FnCol)+libc.Xstrlen(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName)+libc.Uint64FromInt32(1))) + } + } + } + if pSession != 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = rc + return libc.BoolInt32(rc != 0 || (*TSessionTable)(unsafe.Pointer(pTab)).FabPK == uintptr(0)) + } + return rc +} + +// C documentation +// +// /* +// ** Formulate and prepare an INSERT statement to add a record to table zTab. +// ** For example: +// ** +// ** INSERT INTO main."zTab" VALUES(?1, ?2, ?3 ...); +// ** +// ** If successful, SQLITE_OK is returned and SessionApplyCtx.pInsert is left +// ** pointing to the prepared version of the SQL statement. +// */ +func _sessionInsertRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var _ /* buf at bp+8 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _ = i + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} + _sessionAppendStr(tls, bp+8, __ccgo_ts+36357, bp) + _sessionAppendIdent(tls, bp+8, zTab, bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+23957, bp) + i = 0 + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + if i != 0 { + _sessionAppendStr(tls, bp+8, __ccgo_ts+16558, bp) + } + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)), bp) + goto _1 + _1: + ; + i = i + 1 + } + _sessionAppendStr(tls, bp+8, __ccgo_ts+36375, bp) + i = int32(1) + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + _sessionAppendStr(tls, bp+8, __ccgo_ts+36386, bp) + goto _2 + _2: + ; + i = i + 1 + } + _sessionAppendStr(tls, bp+8, __ccgo_ts+5601, bp) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionPrepare(tls, db, p+16, p+128, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Arguments aLeft and aRight both point to buffers containing change +// ** records with nCol columns. This function "merges" the two records into +// ** a single records which is written to the buffer at *paOut. *paOut is +// ** then set to point to one byte after the last byte written before +// ** returning. +// ** +// ** The merging of records is done as follows: For each column, if the +// ** aRight record contains a value for the column, copy the value from +// ** their. Otherwise, if aLeft contains a value, copy it. If neither +// ** record contains a value for a given column, then neither does the +// ** output record. +// */ +func _sessionMergeRecord(tls *libc.TLS, paOut uintptr, nCol int32, aLeft uintptr, aRight uintptr) { + var a1, a2, aOut uintptr + var iCol, n1, n2 int32 + _, _, _, _, _, _ = a1, a2, aOut, iCol, n1, n2 + a1 = aLeft /* Cursor used to iterate through aLeft */ + a2 = aRight /* Cursor used to iterate through aRight */ + aOut = **(**uintptr)(__ccgo_up(paOut)) /* Used to iterate from 0 to nCol */ + iCol = 0 + for { + if !(iCol < nCol) { + break + } + n1 = _sessionSerialLen(tls, a1) + n2 = _sessionSerialLen(tls, a2) + if **(**Tu8)(__ccgo_up(a2)) != 0 { + libc.X__builtin___memcpy_chk(tls, aOut, a2, libc.Uint64FromInt32(n2), ^t__predefined_size_t(0)) + aOut = aOut + uintptr(n2) + } else { + libc.X__builtin___memcpy_chk(tls, aOut, a1, libc.Uint64FromInt32(n1), ^t__predefined_size_t(0)) + aOut = aOut + uintptr(n1) + } + a1 = a1 + uintptr(n1) + a2 = a2 + uintptr(n2) + goto _1 + _1: + ; + iCol = iCol + 1 + } + **(**uintptr)(__ccgo_up(paOut)) = aOut +} + +// C documentation +// +// /* +// ** This function is used by changeset_concat() to merge two UPDATE changes +// ** on the same row. +// */ +func _sessionMergeUpdate(tls *libc.TLS, paOut uintptr, pTab uintptr, bPatchset int32, aOldRecord1 uintptr, aOldRecord2 uintptr, aNewRecord1 uintptr, aNewRecord2 uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aNew, aNew1, aOld, aOld1, aOut, v2 uintptr + var bRequired, i int32 + var _ /* aNew1 at bp+16 */ uintptr + var _ /* aNew2 at bp+24 */ uintptr + var _ /* aOld1 at bp+0 */ uintptr + var _ /* aOld2 at bp+8 */ uintptr + var _ /* nNew at bp+36 */ int32 + var _ /* nNew at bp+44 */ int32 + var _ /* nOld at bp+32 */ int32 + var _ /* nOld at bp+40 */ int32 + _, _, _, _, _, _, _, _ = aNew, aNew1, aOld, aOld1, aOut, bRequired, i, v2 + **(**uintptr)(__ccgo_up(bp)) = aOldRecord1 + **(**uintptr)(__ccgo_up(bp + 8)) = aOldRecord2 + **(**uintptr)(__ccgo_up(bp + 16)) = aNewRecord1 + **(**uintptr)(__ccgo_up(bp + 24)) = aNewRecord2 + aOut = **(**uintptr)(__ccgo_up(paOut)) + if bPatchset == 0 { + bRequired = 0 + /* Write the old.* vector first. */ + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + aOld = _sessionMergeValue(tls, bp, bp+8, bp+32) + aNew = _sessionMergeValue(tls, bp+16, bp+24, bp+36) + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 || **(**int32)(__ccgo_up(bp + 32)) != **(**int32)(__ccgo_up(bp + 36)) || libc.Xmemcmp(tls, aOld, aNew, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 36)))) != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i)))) == 0 { + bRequired = int32(1) + } + libc.X__builtin___memcpy_chk(tls, aOut, aOld, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 32))), ^t__predefined_size_t(0)) + aOut = aOut + uintptr(**(**int32)(__ccgo_up(bp + 32))) + } else { + v2 = aOut + aOut = aOut + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8('\000') + } + goto _1 + _1: + ; + i = i + 1 + } + if !(bRequired != 0) { + return 0 + } + } + /* Write the new.* vector */ + **(**uintptr)(__ccgo_up(bp)) = aOldRecord1 + **(**uintptr)(__ccgo_up(bp + 8)) = aOldRecord2 + **(**uintptr)(__ccgo_up(bp + 16)) = aNewRecord1 + **(**uintptr)(__ccgo_up(bp + 24)) = aNewRecord2 + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + aOld1 = _sessionMergeValue(tls, bp, bp+8, bp+40) + aNew1 = _sessionMergeValue(tls, bp+16, bp+24, bp+44) + if bPatchset == 0 && (**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 || **(**int32)(__ccgo_up(bp + 40)) == **(**int32)(__ccgo_up(bp + 44)) && 0 == libc.Xmemcmp(tls, aOld1, aNew1, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 44))))) { + v2 = aOut + aOut = aOut + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8('\000') + } else { + libc.X__builtin___memcpy_chk(tls, aOut, aNew1, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 44))), ^t__predefined_size_t(0)) + aOut = aOut + uintptr(**(**int32)(__ccgo_up(bp + 44))) + } + goto _3 + _3: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up(paOut)) = aOut + return int32(1) +} + +// C documentation +// +// /* +// ** Prepare a statement against database handle db that SELECTs a single +// ** row containing the default values for each column in table pTab. For +// ** example, if pTab is declared as: +// ** +// ** CREATE TABLE pTab(a PRIMARY KEY, b DEFAULT 123, c DEFAULT 'abcd'); +// ** +// ** Then this function prepares and returns the SQL statement: +// ** +// ** SELECT NULL, 123, 'abcd'; +// */ +func _sessionPrepareDfltStmt(tls *libc.TLS, db uintptr, pTab uintptr, ppStmt uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var ii int32 + var zDflt, zSep, v2 uintptr + var _ /* rc at bp+16 */ int32 + var _ /* sql at bp+0 */ TSessionBuffer + _, _, _, _ = ii, zDflt, zSep, v2 + **(**TSessionBuffer)(__ccgo_up(bp)) = TSessionBuffer{} + **(**int32)(__ccgo_up(bp + 16)) = SQLITE_OK + zSep = __ccgo_ts + 11885 + ii = 0 + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + _sessionAppendPrintf(tls, bp, bp+16, __ccgo_ts+35674, 0) + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FazDflt + uintptr(ii)*8)) != 0 { + v2 = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FazDflt + uintptr(ii)*8)) + } else { + v2 = __ccgo_ts + 1703 + } + zDflt = v2 + _sessionAppendPrintf(tls, bp, bp+16, __ccgo_ts+5571, libc.VaList(bp+32, zSep, zDflt)) + zSep = __ccgo_ts + 16558 + goto _1 + _1: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_prepare_v2(tls, db, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf, -int32(1), ppStmt, uintptr(0)) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** This function is only called from within a pre-update-hook callback. +// ** It determines if the current pre-update-hook change affects the same row +// ** as the change stored in argument pChange. If so, it returns true. Otherwise +// ** if the pre-update-hook does not affect the same row as pChange, it returns +// ** false. +// */ +func _sessionPreupdateEqual(tls *libc.TLS, pSession uintptr, iRowid Ti64, pTab uintptr, pChange uintptr, op int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a, z, v2 uintptr + var eType, iCol, iIdx, rc int32 + var _ /* iVal at bp+8 */ Ti64 + var _ /* n at bp+24 */ int32 + var _ /* pVal at bp+0 */ uintptr + var _ /* rVal at bp+16 */ float64 + _, _, _, _, _, _, _ = a, eType, iCol, iIdx, rc, z, v2 /* Used to iterate through columns */ + a = (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord /* Cursor used to scan change record */ + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a))) != int32(SQLITE_INTEGER) { + return 0 + } + return libc.BoolInt32(_sessionGetI64(tls, a+1) == iRowid) + } + iCol = 0 + for { + if !(iCol < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if !(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(iCol))) != 0) { + a = a + uintptr(_sessionSerialLen(tls, a)) + } else { + v2 = a + a = a + 1 /* Error code from preupdate_new/old */ + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v2))) /* Type of value from change record */ + iIdx = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(iCol)*4)) + /* The following calls to preupdate_new() and preupdate_old() can not + ** fail. This is because they cache their return values, and by the + ** time control flows to here they have already been called once from + ** within sessionPreupdateHash(). The first two asserts below verify + ** this (that the method has already been called). */ + if op == int32(SQLITE_INSERT) { + /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp) + } else { + /* assert( db->pPreUpdate->pUnpacked ); */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp) + } + _ = rc /* Suppress warning about unused variable */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp))) != eType { + return 0 + } + /* A SessionChange object never has a NULL value in a PK column */ + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + **(**Ti64)(__ccgo_up(bp + 8)) = _sessionGetI64(tls, a) + a = a + uintptr(8) + if eType == int32(SQLITE_INTEGER) { + if Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(bp))) != **(**Ti64)(__ccgo_up(bp + 8)) { + return 0 + } + } else { + libc.X__builtin___memcpy_chk(tls, bp+16, bp+8, uint64(8), ^t__predefined_size_t(0)) + if Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(bp))) != **(**float64)(__ccgo_up(bp + 16)) { + return 0 + } + } + } else { + a = a + uintptr(_sessionVarintGet(tls, a, bp+24)) + if Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(bp))) != **(**int32)(__ccgo_up(bp + 24)) { + return 0 + } + if eType == int32(SQLITE_TEXT) { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + z = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(bp))) + } + if **(**int32)(__ccgo_up(bp + 24)) > 0 && libc.Xmemcmp(tls, a, z, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 24)))) != 0 { + return 0 + } + a = a + uintptr(**(**int32)(__ccgo_up(bp + 24))) + } + } + goto _1 + _1: + ; + iCol = iCol + 1 + } + return int32(1) +} + +// C documentation +// +// /* +// ** This function may only be called from within a pre-update callback. +// ** It calculates a hash based on the primary key values of the old.* or +// ** new.* row currently available and, assuming no error occurs, writes it to +// ** *piHash before returning. If the primary key contains one or more NULL +// ** values, *pbNullPK is set to true before returning. +// ** +// ** If an error occurs, an SQLite error code is returned and the final values +// ** of *piHash asn *pbNullPK are undefined. Otherwise, SQLITE_OK is returned +// ** and the output variables are set as described above. +// */ +func _sessionPreupdateHash(tls *libc.TLS, pSession uintptr, iRowid Ti64, pTab uintptr, bNew int32, piHash uintptr, pbNullPK uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eType, i, iIdx, n, rc int32 + var h uint32 + var z uintptr + var _ /* iVal at bp+8 */ Ti64 + var _ /* pVal at bp+0 */ uintptr + var _ /* rVal at bp+16 */ float64 + _, _, _, _, _, _, _ = eType, h, i, iIdx, n, rc, z + h = uint32(0) /* Used to iterate through columns */ + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + h = _sessionHashAppendI64(tls, h, iRowid) + } else { + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 { + iIdx = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(i)*4)) + if bNew != 0 { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp) + } else { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp) + } + if rc != SQLITE_OK { + return rc + } + eType = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp))) + h = _sessionHashAppendType(tls, h, eType) + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + if eType == int32(SQLITE_INTEGER) { + **(**Ti64)(__ccgo_up(bp + 8)) = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + **(**float64)(__ccgo_up(bp + 16)) = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(bp))) + libc.X__builtin___memcpy_chk(tls, bp+8, bp+16, uint64(8), ^t__predefined_size_t(0)) + } + h = _sessionHashAppendI64(tls, h, **(**Ti64)(__ccgo_up(bp + 8))) + } else { + if eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB) { + if eType == int32(SQLITE_TEXT) { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + z = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(bp))) + } + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(bp))) + if !(z != 0) && (eType != int32(SQLITE_BLOB) || n > 0) { + return int32(SQLITE_NOMEM) + } + h = _sessionHashAppendBlob(tls, h, n, z) + } else { + **(**int32)(__ccgo_up(pbNullPK)) = int32(1) + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + **(**int32)(__ccgo_up(piHash)) = libc.Int32FromUint32(h % libc.Uint32FromInt32((*TSessionTable)(unsafe.Pointer(pTab)).FnChange)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is only called from with a pre-update-hook reporting a +// ** change on table pTab (attached to session pSession). The type of change +// ** (UPDATE, INSERT, DELETE) is specified by the first argument. +// ** +// ** Unless one is already present or an error occurs, an entry is added +// ** to the changed-rows hash table associated with table pTab. +// */ +func _sessionPreupdateOneChange(tls *libc.TLS, op int32, iRowid Ti64, pSession uintptr, pTab uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var i, iIdx, iIdx1, nExpect, rc int32 + var p, pC uintptr + var _ /* bNull at bp+4 */ int32 + var _ /* iHash at bp+0 */ int32 + var _ /* nByte at bp+56 */ Tsqlite3_int64 + var _ /* p at bp+64 */ uintptr + var _ /* p at bp+72 */ uintptr + var _ /* stat1 at bp+8 */ TSessionStat1Ctx + _, _, _, _, _, _, _ = i, iIdx, iIdx1, nExpect, p, pC, rc + **(**int32)(__ccgo_up(bp + 4)) = 0 + rc = SQLITE_OK + nExpect = 0 + **(**TSessionStat1Ctx)(__ccgo_up(bp + 8)) = TSessionStat1Ctx{} + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 { + return + } + /* Load table details if required */ + if _sessionInitTable(tls, pSession, pTab, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb) != 0 { + return + } + /* Check the number of columns in this xPreUpdate call matches the + ** number of columns in the table. */ + nExpect = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx) + if (*TSessionTable)(unsafe.Pointer(pTab)).FnTotalCol < nExpect { + if _sessionReinitTable(tls, pSession, pTab) != 0 { + return + } + if _sessionUpdateChanges(tls, pSession, pTab) != 0 { + return + } + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FnTotalCol != nExpect { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = int32(SQLITE_SCHEMA) + return + } + /* Grow the hash table if required */ + if _sessionGrowHash(tls, pSession, 0, pTab) != 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = int32(SQLITE_NOMEM) + return + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FbStat1 != 0 { + (**(**TSessionStat1Ctx)(__ccgo_up(bp + 8))).Fhook = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook + (**(**TSessionStat1Ctx)(__ccgo_up(bp + 8))).FpSession = pSession + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx = bp + 8 + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew = __ccgo_fp(_sessionStat1New) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld = __ccgo_fp(_sessionStat1Old) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount = __ccgo_fp(_sessionStat1Count) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth = __ccgo_fp(_sessionStat1Depth) + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpZeroBlob == uintptr(0) { + p = _sqlite3ValueNew(tls, uintptr(0)) + if p == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto error_out + } + _sqlite3ValueSetStr(tls, p, 0, __ccgo_ts+1702, uint8(0), libc.UintptrFromInt32(0)) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpZeroBlob = p + } + } + /* Calculate the hash-key for this change. If the primary key of the row + ** includes a NULL value, exit early. Such changes are ignored by the + ** session module. */ + rc = _sessionPreupdateHash(tls, pSession, iRowid, pTab, libc.BoolInt32(op == int32(SQLITE_INSERT)), bp, bp+4) + if rc != SQLITE_OK { + goto error_out + } + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + pC = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(**(**int32)(__ccgo_up(bp)))*8)) + for { + if !(pC != 0) { + break + } + if _sessionPreupdateEqual(tls, pSession, iRowid, pTab, pC, op) != 0 { + break + } + goto _1 + _1: + ; + pC = (*TSessionChange)(unsafe.Pointer(pC)).FpNext + } + if pC == uintptr(0) { /* Used to iterate through columns */ + (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry = (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry + 1 + /* Figure out how large an allocation is required */ + **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) = int64(32) + i = (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + iIdx = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(i)*4)) + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) + if op != int32(SQLITE_INSERT) { + /* This may fail if the column has a non-NULL default and was added + ** using ALTER TABLE ADD COLUMN after this record was created. */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp+64) + } else { + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 { + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp+64) + } + } + if rc == SQLITE_OK { + /* This may fail if SQLite value p contains a utf-16 string that must + ** be converted to utf-8 and an OOM error occurs while doing so. */ + rc = _sessionSerializeValue(tls, uintptr(0), **(**uintptr)(__ccgo_up(bp + 64)), bp+56) + } + if rc != SQLITE_OK { + goto error_out + } + goto _2 + _2: + ; + i = i + 1 + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) = **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) + int64(9) /* Size of rowid field - an integer */ + } + /* Allocate the change object */ + pC = _sessionMalloc64(tls, pSession, **(**Tsqlite3_int64)(__ccgo_up(bp + 56))) + if !(pC != 0) { + rc = int32(SQLITE_NOMEM) + goto error_out + } else { + libc.X__builtin___memset_chk(tls, pC, 0, uint64(32), ^t__predefined_size_t(0)) + (*TSessionChange)(unsafe.Pointer(pC)).FaRecord = pC + 1*32 + } + /* Populate the change object. None of the preupdate_old(), + ** preupdate_new() or SerializeValue() calls below may fail as all + ** required values and encodings have already been cached in memory. + ** It is not possible for an OOM to occur in this block. */ + **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) = 0 + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + **(**Tu8)(__ccgo_up((*TSessionChange)(unsafe.Pointer(pC)).FaRecord)) = uint8(SQLITE_INTEGER) + _sessionPutI64(tls, (*TSessionChange)(unsafe.Pointer(pC)).FaRecord+1, iRowid) + **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) = int64(9) + } + i = (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + **(**uintptr)(__ccgo_up(bp + 72)) = uintptr(0) + iIdx1 = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(i)*4)) + if op != int32(SQLITE_INSERT) { + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx1, bp+72) + } else { + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 { + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx1, bp+72) + } + } + _sessionSerializeValue(tls, (*TSessionChange)(unsafe.Pointer(pC)).FaRecord+uintptr(**(**Tsqlite3_int64)(__ccgo_up(bp + 56))), **(**uintptr)(__ccgo_up(bp + 72)), bp+56) + goto _3 + _3: + ; + i = i + 1 + } + /* Add the change to the hash-table */ + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbIndirect != 0 || (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx) != 0 { + (*TSessionChange)(unsafe.Pointer(pC)).FbIndirect = uint8(1) + } + (*TSessionChange)(unsafe.Pointer(pC)).FnRecordField = libc.Uint16FromInt32((*TSessionTable)(unsafe.Pointer(pTab)).FnCol) + (*TSessionChange)(unsafe.Pointer(pC)).FnRecord = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 56))) + (*TSessionChange)(unsafe.Pointer(pC)).Fop = libc.Uint8FromInt32(op) + (*TSessionChange)(unsafe.Pointer(pC)).FpNext = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(**(**int32)(__ccgo_up(bp)))*8)) + **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(**(**int32)(__ccgo_up(bp)))*8)) = pC + } else { + if (*TSessionChange)(unsafe.Pointer(pC)).FbIndirect != 0 { + /* If the existing change is considered "indirect", but this current + ** change is "direct", mark the change object as direct. */ + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx) == 0 && (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbIndirect == 0 { + (*TSessionChange)(unsafe.Pointer(pC)).FbIndirect = uint8(0) + } + } + } + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize != 0 { + rc = _sessionUpdateMaxSize(tls, op, pSession, pTab, pC) + } + } + /* If an error has occurred, mark the session object as failed. */ + goto error_out +error_out: + ; + if (*TSessionTable)(unsafe.Pointer(pTab)).FbStat1 != 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook = (**(**TSessionStat1Ctx)(__ccgo_up(bp + 8))).Fhook + } + if rc != SQLITE_OK { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = rc + } +} + +// C documentation +// +// /* +// ** Write a double value to the buffer aBuf[]. +// */ +func _sessionPutDouble(tls *libc.TLS, aBuf uintptr, _r float64) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*float64)(unsafe.Pointer(bp)) = _r + var _ /* i at bp+8 */ Tu64 + libc.X__builtin___memcpy_chk(tls, bp+8, bp, uint64(8), ^t__predefined_size_t(0)) + _sessionPutI64(tls, aBuf, libc.Int64FromUint64(**(**Tu64)(__ccgo_up(bp + 8)))) +} + +// C documentation +// +// /* +// ** Deserialize a single record from a buffer in memory. See "RECORD FORMAT" +// ** for details. +// ** +// ** When this function is called, *paChange points to the start of the record +// ** to deserialize. Assuming no error occurs, *paChange is set to point to +// ** one byte after the end of the same record before this function returns. +// ** If the argument abPK is NULL, then the record contains nCol values. Or, +// ** if abPK is other than NULL, then the record contains only the PK fields +// ** (in other words, it is a patchset DELETE record). +// ** +// ** If successful, each element of the apOut[] array (allocated by the caller) +// ** is set to point to an sqlite3_value object containing the value read +// ** from the corresponding position in the record. If that value is not +// ** included in the record (i.e. because the record is part of an UPDATE change +// ** and the field was not modified), the corresponding element of apOut[] is +// ** set to NULL. +// ** +// ** It is the responsibility of the caller to free all sqlite_value structures +// ** using sqlite3_free(). +// ** +// ** If an error occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned. +// ** The apOut[] array may have been partially populated in this case. +// */ +func _sessionReadRecord(tls *libc.TLS, pIn uintptr, nCol int32, abPK uintptr, apOut uintptr, pbEmpty uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aVal, v3 uintptr + var eType, i, nRem, rc, v2 int32 + var enc Tu8 + var _ /* d at bp+16 */ float64 + var _ /* nByte at bp+0 */ int32 + var _ /* v at bp+8 */ Tsqlite3_int64 + _, _, _, _, _, _, _, _ = aVal, eType, enc, i, nRem, rc, v2, v3 /* Used to iterate through columns */ + rc = SQLITE_OK + if pbEmpty != 0 { + **(**int32)(__ccgo_up(pbEmpty)) = int32(1) + } + i = 0 + for { + if !(i < nCol && rc == SQLITE_OK) { + break + } + eType = 0 /* Type of value (SQLITE_NULL, TEXT etc.) */ + if abPK != 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(abPK + uintptr(i)))) == 0 { + goto _1 + } + rc = _sessionInputBuffer(tls, pIn, int32(9)) + if rc == SQLITE_OK { + if (*TSessionInput)(unsafe.Pointer(pIn)).FiNext >= (*TSessionInput)(unsafe.Pointer(pIn)).FnData { + rc = _sqlite3CorruptError(tls, int32(237090)) + } else { + v3 = pIn + 8 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pIn)).FaData + uintptr(v2)))) + if eType != 0 { + if pbEmpty != 0 { + **(**int32)(__ccgo_up(pbEmpty)) = 0 + } + **(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)) = _sqlite3ValueNew(tls, uintptr(0)) + if !(**(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)) != 0) { + rc = int32(SQLITE_NOMEM) + } + } + } + } + if rc == SQLITE_OK { + aVal = (*TSessionInput)(unsafe.Pointer(pIn)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiNext) + if eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB) { + nRem = (*TSessionInput)(unsafe.Pointer(pIn)).FnData - (*TSessionInput)(unsafe.Pointer(pIn)).FiNext + **(**int32)(__ccgo_up(pIn + 8)) += _sessionVarintGetSafe(tls, aVal, nRem, bp) + rc = _sessionInputBuffer(tls, pIn, **(**int32)(__ccgo_up(bp))) + if rc == SQLITE_OK { + if **(**int32)(__ccgo_up(bp)) < 0 || **(**int32)(__ccgo_up(bp)) > (*TSessionInput)(unsafe.Pointer(pIn)).FnData-(*TSessionInput)(unsafe.Pointer(pIn)).FiNext { + rc = _sqlite3CorruptError(tls, int32(237111)) + } else { + if eType == int32(SQLITE_TEXT) { + v2 = int32(SQLITE_UTF8) + } else { + v2 = 0 + } + enc = libc.Uint8FromInt32(v2) + rc = _sessionValueSetStr(tls, **(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)), (*TSessionInput)(unsafe.Pointer(pIn)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiNext), **(**int32)(__ccgo_up(bp)), enc) + **(**int32)(__ccgo_up(pIn + 8)) += **(**int32)(__ccgo_up(bp)) + } + } + } + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + if (*TSessionInput)(unsafe.Pointer(pIn)).FnData-(*TSessionInput)(unsafe.Pointer(pIn)).FiNext < int32(8) { + rc = _sqlite3CorruptError(tls, int32(237121)) + } else { + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = _sessionGetI64(tls, aVal) + if eType == int32(SQLITE_INTEGER) { + _sqlite3VdbeMemSetInt64(tls, **(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)), **(**Tsqlite3_int64)(__ccgo_up(bp + 8))) + } else { + libc.X__builtin___memcpy_chk(tls, bp+16, bp+8, uint64(8), ^t__predefined_size_t(0)) + _sqlite3VdbeMemSetDouble(tls, **(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)), **(**float64)(__ccgo_up(bp + 16))) + } + **(**int32)(__ccgo_up(pIn + 8)) += int32(8) + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +// C documentation +// +// /* +// ** pIter is configured to iterate through a changeset. This function rebases +// ** that changeset according to the current configuration of the rebaser +// ** object passed as the first argument. If no error occurs and argument xOutput +// ** is not NULL, then the changeset is returned to the caller by invoking +// ** xOutput zero or more times and SQLITE_OK returned. Or, if xOutput is NULL, +// ** then (*ppOut) is set to point to a buffer containing the rebased changeset +// ** before this function returns. In this case (*pnOut) is set to the size of +// ** the buffer in bytes. It is the responsibility of the caller to eventually +// ** free the (*ppOut) buffer using sqlite3_free(). +// ** +// ** If an error occurs, an SQLite error code is returned. If ppOut and +// ** pnOut are not NULL, then the two output parameters are set to 0 before +// ** returning. +// */ +func _sessionRebase(tls *libc.TLS, p uintptr, pIter uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr, pnOut uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bDone, iHash, v2 int32 + var pChange, pTab, zTab uintptr + var _ /* aRec at bp+8 */ uintptr + var _ /* bNew at bp+20 */ int32 + var _ /* nRec at bp+16 */ int32 + var _ /* pCsr at bp+40 */ uintptr + var _ /* rc at bp+0 */ int32 + var _ /* sOut at bp+24 */ TSessionBuffer + _, _, _, _, _, _ = bDone, iHash, pChange, pTab, zTab, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 16)) = 0 + **(**int32)(__ccgo_up(bp + 20)) = 0 + pTab = uintptr(0) + **(**TSessionBuffer)(__ccgo_up(bp + 24)) = TSessionBuffer{} + for int32(SQLITE_ROW) == _sessionChangesetNext(tls, pIter, bp+8, bp+16, bp+20) { + pChange = uintptr(0) + bDone = 0 + if **(**int32)(__ccgo_up(bp + 20)) != 0 { + zTab = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab + pTab = (*Tsqlite3_rebaser)(unsafe.Pointer(p)).Fgrp.FpList + for { + if !(pTab != 0) { + break + } + if 0 == Xsqlite3_stricmp(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zTab) { + break + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + **(**int32)(__ccgo_up(bp + 20)) = 0 + /* A patchset may not be rebased */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* Append a table header to the output for this new table */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 { + v2 = int32('P') + } else { + v2 = int32('T') + } + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32(v2), bp) + _sessionAppendVarint(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, bp) + _sessionAppendBlob(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, bp) + _sessionAppendBlob(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, libc.Int32FromUint64(libc.Xstrlen(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab))+int32(1), bp) + } + if pTab != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + iHash = libc.Int32FromUint32(_sessionChangeHash(tls, pTab, 0, **(**uintptr)(__ccgo_up(bp + 8)), (*TSessionTable)(unsafe.Pointer(pTab)).FnChange)) + pChange = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*8)) + for { + if !(pChange != 0) { + break + } + if _sessionChangeEqual(tls, pTab, 0, **(**uintptr)(__ccgo_up(bp + 8)), 0, (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord) != 0 { + break + } + goto _3 + _3: + ; + pChange = (*TSessionChange)(unsafe.Pointer(pChange)).FpNext + } + } + if pChange != 0 { + switch (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop { + case int32(SQLITE_INSERT): + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).Fop) == int32(SQLITE_INSERT) { + bDone = int32(1) + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).FbIndirect) == 0 { + _sessionAppendByte(tls, bp+24, uint8(SQLITE_UPDATE), bp) + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp) + _sessionAppendBlob(tls, bp+24, (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord, (*TSessionChange)(unsafe.Pointer(pChange)).FnRecord, bp) + _sessionAppendBlob(tls, bp+24, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), bp) + } + } + case int32(SQLITE_UPDATE): + bDone = int32(1) + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).Fop) == int32(SQLITE_DELETE) { + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).FbIndirect) == 0 { + **(**uintptr)(__ccgo_up(bp + 40)) = **(**uintptr)(__ccgo_up(bp + 8)) + _sessionSkipRecord(tls, bp+40, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) + _sessionAppendByte(tls, bp+24, uint8(SQLITE_INSERT), bp) + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp) + _sessionAppendRecordMerge(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, **(**uintptr)(__ccgo_up(bp + 40)), int32(int64(**(**int32)(__ccgo_up(bp + 16)))-(int64(**(**uintptr)(__ccgo_up(bp + 40)))-int64(**(**uintptr)(__ccgo_up(bp + 8))))), (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord, (*TSessionChange)(unsafe.Pointer(pChange)).FnRecord, bp) + } + } else { + _sessionAppendPartialUpdate(tls, bp+24, pIter, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord, (*TSessionChange)(unsafe.Pointer(pChange)).FnRecord, bp) + } + default: + bDone = int32(1) + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).Fop) == int32(SQLITE_INSERT) { + _sessionAppendByte(tls, bp+24, uint8(SQLITE_DELETE), bp) + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp) + _sessionAppendRecordMerge(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord, (*TSessionChange)(unsafe.Pointer(pChange)).FnRecord, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), bp) + } + break + } + } + if bDone == 0 { + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop), bp) + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp) + _sessionAppendBlob(tls, bp+24, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), bp) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && __ccgo_fp_xOutput != 0 && (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf > _sessions_strm_chunk_size { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf) + (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf = 0 + } + if **(**int32)(__ccgo_up(bp)) != 0 { + break + } + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf) + libc.X__builtin___memset_chk(tls, bp+24, 0, uint64(16), ^t__predefined_size_t(0)) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if __ccgo_fp_xOutput != 0 { + if (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf > 0 { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf) + } + } else { + if ppOut != 0 { + **(**uintptr)(__ccgo_up(ppOut)) = (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf + **(**int32)(__ccgo_up(pnOut)) = (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf + (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf = uintptr(0) + } + } + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Retry the changes accumulated in the pApply->constraints buffer. The +// ** pApply->constraints buffer contains all changes to table zTab that +// ** could not be applied due to SQLITE_CONSTRAINT errors. This function +// ** attempts to apply them as follows: +// ** +// ** 1) It runs through the buffer and attempts to retry each change, +// ** removing any that are successfully applied from the buffer. This +// ** is repeated until no further progress can be made. +// ** +// ** 2) For each UPDATE change in the buffer, try the following in a +// ** savepoint transaction: +// ** +// ** a) DELETE the affected row, +// ** b) Attempt step (1) with remaining changes, +// ** c) Attempt to INSERT a row equivalent to the one that would be +// ** created by applying this UPDATE change. +// ** +// ** If the INSERT in (c) succeeds, the savepoint is committed and all +// ** successfully applied changes are removed from the buffer. Step (2) +// ** is then repeated. +// ** +// ** 3) Once step (2) has been attempted for each UPDATE in the change, +// ** a final attempt is made to apply each remaining change. This time, +// ** if an SQLITE_CONSTRAINT error is encountered, the conflict handler +// ** is invoked and the user has to decide whether to omit the change +// ** or rollback the entire _apply() operation. +// */ +func _sessionRetryConstraints(tls *libc.TLS, db uintptr, bPatchset int32, zTab uintptr, pApply uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iSkip, iThis, iUpdate, rc int32 + var _ /* app at bp+48 */ TSessionBuffer + var _ /* cons at bp+0 */ TSessionBuffer + var _ /* cons at bp+16 */ TSessionBuffer + var _ /* cons at bp+64 */ TSessionBuffer + var _ /* pInsert at bp+40 */ uintptr + var _ /* pUp at bp+32 */ uintptr + _, _, _, _ = iSkip, iThis, iUpdate, rc + rc = SQLITE_OK + iUpdate = 0 + /* Step (1) */ + for (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf != 0 { + **(**TSessionBuffer)(__ccgo_up(bp)) = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints + libc.X__builtin___memset_chk(tls, pApply+88, 0, uint64(16), ^t__predefined_size_t(0)) + rc = _sessionApplyRetryBuffer(tls, bp, -int32(1), db, bPatchset, zTab, pApply, __ccgo_fp_xConflict, pCtx) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf) + if rc != SQLITE_OK { + break + } + /* If no progress has been made this round, break out of the loop. */ + if (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf >= (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf { + break + } + } + /* Step (2) */ + for rc == SQLITE_OK && (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf != 0 && !((*TSessionApplyCtx)(unsafe.Pointer(pApply)).FbNoUpdateLoop != 0) { + **(**TSessionBuffer)(__ccgo_up(bp + 16)) = TSessionBuffer{} + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + iSkip = 0 + rc = _sessionRetryIterInit(tls, pApply+88, bPatchset, zTab, pApply, bp+32) + if rc == SQLITE_OK { + iThis = -int32(1) + for int32(SQLITE_ROW) == Xsqlite3changeset_next(tls, **(**uintptr)(__ccgo_up(bp + 32))) { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 32)))).Fop == int32(SQLITE_UPDATE) { + iThis = iThis + 1 + } + if iThis == iUpdate { + break + } + iSkip = iSkip + 1 + } + if iThis == iUpdate { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36777, uintptr(0), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + rc = _sessionUpdateToDeleteInsert(tls, db, zTab, pApply, **(**uintptr)(__ccgo_up(bp + 32)), bp+40) + } + } + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp + 32))) + if iThis != iUpdate { + break + } + } + if rc == SQLITE_OK { + **(**TSessionBuffer)(__ccgo_up(bp + 16)) = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints + for rc == SQLITE_OK && (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf > 0 { + **(**TSessionBuffer)(__ccgo_up(bp + 48)) = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints + libc.X__builtin___memset_chk(tls, pApply+88, 0, uint64(16), ^t__predefined_size_t(0)) + rc = _sessionApplyRetryBuffer(tls, bp+48, iSkip, db, bPatchset, zTab, pApply, __ccgo_fp_xConflict, pCtx) + if (**(**TSessionBuffer)(__ccgo_up(bp + 48))).FaBuf != (**(**TSessionBuffer)(__ccgo_up(bp + 16))).FaBuf { + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 48))).FaBuf) + } + if (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf >= (**(**TSessionBuffer)(__ccgo_up(bp + 48))).FnBuf { + break + } + iSkip = -int32(1) + } + } + iUpdate = iUpdate + 1 + if rc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 40))) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 40))) + if rc == int32(SQLITE_CONSTRAINT) { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36797, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_free(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FaBuf) + (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints = **(**TSessionBuffer)(__ccgo_up(bp + 16)) + libc.X__builtin___memset_chk(tls, bp+16, 0, uint64(16), ^t__predefined_size_t(0)) + } else { + if rc == SQLITE_OK { + iUpdate = 0 + } + } + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36819, uintptr(0), uintptr(0), uintptr(0)) + } + } else { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 40))) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 16))).FaBuf) + } + /* Step (3) */ + if rc == SQLITE_OK && (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf != 0 { + **(**TSessionBuffer)(__ccgo_up(bp + 64)) = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints + libc.X__builtin___memset_chk(tls, pApply+88, 0, uint64(16), ^t__predefined_size_t(0)) + (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FbDeferConstraints = 0 + rc = _sessionApplyRetryBuffer(tls, bp+64, -int32(1), db, bPatchset, zTab, pApply, __ccgo_fp_xConflict, pCtx) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 64))).FaBuf) + } + return rc +} + +// C documentation +// +// /* +// ** Create an iterator to iterate through the retry buffer pRetry. +// */ +func _sessionRetryIterInit(tls *libc.TLS, pRetry uintptr, bPatchset int32, zTab uintptr, pApply uintptr, ppIter uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte Tsize_t + var _ /* pRet at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _ = nByte + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 8)) = _sessionChangesetStart(tls, bp, uintptr(0), uintptr(0), (*TSessionBuffer)(unsafe.Pointer(pRetry)).FnBuf, (*TSessionBuffer)(unsafe.Pointer(pRetry)).FaBuf, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FbInvertConstraints, int32(1)) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + nByte = libc.Uint64FromInt32(int32(2)*(*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol) * uint64(8) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FbPatchset = bPatchset + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzTab = zTab + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnCol = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FabPK = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK + _sessionBufferGrow(tls, **(**uintptr)(__ccgo_up(bp))+72, libc.Int64FromUint64(nByte), bp+8) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FapValue = (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ftblhdr.FaBuf + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + libc.X__builtin___memset_chk(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FapValue, 0, nByte, ^t__predefined_size_t(0)) + } else { + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + **(**uintptr)(__ccgo_up(ppIter)) = **(**uintptr)(__ccgo_up(bp)) + return **(**int32)(__ccgo_up(bp + 8)) +} + +// C documentation +// +// /* +// ** Bind the PRIMARY KEY values from the change passed in argument pChange +// ** to the SELECT statement passed as the first argument. The SELECT statement +// ** is as prepared by function sessionSelectStmt(). +// ** +// ** Return SQLITE_OK if all PK values are successfully bound, or an SQLite +// ** error code (e.g. SQLITE_NOMEM) otherwise. +// */ +func _sessionSelectBind(tls *libc.TLS, pSelect uintptr, nCol int32, abPK uintptr, pChange uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a, v2 uintptr + var eType, i, rc int32 + var iVal Ti64 + var _ /* iVal at bp+8 */ Ti64 + var _ /* n at bp+16 */ int32 + var _ /* n at bp+20 */ int32 + var _ /* rVal at bp+0 */ float64 + _, _, _, _, _, _ = a, eType, i, iVal, rc, v2 + rc = SQLITE_OK + a = (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord + i = 0 + for { + if !(i < nCol && rc == SQLITE_OK) { + break + } + v2 = a + a = a + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v2))) + switch eType { + case 0: + fallthrough + case int32(SQLITE_NULL): + case int32(SQLITE_INTEGER): + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + iVal = _sessionGetI64(tls, a) + rc = Xsqlite3_bind_int64(tls, pSelect, i+int32(1), iVal) + } + a = a + uintptr(8) + case int32(SQLITE_FLOAT): + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + **(**Ti64)(__ccgo_up(bp + 8)) = _sessionGetI64(tls, a) + libc.X__builtin___memcpy_chk(tls, bp, bp+8, uint64(8), ^t__predefined_size_t(0)) + rc = Xsqlite3_bind_double(tls, pSelect, i+int32(1), **(**float64)(__ccgo_up(bp))) + } + a = a + uintptr(8) + case int32(SQLITE_TEXT): + a = a + uintptr(_sessionVarintGet(tls, a, bp+16)) + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + rc = Xsqlite3_bind_text(tls, pSelect, i+int32(1), a, **(**int32)(__ccgo_up(bp + 16)), uintptr(-libc.Int32FromInt32(1))) + } + a = a + uintptr(**(**int32)(__ccgo_up(bp + 16))) + default: + a = a + uintptr(_sessionVarintGet(tls, a, bp+20)) + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + rc = Xsqlite3_bind_blob(tls, pSelect, i+int32(1), a, **(**int32)(__ccgo_up(bp + 20)), uintptr(-libc.Int32FromInt32(1))) + } + a = a + uintptr(**(**int32)(__ccgo_up(bp + 20))) + break + } + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +func _sessionSelectFindNew(tls *libc.TLS, zDb1 uintptr, zDb2 uintptr, bRowid int32, zTbl uintptr, zExpr uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var zRet, zSel, v1 uintptr + _, _, _ = zRet, zSel, v1 + if bRowid != 0 { + v1 = __ccgo_ts + 35761 + } else { + v1 = __ccgo_ts + 7165 + } + zSel = v1 + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+35772, libc.VaList(bp+8, zSel, zDb1, zTbl, zDb2, zTbl, zExpr)) + return zRet +} + +// C documentation +// +// /* +// ** Formulate and prepare an SQL statement to query table zTab by primary +// ** key. Assuming the following table structure: +// ** +// ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c)); +// ** +// ** The SELECT statement looks like this: +// ** +// ** SELECT * FROM x WHERE a = ?1 AND c = ?3 +// ** +// ** If successful, SQLITE_OK is returned and SessionApplyCtx.pSelect is left +// ** pointing to the prepared version of the SQL statement. +// */ +func _sessionSelectRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) (r int32) { + /* TODO */ + return _sessionSelectStmt(tls, db, libc.Int32FromUint8((*TSessionApplyCtx)(unsafe.Pointer(p)).FbIgnoreNoop), __ccgo_ts+7160, zTab, (*TSessionApplyCtx)(unsafe.Pointer(p)).FbRowid, (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol, (*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK, p+24, p+128) +} + +// C documentation +// +// /* +// ** Formulate and prepare a SELECT statement to retrieve a row from table +// ** zTab in database zDb based on its primary key. i.e. +// ** +// ** SELECT *, FROM zDb.zTab WHERE (pk1, pk2,...) IS (?1, ?2,...) +// ** +// ** where is: +// ** +// ** 1 AND (?A OR ?1 IS ) AND ... +// ** +// ** for each non-pk . +// */ +func _sessionSelectStmt(tls *libc.TLS, db uintptr, bIgnoreNoop int32, zDb uintptr, zTab uintptr, bRowid int32, nCol int32, azCol uintptr, abPK uintptr, ppStmt uintptr, pzErrmsg uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var i int32 + var zSep, zSql, v2 uintptr + var _ /* cols at bp+8 */ TSessionBuffer + var _ /* nooptest at bp+24 */ TSessionBuffer + var _ /* pkfield at bp+40 */ TSessionBuffer + var _ /* pkvar at bp+56 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _, _, _, _ = i, zSep, zSql, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + zSql = uintptr(0) + zSep = __ccgo_ts + 1702 + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 24)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 40)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 56)) = TSessionBuffer{} + _sessionAppendStr(tls, bp+24, __ccgo_ts+36006, bp) + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+13177, zTab) { + _sessionAppendStr(tls, bp+24, __ccgo_ts+36010, bp) + _sessionAppendStr(tls, bp+40, __ccgo_ts+36034, bp) + _sessionAppendStr(tls, bp+56, __ccgo_ts+36043, bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+36088, bp) + } else { + i = 0 + for { + if !(i < nCol) { + break + } + if (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf != 0 { + _sessionAppendStr(tls, bp+8, __ccgo_ts+16558, bp) + } + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)), bp) + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + _sessionAppendStr(tls, bp+40, zSep, bp) + _sessionAppendStr(tls, bp+56, zSep, bp) + zSep = __ccgo_ts + 16558 + _sessionAppendIdent(tls, bp+40, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)), bp) + _sessionAppendPrintf(tls, bp+56, bp, __ccgo_ts+36102, libc.VaList(bp+80, i+int32(1))) + } else { + _sessionAppendPrintf(tls, bp+24, bp, __ccgo_ts+36106, libc.VaList(bp+80, i+int32(1)+nCol, i+int32(1), zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)))) + } + goto _1 + _1: + ; + i = i + 1 + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if bIgnoreNoop != 0 { + v2 = (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf + } else { + v2 = __ccgo_ts + 1702 + } + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+36133, libc.VaList(bp+80, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, v2, zDb, zTab, (**(**TSessionBuffer)(__ccgo_up(bp + 40))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 56))).FaBuf)) + if zSql == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionPrepare(tls, db, ppStmt, pzErrmsg, zSql) + } + Xsqlite3_free(tls, zSql) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 40))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 56))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This function is used to serialize the contents of value pValue (see +// ** comment titled "RECORD FORMAT" above). +// ** +// ** If it is non-NULL, the serialized form of the value is written to +// ** buffer aBuf. *pnWrite is set to the number of bytes written before +// ** returning. Or, if aBuf is NULL, the only thing this function does is +// ** set *pnWrite. +// ** +// ** If no error occurs, SQLITE_OK is returned. Or, if an OOM error occurs +// ** within a call to sqlite3_value_text() (may fail if the db is utf-16)) +// ** SQLITE_NOMEM is returned. +// */ +func _sessionSerializeValue(tls *libc.TLS, aBuf uintptr, pValue uintptr, pnWrite uintptr) (r1 int32) { + var eType, n, nByte, nVarint int32 + var i Tu64 + var r float64 + var z uintptr + _, _, _, _, _, _, _ = eType, i, n, nByte, nVarint, r, z /* Size of serialized value in bytes */ + if pValue != 0 { /* Value type (SQLITE_NULL, TEXT etc.) */ + eType = Xsqlite3_value_type(tls, pValue) + if aBuf != 0 { + **(**Tu8)(__ccgo_up(aBuf)) = libc.Uint8FromInt32(eType) + } + switch eType { + case int32(SQLITE_NULL): + nByte = int32(1) + case int32(SQLITE_INTEGER): + fallthrough + case int32(SQLITE_FLOAT): + if aBuf != 0 { + /* TODO: SQLite does something special to deal with mixed-endian + ** floating point values (e.g. ARM7). This code probably should + ** too. */ + if eType == int32(SQLITE_INTEGER) { + i = libc.Uint64FromInt64(Xsqlite3_value_int64(tls, pValue)) + _sessionPutI64(tls, aBuf+1, libc.Int64FromUint64(i)) + } else { + r = Xsqlite3_value_double(tls, pValue) + _sessionPutDouble(tls, aBuf+1, r) + } + } + nByte = int32(9) + default: + if eType == int32(SQLITE_TEXT) { + z = Xsqlite3_value_text(tls, pValue) + } else { + z = Xsqlite3_value_blob(tls, pValue) + } + n = Xsqlite3_value_bytes(tls, pValue) + if z == uintptr(0) && (eType != int32(SQLITE_BLOB) || n > 0) { + return int32(SQLITE_NOMEM) + } + nVarint = _sessionVarintLen(tls, n) + if aBuf != 0 { + _sessionVarintPut(tls, aBuf+1, n) + if n > 0 { + libc.X__builtin___memcpy_chk(tls, aBuf+uintptr(nVarint+int32(1)), z, libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + } + } + nByte = int32(1) + nVarint + n + break + } + } else { + nByte = int32(1) + if aBuf != 0 { + **(**Tu8)(__ccgo_up(aBuf)) = uint8('\000') + } + } + if pnWrite != 0 { + **(**Tsqlite3_int64)(__ccgo_up(pnWrite)) += int64(nByte) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Prepare statements for applying changes to the sqlite_stat1 table. +// ** These are similar to those created by sessionSelectRow(), +// ** sessionInsertRow(), sessionUpdateRow() and sessionDeleteRow() for +// ** other tables. +// */ +func _sessionStat1Sql(tls *libc.TLS, db uintptr, p uintptr) (r int32) { + var rc int32 + _ = rc + rc = _sessionSelectRow(tls, db, __ccgo_ts+13177, p) + if rc == SQLITE_OK { + rc = _sessionPrepare(tls, db, p+16, uintptr(0), __ccgo_ts+36390) + } + if rc == SQLITE_OK { + rc = _sessionPrepare(tls, db, p+8, uintptr(0), __ccgo_ts+36503) + } + return rc +} + +// C documentation +// +// /* +// ** This function queries the database for the names of the columns of table +// ** zThis, in schema zDb. +// ** +// ** Otherwise, if they are not NULL, variable *pnCol is set to the number +// ** of columns in the database table and variable *pzTab is set to point to a +// ** nul-terminated copy of the table name. *pazCol (if not NULL) is set to +// ** point to an array of pointers to column names. And *pabPK (again, if not +// ** NULL) is set to point to an array of booleans - true if the corresponding +// ** column is part of the primary key. +// ** +// ** For example, if the table is declared as: +// ** +// ** CREATE TABLE tbl1(w, x DEFAULT 'abc', y, z, PRIMARY KEY(w, z)); +// ** +// ** Then the five output variables are populated as follows: +// ** +// ** *pnCol = 4 +// ** *pzTab = "tbl1" +// ** *pazCol = {"w", "x", "y", "z"} +// ** *pazDflt = {NULL, 'abc', NULL, NULL} +// ** *pabPK = {1, 0, 0, 1} +// ** +// ** All returned buffers are part of the same single allocation, which must +// ** be freed using sqlite3_free() by the caller +// */ +func _sessionTableInfo(tls *libc.TLS, pSession uintptr, db uintptr, zDb uintptr, zThis uintptr, pnCol uintptr, pnTotalCol uintptr, pzTab uintptr, pazCol uintptr, pazDflt uintptr, paiIdx uintptr, pabPK uintptr, pbRowid uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var abPK, aiIdx, azCol, azDflt, pAlloc, zDflt, zName, zPragma uintptr + var bRowid, i, nDbCol, nDflt, nName1, nThis, rc int32 + var nByte Tsqlite3_int64 + var nName Tsize_t + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abPK, aiIdx, azCol, azDflt, bRowid, i, nByte, nDbCol, nDflt, nName, nName1, nThis, pAlloc, rc, zDflt, zName, zPragma + nDbCol = 0 + pAlloc = uintptr(0) + azCol = uintptr(0) + azDflt = uintptr(0) + abPK = uintptr(0) + aiIdx = uintptr(0) + bRowid = 0 /* Set to true to use rowid as PK */ + **(**uintptr)(__ccgo_up(pazCol)) = uintptr(0) + **(**uintptr)(__ccgo_up(pabPK)) = uintptr(0) + **(**int32)(__ccgo_up(pnCol)) = 0 + if pnTotalCol != 0 { + **(**int32)(__ccgo_up(pnTotalCol)) = 0 + } + if paiIdx != 0 { + **(**uintptr)(__ccgo_up(paiIdx)) = uintptr(0) + } + if pzTab != 0 { + **(**uintptr)(__ccgo_up(pzTab)) = uintptr(0) + } + if pazDflt != 0 { + **(**uintptr)(__ccgo_up(pazDflt)) = uintptr(0) + } + nThis = _sqlite3Strlen30(tls, zThis) + if nThis == int32(12) && 0 == Xsqlite3_stricmp(tls, __ccgo_ts+13177, zThis) { + rc = Xsqlite3_table_column_metadata(tls, db, zDb, zThis, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ + zPragma = Xsqlite3_mprintf(tls, __ccgo_ts+35514, 0) + } else { + if rc == int32(SQLITE_ERROR) { + zPragma = Xsqlite3_mprintf(tls, __ccgo_ts+1702, 0) + } else { + return rc + } + } + } else { + zPragma = Xsqlite3_mprintf(tls, __ccgo_ts+35644, libc.VaList(bp+16, zDb, zThis)) + } + if !(zPragma != 0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_prepare_v2(tls, db, zPragma, -int32(1), bp, uintptr(0)) + Xsqlite3_free(tls, zPragma) + if rc != SQLITE_OK { + return rc + } + nByte = int64(nThis + int32(1)) + bRowid = libc.BoolInt32(pbRowid != uintptr(0)) + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + nByte = nByte + int64(Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(1))) /* name */ + nByte = nByte + int64(Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(4))) /* dflt_value */ + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(6)) == 0 { /* !hidden */ + nDbCol = nDbCol + 1 + } + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(5)) != 0 { + bRowid = 0 + } /* pk */ + } + if nDbCol == 0 { + bRowid = 0 + } + nDbCol = nDbCol + bRowid + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Xstrlen(tls, __ccgo_ts+31664))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Uint64FromInt32(nDbCol)*(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(4)+libc.Uint64FromInt64(1)+libc.Uint64FromInt32(1)+libc.Uint64FromInt32(1)))) + pAlloc = _sessionMalloc64(tls, pSession, nByte) + if pAlloc == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pAlloc, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + } + } + if rc == SQLITE_OK { + azCol = pAlloc + azDflt = azCol + uintptr(nDbCol)*8 + aiIdx = azDflt + uintptr(nDbCol)*8 + abPK = aiIdx + uintptr(nDbCol)*4 + pAlloc = abPK + uintptr(nDbCol) + if pzTab != 0 { + libc.X__builtin___memcpy_chk(tls, pAlloc, zThis, libc.Uint64FromInt32(nThis+int32(1)), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(pzTab)) = pAlloc + pAlloc = pAlloc + uintptr(nThis+int32(1)) + } + i = 0 + if bRowid != 0 { + nName = libc.Xstrlen(tls, __ccgo_ts+31664) + libc.X__builtin___memcpy_chk(tls, pAlloc, __ccgo_ts+31664, nName+uint64(1), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)) = pAlloc + pAlloc = pAlloc + uintptr(nName+uint64(1)) + **(**Tu8)(__ccgo_up(abPK + uintptr(i))) = uint8(1) + **(**int32)(__ccgo_up(aiIdx + uintptr(i)*4)) = -int32(1) + i = i + 1 + } + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(6)) == 0 { /* !hidden */ + nName1 = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + nDflt = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + zName = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + zDflt = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + if zName == uintptr(0) { + break + } + libc.X__builtin___memcpy_chk(tls, pAlloc, zName, libc.Uint64FromInt32(nName1+int32(1)), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)) = pAlloc + pAlloc = pAlloc + uintptr(nName1+int32(1)) + if zDflt != 0 { + libc.X__builtin___memcpy_chk(tls, pAlloc, zDflt, libc.Uint64FromInt32(nDflt+int32(1)), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(azDflt + uintptr(i)*8)) = pAlloc + pAlloc = pAlloc + uintptr(nDflt+int32(1)) + } else { + **(**uintptr)(__ccgo_up(azDflt + uintptr(i)*8)) = uintptr(0) + } + **(**Tu8)(__ccgo_up(abPK + uintptr(i))) = libc.Uint8FromInt32(Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(5))) + **(**int32)(__ccgo_up(aiIdx + uintptr(i)*4)) = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + i = i + 1 + } + if pnTotalCol != 0 { + **(**int32)(__ccgo_up(pnTotalCol)) = **(**int32)(__ccgo_up(pnTotalCol)) + 1 + } + } + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + } + /* If successful, populate the output variables. Otherwise, zero them and + ** free any allocation made. An error code will be returned in this case. + */ + if rc == SQLITE_OK { + **(**uintptr)(__ccgo_up(pazCol)) = azCol + if pazDflt != 0 { + **(**uintptr)(__ccgo_up(pazDflt)) = azDflt + } + **(**uintptr)(__ccgo_up(pabPK)) = abPK + **(**int32)(__ccgo_up(pnCol)) = nDbCol + if paiIdx != 0 { + **(**uintptr)(__ccgo_up(paiIdx)) = aiIdx + } + } else { + _sessionFree(tls, pSession, azCol) + } + if pbRowid != 0 { + **(**int32)(__ccgo_up(pbRowid)) = bRowid + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Check if table zTab in the "main" database of db is a WITHOUT ROWID +// ** table. +// ** +// ** If no error occurs, return SQLITE_OK and set output variable (*pbWR) to +// ** true if zTab is a WITHOUT ROWID table, or false otherwise. Or, if an +// ** error does occur, return an SQLite error code. The final value of (*pbWR) +// ** is undefined in this case. +// */ +func _sessionTableIsWithoutRowid(tls *libc.TLS, db uintptr, zTab uintptr, pbWR uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc int32 + var zSql uintptr + var _ /* pList at bp+0 */ uintptr + _, _ = rc, zSql + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zSql = uintptr(0) + rc = SQLITE_OK + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+36687, libc.VaList(bp+16, zTab)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + Xsqlite3_free(tls, zSql) + } + if rc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + **(**int32)(__ccgo_up(pbWR)) = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Find a prepared UPDATE statement suitable for the UPDATE step currently +// ** being visited by the iterator. The UPDATE is of the form: +// ** +// ** UPDATE tbl SET col = ?, col2 = ? WHERE pk1 IS ? AND pk2 IS ? +// */ +func _sessionUpdateFind(tls *libc.TLS, pIter uintptr, p uintptr, bPatchset int32, ppStmt uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bStat1, ii, nByte, nCol, nU32, nUp int32 + var pUp, pp, zSep, zSql uintptr + var _ /* buf at bp+8 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = bStat1, ii, nByte, nCol, nU32, nUp, pUp, pp, zSep, zSql + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + pUp = uintptr(0) + nCol = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol + nU32 = ((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol + int32(33)) / int32(32) + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask == uintptr(0) { + (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask = Xsqlite3_malloc(tls, libc.Int32FromUint64(libc.Uint64FromInt32(nU32)*uint64(4))) + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + libc.X__builtin___memset_chk(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, 0, libc.Uint64FromInt32(nU32)*uint64(4), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_CORRUPT) + ii = 0 + for { + if !(ii < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + if **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+ii)*8)) != 0 { + **(**Tu32)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask + uintptr(ii/int32(32))*4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << (ii % libc.Int32FromInt32(32))) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if bPatchset != 0 { + **(**Tu32)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask + uintptr(nCol/int32(32))*4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << (nCol % libc.Int32FromInt32(32))) + } + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp != 0 { + nUp = 0 + pp = p + 64 + for int32(1) != 0 { + nUp = nUp + 1 + if 0 == libc.Xmemcmp(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, (*TSessionUpdate)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FaMask, libc.Uint64FromInt32(nU32)*uint64(4)) { + pUp = **(**uintptr)(__ccgo_up(pp)) + **(**uintptr)(__ccgo_up(pp)) = (*TSessionUpdate)(unsafe.Pointer(pUp)).FpNext + (*TSessionUpdate)(unsafe.Pointer(pUp)).FpNext = (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp + (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp = pUp + break + } + if (*TSessionUpdate)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpNext != 0 { + pp = **(**uintptr)(__ccgo_up(pp)) + 16 + } else { + if nUp >= int32(SESSION_UPDATE_CACHE_SZ) { + Xsqlite3_finalize(tls, (*TSessionUpdate)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpStmt) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(pp))) + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + break + } + } + } + if pUp == uintptr(0) { + nByte = libc.Int32FromUint64(uint64(24) * libc.Uint64FromInt32(nU32) * uint64(4)) + bStat1 = libc.BoolInt32(Xsqlite3_stricmp(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, __ccgo_ts+13177) == 0) + pUp = Xsqlite3_malloc(tls, nByte) + if pUp == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + zSep = __ccgo_ts + 1702 + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(16), ^t__predefined_size_t(0)) + (*TSessionUpdate)(unsafe.Pointer(pUp)).FaMask = pUp + 1*24 + libc.X__builtin___memcpy_chk(tls, (*TSessionUpdate)(unsafe.Pointer(pUp)).FaMask, (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, libc.Uint64FromInt32(nU32)*uint64(4), ^t__predefined_size_t(0)) + _sessionAppendStr(tls, bp+8, __ccgo_ts+36213, bp) + _sessionAppendIdent(tls, bp+8, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+36226, bp) + /* Create the assignments part of the UPDATE */ + ii = 0 + for { + if !(ii < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(ii)))) == 0 && **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+ii)*8)) != 0 { + _sessionAppendStr(tls, bp+8, zSep, bp) + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(ii)*8)), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+36232, bp) + _sessionAppendInteger(tls, bp+8, ii*int32(2)+int32(1), bp) + zSep = __ccgo_ts + 16558 + } + goto _2 + _2: + ; + ii = ii + 1 + } + /* Create the WHERE clause part of the UPDATE */ + zSep = __ccgo_ts + 1702 + _sessionAppendStr(tls, bp+8, __ccgo_ts+36237, bp) + ii = 0 + for { + if !(ii < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(ii))) != 0 || bPatchset == 0 && **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr(ii)*8)) != 0 { + _sessionAppendStr(tls, bp+8, zSep, bp) + if bStat1 != 0 && ii == int32(1) { + _sessionAppendStr(tls, bp+8, __ccgo_ts+36245, bp) + } else { + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(ii)*8)), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+36320, bp) + _sessionAppendInteger(tls, bp+8, ii*int32(2)+int32(2), bp) + } + zSep = __ccgo_ts + 23951 + } + goto _3 + _3: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + zSql = (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf + **(**int32)(__ccgo_up(bp)) = Xsqlite3_prepare_v2(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).Fdb, zSql, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf, pUp, uintptr(0)) + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + Xsqlite3_free(tls, pUp) + pUp = uintptr(0) + } else { + (*TSessionUpdate)(unsafe.Pointer(pUp)).FpNext = (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp + (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp = pUp + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + } + } + } + if pUp != 0 { + **(**uintptr)(__ccgo_up(ppStmt)) = (*TSessionUpdate)(unsafe.Pointer(pUp)).FpStmt + } else { + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + } + return **(**int32)(__ccgo_up(bp)) +} + +func _sessionUpdateMaxSize(tls *libc.TLS, op int32, pSession uintptr, pTab uintptr, pC uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bChanged, eType, iIdx, ii, ii1, nIncr, nOld int32 + var pCsr, v3 uintptr + var _ /* dVal at bp+32 */ float64 + var _ /* iVal at bp+24 */ Tsqlite3_int64 + var _ /* nByte at bp+40 */ int32 + var _ /* nNew at bp+0 */ Ti64 + var _ /* p at bp+16 */ uintptr + var _ /* p at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _ = bChanged, eType, iIdx, ii, ii1, nIncr, nOld, pCsr, v3 + **(**Ti64)(__ccgo_up(bp)) = int64(2) + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pC)).Fop) == int32(SQLITE_INSERT) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(9) + } + if op != int32(SQLITE_DELETE) { + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(ii)*4)), bp+8) + _sessionSerializeValue(tls, uintptr(0), **(**uintptr)(__ccgo_up(bp + 8)), bp) + goto _1 + _1: + ; + ii = ii + 1 + } + } + } else { + if op == int32(SQLITE_DELETE) { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64((*TSessionChange)(unsafe.Pointer(pC)).FnRecord) + if Xsqlite3_preupdate_blobwrite(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb) >= 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64((*TSessionChange)(unsafe.Pointer(pC)).FnRecord) + } + } else { + pCsr = (*TSessionChange)(unsafe.Pointer(pC)).FaRecord + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(libc.Int32FromInt32(9)+libc.Int32FromInt32(1)) + pCsr = pCsr + uintptr(9) + } + ii1 = (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid + for { + if !(ii1 < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + bChanged = int32(1) + nOld = 0 + iIdx = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(ii1)*4)) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp+16) + if **(**uintptr)(__ccgo_up(bp + 16)) == uintptr(0) { + return int32(SQLITE_NOMEM) + } + v3 = pCsr + pCsr = pCsr + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v3))) + switch eType { + case int32(SQLITE_NULL): + bChanged = libc.BoolInt32(Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 16))) != int32(SQLITE_NULL)) + case int32(SQLITE_FLOAT): + fallthrough + case int32(SQLITE_INTEGER): + if eType == Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 16))) { + **(**Tsqlite3_int64)(__ccgo_up(bp + 24)) = _sessionGetI64(tls, pCsr) + if eType == int32(SQLITE_INTEGER) { + bChanged = libc.BoolInt32(**(**Tsqlite3_int64)(__ccgo_up(bp + 24)) != Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(bp + 16)))) + } else { + libc.X__builtin___memcpy_chk(tls, bp+32, bp+24, uint64(8), ^t__predefined_size_t(0)) + bChanged = libc.BoolInt32(**(**float64)(__ccgo_up(bp + 32)) != Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(bp + 16)))) + } + } + nOld = int32(8) + pCsr = pCsr + uintptr(8) + default: + nOld = _sessionVarintGet(tls, pCsr, bp+40) + pCsr = pCsr + uintptr(nOld) + nOld = nOld + **(**int32)(__ccgo_up(bp + 40)) + if eType == Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 16))) && **(**int32)(__ccgo_up(bp + 40)) == Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(bp + 16))) && (**(**int32)(__ccgo_up(bp + 40)) == 0 || 0 == libc.Xmemcmp(tls, pCsr, Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(bp + 16))), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 40))))) { + bChanged = 0 + } + pCsr = pCsr + uintptr(**(**int32)(__ccgo_up(bp + 40))) + break + } + if bChanged != 0 && **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(ii1))) != 0 { + **(**Ti64)(__ccgo_up(bp)) = int64((*TSessionChange)(unsafe.Pointer(pC)).FnRecord + int32(2)) + break + } + if bChanged != 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(int32(1)+nOld) + _sessionSerializeValue(tls, uintptr(0), **(**uintptr)(__ccgo_up(bp + 16)), bp) + } else { + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(ii1))) != 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(int32(2)+nOld) + } else { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(2) + } + } + goto _2 + _2: + ; + ii1 = ii1 + 1 + } + } + } + if **(**Ti64)(__ccgo_up(bp)) > int64((*TSessionChange)(unsafe.Pointer(pC)).FnMaxSize) { + nIncr = int32(**(**Ti64)(__ccgo_up(bp)) - int64((*TSessionChange)(unsafe.Pointer(pC)).FnMaxSize)) + (*TSessionChange)(unsafe.Pointer(pC)).FnMaxSize = int32(**(**Ti64)(__ccgo_up(bp))) + **(**Ti64)(__ccgo_up(pSession + 64)) += int64(nIncr) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Session-change object (*pp) contains an old.* record with fewer than +// ** nCol fields. This function updates it with the default values for +// ** the missing fields. +// */ +func _sessionUpdateOneChange(tls *libc.TLS, pSession uintptr, pRc uintptr, pp uintptr, nCol int32, pDflt uintptr) { + var eType, iField, n, n1, n2, nByte, nIncr, v1 int32 + var iVal Ti64 + var pNew, pOld, z, z1, v2 uintptr + var rVal float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = eType, iField, iVal, n, n1, n2, nByte, nIncr, pNew, pOld, rVal, z, z1, v1, v2 + pOld = **(**uintptr)(__ccgo_up(pp)) + for libc.Int32FromUint16((*TSessionChange)(unsafe.Pointer(pOld)).FnRecordField) < nCol { + pNew = uintptr(0) + nByte = 0 + nIncr = 0 + iField = libc.Int32FromUint16((*TSessionChange)(unsafe.Pointer(pOld)).FnRecordField) + eType = Xsqlite3_column_type(tls, pDflt, iField) + switch eType { + case int32(SQLITE_NULL): + nIncr = int32(1) + case int32(SQLITE_INTEGER): + fallthrough + case int32(SQLITE_FLOAT): + nIncr = int32(9) + default: + n = Xsqlite3_column_bytes(tls, pDflt, iField) + nIncr = int32(1) + _sessionVarintLen(tls, n) + n + break + } + nByte = libc.Int32FromUint64(libc.Uint64FromInt32(nIncr) + (uint64(32) + libc.Uint64FromInt32((*TSessionChange)(unsafe.Pointer(pOld)).FnRecord))) + pNew = _sessionMalloc64(tls, pSession, int64(nByte)) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + return + } else { + libc.X__builtin___memcpy_chk(tls, pNew, pOld, uint64(32), ^t__predefined_size_t(0)) + (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord = pNew + 1*32 + libc.X__builtin___memcpy_chk(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord, (*TSessionChange)(unsafe.Pointer(pOld)).FaRecord, libc.Uint64FromInt32((*TSessionChange)(unsafe.Pointer(pOld)).FnRecord), ^t__predefined_size_t(0)) + v2 = pNew + 8 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TSessionChange)(unsafe.Pointer(pNew)).FaRecord + uintptr(v1))) = libc.Uint8FromInt32(eType) + switch eType { + case int32(SQLITE_INTEGER): + iVal = Xsqlite3_column_int64(tls, pDflt, iField) + _sessionPutI64(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), iVal) + **(**int32)(__ccgo_up(pNew + 8)) += int32(8) + case int32(SQLITE_FLOAT): + rVal = Xsqlite3_column_double(tls, pDflt, iField) + _sessionPutDouble(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), rVal) + **(**int32)(__ccgo_up(pNew + 8)) += int32(8) + case int32(SQLITE_TEXT): + n1 = Xsqlite3_column_bytes(tls, pDflt, iField) + z = Xsqlite3_column_text(tls, pDflt, iField) + **(**int32)(__ccgo_up(pNew + 8)) += _sessionVarintPut(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), n1) + libc.X__builtin___memcpy_chk(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), z, libc.Uint64FromInt32(n1), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pNew + 8)) += n1 + case int32(SQLITE_BLOB): + n2 = Xsqlite3_column_bytes(tls, pDflt, iField) + z1 = Xsqlite3_column_blob(tls, pDflt, iField) + **(**int32)(__ccgo_up(pNew + 8)) += _sessionVarintPut(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), n2) + libc.X__builtin___memcpy_chk(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), z1, libc.Uint64FromInt32(n2), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pNew + 8)) += n2 + default: + break + } + _sessionFree(tls, pSession, pOld) + v2 = pNew + pOld = v2 + **(**uintptr)(__ccgo_up(pp)) = v2 + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecordField = (*TSessionChange)(unsafe.Pointer(pNew)).FnRecordField + 1 + **(**int32)(__ccgo_up(pNew + 4)) += nIncr + if pSession != 0 { + **(**Ti64)(__ccgo_up(pSession + 64)) += int64(nIncr) + } + } + } +} + +// C documentation +// +// /* +// ** Iterator pUp points to an UPDATE change. This function deletes the +// ** affected row from the database and creates an INSERT statement that +// ** may be used to reinsert the row as it is after the UPDATE change +// ** has been applied. +// ** +// ** If successful, SQLITE_OK is returned and output variable (*ppInsert) +// ** is left pointing to a prepared INSERT statement. It is the responsibility +// ** of the caller to eventually free this statement using sqlite3_finalize(). +// ** Or, if an error occurs, an SQLite error code is returned and (*ppInsert) +// ** set to NULL. pApply->zErr may be set to an error message in this case. +// */ +func _sessionUpdateToDeleteInsert(tls *libc.TLS, db uintptr, zTab uintptr, pApply uintptr, pUp uintptr, ppInsert uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var iCol, ii int32 + var pVal, zComma, zComma2, zInsert, zSelect uintptr + var _ /* bWR at bp+20 */ int32 + var _ /* cols at bp+24 */ TSessionBuffer + var _ /* insbind at bp+40 */ TSessionBuffer + var _ /* pRet at bp+0 */ uintptr + var _ /* pSelect at bp+8 */ uintptr + var _ /* pkcols at bp+56 */ TSessionBuffer + var _ /* rc at bp+16 */ int32 + var _ /* selbind at bp+72 */ TSessionBuffer + _, _, _, _, _, _, _ = iCol, ii, pVal, zComma, zComma2, zInsert, zSelect + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* The INSERT statement */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* SELECT to read current values of row */ + **(**int32)(__ccgo_up(bp + 16)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 20)) = 0 + **(**int32)(__ccgo_up(bp + 16)) = _sessionTableIsWithoutRowid(tls, db, zTab, bp+20) + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + zSelect = uintptr(0) + zInsert = uintptr(0) + **(**TSessionBuffer)(__ccgo_up(bp + 24)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 40)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 56)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 72)) = TSessionBuffer{} + zComma = __ccgo_ts + 1702 + zComma2 = __ccgo_ts + 1702 + ii = 0 + for { + if !(ii < (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol) { + break + } + _sessionAppendStr(tls, bp+24, zComma, bp+16) + _sessionAppendIdent(tls, bp+24, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(pApply)).FazCol + uintptr(ii)*8)), bp+16) + _sessionAppendStr(tls, bp+40, zComma, bp+16) + _sessionAppendStr(tls, bp+40, __ccgo_ts+5603, bp+16) + zComma = __ccgo_ts + 16558 + if **(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK + uintptr(ii))) != 0 { + _sessionAppendStr(tls, bp+56, zComma2, bp+16) + _sessionAppendIdent(tls, bp+56, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(pApply)).FazCol + uintptr(ii)*8)), bp+16) + _sessionAppendStr(tls, bp+72, zComma2, bp+16) + _sessionAppendPrintf(tls, bp+72, bp+16, __ccgo_ts+36102, libc.VaList(bp+96, ii+int32(1))) + zComma2 = __ccgo_ts + 16558 + } + goto _1 + _1: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp + 20)) == 0 { + _sessionAppendStr(tls, bp+24, zComma, bp+16) + _sessionAppendStr(tls, bp+24, __ccgo_ts+31664, bp+16) + _sessionAppendStr(tls, bp+40, zComma, bp+16) + _sessionAppendStr(tls, bp+40, __ccgo_ts+5603, bp+16) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + zSelect = Xsqlite3_mprintf(tls, __ccgo_ts+36710, libc.VaList(bp+96, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf, zTab, (**(**TSessionBuffer)(__ccgo_up(bp + 56))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 72))).FaBuf)) + if zSelect == uintptr(0) { + **(**int32)(__ccgo_up(bp + 16)) = int32(SQLITE_NOMEM) + } + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + zInsert = Xsqlite3_mprintf(tls, __ccgo_ts+36747, libc.VaList(bp+96, zTab, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 40))).FaBuf)) + if zInsert == uintptr(0) { + **(**int32)(__ccgo_up(bp + 16)) = int32(SQLITE_NOMEM) + } + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionPrepare(tls, db, bp+8, pApply+128, zSelect) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionPrepare(tls, db, bp, pApply+128, zInsert) + } + Xsqlite3_free(tls, zSelect) + Xsqlite3_free(tls, zInsert) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 40))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 56))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 72))).FaBuf) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionBindRow(tls, pUp, __ccgo_fp(Xsqlite3changeset_old), (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK, **(**uintptr)(__ccgo_up(bp + 8))) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) == int32(SQLITE_ROW) { + iCol = 0 + for { + if !(iCol < (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol) { + break + } + pVal = **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pUp)).FapValue + uintptr(iCol+(*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol)*8)) + if pVal == uintptr(0) { + pVal = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), iCol) + } + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp)), iCol+int32(1), pVal) + goto _2 + _2: + ; + iCol = iCol + 1 + } + if **(**int32)(__ccgo_up(bp + 20)) == 0 { + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), iCol+int32(1), Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp + 8)), iCol)) + } + } + _sessionFinalizeStmt(tls, **(**uintptr)(__ccgo_up(bp + 8)), bp+16) + /* Delete the row from the database. */ + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionBindRow(tls, pUp, __ccgo_fp(Xsqlite3changeset_old), (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + Xsqlite3_bind_int(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol+int32(1), int32(1)) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + Xsqlite3_step(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + } + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppInsert)) = **(**uintptr)(__ccgo_up(bp)) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** This function sets the value of the sqlite3_value object passed as the +// ** first argument to a copy of the string or blob held in the aData[] +// ** buffer. SQLITE_OK is returned if successful, or SQLITE_NOMEM if an OOM +// ** error occurs. +// */ +func _sessionValueSetStr(tls *libc.TLS, pVal uintptr, aData uintptr, nData int32, enc Tu8) (r int32) { + var aCopy uintptr + _ = aCopy + /* In theory this code could just pass SQLITE_TRANSIENT as the final + ** argument to sqlite3ValueSetStr() and have the copy created + ** automatically. But doing so makes it difficult to detect any OOM + ** error. Hence the code to create the copy externally. */ + aCopy = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nData)+int64(1))) + if aCopy == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, aCopy, aData, libc.Uint64FromInt32(nData), ^t__predefined_size_t(0)) + _sqlite3ValueSetStr(tls, pVal, nData, aCopy, enc, __ccgo_fp(Xsqlite3_free)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Read a varint value from buffer aBuf[], size nBuf bytes, into *piVal. +// ** Return the number of bytes read. +// */ +func _sessionVarintGetSafe(tls *libc.TLS, aBuf uintptr, nBuf int32, piVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aRead uintptr + var v1 int32 + var _ /* aCopy at bp+0 */ [9]Tu8 + _, _ = aRead, v1 + aRead = aBuf + libc.X__builtin___memset_chk(tls, bp, 0, uint64(9), ^t__predefined_size_t(0)) + if libc.Uint64FromInt32(nBuf) < uint64(9) { + libc.X__builtin___memcpy_chk(tls, bp, aBuf, libc.Uint64FromInt32(nBuf), ^t__predefined_size_t(0)) + aRead = bp + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aRead))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**int32)(__ccgo_up(piVal)) = libc.Int32FromUint32(uint32(**(**Tu8)(__ccgo_up(aRead)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aRead, piVal)) + } + return libc.Int32FromUint8(libc.Uint8FromInt32(v1)) +} + +/* Load an unaligned and unsigned 32-bit integer */ + +// C documentation +// +// /* IMP: R-25361-16150 This function is omitted from SQLite by default. It +// ** is only available if the SQLITE_SOUNDEX compile-time option is used +// ** when SQLite is built. +// */ +// /* +// ** Compute the soundex encoding of a word. +// ** +// ** IMP: R-59782-00072 The soundex(X) function returns a string that is the +// ** soundex encoding of the string X. +// */ +func _soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var code, i, j, v3 int32 + var prevcode Tu8 + var zIn uintptr + var _ /* zResult at bp+0 */ [8]int8 + _, _, _, _, _, _ = code, i, j, prevcode, zIn, v3 + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn == uintptr(0) { + zIn = __ccgo_ts + 1702 + } + i = 0 + for { + if !(**(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(zIn + uintptr(i)))])&libc.Int32FromInt32(0x02) != 0)) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if **(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0 { + prevcode = _iCode[libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i))))&int32(0x7f)] + (**(**[8]int8)(__ccgo_up(bp)))[0] = int8(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i)))) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(zIn + uintptr(i)))]) & libc.Int32FromInt32(0x20))) + j = int32(1) + for { + if !(j < int32(4) && **(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0) { + break + } + code = libc.Int32FromUint8(_iCode[libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i))))&int32(0x7f)]) + if code > 0 { + if code != libc.Int32FromUint8(prevcode) { + prevcode = libc.Uint8FromInt32(code) + v3 = j + j = j + 1 + (**(**[8]int8)(__ccgo_up(bp)))[v3] = int8(code + int32('0')) + } + } else { + prevcode = uint8(0) + } + goto _2 + _2: + ; + i = i + 1 + } + for j < int32(4) { + v3 = j + j = j + 1 + (**(**[8]int8)(__ccgo_up(bp)))[v3] = int8('0') + } + (**(**[8]int8)(__ccgo_up(bp)))[j] = 0 + Xsqlite3_result_text(tls, context, bp, int32(4), uintptr(-libc.Int32FromInt32(1))) + } else { + /* IMP: R-64894-50321 The string "?000" is returned if the argument + ** is NULL or contains no ASCII alphabetic characters. */ + Xsqlite3_result_text(tls, context, __ccgo_ts+16938, int32(4), libc.UintptrFromInt32(0)) + } +} + +// C documentation +// +// /* +// ** Implementation of the R*-tree variant of SplitNode from Beckman[1990]. +// */ +func _splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32, pLeft uintptr, pRight uintptr, pBboxLeft uintptr, pBboxRight uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aSpare, aaSorted, pBbox, pCell, pTarget, v7, v8 uintptr + var area, fBestArea, fBestMargin, fBestOverlap, margin, overlap TRtreeDValue + var iBestDim, iBestLeft, iBestSplit, ii, jj, kk, nLeft int32 + var nByte Tsqlite3_int64 + var _ /* left at bp+0 */ TRtreeCell + var _ /* right at bp+48 */ TRtreeCell + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aSpare, aaSorted, area, fBestArea, fBestMargin, fBestOverlap, iBestDim, iBestLeft, iBestSplit, ii, jj, kk, margin, nByte, nLeft, overlap, pBbox, pCell, pTarget, v7, v8 + iBestDim = 0 + iBestSplit = 0 + fBestMargin = float64(0) + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim)+libc.Int32FromInt32(1)) * (uint64(8) + libc.Uint64FromInt32(nCell)*uint64(4))) + aaSorted = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if !(aaSorted != 0) { + return int32(SQLITE_NOMEM) + } + aSpare = aaSorted + uintptr((*TRtree)(unsafe.Pointer(pRtree)).FnDim)*8 + uintptr(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim)*nCell)*4 + libc.X__builtin___memset_chk(tls, aaSorted, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + ii = 0 + for { + if !(ii < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim)) { + break + } + **(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) = aaSorted + uintptr((*TRtree)(unsafe.Pointer(pRtree)).FnDim)*8 + uintptr(ii*nCell)*4 + jj = 0 + for { + if !(jj < nCell) { + break + } + **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) + uintptr(jj)*4)) = jj + goto _2 + _2: + ; + jj = jj + 1 + } + _SortByDimension(tls, pRtree, **(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)), nCell, ii, aCell, aSpare) + goto _1 + _1: + ; + ii = ii + 1 + } + ii = 0 + for { + if !(ii < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim)) { + break + } + margin = float64(0) + fBestOverlap = float64(0) + fBestArea = float64(0) + iBestLeft = 0 + nLeft = ((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize - int32(4)) / libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) / int32(3) + for { + if !(nLeft <= nCell-((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize-int32(4))/libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/int32(3)) { + break + } + libc.X__builtin___memcpy_chk(tls, bp, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)))))*48, uint64(48), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, bp+48, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) + uintptr(nCell-int32(1))*4)))*48, uint64(48), ^t__predefined_size_t(0)) + kk = int32(1) + for { + if !(kk < nCell-int32(1)) { + break + } + if kk < nLeft { + _cellUnion(tls, pRtree, bp, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) + uintptr(kk)*4)))*48) + } else { + _cellUnion(tls, pRtree, bp+48, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) + uintptr(kk)*4)))*48) + } + goto _5 + _5: + ; + kk = kk + 1 + } + margin = margin + _cellMargin(tls, pRtree, bp) + margin = margin + _cellMargin(tls, pRtree, bp+48) + overlap = _cellOverlap(tls, pRtree, bp, bp+48, int32(1)) + area = _cellArea(tls, pRtree, bp) + _cellArea(tls, pRtree, bp+48) + if nLeft == ((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize-int32(4))/libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/int32(3) || overlap < fBestOverlap || overlap == fBestOverlap && area < fBestArea { + iBestLeft = nLeft + fBestOverlap = overlap + fBestArea = area + } + goto _4 + _4: + ; + nLeft = nLeft + 1 + } + if ii == 0 || margin < fBestMargin { + iBestDim = ii + fBestMargin = margin + iBestSplit = iBestLeft + } + goto _3 + _3: + ; + ii = ii + 1 + } + libc.X__builtin___memcpy_chk(tls, pBboxLeft, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(iBestDim)*8)))))*48, uint64(48), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, pBboxRight, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(iBestDim)*8)) + uintptr(iBestSplit)*4)))*48, uint64(48), ^t__predefined_size_t(0)) + ii = 0 + for { + if !(ii < nCell) { + break + } + if ii < iBestSplit { + v7 = pLeft + } else { + v7 = pRight + } + pTarget = v7 + if ii < iBestSplit { + v8 = pBboxLeft + } else { + v8 = pBboxRight + } + pBbox = v8 + pCell = aCell + uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(iBestDim)*8)) + uintptr(ii)*4)))*48 + _nodeInsertCell(tls, pRtree, pTarget, pCell) + _cellUnion(tls, pRtree, pBbox, pCell) + goto _6 + _6: + ; + ii = ii + 1 + } + Xsqlite3_free(tls, aaSorted) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Add a new column to the table currently being constructed. +// ** +// ** The parser calls this routine once for each column declaration +// ** in a CREATE TABLE statement. sqlite3StartTable() gets called +// ** first to get things going. Then this routine is called for each +// ** column. +// */ +func _sqlite3AddColumn(tls *libc.TLS, pParse uintptr, _sName TToken, _sType TToken) { + bp := tls.Alloc(48) + defer tls.Free(48) + *(*TToken)(unsafe.Pointer(bp)) = _sName + *(*TToken)(unsafe.Pointer(bp + 16)) = _sType + var aNew, db, p, pCol, z, zType, v1 uintptr + var affinity int8 + var eType, h, szEst Tu8 + var i int32 + _, _, _, _, _, _, _, _, _, _, _, _ = aNew, affinity, db, eType, h, i, p, pCol, szEst, z, zType, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + eType = uint8(COLTYPE_CUSTOM) + szEst = uint8(1) + affinity = int8(SQLITE_AFF_BLOB) + v1 = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + p = v1 + if v1 == uintptr(0) { + return + } + if int32((*TTable)(unsafe.Pointer(p)).FnCol)+int32(1) > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14300, libc.VaList(bp+40, (*TTable)(unsafe.Pointer(p)).FzName)) + return + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + _sqlite3DequoteToken(tls, bp) + } + /* Because keywords GENERATE ALWAYS can be converted into identifiers + ** by the parser, we can sometimes end up with a typename that ends + ** with "generated always". Check for this case and omit the surplus + ** text. */ + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(16) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz+uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-libc.Uint32FromInt32(6)), __ccgo_ts+14323, int32(6)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn -= uint32(6) + for (**(**TToken)(__ccgo_up(bp + 16))).Fn > uint32(0) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp + 16))).Fz + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-uint32(1)))))])&int32(0x01) != 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = (**(**TToken)(__ccgo_up(bp + 16))).Fn - 1 + } + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(9) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz+uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-libc.Uint32FromInt32(9)), __ccgo_ts+14330, int32(9)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn -= uint32(9) + for (**(**TToken)(__ccgo_up(bp + 16))).Fn > uint32(0) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp + 16))).Fz + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-uint32(1)))))])&int32(0x01) != 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = (**(**TToken)(__ccgo_up(bp + 16))).Fn - 1 + } + } + } + /* Check for standard typenames. For standard typenames we will + ** set the Column.eType field rather than storing the typename after + ** the column name, in order to save space. */ + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(3) { + _sqlite3DequoteToken(tls, bp+16) + i = 0 + for { + if !(i < int32(SQLITE_N_STDTYPE)) { + break + } + if (**(**TToken)(__ccgo_up(bp + 16))).Fn == uint32(_sqlite3StdTypeLen[i]) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz, _sqlite3StdType[i], libc.Int32FromUint32((**(**TToken)(__ccgo_up(bp + 16))).Fn)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = uint32(0) + eType = libc.Uint8FromInt32(i + int32(1)) + affinity = _sqlite3StdTypeAffinity[i] + if int32(affinity) <= int32(SQLITE_AFF_TEXT) { + szEst = uint8(5) + } + break + } + goto _2 + _2: + ; + i = i + 1 + } + } + z = _sqlite3DbMallocRaw(tls, db, libc.Uint64FromInt64(libc.Int64FromUint32((**(**TToken)(__ccgo_up(bp))).Fn)+int64(1)+libc.Int64FromUint32((**(**TToken)(__ccgo_up(bp + 16))).Fn)+libc.BoolInt64((**(**TToken)(__ccgo_up(bp + 16))).Fn > libc.Uint32FromInt32(0)))) + if z == uintptr(0) { + return + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, z, bp) + } + libc.X__builtin___memcpy_chk(tls, z, (**(**TToken)(__ccgo_up(bp))).Fz, uint64((**(**TToken)(__ccgo_up(bp))).Fn), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(z + uintptr((**(**TToken)(__ccgo_up(bp))).Fn))) = 0 + _sqlite3Dequote(tls, z) + if (*TTable)(unsafe.Pointer(p)).FnCol != 0 && _sqlite3ColumnIndex(tls, p, z) >= 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14340, libc.VaList(bp+40, z)) + _sqlite3DbFree(tls, db, z) + return + } + aNew = _sqlite3DbRealloc(tls, db, (*TTable)(unsafe.Pointer(p)).FaCol, libc.Uint64FromInt64(int64((*TTable)(unsafe.Pointer(p)).FnCol)+libc.Int64FromInt32(1))*uint64(16)) + if aNew == uintptr(0) { + _sqlite3DbFree(tls, db, z) + return + } + (*TTable)(unsafe.Pointer(p)).FaCol = aNew + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr((*TTable)(unsafe.Pointer(p)).FnCol)*16 + libc.X__builtin___memset_chk(tls, pCol, 0, uint64(16), ^t__predefined_size_t(0)) + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = z + (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, z) + if (**(**TToken)(__ccgo_up(bp + 16))).Fn == uint32(0) { + /* If there is no type specified, columns have the default affinity + ** 'BLOB' with a default size of 4 bytes. */ + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = affinity + libc.SetBitFieldPtr8Uint32(pCol+8, uint32(eType), 4, 0xf0) + (*TColumn)(unsafe.Pointer(pCol)).FszEst = szEst + } else { + zType = z + uintptr(_sqlite3Strlen30(tls, z)) + uintptr(1) + libc.X__builtin___memcpy_chk(tls, zType, (**(**TToken)(__ccgo_up(bp + 16))).Fz, uint64((**(**TToken)(__ccgo_up(bp + 16))).Fn), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(zType + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn))) = 0 + _sqlite3Dequote(tls, zType) + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3AffinityType(tls, zType, pCol) + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_HASTYPE)) + } + if int32((*TTable)(unsafe.Pointer(p)).FnCol) <= int32(0xff) { + h = uint8(uint64((*TColumn)(unsafe.Pointer(pCol)).FhName) % uint64(16)) + **(**Tu8)(__ccgo_up(p + 104 + uintptr(h))) = libc.Uint8FromInt16((*TTable)(unsafe.Pointer(p)).FnCol) + } + (*TTable)(unsafe.Pointer(p)).FnCol = (*TTable)(unsafe.Pointer(p)).FnCol + 1 + (*TTable)(unsafe.Pointer(p)).FnNVCol = (*TTable)(unsafe.Pointer(p)).FnNVCol + 1 + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName.Fn = uint32(0) +} + +// C documentation +// +// /* +// ** The expression is the default value for the most recently added column +// ** of the table currently under construction. +// ** +// ** Default value expressions must be constant. Raise an exception if this +// ** is not the case. +// ** +// ** This routine is called by the parser while in the middle of +// ** parsing a CREATE TABLE statement. +// */ +func _sqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStart uintptr, zEnd uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var db, p, pCol, pDfltExpr uintptr + var isInit int32 + var _ /* x at bp+0 */ TExpr + _, _, _, _, _ = db, isInit, p, pCol, pDfltExpr + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p != uintptr(0) { + isInit = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) != int32(1)) + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(p)).FnCol)-int32(1))*16 + if !(_sqlite3ExprIsConstantOrFunction(tls, pExpr, libc.Uint8FromInt32(isInit)) != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14366, libc.VaList(bp+80, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14411, 0) + } else { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_SPAN) + *(*uintptr)(unsafe.Pointer(bp + 8)) = _sqlite3DbSpanDup(tls, db, zStart, zEnd) + (**(**TExpr)(__ccgo_up(bp))).FpLeft = pExpr + (**(**TExpr)(__ccgo_up(bp))).Fflags = uint32(EP_Skip) + pDfltExpr = _sqlite3ExprDup(tls, db, bp, int32(EXPRDUP_REDUCE)) + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8))) + _sqlite3ColumnSetExpr(tls, pParse, p, pCol, pDfltExpr) + } + } + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameExprUnmap(tls, pParse, pExpr) + } + _sqlite3ExprDelete(tls, db, pExpr) +} + +// C documentation +// +// /* Change the most recently parsed column to be a GENERATED ALWAYS AS +// ** column. +// */ +func _sqlite3AddGenerated(tls *libc.TLS, pParse uintptr, pExpr uintptr, pType uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType Tu8 + var pCol, pTab, v1 uintptr + _, _, _, _ = eType, pCol, pTab, v1 + eType = uint8(COLFLAG_VIRTUAL) + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if pTab == uintptr(0) { + /* generated column in an CREATE TABLE IF NOT EXISTS that already exists */ + goto generated_done + } + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1))*16 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14601, 0) + goto generated_done + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) > 0 { + goto generated_error + } + if pType != 0 { + if (*TToken)(unsafe.Pointer(pType)).Fn == uint32(7) && Xsqlite3_strnicmp(tls, __ccgo_ts+14644, (*TToken)(unsafe.Pointer(pType)).Fz, int32(7)) == 0 { + /* no-op */ + } else { + if (*TToken)(unsafe.Pointer(pType)).Fn == uint32(6) && Xsqlite3_strnicmp(tls, __ccgo_ts+14652, (*TToken)(unsafe.Pointer(pType)).Fz, int32(6)) == 0 { + eType = uint8(COLFLAG_STORED) + } else { + goto generated_error + } + } + } + if libc.Int32FromUint8(eType) == int32(COLFLAG_VIRTUAL) { + (*TTable)(unsafe.Pointer(pTab)).FnNVCol = (*TTable)(unsafe.Pointer(pTab)).FnNVCol - 1 + } + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint8(eType)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(eType) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + _makeColumnPartOfPrimaryKey(tls, pParse, pCol) /* For the error message */ + } + if pExpr != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_ID) { + /* The value of a generated column needs to be a real expression, not + ** just a reference to another column, in order for covering index + ** optimizations to work correctly. So if the value is not an expression, + ** turn it into one by adding a unary "+" operator. */ + pExpr = _sqlite3PExpr(tls, pParse, int32(TK_UPLUS), pExpr, uintptr(0)) + } + if pExpr != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_RAISE) { + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = (*TColumn)(unsafe.Pointer(pCol)).Faffinity + } + _sqlite3ColumnSetExpr(tls, pParse, pTab, pCol, pExpr) + pExpr = uintptr(0) + goto generated_done + goto generated_error +generated_error: + ; + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14659, libc.VaList(bp+8, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + goto generated_done +generated_done: + ; + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) +} + +// C documentation +// +// /* +// ** Designate the PRIMARY KEY for the table. pList is a list of names +// ** of columns that form the primary key. If pList is NULL, then the +// ** most recently added column of the table is the primary key. +// ** +// ** A table can have at most one primary key. If the table already has +// ** a primary key (and this is the second primary key) then create an +// ** error. +// ** +// ** If the PRIMARY KEY is on a single column whose datatype is INTEGER, +// ** then we will try to use that column as the rowid. Set the Table.iPKey +// ** field of the table under construction to be the index of the +// ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is +// ** no INTEGER PRIMARY KEY. +// ** +// ** If the key is not an INTEGER PRIMARY KEY, then create a unique +// ** index for the key. No index is created for INTEGER PRIMARY KEYs. +// */ +func _sqlite3AddPrimaryKey(tls *libc.TLS, pParse uintptr, pList uintptr, onError int32, autoInc int32, sortOrder int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iCol, nTerm int32 + var pCExpr, pCExpr1, pCol, pTab uintptr + _, _, _, _, _, _, _ = i, iCol, nTerm, pCExpr, pCExpr1, pCol, pTab + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + pCol = uintptr(0) + iCol = -int32(1) + if pTab == uintptr(0) { + goto primary_key_exit + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasPrimaryKey) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14504, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto primary_key_exit + } + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_HasPrimaryKey) + if pList == uintptr(0) { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) - int32(1) + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + _makeColumnPartOfPrimaryKey(tls, pParse, pCol) + nTerm = int32(1) + } else { + nTerm = (*TExprList)(unsafe.Pointer(pList)).FnExpr + i = 0 + for { + if !(i < nTerm) { + break + } + pCExpr = _sqlite3ExprSkipCollate(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr) + _sqlite3StringToId(tls, pCExpr) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCExpr)).Fop) == int32(TK_ID) { + iCol = _sqlite3ColumnIndex(tls, pTab, *(*uintptr)(unsafe.Pointer(pCExpr + 8))) + if iCol >= 0 { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + _makeColumnPartOfPrimaryKey(tls, pParse, pCol) + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + if nTerm == int32(1) && pCol != 0 && int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == int32(COLTYPE_INTEGER) && sortOrder != int32(SQLITE_SO_DESC) { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && pList != 0 { + pCExpr1 = _sqlite3ExprSkipCollate(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8))).FpExpr) + _sqlite3RenameTokenRemap(tls, pParse, pTab+52, pCExpr1) + } + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(iCol) + (*TTable)(unsafe.Pointer(pTab)).FkeyConf = libc.Uint8FromInt32(onError) + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(autoInc * int32(TF_Autoincrement)) + if pList != 0 { + (*TParse)(unsafe.Pointer(pParse)).FiPkSortOrder = (*(*TExprList_item)(unsafe.Pointer(pList + 8))).Ffg.FsortFlags + } + _sqlite3HasExplicitNulls(tls, pParse, pList) + } else { + if autoInc != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14545, 0) + } else { + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, onError, uintptr(0), uintptr(0), sortOrder, 0, uint8(SQLITE_IDXTYPE_PRIMARYKEY)) + pList = uintptr(0) + } + } + goto primary_key_exit +primary_key_exit: + ; + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList) + return +} + +// C documentation +// +// /* +// ** Add the RETURNING clause to the parse currently underway. +// ** +// ** This routine creates a special TEMP trigger that will fire for each row +// ** of the DML statement. That TEMP trigger contains a single SELECT +// ** statement with a result set that is the argument of the RETURNING clause. +// ** The trigger has the Trigger.bReturning flag and an opcode of +// ** TK_RETURNING instead of TK_SELECT, so that the trigger code generator +// ** knows to handle it specially. The TEMP trigger is automatically +// ** removed at the end of the parse. +// ** +// ** When this routine is called, we do not yet know if the RETURNING clause +// ** is attached to a DELETE, INSERT, or UPDATE, so construct it as a +// ** RETURNING trigger instead. It will then be converted into the appropriate +// ** type on the first call to sqlite3TriggersExist(). +// */ +func _sqlite3AddReturning(tls *libc.TLS, pParse uintptr, pList uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pHash, pRet uintptr + _, _, _ = db, pHash, pRet + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14246, 0) + } else { + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 3, 0x8) + pRet = _sqlite3DbMallocZero(tls, db, uint64(232)) + if pRet == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pList) + return + } + (*(*struct { + FpReturning uintptr + })(unsafe.Pointer(&(*TParse)(unsafe.Pointer(pParse)).Fu1))).FpReturning = pRet + (*TReturning)(unsafe.Pointer(pRet)).FpParse = pParse + (*TReturning)(unsafe.Pointer(pRet)).FpReturnEL = pList + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3DeleteReturning), pRet) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + Xsqlite3_snprintf(tls, int32(40), pRet+188, __ccgo_ts+14280, libc.VaList(bp+8, pParse)) + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.FzName = pRet + 188 + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.Fop = uint8(TK_RETURNING) + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.Ftr_tm = uint8(TRIGGER_AFTER) + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.FbReturning = uint8(1) + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.FpTabSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.Fstep_list = pRet + 88 + (*TReturning)(unsafe.Pointer(pRet)).FretTStep.Fop = uint8(TK_RETURNING) + (*TReturning)(unsafe.Pointer(pRet)).FretTStep.FpTrig = pRet + 16 + (*TReturning)(unsafe.Pointer(pRet)).FretTStep.FpExprList = pList + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 56 + if _sqlite3HashInsert(tls, pHash, pRet+188, pRet+16) == pRet+16 { + _sqlite3OomFault(tls, db) + } +} + +// C documentation +// +// /* +// ** Initialize a Walker object so that will persist AggInfo entries referenced +// ** by the tree that is walked. +// */ +func _sqlite3AggInfoPersistWalkerInit(tls *libc.TLS, pWalker uintptr, pParse uintptr) { + libc.X__builtin___memset_chk(tls, pWalker, 0, uint64(48), ^t__predefined_size_t(0)) + (*TWalker)(unsafe.Pointer(pWalker)).FpParse = pParse + (*TWalker)(unsafe.Pointer(pWalker)).FxExprCallback = __ccgo_fp(_agginfoPersistExprCb) + (*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) +} + +// C documentation +// +// /* +// ** Generate bytecode to implement: +// ** +// ** ALTER TABLE pSrc ADD [CONSTRAINT pName] CHECK(pExpr) +// ** +// ** Any "ON CONFLICT" text that occurs after the "CHECK(...)", up +// ** until pParse->sLastToken, is included as part of the new constraint. +// */ +func _sqlite3AlterAddConstraint(tls *libc.TLS, pParse uintptr, pSrc uintptr, pFirst uintptr, pName uintptr, zExpr uintptr, nExpr int32, pExpr uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var nCons, rc int32 + var pCons, pTab, zName uintptr + var _ /* iDb at bp+0 */ int32 + var _ /* zDb at bp+8 */ uintptr + _, _, _, _, _ = nCons, pCons, pTab, rc, zName + pTab = uintptr(0) /* Table identified by pSrc */ + **(**int32)(__ccgo_up(bp)) = 0 /* Which schema does pTab live in */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Name of the schema in which pTab lives */ + pCons = uintptr(0) /* Result from error checking pExpr */ + /* Look up the table being altered. */ + pTab = _alterFindTable(tls, pParse, pSrc, bp, bp+8, int32(1)) + if !(pTab != 0) { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + return + } + /* Verify that the new CHECK constraint does not contain any + ** internal-use-only function. Forum post 2026-05-10T01:11:28Z + */ + rc = _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_IsCheck), pExpr, uintptr(0)) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + if rc != 0 { + return + } + /* If this new constraint has a name, check that it is not a duplicate of + ** an existing constraint. It is an error if it is. */ + if pName != 0 { + zName = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pName) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12627, libc.VaList(bp+24, zName, int32(SQLITE_ERROR), **(**uintptr)(__ccgo_up(bp + 8)), (*TTable)(unsafe.Pointer(pTab)).FzName, zName)) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zName) + } + /* Search for a constraint violation. Throw an exception if one is found. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12792, libc.VaList(bp+24, int32(SQLITE_CONSTRAINT), **(**uintptr)(__ccgo_up(bp + 8)), (*TTable)(unsafe.Pointer(pTab)).FzName, nExpr, zExpr)) + /* Edit the SQL for the named table. */ + pCons = (*TToken)(unsafe.Pointer(pFirst)).Fz + nCons = _alterRtrimConstraint(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCons, int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64(pCons))) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12872, libc.VaList(bp+24, **(**uintptr)(__ccgo_up(bp + 8)), nCons, pCons, (*TTable)(unsafe.Pointer(pTab)).FzName)) + /* Finally, reload the database schema. */ + _renameReloadSchema(tls, pParse, **(**int32)(__ccgo_up(bp)), uint16(INITFLAG_AlterDropCons)) +} + +// C documentation +// +// /* +// ** This function is called by the parser after the table-name in +// ** an "ALTER TABLE ADD" statement is parsed. Argument +// ** pSrc is the full-name of the table being altered. +// ** +// ** This routine makes a (partial) copy of the Table structure +// ** for the table being altered and sets Parse.pNewTable to point +// ** to it. Routines called by the parser as the column definition +// ** is parsed (i.e. sqlite3AddColumn()) add the new Column data to +// ** the copy. The copy of the Table structure is deleted by tokenize.c +// ** after parsing is finished. +// ** +// ** Routine sqlite3AlterFinishAddColumn() will be called to complete +// ** coding the "ALTER TABLE ... ADD" statement. +// */ +func _sqlite3AlterBeginAddColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pCol, pNew, pTab uintptr + var i, iDb, nAlloc int32 + _, _, _, _, _, _, _ = db, i, iDb, nAlloc, pCol, pNew, pTab + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Look up the table being altered. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_begin_add_column + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_begin_add_column + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11376, 0) + goto exit_begin_add_column + } + /* Make sure this is not an attempt to ALTER a view. */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11410, 0) + goto exit_begin_add_column + } + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_begin_add_column + } + _sqlite3MayAbort(tls, pParse) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + /* Put a copy of the Table struct in Parse.pNewTable for the + ** sqlite3AddColumn() function and friends to modify. But modify + ** the name by adding an "sqlite_altertab_" prefix. By adding this + ** prefix, we insure that the name will not collide with an existing + ** table because user table are not allowed to have the "sqlite_" + ** prefix on their name. + */ + pNew = _sqlite3DbMallocZero(tls, db, uint64(120)) + if !(pNew != 0) { + goto exit_begin_add_column + } + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = pNew + (*TTable)(unsafe.Pointer(pNew)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pNew)).FnCol = (*TTable)(unsafe.Pointer(pTab)).FnCol + nAlloc = (int32((*TTable)(unsafe.Pointer(pNew)).FnCol)-int32(1))/int32(8)*int32(8) + int32(8) + (*TTable)(unsafe.Pointer(pNew)).FaCol = _sqlite3DbMallocZero(tls, db, uint64(16)*uint64(libc.Uint32FromInt32(nAlloc))) + (*TTable)(unsafe.Pointer(pNew)).FzName = _sqlite3MPrintf(tls, db, __ccgo_ts+11440, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + if !((*TTable)(unsafe.Pointer(pNew)).FaCol != 0) || !((*TTable)(unsafe.Pointer(pNew)).FzName != 0) { + goto exit_begin_add_column + } + libc.X__builtin___memcpy_chk(tls, (*TTable)(unsafe.Pointer(pNew)).FaCol, (*TTable)(unsafe.Pointer(pTab)).FaCol, uint64(16)*libc.Uint64FromInt16((*TTable)(unsafe.Pointer(pNew)).FnCol), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pNew)).FnCol)) { + break + } + pCol = (*TTable)(unsafe.Pointer(pNew)).FaCol + uintptr(i)*16 + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = _sqlite3DbStrDup(tls, db, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + goto _1 + _1: + ; + i = i + 1 + } + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FpDfltList = _sqlite3ExprListDup(tls, db, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpDfltList, 0) + (*TTable)(unsafe.Pointer(pNew)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FaddColOffset = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FaddColOffset + goto exit_begin_add_column +exit_begin_add_column: + ; + _sqlite3SrcListDelete(tls, db, pSrc) + return +} + +// C documentation +// +// /* +// ** This function is called by the parser upon parsing an +// ** +// ** ALTER TABLE pSrc DROP COLUMN pName +// ** +// ** statement. Argument pSrc contains the possibly qualified name of the +// ** table being edited, and token pName the name of the column to drop. +// */ +func _sqlite3AlterDropColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var addr, i, iCol, iColPos, iCur, iDb, iPos, nField, reg, regOut, regRec, v2 int32 + var aff int8 + var db, pPk, pTab, v, zCol, zDb, v1 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, aff, db, i, iCol, iColPos, iCur, iDb, iPos, nField, pPk, pTab, reg, regOut, regRec, v, zCol, zDb, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database containing pTab ("main" etc.) */ + zCol = uintptr(0) /* Index of column zCol in pTab->aCol[] */ + /* Look up the table being altered. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_drop_column + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_drop_column + } + /* Make sure this is not an attempt to ALTER a view, virtual table or + ** system table. */ + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_drop_column + } + if SQLITE_OK != _isRealTable(tls, pParse, pTab, int32(1)) { + goto exit_drop_column + } + /* Find the index of the column being dropped. */ + zCol = _sqlite3NameFromToken(tls, db, pName) + if zCol == uintptr(0) { + goto exit_drop_column + } + iCol = _sqlite3ColumnIndex(tls, pTab, zCol) + if iCol < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11551, libc.VaList(bp+8, pName)) + goto exit_drop_column + } + /* Do not allow the user to drop a PRIMARY KEY column or a column + ** constrained by a UNIQUE constraint. */ + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&(libc.Int32FromInt32(COLFLAG_PRIMKEY)|libc.Int32FromInt32(COLFLAG_UNIQUE)) != 0 { + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + v1 = __ccgo_ts + 11936 + } else { + v1 = __ccgo_ts + 6175 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11948, libc.VaList(bp+8, v1, zCol)) + goto exit_drop_column + } + /* Do not allow the number of columns to go to zero */ + if int32((*TTable)(unsafe.Pointer(pTab)).FnCol) <= int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11976, libc.VaList(bp+8, zCol)) + goto exit_drop_column + } + /* Edit the sqlite_schema table */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, zCol) != 0 { + goto exit_drop_column + } + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1)), __ccgo_ts+1702, 0) + _renameFixQuotes(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1))) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12024, libc.VaList(bp+8, zDb, iDb, iCol, (*TTable)(unsafe.Pointer(pTab)).FzName)) + /* Drop and reload the database schema. */ + _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterDrop)) + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1)), __ccgo_ts+12145, int32(1)) + /* Edit rows of table on disk */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + pPk = uintptr(0) + nField = 0 + v = _sqlite3GetVdbe(tls, pParse) + v1 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + iCur = v2 + _sqlite3OpenTable(tls, pParse, iCur, iDb, pTab, int32(OP_OpenWrite)) + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iCur) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + reg = v2 + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iCur, reg) + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnColumn) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iCur, i, reg+i+int32(1)) + goto _6 + _6: + ; + i = i + 1 + } + nField = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + regRec = v2 + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if i != iCol && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + if pPk != 0 { + iPos = _sqlite3TableColumnToIndex(tls, pPk, i) + iColPos = _sqlite3TableColumnToIndex(tls, pPk, iCol) + if iPos < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) { + goto _9 + } + regOut = reg + int32(1) + iPos - libc.BoolInt32(iPos > iColPos) + } else { + regOut = reg + int32(1) + nField + } + if i == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regOut) + } else { + aff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity + if int32(aff) == int32(SQLITE_AFF_REAL) { + (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity = int8(SQLITE_AFF_NUMERIC) + } + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, i, regOut) + (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity = aff + } + nField = nField + 1 + } + goto _9 + _9: + ; + i = i + 1 + } + if nField == 0 { + /* dbsqlfuzz 5f09e7bcc78b4954d06bf9f2400d7715f48d1fef */ + (*TParse)(unsafe.Pointer(pParse)).FnMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + 1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, reg+int32(1)) + nField = int32(1) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), reg+int32(1), nField, regRec) + if pPk != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iCur, regRec, reg+int32(1), libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iCur, regRec, reg) + } + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iCur, addr+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addr) + } + goto exit_drop_column +exit_drop_column: + ; + _sqlite3DbFree(tls, db, zCol) + _sqlite3SrcListDelete(tls, db, pSrc) +} + +// C documentation +// +// /* +// ** Generate bytecode for one of: +// ** +// ** (1) ALTER TABLE pSrc DROP CONSTRAINT pCons +// ** (2) ALTER TABLE pSrc ALTER pCol DROP NOT NULL +// ** +// ** One of pCons and pCol must be NULL and the other non-null. +// */ +func _sqlite3AlterDropConstraint(tls *libc.TLS, pParse uintptr, pSrc uintptr, pCons uintptr, pCol uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pTab, z, zArg uintptr + var _ /* iCol at bp+16 */ int32 + var _ /* iDb at bp+0 */ int32 + var _ /* zDb at bp+8 */ uintptr + _, _, _, _ = db, pTab, z, zArg + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTab = uintptr(0) + **(**int32)(__ccgo_up(bp)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + zArg = uintptr(0) + pTab = _alterFindTable(tls, pParse, pSrc, bp, bp+8, libc.BoolInt32(pCons != uintptr(0))) + if !(pTab != 0) { + return + } + if pCons != 0 { + z = _sqlite3NameFromToken(tls, db, pCons) + zArg = _sqlite3MPrintf(tls, db, __ccgo_ts+12269, libc.VaList(bp+32, z)) + _sqlite3DbFree(tls, db, z) + } else { + if _alterFindCol(tls, pParse, pTab, pCol, bp+16) != 0 { + return + } + zArg = _sqlite3MPrintf(tls, db, __ccgo_ts+5633, libc.VaList(bp+32, **(**int32)(__ccgo_up(bp + 16)))) + } + /* Edit the SQL for the named table. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12272, libc.VaList(bp+32, **(**uintptr)(__ccgo_up(bp + 8)), zArg, (*TTable)(unsafe.Pointer(pTab)).FzName)) + _sqlite3DbFree(tls, db, zArg) + /* Finally, reload the database schema. */ + _renameReloadSchema(tls, pParse, **(**int32)(__ccgo_up(bp)), uint16(INITFLAG_AlterDropCons)) +} + +// C documentation +// +// /* +// ** This function is called after an "ALTER TABLE ... ADD" statement +// ** has been parsed. Argument pColDef contains the text of the new +// ** column definition. +// ** +// ** The Table structure pParse->pNewTable was extended to include +// ** the new column during parsing. +// */ +func _sqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pCol, pDflt, pNew, pTab, v, zCol, zDb, zEnd, zTab, v1 uintptr + var iDb, r1, rc int32 + var _ /* pVal at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, iDb, pCol, pDflt, pNew, pTab, r1, rc, v, zCol, zDb, zEnd, zTab, v1 /* Temporary registers */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pNew)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + zTab = (*TTable)(unsafe.Pointer(pNew)).FzName + 16 /* Skip the "sqlite_altertab_" prefix on the name */ + pCol = (*TTable)(unsafe.Pointer(pNew)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pNew)).FnCol)-int32(1))*16 + pDflt = _sqlite3ColumnExpr(tls, pNew, pCol) + pTab = _sqlite3FindTable(tls, db, zTab, zDb) + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + return + } + /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. + ** If there is a NOT NULL constraint, then the default value for the + ** column must not be NULL. + */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+10633, 0) + return + } + if (*TTable)(unsafe.Pointer(pNew)).FpIndex != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+10665, 0) + return + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) == 0 { + /* If the default value for the new column was specified with a + ** literal NULL, then set pDflt to 0. This simplifies checking + ** for an SQL NULL default below. + */ + if pDflt != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == int32(TK_NULL) { + pDflt = uintptr(0) + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FpFKey != 0 && pDflt != 0 { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10692) + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 && !(pDflt != 0) { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10751) + } + /* Ensure the default expression is something that sqlite3ValueFromExpr() + ** can handle (i.e. not CURRENT_TIME etc.) + */ + if pDflt != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _sqlite3ValueFromExpr(tls, db, pDflt, uint8(SQLITE_UTF8), uint8(SQLITE_AFF_BLOB), bp) + if rc != SQLITE_OK { + return + } + if !(**(**uintptr)(__ccgo_up(bp)) != 0) { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10804) + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp))) + } + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_STORED) != 0 { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10850) + } + } + /* Modify the CREATE TABLE statement. */ + zCol = _sqlite3DbStrNDup(tls, db, (*TToken)(unsafe.Pointer(pColDef)).Fz, uint64((*TToken)(unsafe.Pointer(pColDef)).Fn)) + if zCol != 0 { + zEnd = zCol + uintptr((*TToken)(unsafe.Pointer(pColDef)).Fn-uint32(1)) + for zEnd > zCol && (int32(**(**int8)(__ccgo_up(zEnd))) == int32(';') || libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zEnd)))])&int32(0x01) != 0) { + v1 = zEnd + zEnd = zEnd - 1 + **(**int8)(__ccgo_up(v1)) = int8('\000') + } + /* substr() operations on characters, but addColOffset is in bytes. So we + ** have to use printf() to translate between these units: */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10877, libc.VaList(bp+16, zDb, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FaddColOffset, zCol, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FaddColOffset, zTab)) + _sqlite3DbFree(tls, db, zCol) + } + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + /* Make sure the schema version is at least 3. But do not upgrade + ** from less than 3 to 4, as that will corrupt any preexisting DESC + ** index. + */ + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_ReadCookie), iDb, r1, int32(BTREE_FILE_FORMAT)) + _sqlite3VdbeUsesBtree(tls, v, iDb) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), r1, -int32(2)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), r1, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_FILE_FORMAT), int32(3)) + _sqlite3ReleaseTempReg(tls, pParse, r1) + /* Reload the table definition */ + _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterAdd)) + /* Verify that constraints are still satisfied */ + if (*TTable)(unsafe.Pointer(pNew)).FpCheck != uintptr(0) || int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 && libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Strict) != uint32(0) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11023, libc.VaList(bp+16, zTab, zDb)) + } + } +} + +// C documentation +// +// /* +// ** Handles the following parser reduction: +// ** +// ** cmd ::= ALTER TABLE pSrc RENAME COLUMN pOld TO pNew +// */ +func _sqlite3AlterRenameColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pOld uintptr, pNew uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bQuote, iCol, iSchema int32 + var db, pTab, zDb, zNew, zOld uintptr + _, _, _, _, _, _, _, _ = bQuote, db, iCol, iSchema, pTab, zDb, zNew, zOld + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Index of column being renamed */ + zOld = uintptr(0) /* Old column name */ + zNew = uintptr(0) /* True to quote the new name */ + /* Locate the table to be altered */ + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_rename_column + } + /* Cannot alter a system table */ + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_rename_column + } + if SQLITE_OK != _isRealTable(tls, pParse, pTab, 0) { + goto exit_rename_column + } + /* Which schema holds the table to be altered */ + iSchema = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*32))).FzDbSName + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + goto exit_rename_column + } + /* Make sure the old name really is a column name in the table to be + ** altered. Set iCol to be the index of the column being renamed */ + zOld = _sqlite3NameFromToken(tls, db, pOld) + if !(zOld != 0) { + goto exit_rename_column + } + iCol = _sqlite3ColumnIndex(tls, pTab, zOld) + if iCol < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11551, libc.VaList(bp+8, pOld)) + goto exit_rename_column + } + /* Ensure the schema contains no double-quoted strings */ + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1)), __ccgo_ts+1702, 0) + _renameFixQuotes(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1))) + /* Do the rename operation using a recursive UPDATE statement that + ** uses the sqlite_rename_column() SQL function to compute the new + ** CREATE statement text for the sqlite_schema table. + */ + _sqlite3MayAbort(tls, pParse) + zNew = _sqlite3NameFromToken(tls, db, pNew) + if !(zNew != 0) { + goto exit_rename_column + } + bQuote = libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up((*TToken)(unsafe.Pointer(pNew)).Fz)))]) & int32(0x80) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11572, libc.VaList(bp+8, zDb, zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, iCol, zNew, bQuote, libc.BoolInt32(iSchema == int32(1)), (*TTable)(unsafe.Pointer(pTab)).FzName)) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11754, libc.VaList(bp+8, zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, iCol, zNew, bQuote)) + /* Drop and reload the database schema. */ + _renameReloadSchema(tls, pParse, iSchema, uint16(INITFLAG_AlterRename)) + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1)), __ccgo_ts+10582, int32(1)) + goto exit_rename_column +exit_rename_column: + ; + _sqlite3SrcListDelete(tls, db, pSrc) + _sqlite3DbFree(tls, db, zOld) + _sqlite3DbFree(tls, db, zNew) + return +} + +// C documentation +// +// /* +// ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" +// ** command. +// */ +func _sqlite3AlterRenameTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pTab, pVTab, v, zDb, zName, zTabName, v2 uintptr + var i, iDb, nTabName, v1 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iDb, nTabName, pTab, pVTab, v, zDb, zName, zTabName, v1, v2 /* Table being renamed */ + zName = uintptr(0) /* NULL-terminated version of pName */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pVTab = uintptr(0) /* Non-zero if this is a v-tab with an xRename() */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_rename_table + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_rename_table + } + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Get a NULL terminated version of the new table name. */ + zName = _sqlite3NameFromToken(tls, db, pName) + if !(zName != 0) { + goto exit_rename_table + } + /* Check that a table or index named 'zName' does not already exist + ** in database iDb. If so, this is an error. + */ + if _sqlite3FindTable(tls, db, zName, zDb) != 0 || _sqlite3FindIndex(tls, db, zName, zDb) != 0 || _sqlite3IsShadowTableOf(tls, db, pTab, zName) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+9662, libc.VaList(bp+8, zName)) + goto exit_rename_table + } + /* Make sure it is not a system table being altered, or a reserved name + ** that the table is being renamed to. + */ + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_rename_table + } + if SQLITE_OK != _sqlite3CheckObjectName(tls, pParse, zName, __ccgo_ts+9721, zName) { + goto exit_rename_table + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+9727, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_rename_table + } + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + goto exit_rename_table + } + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto exit_rename_table + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + pVTab = _sqlite3GetVTable(tls, db, pTab) + if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer((*TVTable)(unsafe.Pointer(pVTab)).FpVtab)).FpModule)).FxRename == uintptr(0) { + pVTab = uintptr(0) + } + } + /* Begin a transaction for database iDb. Then modify the schema cookie + ** (since the ALTER TABLE modifies the schema). Call sqlite3MayAbort(), + ** as the scalar functions (e.g. sqlite_rename_table()) invoked by the + ** nested SQL may raise an exception. */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto exit_rename_table + } + _sqlite3MayAbort(tls, pParse) + /* figure out how many UTF-8 characters are in zName */ + zTabName = (*TTable)(unsafe.Pointer(pTab)).FzName + nTabName = _sqlite3Utf8CharLen(tls, zTabName, -int32(1)) + /* Rewrite all CREATE TABLE, INDEX, TRIGGER or VIEW statements in + ** the schema to use the new table name. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9754, libc.VaList(bp+8, zDb, zDb, zTabName, zName, libc.BoolInt32(iDb == int32(1)), zTabName)) + /* Update the tbl_name and name columns of the sqlite_schema table + ** as required. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9938, libc.VaList(bp+8, zDb, zName, zName, zName, nTabName, zTabName)) + /* If the sqlite_sequence table exists in this database, then update + ** it with the new table name. + */ + if _sqlite3FindTable(tls, db, __ccgo_ts+10243, zDb) != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10259, libc.VaList(bp+8, zDb, zName, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + /* If the table being renamed is not itself part of the temp database, + ** edit view and trigger definitions within the temp database + ** as required. */ + if iDb != int32(1) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10317, libc.VaList(bp+8, zDb, zTabName, zName, zTabName, zDb, zName)) + } + /* If this is a virtual table, invoke the xRename() function if + ** one is defined. The xRename() callback will modify the names + ** of any resources used by the v-table implementation (including other + ** SQLite tables) that are identified by the name of the virtual table. + */ + if pVTab != 0 { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + i = v1 + _sqlite3VdbeLoadString(tls, v, i, zName) + _sqlite3VdbeAddOp4(tls, v, int32(OP_VRename), i, 0, 0, pVTab, -int32(12)) + } + _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterRename)) + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1)), __ccgo_ts+10582, 0) + goto exit_rename_table +exit_rename_table: + ; + _sqlite3SrcListDelete(tls, db, pSrc) + _sqlite3DbFree(tls, db, zName) +} + +// C documentation +// +// /* +// ** Prepare a statement of the form: +// ** +// ** ALTER TABLE pSrc ALTER pCol SET NOT NULL +// */ +func _sqlite3AlterSetNotNull(tls *libc.TLS, pParse uintptr, pSrc uintptr, pCol uintptr, pFirst uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var nCons int32 + var pCons, pTab uintptr + var _ /* iCol at bp+0 */ int32 + var _ /* iDb at bp+4 */ int32 + var _ /* zDb at bp+8 */ uintptr + _, _, _ = nCons, pCons, pTab + pTab = uintptr(0) + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pCons = uintptr(0) + nCons = 0 + /* Look up the table being altered. */ + pTab = _alterFindTable(tls, pParse, pSrc, bp+4, bp+8, 0) + if !(pTab != 0) { + return + } + /* Find the column being altered. */ + if _alterFindCol(tls, pParse, pTab, pCol, bp) != 0 { + return + } + /* Find the length in bytes of the constraint definition */ + pCons = (*TToken)(unsafe.Pointer(pFirst)).Fz + nCons = _alterRtrimConstraint(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCons, int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64(pCons))) + /* Search for a constraint violation. Throw an exception if one is found. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12395, libc.VaList(bp+24, int32(SQLITE_CONSTRAINT), **(**uintptr)(__ccgo_up(bp + 8)), (*TTable)(unsafe.Pointer(pTab)).FzName, libc.Int32FromUint32((*TToken)(unsafe.Pointer(pCol)).Fn), (*TToken)(unsafe.Pointer(pCol)).Fz)) + /* Edit the SQL for the named table. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12476, libc.VaList(bp+24, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp)), nCons, pCons, **(**int32)(__ccgo_up(bp)), (*TTable)(unsafe.Pointer(pTab)).FzName)) + /* Finally, reload the database schema. */ + _renameReloadSchema(tls, pParse, **(**int32)(__ccgo_up(bp + 4)), uint16(INITFLAG_AlterDropCons)) +} + +// C documentation +// +// /* +// ** Load the content of the sqlite_stat1 and sqlite_stat4 tables. The +// ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] +// ** arrays. The contents of sqlite_stat4 are used to populate the +// ** Index.aSample[] arrays. +// ** +// ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR +// ** is returned. In this case, even if SQLITE_ENABLE_STAT4 was defined +// ** during compilation and the sqlite_stat4 table is present, no data is +// ** read from it. +// ** +// ** If SQLITE_ENABLE_STAT4 was defined during compilation and the +// ** sqlite_stat4 table is not present in the database, SQLITE_ERROR is +// ** returned. However, in this case, data is read from the sqlite_stat1 +// ** table (if it is present) before returning. +// ** +// ** If an OOM error occurs, this function always sets db->mallocFailed. +// ** This means if the caller does not care about other errors, the return +// ** code may be ignored. +// */ +func _sqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, pIdx, pIdx1, pIdx2, pSchema, pStat1, pTab, zSql, v3 uintptr + var rc, v5 int32 + var _ /* sInfo at bp+0 */ TanalysisInfo + _, _, _, _, _, _, _, _, _, _, _ = i, pIdx, pIdx1, pIdx2, pSchema, pStat1, pTab, rc, zSql, v3, v5 + rc = SQLITE_OK + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + /* Clear any prior statistics */ + i = (*THash)(unsafe.Pointer(pSchema + 8)).Ffirst + for { + if !(i != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(i)).Fdata + **(**Tu32)(__ccgo_up(pTab + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(TF_HasStat1)) + goto _1 + _1: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + i = (*THash)(unsafe.Pointer(pSchema + 32)).Ffirst + for { + if !(i != 0) { + break + } + pIdx = (*THashElem)(unsafe.Pointer(i)).Fdata + libc.SetBitFieldPtr16Uint32(pIdx+100, libc.Uint32FromInt32(0), 7, 0x80) + _sqlite3DeleteIndexSamples(tls, db, pIdx) + (*TIndex)(unsafe.Pointer(pIdx)).FaSample = uintptr(0) + goto _2 + _2: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + /* Load new statistics out of the sqlite_stat1 table */ + (**(**TanalysisInfo)(__ccgo_up(bp))).Fdb = db + (**(**TanalysisInfo)(__ccgo_up(bp))).FzDatabase = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + v3 = _sqlite3FindTable(tls, db, __ccgo_ts+13177, (**(**TanalysisInfo)(__ccgo_up(bp))).FzDatabase) + pStat1 = v3 + if v3 != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pStat1)).FeTabType) == TABTYP_NORM { + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+13550, libc.VaList(bp+24, (**(**TanalysisInfo)(__ccgo_up(bp))).FzDatabase)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_analysisLoader), bp, uintptr(0)) + _sqlite3DbFree(tls, db, zSql) + } + } + /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */ + i = (*THash)(unsafe.Pointer(pSchema + 32)).Ffirst + for { + if !(i != 0) { + break + } + pIdx1 = (*THashElem)(unsafe.Pointer(i)).Fdata + if !(int32(uint32(*(*uint16)(unsafe.Pointer(pIdx1 + 100))&0x80>>7)) != 0) { + _sqlite3DefaultRowEst(tls, pIdx1) + } + goto _4 + _4: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + /* Load the statistics from the sqlite_stat4 table. */ + if rc == SQLITE_OK { + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + rc = _loadStat4(tls, db, (**(**TanalysisInfo)(__ccgo_up(bp))).FzDatabase) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v5 = 0 + } else { + v5 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v5) + } + i = (*THash)(unsafe.Pointer(pSchema + 32)).Ffirst + for { + if !(i != 0) { + break + } + pIdx2 = (*THashElem)(unsafe.Pointer(i)).Fdata + Xsqlite3_free(tls, (*TIndex)(unsafe.Pointer(pIdx2)).FaiRowEst) + (*TIndex)(unsafe.Pointer(pIdx2)).FaiRowEst = uintptr(0) + goto _6 + _6: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + return rc +} + +/************** End of analyze.c *********************************************/ +/************** Begin file attach.c ******************************************/ +/* +** 2003 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the ATTACH and DETACH commands. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** pArray is a pointer to an array of objects. Each object in the +// ** array is szEntry bytes in size. This routine uses sqlite3DbRealloc() +// ** to extend the array so that there is space for a new object at the end. +// ** +// ** When this function is called, *pnEntry contains the current size of +// ** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes +// ** in total). +// ** +// ** If the realloc() is successful (i.e. if no OOM condition occurs), the +// ** space allocated for the new object is zeroed, *pnEntry updated to +// ** reflect the new size of the array and a pointer to the new allocation +// ** returned. *pIdx is set to the index of the new array entry in this case. +// ** +// ** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains +// ** unchanged and a copy of pArray returned. +// */ +func _sqlite3ArrayAllocate(tls *libc.TLS, db uintptr, pArray uintptr, szEntry int32, pnEntry uintptr, pIdx uintptr) (r uintptr) { + var n, sz Tsqlite3_int64 + var pNew, z uintptr + var v1 int32 + var v2 int64 + _, _, _, _, _, _ = n, pNew, sz, z, v1, v2 + v1 = **(**int32)(__ccgo_up(pnEntry)) + **(**int32)(__ccgo_up(pIdx)) = v1 + n = int64(v1) + if n&(n-int64(1)) == 0 { + if n == 0 { + v2 = int64(1) + } else { + v2 = int64(2) * n + } + sz = v2 + pNew = _sqlite3DbRealloc(tls, db, pArray, libc.Uint64FromInt64(sz*int64(szEntry))) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(pIdx)) = -int32(1) + return pArray + } + pArray = pNew + } + z = pArray + libc.X__builtin___memset_chk(tls, z+uintptr(n*int64(szEntry)), 0, libc.Uint64FromInt32(szEntry), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pnEntry)) = **(**int32)(__ccgo_up(pnEntry)) + 1 + return pArray +} + +// C documentation +// +// /* +// ** Do an authorization check using the code and arguments given. Return +// ** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY. If SQLITE_DENY +// ** is returned, then the error count and error message in pParse are +// ** modified appropriately. +// */ +func _sqlite3AuthCheck(tls *libc.TLS, pParse uintptr, code int32, zArg1 uintptr, zArg2 uintptr, zArg3 uintptr) (r int32) { + var db uintptr + var rc int32 + _, _ = db, rc + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Don't do any authorization checks if the database is initializing + ** or if the parser is being invoked from within sqlite3_declare_vtab. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FxAuth == uintptr(0) || (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + return SQLITE_OK + } + /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the + ** callback are either NULL pointers or zero-terminated strings that + ** contain additional details about the action to be authorized. + ** + ** The following testcase() macros show that any of the 3rd through 6th + ** parameters can be either NULL or a string. */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxAuth})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpAuthArg, code, zArg1, zArg2, zArg3, (*TParse)(unsafe.Pointer(pParse)).FzAuthContext) + if rc == int32(SQLITE_DENY) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14015, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_AUTH) + } else { + if rc != SQLITE_OK && rc != int32(SQLITE_IGNORE) { + rc = int32(SQLITE_DENY) + _sqliteAuthBadReturnCode(tls, pParse) + } + } + return rc +} + +// C documentation +// +// /* +// ** The pExpr should be a TK_COLUMN expression. The table referred to +// ** is in pTabList or else it is the NEW or OLD table of a trigger. +// ** Check to see if it is OK to read this particular column. +// ** +// ** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN +// ** instruction into a TK_NULL. If the auth function returns SQLITE_DENY, +// ** then generate an error. +// */ +func _sqlite3AuthRead(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSchema uintptr, pTabList uintptr) { + var iCol, iDb, iSrc int32 + var pTab, zCol uintptr + _, _, _, _, _ = iCol, iDb, iSrc, pTab, zCol + pTab = uintptr(0) /* Index of column in table */ + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSchema) + if iDb < 0 { + /* An attempt to read a column out of a subquery or other + ** temporary table. */ + return + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_TRIGGER) { + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } else { + iSrc = 0 + for { + if !(iSrc < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(iSrc)*80))).FiCursor { + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(iSrc)*80))).FpSTab + break + } + goto _1 + _1: + ; + iSrc = iSrc + 1 + } + } + iCol = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + if pTab == uintptr(0) { + return + } + if iCol >= 0 { + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + } else { + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) >= 0 { + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TTable)(unsafe.Pointer(pTab)).FiPKey)*16))).FzCnName + } else { + zCol = __ccgo_ts + 8541 + } + } + if int32(SQLITE_IGNORE) == _sqlite3AuthReadCol(tls, pParse, (*TTable)(unsafe.Pointer(pTab)).FzName, zCol, iDb) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + } +} + +// C documentation +// +// /* +// ** Invoke the authorization callback for permission to read column zCol from +// ** table zTab in database zDb. This function assumes that an authorization +// ** callback has been registered (i.e. that sqlite3.xAuth is not NULL). +// ** +// ** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed +// ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE +// ** is treated as SQLITE_DENY. In this case an error is left in pParse. +// */ +func _sqlite3AuthReadCol(tls *libc.TLS, pParse uintptr, zTab uintptr, zCol uintptr, iDb int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, z, zDb uintptr + var rc int32 + _, _, _, _ = db, rc, z, zDb + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database handle */ + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName /* Auth callback return code */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + return SQLITE_OK + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxAuth})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpAuthArg, int32(SQLITE_READ), zTab, zCol, zDb, (*TParse)(unsafe.Pointer(pParse)).FzAuthContext) + if rc == int32(SQLITE_DENY) { + z = Xsqlite3_mprintf(tls, __ccgo_ts+13976, libc.VaList(bp+8, zTab, zCol)) + if (*Tsqlite3)(unsafe.Pointer(db)).FnDb > int32(2) || iDb != 0 { + z = Xsqlite3_mprintf(tls, __ccgo_ts+13982, libc.VaList(bp+8, zDb, z)) + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13988, libc.VaList(bp+8, z)) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_AUTH) + } else { + if rc != int32(SQLITE_IGNORE) && rc != SQLITE_OK { + _sqliteAuthBadReturnCode(tls, pParse) + } + } + return rc +} + +// C documentation +// +// /* +// ** Load all automatic extensions. +// ** +// ** If anything goes wrong, set an error in the database connection. +// */ +func _sqlite3AutoLoadExtensions(tls *libc.TLS, db uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var go1, rc, v2 int32 + var i Tu32 + var mutex, pThunk uintptr + var xInit Tsqlite3_loadext_entry + var v3 bool + var _ /* zErrmsg at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = go1, i, mutex, pThunk, rc, xInit, v2, v3 + go1 = int32(1) + if _sqlite3Autoext.FnExt == uint32(0) { + /* Common case: early out without every having to acquire a mutex */ + return + } + i = uint32(0) + for { + if !(go1 != 0) { + break + } + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + pThunk = uintptr(unsafe.Pointer(&_sqlite3Apis)) + Xsqlite3_mutex_enter(tls, mutex) + if i >= _sqlite3Autoext.FnExt { + xInit = uintptr(0) + go1 = 0 + } else { + xInit = **(**uintptr)(__ccgo_up(_sqlite3Autoext.FaExt + uintptr(i)*8)) + } + Xsqlite3_mutex_leave(tls, mutex) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if v3 = xInit != 0; v3 { + v2 = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xInit})))(tls, db, bp, pThunk) + rc = v2 + } + if v3 && v2 != 0 { + _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+18088, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp)))) + go1 = 0 + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + goto _1 + _1: + ; + i = i + 1 + } +} + +/************** End of loadext.c *********************************************/ +/************** Begin file pragma.c ******************************************/ +/* +** 2003 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the PRAGMA command. + */ +/* #include "sqliteInt.h" */ + +/*************************************************************************** +** The "pragma.h" include file is an automatically generated file that +** that includes the PragType_XXXX macro definitions and the aPragmaName[] +** object. This ensures that the aPragmaName[] table is arranged in +** lexicographical order to facility a binary search of the pragma name. +** Do not edit pragma.h directly. Edit and rerun the script in at +** ../tool/mkpragmatab.tcl. */ +/************** Include pragma.h in the middle of pragma.c *******************/ +/************** Begin file pragma.h ******************************************/ +/* DO NOT EDIT! +** This file is automatically generated by the script at +** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit +** that script and rerun it. + */ + +/* The various pragma types */ + +/* Property flags associated with various pragma. */ + +// C documentation +// +// /* +// ** Generate VDBE code for a BEGIN statement. +// */ +func _sqlite3BeginTransaction(tls *libc.TLS, pParse uintptr, type1 int32) { + var db, pBt, v uintptr + var eTxnType, i int32 + _, _, _, _, _ = db, eTxnType, i, pBt, v + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_TRANSACTION), __ccgo_ts+16447, uintptr(0), uintptr(0)) != 0 { + return + } + v = _sqlite3GetVdbe(tls, pParse) + if !(v != 0) { + return + } + if type1 != int32(TK_DEFERRED) { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 && _sqlite3BtreeIsReadonly(tls, pBt) != 0 { + eTxnType = 0 /* Read txn */ + } else { + if type1 == int32(TK_EXCLUSIVE) { + eTxnType = int32(2) /* Exclusive txn */ + } else { + eTxnType = int32(1) /* Write txn */ + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Transaction), i, eTxnType) + _sqlite3VdbeUsesBtree(tls, v, i) + goto _1 + _1: + ; + i = i + 1 + } + } + _sqlite3VdbeAddOp0(tls, v, int32(OP_AutoCommit)) +} + +// C documentation +// +// /* +// ** This is called by the parser when it sees a CREATE TRIGGER statement +// ** up to the point of the BEGIN before the trigger actions. A Trigger +// ** structure is generated based on the information available and stored +// ** in pParse->pNewTrigger. After the trigger actions have been parsed, the +// ** sqlite3FinishTrigger() function is called to complete the trigger +// ** construction process. +// */ +func _sqlite3BeginTrigger(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, tr_tm int32, op int32, pColumns uintptr, pTableName uintptr, pWhen uintptr, isTemp int32, noErr int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var code, iDb, iTabDb, v4 int32 + var db, pTab, pTrigger, zDb, zDbTrig, zName, v1 uintptr + var _ /* pName at bp+0 */ uintptr + var _ /* sFix at bp+8 */ TDbFixer + _, _, _, _, _, _, _, _, _, _, _ = code, db, iDb, iTabDb, pTab, pTrigger, zDb, zDbTrig, zName, v1, v4 + pTrigger = uintptr(0) /* Table that the trigger fires off of */ + zName = uintptr(0) /* Name of the trigger */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* State vector for the DB fixer */ + /* pName1->z might be NULL, but not pName1 itself */ + if isTemp != 0 { + /* If TEMP was specified, then the trigger name may not be qualified. */ + if (*TToken)(unsafe.Pointer(pName2)).Fn > uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22187, 0) + goto trigger_cleanup + } + iDb = int32(1) + **(**uintptr)(__ccgo_up(bp)) = pName1 + } else { + /* Figure out the db that the trigger will be created in */ + iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp) + if iDb < 0 { + goto trigger_cleanup + } + } + if !(pTableName != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto trigger_cleanup + } + /* A long-standing parser bug is that this syntax was allowed: + ** + ** CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab .... + ** ^^^^^^^^ + ** + ** To maintain backwards compatibility, ignore the database + ** name on pTableName if we are reparsing out of the schema table + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 && iDb != int32(1) { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pTableName + 8 + 72))) + *(*uintptr)(unsafe.Pointer(pTableName + 8 + 72)) = uintptr(0) + } + /* If the trigger name was unqualified, and the table is a temp table, + ** then set iDb to 1 to create the trigger in the temporary database. + ** If sqlite3SrcListLookup() returns 0, indicating the table does not + ** exist, the error is caught by the block below. + */ + pTab = _sqlite3SrcListLookup(tls, pParse, pTableName) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 && (*TToken)(unsafe.Pointer(pName2)).Fn == uint32(0) && pTab != 0 && (*TTable)(unsafe.Pointer(pTab)).FpSchema == (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema { + iDb = int32(1) + } + /* Ensure the table name matches database name and that the table exists */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto trigger_cleanup + } + _sqlite3FixInit(tls, bp+8, pParse, iDb, __ccgo_ts+22233, **(**uintptr)(__ccgo_up(bp))) + if _sqlite3FixSrcList(tls, bp+8, pTableName) != 0 { + goto trigger_cleanup + } + pTab = _sqlite3SrcListLookup(tls, pParse, pTableName) + if !(pTab != 0) { + /* The table does not exist. */ + goto trigger_orphan_error + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22241, 0) + goto trigger_orphan_error + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Shadow) != uint32(0) && _sqlite3ReadOnlyShadowTables(tls, db) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22282, 0) + goto trigger_orphan_error + } + /* Check that the trigger name is not reserved and that no trigger of the + ** specified name exists */ + zName = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if zName == uintptr(0) { + goto trigger_cleanup + } + if _sqlite3CheckObjectName(tls, pParse, zName, __ccgo_ts+22233, (*TTable)(unsafe.Pointer(pTab)).FzName) != 0 { + goto trigger_cleanup + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema+56, zName) != 0 { + if !(noErr != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22322, libc.VaList(bp+112, **(**uintptr)(__ccgo_up(bp)))) + } else { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + } + goto trigger_cleanup + } + } + /* NB: The SQLITE_ALLOW_TRIGGERS_ON_SYSTEM_TABLES compile-time option is + ** experimental and unsupported. Do not use it unless understand the + ** implications and you cannot get by without this capability. */ + /* Do not create a trigger on a system table */ + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+7100, int32(7)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22348, 0) + goto trigger_cleanup + } + /* INSTEAD of triggers are only for views and views only support INSTEAD + ** of triggers. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) && tr_tm != int32(TK_INSTEAD) { + if tr_tm == int32(TK_BEFORE) { + v1 = __ccgo_ts + 22386 + } else { + v1 = __ccgo_ts + 22393 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22399, libc.VaList(bp+112, v1, pTableName+8)) + goto trigger_orphan_error + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VIEW)) && tr_tm == int32(TK_INSTEAD) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22436, libc.VaList(bp+112, pTableName+8)) + goto trigger_orphan_error + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + iTabDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + code = int32(SQLITE_CREATE_TRIGGER) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iTabDb)*32))).FzDbSName + if isTemp != 0 { + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FzDbSName + } else { + v1 = zDb + } + zDbTrig = v1 + if iTabDb == int32(1) || isTemp != 0 { + code = int32(SQLITE_CREATE_TEMP_TRIGGER) + } + if _sqlite3AuthCheck(tls, pParse, code, zName, (*TTable)(unsafe.Pointer(pTab)).FzName, zDbTrig) != 0 { + goto trigger_cleanup + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iTabDb == int32(1) { + v1 = __ccgo_ts + 7108 + } else { + v1 = __ccgo_ts + 6628 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), v1, uintptr(0), zDb) != 0 { + goto trigger_cleanup + } + } + /* INSTEAD OF triggers can only appear on views and BEFORE triggers + ** cannot appear on views. So we might as well translate every + ** INSTEAD OF trigger into a BEFORE trigger. It simplifies code + ** elsewhere. + */ + if tr_tm == int32(TK_INSTEAD) { + tr_tm = int32(TK_BEFORE) + } + /* Build the Trigger object */ + pTrigger = _sqlite3DbMallocZero(tls, db, uint64(72)) + if pTrigger == uintptr(0) { + goto trigger_cleanup + } + (*TTrigger)(unsafe.Pointer(pTrigger)).FzName = zName + zName = uintptr(0) + (*TTrigger)(unsafe.Pointer(pTrigger)).Ftable = _sqlite3DbStrDup(tls, db, (*(*TSrcItem)(unsafe.Pointer(pTableName + 8))).FzName) + (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + (*TTrigger)(unsafe.Pointer(pTrigger)).Fop = libc.Uint8FromInt32(op) + if tr_tm == int32(TK_BEFORE) { + v4 = int32(TRIGGER_BEFORE) + } else { + v4 = int32(TRIGGER_AFTER) + } + (*TTrigger)(unsafe.Pointer(pTrigger)).Ftr_tm = libc.Uint8FromInt32(v4) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, (*TTrigger)(unsafe.Pointer(pTrigger)).Ftable, (*(*TSrcItem)(unsafe.Pointer(pTableName + 8))).FzName) + (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen = pWhen + pWhen = uintptr(0) + } else { + (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen = _sqlite3ExprDup(tls, db, pWhen, int32(EXPRDUP_REDUCE)) + } + (*TTrigger)(unsafe.Pointer(pTrigger)).FpColumns = pColumns + pColumns = uintptr(0) + (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger = pTrigger + goto trigger_cleanup +trigger_cleanup: + ; + _sqlite3DbFree(tls, db, zName) + _sqlite3SrcListDelete(tls, db, pTableName) + _sqlite3IdListDelete(tls, db, pColumns) + _sqlite3ExprDelete(tls, db, pWhen) + if !((*TParse)(unsafe.Pointer(pParse)).FpNewTrigger != 0) { + _sqlite3DeleteTrigger(tls, db, pTrigger) + } else { + } + return + goto trigger_orphan_error +trigger_orphan_error: + ; + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) == int32(1) { + /* Ticket #3810. + ** Normally, whenever a table is dropped, all associated triggers are + ** dropped too. But if a TEMP trigger is created on a non-TEMP table + ** and the table is dropped by a different database connection, the + ** trigger is not visible to the database connection that does the + ** drop so the trigger cannot be dropped. This results in an + ** "orphaned trigger" - a trigger whose associated table is missing. + ** + ** 2020-11-05 see also https://sqlite.org/forum/forumpost/157dc791df + */ + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(1), 0, 0x1) + } + goto trigger_cleanup +} + +// C documentation +// +// /* +// ** Clear the i-th bit. +// ** +// ** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage +// ** that BitvecClear can use to rebuilt its hash table. +// */ +func _sqlite3BitvecClear(tls *libc.TLS, p uintptr, i Tu32, pBuf uintptr) { + var aiValues, v1 uintptr + var bin, h Tu32 + var j uint32 + _, _, _, _, _ = aiValues, bin, h, j, v1 + if p == uintptr(0) { + return + } + i = i - 1 + for (*TBitvec)(unsafe.Pointer(p)).FiDivisor != 0 { + bin = i / (*TBitvec)(unsafe.Pointer(p)).FiDivisor + i = i % (*TBitvec)(unsafe.Pointer(p)).FiDivisor + p = **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) + if !(p != 0) { + return + } + } + if uint64((*TBitvec)(unsafe.Pointer(p)).FiSize) <= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) { + v1 = p + 16 + uintptr(i/uint32(BITVEC_SZELEM)) + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromUint8(libc.Uint8FromInt32(libc.Int32FromInt32(1)<<(i&libc.Uint32FromInt32(libc.Int32FromInt32(BITVEC_SZELEM)-libc.Int32FromInt32(1)))))) + } else { + aiValues = pBuf + libc.X__builtin___memcpy_chk(tls, aiValues, p+16, uint64(496), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, p+16, 0, uint64(496), ^t__predefined_size_t(0)) + (*TBitvec)(unsafe.Pointer(p)).FnSet = uint32(0) + j = uint32(0) + for { + if !(uint64(j) < (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)) { + break + } + if **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4)) != 0 && **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4)) != i+uint32(1) { + h = uint32(uint64((**(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4))-libc.Uint32FromInt32(1))*libc.Uint32FromInt32(1)) % ((libc.Uint64FromInt32(BITVEC_SZ) - libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4)) / libc.Uint64FromInt64(8) * libc.Uint64FromInt64(8) / libc.Uint64FromInt64(4))) + (*TBitvec)(unsafe.Pointer(p)).FnSet = (*TBitvec)(unsafe.Pointer(p)).FnSet + 1 + for **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) != 0 { + h = h + 1 + if uint64(h) >= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4) { + h = uint32(0) + } + } + **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) = **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4)) + } + goto _2 + _2: + ; + j = j + 1 + } + } +} + +// C documentation +// +// /* +// ** Set the i-th bit. Return 0 on success and an error code if +// ** anything goes wrong. +// ** +// ** This routine might cause sub-bitmaps to be allocated. Failing +// ** to get the memory needed to hold the sub-bitmap is the only +// ** that can go wrong with an insert, assuming p and i are valid. +// ** +// ** The calling function must ensure that p is a valid Bitvec object +// ** and that the value for "i" is within range of the Bitvec object. +// ** Otherwise the behavior is undefined. +// */ +func _sqlite3BitvecSet(tls *libc.TLS, p uintptr, i Tu32) (r int32) { + var aiValues, v1 uintptr + var bin, h, v2 Tu32 + var j uint32 + var rc int32 + _, _, _, _, _, _, _ = aiValues, bin, h, j, rc, v1, v2 + if p == uintptr(0) { + return SQLITE_OK + } + i = i - 1 + for uint64((*TBitvec)(unsafe.Pointer(p)).FiSize) > (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) && (*TBitvec)(unsafe.Pointer(p)).FiDivisor != 0 { + bin = i / (*TBitvec)(unsafe.Pointer(p)).FiDivisor + i = i % (*TBitvec)(unsafe.Pointer(p)).FiDivisor + if **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) == uintptr(0) { + **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) = _sqlite3BitvecCreate(tls, (*TBitvec)(unsafe.Pointer(p)).FiDivisor) + if **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) == uintptr(0) { + return int32(SQLITE_NOMEM) + } + } + p = **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) + } + if uint64((*TBitvec)(unsafe.Pointer(p)).FiSize) <= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) { + v1 = p + 16 + uintptr(i/uint32(BITVEC_SZELEM)) + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(1)<<(i&libc.Uint32FromInt32(libc.Int32FromInt32(BITVEC_SZELEM)-libc.Int32FromInt32(1)))) + return SQLITE_OK + } + v2 = i + i = i + 1 + h = uint32(uint64(v2*libc.Uint32FromInt32(1)) % ((libc.Uint64FromInt32(BITVEC_SZ) - libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4)) / libc.Uint64FromInt64(8) * libc.Uint64FromInt64(8) / libc.Uint64FromInt64(4))) + /* if there wasn't a hash collision, and this doesn't */ + /* completely fill the hash, then just add it without */ + /* worrying about sub-dividing and re-hashing. */ + if !(**(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) != 0) { + if uint64((*TBitvec)(unsafe.Pointer(p)).FnSet) < (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)-libc.Uint64FromInt32(1) { + goto bitvec_set_end + } else { + goto bitvec_set_rehash + } + } + /* there was a collision, check to see if it's already */ + /* in hash, if not, try to find a spot for it */ + for cond := true; cond; cond = **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) != 0 { + if **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) == i { + return SQLITE_OK + } + h = h + 1 + if uint64(h) >= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4) { + h = uint32(0) + } + } + /* we didn't find it in the hash. h points to the first */ + /* available free spot. check to see if this is going to */ + /* make our hash too "full". */ + goto bitvec_set_rehash +bitvec_set_rehash: + ; + if uint64((*TBitvec)(unsafe.Pointer(p)).FnSet) >= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)/libc.Uint64FromInt32(2) { + aiValues = _sqlite3DbMallocRaw(tls, uintptr(0), uint64(496)) + if aiValues == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memcpy_chk(tls, aiValues, p+16, uint64(496), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, p+16, 0, uint64(496), ^t__predefined_size_t(0)) + (*TBitvec)(unsafe.Pointer(p)).FiDivisor = (*TBitvec)(unsafe.Pointer(p)).FiSize / uint32((libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(8)) + if (*TBitvec)(unsafe.Pointer(p)).FiSize%uint32((libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(8)) != uint32(0) { + (*TBitvec)(unsafe.Pointer(p)).FiDivisor = (*TBitvec)(unsafe.Pointer(p)).FiDivisor + 1 + } + if uint64((*TBitvec)(unsafe.Pointer(p)).FiDivisor) < (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) { + (*TBitvec)(unsafe.Pointer(p)).FiDivisor = uint32((libc.Uint64FromInt32(BITVEC_SZ) - libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4)) / libc.Uint64FromInt64(8) * libc.Uint64FromInt64(8) / libc.Uint64FromInt64(1) * libc.Uint64FromInt32(BITVEC_SZELEM)) + } + rc = _sqlite3BitvecSet(tls, p, i) + j = uint32(0) + for { + if !(uint64(j) < (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)) { + break + } + if **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4)) != 0 { + rc = rc | _sqlite3BitvecSet(tls, p, **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4))) + } + goto _3 + _3: + ; + j = j + 1 + } + _sqlite3DbFree(tls, uintptr(0), aiValues) + return rc + } + } + goto bitvec_set_end +bitvec_set_end: + ; + (*TBitvec)(unsafe.Pointer(p)).FnSet = (*TBitvec)(unsafe.Pointer(p)).FnSet + 1 + **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) = i + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Copy the complete content of pBtFrom into pBtTo. A transaction +// ** must be active for both files. +// ** +// ** The size of file pTo may be reduced by this operation. If anything +// ** goes wrong, the transaction on pTo is rolled back. If successful, the +// ** transaction is committed before returning. +// */ +func _sqlite3BtreeCopyFile(tls *libc.TLS, pTo uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var pFd, v1 uintptr + var rc int32 + var _ /* b at bp+0 */ Tsqlite3_backup + var _ /* nByte at bp+72 */ Ti64 + _, _, _ = pFd, rc, v1 + _sqlite3BtreeEnter(tls, pTo) + _sqlite3BtreeEnter(tls, pFrom) + pFd = _sqlite3PagerFile(tls, _sqlite3BtreePager(tls, pTo)) + if (*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods != 0 { + **(**Ti64)(__ccgo_up(bp + 72)) = int64(_sqlite3BtreeGetPageSize(tls, pFrom)) * libc.Int64FromUint32(_sqlite3BtreeLastPage(tls, pFrom)) + rc = _sqlite3OsFileControl(tls, pFd, int32(SQLITE_FCNTL_OVERWRITE), bp+72) + if rc == int32(SQLITE_NOTFOUND) { + rc = SQLITE_OK + } + if rc != 0 { + goto copy_finished + } + } + /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set + ** to 0. This is used by the implementations of sqlite3_backup_step() + ** and sqlite3_backup_finish() to detect that they are being called + ** from this function, not directly by the user. + */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**Tsqlite3_backup)(__ccgo_up(bp))).FpSrcDb = (*TBtree)(unsafe.Pointer(pFrom)).Fdb + (**(**Tsqlite3_backup)(__ccgo_up(bp))).FpSrc = pFrom + (**(**Tsqlite3_backup)(__ccgo_up(bp))).FpDest = pTo + (**(**Tsqlite3_backup)(__ccgo_up(bp))).FiNext = uint32(1) + /* 0x7FFFFFFF is the hard limit for the number of pages in a database + ** file. By passing this as the number of pages to copy to + ** sqlite3_backup_step(), we can guarantee that the copy finishes + ** within a single call (unless an error occurs). The assert() statement + ** checks this assumption - (p->rc) should be set to either SQLITE_DONE + ** or an error code. */ + Xsqlite3_backup_step(tls, bp, int32(0x7FFFFFFF)) + rc = Xsqlite3_backup_finish(tls, bp) + if rc == SQLITE_OK { + v1 = (*TBtree)(unsafe.Pointer(pTo)).FpBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + } else { + _sqlite3PagerClearCache(tls, _sqlite3BtreePager(tls, (**(**Tsqlite3_backup)(__ccgo_up(bp))).FpDest)) + } + goto copy_finished +copy_finished: + ; + _sqlite3BtreeLeave(tls, pFrom) + _sqlite3BtreeLeave(tls, pTo) + return rc +} + +/************** End of backup.c **********************************************/ +/************** Begin file vdbemem.c *****************************************/ +/* +** 2004 May 26 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code use to manipulate "Mem" structure. A "Mem" +** stores a single value in the VDBE. Mem is an opaque structure visible +** only within the VDBE. Interface routines refer to a Mem using the +** name sqlite_value + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +/* True if X is a power of two. 0 is considered a power of two here. +** In other words, return true if X has at most one bit set. + */ + +// C documentation +// +// /* +// ** Initialize memory that will be converted into a BtCursor object. +// ** +// ** The simple approach here would be to memset() the entire object +// ** to zero. But it turns out that the apPage[] and aiIdx[] arrays +// ** do not need to be zeroed and they are large, so we can save a lot +// ** of run-time by skipping the initialization of those elements. +// */ +func _sqlite3BtreeCursorZero(tls *libc.TLS, p uintptr) { + libc.X__builtin___memset_chk(tls, p, 0, uint64(libc.UintptrFromInt32(0)+32), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* Move the cursor so that it points to an entry in an index table +// ** near the key pIdxKey. Return a success code. +// ** +// ** If an exact match is not found, then the cursor is always +// ** left pointing at a leaf page which would hold the entry if it +// ** were present. The cursor might point to an entry that comes +// ** before or after the key. +// ** +// ** An integer is written into *pRes which is the result of +// ** comparing the key with the entry to which the cursor is +// ** pointing. The meaning of the integer written into +// ** *pRes is as follows: +// ** +// ** *pRes<0 The cursor is left pointing at an entry that +// ** is smaller than pIdxKey or if the table is empty +// ** and the cursor is therefore left point to nothing. +// ** +// ** *pRes==0 The cursor is left pointing at an entry that +// ** exactly matches pIdxKey. +// ** +// ** *pRes>0 The cursor is left pointing at an entry that +// ** is larger than pIdxKey. +// ** +// ** The pIdxKey->eqSeen field is set to 1 if there +// ** exists an entry in the table that exactly matches pIdxKey. +// */ +func _sqlite3BtreeIndexMoveto(tls *libc.TLS, pCur uintptr, pIdxKey uintptr, pRes uintptr) (r int32) { + var c, c1, idx, lwr, nCell, nOverrun, rc, upr, v1 int32 + var chldPg TPgno + var pCell, pCellBody, pCellKey, pPage, v3 uintptr + var xRecordCompare TRecordCompare + var v10 Ti8 + var v2 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, c1, chldPg, idx, lwr, nCell, nOverrun, pCell, pCellBody, pCellKey, pPage, rc, upr, xRecordCompare, v1, v10, v2, v3 + xRecordCompare = _sqlite3VdbeFindCompare(tls, pIdxKey) + (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode = uint8(0) + /* Check to see if we can skip a lot of work. Two cases: + ** + ** (1) If the cursor is already pointing to the very last cell + ** in the table and the pIdxKey search key is greater than or + ** equal to that last cell, then no movement is required. + ** + ** (2) If the cursor is on the last page of the table and the first + ** cell on that last page is less than or equal to the pIdxKey + ** search key, then we can start the search on the current page + ** without needing to go back to root. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID && (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf != 0 && _cursorOnLastPage(tls, pCur) != 0 { + if v2 = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) == libc.Int32FromUint16((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell)-int32(1); v2 { + v1 = _indexCellCompare(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage, libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix), pIdxKey, xRecordCompare) + c = v1 + } + if v2 && v1 <= 0 && libc.Int32FromUint8((*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode) == SQLITE_OK { + **(**int32)(__ccgo_up(pRes)) = c + return SQLITE_OK /* Cursor already pointing at the correct spot */ + } + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) > 0 && _indexCellCompare(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage, 0, pIdxKey, xRecordCompare) <= 0 && libc.Int32FromUint8((*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode) == SQLITE_OK { + v3 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(BTCF_ValidOvfl) | libc.Int32FromInt32(BTCF_AtLast))) + if !((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FisInit != 0) { + return _sqlite3CorruptError(tls, int32(79227)) + } + goto bypass_moveto_root /* Start search on the current page */ + } + (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode = uint8(SQLITE_OK) + } + rc = _moveToRoot(tls, pCur) + if rc != 0 { + if rc == int32(SQLITE_EMPTY) { + **(**int32)(__ccgo_up(pRes)) = -int32(1) + return SQLITE_OK + } + return rc + } + goto bypass_moveto_root +bypass_moveto_root: + ; + for { + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage /* Pointer to current cell in pPage */ + /* pPage->nCell must be greater than zero. If this is the root-page + ** the cursor would have been INVALID above and this for(;;) loop + ** not run. If this is not the root-page, then the moveToChild() routine + ** would have already detected db corruption. Similarly, pPage must + ** be the right kind (index or table) of b-tree page. Otherwise + ** a moveToChild() or moveToRoot() call would have detected corruption. */ + lwr = 0 + upr = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) - int32(1) + idx = upr >> int32(1) /* idx = (lwr+upr)/2; */ + for { /* Size of the pCell cell in bytes */ + pCell = (*TMemPage)(unsafe.Pointer(pPage)).FaDataOfst + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*idx))))< (*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBt)).FnPage { + rc = _sqlite3CorruptError(tls, int32(79314)) + goto moveto_index_finish + } + pCellKey = _sqlite3Malloc(tls, libc.Uint64FromInt32(nCell)+libc.Uint64FromInt32(nOverrun)) + if pCellKey == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto moveto_index_finish + } + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(idx) + rc = _accessPayload(tls, pCur, uint32(0), libc.Uint32FromInt32(nCell), pCellKey, 0) + libc.X__builtin___memset_chk(tls, pCellKey+uintptr(nCell), 0, libc.Uint64FromInt32(nOverrun), ^t__predefined_size_t(0)) /* Fix uninit warnings */ + v3 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & ^libc.Int32FromInt32(BTCF_ValidOvfl)) + if rc != 0 { + Xsqlite3_free(tls, pCellKey) + goto moveto_index_finish + } + c1 = _sqlite3VdbeRecordCompare(tls, nCell, pCellKey, pIdxKey) + Xsqlite3_free(tls, pCellKey) + } + } + if c1 < 0 { + lwr = idx + int32(1) + } else { + if c1 > 0 { + upr = idx - int32(1) + } else { + **(**int32)(__ccgo_up(pRes)) = 0 + rc = SQLITE_OK + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(idx) + if (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode != 0 { + rc = _sqlite3CorruptError(tls, int32(79346)) + } + goto moveto_index_finish + } + } + if lwr > upr { + break + } + idx = (lwr + upr) >> int32(1) /* idx = (lwr+upr)/2 */ + goto _5 + _5: + } + if (*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(idx) + **(**int32)(__ccgo_up(pRes)) = c1 + rc = SQLITE_OK + goto moveto_index_finish + } + if lwr >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + chldPg = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(8))) + } else { + chldPg = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*lwr))))<ix = (u16)lwr; + ** rc = moveToChild(pCur, chldPg); + ** if( rc ) break; + */ + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + v3 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) >= libc.Int32FromInt32(BTCURSOR_MAX_DEPTH)-libc.Int32FromInt32(1) { + return _sqlite3CorruptError(tls, int32(79377)) + } + **(**Tu16)(__ccgo_up(pCur + 88 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*2)) = libc.Uint16FromInt32(lwr) + **(**uintptr)(__ccgo_up(pCur + 144 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*8)) = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = uint16(0) + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = (*TBtCursor)(unsafe.Pointer(pCur)).FiPage + 1 + rc = _getAndInitPage(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBt, chldPg, pCur+136, libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags)) + if rc == SQLITE_OK && (libc.Int32FromUint16((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell) < int32(1) || libc.Int32FromUint8((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FintKey) != libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurIntKey)) { + _releasePage(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage) + rc = _sqlite3CorruptError(tls, int32(79388)) + } + if rc != 0 { + v3 = pCur + 84 + *(*Ti8)(unsafe.Pointer(v3)) = *(*Ti8)(unsafe.Pointer(v3)) - 1 + v10 = *(*Ti8)(unsafe.Pointer(v3)) + (*TBtCursor)(unsafe.Pointer(pCur)).FpPage = **(**uintptr)(__ccgo_up(pCur + 144 + uintptr(v10)*8)) + break + } + /* + ***** End of in-lined moveToChild() call */ + goto _4 + _4: + } + goto moveto_index_finish +moveto_index_finish: + ; + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + return rc +} + +// C documentation +// +// /* +// ** Insert a new record into the BTree. The content of the new record +// ** is described by the pX object. The pCur cursor is used only to +// ** define what table the record should be inserted into, and is left +// ** pointing at a random location. +// ** +// ** For a table btree (used for rowid tables), only the pX.nKey value of +// ** the key is used. The pX.pKey value must be NULL. The pX.nKey is the +// ** rowid or INTEGER PRIMARY KEY of the row. The pX.nData,pData,nZero fields +// ** hold the content of the row. +// ** +// ** For an index btree (used for indexes and WITHOUT ROWID tables), the +// ** key is an arbitrary byte sequence stored in pX.pKey,nKey. The +// ** pX.pData,nData,nZero fields must be zero. +// ** +// ** If the seekResult parameter is non-zero, then a successful call to +// ** sqlite3BtreeIndexMoveto() to seek cursor pCur to (pKey,nKey) has already +// ** been performed. In other words, if seekResult!=0 then the cursor +// ** is currently pointing to a cell that will be adjacent to the cell +// ** to be inserted. If seekResult<0 then pCur points to a cell that is +// ** smaller then (pKey,nKey). If seekResult>0 then pCur points to a cell +// ** that is larger than (pKey,nKey). +// ** +// ** If seekResult==0, that means pCur is pointing at some unknown location. +// ** In that case, this routine must seek the cursor to the correct insertion +// ** point for (pKey,nKey) before doing the insertion. For index btrees, +// ** if pX->nMem is non-zero, then pX->aMem contains pointers to the unpacked +// ** key values and pX->aMem can be used instead of pX->pKey to avoid having +// ** to decode the key. +// */ +func _sqlite3BtreeInsert(tls *libc.TLS, pCur uintptr, pX uintptr, flags int32, seekResult int32) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var idx int32 + var newCell, oldCell, p, pPage, v1 uintptr + var ovfl TPgno + var v2 Tu16 + var _ /* info at bp+104 */ TCellInfo + var _ /* info at bp+128 */ TCellInfo + var _ /* loc at bp+4 */ int32 + var _ /* r at bp+16 */ TUnpackedRecord + var _ /* rc at bp+0 */ int32 + var _ /* szNew at bp+8 */ int32 + var _ /* x2 at bp+56 */ TBtreePayload + _, _, _, _, _, _, _, _ = idx, newCell, oldCell, ovfl, p, pPage, v1, v2 + **(**int32)(__ccgo_up(bp + 4)) = seekResult /* -1: before desired location +1: after */ + **(**int32)(__ccgo_up(bp + 8)) = 0 + p = (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree + newCell = uintptr(0) + /* Save the positions of any other cursors open on this table. + ** + ** In some cases, the call to btreeMoveto() below is a no-op. For + ** example, when inserting data into a table with auto-generated integer + ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the + ** integer key to use. It then calls this function to actually insert the + ** data into the intkey B-Tree. In this case btreeMoveto() recognizes + ** that the cursor is already where it needs to be and returns without + ** doing any work. To avoid thwarting these optimizations, it is important + ** not to clear the cursor here. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_Multiple) != 0 { + **(**int32)(__ccgo_up(bp)) = _saveAllCursors(tls, (*TBtree)(unsafe.Pointer(p)).FpBt, (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + if **(**int32)(__ccgo_up(bp + 4)) != 0 && int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) < 0 { + /* This can only happen if the schema is corrupt such that there is more + ** than one table or index with the same root page as used by the cursor. + ** Which can only happen if the SQLITE_NoSchemaError flag was set when + ** the schema was loaded. This cannot be asserted though, as a user might + ** set the flag, load the schema, and then unset the flag. */ + return _sqlite3CorruptError(tls, int32(82581)) + } + } + /* Ensure that the cursor is not in the CURSOR_FAULT state and that it + ** points to a valid cell. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) >= int32(CURSOR_REQUIRESEEK) { + **(**int32)(__ccgo_up(bp)) = _moveToRoot(tls, pCur) + if **(**int32)(__ccgo_up(bp)) != 0 && **(**int32)(__ccgo_up(bp)) != int32(SQLITE_EMPTY) { + return **(**int32)(__ccgo_up(bp)) + } + } + /* Assert that the caller has been consistent. If this cursor was opened + ** expecting an index b-tree, then the caller should be inserting blob + ** keys with no associated data. If the cursor was opened expecting an + ** intkey table, the caller should be inserting integer keys with a + ** blob of associated data. */ + if (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo == uintptr(0) { + /* If this is an insert into a table b-tree, invalidate any incrblob + ** cursors open on the row being replaced */ + if (*TBtree)(unsafe.Pointer(p)).FhasIncrblobCur != 0 { + _invalidateIncrblobCursors(tls, p, (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, (*TBtreePayload)(unsafe.Pointer(pX)).FnKey, 0) + } + /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing + ** to a row with the same key as the new entry being inserted. + */ + /* On the other hand, BTREE_SAVEPOSITION==0 does not imply + ** that the cursor is not pointing to a row to be overwritten. + ** So do a complete check. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_ValidNKey) != 0 && (*TBtreePayload)(unsafe.Pointer(pX)).FnKey == (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey { + /* The cursor is pointing to the entry that is to be + ** overwritten */ + if libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize) != 0 && (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload == libc.Uint32FromInt32((*TBtreePayload)(unsafe.Pointer(pX)).FnData)+libc.Uint32FromInt32((*TBtreePayload)(unsafe.Pointer(pX)).FnZero) { + /* New entry is the same size as the old. Do an overwrite */ + return _btreeOverwriteCell(tls, pCur, pX) + } + } else { + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + /* The cursor is *not* pointing to the cell to be overwritten, nor + ** to an adjacent cell. Move the cursor so that it is pointing either + ** to the cell to be overwritten or an adjacent cell. + */ + **(**int32)(__ccgo_up(bp)) = _sqlite3BtreeTableMoveto(tls, pCur, (*TBtreePayload)(unsafe.Pointer(pX)).FnKey, libc.BoolInt32(flags&int32(BTREE_APPEND) != 0), bp+4) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + } + } else { + /* This is an index or a WITHOUT ROWID table */ + /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing + ** to a row with the same key as the new entry being inserted. + */ + /* If the cursor is not already pointing either to the cell to be + ** overwritten, or if a new cell is being inserted, if the cursor is + ** not pointing to an immediately adjacent cell, then move the cursor + ** so that it does. + */ + if **(**int32)(__ccgo_up(bp + 4)) == 0 && flags&int32(BTREE_SAVEPOSITION) == 0 { + if (*TBtreePayload)(unsafe.Pointer(pX)).FnMem != 0 { + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).FpKeyInfo = (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).FaMem = (*TBtreePayload)(unsafe.Pointer(pX)).FaMem + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).FnField = (*TBtreePayload)(unsafe.Pointer(pX)).FnMem + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).Fdefault_rc = 0 + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).FeqSeen = uint8(0) + **(**int32)(__ccgo_up(bp)) = _sqlite3BtreeIndexMoveto(tls, pCur, bp+16, bp+4) + } else { + **(**int32)(__ccgo_up(bp)) = _btreeMoveto(tls, pCur, (*TBtreePayload)(unsafe.Pointer(pX)).FpKey, (*TBtreePayload)(unsafe.Pointer(pX)).FnKey, libc.BoolInt32(flags&int32(BTREE_APPEND) != 0), bp+4) + } + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + /* If the cursor is currently pointing to an entry to be overwritten + ** and the new content is the same as as the old, then use the + ** overwrite optimization. + */ + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + _getCellInfo(tls, pCur) + if (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == (*TBtreePayload)(unsafe.Pointer(pX)).FnKey { + (**(**TBtreePayload)(__ccgo_up(bp + 56))).FpData = (*TBtreePayload)(unsafe.Pointer(pX)).FpKey + (**(**TBtreePayload)(__ccgo_up(bp + 56))).FnData = int32((*TBtreePayload)(unsafe.Pointer(pX)).FnKey) + (**(**TBtreePayload)(__ccgo_up(bp + 56))).FnZero = 0 + return _btreeOverwriteCell(tls, pCur, bp+56) + } + } + } + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + if (*TMemPage)(unsafe.Pointer(pPage)).FnFree < 0 { + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) > int32(CURSOR_INVALID) { + /* ^^^^^--- due to the moveToRoot() call above */ + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(82704)) + } else { + **(**int32)(__ccgo_up(bp)) = _btreeComputeFreeSpace(tls, pPage) + } + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + newCell = (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpTmpSpace + if flags&int32(BTREE_PREFORMAT) != 0 { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 8)) = (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FnPreformatSize + if **(**int32)(__ccgo_up(bp + 8)) < int32(4) { + **(**int32)(__ccgo_up(bp + 8)) = int32(4) + **(**uint8)(__ccgo_up(newCell + 3)) = uint8(0) + } + if (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FautoVacuum != 0 && **(**int32)(__ccgo_up(bp + 8)) > libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell})))(tls, pPage, newCell, bp+104) + if (**(**TCellInfo)(__ccgo_up(bp + 104))).FnPayload != uint32((**(**TCellInfo)(__ccgo_up(bp + 104))).FnLocal) { + ovfl = _sqlite3Get4byte(tls, newCell+uintptr(**(**int32)(__ccgo_up(bp + 8))-int32(4))) + _ptrmapPut(tls, (*TBtree)(unsafe.Pointer(p)).FpBt, ovfl, uint8(PTRMAP_OVERFLOW1), (*TMemPage)(unsafe.Pointer(pPage)).Fpgno, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto end_insert + } + } + } + } else { + **(**int32)(__ccgo_up(bp)) = _fillInCell(tls, pPage, newCell, pX, bp+8) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto end_insert + } + } + idx = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + if idx >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + return _sqlite3CorruptError(tls, int32(82746)) + } + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto end_insert + } + oldCell = (*TMemPage)(unsafe.Pointer(pPage)).FaData + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*idx))))< (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd { + return _sqlite3CorruptError(tls, int32(82776)) + } + libc.X__builtin___memcpy_chk(tls, oldCell, newCell, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 8))), ^t__predefined_size_t(0)) + return SQLITE_OK + } + _dropCell(tls, pPage, idx, libc.Int32FromUint16((**(**TCellInfo)(__ccgo_up(bp + 128))).FnSize), bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto end_insert + } + } else { + if **(**int32)(__ccgo_up(bp + 4)) < 0 && libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) > 0 { + v1 = pCur + 86 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v2 = *(*Tu16)(unsafe.Pointer(v1)) + idx = libc.Int32FromUint16(v2) + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + } else { + } + } + **(**int32)(__ccgo_up(bp)) = _insertCellFast(tls, pPage, idx, newCell, **(**int32)(__ccgo_up(bp + 8))) + /* If no error has occurred and pPage has an overflow cell, call balance() + ** to redistribute the cells within the tree. Since balance() may move + ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey + ** variables. + ** + ** Previous versions of SQLite called moveToRoot() to move the cursor + ** back to the root page as balance() used to invalidate the contents + ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that, + ** set the cursor state to "invalid". This makes common insert operations + ** slightly faster. + ** + ** There is a subtle but important optimization here too. When inserting + ** multiple records into an intkey b-tree using a single cursor (as can + ** happen while processing an "INSERT INTO ... SELECT" statement), it + ** is advantageous to leave the cursor pointing to the last entry in + ** the b-tree if possible. If the cursor is left pointing to the last + ** entry in the table, and the next row inserted has an integer key + ** larger than the largest existing key, it is possible to insert the + ** row without seeking the cursor. This can be a big performance boost. + */ + if (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow != 0 { + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + **(**int32)(__ccgo_up(bp)) = _balance(tls, pCur) + /* Must make sure nOverflow is reset to zero even if the balance() + ** fails. Internal data structure corruption will result otherwise. + ** Also, set the cursor state to invalid. This stops saveCursorPosition() + ** from trying to save the current position of the cursor. */ + (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnOverflow = uint8(0) + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID) + if flags&int32(BTREE_SAVEPOSITION) != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + _btreeReleaseAllCursorPages(tls, pCur) + if (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo != 0 { + (*TBtCursor)(unsafe.Pointer(pCur)).FpKey = _sqlite3Malloc(tls, libc.Uint64FromInt64((*TBtreePayload)(unsafe.Pointer(pX)).FnKey)) + if (*TBtCursor)(unsafe.Pointer(pCur)).FpKey == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memcpy_chk(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpKey, (*TBtreePayload)(unsafe.Pointer(pX)).FpKey, libc.Uint64FromInt64((*TBtreePayload)(unsafe.Pointer(pX)).FnKey), ^t__predefined_size_t(0)) + } + } + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_REQUIRESEEK) + (*TBtCursor)(unsafe.Pointer(pCur)).FnKey = (*TBtreePayload)(unsafe.Pointer(pX)).FnKey + } + } + goto end_insert +end_insert: + ; + return **(**int32)(__ccgo_up(bp)) + return r +} + +// C documentation +// +// /* +// ** This routine does a complete check of the given BTree file. aRoot[] is +// ** an array of pages numbers were each page number is the root page of +// ** a table. nRoot is the number of entries in aRoot. +// ** +// ** A read-only or read-write transaction must be opened before calling +// ** this function. +// ** +// ** Write the number of error seen in *pnErr. Except for some memory +// ** allocation errors, an error message held in memory obtained from +// ** malloc is returned if *pnErr is non-zero. If *pnErr==0 then NULL is +// ** returned. If a memory allocation error occurs, NULL is returned. +// ** +// ** If the first entry in aRoot[] is 0, that indicates that the list of +// ** root pages is incomplete. This is a "partial integrity-check". This +// ** happens when performing an integrity check on a single table. The +// ** zero is skipped, of course. But in addition, the freelist checks +// ** and the checks to make sure every page is referenced are also skipped, +// ** since obviously it is not possible to know which pages are covered by +// ** the unverified btrees. Except, if aRoot[1] is 1, then the freelist +// ** checks are still performed. +// */ +func _sqlite3BtreeIntegrityCheck(tls *libc.TLS, db uintptr, p uintptr, aRoot uintptr, aCnt uintptr, nRoot int32, mxErr int32, pnErr uintptr, pzOut uintptr) (r int32) { + bp := tls.Alloc(272) + defer tls.Free(272) + var bCkFreelist, bPartial int32 + var i, mx, mxInHdr TPgno + var pBt uintptr + var savedDbFlags Tu64 + var _ /* notUsed at bp+232 */ Ti64 + var _ /* sCheck at bp+0 */ TIntegrityCk + var _ /* zErr at bp+128 */ [100]int8 + _, _, _, _, _, _, _ = bCkFreelist, bPartial, i, mx, mxInHdr, pBt, savedDbFlags + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + savedDbFlags = (*Tsqlite3)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags + bPartial = 0 /* True if not checking all btrees */ + bCkFreelist = int32(1) /* True to scan the freelist */ + /* aRoot[0]==0 means this is a partial check */ + if **(**TPgno)(__ccgo_up(aRoot)) == uint32(0) { + bPartial = int32(1) + if **(**TPgno)(__ccgo_up(aRoot + 1*4)) != uint32(1) { + bCkFreelist = 0 + } + } + _sqlite3BtreeEnter(tls, p) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(128), ^t__predefined_size_t(0)) + (**(**TIntegrityCk)(__ccgo_up(bp))).Fdb = db + (**(**TIntegrityCk)(__ccgo_up(bp))).FpBt = pBt + (**(**TIntegrityCk)(__ccgo_up(bp))).FpPager = (*TBtShared)(unsafe.Pointer(pBt)).FpPager + (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage = _btreePagecount(tls, (**(**TIntegrityCk)(__ccgo_up(bp))).FpBt) + (**(**TIntegrityCk)(__ccgo_up(bp))).FmxErr = mxErr + _sqlite3StrAccumInit(tls, bp+72, uintptr(0), bp+128, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TIntegrityCk)(__ccgo_up(bp))).FerrMsg.FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + if (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage == uint32(0) { + goto integrity_ck_cleanup + } + (**(**TIntegrityCk)(__ccgo_up(bp))).FaPgRef = _sqlite3MallocZero(tls, uint64((**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage/uint32(8)+uint32(1))) + if !((**(**TIntegrityCk)(__ccgo_up(bp))).FaPgRef != 0) { + _checkOom(tls, bp) + goto integrity_ck_cleanup + } + (**(**TIntegrityCk)(__ccgo_up(bp))).Fheap = _sqlite3PageMalloc(tls, libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FpageSize)) + if (**(**TIntegrityCk)(__ccgo_up(bp))).Fheap == uintptr(0) { + _checkOom(tls, bp) + goto integrity_ck_cleanup + } + i = libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize + libc.Uint32FromInt32(1) + if i <= (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage { + _setPageReferenced(tls, bp, i) + } + /* Check the integrity of the freelist + */ + if bCkFreelist != 0 { + (**(**TIntegrityCk)(__ccgo_up(bp))).FzPfx = __ccgo_ts + 5306 + _checkList(tls, bp, int32(1), _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+32), _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36)) + (**(**TIntegrityCk)(__ccgo_up(bp))).FzPfx = uintptr(0) + } + /* Check all the tables. + */ + if !(bPartial != 0) { + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + mx = uint32(0) + i = uint32(0) + for { + if !(libc.Int32FromUint32(i) < nRoot) { + break + } + if mx < **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) { + mx = **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) + } + goto _1 + _1: + ; + i = i + 1 + } + mxInHdr = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+52) + if mx != mxInHdr { + _checkAppendMsg(tls, bp, __ccgo_ts+5317, libc.VaList(bp+248, mx, mxInHdr)) + } + } else { + if _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+64) != uint32(0) { + _checkAppendMsg(tls, bp, __ccgo_ts+5362, 0) + } + } + } + **(**Tu64)(__ccgo_up((*TBtShared)(unsafe.Pointer(pBt)).Fdb + 48)) &= ^libc.Uint64FromInt32(SQLITE_CellSizeCk) + i = uint32(0) + for { + if !(libc.Int32FromUint32(i) < nRoot && (**(**TIntegrityCk)(__ccgo_up(bp))).FmxErr != 0) { + break + } + (**(**TIntegrityCk)(__ccgo_up(bp))).FnRow = 0 + if **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) != 0 { + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) > uint32(1) && !(bPartial != 0) { + _checkPtrmap(tls, bp, **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)), uint8(PTRMAP_ROOTPAGE), uint32(0)) + } + (**(**TIntegrityCk)(__ccgo_up(bp))).Fv0 = **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) + _checkTreePage(tls, bp, **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)), bp+232, libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< nFilename { + v1 = nFullPathname + } else { + v1 = nFilename + } + zFullPathname = _sqlite3Malloc(tls, libc.Uint64FromInt32(v1)) + (*TBtree)(unsafe.Pointer(p)).Fsharable = uint8(1) + if !(zFullPathname != 0) { + Xsqlite3_free(tls, p) + return int32(SQLITE_NOMEM) + } + if isMemdb != 0 { + libc.X__builtin___memcpy_chk(tls, zFullPathname, zFilename, libc.Uint64FromInt32(nFilename), ^t__predefined_size_t(0)) + } else { + rc = _sqlite3OsFullPathname(tls, pVfs, zFilename, nFullPathname, zFullPathname) + if rc != 0 { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(2)<= 0) { + break + } + pExisting = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if pExisting != 0 && (*TBtree)(unsafe.Pointer(pExisting)).FpBt == pBt { + Xsqlite3_mutex_leave(tls, mutexShared) + Xsqlite3_mutex_leave(tls, mutexOpen) + Xsqlite3_free(tls, zFullPathname) + Xsqlite3_free(tls, p) + return int32(SQLITE_CONSTRAINT) + } + goto _3 + _3: + ; + iDb = iDb - 1 + } + (*TBtree)(unsafe.Pointer(p)).FpBt = pBt + (*TBtShared)(unsafe.Pointer(pBt)).FnRef = (*TBtShared)(unsafe.Pointer(pBt)).FnRef + 1 + break + } + goto _2 + _2: + ; + pBt = (*TBtShared)(unsafe.Pointer(pBt)).FpNext + } + Xsqlite3_mutex_leave(tls, mutexShared) + Xsqlite3_free(tls, zFullPathname) + } + } + if pBt == uintptr(0) { + /* + ** The following asserts make sure that structures used by the btree are + ** the right size. This is to guard against size changes that result + ** when compiling on a different architecture. + */ + /* Suppress false-positive compiler warning from PVS-Studio */ + libc.X__builtin___memset_chk(tls, bp+16, 0, uint64(8), ^t__predefined_size_t(0)) + pBt = _sqlite3MallocZero(tls, uint64(152)) + if pBt == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto btree_open_out + } + rc = _sqlite3PagerOpen(tls, pVfs, pBt, zFilename, int32(136), flags, vfsFlags, __ccgo_fp(_pageReinit)) + if rc == SQLITE_OK { + _sqlite3PagerSetMmapLimit(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, (*Tsqlite3)(unsafe.Pointer(db)).FszMmap) + rc = _sqlite3PagerReadFileheader(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, int32(100), bp) + } + if rc != SQLITE_OK { + goto btree_open_out + } + (*TBtShared)(unsafe.Pointer(pBt)).FopenFlags = libc.Uint8FromInt32(flags) + (*TBtShared)(unsafe.Pointer(pBt)).Fdb = db + _sqlite3PagerSetBusyHandler(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, __ccgo_fp(_btreeInvokeBusyHandler), pBt) + (*TBtree)(unsafe.Pointer(p)).FpBt = pBt + (*TBtShared)(unsafe.Pointer(pBt)).FpCursor = uintptr(0) + (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0) + if _sqlite3PagerIsreadonly(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) != 0 { + v4 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(BTS_READ_ONLY)) + } + /* EVIDENCE-OF: R-51873-39618 The page size for a database file is + ** determined by the 2-byte integer located at an offset of 16 bytes from + ** the beginning of the database file. */ + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = libc.Uint32FromInt32(libc.Int32FromUint8((**(**[100]uint8)(__ccgo_up(bp)))[int32(16)])< uint32(SQLITE_MAX_PAGE_SIZE) || ((*TBtShared)(unsafe.Pointer(pBt)).FpageSize-uint32(1))&(*TBtShared)(unsafe.Pointer(pBt)).FpageSize != uint32(0) { + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = uint32(0) + /* If the magic name ":memory:" will create an in-memory database, then + ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if + ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if + ** SQLITE_OMIT_MEMORYDB has been defined, then ":memory:" is just a + ** regular file-name. In this case the auto-vacuum applies as per normal. + */ + if zFilename != 0 && !(isMemdb != 0) { + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(libc.Int32FromInt32(0)) + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(libc.Int32FromInt32(0)) + } + nReserve = uint8(0) + } else { + /* EVIDENCE-OF: R-37497-42412 The size of the reserved region is + ** determined by the one-byte unsigned integer found at an offset of 20 + ** into the database file header. */ + nReserve = (**(**[100]uint8)(__ccgo_up(bp)))[int32(20)] + v4 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + if _sqlite3Get4byte(tls, bp+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(4)*libc.Int32FromInt32(4))) != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(v1) + if _sqlite3Get4byte(tls, bp+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(7)*libc.Int32FromInt32(4))) != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(v1) + } + rc = _sqlite3PagerSetPagesize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pBt+52, libc.Int32FromUint8(nReserve)) + if rc != 0 { + goto btree_open_out + } + (*TBtShared)(unsafe.Pointer(pBt)).FusableSize = (*TBtShared)(unsafe.Pointer(pBt)).FpageSize - uint32(nReserve) + /* 8-byte alignment of pageSize */ + /* Add the new BtShared object to the linked list sharable BtShareds. + */ + (*TBtShared)(unsafe.Pointer(pBt)).FnRef = int32(1) + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + mutexShared1 = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + if libc.Bool(int32(SQLITE_THREADSAFE) != 0) && _sqlite3Config.FbCoreMutex != 0 { + (*TBtShared)(unsafe.Pointer(pBt)).Fmutex = _sqlite3MutexAlloc(tls, SQLITE_MUTEX_FAST) + if (*TBtShared)(unsafe.Pointer(pBt)).Fmutex == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto btree_open_out + } + } + Xsqlite3_mutex_enter(tls, mutexShared1) + (*TBtShared)(unsafe.Pointer(pBt)).FpNext = _sqlite3SharedCacheList + _sqlite3SharedCacheList = pBt + Xsqlite3_mutex_leave(tls, mutexShared1) + } + } + /* If the new Btree uses a sharable pBtShared, then link the new + ** Btree into the list of all sharable Btrees for the same connection. + ** The list is kept in ascending order by pBt address. + */ + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + v4 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + pSib = v4 + if v4 != uintptr(0) && (*TBtree)(unsafe.Pointer(pSib)).Fsharable != 0 { + for (*TBtree)(unsafe.Pointer(pSib)).FpPrev != 0 { + pSib = (*TBtree)(unsafe.Pointer(pSib)).FpPrev + } + if uint64((*TBtree)(unsafe.Pointer(p)).FpBt) < uint64((*TBtree)(unsafe.Pointer(pSib)).FpBt) { + (*TBtree)(unsafe.Pointer(p)).FpNext = pSib + (*TBtree)(unsafe.Pointer(p)).FpPrev = uintptr(0) + (*TBtree)(unsafe.Pointer(pSib)).FpPrev = p + } else { + for (*TBtree)(unsafe.Pointer(pSib)).FpNext != 0 && uint64((*TBtree)(unsafe.Pointer((*TBtree)(unsafe.Pointer(pSib)).FpNext)).FpBt) < uint64((*TBtree)(unsafe.Pointer(p)).FpBt) { + pSib = (*TBtree)(unsafe.Pointer(pSib)).FpNext + } + (*TBtree)(unsafe.Pointer(p)).FpNext = (*TBtree)(unsafe.Pointer(pSib)).FpNext + (*TBtree)(unsafe.Pointer(p)).FpPrev = pSib + if (*TBtree)(unsafe.Pointer(p)).FpNext != 0 { + (*TBtree)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpNext)).FpPrev = p + } + (*TBtree)(unsafe.Pointer(pSib)).FpNext = p + } + break + } + goto _8 + _8: + ; + i = i + 1 + } + } + **(**uintptr)(__ccgo_up(ppBtree)) = p + goto btree_open_out +btree_open_out: + ; + if rc != SQLITE_OK { + if pBt != 0 && (*TBtShared)(unsafe.Pointer(pBt)).FpPager != 0 { + _sqlite3PagerClose(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, uintptr(0)) + } + Xsqlite3_free(tls, pBt) + Xsqlite3_free(tls, p) + **(**uintptr)(__ccgo_up(ppBtree)) = uintptr(0) + } else { + /* If the B-Tree was successfully opened, set the pager-cache size to the + ** default value. Except, when opening on an existing shared pager-cache, + ** do not change the pager-cache size. + */ + if _sqlite3BtreeSchema(tls, p, 0, uintptr(0)) == uintptr(0) { + _sqlite3BtreeSetCacheSize(tls, p, -int32(2000)) + } + pFile = _sqlite3PagerFile(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + if (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods != 0 { + _sqlite3OsFileControlHint(tls, pFile, int32(SQLITE_FCNTL_PDB), pBt+8) + } + } + if mutexOpen != 0 { + Xsqlite3_mutex_leave(tls, mutexOpen) + } + return rc +} + +// C documentation +// +// /* +// ** This function is used as part of copying the current row from cursor +// ** pSrc into cursor pDest. If the cursors are open on intkey tables, then +// ** parameter iKey is used as the rowid value when the record is copied +// ** into pDest. Otherwise, the record is copied verbatim. +// ** +// ** This function does not actually write the new value to cursor pDest. +// ** Instead, it creates and populates any required overflow pages and +// ** writes the data for the new cell into the BtShared.pTmpSpace buffer +// ** for the destination database. The size of the cell, in bytes, is left +// ** in BtShared.nPreformatSize. The caller completes the insertion by +// ** calling sqlite3BtreeInsert() with the BTREE_PREFORMAT flag specified. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +// */ +func _sqlite3BtreeTransferRow(tls *libc.TLS, pDest uintptr, pSrc uintptr, iKey Ti64) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aIn, aOut, pBt, pPageOut, pPgnoOut, pSrcPager, v1 uintptr + var nCopy int32 + var nIn, nOut, nRem Tu32 + var ovflIn TPgno + var v2 uint32 + var _ /* pNew at bp+24 */ uintptr + var _ /* pPageIn at bp+8 */ uintptr + var _ /* pgnoNew at bp+16 */ TPgno + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = aIn, aOut, nCopy, nIn, nOut, nRem, ovflIn, pBt, pPageOut, pPgnoOut, pSrcPager, v1, v2 + pBt = (*TBtCursor)(unsafe.Pointer(pDest)).FpBt + aOut = (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace /* Bytes of data still to copy */ + _getCellInfo(tls, pSrc) + if (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload < uint32(0x80) { + v1 = aOut + aOut = aOut + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8((*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload) + } else { + aOut = aOut + uintptr(_sqlite3PutVarint(tls, aOut, uint64((*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload))) + } + if (*TBtCursor)(unsafe.Pointer(pDest)).FpKeyInfo == uintptr(0) { + aOut = aOut + uintptr(_sqlite3PutVarint(tls, aOut, libc.Uint64FromInt64(iKey))) + } + nIn = uint32((*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnLocal) + aIn = (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FpPayload + if aIn+uintptr(nIn) > (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pSrc)).FpPage)).FaDataEnd { + return _sqlite3CorruptError(tls, int32(82878)) + } + nRem = (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload + if nIn == nRem && nIn < uint32((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pDest)).FpPage)).FmaxLocal) { + libc.X__builtin___memcpy_chk(tls, aOut, aIn, uint64(nIn), ^t__predefined_size_t(0)) + (*TBtShared)(unsafe.Pointer(pBt)).FnPreformatSize = libc.Int32FromUint32(nIn + libc.Uint32FromInt32(int32(int64(aOut)-int64((*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace)))) + return SQLITE_OK + } else { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + pSrcPager = (*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pSrc)).FpBt)).FpPager + pPgnoOut = uintptr(0) + ovflIn = uint32(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pPageOut = uintptr(0) /* Size of output buffer aOut[] */ + nOut = libc.Uint32FromInt32(_btreePayloadToLocal(tls, (*TBtCursor)(unsafe.Pointer(pDest)).FpPage, libc.Int64FromUint32((*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload))) + (*TBtShared)(unsafe.Pointer(pBt)).FnPreformatSize = libc.Int32FromUint32(nOut) + int32(int64(aOut)-int64((*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace)) + if nOut < (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload { + pPgnoOut = aOut + uintptr(nOut) + **(**int32)(__ccgo_up(pBt + 144)) += int32(4) + } + if nRem > nIn { + if aIn+uintptr(nIn)+uintptr(4) > (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pSrc)).FpPage)).FaDataEnd { + return _sqlite3CorruptError(tls, int32(82903)) + } + ovflIn = _sqlite3Get4byte(tls, (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FpPayload+uintptr(nIn)) + } + for cond := true; cond; cond = nRem > uint32(0) && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + nRem = nRem - nOut + for cond := true; cond; cond = **(**int32)(__ccgo_up(bp)) == SQLITE_OK && nOut > uint32(0) { + if nIn > uint32(0) { + if nOut < nIn { + v2 = nOut + } else { + v2 = nIn + } + nCopy = libc.Int32FromUint32(v2) + libc.X__builtin___memcpy_chk(tls, aOut, aIn, libc.Uint64FromInt32(nCopy), ^t__predefined_size_t(0)) + nOut = nOut - libc.Uint32FromInt32(nCopy) + nIn = nIn - libc.Uint32FromInt32(nCopy) + aOut = aOut + uintptr(nCopy) + aIn = aIn + uintptr(nCopy) + } + if nOut > uint32(0) { + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerGet(tls, pSrcPager, ovflIn, bp+8, int32(PAGER_GET_READONLY)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + aIn = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 8))) + ovflIn = _sqlite3Get4byte(tls, aIn) + aIn = aIn + uintptr(4) + nIn = (*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pSrc)).FpBt)).FusableSize - uint32(4) + } + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && nRem > uint32(0) && pPgnoOut != 0 { + **(**TPgno)(__ccgo_up(bp + 16)) = uint32(0) /* Prevent harmless static-analyzer warning */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + **(**int32)(__ccgo_up(bp)) = _allocateBtreePage(tls, pBt, bp+24, bp+16, uint32(0), uint8(0)) + _sqlite3Put4byte(tls, pPgnoOut, **(**TPgno)(__ccgo_up(bp + 16))) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && pPageOut != 0 { + _ptrmapPut(tls, pBt, **(**TPgno)(__ccgo_up(bp + 16)), uint8(PTRMAP_OVERFLOW2), (*TMemPage)(unsafe.Pointer(pPageOut)).Fpgno, bp) + } + _releasePage(tls, pPageOut) + pPageOut = **(**uintptr)(__ccgo_up(bp + 24)) + if pPageOut != 0 { + pPgnoOut = (*TMemPage)(unsafe.Pointer(pPageOut)).FaData + _sqlite3Put4byte(tls, pPgnoOut, uint32(0)) + aOut = pPgnoOut + 4 + if (*TBtShared)(unsafe.Pointer(pBt)).FusableSize-uint32(4) < nRem { + v2 = (*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32(4) + } else { + v2 = nRem + } + nOut = v2 + } + } + } + _releasePage(tls, pPageOut) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return **(**int32)(__ccgo_up(bp)) + } + return r +} + +func _sqlite3CantopenError(tls *libc.TLS, lineno int32) (r int32) { + return _sqlite3ReportError(tls, int32(SQLITE_CANTOPEN), lineno, __ccgo_ts+26645) +} + +// C documentation +// +// /* +// ** This routine is used to check if the UTF-8 string zName is a legal +// ** unqualified name for a new schema object (table, index, view or +// ** trigger). All names are legal except those that begin with the string +// ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace +// ** is reserved for internal use. +// ** +// ** When parsing the sqlite_schema table, this routine also checks to +// ** make sure the "type", "name", and "tbl_name" columns are consistent +// ** with the SQL. +// */ +func _sqlite3CheckObjectName(tls *libc.TLS, pParse uintptr, zName uintptr, zType uintptr, zTblName uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db uintptr + _ = db + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if _sqlite3WritableSchema(tls, db) != 0 || int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x6>>1)) != 0 || !(_sqlite3Config.FbExtraSchemaChecks != 0) { + /* Skip these error checks for writable_schema=ON */ + return SQLITE_OK + } + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + if Xsqlite3_stricmp(tls, zType, **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit))) != 0 || Xsqlite3_stricmp(tls, zName, **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit + 1*8))) != 0 || Xsqlite3_stricmp(tls, zTblName, **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit + 2*8))) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1702, 0) /* corruptSchema() will supply the error */ + return int32(SQLITE_ERROR) + } + } else { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && 0 == Xsqlite3_strnicmp(tls, zName, __ccgo_ts+7100, int32(7)) || _sqlite3ReadOnlyShadowTables(tls, db) != 0 && _sqlite3ShadowTableName(tls, db, zName) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14107, libc.VaList(bp+8, zName)) + return int32(SQLITE_ERROR) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Remove entries from the sqlite_statN tables (for N in (1,2,3)) +// ** after a DROP INDEX or DROP TABLE command. +// */ +func _sqlite3ClearStatTables(tls *libc.TLS, pParse uintptr, iDb int32, zType uintptr, zName uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i int32 + var zDbName uintptr + var _ /* zTab at bp+0 */ [24]int8 + _, _ = i, zDbName + zDbName = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName + i = int32(1) + for { + if !(i <= int32(4)) { + break + } + Xsqlite3_snprintf(tls, int32(24), bp, __ccgo_ts+15295, libc.VaList(bp+32, i)) + if _sqlite3FindTable(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, bp, zDbName) != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+13280, libc.VaList(bp+32, zDbName, bp, zType, zName)) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Close an existing SQLite database +// */ +func _sqlite3Close(tls *libc.TLS, db uintptr, forceZombie int32) (r int32) { + var p uintptr + _ = p + if !(db != 0) { + /* EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or + ** sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. */ + return SQLITE_OK + } + if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) { + return _sqlite3MisuseError(tls, int32(188460)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_CLOSE) != 0 { + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_CLOSE), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, db, uintptr(0)) + } + /* Force xDisconnect calls on all virtual tables */ + _disconnectAllVtab(tls, db) + /* If a transaction is open, the disconnectAllVtab() call above + ** will not have called the xDisconnect() method on any virtual + ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback() + ** call will do so. We need to do this before the check for active + ** SQL statements below, as the v-table implementation may be storing + ** some prepared statements internally. + */ + _sqlite3VtabRollback(tls, db) + /* Legacy behavior (sqlite3_close() behavior) is to return + ** SQLITE_BUSY if the connection can not be closed immediately. + */ + if !(forceZombie != 0) && _connectionIsBusy(tls, db) != 0 { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_BUSY), __ccgo_ts+25613, 0) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return int32(SQLITE_BUSY) + } + for (*Tsqlite3)(unsafe.Pointer(db)).FpDbData != 0 { + p = (*Tsqlite3)(unsafe.Pointer(db)).FpDbData + (*Tsqlite3)(unsafe.Pointer(db)).FpDbData = (*TDbClientData)(unsafe.Pointer(p)).FpNext + if (*TDbClientData)(unsafe.Pointer(p)).FxDestructor != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TDbClientData)(unsafe.Pointer(p)).FxDestructor})))(tls, (*TDbClientData)(unsafe.Pointer(p)).FpData) + } + Xsqlite3_free(tls, p) + } + /* Convert the connection into a zombie and then close it. + */ + (*Tsqlite3)(unsafe.Pointer(db)).FeOpenState = uint8(SQLITE_STATE_ZOMBIE) + _sqlite3LeaveMutexAndCloseZombie(tls, db) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Generate code to drop a table. +// */ +func _sqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int32, isView int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pDb, pTrigger, v uintptr + _, _, _, _ = db, pDb, pTrigger, v + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + v = _sqlite3GetVdbe(tls, pParse) + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3VdbeAddOp0(tls, v, int32(OP_VBegin)) + } + /* Drop all triggers associated with the table being dropped. Code + ** is generated to remove entries from sqlite_schema and/or + ** sqlite_temp_schema if required. + */ + pTrigger = _sqlite3TriggerList(tls, pParse, pTab) + for pTrigger != 0 { + _sqlite3DropTriggerPtr(tls, pParse, pTrigger) + pTrigger = (*TTrigger)(unsafe.Pointer(pTrigger)).FpNext + } + /* Remove any entries of the sqlite_sequence table associated with + ** the table being dropped. This is done before the table is dropped + ** at the btree level, in case the sqlite_sequence table needs to + ** move as a result of the drop (can happen in auto-vacuum mode). + */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Autoincrement) != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+15309, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + /* Drop all entries in the schema table that refer to the + ** table. The program name loops through the schema table and deletes + ** every row that refers to a table of the same name as the one being + ** dropped. Triggers are handled separately because a trigger can be + ** created in the temp database that refers to a table in another + ** database. + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+15354, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, (*TTable)(unsafe.Pointer(pTab)).FzName)) + if !(isView != 0) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + _destroyTable(tls, pParse, pTab) + } + /* Remove the table entry from SQLite's internal schema and modify + ** the schema cookie. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_VDestroy), iDb, 0, 0, (*TTable)(unsafe.Pointer(pTab)).FzName, 0) + _sqlite3MayAbort(tls, pParse) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_DropTable), iDb, 0, 0, (*TTable)(unsafe.Pointer(pTab)).FzName, 0) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqliteViewResetAll(tls, db, iDb) +} + +// C documentation +// +// /* +// ** Generate code that will construct an ephemeral table containing all terms +// ** in the RHS of an IN operator. The IN operator can be in either of two +// ** forms: +// ** +// ** x IN (4,5,11) -- IN operator with list on right-hand side +// ** x IN (SELECT a FROM b) -- IN operator with subquery on the right +// ** +// ** The pExpr parameter is the IN operator. The cursor number for the +// ** constructed ephemeral table is returned. The first time the ephemeral +// ** table is computed, the cursor number is also stored in pExpr->iTable, +// ** however the cursor number returned might not be the same, as it might +// ** have been duplicated using OP_OpenDup. +// ** +// ** If the LHS expression ("x" in the examples) is a column value, or +// ** the SELECT statement returns a column value, then the affinity of that +// ** column is used to build the index keys. If both 'x' and the +// ** SELECT... statement are columns, then numeric affinity is used +// ** if either column has NUMERIC or INTEGER affinity. If neither +// ** 'x' nor the SELECT... statement are columns, then numeric affinity +// ** is used. +// */ +func _sqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int32, allowBloom int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addr, addrBloom, addrOnce, i, i1, nVal, r1, r2, rc, regBloom, v1 int32 + var p, pCopy, pE2, pEList, pItem, pKeyInfo, pLeft, pList, pSelect, pSig, v, v2 uintptr + var _ /* affinity at bp+40 */ int8 + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrBloom, addrOnce, i, i1, nVal, p, pCopy, pE2, pEList, pItem, pKeyInfo, pLeft, pList, pSelect, pSig, r1, r2, rc, regBloom, v, v1, v2 + addrOnce = 0 /* the LHS of the IN operator */ + pKeyInfo = uintptr(0) /* The prepared statement under construction */ + pSig = uintptr(0) /* Signature for this subroutine */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* The evaluation of the IN must be repeated every time it + ** is encountered if any of the following is true: + ** + ** * The right-hand side is a correlated subquery + ** * The right-hand side is an expression list containing variables + ** * We are inside a trigger + ** + ** If all of the above are false, then we can compute the RHS just once + ** and reuse it many names. + */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) != libc.Uint32FromInt32(0)) && (*TParse)(unsafe.Pointer(pParse)).FiSelfTab == 0 { + /* Reuse of the RHS is allowed + ** + ** Compute a signature for the RHS of the IN operator to facility + ** finding and reusing prior instances of the same IN operator. + */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselFlags&uint32(SF_All) == uint32(0) { + pSig = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(32)) + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FselId = libc.Int32FromUint32((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselId) + (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff = _exprINAffinity(tls, pParse, pExpr) + } + } + /* Check to see if there is a prior materialization of the RHS of + ** this IN operator. If there is, then make use of that prior + ** materialization rather than recomputing it. + */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) != uint32(0) || _findCompatibleInRhsSubrtn(tls, pParse, pExpr, pSig) != 0 { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8673, libc.VaList(bp+56, (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselId)) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), iTab, (*TExpr)(unsafe.Pointer(pExpr)).FiTable) + _sqlite3VdbeJumpHere(tls, v, addrOnce) + if pSig != 0 { + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSig) + } + return + } + /* Begin coding the subroutine */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn = v1 + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr = _sqlite3VdbeAddOp2(tls, v, int32(OP_BeginSubrtn), 0, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn) + int32(1) + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FbComplete = uint8(0) + (*TSubrtnSig)(unsafe.Pointer(pSig)).FiAddr = (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr + (*TSubrtnSig)(unsafe.Pointer(pSig)).FregReturn = (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn + (*TSubrtnSig)(unsafe.Pointer(pSig)).FiTable = iTab + (*TParse)(unsafe.Pointer(pParse)).FmSubrtnSig = libc.Uint8FromInt32(int32(1) << ((*TSubrtnSig)(unsafe.Pointer(pSig)).FselId & int32(7))) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pSig, -int32(18)) + } + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + /* Check to see if this is a vector IN operator */ + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + nVal = _sqlite3ExprVectorSize(tls, pLeft) + /* Construct the ephemeral table that will contain the content of + ** RHS of the IN operator. + */ + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = iTab + addr = _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, nVal) + pKeyInfo = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, nVal, int32(1)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + /* Case 1: expr IN (SELECT ...) + ** + ** Generate code to write the results of the select into the temporary + ** table allocated and opened above. + */ + pSelect = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + if addrOnce != 0 { + v2 = __ccgo_ts + 1702 + } else { + v2 = __ccgo_ts + 8696 + } + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+8708, libc.VaList(bp+56, v2, (*TSelect)(unsafe.Pointer(pSelect)).FselId)) + /* If the LHS and RHS of the IN operator do not match, that + ** error will have been caught long before we reach this point. */ + if (*TExprList)(unsafe.Pointer(pEList)).FnExpr == nVal { + addrBloom = 0 + _sqlite3SelectDestInit(tls, bp, int32(SRT_Set), iTab) + (**(**TSelectDest)(__ccgo_up(bp))).FzAffSdst = _exprINAffinity(tls, pParse, pExpr) + (*TSelect)(unsafe.Pointer(pSelect)).FiLimit = 0 + if addrOnce != 0 && allowBloom != 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_BloomFilter)) == uint32(0) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regBloom = v1 + addrBloom = _sqlite3VdbeAddOp2(tls, v, int32(OP_Blob), int32(10000), regBloom) + (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 = regBloom + } + /* Caused by OOM in sqlite3KeyInfoAlloc() */ + pCopy = _sqlite3SelectDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect, 0) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + v1 = int32(1) + } else { + v1 = _sqlite3Select(tls, pParse, pCopy, bp) + } + rc = v1 + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCopy) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (**(**TSelectDest)(__ccgo_up(bp))).FzAffSdst) + if addrBloom != 0 { + /* Remember that location of the Bloom filter in the P3 operand + ** of the OP_Once that began this subroutine. tag-202407032019 */ + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, v, addrOnce))).Fp3 = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 + if (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 == 0 { + /* If the Bloom filter won't actually be used, keep it small */ + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, v, addrBloom))).Fp1 = int32(10) + } + } + if rc != 0 { + _sqlite3KeyInfoUnref(tls, pKeyInfo) + return + } + /* OOM will cause exit after sqlite3Select() */ + i = 0 + for { + if !(i < nVal) { + break + } + p = _sqlite3VectorFieldSubexpr(tls, pLeft, i) + *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)) = _sqlite3BinaryCompareCollSeq(tls, pParse, p, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr) + goto _7 + _7: + ; + i = i + 1 + } + } + } else { + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != uintptr(0) { + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + **(**int8)(__ccgo_up(bp + 40)) = _sqlite3ExprAffinity(tls, pLeft) + if int32(**(**int8)(__ccgo_up(bp + 40))) <= int32(SQLITE_AFF_NONE) { + **(**int8)(__ccgo_up(bp + 40)) = int8(SQLITE_AFF_BLOB) + } else { + if int32(**(**int8)(__ccgo_up(bp + 40))) == int32(SQLITE_AFF_REAL) { + **(**int8)(__ccgo_up(bp + 40)) = int8(SQLITE_AFF_NUMERIC) + } + } + if pKeyInfo != 0 { + *(*uintptr)(unsafe.Pointer(pKeyInfo + 32)) = _sqlite3ExprCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + } + /* Loop through each expression in . */ + r1 = _sqlite3GetTempReg(tls, pParse) + r2 = _sqlite3GetTempReg(tls, pParse) + i1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + pItem = pList + 8 + for { + if !(i1 > 0) { + break + } + pE2 = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + /* If the expression is not constant then we will need to + ** disable the test that was generated above that makes sure + ** this code only executes once. Because for a non-constant + ** expression we need to rerun this code each time. + */ + if addrOnce != 0 && !(_sqlite3ExprIsConstant(tls, pParse, pE2) != 0) { + _sqlite3VdbeChangeToNoop(tls, v, addrOnce-int32(1)) + _sqlite3VdbeChangeToNoop(tls, v, addrOnce) + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + addrOnce = 0 + } + /* Evaluate the expression and insert it into the temp table */ + _sqlite3ExprCode(tls, pParse, pE2, r1) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), r1, int32(1), r2, bp+40, int32(1)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iTab, r2, r1, int32(1)) + goto _8 + _8: + ; + i1 = i1 - 1 + pItem += 32 + } + _sqlite3ReleaseTempReg(tls, pParse, r1) + _sqlite3ReleaseTempReg(tls, pParse, r2) + } + } + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FbComplete = uint8(1) + } + if pKeyInfo != 0 { + _sqlite3VdbeChangeP4(tls, v, addr, pKeyInfo, -int32(9)) + } + if addrOnce != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iTab) + _sqlite3VdbeJumpHere(tls, v, addrOnce) + /* Subroutine return */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr, int32(1)) + _sqlite3ClearTempRegCache(tls, pParse) + } +} + +// C documentation +// +// /* +// ** Generate code for scalar subqueries used as a subquery expression +// ** or EXISTS operator: +// ** +// ** (SELECT a FROM b) -- subquery +// ** EXISTS (SELECT a FROM b) -- EXISTS subquery +// ** +// ** The pExpr parameter is the SELECT or EXISTS operator to be coded. +// ** +// ** Return the register that holds the result. For a multi-column SELECT, +// ** the result is stored in a contiguous array of registers and the +// ** return value is the register of the left-most result column. +// ** Return 0 if an error occurs. +// */ +func _sqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var addrOnce, nReg, rReg, v1 int32 + var db, pLeft, pLimit, pSel, v, v2 uintptr + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _ = addrOnce, db, nReg, pLeft, pLimit, pSel, rReg, v, v1, v2 + addrOnce = 0 /* Address of OP_Once at top of subroutine */ + rReg = 0 /* New limit expression */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return 0 + } + pSel = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + /* If this routine has already been coded, then invoke it as a + ** subroutine. */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) != uint32(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8727, libc.VaList(bp+48, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr) + return (*TExpr)(unsafe.Pointer(pExpr)).FiTable + } + /* Begin coding the subroutine */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn = v1 + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr = _sqlite3VdbeAddOp2(tls, v, int32(OP_BeginSubrtn), 0, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn) + int32(1) + /* The evaluation of the EXISTS/SELECT must be repeated every time it + ** is encountered if any of the following is true: + ** + ** * The right-hand side is a correlated subquery + ** * The right-hand side is an expression list containing variables + ** * We are inside a trigger + ** + ** If all of the above are false, then we can run this code just once + ** save the results, and reuse the same result on subsequent invocations. + */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) != libc.Uint32FromInt32(0)) { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + /* For a SELECT, generate code to put the values for all columns of + ** the first row into an array of registers and return the index of + ** the first register. + ** + ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists) + ** into a register and return that register number. + ** + ** In both cases, the query is augmented with "LIMIT 1". Any + ** preexisting limit is discarded in place of the new LIMIT 1. + */ + if addrOnce != 0 { + v2 = __ccgo_ts + 1702 + } else { + v2 = __ccgo_ts + 8696 + } + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+8745, libc.VaList(bp+48, v2, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) { + v1 = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpEList)).FnExpr + } else { + v1 = int32(1) + } + nReg = v1 + _sqlite3SelectDestInit(tls, bp, 0, (*TParse)(unsafe.Pointer(pParse)).FnMem+int32(1)) + **(**int32)(__ccgo_up(pParse + 60)) += nReg + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) { + (**(**TSelectDest)(__ccgo_up(bp))).FeDest = uint8(SRT_Mem) + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_Distinct) != 0 && (*TSelect)(unsafe.Pointer(pSel)).FpLimit != 0 && (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpRight != 0 { + /* If there is both a DISTINCT and an OFFSET clause, then allocate + ** a separate dest.iSdst array for sqlite3Select() and other + ** routines to populate. In this case results will be copied over + ** into the dest.iSDParm array only after OFFSET processing. This + ** ensures that in the case where OFFSET excludes all rows, the + ** dest.iSDParm array is not left populated with the contents of the + ** last row visited - it should be all NULLs if all rows were + ** excluded by OFFSET. */ + (**(**TSelectDest)(__ccgo_up(bp))).FiSdst = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nReg + } else { + (**(**TSelectDest)(__ccgo_up(bp))).FiSdst = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm + } + (**(**TSelectDest)(__ccgo_up(bp))).FnSdst = nReg + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm, (*TParse)(unsafe.Pointer(pParse)).FnMem) + } else { + (**(**TSelectDest)(__ccgo_up(bp))).FeDest = uint8(SRT_Exists) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm) + } + if (*TSelect)(unsafe.Pointer(pSel)).FpLimit != 0 { + /* The subquery already has a limit. If the pre-existing limit X is + ** not already integer value 1 or 0, then make the new limit X<>0 so that + ** the new limit is either 1 or 0 */ + pLeft = (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpLeft + if libc.BoolInt32((*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != uint32(0)) == 0 || *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pLeft)).Fu)) != int32(1) && *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pLeft)).Fu)) != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pLimit = _sqlite3ExprInt32(tls, db, 0) + if pLimit != 0 { + (*TExpr)(unsafe.Pointer(pLimit)).FaffExpr = int8(SQLITE_AFF_NUMERIC) + pLimit = _sqlite3PExpr(tls, pParse, int32(TK_NE), _sqlite3ExprDup(tls, db, pLeft, 0), pLimit) + } + _sqlite3ExprDeferredDelete(tls, pParse, pLeft) + (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpLeft = pLimit + } + } else { + /* If there is no pre-existing limit add a limit of 1 */ + pLimit = _sqlite3ExprInt32(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(1)) + (*TSelect)(unsafe.Pointer(pSel)).FpLimit = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), pLimit, uintptr(0)) + } + (*TSelect)(unsafe.Pointer(pSel)).FiLimit = 0 + if _sqlite3Select(tls, pParse, pSel, bp) != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_ERROR) + return 0 + } + v1 = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm + rReg = v1 + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = v1 + if addrOnce != 0 { + _sqlite3VdbeJumpHere(tls, v, addrOnce) + } + /* Subroutine return */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr, int32(1)) + _sqlite3ClearTempRegCache(tls, pParse) + return rReg +} + +// C documentation +// +// /* +// ** Look through the list of open database files in db->aDb[] and if +// ** any have been closed, remove them from the list. Reallocate the +// ** db->aDb[] structure to a smaller size, if possible. +// ** +// ** Entry 0 (the "main" database) and entry 1 (the "temp" database) +// ** are never candidates for being collapsed. +// */ +func _sqlite3CollapseDatabaseArray(tls *libc.TLS, db uintptr) { + var i, j, v2 int32 + var pDb uintptr + _, _, _, _ = i, j, pDb, v2 + v2 = libc.Int32FromInt32(2) + j = v2 + i = v2 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpBt == uintptr(0) { + _sqlite3DbFree(tls, db, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) + (*TDb)(unsafe.Pointer(pDb)).FzDbSName = uintptr(0) + goto _1 + } + if j < i { + **(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*32)) = **(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)) + } + j = j + 1 + goto _1 + _1: + ; + i = i + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FnDb = j + if (*Tsqlite3)(unsafe.Pointer(db)).FnDb <= int32(2) && (*Tsqlite3)(unsafe.Pointer(db)).FaDb != db+696 { + libc.X__builtin___memcpy_chk(tls, db+696, (*Tsqlite3)(unsafe.Pointer(db)).FaDb, libc.Uint64FromInt32(2)*libc.Uint64FromInt64(32), ^t__predefined_size_t(0)) + _sqlite3DbFree(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaDb) + (*Tsqlite3)(unsafe.Pointer(db)).FaDb = db + 696 + } +} + +// C documentation +// +// /* +// ** Set the collating sequence name for a column. +// */ +func _sqlite3ColumnSetColl(tls *libc.TLS, db uintptr, pCol uintptr, zColl uintptr) { + var n, nColl Ti64 + var zNew, v1 uintptr + _, _, _, _ = n, nColl, zNew, v1 + n = int64(_sqlite3Strlen30(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + int32(1)) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { + n = n + int64(_sqlite3Strlen30(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName+uintptr(n))+int32(1)) + } + nColl = int64(_sqlite3Strlen30(tls, zColl) + int32(1)) + zNew = _sqlite3DbRealloc(tls, db, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, libc.Uint64FromInt64(nColl+n)) + if zNew != 0 { + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = zNew + libc.X__builtin___memcpy_chk(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName+uintptr(n), zColl, libc.Uint64FromInt64(nColl), ^t__predefined_size_t(0)) + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_HASCOLL)) + } +} + +// C documentation +// +// /* +// ** Given an expression list (which is really the list of expressions +// ** that form the result set of a SELECT statement) compute appropriate +// ** column names for a table that would hold the expression list. +// ** +// ** All column names will be unique. +// ** +// ** Only the column names are computed. Column.zType, Column.zColl, +// ** and other fields of Column are zeroed. +// ** +// ** Return SQLITE_OK on success. If a memory allocation error occurs, +// ** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM. +// ** +// ** The only guarantee that SQLite makes about column names is that if the +// ** column has an AS clause assigning it a name, that will be the name used. +// ** That is the only documented guarantee. However, countless applications +// ** developed over the years have made baseless assumptions about column names +// ** and will break if those assumptions changes. Hence, use extreme caution +// ** when modifying this routine to avoid breaking legacy. +// ** +// ** See Also: sqlite3GenerateColumnNames() +// */ +func _sqlite3ColumnsFromExprList(tls *libc.TLS, pParse uintptr, pEList uintptr, pnCol uintptr, paCol uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var aCol, db, pCol, pColExpr, pCollide, pTab, pX, zName, v2, v3 uintptr + var i, iCol, j, nCol, nName int32 + var v5 bool + var v8 Tu32 + var _ /* cnt at bp+0 */ Tu32 + var _ /* ht at bp+8 */ THash + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCol, db, i, iCol, j, nCol, nName, pCol, pColExpr, pCollide, pTab, pX, zName, v2, v3, v5, v8 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + _sqlite3HashInit(tls, bp+8) + if pEList != 0 { + nCol = (*TExprList)(unsafe.Pointer(pEList)).FnExpr + aCol = _sqlite3DbMallocZero(tls, db, uint64(uint64(16)*libc.Uint64FromInt32(nCol))) + if nCol > int32(32767) { + nCol = int32(32767) + } + } else { + nCol = 0 + aCol = uintptr(0) + } + **(**Ti16)(__ccgo_up(pnCol)) = int16(nCol) + **(**uintptr)(__ccgo_up(paCol)) = aCol + i = 0 + pCol = aCol + for { + if !(i < nCol && !((*TParse)(unsafe.Pointer(pParse)).FnErr != 0)) { + break + } + pX = pEList + 8 + uintptr(i)*32 + /* Get an appropriate name for the column + */ + v2 = (*TExprList_item)(unsafe.Pointer(pX)).FzEName + zName = v2 + if v2 != uintptr(0) && int32(uint32(*(*uint16)(unsafe.Pointer(pX + 16 + 4))&0x3>>0)) == ENAME_NAME { + /* If the column contains an "AS " phrase, use as the name */ + } else { + pColExpr = _sqlite3ExprSkipCollateAndLikely(tls, (*TExprList_item)(unsafe.Pointer(pX)).FpExpr) + for pColExpr != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_DOT) { + pColExpr = (*TExpr)(unsafe.Pointer(pColExpr)).FpRight + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pColExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) && *(*uintptr)(unsafe.Pointer(pColExpr + 64)) != uintptr(0) { + /* For columns use the column name name */ + iCol = int32((*TExpr)(unsafe.Pointer(pColExpr)).FiColumn) + pTab = *(*uintptr)(unsafe.Pointer(pColExpr + 64)) + if iCol < 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + if iCol >= 0 { + v2 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + } else { + v2 = __ccgo_ts + 18310 + } + zName = v2 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_ID) { + zName = *(*uintptr)(unsafe.Pointer(pColExpr + 8)) + } else { + /* Use the original text of the column expression as its name */ + /* pointer comparison intended */ + } + } + } + if zName != 0 && !(_sqlite3IsTrueOrFalse(tls, zName) != 0) { + zName = _sqlite3DbStrDup(tls, db, zName) + } else { + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+21025, libc.VaList(bp+40, i+int32(1))) + } + /* Make sure the column name is unique. If the name is not unique, + ** append an integer to the name so that it becomes unique. + */ + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + for { + if v5 = zName != 0; v5 { + v2 = _sqlite3HashFind(tls, bp+8, zName) + pCollide = v2 + } + if !(v5 && v2 != uintptr(0)) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pCollide + 16 + 4))&0x80>>7)) != 0 { + v3 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(COLFLAG_NOEXPAND)) + } + nName = _sqlite3Strlen30(tls, zName) + if nName > 0 { + j = nName - int32(1) + for { + if !(j > 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zName + uintptr(j))))])&int32(0x04) != 0) { + break + } + goto _7 + _7: + ; + j = j - 1 + } + if int32(**(**int8)(__ccgo_up(zName + uintptr(j)))) == int32(':') { + nName = j + } + } + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + 1 + v8 = **(**Tu32)(__ccgo_up(bp)) + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+21034, libc.VaList(bp+40, nName, zName, v8)) + _sqlite3ProgressCheck(tls, pParse) + if **(**Tu32)(__ccgo_up(bp)) > uint32(3) { + Xsqlite3_randomness(tls, int32(4), bp) + } + } + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = zName + (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, zName) + if int32(uint32(*(*uint16)(unsafe.Pointer(pX + 16 + 4))&0x100>>8)) != 0 { + v2 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(COLFLAG_NOEXPAND)) + } + if zName != 0 && _sqlite3HashInsert(tls, bp+8, zName, pX) == pX { + _sqlite3OomFault(tls, db) + } + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + _sqlite3HashClear(tls, bp+8) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + j = 0 + for { + if !(j < i) { + break + } + _sqlite3DbFree(tls, db, (**(**TColumn)(__ccgo_up(aCol + uintptr(j)*16))).FzCnName) + goto _10 + _10: + ; + j = j + 1 + } + _sqlite3DbFree(tls, db, aCol) + **(**uintptr)(__ccgo_up(paCol)) = uintptr(0) + **(**Ti16)(__ccgo_up(pnCol)) = 0 + return (*TParse)(unsafe.Pointer(pParse)).Frc + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** All regular columns for table pTab have been puts into registers +// ** starting with iRegStore. The registers that correspond to STORED +// ** or VIRTUAL columns have not yet been initialized. This routine goes +// ** back and computes the values for those columns based on the previously +// ** computed normal columns. +// */ +func _sqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore int32, pTab uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var eProgress, i, ii, jj, x, v2 int32 + var pCol, pOp, pRedo, zP4, v4 uintptr + var _ /* w at bp+0 */ TWalker + _, _, _, _, _, _, _, _, _, _, _ = eProgress, i, ii, jj, pCol, pOp, pRedo, x, zP4, v2, v4 + /* Before computing generated columns, first go through and make sure + ** that appropriate affinity has been applied to the regular columns + */ + _sqlite3TableAffinity(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iRegStore) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasStored) != uint32(0) { + pOp = _sqlite3VdbeGetLastOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Affinity) { + zP4 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + v2 = libc.Int32FromInt32(0) + jj = v2 + ii = v2 + for { + if !(**(**int8)(__ccgo_up(zP4 + uintptr(jj))) != 0) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(ii)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + goto _1 + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(ii)*16))).FcolFlags)&int32(COLFLAG_STORED) != 0 { + **(**int8)(__ccgo_up(zP4 + uintptr(jj))) = int8(SQLITE_AFF_NONE) + } + jj = jj + 1 + goto _1 + _1: + ; + ii = ii + 1 + } + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_TypeCheck) { + /* If an OP_TypeCheck was generated because the table is STRICT, + ** then set the P3 operand to indicate that generated columns should + ** not be checked */ + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 = int32(1) + } + } + } + /* Because there can be multiple generated columns that refer to one another, + ** this is a two-pass algorithm. On the first pass, mark all generated + ** columns as "not available". + */ + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + v4 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_NOTAVAIL)) + } + goto _3 + _3: + ; + i = i + 1 + } + *(*uintptr)(unsafe.Pointer(bp + 40)) = pTab + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprColumnFlagUnion) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = uintptr(0) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + /* On the second pass, compute the value of each NOT-AVAILABLE column. + ** Companion code in the TK_COLUMN case of sqlite3ExprCodeTarget() will + ** compute dependencies and mark remove the COLSPAN_NOTAVAIL mark, as + ** they are needed. + */ + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = -iRegStore + for cond := true; cond; cond = pRedo != 0 && eProgress != 0 { + eProgress = 0 + pRedo = uintptr(0) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_NOTAVAIL) != 0 { + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_BUSY)) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(0) + _sqlite3WalkExpr(tls, bp, _sqlite3ColumnExpr(tls, pTab, pCol)) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^libc.Int32FromInt32(COLFLAG_BUSY)) + if libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode)&int32(COLFLAG_NOTAVAIL) != 0 { + pRedo = pCol + goto _5 + } + eProgress = int32(1) + x = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(i))) + iRegStore + _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab, pCol, x) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^libc.Int32FromInt32(COLFLAG_NOTAVAIL)) + } + goto _5 + _5: + ; + i = i + 1 + } + } + if pRedo != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8796, libc.VaList(bp+56, (*TColumn)(unsafe.Pointer(pRedo)).FzCnName)) + } + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 +} + +// C documentation +// +// /* +// ** This function is called when +// ** the transaction opened by database db has just finished. Locks held +// ** by database connection db have been released. +// ** +// ** This function loops through each entry in the blocked connections +// ** list and does the following: +// ** +// ** 1) If the sqlite3.pBlockingConnection member of a list entry is +// ** set to db, then set pBlockingConnection=0. +// ** +// ** 2) If the sqlite3.pUnlockConnection member of a list entry is +// ** set to db, then invoke the configured unlock-notify callback and +// ** set pUnlockConnection=0. +// ** +// ** 3) If the two steps above mean that pBlockingConnection==0 and +// ** pUnlockConnection==0, remove the entry from the blocked connections +// ** list. +// */ +func _sqlite3ConnectionUnlocked(tls *libc.TLS, db uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var aArg, aDyn, p, pNew, pp, xUnlockNotify, v2 uintptr + var nArg, v3 int32 + var _ /* aStatic at bp+0 */ [16]uintptr + _, _, _, _, _, _, _, _, _ = aArg, aDyn, nArg, p, pNew, pp, xUnlockNotify, v2, v3 + xUnlockNotify = uintptr(0) /* Unlock-notify cb to invoke */ + nArg = 0 /* Arguments to the unlock callback */ + aDyn = uintptr(0) /* Starter space for aArg[]. No malloc required */ + aArg = bp + _enterMutex(tls) /* Enter STATIC_MAIN mutex */ + /* This loop runs once for each entry in the blocked-connections list. */ + pp = uintptr(unsafe.Pointer(&_sqlite3BlockedList)) + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + p = **(**uintptr)(__ccgo_up(pp)) + /* Step 1. */ + if (*Tsqlite3)(unsafe.Pointer(p)).FpBlockingConnection == db { + (*Tsqlite3)(unsafe.Pointer(p)).FpBlockingConnection = uintptr(0) + } + /* Step 2. */ + if (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection == db { + if (*Tsqlite3)(unsafe.Pointer(p)).FxUnlockNotify != xUnlockNotify && nArg != 0 { + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})))(tls, aArg, nArg) + nArg = 0 + } + _sqlite3BeginBenignMalloc(tls) + if !(aDyn != 0) && nArg == libc.Int32FromUint64(libc.Uint64FromInt64(128)/libc.Uint64FromInt64(8)) || aDyn != 0 && nArg == libc.Int32FromUint64(libc.Uint64FromInt32(_sqlite3MallocSize(tls, aDyn))/libc.Uint64FromInt64(8)) { + /* The aArg[] array needs to grow. */ + pNew = _sqlite3Malloc(tls, uint64(libc.Uint64FromInt32(nArg)*uint64(8)*uint64(2))) + if pNew != 0 { + libc.X__builtin___memcpy_chk(tls, pNew, aArg, libc.Uint64FromInt32(nArg)*uint64(8), ^t__predefined_size_t(0)) + Xsqlite3_free(tls, aDyn) + v2 = pNew + aArg = v2 + aDyn = v2 + } else { + /* This occurs when the array of context pointers that need to + ** be passed to the unlock-notify callback is larger than the + ** aStatic[] array allocated on the stack and the attempt to + ** allocate a larger array from the heap has failed. + ** + ** This is a difficult situation to handle. Returning an error + ** code to the caller is insufficient, as even if an error code + ** is returned the transaction on connection db will still be + ** closed and the unlock-notify callbacks on blocked connections + ** will go unissued. This might cause the application to wait + ** indefinitely for an unlock-notify callback that will never + ** arrive. + ** + ** Instead, invoke the unlock-notify callback with the context + ** array already accumulated. We can then clear the array and + ** begin accumulating any further context pointers without + ** requiring any dynamic allocation. This is sub-optimal because + ** it means that instead of one callback with a large array of + ** context pointers the application will receive two or more + ** callbacks with smaller arrays of context pointers, which will + ** reduce the applications ability to prioritize multiple + ** connections. But it is the best that can be done under the + ** circumstances. + */ + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})))(tls, aArg, nArg) + nArg = 0 + } + } + _sqlite3EndBenignMalloc(tls) + v3 = nArg + nArg = nArg + 1 + **(**uintptr)(__ccgo_up(aArg + uintptr(v3)*8)) = (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockArg + xUnlockNotify = (*Tsqlite3)(unsafe.Pointer(p)).FxUnlockNotify + (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(p)).FxUnlockNotify = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockArg = uintptr(0) + } + /* Step 3. */ + if (*Tsqlite3)(unsafe.Pointer(p)).FpBlockingConnection == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection == uintptr(0) { + /* Remove connection p from the blocked connections list. */ + **(**uintptr)(__ccgo_up(pp)) = (*Tsqlite3)(unsafe.Pointer(p)).FpNextBlocked + (*Tsqlite3)(unsafe.Pointer(p)).FpNextBlocked = uintptr(0) + } else { + pp = p + 856 + } + goto _1 + _1: + } + if nArg != 0 { + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})))(tls, aArg, nArg) + } + Xsqlite3_free(tls, aDyn) + _leaveMutex(tls) /* Leave STATIC_MAIN mutex */ +} + +func _sqlite3CorruptError(tls *libc.TLS, lineno int32) (r int32) { + return _sqlite3ReportError(tls, int32(SQLITE_CORRUPT), lineno, __ccgo_ts+26618) +} + +// C documentation +// +// /* +// ** This routine is called to create a new foreign key on the table +// ** currently under construction. pFromCol determines which columns +// ** in the current table point to the foreign key. If pFromCol==0 then +// ** connect the key to the last column inserted. pTo is the name of +// ** the table referred to (a.k.a the "parent" table). pToCol is a list +// ** of tables in the parent pTo table. flags contains all +// ** information about the conflict resolution algorithms specified +// ** in the ON DELETE, ON UPDATE and ON INSERT clauses. +// ** +// ** An FKey structure is created and added to the table currently +// ** under construction in the pParse->pNewTable field. +// ** +// ** The foreign key is set for IMMEDIATE processing. A subsequent call +// ** to sqlite3DeferForeignKey() might change this to DEFERRED. +// */ +func _sqlite3CreateForeignKey(tls *libc.TLS, pParse uintptr, pFromCol uintptr, pTo uintptr, pToCol uintptr, flags int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pFKey, pNextTo, z uintptr + var i, iCol, j, n, nCol int32 + var nByte Ti64 + _, _, _, _, _, _, _, _, _, _, _ = db, i, iCol, j, n, nByte, nCol, p, pFKey, pNextTo, z + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pFKey = uintptr(0) + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) { + goto fk_end + } + if pFromCol == uintptr(0) { + iCol = int32((*TTable)(unsafe.Pointer(p)).FnCol) - int32(1) + if iCol < 0 { + goto fk_end + } + if pToCol != 0 && (*TExprList)(unsafe.Pointer(pToCol)).FnExpr != int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15515, libc.VaList(bp+8, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(iCol)*16))).FzCnName, pTo)) + goto fk_end + } + nCol = int32(1) + } else { + if pToCol != 0 && (*TExprList)(unsafe.Pointer(pToCol)).FnExpr != (*TExprList)(unsafe.Pointer(pFromCol)).FnExpr { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15578, 0) + goto fk_end + } else { + nCol = (*TExprList)(unsafe.Pointer(pFromCol)).FnExpr + } + } + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+64) + libc.Uint64FromInt32(nCol)*uint64(16) + uint64((*TToken)(unsafe.Pointer(pTo)).Fn) + uint64(1)) + if pToCol != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pToCol)).FnExpr) { + break + } + nByte = nByte + int64(_sqlite3Strlen30(tls, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName)+int32(1)) + goto _1 + _1: + ; + i = i + 1 + } + } + pFKey = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte)) + if pFKey == uintptr(0) { + goto fk_end + } + (*TFKey)(unsafe.Pointer(pFKey)).FpFrom = p + (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FpFKey + z = pFKey + 64 + uintptr(nCol)*16 + (*TFKey)(unsafe.Pointer(pFKey)).FzTo = z + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, z, pTo) + } + libc.X__builtin___memcpy_chk(tls, z, (*TToken)(unsafe.Pointer(pTo)).Fz, uint64((*TToken)(unsafe.Pointer(pTo)).Fn), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(z + uintptr((*TToken)(unsafe.Pointer(pTo)).Fn))) = 0 + _sqlite3Dequote(tls, z) + z = z + uintptr((*TToken)(unsafe.Pointer(pTo)).Fn+uint32(1)) + (*TFKey)(unsafe.Pointer(pFKey)).FnCol = nCol + if pFromCol == uintptr(0) { + (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom = int32((*TTable)(unsafe.Pointer(p)).FnCol) - int32(1) + } else { + i = 0 + for { + if !(i < nCol) { + break + } + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + if _sqlite3StrICmp(tls, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(j)*16))).FzCnName, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName) == 0 { + (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FiFrom = j + break + } + goto _3 + _3: + ; + j = j + 1 + } + if j >= int32((*TTable)(unsafe.Pointer(p)).FnCol) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15672, libc.VaList(bp+8, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName)) + goto fk_end + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, pFKey+64+uintptr(i)*16, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName) + } + goto _2 + _2: + ; + i = i + 1 + } + } + if pToCol != 0 { + i = 0 + for { + if !(i < nCol) { + break + } + n = _sqlite3Strlen30(tls, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName) + (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FzCol = z + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, z, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName) + } + libc.X__builtin___memcpy_chk(tls, z, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName, libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(z + uintptr(n))) = 0 + z = z + uintptr(n+int32(1)) + goto _4 + _4: + ; + i = i + 1 + } + } + (*TFKey)(unsafe.Pointer(pFKey)).FisDeferred = uint8(0) + **(**Tu8)(__ccgo_up(pFKey + 45)) = libc.Uint8FromInt32(flags & libc.Int32FromInt32(0xff)) /* ON DELETE action */ + **(**Tu8)(__ccgo_up(pFKey + 45 + 1)) = libc.Uint8FromInt32(flags >> libc.Int32FromInt32(8) & libc.Int32FromInt32(0xff)) /* ON UPDATE action */ + pNextTo = _sqlite3HashInsert(tls, (*TTable)(unsafe.Pointer(p)).FpSchema+80, (*TFKey)(unsafe.Pointer(pFKey)).FzTo, pFKey) + if pNextTo == pFKey { + _sqlite3OomFault(tls, db) + goto fk_end + } + if pNextTo != 0 { + (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo = pNextTo + (*TFKey)(unsafe.Pointer(pNextTo)).FpPrevTo = pFKey + } + /* Link the foreign key to the table as the last step. + */ + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FpFKey = pFKey + pFKey = uintptr(0) + goto fk_end +fk_end: + ; + _sqlite3DbFree(tls, db, pFKey) + _sqlite3ExprListDelete(tls, db, pFromCol) + _sqlite3ExprListDelete(tls, db, pToCol) +} + +// C documentation +// +// /* +// ** This function is exactly the same as sqlite3_create_function(), except +// ** that it is designed to be called by internal code. The difference is +// ** that if a malloc() fails in sqlite3_create_function(), an error code +// ** is returned and the mallocFailed flag cleared. +// */ +func _sqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg int32, enc int32, pUserData uintptr, __ccgo_fp_xSFunc uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr, __ccgo_fp_xValue uintptr, __ccgo_fp_xInverse uintptr, pDestructor uintptr) (r int32) { + var extraFlags, rc int32 + var p, v1 uintptr + _, _, _, _ = extraFlags, p, rc, v1 + if zFunctionName == uintptr(0) || __ccgo_fp_xSFunc != uintptr(0) && __ccgo_fp_xFinal != uintptr(0) || libc.BoolInt32(__ccgo_fp_xFinal == uintptr(0)) != libc.BoolInt32(__ccgo_fp_xStep == uintptr(0)) || libc.BoolInt32(__ccgo_fp_xValue == uintptr(0)) != libc.BoolInt32(__ccgo_fp_xInverse == uintptr(0)) || (nArg < -int32(1) || nArg > int32(SQLITE_MAX_FUNCTION_ARG)) || int32(255) < _sqlite3Strlen30(tls, zFunctionName) { + return _sqlite3MisuseError(tls, int32(189155)) + } + extraFlags = enc & (libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_DIRECTONLY) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_INNOCUOUS) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_SELFORDER1)) + enc = enc & (libc.Int32FromInt32(SQLITE_FUNC_ENCMASK) | libc.Int32FromInt32(SQLITE_ANY)) + /* The SQLITE_INNOCUOUS flag is the same bit as SQLITE_FUNC_UNSAFE. But + ** the meaning is inverted. So flip the bit. */ + extraFlags = extraFlags ^ int32(SQLITE_FUNC_UNSAFE) /* tag-20230109-1 */ + /* If SQLITE_UTF16 is specified as the encoding type, transform this + ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the + ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. + ** + ** If SQLITE_ANY is specified, add three versions of the function + ** to the hash table. + */ + switch enc { + case int32(SQLITE_UTF16): + enc = int32(SQLITE_UTF16LE) + case int32(SQLITE_ANY): + rc = _sqlite3CreateFunc(tls, db, zFunctionName, nArg, int32(SQLITE_UTF8)|extraFlags^int32(SQLITE_FUNC_UNSAFE), pUserData, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, __ccgo_fp_xValue, __ccgo_fp_xInverse, pDestructor) + if rc == SQLITE_OK { + rc = _sqlite3CreateFunc(tls, db, zFunctionName, nArg, int32(SQLITE_UTF16LE)|extraFlags^int32(SQLITE_FUNC_UNSAFE), pUserData, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, __ccgo_fp_xValue, __ccgo_fp_xInverse, pDestructor) + } + if rc != SQLITE_OK { + return rc + } + enc = int32(SQLITE_UTF16BE) + case int32(SQLITE_UTF8): + fallthrough + case int32(SQLITE_UTF16LE): + fallthrough + case int32(SQLITE_UTF16BE): + default: + enc = int32(SQLITE_UTF8) + break + } + /* Check if an existing function is being overridden or deleted. If so, + ** and there are active VMs, then return SQLITE_BUSY. If a function + ** is being overridden/deleted but there are no active VMs, allow the + ** operation to continue but invalidate all precompiled statements. + */ + p = _sqlite3FindFunction(tls, db, zFunctionName, nArg, libc.Uint8FromInt32(enc), uint8(0)) + if p != 0 && (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_ENCMASK) == libc.Uint32FromInt32(enc) && int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) == nArg { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_BUSY), __ccgo_ts+26237, 0) + return int32(SQLITE_BUSY) + } else { + _sqlite3ExpirePreparedStatements(tls, db, 0) + } + } else { + if __ccgo_fp_xSFunc == uintptr(0) && __ccgo_fp_xFinal == uintptr(0) { + /* Trying to delete a function that does not exist. This is a no-op. + ** https://sqlite.org/forum/forumpost/726219164b */ + return SQLITE_OK + } + } + p = _sqlite3FindFunction(tls, db, zFunctionName, nArg, libc.Uint8FromInt32(enc), uint8(1)) + if !(p != 0) { + return int32(SQLITE_NOMEM) + } + /* If an older version of the function with a configured destructor is + ** being replaced invoke the destructor function here. */ + _functionDestroy(tls, db, p) + if pDestructor != 0 { + (*TFuncDestructor)(unsafe.Pointer(pDestructor)).FnRef = (*TFuncDestructor)(unsafe.Pointer(pDestructor)).FnRef + 1 + } + *(*uintptr)(unsafe.Pointer(p + 64)) = pDestructor + (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags = (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_ENCMASK) | libc.Uint32FromInt32(extraFlags) + if __ccgo_fp_xSFunc != 0 { + v1 = __ccgo_fp_xSFunc + } else { + v1 = __ccgo_fp_xStep + } + (*TFuncDef)(unsafe.Pointer(p)).FxSFunc = v1 + (*TFuncDef)(unsafe.Pointer(p)).FxFinalize = __ccgo_fp_xFinal + (*TFuncDef)(unsafe.Pointer(p)).FxValue = __ccgo_fp_xValue + (*TFuncDef)(unsafe.Pointer(p)).FxInverse = __ccgo_fp_xInverse + (*TFuncDef)(unsafe.Pointer(p)).FpUserData = pUserData + (*TFuncDef)(unsafe.Pointer(p)).FnArg = libc.Int16FromUint16(libc.Uint16FromInt32(nArg)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Create a new index for an SQL table. pName1.pName2 is the name of the index +// ** and pTblList is the name of the table that is to be indexed. Both will +// ** be NULL for a primary key or an index that is created to satisfy a +// ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse->pNewTable +// ** as the table to be indexed. pParse->pNewTable is a table that is +// ** currently being constructed by a CREATE TABLE statement. +// ** +// ** pList is a list of columns to be indexed. pList will be NULL if this +// ** is a primary key or unique-constraint on the most recent column added +// ** to the table currently under construction. +// */ +func _sqlite3CreateIndex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pTblName uintptr, pList uintptr, onError int32, pStart uintptr, pPIWhere uintptr, sortOrder int32, ifNotExist int32, idxType Tu8) { + bp := tls.Alloc(176) + defer tls.Free(176) + var db, p, pCExpr, pCol, pDb, pExpr, pIdx, pIndex, pListItem, pLoop, pNext, pPk, pTab, pThis, ppFrom, v, z1, z2, zColl, zDb, zName, zStmt, v2 uintptr + var i, iDb, iMem, j, k, n, n1, nColl, nExtra, nExtraCol, nName, requestedSortOrder, sortOrderMask, x, v5 int32 + var _ /* pName at bp+96 */ uintptr + var _ /* prevCol at bp+112 */ TToken + var _ /* sFix at bp+0 */ TDbFixer + var _ /* zExtra at bp+104 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iDb, iMem, j, k, n, n1, nColl, nExtra, nExtraCol, nName, p, pCExpr, pCol, pDb, pExpr, pIdx, pIndex, pListItem, pLoop, pNext, pPk, pTab, pThis, ppFrom, requestedSortOrder, sortOrderMask, v, x, z1, z2, zColl, zDb, zName, zStmt, v2, v5 + pTab = uintptr(0) /* Table to be indexed */ + pIndex = uintptr(0) /* The index to be created */ + zName = uintptr(0) /* 1 to honor DESC in index. 0 to ignore. */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Index of the database that is being written */ + **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) /* For looping over pList */ + nExtra = 0 /* Number of extra columns needed */ + **(**uintptr)(__ccgo_up(bp + 104)) = uintptr(0) /* Extra space after the Index object */ + pPk = uintptr(0) /* PRIMARY KEY index for WITHOUT ROWID tables */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) && libc.Int32FromUint8(idxType) != int32(SQLITE_IDXTYPE_PRIMARYKEY) { + goto exit_create_index + } + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto exit_create_index + } + if _sqlite3HasExplicitNulls(tls, pParse, pList) != 0 { + goto exit_create_index + } + /* + ** Find the table that is to be indexed. Return early if not found. + */ + if pTblName != uintptr(0) { + /* Use the two-part index name to determine the database + ** to search for the table. 'Fix' the table name to this db + ** before looking up the table. + */ + iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp+96) + if iDb < 0 { + goto exit_create_index + } + /* If the index name was unqualified, check if the table + ** is a temp table. If so, set the database to 1. Do not do this + ** if initializing a database schema. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + pTab = _sqlite3SrcListLookup(tls, pParse, pTblName) + if (*TToken)(unsafe.Pointer(pName2)).Fn == uint32(0) && pTab != 0 && (*TTable)(unsafe.Pointer(pTab)).FpSchema == (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema { + iDb = int32(1) + } + } + _sqlite3FixInit(tls, bp, pParse, iDb, __ccgo_ts+15757, **(**uintptr)(__ccgo_up(bp + 96))) + if _sqlite3FixSrcList(tls, bp, pTblName) != 0 { + /* Because the parser constructs pTblName from a single identifier, + ** sqlite3FixSrcList can never fail. */ + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pTblName+8) + if pTab == uintptr(0) { + goto exit_create_index + } + if iDb == int32(1) && (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema != (*TTable)(unsafe.Pointer(pTab)).FpSchema { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15763, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_create_index + } + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + } + } else { + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if !(pTab != 0) { + goto exit_create_index + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+7100, int32(7)) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 && pTblName != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15813, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_create_index + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15841, 0) + goto exit_create_index + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15866, 0) + goto exit_create_index + } + /* + ** Find the name of the index. Make sure there is not already another + ** index or table with the same name. + ** + ** Exception: If we are reading the names of permanent indices from the + ** sqlite_schema table (because some other process changed the schema) and + ** one of the index names collides with the name of a temporary table or + ** index, then we will continue to process this index. + ** + ** If pName==0 it means that we are + ** dealing with a primary key or UNIQUE constraint. We have to invent our + ** own name. + */ + if **(**uintptr)(__ccgo_up(bp + 96)) != 0 { + zName = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp + 96))) + if zName == uintptr(0) { + goto exit_create_index + } + if SQLITE_OK != _sqlite3CheckObjectName(tls, pParse, zName, __ccgo_ts+15757, (*TTable)(unsafe.Pointer(pTab)).FzName) { + goto exit_create_index + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + if _sqlite3FindTable(tls, db, zName, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15900, libc.VaList(bp+136, zName)) + goto exit_create_index + } + } + if _sqlite3FindIndex(tls, db, zName, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0) { + if !(ifNotExist != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15934, libc.VaList(bp+136, zName)) + } else { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3ForceNotReadOnly(tls, pParse) + } + goto exit_create_index + } + } + } else { + pLoop = (*TTable)(unsafe.Pointer(pTab)).FpIndex + n = libc.Int32FromInt32(1) + for { + if !(pLoop != 0) { + break + } + goto _1 + _1: + ; + pLoop = (*TIndex)(unsafe.Pointer(pLoop)).FpNext + n = n + 1 + } + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+15958, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName, n)) + if zName == uintptr(0) { + goto exit_create_index + } + /* Automatic index names generated from within sqlite3_declare_vtab() + ** must have names that are distinct from normal automatic index names. + ** The following statement converts "sqlite3_autoindex..." into + ** "sqlite3_butoindex..." in order to make the names distinct. + ** The "vtab_err.test" test demonstrates the need of this statement. */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + **(**int8)(__ccgo_up(zName + 7)) = **(**int8)(__ccgo_up(zName + 7)) + 1 + } + } + /* Check for authorization to create an index. + */ + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + zDb = (*TDb)(unsafe.Pointer(pDb)).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v2 = __ccgo_ts + 7108 + } else { + v2 = __ccgo_ts + 6628 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), v2, uintptr(0), zDb) != 0 { + goto exit_create_index + } + i = int32(SQLITE_CREATE_INDEX) + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + i = int32(SQLITE_CREATE_TEMP_INDEX) + } + if _sqlite3AuthCheck(tls, pParse, i, zName, (*TTable)(unsafe.Pointer(pTab)).FzName, zDb) != 0 { + goto exit_create_index + } + } + /* If pList==0, it means this routine was called to make a primary + ** key out of the last column added to the table under construction. + ** So create a fake list to simulate this. + */ + if pList == uintptr(0) { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1))*16 + v2 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(COLFLAG_UNIQUE)) + _sqlite3TokenInit(tls, bp+112, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + pList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+112, 0)) + if pList == uintptr(0) { + goto exit_create_index + } + _sqlite3ExprListSetSortOrder(tls, pList, sortOrder, -int32(1)) + } else { + _sqlite3ExprListCheckLength(tls, pParse, pList, __ccgo_ts+15757) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + } + /* Figure out how many bytes of space are required to store explicitly + ** specified collation sequence names. + */ + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE) { + nExtra = nExtra + (int32(1) + _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)))) + } + goto _4 + _4: + ; + i = i + 1 + } + /* + ** Allocate the index structure. + */ + nName = _sqlite3Strlen30(tls, zName) + if pPk != 0 { + v5 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } else { + v5 = int32(1) + } + nExtraCol = v5 + pIndex = _sqlite3AllocateIndexObject(tls, db, (*TExprList)(unsafe.Pointer(pList)).FnExpr+nExtraCol, nName+nExtra+int32(1), bp+104) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_create_index + } + (*TIndex)(unsafe.Pointer(pIndex)).FzName = **(**uintptr)(__ccgo_up(bp + 104)) + **(**uintptr)(__ccgo_up(bp + 104)) = **(**uintptr)(__ccgo_up(bp + 104)) + uintptr(nName+int32(1)) + libc.X__builtin___memcpy_chk(tls, (*TIndex)(unsafe.Pointer(pIndex)).FzName, zName, libc.Uint64FromInt32(nName+int32(1)), ^t__predefined_size_t(0)) + (*TIndex)(unsafe.Pointer(pIndex)).FpTable = pTab + (*TIndex)(unsafe.Pointer(pIndex)).FonError = libc.Uint8FromInt32(onError) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.BoolUint32(onError != libc.Int32FromInt32(OE_None)), 3, 0x8) + libc.SetBitFieldPtr16Uint32(pIndex+100, uint32(idxType), 0, 0x3) + (*TIndex)(unsafe.Pointer(pIndex)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol = libc.Uint16FromInt32((*TExprList)(unsafe.Pointer(pList)).FnExpr) + if pPIWhere != 0 { + _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_PartIdx), pPIWhere, uintptr(0)) + (*TIndex)(unsafe.Pointer(pIndex)).FpPartIdxWhere = pPIWhere + pPIWhere = uintptr(0) + } + /* Check to see if we should honor DESC requests on index columns + */ + if libc.Int32FromUint8((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) >= int32(4) { + sortOrderMask = -int32(1) /* Honor DESC */ + } else { + sortOrderMask = 0 /* Ignore DESC */ + } + /* Analyze the list of expressions that form the terms of the index and + ** report any errors. In the common case where the expression is exactly + ** a table column, store that column in aiColumn[]. For general expressions, + ** populate pIndex->aColExpr and store XN_EXPR (-2) in aiColumn[]. + ** + ** TODO: Issue a warning if two or more columns of the index are identical. + ** TODO: Issue a warning if the table primary key is used as part of the + ** index key. + */ + pListItem = pList + 8 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr = pList + pList = uintptr(0) + } + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol)) { + break + } /* Collation sequence name */ + _sqlite3StringToId(tls, (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr) + _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_IdxExpr), (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + pCExpr = _sqlite3ExprSkipCollate(tls, (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCExpr)).Fop) != int32(TK_COLUMN) { + if pTab == (*TParse)(unsafe.Pointer(pParse)).FpNewTable { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15981, 0) + goto exit_create_index + } + if (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr == uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr = pList + pList = uintptr(0) + } + j = -int32(2) + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-libc.Int32FromInt32(2)) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 11, 0x800) + } else { + j = int32((*TExpr)(unsafe.Pointer(pCExpr)).FiColumn) + if j < 0 { + j = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16 + 8))&0xf>>0)) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 3, 0x8) + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 10, 0x400) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 11, 0x800) + } + } + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(j) + } + zColl = uintptr(0) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == int32(TK_COLLATE) { + zColl = *(*uintptr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr + 8)) + nColl = _sqlite3Strlen30(tls, zColl) + int32(1) + libc.X__builtin___memcpy_chk(tls, **(**uintptr)(__ccgo_up(bp + 104)), zColl, libc.Uint64FromInt32(nColl), ^t__predefined_size_t(0)) + zColl = **(**uintptr)(__ccgo_up(bp + 104)) + **(**uintptr)(__ccgo_up(bp + 104)) = **(**uintptr)(__ccgo_up(bp + 104)) + uintptr(nColl) + nExtra = nExtra - nColl + } else { + if j >= 0 { + zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16) + } + } + if !(zColl != 0) { + zColl = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) && !(_sqlite3LocateCollSeq(tls, pParse, zColl) != 0) { + goto exit_create_index + } + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = zColl + requestedSortOrder = libc.Int32FromUint8((*TExprList_item)(unsafe.Pointer(pListItem)).Ffg.FsortFlags) & sortOrderMask + **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = libc.Uint8FromInt32(requestedSortOrder) + goto _6 + _6: + ; + i = i + 1 + pListItem += 32 + } + /* Append the table key to the end of the index. For WITHOUT ROWID + ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For + ** normal tables (when pPk==0) this will be the rowid. + */ + if pPk != 0 { + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + x = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2))) + if _isDupColumn(tls, pIndex, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol), pPk, j) != 0 { + (*TIndex)(unsafe.Pointer(pIndex)).FnColumn = (*TIndex)(unsafe.Pointer(pIndex)).FnColumn - 1 + } else { + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(x) + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*8)) + **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(j))) + i = i + 1 + } + goto _7 + _7: + ; + j = j + 1 + } + } else { + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-libc.Int32FromInt32(1)) + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + _sqlite3DefaultRowEst(tls, pIndex) + if (*TParse)(unsafe.Pointer(pParse)).FpNewTable == uintptr(0) { + _estimateIndexWidth(tls, pIndex) + } + /* If this index contains every column of its table, then mark + ** it as a covering index */ + _recomputeColumnsNotIndexed(tls, pIndex) + if pTblName != uintptr(0) && libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnColumn) >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 5, 0x20) + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + goto _8 + } + if _sqlite3TableColumnToIndex(tls, pIndex, j) >= 0 { + goto _8 + } + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 5, 0x20) + break + goto _8 + _8: + ; + j = j + 1 + } + } + if pTab == (*TParse)(unsafe.Pointer(pParse)).FpNewTable { + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol) { + goto _9 + } + k = 0 + for { + if !(k < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(k)*2))) != int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(k)*2))) { + break + } + z1 = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(k)*8)) + z2 = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(k)*8)) + if _sqlite3StrICmp(tls, z1, z2) != 0 { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if k == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) { + /* This constraint creates the same index as a previous + ** constraint specified somewhere in the CREATE TABLE statement. + ** However the ON CONFLICT clauses are different. If both this + ** constraint and the previous equivalent constraint have explicit + ** ON CONFLICT clauses this is an error. Otherwise, use the + ** explicitly specified behavior for the index. + */ + if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Default) || libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) == int32(OE_Default)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16042, libc.VaList(bp+136, 0)) + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Default) { + (*TIndex)(unsafe.Pointer(pIdx)).FonError = (*TIndex)(unsafe.Pointer(pIndex)).FonError + } + } + if libc.Int32FromUint8(idxType) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + libc.SetBitFieldPtr16Uint32(pIdx+100, uint32(idxType), 0, 0x3) + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TIndex)(unsafe.Pointer(pIndex)).FpNext = (*TParse)(unsafe.Pointer(pParse)).FpNewIndex + (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex + pIndex = uintptr(0) + } + goto exit_create_index + } + goto _9 + _9: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + /* Link the new Index structure to its table and to the other + ** in-memory database structures. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + if pTblName != uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).Ftnum = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum + if _sqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16084, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = _sqlite3CorruptError(tls, int32(130799)) + goto exit_create_index + } + } + p = _sqlite3HashInsert(tls, (*TIndex)(unsafe.Pointer(pIndex)).FpSchema+32, (*TIndex)(unsafe.Pointer(pIndex)).FzName, pIndex) + if p != 0 { + /* Malloc must have failed */ + _sqlite3OomFault(tls, db) + goto exit_create_index + } + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + } else { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || pTblName != uintptr(0) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v5 = *(*int32)(unsafe.Pointer(v2)) + iMem = v5 + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto exit_create_index + } + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + /* Create the rootpage for the index using CreateIndex. But before + ** doing so, code a Noop instruction and store its address in + ** Index.tnum. This is required in case this index is actually a + ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In + ** that case the convertToWithoutRowidTable() routine will replace + ** the Noop with a Goto to jump over the VDBE code generated below. */ + (*TIndex)(unsafe.Pointer(pIndex)).Ftnum = libc.Uint32FromInt32(_sqlite3VdbeAddOp0(tls, v, int32(OP_Noop))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_CreateBtree), iDb, iMem, int32(BTREE_BLOBKEY)) + /* Gather the complete text of the CREATE INDEX statement into + ** the zStmt variable + */ + if pStart != 0 { + n1 = libc.Int32FromUint32(libc.Uint32FromInt32(int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64((*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz))) + (*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fn) + if int32(**(**int8)(__ccgo_up((*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz + uintptr(n1-int32(1))))) == int32(';') { + n1 = n1 - 1 + } + /* A named index with an explicit CREATE INDEX statement */ + if onError == OE_None { + v2 = __ccgo_ts + 1702 + } else { + v2 = __ccgo_ts + 16101 + } + zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+16109, libc.VaList(bp+136, v2, n1, (*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz)) + } else { + /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ + /* zStmt = sqlite3MPrintf(""); */ + zStmt = uintptr(0) + } + /* Add an entry in sqlite_schema for this index + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+16129, libc.VaList(bp+136, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TIndex)(unsafe.Pointer(pIndex)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, iMem, zStmt)) + _sqlite3DbFree(tls, db, zStmt) + /* Fill the index with data and reparse the schema. Code an OP_Expire + ** to invalidate all pre-compiled statements. + */ + if pTblName != 0 { + _sqlite3RefillIndex(tls, pParse, pIndex, iMem) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+16188, libc.VaList(bp+136, (*TIndex)(unsafe.Pointer(pIndex)).FzName)), uint16(0)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Expire), 0, int32(1)) + } + _sqlite3VdbeJumpHere(tls, v, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIndex)).Ftnum)) + } + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || pTblName == uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).FpNext = (*TTable)(unsafe.Pointer(pTab)).FpIndex + (*TTable)(unsafe.Pointer(pTab)).FpIndex = pIndex + pIndex = uintptr(0) + } else { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex + pIndex = uintptr(0) + } + } + /* Clean up before exiting */ + goto exit_create_index +exit_create_index: + ; + if pIndex != 0 { + _sqlite3FreeIndex(tls, db, pIndex) + } + if pTab != 0 { + ppFrom = pTab + 16 + for { + v2 = **(**uintptr)(__ccgo_up(ppFrom)) + pThis = v2 + if !(v2 != uintptr(0)) { + break + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pThis)).FonError) != int32(OE_Replace) { + goto _14 + } + for { + v2 = (*TIndex)(unsafe.Pointer(pThis)).FpNext + pNext = v2 + if !(v2 != uintptr(0) && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pNext)).FonError) != int32(OE_Replace)) { + break + } + **(**uintptr)(__ccgo_up(ppFrom)) = pNext + (*TIndex)(unsafe.Pointer(pThis)).FpNext = (*TIndex)(unsafe.Pointer(pNext)).FpNext + (*TIndex)(unsafe.Pointer(pNext)).FpNext = pThis + ppFrom = pNext + 40 + } + break + goto _14 + _14: + ; + ppFrom = pThis + 40 + } + } + _sqlite3ExprDelete(tls, db, pPIWhere) + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3SrcListDelete(tls, db, pTblName) + _sqlite3DbFree(tls, db, zName) +} + +// C documentation +// +// /* +// ** The parser calls this routine in order to create a new VIEW +// */ +func _sqlite3CreateView(tls *libc.TLS, pParse uintptr, pBegin uintptr, pName1 uintptr, pName2 uintptr, pCNames uintptr, pSelect uintptr, isTemp int32, noErr int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var db, p, z uintptr + var iDb, n int32 + var _ /* pName at bp+112 */ uintptr + var _ /* sEnd at bp+0 */ TToken + var _ /* sFix at bp+16 */ TDbFixer + _, _, _, _, _ = db, iDb, n, p, z + **(**uintptr)(__ccgo_up(bp + 112)) = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if int32((*TParse)(unsafe.Pointer(pParse)).FnVar) > 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15147, 0) + goto create_view_fail + } + _sqlite3StartTable(tls, pParse, pName1, pName2, isTemp, int32(1), 0, noErr) + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) || (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto create_view_fail + } + /* Legacy versions of SQLite allowed the use of the magic "rowid" column + ** on a view, even though views do not have rowids. The following flag + ** setting fixes this problem. But the fix can be disabled by compiling + ** with -DSQLITE_ALLOW_ROWID_IN_VIEW in case there are legacy apps that + ** depend upon the old buggy behavior. The ability can also be toggled + ** using sqlite3_config(SQLITE_CONFIG_ROWID_IN_VIEW,...) */ + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_NoVisibleRowid) /* Never allow rowid in view */ + _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp+112) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(p)).FpSchema) + _sqlite3FixInit(tls, bp+16, pParse, iDb, __ccgo_ts+11459, **(**uintptr)(__ccgo_up(bp + 112))) + if _sqlite3FixSelect(tls, bp+16, pSelect) != 0 { + goto create_view_fail + } + /* Make a copy of the entire SELECT statement that defines the view. + ** This will force all the Expr.token.z values to be dynamically + ** allocated rather than point to the input string - which means that + ** they will persist after the current sqlite3_exec() call returns. + */ + **(**Tu32)(__ccgo_up(pSelect + 4)) |= uint32(SF_View) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(p)).Fu))).FpSelect = pSelect + pSelect = uintptr(0) + } else { + (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(p)).Fu))).FpSelect = _sqlite3SelectDup(tls, db, pSelect, int32(EXPRDUP_REDUCE)) + } + (*TTable)(unsafe.Pointer(p)).FpCheck = _sqlite3ExprListDup(tls, db, pCNames, int32(EXPRDUP_REDUCE)) + (*TTable)(unsafe.Pointer(p)).FeTabType = uint8(TABTYP_VIEW) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto create_view_fail + } + /* Locate the end of the CREATE VIEW statement. Make sEnd point to + ** the end. + */ + **(**TToken)(__ccgo_up(bp)) = (*TParse)(unsafe.Pointer(pParse)).FsLastToken + if int32(**(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp))).Fz))) != int32(';') { + (**(**TToken)(__ccgo_up(bp))).Fz += uintptr((**(**TToken)(__ccgo_up(bp))).Fn) + } + (**(**TToken)(__ccgo_up(bp))).Fn = uint32(0) + n = int32(int64((**(**TToken)(__ccgo_up(bp))).Fz) - int64((*TToken)(unsafe.Pointer(pBegin)).Fz)) + z = (*TToken)(unsafe.Pointer(pBegin)).Fz + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(n-int32(1)))))])&int32(0x01) != 0 { + n = n - 1 + } + (**(**TToken)(__ccgo_up(bp))).Fz = z + uintptr(n-int32(1)) + (**(**TToken)(__ccgo_up(bp))).Fn = uint32(1) + /* Use sqlite3EndTable() to add the view to the schema table */ + _sqlite3EndTable(tls, pParse, uintptr(0), bp, uint32(0), uintptr(0)) + goto create_view_fail +create_view_fail: + ; + _sqlite3SelectDelete(tls, db, pSelect) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameExprlistUnmap(tls, pParse, pCNames) + } + _sqlite3ExprListDelete(tls, db, pCNames) + return +} + +// C documentation +// +// /* +// ** Return true if zName points to a name that may be used to refer to +// ** database iDb attached to handle db. +// */ +func _sqlite3DbIsNamed(tls *libc.TLS, db uintptr, iDb int32, zName uintptr) (r int32) { + return libc.BoolInt32(_sqlite3StrICmp(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zName) == 0 || iDb == 0 && _sqlite3StrICmp(tls, __ccgo_ts+7160, zName) == 0) +} + +// C documentation +// +// /* +// ** Allocate and zero memory. If the allocation fails, make +// ** the mallocFailed flag in the connection pointer. +// */ +func _sqlite3DbMallocZero(tls *libc.TLS, db uintptr, n Tu64) (r uintptr) { + var p uintptr + _ = p + p = _sqlite3DbMallocRaw(tls, db, n) + if p != 0 { + libc.X__builtin___memset_chk(tls, p, 0, n, ^t__predefined_size_t(0)) + } + return p +} + +// C documentation +// +// /* +// ** Make a copy of a string in memory obtained from sqliteMalloc(). These +// ** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This +// ** is because when memory debugging is turned on, these two functions are +// ** called via macros that record the current file and line number in the +// ** ThreadData structure. +// */ +func _sqlite3DbStrDup(tls *libc.TLS, db uintptr, z uintptr) (r uintptr) { + var n Tsize_t + var zNew uintptr + _, _ = n, zNew + if z == uintptr(0) { + return uintptr(0) + } + n = libc.Xstrlen(tls, z) + uint64(1) + zNew = _sqlite3DbMallocRaw(tls, db, n) + if zNew != 0 { + libc.X__builtin___memcpy_chk(tls, zNew, z, n, ^t__predefined_size_t(0)) + } + return zNew +} + +func _sqlite3DbStrNDup(tls *libc.TLS, db uintptr, z uintptr, n Tu64) (r uintptr) { + var zNew, v1 uintptr + _, _ = zNew, v1 + if z != 0 { + v1 = _sqlite3DbMallocRawNN(tls, db, n+uint64(1)) + } else { + v1 = uintptr(0) + } + zNew = v1 + if zNew != 0 { + libc.X__builtin___memcpy_chk(tls, zNew, z, n, ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(zNew + uintptr(n))) = 0 + } + return zNew +} + +// C documentation +// +// /* +// ** Invoke this routine to register the "dbpage" virtual table module +// */ +func _sqlite3DbpageRegister(tls *libc.TLS, db uintptr) (r int32) { + return Xsqlite3_create_module(tls, db, __ccgo_ts+35500, uintptr(unsafe.Pointer(&_dbpage_module)), uintptr(0)) +} + +// C documentation +// +// /* +// ** Invoke this routine to register the "dbstat" virtual table module +// */ +func _sqlite3DbstatRegister(tls *libc.TLS, db uintptr) (r int32) { + return Xsqlite3_create_module(tls, db, __ccgo_ts+35315, uintptr(unsafe.Pointer(&_dbstat_module)), uintptr(0)) +} + +// C documentation +// +// /* +// ** Transform a UTF-8 integer literal, in either decimal or hexadecimal, +// ** into a 64-bit signed integer. This routine accepts hexadecimal literals, +// ** whereas sqlite3Atoi64() does not. +// ** +// ** Returns: +// ** +// ** 0 Successful transformation. Fits in a 64-bit signed integer. +// ** 1 Excess text after the integer value +// ** 2 Integer too large for a 64-bit signed integer or is malformed +// ** 3 Special case of 9223372036854775808 +// */ +func _sqlite3DecOrHexToI64(tls *libc.TLS, z uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, k, n int32 + var _ /* u at bp+0 */ Tu64 + _, _, _ = i, k, n + if int32(**(**int8)(__ccgo_up(z))) == int32('0') && (int32(**(**int8)(__ccgo_up(z + 1))) == int32('x') || int32(**(**int8)(__ccgo_up(z + 1))) == int32('X')) { + **(**Tu64)(__ccgo_up(bp)) = uint64(0) + i = int32(2) + for { + if !(int32(**(**int8)(__ccgo_up(z + uintptr(i)))) == int32('0')) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + k = i + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(k))))])&int32(0x08) != 0) { + break + } + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))*uint64(16) + uint64(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(z + uintptr(k)))))) + goto _2 + _2: + ; + k = k + 1 + } + libc.X__builtin___memcpy_chk(tls, pOut, bp, uint64(8), ^t__predefined_size_t(0)) + if k-i > int32(16) { + return int32(2) + } + if int32(**(**int8)(__ccgo_up(z + uintptr(k)))) != 0 { + return int32(1) + } + return 0 + } else { + n = libc.Int32FromUint64(libc.Uint64FromInt32(0x3fffffff) & libc.Xstrspn(tls, z, __ccgo_ts+1832)) + if **(**int8)(__ccgo_up(z + uintptr(n))) != 0 { + n = n + 1 + } + return _sqlite3Atoi64(tls, z, pOut, n, uint8(SQLITE_UTF8)) + } + return r +} + +// C documentation +// +// /* +// ** Fill the Index.aiRowEst[] array with default information - information +// ** to be used when we have not run the ANALYZE command. +// ** +// ** aiRowEst[0] is supposed to contain the number of elements in the index. +// ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the +// ** number of rows in the table that match any particular value of the +// ** first column of the index. aiRowEst[2] is an estimate of the number +// ** of rows that match any particular combination of the first 2 columns +// ** of the index. And so forth. It must always be the case that +// * +// ** aiRowEst[N]<=aiRowEst[N-1] +// ** aiRowEst[N]>=1 +// ** +// ** Apart from that, we have little to go on besides intuition as to +// ** how aiRowEst[] should be initialized. The numbers generated here +// ** are based on typical values found in actual indices. +// */ +func _sqlite3DefaultRowEst(tls *libc.TLS, pIdx uintptr) { + var a uintptr + var i, nCopy, v1 int32 + var x, v2 TLogEst + _, _, _, _, _, _ = a, i, nCopy, x, v1, v2 + a = (*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst + if libc.Int32FromUint64(libc.Uint64FromInt64(10)/libc.Uint64FromInt64(2)) < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + v1 = libc.Int32FromUint64(libc.Uint64FromInt64(10) / libc.Uint64FromInt64(2)) + } else { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + } + nCopy = v1 + /* Indexes with default row estimates should not have stat1 data */ + /* Set the first entry (number of rows in the index) to the estimated + ** number of rows in the table, or half the number of rows in the table + ** for a partial index. + ** + ** 2020-05-27: If some of the stat data is coming from the sqlite_stat1 + ** table but other parts we are having to guess at, then do not let the + ** estimated number of rows in the table be less than 1000 (LogEst 99). + ** Failure to do this can cause the indexes for which we do not have + ** stat1 data to be ignored by the query planner. + */ + x = (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FnRowLogEst + if int32(x) < int32(99) { + v2 = libc.Int16FromInt32(99) + x = v2 + (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FnRowLogEst = v2 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) { + x = int16(int32(x) - libc.Int32FromInt32(10)) + } + **(**TLogEst)(__ccgo_up(a)) = x + /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is + ** 6 and each subsequent value (if any) is 5. */ + libc.X__builtin___memcpy_chk(tls, a+1*2, uintptr(unsafe.Pointer(&_aVal)), libc.Uint64FromInt32(nCopy)*uint64(2), ^t__predefined_size_t(0)) + i = nCopy + int32(1) + for { + if !(i <= libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + **(**TLogEst)(__ccgo_up(a + uintptr(i)*2)) = int16(23) + goto _3 + _3: + ; + i = i + 1 + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != OE_None { + **(**TLogEst)(__ccgo_up(a + uintptr((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)*2)) = 0 + } +} + +// C documentation +// +// /* +// ** Generate code for a DELETE FROM statement. +// ** +// ** DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL; +// ** \________/ \________________/ +// ** pTabList pWhere +// */ +func _sqlite3DeleteFrom(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWhere uintptr, pOrderBy uintptr, pLimit uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aToOpen, db, pIdx, pPk, pTab, pTrigger, pVTab, pWInfo, v, v3 uintptr + var addrBypass, addrEphOpen, addrLoop, bComplex, count, eOnePass, i, iAddrOnce, iDb, iEphCur, iKey, iPk, iRowSet, iTabCur, isView, memCnt, nIdx, rcauth, v1, v2 int32 + var nKey, nPk Ti16 + var wcf Tu16 + var _ /* aiCurOnePass at bp+80 */ [2]int32 + var _ /* iDataCur at bp+0 */ int32 + var _ /* iIdxCur at bp+4 */ int32 + var _ /* sContext at bp+8 */ TAuthContext + var _ /* sNC at bp+24 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aToOpen, addrBypass, addrEphOpen, addrLoop, bComplex, count, db, eOnePass, i, iAddrOnce, iDb, iEphCur, iKey, iPk, iRowSet, iTabCur, isView, memCnt, nIdx, nKey, nPk, pIdx, pPk, pTab, pTrigger, pVTab, pWInfo, rcauth, v, wcf, v1, v2, v3 /* Cursor number for the table */ + **(**int32)(__ccgo_up(bp)) = 0 /* VDBE cursor for the canonical data source */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* Database number */ + memCnt = 0 /* The write cursors opened by WHERE_ONEPASS */ + aToOpen = uintptr(0) /* The PRIMARY KEY index on the table */ + iPk = 0 /* First of nPk registers holding PRIMARY KEY value */ + nPk = int16(1) /* Number of memory cells in the row key */ + iEphCur = 0 /* Ephemeral table holding all primary key values */ + iRowSet = 0 /* Register for rowset of rows to delete */ + addrBypass = 0 /* Address of jump over the delete logic */ + addrLoop = 0 /* Top of the delete loop */ + addrEphOpen = 0 /* List of table triggers, if required */ + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(16), ^t__predefined_size_t(0)) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto delete_from_cleanup + } + /* Locate the table which we want to delete. This table has to be + ** put in an SrcList structure because some of the subroutines we + ** will be calling are designed to work with multiple tables and expect + ** an SrcList* parameter instead of just a Table* parameter. + */ + pTab = _sqlite3SrcListLookup(tls, pParse, pTabList) + if pTab == uintptr(0) { + goto delete_from_cleanup + } + /* Figure out if we have any triggers and if the table being + ** deleted from is a view + */ + pTrigger = _sqlite3TriggersExist(tls, pParse, pTab, int32(TK_DELETE), uintptr(0), uintptr(0)) + isView = libc.BoolInt32(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW)) + bComplex = libc.BoolInt32(pTrigger != 0 || _sqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0) + /* If pTab is really a view, make sure it has been initialized. + */ + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto delete_from_cleanup + } + if _sqlite3IsReadOnly(tls, pParse, pTab, pTrigger) != 0 { + goto delete_from_cleanup + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + rcauth = _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + if rcauth == int32(SQLITE_DENY) { + goto delete_from_cleanup + } + /* Assign cursor numbers to the table and all its indices. + */ + v3 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = v2 + (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor = v1 + iTabCur = v1 + nIdx = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + (*TParse)(unsafe.Pointer(pParse)).FnTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + 1 + goto _4 + _4: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + nIdx = nIdx + 1 + } + /* Start the view context + */ + if isView != 0 { + _sqlite3AuthContextPush(tls, pParse, bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName) + } + /* Begin generating code. + */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto delete_from_cleanup + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _sqlite3VdbeCountChanges(tls, v) + } + _sqlite3BeginWriteOperation(tls, pParse, bComplex, iDb) + /* If we are trying to delete from a view, realize that view into + ** an ephemeral table. + */ + if isView != 0 { + _sqlite3MaterializeView(tls, pParse, pTab, pWhere, pOrderBy, pLimit, iTabCur) + v1 = iTabCur + **(**int32)(__ccgo_up(bp + 4)) = v1 + **(**int32)(__ccgo_up(bp)) = v1 + pOrderBy = uintptr(0) + pLimit = uintptr(0) + } + /* Resolve the column names in the WHERE clause. + */ + libc.X__builtin___memset_chk(tls, bp+24, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp + 24))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp + 24))).FpSrcList = pTabList + if _sqlite3ResolveExprNames(tls, bp+24, pWhere) != 0 { + goto delete_from_cleanup + } + /* Initialize the counter of the number of rows deleted, if + ** we are counting rows. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00001))<>3)) != 0) { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = *(*int32)(unsafe.Pointer(v3)) + memCnt = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, memCnt) + } + /* Special case: A DELETE without a WHERE clause deletes everything. + ** It is easier just to erase the whole table. Prior to version 3.6.5, + ** this optimization caused the row change count (the value returned by + ** API function sqlite3_count_changes) to be set incorrectly. + ** + ** The "rcauth==SQLITE_OK" terms is the + ** IMPLEMENTATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and + ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but + ** the truncate optimization is disabled and all rows are deleted + ** individually. + */ + if rcauth == SQLITE_OK && pWhere == uintptr(0) && !(bComplex != 0) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) && (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback == uintptr(0) { + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(1), (*TTable)(unsafe.Pointer(pTab)).FzName) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + if memCnt != 0 { + v1 = memCnt + } else { + v1 = -int32(1) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_Clear), libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab)).Ftnum), iDb, v1, (*TTable)(unsafe.Pointer(pTab)).FzName, -int32(1)) + } + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) && !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + if memCnt != 0 { + v1 = memCnt + } else { + v1 = -int32(1) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Clear), libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx)).Ftnum), iDb, v1) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Clear), libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx)).Ftnum), iDb) + } + goto _9 + _9: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } else { + wcf = libc.Uint16FromInt32(libc.Int32FromInt32(WHERE_ONEPASS_DESIRED) | libc.Int32FromInt32(WHERE_DUPLICATES_OK)) + if (**(**TNameContext)(__ccgo_up(bp + 24))).FncFlags&int32(NC_Subquery) != 0 { + bComplex = int32(1) + } + if bComplex != 0 { + v1 = 0 + } else { + v1 = int32(WHERE_ONEPASS_MULTIROW) + } + wcf = libc.Uint16FromInt32(int32(wcf) | v1) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + /* For a rowid table, initialize the RowSet to an empty set */ + pPk = uintptr(0) + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = *(*int32)(unsafe.Pointer(v3)) + iRowSet = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, iRowSet) + } else { + /* For a WITHOUT ROWID table, create an ephemeral table used to + ** hold all primary keys for rows to be deleted. */ + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int16FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + iPk = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(nPk) + v3 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + iEphCur = v1 + addrEphOpen = _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), iEphCur, int32(nPk)) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) + } + /* Construct a query to find the rowid or primary key for every row + ** to be deleted, based on the WHERE clause. Set variable eOnePass + ** to indicate the strategy used to implement this delete: + ** + ** ONEPASS_OFF: Two-pass approach - use a FIFO for rowids/PK values. + ** ONEPASS_SINGLE: One-pass approach - at most one row deleted. + ** ONEPASS_MULTI: One-pass approach - any number of rows may be deleted. + */ + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, uintptr(0), uintptr(0), uintptr(0), wcf, iTabCur+int32(1)) + if pWInfo == uintptr(0) { + goto delete_from_cleanup + } + eOnePass = _sqlite3WhereOkOnePass(tls, pWInfo, bp+80) + if eOnePass != int32(ONEPASS_SINGLE) { + _sqlite3MultiWrite(tls, pParse) + } + if _sqlite3WhereUsesDeferredSeek(tls, pWInfo) != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_FinishSeek), iTabCur) + } + /* Keep track of the number of rows to be deleted */ + if memCnt != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), memCnt, int32(1)) + } + /* Extract the rowid or primary key for the current row */ + if pPk != 0 { + i = 0 + for { + if !(i < int32(nPk)) { + break + } + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iTabCur, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))), iPk+i) + goto _16 + _16: + ; + i = i + 1 + } + iKey = iPk + } else { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = *(*int32)(unsafe.Pointer(v3)) + iKey = v1 + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iTabCur, -int32(1), iKey) + } + if eOnePass != ONEPASS_OFF { + /* For ONEPASS, no need to store the rowid/primary-key. There is only + ** one, so just keep it in its register(s) and fall through to the + ** delete code. */ + nKey = nPk /* OP_Found will use an unpacked key */ + aToOpen = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(nIdx+int32(2))) + if aToOpen == uintptr(0) { + _sqlite3WhereEnd(tls, pWInfo) + goto delete_from_cleanup + } + libc.X__builtin___memset_chk(tls, aToOpen, int32(1), libc.Uint64FromInt32(nIdx+int32(1)), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up(aToOpen + uintptr(nIdx+int32(1)))) = uint8(0) + if (**(**[2]int32)(__ccgo_up(bp + 80)))[0] >= 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr((**(**[2]int32)(__ccgo_up(bp + 80)))[0]-iTabCur))) = uint8(0) + } + if (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] >= 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr((**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)]-iTabCur))) = uint8(0) + } + if addrEphOpen != 0 { + _sqlite3VdbeChangeToNoop(tls, v, addrEphOpen) + } + addrBypass = _sqlite3VdbeMakeLabel(tls, pParse) + } else { + if pPk != 0 { + /* Add the PK key for this row to the temporary table */ + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = *(*int32)(unsafe.Pointer(v3)) + iKey = v1 + nKey = 0 /* Zero tells OP_Found to use a composite key */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), iPk, int32(nPk), iKey, _sqlite3IndexAffinityStr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPk), int32(nPk)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iEphCur, iKey, iPk, int32(nPk)) + } else { + /* Add the rowid of the row to be deleted to the RowSet */ + nKey = int16(1) /* OP_DeferredSeek always uses a single rowid */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowSetAdd), iRowSet, iKey) + } + _sqlite3WhereEnd(tls, pWInfo) + } + /* Unless this is a view, open cursors for the table we are + ** deleting from and all its indices. If this is a view, then the + ** only effect this statement has is to fire the INSTEAD OF + ** triggers. + */ + if !(isView != 0) { + iAddrOnce = 0 + if eOnePass == int32(ONEPASS_MULTI) { + iAddrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + _sqlite3OpenTableAndIndices(tls, pParse, pTab, int32(OP_OpenWrite), uint8(OPFLAG_FORDELETE), iTabCur, aToOpen, bp, bp+4) + if eOnePass == int32(ONEPASS_MULTI) { + _sqlite3VdbeJumpHereOrPopInst(tls, v, iAddrOnce) + } + } + /* Set up a loop over the rowids/primary-keys that were found in the + ** where-clause loop above. + */ + if eOnePass != ONEPASS_OFF { + /* OP_Found will use an unpacked key */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) && **(**Tu8)(__ccgo_up(aToOpen + uintptr(**(**int32)(__ccgo_up(bp))-iTabCur))) != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), **(**int32)(__ccgo_up(bp)), addrBypass, iKey, int32(nKey)) + } + } else { + if pPk != 0 { + addrLoop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iEphCur) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEphCur, 0, iKey) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowData), iEphCur, iKey) + } + /* OP_Found will use a composite key */ + } else { + addrLoop = _sqlite3VdbeAddOp3(tls, v, int32(OP_RowSetRead), iRowSet, 0, iKey) + } + } + /* Delete the row */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + pVTab = _sqlite3GetVTable(tls, db, pTab) + _sqlite3VtabMakeWritable(tls, pParse, pTab) + _sqlite3MayAbort(tls, pParse) + if eOnePass == int32(ONEPASS_SINGLE) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iTabCur) + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).FisMultiWrite = uint8(0) + } + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_VUpdate), 0, int32(1), iKey, pVTab, -int32(12)) + _sqlite3VdbeChangeP5(tls, v, uint16(OE_Abort)) + } else { + count = libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0) /* True to count changes */ + _sqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), iKey, nKey, libc.Uint8FromInt32(count), uint8(OE_Default), libc.Uint8FromInt32(eOnePass), (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)]) + } + /* End of the loop over all rowids/primary-keys. */ + if eOnePass != ONEPASS_OFF { + _sqlite3VdbeResolveLabel(tls, v, addrBypass) + _sqlite3WhereEnd(tls, pWInfo) + } else { + if pPk != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iEphCur, addrLoop+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addrLoop) + } else { + _sqlite3VdbeGoto(tls, v, addrLoop) + _sqlite3VdbeJumpHere(tls, v, addrLoop) + } + } + } /* End non-truncate path */ + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0) { + _sqlite3AutoincrementEnd(tls, pParse) + } + /* Return the number of rows that were deleted. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + if memCnt != 0 { + _sqlite3CodeChangeCount(tls, v, memCnt, __ccgo_ts+16789) + } + goto delete_from_cleanup +delete_from_cleanup: + ; + _sqlite3AuthContextPop(tls, bp+8) + _sqlite3SrcListDelete(tls, db, pTabList) + _sqlite3ExprDelete(tls, db, pWhere) + if aToOpen != 0 { + _sqlite3DbNNFreeNN(tls, db, aToOpen) + } + return +} + +/* Make sure "isView" and other macros defined above are undefined. Otherwise +** they may interfere with compilation of other functions in this file +** (or in another file, if this file becomes part of the amalgamation). */ + +// C documentation +// +// /* +// ** This routine will drop an existing named index. This routine +// ** implements the DROP INDEX statement. +// */ +func _sqlite3DropIndex(tls *libc.TLS, pParse uintptr, pName uintptr, ifExists int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var code, iDb int32 + var db, pIndex, pTab, v, zDb, zTab, v1 uintptr + _, _, _, _, _, _, _, _, _ = code, db, iDb, pIndex, pTab, v, zDb, zTab, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_drop_index + } + /* Never called with prior non-OOM errors */ + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto exit_drop_index + } + pIndex = _sqlite3FindIndex(tls, db, (*(*TSrcItem)(unsafe.Pointer(pName + 8))).FzName, *(*uintptr)(unsafe.Pointer(pName + 8 + 72))) + if pIndex == uintptr(0) { + if !(ifExists != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16215, libc.VaList(bp+8, pName+8)) + } else { + _sqlite3CodeVerifyNamedSchema(tls, pParse, *(*uintptr)(unsafe.Pointer(pName + 8 + 72))) + _sqlite3ForceNotReadOnly(tls, pParse) + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + goto exit_drop_index + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIndex + 100))&0x3>>0)) != SQLITE_IDXTYPE_APPDEF { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16233, libc.VaList(bp+8, 0)) + goto exit_drop_index + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIndex)).FpSchema) + code = int32(SQLITE_DROP_INDEX) + pTab = (*TIndex)(unsafe.Pointer(pIndex)).FpTable + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v1 = __ccgo_ts + 7108 + } else { + v1 = __ccgo_ts + 6628 + } + zTab = v1 + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), zTab, uintptr(0), zDb) != 0 { + goto exit_drop_index + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + code = int32(SQLITE_DROP_TEMP_INDEX) + } + if _sqlite3AuthCheck(tls, pParse, code, (*TIndex)(unsafe.Pointer(pIndex)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, zDb) != 0 { + goto exit_drop_index + } + /* Generate code to remove the index and from the schema table */ + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+16306, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TIndex)(unsafe.Pointer(pIndex)).FzName)) + _sqlite3ClearStatTables(tls, pParse, iDb, __ccgo_ts+13388, (*TIndex)(unsafe.Pointer(pIndex)).FzName) + _sqlite3ChangeCookie(tls, pParse, iDb) + _destroyRootPage(tls, pParse, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIndex)).Ftnum), iDb) + _sqlite3VdbeAddOp4(tls, v, int32(OP_DropIndex), iDb, 0, 0, (*TIndex)(unsafe.Pointer(pIndex)).FzName, 0) + } + goto exit_drop_index +exit_drop_index: + ; + _sqlite3SrcListDelete(tls, db, pName) +} + +// C documentation +// +// /* +// ** This routine is called to do the work of a DROP TABLE statement. +// ** pName is the name of the table to be dropped. +// */ +func _sqlite3DropTable(tls *libc.TLS, pParse uintptr, pName uintptr, isView int32, noErr int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var code, iDb int32 + var db, pTab, v, zArg2, zDb, zTab, v1 uintptr + _, _, _, _, _, _, _, _, _ = code, db, iDb, pTab, v, zArg2, zDb, zTab, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_drop_table + } + if _sqlite3ReadSchema(tls, pParse) != 0 { + goto exit_drop_table + } + if noErr != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr = (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr + 1 + } + pTab = _sqlite3LocateTableItem(tls, pParse, libc.Uint32FromInt32(isView), pName+8) + if noErr != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr = (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr - 1 + } + if pTab == uintptr(0) { + if noErr != 0 { + _sqlite3CodeVerifyNamedSchema(tls, pParse, *(*uintptr)(unsafe.Pointer(pName + 8 + 72))) + _sqlite3ForceNotReadOnly(tls, pParse) + } + goto exit_drop_table + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + /* If pTab is a virtual table, call ViewGetColumnNames() to ensure + ** it is initialized. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) && _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto exit_drop_table + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v1 = __ccgo_ts + 7108 + } else { + v1 = __ccgo_ts + 6628 + } + zTab = v1 + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + zArg2 = uintptr(0) + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), zTab, uintptr(0), zDb) != 0 { + goto exit_drop_table + } + if isView != 0 { + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + code = int32(SQLITE_DROP_TEMP_VIEW) + } else { + code = int32(SQLITE_DROP_VIEW) + } + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + code = int32(SQLITE_DROP_VTABLE) + zArg2 = (*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer(_sqlite3GetVTable(tls, db, pTab))).FpMod)).FzName + } else { + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + code = int32(SQLITE_DROP_TEMP_TABLE) + } else { + code = int32(SQLITE_DROP_TABLE) + } + } + } + if _sqlite3AuthCheck(tls, pParse, code, (*TTable)(unsafe.Pointer(pTab)).FzName, zArg2, zDb) != 0 { + goto exit_drop_table + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0), zDb) != 0 { + goto exit_drop_table + } + if _tableMayNotBeDropped(tls, db, pTab) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15421, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_drop_table + } + /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used + ** on a table. + */ + if isView != 0 && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VIEW)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15449, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_drop_table + } + if !(isView != 0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15483, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_drop_table + } + /* Generate code to remove the table from the schema table + ** on disk. + */ + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + if !(isView != 0) { + _sqlite3ClearStatTables(tls, pParse, iDb, __ccgo_ts+13392, (*TTable)(unsafe.Pointer(pTab)).FzName) + _sqlite3FkDropTable(tls, pParse, pName, pTab) + } + _sqlite3CodeDropTable(tls, pParse, pTab, iDb, isView) + } + goto exit_drop_table +exit_drop_table: + ; + _sqlite3SrcListDelete(tls, db, pName) +} + +// C documentation +// +// /* +// ** This function is called to drop a trigger from the database schema. +// ** +// ** This may be called directly from the parser and therefore identifies +// ** the trigger by name. The sqlite3DropTriggerPtr() routine does the +// ** same job as this routine except it takes a pointer to the trigger +// ** instead of the trigger name. +// **/ +func _sqlite3DropTrigger(tls *libc.TLS, pParse uintptr, pName uintptr, noErr int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pTrigger, zDb, zName uintptr + var i, j, v2 int32 + _, _, _, _, _, _, _ = db, i, j, pTrigger, zDb, zName, v2 + pTrigger = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto drop_trigger_cleanup + } + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto drop_trigger_cleanup + } + zDb = *(*uintptr)(unsafe.Pointer(pName + 8 + 72)) + zName = (*(*TSrcItem)(unsafe.Pointer(pName + 8))).FzName + i = OMIT_TEMPDB + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if i < int32(2) { + v2 = i ^ int32(1) + } else { + v2 = i + } + j = v2 /* Search TEMP before MAIN */ + if zDb != 0 && _sqlite3DbIsNamed(tls, db, j, zDb) == 0 { + goto _1 + } + pTrigger = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*32))).FpSchema+56, zName) + if pTrigger != 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if !(pTrigger != 0) { + if !(noErr != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22729, libc.VaList(bp+8, pName+8)) + } else { + _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + goto drop_trigger_cleanup + } + _sqlite3DropTriggerPtr(tls, pParse, pTrigger) + goto drop_trigger_cleanup +drop_trigger_cleanup: + ; + _sqlite3SrcListDelete(tls, db, pName) +} + +// C documentation +// +// /* +// ** Drop a trigger given a pointer to that trigger. +// */ +func _sqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var code, iDb int32 + var db, pTable, v, zDb, zTab, v1 uintptr + _, _, _, _, _, _, _, _ = code, db, iDb, pTable, v, zDb, zTab, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema) + pTable = _tableOfTrigger(tls, pTrigger) + if pTable != 0 { + code = int32(SQLITE_DROP_TRIGGER) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v1 = __ccgo_ts + 7108 + } else { + v1 = __ccgo_ts + 6628 + } + zTab = v1 + if iDb == int32(1) { + code = int32(SQLITE_DROP_TEMP_TRIGGER) + } + if _sqlite3AuthCheck(tls, pParse, code, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName, (*TTable)(unsafe.Pointer(pTable)).FzName, zDb) != 0 || _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), zTab, uintptr(0), zDb) != 0 { + return + } + } + /* Generate code to destroy the database record of the trigger. + */ + v1 = _sqlite3GetVdbe(tls, pParse) + v = v1 + if v1 != uintptr(0) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+22749, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName)) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddOp4(tls, v, int32(OP_DropTrigger), iDb, 0, 0, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName, 0) + } +} + +// C documentation +// +// /* +// ** This routine is called to report the final ")" that terminates +// ** a CREATE TABLE statement. +// ** +// ** The table structure that other action routines have been building +// ** is added to the internal hash tables, assuming no errors have +// ** occurred. +// ** +// ** An entry for the table is made in the schema table on disk, unless +// ** this is a temporary table or db->init.busy==1. When db->init.busy==1 +// ** it means we are reading the sqlite_schema table because we just +// ** connected to the database or because the sqlite_schema table has +// ** recently changed, so the entry for this table already exists in +// ** the sqlite_schema table. We do not want to create it again. +// ** +// ** If the pSelect argument is not NULL, it means that this routine +// ** was called to create a table generated from a +// ** "CREATE TABLE ... AS SELECT ..." statement. The column names of +// ** the new table will match the result set of the SELECT. +// */ +func _sqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr, tabOpts Tu32, pSelect uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var addrInsLoop, addrTop, iCsr, iDb, ii, ii1, n, nNG, regRec, regRowid, regYield, v4 int32 + var colFlags Tu32 + var db, p, pCol, pDb, pEnd2, pIdx, pOld, pSchema, pSelTab, pX, v, zStmt, zType, zType2, v5 uintptr + var v12 Ti16 + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrInsLoop, addrTop, colFlags, db, iCsr, iDb, ii, ii1, n, nNG, p, pCol, pDb, pEnd2, pIdx, pOld, pSchema, pSelTab, pX, regRec, regRowid, regYield, v, zStmt, zType, zType2, v12, v4, v5 /* The new table */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* An implied index of the table */ + if pEnd == uintptr(0) && pSelect == uintptr(0) { + return + } + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) { + return + } + if pSelect == uintptr(0) && _sqlite3ShadowTableName(tls, db, (*TTable)(unsafe.Pointer(p)).FzName) != 0 { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Shadow) + } + /* If the db->init.busy is 1 it means we are reading the SQL off the + ** "sqlite_schema" or "sqlite_temp_schema" table on the disk. + ** So do not write to the disk again. Extract the root page number + ** for the table from the db->init.newTnum field. (The page number + ** should have been put there by the sqliteOpenCb routine.) + ** + ** If the root page number is 1, that means this is the sqlite_schema + ** table itself. So mark it read-only. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + if pSelect != 0 || !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) && (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1702, 0) + return + } + (*TTable)(unsafe.Pointer(p)).Ftnum = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum + if (*TTable)(unsafe.Pointer(p)).Ftnum == uint32(1) { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Readonly) + } + } + /* Special processing for tables that include the STRICT keyword: + ** + ** * Do not allow custom column datatypes. Every column must have + ** a datatype that is one of INT, INTEGER, REAL, TEXT, or BLOB. + ** + ** * If a PRIMARY KEY is defined, other than the INTEGER PRIMARY KEY, + ** then all columns of the PRIMARY KEY must have a NOT NULL + ** constraint. + */ + if tabOpts&uint32(TF_Strict) != 0 { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Strict) + ii = 0 + for { + if !(ii < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr(ii)*16 + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == COLTYPE_CUSTOM { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14740, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, _sqlite3ColumnType(tls, pCol, __ccgo_ts+1702))) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14773, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + } + return + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == int32(COLTYPE_ANY) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = int8(SQLITE_AFF_BLOB) + } + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 && int32((*TTable)(unsafe.Pointer(p)).FiPKey) != ii && int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) == OE_None { + libc.SetBitFieldPtr8Uint32(pCol+8, libc.Uint32FromInt32(OE_Abort), 0, 0xf) + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_HasNotNull) + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + /* Special processing for WITHOUT ROWID Tables */ + if tabOpts&uint32(TF_WithoutRowid) != 0 { + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_Autoincrement) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14800, 0) + return + } + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasPrimaryKey) == uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14850, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName)) + return + } + **(**Tu32)(__ccgo_up(p + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid) | libc.Int32FromInt32(TF_NoVisibleRowid)) + _convertToWithoutRowidTable(tls, pParse, p) + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(p)).FpSchema) + /* Resolve names in all CHECK constraint expressions. + */ + if (*TTable)(unsafe.Pointer(p)).FpCheck != 0 { + _sqlite3ResolveSelfReference(tls, pParse, p, int32(NC_IsCheck), uintptr(0), (*TTable)(unsafe.Pointer(p)).FpCheck) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + /* If errors are seen, delete the CHECK constraints now, else they might + ** actually be used if PRAGMA writable_schema=ON is set. */ + _sqlite3ExprListDelete(tls, db, (*TTable)(unsafe.Pointer(p)).FpCheck) + (*TTable)(unsafe.Pointer(p)).FpCheck = uintptr(0) + } else { + } + } + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasGenerated) != 0 { + nNG = 0 + ii1 = 0 + for { + if !(ii1 < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + colFlags = uint32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(ii1)*16))).FcolFlags) + if colFlags&uint32(COLFLAG_GENERATED) != uint32(0) { + pX = _sqlite3ColumnExpr(tls, p, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(ii1)*16) + if _sqlite3ResolveSelfReference(tls, pParse, p, int32(NC_GenCol), pX, uintptr(0)) != 0 { + /* If there are errors in resolving the expression, change the + ** expression to a NULL. This prevents code generators that operate + ** on the expression from inserting extra parts into the expression + ** tree that have been allocated from lookaside memory, which is + ** illegal in a schema and will lead to errors or heap corruption + ** when the database connection closes. */ + _sqlite3ColumnSetExpr(tls, pParse, p, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(ii1)*16, _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0)) + } + } else { + nNG = nNG + 1 + } + goto _2 + _2: + ; + ii1 = ii1 + 1 + } + if nNG == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14882, 0) + return + } + } + /* Estimate the average row size for the table and for all implied indices */ + _estimateTableWidth(tls, p) + pIdx = (*TTable)(unsafe.Pointer(p)).FpIndex + for { + if !(pIdx != 0) { + break + } + _estimateIndexWidth(tls, pIdx) + goto _3 + _3: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + /* If not initializing, then create a record for the new table + ** in the schema table of the database. + ** + ** If this is a TEMPORARY table, write the entry into the auxiliary + ** file instead of into the main database file. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { /* Text of the CREATE TABLE or CREATE VIEW statement */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + return + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), 0) + /* + ** Initialize zType for the new view or table. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM { + /* A regular table */ + zType = __ccgo_ts + 9721 + zType2 = __ccgo_ts + 14926 + } else { + /* A view */ + zType = __ccgo_ts + 11459 + zType2 = __ccgo_ts + 14932 + } + /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT + ** statement to populate the new table. The root-page number for the + ** new table is in register pParse->u1.cr.regRoot. + ** + ** Once the SELECT has been coded by sqlite3Select(), it is in a + ** suitable state to query for the column names and types to be used + ** by the new table. + ** + ** A shared-cache write-lock is not required to write to the new table, + ** as a schema-lock must have already been obtained to create it. Since + ** a schema-lock excludes all other database users, the write-lock would + ** be redundant. + */ + if pSelect != 0 { /* Write cursor on the new table */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + return + } + v5 = pParse + 56 + v4 = *(*int32)(unsafe.Pointer(v5)) + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + iCsr = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regYield = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regRec = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regRowid = v4 + _sqlite3MayAbort(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenWrite), iCsr, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot, iDb) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_P2ISREG)) + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, addrTop) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + pSelTab = _sqlite3ResultSetOfSelect(tls, pParse, pSelect, int8(SQLITE_AFF_BLOB)) + if pSelTab == uintptr(0) { + return + } + v12 = (*TTable)(unsafe.Pointer(pSelTab)).FnCol + (*TTable)(unsafe.Pointer(p)).FnNVCol = v12 + (*TTable)(unsafe.Pointer(p)).FnCol = v12 + (*TTable)(unsafe.Pointer(p)).FaCol = (*TTable)(unsafe.Pointer(pSelTab)).FaCol + (*TTable)(unsafe.Pointer(pSelTab)).FnCol = 0 + (*TTable)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) + _sqlite3DeleteTable(tls, db, pSelTab) + _sqlite3SelectDestInit(tls, bp, int32(SRT_Coroutine), regYield) + _sqlite3Select(tls, pParse, pSelect, bp) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + _sqlite3VdbeEndCoroutine(tls, v, regYield) + _sqlite3VdbeJumpHere(tls, v, addrTop-int32(1)) + addrInsLoop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (**(**TSelectDest)(__ccgo_up(bp))).FiSdst, (**(**TSelectDest)(__ccgo_up(bp))).FnSdst, regRec) + _sqlite3TableAffinity(tls, v, p, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iCsr, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iCsr, regRec, regRowid) + _sqlite3VdbeGoto(tls, v, addrInsLoop) + _sqlite3VdbeJumpHere(tls, v, addrInsLoop) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iCsr) + } + /* Compute the complete text of the CREATE statement */ + if pSelect != 0 { + zStmt = _createTableStmt(tls, db, p) + } else { + if tabOpts != 0 { + v5 = pParse + 280 + } else { + v5 = pEnd + } + pEnd2 = v5 + n = int32(int64((*TToken)(unsafe.Pointer(pEnd2)).Fz) - int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + if int32(**(**int8)(__ccgo_up((*TToken)(unsafe.Pointer(pEnd2)).Fz))) != int32(';') { + n = libc.Int32FromUint32(uint32(n) + (*TToken)(unsafe.Pointer(pEnd2)).Fn) + } + zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+14937, libc.VaList(bp+48, zType2, n, (*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + } + /* A slot for the record has already been allocated in the + ** schema table. We just need to update that slot with all + ** the information we've collected. + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+14952, libc.VaList(bp+48, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zType, (*TTable)(unsafe.Pointer(p)).FzName, (*TTable)(unsafe.Pointer(p)).FzName, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot, zStmt, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRowid)) + _sqlite3DbFree(tls, db, zStmt) + _sqlite3ChangeCookie(tls, pParse, iDb) + /* Check to see if we need to create an sqlite_sequence table for + ** keeping track of autoincrement keys. + */ + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_Autoincrement) != uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != libc.Int32FromInt32(PARSE_MODE_NORMAL)) { + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + if (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab == uintptr(0) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+15050, libc.VaList(bp+48, (*TDb)(unsafe.Pointer(pDb)).FzDbSName)) + } + } + /* Reparse everything to update our internal data structures */ + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+15092, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName)), uint16(0)) + /* Test for cycles in generated columns and illegal expressions + ** in CHECK constraints and in DEFAULT clauses. */ + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasGenerated) != 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_SqlExec), int32(0x0001), 0, 0, _sqlite3MPrintf(tls, db, __ccgo_ts+15126, libc.VaList(bp+48, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(p)).FzName)), -int32(7)) + } + } + /* Add the table to the in-memory representation of the database. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + pSchema = (*TTable)(unsafe.Pointer(p)).FpSchema + pOld = _sqlite3HashInsert(tls, pSchema+8, (*TTable)(unsafe.Pointer(p)).FzName, p) + if pOld != 0 { + /* Malloc must have failed inside HashInsert() */ + _sqlite3OomFault(tls, db) + return + } + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + /* If this is the magic sqlite_sequence table used by autoincrement, + ** then record a pointer to this table in the main database structure + ** so that INSERT can find the table easily. */ + if libc.Xstrcmp(tls, (*TTable)(unsafe.Pointer(p)).FzName, __ccgo_ts+10243) == 0 { + (*TSchema)(unsafe.Pointer((*TTable)(unsafe.Pointer(p)).FpSchema)).FpSeqTab = p + } + } + if !(pSelect != 0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM { + if (*TToken)(unsafe.Pointer(pCons)).Fz == uintptr(0) { + pCons = pEnd + } + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FaddColOffset = int32(13) + int32(int64((*TToken)(unsafe.Pointer(pCons)).Fz)-int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + } +} + +// C documentation +// +// /* +// ** Generate VDBE code for a COMMIT or ROLLBACK statement. +// ** Code for ROLLBACK is generated if eType==TK_ROLLBACK. Otherwise +// ** code is generated for a COMMIT. +// */ +func _sqlite3EndTransaction(tls *libc.TLS, pParse uintptr, eType int32) { + var isRollback int32 + var v, v1 uintptr + _, _, _ = isRollback, v, v1 + isRollback = libc.BoolInt32(eType == int32(TK_ROLLBACK)) + if isRollback != 0 { + v1 = __ccgo_ts + 16453 + } else { + v1 = __ccgo_ts + 16462 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_TRANSACTION), v1, uintptr(0), uintptr(0)) != 0 { + return + } + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AutoCommit), int32(1), isRollback) + } +} + +// C documentation +// +// /* +// ** Return a static string that describes the kind of error specified in the +// ** argument. +// */ +func _sqlite3ErrStr(tls *libc.TLS, rc int32) (r uintptr) { + var zErr uintptr + _ = zErr + zErr = __ccgo_ts + 26156 + switch rc { + case libc.Int32FromInt32(SQLITE_ABORT) | libc.Int32FromInt32(2)<= 0 && rc < libc.Int32FromUint64(libc.Uint64FromInt64(232)/libc.Uint64FromInt64(8)) && _aMsg[rc] != uintptr(0) { + zErr = _aMsg[rc] + } + break + } + return zErr +} + +// C documentation +// +// /* +// ** Write code that will raise an error if the table described by +// ** zDb and zTab is not empty. +// */ +func _sqlite3ErrorIfNotEmpty(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zErr uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10595, libc.VaList(bp+8, zErr, zDb, zTab)) +} + +// C documentation +// +// /* +// ** The SrcItem structure passed as the second argument represents a +// ** sub-query in the FROM clause of a SELECT statement. This function +// ** allocates and populates the SrcItem.pTab object. If successful, +// ** SQLITE_OK is returned. Otherwise, if an OOM error is encountered, +// ** SQLITE_NOMEM. +// */ +func _sqlite3ExpandSubquery(tls *libc.TLS, pParse uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pSel, pTab, v1 uintptr + var v2 int32 + _, _, _, _ = pSel, pTab, v1, v2 + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + v1 = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(120)) + pTab = v1 + (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab = v1 + if pTab == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = uint32(1) + if (*TSrcItem)(unsafe.Pointer(pFrom)).FzAlias != 0 { + (*TTable)(unsafe.Pointer(pTab)).FzName = _sqlite3DbStrDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TSrcItem)(unsafe.Pointer(pFrom)).FzAlias) + } else { + (*TTable)(unsafe.Pointer(pTab)).FzName = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+21602, libc.VaList(bp+8, pFrom)) + } + for (*TSelect)(unsafe.Pointer(pSel)).FpPrior != 0 { + pSel = (*TSelect)(unsafe.Pointer(pSel)).FpPrior + } + _sqlite3ColumnsFromExprList(tls, pParse, (*TSelect)(unsafe.Pointer(pSel)).FpEList, pTab+54, pTab+8) + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(-int32(1)) + (*TTable)(unsafe.Pointer(pTab)).FeTabType = uint8(TABTYP_VIEW) + (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) + /* The usual case - do not allow ROWID on a subquery */ + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TF_Ephemeral) | libc.Int32FromInt32(TF_NoVisibleRowid)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = SQLITE_OK + } + return v2 +} + +// C documentation +// +// /* +// ** Attach an ORDER BY clause to a function call. +// ** +// ** functionname( arguments ORDER BY sortlist ) +// ** \_____________________/ \______/ +// ** pExpr pOrderBy +// ** +// ** The ORDER BY clause is inserted into a new Expr node of type TK_ORDER +// ** and added to the Expr.pLeft field of the parent TK_FUNCTION node. +// */ +func _sqlite3ExprAddFunctionOrderBy(tls *libc.TLS, pParse uintptr, pExpr uintptr, pOrderBy uintptr) { + var db, pOB uintptr + _, _ = db, pOB + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pOrderBy == uintptr(0) { + return + } + if pExpr == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pOrderBy) + return + } + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) == uintptr(0) || (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr == 0 { + /* Ignore ORDER BY on zero-argument aggregates */ + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprListDeleteGeneric), pOrderBy) + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FeFrmType) != int32(TK_FILTER) { + _sqlite3ExprOrderByAggregateError(tls, pParse, pExpr) + _sqlite3ExprListDelete(tls, db, pOrderBy) + return + } + if (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7969, 0) + _sqlite3ExprListDelete(tls, db, pOrderBy) + return + } + pOB = _sqlite3ExprAlloc(tls, db, int32(TK_ORDER), uintptr(0), 0) + if pOB == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pOrderBy) + return + } + *(*uintptr)(unsafe.Pointer(pOB + 32)) = pOrderBy + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = pOB + **(**Tu32)(__ccgo_up(pOB + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FullSize)) +} + +// C documentation +// +// /* +// ** This routine is the core allocator for Expr nodes. +// ** +// ** Construct a new expression node and return a pointer to it. Memory +// ** for this node and for the pToken argument is a single allocation +// ** obtained from sqlite3DbMalloc(). The calling function +// ** is responsible for making sure the node eventually gets freed. +// ** +// ** If dequote is true, then the token (if it exists) is dequoted. +// ** If dequote is false, no dequoting is performed. The deQuote +// ** parameter is ignored if pToken is NULL or if the token does not +// ** appear to be quoted. If the quotes were of the form "..." (double-quotes) +// ** then the EP_DblQuoted flag is set on the expression node. +// ** +// ** Special case (tag-20240227-a): If op==TK_INTEGER and pToken points to +// ** a string that can be translated into a 32-bit integer, then the token is +// ** not stored in u.zToken. Instead, the integer values is written +// ** into u.iValue and the EP_IntValue flag is set. No extra storage +// ** is allocated to hold the integer text and the dequote flag is ignored. +// ** See also tag-20240227-b. +// */ +func _sqlite3ExprAlloc(tls *libc.TLS, db uintptr, op int32, pToken uintptr, dequote int32) (r uintptr) { + var nExtra int32 + var pNew uintptr + var v1 uint32 + _, _, _ = nExtra, pNew, v1 + if pToken != 0 { + v1 = (*TToken)(unsafe.Pointer(pToken)).Fn + uint32(1) + } else { + v1 = uint32(0) + } + nExtra = libc.Int32FromUint32(v1) + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(72)+libc.Uint64FromInt32(nExtra))) + if pNew != 0 { + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(72), ^t__predefined_size_t(0)) + (*TExpr)(unsafe.Pointer(pNew)).Fop = libc.Uint8FromInt32(op) + (*TExpr)(unsafe.Pointer(pNew)).FiAgg = int16(-int32(1)) + if nExtra != 0 { + *(*uintptr)(unsafe.Pointer(pNew + 8)) = pNew + 1*72 + if (*TToken)(unsafe.Pointer(pToken)).Fn != 0 { + libc.X__builtin___memcpy_chk(tls, *(*uintptr)(unsafe.Pointer(pNew + 8)), (*TToken)(unsafe.Pointer(pToken)).Fz, uint64((*TToken)(unsafe.Pointer(pToken)).Fn), ^t__predefined_size_t(0)) + } + **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pNew + 8)) + uintptr((*TToken)(unsafe.Pointer(pToken)).Fn))) = 0 + if dequote != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pNew + 8)))))])&int32(0x80) != 0 { + _sqlite3DequoteExpr(tls, pNew) + } + } + (*TExpr)(unsafe.Pointer(pNew)).FnHeight = int32(1) + } + return pNew +} + +// C documentation +// +// /* +// ** Assign a variable number to an expression that encodes a wildcard +// ** in the original SQL statement. +// ** +// ** Wildcards consisting of a single "?" are assigned the next sequential +// ** variable number. +// ** +// ** Wildcards of the form "?nnn" are assigned the number "nnn". We make +// ** sure "nnn" is not too big to avoid a denial of service attack when +// ** the SQL statement comes from an external source. +// ** +// ** Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number +// ** as the previous instance of the same wildcard. Or if this is the first +// ** instance of the wildcard, the next sequential variable number is +// ** assigned. +// */ +func _sqlite3ExprAssignVarNumber(tls *libc.TLS, pParse uintptr, pExpr uintptr, n Tu32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOk, doAdd int32 + var db, z, v2 uintptr + var x, v1 TynVar + var _ /* i at bp+0 */ Ti64 + _, _, _, _, _, _, _ = bOk, db, doAdd, x, z, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pExpr == uintptr(0) { + return + } + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + if int32(**(**int8)(__ccgo_up(z + 1))) == 0 { + /* Wildcard of the form "?". Assign the next variable number */ + v2 = pParse + 296 + *(*TynVar)(unsafe.Pointer(v2)) = *(*TynVar)(unsafe.Pointer(v2)) + 1 + v1 = *(*TynVar)(unsafe.Pointer(v2)) + x = v1 + } else { + doAdd = 0 + if int32(**(**int8)(__ccgo_up(z))) == int32('?') { + if n == uint32(2) { /*OPTIMIZATION-IF-TRUE*/ + **(**Ti64)(__ccgo_up(bp)) = int64(int32(**(**int8)(__ccgo_up(z + 1))) - int32('0')) /* The common case of ?N for a single digit N */ + bOk = int32(1) + } else { + bOk = libc.BoolInt32(0 == _sqlite3Atoi64(tls, z+1, bp, libc.Int32FromUint32(n-uint32(1)), uint8(SQLITE_UTF8))) + } + if bOk == 0 || **(**Ti64)(__ccgo_up(bp)) < int64(1) || **(**Ti64)(__ccgo_up(bp)) > int64(**(**int32)(__ccgo_up(db + 136 + 9*4))) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8403, libc.VaList(bp+16, **(**int32)(__ccgo_up(db + 136 + 9*4)))) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + return + } + x = int16(**(**Ti64)(__ccgo_up(bp))) + if int32(x) > int32((*TParse)(unsafe.Pointer(pParse)).FnVar) { + (*TParse)(unsafe.Pointer(pParse)).FnVar = int16(int32(x)) + doAdd = int32(1) + } else { + if _sqlite3VListNumToName(tls, (*TParse)(unsafe.Pointer(pParse)).FpVList, int32(x)) == uintptr(0) { + doAdd = int32(1) + } + } + } else { + /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable + ** number as the prior appearance of the same name, or if the name + ** has never appeared before, reuse the same variable number + */ + x = int16(_sqlite3VListNameToNum(tls, (*TParse)(unsafe.Pointer(pParse)).FpVList, z, libc.Int32FromUint32(n))) + if int32(x) == 0 { + v2 = pParse + 296 + *(*TynVar)(unsafe.Pointer(v2)) = *(*TynVar)(unsafe.Pointer(v2)) + 1 + v1 = *(*TynVar)(unsafe.Pointer(v2)) + x = v1 + doAdd = int32(1) + } + } + if doAdd != 0 { + (*TParse)(unsafe.Pointer(pParse)).FpVList = _sqlite3VListAdd(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpVList, z, libc.Int32FromUint32(n), int32(x)) + } + } + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = x + if int32(x) > **(**int32)(__ccgo_up(db + 136 + 9*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8446, 0) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + } +} + +// C documentation +// +// /* +// ** Return TRUE if expression pExpr is able to return a subtype. +// ** +// ** A TRUE return does not guarantee that a subtype will be returned. +// ** It only indicates that a subtype return is possible. False positives +// ** are acceptable as they only disable an optimization. False negatives, +// ** on the other hand, can lead to incorrect answers. +// */ +func _sqlite3ExprCanReturnSubtype(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprNodeCanReturnSubtype) + _sqlite3WalkExpr(tls, bp, pExpr) + return libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) +} + +// C documentation +// +// /* +// ** Check that argument nHeight is less than or equal to the maximum +// ** expression depth allowed. If it is not, leave an error message in +// ** pParse. +// */ +func _sqlite3ExprCheckHeight(tls *libc.TLS, pParse uintptr, nHeight int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var mxHeight, rc int32 + _, _ = mxHeight, rc + rc = SQLITE_OK + mxHeight = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 3*4)) + if nHeight > mxHeight { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8205, libc.VaList(bp+8, mxHeight)) + rc = int32(SQLITE_ERROR) + } + return rc +} + +// C documentation +// +// /* +// ** Generate code to extract the value of the iCol-th column of a table. +// */ +func _sqlite3ExprCodeGetColumnOfTable(tls *libc.TLS, v uintptr, pTab uintptr, iTabCur int32, iCol int32, regOut int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var op, savedSelfTab, x int32 + var pCol, pParse, v1 uintptr + _, _, _, _, _, _ = op, pCol, pParse, savedSelfTab, x, v1 + if iCol < 0 || iCol == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iTabCur, regOut) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + op = int32(OP_VColumn) + x = iCol + } else { + v1 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + pCol = v1 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(v1)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + pParse = _sqlite3VdbeParser(tls, v) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_BUSY) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8796, libc.VaList(bp+8, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + } else { + savedSelfTab = (*TParse)(unsafe.Pointer(pParse)).FiSelfTab + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_BUSY)) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = iTabCur + int32(1) + _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab, pCol, regOut) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = savedSelfTab + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(COLFLAG_BUSY)) + } + return + } else { + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + x = _sqlite3TableColumnToIndex(tls, _sqlite3PrimaryKeyIndex(tls, pTab), iCol) + op = int32(OP_Column) + } else { + x = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + op = int32(OP_Column) + } + } + } + _sqlite3VdbeAddOp3(tls, v, op, iTabCur, x, regOut) + _sqlite3ColumnDefault(tls, v, pTab, iCol, regOut) + } +} + +// C documentation +// +// /* +// ** Generate code into the current Vdbe to evaluate the given +// ** expression. Attempt to store the results in register "target". +// ** Return the register where results are stored. +// ** +// ** With this routine, there is no guarantee that results will +// ** be stored in target. The result might be stored in some other +// ** register if it is convenient to do so. The calling function +// ** must check the return code and move the results to the desired +// ** register. +// */ +func _sqlite3ExprCodeTarget(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) (r int32) { + bp := tls.Alloc(192) + defer tls.Free(192) + var aListelem, db, db1, pAggInfo, pAggInfo1, pCol, pCol1, pColl, pDef, pDel, pEList, pFarg, pInfo, pLeft, pLeft1, pLeft2, pTab, pTab1, pTab2, pTest, pX, v, z, zBlob, zId, v3 uintptr + var addr, addrINR, addrIsNull, addrIsNull1, aff, bNormal, destIfFalse, destIfNull, endLabel, i, i1, iCol, iCol1, iReg, iSrc, iTab, inReg, isTrue, n, n1, nCol, nExpr, nFarg, nextCase, op, p1, p5, v1 int32 + var constMask Tu32 + var enc, exprOp, okConstFactor Tu8 + var v2 bool + var _ /* opCompare at bp+88 */ TExpr + var _ /* r1 at bp+8 */ int32 + var _ /* r2 at bp+12 */ int32 + var _ /* regFree1 at bp+0 */ int32 + var _ /* regFree2 at bp+4 */ int32 + var _ /* tempX at bp+16 */ TExpr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aListelem, addr, addrINR, addrIsNull, addrIsNull1, aff, bNormal, constMask, db, db1, destIfFalse, destIfNull, enc, endLabel, exprOp, i, i1, iCol, iCol1, iReg, iSrc, iTab, inReg, isTrue, n, n1, nCol, nExpr, nFarg, nextCase, okConstFactor, op, p1, p5, pAggInfo, pAggInfo1, pCol, pCol1, pColl, pDef, pDel, pEList, pFarg, pInfo, pLeft, pLeft1, pLeft2, pTab, pTab1, pTab2, pTest, pX, v, z, zBlob, zId, v1, v2, v3 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* The opcode being coded */ + inReg = target /* Results stored in register inReg */ + **(**int32)(__ccgo_up(bp)) = 0 /* If non-zero free this temporary register */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* Temporary expression node */ + p5 = 0 + goto expr_code_doover +expr_code_doover: + ; + if pExpr == uintptr(0) { + op = int32(TK_NULL) + } else { + if v2 = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr != uintptr(0) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)); v2 { + v1 = _sqlite3IndexedExprLookup(tls, pParse, pExpr, target) + **(**int32)(__ccgo_up(bp + 8)) = v1 + } + if v2 && v1 >= 0 { + return **(**int32)(__ccgo_up(bp + 8)) + } else { + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + } + } + switch op { + case int32(TK_AGG_COLUMN): + pAggInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn { + /* Happens when the left table of a RIGHT JOIN is null and + ** is using an expression index */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + break + } + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32 + if !((*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode != 0) { + return (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + } else { + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx != 0 { + pTab = (*TAggInfo_col)(unsafe.Pointer(pCol)).FpTab + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab, (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn, target) + if pTab == uintptr(0) { + /* No comment added */ + } else { + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn < 0 { + } else { + if int32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + } + } + } + return target + } else { + if *(*uintptr)(unsafe.Pointer(pExpr + 64)) == uintptr(0) { + /* This case happens when the argument to an aggregate function + ** is rewritten by aggregateConvertIndexedExprRefToColumn() */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), target) + return target + } + } + } + /* Otherwise, fall thru into the TK_COLUMN case */ + fallthrough + case int32(TK_COLUMN): + iTab = (*TExpr)(unsafe.Pointer(pExpr)).FiTable + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != uint32(0) { + iReg = _sqlite3ExprCodeTarget(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + aff = int32(_sqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn))) + if aff > int32(SQLITE_AFF_BLOB) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), iReg, int32(1), 0, uintptr(unsafe.Pointer(&_zAff))+uintptr((aff-int32('B'))*int32(2)), -int32(1)) + } + return iReg + } + if iTab < 0 { + if (*TParse)(unsafe.Pointer(pParse)).FiSelfTab < 0 { + iCol = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + pTab1 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + if iCol < 0 { + return -int32(1) - (*TParse)(unsafe.Pointer(pParse)).FiSelfTab + } + pCol1 = (*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(iCol)*16 + iSrc = int32(_sqlite3TableColumnToStorage(tls, pTab1, int16(iCol))) - (*TParse)(unsafe.Pointer(pParse)).FiSelfTab + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_BUSY) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8796, libc.VaList(bp+168, (*TColumn)(unsafe.Pointer(pCol1)).FzCnName)) + return 0 + } + v3 = pCol1 + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(COLFLAG_BUSY)) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_NOTAVAIL) != 0 { + _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab1, pCol1, iSrc) + } + v3 = pCol1 + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(COLFLAG_BUSY) | libc.Int32FromInt32(COLFLAG_NOTAVAIL))) + return iSrc + } else { + if int32((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), iSrc, target) + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + return target + } else { + return iSrc + } + } + } else { + /* Coding an expression that is part of an index where column names + ** in the index refer to the table to which the index belongs */ + iTab = (*TParse)(unsafe.Pointer(pParse)).FiSelfTab - int32(1) + } + } else { + if v2 = (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr != 0; v2 { + v1 = _exprPartidxExprLookup(tls, pParse, pExpr, target) + **(**int32)(__ccgo_up(bp + 8)) = v1 + } + if v2 && 0 != v1 { + return **(**int32)(__ccgo_up(bp + 8)) + } + } + iReg = _sqlite3ExprCodeGetColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), iTab, target, (*TExpr)(unsafe.Pointer(pExpr)).Fop2) + return iReg + case int32(TK_INTEGER): + _codeInteger(tls, pParse, pExpr, 0, target) + return target + case int32(TK_TRUEFALSE): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprTruthValue(tls, pExpr), target) + return target + case int32(TK_FLOAT): + _codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pExpr + 8)), 0, target) + return target + case int32(TK_STRING): + _sqlite3VdbeLoadString(tls, v, target, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + return target + case int32(TK_NULLS): + /* Set a range of registers to NULL. pExpr->y.nReg registers starting + ** with target */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, target, target+*(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fy))-int32(1)) + return target + default: + /* Make NULL the default case so that if a bug causes an illegal + ** Expr node to be passed into this function, it will be handled + ** sanely and not crash. But keep the assert() to bring the problem + ** to the attention of the developers. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + return target + case int32(TK_BLOB): + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + 2 + n = _sqlite3Strlen30(tls, z) - int32(1) + zBlob = _sqlite3HexToBlob(tls, _sqlite3VdbeDb(tls, v), z, n) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Blob), n/int32(2), target, 0, zBlob, -int32(7)) + return target + case int32(TK_VARIABLE): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Variable), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), target) + return target + case int32(TK_REGISTER): + return (*TExpr)(unsafe.Pointer(pExpr)).FiTable + case int32(TK_CAST): + /* Expressions of the form: CAST(pLeft AS token) */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Cast), target, int32(_sqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0)))) + return inReg + case int32(TK_IS): + fallthrough + case int32(TK_ISNOT): + if op == int32(TK_IS) { + v1 = int32(TK_EQ) + } else { + v1 = int32(TK_NE) + } + op = v1 + p5 = int32(SQLITE_NULLEQ) + fallthrough + case int32(TK_LT): + fallthrough + case int32(TK_LE): + fallthrough + case int32(TK_GT): + fallthrough + case int32(TK_GE): + fallthrough + case int32(TK_NE): + fallthrough + case int32(TK_EQ): + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + addrIsNull = 0 + if _sqlite3ExprIsVector(tls, pLeft) != 0 { + _codeVectorCompare(tls, pParse, pExpr, target, libc.Uint8FromInt32(op), libc.Uint8FromInt32(p5)) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) && p5 != int32(SQLITE_NULLEQ) { + addrIsNull = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), inReg) + _codeCompare(tls, pParse, pLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, op, **(**int32)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 12)), _sqlite3VdbeCurrentAddr(tls, v)+int32(2), p5, libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0))) + if p5 == int32(SQLITE_NULLEQ) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, inReg) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_ZeroOrNull), **(**int32)(__ccgo_up(bp + 8)), inReg, **(**int32)(__ccgo_up(bp + 12))) + if addrIsNull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addrIsNull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, inReg) + } + } + } + case int32(TK_AND): + fallthrough + case int32(TK_OR): + inReg = _exprCodeTargetAndOr(tls, pParse, pExpr, target, bp) + case int32(TK_PLUS): + fallthrough + case int32(TK_STAR): + fallthrough + case int32(TK_MINUS): + fallthrough + case int32(TK_REM): + fallthrough + case int32(TK_BITAND): + fallthrough + case int32(TK_BITOR): + fallthrough + case int32(TK_SLASH): + fallthrough + case int32(TK_LSHIFT): + fallthrough + case int32(TK_RSHIFT): + fallthrough + case int32(TK_CONCAT): + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + addrIsNull1 = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) + addrIsNull1 = 0 + } + _sqlite3VdbeAddOp3(tls, v, op, **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 8)), target) + if addrIsNull1 != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addrIsNull1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + case int32(TK_UMINUS): + pLeft1 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft1)).Fop) == int32(TK_INTEGER) { + _codeInteger(tls, pParse, pLeft1, int32(1), target) + return target + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft1)).Fop) == int32(TK_FLOAT) { + _codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pLeft1 + 8)), int32(1), target) + return target + } else { + (**(**TExpr)(__ccgo_up(bp + 16))).Fop = uint8(TK_INTEGER) + (**(**TExpr)(__ccgo_up(bp + 16))).Fflags = libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue) | libc.Int32FromInt32(EP_TokenOnly)) + *(*int32)(unsafe.Pointer(bp + 16 + 8)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, bp+16, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp+4) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Subtract), **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 8)), target) + } + } + case int32(TK_BITNOT): + fallthrough + case int32(TK_NOT): + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + _sqlite3VdbeAddOp2(tls, v, op, **(**int32)(__ccgo_up(bp + 8)), inReg) + case int32(TK_TRUTH): /* IS TRUE or IS FALSE */ + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + isTrue = _sqlite3ExprTruthValue(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + bNormal = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) == int32(TK_IS)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsTrue), **(**int32)(__ccgo_up(bp + 8)), inReg, libc.BoolInt32(!(isTrue != 0)), isTrue^bNormal) + case int32(TK_ISNULL): + fallthrough + case int32(TK_NOTNULL): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), target) + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + addr = _sqlite3VdbeAddOp1(tls, v, op, **(**int32)(__ccgo_up(bp + 8))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, target) + _sqlite3VdbeJumpHere(tls, v, addr) + case int32(TK_AGG_FUNCTION): + pInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if pInfo == uintptr(0) || int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) < 0 || int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pInfo)).FnFunc { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8857, libc.VaList(bp+168, pExpr)) + } else { + return (*TAggInfo)(unsafe.Pointer(pInfo)).FiFirstReg + (*TAggInfo)(unsafe.Pointer(pInfo)).FnColumn + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + } + case int32(TK_FUNCTION): /* The function name */ + constMask = uint32(0) /* Loop counter */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The database connection */ + enc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc /* The text encoding used by this database */ + pColl = uintptr(0) /* A collating sequence */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + return (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FregResult + } + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x80>>7)) != 0 && _sqlite3ExprIsConstantNotJoin(tls, pParse, pExpr) != 0 { + /* SQL functions can be expensive. So try to avoid running them + ** multiple times if we know they always give the same result */ + return _sqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -int32(1)) + } + pFarg = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if pFarg != 0 { + v1 = (*TExprList)(unsafe.Pointer(pFarg)).FnExpr + } else { + v1 = 0 + } + nFarg = v1 + zId = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + pDef = _sqlite3FindFunction(tls, db, zId, nFarg, enc, uint8(0)) + if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8884, libc.VaList(bp+168, pExpr)) + break + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INLINE) != uint32(0) && pFarg != uintptr(0) { + return _exprCodeInlineFunction(tls, pParse, pFarg, int32(int64((*TFuncDef)(unsafe.Pointer(pDef)).FpUserData)), target) + } else { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_DIRECT)|libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) != 0 { + _sqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) + } + } + i = 0 + for { + if !(i < nFarg) { + break + } + if i < int32(32) && _sqlite3ExprIsConstant(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + uintptr(i)*32))).FpExpr) != 0 { + constMask = constMask | libc.Uint32FromInt32(1)<= int32(2) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InfixFunc)) != uint32(0) { + pDef = _sqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr) + } else { + if nFarg > 0 { + pDef = _sqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr) + } + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 { + if !(pColl != 0) { + pColl = (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_CollSeq), 0, 0, 0, pColl, -int32(2)) + } + _sqlite3VdbeAddFunctionCall(tls, pParse, libc.Int32FromUint32(constMask), **(**int32)(__ccgo_up(bp + 8)), target, nFarg, pDef, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2)) + if nFarg != 0 { + if constMask == uint32(0) { + _sqlite3ReleaseTempRange(tls, pParse, **(**int32)(__ccgo_up(bp + 8)), nFarg) + } else { + } + } + return target + case int32(TK_EXISTS): + fallthrough + case int32(TK_SELECT): + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return 0 + } else { + if v2 = op == int32(TK_SELECT) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0); v2 { + v1 = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList)).FnExpr + nCol = v1 + } + if v2 && v1 != int32(1) { + _sqlite3SubselectError(tls, pParse, nCol, int32(1)) + } else { + return _sqlite3CodeSubselect(tls, pParse, pExpr) + } + } + case int32(TK_SELECT_COLUMN): + pLeft2 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if (*TExpr)(unsafe.Pointer(pLeft2)).FiTable == 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn) > libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft2)).Fop2) { + (*TExpr)(unsafe.Pointer(pLeft2)).FiTable = _sqlite3CodeSubselect(tls, pParse, pLeft2) + (*TExpr)(unsafe.Pointer(pLeft2)).Fop2 = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn + } + n1 = _sqlite3ExprVectorSize(tls, pLeft2) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable != n1 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8469, libc.VaList(bp+168, (*TExpr)(unsafe.Pointer(pExpr)).FiTable, n1)) + } + return (*TExpr)(unsafe.Pointer(pLeft2)).FiTable + int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + case int32(TK_IN): + destIfFalse = _sqlite3VdbeMakeLabel(tls, pParse) + destIfNull = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + _sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), target) + _sqlite3VdbeResolveLabel(tls, v, destIfFalse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), target, 0) + _sqlite3VdbeResolveLabel(tls, v, destIfNull) + return target + /* + ** x BETWEEN y AND z + ** + ** This is equivalent to + ** + ** x>=y AND x<=z + ** + ** X is stored in pExpr->pLeft. + ** Y is stored in pExpr->pList->a[0].pExpr. + ** Z is stored in pExpr->pList->a[1].pExpr. + */ + fallthrough + case int32(TK_BETWEEN): + _exprCodeBetween(tls, pParse, pExpr, target, uintptr(0), 0) + return target + case int32(TK_COLLATE): + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != libc.Uint32FromInt32(0)) { + /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called + ** "SOFT-COLLATE" that is added to constraints that are pushed down + ** from outer queries into sub-queries by the WHERE-clause push-down + ** optimization. Clear subtypes as subtypes may not cross a subquery + ** boundary. + */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ClrSubtype), target) + return target + } else { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + goto expr_code_doover /* 2018-04-28: Prevent deep recursion. */ + } + fallthrough + case int32(TK_SPAN): + fallthrough + case int32(TK_UPLUS): + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + goto expr_code_doover /* 2018-04-28: Prevent deep recursion. OSSFuzz. */ + case int32(TK_TRIGGER): + pTab2 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + iCol1 = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + p1 = (*TExpr)(unsafe.Pointer(pExpr)).FiTable*(int32((*TTable)(unsafe.Pointer(pTab2)).FnCol)+int32(1)) + int32(1) + int32(_sqlite3TableColumnToStorage(tls, pTab2, int16(iCol1))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Param), p1, target) + /* If the column has REAL affinity, it may currently be stored as an + ** integer. Use OP_RealAffinity to make sure it is really real. + ** + ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to + ** floating point when extracting it from the record. */ + if iCol1 >= 0 && int32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab2)).FaCol + uintptr(iCol1)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + } + case int32(TK_VECTOR): + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7252, 0) + break + /* TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions + ** that derive from the right-hand table of a LEFT JOIN. The + ** Expr.iTable value is the table number for the right-hand table. + ** The expression is only evaluated if that table is not currently + ** on a LEFT JOIN NULL row. + */ + fallthrough + case int32(TK_IF_NULL_ROW): + okConstFactor = libc.Uint8FromInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x80 >> 7))) + pAggInfo1 = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if pAggInfo1 != 0 { + if !((*TAggInfo)(unsafe.Pointer(pAggInfo1)).FdirectMode != 0) { + inReg = (*TAggInfo)(unsafe.Pointer(pAggInfo1)).FiFirstReg + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + break + } + if (*TAggInfo)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo)).FuseSortingIdx != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo)(unsafe.Pointer(pAggInfo1)).FsortingIdxPTab, (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo1)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32))).FiSorterColumn, target) + inReg = target + break + } + } + addrINR = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNullRow), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, 0, target) + /* The OP_IfNullRow opcode above can overwrite the result register with + ** NULL. So we have to ensure that the result register is not a value + ** that is suppose to be a constant. Two defenses are needed: + ** (1) Temporarily disable factoring of constant expressions + ** (2) Make sure the computed value really is stored in register + ** "target" and not someplace else. + */ + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) /* note (1) above */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + libc.SetBitFieldPtr16Uint32(pParse+40, uint32(okConstFactor), 7, 0x80) + _sqlite3VdbeJumpHere(tls, v, addrINR) + break + /* + ** Form A: + ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** Form B: + ** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** Form A is can be transformed into the equivalent form B as follows: + ** CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ... + ** WHEN x=eN THEN rN ELSE y END + ** + ** X (if it exists) is in pExpr->pLeft. + ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is + ** odd. The Y is also optional. If the number of elements in x.pList + ** is even, then Y is omitted and the "otherwise" result is NULL. + ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1]. + ** + ** The result of the expression is the Ri for the first matching Ei, + ** or if there is no matching Ei, the ELSE term Y, or if there is + ** no ELSE term, NULL. + */ + fallthrough + case int32(TK_CASE): /* The X expression */ + pTest = uintptr(0) /* X==Ei (form A) or just Ei (form B) */ + pDel = uintptr(0) + db1 = (*TParse)(unsafe.Pointer(pParse)).Fdb + pEList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + aListelem = pEList + 8 + nExpr = (*TExprList)(unsafe.Pointer(pEList)).FnExpr + endLabel = _sqlite3VdbeMakeLabel(tls, pParse) + v3 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pX = v3 + if v3 != uintptr(0) { + pDel = _sqlite3ExprDup(tls, db1, pX, 0) + if (*Tsqlite3)(unsafe.Pointer(db1)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db1, pDel) + break + } + _sqlite3ExprToRegister(tls, pDel, _exprCodeVector(tls, pParse, pDel, bp)) + libc.X__builtin___memset_chk(tls, bp+88, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TExpr)(__ccgo_up(bp + 88))).Fop = uint8(TK_EQ) + (**(**TExpr)(__ccgo_up(bp + 88))).FpLeft = pDel + pTest = bp + 88 + /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001: + ** The value in regFree1 might get SCopy-ed into the file result. + ** So make sure that the regFree1 register is not reused for other + ** purposes and possibly overwritten. */ + **(**int32)(__ccgo_up(bp)) = 0 + } + i1 = 0 + for { + if !(i1 < nExpr-int32(1)) { + break + } + if pX != 0 { + (**(**TExpr)(__ccgo_up(bp + 88))).FpRight = (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1)*32))).FpExpr + } else { + pTest = (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1)*32))).FpExpr + } + nextCase = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfFalse(tls, pParse, pTest, nextCase, int32(SQLITE_JUMPIFNULL)) + _sqlite3ExprCode(tls, pParse, (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1+int32(1))*32))).FpExpr, target) + _sqlite3VdbeGoto(tls, v, endLabel) + _sqlite3VdbeResolveLabel(tls, v, nextCase) + goto _13 + _13: + ; + i1 = i1 + int32(2) + } + if nExpr&int32(1) != 0 { + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(nExpr-int32(1))*32))).FpExpr, target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + _sqlite3ExprDelete(tls, db1, pDel) + _setDoNotMergeFlagOnCopy(tls, v) + _sqlite3VdbeResolveLabel(tls, v, endLabel) + case int32(TK_RAISE): + if !((*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0) && !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8908, 0) + return 0 + } + if int32((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(OE_Abort) { + _sqlite3MayAbort(tls, pParse) + } + if int32((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(OE_Ignore) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), SQLITE_OK, int32(OE_Ignore)) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { + v1 = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(7)< **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 6*4)) && !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8299, libc.VaList(bp+8, pToken)) + } + *(*uintptr)(unsafe.Pointer(pNew + 32)) = pList + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)) + _sqlite3ExprSetHeightAndFlags(tls, pParse, pNew) + if eDistinct == int32(SF_Distinct) { + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)) + } + return pNew +} + +// C documentation +// +// /* +// ** Check to see if a function is usable according to current access +// ** rules: +// ** +// ** SQLITE_FUNC_DIRECT - Only usable from top-level SQL +// ** +// ** SQLITE_FUNC_UNSAFE - Usable if TRUSTED_SCHEMA or from +// ** top-level SQL +// ** +// ** If the function is not usable, create an error. +// */ +func _sqlite3ExprFunctionUsable(tls *libc.TLS, pParse uintptr, pExpr uintptr, pDef uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) != uint32(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_FROM_DDL) != 0 { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_DIRECT) != uint32(0) || (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_TrustedSchema) == uint64(0) { + /* Functions prohibited in triggers and views if: + ** (1) tagged with SQLITE_DIRECTONLY + ** (2) not tagged with SQLITE_INNOCUOUS (which means it + ** is tagged with SQLITE_FUNC_UNSAFE) and + ** SQLITE_DBCONFIG_TRUSTED_SCHEMA is off (meaning + ** that the schema is possibly tainted). + */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8383, libc.VaList(bp+8, pExpr)) + } + } +} + +// C documentation +// +// /* +// ** Allocate an expression for a 32-bit signed integer literal. +// */ +func _sqlite3ExprInt32(tls *libc.TLS, db uintptr, iVal int32) (r uintptr) { + var pNew uintptr + var v1 int32 + _, _ = pNew, v1 + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(72)) + if pNew != 0 { + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(72), ^t__predefined_size_t(0)) + (*TExpr)(unsafe.Pointer(pNew)).Fop = uint8(TK_INTEGER) + (*TExpr)(unsafe.Pointer(pNew)).FiAgg = int16(-int32(1)) + if iVal != 0 { + v1 = int32(EP_IsTrue) + } else { + v1 = int32(EP_IsFalse) + } + (*TExpr)(unsafe.Pointer(pNew)).Fflags = libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue) | libc.Int32FromInt32(EP_Leaf) | v1) + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pNew)).Fu)) = iVal + (*TExpr)(unsafe.Pointer(pNew)).FnHeight = int32(1) + } + return pNew +} + +// C documentation +// +// /* +// ** pColumns and pExpr form a vector assignment which is part of the SET +// ** clause of an UPDATE statement. Like this: +// ** +// ** (a,b,c) = (expr1,expr2,expr3) +// ** Or: (a,b,c) = (SELECT x,y,z FROM ....) +// ** +// ** For each term of the vector assignment, append new entries to the +// ** expression list pList. In the case of a subquery on the RHS, append +// ** TK_SELECT_COLUMN expressions. +// */ +func _sqlite3ExprListAppendVector(tls *libc.TLS, pParse uintptr, pList uintptr, pColumns uintptr, pExpr uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pFirst, pSubExpr uintptr + var i, iFirst, n, v1 int32 + var v3 bool + _, _, _, _, _, _, _, _ = db, i, iFirst, n, pFirst, pSubExpr, v1, v3 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pList != 0 { + v1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v1 = 0 + } + iFirst = v1 + /* pColumns can only be NULL due to an OOM but an OOM will cause an + ** exit prior to this routine being invoked */ + if pColumns == uintptr(0) { + goto vector_append_error + } + if pExpr == uintptr(0) { + goto vector_append_error + } + /* If the RHS is a vector, then we can immediately check to see that + ** the size of the RHS and LHS match. But if the RHS is a SELECT, + ** wildcards ("*") in the result set of the SELECT must be expanded before + ** we can do the size check, so defer the size check until code generation. + */ + if v3 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_SELECT); v3 { + v1 = _sqlite3ExprVectorSize(tls, pExpr) + n = v1 + } + if v3 && (*TIdList)(unsafe.Pointer(pColumns)).FnId != v1 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8469, libc.VaList(bp+8, (*TIdList)(unsafe.Pointer(pColumns)).FnId, n)) + goto vector_append_error + } + i = 0 + for { + if !(i < (*TIdList)(unsafe.Pointer(pColumns)).FnId) { + break + } + pSubExpr = _sqlite3ExprForVectorField(tls, pParse, pExpr, i, (*TIdList)(unsafe.Pointer(pColumns)).FnId) + if pSubExpr == uintptr(0) { + goto _4 + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, pSubExpr) + if pList != 0 { + (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr((*TExprList)(unsafe.Pointer(pList)).FnExpr-int32(1))*32))).FzEName = (*(*TIdList_item)(unsafe.Pointer(pColumns + 8 + uintptr(i)*8))).FzName + (*(*TIdList_item)(unsafe.Pointer(pColumns + 8 + uintptr(i)*8))).FzName = uintptr(0) + } + goto _4 + _4: + ; + i = i + 1 + } + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) && pList != uintptr(0) { + pFirst = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(iFirst)*32))).FpExpr + /* Store the SELECT statement in pRight so it will be deleted when + ** sqlite3ExprListDelete() is called */ + (*TExpr)(unsafe.Pointer(pFirst)).FpRight = pExpr + pExpr = uintptr(0) + /* Remember the size of the LHS in iTable so that we can check that + ** the RHS and LHS sizes match during code generation. */ + (*TExpr)(unsafe.Pointer(pFirst)).FiTable = (*TIdList)(unsafe.Pointer(pColumns)).FnId + } + goto vector_append_error +vector_append_error: + ; + _sqlite3ExprUnmapAndDelete(tls, pParse, pExpr) + _sqlite3IdListDelete(tls, db, pColumns) + return pList +} + +// C documentation +// +// /* +// ** If the expression list pEList contains more than iLimit elements, +// ** leave an error message in pParse. +// */ +func _sqlite3ExprListCheckLength(tls *libc.TLS, pParse uintptr, pEList uintptr, zObject uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var mx int32 + _ = mx + mx = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 2*4)) + if pEList != 0 && (*TExprList)(unsafe.Pointer(pEList)).FnExpr > mx { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8499, libc.VaList(bp+8, zObject)) + } +} + +// C documentation +// +// /* +// ** Expression list pEList is a list of vector values. This function +// ** converts the contents of pEList to a VALUES(...) Select statement +// ** returning 1 row for each element of the list. For example, the +// ** expression list: +// ** +// ** ( (1,2), (3,4) (5,6) ) +// ** +// ** is translated to the equivalent of: +// ** +// ** VALUES(1,2), (3,4), (5,6) +// ** +// ** Each of the vector values in pEList must contain exactly nElem terms. +// ** If a list element that is not a vector or does not contain nElem terms, +// ** an error message is left in pParse. +// ** +// ** This is used as part of processing IN(...) expressions with a list +// ** of vectors on the RHS. e.g. "... IN ((1,2), (3,4), (5,6))". +// */ +func _sqlite3ExprListToValues(tls *libc.TLS, pParse uintptr, nElem int32, pEList uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ii, nExprElem int32 + var pExpr, pRet, pSel, v2 uintptr + _, _, _, _, _, _ = ii, nExprElem, pExpr, pRet, pSel, v2 + pRet = uintptr(0) + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_VECTOR) { + nExprElem = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + } else { + nExprElem = int32(1) + } + if nExprElem != nElem { + if nExprElem > int32(1) { + v2 = __ccgo_ts + 8253 + } else { + v2 = __ccgo_ts + 1702 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8255, libc.VaList(bp+8, nExprElem, v2, nElem)) + break + } + pSel = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 32)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values), uintptr(0)) + *(*uintptr)(unsafe.Pointer(pExpr + 32)) = uintptr(0) + if pSel != 0 { + if pRet != 0 { + (*TSelect)(unsafe.Pointer(pSel)).Fop = uint8(TK_ALL) + (*TSelect)(unsafe.Pointer(pSel)).FpPrior = pRet + } + pRet = pSel + } + goto _1 + _1: + ; + ii = ii + 1 + } + if pRet != 0 && (*TSelect)(unsafe.Pointer(pRet)).FpPrior != 0 { + **(**Tu32)(__ccgo_up(pRet + 4)) |= uint32(SF_MultiValue) + } + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pEList) + return pRet +} + +// C documentation +// +// /* +// ** Make arrangements to invoke OP_Null on a range of registers +// ** during initialization. +// */ +func _sqlite3ExprNullRegisterRange(tls *libc.TLS, pParse uintptr, iReg int32, nReg int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var okConstFactor Tu8 + var _ /* t at bp+0 */ TExpr + _ = okConstFactor + okConstFactor = libc.Uint8FromInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x80 >> 7))) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_NULLS) + *(*int32)(unsafe.Pointer(bp + 64)) = nReg + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 7, 0x80) + _sqlite3ExprCodeRunJustOnce(tls, pParse, bp, iReg) + libc.SetBitFieldPtr16Uint32(pParse+40, uint32(okConstFactor), 7, 0x80) +} + +// C documentation +// +// /* +// ** Report an error when attempting to use an ORDER BY clause within +// ** the arguments of a non-aggregate function. +// */ +func _sqlite3ExprOrderByAggregateError(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8333, libc.VaList(bp+8, p)) +} + +// C documentation +// +// /* +// ** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The +// ** only columns that are modified by the UPDATE are those for which +// ** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true. +// ** +// ** Return true if CHECK constraint pExpr uses any of the +// ** changing columns (or the rowid if it is changing). In other words, +// ** return true if this CHECK constraint must be validated for +// ** the new row in the UPDATE statement. +// ** +// ** 2018-09-15: pExpr might also be an expression for an index-on-expressions. +// ** The operation of this routine is the same - return true if an only if +// ** the expression uses one or more of columns identified by the second and +// ** third arguments. +// */ +func _sqlite3ExprReferencesUpdatedColumn(tls *libc.TLS, pExpr uintptr, aiChng uintptr, chngRowid int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var v1 uintptr + var _ /* w at bp+0 */ TWalker + _ = v1 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(0) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_checkConstraintExprNode) + *(*uintptr)(unsafe.Pointer(bp + 40)) = aiChng + _sqlite3WalkExpr(tls, bp, pExpr) + if !(chngRowid != 0) { + v1 = bp + 36 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(CKCNSTRNT_ROWID)) + } + return libc.BoolInt32(libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) != 0) +} + +// C documentation +// +// /* +// ** Parameter zName points to a nul-terminated buffer containing the name +// ** of a database ("main", "temp" or the name of an attached db). This +// ** function returns the index of the named database in db->aDb[], or +// ** -1 if the named db cannot be found. +// */ +func _sqlite3FindDbName(tls *libc.TLS, db uintptr, zName uintptr) (r int32) { + var i int32 + var pDb uintptr + _, _ = i, pDb + i = -int32(1) /* Database number */ + if zName != 0 { + i = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + for { + if !(i >= 0) { + break + } + if 0 == Xsqlite3_stricmp(tls, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, zName) { + break + } + /* "main" is always an acceptable alias for the primary database + ** even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME. */ + if i == 0 && 0 == Xsqlite3_stricmp(tls, __ccgo_ts+7160, zName) { + break + } + goto _1 + _1: + ; + i = i - 1 + pDb -= 32 + } + } + return i +} + +// C documentation +// +// /* +// ** Locate a user function given a name, a number of arguments and a flag +// ** indicating whether the function prefers UTF-16 over UTF-8. Return a +// ** pointer to the FuncDef structure that defines that function, or return +// ** NULL if the function does not exist. +// ** +// ** If the createFlag argument is true, then a new (blank) FuncDef +// ** structure is created and liked into the "db" structure if a +// ** no matching function previously existed. +// ** +// ** If nArg is -2, then the first valid function found is returned. A +// ** function is valid if xSFunc is non-zero. The nArg==(-2) +// ** case is used to see if zName is a valid function name for some number +// ** of arguments. If nArg is -2, then createFlag must be 0. +// ** +// ** If createFlag is false, then a function with the required name and +// ** number of arguments may be returned even if the eTextRep flag does not +// ** match that requested. +// */ +func _sqlite3FindFunction(tls *libc.TLS, db uintptr, zName uintptr, nArg int32, enc Tu8, createFlag Tu8) (r uintptr) { + var bestScore, h, nName, score, score1 int32 + var p, pBest, pOther, z, v1 uintptr + var v2 bool + _, _, _, _, _, _, _, _, _, _, _ = bestScore, h, nName, p, pBest, pOther, score, score1, z, v1, v2 /* Iterator variable */ + pBest = uintptr(0) /* Best match found so far */ + bestScore = 0 /* Length of the name */ + nName = _sqlite3Strlen30(tls, zName) + /* First search for a match amongst the application-defined functions. + */ + p = _sqlite3HashFind(tls, db+624, zName) + for p != 0 { + score = _matchQuality(tls, p, nArg, enc) + if score > bestScore { + pBest = p + bestScore = score + } + p = (*TFuncDef)(unsafe.Pointer(p)).FpNext + } + /* If no match is found, search the built-in functions. + ** + ** If the DBFLAG_PreferBuiltin flag is set, then search the built-in + ** functions even if a prior app-defined function was found. And give + ** priority to built-in functions. + ** + ** Except, if createFlag is true, that means that we are trying to + ** install a new function. Whatever FuncDef structure is returned it will + ** have fields overwritten with new information appropriate for the + ** new function. But the FuncDefs for built-in functions are read-only. + ** So we must not search for built-ins when creating a new function. + */ + if !(createFlag != 0) && (pBest == uintptr(0) || (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_PreferBuiltin) != uint32(0)) { + bestScore = 0 + h = (libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zName)))]) + nName) % int32(SQLITE_FUNC_HASH_SZ) + p = _sqlite3FunctionSearch(tls, h, zName) + for p != 0 { + score1 = _matchQuality(tls, p, nArg, enc) + if score1 > bestScore { + pBest = p + bestScore = score1 + } + p = (*TFuncDef)(unsafe.Pointer(p)).FpNext + } + } + /* If the createFlag parameter is true and the search did not reveal an + ** exact match for the name, number of arguments and encoding, then add a + ** new entry to the hash table and return it. + */ + if v2 = createFlag != 0 && bestScore < int32(FUNC_PERFECT_MATCH); v2 { + v1 = _sqlite3DbMallocZero(tls, db, uint64(uint64(72)+libc.Uint64FromInt32(nName)+uint64(1))) + pBest = v1 + } + if v2 && v1 != uintptr(0) { + (*TFuncDef)(unsafe.Pointer(pBest)).FzName = pBest + 1*72 + (*TFuncDef)(unsafe.Pointer(pBest)).FnArg = libc.Int16FromUint16(libc.Uint16FromInt32(nArg)) + (*TFuncDef)(unsafe.Pointer(pBest)).FfuncFlags = uint32(enc) + libc.X__builtin___memcpy_chk(tls, pBest+1*72, zName, libc.Uint64FromInt32(nName+int32(1)), ^t__predefined_size_t(0)) + z = (*TFuncDef)(unsafe.Pointer(pBest)).FzName + for { + if !(**(**Tu8)(__ccgo_up(z)) != 0) { + break + } + **(**Tu8)(__ccgo_up(z)) = _sqlite3UpperToLower[**(**Tu8)(__ccgo_up(z))] + goto _3 + _3: + ; + z = z + 1 + } + pOther = _sqlite3HashInsert(tls, db+624, (*TFuncDef)(unsafe.Pointer(pBest)).FzName, pBest) + if pOther == pBest { + _sqlite3DbFree(tls, db, pBest) + _sqlite3OomFault(tls, db) + return uintptr(0) + } else { + (*TFuncDef)(unsafe.Pointer(pBest)).FpNext = pOther + } + } + if pBest != 0 && ((*TFuncDef)(unsafe.Pointer(pBest)).FxSFunc != 0 || createFlag != 0) { + return pBest + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** This function is used by the implementation of the IN (...) operator. +// ** The pX parameter is the expression on the RHS of the IN operator, which +// ** might be either a list of expressions or a subquery. +// ** +// ** The job of this routine is to find or create a b-tree object that can +// ** be used either to test for membership in the RHS set or to iterate through +// ** all members of the RHS set, skipping duplicates. +// ** +// ** A cursor is opened on the b-tree object that is the RHS of the IN operator +// ** and the *piTab parameter is set to the index of that cursor. +// ** +// ** The returned value of this function indicates the b-tree type, as follows: +// ** +// ** IN_INDEX_ROWID - The cursor was opened on a database table. +// ** IN_INDEX_INDEX_ASC - The cursor was opened on an ascending index. +// ** IN_INDEX_INDEX_DESC - The cursor was opened on a descending index. +// ** IN_INDEX_EPH - The cursor was opened on a specially created and +// ** populated ephemeral table. +// ** IN_INDEX_NOOP - No cursor was allocated. The IN operator must be +// ** implemented as a sequence of comparisons. +// ** +// ** An existing b-tree might be used if the RHS expression pX is a simple +// ** subquery such as: +// ** +// ** SELECT , ... FROM +// ** +// ** If the RHS of the IN operator is a list or a more complex subquery, then +// ** an ephemeral table might need to be generated from the RHS and then +// ** pX->iTable made to point to the ephemeral table instead of an +// ** existing table. In this case, the creation and initialization of the +// ** ephemeral table might be put inside of a subroutine, the EP_Subrtn flag +// ** will be set on pX and the pX->y.sub fields will be set to show where +// ** the subroutine is coded. +// ** +// ** The inFlags parameter must contain, at a minimum, one of the bits +// ** IN_INDEX_MEMBERSHIP or IN_INDEX_LOOP but not both. If inFlags contains +// ** IN_INDEX_MEMBERSHIP, then the generated table will be used for a fast +// ** membership test. When the IN_INDEX_LOOP bit is set, the IN index will +// ** be used to loop over all values of the RHS of the IN operator. +// ** +// ** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate +// ** through the set members) then the b-tree must not contain duplicates. +// ** An ephemeral table will be created unless the selected columns are guaranteed +// ** to be unique - either because it is an INTEGER PRIMARY KEY or due to +// ** a UNIQUE constraint or index. +// ** +// ** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used +// ** for fast set membership tests) then an ephemeral table must +// ** be used unless is a single INTEGER PRIMARY KEY column or an +// ** index can be found with the specified as its left-most. +// ** +// ** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and +// ** if the RHS of the IN operator is a list (not a subquery) then this +// ** routine might decide that creating an ephemeral b-tree for membership +// ** testing is too expensive and return IN_INDEX_NOOP. In that case, the +// ** calling routine should implement the IN operator using a sequence +// ** of Eq or Ne comparison operations. +// ** +// ** When the b-tree is being used for membership tests, the calling function +// ** might need to know whether or not the RHS side of the IN operator +// ** contains a NULL. If prRhsHasNull is not a NULL pointer and +// ** if there is any chance that the (...) might contain a NULL value at +// ** runtime, then a register is allocated and the register number written +// ** to *prRhsHasNull. If there is no chance that the (...) contains a +// ** NULL value, then *prRhsHasNull is left unchanged. +// ** +// ** If a register is allocated and its location stored in *prRhsHasNull, then +// ** the value in that register will be NULL if the b-tree contains one or more +// ** NULL values, and it will be some non-NULL value if the b-tree contains no +// ** NULL values. +// ** +// ** If the aiMap parameter is not NULL, it must point to an array containing +// ** one element for each column returned by the SELECT statement on the RHS +// ** of the IN(...) operator. The i'th entry of the array is populated with the +// ** offset of the index column that matches the i'th column returned by the +// ** SELECT. For example, if the expression and selected index are: +// ** +// ** (?,?,?) IN (SELECT a, b, c FROM t1) +// ** CREATE INDEX i1 ON t1(b, c, a); +// ** +// ** then aiMap[] is populated with {2, 0, 1}. +// */ +func _sqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags Tu32, prRhsHasNull uintptr, aiMap uintptr, piTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var affinity_ok, bloomOk, eType, i, i1, i2, iAddr, iAddr1, iCol, iDb, iTab, j, mustBeUnique, n, nExpr, rMayHaveNull, v1, v10 int32 + var cmpaff, idxaff int8 + var colUsed, mCol TBitmask + var db, p, pEList, pEList1, pIdx, pLhs, pLhs1, pReq, pRhs, pTab, v, v2 uintptr + var savedNQueryLoop Tu32 + var v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = affinity_ok, bloomOk, cmpaff, colUsed, db, eType, i, i1, i2, iAddr, iAddr1, iCol, iDb, iTab, idxaff, j, mCol, mustBeUnique, n, nExpr, p, pEList, pEList1, pIdx, pLhs, pLhs1, pReq, pRhs, pTab, rMayHaveNull, savedNQueryLoop, v, v1, v10, v2, v5 /* SELECT to the right of IN operator */ + eType = 0 /* True if RHS must be unique */ + v = _sqlite3GetVdbe(tls, pParse) /* Virtual machine being coded */ + mustBeUnique = libc.BoolInt32(inFlags&uint32(IN_INDEX_LOOP) != uint32(0)) + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + iTab = v1 + /* If the RHS of this IN(...) operator is a SELECT, and if it matters + ** whether or not the SELECT result contains NULL values, check whether + ** or not NULL is actually possible (it may not be, for example, due + ** to NOT NULL constraints in the schema). If no NULL values are possible, + ** set prRhsHasNull to 0 before continuing. */ + if prRhsHasNull != 0 && (*TExpr)(unsafe.Pointer(pX)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + pEList = (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32)))).FpEList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if _sqlite3ExprCanBeNull(tls, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr) != 0 { + break + } + goto _3 + _3: + ; + i = i + 1 + } + if i == (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + prRhsHasNull = uintptr(0) + } + } + /* Check to see if an existing table or index can be used to + ** satisfy the query. This is preferable to generating a new + ** ephemeral table. */ + if v5 = (*TParse)(unsafe.Pointer(pParse)).FnErr == 0; v5 { + v2 = _isCandidateForInOpt(tls, pX) + p = v2 + } + if v5 && v2 != uintptr(0) { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database idx for pTab */ + pEList1 = (*TSelect)(unsafe.Pointer(p)).FpEList + nExpr = (*TExprList)(unsafe.Pointer(pEList1)).FnExpr + /* Because of isCandidateForInOpt(p) */ + /* Because of isCandidateForInOpt(p) */ + /* Because of isCandidateForInOpt(p) */ + pTab = (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab + /* Code an OP_Transaction and OP_TableLock for
. */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab)).FzName) + /* sqlite3GetVdbe() has always been previously called */ + if nExpr == int32(1) && int32((*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList1 + 8))).FpExpr)).FiColumn) < 0 { + /* The "x IN (SELECT rowid FROM table)" case */ + iAddr = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + _sqlite3OpenTable(tls, pParse, iTab, iDb, pTab, int32(OP_OpenRead)) + eType = int32(IN_INDEX_ROWID) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8551, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + _sqlite3VdbeJumpHere(tls, v, iAddr) + } else { /* Iterator variable */ + affinity_ok = int32(1) + /* Check that the affinity that will be used to perform each + ** comparison is the same as the affinity of each column in table + ** on the RHS of the IN operator. If it not, it is not possible to + ** use any index of the RHS table. */ + i1 = 0 + for { + if !(i1 < nExpr && affinity_ok != 0) { + break + } + pLhs = _sqlite3VectorFieldSubexpr(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft, i1) + iCol = int32((*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList1 + 8 + uintptr(i1)*32))).FpExpr)).FiColumn) + idxaff = _sqlite3TableColumnAffinity(tls, pTab, iCol) /* RHS table */ + cmpaff = _sqlite3CompareAffinity(tls, pLhs, idxaff) + switch int32(cmpaff) { + case int32(SQLITE_AFF_BLOB): + case int32(SQLITE_AFF_TEXT): + /* sqlite3CompareAffinity() only returns TEXT if one side or the + ** other has no affinity and the other side is TEXT. Hence, + ** the only way for cmpaff to be TEXT is for idxaff to be TEXT + ** and for the term on the LHS of the IN to have no affinity. */ + default: + affinity_ok = libc.BoolInt32(int32(idxaff) >= int32(SQLITE_AFF_NUMERIC)) + } + goto _6 + _6: + ; + i1 = i1 + 1 + } + if affinity_ok != 0 { + /* Search for an existing index that will work for this IN operator */ + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0 && eType == 0) { + break + } /* Mask for the current column */ + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) < nExpr { + goto _7 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) { + goto _7 + } + /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute + ** BITMASK(nExpr) without overflowing */ + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + goto _7 + } + if mustBeUnique != 0 { + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) > nExpr || libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) > nExpr && !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromInt32(OE_None)) { + goto _7 /* This index is not unique over the IN RHS columns */ + } + } + colUsed = uint64(0) /* Columns of index used so far */ + i1 = 0 + for { + if !(i1 < nExpr) { + break + } + pLhs1 = _sqlite3VectorFieldSubexpr(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft, i1) + pRhs = (*(*TExprList_item)(unsafe.Pointer(pEList1 + 8 + uintptr(i1)*32))).FpExpr + pReq = _sqlite3BinaryCompareCollSeq(tls, pParse, pLhs1, pRhs) + j = 0 + for { + if !(j < nExpr) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) != int32((*TExpr)(unsafe.Pointer(pRhs)).FiColumn) { + goto _9 + } + if pReq != uintptr(0) && _sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pReq)).FzName, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8))) != 0 { + goto _9 + } + break + goto _9 + _9: + ; + j = j + 1 + } + if j == nExpr { + break + } + mCol = libc.Uint64FromInt32(1) << j + if mCol&colUsed != 0 { + break + } /* Each column used only once */ + colUsed = colUsed | mCol + if aiMap != 0 { + **(**int32)(__ccgo_up(aiMap + uintptr(i1)*4)) = j + } + goto _8 + _8: + ; + i1 = i1 + 1 + } + if colUsed == libc.Uint64FromInt32(1)<= (*Tsqlite3)(unsafe.Pointer(db)).FnDb { + /* No match against the official names. But always match "main" + ** to schema 0 as a legacy fallback. */ + if _sqlite3StrICmp(tls, zDatabase, __ccgo_ts+7160) == 0 { + i = 0 + } else { + return uintptr(0) + } + } + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema+8, zName) + if p == uintptr(0) && Xsqlite3_strnicmp(tls, zName, __ccgo_ts+7100, int32(7)) == 0 { + if i == int32(1) { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+7127+7) == 0 || _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+7146+7) == 0 || _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6628+7) == 0 { + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema+8, __ccgo_ts+7108) + } + } else { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+7146+7) == 0 { + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema+8, __ccgo_ts+6628) + } + } + } + } else { + /* Match against TEMP first */ + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema+8, zName) + if p != 0 { + return p + } + /* The main database is second */ + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema+8, zName) + if p != 0 { + return p + } + /* Attached databases are in order of attachment */ + i = int32(2) + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema+8, zName) + if p != 0 { + break + } + goto _2 + _2: + ; + i = i + 1 + } + if p == uintptr(0) && Xsqlite3_strnicmp(tls, zName, __ccgo_ts+7100, int32(7)) == 0 { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+7146+7) == 0 { + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema+8, __ccgo_ts+6628) + } else { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+7127+7) == 0 { + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema+8, __ccgo_ts+7108) + } + } + } + } + return p +} + +// C documentation +// +// /* +// ** This routine is called after all of the trigger actions have been parsed +// ** in order to complete the process of building the trigger. +// */ +func _sqlite3FinishTrigger(tls *libc.TLS, pParse uintptr, pStepList uintptr, pAll uintptr) { + bp := tls.Alloc(160) + defer tls.Free(160) + var db, pHash, pLink, pStep, pTab, pTrig, v, z, zName uintptr + var iDb int32 + var _ /* nameToken at bp+96 */ TToken + var _ /* sFix at bp+0 */ TDbFixer + _, _, _, _, _, _, _, _, _, _ = db, iDb, pHash, pLink, pStep, pTab, pTrig, v, z, zName + pTrig = (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger /* Name of trigger */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Trigger name for error reporting */ + (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger = uintptr(0) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 || !(pTrig != 0) { + goto triggerfinish_cleanup + } + zName = (*TTrigger)(unsafe.Pointer(pTrig)).FzName + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTrigger)(unsafe.Pointer(pTrig)).FpSchema) + (*TTrigger)(unsafe.Pointer(pTrig)).Fstep_list = pStepList + for pStepList != 0 { + (*TTriggerStep)(unsafe.Pointer(pStepList)).FpTrig = pTrig + pStepList = (*TTriggerStep)(unsafe.Pointer(pStepList)).FpNext + } + _sqlite3TokenInit(tls, bp+96, (*TTrigger)(unsafe.Pointer(pTrig)).FzName) + _sqlite3FixInit(tls, bp, pParse, iDb, __ccgo_ts+22233, bp+96) + if _sqlite3FixTriggerStep(tls, bp, (*TTrigger)(unsafe.Pointer(pTrig)).Fstep_list) != 0 || _sqlite3FixExpr(tls, bp, (*TTrigger)(unsafe.Pointer(pTrig)).FpWhen) != 0 { + goto triggerfinish_cleanup + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger = pTrig + pTrig = uintptr(0) + } else { + /* if we are not initializing, + ** build the sqlite_schema entry + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + /* If this is a new CREATE TABLE statement, and if shadow tables + ** are read-only, and the trigger makes a change to a shadow table, + ** then raise an error - do not allow the trigger to be created. */ + if _sqlite3ReadOnlyShadowTables(tls, db) != 0 { + pStep = (*TTrigger)(unsafe.Pointer(pTrig)).Fstep_list + for { + if !(pStep != 0) { + break + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != uintptr(0) && _sqlite3ShadowTableName(tls, db, (*(*TSrcItem)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8))).FzName) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22482, libc.VaList(bp+120, (*TTrigger)(unsafe.Pointer(pTrig)).FzName, (*(*TSrcItem)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8))).FzName)) + goto triggerfinish_cleanup + } + goto _1 + _1: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + } + /* Make an entry in the sqlite_schema table */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto triggerfinish_cleanup + } + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + z = _sqlite3DbStrNDup(tls, db, (*TToken)(unsafe.Pointer(pAll)).Fz, uint64((*TToken)(unsafe.Pointer(pAll)).Fn)) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+22530, libc.VaList(bp+120, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zName, (*TTrigger)(unsafe.Pointer(pTrig)).Ftable, z)) + _sqlite3DbFree(tls, db, z) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+22605, libc.VaList(bp+120, zName)), uint16(0)) + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + pLink = pTrig + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 56 + pTrig = _sqlite3HashInsert(tls, pHash, zName, pTrig) + if pTrig != 0 { + _sqlite3OomFault(tls, db) + } else { + if (*TTrigger)(unsafe.Pointer(pLink)).FpSchema == (*TTrigger)(unsafe.Pointer(pLink)).FpTabSchema { + pTab = _sqlite3HashFind(tls, (*TTrigger)(unsafe.Pointer(pLink)).FpTabSchema+8, (*TTrigger)(unsafe.Pointer(pLink)).Ftable) + (*TTrigger)(unsafe.Pointer(pLink)).FpNext = (*TTable)(unsafe.Pointer(pTab)).FpTrigger + (*TTable)(unsafe.Pointer(pTab)).FpTrigger = pLink + } + } + } + goto triggerfinish_cleanup +triggerfinish_cleanup: + ; + _sqlite3DeleteTrigger(tls, db, pTrig) + _sqlite3DeleteTriggerStep(tls, db, pStepList) +} + +// C documentation +// +// /* +// ** The following set of routines walk through the parse tree and assign +// ** a specific database to all table references where the database name +// ** was left unspecified in the original SQL statement. The pFix structure +// ** must have been initialized by a prior call to sqlite3FixInit(). +// ** +// ** These routines are used to make sure that an index, trigger, or +// ** view in one database does not refer to objects in a different database. +// ** (Exception: indices, triggers, and views in the TEMP database are +// ** allowed to refer to anything.) If a reference is explicitly made +// ** to an object in a different database, an error message is added to +// ** pParse->zErrMsg and these routines return non-zero. If everything +// ** checks out, these routines return 0. +// */ +func _sqlite3FixSrcList(tls *libc.TLS, pFix uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var res int32 + var _ /* s at bp+0 */ TSelect + _ = res + res = 0 + if pList != 0 { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(120), ^t__predefined_size_t(0)) + (**(**TSelect)(__ccgo_up(bp))).FpSrc = pList + res = _sqlite3WalkSelect(tls, pFix+8, bp) + } + return res +} + +// C documentation +// +// /* +// ** A foreign key constraint requires that the key columns in the parent +// ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. +// ** Given that pParent is the parent table for foreign key constraint pFKey, +// ** search the schema for a unique index on the parent key columns. +// ** +// ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY +// ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx +// ** is set to point to the unique index. +// ** +// ** If the parent key consists of a single column (the foreign key constraint +// ** is not a composite foreign key), output variable *paiCol is set to NULL. +// ** Otherwise, it is set to point to an allocated array of size N, where +// ** N is the number of columns in the parent key. The first element of the +// ** array is the index of the child table column that is mapped by the FK +// ** constraint to the parent table column stored in the left-most column +// ** of index *ppIdx. The second element of the array is the index of the +// ** child table column that corresponds to the second left-most column of +// ** *ppIdx, and so on. +// ** +// ** If the required index cannot be found, either because: +// ** +// ** 1) The named parent key columns do not exist, or +// ** +// ** 2) The named parent key columns do exist, but are not subject to a +// ** UNIQUE or PRIMARY KEY constraint, or +// ** +// ** 3) No parent key columns were provided explicitly as part of the +// ** foreign key definition, and the parent table does not have a +// ** PRIMARY KEY, or +// ** +// ** 4) No parent key columns were provided explicitly as part of the +// ** foreign key definition, and the PRIMARY KEY of the parent table +// ** consists of a different number of columns to the child key in +// ** the child table. +// ** +// ** then non-zero is returned, and a "foreign key mismatch" error loaded +// ** into pParse. If an OOM error occurs, non-zero is returned and the +// ** pParse->db->mallocFailed flag is set. +// */ +func _sqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey uintptr, ppIdx uintptr, paiCol uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aiCol, pIdx, zDfltColl, zIdxCol, zKey uintptr + var i, i1, j, nCol int32 + var iCol Ti16 + _, _, _, _, _, _, _, _, _, _ = aiCol, i, i1, iCol, j, nCol, pIdx, zDfltColl, zIdxCol, zKey + pIdx = uintptr(0) /* Value to return via *ppIdx */ + aiCol = uintptr(0) /* Value to return via *paiCol */ + nCol = (*TFKey)(unsafe.Pointer(pFKey)).FnCol /* Number of columns in parent key */ + zKey = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FzCol /* Name of left-most parent key column */ + /* The caller is responsible for zeroing output parameters. */ + /* If this is a non-composite (single column) foreign key, check if it + ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx + ** and *paiCol set to zero and return early. + ** + ** Otherwise, for a composite foreign key (more than one column), allocate + ** space for the aiCol array (returned via output parameter *paiCol). + ** Non-composite foreign keys do not require the aiCol array. + */ + if nCol == int32(1) { + /* The FK maps to the IPK if any of the following are true: + ** + ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly + ** mapped to the primary key of table pParent, or + ** 2) The FK is explicitly mapped to a column declared as INTEGER + ** PRIMARY KEY. + */ + if int32((*TTable)(unsafe.Pointer(pParent)).FiPKey) >= 0 { + if !(zKey != 0) { + return 0 + } + if !(_sqlite3StrICmp(tls, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pParent)).FaCol + uintptr((*TTable)(unsafe.Pointer(pParent)).FiPKey)*16))).FzCnName, zKey) != 0) { + return 0 + } + } + } else { + if paiCol != 0 { + aiCol = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(libc.Uint64FromInt32(nCol)*uint64(4))) + if !(aiCol != 0) { + return int32(1) + } + **(**uintptr)(__ccgo_up(paiCol)) = aiCol + } + } + pIdx = (*TTable)(unsafe.Pointer(pParent)).FpIndex + for { + if !(pIdx != 0) { + break + } + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) == nCol && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != OE_None && (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) { + /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number + ** of columns. If each indexed column corresponds to a foreign key + ** column of pFKey, then this index is a winner. */ + if zKey == uintptr(0) { + /* If zKey is NULL, then this foreign key is implicitly mapped to + ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be + ** identified by the test. */ + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + if aiCol != 0 { + i = 0 + for { + if !(i < nCol) { + break + } + **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) = (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FiFrom + goto _2 + _2: + ; + i = i + 1 + } + } + break + } + } else { + i1 = 0 + for { + if !(i1 < nCol) { + break + } + iCol = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i1)*2)) /* Name of indexed column */ + if int32(iCol) < 0 { + break + } /* No foreign keys against expression indexes */ + /* If the index uses a collation sequence that is different from + ** the default collation sequence for the column, this index is + ** unusable. Bail out early in this case. */ + zDfltColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pParent)).FaCol+uintptr(iCol)*16) + if !(zDfltColl != 0) { + zDfltColl = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + if _sqlite3StrICmp(tls, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i1)*8)), zDfltColl) != 0 { + break + } + zIdxCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pParent)).FaCol + uintptr(iCol)*16))).FzCnName + j = 0 + for { + if !(j < nCol) { + break + } + if _sqlite3StrICmp(tls, (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(j)*16))).FzCol, zIdxCol) == 0 { + if aiCol != 0 { + **(**int32)(__ccgo_up(aiCol + uintptr(i1)*4)) = (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(j)*16))).FiFrom + } + break + } + goto _4 + _4: + ; + j = j + 1 + } + if j == nCol { + break + } + goto _3 + _3: + ; + i1 = i1 + 1 + } + if i1 == nCol { + break + } /* pIdx is usable */ + } + } + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if !(pIdx != 0) { + if !(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x1>>0)) != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17644, libc.VaList(bp+8, (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName, (*TFKey)(unsafe.Pointer(pFKey)).FzTo)) + } + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, aiCol) + return int32(1) + } + **(**uintptr)(__ccgo_up(ppIdx)) = pIdx + return 0 +} + +// C documentation +// +// /* +// ** Return an IEEE754 floating point value that approximates d*pow(10,p). +// ** +// ** The (current) algorithm is adapted from the work of Ross Cox at +// ** https://github.com/rsc/fpfmt +// */ +func _sqlite3Fp10Convert2(tls *libc.TLS, d Tu64, p int32) (r float64) { + bp := tls.Alloc(32) + defer tls.Free(32) + var adj, b, e, lp, s int32 + var hi, pwr10h, sticky, u, x Tu64 + var mid1, mid2 Tu32 + var _ /* lo at bp+8 */ Tu64 + var _ /* m at bp+16 */ Tu64 + var _ /* pwr10l at bp+0 */ Tu32 + var _ /* r at bp+24 */ float64 + _, _, _, _, _, _, _, _, _, _, _, _ = adj, b, e, hi, lp, mid1, mid2, pwr10h, s, sticky, u, x + if p < -int32(348) { + return float64(0) + } + if p > +libc.Int32FromInt32(347) { + return float64(libc.X__builtin_huge_valf(tls)) + } + b = int32(64) - _countLeadingZeros(tls, d) + lp = _pwr10to2(tls, p) + e = int32(53) - b - lp + if e > int32(1074) { + if e >= int32(1130) { + return float64(0) + } + e = int32(1074) + } + s = -(e - (int32(64) - b) + lp + int32(3)) + pwr10h = _powerOfTen(tls, p, bp) + if **(**Tu32)(__ccgo_up(bp)) != uint32(0) { + pwr10h = pwr10h + 1 + **(**Tu32)(__ccgo_up(bp)) = ^**(**Tu32)(__ccgo_up(bp)) + } + x = d << (int32(64) - b) + hi = _sqlite3Multiply128(tls, x, pwr10h, bp+8) + mid1 = uint32(**(**Tu64)(__ccgo_up(bp + 8)) >> int32(32)) + sticky = uint64(1) + if hi&(libc.Uint64FromInt32(1)<> int32(32)) + sticky = libc.BoolUint64(mid1-mid2 > libc.Uint32FromInt32(1)) + hi = hi - libc.BoolUint64(mid1 < mid2) + } + u = hi>>s | sticky + adj = libc.BoolInt32(u >= libc.Uint64FromInt32(1)<>adj | u&uint64(1) + e = e - adj + } + **(**Tu64)(__ccgo_up(bp + 16)) = (u + uint64(1) + u>>libc.Int32FromInt32(2)&uint64(1)) >> int32(2) + if e <= -int32(972) { + return float64(libc.X__builtin_huge_valf(tls)) + } + if **(**Tu64)(__ccgo_up(bp + 16))&(libc.Uint64FromInt32(1)<0 round to min(iRound,mxRound) significant digits total. +// ** +// ** mxRound must be positive. +// ** +// ** The significant digits of the decimal representation are +// ** stored in p->z[] which is a often (but not always) a pointer +// ** into the middle of p->zBuf[]. There are p->n significant digits. +// ** The p->z[] array is *not* zero-terminated. +// */ +func _sqlite3FpDecode(tls *libc.TLS, p uintptr, _r float64, iRound int32, mxRound int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + *(*float64)(unsafe.Pointer(bp)) = _r + var e, i, j, jj, jj1, kk, kk1, kk2, n, nn, v1 int32 + var v2, v21 Tu64 + var z, zBuf uintptr + var _ /* exp at bp+16 */ int32 + var _ /* v at bp+8 */ Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = e, i, j, jj, jj1, kk, kk1, kk2, n, nn, v2, v21, z, zBuf, v1 + **(**int32)(__ccgo_up(bp + 16)) = 0 /* Local alias for p->z */ + (*TFpDecode)(unsafe.Pointer(p)).FisSpecial = 0 + /* Convert negative numbers to positive. Deal with Infinity, 0.0, and + ** NaN. */ + if **(**float64)(__ccgo_up(bp)) < float64(0) { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = int8('-') + **(**float64)(__ccgo_up(bp)) = -**(**float64)(__ccgo_up(bp)) + } else { + if **(**float64)(__ccgo_up(bp)) == float64(0) { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = int8('+') + (*TFpDecode)(unsafe.Pointer(p)).Fn = int32(1) + (*TFpDecode)(unsafe.Pointer(p)).FiDP = int32(1) + (*TFpDecode)(unsafe.Pointer(p)).Fz = __ccgo_ts + 1848 + return + } else { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = int8('+') + } + } + libc.X__builtin___memcpy_chk(tls, bp+8, bp, uint64(8), ^t__predefined_size_t(0)) + e = libc.Int32FromUint64(**(**Tu64)(__ccgo_up(bp + 8)) >> libc.Int32FromInt32(52) & uint64(0x7ff)) + if e == int32(0x7ff) { + (*TFpDecode)(unsafe.Pointer(p)).FisSpecial = int8(int32(1) + libc.BoolInt32(**(**Tu64)(__ccgo_up(bp + 8)) != uint64(0x7ff0000000000000))) + (*TFpDecode)(unsafe.Pointer(p)).Fn = 0 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = 0 + (*TFpDecode)(unsafe.Pointer(p)).Fz = p + 16 + return + } + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) & uint64(0x000fffffffffffff) + if e == 0 { + nn = _countLeadingZeros(tls, **(**Tu64)(__ccgo_up(bp + 8))) + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) << libc.Uint64FromInt32(nn) + e = -int32(1074) - nn + } else { + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8))<= int32(18) { + v1 = int32(18) + } else { + v1 = iRound + int32(1) + } + _sqlite3Fp2Convert10(tls, **(**Tu64)(__ccgo_up(bp + 8)), e, v1, bp+8, bp+16) + /* Extract significant digits, start at the right-most slot in p->zBuf + ** and working back to the right. "i" keeps track of the next slot in + ** which to store a digit. */ + zBuf = p + 16 + i = int32(SQLITE_U64_DIGITS) + for **(**Tu64)(__ccgo_up(bp + 8)) >= uint64(10) { + kk = libc.Int32FromUint64(**(**Tu64)(__ccgo_up(bp + 8)) % uint64(100) * uint64(2)) + **(**Tu16)(__ccgo_up(zBuf + uintptr(i-int32(2)))) = **(**Tu16)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3DigitPairs)) + uintptr(kk))) + i = i - int32(2) + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) / uint64(100) + } + if **(**Tu64)(__ccgo_up(bp + 8)) != 0 { + i = i - 1 + v1 = i + **(**int8)(__ccgo_up(zBuf + uintptr(v1))) = libc.Int8FromUint64(**(**Tu64)(__ccgo_up(bp + 8)) + uint64('0')) + } + n = int32(SQLITE_U64_DIGITS) - i /* Total number of digits extracted */ + (*TFpDecode)(unsafe.Pointer(p)).FiDP = n + **(**int32)(__ccgo_up(bp + 16)) + if iRound <= 0 { + iRound = (*TFpDecode)(unsafe.Pointer(p)).FiDP - iRound + if iRound == 0 && int32(**(**int8)(__ccgo_up(zBuf + uintptr(i)))) >= int32('5') { + iRound = int32(1) + i = i - 1 + v1 = i + **(**int8)(__ccgo_up(zBuf + uintptr(v1))) = int8('0') + n = n + 1 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = (*TFpDecode)(unsafe.Pointer(p)).FiDP + 1 + } + } + z = zBuf + uintptr(i) /* z points to the first digit */ + if iRound > 0 && (iRound < n || n > mxRound) { + if iRound > mxRound { + iRound = mxRound + } + if iRound == int32(17) { + /* If the precision is exactly 17, which only happens with the "!" + ** flag (ex: "%!.17g") then try to reduce the precision if that + ** yields text that will round-trip to the original floating-point. + ** value. Thus, for exaple, 49.47 will render as 49.47, rather than + ** as 49.469999999999999. */ + if int32(**(**int8)(__ccgo_up(z + 15))) == int32('9') && int32(**(**int8)(__ccgo_up(z + 14))) == int32('9') { + jj = int32(14) + for { + if !(jj > 0 && int32(**(**int8)(__ccgo_up(z + uintptr(jj-int32(1))))) == int32('9')) { + break + } + goto _4 + _4: + ; + jj = jj - 1 + } + if jj == 0 { + v2 = uint64(1) + } else { + v2 = libc.Uint64FromInt32(int32(**(**int8)(__ccgo_up(z))) - int32('0')) + kk1 = int32(1) + for { + if !(kk1 < jj) { + break + } + v2 = v2*uint64(10) + libc.Uint64FromInt8(**(**int8)(__ccgo_up(z + uintptr(kk1)))) - uint64('0') + goto _5 + _5: + ; + kk1 = kk1 + 1 + } + v2 = v2 + 1 + } + if **(**float64)(__ccgo_up(bp)) == _sqlite3Fp10Convert2(tls, v2, **(**int32)(__ccgo_up(bp + 16))+n-jj) { + iRound = jj + int32(1) + } + } else { + if (*TFpDecode)(unsafe.Pointer(p)).FiDP >= n || int32(**(**int8)(__ccgo_up(z + 15))) == int32('0') && int32(**(**int8)(__ccgo_up(z + 14))) == int32('0') && int32(**(**int8)(__ccgo_up(z + 13))) == int32('0') { + jj1 = int32(13) + for { + if !(int32(**(**int8)(__ccgo_up(z + uintptr(jj1-int32(1))))) == int32('0')) { + break + } + goto _6 + _6: + ; + jj1 = jj1 - 1 + } + v21 = libc.Uint64FromInt32(int32(**(**int8)(__ccgo_up(z))) - int32('0')) + kk2 = int32(1) + for { + if !(kk2 < jj1) { + break + } + v21 = v21*uint64(10) + libc.Uint64FromInt8(**(**int8)(__ccgo_up(z + uintptr(kk2)))) - uint64('0') + goto _7 + _7: + ; + kk2 = kk2 + 1 + } + if **(**float64)(__ccgo_up(bp)) == _sqlite3Fp10Convert2(tls, v21, **(**int32)(__ccgo_up(bp + 16))+n-jj1) { + iRound = jj1 + int32(1) + } + } + } + } + n = iRound + if int32(**(**int8)(__ccgo_up(z + uintptr(iRound)))) >= int32('5') { + j = iRound - int32(1) + for int32(1) != 0 { + **(**int8)(__ccgo_up(z + uintptr(j))) = **(**int8)(__ccgo_up(z + uintptr(j))) + 1 + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) <= int32('9') { + break + } + **(**int8)(__ccgo_up(z + uintptr(j))) = int8('0') + if j == 0 { + z = z - 1 + **(**int8)(__ccgo_up(z)) = int8('1') + n = n + 1 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = (*TFpDecode)(unsafe.Pointer(p)).FiDP + 1 + break + } else { + j = j - 1 + } + } + } + } + for int32(**(**int8)(__ccgo_up(z + uintptr(n-int32(1))))) == int32('0') { + n = n - 1 + } + (*TFpDecode)(unsafe.Pointer(p)).Fn = n + (*TFpDecode)(unsafe.Pointer(p)).Fz = z +} + +func _sqlite3Fts5AuxInit(tls *libc.TLS, pApi uintptr) (r int32) { + var aBuiltin [4]struct { + FzFunc uintptr + FpUserData uintptr + FxFunc Tfts5_extension_function + FxDestroy uintptr + } + var i, rc int32 + _, _, _ = aBuiltin, i, rc + aBuiltin = [4]struct { + FzFunc uintptr + FpUserData uintptr + FxFunc Tfts5_extension_function + FxDestroy uintptr + }{ + 0: { + FzFunc: __ccgo_ts + 37688, + FxFunc: __ccgo_fp(_fts5SnippetFunction), + }, + 1: { + FzFunc: __ccgo_ts + 37696, + FxFunc: __ccgo_fp(_fts5HighlightFunction), + }, + 2: { + FzFunc: __ccgo_ts + 37706, + FxFunc: __ccgo_fp(_fts5Bm25Function), + }, + 3: { + FzFunc: __ccgo_ts + 37711, + FxFunc: __ccgo_fp(_fts5GetLocaleFunction), + }, + } + rc = SQLITE_OK /* To iterate through builtin functions */ + i = 0 + for { + if !(rc == SQLITE_OK && i < libc.Int32FromUint64(libc.Uint64FromInt64(128)/libc.Uint64FromInt64(32))) { + break + } + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, Tfts5_extension_function, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfts5_api)(unsafe.Pointer(pApi)).FxCreateFunction})))(tls, pApi, aBuiltin[i].FzFunc, aBuiltin[i].FpUserData, aBuiltin[i].FxFunc, aBuiltin[i].FxDestroy) + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** + */ + +/* #include "fts5Int.h" */ + +// C documentation +// +// /* +// ** Append buffer nData/pData to buffer pBuf. If an OOM error occurs, set +// ** the error code in p. If an error has already occurred when this function +// ** is called, it is a no-op. +// */ +func _sqlite3Fts5BufferAppendBlob(tls *libc.TLS, pRc uintptr, pBuf uintptr, nData Tu32, pData uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if nData != 0 { + if libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)+nData <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) { + v1 = 0 + } else { + v1 = _sqlite3Fts5BufferSize(tls, pRc, pBuf, nData+libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + } + if v1 != 0 { + return + } + libc.X__builtin___memcpy_chk(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), pData, uint64(nData), ^t__predefined_size_t(0)) + v2 = pBuf + 8 + *(*int32)(unsafe.Pointer(v2)) = int32(uint32(*(*int32)(unsafe.Pointer(v2))) + nData) + } +} + +// C documentation +// +// /* +// ** Free any buffer allocated by pBuf. Zero the structure before returning. +// */ +func _sqlite3Fts5BufferFree(tls *libc.TLS, pBuf uintptr) { + Xsqlite3_free(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp) + libc.X__builtin___memset_chk(tls, pBuf, 0, uint64(16), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Call sqlite3_declare_vtab() based on the contents of the configuration +// ** object passed as the only argument. Return SQLITE_OK if successful, or +// ** an SQLite error code if an error occurs. +// */ +func _sqlite3Fts5ConfigDeclareVtab(tls *libc.TLS, pConfig uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var zSep, zSql, v2 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _ = i, zSep, zSql, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + zSql = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38625, 0) + i = 0 + for { + if !(zSql != 0 && i < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if i == 0 { + v2 = __ccgo_ts + 1702 + } else { + v2 = __ccgo_ts + 16558 + } + zSep = v2 + zSql = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38641, libc.VaList(bp+16, zSql, zSep, **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(i)*8)))) + goto _1 + _1: + ; + i = i + 1 + } + zSql = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38648, libc.VaList(bp+16, zSql, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, __ccgo_ts+38288)) + if zSql != 0 { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_declare_vtab(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql) + Xsqlite3_free(tls, zSql) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Load the contents of the %_config table into memory. +// */ +func _sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iVersion int32 + var pVal, zK, zSelect, zSql uintptr + var _ /* bDummy at bp+12 */ int32 + var _ /* p at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _, _, _, _ = iVersion, pVal, zK, zSelect, zSql + zSelect = __ccgo_ts + 38756 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = SQLITE_OK + iVersion = 0 + /* Set default values */ + (*TFts5Config)(unsafe.Pointer(pConfig)).Fpgsz = int32(FTS5_DEFAULT_PAGE_SIZE) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = int32(FTS5_DEFAULT_AUTOMERGE) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = int32(FTS5_DEFAULT_USERMERGE) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = int32(FTS5_DEFAULT_CRISISMERGE) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnHashSize = libc.Int32FromInt32(1024) * libc.Int32FromInt32(1024) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnDeleteMerge = int32(FTS5_DEFAULT_DELETE_AUTOMERGE) + zSql = _sqlite3Fts5Mprintf(tls, bp+8, zSelect, libc.VaList(bp+24, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + if zSql != 0 { + **(**int32)(__ccgo_up(bp + 8)) = Xsqlite3_prepare_v2(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -int32(1), bp, uintptr(0)) + Xsqlite3_free(tls, zSql) + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zK = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + pVal = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + if 0 == Xsqlite3_stricmp(tls, zK, __ccgo_ts+38788) { + iVersion = Xsqlite3_value_int(tls, pVal) + } else { + **(**int32)(__ccgo_up(bp + 12)) = 0 + _sqlite3Fts5ConfigSetValue(tls, pConfig, zK, pVal, bp+12) + } + } + **(**int32)(__ccgo_up(bp + 8)) = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && iVersion != int32(FTS5_CURRENT_VERSION) && iVersion != int32(FTS5_CURRENT_VERSION_SECUREDELETE) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_ERROR) + _sqlite3Fts5ConfigErrmsg(tls, pConfig, __ccgo_ts+38796, libc.VaList(bp+24, iVersion, int32(FTS5_CURRENT_VERSION), int32(FTS5_CURRENT_VERSION_SECUREDELETE))) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FiVersion = iVersion + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + (*TFts5Config)(unsafe.Pointer(pConfig)).FiCookie = iCookie + } + return **(**int32)(__ccgo_up(bp + 8)) +} + +// C documentation +// +// /* +// ** Arguments nArg/azArg contain the string arguments passed to the xCreate +// ** or xConnect method of the virtual table. This function attempts to +// ** allocate an instance of Fts5Config containing the results of parsing +// ** those arguments. +// ** +// ** If successful, SQLITE_OK is returned and *ppOut is set to point to the +// ** new Fts5Config object. If an error occurs, an SQLite error code is +// ** returned, *ppOut is set to NULL and an error message may be left in +// ** *pzErr. It is the responsibility of the caller to eventually free any +// ** such error message using sqlite3_free(). +// */ +func _sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int32, azArg uintptr, ppOut uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bOption, i int32 + var nByte Tsqlite3_int64 + var pRet, z, zOrig, zTail, v1, v2 uintptr + var _ /* bDummy at bp+28 */ int32 + var _ /* bMustBeCol at bp+24 */ int32 + var _ /* bUnindexed at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + var _ /* zOne at bp+8 */ uintptr + var _ /* zTwo at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _ = bOption, i, nByte, pRet, z, zOrig, zTail, v1, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 4)) = 0 /* True if there are one or more UNINDEXED */ + v1 = Xsqlite3_malloc64(tls, uint64(256)) + pRet = v1 + **(**uintptr)(__ccgo_up(ppOut)) = v1 + if pRet == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, pRet, 0, uint64(256), ^t__predefined_size_t(0)) + (*TFts5Config)(unsafe.Pointer(pRet)).FpGlobal = pGlobal + (*TFts5Config)(unsafe.Pointer(pRet)).Fdb = db + (*TFts5Config)(unsafe.Pointer(pRet)).FiCookie = -int32(1) + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(nArg) * (libc.Uint64FromInt64(8) + libc.Uint64FromInt64(1))) + (*TFts5Config)(unsafe.Pointer(pRet)).FazCol = _sqlite3Fts5MallocZero(tls, bp, nByte) + if (*TFts5Config)(unsafe.Pointer(pRet)).FazCol != 0 { + v1 = (*TFts5Config)(unsafe.Pointer(pRet)).FazCol + uintptr(nArg)*8 + } else { + v1 = uintptr(0) + } + (*TFts5Config)(unsafe.Pointer(pRet)).FabUnindexed = v1 + (*TFts5Config)(unsafe.Pointer(pRet)).FzDb = _sqlite3Fts5Strndup(tls, bp, **(**uintptr)(__ccgo_up(azArg + 1*8)), -int32(1)) + (*TFts5Config)(unsafe.Pointer(pRet)).FzName = _sqlite3Fts5Strndup(tls, bp, **(**uintptr)(__ccgo_up(azArg + 2*8)), -int32(1)) + (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize = int32(1) + (*TFts5Config)(unsafe.Pointer(pRet)).FeDetail = FTS5_DETAIL_FULL + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && Xsqlite3_stricmp(tls, (*TFts5Config)(unsafe.Pointer(pRet)).FzName, __ccgo_ts+38288) == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38399, libc.VaList(bp+40, (*TFts5Config)(unsafe.Pointer(pRet)).FzName)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + i = int32(3) + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < nArg) { + break + } + zOrig = **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + bOption = 0 + **(**int32)(__ccgo_up(bp + 24)) = 0 + z = _fts5ConfigGobbleWord(tls, bp, zOrig, bp+8, bp+24) + z = _fts5ConfigSkipWhitespace(tls, z) + if z != 0 && int32(**(**int8)(__ccgo_up(z))) == int32('=') { + bOption = int32(1) + z = z + 1 + if **(**int32)(__ccgo_up(bp + 24)) != 0 { + z = uintptr(0) + } + } + z = _fts5ConfigSkipWhitespace(tls, z) + if z != 0 && **(**int8)(__ccgo_up(z)) != 0 { + z = _fts5ConfigGobbleWord(tls, bp, z, bp+16, bp+28) + if z != 0 && **(**int8)(__ccgo_up(z)) != 0 { + z = uintptr(0) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if z == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38428, libc.VaList(bp+40, zOrig)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + if bOption != 0 { + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v1 = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + v1 = __ccgo_ts + 1702 + } + if **(**uintptr)(__ccgo_up(bp + 16)) != 0 { + v2 = **(**uintptr)(__ccgo_up(bp + 16)) + } else { + v2 = __ccgo_ts + 1702 + } + **(**int32)(__ccgo_up(bp)) = _fts5ConfigParseSpecial(tls, pRet, v1, v2, pzErr) + } else { + **(**int32)(__ccgo_up(bp)) = _fts5ConfigParseColumn(tls, pRet, **(**uintptr)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp + 16)), pzErr, bp+4) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + } + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 16))) + goto _3 + _3: + ; + i = i + 1 + } + /* We only allow contentless_delete=1 if the table is indeed contentless. */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessDelete != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FeContent != int32(FTS5_CONTENT_NONE) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38448, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* We only allow contentless_delete=1 if columnsize=0 is not present. + ** + ** This restriction may be removed at some point. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessDelete != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38498, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* We only allow contentless_unindexed=1 if the table is actually a + ** contentless one. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessUnindexed != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FeContent != int32(FTS5_CONTENT_NONE) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38553, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* If no zContent option was specified, fill in the default values. */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FzContent == uintptr(0) { + zTail = uintptr(0) + if (*TFts5Config)(unsafe.Pointer(pRet)).FeContent == FTS5_CONTENT_NORMAL { + zTail = __ccgo_ts + 37911 + } else { + if **(**int32)(__ccgo_up(bp + 4)) != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessUnindexed != 0 { + (*TFts5Config)(unsafe.Pointer(pRet)).FeContent = int32(FTS5_CONTENT_UNINDEXED) + zTail = __ccgo_ts + 37911 + } else { + if (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize != 0 { + zTail = __ccgo_ts + 38606 + } + } + } + if zTail != 0 { + (*TFts5Config)(unsafe.Pointer(pRet)).FzContent = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38614, libc.VaList(bp+40, (*TFts5Config)(unsafe.Pointer(pRet)).FzDb, (*TFts5Config)(unsafe.Pointer(pRet)).FzName, zTail)) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FzContentRowid == uintptr(0) { + (*TFts5Config)(unsafe.Pointer(pRet)).FzContentRowid = _sqlite3Fts5Strndup(tls, bp, __ccgo_ts+18310, -int32(1)) + } + /* Formulate the zContentExprlist text */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _fts5ConfigMakeExprlist(tls, pRet) + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + _sqlite3Fts5ConfigFree(tls, pRet) + **(**uintptr)(__ccgo_up(ppOut)) = uintptr(0) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Parameter zIn contains a rank() function specification. The format of +// ** this is: +// ** +// ** + Bareword (function name) +// ** + Open parenthesis - "(" +// ** + Zero or more SQL literals in a comma separated list +// ** + Close parenthesis - ")" +// */ +func _sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRankArgs uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p, pArgs, pRank, zRank, zRankArgs uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _ = p, pArgs, pRank, zRank, zRankArgs + p = zIn + zRank = uintptr(0) + zRankArgs = uintptr(0) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**uintptr)(__ccgo_up(pzRank)) = uintptr(0) + **(**uintptr)(__ccgo_up(pzRankArgs)) = uintptr(0) + if p == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + p = _fts5ConfigSkipWhitespace(tls, p) + pRank = p + p = _fts5ConfigSkipBareword(tls, p) + if p != 0 { + zRank = _sqlite3Fts5MallocZero(tls, bp, int64(uintptr(1)+p)-int64(pRank)) + if zRank != 0 { + libc.X__builtin___memcpy_chk(tls, zRank, pRank, libc.Uint64FromInt64(int64(p)-int64(pRank)), ^t__predefined_size_t(0)) + } + } else { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + p = _fts5ConfigSkipWhitespace(tls, p) + if int32(**(**int8)(__ccgo_up(p))) != int32('(') { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + p = p + 1 + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + p = _fts5ConfigSkipWhitespace(tls, p) + pArgs = p + if int32(**(**int8)(__ccgo_up(p))) != int32(')') { + p = _fts5ConfigSkipArgs(tls, p) + if p == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + zRankArgs = _sqlite3Fts5MallocZero(tls, bp, int64(uintptr(1)+p)-int64(pArgs)) + if zRankArgs != 0 { + libc.X__builtin___memcpy_chk(tls, zRankArgs, pArgs, libc.Uint64FromInt64(int64(p)-int64(pArgs)), ^t__predefined_size_t(0)) + } + } + } + } + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + Xsqlite3_free(tls, zRank) + } else { + **(**uintptr)(__ccgo_up(pzRank)) = zRank + **(**uintptr)(__ccgo_up(pzRankArgs)) = zRankArgs + } + return **(**int32)(__ccgo_up(bp)) +} + +func _sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVal uintptr, pbBadkey uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bVal, bVal1, nAutomerge, nCrisisMerge, nHashSize, nUsermerge, nVal, pgsz, rc, v1 int32 + var zIn uintptr + var _ /* zRank at bp+0 */ uintptr + var _ /* zRankArgs at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = bVal, bVal1, nAutomerge, nCrisisMerge, nHashSize, nUsermerge, nVal, pgsz, rc, zIn, v1 + rc = SQLITE_OK + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38674) { + pgsz = 0 + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + pgsz = Xsqlite3_value_int(tls, pVal) + } + if pgsz < int32(32) || pgsz > libc.Int32FromInt32(64)*libc.Int32FromInt32(1024) { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).Fpgsz = pgsz + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38679) { + nHashSize = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nHashSize = Xsqlite3_value_int(tls, pVal) + } + if nHashSize <= 0 { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FnHashSize = nHashSize + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38688) { + nAutomerge = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nAutomerge = Xsqlite3_value_int(tls, pVal) + } + if nAutomerge < 0 || nAutomerge > int32(64) { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + if nAutomerge == int32(1) { + nAutomerge = int32(FTS5_DEFAULT_AUTOMERGE) + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = nAutomerge + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38698) { + nUsermerge = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nUsermerge = Xsqlite3_value_int(tls, pVal) + } + if nUsermerge < int32(2) || nUsermerge > int32(16) { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = nUsermerge + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38708) { + nCrisisMerge = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nCrisisMerge = Xsqlite3_value_int(tls, pVal) + } + if nCrisisMerge < 0 { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + if nCrisisMerge <= int32(1) { + nCrisisMerge = int32(FTS5_DEFAULT_CRISISMERGE) + } + if nCrisisMerge >= int32(FTS5_MAX_SEGMENT) { + nCrisisMerge = libc.Int32FromInt32(FTS5_MAX_SEGMENT) - libc.Int32FromInt32(1) + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = nCrisisMerge + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38720) { + nVal = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nVal = Xsqlite3_value_int(tls, pVal) + } else { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } + if nVal < 0 { + nVal = int32(FTS5_DEFAULT_DELETE_AUTOMERGE) + } + if nVal > int32(100) { + nVal = 0 + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FnDeleteMerge = nVal + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38288) { + zIn = Xsqlite3_value_text(tls, pVal) + rc = _sqlite3Fts5ConfigParseRank(tls, zIn, bp, bp+8) + if rc == SQLITE_OK { + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzRankArgs) + (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank = **(**uintptr)(__ccgo_up(bp)) + (*TFts5Config)(unsafe.Pointer(pConfig)).FzRankArgs = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + if rc == int32(SQLITE_ERROR) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38732) { + bVal = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + bVal = Xsqlite3_value_int(tls, pVal) + } + if bVal < 0 { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + if bVal != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FbSecureDelete = v1 + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38746) { + bVal1 = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + bVal1 = Xsqlite3_value_int(tls, pVal) + } + if bVal1 < 0 { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + if bVal1 != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken = v1 + } + } else { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } + } + } + } + } + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Create the shadow table named zPost, with definition zDefn. Return +// ** SQLITE_OK if successful, or an SQLite error code otherwise. +// */ +func _sqlite3Fts5CreateTable(tls *libc.TLS, pConfig uintptr, zPost uintptr, zDefn uintptr, bWithout int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var rc int32 + var v1 uintptr + var _ /* zErr at bp+0 */ uintptr + _, _ = rc, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if bWithout != 0 { + v1 = __ccgo_ts + 32405 + } else { + v1 = __ccgo_ts + 1702 + } + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, bp, __ccgo_ts+41808, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zPost, zDefn, v1)) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+41838, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zPost, **(**uintptr)(__ccgo_up(bp)))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Drop all shadow tables. Return SQLITE_OK if successful or an SQLite error +// ** code otherwise. +// */ +func _sqlite3Fts5DropAll(tls *libc.TLS, pConfig uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var rc int32 + _ = rc + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41586, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41690, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41728, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + return rc +} + +func _sqlite3Fts5ExprAnd(tls *libc.TLS, pp1 uintptr, p2 uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var ap, p1 uintptr + var i, nPhrase int32 + var _ /* sParse at bp+0 */ TFts5Parse + _, _, _, _ = ap, i, nPhrase, p1 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + if **(**uintptr)(__ccgo_up(pp1)) != 0 && p2 != 0 { + p1 = **(**uintptr)(__ccgo_up(pp1)) + nPhrase = (*TFts5Expr)(unsafe.Pointer(p1)).FnPhrase + (*TFts5Expr)(unsafe.Pointer(p2)).FnPhrase + (*TFts5Expr)(unsafe.Pointer(p1)).FpRoot = _sqlite3Fts5ParseNode(tls, bp, int32(FTS5_AND), (*TFts5Expr)(unsafe.Pointer(p1)).FpRoot, (*TFts5Expr)(unsafe.Pointer(p2)).FpRoot, uintptr(0)) + (*TFts5Expr)(unsafe.Pointer(p2)).FpRoot = uintptr(0) + if (**(**TFts5Parse)(__ccgo_up(bp))).Frc == SQLITE_OK { + ap = Xsqlite3_realloc64(tls, (*TFts5Expr)(unsafe.Pointer(p1)).FapExprPhrase, uint64(libc.Uint64FromInt32(nPhrase)*uint64(8))) + if ap == uintptr(0) { + (**(**TFts5Parse)(__ccgo_up(bp))).Frc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memmove_chk(tls, ap+uintptr((*TFts5Expr)(unsafe.Pointer(p2)).FnPhrase)*8, ap, libc.Uint64FromInt32((*TFts5Expr)(unsafe.Pointer(p1)).FnPhrase)*uint64(8), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < (*TFts5Expr)(unsafe.Pointer(p2)).FnPhrase) { + break + } + **(**uintptr)(__ccgo_up(ap + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(p2)).FapExprPhrase + uintptr(i)*8)) + goto _1 + _1: + ; + i = i + 1 + } + (*TFts5Expr)(unsafe.Pointer(p1)).FnPhrase = nPhrase + (*TFts5Expr)(unsafe.Pointer(p1)).FapExprPhrase = ap + } + } + Xsqlite3_free(tls, (*TFts5Expr)(unsafe.Pointer(p2)).FapExprPhrase) + Xsqlite3_free(tls, p2) + } else { + if p2 != 0 { + **(**uintptr)(__ccgo_up(pp1)) = p2 + } + } + return (**(**TFts5Parse)(__ccgo_up(bp))).Frc +} + +// C documentation +// +// /* +// ** Clear the position lists associated with all phrases in the expression +// ** passed as the first argument. Argument bLive is true if the expression +// ** might be pointing to a real entry, otherwise it has just been reset. +// ** +// ** At present this function is only used for detail=col and detail=none +// ** fts5 tables. This implies that all phrases must be at most 1 token +// ** in size, as phrase matches are not supported without detail=full. +// */ +func _sqlite3Fts5ExprClearPoslists(tls *libc.TLS, pExpr uintptr, bLive int32) (r uintptr) { + var i int32 + var pBuf, pNode, pRet uintptr + _, _, _, _ = i, pBuf, pNode, pRet + pRet = Xsqlite3_malloc64(tls, uint64(uint64(16)*libc.Uint64FromInt32((*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase))) + if pRet != 0 { + libc.X__builtin___memset_chk(tls, pRet, 0, uint64(16)*libc.Uint64FromInt32((*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase) { + break + } + pBuf = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*8)) + 8 + pNode = (*TFts5ExprPhrase)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*8)))).FpNode + if bLive != 0 && ((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn == 0 || (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid != (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pExpr)).FpRoot)).FiRowid || (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof != 0) { + (**(**TFts5PoslistPopulator)(__ccgo_up(pRet + uintptr(i)*16))).FbMiss = int32(1) + } else { + (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn = 0 + } + goto _1 + _1: + ; + i = i + 1 + } + } + return pRet +} + +// C documentation +// +// /* +// ** Create a new FTS5 expression by cloning phrase iPhrase of the +// ** expression passed as the second argument. +// */ +func _sqlite3Fts5ExprClonePhrase(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppNew uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, tflags int32 + var nByte Tsqlite3_int64 + var p, pColset, pColsetOrig, pNew, pOrig uintptr + var _ /* rc at bp+0 */ int32 + var _ /* sCtx at bp+8 */ TTokenCtx + _, _, _, _, _, _, _, _ = i, nByte, p, pColset, pColsetOrig, pNew, pOrig, tflags + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Return code */ + pOrig = uintptr(0) /* The phrase extracted from pExpr */ + pNew = uintptr(0) /* Expression to return via *ppNew */ + **(**TTokenCtx)(__ccgo_up(bp + 8)) = TTokenCtx{} /* Context object for fts5ParseTokenize */ + if !(pExpr != 0) || iPhrase < 0 || iPhrase >= (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_RANGE) + } else { + pOrig = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) + pNew = _sqlite3Fts5MallocZero(tls, bp, int64(40)) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase = _sqlite3Fts5MallocZero(tls, bp, int64(8)) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+48)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(8))) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt32(libc.Int32FromInt32(2))*libc.Uint64FromInt64(8))) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && pOrig != uintptr(0) { + pColsetOrig = (*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer((*TFts5ExprPhrase)(unsafe.Pointer(pOrig)).FpNode)).FpNear)).FpColset + if pColsetOrig != 0 { + nByte = libc.Int64FromUint64(libc.Uint64FromInt64(8) * libc.Uint64FromInt32(((*TFts5Colset)(unsafe.Pointer(pColsetOrig)).FnCol+libc.Int32FromInt32(2))/libc.Int32FromInt32(2))) + pColset = _sqlite3Fts5MallocZero(tls, bp, nByte) + if pColset != 0 { + libc.X__builtin___memcpy_chk(tls, pColset, pColsetOrig, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + } + (*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear)).FpColset = pColset + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if (*TFts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm != 0 { /* Used to iterate through phrase terms */ + (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpConfig = (*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < (*TFts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm) { + break + } + tflags = 0 + p = pOrig + 32 + uintptr(i)*40 + for { + if !(p != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK) { + break + } + **(**int32)(__ccgo_up(bp)) = _fts5ParseTokenize(tls, bp+8, tflags, (*TFts5ExprTerm)(unsafe.Pointer(p)).FpTerm, (*TFts5ExprTerm)(unsafe.Pointer(p)).FnFullTerm, 0, 0) + tflags = int32(FTS5_TOKEN_COLOCATED) + goto _2 + _2: + ; + p = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpSynonym + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*(*TFts5ExprTerm)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase + 32 + uintptr(i)*40))).FbPrefix = (*(*TFts5ExprTerm)(unsafe.Pointer(pOrig + 32 + uintptr(i)*40))).FbPrefix + (*(*TFts5ExprTerm)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase + 32 + uintptr(i)*40))).FbFirst = (*(*TFts5ExprTerm)(unsafe.Pointer(pOrig + 32 + uintptr(i)*40))).FbFirst + } + goto _1 + _1: + ; + i = i + 1 + } + } else { + /* This happens when parsing a token or quoted phrase that contains + ** no token characters at all. (e.g ... MATCH '""'). */ + (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(40))) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase != 0 { + /* All the allocations succeeded. Put the expression object together. */ + (*TFts5Expr)(unsafe.Pointer(pNew)).FpIndex = (*TFts5Expr)(unsafe.Pointer(pExpr)).FpIndex + (*TFts5Expr)(unsafe.Pointer(pNew)).FpConfig = (*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig + (*TFts5Expr)(unsafe.Pointer(pNew)).FnPhrase = int32(1) + **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase)) = (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase + *(*uintptr)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear + 24)) = (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase + (*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear)).FnPhrase = int32(1) + (*TFts5ExprPhrase)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase)).FpNode = (*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot + if (*TFts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm == int32(1) && (*(*TFts5ExprTerm)(unsafe.Pointer(pOrig + 32))).FpSynonym == uintptr(0) && libc.Int32FromUint8((*(*TFts5ExprTerm)(unsafe.Pointer(pOrig + 32))).FbFirst) == 0 { + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = int32(FTS5_TERM) + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = __ccgo_fp(_fts5ExprNodeNext_TERM) + } else { + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = int32(FTS5_STRING) + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = __ccgo_fp(_fts5ExprNodeNext_STRING) + } + } else { + _sqlite3Fts5ExprFree(tls, pNew) + _fts5ExprPhraseFree(tls, (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase) + pNew = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppNew)) = pNew + return **(**int32)(__ccgo_up(bp)) +} + +func _sqlite3Fts5ExprNew(tls *libc.TLS, pConfig uintptr, bPhraseToAnd int32, iCol int32, zExpr uintptr, ppNew uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var n, t int32 + var pColset, pEngine, pNew, v1 uintptr + var _ /* sParse at bp+0 */ TFts5Parse + var _ /* token at bp+48 */ TFts5Token + var _ /* z at bp+64 */ uintptr + _, _, _, _, _, _ = n, pColset, pEngine, pNew, t, v1 + **(**uintptr)(__ccgo_up(bp + 64)) = zExpr + **(**uintptr)(__ccgo_up(ppNew)) = uintptr(0) + **(**uintptr)(__ccgo_up(pzErr)) = uintptr(0) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TFts5Parse)(__ccgo_up(bp))).FbPhraseToAnd = bPhraseToAnd + pEngine = _sqlite3Fts5ParserAlloc(tls, __ccgo_fp(_fts5ParseAlloc)) + if pEngine == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (**(**TFts5Parse)(__ccgo_up(bp))).FpConfig = pConfig + for cond := true; cond; cond = (**(**TFts5Parse)(__ccgo_up(bp))).Frc == SQLITE_OK && t != FTS5_EOF { + t = _fts5ExprGetToken(tls, bp, bp+64, bp+48) + _sqlite3Fts5Parser(tls, pEngine, t, **(**TFts5Token)(__ccgo_up(bp + 48)), bp) + } + _sqlite3Fts5ParserFree(tls, pEngine, __ccgo_fp(_fts5ParseFree)) + /* If the LHS of the MATCH expression was a user column, apply the + ** implicit column-filter. */ + if (**(**TFts5Parse)(__ccgo_up(bp))).Frc == SQLITE_OK && iCol < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol { + n = libc.Int32FromUint64(libc.Uint64FromInt64(8) * libc.Uint64FromInt32((libc.Int32FromInt32(1)+libc.Int32FromInt32(2))/libc.Int32FromInt32(2))) + pColset = _sqlite3Fts5MallocZero(tls, bp+16, int64(n)) + if pColset != 0 { + (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol = int32(1) + *(*int32)(unsafe.Pointer(pColset + 4)) = iCol + _sqlite3Fts5ParseSetColset(tls, bp, (**(**TFts5Parse)(__ccgo_up(bp))).FpExpr, pColset) + } + } + if (**(**TFts5Parse)(__ccgo_up(bp))).Frc == SQLITE_OK { + v1 = Xsqlite3_malloc64(tls, uint64(40)) + pNew = v1 + **(**uintptr)(__ccgo_up(ppNew)) = v1 + if pNew == uintptr(0) { + (**(**TFts5Parse)(__ccgo_up(bp))).Frc = int32(SQLITE_NOMEM) + _sqlite3Fts5ParseNodeFree(tls, (**(**TFts5Parse)(__ccgo_up(bp))).FpExpr) + } else { + (*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot = (**(**TFts5Parse)(__ccgo_up(bp))).FpExpr + (*TFts5Expr)(unsafe.Pointer(pNew)).FpIndex = uintptr(0) + (*TFts5Expr)(unsafe.Pointer(pNew)).FpConfig = pConfig + (*TFts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase = (**(**TFts5Parse)(__ccgo_up(bp))).FapPhrase + (*TFts5Expr)(unsafe.Pointer(pNew)).FnPhrase = (**(**TFts5Parse)(__ccgo_up(bp))).FnPhrase + (*TFts5Expr)(unsafe.Pointer(pNew)).FbDesc = 0 + (**(**TFts5Parse)(__ccgo_up(bp))).FapPhrase = uintptr(0) + } + } else { + _sqlite3Fts5ParseNodeFree(tls, (**(**TFts5Parse)(__ccgo_up(bp))).FpExpr) + } + Xsqlite3_free(tls, (**(**TFts5Parse)(__ccgo_up(bp))).FapPhrase) + if uintptr(0) == **(**uintptr)(__ccgo_up(pzErr)) { + **(**uintptr)(__ccgo_up(pzErr)) = (**(**TFts5Parse)(__ccgo_up(bp))).FzErr + } else { + Xsqlite3_free(tls, (**(**TFts5Parse)(__ccgo_up(bp))).FzErr) + } + return (**(**TFts5Parse)(__ccgo_up(bp))).Frc +} + +// C documentation +// +// /* +// ** Empty (but do not delete) a hash table. +// */ +func _sqlite3Fts5HashClear(tls *libc.TLS, pHash uintptr) { + var i int32 + var pNext, pSlot uintptr + _, _, _ = i, pNext, pSlot + i = 0 + for { + if !(i < (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot) { + break + } + pSlot = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(i)*8)) + for { + if !(pSlot != 0) { + break + } + pNext = (*TFts5HashEntry)(unsafe.Pointer(pSlot)).FpHashNext + Xsqlite3_free(tls, pSlot) + goto _2 + _2: + ; + pSlot = pNext + } + goto _1 + _1: + ; + i = i + 1 + } + libc.X__builtin___memset_chk(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot, 0, libc.Uint64FromInt32((*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot)*uint64(8), ^t__predefined_size_t(0)) + (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry = 0 +} + +// C documentation +// +// /* +// ** Allocate a new hash table. +// */ +func _sqlite3Fts5HashNew(tls *libc.TLS, pConfig uintptr, ppNew uintptr, pnByte uintptr) (r int32) { + var nByte Tsqlite3_int64 + var pNew, v1 uintptr + var rc int32 + _, _, _, _ = nByte, pNew, rc, v1 + rc = SQLITE_OK + v1 = Xsqlite3_malloc64(tls, uint64(40)) + pNew = v1 + **(**uintptr)(__ccgo_up(ppNew)) = v1 + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pNew, 0, uint64(40), ^t__predefined_size_t(0)) + (*TFts5Hash)(unsafe.Pointer(pNew)).FpnByte = pnByte + (*TFts5Hash)(unsafe.Pointer(pNew)).FeDetail = (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail + (*TFts5Hash)(unsafe.Pointer(pNew)).FnSlot = int32(1024) + nByte = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt32((*TFts5Hash)(unsafe.Pointer(pNew)).FnSlot)) + (*TFts5Hash)(unsafe.Pointer(pNew)).FaSlot = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if (*TFts5Hash)(unsafe.Pointer(pNew)).FaSlot == uintptr(0) { + Xsqlite3_free(tls, pNew) + **(**uintptr)(__ccgo_up(ppNew)) = uintptr(0) + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, (*TFts5Hash)(unsafe.Pointer(pNew)).FaSlot, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Query the hash table for a doclist associated with term pTerm/nTerm. +// */ +func _sqlite3Fts5HashQuery(tls *libc.TLS, pHash uintptr, nPre int32, pTerm uintptr, nTerm int32, ppOut uintptr, pnDoclist uintptr) (r int32) { + var iHash uint32 + var nHashPre, nList int32 + var p, pFaux, pRet, zKey, v2 uintptr + _, _, _, _, _, _, _, _ = iHash, nHashPre, nList, p, pFaux, pRet, zKey, v2 + iHash = _fts5HashKey(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot, pTerm, nTerm) + zKey = uintptr(0) + p = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) + for { + if !(p != 0) { + break + } + zKey = p + 1*48 + if nTerm == (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey && libc.Xmemcmp(tls, zKey, pTerm, libc.Uint64FromInt32(nTerm)) == 0 { + break + } + goto _1 + _1: + ; + p = (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext + } + if p != 0 { + nHashPre = libc.Int32FromUint64(uint64(48) + libc.Uint64FromInt32(nTerm)) + nList = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData - nHashPre + v2 = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nPre+nList+int32(10))) + **(**uintptr)(__ccgo_up(ppOut)) = v2 + pRet = v2 + if pRet != 0 { + pFaux = pRet + uintptr(nPre-nHashPre) + libc.X__builtin___memcpy_chk(tls, pRet+uintptr(nPre), p+uintptr(nHashPre), libc.Uint64FromInt32(nList), ^t__predefined_size_t(0)) + nList = nList + _fts5HashAddPoslistSize(tls, pHash, p, pFaux) + **(**int32)(__ccgo_up(pnDoclist)) = nList + } else { + **(**int32)(__ccgo_up(pnDoclist)) = 0 + return int32(SQLITE_NOMEM) + } + } else { + **(**uintptr)(__ccgo_up(ppOut)) = uintptr(0) + **(**int32)(__ccgo_up(pnDoclist)) = 0 + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Add an entry to the in-memory hash table. The key is the concatenation +// ** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos). +// ** +// ** (bByte || pToken) -> (iRowid,iCol,iPos) +// ** +// ** Or, if iCol is negative, then the value is a delete marker. +// */ +func _sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid Ti64, iCol int32, iPos int32, bByte int8, pToken uintptr, nToken int32) (r int32) { + var bNew, nIncr, rc, v2 int32 + var iDiff Tu64 + var iHash uint32 + var nByte, nNew Tsqlite3_int64 + var p, pNew, pPtr, pp, zKey, zKey1, v6 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNew, iDiff, iHash, nByte, nIncr, nNew, p, pNew, pPtr, pp, rc, zKey, zKey1, v2, v6 + nIncr = 0 /* If non-delete entry should be written */ + bNew = libc.BoolInt32((*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL) + /* Attempt to locate an existing hash entry */ + iHash = _fts5HashKey2(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot, libc.Uint8FromInt8(bByte), pToken, nToken) + p = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) + for { + if !(p != 0) { + break + } + zKey = p + 1*48 + if int32(**(**int8)(__ccgo_up(zKey))) == int32(bByte) && (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey == nToken+int32(1) && libc.Xmemcmp(tls, zKey+1, pToken, libc.Uint64FromInt32(nToken)) == 0 { + break + } + goto _1 + _1: + ; + p = (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext + } + /* If an existing hash entry cannot be found, create a new one. */ + if p == uintptr(0) { + nByte = libc.Int64FromUint64(uint64(48) + libc.Uint64FromInt32(nToken+libc.Int32FromInt32(1)) + uint64(1) + uint64(64)) + if nByte < int64(128) { + nByte = int64(128) + } + /* Grow the Fts5Hash.aSlot[] array if necessary. */ + if (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry*int32(2) >= (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot { + rc = _fts5HashResize(tls, pHash) + if rc != SQLITE_OK { + return rc + } + iHash = _fts5HashKey2(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot, libc.Uint8FromInt8(bByte), pToken, nToken) + } + /* Allocate new Fts5HashEntry and add it to the hash table. */ + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if !(p != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, p, 0, uint64(48), ^t__predefined_size_t(0)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc = int32(nByte) + zKey1 = p + 1*48 + **(**int8)(__ccgo_up(zKey1)) = bByte + libc.X__builtin___memcpy_chk(tls, zKey1+1, pToken, libc.Uint64FromInt32(nToken), ^t__predefined_size_t(0)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey = nToken + int32(1) + **(**int8)(__ccgo_up(zKey1 + uintptr(nToken+int32(1)))) = int8('\000') + (*TFts5HashEntry)(unsafe.Pointer(p)).FnData = libc.Int32FromUint64(libc.Uint64FromInt32(nToken+int32(1)) + uint64(48)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) = p + (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry = (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry + 1 + /* Add the first rowid field to the hash-entry */ + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, p+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt64(iRowid)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid + (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail != int32(FTS5_DETAIL_NONE) { + **(**int32)(__ccgo_up(p + 24)) += int32(1) + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v2 = 0 + } else { + v2 = -int32(1) + } + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + } + } else { + /* Appending to an existing hash-entry. Check that there is enough + ** space to append the largest possible new entry. Worst case scenario + ** is: + ** + ** + 9 bytes for a new rowid, + ** + 4 byte reserved for the "poslist size" varint. + ** + 1 byte for a "new column" byte, + ** + 3 bytes for a new column number (16-bit max) as a varint, + ** + 5 bytes for the new position offset (32-bit max). + */ + if (*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc-(*TFts5HashEntry)(unsafe.Pointer(p)).FnData < libc.Int32FromInt32(9)+libc.Int32FromInt32(4)+libc.Int32FromInt32(1)+libc.Int32FromInt32(3)+libc.Int32FromInt32(5) { + nNew = int64((*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc * int32(2)) + pNew = Xsqlite3_realloc64(tls, p, libc.Uint64FromInt64(nNew)) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TFts5HashEntry)(unsafe.Pointer(pNew)).FnAlloc = int32(nNew) + pp = (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != p) { + break + } + goto _3 + _3: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + } + **(**uintptr)(__ccgo_up(pp)) = pNew + p = pNew + } + nIncr = nIncr - (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + } + pPtr = p + /* If this is a new rowid, append the 4-byte size field for the previous + ** entry, and the new rowid for this entry. */ + if iRowid != (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid { + iDiff = libc.Uint64FromInt64(iRowid) - libc.Uint64FromInt64((*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid) + _fts5HashAddPoslistSize(tls, pHash, p, uintptr(0)) + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), iDiff) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid + bNew = int32(1) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail != int32(FTS5_DETAIL_NONE) { + **(**int32)(__ccgo_up(p + 24)) += int32(1) + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v2 = 0 + } else { + v2 = -int32(1) + } + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = 0 + } + } + if iCol >= 0 { + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == int32(FTS5_DETAIL_NONE) { + (*TFts5HashEntry)(unsafe.Pointer(p)).FbContent = uint8(1) + } else { + /* Append a new column value, if necessary */ + if iCol != int32((*TFts5HashEntry)(unsafe.Pointer(p)).FiCol) { + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v6 = p + 24 + v2 = *(*int32)(unsafe.Pointer(v6)) + *(*int32)(unsafe.Pointer(v6)) = *(*int32)(unsafe.Pointer(v6)) + 1 + **(**Tu8)(__ccgo_up(pPtr + uintptr(v2))) = uint8(0x01) + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt32(iCol)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(iCol) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = 0 + } else { + bNew = int32(1) + v2 = iCol + iPos = v2 + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + } + } + /* Append the new position offset, if necessary */ + if bNew != 0 { + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt32(iPos-(*TFts5HashEntry)(unsafe.Pointer(p)).FiPos+int32(2))) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = iPos + } + } + } else { + /* This is a delete. Set the delete flag. */ + (*TFts5HashEntry)(unsafe.Pointer(p)).FbDel = uint8(1) + } + nIncr = nIncr + (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + **(**int32)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FpnByte)) += nIncr + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Read and decode the "averages" record from the database. +// ** +// ** Parameter anSize must point to an array of size nCol, where nCol is +// ** the number of user defined columns in the FTS table. +// */ +func _sqlite3Fts5IndexGetAverages(tls *libc.TLS, p uintptr, pnRow uintptr, anSize uintptr) (r int32) { + var i, iCol, nCol int32 + var pData uintptr + _, _, _, _ = i, iCol, nCol, pData + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FnCol + **(**Ti64)(__ccgo_up(pnRow)) = 0 + libc.X__builtin___memset_chk(tls, anSize, 0, uint64(8)*libc.Uint64FromInt32(nCol), ^t__predefined_size_t(0)) + pData = _fts5DataRead(tls, p, int64(FTS5_AVERAGES_ROWID)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5Data)(unsafe.Pointer(pData)).Fnn != 0 { + i = 0 + i = i + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr(i), pnRow)) + iCol = 0 + for { + if !(i < (*TFts5Data)(unsafe.Pointer(pData)).Fnn && iCol < nCol) { + break + } + i = i + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr(i), anSize+uintptr(iCol)*8)) + goto _1 + _1: + ; + iCol = iCol + 1 + } + } + _fts5DataRelease(tls, pData) + return _fts5IndexReturn(tls, p) +} + +// C documentation +// +// /* +// ** Run internal checks to ensure that the FTS index (a) is internally +// ** consistent and (b) contains entries for which the XOR of the checksums +// ** as calculated by sqlite3Fts5IndexEntryCksum() is cksum. +// ** +// ** Return SQLITE_CORRUPT if any of the internal checks fail, or if the +// ** checksum does not match. Return SQLITE_OK if all checks pass without +// ** error, or some other SQLite error code if another error (e.g. OOM) +// ** occurs. +// */ +func _sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum Tu64, bUseCksum int32) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var cksum2 Tu64 + var eDetail, flags, iCol, iLvl, iSeg, iTokOff int32 + var iRowid Ti64 + var pSeg, pStruct, z uintptr + var _ /* iOff at bp+40 */ int32 + var _ /* iPos at bp+32 */ Ti64 + var _ /* n at bp+24 */ int32 + var _ /* pIter at bp+16 */ uintptr + var _ /* poslist at bp+0 */ TFts5Buffer + _, _, _, _, _, _, _, _, _, _, _ = cksum2, eDetail, flags, iCol, iLvl, iRowid, iSeg, iTokOff, pSeg, pStruct, z + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail + cksum2 = uint64(0) /* Checksum based on contents of indexes */ + **(**TFts5Buffer)(__ccgo_up(bp)) = TFts5Buffer{} + flags = int32(FTS5INDEX_QUERY_NOOUTPUT) + /* Load the FTS index structure */ + pStruct = _fts5StructureRead(tls, p) + if pStruct == uintptr(0) { + return _fts5IndexReturn(tls, p) + } + /* Check that the internal nodes of each segment match the leaves */ + iLvl = 0 + for { + if !(iLvl < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + iSeg = 0 + for { + if !(iSeg < (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg) { + break + } + pSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr(iSeg)*56 + _fts5IndexIntegrityCheckSegment(tls, p, pSeg) + goto _2 + _2: + ; + iSeg = iSeg + 1 + } + goto _1 + _1: + ; + iLvl = iLvl + 1 + } + /* The cksum argument passed to this function is a checksum calculated + ** based on all expected entries in the FTS index (including prefix index + ** entries). This block checks that a checksum calculated based on the + ** actual contents of FTS index is identical. + ** + ** Two versions of the same checksum are calculated. The first (stack + ** variable cksum2) based on entries extracted from the full-text index + ** while doing a linear scan of each individual index in turn. + ** + ** As each term visited by the linear scans, a separate query for the + ** same term is performed. cksum3 is calculated based on the entries + ** extracted by these queries. + */ + _fts5MultiIterNew(tls, p, pStruct, flags, uintptr(0), uintptr(0), 0, -int32(1), 0, bp+16) + for { + if !(_fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp + 16))) == 0) { + break + } /* Size of term in bytes */ + **(**Ti64)(__ccgo_up(bp + 32)) = 0 /* Position read from poslist */ + **(**int32)(__ccgo_up(bp + 40)) = 0 /* Offset within poslist */ + iRowid = _fts5MultiIterRowid(tls, **(**uintptr)(__ccgo_up(bp + 16))) + z = _fts5MultiIterTerm(tls, **(**uintptr)(__ccgo_up(bp + 16)), bp+24) + /* If this is a new term, query for it. Update cksum3 with the results. */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + if eDetail == int32(FTS5_DETAIL_NONE) { + if 0 == _fts5MultiIterIsEmpty(tls, p, **(**uintptr)(__ccgo_up(bp + 16))) { + cksum2 = cksum2 ^ _sqlite3Fts5IndexEntryCksum(tls, iRowid, 0, 0, -int32(1), z, **(**int32)(__ccgo_up(bp + 24))) + } + } else { + (**(**TFts5Buffer)(__ccgo_up(bp))).Fn = 0 + _fts5SegiterPoslist(tls, p, **(**uintptr)(__ccgo_up(bp + 16))+104+uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FaFirst + 1*4))).FiFirst)*128, uintptr(0), bp) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, uint32(4), __ccgo_ts+39992) + for 0 == _sqlite3Fts5PoslistNext64(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn, bp+40, bp+32) { + iCol = int32(**(**Ti64)(__ccgo_up(bp + 32)) >> libc.Int32FromInt32(32) & libc.Int64FromInt32(0x7FFFFFFF)) + iTokOff = int32(**(**Ti64)(__ccgo_up(bp + 32)) & libc.Int64FromInt32(0x7FFFFFFF)) + cksum2 = cksum2 ^ _sqlite3Fts5IndexEntryCksum(tls, iRowid, iCol, iTokOff, -int32(1), z, **(**int32)(__ccgo_up(bp + 24))) + } + } + goto _3 + _3: + ; + _fts5MultiIterNext(tls, p, **(**uintptr)(__ccgo_up(bp + 16)), 0, 0) + } + _fts5MultiIterFree(tls, **(**uintptr)(__ccgo_up(bp + 16))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bUseCksum != 0 && cksum != cksum2 { + (*TFts5Index)(unsafe.Pointer(p)).Frc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< 0 { + libc.X__builtin___memcpy_chk(tls, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp+1, pToken, libc.Uint64FromInt32(nToken), ^t__predefined_size_t(0)) + } + /* The NOTOKENDATA flag is set when each token in a tokendata=1 table + ** should be treated individually, instead of merging all those with + ** a common prefix into a single entry. This is used, for example, by + ** queries performed as part of an integrity-check, or by the fts5vocab + ** module. */ + if flags&(libc.Int32FromInt32(FTS5INDEX_QUERY_NOTOKENDATA)|libc.Int32FromInt32(FTS5INDEX_QUERY_SCAN)) != 0 { + bTokendata = 0 + } + /* Figure out which index to search and set iIdx accordingly. If this + ** is a prefix query for which there is no prefix index, set iIdx to + ** greater than pConfig->nPrefix to indicate that the query will be + ** satisfied by scanning multiple terms in the main index. + ** + ** If the QUERY_TEST_NOIDX flag was specified, then this must be a + ** prefix-query. Instead of using a prefix-index (if one exists), + ** evaluate the prefix query using the main FTS index. This is used + ** for internal sanity checking by the integrity-check in debug + ** mode only. */ + if flags&int32(FTS5INDEX_QUERY_PREFIX) != 0 { + nChar = _fts5IndexCharlen(tls, pToken, nToken) + iIdx = int32(1) + for { + if !(iIdx <= (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix) { + break + } + nIdxChar = **(**int32)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr(iIdx-int32(1))*4)) + if nIdxChar == nChar { + break + } + if nIdxChar == nChar+int32(1) { + iPrefixIdx = iIdx + } + goto _1 + _1: + ; + iIdx = iIdx + 1 + } + } + if bTokendata != 0 && iIdx == 0 { + **(**Tu8)(__ccgo_up((**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp)) = uint8('0') + **(**uintptr)(__ccgo_up(bp)) = _fts5SetupTokendataIter(tls, p, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp, nToken+int32(1), pColset) + } else { + if iIdx <= (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix { + /* Straight index lookup */ + pStruct = _fts5StructureRead(tls, p) + **(**Tu8)(__ccgo_up((**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp)) = libc.Uint8FromInt32(libc.Int32FromUint8('0') + iIdx) + if pStruct != 0 { + _fts5MultiIterNew(tls, p, pStruct, flags|int32(FTS5INDEX_QUERY_SKIPEMPTY), pColset, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp, nToken+int32(1), -int32(1), 0, bp) + _fts5StructureRelease(tls, pStruct) + } + } else { + /* Scan multiple terms in the main index for a prefix query. */ + bDesc = libc.BoolInt32(flags&int32(FTS5INDEX_QUERY_DESC) != 0) + _fts5SetupPrefixIter(tls, p, bDesc, iPrefixIdx, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp, nToken+int32(1), pColset, bp) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + } else { + _fts5IterSetOutputCb(tls, p+60, **(**uintptr)(__ccgo_up(bp))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pSeg = **(**uintptr)(__ccgo_up(bp)) + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaFirst + 1*4))).FiFirst)*128 + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 { + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxSetOutputs})))(tls, **(**uintptr)(__ccgo_up(bp)), pSeg) + } + } + } + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + _fts5IterClose(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _fts5IndexCloseReader(tls, p) + } + **(**uintptr)(__ccgo_up(ppIter)) = **(**uintptr)(__ccgo_up(bp)) + _sqlite3Fts5BufferFree(tls, bp+8) + } + return _fts5IndexReturn(tls, p) +} + +// C documentation +// +// /* +// ** The %_data table is completely empty when this function is called. This +// ** function populates it with the initial structure objects for each index, +// ** and the initial version of the "averages" record (a zero-byte blob). +// */ +func _sqlite3Fts5IndexReinit(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pTmp uintptr + var _ /* uFts at bp+0 */ struct { + FtmpSpace [0][48]Tu8 + FsFts TFts5Structure + F__ccgo_pad2 [16]byte + } + _ = pTmp + _fts5StructureInvalidate(tls, p) + _fts5IndexDiscardData(tls, p) + pTmp = bp + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FbContentlessDelete != 0 { + (*TFts5Structure)(unsafe.Pointer(pTmp)).FnOriginCntr = uint64(1) + } + _fts5DataWrite(tls, p, int64(FTS5_AVERAGES_ROWID), __ccgo_ts+1702, 0) + _fts5StructureWrite(tls, p, pTmp) + return _fts5IndexReturn(tls, p) +} + +// C documentation +// +// /* +// ** Set the 32-bit cookie value stored at the start of all structure +// ** records to the value passed as the second argument. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code if an error +// ** occurs. +// */ +func _sqlite3Fts5IndexSetCookie(tls *libc.TLS, p uintptr, iNew int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pConfig uintptr + var rc int32 + var _ /* aCookie at bp+0 */ [4]Tu8 + var _ /* pBlob at bp+8 */ uintptr + _, _ = pConfig, rc /* Return code */ + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig /* Binary representation of iNew */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + _sqlite3Fts5Put32(tls, bp, iNew) + rc = Xsqlite3_blob_open(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Index)(unsafe.Pointer(p)).FzDataTbl, __ccgo_ts+39262, int64(FTS5_STRUCTURE_ROWID), int32(1), bp+8) + if rc == SQLITE_OK { + Xsqlite3_blob_write(tls, **(**uintptr)(__ccgo_up(bp + 8)), bp, int32(4), 0) + rc = Xsqlite3_blob_close(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + return rc +} + +// C documentation +// +// /* +// ** Attempt to instantiate the tokenizer. +// */ +func _sqlite3Fts5LoadTokenizer(tls *libc.TLS, pConfig uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azArg, pMod, xCreate, v1 uintptr + var nArg, rc, v3 int32 + _, _, _, _, _, _, _ = azArg, nArg, pMod, rc, xCreate, v1, v3 + azArg = (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FazArg + nArg = (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FnArg + pMod = uintptr(0) + rc = SQLITE_OK + if nArg == 0 { + v1 = uintptr(0) + } else { + v1 = **(**uintptr)(__ccgo_up(azArg)) + } + pMod = _fts5LocateTokenizer(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FpGlobal, v1) + if pMod == uintptr(0) { + rc = int32(SQLITE_ERROR) + _sqlite3Fts5ConfigErrmsg(tls, pConfig, __ccgo_ts+40763, libc.VaList(bp+8, **(**uintptr)(__ccgo_up(azArg)))) + } else { + xCreate = uintptr(0) + if (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FbV2Native != 0 { + xCreate = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx2.FxCreate + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi2 = pMod + 48 + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi1 = pMod + 24 + xCreate = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx1.FxCreate + } + if azArg != 0 { + v1 = azArg + 1*8 + } else { + v1 = uintptr(0) + } + if nArg != 0 { + v3 = nArg - int32(1) + } else { + v3 = 0 + } + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xCreate})))(tls, (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData, v1, v3, pConfig+128) + if rc != SQLITE_OK { + if rc != int32(SQLITE_NOMEM) { + _sqlite3Fts5ConfigErrmsg(tls, pConfig, __ccgo_ts+40785, 0) + } + } else { + if (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FbV2Native == 0 { + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FePattern = _sqlite3Fts5TokenizerPattern(tls, (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx1.FxCreate, (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpTok) + } + } + } + if rc != SQLITE_OK { + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi1 = uintptr(0) + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi2 = uintptr(0) + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpTok = uintptr(0) + } + return rc +} + +func _sqlite3Fts5MallocZero(tls *libc.TLS, pRc uintptr, nByte Tsqlite3_int64) (r uintptr) { + var pRet uintptr + _ = pRet + pRet = uintptr(0) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pRet == uintptr(0) { + if nByte > 0 { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } else { + libc.X__builtin___memset_chk(tls, pRet, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + } + } + return pRet +} + +func _sqlite3Fts5ParseColset(tls *libc.TLS, pParse uintptr, pColset uintptr, p uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iCol int32 + var pConfig, pRet, z uintptr + _, _, _, _ = iCol, pConfig, pRet, z + pRet = uintptr(0) /* Dequoted copy of token p */ + z = _sqlite3Fts5Strndup(tls, pParse+16, (*TFts5Token)(unsafe.Pointer(p)).Fp, (*TFts5Token)(unsafe.Pointer(p)).Fn) + if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { + pConfig = (*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig + _sqlite3Fts5Dequote(tls, z) + iCol = 0 + for { + if !(iCol < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(iCol)*8)), z) { + break + } + goto _1 + _1: + ; + iCol = iCol + 1 + } + if iCol == (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+12250, libc.VaList(bp+8, z)) + } else { + pRet = _fts5ParseColset(tls, pParse, pColset, iCol) + } + Xsqlite3_free(tls, z) + } + if pRet == uintptr(0) { + Xsqlite3_free(tls, pColset) + } + return pRet +} + +func _sqlite3Fts5ParseImplicitAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) (r uintptr) { + var ap, pPrev, pRet uintptr + _, _, _ = ap, pPrev, pRet + pRet = uintptr(0) + if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc != 0 { + _sqlite3Fts5ParseNodeFree(tls, pLeft) + _sqlite3Fts5ParseNodeFree(tls, pRight) + } else { + if (*TFts5ExprNode)(unsafe.Pointer(pLeft)).FeType == int32(FTS5_AND) { + pPrev = *(*uintptr)(unsafe.Pointer(pLeft + 48 + uintptr((*TFts5ExprNode)(unsafe.Pointer(pLeft)).FnChild-int32(1))*8)) + } else { + pPrev = pLeft + } + if (*TFts5ExprNode)(unsafe.Pointer(pRight)).FeType == FTS5_EOF { + _sqlite3Fts5ParseNodeFree(tls, pRight) + pRet = pLeft + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + } else { + if (*TFts5ExprNode)(unsafe.Pointer(pPrev)).FeType == FTS5_EOF { + if pPrev == pLeft { + pRet = pRight + } else { + *(*uintptr)(unsafe.Pointer(pLeft + 48 + uintptr((*TFts5ExprNode)(unsafe.Pointer(pLeft)).FnChild-int32(1))*8)) = pRight + pRet = pLeft + } + ap = (*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase-int32(1)-(*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase)*8 + libc.X__builtin___memmove_chk(tls, ap, ap+1*8, uint64(8)*libc.Uint64FromInt32((*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase), ^t__predefined_size_t(0)) + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + _sqlite3Fts5ParseNodeFree(tls, pPrev) + } else { + pRet = _sqlite3Fts5ParseNode(tls, pParse, int32(FTS5_AND), pLeft, pRight, uintptr(0)) + } + } + } + return pRet +} + +// C documentation +// +// /* +// ** Token pTok has appeared in a MATCH expression where the NEAR operator +// ** is expected. If token pTok does not contain "NEAR", store an error +// ** in the pParse object. +// */ +func _sqlite3Fts5ParseNear(tls *libc.TLS, pParse uintptr, pTok uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + if (*TFts5Token)(unsafe.Pointer(pTok)).Fn != int32(4) || libc.Xmemcmp(tls, __ccgo_ts+38925, (*TFts5Token)(unsafe.Pointer(pTok)).Fp, uint64(4)) != 0 { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+37438, libc.VaList(bp+8, (*TFts5Token)(unsafe.Pointer(pTok)).Fn, (*TFts5Token)(unsafe.Pointer(pTok)).Fp)) + } +} + +// C documentation +// +// /* +// ** If argument pNear is NULL, then a new Fts5ExprNearset object is allocated +// ** and populated with pPhrase. Or, if pNear is not NULL, phrase pPhrase is +// ** appended to it and the results returned. +// ** +// ** If an OOM error occurs, both the pNear and pPhrase objects are freed and +// ** NULL returned. +// */ +func _sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhrase uintptr) (r uintptr) { + var SZALLOC, nNew, v1 int32 + var nByte, nByte1 Tsqlite3_int64 + var pLast, pRet, v2 uintptr + _, _, _, _, _, _, _, _ = SZALLOC, nByte, nByte1, nNew, pLast, pRet, v1, v2 + SZALLOC = int32(8) + pRet = uintptr(0) + if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { + if pNear == uintptr(0) { + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+24) + libc.Uint64FromInt32(SZALLOC+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pRet == uintptr(0) { + (*TFts5Parse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pRet, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + } + } else { + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase%SZALLOC == 0 { + nNew = (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase + SZALLOC + nByte1 = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+24) + libc.Uint64FromInt32(nNew+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + pRet = Xsqlite3_realloc64(tls, pNear, libc.Uint64FromInt64(nByte1)) + if pRet == uintptr(0) { + (*TFts5Parse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + } + } else { + pRet = pNear + } + } + } + if pRet == uintptr(0) { + _sqlite3Fts5ParseNearsetFree(tls, pNear) + _sqlite3Fts5ParsePhraseFree(tls, pPhrase) + } else { + if (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase > 0 { + pLast = *(*uintptr)(unsafe.Pointer(pRet + 24 + uintptr((*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase-int32(1))*8)) + if (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm == 0 { + _fts5ExprPhraseFree(tls, pPhrase) + (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase = (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase - 1 + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + pPhrase = pLast + } else { + if (*TFts5ExprPhrase)(unsafe.Pointer(pLast)).FnTerm == 0 { + _fts5ExprPhraseFree(tls, pLast) + **(**uintptr)(__ccgo_up((*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase-int32(2))*8)) = pPhrase + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase = (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase - 1 + } + } + } + v2 = pRet + 16 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + *(*uintptr)(unsafe.Pointer(pRet + 24 + uintptr(v1)*8)) = pPhrase + } + return pRet +} + +// C documentation +// +// /* +// ** Allocate and return a new expression object. If anything goes wrong (i.e. +// ** OOM error), leave an error code in pParse and return NULL. +// */ +func _sqlite3Fts5ParseNode(tls *libc.TLS, pParse uintptr, eType int32, pLeft uintptr, pRight uintptr, pNear uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iPhrase, nChild int32 + var nByte Tsqlite3_int64 + var pPhrase, pRet, v2 uintptr + _, _, _, _, _, _ = iPhrase, nByte, nChild, pPhrase, pRet, v2 + pRet = uintptr(0) + if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { + nChild = 0 /* Bytes of space to allocate for this node */ + if eType == int32(FTS5_STRING) && pNear == uintptr(0) { + return uintptr(0) + } + if eType != int32(FTS5_STRING) && pLeft == uintptr(0) { + return pRight + } + if eType != int32(FTS5_STRING) && pRight == uintptr(0) { + return pLeft + } + if eType == int32(FTS5_STRING) && (*TFts5Parse)(unsafe.Pointer(pParse)).FbPhraseToAnd != 0 && (*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24)))).FnTerm > int32(1) { + pRet = _fts5ParsePhraseToAnd(tls, pParse, pNear) + } else { + if eType == int32(FTS5_NOT) { + nChild = int32(2) + } else { + if eType == int32(FTS5_AND) || eType == int32(FTS5_OR) { + nChild = int32(2) + if (*TFts5ExprNode)(unsafe.Pointer(pLeft)).FeType == eType { + nChild = nChild + ((*TFts5ExprNode)(unsafe.Pointer(pLeft)).FnChild - int32(1)) + } + if (*TFts5ExprNode)(unsafe.Pointer(pRight)).FeType == eType { + nChild = nChild + ((*TFts5ExprNode)(unsafe.Pointer(pRight)).FnChild - int32(1)) + } + } + } + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+48) + libc.Uint64FromInt32(nChild)*libc.Uint64FromInt64(8)) + pRet = _sqlite3Fts5MallocZero(tls, pParse+16, nByte) + if pRet != 0 { + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FeType = eType + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FpNear = pNear + _fts5ExprAssignXNext(tls, pRet) + if eType == int32(FTS5_STRING) { + iPhrase = 0 + for { + if !(iPhrase < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + (*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(iPhrase)*8)))).FpNode = pRet + if (*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(iPhrase)*8)))).FnTerm == 0 { + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FxNext = uintptr(0) + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FeType = FTS5_EOF + } + goto _1 + _1: + ; + iPhrase = iPhrase + 1 + } + if (*TFts5Config)(unsafe.Pointer((*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail != FTS5_DETAIL_FULL { + pPhrase = *(*uintptr)(unsafe.Pointer(pNear + 24)) + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase != int32(1) || (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > int32(1) || (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0 && (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32))).FbFirst != 0 { + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == int32(1) { + v2 = __ccgo_ts + 39012 + } else { + v2 = __ccgo_ts + 38925 + } + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+39019, libc.VaList(bp+8, v2)) + _sqlite3Fts5ParseNodeFree(tls, pRet) + pRet = uintptr(0) + pNear = uintptr(0) + } + } + } else { + _fts5ExprAddChildren(tls, pRet, pLeft) + _fts5ExprAddChildren(tls, pRet, pRight) + v2 = libc.UintptrFromInt32(0) + pRight = v2 + pLeft = v2 + if (*TFts5ExprNode)(unsafe.Pointer(pRet)).FiHeight > int32(SQLITE_FTS5_MAX_EXPR_DEPTH) { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+39069, libc.VaList(bp+8, int32(SQLITE_FTS5_MAX_EXPR_DEPTH))) + _sqlite3Fts5ParseNodeFree(tls, pRet) + pRet = uintptr(0) + } + } + } + } + } + if pRet == uintptr(0) { + _sqlite3Fts5ParseNodeFree(tls, pLeft) + _sqlite3Fts5ParseNodeFree(tls, pRight) + _sqlite3Fts5ParseNearsetFree(tls, pNear) + } + return pRet +} + +// C documentation +// +// /* +// ** Apply colset pColset to expression node pExpr and all of its descendents. +// */ +func _sqlite3Fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pExpr uintptr, pColset uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* pFree at bp+0 */ uintptr + **(**uintptr)(__ccgo_up(bp)) = pColset + if (*TFts5Config)(unsafe.Pointer((*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38959, 0) + } else { + _fts5ParseSetColset(tls, pParse, pExpr, pColset, bp) + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) +} + +func _sqlite3Fts5ParseSetDistance(tls *libc.TLS, pParse uintptr, pNear uintptr, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c int8 + var i, nNear int32 + _, _, _ = c, i, nNear + if pNear != 0 { + nNear = 0 + if (*TFts5Token)(unsafe.Pointer(p)).Fn != 0 { + i = 0 + for { + if !(i < (*TFts5Token)(unsafe.Pointer(p)).Fn) { + break + } + c = **(**int8)(__ccgo_up((*TFts5Token)(unsafe.Pointer(p)).Fp + uintptr(i))) + if int32(c) < int32('0') || int32(c) > int32('9') { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38930, libc.VaList(bp+8, (*TFts5Token)(unsafe.Pointer(p)).Fn, (*TFts5Token)(unsafe.Pointer(p)).Fp)) + return + } + if nNear < int32(214748363) { + nNear = nNear*int32(10) + (int32(**(**int8)(__ccgo_up((*TFts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))) - int32('0')) + } + /* ^^^^^^^^^^^^^^^--- Prevent integer overflow */ + goto _1 + _1: + ; + i = i + 1 + } + } else { + nNear = int32(FTS5_DEFAULT_NEARDIST) + } + (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnNear = nNear + } +} + +// C documentation +// +// /* +// ** This function is called by the parser to process a string token. The +// ** string may or may not be quoted. In any case it is tokenized and a +// ** phrase object consisting of all tokens returned. +// */ +func _sqlite3Fts5ParseTerm(tls *libc.TLS, pParse uintptr, pAppend uintptr, pToken uintptr, bPrefix int32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var flags, n, rc, v1 int32 + var pConfig uintptr + var v3 bool + var _ /* sCtx at bp+0 */ TTokenCtx + var _ /* z at bp+24 */ uintptr + _, _, _, _, _, _ = flags, n, pConfig, rc, v1, v3 + pConfig = (*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig /* Tokenize return code */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(24), ^t__predefined_size_t(0)) + (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase = pAppend + (**(**TTokenCtx)(__ccgo_up(bp))).FpConfig = pConfig + rc = _fts5ParseStringFromToken(tls, pToken, bp+24) + if rc == SQLITE_OK { + if bPrefix != 0 { + v1 = int32(FTS5_TOKENIZE_PREFIX) + } else { + v1 = 0 + } + flags = int32(FTS5_TOKENIZE_QUERY) | v1 + _sqlite3Fts5Dequote(tls, **(**uintptr)(__ccgo_up(bp + 24))) + n = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(bp + 24)))) + rc = _sqlite3Fts5Tokenize(tls, pConfig, flags, **(**uintptr)(__ccgo_up(bp + 24)), n, bp, __ccgo_fp(_fts5ParseTokenize)) + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 24))) + if v3 = rc != 0; !v3 { + v1 = (**(**TTokenCtx)(__ccgo_up(bp))).Frc + rc = v1 + } + if v3 || v1 != 0 { + (*TFts5Parse)(unsafe.Pointer(pParse)).Frc = rc + _fts5ExprPhraseFree(tls, (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase) + (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase = uintptr(0) + } else { + if pAppend == uintptr(0) { + if _parseGrowPhraseArray(tls, pParse) != 0 { + _fts5ExprPhraseFree(tls, (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase) + return uintptr(0) + } + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase + 1 + } + if (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase == uintptr(0) { + /* This happens when parsing a token or quoted phrase that contains + ** no token characters at all. (e.g ... MATCH '""'). */ + (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase = _sqlite3Fts5MallocZero(tls, pParse+16, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(40))) + } else { + if (*TFts5ExprPhrase)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase)).FnTerm != 0 { + (*(*TFts5ExprTerm)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase + 32 + uintptr((*TFts5ExprPhrase)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase)).FnTerm-int32(1))*40))).FbPrefix = libc.Uint8FromInt32(bPrefix) + } + } + **(**uintptr)(__ccgo_up((*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase-int32(1))*8)) = (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase + } + return (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase +} + +// C documentation +// +// /* +// ** Return the fallback token corresponding to canonical token iToken, or +// ** 0 if iToken has no fallback. +// */ +func _sqlite3Fts5ParserFallback(tls *libc.TLS, iToken int32) (r int32) { + _ = iToken + return 0 +} + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** + */ + +/* #include "fts5Int.h" */ +/* + * Copyright (c) 2002-2017 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +func _sqlite3Fts5PoslistReaderInit(tls *libc.TLS, a uintptr, n int32, pIter uintptr) (r int32) { + libc.X__builtin___memset_chk(tls, pIter, 0, uint64(32), ^t__predefined_size_t(0)) + (*TFts5PoslistReader)(unsafe.Pointer(pIter)).Fa = a + (*TFts5PoslistReader)(unsafe.Pointer(pIter)).Fn = n + _sqlite3Fts5PoslistReaderNext(tls, pIter) + return libc.Int32FromUint8((*TFts5PoslistReader)(unsafe.Pointer(pIter)).FbEof) +} + +// C documentation +// +// /* +// ** Delete all entries in the FTS5 index. +// */ +func _sqlite3Fts5StorageDeleteAll(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pConfig uintptr + var rc int32 + _, _ = pConfig, rc + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + (*TFts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0 + /* Delete the contents of the %_data and %_docsize tables. */ + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+42014, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+42064, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_UNINDEXED) { + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+42093, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + /* Reinitialize the %_data table. This call creates the initial structure + ** and averages records. */ + if rc == SQLITE_OK { + rc = _sqlite3Fts5IndexReinit(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5StorageConfigValue(tls, p, __ccgo_ts+38788, uintptr(0), int32(FTS5_CURRENT_VERSION)) + } + return rc +} + +// C documentation +// +// /* +// ** Insert new entries into the FTS index and %_docsize table. +// */ +func _sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRowid Ti64) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iCol int32 + var pConfig, pVal uintptr + var _ /* buf at bp+24 */ TFts5Buffer + var _ /* ctx at bp+8 */ TFts5InsertCtx + var _ /* nLoc at bp+56 */ int32 + var _ /* nText at bp+40 */ int32 + var _ /* pLoc at bp+64 */ uintptr + var _ /* pText at bp+48 */ uintptr + var _ /* rc at bp+0 */ int32 + _, _, _ = iCol, pConfig, pVal + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Buffer used to build up %_docsize blob */ + libc.X__builtin___memset_chk(tls, bp+24, 0, uint64(16), ^t__predefined_size_t(0)) + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FpStorage = p + **(**int32)(__ccgo_up(bp)) = _fts5StorageLoadTotals(tls, p, int32(1)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5IndexBeginWrite(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid) + } + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FszCol = 0 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol)))) == 0 { + **(**int32)(__ccgo_up(bp + 40)) = 0 /* Size of pText in bytes */ + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) /* Pointer to buffer containing text value */ + **(**int32)(__ccgo_up(bp + 56)) = 0 /* Size of pText in bytes */ + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) /* Pointer to buffer containing text value */ + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol+int32(2))*8)) + if (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow != 0 && Xsqlite3_value_nochange(tls, pVal) != 0 { + pVal = Xsqlite3_column_value(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow, (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol+int32(1)) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL && (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 { + iCol = (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol + int32(1) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + **(**uintptr)(__ccgo_up(bp + 64)) = Xsqlite3_column_text(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow, iCol) + **(**int32)(__ccgo_up(bp + 56)) = Xsqlite3_column_bytes(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow, iCol) + } + } else { + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol+int32(2))*8)) + } + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 && _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5DecodeLocaleValue(tls, pVal, bp+48, bp+40, bp+64, bp+56) + } else { + **(**uintptr)(__ccgo_up(bp + 48)) = Xsqlite3_value_text(tls, pVal) + **(**int32)(__ccgo_up(bp + 40)) = Xsqlite3_value_bytes(tls, pVal) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + _sqlite3Fts5SetLocale(tls, pConfig, **(**uintptr)(__ccgo_up(bp + 64)), **(**int32)(__ccgo_up(bp + 56))) + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5Tokenize(tls, pConfig, int32(FTS5_TOKENIZE_DOCUMENT), **(**uintptr)(__ccgo_up(bp + 48)), **(**int32)(__ccgo_up(bp + 40)), bp+8, __ccgo_fp(_fts5StorageInsertCallback)) + _sqlite3Fts5ClearLocale(tls, pConfig) + } + } + _sqlite3Fts5BufferAppendVarint(tls, bp, bp+24, int64((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FszCol)) + **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol)*8)) += int64((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FszCol) + goto _1 + _1: + ; + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol = (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol + 1 + } + (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow = (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow + 1 + /* Write the %_docsize record */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _fts5StorageInsertDocsize(tls, p, iRowid, bp+24) + } + Xsqlite3_free(tls, (**(**TFts5Buffer)(__ccgo_up(bp + 24))).Fp) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Check that the contents of the FTS index match that of the %_content +// ** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return +// ** some other SQLite error code if an error occurs while attempting to +// ** determine this. +// */ +func _sqlite3Fts5StorageIntegrity(tls *libc.TLS, p uintptr, iArg int32) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aColSize, aTotalSize, pConfig, pVal uintptr + var bUseCksum, i, i1, iCol, rc, rc2 int32 + var _ /* ctx at bp+0 */ TFts5IntegrityCtx + var _ /* nLoc at bp+72 */ int32 + var _ /* nRow at bp+80 */ Ti64 + var _ /* nRow at bp+88 */ Ti64 + var _ /* nText at bp+56 */ int32 + var _ /* pLoc at bp+64 */ uintptr + var _ /* pScan at bp+40 */ uintptr + var _ /* pText at bp+48 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aColSize, aTotalSize, bUseCksum, i, i1, iCol, pConfig, pVal, rc, rc2 + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + rc = SQLITE_OK + libc.X__builtin___memset_chk(tls, bp, 0, uint64(40), ^t__predefined_size_t(0)) + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FpConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + aTotalSize = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*(libc.Uint64FromInt64(4)+libc.Uint64FromInt64(8)))) + if !(aTotalSize != 0) { + return int32(SQLITE_NOMEM) + } + aColSize = aTotalSize + uintptr((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*8 + libc.X__builtin___memset_chk(tls, aTotalSize, 0, uint64(8)*libc.Uint64FromInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol), ^t__predefined_size_t(0)) + bUseCksum = libc.BoolInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL || (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_EXTERNAL) && iArg != 0) + if bUseCksum != 0 { + /* Generate the expected index checksum based on the contents of the + ** %_content table. This block stores the checksum in ctx.cksum. */ + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_SCAN), bp+40, uintptr(0)) + if rc == SQLITE_OK { + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 40))) { + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FiRowid = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp + 40)), 0) + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FszCol = 0 + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + rc = _sqlite3Fts5StorageDocsize(tls, p, (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FiRowid, aColSize) + } + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + rc = _sqlite3Fts5TermsetNew(tls, bp+24) + } + i = 0 + for { + if !(rc == SQLITE_OK && i < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i)))) == 0 { + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 56)) = 0 + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 72)) = 0 + pVal = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp + 40)), i+int32(1)) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_EXTERNAL) && _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + rc = _sqlite3Fts5DecodeLocaleValue(tls, pVal, bp+48, bp+56, bp+64, bp+72) + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL && (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 { + iCol = i + int32(1) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + **(**uintptr)(__ccgo_up(bp + 64)) = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 40)), iCol) + **(**int32)(__ccgo_up(bp + 72)) = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp + 40)), iCol) + } + **(**uintptr)(__ccgo_up(bp + 48)) = Xsqlite3_value_text(tls, pVal) + **(**int32)(__ccgo_up(bp + 56)) = Xsqlite3_value_bytes(tls, pVal) + } + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FiCol = i + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FszCol = 0 + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_COLUMNS) { + rc = _sqlite3Fts5TermsetNew(tls, bp+24) + } + if rc == SQLITE_OK { + _sqlite3Fts5SetLocale(tls, pConfig, **(**uintptr)(__ccgo_up(bp + 64)), **(**int32)(__ccgo_up(bp + 72))) + rc = _sqlite3Fts5Tokenize(tls, pConfig, int32(FTS5_TOKENIZE_DOCUMENT), **(**uintptr)(__ccgo_up(bp + 48)), **(**int32)(__ccgo_up(bp + 56)), bp, __ccgo_fp(_fts5StorageIntegrityCallback)) + _sqlite3Fts5ClearLocale(tls, pConfig) + } + /* If this is not a columnsize=0 database, check that the number + ** of tokens in the value matches the aColSize[] value read from + ** the %_docsize table. */ + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 && (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FszCol != **(**int32)(__ccgo_up(aColSize + uintptr(i)*4)) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= 0) { + break + } + hash = hash< */ + +// C documentation +// +// /* +// ** Return true if the tokenizer described by p->azArg[] is the trigram +// ** tokenizer. This tokenizer needs to be loaded before xBestIndex is +// ** called for the first time in order to correctly handle LIKE/GLOB. +// */ +func _sqlite3Fts5TokenizerPreload(tls *libc.TLS, p uintptr) (r int32) { + return libc.BoolInt32((*TFts5TokenizerConfig)(unsafe.Pointer(p)).FnArg >= int32(1) && 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up((*TFts5TokenizerConfig)(unsafe.Pointer(p)).FazArg)), __ccgo_ts+42525)) +} + +func _sqlite3Fts5VocabInit(tls *libc.TLS, pGlobal uintptr, db uintptr) (r int32) { + var p uintptr + _ = p + p = pGlobal + return Xsqlite3_create_module_v2(tls, db, __ccgo_ts+42849, uintptr(unsafe.Pointer(&_fts5Vocab)), p, uintptr(0)) +} + +// C documentation +// +// /* +// ** Compute the column names for a SELECT statement. +// ** +// ** The only guarantee that SQLite makes about column names is that if the +// ** column has an AS clause assigning it a name, that will be the name used. +// ** That is the only documented guarantee. However, countless applications +// ** developed over the years have made baseless assumptions about column names +// ** and will break if those assumptions changes. Hence, use extreme caution +// ** when modifying this routine to avoid breaking legacy. +// ** +// ** See Also: sqlite3ColumnsFromExprList() +// ** +// ** The PRAGMA short_column_names and PRAGMA full_column_names settings are +// ** deprecated. The default setting is short=ON, full=OFF. 99.9% of all +// ** applications should operate this way. Nevertheless, we need to support the +// ** other modes for legacy: +// ** +// ** short=OFF, full=OFF: Column name is the text of the expression has it +// ** originally appears in the SELECT statement. In +// ** other words, the zSpan of the result expression. +// ** +// ** short=ON, full=OFF: (This is the default setting). If the result +// ** refers directly to a table column, then the +// ** result column name is just the table column +// ** name: COLUMN. Otherwise use zSpan. +// ** +// ** full=ON, short=ANY: If the result refers directly to a table column, +// ** then the result column name with the table name +// ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan. +// */ +func _sqlite3GenerateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pEList, pTab, pTabList, v, z, zCol, zName, zName1, v2 uintptr + var fullName, i, iCol, srcName int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, fullName, i, iCol, p, pEList, pTab, pTabList, srcName, v, z, zCol, zName, zName1, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* COLUMN or TABLE.COLUMN if no AS clause and is direct */ + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x20>>5)) != 0 { + return + } + /* Column names are determined by the left-most term of a compound select */ + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + pTabList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 5, 0x20) + fullName = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_FullColNames) != uint64(0)) + srcName = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ShortColNames) != uint64(0) || fullName != 0) + _sqlite3VdbeSetNumCols(tls, v, (*TExprList)(unsafe.Pointer(pEList)).FnExpr) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + p = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr + /* Agg processing has not run yet */ + /* Covering idx not yet coded */ + if (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME { + /* An AS clause always takes first priority */ + zName = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName, uintptr(-libc.Int32FromInt32(1))) + } else { + if srcName != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_COLUMN) { + iCol = int32((*TExpr)(unsafe.Pointer(p)).FiColumn) + pTab = *(*uintptr)(unsafe.Pointer(p + 64)) + if iCol < 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + if iCol < 0 { + zCol = __ccgo_ts + 18310 + } else { + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + } + if fullName != 0 { + zName1 = uintptr(0) + zName1 = _sqlite3MPrintf(tls, db, __ccgo_ts+13976, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, zCol)) + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName1, __ccgo_fp(_sqlite3RowSetClear)) + } else { + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zCol, uintptr(-libc.Int32FromInt32(1))) + } + } else { + z = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName + if z == uintptr(0) { + v2 = _sqlite3MPrintf(tls, db, __ccgo_ts+21025, libc.VaList(bp+8, i+int32(1))) + } else { + v2 = _sqlite3DbStrDup(tls, db, z) + } + z = v2 + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, z, __ccgo_fp(_sqlite3RowSetClear)) + } + } + goto _1 + _1: + ; + i = i + 1 + } + _generateColumnTypes(tls, pParse, pTabList, pEList) +} + +// C documentation +// +// /* +// ** Generate code to do constraint checks prior to an INSERT or an UPDATE +// ** on table pTab. +// ** +// ** The regNewData parameter is the first register in a range that contains +// ** the data to be inserted or the data after the update. There will be +// ** pTab->nCol+1 registers in this range. The first register (the one +// ** that regNewData points to) will contain the new rowid, or NULL in the +// ** case of a WITHOUT ROWID table. The second register in the range will +// ** contain the content of the first table column. The third register will +// ** contain the content of the second table column. And so forth. +// ** +// ** The regOldData parameter is similar to regNewData except that it contains +// ** the data prior to an UPDATE rather than afterwards. regOldData is zero +// ** for an INSERT. This routine can distinguish between UPDATE and INSERT by +// ** checking regOldData for zero. +// ** +// ** For an UPDATE, the pkChng boolean is true if the true primary key (the +// ** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table) +// ** might be modified by the UPDATE. If pkChng is false, then the key of +// ** the iDataCur content table is guaranteed to be unchanged by the UPDATE. +// ** +// ** For an INSERT, the pkChng boolean indicates whether or not the rowid +// ** was explicitly specified as part of the INSERT statement. If pkChng +// ** is zero, it means that the either rowid is computed automatically or +// ** that the table is a WITHOUT ROWID table and has no rowid. On an INSERT, +// ** pkChng will only be true if the INSERT statement provides an integer +// ** value for either the rowid column or its INTEGER PRIMARY KEY alias. +// ** +// ** The code generated by this routine will store new index entries into +// ** registers identified by aRegIdx[]. No index entry is created for +// ** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is +// ** the same as the order of indices on the linked list of indices +// ** at pTab->pIndex. +// ** +// ** (2019-05-07) The generated code also creates a new record for the +// ** main table, if pTab is a rowid table, and stores that record in the +// ** register identified by aRegIdx[nIdx] - in other words in the first +// ** entry of aRegIdx[] past the last index. It is important that the +// ** record be generated during constraint checks to avoid affinity changes +// ** to the register content that occur after constraint checks but before +// ** the new record is inserted. +// ** +// ** The caller must have already opened writeable cursors on the main +// ** table and all applicable indices (that is to say, all indices for which +// ** aRegIdx[] is not zero). iDataCur is the cursor for the main table when +// ** inserting or updating a rowid table, or the cursor for the PRIMARY KEY +// ** index when operating on a WITHOUT ROWID table. iIdxCur is the cursor +// ** for the first index in the pTab->pIndex list. Cursors for other indices +// ** are at iIdxCur+N for the N-th element of the pTab->pIndex list. +// ** +// ** This routine also generates code to check constraints. NOT NULL, +// ** CHECK, and UNIQUE constraints are all checked. If a constraint fails, +// ** then the appropriate action is performed. There are five possible +// ** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE. +// ** +// ** Constraint type Action What Happens +// ** --------------- ---------- ---------------------------------------- +// ** any ROLLBACK The current transaction is rolled back and +// ** sqlite3_step() returns immediately with a +// ** return code of SQLITE_CONSTRAINT. +// ** +// ** any ABORT Back out changes from the current command +// ** only (do not do a complete rollback) then +// ** cause sqlite3_step() to return immediately +// ** with SQLITE_CONSTRAINT. +// ** +// ** any FAIL Sqlite3_step() returns immediately with a +// ** return code of SQLITE_CONSTRAINT. The +// ** transaction is not rolled back and any +// ** changes to prior rows are retained. +// ** +// ** any IGNORE The attempt in insert or update the current +// ** row is skipped, without throwing an error. +// ** Processing continues with the next row. +// ** (There is an immediate jump to ignoreDest.) +// ** +// ** NOT NULL REPLACE The NULL value is replace by the default +// ** value for that column. If the default value +// ** is NULL, the action is the same as ABORT. +// ** +// ** UNIQUE REPLACE The other row that conflicts with the row +// ** being inserted is removed. +// ** +// ** CHECK REPLACE Illegal. The results in an exception. +// ** +// ** Which action to take is determined by the overrideError parameter. +// ** Or if overrideError==OE_Default, then the pParse->onError parameter +// ** is used. Or if pParse->onError==OE_Default then the onError value +// ** for the constraint is used. +// */ +func _sqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintptr, aRegIdx uintptr, iDataCur int32, iIdxCur int32, regNewData int32, regOldData int32, pkChng Tu8, overrideError Tu8, ignoreDest int32, pbMayReplace uintptr, aiChng uintptr, pUpsert uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addr1, addrBypass, addrConflictCk, addrJump, addrRecheck, addrRowidOk, addrUniqueOk, allOk, b2ndPass, i, iField, iReg, iThisCur, ipkBottom, ipkTop, isGenerated, jj, lblRecheckOk, nCol, nConflictCk, nGenerated, nIdx, nPkField, nReplaceTrig, nSeenReplace, onError, op, p2, regCmp, regIdx, regR, regRec, regTrigCnt, seenReplace, upsertIpkDelay, upsertIpkReturn, x, x1, v2 int32 + var bAffinityDone, isUpdate Tu8 + var bUsed, db, p4, pCheck, pCol, pCopy, pExpr, pIdx, pPk, pTerm, pTrigger, pUpsertClause, v, zMsg, zName, zP4, v8 uintptr + var nByte Tu64 + var _ /* ix at bp+0 */ int32 + var _ /* sIdxIter at bp+8 */ TIndexIterator + var _ /* x at bp+32 */ TVdbeOp + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, addrBypass, addrConflictCk, addrJump, addrRecheck, addrRowidOk, addrUniqueOk, allOk, b2ndPass, bAffinityDone, bUsed, db, i, iField, iReg, iThisCur, ipkBottom, ipkTop, isGenerated, isUpdate, jj, lblRecheckOk, nByte, nCol, nConflictCk, nGenerated, nIdx, nPkField, nReplaceTrig, nSeenReplace, onError, op, p2, p4, pCheck, pCol, pCopy, pExpr, pIdx, pPk, pTerm, pTrigger, pUpsertClause, regCmp, regIdx, regR, regRec, regTrigCnt, seenReplace, upsertIpkDelay, upsertIpkReturn, v, x, x1, zMsg, zName, zP4, v2, v8 /* Pointer to one of the indices */ + pPk = uintptr(0) /* Conflict resolution strategy */ + seenReplace = 0 /* Number of fields in PRIMARY KEY. 1 for ROWID tables */ + pUpsertClause = uintptr(0) /* True if this is an UPDATE operation */ + bAffinityDone = uint8(0) /* True if the OP_Affinity operation has been run */ + upsertIpkReturn = 0 /* Address of Goto at end of IPK uniqueness check */ + upsertIpkDelay = 0 /* Address of Goto to bypass initial IPK check */ + ipkTop = 0 /* Top of the IPK uniqueness check */ + ipkBottom = 0 /* Register used to count replace trigger invocations */ + addrRecheck = 0 /* Jump here to recheck all uniqueness constraints */ + lblRecheckOk = 0 /* List of DELETE triggers on the table pTab */ + nReplaceTrig = 0 /* Index iterator */ + isUpdate = libc.BoolUint8(regOldData != 0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* This table is not a VIEW */ + nCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for + ** normal rowid tables. nPkField is the number of key fields in the + ** pPk index or 1 for a rowid table. In other words, nPkField is the + ** number of fields in the true primary key of the table. */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + pPk = uintptr(0) + nPkField = int32(1) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPkField = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } + /* Record that this module has started */ + /* Test all NOT NULL constraints. + */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasNotNull) != 0 { + b2ndPass = 0 /* True if currently running 2nd pass */ + nSeenReplace = 0 /* Number of ON CONFLICT REPLACE operations */ + nGenerated = 0 /* Number of generated columns with NOT NULL */ + for int32(1) != 0 { /* Make 2 passes over columns. Exit loop via "break" */ + i = 0 + for { + if !(i < nCol) { + break + } /* Register holding column value */ + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 /* non-zero if column is generated */ + onError = int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8)) & 0xf >> 0)) + if onError == OE_None { + goto _1 + } /* No NOT NULL on this column */ + if i == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + goto _1 /* ROWID is never NULL */ + } + isGenerated = libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags) & int32(COLFLAG_GENERATED) + if isGenerated != 0 && !(b2ndPass != 0) { + nGenerated = nGenerated + 1 + goto _1 /* Generated columns processed on 2nd pass */ + } + if aiChng != 0 && **(**int32)(__ccgo_up(aiChng + uintptr(i)*4)) < 0 && !(isGenerated != 0) { + /* Do not check NOT NULL on columns that do not change */ + goto _1 + } + if libc.Int32FromUint8(overrideError) != int32(OE_Default) { + onError = libc.Int32FromUint8(overrideError) + } else { + if onError == int32(OE_Default) { + onError = int32(OE_Abort) + } + } + if onError == int32(OE_Replace) { + if b2ndPass != 0 || libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) == 0 { + onError = int32(OE_Abort) + } else { + } + } else { + if b2ndPass != 0 && !(isGenerated != 0) { + goto _1 + } + } + iReg = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(i))) + regNewData + int32(1) + switch onError { + case int32(OE_Replace): + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_NotNull), iReg) + nSeenReplace = nSeenReplace + 1 + _sqlite3ExprCodeCopy(tls, pParse, _sqlite3ColumnExpr(tls, pTab, pCol), iReg) + _sqlite3VdbeJumpHere(tls, v, addr1) + case int32(OE_Abort): + _sqlite3MayAbort(tls, pParse) + fallthrough + case int32(OE_Rollback): + fallthrough + case int32(OE_Fail): + zMsg = _sqlite3MPrintf(tls, db, __ccgo_ts+13976, libc.VaList(bp+64, (*TTable)(unsafe.Pointer(pTab)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_HaltIfNull), libc.Int32FromInt32(SQLITE_CONSTRAINT)|libc.Int32FromInt32(5)< 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != uint32(0) { + /* If any NOT NULL ON CONFLICT REPLACE constraints fired on the + ** first pass, recomputed values for all generated columns, as + ** those values might depend on columns affected by the REPLACE. + */ + _sqlite3ComputeGeneratedColumns(tls, pParse, regNewData+int32(1), pTab) + } + } /* end of 2-pass loop */ + } /* end if( has-not-null-constraints ) */ + /* Test all CHECK constraints + */ + if (*TTable)(unsafe.Pointer(pTab)).FpCheck != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_IgnoreChecks) == uint64(0) { + pCheck = (*TTable)(unsafe.Pointer(pTab)).FpCheck + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + int32(1)) + if libc.Int32FromUint8(overrideError) != int32(OE_Default) { + v2 = libc.Int32FromUint8(overrideError) + } else { + v2 = int32(OE_Abort) + } + onError = v2 + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pCheck)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(i)*32))).FpExpr + if aiChng != 0 && !(_sqlite3ExprReferencesUpdatedColumn(tls, pExpr, aiChng, libc.Int32FromUint8(pkChng)) != 0) { + /* The check constraints do not reference any of the columns being + ** updated so there is no point it verifying the check constraint */ + goto _3 + } + if libc.Int32FromUint8(bAffinityDone) == 0 { + _sqlite3TableAffinity(tls, v, pTab, regNewData+int32(1)) + bAffinityDone = uint8(1) + } + allOk = _sqlite3VdbeMakeLabel(tls, pParse) + pCopy = _sqlite3ExprDup(tls, db, pExpr, 0) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + _sqlite3ExprIfTrue(tls, pParse, pCopy, allOk, int32(SQLITE_JUMPIFNULL)) + } + _sqlite3ExprDelete(tls, db, pCopy) + if onError == int32(OE_Ignore) { + _sqlite3VdbeGoto(tls, v, ignoreDest) + } else { + zName = (*(*TExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(i)*32))).FzEName + if onError == int32(OE_Replace) { + onError = int32(OE_Abort) + } /* IMP: R-26383-51744 */ + _sqlite3HaltConstraint(tls, pParse, libc.Int32FromInt32(SQLITE_CONSTRAINT)|libc.Int32FromInt32(1)<>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + v2 = regIdx + } else { + v2 = regR + } + regCmp = v2 + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + p4 = _sqlite3LocateCollSeq(tls, pParse, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(i)*8))) + x1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))) + if i == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)-int32(1) { + addrJump = addrUniqueOk + op = int32(OP_Eq) + } + x1 = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(x1))) + _sqlite3VdbeAddOp4(tls, v, op, regOldData+int32(1)+x1, addrJump, regCmp+i, p4, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL)) + goto _14 + _14: + ; + i = i + 1 + } + } + } + } + /* Generate code that executes if the new index entry is not unique */ + switch onError { + case int32(OE_Rollback): + fallthrough + case int32(OE_Abort): + fallthrough + case int32(OE_Fail): + _sqlite3UniqueConstraint(tls, pParse, onError, pIdx) + case int32(OE_Update): + _sqlite3UpsertDoUpdate(tls, pParse, pUpsert, pTab, pIdx, iIdxCur+**(**int32)(__ccgo_up(bp))) + fallthrough + case int32(OE_Ignore): + _sqlite3VdbeGoto(tls, v, ignoreDest) + default: /* Number of opcodes in conflict check logic */ + nConflictCk = _sqlite3VdbeCurrentAddr(tls, v) - addrConflictCk + if regTrigCnt != 0 { + _sqlite3MultiWrite(tls, pParse) + nReplaceTrig = nReplaceTrig + 1 + } + if pTrigger != 0 && isUpdate != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_CursorLock), iDataCur) + } + if pIdx == pPk { + v2 = int32(ONEPASS_SINGLE) + } else { + v2 = ONEPASS_OFF + } + _sqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, iDataCur, iIdxCur, regR, int16(nPkField), uint8(0), uint8(OE_Replace), libc.Uint8FromInt32(v2), iThisCur) + if pTrigger != 0 && isUpdate != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_CursorUnlock), iDataCur) + } + if regTrigCnt != 0 { /* Jump destination to bypass recheck logic */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), regTrigCnt, int32(1)) /* incr trigger cnt */ + addrBypass = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) /* Bypass recheck */ + /* Here we insert code that will be invoked after all constraint + ** checks have run, if and only if one or more replace triggers + ** fired. */ + _sqlite3VdbeResolveLabel(tls, v, lblRecheckOk) + lblRecheckOk = _sqlite3VdbeMakeLabel(tls, pParse) + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + /* Bypass the recheck if this partial index is not defined + ** for the current row */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regIdx-int32(1), lblRecheckOk) + } + /* Copy the constraint check code from above, except change + ** the constraint-ok jump destination to be the address of + ** the next retest block */ + for nConflictCk > 0 { /* Conflict check opcode to copy */ + /* The sqlite3VdbeAddOp4() call might reallocate the opcode array. + ** Hence, make a complete copy of the opcode, rather than using + ** a pointer to the opcode. */ + **(**TVdbeOp)(__ccgo_up(bp + 32)) = **(**TVdbeOp)(__ccgo_up(_sqlite3VdbeGetOp(tls, v, addrConflictCk))) + if libc.Int32FromUint8((**(**TVdbeOp)(__ccgo_up(bp + 32))).Fopcode) != int32(OP_IdxRowid) { + if libc.Int32FromUint8(_sqlite3OpcodeProperty[(**(**TVdbeOp)(__ccgo_up(bp + 32))).Fopcode])&int32(OPFLG_JUMP) != 0 { + p2 = lblRecheckOk + } else { + p2 = (**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp2 + } + if int32((**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp4type) == -int32(3) { + v8 = uintptr(int64(*(*int32)(unsafe.Pointer(bp + 32 + 16)))) + } else { + v8 = *(*uintptr)(unsafe.Pointer(bp + 32 + 16)) + } + zP4 = v8 + _sqlite3VdbeAddOp4(tls, v, libc.Int32FromUint8((**(**TVdbeOp)(__ccgo_up(bp + 32))).Fopcode), (**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp1, p2, (**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp3, zP4, int32((**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp4type)) + _sqlite3VdbeChangeP5(tls, v, (**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp5) + } + nConflictCk = nConflictCk - 1 + addrConflictCk = addrConflictCk + 1 + } + /* If the retest fails, issue an abort */ + _sqlite3UniqueConstraint(tls, pParse, int32(OE_Abort), pIdx) + _sqlite3VdbeJumpHere(tls, v, addrBypass) /* Terminate the recheck bypass */ + } + seenReplace = int32(1) + break + } + _sqlite3VdbeResolveLabel(tls, v, addrUniqueOk) + if regR != regIdx { + _sqlite3ReleaseTempRange(tls, pParse, regR, nPkField) + } + if pUpsertClause != 0 && upsertIpkReturn != 0 && _sqlite3UpsertNextIsIPK(tls, pUpsertClause) != 0 { + _sqlite3VdbeGoto(tls, v, upsertIpkDelay+int32(1)) + _sqlite3VdbeJumpHere(tls, v, upsertIpkReturn) + upsertIpkReturn = 0 + } + goto _9 + _9: + ; + pIdx = _indexIteratorNext(tls, bp+8, bp) + } + /* If the IPK constraint is a REPLACE, run it last */ + if ipkTop != 0 { + _sqlite3VdbeGoto(tls, v, ipkTop) + _sqlite3VdbeJumpHere(tls, v, ipkBottom) + } + /* Recheck all uniqueness constraints after replace triggers have run */ + if nReplaceTrig != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNot), regTrigCnt, lblRecheckOk) + if !(pPk != 0) { + if isUpdate != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), regNewData, addrRecheck, regOldData) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL)) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iDataCur, addrRecheck, regNewData) + _sqlite3RowidConstraint(tls, pParse, int32(OE_Abort), pTab) + } else { + _sqlite3VdbeGoto(tls, v, addrRecheck) + } + _sqlite3VdbeResolveLabel(tls, v, lblRecheckOk) + } + /* Generate the table record */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + regRec = **(**int32)(__ccgo_up(aRegIdx + uintptr(**(**int32)(__ccgo_up(bp)))*4)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regNewData+int32(1), int32((*TTable)(unsafe.Pointer(pTab)).FnNVCol), regRec) + if !(bAffinityDone != 0) { + _sqlite3TableAffinity(tls, v, pTab, 0) + } + } + **(**int32)(__ccgo_up(pbMayReplace)) = seenReplace +} + +// C documentation +// +// /* +// ** This routine generates VDBE code that causes a single row of a +// ** single table to be deleted. Both the original table entry and +// ** all indices are removed. +// ** +// ** Preconditions: +// ** +// ** 1. iDataCur is an open cursor on the btree that is the canonical data +// ** store for the table. (This will be either the table itself, +// ** in the case of a rowid table, or the PRIMARY KEY index in the case +// ** of a WITHOUT ROWID table.) +// ** +// ** 2. Read/write cursors for all indices of pTab must be open as +// ** cursor number iIdxCur+i for the i-th index. +// ** +// ** 3. The primary key for the row to be deleted must be stored in a +// ** sequence of nPk memory cells starting at iPk. If nPk==0 that means +// ** that a search record formed from OP_MakeRecord is contained in the +// ** single memory location iPk. +// ** +// ** eMode: +// ** Parameter eMode may be passed either ONEPASS_OFF (0), ONEPASS_SINGLE, or +// ** ONEPASS_MULTI. If eMode is not ONEPASS_OFF, then the cursor +// ** iDataCur already points to the row to delete. If eMode is ONEPASS_OFF +// ** then this function must seek iDataCur to the entry identified by iPk +// ** and nPk before reading from it. +// ** +// ** If eMode is ONEPASS_MULTI, then this call is being made as part +// ** of a ONEPASS delete that affects multiple rows. In this case, if +// ** iIdxNoSeek is a valid cursor number (>=0) and is not the same as +// ** iDataCur, then its position should be preserved following the delete +// ** operation. Or, if iIdxNoSeek is not a valid cursor number, the +// ** position of iDataCur should be preserved instead. +// ** +// ** iIdxNoSeek: +// ** If iIdxNoSeek is a valid cursor number (>=0) not equal to iDataCur, +// ** then it identifies an index cursor (from within array of cursors +// ** starting at iIdxCur) that already points to the index entry to be deleted. +// ** Except, this optimization is disabled if there are BEFORE triggers since +// ** the trigger body might have moved the cursor. +// */ +func _sqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTrigger uintptr, iDataCur int32, iIdxCur int32, iPk int32, nPk Ti16, count Tu8, onconf Tu8, eMode Tu8, iIdxNoSeek int32) { + var addrStart, iCol, iLabel, iOld, kk, v1 int32 + var mask Tu32 + var opSeek, p5 Tu8 + var v uintptr + _, _, _, _, _, _, _, _, _, _ = addrStart, iCol, iLabel, iOld, kk, mask, opSeek, p5, v, v1 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Vdbe */ + iOld = 0 /* Seek opcode */ + /* Vdbe is guaranteed to have been allocated by this stage. */ + /* Seek cursor iCur to the row to delete. If this row no longer exists + ** (this can happen if a trigger program has already deleted it), do + ** not attempt to delete it or fire any DELETE triggers. */ + iLabel = _sqlite3VdbeMakeLabel(tls, pParse) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v1 = int32(OP_NotExists) + } else { + v1 = int32(OP_NotFound) + } + opSeek = libc.Uint8FromInt32(v1) + if libc.Int32FromUint8(eMode) == ONEPASS_OFF { + _sqlite3VdbeAddOp4Int(tls, v, libc.Int32FromUint8(opSeek), iDataCur, iLabel, iPk, int32(nPk)) + } + /* If there are any triggers to fire, allocate a range of registers to + ** use for the old.* references in the triggers. */ + if _sqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0 || pTrigger != 0 { /* Start of BEFORE trigger programs */ + /* TODO: Could use temporary registers here. Also could attempt to + ** avoid copying the contents of the rowid register. */ + mask = _sqlite3TriggerColmask(tls, pParse, pTrigger, uintptr(0), 0, libc.Int32FromInt32(TRIGGER_BEFORE)|libc.Int32FromInt32(TRIGGER_AFTER), pTab, libc.Int32FromUint8(onconf)) + mask = mask | _sqlite3FkOldmask(tls, pParse, pTab) + iOld = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(1) + int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + /* Populate the OLD.* pseudo-table register array. These values will be + ** used by any BEFORE and AFTER triggers that exist. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), iPk, iOld) + iCol = 0 + for { + if !(iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if mask == uint32(0xffffffff) || iCol <= int32(31) && mask&(libc.Uint32FromInt32(1)<= 0 && iIdxNoSeek != iDataCur { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Delete), iIdxNoSeek) + } + if libc.Int32FromUint8(eMode) == int32(ONEPASS_MULTI) { + p5 = libc.Uint8FromInt32(int32(p5) | libc.Int32FromInt32(OPFLAG_SAVEPOSITION)) + } + _sqlite3VdbeChangeP5(tls, v, uint16(p5)) + } + /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to + ** handle rows (possibly in other tables) that refer via a foreign key + ** to the row just deleted. */ + _sqlite3FkActions(tls, pParse, pTab, uintptr(0), iOld, uintptr(0), 0) + /* Invoke AFTER DELETE trigger programs. */ + if pTrigger != 0 { + _sqlite3CodeRowTrigger(tls, pParse, pTrigger, int32(TK_DELETE), uintptr(0), int32(TRIGGER_AFTER), pTab, iOld, libc.Int32FromUint8(onconf), iLabel) + } + /* Jump here if the row had already been deleted before any BEFORE + ** trigger programs were invoked. Or if a trigger program throws a + ** RAISE(IGNORE) exception. */ + _sqlite3VdbeResolveLabel(tls, v, iLabel) +} + +// C documentation +// +// /* +// ** This function is responsible for invoking the collation factory callback +// ** or substituting a collation sequence of a different encoding when the +// ** requested collation sequence is not available in the desired encoding. +// ** +// ** If it is not NULL, then pColl must point to the database native encoding +// ** collation sequence with name zName, length nName. +// ** +// ** The return value is either the collation sequence to be used in database +// ** db for collation type name zName, length nName, or NULL, if no collation +// ** sequence can be found. If no collation is found, leave an error message. +// ** +// ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq() +// */ +func _sqlite3GetCollSeq(tls *libc.TLS, pParse uintptr, enc Tu8, pColl uintptr, zName uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, p uintptr + _, _ = db, p + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = pColl + if !(p != 0) { + p = _sqlite3FindCollSeq(tls, db, enc, zName, 0) + } + if !(p != 0) || !((*TCollSeq)(unsafe.Pointer(p)).FxCmp != 0) { + /* No collation sequence of this type for this encoding is registered. + ** Call the collation factory to see if it can supply us with one. + */ + _callCollNeeded(tls, db, libc.Int32FromUint8(enc), zName) + p = _sqlite3FindCollSeq(tls, db, enc, zName, 0) + } + if p != 0 && !((*TCollSeq)(unsafe.Pointer(p)).FxCmp != 0) && _synthCollSeq(tls, db, p) != 0 { + p = uintptr(0) + } + if p == uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16658, libc.VaList(bp+8, zName)) + (*TParse)(unsafe.Pointer(pParse)).Frc = libc.Int32FromInt32(SQLITE_ERROR) | libc.Int32FromInt32(1)<= 0 && c <= int32(9)) { + break + } + v = v*int64(10) + int64(c) + goto _2 + _2: + ; + i = i + 1 + } + /* The longest decimal representation of a 32 bit integer is 10 digits: + ** + ** 1234567890 + ** 2^31 -> 2147483648 + */ + if i > int32(10) { + return 0 + } + if v-int64(neg) > int64(2147483647) { + return 0 + } + if neg != 0 { + v = -v + } + **(**int32)(__ccgo_up(pValue)) = int32(v) + return int32(1) +} + +// C documentation +// +// /* +// ** If expression list pList contains an expression that was parsed with +// ** an explicit "NULLS FIRST" or "NULLS LAST" clause, leave an error in +// ** pParse and return non-zero. Otherwise, return zero. +// */ +func _sqlite3HasExplicitNulls(tls *libc.TLS, pParse uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var sf Tu8 + var v2 uintptr + _, _, _ = i, sf, v2 + if pList != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pList + 8 + uintptr(i)*32 + 16 + 4))&0x20>>5)) != 0 { + sf = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).Ffg.FsortFlags + if libc.Int32FromUint8(sf) == 0 || libc.Int32FromUint8(sf) == int32(3) { + v2 = __ccgo_ts + 15718 + } else { + v2 = __ccgo_ts + 15724 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15729, libc.VaList(bp+8, v2)) + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + } + return 0 +} + +// C documentation +// +// /* +// ** If the source-list item passed as an argument was augmented with an +// ** INDEXED BY clause, then try to locate the specified index. If there +// ** was such a clause and the named index cannot be found, return +// ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate +// ** pFrom->pIndex and return SQLITE_OK. +// */ +func _sqlite3IndexedByLookup(tls *libc.TLS, pParse uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pIdx, pTab, zIndexedBy uintptr + _, _, _ = pIdx, pTab, zIndexedBy + pTab = (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab + zIndexedBy = *(*uintptr)(unsafe.Pointer(pFrom + 48)) + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0 && _sqlite3StrICmp(tls, (*TIndex)(unsafe.Pointer(pIdx)).FzName, zIndexedBy) != 0) { + break + } + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if !(pIdx != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21365, libc.VaList(bp+8, zIndexedBy, 0)) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + return int32(SQLITE_ERROR) + } + *(*uintptr)(unsafe.Pointer(pFrom + 56)) = pIdx + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This is the callback routine for the code that initializes the +// ** database. See sqlite3Init() below for additional information. +// ** This routine is also called from the OP_ParseSchema opcode of the VDBE. +// ** +// ** Each callback contains the following information: +// ** +// ** argv[0] = type of object: "table", "index", "trigger", or "view". +// ** argv[1] = name of thing being created +// ** argv[2] = associated table if an index or trigger +// ** argv[3] = root page number for table or index. 0 for trigger or view. +// ** argv[4] = SQL text for the CREATE statement. +// ** +// */ +func _sqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr, NotUsed uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pData, pIndex uintptr + var iDb, rc int32 + var saved_iDb Tu8 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _ = db, iDb, pData, pIndex, rc, saved_iDb + pData = pInit + db = (*TInitData)(unsafe.Pointer(pData)).Fdb + iDb = (*TInitData)(unsafe.Pointer(pData)).FiDb + _ = NotUsed + _ = argc + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_EncodingFixed) + if argv == uintptr(0) { + return 0 + } /* Might happen if EMPTY_RESULT_CALLBACKS are on */ + (*TInitData)(unsafe.Pointer(pData)).FnInitRow = (*TInitData)(unsafe.Pointer(pData)).FnInitRow + 1 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _corruptSchema(tls, pData, argv, uintptr(0)) + return int32(1) + } + if **(**uintptr)(__ccgo_up(argv + 3*8)) == uintptr(0) { + _corruptSchema(tls, pData, argv, uintptr(0)) + } else { + if **(**uintptr)(__ccgo_up(argv + 4*8)) != 0 && int32('c') == libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8)))))]) && int32('r') == libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8)) + 1)))]) { + saved_iDb = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb + /* Return code from sqlite3_prepare() */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(iDb) + if _sqlite3GetUInt32(tls, **(**uintptr)(__ccgo_up(argv + 3*8)), db+192) == 0 || (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum > (*TInitData)(unsafe.Pointer(pData)).FmxPage && (*TInitData)(unsafe.Pointer(pData)).FmxPage > uint32(0) { + if _sqlite3Config.FbExtraSchemaChecks != 0 { + _corruptSchema(tls, pData, argv, __ccgo_ts+16084) + } + } + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(0), 0, 0x1) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = argv + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _sqlite3Prepare(tls, db, **(**uintptr)(__ccgo_up(argv + 4*8)), -int32(1), uint32(0), uintptr(0), bp, uintptr(0)) + rc = (*Tsqlite3)(unsafe.Pointer(db)).FerrCode + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = saved_iDb + /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */ + if SQLITE_OK != rc { + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x1>>0)) != 0 { + } else { + if rc > (*TInitData)(unsafe.Pointer(pData)).Frc { + (*TInitData)(unsafe.Pointer(pData)).Frc = rc + } + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } else { + if rc != int32(SQLITE_INTERRUPT) && rc&int32(0xFF) != int32(SQLITE_LOCKED) { + _corruptSchema(tls, pData, argv, Xsqlite3_errmsg(tls, db)) + } + } + } + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = uintptr(unsafe.Pointer(&_sqlite3StdType)) /* Any array of string ptrs will do */ + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + if **(**uintptr)(__ccgo_up(argv + 1*8)) == uintptr(0) || **(**uintptr)(__ccgo_up(argv + 4*8)) != uintptr(0) && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8))))) != 0 { + _corruptSchema(tls, pData, argv, uintptr(0)) + } else { + pIndex = _sqlite3FindIndex(tls, db, **(**uintptr)(__ccgo_up(argv + 1*8)), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + if pIndex == uintptr(0) { + _corruptSchema(tls, pData, argv, __ccgo_ts+20483) + } else { + if _sqlite3GetUInt32(tls, **(**uintptr)(__ccgo_up(argv + 3*8)), pIndex+88) == 0 || (*TIndex)(unsafe.Pointer(pIndex)).Ftnum < uint32(2) || (*TIndex)(unsafe.Pointer(pIndex)).Ftnum > (*TInitData)(unsafe.Pointer(pData)).FmxPage || _sqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 { + if _sqlite3Config.FbExtraSchemaChecks != 0 { + _corruptSchema(tls, pData, argv, __ccgo_ts+16084) + } + } + } + } + } + } + return 0 +} + +// C documentation +// +// /* +// ** Attempt to read the database schema and initialize internal +// ** data structures for a single database file. The index of the +// ** database file is given by iDb. iDb==0 is used for the main +// ** database. iDb==1 should never be used. iDb>=2 is used for +// ** auxiliary databases. Return one of the SQLITE_ error codes to +// ** indicate success or failure. +// */ +func _sqlite3InitOne(tls *libc.TLS, db uintptr, iDb int32, pzErrMsg uintptr, mFlags Tu32) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var encoding Tu8 + var i, mask, openedTransaction, rc, size int32 + var pDb, zSchemaTabName, zSql, v1, v2 uintptr + var xAuth Tsqlite3_xauth + var _ /* azArg at bp+0 */ [6]uintptr + var _ /* initData at bp+72 */ TInitData + var _ /* meta at bp+48 */ [5]int32 + _, _, _, _, _, _, _, _, _, _, _, _ = encoding, i, mask, openedTransaction, pDb, rc, size, xAuth, zSchemaTabName, zSql, v1, v2 + openedTransaction = 0 + mask = libc.Int32FromUint32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&libc.Uint32FromInt32(DBFLAG_EncodingFixed) | libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_EncodingFixed))) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(1) + /* Construct the in-memory representation schema tables (sqlite_schema or + ** sqlite_temp_schema) by invoking the parser directly. The appropriate + ** table name will be inserted automatically by the parser so we can just + ** use the abbreviation "x" here. The parser will also automatically tag + ** the schema table as read-only. */ + (**(**[6]uintptr)(__ccgo_up(bp)))[0] = __ccgo_ts + 9721 + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v2 = __ccgo_ts + 7108 + } else { + v2 = __ccgo_ts + 6628 + } + v1 = v2 + zSchemaTabName = v1 + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(1)] = v1 + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(2)] = (**(**[6]uintptr)(__ccgo_up(bp)))[int32(1)] + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(3)] = __ccgo_ts + 20496 + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(4)] = __ccgo_ts + 20498 + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(5)] = uintptr(0) + (**(**TInitData)(__ccgo_up(bp + 72))).Fdb = db + (**(**TInitData)(__ccgo_up(bp + 72))).FiDb = iDb + (**(**TInitData)(__ccgo_up(bp + 72))).Frc = SQLITE_OK + (**(**TInitData)(__ccgo_up(bp + 72))).FpzErrMsg = pzErrMsg + (**(**TInitData)(__ccgo_up(bp + 72))).FmInitFlags = mFlags + (**(**TInitData)(__ccgo_up(bp + 72))).FnInitRow = uint32(0) + (**(**TInitData)(__ccgo_up(bp + 72))).FmxPage = uint32(0) + _sqlite3InitCallback(tls, bp+72, int32(5), bp, uintptr(0)) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(mask) + if (**(**TInitData)(__ccgo_up(bp + 72))).Frc != 0 { + rc = (**(**TInitData)(__ccgo_up(bp + 72))).Frc + goto error_out + } + /* Create a cursor to hold the database open + */ + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpBt == uintptr(0) { + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(DB_SchemaLoaded)) + rc = SQLITE_OK + goto error_out + } + /* If there is not already a read-only (or read-write) transaction opened + ** on the b-tree database, open one now. If a transaction is opened, it + ** will be closed before this function returns. */ + _sqlite3BtreeEnter(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + if _sqlite3BtreeTxnState(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) == SQLITE_TXN_NONE { + rc = _sqlite3BtreeBeginTrans(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, 0, uintptr(0)) + if rc != SQLITE_OK { + _sqlite3SetString(tls, pzErrMsg, db, _sqlite3ErrStr(tls, rc)) + goto initone_error_out + } + openedTransaction = int32(1) + } + /* Get the database meta information. + ** + ** Meta values are as follows: + ** meta[0] Schema cookie. Changes with each schema change. + ** meta[1] File format of schema layer. + ** meta[2] Size of the page cache. + ** meta[3] Largest rootpage (auto/incr_vacuum mode) + ** meta[4] Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE + ** meta[5] User version + ** meta[6] Incremental vacuum mode + ** meta[7] unused + ** meta[8] unused + ** meta[9] unused + ** + ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to + ** the possible values of meta[4]. + */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(20)/libc.Uint64FromInt64(4))) { + break + } + _sqlite3BtreeGetMeta(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, i+int32(1), bp+48+uintptr(i)*4) + goto _4 + _4: + ; + i = i + 1 + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ResetDatabase) != uint64(0) { + libc.X__builtin___memset_chk(tls, bp+48, 0, uint64(20), ^t__predefined_size_t(0)) + } + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_SCHEMA_VERSION)-libc.Int32FromInt32(1)] + /* If opening a non-empty database, check the text encoding. For the + ** main database, set sqlite3.enc to the encoding of the main database. + ** For an attached db, it is an error if the encoding is not the same + ** as sqlite3.enc. + */ + if (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_TEXT_ENCODING)-libc.Int32FromInt32(1)] != 0 { /* text encoding */ + if iDb == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_EncodingFixed) == uint32(0) { + /* If opening the main database, set ENC(db). */ + encoding = libc.Uint8FromInt32(libc.Int32FromUint8(libc.Uint8FromInt32((**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_TEXT_ENCODING)-libc.Int32FromInt32(1)])) & int32(3)) + if libc.Int32FromUint8(encoding) == 0 { + encoding = uint8(SQLITE_UTF8) + } + _sqlite3SetTextEncoding(tls, db, encoding) + } else { + /* If opening an attached database, the encoding much match ENC(db) */ + if (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_TEXT_ENCODING)-libc.Int32FromInt32(1)]&int32(3) != libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Fenc) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+13690) + rc = int32(SQLITE_ERROR) + goto initone_error_out + } + } + } + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fenc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + if (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size == 0 { + size = _sqlite3AbsInt32(tls, (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_DEFAULT_CACHE_SIZE)-libc.Int32FromInt32(1)]) + if size == 0 { + size = -int32(2000) + } + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size + _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) + } + /* + ** file_format==1 Version 3.0.0. + ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN + ** file_format==3 Version 3.1.4. // ditto but with non-NULL defaults + ** file_format==4 Version 3.3.0. // DESC indices. Boolean constants + */ + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = libc.Uint8FromInt32((**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_FILE_FORMAT)-libc.Int32FromInt32(1)]) + if libc.Int32FromUint8((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) == 0 { + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = uint8(1) + } + if libc.Int32FromUint8((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) > int32(SQLITE_MAX_FILE_FORMAT) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+20570) + rc = int32(SQLITE_ERROR) + goto initone_error_out + } + /* Ticket #2804: When we open a database in the newer file format, + ** clear the legacy_file_format pragma flag so that a VACUUM will + ** not downgrade the database and thus invalidate any descending + ** indices that the user might have created. + */ + if iDb == 0 && (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_FILE_FORMAT)-libc.Int32FromInt32(1)] >= int32(4) { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_LegacyFileFmt) + } + /* Read the schema information out of the schema tables + */ + (**(**TInitData)(__ccgo_up(bp + 72))).FmxPage = _sqlite3BtreeLastPage(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+20594, libc.VaList(bp+120, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zSchemaTabName)) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_sqlite3InitCallback), bp+72, uintptr(0)) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + if rc == SQLITE_OK { + rc = (**(**TInitData)(__ccgo_up(bp + 72))).Frc + } + _sqlite3DbFree(tls, db, zSql) + if rc == SQLITE_OK { + _sqlite3AnalysisLoad(tls, db, iDb) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + _sqlite3ResetAllSchemasOfConnection(tls, db) + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + } else { + if rc == SQLITE_OK || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NoSchemaError) != 0 && rc != int32(SQLITE_NOMEM) { + /* Hack: If the SQLITE_NoSchemaError flag is set, then consider + ** the schema loaded, even if errors (other than OOM) occurred. In + ** this situation the current sqlite3_prepare() operation will fail, + ** but the following one will attempt to compile the supplied statement + ** against whatever subset of the schema was loaded before the error + ** occurred. + ** + ** The primary purpose of this is to allow access to the sqlite_schema + ** table even when its contents have been corrupted. + */ + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(DB_SchemaLoaded)) + rc = SQLITE_OK + } + } + /* Jump here for an error that occurs after successfully allocating + ** curMain and calling sqlite3BtreeEnter(). For an error that occurs + ** before that point, jump to error_out. + */ + goto initone_error_out +initone_error_out: + ; + if openedTransaction != 0 { + _sqlite3BtreeCommit(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + } + _sqlite3BtreeLeave(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + goto error_out +error_out: + ; + if rc != 0 { + if rc == int32(SQLITE_NOMEM) || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)< and its indices +// ** put VALUES clause expressions into registers +// ** write the resulting record into
+// ** cleanup +// ** +// ** The three remaining templates assume the statement is of the form +// ** +// ** INSERT INTO
SELECT ... +// ** +// ** If the SELECT clause is of the restricted form "SELECT * FROM " - +// ** in other words if the SELECT pulls all columns from a single table +// ** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and +// ** if and are distinct tables but have identical +// ** schemas, including all the same indices, then a special optimization +// ** is invoked that copies raw records from over to . +// ** See the xferOptimization() function for the implementation of this +// ** template. This is the 2nd template. +// ** +// ** open a write cursor to
+// ** open read cursor on +// ** transfer all records in over to
+// ** close cursors +// ** foreach index on
+// ** open a write cursor on the
index +// ** open a read cursor on the corresponding index +// ** transfer all records from the read to the write cursors +// ** close cursors +// ** end foreach +// ** +// ** The 3rd template is for when the second template does not apply +// ** and the SELECT clause does not read from
at any time. +// ** The generated code follows this template: +// ** +// ** X <- A +// ** goto B +// ** A: setup for the SELECT +// ** loop over the rows in the SELECT +// ** load values into registers R..R+n +// ** yield X +// ** end loop +// ** cleanup after the SELECT +// ** end-coroutine X +// ** B: open write cursor to
and its indices +// ** C: yield X, at EOF goto D +// ** insert the select result into
from R..R+n +// ** goto C +// ** D: cleanup +// ** +// ** The 4th template is used if the insert statement takes its +// ** values from a SELECT but the data is being inserted into a table +// ** that is also read as part of the SELECT. In the third form, +// ** we have to use an intermediate table to store the results of +// ** the select. The template is like this: +// ** +// ** X <- A +// ** goto B +// ** A: setup for the SELECT +// ** loop over the tables in the SELECT +// ** load value into register R..R+n +// ** yield X +// ** end loop +// ** cleanup after the SELECT +// ** end co-routine R +// ** B: open temp table +// ** L: yield X, at EOF goto M +// ** insert row from R..R+n into temp table +// ** goto L +// ** M: open write cursor to
and its indices +// ** rewind temp table +// ** C: loop over rows of intermediate table +// ** transfer values form intermediate table into
+// ** end loop +// ** D: cleanup +// */ +func _sqlite3Insert(tls *libc.TLS, pParse uintptr, pTabList uintptr, pSelect uintptr, pColumn uintptr, onError int32, pUpsert uintptr) { + bp := tls.Alloc(160) + defer tls.Free(160) + var aRegIdx, aTabColMap, db, pIdx, pIpk, pItem, pList, pNx, pSubq, pTab, pTrigger, pVTab, pX, v, v5 uintptr + var addr1, addr11, addrCont, addrInsTop, addrL, addrTop, bUseSeek, endOfLoop, i, iDb, iRegStore, ipkColumn, isView, j, k, nColumn, nHidden, nIdx, rc, regAutoinc, regCols, regData, regFromSelect, regIns, regRec, regRowCount, regRowid, regTempRowid, regYield, srcTab, y, v1 int32 + var appendFlag, bIdListInOrder, useTempTable, withoutRowid Tu8 + var colFlags, v20 Tu32 + var _ /* dest at bp+8 */ TSelectDest + var _ /* iDataCur at bp+0 */ int32 + var _ /* iIdxCur at bp+4 */ int32 + var _ /* isReplace at bp+112 */ int32 + var _ /* sNC at bp+56 */ TNameContext + var _ /* tmask at bp+48 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aRegIdx, aTabColMap, addr1, addr11, addrCont, addrInsTop, addrL, addrTop, appendFlag, bIdListInOrder, bUseSeek, colFlags, db, endOfLoop, i, iDb, iRegStore, ipkColumn, isView, j, k, nColumn, nHidden, nIdx, pIdx, pIpk, pItem, pList, pNx, pSubq, pTab, pTrigger, pVTab, pX, rc, regAutoinc, regCols, regData, regFromSelect, regIns, regRec, regRowCount, regRowid, regTempRowid, regYield, srcTab, useTempTable, v, withoutRowid, y, v1, v20, v5 /* Number of columns in the data */ + nHidden = 0 /* Number of hidden columns if TABLE is virtual */ + **(**int32)(__ccgo_up(bp)) = 0 /* VDBE cursor that is the main data repository */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* First index cursor */ + ipkColumn = -int32(1) /* Label for the end of the insertion loop */ + srcTab = 0 /* Data comes from this temporary cursor if >=0 */ + addrInsTop = 0 /* Jump to label "D" */ + addrCont = 0 /* Index of database holding TABLE */ + useTempTable = uint8(0) /* Store SELECT results in intermediate table */ + appendFlag = uint8(0) /* True if IDLIST is in table order */ + pList = uintptr(0) /* Register in which to store next column */ + /* Register allocations */ + regFromSelect = 0 /* Base register for data coming from SELECT */ + regAutoinc = 0 /* Register holding the AUTOINCREMENT counter */ + regRowCount = 0 /* register holding first column to insert */ + aRegIdx = uintptr(0) /* One register allocated to each index */ + aTabColMap = uintptr(0) /* Mask of trigger times */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto insert_cleanup + } + (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSDParm = 0 /* Suppress a harmless compiler warning */ + /* If the Select object is really just a simple VALUES() list with a + ** single row (the common case) then keep that one row of values + ** and discard the other (unused) parts of the pSelect object + */ + if pSelect != 0 && (*TSelect)(unsafe.Pointer(pSelect)).FselFlags&uint32(SF_Values) != uint32(0) && (*TSelect)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0) { + pList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + (*TSelect)(unsafe.Pointer(pSelect)).FpEList = uintptr(0) + _sqlite3SelectDelete(tls, db, pSelect) + pSelect = uintptr(0) + } + /* Locate the table into which we will be inserting new information. + */ + pTab = _sqlite3SrcListLookup(tls, pParse, pTabList) + if pTab == uintptr(0) { + goto insert_cleanup + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) != 0 { + goto insert_cleanup + } + withoutRowid = libc.BoolUint8(!((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0))) + /* Figure out if we have any triggers and if the table being + ** inserted into is a view + */ + pTrigger = _sqlite3TriggersExist(tls, pParse, pTab, int32(TK_INSERT), uintptr(0), bp+48) + isView = libc.BoolInt32(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW)) + /* If pTab is really a view, make sure it has been initialized. + ** ViewGetColumnNames() is a no-op if pTab is not a view. + */ + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto insert_cleanup + } + /* Cannot insert into a read-only table. + */ + if _sqlite3IsReadOnly(tls, pParse, pTab, pTrigger) != 0 { + goto insert_cleanup + } + /* Allocate a VDBE + */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto insert_cleanup + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _sqlite3VdbeCountChanges(tls, v) + } + _sqlite3BeginWriteOperation(tls, pParse, libc.BoolInt32(pSelect != 0 || pTrigger != 0), iDb) + /* If the statement is of the form + ** + ** INSERT INTO SELECT * FROM ; + ** + ** Then special optimizations can be applied that make the transfer + ** very fast and which reduce fragmentation of indices. + ** + ** This is the 2nd template. + */ + if pColumn == uintptr(0) && pSelect != uintptr(0) && pTrigger == uintptr(0) && _xferOptimization(tls, pParse, pTab, pSelect, onError, iDb) != 0 { + goto insert_end + } + /* If this is an AUTOINCREMENT table, look up the sequence number in the + ** sqlite_sequence table and store it in memory cell regAutoinc. + */ + regAutoinc = _autoIncBegin(tls, pParse, iDb, pTab) + /* Allocate a block registers to hold the rowid and the values + ** for all columns of the new row. + */ + v1 = (*TParse)(unsafe.Pointer(pParse)).FnMem + libc.Int32FromInt32(1) + regIns = v1 + regRowid = v1 + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + int32(1) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + regRowid = regRowid + 1 + (*TParse)(unsafe.Pointer(pParse)).FnMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + 1 + } + regData = regRowid + int32(1) + /* If the INSERT statement included an IDLIST term, then make sure + ** all elements of the IDLIST really are columns of the table and + ** remember the column indices. + ** + ** If the table has an INTEGER PRIMARY KEY column and that column + ** is named in the IDLIST, then record in the ipkColumn variable + ** the index into IDLIST of the primary key column. ipkColumn is + ** the index of the primary key as it appears in IDLIST, not as + ** is appears in the original table. (The index of the INTEGER + ** PRIMARY KEY in the original table is pTab->iPKey.) After this + ** loop, if ipkColumn==(-1), that means that integer primary key + ** is unspecified, and hence the table is either WITHOUT ROWID or + ** it will automatically generated an integer primary key. + ** + ** bIdListInOrder is true if the columns in IDLIST are in storage + ** order. This enables an optimization that avoids shuffling the + ** columns into storage order. False negatives are harmless, + ** but false positives will cause database corruption. + */ + bIdListInOrder = libc.BoolUint8((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(libc.Int32FromInt32(TF_OOOHidden)|libc.Int32FromInt32(TF_HasStored)) == uint32(0)) + if pColumn != 0 { + aTabColMap = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt16((*TTable)(unsafe.Pointer(pTab)).FnCol)*uint64(4))) + if aTabColMap == uintptr(0) { + goto insert_cleanup + } + i = 0 + for { + if !(i < (*TIdList)(unsafe.Pointer(pColumn)).FnId) { + break + } + j = _sqlite3ColumnIndex(tls, pTab, (*(*TIdList_item)(unsafe.Pointer(pColumn + 8 + uintptr(i)*8))).FzName) + if j >= 0 { + if **(**int32)(__ccgo_up(aTabColMap + uintptr(j)*4)) == 0 { + **(**int32)(__ccgo_up(aTabColMap + uintptr(j)*4)) = i + int32(1) + } + if i != j { + bIdListInOrder = uint8(0) + } + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + ipkColumn = i + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&(libc.Int32FromInt32(COLFLAG_STORED)|libc.Int32FromInt32(COLFLAG_VIRTUAL)) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17689, libc.VaList(bp+128, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FzCnName)) + goto insert_cleanup + } + } else { + if _sqlite3IsRowid(tls, (*(*TIdList_item)(unsafe.Pointer(pColumn + 8 + uintptr(i)*8))).FzName) != 0 && !(withoutRowid != 0) { + ipkColumn = i + bIdListInOrder = uint8(0) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17730, libc.VaList(bp+128, pTabList+8, (*(*TIdList_item)(unsafe.Pointer(pColumn + 8 + uintptr(i)*8))).FzName)) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + goto insert_cleanup + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + /* Figure out how many columns of data are supplied. If the data + ** is coming from a SELECT statement, then generate a co-routine that + ** produces a single row of the SELECT on each invocation. The + ** co-routine is the common header to the 3rd and 4th templates. + */ + if pSelect != 0 { /* Result code */ + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc == int32(1) && int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + 24 + 4))&0x40>>6) != 0 && (*TSelect)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0) { + pItem = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + pSubq = *(*uintptr)(unsafe.Pointer(pItem + 72)) + (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSDParm = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + regFromSelect = (*TSubquery)(unsafe.Pointer(pSubq)).FregResult + nColumn = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(pSubq)).FpSelect)).FpEList)).FnExpr + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+17762, libc.VaList(bp+128, pItem)) + if bIdListInOrder != 0 && nColumn == int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + regData = regFromSelect + regRowid = regData - int32(1) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + v1 = int32(1) + } else { + v1 = 0 + } + regIns = regRowid - v1 + } + } else { + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v1 = *(*int32)(unsafe.Pointer(v5)) /* Top of the co-routine */ + regYield = v1 + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, addrTop) + _sqlite3SelectDestInit(tls, bp+8, int32(SRT_Coroutine), regYield) + if bIdListInOrder != 0 { + v1 = regData + } else { + v1 = 0 + } + (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSdst = v1 + (**(**TSelectDest)(__ccgo_up(bp + 8))).FnSdst = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + rc = _sqlite3Select(tls, pParse, pSelect, bp+8) + regFromSelect = (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSdst + if rc != 0 || (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto insert_cleanup + } + _sqlite3VdbeEndCoroutine(tls, v, regYield) + _sqlite3VdbeJumpHere(tls, v, addrTop-int32(1)) /* label B: */ + nColumn = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList)).FnExpr + } + /* Set useTempTable to TRUE if the result of the SELECT statement + ** should be written into a temporary table (template 4). Set to + ** FALSE if each output row of the SELECT can be written directly into + ** the destination table (template 3). + ** + ** A temp table must be used if the table being updated is also one + ** of the tables being read by the SELECT statement. Also use a + ** temp table in the case of row triggers. + */ + if pTrigger != 0 || _readsTable(tls, pParse, iDb, pTab) != 0 { + useTempTable = uint8(1) + } + if useTempTable != 0 { /* Label "L" */ + v5 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v5)) + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + srcTab = v1 + regRec = _sqlite3GetTempReg(tls, pParse) + regTempRowid = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), srcTab, nColumn) + addrL = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSDParm) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regFromSelect, nColumn, regRec) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), srcTab, regTempRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), srcTab, regRec, regTempRowid) + _sqlite3VdbeGoto(tls, v, addrL) + _sqlite3VdbeJumpHere(tls, v, addrL) + _sqlite3ReleaseTempReg(tls, pParse, regRec) + _sqlite3ReleaseTempReg(tls, pParse, regTempRowid) + } + } else { + libc.X__builtin___memset_chk(tls, bp+56, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp + 56))).FpParse = pParse + srcTab = -int32(1) + if pList != 0 { + nColumn = (*TExprList)(unsafe.Pointer(pList)).FnExpr + if _sqlite3ResolveExprListNames(tls, bp+56, pList) != 0 { + goto insert_cleanup + } + } else { + nColumn = 0 + } + } + /* If there is no IDLIST term but the table has an integer primary + ** key, the set the ipkColumn variable to the integer primary key + ** column index in the original table definition. + */ + if pColumn == uintptr(0) && nColumn > 0 { + ipkColumn = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + if ipkColumn >= 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != uint32(0) { + i = ipkColumn - int32(1) + for { + if !(i >= 0) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + ipkColumn = ipkColumn - 1 + } + goto _9 + _9: + ; + i = i - 1 + } + } + /* Make sure the number of columns in the source data matches the number + ** of columns to be inserted into the table. + */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(libc.Int32FromInt32(TF_HasGenerated)|libc.Int32FromInt32(TF_HasHidden)) != uint32(0) { + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_NOINSERT) != 0 { + nHidden = nHidden + 1 + } + goto _10 + _10: + ; + i = i + 1 + } + } + if nColumn != int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-nHidden { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17770, libc.VaList(bp+128, pTabList+8, int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-nHidden, nColumn)) + goto insert_cleanup + } + } + if pColumn != uintptr(0) && nColumn != (*TIdList)(unsafe.Pointer(pColumn)).FnId { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17822, libc.VaList(bp+128, nColumn, (*TIdList)(unsafe.Pointer(pColumn)).FnId)) + goto insert_cleanup + } + /* Initialize the count of rows to be inserted + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00001))<>3)) != 0) { + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v1 = *(*int32)(unsafe.Pointer(v5)) + regRowCount = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regRowCount) + } + /* If this is not a view, open the table and and all indices */ + if !(isView != 0) { + nIdx = _sqlite3OpenTableAndIndices(tls, pParse, pTab, int32(OP_OpenWrite), uint8(0), -int32(1), uintptr(0), bp, bp+4) + aRegIdx = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(nIdx+libc.Int32FromInt32(2)))) + if aRegIdx == uintptr(0) { + goto insert_cleanup + } + i = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(i < nIdx) { + break + } + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v1 = *(*int32)(unsafe.Pointer(v5)) + **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)) = v1 + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + goto _13 + _13: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + i = i + 1 + } + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v1 = *(*int32)(unsafe.Pointer(v5)) + **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)) = v1 /* Register to store the table record */ + } + if pUpsert != 0 { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17847, libc.VaList(bp+128, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto insert_cleanup + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17893, 0) + goto insert_cleanup + } + if _sqlite3HasExplicitNulls(tls, pParse, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) != 0 { + goto insert_cleanup + } + (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor = **(**int32)(__ccgo_up(bp)) + pNx = pUpsert + for cond := true; cond; cond = pNx != uintptr(0) { + (*TUpsert)(unsafe.Pointer(pNx)).FpUpsertSrc = pTabList + (*TUpsert)(unsafe.Pointer(pNx)).FregData = regData + (*TUpsert)(unsafe.Pointer(pNx)).FiDataCur = **(**int32)(__ccgo_up(bp)) + (*TUpsert)(unsafe.Pointer(pNx)).FiIdxCur = **(**int32)(__ccgo_up(bp + 4)) + if (*TUpsert)(unsafe.Pointer(pNx)).FpUpsertTarget != 0 { + if _sqlite3UpsertAnalyzeTarget(tls, pParse, pTabList, pNx, pUpsert) != 0 { + goto insert_cleanup + } + } + pNx = (*TUpsert)(unsafe.Pointer(pNx)).FpNextUpsert + } + } + /* This is the top of the main insertion loop */ + if useTempTable != 0 { + /* This block codes the top of loop only. The complete loop is the + ** following pseudocode (template 4): + ** + ** rewind temp table, if empty goto D + ** C: loop over rows of intermediate table + ** transfer values form intermediate table into
+ ** end loop + ** D: ... + */ + addrInsTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), srcTab) + addrCont = _sqlite3VdbeCurrentAddr(tls, v) + } else { + if pSelect != 0 { + /* This block codes the top of loop only. The complete loop is the + ** following pseudocode (template 3): + ** + ** C: yield X, at EOF goto D + ** insert the select result into
from R..R+n + ** goto C + ** D: ... + */ + v1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSDParm) + addrCont = v1 + addrInsTop = v1 + if ipkColumn >= 0 { + /* tag-20191021-001: If the INTEGER PRIMARY KEY is being generated by the + ** SELECT, go ahead and copy the value into the rowid slot now, so that + ** the value does not get overwritten by a NULL at tag-20191021-002. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), regFromSelect+ipkColumn, regRowid) + } + } + } + /* Compute data for ordinary columns of the new entry. Values + ** are written in storage order into registers starting with regData. + ** Only ordinary columns are computed in this loop. The rowid + ** (if there is one) is computed later and generated columns are + ** computed after the rowid since they might depend on the value + ** of the rowid. + */ + nHidden = 0 + iRegStore = regData + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if i == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + /* tag-20191021-002: References to the INTEGER PRIMARY KEY are filled + ** using the rowid. So put a NULL in the IPK slot of the record to avoid + ** using excess space. The file format definition requires this extra + ** NULL - we cannot optimize further by skipping the column completely */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_SoftNull), iRegStore) + goto _19 + } + v20 = uint32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags) + colFlags = v20 + if v20&uint32(COLFLAG_NOINSERT) != uint32(0) { + nHidden = nHidden + 1 + if colFlags&uint32(COLFLAG_VIRTUAL) != uint32(0) { + /* Virtual columns do not participate in OP_MakeRecord. So back up + ** iRegStore by one slot to compensate for the iRegStore++ in the + ** outer for() loop */ + iRegStore = iRegStore - 1 + goto _19 + } else { + if colFlags&uint32(COLFLAG_STORED) != uint32(0) { + /* Stored columns are computed later. But if there are BEFORE + ** triggers, the slots used for stored columns will be OP_Copy-ed + ** to a second block of registers, so the register needs to be + ** initialized to NULL to avoid an uninitialized register read */ + if **(**int32)(__ccgo_up(bp + 48))&int32(TRIGGER_BEFORE) != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_SoftNull), iRegStore) + } + goto _19 + } else { + if pColumn == uintptr(0) { + /* Hidden columns that are not explicitly named in the INSERT + ** get their default value */ + _sqlite3ExprCodeFactorable(tls, pParse, _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16), iRegStore) + goto _19 + } + } + } + } + if pColumn != 0 { + j = **(**int32)(__ccgo_up(aTabColMap + uintptr(i)*4)) + if j == 0 { + /* A column not named in the insert column list gets its + ** default value */ + _sqlite3ExprCodeFactorable(tls, pParse, _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16), iRegStore) + goto _19 + } + k = j - int32(1) + } else { + if nColumn == 0 { + /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */ + _sqlite3ExprCodeFactorable(tls, pParse, _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16), iRegStore) + goto _19 + } else { + k = i - nHidden + } + } + if useTempTable != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), srcTab, k, iRegStore) + } else { + if pSelect != 0 { + if regFromSelect != regData { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), regFromSelect+k, iRegStore) + } + } else { + pX = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(k)*32))).FpExpr + y = _sqlite3ExprCodeTarget(tls, pParse, pX, iRegStore) + if y != iRegStore { + if (*TExpr)(unsafe.Pointer(pX)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + v1 = int32(OP_Copy) + } else { + v1 = int32(OP_SCopy) + } + _sqlite3VdbeAddOp2(tls, v, v1, y, iRegStore) + } + } + } + goto _19 + _19: + ; + i = i + 1 + iRegStore = iRegStore + 1 + } + /* Run the BEFORE and INSTEAD OF triggers, if there are any + */ + endOfLoop = _sqlite3VdbeMakeLabel(tls, pParse) + if **(**int32)(__ccgo_up(bp + 48))&int32(TRIGGER_BEFORE) != 0 { + regCols = _sqlite3GetTempRange(tls, pParse, int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1)) + /* build the NEW.* reference row. Note that if there is an INTEGER + ** PRIMARY KEY into which a NULL is being inserted, that NULL will be + ** translated into a unique ID for the row. But on a BEFORE trigger, + ** we do not know what the unique ID will be (because the insert has + ** not happened yet) so we substitute a rowid of -1 + */ + if ipkColumn < 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), -int32(1), regCols) + } else { + if useTempTable != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), srcTab, ipkColumn, regCols) + } else { + /* Otherwise useTempTable is true */ + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ipkColumn)*32))).FpExpr, regCols) + } + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_NotNull), regCols) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), -int32(1), regCols) + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp1(tls, v, int32(OP_MustBeInt), regCols) + } + /* Copy the new data already generated. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regRowid+int32(1), regCols+int32(1), int32((*TTable)(unsafe.Pointer(pTab)).FnNVCol)-int32(1)) + /* Compute the new value for generated columns after all other + ** columns have already been computed. This must be done after + ** computing the ROWID in case one of the generated columns + ** refers to the ROWID. */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != 0 { + _sqlite3ComputeGeneratedColumns(tls, pParse, regCols+int32(1), pTab) + } + /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger, + ** do not attempt any conversions before assembling the record. + ** If this is a real table, attempt conversions as required by the + ** table column affinities. + */ + if !(isView != 0) { + _sqlite3TableAffinity(tls, v, pTab, regCols+int32(1)) + } + /* Fire BEFORE or INSTEAD OF triggers */ + _sqlite3CodeRowTrigger(tls, pParse, pTrigger, int32(TK_INSERT), uintptr(0), int32(TRIGGER_BEFORE), pTab, regCols-int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1), onError, endOfLoop) + _sqlite3ReleaseTempRange(tls, pParse, regCols, int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1)) + } + if !(isView != 0) { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + /* The row that the VUpdate opcode will delete: none */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regIns) + } + if ipkColumn >= 0 { + /* Compute the new rowid */ + if useTempTable != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), srcTab, ipkColumn, regRowid) + } else { + if pSelect != 0 { + /* Rowid already initialized at tag-20191021-001 */ + } else { + pIpk = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ipkColumn)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pIpk)).Fop) == int32(TK_NULL) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_NewRowid), **(**int32)(__ccgo_up(bp)), regRowid, regAutoinc) + appendFlag = uint8(1) + } else { + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ipkColumn)*32))).FpExpr, regRowid) + } + } + } + /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid + ** to generate a unique primary key value. + */ + if !(appendFlag != 0) { + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + addr11 = _sqlite3VdbeAddOp1(tls, v, int32(OP_NotNull), regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_NewRowid), **(**int32)(__ccgo_up(bp)), regRowid, regAutoinc) + _sqlite3VdbeJumpHere(tls, v, addr11) + } else { + addr11 = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regRowid, addr11+int32(2)) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_MustBeInt), regRowid) + } + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) || withoutRowid != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regRowid) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_NewRowid), **(**int32)(__ccgo_up(bp)), regRowid, regAutoinc) + appendFlag = uint8(1) + } + } + _autoIncStep(tls, pParse, regAutoinc, regRowid) + /* Compute the new value for generated columns after all other + ** columns have already been computed. This must be done after + ** computing the ROWID in case one of the generated columns + ** is derived from the INTEGER PRIMARY KEY. */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != 0 { + _sqlite3ComputeGeneratedColumns(tls, pParse, regRowid+int32(1), pTab) + } + /* Generate code to check constraints and generate index keys and + ** do the insertion. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + pVTab = _sqlite3GetVTable(tls, db, pTab) + _sqlite3VtabMakeWritable(tls, pParse, pTab) + _sqlite3VdbeAddOp4(tls, v, int32(OP_VUpdate), int32(1), int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(2), regIns, pVTab, -int32(12)) + if onError == int32(OE_Default) { + v1 = int32(OE_Abort) + } else { + v1 = onError + } + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(v1)) + _sqlite3MayAbort(tls, pParse) + } else { + **(**int32)(__ccgo_up(bp + 112)) = 0 /* True to use OPFLAG_SEEKRESULT */ + _sqlite3GenerateConstraintChecks(tls, pParse, pTab, aRegIdx, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), regIns, 0, libc.BoolUint8(ipkColumn >= 0), libc.Uint8FromInt32(onError), endOfLoop, bp+112, uintptr(0), pUpsert) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 { + _sqlite3FkCheck(tls, pParse, pTab, 0, regIns, uintptr(0), 0) + } + /* Set the OPFLAG_USESEEKRESULT flag if either (a) there are no REPLACE + ** constraints or (b) there are no triggers and this table is not a + ** parent table in a foreign key constraint. It is safe to set the + ** flag in the second case as if any REPLACE constraint is hit, an + ** OP_Delete or OP_IdxDelete instruction will be executed on each + ** cursor that is disturbed. And these instructions both clear the + ** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT + ** functionality. */ + bUseSeek = libc.BoolInt32(**(**int32)(__ccgo_up(bp + 112)) == 0 || !(_sqlite3VdbeHasSubProgram(tls, v) != 0)) + _sqlite3CompleteInsertion(tls, pParse, pTab, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), regIns, aRegIdx, 0, libc.Int32FromUint8(appendFlag), bUseSeek) + } + } + /* Update the count of rows that are inserted + */ + if regRowCount != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), regRowCount, int32(1)) + } + if pTrigger != 0 { + /* Code AFTER triggers */ + _sqlite3CodeRowTrigger(tls, pParse, pTrigger, int32(TK_INSERT), uintptr(0), int32(TRIGGER_AFTER), pTab, regData-int32(2)-int32((*TTable)(unsafe.Pointer(pTab)).FnCol), onError, endOfLoop) + } + /* The bottom of the main insertion loop, if the data source + ** is a SELECT statement. + */ + _sqlite3VdbeResolveLabel(tls, v, endOfLoop) + if useTempTable != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), srcTab, addrCont) + _sqlite3VdbeJumpHere(tls, v, addrInsTop) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), srcTab) + } else { + if pSelect != 0 { + _sqlite3VdbeGoto(tls, v, addrCont) + _sqlite3VdbeJumpHere(tls, v, addrInsTop) + } + } + goto insert_end +insert_end: + ; + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0) { + _sqlite3AutoincrementEnd(tls, pParse) + } + /* + ** Return the number of rows inserted. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + if regRowCount != 0 { + _sqlite3CodeChangeCount(tls, v, regRowCount, __ccgo_ts+17914) + } + goto insert_cleanup +insert_cleanup: + ; + _sqlite3SrcListDelete(tls, db, pTabList) + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3UpsertDelete(tls, db, pUpsert) + _sqlite3SelectDelete(tls, db, pSelect) + if pColumn != 0 { + _sqlite3IdListDelete(tls, db, pColumn) + _sqlite3DbFree(tls, db, aTabColMap) + } + if aRegIdx != 0 { + _sqlite3DbNNFreeNN(tls, db, aRegIdx) + } +} + +/* Make sure "isView" and other macros defined above are undefined. Otherwise +** they may interfere with compilation of other functions in this file +** (or in another file, if this file becomes part of the amalgamation). */ + +/* +** Meanings of bits in of pWalker->eCode for +** sqlite3ExprReferencesUpdatedColumn() + */ + +// C documentation +// +// /* +// ** Render an signed 64-bit integer as text. Store the result in zOut[] and +// ** return the length of the string that was stored, in bytes. The value +// ** returned does not include the zero terminator at the end of the output +// ** string. +// ** +// ** The caller must ensure that zOut[] is at least 21 bytes in size. +// */ +func _sqlite3Int64ToText(tls *libc.TLS, v Ti64, zOut uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, kk, v2 int32 + var x Tu64 + var v1 uint64 + var _ /* u at bp+0 */ struct { + FforceAlignment [0]Tu16 + Fa [21]int8 + F__ccgo_pad2 [1]byte + } + _, _, _, _, _ = i, kk, x, v1, v2 + if v > 0 { + x = libc.Uint64FromInt64(v) + } else { + if v == 0 { + **(**int8)(__ccgo_up(zOut)) = int8('0') + **(**int8)(__ccgo_up(zOut + 1)) = 0 + return int32(1) + } else { + if v == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= uint64(10) { + kk = libc.Int32FromUint64(x % uint64(100) * uint64(2)) + **(**Tu16)(__ccgo_up(bp + uintptr(i-int32(2)))) = **(**Tu16)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3DigitPairs)) + uintptr(kk))) + i = i - int32(2) + x = x / uint64(100) + } + if x != 0 { + i = i - 1 + v2 = i + **(**int8)(__ccgo_up(bp + uintptr(v2))) = libc.Int8FromUint64(x + uint64('0')) + } + if v < 0 { + i = i - 1 + v2 = i + **(**int8)(__ccgo_up(bp + uintptr(v2))) = int8('-') + } + libc.X__builtin___memcpy_chk(tls, zOut, bp+uintptr(i), uint64(21)-libc.Uint64FromInt32(i), ^t__predefined_size_t(0)) + return libc.Int32FromUint64(libc.Uint64FromInt64(21) - libc.Uint64FromInt32(1) - libc.Uint64FromInt32(i)) +} + +// C documentation +// +// /* +// ** The following is the implementation of an SQL function that always +// ** fails with an error message stating that the function is used in the +// ** wrong context. The sqlite3_overload_function() API might construct +// ** SQL function that use this routine so that the functions will exist +// ** for name resolution but are actually overloaded by the xFindFunction +// ** method of virtual tables. +// */ +func _sqlite3InvalidFunction(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var zErr, zName uintptr + _, _ = zErr, zName + zName = Xsqlite3_user_data(tls, context) + _ = NotUsed + _ = NotUsed2 + zErr = Xsqlite3_mprintf(tls, __ccgo_ts+26300, libc.VaList(bp+8, zName)) + Xsqlite3_result_error(tls, context, zErr, -int32(1)) + Xsqlite3_free(tls, zErr) +} + +// C documentation +// +// /* +// ** pExpr points to an expression which implements a function. If +// ** it is appropriate to apply the LIKE optimization to that function +// ** then set aWc[0] through aWc[2] to the wildcard characters and the +// ** escape character and then return TRUE. If the function is not a +// ** LIKE-style function then return FALSE. +// ** +// ** The expression "a LIKE b ESCAPE c" is only considered a valid LIKE +// ** operator if c is a string literal that is exactly one byte in length. +// ** That one byte is stored in aWc[3]. aWc[3] is set to zero if there is +// ** no ESCAPE clause. +// ** +// ** *pIsNocase is set to true if uppercase and lowercase are equivalent for +// ** the function (default for LIKE). If the function makes the distinction +// ** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to +// ** false. +// */ +func _sqlite3IsLikeFunction(tls *libc.TLS, db uintptr, pExpr uintptr, pIsNocase uintptr, aWc uintptr) (r int32) { + var nExpr int32 + var pDef, pEscape, zEscape uintptr + _, _, _, _ = nExpr, pDef, pEscape, zEscape + if !(*(*uintptr)(unsafe.Pointer(pExpr + 32)) != 0) { + return 0 + } + nExpr = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + pDef = _sqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8)), nExpr, uint8(SQLITE_UTF8), uint8(0)) + if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_LIKE) == uint32(0) { + return 0 + } + /* The memcpy() statement assumes that the wildcard characters are + ** the first three statements in the compareInfo structure. The + ** asserts() that follow verify that assumption + */ + libc.X__builtin___memcpy_chk(tls, aWc, (*TFuncDef)(unsafe.Pointer(pDef)).FpUserData, uint64(3), ^t__predefined_size_t(0)) + if nExpr < int32(3) { + **(**int8)(__ccgo_up(aWc + 3)) = 0 + } else { + pEscape = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 2*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pEscape)).Fop) != int32(TK_STRING) { + return 0 + } + zEscape = *(*uintptr)(unsafe.Pointer(pEscape + 8)) + if int32(**(**int8)(__ccgo_up(zEscape))) == 0 || int32(**(**int8)(__ccgo_up(zEscape + 1))) != 0 { + return 0 + } + if int32(**(**int8)(__ccgo_up(zEscape))) == int32(**(**int8)(__ccgo_up(aWc))) { + return 0 + } + if int32(**(**int8)(__ccgo_up(zEscape))) == int32(**(**int8)(__ccgo_up(aWc + 1))) { + return 0 + } + **(**int8)(__ccgo_up(aWc + 3)) = **(**int8)(__ccgo_up(zEscape)) + } + **(**int32)(__ccgo_up(pIsNocase)) = libc.BoolInt32((*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_CASE) == uint32(0)) + return int32(1) +} + +/* Mathematical Constants */ + +// C documentation +// +// /* +// ** Return true if the floating point value is Not a Number (NaN). +// ** +// ** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN. +// ** Otherwise, we have our own implementation that works on most systems. +// */ +func _sqlite3IsNaN(tls *libc.TLS, _x float64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*float64)(unsafe.Pointer(bp)) = _x + var rc int32 + var _ /* y at bp+8 */ Tu64 + _ = rc + libc.X__builtin___memcpy_chk(tls, bp+8, bp, uint64(8), ^t__predefined_size_t(0)) + rc = libc.BoolInt32(**(**Tu64)(__ccgo_up(bp + 8))&(libc.Uint64FromInt32(0x7ff)< generate an error message and return 1. +// ** If pTab is writable but other errors have occurred -> return 1. +// ** If pTab is writable and no prior errors -> return 0; +// */ +func _sqlite3IsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr, pTrigger uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if _tabIsReadOnly(tls, pParse, pTab) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16722, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(1) + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) && (pTrigger == uintptr(0) || (*TTrigger)(unsafe.Pointer(pTrigger)).FbReturning != 0 && (*TTrigger)(unsafe.Pointer(pTrigger)).FpNext == uintptr(0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16751, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Return TRUE if the given string is a row-id column name. +// */ +func _sqlite3IsRowid(tls *libc.TLS, z uintptr) (r int32) { + if _sqlite3StrICmp(tls, z, __ccgo_ts+8533) == 0 { + return int32(1) + } + if _sqlite3StrICmp(tls, z, __ccgo_ts+8541) == 0 { + return int32(1) + } + if _sqlite3StrICmp(tls, z, __ccgo_ts+8547) == 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Check the input string to see if it is "true" or "false" (in any case). +// ** +// ** If the string is.... Return +// ** "true" EP_IsTrue +// ** "false" EP_IsFalse +// ** anything else 0 +// */ +func _sqlite3IsTrueOrFalse(tls *libc.TLS, zIn uintptr) (r Tu32) { + if _sqlite3StrICmp(tls, zIn, __ccgo_ts+8522) == 0 { + return uint32(EP_IsTrue) + } + if _sqlite3StrICmp(tls, zIn, __ccgo_ts+8527) == 0 { + return uint32(EP_IsFalse) + } + return uint32(0) +} + +// C documentation +// +// /* +// ** Given 1 to 3 identifiers preceding the JOIN keyword, determine the +// ** type of join. Return an integer constant that expresses that type +// ** in terms of the following bit values: +// ** +// ** JT_INNER +// ** JT_CROSS +// ** JT_OUTER +// ** JT_NATURAL +// ** JT_LEFT +// ** JT_RIGHT +// ** +// ** A full outer join is the combination of JT_LEFT and JT_RIGHT. +// ** +// ** If an illegal or unsupported join type is seen, then still return +// ** a join type, but put an error in the pParse structure. +// ** +// ** These are the valid join types: +// ** +// ** +// ** pA pB pC Return Value +// ** ------- ----- ----- ------------ +// ** CROSS - - JT_CROSS +// ** INNER - - JT_INNER +// ** LEFT - - JT_LEFT|JT_OUTER +// ** LEFT OUTER - JT_LEFT|JT_OUTER +// ** RIGHT - - JT_RIGHT|JT_OUTER +// ** RIGHT OUTER - JT_RIGHT|JT_OUTER +// ** FULL - - JT_LEFT|JT_RIGHT|JT_OUTER +// ** FULL OUTER - JT_LEFT|JT_RIGHT|JT_OUTER +// ** NATURAL INNER - JT_NATURAL|JT_INNER +// ** NATURAL LEFT - JT_NATURAL|JT_LEFT|JT_OUTER +// ** NATURAL LEFT OUTER JT_NATURAL|JT_LEFT|JT_OUTER +// ** NATURAL RIGHT - JT_NATURAL|JT_RIGHT|JT_OUTER +// ** NATURAL RIGHT OUTER JT_NATURAL|JT_RIGHT|JT_OUTER +// ** NATURAL FULL - JT_NATURAL|JT_LEFT|JT_RIGHT +// ** NATURAL FULL OUTER JT_NATRUAL|JT_LEFT|JT_RIGHT +// ** +// ** To preserve historical compatibly, SQLite also accepts a variety +// ** of other non-standard and in many cases nonsensical join types. +// ** This routine makes as much sense at it can from the nonsense join +// ** type and returns a result. Examples of accepted nonsense join types +// ** include but are not limited to: +// ** +// ** INNER CROSS JOIN -> same as JOIN +// ** NATURAL CROSS JOIN -> same as NATURAL JOIN +// ** OUTER LEFT JOIN -> same as LEFT JOIN +// ** LEFT NATURAL JOIN -> same as NATURAL LEFT JOIN +// ** LEFT RIGHT JOIN -> same as FULL JOIN +// ** RIGHT OUTER FULL JOIN -> same as FULL JOIN +// ** CROSS CROSS CROSS JOIN -> same as JOIN +// ** +// ** The only restrictions on the join type name are: +// ** +// ** * "INNER" cannot appear together with "OUTER", "LEFT", "RIGHT", +// ** or "FULL". +// ** +// ** * "CROSS" cannot appear together with "OUTER", "LEFT", "RIGHT, +// ** or "FULL". +// ** +// ** * If "OUTER" is present then there must also be one of +// ** "LEFT", "RIGHT", or "FULL" +// */ +func _sqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var apAll [3]uintptr + var i, j, jointype int32 + var p, zSp1, zSp2 uintptr + _, _, _, _, _, _, _ = apAll, i, j, jointype, p, zSp1, zSp2 + jointype = 0 + apAll[0] = pA + apAll[int32(1)] = pB + apAll[int32(2)] = pC + i = 0 + for { + if !(i < int32(3) && apAll[i] != 0) { + break + } + p = apAll[i] + j = 0 + for { + if !(j < libc.Int32FromUint64(libc.Uint64FromInt64(21)/libc.Uint64FromInt64(3))) { + break + } + if (*TToken)(unsafe.Pointer(p)).Fn == uint32(_aKeyword[j].FnChar) && Xsqlite3_strnicmp(tls, (*TToken)(unsafe.Pointer(p)).Fz, uintptr(unsafe.Pointer(&_zKeyText))+uintptr(_aKeyword[j].Fi), libc.Int32FromUint32((*TToken)(unsafe.Pointer(p)).Fn)) == 0 { + jointype = jointype | libc.Int32FromUint8(_aKeyword[j].Fcode) + break + } + goto _2 + _2: + ; + j = j + 1 + } + if j >= libc.Int32FromUint64(libc.Uint64FromInt64(21)/libc.Uint64FromInt64(3)) { + jointype = jointype | int32(JT_ERROR) + break + } + goto _1 + _1: + ; + i = i + 1 + } + if jointype&(libc.Int32FromInt32(JT_INNER)|libc.Int32FromInt32(JT_OUTER)) == libc.Int32FromInt32(JT_INNER)|libc.Int32FromInt32(JT_OUTER) || jointype&int32(JT_ERROR) != 0 || jointype&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_RIGHT)) == int32(JT_OUTER) { + zSp1 = __ccgo_ts + 11885 + zSp2 = __ccgo_ts + 11885 + if pB == uintptr(0) { + zSp1 = zSp1 + 1 + } + if pC == uintptr(0) { + zSp2 = zSp2 + 1 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20677, libc.VaList(bp+8, pA, zSp1, pB, zSp2, pC)) + jointype = int32(JT_INNER) + } + return jointype +} + +// C documentation +// +// /* +// ** Open a journal file. +// ** +// ** The behaviour of the journal file depends on the value of parameter +// ** nSpill. If nSpill is 0, then the journal file is always create and +// ** accessed using the underlying VFS. If nSpill is less than zero, then +// ** all content is always stored in main-memory. Finally, if nSpill is a +// ** positive value, then the journal file is initially created in-memory +// ** but may be flushed to disk later on. In this case the journal file is +// ** flushed to disk either when it grows larger than nSpill bytes in size, +// ** or when sqlite3JournalCreate() is called. +// */ +func _sqlite3JournalOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pJfd uintptr, flags int32, nSpill int32) (r int32) { + var p uintptr + _ = p + p = pJfd + /* Zero the file-handle object. If nSpill was passed zero, initialize + ** it using the sqlite3OsOpen() function of the underlying VFS. In this + ** case none of the code in this module is executed as a result of calls + ** made on the journal file-handle. */ + libc.X__builtin___memset_chk(tls, p, 0, uint64(80), ^t__predefined_size_t(0)) + if nSpill == 0 { + return _sqlite3OsOpen(tls, pVfs, zName, pJfd, flags, uintptr(0)) + } + if nSpill > 0 { + (*TMemJournal)(unsafe.Pointer(p)).FnChunkSize = nSpill + } else { + (*TMemJournal)(unsafe.Pointer(p)).FnChunkSize = libc.Int32FromUint64(libc.Uint64FromInt32(libc.Int32FromInt32(8)+libc.Int32FromInt32(MEMJOURNAL_DFLT_FILECHUNKSIZE)) - libc.Uint64FromInt64(16)) + } + (*Tsqlite3_file)(unsafe.Pointer(pJfd)).FpMethods = uintptr(unsafe.Pointer(&_MemJournalMethods)) + (*TMemJournal)(unsafe.Pointer(p)).FnSpill = nSpill + (*TMemJournal)(unsafe.Pointer(p)).Fflags = flags + (*TMemJournal)(unsafe.Pointer(p)).FzJournal = zName + (*TMemJournal)(unsafe.Pointer(p)).FpVfs = pVfs + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Allocate a KeyInfo object sufficient for an index of N key columns and +// ** X extra columns. +// */ +func _sqlite3KeyInfoAlloc(tls *libc.TLS, db uintptr, N int32, X int32) (r uintptr) { + var nExtra int32 + var p uintptr + _, _ = nExtra, p + nExtra = libc.Int32FromUint64(libc.Uint64FromInt32(N+X) * (libc.Uint64FromInt64(8) + libc.Uint64FromInt32(1))) + if N+X > int32(0xffff) { + return _sqlite3OomFault(tls, db) + } + p = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(0))*libc.Uint64FromInt64(8)+libc.Uint64FromInt32(nExtra))) + if p != 0 { + (*TKeyInfo)(unsafe.Pointer(p)).FaSortFlags = p + 32 + uintptr(N+X)*8 + (*TKeyInfo)(unsafe.Pointer(p)).FnKeyField = libc.Uint16FromInt32(N) + (*TKeyInfo)(unsafe.Pointer(p)).FnAllField = libc.Uint16FromInt32(N + X) + (*TKeyInfo)(unsafe.Pointer(p)).Fenc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + (*TKeyInfo)(unsafe.Pointer(p)).Fdb = db + (*TKeyInfo)(unsafe.Pointer(p)).FnRef = uint32(1) + libc.X__builtin___memset_chk(tls, p+32, 0, libc.Uint64FromInt32(nExtra), ^t__predefined_size_t(0)) + } else { + return _sqlite3OomFault(tls, db) + } + return p +} + +// C documentation +// +// /* +// ** Attempt to load an SQLite extension library contained in the file +// ** zFile. The entry point is zProc. zProc may be 0 in which case a +// ** default entry point name (sqlite3_extension_init) is used. Use +// ** of the default name is recommended. +// ** +// ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. +// ** +// ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with +// ** error message text. The calling function should free this memory +// ** by calling sqlite3DbFree(db, ). +// */ +func _sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aHandle, handle, pVfs, zAltEntry, zAltFile, zEntry, v1 uintptr + var c, cnt, iEntry, iFile, ii, ncFile, rc, v3, v8 int32 + var nMsg Tu64 + var xInit Tsqlite3_loadext_entry + var v4 bool + var _ /* zErrmsg at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aHandle, c, cnt, handle, iEntry, iFile, ii, nMsg, ncFile, pVfs, rc, xInit, zAltEntry, zAltFile, zEntry, v1, v3, v4, v8 + pVfs = (*Tsqlite3)(unsafe.Pointer(db)).FpVfs + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zAltEntry = uintptr(0) + nMsg = uint64(libc.Xstrlen(tls, zFile)) + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + /* Ticket #1863. To avoid a creating security problems for older + ** applications that relink against newer versions of SQLite, the + ** ability to run load_extension is turned off by default. One + ** must call either sqlite3_enable_load_extension(db) or + ** sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0) + ** to turn on extension loading. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LoadExtension) == uint64(0) { + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+14015, 0) + } + return int32(SQLITE_ERROR) + } + if zProc != 0 { + v1 = zProc + } else { + v1 = __ccgo_ts + 17934 + } + zEntry = v1 + /* tag-20210611-1. Some dlopen() implementations will segfault if given + ** an oversize filename. Most filesystems have a pathname limit of 4K, + ** so limit the extension filename length to about twice that. + ** https://sqlite.org/forum/forumpost/08a0d6d9bf + ** + ** Later (2023-03-25): Save an extra 6 bytes for the filename suffix. + ** See https://sqlite.org/forum/forumpost/24083b579d. + */ + if nMsg > uint64(FILENAME_MAX) { + goto extension_not_found + } + /* Do not allow sqlite3_load_extension() to link to a copy of the + ** running application, by passing in an empty filename. */ + if nMsg == uint64(0) { + goto extension_not_found + } + handle = _sqlite3OsDlOpen(tls, pVfs, zFile) + ii = 0 + for { + if !(ii < libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(8)) && handle == uintptr(0)) { + break + } + zAltFile = Xsqlite3_mprintf(tls, __ccgo_ts+13976, libc.VaList(bp+16, zFile, _azEndings[ii])) + if zAltFile == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if nMsg+uint64(libc.Xstrlen(tls, _azEndings[ii]))+uint64(1) <= uint64(FILENAME_MAX) { + handle = _sqlite3OsDlOpen(tls, pVfs, zAltFile) + } + Xsqlite3_free(tls, zAltFile) + goto _2 + _2: + ; + ii = ii + 1 + } + if handle == uintptr(0) { + goto extension_not_found + } + xInit = _sqlite3OsDlSym(tls, pVfs, handle, zEntry) + /* If no entry point was specified and the default legacy + ** entry point name "sqlite3_extension_init" was not found, then + ** construct an entry point name "sqlite3_X_init" where the X is + ** replaced by the lowercase value of every ASCII alphabetic + ** character in the filename after the last "/" up to the first ".", + ** and skipping the first three characters if they are "lib". + ** Examples: + ** + ** /usr/local/lib/libExample5.4.3.so ==> sqlite3_example_init + ** C:/lib/mathfuncs.dll ==> sqlite3_mathfuncs_init + ** + ** If that still finds no entry point, repeat a second time but this + ** time include both alphabetic and numeric characters up to the first + ** ".". Example: + ** + ** /usr/local/lib/libExample5.4.3.so ==> sqlite3_example5_init + */ + if xInit == uintptr(0) && zProc == uintptr(0) { + ncFile = _sqlite3Strlen30(tls, zFile) + cnt = 0 + zAltEntry = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(ncFile+int32(30))) + if zAltEntry == uintptr(0) { + _sqlite3OsDlClose(tls, pVfs, handle) + return int32(SQLITE_NOMEM) + } + for { + libc.X__builtin___memcpy_chk(tls, zAltEntry, __ccgo_ts+17957, uint64(8), ^t__predefined_size_t(0)) + iFile = ncFile - int32(1) + for { + if !(iFile >= 0 && !(int32(**(**int8)(__ccgo_up(zFile + uintptr(iFile)))) == libc.Int32FromUint8('/'))) { + break + } + goto _6 + _6: + ; + iFile = iFile - 1 + } + iFile = iFile + 1 + if Xsqlite3_strnicmp(tls, zFile+uintptr(iFile), __ccgo_ts+17966, int32(3)) == 0 { + iFile = iFile + int32(3) + } + iEntry = int32(8) + for { + v3 = int32(**(**int8)(__ccgo_up(zFile + uintptr(iFile)))) + c = v3 + if !(v3 != 0 && c != int32('.')) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt32(c)])&int32(0x02) != 0 || cnt != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt32(c)])&int32(0x04) != 0 { + v8 = iEntry + iEntry = iEntry + 1 + **(**int8)(__ccgo_up(zAltEntry + uintptr(v8))) = libc.Int8FromUint8(_sqlite3UpperToLower[libc.Uint32FromInt32(c)]) + } + goto _7 + _7: + ; + iFile = iFile + 1 + } + libc.X__builtin___memcpy_chk(tls, zAltEntry+uintptr(iEntry), __ccgo_ts+17970, uint64(6), ^t__predefined_size_t(0)) + zEntry = zAltEntry + xInit = _sqlite3OsDlSym(tls, pVfs, handle, zEntry) + goto _5 + _5: + ; + if v4 = xInit == uintptr(0); v4 { + cnt = cnt + 1 + v3 = cnt + } + if !(v4 && v3 < int32(2)) { + break + } + } + } + if xInit == uintptr(0) { + if pzErrMsg != 0 { + nMsg = nMsg + uint64(libc.Xstrlen(tls, zEntry)+uint64(300)) + v1 = Xsqlite3_malloc64(tls, nMsg) + **(**uintptr)(__ccgo_up(bp)) = v1 + **(**uintptr)(__ccgo_up(pzErrMsg)) = v1 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + /* zErrmsg would be NULL if not so */ + Xsqlite3_snprintf(tls, libc.Int32FromUint64(nMsg), **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+17976, libc.VaList(bp+16, zEntry, zFile)) + _sqlite3OsDlError(tls, pVfs, libc.Int32FromUint64(nMsg-uint64(1)), **(**uintptr)(__ccgo_up(bp))) + } + } + _sqlite3OsDlClose(tls, pVfs, handle) + Xsqlite3_free(tls, zAltEntry) + return int32(SQLITE_ERROR) + } + Xsqlite3_free(tls, zAltEntry) + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xInit})))(tls, db, bp, uintptr(unsafe.Pointer(&_sqlite3Apis))) + if rc != 0 { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(1)<aExtension array. */ + aHandle = _sqlite3DbMallocZero(tls, db, uint64(uint64(8)*libc.Uint64FromInt32((*Tsqlite3)(unsafe.Pointer(db)).FnExtension+libc.Int32FromInt32(1)))) + if aHandle == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FnExtension > 0 { + libc.X__builtin___memcpy_chk(tls, aHandle, (*Tsqlite3)(unsafe.Pointer(db)).FaExtension, uint64(8)*libc.Uint64FromInt32((*Tsqlite3)(unsafe.Pointer(db)).FnExtension), ^t__predefined_size_t(0)) + } + _sqlite3DbFree(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaExtension) + (*Tsqlite3)(unsafe.Pointer(db)).FaExtension = aHandle + v1 = db + 236 + v3 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaExtension + uintptr(v3)*8)) = handle + return SQLITE_OK + goto extension_not_found +extension_not_found: + ; + if pzErrMsg != 0 { + nMsg = nMsg + uint64(300) + v1 = Xsqlite3_malloc64(tls, nMsg) + **(**uintptr)(__ccgo_up(bp)) = v1 + **(**uintptr)(__ccgo_up(pzErrMsg)) = v1 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + /* zErrmsg would be NULL if not so */ + Xsqlite3_snprintf(tls, libc.Int32FromUint64(nMsg), **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+18051, libc.VaList(bp+16, int32(FILENAME_MAX), zFile)) + _sqlite3OsDlError(tls, pVfs, libc.Int32FromUint64(nMsg-uint64(1)), **(**uintptr)(__ccgo_up(bp))) + } + } + return int32(SQLITE_ERROR) +} + +// C documentation +// +// /* +// ** Locate the in-memory structure that describes a particular database +// ** table given the name of that table and (optionally) the name of the +// ** database containing the table. Return NULL if not found. Also leave an +// ** error message in pParse->zErrMsg. +// ** +// ** The difference between this routine and sqlite3FindTable() is that this +// ** routine leaves an error message in pParse->zErrMsg where +// ** sqlite3FindTable() does not. +// */ +func _sqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags Tu32, zName uintptr, zDbase uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pMod, zMsg, v1 uintptr + _, _, _, _, _ = db, p, pMod, zMsg, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_SchemaKnownOk) == uint32(0) && SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + return uintptr(0) + } + p = _sqlite3FindTable(tls, db, zName, zDbase) + if p == uintptr(0) { + /* If zName is the not the name of a table in the schema created using + ** CREATE, then check to see if it is the name of an virtual table that + ** can be an eponymous virtual table. */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_NO_VTAB) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { + pMod = _sqlite3HashFind(tls, db+576, zName) + if pMod == uintptr(0) && Xsqlite3_strnicmp(tls, zName, __ccgo_ts+14030, int32(7)) == 0 { + pMod = _sqlite3PragmaVtabRegister(tls, db, zName) + } + if pMod == uintptr(0) && Xsqlite3_strnicmp(tls, zName, __ccgo_ts+14038, int32(4)) == 0 { + pMod = _sqlite3JsonVtabRegister(tls, db, zName) + } + if pMod != 0 && _sqlite3VtabEponymousTableInit(tls, pParse, pMod) != 0 { + return (*TModule)(unsafe.Pointer(pMod)).FpEpoTab + } + } + if flags&uint32(LOCATE_NOERR) != 0 { + return uintptr(0) + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == int32(TABTYP_VTAB) && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_NO_VTAB) != 0 { + p = uintptr(0) + } + } + if p == uintptr(0) { + if flags&uint32(LOCATE_VIEW) != 0 { + v1 = __ccgo_ts + 14043 + } else { + v1 = __ccgo_ts + 14056 + } + zMsg = v1 + if zDbase != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7364, libc.VaList(bp+8, zMsg, zDbase, zName)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7435, libc.VaList(bp+8, zMsg, zName)) + } + } else { + } + return p +} + +// C documentation +// +// /* +// ** Convert a double into a LogEst +// ** In other words, compute an approximation for 10*log2(x). +// */ +func _sqlite3LogEstFromDouble(tls *libc.TLS, _x float64) (r TLogEst) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*float64)(unsafe.Pointer(bp)) = _x + var e TLogEst + var _ /* a at bp+8 */ Tu64 + _ = e + if **(**float64)(__ccgo_up(bp)) <= libc.Float64FromInt32(1) { + return 0 + } + if **(**float64)(__ccgo_up(bp)) <= libc.Float64FromInt32(2000000000) { + return _sqlite3LogEst(tls, uint64(**(**float64)(__ccgo_up(bp)))) + } + libc.X__builtin___memcpy_chk(tls, bp+8, bp, uint64(8), ^t__predefined_size_t(0)) + e = libc.Int16FromUint64(**(**Tu64)(__ccgo_up(bp + 8))>>libc.Int32FromInt32(52) - uint64(1022)) + return int16(int32(e) * int32(10)) +} + +// C documentation +// +// /* +// ** Deinitialize the memory allocation subsystem. +// */ +func _sqlite3MallocEnd(tls *libc.TLS) { + if _sqlite3Config.Fm.FxShutdown != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxShutdown})))(tls, _sqlite3Config.Fm.FpAppData) + } + libc.X__builtin___memset_chk(tls, uintptr(unsafe.Pointer(&_mem0)), 0, uint64(32), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Initialize the memory allocation subsystem. +// */ +func _sqlite3MallocInit(tls *libc.TLS) (r int32) { + var rc int32 + _ = rc + if _sqlite3Config.Fm.FxMalloc == uintptr(0) { + _sqlite3MemSetDefault(tls) + } + _mem0.Fmutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MEM)) + if _sqlite3Config.FpPage == uintptr(0) || _sqlite3Config.FszPage < int32(512) || _sqlite3Config.FnPage <= 0 { + _sqlite3Config.FpPage = uintptr(0) + _sqlite3Config.FszPage = 0 + } + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxInit})))(tls, _sqlite3Config.Fm.FpAppData) + if rc != SQLITE_OK { + libc.X__builtin___memset_chk(tls, uintptr(unsafe.Pointer(&_mem0)), 0, uint64(32), ^t__predefined_size_t(0)) + } + return rc +} + +// C documentation +// +// /* +// ** Allocate and zero memory. +// */ +func _sqlite3MallocZero(tls *libc.TLS, n Tu64) (r uintptr) { + var p uintptr + _ = p + p = _sqlite3Malloc(tls, n) + if p != 0 { + libc.X__builtin___memset_chk(tls, p, 0, n, ^t__predefined_size_t(0)) + } + return p +} + +func _sqlite3MisuseError(tls *libc.TLS, lineno int32) (r int32) { + return _sqlite3ReportError(tls, int32(SQLITE_MISUSE), lineno, __ccgo_ts+26638) +} + +// C documentation +// +// /* +// ** Run the parser and code generator recursively in order to generate +// ** code for the SQL statement given onto the end of the pParse context +// ** currently under construction. Notes: +// ** +// ** * The final OP_Halt is not appended and other initialization +// ** and finalization steps are omitted because those are handling by the +// ** outermost parser. +// ** +// ** * Built-in SQL functions always take precedence over application-defined +// ** SQL functions. In other words, it is not possible to override a +// ** built-in function. +// */ +func _sqlite3NestedParse(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var ap Tva_list + var db, zSql uintptr + var savedDbFlags Tu32 + var _ /* saveBuf at bp+0 */ [136]int8 + _, _, _, _ = ap, db, savedDbFlags, zSql + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + savedDbFlags = (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + if (*TParse)(unsafe.Pointer(pParse)).FeParseMode != 0 { + return + } + /* Nesting should only be of limited depth */ + ap = va + zSql = _sqlite3VMPrintf(tls, db, zFormat, ap) + _ = ap + if zSql == uintptr(0) { + /* This can result either from an OOM or because the formatted string + ** exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set + ** an error */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_TOOBIG) + } + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + return + } + (*TParse)(unsafe.Pointer(pParse)).Fnested = (*TParse)(unsafe.Pointer(pParse)).Fnested + 1 + libc.X__builtin___memcpy_chk(tls, bp, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), 0, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280), ^t__predefined_size_t(0)) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_PreferBuiltin) + _sqlite3RunParser(tls, pParse, zSql) + (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags = savedDbFlags + _sqlite3DbFree(tls, db, zSql) + libc.X__builtin___memcpy_chk(tls, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), bp, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280), ^t__predefined_size_t(0)) + (*TParse)(unsafe.Pointer(pParse)).Fnested = (*TParse)(unsafe.Pointer(pParse)).Fnested - 1 +} + +// C documentation +// +// /* +// ** Cause a function to throw an error if it was call from OP_PureFunc +// ** rather than OP_Function. +// ** +// ** OP_PureFunc means that the function must be deterministic, and should +// ** throw an error if it is given inputs that would make it non-deterministic. +// ** This routine is invoked by date/time functions that use non-deterministic +// ** features such as 'now'. +// */ +func _sqlite3NotPureFunc(tls *libc.TLS, pCtx uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pOp, zContext, zMsg uintptr + _, _, _ = pOp, zContext, zMsg + if (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe == uintptr(0) { + return int32(1) + } + pOp = (*TVdbe)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe)).FaOp + uintptr((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FiOp)*24 + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_PureFunc) { + if libc.Int32FromUint16((*TVdbeOp)(unsafe.Pointer(pOp)).Fp5)&int32(NC_IsCheck) != 0 { + zContext = __ccgo_ts + 5766 + } else { + if libc.Int32FromUint16((*TVdbeOp)(unsafe.Pointer(pOp)).Fp5)&int32(NC_GenCol) != 0 { + zContext = __ccgo_ts + 5785 + } else { + zContext = __ccgo_ts + 5804 + } + } + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+5813, libc.VaList(bp+8, (*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpFunc)).FzName, zContext)) + Xsqlite3_result_error(tls, pCtx, zMsg, -int32(1)) + Xsqlite3_free(tls, zMsg) + return 0 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Open the sqlite_schema table stored in database number iDb for +// ** writing. The table is opened using cursor 0. +// */ +func _sqlite3OpenSchemaTable(tls *libc.TLS, p uintptr, iDb int32) { + var v uintptr + _ = v + v = _sqlite3GetVdbe(tls, p) + _sqlite3TableLock(tls, p, iDb, uint32(SCHEMA_ROOT), uint8(1), __ccgo_ts+6628) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_OpenWrite), 0, int32(SCHEMA_ROOT), iDb, int32(5)) + if (*TParse)(unsafe.Pointer(p)).FnTab == 0 { + (*TParse)(unsafe.Pointer(p)).FnTab = int32(1) + } +} + +// C documentation +// +// /* +// ** Make sure the TEMP database is open and available for use. Return +// ** the number of errors. Leave any error messages in the pParse structure. +// */ +func _sqlite3OpenTempDatabase(tls *libc.TLS, pParse uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db uintptr + var rc int32 + var _ /* pBt at bp+0 */ uintptr + _, _ = db, rc + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt == uintptr(0) && !((*TParse)(unsafe.Pointer(pParse)).Fexplain != 0) { + rc = _sqlite3BtreeOpen(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, bp, 0, _flags) + if rc != SQLITE_OK { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16477, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + return int32(1) + } + (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt = **(**uintptr)(__ccgo_up(bp)) + if int32(SQLITE_NOMEM) == _sqlite3BtreeSetPageSize(tls, **(**uintptr)(__ccgo_up(bp)), (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { + _sqlite3OomFault(tls, db) + return int32(1) + } + } + return 0 +} + +func _sqlite3OsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) (r int32) { + if _sqlite3Config.FiPrngSeed != 0 { + libc.X__builtin___memset_chk(tls, zBufOut, 0, libc.Uint64FromInt32(nByte), ^t__predefined_size_t(0)) + if nByte > libc.Int32FromInt64(4) { + nByte = int32(4) + } + libc.X__builtin___memcpy_chk(tls, zBufOut, uintptr(unsafe.Pointer(&_sqlite3Config))+432, libc.Uint64FromInt32(nByte), ^t__predefined_size_t(0)) + return SQLITE_OK + } else { + return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxRandomness})))(tls, pVfs, nByte, zBufOut) + } + return r +} + +// C documentation +// +// /* +// ** Allocate an Expr node which joins as many as two subtrees. +// ** +// ** One or both of the subtrees can be NULL. Return a pointer to the new +// ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed, +// ** free the subtrees and return NULL. +// */ +func _sqlite3PExpr(tls *libc.TLS, pParse uintptr, op int32, pLeft uintptr, pRight uintptr) (r uintptr) { + var p uintptr + _ = p + p = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(72)) + if p != 0 { + libc.X__builtin___memset_chk(tls, p, 0, uint64(72), ^t__predefined_size_t(0)) + (*TExpr)(unsafe.Pointer(p)).Fop = libc.Uint8FromInt32(op & int32(0xff)) + (*TExpr)(unsafe.Pointer(p)).FiAgg = int16(-int32(1)) + _sqlite3ExprAttachSubtrees(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p, pLeft, pRight) + _sqlite3ExprCheckHeight(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FnHeight) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pLeft) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pRight) + } + return p +} + +// C documentation +// +// /* +// ** This function is called when the user invokes "PRAGMA wal_checkpoint", +// ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint() +// ** or wal_blocking_checkpoint() API functions. +// ** +// ** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART. +// */ +func _sqlite3PagerCheckpoint(tls *libc.TLS, pPager uintptr, db uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) (r int32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + rc = SQLITE_OK + if (*TPager)(unsafe.Pointer(pPager)).FpWal == uintptr(0) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_WAL) { + /* This only happens when a database file is zero bytes in size opened and + ** then "PRAGMA journal_mode=WAL" is run and then sqlite3_wal_checkpoint() + ** is invoked without any intervening transactions. We need to start + ** a transaction to initialize pWal. The PRAGMA table_list statement is + ** used for this since it starts transactions on every database file, + ** including all ATTACHed databases. This seems expensive for a single + ** sqlite3_wal_checkpoint() call, but it happens very rarely. + ** https://sqlite.org/forum/forumpost/fd0f19d229156939 + */ + Xsqlite3_exec(tls, db, __ccgo_ts+4602, uintptr(0), uintptr(0), uintptr(0)) + } + if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + if eMode <= SQLITE_CHECKPOINT_PASSIVE { + v1 = uintptr(0) + } else { + v1 = (*TPager)(unsafe.Pointer(pPager)).FxBusyHandler + } + rc = _sqlite3WalCheckpoint(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, db, eMode, v1, (*TPager)(unsafe.Pointer(pPager)).FpBusyHandlerArg, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FwalSyncFlags), int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace, pnLog, pnCkpt) + } + return rc +} + +// C documentation +// +// /* +// ** Allocate and initialize a new Pager object and put a pointer to it +// ** in *ppPager. The pager should eventually be freed by passing it +// ** to sqlite3PagerClose(). +// ** +// ** The zFilename argument is the path to the database file to open. +// ** If zFilename is NULL then a randomly-named temporary file is created +// ** and used as the file to be cached. Temporary files are be deleted +// ** automatically when they are closed. If zFilename is ":memory:" then +// ** all information is held in cache. It is never written to disk. +// ** This can be used to implement an in-memory database. +// ** +// ** The nExtra parameter specifies the number of bytes of space allocated +// ** along with each page reference. This space is available to the user +// ** via the sqlite3PagerGetExtra() API. When a new page is allocated, the +// ** first 8 bytes of this space are zeroed but the remainder is uninitialized. +// ** (The extra space is used by btree as the MemPage object.) +// ** +// ** The flags argument is used to specify properties that affect the +// ** operation of the pager. It should be passed some bitwise combination +// ** of the PAGER_* flags. +// ** +// ** The vfsFlags parameter is a bitmask to pass to the flags parameter +// ** of the xOpen() method of the supplied VFS when opening files. +// ** +// ** If the pager object is allocated and the specified file opened +// ** successfully, SQLITE_OK is returned and *ppPager set to point to +// ** the new pager object. If an error occurs, *ppPager is set to NULL +// ** and error code returned. This function may return SQLITE_NOMEM +// ** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or +// ** various SQLITE_IO_XXX errors. +// */ +func _sqlite3PagerOpen(tls *libc.TLS, pVfs uintptr, ppPager uintptr, zFilename uintptr, nExtra int32, flags int32, vfsFlags int32, __ccgo_fp_xReinit uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDc, journalFileSize, memDb, memJM, nPathname, nUriByte, pcacheSize, rc, readOnly, tempFile, useJournal, v4 int32 + var pPtr, z, zPathname, zUri, v1 uintptr + var _ /* fout at bp+12 */ int32 + var _ /* pPager at bp+0 */ uintptr + var _ /* szPageDflt at bp+8 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iDc, journalFileSize, memDb, memJM, nPathname, nUriByte, pPtr, pcacheSize, rc, readOnly, tempFile, useJournal, z, zPathname, zUri, v1, v4 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Pager object to allocate and return */ + rc = SQLITE_OK /* Return code */ + tempFile = 0 /* True for temp files (incl. in-memory files) */ + memDb = 0 /* True if this is an in-memory file */ + memJM = 0 /* Memory journal mode */ + readOnly = 0 /* Bytes to allocate for each journal fd */ + zPathname = uintptr(0) /* Full path to database file */ + nPathname = 0 /* Number of bytes in zPathname */ + useJournal = libc.BoolInt32(flags&int32(PAGER_OMIT_JOURNAL) == 0) /* False to omit journal */ + pcacheSize = _sqlite3PcacheSize(tls) /* Bytes to allocate for PCache */ + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(SQLITE_DEFAULT_PAGE_SIZE) /* Default page size */ + zUri = uintptr(0) /* URI args to copy */ + nUriByte = int32(1) /* Number of bytes of URI args at *zUri */ + /* Figure out how much space is required for each journal file-handle + ** (there are two of them, the main journal and the sub-journal). */ + journalFileSize = (_sqlite3JournalSize(tls, pVfs) + int32(7)) & ^libc.Int32FromInt32(7) + /* Set the output variable to NULL in case an error occurs. */ + **(**uintptr)(__ccgo_up(ppPager)) = uintptr(0) + if flags&int32(PAGER_MEMORY) != 0 { + memDb = int32(1) + if zFilename != 0 && **(**int8)(__ccgo_up(zFilename)) != 0 { + zPathname = _sqlite3DbStrDup(tls, uintptr(0), zFilename) + if zPathname == uintptr(0) { + return int32(SQLITE_NOMEM) + } + nPathname = _sqlite3Strlen30(tls, zPathname) + zFilename = uintptr(0) + } + } + /* Compute and store the full pathname in an allocated buffer pointed + ** to by zPathname, length nPathname. Or, if this is a temporary file, + ** leave both nPathname and zPathname set to 0. + */ + if zFilename != 0 && **(**int8)(__ccgo_up(zFilename)) != 0 { + nPathname = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname + int32(1) + zPathname = _sqlite3DbMallocRaw(tls, uintptr(0), libc.Uint64FromInt64(int64(2)*int64(nPathname))) + if zPathname == uintptr(0) { + return int32(SQLITE_NOMEM) + } + **(**int8)(__ccgo_up(zPathname)) = 0 /* Make sure initialized even if FullPathname() fails */ + rc = _sqlite3OsFullPathname(tls, pVfs, zFilename, nPathname, zPathname) + if rc != SQLITE_OK { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(2)< (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname { + /* This branch is taken when the journal path required by + ** the database being opened will be more than pVfs->mxPathname + ** bytes in length. This means the database cannot be opened, + ** as it will not be possible to open the journal file or even + ** check for a hot-journal before reading. + */ + rc = _sqlite3CantopenError(tls, int32(64423)) + } + if rc != SQLITE_OK { + _sqlite3DbFree(tls, uintptr(0), zPathname) + return rc + } + } + /* Allocate memory for the Pager structure, PCache object, the + ** three file descriptors, the database file name and the journal + ** file name. The layout in memory is as follows: + ** + ** Pager object (sizeof(Pager) bytes) + ** PCache object (sqlite3PcacheSize() bytes) + ** Database file handle (pVfs->szOsFile bytes) + ** Sub-journal file handle (journalFileSize bytes) + ** Main journal file handle (journalFileSize bytes) + ** Ptr back to the Pager (sizeof(Pager*) bytes) + ** \0\0\0\0 database prefix (4 bytes) + ** Database file name (nPathname+1 bytes) + ** URI query parameters (nUriByte bytes) + ** Journal filename (nPathname+8+1 bytes) + ** WAL filename (nPathname+4+1 bytes) + ** \0\0\0 terminator (3 bytes) + ** + ** Some 3rd-party software, over which we have no control, depends on + ** the specific order of the filenames and the \0 separators between them + ** so that it can (for example) find the database filename given the WAL + ** filename without using the sqlite3_filename_database() API. This is a + ** misuse of SQLite and a bug in the 3rd-party software, but the 3rd-party + ** software is in widespread use, so we try to avoid changing the filename + ** order and formatting if possible. In particular, the details of the + ** filename format expected by 3rd-party software should be as follows: + ** + ** - Main Database Path + ** - \0 + ** - Multiple URI components consisting of: + ** - Key + ** - \0 + ** - Value + ** - \0 + ** - \0 + ** - Journal Path + ** - \0 + ** - WAL Path (zWALName) + ** - \0 + ** + ** The sqlite3_create_filename() interface and the databaseFilename() utility + ** that is used by sqlite3_filename_database() and kin also depend on the + ** specific formatting and order of the various filenames, so if the format + ** changes here, be sure to change it there as well. + */ + pPtr = _sqlite3MallocZero(tls, uint64((libc.Uint64FromInt64(312)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32((pcacheSize+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7))+libc.Uint64FromInt32(((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)))+libc.Uint64FromInt32(journalFileSize)*uint64(2)+uint64(__SIZEOF_POINTER__)+uint64(4)+libc.Uint64FromInt32(nPathname)+uint64(1)+libc.Uint64FromInt32(nUriByte)+libc.Uint64FromInt32(nPathname)+uint64(8)+uint64(1)+libc.Uint64FromInt32(nPathname)+uint64(4)+uint64(1)+uint64(3)) + if !(pPtr != 0) { + _sqlite3DbFree(tls, uintptr(0), zPathname) + return int32(SQLITE_NOMEM) + } + **(**uintptr)(__ccgo_up(bp)) = pPtr + pPtr = pPtr + uintptr((libc.Uint64FromInt64(312)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpPCache = pPtr + pPtr = pPtr + uintptr((pcacheSize+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd = pPtr + pPtr = pPtr + uintptr(((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fsjfd = pPtr + pPtr = pPtr + uintptr(journalFileSize) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fjfd = pPtr + pPtr = pPtr + uintptr(journalFileSize) + libc.X__builtin___memcpy_chk(tls, pPtr, bp, uint64(__SIZEOF_POINTER__), ^t__predefined_size_t(0)) + pPtr = pPtr + uintptr(__SIZEOF_POINTER__) + /* Fill in the Pager.zFilename and pPager.zQueryParam fields */ + pPtr = pPtr + uintptr(4) /* Skip zero prefix */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename = pPtr + if nPathname > 0 { + libc.X__builtin___memcpy_chk(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname), ^t__predefined_size_t(0)) + pPtr = pPtr + uintptr(nPathname+int32(1)) + if zUri != 0 { + libc.X__builtin___memcpy_chk(tls, pPtr, zUri, libc.Uint64FromInt32(nUriByte), ^t__predefined_size_t(0)) + pPtr = pPtr + uintptr(nUriByte) + } else { + pPtr = pPtr + 1 + } + } + /* Fill in Pager.zJournal */ + if nPathname > 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzJournal = pPtr + libc.X__builtin___memcpy_chk(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname), ^t__predefined_size_t(0)) + pPtr = pPtr + uintptr(nPathname) + libc.X__builtin___memcpy_chk(tls, pPtr, __ccgo_ts+4571, uint64(8), ^t__predefined_size_t(0)) + pPtr = pPtr + uintptr(libc.Int32FromInt32(8)+libc.Int32FromInt32(1)) + } else { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzJournal = uintptr(0) + } + /* Fill in Pager.zWal */ + if nPathname > 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzWal = pPtr + libc.X__builtin___memcpy_chk(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname), ^t__predefined_size_t(0)) + pPtr = pPtr + uintptr(nPathname) + libc.X__builtin___memcpy_chk(tls, pPtr, __ccgo_ts+4580, uint64(4), ^t__predefined_size_t(0)) + pPtr = pPtr + uintptr(libc.Int32FromInt32(4)+libc.Int32FromInt32(1)) + } else { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzWal = uintptr(0) + } + _ = pPtr /* Suppress warning about unused pPtr value */ + if nPathname != 0 { + _sqlite3DbFree(tls, uintptr(0), zPathname) + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpVfs = pVfs + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FvfsFlags = libc.Uint32FromInt32(vfsFlags) + /* Open the pager file. + */ + if !(zFilename != 0 && **(**int8)(__ccgo_up(zFilename)) != 0) { + goto _2 + } + **(**int32)(__ccgo_up(bp + 12)) = 0 /* VFS flags returned by xOpen() */ + rc = _sqlite3OsOpen(tls, pVfs, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd, vfsFlags, bp+12) + v4 = libc.BoolInt32(**(**int32)(__ccgo_up(bp + 12))&libc.Int32FromInt32(SQLITE_OPEN_MEMORY) != libc.Int32FromInt32(0)) + memJM = v4 + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmemVfs = libc.Uint8FromInt32(v4) + readOnly = libc.BoolInt32(**(**int32)(__ccgo_up(bp + 12))&int32(SQLITE_OPEN_READONLY) != 0) + /* If the file was successfully opened for read/write access, + ** choose a default page size in case we have to create the + ** database file. The default page size is the maximum of: + ** + ** + SQLITE_DEFAULT_PAGE_SIZE, + ** + The value returned by sqlite3OsSectorSize() + ** + The largest page size that can be written atomically. + */ + if rc == SQLITE_OK { + iDc = _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd) + if !(readOnly != 0) { + _setSectorSize(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**Tu32)(__ccgo_up(bp + 8)) < (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize { + if (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize > uint32(SQLITE_MAX_DEFAULT_PAGE_SIZE) { + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(SQLITE_MAX_DEFAULT_PAGE_SIZE) + } else { + **(**Tu32)(__ccgo_up(bp + 8)) = (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize + } + } + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnoLock = libc.Uint8FromInt32(Xsqlite3_uri_boolean(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, __ccgo_ts+4585, 0)) + if iDc&int32(SQLITE_IOCAP_IMMUTABLE) != 0 || Xsqlite3_uri_boolean(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, __ccgo_ts+4592, 0) != 0 { + vfsFlags = vfsFlags | int32(SQLITE_OPEN_READONLY) + goto act_like_temp_file + } + } + goto _3 +_2: + ; + /* If a temporary file is requested, it is not opened immediately. + ** In this case we accept the default page size and delay actually + ** opening the file until the first call to OsWrite(). + ** + ** This branch is also run for an in-memory database. An in-memory + ** database is the same as a temp-file that is never written out to + ** disk and uses an in-memory rollback journal. + ** + ** This branch also runs for files marked as immutable. + */ + goto act_like_temp_file +act_like_temp_file: + ; + tempFile = int32(1) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FeState = uint8(PAGER_READER) /* Pretend we already have a lock */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FeLock = uint8(EXCLUSIVE_LOCK) /* Pretend we are in EXCLUSIVE mode */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnoLock = uint8(1) /* Do no locking */ + readOnly = vfsFlags & int32(SQLITE_OPEN_READONLY) +_3: + ; + /* The following call to PagerSetPagesize() serves to set the value of + ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer. + */ + if rc == SQLITE_OK { + rc = _sqlite3PagerSetPagesize(tls, **(**uintptr)(__ccgo_up(bp)), bp+8, -int32(1)) + } + /* Initialize the PCache object. */ + if rc == SQLITE_OK { + nExtra = (nExtra + int32(7)) & ^libc.Int32FromInt32(7) + if !(memDb != 0) { + v1 = __ccgo_fp(_pagerStress) + } else { + v1 = uintptr(0) + } + rc = _sqlite3PcacheOpen(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp + 8))), nExtra, libc.BoolInt32(!(memDb != 0)), v1, **(**uintptr)(__ccgo_up(bp)), (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpPCache) + } + /* If an error occurred above, free the Pager structure and close the file. + */ + if rc != SQLITE_OK { + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd) + _sqlite3PageFree(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpTmpSpace) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + return rc + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FuseJournal = libc.Uint8FromInt32(useJournal) + /* pPager->stmtOpen = 0; */ + /* pPager->stmtInUse = 0; */ + /* pPager->nRef = 0; */ + /* pPager->stmtSize = 0; */ + /* pPager->stmtJSize = 0; */ + /* pPager->nPage = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmxPgno = uint32(SQLITE_MAX_PAGE_COUNT) + /* pPager->state = PAGER_UNLOCK; */ + /* pPager->errMask = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FtempFile = libc.Uint8FromInt32(tempFile) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FexclusiveMode = libc.Uint8FromInt32(tempFile) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FchangeCountDone = (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FtempFile + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmemDb = libc.Uint8FromInt32(memDb) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FreadOnly = libc.Uint8FromInt32(readOnly) + _sqlite3PagerSetFlags(tls, **(**uintptr)(__ccgo_up(bp)), libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DEFAULT_SYNCHRONOUS)+libc.Int32FromInt32(1)|libc.Int32FromInt32(PAGER_CACHESPILL))) + /* pPager->pFirst = 0; */ + /* pPager->pFirstSynced = 0; */ + /* pPager->pLast = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExtra = libc.Uint16FromInt32(nExtra) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalSizeLimit = int64(-int32(1)) + _setSectorSize(tls, **(**uintptr)(__ccgo_up(bp))) + if !(useJournal != 0) { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalMode = uint8(PAGER_JOURNALMODE_OFF) + } else { + if memDb != 0 || memJM != 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalMode = uint8(PAGER_JOURNALMODE_MEMORY) + } + } + /* pPager->xBusyHandler = 0; */ + /* pPager->pBusyHandlerArg = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxReiniter = __ccgo_fp_xReinit + _setGetterMethod(tls, **(**uintptr)(__ccgo_up(bp))) + /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */ + /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */ + **(**uintptr)(__ccgo_up(ppPager)) = **(**uintptr)(__ccgo_up(bp)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Read the first N bytes from the beginning of the file into memory +// ** that pDest points to. +// ** +// ** If the pager was opened on a transient file (zFilename==""), or +// ** opened on a file less than N bytes in size, the output buffer is +// ** zeroed and SQLITE_OK returned. The rationale for this is that this +// ** function is used to read database headers, and a new transient or +// ** zero sized database has a header than consists entirely of zeroes. +// ** +// ** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered, +// ** the error code is returned to the caller and the contents of the +// ** output buffer undefined. +// */ +func _sqlite3PagerReadFileheader(tls *libc.TLS, pPager uintptr, N int32, pDest uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + libc.X__builtin___memset_chk(tls, pDest, 0, libc.Uint64FromInt32(N), ^t__predefined_size_t(0)) + /* This routine is only called by btree immediately after creating + ** the Pager object. There has not been an opportunity to transition + ** to WAL mode yet. + */ + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) { + rc = _sqlite3OsRead(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, pDest, N, 0) + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)< PAGER_OPEN && (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) { + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, bp) + } + if rc == SQLITE_OK { + /* 8 bytes of zeroed overrun space is sufficient so that the b-tree + * cell header parser will never run off the end of the allocation */ + pNew = _sqlite3PageMalloc(tls, libc.Int32FromUint32(pageSize+uint32(8))) + if !(pNew != 0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pNew+uintptr(pageSize), 0, uint64(8), ^t__predefined_size_t(0)) + } + } + if rc == SQLITE_OK { + _pager_reset(tls, pPager) + rc = _sqlite3PcacheSetPageSize(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, libc.Int32FromUint32(pageSize)) + } + if rc == SQLITE_OK { + _sqlite3PageFree(tls, (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace) + (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace = pNew + (*TPager)(unsafe.Pointer(pPager)).FdbSize = libc.Uint32FromInt64((**(**Ti64)(__ccgo_up(bp)) + libc.Int64FromUint32(pageSize) - libc.Int64FromInt32(1)) / libc.Int64FromUint32(pageSize)) + (*TPager)(unsafe.Pointer(pPager)).FpageSize = libc.Int64FromUint32(pageSize) + (*TPager)(unsafe.Pointer(pPager)).FlckPgno = libc.Uint32FromInt32(_sqlite3PendingByte)/pageSize + uint32(1) + } else { + _sqlite3PageFree(tls, pNew) + } + } + **(**Tu32)(__ccgo_up(pPageSize)) = libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) + if rc == SQLITE_OK { + if nReserve < 0 { + nReserve = int32((*TPager)(unsafe.Pointer(pPager)).FnReserve) + } + (*TPager)(unsafe.Pointer(pPager)).FnReserve = int16(nReserve) + _pagerFixMaplimit(tls, pPager) + } + return rc +} + +// C documentation +// +// /* +// ** This function is called to obtain a shared lock on the database file. +// ** It is illegal to call sqlite3PagerGet() until after this function +// ** has been successfully called. If a shared-lock is already held when +// ** this function is called, it is a no-op. +// ** +// ** The following operations are also performed by this function. +// ** +// ** 1) If the pager is currently in PAGER_OPEN state (no lock held +// ** on the database file), then an attempt is made to obtain a +// ** SHARED lock on the database file. Immediately after obtaining +// ** the SHARED lock, the file-system is checked for a hot-journal, +// ** which is played back if present. Following any hot-journal +// ** rollback, the contents of the cache are validated by checking +// ** the 'change-counter' field of the database file header and +// ** discarded if they are found to be invalid. +// ** +// ** 2) If the pager is running in exclusive-mode, and there are currently +// ** no outstanding references to any pages, and is in the error state, +// ** then an attempt is made to clear the error state by discarding +// ** the contents of the page cache and rolling back any open journal +// ** file. +// ** +// ** If everything is successful, SQLITE_OK is returned. If an IO error +// ** occurs while locking the database, checking for a hot-journal file or +// ** rolling back a journal file, the IO error code is returned. +// */ +func _sqlite3PagerSharedLock(tls *libc.TLS, pPager uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var f, rc int32 + var pVfs uintptr + var _ /* bExists at bp+4 */ int32 + var _ /* bHotJournal at bp+0 */ int32 + var _ /* dbFileVers at bp+12 */ [16]int8 + var _ /* fout at bp+8 */ int32 + _, _, _ = f, pVfs, rc + rc = SQLITE_OK /* Return code */ + /* This routine is only called from b-tree and only when there are no + ** outstanding pages. This implies that the pager state should either + ** be OPEN or READER. READER is only possible if the pager is or was in + ** exclusive access mode. */ + if !((*TPager)(unsafe.Pointer(pPager)).FpWal != libc.UintptrFromInt32(0)) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN { + **(**int32)(__ccgo_up(bp)) = int32(1) /* True if there exists a hot journal-file */ + rc = _pager_wait_on_lock(tls, pPager, int32(SHARED_LOCK)) + if rc != SQLITE_OK { + goto failed + } + /* If a journal file exists, and there is no RESERVED lock on the + ** database file, then it either needs to be played back or deleted. + */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) <= int32(SHARED_LOCK) { + rc = _hasHotJournal(tls, pPager, bp) + } + if rc != SQLITE_OK { + goto failed + } + if **(**int32)(__ccgo_up(bp)) != 0 { + if (*TPager)(unsafe.Pointer(pPager)).FreadOnly != 0 { + rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(3)<= int32(5) && libc.Xmemcmp(tls, zUri, __ccgo_ts+26440, uint64(5)) == 0 { /* Input character index */ + iOut = 0 /* Output character index */ + nByte = libc.Uint64FromInt32(nUri + int32(8)) /* Bytes of space to allocate */ + /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen + ** method that there may be extra parameters following the file-name. */ + flags = flags | uint32(SQLITE_OPEN_URI) + iIn = 0 + for { + if !(iIn < nUri) { + break + } + nByte = nByte + libc.BoolUint64(int32(**(**int8)(__ccgo_up(zUri + uintptr(iIn)))) == libc.Int32FromUint8('&')) + goto _1 + _1: + ; + iIn = iIn + 1 + } + zFile = Xsqlite3_malloc64(tls, nByte) + if !(zFile != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, zFile, 0, uint64(4), ^t__predefined_size_t(0)) /* 4-byte of 0x00 is the start of DB name marker */ + zFile = zFile + uintptr(4) + iIn = int32(5) + /* Discard the scheme and authority segments of the URI. */ + if int32(**(**int8)(__ccgo_up(zUri + 5))) == int32('/') && int32(**(**int8)(__ccgo_up(zUri + 6))) == int32('/') { + iIn = int32(7) + for **(**int8)(__ccgo_up(zUri + uintptr(iIn))) != 0 && int32(**(**int8)(__ccgo_up(zUri + uintptr(iIn)))) != int32('/') { + iIn = iIn + 1 + } + if iIn != int32(7) && (iIn != int32(16) || libc.Xmemcmp(tls, __ccgo_ts+26446, zUri+7, uint64(9)) != 0) { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26456, libc.VaList(bp+8, iIn-int32(7), zUri+7)) + rc = int32(SQLITE_ERROR) + goto parse_uri_out + } + } + /* Copy the filename and any query parameters into the zFile buffer. + ** Decode %HH escape codes along the way. + ** + ** Within this loop, variable eState may be set to 0, 1 or 2, depending + ** on the parsing context. As follows: + ** + ** 0: Parsing file-name. + ** 1: Parsing name section of a name=value query parameter. + ** 2: Parsing value section of a name=value query parameter. + */ + eState = 0 + for { + v2 = **(**int8)(__ccgo_up(zUri + uintptr(iIn))) + c = v2 + if !(int32(v2) != 0 && int32(c) != int32('#')) { + break + } + iIn = iIn + 1 + if int32(c) == int32('%') && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zUri + uintptr(iIn))))])&int32(0x08) != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zUri + uintptr(iIn+int32(1)))))])&int32(0x08) != 0 { + v3 = iIn + iIn = iIn + 1 + octet = libc.Int32FromUint8(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(zUri + uintptr(v3)))))) << int32(4) + v4 = iIn + iIn = iIn + 1 + octet = octet + libc.Int32FromUint8(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(zUri + uintptr(v4)))))) + if octet == 0 { + /* This branch is taken when "%00" appears within the URI. In this + ** case we ignore all text in the remainder of the path, name or + ** value currently being parsed. So ignore the current character + ** and skip to the next "?", "=" or "&", as appropriate. */ + for { + v2 = **(**int8)(__ccgo_up(zUri + uintptr(iIn))) + c = v2 + if !(int32(v2) != 0 && int32(c) != int32('#') && (eState != 0 || int32(c) != int32('?')) && (eState != int32(1) || int32(c) != int32('=') && int32(c) != int32('&')) && (eState != int32(2) || int32(c) != int32('&'))) { + break + } + iIn = iIn + 1 + } + continue + } + c = int8(octet) + } else { + if eState == int32(1) && (int32(c) == int32('&') || int32(c) == int32('=')) { + if int32(**(**int8)(__ccgo_up(zFile + uintptr(iOut-int32(1))))) == 0 { + /* An empty option name. Ignore this option altogether. */ + for **(**int8)(__ccgo_up(zUri + uintptr(iIn))) != 0 && int32(**(**int8)(__ccgo_up(zUri + uintptr(iIn)))) != int32('#') && int32(**(**int8)(__ccgo_up(zUri + uintptr(iIn-int32(1))))) != int32('&') { + iIn = iIn + 1 + } + continue + } + if int32(c) == int32('&') { + v3 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zFile + uintptr(v3))) = int8('\000') + } else { + eState = int32(2) + } + c = 0 + } else { + if eState == 0 && int32(c) == int32('?') || eState == int32(2) && int32(c) == int32('&') { + c = 0 + eState = int32(1) + } + } + } + v3 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zFile + uintptr(v3))) = c + } + if eState == int32(1) { + v3 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zFile + uintptr(v3))) = int8('\000') + } + libc.X__builtin___memset_chk(tls, zFile+uintptr(iOut), 0, uint64(4), ^t__predefined_size_t(0)) /* end-of-options + empty journal filenames */ + /* Check if there were any options specified that should be interpreted + ** here. Options that are interpreted here include "vfs" and those that + ** correspond to flags that may be passed to the sqlite3_open_v2() + ** method. */ + zOpt = zFile + uintptr(_sqlite3Strlen30(tls, zFile)+int32(1)) + for **(**int8)(__ccgo_up(zOpt)) != 0 { + nOpt = _sqlite3Strlen30(tls, zOpt) + zVal = zOpt + uintptr(nOpt+int32(1)) + nVal = _sqlite3Strlen30(tls, zVal) + if nOpt == int32(3) && libc.Xmemcmp(tls, __ccgo_ts+26484, zOpt, uint64(3)) == 0 { + zVfs = zVal + } else { + aMode = uintptr(0) + zModeType = uintptr(0) + mask = 0 + limit = 0 + if nOpt == int32(5) && libc.Xmemcmp(tls, __ccgo_ts+26488, zOpt, uint64(5)) == 0 { + mask = libc.Int32FromInt32(SQLITE_OPEN_SHAREDCACHE) | libc.Int32FromInt32(SQLITE_OPEN_PRIVATECACHE) + aMode = uintptr(unsafe.Pointer(&_aCacheMode)) + limit = mask + zModeType = __ccgo_ts + 26488 + } + if nOpt == int32(4) && libc.Xmemcmp(tls, __ccgo_ts+26509, zOpt, uint64(4)) == 0 { + mask = libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_MEMORY) + aMode = uintptr(unsafe.Pointer(&_aOpenMode)) + limit = libc.Int32FromUint32(libc.Uint32FromInt32(mask) & flags) + zModeType = __ccgo_ts + 3551 + } + if aMode != 0 { + mode = 0 + i = 0 + for { + if !((**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fz != 0) { + break + } + z = (**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fz + if nVal == _sqlite3Strlen30(tls, z) && 0 == libc.Xmemcmp(tls, zVal, z, libc.Uint64FromInt32(nVal)) { + mode = (**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fmode + break + } + goto _9 + _9: + ; + i = i + 1 + } + if mode == 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26524, libc.VaList(bp+8, zModeType, zVal)) + rc = int32(SQLITE_ERROR) + goto parse_uri_out + } + if mode & ^libc.Int32FromInt32(SQLITE_OPEN_MEMORY) > limit { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26544, libc.VaList(bp+8, zModeType, zVal)) + rc = int32(SQLITE_PERM) + goto parse_uri_out + } + flags = flags&libc.Uint32FromInt32(^mask) | libc.Uint32FromInt32(mode) + } + } + zOpt = zVal + uintptr(nVal+int32(1)) + } + } else { + zFile = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nUri+int32(8))) + if !(zFile != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, zFile, 0, uint64(4), ^t__predefined_size_t(0)) + zFile = zFile + uintptr(4) + if nUri != 0 { + libc.X__builtin___memcpy_chk(tls, zFile, zUri, libc.Uint64FromInt32(nUri), ^t__predefined_size_t(0)) + } + libc.X__builtin___memset_chk(tls, zFile+uintptr(nUri), 0, uint64(4), ^t__predefined_size_t(0)) + flags = flags & libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_OPEN_URI)) + } + **(**uintptr)(__ccgo_up(ppVfs)) = Xsqlite3_vfs_find(tls, zVfs) + if **(**uintptr)(__ccgo_up(ppVfs)) == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26568, libc.VaList(bp+8, zVfs)) + rc = int32(SQLITE_ERROR) + } + goto parse_uri_out +parse_uri_out: + ; + if rc != SQLITE_OK { + Xsqlite3_free_filename(tls, zFile) + zFile = uintptr(0) + } + **(**uint32)(__ccgo_up(pFlags)) = flags + **(**uintptr)(__ccgo_up(pzFile)) = zFile + return rc +} + +// C documentation +// +// /* +// ** Create a new PCache object. Storage space to hold the object +// ** has already been allocated and is passed in as the p pointer. +// ** The caller discovers how much space needs to be allocated by +// ** calling sqlite3PcacheSize(). +// ** +// ** szExtra is some extra space allocated for each page. The first +// ** 8 bytes of the extra space will be zeroed as the page is allocated, +// ** but remaining content will be uninitialized. Though it is opaque +// ** to this module, the extra space really ends up being the MemPage +// ** structure in the pager. +// */ +func _sqlite3PcacheOpen(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32, __ccgo_fp_xStress uintptr, pStress uintptr, p uintptr) (r int32) { + libc.X__builtin___memset_chk(tls, p, 0, uint64(80), ^t__predefined_size_t(0)) + (*TPCache)(unsafe.Pointer(p)).FszPage = int32(1) + (*TPCache)(unsafe.Pointer(p)).FszExtra = szExtra + /* First 8 bytes will be zeroed */ + (*TPCache)(unsafe.Pointer(p)).FbPurgeable = libc.Uint8FromInt32(bPurgeable) + (*TPCache)(unsafe.Pointer(p)).FeCreate = uint8(2) + (*TPCache)(unsafe.Pointer(p)).FxStress = __ccgo_fp_xStress + (*TPCache)(unsafe.Pointer(p)).FpStress = pStress + (*TPCache)(unsafe.Pointer(p)).FszCache = int32(100) + (*TPCache)(unsafe.Pointer(p)).FszSpill = int32(1) + return _sqlite3PcacheSetPageSize(tls, p, szPage) +} + +// C documentation +// +// /* +// ** Drop every cache entry whose page number is greater than "pgno". The +// ** caller must ensure that there are no outstanding references to any pages +// ** other than page 1 with a page number greater than pgno. +// ** +// ** If there is a reference to page 1 and the pgno parameter passed to this +// ** function is 0, then the data area associated with page 1 is zeroed, but +// ** the page object is not dropped. +// */ +func _sqlite3PcacheTruncate(tls *libc.TLS, pCache uintptr, pgno TPgno) { + var p, pNext, pPage1 uintptr + _, _, _ = p, pNext, pPage1 + if (*TPCache)(unsafe.Pointer(pCache)).FpCache != 0 { + p = (*TPCache)(unsafe.Pointer(pCache)).FpDirty + for { + if !(p != 0) { + break + } + pNext = (*TPgHdr)(unsafe.Pointer(p)).FpDirtyNext + /* This routine never gets call with a positive pgno except right + ** after sqlite3PcacheCleanAll(). So if there are dirty pages, + ** it must be that pgno==0. + */ + if (*TPgHdr)(unsafe.Pointer(p)).Fpgno > pgno { + _sqlite3PcacheMakeClean(tls, p) + } + goto _1 + _1: + ; + p = pNext + } + if pgno == uint32(0) && (*TPCache)(unsafe.Pointer(pCache)).FnRefSum != 0 { + pPage1 = (*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxFetch})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, uint32(1), 0) + if pPage1 != 0 { /* Page 1 is always available in cache, because + ** pCache->nRefSum>0 */ + libc.X__builtin___memset_chk(tls, (*Tsqlite3_pcache_page)(unsafe.Pointer(pPage1)).FpBuf, 0, libc.Uint64FromInt32((*TPCache)(unsafe.Pointer(pCache)).FszPage), ^t__predefined_size_t(0)) + pgno = uint32(1) + } + } + (*(*func(*libc.TLS, uintptr, uint32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxTruncate})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, pgno+uint32(1)) + } +} + +// C documentation +// +// /* +// ** Process a pragma statement. +// ** +// ** Pragmas are of this form: +// ** +// ** PRAGMA [schema.]id [= value] +// ** +// ** The identifier might also be a string. The value is a string, and +// ** identifier, or a number. If minusFlag is true, then the value is +// ** a number that was preceded by a minus sign. +// ** +// ** If the left side is "database.id" then pId1 is the database name +// ** and pId2 is the id. If the left side is just "id" then pId1 is the +// ** id and pId2 is any empty string. +// */ +func _sqlite3Pragma(tls *libc.TLS, pParse uintptr, pId1 uintptr, pId2 uintptr, pValue uintptr, minusFlag int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var a1, a11, addr, addr1, addrCkFault, addrCkOk, addrOk, addrTop, b, bStrict, ckUniq, cnt, doTypeCheck, eAuto, eMode, eMode1, eMode2, i, i1, i10, i2, i3, i4, i5, i6, i7, i8, i9, iAddr, iAddr1, iBt, iCol, iCol1, iCookie, iDb, iDbLast, iEnd, iIdxDb, iLevel, iReg, iTab, iTabCur, iTabDb, iTabDb1, ii, ii1, ii2, ii3, ii4, initNCol, isHidden, isQuick, j2, j3, j4, jmp, jmp2, jmp21, jmp3, jmp4, jmp5, jmp6, jmp61, jmp7, k, k3, kk, label6, labelError, labelOk, loopTop, mx, mxCol, n, nBtree, nCheck, nHidden, nIdx, nIndex, nLimit, p11, p3, p4, r1, r11, r2, rc, regResult, regRow, res1, showInternFunc, size, size1, size2, uniqOk, x1, v2 int32 + var aOp, aOp1, aOp2, aOp3, aOp4, aOp5, aRoot, db, j, j1, k1, k2, k4, p, p1, pBt, pBt1, pBt2, pCheck, pCol, pCol1, pColExpr, pColl, pDb, pEnc, pFK, pFK1, pFile, pFile1, pHash, pIdx, pIdx1, pIdx3, pIdx4, pIdx5, pIdx6, pIdx7, pMod, pObjTab, pPager, pPager1, pPager2, pPager3, pParent, pPk, pPk1, pPragma, pPrior, pSchema, pTab, pTab1, pTab10, pTab11, pTab12, pTab2, pTab3, pTab4, pTab5, pTab6, pTab7, pTab8, pTab9, pTbls, pVTab, v, x2, zDb, zErr, zErr1, zErr2, zLeft, zMod, zMode, zOpt, zRet, zRight, zSql, zSubSql, zType, v1, v5 uintptr + var azOrigin [3]uintptr + var cnum Ti16 + var enc Tu8 + var iPrior Tsqlite3_int64 + var iRange, szThreshold TLogEst + var mask Tu64 + var opMask Tu32 + var _ /* N at bp+144 */ Tsqlite3_int64 + var _ /* N at bp+152 */ Tsqlite3_int64 + var _ /* N at bp+160 */ Tsqlite3_int64 + var _ /* N at bp+168 */ Tsqlite3_int64 + var _ /* aFcntl at bp+8 */ [4]uintptr + var _ /* aiCols at bp+104 */ uintptr + var _ /* iDataCur at bp+116 */ int32 + var _ /* iIdxCur at bp+120 */ int32 + var _ /* iLimit at bp+48 */ Ti64 + var _ /* iLimit at bp+56 */ int32 + var _ /* jmp3 at bp+136 */ int32 + var _ /* mxErr at bp+112 */ int32 + var _ /* pDfltValue at bp+128 */ uintptr + var _ /* pDummy at bp+88 */ uintptr + var _ /* pId at bp+0 */ uintptr + var _ /* pIdx at bp+96 */ uintptr + var _ /* proxy_file_path at bp+80 */ uintptr + var _ /* res at bp+72 */ int32 + var _ /* size at bp+60 */ int32 + var _ /* sz at bp+64 */ Tsqlite3_int64 + var _ /* x at bp+40 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a1, a11, aOp, aOp1, aOp2, aOp3, aOp4, aOp5, aRoot, addr, addr1, addrCkFault, addrCkOk, addrOk, addrTop, azOrigin, b, bStrict, ckUniq, cnt, cnum, db, doTypeCheck, eAuto, eMode, eMode1, eMode2, enc, i, i1, i10, i2, i3, i4, i5, i6, i7, i8, i9, iAddr, iAddr1, iBt, iCol, iCol1, iCookie, iDb, iDbLast, iEnd, iIdxDb, iLevel, iPrior, iRange, iReg, iTab, iTabCur, iTabDb, iTabDb1, ii, ii1, ii2, ii3, ii4, initNCol, isHidden, isQuick, j, j1, j2, j3, j4, jmp, jmp2, jmp21, jmp3, jmp4, jmp5, jmp6, jmp61, jmp7, k, k1, k2, k3, k4, kk, label6, labelError, labelOk, loopTop, mask, mx, mxCol, n, nBtree, nCheck, nHidden, nIdx, nIndex, nLimit, opMask, p, p1, p11, p3, p4, pBt, pBt1, pBt2, pCheck, pCol, pCol1, pColExpr, pColl, pDb, pEnc, pFK, pFK1, pFile, pFile1, pHash, pIdx, pIdx1, pIdx3, pIdx4, pIdx5, pIdx6, pIdx7, pMod, pObjTab, pPager, pPager1, pPager2, pPager3, pParent, pPk, pPk1, pPragma, pPrior, pSchema, pTab, pTab1, pTab10, pTab11, pTab12, pTab2, pTab3, pTab4, pTab5, pTab6, pTab7, pTab8, pTab9, pTbls, pVTab, r1, r11, r2, rc, regResult, regRow, res1, showInternFunc, size, size1, size2, szThreshold, uniqOk, v, x1, x2, zDb, zErr, zErr1, zErr2, zLeft, zMod, zMode, zOpt, zRet, zRight, zSql, zSubSql, zType, v1, v2, v5 + zLeft = uintptr(0) /* Nul-terminated UTF-8 string */ + zRight = uintptr(0) /* Nul-terminated UTF-8 string , or NULL */ + zDb = uintptr(0) /* return value form SQLITE_FCNTL_PRAGMA */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The specific database being pragmaed */ + v = _sqlite3GetVdbe(tls, pParse) /* The pragma */ + if v == uintptr(0) { + return + } + _sqlite3VdbeRunOnlyOnce(tls, v) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(2) + /* Interpret the [schema.] part of the pragma statement. iDb is the + ** index of the database this pragma is being applied to in db.aDb[]. */ + iDb = _sqlite3TwoPartName(tls, pParse, pId1, pId2, bp) + if iDb < 0 { + return + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + /* If the temp database has been explicitly named as part of the + ** pragma, make sure it is open. + */ + if iDb == int32(1) && _sqlite3OpenTempDatabase(tls, pParse) != 0 { + return + } + zLeft = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if !(zLeft != 0) { + return + } + if minusFlag != 0 { + zRight = _sqlite3MPrintf(tls, db, __ccgo_ts+19577, libc.VaList(bp+184, pValue)) + } else { + zRight = _sqlite3NameFromToken(tls, db, pValue) + } + if (*TToken)(unsafe.Pointer(pId2)).Fn > uint32(0) { + v1 = (*TDb)(unsafe.Pointer(pDb)).FzDbSName + } else { + v1 = uintptr(0) + } + zDb = v1 + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_PRAGMA), zLeft, zRight, zDb) != 0 { + goto pragma_out + } + /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS + ** connection. If it returns SQLITE_OK, then assume that the VFS + ** handled the pragma and generate a no-op prepared statement. + ** + ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed, + ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file + ** object corresponding to the database file to which the pragma + ** statement refers. + ** + ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA + ** file control is an array of pointers to strings (char**) in which the + ** second element of the array is the name of the pragma and the third + ** element is the argument to the pragma or NULL if the pragma has no + ** argument. + */ + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0] = uintptr(0) + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(1)] = zLeft + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(2)] = zRight + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(3)] = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 + rc = Xsqlite3_file_control(tls, db, zDb, int32(SQLITE_FCNTL_PRAGMA), bp+8) + if rc == SQLITE_OK { + _sqlite3VdbeSetNumCols(tls, v, int32(1)) + _sqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0], uintptr(-libc.Int32FromInt32(1))) + _returnSingleText(tls, v, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + Xsqlite3_free(tls, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + goto pragma_out + } + if rc != int32(SQLITE_NOTFOUND) { + if (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0] != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3944, libc.VaList(bp+184, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0])) + Xsqlite3_free(tls, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + } + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + goto pragma_out + } + /* Locate the pragma in the lookup table */ + pPragma = _pragmaLocate(tls, zLeft) + if pPragma == uintptr(0) { + /* IMP: R-43042-22504 No error messages are generated if an + ** unknown pragma is issued. */ + goto pragma_out + } + /* Make sure the database schema is loaded if the pragma requires that */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NeedSchema) != 0 { + if _sqlite3ReadSchema(tls, pParse) != 0 { + goto pragma_out + } + } + /* Register the result column names for pragmas that return results */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns) == 0 && (libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns1) == 0 || zRight == uintptr(0)) { + _setPragmaResultColumnNames(tls, v, pPragma) + } + /* Jump to the appropriate pragma handler */ + switch libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FePragTyp) { + /* + ** PRAGMA [schema.]default_cache_size + ** PRAGMA [schema.]default_cache_size=N + ** + ** The first form reports the current persistent setting for the + ** page cache size. The value returned is the maximum number of + ** pages in the page cache. The second form sets both the current + ** page cache size value and the persistent page cache size value + ** stored in the database file. + ** + ** Older versions of SQLite would set the default cache size to a + ** negative number to indicate synchronous=OFF. These days, synchronous + ** is always on by default regardless of the sign of the default cache + ** size. But continue to take the absolute value of the default cache + ** size of historical compatibility. + */ + case int32(PragTyp_DEFAULT_CACHE_SIZE): + _sqlite3VdbeUsesBtree(tls, v, iDb) + if !(zRight != 0) { + **(**int32)(__ccgo_up(pParse + 60)) += int32(2) + aOp = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(36)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_getCacheSize)), _iLn3) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp + 6*24))).Fp1 = -int32(2000) + } else { + size = _sqlite3AbsInt32(tls, _sqlite3Atoi(tls, zRight)) + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_DEFAULT_CACHE_SIZE), size) + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size + _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) + } + break + /* + ** PRAGMA [schema.]page_size + ** PRAGMA [schema.]page_size=N + ** + ** The first form reports the current setting for the + ** database page size in bytes. The second form sets the + ** database page size value. The value can only be set if + ** the database has not yet been created. + */ + fallthrough + case int32(PragTyp_PAGE_SIZE): + pBt = (*TDb)(unsafe.Pointer(pDb)).FpBt + if !(zRight != 0) { + if pBt != 0 { + v2 = _sqlite3BtreeGetPageSize(tls, pBt) + } else { + v2 = 0 + } + size1 = v2 + _returnSingleInt(tls, v, int64(size1)) + } else { + /* Malloc may fail when setting the page-size, as there is an internal + ** buffer that the pager module resizes using sqlite3_realloc(). + */ + (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize = _sqlite3Atoi(tls, zRight) + if int32(SQLITE_NOMEM) == _sqlite3BtreeSetPageSize(tls, pBt, (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { + _sqlite3OomFault(tls, db) + } + } + break + /* + ** PRAGMA [schema.]secure_delete + ** PRAGMA [schema.]secure_delete=ON/OFF/FAST + ** + ** The first form reports the current setting for the + ** secure_delete flag. The second form changes the secure_delete + ** flag setting and reports the new value. + */ + fallthrough + case int32(PragTyp_SECURE_DELETE): + pBt1 = (*TDb)(unsafe.Pointer(pDb)).FpBt + b = -int32(1) + if zRight != 0 { + if Xsqlite3_stricmp(tls, zRight, __ccgo_ts+19581) == 0 { + b = int32(2) + } else { + b = libc.Int32FromUint8(_sqlite3GetBoolean(tls, zRight, uint8(0))) + } + } + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) && b >= 0 { + ii = 0 + for { + if !(ii < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + _sqlite3BtreeSecureDelete(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii)*32))).FpBt, b) + goto _3 + _3: + ; + ii = ii + 1 + } + } + b = _sqlite3BtreeSecureDelete(tls, pBt1, b) + _returnSingleInt(tls, v, int64(b)) + break + /* + ** PRAGMA [schema.]max_page_count + ** PRAGMA [schema.]max_page_count=N + ** + ** The first form reports the current setting for the + ** maximum number of pages in the database file. The + ** second form attempts to change this setting. Both + ** forms return the current setting. + ** + ** The absolute value of N is used. This is undocumented and might + ** change. The only purpose is to provide an easy way to test + ** the sqlite3AbsInt32() function. + ** + ** PRAGMA [schema.]page_count + ** + ** Return the number of pages in the specified database. + */ + fallthrough + case int32(PragTyp_PAGE_COUNT): + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + _sqlite3CodeVerifySchema(tls, pParse, iDb) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + iReg = v2 + if libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zLeft)))]) == int32('p') { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Pagecount), iDb, iReg) + } else { + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+40) == 0 { + if **(**Ti64)(__ccgo_up(bp + 40)) < 0 { + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + } else { + if **(**Ti64)(__ccgo_up(bp + 40)) > libc.Int64FromUint32(0xfffffffe) { + **(**Ti64)(__ccgo_up(bp + 40)) = libc.Int64FromUint32(0xfffffffe) + } + } + } else { + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MaxPgcnt), iDb, iReg, int32(**(**Ti64)(__ccgo_up(bp + 40)))) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), iReg, int32(1)) + break + /* + ** PRAGMA [schema.]locking_mode + ** PRAGMA [schema.]locking_mode = (normal|exclusive) + */ + fallthrough + case int32(PragTyp_LOCKING_MODE): + zRet = __ccgo_ts + 19372 + eMode = _getLockingMode(tls, zRight) + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) && eMode == -int32(1) { + /* Simple "PRAGMA locking_mode;" statement. This is a query for + ** the current default locking mode (which may be different to + ** the locking-mode of the main database). + */ + eMode = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FdfltLockMode) + } else { + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + ii1 = int32(2) + for { + if !(ii1 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pPager = _sqlite3BtreePager(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii1)*32))).FpBt) + _sqlite3PagerLockingMode(tls, pPager, eMode) + goto _6 + _6: + ; + ii1 = ii1 + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FdfltLockMode = libc.Uint8FromInt32(eMode) + } + pPager = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + eMode = _sqlite3PagerLockingMode(tls, pPager, eMode) + } + if eMode == int32(PAGER_LOCKINGMODE_EXCLUSIVE) { + zRet = __ccgo_ts + 19362 + } + _returnSingleText(tls, v, zRet) + break + /* + ** PRAGMA [schema.]journal_mode + ** PRAGMA [schema.]journal_mode = + ** (delete|persist|off|truncate|memory|wal|off) + */ + fallthrough + case int32(PragTyp_JOURNAL_MODE): /* Loop counter */ + if zRight == uintptr(0) { + /* If there is no "=MODE" part of the pragma, do a query for the + ** current mode */ + eMode1 = -int32(1) + } else { + n = _sqlite3Strlen30(tls, zRight) + eMode1 = 0 + for { + v1 = _sqlite3JournalModename(tls, eMode1) + zMode = v1 + if !(v1 != uintptr(0)) { + break + } + if Xsqlite3_strnicmp(tls, zRight, zMode, n) == 0 { + break + } + goto _7 + _7: + ; + eMode1 = eMode1 + 1 + } + if !(zMode != 0) { + /* If the "=MODE" part does not match any known journal mode, + ** then do a query */ + eMode1 = -int32(1) + } + if eMode1 == int32(PAGER_JOURNALMODE_OFF) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) { + /* Do not allow journal-mode "OFF" in defensive since the database + ** can become corrupted using ordinary SQL when the journal is off */ + eMode1 = -int32(1) + } + } + if eMode1 == -int32(1) && (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ + iDb = 0 + (*TToken)(unsafe.Pointer(pId2)).Fn = uint32(1) + } + ii2 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + for { + if !(ii2 >= 0) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii2)*32))).FpBt != 0 && (ii2 == iDb || (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0)) { + _sqlite3VdbeUsesBtree(tls, v, ii2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_JournalMode), ii2, int32(1), eMode1) + } + goto _9 + _9: + ; + ii2 = ii2 - 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) + break + /* + ** PRAGMA [schema.]journal_size_limit + ** PRAGMA [schema.]journal_size_limit=N + ** + ** Get or set the size limit on rollback journal files. + */ + fallthrough + case int32(PragTyp_JOURNAL_SIZE_LIMIT): + pPager1 = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + **(**Ti64)(__ccgo_up(bp + 48)) = int64(-int32(2)) + if zRight != 0 { + _sqlite3DecOrHexToI64(tls, zRight, bp+48) + if **(**Ti64)(__ccgo_up(bp + 48)) < int64(-int32(1)) { + **(**Ti64)(__ccgo_up(bp + 48)) = int64(-int32(1)) + } + } + **(**Ti64)(__ccgo_up(bp + 48)) = _sqlite3PagerJournalSizeLimit(tls, pPager1, **(**Ti64)(__ccgo_up(bp + 48))) + _returnSingleInt(tls, v, **(**Ti64)(__ccgo_up(bp + 48))) + break + /* + ** PRAGMA [schema.]auto_vacuum + ** PRAGMA [schema.]auto_vacuum=N + ** + ** Get or set the value of the database 'auto-vacuum' parameter. + ** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL + */ + fallthrough + case int32(PragTyp_AUTO_VACUUM): + pBt2 = (*TDb)(unsafe.Pointer(pDb)).FpBt + if !(zRight != 0) { + _returnSingleInt(tls, v, int64(_sqlite3BtreeGetAutoVacuum(tls, pBt2))) + } else { + eAuto = _getAutoVacuum(tls, zRight) + (*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac = libc.Int8FromUint8(libc.Uint8FromInt32(eAuto)) + /* Call SetAutoVacuum() to set initialize the internal auto and + ** incr-vacuum flags. This is required in case this connection + ** creates the database file. It is important that it is created + ** as an auto-vacuum capable db. + */ + rc = _sqlite3BtreeSetAutoVacuum(tls, pBt2, eAuto) + if rc == SQLITE_OK && (eAuto == int32(1) || eAuto == int32(2)) { + iAddr = _sqlite3VdbeCurrentAddr(tls, v) + aOp1 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(20)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_setMeta6)), _iLn11) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp1))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 2*24))).Fp2 = iAddr + int32(4) + (**(**TVdbeOp)(__ccgo_up(aOp1 + 4*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 4*24))).Fp3 = eAuto - int32(1) + _sqlite3VdbeUsesBtree(tls, v, iDb) + } + } + break + /* + ** PRAGMA [schema.]incremental_vacuum(N) + ** + ** Do N steps of incremental vacuuming on a database. + */ + fallthrough + case int32(PragTyp_INCREMENTAL_VACUUM): + **(**int32)(__ccgo_up(bp + 56)) = 0 + if zRight == uintptr(0) || !(_sqlite3GetInt32(tls, zRight, bp+56) != 0) || **(**int32)(__ccgo_up(bp + 56)) <= 0 { + **(**int32)(__ccgo_up(bp + 56)) = int32(0x7fffffff) + } + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp + 56)), int32(1)) + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IncrVacuum), iDb) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResultRow), int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(1), -int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), int32(1), addr) + _sqlite3VdbeJumpHere(tls, v, addr) + break + /* + ** PRAGMA [schema.]cache_size + ** PRAGMA [schema.]cache_size=N + ** + ** The first form reports the current local setting for the + ** page cache size. The second form sets the local + ** page cache size value. If N is positive then that is the + ** number of pages in the cache. If N is negative, then the + ** number of pages is adjusted so that the cache uses -N kibibytes + ** of memory. + */ + fallthrough + case int32(PragTyp_CACHE_SIZE): + if !(zRight != 0) { + _returnSingleInt(tls, v, int64((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size)) + } else { + size2 = _sqlite3Atoi(tls, zRight) + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size2 + _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) + } + break + /* + ** PRAGMA [schema.]cache_spill + ** PRAGMA cache_spill=BOOLEAN + ** PRAGMA [schema.]cache_spill=N + ** + ** The first form reports the current local setting for the + ** page cache spill size. The second form turns cache spill on + ** or off. When turning cache spill on, the size is set to the + ** current cache_size. The third form sets a spill size that + ** may be different form the cache size. + ** If N is positive then that is the + ** number of pages in the cache. If N is negative, then the + ** number of pages is adjusted so that the cache uses -N kibibytes + ** of memory. + ** + ** If the number of cache_spill pages is less then the number of + ** cache_size pages, no spilling occurs until the page count exceeds + ** the number of cache_size pages. + ** + ** The cache_spill=BOOLEAN setting applies to all attached schemas, + ** not just the schema specified. + */ + fallthrough + case int32(PragTyp_CACHE_SPILL): + if !(zRight != 0) { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_CacheSpill) == uint64(0) { + v2 = 0 + } else { + v2 = _sqlite3BtreeSetSpillSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, 0) + } + _returnSingleInt(tls, v, int64(v2)) + } else { + **(**int32)(__ccgo_up(bp + 60)) = int32(1) + if _sqlite3GetInt32(tls, zRight, bp+60) != 0 { + _sqlite3BtreeSetSpillSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, **(**int32)(__ccgo_up(bp + 60))) + } + if _sqlite3GetBoolean(tls, zRight, libc.BoolUint8(**(**int32)(__ccgo_up(bp + 60)) != 0)) != 0 { + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_CacheSpill) + } else { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_CacheSpill) + } + _setAllPagerFlags(tls, db) + } + break + /* + ** PRAGMA [schema.]mmap_size(N) + ** + ** Used to set mapping size limit. The mapping size limit is + ** used to limit the aggregate size of all memory mapped regions of the + ** database file. If this parameter is set to zero, then memory mapping + ** is not used at all. If N is negative, then the default memory map + ** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_SIZE) is set. + ** The parameter N is measured in bytes. + ** + ** This value is advisory. The underlying VFS is free to memory map + ** as little or as much as it wants. Except, if N is set to 0 then the + ** upper layers will never invoke the xFetch interfaces to the VFS. + */ + fallthrough + case int32(PragTyp_MMAP_SIZE): + if zRight != 0 { + _sqlite3DecOrHexToI64(tls, zRight, bp+64) + if **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) < 0 { + **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) = _sqlite3Config.FszMmap + } + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + (*Tsqlite3)(unsafe.Pointer(db)).FszMmap = **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) + } + ii3 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + for { + if !(ii3 >= 0) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii3)*32))).FpBt != 0 && (ii3 == iDb || (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0)) { + _sqlite3BtreeSetMmapLimit(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii3)*32))).FpBt, **(**Tsqlite3_int64)(__ccgo_up(bp + 64))) + } + goto _11 + _11: + ; + ii3 = ii3 - 1 + } + } + **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) = int64(-int32(1)) + rc = Xsqlite3_file_control(tls, db, zDb, int32(SQLITE_FCNTL_MMAP_SIZE), bp+64) + if rc == SQLITE_OK { + _returnSingleInt(tls, v, **(**Tsqlite3_int64)(__ccgo_up(bp + 64))) + } else { + if rc != int32(SQLITE_NOTFOUND) { + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + } + } + break + /* + ** PRAGMA temp_store + ** PRAGMA temp_store = "default"|"memory"|"file" + ** + ** Return or set the local value of the temp_store flag. Changing + ** the local value does not make changes to the disk file and the default + ** value will be restored the next time the database is opened. + ** + ** Note that it is possible for the library compile-time options to + ** override this setting + */ + fallthrough + case int32(PragTyp_TEMP_STORE): + if !(zRight != 0) { + _returnSingleInt(tls, v, libc.Int64FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store)) + } else { + _changeTempStorage(tls, pParse, zRight) + } + break + /* + ** PRAGMA temp_store_directory + ** PRAGMA temp_store_directory = ""|"directory_name" + ** + ** Return or set the local value of the temp_store_directory flag. Changing + ** the value sets a specific directory to be used for temporary files. + ** Setting to a null string reverts to the default temporary directory search. + ** If temporary directory is changed, then invalidateTempStorage. + ** + */ + fallthrough + case int32(PragTyp_TEMP_STORE_DIRECTORY): + Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + if !(zRight != 0) { + _returnSingleText(tls, v, Xsqlite3_temp_directory) + } else { + if **(**int8)(__ccgo_up(zRight)) != 0 { + rc = _sqlite3OsAccess(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, zRight, int32(SQLITE_ACCESS_READWRITE), bp+72) + if rc != SQLITE_OK || **(**int32)(__ccgo_up(bp + 72)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19586, 0) + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + goto pragma_out + } + } + if libc.Bool(false) || libc.Bool(true) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) <= int32(1) || libc.Bool(libc.Bool(false) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) == int32(1)) { + _invalidateTempStorage(tls, pParse) + } + Xsqlite3_free(tls, Xsqlite3_temp_directory) + if **(**int8)(__ccgo_up(zRight)) != 0 { + Xsqlite3_temp_directory = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+184, zRight)) + } else { + Xsqlite3_temp_directory = uintptr(0) + } + } + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + break + /* + ** PRAGMA [schema.]lock_proxy_file + ** PRAGMA [schema.]lock_proxy_file = ":auto:"|"lock_file_path" + ** + ** Return or set the value of the lock_proxy_file flag. Changing + ** the value sets a specific file to be used for database access locks. + ** + */ + fallthrough + case int32(PragTyp_LOCK_PROXY_FILE): + if !(zRight != 0) { + pPager2 = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + **(**uintptr)(__ccgo_up(bp + 80)) = libc.UintptrFromInt32(0) + pFile = _sqlite3PagerFile(tls, pPager2) + _sqlite3OsFileControlHint(tls, pFile, int32(SQLITE_FCNTL_GET_LOCKPROXYFILE), bp+80) + _returnSingleText(tls, v, **(**uintptr)(__ccgo_up(bp + 80))) + } else { + pPager3 = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + pFile1 = _sqlite3PagerFile(tls, pPager3) + if **(**int8)(__ccgo_up(zRight)) != 0 { + res1 = _sqlite3OsFileControl(tls, pFile1, int32(SQLITE_FCNTL_SET_LOCKPROXYFILE), zRight) + } else { + res1 = _sqlite3OsFileControl(tls, pFile1, int32(SQLITE_FCNTL_SET_LOCKPROXYFILE), libc.UintptrFromInt32(0)) + } + if res1 != SQLITE_OK { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19611, 0) + goto pragma_out + } + } + break + /* + ** PRAGMA [schema.]synchronous + ** PRAGMA [schema.]synchronous=OFF|ON|NORMAL|FULL|EXTRA + ** + ** Return or set the local value of the synchronous flag. Changing + ** the local value does not make changes to the disk file and the + ** default value will be restored the next time the database is + ** opened. + */ + fallthrough + case int32(PragTyp_SYNCHRONOUS): + if !(zRight != 0) { + _returnSingleInt(tls, v, int64(libc.Int32FromUint8((*TDb)(unsafe.Pointer(pDb)).Fsafety_level)-int32(1))) + } else { + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19641, 0) + } else { + if iDb != int32(1) { + iLevel = (libc.Int32FromUint8(_getSafetyLevel(tls, zRight, 0, uint8(1))) + int32(1)) & int32(PAGER_SYNCHRONOUS_MASK) + if iLevel == 0 { + iLevel = int32(1) + } + (*TDb)(unsafe.Pointer(pDb)).Fsafety_level = libc.Uint8FromInt32(iLevel) + (*TDb)(unsafe.Pointer(pDb)).FbSyncSet = uint8(1) + _setAllPagerFlags(tls, db) + } + } + } + case int32(PragTyp_FLAG): + if zRight == uintptr(0) { + _setPragmaResultColumnNames(tls, v, pPragma) + _returnSingleInt(tls, v, libc.BoolInt64((*Tsqlite3)(unsafe.Pointer(db)).Fflags&(*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != uint64(0))) + } else { + mask = (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg /* Mask of bits to set or clear. */ + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 { + /* Foreign key support may not be enabled or disabled while not + ** in auto-commit mode. */ + mask = mask & libc.Uint64FromInt32(^libc.Int32FromInt32(SQLITE_ForeignKeys)) + } + if _sqlite3GetBoolean(tls, zRight, uint8(0)) != 0 { + if mask&uint64(SQLITE_WriteSchema) == uint64(0) || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) == uint64(0) { + **(**Tu64)(__ccgo_up(db + 48)) |= mask + } + } else { + **(**Tu64)(__ccgo_up(db + 48)) &= ^mask + if mask == uint64(SQLITE_DeferFKs) { + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons = 0 + } + if mask&uint64(SQLITE_WriteSchema) != uint64(0) && Xsqlite3_stricmp(tls, zRight, __ccgo_ts+19694) == 0 { + /* IMP: R-60817-01178 If the argument is "RESET" then schema + ** writing is disabled (as with "PRAGMA writable_schema=OFF") and, + ** in addition, the schema is reloaded. */ + _sqlite3ResetAllSchemasOfConnection(tls, db) + } + } + /* Many of the flag-pragmas modify the code generated by the SQL + ** compiler (eg. count_changes). So add an opcode to expire all + ** compiled SQL statements after modifying a pragma value. + */ + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + _setAllPagerFlags(tls, db) + } + break + /* + ** PRAGMA table_info(
) + ** + ** Return a single row for each column of the named table. The columns of + ** the returned data set are: + ** + ** cid: Column id (numbered from left to right, starting at 0) + ** name: Column name + ** type: Column declaration type. + ** notnull: True if 'NOT NULL' is part of column declaration + ** dflt_value: The default value for the column, if any. + ** pk: Non-zero for PK fields. + */ + fallthrough + case int32(PragTyp_TABLE_INFO): + if zRight != 0 { + _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) + pTab = _sqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb) + if pTab != 0 { + nHidden = 0 + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(7) + _sqlite3ViewGetColumnNames(tls, pParse, pTab) + i = 0 + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + isHidden = 0 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_NOINSERT) != 0 { + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg == uint64(0) { + nHidden = nHidden + 1 + goto _12 + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + isHidden = int32(2) /* GENERATED ALWAYS AS ... VIRTUAL */ + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_STORED) != 0 { + isHidden = int32(3) /* GENERATED ALWAYS AS ... STORED */ + } else { + isHidden = int32(1) /* HIDDEN */ + } + } + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) == 0 { + k = 0 + } else { + if pPk == uintptr(0) { + k = int32(1) + } else { + k = int32(1) + for { + if !(k <= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) && int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(k-int32(1))*2))) != i) { + break + } + goto _13 + _13: + ; + k = k + 1 + } + } + } + pColExpr = _sqlite3ColumnExpr(tls, pTab, pCol) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + v1 = __ccgo_ts + 19700 + } else { + v1 = __ccgo_ts + 19708 + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + if isHidden >= int32(2) || pColExpr == uintptr(0) { + v5 = uintptr(0) + } else { + v5 = *(*uintptr)(unsafe.Pointer(pColExpr + 8)) + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), v1, libc.VaList(bp+184, i-nHidden, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, _sqlite3ColumnType(tls, pCol, __ccgo_ts+1702), v2, v5, k, isHidden)) + goto _12 + _12: + ; + i = i + 1 + pCol += 16 + } + } + } + break + /* + ** PRAGMA table_list + ** + ** Return a single row for each table, virtual table, or view in the + ** entire schema. + ** + ** schema: Name of attached database hold this table + ** name: Name of the table itself + ** type: "table", "view", "virtual", "shadow" + ** ncol: Number of columns + ** wr: True for a WITHOUT ROWID table + ** strict: True for a STRICT table + */ + fallthrough + case int32(PragTyp_TABLE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) + ii4 = 0 + for { + if !(ii4 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if zDb != 0 && Xsqlite3_stricmp(tls, zDb, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FzDbSName) != 0 { + goto _17 + } + /* Ensure that the Table.nCol field is initialized for all views + ** and virtual tables. Each time we initialize a Table.nCol value + ** for a table, that can potentially disrupt the hash table, so restart + ** the initialization scan. + */ + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FpSchema + 8 + initNCol = libc.Int32FromUint32((*THash)(unsafe.Pointer(pHash)).Fcount) + for { + v2 = initNCol + initNCol = initNCol - 1 + if !(v2 != 0) { + break + } + k1 = (*THash)(unsafe.Pointer(pHash)).Ffirst + for { + if !(int32(1) != 0) { + break + } + if k1 == uintptr(0) { + initNCol = 0 + break + } + pTab1 = (*THashElem)(unsafe.Pointer(k1)).Fdata + if int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) == 0 { + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+19715, libc.VaList(bp+184, (*TTable)(unsafe.Pointer(pTab1)).FzName)) + if zSql != 0 { + **(**uintptr)(__ccgo_up(bp + 88)) = uintptr(0) + Xsqlite3_prepare_v3(tls, db, zSql, -int32(1), uint32(SQLITE_PREPARE_DONT_LOG), bp+88, uintptr(0)) + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 88))) + _sqlite3DbFree(tls, db, zSql) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ErrorMsg(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpParse, __ccgo_ts+1672, 0) + (*TParse)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpParse)).Frc = int32(SQLITE_NOMEM) + } + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FpSchema + 8 + break + } + goto _19 + _19: + ; + k1 = (*THashElem)(unsafe.Pointer(k1)).Fnext + } + } + k1 = (*THash)(unsafe.Pointer(pHash)).Ffirst + for { + if !(k1 != 0) { + break + } + pTab2 = (*THashElem)(unsafe.Pointer(k1)).Fdata + if zRight != 0 && Xsqlite3_stricmp(tls, zRight, (*TTable)(unsafe.Pointer(pTab2)).FzName) != 0 { + goto _20 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VIEW) { + zType = __ccgo_ts + 11459 + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VTAB) { + zType = __ccgo_ts + 14644 + } else { + if (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Shadow) != 0 { + zType = __ccgo_ts + 19731 + } else { + zType = __ccgo_ts + 9721 + } + } + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19738, libc.VaList(bp+184, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FzDbSName, _sqlite3PreferredTableName(tls, (*TTable)(unsafe.Pointer(pTab2)).FzName), zType, int32((*TTable)(unsafe.Pointer(pTab2)).FnCol), libc.BoolInt32((*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_WithoutRowid) != uint32(0)), libc.BoolInt32((*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Strict) != uint32(0)))) + goto _20 + _20: + ; + k1 = (*THashElem)(unsafe.Pointer(k1)).Fnext + } + goto _17 + _17: + ; + ii4 = ii4 + 1 + } + case int32(PragTyp_INDEX_INFO): + if zRight != 0 { + pIdx = _sqlite3FindIndex(tls, db, zRight, zDb) + if pIdx == uintptr(0) { + /* If there is no index named zRight, check to see if there is a + ** WITHOUT ROWID table named zRight, and if there is, show the + ** structure of the PRIMARY KEY index for that table. */ + pTab3 = _sqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb) + if pTab3 != 0 && !((*TTable)(unsafe.Pointer(pTab3)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pIdx = _sqlite3PrimaryKeyIndex(tls, pTab3) + } + } + if pIdx != 0 { + iIdxDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIdx)).FpSchema) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + /* PRAGMA index_xinfo (newer version with more rows and columns) */ + mx = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + } else { + /* PRAGMA index_info (legacy version) */ + mx = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + } + pTab3 = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + _sqlite3CodeVerifySchema(tls, pParse, iIdxDb) + i1 = 0 + for { + if !(i1 < mx) { + break + } + cnum = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i1)*2)) + if int32(cnum) < 0 { + v1 = uintptr(0) + } else { + v1 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab3)).FaCol + uintptr(cnum)*16))).FzCnName + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19745, libc.VaList(bp+184, i1, int32(cnum), v1)) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + _sqlite3VdbeMultiLoad(tls, v, int32(4), __ccgo_ts+19750, libc.VaList(bp+184, libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i1)))), **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i1)*8)), libc.BoolInt32(i1 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)))) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), (*TParse)(unsafe.Pointer(pParse)).FnMem) + goto _21 + _21: + ; + i1 = i1 + 1 + } + } + } + case int32(PragTyp_INDEX_LIST): + if zRight != 0 { + pTab4 = _sqlite3FindTable(tls, db, zRight, zDb) + if pTab4 != 0 { + iTabDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab4)).FpSchema) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(5) + _sqlite3CodeVerifySchema(tls, pParse, iTabDb) + pIdx1 = (*TTable)(unsafe.Pointer(pTab4)).FpIndex + i2 = libc.Int32FromInt32(0) + for { + if !(pIdx1 != 0) { + break + } + azOrigin = [3]uintptr{ + 0: __ccgo_ts + 19755, + 1: __ccgo_ts + 19757, + 2: __ccgo_ts + 18198, + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19759, libc.VaList(bp+184, i2, (*TIndex)(unsafe.Pointer(pIdx1)).FzName, libc.BoolInt32(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx1)).FonError) != OE_None), azOrigin[int32(uint32(*(*uint16)(unsafe.Pointer(pIdx1 + 100))&0x3>>0))], libc.BoolInt32((*TIndex)(unsafe.Pointer(pIdx1)).FpPartIdxWhere != uintptr(0)))) + goto _23 + _23: + ; + pIdx1 = (*TIndex)(unsafe.Pointer(pIdx1)).FpNext + i2 = i2 + 1 + } + } + } + case int32(PragTyp_DATABASE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + i3 = 0 + for { + if !(i3 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FpBt == uintptr(0) { + goto _24 + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19765, libc.VaList(bp+184, i3, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FzDbSName, _sqlite3BtreeGetFilename(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FpBt))) + goto _24 + _24: + ; + i3 = i3 + 1 + } + case int32(PragTyp_COLLATION_LIST): + i4 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(2) + p = (*THash)(unsafe.Pointer(db + 648)).Ffirst + for { + if !(p != 0) { + break + } + pColl = (*THashElem)(unsafe.Pointer(p)).Fdata + v2 = i4 + i4 = i4 + 1 + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19769, libc.VaList(bp+184, v2, (*TCollSeq)(unsafe.Pointer(pColl)).FzName)) + goto _25 + _25: + ; + p = (*THashElem)(unsafe.Pointer(p)).Fnext + } + case int32(PragTyp_FUNCTION_LIST): + showInternFunc = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_InternalFunc) != uint32(0)) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + i5 = 0 + for { + if !(i5 < int32(SQLITE_FUNC_HASH_SZ)) { + break + } + p1 = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(i5)*8)) + for { + if !(p1 != 0) { + break + } + _pragmaFunclistLine(tls, v, p1, int32(1), showInternFunc) + goto _28 + _28: + ; + p1 = *(*uintptr)(unsafe.Pointer(p1 + 64)) + } + goto _27 + _27: + ; + i5 = i5 + 1 + } + j = (*THash)(unsafe.Pointer(db + 624)).Ffirst + for { + if !(j != 0) { + break + } + p1 = (*THashElem)(unsafe.Pointer(j)).Fdata + _pragmaFunclistLine(tls, v, p1, 0, showInternFunc) + goto _29 + _29: + ; + j = (*THashElem)(unsafe.Pointer(j)).Fnext + } + case int32(PragTyp_MODULE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(1) + j1 = (*THash)(unsafe.Pointer(db + 576)).Ffirst + for { + if !(j1 != 0) { + break + } + pMod = (*THashElem)(unsafe.Pointer(j1)).Fdata + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+8253, libc.VaList(bp+184, (*TModule)(unsafe.Pointer(pMod)).FzName)) + goto _30 + _30: + ; + j1 = (*THashElem)(unsafe.Pointer(j1)).Fnext + } + case int32(PragTyp_PRAGMA_LIST): + i6 = 0 + for { + if !(i6 < libc.Int32FromUint64(libc.Uint64FromInt64(1608)/libc.Uint64FromInt64(24))) { + break + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+8253, libc.VaList(bp+184, _aPragmaName[i6].FzName)) + goto _31 + _31: + ; + i6 = i6 + 1 + } + case int32(PragTyp_FOREIGN_KEY_LIST): + if zRight != 0 { + pTab5 = _sqlite3FindTable(tls, db, zRight, zDb) + if pTab5 != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab5)).FeTabType) == TABTYP_NORM { + pFK = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab5 + 64))).FpFKey + if pFK != 0 { + iTabDb1 = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab5)).FpSchema) + i7 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(8) + _sqlite3CodeVerifySchema(tls, pParse, iTabDb1) + for pFK != 0 { + j2 = 0 + for { + if !(j2 < (*TFKey)(unsafe.Pointer(pFK)).FnCol) { + break + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19772, libc.VaList(bp+184, i7, j2, (*TFKey)(unsafe.Pointer(pFK)).FzTo, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab5)).FaCol + uintptr((*(*TsColMap)(unsafe.Pointer(pFK + 64 + uintptr(j2)*16))).FiFrom)*16))).FzCnName, (*(*TsColMap)(unsafe.Pointer(pFK + 64 + uintptr(j2)*16))).FzCol, _actionName(tls, **(**Tu8)(__ccgo_up(pFK + 45 + 1))), _actionName(tls, **(**Tu8)(__ccgo_up(pFK + 45))), __ccgo_ts+19781)) + goto _32 + _32: + ; + j2 = j2 + 1 + } + i7 = i7 + 1 + pFK = (*TFKey)(unsafe.Pointer(pFK)).FpNextFrom + } + } + } + } + case int32(PragTyp_FOREIGN_KEY_CHECK): /* child to parent column mapping */ + regResult = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(4) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + regRow = v2 + k2 = (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 8)).Ffirst + for k2 != 0 { + if zRight != 0 { + pTab6 = _sqlite3LocateTable(tls, pParse, uint32(0), zRight, zDb) + k2 = uintptr(0) + } else { + pTab6 = (*THashElem)(unsafe.Pointer(k2)).Fdata + k2 = (*THashElem)(unsafe.Pointer(k2)).Fnext + } + if pTab6 == uintptr(0) || !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab6)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) || (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey == uintptr(0) { + continue + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab6)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab6)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab6)).FzName) + _sqlite3TouchRegister(tls, pParse, int32((*TTable)(unsafe.Pointer(pTab6)).FnCol)+regRow) + _sqlite3OpenTable(tls, pParse, 0, iDb, pTab6, int32(OP_OpenRead)) + _sqlite3VdbeLoadString(tls, v, regResult, (*TTable)(unsafe.Pointer(pTab6)).FzName) + i8 = int32(1) + pFK1 = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey + for { + if !(pFK1 != 0) { + break + } + pParent = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, zDb) + if pParent == uintptr(0) { + goto _35 + } + **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pParent)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pParent)).FzName) + x1 = _sqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+96, uintptr(0)) + if x1 == 0 { + if **(**uintptr)(__ccgo_up(bp + 96)) == uintptr(0) { + _sqlite3OpenTable(tls, pParse, i8, iDb, pParent, int32(OP_OpenRead)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), i8, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, **(**uintptr)(__ccgo_up(bp + 96))) + } + } else { + k2 = uintptr(0) + break + } + goto _35 + _35: + ; + i8 = i8 + 1 + pFK1 = (*TFKey)(unsafe.Pointer(pFK1)).FpNextFrom + } + if pFK1 != 0 { + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnTab < i8 { + (*TParse)(unsafe.Pointer(pParse)).FnTab = i8 + } + addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), 0) + i8 = int32(1) + pFK1 = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey + for { + if !(pFK1 != 0) { + break + } + pParent = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, zDb) + **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 104)) = uintptr(0) + if pParent != 0 { + x1 = _sqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+96, bp+104) + } + addrOk = _sqlite3VdbeMakeLabel(tls, pParse) + /* Generate code to read the child key values into registers + ** regRow..regRow+n. If any of the child key values are NULL, this + ** row cannot cause an FK violation. Jump directly to addrOk in + ** this case. */ + _sqlite3TouchRegister(tls, pParse, regRow+(*TFKey)(unsafe.Pointer(pFK1)).FnCol) + j3 = 0 + for { + if !(j3 < (*TFKey)(unsafe.Pointer(pFK1)).FnCol) { + break + } + if **(**uintptr)(__ccgo_up(bp + 104)) != 0 { + v2 = **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 104)) + uintptr(j3)*4)) + } else { + v2 = (*(*TsColMap)(unsafe.Pointer(pFK1 + 64 + uintptr(j3)*16))).FiFrom + } + iCol = v2 + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab6, 0, iCol, regRow+j3) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regRow+j3, addrOk) + goto _37 + _37: + ; + j3 = j3 + 1 + } + /* Generate code to query the parent index for a matching parent + ** key. If a match is found, jump to addrOk. */ + if **(**uintptr)(__ccgo_up(bp + 96)) != 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), regRow, (*TFKey)(unsafe.Pointer(pFK1)).FnCol, 0, _sqlite3IndexAffinityStr(tls, db, **(**uintptr)(__ccgo_up(bp + 96))), (*TFKey)(unsafe.Pointer(pFK1)).FnCol) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), i8, addrOk, regRow, (*TFKey)(unsafe.Pointer(pFK1)).FnCol) + } else { + if pParent != 0 { + jmp = _sqlite3VdbeCurrentAddr(tls, v) + int32(2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), i8, jmp, regRow) + _sqlite3VdbeGoto(tls, v, addrOk) + } + } + /* Generate code to report an FK violation to the caller. */ + if (*TTable)(unsafe.Pointer(pTab6)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), 0, regResult+int32(1)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regResult+int32(1)) + } + _sqlite3VdbeMultiLoad(tls, v, regResult+int32(2), __ccgo_ts+19786, libc.VaList(bp+184, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, i8-int32(1))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), regResult, int32(4)) + _sqlite3VdbeResolveLabel(tls, v, addrOk) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 104))) + goto _36 + _36: + ; + i8 = i8 + 1 + pFK1 = (*TFKey)(unsafe.Pointer(pFK1)).FpNextFrom + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), 0, addrTop+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addrTop) + } + break + /* Reinstall the LIKE and GLOB functions. The variant of LIKE + ** used will be case sensitive or not depending on the RHS. + */ + fallthrough + case int32(PragTyp_CASE_SENSITIVE_LIKE): + if zRight != 0 { + _sqlite3RegisterLikeFunctions(tls, db, libc.Int32FromUint8(_sqlite3GetBoolean(tls, zRight, uint8(0)))) + } + break + /* PRAGMA integrity_check + ** PRAGMA integrity_check(N) + ** PRAGMA quick_check + ** PRAGMA quick_check(N) + ** + ** Verify the integrity of the database. + ** + ** The "quick_check" is reduced version of + ** integrity_check designed to detect most database corruption + ** without the overhead of cross-checking indexes. Quick_check + ** is linear time whereas integrity_check is O(NlogN). + ** + ** The maximum number of errors is 100 by default. A different default + ** can be specified using a numeric parameter N. + ** + ** Or, the parameter N can be the name of a table. In that case, only + ** the one table named is verified. The freelist is only verified if + ** the named table is "sqlite_schema" (or one of its aliases). + ** + ** All schemas are checked by default. To check just a single + ** schema, use the form: + ** + ** PRAGMA schema.integrity_check; + */ + fallthrough + case int32(PragTyp_INTEGRITY_CHECK): + pObjTab = uintptr(0) /* Check only this one table, if not NULL */ + isQuick = libc.BoolInt32(libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zLeft)))]) == int32('q')) + /* If the PRAGMA command was of the form "PRAGMA .integrity_check", + ** then iDb is set to the index of the database identified by . + ** In this case, the integrity of database iDb only is verified by + ** the VDBE created below. + ** + ** Otherwise, if the command was simply "PRAGMA integrity_check" (or + ** "PRAGMA quick_check"), then iDb is set to 0. In this case, set iDb + ** to -1 here, to indicate that the VDBE should verify the integrity + ** of all attached databases. */ + if (*TToken)(unsafe.Pointer(pId2)).Fz == uintptr(0) { + iDb = -int32(1) + } + /* Initialize the VDBE program */ + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + /* Set the maximum error count */ + **(**int32)(__ccgo_up(bp + 112)) = int32(SQLITE_INTEGRITY_CHECK_ERROR_MAX) + if zRight != 0 { + if _sqlite3GetInt32(tls, (*TToken)(unsafe.Pointer(pValue)).Fz, bp+112) != 0 { + if **(**int32)(__ccgo_up(bp + 112)) <= 0 { + **(**int32)(__ccgo_up(bp + 112)) = int32(SQLITE_INTEGRITY_CHECK_ERROR_MAX) + } + } else { + if iDb >= 0 { + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + v1 = uintptr(0) + } + pObjTab = _sqlite3LocateTable(tls, pParse, uint32(0), zRight, v1) + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp + 112))-int32(1), int32(1)) /* reg[1] holds errors left */ + /* Do an integrity check on each database file */ + i9 = 0 + for { + if !(i9 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } /* Array of root page numbers of all btrees */ + cnt = 0 /* Number of entries in aRoot[] */ + if libc.Bool(OMIT_TEMPDB != 0) && i9 == int32(1) { + goto _40 + } + if iDb >= 0 && i9 != iDb { + goto _40 + } + _sqlite3CodeVerifySchema(tls, pParse, i9) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) /* tag-20230327-1 */ + /* Do an integrity check of the B-Tree + ** + ** Begin by finding the root pages numbers + ** for all tables and indices in the database. + */ + pTbls = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i9)*32))).FpSchema + 8 + cnt = 0 + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab7 = (*THashElem)(unsafe.Pointer(x2)).Fdata /* Number of indexes on pTab */ + if _tableSkipIntegrityCheck(tls, pTab7, pObjTab) != 0 { + goto _41 + } + if (*TTable)(unsafe.Pointer(pTab7)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + cnt = cnt + 1 + } + nIdx = 0 + pIdx3 = (*TTable)(unsafe.Pointer(pTab7)).FpIndex + for { + if !(pIdx3 != 0) { + break + } + cnt = cnt + 1 + goto _42 + _42: + ; + pIdx3 = (*TIndex)(unsafe.Pointer(pIdx3)).FpNext + nIdx = nIdx + 1 + } + goto _41 + _41: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + if cnt == 0 { + goto _40 + } + if pObjTab != 0 { + cnt = cnt + 1 + } + aRoot = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(cnt+libc.Int32FromInt32(1)))) + if aRoot == uintptr(0) { + break + } + cnt = 0 + if pObjTab != 0 { + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = 0 + } + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab8 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab8, pObjTab) != 0 { + goto _44 + } + if (*TTable)(unsafe.Pointer(pTab8)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab8)).Ftnum) + } + pIdx4 = (*TTable)(unsafe.Pointer(pTab8)).FpIndex + for { + if !(pIdx4 != 0) { + break + } + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx4)).Ftnum) + goto _46 + _46: + ; + pIdx4 = (*TIndex)(unsafe.Pointer(pIdx4)).FpNext + } + goto _44 + _44: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + **(**int32)(__ccgo_up(aRoot)) = cnt + /* Make sure sufficient number of registers have been allocated */ + _sqlite3TouchRegister(tls, pParse, int32(8)+cnt) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, int32(8), int32(8)+cnt) + _sqlite3ClearTempRegCache(tls, pParse) + /* Do the b-tree integrity checks */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_IntegrityCk), int32(1), cnt, int32(8), aRoot, -int32(15)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(i9)) + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), int32(2)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+19790, libc.VaList(bp+184, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i9)*32))).FzDbSName)), -int32(7)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(2), int32(3), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, addr1) + /* Check that the indexes all have the right number of rows */ + if pObjTab != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + cnt = v2 + _sqlite3VdbeLoadString(tls, v, int32(2), __ccgo_ts+19814) + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + iTab = 0 + pTab9 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab9, pObjTab) != 0 { + goto _49 + } + if (*TTable)(unsafe.Pointer(pTab9)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v2 = cnt + cnt = cnt + 1 + iTab = v2 + } else { + iTab = cnt + pIdx5 = (*TTable)(unsafe.Pointer(pTab9)).FpIndex + for { + if !(pIdx5 != 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx5 + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + break + } + iTab = iTab + 1 + goto _51 + _51: + ; + pIdx5 = (*TIndex)(unsafe.Pointer(pIdx5)).FpNext + } + } + pIdx5 = (*TTable)(unsafe.Pointer(pTab9)).FpIndex + for { + if !(pIdx5 != 0) { + break + } + if (*TIndex)(unsafe.Pointer(pIdx5)).FpPartIdxWhere == uintptr(0) { + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), int32(8)+cnt, 0, int32(8)+iTab) + _sqlite3VdbeLoadString(tls, v, int32(4), (*TIndex)(unsafe.Pointer(pIdx5)).FzName) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(2), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, addr1) + } + cnt = cnt + 1 + goto _52 + _52: + ; + pIdx5 = (*TIndex)(unsafe.Pointer(pIdx5)).FpNext + } + goto _49 + _49: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + /* Make sure all the indices are constructed correctly. + */ + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab10 = (*THashElem)(unsafe.Pointer(x2)).Fdata + pPrior = uintptr(0) + r1 = -int32(1) /* Maximum non-virtual column number */ + if _tableSkipIntegrityCheck(tls, pTab10, pObjTab) != 0 { + goto _53 + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab10)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + goto _53 + } + if isQuick != 0 || (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + pPk1 = uintptr(0) + r2 = 0 + } else { + pPk1 = _sqlite3PrimaryKeyIndex(tls, pTab10) + r2 = _sqlite3GetTempRange(tls, pParse, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), int32(1), r2, r2+libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)-int32(1)) + } + _sqlite3OpenTableAndIndices(tls, pParse, pTab10, int32(OP_OpenRead), uint8(0), int32(1), uintptr(0), bp+116, bp+120) + /* reg[7] counts the number of entries in the table. + ** reg[8+i] counts the number of entries in the i-th index + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, int32(7)) + j4 = 0 + pIdx6 = (*TTable)(unsafe.Pointer(pTab10)).FpIndex + for { + if !(pIdx6 != 0) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, int32(8)+j4) /* index entries counter */ + goto _54 + _54: + ; + pIdx6 = (*TIndex)(unsafe.Pointer(pIdx6)).FpNext + j4 = j4 + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), **(**int32)(__ccgo_up(bp + 116)), 0) + loopTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(7), int32(1)) + /* Fetch the right-most column from the table. This will cause + ** the entire record header to be parsed and sanity checked. It + ** will also prepopulate the cursor column cache that is used + ** by the OP_IsType code, so it is a required step. + */ + if (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + mxCol = -int32(1) + j4 = 0 + for { + if !(j4 < int32((*TTable)(unsafe.Pointer(pTab10)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + mxCol = mxCol + 1 + } + goto _55 + _55: + ; + j4 = j4 + 1 + } + if mxCol == int32((*TTable)(unsafe.Pointer(pTab10)).FiPKey) { + mxCol = mxCol - 1 + } + } else { + /* COLFLAG_VIRTUAL columns are not included in the WITHOUT ROWID + ** PK index column-count, so there is no need to account for them + ** in this case. */ + mxCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(_sqlite3PrimaryKeyIndex(tls, pTab10))).FnColumn) - int32(1) + } + if mxCol >= 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 116)), mxCol, int32(3)) + _sqlite3VdbeTypeofColumn(tls, v, int32(3)) + } + if !(isQuick != 0) { + if pPk1 != 0 { + a1 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxGT), **(**int32)(__ccgo_up(bp + 116)), 0, r2, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), r2) + zErr = _sqlite3MPrintf(tls, db, __ccgo_ts+19843, libc.VaList(bp+184, (*TTable)(unsafe.Pointer(pTab10)).FzName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr, -int32(7)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, a1) + _sqlite3VdbeJumpHere(tls, v, a1+int32(1)) + j4 = 0 + for { + if !(j4 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) { + break + } + _sqlite3ExprCodeLoadIndexColumn(tls, pParse, pPk1, **(**int32)(__ccgo_up(bp + 116)), j4, r2+j4) + goto _56 + _56: + ; + j4 = j4 + 1 + } + } + } + /* Verify datatypes for all columns: + ** + ** (1) NOT NULL columns may not contain a NULL + ** (2) Datatype must be exact for non-ANY columns in STRICT tables + ** (3) Datatype for TEXT columns in non-STRICT tables must be + ** NULL, TEXT, or BLOB. + ** (4) Datatype for numeric columns in non-STRICT tables must not + ** be a TEXT value that can be losslessly converted to numeric. + */ + bStrict = libc.BoolInt32((*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_Strict) != uint32(0)) + j4 = 0 + for { + if !(j4 < int32((*TTable)(unsafe.Pointer(pTab10)).FnCol)) { + break + } + pCol1 = (*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16 /* Check datatypes (besides NOT NULL) */ + if j4 == int32((*TTable)(unsafe.Pointer(pTab10)).FiPKey) { + goto _57 + } + if bStrict != 0 { + doTypeCheck = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4)) > int32(COLTYPE_ANY)) + } else { + doTypeCheck = libc.BoolInt32(int32((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) > int32(SQLITE_AFF_BLOB)) + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf>>0)) == 0 && !(doTypeCheck != 0) { + goto _57 + } + /* Compute the operands that will be needed for OP_IsType */ + p4 = int32(SQLITE_NULL) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab10, **(**int32)(__ccgo_up(bp + 116)), j4, int32(3)) + p11 = -int32(1) + p3 = int32(3) + } else { + if (*TColumn)(unsafe.Pointer(pCol1)).FiDflt != 0 { + **(**uintptr)(__ccgo_up(bp + 128)) = uintptr(0) + _sqlite3ValueFromExpr(tls, db, _sqlite3ColumnExpr(tls, pTab10, pCol1), (*Tsqlite3)(unsafe.Pointer(db)).Fenc, libc.Uint8FromInt8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity), bp+128) + if **(**uintptr)(__ccgo_up(bp + 128)) != 0 { + p4 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 128))) + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp + 128))) + } + } + p11 = **(**int32)(__ccgo_up(bp + 116)) + if !((*TTable)(unsafe.Pointer(pTab10)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + p3 = _sqlite3TableColumnToIndex(tls, _sqlite3PrimaryKeyIndex(tls, pTab10), j4) + } else { + p3 = int32(_sqlite3TableColumnToStorage(tls, pTab10, int16(j4))) + } + } + labelError = _sqlite3VdbeMakeLabel(tls, pParse) + labelOk = _sqlite3VdbeMakeLabel(tls, pParse) + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf>>0)) != 0 { + jmp2 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + if p11 < 0 { + _sqlite3VdbeChangeP5(tls, v, uint16(0x0f)) /* INT, REAL, TEXT, or BLOB */ + jmp3 = jmp2 + } else { + _sqlite3VdbeChangeP5(tls, v, uint16(0x0d)) /* INT, TEXT, or BLOB */ + /* OP_IsType does not detect NaN values in the database file + ** which should be treated as a NULL. So if the header type + ** is REAL, we have to load the actual data using OP_Column + ** to reliably determine if the value is a NULL. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), p11, p3, int32(3)) + _sqlite3ColumnDefault(tls, v, pTab10, j4, int32(3)) + jmp3 = _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), int32(3), labelOk) + } + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19879, libc.VaList(bp+184, (*TTable)(unsafe.Pointer(pTab10)).FzName, (*TColumn)(unsafe.Pointer(pCol1)).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + if doTypeCheck != 0 { + _sqlite3VdbeGoto(tls, v, labelError) + _sqlite3VdbeJumpHere(tls, v, jmp2) + _sqlite3VdbeJumpHere(tls, v, jmp3) + } else { + /* VDBE byte code will fall thru */ + } + } + if bStrict != 0 && doTypeCheck != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(_aStdTypeMask[int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4))-int32(1)])) + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19899, libc.VaList(bp+184, _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4))-int32(1)], (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } else { + if !(bStrict != 0) && int32((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) == int32(SQLITE_AFF_TEXT) { + /* (3) Datatype for TEXT columns in non-STRICT tables must be + ** NULL, TEXT, or BLOB. */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1c)) /* NULL, TEXT, or BLOB */ + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19921, libc.VaList(bp+184, (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } else { + if !(bStrict != 0) && int32((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) { + /* (4) Datatype for numeric columns in non-STRICT tables must not + ** be a TEXT value that can be converted to numeric. */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1b)) /* NULL, INT, FLOAT, or BLOB */ + if p11 >= 0 { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab10, **(**int32)(__ccgo_up(bp + 116)), j4, int32(3)) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), int32(3), int32(1), 0, __ccgo_ts+19944, -int32(1)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), -int32(1), labelOk, int32(3), p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1c)) /* NULL, TEXT, or BLOB */ + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19946, libc.VaList(bp+184, (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } + } + } + _sqlite3VdbeResolveLabel(tls, v, labelError) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, labelOk) + goto _57 + _57: + ; + j4 = j4 + 1 + } + /* Verify CHECK constraints */ + if (*TTable)(unsafe.Pointer(pTab10)).FpCheck != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_IgnoreChecks) == uint64(0) { + pCheck = _sqlite3ExprListDup(tls, db, (*TTable)(unsafe.Pointer(pTab10)).FpCheck, 0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + addrCkFault = _sqlite3VdbeMakeLabel(tls, pParse) + addrCkOk = _sqlite3VdbeMakeLabel(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = **(**int32)(__ccgo_up(bp + 116)) + int32(1) + k3 = (*TExprList)(unsafe.Pointer(pCheck)).FnExpr - int32(1) + for { + if !(k3 > 0) { + break + } + _sqlite3ExprIfFalse(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(k3)*32))).FpExpr, addrCkFault, 0) + goto _58 + _58: + ; + k3 = k3 - 1 + } + _sqlite3ExprIfTrue(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pCheck + 8))).FpExpr, addrCkOk, int32(SQLITE_JUMPIFNULL)) + _sqlite3VdbeResolveLabel(tls, v, addrCkFault) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 + zErr2 = _sqlite3MPrintf(tls, db, __ccgo_ts+19966, libc.VaList(bp+184, (*TTable)(unsafe.Pointer(pTab10)).FzName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr2, -int32(7)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, addrCkOk) + } + _sqlite3ExprListDelete(tls, db, pCheck) + } + if !(isQuick != 0) { /* Omit the remaining tests for quick_check */ + /* Validate index entries for the current row */ + j4 = 0 + pIdx6 = (*TTable)(unsafe.Pointer(pTab10)).FpIndex + for { + if !(pIdx6 != 0) { + break + } + ckUniq = _sqlite3VdbeMakeLabel(tls, pParse) + if pPk1 == pIdx6 { + goto _59 + } + r1 = _sqlite3GenerateIndexKey(tls, pParse, pIdx6, **(**int32)(__ccgo_up(bp + 116)), 0, 0, bp+136, pPrior, r1) + pPrior = pIdx6 + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(8)+j4, int32(1)) /* increment entry count */ + /* Verify that an index entry exists for the current table row */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), **(**int32)(__ccgo_up(bp + 120))+j4, ckUniq, r1, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnColumn)) + jmp21 = _sqlite3VdbeAddOp3(tls, v, int32(OP_IFindKey), **(**int32)(__ccgo_up(bp + 120))+j4, ckUniq, r1) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pIdx6, -int32(6)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+19996, libc.VaList(bp+184, (*TIndex)(unsafe.Pointer(pIdx6)).FzName)), -int32(7)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, ckUniq) + _sqlite3VdbeJumpHere(tls, v, jmp21) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+20055) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+20060) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(3), int32(3)) + jmp5 = _sqlite3VdbeLoadString(tls, v, int32(4), (*TIndex)(unsafe.Pointer(pIdx6)).FzName) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(3), int32(3)) + jmp4 = _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, ckUniq) + /* The OP_IdxRowid opcode is an optimized version of OP_Column + ** that extracts the rowid off the end of the index record. + ** But it only works correctly if index record does not have + ** any extra bytes at the end. Verify that this is the case. */ + if (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), **(**int32)(__ccgo_up(bp + 120))+j4, int32(3)) + jmp7 = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), int32(3), 0, r1+libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnColumn)-int32(1)) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+20081) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+20117) + _sqlite3VdbeGoto(tls, v, jmp5-int32(1)) + _sqlite3VdbeJumpHere(tls, v, jmp7) + } + /* Any indexed columns with non-BINARY collations must still hold + ** the exact same text value as the table. */ + label6 = 0 + kk = 0 + for { + if !(kk < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) { + break + } + if **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx6)).FazColl + uintptr(kk)*8)) == uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) { + goto _60 + } + if label6 == 0 { + label6 = _sqlite3VdbeMakeLabel(tls, pParse) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 120))+j4, kk, int32(3)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ne), int32(3), label6, r1+kk) + goto _60 + _60: + ; + kk = kk + 1 + } + if label6 != 0 { + jmp6 = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + _sqlite3VdbeResolveLabel(tls, v, label6) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+20055) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+20128) + _sqlite3VdbeGoto(tls, v, jmp5-int32(1)) + _sqlite3VdbeJumpHere(tls, v, jmp6) + } + /* For UNIQUE indexes, verify that only one entry exists with the + ** current key. The entry is unique if (1) any column is NULL + ** or (2) the next entry has a different key */ + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx6)).FonError) != OE_None { + uniqOk = _sqlite3VdbeMakeLabel(tls, pParse) + kk = 0 + for { + if !(kk < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) { + break + } + iCol1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx6)).FaiColumn + uintptr(kk)*2))) + if iCol1 >= 0 && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(iCol1)*16 + 8))&0xf>>0)) != 0 { + goto _61 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), r1+kk, uniqOk) + goto _61 + _61: + ; + kk = kk + 1 + } + jmp61 = _sqlite3VdbeAddOp1(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 120))+j4) + _sqlite3VdbeGoto(tls, v, uniqOk) + _sqlite3VdbeJumpHere(tls, v, jmp61) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxGT), **(**int32)(__ccgo_up(bp + 120))+j4, uniqOk, r1, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+20155) + _sqlite3VdbeGoto(tls, v, jmp5) + _sqlite3VdbeResolveLabel(tls, v, uniqOk) + } + _sqlite3VdbeJumpHere(tls, v, jmp4) + _sqlite3ResolvePartIdxLabel(tls, pParse, **(**int32)(__ccgo_up(bp + 136))) + goto _59 + _59: + ; + pIdx6 = (*TIndex)(unsafe.Pointer(pIdx6)).FpNext + j4 = j4 + 1 + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 116)), loopTop) + _sqlite3VdbeJumpHere(tls, v, loopTop-int32(1)) + if pPk1 != 0 { + _sqlite3ReleaseTempRange(tls, pParse, r2, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + } + goto _53 + _53: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + /* Second pass to invoke the xIntegrity method on all virtual + ** tables. + */ + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab11 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab11, pObjTab) != 0 { + goto _62 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab11)).FeTabType) == TABTYP_NORM { + goto _62 + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab11)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + goto _62 + } + if int32((*TTable)(unsafe.Pointer(pTab11)).FnCol) <= 0 { + zMod = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).FazArg)) + if _sqlite3HashFind(tls, db+576, zMod) == uintptr(0) { + goto _62 + } + } + _sqlite3ViewGetColumnNames(tls, pParse, pTab11) + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).Fp == uintptr(0) { + goto _62 + } + pVTab = (*TVTable)(unsafe.Pointer((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).Fp)).FpVtab + if pVTab == uintptr(0) { + goto _62 + } + if (*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule == uintptr(0) { + goto _62 + } + if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule)).FiVersion < int32(4) { + goto _62 + } + if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule)).FxIntegrity == uintptr(0) { + goto _62 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_VCheck), i9, int32(3), isQuick) + (*TTable)(unsafe.Pointer(pTab11)).FnTabRef = (*TTable)(unsafe.Pointer(pTab11)).FnTabRef + 1 + _sqlite3VdbeAppendP4(tls, v, pTab11, -int32(17)) + a11 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, a11) + goto _62 + goto _62 + _62: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + goto _40 + _40: + ; + i9 = i9 + 1 + } + aOp2 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(28)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_endCode)), _iLn21) + if aOp2 != 0 { + (**(**TVdbeOp)(__ccgo_up(aOp2))).Fp2 = int32(1) - **(**int32)(__ccgo_up(bp + 112)) + (**(**TVdbeOp)(__ccgo_up(aOp2 + 2*24))).Fp4type = int8(-libc.Int32FromInt32(1)) + *(*uintptr)(unsafe.Pointer(aOp2 + 2*24 + 16)) = __ccgo_ts + 20182 + (**(**TVdbeOp)(__ccgo_up(aOp2 + 5*24))).Fp4type = int8(-libc.Int32FromInt32(1)) + *(*uintptr)(unsafe.Pointer(aOp2 + 5*24 + 16)) = _sqlite3ErrStr(tls, int32(SQLITE_CORRUPT)) + } + _sqlite3VdbeChangeP3(tls, v, 0, _sqlite3VdbeCurrentAddr(tls, v)-int32(2)) + break + /* + ** PRAGMA encoding + ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" + ** + ** In its first form, this pragma returns the encoding of the main + ** database. If the database is not initialized, it is initialized now. + ** + ** The second form of this pragma is a no-op if the main database file + ** has not already been initialized. In this case it sets the default + ** encoding that will be used for the main database file if a new file + ** is created. If an existing main database file is opened, then the + ** default text encoding for the existing database is used. + ** + ** In all cases new databases created using the ATTACH command are + ** created to use the same default text encoding as the main database. If + ** the main database has not been initialized and/or created when ATTACH + ** is executed, this is done before the ATTACH operation. + ** + ** In the second form this pragma sets the text encoding to be used in + ** new database files created using this database handle. It is only + ** useful if invoked immediately after the main database i + */ + fallthrough + case int32(PragTyp_ENCODING): + if !(zRight != 0) { /* "PRAGMA encoding" */ + if _sqlite3ReadSchema(tls, pParse) != 0 { + goto pragma_out + } + _returnSingleText(tls, v, _encnames1[(*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc].FzName) + } else { /* "PRAGMA encoding = XXX" */ + /* Only change the value of sqlite.enc if the database handle is not + ** initialized. If the main database exists, the new sqlite.enc value + ** will be overwritten when the schema is next loaded. If it does not + ** already exists, it will be created to use the new encoding value. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_EncodingFixed) == uint32(0) { + pEnc = uintptr(unsafe.Pointer(&_encnames1)) + for { + if !((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName != 0) { + break + } + if 0 == _sqlite3StrICmp(tls, zRight, (*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName) { + if (*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).Fenc != 0 { + v2 = libc.Int32FromUint8((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).Fenc) + } else { + v2 = int32(SQLITE_UTF16LE) + } + enc = libc.Uint8FromInt32(v2) + (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).Fenc = enc + _sqlite3SetTextEncoding(tls, db, enc) + break + } + goto _63 + _63: + ; + pEnc += 16 + } + if !((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20243, libc.VaList(bp+184, zRight)) + } + } + } + break + /* + ** PRAGMA [schema.]schema_version + ** PRAGMA [schema.]schema_version = + ** + ** PRAGMA [schema.]user_version + ** PRAGMA [schema.]user_version = + ** + ** PRAGMA [schema.]freelist_count + ** + ** PRAGMA [schema.]data_version + ** + ** PRAGMA [schema.]application_id + ** PRAGMA [schema.]application_id = + ** + ** The pragma's schema_version and user_version are used to set or get + ** the value of the schema-version and user-version, respectively. Both + ** the schema-version and the user-version are 32-bit signed integers + ** stored in the database header. + ** + ** The schema-cookie is usually only manipulated internally by SQLite. It + ** is incremented by SQLite whenever the database schema is modified (by + ** creating or dropping a table or index). The schema version is used by + ** SQLite each time a query is executed to ensure that the internal cache + ** of the schema used when compiling the SQL query matches the schema of + ** the database against which the compiled query is actually executed. + ** Subverting this mechanism by using "PRAGMA schema_version" to modify + ** the schema-version is potentially dangerous and may lead to program + ** crashes or database corruption. Use with caution! + ** + ** The user-version is not used internally by SQLite. It may be used by + ** applications for any purpose. + */ + fallthrough + case int32(PragTyp_HEADER_VALUE): + iCookie = libc.Int32FromUint64((*TPragmaName)(unsafe.Pointer(pPragma)).FiArg) /* Which cookie to read or write */ + _sqlite3VdbeUsesBtree(tls, v, iDb) + if zRight != 0 && libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_ReadOnly) == 0 { + aOp3 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_setCookie)), 0) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp3))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp2 = iCookie + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp3 = _sqlite3Atoi(tls, zRight) + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp5 = uint16(1) + if iCookie == int32(BTREE_SCHEMA_VERSION) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) { + /* Do not allow the use of PRAGMA schema_version=VALUE in defensive + ** mode. Change the OP_SetCookie opcode into a no-op. */ + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fopcode = uint8(OP_Noop) + } + } else { + aOp4 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(12)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_readCookie)), 0) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp4))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp4 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp4 + 1*24))).Fp3 = iCookie + _sqlite3VdbeReusable(tls, v) + } + break + /* + ** PRAGMA compile_options + ** + ** Return the names of all compile-time options used in this build, + ** one option per row. + */ + fallthrough + case int32(PragTyp_COMPILE_OPTIONS): + i10 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(1) + for { + v2 = i10 + i10 = i10 + 1 + v1 = Xsqlite3_compileoption_get(tls, v2) + zOpt = v1 + if !(v1 != uintptr(0)) { + break + } + _sqlite3VdbeLoadString(tls, v, int32(1), zOpt) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) + } + _sqlite3VdbeReusable(tls, v) + break + /* + ** PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate + ** + ** Checkpoint the database. + */ + fallthrough + case int32(PragTyp_WAL_CHECKPOINT): + if (*TToken)(unsafe.Pointer(pId2)).Fz != 0 { + v2 = iDb + } else { + v2 = libc.Int32FromInt32(SQLITE_MAX_ATTACHED) + libc.Int32FromInt32(2) + } + iBt = v2 + eMode2 = SQLITE_CHECKPOINT_PASSIVE + if zRight != 0 { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19379) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_FULL) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+20268) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_RESTART) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19532) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_TRUNCATE) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+20276) == 0 { + eMode2 = -int32(1) + } + } + } + } + } + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Checkpoint), iBt, eMode2, int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(3)) + break + /* + ** PRAGMA wal_autocheckpoint + ** PRAGMA wal_autocheckpoint = N + ** + ** Configure a database connection to automatically checkpoint a database + ** after accumulating N frames in the log. Or query for the current value + ** of N. + */ + fallthrough + case int32(PragTyp_WAL_AUTOCHECKPOINT): + if zRight != 0 { + Xsqlite3_wal_autocheckpoint(tls, db, _sqlite3Atoi(tls, zRight)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxWalCallback == __ccgo_fp(_sqlite3WalDefaultHook) { + v2 = int32(int64((*Tsqlite3)(unsafe.Pointer(db)).FpWalArg)) + } else { + v2 = 0 + } + _returnSingleInt(tls, v, int64(v2)) + break + /* + ** PRAGMA shrink_memory + ** + ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database + ** connection on which it is invoked to free up as much memory as it + ** can, by calling sqlite3_db_release_memory(). + */ + fallthrough + case int32(PragTyp_SHRINK_MEMORY): + Xsqlite3_db_release_memory(tls, db) + break + /* + ** PRAGMA optimize + ** PRAGMA optimize(MASK) + ** PRAGMA schema.optimize + ** PRAGMA schema.optimize(MASK) + ** + ** Attempt to optimize the database. All schemas are optimized in the first + ** two forms, and only the specified schema is optimized in the latter two. + ** + ** The details of optimizations performed by this pragma are expected + ** to change and improve over time. Applications should anticipate that + ** this pragma will perform new optimizations in future releases. + ** + ** The optional argument is a bitmask of optimizations to perform: + ** + ** 0x00001 Debugging mode. Do not actually perform any optimizations + ** but instead return one line of text for each optimization + ** that would have been done. Off by default. + ** + ** 0x00002 Run ANALYZE on tables that might benefit. On by default. + ** See below for additional information. + ** + ** 0x00010 Run all ANALYZE operations using an analysis_limit that + ** is the lessor of the current analysis_limit and the + ** SQLITE_DEFAULT_OPTIMIZE_LIMIT compile-time option. + ** The default value of SQLITE_DEFAULT_OPTIMIZE_LIMIT is + ** currently (2024-02-19) set to 2000, which is such that + ** the worst case run-time for PRAGMA optimize on a 100MB + ** database will usually be less than 100 milliseconds on + ** a RaspberryPI-4 class machine. On by default. + ** + ** 0x10000 Look at tables to see if they need to be reanalyzed + ** due to growth or shrinkage even if they have not been + ** queried during the current connection. Off by default. + ** + ** The default MASK is and always shall be 0x0fffe. In the current + ** implementation, the default mask only covers the 0x00002 optimization, + ** though additional optimizations that are covered by 0x0fffe might be + ** added in the future. Optimizations that are off by default and must + ** be explicitly requested have masks of 0x10000 or greater. + ** + ** DETERMINATION OF WHEN TO RUN ANALYZE + ** + ** In the current implementation, a table is analyzed if only if all of + ** the following are true: + ** + ** (1) MASK bit 0x00002 is set. + ** + ** (2) The table is an ordinary table, not a virtual table or view. + ** + ** (3) The table name does not begin with "sqlite_". + ** + ** (4) One or more of the following is true: + ** (4a) The 0x10000 MASK bit is set. + ** (4b) One or more indexes on the table lacks an entry + ** in the sqlite_stat1 table. + ** (4c) The query planner used sqlite_stat1-style statistics for one + ** or more indexes of the table at some point during the lifetime + ** of the current connection. + ** + ** (5) One or more of the following is true: + ** (5a) One or more indexes on the table lacks an entry + ** in the sqlite_stat1 table. (Same as 4a) + ** (5b) The number of rows in the table has increased or decreased by + ** 10-fold. In other words, the current size of the table is + ** 10 times larger than the size in sqlite_stat1 or else the + ** current size is less than 1/10th the size in sqlite_stat1. + ** + ** The rules for when tables are analyzed are likely to change in + ** future releases. Future versions of SQLite might accept a string + ** literal argument to this pragma that contains a mnemonic description + ** of the options rather than a bitmap. + */ + fallthrough + case int32(PragTyp_OPTIMIZE): /* Analysis limit to use */ + nCheck = 0 /* Number of tables to be optimized */ + nBtree = 0 /* Number of indexes on the current table */ + if zRight != 0 { + opMask = libc.Uint32FromInt32(_sqlite3Atoi(tls, zRight)) + if opMask&uint32(0x02) == uint32(0) { + break + } + } else { + opMask = uint32(0xfffe) + } + if opMask&uint32(0x10) == uint32(0) { + nLimit = 0 + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit > 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit < int32(SQLITE_DEFAULT_OPTIMIZE_LIMIT) { + nLimit = 0 + } else { + nLimit = int32(SQLITE_DEFAULT_OPTIMIZE_LIMIT) + } + } + v1 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + iTabCur = v2 + if zDb != 0 { + v2 = iDb + } else { + v2 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + } + iDbLast = v2 + for { + if !(iDb <= iDbLast) { + break + } + if iDb == int32(1) { + goto _71 + } + _sqlite3CodeVerifySchema(tls, pParse, iDb) + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + k4 = (*THash)(unsafe.Pointer(pSchema + 8)).Ffirst + for { + if !(k4 != 0) { + break + } + pTab12 = (*THashElem)(unsafe.Pointer(k4)).Fdata + /* This only works for ordinary tables */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab12)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + goto _73 + } + /* Do not scan system tables */ + if 0 == Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab12)).FzName, __ccgo_ts+7100, int32(7)) { + goto _73 + } + /* Find the size of the table as last recorded in sqlite_stat1. + ** If any index is unanalyzed, then the threshold is -1 to + ** indicate a new, unanalyzed index + */ + szThreshold = (*TTable)(unsafe.Pointer(pTab12)).FnRowLogEst + nIndex = 0 + pIdx7 = (*TTable)(unsafe.Pointer(pTab12)).FpIndex + for { + if !(pIdx7 != 0) { + break + } + nIndex = nIndex + 1 + if !(int32(uint32(*(*uint16)(unsafe.Pointer(pIdx7 + 100))&0x80>>7)) != 0) { + szThreshold = int16(-int32(1)) /* Always analyze if any index lacks statistics */ + } + goto _74 + _74: + ; + pIdx7 = (*TIndex)(unsafe.Pointer(pIdx7)).FpNext + } + /* If table pTab has not been used in a way that would benefit from + ** having analysis statistics during the current session, then skip it, + ** unless the 0x10000 MASK bit is set. */ + if (*TTable)(unsafe.Pointer(pTab12)).FtabFlags&uint32(TF_MaybeReanalyze) != uint32(0) { + /* Check for size change if stat1 has been used for a query */ + } else { + if opMask&uint32(0x10000) != 0 { + /* Check for size change if 0x10000 is set */ + } else { + if (*TTable)(unsafe.Pointer(pTab12)).FpIndex != uintptr(0) && int32(szThreshold) < 0 { + /* Do analysis if unanalyzed indexes exists */ + } else { + /* Otherwise, we can skip this table */ + goto _73 + } + } + } + nCheck = nCheck + 1 + if nCheck == int32(2) { + /* If ANALYZE might be invoked two or more times, hold a write + ** transaction for efficiency */ + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + } + nBtree = nBtree + (nIndex + int32(1)) + /* Reanalyze if the table is 10 times larger or smaller than + ** the last analysis. Unconditional reanalysis if there are + ** unanalyzed indexes. */ + _sqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab12, int32(OP_OpenRead)) + if int32(szThreshold) >= 0 { + iRange = int16(33) /* 10x size change */ + if int32(szThreshold) >= int32(iRange) { + v2 = int32(szThreshold) - int32(iRange) + } else { + v2 = -int32(1) + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IfSizeBetween), iTabCur, libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3VdbeCurrentAddr(tls, v)+int32(2))+opMask&uint32(1)), v2, int32(szThreshold)+int32(iRange)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iTabCur, libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3VdbeCurrentAddr(tls, v)+int32(2))+opMask&uint32(1))) + } + zSubSql = _sqlite3MPrintf(tls, db, __ccgo_ts+20281, libc.VaList(bp+184, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(pTab12)).FzName)) + if opMask&uint32(0x01) != 0 { + r11 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, r11, 0, zSubSql, -int32(7)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), r11, int32(1)) + } else { + if nLimit != 0 { + v2 = int32(0x02) + } else { + v2 = 00 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_SqlExec), v2, nLimit, 0, zSubSql, -int32(7)) + } + goto _73 + _73: + ; + k4 = (*THashElem)(unsafe.Pointer(k4)).Fnext + } + goto _71 + _71: + ; + iDb = iDb + 1 + } + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + /* In a schema with a large number of tables and indexes, scale back + ** the analysis_limit to avoid excess run-time in the worst case. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) && nLimit > 0 && nBtree > int32(100) { + nLimit = int32(100) * nLimit / nBtree + if nLimit < int32(100) { + nLimit = int32(100) + } + aOp5 = _sqlite3VdbeGetOp(tls, v, 0) + iEnd = _sqlite3VdbeCurrentAddr(tls, v) + iAddr1 = 0 + for { + if !(iAddr1 < iEnd) { + break + } + if libc.Int32FromUint8((**(**TVdbeOp)(__ccgo_up(aOp5 + uintptr(iAddr1)*24))).Fopcode) == int32(OP_SqlExec) { + (**(**TVdbeOp)(__ccgo_up(aOp5 + uintptr(iAddr1)*24))).Fp2 = nLimit + } + goto _77 + _77: + ; + iAddr1 = iAddr1 + 1 + } + } + break + /* + ** PRAGMA busy_timeout + ** PRAGMA busy_timeout = N + ** + ** Call sqlite3_busy_timeout(db, N). Return the current timeout value + ** if one is set. If no busy handler or a different busy handler is set + ** then 0 is returned. Setting the busy_timeout to 0 or negative + ** disables the timeout. + */ + /*case PragTyp_BUSY_TIMEOUT*/ + fallthrough + default: + if zRight != 0 { + Xsqlite3_busy_timeout(tls, db, _sqlite3Atoi(tls, zRight)) + } + _returnSingleInt(tls, v, int64((*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout)) + break + /* + ** PRAGMA soft_heap_limit + ** PRAGMA soft_heap_limit = N + ** + ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the + ** sqlite3_soft_heap_limit64() interface with the argument N, if N is + ** specified and is a non-negative integer. + ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always + ** returns the same integer that would be returned by the + ** sqlite3_soft_heap_limit64(-1) C-language function. + */ + fallthrough + case int32(PragTyp_SOFT_HEAP_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+144) == SQLITE_OK { + Xsqlite3_soft_heap_limit64(tls, **(**Tsqlite3_int64)(__ccgo_up(bp + 144))) + } + _returnSingleInt(tls, v, Xsqlite3_soft_heap_limit64(tls, int64(-int32(1)))) + break + /* + ** PRAGMA hard_heap_limit + ** PRAGMA hard_heap_limit = N + ** + ** Invoke sqlite3_hard_heap_limit64() to query or set the hard heap + ** limit. The hard heap limit can be activated or lowered by this + ** pragma, but not raised or deactivated. Only the + ** sqlite3_hard_heap_limit64() C-language API can raise or deactivate + ** the hard heap limit. This allows an application to set a heap limit + ** constraint that cannot be relaxed by an untrusted SQL script. + */ + fallthrough + case int32(PragTyp_HARD_HEAP_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+152) == SQLITE_OK { + iPrior = Xsqlite3_hard_heap_limit64(tls, int64(-int32(1))) + if **(**Tsqlite3_int64)(__ccgo_up(bp + 152)) > 0 && (iPrior == 0 || iPrior > **(**Tsqlite3_int64)(__ccgo_up(bp + 152))) { + Xsqlite3_hard_heap_limit64(tls, **(**Tsqlite3_int64)(__ccgo_up(bp + 152))) + } + } + _returnSingleInt(tls, v, Xsqlite3_hard_heap_limit64(tls, int64(-int32(1)))) + break + /* + ** PRAGMA threads + ** PRAGMA threads = N + ** + ** Configure the maximum number of worker threads. Return the new + ** maximum, which might be less than requested. + */ + fallthrough + case int32(PragTyp_THREADS): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+160) == SQLITE_OK && **(**Tsqlite3_int64)(__ccgo_up(bp + 160)) >= 0 { + Xsqlite3_limit(tls, db, int32(SQLITE_LIMIT_WORKER_THREADS), int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 160))&libc.Int64FromInt32(0x7fffffff))) + } + _returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, int32(SQLITE_LIMIT_WORKER_THREADS), -int32(1)))) + break + /* + ** PRAGMA analysis_limit + ** PRAGMA analysis_limit = N + ** + ** Configure the maximum number of rows that ANALYZE will examine + ** in each index that it looks at. Return the new limit. + */ + fallthrough + case int32(PragTyp_ANALYSIS_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+168) == SQLITE_OK && **(**Tsqlite3_int64)(__ccgo_up(bp + 168)) >= 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 168)) & libc.Int64FromInt32(0x7fffffff)) + } + _returnSingleInt(tls, v, int64((*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit)) /* IMP: R-57594-65522 */ + break + } /* End of the PRAGMA switch */ + /* The following block is a no-op unless SQLITE_DEBUG is defined. Its only + ** purpose is to execute assert() statements to verify that if the + ** PragFlg_NoColumns1 flag is set and the caller specified an argument + ** to the PRAGMA, the implementation has not added any OP_ResultRow + ** instructions to the VM. */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns1) != 0 && zRight != 0 { + } + goto pragma_out +pragma_out: + ; + _sqlite3DbFree(tls, db, zLeft) + _sqlite3DbFree(tls, db, zRight) +} + +// C documentation +// +// /* +// ** Return the preferred table name for system tables. Translate legacy +// ** names into the new preferred names, as appropriate. +// */ +func _sqlite3PreferredTableName(tls *libc.TLS, zName uintptr) (r uintptr) { + if Xsqlite3_strnicmp(tls, zName, __ccgo_ts+7100, int32(7)) == 0 { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6628+7) == 0 { + return __ccgo_ts + 7146 + } + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+7108+7) == 0 { + return __ccgo_ts + 7127 + } + } + return zName +} + +// C documentation +// +// /* +// ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. +// */ +func _sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags Tu32, pReprepare uintptr, ppStmt uintptr, pzTail uintptr) (r int32) { + bp := tls.Alloc(432) + defer tls.Free(432) + var i, mxLen, rc, v1 int32 + var pBt, pT, zDb, zSqlCopy uintptr + var _ /* sParse at bp+0 */ TParse + _, _, _, _, _, _, _, _ = i, mxLen, pBt, pT, rc, zDb, zSqlCopy, v1 + rc = SQLITE_OK /* Parsing context */ + /* sqlite3ParseObjectInit(&sParse, db); // inlined for performance */ + libc.X__builtin___memset_chk(tls, bp+uintptr(uint64(libc.UintptrFromInt32(0)+8)), 0, uint64(libc.UintptrFromInt32(0)+184)-uint64(libc.UintptrFromInt32(0)+8), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+uintptr(uint64(libc.UintptrFromInt32(0)+280)), 0, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280), ^t__predefined_size_t(0)) + (**(**TParse)(__ccgo_up(bp))).FpOuterParse = (*Tsqlite3)(unsafe.Pointer(db)).FpParse + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = bp + (**(**TParse)(__ccgo_up(bp))).Fdb = db + if pReprepare != 0 { + (**(**TParse)(__ccgo_up(bp))).FpReprepare = pReprepare + (**(**TParse)(__ccgo_up(bp))).Fexplain = libc.Uint8FromInt32(Xsqlite3_stmt_isexplain(tls, pReprepare)) + } else { + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ErrorMsg(tls, bp, __ccgo_ts+1672, 0) + v1 = libc.Int32FromInt32(SQLITE_NOMEM) + rc = v1 + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = v1 + goto end_prepare + } + /* For a long-term use prepared statement avoid the use of + ** lookaside memory. + */ + if prepFlags&uint32(SQLITE_PREPARE_PERSISTENT) != 0 { + (**(**TParse)(__ccgo_up(bp))).FdisableLookaside = (**(**TParse)(__ccgo_up(bp))).FdisableLookaside + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + } + (**(**TParse)(__ccgo_up(bp))).FprepFlags = uint8(prepFlags & uint32(0xff)) + /* Check to verify that it is possible to get a read lock on all + ** database schemas. The inability to get a read lock indicates that + ** some other database connection is holding a write-lock, which in + ** turn means that the other connection has made uncommitted changes + ** to the schema. + ** + ** Were we to proceed and prepare the statement against the uncommitted + ** schema changes and if those schema changes are subsequently rolled + ** back and different changes are made in their place, then when this + ** prepared statement goes to run the schema cookie would fail to detect + ** the schema change. Disaster would follow. + ** + ** This thread is currently holding mutexes on all Btrees (because + ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it + ** is not possible for another thread to start a new schema change + ** while this routine is running. Hence, we do not need to hold + ** locks on the schema, we just need to make sure nobody else is + ** holding them. + ** + ** Note that setting READ_UNCOMMITTED overrides most lock detection, + ** but it does *not* override schema lock detection, so this all still + ** works even if READ_UNCOMMITTED is set. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FnoSharedCache != 0) { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 { + rc = _sqlite3BtreeSchemaLocked(tls, pBt) + if rc != 0 { + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName + _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+20628, libc.VaList(bp+424, zDb)) + goto end_prepare + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FpDisconnect != 0 { + _sqlite3VtabUnlockList(tls, db) + } + if nBytes >= 0 && (nBytes == 0 || int32(**(**int8)(__ccgo_up(zSql + uintptr(nBytes-int32(1))))) != 0) { + mxLen = **(**int32)(__ccgo_up(db + 136 + 1*4)) + if nBytes > mxLen { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_TOOBIG), __ccgo_ts+20658, 0) + rc = _sqlite3ApiExit(tls, db, int32(SQLITE_TOOBIG)) + goto end_prepare + } + zSqlCopy = _sqlite3DbStrNDup(tls, db, zSql, libc.Uint64FromInt32(nBytes)) + if zSqlCopy != 0 { + _sqlite3RunParser(tls, bp, zSqlCopy) + (**(**TParse)(__ccgo_up(bp))).FzTail = zSql + uintptr(int64((**(**TParse)(__ccgo_up(bp))).FzTail)-int64(zSqlCopy)) + _sqlite3DbFree(tls, db, zSqlCopy) + } else { + (**(**TParse)(__ccgo_up(bp))).FzTail = zSql + uintptr(nBytes) + } + } else { + _sqlite3RunParser(tls, bp, zSql) + } + if pzTail != 0 { + **(**uintptr)(__ccgo_up(pzTail)) = (**(**TParse)(__ccgo_up(bp))).FzTail + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { + _sqlite3VdbeSetSql(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe, zSql, int32(int64((**(**TParse)(__ccgo_up(bp))).FzTail)-int64(zSql)), uint8(prepFlags)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (**(**TParse)(__ccgo_up(bp))).Frc = int32(SQLITE_NOMEM) + libc.SetBitFieldPtr16Uint32(bp+40, libc.Uint32FromInt32(0), 8, 0x100) + } + if (**(**TParse)(__ccgo_up(bp))).Frc != SQLITE_OK && (**(**TParse)(__ccgo_up(bp))).Frc != int32(SQLITE_DONE) { + if int32(Tbft(*(*uint16)(unsafe.Pointer(bp + 40))&0x100>>8)) != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { + _schemaIsValid(tls, bp) + } + if (**(**TParse)(__ccgo_up(bp))).FpVdbe != 0 { + _sqlite3VdbeFinalize(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe) + } + rc = (**(**TParse)(__ccgo_up(bp))).Frc + if (**(**TParse)(__ccgo_up(bp))).FzErrMsg != 0 { + _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+3944, libc.VaList(bp+424, (**(**TParse)(__ccgo_up(bp))).FzErrMsg)) + _sqlite3DbFree(tls, db, (**(**TParse)(__ccgo_up(bp))).FzErrMsg) + } else { + _sqlite3Error(tls, db, rc) + } + } else { + **(**uintptr)(__ccgo_up(ppStmt)) = (**(**TParse)(__ccgo_up(bp))).FpVdbe + rc = SQLITE_OK + _sqlite3ErrorClear(tls, db) + } + /* Delete any TriggerPrg structures allocated while parsing this statement. */ + for (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg != 0 { + pT = (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg + (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg = (*TTriggerPrg)(unsafe.Pointer(pT)).FpNext + _sqlite3DbFree(tls, db, pT) + } + goto end_prepare +end_prepare: + ; + _sqlite3ParseObjectReset(tls, bp) + return rc +} + +func _sqlite3PrngRestoreState(tls *libc.TLS) { + libc.X__builtin___memcpy_chk(tls, uintptr(unsafe.Pointer(&_sqlite3Prng)), uintptr(unsafe.Pointer(&_sqlite3SavedPrng)), uint64(132), ^t__predefined_size_t(0)) +} + +func _sqlite3PrngSaveState(tls *libc.TLS) { + libc.X__builtin___memcpy_chk(tls, uintptr(unsafe.Pointer(&_sqlite3SavedPrng)), uintptr(unsafe.Pointer(&_sqlite3Prng)), uint64(132), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** This routine processes the join information for a SELECT statement. +// ** +// ** * A NATURAL join is converted into a USING join. After that, we +// ** do not need to be concerned with NATURAL joins and we only have +// ** think about USING joins. +// ** +// ** * ON and USING clauses result in extra terms being added to the +// ** WHERE clause to enforce the specified constraints. The extra +// ** WHERE clause terms will be tagged with EP_OuterON or +// ** EP_InnerON so that we know that they originated in ON/USING. +// ** +// ** The terms of a FROM clause are contained in the Select.pSrc structure. +// ** The left most table is the first entry in Select.pSrc. The right-most +// ** table is the last entry. The join operator is held in the entry to +// ** the right. Thus entry 1 contains the join operator for the join between +// ** entries 0 and 1. Any ON or USING clauses associated with the join are +// ** also attached to the right entry. +// ** +// ** This routine returns the number of errors encountered. +// */ +func _sqlite3ProcessJoin(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pE1, pE2, pEq, pFuncArgs, pLeft, pList, pRight, pRightTab, pSrc, pUsing, zName, zName1 uintptr + var i, iRightCol, j, v2 int32 + var joinType Tu32 + var _ /* iLeft at bp+0 */ int32 + var _ /* iLeftCol at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iRightCol, j, joinType, pE1, pE2, pEq, pFuncArgs, pLeft, pList, pRight, pRightTab, pSrc, pUsing, zName, zName1, v2 /* Right table being joined */ + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + pLeft = pSrc + 8 + pRight = pLeft + 1*80 + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc-int32(1)) { + break + } + pRightTab = (*TSrcItem)(unsafe.Pointer(pRight)).FpSTab + if (*TSrcItem)(unsafe.Pointer(pLeft)).FpSTab == uintptr(0) || pRightTab == uintptr(0) { + goto _1 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&int32(JT_OUTER) != 0 { + v2 = int32(EP_OuterON) + } else { + v2 = int32(EP_InnerON) + } + joinType = libc.Uint32FromInt32(v2) + /* If this is a NATURAL join, synthesize an appropriate USING clause + ** to specify which columns should be joined. + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&int32(JT_NATURAL) != 0 { + pUsing = uintptr(0) + if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x800>>11) != 0 || *(*uintptr)(unsafe.Pointer(pRight + 64)) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20707, libc.VaList(bp+16, 0)) + return int32(1) + } + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(pRightTab)).FnCol)) { + break + } /* Name of column in the right table */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer((*TTable)(unsafe.Pointer(pRightTab)).FaCol+uintptr(j)*16)).FcolFlags)&int32(COLFLAG_HIDDEN) != 0 { + goto _3 + } + zName = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*16))).FzCnName + if _tableAndColumnIndex(tls, pSrc, 0, i, zName, uintptr(0), uintptr(0), int32(1)) != 0 { + pUsing = _sqlite3IdListAppend(tls, pParse, pUsing, uintptr(0)) + if pUsing != 0 { + (*(*TIdList_item)(unsafe.Pointer(pUsing + 8 + uintptr((*TIdList)(unsafe.Pointer(pUsing)).FnId-int32(1))*8))).FzName = _sqlite3DbStrDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zName) + } + } + goto _3 + _3: + ; + j = j + 1 + } + if pUsing != 0 { + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 11, 0x800) + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 13, 0x2000) + *(*uintptr)(unsafe.Pointer(pRight + 64)) = pUsing + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(1) + } + } + /* Create extra terms on the WHERE clause for each column named + ** in the USING clause. Example: If the two tables to be joined are + ** A and B and the USING clause names X, Y, and Z, then add this + ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z + ** Report an error if any column mentioned in the USING clause is + ** not contained in both tables to be joined. + */ + if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x800>>11) != 0 { + pList = *(*uintptr)(unsafe.Pointer(pRight + 64)) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + j = 0 + for { + if !(j < (*TIdList)(unsafe.Pointer(pList)).FnId) { + break + } /* Equality constraint. pE1 == pE2 */ + zName1 = (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(j)*8))).FzName + iRightCol = _sqlite3ColumnIndex(tls, pRightTab, zName1) + if iRightCol < 0 || _tableAndColumnIndex(tls, pSrc, 0, i, zName1, bp, bp+4, int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x2000>>13)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20757, libc.VaList(bp+16, zName1)) + return int32(1) + } + pE1 = _sqlite3CreateColumnExpr(tls, db, pSrc, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4))) + _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(**(**int32)(__ccgo_up(bp)))*80, **(**int32)(__ccgo_up(bp + 4))) + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + /* This branch runs if the query contains one or more RIGHT or FULL + ** JOINs. If only a single table on the left side of this join + ** contains the zName column, then this branch is a no-op. + ** But if there are two or more tables on the left side + ** of the join, construct a coalesce() function that gathers all + ** such tables. Raise an error if more than one of those references + ** to zName is not also within a prior USING clause. + ** + ** We really ought to raise an error if there are two or more + ** non-USING references to zName on the left of an INNER or LEFT + ** JOIN. But older versions of SQLite do not do that, so we avoid + ** adding a new error so as to not break legacy applications. + */ + pFuncArgs = uintptr(0) /* Arguments to the coalesce() */ + **(**Tu32)(__ccgo_up(pE1 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + for _tableAndColumnIndex(tls, pSrc, **(**int32)(__ccgo_up(bp))+int32(1), i, zName1, bp, bp+4, int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x2000>>13)) != 0 { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(**(**int32)(__ccgo_up(bp)))*80 + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(**(**int32)(__ccgo_up(bp)))*80 + 64)), zName1) < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20821, libc.VaList(bp+16, zName1)) + break + } + pFuncArgs = _sqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1) + pE1 = _sqlite3CreateColumnExpr(tls, db, pSrc, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4))) + _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(**(**int32)(__ccgo_up(bp)))*80, **(**int32)(__ccgo_up(bp + 4))) + } + if pFuncArgs != 0 { + pFuncArgs = _sqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1) + pE1 = _sqlite3ExprFunction(tls, pParse, pFuncArgs, uintptr(unsafe.Pointer(&_tkCoalesce)), 0) + if pE1 != 0 { + (*TExpr)(unsafe.Pointer(pE1)).FaffExpr = int8(SQLITE_AFF_DEFER) + } + } + } else { + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i+int32(1))*80))).Ffg.Fjointype)&int32(JT_LEFT) != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + **(**Tu32)(__ccgo_up(pE1 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + } + pE2 = _sqlite3CreateColumnExpr(tls, db, pSrc, i+int32(1), iRightCol) + _sqlite3SrcItemColumnUsed(tls, pRight, iRightCol) + pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), pE1, pE2) + if pEq != 0 { + **(**Tu32)(__ccgo_up(pEq + 4)) |= joinType + *(*int32)(unsafe.Pointer(pEq + 52)) = (*TExpr)(unsafe.Pointer(pE2)).FiTable + } + (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWhere, pEq) + goto _4 + _4: + ; + j = j + 1 + } + } else { + if *(*uintptr)(unsafe.Pointer(pRight + 64)) != 0 { + _sqlite3SetJoinExpr(tls, *(*uintptr)(unsafe.Pointer(pRight + 64)), (*TSrcItem)(unsafe.Pointer(pRight)).FiCursor, joinType) + (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWhere, *(*uintptr)(unsafe.Pointer(pRight + 64))) + *(*uintptr)(unsafe.Pointer(pRight + 64)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 12, 0x1000) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_OnToWhere) + } + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pRightTab)).FeTabType) == int32(TABTYP_VTAB) && joinType == uint32(EP_OuterON) && *(*uintptr)(unsafe.Pointer(pRight + 48)) != 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_OnToWhere) + } + goto _1 + _1: + ; + i = i + 1 + pRight += 80 + pLeft += 80 + } + return 0 +} + +// C documentation +// +// /* +// ** Scan the expression list that is the argument to RETURNING looking +// ** for subqueries that depend on the table which is being modified in the +// ** statement that is hosting the RETURNING clause (pTab). Mark all such +// ** subqueries as SF_Correlated. If the subqueries are part of an +// ** expression, mark the expression as EP_VarSelect. +// ** +// ** https://sqlite.org/forum/forumpost/2c83569ce8945d39 +// */ +func _sqlite3ProcessReturningSubqueries(tls *libc.TLS, pEList uintptr, pTab uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_sqlite3ExprWalkNoop) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3ReturningSubqueryCorrelated) + *(*uintptr)(unsafe.Pointer(bp + 40)) = pTab + _sqlite3WalkExprList(tls, bp, pEList) + if (**(**TWalker)(__ccgo_up(bp))).FeCode != 0 { + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_sqlite3ReturningSubqueryVarSelect) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + _sqlite3WalkExprList(tls, bp, pEList) + } +} + +// C documentation +// +// /* +// ** Append to pStr text that is the SQL literal representation of the +// ** value contained in pValue. +// */ +func _sqlite3QuoteValue(tls *libc.TLS, pStr uintptr, pValue uintptr, bEscape int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var nBlob Ti64 + var zArg, zBlob, zText, v2 uintptr + _, _, _, _, _, _ = i, nBlob, zArg, zBlob, zText, v2 + /* As currently implemented, the string must be initially empty. + ** we might relax this requirement in the future, but that will + ** require enhancements to the implementation. */ + switch Xsqlite3_value_type(tls, pValue) { + case int32(SQLITE_FLOAT): + /* ,--- Show infinity as 9.0e+999 + ** | + ** | ,--- 17 precision guarantees round-trip + ** v v */ + Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+16903, libc.VaList(bp+8, Xsqlite3_value_double(tls, pValue))) + case int32(SQLITE_INTEGER): + Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+1463, libc.VaList(bp+8, Xsqlite3_value_int64(tls, pValue))) + case int32(SQLITE_BLOB): + zBlob = Xsqlite3_value_blob(tls, pValue) + nBlob = int64(Xsqlite3_value_bytes(tls, pValue)) + /* No encoding change */ + _sqlite3StrAccumEnlarge(tls, pStr, nBlob*int64(2)+int64(4)) + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(pStr)).FaccError) == 0 { + zText = (*TStrAccum)(unsafe.Pointer(pStr)).FzText + i = 0 + for { + if !(int64(i) < nBlob) { + break + } + **(**int8)(__ccgo_up(zText + uintptr(i*int32(2)+int32(2)))) = _hexdigits[int32(**(**int8)(__ccgo_up(zBlob + uintptr(i))))>>int32(4)&int32(0x0F)] + **(**int8)(__ccgo_up(zText + uintptr(i*int32(2)+int32(3)))) = _hexdigits[int32(**(**int8)(__ccgo_up(zBlob + uintptr(i))))&int32(0x0F)] + goto _1 + _1: + ; + i = i + 1 + } + **(**int8)(__ccgo_up(zText + uintptr(nBlob*int64(2)+int64(2)))) = int8('\'') + **(**int8)(__ccgo_up(zText + uintptr(nBlob*int64(2)+int64(3)))) = int8('\000') + **(**int8)(__ccgo_up(zText)) = int8('X') + **(**int8)(__ccgo_up(zText + 1)) = int8('\'') + (*TStrAccum)(unsafe.Pointer(pStr)).FnChar = libc.Uint32FromInt64(nBlob*int64(2) + int64(3)) + } + case int32(SQLITE_TEXT): + zArg = Xsqlite3_value_text(tls, pValue) + if bEscape != 0 { + v2 = __ccgo_ts + 16911 + } else { + v2 = __ccgo_ts + 12269 + } + Xsqlite3_str_appendf(tls, pStr, v2, libc.VaList(bp+8, zArg)) + default: + Xsqlite3_str_append(tls, pStr, __ccgo_ts+1703, int32(4)) + break + } +} + +// C documentation +// +// /* +// ** Check to see if pExpr references any tables in pSrcList. +// ** Possible return values: +// ** +// ** 1 pExpr does references a table in pSrcList. +// ** +// ** 0 pExpr references some table that is not defined in either +// ** pSrcList or in subqueries of pExpr itself. +// ** +// ** -1 pExpr only references no tables at all, or it only +// ** references tables defined in subqueries of pExpr itself. +// ** +// ** As currently used, pExpr is always an aggregate function call. That +// ** fact is exploited for efficiency. +// */ +func _sqlite3ReferencesSrcList(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSrcList uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var _ /* w at bp+0 */ TWalker + var _ /* x at bp+48 */ TRefSrcList + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+48, 0, uint64(32), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprRefToSrcList) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_selectRefEnter) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = __ccgo_fp(_selectRefLeave) + *(*uintptr)(unsafe.Pointer(bp + 40)) = bp + 48 + (**(**TRefSrcList)(__ccgo_up(bp + 48))).Fdb = (*TParse)(unsafe.Pointer(pParse)).Fdb + (**(**TRefSrcList)(__ccgo_up(bp + 48))).FpRef = pSrcList + _sqlite3WalkExprList(tls, bp, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3WalkExprList(tls, bp, *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32))) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3WalkExpr(tls, bp, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpFilter) + } + if (**(**TRefSrcList)(__ccgo_up(bp + 48))).FaiExclude != 0 { + _sqlite3DbNNFreeNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (**(**TRefSrcList)(__ccgo_up(bp + 48))).FaiExclude) + } + if libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode)&int32(0x01) != 0 { + return int32(1) + } else { + if (**(**TWalker)(__ccgo_up(bp))).FeCode != 0 { + return 0 + } else { + return -int32(1) + } + } + return r +} + +// C documentation +// +// /* +// ** Re-register the built-in LIKE functions. The caseSensitive +// ** parameter determines whether or not the LIKE operator is case +// ** sensitive. +// */ +func _sqlite3RegisterLikeFunctions(tls *libc.TLS, db uintptr, caseSensitive int32) { + var flags, nArg int32 + var pDef, pInfo uintptr + _, _, _, _ = flags, nArg, pDef, pInfo + if caseSensitive != 0 { + pInfo = uintptr(unsafe.Pointer(&_likeInfoAlt)) + flags = libc.Int32FromInt32(SQLITE_FUNC_LIKE) | libc.Int32FromInt32(SQLITE_FUNC_CASE) + } else { + pInfo = uintptr(unsafe.Pointer(&_likeInfoNorm)) + flags = int32(SQLITE_FUNC_LIKE) + } + nArg = int32(2) + for { + if !(nArg <= int32(3)) { + break + } + _sqlite3CreateFunc(tls, db, __ccgo_ts+16949, nArg, int32(SQLITE_UTF8), pInfo, __ccgo_fp(_likeFunc), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + pDef = _sqlite3FindFunction(tls, db, __ccgo_ts+16949, nArg, uint8(SQLITE_UTF8), uint8(0)) + /* The sqlite3CreateFunc() call above cannot fail + ** because the "like" SQL-function already exists */ + **(**Tu32)(__ccgo_up(pDef + 4)) |= libc.Uint32FromInt32(flags) + **(**Tu32)(__ccgo_up(pDef + 4)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) + goto _1 + _1: + ; + nArg = nArg + 1 + } +} + +// C documentation +// +// /* +// ** This routine does per-connection function registration. Most +// ** of the built-in functions above are part of the global function set. +// ** This routine only deals with those that are not global. +// */ +func _sqlite3RegisterPerConnectionBuiltinFunctions(tls *libc.TLS, db uintptr) { + var rc int32 + _ = rc + rc = Xsqlite3_overload_function(tls, db, __ccgo_ts+16943, int32(2)) + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } +} + +// C documentation +// +// /* +// ** Generate code for the REINDEX command. +// ** +// ** REINDEX -- 1 +// ** REINDEX -- 2 +// ** REINDEX ?.? -- 3 +// ** REINDEX ?.? -- 4 +// ** REINDEX EXPRESSIONS -- 5 +// ** +// ** Form 1 causes all indexes in all attached databases to be rebuilt. +// ** Form 2 rebuilds all indexes in all databases that use the named +// ** collating function. Forms 3 and 4 rebuild the named index or all +// ** indexes associated with the named table, respectively. Form 5 +// ** rebuilds all expression indexes in addition to all collations, +// ** indexes, or tables named "EXPRESSIONS". +// ** +// ** If the name is ambiguous such that it matches two or more of +// ** forms 2 through 5, then rebuild the union of all matching indexes, +// ** taken care to avoid rebuilding the same index more than once. +// */ +func _sqlite3Reindex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bAll, bMatch, iDb, iReDb, isExprIdx int32 + var db, k, pDb, pIdx, pReIndex, pReTab, pTab, z, zColl, zDb, v1 uintptr + var v2 bool + var _ /* pObjName at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bAll, bMatch, db, iDb, iReDb, isExprIdx, k, pDb, pIdx, pReIndex, pReTab, pTab, z, zColl, zDb, v1, v2 + z = uintptr(0) /* Name of a table or index or collation */ + zDb = uintptr(0) /* Name of the database */ + iReDb = -int32(1) /* The database index number */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Name of the table or index to be reindexed */ + bMatch = 0 /* At least one name match */ + zColl = uintptr(0) /* Rebuild indexes using this collation */ + pReTab = uintptr(0) /* Rebuild all indexes of this table */ + pReIndex = uintptr(0) /* Rebuild this index */ + isExprIdx = 0 /* Rebuild all expression indexes */ + bAll = 0 /* Rebuild all indexes */ + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + return + } + if pName1 == uintptr(0) { + /* rebuild all indexes */ + bMatch = int32(1) + bAll = int32(1) + } else { + if pName2 == uintptr(0) || (*TToken)(unsafe.Pointer(pName2)).Fz == uintptr(0) { + z = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pName1) + if z == uintptr(0) { + return + } + } else { + iReDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp) + if iReDb < 0 { + return + } + z = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if z == uintptr(0) { + return + } + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iReDb)*32))).FzDbSName + } + } + if !(bAll != 0) { + if zDb == uintptr(0) && _sqlite3StrICmp(tls, z, __ccgo_ts+16570) == 0 { + isExprIdx = int32(1) + bMatch = int32(1) + } + if zDb == uintptr(0) && _sqlite3FindCollSeq(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, z, 0) != uintptr(0) { + zColl = z + bMatch = int32(1) + } + if v2 = zColl == uintptr(0); v2 { + v1 = _sqlite3FindTable(tls, db, z, zDb) + pReTab = v1 + } + if v2 && v1 != uintptr(0) { + bMatch = int32(1) + } + if v2 = zColl == uintptr(0); v2 { + v1 = _sqlite3FindIndex(tls, db, z, zDb) + pReIndex = v1 + } + if v2 && v1 != uintptr(0) { + bMatch = int32(1) + } + } + if bMatch != 0 { + iDb = 0 + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + for { + if !(iDb < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if iReDb >= 0 && iReDb != iDb { + goto _5 + } + k = (*THash)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema + 8)).Ffirst + for { + if !(k != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(k)).Fdata + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + goto _6 + } + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if bAll != 0 || pTab == pReTab || pIdx == pReIndex || isExprIdx != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x800>>11)) != 0 || zColl != uintptr(0) && _collationMatch(tls, zColl, pIdx) != 0 { + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + _sqlite3RefillIndex(tls, pParse, pIdx, -int32(1)) + } + goto _7 + _7: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } /* End loop over indexes of pTab */ + goto _6 + _6: + ; + k = (*THashElem)(unsafe.Pointer(k)).Fnext + } /* End loop over tables of iDb */ + goto _5 + _5: + ; + iDb = iDb + 1 + pDb += 32 + } /* End loop over databases */ + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16582, 0) + } + _sqlite3DbFree(tls, db, z) + return +} + +// C documentation +// +// /* +// ** Remove all nodes that are part of expression pExpr from the rename list. +// */ +func _sqlite3RenameExprUnmap(tls *libc.TLS, pParse uintptr, pExpr uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var eMode Tu8 + var _ /* sWalker at bp+0 */ TWalker + _ = eMode + eMode = (*TParse)(unsafe.Pointer(pParse)).FeParseMode + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_renameUnmapExprCb) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_renameUnmapSelectCb) + (*TParse)(unsafe.Pointer(pParse)).FeParseMode = uint8(PARSE_MODE_UNMAP) + _sqlite3WalkExpr(tls, bp, pExpr) + (*TParse)(unsafe.Pointer(pParse)).FeParseMode = eMode +} + +// C documentation +// +// /* +// ** Remove all nodes that are part of expression-list pEList from the +// ** rename list. +// */ +func _sqlite3RenameExprlistUnmap(tls *libc.TLS, pParse uintptr, pEList uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var _ /* sWalker at bp+0 */ TWalker + _ = i + if pEList != 0 { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_renameUnmapExprCb) + _sqlite3WalkExprList(tls, bp, pEList) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName) + } + goto _1 + _1: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** The following routines are substitutes for constants SQLITE_CORRUPT, +// ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_NOMEM and possibly other error +// ** constants. They serve two purposes: +// ** +// ** 1. Serve as a convenient place to set a breakpoint in a debugger +// ** to detect when version error conditions occurs. +// ** +// ** 2. Invoke sqlite3_log() to provide the source code location where +// ** a low-level error is first detected. +// */ +func _sqlite3ReportError(tls *libc.TLS, iErr int32, lineno int32, zType uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + Xsqlite3_log(tls, iErr, __ccgo_ts+26593, libc.VaList(bp+8, zType, lineno, uintptr(20)+Xsqlite3_sourceid(tls))) + return iErr +} + +// C documentation +// +// /* +// ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of +// ** the SELECT statement pSelect. If any term is reference to a +// ** result set expression (as determined by the ExprList.a.u.x.iOrderByCol +// ** field) then convert that term into a copy of the corresponding result set +// ** column. +// ** +// ** If any errors are detected, add an error message to pParse and +// ** return non-zero. Return zero if no errors are seen. +// */ +func _sqlite3ResolveOrderGroupBy(tls *libc.TLS, pParse uintptr, pSelect uintptr, pOrderBy uintptr, zType uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pEList, pItem uintptr + var i int32 + _, _, _, _ = db, i, pEList, pItem + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pOrderBy == uintptr(0) || (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return 0 + } + if (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8070, libc.VaList(bp+8, zType)) + return int32(1) + } + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + /* sqlite3SelectNew() guarantees this */ + i = 0 + pItem = pOrderBy + 8 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + if (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol != 0 { + if libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol) > (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + _resolveOutOfRangeError(tls, pParse, zType, i+int32(1), (*TExprList)(unsafe.Pointer(pEList)).FnExpr, uintptr(0)) + return int32(1) + } + _resolveAlias(tls, pParse, pEList, libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol)-int32(1), (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr, 0) + } + goto _1 + _1: + ; + i = i + 1 + pItem += 32 + } + return 0 +} + +// C documentation +// +// /* +// ** Resolve names in expressions that can only reference a single table +// ** or which cannot reference any tables at all. Examples: +// ** +// ** "type" flag +// ** ------------ +// ** (1) CHECK constraints NC_IsCheck +// ** (2) WHERE clauses on partial indices NC_PartIdx +// ** (3) Expressions in indexes on expressions NC_IdxExpr +// ** (4) Expression arguments to VACUUM INTO. 0 +// ** (5) GENERATED ALWAYS as expressions NC_GenCol +// ** +// ** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN +// ** nodes of the expression is set to -1 and the Expr.iColumn value is +// ** set to the column number. In case (4), TK_COLUMN nodes cause an error. +// ** +// ** Any errors cause an error message to be set in pParse. +// */ +func _sqlite3ResolveSelfReference(tls *libc.TLS, pParse uintptr, pTab uintptr, type1 int32, pExpr uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var pSrc uintptr + var rc, v1 int32 + var _ /* sNC at bp+0 */ TNameContext + var _ /* uSrc at bp+56 */ struct { + FsrcSpace [0][88]Tu8 + FsSrc TSrcList + F__ccgo_pad2 [80]byte + } + _, _, _ = pSrc, rc, v1 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+56, 0, uint64(88), ^t__predefined_size_t(0)) + pSrc = bp + 56 + if pTab != 0 { + (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc = int32(1) + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FzName = (*TTable)(unsafe.Pointer(pTab)).FzName + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FpSTab = pTab + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FiCursor = -int32(1) + if (*TTable)(unsafe.Pointer(pTab)).FpSchema != (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + 1*32))).FpSchema { + /* Cause EP_FromDDL to be set on TK_FUNCTION nodes of non-TEMP + ** schema elements */ + type1 = type1 | int32(NC_FromDDL) + } + } + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pSrc + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = type1 | int32(NC_IsDDL) + v1 = _sqlite3ResolveExprNames(tls, bp, pExpr) + rc = v1 + if v1 != SQLITE_OK { + return rc + } + if pList != 0 { + rc = _sqlite3ResolveExprListNames(tls, bp, pList) + } + return rc +} + +// C documentation +// +// /* +// ** Return a pointer to a buffer containing a usable rowid alias for table +// ** pTab. An alias is usable if there is not an explicit user-defined column +// ** of the same name. +// */ +func _sqlite3RowidAlias(tls *libc.TLS, pTab uintptr) (r uintptr) { + var azOpt [3]uintptr + var ii int32 + _, _ = azOpt, ii + azOpt = [3]uintptr{ + 0: __ccgo_ts + 8533, + 1: __ccgo_ts + 8541, + 2: __ccgo_ts + 8547, + } + ii = 0 + for { + if !(ii < libc.Int32FromUint64(libc.Uint64FromInt64(24)/libc.Uint64FromInt64(8))) { + break + } + if _sqlite3ColumnIndex(tls, pTab, azOpt[ii]) < 0 { + return azOpt[ii] + } + goto _1 + _1: + ; + ii = ii + 1 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Code an OP_Halt due to non-unique rowid. +// */ +func _sqlite3RowidConstraint(tls *libc.TLS, pParse uintptr, onError int32, pTab uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc int32 + var zMsg uintptr + _, _ = rc, zMsg + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) >= 0 { + zMsg = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+13976, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TTable)(unsafe.Pointer(pTab)).FiPKey)*16))).FzCnName)) + rc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(6)<= int32(TK_WINDOW) { + if libc.AtomicLoadNInt32(db+432, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0 { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_INTERRUPT) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + break + } + if **(**int32)(__ccgo_up(bp)) == int32(TK_SPACE) { + zSql = zSql + uintptr(n) + continue + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + /* Upon reaching the end of input, call the parser two more times + ** with tokens TK_SEMI and 0, in that order. */ + if lastTokenParsed == int32(TK_SEMI) { + **(**int32)(__ccgo_up(bp)) = 0 + } else { + if lastTokenParsed == 0 { + break + } else { + **(**int32)(__ccgo_up(bp)) = int32(TK_SEMI) + } + } + n = 0 + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_WINDOW) { + **(**int32)(__ccgo_up(bp)) = _analyzeWindowKeyword(tls, zSql+6) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_OVER) { + **(**int32)(__ccgo_up(bp)) = _analyzeOverKeyword(tls, zSql+4, lastTokenParsed) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_FILTER) { + **(**int32)(__ccgo_up(bp)) = _analyzeFilterKeyword(tls, zSql+6, lastTokenParsed) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_COMMENT) && ((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00040))<declareVtab flag is set, do not delete any table + ** structure built up in pParse->pNewTable. The calling code (see vtab.c) + ** will take responsibility for freeing the Table structure. + */ + _sqlite3DeleteTable(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTable) + } + if (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger != 0 && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + _sqlite3DeleteTrigger(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger) + } + if (*TParse)(unsafe.Pointer(pParse)).FpVList != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpVList) + } + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = pParentParse + return nErr +} + +/************** End of tokenize.c ********************************************/ +/************** Begin file complete.c ****************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** An tokenizer for SQL +** +** This file contains C code that implements the sqlite3_complete() API. +** This code used to be part of the tokenizer.c source file. But by +** separating it out, the code will be automatically omitted from +** static links that do not use it. + */ +/* #include "sqliteInt.h" */ + +/* +** This is defined in tokenize.c. We just have to import the definition. + */ + +/* +** Token types used by the sqlite3_complete() routine. See the header +** comments on that procedure for additional information. + */ + +// C documentation +// +// /* +// ** This routine implements the OP_Vacuum opcode of the VDBE. +// */ +func _sqlite3RunVacuum(tls *libc.TLS, pzErrMsg uintptr, db uintptr, iDb int32, pOut uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var i, isMemDb, nDb, nNew, nRes, rc, v1 int32 + var id, pDb, pMain, pTemp, zDbMain, zFilename, zOut uintptr + var pgflags, saved_mDbFlags, saved_openFlags Tu32 + var saved_flags Tu64 + var saved_mTrace Tu8 + var saved_nChange, saved_nTotalChange Ti64 + var _ /* iRandom at bp+0 */ Tu64 + var _ /* meta at bp+64 */ Tu32 + var _ /* sz at bp+56 */ Ti64 + var _ /* zDbVacuum at bp+8 */ [42]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, id, isMemDb, nDb, nNew, nRes, pDb, pMain, pTemp, pgflags, rc, saved_flags, saved_mDbFlags, saved_mTrace, saved_nChange, saved_nTotalChange, saved_openFlags, zDbMain, zFilename, zOut, v1 + rc = SQLITE_OK /* Saved trace settings */ + pDb = uintptr(0) /* Name of output file */ + pgflags = uint32(PAGER_SYNCHRONOUS_OFF) /* Name of the ATTACH-ed database used for vacuum */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+23063) + return int32(SQLITE_ERROR) /* IMP: R-12218-18073 */ + } + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive > int32(1) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+23103) + return int32(SQLITE_ERROR) /* IMP: R-15610-35227 */ + } + saved_openFlags = (*Tsqlite3)(unsafe.Pointer(db)).FopenFlags + if pOut != 0 { + if Xsqlite3_value_type(tls, pOut) != int32(SQLITE_TEXT) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+23146) + return int32(SQLITE_ERROR) + } + zOut = Xsqlite3_value_text(tls, pOut) + **(**uint32)(__ccgo_up(db + 76)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_OPEN_READONLY)) + **(**uint32)(__ccgo_up(db + 76)) |= libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE)) + } else { + zOut = __ccgo_ts + 1702 + } + /* Save the current value of the database flags so that it can be + ** restored before returning. Then set the writable-schema flag, and + ** disable CHECK and foreign key constraints. */ + saved_flags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + saved_mDbFlags = (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags + saved_nChange = (*Tsqlite3)(unsafe.Pointer(db)).FnChange + saved_nTotalChange = (*Tsqlite3)(unsafe.Pointer(db)).FnTotalChange + saved_mTrace = (*Tsqlite3)(unsafe.Pointer(db)).FmTrace + **(**Tu64)(__ccgo_up(db + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_WriteSchema)|libc.Int32FromInt32(SQLITE_IgnoreChecks)) | libc.Uint64FromInt32(libc.Int32FromInt32(0x00040))< 0) { + rc = int32(SQLITE_ERROR) + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+23195) + goto end_of_vacuum + } + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_VacuumInto) + /* For a VACUUM INTO, the pager-flags are set to the same values as + ** they are for the database being vacuumed, except that PAGER_CACHESPILL + ** is always set. */ + pgflags = uint32(uint64((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).Fsafety_level) | (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(PAGER_FLAGS_MASK)) + /* If the VACUUM INTO target file is a URI filename and if the + ** "reserve=N" query parameter is present, reset the reserve to the + ** amount specified, if the amount is within range */ + zFilename = _sqlite3BtreeGetFilename(tls, pTemp) + if zFilename != 0 { + nNew = int32(Xsqlite3_uri_int64(tls, zFilename, __ccgo_ts+23222, int64(nRes))) + if nNew >= 0 && nNew <= int32(255) { + nRes = nNew + } + } + } + _sqlite3BtreeSetCacheSize(tls, pTemp, (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema)).Fcache_size) + _sqlite3BtreeSetSpillSize(tls, pTemp, _sqlite3BtreeSetSpillSize(tls, pMain, 0)) + _sqlite3BtreeSetPagerFlags(tls, pTemp, pgflags|uint32(PAGER_CACHESPILL)) + /* Begin a transaction and take an exclusive lock on the main database + ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below, + ** to ensure that we do not try to change the page-size on a WAL database. + */ + rc = _execSql(tls, db, pzErrMsg, __ccgo_ts+16447) + if rc != SQLITE_OK { + goto end_of_vacuum + } + if pOut == uintptr(0) { + v1 = int32(2) + } else { + v1 = 0 + } + rc = _sqlite3BtreeBeginTrans(tls, pMain, v1, uintptr(0)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + /* Do not attempt to change the page size for a WAL database */ + if _sqlite3PagerGetJournalMode(tls, _sqlite3BtreePager(tls, pMain)) == int32(PAGER_JOURNALMODE_WAL) && pOut == uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize = 0 + } + if _sqlite3BtreeSetPageSize(tls, pTemp, _sqlite3BtreeGetPageSize(tls, pMain), nRes, 0) != 0 || !(isMemDb != 0) && _sqlite3BtreeSetPageSize(tls, pTemp, (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, nRes, 0) != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + goto end_of_vacuum + } + if int32((*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac) >= 0 { + v1 = int32((*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac) + } else { + v1 = _sqlite3BtreeGetAutoVacuum(tls, pMain) + } + _sqlite3BtreeSetAutoVacuum(tls, pTemp, v1) + /* Query the schema of the main database. Create a mirror schema + ** in the temporary database. + */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(nDb) /* force new CREATE statements into vacuum_db */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+23230, libc.VaList(bp+80, zDbMain)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+23338, libc.VaList(bp+80, zDbMain)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + /* Loop through the tables in the main database. For each, do + ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy + ** the contents to the temporary database. + */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+23392, libc.VaList(bp+80, bp+8, zDbMain, bp+8)) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_Vacuum)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + /* Copy the triggers, views, and virtual tables from the main database + ** over to the temporary database. None of these objects has any + ** associated storage, so all we have to do is copy their entries + ** from the schema table. + */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+23529, libc.VaList(bp+80, bp+8, zDbMain)) + if rc != 0 { + goto end_of_vacuum + } + /* Copy Btree meta values */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(10)/libc.Uint64FromInt64(1))) { + break + } + /* GetMeta() and UpdateMeta() cannot fail in this context because + ** we already have page 1 loaded into cache and marked dirty. */ + _sqlite3BtreeGetMeta(tls, pMain, libc.Int32FromUint8(_aCopy[i]), bp+64) + rc = _sqlite3BtreeUpdateMeta(tls, pTemp, libc.Int32FromUint8(_aCopy[i]), **(**Tu32)(__ccgo_up(bp + 64))+uint32(_aCopy[i+int32(1)])) + if rc != SQLITE_OK { + goto end_of_vacuum + } + goto _3 + _3: + ; + i = i + int32(2) + } + if pOut == uintptr(0) { + rc = _sqlite3BtreeCopyFile(tls, pMain, pTemp) + } + if rc != SQLITE_OK { + goto end_of_vacuum + } + rc = _sqlite3BtreeCommit(tls, pTemp) + if rc != SQLITE_OK { + goto end_of_vacuum + } + if pOut == uintptr(0) { + _sqlite3BtreeSetAutoVacuum(tls, pMain, _sqlite3BtreeGetAutoVacuum(tls, pTemp)) + } + if pOut == uintptr(0) { + nRes = _sqlite3BtreeGetRequestedReserve(tls, pTemp) + rc = _sqlite3BtreeSetPageSize(tls, pMain, _sqlite3BtreeGetPageSize(tls, pTemp), nRes, int32(1)) + } + goto end_of_vacuum +end_of_vacuum: + ; + /* Restore the original value of db->flags */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags = saved_mDbFlags + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = saved_flags + (*Tsqlite3)(unsafe.Pointer(db)).FnChange = saved_nChange + (*Tsqlite3)(unsafe.Pointer(db)).FnTotalChange = saved_nTotalChange + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = saved_mTrace + _sqlite3BtreeSetPageSize(tls, pMain, -int32(1), 0, int32(1)) + /* Currently there is an SQL level transaction open on the vacuum + ** database. No locks are held on any other files (since the main file + ** was committed at the btree level). So it safe to end the transaction + ** by manually setting the autoCommit flag to true and detaching the + ** vacuum database. The vacuum_db journal file is deleted when the pager + ** is closed by the DETACH. + */ + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(1) + if pDb != 0 { + _sqlite3BtreeClose(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + (*TDb)(unsafe.Pointer(pDb)).FpBt = uintptr(0) + (*TDb)(unsafe.Pointer(pDb)).FpSchema = uintptr(0) + } + /* This both clears the schemas and reduces the size of the db->aDb[] + ** array. */ + _sqlite3ResetAllSchemasOfConnection(tls, db) + return rc +} + +/* At this point, there is a write transaction open on both the + ** vacuum database and the main database. Assuming no error occurs, + ** both transactions are closed by this block - the main database + ** transaction by sqlite3BtreeCopyFile() and the other by an explicit + ** call to sqlite3BtreeCommit(). + */ + +// C documentation +// +// /* +// ** Free all resources held by the schema structure. The void* argument points +// ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the +// ** pointer itself, it just cleans up subsidiary resources (i.e. the contents +// ** of the schema hash tables). +// ** +// ** The Schema.cache_size variable is not cleared. +// */ +func _sqlite3SchemaClear(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(912) + defer tls.Free(912) + var pElem, pSchema, pTab, v3 uintptr + var _ /* temp1 at bp+0 */ THash + var _ /* temp2 at bp+24 */ THash + var _ /* xdb at bp+48 */ Tsqlite3 + _, _, _, _ = pElem, pSchema, pTab, v3 + pSchema = p + libc.X__builtin___memset_chk(tls, bp+48, 0, uint64(864), ^t__predefined_size_t(0)) + **(**THash)(__ccgo_up(bp)) = (*TSchema)(unsafe.Pointer(pSchema)).FtblHash + **(**THash)(__ccgo_up(bp + 24)) = (*TSchema)(unsafe.Pointer(pSchema)).FtrigHash + _sqlite3HashInit(tls, pSchema+56) + _sqlite3HashClear(tls, pSchema+32) + pElem = (*THash)(unsafe.Pointer(bp + 24)).Ffirst + for { + if !(pElem != 0) { + break + } + _sqlite3DeleteTrigger(tls, bp+48, (*THashElem)(unsafe.Pointer(pElem)).Fdata) + goto _1 + _1: + ; + pElem = (*THashElem)(unsafe.Pointer(pElem)).Fnext + } + _sqlite3HashClear(tls, bp+24) + _sqlite3HashInit(tls, pSchema+8) + pElem = (*THash)(unsafe.Pointer(bp)).Ffirst + for { + if !(pElem != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(pElem)).Fdata + _sqlite3DeleteTable(tls, bp+48, pTab) + goto _2 + _2: + ; + pElem = (*THashElem)(unsafe.Pointer(pElem)).Fnext + } + _sqlite3HashClear(tls, bp) + _sqlite3HashClear(tls, pSchema+80) + (*TSchema)(unsafe.Pointer(pSchema)).FpSeqTab = uintptr(0) + if libc.Int32FromUint16((*TSchema)(unsafe.Pointer(pSchema)).FschemaFlags)&int32(DB_SchemaLoaded) != 0 { + (*TSchema)(unsafe.Pointer(pSchema)).FiGeneration = (*TSchema)(unsafe.Pointer(pSchema)).FiGeneration + 1 + } + v3 = pSchema + 114 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(DB_SchemaLoaded) | libc.Int32FromInt32(DB_ResetWanted))) +} + +// C documentation +// +// /* +// ** Generate byte-code for the SELECT statement given in the p argument. +// ** +// ** The results are returned according to the SelectDest structure. +// ** See comments in sqliteInt.h for further information. +// ** +// ** This routine returns the number of errors. If any errors are +// ** encountered, then an appropriate error message is left in +// ** pParse->zErrMsg. +// ** +// ** This routine does NOT free the Select structure passed in. The +// ** calling function needs to do that. +// ** +// ** This is a long function. The following is an outline of the processing +// ** steps, with tags referencing various milestones: +// ** +// ** * Resolve names and similar preparation tag-select-0100 +// ** * Scan of the FROM clause tag-select-0200 +// ** + OUTER JOIN strength reduction tag-select-0220 +// ** + Sub-query ORDER BY removal tag-select-0230 +// ** + Query flattening tag-select-0240 +// ** * Separate subroutine for compound-SELECT tag-select-0300 +// ** * WHERE-clause constant propagation tag-select-0330 +// ** * Count()-of-VIEW optimization tag-select-0350 +// ** * Scan of the FROM clause again tag-select-0400 +// ** + Authorize unreferenced tables tag-select-0410 +// ** + Predicate push-down optimization tag-select-0420 +// ** + Omit unused subquery columns optimization tag-select-0440 +// ** + Generate code to implement subqueries tag-select-0480 +// ** - Co-routines tag-select-0482 +// ** - Reuse previously computed CTE tag-select-0484 +// ** - REuse previously computed VIEW tag-select-0486 +// ** - Materialize a VIEW or CTE tag-select-0488 +// ** * DISTINCT ORDER BY -> GROUP BY optimization tag-select-0500 +// ** * Set up for ORDER BY tag-select-0600 +// ** * Create output table tag-select-0630 +// ** * Prepare registers for LIMIT tag-select-0650 +// ** * Setup for DISTINCT tag-select-0680 +// ** * Generate code for non-aggregate and non-GROUP BY tag-select-0700 +// ** * Generate code for aggregate and/or GROUP BY tag-select-0800 +// ** + GROUP BY queries tag-select-0810 +// ** + non-GROUP BY queries tag-select-0820 +// ** - Special case of count() w/o GROUP BY tag-select-0821 +// ** - General case of non-GROUP BY aggregates tag-select-0822 +// ** * Sort results, as needed tag-select-0900 +// ** * Internal self-checks tag-select-1000 +// */ +func _sqlite3Select(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var addr1, addrEnd, addrGosub, addrOutputRow, addrReset, addrSetAbort, addrSortingIdx, addrTop, addrTopOfLoop, eDist, eDist1, groupBySort, i, iAMem, iAbortFlag, iBMem, iBreak, iCont, iCsr, iDb, iDb1, iEnd, iOrderByCol, iUseFlag, ii, isAgg, j, k, nCol, nGroupBy, onceAddr, orderByGrp, rc, regAcc, regBase, regGosub, regOutputRow, regRecord, regReset, sortOut, sortPTab, topAddr, v12, v15 int32 + var db, p0, pAggInfo, pBase, pBest, pCol, pCteUse, pCteUse1, pDistinct, pDistinct1, pEList, pExpr, pF, pF1, pGroupBy, pHaving, pI2, pIdx, pItem, pItem1, pItem2, pKeyInfo, pKeyInfo1, pKeyInfo2, pPrior, pPriorSubq, pSub, pSub1, pSubq, pTab, pTab1, pTabList, pWInfo, pWhere, pWin, pX, v, zDb, zSavedAuthContext, v1, v3 uintptr + var distFlag, distFlag1, wctrlFlags Tu16 + var iRoot TPgno + var minMaxFlag Tu8 + var _ /* dest at bp+72 */ TSelectDest + var _ /* pMinMaxOrderBy at bp+64 */ uintptr + var _ /* sDistinct at bp+0 */ TDistinctCtx + var _ /* sNC at bp+112 */ TNameContext + var _ /* sSort at bp+16 */ TSortCtx + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, addrEnd, addrGosub, addrOutputRow, addrReset, addrSetAbort, addrSortingIdx, addrTop, addrTopOfLoop, db, distFlag, distFlag1, eDist, eDist1, groupBySort, i, iAMem, iAbortFlag, iBMem, iBreak, iCont, iCsr, iDb, iDb1, iEnd, iOrderByCol, iRoot, iUseFlag, ii, isAgg, j, k, minMaxFlag, nCol, nGroupBy, onceAddr, orderByGrp, p0, pAggInfo, pBase, pBest, pCol, pCteUse, pCteUse1, pDistinct, pDistinct1, pEList, pExpr, pF, pF1, pGroupBy, pHaving, pI2, pIdx, pItem, pItem1, pItem2, pKeyInfo, pKeyInfo1, pKeyInfo2, pPrior, pPriorSubq, pSub, pSub1, pSubq, pTab, pTab1, pTabList, pWInfo, pWhere, pWin, pX, rc, regAcc, regBase, regGosub, regOutputRow, regRecord, regReset, sortOut, sortPTab, topAddr, v, wctrlFlags, zDb, zSavedAuthContext, v1, v12, v15, v3 /* True for select lists like "count(*)" */ + pEList = uintptr(0) /* The HAVING clause. May be NULL */ + pAggInfo = uintptr(0) /* Aggregate information */ + rc = int32(1) /* The database connection */ + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) /* Flag for min/max queries */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = _sqlite3GetVdbe(tls, pParse) + if p == uintptr(0) || (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(1) + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_SELECT), uintptr(0), uintptr(0), uintptr(0)) != 0 { + return int32(1) + } + /* tag-select-0100 */ + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) <= int32(SRT_DistQueue) { + /* All of these destinations are also able to ignore the ORDER BY clause */ + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprListDeleteGeneric), (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + } + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Distinct) + } + _sqlite3SelectPrep(tls, pParse, p, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto select_end + } + /* If the SF_UFSrcCheck flag is set, then this function is being called + ** as part of populating the temp table for an UPDATE...FROM statement. + ** In this case, it is an error if the target object (pSrc->a[0]) name + ** or alias is duplicated within FROM clause (pSrc->a[1..n]). + ** + ** Postgres disallows this case too. The reason is that some other + ** systems handle this case differently, and not all the same way, + ** which is just confusing. To avoid this, we follow PG's lead and + ** disallow it altogether. */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_UFSrcCheck) != 0 { + p0 = (*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + if _sameSrcAlias(tls, p0, (*TSelect)(unsafe.Pointer(p)).FpSrc) != 0 { + if (*TSrcItem)(unsafe.Pointer(p0)).FzAlias != 0 { + v1 = (*TSrcItem)(unsafe.Pointer(p0)).FzAlias + } else { + v1 = (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(p0)).FpSTab)).FzName + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21979, libc.VaList(bp+176, v1)) + goto select_end + } + /* Clear the SF_UFSrcCheck flag. The check has already been performed, + ** and leaving this flag set can cause errors if a compound sub-query + ** in p->pSrc is flattened into this query and this function called + ** again as part of compound SELECT processing. */ + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_UFSrcCheck) + } + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) == int32(SRT_Output) { + _sqlite3GenerateColumnNames(tls, pParse, p) + } + if _sqlite3WindowRewrite(tls, pParse, p) != 0 { + goto select_end + } + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + isAgg = libc.BoolInt32((*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Aggregate) != uint32(0)) + libc.X__builtin___memset_chk(tls, bp+16, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + /* Try to do various optimizations (flattening subqueries, and strength + ** reduction of join operators) in the FROM clause up into the main query + ** tag-select-0200 + */ + i = 0 + for { + if !(!((*TSelect)(unsafe.Pointer(p)).FpPrior != 0) && i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + pItem = pTabList + 8 + uintptr(i)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { + v1 = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + } else { + v1 = uintptr(0) + } + pSub = v1 + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + /* The expander should have already created transient Table objects + ** even for FROM clause elements such as subqueries that do not correspond + ** to a real table */ + /* Try to simplify joins: + ** + ** LEFT JOIN -> JOIN + ** RIGHT JOIN -> JOIN + ** FULL JOIN -> RIGHT JOIN + ** + ** If terms of the i-th table are used in the WHERE clause in such a + ** way that the i-th table cannot be the NULL row of a join, then + ** perform the appropriate simplification. This is called + ** "OUTER JOIN strength reduction" in the SQLite documentation. + ** tag-select-0220 + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0 && _sqlite3ExprImpliesNonNullRow(tls, (*TSelect)(unsafe.Pointer(p)).FpWhere, (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor, libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LTORJ)) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_SimplifyJoin)) == uint32(0) { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + v1 = pItem + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(JT_LEFT)) + } else { + v1 = pItem + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(JT_LEFT) | libc.Int32FromInt32(JT_OUTER))) + _unsetJoinExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpWhere, (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor, 0) + } + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + j = i + int32(1) + for { + if !(j < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + pI2 = pTabList + 8 + uintptr(j)*80 + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pI2)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pI2)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + v1 = pI2 + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(JT_RIGHT)) + } else { + v1 = pI2 + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(JT_RIGHT) | libc.Int32FromInt32(JT_OUTER))) + _unsetJoinExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpWhere, (*TSrcItem)(unsafe.Pointer(pI2)).FiCursor, int32(1)) + } + } + goto _6 + _6: + ; + j = j + 1 + } + j = (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc - int32(1) + for { + if !(j >= 0) { + break + } + v1 = pTabList + 8 + uintptr(j)*80 + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(JT_LTORJ)) + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80))).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + break + } + goto _9 + _9: + ; + j = j - 1 + } + } + } + /* No further action if this term of the FROM clause is not a subquery */ + if pSub == uintptr(0) { + goto _2 + } + /* Catch mismatch in the declared columns of a view and the number of + ** columns in the SELECT on the RHS */ + if int32((*TTable)(unsafe.Pointer(pTab)).FnCol) != (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpEList)).FnExpr { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22033, libc.VaList(bp+176, int32((*TTable)(unsafe.Pointer(pTab)).FnCol), (*TTable)(unsafe.Pointer(pTab)).FzName, (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpEList)).FnExpr)) + goto select_end + } + /* Do not attempt the usual optimizations (flattening and ORDER BY + ** elimination) on a MATERIALIZED common table expression because + ** a MATERIALIZED common table expression is an optimization fence. + */ + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x200>>9) != 0 && libc.Int32FromUint8((*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 56)))).FeM10d) == M10d_Yes { + goto _2 + } + /* Do not try to flatten an aggregate subquery. + ** + ** Flattening an aggregate subquery is only possible if the outer query + ** is not a join. But if the outer query is not a join, then the subquery + ** will be implemented as a co-routine and there is no advantage to + ** flattening in that case. + */ + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&uint32(SF_Aggregate) != uint32(0) { + goto _2 + } + /* tag-select-0230: + ** If a FROM-clause subquery has an ORDER BY clause that is not + ** really doing anything, then delete it now so that it does not + ** interfere with query flattening. See the discussion at + ** https://sqlite.org/forum/forumpost/2d76f2bcf65d256a + ** + ** Beware of these cases where the ORDER BY clause may not be safely + ** omitted: + ** + ** (1) There is also a LIMIT clause + ** (2) The subquery was added to help with window-function + ** processing + ** (3) The subquery is in the FROM clause of an UPDATE + ** (4) The outer query uses an aggregate function other than + ** the built-in count(), min(), or max(). + ** (5) The ORDER BY isn't going to accomplish anything because + ** one of: + ** (a) The outer query has a different ORDER BY clause + ** (b) The subquery is part of a join + ** See forum post 062d576715d277c8 + ** (6) The subquery is not a recursive CTE. ORDER BY has a different + ** meaning for recursive CTEs and this optimization does not + ** apply. + ** + ** Also retain the ORDER BY if the OmitOrderBy optimization is disabled. + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != uintptr(0) && ((*TSelect)(unsafe.Pointer(p)).FpOrderBy != uintptr(0) || (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc > int32(1)) && (*TSelect)(unsafe.Pointer(pSub)).FpLimit == uintptr(0) && (*TSelect)(unsafe.Pointer(pSub)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_OrderByReqd)|libc.Int32FromInt32(SF_Recursive)) == uint32(0) && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_OrderByReqd) == uint32(0) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OmitOrderBy)) == uint32(0) { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprListDeleteGeneric), (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy) + (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0) + } + /* If the outer query contains a "complex" result set (that is, + ** if the result set of the outer query uses functions or subqueries) + ** and if the subquery contains an ORDER BY clause and if + ** it will be implemented as a co-routine, then do not flatten. This + ** restriction allows SQL constructs like this: + ** + ** SELECT expensive_function(x) + ** FROM (SELECT x FROM tab ORDER BY y LIMIT 10); + ** + ** The expensive_function() is only computed on the 10 rows that + ** are output, rather than every row of the table. + ** + ** The requirement that the outer query have a complex result set + ** means that flattening does occur on simpler SQL constraints without + ** the expensive_function() like: + ** + ** SELECT x FROM (SELECT x FROM tab ORDER BY y LIMIT 10); + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != uintptr(0) && i == 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_ComplexResult) != uint32(0) && ((*TSrcList)(unsafe.Pointer(pTabList)).FnSrc == int32(1) || libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + 1*80))).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)) != 0) { + goto _2 + } + /* tag-select-0240 */ + if _flattenSubquery(tls, pParse, p, i, isAgg) != 0 { + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto select_end + } + /* This subquery can be absorbed into its parent. */ + i = -int32(1) + } + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + if !(libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) <= libc.Int32FromInt32(SRT_Fifo)) { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + } + goto _2 + _2: + ; + i = i + 1 + } + /* Handle compound SELECT statements using the separate multiSelect() + ** procedure. tag-select-0300 + */ + if (*TSelect)(unsafe.Pointer(p)).FpPrior != 0 { + rc = _multiSelect(tls, pParse, p, pDest) + if (*TSelect)(unsafe.Pointer(p)).FpNext == uintptr(0) { + _sqlite3VdbeExplainPop(tls, pParse) + } + return rc + } + /* If there may be an "EXISTS (SELECT ...)" in the WHERE clause, attempt + ** to change it into a join. */ + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x10>>4)) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_ExistsToJoin)) == uint32(0) { + _existsToJoin(tls, pParse, p, (*TSelect)(unsafe.Pointer(p)).FpWhere) + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + } + /* Do the WHERE-clause constant propagation optimization if this is + ** a join. No need to spend time on this operation for non-join queries + ** as the equivalent optimization will be handled by query planner in + ** sqlite3WhereBegin(). tag-select-0330 + */ + if (*TSelect)(unsafe.Pointer(p)).FpWhere != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpWhere)).Fop) == int32(TK_AND) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_PropagateConst)) == uint32(0) && _propagateConstants(tls, pParse, p) != 0 { + } else { + } + /* tag-select-0350 */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_QueryFlattener)|libc.Int32FromInt32(SQLITE_CountOfView)) == uint32(0) && _countOfViewOptimization(tls, pParse, p) != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + } + /* Loop over all terms in the FROM clause and do two things for each term: + ** + ** (1) Authorize unreferenced tables + ** (2) Generate code for all sub-queries + ** + ** tag-select-0400 + */ + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + pItem1 = pTabList + 8 + uintptr(i)*80 + /* Authorized unreferenced tables. tag-select-0410 + ** + ** Issue SQLITE_READ authorizations with a fake column name for any + ** tables that are referenced but from which no values are extracted. + ** Examples of where these kinds of null SQLITE_READ authorizations + ** would occur: + ** + ** SELECT count(*) FROM t1; -- SQLITE_READ t1."" + ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2."" + ** + ** The fake column name is an empty string. It is possible for a table to + ** have a column named by the empty string, in which case there is no way to + ** distinguish between an unreferenced table and an actual reference to the + ** "" column. The original design was for the fake column name to be a NULL, + ** which would be unambiguous. But legacy authorization callbacks might + ** assume the column name is non-NULL and segfault. The use of an empty + ** string for the fake column name seems safer. + */ + if (*TSrcItem)(unsafe.Pointer(pItem1)).FcolUsed == uint64(0) && (*TSrcItem)(unsafe.Pointer(pItem1)).FzName != uintptr(0) { + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x10000>>16) != 0 { + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(pItem1 + 72))) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x4>>2) != 0 { + zDb = uintptr(0) + } else { + zDb = *(*uintptr)(unsafe.Pointer(pItem1 + 72)) + } + } + _sqlite3AuthCheck(tls, pParse, int32(SQLITE_READ), (*TSrcItem)(unsafe.Pointer(pItem1)).FzName, __ccgo_ts+1702, zDb) + } + /* Generate code for all sub-queries in the FROM clause + */ + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x4>>2) == 0 { + goto _11 + } + pSubq = *(*uintptr)(unsafe.Pointer(pItem1 + 72)) + pSub1 = (*TSubquery)(unsafe.Pointer(pSubq)).FpSelect + /* The code for a subquery should only be generated once. */ + if (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub != 0 { + goto _11 + } + /* Increment Parse.nHeight by the height of the largest expression + ** tree referred to by this, the parent select. The child select + ** may contain expression trees of at most + ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit + ** more conservative than necessary, but much easier than enforcing + ** an exact limit. + */ + **(**int32)(__ccgo_up(pParse + 308)) += _sqlite3SelectExprHeight(tls, p) + /* Make copies of constant WHERE-clause terms in the outer query down + ** inside the subquery. This can help the subquery to run more efficiently. + ** This is the "predicate push-down optimization". tag-select-0420 + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_PushDown)) == uint32(0) && (int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x200>>9) == 0 || libc.Int32FromUint8((*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 56)))).FeM10d) != M10d_Yes && (*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 56)))).FnUse < int32(2)) && _pushDownWhereTerms(tls, pParse, pSub1, (*TSelect)(unsafe.Pointer(p)).FpWhere, pTabList, i) != 0 { + } else { + } + /* Convert unused result columns of the subquery into simple NULL + ** expressions, to avoid unneeded searching and computation. + ** tag-select-0440 + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_NullUnusedCols)) == uint32(0) && _disableUnusedSubqueryResultColumns(tls, pItem1) != 0 { + } + zSavedAuthContext = (*TParse)(unsafe.Pointer(pParse)).FzAuthContext + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = (*TSrcItem)(unsafe.Pointer(pItem1)).FzName + /* Generate byte-code to implement the subquery tag-select-0480 + */ + if _fromClauseTermCanBeCoroutine(tls, pParse, pTabList, i, libc.Int32FromUint32((*TSelect)(unsafe.Pointer(p)).FselFlags)) != 0 { + /* Implement a co-routine that will return a single row of the result + ** set on each invocation. tag-select-0482 + */ + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn = v12 + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn, 0, addrTop) + (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub = addrTop + _sqlite3SelectDestInit(tls, bp+72, int32(SRT_Coroutine), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+22073, libc.VaList(bp+176, pItem1)) + _sqlite3Select(tls, pParse, pSub1, bp+72) + (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem1)).FpSTab)).FnRowLogEst = (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow + libc.SetBitFieldPtr32Uint32(pItem1+24+4, libc.Uint32FromInt32(1), 6, 0x40) + (*TSubquery)(unsafe.Pointer(pSubq)).FregResult = (**(**TSelectDest)(__ccgo_up(bp + 72))).FiSdst + _sqlite3VdbeEndCoroutine(tls, v, (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn) + _sqlite3VdbeJumpHere(tls, v, addrTop-int32(1)) + _sqlite3ClearTempRegCache(tls, pParse) + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x200>>9) != 0 && (*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 56)))).FaddrM9e > 0 { + /* This is a CTE for which materialization code has already been + ** generated. Invoke the subroutine to compute the materialization, + ** then make the pItem->iCursor be a copy of the ephemeral table that + ** holds the result of the materialization. tag-select-0484 */ + pCteUse = *(*uintptr)(unsafe.Pointer(pItem1 + 56)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TCteUse)(unsafe.Pointer(pCteUse)).FregRtn, (*TCteUse)(unsafe.Pointer(pCteUse)).FaddrM9e) + if (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor != (*TCteUse)(unsafe.Pointer(pCteUse)).FiCur { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor, (*TCteUse)(unsafe.Pointer(pCteUse)).FiCur) + } + (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow = (*TCteUse)(unsafe.Pointer(pCteUse)).FnRowEst + } else { + v1 = _isSelfJoinView(tls, pTabList, pItem1, 0, i) + pPrior = v1 + if v1 != uintptr(0) { + pPriorSubq = *(*uintptr)(unsafe.Pointer(pPrior + 72)) + if (*TSubquery)(unsafe.Pointer(pPriorSubq)).FaddrFillSub != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TSubquery)(unsafe.Pointer(pPriorSubq)).FregReturn, (*TSubquery)(unsafe.Pointer(pPriorSubq)).FaddrFillSub) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor, (*TSrcItem)(unsafe.Pointer(pPrior)).FiCursor) + (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow = (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(pPriorSubq)).FpSelect)).FnSelectRow + } else { + onceAddr = 0 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn = v12 + topAddr = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub = topAddr + int32(1) + libc.SetBitFieldPtr32Uint32(pItem1+24+4, libc.Uint32FromInt32(1), 5, 0x20) + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x10>>4) == 0 { + /* If the subquery is not correlated and if we are not inside of + ** a trigger, then we only need to compute the value of the subquery + ** once. */ + onceAddr = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } else { + } + _sqlite3SelectDestInit(tls, bp+72, int32(SRT_EphemTab), (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+22088, libc.VaList(bp+176, pItem1)) + _sqlite3Select(tls, pParse, pSub1, bp+72) + (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem1)).FpSTab)).FnRowLogEst = (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow + if onceAddr != 0 { + _sqlite3VdbeJumpHere(tls, v, onceAddr) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Return), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn, topAddr+int32(1)) + _sqlite3VdbeJumpHere(tls, v, topAddr) + _sqlite3ClearTempRegCache(tls, pParse) + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x200>>9) != 0 && int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x10>>4) == 0 { + pCteUse1 = *(*uintptr)(unsafe.Pointer(pItem1 + 56)) + (*TCteUse)(unsafe.Pointer(pCteUse1)).FaddrM9e = (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub + (*TCteUse)(unsafe.Pointer(pCteUse1)).FregRtn = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + (*TCteUse)(unsafe.Pointer(pCteUse1)).FiCur = (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor + (*TCteUse)(unsafe.Pointer(pCteUse1)).FnRowEst = (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow + } + } + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + **(**int32)(__ccgo_up(pParse + 308)) -= _sqlite3SelectExprHeight(tls, p) + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedAuthContext + goto _11 + _11: + ; + i = i + 1 + } + /* Various elements of the SELECT copied into local variables for + ** convenience */ + pEList = (*TSelect)(unsafe.Pointer(p)).FpEList + pWhere = (*TSelect)(unsafe.Pointer(p)).FpWhere + pGroupBy = (*TSelect)(unsafe.Pointer(p)).FpGroupBy + pHaving = (*TSelect)(unsafe.Pointer(p)).FpHaving + (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct = libc.BoolUint8((*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != uint32(0)) + /* tag-select-0500 + ** + ** If the query is DISTINCT with an ORDER BY but is not an aggregate, and + ** if the select-list is the same as the ORDER BY list, then this query + ** can be rewritten as a GROUP BY. In other words, this: + ** + ** SELECT DISTINCT xyz FROM ... ORDER BY xyz + ** + ** is transformed to: + ** + ** SELECT xyz FROM ... GROUP BY xyz ORDER BY xyz + ** + ** The second form is preferred as a single index (or temp-table) may be + ** used for both the ORDER BY and DISTINCT processing. As originally + ** written the query must use a temp-table for at least one of the ORDER + ** BY and DISTINCT, and an index or separate temp-table for the other. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Distinct)|libc.Int32FromInt32(SF_Aggregate)) == uint32(SF_Distinct) && _sqlite3CopySortOrder(tls, pEList, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy) != 0 && _sqlite3ExprListCompare(tls, pEList, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy, -int32(1)) == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_GroupByOrder)) == uint32(0) && (*TSelect)(unsafe.Pointer(p)).FpWin == uintptr(0) { + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Distinct) + v1 = _sqlite3ExprListDup(tls, db, pEList, 0) + (*TSelect)(unsafe.Pointer(p)).FpGroupBy = v1 + pGroupBy = v1 + if pGroupBy != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { + break + } + *(*Tu16)(unsafe.Pointer(pGroupBy + 8 + uintptr(i)*32 + 24)) = libc.Uint16FromInt32(i + int32(1)) + goto _18 + _18: + ; + i = i + 1 + } + } + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_Aggregate) + /* Notice that even thought SF_Distinct has been cleared from p->selFlags, + ** the sDistinct.isTnct is still set. Hence, isTnct represents the + ** original setting of the SF_Distinct flag, not the current setting */ + (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct = uint8(2) + } + /* If there is an ORDER BY clause, then create an ephemeral index to + ** do the sorting. But this sorting ephemeral index might end up + ** being unused if the data can be extracted in pre-sorted order. + ** If that is the case, then the OP_OpenEphemeral instruction will be + ** changed to an OP_Noop once we figure out that the sorting index is + ** not needed. The sSort.addrSortIndex variable is used to facilitate + ** that change. tag-select-0600 + */ + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy != 0 { + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy, 0, (*TExprList)(unsafe.Pointer(pEList)).FnExpr) + v1 = pParse + 56 + v12 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + (**(**TSortCtx)(__ccgo_up(bp + 16))).FiECursor = v12 + (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex = _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), (**(**TSortCtx)(__ccgo_up(bp + 16))).FiECursor, (*TExprList)(unsafe.Pointer((**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy)).FnExpr+int32(1)+(*TExprList)(unsafe.Pointer(pEList)).FnExpr, 0, pKeyInfo, -int32(9)) + } else { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex = -int32(1) + } + /* If the output is destined for a temporary table, open that table. + ** tag-select-0630 + */ + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) == int32(SRT_EphemTab) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*TExprList)(unsafe.Pointer(pEList)).FnExpr) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_NestedFrom) != 0 { + ii = (*TExprList)(unsafe.Pointer(pEList)).FnExpr - int32(1) + for { + if !(ii > 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32 + 16 + 4))&0x40>>6)) == 0) { + break + } + _sqlite3ExprDelete(tls, db, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32))).FpExpr) + _sqlite3DbFree(tls, db, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32))).FzEName) + (*TExprList)(unsafe.Pointer(pEList)).FnExpr = (*TExprList)(unsafe.Pointer(pEList)).FnExpr - 1 + goto _21 + _21: + ; + ii = ii - 1 + } + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32 + 16 + 4))&0x40>>6)) == 0 { + (*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32))).FpExpr)).Fop = uint8(TK_NULL) + } + goto _22 + _22: + ; + ii = ii + 1 + } + } + } + /* Set the limiter. tag-select-0650 + */ + iEnd = _sqlite3VdbeMakeLabel(tls, pParse) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_FixedLimit) == uint32(0) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(320) /* 4 billion rows */ + } + if (*TSelect)(unsafe.Pointer(p)).FpLimit != 0 { + _computeLimitRegisters(tls, pParse, p, iEnd) + } + if (*TSelect)(unsafe.Pointer(p)).FiLimit == 0 && (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex >= 0 { + _sqlite3VdbeChangeOpcode(tls, v, (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex, uint8(OP_SorterOpen)) + v1 = bp + 16 + 36 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SORTFLAG_UseSorter)) + } + /* Open an ephemeral index to use for the distinct set. tag-select-0680 + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != 0 { + v1 = pParse + 56 + v12 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + (**(**TDistinctCtx)(__ccgo_up(bp))).FtabTnct = v12 + (**(**TDistinctCtx)(__ccgo_up(bp))).FaddrTnct = _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), (**(**TDistinctCtx)(__ccgo_up(bp))).FtabTnct, 0, 0, _sqlite3KeyInfoFromExprList(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpEList, 0, 0), -int32(9)) + _sqlite3VdbeChangeP5(tls, v, uint16(BTREE_UNORDERED)) + (**(**TDistinctCtx)(__ccgo_up(bp))).FeTnctType = uint8(WHERE_DISTINCT_UNORDERED) + } else { + (**(**TDistinctCtx)(__ccgo_up(bp))).FeTnctType = uint8(WHERE_DISTINCT_NOOP) + } + if !(isAgg != 0) && pGroupBy == uintptr(0) { + if (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct != 0 { + v12 = int32(WHERE_WANT_DISTINCT) + } else { + v12 = 0 + } + /* No aggregate functions and no GROUP BY clause. tag-select-0700 */ + wctrlFlags = uint16(libc.Uint32FromInt32(v12) | (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_FixedLimit)) + pWin = (*TSelect)(unsafe.Pointer(p)).FpWin /* Main window object (or NULL) */ + if pWin != 0 { + _sqlite3WindowCodeInit(tls, pParse, p) + } + /* Begin the database scan. */ + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy, (*TSelect)(unsafe.Pointer(p)).FpEList, p, wctrlFlags, int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow)) + if pWInfo == uintptr(0) { + goto select_end + } + if int32(_sqlite3WhereOutputRowCount(tls, pWInfo)) < int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3WhereOutputRowCount(tls, pWInfo) + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) <= int32(SRT_DistQueue) && libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) >= int32(SRT_DistFifo) { + /* TUNING: For a UNION CTE, because UNION is implies DISTINCT, + ** reduce the estimated output row count by 8 (LogEst 30). + ** Search for tag-20250414a to see other cases */ + v1 = p + 2 + *(*TLogEst)(unsafe.Pointer(v1)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v1))) - libc.Int32FromInt32(30)) + } + } + if (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct != 0 && _sqlite3WhereIsDistinct(tls, pWInfo) != 0 { + (**(**TDistinctCtx)(__ccgo_up(bp))).FeTnctType = libc.Uint8FromInt32(_sqlite3WhereIsDistinct(tls, pWInfo)) + } + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy != 0 { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FnOBSat = _sqlite3WhereIsOrdered(tls, pWInfo) + (**(**TSortCtx)(__ccgo_up(bp + 16))).FlabelOBLopt = _sqlite3WhereOrderByLimitOptLabel(tls, pWInfo) + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FnOBSat == (*TExprList)(unsafe.Pointer((**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy)).FnExpr { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = uintptr(0) + } + } + /* If sorting index that was created by a prior OP_OpenEphemeral + ** instruction ended up not being needed, then change the OP_OpenEphemeral + ** into an OP_Noop. + */ + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex >= 0 && (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy == uintptr(0) { + _sqlite3VdbeChangeToNoop(tls, v, (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex) + } + if pWin != 0 { + addrGosub = _sqlite3VdbeMakeLabel(tls, pParse) + iCont = _sqlite3VdbeMakeLabel(tls, pParse) + iBreak = _sqlite3VdbeMakeLabel(tls, pParse) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + regGosub = v12 + _sqlite3WindowCodeStep(tls, pParse, p, pWInfo, regGosub, addrGosub) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, iBreak) + _sqlite3VdbeResolveLabel(tls, v, addrGosub) + (**(**TSortCtx)(__ccgo_up(bp + 16))).FlabelOBLopt = 0 + _selectInnerLoop(tls, pParse, p, -int32(1), bp+16, bp, pDest, iCont, iBreak) + _sqlite3VdbeResolveLabel(tls, v, iCont) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regGosub) + _sqlite3VdbeResolveLabel(tls, v, iBreak) + } else { + /* Use the standard inner loop. */ + _selectInnerLoop(tls, pParse, p, -int32(1), bp+16, bp, pDest, _sqlite3WhereContinueLabel(tls, pWInfo), _sqlite3WhereBreakLabel(tls, pWInfo)) + /* End the database scan loop. + */ + _sqlite3WhereEnd(tls, pWInfo) + } + } else { /* End of processing for this SELECT */ + sortPTab = 0 /* Pseudotable used to decode sorting results */ + sortOut = 0 /* Output register from the sorter */ + orderByGrp = 0 /* True if the GROUP BY and ORDER BY are the same */ + /* Remove any and all aliases between the result set and the + ** GROUP BY clause. + */ + if pGroupBy != 0 { /* For looping over expression in a list */ + k = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr + pItem2 = (*TSelect)(unsafe.Pointer(p)).FpEList + 8 + for { + if !(k > 0) { + break + } + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem2 + 24))).FiAlias = uint16(0) + goto _30 + _30: + ; + k = k - 1 + pItem2 += 32 + } + k = (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + pItem2 = pGroupBy + 8 + for { + if !(k > 0) { + break + } + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem2 + 24))).FiAlias = uint16(0) + goto _31 + _31: + ; + k = k - 1 + pItem2 += 32 + } + if int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) > int32(66) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(66) + } + /* If there is both a GROUP BY and an ORDER BY clause and they are + ** identical, then it may be possible to disable the ORDER BY clause + ** on the grounds that the GROUP BY will cause elements to come out + ** in the correct order. It also may not - the GROUP BY might use a + ** database index that causes rows to be grouped together as required + ** but not actually sorted. Either way, record the fact that the + ** ORDER BY and GROUP BY clauses are the same by setting the orderByGrp + ** variable. */ + if _sqlite3CopySortOrder(tls, pGroupBy, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy) != 0 && _sqlite3ExprListCompare(tls, pGroupBy, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy, -int32(1)) == 0 { + orderByGrp = int32(1) + } + } else { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = 0 + } + /* Create a label to jump to when we want to abort the query */ + addrEnd = _sqlite3VdbeMakeLabel(tls, pParse) + /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in + ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the + ** SELECT statement. + */ + pAggInfo = _sqlite3DbMallocZero(tls, db, uint64(64)) + if pAggInfo != 0 { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_agginfoFree), pAggInfo) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FselId = (*TSelect)(unsafe.Pointer(p)).FselId + libc.X__builtin___memset_chk(tls, bp+112, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp + 112))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp + 112))).FpSrcList = pTabList + *(*uintptr)(unsafe.Pointer(bp + 112 + 16)) = pAggInfo + if pGroupBy != 0 { + v12 = (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + } else { + v12 = 0 + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn = libc.Uint32FromInt32(v12) + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy = pGroupBy + _sqlite3ExprAnalyzeAggList(tls, bp+112, pEList) + _sqlite3ExprAnalyzeAggList(tls, bp+112, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy) + if pHaving != 0 { + if pGroupBy != 0 { + _havingToWhere(tls, pParse, p) + pWhere = (*TSelect)(unsafe.Pointer(p)).FpWhere + } + _sqlite3ExprAnalyzeAggregates(tls, bp+112, pHaving) + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + if (*TSelect)(unsafe.Pointer(p)).FpGroupBy == uintptr(0) && (*TSelect)(unsafe.Pointer(p)).FpHaving == uintptr(0) && (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == int32(1) { + minMaxFlag = _minMaxQuery(tls, db, (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr, bp+64) + } else { + minMaxFlag = uint8(WHERE_ORDERBY_NORMAL) + } + _analyzeAggFuncArgs(tls, pAggInfo, bp+112) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + /* Processing for aggregates with GROUP BY is very different and + ** much more complex than aggregates without a GROUP BY. tag-select-0810 + */ + if pGroupBy != 0 { /* Return address register for reset subroutine */ + pDistinct = uintptr(0) + distFlag = uint16(0) + eDist = WHERE_DISTINCT_NOOP + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == int32(1) && (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FiDistinct >= 0 && (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr != uintptr(0) && (*TExpr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr)).Fflags&uint32(EP_xIsSelect) == uint32(0) && *(*uintptr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr + 32)) != uintptr(0) { + pExpr = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr + 32)) + 8))).FpExpr + pExpr = _sqlite3ExprDup(tls, db, pExpr, 0) + pDistinct = _sqlite3ExprListDup(tls, db, pGroupBy, 0) + pDistinct = _sqlite3ExprListAppend(tls, pParse, pDistinct, pExpr) + if pDistinct != 0 { + v12 = libc.Int32FromInt32(WHERE_WANT_DISTINCT) | libc.Int32FromInt32(WHERE_AGG_DISTINCT) + } else { + v12 = 0 + } + distFlag = libc.Uint16FromInt32(v12) + } + /* If there is a GROUP BY clause we might need a sorting index to + ** implement it. Allocate that sorting index now. If it turns out + ** that we do not need it after all, the OP_SorterOpen instruction + ** will be converted into a Noop. + */ + v1 = pParse + 56 + v12 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx = v12 + pKeyInfo1 = _sqlite3KeyInfoFromExprList(tls, pParse, pGroupBy, 0, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) + addrSortingIdx = _sqlite3VdbeAddOp4(tls, v, int32(OP_SorterOpen), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, libc.Int32FromUint32((*TAggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn), 0, pKeyInfo1, -int32(9)) + /* Initialize memory locations used by GROUP BY aggregate processing + */ + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + iUseFlag = v12 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + iAbortFlag = v12 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + regOutputRow = v12 + addrOutputRow = _sqlite3VdbeMakeLabel(tls, pParse) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + regReset = v12 + addrReset = _sqlite3VdbeMakeLabel(tls, pParse) + iAMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + iBMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, iAbortFlag) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, iAMem, iAMem+(*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr-int32(1)) + _sqlite3ExprNullRegisterRange(tls, pParse, iAMem, (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) + /* Begin a loop that will extract all source rows in GROUP BY order. + ** This might involve two separate loops with an OP_Sort in between, or + ** it might be a single loop that uses an index to extract information + ** in the right order to begin with. + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regReset, addrReset) + if libc.Int32FromUint8((**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct) == int32(2) { + v12 = int32(WHERE_DISTINCTBY) + } else { + v12 = int32(WHERE_GROUPBY) + } + if orderByGrp != 0 { + v15 = int32(WHERE_SORTBYGROUP) + } else { + v15 = 0 + } + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, pGroupBy, pDistinct, p, libc.Uint16FromInt32(v12|v15|libc.Int32FromUint16(distFlag)), 0) + if pWInfo == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pDistinct) + goto select_end + } + if (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr != 0 { + _optimizeAggregateUseOfIndexedExpr(tls, pParse, p, pAggInfo, bp+112) + } + _assignAggregateRegisters(tls, pParse, pAggInfo) + eDist = _sqlite3WhereIsDistinct(tls, pWInfo) + if _sqlite3WhereIsOrdered(tls, pWInfo) == (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr { + /* The optimizer is able to deliver rows in group by order so + ** we do not have to sort. The OP_OpenEphemeral table will be + ** cancelled later because we still need to use the pKeyInfo + */ + groupBySort = 0 + } else { + if (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) == uint32(0) { + v1 = __ccgo_ts + 22104 + } else { + v1 = __ccgo_ts + 22113 + } + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20911, libc.VaList(bp+176, v1)) + groupBySort = int32(1) + nGroupBy = (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + nCol = nGroupBy + j = nGroupBy + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) { + break + } + if (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(i)*32))).FiSorterColumn >= j { + nCol = nCol + 1 + j = j + 1 + } + goto _47 + _47: + ; + i = i + 1 + } + regBase = _sqlite3GetTempRange(tls, pParse, nCol) + _sqlite3ExprCodeExprList(tls, pParse, pGroupBy, regBase, 0, uint8(0)) + j = nGroupBy + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = uint8(1) + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) { + break + } + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(i)*32 + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn >= j { + _sqlite3ExprCode(tls, pParse, (*TAggInfo_col)(unsafe.Pointer(pCol)).FpCExpr, j+regBase) + j = j + 1 + } + goto _48 + _48: + ; + i = i + 1 + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = uint8(0) + regRecord = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regBase, nCol, regRecord) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterInsert), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, regRecord) + _sqlite3ReleaseTempReg(tls, pParse, regRecord) + _sqlite3ReleaseTempRange(tls, pParse, regBase, nCol) + _sqlite3WhereEnd(tls, pWInfo) + v1 = pParse + 56 + v15 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = v15 + sortPTab = v12 + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab = v12 + sortOut = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenPseudo), sortPTab, sortOut, nCol) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterSort), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrEnd) + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx = uint8(1) + } + /* If there are entries in pAgggInfo->aFunc[] that contain subexpressions + ** that are indexed (and that were previously identified and tagged + ** in optimizeAggregateUseOfIndexedExpr()) then those subexpressions + ** must now be converted into a TK_AGG_COLUMN node so that the value + ** is correctly pulled from the index rather than being recomputed. */ + if (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr != 0 { + _aggregateConvertIndexedExprRefToColumn(tls, pAggInfo) + } + /* If the index or temporary table used by the GROUP BY sort + ** will naturally deliver rows in the order required by the ORDER BY + ** clause, cancel the ephemeral table open coded earlier. + ** + ** This is an optimization - the correct answer should result regardless. + ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER to + ** disable this optimization for testing purposes. */ + if orderByGrp != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_GroupByOrder)) == uint32(0) && (groupBySort != 0 || _sqlite3WhereIsSorted(tls, pWInfo) != 0) { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = uintptr(0) + _sqlite3VdbeChangeToNoop(tls, v, (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex) + } + /* Evaluate the current GROUP BY terms and store in b0, b1, b2... + ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth) + ** Then compare the current GROUP BY terms against the GROUP BY terms + ** from the previous row currently stored in a0, a1, a2... + */ + addrTopOfLoop = _sqlite3VdbeCurrentAddr(tls, v) + if groupBySort != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_SorterData), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, sortOut, sortPTab) + } + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { + break + } + iOrderByCol = libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pGroupBy + 8 + uintptr(j)*32 + 24))) + if groupBySort != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), sortPTab, j, iBMem+j) + } else { + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = uint8(1) + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pGroupBy + 8 + uintptr(j)*32))).FpExpr, iBMem+j) + } + if iOrderByCol != 0 { + pX = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8 + uintptr(iOrderByCol-int32(1))*32))).FpExpr + pBase = _sqlite3ExprSkipCollateAndLikely(tls, pX) + for pBase != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pBase)).Fop) == int32(TK_IF_NULL_ROW) { + pX = (*TExpr)(unsafe.Pointer(pBase)).FpLeft + pBase = _sqlite3ExprSkipCollateAndLikely(tls, pX) + } + if pBase != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pBase)).Fop) != int32(TK_AGG_COLUMN) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pBase)).Fop) != int32(TK_REGISTER) { + _sqlite3ExprToRegister(tls, pX, iAMem+j) + } + } + goto _52 + _52: + ; + j = j + 1 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_Compare), iAMem, iBMem, (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr, _sqlite3KeyInfoRef(tls, pKeyInfo1), -int32(9)) + addr1 = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addr1+int32(1), 0, addr1+int32(1)) + /* Generate code that runs whenever the GROUP BY changes. + ** Changes in the GROUP BY are detected by the previous code + ** block. If there were no changes, this block is skipped. + ** + ** This code copies current group by terms in b0,b1,b2,... + ** over to a0,a1,a2. It then calls the output subroutine + ** and resets the aggregate accumulator registers in preparation + ** for the next GROUP BY batch. + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutputRow, addrOutputRow) + _sqlite3ExprCodeMove(tls, pParse, iBMem, iAMem, (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), iAbortFlag, addrEnd) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regReset, addrReset) + /* Update the aggregate accumulators based on the content of + ** the current row + */ + _sqlite3VdbeJumpHere(tls, v, addr1) + _updateAccumulator(tls, pParse, iUseFlag, pAggInfo, eDist) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), iUseFlag) + /* End of the loop + */ + if groupBySort != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterNext), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrTopOfLoop) + } else { + _sqlite3WhereEnd(tls, pWInfo) + _sqlite3VdbeChangeToNoop(tls, v, addrSortingIdx) + } + _sqlite3ExprListDelete(tls, db, pDistinct) + /* Output the final row of result + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutputRow, addrOutputRow) + /* Jump over the subroutines + */ + _sqlite3VdbeGoto(tls, v, addrEnd) + /* Generate a subroutine that outputs a single row of the result + ** set. This subroutine first looks at the iUseFlag. If iUseFlag + ** is less than or equal to zero, the subroutine is a no-op. If + ** the processing calls for the query to abort, this subroutine + ** increments the iAbortFlag memory location before returning in + ** order to signal the caller to abort. + */ + addrSetAbort = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), iAbortFlag) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regOutputRow) + _sqlite3VdbeResolveLabel(tls, v, addrOutputRow) + addrOutputRow = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), iUseFlag, addrOutputRow+int32(2)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regOutputRow) + _finalizeAggFunctions(tls, pParse, pAggInfo) + _sqlite3ExprIfFalse(tls, pParse, pHaving, addrOutputRow+int32(1), int32(SQLITE_JUMPIFNULL)) + _selectInnerLoop(tls, pParse, p, -int32(1), bp+16, bp, pDest, addrOutputRow+int32(1), addrSetAbort) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regOutputRow) + /* Generate a subroutine that will reset the group-by accumulator + */ + _sqlite3VdbeResolveLabel(tls, v, addrReset) + _resetAccumulator(tls, pParse, pAggInfo) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, iUseFlag) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regReset) + if libc.Int32FromUint16(distFlag) != 0 && eDist != WHERE_DISTINCT_NOOP { + pF = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + _fixDistinctOpenEph(tls, pParse, eDist, (*TAggInfo_func)(unsafe.Pointer(pF)).FiDistinct, (*TAggInfo_func)(unsafe.Pointer(pF)).FiDistAddr) + } + } else { + v1 = _isSimpleCount(tls, p, pAggInfo) + pTab1 = v1 + if v1 != uintptr(0) { + /* tag-select-0821 + ** + ** If isSimpleCount() returns a pointer to a Table structure, then + ** the SQL statement is of the form: + ** + ** SELECT count(*) FROM + ** + ** where the Table structure returned represents table . + ** + ** This statement is so common that it is optimized specially. The + ** OP_Count instruction is executed either on the intkey table that + ** contains the data for table or on one of its indexes. It + ** is better to execute the op on an index, as indexes are almost + ** always spread across less pages than their corresponding tables. + */ + iDb1 = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab1)).FpSchema) + v3 = pParse + 56 + v12 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + iCsr = v12 /* Iterator variable */ + pKeyInfo2 = uintptr(0) /* Keyinfo for scanned index */ + pBest = uintptr(0) /* Best index found so far */ + iRoot = (*TTable)(unsafe.Pointer(pTab1)).Ftnum /* Root page of scanned b-tree */ + _sqlite3CodeVerifySchema(tls, pParse, iDb1) + _sqlite3TableLock(tls, pParse, iDb1, (*TTable)(unsafe.Pointer(pTab1)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab1)).FzName) + /* Search for the index that has the lowest scan cost. + ** + ** (2011-04-15) Do not do a full scan of an unordered index. + ** + ** (2013-10-03) Do not count the entries in a partial index. + ** + ** In practice the KeyInfo structure will not be used. It is only + ** passed to keep OP_OpenRead happy. + */ + if !((*TTable)(unsafe.Pointer(pTab1)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pBest = _sqlite3PrimaryKeyIndex(tls, pTab1) + } + if !(int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + 24 + 4))&0x1>>0) != 0) { + pIdx = (*TTable)(unsafe.Pointer(pTab1)).FpIndex + for { + if !(pIdx != 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x4>>2)) == 0 && int32((*TIndex)(unsafe.Pointer(pIdx)).FszIdxRow) < int32((*TTable)(unsafe.Pointer(pTab1)).FszTabRow) && (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) && (!(pBest != 0) || int32((*TIndex)(unsafe.Pointer(pIdx)).FszIdxRow) < int32((*TIndex)(unsafe.Pointer(pBest)).FszIdxRow)) { + pBest = pIdx + } + goto _56 + _56: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } + if pBest != 0 { + iRoot = (*TIndex)(unsafe.Pointer(pBest)).Ftnum + pKeyInfo2 = _sqlite3KeyInfoOfIndex(tls, pParse, pBest) + } + /* Open a read-only cursor, execute the OP_Count, close the cursor. */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_OpenRead), iCsr, libc.Int32FromUint32(iRoot), iDb1, int32(1)) + if pKeyInfo2 != 0 { + _sqlite3VdbeChangeP4(tls, v, -int32(1), pKeyInfo2, -int32(9)) + } + _assignAggregateRegisters(tls, pParse, pAggInfo) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Count), iCsr, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+(*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn+0) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iCsr) + _explainSimpleCount(tls, pParse, pTab1, pBest) + } else { + /* The general case of an aggregate query without GROUP BY + ** tag-select-0822 */ + regAcc = 0 /* "populate accumulators" flag */ + pDistinct1 = uintptr(0) + distFlag1 = uint16(0) + /* If there are accumulator registers but no min() or max() functions + ** without FILTER clauses, allocate register regAcc. Register regAcc + ** will contain 0 the first time the inner loop runs, and 1 thereafter. + ** The code generated by updateAccumulator() uses this to ensure + ** that the accumulator registers are (a) updated only once if + ** there are no min() or max functions or (b) always updated for the + ** first row visited by the aggregate, so that they are updated at + ** least once even if the FILTER clause means the min() or max() + ** function visits zero rows. */ + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0 { + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + if (*TExpr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32))).FpFExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + goto _57 + } + if (*TFuncDef)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32))).FpFunc)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 { + break + } + goto _57 + _57: + ; + i = i + 1 + } + if i == (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc { + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + regAcc = v12 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regAcc) + } + } else { + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == int32(1) && (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FiDistinct >= 0 { + pDistinct1 = *(*uintptr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr + 32)) + if pDistinct1 != 0 { + v12 = libc.Int32FromInt32(WHERE_WANT_DISTINCT) | libc.Int32FromInt32(WHERE_AGG_DISTINCT) + } else { + v12 = 0 + } + distFlag1 = libc.Uint16FromInt32(v12) + } + } + _assignAggregateRegisters(tls, pParse, pAggInfo) + /* This case runs if the aggregate has no GROUP BY clause. The + ** processing is much simpler since there is only a single row + ** of output. + */ + _resetAccumulator(tls, pParse, pAggInfo) + /* If this query is a candidate for the min/max optimization, then + ** minMaxFlag will have been previously set to either + ** WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX and pMinMaxOrderBy will + ** be an appropriate ORDER BY expression for the optimization. + */ + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, **(**uintptr)(__ccgo_up(bp + 64)), pDistinct1, p, libc.Uint16FromInt32(libc.Int32FromUint8(minMaxFlag)|libc.Int32FromUint16(distFlag1)), 0) + if pWInfo == uintptr(0) { + goto select_end + } + eDist1 = _sqlite3WhereIsDistinct(tls, pWInfo) + _updateAccumulator(tls, pParse, regAcc, pAggInfo, eDist1) + if eDist1 != WHERE_DISTINCT_NOOP { + pF1 = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + if pF1 != 0 { + _fixDistinctOpenEph(tls, pParse, eDist1, (*TAggInfo_func)(unsafe.Pointer(pF1)).FiDistinct, (*TAggInfo_func)(unsafe.Pointer(pF1)).FiDistAddr) + } + } + if regAcc != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), regAcc) + } + if minMaxFlag != 0 { + _sqlite3WhereMinMaxOptEarlyOut(tls, v, pWInfo) + } + _sqlite3WhereEnd(tls, pWInfo) + _finalizeAggFunctions(tls, pParse, pAggInfo) + } + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = uintptr(0) + _sqlite3ExprIfFalse(tls, pParse, pHaving, addrEnd, int32(SQLITE_JUMPIFNULL)) + _selectInnerLoop(tls, pParse, p, -int32(1), uintptr(0), uintptr(0), pDest, addrEnd, addrEnd) + } + _sqlite3VdbeResolveLabel(tls, v, addrEnd) + } /* endif aggregate query */ + if libc.Int32FromUint8((**(**TDistinctCtx)(__ccgo_up(bp))).FeTnctType) == int32(WHERE_DISTINCT_UNORDERED) { + _explainTempTable(tls, pParse, __ccgo_ts+22104) + } + /* If there is an ORDER BY clause, then we need to sort the results + ** and send them to the callback one by one. tag-select-0900 + */ + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy != 0 { + _generateSortTail(tls, pParse, p, bp+16, (*TExprList)(unsafe.Pointer(pEList)).FnExpr, pDest) + } + /* Jump here to skip this query + */ + _sqlite3VdbeResolveLabel(tls, v, iEnd) + /* The SELECT has been coded. If there is an error in the Parse structure, + ** set the return code to 1. Otherwise 0. */ + rc = libc.BoolInt32((*TParse)(unsafe.Pointer(pParse)).FnErr > 0) + /* Control jumps to here if an error is encountered above, or upon + ** successful coding of the SELECT. + */ + goto select_end +select_end: + ; + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp + 64))) + _sqlite3VdbeExplainPop(tls, pParse) + return rc +} + +/************** End of select.c **********************************************/ +/************** Begin file table.c *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the sqlite3_get_table() and sqlite3_free_table() +** interface routines. These are just wrappers around the main +** interface routine of sqlite3_exec(). +** +** These routines are in a separate files so that they will not be linked +** if they are not used. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** Check all ON clauses in pSelect to verify that they do not reference +// ** columns to the right. +// */ +func _sqlite3SelectCheckOnClauses(tls *libc.TLS, pParse uintptr, pSelect uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var ii int32 + var pItem uintptr + var _ /* sCtx at bp+48 */ TCheckOnCtx + var _ /* w at bp+0 */ TWalker + _, _ = ii, pItem + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_selectCheckOnClausesExpr) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_selectCheckOnClausesSelect) + *(*uintptr)(unsafe.Pointer(bp + 40)) = bp + 48 + libc.X__builtin___memset_chk(tls, bp+48, 0, uint64(24), ^t__predefined_size_t(0)) + (**(**TCheckOnCtx)(__ccgo_up(bp + 48))).FpSrc = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + _sqlite3WalkExpr(tls, bp, (*TSelect)(unsafe.Pointer(pSelect)).FpWhere) + **(**Tu32)(__ccgo_up(pSelect + 4)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SF_OnToWhere)) + /* Check for any table-function args that are attached to virtual tables + ** on the RHS of an outer join. They are subject to the same constraints + ** as ON clauses. */ + (**(**TCheckOnCtx)(__ccgo_up(bp + 48))).FbFuncArg = int32(1) + ii = 0 + for { + if !(ii < (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc) { + break + } + pItem = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + uintptr(ii)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x8>>3) != 0 && libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_OUTER) != 0 { + (**(**TCheckOnCtx)(__ccgo_up(bp + 48))).FiJoin = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + _sqlite3WalkExprList(tls, bp, *(*uintptr)(unsafe.Pointer(pItem + 48))) + } + goto _1 + _1: + ; + ii = ii + 1 + } +} + +// C documentation +// +// /* +// ** Name of the connection operator, used for error messages. +// */ +func _sqlite3SelectOpName(tls *libc.TLS, id int32) (r uintptr) { + var z uintptr + _ = z + switch id { + case int32(TK_ALL): + z = __ccgo_ts + 20878 + case int32(TK_INTERSECT): + z = __ccgo_ts + 20888 + case int32(TK_EXCEPT): + z = __ccgo_ts + 20898 + default: + z = __ccgo_ts + 20905 + break + } + return z +} + +// C documentation +// +// /* +// ** Error message for when two or more terms of a compound select have different +// ** size result sets. +// */ +func _sqlite3SelectWrongNumTermsError(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Values) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21215, 0) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21261, libc.VaList(bp+8, _sqlite3SelectOpName(tls, libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop)))) + } +} + +// C documentation +// +// /* +// ** Attach a Subquery object to pItem->uv.pSubq. Set the +// ** pSelect value but leave all the other values initialized +// ** to zero. +// ** +// ** A copy of the Select object is made if dupSelect is true, and the +// ** SrcItem takes responsibility for deleting the copy. If dupSelect is +// ** false, ownership of the Select passes to the SrcItem. Either way, +// ** the SrcItem will take responsibility for deleting the Select. +// ** +// ** When dupSelect is zero, that means the Select might get deleted right +// ** away if there is an OOM error. Beware. +// ** +// ** Return non-zero on success. Return zero on an OOM error. +// */ +func _sqlite3SrcItemAttachSubquery(tls *libc.TLS, pParse uintptr, pItem uintptr, pSelect uintptr, dupSelect int32) (r int32) { + var p, v1 uintptr + _, _ = p, v1 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) != 0 { + *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(0), 16, 0x10000) + } else { + if *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(pItem + 72))) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) + } + } + if dupSelect != 0 { + pSelect = _sqlite3SelectDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect, 0) + if pSelect == uintptr(0) { + return 0 + } + } + v1 = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(24)) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = v1 + p = v1 + if p == uintptr(0) { + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect) + return 0 + } + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 2, 0x4) + (*TSubquery)(unsafe.Pointer(p)).FpSelect = pSelect + libc.X__builtin___memset_chk(tls, p+uintptr(8), 0, libc.Uint64FromInt64(24)-libc.Uint64FromInt64(8), ^t__predefined_size_t(0)) + return int32(1) +} + +// C documentation +// +// /* +// ** Append a new table name to the given SrcList. Create a new SrcList if +// ** need be. A new entry is created in the SrcList even if pTable is NULL. +// ** +// ** A SrcList is returned, or NULL if there is an OOM error or if the +// ** SrcList grows to large. The returned +// ** SrcList might be the same as the SrcList that was input or it might be +// ** a new one. If an OOM error does occurs, then the prior value of pList +// ** that is input to this routine is automatically freed. +// ** +// ** If pDatabase is not null, it means that the table has an optional +// ** database name prefix. Like this: "database.table". The pDatabase +// ** points to the table name and the pTable points to the database name. +// ** The SrcList.a[].zName field is filled with the table name which might +// ** come from pTable (if pDatabase is NULL) or from pDatabase. +// ** SrcList.a[].zDatabase is filled with the database name from pTable, +// ** or with NULL if no database is specified. +// ** +// ** In other words, if call like this: +// ** +// ** sqlite3SrcListAppend(D,A,B,0); +// ** +// ** Then B is a table name and the database name is unspecified. If called +// ** like this: +// ** +// ** sqlite3SrcListAppend(D,A,B,C); +// ** +// ** Then C is the table name and B is the database name. If C is defined +// ** then so is B. In other words, we never have a case where: +// ** +// ** sqlite3SrcListAppend(D,A,0,C); +// ** +// ** Both pTable and pDatabase are assumed to be quoted. They are dequoted +// ** before being added to the SrcList. +// */ +func _sqlite3SrcListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pTable uintptr, pDatabase uintptr) (r uintptr) { + var db, pItem, pNew uintptr + _, _, _ = db, pItem, pNew + /* Cannot have C without B */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pList == uintptr(0) { + pList = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(80))) + if pList == uintptr(0) { + return uintptr(0) + } + (*TSrcList)(unsafe.Pointer(pList)).FnAlloc = uint32(1) + (*TSrcList)(unsafe.Pointer(pList)).FnSrc = int32(1) + libc.X__builtin___memset_chk(tls, pList+8, 0, uint64(80), ^t__predefined_size_t(0)) + (*(*TSrcItem)(unsafe.Pointer(pList + 8))).FiCursor = -int32(1) + } else { + pNew = _sqlite3SrcListEnlarge(tls, pParse, pList, int32(1), (*TSrcList)(unsafe.Pointer(pList)).FnSrc) + if pNew == uintptr(0) { + _sqlite3SrcListDelete(tls, db, pList) + return uintptr(0) + } else { + pList = pNew + } + } + pItem = pList + 8 + uintptr((*TSrcList)(unsafe.Pointer(pList)).FnSrc-int32(1))*80 + if pDatabase != 0 && (*TToken)(unsafe.Pointer(pDatabase)).Fz == uintptr(0) { + pDatabase = uintptr(0) + } + if pDatabase != 0 { + (*TSrcItem)(unsafe.Pointer(pItem)).FzName = _sqlite3NameFromToken(tls, db, pDatabase) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = _sqlite3NameFromToken(tls, db, pTable) + } else { + (*TSrcItem)(unsafe.Pointer(pItem)).FzName = _sqlite3NameFromToken(tls, db, pTable) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) + } + return pList +} + +// C documentation +// +// /* +// ** This routine is called by the parser to add a new term to the +// ** end of a growing FROM clause. The "p" parameter is the part of +// ** the FROM clause that has already been constructed. "p" is NULL +// ** if this is the first term of the FROM clause. pTable and pDatabase +// ** are the name of the table and database named in the FROM clause term. +// ** pDatabase is NULL if the database name qualifier is missing - the +// ** usual case. If the term has an alias, then pAlias points to the +// ** alias token. If the term is a subquery, then pSubquery is the +// ** SELECT statement that the subquery encodes. The pTable and +// ** pDatabase parameters are NULL for subqueries. The pOn and pUsing +// ** parameters are the content of the ON and USING clauses. +// ** +// ** Return a new SrcList which encodes is the FROM with the new +// ** term added. +// */ +func _sqlite3SrcListAppendFromTerm(tls *libc.TLS, pParse uintptr, p uintptr, pTable uintptr, pDatabase uintptr, pAlias uintptr, pSubquery uintptr, pOnUsing uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pItem, pToken, v1 uintptr + _, _, _, _ = db, pItem, pToken, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if !(p != 0) && pOnUsing != uintptr(0) && ((*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn != 0 || (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing != 0) { + if (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn != 0 { + v1 = __ccgo_ts + 16402 + } else { + v1 = __ccgo_ts + 16405 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16411, libc.VaList(bp+8, v1)) + goto append_from_error + } + p = _sqlite3SrcListAppend(tls, pParse, p, pTable, pDatabase) + if p == uintptr(0) { + goto append_from_error + } + pItem = p + 8 + uintptr((*TSrcList)(unsafe.Pointer(p)).FnSrc-int32(1))*80 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { + if pDatabase != 0 && (*TToken)(unsafe.Pointer(pDatabase)).Fz != 0 { + v1 = pDatabase + } else { + v1 = pTable + } + pToken = v1 + _sqlite3RenameTokenMap(tls, pParse, (*TSrcItem)(unsafe.Pointer(pItem)).FzName, pToken) + } + if (*TToken)(unsafe.Pointer(pAlias)).Fn != 0 { + (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias = _sqlite3NameFromToken(tls, db, pAlias) + } + if pSubquery != 0 { + if _sqlite3SrcItemAttachSubquery(tls, pParse, pItem, pSubquery, 0) != 0 { + if (*TSelect)(unsafe.Pointer(pSubquery)).FselFlags&uint32(SF_NestedFrom) != 0 { + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 14, 0x4000) + } + } + } + if pOnUsing == uintptr(0) { + *(*uintptr)(unsafe.Pointer(pItem + 64)) = uintptr(0) + } else { + if (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing != 0 { + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 11, 0x800) + *(*uintptr)(unsafe.Pointer(pItem + 64)) = (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing + } else { + *(*uintptr)(unsafe.Pointer(pItem + 64)) = (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn + } + } + return p + goto append_from_error +append_from_error: + ; + _sqlite3ClearOnOrUsing(tls, db, pOnUsing) + _sqlite3SelectDelete(tls, db, pSubquery) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Append the contents of SrcList p2 to SrcList p1 and return the resulting +// ** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2 +// ** are deleted by this function. +// */ +func _sqlite3SrcListAppendList(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uintptr) (r uintptr) { + var nOld int32 + var pNew, v1 uintptr + _, _, _ = nOld, pNew, v1 + if p2 != 0 { + nOld = (*TSrcList)(unsafe.Pointer(p1)).FnSrc + pNew = _sqlite3SrcListEnlarge(tls, pParse, p1, (*TSrcList)(unsafe.Pointer(p2)).FnSrc, nOld) + if pNew == uintptr(0) { + _sqlite3SrcListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p2) + } else { + p1 = pNew + libc.X__builtin___memcpy_chk(tls, p1+8+uintptr(nOld)*80, p2+8, libc.Uint64FromInt32((*TSrcList)(unsafe.Pointer(p2)).FnSrc)*uint64(80), ^t__predefined_size_t(0)) + v1 = p1 + 8 + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JT_LTORJ)&libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(p2 + 8))).Ffg.Fjointype)) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p2) + } + } + return p1 +} + +// C documentation +// +// /* +// ** If cursors, triggers, views and subqueries are all omitted from +// ** the build, then none of the following routines, except for +// ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes +// ** called with a NULL argument. +// */ +func _sqlite3SrcListDup(tls *libc.TLS, db uintptr, p uintptr, flags int32) (r uintptr) { + var i int32 + var pNew, pNewItem, pNewSubq, pOldItem, pTab, v3 uintptr + var v1 Tu32 + _, _, _, _, _, _, _, _ = i, pNew, pNewItem, pNewSubq, pOldItem, pTab, v1, v3 + if p == uintptr(0) { + return uintptr(0) + } + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32((*TSrcList)(unsafe.Pointer(p)).FnSrc)*libc.Uint64FromInt64(80))) + if pNew == uintptr(0) { + return uintptr(0) + } + v1 = libc.Uint32FromInt32((*TSrcList)(unsafe.Pointer(p)).FnSrc) + (*TSrcList)(unsafe.Pointer(pNew)).FnAlloc = v1 + (*TSrcList)(unsafe.Pointer(pNew)).FnSrc = libc.Int32FromUint32(v1) + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(p)).FnSrc) { + break + } + pNewItem = pNew + 8 + uintptr(i)*80 + pOldItem = p + 8 + uintptr(i)*80 + (*TSrcItem)(unsafe.Pointer(pNewItem)).Ffg = (*TSrcItem)(unsafe.Pointer(pOldItem)).Ffg + if int32(*(*uint32)(unsafe.Pointer(pOldItem + 24 + 4))&0x4>>2) != 0 { + pNewSubq = _sqlite3DbMallocRaw(tls, db, uint64(24)) + if pNewSubq == uintptr(0) { + libc.SetBitFieldPtr32Uint32(pNewItem+24+4, libc.Uint32FromInt32(0), 2, 0x4) + } else { + libc.X__builtin___memcpy_chk(tls, pNewSubq, *(*uintptr)(unsafe.Pointer(pOldItem + 72)), uint64(24), ^t__predefined_size_t(0)) + (*TSubquery)(unsafe.Pointer(pNewSubq)).FpSelect = _sqlite3SelectDup(tls, db, (*TSubquery)(unsafe.Pointer(pNewSubq)).FpSelect, flags) + if (*TSubquery)(unsafe.Pointer(pNewSubq)).FpSelect == uintptr(0) { + _sqlite3DbFree(tls, db, pNewSubq) + pNewSubq = uintptr(0) + libc.SetBitFieldPtr32Uint32(pNewItem+24+4, libc.Uint32FromInt32(0), 2, 0x4) + } + } + *(*uintptr)(unsafe.Pointer(pNewItem + 72)) = pNewSubq + } else { + if int32(*(*uint32)(unsafe.Pointer(pOldItem + 24 + 4))&0x10000>>16) != 0 { + *(*uintptr)(unsafe.Pointer(pNewItem + 72)) = *(*uintptr)(unsafe.Pointer(pOldItem + 72)) + } else { + *(*uintptr)(unsafe.Pointer(pNewItem + 72)) = _sqlite3DbStrDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 72))) + } + } + (*TSrcItem)(unsafe.Pointer(pNewItem)).FzName = _sqlite3DbStrDup(tls, db, (*TSrcItem)(unsafe.Pointer(pOldItem)).FzName) + (*TSrcItem)(unsafe.Pointer(pNewItem)).FzAlias = _sqlite3DbStrDup(tls, db, (*TSrcItem)(unsafe.Pointer(pOldItem)).FzAlias) + (*TSrcItem)(unsafe.Pointer(pNewItem)).FiCursor = (*TSrcItem)(unsafe.Pointer(pOldItem)).FiCursor + if int32(*(*uint32)(unsafe.Pointer(pNewItem + 24 + 4))&0x2>>1) != 0 { + *(*uintptr)(unsafe.Pointer(pNewItem + 48)) = _sqlite3DbStrDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 48))) + } else { + if int32(*(*uint32)(unsafe.Pointer(pNewItem + 24 + 4))&0x8>>3) != 0 { + *(*uintptr)(unsafe.Pointer(pNewItem + 48)) = _sqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 48)), flags) + } else { + *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(pNewItem)).Fu1)) = *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(pOldItem)).Fu1)) + } + } + (*TSrcItem)(unsafe.Pointer(pNewItem)).Fu2 = (*TSrcItem)(unsafe.Pointer(pOldItem)).Fu2 + if int32(*(*uint32)(unsafe.Pointer(pNewItem + 24 + 4))&0x200>>9) != 0 { + (*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNewItem + 56)))).FnUse = (*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNewItem + 56)))).FnUse + 1 + } + v3 = (*TSrcItem)(unsafe.Pointer(pOldItem)).FpSTab + (*TSrcItem)(unsafe.Pointer(pNewItem)).FpSTab = v3 + pTab = v3 + if pTab != 0 { + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + } + if int32(*(*uint32)(unsafe.Pointer(pOldItem + 24 + 4))&0x800>>11) != 0 { + *(*uintptr)(unsafe.Pointer(pNewItem + 64)) = _sqlite3IdListDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 64))) + } else { + *(*uintptr)(unsafe.Pointer(pNewItem + 64)) = _sqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 64)), flags) + } + (*TSrcItem)(unsafe.Pointer(pNewItem)).FcolUsed = (*TSrcItem)(unsafe.Pointer(pOldItem)).FcolUsed + goto _2 + _2: + ; + i = i + 1 + } + return pNew +} + +// C documentation +// +// /* +// ** Expand the space allocated for the given SrcList object by +// ** creating nExtra new slots beginning at iStart. iStart is zero based. +// ** New slots are zeroed. +// ** +// ** For example, suppose a SrcList initially contains two entries: A,B. +// ** To append 3 new entries onto the end, do this: +// ** +// ** sqlite3SrcListEnlarge(db, pSrclist, 3, 2); +// ** +// ** After the call above it would contain: A, B, nil, nil, nil. +// ** If the iStart argument had been 1 instead of 2, then the result +// ** would have been: A, nil, nil, nil, B. To prepend the new slots, +// ** the iStart value would be 0. The result then would +// ** be: nil, nil, nil, A, B. +// ** +// ** If a memory allocation fails or the SrcList becomes too large, leave +// ** the original SrcList unchanged, return NULL, and leave an error message +// ** in pParse. +// */ +func _sqlite3SrcListEnlarge(tls *libc.TLS, pParse uintptr, pSrc uintptr, nExtra int32, iStart int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pNew uintptr + var i int32 + var nAlloc Tsqlite3_int64 + _, _, _, _ = db, i, nAlloc, pNew + /* Sanity checking on calling parameters */ + /* Allocate additional space if needed */ + if libc.Uint32FromInt32((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc)+libc.Uint32FromInt32(nExtra) > (*TSrcList)(unsafe.Pointer(pSrc)).FnAlloc { + nAlloc = int64(2)*int64((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) + int64(nExtra) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc+nExtra >= int32(SQLITE_MAX_SRCLIST) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16366, libc.VaList(bp+8, int32(SQLITE_MAX_SRCLIST))) + return uintptr(0) + } + if nAlloc > int64(SQLITE_MAX_SRCLIST) { + nAlloc = int64(SQLITE_MAX_SRCLIST) + } + pNew = _sqlite3DbRealloc(tls, db, pSrc, uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt64(nAlloc)*libc.Uint64FromInt64(80)) + if pNew == uintptr(0) { + return uintptr(0) + } + pSrc = pNew + (*TSrcList)(unsafe.Pointer(pSrc)).FnAlloc = libc.Uint32FromInt64(nAlloc) + } + /* Move existing slots that come after the newly inserted slots + ** out of the way */ + i = (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc - int32(1) + for { + if !(i >= iStart) { + break + } + *(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i+nExtra)*80)) = *(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80)) + goto _1 + _1: + ; + i = i - 1 + } + **(**int32)(__ccgo_up(pSrc)) += nExtra + /* Zero the newly allocated slots */ + libc.X__builtin___memset_chk(tls, pSrc+8+uintptr(iStart)*80, 0, uint64(80)*libc.Uint64FromInt32(nExtra), ^t__predefined_size_t(0)) + i = iStart + for { + if !(i < iStart+nExtra) { + break + } + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FiCursor = -int32(1) + goto _2 + _2: + ; + i = i + 1 + } + /* Return a pointer to the enlarged SrcList */ + return pSrc +} + +// C documentation +// +// /* +// ** Begin constructing a new table representation in memory. This is +// ** the first of several action routines that get called in response +// ** to a CREATE TABLE statement. In particular, this routine is called +// ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp +// ** flag is true if the table should be stored in the auxiliary database +// ** file instead of in the main database file. This is normally the case +// ** when the "TEMP" or "TEMPORARY" keyword occurs in between +// ** CREATE and TABLE. +// ** +// ** The new table record is initialized and put in pParse->pNewTable. +// ** As more of the CREATE TABLE statement is parsed, additional action +// ** routines will be called to add more information to this record. +// ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine +// ** is called to complete the construction of the new table record. +// */ +func _sqlite3StartTable(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, isTemp int32, isView int32, isVirtual int32, noErr int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var addr1, fileFormat, iDb, reg1, reg2, reg3, v7, v8 int32 + var db, pTable, v, zDb, zDb1, zName, v1 uintptr + var v6 bool + var _ /* pName at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, db, fileFormat, iDb, pTable, reg1, reg2, reg3, v, zDb, zDb1, zName, v1, v6, v7, v8 + zName = uintptr(0) /* The name of the new table */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Unqualified name of the table to create */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum == uint32(1) { + /* Special case: Parsing the sqlite_schema or sqlite_temp_schema schema */ + iDb = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v1 = __ccgo_ts + 7108 + } else { + v1 = __ccgo_ts + 6628 + } + zName = _sqlite3DbStrDup(tls, db, v1) + **(**uintptr)(__ccgo_up(bp)) = pName1 + } else { + /* The common case */ + iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp) + if iDb < 0 { + return + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && isTemp != 0 && (*TToken)(unsafe.Pointer(pName2)).Fn > uint32(0) && iDb != int32(1) { + /* If creating a temp table, the name may not be qualified. Unless + ** the database name is "temp" anyway. */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14149, 0) + return + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && isTemp != 0 { + iDb = int32(1) + } + zName = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, zName, **(**uintptr)(__ccgo_up(bp))) + } + } + (*TParse)(unsafe.Pointer(pParse)).FsNameToken = **(**TToken)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) + if zName == uintptr(0) { + return + } + if isView != 0 { + v1 = __ccgo_ts + 11459 + } else { + v1 = __ccgo_ts + 9721 + } + if _sqlite3CheckObjectName(tls, pParse, zName, v1, zName) != 0 { + goto begin_table_error + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) == int32(1) { + isTemp = int32(1) + } + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && isTemp == int32(1) { + v1 = __ccgo_ts + 7108 + } else { + v1 = __ccgo_ts + 6628 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), v1, uintptr(0), zDb) != 0 { + goto begin_table_error + } + if !(isVirtual != 0) && _sqlite3AuthCheck(tls, pParse, libc.Int32FromUint8(_aCode[isTemp+int32(2)*isView]), zName, uintptr(0), zDb) != 0 { + goto begin_table_error + } + /* Make sure the new table name does not collide with an existing + ** index or table name in the same database. Issue an error message if + ** it does. The exception is if the statement being parsed was passed + ** to an sqlite3_declare_vtab() call. In that case only the column names + ** and types will be used, so there is no need to test for namespace + ** collisions. + */ + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != libc.Int32FromInt32(PARSE_MODE_NORMAL)) { + zDb1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto begin_table_error + } + pTable = _sqlite3FindTable(tls, db, zName, zDb1) + if pTable != 0 { + if !(noErr != 0) { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == int32(TABTYP_VIEW) { + v1 = __ccgo_ts + 11459 + } else { + v1 = __ccgo_ts + 9721 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14190, libc.VaList(bp+16, v1, **(**uintptr)(__ccgo_up(bp)))) + } else { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3ForceNotReadOnly(tls, pParse) + } + goto begin_table_error + } + if _sqlite3FindIndex(tls, db, zName, zDb1) != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14211, libc.VaList(bp+16, zName)) + goto begin_table_error + } + } + pTable = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTable == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + goto begin_table_error + } + (*TTable)(unsafe.Pointer(pTable)).FzName = zName + (*TTable)(unsafe.Pointer(pTable)).FiPKey = int16(-int32(1)) + (*TTable)(unsafe.Pointer(pTable)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*TTable)(unsafe.Pointer(pTable)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pTable)).FnRowLogEst = int16(200) + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = pTable + /* Begin generating the code that will insert the table record into + ** the schema table. Note in particular that we must go ahead + ** and allocate the record number for the table entry now. Before any + ** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause + ** indices to be created and the table record must come before the + ** indices. Hence, the record number for the table must be allocated + ** now. + */ + if v6 = !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0); v6 { + v1 = _sqlite3GetVdbe(tls, pParse) + v = v1 + } + if v6 && v1 != uintptr(0) { + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + if isVirtual != 0 { + _sqlite3VdbeAddOp0(tls, v, int32(OP_VBegin)) + } + /* If the file format and encoding in the database have not been set, + ** set them now. + */ + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v8 = *(*int32)(unsafe.Pointer(v1)) + v7 = v8 + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRowid = v7 + reg1 = v7 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v8 = *(*int32)(unsafe.Pointer(v1)) + v7 = v8 + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot = v7 + reg2 = v7 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v7 = *(*int32)(unsafe.Pointer(v1)) + reg3 = v7 + _sqlite3VdbeAddOp3(tls, v, int32(OP_ReadCookie), iDb, reg3, int32(BTREE_FILE_FORMAT)) + _sqlite3VdbeUsesBtree(tls, v, iDb) + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_If), reg3) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LegacyFileFmt) != uint64(0) { + v7 = int32(1) + } else { + v7 = int32(SQLITE_MAX_FILE_FORMAT) + } + fileFormat = v7 + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_FILE_FORMAT), fileFormat) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_TEXT_ENCODING), libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Fenc)) + _sqlite3VdbeJumpHere(tls, v, addr1) + /* This just creates a place-holder record in the sqlite_schema table. + ** The record created does not contain anything yet. It will be replaced + ** by the real entry in code generated at sqlite3EndTable(). + ** + ** The rowid for the new entry is left in register pParse->u1.cr.regRowid. + ** The root page of the new table is left in reg pParse->u1.cr.regRoot. + ** The rowid and root page number values are needed by the code that + ** sqlite3EndTable will generate. + */ + if isView != 0 || isVirtual != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, reg2) + } else { + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FaddrCrTab = _sqlite3VdbeAddOp3(tls, v, int32(OP_CreateBtree), iDb, reg2, int32(BTREE_INTKEY)) + } + _sqlite3OpenSchemaTable(tls, pParse, iDb) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), 0, reg1) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Blob), int32(6), reg3, 0, uintptr(unsafe.Pointer(&_nullRow)), -int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), 0, reg3, reg1) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + _sqlite3VdbeAddOp0(tls, v, int32(OP_Close)) + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x6>>1)) != 0 { + **(**Tu32)(__ccgo_up(pTable + 48)) |= uint32(TF_Imposter) + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x6>>1)) >= int32(2) { + **(**Tu32)(__ccgo_up(pTable + 48)) |= uint32(TF_Readonly) + } + } + } + /* Normal (non-error) return. */ + return + /* If an error occurs, we jump here */ + goto begin_table_error +begin_table_error: + ; + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + _sqlite3DbFree(tls, db, zName) + return +} + +// C documentation +// +// /* +// ** Enlarge the memory allocation on a StrAccum object so that it is +// ** able to accept at least N more bytes of text. +// ** +// ** Return the number of bytes of text that StrAccum is able to accept +// ** after the attempted enlargement. The value returned might be zero. +// */ +func _sqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N Ti64) (r int32) { + var szNew Ti64 + var zNew, zOld, v1 uintptr + _, _, _, _ = szNew, zNew, zOld, v1 + /* Only called if really needed */ + if (*TStrAccum)(unsafe.Pointer(p)).FaccError != 0 { + return 0 + } + if (*TStrAccum)(unsafe.Pointer(p)).FmxAlloc == uint32(0) { + _sqlite3StrAccumSetError(tls, p, uint8(SQLITE_TOOBIG)) + return libc.Int32FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnAlloc - (*TStrAccum)(unsafe.Pointer(p)).FnChar - uint32(1)) + } else { + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&int32(SQLITE_PRINTF_MALLOCED) != 0 { + v1 = (*TStrAccum)(unsafe.Pointer(p)).FzText + } else { + v1 = uintptr(0) + } + zOld = v1 + szNew = libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar) + N + int64(1) + if szNew+libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar) <= libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FmxAlloc) { + /* Force exponential buffer size growth as long as it does not overflow, + ** to avoid having to call this routine too often */ + szNew = szNew + libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar) + } + if szNew > libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FmxAlloc) { + Xsqlite3_str_reset(tls, p) + _sqlite3StrAccumSetError(tls, p, uint8(SQLITE_TOOBIG)) + return 0 + } else { + (*TStrAccum)(unsafe.Pointer(p)).FnAlloc = libc.Uint32FromInt32(int32(szNew)) + } + if (*TStrAccum)(unsafe.Pointer(p)).Fdb != 0 { + zNew = _sqlite3DbRealloc(tls, (*TStrAccum)(unsafe.Pointer(p)).Fdb, zOld, uint64((*TStrAccum)(unsafe.Pointer(p)).FnAlloc)) + } else { + zNew = _sqlite3Realloc(tls, zOld, uint64((*TStrAccum)(unsafe.Pointer(p)).FnAlloc)) + } + if zNew != 0 { + if !(libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED) != libc.Int32FromInt32(0)) && (*TStrAccum)(unsafe.Pointer(p)).FnChar > uint32(0) { + libc.X__builtin___memcpy_chk(tls, zNew, (*TStrAccum)(unsafe.Pointer(p)).FzText, uint64((*TStrAccum)(unsafe.Pointer(p)).FnChar), ^t__predefined_size_t(0)) + } + (*TStrAccum)(unsafe.Pointer(p)).FzText = zNew + (*TStrAccum)(unsafe.Pointer(p)).FnAlloc = libc.Uint32FromInt32(_sqlite3DbMallocSize(tls, (*TStrAccum)(unsafe.Pointer(p)).Fdb, zNew)) + v1 = p + 29 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) + } else { + Xsqlite3_str_reset(tls, p) + _sqlite3StrAccumSetError(tls, p, uint8(SQLITE_NOMEM)) + return 0 + } + } + return int32(N) +} + +// C documentation +// +// /* +// ** pTab is a transient Table object that represents a subquery of some +// ** kind (maybe a parenthesized subquery in the FROM clause of a larger +// ** query, or a VIEW, or a CTE). This routine computes type information +// ** for that Table object based on the Select object that implements the +// ** subquery. For the purposes of this routine, "type information" means: +// ** +// ** * The datatype name, as it might appear in a CREATE TABLE statement +// ** * Which collating sequence to use for the column +// ** * The affinity of the column +// */ +func _sqlite3SubqueryColumnTypes(tls *libc.TLS, pParse uintptr, pTab uintptr, pSelect uintptr, aff int8) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, db, p, pCol, pColl, pS2, zType, v4 uintptr + var i, j, m int32 + var k, n Ti64 + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _ = a, db, i, j, k, m, n, p, pCol, pColl, pS2, zType, v4 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return + } + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + a = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + 8 + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + i = 0 + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + m = 0 + pS2 = pSelect + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags) & libc.Int32FromInt32(COLFLAG_NOINSERT)) + p = (**(**TExprList_item)(__ccgo_up(a + uintptr(i)*32))).FpExpr + /* pCol->szEst = ... // Column size est for SELECT tables never used */ + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3ExprAffinity(tls, p) + for int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) <= int32(SQLITE_AFF_NONE) && (*TSelect)(unsafe.Pointer(pS2)).FpNext != uintptr(0) { + m = m | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) <= int32(SQLITE_AFF_NONE) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = aff + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_TEXT) && ((*TSelect)(unsafe.Pointer(pS2)).FpNext != 0 || pS2 != pSelect) { + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + for { + if !(pS2 != 0) { + break + } + m = m | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + goto _2 + _2: + ; + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_TEXT) && m&int32(0x01) != 0 { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = int8(SQLITE_AFF_BLOB) + } else { + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) && m&int32(0x02) != 0 { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = int8(SQLITE_AFF_BLOB) + } + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_CAST) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = int8(SQLITE_AFF_FLEXNUM) + } + } + zType = _columnTypeImpl(tls, bp, p, uintptr(0), uintptr(0), uintptr(0)) + if zType == uintptr(0) || int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) != int32(_sqlite3AffinityType(tls, zType, uintptr(0))) { + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_NUMERIC) || int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_FLEXNUM) { + zType = __ccgo_ts + 21042 + } else { + zType = uintptr(0) + j = int32(1) + for { + if !(j < int32(SQLITE_N_STDTYPE)) { + break + } + if int32(_sqlite3StdTypeAffinity[j]) == int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) { + zType = _sqlite3StdType[j] + break + } + goto _3 + _3: + ; + j = j + 1 + } + } + } + if zType != 0 { + k = libc.Int64FromUint64(libc.Xstrlen(tls, zType)) + n = libc.Int64FromUint64(libc.Xstrlen(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = _sqlite3DbReallocOrFree(tls, db, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, libc.Uint64FromInt64(n+k+int64(2))) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^(libc.Int32FromInt32(COLFLAG_HASTYPE) | libc.Int32FromInt32(COLFLAG_HASCOLL))) + if (*TColumn)(unsafe.Pointer(pCol)).FzCnName != 0 { + libc.X__builtin___memcpy_chk(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName+uintptr(n+int64(1)), zType, libc.Uint64FromInt64(k+int64(1)), ^t__predefined_size_t(0)) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_HASTYPE)) + } + } + pColl = _sqlite3ExprCollSeq(tls, pParse, p) + if pColl != 0 { + _sqlite3ColumnSetColl(tls, db, pCol, (*TCollSeq)(unsafe.Pointer(pColl)).FzName) + } + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + (*TTable)(unsafe.Pointer(pTab)).FszTabRow = int16(1) /* Any non-zero value works */ +} + +// C documentation +// +// /* +// ** Load the Parse object passed as the first argument with an error +// ** message of the form: +// ** +// ** "sub-select returns N columns - expected M" +// */ +func _sqlite3SubselectError(tls *libc.TLS, pParse uintptr, nActual int32, nExpect int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var zFmt uintptr + _ = zFmt + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + zFmt = __ccgo_ts + 8629 + _sqlite3ErrorMsg(tls, pParse, zFmt, libc.VaList(bp+8, nActual, nExpect)) + } +} + +// C documentation +// +// /* The table or view or trigger name is passed to this routine via tokens +// ** pName1 and pName2. If the table name was fully qualified, for example: +// ** +// ** CREATE TABLE xxx.yyy (...); +// ** +// ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if +// ** the table name is not fully qualified, i.e.: +// ** +// ** CREATE TABLE yyy(...); +// ** +// ** Then pName1 is set to "yyy" and pName2 is "". +// ** +// ** This routine sets the *ppUnqual pointer to point at the token (pName1 or +// ** pName2) that stores the unqualified table name. The index of the +// ** database "xxx" is returned. +// */ +func _sqlite3TwoPartName(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pUnqual uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db uintptr + var iDb int32 + _, _ = db, iDb /* Database holding the object */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TToken)(unsafe.Pointer(pName2)).Fn > uint32(0) { + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14070, 0) + return -int32(1) + } + **(**uintptr)(__ccgo_up(pUnqual)) = pName2 + iDb = _sqlite3FindDb(tls, db, pName1) + if iDb < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14087, libc.VaList(bp+8, pName1)) + return -int32(1) + } + } else { + iDb = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) + **(**uintptr)(__ccgo_up(pUnqual)) = pName1 + } + return iDb +} + +// C documentation +// +// /* +// ** Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation. +// */ +func _sqlite3UniqueConstraint(tls *libc.TLS, pParse uintptr, onError int32, pIdx uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var j, v2 int32 + var pTab, zCol, zErr uintptr + var _ /* errMsg at bp+0 */ TStrAccum + _, _, _, _, _ = j, pTab, zCol, zErr, v2 + pTab = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + _sqlite3StrAccumInit(tls, bp, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), 0, **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136))) + if (*TIndex)(unsafe.Pointer(pIdx)).FaColExpr != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+16547, libc.VaList(bp+40, (*TIndex)(unsafe.Pointer(pIdx)).FzName)) + } else { + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2)))*16))).FzCnName + if j != 0 { + Xsqlite3_str_append(tls, bp, __ccgo_ts+16558, int32(2)) + } + Xsqlite3_str_appendall(tls, bp, (*TTable)(unsafe.Pointer(pTab)).FzName) + Xsqlite3_str_append(tls, bp, __ccgo_ts+1741, int32(1)) + Xsqlite3_str_appendall(tls, bp, zCol) + goto _1 + _1: + ; + j = j + 1 + } + } + zErr = _sqlite3StrAccumFinish(tls, bp) + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + v2 = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(6)<nExpr, else 0 */ + /* Register Allocations */ + regRowCount = 0 /* A count of rows changed */ + regOldRowid = 0 /* The old rowid */ + regNewRowid = 0 /* The new rowid */ + regNew = 0 /* Content of the NEW.* table in triggers */ + regOld = 0 /* Content of OLD.* table in triggers */ + regRowSet = 0 /* Rowset of rows to be updated */ + regKey = 0 /* composite PRIMARY KEY value */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(16), ^t__predefined_size_t(0)) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto update_cleanup + } + /* Locate the table which we want to update. + */ + pTab = _sqlite3SrcListLookup(tls, pParse, pTabList) + if pTab == uintptr(0) { + goto update_cleanup + } + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + /* Figure out if we have any triggers and if the table being + ** updated is a view. + */ + pTrigger = _sqlite3TriggersExist(tls, pParse, pTab, int32(TK_UPDATE), pChanges, bp+72) + isView = libc.BoolInt32(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW)) + /* If there was a FROM clause, set nChangeFrom to the number of expressions + ** in the change-list. Otherwise, set it to 0. There cannot be a FROM + ** clause if this function is being called to generate code for part of + ** an UPSERT statement. */ + if (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc > int32(1) { + v1 = (*TExprList)(unsafe.Pointer(pChanges)).FnExpr + } else { + v1 = 0 + } + nChangeFrom = v1 + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto update_cleanup + } + if _sqlite3IsReadOnly(tls, pParse, pTab, pTrigger) != 0 { + goto update_cleanup + } + /* Allocate a cursors for the main database table and for all indices. + ** The index cursors might not be used, but if they are used they + ** need to occur right after the database cursor. So go ahead and + ** allocate enough space, just in case. + */ + v4 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = v2 + iDataCur = v1 + iBaseCur = v1 + iIdxCur = iDataCur + int32(1) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v4 = uintptr(0) + } else { + v4 = _sqlite3PrimaryKeyIndex(tls, pTab) + } + pPk = v4 + nIdx = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if pPk == pIdx { + iDataCur = (*TParse)(unsafe.Pointer(pParse)).FnTab + } + (*TParse)(unsafe.Pointer(pParse)).FnTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + 1 + goto _6 + _6: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + nIdx = nIdx + 1 + } + if pUpsert != 0 { + /* On an UPSERT, reuse the same cursors already opened by INSERT */ + iDataCur = (*TUpsert)(unsafe.Pointer(pUpsert)).FiDataCur + iIdxCur = (*TUpsert)(unsafe.Pointer(pUpsert)).FiIdxCur + (*TParse)(unsafe.Pointer(pParse)).FnTab = iBaseCur + } + (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor = iDataCur + /* Allocate space for aXRef[], aRegIdx[], and aToOpen[]. + ** Initialize aXRef[] and aToOpen[] to their default values. + */ + aXRef = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+nIdx+libc.Int32FromInt32(1))+libc.Uint64FromInt32(nIdx)+uint64(2))) + if aXRef == uintptr(0) { + goto update_cleanup + } + aRegIdx = aXRef + uintptr((*TTable)(unsafe.Pointer(pTab)).FnCol)*4 + aToOpen = aRegIdx + uintptr(nIdx)*4 + libc.UintptrFromInt32(1)*4 + libc.X__builtin___memset_chk(tls, aToOpen, int32(1), libc.Uint64FromInt32(nIdx+int32(1)), ^t__predefined_size_t(0)) + **(**Tu8)(__ccgo_up(aToOpen + uintptr(nIdx+int32(1)))) = uint8(0) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + **(**int32)(__ccgo_up(aXRef + uintptr(i)*4)) = -int32(1) + goto _7 + _7: + ; + i = i + 1 + } + /* Initialize the name-context */ + libc.X__builtin___memset_chk(tls, bp+16, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp + 16))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp + 16))).FpSrcList = pTabList + *(*uintptr)(unsafe.Pointer(bp + 16 + 16)) = pUpsert + (**(**TNameContext)(__ccgo_up(bp + 16))).FncFlags = int32(NC_UUpsert) + /* Begin generating code. */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto update_cleanup + } + /* Resolve the column names in all the expressions of the + ** of the UPDATE statement. Also find the column index + ** for each column to be updated in the pChanges array. For each + ** column to be updated, make sure we have authorization to change + ** that column. + */ + v8 = libc.Uint8FromInt32(0) + chngPk = v8 + chngRowid = v8 + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pChanges)).FnExpr) { + break + } + /* If this is an UPDATE with a FROM clause, do not resolve expressions + ** here. The call to sqlite3Select() below will do that. */ + if nChangeFrom == 0 && _sqlite3ResolveExprNames(tls, bp+16, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FpExpr) != 0 { + goto update_cleanup + } + j = _sqlite3ColumnIndex(tls, pTab, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FzEName) + if j >= 0 { + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + chngRowid = uint8(1) + pRowidExpr = (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FpExpr + iRowidExpr = i + } else { + if pPk != 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + chngPk = uint8(1) + } else { + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22929, libc.VaList(bp+112, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FzCnName)) + goto update_cleanup + } + } + } + **(**int32)(__ccgo_up(aXRef + uintptr(j)*4)) = i + } else { + if pPk == uintptr(0) && _sqlite3IsRowid(tls, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FzEName) != 0 { + j = -int32(1) + chngRowid = uint8(1) + pRowidExpr = (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FpExpr + iRowidExpr = i + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+12250, libc.VaList(bp+112, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FzEName)) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + goto update_cleanup + } + } + if j < 0 { + v4 = __ccgo_ts + 8541 + } else { + v4 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FzCnName + } + rc = _sqlite3AuthCheck(tls, pParse, int32(SQLITE_UPDATE), (*TTable)(unsafe.Pointer(pTab)).FzName, v4, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + if rc == int32(SQLITE_DENY) { + goto update_cleanup + } else { + if rc == int32(SQLITE_IGNORE) { + **(**int32)(__ccgo_up(aXRef + uintptr(j)*4)) = -int32(1) + } + } + goto _9 + _9: + ; + i = i + 1 + } + chngKey = libc.Uint8FromInt32(libc.Int32FromUint8(chngRowid) + libc.Int32FromUint8(chngPk)) + /* Mark generated columns as changing if their generator expressions + ** reference any changing column. The actual aXRef[] value for + ** generated expressions is not used, other than to check to see that it + ** is non-negative, so the value of aXRef[] for generated columns can be + ** set to any non-negative number. We use 99999 so that the value is + ** obvious when looking at aXRef[] in a symbolic debugger. + */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != 0 { + for cond := true; cond; cond = bProgress != 0 { + bProgress = 0 + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if **(**int32)(__ccgo_up(aXRef + uintptr(i)*4)) >= 0 { + goto _11 + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_GENERATED) == 0 { + goto _11 + } + if _sqlite3ExprReferencesUpdatedColumn(tls, _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16), aXRef, libc.Int32FromUint8(chngRowid)) != 0 { + **(**int32)(__ccgo_up(aXRef + uintptr(i)*4)) = int32(99999) + bProgress = int32(1) + } + goto _11 + _11: + ; + i = i + 1 + } + } + } + /* The SET expressions are not actually used inside the WHERE loop. + ** So reset the colUsed mask. Unless this is a virtual table. In that + ** case, set all bits of the colUsed mask (to ensure that the virtual + ** table implementation makes all columns available). + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + v12 = libc.Uint64FromInt32(-libc.Int32FromInt32(1)) + } else { + v12 = uint64(0) + } + (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FcolUsed = v12 + hasFK = _sqlite3FkRequired(tls, pParse, pTab, aXRef, libc.Int32FromUint8(chngKey)) + /* There is one entry in the aRegIdx[] array for each index on the table + ** being updated. Fill in aRegIdx[] with a register number that will hold + ** the key for accessing each index. + */ + if onError == int32(OE_Replace) { + **(**int32)(__ccgo_up(bp + 88)) = int32(1) + } + nAllIdx = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if chngKey != 0 || hasFK > int32(1) || pIdx == pPk || _indexWhereClauseMightChange(tls, pIdx, aXRef, libc.Int32FromUint8(chngRowid)) != 0 { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + reg = v1 + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } else { + reg = 0 + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + if _indexColumnIsBeingUpdated(tls, pIdx, i, aXRef, libc.Int32FromUint8(chngRowid)) != 0 { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + reg = v1 + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + if onError == int32(OE_Default) && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Replace) { + **(**int32)(__ccgo_up(bp + 88)) = int32(1) + } + break + } + goto _16 + _16: + ; + i = i + 1 + } + } + if reg == 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr(nAllIdx+int32(1)))) = uint8(0) + } + **(**int32)(__ccgo_up(aRegIdx + uintptr(nAllIdx)*4)) = reg + goto _13 + _13: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + nAllIdx = nAllIdx + 1 + } + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + **(**int32)(__ccgo_up(aRegIdx + uintptr(nAllIdx)*4)) = v1 /* Register storing the table record */ + if **(**int32)(__ccgo_up(bp + 88)) != 0 { + /* If REPLACE conflict resolution might be invoked, open cursors on all + ** indexes in case they are needed to delete records. */ + libc.X__builtin___memset_chk(tls, aToOpen, int32(1), libc.Uint64FromInt32(nIdx+int32(1)), ^t__predefined_size_t(0)) + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _sqlite3VdbeCountChanges(tls, v) + } + _sqlite3BeginWriteOperation(tls, pParse, libc.BoolInt32(pTrigger != 0 || hasFK != 0), iDb) + /* Allocate required registers. */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + /* For now, regRowSet and aRegIdx[nAllIdx] share the same register. + ** If regRowSet turns out to be needed, then aRegIdx[nAllIdx] will be + ** reallocated. aRegIdx[nAllIdx] is the register in which the main + ** table record is written. regRowSet holds the RowSet for the + ** two-pass update algorithm. */ + regRowSet = **(**int32)(__ccgo_up(aRegIdx + uintptr(nAllIdx)*4)) + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v2 = *(*int32)(unsafe.Pointer(v4)) + v1 = v2 + regNewRowid = v1 + regOldRowid = v1 + if chngPk != 0 || pTrigger != 0 || hasFK != 0 { + regOld = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } + if chngKey != 0 || pTrigger != 0 || hasFK != 0 { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regNewRowid = v1 + } + regNew = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } + /* Start the view context. */ + if isView != 0 { + _sqlite3AuthContextPush(tls, pParse, bp, (*TTable)(unsafe.Pointer(pTab)).FzName) + } + /* If we are trying to update a view, realize that view into + ** an ephemeral table. + */ + if nChangeFrom == 0 && isView != 0 { + _sqlite3MaterializeView(tls, pParse, pTab, pWhere, pOrderBy, pLimit, iDataCur) + pOrderBy = uintptr(0) + pLimit = uintptr(0) + } + /* Resolve the column names in all the expressions in the + ** WHERE clause. + */ + if nChangeFrom == 0 && _sqlite3ResolveExprNames(tls, bp+16, pWhere) != 0 { + goto update_cleanup + } + /* Virtual tables must be handled separately */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _updateVirtualTable(tls, pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, pWhere, onError) + goto update_cleanup + } + /* Jump to labelBreak to abandon further processing of this UPDATE */ + v1 = _sqlite3VdbeMakeLabel(tls, pParse) + labelBreak = v1 + labelContinue = v1 + /* Not an UPSERT. Normal processing. Begin by + ** initialize the count of updated rows */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00001))<>3)) != 0) && pUpsert == uintptr(0) { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regRowCount = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regRowCount) + } + if nChangeFrom == 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, regRowSet, regOldRowid) + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iEph = v1 + addrOpen = _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenEphemeral), iEph, 0, regRowSet) + } else { + if pPk != 0 { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } else { + v1 = 0 + } + nPk = int16(v1) + iPk = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(nPk) + **(**int32)(__ccgo_up(pParse + 60)) += nChangeFrom + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regKey = v1 + if pUpsert == uintptr(0) { + if isView != 0 { + v1 = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + v1 = 0 + } + nEphCol = int32(nPk) + nChangeFrom + v1 + v4 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iEph = v2 + if pPk != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, iPk, iPk+int32(nPk)-int32(1)) + } + addrOpen = _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), iEph, nEphCol) + if pPk != 0 { + pKeyInfo = _sqlite3KeyInfoOfIndex(tls, pParse, pPk) + if pKeyInfo != 0 { + (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField = libc.Uint16FromInt32(nEphCol) + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + } + } + if nChangeFrom != 0 { + _updateFromSelect(tls, pParse, iEph, pPk, pChanges, pTabList, pWhere, pOrderBy, pLimit) + if isView != 0 { + iDataCur = iEph + } + } + } + } + if nChangeFrom != 0 { + _sqlite3MultiWrite(tls, pParse) + eOnePass = ONEPASS_OFF + nKey = int32(nPk) + regKey = iPk + } else { + if pUpsert != 0 { + /* If this is an UPSERT, then all cursors have already been opened by + ** the outer INSERT and the data cursor should be pointing at the row + ** that is to be updated. So bypass the code that searches for the + ** row(s) to be updated. + */ + pWInfo = uintptr(0) + eOnePass = int32(ONEPASS_SINGLE) + _sqlite3ExprIfFalse(tls, pParse, pWhere, labelBreak, int32(SQLITE_JUMPIFNULL)) + bFinishSeek = 0 + } else { + /* Begin the database scan. + ** + ** Do not consider a single-pass strategy for a multi-row update if + ** there is anything that might disrupt the cursor being used to do + ** the UPDATE: + ** (1) This is a nested UPDATE + ** (2) There are triggers + ** (3) There are FOREIGN KEY constraints + ** (4) There are REPLACE conflict handlers + ** (5) There are subqueries in the WHERE clause + */ + flags = int32(WHERE_ONEPASS_DESIRED) + if !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) && !(pTrigger != 0) && !(hasFK != 0) && !(chngKey != 0) && !(**(**int32)(__ccgo_up(bp + 88)) != 0) && (pWhere == uintptr(0) || !((*TExpr)(unsafe.Pointer(pWhere)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != libc.Uint32FromInt32(0))) { + flags = flags | int32(WHERE_ONEPASS_MULTIROW) + } + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, uintptr(0), uintptr(0), uintptr(0), libc.Uint16FromInt32(flags), iIdxCur) + if pWInfo == uintptr(0) { + goto update_cleanup + } + /* A one-pass strategy that might update more than one row may not + ** be used if any column of the index used for the scan is being + ** updated. Otherwise, if there is an index on "b", statements like + ** the following could create an infinite loop: + ** + ** UPDATE t1 SET b=b+1 WHERE b>? + ** + ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI + ** strategy that uses an index for which one or more columns are being + ** updated. */ + eOnePass = _sqlite3WhereOkOnePass(tls, pWInfo, bp+80) + bFinishSeek = _sqlite3WhereUsesDeferredSeek(tls, pWInfo) + if eOnePass != int32(ONEPASS_SINGLE) { + _sqlite3MultiWrite(tls, pParse) + if eOnePass == int32(ONEPASS_MULTI) { + iCur = (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] + if iCur >= 0 && iCur != iDataCur && **(**Tu8)(__ccgo_up(aToOpen + uintptr(iCur-iBaseCur))) != 0 { + eOnePass = ONEPASS_OFF + } + } + } + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + /* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF + ** mode, write the rowid into the FIFO. In either of the one-pass modes, + ** leave it in register regOldRowid. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iDataCur, regOldRowid) + if eOnePass == ONEPASS_OFF { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + **(**int32)(__ccgo_up(aRegIdx + uintptr(nAllIdx)*4)) = v1 + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iEph, regRowSet, regOldRowid) + } else { + if addrOpen != 0 { + _sqlite3VdbeChangeToNoop(tls, v, addrOpen) + } + } + } else { + /* Read the PK of the current row into an array of registers. In + ** ONEPASS_OFF mode, serialize the array into a record and store it in + ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change + ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table + ** is not required) and leave the PK fields in the array of registers. */ + i = 0 + for { + if !(i < int32(nPk)) { + break + } + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))), iPk+i) + goto _39 + _39: + ; + i = i + 1 + } + if eOnePass != 0 { + if addrOpen != 0 { + _sqlite3VdbeChangeToNoop(tls, v, addrOpen) + } + nKey = int32(nPk) + regKey = iPk + } else { + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), iPk, int32(nPk), regKey, _sqlite3IndexAffinityStr(tls, db, pPk), int32(nPk)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iEph, regKey, iPk, int32(nPk)) + } + } + } + if pUpsert == uintptr(0) { + if nChangeFrom == 0 && eOnePass != int32(ONEPASS_MULTI) { + _sqlite3WhereEnd(tls, pWInfo) + } + if !(isView != 0) { + addrOnce = 0 + **(**int32)(__ccgo_up(bp + 92)) = 0 + **(**int32)(__ccgo_up(bp + 96)) = 0 + /* Open every index that needs updating. */ + if eOnePass != ONEPASS_OFF { + if (**(**[2]int32)(__ccgo_up(bp + 80)))[0] >= 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr((**(**[2]int32)(__ccgo_up(bp + 80)))[0]-iBaseCur))) = uint8(0) + } + if (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] >= 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr((**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)]-iBaseCur))) = uint8(0) + } + } + if eOnePass == int32(ONEPASS_MULTI) && nIdx-libc.BoolInt32((**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] >= 0) > 0 { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + _sqlite3OpenTableAndIndices(tls, pParse, pTab, int32(OP_OpenWrite), uint8(0), iBaseCur, aToOpen, bp+92, bp+96) + if addrOnce != 0 { + _sqlite3VdbeJumpHereOrPopInst(tls, v, addrOnce) + } + } + /* Top of the update loop */ + if eOnePass != ONEPASS_OFF { + if (**(**[2]int32)(__ccgo_up(bp + 80)))[0] != iDataCur && (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] != iDataCur { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), iDataCur, labelBreak, regKey, nKey) + } + if eOnePass != int32(ONEPASS_SINGLE) { + labelContinue = _sqlite3VdbeMakeLabel(tls, pParse) + } + if pPk != 0 { + v1 = regKey + } else { + v1 = regOldRowid + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), v1, labelBreak) + } else { + if pPk != 0 || nChangeFrom != 0 { + labelContinue = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iEph, labelBreak) + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + if nChangeFrom != 0 { + if !(isView != 0) { + if pPk != 0 { + i = 0 + for { + if !(i < int32(nPk)) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEph, i, iPk+i) + goto _41 + _41: + ; + i = i + 1 + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), iDataCur, labelContinue, iPk, int32(nPk)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iEph, regOldRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iDataCur, labelContinue, regOldRowid) + } + } + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowData), iEph, regKey) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), iDataCur, labelContinue, regKey, 0) + } + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iEph, labelBreak) + labelContinue = _sqlite3VdbeMakeLabel(tls, pParse) + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iEph, regOldRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iDataCur, labelContinue, regOldRowid) + } + } + } + /* If the rowid value will change, set register regNewRowid to + ** contain the new value. If the rowid is not being modified, + ** then regNewRowid is the same register as regOldRowid, which is + ** already populated. */ + if chngRowid != 0 { + if nChangeFrom == 0 { + _sqlite3ExprCode(tls, pParse, pRowidExpr, regNewRowid) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEph, iRowidExpr, regNewRowid) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_MustBeInt), regNewRowid) + } + /* Compute the old pre-UPDATE content of the row being changed, if that + ** information is needed */ + if chngPk != 0 || hasFK != 0 || pTrigger != 0 { + if hasFK != 0 { + v42 = _sqlite3FkOldmask(tls, pParse, pTab) + } else { + v42 = uint32(0) + } + oldmask = v42 + oldmask = oldmask | _sqlite3TriggerColmask(tls, pParse, pTrigger, pChanges, 0, libc.Int32FromInt32(TRIGGER_BEFORE)|libc.Int32FromInt32(TRIGGER_AFTER), pTab, onError) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + colFlags = uint32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags) + k = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(i))) + regOld + if oldmask == uint32(0xffffffff) || i < int32(32) && oldmask&(libc.Uint32FromInt32(1)<= 0 { + if nChangeFrom != 0 { + if isView != 0 { + v1 = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + v1 = int32(nPk) + } + nOff = v1 + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEph, nOff+j, k) + } else { + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(j)*32))).FpExpr, k) + } + } else { + if 0 == **(**int32)(__ccgo_up(bp + 72))&int32(TRIGGER_BEFORE) || i > int32(31) || libc.Uint32FromInt32(newmask)&(libc.Uint32FromInt32(1)< int32(1) || chngKey != 0 { + v1 = 0 + } else { + v1 = int32(OPFLAG_ISNOOP) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Delete), iDataCur, int32(OPFLAG_ISUPDATE)|v1, regNewRowid) + if eOnePass == int32(ONEPASS_MULTI) { + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION)) + } + if !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { + _sqlite3VdbeAppendP4(tls, v, pTab, -int32(5)) + } + if hasFK != 0 { + _sqlite3FkCheck(tls, pParse, pTab, 0, regNewRowid, aXRef, libc.Int32FromUint8(chngKey)) + } + /* Insert the new index entries and the new record. */ + if eOnePass == int32(ONEPASS_MULTI) { + v1 = int32(OPFLAG_SAVEPOSITION) + } else { + v1 = 0 + } + _sqlite3CompleteInsertion(tls, pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx, int32(OPFLAG_ISUPDATE)|v1, 0, 0) + /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to + ** handle rows (possibly in other tables) that refer via a foreign key + ** to the row just updated. */ + if hasFK != 0 { + _sqlite3FkActions(tls, pParse, pTab, pChanges, regOldRowid, aXRef, libc.Int32FromUint8(chngKey)) + } + } + /* Increment the row counter + */ + if regRowCount != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), regRowCount, int32(1)) + } + if pTrigger != 0 { + _sqlite3CodeRowTrigger(tls, pParse, pTrigger, int32(TK_UPDATE), pChanges, int32(TRIGGER_AFTER), pTab, regOldRowid, onError, labelContinue) + } + /* Repeat the above with the next record to be updated, until + ** all record selected by the WHERE clause have been updated. + */ + if eOnePass == int32(ONEPASS_SINGLE) { + /* Nothing to do at end-of-loop for a single-pass */ + } else { + if eOnePass == int32(ONEPASS_MULTI) { + _sqlite3VdbeResolveLabel(tls, v, labelContinue) + _sqlite3WhereEnd(tls, pWInfo) + } else { + _sqlite3VdbeResolveLabel(tls, v, labelContinue) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iEph, addrTop) + } + } + _sqlite3VdbeResolveLabel(tls, v, labelBreak) + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0) && pUpsert == uintptr(0) { + _sqlite3AutoincrementEnd(tls, pParse) + } + /* + ** Return the number of rows that were changed, if we are tracking + ** that information. + */ + if regRowCount != 0 { + _sqlite3CodeChangeCount(tls, v, regRowCount, __ccgo_ts+22965) + } + goto update_cleanup +update_cleanup: + ; + _sqlite3AuthContextPop(tls, bp) + _sqlite3DbFree(tls, db, aXRef) /* Also frees aRegIdx[] and aToOpen[] */ + _sqlite3SrcListDelete(tls, db, pTabList) + _sqlite3ExprListDelete(tls, db, pChanges) + _sqlite3ExprDelete(tls, db, pWhere) + return +} + +/* Make sure "isView" and other macros defined above are undefined. Otherwise +** they may interfere with compilation of other functions in this file +** (or in another file, if this file becomes part of the amalgamation). */ + +// C documentation +// +// /* +// ** Analyze the ON CONFLICT clause described by pUpsert. Resolve all +// ** symbols in the conflict-target. +// ** +// ** Return SQLITE_OK if everything works, or an error code is something +// ** is wrong. +// */ +func _sqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr, pUpsert uintptr, pAll uintptr) (r int32) { + bp := tls.Alloc(240) + defer tls.Free(240) + var iCursor, ii, jj, nClause, nn, rc int32 + var pExpr, pIdx, pTab, pTarget, pTerm, v2 uintptr + var v3 bool + var _ /* sCol at bp+56 */ [2]TExpr + var _ /* sNC at bp+0 */ TNameContext + var _ /* zWhich at bp+200 */ [16]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _ = iCursor, ii, jj, nClause, nn, pExpr, pIdx, pTab, pTarget, pTerm, rc, v2, v3 /* Index column converted into an Expr */ + nClause = 0 /* Counter of ON CONFLICT clauses */ + /* Resolve all symbolic names in the conflict-target clause, which + ** includes both the list of columns and the optional partial-index + ** WHERE clause. + */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pTabList + for { + if !(pUpsert != 0 && (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget != 0) { + break + } + rc = _sqlite3ResolveExprListNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) + if rc != 0 { + return rc + } + rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) + if rc != 0 { + return rc + } + /* Check to see if the conflict target matches the rowid. */ + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab + pTarget = (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget + iCursor = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor + if v3 = (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) && (*TExprList)(unsafe.Pointer(pTarget)).FnExpr == int32(1); v3 { + v2 = (*(*TExprList_item)(unsafe.Pointer(pTarget + 8))).FpExpr + pTerm = v2 + } + if v3 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(v2)).Fop) == int32(TK_COLUMN) && int32((*TExpr)(unsafe.Pointer(pTerm)).FiColumn) == -int32(1) { + /* The conflict-target is the rowid of the primary table */ + goto _1 + } + /* Initialize sCol[0..1] to be an expression parse tree for a + ** single column of an index. The sCol[0] node will be the TK_COLLATE + ** operator and sCol[1] will be the TK_COLUMN operator. Code below + ** will populate the specific collation and column number values + ** prior to comparing against the conflict-target expression. + */ + libc.X__builtin___memset_chk(tls, bp+56, 0, uint64(144), ^t__predefined_size_t(0)) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].Fop = uint8(TK_COLLATE) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = bp + 56 + 1*72 + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].Fop = uint8(TK_COLUMN) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].FiTable = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor + /* Check for matches against other indexes */ + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromInt32(OE_None)) { + goto _4 + } + if (*TExprList)(unsafe.Pointer(pTarget)).FnExpr != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + goto _4 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + if (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere == uintptr(0) { + goto _4 + } + if _sqlite3ExprCompare(tls, pParse, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere, (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere, iCursor) != 0 { + goto _4 + } + } + nn = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + ii = 0 + for { + if !(ii < nn) { + break + } + *(*uintptr)(unsafe.Pointer(bp + 56 + 8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(ii)*8)) + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2))) == -int32(2) { + pExpr = (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(ii)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLLATE) { + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = pExpr + pExpr = bp + 56 + } + } else { + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = bp + 56 + 1*72 + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].FiColumn = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2)) + pExpr = bp + 56 + } + jj = 0 + for { + if !(jj < nn) { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pTarget + 8 + uintptr(jj)*32))).FpExpr, pExpr, iCursor) < int32(2) { + break /* Column ii of the index matches column jj of target */ + } + goto _6 + _6: + ; + jj = jj + 1 + } + if jj >= nn { + /* The target contains no match for column jj of the index */ + break + } + goto _5 + _5: + ; + ii = ii + 1 + } + if ii < nn { + /* Column ii of the index did not match any term of the conflict target. + ** Continue the search with the next index. */ + goto _4 + } + (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx = pIdx + if _sqlite3UpsertOfIndex(tls, pAll, pIdx) != pUpsert { + /* Really this should be an error. The isDup ON CONFLICT clause will + ** never fire. But this problem was not discovered until three years + ** after multi-CONFLICT upsert was added, and so we silently ignore + ** the problem to prevent breaking applications that might actually + ** have redundant ON CONFLICT clauses. */ + (*TUpsert)(unsafe.Pointer(pUpsert)).FisDup = uint8(1) + } + break + goto _4 + _4: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx == uintptr(0) { + if nClause == 0 && (*TUpsert)(unsafe.Pointer(pUpsert)).FpNextUpsert == uintptr(0) { + (**(**[16]int8)(__ccgo_up(bp + 200)))[0] = 0 + } else { + Xsqlite3_snprintf(tls, int32(16), bp+200, __ccgo_ts+22978, libc.VaList(bp+224, nClause+int32(1))) + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22982, libc.VaList(bp+224, bp+200)) + return int32(SQLITE_ERROR) + } + goto _1 + _1: + ; + pUpsert = (*TUpsert)(unsafe.Pointer(pUpsert)).FpNextUpsert + nClause = nClause + 1 + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Generate bytecode that does an UPDATE as part of an upsert. +// ** +// ** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK. +// ** In this case parameter iCur is a cursor open on the table b-tree that +// ** currently points to the conflicting table row. Otherwise, if pIdx +// ** is not NULL, then pIdx is the constraint that failed and iCur is a +// ** cursor points to the conflicting row. +// */ +func _sqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab uintptr, pIdx uintptr, iCur int32) { + var db, pPk, pSrc, pTop, v uintptr + var i, iDataCur, iPk, k, nPk, regRowid int32 + _, _, _, _, _, _, _, _, _, _, _ = db, i, iDataCur, iPk, k, nPk, pPk, pSrc, pTop, regRowid, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTop = pUpsert + iDataCur = (*TUpsert)(unsafe.Pointer(pUpsert)).FiDataCur + pUpsert = _sqlite3UpsertOfIndex(tls, pTop, pIdx) + if pIdx != 0 && iCur != iDataCur { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + regRowid = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), iCur, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), iDataCur, 0, regRowid) + _sqlite3ReleaseTempReg(tls, pParse, regRowid) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + iPk = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPk + i = 0 + for { + if !(i < nPk) { + break + } + k = _sqlite3TableColumnToIndex(tls, pIdx, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iCur, k, iPk+i) + goto _1 + _1: + ; + i = i + 1 + } + i = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iDataCur, 0, iPk, nPk) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Halt), int32(SQLITE_CORRUPT), int32(OE_Abort), 0, __ccgo_ts+14070, -int32(1)) + _sqlite3MayAbort(tls, pParse) + _sqlite3VdbeJumpHere(tls, v, i) + } + } + /* pUpsert does not own pTop->pUpsertSrc - the outer INSERT statement does. + ** So we have to make a copy before passing it down into sqlite3Update() */ + pSrc = _sqlite3SrcListDup(tls, db, (*TUpsert)(unsafe.Pointer(pTop)).FpUpsertSrc, 0) + /* excluded.* columns of type REAL need to be converted to a hard real */ + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if int32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), (*TUpsert)(unsafe.Pointer(pTop)).FregData+i) + } + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3Update(tls, pParse, pSrc, _sqlite3ExprListDup(tls, db, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSet, 0), _sqlite3ExprDup(tls, db, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere, 0), int32(OE_Abort), uintptr(0), uintptr(0), pUpsert) +} + +/************** End of upsert.c **********************************************/ +/************** Begin file vacuum.c ******************************************/ +/* +** 2003 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the VACUUM command. +** +** Most of the code in this file may be omitted by defining the +** SQLITE_OMIT_VACUUM macro. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +// C documentation +// +// /* +// ** Convert a UTF-16 string in the native encoding into a UTF-8 string. +// ** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must +// ** be freed by the calling function. +// ** +// ** NULL is returned if there is an allocation error. +// */ +func _sqlite3Utf16to8(tls *libc.TLS, db uintptr, z uintptr, nByte int32, enc Tu8) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var _ /* m at bp+0 */ TMem + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TMem)(__ccgo_up(bp))).Fdb = db + _sqlite3VdbeMemSetStr(tls, bp, z, int64(nByte), enc, libc.UintptrFromInt32(0)) + _sqlite3VdbeChangeEncoding(tls, bp, int32(SQLITE_UTF8)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3VdbeMemRelease(tls, bp) + (**(**TMem)(__ccgo_up(bp))).Fz = uintptr(0) + } + return (**(**TMem)(__ccgo_up(bp))).Fz +} + +// C documentation +// +// /* +// ** Add a new name/number pair to a VList. This might require that the +// ** VList object be reallocated, so return the new VList. If an OOM +// ** error occurs, the original VList returned and the +// ** db->mallocFailed flag is set. +// ** +// ** A VList is really just an array of integers. To destroy a VList, +// ** simply pass it to sqlite3DbFree(). +// ** +// ** The first integer is the number of integers allocated for the whole +// ** VList. The second integer is the number of integers actually used. +// ** Each name/number pair is encoded by subsequent groups of 3 or more +// ** integers. +// ** +// ** Each name/number pair starts with two integers which are the numeric +// ** value for the pair and the size of the name/number pair, respectively. +// ** The text name overlays one or more following integers. The text name +// ** is always zero-terminated. +// ** +// ** Conceptually: +// ** +// ** struct VList { +// ** int nAlloc; // Number of allocated slots +// ** int nUsed; // Number of used slots +// ** struct VListEntry { +// ** int iValue; // Value for this entry +// ** int nSlot; // Slots used by this entry +// ** // ... variable name goes here +// ** } a[0]; +// ** } +// ** +// ** During code generation, pointers to the variable names within the +// ** VList are taken. When that happens, nAlloc is set to zero as an +// ** indication that the VList may never again be enlarged, since the +// ** accompanying realloc() would invalidate the pointers. +// */ +func _sqlite3VListAdd(tls *libc.TLS, db uintptr, pIn uintptr, zName uintptr, nName int32, iVal int32) (r uintptr) { + var i, nInt int32 + var nAlloc Tsqlite3_int64 + var pOut, z uintptr + var v1 int64 + _, _, _, _, _, _ = i, nAlloc, nInt, pOut, z, v1 /* Index in pIn[] where zName is stored */ + nInt = nName/int32(4) + int32(3) + /* Verify ok to add new elements */ + if pIn == uintptr(0) || **(**TVList)(__ccgo_up(pIn + 1*4))+nInt > **(**TVList)(__ccgo_up(pIn)) { + if pIn != 0 { + v1 = int64(2) * int64(**(**TVList)(__ccgo_up(pIn))) + } else { + v1 = int64(10) + } + /* Enlarge the allocation */ + nAlloc = v1 + int64(nInt) + pOut = _sqlite3DbRealloc(tls, db, pIn, libc.Uint64FromInt64(nAlloc)*uint64(4)) + if pOut == uintptr(0) { + return pIn + } + if pIn == uintptr(0) { + **(**TVList)(__ccgo_up(pOut + 1*4)) = int32(2) + } + pIn = pOut + **(**TVList)(__ccgo_up(pIn)) = int32(nAlloc) + } + i = **(**TVList)(__ccgo_up(pIn + 1*4)) + **(**TVList)(__ccgo_up(pIn + uintptr(i)*4)) = iVal + **(**TVList)(__ccgo_up(pIn + uintptr(i+int32(1))*4)) = nInt + z = pIn + uintptr(i+int32(2))*4 + **(**TVList)(__ccgo_up(pIn + 1*4)) = i + nInt + libc.X__builtin___memcpy_chk(tls, z, zName, libc.Uint64FromInt32(nName), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(z + uintptr(nName))) = 0 + return pIn +} + +// C documentation +// +// /* +// ** Add an opcode that includes the p4 value with a P4_INT64 or +// ** P4_REAL type. +// */ +func _sqlite3VdbeAddOp4Dup8(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, zP4 uintptr, p4type int32) (r int32) { + var p4copy uintptr + _ = p4copy + p4copy = _sqlite3DbMallocRawNN(tls, _sqlite3VdbeDb(tls, p), uint64(8)) + if p4copy != 0 { + libc.X__builtin___memcpy_chk(tls, p4copy, zP4, uint64(8), ^t__predefined_size_t(0)) + } + return _sqlite3VdbeAddOp4(tls, p, op, p1, p2, p3, p4copy, p4type) +} + +// C documentation +// +// /* +// ** Create a new virtual database engine. +// */ +func _sqlite3VdbeCreate(tls *libc.TLS, pParse uintptr) (r uintptr) { + var db, p uintptr + _, _ = db, p + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = _sqlite3DbMallocRawNN(tls, db, uint64(304)) + if p == uintptr(0) { + return uintptr(0) + } + libc.X__builtin___memset_chk(tls, p+136, 0, libc.Uint64FromInt64(304)-uint64(libc.UintptrFromInt32(0)+136), ^t__predefined_size_t(0)) + (*TVdbe)(unsafe.Pointer(p)).Fdb = db + if (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe != 0 { + (*TVdbe)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpVdbe)).FppVPrev = p + 16 + } + (*TVdbe)(unsafe.Pointer(p)).FpVNext = (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe + (*TVdbe)(unsafe.Pointer(p)).FppVPrev = db + 8 + (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe = p + (*TVdbe)(unsafe.Pointer(p)).FpParse = pParse + (*TParse)(unsafe.Pointer(pParse)).FpVdbe = p + _sqlite3VdbeAddOp2(tls, p, int32(OP_Init), 0, int32(1)) + return p +} + +// C documentation +// +// /* +// ** Compute a string that describes the P4 parameter for an opcode. +// ** Use zTemp for any required temporary buffer space. +// */ +func _sqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var ai, pColl, pColl1, pDef, pDef1, pKeyInfo, pMem, pSig, pVtab, zColl, zP4, v2, v3 uintptr + var i, n Tu32 + var j, v6 int32 + var _ /* x at bp+0 */ TStrAccum + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ai, i, j, n, pColl, pColl1, pDef, pDef1, pKeyInfo, pMem, pSig, pVtab, zColl, zP4, v2, v3, v6 + zP4 = uintptr(0) + _sqlite3StrAccumInit(tls, bp, uintptr(0), uintptr(0), 0, int32(SQLITE_MAX_LENGTH)) + switch int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) { + case -int32(9): + pKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5576, libc.VaList(bp+40, libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField))) + j = 0 + for { + if !(j < libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField)) { + break + } + pColl = *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(j)*8)) + if pColl != 0 { + v2 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v2 = __ccgo_ts + 1702 + } + zColl = v2 + if libc.Xstrcmp(tls, zColl, __ccgo_ts+5581) == 0 { + zColl = __ccgo_ts + 5588 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j))))&int32(KEYINFO_ORDER_DESC) != 0 { + v2 = __ccgo_ts + 5569 + } else { + v2 = __ccgo_ts + 1702 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j))))&int32(KEYINFO_ORDER_BIGNULL) != 0 { + v3 = __ccgo_ts + 5590 + } else { + v3 = __ccgo_ts + 1702 + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5593, libc.VaList(bp+40, v2, v3, zColl)) + goto _1 + _1: + ; + j = j + 1 + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5601, int32(1)) + case -int32(2): + pColl1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5617, libc.VaList(bp+40, (*TCollSeq)(unsafe.Pointer(pColl1)).FzName, _encnames[(*TCollSeq)(unsafe.Pointer(pColl1)).Fenc])) + case -int32(8): + pDef = *(*uintptr)(unsafe.Pointer(pOp + 16)) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5626, libc.VaList(bp+40, (*TFuncDef)(unsafe.Pointer(pDef)).FzName, int32((*TFuncDef)(unsafe.Pointer(pDef)).FnArg))) + case -int32(16): + pDef1 = (*Tsqlite3_context)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpFunc + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5626, libc.VaList(bp+40, (*TFuncDef)(unsafe.Pointer(pDef1)).FzName, int32((*TFuncDef)(unsafe.Pointer(pDef1)).FnArg))) + case -int32(14): + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+1463, libc.VaList(bp+40, **(**Ti64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))))) + case -int32(3): + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5633, libc.VaList(bp+40, (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) + case -int32(13): + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+1430, libc.VaList(bp+40, **(**float64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))))) + case -int32(11): + pMem = *(*uintptr)(unsafe.Pointer(pOp + 16)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Str) != 0 { + zP4 = (*TMem)(unsafe.Pointer(pMem)).Fz + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+1463, libc.VaList(bp+40, *(*Ti64)(unsafe.Pointer(pMem)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Real) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+1430, libc.VaList(bp+40, *(*float64)(unsafe.Pointer(pMem)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Null) != 0 { + zP4 = __ccgo_ts + 1703 + } else { + zP4 = __ccgo_ts + 5636 + } + } + } + } + case -int32(12): + pVtab = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5643, libc.VaList(bp+40, pVtab)) + case -int32(15): + ai = *(*uintptr)(unsafe.Pointer(pOp + 16)) + n = **(**Tu32)(__ccgo_up(ai)) /* The first element of an INTARRAY is always the + ** count of the number of elements to follow */ + i = uint32(1) + for { + if !(i <= n) { + break + } + if i == uint32(1) { + v6 = int32('[') + } else { + v6 = int32(',') + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5651, libc.VaList(bp+40, v6, **(**Tu32)(__ccgo_up(ai + uintptr(i)*4)))) + goto _5 + _5: + ; + i = i + 1 + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5656, int32(1)) + case -int32(4): + zP4 = __ccgo_ts + 5658 + case -int32(5): + zP4 = (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FzName + case -int32(6): + zP4 = (*TIndex)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FzName + case -int32(18): + pSig = *(*uintptr)(unsafe.Pointer(pOp + 16)) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5666, libc.VaList(bp+40, (*TSubrtnSig)(unsafe.Pointer(pSig)).FselId, (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff)) + default: + zP4 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + } + if zP4 != 0 { + Xsqlite3_str_appendall(tls, bp, zP4) + } + if libc.Int32FromUint8((**(**TStrAccum)(__ccgo_up(bp))).FaccError)&int32(SQLITE_NOMEM) != 0 { + _sqlite3OomFault(tls, db) + } + return _sqlite3StrAccumFinish(tls, bp) +} + +// C documentation +// +// /* +// ** Execute as much of a VDBE program as we can. +// ** This is the core of sqlite3_step(). +// */ +func _sqlite3VdbeExec(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(1024) + defer tls.Free(1024) + var aCol, aMem, aOffset, aOp, aPermute, aRoot, apArg, apArg1, db, pArgc, pBt, pBt1, pBt2, pBt3, pC, pC1, pC10, pC11, pC12, pC13, pC14, pC15, pC16, pC17, pC18, pC19, pC2, pC20, pC21, pC22, pC23, pC24, pC25, pC26, pC27, pC28, pC29, pC3, pC30, pC31, pC32, pC33, pC34, pC4, pC5, pC6, pC7, pC8, pC9, pCaller, pColl, pCrsr, pCrsr1, pCrsr2, pCrsr3, pCrsr4, pCrsr5, pCrsr6, pCrsr7, pCrsr8, pCtx, pCtx1, pCtx2, pCur, pCur1, pCur2, pCur3, pCur4, pCur5, pCur6, pCx, pCx1, pCx2, pCx3, pData, pData0, pDb, pDb1, pDb2, pDb3, pDest, pDest1, pDest2, pEnd, pFrame, pFrame1, pFrame2, pFrame3, pFrame4, pIdxKey, pIn, pIn1, pIn2, pIn3, pKey, pKeyInfo, pKeyInfo1, pKeyInfo2, pLast, pMem, pMem1, pMem2, pMem3, pMem4, pModule, pModule1, pModule2, pModule3, pModule4, pModule5, pModule6, pName, pNew, pOp, pOrig, pOut, pPager, pProgram, pQuery, pRec, pReg, pRhs, pRt, pSavepoint, pSrc, pTab, pTab1, pTab2, pTab3, pTabCur, pTmp, pVCur1, pVTab, pVar, pVtab, pVtab1, pVtab2, pVtab3, pVtab4, pVtab5, pVtab6, pVtab7, pX, pX1, pnErr, t1, z1, z2, z3, zAffinity, zAffinity1, zData, zDb, zDb1, zEndHdr, zErr, zFilename, zHdr, zHdr1, zName, zPayload, zSchema, zSql, zTab, zTrace, v191, v194 uintptr + var affinity int8 + var alreadyExists, bRev, c, c1, c2, cnt, cnt1, desiredAutoCommit, eNew, eOld, eqOnly, exists, i, i1, i2, i4, i5, i6, i7, i8, i9, iCompare, iCookie, iDb, iDb1, iDb2, iDb3, iQuery, iRollback, iSavepoint, iSet, ii, ii1, isLegacy, isSchemaChange, isTransaction, len1, n, n1, n2, n4, nArg, nArg1, nCol, nField, nField1, nField2, nHdr, nKeyCol, nMem, nName, nRoot, nStep, nVarint, oc, opflags, p1, p11, p12, p13, p2, p21, pcDest, pcx, rc, res, res11, res13, res14, res21, savedAnalysisLimit, seekResult, v11, v21, wrFlag, v190, v193 int32 + var colCacheCtr, iAddr, iMap, iPrior, idx, len11, n3, p22, p23, serialType, serial_type, v215, v216 Tu32 + var encoding, isWriteLock, mTrace, op, p5, resetSchemaOnFault, vtabOnConflict, v227 Tu8 + var flags1, flags11, flags2, flags3, flags31, newType, nullFlag, type1, type2, typeMask, v192 Tu16 + var h, h1, iKey1, nAlloc, nData, nProgressLimit, nVmStep, offset64, uu Tu64 + var i3, iA, iB1, iKey, iKey2, nByte, nByte1, nByte2, nCellKey, nZero, sz, v256 Ti64 + var newMax, v213 uint32 + var rA, rB float64 + var xAuth Tsqlite3_xauth + var v206 int64 + var v217 bool + var _ /* aRes at bp+760 */ [3]int32 + var _ /* iA at bp+8 */ Ti64 + var _ /* iB at bp+0 */ Ti64 + var _ /* iMeta at bp+104 */ int32 + var _ /* iMeta at bp+108 */ int32 + var _ /* iMoved at bp+608 */ int32 + var _ /* initData at bp+640 */ TInitData + var _ /* m at bp+552 */ TMem + var _ /* nChange at bp+616 */ Ti64 + var _ /* nEntry at bp+96 */ Ti64 + var _ /* nErr at bp+680 */ int32 + var _ /* nullFunc at bp+896 */ TFuncDef + var _ /* pVCur at bp+832 */ uintptr + var _ /* pgno at bp+624 */ TPgno + var _ /* r at bp+120 */ TUnpackedRecord + var _ /* r at bp+168 */ TUnpackedRecord + var _ /* r at bp+208 */ TUnpackedRecord + var _ /* r at bp+464 */ TUnpackedRecord + var _ /* r at bp+512 */ TUnpackedRecord + var _ /* r at bp+704 */ TUnpackedRecord + var _ /* res at bp+112 */ int32 + var _ /* res at bp+160 */ int32 + var _ /* res at bp+248 */ int32 + var _ /* res at bp+320 */ int32 + var _ /* res at bp+376 */ int32 + var _ /* res at bp+392 */ int32 + var _ /* res at bp+396 */ int32 + var _ /* res at bp+400 */ int32 + var _ /* res at bp+404 */ int32 + var _ /* res at bp+456 */ int32 + var _ /* res at bp+696 */ int32 + var _ /* rowid at bp+504 */ Ti64 + var _ /* rowid at bp+968 */ Tsqlite_int64 + var _ /* sContext at bp+848 */ Tsqlite3_context + var _ /* sMem at bp+24 */ TMem + var _ /* sMem at bp+776 */ TMem + var _ /* t at bp+80 */ Tu32 + var _ /* uA at bp+16 */ Tu64 + var _ /* v at bp+312 */ Ti64 + var _ /* v at bp+384 */ Ti64 + var _ /* v at bp+88 */ Tu64 + var _ /* val at bp+744 */ Ti64 + var _ /* x at bp+256 */ TMem + var _ /* x at bp+328 */ TBtreePayload + var _ /* x at bp+408 */ TBtreePayload + var _ /* x at bp+752 */ Ti64 + var _ /* z at bp+688 */ uintptr + var _ /* zErr at bp+632 */ uintptr + var _ /* zErr at bp+840 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCol, aMem, aOffset, aOp, aPermute, aRoot, affinity, alreadyExists, apArg, apArg1, bRev, c, c1, c2, cnt, cnt1, colCacheCtr, db, desiredAutoCommit, eNew, eOld, encoding, eqOnly, exists, flags1, flags11, flags2, flags3, flags31, h, h1, i, i1, i2, i3, i4, i5, i6, i7, i8, i9, iA, iAddr, iB1, iCompare, iCookie, iDb, iDb1, iDb2, iDb3, iKey, iKey1, iKey2, iMap, iPrior, iQuery, iRollback, iSavepoint, iSet, idx, ii, ii1, isLegacy, isSchemaChange, isTransaction, isWriteLock, len1, len11, mTrace, n, n1, n2, n3, n4, nAlloc, nArg, nArg1, nByte, nByte1, nByte2, nCellKey, nCol, nData, nField, nField1, nField2, nHdr, nKeyCol, nMem, nName, nProgressLimit, nRoot, nStep, nVarint, nVmStep, nZero, newMax, newType, nullFlag, oc, offset64, op, opflags, p1, p11, p12, p13, p2, p21, p22, p23, p5, pArgc, pBt, pBt1, pBt2, pBt3, pC, pC1, pC10, pC11, pC12, pC13, pC14, pC15, pC16, pC17, pC18, pC19, pC2, pC20, pC21, pC22, pC23, pC24, pC25, pC26, pC27, pC28, pC29, pC3, pC30, pC31, pC32, pC33, pC34, pC4, pC5, pC6, pC7, pC8, pC9, pCaller, pColl, pCrsr, pCrsr1, pCrsr2, pCrsr3, pCrsr4, pCrsr5, pCrsr6, pCrsr7, pCrsr8, pCtx, pCtx1, pCtx2, pCur, pCur1, pCur2, pCur3, pCur4, pCur5, pCur6, pCx, pCx1, pCx2, pCx3, pData, pData0, pDb, pDb1, pDb2, pDb3, pDest, pDest1, pDest2, pEnd, pFrame, pFrame1, pFrame2, pFrame3, pFrame4, pIdxKey, pIn, pIn1, pIn2, pIn3, pKey, pKeyInfo, pKeyInfo1, pKeyInfo2, pLast, pMem, pMem1, pMem2, pMem3, pMem4, pModule, pModule1, pModule2, pModule3, pModule4, pModule5, pModule6, pName, pNew, pOp, pOrig, pOut, pPager, pProgram, pQuery, pRec, pReg, pRhs, pRt, pSavepoint, pSrc, pTab, pTab1, pTab2, pTab3, pTabCur, pTmp, pVCur1, pVTab, pVar, pVtab, pVtab1, pVtab2, pVtab3, pVtab4, pVtab5, pVtab6, pVtab7, pX, pX1, pcDest, pcx, pnErr, rA, rB, rc, res, res11, res13, res14, res21, resetSchemaOnFault, savedAnalysisLimit, seekResult, serialType, serial_type, sz, t1, type1, type2, typeMask, uu, v11, v21, vtabOnConflict, wrFlag, xAuth, z1, z2, z3, zAffinity, zAffinity1, zData, zDb, zDb1, zEndHdr, zErr, zFilename, zHdr, zHdr1, zName, zPayload, zSchema, zSql, zTab, zTrace, v190, v191, v192, v193, v194, v206, v213, v215, v216, v217, v227, v256 + aOp = (*TVdbe)(unsafe.Pointer(p)).FaOp /* Copy of p->aOp */ + pOp = aOp /* Current operation */ + rc = SQLITE_OK /* Value to return */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb /* The database */ + resetSchemaOnFault = uint8(0) /* Reset schema after an error if positive */ + encoding = (*Tsqlite3)(unsafe.Pointer(db)).Fenc /* The database encoding */ + iCompare = 0 /* Result of last comparison */ + nVmStep = uint64(0) /* Invoke xProgress() when nVmStep reaches this */ + aMem = (*TVdbe)(unsafe.Pointer(p)).FaMem /* Copy of p->aMem */ + pIn1 = uintptr(0) /* 1st input operand */ + pIn2 = uintptr(0) /* 2nd input operand */ + pIn3 = uintptr(0) /* 3rd input operand */ + pOut = uintptr(0) /* Output operand */ + colCacheCtr = uint32(0) /* Column cache counter */ + /*** INSERT STACK UNION HERE ***/ + /* sqlite3_step() verifies this */ + if (*TVdbe)(unsafe.Pointer(p)).FlockMask != uint32(0) { + _sqlite3VdbeEnter(tls, p) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != 0 { + iPrior = **(**Tu32)(__ccgo_up(p + 212 + 4*4)) + nProgressLimit = uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps - iPrior%(*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + } else { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)<= nProgressLimit && (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0) { + nProgressLimit = nProgressLimit + uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)< 0 && int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == P4_NOTUSED { + zErr = _sqlite3ValueText(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, uint8(SQLITE_UTF8)) + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, zErr)) + } else { + if (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+6200, libc.VaList(bp+984, _azType[libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)-int32(1)])) + if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3MPrintf(tls, db, __ccgo_ts+6221, libc.VaList(bp+984, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + } + } else { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + } + } + _sqlite3VdbeLogAbort(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, pOp, aOp) + } + rc = _sqlite3VdbeHalt(tls, p) + if rc == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_BUSY) + } else { + if (*TVdbe)(unsafe.Pointer(p)).Frc != 0 { + v190 = int32(SQLITE_ERROR) + } else { + v190 = int32(SQLITE_DONE) + } + rc = v190 + } + goto vdbe_return + /* Opcode: Integer P1 P2 * * * + ** Synopsis: r[P2]=P1 + ** + ** The 32-bit integer value P1 is written into register P2. + */ + _10: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = int64((*TOp)(unsafe.Pointer(pOp)).Fp1) + goto _189 + /* Opcode: Int64 * P2 * P4 * + ** Synopsis: r[P2]=P4 + ** + ** P4 is a pointer to a 64-bit integer value. + ** Write that value into register P2. + */ + _11: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))) + goto _189 + /* Opcode: Real * P2 * P4 * + ** Synopsis: r[P2]=P4 + ** + ** P4 is a pointer to a 64-bit floating point value. + ** Write that value into register P2. + */ + _12: + ; /* same as TK_FLOAT, out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Real) + *(*float64)(unsafe.Pointer(pOut)) = **(**float64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))) + goto _189 + /* Opcode: String8 * P2 * P4 * + ** Synopsis: r[P2]='P4' + ** + ** P4 points to a nul terminated UTF-8 string. This opcode is transformed + ** into a String opcode before it is executed for the first time. During + ** this transformation, the length of string P4 is computed and stored + ** as the P1 parameter. + */ + _13: + ; /* same as TK_STRING, out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TOp)(unsafe.Pointer(pOp)).Fp1 = _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pOp + 16))) + if libc.Int32FromUint8(encoding) != int32(SQLITE_UTF8) { + rc = _sqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64(-int32(1)), uint8(SQLITE_UTF8), libc.UintptrFromInt32(0)) + if rc != 0 { + goto too_big + } + if SQLITE_OK != _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8(encoding)) { + goto no_mem + } + (*TMem)(unsafe.Pointer(pOut)).FszMalloc = 0 + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Static)) + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(7) { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + (*TOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = (*TMem)(unsafe.Pointer(pOut)).Fz + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (*TMem)(unsafe.Pointer(pOut)).Fn + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 > **(**int32)(__ccgo_up(db + 136)) { + goto too_big + } + (*TOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_String) + /* Fall through to the next case, OP_String */ + /* Opcode: String P1 P2 P3 P4 P5 + ** Synopsis: r[P2]='P4' (len=P1) + ** + ** The string value P4 of length P1 (bytes) is stored in register P2. + ** + ** If P3 is not zero and the content of register P3 is equal to P5, then + ** the datatype of the register P2 is converted to BLOB. The content is + ** the same sequence of bytes, it is merely interpreted as a BLOB instead + ** of a string, as if it had been CAST. In other words: + ** + ** if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB) + */ + _14: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fz = *(*uintptr)(unsafe.Pointer(pOp + 16)) + (*TMem)(unsafe.Pointer(pOut)).Fn = (*TOp)(unsafe.Pointer(pOp)).Fp1 + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: BeginSubrtn * P2 * * * + ** Synopsis: r[P2]=NULL + ** + ** Mark the beginning of a subroutine that can be entered in-line + ** or that can be called using OP_Gosub. The subroutine should + ** be terminated by an OP_Return instruction that has a P1 operand that + ** is the same as the P2 operand to this opcode and that has P3 set to 1. + ** If the subroutine is entered in-line, then the OP_Return will simply + ** fall through. But if the subroutine is entered using OP_Gosub, then + ** the OP_Return will jump back to the first instruction after the OP_Gosub. + ** + ** This routine works by loading a NULL into the P2 register. When the + ** return address register contains a NULL, the OP_Return instruction is + ** a no-op that simply falls through to the next instruction (assuming that + ** the OP_Return opcode has a P3 value of 1). Thus if the subroutine is + ** entered in-line, then the OP_Return will cause in-line execution to + ** continue. But if the subroutine is entered via OP_Gosub, then the + ** OP_Return will cause a return to the address following the OP_Gosub. + ** + ** This opcode is identical to OP_Null. It has a different name + ** only to make the byte code easier to read and verify. + */ + /* Opcode: Null P1 P2 P3 * * + ** Synopsis: r[P2..P3]=NULL + ** + ** Write a NULL into registers P2. If P3 greater than P2, then also write + ** NULL into register P3 and every register in between P2 and P3. If P3 + ** is less than P2 (typically P3 is zero) then only register P2 is + ** set to NULL. + ** + ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that + ** NULL values will not compare equal even if SQLITE_NULLEQ is set on + ** OP_Ne or OP_Eq. + */ + _16: + ; + _15: + ; + pOut = _out2Prerelease(tls, p, pOp) + cnt = (*TOp)(unsafe.Pointer(pOp)).Fp3 - (*TOp)(unsafe.Pointer(pOp)).Fp2 + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + v190 = libc.Int32FromInt32(MEM_Null) | libc.Int32FromInt32(MEM_Cleared) + } else { + v190 = int32(MEM_Null) + } + v192 = libc.Uint16FromInt32(v190) + nullFlag = v192 + (*TMem)(unsafe.Pointer(pOut)).Fflags = v192 + (*TMem)(unsafe.Pointer(pOut)).Fn = 0 + for cnt > 0 { + pOut += 56 + _sqlite3VdbeMemSetNull(tls, pOut) + (*TMem)(unsafe.Pointer(pOut)).Fflags = nullFlag + (*TMem)(unsafe.Pointer(pOut)).Fn = 0 + cnt = cnt - 1 + } + goto _189 + /* Opcode: SoftNull P1 * * * * + ** Synopsis: r[P1]=NULL + ** + ** Set register P1 to have the value NULL as seen by the OP_MakeRecord + ** instruction, but do not free any string or blob memory associated with + ** the register, so that if the value was a string or blob that was + ** previously copied using OP_SCopy, the copies will continue to be valid. + */ + _17: + ; + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_Undefined)|libc.Int32FromInt32(MEM_AffMask)) | int32(MEM_Null)) + goto _189 + /* Opcode: Blob P1 P2 * P4 * + ** Synopsis: r[P2]=P4 (len=P1) + ** + ** P4 points to a blob of data P1 bytes long. Store this + ** blob in register P2. If P4 is a NULL pointer, then construct + ** a zero-filled blob that is P1 bytes long in P2. + */ + _18: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + if *(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0) { + _sqlite3VdbeMemSetZeroBlob(tls, pOut, (*TOp)(unsafe.Pointer(pOp)).Fp1) + if _sqlite3VdbeMemExpandBlob(tls, pOut) != 0 { + goto no_mem + } + } else { + _sqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64((*TOp)(unsafe.Pointer(pOp)).Fp1), uint8(0), uintptr(0)) + } + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: Variable P1 P2 * * * + ** Synopsis: r[P2]=parameter(P1) + ** + ** Transfer the values of bound parameter P1 into register P2 + */ + _19: + ; /* Value being transferred */ + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1-int32(1))*56 + if _sqlite3VdbeMemTooBig(tls, pVar) != 0 { + goto too_big + } + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + } + libc.X__builtin___memcpy_chk(tls, pOut, pVar, uint64(libc.UintptrFromInt32(0)+24), ^t__predefined_size_t(0)) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Ephem))) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | (libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_FromBind))) + goto _189 + /* Opcode: Move P1 P2 P3 * * + ** Synopsis: r[P2@P3]=r[P1@P3] + ** + ** Move the P3 values in register P1..P1+P3-1 over into + ** registers P2..P2+P3-1. Registers P1..P1+P3-1 are + ** left holding a NULL. It is an error for register ranges + ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error + ** for P3 to be less than 1. + */ + _20: + ; /* Register to copy to */ + n = (*TOp)(unsafe.Pointer(pOp)).Fp3 + p1 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + p2 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pIn1 = aMem + uintptr(p1)*56 + pOut = aMem + uintptr(p2)*56 + for { + _sqlite3VdbeMemMove(tls, pOut, pIn1) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + pIn1 += 56 + pOut += 56 + goto _197 + _197: + ; + n = n - 1 + v190 = n + if !(v190 != 0) { + break + } + } + goto _189 + /* Opcode: Copy P1 P2 P3 * P5 + ** Synopsis: r[P2@P3+1]=r[P1@P3+1] + ** + ** Make a copy of registers P1..P1+P3 into registers P2..P2+P3. + ** + ** If the 0x0002 bit of P5 is set then also clear the MEM_Subtype flag in the + ** destination. The 0x0001 bit of P5 indicates that this Copy opcode cannot + ** be merged. The 0x0001 bit is used by the query planner and does not + ** come into play during query execution. + ** + ** This instruction makes a deep copy of the value. A duplicate + ** is made of any string or blob constant. See also OP_SCopy. + */ + _21: + ; + n1 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + for int32(1) != 0 { + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn1, int32(MEM_Ephem)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Subtype) != 0 && libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(0x0002) != 0 { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + } + v190 = n1 + n1 = n1 - 1 + if v190 == 0 { + break + } + pOut += 56 + pIn1 += 56 + } + goto _189 + /* Opcode: SCopy P1 P2 * * * + ** Synopsis: r[P2]=r[P1] + ** + ** Make a shallow copy of register P1 into register P2. + ** + ** This instruction makes a shallow copy of the value. If the value + ** is a string or blob, then the copy is only a pointer to the + ** original and hence if the original changes so will the copy. + ** Worse, if the original is deallocated, the copy becomes invalid. + ** Thus the program must guarantee that the original will not change + ** during the lifetime of the copy. Use OP_Copy to make a complete + ** copy. + */ + _22: + ; /* out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn1, int32(MEM_Ephem)) + goto _189 + /* Opcode: IntCopy P1 P2 * * * + ** Synopsis: r[P2]=r[P1] + ** + ** Transfer the integer value held in register P1 into register P2. + ** + ** This is an optimized version of SCopy that works only for integer + ** values. + */ + _23: + ; /* out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemSetInt64(tls, pOut, *(*Ti64)(unsafe.Pointer(pIn1))) + goto _189 + /* Opcode: FkCheck * * * * * + ** + ** Halt with an SQLITE_CONSTRAINT error if there are any unresolved + ** foreign key constraint violations. If there are no foreign key + ** constraint violations, this is a no-op. + ** + ** FK constraint violations are also checked when the prepared statement + ** exits. This opcode is used to raise foreign key constraint errors prior + ** to returning results such as a row change count or the result of a + ** RETURNING clause. + */ + _24: + ; + v190 = _sqlite3VdbeCheckFkImmediate(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto abort_due_to_error + } + goto _189 + /* Opcode: ResultRow P1 P2 * * * + ** Synopsis: output=r[P1@P2] + ** + ** The registers P1 through P1+P2-1 contain a single row of + ** results. This opcode causes the sqlite3_step() call to terminate + ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt + ** structure to provide access to the r(P1)..r(P1+P2-1) values as + ** the result row. + */ + _25: + ; + (*TVdbe)(unsafe.Pointer(p)).FcacheCtr = (*TVdbe)(unsafe.Pointer(p)).FcacheCtr + uint32(2) | uint32(1) + (*TVdbe)(unsafe.Pointer(p)).FpResultRow = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto no_mem + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_ROW) != 0 { + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_ROW), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0)) + } + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp)-int64(aOp))/24) + int32(1) + rc = int32(SQLITE_ROW) + goto vdbe_return + /* Opcode: Concat P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]+r[P1] + ** + ** Add the text in register P1 onto the end of the text in + ** register P2 and store the result in register P3. + ** If either the P1 or P2 text are NULL then store NULL in P3. + ** + ** P3 = P2 || P1 + ** + ** It is illegal for P1 and P3 to be the same register. Sometimes, + ** if P3 is the same register as P2, the implementation is able + ** to avoid a memcpy(). + */ + _26: + ; /* Initial flags for P2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags1 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + if (libc.Int32FromUint16(flags1)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags))&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + goto _189 + } + if libc.Int32FromUint16(flags1)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) == 0 { + if _sqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(0)) != 0 { + goto no_mem + } + flags1 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } else { + if libc.Int32FromUint16(flags1)&int32(MEM_Zero) != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pIn1) != 0 { + goto no_mem + } + flags1 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } + } + flags2 = (*TMem)(unsafe.Pointer(pIn2)).Fflags + if libc.Int32FromUint16(flags2)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) == 0 { + if _sqlite3VdbeMemStringify(tls, pIn2, encoding, uint8(0)) != 0 { + goto no_mem + } + flags2 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } else { + if libc.Int32FromUint16(flags2)&int32(MEM_Zero) != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pIn2) != 0 { + goto no_mem + } + flags2 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } + } + nByte = int64((*TMem)(unsafe.Pointer(pIn1)).Fn) + nByte = nByte + int64((*TMem)(unsafe.Pointer(pIn2)).Fn) + if nByte > int64(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + if _sqlite3VdbeMemGrow(tls, pOut, int32(nByte)+int32(2), libc.BoolInt32(pOut == pIn2)) != 0 { + goto no_mem + } + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Str)) + if pOut != pIn2 { + libc.X__builtin___memcpy_chk(tls, (*TMem)(unsafe.Pointer(pOut)).Fz, (*TMem)(unsafe.Pointer(pIn2)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn2)).Fn), ^t__predefined_size_t(0)) + (*TMem)(unsafe.Pointer(pIn2)).Fflags = flags2 + } + libc.X__builtin___memcpy_chk(tls, (*TMem)(unsafe.Pointer(pOut)).Fz+uintptr((*TMem)(unsafe.Pointer(pIn2)).Fn), (*TMem)(unsafe.Pointer(pIn1)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn), ^t__predefined_size_t(0)) + (*TMem)(unsafe.Pointer(pIn1)).Fflags = flags1 + if libc.Int32FromUint8(encoding) > int32(SQLITE_UTF8) { + nByte = nByte & int64(^libc.Int32FromInt32(1)) + } + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte))) = 0 + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte+int64(1)))) = 0 + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fn = int32(nByte) + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: Add P1 P2 P3 * * + ** Synopsis: r[P3]=r[P1]+r[P2] + ** + ** Add the value in register P1 to the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Multiply P1 P2 P3 * * + ** Synopsis: r[P3]=r[P1]*r[P2] + ** + ** + ** Multiply the value in register P1 by the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Subtract P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]-r[P1] + ** + ** Subtract the value in register P1 from the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Divide P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]/r[P1] + ** + ** Divide the value in register P1 by the value in register P2 + ** and store the result in register P3 (P3=P2/P1). If the value in + ** register P1 is zero, then the result is NULL. If either input is + ** NULL, the result is NULL. + */ + /* Opcode: Remainder P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]%r[P1] + ** + ** Compute the remainder after integer register P2 is divided by + ** register P1 and store the result in register P3. + ** If the value in register P1 is zero the result is NULL. + ** If either operand is NULL, the result is NULL. + */ + _31: + ; /* same as TK_PLUS, in1, in2, out3 */ + _30: + ; /* same as TK_MINUS, in1, in2, out3 */ + _29: + ; /* same as TK_STAR, in1, in2, out3 */ + _28: + ; /* same as TK_SLASH, in1, in2, out3 */ + _27: + ; /* Real value of right operand */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + type1 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + type2 = (*TMem)(unsafe.Pointer(pIn2)).Fflags + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if !(libc.Int32FromUint16(type1)&libc.Int32FromUint16(type2)&int32(MEM_Int) != 0) { + goto _202 + } + goto int_math + int_math: + ; + iA = *(*Ti64)(unsafe.Pointer(pIn1)) + **(**Ti64)(__ccgo_up(bp)) = *(*Ti64)(unsafe.Pointer(pIn2)) + switch libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) { + case int32(OP_Add): + if _sqlite3AddInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Subtract): + if _sqlite3SubInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Multiply): + if _sqlite3MulInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Divide): + if iA == 0 { + goto arithmetic_result_is_null + } + if iA == int64(-int32(1)) && **(**Ti64)(__ccgo_up(bp)) == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>r[P1] + ** + ** Shift the integer value in register P2 to the right by the + ** number of bits specified by the integer in register P1. + ** Store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + _36: + ; /* same as TK_BITAND, in1, in2, out3 */ + _35: + ; /* same as TK_BITOR, in1, in2, out3 */ + _34: + ; /* same as TK_LSHIFT, in1, in2, out3 */ + _33: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if (libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags))&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + goto _189 + } + **(**Ti64)(__ccgo_up(bp + 8)) = _sqlite3VdbeIntValue(tls, pIn2) + iB1 = _sqlite3VdbeIntValue(tls, pIn1) + op = (*TOp)(unsafe.Pointer(pOp)).Fopcode + if libc.Int32FromUint8(op) == int32(OP_BitAnd) { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) & iB1 + } else { + if libc.Int32FromUint8(op) == int32(OP_BitOr) { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) | iB1 + } else { + if iB1 != 0 { + /* If shifting by a negative amount, shift in the other direction */ + if iB1 < 0 { + op = libc.Uint8FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(OP_ShiftLeft) + libc.Int32FromInt32(1) - libc.Int32FromUint8(op)) + if iB1 > int64(-libc.Int32FromInt32(64)) { + v206 = -iB1 + } else { + v206 = int64(64) + } + iB1 = v206 + } + if iB1 >= int64(64) { + if **(**Ti64)(__ccgo_up(bp + 8)) >= 0 || libc.Int32FromUint8(op) == int32(OP_ShiftLeft) { + v190 = 0 + } else { + v190 = -int32(1) + } + **(**Ti64)(__ccgo_up(bp + 8)) = int64(v190) + } else { + libc.X__builtin___memcpy_chk(tls, bp+16, bp+8, uint64(8), ^t__predefined_size_t(0)) + if libc.Int32FromUint8(op) == int32(OP_ShiftLeft) { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) << libc.Uint64FromInt64(iB1) + } else { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) >> libc.Uint64FromInt64(iB1) + /* Sign-extend on a right shift of a negative number */ + if **(**Ti64)(__ccgo_up(bp + 8)) < 0 { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) | (libc.Uint64FromUint32(0xffffffff)< + **
  • P2=='A' → BLOB + **
  • P2=='B' → TEXT + **
  • P2=='C' → NUMERIC + **
  • P2=='D' → INTEGER + **
  • P2=='E' → REAL + ** + ** + ** A NULL value is not changed by this routine. It remains NULL. + */ + _40: + ; /* in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn1) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + rc = _sqlite3VdbeMemCast(tls, pIn1, libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2), encoding) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Eq P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]==r[P1] + ** + ** Compare the values in register P1 and P3. If reg(P3)==reg(P1) then + ** jump to address P2. + ** + ** The SQLITE_AFF_MASK portion of P5 must be an affinity character - + ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made + ** to coerce both inputs according to this affinity before the + ** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric + ** affinity is used. Note that the affinity conversions are stored + ** back into the input registers P1 and P3. So this opcode can cause + ** persistent changes to registers P1 and P3. + ** + ** Once any conversions have taken place, and neither value is NULL, + ** the values are compared. If both values are blobs then memcmp() is + ** used to determine the results of the comparison. If both values + ** are text, then the appropriate collating function specified in + ** P4 is used to do the comparison. If P4 is not specified then + ** memcmp() is used to compare text string. If both values are + ** numeric, then a numeric comparison is used. If the two values + ** are of different types, then numbers are considered less than + ** strings and strings are considered less than blobs. + ** + ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either + ** true or false and is never NULL. If both operands are NULL then the result + ** of comparison is true. If either operand is NULL then the result is false. + ** If neither operand is NULL the result is the same as it would be if + ** the SQLITE_NULLEQ flag were omitted from P5. + ** + ** This opcode saves the result of comparison for use by the new + ** OP_Jump opcode. + */ + /* Opcode: Ne P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]!=r[P1] + ** + ** This works just like the Eq opcode except that the jump is taken if + ** the operands in registers P1 and P3 are not equal. See the Eq opcode for + ** additional information. + */ + /* Opcode: Lt P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]r[P1] + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than the content of + ** register P1. See the Lt opcode for additional information. + */ + /* Opcode: Ge P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]>=r[P1] + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than or equal to the content of + ** register P1. See the Lt opcode for additional information. + */ + _46: + ; /* same as TK_EQ, jump, in1, in3 */ + _45: + ; /* same as TK_NE, jump, in1, in3 */ + _44: + ; /* same as TK_LT, jump, in1, in3 */ + _43: + ; /* same as TK_LE, jump, in1, in3 */ + _42: + ; /* same as TK_GT, jump, in1, in3 */ + _41: + ; /* Copy of initial value of pIn3->flags */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags11 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + flags3 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + if libc.Int32FromUint16(flags11)&libc.Int32FromUint16(flags3)&int32(MEM_Int) != 0 { + /* Common case of comparison of two integers */ + if *(*Ti64)(unsafe.Pointer(pIn3)) > *(*Ti64)(unsafe.Pointer(pIn1)) { + if **(**uint8)(__ccgo_up(_sqlite3aGTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = +libc.Int32FromInt32(1) + } else { + if *(*Ti64)(unsafe.Pointer(pIn3)) < *(*Ti64)(unsafe.Pointer(pIn1)) { + if **(**uint8)(__ccgo_up(_sqlite3aLTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = -int32(1) + } else { + if **(**uint8)(__ccgo_up(_sqlite3aEQb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = 0 + } + } + goto _189 + } + if (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Null) != 0 { + /* One or both operands are NULL */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(SQLITE_NULLEQ) != 0 { + /* If SQLITE_NULLEQ is set (which will only happen if the operator is + ** OP_Eq or OP_Ne) then take the jump or not depending on whether + ** or not both operands are null. + */ + if libc.Int32FromUint16(flags11)&libc.Int32FromUint16(flags3)&int32(MEM_Null) != 0 && libc.Int32FromUint16(flags3)&int32(MEM_Cleared) == 0 { + res = 0 /* Operands are equal */ + } else { + if libc.Int32FromUint16(flags3)&int32(MEM_Null) != 0 { + v190 = -int32(1) + } else { + v190 = +libc.Int32FromInt32(1) + } + res = v190 /* Operands are not equal */ + } + } else { + /* SQLITE_NULLEQ is clear and at least one operand is NULL, + ** then the result is always NULL. + ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. + */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(SQLITE_JUMPIFNULL) != 0 { + goto jump_to_p2 + } + iCompare = int32(1) /* Operands are not equal */ + goto _189 + } + } else { + /* Neither operand is NULL and we couldn't do the special high-speed + ** integer comparison case. So do a general-case comparison. */ + affinity = int8(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) & int32(SQLITE_AFF_MASK)) + if int32(affinity) >= int32(SQLITE_AFF_NUMERIC) { + if (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Str) != 0 { + if libc.Int32FromUint16(flags11)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn1, 0) + flags3 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + } + if libc.Int32FromUint16(flags3)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn3, 0) + } + } + } else { + if int32(affinity) == int32(SQLITE_AFF_TEXT) && (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Str) != 0 { + if libc.Int32FromUint16(flags11)&int32(MEM_Str) != 0 { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) + } else { + if libc.Int32FromUint16(flags11)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(1)) + flags11 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_TypeMask) | libc.Int32FromUint16(flags11)&int32(MEM_TypeMask)) + if pIn1 == pIn3 { + flags3 = libc.Uint16FromInt32(libc.Int32FromUint16(flags11) | int32(MEM_Str)) + } + } + } + if libc.Int32FromUint16(flags3)&int32(MEM_Str) != 0 { + v191 = pIn3 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) + } else { + if libc.Int32FromUint16(flags3)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemStringify(tls, pIn3, encoding, uint8(1)) + flags3 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn3)).Fflags) & ^libc.Int32FromInt32(MEM_TypeMask) | libc.Int32FromUint16(flags3)&int32(MEM_TypeMask)) + } + } + } + } + res = _sqlite3MemCompare(tls, pIn3, pIn1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + /* At this point, res is negative, zero, or positive if reg[P1] is + ** less than, equal to, or greater than reg[P3], respectively. Compute + ** the answer to this operator in res2, depending on what the comparison + ** operator actually is. The next block of code depends on the fact + ** that the 6 comparison operators are consecutive integers in this + ** order: NE, EQ, GT, LE, LT, GE */ + if res < 0 { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aLTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } else { + if res == 0 { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aEQb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } else { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aGTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } + } + iCompare = res + /* Undo any changes made by applyAffinity() to the input registers. */ + (*TMem)(unsafe.Pointer(pIn3)).Fflags = flags3 + (*TMem)(unsafe.Pointer(pIn1)).Fflags = flags11 + if res21 != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: ElseEq * P2 * * * + ** + ** This opcode must follow an OP_Lt or OP_Gt comparison operator. There + ** can be zero or more OP_ReleaseReg opcodes intervening, but no other + ** opcodes are allowed to occur between this instruction and the previous + ** OP_Lt or OP_Gt. + ** + ** If the result of an OP_Eq comparison on the same two operands as + ** the prior OP_Lt or OP_Gt would have been true, then jump to P2. If + ** the result of an OP_Eq comparison on the two previous operands + ** would have been false or NULL, then fall through. + */ + _47: + ; /* same as TK_ESCAPE, jump */ + if iCompare == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Permutation * * * P4 * + ** + ** Set the permutation used by the OP_Compare operator in the next + ** instruction. The permutation is stored in the P4 operand. + ** + ** The permutation is only valid for the next opcode which must be + ** an OP_Compare that has the OPFLAG_PERMUTE bit set in P5. + ** + ** The first integer in the P4 integer array is the length of the array + ** and does not become part of the permutation. + */ + _48: + ; + goto _189 + /* Opcode: Compare P1 P2 P3 P4 P5 + ** Synopsis: r[P1@P3] <-> r[P2@P3] + ** + ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this + ** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of + ** the comparison for use by the next OP_Jump instruct. + ** + ** If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is + ** determined by the most recent OP_Permutation operator. If the + ** OPFLAG_PERMUTE bit is clear, then register are compared in sequential + ** order. + ** + ** P4 is a KeyInfo structure that defines collating sequences and sort + ** orders for the comparison. The permutation applies to registers + ** only. The KeyInfo elements are used sequentially. + ** + ** The comparison is a sort comparison, so NULLs compare equal, + ** NULLs are less than numbers, numbers are less than strings, + ** and strings are less than blobs. + ** + ** This opcode must be immediately followed by an OP_Jump opcode. + */ + _49: + ; /* The permutation */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_PERMUTE) == 0 { + aPermute = uintptr(0) + } else { + aPermute = *(*uintptr)(unsafe.Pointer(pOp + uintptr(-libc.Int32FromInt32(1))*24 + 16)) + uintptr(1)*4 + } + n2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) + p11 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + p21 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + i = 0 + for { + if !(i < n2) { + break + } + if aPermute != 0 { + v213 = **(**Tu32)(__ccgo_up(aPermute + uintptr(i)*4)) + } else { + v213 = libc.Uint32FromInt32(i) + } + idx = v213 + pColl = *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)) + bRev = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i)))) & int32(KEYINFO_ORDER_DESC) + iCompare = _sqlite3MemCompare(tls, aMem+uintptr(libc.Uint32FromInt32(p11)+idx)*56, aMem+uintptr(libc.Uint32FromInt32(p21)+idx)*56, pColl) + if iCompare != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i))))&int32(KEYINFO_ORDER_BIGNULL) != 0 && (libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr(libc.Uint32FromInt32(p11)+idx)*56))).Fflags)&int32(MEM_Null) != 0 || libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr(libc.Uint32FromInt32(p21)+idx)*56))).Fflags)&int32(MEM_Null) != 0) { + iCompare = -iCompare + } + if bRev != 0 { + iCompare = -iCompare + } + break + } + goto _212 + _212: + ; + i = i + 1 + } + goto _189 + /* Opcode: Jump P1 P2 P3 * * + ** + ** Jump to the instruction at address P1, P2, or P3 depending on whether + ** in the most recent OP_Compare instruction the P1 vector was less than, + ** equal to, or greater than the P2 vector, respectively. + ** + ** This opcode must immediately follow an OP_Compare opcode. + */ + _50: + ; /* jump */ + if iCompare < 0 { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1-int32(1))*24 + } else { + if iCompare == 0 { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2-int32(1))*24 + } else { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3-int32(1))*24 + } + } + goto _189 + /* Opcode: And P1 P2 P3 * * + ** Synopsis: r[P3]=(r[P1] && r[P2]) + ** + ** Take the logical AND of the values in registers P1 and P2 and + ** write the result into register P3. + ** + ** If either P1 or P2 is 0 (false) then the result is 0 even if + ** the other input is NULL. A NULL and true or two NULLs give + ** a NULL output. + */ + /* Opcode: Or P1 P2 P3 * * + ** Synopsis: r[P3]=(r[P1] || r[P2]) + ** + ** Take the logical OR of the values in register P1 and P2 and + ** store the answer in register P3. + ** + ** If either P1 or P2 is nonzero (true) then the result is 1 (true) + ** even if the other input is NULL. A NULL and false or two NULLs + ** give a NULL output. + */ + _52: + ; /* same as TK_AND, in1, in2, out3 */ + _51: + ; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ + v11 = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, int32(2)) + v21 = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, int32(2)) + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_And) { + v11 = libc.Int32FromUint8(_and_logic[v11*int32(3)+v21]) + } else { + v11 = libc.Int32FromUint8(_or_logic[v11*int32(3)+v21]) + } + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if v11 == int32(2) { + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Null)) + } else { + *(*Ti64)(unsafe.Pointer(pOut)) = int64(v11) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Int)) + } + goto _189 + /* Opcode: IsTrue P1 P2 P3 P4 * + ** Synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 + ** + ** This opcode implements the IS TRUE, IS FALSE, IS NOT TRUE, and + ** IS NOT FALSE operators. + ** + ** Interpret the value in register P1 as a boolean value. Store that + ** boolean (a 0 or 1) in register P2. Or if the value in register P1 is + ** NULL, then the P3 is stored in register P2. Invert the answer if P4 + ** is 1. + ** + ** The logic is summarized like this: + ** + **
      + **
    • If P3==0 and P4==0 then r[P2] := r[P1] IS TRUE + **
    • If P3==1 and P4==1 then r[P2] := r[P1] IS FALSE + **
    • If P3==0 and P4==1 then r[P2] := r[P1] IS NOT TRUE + **
    • If P3==1 and P4==0 then r[P2] := r[P1] IS NOT FALSE + **
    + */ + _53: + ; /* in1, out2 */ + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, int64(_sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, (*TOp)(unsafe.Pointer(pOp)).Fp3)^(*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) + goto _189 + /* Opcode: Not P1 P2 * * * + ** Synopsis: r[P2]= !r[P1] + ** + ** Interpret the value in register P1 as a boolean value. Store the + ** boolean complement in register P2. If the value in register P1 is + ** NULL, then a NULL is stored in P2. + */ + _54: + ; /* same as TK_NOT, in1, out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + _sqlite3VdbeMemSetInt64(tls, pOut, libc.BoolInt64(!(_sqlite3VdbeBooleanValue(tls, pIn1, 0) != 0))) + } else { + _sqlite3VdbeMemSetNull(tls, pOut) + } + goto _189 + /* Opcode: BitNot P1 P2 * * * + ** Synopsis: r[P2]= ~r[P1] + ** + ** Interpret the content of register P1 as an integer. Store the + ** ones-complement of the P1 value into register P2. If P1 holds + ** a NULL then store a NULL in P2. + */ + _55: + ; /* same as TK_BITNOT, in1, out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemSetNull(tls, pOut) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) + *(*Ti64)(unsafe.Pointer(pOut)) = ^_sqlite3VdbeIntValue(tls, pIn1) + } + goto _189 + /* Opcode: Once P1 P2 P3 * * + ** + ** Fall through to the next instruction the first time this opcode is + ** encountered on each invocation of the byte-code program. Jump to P2 + ** on the second and all subsequent encounters during the same invocation. + ** + ** Top-level programs determine first invocation by comparing the P1 + ** operand against the P1 operand on the OP_Init opcode at the beginning + ** of the program. If the P1 values differ, then fall through and make + ** the P1 of this opcode equal to the P1 of OP_Init. If P1 values are + ** the same then take the jump. + ** + ** For subprograms, there is a bitmask in the VdbeFrame that determines + ** whether or not the jump should be taken. The bitmask is necessary + ** because the self-altering code trick does not work for recursive + ** triggers. + ** + ** The P3 operand is not used directly by this opcode. However P3 is + ** used by the code generator as follows: If this opcode is the start + ** of a subroutine and that subroutine uses a Bloom filter, then P3 will + ** be the register that holds that Bloom filter. See tag-202407032019 + ** in the source code for implementation details. + */ + _56: + ; /* Address of this instruction */ + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + iAddr = libc.Uint32FromInt32(int32((int64(pOp) - int64((*TVdbe)(unsafe.Pointer(p)).FaOp)) / 24)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TVdbeFrame)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/uint32(8)))))&(int32(1)<<(iAddr&uint32(7))) != 0 { + goto jump_to_p2 + } + v191 = (*TVdbeFrame)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/uint32(8)) + *(*Tu8)(unsafe.Pointer(v191)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v191))) | libc.Int32FromInt32(1)<<(iAddr&libc.Uint32FromInt32(7))) + } else { + if (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp))).Fp1 == (*TOp)(unsafe.Pointer(pOp)).Fp1 { + goto jump_to_p2 + } + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp))).Fp1 + goto _189 + /* Opcode: If P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is true. The value + ** is considered true if it is numeric and non-zero. If the value + ** in P1 is NULL then take the jump if and only if P3 is non-zero. + */ + _57: + ; + c = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, (*TOp)(unsafe.Pointer(pOp)).Fp3) + if c != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IfNot P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is False. The value + ** is considered false if it has a numeric value of zero. If the value + ** in P1 is NULL then take the jump if and only if P3 is non-zero. + */ + _58: + ; + c1 = libc.BoolInt32(!(_sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, libc.BoolInt32(!((*TOp)(unsafe.Pointer(pOp)).Fp3 != 0))) != 0)) + if c1 != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IsNull P1 P2 * * * + ** Synopsis: if r[P1]==NULL goto P2 + ** + ** Jump to P2 if the value in register P1 is NULL. + */ + _59: + ; /* same as TK_ISNULL, jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IsType P1 P2 P3 P4 P5 + ** Synopsis: if typeof(P1.P3) in P5 goto P2 + ** + ** Jump to P2 if the type of a column in a btree is one of the types specified + ** by the P5 bitmask. + ** + ** P1 is normally a cursor on a btree for which the row decode cache is + ** valid through at least column P3. In other words, there should have been + ** a prior OP_Column for column P3 or greater. If the cursor is not valid, + ** then this opcode might give spurious results. + ** The the btree row has fewer than P3 columns, then use P4 as the + ** datatype. + ** + ** If P1 is -1, then P3 is a register number and the datatype is taken + ** from the value in that register. + ** + ** P5 is a bitmask of data types. SQLITE_INTEGER is the least significant + ** (0x01) bit. SQLITE_FLOAT is the 0x02 bit. SQLITE_TEXT is 0x04. + ** SQLITE_BLOB is 0x08. SQLITE_NULL is 0x10. + ** + ** WARNING: This opcode does not reliably distinguish between NULL and REAL + ** when P1>=0. If the database contains a NaN value, this opcode will think + ** that the datatype is REAL when it should be NULL. When P1<0 and the value + ** is already stored in register P3, then this opcode does reliably + ** distinguish between NULL and REAL. The problem only arises then P1>=0. + ** + ** Take the jump to address P2 if and only if the datatype of the + ** value determined by P1 and P3 corresponds to one of the bits in the + ** P5 bitmask. + ** + */ + _60: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp1 >= 0 { + pC = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 < libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) { + serialType = *(*Tu32)(unsafe.Pointer(pC + 120 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*4)) + if serialType >= uint32(12) { + if serialType&uint32(1) != 0 { + typeMask = uint16(0x04) /* SQLITE_TEXT */ + } else { + typeMask = uint16(0x08) /* SQLITE_BLOB */ + } + } else { + typeMask = uint16(_aMask[serialType]) + } + } else { + typeMask = libc.Uint16FromInt32(int32(1) << ((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi - int32(1))) + } + } else { + typeMask = libc.Uint16FromInt32(int32(1) << (Xsqlite3_value_type(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56) - int32(1))) + } + if libc.Int32FromUint16(typeMask)&libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: ZeroOrNull P1 P2 P3 * * + ** Synopsis: r[P2] = 0 OR NULL + ** + ** If both registers P1 and P3 are NOT NULL, then store a zero in + ** register P2. If either registers P1 or P3 are NULL then put + ** a NULL in register P2. + */ + _61: + ; /* in1, in2, out2, in3 */ + if libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56))).Fflags)&int32(MEM_Null) != 0 || libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fflags)&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56) + } else { + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, 0) + } + goto _189 + /* Opcode: NotNull P1 P2 * * * + ** Synopsis: if r[P1]!=NULL goto P2 + ** + ** Jump to P2 if the value in register P1 is not NULL. + */ + _62: + ; /* same as TK_NOTNULL, jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IfNullRow P1 P2 P3 * * + ** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2 + ** + ** Check the cursor P1 to see if it is currently pointing at a NULL row. + ** If it is, then set register P3 to NULL and jump immediately to P2. + ** If P1 is not on a NULL row, then fall through without making any + ** changes. + ** + ** If P1 is not an open cursor, then this opcode is a no-op. + */ + _63: + ; + pC1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pC1 != 0 && (*TVdbeCursor)(unsafe.Pointer(pC1)).FnullRow != 0 { + _sqlite3VdbeMemSetNull(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56) + goto jump_to_p2 + } + goto _189 + /* Opcode: Offset P1 P2 P3 * * + ** Synopsis: r[P3] = sqlite_offset(P1) + ** + ** Store in register r[P3] the byte offset into the database file that is the + ** start of the payload for the record at which that cursor P1 is currently + ** pointing. + ** + ** P2 is the column number for the argument to the sqlite_offset() function. + ** This opcode does not use P2 itself, but the P2 value is used by the + ** code generator. The P1, P2, and P3 operands to this opcode are the + ** same as for OP_Column. + ** + ** This opcode is only available if SQLite is compiled with the + ** -DSQLITE_ENABLE_OFFSET_SQL_FUNC option. + */ + _64: + ; /* The VDBE cursor */ + pC2 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pOut = (*TVdbe)(unsafe.Pointer(p)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if pC2 == uintptr(0) || libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC2)).FeCurType) != CURTYPE_BTREE { + _sqlite3VdbeMemSetNull(tls, pOut) + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC2)).FdeferredMoveto != 0 { + rc = _sqlite3VdbeFinishMoveto(tls, pC2) + if rc != 0 { + goto abort_due_to_error + } + } + if _sqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC2 + 48))) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + } else { + _sqlite3VdbeMemSetInt64(tls, pOut, _sqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC2 + 48)))) + } + } + goto _189 + /* Opcode: Column P1 P2 P3 P4 P5 + ** Synopsis: r[P3]=PX cursor P1 column P2 + ** + ** Interpret the data that cursor P1 points to as a structure built using + ** the MakeRecord instruction. (See the MakeRecord opcode for additional + ** information about the format of the data.) Extract the P2-th column + ** from this record. If there are less than (P2+1) + ** values in the record, extract a NULL. + ** + ** The value extracted is stored in register P3. + ** + ** If the record contains fewer than P2 fields, then extract a NULL. Or, + ** if the P4 argument is a P4_MEM use the value of the P4 argument as + ** the result. + ** + ** If the OPFLAG_LENGTHARG bit is set in P5 then the result is guaranteed + ** to only be used by the length() function or the equivalent. The content + ** of large blobs is not loaded, thus saving CPU cycles. If the + ** OPFLAG_TYPEOFARG bit is set then the result will only be used by the + ** typeof() function or the IS NULL or IS NOT NULL operators or the + ** equivalent. In this case, all content loading can be omitted. + */ + _65: + ; /* PseudoTable input register */ + pC3 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + p22 = libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) + goto op_column_restart + op_column_restart: + ; + aOffset = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaOffset + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus != (*TVdbe)(unsafe.Pointer(p)).FcacheCtr { /*OPTIMIZATION-IF-FALSE*/ + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FnullRow != 0 { + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC3)).FeCurType) == int32(CURTYPE_PSEUDO) && (*TVdbeCursor)(unsafe.Pointer(pC3)).FseekResult > 0 { + /* For the special case of as pseudo-cursor, the seekResult field + ** identifies the register that holds the record */ + pReg = aMem + uintptr((*TVdbeCursor)(unsafe.Pointer(pC3)).FseekResult)*56 + v215 = libc.Uint32FromInt32((*TMem)(unsafe.Pointer(pReg)).Fn) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow = v215 + (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = v215 + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = (*TMem)(unsafe.Pointer(pReg)).Fz + } else { + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + _sqlite3VdbeMemSetNull(tls, pDest) + goto op_column_out + } + } else { + pCrsr = *(*uintptr)(unsafe.Pointer(pC3 + 48)) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FdeferredMoveto != 0 { + if v217 = *(*uintptr)(unsafe.Pointer(pC3 + 16)) != 0; v217 { + v215 = **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pC3 + 16)) + uintptr(uint32(1)+p22)*4)) + iMap = v215 + } + if v217 && v215 > uint32(0) { + pC3 = (*TVdbeCursor)(unsafe.Pointer(pC3)).FpAltCursor + p22 = iMap - uint32(1) + goto op_column_restart + } + rc = _sqlite3VdbeFinishMoveto(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + } else { + if _sqlite3BtreeCursorHasMoved(tls, pCrsr) != 0 { + rc = _sqlite3VdbeHandleMovedCursor(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + goto op_column_restart + } + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = _sqlite3BtreePayloadSize(tls, pCrsr) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = _sqlite3BtreePayloadFetch(tls, pCrsr, pC3+108) + /* Maximum page size is 64KiB */ + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = (*TVdbe)(unsafe.Pointer(p)).FcacheCtr + v215 = uint32(**(**Tu8)(__ccgo_up((*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow))) + **(**Tu32)(__ccgo_up(aOffset)) = v215 + if v215 < uint32(0x80) { + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = uint32(1) + } else { + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = uint32(_sqlite3GetVarint32(tls, (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow, aOffset)) + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = uint16(0) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow < **(**Tu32)(__ccgo_up(aOffset)) { /*OPTIMIZATION-IF-FALSE*/ + /* pC->aRow does not have to hold the entire row, but it does at least + ** need to cover the header of the record. If pC->aRow does not contain + ** the complete header, then set it to zero, forcing the header to be + ** dynamically allocated. */ + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = uintptr(0) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow = uint32(0) + /* Make sure a corrupt database has not given us an oversize header. + ** Do this now to avoid an oversize memory allocation. + ** + ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte + ** types use so much data space that there can only be 4096 and 32 of + ** them, respectively. So the maximum header length results from a + ** 3-byte type for each of the maximum of 32768 columns plus three + ** extra bytes for the header length itself. 32768*3 + 3 = 98307. + */ + if **(**Tu32)(__ccgo_up(aOffset)) > uint32(98307) || **(**Tu32)(__ccgo_up(aOffset)) > (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize { + goto op_column_corrupt + } + } else { + /* This is an optimization. By skipping over the first few tests + ** (ex: pC->nHdrParsed<=p2) in the next section, we achieve a + ** measurable performance gain. + ** + ** This branch is taken even if aOffset[0]==0. Such a record is never + ** generated by SQLite, and could be considered corruption, but we + ** accept it for historical reasons. When aOffset[0]==0, the code this + ** branch jumps to reads past the end of the record, but never more + ** than a few bytes. Even if the record occurs at the end of the page + ** content area, the "page header" comes after the page content and so + ** this overread is harmless. Similar overreads can occur for a corrupt + ** database file. + */ + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + /* Conditional skipped */ + goto op_column_read_header + } + } else { + if _sqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(pC3 + 48))) != 0 { + rc = _sqlite3VdbeHandleMovedCursor(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + goto op_column_restart + } + } + /* Make sure at least the first p2+1 entries of the header have been + ** parsed and valid information is in aOffset[] and pC->aType[]. + */ + if !(uint32((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22) { + goto _219 + } + /* If there is more header available for parsing in the record, try + ** to extract additional fields up through the p2+1-th field + */ + if !((*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset < **(**Tu32)(__ccgo_up(aOffset))) { + goto _221 + } + /* Make sure zData points to enough of the record to cover the header. */ + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + libc.X__builtin___memset_chk(tls, bp+24, 0, uint64(56), ^t__predefined_size_t(0)) + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(pC3 + 48)), **(**Tu32)(__ccgo_up(aOffset)), bp+24) + if rc != SQLITE_OK { + goto abort_due_to_error + } + zData = (**(**TMem)(__ccgo_up(bp + 24))).Fz + } else { + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + } + /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */ + goto op_column_read_header + op_column_read_header: + ; + i1 = libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) + offset64 = uint64(**(**Tu32)(__ccgo_up(aOffset + uintptr(i1)*4))) + zHdr = zData + uintptr((*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset) + zEndHdr = zData + uintptr(**(**Tu32)(__ccgo_up(aOffset))) + for cond := true; cond; cond = libc.Uint32FromInt32(i1) <= p22 && zHdr < zEndHdr { + v216 = uint32(**(**Tu8)(__ccgo_up(zHdr))) + **(**Tu32)(__ccgo_up(bp + 80)) = v216 + v215 = v216 + *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(i1)*4)) = v215 + if v215 < uint32(0x80) { + zHdr = zHdr + 1 + offset64 = offset64 + uint64(_sqlite3VdbeOneByteSerialTypeLen(tls, uint8(**(**Tu32)(__ccgo_up(bp + 80))))) + } else { + zHdr = zHdr + uintptr(_sqlite3GetVarint32(tls, zHdr, bp+80)) + *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(i1)*4)) = **(**Tu32)(__ccgo_up(bp + 80)) + offset64 = offset64 + uint64(_sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 80)))) + } + i1 = i1 + 1 + v190 = i1 + **(**Tu32)(__ccgo_up(aOffset + uintptr(v190)*4)) = uint32(offset64 & libc.Uint64FromUint32(0xffffffff)) + } + /* The record is corrupt if any of the following are true: + ** (1) the bytes of the header extend past the declared header size + ** (2) the entire header was used but not all data was used + ** (3) the end of the data extends beyond the end of the record. + */ + if zHdr >= zEndHdr && (zHdr > zEndHdr || offset64 != uint64((*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize)) || offset64 > uint64((*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize) { + if **(**Tu32)(__ccgo_up(aOffset)) == uint32(0) { + i1 = 0 + zHdr = zEndHdr + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + _sqlite3VdbeMemRelease(tls, bp+24) + } + goto op_column_corrupt + } + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = libc.Uint16FromInt32(i1) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = libc.Uint32FromInt64(int64(zHdr) - int64(zData)) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + _sqlite3VdbeMemRelease(tls, bp+24) + } + goto _222 + _221: + ; + **(**Tu32)(__ccgo_up(bp + 80)) = uint32(0) + _222: + ; + /* If after trying to extract new entries from the header, nHdrParsed is + ** still not up to p2, that means that the record has fewer than p2 + ** columns. So the result will be either the default value or a NULL. + */ + if uint32((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22 { + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(11) { + _sqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16)), int32(MEM_Static)) + } else { + _sqlite3VdbeMemSetNull(tls, pDest) + } + goto op_column_out + } + goto _220 + _219: + ; + **(**Tu32)(__ccgo_up(bp + 80)) = *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(p22)*4)) + _220: + ; + /* Extract the content for the p2+1-th column. Control can only + ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are + ** all valid. + */ + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pDest)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _sqlite3VdbeMemSetNull(tls, pDest) + } + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow >= **(**Tu32)(__ccgo_up(aOffset + uintptr(p22+uint32(1))*4)) { + /* This is the common case where the desired content fits on the original + ** page - where the content is not on an overflow page */ + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + uintptr(**(**Tu32)(__ccgo_up(aOffset + uintptr(p22)*4))) + if **(**Tu32)(__ccgo_up(bp + 80)) < uint32(12) { + _sqlite3VdbeSerialGet(tls, zData, **(**Tu32)(__ccgo_up(bp + 80)), pDest) + } else { + v190 = libc.Int32FromUint32((**(**Tu32)(__ccgo_up(bp + 80)) - libc.Uint32FromInt32(12)) / libc.Uint32FromInt32(2)) + len1 = v190 + (*TMem)(unsafe.Pointer(pDest)).Fn = v190 + (*TMem)(unsafe.Pointer(pDest)).Fenc = encoding + if (*TMem)(unsafe.Pointer(pDest)).FszMalloc < len1+int32(2) { + if len1 > **(**int32)(__ccgo_up(db + 136)) { + goto too_big + } + (*TMem)(unsafe.Pointer(pDest)).Fflags = uint16(MEM_Null) + if _sqlite3VdbeMemGrow(tls, pDest, len1+int32(2), 0) != 0 { + goto no_mem + } + } else { + (*TMem)(unsafe.Pointer(pDest)).Fz = (*TMem)(unsafe.Pointer(pDest)).FzMalloc + } + libc.X__builtin___memcpy_chk(tls, (*TMem)(unsafe.Pointer(pDest)).Fz, zData, libc.Uint64FromInt32(len1), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1))) = 0 + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1+int32(1)))) = 0 + (*TMem)(unsafe.Pointer(pDest)).Fflags = _aFlag1[**(**Tu32)(__ccgo_up(bp + 80))&uint32(1)] + } + } else { + (*TMem)(unsafe.Pointer(pDest)).Fenc = encoding + /* This branch happens only when content is on overflow pages */ + v227 = libc.Uint8FromInt32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) & libc.Int32FromInt32(OPFLAG_BYTELENARG)) + p5 = v227 + if libc.Int32FromUint8(v227) != 0 && (libc.Int32FromUint8(p5) == int32(OPFLAG_TYPEOFARG) || **(**Tu32)(__ccgo_up(bp + 80)) >= uint32(12) && (**(**Tu32)(__ccgo_up(bp + 80))&uint32(1) == uint32(0) || libc.Int32FromUint8(p5) == int32(OPFLAG_BYTELENARG))) || _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 80))) == uint32(0) { + /* Content is irrelevant for + ** 1. the typeof() function, + ** 2. the length(X) function if X is a blob, and + ** 3. if the content length is zero. + ** So we might as well use bogus content rather than reading + ** content from disk. + ** + ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the + ** buffer passed to it, debugging function VdbeMemPrettyPrint() may + ** read more. Use the global constant sqlite3CtypeMap[] as the array, + ** as that array is 256 bytes long (plenty for VdbeMemPrettyPrint()) + ** and it begins with a bunch of zeros. + */ + _sqlite3VdbeSerialGet(tls, uintptr(unsafe.Pointer(&_sqlite3CtypeMap)), **(**Tu32)(__ccgo_up(bp + 80)), pDest) + } else { + rc = _vdbeColumnFromOverflow(tls, pC3, libc.Int32FromUint32(p22), **(**Tu32)(__ccgo_up(bp + 80)), libc.Int64FromUint32(**(**Tu32)(__ccgo_up(aOffset + uintptr(p22)*4))), (*TVdbe)(unsafe.Pointer(p)).FcacheCtr, colCacheCtr, pDest) + if rc != 0 { + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + if rc == int32(SQLITE_TOOBIG) { + goto too_big + } + goto abort_due_to_error + } + } + } + goto op_column_out + op_column_out: + ; + goto _189 + goto op_column_corrupt + op_column_corrupt: + ; + if (**(**TOp)(__ccgo_up(aOp))).Fp3 > 0 { + pOp = aOp + uintptr((**(**TOp)(__ccgo_up(aOp))).Fp3-int32(1))*24 + goto _189 + } else { + rc = _sqlite3CorruptError(tls, int32(99741)) + goto abort_due_to_error + } + /* Opcode: TypeCheck P1 P2 P3 P4 * + ** Synopsis: typecheck(r[P1@P2]) + ** + ** Apply affinities to the range of P2 registers beginning with P1. + ** Take the affinities from the Table object in P4. If any value + ** cannot be coerced into the correct type, then raise an error. + ** + ** If P3==0, then omit checking of VIRTUAL columns. + ** + ** If P3==1, then omit checking of all generated column, both VIRTUAL + ** and STORED. + ** + ** If P3>=2, then only check column number P3-2 in the table (which will + ** be a VIRTUAL column) against the value in reg[P1]. In this case, + ** P2 will be 1. + ** + ** This opcode is similar to OP_Affinity except that this opcode + ** forces the register type to the Table column type. This is used + ** to implement "strict affinity". + ** + ** GENERATED ALWAYS AS ... STATIC columns are only checked if P3 + ** is zero. When P3 is non-zero, no type checking occurs for + ** static generated columns. Virtual columns are computed at query time + ** and so they are never checked. + ** + ** Preconditions: + ** + **
      + **
    • P2 should be the number of non-virtual columns in the + ** table of P4 unless P3>1, in which case P2 will be 1. + **
    • Table P4 is a STRICT table. + **
    + ** + ** If any precondition is false, an assertion fault occurs. + */ + _66: + ; + pTab = *(*uintptr)(unsafe.Pointer(pOp + 16)) + aCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*TOp)(unsafe.Pointer(pOp)).Fp3 < int32(2) { + i2 = 0 + nCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + i2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 - int32(2) + nCol = i2 + int32(1) + } + for { + if !(i2 < nCol) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 && (*TOp)(unsafe.Pointer(pOp)).Fp3 < int32(2) { + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + goto _228 + } + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + pIn1 += 56 + goto _228 + } + } + _applyAffinity(tls, pIn1, (**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).Faffinity, encoding) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + switch int32(uint32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 8)) & 0xf0 >> 4)) { + case int32(COLTYPE_BLOB): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_INTEGER): + fallthrough + case int32(COLTYPE_INT): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Int) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_TEXT): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Str) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_REAL): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Int) != 0 { + /* When applying REAL affinity, if the result is still an MEM_Int + ** that will fit in 6 bytes, then change the type to MEM_IntReal + ** so that we keep the high-resolution integer value but know that + ** the type really wants to be REAL. */ + if *(*Ti64)(unsafe.Pointer(pIn1)) <= int64(140737488355327) && *(*Ti64)(unsafe.Pointer(pIn1)) >= -int64(140737488355328) { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } else { + *(*float64)(unsafe.Pointer(pIn1)) = float64(*(*Ti64)(unsafe.Pointer(pIn1))) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + goto vdbe_type_error + } + } + default: + /* COLTYPE_ANY. Accept anything. */ + break + } + } + pIn1 += 56 + goto _228 + _228: + ; + i2 = i2 + 1 + } + goto _189 + goto vdbe_type_error + vdbe_type_error: + ; + _sqlite3VdbeError(tls, p, __ccgo_ts+6228, libc.VaList(bp+984, _vdbeMemTypeName(tls, pIn1), _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 8))&0xf0>>4))-int32(1)], (*TTable)(unsafe.Pointer(pTab)).FzName, (**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FzCnName)) + rc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(12)<= -int64(140737488355328) { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } else { + *(*float64)(unsafe.Pointer(pIn1)) = float64(*(*Ti64)(unsafe.Pointer(pIn1))) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Str))) + } + } + zAffinity = zAffinity + 1 + if int32(**(**int8)(__ccgo_up(zAffinity))) == 0 { + break + } + pIn1 += 56 + } + goto _189 + /* Opcode: MakeRecord P1 P2 P3 P4 * + ** Synopsis: r[P3]=mkrec(r[P1@P2]) + ** + ** Convert P2 registers beginning with P1 into the [record format] + ** use as a data record in a database table or as a key + ** in an index. The OP_Column opcode can decode the record later. + ** + ** P4 may be a string that is P2 characters long. The N-th character of the + ** string indicates the column affinity that should be used for the N-th + ** field of the index key. + ** + ** The mapping from character to affinity is given by the SQLITE_AFF_ + ** macros defined in sqliteInt.h. + ** + ** If P4 is NULL then all index fields have the affinity BLOB. + ** + ** The meaning of P5 depends on whether or not the SQLITE_ENABLE_NULL_TRIM + ** compile-time option is enabled: + ** + ** * If SQLITE_ENABLE_NULL_TRIM is enabled, then the P5 is the index + ** of the right-most table that can be null-trimmed. + ** + ** * If SQLITE_ENABLE_NULL_TRIM is omitted, then P5 has the value + ** OPFLAG_NOCHNG_MAGIC if the OP_MakeRecord opcode is allowed to + ** accept no-change records with serial_type 10. This value is + ** only used inside an assert() and does not affect the end result. + */ + _68: + ; /* Where to write next byte of the payload */ + /* Assuming the record contains N fields, the record format looks + ** like this: + ** + ** ------------------------------------------------------------------------ + ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | + ** ------------------------------------------------------------------------ + ** + ** Data(0) is taken from register P1. Data(1) comes from register P1+1 + ** and so forth. + ** + ** Each type field is a varint representing the serial type of the + ** corresponding data element (see sqlite3VdbeSerialType()). The + ** hdr-size field is also a varint which is the offset from the beginning + ** of the record to data0. + */ + nData = uint64(0) /* Number of bytes of data space */ + nHdr = 0 /* Number of bytes of header space */ + nZero = 0 /* Number of zero bytes at the end of the record */ + nField = (*TOp)(unsafe.Pointer(pOp)).Fp1 + zAffinity1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pData0 = aMem + uintptr(nField)*56 + nField = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pLast = pData0 + uintptr(nField-int32(1))*56 + /* Identify the output register */ + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + /* Apply the requested affinity to all inputs + */ + if zAffinity1 != 0 { + pRec = pData0 + for cond := true; cond; cond = **(**int8)(__ccgo_up(zAffinity1)) != 0 { + _applyAffinity(tls, pRec, **(**int8)(__ccgo_up(zAffinity1)), encoding) + if int32(**(**int8)(__ccgo_up(zAffinity1))) == int32(SQLITE_AFF_REAL) && libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Int) != 0 { + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } + zAffinity1 = zAffinity1 + 1 + pRec += 56 + } + } + /* Loop through the elements that will make up the record to figure + ** out how much space is required for the new record. After this loop, + ** the Mem.uTemp field of each term should hold the serial-type that will + ** be used for that term in the generated record: + ** + ** Mem.uTemp value type + ** --------------- --------------- + ** 0 NULL + ** 1 1-byte signed integer + ** 2 2-byte signed integer + ** 3 3-byte signed integer + ** 4 4-byte signed integer + ** 5 6-byte signed integer + ** 6 8-byte signed integer + ** 7 IEEE float + ** 8 Integer constant 0 + ** 9 Integer constant 1 + ** 10,11 reserved for expansion + ** N>=12 and even BLOB + ** N>=13 and odd text + ** + ** The following additional values are computed: + ** nHdr Number of bytes needed for the record header + ** nData Number of bytes of data space needed for the record + ** nZero Zero bytes at the end of the record + */ + pRec = pLast + for cond := true; cond; cond = int32(1) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Null) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Zero) != 0 { + /* Values with MEM_Null and MEM_Zero are created by xColumn virtual + ** table methods that never invoke sqlite3_result_xxxxx() while + ** computing an unchanging column value in an UPDATE statement. + ** Give such values a special internal-use-only serial-type of 10 + ** so that they can be passed through to xUpdate and have + ** a true sqlite3_value_nochange(). */ + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(10) + } else { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(0) + } + nHdr = nHdr + 1 + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */ + i3 = *(*Ti64)(unsafe.Pointer(pRec)) + if i3 < 0 { + uu = libc.Uint64FromInt64(^i3) + } else { + uu = libc.Uint64FromInt64(i3) + } + nHdr = nHdr + 1 + if uu <= uint64(127) { + if i3&int64(1) == i3 && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat) >= int32(4) { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(8) + uint32(uu) + } else { + nData = nData + 1 + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(1) + } + } else { + if uu <= uint64(32767) { + nData = nData + uint64(2) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(2) + } else { + if uu <= uint64(8388607) { + nData = nData + uint64(3) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(3) + } else { + if uu <= uint64(2147483647) { + nData = nData + uint64(4) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(4) + } else { + if uu <= uint64(140737488355327) { + nData = nData + uint64(6) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(5) + } else { + nData = nData + uint64(8) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_IntReal) != 0 { + /* If the value is IntReal and is going to take up 8 bytes to store + ** as an integer, then we might as well make it an 8-byte floating + ** point value */ + *(*float64)(unsafe.Pointer(pRec)) = float64(*(*Ti64)(unsafe.Pointer(pRec))) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_IntReal)) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(7) + } else { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(6) + } + } + } + } + } + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Real) != 0 { + nHdr = nHdr + 1 + nData = nData + uint64(8) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(7) + } else { + len11 = libc.Uint32FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn) + serial_type = len11*uint32(2) + uint32(12) + libc.BoolUint32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&libc.Int32FromInt32(MEM_Str) != libc.Int32FromInt32(0)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Zero) != 0 { + serial_type = serial_type + libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu)))*uint32(2) + if nData != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pRec) != 0 { + goto no_mem + } + len11 = len11 + libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu))) + } else { + nZero = nZero + int64(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu))) + } + } + nData = nData + uint64(len11) + nHdr = nHdr + _sqlite3VarintLen(tls, uint64(serial_type)) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = serial_type + } + } + } + if pRec == pData0 { + break + } + pRec -= 56 + } + /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint + ** which determines the total number of bytes in the header. The varint + ** value is the size of the header in bytes including the size varint + ** itself. */ + if nHdr <= int32(126) { + /* The common case */ + nHdr = nHdr + int32(1) + } else { + /* Rare case of a really large header */ + nVarint = _sqlite3VarintLen(tls, libc.Uint64FromInt32(nHdr)) + nHdr = nHdr + nVarint + if nVarint < _sqlite3VarintLen(tls, libc.Uint64FromInt32(nHdr)) { + nHdr = nHdr + 1 + } + } + nByte1 = libc.Int64FromUint64(libc.Uint64FromInt32(nHdr) + nData) + /* Make sure the output register has a buffer large enough to store + ** the new record. The output register (pOp->p3) is not allowed to + ** be one of the input registers (because the following call to + ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used). + */ + if nByte1+nZero <= int64((*TMem)(unsafe.Pointer(pOut)).FszMalloc) { + /* The output register is already large enough to hold the record. + ** No error checks or buffer enlargement is required */ + (*TMem)(unsafe.Pointer(pOut)).Fz = (*TMem)(unsafe.Pointer(pOut)).FzMalloc + } else { + /* Need to make sure that the output is not too big and then enlarge + ** the output register to hold the full result */ + if nByte1+nZero > int64(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + if _sqlite3VdbeMemClearAndResize(tls, pOut, int32(nByte1)) != 0 { + goto no_mem + } + } + (*TMem)(unsafe.Pointer(pOut)).Fn = int32(nByte1) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Blob) + if nZero != 0 { + *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pOut)).Fu)) = int32(nZero) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Zero)) + } + zHdr1 = (*TMem)(unsafe.Pointer(pOut)).Fz + zPayload = zHdr1 + uintptr(nHdr) + /* Write the record */ + if nHdr < int32(0x80) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = libc.Uint8FromInt32(nHdr) + } else { + zHdr1 = zHdr1 + uintptr(_sqlite3PutVarint(tls, zHdr1, libc.Uint64FromInt32(nHdr))) + } + pRec = pData0 + for int32(1) != 0 { + serial_type = (*TMem)(unsafe.Pointer(pRec)).FuTemp + /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more + ** additional varints, one per column. + ** EVIDENCE-OF: R-64536-51728 The values for each column in the record + ** immediately follow the header. */ + if serial_type <= uint32(7) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = uint8(serial_type) + if serial_type == uint32(0) { + /* NULL value. No change in zPayload */ + } else { + if serial_type == uint32(7) { + libc.X__builtin___memcpy_chk(tls, bp+88, pRec, uint64(8), ^t__predefined_size_t(0)) + } else { + **(**Tu64)(__ccgo_up(bp + 88)) = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(pRec))) + } + len11 = uint32(_sqlite3SmallTypeSizes[serial_type]) + switch len11 { + default: + **(**Tu8)(__ccgo_up(zPayload + 7)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + **(**Tu8)(__ccgo_up(zPayload + 6)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(6): + **(**Tu8)(__ccgo_up(zPayload + 5)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + **(**Tu8)(__ccgo_up(zPayload + 4)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(4): + **(**Tu8)(__ccgo_up(zPayload + 3)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(3): + **(**Tu8)(__ccgo_up(zPayload + 2)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(2): + **(**Tu8)(__ccgo_up(zPayload + 1)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(1): + **(**Tu8)(__ccgo_up(zPayload)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + } + zPayload = zPayload + uintptr(len11) + } + } else { + if serial_type < uint32(0x80) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = uint8(serial_type) + if serial_type >= uint32(14) && (*TMem)(unsafe.Pointer(pRec)).Fn > 0 { + libc.X__builtin___memcpy_chk(tls, zPayload, (*TMem)(unsafe.Pointer(pRec)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn), ^t__predefined_size_t(0)) + zPayload = zPayload + uintptr((*TMem)(unsafe.Pointer(pRec)).Fn) + } + } else { + zHdr1 = zHdr1 + uintptr(_sqlite3PutVarint(tls, zHdr1, uint64(serial_type))) + if (*TMem)(unsafe.Pointer(pRec)).Fn != 0 { + libc.X__builtin___memcpy_chk(tls, zPayload, (*TMem)(unsafe.Pointer(pRec)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn), ^t__predefined_size_t(0)) + zPayload = zPayload + uintptr((*TMem)(unsafe.Pointer(pRec)).Fn) + } + } + } + if pRec == pLast { + break + } + pRec += 56 + } + goto _189 + /* Opcode: Count P1 P2 P3 * * + ** Synopsis: r[P2]=count() + ** + ** Store the number of entries (an integer value) in the table or index + ** opened by cursor P1 in register P2. + ** + ** If P3==0, then an exact count is obtained, which involves visiting + ** every btree page of the table. But if P3 is non-zero, an estimate + ** is returned based on the current cursor position. + */ + _69: + ; + pCrsr1 = *(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + 48)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + **(**Ti64)(__ccgo_up(bp + 96)) = _sqlite3BtreeRowCountEst(tls, pCrsr1) + } else { + **(**Ti64)(__ccgo_up(bp + 96)) = 0 /* Not needed. Only used to silence a warning. */ + rc = _sqlite3BtreeCount(tls, db, pCrsr1, bp+96) + if rc != 0 { + goto abort_due_to_error + } + } + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 96)) + goto check_for_interrupt + /* Opcode: Savepoint P1 * * P4 * + ** + ** Open, release or rollback the savepoint named by parameter P4, depending + ** on the value of P1. To open a new savepoint set P1==0 (SAVEPOINT_BEGIN). + ** To release (commit) an existing savepoint set P1==1 (SAVEPOINT_RELEASE). + ** To rollback an existing savepoint set P1==2 (SAVEPOINT_ROLLBACK). + */ + _70: + ; + p12 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + zName = *(*uintptr)(unsafe.Pointer(pOp + 16)) + /* Assert that the p1 parameter is valid. Also that if there is no open + ** transaction, then there cannot be any savepoints. + */ + if p12 == SAVEPOINT_BEGIN { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 { + /* A new savepoint cannot be created if there are active write + ** statements (i.e. open read/write incremental blob handles). + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+6269, 0) + rc = int32(SQLITE_BUSY) + } else { + nName = _sqlite3Strlen30(tls, zName) + /* This call is Ok even if this savepoint is actually a transaction + ** savepoint (and therefore should not prompt xSavepoint()) callbacks. + ** If this is a transaction savepoint being opened, it is guaranteed + ** that the db->aVTrans[] array is empty. */ + rc = _sqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*Tsqlite3)(unsafe.Pointer(db)).FnStatement+(*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint) + if rc != SQLITE_OK { + goto abort_due_to_error + } + /* Create a new savepoint structure. */ + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(32)+libc.Uint64FromInt32(nName)+uint64(1))) + if pNew != 0 { + (*TSavepoint)(unsafe.Pointer(pNew)).FzName = pNew + 1*32 + libc.X__builtin___memcpy_chk(tls, (*TSavepoint)(unsafe.Pointer(pNew)).FzName, zName, libc.Uint64FromInt32(nName+int32(1)), ^t__predefined_size_t(0)) + /* If there is no open transaction, then mark this as a special + ** "transaction savepoint". */ + if (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(1) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + 1 + } + /* Link the new savepoint into the database handle's list. */ + (*TSavepoint)(unsafe.Pointer(pNew)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint + (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint = pNew + (*TSavepoint)(unsafe.Pointer(pNew)).FnDeferredCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons + (*TSavepoint)(unsafe.Pointer(pNew)).FnDeferredImmCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons + } + } + } else { + iSavepoint = 0 + /* Find the named savepoint. If there is no such savepoint, then an + ** an error is returned to the user. */ + pSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint + for { + if !(pSavepoint != 0 && _sqlite3StrICmp(tls, (*TSavepoint)(unsafe.Pointer(pSavepoint)).FzName, zName) != 0) { + break + } + iSavepoint = iSavepoint + 1 + goto _245 + _245: + ; + pSavepoint = (*TSavepoint)(unsafe.Pointer(pSavepoint)).FpNext + } + if !(pSavepoint != 0) { + _sqlite3VdbeError(tls, p, __ccgo_ts+6320, libc.VaList(bp+984, zName)) + rc = int32(SQLITE_ERROR) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 && p12 == int32(SAVEPOINT_RELEASE) { + /* It is not possible to release (commit) a savepoint if there are + ** active write statements. + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+6342, 0) + rc = int32(SQLITE_BUSY) + } else { + /* Determine whether or not this is a transaction savepoint. If so, + ** and this is a RELEASE command, then the current transaction + ** is committed. + */ + isTransaction = libc.BoolInt32((*TSavepoint)(unsafe.Pointer(pSavepoint)).FpNext == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint != 0) + if isTransaction != 0 && p12 == int32(SAVEPOINT_RELEASE) { + v190 = _sqlite3VdbeCheckFkDeferred(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto vdbe_return + } + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(1) + if _sqlite3VdbeHalt(tls, p) == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + v190 = libc.Int32FromInt32(SQLITE_BUSY) + rc = v190 + (*TVdbe)(unsafe.Pointer(p)).Frc = v190 + goto vdbe_return + } + rc = (*TVdbe)(unsafe.Pointer(p)).Frc + if rc != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(0) + } + } else { + iSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint - iSavepoint - int32(1) + if p12 == int32(SAVEPOINT_ROLLBACK) { + isSchemaChange = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_SchemaChange) != uint32(0)) + ii = 0 + for { + if !(ii < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + rc = _sqlite3BtreeTripAllCursors(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii)*32))).FpBt, libc.Int32FromInt32(SQLITE_ABORT)|libc.Int32FromInt32(2)< 0 { + /* If this instruction implements a COMMIT and other VMs are writing + ** return an error indicating that the other VMs must complete first. + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+6396, 0) + rc = int32(SQLITE_BUSY) + goto abort_due_to_error + } else { + v190 = _sqlite3VdbeCheckFkDeferred(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto vdbe_return + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = libc.Uint8FromInt32(desiredAutoCommit) + } + } + } + if _sqlite3VdbeHalt(tls, p) == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = libc.Uint8FromInt32(libc.Int32FromInt32(1) - desiredAutoCommit) + v190 = libc.Int32FromInt32(SQLITE_BUSY) + rc = v190 + (*TVdbe)(unsafe.Pointer(p)).Frc = v190 + goto vdbe_return + } + _sqlite3CloseSavepoints(tls, db) + if (*TVdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rc = int32(SQLITE_DONE) + } else { + rc = int32(SQLITE_ERROR) + } + goto vdbe_return + } else { + if !(desiredAutoCommit != 0) { + v191 = __ccgo_ts + 6451 + } else { + if iRollback != 0 { + v194 = __ccgo_ts + 6499 + } else { + v194 = __ccgo_ts + 6542 + } + v191 = v194 + } + _sqlite3VdbeError(tls, p, v191, 0) + rc = int32(SQLITE_ERROR) + goto abort_due_to_error + } + /* Opcode: Transaction P1 P2 P3 P4 P5 + ** + ** Begin a transaction on database P1 if a transaction is not already + ** active. + ** If P2 is non-zero, then a write-transaction is started, or if a + ** read-transaction is already active, it is upgraded to a write-transaction. + ** If P2 is zero, then a read-transaction is started. If P2 is 2 or more + ** then an exclusive transaction is started. + ** + ** P1 is the index of the database file on which the transaction is + ** started. Index 0 is the main database file and index 1 is the + ** file used for temporary tables. Indices of 2 or more are used for + ** attached databases. + ** + ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is + ** true (this flag is set if the Vdbe may modify more than one row and may + ** throw an ABORT exception), a statement transaction may also be opened. + ** More specifically, a statement transaction is opened iff the database + ** connection is currently not in autocommit mode, or if there are other + ** active statements. A statement transaction allows the changes made by this + ** VDBE to be rolled back after an error without having to roll back the + ** entire transaction. If no error is encountered, the statement transaction + ** will automatically commit when the VDBE halts. + ** + ** If P5!=0 then this opcode also checks the schema cookie against P3 + ** and the schema generation counter against P4. + ** The cookie changes its value whenever the database schema changes. + ** This operation is used to detect when that the cookie has changed + ** and that the current process needs to reread the schema. If the schema + ** cookie in P3 differs from the schema cookie in the database header or + ** if the schema generation counter in P4 differs from the current + ** generation counter, then an SQLITE_SCHEMA error is raised and execution + ** halts. The sqlite3_step() wrapper function might then reprepare the + ** statement and rerun it from the beginning. + */ + _72: + ; + **(**int32)(__ccgo_up(bp + 104)) = 0 + if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(SQLITE_QueryOnly)|libc.Uint64FromInt32(libc.Int32FromInt32(0x00002))<>5)) != 0 && (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 && (libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 || (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1)) { + if (*TVdbe)(unsafe.Pointer(p)).FiStatement == 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnStatement + 1 + (*TVdbe)(unsafe.Pointer(p)).FiStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement + } + rc = _sqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*TVdbe)(unsafe.Pointer(p)).FiStatement-int32(1)) + if rc == SQLITE_OK { + rc = _sqlite3BtreeBeginStmt(tls, pBt, (*TVdbe)(unsafe.Pointer(p)).FiStatement) + } + /* Store the current value of the database handles deferred constraint + ** counter. If the statement transaction needs to be rolled back, + ** the value of this counter needs to be restored too. */ + (*TVdbe)(unsafe.Pointer(p)).FnStmtDefCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons + (*TVdbe)(unsafe.Pointer(p)).FnStmtDefImmCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons + } + } + if rc == SQLITE_OK && (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 && (**(**int32)(__ccgo_up(bp + 104)) != (*TOp)(unsafe.Pointer(pOp)).Fp3 || (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FiGeneration != (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) { + /* + ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema + ** version is checked to ensure that the schema has not changed since the + ** SQL statement was prepared. + */ + _sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg) + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3DbStrDup(tls, db, __ccgo_ts+6583) + /* If the schema-cookie from the database file matches the cookie + ** stored with the in-memory representation of the schema, do + ** not reload the schema from the database file. + ** + ** If virtual-tables are in use, this is not just an optimization. + ** Often, v-tables store their data in other SQLite tables, which + ** are queried from within xNext() and other v-table methods using + ** prepared queries. If such a query is out-of-date, we do not want to + ** discard the database schema, as the user code implementing the + ** v-table would have to be ready for the sqlite3_vtab structure itself + ** to be invalidated whenever sqlite3_step() is called from within + ** a v-table method. + */ + if (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpSchema)).Fschema_cookie != **(**int32)(__ccgo_up(bp + 104)) { + _sqlite3ResetOneSchema(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + } + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 0, 0x3) + rc = int32(SQLITE_SCHEMA) + /* Set changeCntOn to 0 to prevent the value returned by sqlite3_changes() + ** from being modified in sqlite3VdbeHalt(). If this statement is + ** reprepared, changeCntOn will be set again. */ + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 4, 0x10) + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: ReadCookie P1 P2 P3 * * + ** + ** Read cookie number P3 from database P1 and write it into register P2. + ** P3==1 is the schema version. P3==2 is the database format. + ** P3==3 is the recommended pager cache size, and so forth. P1==0 is + ** the main database file and P1==1 is the database file used to store + ** temporary tables. + ** + ** There must be a read-lock on the database (either a transaction + ** must be started or there must be an open cursor) before + ** executing this instruction. + */ + _73: + ; + iDb = (*TOp)(unsafe.Pointer(pOp)).Fp1 + iCookie = (*TOp)(unsafe.Pointer(pOp)).Fp3 + _sqlite3BtreeGetMeta(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt, iCookie, bp+108) + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = int64(**(**int32)(__ccgo_up(bp + 108))) + goto _189 + /* Opcode: SetCookie P1 P2 P3 * P5 + ** + ** Write the integer value P3 into cookie number P2 of database P1. + ** P2==1 is the schema version. P2==2 is the database format. + ** P2==3 is the recommended pager cache + ** size, and so forth. P1==0 is the main database file and P1==1 is the + ** database file used to store temporary tables. + ** + ** A transaction must be started before executing this opcode. + ** + ** If P2 is the SCHEMA_VERSION cookie (cookie number 1) then the internal + ** schema version is set to P3-P5. The "PRAGMA schema_version=N" statement + ** has P5 set to 1, so that the internal schema version will be different + ** from the database schema version, resulting in a schema reset. + */ + _74: + ; + pDb1 = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32 + /* See note about index shifting on OP_ReadCookie */ + rc = _sqlite3BtreeUpdateMeta(tls, (*TDb)(unsafe.Pointer(pDb1)).FpBt, (*TOp)(unsafe.Pointer(pOp)).Fp2, libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3)) + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == int32(BTREE_SCHEMA_VERSION) { + /* When the schema cookie changes, record the new cookie internally */ + **(**Tu32)(__ccgo_up((*TDb)(unsafe.Pointer(pDb1)).FpSchema)) = **(**Tu32)(__ccgo_up(pOp + 12)) - uint32((*TOp)(unsafe.Pointer(pOp)).Fp5) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + _sqlite3FkClearTriggerCache(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + } else { + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == int32(BTREE_FILE_FORMAT) { + /* Record changes in the file format */ + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb1)).FpSchema)).Ffile_format = libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 == int32(1) { + /* Invalidate all prepared statements whenever the TEMP database + ** schema is changed. Ticket #1644 */ + _sqlite3ExpirePreparedStatements(tls, db, 0) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: OpenRead P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** Open a read-only cursor for the database table whose root page is + ** P2 in a database file. The database file is determined by P3. + ** P3==0 means the main database, P3==1 means the database used for + ** temporary tables, and P3>1 means used the corresponding attached + ** database. Give the new cursor an identifier of P1. The P1 + ** values need not be contiguous but all P1 values should be small integers. + ** It is an error for P1 to be negative. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** object, then table being opened must be an [index b-tree] where the + ** KeyInfo object defines the content and collating + ** sequence of that index b-tree. Otherwise, if P4 is an integer + ** value, then the table being opened must be a [table b-tree] with a + ** number of columns no less than the value of P4. + ** + ** See also: OpenWrite, ReopenIdx + */ + /* Opcode: ReopenIdx P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** The ReopenIdx opcode works like OP_OpenRead except that it first + ** checks to see if the cursor on P1 is already open on the same + ** b-tree and if it is this opcode becomes a no-op. In other words, + ** if the cursor is already open, do not reopen it. + ** + ** The ReopenIdx opcode may only be used with P5==0 or P5==OPFLAG_SEEKEQ + ** and with P4 being a P4_KEYINFO object. Furthermore, the P3 value must + ** be the same as every other ReopenIdx or OpenRead for the same cursor + ** number. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    + ** + ** See also: OP_OpenRead, OP_OpenWrite + */ + /* Opcode: OpenWrite P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** Open a read/write cursor named P1 on the table or index whose root + ** page is P2 (or whose root page is held in register P2 if the + ** OPFLAG_P2ISREG bit is set in P5 - see below). + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** object, then table being opened must be an [index b-tree] where the + ** KeyInfo object defines the content and collating + ** sequence of that index b-tree. Otherwise, if P4 is an integer + ** value, then the table being opened must be a [table b-tree] with a + ** number of columns no less than the value of P4. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    • 0x08 OPFLAG_FORDELETE: This cursor is used only to seek + ** and subsequently delete entries in an index btree. This is a + ** hint to the storage engine that the storage engine is allowed to + ** ignore. The hint is not used by the official SQLite b*tree storage + ** engine, but is used by COMDB2. + **
    • 0x10 OPFLAG_P2ISREG: Use the content of register P2 + ** as the root page, not the value of P2 itself. + **
    + ** + ** This instruction works like OpenRead except that it opens the cursor + ** in read/write mode. + ** + ** See also: OP_OpenRead, OP_ReopenIdx + */ + _77: + ; + pCur = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCur != 0 && (*TVdbeCursor)(unsafe.Pointer(pCur)).FpgnoRoot == libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) { + /* Guaranteed by the code generator */ + _sqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pCur + 48))) + goto open_cursor_set_hints + } + /* If the cursor is not currently open or is open on a different + ** index, then fall through into OP_OpenRead to force a reopen */ + _76: + ; /* ncycle */ + _75: + ; + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x3>>0)) == int32(1) { + rc = libc.Int32FromInt32(SQLITE_ABORT) | libc.Int32FromInt32(2)<>2))), 2, 0x4) + *(*uintptr)(unsafe.Pointer(pCx + 16)) = *(*uintptr)(unsafe.Pointer(pOrig + 16)) + libc.SetBitFieldPtr8Uint32(pCx+8, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(pOrig+8, libc.Uint32FromInt32(1), 3, 0x8) + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx + 16)), (*TVdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, int32(BTREE_WRCSR), (*TVdbeCursor)(unsafe.Pointer(pCx)).FpKeyInfo, *(*uintptr)(unsafe.Pointer(pCx + 48))) + /* The sqlite3BtreeCursor() routine can only fail for the first cursor + ** opened for a database. Since there is already an open cursor when this + ** opcode is run, the sqlite3BtreeCursor() cannot fail */ + goto _189 + /* Opcode: OpenEphemeral P1 P2 P3 P4 P5 + ** Synopsis: nColumn=P2 + ** + ** Open a new cursor P1 to a transient table. + ** The cursor is always opened read/write even if + ** the main database is read-only. The ephemeral + ** table is deleted automatically when the cursor is closed. + ** + ** If the cursor P1 is already opened on an ephemeral table, the table + ** is cleared (all content is erased). + ** + ** P2 is the number of columns in the ephemeral table. + ** The cursor points to a BTree table if P4==0 and to a BTree index + ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure + ** that defines the format of keys in the index. + ** + ** The P5 parameter can be a mask of the BTREE_* flags defined + ** in btree.h. These flags control aspects of the operation of + ** the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are + ** added automatically. + ** + ** If P3 is positive, then reg[P3] is modified slightly so that it + ** can be used as zero-length data for OP_Insert. This is an optimization + ** that avoids an extra OP_Blob opcode to initialize that register. + */ + /* Opcode: OpenAutoindex P1 P2 * P4 * + ** Synopsis: nColumn=P2 + ** + ** This opcode works the same as OP_OpenEphemeral. It has a + ** different name to distinguish its use. Tables created using + ** by this opcode will be used for automatically created transient + ** indices in joins. + */ + _80: + ; /* ncycle */ + _79: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp3 > 0 { + /* Make register reg[P3] into a value that can be used as the data + ** form sqlite3BtreeInsert() where the length of the data is zero. */ + /* Only used when number of columns is zero */ + (**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fn = 0 + (**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fz = __ccgo_ts + 1702 + } + pCx1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCx1 != 0 && !(int32(TBool(*(*uint8)(unsafe.Pointer(pCx1 + 8))&0x8>>3)) != 0) && (*TOp)(unsafe.Pointer(pOp)).Fp2 <= int32((*TVdbeCursor)(unsafe.Pointer(pCx1)).FnField) { + /* If the ephemeral table is already open and has no duplicates from + ** OP_OpenDup, then erase all existing content so that the table is + ** empty again, rather than creating a new table. */ + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FseqCount = 0 + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = uint32(CACHE_STALE) + rc = _sqlite3BtreeClearTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), libc.Int32FromUint32((*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot), uintptr(0)) + } else { + pCx1 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_BTREE)) + if pCx1 == uintptr(0) { + goto no_mem + } + libc.SetBitFieldPtr8Uint32(pCx1+8, libc.Uint32FromInt32(1), 0, 0x1) + rc = _sqlite3BtreeOpen(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, pCx1+16, libc.Int32FromInt32(BTREE_OMIT_JOURNAL)|libc.Int32FromInt32(BTREE_SINGLE)|libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5), _vfsFlags) + if rc == SQLITE_OK { + rc = _sqlite3BtreeBeginTrans(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), int32(1), uintptr(0)) + if rc == SQLITE_OK { + /* If a transient index is required, create it by calling + ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before + ** opening it. If a transient table is required, just use the + ** automatically created table with root-page 1 (an BLOB_INTKEY table). + */ + v194 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pKeyInfo2 = v194 + v191 = v194 + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpKeyInfo = v191 + if v191 != uintptr(0) { + rc = _sqlite3BtreeCreateTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), pCx1+68, int32(BTREE_BLOBKEY)|libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)) + if rc == SQLITE_OK { + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, int32(BTREE_WRCSR), pKeyInfo2, *(*uintptr)(unsafe.Pointer(pCx1 + 48))) + } + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FisTable = uint8(0) + } else { + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = uint32(SCHEMA_ROOT) + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), uint32(SCHEMA_ROOT), int32(BTREE_WRCSR), uintptr(0), *(*uintptr)(unsafe.Pointer(pCx1 + 48))) + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FisTable = uint8(1) + } + } + libc.SetBitFieldPtr8Uint32(pCx1+8, libc.BoolUint32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) != libc.Int32FromInt32(BTREE_UNORDERED)), 2, 0x4) + if rc != 0 { + _sqlite3BtreeClose(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16))) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) = uintptr(0) /* Not required; helps with static analysis */ + } else { + } + } + } + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FnullRow = uint8(1) + goto _189 + /* Opcode: SorterOpen P1 P2 P3 P4 * + ** + ** This opcode works like OP_OpenEphemeral except that it opens + ** a transient index that is specifically designed to sort large + ** tables using an external merge-sort algorithm. + ** + ** If argument P3 is non-zero, then it indicates that the sorter may + ** assume that a stable sort considering the first P3 fields of each + ** key is sufficient to produce the required results. + */ + _81: + ; + pCx2 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_SORTER)) + if pCx2 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pCx2)).FpKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) + rc = _sqlite3VdbeSorterInit(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp3, pCx2) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: SequenceTest P1 P2 * * * + ** Synopsis: if( cursor[P1].ctr++ ) pc = P2 + ** + ** P1 is a sorter cursor. If the sequence counter is currently zero, jump + ** to P2. Regardless of whether or not the jump is taken, increment the + ** the sequence value. + */ + _82: + ; + pC4 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + v191 = pC4 + 24 + v256 = *(*Ti64)(unsafe.Pointer(v191)) + *(*Ti64)(unsafe.Pointer(v191)) = *(*Ti64)(unsafe.Pointer(v191)) + 1 + if v256 == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: OpenPseudo P1 P2 P3 * * + ** Synopsis: P3 columns in r[P2] + ** + ** Open a new cursor that points to a fake table that contains a single + ** row of data. The content of that one row is the content of memory + ** register P2. In other words, cursor P1 becomes an alias for the + ** MEM_Blob content contained in register P2. + ** + ** A pseudo-table created by this opcode is used to hold a single + ** row output from the sorter so that the row can be decomposed into + ** individual columns using the OP_Column opcode. The OP_Column opcode + ** is the only cursor opcode that works with a pseudo-table. + ** + ** P3 is the number of fields in the records that will be stored by + ** the pseudo-table. If P2 is 0 or negative then the pseudo-cursor + ** will return NULL for every column. + */ + _83: + ; + pCx3 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp3, uint8(CURTYPE_PSEUDO)) + if pCx3 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FnullRow = uint8(1) + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FseekResult = (*TOp)(unsafe.Pointer(pOp)).Fp2 + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FisTable = uint8(1) + /* Give this pseudo-cursor a fake BtCursor pointer so that pCx + ** can be safely passed to sqlite3VdbeCursorMoveto(). This avoids a test + ** for pCx->eCurType==CURTYPE_BTREE inside of sqlite3VdbeCursorMoveto() + ** which is a performance optimization */ + *(*uintptr)(unsafe.Pointer(pCx3 + 48)) = _sqlite3BtreeFakeValidCursor(tls) + goto _189 + /* Opcode: Close P1 * * * * + ** + ** Close a cursor previously opened as P1. If P1 is not + ** currently open, this instruction is a no-op. + */ + _84: + ; /* ncycle */ + _sqlite3VdbeFreeCursor(tls, p, **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8))) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) = uintptr(0) + goto _189 + /* Opcode: SeekGE P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as the key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than or equal to the key value. If there are no records + ** greater than or equal to the key and P2 is not zero, then jump to P2. + ** + ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this + ** opcode will either land on a record that exactly matches the key, or + ** else it will cause a jump to P2. When the cursor is OPFLAG_SEEKEQ, + ** this opcode must be followed by an IdxLE opcode with the same arguments. + ** The IdxGT opcode will be skipped if this opcode succeeds, but the + ** IdxGT opcode will be used on subsequent loop iterations. The + ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this + ** is an equality search. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + ** + ** See also: Found, NotFound, SeekLt, SeekGt, SeekLe + */ + /* Opcode: SeekGT P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than the key value. If there are no records greater than + ** the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + ** + ** See also: Found, NotFound, SeekLt, SeekGe, SeekLe + */ + /* Opcode: SeekLT P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than the key value. If there are no records less than + ** the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + ** + ** See also: Found, NotFound, SeekGt, SeekGe, SeekLe + */ + /* Opcode: SeekLE P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than or equal to the key value. If there are no records + ** less than or equal to the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + ** + ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this + ** opcode will either land on a record that exactly matches the key, or + ** else it will cause a jump to P2. When the cursor is OPFLAG_SEEKEQ, + ** this opcode must be followed by an IdxLE opcode with the same arguments. + ** The IdxGE opcode will be skipped if this opcode succeeds, but the + ** IdxGE opcode will be used on subsequent loop iterations. The + ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this + ** is an equality search. + ** + ** See also: Found, NotFound, SeekGt, SeekGe, SeekLt + */ + _88: + ; /* jump0, in3, group, ncycle */ + _87: + ; /* jump0, in3, group, ncycle */ + _86: + ; /* jump0, in3, group, ncycle */ + _85: + ; /* Only interested in == results */ + pC5 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + oc = libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) + eqOnly = 0 + (*TVdbeCursor)(unsafe.Pointer(pC5)).FnullRow = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FcacheStatus = uint32(CACHE_STALE) + if (*TVdbeCursor)(unsafe.Pointer(pC5)).FisTable != 0 { + /* The OPFLAG_SEEKEQ/BTREE_SEEK_EQ flag is only set on index cursors */ + /* The input value in P3 might be of any type: integer, real, string, + ** blob, or NULL. But it needs to be an integer before we can do + ** the seek, so convert it. */ + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags31 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + if libc.Int32FromUint16(flags31)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn3, 0) + } + iKey = _sqlite3VdbeIntValue(tls, pIn3) /* Get the integer key value */ + newType = (*TMem)(unsafe.Pointer(pIn3)).Fflags /* Record the type after applying numeric affinity */ + (*TMem)(unsafe.Pointer(pIn3)).Fflags = flags31 /* But convert the type back to its original */ + /* If the P3 value could not be converted into an integer without + ** loss of information, then special processing is required... */ + if libc.Int32FromUint16(newType)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + if libc.Int32FromUint16(newType)&int32(MEM_Real) == 0 { + if libc.Int32FromUint16(newType)&int32(MEM_Null) != 0 || oc >= int32(OP_SeekGE) { + goto jump_to_p2 + } else { + rc = _sqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), bp+112) + if rc != SQLITE_OK { + goto abort_due_to_error + } + goto seek_not_found + } + } + c2 = _sqlite3IntFloatCompare(tls, iKey, *(*float64)(unsafe.Pointer(pIn3))) + /* If the approximation iKey is larger than the actual real search + ** term, substitute >= for > and < for <=. e.g. if the search term + ** is 4.9 and the integer approximation 5: + ** + ** (x > 4.9) -> (x >= 5) + ** (x <= 4.9) -> (x < 5) + */ + if c2 > 0 { + if oc&int32(0x0001) == libc.Int32FromInt32(OP_SeekGT)&libc.Int32FromInt32(0x0001) { + oc = oc - 1 + } + } else { + if c2 < 0 { + if oc&int32(0x0001) == libc.Int32FromInt32(OP_SeekLT)&libc.Int32FromInt32(0x0001) { + oc = oc + 1 + } + } + } + } + rc = _sqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), libc.Int64FromUint64(libc.Uint64FromInt64(iKey)), 0, bp+112) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FmovetoTarget = iKey /* Used by OP_Delete */ + if rc != SQLITE_OK { + goto abort_due_to_error + } + } else { + /* For a cursor with the OPFLAG_SEEKEQ/BTREE_SEEK_EQ hint, only the + ** OP_SeekGE and OP_SeekLE opcodes are allowed, and these must be + ** immediately followed by an OP_IdxGT or OP_IdxLT opcode, respectively, + ** with the same key. + */ + if _sqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), uint32(BTREE_SEEK_EQ)) != 0 { + eqOnly = int32(1) + } + nField2 = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC5)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FnField = libc.Uint16FromInt32(nField2) + /* The next line of code computes as follows, only faster: + ** if( oc==OP_SeekGT || oc==OP_SeekLE ){ + ** r.default_rc = -1; + ** }else{ + ** r.default_rc = +1; + ** } + */ + if int32(1)&(oc-int32(OP_SeekLT)) != 0 { + v190 = -int32(1) + } else { + v190 = +libc.Int32FromInt32(1) + } + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).Fdefault_rc = int8(v190) + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FeqSeen = uint8(0) + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), bp+120, bp+112) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if eqOnly != 0 && libc.Int32FromUint8((**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FeqSeen) == 0 { + goto seek_not_found + } + } + if oc >= int32(OP_SeekGE) { + if **(**int32)(__ccgo_up(bp + 112)) < 0 || **(**int32)(__ccgo_up(bp + 112)) == 0 && oc == int32(OP_SeekGT) { + **(**int32)(__ccgo_up(bp + 112)) = 0 + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), 0) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 112)) = int32(1) + } else { + goto abort_due_to_error + } + } + } else { + **(**int32)(__ccgo_up(bp + 112)) = 0 + } + } else { + if **(**int32)(__ccgo_up(bp + 112)) > 0 || **(**int32)(__ccgo_up(bp + 112)) == 0 && oc == int32(OP_SeekLT) { + **(**int32)(__ccgo_up(bp + 112)) = 0 + rc = _sqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), 0) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 112)) = int32(1) + } else { + goto abort_due_to_error + } + } + } else { + /* res might be negative because the table is empty. Check to + ** see if this is the case. + */ + **(**int32)(__ccgo_up(bp + 112)) = _sqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48))) + } + } + goto seek_not_found + seek_not_found: + ; + if **(**int32)(__ccgo_up(bp + 112)) != 0 { + goto jump_to_p2 + } else { + if eqOnly != 0 { + pOp += 24 /* Skip the OP_IdxLt or OP_IdxGT that follows */ + } + } + goto _189 + /* Opcode: SeekScan P1 P2 * * P5 + ** Synopsis: Scan-ahead up to P1 rows + ** + ** This opcode is a prefix opcode to OP_SeekGE. In other words, this + ** opcode must be immediately followed by OP_SeekGE. This constraint is + ** checked by assert() statements. + ** + ** This opcode uses the P1 through P4 operands of the subsequent + ** OP_SeekGE. In the text that follows, the operands of the subsequent + ** OP_SeekGE opcode are denoted as SeekOP.P1 through SeekOP.P4. Only + ** the P1, P2 and P5 operands of this opcode are also used, and are called + ** This.P1, This.P2 and This.P5. + ** + ** This opcode helps to optimize IN operators on a multi-column index + ** where the IN operator is on the later terms of the index by avoiding + ** unnecessary seeks on the btree, substituting steps to the next row + ** of the b-tree instead. A correct answer is obtained if this opcode + ** is omitted or is a no-op. + ** + ** The SeekGE.P3 and SeekGE.P4 operands identify an unpacked key which + ** is the desired entry that we want the cursor SeekGE.P1 to be pointing + ** to. Call this SeekGE.P3/P4 row the "target". + ** + ** If the SeekGE.P1 cursor is not currently pointing to a valid row, + ** then this opcode is a no-op and control passes through into the OP_SeekGE. + ** + ** If the SeekGE.P1 cursor is pointing to a valid row, then that row + ** might be the target row, or it might be near and slightly before the + ** target row, or it might be after the target row. If the cursor is + ** currently before the target row, then this opcode attempts to position + ** the cursor on or after the target row by invoking sqlite3BtreeStep() + ** on the cursor between 1 and This.P1 times. + ** + ** The This.P5 parameter is a flag that indicates what to do if the + ** cursor ends up pointing at a valid row that is past the target + ** row. If This.P5 is false (0) then a jump is made to SeekGE.P2. If + ** This.P5 is true (non-zero) then a jump is made to This.P2. The P5==0 + ** case occurs when there are no inequality constraints to the right of + ** the IN constraint. The jump to SeekGE.P2 ends the loop. The P5!=0 case + ** occurs when there are inequality constraints to the right of the IN + ** operator. In that case, the This.P2 will point either directly to or + ** to setup code prior to the OP_IdxGT or OP_IdxGE opcode that checks for + ** loop terminate. + ** + ** Possible outcomes from this opcode:
      + ** + **
    1. If the cursor is initially not pointed to any valid row, then + ** fall through into the subsequent OP_SeekGE opcode. + ** + **
    2. If the cursor is left pointing to a row that is before the target + ** row, even after making as many as This.P1 calls to + ** sqlite3BtreeNext(), then also fall through into OP_SeekGE. + ** + **
    3. If the cursor is left pointing at the target row, either because it + ** was at the target row to begin with or because one or more + ** sqlite3BtreeNext() calls moved the cursor to the target row, + ** then jump to This.P2.., + ** + **
    4. If the cursor started out before the target row and a call to + ** to sqlite3BtreeNext() moved the cursor off the end of the index + ** (indicating that the target row definitely does not exist in the + ** btree) then jump to SeekGE.P2, ending the loop. + ** + **
    5. If the cursor ends up on a valid row that is past the target row + ** (indicating that the target row does not exist in the btree) then + ** jump to SeekOP.P2 if This.P5==0 or to This.P2 if This.P5>0. + **
    + */ + _89: + ; + /* If pOp->p5 is clear, then pOp->p2 points to the first instruction past the + ** OP_IdxGT that follows the OP_SeekGE. Otherwise, it points to the first + ** opcode past the OP_SeekGE itself. */ + pC6 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((**(**TOp)(__ccgo_up(pOp + 1*24))).Fp1)*8)) + if !(_sqlite3BtreeCursorIsValidNN(tls, *(*uintptr)(unsafe.Pointer(pC6 + 48))) != 0) { + goto _189 + } + nStep = (*TOp)(unsafe.Pointer(pOp)).Fp1 + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC6)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FnField = libc.Uint16FromInt32(*(*int32)(unsafe.Pointer(pOp + 1*24 + 16))) + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).Fdefault_rc = 0 + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FaMem = aMem + uintptr((**(**TOp)(__ccgo_up(pOp + 1*24))).Fp3)*56 + **(**int32)(__ccgo_up(bp + 160)) = 0 /* Not needed. Only used to silence a warning. */ + _260: + ; + if !(int32(1) != 0) { + goto _259 + } + rc = _sqlite3VdbeIdxKeyCompare(tls, db, pC6, bp+168, bp+160) + if rc != 0 { + goto abort_due_to_error + } + if !(**(**int32)(__ccgo_up(bp + 160)) > 0 && libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == 0) { + goto _261 + } + goto seekscan_search_fail + seekscan_search_fail: + ; + /* Jump to SeekGE.P2, ending the loop */ + pOp += 24 + goto jump_to_p2 + _261: + ; + if **(**int32)(__ccgo_up(bp + 160)) >= 0 { + /* Jump to This.P2, bypassing the OP_SeekGE opcode */ + goto jump_to_p2 + goto _259 + } + if nStep <= 0 { + goto _259 + } + nStep = nStep - 1 + (*TVdbeCursor)(unsafe.Pointer(pC6)).FcacheStatus = uint32(CACHE_STALE) + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC6 + 48)), 0) + if rc != 0 { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + goto seekscan_search_fail + } else { + goto abort_due_to_error + } + } + goto _260 + _259: + ; + goto _189 + /* Opcode: SeekHit P1 P2 P3 * * + ** Synopsis: set P2<=seekHit<=P3 + ** + ** Increase or decrease the seekHit value for cursor P1, if necessary, + ** so that it is no less than P2 and no greater than P3. + ** + ** The seekHit integer represents the maximum of terms in an index for which + ** there is known to be at least one match. If the seekHit value is smaller + ** than the total number of equality terms in an index lookup, then the + ** OP_IfNoHope opcode might run to see if the IN loop can be abandoned + ** early, thus saving work. This is part of the IN-early-out optimization. + ** + ** P1 must be a valid b-tree cursor. + */ + _90: + ; + pC7 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit) < (*TOp)(unsafe.Pointer(pOp)).Fp2 { + (*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit) > (*TOp)(unsafe.Pointer(pOp)).Fp3 { + (*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + goto _189 + /* Opcode: IfNotOpen P1 P2 * * * + ** Synopsis: if( !csr[P1] ) goto P2 + ** + ** If cursor P1 is not open or if P1 is set to a NULL row using the + ** OP_NullRow opcode, then jump to instruction P2. Otherwise, fall through. + */ + _91: + ; + pCur1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCur1 == uintptr(0) || (*TVdbeCursor)(unsafe.Pointer(pCur1)).FnullRow != 0 { + goto jump_to_p2_and_check_for_interrupt + } + goto _189 + /* Opcode: Found P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is a prefix of any entry in P1 then a jump is made to P2 and + ** P1 is left pointing at the matching entry. + ** + ** This operation leaves the cursor in a state where it can be + ** advanced in the forward direction. The Next instruction will work, + ** but not the Prev instruction. + ** + ** See also: NotFound, NoConflict, NotExists. SeekGe + */ + /* Opcode: NotFound P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 + ** does contain an entry whose prefix matches the P3/P4 record then control + ** falls through to the next instruction and P1 is left pointing at the + ** matching entry. + ** + ** This operation leaves the cursor in a state where it cannot be + ** advanced in either direction. In other words, the Next and Prev + ** opcodes do not work after this operation. + ** + ** See also: Found, NotExists, NoConflict, IfNoHope + */ + /* Opcode: IfNoHope P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** Register P3 is the first of P4 registers that form an unpacked + ** record. Cursor P1 is an index btree. P2 is a jump destination. + ** In other words, the operands to this opcode are the same as the + ** operands to OP_NotFound and OP_IdxGT. + ** + ** This opcode is an optimization attempt only. If this opcode always + ** falls through, the correct answer is still obtained, but extra work + ** is performed. + ** + ** A value of N in the seekHit flag of cursor P1 means that there exists + ** a key P3:N that will match some record in the index. We want to know + ** if it is possible for a record P3:P4 to match some record in the + ** index. If it is not possible, we can skip some work. So if seekHit + ** is less than P4, attempt to find out if a match is possible by running + ** OP_NotFound. + ** + ** This opcode is used in IN clause processing for a multi-column key. + ** If an IN clause is attached to an element of the key other than the + ** left-most element, and if there are no matches on the most recent + ** seek over the whole key, then it might be that one of the key element + ** to the left is prohibiting a match, and hence there is "no hope" of + ** any match regardless of how many IN clause elements are checked. + ** In such a case, we abandon the IN clause search early, using this + ** opcode. The opcode name comes from the fact that the + ** jump is taken if there is "no hope" of achieving a match. + ** + ** See also: NotFound, SeekHit + */ + /* Opcode: NoConflict P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** contains any NULL value, jump immediately to P2. If all terms of the + ** record are not-NULL then a check is done to determine if any row in the + ** P1 index btree has a matching key prefix. If there are no matches, jump + ** immediately to P2. If there is a match, fall through and leave the P1 + ** cursor pointing to the matching row. + ** + ** This opcode is similar to OP_NotFound with the exceptions that the + ** branch is always taken if any part of the search key input is NULL. + ** + ** This operation leaves the cursor in a state where it cannot be + ** advanced in either direction. In other words, the Next and Prev + ** opcodes do not work after this operation. + ** + ** See also: NotFound, Found, NotExists + */ + _92: + ; + pC8 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC8)).FseekHit) >= (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi { + goto _189 + } + /* Fall through into OP_NotFound */ + _95: + ; /* jump, in3, ncycle */ + _94: + ; /* jump, in3, ncycle */ + _93: + ; + pC9 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + if libc.Int32FromUint16((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField) > 0 { + /* Key values in an array of registers */ + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).Fdefault_rc = 0 + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 48)), bp+208, pC9+36) + } else { + /* Composite key generated by OP_MakeRecord */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto no_mem + } + pIdxKey = _sqlite3VdbeAllocUnpackedRecord(tls, (*TVdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo) + if pIdxKey == uintptr(0) { + goto no_mem + } + _sqlite3VdbeRecordUnpack(tls, (*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fn, (*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fz, pIdxKey) + (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).Fdefault_rc = 0 + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 48)), pIdxKey, pC9+36) + _sqlite3DbFreeNN(tls, db, pIdxKey) + } + if rc != SQLITE_OK { + goto abort_due_to_error + } + alreadyExists = libc.BoolInt32((*TVdbeCursor)(unsafe.Pointer(pC9)).FseekResult == 0) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FnullRow = libc.Uint8FromInt32(int32(1) - alreadyExists) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = uint32(CACHE_STALE) + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Found) { + if alreadyExists != 0 { + goto jump_to_p2 + } + } else { + if !(alreadyExists != 0) { + goto jump_to_p2 + } + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_NoConflict) { + /* For the OP_NoConflict opcode, take the jump if any of the + ** input fields are NULL, since any key with a NULL will not + ** conflict */ + ii1 = 0 + for { + if !(ii1 < libc.Int32FromUint16((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField)) { + break + } + if libc.Int32FromUint16((**(**TMem)(__ccgo_up((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem + uintptr(ii1)*56))).Fflags)&int32(MEM_Null) != 0 { + goto jump_to_p2 + } + goto _263 + _263: + ; + ii1 = ii1 + 1 + } + } + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_IfNoHope) { + (*TVdbeCursor)(unsafe.Pointer(pC9)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + } + } + goto _189 + /* Opcode: SeekRowid P1 P2 P3 * * + ** Synopsis: intkey=r[P3] + ** + ** P1 is the index of a cursor open on an SQL table btree (with integer + ** keys). If register P3 does not contain an integer or if P1 does not + ** contain a record with rowid P3 then jump immediately to P2. + ** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain + ** a record with rowid P3 then + ** leave the cursor pointing at that record and fall through to the next + ** instruction. + ** + ** The OP_NotExists opcode performs the same operation, but with OP_NotExists + ** the P3 register must be guaranteed to contain an integer value. With this + ** opcode, register P3 might not contain an integer. + ** + ** The OP_NotFound opcode performs the same operation on index btrees + ** (with arbitrary multi-value keys). + ** + ** This opcode leaves the cursor in a state where it cannot be advanced + ** in either direction. In other words, the Next and Prev opcodes will + ** not work following this opcode. + ** + ** See also: Found, NotFound, NoConflict, SeekRowid + */ + /* Opcode: NotExists P1 P2 P3 * * + ** Synopsis: intkey=r[P3] + ** + ** P1 is the index of a cursor open on an SQL table btree (with integer + ** keys). P3 is an integer rowid. If P1 does not contain a record with + ** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an + ** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then + ** leave the cursor pointing at that record and fall through to the next + ** instruction. + ** + ** The OP_SeekRowid opcode performs the same operation but also allows the + ** P3 register to contain a non-integer value, in which case the jump is + ** always taken. This opcode requires that P3 always contain an integer. + ** + ** The OP_NotFound opcode performs the same operation on index btrees + ** (with arbitrary multi-value keys). + ** + ** This opcode leaves the cursor in a state where it cannot be advanced + ** in either direction. In other words, the Next and Prev opcodes will + ** not work following this opcode. + ** + ** See also: Found, NotFound, NoConflict, SeekRowid + */ + _97: + ; + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn3)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + /* If pIn3->u.i does not contain an integer, compute iKey as the + ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted + ** into an integer without loss of information. Take care to avoid + ** changing the datatype of pIn3, however, as it is used by other + ** parts of the prepared statement. */ + *(*TMem)(unsafe.Pointer(bp + 256)) = TMem{} + /* If pIn3->u.i does not contain an integer, compute iKey as the + ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted + ** into an integer without loss of information. Take care to avoid + ** changing the datatype of pIn3, however, as it is used by other + ** parts of the prepared statement. */ + *(*Tsqlite3_value)(unsafe.Pointer(bp + 256)) = **(**TMem)(__ccgo_up(pIn3)) + _applyAffinity(tls, bp+256, int8(SQLITE_AFF_NUMERIC), encoding) + if libc.Int32FromUint16((**(**TMem)(__ccgo_up(bp + 256))).Fflags)&int32(MEM_Int) == 0 { + goto jump_to_p2 + } + iKey1 = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(bp + 256))) + goto notExistsWithKey + } + /* Fall through into OP_NotExists */ + _96: + ; /* jump, in3, ncycle */ + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + iKey1 = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(pIn3))) + goto notExistsWithKey + notExistsWithKey: + ; + pC10 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr2 = *(*uintptr)(unsafe.Pointer(pC10 + 48)) + **(**int32)(__ccgo_up(bp + 248)) = 0 + rc = _sqlite3BtreeTableMoveto(tls, pCrsr2, libc.Int64FromUint64(iKey1), 0, bp+248) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget = libc.Int64FromUint64(iKey1) /* Used by OP_Delete */ + (*TVdbeCursor)(unsafe.Pointer(pC10)).FnullRow = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = uint32(CACHE_STALE) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FseekResult = **(**int32)(__ccgo_up(bp + 248)) + if **(**int32)(__ccgo_up(bp + 248)) != 0 { + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == 0 { + rc = _sqlite3CorruptError(tls, int32(102023)) + } else { + goto jump_to_p2 + } + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Sequence P1 P2 * * * + ** Synopsis: r[P2]=cursor[P1].ctr++ + ** + ** Find the next available sequence number for cursor P1. + ** Write the sequence number into register P2. + ** The sequence number on the cursor is incremented after this + ** instruction. + */ + _98: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + v191 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + 24 + v256 = *(*Ti64)(unsafe.Pointer(v191)) + *(*Ti64)(unsafe.Pointer(v191)) = *(*Ti64)(unsafe.Pointer(v191)) + 1 + *(*Ti64)(unsafe.Pointer(pOut)) = v256 + goto _189 + /* Opcode: NewRowid P1 P2 P3 * * + ** Synopsis: r[P2]=rowid + ** + ** Get a new integer record number (a.k.a "rowid") used as the key to a table. + ** The record number is not previously used as a key in the database + ** table that cursor P1 points to. The new record number is written + ** written to register P2. + ** + ** If P3>0 then P3 is a register in the root frame of this VDBE that holds + ** the largest previously generated record number. No new record numbers are + ** allowed to be less than this value. When this value reaches its maximum, + ** an SQLITE_FULL error is generated. The P3 register is updated with the ' + ** generated record number. This P3 mechanism is used to help implement the + ** AUTOINCREMENT feature. + */ + _99: + ; /* Root frame of VDBE */ + **(**Ti64)(__ccgo_up(bp + 312)) = 0 + **(**int32)(__ccgo_up(bp + 320)) = 0 + pOut = _out2Prerelease(tls, p, pOp) + pC11 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + /* The next rowid or record number (different terms for the same + ** thing) is obtained in a two-step algorithm. + ** + ** First we attempt to find the largest existing rowid and add one + ** to that. But if the largest existing rowid is already the maximum + ** positive integer, we have to fall through to the second + ** probabilistic algorithm + ** + ** The second algorithm is to select a rowid at random and see if + ** it already exists in the table. If it does not exist, we have + ** succeeded. If the random rowid does exist, we select a new one + ** and try again, up to 100 times. + */ + /* Some compilers complain about constants of the form 0x7fffffffffffffff. + ** Others complain about 0x7ffffffffffffffffLL. The following macro seems + ** to provide the constant while making all compilers happy. + */ + if !(int32(TBool(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0) { + rc = _sqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48)), bp+320) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 320)) != 0 { + **(**Ti64)(__ccgo_up(bp + 312)) = int64(1) /* IMP: R-61914-48074 */ + } else { + **(**Ti64)(__ccgo_up(bp + 312)) = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48))) + if **(**Ti64)(__ccgo_up(bp + 312)) >= libc.Int64FromUint64(libc.Uint64FromInt32(0x7fffffff)<>1)) != 0 { + rc = int32(SQLITE_FULL) /* IMP: R-17817-00630 */ + goto abort_due_to_error + } + if **(**Ti64)(__ccgo_up(bp + 312)) < *(*Ti64)(unsafe.Pointer(pMem))+int64(1) { + **(**Ti64)(__ccgo_up(bp + 312)) = *(*Ti64)(unsafe.Pointer(pMem)) + int64(1) + } + *(*Ti64)(unsafe.Pointer(pMem)) = **(**Ti64)(__ccgo_up(bp + 312)) + } + if int32(TBool(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0 { + /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the + ** largest possible integer (9223372036854775807) then the database + ** engine starts picking positive candidate ROWIDs at random until + ** it finds one that is not previously used. */ + /* We cannot be in random rowid mode if this is + ** an AUTOINCREMENT table. */ + cnt1 = 0 + for { + Xsqlite3_randomness(tls, int32(8), bp+312) + **(**Ti64)(__ccgo_up(bp + 312)) = **(**Ti64)(__ccgo_up(bp + 312)) & (libc.Int64FromUint64(libc.Uint64FromInt32(0x7fffffff)<> libc.Int32FromInt32(1)) + **(**Ti64)(__ccgo_up(bp + 312)) = **(**Ti64)(__ccgo_up(bp + 312)) + 1 /* Ensure that v is greater than zero */ + goto _270 + _270: + ; + v190 = _sqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48)), libc.Int64FromUint64(libc.Uint64FromInt64(**(**Ti64)(__ccgo_up(bp + 312)))), 0, bp+320) + rc = v190 + if v217 = v190 == SQLITE_OK && **(**int32)(__ccgo_up(bp + 320)) == 0; v217 { + cnt1 = cnt1 + 1 + v193 = cnt1 + } + if !(v217 && v193 < int32(100)) { + break + } + } + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 320)) == 0 { + rc = int32(SQLITE_FULL) /* IMP: R-38219-53002 */ + goto abort_due_to_error + } + /* EV: R-40812-03570 */ + } + (*TVdbeCursor)(unsafe.Pointer(pC11)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC11)).FcacheStatus = uint32(CACHE_STALE) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 312)) + goto _189 + /* Opcode: Insert P1 P2 P3 P4 P5 + ** Synopsis: intkey=r[P3] data=r[P2] + ** + ** Write an entry into the table of cursor P1. A new entry is + ** created if it doesn't already exist or the data for an existing + ** entry is overwritten. The data is the value MEM_Blob stored in register + ** number P2. The key is stored in register P3. The key must + ** be a MEM_Int. + ** + ** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is + ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, + ** then rowid is stored for subsequent return by the + ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). + ** + ** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might + ** run faster by avoiding an unnecessary seek on cursor P1. However, + ** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior + ** seeks on the cursor or if the most recent seek used a key equal to P3. + ** + ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an + ** UPDATE operation. Otherwise (if the flag is clear) then this opcode + ** is part of an INSERT operation. The difference is only important to + ** the update hook. + ** + ** Parameter P4 may point to a Table structure, or may be NULL. If it is + ** not NULL, then the update-hook (sqlite3.xUpdateCallback) is invoked + ** following a successful insert. + ** + ** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically + ** allocated, then ownership of P2 is transferred to the pseudo-cursor + ** and register P2 becomes ephemeral. If the cursor is changed, the + ** value of register P2 will then change. Make sure this does not + ** cause any problems.) + ** + ** This instruction only works on tables. The equivalent instruction + ** for indices is OP_IdxInsert. + */ + _100: + ; /* Payload to be inserted */ + pData = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pC12 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pKey = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey = *(*Ti64)(unsafe.Pointer(pKey)) + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(5) && ((*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) { + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TVdbeCursor)(unsafe.Pointer(pC12)).FiDb)*32))).FzDbSName + pTab1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + } else { + pTab1 = uintptr(0) + zDb = uintptr(0) + } + /* Invoke the pre-update hook, if any */ + if pTab1 != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && !(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&libc.Int32FromInt32(OPFLAG_ISUPDATE) != 0) { + _sqlite3VdbePreUpdateHook(tls, p, pC12, int32(SQLITE_INSERT), zDb, pTab1, (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey, (*TOp)(unsafe.Pointer(pOp)).Fp2, -int32(1)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback == uintptr(0) || (*TTable)(unsafe.Pointer(pTab1)).FaCol == uintptr(0) { + /* Prevent post-update hook from running in cases when it should not */ + pTab1 = uintptr(0) + } + } + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_ISNOOP) != 0 { + goto _189 + } + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_LASTROWID) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey + } + } + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FpData = (*TMem)(unsafe.Pointer(pData)).Fz + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnData = (*TMem)(unsafe.Pointer(pData)).Fn + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_USESEEKRESULT) != 0 { + v190 = (*TVdbeCursor)(unsafe.Pointer(pC12)).FseekResult + } else { + v190 = 0 + } + seekResult = v190 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pData)).Fflags)&int32(MEM_Zero) != 0 { + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnZero = *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pData)).Fu)) + } else { + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnZero = 0 + } + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FpKey = uintptr(0) + rc = _sqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC12 + 48)), bp+328, libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&(libc.Int32FromInt32(OPFLAG_APPEND)|libc.Int32FromInt32(OPFLAG_SAVEPOSITION)|libc.Int32FromInt32(OPFLAG_PREFORMAT)), seekResult) + (*TVdbeCursor)(unsafe.Pointer(pC12)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC12)).FcacheStatus = uint32(CACHE_STALE) + colCacheCtr = colCacheCtr + 1 + /* Invoke the update-hook if required. */ + if rc != 0 { + goto abort_due_to_error + } + if pTab1 != 0 { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_ISUPDATE) != 0 { + v190 = int32(SQLITE_UPDATE) + } else { + v190 = int32(SQLITE_INSERT) + } + (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Tsqlite_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg, v190, zDb, (*TTable)(unsafe.Pointer(pTab1)).FzName, (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey) + } + goto _189 + /* Opcode: RowCell P1 P2 P3 * * + ** + ** P1 and P2 are both open cursors. Both must be opened on the same type + ** of table - intkey or index. This opcode is used as part of copying + ** the current row from P2 into P1. If the cursors are opened on intkey + ** tables, register P3 contains the rowid to use with the new record in + ** P1. If they are opened on index tables, P3 is not used. + ** + ** This opcode must be followed by either an Insert or InsertIdx opcode + ** with the OPFLAG_PREFORMAT flag set to complete the insert operation. + */ + _101: + ; /* Rowid value to insert with */ + pDest1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pSrc = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*8)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + v206 = *(*Ti64)(unsafe.Pointer(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56)) + } else { + v206 = 0 + } + iKey2 = v206 + rc = _sqlite3BtreeTransferRow(tls, *(*uintptr)(unsafe.Pointer(pDest1 + 48)), *(*uintptr)(unsafe.Pointer(pSrc + 48)), iKey2) + if rc != SQLITE_OK { + goto abort_due_to_error + } + goto _189 + /* Opcode: Delete P1 P2 P3 P4 P5 + ** + ** Delete the record at which the P1 cursor is currently pointing. + ** + ** If the OPFLAG_SAVEPOSITION bit of the P5 parameter is set, then + ** the cursor will be left pointing at either the next or the previous + ** record in the table. If it is left pointing at the next record, then + ** the next Next instruction will be a no-op. As a result, in this case + ** it is ok to delete a record from within a Next loop. If + ** OPFLAG_SAVEPOSITION bit of P5 is clear, then the cursor will be + ** left in an undefined state. + ** + ** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this + ** delete is one of several associated with deleting a table row and + ** all its associated index entries. Exactly one of those deletes is + ** the "primary" delete. The others are all on OPFLAG_FORDELETE + ** cursors or else are marked with the AUXDELETE flag. + ** + ** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then + ** the row change count is incremented (otherwise not). + ** + ** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the + ** pre-update-hook for deletes is run, but the btree is otherwise unchanged. + ** This happens when the OP_Delete is to be shortly followed by an OP_Insert + ** with the same key, causing the btree entry to be overwritten. + ** + ** P1 must not be pseudo-table. It has to be a real table with + ** multiple rows. + ** + ** If P4 is not NULL then it points to a Table object. In this case either + ** the update or pre-update hook, or both, may be invoked. The P1 cursor must + ** have been positioned using OP_NotFound prior to invoking this opcode in + ** this case. Specifically, if one is configured, the pre-update hook is + ** invoked if P4 is not NULL. The update-hook is invoked if one is configured, + ** P4 is not NULL, and the OPFLAG_NCHANGE flag is set in P2. + ** + ** If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address + ** of the memory cell that contains the value that the rowid of the row will + ** be set to by the update. + */ + _102: + ; + opflags = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pC13 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + /* If the update-hook or pre-update-hook will be invoked, set zDb to + ** the name of the db to pass as to it. Also set local pTab to a copy + ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was + ** last moved with OP_Next or OP_Prev, not Seek or NotFound, set + ** VdbeCursor.movetoTarget to the current rowid. */ + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(5) && ((*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) { + zDb1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TVdbeCursor)(unsafe.Pointer(pC13)).FiDb)*32))).FzDbSName + pTab2 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_SAVEPOSITION) != 0 && (*TVdbeCursor)(unsafe.Pointer(pC13)).FisTable != 0 { + (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC13 + 48))) + } + } else { + zDb1 = uintptr(0) + pTab2 = uintptr(0) + } + /* Invoke the pre-update-hook if required. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && pTab2 != 0 { + if opflags&int32(OPFLAG_ISUPDATE) != 0 { + v190 = int32(SQLITE_UPDATE) + } else { + v190 = int32(SQLITE_DELETE) + } + _sqlite3VdbePreUpdateHook(tls, p, pC13, v190, zDb1, pTab2, (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget, (*TOp)(unsafe.Pointer(pOp)).Fp3, -int32(1)) + } + if opflags&int32(OPFLAG_ISNOOP) != 0 { + goto _189 + } + /* Only flags that can be set are SAVEPOISTION and AUXDELETE */ + rc = _sqlite3BtreeDelete(tls, *(*uintptr)(unsafe.Pointer(pC13 + 48)), uint8((*TOp)(unsafe.Pointer(pOp)).Fp5)) + (*TVdbeCursor)(unsafe.Pointer(pC13)).FcacheStatus = uint32(CACHE_STALE) + colCacheCtr = colCacheCtr + 1 + (*TVdbeCursor)(unsafe.Pointer(pC13)).FseekResult = 0 + if rc != 0 { + goto abort_due_to_error + } + /* Invoke the update-hook if required. */ + if opflags&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + if (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0 && pTab2 != uintptr(0) && (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Tsqlite_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg, int32(SQLITE_DELETE), zDb1, (*TTable)(unsafe.Pointer(pTab2)).FzName, (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget) + } + } + goto _189 + /* Opcode: ResetCount * * * * * + ** + ** The value of the change counter is copied to the database handle + ** change counter (returned by subsequent calls to sqlite3_changes()). + ** Then the VMs internal change counter resets to 0. + ** This is used by trigger programs. + */ + _103: + ; + _sqlite3VdbeSetChanges(tls, db, (*TVdbe)(unsafe.Pointer(p)).FnChange) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + goto _189 + /* Opcode: SorterCompare P1 P2 P3 P4 + ** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2 + ** + ** P1 is a sorter cursor. This instruction compares a prefix of the + ** record blob in register P3 against a prefix of the entry that + ** the sorter cursor currently points to. Only the first P4 fields + ** of r[P3] and the sorter record are compared. + ** + ** If either P3 or the sorter contains a NULL in one of their significant + ** fields (not counting the P4 fields at the end which are ignored) then + ** the comparison is assumed to be equal. + ** + ** Fall through to next instruction if the two records compare equal to + ** each other. Jump to P2 if they are different. + */ + _104: + ; + pC14 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + nKeyCol = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + **(**int32)(__ccgo_up(bp + 376)) = 0 + rc = _sqlite3VdbeSorterCompare(tls, pC14, pIn3, nKeyCol, bp+376) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 376)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: SorterData P1 P2 P3 * * + ** Synopsis: r[P2]=data + ** + ** Write into register P2 the current sorter data for sorter cursor P1. + ** Then clear the column header cache on cursor P3. + ** + ** This opcode is normally used to move a record out of the sorter and into + ** a register that is the source for a pseudo-table cursor created using + ** OpenPseudo. That pseudo-table cursor is the one that is identified by + ** parameter P3. Clearing the P3 column cache as part of this opcode saves + ** us from having to issue a separate NullRow instruction to clear that cache. + */ + _105: + ; + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pC15 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3VdbeSorterRowkey(tls, pC15, pOut) + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*8)))).FcacheStatus = uint32(CACHE_STALE) + goto _189 + /* Opcode: RowData P1 P2 P3 * * + ** Synopsis: r[P2]=data + ** + ** Write into register P2 the complete row content for the row at + ** which cursor P1 is currently pointing. + ** There is no interpretation of the data. + ** It is just copied onto the P2 register exactly as + ** it is found in the database file. + ** + ** If cursor P1 is an index, then the content is the key of the row. + ** If cursor P2 is a table, then the content extracted is the data. + ** + ** If the P1 cursor must be pointing to a valid row (not a NULL row) + ** of a real table, not a pseudo-table. + ** + ** If P3!=0 then this opcode is allowed to make an ephemeral pointer + ** into the database page. That means that the content of the output + ** register will be invalidated as soon as the cursor moves - including + ** moves caused by other cursors that "save" the current cursors + ** position in order that they can write to the same table. If P3==0 + ** then a copy of the data is made into memory. P3!=0 is faster, but + ** P3==0 is safer. + ** + ** If P3!=0 then the content of the P2 register is unsuitable for use + ** in OP_Result and any OP_Result will invalidate the P2 register content. + ** The P2 register content is invalidated by opcodes like OP_Function or + ** by any use of another cursor pointing to the same table. + */ + _106: + ; + pOut = _out2Prerelease(tls, p, pOp) + pC16 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr3 = *(*uintptr)(unsafe.Pointer(pC16 + 48)) + /* The OP_RowData opcodes always follow OP_NotExists or + ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions + ** that might invalidate the cursor. + ** If this were not the case, one of the following assert()s + ** would fail. Should this ever change (because of changes in the code + ** generator) then the fix would be to insert a call to + ** sqlite3VdbeCursorMoveto(). + */ + n3 = _sqlite3BtreePayloadSize(tls, pCrsr3) + if n3 > libc.Uint32FromInt32(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCrsr3, n3, pOut) + if rc != 0 { + goto abort_due_to_error + } + if !((*TOp)(unsafe.Pointer(pOp)).Fp3 != 0) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + } + goto _189 + /* Opcode: Rowid P1 P2 * * * + ** Synopsis: r[P2]=PX rowid of P1 + ** + ** Store in register P2 an integer which is the key of the table entry that + ** P1 is currently point to. + ** + ** P1 can be either an ordinary table or a virtual table. There used to + ** be a separate OP_VRowid opcode for use with virtual tables, but this + ** one opcode now works for both table types. + */ + _107: + ; + pOut = _out2Prerelease(tls, p, pOp) + pC17 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + goto _189 + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FdeferredMoveto != 0 { + **(**Ti64)(__ccgo_up(bp + 384)) = (*TVdbeCursor)(unsafe.Pointer(pC17)).FmovetoTarget + } else { + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC17)).FeCurType) == int32(CURTYPE_VTAB) { + pVtab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pC17 + 48)))).FpVtab + pModule = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule)).FxRowid})))(tls, *(*uintptr)(unsafe.Pointer(pC17 + 48)), bp+384) + _sqlite3VtabImportErrmsg(tls, p, pVtab) + if rc != 0 { + goto abort_due_to_error + } + } else { + rc = _sqlite3VdbeCursorRestore(tls, pC17) + if rc != 0 { + goto abort_due_to_error + } + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + goto _189 + } + **(**Ti64)(__ccgo_up(bp + 384)) = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC17 + 48))) + } + } + } + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 384)) + goto _189 + /* Opcode: NullRow P1 * * * * + ** + ** Move the cursor P1 to a null row. Any OP_Column operations + ** that occur while the cursor is on the null row will always + ** write a NULL. + ** + ** If cursor P1 is not previously opened, open it now to a special + ** pseudo-cursor that always returns NULL for every column. + */ + _108: + ; + pC18 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pC18 == uintptr(0) { + /* If the cursor is not already open, create a special kind of + ** pseudo-cursor that always gives null rows. */ + pC18 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, int32(1), uint8(CURTYPE_PSEUDO)) + if pC18 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pC18)).FseekResult = 0 + (*TVdbeCursor)(unsafe.Pointer(pC18)).FisTable = uint8(1) + libc.SetBitFieldPtr8Uint32(pC18+8, libc.Uint32FromInt32(1), 3, 0x8) + *(*uintptr)(unsafe.Pointer(pC18 + 48)) = _sqlite3BtreeFakeValidCursor(tls) + } + (*TVdbeCursor)(unsafe.Pointer(pC18)).FnullRow = uint8(1) + (*TVdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = uint32(CACHE_STALE) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC18)).FeCurType) == CURTYPE_BTREE { + _sqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pC18 + 48))) + } + goto _189 + /* Opcode: SeekEnd P1 * * * * + ** + ** Position cursor P1 at the end of the btree for the purpose of + ** appending a new entry onto the btree. + ** + ** It is assumed that the cursor is used only for appending and so + ** if the cursor is valid, then the cursor must already be pointing + ** at the end of the btree and so no changes are made to + ** the cursor. + */ + /* Opcode: Last P1 P2 * * * + ** + ** The next use of the Rowid or Column or Prev instruction for P1 + ** will refer to the last entry in the database table or index. + ** If the table or index is empty and P2>0, then jump immediately to P2. + ** If P2 is 0 or if the table or index is not empty, fall through + ** to the following instruction. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + */ + _110: + ; /* ncycle */ + _109: + ; + pC19 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr4 = *(*uintptr)(unsafe.Pointer(pC19 + 48)) + **(**int32)(__ccgo_up(bp + 392)) = 0 + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_SeekEnd) { + (*TVdbeCursor)(unsafe.Pointer(pC19)).FseekResult = -int32(1) + if _sqlite3BtreeCursorIsValidNN(tls, pCrsr4) != 0 { + goto _189 + } + } + rc = _sqlite3BtreeLast(tls, pCrsr4, bp+392) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FnullRow = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 392))) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = uint32(CACHE_STALE) + if rc != 0 { + goto abort_due_to_error + } + if (*TOp)(unsafe.Pointer(pOp)).Fp2 > 0 { + if **(**int32)(__ccgo_up(bp + 392)) != 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: IfSizeBetween P1 P2 P3 P4 * + ** + ** Let N be the approximate number of rows in the table or index + ** with cursor P1 and let X be 10*log2(N) if N is positive or -1 + ** if N is zero. + ** + ** Jump to P2 if X is in between P3 and P4, inclusive. + */ + _111: + ; + pC20 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr5 = *(*uintptr)(unsafe.Pointer(pC20 + 48)) + rc = _sqlite3BtreeFirst(tls, pCrsr5, bp+396) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 396)) != 0 { + sz = int64(-int32(1)) /* -Infinity encoding */ + } else { + sz = _sqlite3BtreeRowCountEst(tls, pCrsr5) + sz = int64(_sqlite3LogEst(tls, libc.Uint64FromInt64(sz))) + } + **(**int32)(__ccgo_up(bp + 396)) = libc.BoolInt32(sz >= int64((*TOp)(unsafe.Pointer(pOp)).Fp3) && sz <= int64((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) + if **(**int32)(__ccgo_up(bp + 396)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: SorterSort P1 P2 * * * + ** + ** After all records have been inserted into the Sorter object + ** identified by P1, invoke this opcode to actually do the sorting. + ** Jump to P2 if there are no records to be sorted. + ** + ** This opcode is an alias for OP_Sort and OP_Rewind that is used + ** for Sorter objects. + */ + /* Opcode: Sort P1 P2 * * * + ** + ** This opcode does exactly the same thing as OP_Rewind except that + ** it increments an undocumented global variable used for testing. + ** + ** Sorting is accomplished by writing records into a sorting index, + ** then rewinding that index and playing it back from beginning to + ** end. We use the OP_Sort opcode instead of OP_Rewind to do the + ** rewinding so that the global variable will be incremented and + ** regression tests can determine whether or not the optimizer is + ** correctly optimizing out sorts. + */ + _113: + ; /* jump ncycle */ + _112: + ; /* jump ncycle */ + **(**Tu32)(__ccgo_up(p + 212 + 2*4)) = **(**Tu32)(__ccgo_up(p + 212 + 2*4)) + 1 + /* Fall through into OP_Rewind */ + /* Opcode: Rewind P1 P2 * * * + ** + ** The next use of the Rowid or Column or Next instruction for P1 + ** will refer to the first entry in the database table or index. + ** If the table or index is empty, jump immediately to P2. + ** If the table or index is not empty, fall through to the following + ** instruction. + ** + ** If P2 is zero, that is an assertion that the P1 table is never + ** empty and hence the jump will never be taken. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + */ + _114: + ; + pC21 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + **(**int32)(__ccgo_up(bp + 400)) = int32(1) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC21)).FeCurType) == int32(CURTYPE_SORTER) { + rc = _sqlite3VdbeSorterRewind(tls, pC21, bp+400) + } else { + pCrsr6 = *(*uintptr)(unsafe.Pointer(pC21 + 48)) + rc = _sqlite3BtreeFirst(tls, pCrsr6, bp+400) + (*TVdbeCursor)(unsafe.Pointer(pC21)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC21)).FcacheStatus = uint32(CACHE_STALE) + } + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(pC21)).FnullRow = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 400))) + if (*TOp)(unsafe.Pointer(pOp)).Fp2 > 0 { + if **(**int32)(__ccgo_up(bp + 400)) != 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: IfEmpty P1 P2 * * * + ** Synopsis: if( empty(P1) ) goto P2 + ** + ** Check to see if the b-tree table that cursor P1 references is empty + ** and jump to P2 if it is. + */ + _115: + ; + pC22 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr7 = *(*uintptr)(unsafe.Pointer(pC22 + 48)) + rc = _sqlite3BtreeIsEmpty(tls, pCrsr7, bp+404) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 404)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Next P1 P2 P3 * P5 + ** + ** Advance cursor P1 so that it points to the next key/data pair in its + ** table or index. If there are no more key/value pairs then fall through + ** to the following instruction. But if the cursor advance was successful, + ** jump immediately to P2. + ** + ** The Next opcode is only valid following an SeekGT, SeekGE, or + ** OP_Rewind opcode used to position the cursor. Next is not allowed + ** to follow SeekLT, SeekLE, or OP_Last. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. P1 must have + ** been opened prior to this opcode or the program will segfault. + ** + ** The P3 value is a hint to the btree implementation. If P3==1, that + ** means P1 is an SQL index and that this instruction could have been + ** omitted if that index had been unique. P3 is usually 0. P3 is + ** always either 0 or 1. + ** + ** If P5 is positive and the jump is taken, then event counter + ** number P5-1 in the prepared statement is incremented. + ** + ** See also: Prev + */ + /* Opcode: Prev P1 P2 P3 * P5 + ** + ** Back up cursor P1 so that it points to the previous key/data pair in its + ** table or index. If there is no previous key/value pairs then fall through + ** to the following instruction. But if the cursor backup was successful, + ** jump immediately to P2. + ** + ** + ** The Prev opcode is only valid following an SeekLT, SeekLE, or + ** OP_Last opcode used to position the cursor. Prev is not allowed + ** to follow SeekGT, SeekGE, or OP_Rewind. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. If P1 is + ** not open then the behavior is undefined. + ** + ** The P3 value is a hint to the btree implementation. If P3==1, that + ** means P1 is an SQL index and that this instruction could have been + ** omitted if that index had been unique. P3 is usually 0. P3 is + ** always either 0 or 1. + ** + ** If P5 is positive and the jump is taken, then event counter + ** number P5-1 in the prepared statement is incremented. + */ + /* Opcode: SorterNext P1 P2 * * P5 + ** + ** This opcode works just like OP_Next except that P1 must be a + ** sorter object for which the OP_SorterSort opcode has been + ** invoked. This opcode advances the cursor to the next sorted + ** record, or jumps to P2 if there are no more sorted records. + */ + _118: + ; + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3VdbeSorterNext(tls, db, pC23) + goto next_tail + _116: + ; /* jump, ncycle */ + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC23 + 48)), (*TOp)(unsafe.Pointer(pOp)).Fp3) + goto next_tail + _117: + ; /* jump, ncycle */ + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC23 + 48)), (*TOp)(unsafe.Pointer(pOp)).Fp3) + goto next_tail + next_tail: + ; + (*TVdbeCursor)(unsafe.Pointer(pC23)).FcacheStatus = uint32(CACHE_STALE) + if rc == SQLITE_OK { + (*TVdbeCursor)(unsafe.Pointer(pC23)).FnullRow = uint8(0) + **(**Tu32)(__ccgo_up(p + 212 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*4)) = **(**Tu32)(__ccgo_up(p + 212 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*4)) + 1 + goto jump_to_p2_and_check_for_interrupt + } + if rc != int32(SQLITE_DONE) { + goto abort_due_to_error + } + rc = SQLITE_OK + (*TVdbeCursor)(unsafe.Pointer(pC23)).FnullRow = uint8(1) + goto check_for_interrupt + /* Opcode: IdxInsert P1 P2 P3 P4 P5 + ** Synopsis: key=r[P2] + ** + ** Register P2 holds an SQL index key made using the + ** MakeRecord instructions. This opcode writes that key + ** into the index P1. Data for the entry is nil. + ** + ** If P4 is not zero, then it is the number of values in the unpacked + ** key of reg(P2). In that case, P3 is the index of the first register + ** for the unpacked key. The availability of the unpacked key can sometimes + ** be an optimization. + ** + ** If P5 has the OPFLAG_APPEND bit set, that is a hint to the b-tree layer + ** that this insert is likely to be an append. + ** + ** If P5 has the OPFLAG_NCHANGE bit set, then the change counter is + ** incremented by this instruction. If the OPFLAG_NCHANGE bit is clear, + ** then the change counter is unchanged. + ** + ** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might + ** run faster by avoiding an unnecessary seek on cursor P1. However, + ** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior + ** seeks on the cursor or if the most recent seek used a key equivalent + ** to P2. + ** + ** This instruction only works for indices. The equivalent instruction + ** for tables is OP_Insert. + */ + _119: + ; + pC24 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn2) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FnKey = int64((*TMem)(unsafe.Pointer(pIn2)).Fn) + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FpKey = (*TMem)(unsafe.Pointer(pIn2)).Fz + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FnMem = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_USESEEKRESULT) != 0 { + v190 = (*TVdbeCursor)(unsafe.Pointer(pC24)).FseekResult + } else { + v190 = 0 + } + rc = _sqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC24 + 48)), bp+408, libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&(libc.Int32FromInt32(OPFLAG_APPEND)|libc.Int32FromInt32(OPFLAG_SAVEPOSITION)|libc.Int32FromInt32(OPFLAG_PREFORMAT)), v190) + (*TVdbeCursor)(unsafe.Pointer(pC24)).FcacheStatus = uint32(CACHE_STALE) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: SorterInsert P1 P2 * * * + ** Synopsis: key=r[P2] + ** + ** Register P2 holds an SQL index key made using the + ** MakeRecord instructions. This opcode writes that key + ** into the sorter P1. Data for the entry is nil. + */ + _120: + ; + pC25 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn2) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + rc = _sqlite3VdbeSorterWrite(tls, pC25, pIn2) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: IdxDelete P1 P2 P3 P4 * + ** Synopsis: key=r[P2@P3] + ** + ** The content of P3 registers starting at register P2 form + ** an unpacked index key. This opcode removes that entry from the + ** index opened by cursor P1. + ** + ** P4 is a pointer to an Index structure. + ** + ** Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found + ** and not in writable_schema mode. + */ + _121: + ; + pC26 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr8 = *(*uintptr)(unsafe.Pointer(pC26 + 48)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC26)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FnField = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).Fdefault_rc = 0 + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + rc = _sqlite3BtreeIndexMoveto(tls, pCrsr8, bp+464, bp+456) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 456)) != 0 { + rc = _sqlite3VdbeFindIndexKey(tls, pCrsr8, *(*uintptr)(unsafe.Pointer(pOp + 16)), bp+464, bp+456, 0) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 456)) != 0 { + if !(_sqlite3WritableSchema(tls, db) != 0) { + rc = _sqlite3ReportError(tls, libc.Int32FromInt32(SQLITE_CORRUPT)|libc.Int32FromInt32(3)< int64(0x7fffffff) { + rc = _sqlite3CorruptError(tls, int32(103352)) + goto abort_due_to_error + } + _sqlite3VdbeMemInit(tls, bp+552, db, uint16(0)) + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCur2, libc.Uint32FromInt64(nCellKey), bp+552) + if rc != 0 { + goto abort_due_to_error + } + res11 = _sqlite3VdbeRecordCompareWithSkip(tls, (**(**TMem)(__ccgo_up(bp + 552))).Fn, (**(**TMem)(__ccgo_up(bp + 552))).Fz, bp+512, 0) + _sqlite3VdbeMemReleaseMalloc(tls, bp+552) + /* End of inlined sqlite3VdbeIdxKeyCompare() */ + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode)&int32(1) == libc.Int32FromInt32(OP_IdxLT)&libc.Int32FromInt32(1) { + res11 = -res11 + } else { + res11 = res11 + 1 + } + if res11 > 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Destroy P1 P2 P3 * * + ** + ** Delete an entire database table or index whose root page in the database + ** file is given by P1. + ** + ** The table being destroyed is in the main database file if P3==0. If + ** P3==1 then the table to be destroyed is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If AUTOVACUUM is enabled then it is possible that another root page + ** might be moved into the newly deleted root page in order to keep all + ** root pages contiguous at the beginning of the database. The former + ** value of the root page that moved - its value before the move occurred - + ** is stored in register P2. If no page movement was required (because the + ** table being dropped was already the last one in the database) then a + ** zero is stored in register P2. If AUTOVACUUM is disabled then a zero + ** is stored in register P2. + ** + ** This opcode throws an error if there are any active reader VMs when + ** it is invoked. This is done to avoid the difficulty associated with + ** updating existing cursors when a root page is moved in an AUTOVACUUM + ** database. This error is thrown even if the database is not an AUTOVACUUM + ** db in order to avoid introducing an incompatibility between autovacuum + ** and non-autovacuum modes. + ** + ** See also: Clear + */ + _129: + ; + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > (*Tsqlite3)(unsafe.Pointer(db)).FnVDestroy+int32(1) { + rc = int32(SQLITE_LOCKED) + (*TVdbe)(unsafe.Pointer(p)).FerrorAction = uint8(OE_Abort) + goto abort_due_to_error + } else { + iDb2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + **(**int32)(__ccgo_up(bp + 608)) = 0 /* Not needed. Only to silence a warning. */ + rc = _sqlite3BtreeDropTable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb2)*32))).FpBt, (*TOp)(unsafe.Pointer(pOp)).Fp1, bp+608) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) + *(*Ti64)(unsafe.Pointer(pOut)) = int64(**(**int32)(__ccgo_up(bp + 608))) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 608)) != 0 { + _sqlite3RootPageMoved(tls, db, iDb2, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 608))), libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp1)) + /* All OP_Destroy operations occur on the same btree */ + resetSchemaOnFault = libc.Uint8FromInt32(iDb2 + int32(1)) + } + } + goto _189 + /* Opcode: Clear P1 P2 P3 + ** + ** Delete all contents of the database table or index whose root page + ** in the database file is given by P1. But, unlike Destroy, do not + ** remove the table or index from the database file. + ** + ** The table being cleared is in the main database file if P2==0. If + ** P2==1 then the table to be cleared is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If the P3 value is non-zero, then the row change count is incremented + ** by the number of rows in the table being cleared. If P3 is greater + ** than zero, then the value stored in register P3 is also incremented + ** by the number of rows in the table being cleared. + ** + ** See also: Destroy + */ + _130: + ; + **(**Ti64)(__ccgo_up(bp + 616)) = 0 + rc = _sqlite3BtreeClearTable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*32))).FpBt, libc.Int32FromUint32(libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp1)), bp+616) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + **(**Ti64)(__ccgo_up(p + 56)) += **(**Ti64)(__ccgo_up(bp + 616)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 > 0 { + *(*Ti64)(unsafe.Pointer(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56)) += **(**Ti64)(__ccgo_up(bp + 616)) + } + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: ResetSorter P1 * * * * + ** + ** Delete all contents from the ephemeral table or sorter + ** that is open on cursor P1. + ** + ** This opcode only works for cursors used for sorting and + ** opened with OP_OpenEphemeral or OP_SorterOpen. + */ + _131: + ; + pC30 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC30)).FeCurType) == int32(CURTYPE_SORTER) { + _sqlite3VdbeSorterReset(tls, db, *(*uintptr)(unsafe.Pointer(pC30 + 48))) + } else { + rc = _sqlite3BtreeClearTableOfCursor(tls, *(*uintptr)(unsafe.Pointer(pC30 + 48))) + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: CreateBtree P1 P2 P3 * * + ** Synopsis: r[P2]=root iDb=P1 flags=P3 + ** + ** Allocate a new b-tree in the main database file if P1==0 or in the + ** TEMP database file if P1==1 or in an attached database if + ** P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table + ** it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table. + ** The root page number of the new b-tree is stored in register P2. + */ + _132: + ; + pOut = _out2Prerelease(tls, p, pOp) + **(**TPgno)(__ccgo_up(bp + 624)) = uint32(0) + pDb3 = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32 + rc = _sqlite3BtreeCreateTable(tls, (*TDb)(unsafe.Pointer(pDb3)).FpBt, bp+624, (*TOp)(unsafe.Pointer(pOp)).Fp3) + if rc != 0 { + goto abort_due_to_error + } + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(**(**TPgno)(__ccgo_up(bp + 624))) + goto _189 + /* Opcode: SqlExec P1 P2 * P4 * + ** + ** Run the SQL statement or statements specified in the P4 string. + ** + ** The P1 parameter is a bitmask of options: + ** + ** 0x0001 Disable Auth and Trace callbacks while the statements + ** in P4 are running. + ** + ** 0x0002 Set db->nAnalysisLimit to P2 while the statements in + ** P4 are running. + ** + */ + _133: + ; + (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec = (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec + 1 + **(**uintptr)(__ccgo_up(bp + 632)) = uintptr(0) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + mTrace = (*Tsqlite3)(unsafe.Pointer(db)).FmTrace + savedAnalysisLimit = (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit + if (*TOp)(unsafe.Pointer(pOp)).Fp1&int32(0x0001) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = uint8(0) + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1&int32(0x0002) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = (*TOp)(unsafe.Pointer(pOp)).Fp2 + } + rc = Xsqlite3_exec(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16)), uintptr(0), uintptr(0), bp+632) + (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec = (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec - 1 + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = mTrace + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = savedAnalysisLimit + if **(**uintptr)(__ccgo_up(bp + 632)) != 0 || rc != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, **(**uintptr)(__ccgo_up(bp + 632)))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 632))) + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + goto abort_due_to_error + } + goto _189 + /* Opcode: ParseSchema P1 * * P4 * + ** + ** Read and parse all entries from the schema table of database P1 + ** that match the WHERE clause P4. If P4 is a NULL pointer, then the + ** entire schema for P1 is reparsed. + ** + ** This opcode invokes the parser to create a new virtual machine, + ** then runs the new virtual machine. It is thus a re-entrant opcode. + */ + _134: + ; + /* Any prepared statement that invokes this opcode will hold mutexes + ** on every btree. This is a prerequisite for invoking + ** sqlite3InitCallback(). + */ + iDb3 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + if *(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0) { + _sqlite3SchemaClear(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FpSchema) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_SchemaKnownOk)) + rc = _sqlite3InitOne(tls, db, iDb3, p+168, uint32((*TOp)(unsafe.Pointer(pOp)).Fp5)) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + } else { + zSchema = __ccgo_ts + 6628 + (**(**TInitData)(__ccgo_up(bp + 640))).Fdb = db + (**(**TInitData)(__ccgo_up(bp + 640))).FiDb = iDb3 + (**(**TInitData)(__ccgo_up(bp + 640))).FpzErrMsg = p + 168 + (**(**TInitData)(__ccgo_up(bp + 640))).FmInitFlags = uint32(0) + (**(**TInitData)(__ccgo_up(bp + 640))).FmxPage = _sqlite3BtreeLastPage(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FpBt) + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+6642, libc.VaList(bp+984, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FzDbSName, zSchema, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(1) + (**(**TInitData)(__ccgo_up(bp + 640))).Frc = SQLITE_OK + (**(**TInitData)(__ccgo_up(bp + 640))).FnInitRow = uint32(0) + rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_sqlite3InitCallback), bp+640, uintptr(0)) + if rc == SQLITE_OK { + rc = (**(**TInitData)(__ccgo_up(bp + 640))).Frc + } + if rc == SQLITE_OK && (**(**TInitData)(__ccgo_up(bp + 640))).FnInitRow == uint32(0) { + /* The OP_ParseSchema opcode with a non-NULL P4 argument should parse + ** at least one SQL statement. Any less than that indicates that + ** the sqlite_schema table is corrupt. */ + rc = _sqlite3CorruptError(tls, int32(103645)) + } + _sqlite3DbFreeNN(tls, db, zSql) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(0) + } + } + if rc != 0 { + _sqlite3ResetAllSchemasOfConnection(tls, db) + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + goto abort_due_to_error + } + goto _189 + /* Opcode: LoadAnalysis P1 * * * * + ** + ** Read the sqlite_stat1 table for database P1 and load the content + ** of that table into the internal index hash table. This will cause + ** the analysis to be used when preparing all subsequent queries. + */ + _135: + ; + rc = _sqlite3AnalysisLoad(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: DropTable P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the table named P4 in database P1. This is called after a table + ** is dropped from disk (using the Destroy opcode) in order to keep + ** the internal representation of the + ** schema consistent with what is on disk. + */ + _136: + ; + _sqlite3UnlinkAndDeleteTable(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: DropIndex P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the index named P4 in database P1. This is called after an index + ** is dropped from disk (using the Destroy opcode) + ** in order to keep the internal representation of the + ** schema consistent with what is on disk. + */ + _137: + ; + _sqlite3UnlinkAndDeleteIndex(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: DropTrigger P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the trigger named P4 in database P1. This is called after a trigger + ** is dropped from disk (using the Destroy opcode) in order to keep + ** the internal representation of the + ** schema consistent with what is on disk. + */ + _138: + ; + _sqlite3UnlinkAndDeleteTrigger(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: IntegrityCk P1 P2 P3 P4 P5 + ** + ** Do an analysis of the currently open database. Store in + ** register (P1+1) the text of an error message describing any problems. + ** If no problems are found, store a NULL in register (P1+1). + ** + ** The register (P1) contains one less than the maximum number of allowed + ** errors. At most reg(P1) errors will be reported. + ** In other words, the analysis stops as soon as reg(P1) errors are + ** seen. Reg(P1) is updated with the number of errors remaining. + ** + ** The root page numbers of all tables in the database are integers + ** stored in P4_INTARRAY argument. + ** + ** If P5 is not zero, the check is done on the auxiliary database + ** file, not the main database file. + ** + ** This opcode is used to implement the integrity_check pragma. + */ + _139: + ; /* Register keeping track of errors remaining */ + nRoot = (*TOp)(unsafe.Pointer(pOp)).Fp2 + aRoot = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pnErr = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1+int32(1))*56 + rc = _sqlite3BtreeIntegrityCheck(tls, db, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*32))).FpBt, aRoot+1*4, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, nRoot, int32(*(*Ti64)(unsafe.Pointer(pnErr)))+int32(1), bp+680, bp+688) + _sqlite3VdbeMemSetNull(tls, pIn1) + if **(**int32)(__ccgo_up(bp + 680)) == 0 { + } else { + if rc != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 688))) + goto abort_due_to_error + } else { + *(*Ti64)(unsafe.Pointer(pnErr)) -= int64(**(**int32)(__ccgo_up(bp + 680)) - int32(1)) + _sqlite3VdbeMemSetStr(tls, pIn1, **(**uintptr)(__ccgo_up(bp + 688)), int64(-int32(1)), uint8(SQLITE_UTF8), __ccgo_fp(Xsqlite3_free)) + } + } + _sqlite3VdbeChangeEncoding(tls, pIn1, libc.Int32FromUint8(encoding)) + goto check_for_interrupt + /* Opcode: IFindKey P1 P2 P3 P4 * + ** + ** This instruction always follows an OP_Found with the same P1, P2 and P3 + ** values as this instruction and a non-zero P4 value. The P4 value to + ** this opcode is of type P4_INDEX and contains a pointer to the Index + ** object of for the index being searched. + ** + ** This opcode uses sqlite3VdbeFindIndexKey() to search around the current + ** cursor location for an index key that exactly matches all fields that + ** are not indexed expressions or references to VIRTUAL generated columns, + ** and either exactly match or are real numbers that are within 2 ULPs of + ** each other if the don't match. + ** + ** To put it another way, this opcode looks for nearby index entries that + ** are very close to the search key, but which might have small differences + ** in floating-point values that come via an expression. + ** + ** If no nearby alternative entry is found in cursor P1, then jump to P2. + ** But if a close match is found, fall through. + ** + ** This opcode is used by PRAGMA integrity_check to help distinguish + ** between truely corrupt indexes and expression indexes that are holding + ** floating-point values that are off by one or two ULPs. + */ + _140: + ; + pC31 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + libc.X__builtin___memset_chk(tls, bp+704, 0, uint64(40), ^t__predefined_size_t(0)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FnField = (*TIndex)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FnColumn + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC31)).FpKeyInfo + rc = _sqlite3VdbeFindIndexKey(tls, *(*uintptr)(unsafe.Pointer(pC31 + 48)), *(*uintptr)(unsafe.Pointer(pOp + 16)), bp+704, bp+696, int32(1)) + if rc != 0 || **(**int32)(__ccgo_up(bp + 696)) != 0 { + rc = SQLITE_OK + goto jump_to_p2 + } + (*TVdbeCursor)(unsafe.Pointer(pC31)).FnullRow = uint8(0) + goto _189 + /* Opcode: RowSetAdd P1 P2 * * * + ** Synopsis: rowset(P1)=r[P2] + ** + ** Insert the integer value held by register P2 into a RowSet object + ** held in register P1. + ** + ** An assertion fails if P2 is not an integer. + */ + _141: + ; /* in1, in2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + if _sqlite3VdbeMemSetRowSet(tls, pIn1) != 0 { + goto no_mem + } + } + _sqlite3RowSetInsert(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, *(*Ti64)(unsafe.Pointer(pIn2))) + goto _189 + /* Opcode: RowSetRead P1 P2 P3 * * + ** Synopsis: r[P3]=rowset(P1) + ** + ** Extract the smallest value from the RowSet object in P1 + ** and put that value into register P3. + ** Or, if RowSet object P1 is initially empty, leave P3 + ** unchanged and jump to instruction P2. + */ + _142: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 || _sqlite3RowSetNext(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, bp+744) == 0 { + /* The boolean index is empty */ + _sqlite3VdbeMemSetNull(tls, pIn1) + goto jump_to_p2_and_check_for_interrupt + } else { + /* A value was pulled from the index */ + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, **(**Ti64)(__ccgo_up(bp + 744))) + } + goto check_for_interrupt + /* Opcode: RowSetTest P1 P2 P3 P4 + ** Synopsis: if r[P3] in rowset(P1) goto P2 + ** + ** Register P3 is assumed to hold a 64-bit integer value. If register P1 + ** contains a RowSet object and that RowSet object contains + ** the value held in P3, jump to register P2. Otherwise, insert the + ** integer in P3 into the RowSet and continue on to the + ** next opcode. + ** + ** The RowSet object is optimized for the case where sets of integers + ** are inserted in distinct phases, which each set contains no duplicates. + ** Each set is identified by a unique P4 value. The first set + ** must have P4==0, the final set must have P4==-1, and for all other sets + ** must have P4>0. + ** + ** This allows optimizations: (a) when P4==0 there is no need to test + ** the RowSet object for P3, as it is guaranteed not to contain it, + ** (b) when P4==-1 there is no need to insert the value, as it will + ** never be tested for, and (c) when a value that is part of set X is + ** inserted, there is no need to search to see if the same value was + ** previously inserted as part of set X (only if it was previously + ** inserted as part of some other set). + */ + _143: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + iSet = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + /* If there is anything other than a rowset object in memory cell P1, + ** delete it now and initialize P1 with an empty rowset + */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + if _sqlite3VdbeMemSetRowSet(tls, pIn1) != 0 { + goto no_mem + } + } + if iSet != 0 { + exists = _sqlite3RowSetTest(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, iSet, *(*Ti64)(unsafe.Pointer(pIn3))) + if exists != 0 { + goto jump_to_p2 + } + } + if iSet >= 0 { + _sqlite3RowSetInsert(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, *(*Ti64)(unsafe.Pointer(pIn3))) + } + goto _189 + /* Opcode: Program P1 P2 P3 P4 P5 + ** + ** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). + ** + ** P1 contains the address of the memory cell that contains the first memory + ** cell in an array of values used as arguments to the sub-program. P2 + ** contains the address to jump to if the sub-program throws an IGNORE + ** exception using the RAISE() function. P2 might be zero, if there is + ** no possibility that an IGNORE exception will be raised. + ** Register P3 contains the address + ** of a memory cell in this (the parent) VM that is used to allocate the + ** memory required by the sub-vdbe at runtime. + ** + ** P4 is a pointer to the VM containing the trigger program. + ** + ** If P5 is non-zero, then recursive program invocation is enabled. + */ + _144: + ; /* Token identifying trigger */ + pProgram = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pRt = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + /* If the p5 flag is clear, then recursive invocation of triggers is + ** disabled for backwards compatibility (p5 is set if this sub-program + ** is really a trigger, not a foreign key action, and the flag set + ** and cleared by the "PRAGMA recursive_triggers" command is clear). + ** + ** It is recursive invocation of triggers, at the SQL level, that is + ** disabled. In some cases a single trigger may generate more than one + ** SubProgram (if the trigger may be executed with more than one different + ** ON CONFLICT algorithm). SubProgram structures associated with a + ** single trigger all have the same value for the SubProgram.token + ** variable. */ + if (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 { + t1 = (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken + pFrame2 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + for { + if !(pFrame2 != 0 && (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken != t1) { + break + } + goto _278 + _278: + ; + pFrame2 = (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpParent + } + if pFrame2 != 0 { + goto _189 + } + } + if (*TVdbe)(unsafe.Pointer(p)).FnFrame >= **(**int32)(__ccgo_up(db + 136 + 10*4)) { + rc = int32(SQLITE_ERROR) + _sqlite3VdbeError(tls, p, __ccgo_ts+6685, 0) + goto abort_due_to_error + } + /* Register pRt is used to store the memory required to save the state + ** of the current program, and the memory required at runtime to execute + ** the trigger program. If this trigger has been fired before, then pRt + ** is already allocated. Otherwise, it must be initialized. */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRt)).Fflags)&int32(MEM_Blob) == 0 { + /* SubProgram.nMem is set to the number of memory cells used by the + ** program stored in SubProgram.aOp. As well as these, one memory + ** cell is required for each cursor used by the program. Set local + ** variable nMem (and later, VdbeFrame.nChildMem) to this value. + */ + nMem = (*TSubProgram)(unsafe.Pointer(pProgram)).FnMem + (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr + if (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr == 0 { + nMem = nMem + 1 + } + nByte2 = libc.Int64FromUint64(uint64((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32(nMem)*uint64(56)+libc.Uint64FromInt32((*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr)*uint64(8)) + libc.Uint64FromInt64((int64(7)+int64((*TSubProgram)(unsafe.Pointer(pProgram)).FnOp))/int64(8))) + pFrame2 = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte2)) + if !(pFrame2 != 0) { + goto no_mem + } + _sqlite3VdbeMemRelease(tls, pRt) + (*TMem)(unsafe.Pointer(pRt)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Blob) | libc.Int32FromInt32(MEM_Dyn)) + (*TMem)(unsafe.Pointer(pRt)).Fz = pFrame2 + (*TMem)(unsafe.Pointer(pRt)).Fn = int32(nByte2) + (*TMem)(unsafe.Pointer(pRt)).FxDel = __ccgo_fp(_sqlite3VdbeFrameMemDel) + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Fv = p + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem = nMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr = (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaMem = (*TVdbe)(unsafe.Pointer(p)).FaMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnMem = (*TVdbe)(unsafe.Pointer(p)).FnMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FapCsr = (*TVdbe)(unsafe.Pointer(p)).FapCsr + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnCursor = (*TVdbe)(unsafe.Pointer(p)).FnCursor + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnOp = (*TVdbe)(unsafe.Pointer(p)).FnOp + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken = (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken + pEnd = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + uintptr((*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*56 + pMem1 = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + for { + if !(pMem1 != pEnd) { + break + } + (*TMem)(unsafe.Pointer(pMem1)).Fflags = uint16(MEM_Undefined) + (*TMem)(unsafe.Pointer(pMem1)).Fdb = db + goto _279 + _279: + ; + pMem1 += 56 + } + } else { + pFrame2 = (*TMem)(unsafe.Pointer(pRt)).Fz + } + (*TVdbe)(unsafe.Pointer(p)).FnFrame = (*TVdbe)(unsafe.Pointer(p)).FnFrame + 1 + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpParent = (*TVdbe)(unsafe.Pointer(p)).FpFrame + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FlastRowid = (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnDbChange = (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FnChange + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpAuxData = (*TVdbe)(unsafe.Pointer(p)).FpAuxData + (*TVdbe)(unsafe.Pointer(p)).FpAuxData = uintptr(0) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + (*TVdbe)(unsafe.Pointer(p)).FpFrame = pFrame2 + v191 = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + aMem = v191 + (*TVdbe)(unsafe.Pointer(p)).FaMem = v191 + (*TVdbe)(unsafe.Pointer(p)).FnMem = (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem + (*TVdbe)(unsafe.Pointer(p)).FnCursor = libc.Int32FromUint16(libc.Uint16FromInt32((*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr)) + (*TVdbe)(unsafe.Pointer(p)).FapCsr = aMem + uintptr((*TVdbe)(unsafe.Pointer(p)).FnMem)*56 + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce = (*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr)*8 + libc.X__builtin___memset_chk(tls, (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce, 0, libc.Uint64FromInt32(((*TSubProgram)(unsafe.Pointer(pProgram)).FnOp+int32(7))/int32(8)), ^t__predefined_size_t(0)) + v191 = (*TSubProgram)(unsafe.Pointer(pProgram)).FaOp + aOp = v191 + (*TVdbe)(unsafe.Pointer(p)).FaOp = v191 + (*TVdbe)(unsafe.Pointer(p)).FnOp = (*TSubProgram)(unsafe.Pointer(pProgram)).FnOp + pOp = aOp + uintptr(-libc.Int32FromInt32(1))*24 + goto check_for_interrupt + /* Opcode: Param P1 P2 * * * + ** + ** This opcode is only ever present in sub-programs called via the + ** OP_Program instruction. Copy a value currently stored in a memory + ** cell of the calling (parent) frame to cell P2 in the current frames + ** address space. This is used by trigger programs to access the new.* + ** and old.* values. + ** + ** The address of the cell in the parent frame is determined by adding + ** the value of the P1 argument to the value of the P1 argument to the + ** calling OP_Program instruction. + */ + _145: + ; + pOut = _out2Prerelease(tls, p, pOp) + pFrame3 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + pIn = (*TVdbeFrame)(unsafe.Pointer(pFrame3)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1+(**(**TOp)(__ccgo_up((*TVdbeFrame)(unsafe.Pointer(pFrame3)).FaOp + uintptr((*TVdbeFrame)(unsafe.Pointer(pFrame3)).Fpc)*24))).Fp1)*56 + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn, int32(MEM_Ephem)) + goto _189 + /* Opcode: FkCounter P1 P2 * * * + ** Synopsis: fkctr[P1]+=P2 + ** + ** Increment a "constraint counter" by P2 (P2 may be negative or positive). + ** If P1 is non-zero, the database constraint counter is incremented + ** (deferred foreign key constraints). Otherwise, if P1 is zero, the + ** statement counter is incremented (immediate foreign key constraints). + */ + _146: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + **(**Ti64)(__ccgo_up(db + 784)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0 { + **(**Ti64)(__ccgo_up(db + 792)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + **(**Ti64)(__ccgo_up(p + 80)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } + } + goto _189 + /* Opcode: FkIfZero P1 P2 * * * + ** Synopsis: if fkctr[P1]==0 goto P2 + ** + ** This opcode tests if a foreign key constraint-counter is currently zero. + ** If so, jump to instruction P2. Otherwise, fall through to the next + ** instruction. + ** + ** If P1 is non-zero, then the jump is taken if the database constraint-counter + ** is zero (the one that counts deferred constraint violations). If P1 is + ** zero, the jump is taken if the statement constraint-counter is zero + ** (immediate foreign key constraint violations). + */ + _147: + ; /* jump */ + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { + goto jump_to_p2 + } + } else { + if (*TVdbe)(unsafe.Pointer(p)).FnFkConstraint == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: MemMax P1 P2 * * * + ** Synopsis: r[P1]=max(r[P1],r[P2]) + ** + ** P1 is a register in the root frame of this VM (the root frame is + ** different from the current frame if this instruction is being executed + ** within a sub-program). Set the value of register P1 to the maximum of + ** its current value and the value in register P2. + ** + ** This instruction throws an error if the memory cell is not initially + ** an integer. + */ + _148: + ; + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + pFrame4 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + for { + if !((*TVdbeFrame)(unsafe.Pointer(pFrame4)).FpParent != 0) { + break + } + goto _282 + _282: + ; + pFrame4 = (*TVdbeFrame)(unsafe.Pointer(pFrame4)).FpParent + } + pIn1 = (*TVdbeFrame)(unsafe.Pointer(pFrame4)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + } else { + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + } + _sqlite3VdbeMemIntegerify(tls, pIn1) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemIntegerify(tls, pIn2) + if *(*Ti64)(unsafe.Pointer(pIn1)) < *(*Ti64)(unsafe.Pointer(pIn2)) { + *(*Ti64)(unsafe.Pointer(pIn1)) = *(*Ti64)(unsafe.Pointer(pIn2)) + } + goto _189 + /* Opcode: IfPos P1 P2 P3 * * + ** Synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 + ** + ** Register P1 must contain an integer. + ** If the value of register P1 is 1 or greater, subtract P3 from the + ** value in P1 and jump to P2. + ** + ** If the initial value of register P1 is less than 1, then the + ** value is unchanged and control passes through to the next instruction. + */ + _149: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) > 0 { + *(*Ti64)(unsafe.Pointer(pIn1)) -= int64((*TOp)(unsafe.Pointer(pOp)).Fp3) + goto jump_to_p2 + } + goto _189 + /* Opcode: OffsetLimit P1 P2 P3 * * + ** Synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) + ** + ** This opcode performs a commonly used computation associated with + ** LIMIT and OFFSET processing. r[P1] holds the limit counter. r[P3] + ** holds the offset counter. The opcode computes the combined value + ** of the LIMIT and OFFSET and stores that value in r[P2]. The r[P2] + ** value computed is the total number of rows that will need to be + ** visited in order to complete the query. + ** + ** If r[P3] is zero or negative, that means there is no OFFSET + ** and r[P2] is set to be the value of the LIMIT, r[P1]. + ** + ** if r[P1] is zero or negative, that means there is no LIMIT + ** and r[P2] is set to -1. + ** + ** Otherwise, r[P2] is set to the sum of r[P1] and r[P3]. + */ + _150: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + pOut = _out2Prerelease(tls, p, pOp) + **(**Ti64)(__ccgo_up(bp + 752)) = *(*Ti64)(unsafe.Pointer(pIn1)) + if v217 = **(**Ti64)(__ccgo_up(bp + 752)) <= 0; !v217 { + if *(*Ti64)(unsafe.Pointer(pIn3)) > 0 { + v206 = *(*Ti64)(unsafe.Pointer(pIn3)) + } else { + v206 = 0 + } + } + if v217 || _sqlite3AddInt64(tls, bp+752, v206) != 0 { + /* If the LIMIT is less than or equal to zero, loop forever. This + ** is documented. But also, if the LIMIT+OFFSET exceeds 2^63 then + ** also loop forever. This is undocumented. In fact, one could argue + ** that the loop should terminate. But assuming 1 billion iterations + ** per second (far exceeding the capabilities of any current hardware) + ** it would take nearly 300 years to actually reach the limit. So + ** looping forever is a reasonable approximation. */ + *(*Ti64)(unsafe.Pointer(pOut)) = int64(-int32(1)) + } else { + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 752)) + } + goto _189 + /* Opcode: IfNotZero P1 P2 * * * + ** Synopsis: if r[P1]!=0 then r[P1]--, goto P2 + ** + ** Register P1 must contain an integer. If the content of register P1 is + ** initially greater than zero, then decrement the value in register P1. + ** If it is non-zero (negative or positive) and then also jump to P2. + ** If register P1 is initially zero, leave it unchanged and fall through. + */ + _151: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) != 0 { + if *(*Ti64)(unsafe.Pointer(pIn1)) > 0 { + *(*Ti64)(unsafe.Pointer(pIn1)) = *(*Ti64)(unsafe.Pointer(pIn1)) - 1 + } + goto jump_to_p2 + } + goto _189 + /* Opcode: DecrJumpZero P1 P2 * * * + ** Synopsis: if (--r[P1])==0 goto P2 + ** + ** Register P1 must hold an integer. Decrement the value in P1 + ** and jump to P2 if the new value is exactly zero. + */ + _152: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) > int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= 0) { + break + } + *(*uintptr)(unsafe.Pointer(pCtx1 + 48 + uintptr(i4)*8)) = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2+i4)*56 + goto _285 + _285: + ; + i4 = i4 - 1 + } + } + (*TMem)(unsafe.Pointer(pMem2)).Fn = (*TMem)(unsafe.Pointer(pMem2)).Fn + 1 + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxInverse})))(tls, pCtx1, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+48) + } else { + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxSFunc})))(tls, pCtx1, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+48) + } /* IMP: R-24505-23230 */ + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError != 0 { + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError > 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut))) + rc = (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError + } + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag != 0 { + i4 = (**(**TOp)(__ccgo_up(pOp + uintptr(-libc.Int32FromInt32(1))*24))).Fp1 + if i4 != 0 { + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr(i4)*56, int64(1)) + } + (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag = uint8(0) + } + _sqlite3VdbeMemRelease(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut) + (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = uint16(MEM_Null) + (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError = 0 + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: AggFinal P1 P2 * P4 * + ** Synopsis: accum=r[P1] N=P2 + ** + ** P1 is the memory location that is the accumulator for an aggregate + ** or window function. Execute the finalizer function + ** for an aggregate and store the result in P1. + ** + ** P2 is the number of arguments that the step function takes and + ** P4 is a pointer to the FuncDef for this function. The P2 + ** argument is not used by this opcode. It is only there to disambiguate + ** functions that can take varying numbers of arguments. The + ** P4 argument is only needed for the case where + ** the step function was not previously called. + */ + /* Opcode: AggValue * P2 P3 P4 * + ** Synopsis: r[P3]=value N=P2 + ** + ** Invoke the xValue() function and store the result in register P3. + ** + ** P2 is the number of arguments that the step function takes and + ** P4 is a pointer to the FuncDef for this function. The P2 + ** argument is not used by this opcode. It is only there to disambiguate + ** functions that can take varying numbers of arguments. The + ** P4 argument is only needed for the case where + ** the step function was not previously called. + */ + _157: + ; + _156: + ; + pMem3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + rc = _sqlite3VdbeMemAggValue(tls, pMem3, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, *(*uintptr)(unsafe.Pointer(pOp + 16))) + pMem3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + } else { + rc = _sqlite3VdbeMemFinalize(tls, pMem3, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + if rc != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pMem3))) + goto abort_due_to_error + } + _sqlite3VdbeChangeEncoding(tls, pMem3, libc.Int32FromUint8(encoding)) + goto _189 + /* Opcode: Checkpoint P1 P2 P3 * * + ** + ** Checkpoint database P1. This is a no-op if P1 is not currently in + ** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL, + ** RESTART, or TRUNCATE. Write 1 or 0 into mem[P3] if the checkpoint returns + ** SQLITE_BUSY or not, respectively. Write the number of pages in the + ** WAL after the checkpoint into mem[P3+1] and the number of pages + ** in the WAL that have been checkpointed after the checkpoint + ** completes into mem[P3+2]. However on an error, mem[P3+1] and + ** mem[P3+2] are initialized to -1. + */ + _158: + ; /* Write results here */ + (**(**[3]int32)(__ccgo_up(bp + 760)))[0] = 0 + v190 = -libc.Int32FromInt32(1) + (**(**[3]int32)(__ccgo_up(bp + 760)))[int32(2)] = v190 + (**(**[3]int32)(__ccgo_up(bp + 760)))[int32(1)] = v190 + rc = _sqlite3Checkpoint(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, bp+760+1*4, bp+760+2*4) + if rc != 0 { + if rc != int32(SQLITE_BUSY) { + goto abort_due_to_error + } + rc = SQLITE_OK + (**(**[3]int32)(__ccgo_up(bp + 760)))[0] = int32(1) + } + i5 = 0 + pMem4 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + for { + if !(i5 < int32(3)) { + break + } + _sqlite3VdbeMemSetInt64(tls, pMem4, int64((**(**[3]int32)(__ccgo_up(bp + 760)))[i5])) + goto _287 + _287: + ; + i5 = i5 + 1 + pMem4 += 56 + } + goto _189 + /* Opcode: JournalMode P1 P2 P3 * * + ** + ** Change the journal mode of database P1 to P3. P3 must be one of the + ** PAGER_JOURNALMODE_XXX values. If changing between the various rollback + ** modes (delete, truncate, persist, off and memory), this is a simple + ** operation. No IO is required. + ** + ** If changing into or out of WAL mode the procedure is more complicated. + ** + ** Write a string containing the final journal-mode to register P2. + */ + _159: + ; /* Name of database file for pPager */ + pOut = _out2Prerelease(tls, p, pOp) + eNew = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pBt1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + pPager = _sqlite3BtreePager(tls, pBt1) + eOld = _sqlite3PagerGetJournalMode(tls, pPager) + if eNew == -int32(1) { + eNew = eOld + } + if !(_sqlite3PagerOkToChangeJournalMode(tls, pPager) != 0) { + eNew = eOld + } + zFilename = _sqlite3PagerFilename(tls, pPager, int32(1)) + /* Do not allow a transition to journal_mode=WAL for a database + ** in temporary storage or if the VFS does not support shared memory + */ + if eNew == int32(PAGER_JOURNALMODE_WAL) && (_sqlite3Strlen30(tls, zFilename) == 0 || !(_sqlite3PagerWalSupported(tls, pPager) != 0)) { + eNew = eOld + } + if eNew != eOld && (eOld == int32(PAGER_JOURNALMODE_WAL) || eNew == int32(PAGER_JOURNALMODE_WAL)) { + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1) { + rc = int32(SQLITE_ERROR) + if eNew == int32(PAGER_JOURNALMODE_WAL) { + v191 = __ccgo_ts + 6722 + } else { + v191 = __ccgo_ts + 6727 + } + _sqlite3VdbeError(tls, p, __ccgo_ts+6734, libc.VaList(bp+984, v191)) + goto abort_due_to_error + } else { + if eOld == int32(PAGER_JOURNALMODE_WAL) { + /* If leaving WAL mode, close the log file. If successful, the call + ** to PagerCloseWal() checkpoints and deletes the write-ahead-log + ** file. An EXCLUSIVE lock may still be held on the database file + ** after a successful return. + */ + rc = _sqlite3PagerCloseWal(tls, pPager, db) + if rc == SQLITE_OK { + _sqlite3PagerSetJournalMode(tls, pPager, eNew) + } + } else { + if eOld == int32(PAGER_JOURNALMODE_MEMORY) { + /* Cannot transition directly from MEMORY to WAL. Use mode OFF + ** as an intermediate */ + _sqlite3PagerSetJournalMode(tls, pPager, int32(PAGER_JOURNALMODE_OFF)) + } + } + /* Open a transaction on the database file. Regardless of the journal + ** mode, this transaction always uses a rollback journal. + */ + if rc == SQLITE_OK { + if eNew == int32(PAGER_JOURNALMODE_WAL) { + v190 = int32(2) + } else { + v190 = int32(1) + } + rc = _sqlite3BtreeSetVersion(tls, pBt1, v190) + } + } + } + if rc != 0 { + eNew = eOld + } + eNew = _sqlite3PagerSetJournalMode(tls, pPager, eNew) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fz = _sqlite3JournalModename(tls, eNew) + (*TMem)(unsafe.Pointer(pOut)).Fn = _sqlite3Strlen30(tls, (*TMem)(unsafe.Pointer(pOut)).Fz) + (*TMem)(unsafe.Pointer(pOut)).Fenc = uint8(SQLITE_UTF8) + _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8(encoding)) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Vacuum P1 P2 * * * + ** + ** Vacuum the entire database P1. P1 is 0 for "main", and 2 or more + ** for an attached database. The "temp" database may not be vacuumed. + ** + ** If P2 is not zero, then it is a register holding a string which is + ** the file into which the result of vacuum should be written. When + ** P2 is zero, the vacuum overwrites the original database. + */ + _160: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 { + v191 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + } else { + v191 = uintptr(0) + } + rc = _sqlite3RunVacuum(tls, p+168, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, v191) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: IncrVacuum P1 P2 * * * + ** + ** Perform a single step of the incremental vacuum procedure on + ** the P1 database. If the vacuum has finished, jump to instruction + ** P2. Otherwise, fall through to the next instruction. + */ + _161: + ; + pBt2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + rc = _sqlite3BtreeIncrVacuum(tls, pBt2) + if rc != 0 { + if rc != int32(SQLITE_DONE) { + goto abort_due_to_error + } + rc = SQLITE_OK + goto jump_to_p2 + } + goto _189 + /* Opcode: Expire P1 P2 * * * + ** + ** Cause precompiled statements to expire. When an expired statement + ** is executed using sqlite3_step() it will either automatically + ** reprepare itself (if it was originally created using sqlite3_prepare_v2()) + ** or it will fail with SQLITE_SCHEMA. + ** + ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, + ** then only the currently executing statement is expired. + ** + ** If P2 is 0, then SQL statements are expired immediately. If P2 is 1, + ** then running SQL statements are allowed to continue to run to completion. + ** The P2==1 case occurs when a CREATE INDEX or similar schema change happens + ** that might help the statement run faster but which does not affect the + ** correctness of operation. + */ + _162: + ; + if !((*TOp)(unsafe.Pointer(pOp)).Fp1 != 0) { + _sqlite3ExpirePreparedStatements(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2+libc.Int32FromInt32(1)), 0, 0x3) + } + goto _189 + /* Opcode: CursorLock P1 * * * * + ** + ** Lock the btree to which cursor P1 is pointing so that the btree cannot be + ** written by an other cursor. + */ + _163: + ; + pC32 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + _sqlite3BtreeCursorPin(tls, *(*uintptr)(unsafe.Pointer(pC32 + 48))) + goto _189 + /* Opcode: CursorUnlock P1 * * * * + ** + ** Unlock the btree to which cursor P1 is pointing so that it can be + ** written by other cursors. + */ + _164: + ; + pC33 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + _sqlite3BtreeCursorUnpin(tls, *(*uintptr)(unsafe.Pointer(pC33 + 48))) + goto _189 + /* Opcode: TableLock P1 P2 P3 P4 * + ** Synopsis: iDb=P1 root=P2 write=P3 + ** + ** Obtain a lock on a particular table. This instruction is only used when + ** the shared-cache feature is enabled. + ** + ** P1 is the index of the database in sqlite3.aDb[] of the database + ** on which the lock is acquired. A readlock is obtained if P3==0 or + ** a write lock if P3==1. + ** + ** P2 contains the root-page of the table to lock. + ** + ** P4 contains a pointer to the name of the table being locked. This is only + ** used to generate an error message if the lock cannot be obtained. + */ + _165: + ; + isWriteLock = libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + if isWriteLock != 0 || uint64(0) == (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00004))< 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pDest2))) + rc = (**(**Tsqlite3_context)(__ccgo_up(bp + 848))).FisError + } + _sqlite3VdbeChangeEncoding(tls, pDest2, libc.Int32FromUint8(encoding)) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: VNext P1 P2 * * * + ** + ** Advance virtual table P1 to the next row in its result set and + ** jump to instruction P2. Or, if the virtual table has reached + ** the end of its result set, then fall through to the next instruction. + */ + _174: + ; + pCur6 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TVdbeCursor)(unsafe.Pointer(pCur6)).FnullRow != 0 { + goto _189 + } + pVtab5 = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCur6 + 48)))).FpVtab + pModule5 = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab5)).FpModule + /* Invoke the xNext() method of the module. There is no way for the + ** underlying implementation to return an error if one occurs during + ** xNext(). Instead, if an error occurs, true is returned (indicating that + ** data is available) and the error code returned when xColumn or + ** some other method is next invoked on the save virtual table cursor. + */ + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule5)).FxNext})))(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 48))) + _sqlite3VtabImportErrmsg(tls, p, pVtab5) + if rc != 0 { + goto abort_due_to_error + } + res14 = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule5)).FxEof})))(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 48))) + if !(res14 != 0) { + /* If there is data, jump to P2 */ + goto jump_to_p2_and_check_for_interrupt + } + goto check_for_interrupt + /* Opcode: VRename P1 * * P4 * + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** This opcode invokes the corresponding xRename method. The value + ** in register P1 is passed as the zName argument to the xRename method. + */ + _175: + ; + isLegacy = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_LegacyAlter)) + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_LegacyAlter) + pVtab6 = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab + pName = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + rc = _sqlite3VdbeChangeEncoding(tls, pName, int32(SQLITE_UTF8)) + if rc != 0 { + goto abort_due_to_error + } + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVtab6)).FpModule)).FxRename})))(tls, pVtab6, (*TMem)(unsafe.Pointer(pName)).Fz) + if isLegacy == 0 { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_LegacyAlter) + } + _sqlite3VtabImportErrmsg(tls, p, pVtab6) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: VUpdate P1 P2 P3 P4 P5 + ** Synopsis: data=r[P3@P2] + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** This opcode invokes the corresponding xUpdate method. P2 values + ** are contiguous memory cells starting at P3 to pass to the xUpdate + ** invocation. The value in register (P3+P2-1) corresponds to the + ** p2th element of the argv array passed to xUpdate. + ** + ** The xUpdate method will do a DELETE or an INSERT or both. + ** The argv[0] element (which corresponds to memory cell P3) + ** is the rowid of a row to delete. If argv[0] is NULL then no + ** deletion occurs. The argv[1] element is the rowid of the new + ** row. This can be NULL to have the virtual table select the new + ** rowid for itself. The subsequent elements in the array are + ** the values of columns in the new row. + ** + ** If P2==1 then no insert is performed. argv[0] is the rowid of + ** a row to delete. + ** + ** P1 is a boolean flag. If it is set to true and the xUpdate call + ** is successful, then the value returned by sqlite3_last_insert_rowid() + ** is set to the value of the rowid for the row just inserted. + ** + ** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to + ** apply in the case of a constraint failure on an insert or update. + */ + _176: + ; + **(**Tsqlite_int64)(__ccgo_up(bp + 968)) = 0 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto no_mem + } + pVtab7 = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab + if pVtab7 == uintptr(0) || (*Tsqlite3_vtab)(unsafe.Pointer(pVtab7)).FpModule == uintptr(0) { + rc = int32(SQLITE_LOCKED) + goto abort_due_to_error + } + pModule6 = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab7)).FpModule + nArg1 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + if (*Tsqlite3_module)(unsafe.Pointer(pModule6)).FxUpdate != 0 { + vtabOnConflict = (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict + apArg1 = (*TVdbe)(unsafe.Pointer(p)).FapArg + pX1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + i7 = 0 + for { + if !(i7 < nArg1) { + break + } + **(**uintptr)(__ccgo_up(apArg1 + uintptr(i7)*8)) = pX1 + pX1 += 56 + goto _292 + _292: + ; + i7 = i7 + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict = uint8((*TOp)(unsafe.Pointer(pOp)).Fp5) + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule6)).FxUpdate})))(tls, pVtab7, nArg1, apArg1, bp+968) + (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict = vtabOnConflict + _sqlite3VtabImportErrmsg(tls, p, pVtab7) + if rc == SQLITE_OK && (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = **(**Tsqlite_int64)(__ccgo_up(bp + 968)) + } + if rc&int32(0xff) == int32(SQLITE_CONSTRAINT) && (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FbConstraint != 0 { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == int32(OE_Ignore) { + rc = SQLITE_OK + } else { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == int32(OE_Replace) { + v190 = int32(OE_Abort) + } else { + v190 = libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) + } + (*TVdbe)(unsafe.Pointer(p)).FerrorAction = libc.Uint8FromInt32(v190) + } + } else { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + } + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: Pagecount P1 P2 * * * + ** + ** Write the current number of pages in database P1 to memory cell P2. + */ + _177: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(_sqlite3BtreeLastPage(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt)) + goto _189 + /* Opcode: MaxPgcnt P1 P2 P3 * * + ** + ** Try to set the maximum page count for database P1 to the value in P3. + ** Do not let the maximum page count fall below the current page count and + ** do not change the maximum page count value if P3==0. + ** + ** Store the maximum page count after the change in register P2. + */ + _178: + ; + pOut = _out2Prerelease(tls, p, pOp) + pBt3 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + newMax = uint32(0) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + newMax = _sqlite3BtreeLastPage(tls, pBt3) + if newMax < libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) { + newMax = libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(_sqlite3BtreeMaxPageCount(tls, pBt3, newMax)) + goto _189 + /* Opcode: Function P1 P2 P3 P4 * + ** Synopsis: r[P3]=func(r[P2@NP]) + ** + ** Invoke a user function (P4 is a pointer to an sqlite3_context object that + ** contains a pointer to the function to be run) with arguments taken + ** from register P2 and successors. The number of arguments is in + ** the sqlite3_context object that P4 points to. + ** The result of the function is stored + ** in register P3. Register P3 must not be one of the function inputs. + ** + ** P1 is a 32-bit bitmask indicating whether or not each argument to the + ** function was determined to be constant at compile time. If the first + ** argument was constant then bit 0 of P1 is set. This is used to determine + ** whether meta data associated with a user function argument using the + ** sqlite3_set_auxdata() API may be safely retained until the next + ** invocation of this opcode. + ** + ** See also: AggStep, AggFinal, PureFunc + */ + /* Opcode: PureFunc P1 P2 P3 P4 * + ** Synopsis: r[P3]=func(r[P2@NP]) + ** + ** Invoke a user function (P4 is a pointer to an sqlite3_context object that + ** contains a pointer to the function to be run) with arguments taken + ** from register P2 and successors. The number of arguments is in + ** the sqlite3_context object that P4 points to. + ** The result of the function is stored + ** in register P3. Register P3 must not be one of the function inputs. + ** + ** P1 is a 32-bit bitmask indicating whether or not each argument to the + ** function was determined to be constant at compile time. If the first + ** argument was constant then bit 0 of P1 is set. This is used to determine + ** whether meta data associated with a user function argument using the + ** sqlite3_set_auxdata() API may be safely retained until the next + ** invocation of this opcode. + ** + ** This opcode works exactly like OP_Function. The only difference is in + ** its name. This opcode is used in places where the function must be + ** purely non-deterministic. Some built-in date/time functions can be + ** either deterministic of non-deterministic, depending on their arguments. + ** When those function are used in a non-deterministic way, they will check + ** to see if they were called using OP_PureFunc instead of OP_Function, and + ** if they were, they throw an error. + ** + ** See also: AggStep, AggFinal, Function + */ + _180: + ; /* group */ + _179: + ; + pCtx2 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + /* If this function is inside of a trigger, the register array in aMem[] + ** might change from one evaluation to the next. The next block of code + ** checks to see if the register array has changed, and if so it + ** reinitializes the relevant parts of the sqlite3_context object */ + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpOut != pOut { + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpVdbe = p + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpOut = pOut + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fenc = encoding + i8 = libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fargc) - int32(1) + for { + if !(i8 >= 0) { + break + } + *(*uintptr)(unsafe.Pointer(pCtx2 + 48 + uintptr(i8)*8)) = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2+i8)*56 + goto _294 + _294: + ; + i8 = i8 - 1 + } + } + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Null)) + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpFunc)).FxSFunc})))(tls, pCtx2, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fargc), pCtx2+48) /* IMP: R-24505-23230 */ + /* If the function returned an error, throw an exception */ + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError != 0 { + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError > 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pOut))) + rc = (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError + } + _sqlite3VdbeDeleteAuxData(tls, db, p+296, (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FiOp, (*TOp)(unsafe.Pointer(pOp)).Fp1) + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError = 0 + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: ClrSubtype P1 * * * * + ** Synopsis: r[P1].subtype = 0 + ** + ** Clear the subtype from register P1. + */ + _181: + ; /* in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + goto _189 + /* Opcode: GetSubtype P1 P2 * * * + ** Synopsis: r[P2] = r[P1].subtype + ** + ** Extract the subtype value from register P1 and write that subtype + ** into register P2. If P1 has no subtype, then P1 gets a NULL. + */ + _182: + ; /* in1 out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Subtype) != 0 { + _sqlite3VdbeMemSetInt64(tls, pOut, libc.Int64FromUint8((*TMem)(unsafe.Pointer(pIn1)).FeSubtype)) + } else { + _sqlite3VdbeMemSetNull(tls, pOut) + } + goto _189 + /* Opcode: SetSubtype P1 P2 * * * + ** Synopsis: r[P2].subtype = r[P1] + ** + ** Set the subtype value of register P2 to the integer from register P1. + ** If P1 is NULL, clear the subtype from p2. + */ + _183: + ; /* in1 out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) != 0 { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + } else { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Subtype)) + (*TMem)(unsafe.Pointer(pOut)).FeSubtype = libc.Uint8FromInt64(*(*Ti64)(unsafe.Pointer(pIn1)) & libc.Int64FromInt32(0xff)) + } + goto _189 + /* Opcode: FilterAdd P1 * P3 P4 * + ** Synopsis: filter(P1) += key(P3@P4) + ** + ** Compute a hash on the P4 registers starting with r[P3] and + ** add that hash to the bloom filter contained in r[P1]. + */ + _184: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + h = _filterHash(tls, aMem, pOp) + h = h % libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn*libc.Int32FromInt32(8)) + v191 = (*TMem)(unsafe.Pointer(pIn1)).Fz + uintptr(h/uint64(8)) + *(*int8)(unsafe.Pointer(v191)) = int8(int32(*(*int8)(unsafe.Pointer(v191))) | libc.Int32FromInt32(1)<<(h&libc.Uint64FromInt32(7))) + goto _189 + /* Opcode: Filter P1 P2 P3 P4 * + ** Synopsis: if key(P3@P4) not in filter(P1) goto P2 + ** + ** Compute a hash on the key contained in the P4 registers starting + ** with r[P3]. Check to see if that hash is found in the + ** bloom filter hosted by register P1. If it is not present then + ** maybe jump to P2. Otherwise fall through. + ** + ** False negatives are harmless. It is always safe to fall through, + ** even if the value is in the bloom filter. A false negative causes + ** more CPU cycles to be used, but it should still yield the correct + ** answer. However, an incorrect answer may well arise from a + ** false positive - if the jump is taken when it should fall through. + */ + _185: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + h1 = _filterHash(tls, aMem, pOp) + h1 = h1 % libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn*libc.Int32FromInt32(8)) + if int32(**(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pIn1)).Fz + uintptr(h1/uint64(8)))))&(int32(1)<<(h1&uint64(7))) == 0 { + **(**Tu32)(__ccgo_up(p + 212 + 8*4)) = **(**Tu32)(__ccgo_up(p + 212 + 8*4)) + 1 + goto jump_to_p2 + } else { + **(**Tu32)(__ccgo_up(p + 212 + 7*4)) = **(**Tu32)(__ccgo_up(p + 212 + 7*4)) + 1 + } + goto _189 + /* Opcode: Trace P1 P2 * P4 * + ** + ** Write P4 on the statement trace output if statement tracing is + ** enabled. + ** + ** Operand P1 must be 0x7fffffff and P2 must positive. + */ + /* Opcode: Init P1 P2 P3 P4 * + ** Synopsis: Start at P2 + ** + ** Programs contain a single instance of this opcode as the very first + ** opcode. + ** + ** If tracing is enabled (by the sqlite3_trace()) interface, then + ** the UTF-8 string contained in P4 is emitted on the trace callback. + ** Or if P4 is blank, use the string returned by sqlite3_sql(). + ** + ** If P2 is not zero, jump to instruction P2. + ** + ** Increment the value of P1 so that OP_Once opcodes will jump the + ** first time they are evaluated for this run. + ** + ** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT + ** error is encountered. + */ + _187: + ; + _186: + ; + /* If the P4 argument is not NULL, then it must be an SQL comment string. + ** The "--" string is broken up to prevent false-positives with srcck1.c. + ** + ** This assert() provides evidence for: + ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that + ** would have been returned by the legacy sqlite3_trace() interface by + ** using the X argument when X begins with "--" and invoking + ** sqlite3_expanded_sql(P) otherwise. + */ + /* OP_Init is always instruction 0 */ + if v217 = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&(libc.Int32FromInt32(SQLITE_TRACE_STMT)|libc.Int32FromInt32(SQLITE_TRACE_LEGACY)) != 0 && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat) != int32(254); v217 { + if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 { + v194 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + } else { + v194 = (*TVdbe)(unsafe.Pointer(p)).FzSql + } + v191 = v194 + zTrace = v191 + } + if v217 && v191 != uintptr(0) { + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_LEGACY) != 0 { + z2 = _sqlite3VdbeExpandSql(tls, p, zTrace) + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).Ftrace.FxLegacy})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, z2) + Xsqlite3_free(tls, z2) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > int32(1) { + z3 = _sqlite3MPrintf(tls, db, __ccgo_ts+6825, libc.VaList(bp+984, zTrace)) + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_STMT), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3) + _sqlite3DbFree(tls, db, z3) + } else { + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_STMT), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace) + } + } + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 >= _sqlite3Config.FiOnceResetThreshold { + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Trace) { + goto _189 + } + i9 = int32(1) + for { + if !(i9 < (*TVdbe)(unsafe.Pointer(p)).FnOp) { + break + } + if libc.Int32FromUint8((**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24))).Fopcode) == int32(OP_Once) { + (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24))).Fp1 = 0 + } + goto _302 + _302: + ; + i9 = i9 + 1 + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = 0 + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + 1 + **(**Tu32)(__ccgo_up(p + 212 + 6*4)) = **(**Tu32)(__ccgo_up(p + 212 + 6*4)) + 1 + goto jump_to_p2 + /* Opcode: Noop * * * * * + ** + ** Do nothing. Continue downward to the next opcode. + */ + /* Opcode: Explain P1 P2 P3 P4 * + ** + ** This is the same as OP_Noop during normal query execution. The + ** purpose of this opcode is to hold information about the query + ** plan for the purpose of EXPLAIN QUERY PLAN output. + ** + ** The P4 value is human-readable text that describes the query plan + ** element. Something like "SCAN t1" or "SEARCH t2 USING INDEX t2x1". + ** + ** The P1 value is the ID of the current element and P2 is the parent + ** element for the case of nested query plan elements. If P2 is zero + ** then this element is a top-level element. + ** + ** For loop elements, P3 is the estimated code of each invocation of this + ** element. + ** + ** As with all opcodes, the meanings of the parameters for OP_Explain + ** are subject to change from one release to the next. Applications + ** should not attempt to interpret or use any of the information + ** contained in the OP_Explain opcode. The information provided by this + ** opcode is intended for testing and debugging use only. + */ + _188: + ; /* This is really OP_Noop, OP_Explain */ + goto _189 + /***************************************************************************** + ** The cases of the switch statement above this line should all be indented + ** by 6 spaces. But the left-most 6 spaces have been removed to improve the + ** readability. From this point on down, the normal indentation rules are + ** restored. + *****************************************************************************/ + _189: + ; + /* The following code adds nothing to the actual functionality + ** of the program. It is only here for testing and debugging. + ** On the other hand, it does burn CPU cycles every time through + ** the evaluator loop. So we can leave it out when NDEBUG is defined. + */ + goto _1 + _1: + ; + pOp += 24 + } /* The end of the for(;;) loop the loops through opcodes */ + /* If we reach this point, it means that execution is finished with + ** an error of some kind. + */ + goto abort_due_to_error +abort_due_to_error: + ; + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } else { + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(33)< 0 { + _sqlite3ResetOneSchema(tls, db, libc.Int32FromUint8(resetSchemaOnFault)-int32(1)) + } + /* This is the only way out of this procedure. We have to + ** release the mutexes on btrees that were acquired at the + ** top. */ + goto vdbe_return +vdbe_return: + ; + for nVmStep >= nProgressLimit && (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0) { + nProgressLimit = nProgressLimit + uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)<aVar[]. Then render +// ** the value as a literal in place of the host parameter name. +// */ +func _sqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) (r uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var db, pVar, zStart, v1 uintptr + var enc Tu8 + var i, nOut, nOut1, nextIndex, v2 int32 + var n Ti64 + var _ /* idx at bp+0 */ int32 + var _ /* nToken at bp+8 */ Ti64 + var _ /* out at bp+16 */ TStrAccum + var _ /* utf8 at bp+48 */ TMem + _, _, _, _, _, _, _, _, _, _, _ = db, enc, i, n, nOut, nOut1, nextIndex, pVar, zStart, v1, v2 /* The database connection */ + **(**int32)(__ccgo_up(bp)) = 0 /* Index of a host parameter */ + nextIndex = int32(1) /* Used to convert UTF16 into UTF8 for display */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + _sqlite3StrAccumInit(tls, bp+16, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up(db + 136))) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > int32(1) { + for **(**int8)(__ccgo_up(zRawSql)) != 0 { + zStart = zRawSql + for { + v1 = zRawSql + zRawSql = zRawSql + 1 + if !(int32(**(**int8)(__ccgo_up(v1))) != int32('\n') && **(**int8)(__ccgo_up(zRawSql)) != 0) { + break + } + } + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+6057, int32(3)) + Xsqlite3_str_append(tls, bp+16, zStart, int32(int64(zRawSql)-int64(zStart))) + } + } else { + if int32((*TVdbe)(unsafe.Pointer(p)).FnVar) == 0 { + Xsqlite3_str_append(tls, bp+16, zRawSql, _sqlite3Strlen30(tls, zRawSql)) + } else { + for **(**int8)(__ccgo_up(zRawSql)) != 0 { + n = _findNextHostParameter(tls, zRawSql, bp+8) + Xsqlite3_str_append(tls, bp+16, zRawSql, int32(n)) + zRawSql = zRawSql + uintptr(n) + if **(**Ti64)(__ccgo_up(bp + 8)) == 0 { + break + } + if int32(**(**int8)(__ccgo_up(zRawSql))) == int32('?') { + if **(**Ti64)(__ccgo_up(bp + 8)) > int64(1) { + _sqlite3GetInt32(tls, zRawSql+1, bp) + } else { + **(**int32)(__ccgo_up(bp)) = nextIndex + } + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3VdbeParameterIndex(tls, p, zRawSql, int32(**(**Ti64)(__ccgo_up(bp + 8)))) + } + zRawSql = zRawSql + uintptr(**(**Ti64)(__ccgo_up(bp + 8))) + if **(**int32)(__ccgo_up(bp))+int32(1) > nextIndex { + v2 = **(**int32)(__ccgo_up(bp)) + int32(1) + } else { + v2 = nextIndex + } + nextIndex = v2 + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Null) != 0 { + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+1703, int32(4)) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+1463, libc.VaList(bp+112, *(*Ti64)(unsafe.Pointer(pVar)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Real) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+6061, libc.VaList(bp+112, *(*float64)(unsafe.Pointer(pVar)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Str) != 0 { /* Number of bytes of the string text to include in output */ + enc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) { + libc.X__builtin___memset_chk(tls, bp+48, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TMem)(__ccgo_up(bp + 48))).Fdb = db + _sqlite3VdbeMemSetStr(tls, bp+48, (*TMem)(unsafe.Pointer(pVar)).Fz, int64((*TMem)(unsafe.Pointer(pVar)).Fn), enc, libc.UintptrFromInt32(0)) + if int32(SQLITE_NOMEM) == _sqlite3VdbeChangeEncoding(tls, bp+48, int32(SQLITE_UTF8)) { + (**(**TStrAccum)(__ccgo_up(bp + 16))).FaccError = uint8(SQLITE_NOMEM) + (**(**TStrAccum)(__ccgo_up(bp + 16))).FnAlloc = uint32(0) + } + pVar = bp + 48 + } + nOut = (*TMem)(unsafe.Pointer(pVar)).Fn + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+6068, libc.VaList(bp+112, nOut, (*TMem)(unsafe.Pointer(pVar)).Fz)) + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) { + _sqlite3VdbeMemRelease(tls, bp+48) + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Zero) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+6075, libc.VaList(bp+112, *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pVar)).Fu)))) + } else { /* Number of bytes of the blob to include in output */ + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+6088, int32(2)) + nOut1 = (*TMem)(unsafe.Pointer(pVar)).Fn + i = 0 + for { + if !(i < nOut1) { + break + } + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+6091, libc.VaList(bp+112, int32(**(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pVar)).Fz + uintptr(i))))&int32(0xff))) + goto _3 + _3: + ; + i = i + 1 + } + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+6096, int32(1)) + } + } + } + } + } + } + } + } + if (**(**TStrAccum)(__ccgo_up(bp + 16))).FaccError != 0 { + Xsqlite3_str_reset(tls, bp+16) + } + return _sqlite3StrAccumFinish(tls, bp+16) +} + +/************** End of vdbetrace.c *******************************************/ +/************** Begin file vdbe.c ********************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** The code in this file implements the function that runs the +** bytecode of a prepared statement. +** +** Various scripts scan this source file in order to generate HTML +** documentation, headers files, or other derived files. The formatting +** of the code in this file is, therefore, important. See other comments +** in this file for details. If in doubt, do not deviate from existing +** commenting and indentation practices when changing or adding code. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +/* +** High-resolution hardware timer used for debugging and testing only. + */ + +/* +** Invoke this macro on memory cells just prior to changing the +** value of the cell. This macro verifies that shallow copies are +** not misused. A shallow copy of a string or blob just copies a +** pointer to the string or blob, not the content. If the original +** is changed while the copy is still in use, the string or blob might +** be changed out from under the copy. This macro verifies that nothing +** like that ever happens. + */ + +/* +** The following global variable is incremented every time a cursor +** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test +** procedures use this information to make sure that indices are +** working correctly. This variable has no function other than to +** help verify the correct operation of the library. + */ + +/* +** When this global variable is positive, it gets decremented once before +** each instruction in the VDBE. When it reaches zero, the u1.isInterrupted +** field of the sqlite3 structure is set in order to simulate an interrupt. +** +** This facility is used for testing purposes only. It does not function +** in an ordinary build. + */ + +/* +** The next global variable is incremented each type the OP_Sort opcode +** is executed. The test procedures use this information to make sure that +** sorting is occurring or not occurring at appropriate times. This variable +** has no function other than to help verify the correct operation of the +** library. + */ + +/* +** The next global variable records the size of the largest MEM_Blob +** or MEM_Str that has been used by a VDBE opcode. The test procedures +** use this information to make sure that the zero-blob functionality +** is working correctly. This variable has no function other than to +** help verify the correct operation of the library. + */ + +/* +** This macro evaluates to true if either the update hook or the preupdate +** hook are enabled for database connect DB. + */ + +/* +** The next global variable is incremented each time the OP_Found opcode +** is executed. This is used to test whether or not the foreign key +** operation implemented using OP_FkIsZero is working. This variable +** has no function other than to help verify the correct operation of the +** library. + */ + +/* +** Test a register to see if it exceeds the current maximum blob size. +** If it does, record the new maximum blob size. + */ + +/* +** Invoke the VDBE coverage callback, if that callback is defined. This +** feature is used for test suite validation only and does not appear an +** production builds. +** +** M is the type of branch. I is the direction taken for this instance of +** the branch. +** +** M: 2 - two-way branch (I=0: fall-thru 1: jump ) +** 3 - two-way + NULL (I=0: fall-thru 1: jump 2: NULL ) +** 4 - OP_Jump (I=0: jump p1 1: jump p2 2: jump p3) +** +** In other words, if M is 2, then I is either 0 (for fall-through) or +** 1 (for when the branch is taken). If M is 3, the I is 0 for an +** ordinary fall-through, I is 1 if the branch was taken, and I is 2 +** if the result of comparison is NULL. For M=3, I=2 the jump may or +** may not be taken, depending on the SQLITE_JUMPIFNULL flags in p5. +** When M is 4, that means that an OP_Jump is being run. I is 0, 1, or 2 +** depending on if the operands are less than, equal, or greater than. +** +** iSrcLine is the source code line (from the __LINE__ macro) that +** generated the VDBE instruction combined with flag bits. The source +** code line number is in the lower 24 bits of iSrcLine and the upper +** 8 bytes are flags. The lower three bits of the flags indicate +** values for I that should never occur. For example, if the branch is +** always taken, the flags should be 0x05 since the fall-through and +** alternate branch are never taken. If a branch is never taken then +** flags should be 0x06 since only the fall-through approach is allowed. +** +** Bit 0x08 of the flags indicates an OP_Jump opcode that is only +** interested in equal or not-equal. In other words, I==0 and I==2 +** should be treated as equivalent +** +** Since only a line number is retained, not the filename, this macro +** only works for amalgamation builds. But that is ok, since these macros +** should be no-ops except for special builds used to measure test coverage. + */ + +/* +** An ephemeral string value (signified by the MEM_Ephem flag) contains +** a pointer to a dynamically allocated string where some other entity +** is responsible for deallocating that string. Because the register +** does not control the string, it might be deleted without the register +** knowing it. +** +** This routine converts an ephemeral string into a dynamically allocated +** string that the register itself controls. In other words, it +** converts an MEM_Ephem string into a string with P.z==P.zMalloc. + */ + +/* Return true if the cursor was opened using the OP_OpenSorter opcode. */ + +// C documentation +// +// /* +// ** Send a "statement aborts" message to the error log. +// */ +func _sqlite3VdbeLogAbort(tls *libc.TLS, p uintptr, rc int32, pOp uintptr, aOp uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var pc int32 + var zPrefix, zSql uintptr + var _ /* zXtra at bp+0 */ [100]int8 + _, _, _ = pc, zPrefix, zSql + zSql = (*TVdbe)(unsafe.Pointer(p)).FzSql /* Original SQL text */ + zPrefix = __ccgo_ts + 1702 /* Buffer space to store zPrefix */ + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + if *(*uintptr)(unsafe.Pointer(aOp + 16)) != uintptr(0) { + Xsqlite3_snprintf(tls, int32(100), bp, __ccgo_ts+6098, libc.VaList(bp+112, *(*uintptr)(unsafe.Pointer(aOp + 16))+uintptr(3))) + zPrefix = bp + } else { + zPrefix = __ccgo_ts + 6108 + } + } + pc = int32((int64(pOp) - int64(aOp)) / 24) + Xsqlite3_log(tls, rc, __ccgo_ts+6131, libc.VaList(bp+112, pc, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, zPrefix, zSql)) +} + +// C documentation +// +// /* +// ** Prepare a virtual machine for execution for the first time after +// ** creating the virtual machine. This involves things such +// ** as allocating registers and initializing the program counter. +// ** After the VDBE has be prepped, it can be executed by one or more +// ** calls to sqlite3VdbeExec(). +// ** +// ** This function may be called exactly once on each virtual machine. +// ** After this routine is called the VM has been "packaged" and is ready +// ** to run. After this routine is called, further calls to +// ** sqlite3VdbeAddOp() functions are prohibited. This routine disconnects +// ** the Vdbe from the Parse object that helped generate it so that the +// ** the Vdbe becomes an independent entity and the Parse object can be +// ** destroyed. +// ** +// ** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back +// ** to its initial state after it has been run. +// */ +func _sqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, v1 uintptr + var n, nCursor, nMem, nVar int32 + var _ /* nArg at bp+0 */ int32 + var _ /* x at bp+8 */ TReusableSpace + _, _, _, _, _, _ = db, n, nCursor, nMem, nVar, v1 /* Reusable bulk memory */ + (*TVdbe)(unsafe.Pointer(p)).FpVList = (*TParse)(unsafe.Pointer(pParse)).FpVList + (*TParse)(unsafe.Pointer(pParse)).FpVList = uintptr(0) + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + nVar = int32((*TParse)(unsafe.Pointer(pParse)).FnVar) + nMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + nCursor = (*TParse)(unsafe.Pointer(pParse)).FnTab + **(**int32)(__ccgo_up(bp)) = (*TParse)(unsafe.Pointer(pParse)).FnMaxArg + /* Each cursor uses a memory cell. The first cursor (cursor 0) can + ** use aMem[0] which is not otherwise used by the VDBE program. Allocate + ** space at the end of aMem[] for cursors 1 and greater. + ** See also: allocateCursor(). + */ + nMem = nMem + nCursor + if nCursor == 0 && nMem > 0 { + nMem = nMem + 1 + } /* Space for aMem[0] even if not used */ + /* Figure out how much reusable memory is available at the end of the + ** opcode array. This extra memory will be reallocated for other elements + ** of the prepared statement. + */ + n = libc.Int32FromUint64(libc.Uint64FromInt64(24) * libc.Uint64FromInt32((*TVdbe)(unsafe.Pointer(p)).FnOp)) /* Bytes of opcode memory used */ + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FpSpace = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(n) /* Unused opcode memory */ + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnFree = int64(((*TParse)(unsafe.Pointer(pParse)).FszOpAlloc - n) & ^libc.Int32FromInt32(7)) /* Bytes of unused memory */ + _resolveP2Values(tls, p, bp) + libc.SetBitFieldPtr16Uint32(p+200, uint32(libc.BoolUint8((*TParse)(unsafe.Pointer(pParse)).FisMultiWrite != 0 && int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x2>>1)) != 0)), 5, 0x20) + if (*TParse)(unsafe.Pointer(pParse)).Fexplain != 0 { + if nMem < int32(10) { + nMem = int32(10) + } + libc.SetBitFieldPtr16Uint32(p+200, uint32((*TParse)(unsafe.Pointer(pParse)).Fexplain), 2, 0xc) + (*TVdbe)(unsafe.Pointer(p)).FnResColumn = libc.Uint16FromInt32(int32(12) - int32(4)*int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2))) + } + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + /* Memory for registers, parameters, cursor, etc, is allocated in one or two + ** passes. On the first pass, we try to reuse unused memory at the + ** end of the opcode array. If we are unable to satisfy all memory + ** requirements by reusing the opcode array tail, then the second + ** pass will fill in the remainder using a fresh memory allocation. + ** + ** This two-pass approach that reuses as much memory as possible from + ** the leftover memory at the end of the opcode array. This can significantly + ** reduce the amount of memory held by a prepared statement. + */ + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnNeeded = 0 + (*TVdbe)(unsafe.Pointer(p)).FaMem = _allocSpace(tls, bp+8, uintptr(0), libc.Int64FromUint64(libc.Uint64FromInt32(nMem)*uint64(56))) + (*TVdbe)(unsafe.Pointer(p)).FaVar = _allocSpace(tls, bp+8, uintptr(0), libc.Int64FromUint64(libc.Uint64FromInt32(nVar)*uint64(56))) + (*TVdbe)(unsafe.Pointer(p)).FapArg = _allocSpace(tls, bp+8, uintptr(0), libc.Int64FromUint64(libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(8))) + (*TVdbe)(unsafe.Pointer(p)).FapCsr = _allocSpace(tls, bp+8, uintptr(0), libc.Int64FromUint64(libc.Uint64FromInt32(nCursor)*uint64(8))) + if (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnNeeded != 0 { + v1 = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt64((**(**TReusableSpace)(__ccgo_up(bp + 8))).FnNeeded)) + (*TVdbe)(unsafe.Pointer(p)).FpFree = v1 + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FpSpace = v1 + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnFree = (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnNeeded + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + (*TVdbe)(unsafe.Pointer(p)).FaMem = _allocSpace(tls, bp+8, (*TVdbe)(unsafe.Pointer(p)).FaMem, libc.Int64FromUint64(libc.Uint64FromInt32(nMem)*uint64(56))) + (*TVdbe)(unsafe.Pointer(p)).FaVar = _allocSpace(tls, bp+8, (*TVdbe)(unsafe.Pointer(p)).FaVar, libc.Int64FromUint64(libc.Uint64FromInt32(nVar)*uint64(56))) + (*TVdbe)(unsafe.Pointer(p)).FapArg = _allocSpace(tls, bp+8, (*TVdbe)(unsafe.Pointer(p)).FapArg, libc.Int64FromUint64(libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(8))) + (*TVdbe)(unsafe.Pointer(p)).FapCsr = _allocSpace(tls, bp+8, (*TVdbe)(unsafe.Pointer(p)).FapCsr, libc.Int64FromUint64(libc.Uint64FromInt32(nCursor)*uint64(8))) + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnVar = 0 + (*TVdbe)(unsafe.Pointer(p)).FnCursor = 0 + (*TVdbe)(unsafe.Pointer(p)).FnMem = 0 + } else { + (*TVdbe)(unsafe.Pointer(p)).FnCursor = nCursor + (*TVdbe)(unsafe.Pointer(p)).FnVar = int16(nVar) + _initMemArray(tls, (*TVdbe)(unsafe.Pointer(p)).FaVar, nVar, db, uint16(MEM_Null)) + (*TVdbe)(unsafe.Pointer(p)).FnMem = nMem + _initMemArray(tls, (*TVdbe)(unsafe.Pointer(p)).FaMem, nMem, db, uint16(MEM_Undefined)) + libc.X__builtin___memset_chk(tls, (*TVdbe)(unsafe.Pointer(p)).FapCsr, 0, libc.Uint64FromInt32(nCursor)*uint64(8), ^t__predefined_size_t(0)) + } + _sqlite3VdbeRewind(tls, p) +} + +// C documentation +// +// /* +// ** Memory cell pAccum contains the context of an aggregate function. +// ** This routine calls the xValue method for that function and stores +// ** the results in memory cell pMem. +// ** +// ** SQLITE_ERROR is returned if xValue() reports an error. SQLITE_OK +// ** otherwise. +// */ +func _sqlite3VdbeMemAggValue(tls *libc.TLS, pAccum uintptr, pOut uintptr, pFunc uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* ctx at bp+0 */ Tsqlite3_context + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + _sqlite3VdbeMemSetNull(tls, pOut) + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpOut = pOut + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpMem = pAccum + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpFunc = pFunc + (**(**Tsqlite3_context)(__ccgo_up(bp))).Fenc = (*Tsqlite3)(unsafe.Pointer((*TMem)(unsafe.Pointer(pAccum)).Fdb)).Fenc + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer(pFunc)).FxValue})))(tls, bp) + return (**(**Tsqlite3_context)(__ccgo_up(bp))).FisError +} + +// C documentation +// +// /* +// ** Make a full copy of pFrom into pTo. Prior contents of pTo are +// ** freed before the copy is made. +// */ +func _sqlite3VdbeMemCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr) (r int32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + rc = SQLITE_OK + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pTo)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _vdbeMemClearExternAndSetNull(tls, pTo) + } + libc.X__builtin___memcpy_chk(tls, pTo, pFrom, uint64(libc.UintptrFromInt32(0)+24), ^t__predefined_size_t(0)) + v1 = pTo + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Dyn)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pTo)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) != 0 { + if 0 == libc.Int32FromUint16((*TMem)(unsafe.Pointer(pFrom)).Fflags)&int32(MEM_Static) { + v1 = pTo + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Ephem)) + rc = _sqlite3VdbeMemMakeWriteable(tls, pTo) + } + } + return rc +} + +// C documentation +// +// /* +// ** If the given Mem* has a zero-filled tail, turn it into an ordinary +// ** blob stored in dynamically allocated space. +// */ +func _sqlite3VdbeMemExpandBlob(tls *libc.TLS, pMem uintptr) (r int32) { + var nByte int32 + var v1 uintptr + _, _ = nByte, v1 + /* Set nByte to the number of bytes required to store the expanded blob. */ + nByte = (*TMem)(unsafe.Pointer(pMem)).Fn + *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pMem)).Fu)) + if nByte <= 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Blob) == 0 { + return SQLITE_OK + } + nByte = int32(1) + } + if _sqlite3VdbeMemGrow(tls, pMem, nByte, int32(1)) != 0 { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, (*TMem)(unsafe.Pointer(pMem)).Fz+uintptr((*TMem)(unsafe.Pointer(pMem)).Fn), 0, libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pMem)).Fu))), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pMem + 16)) += *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pMem)).Fu)) + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Zero) | libc.Int32FromInt32(MEM_Term))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Memory cell pMem contains the context of an aggregate function. +// ** This routine calls the finalize method for that function. The +// ** result of the aggregate is stored back into pMem. +// ** +// ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK +// ** otherwise. +// */ +func _sqlite3VdbeMemFinalize(tls *libc.TLS, pMem uintptr, pFunc uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var _ /* ctx at bp+0 */ Tsqlite3_context + var _ /* t at bp+48 */ TMem + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, bp+48, 0, uint64(56), ^t__predefined_size_t(0)) + (**(**TMem)(__ccgo_up(bp + 48))).Fflags = uint16(MEM_Null) + (**(**TMem)(__ccgo_up(bp + 48))).Fdb = (*TMem)(unsafe.Pointer(pMem)).Fdb + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpOut = bp + 48 + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpMem = pMem + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpFunc = pFunc + (**(**Tsqlite3_context)(__ccgo_up(bp))).Fenc = (*Tsqlite3)(unsafe.Pointer((**(**TMem)(__ccgo_up(bp + 48))).Fdb)).Fenc + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer(pFunc)).FxFinalize})))(tls, bp) /* IMP: R-24505-23230 */ + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc > 0 { + _sqlite3DbFreeNN(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } + libc.X__builtin___memcpy_chk(tls, pMem, bp+48, uint64(56), ^t__predefined_size_t(0)) + return (**(**Tsqlite3_context)(__ccgo_up(bp))).FisError +} + +// C documentation +// +// /* +// ** Make sure pMem->z points to a writable allocation of at least n bytes. +// ** +// ** If the bPreserve argument is true, then copy of the content of +// ** pMem->z into the new allocation. pMem must be either a string or +// ** blob if bPreserve is true. If bPreserve is false, any prior content +// ** in pMem->z is discarded. +// */ +func _sqlite3VdbeMemGrow(tls *libc.TLS, pMem uintptr, n int32, bPreserve int32) (r int32) { + var v1 uintptr + _ = v1 + /* If the bPreserve flag is set to true, then the memory cell must already + ** contain a valid string or blob value. */ + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc > 0 && bPreserve != 0 && (*TMem)(unsafe.Pointer(pMem)).Fz == (*TMem)(unsafe.Pointer(pMem)).FzMalloc { + if (*TMem)(unsafe.Pointer(pMem)).Fdb != 0 { + v1 = _sqlite3DbReallocOrFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).Fz, libc.Uint64FromInt32(n)) + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = v1 + (*TMem)(unsafe.Pointer(pMem)).Fz = v1 + } else { + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = _sqlite3Realloc(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, libc.Uint64FromInt32(n)) + if (*TMem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) { + Xsqlite3_free(tls, (*TMem)(unsafe.Pointer(pMem)).Fz) + } + (*TMem)(unsafe.Pointer(pMem)).Fz = (*TMem)(unsafe.Pointer(pMem)).FzMalloc + } + bPreserve = 0 + } else { + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc > 0 { + _sqlite3DbFreeNN(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = _sqlite3DbMallocRaw(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, libc.Uint64FromInt32(n)) + } + if (*TMem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) { + _sqlite3VdbeMemSetNull(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = uintptr(0) + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = 0 + return int32(SQLITE_NOMEM) + } else { + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } + if bPreserve != 0 && (*TMem)(unsafe.Pointer(pMem)).Fz != 0 { + libc.X__builtin___memcpy_chk(tls, (*TMem)(unsafe.Pointer(pMem)).FzMalloc, (*TMem)(unsafe.Pointer(pMem)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn), ^t__predefined_size_t(0)) + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Dyn) != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMem)(unsafe.Pointer(pMem)).FxDel})))(tls, (*TMem)(unsafe.Pointer(pMem)).Fz) + } + (*TMem)(unsafe.Pointer(pMem)).Fz = (*TMem)(unsafe.Pointer(pMem)).FzMalloc + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Ephem) | libc.Int32FromInt32(MEM_Static))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This routine checks for a byte-order mark at the beginning of the +// ** UTF-16 string stored in *pMem. If one is present, it is removed and +// ** the encoding of the Mem adjusted. This routine does not do any +// ** byte-swapping, it just sets Mem.enc appropriately. +// ** +// ** The allocation (static, dynamic etc.) and encoding of the Mem may be +// ** changed by this function. +// */ +func _sqlite3VdbeMemHandleBom(tls *libc.TLS, pMem uintptr) (r int32) { + var b1, b2, bom Tu8 + var rc int32 + var v1 uintptr + _, _, _, _, _ = b1, b2, bom, rc, v1 + rc = SQLITE_OK + bom = uint8(0) + if (*TMem)(unsafe.Pointer(pMem)).Fn > int32(1) { + b1 = **(**Tu8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz)) + b2 = **(**Tu8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + libc.UintptrFromInt32(1))) + if libc.Int32FromUint8(b1) == int32(0xFE) && libc.Int32FromUint8(b2) == int32(0xFF) { + bom = uint8(SQLITE_UTF16BE) + } + if libc.Int32FromUint8(b1) == int32(0xFF) && libc.Int32FromUint8(b2) == int32(0xFE) { + bom = uint8(SQLITE_UTF16LE) + } + } + if bom != 0 { + rc = _sqlite3VdbeMemMakeWriteable(tls, pMem) + if rc == SQLITE_OK { + **(**int32)(__ccgo_up(pMem + 16)) -= int32(2) + libc.X__builtin___memmove_chk(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, (*TMem)(unsafe.Pointer(pMem)).Fz+2, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = int8('\000') + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn+int32(1)))) = int8('\000') + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pMem)).Fenc = bom + } + } + return rc +} + +// C documentation +// +// /* +// ** Transfer the contents of pFrom to pTo. Any existing value in pTo is +// ** freed. If pFrom contains ephemeral data, a copy is made. +// ** +// ** pFrom contains an SQL NULL when this routine returns. +// */ +func _sqlite3VdbeMemMove(tls *libc.TLS, pTo uintptr, pFrom uintptr) { + _sqlite3VdbeMemRelease(tls, pTo) + libc.X__builtin___memcpy_chk(tls, pTo, pFrom, uint64(56), ^t__predefined_size_t(0)) + (*TMem)(unsafe.Pointer(pFrom)).Fflags = uint16(MEM_Null) + (*TMem)(unsafe.Pointer(pFrom)).FszMalloc = 0 +} + +// C documentation +// +// /* +// ** Change the value of a Mem to be a string or a BLOB. +// ** +// ** The memory management strategy depends on the value of the xDel +// ** parameter. If the value passed is SQLITE_TRANSIENT, then the +// ** string is copied into a (possibly existing) buffer managed by the +// ** Mem structure. Otherwise, any existing buffer is freed and the +// ** pointer copied. +// ** +// ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH +// ** size limit) then no memory allocation occurs. If the string can be +// ** stored without allocating memory, then it is. If a memory allocation +// ** is required to store the string, then value of pMem is unchanged. In +// ** either case, SQLITE_TOOBIG is returned. +// ** +// ** The "enc" parameter is the text encoding for the string, or zero +// ** to store a blob. +// ** +// ** If n is negative, then the string consists of all bytes up to but +// ** excluding the first zero character. The n parameter must be +// ** non-negative for blobs. +// */ +func _sqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n Ti64, enc Tu8, __ccgo_fp_xDel uintptr) (r int32) { + var flags Tu16 + var iLimit, v2 int32 + var nAlloc, nByte Ti64 + var v3 int64 + _, _, _, _, _, _ = flags, iLimit, nAlloc, nByte, v2, v3 + nByte = n /* New value for pMem->flags */ + /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ + if !(z != 0) { + _sqlite3VdbeMemSetNull(tls, pMem) + return SQLITE_OK + } + if (*TMem)(unsafe.Pointer(pMem)).Fdb != 0 { + iLimit = **(**int32)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fdb + 136)) + } else { + iLimit = int32(SQLITE_MAX_LENGTH) + } + if nByte < 0 { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, z)) + } else { + nByte = 0 + for { + if !(nByte <= int64(iLimit) && int32(**(**int8)(__ccgo_up(z + uintptr(nByte))))|int32(**(**int8)(__ccgo_up(z + uintptr(nByte+int64(1))))) != 0) { + break + } + goto _1 + _1: + ; + nByte = nByte + int64(2) + } + } + flags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term)) + } else { + if libc.Int32FromUint8(enc) == 0 { + flags = uint16(MEM_Blob) + enc = uint8(SQLITE_UTF8) + } else { + flags = uint16(MEM_Str) + } + } + if nByte > int64(iLimit) { + if __ccgo_fp_xDel != 0 && __ccgo_fp_xDel != uintptr(-libc.Int32FromInt32(1)) { + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, z) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, z) + } + } + _sqlite3VdbeMemSetNull(tls, pMem) + return _sqlite3ErrorToParser(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, int32(SQLITE_TOOBIG)) + } + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + if __ccgo_fp_xDel == uintptr(-libc.Int32FromInt32(1)) { + nAlloc = nByte + if libc.Int32FromUint16(flags)&int32(MEM_Term) != 0 { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + v2 = int32(1) + } else { + v2 = int32(2) + } + nAlloc = nAlloc + int64(v2) + } + if nAlloc > int64(libc.Int32FromInt32(32)) { + v3 = nAlloc + } else { + v3 = int64(libc.Int32FromInt32(32)) + } + if _sqlite3VdbeMemClearAndResize(tls, pMem, int32(v3)) != 0 { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, z, libc.Uint64FromInt64(nAlloc), ^t__predefined_size_t(0)) + } else { + _sqlite3VdbeMemRelease(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = z + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = (*TMem)(unsafe.Pointer(pMem)).Fz + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } else { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + if __ccgo_fp_xDel == libc.UintptrFromInt32(0) { + v2 = int32(MEM_Static) + } else { + v2 = int32(MEM_Dyn) + } + flags = libc.Uint16FromInt32(int32(flags) | v2) + } + } + (*TMem)(unsafe.Pointer(pMem)).Fn = int32(nByte & libc.Int64FromInt32(0x7fffffff)) + (*TMem)(unsafe.Pointer(pMem)).Fflags = flags + (*TMem)(unsafe.Pointer(pMem)).Fenc = enc + if libc.Int32FromUint8(enc) > int32(SQLITE_UTF8) && _sqlite3VdbeMemHandleBom(tls, pMem) != 0 { + return int32(SQLITE_NOMEM) + } + return SQLITE_OK +} + +// C documentation +// +// /* Like sqlite3VdbeMemSetStr() except: +// ** +// ** enc is always SQLITE_UTF8 +// ** pMem->db is always non-NULL +// */ +func _sqlite3VdbeMemSetText(tls *libc.TLS, pMem uintptr, z uintptr, n Ti64, __ccgo_fp_xDel uintptr) (r int32) { + var flags Tu16 + var nAlloc, nByte Ti64 + var v1 int64 + _, _, _, _ = flags, nAlloc, nByte, v1 + nByte = n + /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ + if !(z != 0) { + _sqlite3VdbeMemSetNull(tls, pMem) + return SQLITE_OK + } + if nByte < 0 { + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, z)) + flags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term)) + } else { + flags = uint16(MEM_Str) + } + if nByte > int64(**(**int32)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fdb + 136))) { + if __ccgo_fp_xDel != 0 && __ccgo_fp_xDel != uintptr(-libc.Int32FromInt32(1)) { + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, z) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, z) + } + } + _sqlite3VdbeMemSetNull(tls, pMem) + return _sqlite3ErrorToParser(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, int32(SQLITE_TOOBIG)) + } + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + if __ccgo_fp_xDel == uintptr(-libc.Int32FromInt32(1)) { + nAlloc = nByte + int64(1) + if nAlloc > int64(libc.Int32FromInt32(32)) { + v1 = nAlloc + } else { + v1 = int64(libc.Int32FromInt32(32)) + } + if _sqlite3VdbeMemClearAndResize(tls, pMem, int32(v1)) != 0 { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, z, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr(nByte))) = 0 + } else { + _sqlite3VdbeMemRelease(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = z + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = (*TMem)(unsafe.Pointer(pMem)).Fz + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + (*TMem)(unsafe.Pointer(pMem)).FxDel = uintptr(0) + } else { + if __ccgo_fp_xDel == libc.UintptrFromInt32(0) { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + flags = libc.Uint16FromInt32(int32(flags) | libc.Int32FromInt32(MEM_Static)) + } else { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + flags = libc.Uint16FromInt32(int32(flags) | libc.Int32FromInt32(MEM_Dyn)) + } + } + } + (*TMem)(unsafe.Pointer(pMem)).Fflags = flags + (*TMem)(unsafe.Pointer(pMem)).Fn = int32(nByte & libc.Int64FromInt32(0x7fffffff)) + (*TMem)(unsafe.Pointer(pMem)).Fenc = uint8(SQLITE_UTF8) + return SQLITE_OK +} + +func _sqlite3VdbeMemShallowCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, srcType int32) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pTo)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _vdbeClrCopy(tls, pTo, pFrom, srcType) + return + } + libc.X__builtin___memcpy_chk(tls, pTo, pFrom, uint64(libc.UintptrFromInt32(0)+24), ^t__predefined_size_t(0)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pFrom)).Fflags)&int32(MEM_Static) == 0 { + v1 = pTo + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Ephem))) + v1 = pTo + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | srcType) + } +} + +// C documentation +// +// /* +// ** Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call, +// ** then cursor passed as the second argument should point to the row about +// ** to be update or deleted. If the application calls sqlite3_preupdate_old(), +// ** the required value will be read from the row the cursor points to. +// */ +func _sqlite3VdbePreUpdateHook(tls *libc.TLS, v uintptr, pCsr uintptr, op int32, zDb uintptr, pTab uintptr, iKey1 Ti64, iReg int32, iBlobWrite int32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var db, zTbl uintptr + var i, i1 int32 + var iKey2, v1 Ti64 + var _ /* preupdate at bp+0 */ TPreUpdate + _, _, _, _, _, _ = db, i, i1, iKey2, zTbl, v1 + db = (*TVdbe)(unsafe.Pointer(v)).Fdb + zTbl = (*TTable)(unsafe.Pointer(pTab)).FzName + libc.X__builtin___memset_chk(tls, bp, 0, uint64(200), ^t__predefined_size_t(0)) + if libc.BoolInt32((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0)) == 0 { + v1 = libc.Int64FromInt32(0) + iKey2 = v1 + iKey1 = v1 + (**(**TPreUpdate)(__ccgo_up(bp))).FpPk = _sqlite3PrimaryKeyIndex(tls, pTab) + } else { + if op == int32(SQLITE_UPDATE) { + iKey2 = *(*Ti64)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(v)).FaMem + uintptr(iReg)*56)) + } else { + iKey2 = iKey1 + } + } + (**(**TPreUpdate)(__ccgo_up(bp))).Fv = v + (**(**TPreUpdate)(__ccgo_up(bp))).FpCsr = pCsr + (**(**TPreUpdate)(__ccgo_up(bp))).Fop = op + (**(**TPreUpdate)(__ccgo_up(bp))).FiNewReg = iReg + (**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo = bp + 168 + (*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).Fdb = db + (*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).Fenc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + (*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).FnKeyField = libc.Uint16FromInt16((*TTable)(unsafe.Pointer(pTab)).FnCol) + (*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).FaSortFlags = uintptr(0) /* Indicate .aColl, .nAllField uninit */ + (**(**TPreUpdate)(__ccgo_up(bp))).FiKey1 = iKey1 + (**(**TPreUpdate)(__ccgo_up(bp))).FiKey2 = iKey2 + (**(**TPreUpdate)(__ccgo_up(bp))).FpTab = pTab + (**(**TPreUpdate)(__ccgo_up(bp))).FiBlobWrite = iBlobWrite + (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate = bp + (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, Tsqlite3_int64, Tsqlite3_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2) + (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate = uintptr(0) + _sqlite3DbFree(tls, db, (**(**TPreUpdate)(__ccgo_up(bp))).FaRecord) + _vdbeFreeUnpacked(tls, db, libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).FnKeyField)+int32(1), (**(**TPreUpdate)(__ccgo_up(bp))).FpUnpacked) + _vdbeFreeUnpacked(tls, db, libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).FnKeyField)+int32(1), (**(**TPreUpdate)(__ccgo_up(bp))).FpNewUnpacked) + _sqlite3VdbeMemRelease(tls, bp+80) + if (**(**TPreUpdate)(__ccgo_up(bp))).FaNew != 0 { + i = 0 + for { + if !(i < int32((*TVdbeCursor)(unsafe.Pointer(pCsr)).FnField)) { + break + } + _sqlite3VdbeMemRelease(tls, (**(**TPreUpdate)(__ccgo_up(bp))).FaNew+uintptr(i)*56) + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3DbNNFreeNN(tls, db, (**(**TPreUpdate)(__ccgo_up(bp))).FaNew) + } + if (**(**TPreUpdate)(__ccgo_up(bp))).FapDflt != 0 { + i1 = 0 + for { + if !(i1 < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up((**(**TPreUpdate)(__ccgo_up(bp))).FapDflt + uintptr(i1)*8))) + goto _3 + _3: + ; + i1 = i1 + 1 + } + _sqlite3DbFree(tls, db, (**(**TPreUpdate)(__ccgo_up(bp))).FapDflt) + } +} + +/************** End of vdbeaux.c *********************************************/ +/************** Begin file vdbeapi.c *****************************************/ +/* +** 2004 May 26 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code use to implement APIs that are part of the +** VDBE. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ +/* #include "opcodes.h" */ + +// C documentation +// +// /* +// ** Initialize the temporary index cursor just opened as a sorter cursor. +// ** +// ** Usually, the sorter module uses the value of (pCsr->pKeyInfo->nKeyField) +// ** to determine the number of fields that should be compared from the +// ** records being sorted. However, if the value passed as argument nField +// ** is non-zero and the sorter is able to guarantee a stable sort, nField +// ** is used instead. This is used when sorting records for a CREATE INDEX +// ** statement. In this case, keys are always delivered to the sorter in +// ** order of the primary key, which happens to be make up the final part +// ** of the records being sorted. So if the sort is stable, there is never +// ** any reason to compare PK fields and they can be ignored for a small +// ** performance boost. +// ** +// ** The sorter can guarantee a stable sort when running in single-threaded +// ** mode, but not in multi-threaded mode. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +// */ +func _sqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintptr) (r int32) { + var i, nWorker, pgsz, rc, szKeyInfo, v2 int32 + var mxCache, sz Ti64 + var pBt, pKeyInfo, pSorter, pTask, v1 uintptr + var szPma Tu32 + var v4 int64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, mxCache, nWorker, pBt, pKeyInfo, pSorter, pTask, pgsz, rc, sz, szKeyInfo, szPma, v1, v2, v4 /* Size of pSorter in bytes */ + rc = SQLITE_OK + /* Initialize the upper limit on the number of worker threads */ + if _sqlite3TempInMemory(tls, db) != 0 || libc.Int32FromUint8(_sqlite3Config.FbCoreMutex) == 0 { + nWorker = 0 + } else { + nWorker = **(**int32)(__ccgo_up(db + 136 + 11*4)) + } + /* Do not allow the total number of threads (main thread + all workers) + ** to exceed the maximum merge count */ + szKeyInfo = libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0)+32) + uint64((*TKeyInfo)(unsafe.Pointer((*TVdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo)).FnAllField)*libc.Uint64FromInt64(8)) + sz = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+96) + libc.Uint64FromInt32(nWorker+libc.Int32FromInt32(1))*libc.Uint64FromInt64(104)) + pSorter = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(sz+int64(szKeyInfo))) + *(*uintptr)(unsafe.Pointer(pCsr + 48)) = pSorter + if pSorter == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpBt + v1 = pSorter + uintptr(sz) + pKeyInfo = v1 + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpKeyInfo = v1 + libc.X__builtin___memcpy_chk(tls, pKeyInfo, (*TVdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo, libc.Uint64FromInt32(szKeyInfo), ^t__predefined_size_t(0)) + (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb = uintptr(0) + if nField != 0 && nWorker == 0 { + (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField = libc.Uint16FromInt32(nField) + } + /* It is OK that pKeyInfo reuses the aSortFlags field from pCsr->pKeyInfo, + ** since the pCsr->pKeyInfo->aSortFlags[] array is invariant and lives + ** longer that pSorter. */ + _sqlite3BtreeEnter(tls, pBt) + v2 = _sqlite3BtreeGetPageSize(tls, pBt) + pgsz = v2 + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Fpgsz = v2 + _sqlite3BtreeLeave(tls, pBt) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask = libc.Uint8FromInt32(nWorker + int32(1)) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FiPrev = libc.Uint8FromInt32(nWorker - libc.Int32FromInt32(1)) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads = libc.BoolUint8(libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > libc.Int32FromInt32(1)) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Fdb = db + i = 0 + for { + if !(i < libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) { + break + } + pTask = pSorter + 96 + uintptr(i)*104 + (*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter = pSorter + goto _3 + _3: + ; + i = i + 1 + } + if !(_sqlite3TempInMemory(tls, db) != 0) { /* Cache size in bytes*/ + szPma = _sqlite3Config.FszPma + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize = libc.Int32FromUint32(szPma * libc.Uint32FromInt32(pgsz)) + mxCache = int64((*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).Fcache_size) + if mxCache < 0 { + /* A negative cache-size value C indicates that the cache is abs(C) + ** KiB in size. */ + mxCache = mxCache * int64(-int32(1024)) + } else { + mxCache = mxCache * int64(pgsz) + } + if mxCache < int64(libc.Int32FromInt32(1)< int32(mxCache) { + v2 = (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize + } else { + v2 = int32(mxCache) + } + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize = v2 + /* Avoid large memory allocations if the application has requested + ** SQLITE_CONFIG_SMALL_MALLOC. */ + if libc.Int32FromUint8(_sqlite3Config.FbSmallMalloc) == 0 { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = pgsz + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = _sqlite3Malloc(tls, libc.Uint64FromInt32(pgsz)) + if !((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0) { + rc = int32(SQLITE_NOMEM) + } + } + } + if libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField) < int32(13) && (*(*uintptr)(unsafe.Pointer(pKeyInfo + 32)) == uintptr(0) || *(*uintptr)(unsafe.Pointer(pKeyInfo + 32)) == (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags)))&int32(KEYINFO_ORDER_BIGNULL) == 0 { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = libc.Uint8FromInt32(libc.Int32FromInt32(SORTER_TYPE_INTEGER) | libc.Int32FromInt32(SORTER_TYPE_TEXT)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Copy the current sorter key into the memory cell pOut. +// */ +func _sqlite3VdbeSorterRowkey(tls *libc.TLS, pCsr uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pKey, pSorter uintptr + var _ /* nKey at bp+0 */ int32 + _, _ = pKey, pSorter /* Sorter key to copy into pOut */ + pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 48)) + pKey = _vdbeSorterRowkey(tls, pSorter, bp) + if _sqlite3VdbeMemClearAndResize(tls, pOut, **(**int32)(__ccgo_up(bp))) != 0 { + return int32(SQLITE_NOMEM) + } + (*TMem)(unsafe.Pointer(pOut)).Fn = **(**int32)(__ccgo_up(bp)) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Blob)) + libc.X__builtin___memcpy_chk(tls, (*TMem)(unsafe.Pointer(pOut)).Fz, pKey, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))), ^t__predefined_size_t(0)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Add a record to the sorter. +// */ +func _sqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aNew, pNew, pSorter, v1 uintptr + var bFlush, iListOff, nMin, rc int32 + var nNew Tsqlite3_int64 + var nPMA, nReq Ti64 + var _ /* t at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = aNew, bFlush, iListOff, nMin, nNew, nPMA, nReq, pNew, pSorter, rc, v1 + rc = SQLITE_OK /* serial type of first record field */ + pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 48)) + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint32(uint32(**(**Tu8)(__ccgo_up((*TMem)(unsafe.Pointer(pVal)).Fz + 1)))) + if **(**int32)(__ccgo_up(bp)) >= int32(0x80) { + _sqlite3GetVarint32(tls, (*TMem)(unsafe.Pointer(pVal)).Fz+1, bp) + } + if **(**int32)(__ccgo_up(bp)) > 0 && **(**int32)(__ccgo_up(bp)) < int32(10) && **(**int32)(__ccgo_up(bp)) != int32(7) { + v1 = pSorter + 92 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & libc.Int32FromInt32(SORTER_TYPE_INTEGER)) + } else { + if **(**int32)(__ccgo_up(bp)) > int32(10) && **(**int32)(__ccgo_up(bp))&int32(0x01) != 0 { + v1 = pSorter + 92 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & libc.Int32FromInt32(SORTER_TYPE_TEXT)) + } else { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = uint8(0) + } + } + /* Figure out whether or not the current contents of memory should be + ** flushed to a PMA before continuing. If so, do so. + ** + ** If using the single large allocation mode (pSorter->aMemory!=0), then + ** flush the contents of memory to a new PMA if (a) at least one value is + ** already in memory and (b) the new value will not fit in memory. + ** + ** Or, if using separate allocations for each record, flush the contents + ** of memory to a PMA if either of the following are true: + ** + ** * The total memory allocated for the in-memory list is greater + ** than (page-size * cache-size), or + ** + ** * The total memory allocated for the in-memory list is greater + ** than (page-size * 10) and sqlite3HeapNearlyFull() returns true. + */ + nReq = libc.Int64FromUint64(libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pVal)).Fn) + uint64(16)) + nPMA = int64((*TMem)(unsafe.Pointer(pVal)).Fn + _sqlite3VarintLen(tls, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pVal)).Fn))) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize != 0 { + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 { + bFlush = libc.BoolInt32((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory != 0 && int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory)+nReq > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize)) + } else { + bFlush = libc.BoolInt32((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize) || (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize) && _sqlite3HeapNearlyFull(tls) != 0) + } + if bFlush != 0 { + rc = _vdbeSorterFlushPMA(tls, pSorter) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA = 0 + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory = 0 + } + } + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA += nPMA + if nPMA > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxKeysize) { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxKeysize = int32(nPMA) + } + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 { + nMin = int32(int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory) + nReq) + if nMin > (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory { + nNew = int64(2) * int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory) + iListOff = -int32(1) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { + iListOff = int32(int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList) - int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)) + } + for nNew < int64(nMin) { + nNew = nNew * int64(2) + } + if nNew > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize) { + nNew = int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize) + } + if nNew < int64(nMin) { + nNew = int64(nMin) + } + aNew = _sqlite3Realloc(tls, (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory, libc.Uint64FromInt64(nNew)) + if !(aNew != 0) { + return int32(SQLITE_NOMEM) + } + if iListOff >= 0 { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = aNew + uintptr(iListOff) + } + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = aNew + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = int32(nNew) + } + pNew = (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory + uintptr((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory) + v1 = pSorter + 80 + *(*int32)(unsafe.Pointer(v1)) = int32(int64(*(*int32)(unsafe.Pointer(v1))) + (nReq+libc.Int64FromInt32(7))&int64(^libc.Int32FromInt32(7))) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { + *(*int32)(unsafe.Pointer(&(*TSorterRecord)(unsafe.Pointer(pNew)).Fu)) = int32(int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList) - int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)) + } + } else { + pNew = _sqlite3Malloc(tls, libc.Uint64FromInt64(nReq)) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + *(*uintptr)(unsafe.Pointer(pNew + 8)) = (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList + } + libc.X__builtin___memcpy_chk(tls, pNew+libc.UintptrFromInt32(1)*16, (*TMem)(unsafe.Pointer(pVal)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pVal)).Fn), ^t__predefined_size_t(0)) + (*TSorterRecord)(unsafe.Pointer(pNew)).FnVal = (*TMem)(unsafe.Pointer(pVal)).Fn + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = pNew + return rc +} + +// C documentation +// +// /* +// ** Swap byte-code between two VDBE structures. +// ** +// ** This happens after pB was previously run and returned +// ** SQLITE_SCHEMA. The statement was then reprepared in pA. +// ** This routine transfers the new bytecode in pA over to pB +// ** so that pB can be run again. The old pB byte code is +// ** moved back to pA so that it will be cleaned up when pA is +// ** finalized. +// */ +func _sqlite3VdbeSwap(tls *libc.TLS, pA uintptr, pB uintptr) { + var pTmp, ppTmp, zTmp uintptr + var tmp TVdbe + _, _, _, _ = pTmp, ppTmp, tmp, zTmp + tmp = **(**TVdbe)(__ccgo_up(pA)) + **(**TVdbe)(__ccgo_up(pA)) = **(**TVdbe)(__ccgo_up(pB)) + **(**TVdbe)(__ccgo_up(pB)) = tmp + pTmp = (*TVdbe)(unsafe.Pointer(pA)).FpVNext + (*TVdbe)(unsafe.Pointer(pA)).FpVNext = (*TVdbe)(unsafe.Pointer(pB)).FpVNext + (*TVdbe)(unsafe.Pointer(pB)).FpVNext = pTmp + ppTmp = (*TVdbe)(unsafe.Pointer(pA)).FppVPrev + (*TVdbe)(unsafe.Pointer(pA)).FppVPrev = (*TVdbe)(unsafe.Pointer(pB)).FppVPrev + (*TVdbe)(unsafe.Pointer(pB)).FppVPrev = ppTmp + zTmp = (*TVdbe)(unsafe.Pointer(pA)).FzSql + (*TVdbe)(unsafe.Pointer(pA)).FzSql = (*TVdbe)(unsafe.Pointer(pB)).FzSql + (*TVdbe)(unsafe.Pointer(pB)).FzSql = zTmp + (*TVdbe)(unsafe.Pointer(pB)).Fexpmask = (*TVdbe)(unsafe.Pointer(pA)).Fexpmask + (*TVdbe)(unsafe.Pointer(pB)).FprepFlags = (*TVdbe)(unsafe.Pointer(pA)).FprepFlags + libc.X__builtin___memcpy_chk(tls, pB+212, pA+212, uint64(36), ^t__predefined_size_t(0)) + **(**Tu32)(__ccgo_up(pB + 212 + 5*4)) = **(**Tu32)(__ccgo_up(pB + 212 + 5*4)) + 1 +} + +// C documentation +// +// /* +// ** Expression pExpr is a vector that has been used in a context where +// ** it is not permitted. If pExpr is a sub-select vector, this routine +// ** loads the Parse object with a message of the form: +// ** +// ** "sub-select returns N columns - expected 1" +// ** +// ** Or, if it is a regular scalar vector: +// ** +// ** "row value misused" +// */ +func _sqlite3VectorErrorMsg(tls *libc.TLS, pParse uintptr, pExpr uintptr) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _sqlite3SubselectError(tls, pParse, (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList)).FnExpr, int32(1)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7252, 0) + } +} + +// C documentation +// +// /* +// ** This function is invoked by the parser to call the xConnect() method +// ** of the virtual table pTab. If an error occurs, an error code is returned +// ** and an error left in pParse. +// ** +// ** This call is a no-op if table pTab is not a virtual table. +// */ +func _sqlite3VtabCallConnect(tls *libc.TLS, pParse uintptr, pTab uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pMod, zMod, zModule uintptr + var rc int32 + var _ /* zErr at bp+0 */ uintptr + _, _, _, _, _ = db, pMod, rc, zMod, zModule + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if _sqlite3GetVTable(tls, db, pTab) != 0 { + return SQLITE_OK + } + /* Locate the required virtual table module */ + zMod = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg)) + pMod = _sqlite3HashFind(tls, db+576, zMod) + if !(pMod != 0) { + zModule = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg)) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+23912, libc.VaList(bp+16, zModule)) + rc = int32(SQLITE_ERROR) + } else { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _vtabCallConstructor(tls, db, pTab, pMod, (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxConnect, bp) + if rc != SQLITE_OK { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3944, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp)))) + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + } + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** This function is invoked by the vdbe to call the xCreate method +// ** of the virtual table named zTab in database iDb. +// ** +// ** If an error occurs, *pzErr is set to point to an English language +// ** description of the error and an SQLITE_XXX error code is returned. +// ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr. +// */ +func _sqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pMod, pTab, zMod uintptr + var rc int32 + _, _, _, _ = pMod, pTab, rc, zMod + rc = SQLITE_OK + pTab = _sqlite3FindTable(tls, db, zTab, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + /* Locate the required virtual table module */ + zMod = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg)) + pMod = _sqlite3HashFind(tls, db+576, zMod) + /* If the module has been registered and includes a Create method, + ** invoke it now. If the module has not been registered, return an + ** error. Otherwise, do nothing. + */ + if pMod == uintptr(0) || (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxCreate == uintptr(0) || (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxDestroy == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+23912, libc.VaList(bp+8, zMod)) + rc = int32(SQLITE_ERROR) + } else { + rc = _vtabCallConstructor(tls, db, pTab, pMod, (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxCreate, pzErr) + } + /* Justification of ALWAYS(): The xConstructor method is required to + ** create a valid sqlite3_vtab if it returns SQLITE_OK. */ + if rc == SQLITE_OK && _sqlite3GetVTable(tls, db, pTab) != 0 { + rc = _growVTrans(tls, db) + if rc == SQLITE_OK { + _addToVTrans(tls, db, _sqlite3GetVTable(tls, db, pTab)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Construct and install a Module object for a virtual table. When this +// ** routine is called, it is guaranteed that all appropriate locks are held +// ** and the module is not already part of the connection. +// ** +// ** If there already exists a module with zName, replace it with the new one. +// ** If pModule==0, then delete the module zName if it exists. +// */ +func _sqlite3VtabCreateModule(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, __ccgo_fp_xDestroy uintptr) (r uintptr) { + var nName int32 + var pDel, pMod, zCopy uintptr + _, _, _, _ = nName, pDel, pMod, zCopy + if pModule == uintptr(0) { + zCopy = zName + pMod = uintptr(0) + } else { + nName = _sqlite3Strlen30(tls, zName) + pMod = _sqlite3Malloc(tls, uint64(uint64(48)+libc.Uint64FromInt32(nName)+uint64(1))) + if pMod == uintptr(0) { + _sqlite3OomFault(tls, db) + return uintptr(0) + } + zCopy = pMod + 1*48 + libc.X__builtin___memcpy_chk(tls, zCopy, zName, libc.Uint64FromInt32(nName+int32(1)), ^t__predefined_size_t(0)) + (*TModule)(unsafe.Pointer(pMod)).FzName = zCopy + (*TModule)(unsafe.Pointer(pMod)).FpModule = pModule + (*TModule)(unsafe.Pointer(pMod)).FpAux = pAux + (*TModule)(unsafe.Pointer(pMod)).FxDestroy = __ccgo_fp_xDestroy + (*TModule)(unsafe.Pointer(pMod)).FpEpoTab = uintptr(0) + (*TModule)(unsafe.Pointer(pMod)).FnRefModule = int32(1) + } + pDel = _sqlite3HashInsert(tls, db+576, zCopy, pMod) + if pDel != 0 { + if pDel == pMod { + _sqlite3OomFault(tls, db) + _sqlite3DbFree(tls, db, pDel) + pMod = uintptr(0) + } else { + _sqlite3VtabEponymousTableClear(tls, db, pDel) + _sqlite3VtabModuleUnref(tls, db, pDel) + } + } + return pMod +} + +// C documentation +// +// /* +// ** The parser calls this routine after the CREATE VIRTUAL TABLE statement +// ** has been completely parsed. +// */ +func _sqlite3VtabFinishParse(tls *libc.TLS, pParse uintptr, pEnd uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var db, pOld, pSchema, pTab, v, zName, zStmt, zWhere, v2 uintptr + var iDb, iReg, v1 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = db, iDb, iReg, pOld, pSchema, pTab, v, zName, zStmt, zWhere, v1, v2 + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable /* The table being constructed */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The database connection */ + if pTab == uintptr(0) { + return + } + _addArgumentToVtab(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FsArg.Fz = uintptr(0) + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FnArg < int32(1) { + return + } + /* If the CREATE VIRTUAL TABLE statement is being entered for the + ** first time (in other words if the virtual table is actually being + ** created now instead of just being read out of sqlite_schema) then + ** do additional initialization work and store the statement text + ** in the sqlite_schema table. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + _sqlite3MayAbort(tls, pParse) + /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ + if pEnd != 0 { + (*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fn = libc.Uint32FromInt32(int32(int64((*TToken)(unsafe.Pointer(pEnd)).Fz)-int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz))) + (*TToken)(unsafe.Pointer(pEnd)).Fn + } + zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+23652, libc.VaList(bp+8, pParse+224)) + /* A slot for the record has already been allocated in the + ** schema table. We just need to update that slot with all + ** the information we've collected. + ** + ** The VM register number pParse->u1.cr.regRowid holds the rowid of an + ** entry in the sqlite_schema table that was created for this vtab + ** by sqlite3StartTable(). + */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+23676, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(pTab)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, zStmt, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRowid)) + v = _sqlite3GetVdbe(tls, pParse) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + zWhere = _sqlite3MPrintf(tls, db, __ccgo_ts+23775, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, zStmt)) + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, zWhere, uint16(0)) + _sqlite3DbFree(tls, db, zStmt) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + iReg = v1 + _sqlite3VdbeLoadString(tls, v, iReg, (*TTable)(unsafe.Pointer(pTab)).FzName) + _sqlite3VdbeAddOp2(tls, v, int32(OP_VCreate), iDb, iReg) + } else { + pSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + zName = (*TTable)(unsafe.Pointer(pTab)).FzName + _sqlite3MarkAllShadowTablesOf(tls, db, pTab) + pOld = _sqlite3HashInsert(tls, pSchema+8, zName, pTab) + if pOld != 0 { + _sqlite3OomFault(tls, db) + /* Malloc must have failed inside HashInsert() */ + return + } + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0) + } +} + +// C documentation +// +// /* +// ** The first parameter (pDef) is a function implementation. The +// ** second parameter (pExpr) is the first argument to this function. +// ** If pExpr is a column in a virtual table, then let the virtual +// ** table implementation have an opportunity to overload the function. +// ** +// ** This routine is used to allow virtual table implementations to +// ** overload MATCH, LIKE, GLOB, and REGEXP operators. +// ** +// ** Return either the pDef argument (indicating no change) or a +// ** new FuncDef structure that is marked as ephemeral using the +// ** SQLITE_FUNC_EPHEM flag. +// */ +func _sqlite3VtabOverloadFunction(tls *libc.TLS, db uintptr, pDef uintptr, nArg int32, pExpr uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pMod, pNew, pTab, pVtab uintptr + var rc int32 + var _ /* pArg at bp+8 */ uintptr + var _ /* xSFunc at bp+0 */ uintptr + _, _, _, _, _ = pMod, pNew, pTab, pVtab, rc + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + rc = 0 + /* Check to see the left operand is a column in a virtual table */ + if pExpr == uintptr(0) { + return pDef + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLUMN) { + return pDef + } + pTab = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + if pTab == uintptr(0) { + return pDef + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + return pDef + } + pVtab = (*TVTable)(unsafe.Pointer(_sqlite3GetVTable(tls, db, pTab))).FpVtab + pMod = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule + if (*Tsqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction == uintptr(0) { + return pDef + } + /* Call the xFindFunction method on the virtual table implementation + ** to see if the implementation wants to overload this function. + ** + ** Though undocumented, we have historically always invoked xFindFunction + ** with an all lower-case function name. Continue in this tradition to + ** avoid any chance of an incompatibility. + */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction})))(tls, pVtab, nArg, (*TFuncDef)(unsafe.Pointer(pDef)).FzName, bp, bp+8) + if rc == 0 { + return pDef + } + /* Create a new ephemeral function definition for the overloaded + ** function */ + pNew = _sqlite3DbMallocZero(tls, db, uint64(uint64(72)+libc.Uint64FromInt32(_sqlite3Strlen30(tls, (*TFuncDef)(unsafe.Pointer(pDef)).FzName))+uint64(1))) + if pNew == uintptr(0) { + return pDef + } + **(**TFuncDef)(__ccgo_up(pNew)) = **(**TFuncDef)(__ccgo_up(pDef)) + (*TFuncDef)(unsafe.Pointer(pNew)).FzName = pNew + 1*72 + libc.X__builtin___memcpy_chk(tls, pNew+1*72, (*TFuncDef)(unsafe.Pointer(pDef)).FzName, libc.Uint64FromInt32(_sqlite3Strlen30(tls, (*TFuncDef)(unsafe.Pointer(pDef)).FzName)+int32(1)), ^t__predefined_size_t(0)) + (*TFuncDef)(unsafe.Pointer(pNew)).FxSFunc = **(**uintptr)(__ccgo_up(bp)) + (*TFuncDef)(unsafe.Pointer(pNew)).FpUserData = **(**uintptr)(__ccgo_up(bp + 8)) + **(**Tu32)(__ccgo_up(pNew + 4)) |= uint32(SQLITE_FUNC_EPHEM) + return pNew +} + +// C documentation +// +// /* +// ** This routine is called to implement sqlite3_wal_checkpoint() and +// ** related interfaces. +// ** +// ** Obtain a CHECKPOINT lock and then backfill as much information as +// ** we can from WAL into the database. +// ** +// ** If parameter xBusy is not NULL, it is a pointer to a busy-handler +// ** callback. In this case this function runs a blocking checkpoint. +// */ +func _sqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, __ccgo_fp_xBusy uintptr, pBusyArg uintptr, sync_flags int32, nBuf int32, zBuf uintptr, pnLog uintptr, pnCkpt uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eMode2, rc, v1 int32 + var xBusy2 uintptr + var _ /* isChanged at bp+0 */ int32 + _, _, _, _ = eMode2, rc, xBusy2, v1 /* Return code */ + **(**int32)(__ccgo_up(bp)) = 0 /* True if a new wal-index header is loaded */ + eMode2 = eMode /* Mode to pass to walCheckpoint() */ + xBusy2 = __ccgo_fp_xBusy /* Busy handler for eMode2 */ + /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked + ** in the SQLITE_CHECKPOINT_PASSIVE mode. */ + if (*TWal)(unsafe.Pointer(pWal)).FreadOnly != 0 { + return int32(SQLITE_READONLY) + } + /* Enable blocking locks, if possible. */ + if xBusy2 != 0 { + } + /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive + ** "checkpoint" lock on the database file. + ** EVIDENCE-OF: R-10421-19736 If any other process is running a + ** checkpoint operation at the same time, the lock cannot be obtained and + ** SQLITE_BUSY is returned. + ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured, + ** it will not be invoked in this case. + */ + if eMode != -int32(1) { + rc = _walLockExclusive(tls, pWal, int32(WAL_CKPT_LOCK), int32(1)) + if rc == SQLITE_OK { + (*TWal)(unsafe.Pointer(pWal)).FckptLock = uint8(1) + /* IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART + ** and TRUNCATE modes also obtain the exclusive "writer" lock on the + ** database file. + ** + ** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained + ** immediately, and a busy-handler is configured, it is invoked and the + ** writer lock retried until either the busy-handler returns 0 or the + ** lock is successfully obtained. + */ + if eMode != SQLITE_CHECKPOINT_PASSIVE { + rc = _walBusyLock(tls, pWal, xBusy2, pBusyArg, WAL_WRITE_LOCK, int32(1)) + if rc == SQLITE_OK { + (*TWal)(unsafe.Pointer(pWal)).FwriteLock = uint8(1) + } else { + if rc == int32(SQLITE_BUSY) { + eMode2 = SQLITE_CHECKPOINT_PASSIVE + xBusy2 = uintptr(0) + rc = SQLITE_OK + } + } + } + } + } else { + rc = SQLITE_OK + } + /* Read the wal-index header. */ + if rc == SQLITE_OK { + /* For a passive checkpoint, do not re-enable blocking locks after + ** reading the wal-index header. A passive checkpoint should not block + ** or invoke the busy handler. The only lock such a checkpoint may + ** attempt to obtain is a lock on a read-slot, and it should give up + ** immediately and do a partial checkpoint if it cannot obtain it. */ + rc = _walIndexReadHdr(tls, pWal, bp) + if eMode2 > SQLITE_CHECKPOINT_PASSIVE { + } + if **(**int32)(__ccgo_up(bp)) != 0 && (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*TWal)(unsafe.Pointer(pWal)).FpDbFd)).FpMethods)).FiVersion >= int32(3) { + _sqlite3OsUnfetch(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, 0, uintptr(0)) + } + } + /* Copy data from the log to the database file. */ + if rc == SQLITE_OK { + _sqlite3FaultSim(tls, int32(660)) + if (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0 && _walPagesize(tls, pWal) != nBuf { + rc = _sqlite3CorruptError(tls, int32(71830)) + } else { + if eMode2 != -int32(1) { + rc = _walCheckpoint(tls, pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf) + } + } + /* If no error occurred, set the output variables. */ + if rc == SQLITE_OK || rc == int32(SQLITE_BUSY) { + if pnLog != 0 { + **(**int32)(__ccgo_up(pnLog)) = libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) + } + if pnCkpt != 0 { + **(**int32)(__ccgo_up(pnCkpt)) = libc.Int32FromUint32((*TWalCkptInfo)(unsafe.Pointer(_walCkptInfo(tls, pWal))).FnBackfill) + } + } + } + if **(**int32)(__ccgo_up(bp)) != 0 { + /* If a new wal-index header was loaded before the checkpoint was + ** performed, then the pager-cache associated with pWal is now + ** out of date. So zero the cached wal-index header to ensure that + ** next time the pager opens a snapshot on this database it knows that + ** the cache needs to be reset. + */ + libc.X__builtin___memset_chk(tls, pWal+72, 0, uint64(48), ^t__predefined_size_t(0)) + } + /* Release the locks. */ + _sqlite3WalEndWriteTransaction(tls, pWal) + if (*TWal)(unsafe.Pointer(pWal)).FckptLock != 0 { + _walUnlockExclusive(tls, pWal, int32(WAL_CKPT_LOCK), int32(1)) + (*TWal)(unsafe.Pointer(pWal)).FckptLock = uint8(0) + } + if rc == SQLITE_OK && eMode != eMode2 { + v1 = int32(SQLITE_BUSY) + } else { + v1 = rc + } + return v1 +} + +// C documentation +// +// /* Create a snapshot object. The content of a snapshot is opaque to +// ** every other subsystem, so the WAL module can put whatever it needs +// ** in the object. +// */ +func _sqlite3WalSnapshotGet(tls *libc.TLS, pWal uintptr, ppSnapshot uintptr) (r int32) { + var pRet uintptr + var rc int32 + _, _ = pRet, rc + rc = SQLITE_OK + if libc.Xmemcmp(tls, pWal+72+24, uintptr(unsafe.Pointer(&_aZero)), uint64(16)) == 0 { + **(**uintptr)(__ccgo_up(ppSnapshot)) = uintptr(0) + return int32(SQLITE_ERROR) + } + pRet = Xsqlite3_malloc(tls, int32(48)) + if pRet == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memcpy_chk(tls, pRet, pWal+72, uint64(48), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up(ppSnapshot)) = pRet + } + return rc +} + +// C documentation +// +// /* +// ** If any data has been written (but not committed) to the log file, this +// ** function moves the write-pointer back to the start of the transaction. +// ** +// ** Additionally, the callback function is invoked for each frame written +// ** to the WAL since the start of the transaction. If the callback returns +// ** other than SQLITE_OK, it is not invoked again and the error code is +// ** returned to the caller. +// ** +// ** Otherwise, if the callback function does not return an error, this +// ** function returns SQLITE_OK. +// */ +func _sqlite3WalUndo(tls *libc.TLS, pWal uintptr, __ccgo_fp_xUndo uintptr, pUndoCtx uintptr) (r int32) { + var iFrame, iMax TPgno + var rc int32 + _, _, _ = iFrame, iMax, rc + rc = SQLITE_OK + if (*TWal)(unsafe.Pointer(pWal)).FwriteLock != 0 { + iMax = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + /* Restore the clients cache of the wal-index header to the state it + ** was in before the client began writing to the database. + */ + libc.X__builtin___memcpy_chk(tls, pWal+72, _walIndexHdr(tls, pWal), uint64(48), ^t__predefined_size_t(0)) + iFrame = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + uint32(1) + for { + if !(rc == SQLITE_OK && iFrame <= iMax) { + break + } + /* This call cannot fail. Unless the page for which the page number + ** is passed as the second argument is (a) in the cache and + ** (b) has an outstanding reference, then xUndo is either a no-op + ** (if (a) is false) or simply expels the page from the cache (if (b) + ** is false). + ** + ** If the upper layer is doing a rollback, it is guaranteed that there + ** are no outstanding references to any page other than page 1. And + ** page 1 is never written to the log until the transaction is + ** committed. As a result, the call to xUndo may not fail. + */ + rc = (*(*func(*libc.TLS, uintptr, TPgno) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xUndo})))(tls, pUndoCtx, _walFramePgno(tls, pWal, iFrame)) + goto _1 + _1: + ; + iFrame = iFrame + 1 + } + if iMax != (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { + _walCleanupHash(tls, pWal) + } + (*TWal)(unsafe.Pointer(pWal)).FiReCksum = uint32(0) + } + return rc +} + +// C documentation +// +// /* +// ** This function sets the P4 value of an existing OP_Explain opcode to +// ** text describing the loop in pLevel. If the OP_Explain opcode already has +// ** a P4 value, it is freed before it is overwritten. +// */ +func _sqlite3WhereAddExplainText(tls *libc.TLS, pParse uintptr, addr int32, pTabList uintptr, pLevel uintptr, wctrlFlags Tu16) { + bp := tls.Alloc(176) + defer tls.Free(176) + var cRangeOp int8 + var db, pIdx, pItem, pLoop, pOp, zFmt, zRowid, v1, v2 uintptr + var flags Tu32 + var isSearch int32 + var _ /* str at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [100]int8 + _, _, _, _, _, _, _, _, _, _, _, _ = cRangeOp, db, flags, isSearch, pIdx, pItem, pLoop, pOp, zFmt, zRowid, v1, v2 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(v1)).Fexplain) == int32(2) || libc.Bool(0 != 0) { + pOp = _sqlite3VdbeGetOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, addr) + pItem = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Initial space for EQP output string */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + flags = (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags + isSearch = libc.BoolInt32(flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_BTM_LIMIT)|libc.Int32FromInt32(WHERE_TOP_LIMIT)) != uint32(0) || flags&uint32(WHERE_VIRTUALTABLE) == uint32(0) && libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) > 0 || libc.Int32FromUint16(wctrlFlags)&(libc.Int32FromInt32(WHERE_ORDERBY_MIN)|libc.Int32FromInt32(WHERE_ORDERBY_MAX)) != 0) + _sqlite3StrAccumInit(tls, bp, db, bp+32, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TStrAccum)(__ccgo_up(bp))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + if isSearch != 0 { + v1 = __ccgo_ts + 23979 + } else { + v1 = __ccgo_ts + 23986 + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x40000>>18) != 0 { + v2 = __ccgo_ts + 23991 + } else { + v2 = __ccgo_ts + 1702 + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23999, libc.VaList(bp+144, v1, pItem, v2)) + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_VIRTUALTABLE)) == uint32(0) { + zFmt = uintptr(0) + pIdx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + if !((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + if isSearch != 0 { + zFmt = __ccgo_ts + 11936 + } + } else { + if flags&uint32(WHERE_PARTIALIDX) != 0 { + zFmt = __ccgo_ts + 24007 + } else { + if flags&uint32(WHERE_AUTO_INDEX) != 0 { + zFmt = __ccgo_ts + 24040 + } else { + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY)|libc.Int32FromInt32(WHERE_EXPRIDX)) != 0 { + zFmt = __ccgo_ts + 24065 + } else { + zFmt = __ccgo_ts + 24083 + } + } + } + } + if zFmt != 0 { + Xsqlite3_str_append(tls, bp, __ccgo_ts+24092, int32(7)) + Xsqlite3_str_appendf(tls, bp, zFmt, libc.VaList(bp+144, (*TIndex)(unsafe.Pointer(pIdx)).FzName)) + _explainIndexRange(tls, bp, pLoop) + } + } else { + if flags&uint32(WHERE_IPK) != uint32(0) && flags&uint32(WHERE_CONSTRAINT) != uint32(0) { + zRowid = __ccgo_ts + 18310 + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+24100, libc.VaList(bp+144, zRowid)) + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_EQ)|libc.Int32FromInt32(WHERE_COLUMN_IN)) != 0 { + cRangeOp = int8('=') + } else { + if flags&uint32(WHERE_BOTH_LIMIT) == uint32(WHERE_BOTH_LIMIT) { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+24131, libc.VaList(bp+144, zRowid)) + cRangeOp = int8('<') + } else { + if flags&uint32(WHERE_BTM_LIMIT) != 0 { + cRangeOp = int8('>') + } else { + cRangeOp = int8('<') + } + } + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+24141, libc.VaList(bp+144, int32(cRangeOp))) + } else { + if flags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+24146) + if int32(Tu32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x4>>2)) != 0 { + v1 = __ccgo_ts + 24168 + } else { + v1 = __ccgo_ts + 24176 + } + Xsqlite3_str_appendf(tls, bp, v1, libc.VaList(bp+144, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxNum, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxStr)) + } + } + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+24182, 0) + } + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16))) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = _sqlite3StrAccumFinish(tls, bp) + } +} + +// C documentation +// +// /* +// ** Generate the beginning of the loop used for WHERE clause processing. +// ** The return value is a pointer to an opaque structure that contains +// ** information needed to terminate the loop. Later, the calling routine +// ** should invoke sqlite3WhereEnd() with the return value of this function +// ** in order to complete the WHERE clause processing. +// ** +// ** If an error occurs, this routine returns NULL. +// ** +// ** The basic idea is to do a nested loop, one loop for each table in +// ** the FROM clause of a select. (INSERT and UPDATE statements are the +// ** same as a SELECT with only a single table in the FROM clause.) For +// ** example, if the SQL is this: +// ** +// ** SELECT * FROM t1, t2, t3 WHERE ...; +// ** +// ** Then the code generated is conceptually like the following: +// ** +// ** foreach row1 in t1 do \ Code generated +// ** foreach row2 in t2 do |-- by sqlite3WhereBegin() +// ** foreach row3 in t3 do / +// ** ... +// ** end \ Code generated +// ** end |-- by sqlite3WhereEnd() +// ** end / +// ** +// ** Note that the loops might not be nested in the order in which they +// ** appear in the FROM clause if a different order is better able to make +// ** use of indices. Note also that when the IN operator appears in +// ** the WHERE clause, it might result in additional nested loops for +// ** scanning through all values on the right-hand side of the IN. +// ** +// ** There are Btree cursors associated with each table. t1 uses cursor +// ** number pTabList->a[0].iCursor. t2 uses the cursor pTabList->a[1].iCursor. +// ** And so forth. This routine generates code to open those VDBE cursors +// ** and sqlite3WhereEnd() generates the code to close them. +// ** +// ** The code that sqlite3WhereBegin() generates leaves the cursors named +// ** in pTabList pointing at their appropriate entries. The [...] code +// ** can use OP_Column and OP_Rowid opcodes on these cursors to extract +// ** data from the various tables of the loop. +// ** +// ** If the WHERE clause is empty, the foreach loops must each scan their +// ** entire tables. Thus a three-way join is an O(N^3) operation. But if +// ** the tables have indices and there are terms in the WHERE clause that +// ** refer to those indices, a complete table scan can be avoided and the +// ** code will run much faster. Most of the work of this routine is checking +// ** to see if there are indices that can be used to speed up the loop. +// ** +// ** Terms of the WHERE clause are also used to limit which rows actually +// ** make it to the "..." in the middle of the loop. After each "foreach", +// ** terms of the WHERE clause that use only terms in that loop and outer +// ** loops are evaluated and if false a jump is made around all subsequent +// ** inner loops (or around the "..." if the test occurs within the inner- +// ** most loop) +// ** +// ** OUTER JOINS +// ** +// ** An outer join of tables t1 and t2 is conceptually coded as follows: +// ** +// ** foreach row1 in t1 do +// ** flag = 0 +// ** foreach row2 in t2 do +// ** start: +// ** ... +// ** flag = 1 +// ** end +// ** if flag==0 then +// ** move the row2 cursor to a null row +// ** goto start +// ** fi +// ** end +// ** +// ** ORDER BY CLAUSE PROCESSING +// ** +// ** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause +// ** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement +// ** if there is one. If there is no ORDER BY clause or if this routine +// ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL. +// ** +// ** The iIdxCur parameter is the cursor number of an index. If +// ** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index +// ** to use for OR clause processing. The WHERE clause should use this +// ** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is +// ** the first cursor in an array of cursors for all indices. iIdxCur should +// ** be used to compute the appropriate cursor depending on which index is +// ** used. +// */ +func _sqlite3WhereBegin(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWhere uintptr, pOrderBy uintptr, pResultSet uintptr, pSelect uintptr, wctrlFlags Tu16, iAuxArg int32) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addrExplain, bOnerow, iCur, iDb, iIndexCur, iOnce, ii, n, nByteWInfo, nTabList, op, op1, rc, wsFlags, wsFlags1, v1 int32 + var b, notReady TBitmask + var bFordelete Tu8 + var db, p, pInfo, pIx, pJ, pLevel, pLoop, pMaskSet, pPk, pRJ, pSrc, pSubq, pT, pTab, pTabItem, pVTab, pWInfo, pX, v, v7, v8 uintptr + var v19 bool + var _ /* sWLB at bp+0 */ TWhereLoopBuilder + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrExplain, b, bFordelete, bOnerow, db, iCur, iDb, iIndexCur, iOnce, ii, n, nByteWInfo, nTabList, notReady, op, op1, p, pInfo, pIx, pJ, pLevel, pLoop, pMaskSet, pPk, pRJ, pSrc, pSubq, pT, pTab, pTabItem, pVTab, pWInfo, pX, rc, v, wsFlags, wsFlags1, v1, v19, v7, v8 /* Will become the return value of this function */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Return code */ + bFordelete = uint8(0) /* OPFLAG_FORDELETE or zero, as appropriate */ + /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */ + /* Variable initialization */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ + if pOrderBy != 0 && (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + pOrderBy = uintptr(0) + wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & ^libc.Int32FromInt32(WHERE_WANT_DISTINCT)) + wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) | libc.Int32FromInt32(WHERE_KEEP_ALL_JOINS)) /* Disable omit-noop-join opt */ + } + /* The number of tables in the FROM clause is limited by the number of + ** bits in a Bitmask + */ + if (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc > libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24426, libc.VaList(bp+64, libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)))) + return uintptr(0) + } + /* This function normally generates a nested loop for all tables in + ** pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should + ** only generate code for the first table in pTabList and assume that + ** any cursors associated with subsequent tables are uninitialized. + */ + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) != 0 { + v1 = int32(1) + } else { + v1 = (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc + } + nTabList = v1 + /* Allocate and initialize the WhereInfo structure that will become the + ** return value. A single allocation is used to store the WhereInfo + ** struct, the contents of WhereInfo.a[], the WhereClause structure + ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte + ** field (type Bitmask) it must be aligned on an 8-byte boundary on + ** some architectures. Hence the ROUND8() below. + */ + nByteWInfo = libc.Int32FromUint64((uint64(libc.UintptrFromInt32(0)+856) + libc.Uint64FromInt32(nTabList)*libc.Uint64FromInt64(112) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + pWInfo = _sqlite3DbMallocRawNN(tls, db, uint64(libc.Uint64FromInt32(nByteWInfo)+uint64(104))) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3DbFree(tls, db, pWInfo) + pWInfo = uintptr(0) + goto whereBeginError + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse = pParse + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList = pTabList + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pOrderBy + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet = pResultSet + v1 = -libc.Int32FromInt32(1) + **(**int32)(__ccgo_up(pWInfo + 40 + 1*4)) = v1 + **(**int32)(__ccgo_up(pWInfo + 40)) = v1 + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel = libc.Uint8FromInt32(nTabList) + v1 = _sqlite3VdbeMakeLabel(tls, pParse) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiContinue = v1 + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak = v1 + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags = wctrlFlags + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiLimit = int16(iAuxArg) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop = int32((*TParse)(unsafe.Pointer(pParse)).FnQueryLoop) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect = pSelect + libc.X__builtin___memset_chk(tls, pWInfo+65, 0, uint64(libc.UintptrFromInt32(0)+104)-uint64(libc.UintptrFromInt32(0)+65), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, pWInfo+856, 0, uint64(104)+libc.Uint64FromInt32(nTabList)*uint64(112), ^t__predefined_size_t(0)) + /* ONEPASS defaults to OFF */ + pMaskSet = pWInfo + 592 + (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn = 0 + **(**int32)(__ccgo_up(pMaskSet + 8)) = -int32(99) /* Initialize ix[0] to a value that can never be + ** a valid cursor number, to avoid an initial + ** test for pMaskSet->n==0 in sqlite3WhereGetMask() */ + (**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpWInfo = pWInfo + (**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpWC = pWInfo + 104 + (**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpNew = pWInfo + uintptr(nByteWInfo) + _whereLoopInit(tls, (**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpNew) + /* Split the WHERE clause into separate subexpressions where each + ** subexpression is separated by an AND operator. + */ + _sqlite3WhereClauseInit(tls, pWInfo+104, pWInfo) + _sqlite3WhereSplit(tls, pWInfo+104, pWhere, uint8(TK_AND)) + /* Special case: No FROM clause + */ + if nTabList == 0 { + if pOrderBy != 0 { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = int8((*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) + } + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DistinctOpt)) == uint32(0) { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_UNIQUE) + } + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect != 0 && (*TSelect)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FselFlags&uint32(SF_MultiValue) == uint32(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+24454, 0) + } + } else { + /* Assign a bit from the bitmask to every term in the FROM clause. + ** + ** The N-th term of the FROM clause is assigned a bitmask of 1<nSrc tables in + ** pTabList, not just the first nTabList tables. nTabList is normally + ** equal to pTabList->nSrc but might be shortened to 1 if the + ** WHERE_OR_SUBCLAUSE flag is set. + */ + ii = 0 + for { + _createMask(tls, pMaskSet, (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(ii)*80))).FiCursor) + _sqlite3WhereTabFuncArgs(tls, pParse, pTabList+8+uintptr(ii)*80, pWInfo+104) + goto _5 + _5: + ; + ii = ii + 1 + v1 = ii + if !(v1 < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + } + } + /* Analyze all of the subexpressions. */ + _sqlite3WhereExprAnalyze(tls, pTabList, pWInfo+104) + if pSelect != 0 && (*TSelect)(unsafe.Pointer(pSelect)).FpLimit != 0 { + _sqlite3WhereAddLimit(tls, pWInfo+104, pSelect) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto whereBeginError + } + /* The False-WHERE-Term-Bypass optimization: + ** + ** If there are WHERE terms that are false, then no rows will be output, + ** so skip over all of the code generated here. + ** + ** Conditions: + ** + ** (1) The WHERE term must not refer to any tables in the join. + ** (2) The term must not come from an ON clause on the + ** right-hand side of a LEFT or FULL JOIN. + ** (3) The term must not come from an ON clause, or there must be + ** no RIGHT or FULL OUTER joins in pTabList. + ** (4) If the expression contains non-deterministic functions + ** that are not within a sub-select. This is not required + ** for correctness but rather to preserves SQLite's legacy + ** behaviour in the following two cases: + ** + ** WHERE random()>0; -- eval random() once per row + ** WHERE (SELECT random())>0; -- eval random() just once overall + ** + ** Note that the Where term need not be a constant in order for this + ** optimization to apply, though it does need to be constant relative to + ** the current subquery (condition 1). The term might include variables + ** from outer queries so that the value of the term changes from one + ** invocation of the current subquery to the next. + */ + ii = 0 + for { + if !(ii < (*TWhereClause)(unsafe.Pointer((**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpWC)).FnBase) { + break + } + pT = (*TWhereClause)(unsafe.Pointer((**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpWC)).Fa + uintptr(ii)*56 /* The expression of pT */ + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pT)).FwtFlags)&int32(TERM_VIRTUAL) != 0 { + goto _6 + } + pX = (*TWhereTerm)(unsafe.Pointer(pT)).FpExpr + if (*TWhereTerm)(unsafe.Pointer(pT)).FprereqAll == uint64(0) && (nTabList == 0 || _exprIsDeterministic(tls, pX) != 0) && !((*TExpr)(unsafe.Pointer(pX)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) != uint32(0) && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0) { + _sqlite3ExprIfFalse(tls, pParse, pX, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak, int32(SQLITE_JUMPIFNULL)) + v7 = pT + 18 + *(*Tu16)(unsafe.Pointer(v7)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v7))) | libc.Int32FromInt32(TERM_CODED)) + } + goto _6 + _6: + ; + ii = ii + 1 + } + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DistinctOpt)) != uint32(0) { + /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via + ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */ + wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & ^libc.Int32FromInt32(WHERE_WANT_DISTINCT)) + v7 = pWInfo + 60 + *(*Tu16)(unsafe.Pointer(v7)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v7))) & ^libc.Int32FromInt32(WHERE_WANT_DISTINCT)) + } else { + if _isDistinctRedundant(tls, pParse, pTabList, pWInfo+104, pResultSet) != 0 { + /* The DISTINCT marking is pointless. Ignore it. */ + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_UNIQUE) + } else { + if pOrderBy == uintptr(0) { + /* Try to ORDER BY the result set to make distinct processing easier */ + v7 = pWInfo + 60 + *(*Tu16)(unsafe.Pointer(v7)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v7))) | libc.Int32FromInt32(WHERE_DISTINCTBY)) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pResultSet + } + } + } + } + /* Construct the WhereLoop objects */ + if nTabList != int32(1) || _whereShortCut(tls, bp) == 0 { + rc = _whereLoopAddAll(tls, bp) + if rc != 0 { + goto whereBeginError + } + /* If one or more WhereTerm.truthProb values were used in estimating + ** loop parameters, but then those truthProb values were subsequently + ** changed based on STAT4 information while computing subsequent loops, + ** then we need to rerun the whole loop building process so that all + ** loops will be built using the revised truthProb values. */ + if libc.Int32FromUint8((**(**TWhereLoopBuilder)(__ccgo_up(bp))).FbldFlags2)&int32(SQLITE_BLDF2_2NDPASS) != 0 { + for (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops != 0 { + p = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops = (*TWhereLoop)(unsafe.Pointer(p)).FpNextLoop + _whereLoopDelete(tls, db, p) + } + rc = _whereLoopAddAll(tls, bp) + if rc != 0 { + goto whereBeginError + } + } + _wherePathSolver(tls, pWInfo, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto whereBeginError + } + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { + _whereInterstageHeuristic(tls, pWInfo) + if int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut) < 0 { + v1 = int32(1) + } else { + v1 = int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut) + int32(1) + } + _wherePathSolver(tls, pWInfo, int16(v1)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto whereBeginError + } + } + /* TUNING: Assume that a DISTINCT clause on a subquery reduces + ** the output size by a factor of 8 (LogEst -30). Search for + ** tag-20250414a to see other cases. + */ + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 { + v7 = pWInfo + 70 + *(*TLogEst)(unsafe.Pointer(v7)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v7))) - libc.Int32FromInt32(30)) + } + } + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ReverseOrder) != uint64(0) { + _whereReverseScanOrder(tls, pWInfo) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto whereBeginError + } + /* Attempt to omit tables from a join that do not affect the result. + ** See the comment on whereOmitNoopJoin() for further information. + ** + ** This query optimization is factored out into a separate "no-inline" + ** procedure to keep the sqlite3WhereBegin() procedure from becoming + ** too large. If sqlite3WhereBegin() becomes too large, that prevents + ** some C-compiler optimizers from in-lining the + ** sqlite3WhereCodeOneLoopStart() procedure, and it is important to + ** in-line sqlite3WhereCodeOneLoopStart() for performance reasons. + */ + notReady = ^libc.Uint64FromInt32(0) + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) >= int32(2) && pResultSet != uintptr(0) && 0 == libc.Int32FromUint16(wctrlFlags)&(libc.Int32FromInt32(WHERE_AGG_DISTINCT)|libc.Int32FromInt32(WHERE_KEEP_ALL_JOINS)) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OmitNoopJoin)) == uint32(0) { + notReady = _whereOmitNoopJoin(tls, pWInfo, notReady) + nTabList = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) + } + /* Check to see if there are any SEARCH loops that might benefit from + ** using a Bloom filter. + */ + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) >= int32(2) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_BloomFilter)) == uint32(0) { + _whereCheckIfBloomFilterIsUseful(tls, pWInfo) + } + v7 = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + 28 + *(*TLogEst)(unsafe.Pointer(v7)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v7))) + int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut)) + /* If the caller is an UPDATE or DELETE statement that is requesting + ** to use a one-pass algorithm, determine if this is appropriate. + ** + ** A one-pass approach can be used if the caller has requested one + ** and either (a) the scan visits at most one row or (b) each + ** of the following are true: + ** + ** * the caller has indicated that a one-pass approach can be used + ** with multiple rows (by setting WHERE_ONEPASS_MULTIROW), and + ** * the table is not a virtual table, and + ** * either the scan does not use the OR optimization or the caller + ** is a DELETE operation (WHERE_DUPLICATES_OK is only specified + ** for DELETE). + ** + ** The last qualification is because an UPDATE statement uses + ** WhereInfo.aiCurOnePass[1] to determine whether or not it really can + ** use a one-pass approach, and this is not set accurately for scans + ** that use the OR optimization. + */ + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_ONEPASS_DESIRED) != 0 { + wsFlags = libc.Int32FromUint32((*TWhereLoop)(unsafe.Pointer((*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856))).FpWLoop)).FwsFlags) + bOnerow = libc.BoolInt32(wsFlags&int32(WHERE_ONEROW) != 0) + if bOnerow != 0 || 0 != libc.Int32FromUint16(wctrlFlags)&int32(WHERE_ONEPASS_MULTIROW) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) && (0 == wsFlags&int32(WHERE_MULTI_OR) || libc.Int32FromUint16(wctrlFlags)&int32(WHERE_DUPLICATES_OK) != 0) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OnePass)) == uint32(0) { + if bOnerow != 0 { + v1 = int32(ONEPASS_SINGLE) + } else { + v1 = int32(ONEPASS_MULTI) + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass = libc.Uint8FromInt32(v1) + if (*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) && wsFlags&int32(WHERE_IDX_ONLY) != 0 { + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_ONEPASS_MULTIROW) != 0 { + bFordelete = uint8(OPFLAG_FORDELETE) + } + (*TWhereLoop)(unsafe.Pointer((*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856))).FpWLoop)).FwsFlags = libc.Uint32FromInt32(wsFlags & ^libc.Int32FromInt32(WHERE_IDX_ONLY)) + } + } + } + /* Open all tables in the pTabList and any indices selected for + ** searching those tables. + */ + ii = 0 + pLevel = pWInfo + 856 + for { + if !(ii < nTabList) { + break + } + pTabItem = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + pTab = (*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk = _sqlite3VdbeMakeLabel(tls, pParse) + if ii == 0 || libc.Int32FromUint8((**(**TSrcItem)(__ccgo_up(pTabItem))).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk + } else { + if (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(ii-int32(1))*112))).FpRJ != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(ii-int32(1))*112))).FaddrBrk + } else { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(ii-int32(1))*112))).FaddrHalt + } + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Ephemeral) != uint32(0) || libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + /* Do nothing */ + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { + pVTab = _sqlite3GetVTable(tls, db, pTab) + iCur = (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor + _sqlite3VdbeAddOp4(tls, v, int32(OP_VOpen), iCur, 0, 0, pVTab, -int32(12)) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + /* noop */ + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IDX_ONLY) == uint32(0) && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) == 0 || libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + op = int32(OP_OpenRead) + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF { + op = int32(OP_OpenWrite) + **(**int32)(__ccgo_up(pWInfo + 40)) = (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor + } + _sqlite3OpenTable(tls, pParse, (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor, iDb, pTab, op) + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF && int32((*TTable)(unsafe.Pointer(pTab)).FnCol) < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(libc.Int32FromInt32(TF_HasGenerated)|libc.Int32FromInt32(TF_WithoutRowid)) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_AUTO_INDEX)|libc.Int32FromInt32(WHERE_BLOOMFILTER)) == uint32(0) { + /* If we know that only a prefix of the record will be used, + ** it is advantageous to reduce the "column count" field in + ** the P4 operand of the OP_OpenRead/Write opcode. */ + b = (*TSrcItem)(unsafe.Pointer(pTabItem)).FcolUsed + n = 0 + for { + if !(b != 0) { + break + } + goto _15 + _15: + ; + b = b >> int32(1) + n = n + 1 + } + _sqlite3VdbeChangeP4(tls, v, -int32(1), uintptr(int64(n)), -int32(3)) + } + _sqlite3VdbeChangeP5(tls, v, uint16(bFordelete)) + if ii >= int32(2) && libc.Int32FromUint8((**(**TSrcItem)(__ccgo_up(pTabItem))).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_LEFT)) == 0 && (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt == (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856))).FaddrHalt { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfEmpty), (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak) + } + } else { + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab)).FzName) + } + } + } + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_INDEXED) != 0 { + pIx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + op1 = int32(OP_OpenRead) + /* iAuxArg is always set to a positive value if ONEPASS is possible */ + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) != 0 { + /* This is one term of an OR-optimization using the PRIMARY KEY of a + ** WITHOUT ROWID table. No need for a separate index */ + iIndexCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur + op1 = 0 + } else { + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF { + pJ = (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab)).FpIndex + iIndexCur = iAuxArg + for pJ != 0 && pJ != pIx { + iIndexCur = iIndexCur + 1 + pJ = (*TIndex)(unsafe.Pointer(pJ)).FpNext + } + op1 = int32(OP_OpenWrite) + **(**int32)(__ccgo_up(pWInfo + 40 + 1*4)) = iIndexCur + } else { + if iAuxArg != 0 && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) != 0 { + iIndexCur = iAuxArg + op1 = int32(OP_ReopenIdx) + } else { + v7 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v7)) + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + iIndexCur = v1 + if int32(uint32(*(*uint16)(unsafe.Pointer(pIx + 100))&0x800>>11)) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_IndexedExpr)) == uint32(0) { + _whereAddIndexedExpr(tls, pParse, pIx, iIndexCur, pTabItem) + } + if (*TIndex)(unsafe.Pointer(pIx)).FpPartIdxWhere != 0 && libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + _wherePartIdxExpr(tls, pParse, pIx, (*TIndex)(unsafe.Pointer(pIx)).FpPartIdxWhere, uintptr(0), iIndexCur, pTabItem) + } + } + } + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = iIndexCur + if op1 != 0 { + _sqlite3VdbeAddOp3(tls, v, op1, iIndexCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIx)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pIx) + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_CONSTRAINT) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_RANGE)|libc.Int32FromInt32(WHERE_SKIPSCAN)) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BIGNULL_SORT) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_SEEKSCAN) == uint32(0) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_ORDERBY_MIN) == 0 && libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) != int32(WHERE_DISTINCT_ORDERED) { + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SEEKEQ)) + } + } + } + if iDb >= 0 { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + } + if v19 = libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0; v19 { + v7 = _sqlite3WhereMalloc(tls, pWInfo, uint64(20)) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ = v7 + } + if v19 && v7 != uintptr(0) { + pRJ = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + v8 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v8)) + *(*int32)(unsafe.Pointer(v8)) = *(*int32)(unsafe.Pointer(v8)) + 1 + (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch = v1 + v7 = pParse + 60 + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + v1 = *(*int32)(unsafe.Pointer(v7)) + (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Blob), int32(65536), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom) + v7 = pParse + 60 + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + v1 = *(*int32)(unsafe.Pointer(v7)) + (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, int32(1)) + pInfo = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(1), 0) + if pInfo != 0 { + *(*uintptr)(unsafe.Pointer(pInfo + 32)) = uintptr(0) + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pInfo)).FaSortFlags)) = uint8(0) + _sqlite3VdbeAppendP4(tls, v, pInfo, -int32(9)) + } + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) + } + **(**Tu32)(__ccgo_up(pLoop + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(WHERE_IDX_ONLY)) + /* The nature of RIGHT JOIN processing is such that it messes up + ** the output order. So omit any ORDER BY/GROUP BY elimination + ** optimizations. We need to do an actual sort for RIGHT JOIN. */ + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = 0 + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_UNORDERED) + } + goto _14 + _14: + ; + ii = ii + 1 + pLevel += 112 + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiTop = _sqlite3VdbeCurrentAddr(tls, v) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto whereBeginError + } + /* Generate the code to do the search. Each iteration of the for + ** loop below generates code for a single nested loop of the VM + ** program. + */ + ii = 0 + for { + if !(ii < nTabList) { + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto whereBeginError + } + pLevel = pWInfo + 856 + uintptr(ii)*112 + wsFlags1 = libc.Int32FromUint32((*TWhereLoop)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags) + pSrc = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x20>>5) != 0 { + iOnce = 0 + pSubq = *(*uintptr)(unsafe.Pointer(pSrc + 72)) + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x10>>4) == 0 { + iOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } else { + iOnce = 0 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) + if iOnce != 0 { + _sqlite3VdbeJumpHere(tls, v, iOnce) + } + } + if wsFlags1&(libc.Int32FromInt32(WHERE_AUTO_INDEX)|libc.Int32FromInt32(WHERE_BLOOMFILTER)) != 0 { + if wsFlags1&int32(WHERE_AUTO_INDEX) != 0 { + _constructAutomaticIndex(tls, pParse, pWInfo+104, notReady, pLevel) + } else { + _sqlite3ConstructBloomFilter(tls, pWInfo, ii, pLevel, notReady) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto whereBeginError + } + } + addrExplain = _sqlite3WhereExplainOneScan(tls, pParse, pTabList, pLevel, wctrlFlags) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBody = _sqlite3VdbeCurrentAddr(tls, v) + notReady = _sqlite3WhereCodeOneLoopStart(tls, pParse, v, pWInfo, ii, pLevel, notReady) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiContinue = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont + if wsFlags1&int32(WHERE_MULTI_OR) == 0 && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) == 0 { + _ = addrExplain + } + goto _26 + _26: + ; + ii = ii + 1 + } + /* Done. */ + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiEndWhere = _sqlite3VdbeCurrentAddr(tls, v) + return pWInfo + /* Jump here if malloc fails */ + goto whereBeginError +whereBeginError: + ; + if pWInfo != 0 { + (*TParse)(unsafe.Pointer(pParse)).FnQueryLoop = int16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop) + _whereInfoFree(tls, db, pWInfo) + } + return uintptr(0) +} + +/* +** Part of sqlite3WhereEnd() will rewrite opcodes to reference the +** index rather than the main table. In SQLITE_DEBUG mode, we want +** to trace those changes if PRAGMA vdbe_addoptrace=on. This routine +** does that. + */ + +// C documentation +// +// /* +// ** Generate code for the start of the iLevel-th loop in the WHERE clause +// ** implementation described by pWInfo. +// */ +func _sqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWInfo uintptr, iLevel int32, pLevel uintptr, notReady TBitmask) (r2 TBitmask) { + bp := tls.Alloc(112) + defer tls.Free(112) + var aMoveOp [4]Tu8 + var addrBrk, addrCont, addrExplain, addrNotFound, addrNxt, addrSeekScan, bRev, endEq, iCache, iCol, iCol1, iCovCur, iCur, iFld, iIdxCur, iIn, iLoop, iLoopBody, iNext, iPk, iPk1, iReg, iReleaseReg, iRetInit, iRowidReg, iSet, iTab, iTarget, iTerm, ii, j, jmp1, jmp11, k, memEndValue, nConstraint, nConstraint1, nExtraReg, nNotReady, nPk, nPk1, omitTable, op, op1, r, r1, r11, regBase, regBignull, regReturn, regRowid, regRowset, regYield, skipLikeAddr, start, startEq, start_constraints, testOp, untestedTerms, v1, v2 int32 + var bSeekPastNull, bStopAtNull, t1, t2 Tu8 + var db, origSrc, pAlt, pAndExpr, pCompare, pCov, pDelete, pE, pE1, pEnd, pExpr, pIdx, pLeft, pLoop, pOp, pOrExpr, pOrTab, pOrTerm, pOrWc, pPk, pPk1, pPk2, pPk3, pRJ, pRJ1, pRangeEnd, pRangeStart, pRight, pRight1, pRight2, pRight3, pStart, pSubLoop, pSubWInfo, pSubq, pTab, pTab1, pTabItem, pTerm, pWC, pX, pX1, t, zEndAff, v4, v8 uintptr + var m TBitmask + var nBtm, nEq, nTop Tu16 + var v6 uint32 + var v15 bool + var _ /* rTemp at bp+0 */ int32 + var _ /* sEAlt at bp+16 */ TExpr + var _ /* zStartAff at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aMoveOp, addrBrk, addrCont, addrExplain, addrNotFound, addrNxt, addrSeekScan, bRev, bSeekPastNull, bStopAtNull, db, endEq, iCache, iCol, iCol1, iCovCur, iCur, iFld, iIdxCur, iIn, iLoop, iLoopBody, iNext, iPk, iPk1, iReg, iReleaseReg, iRetInit, iRowidReg, iSet, iTab, iTarget, iTerm, ii, j, jmp1, jmp11, k, m, memEndValue, nBtm, nConstraint, nConstraint1, nEq, nExtraReg, nNotReady, nPk, nPk1, nTop, omitTable, op, op1, origSrc, pAlt, pAndExpr, pCompare, pCov, pDelete, pE, pE1, pEnd, pExpr, pIdx, pLeft, pLoop, pOp, pOrExpr, pOrTab, pOrTerm, pOrWc, pPk, pPk1, pPk2, pPk3, pRJ, pRJ1, pRangeEnd, pRangeStart, pRight, pRight1, pRight2, pRight3, pStart, pSubLoop, pSubWInfo, pSubq, pTab, pTab1, pTabItem, pTerm, pWC, pX, pX1, r, r1, r11, regBase, regBignull, regReturn, regRowid, regRowset, regYield, skipLikeAddr, start, startEq, start_constraints, t, t1, t2, testOp, untestedTerms, zEndAff, v1, v15, v2, v4, v6, v8 /* Jump here to continue with next cycle */ + iRowidReg = 0 /* Rowid is stored in this register, if not zero */ + iReleaseReg = 0 /* Temp register to free before returning */ + pIdx = uintptr(0) /* Iteration of constraint generator loop */ + pWC = pWInfo + 104 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + pTabItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + iCur = (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor + (*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady = notReady & ^_sqlite3WhereGetMask(tls, pWInfo+592, iCur) + bRev = libc.Int32FromUint64((*TWhereInfo)(unsafe.Pointer(pWInfo)).FrevMask >> iLevel & uint64(1)) + /* Create labels for the "break" and "continue" instructions + ** for the current loop. Jump to addrBrk to break out of a loop. + ** Jump to cont to go immediately to the next iteration of the + ** loop. + ** + ** When there is an IN operator, we also have a "addrNxt" label that + ** means to continue with the next IN value combination. When + ** there are no IN operators in the constraints, the "addrNxt" label + ** is the same as "addrBrk". + */ + v1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt = v1 + addrBrk = v1 + v1 = _sqlite3VdbeMakeLabel(tls, pParse) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont = v1 + addrCont = v1 + /* If this is the right table of a LEFT OUTER JOIN, allocate and + ** initialize a memory cell that records if this table matches any + ** row of the left table of the join. + */ + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom) > 0 && libc.Int32FromUint8((**(**TSrcItem)(__ccgo_up(pTabItem))).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + } + /* Special case of a FROM clause subquery implemented as a co-routine */ + if int32(*(*uint32)(unsafe.Pointer(pTabItem + 24 + 4))&0x40>>6) != 0 { + pSubq = *(*uintptr)(unsafe.Pointer(pTabItem + 72)) + regYield = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regYield, addrBrk) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Goto) + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { + nConstraint = libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) + iReg = _sqlite3GetTempRange(tls, pParse, nConstraint+int32(2)) + addrNotFound = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk + j = 0 + for { + if !(j < nConstraint) { + break + } + iTarget = iReg + j + int32(2) + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) + if pTerm == uintptr(0) { + goto _5 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_IN) != 0 { + if j <= int32(31) { + v6 = libc.Uint32FromInt32(1) << j + } else { + v6 = uint32(0) + } + if v6&(*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FmHandleIn != 0 { + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iTab = v1 + v8 = pParse + 60 + *(*int32)(unsafe.Pointer(v8)) = *(*int32)(unsafe.Pointer(v8)) + 1 + v2 = *(*int32)(unsafe.Pointer(v8)) + iCache = v2 + _sqlite3CodeRhsOfIN(tls, pParse, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, iTab, 0) + _sqlite3VdbeAddOp3(tls, v, int32(OP_VInitIn), iTab, iTarget, iCache) + } else { + _codeEqualityTerm(tls, pParse, pTerm, pLevel, j, bRev, iTarget) + addrNotFound = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt + } + } else { + pRight = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight + _codeExprOrVector(tls, pParse, pRight, iTarget, int32(1)) + if libc.Int32FromUint8((*TWhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp) == int32(SQLITE_INDEX_CONSTRAINT_OFFSET) && int32(Tu32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x2>>1)) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TSelect)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FiOffset) + } + } + goto _5 + _5: + ; + j = j + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxNum, iReg) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), nConstraint, iReg+int32(1)) + /* The instruction immediately prior to OP_VFilter must be an OP_Integer + ** that sets the "argc" value for xVFilter. This is necessary for + ** resolveP2() to work correctly. See tag-20250207a. */ + if int32(Tu32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x1>>0)) != 0 { + v1 = -int32(7) + } else { + v1 = -int32(1) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_VFilter), iCur, addrNotFound, iReg, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxStr, v1) + libc.SetBitFieldPtr8Uint32(pLoop+24+4, libc.Uint32FromInt32(0), 0, 0x1) + /* An OOM inside of AddOp4(OP_VFilter) instruction above might have freed + ** the u.vtab.idxStr. NULL it out to prevent a use-after-free */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxStr = uintptr(0) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass != 0 { + v1 = int32(OP_Noop) + } else { + v1 = int32(OP_VNext) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = libc.Uint8FromInt32(v1) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = _sqlite3VdbeCurrentAddr(tls, v) + j = 0 + for { + if !(j < nConstraint) { + break + } + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) + if j < int32(16) && libc.Int32FromUint16((*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FomitMask)>>j&int32(1) != 0 { + _disableTerm(tls, pLevel, pTerm) + goto _13 + } + if v15 = libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_IN) != 0; v15 { + if j <= int32(31) { + v6 = libc.Uint32FromInt32(1) << j + } else { + v6 = uint32(0) + } + } + if v15 && v6&(*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FmHandleIn == uint32(0) && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { /* IN loop corresponding to the j-th constraint */ + /* Reload the constraint value into reg[iReg+j+2]. The same value + ** was loaded into the same register prior to the OP_VFilter, but + ** the xFilter implementation might have changed the datatype or + ** encoding of the value in the register, so it *must* be reloaded. + */ + iIn = 0 + for { + if !(iIn < (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn) { + break + } + pOp = _sqlite3VdbeGetOp(tls, v, (**(**TInLoop)(__ccgo_up((*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FaInLoop + uintptr(iIn)*20))).FaddrInTop) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Column) && (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 == iReg+j+int32(2) || libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Rowid) && (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 == iReg+j+int32(2) { + _sqlite3VdbeAddOp3(tls, v, libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode), (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1, (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2, (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3) + break + } + goto _16 + _16: + ; + iIn = iIn + 1 + } + /* Generate code that will continue to the next row if + ** the IN constraint is not satisfied + */ + pCompare = _sqlite3PExpr(tls, pParse, int32(TK_EQ), uintptr(0), uintptr(0)) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + iFld = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField + pLeft = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft + if iFld > 0 { + (*TExpr)(unsafe.Pointer(pCompare)).FpLeft = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 32)) + 8 + uintptr(iFld-int32(1))*32))).FpExpr + } else { + (*TExpr)(unsafe.Pointer(pCompare)).FpLeft = pLeft + } + v4 = _sqlite3Expr(tls, db, int32(TK_REGISTER), uintptr(0)) + pRight1 = v4 + (*TExpr)(unsafe.Pointer(pCompare)).FpRight = v4 + if pRight1 != 0 { + (*TExpr)(unsafe.Pointer(pRight1)).FiTable = iReg + j + int32(2) + _sqlite3ExprIfFalse(tls, pParse, pCompare, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont, int32(SQLITE_JUMPIFNULL)) + } + (*TExpr)(unsafe.Pointer(pCompare)).FpLeft = uintptr(0) + } + _sqlite3ExprDelete(tls, db, pCompare) + } + goto _13 + _13: + ; + j = j + 1 + } + /* These registers need to be preserved in case there is an IN operator + ** loop. So we could deallocate the registers here (and potentially + ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems + ** simpler and safer to simply not reuse the registers. + ** + ** sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2); + */ + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_IN)|libc.Int32FromInt32(WHERE_COLUMN_EQ)) != uint32(0) { + /* Case 2: We can directly reference a single row using an + ** equality comparison against the ROWID field. Or + ** we reference multiple rows using a "rowid IN (...)" + ** construct. + */ + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + iReleaseReg = v1 + iRowidReg = _codeEqualityTerm(tls, pParse, pTerm, pLevel, 0, bRev, iReleaseReg) + if iRowidReg != iReleaseReg { + _sqlite3ReleaseTempReg(tls, pParse, iReleaseReg) + } + addrNxt = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_MustBeInt), iRowidReg, addrNxt) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Filter), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, addrNxt, iRowidReg, int32(1)) + _filterPullDown(tls, pParse, pWInfo, iLevel, addrNxt, notReady) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), iCur, addrNxt, iRowidReg) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Noop) + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_COLUMN_RANGE) != uint32(0) { + /* Case 3: We have an inequality comparison against the ROWID field. + */ + testOp = int32(OP_Noop) + memEndValue = 0 + j = 0 + v4 = libc.UintptrFromInt32(0) + pEnd = v4 + pStart = v4 + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BTM_LIMIT) != 0 { + v1 = j + j = j + 1 + pStart = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(v1)*8)) + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_TOP_LIMIT) != 0 { + v1 = j + j = j + 1 + pEnd = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(v1)*8)) + } + if bRev != 0 { + pTerm = pStart + pStart = pEnd + pEnd = pTerm + } + if pStart != 0 { /* Cursor seek operation */ + /* The following constant maps TK_xx codes into corresponding + ** seek opcodes. It depends on a particular ordering of TK_xx + */ + aMoveOp = [4]Tu8{ + 0: uint8(OP_SeekGT), + 1: uint8(OP_SeekLE), + 2: uint8(OP_SeekLT), + 3: uint8(OP_SeekGE), + } + /* Make sure the ordering.. */ + /* ... of the TK_xx values... */ + /* ... is correct. */ + pX = (*TWhereTerm)(unsafe.Pointer(pStart)).FpExpr + /* transitive constraints */ + if _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pX)).FpRight) != 0 { + v1 = _sqlite3GetTempReg(tls, pParse) + **(**int32)(__ccgo_up(bp)) = v1 + r11 = v1 + _codeExprOrVector(tls, pParse, (*TExpr)(unsafe.Pointer(pX)).FpRight, r11, int32(1)) + op = libc.Int32FromUint8(aMoveOp[(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop)-int32(TK_GT)-int32(1))&int32(0x3)|int32(0x1)]) + } else { + r11 = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pX)).FpRight, bp) + _disableTerm(tls, pLevel, pStart) + op = libc.Int32FromUint8(aMoveOp[libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop)-int32(TK_GT)]) + } + _sqlite3VdbeAddOp3(tls, v, op, iCur, addrBrk, r11) + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp))) + } else { + if bRev != 0 { + v1 = int32(OP_Last) + } else { + v1 = int32(OP_Rewind) + } + _sqlite3VdbeAddOp2(tls, v, v1, iCur, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt) + } + if pEnd != 0 { + pX1 = (*TWhereTerm)(unsafe.Pointer(pEnd)).FpExpr + /* Transitive constraints */ + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + memEndValue = v1 + _codeExprOrVector(tls, pParse, (*TExpr)(unsafe.Pointer(pX1)).FpRight, memEndValue, int32(1)) + if 0 == _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pX1)).FpRight) && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX1)).Fop) == int32(TK_LT) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX1)).Fop) == int32(TK_GT)) { + if bRev != 0 { + v1 = int32(OP_Le) + } else { + v1 = int32(OP_Ge) + } + testOp = v1 + } else { + if bRev != 0 { + v1 = int32(OP_Lt) + } else { + v1 = int32(OP_Gt) + } + testOp = v1 + } + if 0 == _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pX1)).FpRight) { + _disableTerm(tls, pLevel, pEnd) + } + } + start = _sqlite3VdbeCurrentAddr(tls, v) + if bRev != 0 { + v1 = int32(OP_Prev) + } else { + v1 = int32(OP_Next) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = libc.Uint8FromInt32(v1) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = start + if testOp != int32(OP_Noop) { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + iRowidReg = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iCur, iRowidReg) + _sqlite3VdbeAddOp3(tls, v, testOp, memEndValue, addrBrk, iRowidReg) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(libc.Int32FromInt32(SQLITE_AFF_NUMERIC)|libc.Int32FromInt32(SQLITE_JUMPIFNULL))) + } + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_INDEXED) != 0 { + nEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq /* Number of == or IN terms */ + nBtm = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm /* Length of BTM vector */ + nTop = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop /* Base register holding constraint values */ + pRangeStart = uintptr(0) /* Inequality constraint at range start */ + pRangeEnd = uintptr(0) /* The VDBE cursor for the index */ + nExtraReg = 0 /* Affinity for start of range constraint */ + zEndAff = uintptr(0) /* Affinity for end of range constraint */ + bSeekPastNull = uint8(0) /* True to seek past initial nulls */ + bStopAtNull = uint8(0) /* True if we use the index only */ + regBignull = 0 /* big-null flag register */ + addrSeekScan = 0 /* Opcode of the OP_SeekScan, if any */ + pIdx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + iIdxCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + /* Find any inequality constraint terms for the start and end + ** of the range. + */ + j = libc.Int32FromUint16(nEq) + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BTM_LIMIT) != 0 { + v1 = j + j = j + 1 + pRangeStart = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(v1)*8)) + if nExtraReg > libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm) { + v1 = nExtraReg + } else { + v1 = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm) + } + nExtraReg = v1 + /* Like optimization range constraints always occur in pairs */ + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_TOP_LIMIT) != 0 { + v1 = j + j = j + 1 + pRangeEnd = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(v1)*8)) + if nExtraReg > libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop) { + v1 = nExtraReg + } else { + v1 = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop) + } + nExtraReg = v1 + if pRangeStart == uintptr(0) { + j = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(nEq)*2))) + if j >= 0 && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(j)*16 + 8))&0xf>>0)) == 0 || j == -int32(2) { + bSeekPastNull = uint8(1) + } + } + } + /* If the WHERE_BIGNULL_SORT flag is set, then index column nEq uses + ** a non-default "big-null" sort (either ASC NULLS LAST or DESC NULLS + ** FIRST). In both cases separate ordered scans are made of those + ** index entries for which the column is null and for those for which + ** it is not. For an ASC sort, the non-NULL entries are scanned first. + ** For DESC, NULL entries are scanned first. + */ + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_TOP_LIMIT)|libc.Int32FromInt32(WHERE_BTM_LIMIT)) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BIGNULL_SORT) != uint32(0) { + nExtraReg = int32(1) + bSeekPastNull = uint8(1) + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v2 = *(*int32)(unsafe.Pointer(v4)) + v1 = v2 + regBignull = v1 + (*TWhereLevel)(unsafe.Pointer(pLevel)).FregBignull = v1 + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regBignull) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull = _sqlite3VdbeMakeLabel(tls, pParse) + } + /* If we are doing a reverse order scan on an ascending index, or + ** a forward order scan on a descending index, interchange the + ** start and end terms (pRangeStart and pRangeEnd). + */ + if libc.Int32FromUint16(nEq) < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) && bRev == libc.BoolInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) == SQLITE_SO_ASC) { + t = pRangeEnd + pRangeEnd = pRangeStart + pRangeStart = t + t1 = bSeekPastNull + bSeekPastNull = bStopAtNull + bStopAtNull = t1 + t2 = uint8(nBtm) + nBtm = nTop + nTop = uint16(t2) + } + if iLevel > 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_SEEKSCAN) != uint32(0) { + /* In case OP_SeekScan is used, ensure that the index cursor does not + ** point to a valid row for the first iteration of this loop. */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iIdxCur) + } + /* Generate code to evaluate all constraint terms using == or IN + ** and store the values of those terms in an array of registers + ** starting at regBase. + */ + regBase = _codeAllEqualityTerms(tls, pParse, pLevel, bRev, nExtraReg, bp+8) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 && nTop != 0 { + zEndAff = _sqlite3DbStrDup(tls, db, **(**uintptr)(__ccgo_up(bp + 8))+uintptr(nEq)) + } + if regBignull != 0 { + v1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull + } else { + v1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt + } + addrNxt = v1 + startEq = libc.BoolInt32(!(pRangeStart != 0) || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pRangeStart)).FeOperator)&(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) != 0) + endEq = libc.BoolInt32(!(pRangeEnd != 0) || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pRangeEnd)).FeOperator)&(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) != 0) + start_constraints = libc.BoolInt32(pRangeStart != 0 || libc.Int32FromUint16(nEq) > 0) + /* Seek the index cursor to the start of the range. */ + nConstraint1 = libc.Int32FromUint16(nEq) + if pRangeStart != 0 { + pRight2 = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pRangeStart)).FpExpr)).FpRight + _codeExprOrVector(tls, pParse, pRight2, regBase+libc.Int32FromUint16(nEq), libc.Int32FromUint16(nBtm)) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pRangeStart)).FwtFlags)&int32(TERM_VNULL) == 0 && _sqlite3ExprCanBeNull(tls, pRight2) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regBase+libc.Int32FromUint16(nEq), addrNxt) + } + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _updateRangeAffinityStr(tls, pRight2, libc.Int32FromUint16(nBtm), **(**uintptr)(__ccgo_up(bp + 8))+uintptr(nEq)) + } + nConstraint1 = nConstraint1 + libc.Int32FromUint16(nBtm) + if _sqlite3ExprIsVector(tls, pRight2) == 0 { + _disableTerm(tls, pLevel, pRangeStart) + } else { + startEq = int32(1) + } + bSeekPastNull = uint8(0) + } else { + if bSeekPastNull != 0 { + startEq = 0 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regBase+libc.Int32FromUint16(nEq)) + start_constraints = int32(1) + nConstraint1 = nConstraint1 + 1 + } else { + if regBignull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regBase+libc.Int32FromUint16(nEq)) + start_constraints = int32(1) + nConstraint1 = nConstraint1 + 1 + } + } + } + _codeApplyAffinity(tls, pParse, regBase, nConstraint1-libc.Int32FromUint8(bSeekPastNull), **(**uintptr)(__ccgo_up(bp + 8))) + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) > 0 && nConstraint1 == libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) { + /* The skip-scan logic inside the call to codeAllEqualityConstraints() + ** above has already left the cursor sitting on the correct row, + ** so no further seeking is needed */ + } else { + if regBignull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), regBignull) + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Filter), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, addrNxt, regBase, libc.Int32FromUint16(nEq)) + _filterPullDown(tls, pParse, pWInfo, iLevel, addrNxt, notReady) + } + op1 = libc.Int32FromUint8(_aStartOp[start_constraints< int32(1))*int32(4)+int32(2)+bRev]) + _sqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase, nConstraint1-startEq) + } + } + /* Load the value for the inequality constraint at the end of the + ** range (if any). + */ + nConstraint1 = libc.Int32FromUint16(nEq) + if pRangeEnd != 0 { + pRight3 = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pRangeEnd)).FpExpr)).FpRight + _codeExprOrVector(tls, pParse, pRight3, regBase+libc.Int32FromUint16(nEq), libc.Int32FromUint16(nTop)) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pRangeEnd)).FwtFlags)&int32(TERM_VNULL) == 0 && _sqlite3ExprCanBeNull(tls, pRight3) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regBase+libc.Int32FromUint16(nEq), addrNxt) + } + if zEndAff != 0 { + _updateRangeAffinityStr(tls, pRight3, libc.Int32FromUint16(nTop), zEndAff) + _codeApplyAffinity(tls, pParse, regBase+libc.Int32FromUint16(nEq), libc.Int32FromUint16(nTop), zEndAff) + } else { + } + nConstraint1 = nConstraint1 + libc.Int32FromUint16(nTop) + if _sqlite3ExprIsVector(tls, pRight3) == 0 { + _disableTerm(tls, pLevel, pRangeEnd) + } else { + endEq = int32(1) + } + } else { + if bStopAtNull != 0 { + if regBignull == 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regBase+libc.Int32FromUint16(nEq)) + endEq = 0 + } + nConstraint1 = nConstraint1 + 1 + } + } + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _sqlite3DbNNFreeNN(tls, db, **(**uintptr)(__ccgo_up(bp + 8))) + } + if zEndAff != 0 { + _sqlite3DbNNFreeNN(tls, db, zEndAff) + } + /* Top of the loop body */ + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = _sqlite3VdbeCurrentAddr(tls, v) + /* Check if the index cursor is past the end of the range. */ + if nConstraint1 != 0 { + if regBignull != 0 { + /* Except, skip the end-of-range check while doing the NULL-scan */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNot), regBignull, _sqlite3VdbeCurrentAddr(tls, v)+int32(3)) + } + op1 = libc.Int32FromUint8(_aEndOp[bRev*int32(2)+endEq]) + _sqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase, nConstraint1) + if addrSeekScan != 0 { + _sqlite3VdbeJumpHere(tls, v, addrSeekScan) + } + } + if regBignull != 0 { + /* During a NULL-scan, check to see if we have reached the end of + ** the NULLs */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_If), regBignull, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + op1 = libc.Int32FromUint8(_aEndOp[bRev*int32(2)+libc.Int32FromUint8(bSeekPastNull)]) + _sqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase, nConstraint1+libc.Int32FromUint8(bSeekPastNull)) + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_EARLYOUT) != uint32(0) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekHit), iIdxCur, libc.Int32FromUint16(nEq), libc.Int32FromUint16(nEq)) + } + /* Seek the table cursor, if required */ + omitTable = libc.BoolInt32((*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IDX_ONLY) != uint32(0) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(libc.Int32FromInt32(WHERE_OR_SUBCLAUSE)|libc.Int32FromInt32(WHERE_RIGHT_JOIN)) == 0) + if omitTable != 0 { + /* pIdx is a covering index. No need to access the main table. */ + } else { + if (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _codeDeferredSeek(tls, pWInfo, pIdx, iCur, iIdxCur) + } else { + if iCur != iIdxCur { + pPk = _sqlite3PrimaryKeyIndex(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpTable) + iRowidReg = _sqlite3GetTempRange(tls, pParse, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + k = _sqlite3TableColumnToIndex(tls, pIdx, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, k, iRowidReg+j) + goto _40 + _40: + ; + j = j + 1 + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), iCur, addrCont, iRowidReg, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + } + } + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0 { + /* If a partial index is driving the loop, try to eliminate WHERE clause + ** terms from the query that must be true due to the WHERE clause of + ** the partial index. This optimization does not work on an outer join, + ** as shown by: + ** + ** 2019-11-02 ticket 623eff57e76d45f6 (LEFT JOIN) + ** 2025-05-29 forum post 7dee41d32506c4ae (RIGHT JOIN) + */ + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 && (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ == uintptr(0) { + _whereApplyPartialIndexConstraints(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere, iCur, pWC) + } + } else { + /* The following assert() is not a requirement, merely an observation: + ** The OR-optimization doesn't work for the right hand table of + ** a LEFT JOIN: */ + } + /* Record the instruction used to terminate the loop. */ + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_ONEROW) != 0 || (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn != 0 && regBignull == 0 && _whereLoopIsOneRow(tls, pLoop) != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Noop) + } else { + if bRev != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Prev) + } else { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Next) + } + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iIdxCur + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_UNQ_WANTED) != uint32(0) { + v1 = int32(1) + } else { + v1 = 0 + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp3 = libc.Uint8FromInt32(v1) + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_CONSTRAINT) == uint32(0) { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp5 = uint8(SQLITE_STMTSTATUS_FULLSCAN_STEP) + } else { + } + if omitTable != 0 { + pIdx = uintptr(0) + } + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_MULTI_OR) != 0 { /* Shortened table list or OR-clause generation */ + pCov = uintptr(0) + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 /* Potential covering index (or NULL) */ + iCovCur = v1 + v8 = pParse + 60 + *(*int32)(unsafe.Pointer(v8)) = *(*int32)(unsafe.Pointer(v8)) + 1 + v2 = *(*int32)(unsafe.Pointer(v8)) /* Cursor used for index scans (if any) */ + regReturn = v2 /* Register used with OP_Gosub */ + regRowset = 0 /* Register for RowSet object */ + regRowid = 0 /* Register holding rowid */ + iLoopBody = _sqlite3VdbeMakeLabel(tls, pParse) /* Address of regReturn init */ + untestedTerms = 0 /* Loop counter */ + pAndExpr = uintptr(0) /* An ".. AND (...)" expression */ + pTab = (*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) + pOrWc = *(*uintptr)(unsafe.Pointer(pTerm + 32)) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Return) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = regReturn + /* Set up a new SrcList in pOrTab containing the table being scanned + ** by this loop in the a[0] slot and all notReady tables in a[1..] slots. + ** This becomes the SrcList in the recursive call to sqlite3WhereBegin(). + */ + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) > int32(1) || int32(*(*uint32)(unsafe.Pointer(pTabItem + 24 + 4))&0x40000>>18) != 0 { /* Original list of tables */ + nNotReady = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - iLevel - int32(1) + pOrTab = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32(nNotReady+libc.Int32FromInt32(1))*libc.Uint64FromInt64(80))) + if pOrTab == uintptr(0) { + return notReady + } + (*TSrcList)(unsafe.Pointer(pOrTab)).FnAlloc = uint32(libc.Uint8FromInt32(nNotReady + libc.Int32FromInt32(1))) + (*TSrcList)(unsafe.Pointer(pOrTab)).FnSrc = libc.Int32FromUint32((*TSrcList)(unsafe.Pointer(pOrTab)).FnAlloc) + libc.X__builtin___memcpy_chk(tls, pOrTab+8, pTabItem, uint64(80), ^t__predefined_size_t(0)) + origSrc = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + k = int32(1) + for { + if !(k <= nNotReady) { + break + } + libc.X__builtin___memcpy_chk(tls, pOrTab+8+uintptr(k)*80, origSrc+uintptr((**(**TWhereLevel)(__ccgo_up(pLevel + uintptr(k)*112))).FiFrom)*80, uint64(80), ^t__predefined_size_t(0)) + goto _46 + _46: + ; + k = k + 1 + } + /* Clear the fromExists flag on the OR-optimized table entry so that + ** the calls to sqlite3WhereEnd() do not code early-exits after the + ** first row is visited. The early exit applies to this table's + ** overall loop - including the multiple OR branches and any WHERE + ** conditions not passed to the sub-loops - not to the sub-loops. */ + libc.SetBitFieldPtr32Uint32(pOrTab+8+24+4, libc.Uint32FromInt32(0), 18, 0x40000) + } else { + pOrTab = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + } + /* Initialize the rowset register to contain NULL. An SQL NULL is + ** equivalent to an empty rowset. Or, create an ephemeral index + ** capable of holding primary keys in the case of a WITHOUT ROWID. + ** + ** Also initialize regReturn to contain the address of the instruction + ** immediately following the OP_Return at the bottom of the loop. This + ** is required in a few obscure LEFT JOIN cases where control jumps + ** over the top of the loop into the body of it. In this case the + ** correct response for the end-of-loop code (the OP_Return) is to + ** fall through to the next instruction, just as an OP_Next does if + ** called on an uninitialized cursor. + */ + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DUPLICATES_OK) == 0 { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regRowset = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regRowset) + } else { + pPk1 = _sqlite3PrimaryKeyIndex(tls, pTab) + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + regRowset = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), regRowset, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pPk1) + } + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regRowid = v1 + } + iRetInit = _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regReturn) + /* If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y + ** Then for every term xN, evaluate as the subexpression: xN AND y + ** That way, terms in y that are factored into the disjunction will + ** be picked up by the recursive calls to sqlite3WhereBegin() below. + ** + ** Actually, each subexpression is converted to "xN AND w" where w is + ** the "interesting" terms of z - terms that did not originate in the + ** ON or USING clause of a LEFT JOIN, and terms that are usable as + ** indices. + ** + ** This optimization also only applies if the (x1 OR x2 OR ...) term + ** is not contained in the ON clause of a LEFT JOIN. + ** See ticket http://sqlite.org/src/info/f2369304e4 + ** + ** 2022-02-04: Do not push down slices of a row-value comparison. + ** In other words, "w" or "y" may not be a slice of a vector. Otherwise, + ** the initialization of the right-hand operand of the vector comparison + ** might not occur, or might occur only in an OR branch that is not + ** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1. + ** + ** 2022-03-03: Do not push down expressions that involve subqueries. + ** The subquery might get coded as a subroutine. Any table-references + ** in the subquery might be resolved to index-references for the index on + ** the OR branch in which the subroutine is coded. But if the subroutine + ** is invoked from a different OR branch that uses a different index, such + ** index-references will not work. tag-20220303a + ** https://sqlite.org/forum/forumpost/36937b197273d403 + */ + if (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm > int32(1) { + iTerm = 0 + for { + if !(iTerm < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + pExpr = (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iTerm)*56))).FpExpr + if (*TWhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*56 == pTerm { + goto _53 + } + if libc.Int32FromUint16((**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iTerm)*56))).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_CODED)|libc.Int32FromInt32(TERM_SLICE)) != 0 { + goto _53 + } + if libc.Int32FromUint16((**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iTerm)*56))).FeOperator)&int32(WO_ALL) == 0 { + goto _53 + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + goto _53 + } /* tag-20220303a */ + pExpr = _sqlite3ExprDup(tls, db, pExpr, 0) + pAndExpr = _sqlite3ExprAnd(tls, pParse, pAndExpr, pExpr) + goto _53 + _53: + ; + iTerm = iTerm + 1 + } + if pAndExpr != 0 { + /* The extra 0x10000 bit on the opcode is masked off and does not + ** become part of the new Expr.op. However, it does make the + ** op==TK_AND comparison inside of sqlite3PExpr() false, and this + ** prevents sqlite3PExpr() from applying the AND short-circuit + ** optimization, which we do not want here. */ + pAndExpr = _sqlite3PExpr(tls, pParse, libc.Int32FromInt32(TK_AND)|libc.Int32FromInt32(0x10000), uintptr(0), pAndExpr) + } + } + /* Run a separate WHERE clause for each term of the OR clause. After + ** eliminating duplicates from other WHERE clauses, the action for each + ** sub-WHERE clause is to to invoke the main loop body as a subroutine. + */ + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+24222, 0) + ii = 0 + for { + if !(ii < (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm) { + break + } + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr(ii)*56 + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_AND) != 0 { /* Info for single OR-term scan */ + pOrExpr = (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr /* Local copy of OR clause term */ + jmp1 = 0 /* Address of jump operation */ + /* See TH3 vtab25.400 and ticket 614b25314c766238 */ + v4 = _sqlite3ExprDup(tls, db, pOrExpr, 0) + pOrExpr = v4 + pDelete = v4 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pDelete) + goto _54 + } + if pAndExpr != 0 { + (*TExpr)(unsafe.Pointer(pAndExpr)).FpLeft = pOrExpr + pOrExpr = pAndExpr + } + /* Loop through table entries that match term pOrTerm. */ + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+24237, libc.VaList(bp+96, ii+int32(1))) + pSubWInfo = _sqlite3WhereBegin(tls, pParse, pOrTab, pOrExpr, uintptr(0), uintptr(0), uintptr(0), uint16(WHERE_OR_SUBCLAUSE), iCovCur) + if pSubWInfo != 0 { + addrExplain = _sqlite3WhereExplainOneScan(tls, pParse, pOrTab, pSubWInfo+856, uint16(0)) + _ = addrExplain + /* This is the sub-WHERE clause body. First skip over + ** duplicate rows from prior sub-WHERE clauses, and record the + ** rowid (or PRIMARY KEY) for the current row so that the same + ** row will be skipped in subsequent sub-WHERE clauses. + */ + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DUPLICATES_OK) == 0 { + if ii == (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm-int32(1) { + v1 = -int32(1) + } else { + v1 = ii + } + iSet = v1 + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, -int32(1), regRowid) + jmp1 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_RowSetTest), regRowset, 0, regRowid, iSet) + } else { + pPk2 = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk2)).FnKeyCol) + /* Read the PK into an array of temp registers. */ + r = _sqlite3GetTempRange(tls, pParse, nPk) + iPk = 0 + for { + if !(iPk < nPk) { + break + } + iCol = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk2)).FaiColumn + uintptr(iPk)*2))) + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, iCol, r+iPk) + goto _57 + _57: + ; + iPk = iPk + 1 + } + /* Check if the temp table already contains this key. If so, + ** the row has already been included in the result set and + ** can be ignored (by jumping past the Gosub below). Otherwise, + ** insert the key into the temp table and proceed with processing + ** the row. + ** + ** Use some of the same optimizations as OP_RowSetTest: If iSet + ** is zero, assume that the key cannot already be present in + ** the temp table. And if iSet is -1, assume that there is no + ** need to insert the key into the temp table, as it will never + ** be tested for. */ + if iSet != 0 { + jmp1 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), regRowset, 0, r, nPk) + } + if iSet >= 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), r, nPk, regRowid) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), regRowset, regRowid, r, nPk) + if iSet != 0 { + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + } + } + /* Release the array of temp registers */ + _sqlite3ReleaseTempRange(tls, pParse, r, nPk) + } + } + /* Invoke the main loop body as a subroutine */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regReturn, iLoopBody) + /* Jump here (skipping the main loop body subroutine) if the + ** current sub-WHERE row is a duplicate from prior sub-WHEREs. */ + if jmp1 != 0 { + _sqlite3VdbeJumpHere(tls, v, jmp1) + } + /* The pSubWInfo->untestedTerms flag means that this OR term + ** contained one or more AND term from a notReady table. The + ** terms from the notReady table could not be tested and will + ** need to be tested later. + */ + if int32(uint32(*(*uint8)(unsafe.Pointer(pSubWInfo + 68))&0x2>>1)) != 0 { + untestedTerms = int32(1) + } + /* If all of the OR-connected terms are optimized using the same + ** index, and the index is opened using the same cursor number + ** by each call to sqlite3WhereBegin() made by this loop, it may + ** be possible to use that index as a covering index. + ** + ** If the call to sqlite3WhereBegin() above resulted in a scan that + ** uses an index, and this is either the first OR-connected term + ** processed or the index is the same as that used by all previous + ** terms, set pCov to the candidate covering index. Otherwise, set + ** pCov to NULL to indicate that no candidate covering index will + ** be available. + */ + pSubLoop = (*(*TWhereLevel)(unsafe.Pointer(pSubWInfo + 856))).FpWLoop + if (*TWhereLoop)(unsafe.Pointer(pSubLoop)).FwsFlags&uint32(WHERE_INDEXED) != uint32(0) && (ii == 0 || (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pSubLoop + 24))).FpIndex == pCov) && ((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || !(int32(uint32(*(*uint16)(unsafe.Pointer((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pSubLoop + 24))).FpIndex + 100))&0x3>>0)) == libc.Int32FromInt32(SQLITE_IDXTYPE_PRIMARYKEY))) { + pCov = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pSubLoop + 24))).FpIndex + } else { + pCov = uintptr(0) + } + if _sqlite3WhereUsesDeferredSeek(tls, pSubWInfo) != 0 { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 0, 0x1) + } + /* Finish the loop through table entries that match term pOrTerm. */ + _sqlite3WhereEnd(tls, pSubWInfo) + _sqlite3VdbeExplainPop(tls, pParse) + } + _sqlite3ExprDelete(tls, db, pDelete) + } + goto _54 + _54: + ; + ii = ii + 1 + } + _sqlite3VdbeExplainPop(tls, pParse) + *(*uintptr)(unsafe.Pointer(&(*TWhereLevel)(unsafe.Pointer(pLevel)).Fu)) = pCov + if pCov != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = iCovCur + } + if pAndExpr != 0 { + (*TExpr)(unsafe.Pointer(pAndExpr)).FpLeft = uintptr(0) + _sqlite3ExprDelete(tls, db, pAndExpr) + } + _sqlite3VdbeChangeP1(tls, v, iRetInit, _sqlite3VdbeCurrentAddr(tls, v)) + _sqlite3VdbeGoto(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + _sqlite3VdbeResolveLabel(tls, v, iLoopBody) + /* Set the P2 operand of the OP_Return opcode that will end the current + ** loop to point to this spot, which is the top of the next containing + ** loop. The byte-code formatter will use that P2 value as a hint to + ** indent everything in between the this point and the final OP_Return. + ** See tag-20220407a in vdbe.c and shell.c */ + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = _sqlite3VdbeCurrentAddr(tls, v) + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList != pOrTab { + _sqlite3DbFreeNN(tls, db, pOrTab) + } + if !(untestedTerms != 0) { + _disableTerm(tls, pLevel, pTerm) + } + } else { + if int32(*(*uint32)(unsafe.Pointer(pTabItem + 24 + 4))&0x80>>7) != 0 { + /* Tables marked isRecursive have only a single row that is stored in + ** a pseudo-cursor. No need to Rewind or Next such cursors. */ + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Noop) + } else { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = _aStep[bRev] + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = int32(1) + _sqlite3VdbeAddOp2(tls, v, libc.Int32FromUint8(_aStart[bRev]), iCur, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp5 = uint8(SQLITE_STMTSTATUS_FULLSCAN_STEP) + } + } + } + } + } + } + } + /* Insert code to test every subexpression that can be completely + ** computed using the current set of tables. + ** + ** This loop may run between one and three times, depending on the + ** constraints to be generated. The value of stack variable iLoop + ** determines the constraints coded by each iteration, as follows: + ** + ** iLoop==1: Code only expressions that are entirely covered by pIdx. + ** iLoop==2: Code remaining expressions that do not contain correlated + ** sub-queries. + ** iLoop==3: Code all remaining expressions. + ** + ** An effort is made to skip unnecessary iterations of the loop. + ** + ** This optimization of causing simple query restrictions to occur before + ** more complex one is call the "push-down" optimization in MySQL. Here + ** in SQLite, the name is "MySQL push-down", since there is also another + ** totally unrelated optimization called "WHERE-clause push-down". + ** Sometimes the qualifier is omitted, resulting in an ambiguity, so beware. + */ + if pIdx != 0 { + v1 = int32(1) + } else { + v1 = int32(2) + } + iLoop = v1 + for cond := true; cond; cond = iLoop > 0 { + iNext = 0 /* Next value for iLoop */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + j = (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm + for { + if !(j > 0) { + break + } + skipLikeAddr = 0 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_CODED)) != 0 { + goto _59 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady != uint64(0) { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 1, 0x2) + goto _59 + } + pE = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + if !((*TExpr)(unsafe.Pointer(pE)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != libc.Uint32FromInt32(0)) { + /* Defer processing WHERE clause constraints until after outer + ** join processing. tag-20220513a */ + goto _59 + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_LEFT) == int32(JT_LEFT) && !((*TExpr)(unsafe.Pointer(pE)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) { + goto _59 + } else { + m = _sqlite3WhereGetMask(tls, pWInfo+592, *(*int32)(unsafe.Pointer(pE + 52))) + if m&(*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady != 0 { + /* An ON clause that is not ripe */ + goto _59 + } + } + } + } + if iLoop == int32(1) && !(_sqlite3ExprCoveredByIndex(tls, pE, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, pIdx) != 0) { + iNext = int32(2) + goto _59 + } + if iLoop < int32(3) && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VARSELECT) != 0 { + if iNext == 0 { + iNext = int32(3) + } + goto _59 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_LIKECOND) != 0 { + /* If the TERM_LIKECOND flag is set, that means that the range search + ** is sufficient to guarantee that the LIKE operator is true, so we + ** can skip the call to the like(A,B) function. But this only works + ** for strings. So do not skip the call to the function on the pass + ** that compares BLOBs. */ + goto _59 + } + _sqlite3ExprIfFalse(tls, pParse, pE, addrCont, int32(SQLITE_JUMPIFNULL)) + if skipLikeAddr != 0 { + _sqlite3VdbeJumpHere(tls, v, skipLikeAddr) + } + v4 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(TERM_CODED)) + goto _59 + _59: + ; + j = j - 1 + pTerm += 56 + } + iLoop = iNext + } + /* Insert code to test for implied constraints based on transitivity + ** of the "==" operator. + ** + ** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123" + ** and we are coding the t1 loop and the t2 loop has not yet coded, + ** then we cannot use the "t1.a=t2.b" constraint, but we can code + ** the implied "t1.a=123" constraint. + */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + j = (*TWhereClause)(unsafe.Pointer(pWC)).FnBase + for { + if !(j > 0) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_CODED)) != 0 { + goto _61 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) == 0 { + goto _61 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_EQUIV) == 0 { + goto _61 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != iCur { + goto _61 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + goto _61 + } + pE1 = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + pAlt = _sqlite3WhereFindTerm(tls, pWC, iCur, (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn, notReady, libc.Uint32FromInt32(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IN)|libc.Int32FromInt32(WO_IS)), uintptr(0)) + if pAlt == uintptr(0) { + goto _61 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pAlt)).FwtFlags)&int32(TERM_CODED) != 0 { + goto _61 + } + if (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != uint32(0) { + goto _61 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pAlt)).FeOperator)&int32(WO_IN) != 0 && (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAlt)).FpExpr + 32)))).FpEList)).FnExpr > int32(1) { + goto _61 + } + **(**TExpr)(__ccgo_up(bp + 16)) = **(**TExpr)(__ccgo_up((*TWhereTerm)(unsafe.Pointer(pAlt)).FpExpr)) + (**(**TExpr)(__ccgo_up(bp + 16))).FpLeft = (*TExpr)(unsafe.Pointer(pE1)).FpLeft + _sqlite3ExprIfFalse(tls, pParse, bp+16, addrCont, int32(SQLITE_JUMPIFNULL)) + v4 = pAlt + 18 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(TERM_CODED)) + goto _61 + _61: + ; + j = j - 1 + pTerm += 56 + } + /* For a RIGHT OUTER JOIN, record the fact that the current row has + ** been matched at least once. + */ + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 { + jmp11 = 0 + pRJ = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + /* pTab is the right-hand table of the RIGHT JOIN. Generate code that + ** will record that the current row of that table has been matched at + ** least once. This is accomplished by storing the PK for the row in + ** both the iMatch index and the regBloom Bloom filter. + */ + pTab1 = (*(*TSrcItem)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80))).FpSTab + if (*TTable)(unsafe.Pointer(pTab1)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + r1 = _sqlite3GetTempRange(tls, pParse, int32(2)) + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab1, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, -int32(1), r1+int32(1)) + nPk1 = int32(1) + } else { + pPk3 = _sqlite3PrimaryKeyIndex(tls, pTab1) + nPk1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk3)).FnKeyCol) + r1 = _sqlite3GetTempRange(tls, pParse, nPk1+int32(1)) + iPk1 = 0 + for { + if !(iPk1 < nPk1) { + break + } + iCol1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk3)).FaiColumn + uintptr(iPk1)*2))) + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab1, iCur, iCol1, r1+int32(1)+iPk1) + goto _63 + _63: + ; + iPk1 = iPk1 + 1 + } + } + jmp11 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, 0, r1+int32(1), nPk1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), r1+int32(1), nPk1, r1) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, r1, r1+int32(1), nPk1) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom, 0, r1+int32(1), nPk1) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + _sqlite3VdbeJumpHere(tls, v, jmp11) + _sqlite3ReleaseTempRange(tls, pParse, r1, nPk1+int32(1)) + } + /* For a LEFT OUTER JOIN, generate code that will record the fact that + ** at least one row of the right table has matched the left table. + */ + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ == uintptr(0) { + goto code_outer_join_constraints /* WHERE clause constraints */ + } + } + if !((*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0) { + goto _64 + } + /* Create a subroutine used to process all interior loops and code + ** of the RIGHT JOIN. During normal operation, the subroutine will + ** be in-line with the rest of the code. But at the end, a separate + ** loop will run that invokes this subroutine for unmatched rows + ** of pTab, with all tables to left begin set to NULL. + */ + pRJ1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + _sqlite3VdbeAddOp2(tls, v, int32(OP_BeginSubrtn), 0, (*TWhereRightJoin)(unsafe.Pointer(pRJ1)).FregReturn) + (*TWhereRightJoin)(unsafe.Pointer(pRJ1)).FaddrSubrtn = _sqlite3VdbeCurrentAddr(tls, v) + (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn + 1 + /* WHERE clause constraints must be deferred until after outer join + ** row elimination has completed, since WHERE clause constraints apply + ** to the results of the OUTER JOIN. The following loop generates the + ** appropriate WHERE clause constraint checks. tag-20220513a. + */ + goto code_outer_join_constraints +code_outer_join_constraints: + ; + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + j = libc.Int32FromInt32(0) + for { + if !(j < (*TWhereClause)(unsafe.Pointer(pWC)).FnBase) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_CODED)) != 0 { + goto _65 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady != uint64(0) { + goto _65 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + goto _65 + } + _sqlite3ExprIfFalse(tls, pParse, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, int32(SQLITE_JUMPIFNULL)) + v4 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(TERM_CODED)) + goto _65 + _65: + ; + j = j + 1 + pTerm += 56 + } +_64: + ; + return (*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady +} + +// C documentation +// +// /* +// ** Generate the end of the WHERE loop. See comments on +// ** sqlite3WhereBegin() for additional information. +// */ +func _sqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { + var addr, addrIfNull, addrSeek, bEarlyOut, i, iDb, iEnd, j, j1, k, last, m, n, n1, nRJ, op, r1, ws, x, v4 int32 + var db, p, pIdx, pIdx1, pIn, pIx, pLastOp, pLevel, pLoop, pOp, pParse, pPk, pRJ, pSrc, pTab, pTabItem, pTabList, v, v2 uintptr + var v3, v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrIfNull, addrSeek, bEarlyOut, db, i, iDb, iEnd, j, j1, k, last, m, n, n1, nRJ, op, p, pIdx, pIdx1, pIn, pIx, pLastOp, pLevel, pLoop, pOp, pParse, pPk, pRJ, pSrc, pTab, pTabItem, pTabList, r1, v, ws, x, v2, v3, v4, v5 + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pTabList = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + iEnd = _sqlite3VdbeCurrentAddr(tls, v) + nRJ = 0 + addrSeek = 0 + /* Generate loop termination code. + */ + i = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - int32(1) + for { + if !(i >= 0) { + break + } + pLevel = pWInfo + 856 + uintptr(i)*112 + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 { + /* Terminate the subroutine that forms the interior of the loop of + ** the RIGHT JOIN table */ + pRJ = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont) + /* Replace addrCont with a new label that will never be used, just so + ** the subsequent call to resolve pLevel->addrCont will have something + ** to resolve. */ + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont = _sqlite3VdbeMakeLabel(tls, pParse) + (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FendSubrtn = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn, (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FaddrSubrtn, int32(1)) + nRJ = nRJ + 1 + } + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop) != int32(OP_Noop) { + if v3 = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == int32(WHERE_DISTINCT_ORDERED) && i == libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-int32(1) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_INDEXED) != uint32(0); v3 { + v2 = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + pIdx = v2 + } + if v5 = v3 && int32(uint32(*(*uint16)(unsafe.Pointer(v2 + 100))&0x80>>7)) != 0; v5 { + v4 = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnDistinctCol) + n = v4 + } + if v5 && v4 > 0 && int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst + uintptr(n)*2))) >= int32(36) { + r1 = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + addrIfNull = 0 /* Init to avoid false-positive compiler warning */ + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + addrIfNull = _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNullRow), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, r1) + } + j = 0 + for { + if !(j < n) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, j, r1+j) + goto _6 + _6: + ; + j = j + 1 + } + **(**int32)(__ccgo_up(pParse + 60)) += n + int32(1) + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop) == int32(OP_Prev) { + v4 = int32(OP_SeekLT) + } else { + v4 = int32(OP_SeekGT) + } + op = v4 + addrSeek = _sqlite3VdbeAddOp4Int(tls, v, op, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, 0, r1, n) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), int32(1), (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + _sqlite3VdbeJumpHere(tls, v, addrIfNull) + } + } + } + if int32(*(*uint32)(unsafe.Pointer(pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + 24 + 4))&0x40000>>18) != 0 { + /* This is an EXISTS-to-JOIN optimization loop. If this loop sees a + ** successful row, it should break out of itself. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + } + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont) + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop) != int32(OP_Noop) { + _sqlite3VdbeAddOp3(tls, v, libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop), (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2, libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fp3)) + _sqlite3VdbeChangeP5(tls, v, uint16((*TWhereLevel)(unsafe.Pointer(pLevel)).Fp5)) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregBignull != 0 { + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_DecrJumpZero), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregBignull, (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2-int32(1)) + } + if addrSeek != 0 { + _sqlite3VdbeJumpHere(tls, v, addrSeek) + addrSeek = 0 + } + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_ABLE) != uint32(0) && (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn > 0 { + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt) + j1 = (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn + pIn = (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FaInLoop + uintptr(j1-int32(1))*20 + for { + if !(j1 > 0) { + break + } + _sqlite3VdbeJumpHere(tls, v, (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop+int32(1)) + if libc.Int32FromUint8((*TInLoop)(unsafe.Pointer(pIn)).FeEndLoopOp) != int32(OP_Noop) { + if (*TInLoop)(unsafe.Pointer(pIn)).FnPrefix != 0 { + bEarlyOut = libc.BoolInt32((*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_VIRTUALTABLE) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_EARLYOUT) != uint32(0)) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + /* For LEFT JOIN queries, cursor pIn->iCur may not have been + ** opened yet. This occurs for WHERE clauses such as + ** "a = ? AND b IN (...)", where the index is on (a, b). If + ** the RHS of the (a=?) is NULL, then the "b IN (...)" may + ** never have been coded, but the body of the loop run to + ** return the null-row. So, if the cursor is not open yet, + ** jump over the OP_Next or OP_Prev instruction about to + ** be coded. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNotOpen), (*TInLoop)(unsafe.Pointer(pIn)).FiCur, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)+bEarlyOut) + } + if bEarlyOut != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IfNoHope), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, _sqlite3VdbeCurrentAddr(tls, v)+int32(2), (*TInLoop)(unsafe.Pointer(pIn)).FiBase, (*TInLoop)(unsafe.Pointer(pIn)).FnPrefix) + /* Retarget the OP_IsNull against the left operand of IN so + ** it jumps past the OP_IfNoHope. This is because the + ** OP_IsNull also bypasses the OP_Affinity opcode that is + ** required by OP_IfNoHope. */ + _sqlite3VdbeJumpHere(tls, v, (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop+int32(1)) + } + } + _sqlite3VdbeAddOp2(tls, v, libc.Int32FromUint8((*TInLoop)(unsafe.Pointer(pIn)).FeEndLoopOp), (*TInLoop)(unsafe.Pointer(pIn)).FiCur, (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop) + } + _sqlite3VdbeJumpHere(tls, v, (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop-int32(1)) + goto _8 + _8: + ; + j1 = j1 - 1 + pIn -= 20 + } + } + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*TWhereRightJoin)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ)).FregReturn, 0, int32(1)) + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip != 0 { + _sqlite3VdbeGoto(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip) + _sqlite3VdbeJumpHere(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip) + _sqlite3VdbeJumpHere(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip-int32(2)) + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + ws = libc.Int32FromUint32((*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags) + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfPos), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + if ws&int32(WHERE_IDX_ONLY) == 0 { + pSrc = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40>>6) != 0 { + n1 = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FregResult + m = int32((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FnCol) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, n1, n1+m-int32(1)) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) + } + if ws&int32(WHERE_INDEXED) != 0 || ws&int32(WHERE_MULTI_OR) != 0 && *(*uintptr)(unsafe.Pointer(&(*TWhereLevel)(unsafe.Pointer(pLevel)).Fu)) != 0 { + if ws&int32(WHERE_MULTI_OR) != 0 { + pIx = *(*uintptr)(unsafe.Pointer(&(*TWhereLevel)(unsafe.Pointer(pLevel)).Fu)) + iDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIx)).FpSchema) + _sqlite3VdbeAddOp3(tls, v, int32(OP_ReopenIdx), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIx)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pIx) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + } + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop) == int32(OP_Return) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) + } else { + _sqlite3VdbeGoto(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) + } + _sqlite3VdbeJumpHere(tls, v, addr) + } + goto _1 + _1: + ; + i = i - 1 + } + i = 0 + pLevel = pWInfo + 856 + for { + if !(i < libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)) { + break + } + pIdx1 = uintptr(0) + pTabItem = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + pTab = (*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + /* Do RIGHT JOIN processing. Generate code that will output the + ** unmatched rows of the right operand of the RIGHT JOIN with + ** all of the columns of the left operand set to NULL. + */ + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 { + _sqlite3WhereRightJoinLoop(tls, pWInfo, i, pLevel) + goto _9 + } + /* For a co-routine, change all OP_Column references to the table of + ** the co-routine into OP_Copy of result contained in a register. + ** OP_Rowid becomes OP_Null. + */ + if int32(*(*uint32)(unsafe.Pointer(pTabItem + 24 + 4))&0x40>>6) != 0 { + _translateColumnToCopy(tls, pParse, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBody, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTabItem + 72)))).FregResult, 0) + goto _9 + } + /* If this scan uses an index, make VDBE code substitutions to read data + ** from the index instead of from the table where possible. In some cases + ** this optimization prevents the table from ever being read, which can + ** yield a significant performance boost. + ** + ** Calls to the code generator in between sqlite3WhereBegin and + ** sqlite3WhereEnd will have created code that references the table + ** directly. This loop scans all that code looking for opcodes + ** that reference the table and converts them into opcodes that + ** reference the index. + */ + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_INDEXED)|libc.Int32FromInt32(WHERE_IDX_ONLY)) != 0 { + pIdx1 = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_MULTI_OR) != 0 { + pIdx1 = *(*uintptr)(unsafe.Pointer(&(*TWhereLevel)(unsafe.Pointer(pLevel)).Fu)) + } + } + if pIdx1 != 0 && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF || !((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx1)).FpTable)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + last = iEnd + } else { + last = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiEndWhere + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx1 + 100))&0x800>>11)) != 0 { + p = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + for p != 0 { + if (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur == (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur { + (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur = -int32(1) + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur = -int32(1) + } + p = (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext + } + } + k = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBody + int32(1) + pOp = _sqlite3VdbeGetOp(tls, v, k) + pLastOp = pOp + uintptr(last-k)*24 + for { + if (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 != (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur { + /* no-op */ + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Column) || libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Offset) { + x = (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Offset) { + /* Do not need to translate the column number */ + } else { + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + x = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(x)*2))) + } else { + x = int32(_sqlite3StorageColumnToTable(tls, pTab, int16(x))) + } + } + x = _sqlite3TableColumnToIndex(tls, pIdx1, x) + if x >= 0 { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 = x + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY)|libc.Int32FromInt32(WHERE_EXPRIDX)) != 0 { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IDX_ONLY) != 0 { + /* An error. pLoop is supposed to be a covering index loop, + ** and yet the VM code refers to a column of the table that + ** is not part of the index. */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24472, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_INTERNAL) + } else { + /* The WHERE_EXPRIDX flag is set by the planner when it is likely + ** that pLoop is a covering index loop, but it is not possible + ** to be 100% sure. In this case, any OP_Explain opcode + ** corresponding to this loop describes the index as a "COVERING + ** INDEX". But, pOp proves that pLoop is not actually a covering + ** index loop. So clear the WHERE_EXPRIDX flag and rewrite the + ** text that accompanies the OP_Explain opcode, if any. */ + **(**Tu32)(__ccgo_up(pLoop + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(WHERE_EXPRIDX)) + _sqlite3WhereAddExplainText(tls, pParse, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBody-int32(1), pTabList, pLevel, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) + } + } + } + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Rowid) { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + (*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_IdxRowid) + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_IfNullRow) { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + } + } + } + } + goto _11 + _11: + ; + pOp += 24 + v2 = pOp + if !(v2 < pLastOp) { + break + } + } + } + goto _9 + _9: + ; + i = i + 1 + pLevel += 112 + } + /* The "break" point is here, just past the end of the outer loop. + ** Set it. + */ + _sqlite3VdbeResolveLabel(tls, v, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak) + /* Final cleanup + */ + (*TParse)(unsafe.Pointer(pParse)).FnQueryLoop = int16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop) + _whereInfoFree(tls, db, pWInfo) + v2 = pParse + 35 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) - nRJ) + return +} + +/************** End of where.c ***********************************************/ +/************** Begin file window.c ******************************************/ +/* +** 2018 May 08 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* + */ +/* #include "sqliteInt.h" */ + +/* +** SELECT REWRITING +** +** Any SELECT statement that contains one or more window functions in +** either the select list or ORDER BY clause (the only two places window +** functions may be used) is transformed by function sqlite3WindowRewrite() +** in order to support window function processing. For example, with the +** schema: +** +** CREATE TABLE t1(a, b, c, d, e, f, g); +** +** the statement: +** +** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM t1 ORDER BY e; +** +** is transformed to: +** +** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM ( +** SELECT a, e, c, d, b FROM t1 ORDER BY c, d +** ) ORDER BY e; +** +** The flattening optimization is disabled when processing this transformed +** SELECT statement. This allows the implementation of the window function +** (in this case max()) to process rows sorted in order of (c, d), which +** makes things easier for obvious reasons. More generally: +** +** * FROM, WHERE, GROUP BY and HAVING clauses are all moved to +** the sub-query. +** +** * ORDER BY, LIMIT and OFFSET remain part of the parent query. +** +** * Terminals from each of the expression trees that make up the +** select-list and ORDER BY expressions in the parent query are +** selected by the sub-query. For the purposes of the transformation, +** terminals are column references and aggregate functions. +** +** If there is more than one window function in the SELECT that uses +** the same window declaration (the OVER bit), then a single scan may +** be used to process more than one window function. For example: +** +** SELECT max(b) OVER (PARTITION BY c ORDER BY d), +** min(e) OVER (PARTITION BY c ORDER BY d) +** FROM t1; +** +** is transformed in the same way as the example above. However: +** +** SELECT max(b) OVER (PARTITION BY c ORDER BY d), +** min(e) OVER (PARTITION BY a ORDER BY b) +** FROM t1; +** +** Must be transformed to: +** +** SELECT max(b) OVER (PARTITION BY c ORDER BY d) FROM ( +** SELECT e, min(e) OVER (PARTITION BY a ORDER BY b), c, d, b FROM +** SELECT a, e, c, d, b FROM t1 ORDER BY a, b +** ) ORDER BY c, d +** ) ORDER BY e; +** +** so that both min() and max() may process rows in the order defined by +** their respective window declarations. +** +** INTERFACE WITH SELECT.C +** +** When processing the rewritten SELECT statement, code in select.c calls +** sqlite3WhereBegin() to begin iterating through the results of the +** sub-query, which is always implemented as a co-routine. It then calls +** sqlite3WindowCodeStep() to process rows and finish the scan by calling +** sqlite3WhereEnd(). +** +** sqlite3WindowCodeStep() generates VM code so that, for each row returned +** by the sub-query a sub-routine (OP_Gosub) coded by select.c is invoked. +** When the sub-routine is invoked: +** +** * The results of all window-functions for the row are stored +** in the associated Window.regResult registers. +** +** * The required terminal values are stored in the current row of +** temp table Window.iEphCsr. +** +** In some cases, depending on the window frame and the specific window +** functions invoked, sqlite3WindowCodeStep() caches each entire partition +** in a temp table before returning any rows. In other cases it does not. +** This detail is encapsulated within this file, the code generated by +** select.c is the same in either case. +** +** BUILT-IN WINDOW FUNCTIONS +** +** This implementation features the following built-in window functions: +** +** row_number() +** rank() +** dense_rank() +** percent_rank() +** cume_dist() +** ntile(N) +** lead(expr [, offset [, default]]) +** lag(expr [, offset [, default]]) +** first_value(expr) +** last_value(expr) +** nth_value(expr, N) +** +** These are the same built-in window functions supported by Postgres. +** Although the behaviour of aggregate window functions (functions that +** can be used as either aggregates or window functions) allows them to +** be implemented using an API, built-in window functions are much more +** esoteric. Additionally, some window functions (e.g. nth_value()) +** may only be implemented by caching the entire partition in memory. +** As such, some built-in window functions use the same API as aggregate +** window functions and some are implemented directly using VDBE +** instructions. Additionally, for those functions that use the API, the +** window frame is sometimes modified before the SELECT statement is +** rewritten. For example, regardless of the specified window frame, the +** row_number() function always uses: +** +** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW +** +** See sqlite3WindowUpdate() for details. +** +** As well as some of the built-in window functions, aggregate window +** functions min() and max() are implemented using VDBE instructions if +** the start of the window frame is declared as anything other than +** UNBOUNDED PRECEDING. + */ + +// C documentation +// +// /* +// ** Add a single OP_Explain opcode that describes a Bloom filter. +// ** +// ** Or if not processing EXPLAIN QUERY PLAN and not in a SQLITE_DEBUG and/or +// ** SQLITE_ENABLE_STMT_SCANSTATUS build, then OP_Explain opcodes are not +// ** required and this routine is a no-op. +// ** +// ** If an OP_Explain opcode is added to the VM, its address is returned. +// ** Otherwise, if no OP_Explain is coded, zero is returned. +// */ +func _sqlite3WhereExplainBloomFilter(tls *libc.TLS, pParse uintptr, pWInfo uintptr, pLevel uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var db, pItem, pLoop, pTab, v, z, zMsg uintptr + var i, ret int32 + var _ /* str at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [100]int8 + _, _, _, _, _, _, _, _, _ = db, i, pItem, pLoop, pTab, ret, v, z, zMsg + ret = 0 + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* VM being constructed */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Initial space for EQP output string */ + _sqlite3StrAccumInit(tls, bp, db, bp+32, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TStrAccum)(__ccgo_up(bp))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+24193, libc.VaList(bp+144, pItem)) + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != 0 { + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) >= 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23962, libc.VaList(bp+144, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TTable)(unsafe.Pointer(pTab)).FiPKey)*16))).FzCnName)) + } else { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+24214, 0) + } + } else { + i = libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) + for { + if !(i < libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq)) { + break + } + z = _explainIndexColumnName(tls, (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex, i) + if i > libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) { + Xsqlite3_str_append(tls, bp, __ccgo_ts+23951, int32(5)) + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23962, libc.VaList(bp+144, z)) + goto _1 + _1: + ; + i = i + 1 + } + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5601, int32(1)) + zMsg = _sqlite3StrAccumFinish(tls, bp) + ret = _sqlite3VdbeAddOp4(tls, v, int32(OP_Explain), _sqlite3VdbeCurrentAddr(tls, v), (*TParse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -int32(7)) + return ret +} + +// C documentation +// +// /* +// ** Return ONEPASS_OFF (0) if an UPDATE or DELETE statement is unable to +// ** operate directly on the rowids returned by a WHERE clause. Return +// ** ONEPASS_SINGLE (1) if the statement can operation directly because only +// ** a single row is to be changed. Return ONEPASS_MULTI (2) if the one-pass +// ** optimization can be used on multiple +// ** +// ** If the ONEPASS optimization is used (if this routine returns true) +// ** then also write the indices of open cursors used by ONEPASS +// ** into aiCur[0] and aiCur[1]. iaCur[0] gets the cursor of the data +// ** table and iaCur[1] gets the cursor used by an auxiliary index. +// ** Either value may be -1, indicating that cursor is not used. +// ** Any cursors returned will have been opened for writing. +// ** +// ** aiCur[0] and aiCur[1] both get -1 if the where-clause logic is +// ** unable to use the ONEPASS optimization. +// */ +func _sqlite3WhereOkOnePass(tls *libc.TLS, pWInfo uintptr, aiCur uintptr) (r int32) { + libc.X__builtin___memcpy_chk(tls, aiCur, pWInfo+40, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2), ^t__predefined_size_t(0)) + return libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) +} + +func _sqlite3WhereRealloc(tls *libc.TLS, pWInfo uintptr, pOld uintptr, nByte Tu64) (r uintptr) { + var pNew, pOldBlk uintptr + _, _ = pNew, pOldBlk + pNew = _sqlite3WhereMalloc(tls, pWInfo, nByte) + if pNew != 0 && pOld != 0 { + pOldBlk = pOld + pOldBlk -= 16 + libc.X__builtin___memcpy_chk(tls, pNew, pOld, (*TWhereMemBlock)(unsafe.Pointer(pOldBlk)).Fsz, ^t__predefined_size_t(0)) + } + return pNew +} + +// C documentation +// +// /* +// ** Generate the code for the loop that finds all non-matched terms +// ** for a RIGHT JOIN. +// */ +func _sqlite3WhereRightJoinLoop(tls *libc.TLS, pWInfo uintptr, iLevel int32, pLevel uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var addrCont, iCol, iCur, iIdxCur, iPk, jmp, k, nPk, r, v3 int32 + var mAll TBitmask + var pFrom, pLoop, pParse, pPk, pRJ, pRight, pSubWInfo, pSubWhere, pSubq, pTab, pTabItem, pTerm, pWC, v, v4 uintptr + var _ /* uSrc at bp+0 */ struct { + FfromSpace [0][88]Tu8 + FsSrc TSrcList + F__ccgo_pad2 [80]byte + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCont, iCol, iCur, iIdxCur, iPk, jmp, k, mAll, nPk, pFrom, pLoop, pParse, pPk, pRJ, pRight, pSubWInfo, pSubWhere, pSubq, pTab, pTabItem, pTerm, pWC, r, v, v3, v4 + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pRJ = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + pSubWhere = uintptr(0) + pWC = pWInfo + 104 + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + pTabItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + mAll = uint64(0) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+24246, libc.VaList(bp+96, (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab)).FzName)) + k = 0 + for { + if !(k < iLevel) { + break + } + pRight = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(k)*112))).FiFrom)*80 + mAll = mAll | (*TWhereLoop)(unsafe.Pointer((*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(k)*112))).FpWLoop)).FmaskSelf + if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x40>>6) != 0 { + pSubq = *(*uintptr)(unsafe.Pointer(pRight + 72)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (*TSubquery)(unsafe.Pointer(pSubq)).FregResult, (*TSubquery)(unsafe.Pointer(pSubq)).FregResult+(*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(pSubq)).FpSelect)).FpEList)).FnExpr-int32(1)) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(k)*112))).FiTabCur) + iIdxCur = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(k)*112))).FiIdxCur + if iIdxCur != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iIdxCur) + } + goto _1 + _1: + ; + k = k + 1 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_LTORJ) == 0 { + mAll = mAll | (*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf + k = 0 + for { + if !(k < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(k)*56 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_SLICE)) != 0 && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != int32(WO_ROWVAL) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & ^mAll != 0 { + goto _2 + } + if (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + goto _2 + } + pSubWhere = _sqlite3ExprAnd(tls, pParse, pSubWhere, _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, 0)) + goto _2 + _2: + ; + k = k + 1 + } + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur != 0 { + /* pSubWhere may contain expressions that read from an index on the + ** table on the RHS of the right join. All such expressions first test + ** if the index is pointing at a NULL row, and if so, read from the + ** table cursor instead. So ensure that the index cursor really is + ** pointing at a NULL row here, so that no values are read from it during + ** the scan of the RHS of the RIGHT join below. */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + } + pFrom = bp + (*TSrcList)(unsafe.Pointer(pFrom)).FnSrc = int32(1) + (*TSrcList)(unsafe.Pointer(pFrom)).FnAlloc = uint32(1) + libc.X__builtin___memcpy_chk(tls, pFrom+8, pTabItem, uint64(80), ^t__predefined_size_t(0)) + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).Ffg.Fjointype = uint8(0) + (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn + 1 + pSubWInfo = _sqlite3WhereBegin(tls, pParse, pFrom, pSubWhere, uintptr(0), uintptr(0), uintptr(0), uint16(WHERE_RIGHT_JOIN), 0) + if pSubWInfo != 0 { + iCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v3 = *(*int32)(unsafe.Pointer(v4)) + r = v3 + addrCont = _sqlite3WhereContinueLabel(tls, pSubWInfo) + pTab = (*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, -int32(1), r) + nPk = int32(1) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + **(**int32)(__ccgo_up(pParse + 60)) += nPk - int32(1) + iPk = 0 + for { + if !(iPk < nPk) { + break + } + iCol = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(iPk)*2))) + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, iCol, r+iPk) + goto _5 + _5: + ; + iPk = iPk + 1 + } + } + jmp = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Filter), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom, 0, r, nPk) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, addrCont, r, nPk) + _sqlite3VdbeJumpHere(tls, v, jmp) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn, (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FaddrSubrtn) + _sqlite3WhereEnd(tls, pSubWInfo) + } + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSubWhere) + _sqlite3VdbeExplainPop(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn - 1 +} + +// C documentation +// +// /* +// ** For table-valued-functions, transform the function arguments into +// ** new WHERE clause terms. +// ** +// ** Each function argument translates into an equality constraint against +// ** a HIDDEN column in the table. +// */ +func _sqlite3WhereTabFuncArgs(tls *libc.TLS, pParse uintptr, pItem uintptr, pWC uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var j, k, v2 int32 + var joinType Tu32 + var pArgs, pColRef, pRhs, pTab, pTerm uintptr + _, _, _, _, _, _, _, _, _ = j, joinType, k, pArgs, pColRef, pRhs, pTab, pTerm, v2 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x8>>3) == 0 { + return + } + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + pArgs = *(*uintptr)(unsafe.Pointer(pItem + 48)) + if pArgs == uintptr(0) { + return + } + v2 = libc.Int32FromInt32(0) + k = v2 + j = v2 + for { + if !(j < (*TExprList)(unsafe.Pointer(pArgs)).FnExpr) { + break + } + for k < int32((*TTable)(unsafe.Pointer(pTab)).FnCol) && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(k)*16))).FcolFlags)&int32(COLFLAG_HIDDEN) == 0 { + k = k + 1 + } + if k >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24274, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, j)) + return + } + pColRef = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_COLUMN), uintptr(0), 0) + if pColRef == uintptr(0) { + return + } + (*TExpr)(unsafe.Pointer(pColRef)).FiTable = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + v2 = k + k = k + 1 + (*TExpr)(unsafe.Pointer(pColRef)).FiColumn = int16(v2) + *(*uintptr)(unsafe.Pointer(pColRef + 64)) = pTab + **(**TBitmask)(__ccgo_up(pItem + 40)) |= _sqlite3ExprColUsed(tls, pColRef) + pRhs = _sqlite3PExpr(tls, pParse, int32(TK_UPLUS), _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*(*TExprList_item)(unsafe.Pointer(pArgs + 8 + uintptr(j)*32))).FpExpr, 0), uintptr(0)) + pTerm = _sqlite3PExpr(tls, pParse, int32(TK_EQ), pColRef, pRhs) + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + /* testtag-20230227a */ + /* testtag-20230227b */ + joinType = uint32(EP_OuterON) + } else { + /* testtag-20230227c */ + joinType = uint32(EP_InnerON) + } + _sqlite3SetJoinExpr(tls, pTerm, (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor, joinType) + _whereClauseInsert(tls, pWC, pTerm, uint16(TERM_DYNAMIC)) + goto _1 + _1: + ; + j = j + 1 + } +} + +/************** End of whereexpr.c *******************************************/ +/************** Begin file where.c *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This module contains C code that generates VDBE code used to process +** the WHERE clause of SQL statements. This module is responsible for +** generating the code that loops through a table looking for applicable +** rows. Indices are selected and used to speed the search when doing +** so is applicable. Because this module is responsible for selecting +** indices, you might also think of this module as the "query optimizer". + */ +/* #include "sqliteInt.h" */ +/* #include "whereInt.h" */ + +// C documentation +// +// /* +// ** Allocate and return a new Window object describing a Window Definition. +// */ +func _sqlite3WindowAlloc(tls *libc.TLS, pParse uintptr, eType int32, eStart int32, pStart uintptr, eEnd int32, pEnd uintptr, eExclude Tu8) (r uintptr) { + var bImplicitFrame int32 + var pWin uintptr + _, _ = bImplicitFrame, pWin + pWin = uintptr(0) + bImplicitFrame = 0 + /* Parser assures the following: */ + if eType == 0 { + bImplicitFrame = int32(1) + eType = int32(TK_RANGE) + } + /* Additionally, the + ** starting boundary type may not occur earlier in the following list than + ** the ending boundary type: + ** + ** UNBOUNDED PRECEDING + ** PRECEDING + ** CURRENT ROW + ** FOLLOWING + ** UNBOUNDED FOLLOWING + ** + ** The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending + ** boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting + ** frame boundary. + */ + if eStart == int32(TK_CURRENT) && eEnd == int32(TK_PRECEDING) || eStart == int32(TK_FOLLOWING) && (eEnd == int32(TK_PRECEDING) || eEnd == int32(TK_CURRENT)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24781, 0) + goto windowAllocErr + } + pWin = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) + if pWin == uintptr(0) { + goto windowAllocErr + } + (*TWindow)(unsafe.Pointer(pWin)).FeFrmType = libc.Uint8FromInt32(eType) + (*TWindow)(unsafe.Pointer(pWin)).FeStart = libc.Uint8FromInt32(eStart) + (*TWindow)(unsafe.Pointer(pWin)).FeEnd = libc.Uint8FromInt32(eEnd) + if libc.Int32FromUint8(eExclude) == 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_WindowFunc)) != uint32(0) { + eExclude = uint8(TK_NO) + } + (*TWindow)(unsafe.Pointer(pWin)).FeExclude = eExclude + (*TWindow)(unsafe.Pointer(pWin)).FbImplicitFrame = libc.Uint8FromInt32(bImplicitFrame) + (*TWindow)(unsafe.Pointer(pWin)).FpEnd = _sqlite3WindowOffsetExpr(tls, pParse, pEnd) + (*TWindow)(unsafe.Pointer(pWin)).FpStart = _sqlite3WindowOffsetExpr(tls, pParse, pStart) + return pWin + goto windowAllocErr +windowAllocErr: + ; + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pEnd) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pStart) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Attach window object pWin to expression p. +// */ +func _sqlite3WindowAttach(tls *libc.TLS, pParse uintptr, p uintptr, pWin uintptr) { + if p != 0 { + *(*uintptr)(unsafe.Pointer(p + 64)) = pWin + **(**Tu32)(__ccgo_up(p + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc) | libc.Int32FromInt32(EP_FullSize)) + (*TWindow)(unsafe.Pointer(pWin)).FpOwner = p + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_Distinct) != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeFrmType) != int32(TK_FILTER) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24899, 0) + } + } else { + _sqlite3WindowDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pWin) + } +} + +// C documentation +// +// /* +// ** Window *pWin has just been created from a WINDOW clause. Token pBase +// ** is the base window. Earlier windows from the same WINDOW clause are +// ** stored in the linked list starting at pWin->pNextWin. This function +// ** either updates *pWin according to the base specification, or else +// ** leaves an error in pParse. +// */ +func _sqlite3WindowChain(tls *libc.TLS, pParse uintptr, pWin uintptr, pList uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pExist, zErr uintptr + _, _, _ = db, pExist, zErr + if (*TWindow)(unsafe.Pointer(pWin)).FzBase != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pExist = _windowFind(tls, pParse, pList, (*TWindow)(unsafe.Pointer(pWin)).FzBase) + if pExist != 0 { + zErr = uintptr(0) + /* Check for errors */ + if (*TWindow)(unsafe.Pointer(pWin)).FpPartition != 0 { + zErr = __ccgo_ts + 24813 + } else { + if (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy != 0 && (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy != 0 { + zErr = __ccgo_ts + 24830 + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pExist)).FbImplicitFrame) == 0 { + zErr = __ccgo_ts + 24846 + } + } + } + if zErr != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24866, libc.VaList(bp+8, zErr, (*TWindow)(unsafe.Pointer(pWin)).FzBase)) + } else { + (*TWindow)(unsafe.Pointer(pWin)).FpPartition = _sqlite3ExprListDup(tls, db, (*TWindow)(unsafe.Pointer(pExist)).FpPartition, 0) + if (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy != 0 { + (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy = _sqlite3ExprListDup(tls, db, (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy, 0) + } + _sqlite3DbFree(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FzBase) + (*TWindow)(unsafe.Pointer(pWin)).FzBase = uintptr(0) + } + } + } +} + +// C documentation +// +// /* +// ** sqlite3WhereBegin() has already been called for the SELECT statement +// ** passed as the second argument when this function is invoked. It generates +// ** code to populate the Window.regResult register for each window function +// ** and invoke the sub-routine at instruction addrGosub once for each row. +// ** sqlite3WhereEnd() is always called before returning. +// ** +// ** This function handles several different types of window frames, which +// ** require slightly different processing. The following pseudo code is +// ** used to implement window frames of the form: +// ** +// ** ROWS BETWEEN PRECEDING AND FOLLOWING +// ** +// ** Other window frame types use variants of the following: +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** +// ** if( first row of partition ){ +// ** // Rewind three cursors, all open on the eph table. +// ** Rewind(csrEnd); +// ** Rewind(csrStart); +// ** Rewind(csrCurrent); +// ** +// ** regEnd = // FOLLOWING expression +// ** regStart = // PRECEDING expression +// ** }else{ +// ** // First time this branch is taken, the eph table contains two +// ** // rows. The first row in the partition, which all three cursors +// ** // currently point to, and the following row. +// ** AGGSTEP +// ** if( (regEnd--)<=0 ){ +// ** RETURN_ROW +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** RETURN ROW +// ** if( csrCurrent is EOF ) break; +// ** if( (regStart--)<=0 ){ +// ** AggInverse(csrStart) +// ** Next(csrStart) +// ** } +// ** } +// ** +// ** The pseudo-code above uses the following shorthand: +// ** +// ** AGGSTEP: invoke the aggregate xStep() function for each window function +// ** with arguments read from the current row of cursor csrEnd, then +// ** step cursor csrEnd forward one row (i.e. sqlite3BtreeNext()). +// ** +// ** RETURN_ROW: return a row to the caller based on the contents of the +// ** current row of csrCurrent and the current state of all +// ** aggregates. Then step cursor csrCurrent forward one row. +// ** +// ** AGGINVERSE: invoke the aggregate xInverse() function for each window +// ** functions with arguments read from the current row of cursor +// ** csrStart. Then step csrStart forward one row. +// ** +// ** There are two other ROWS window frames that are handled significantly +// ** differently from the above - "BETWEEN PRECEDING AND PRECEDING" +// ** and "BETWEEN FOLLOWING AND FOLLOWING". These are special +// ** cases because they change the order in which the three cursors (csrStart, +// ** csrCurrent and csrEnd) iterate through the ephemeral table. Cases that +// ** use UNBOUNDED or CURRENT ROW are much simpler variations on one of these +// ** three. +// ** +// ** ROWS BETWEEN PRECEDING AND PRECEDING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else{ +// ** if( (regEnd--)<=0 ){ +// ** AGGSTEP +// ** } +// ** RETURN_ROW +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** flush: +// ** if( (regEnd--)<=0 ){ +// ** AGGSTEP +// ** } +// ** RETURN_ROW +// ** +// ** +// ** ROWS BETWEEN FOLLOWING AND FOLLOWING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = regEnd - +// ** }else{ +// ** AGGSTEP +// ** if( (regEnd--)<=0 ){ +// ** RETURN_ROW +// ** } +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** if( (regEnd--)<=0 ){ +// ** RETURN_ROW +// ** if( eof ) break; +// ** } +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** if( eof ) break +// ** } +// ** } +// ** while( !eof csrCurrent ){ +// ** RETURN_ROW +// ** } +// ** +// ** For the most part, the patterns above are adapted to support UNBOUNDED by +// ** assuming that it is equivalent to "infinity PRECEDING/FOLLOWING" and +// ** CURRENT ROW by assuming that it is equivalent to "0 PRECEDING/FOLLOWING". +// ** This is optimized of course - branches that will never be taken and +// ** conditions that are always true are omitted from the VM code. The only +// ** exceptional case is: +// ** +// ** ROWS BETWEEN FOLLOWING AND UNBOUNDED FOLLOWING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regStart = +// ** }else{ +// ** AGGSTEP +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** if( eof ) break +// ** } +// ** RETURN_ROW +// ** } +// ** while( !eof csrCurrent ){ +// ** RETURN_ROW +// ** } +// ** +// ** Also requiring special handling are the cases: +// ** +// ** ROWS BETWEEN PRECEDING AND PRECEDING +// ** ROWS BETWEEN FOLLOWING AND FOLLOWING +// ** +// ** when (expr1 < expr2). This is detected at runtime, not by this function. +// ** To handle this case, the pseudo-code programs depicted above are modified +// ** slightly to be: +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** if( regEnd < regStart ){ +// ** RETURN_ROW +// ** delete eph table contents +// ** continue +// ** } +// ** ... +// ** +// ** The new "continue" statement in the above jumps to the next iteration +// ** of the outer loop - the one started by sqlite3WhereBegin(). +// ** +// ** The various GROUPS cases are implemented using the same patterns as +// ** ROWS. The VM code is modified slightly so that: +// ** +// ** 1. The else branch in the main loop is only taken if the row just +// ** added to the ephemeral table is the start of a new group. In +// ** other words, it becomes: +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else if( new group ){ +// ** ... +// ** } +// ** } +// ** +// ** 2. Instead of processing a single row, each RETURN_ROW, AGGSTEP or +// ** AGGINVERSE step processes the current row of the relevant cursor and +// ** all subsequent rows belonging to the same group. +// ** +// ** RANGE window frames are a little different again. As for GROUPS, the +// ** main loop runs once per group only. And RETURN_ROW, AGGSTEP and AGGINVERSE +// ** deal in groups instead of rows. As for ROWS and GROUPS, there are three +// ** basic cases: +// ** +// ** RANGE BETWEEN PRECEDING AND FOLLOWING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else{ +// ** AGGSTEP +// ** while( (csrCurrent.key + regEnd) < csrEnd.key ){ +// ** RETURN_ROW +// ** while( csrStart.key + regStart) < csrCurrent.key ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** RETURN ROW +// ** if( csrCurrent is EOF ) break; +// ** while( csrStart.key + regStart) < csrCurrent.key ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** +// ** In the above notation, "csr.key" means the current value of the ORDER BY +// ** expression (there is only ever 1 for a RANGE that uses an FOLLOWING +// ** or PRECEDING AND PRECEDING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else{ +// ** while( (csrEnd.key + regEnd) <= csrCurrent.key ){ +// ** AGGSTEP +// ** } +// ** while( (csrStart.key + regStart) < csrCurrent.key ){ +// ** AGGINVERSE +// ** } +// ** RETURN_ROW +// ** } +// ** } +// ** flush: +// ** while( (csrEnd.key + regEnd) <= csrCurrent.key ){ +// ** AGGSTEP +// ** } +// ** while( (csrStart.key + regStart) < csrCurrent.key ){ +// ** AGGINVERSE +// ** } +// ** RETURN_ROW +// ** +// ** RANGE BETWEEN FOLLOWING AND FOLLOWING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else{ +// ** AGGSTEP +// ** while( (csrCurrent.key + regEnd) < csrEnd.key ){ +// ** while( (csrCurrent.key + regStart) > csrStart.key ){ +// ** AGGINVERSE +// ** } +// ** RETURN_ROW +// ** } +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** while( (csrCurrent.key + regStart) > csrStart.key ){ +// ** AGGINVERSE +// ** if( eof ) break "while( 1 )" loop. +// ** } +// ** RETURN_ROW +// ** } +// ** while( !eof csrCurrent ){ +// ** RETURN_ROW +// ** } +// ** +// ** The text above leaves out many details. Refer to the code and comments +// ** below for a more complete picture. +// */ +func _sqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uintptr, regGosub int32, addrGosub int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addr, addr1, addrBreak, addrBreak1, addrBreak2, addrBreak3, addrEmpty, addrGe, addrGosubFlush, addrInteger, addrNe, addrNext, addrStart, addrStart1, bRPS, bRPS1, csrInput, csrWrite, iInput, lbl, lbl1, lblWhereEnd, nInput, nPart, nPeer, op, regEnd, regFlushPart, regNew, regNewPart, regNewPeer, regPeer, regRecord, regStart, v1 int32 + var pKeyInfo, pMWin, pOrderBy, pPart, v, v2 uintptr + var _ /* s at bp+0 */ TWindowCodeArg + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addr1, addrBreak, addrBreak1, addrBreak2, addrBreak3, addrEmpty, addrGe, addrGosubFlush, addrInteger, addrNe, addrNext, addrStart, addrStart1, bRPS, bRPS1, csrInput, csrWrite, iInput, lbl, lbl1, lblWhereEnd, nInput, nPart, nPeer, op, pKeyInfo, pMWin, pOrderBy, pPart, regEnd, regFlushPart, regNew, regNewPart, regNewPeer, regPeer, regRecord, regStart, v, v1, v2 + pMWin = (*TSelect)(unsafe.Pointer(p)).FpWin + pOrderBy = (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy + v = _sqlite3GetVdbe(tls, pParse) /* Cursor used to write to eph. table */ + csrInput = (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FiCursor /* Cursor of sub-select */ + nInput = int32((*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab)).FnCol) /* Address of OP_Ne */ + addrGosubFlush = 0 /* Address of OP_Gosub to flush: */ + addrInteger = 0 /* regNew array in record form */ + regNewPeer = 0 /* Peer values for new row (part of regNew) */ + regPeer = 0 /* Peer values for current row */ + regFlushPart = 0 /* Label just before sqlite3WhereEnd() code */ + regStart = 0 /* Value of PRECEDING */ + regEnd = 0 /* Value of FOLLOWING */ + lblWhereEnd = _sqlite3VdbeMakeLabel(tls, pParse) + /* Fill in the context object */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TWindowCodeArg)(__ccgo_up(bp))).FpParse = pParse + (**(**TWindowCodeArg)(__ccgo_up(bp))).FpMWin = pMWin + (**(**TWindowCodeArg)(__ccgo_up(bp))).FpVdbe = v + (**(**TWindowCodeArg)(__ccgo_up(bp))).FregGosub = regGosub + (**(**TWindowCodeArg)(__ccgo_up(bp))).FaddrGosub = addrGosub + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr = (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr + csrWrite = (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr + int32(1) + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fstart.Fcsr = (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr + int32(2) + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Fcsr = (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr + int32(3) + /* Figure out when rows may be deleted from the ephemeral table. There + ** are four options - they may never be deleted (eDelete==0), they may + ** be deleted as soon as they are no longer part of the window frame + ** (eDelete==WINDOW_AGGINVERSE), they may be deleted as after the row + ** has been returned to the caller (WINDOW_RETURN_ROW), or they may + ** be deleted after they enter the frame (WINDOW_AGGSTEP). */ + switch libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) { + case int32(TK_FOLLOWING): + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_RANGE) && _windowExprGtZero(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpStart) != 0 { + (**(**TWindowCodeArg)(__ccgo_up(bp))).FeDelete = int32(WINDOW_RETURN_ROW) + } + case int32(TK_UNBOUNDED): + if _windowCacheFrame(tls, pMWin) == 0 { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_PRECEDING) { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_RANGE) && _windowExprGtZero(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpEnd) != 0 { + (**(**TWindowCodeArg)(__ccgo_up(bp))).FeDelete = int32(WINDOW_AGGSTEP) + } + } else { + (**(**TWindowCodeArg)(__ccgo_up(bp))).FeDelete = int32(WINDOW_RETURN_ROW) + } + } + default: + (**(**TWindowCodeArg)(__ccgo_up(bp))).FeDelete = int32(WINDOW_AGGINVERSE) + break + } + /* Allocate registers for the array of values from the sub-query, the + ** same values in record form, and the rowid used to insert said record + ** into the ephemeral table. */ + regNew = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nInput + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regRecord = v1 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid = v1 + /* If the window frame contains an " PRECEDING" or " FOLLOWING" + ** clause, allocate registers to store the results of evaluating each + ** . */ + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_PRECEDING) || libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regStart = v1 + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_PRECEDING) || libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_FOLLOWING) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regEnd = v1 + } + /* If this is not a "ROWS BETWEEN ..." frame, then allocate arrays of + ** registers to store copies of the ORDER BY expressions (peer values) + ** for the main loop, and for each cursor (start, current and end). */ + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_ROWS) { + if pOrderBy != 0 { + v1 = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr + } else { + v1 = 0 + } + nPeer = v1 + regNewPeer = regNew + (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + regNewPeer = regNewPeer + (*TExprList)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pMWin)).FpPartition)).FnExpr + } + regPeer = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPeer + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fstart.Freg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPeer + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Freg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPeer + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Freg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPeer + } + /* Load the column values for the row returned by the sub-select + ** into an array of registers starting at regNew. Assemble them into + ** a record in register regRecord. */ + iInput = 0 + for { + if !(iInput < nInput) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), csrInput, iInput, regNew+iInput) + goto _10 + _10: + ; + iInput = iInput + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regNew, nInput, regRecord) + /* An input row has just been read into an array of registers starting + ** at regNew. If the window has a PARTITION clause, this block generates + ** VM code to check if the input row is the start of a new partition. + ** If so, it does an OP_Gosub to an address to be filled in later. The + ** address of the OP_Gosub is stored in local variable addrGosubFlush. */ + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + pPart = (*TWindow)(unsafe.Pointer(pMWin)).FpPartition + nPart = (*TExprList)(unsafe.Pointer(pPart)).FnExpr + regNewPart = regNew + (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, pPart, 0, 0) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regFlushPart = v1 + addr = _sqlite3VdbeAddOp3(tls, v, int32(OP_Compare), regNewPart, (*TWindow)(unsafe.Pointer(pMWin)).FregPart, nPart) + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addr+int32(2), addr+int32(4), addr+int32(2)) + addrGosubFlush = _sqlite3VdbeAddOp1(tls, v, int32(OP_Gosub), regFlushPart) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regNewPart, (*TWindow)(unsafe.Pointer(pMWin)).FregPart, nPart-int32(1)) + } + /* Insert the new row into the ephemeral table */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), csrWrite, (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), csrWrite, regRecord, (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid) + addrNe = _sqlite3VdbeAddOp3(tls, v, int32(OP_Ne), (*TWindow)(unsafe.Pointer(pMWin)).FregOne, 0, (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid) + /* This block is run for the first row of each partition */ + (**(**TWindowCodeArg)(__ccgo_up(bp))).FregArg = _windowInitAccum(tls, pParse, pMWin) + if regStart != 0 { + _sqlite3ExprCode(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpStart, regStart) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + v1 = int32(3) + } else { + v1 = 0 + } + _windowCheckValue(tls, pParse, regStart, 0+v1) + } + if regEnd != 0 { + _sqlite3ExprCode(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpEnd, regEnd) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + v1 = int32(3) + } else { + v1 = 0 + } + _windowCheckValue(tls, pParse, regEnd, int32(1)+v1) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_RANGE) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) && regStart != 0 { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + v1 = int32(OP_Ge) + } else { + v1 = int32(OP_Le) + } + op = v1 + addrGe = _sqlite3VdbeAddOp3(tls, v, op, regStart, 0, regEnd) + /* NeverNull because bound */ + /* values previously checked */ + _windowAggFinal(tls, bp, 0) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr) + _windowReturnOneRow(tls, bp) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResetSorter), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, lblWhereEnd) + _sqlite3VdbeJumpHere(tls, v, addrGe) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_RANGE) && regEnd != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Subtract), regStart, regEnd, regStart) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) != int32(TK_UNBOUNDED) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fstart.Fcsr) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Fcsr) + if regPeer != 0 && pOrderBy != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regNewPeer, regPeer, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr-int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regPeer, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fstart.Freg, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr-int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regPeer, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Freg, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr-int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regPeer, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Freg, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr-int32(1)) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, lblWhereEnd) + _sqlite3VdbeJumpHere(tls, v, addrNe) + /* Beginning of the block executed for the second and subsequent rows. */ + if regPeer != 0 { + _windowIfNewPeer(tls, pParse, pOrderBy, regNewPeer, regPeer, lblWhereEnd) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), 0, 0) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) != int32(TK_UNBOUNDED) { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + lbl = _sqlite3VdbeMakeLabel(tls, pParse) + addrNext = _sqlite3VdbeCurrentAddr(tls, v) + _windowCodeRangeTest(tls, bp, int32(OP_Ge), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr, regEnd, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Fcsr, lbl) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrNext) + _sqlite3VdbeResolveLabel(tls, v, lbl) + } else { + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), regEnd, 0) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + } + } + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_PRECEDING) { + bRPS = libc.BoolInt32(libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_PRECEDING) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE)) + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), regEnd, 0) + if bRPS != 0 { + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + } + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + if !(bRPS != 0) { + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + } + } else { + addr1 = 0 + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), 0, 0) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) != int32(TK_UNBOUNDED) { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + lbl1 = 0 + addr1 = _sqlite3VdbeCurrentAddr(tls, v) + if regEnd != 0 { + lbl1 = _sqlite3VdbeMakeLabel(tls, pParse) + _windowCodeRangeTest(tls, bp, int32(OP_Ge), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr, regEnd, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Fcsr, lbl1) + } + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + if regEnd != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addr1) + _sqlite3VdbeResolveLabel(tls, v, lbl1) + } + } else { + if regEnd != 0 { + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfPos), regEnd, 0, int32(1)) + } + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + if regEnd != 0 { + _sqlite3VdbeJumpHere(tls, v, addr1) + } + } + } + } + } + /* End of the main input loop */ + _sqlite3VdbeResolveLabel(tls, v, lblWhereEnd) + _sqlite3WhereEnd(tls, pWInfo) + /* Fall through */ + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + addrInteger = _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regFlushPart) + _sqlite3VdbeJumpHere(tls, v, addrGosubFlush) + } + (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid = 0 + addrEmpty = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), csrWrite) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_PRECEDING) { + bRPS1 = libc.BoolInt32(libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_PRECEDING) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE)) + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), regEnd, 0) + if bRPS1 != 0 { + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + } + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), 0, 0) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + addrStart = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak2 = _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, int32(1)) + addrBreak1 = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, int32(1)) + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_UNBOUNDED) { + addrStart = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak1 = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), regStart, int32(1)) + addrBreak2 = _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), 0, int32(1)) + } else { + /* assert( regStart>=0 ); + ** regEnd = regEnd - regStart; + ** regStart = 0; */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Subtract), regStart, regEnd, regEnd) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regStart) + addrStart = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak1 = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), regEnd, int32(1)) + addrBreak2 = _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, int32(1)) + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrStart) + _sqlite3VdbeJumpHere(tls, v, addrBreak2) + addrStart = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak3 = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrStart) + _sqlite3VdbeJumpHere(tls, v, addrBreak1) + _sqlite3VdbeJumpHere(tls, v, addrBreak3) + } else { + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), 0, 0) + addrStart1 = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, int32(1)) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrStart1) + _sqlite3VdbeJumpHere(tls, v, addrBreak) + } + } + _sqlite3VdbeJumpHere(tls, v, addrEmpty) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResetSorter), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr) + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pMWin)).FregEndRowid) + } + _sqlite3VdbeChangeP1(tls, v, addrInteger, _sqlite3VdbeCurrentAddr(tls, v)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regFlushPart) + } +} + +/************** End of window.c **********************************************/ +/************** Begin file parse.c *******************************************/ +/* This file is automatically generated by Lemon from input grammar +** source file "parse.y". + */ +/* +** 2001-09-15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains SQLite's SQL parser. +** +** The canonical source code to this file ("parse.y") is a Lemon grammar +** file that specifies the input grammar and actions to take while parsing. +** That input file is processed by Lemon to generate a C-language +** implementation of a parser for the given grammar. You might be reading +** this comment as part of the translated C-code. Edits should be made +** to the original parse.y sources. + */ + +/* #include "sqliteInt.h" */ + +/* +** Verify that the pParse->isCreate field is set + */ + +/* +** Disable all error recovery processing in the parser push-down +** automaton. + */ + +/* +** Make yytestcase() the same as testcase() + */ + +/* +** Indicate that sqlite3ParserFree() will never be called with a null +** pointer. + */ + +/* +** In the amalgamation, the parse.c file generated by lemon and the +** tokenize.c file are concatenated. In that case, sqlite3RunParser() +** has access to the the size of the yyParser object and so the parser +** engine can be allocated from stack. In that case, only the +** sqlite3ParserInit() and sqlite3ParserFinalize() routines are invoked +** and the sqlite3ParserAlloc() and sqlite3ParserFree() routines can be +** omitted. + */ + +/* +** Alternative datatype for the argument to the malloc() routine passed +** into sqlite3ParserAlloc(). The default is size_t. + */ + +// C documentation +// +// /* +// ** If the SELECT statement passed as the second argument does not invoke +// ** any SQL window functions, this function is a no-op. Otherwise, it +// ** rewrites the SELECT statement so that window function xStep functions +// ** are invoked in the correct order as described under "SELECT REWRITING" +// ** at the top of this file. +// */ +func _sqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pArgs, pFilter, pGroupBy, pHaving, pMWin, pSort, pSrc, pSub, pTab, pTab2, pWhere, pWin, v, v2 uintptr + var nSave, rc, v1 int32 + var selFlags Tu32 + var _ /* pSublist at bp+0 */ uintptr + var _ /* w at bp+8 */ TWalker + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, nSave, pArgs, pFilter, pGroupBy, pHaving, pMWin, pSort, pSrc, pSub, pTab, pTab2, pWhere, pWin, rc, selFlags, v, v1, v2 + rc = SQLITE_OK + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 && (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_WinRewrite) == uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + v = _sqlite3GetVdbe(tls, pParse) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pSub = uintptr(0) /* The subquery */ + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + pWhere = (*TSelect)(unsafe.Pointer(p)).FpWhere + pGroupBy = (*TSelect)(unsafe.Pointer(p)).FpGroupBy + pHaving = (*TSelect)(unsafe.Pointer(p)).FpHaving + pSort = uintptr(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Expression list for sub-query */ + pMWin = (*TSelect)(unsafe.Pointer(p)).FpWin + selFlags = (*TSelect)(unsafe.Pointer(p)).FselFlags + pTab = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTab == uintptr(0) { + return _sqlite3ErrorToParser(tls, db, int32(SQLITE_NOMEM)) + } + _sqlite3AggInfoPersistWalkerInit(tls, bp+8, pParse) + _sqlite3WalkSelect(tls, bp+8, p) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Aggregate) == uint32(0) { + (**(**TWalker)(__ccgo_up(bp + 8))).FxExprCallback = __ccgo_fp(_disallowAggregatesInOrderByCb) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback = uintptr(0) + _sqlite3WalkExprList(tls, bp+8, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + } + (*TSelect)(unsafe.Pointer(p)).FpSrc = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpWhere = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpGroupBy = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpHaving = uintptr(0) + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Aggregate) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_WinRewrite) + /* Create the ORDER BY clause for the sub-select. This is the concatenation + ** of the window PARTITION and ORDER BY clauses. Then, if this makes it + ** redundant, remove the ORDER BY from the parent SELECT. */ + pSort = _exprListAppendList(tls, pParse, uintptr(0), (*TWindow)(unsafe.Pointer(pMWin)).FpPartition, int32(1)) + pSort = _exprListAppendList(tls, pParse, pSort, (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy, int32(1)) + if pSort != 0 && (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 && (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr <= (*TExprList)(unsafe.Pointer(pSort)).FnExpr { + nSave = (*TExprList)(unsafe.Pointer(pSort)).FnExpr + (*TExprList)(unsafe.Pointer(pSort)).FnExpr = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr + if _sqlite3ExprListCompare(tls, pSort, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, -int32(1)) == 0 { + _sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + } + (*TExprList)(unsafe.Pointer(pSort)).FnExpr = nSave + } + /* Assign a cursor number for the ephemeral table used to buffer rows. + ** The OpenEphemeral instruction is coded later, after it is known how + ** many columns the table will have. */ + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr = v1 + **(**int32)(__ccgo_up(pParse + 56)) += int32(3) + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, (*TSelect)(unsafe.Pointer(p)).FpEList, pTab, bp) + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, pTab, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol = v1 + /* Append the PARTITION BY and ORDER BY expressions to the to the + ** sub-select expression list. They are required to figure out where + ** boundaries for partitions and sets of peer rows lie. */ + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), (*TWindow)(unsafe.Pointer(pMWin)).FpPartition, 0) + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy, 0) + /* Append the arguments passed to each window function to the + ** sub-select expression list. Also allocate two registers for each + ** window function - one for the accumulator, another for interim + ** results. */ + pWin = pMWin + for { + if !(pWin != 0) { + break + } + pArgs = *(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)) + if (*TFuncDef)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpWFunc)).FfuncFlags&uint32(SQLITE_SUBTYPE) != 0 { + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, pArgs, pTab, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pWin)).FiArgCol = v1 + (*TWindow)(unsafe.Pointer(pWin)).FbExprArgs = uint8(1) + } else { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pWin)).FiArgCol = v1 + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pArgs, 0) + } + if (*TWindow)(unsafe.Pointer(pWin)).FpFilter != 0 { + pFilter = _sqlite3ExprDup(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FpFilter, 0) + **(**uintptr)(__ccgo_up(bp)) = _sqlite3ExprListAppend(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pFilter) + } + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pWin)).FregAccum = v1 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pWin)).FregResult = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregAccum) + goto _4 + _4: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + /* If there is no ORDER BY or PARTITION BY clause, and the window + ** function accepts zero arguments, and there are no other columns + ** selected (e.g. "SELECT row_number() OVER () FROM t1"), it is possible + ** that pSublist is still NULL here. Add a constant expression here to + ** keep everything legal in this case. + */ + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3ExprInt32(tls, db, 0)) + } + pSub = _sqlite3SelectNew(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pSrc, pWhere, pGroupBy, pHaving, pSort, uint32(0), uintptr(0)) + (*TSelect)(unsafe.Pointer(p)).FpSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + /* Due to db->mallocFailed test inside + ** of sqlite3DbMallocRawNN() called from + ** sqlite3SrcListAppend() */ + if (*TSelect)(unsafe.Pointer(p)).FpSrc == uintptr(0) { + _sqlite3SelectDelete(tls, db, pSub) + } else { + if _sqlite3SrcItemAttachSubquery(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpSrc+8, pSub, 0) != 0 { + libc.SetBitFieldPtr32Uint32((*TSelect)(unsafe.Pointer(p)).FpSrc+8+24+4, libc.Uint32FromInt32(1), 4, 0x10) + _sqlite3SrcListAssignCursors(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpSrc) + **(**Tu32)(__ccgo_up(pSub + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(SF_Expanded) | libc.Int32FromInt32(SF_OrderByReqd)) + pTab2 = _sqlite3ResultSetOfSelect(tls, pParse, pSub, int8(SQLITE_AFF_NONE)) + **(**Tu32)(__ccgo_up(pSub + 4)) |= selFlags & uint32(SF_Aggregate) + if pTab2 == uintptr(0) { + /* Might actually be some other kind of error, but in that case + ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get + ** the correct error message regardless. */ + rc = int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memcpy_chk(tls, pTab, pTab2, uint64(120), ^t__predefined_size_t(0)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_Ephemeral) + (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab = pTab + pTab = pTab2 + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp + 8))).FxExprCallback = __ccgo_fp(_sqlite3WindowExtraAggFuncDepth) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback = __ccgo_fp(_sqlite3WalkerDepthIncrease) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback2 = __ccgo_fp(_sqlite3WalkerDepthDecrease) + _sqlite3WalkSelect(tls, bp+8, pSub) + } + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } + /* Defer deleting the temporary table pTab because if an error occurred, + ** there could still be references to that table embedded in the + ** result-set or ORDER BY clause of the SELECT statement p. */ + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3DbFree), pTab) + } + return rc +} + +// C documentation +// +// /* +// ** This function is called immediately after resolving the function name +// ** for a window function within a SELECT statement. Argument pList is a +// ** linked list of WINDOW definitions for the current SELECT statement. +// ** Argument pFunc is the function definition just resolved and pWin +// ** is the Window object representing the associated OVER clause. This +// ** function updates the contents of pWin as follows: +// ** +// ** * If the OVER clause referred to a named window (as in "max(x) OVER win"), +// ** search list pList for a matching WINDOW definition, and update pWin +// ** accordingly. If no such WINDOW clause can be found, leave an error +// ** in pParse. +// ** +// ** * If the function is a built-in window function that requires the +// ** window to be coerced (see "BUILT-IN WINDOW FUNCTIONS" at the top +// ** of this file), pWin is updated here. +// */ +func _sqlite3WindowUpdate(tls *libc.TLS, pParse uintptr, pList uintptr, pWin uintptr, pFunc uintptr) { + var aUp [8]struct { + FzFunc uintptr + FeFrmType int32 + FeStart int32 + FeEnd int32 + } + var db, p, v2 uintptr + var i int32 + _, _, _, _, _ = aUp, db, i, p, v2 + if (*TWindow)(unsafe.Pointer(pWin)).FzName != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeFrmType) == 0 { + p = _windowFind(tls, pParse, pList, (*TWindow)(unsafe.Pointer(pWin)).FzName) + if p == uintptr(0) { + return + } + (*TWindow)(unsafe.Pointer(pWin)).FpPartition = _sqlite3ExprListDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWindow)(unsafe.Pointer(p)).FpPartition, 0) + (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy = _sqlite3ExprListDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWindow)(unsafe.Pointer(p)).FpOrderBy, 0) + (*TWindow)(unsafe.Pointer(pWin)).FpStart = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWindow)(unsafe.Pointer(p)).FpStart, 0) + (*TWindow)(unsafe.Pointer(pWin)).FpEnd = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWindow)(unsafe.Pointer(p)).FpEnd, 0) + (*TWindow)(unsafe.Pointer(pWin)).FeStart = (*TWindow)(unsafe.Pointer(p)).FeStart + (*TWindow)(unsafe.Pointer(pWin)).FeEnd = (*TWindow)(unsafe.Pointer(p)).FeEnd + (*TWindow)(unsafe.Pointer(pWin)).FeFrmType = (*TWindow)(unsafe.Pointer(p)).FeFrmType + (*TWindow)(unsafe.Pointer(pWin)).FeExclude = (*TWindow)(unsafe.Pointer(p)).FeExclude + } else { + _sqlite3WindowChain(tls, pParse, pWin, pList) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeFrmType) == int32(TK_RANGE) && ((*TWindow)(unsafe.Pointer(pWin)).FpStart != 0 || (*TWindow)(unsafe.Pointer(pWin)).FpEnd != 0) && ((*TWindow)(unsafe.Pointer(pWin)).FpOrderBy == uintptr(0) || (*TExprList)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOrderBy)).FnExpr != int32(1)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24621, 0) + } else { + if (*TFuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TWindow)(unsafe.Pointer(pWin)).FpFilter != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24692, 0) + } else { + aUp = [8]struct { + FzFunc uintptr + FeFrmType int32 + FeStart int32 + FeEnd int32 + }{ + 0: { + FzFunc: uintptr(unsafe.Pointer(&_row_numberName)), + FeFrmType: int32(TK_ROWS), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_CURRENT), + }, + 1: { + FzFunc: uintptr(unsafe.Pointer(&_dense_rankName)), + FeFrmType: int32(TK_RANGE), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_CURRENT), + }, + 2: { + FzFunc: uintptr(unsafe.Pointer(&_rankName)), + FeFrmType: int32(TK_RANGE), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_CURRENT), + }, + 3: { + FzFunc: uintptr(unsafe.Pointer(&_percent_rankName)), + FeFrmType: int32(TK_GROUPS), + FeStart: int32(TK_CURRENT), + FeEnd: int32(TK_UNBOUNDED), + }, + 4: { + FzFunc: uintptr(unsafe.Pointer(&_cume_distName)), + FeFrmType: int32(TK_GROUPS), + FeStart: int32(TK_FOLLOWING), + FeEnd: int32(TK_UNBOUNDED), + }, + 5: { + FzFunc: uintptr(unsafe.Pointer(&_ntileName)), + FeFrmType: int32(TK_ROWS), + FeStart: int32(TK_CURRENT), + FeEnd: int32(TK_UNBOUNDED), + }, + 6: { + FzFunc: uintptr(unsafe.Pointer(&_leadName)), + FeFrmType: int32(TK_ROWS), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_UNBOUNDED), + }, + 7: { + FzFunc: uintptr(unsafe.Pointer(&_lagName)), + FeFrmType: int32(TK_ROWS), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_CURRENT), + }, + } + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(192)/libc.Uint64FromInt64(24))) { + break + } + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == aUp[i].FzFunc { + _sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FpStart) + _sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FpEnd) + v2 = libc.UintptrFromInt32(0) + (*TWindow)(unsafe.Pointer(pWin)).FpStart = v2 + (*TWindow)(unsafe.Pointer(pWin)).FpEnd = v2 + (*TWindow)(unsafe.Pointer(pWin)).FeFrmType = libc.Uint8FromInt32(aUp[i].FeFrmType) + (*TWindow)(unsafe.Pointer(pWin)).FeStart = libc.Uint8FromInt32(aUp[i].FeStart) + (*TWindow)(unsafe.Pointer(pWin)).FeEnd = libc.Uint8FromInt32(aUp[i].FeEnd) + (*TWindow)(unsafe.Pointer(pWin)).FeExclude = uint8(0) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeStart) == int32(TK_FOLLOWING) { + (*TWindow)(unsafe.Pointer(pWin)).FpStart = _sqlite3ExprInt32(tls, db, int32(1)) + } + break + } + goto _1 + _1: + ; + i = i + 1 + } + } + } + } + (*TWindow)(unsafe.Pointer(pWin)).FpWFunc = pFunc +} + +// C documentation +// +// /* +// ** This routine is invoked once per CTE by the parser while parsing a +// ** WITH clause. The CTE described by the third argument is added to +// ** the WITH clause of the second argument. If the second argument is +// ** NULL, then a new WITH argument is created. +// */ +func _sqlite3WithAdd(tls *libc.TLS, pParse uintptr, pWith uintptr, pCte uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pNew, zName, v3 uintptr + var i, v2 int32 + _, _, _, _, _, _ = db, i, pNew, zName, v2, v3 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pCte == uintptr(0) { + return pWith + } + /* Check that the CTE name is unique within this WITH clause. If + ** not, store an error in the Parse structure. */ + zName = (*TCte)(unsafe.Pointer(pCte)).FzName + if zName != 0 && pWith != 0 { + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer(pWith)).FnCte) { + break + } + if _sqlite3StrICmp(tls, zName, (*(*TCte)(unsafe.Pointer(pWith + 16 + uintptr(i)*48))).FzName) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16628, libc.VaList(bp+8, zName)) + } + goto _1 + _1: + ; + i = i + 1 + } + } + if pWith != 0 { + pNew = _sqlite3DbRealloc(tls, db, pWith, uint64(uint64(libc.UintptrFromInt32(0)+16)+libc.Uint64FromInt32((*TWith)(unsafe.Pointer(pWith)).FnCte+libc.Int32FromInt32(1))*libc.Uint64FromInt64(48))) + } else { + pNew = _sqlite3DbMallocZero(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+16)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(48))) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3CteDelete(tls, db, pCte) + pNew = pWith + } else { + v3 = pNew + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + *(*TCte)(unsafe.Pointer(pNew + 16 + uintptr(v2)*48)) = **(**TCte)(__ccgo_up(pCte)) + _sqlite3DbFree(tls, db, pCte) + } + return pNew +} + +func _sqlite3_geopoly_init(tls *libc.TLS, db uintptr) (r int32) { + var enc, rc int32 + var i uint32 + _, _, _ = enc, i, rc + rc = SQLITE_OK + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(288)/libc.Uint64FromInt64(24) && rc == SQLITE_OK) { + break + } + if _aFunc[i].FbPure != 0 { + enc = libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_INNOCUOUS) + } else { + enc = libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DIRECTONLY) + } + rc = Xsqlite3_create_function(tls, db, _aFunc[i].FzName, int32(_aFunc[i].FnArg), enc, uintptr(0), _aFunc[i].FxFunc, uintptr(0), uintptr(0)) + goto _1 + _1: + ; + i = i + 1 + } + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(24)/libc.Uint64FromInt64(24) && rc == SQLITE_OK) { + break + } + rc = Xsqlite3_create_function(tls, db, _aAgg[i].FzName, int32(1), libc.Int32FromInt32(SQLITE_UTF8)|libc.Int32FromInt32(SQLITE_DETERMINISTIC)|libc.Int32FromInt32(SQLITE_INNOCUOUS), uintptr(0), uintptr(0), _aAgg[i].FxStep, _aAgg[i].FxFinal) + goto _2 + _2: + ; + i = i + 1 + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_module_v2(tls, db, __ccgo_ts+30543, uintptr(unsafe.Pointer(&_geopolyModule)), uintptr(0), uintptr(0)) + } + return rc +} + +// C documentation +// +// /* +// ** This routine is called once for each row in the result table. Its job +// ** is to fill in the TabResult structure appropriately, allocating new +// ** memory as necessary. +// */ +func _sqlite3_get_table_cb(tls *libc.TLS, pArg uintptr, nCol int32, argv uintptr, colv uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azNew, p, z, v3 uintptr + var i, n, need int32 + var v2 Tu32 + _, _, _, _, _, _, _, _ = azNew, i, n, need, p, z, v2, v3 + p = pArg /* A single column of result */ + /* Make sure there is enough space in p->azResult to hold everything + ** we need to remember from this invocation of the callback. + */ + if (*TTabResult)(unsafe.Pointer(p)).FnRow == uint32(0) && argv != uintptr(0) { + need = nCol * int32(2) + } else { + need = nCol + } + if (*TTabResult)(unsafe.Pointer(p)).FnData+libc.Uint32FromInt32(need) > (*TTabResult)(unsafe.Pointer(p)).FnAlloc { + (*TTabResult)(unsafe.Pointer(p)).FnAlloc = (*TTabResult)(unsafe.Pointer(p)).FnAlloc*uint32(2) + libc.Uint32FromInt32(need) + azNew = _sqlite3Realloc(tls, (*TTabResult)(unsafe.Pointer(p)).FazResult, uint64(8)*uint64((*TTabResult)(unsafe.Pointer(p)).FnAlloc)) + if azNew == uintptr(0) { + goto malloc_failed + } + (*TTabResult)(unsafe.Pointer(p)).FazResult = azNew + } + /* If this is the first row, then generate an extra row containing + ** the names of all columns. + */ + if (*TTabResult)(unsafe.Pointer(p)).FnRow == uint32(0) { + (*TTabResult)(unsafe.Pointer(p)).FnColumn = libc.Uint32FromInt32(nCol) + i = 0 + for { + if !(i < nCol) { + break + } + z = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, **(**uintptr)(__ccgo_up(colv + uintptr(i)*8)))) + if z == uintptr(0) { + goto malloc_failed + } + v3 = p + 28 + v2 = *(*Tu32)(unsafe.Pointer(v3)) + *(*Tu32)(unsafe.Pointer(v3)) = *(*Tu32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up((*TTabResult)(unsafe.Pointer(p)).FazResult + uintptr(v2)*8)) = z + goto _1 + _1: + ; + i = i + 1 + } + } else { + if libc.Int32FromUint32((*TTabResult)(unsafe.Pointer(p)).FnColumn) != nCol { + Xsqlite3_free(tls, (*TTabResult)(unsafe.Pointer(p)).FzErrMsg) + (*TTabResult)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+22122, 0) + (*TTabResult)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + return int32(1) + } + } + /* Copy over the row data + */ + if argv != uintptr(0) { + i = 0 + for { + if !(i < nCol) { + break + } + if **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)) == uintptr(0) { + z = uintptr(0) + } else { + n = _sqlite3Strlen30(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + int32(1) + z = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(n)) + if z == uintptr(0) { + goto malloc_failed + } + libc.X__builtin___memcpy_chk(tls, z, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)), libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + } + v3 = p + 28 + v2 = *(*Tu32)(unsafe.Pointer(v3)) + *(*Tu32)(unsafe.Pointer(v3)) = *(*Tu32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up((*TTabResult)(unsafe.Pointer(p)).FazResult + uintptr(v2)*8)) = z + goto _4 + _4: + ; + i = i + 1 + } + (*TTabResult)(unsafe.Pointer(p)).FnRow = (*TTabResult)(unsafe.Pointer(p)).FnRow + 1 + } + return 0 + goto malloc_failed +malloc_failed: + ; + (*TTabResult)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + return int32(1) +} + +// C documentation +// +// /* +// ** Write an error message into pParse->zErrMsg that explains that the +// ** user-supplied authorization function returned an illegal value. +// */ +func _sqliteAuthBadReturnCode(tls *libc.TLS, pParse uintptr) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13953, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) +} + +func _statClearPage(tls *libc.TLS, p uintptr) { + var aPg uintptr + _ = aPg + aPg = (*TStatPage)(unsafe.Pointer(p)).FaPg + _statClearCells(tls, p) + Xsqlite3_free(tls, (*TStatPage)(unsafe.Pointer(p)).FzPath) + libc.X__builtin___memset_chk(tls, p, 0, uint64(64), ^t__predefined_size_t(0)) + (*TStatPage)(unsafe.Pointer(p)).FaPg = aPg +} + +// C documentation +// +// /* +// ** Connect to or create a new DBSTAT virtual table. +// */ +func _statConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iDb, rc int32 + var pTab uintptr + var _ /* nm at bp+0 */ TToken + _, _, _ = iDb, pTab, rc + pTab = uintptr(0) + rc = SQLITE_OK + _ = pAux + if argc >= int32(4) { + _sqlite3TokenInit(tls, bp, **(**uintptr)(__ccgo_up(argv + 3*8))) + iDb = _sqlite3FindDb(tls, db, bp) + if iDb < 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+13786, libc.VaList(bp+24, **(**uintptr)(__ccgo_up(argv + 3*8)))) + return int32(SQLITE_ERROR) + } + } else { + iDb = 0 + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_DIRECTONLY), 0) + rc = Xsqlite3_declare_vtab(tls, db, uintptr(unsafe.Pointer(&_zDbstatSchema))) + if rc == SQLITE_OK { + pTab = Xsqlite3_malloc64(tls, uint64(40)) + if pTab == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc == SQLITE_OK { + libc.X__builtin___memset_chk(tls, pTab, 0, uint64(40), ^t__predefined_size_t(0)) + (*TStatTable)(unsafe.Pointer(pTab)).Fdb = db + (*TStatTable)(unsafe.Pointer(pTab)).FiDb = iDb + } + **(**uintptr)(__ccgo_up(ppVtab)) = pTab + return rc +} + +// C documentation +// +// /* Populate the StatPage object with information about the all +// ** cells found on the page currently under analysis. +// */ +func _statDecodePage(tls *libc.TLS, pBt uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aData, aHdr, pCell uintptr + var i, iNext, iOff, isLeaf, j, nHdr, nLocal, nOvfl, nUnused, nUsable, rc, szPage, v1 int32 + var iPrev Tu32 + var v2 uint32 + var _ /* dummy at bp+8 */ Tu64 + var _ /* nPayload at bp+0 */ Tu32 + var _ /* pPg at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, aHdr, i, iNext, iOff, iPrev, isLeaf, j, nHdr, nLocal, nOvfl, nUnused, nUsable, pCell, rc, szPage, v1, v2 + aData = (*TStatPage)(unsafe.Pointer(p)).FaPg + if (*TStatPage)(unsafe.Pointer(p)).FiPgno == uint32(1) { + v1 = int32(100) + } else { + v1 = 0 + } + aHdr = aData + uintptr(v1) + (*TStatPage)(unsafe.Pointer(p)).Fflags = **(**Tu8)(__ccgo_up(aHdr)) + if libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x0A) || libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x0D) { + isLeaf = int32(1) + nHdr = int32(8) + } else { + if libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x05) || libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x02) { + isLeaf = 0 + nHdr = int32(12) + } else { + goto statPageIsCorrupt + } + } + if (*TStatPage)(unsafe.Pointer(p)).FiPgno == uint32(1) { + nHdr = nHdr + int32(100) + } + (*TStatPage)(unsafe.Pointer(p)).FnCell = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aHdr + 3)))<= szPage { + goto statPageIsCorrupt + } + nUnused = nUnused + (libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(iOff+int32(2)))))< 0 { + goto statPageIsCorrupt + } + iOff = iNext + } + (*TStatPage)(unsafe.Pointer(p)).FnUnused = nUnused + if isLeaf != 0 { + v2 = uint32(0) + } else { + v2 = _sqlite3Get4byte(tls, aHdr+8) + } + (*TStatPage)(unsafe.Pointer(p)).FiRightChildPg = v2 + if (*TStatPage)(unsafe.Pointer(p)).FnCell != 0 { /* Usable bytes per page */ + _sqlite3BtreeEnter(tls, pBt) + nUsable = szPage - _sqlite3BtreeGetReserveNoMutex(tls, pBt) + _sqlite3BtreeLeave(tls, pBt) + (*TStatPage)(unsafe.Pointer(p)).FaCell = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TStatPage)(unsafe.Pointer(p)).FnCell+libc.Int32FromInt32(1))*uint64(32))) + if (*TStatPage)(unsafe.Pointer(p)).FaCell == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, (*TStatPage)(unsafe.Pointer(p)).FaCell, 0, libc.Uint64FromInt32((*TStatPage)(unsafe.Pointer(p)).FnCell+libc.Int32FromInt32(1))*uint64(32), ^t__predefined_size_t(0)) + i = 0 + for { + if !(i < (*TStatPage)(unsafe.Pointer(p)).FnCell) { + break + } + pCell = (*TStatPage)(unsafe.Pointer(p)).FaCell + uintptr(i)*32 + iOff = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(nHdr+i*int32(2)))))<= szPage { + goto statPageIsCorrupt + } + if !(isLeaf != 0) { + (*TStatCell)(unsafe.Pointer(pCell)).FiChildPg = _sqlite3Get4byte(tls, aData+uintptr(iOff)) + iOff = iOff + int32(4) + } + if libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x05) { + /* A table interior node. nPayload==0. */ + } else { /* Bytes of payload stored locally */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(iOff)))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**Tu8)(__ccgo_up(aData + uintptr(iOff)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aData+uintptr(iOff), bp)) + } + iOff = iOff + libc.Int32FromUint8(libc.Uint8FromInt32(v1)) + if libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x0D) { + iOff = iOff + libc.Int32FromUint8(_sqlite3GetVarint(tls, aData+uintptr(iOff), bp+8)) + } + if **(**Tu32)(__ccgo_up(bp)) > libc.Uint32FromInt32((*TStatPage)(unsafe.Pointer(p)).FnMxPayload) { + (*TStatPage)(unsafe.Pointer(p)).FnMxPayload = libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))) + } + nLocal = _getLocalPayload(tls, nUsable, (*TStatPage)(unsafe.Pointer(p)).Fflags, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp)))) + if nLocal < 0 { + goto statPageIsCorrupt + } + (*TStatCell)(unsafe.Pointer(pCell)).FnLocal = nLocal + if **(**Tu32)(__ccgo_up(bp)) > libc.Uint32FromInt32(nLocal) { + nOvfl = libc.Int32FromUint32((**(**Tu32)(__ccgo_up(bp)) - libc.Uint32FromInt32(nLocal) + libc.Uint32FromInt32(nUsable) - uint32(4) - uint32(1)) / libc.Uint32FromInt32(nUsable-libc.Int32FromInt32(4))) + if iOff+nLocal+int32(4) > nUsable || **(**Tu32)(__ccgo_up(bp)) > uint32(0x7fffffff) { + goto statPageIsCorrupt + } + (*TStatCell)(unsafe.Pointer(pCell)).FnLastOvfl = libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp)) - libc.Uint32FromInt32(nLocal) - libc.Uint32FromInt32((nOvfl-int32(1))*(nUsable-int32(4)))) + (*TStatCell)(unsafe.Pointer(pCell)).FnOvfl = nOvfl + (*TStatCell)(unsafe.Pointer(pCell)).FaOvfl = Xsqlite3_malloc64(tls, uint64(uint64(4)*libc.Uint64FromInt32(nOvfl))) + if (*TStatCell)(unsafe.Pointer(pCell)).FaOvfl == uintptr(0) { + return int32(SQLITE_NOMEM) + } + **(**Tu32)(__ccgo_up((*TStatCell)(unsafe.Pointer(pCell)).FaOvfl)) = _sqlite3Get4byte(tls, aData+uintptr(iOff+nLocal)) + j = int32(1) + for { + if !(j < nOvfl) { + break + } + iPrev = **(**Tu32)(__ccgo_up((*TStatCell)(unsafe.Pointer(pCell)).FaOvfl + uintptr(j-int32(1))*4)) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + rc = _sqlite3PagerGet(tls, _sqlite3BtreePager(tls, pBt), iPrev, bp+16, 0) + if rc != SQLITE_OK { + return rc + } + **(**Tu32)(__ccgo_up((*TStatCell)(unsafe.Pointer(pCell)).FaOvfl + uintptr(j)*4)) = _sqlite3Get4byte(tls, _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 16)))) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 16))) + goto _5 + _5: + ; + j = j + 1 + } + } + } + goto _3 + _3: + ; + i = i + 1 + } + } + return SQLITE_OK + goto statPageIsCorrupt +statPageIsCorrupt: + ; + (*TStatPage)(unsafe.Pointer(p)).Fflags = uint8(0) + _statClearCells(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* Initialize a cursor according to the query plan idxNum using the +// ** arguments in argv[0]. See statBestIndex() for a description of the +// ** meaning of the bits in idxNum. +// */ +func _statFilter(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iArg, rc, v1 int32 + var pCsr, pSql, pTab, zDbase, zName, zSql uintptr + _, _, _, _, _, _, _, _, _ = iArg, pCsr, pSql, pTab, rc, zDbase, zName, zSql, v1 + pCsr = pCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab /* String value of pSql */ + iArg = 0 /* Count of argv[] parameters used so far */ + rc = SQLITE_OK /* Result of this operation */ + zName = uintptr(0) /* Only provide analysis of this table */ + _ = argc + _ = idxStr + _statResetCsr(tls, pCsr) + Xsqlite3_finalize(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) + if idxNum&int32(0x01) != 0 { + v1 = iArg + iArg = iArg + 1 + /* schema=? constraint is present. Get its value */ + zDbase = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8))) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb = _sqlite3FindDbName(tls, (*TStatTable)(unsafe.Pointer(pTab)).Fdb, zDbase) + if (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb < 0 { + (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FisEof = uint8(1) + return SQLITE_OK + } + } else { + (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb = (*TStatTable)(unsafe.Pointer(pTab)).FiDb + } + if idxNum&int32(0x02) != 0 { + /* name=? constraint is present */ + v1 = iArg + iArg = iArg + 1 + zName = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8))) + } + if idxNum&int32(0x04) != 0 { + /* aggregate=? constraint is present */ + v1 = iArg + iArg = iArg + 1 + (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg = libc.BoolUint8(Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8))) != float64(0)) + } else { + (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg = uint8(0) + } + pSql = Xsqlite3_str_new(tls, (*TStatTable)(unsafe.Pointer(pTab)).Fdb) + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+35131, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TStatTable)(unsafe.Pointer(pTab)).Fdb)).FaDb + uintptr((*TStatCursor)(unsafe.Pointer(pCsr)).FiDb)*32))).FzDbSName)) + if zName != 0 { + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+35286, libc.VaList(bp+8, zName)) + } + if idxNum&int32(0x08) != 0 { + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+35300, 0) + } + zSql = Xsqlite3_str_finish(tls, pSql) + if zSql == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, (*TStatTable)(unsafe.Pointer(pTab)).Fdb, zSql, -int32(1), pCsr+8, uintptr(0)) + Xsqlite3_free(tls, zSql) + } + if rc == SQLITE_OK { + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = -int32(1) + rc = _statNext(tls, pCursor) + } + return rc +} + +// C documentation +// +// /* +// ** Implementation of the stat_get(P,J) SQL function. This routine is +// ** used to query statistical information that has been gathered into +// ** the StatAccum object by prior calls to stat_push(). The P parameter +// ** has type BLOB but it is really just a pointer to the StatAccum object. +// ** The content to returned is determined by the parameter J +// ** which is one of the STAT_GET_xxxx values defined above. +// ** +// ** The stat_get(P,J) function is not available to generic SQL. It is +// ** inserted as part of a manually constructed bytecode program. (See +// ** the callStatGet() routine below.) It is guaranteed that the P +// ** parameter will always be a pointer to a StatAccum object, never a +// ** NULL. +// ** +// ** If STAT4 is not enabled, then J is always +// ** STAT_GET_STAT1 and is hence omitted and this routine becomes +// ** a one-parameter function, stat_get(P), that always returns the +// ** stat1 table entry information. +// */ +func _statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var aCnt, p, pS uintptr + var eCall, i, i1 int32 + var iVal, nDistinct Tu64 + var v1 uint64 + var _ /* sStat at bp+0 */ Tsqlite3_str + var _ /* sStat at bp+32 */ Tsqlite3_str + _, _, _, _, _, _, _, _, _ = aCnt, eCall, i, i1, iVal, nDistinct, p, pS, v1 + p = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + /* STAT4 has a parameter on this routine. */ + eCall = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if eCall == STAT_GET_STAT1 { + /* Loop counter */ + _sqlite3StrAccumInit(tls, bp, uintptr(0), uintptr(0), 0, ((*TStatAccum)(unsafe.Pointer(p)).FnKeyCol+int32(1))*int32(100)) + if (*TStatAccum)(unsafe.Pointer(p)).FnSkipAhead != 0 { + v1 = (*TStatAccum)(unsafe.Pointer(p)).FnEst + } else { + v1 = (*TStatAccum)(unsafe.Pointer(p)).FnRow + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+13348, libc.VaList(bp+72, v1)) + i = 0 + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FnKeyCol) { + break + } + nDistinct = **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(i)*8)) + uint64(1) + iVal = ((*TStatAccum)(unsafe.Pointer(p)).FnRow + nDistinct - uint64(1)) / nDistinct + if iVal == uint64(2) && (*TStatAccum)(unsafe.Pointer(p)).FnRow*uint64(10) <= nDistinct*uint64(11) { + iVal = uint64(1) + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+13353, libc.VaList(bp+72, iVal)) + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3ResultStrAccum(tls, context, bp) + } else { + if eCall == int32(STAT_GET_ROWID) { + if (*TStatAccum)(unsafe.Pointer(p)).FiGet < 0 { + _samplePushPrevious(tls, p, 0) + (*TStatAccum)(unsafe.Pointer(p)).FiGet = 0 + } + if (*TStatAccum)(unsafe.Pointer(p)).FiGet < (*TStatAccum)(unsafe.Pointer(p)).FnSample { + pS = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiGet)*48 + if (*TStatSample)(unsafe.Pointer(pS)).FnRowid == uint32(0) { + Xsqlite3_result_int64(tls, context, *(*Ti64)(unsafe.Pointer(pS + 24))) + } else { + Xsqlite3_result_blob(tls, context, *(*uintptr)(unsafe.Pointer(pS + 24)), libc.Int32FromUint32((*TStatSample)(unsafe.Pointer(pS)).FnRowid), uintptr(-libc.Int32FromInt32(1))) + } + } + } else { + aCnt = uintptr(0) + switch eCall { + case int32(STAT_GET_NEQ): + aCnt = (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiGet)*48))).FanEq + case int32(STAT_GET_NLT): + aCnt = (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiGet)*48))).FanLt + default: + aCnt = (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiGet)*48))).FanDLt + (*TStatAccum)(unsafe.Pointer(p)).FiGet = (*TStatAccum)(unsafe.Pointer(p)).FiGet + 1 + break + } + _sqlite3StrAccumInit(tls, bp+32, uintptr(0), uintptr(0), 0, (*TStatAccum)(unsafe.Pointer(p)).FnCol*int32(100)) + i1 = 0 + for { + if !(i1 < (*TStatAccum)(unsafe.Pointer(p)).FnCol) { + break + } + Xsqlite3_str_appendf(tls, bp+32, __ccgo_ts+13359, libc.VaList(bp+72, **(**TtRowcnt)(__ccgo_up(aCnt + uintptr(i1)*8)))) + goto _3 + _3: + ; + i1 = i1 + 1 + } + if (**(**Tsqlite3_str)(__ccgo_up(bp + 32))).FnChar != 0 { + (**(**Tsqlite3_str)(__ccgo_up(bp + 32))).FnChar = (**(**Tsqlite3_str)(__ccgo_up(bp + 32))).FnChar - 1 + } + _sqlite3ResultStrAccum(tls, context, bp+32) + } + } + _ = argc +} + +var _statGetFuncdef = TFuncDef{ + FnArg: int16(libc.Int32FromInt32(1) + libc.Int32FromInt32(IsStat4)), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 13365, +} + +// C documentation +// +// /* +// ** Load a copy of the page data for page iPg into the buffer belonging +// ** to page object pPg. Allocate the buffer if necessary. Return SQLITE_OK +// ** if successful, or an SQLite error code otherwise. +// */ +func _statGetPage(tls *libc.TLS, pBt uintptr, iPg Tu32, pPg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a uintptr + var pgsz, rc int32 + var _ /* pDbPage at bp+0 */ uintptr + _, _, _ = a, pgsz, rc + pgsz = _sqlite3BtreeGetPageSize(tls, pBt) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*TStatPage)(unsafe.Pointer(pPg)).FaPg == uintptr(0) { + (*TStatPage)(unsafe.Pointer(pPg)).FaPg = Xsqlite3_malloc(tls, pgsz+int32(DBSTAT_PAGE_PADDING_BYTES)) + if (*TStatPage)(unsafe.Pointer(pPg)).FaPg == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, (*TStatPage)(unsafe.Pointer(pPg)).FaPg+uintptr(pgsz), 0, uint64(DBSTAT_PAGE_PADDING_BYTES), ^t__predefined_size_t(0)) + } + rc = _sqlite3PagerGet(tls, _sqlite3BtreePager(tls, pBt), iPg, bp, 0) + if rc == SQLITE_OK { + a = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + libc.X__builtin___memcpy_chk(tls, (*TStatPage)(unsafe.Pointer(pPg)).FaPg, a, libc.Uint64FromInt32(pgsz), ^t__predefined_size_t(0)) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +var _statInitFuncdef = TFuncDef{ + FnArg: int16(4), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 13328, +} + +// C documentation +// +// /* +// ** Move a DBSTAT cursor to the next entry. Normally, the next +// ** entry will be the next page, but in aggregated mode (pCsr->isAgg!=0), +// ** the next entry is the next btree. +// */ +func _statNext(tls *libc.TLS, pCursor uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, iOvfl, nPayload, nUsable, rc, v3 int32 + var iRoot Tu32 + var p, p1, pBt, pCell, pCsr, pPager, pTab, z, v1 uintptr + var _ /* nPage at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iOvfl, iRoot, nPayload, nUsable, p, p1, pBt, pCell, pCsr, pPager, pTab, rc, z, v1, v3 + pCsr = pCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TStatTable)(unsafe.Pointer(pTab)).Fdb)).FaDb + uintptr((*TStatCursor)(unsafe.Pointer(pCsr)).FiDb)*32))).FpBt + pPager = _sqlite3BtreePager(tls, pBt) + Xsqlite3_free(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath) + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath = uintptr(0) + goto statNextRestart +statNextRestart: + ; + if (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage < 0 { + /* Start measuring space on the next btree */ + _statResetCounts(tls, pCsr) + rc = Xsqlite3_step(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + if rc == int32(SQLITE_ROW) { + iRoot = libc.Uint32FromInt64(Xsqlite3_column_int64(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1))) + _sqlite3PagerPagecount(tls, pPager, bp) + if **(**int32)(__ccgo_up(bp)) == 0 { + (*TStatCursor)(unsafe.Pointer(pCsr)).FisEof = uint8(1) + return Xsqlite3_reset(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + } + rc = _statGetPage(tls, pBt, iRoot, pCsr+24) + (**(**TStatPage)(__ccgo_up(pCsr + 24))).FiPgno = iRoot + (**(**TStatPage)(__ccgo_up(pCsr + 24))).FiCell = 0 + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + v1 = Xsqlite3_mprintf(tls, __ccgo_ts+4178, 0) + z = v1 + (**(**TStatPage)(__ccgo_up(pCsr + 24))).FzPath = v1 + if z == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage = int32(1) + } else { + (*TStatCursor)(unsafe.Pointer(pCsr)).FisEof = uint8(1) + return Xsqlite3_reset(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + } + } else { + /* Continue analyzing the btree previously started */ + p = pCsr + 24 + uintptr((*TStatCursor)(unsafe.Pointer(pCsr)).FiPage)*64 + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + _statResetCounts(tls, pCsr) + } + for (*TStatPage)(unsafe.Pointer(p)).FiCell < (*TStatPage)(unsafe.Pointer(p)).FnCell { + pCell = (*TStatPage)(unsafe.Pointer(p)).FaCell + uintptr((*TStatPage)(unsafe.Pointer(p)).FiCell)*32 + for (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl < (*TStatCell)(unsafe.Pointer(pCell)).FnOvfl { + _sqlite3BtreeEnter(tls, pBt) + nUsable = _sqlite3BtreeGetPageSize(tls, pBt) - _sqlite3BtreeGetReserveNoMutex(tls, pBt) + _sqlite3BtreeLeave(tls, pBt) + (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage = (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage + 1 + _statSizeAndOffset(tls, pCsr) + if (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl < (*TStatCell)(unsafe.Pointer(pCell)).FnOvfl-int32(1) { + **(**Ti64)(__ccgo_up(pCsr + 2128)) += int64(nUsable - int32(4)) + } else { + **(**Ti64)(__ccgo_up(pCsr + 2128)) += int64((*TStatCell)(unsafe.Pointer(pCell)).FnLastOvfl) + **(**Ti64)(__ccgo_up(pCsr + 2120)) += int64(nUsable - int32(4) - (*TStatCell)(unsafe.Pointer(pCell)).FnLastOvfl) + } + iOvfl = (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl + (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl = (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl + 1 + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + (*TStatCursor)(unsafe.Pointer(pCsr)).FzName = Xsqlite3_column_text(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt, 0) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPageno = **(**Tu32)(__ccgo_up((*TStatCell)(unsafe.Pointer(pCell)).FaOvfl + uintptr(iOvfl)*4)) + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype = __ccgo_ts + 35078 + v1 = Xsqlite3_mprintf(tls, __ccgo_ts+35087, libc.VaList(bp+16, (*TStatPage)(unsafe.Pointer(p)).FzPath, (*TStatPage)(unsafe.Pointer(p)).FiCell, iOvfl)) + z = v1 + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath = v1 + if z == uintptr(0) { + v3 = int32(SQLITE_NOMEM) + } else { + v3 = SQLITE_OK + } + return v3 + } + } + if (*TStatPage)(unsafe.Pointer(p)).FiRightChildPg != 0 { + break + } + (*TStatPage)(unsafe.Pointer(p)).FiCell = (*TStatPage)(unsafe.Pointer(p)).FiCell + 1 + } + if !((*TStatPage)(unsafe.Pointer(p)).FiRightChildPg != 0) || (*TStatPage)(unsafe.Pointer(p)).FiCell > (*TStatPage)(unsafe.Pointer(p)).FnCell { + _statClearPage(tls, p) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage - 1 + if (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0 && (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage < 0 { + /* label-statNext-done: When computing aggregate space usage over + ** an entire btree, this is the exit point from this function */ + return SQLITE_OK + } + goto statNextRestart /* Tail recursion */ + } + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage + 1 + if (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage >= libc.Int32FromUint64(libc.Uint64FromInt64(2048)/libc.Uint64FromInt64(64)) { + _statResetCsr(tls, pCsr) + return _sqlite3CorruptError(tls, int32(232191)) + } + if (*TStatPage)(unsafe.Pointer(p)).FiCell == (*TStatPage)(unsafe.Pointer(p)).FnCell { + (**(**TStatPage)(__ccgo_up(p + 1*64))).FiPgno = (*TStatPage)(unsafe.Pointer(p)).FiRightChildPg + } else { + (**(**TStatPage)(__ccgo_up(p + 1*64))).FiPgno = (**(**TStatCell)(__ccgo_up((*TStatPage)(unsafe.Pointer(p)).FaCell + uintptr((*TStatPage)(unsafe.Pointer(p)).FiCell)*32))).FiChildPg + } + rc = _statGetPage(tls, pBt, (**(**TStatPage)(__ccgo_up(p + 1*64))).FiPgno, p+1*64) + (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage = (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage + 1 + (**(**TStatPage)(__ccgo_up(p + 1*64))).FiCell = 0 + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + v1 = Xsqlite3_mprintf(tls, __ccgo_ts+35099, libc.VaList(bp+16, (*TStatPage)(unsafe.Pointer(p)).FzPath, (*TStatPage)(unsafe.Pointer(p)).FiCell)) + z = v1 + (**(**TStatPage)(__ccgo_up(p + 1*64))).FzPath = v1 + if z == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + (*TStatPage)(unsafe.Pointer(p)).FiCell = (*TStatPage)(unsafe.Pointer(p)).FiCell + 1 + } + /* Populate the StatCursor fields with the values to be returned + ** by the xColumn() and xRowid() methods. + */ + if rc == SQLITE_OK { + p1 = pCsr + 24 + uintptr((*TStatCursor)(unsafe.Pointer(pCsr)).FiPage)*64 + (*TStatCursor)(unsafe.Pointer(pCsr)).FzName = Xsqlite3_column_text(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt, 0) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPageno = (*TStatPage)(unsafe.Pointer(p1)).FiPgno + rc = _statDecodePage(tls, pBt, p1) + if rc == SQLITE_OK { + _statSizeAndOffset(tls, pCsr) + switch libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p1)).Fflags) { + case int32(0x05): /* table internal */ + fallthrough + case int32(0x02): /* index internal */ + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype = __ccgo_ts + 35107 + case int32(0x0D): /* table leaf */ + fallthrough + case int32(0x0A): /* index leaf */ + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype = __ccgo_ts + 35116 + default: + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype = __ccgo_ts + 35121 + break + } + **(**int32)(__ccgo_up(pCsr + 2108)) += (*TStatPage)(unsafe.Pointer(p1)).FnCell + **(**Ti64)(__ccgo_up(pCsr + 2120)) += int64((*TStatPage)(unsafe.Pointer(p1)).FnUnused) + if (*TStatPage)(unsafe.Pointer(p1)).FnMxPayload > (*TStatCursor)(unsafe.Pointer(pCsr)).FnMxPayload { + (*TStatCursor)(unsafe.Pointer(pCsr)).FnMxPayload = (*TStatPage)(unsafe.Pointer(p1)).FnMxPayload + } + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + v1 = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, (*TStatPage)(unsafe.Pointer(p1)).FzPath)) + z = v1 + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath = v1 + if z == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + nPayload = 0 + i = 0 + for { + if !(i < (*TStatPage)(unsafe.Pointer(p1)).FnCell) { + break + } + nPayload = nPayload + (**(**TStatCell)(__ccgo_up((*TStatPage)(unsafe.Pointer(p1)).FaCell + uintptr(i)*32))).FnLocal + goto _6 + _6: + ; + i = i + 1 + } + **(**Ti64)(__ccgo_up(pCsr + 2128)) += int64(nPayload) + /* If computing aggregate space usage by btree, continue with the + ** next page. The loop will exit via the return at label-statNext-done + */ + if (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0 { + goto statNextRestart + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Open a new DBSTAT cursor. +// */ +func _statOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) (r int32) { + var pCsr, pTab uintptr + _, _ = pCsr, pTab + pTab = pVTab + pCsr = Xsqlite3_malloc64(tls, uint64(2152)) + if pCsr == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + libc.X__builtin___memset_chk(tls, pCsr, 0, uint64(2152), ^t__predefined_size_t(0)) + (*TStatCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab + (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb = (*TStatTable)(unsafe.Pointer(pTab)).FiDb + } + **(**uintptr)(__ccgo_up(ppCursor)) = pCsr + return SQLITE_OK +} + +var _statPushFuncdef = TFuncDef{ + FnArg: int16(libc.Int32FromInt32(2) + libc.Int32FromInt32(IsStat4)), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 13338, +} + +// C documentation +// +// /* +// ** Finish off a string by making sure it is zero-terminated. +// ** Return a pointer to the resulting string. Return a NULL +// ** pointer if any kind of error was encountered. +// */ +func _strAccumFinishRealloc(tls *libc.TLS, p uintptr) (r uintptr) { + var zText, v1 uintptr + _, _ = zText, v1 + zText = _sqlite3DbMallocRaw(tls, (*TStrAccum)(unsafe.Pointer(p)).Fdb, uint64(1)+uint64((*TStrAccum)(unsafe.Pointer(p)).FnChar)) + if zText != 0 { + libc.X__builtin___memcpy_chk(tls, zText, (*TStrAccum)(unsafe.Pointer(p)).FzText, uint64((*TStrAccum)(unsafe.Pointer(p)).FnChar+uint32(1)), ^t__predefined_size_t(0)) + v1 = p + 29 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) + } else { + _sqlite3StrAccumSetError(tls, p, uint8(SQLITE_NOMEM)) + } + (*TStrAccum)(unsafe.Pointer(p)).FzText = zText + return zText +} + +// C documentation +// +// /* +// ** Scan through the expression pExpr. Replace every reference to +// ** a column in table number iTable with a copy of the iColumn-th +// ** entry in pEList. (But leave references to the ROWID column +// ** unchanged.) +// ** +// ** This routine is part of the flattening procedure. A subquery +// ** whose result set is defined by pEList appears as entry in the +// ** FROM clause of a SELECT such that the VDBE cursor assigned to that +// ** FORM clause entry is iTable. This routine makes the necessary +// ** changes to pExpr so that it refers directly to the source table +// ** of the subquery rather the result set of the subquery. +// */ +func _substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var db, pColl, pCopy, pNat, pNew, pWin, v1 uintptr + var iColumn int32 + var _ /* ifNullRow at bp+0 */ TExpr + _, _, _, _, _, _, _, _ = db, iColumn, pColl, pCopy, pNat, pNew, pWin, v1 + if pExpr == uintptr(0) { + return uintptr(0) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) && *(*int32)(unsafe.Pointer(pExpr + 52)) == (*TSubstContext)(unsafe.Pointer(pSubst)).FiTable { + *(*int32)(unsafe.Pointer(pExpr + 52)) = (*TSubstContext)(unsafe.Pointer(pSubst)).FiNewTable + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TSubstContext)(unsafe.Pointer(pSubst)).FiTable && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != libc.Uint32FromInt32(0)) { + iColumn = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + pCopy = (*(*TExprList_item)(unsafe.Pointer((*TSubstContext)(unsafe.Pointer(pSubst)).FpEList + 8 + uintptr(iColumn)*32))).FpExpr + if _sqlite3ExprIsVector(tls, pCopy) != 0 { + _sqlite3VectorErrorMsg(tls, (*TSubstContext)(unsafe.Pointer(pSubst)).FpParse, pCopy) + } else { + db = (*TParse)(unsafe.Pointer((*TSubstContext)(unsafe.Pointer(pSubst)).FpParse)).Fdb + if (*TSubstContext)(unsafe.Pointer(pSubst)).FisOuterJoin != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCopy)).Fop) != int32(TK_COLUMN) || (*TExpr)(unsafe.Pointer(pCopy)).FiTable != (*TSubstContext)(unsafe.Pointer(pSubst)).FiNewTable) { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(72), ^t__predefined_size_t(0)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_IF_NULL_ROW) + (**(**TExpr)(__ccgo_up(bp))).FpLeft = pCopy + (**(**TExpr)(__ccgo_up(bp))).FiTable = (*TSubstContext)(unsafe.Pointer(pSubst)).FiNewTable + (**(**TExpr)(__ccgo_up(bp))).FiColumn = int16(-int32(99)) + (**(**TExpr)(__ccgo_up(bp))).Fflags = uint32(EP_IfNullRow) + pCopy = bp + } + pNew = _sqlite3ExprDup(tls, db, pCopy, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pNew) + return pExpr + } + if (*TSubstContext)(unsafe.Pointer(pSubst)).FisOuterJoin != 0 { + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pNew)).Fop) == int32(TK_TRUEFALSE) { + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pNew)).Fu)) = _sqlite3ExprTruthValue(tls, pNew) + (*TExpr)(unsafe.Pointer(pNew)).Fop = uint8(TK_INTEGER) + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) + } + /* Ensure that the expression now has an implicit collation sequence, + ** just as it did when it was a column of a view or sub-query. */ + pNat = _sqlite3ExprCollSeq(tls, (*TSubstContext)(unsafe.Pointer(pSubst)).FpParse, pNew) + pColl = _sqlite3ExprCollSeq(tls, (*TSubstContext)(unsafe.Pointer(pSubst)).FpParse, (*(*TExprList_item)(unsafe.Pointer((*TSubstContext)(unsafe.Pointer(pSubst)).FpCList + 8 + uintptr(iColumn)*32))).FpExpr) + if pNat != pColl || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pNew)).Fop) != int32(TK_COLUMN) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pNew)).Fop) != int32(TK_COLLATE) { + if pColl != 0 { + v1 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v1 = __ccgo_ts + 5581 + } + pNew = _sqlite3ExprAddCollateString(tls, (*TSubstContext)(unsafe.Pointer(pSubst)).FpParse, pNew, v1) + } + **(**Tu32)(__ccgo_up(pNew + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + _sqlite3SetJoinExpr(tls, pNew, *(*int32)(unsafe.Pointer(pExpr + 52)), (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON))) + } + _sqlite3ExprDelete(tls, db, pExpr) + pExpr = pNew + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IF_NULL_ROW) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TSubstContext)(unsafe.Pointer(pSubst)).FiTable { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSubstContext)(unsafe.Pointer(pSubst)).FiNewTable + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_FUNCTION) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) >= (*TSubstContext)(unsafe.Pointer(pSubst)).FnSelDepth { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop2 - 1 + } + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = _substExpr(tls, pSubst, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = _substExpr(tls, pSubst, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _substSelect(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 32)), int32(1)) + } else { + _substExprList(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + pWin = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + (*TWindow)(unsafe.Pointer(pWin)).FpFilter = _substExpr(tls, pSubst, (*TWindow)(unsafe.Pointer(pWin)).FpFilter) + _substExprList(tls, pSubst, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) + _substExprList(tls, pSubst, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) + } + } + return pExpr +} + +func _sumFinalize(tls *libc.TLS, context uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, context, 0) + if p != 0 && (*TSumCtx)(unsafe.Pointer(p)).Fcnt > 0 { + if (*TSumCtx)(unsafe.Pointer(p)).Fapprox != 0 { + if (*TSumCtx)(unsafe.Pointer(p)).Fovrfl != 0 { + Xsqlite3_result_error(tls, context, __ccgo_ts+16802, -int32(1)) + } else { + if !(_sqlite3IsOverflow(tls, (*TSumCtx)(unsafe.Pointer(p)).FrErr) != 0) { + Xsqlite3_result_double(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FrSum+(*TSumCtx)(unsafe.Pointer(p)).FrErr) + } else { + Xsqlite3_result_double(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FrSum) + } + } + } else { + Xsqlite3_result_int64(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FiSum) + } + } +} + +// C documentation +// +// /* Takes a fully configured proxy locking-style unix file and switches +// ** the local lock file path +// */ +func _switchLockProxyPath(tls *libc.TLS, pFile uintptr, path uintptr) (r int32) { + var lockProxy, oldPath, pCtx uintptr + var rc int32 + _, _, _, _ = lockProxy, oldPath, pCtx, rc + pCtx = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + oldPath = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath + rc = SQLITE_OK + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) != NO_LOCK { + return int32(SQLITE_BUSY) + } + /* nothing to do if the path is NULL, :auto: or matches the existing path */ + if !(path != 0) || int32(**(**int8)(__ccgo_up(path))) == int32('\000') || !(libc.Xstrcmp(tls, path, __ccgo_ts+4139) != 0) || oldPath != 0 && !(libc.Xstrncmp(tls, oldPath, path, uint64(PATH_MAX)) != 0) { + return SQLITE_OK + } else { + lockProxy = (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxy = libc.UintptrFromInt32(0) + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FconchHeld = 0 + if lockProxy != libc.UintptrFromInt32(0) { + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(lockProxy)).FpMethod)).FxClose})))(tls, lockProxy) + if rc != 0 { + return rc + } + Xsqlite3_free(tls, lockProxy) + } + Xsqlite3_free(tls, oldPath) + (*TproxyLockingContext)(unsafe.Pointer(pCtx)).FlockProxyPath = _sqlite3DbStrDup(tls, uintptr(0), path) + } + return rc +} + +// C documentation +// +// /* +// ** Sync the journal. In other words, make sure all the pages that have +// ** been written to the journal have actually reached the surface of the +// ** disk and can be restored in the event of a hot-journal rollback. +// ** +// ** If the Pager.noSync flag is set, then this function is a no-op. +// ** Otherwise, the actions required depend on the journal-mode and the +// ** device characteristics of the file-system, as follows: +// ** +// ** * If the journal file is an in-memory journal file, no action need +// ** be taken. +// ** +// ** * Otherwise, if the device does not support the SAFE_APPEND property, +// ** then the nRec field of the most recently written journal header +// ** is updated to contain the number of journal records that have +// ** been written following it. If the pager is operating in full-sync +// ** mode, then the journal file is synced before this field is updated. +// ** +// ** * If the device does not support the SEQUENTIAL property, then +// ** journal file is synced. +// ** +// ** Or, in pseudo-code: +// ** +// ** if( NOT ){ +// ** if( NOT SAFE_APPEND ){ +// ** if( ) xSync(); +// ** +// ** } +// ** if( NOT SEQUENTIAL ) xSync(); +// ** } +// ** +// ** If successful, this routine clears the PGHDR_NEED_SYNC flag of every +// ** page currently held in memory before returning SQLITE_OK. If an IO +// ** error is encountered, then the IO error code is returned to the caller. +// */ +func _syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iDc, rc, v1 int32 + var iNextHdrOffset Ti64 + var _ /* aMagic at bp+0 */ [8]Tu8 + var _ /* zHeader at bp+8 */ [12]Tu8 + _, _, _, _ = iDc, iNextHdrOffset, rc, v1 /* Return code */ + rc = _sqlite3PagerExclusiveLock(tls, pPager) + if rc != SQLITE_OK { + return rc + } + if !((*TPager)(unsafe.Pointer(pPager)).FnoSync != 0) { + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) != int32(PAGER_JOURNALMODE_MEMORY) { + iDc = _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd) + if 0 == iDc&int32(SQLITE_IOCAP_SAFE_APPEND) { + libc.X__builtin___memcpy_chk(tls, bp+8, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8), ^t__predefined_size_t(0)) + _sqlite3Put4byte(tls, bp+8+uintptr(8), libc.Uint32FromInt32((*TPager)(unsafe.Pointer(pPager)).FnRec)) + iNextHdrOffset = _journalHdrOffset(tls, pPager) + rc = _sqlite3OsRead(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp, int32(8), iNextHdrOffset) + if rc == SQLITE_OK && 0 == libc.Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8)) { + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&_zerobyte)), int32(1), iNextHdrOffset) + } + if rc != SQLITE_OK && rc != libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)< UTF-16 conversion if +// ** possible. +// */ +func _synthCollSeq(tls *libc.TLS, db uintptr, pColl uintptr) (r int32) { + var i int32 + var pColl2, z uintptr + _, _, _ = i, pColl2, z + z = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + i = 0 + for { + if !(i < int32(3)) { + break + } + pColl2 = _sqlite3FindCollSeq(tls, db, _aEnc[i], z, 0) + if (*TCollSeq)(unsafe.Pointer(pColl2)).FxCmp != uintptr(0) { + libc.X__builtin___memcpy_chk(tls, pColl, pColl2, uint64(40), ^t__predefined_size_t(0)) + (*TCollSeq)(unsafe.Pointer(pColl)).FxDel = uintptr(0) /* Do not copy the destructor */ + return SQLITE_OK + } + goto _1 + _1: + ; + i = i + 1 + } + return int32(SQLITE_ERROR) +} + +// C documentation +// +// /* +// ** Return true if it is not allowed to drop the given table +// */ +func _tableMayNotBeDropped(tls *libc.TLS, db uintptr, pTab uintptr) (r int32) { + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+7100, int32(7)) == 0 { + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName+uintptr(7), __ccgo_ts+3565, int32(4)) == 0 { + return 0 + } + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName+uintptr(7), __ccgo_ts+7902, int32(10)) == 0 { + return 0 + } + return int32(1) + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Shadow) != uint32(0) && _sqlite3ReadOnlyShadowTables(tls, db) != 0 { + return int32(1) + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Eponymous) != 0 { + return int32(1) + } + return 0 +} + +var _tkCoalesce = TToken{ + Fz: __ccgo_ts + 7305, + Fn: uint32(8), +} + +// C documentation +// +// /* +// ** Assuming the input DateTime is UTC, move it to its localtime equivalent. +// */ +func _toLocaltime(tls *libc.TLS, p uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var iYearDiff int32 + var _ /* sLocal at bp+8 */ Ttm + var _ /* t at bp+0 */ Ttime_t + var _ /* x at bp+64 */ TDateTime + _ = iYearDiff + /* Initialize the contents of sLocal to avoid a compiler warning. */ + libc.X__builtin___memset_chk(tls, bp+8, 0, uint64(56), ^t__predefined_size_t(0)) + _computeJD(tls, p) + if (*TDateTime)(unsafe.Pointer(p)).FiJD < libc.Int64FromInt32(2108667600)*libc.Int64FromInt32(100000) || (*TDateTime)(unsafe.Pointer(p)).FiJD > libc.Int64FromInt32(2130141456)*libc.Int64FromInt32(100000) { + /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only + ** works for years between 1970 and 2037. For dates outside this range, + ** SQLite attempts to map the year into an equivalent year within this + ** range, do the calculation, then map the year back. + */ + **(**TDateTime)(__ccgo_up(bp + 64)) = **(**TDateTime)(__ccgo_up(p)) + _computeYMD_HMS(tls, bp+64) + iYearDiff = int32(2000) + (**(**TDateTime)(__ccgo_up(bp + 64))).FY%int32(4) - (**(**TDateTime)(__ccgo_up(bp + 64))).FY + (**(**TDateTime)(__ccgo_up(bp + 64))).FY += iYearDiff + (**(**TDateTime)(__ccgo_up(bp + 64))).FvalidJD = 0 + _computeJD(tls, bp+64) + **(**Ttime_t)(__ccgo_up(bp)) = int64((**(**TDateTime)(__ccgo_up(bp + 64))).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) + } else { + iYearDiff = 0 + **(**Ttime_t)(__ccgo_up(bp)) = int64((*TDateTime)(unsafe.Pointer(p)).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) + } + if _osLocaltime(tls, bp, bp+8) != 0 { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+1247, -int32(1)) + return int32(SQLITE_ERROR) + } + (*TDateTime)(unsafe.Pointer(p)).FY = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_year + int32(1900) - iYearDiff + (*TDateTime)(unsafe.Pointer(p)).FM = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_mon + int32(1) + (*TDateTime)(unsafe.Pointer(p)).FD = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_mday + (*TDateTime)(unsafe.Pointer(p)).Fh = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_hour + (*TDateTime)(unsafe.Pointer(p)).Fm = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_min + (*TDateTime)(unsafe.Pointer(p)).Fs = float64((**(**Ttm)(__ccgo_up(bp + 8))).Ftm_sec) + float64(float64((*TDateTime)(unsafe.Pointer(p)).FiJD%libc.Int64FromInt32(1000))*float64(0.001)) + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = int8(1) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = int8(1) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 1, 0x2) + return SQLITE_OK +} + +// C documentation +// +// /* Construct a new Expr object from a single token */ +func _tokenExpr(tls *libc.TLS, pParse uintptr, op int32, _t TToken) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*TToken)(unsafe.Pointer(bp)) = _t + var p, v1 uintptr + _, _ = p, v1 + p = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(72)+uint64((**(**TToken)(__ccgo_up(bp))).Fn)+uint64(1)) + if p != 0 { + /* memset(p, 0, sizeof(Expr)); */ + (*TExpr)(unsafe.Pointer(p)).Fop = libc.Uint8FromInt32(op) + (*TExpr)(unsafe.Pointer(p)).FaffExpr = 0 + (*TExpr)(unsafe.Pointer(p)).Fflags = uint32(EP_Leaf) + /* p->iAgg = -1; // Not required */ + v1 = libc.UintptrFromInt32(0) + (*TExpr)(unsafe.Pointer(p)).FpRight = v1 + (*TExpr)(unsafe.Pointer(p)).FpLeft = v1 + (*TExpr)(unsafe.Pointer(p)).FpAggInfo = uintptr(0) + libc.X__builtin___memset_chk(tls, p+32, 0, uint64(8), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, p+64, 0, uint64(8), ^t__predefined_size_t(0)) + (*TExpr)(unsafe.Pointer(p)).Fop2 = uint8(0) + (*TExpr)(unsafe.Pointer(p)).FiTable = 0 + (*TExpr)(unsafe.Pointer(p)).FiColumn = 0 + *(*uintptr)(unsafe.Pointer(p + 8)) = p + 1*72 + libc.X__builtin___memcpy_chk(tls, *(*uintptr)(unsafe.Pointer(p + 8)), (**(**TToken)(__ccgo_up(bp))).Fz, uint64((**(**TToken)(__ccgo_up(bp))).Fn), ^t__predefined_size_t(0)) + **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(p + 8)) + uintptr((**(**TToken)(__ccgo_up(bp))).Fn))) = 0 + *(*int32)(unsafe.Pointer(p + 52)) = int32(int64((**(**TToken)(__ccgo_up(bp))).Fz) - int64((*TParse)(unsafe.Pointer(pParse)).FzTail)) + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(p + 8)))))])&int32(0x80) != 0 { + _sqlite3DequoteExpr(tls, p) + } + (*TExpr)(unsafe.Pointer(p)).FnHeight = int32(1) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return _sqlite3RenameTokenMap(tls, pParse, p, bp) + } + } + return p +} + +// C documentation +// +// /* +// ** Allocate space to hold a new trigger step. The allocated space +// ** holds both the TriggerStep object and the TriggerStep.target.z string. +// ** +// ** If an OOM error occurs, NULL is returned and db->mallocFailed is set. +// */ +func _triggerStepAllocate(tls *libc.TLS, pParse uintptr, op Tu8, pTabList uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var db, pNew, pTriggerStep uintptr + _, _, _ = db, pNew, pTriggerStep + pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTriggerStep = uintptr(0) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + if pNew != 0 && (*TTrigger)(unsafe.Pointer(pNew)).FpSchema != (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema && *(*uintptr)(unsafe.Pointer(pTabList + 8 + 72)) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22634, 0) + } else { + pTriggerStep = _sqlite3DbMallocZero(tls, db, uint64(88)) + if pTriggerStep != 0 { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc = _sqlite3SrcListDup(tls, db, pTabList, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = op + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = _triggerSpanDup(tls, db, zStart, zEnd) + if (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc != 0 && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc + 8))).FzName, (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FzName) + } + } + } + } + _sqlite3SrcListDelete(tls, db, pTabList) + return pTriggerStep +} + +// C documentation +// +// /* +// ** Return a list of all triggers on table pTab if there exists at least +// ** one trigger that must be fired when an operation of type 'op' is +// ** performed on the table, and, if that operation is an UPDATE, if at +// ** least one of the columns in pChanges is being modified. +// */ +func _triggersReallyExist(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32, pChanges uintptr, pMask uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var mask int32 + var p, pList, v1 uintptr + _, _, _, _ = mask, p, pList, v1 + mask = 0 + pList = uintptr(0) + pList = _sqlite3TriggerList(tls, pParse, pTab) + if pList != uintptr(0) { + p = pList + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_EnableTrigger) == uint64(0) && (*TTable)(unsafe.Pointer(pTab)).FpTrigger != uintptr(0) && _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTrigger)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FpTrigger)).FpSchema) != int32(1) { + /* The SQLITE_DBCONFIG_ENABLE_TRIGGER setting is off. That means that + ** only TEMP triggers are allowed. Truncate the pList so that it + ** includes only TEMP triggers */ + if pList == (*TTable)(unsafe.Pointer(pTab)).FpTrigger { + pList = uintptr(0) + goto exit_triggers_exist + } + for (*TTrigger)(unsafe.Pointer(p)).FpNext != 0 && (*TTrigger)(unsafe.Pointer(p)).FpNext != (*TTable)(unsafe.Pointer(pTab)).FpTrigger { + p = (*TTrigger)(unsafe.Pointer(p)).FpNext + } + (*TTrigger)(unsafe.Pointer(p)).FpNext = uintptr(0) + p = pList + } + for cond := true; cond; cond = p != 0 { + if libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == op && _checkColumnOverlap(tls, (*TTrigger)(unsafe.Pointer(p)).FpColumns, pChanges) != 0 { + mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm) + } else { + if libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == int32(TK_RETURNING) { + /* The first time a RETURNING trigger is seen, the "op" value tells + ** us what time of trigger it should be. */ + (*TTrigger)(unsafe.Pointer(p)).Fop = libc.Uint8FromInt32(op) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + if op != int32(TK_INSERT) { + if op == int32(TK_DELETE) { + v1 = __ccgo_ts + 22811 + } else { + v1 = __ccgo_ts + 22818 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22825, libc.VaList(bp+8, v1)) + } + (*TTrigger)(unsafe.Pointer(p)).Ftr_tm = uint8(TRIGGER_BEFORE) + } else { + (*TTrigger)(unsafe.Pointer(p)).Ftr_tm = uint8(TRIGGER_AFTER) + } + mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm) + } else { + if (*TTrigger)(unsafe.Pointer(p)).FbReturning != 0 && libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == int32(TK_INSERT) && op == int32(TK_UPDATE) && (*TParse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) { + /* Also fire a RETURNING trigger for an UPSERT */ + mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm) + } + } + } + p = (*TTrigger)(unsafe.Pointer(p)).FpNext + } + } + goto exit_triggers_exist +exit_triggers_exist: + ; + if pMask != 0 { + **(**int32)(__ccgo_up(pMask)) = mask + } + if mask != 0 { + v1 = pList + } else { + v1 = uintptr(0) + } + return v1 +} + +// C documentation +// +// /* +// ** Implementation of the UNISTR() function. +// ** +// ** This is intended to be a work-alike of the UNISTR() function in +// ** PostgreSQL. Quoting from the PG documentation (PostgreSQL 17 - +// ** scraped on 2025-02-22): +// ** +// ** Evaluate escaped Unicode characters in the argument. Unicode +// ** characters can be specified as \XXXX (4 hexadecimal digits), +// ** \+XXXXXX (6 hexadecimal digits), \uXXXX (4 hexadecimal digits), +// ** or \UXXXXXXXX (8 hexadecimal digits). To specify a backslash, +// ** write two backslashes. All other characters are taken literally. +// */ +func _unistrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j, n, nIn, v1 int32 + var z, zIn, zOut uintptr + var _ /* v at bp+0 */ Tu32 + _, _, _, _, _, _, _, _ = i, j, n, nIn, z, zIn, zOut, v1 + _ = argc + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn == uintptr(0) { + return + } + nIn = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + zOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nIn+int32(1))) + if zOut == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + v1 = libc.Int32FromInt32(0) + j = v1 + i = v1 + for i < nIn { + z = libc.Xstrchr(tls, zIn+uintptr(i), int32('\\')) + if z == uintptr(0) { + n = nIn - i + libc.X__builtin___memmove_chk(tls, zOut+uintptr(j), zIn+uintptr(i), libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + j = j + n + break + } + n = int32(int64(z) - t__predefined_ptrdiff_t(zIn+uintptr(i))) + if n > 0 { + libc.X__builtin___memmove_chk(tls, zOut+uintptr(j), zIn+uintptr(i), libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + j = j + n + i = i + n + } + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('\\') { + i = i + int32(2) + v1 = j + j = j + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v1))) = int8('\\') + } else { + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1)))))])&int32(0x08) != 0 { + if !(_isNHex(tls, zIn+uintptr(i+int32(1)), int32(4), bp) != 0) { + goto unistr_error + } + i = i + int32(5) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('+') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(6), bp) != 0) { + goto unistr_error + } + i = i + int32(8) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('u') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(4), bp) != 0) { + goto unistr_error + } + i = i + int32(6) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('U') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(8), bp) != 0) { + goto unistr_error + } + i = i + int32(10) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + goto unistr_error + } + } + } + } + } + } + **(**int8)(__ccgo_up(zOut + uintptr(j))) = 0 + Xsqlite3_result_text64(tls, context, zOut, libc.Uint64FromInt32(j), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) + return + goto unistr_error +unistr_error: + ; + Xsqlite3_free(tls, zOut) + Xsqlite3_result_error(tls, context, __ccgo_ts+16915, -int32(1)) + return +} + +// C documentation +// +// /* +// ** Test the existence of or access permissions of file zPath. The +// ** test performed depends on the value of flags: +// ** +// ** SQLITE_ACCESS_EXISTS: Return 1 if the file exists +// ** SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable. +// ** SQLITE_ACCESS_READONLY: Return 1 if the file is readable. +// ** +// ** Otherwise return 0. +// */ +func _unixAccess(tls *libc.TLS, NotUsed uintptr, zPath uintptr, flags int32, pResOut uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var _ /* buf at bp+0 */ Tstat + _ = NotUsed + /* The spec says there are three possible values for flags. But only + ** two of them are actually used */ + if flags == SQLITE_ACCESS_EXISTS { + **(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32(0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zPath, bp) && (!(libc.Int32FromUint16((**(**Tstat)(__ccgo_up(bp))).Fst_mode)&libc.Int32FromInt32(S_IFMT) == libc.Int32FromInt32(S_IFREG)) || (**(**Tstat)(__ccgo_up(bp))).Fst_size > 0)) + } else { + **(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zPath, libc.Int32FromInt32(1)< int32(SHARED_LOCK) { + reserved = int32(1) + } + /* Otherwise see if some other process holds it. + */ + if !(reserved != 0) && !((*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FbProcessLock != 0) { + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = SEEK_SET + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(1)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(F_GETLK), libc.VaList(bp+32, bp)) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(14)<iBusyTimeout +** value is set, then it is the number of milliseconds to wait before +** failing the lock. The iBusyTimeout value is always reset back to +** zero on each call. +** +** If SQLITE_ENABLE_SETLK_TIMEOUT is not defined, then do a non-blocking +** attempt to set the lock. + */ + +// C documentation +// +// /* +// ** Delete the file at zPath. If the dirSync argument is true, fsync() +// ** the directory after deleting the file. +// */ +func _unixDelete(tls *libc.TLS, NotUsed uintptr, zPath uintptr, dirSync int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* fd at bp+0 */ int32 + _ = rc + rc = SQLITE_OK + _ = NotUsed + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(16)].FpCurrent})))(tls, zPath) == -int32(1) { + if **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(ENOENT) { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(23)< _sqlite3Config.FmxMmap { + newLimit = _sqlite3Config.FmxMmap + } + /* The value of newLimit may be eventually cast to (size_t) and passed + ** to mmap(). Restrict its value to 2GB if (size_t) is not at least a + ** 64-bit type. */ + if newLimit > 0 && libc.Bool(uint64(8) < uint64(8)) { + newLimit = newLimit & libc.Int64FromInt32(0x7FFFFFFF) + } + **(**Ti64)(__ccgo_up(pArg)) = (*TunixFile)(unsafe.Pointer(pFile)).FmmapSizeMax + if newLimit >= 0 && newLimit != (*TunixFile)(unsafe.Pointer(pFile)).FmmapSizeMax && (*TunixFile)(unsafe.Pointer(pFile)).FnFetchOut == 0 { + (*TunixFile)(unsafe.Pointer(pFile)).FmmapSizeMax = newLimit + if (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize > 0 { + _unixUnmapfile(tls, pFile) + rc1 = _unixMapfile(tls, pFile, int64(-int32(1))) + } + } + return rc1 + case int32(SQLITE_FCNTL_SET_LOCKPROXYFILE): + fallthrough + case int32(SQLITE_FCNTL_GET_LOCKPROXYFILE): + return _proxyFileControl(tls, id, op, pArg) + case int32(SQLITE_FCNTL_EXTERNAL_READER): + return _unixFcntlExternalReader(tls, id, pArg) + } + return int32(SQLITE_NOTFOUND) +} + +// C documentation +// +// /* +// ** Determine the current size of a file in bytes +// */ +func _unixFileSize(tls *libc.TLS, id uintptr, pSize uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var rc int32 + var _ /* buf at bp+0 */ Tstat + _ = rc + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(id)).Fh, bp) + if rc != 0 { + _storeLastErrno(tls, id, **(**int32)(__ccgo_up(libc.X__error(tls)))) + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)< 0x40000200 +** +** This works well on the local file system, but shows a nearly 100x +** slowdown in read performance on AFP because the AFP client disables +** the read cache when byte-range locks are present. Enabling the read +** cache exposes a cache coherency problem that is present on all OS X +** supported network file systems. NFS and AFP both observe the +** close-to-open semantics for ensuring cache coherency +** [http://nfs.sourceforge.net/#faq_a8], which does not effectively +** address the requirements for concurrent database access by multiple +** readers and writers +** [http://www.nabble.com/SQLite-on-NFS-cache-coherency-td15655701.html]. +** +** To address the performance and cache coherency issues, proxy file locking +** changes the way database access is controlled by limiting access to a +** single host at a time and moving file locks off of the database file +** and onto a proxy file on the local file system. +** +** +** Using proxy locks +** ----------------- +** +** C APIs +** +** sqlite3_file_control(db, dbname, SQLITE_FCNTL_SET_LOCKPROXYFILE, +** | ":auto:"); +** sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE, +** &); +** +** +** SQL pragmas +** +** PRAGMA [database.]lock_proxy_file= | :auto: +** PRAGMA [database.]lock_proxy_file +** +** Specifying ":auto:" means that if there is a conch file with a matching +** host ID in it, the proxy path in the conch file will be used, otherwise +** a proxy path based on the user's temp dir +** (via confstr(_CS_DARWIN_USER_TEMP_DIR,...)) will be used and the +** actual proxy file name is generated from the name and path of the +** database file. For example: +** +** For database path "/Users/me/foo.db" +** The lock path will be "/sqliteplocks/_Users_me_foo.db:auto:") +** +** Once a lock proxy is configured for a database connection, it can not +** be removed, however it may be switched to a different proxy path via +** the above APIs (assuming the conch file is not being held by another +** connection or process). +** +** +** How proxy locking works +** ----------------------- +** +** Proxy file locking relies primarily on two new supporting files: +** +** * conch file to limit access to the database file to a single host +** at a time +** +** * proxy file to act as a proxy for the advisory locks normally +** taken on the database +** +** The conch file - to use a proxy file, sqlite must first "hold the conch" +** by taking an sqlite-style shared lock on the conch file, reading the +** contents and comparing the host's unique host ID (see below) and lock +** proxy path against the values stored in the conch. The conch file is +** stored in the same directory as the database file and the file name +** is patterned after the database file name as ".-conch". +** If the conch file does not exist, or its contents do not match the +** host ID and/or proxy path, then the lock is escalated to an exclusive +** lock and the conch file contents is updated with the host ID and proxy +** path and the lock is downgraded to a shared lock again. If the conch +** is held by another process (with a shared lock), the exclusive lock +** will fail and SQLITE_BUSY is returned. +** +** The proxy file - a single-byte file used for all advisory file locks +** normally taken on the database file. This allows for safe sharing +** of the database file for multiple readers and writers on the same +** host (the conch ensures that they all use the same local lock file). +** +** Requesting the lock proxy does not immediately take the conch, it is +** only taken when the first request to lock database file is made. +** This matches the semantics of the traditional locking behavior, where +** opening a connection to a database file does not take a lock on it. +** The shared lock and an open file descriptor are maintained until +** the connection to the database is closed. +** +** The proxy file and the lock file are never deleted so they only need +** to be created the first time they are used. +** +** Configuration options +** --------------------- +** +** SQLITE_PREFER_PROXY_LOCKING +** +** Database files accessed on non-local file systems are +** automatically configured for proxy locking, lock files are +** named automatically using the same logic as +** PRAGMA lock_proxy_file=":auto:" +** +** SQLITE_PROXY_DEBUG +** +** Enables the logging of error messages during host id file +** retrieval and creation +** +** LOCKPROXYDIR +** +** Overrides the default directory used for lock proxy files that +** are named automatically via the ":auto:" setting +** +** SQLITE_DEFAULT_PROXYDIR_PERMISSIONS +** +** Permissions to use when creating a directory for storing the +** lock proxy files, only used when LOCKPROXYDIR is not set. +** +** +** As mentioned above, when compiled with SQLITE_PREFER_PROXY_LOCKING, +** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will +** force proxy locking to be used for every database file opened, and 0 +** will force automatic proxy locking to be disabled for all database +** files (explicitly calling the SQLITE_FCNTL_SET_LOCKPROXYFILE pragma or +** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING). + */ + +/* +** Proxy locking is only available on MacOSX + */ + +// C documentation +// +// /* +// ** Create a temporary file name in zBuf. zBuf must be allocated +// ** by the calling process and must be big enough to hold at least +// ** pVfs->mxPathname bytes. +// */ +func _unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iLimit, rc, v1 int32 + var zDir uintptr + var v2 bool + var _ /* r at bp+0 */ Tu64 + _, _, _, _, _ = iLimit, rc, zDir, v1, v2 + iLimit = 0 + rc = SQLITE_OK + /* It's odd to simulate an io-error here, but really this is just + ** using the io-error infrastructure to test that SQLite handles this + ** function failing. + */ + **(**int8)(__ccgo_up(zBuf)) = 0 + Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + zDir = _unixTempFileDir(tls) + if zDir == uintptr(0) { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(25)< int32(10) { + rc = int32(SQLITE_ERROR) + break + } + } + } + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + return rc +} + +// C documentation +// +// /* +// ** If pFile has a -shm file open and it is sharing that file with some +// ** other connection, either in the same process or in a separate process, +// ** then return true. Return false if either pFile does not have a -shm +// ** file open or if it is the only connection to that -shm file across the +// ** entire system. +// ** +// ** This routine is not required for correct operation. It can always return +// ** false and SQLite will continue to operate according to spec. However, +// ** when this routine does its job, it adds extra robustness in cases +// ** where database file locks have been erroneously deleted in a WAL-mode +// ** database by doing close(open(DATABASE_PATHNAME)) or similar. +// ** +// ** With false negatives, SQLite still operates to spec, though with less +// ** robustness. With false positives, the last database connection on a +// ** WAL-mode database will fail to unlink the -wal and -shm files, which +// ** is annoying but harmless. False positives will also prevent a database +// ** connection from running "PRAGMA journal_mode=DELETE" in order to take +// ** the database out of WAL mode, which is perhaps more serious, but is +// ** still not a disaster. +// */ +func _unixIsSharingShmNode(tls *libc.TLS, pFile uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pShmNode uintptr + var _ /* lock at bp+0 */ Tflock + _ = pShmNode + if (*TunixFile)(unsafe.Pointer(pFile)).FpShm == uintptr(0) { + return 0 + } + if libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFile)).FctrlFlags)&int32(UNIXFILE_EXCL) != 0 { + return 0 + } + pShmNode = (*TunixShm)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpShm)).FpShmNode + libc.X__builtin___memset_chk(tls, bp, 0, uint64(24), ^t__predefined_size_t(0)) + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = SEEK_SET + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64((libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4) + libc.Int32FromInt32(SQLITE_SHM_NLOCK)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int32(F_GETLK), libc.VaList(bp+32, bp)) + return libc.BoolInt32(int32((**(**Tflock)(__ccgo_up(bp))).Fl_type) != int32(F_UNLCK)) +} + +// C documentation +// +// /* +// ** The DMS lock has not yet been taken on shm file pShmNode. Attempt to +// ** take it now. Return SQLITE_OK if successful, or an SQLite error +// ** code otherwise. +// ** +// ** If the DMS cannot be locked because this is a readonly_shm=1 +// ** connection and no other process already holds a lock, return +// ** SQLITE_READONLY_CANTINIT and set pShmNode->isUnlocked=1. +// */ +func _unixLockSharedMemory(tls *libc.TLS, pDbFd uintptr, pShmNode uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var rc int32 + var _ /* lock at bp+0 */ Tflock + _ = rc + rc = SQLITE_OK + /* Use F_GETLK to determine the locks other processes are holding + ** on the DMS byte. If it indicates that another process is holding + ** a SHARED lock, then this process may also take a SHARED lock + ** and proceed with opening the *-shm file. + ** + ** Or, if no other process is holding any lock, then this process + ** is the first to open it. In this case take an EXCLUSIVE lock on the + ** DMS byte and truncate the *-shm file to zero bytes in size. Then + ** downgrade to a SHARED lock on the DMS byte. + ** + ** If another process is holding an EXCLUSIVE lock on the DMS byte, + ** return SQLITE_BUSY to the caller (it will try again). An earlier + ** version of this code attempted the SHARED lock at this point. But + ** this introduced a subtle race condition: if the process holding + ** EXCLUSIVE failed just before truncating the *-shm file, then this + ** process might open and use the *-shm file without truncating it. + ** And if the *-shm file has been corrupted by a power failure or + ** system crash, the database itself may also become corrupt. */ + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = SEEK_SET + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64((libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4) + libc.Int32FromInt32(SQLITE_SHM_NLOCK)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int32(F_GETLK), libc.VaList(bp+32, bp)) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(15)< (READWRITE | CREATE) +// ** ReadOnly() -> (READONLY) +// ** OpenExclusive() -> (READWRITE | CREATE | EXCLUSIVE) +// ** +// ** The old OpenExclusive() accepted a boolean argument - "delFlag". If +// ** true, the file was configured to be automatically deleted when the +// ** file handle closed. To achieve the same effect using this new +// ** interface, add the DELETEONCLOSE flag to those specified above for +// ** OpenExclusive(). +// */ +func _unixOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, flags int32, pOutFlags uintptr) (r int32) { + bp := tls.Alloc(2704) + defer tls.Free(2704) + var ctrlFlags, eType, fd, isAutoProxy, isCreate, isDelete, isExclusive, isNewJrnl, isReadWrite, isReadonly, noLock, openFlags, rc, rc2, useProxy int32 + var envforce, p, pReadonly, pUnused, zName uintptr + var _ /* fsInfo at bp+0 */ Tstatfs + var _ /* gid at bp+2688 */ Tgid_t + var _ /* openMode at bp+2682 */ Tmode_t + var _ /* uid at bp+2684 */ Tuid_t + var _ /* zTmpname at bp+2168 */ [514]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ctrlFlags, eType, envforce, fd, isAutoProxy, isCreate, isDelete, isExclusive, isNewJrnl, isReadWrite, isReadonly, noLock, openFlags, p, pReadonly, pUnused, rc, rc2, useProxy, zName + p = pFile + fd = -int32(1) /* File descriptor returned by open() */ + openFlags = 0 /* Flags to pass to open() */ + eType = flags & int32(0x0FFF00) /* True to omit locking primitives */ + rc = SQLITE_OK /* Function Return Code */ + ctrlFlags = 0 /* UNIXFILE_* flags */ + isExclusive = flags & int32(SQLITE_OPEN_EXCLUSIVE) + isDelete = flags & int32(SQLITE_OPEN_DELETEONCLOSE) + isCreate = flags & int32(SQLITE_OPEN_CREATE) + isReadonly = flags & int32(SQLITE_OPEN_READONLY) + isReadWrite = flags & int32(SQLITE_OPEN_READWRITE) + isAutoProxy = flags & int32(SQLITE_OPEN_AUTOPROXY) + /* If creating a super- or main-file journal, this function will open + ** a file-descriptor on the directory too. The first time unixSync() + ** is called the directory file descriptor will be fsync()ed and close()d. + */ + isNewJrnl = libc.BoolInt32(isCreate != 0 && (eType == int32(SQLITE_OPEN_SUPER_JOURNAL) || eType == int32(SQLITE_OPEN_MAIN_JOURNAL) || eType == int32(SQLITE_OPEN_WAL))) + zName = zPath + /* Check the following statements are true: + ** + ** (a) Exactly one of the READWRITE and READONLY flags must be set, and + ** (b) if CREATE is set, then READWRITE must also be set, and + ** (c) if EXCLUSIVE is set, then CREATE must also be set. + ** (d) if DELETEONCLOSE is set, then CREATE must also be set. + */ + /* The main DB, main journal, WAL file and super-journal are never + ** automatically deleted. Nor are they ever temporary files. */ + /* Assert that the upper layer has set one of the "file-type" flags. */ + /* Detect a pid change and reset the PRNG. There is a race condition + ** here such that two or more threads all trying to open databases at + ** the same instant might all reset the PRNG. But multiple resets + ** are harmless. + */ + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_randomnessPid))) != libc.Xgetpid(tls) { + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_randomnessPid)), libc.Xgetpid(tls)) + Xsqlite3_randomness(tls, 0, uintptr(0)) + } + libc.X__builtin___memset_chk(tls, p, 0, uint64(128), ^t__predefined_size_t(0)) + if eType == int32(SQLITE_OPEN_MAIN_DB) { + pUnused = _findReusableFd(tls, zName, flags) + if pUnused != 0 { + fd = (*TUnixUnusedFd)(unsafe.Pointer(pUnused)).Ffd + } else { + pUnused = Xsqlite3_malloc64(tls, uint64(16)) + if !(pUnused != 0) { + return int32(SQLITE_NOMEM) + } + } + (*TunixFile)(unsafe.Pointer(p)).FpPreallocatedUnused = pUnused + /* Database filenames are double-zero terminated if they are not + ** URIs with parameters. Hence, they can always be passed into + ** sqlite3_uri_parameter(). */ + } else { + if !(zName != 0) { + /* If zName is NULL, the upper layer is requesting a temp file. */ + rc = _unixGetTempname(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname, bp+2168) + if rc != SQLITE_OK { + return rc + } + zName = bp + 2168 + /* Generated temporary filenames are always double-zero terminated + ** for use by sqlite3_uri_parameter(). */ + } + } + /* Determine the value of the flags parameter passed to POSIX function + ** open(). These must be calculated even if open() is not called, as + ** they may be stored as part of the file handle and used by the + ** 'conch file' locking functions later on. */ + if isReadonly != 0 { + openFlags = openFlags | O_RDONLY + } + if isReadWrite != 0 { + openFlags = openFlags | int32(O_RDWR) + } + if isCreate != 0 { + openFlags = openFlags | int32(O_CREAT) + } + if isExclusive != 0 { + openFlags = openFlags | (libc.Int32FromInt32(O_EXCL) | libc.Int32FromInt32(O_NOFOLLOW)) + } + openFlags = openFlags | (libc.Int32FromInt32(O_LARGEFILE) | libc.Int32FromInt32(O_BINARY) | libc.Int32FromInt32(O_NOFOLLOW)) + if fd < 0 { /* Groupid for the file */ + rc = _findCreateFileMode(tls, zName, flags, bp+2682, bp+2684, bp+2688) + if rc != SQLITE_OK { + return rc + } + fd = _robust_open(tls, zName, openFlags, **(**Tmode_t)(__ccgo_up(bp + 2682))) + if fd < 0 { + if isNewJrnl != 0 && **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(EACCES) && (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zName, F_OK) != 0 { + /* If unable to create a journal because the directory is not + ** writable, change the error code to indicate that. */ + rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(6)< 0) + } else { + useProxy = libc.BoolInt32(!((**(**Tstatfs)(__ccgo_up(bp))).Ff_flags&libc.Uint32FromInt32(MNT_LOCAL) != 0)) + } + if useProxy != 0 { + rc = _fillInUnixFile(tls, pVfs, fd, pFile, zPath, ctrlFlags) + if rc == SQLITE_OK { + rc = _proxyTransformUnixFile(tls, pFile, __ccgo_ts+4139) + if rc != SQLITE_OK { + /* Use unixClose to clean up the resources added in fillInUnixFile + ** and clear all the structure's references. Specifically, + ** pFile->pMethods will be NULL so sqlite3OsClose will be a no-op + */ + _unixClose(tls, pFile) + return rc + } + } + goto open_finished + } + } + rc = _fillInUnixFile(tls, pVfs, fd, pFile, zPath, ctrlFlags) + goto open_finished +open_finished: + ; + if rc != SQLITE_OK { + Xsqlite3_free(tls, (*TunixFile)(unsafe.Pointer(p)).FpPreallocatedUnused) + } + return rc +} + +// C documentation +// +// /* +// ** Open a shared-memory area associated with open database file pDbFd. +// ** This particular implementation uses mmapped files. +// ** +// ** The file used to implement shared-memory is in the same directory +// ** as the open database file and has the same name as the open database +// ** file with the "-shm" suffix added. For example, if the database file +// ** is "/home/user1/config.db" then the file that is created and mmapped +// ** for shared memory will be called "/home/user1/config.db-shm". +// ** +// ** Another approach to is to use files in /dev/shm or /dev/tmp or an +// ** some other tmpfs mount. But if a file in a different directory +// ** from the database file is used, then differing access permissions +// ** or a chroot() might cause two different processes on the same +// ** database to end up using different files for shared memory - +// ** meaning that their memory would not really be shared - resulting +// ** in database corruption. Nevertheless, this tmpfs file usage +// ** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY="/dev/shm" +// ** or the equivalent. The use of the SQLITE_SHM_DIRECTORY compile-time +// ** option results in an incompatible build of SQLite; builds of SQLite +// ** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the +// ** same database file at the same time, database corruption will likely +// ** result. The SQLITE_SHM_DIRECTORY compile-time option is considered +// ** "unsupported" and may go away in a future SQLite release. +// ** +// ** When opening a new shared-memory file, if no other instances of that +// ** file are currently open, in this process or in other processes, then +// ** the file must be truncated to zero length or have its header cleared. +// ** +// ** If the original database file (pDbFd) is using the "unix-excl" VFS +// ** that means that an exclusive lock is held on the database file and +// ** that no other processes are able to read or write the database. In +// ** that case, we do not really need shared memory. No shared memory +// ** file is created. The shared memory will be simulated with heap memory. +// */ +func _unixOpenSharedMemory(tls *libc.TLS, pDbFd uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var nShmFilename, rc int32 + var p, pInode, pShmNode, zBasePath, zShm, v1 uintptr + var _ /* sStat at bp+0 */ Tstat + _, _, _, _, _, _, _, _ = nShmFilename, p, pInode, pShmNode, rc, zBasePath, zShm, v1 + p = uintptr(0) /* The underlying mmapped file */ + rc = SQLITE_OK /* Size of the SHM filename in bytes */ + /* Allocate space for the new unixShm object. */ + p = Xsqlite3_malloc64(tls, uint64(24)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, p, 0, uint64(24), ^t__predefined_size_t(0)) + /* Check to see if a unixShmNode object already exists. Reuse an existing + ** one if present. Create a new one if necessary. + */ + _unixEnterMutex(tls) + pInode = (*TunixFile)(unsafe.Pointer(pDbFd)).FpInode + pShmNode = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpShmNode + if pShmNode == uintptr(0) { /* fstat() info for database file */ + zBasePath = (*TunixFile)(unsafe.Pointer(pDbFd)).FzPath + /* Call fstat() to figure out the permissions on the database file. If + ** a new *-shm file is created, an attempt will be made to create it + ** with the same permissions. + */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pDbFd)).Fh, bp) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)<pFirst. This must be done while holding the + ** pShmNode->pShmMutex. + */ + Xsqlite3_mutex_enter(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + (*TunixShm)(unsafe.Pointer(p)).FpNext = (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpFirst + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpFirst = p + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + return rc + /* Jump here on any error */ + goto shm_open_err +shm_open_err: + ; + _unixShmPurge(tls, pDbFd) /* This call frees pShmNode if required */ + Xsqlite3_free(tls, p) + _unixLeaveMutex(tls) + return rc +} + +// C documentation +// +// /* +// ** Write nBuf bytes of random data to the supplied buffer zBuf. +// */ +func _unixRandomness(tls *libc.TLS, NotUsed uintptr, nBuf int32, zBuf uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var fd, got int32 + var _ /* rp at bp+8 */ Tpid_t + var _ /* t at bp+0 */ Ttime_t + _, _ = fd, got + _ = NotUsed + /* We have to initialize zBuf to prevent valgrind from reporting + ** errors. The reports issued by valgrind are incorrect - we would + ** prefer that the randomness be increased by making use of the + ** uninitialized space in zBuf - but valgrind errors tend to worry + ** some users. Rather than argue, it seems easier just to initialize + ** the whole array and silence valgrind, even if that means less randomness + ** in the random seed. + ** + ** When testing, initializing zBuf[] to zero is all we do. That means + ** that we always use the same random number sequence. This makes the + ** tests repeatable. + */ + libc.X__builtin___memset_chk(tls, zBuf, 0, libc.Uint64FromInt32(nBuf), ^t__predefined_size_t(0)) + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_randomnessPid)), libc.Xgetpid(tls)) + fd = _robust_open(tls, __ccgo_ts+4152, O_RDONLY, uint16(0)) + if fd < 0 { + libc.Xtime(tls, bp) + libc.X__builtin___memcpy_chk(tls, zBuf, bp, uint64(8), ^t__predefined_size_t(0)) + **(**Tpid_t)(__ccgo_up(bp + 8)) = libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_randomnessPid))) + libc.X__builtin___memcpy_chk(tls, zBuf+uintptr(8), bp+8, uint64(4), ^t__predefined_size_t(0)) + nBuf = libc.Int32FromUint64(libc.Uint64FromInt64(8) + libc.Uint64FromInt64(4)) + } else { + for cond := true; cond; cond = got < 0 && **(**int32)(__ccgo_up(libc.X__error(tls))) == int32(EINTR) { + got = int32((*(*func(*libc.TLS, int32, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(8)].FpCurrent})))(tls, fd, zBuf, libc.Uint64FromInt32(nBuf))) + } + _robust_close(tls, uintptr(0), fd, int32(47319)) + } + return nBuf +} + +// C documentation +// +// /* +// ** Read data from a file into a buffer. Return SQLITE_OK if all +// ** bytes were read successfully and SQLITE_IOERR if anything goes +// ** wrong. +// */ +func _unixRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Tsqlite3_int64) (r int32) { + var got, nCopy int32 + var pFile uintptr + _, _, _ = got, nCopy, pFile + pFile = id + /* If this is a database file (not a journal, super-journal or temp + ** file), the bytes in the locking range should never be read or written. */ + /* Deal with as much of this read request as possible by transferring + ** data from the memory mapping using memcpy(). */ + if offset < (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize { + if offset+int64(amt) <= (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize { + libc.X__builtin___memcpy_chk(tls, pBuf, (*TunixFile)(unsafe.Pointer(pFile)).FpMapRegion+uintptr(offset), libc.Uint64FromInt32(amt), ^t__predefined_size_t(0)) + return SQLITE_OK + } else { + nCopy = int32((*TunixFile)(unsafe.Pointer(pFile)).FmmapSize - offset) + libc.X__builtin___memcpy_chk(tls, pBuf, (*TunixFile)(unsafe.Pointer(pFile)).FpMapRegion+uintptr(offset), libc.Uint64FromInt32(nCopy), ^t__predefined_size_t(0)) + pBuf = pBuf + uintptr(nCopy) + amt = amt - nCopy + offset = offset + int64(nCopy) + } + } + got = _seekAndRead(tls, pFile, offset, pBuf, amt) + if got == amt { + return SQLITE_OK + } else { + if got < 0 { + /* pFile->lastErrno has been set by seekAndRead(). + ** Usually we return SQLITE_IOERR_READ here, though for some + ** kinds of errors we return SQLITE_IOERR_CORRUPTFS. The + ** SQLITE_IOERR_CORRUPTFS will be converted into SQLITE_CORRUPT + ** prior to returning to the application by the sqlite3ApiExit() + ** routine. + */ + switch (*TunixFile)(unsafe.Pointer(pFile)).FlastErrno { + case int32(ERANGE): + fallthrough + case int32(EIO): + fallthrough + case int32(ENXIO): + fallthrough + case int32(EDEVERR): + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(33)<=3 && ofst int32(1) { + bUnlock = 0 + **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) = **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) - 1 + v1 = p + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromUint16(mask)) + } + } + if bUnlock != 0 { + rc = _unixShmSystemLock(tls, pDbFd, int32(F_UNLCK), ofst+(libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4), n) + if rc == SQLITE_OK { + libc.X__builtin___memset_chk(tls, aLock+uintptr(ofst)*4, 0, uint64(4)*libc.Uint64FromInt32(n), ^t__predefined_size_t(0)) + v1 = p + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromUint16(mask)) + v1 = p + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromUint16(mask)) + } + } + } else { + if flags&int32(SQLITE_SHM_SHARED) != 0 { + /* Case (b) - a shared lock. */ + if **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) < 0 { + /* An exclusive lock is held by some other connection. BUSY. */ + rc = int32(SQLITE_BUSY) + } else { + if **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) == 0 { + rc = _unixShmSystemLock(tls, pDbFd, int32(F_RDLCK), ofst+(libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4), n) + } + } + /* Get the local shared locks */ + if rc == SQLITE_OK { + v1 = p + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16(mask)) + **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) = **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) + 1 + } + } else { + /* Make sure no sibling connections hold locks that will block this + ** lock. If any do, return SQLITE_BUSY right away. */ + ii = ofst + for { + if !(ii < ofst+n) { + break + } + if **(**int32)(__ccgo_up(aLock + uintptr(ii)*4)) != 0 { + rc = int32(SQLITE_BUSY) + break + } + goto _5 + _5: + ; + ii = ii + 1 + } + /* Get the exclusive locks at the system level. Then if successful + ** also update the in-memory values. */ + if rc == SQLITE_OK { + rc = _unixShmSystemLock(tls, pDbFd, int32(F_WRLCK), ofst+(libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4), n) + if rc == SQLITE_OK { + v1 = p + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16(mask)) + ii = ofst + for { + if !(ii < ofst+n) { + break + } + **(**int32)(__ccgo_up(aLock + uintptr(ii)*4)) = -int32(1) + goto _7 + _7: + ; + ii = ii + 1 + } + } + } + } + } + } + /* Drop the mutexes acquired above. */ + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + } + return rc +} + +// C documentation +// +// /* +// ** This function is called to obtain a pointer to region iRegion of the +// ** shared-memory associated with the database file fd. Shared-memory regions +// ** are numbered starting from zero. Each shared-memory region is szRegion +// ** bytes in size. +// ** +// ** If an error occurs, an error code is returned and *pp is set to NULL. +// ** +// ** Otherwise, if the bExtend parameter is 0 and the requested shared-memory +// ** region has not been allocated (by any client, including one running in a +// ** separate process), then *pp is set to NULL and SQLITE_OK returned. If +// ** bExtend is non-zero and the requested shared-memory region has not yet +// ** been allocated, it is allocated by this function. +// ** +// ** If the shared-memory region has already been allocated or is allocated by +// ** this call as described above, then it is mapped into this processes +// ** address space (if it is not already), *pp is set to point to the mapped +// ** memory and SQLITE_OK returned. +// */ +func _unixShmMap(tls *libc.TLS, fd uintptr, iRegion int32, szRegion int32, bExtend int32, pp uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var apNew, p, pDbFd, pMem, pShmNode, zFile, v4 uintptr + var i, iPg, nByte, nMap Ti64 + var nReqRegion, nShmPerMap, rc, v2 int32 + var _ /* sStat at bp+0 */ Tstat + var _ /* x at bp+144 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = apNew, i, iPg, nByte, nMap, nReqRegion, nShmPerMap, p, pDbFd, pMem, pShmNode, rc, zFile, v2, v4 + pDbFd = fd + rc = SQLITE_OK + nShmPerMap = _unixShmRegionPerMap(tls) + /* If the shared-memory file has not yet been opened, open it now. */ + if (*TunixFile)(unsafe.Pointer(pDbFd)).FpShm == uintptr(0) { + rc = _unixOpenSharedMemory(tls, pDbFd) + if rc != SQLITE_OK { + return rc + } + } + p = (*TunixFile)(unsafe.Pointer(pDbFd)).FpShm + pShmNode = (*TunixShm)(unsafe.Pointer(p)).FpShmNode + Xsqlite3_mutex_enter(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked != 0 { + rc = _unixLockSharedMemory(tls, pDbFd, pShmNode) + if rc != SQLITE_OK { + goto shmpage_out + } + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked = uint8(0) + } + /* Minimum number of regions required to be mapped. */ + nReqRegion = (iRegion + nShmPerMap) / nShmPerMap * nShmPerMap + if libc.Int32FromUint16((*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRegion) < nReqRegion { /* New apRegion[] array */ + nByte = int64(nReqRegion) * int64(szRegion) /* Used by fstat() */ + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FszRegion = szRegion + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0 { + /* The requested region is not mapped into this processes address space. + ** Check to see if it has been allocated (i.e. if the wal-index file is + ** large enough to contain the requested region). + */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, bp) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(19)<= 0 { + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 { + v2 = int32(PROT_READ) + } else { + v2 = libc.Int32FromInt32(PROT_READ) | libc.Int32FromInt32(PROT_WRITE) + } + pMem = (*(*func(*libc.TLS, uintptr, Tsize_t, int32, int32, int32, Toff_t) uintptr)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(22)].FpCurrent})))(tls, uintptr(0), libc.Uint64FromInt64(nMap), v2, int32(MAP_SHARED), (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(szRegion)*libc.Int64FromUint16((*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRegion)) + if pMem == uintptr(-libc.Int32FromInt32(1)) { + rc = _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(21)< iRegion { + **(**uintptr)(__ccgo_up(pp)) = **(**uintptr)(__ccgo_up((*TunixShmNode)(unsafe.Pointer(pShmNode)).FapRegion + uintptr(iRegion)*8)) + } else { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 && rc == SQLITE_OK { + rc = int32(SQLITE_READONLY) + } + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + return rc +} + +// C documentation +// +// /* +// ** Make sure all writes to a particular file are committed to disk. +// ** +// ** If dataOnly==0 then both the file itself and its metadata (file +// ** size, access time, etc) are synced. If dataOnly!=0 then only the +// ** file data is synced. +// ** +// ** Under Unix, also make sure that the directory entry for the file +// ** has been created by fsync-ing the directory that contains the file. +// ** If we do not do this and we encounter a power failure, the directory +// ** entry for the journal might not exist after we reboot. The next +// ** SQLite to access the file will not know that the journal exists (because +// ** the directory entry for the journal was never created) and the transaction +// ** will not roll back - possibly leading to database corruption. +// */ +func _unixSync(tls *libc.TLS, id uintptr, flags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var isDataOnly, isFullsync, rc int32 + var pFile, v1 uintptr + var _ /* dirfd at bp+0 */ int32 + _, _, _, _, _ = isDataOnly, isFullsync, pFile, rc, v1 + pFile = id + isDataOnly = flags & int32(SQLITE_SYNC_DATAONLY) + isFullsync = libc.BoolInt32(flags&int32(0x0F) == int32(SQLITE_SYNC_FULL)) + /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */ + /* Unix cannot, but some systems may return SQLITE_FULL from here. This + ** line is to test that doing so does not cause any problems. + */ + rc = _full_fsync(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, isFullsync, isDataOnly) + if rc != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__error(tls)))) + return _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(4)<= libc.Uint64FromInt64(48)/libc.Uint64FromInt64(8) { + break + } + v1 = i + i = i + 1 + zDir = _azTempDirs[v1] + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Initialize first two members of azTempDirs[] array. +// */ +func _unixTempFileInit(tls *libc.TLS) { + _azTempDirs[0] = libc.Xgetenv(tls, __ccgo_ts+4055) + _azTempDirs[int32(1)] = libc.Xgetenv(tls, __ccgo_ts+4069) +} + +// C documentation +// +// /* +// ** Extract a value from the supplied expression in the manner described +// ** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object +// ** using valueNew(). +// ** +// ** If pCtx is NULL and an error occurs after the sqlite3_value object +// ** has been allocated, it is freed before returning. Or, if pCtx is not +// ** NULL, it is assumed that the caller will free any allocated object +// ** in all cases. +// */ +func _valueFromExpr(tls *libc.TLS, db uintptr, pExpr uintptr, enc Tu8, affinity Tu8, ppVal uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aff Tu8 + var nVal, negInt, op, rc, v1 int32 + var pLeft, zNeg, zVal, v3 uintptr + var _ /* iVal at bp+8 */ Ti64 + var _ /* pVal at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aff, nVal, negInt, op, pLeft, rc, zNeg, zVal, v1, v3 + zVal = uintptr(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + negInt = int32(1) + zNeg = __ccgo_ts + 1702 + rc = SQLITE_OK + for { + v1 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + op = v1 + if !(v1 == int32(TK_UPLUS) || op == int32(TK_SPAN)) { + break + } + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + } + if op == int32(TK_REGISTER) { + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) + } + /* Compressed expressions only appear when parsing the DEFAULT clause + ** on a table column definition, and hence only when pCtx==0. This + ** check ensures that an EP_TokenOnly expression is never passed down + ** into valueFromFunction(). */ + if op == int32(TK_CAST) { + aff = libc.Uint8FromInt8(_sqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0))) + rc = _valueFromExpr(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, enc, aff, ppVal, pCtx) + if **(**uintptr)(__ccgo_up(ppVal)) != 0 { + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppVal)))).Fflags)&int32(MEM_Zero) != 0 { + v1 = _sqlite3VdbeMemExpandBlob(tls, **(**uintptr)(__ccgo_up(ppVal))) + } else { + v1 = 0 + } + rc = v1 + _sqlite3VdbeMemCast(tls, **(**uintptr)(__ccgo_up(ppVal)), aff, enc) + _sqlite3ValueApplyAffinity(tls, **(**uintptr)(__ccgo_up(ppVal)), affinity, enc) + } + return rc + } + /* Handle negative integers in a single step. This is needed in the + ** case when the value is -9223372036854775808. Except - do not do this + ** for hexadecimal literals. */ + if op == int32(TK_UMINUS) { + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) == int32(TK_INTEGER) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) == int32(TK_FLOAT) { + if (*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != uint32(0) || int32(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pLeft + 8))))) != int32('0') || int32(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pLeft + 8)) + 1))) & ^libc.Int32FromInt32(0x20) != int32('X') { + pExpr = pLeft + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + negInt = -int32(1) + zNeg = __ccgo_ts + 5569 + } + } + } + if op == int32(TK_STRING) || op == int32(TK_FLOAT) || op == int32(TK_INTEGER) { + **(**uintptr)(__ccgo_up(bp)) = _valueNew(tls, db, pCtx) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + goto no_mem + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != uint32(0) { + _sqlite3VdbeMemSetInt64(tls, **(**uintptr)(__ccgo_up(bp)), int64(*(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fu)))*int64(negInt)) + } else { + if op == int32(TK_INTEGER) && 0 == _sqlite3DecOrHexToI64(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), bp+8) { + _sqlite3VdbeMemSetInt64(tls, **(**uintptr)(__ccgo_up(bp)), **(**Ti64)(__ccgo_up(bp + 8))*int64(negInt)) + } else { + zVal = _sqlite3MPrintf(tls, db, __ccgo_ts+5571, libc.VaList(bp+24, zNeg, *(*uintptr)(unsafe.Pointer(pExpr + 8)))) + if zVal == uintptr(0) { + goto no_mem + } + _sqlite3ValueSetStr(tls, **(**uintptr)(__ccgo_up(bp)), -int32(1), zVal, uint8(SQLITE_UTF8), __ccgo_fp(_sqlite3RowSetClear)) + } + } + if libc.Int32FromUint8(affinity) == int32(SQLITE_AFF_BLOB) { + if op == int32(TK_FLOAT) { + _sqlite3AtoF(tls, (*Tsqlite3_value)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fz, **(**uintptr)(__ccgo_up(bp))) + (*Tsqlite3_value)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fflags = uint16(MEM_Real) + } else { + if op == int32(TK_INTEGER) { + /* This case is required by -9223372036854775808 and other strings + ** that look like integers but cannot be handled by the + ** sqlite3DecOrHexToI64() call above. */ + _sqlite3ValueApplyAffinity(tls, **(**uintptr)(__ccgo_up(bp)), uint8(SQLITE_AFF_NUMERIC), uint8(SQLITE_UTF8)) + } + } + } else { + _sqlite3ValueApplyAffinity(tls, **(**uintptr)(__ccgo_up(bp)), affinity, uint8(SQLITE_UTF8)) + } + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)) != 0 { + v3 = **(**uintptr)(__ccgo_up(bp)) + 20 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^libc.Int32FromInt32(MEM_Str)) + } + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) { + rc = _sqlite3VdbeChangeEncoding(tls, **(**uintptr)(__ccgo_up(bp)), libc.Int32FromUint8(enc)) + } + } else { + if op == int32(TK_UMINUS) { + /* This branch happens for multiple negative signs. Ex: -(-5) */ + if SQLITE_OK == _valueFromExpr(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, enc, affinity, bp, pCtx) && **(**uintptr)(__ccgo_up(bp)) != uintptr(0) { + _sqlite3VdbeMemNumerify(tls, **(**uintptr)(__ccgo_up(bp))) + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fflags)&int32(MEM_Real) != 0 { + *(*float64)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))) = -*(*float64)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))) + } else { + if *(*Ti64)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))) == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= int32(SQLITE_TXN_WRITE) { + rc = _sqlite3BtreeCommitPhaseOne(tls, pBt1, uintptr(0)) + } + goto _2 + _2: + ; + i = i + 1 + } + } + /* Do the commit only if all databases successfully complete phase 1. + ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an + ** IO error while deleting or truncating a journal file. It is unlikely, + ** but could happen. In this case abandon processing and return the error. + */ + i = 0 + for { + if !(rc == SQLITE_OK && i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + txn = _sqlite3BtreeTxnState(tls, pBt2) + if txn != SQLITE_TXN_NONE { + rc = _sqlite3BtreeCommitPhaseTwo(tls, pBt2, 0) + } + goto _3 + _3: + ; + i = i + 1 + } + if rc == SQLITE_OK { + _sqlite3VtabCommit(tls, db) + } + } else { + pVfs = (*Tsqlite3)(unsafe.Pointer(db)).FpVfs + zSuper = uintptr(0) /* File-name for the super-journal */ + zMainFile = _sqlite3BtreeGetFilename(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpBt) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + offset = 0 + retryCount = 0 + /* Select a super-journal file name */ + nMainFile = _sqlite3Strlen30(tls, zMainFile) + zSuper = _sqlite3MPrintf(tls, db, __ccgo_ts+5682, libc.VaList(bp+24, 0, zMainFile, 0)) + if zSuper == uintptr(0) { + return int32(SQLITE_NOMEM) + } + zSuper = zSuper + uintptr(4) + for cond := true; cond; cond = rc == SQLITE_OK && **(**int32)(__ccgo_up(bp + 8)) != 0 { + if retryCount != 0 { + if retryCount > int32(100) { + Xsqlite3_log(tls, int32(SQLITE_FULL), __ccgo_ts+5694, libc.VaList(bp+24, zSuper)) + _sqlite3OsDelete(tls, pVfs, zSuper, 0) + break + } else { + if retryCount == int32(1) { + Xsqlite3_log(tls, int32(SQLITE_FULL), __ccgo_ts+5708, libc.VaList(bp+24, zSuper)) + } + } + } + retryCount = retryCount + 1 + Xsqlite3_randomness(tls, int32(4), bp+12) + Xsqlite3_snprintf(tls, int32(13), zSuper+uintptr(nMainFile), __ccgo_ts+5723, libc.VaList(bp+24, **(**Tu32)(__ccgo_up(bp + 12))>>libc.Int32FromInt32(8)&uint32(0xffffff), **(**Tu32)(__ccgo_up(bp + 12))&uint32(0xff))) + /* The antipenultimate character of the super-journal name must + ** be "9" to avoid name collisions when using 8+3 filenames. */ + rc = _sqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+8) + } + if rc == SQLITE_OK { + /* Open the super-journal. */ + rc = _sqlite3OsOpenMalloc(tls, pVfs, zSuper, bp, libc.Int32FromInt32(SQLITE_OPEN_READWRITE)|libc.Int32FromInt32(SQLITE_OPEN_CREATE)|libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE)|libc.Int32FromInt32(SQLITE_OPEN_SUPER_JOURNAL), uintptr(0)) + } + if rc != SQLITE_OK { + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + return rc + } + /* Write the name of each database file in the transaction into the new + ** super-journal file. If an error occurs at this point close + ** and delete the super-journal file. All the individual journal files + ** still have 'null' as the super-journal pointer, so they will roll + ** back independently if a failure occurs. + */ + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt3 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if _sqlite3BtreeTxnState(tls, pBt3) == int32(SQLITE_TXN_WRITE) { + zFile = _sqlite3BtreeGetJournalname(tls, pBt3) + if zFile == uintptr(0) { + goto _4 /* Ignore TEMP and :memory: databases */ + } + rc = _sqlite3OsWrite(tls, **(**uintptr)(__ccgo_up(bp)), zFile, _sqlite3Strlen30(tls, zFile)+int32(1), offset) + offset = offset + int64(_sqlite3Strlen30(tls, zFile)+int32(1)) + if rc != SQLITE_OK { + _sqlite3OsCloseFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3OsDelete(tls, pVfs, zSuper, 0) + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + return rc + } + } + goto _4 + _4: + ; + i = i + 1 + } + /* Sync the super-journal file. If the IOCAP_SEQUENTIAL device + ** flag is set this is not required. + */ + if v6 = 0 == _sqlite3OsDeviceCharacteristics(tls, **(**uintptr)(__ccgo_up(bp)))&int32(SQLITE_IOCAP_SEQUENTIAL); v6 { + v5 = _sqlite3OsSync(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_SYNC_NORMAL)) + rc = v5 + } + if v6 && SQLITE_OK != v5 { + _sqlite3OsCloseFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3OsDelete(tls, pVfs, zSuper, 0) + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + return rc + } + /* Sync all the db files involved in the transaction. The same call + ** sets the super-journal pointer in each individual journal. If + ** an error occurs here, do not delete the super-journal file. + ** + ** If the error occurs during the first call to + ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the + ** super-journal file will be orphaned. But we cannot delete it, + ** in case the super-journal file name was written into the journal + ** file before the failure occurred. + */ + i = 0 + for { + if !(rc == SQLITE_OK && i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt4 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt4 != 0 { + rc = _sqlite3BtreeCommitPhaseOne(tls, pBt4, zSuper) + } + goto _7 + _7: + ; + i = i + 1 + } + _sqlite3OsCloseFree(tls, **(**uintptr)(__ccgo_up(bp))) + if rc != SQLITE_OK { + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + return rc + } + /* Delete the super-journal file. This commits the transaction. After + ** doing this the directory is synced again before any individual + ** transaction files are deleted. + */ + rc = _sqlite3OsDelete(tls, pVfs, zSuper, int32(1)) + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + zSuper = uintptr(0) + if rc != 0 { + return rc + } + /* All files and directories have already been synced, so the following + ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and + ** deleting or truncating journals. If something goes wrong while + ** this is happening we don't really care. The integrity of the + ** transaction is already guaranteed, but some stray 'cold' journals + ** may be lying around. Returning an error code won't help matters. + */ + _sqlite3BeginBenignMalloc(tls) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt5 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt5 != 0 { + _sqlite3BtreeCommitPhaseTwo(tls, pBt5, int32(1)) + } + goto _8 + _8: + ; + i = i + 1 + } + _sqlite3EndBenignMalloc(tls) + _sqlite3VtabCommit(tls, db) + } + return rc +} + +// C documentation +// +// /* +// ** These functions are called when a transaction opened by the database +// ** handle associated with the VM passed as an argument is about to be +// ** committed. If there are outstanding foreign key constraint violations +// ** return an error code. Otherwise, SQLITE_OK. +// ** +// ** If there are outstanding FK violations and this function returns +// ** non-zero, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY +// ** and write an error message to it. +// */ +func _vdbeFkError(tls *libc.TLS, p uintptr) (r int32) { + (*TVdbe)(unsafe.Pointer(p)).Frc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(3)< uint32(0x7fffffff) { + return _sqlite3CorruptError(tls, int32(93211)) + } + /* Allocate 5 extra bytes at the end of the buffer. This allows the + ** getVarint32() call below to read slightly past the end of the buffer + ** if the record is corrupt. */ + aRec = _sqlite3MallocZero(tls, uint64(nRec+uint32(5))) + if aRec == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = _sqlite3BtreePayload(tls, pCur, uint32(0), nRec, aRec) + } + if rc == SQLITE_OK { + **(**Tu32)(__ccgo_up(bp + 56)) = uint32(0) /* Size of record header in bytes */ + idxHdr = uint32(0) /* Current index in header */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aRec))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp + 56)) = uint32(**(**Tu8)(__ccgo_up(aRec))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aRec, bp+56)) + } + idxHdr = uint32(libc.Uint8FromInt32(v1)) + if **(**Tu32)(__ccgo_up(bp + 56)) > uint32(98307) { + rc = int32(SQLITE_CORRUPT) + } else { + res = 0 /* Result of this function call */ + idxRec = **(**Tu32)(__ccgo_up(bp + 56)) /* Index of next field in record body */ + ii = 0 /* Iterator variable */ + nCol = libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FnAllField) + ii = 0 + for { + if !(ii < nCol && rc == SQLITE_OK) { + break + } + **(**Tu32)(__ccgo_up(bp + 60)) = uint32(0) + nSerial = 0 + if idxHdr >= **(**Tu32)(__ccgo_up(bp + 56)) { + rc = _sqlite3CorruptError(tls, int32(93242)) + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aRec + uintptr(idxHdr)))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp + 60)) = uint32(**(**Tu8)(__ccgo_up(aRec + uintptr(idxHdr)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aRec+uintptr(idxHdr), bp+60)) + } + idxHdr = idxHdr + uint32(libc.Uint8FromInt32(v1)) + nSerial = libc.Int32FromUint32(_sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 60)))) + if idxRec+libc.Uint32FromInt32(nSerial) > nRec { + rc = _sqlite3CorruptError(tls, int32(93248)) + } else { + _sqlite3VdbeSerialGet(tls, aRec+uintptr(idxRec), **(**Tu32)(__ccgo_up(bp + 60)), bp) + if _vdbeSkipField(tls, mask, ii, (*TUnpackedRecord)(unsafe.Pointer(p)).FaMem+uintptr(ii)*56, bp, bInt) == 0 { + res = _sqlite3MemCompare(tls, bp, (*TUnpackedRecord)(unsafe.Pointer(p)).FaMem+uintptr(ii)*56, *(*uintptr)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + 32 + uintptr(ii)*8))) + if res != 0 { + break + } + } + } + idxRec = idxRec + _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 60))) + goto _2 + _2: + ; + ii = ii + 1 + } + **(**int32)(__ccgo_up(piRes)) = res + } + } + Xsqlite3_free(tls, aRec) + return rc +} + +// C documentation +// +// /* +// ** Render a Mem object which is one of MEM_Int, MEM_Real, or MEM_IntReal +// ** into a buffer. +// */ +func _vdbeMemRenderNum(tls *libc.TLS, sz int32, zBuf uintptr, p uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var v1 int32 + var _ /* acc at bp+0 */ TStrAccum + _ = v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + (*TMem)(unsafe.Pointer(p)).Fn = _sqlite3Int64ToText(tls, *(*Ti64)(unsafe.Pointer(p)), zBuf) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&int32(MEM_IntReal) != 0 { + libc.X__builtin___memcpy_chk(tls, zBuf+uintptr((*TMem)(unsafe.Pointer(p)).Fn), __ccgo_ts+5560, uint64(3), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(p + 16)) += int32(2) + } + } else { + _sqlite3StrAccumInit(tls, bp, uintptr(0), zBuf, sz, 0) + if (*TMem)(unsafe.Pointer(p)).Fdb != 0 { + v1 = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TMem)(unsafe.Pointer(p)).Fdb)).FnFpDigit) + } else { + v1 = int32(17) + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5563, libc.VaList(bp+40, v1, *(*float64)(unsafe.Pointer(p)))) + **(**int8)(__ccgo_up(zBuf + uintptr((**(**TStrAccum)(__ccgo_up(bp))).FnChar))) = 0 /* Fast version of sqlite3StrAccumFinish(&acc) */ + (*TMem)(unsafe.Pointer(p)).Fn = libc.Int32FromUint32((**(**TStrAccum)(__ccgo_up(bp))).FnChar) + } +} + +// C documentation +// +// /* +// ** Read the next nByte bytes of data from the PMA p. +// ** If successful, set *ppOut to point to a buffer containing the data +// ** and return SQLITE_OK. Otherwise, if an error occurs, return an SQLite +// ** error code. +// ** +// ** The buffer returned in *ppOut is only valid until the +// ** next call to this function. +// */ +func _vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aNew uintptr + var iBuf, nAvail, nCopy, nRead, nRem, rc, rc1 int32 + var nNew Tsqlite3_int64 + var v1 int64 + var _ /* aNext at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aNew, iBuf, nAvail, nCopy, nNew, nRead, nRem, rc, rc1, v1 /* Bytes of data available in buffer */ + if (*TPmaReader)(unsafe.Pointer(p)).FaMap != 0 { + **(**uintptr)(__ccgo_up(ppOut)) = (*TPmaReader)(unsafe.Pointer(p)).FaMap + uintptr((*TPmaReader)(unsafe.Pointer(p)).FiReadOff) + **(**Ti64)(__ccgo_up(p)) += int64(nByte) + return SQLITE_OK + } + /* If there is no more data to be read from the buffer, read the next + ** p->nBuffer bytes of data from the file into it. Or, if there are less + ** than p->nBuffer bytes remaining in the PMA, read all remaining data. */ + iBuf = int32((*TPmaReader)(unsafe.Pointer(p)).FiReadOff % int64((*TPmaReader)(unsafe.Pointer(p)).FnBuffer)) + if iBuf == 0 { /* sqlite3OsRead() return code */ + /* Determine how many bytes of data to read. */ + if (*TPmaReader)(unsafe.Pointer(p)).FiEof-(*TPmaReader)(unsafe.Pointer(p)).FiReadOff > int64((*TPmaReader)(unsafe.Pointer(p)).FnBuffer) { + nRead = (*TPmaReader)(unsafe.Pointer(p)).FnBuffer + } else { + nRead = int32((*TPmaReader)(unsafe.Pointer(p)).FiEof - (*TPmaReader)(unsafe.Pointer(p)).FiReadOff) + } + /* Readr data from the file. Return early if an error occurs. */ + rc = _sqlite3OsRead(tls, (*TPmaReader)(unsafe.Pointer(p)).FpFd, (*TPmaReader)(unsafe.Pointer(p)).FaBuffer, nRead, (*TPmaReader)(unsafe.Pointer(p)).FiReadOff) + if rc != SQLITE_OK { + return rc + } + } + nAvail = (*TPmaReader)(unsafe.Pointer(p)).FnBuffer - iBuf + if nByte <= nAvail { + /* The requested data is available in the in-memory buffer. In this + ** case there is no need to make a copy of the data, just return a + ** pointer into the buffer to the caller. */ + **(**uintptr)(__ccgo_up(ppOut)) = (*TPmaReader)(unsafe.Pointer(p)).FaBuffer + uintptr(iBuf) + **(**Ti64)(__ccgo_up(p)) += int64(nByte) + } else { /* Bytes remaining to copy */ + /* Extend the p->aAlloc[] allocation if required. */ + if (*TPmaReader)(unsafe.Pointer(p)).FnAlloc < nByte { + if int64(libc.Int32FromInt32(128)) > int64(2)*int64((*TPmaReader)(unsafe.Pointer(p)).FnAlloc) { + v1 = int64(libc.Int32FromInt32(128)) + } else { + v1 = int64(2) * int64((*TPmaReader)(unsafe.Pointer(p)).FnAlloc) + } + nNew = v1 + for int64(nByte) > nNew { + nNew = nNew * int64(2) + } + aNew = _sqlite3Realloc(tls, (*TPmaReader)(unsafe.Pointer(p)).FaAlloc, libc.Uint64FromInt64(nNew)) + if !(aNew != 0) { + return int32(SQLITE_NOMEM) + } + (*TPmaReader)(unsafe.Pointer(p)).FnAlloc = int32(nNew) + (*TPmaReader)(unsafe.Pointer(p)).FaAlloc = aNew + } + /* Copy as much data as is available in the buffer into the start of + ** p->aAlloc[]. */ + libc.X__builtin___memcpy_chk(tls, (*TPmaReader)(unsafe.Pointer(p)).FaAlloc, (*TPmaReader)(unsafe.Pointer(p)).FaBuffer+uintptr(iBuf), libc.Uint64FromInt32(nAvail), ^t__predefined_size_t(0)) + **(**Ti64)(__ccgo_up(p)) += int64(nAvail) + nRem = nByte - nAvail + /* The following loop copies up to p->nBuffer bytes per iteration into + ** the p->aAlloc[] buffer. */ + for nRem > 0 { /* Number of bytes to copy */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Pointer to buffer to copy data from */ + nCopy = nRem + if nRem > (*TPmaReader)(unsafe.Pointer(p)).FnBuffer { + nCopy = (*TPmaReader)(unsafe.Pointer(p)).FnBuffer + } + rc1 = _vdbePmaReadBlob(tls, p, nCopy, bp) + if rc1 != SQLITE_OK { + return rc1 + } + libc.X__builtin___memcpy_chk(tls, (*TPmaReader)(unsafe.Pointer(p)).FaAlloc+uintptr(nByte-nRem), **(**uintptr)(__ccgo_up(bp)), libc.Uint64FromInt32(nCopy), ^t__predefined_size_t(0)) + nRem = nRem - nCopy + } + **(**uintptr)(__ccgo_up(ppOut)) = (*TPmaReader)(unsafe.Pointer(p)).FaAlloc + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Free all memory belonging to the PmaReader object passed as the +// ** argument. All structure fields are set to zero before returning. +// */ +func _vdbePmaReaderClear(tls *libc.TLS, pReadr uintptr) { + Xsqlite3_free(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FaAlloc) + Xsqlite3_free(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FaBuffer) + if (*TPmaReader)(unsafe.Pointer(pReadr)).FaMap != 0 { + _sqlite3OsUnfetch(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FpFd, 0, (*TPmaReader)(unsafe.Pointer(pReadr)).FaMap) + } + _vdbeIncrFree(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr) + libc.X__builtin___memset_chk(tls, pReadr, 0, uint64(80), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Write nData bytes of data to the PMA. Return SQLITE_OK +// ** if successful, or an SQLite error code if an error occurs. +// */ +func _vdbePmaWriteBlob(tls *libc.TLS, p uintptr, pData uintptr, nData int32) { + var nCopy, nRem, v1 int32 + _, _, _ = nCopy, nRem, v1 + nRem = nData + for nRem > 0 && (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr == 0 { + nCopy = nRem + if nCopy > (*TPmaWriter)(unsafe.Pointer(p)).FnBuffer-(*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd { + nCopy = (*TPmaWriter)(unsafe.Pointer(p)).FnBuffer - (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd + } + libc.X__builtin___memcpy_chk(tls, (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd), pData+uintptr(nData-nRem), libc.Uint64FromInt32(nCopy), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(p + 24)) += nCopy + if (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd == (*TPmaWriter)(unsafe.Pointer(p)).FnBuffer { + (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr = _sqlite3OsWrite(tls, (*TPmaWriter)(unsafe.Pointer(p)).FpFd, (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart), (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd-(*TPmaWriter)(unsafe.Pointer(p)).FiBufStart, (*TPmaWriter)(unsafe.Pointer(p)).FiWriteOff+int64((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart)) + **(**Tu64)(__ccgo_up(p + 48)) += libc.Uint64FromInt32((*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd - (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart) + v1 = libc.Int32FromInt32(0) + (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd = v1 + (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart = v1 + **(**Ti64)(__ccgo_up(p + 32)) += int64((*TPmaWriter)(unsafe.Pointer(p)).FnBuffer) + } + nRem = nRem - nCopy + } +} + +// C documentation +// +// /* +// ** Flush any buffered data to disk and clean up the PMA-writer object. +// ** The results of using the PMA-writer after this call are undefined. +// ** Return SQLITE_OK if flushing the buffered data succeeds or is not +// ** required. Otherwise, return an SQLite error code. +// ** +// ** Before returning, set *piEof to the offset immediately following the +// ** last byte written to the file. Also, increment (*pnSpill) by the total +// ** number of bytes written to the file. +// */ +func _vdbePmaWriterFinish(tls *libc.TLS, p uintptr, piEof uintptr, pnSpill uintptr) (r int32) { + var rc int32 + _ = rc + if (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr == 0 && (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer != 0 && (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd > (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart { + (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr = _sqlite3OsWrite(tls, (*TPmaWriter)(unsafe.Pointer(p)).FpFd, (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart), (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd-(*TPmaWriter)(unsafe.Pointer(p)).FiBufStart, (*TPmaWriter)(unsafe.Pointer(p)).FiWriteOff+int64((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart)) + **(**Tu64)(__ccgo_up(p + 48)) += libc.Uint64FromInt32((*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd - (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart) + } + **(**Ti64)(__ccgo_up(piEof)) = (*TPmaWriter)(unsafe.Pointer(p)).FiWriteOff + int64((*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd) + **(**Tu64)(__ccgo_up(pnSpill)) += (*TPmaWriter)(unsafe.Pointer(p)).FnPmaSpill + Xsqlite3_free(tls, (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer) + rc = (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr + libc.X__builtin___memset_chk(tls, p, 0, uint64(56), ^t__predefined_size_t(0)) + return rc +} + +// C documentation +// +// /* +// ** Initialize a PMA-writer object. +// */ +func _vdbePmaWriterInit(tls *libc.TLS, pFd uintptr, p uintptr, nBuf int32, iStart Ti64) { + var v1 int32 + _ = v1 + libc.X__builtin___memset_chk(tls, p, 0, uint64(56), ^t__predefined_size_t(0)) + (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer = _sqlite3Malloc(tls, libc.Uint64FromInt32(nBuf)) + if !((*TPmaWriter)(unsafe.Pointer(p)).FaBuffer != 0) { + (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr = int32(SQLITE_NOMEM) + } else { + v1 = int32(iStart % int64(nBuf)) + (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart = v1 + (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd = v1 + (*TPmaWriter)(unsafe.Pointer(p)).FiWriteOff = iStart - int64((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart) + (*TPmaWriter)(unsafe.Pointer(p)).FnBuffer = nBuf + (*TPmaWriter)(unsafe.Pointer(p)).FpFd = pFd + } +} + +// C documentation +// +// /* +// ** Check on a Vdbe to make sure it has not been finalized. Log +// ** an error and return true if it has been finalized (or is otherwise +// ** invalid). Return false if it is ok. +// */ +func _vdbeSafety(tls *libc.TLS, p uintptr) (r int32) { + if (*TVdbe)(unsafe.Pointer(p)).Fdb == uintptr(0) { + Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+5849, 0) + return int32(1) + } else { + return 0 + } + return r +} + +func _vdbeSafetyNotNull(tls *libc.TLS, p uintptr) (r int32) { + if p == uintptr(0) { + Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+5894, 0) + return int32(1) + } else { + return _vdbeSafety(tls, p) + } + return r +} + +// C documentation +// +// /* +// ** Helper function for vdbeIsMatchingIndexKey(). Return true if column +// ** iCol should be ignored when comparing a record with a record from +// ** an index on disk. The field should be ignored if: +// ** +// ** * the corresponding bit in mask is set, and +// ** * either: +// ** - bIntegrity is false, or +// ** - the two Mem values are both real values that differ by +// ** BTREE_ULPDISTORTION or fewer ULPs. +// */ +func _vdbeSkipField(tls *libc.TLS, mask TBitmask, iCol int32, pMem1 uintptr, pMem2 uintptr, bIntegrity int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* m1 at bp+0 */ Tu64 + var _ /* m2 at bp+8 */ Tu64 + _ = v1 + if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) || mask&(libc.Uint64FromInt32(1)<list.aMemory can only be non-zero if it was handed memory + ** from the main thread. That only occurs SQLITE_MAX_WORKER_THREADS>0 */ + if (*TSortSubtask)(unsafe.Pointer(pTask)).Flist.FaMemory != 0 { + Xsqlite3_free(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).Flist.FaMemory) + } else { + _vdbeSorterRecordFree(tls, uintptr(0), (*TSortSubtask)(unsafe.Pointer(pTask)).Flist.FpList) + } + if (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd != 0 { + _sqlite3OsCloseFree(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd) + } + if (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd != 0 { + _sqlite3OsCloseFree(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd) + } + libc.X__builtin___memset_chk(tls, pTask, 0, uint64(104), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Write the current contents of in-memory linked-list pList to a level-0 +// ** PMA in the temp file belonging to sub-task pTask. Return SQLITE_OK if +// ** successful, or an SQLite error code otherwise. +// ** +// ** The format of a PMA is: +// ** +// ** * A varint. This varint contains the total number of bytes of content +// ** in the PMA (not including the varint itself). +// ** +// ** * One or more records packed end-to-end in order of ascending keys. +// ** Each record consists of a varint followed by a blob of data (the +// ** key). The varint is the number of bytes in the blob of data. +// */ +func _vdbeSorterListToPMA(tls *libc.TLS, pTask uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, p, pNext uintptr + var rc int32 + var _ /* writer at bp+0 */ TPmaWriter + _, _, _, _ = db, p, pNext, rc + db = (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb + rc = SQLITE_OK /* Object used to write to the file */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(56), ^t__predefined_size_t(0)) + /* If the first temporary PMA file has not been opened, open it now. */ + if (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd == uintptr(0) { + rc = _vdbeSorterOpenTempFile(tls, db, 0, pTask+64) + } + /* Try to get the file to memory map */ + if rc == SQLITE_OK { + _vdbeSorterExtendFile(tls, db, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FiEof+(*TSorterList)(unsafe.Pointer(pList)).FszPMA+int64(9)) + } + /* Sort the list */ + if rc == SQLITE_OK { + rc = _vdbeSorterSort(tls, pTask, pList) + } + if rc == SQLITE_OK { + pNext = uintptr(0) + _vdbePmaWriterInit(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd, bp, (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FiEof) + (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA = (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA + 1 + _vdbePmaWriteVarint(tls, bp, libc.Uint64FromInt64((*TSorterList)(unsafe.Pointer(pList)).FszPMA)) + p = (*TSorterList)(unsafe.Pointer(pList)).FpList + for { + if !(p != 0) { + break + } + pNext = *(*uintptr)(unsafe.Pointer(p + 8)) + _vdbePmaWriteVarint(tls, bp, libc.Uint64FromInt32((*TSorterRecord)(unsafe.Pointer(p)).FnVal)) + _vdbePmaWriteBlob(tls, bp, p+libc.UintptrFromInt32(1)*16, (*TSorterRecord)(unsafe.Pointer(p)).FnVal) + if (*TSorterList)(unsafe.Pointer(pList)).FaMemory == uintptr(0) { + Xsqlite3_free(tls, p) + } + goto _1 + _1: + ; + p = pNext + } + (*TSorterList)(unsafe.Pointer(pList)).FpList = p + rc = _vdbePmaWriterFinish(tls, bp, pTask+64+8, pTask+96) + } + return rc +} + +// C documentation +// +// /* +// ** Sort the linked list of records headed at pTask->pList. Return +// ** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if +// ** an error occurs. +// */ +func _vdbeSorterSort(tls *libc.TLS, pTask uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(512) + defer tls.Free(512) + var i, rc int32 + var p, pNext, v3 uintptr + var _ /* aSlot at bp+0 */ [64]uintptr + _, _, _, _, _ = i, p, pNext, rc, v3 + rc = _vdbeSortAllocUnpacked(tls, pTask) + if rc != SQLITE_OK { + return rc + } + p = (*TSorterList)(unsafe.Pointer(pList)).FpList + (*TSortSubtask)(unsafe.Pointer(pTask)).FxCompare = _vdbeSorterGetCompare(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter) + libc.X__builtin___memset_chk(tls, bp, 0, uint64(512), ^t__predefined_size_t(0)) + for p != 0 { + if (*TSorterList)(unsafe.Pointer(pList)).FaMemory != 0 { + if p == (*TSorterList)(unsafe.Pointer(pList)).FaMemory { + pNext = uintptr(0) + } else { + pNext = (*TSorterList)(unsafe.Pointer(pList)).FaMemory + uintptr(*(*int32)(unsafe.Pointer(&(*TSorterRecord)(unsafe.Pointer(p)).Fu))) + } + } else { + pNext = *(*uintptr)(unsafe.Pointer(p + 8)) + } + *(*uintptr)(unsafe.Pointer(p + 8)) = uintptr(0) + i = 0 + for { + if !((**(**[64]uintptr)(__ccgo_up(bp)))[i] != 0) { + break + } + p = _vdbeSorterMerge(tls, pTask, p, (**(**[64]uintptr)(__ccgo_up(bp)))[i]) + /* ,--Each aSlot[] holds twice as much as the previous. So we cannot use + ** | up all 64 aSlots[] with only a 64-bit address space. + ** v */ + (**(**[64]uintptr)(__ccgo_up(bp)))[i] = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + (**(**[64]uintptr)(__ccgo_up(bp)))[i] = p + p = pNext + } + p = uintptr(0) + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(512)/libc.Uint64FromInt64(8))) { + break + } + if (**(**[64]uintptr)(__ccgo_up(bp)))[i] == uintptr(0) { + goto _2 + } + if p != 0 { + v3 = _vdbeSorterMerge(tls, pTask, p, (**(**[64]uintptr)(__ccgo_up(bp)))[i]) + } else { + v3 = (**(**[64]uintptr)(__ccgo_up(bp)))[i] + } + p = v3 + goto _2 + _2: + ; + i = i + 1 + } + (*TSorterList)(unsafe.Pointer(pList)).FpList = p + return libc.Int32FromUint8((*TUnpackedRecord)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode) +} + +// C documentation +// +// /******************************* sqlite3_bind_ *************************** +// ** +// ** Routines used to attach values to wildcards in a compiled SQL statement. +// */ +// /* +// ** Unbind the value bound to variable i in virtual machine p. This is the +// ** the same as binding a NULL value to the column. If the "i" parameter is +// ** out of range, then SQLITE_RANGE is returned. Otherwise SQLITE_OK. +// ** +// ** A successful evaluation of this routine acquires the mutex on p. +// ** the mutex is released if any kind of error occurs. +// ** +// ** The error code stored in database p->db is overwritten with the return +// ** value in any case. +// ** +// ** (tag-20240917-01) If vdbeUnbind(p,(u32)(i-1)) returns SQLITE_OK, +// ** that means all of the the following will be true: +// ** +// ** p!=0 +// ** p->pVar!=0 +// ** i>0 +// ** i<=p->nVar +// ** +// ** An assert() is normally added after vdbeUnbind() to help static analyzers +// ** realize this. +// */ +func _vdbeUnbind(tls *libc.TLS, p uintptr, i uint32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pVar uintptr + var v1 uint32 + var v2 bool + _, _, _ = pVar, v1, v2 + if _vdbeSafetyNotNull(tls, p) != 0 { + return _sqlite3MisuseError(tls, int32(95215)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FeVdbeState) != int32(VDBE_READY_STATE) { + _sqlite3Error(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, _sqlite3MisuseError(tls, int32(95219))) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+6017, libc.VaList(bp+8, (*TVdbe)(unsafe.Pointer(p)).FzSql)) + return _sqlite3MisuseError(tls, int32(95223)) + } + if i >= libc.Uint32FromInt16((*TVdbe)(unsafe.Pointer(p)).FnVar) { + _sqlite3Error(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, int32(SQLITE_RANGE)) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + return int32(SQLITE_RANGE) + } + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56 + _sqlite3VdbeMemRelease(tls, pVar) + (*TMem)(unsafe.Pointer(pVar)).Fflags = uint16(MEM_Null) + (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FerrCode = SQLITE_OK + /* If the bit corresponding to this variable in Vdbe.expmask is set, then + ** binding a new value to this variable invalidates the current query plan. + ** + ** IMPLEMENTATION-OF: R-57496-20354 If the specific value bound to a host + ** parameter in the WHERE clause might influence the choice of query plan + ** for a statement, then the statement will be automatically recompiled, + ** as if there had been a schema change, on the first sqlite3_step() call + ** following any change to the bindings of that parameter. + */ + if v2 = (*TVdbe)(unsafe.Pointer(p)).Fexpmask != uint32(0); v2 { + if i >= uint32(31) { + v1 = uint32(0x80000000) + } else { + v1 = libc.Uint32FromInt32(1) << i + } + } + if v2 && (*TVdbe)(unsafe.Pointer(p)).Fexpmask&v1 != uint32(0) { + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 0, 0x3) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Allocate and populate an UnpackedRecord structure based on the serialized +// ** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure +// ** if successful, or a NULL pointer if an OOM error is encountered. +// */ +func _vdbeUnpackRecord(tls *libc.TLS, pKeyInfo uintptr, nKey int32, pKey uintptr) (r uintptr) { + var pRet uintptr + _ = pRet /* Return value */ + pRet = _sqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo) + if pRet != 0 { + libc.X__builtin___memset_chk(tls, (*TUnpackedRecord)(unsafe.Pointer(pRet)).FaMem, 0, uint64(56)*libc.Uint64FromInt32(libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField)+libc.Int32FromInt32(1)), ^t__predefined_size_t(0)) + _sqlite3VdbeRecordUnpack(tls, nKey, pKey, pRet) + } + return pRet +} + +// C documentation +// +// /* +// ** Check a unixFile that is a database. Verify the following: +// ** +// ** (1) There is exactly one hard link on the file +// ** (2) The file is not a symbolic link +// ** (3) The file has not been renamed or unlinked +// ** +// ** Issue sqlite3_log(SQLITE_WARNING,...) messages if anything is not right. +// */ +func _verifyDbFile(tls *libc.TLS, pFile uintptr) { + bp := tls.Alloc(160) + defer tls.Free(160) + var rc int32 + var _ /* buf at bp+0 */ Tstat + _ = rc + /* These verifications occurs for the main database only */ + if libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFile)).FctrlFlags)&int32(UNIXFILE_NOLOCK) != 0 { + return + } + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, bp) + if rc != 0 { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3836, libc.VaList(bp+152, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if libc.Int32FromUint16((**(**Tstat)(__ccgo_up(bp))).Fst_nlink) == 0 { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3860, libc.VaList(bp+152, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if libc.Int32FromUint16((**(**Tstat)(__ccgo_up(bp))).Fst_nlink) > int32(1) { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3889, libc.VaList(bp+152, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if _fileHasMoved(tls, pFile) != 0 { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3916, libc.VaList(bp+152, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } +} + +// C documentation +// +// /* +// ** The Table structure pTable is really a VIEW. Fill in the names of +// ** the columns of the view in the pTable structure. Return non-zero if +// ** there are errors. If an error is seen an error message is left +// ** in pParse->zErrMsg. +// */ +func _viewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pSel, pSelTab, v2 uintptr + var eParseMode Tu8 + var nErr, nSelect, nTab, rc, v1 int32 + var xAuth Tsqlite3_xauth + _, _, _, _, _, _, _, _, _, _, _ = db, eParseMode, nErr, nSelect, nTab, pSel, pSelTab, rc, xAuth, v1, v2 /* Copy of the SELECT that implements the view */ + nErr = 0 /* Number of errors encountered */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Saved xAuth pointer */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == int32(TABTYP_VTAB) { + (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock + 1 + rc = _sqlite3VtabCallConnect(tls, pParse, pTable) + (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock - 1 + return rc + } + /* A positive nCol means the columns names for this view are + ** already known. This routine is not called unless either the + ** table is virtual or nCol is zero. + */ + /* A negative nCol is a special marker meaning that we are currently + ** trying to compute the column names. If we enter this routine with + ** a negative nCol, it means two or more views form a loop, like this: + ** + ** CREATE VIEW one AS SELECT * FROM two; + ** CREATE VIEW two AS SELECT * FROM one; + ** + ** Actually, the error above is now caught prior to reaching this point. + ** But the following test is still important as it does come up + ** in the following: + ** + ** CREATE TABLE main.ex1(a); + ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1; + ** SELECT * FROM temp.ex1; + */ + if int32((*TTable)(unsafe.Pointer(pTable)).FnCol) < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15183, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTable)).FzName)) + return int32(1) + } + /* If we get this far, it means we need to compute the table names. + ** Note that the call to sqlite3ResultSetOfSelect() will expand any + ** "*" elements in the results set of the view and will assign cursors + ** to the elements of the FROM clause. But we do not want these changes + ** to be permanent. So the computation is done on a copy of the SELECT + ** statement that defines the view. + */ + pSel = _sqlite3SelectDup(tls, db, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTable)).Fu))).FpSelect, 0) + if pSel != 0 { + eParseMode = (*TParse)(unsafe.Pointer(pParse)).FeParseMode + nTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + nSelect = (*TParse)(unsafe.Pointer(pParse)).FnSelect + (*TParse)(unsafe.Pointer(pParse)).FeParseMode = uint8(PARSE_MODE_NORMAL) + _sqlite3SrcListAssignCursors(tls, pParse, (*TSelect)(unsafe.Pointer(pSel)).FpSrc) + (*TTable)(unsafe.Pointer(pTable)).FnCol = int16(-int32(1)) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + pSelTab = _sqlite3ResultSetOfSelect(tls, pParse, pSel, int8(SQLITE_AFF_NONE)) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + (*TParse)(unsafe.Pointer(pParse)).FnTab = nTab + (*TParse)(unsafe.Pointer(pParse)).FnSelect = nSelect + if pSelTab == uintptr(0) { + (*TTable)(unsafe.Pointer(pTable)).FnCol = 0 + nErr = nErr + 1 + } else { + if (*TTable)(unsafe.Pointer(pTable)).FpCheck != 0 { + /* CREATE VIEW name(arglist) AS ... + ** The names of the columns in the table are taken from + ** arglist which is stored in pTable->pCheck. The pCheck field + ** normally holds CHECK constraints on an ordinary table, but for + ** a VIEW it holds the list of column names. + */ + _sqlite3ColumnsFromExprList(tls, pParse, (*TTable)(unsafe.Pointer(pTable)).FpCheck, pTable+54, pTable+8) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && int32((*TTable)(unsafe.Pointer(pTable)).FnCol) == (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpEList)).FnExpr { + _sqlite3SubqueryColumnTypes(tls, pParse, pTable, pSel, int8(SQLITE_AFF_NONE)) + } + } else { + /* CREATE VIEW name AS... without an argument list. Construct + ** the column names from the SELECT statement that defines the view. + */ + (*TTable)(unsafe.Pointer(pTable)).FnCol = (*TTable)(unsafe.Pointer(pSelTab)).FnCol + (*TTable)(unsafe.Pointer(pTable)).FaCol = (*TTable)(unsafe.Pointer(pSelTab)).FaCol + **(**Tu32)(__ccgo_up(pTable + 48)) |= (*TTable)(unsafe.Pointer(pSelTab)).FtabFlags & uint32(COLFLAG_NOINSERT) + (*TTable)(unsafe.Pointer(pSelTab)).FnCol = 0 + (*TTable)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) + } + } + (*TTable)(unsafe.Pointer(pTable)).FnNVCol = (*TTable)(unsafe.Pointer(pTable)).FnCol + _sqlite3DeleteTable(tls, db, pSelTab) + _sqlite3SelectDelete(tls, db, pSel) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v1 = 0 + } else { + v1 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v1) + (*TParse)(unsafe.Pointer(pParse)).FeParseMode = eParseMode + } else { + nErr = nErr + 1 + } + v2 = (*TTable)(unsafe.Pointer(pTable)).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(DB_UnresetViews)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3DeleteColumnNames(tls, db, pTable) + } + return nErr + (*TParse)(unsafe.Pointer(pParse)).FnErr +} + +// C documentation +// +// /* +// ** Invoke a virtual table constructor (either xCreate or xConnect). The +// ** pointer to the function to invoke is passed as the fourth parameter +// ** to this procedure. +// */ +func _vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, __ccgo_fp_xConstruct uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var azArg, pCtx, pVTable, zFormat, zModuleName, zType, v6 uintptr + var i, iCol, iDb, j, nArg, nDel, nType, rc, v4 int32 + var oooHidden Tu16 + var _ /* sCtx at bp+0 */ TVtabCtx + var _ /* zErr at bp+32 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = azArg, i, iCol, iDb, j, nArg, nDel, nType, oooHidden, pCtx, pVTable, rc, zFormat, zModuleName, zType, v4, v6 + nArg = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FnArg + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + azArg = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg + /* Check that the virtual-table is not already being initialized */ + pCtx = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + for { + if !(pCtx != 0) { + break + } + if (*TVtabCtx)(unsafe.Pointer(pCtx)).FpTab == pTab { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+23794, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(SQLITE_LOCKED) + } + goto _1 + _1: + ; + pCtx = (*TVtabCtx)(unsafe.Pointer(pCtx)).FpPrior + } + zModuleName = _sqlite3DbStrDup(tls, db, (*TTable)(unsafe.Pointer(pTab)).FzName) + if !(zModuleName != 0) { + return int32(SQLITE_NOMEM) + } + pVTable = _sqlite3MallocZero(tls, uint64(48)) + if !(pVTable != 0) { + _sqlite3OomFault(tls, db) + _sqlite3DbFree(tls, db, zModuleName) + return int32(SQLITE_NOMEM) + } + (*TVTable)(unsafe.Pointer(pVTable)).Fdb = db + (*TVTable)(unsafe.Pointer(pVTable)).FpMod = pMod + (*TVTable)(unsafe.Pointer(pVTable)).FeVtabRisk = uint8(SQLITE_VTABRISK_Normal) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg + 1*8)) = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Invoke the virtual table constructor */ + (**(**TVtabCtx)(__ccgo_up(bp))).FpTab = pTab + (**(**TVtabCtx)(__ccgo_up(bp))).FpVTable = pVTable + (**(**TVtabCtx)(__ccgo_up(bp))).FpPrior = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + (**(**TVtabCtx)(__ccgo_up(bp))).FbDeclared = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx = bp + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xConstruct})))(tls, db, (*TModule)(unsafe.Pointer(pMod)).FpAux, nArg, azArg, pVTable+16, bp+32) + _sqlite3DeleteTable(tls, db, pTab) + (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx = (**(**TVtabCtx)(__ccgo_up(bp))).FpPrior + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + if SQLITE_OK != rc { + if **(**uintptr)(__ccgo_up(bp + 32)) == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+23836, libc.VaList(bp+48, zModuleName)) + } else { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+3944, libc.VaList(bp+48, **(**uintptr)(__ccgo_up(bp + 32)))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 32))) + } + _sqlite3DbFree(tls, db, pVTable) + } else { + if (*TVTable)(unsafe.Pointer(pVTable)).FpVtab != 0 { + /* Justification of ALWAYS(): A correct vtab constructor must allocate + ** the sqlite3_vtab object if successful. */ + libc.X__builtin___memset_chk(tls, (*TVTable)(unsafe.Pointer(pVTable)).FpVtab, 0, uint64(24), ^t__predefined_size_t(0)) + (*Tsqlite3_vtab)(unsafe.Pointer((*TVTable)(unsafe.Pointer(pVTable)).FpVtab)).FpModule = (*TModule)(unsafe.Pointer(pMod)).FpModule + (*TModule)(unsafe.Pointer(pMod)).FnRefModule = (*TModule)(unsafe.Pointer(pMod)).FnRefModule + 1 + (*TVTable)(unsafe.Pointer(pVTable)).FnRef = int32(1) + if (**(**TVtabCtx)(__ccgo_up(bp))).FbDeclared == 0 { + zFormat = __ccgo_ts + 23866 + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, zFormat, libc.VaList(bp+48, zModuleName)) + _sqlite3VtabUnlock(tls, pVTable) + rc = int32(SQLITE_ERROR) + } else { + oooHidden = uint16(0) + /* If everything went according to plan, link the new VTable structure + ** into the linked list headed by pTab->u.vtab.p. Then loop through the + ** columns of the table to see if any of them contain the token "hidden". + ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from + ** the type string. */ + (*TVTable)(unsafe.Pointer(pVTable)).FpNext = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp + (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp = pVTable + iCol = 0 + for { + if !(iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + zType = _sqlite3ColumnType(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16, __ccgo_ts+1702) + i = 0 + nType = _sqlite3Strlen30(tls, zType) + i = 0 + for { + if !(i < nType) { + break + } + if 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+18201, zType+uintptr(i), int32(6)) && (i == 0 || int32(**(**int8)(__ccgo_up(zType + uintptr(i-int32(1))))) == int32(' ')) && (int32(**(**int8)(__ccgo_up(zType + uintptr(i+int32(6))))) == int32('\000') || int32(**(**int8)(__ccgo_up(zType + uintptr(i+int32(6))))) == int32(' ')) { + break + } + goto _3 + _3: + ; + i = i + 1 + } + if i < nType { + if **(**int8)(__ccgo_up(zType + uintptr(i+int32(6)))) != 0 { + v4 = int32(1) + } else { + v4 = 0 + } + nDel = int32(6) + v4 + j = i + for { + if !(j+nDel <= nType) { + break + } + **(**int8)(__ccgo_up(zType + uintptr(j))) = **(**int8)(__ccgo_up(zType + uintptr(j+nDel))) + goto _5 + _5: + ; + j = j + 1 + } + if int32(**(**int8)(__ccgo_up(zType + uintptr(i)))) == int32('\000') && i > 0 { + **(**int8)(__ccgo_up(zType + uintptr(i-int32(1)))) = int8('\000') + } + v6 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + 14 + *(*Tu16)(unsafe.Pointer(v6)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v6))) | libc.Int32FromInt32(COLFLAG_HIDDEN)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_HasHidden) + oooHidden = uint16(TF_OOOHidden) + } else { + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(oooHidden) + } + goto _2 + _2: + ; + iCol = iCol + 1 + } + } + } + } + _sqlite3DbFree(tls, db, zModuleName) + return rc +} + +// C documentation +// +// /* Return true if table pTab is read-only. +// ** +// ** A table is read-only if any of the following are true: +// ** +// ** 1) It is a virtual table and no implementation of the xUpdate method +// ** has been provided +// ** +// ** 2) A trigger is currently being coded and the table is a virtual table +// ** that is SQLITE_VTAB_DIRECTONLY or if PRAGMA trusted_schema=OFF and +// ** the table is not SQLITE_VTAB_INNOCUOUS. +// ** +// ** 3) It is a system table (i.e. sqlite_schema), this call is not +// ** part of a nested parse and writable_schema pragma has not +// ** been specified +// ** +// ** 4) The table is a shadow table, the database connection is in +// ** defensive mode, and the current sqlite3_prepare() +// ** is for a top-level SQL statement. +// */ +func _vtabIsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer(_sqlite3GetVTable(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pTab))).FpMod)).FpModule)).FxUpdate == uintptr(0) { + return int32(1) + } + /* Within triggers: + ** * Do not allow DELETE, INSERT, or UPDATE of SQLITE_VTAB_DIRECTONLY + ** virtual tables + ** * Only allow DELETE, INSERT, or UPDATE of non-SQLITE_VTAB_INNOCUOUS + ** virtual tables if PRAGMA trusted_schema=ON. + */ + if ((*TParse)(unsafe.Pointer(pParse)).FpToplevel != uintptr(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_FROM_DDL) != 0) && libc.Int32FromUint8((*TVTable)(unsafe.Pointer((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp)).FeVtabRisk) > libc.BoolInt32((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_TrustedSchema) != uint64(0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16689, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + return 0 +} + +// C documentation +// +// /* +// ** This function does the work of sqlite3WalBeginReadTransaction() (see +// ** below). That function simply calls this one inside an SEH_TRY{...} block. +// */ +func _walBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bChanged, ckptLock, rc int32 + var pInfo, pSnapshot uintptr + var _ /* cnt at bp+0 */ int32 + _, _, _, _, _ = bChanged, ckptLock, pInfo, pSnapshot, rc /* Return code */ + **(**int32)(__ccgo_up(bp)) = 0 /* Number of TryBeginRead attempts */ + ckptLock = 0 + bChanged = 0 + pSnapshot = (*TWal)(unsafe.Pointer(pWal)).FpSnapshot + if pSnapshot != 0 { + if libc.Xmemcmp(tls, pSnapshot, pWal+72, uint64(48)) != 0 { + bChanged = int32(1) + } + /* It is possible that there is a checkpointer thread running + ** concurrent with this code. If this is the case, it may be that the + ** checkpointer has already determined that it will checkpoint + ** snapshot X, where X is later in the wal file than pSnapshot, but + ** has not yet set the pInfo->nBackfillAttempted variable to indicate + ** its intent. To avoid the race condition this leads to, ensure that + ** there is no checkpointer process by taking a shared CKPT lock + ** before checking pInfo->nBackfillAttempted. */ + rc = _walLockShared(tls, pWal, int32(WAL_CKPT_LOCK)) + if rc != SQLITE_OK { + return rc + } + ckptLock = int32(1) + } + for cond := true; cond; cond = rc == -int32(1) { + rc = _walTryBeginRead(tls, pWal, pChanged, 0, bp) + } + if rc == SQLITE_OK { + if pSnapshot != 0 && libc.Xmemcmp(tls, pSnapshot, pWal+72, uint64(48)) != 0 { + /* At this point the client has a lock on an aReadMark[] slot holding + ** a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr + ** is populated with the wal-index header corresponding to the head + ** of the wal file. Verify that pSnapshot is still valid before + ** continuing. Reasons why pSnapshot might no longer be valid: + ** + ** (1) The WAL file has been reset since the snapshot was taken. + ** In this case, the salt will have changed. + ** + ** (2) A checkpoint as been attempted that wrote frames past + ** pSnapshot->mxFrame into the database file. Note that the + ** checkpoint need not have completed for this to cause problems. + */ + pInfo = _walCkptInfo(tls, pWal) + /* Check that the wal file has not been wrapped. Assuming that it has + ** not, also check that no checkpointer has attempted to checkpoint any + ** frames beyond pSnapshot->mxFrame. If either of these conditions are + ** true, return SQLITE_ERROR_SNAPSHOT. Otherwise, overwrite pWal->hdr + ** with *pSnapshot and set *pChanged as appropriate for opening the + ** snapshot. */ + if !(libc.Xmemcmp(tls, pSnapshot+32, pWal+72+32, uint64(8)) != 0) && (*TWalIndexHdr)(unsafe.Pointer(pSnapshot)).FmxFrame >= (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted { + libc.X__builtin___memcpy_chk(tls, pWal+72, pSnapshot, uint64(48), ^t__predefined_size_t(0)) + **(**int32)(__ccgo_up(pChanged)) = bChanged + } else { + rc = libc.Int32FromInt32(SQLITE_ERROR) | libc.Int32FromInt32(3)<apWiData[] using heap memory instead of shared +// ** memory. +// ** +// ** If this function returns SQLITE_OK, then the read transaction has +// ** been successfully opened. In this case output variable (*pChanged) +// ** is set to true before returning if the caller should discard the +// ** contents of the page cache before proceeding. Or, if it returns +// ** WAL_RETRY, then the heap memory wal-index has been discarded and +// ** the caller should retry opening the read transaction from the +// ** beginning (including attempting to map the *-shm file). +// ** +// ** If an error occurs, an SQLite error code is returned. +// */ +func _walBeginShmUnreliable(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var aData, aFrame uintptr + var aSaveCksum [2]Tu32 + var i, rc, szFrame, v1 int32 + var iOffset Ti64 + var _ /* aBuf at bp+8 */ [32]Tu8 + var _ /* nTruncate at bp+52 */ Tu32 + var _ /* pDummy at bp+40 */ uintptr + var _ /* pgno at bp+48 */ Tu32 + var _ /* szWal at bp+0 */ Ti64 + _, _, _, _, _, _, _, _ = aData, aFrame, aSaveCksum, i, iOffset, rc, szFrame, v1 /* Buffer to load WAL header into */ + aFrame = uintptr(0) /* Saved copy of pWal->hdr.aFrameCksum */ + /* Take WAL_READ_LOCK(0). This has the effect of preventing any + ** writers from running a checkpoint, but does not stop them + ** from running recovery. */ + rc = _walLockShared(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(0)) + if rc != SQLITE_OK { + if rc == int32(SQLITE_BUSY) { + rc = -int32(1) + } + goto begin_unreliable_shm_out + } + (*TWal)(unsafe.Pointer(pWal)).FreadLock = 0 + /* Check to see if a separate writer has attached to the shared-memory area, + ** thus making the shared-memory "reliable" again. Do this by invoking + ** the xShmMap() routine of the VFS and looking to see if the return + ** is SQLITE_READONLY instead of SQLITE_READONLY_CANTINIT. + ** + ** If the shared-memory is now "reliable" return WAL_RETRY, which will + ** cause the heap-memory WAL-index to be discarded and the actual + ** shared memory to be used in its place. + ** + ** This step is important because, even though this connection is holding + ** the WAL_READ_LOCK(0) which prevents a checkpoint, a writer might + ** have already checkpointed the WAL file and, while the current + ** is active, wrap the WAL and start overwriting frames that this + ** process wants to use. + ** + ** Once sqlite3OsShmMap() has been called for an sqlite3_file and has + ** returned any SQLITE_READONLY value, it must return only SQLITE_READONLY + ** or SQLITE_READONLY_CANTINIT or some error for all subsequent invocations, + ** even if some external agent does a "chmod" to make the shared-memory + ** writable by us, until sqlite3OsShmUnmap() has been called. + ** This is a requirement on the VFS implementation. + */ + rc = _sqlite3OsShmMap(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, 0, libc.Int32FromUint64(libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4)), 0, bp+40) + /* SQLITE_OK not possible for read-only connection */ + if rc != libc.Int32FromInt32(SQLITE_READONLY)|libc.Int32FromInt32(5)<hdr. + */ + libc.X__builtin___memcpy_chk(tls, pWal+72, _walIndexHdr(tls, pWal), uint64(48), ^t__predefined_size_t(0)) + /* Make sure some writer hasn't come in and changed the WAL file out + ** from under us, then disconnected, while we were not looking. + */ + rc = _sqlite3OsFileSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp) + if rc != SQLITE_OK { + goto begin_unreliable_shm_out + } + if **(**Ti64)(__ccgo_up(bp)) < int64(WAL_HDRSIZE) { + /* If the wal file is too small to contain a wal-header and the + ** wal-index header has mxFrame==0, then it must be safe to proceed + ** reading the database file only. However, the page cache cannot + ** be trusted, as a read/write connection may have connected, written + ** the db, run a checkpoint, truncated the wal file and disconnected + ** since this client's last read transaction. */ + **(**int32)(__ccgo_up(pChanged)) = int32(1) + if (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == uint32(0) { + v1 = SQLITE_OK + } else { + v1 = -int32(1) + } + rc = v1 + goto begin_unreliable_shm_out + } + /* Check the salt keys at the start of the wal file still match. */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp+8, int32(WAL_HDRSIZE), 0) + if rc != SQLITE_OK { + goto begin_unreliable_shm_out + } + if libc.Xmemcmp(tls, pWal+72+32, bp+8+16, uint64(8)) != 0 { + /* Some writer has wrapped the WAL file while we were not looking. + ** Return WAL_RETRY which will cause the in-memory WAL-index to be + ** rebuilt. */ + rc = -int32(1) + goto begin_unreliable_shm_out + } + /* Allocate a buffer to read frames into */ + szFrame = libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage + uint32(WAL_FRAME_HDRSIZE)) + aFrame = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(szFrame)) + if aFrame == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto begin_unreliable_shm_out + } + aData = aFrame + 24 + /* Check to see if a complete transaction has been appended to the + ** wal file since the heap-memory wal-index was created. If so, the + ** heap-memory wal-index is discarded and WAL_RETRY returned to + ** the caller. */ + aSaveCksum[0] = **(**Tu32)(__ccgo_up(pWal + 72 + 24)) + aSaveCksum[int32(1)] = **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) + iOffset = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32((*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame+libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*libc.Int64FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage+libc.Uint32FromInt32(WAL_FRAME_HDRSIZE)) + for { + if !(iOffset+int64(szFrame) <= **(**Ti64)(__ccgo_up(bp))) { + break + } /* dbsize field from frame header */ + /* Read and decode the next log frame. */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset) + if rc != SQLITE_OK { + break + } + if !(_walDecodeFrame(tls, pWal, bp+48, bp+52, aData, aFrame) != 0) { + break + } + /* If nTruncate is non-zero, then a complete transaction has been + ** appended to this wal file. Set rc to WAL_RETRY and break out of + ** the loop. */ + if **(**Tu32)(__ccgo_up(bp + 52)) != 0 { + rc = -int32(1) + break + } + goto _3 + _3: + ; + iOffset = iOffset + int64(szFrame) + } + **(**Tu32)(__ccgo_up(pWal + 72 + 24)) = aSaveCksum[0] + **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) = aSaveCksum[int32(1)] + goto begin_unreliable_shm_out +begin_unreliable_shm_out: + ; + Xsqlite3_free(tls, aFrame) + if rc != SQLITE_OK { + i = 0 + for { + if !(i < (*TWal)(unsafe.Pointer(pWal)).FnWiData) { + break + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8))) + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8)) = uintptr(0) + goto _4 + _4: + ; + i = i + 1 + } + (*TWal)(unsafe.Pointer(pWal)).FbShmUnreliable = uint8(0) + _sqlite3WalEndReadTransaction(tls, pWal) + **(**int32)(__ccgo_up(pChanged)) = int32(1) + } + return rc +} + +/* +** The final argument passed to walTryBeginRead() is of type (int*). The +** caller should invoke walTryBeginRead as follows: +** +** int cnt = 0; +** do { +** rc = walTryBeginRead(..., &cnt); +** }while( rc==WAL_RETRY ); +** +** The final value of "cnt" is of no use to the caller. It is used by +** the implementation of walTryBeginRead() as follows: +** +** + Each time walTryBeginRead() is called, it is incremented. Once +** it reaches WAL_RETRY_PROTOCOL_LIMIT - indicating that walTryBeginRead() +** has many times been invoked and failed with WAL_RETRY - walTryBeginRead() +** returns SQLITE_PROTOCOL. +** +** + If SQLITE_ENABLE_SETLK_TIMEOUT is defined and walTryBeginRead() failed +** because a blocking lock timed out (SQLITE_BUSY_TIMEOUT from the OS +** layer), the WAL_RETRY_BLOCKED_MASK bit is set in "cnt". In this case +** the next invocation of walTryBeginRead() may omit an expected call to +** sqlite3OsSleep(). There has already been a delay when the previous call +** waited on a lock. + */ + +// C documentation +// +// /* +// ** Remove entries from the hash table that point to WAL slots greater +// ** than pWal->hdr.mxFrame. +// ** +// ** This function is called whenever pWal->hdr.mxFrame is decreased due +// ** to a rollback or savepoint. +// ** +// ** At most only the hash table containing pWal->hdr.mxFrame needs to be +// ** updated. Any later hash tables will be automatically cleared when +// ** pWal->hdr.mxFrame advances to the point where those hash tables are +// ** actually needed. +// */ +func _walCleanupHash(tls *libc.TLS, pWal uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, iLimit, nByte int32 + var _ /* sLoc at bp+0 */ TWalHashLoc + _, _, _ = i, iLimit, nByte /* Hash table location */ + iLimit = 0 /* Used to iterate through aHash[] */ + if (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == uint32(0) { + return + } + /* Obtain pointers to the hash-table and page-number array containing + ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed + ** that the page said hash-table and array reside on is already mapped.(1) + */ + i = _walHashGet(tls, pWal, _walFramePage(tls, (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame), bp) + if i != 0 { + return + } /* Defense-in-depth, in case (1) above is wrong */ + /* Zero all hash-table entries that correspond to frame numbers greater + ** than pWal->hdr.mxFrame. + */ + iLimit = libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero) + i = 0 + for { + if !(i < libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2)) { + break + } + if libc.Int32FromUint16(**(**Tht_slot)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash + uintptr(i)*2))) > iLimit { + **(**Tht_slot)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash + uintptr(i)*2)) = uint16(0) + } + goto _1 + _1: + ; + i = i + 1 + } + /* Zero the entries in the aPgno array that correspond to frames with + ** frame numbers greater than pWal->hdr.mxFrame. + */ + nByte = int32(int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash) - int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno+uintptr(iLimit)*4)) + libc.X__builtin___memset_chk(tls, (**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno+uintptr(iLimit)*4, 0, libc.Uint64FromInt32(nByte), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** This function encodes a single frame header and writes it to a buffer +// ** supplied by the caller. A frame-header is made up of a series of +// ** 4-byte big-endian integers, as follows: +// ** +// ** 0: Page number. +// ** 4: For commit records, the size of the database image in pages +// ** after the commit. For all other records, zero. +// ** 8: Salt-1 (copied from the wal-header) +// ** 12: Salt-2 (copied from the wal-header) +// ** 16: Checksum-1. +// ** 20: Checksum-2. +// */ +func _walEncodeFrame(tls *libc.TLS, pWal uintptr, iPage Tu32, nTruncate Tu32, aData uintptr, aFrame uintptr) { + var aCksum uintptr + var nativeCksum int32 + _, _ = aCksum, nativeCksum /* True for native byte-order checksums */ + aCksum = pWal + 72 + 24 + _sqlite3Put4byte(tls, aFrame, iPage) + _sqlite3Put4byte(tls, aFrame+4, nTruncate) + if (*TWal)(unsafe.Pointer(pWal)).FiReCksum == uint32(0) { + libc.X__builtin___memcpy_chk(tls, aFrame+8, pWal+72+32, uint64(8), ^t__predefined_size_t(0)) + nativeCksum = libc.BoolInt32(libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN) + _walChecksumBytes(tls, nativeCksum, aFrame, int32(8), aCksum, aCksum) + _walChecksumBytes(tls, nativeCksum, aData, libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum) + _sqlite3Put4byte(tls, aFrame+16, **(**Tu32)(__ccgo_up(aCksum))) + _sqlite3Put4byte(tls, aFrame+20, **(**Tu32)(__ccgo_up(aCksum + 1*4))) + } else { + libc.X__builtin___memset_chk(tls, aFrame+8, 0, uint64(16), ^t__predefined_size_t(0)) + } +} + +// C documentation +// +// /* +// ** Write a set of frames to the log. The caller must hold the write-lock +// ** on the log file (obtained using sqlite3WalBeginWriteTransaction()). +// */ +func _walFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, nTruncate TPgno, isCommit int32, sync_flags int32) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bSync, nDbSize, nExtra, rc, sectorSize, szFrame, v1 int32 + var iFirst, iFrame Tu32 + var iOff, iOffset, sz Ti64 + var p, pData, pLast, pLive, v3 uintptr + var v4 uint32 + var _ /* aCksum at bp+64 */ [2]Tu32 + var _ /* aWalHdr at bp+32 */ [32]Tu8 + var _ /* iWrite at bp+72 */ Tu32 + var _ /* w at bp+0 */ TWalWriter + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bSync, iFirst, iFrame, iOff, iOffset, nDbSize, nExtra, p, pData, pLast, pLive, rc, sectorSize, sz, szFrame, v1, v3, v4 /* Iterator to run through pList with. */ + pLast = uintptr(0) /* Last frame in list */ + nExtra = 0 /* The writer */ + iFirst = uint32(0) /* Pointer to shared header */ + /* If this frame set completes a transaction, then nTruncate>0. If + ** nTruncate==0 then this frame set does not complete the transaction. */ + pLive = _walIndexHdr(tls, pWal) + if libc.Xmemcmp(tls, pWal+72, pLive, uint64(48)) != 0 { + iFirst = (*TWalIndexHdr)(unsafe.Pointer(pLive)).FmxFrame + uint32(1) + } + /* See if it is possible to write these frames into the start of the + ** log file, instead of appending to it at pWal->hdr.mxFrame. + */ + v1 = _walRestartLog(tls, pWal) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + /* If this is the first frame written into the log, write the WAL + ** header to the start of the WAL file. See comments at the top of + ** this source file for a description of the WAL header format. + */ + iFrame = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + if iFrame == uint32(0) { /* Checksum for wal-header */ + _sqlite3Put4byte(tls, bp+32, libc.Uint32FromInt32(libc.Int32FromInt32(WAL_MAGIC)|libc.Int32FromInt32(SQLITE_BIGENDIAN))) + _sqlite3Put4byte(tls, bp+32+4, uint32(WAL_MAX_VERSION)) + _sqlite3Put4byte(tls, bp+32+8, libc.Uint32FromInt32(szPage)) + _sqlite3Put4byte(tls, bp+32+12, (*TWal)(unsafe.Pointer(pWal)).FnCkpt) + if (*TWal)(unsafe.Pointer(pWal)).FnCkpt == uint32(0) { + Xsqlite3_randomness(tls, int32(8), pWal+72+32) + } + libc.X__builtin___memcpy_chk(tls, bp+32+16, pWal+72+32, uint64(8), ^t__predefined_size_t(0)) + _walChecksumBytes(tls, int32(1), bp+32, libc.Int32FromInt32(WAL_HDRSIZE)-libc.Int32FromInt32(2)*libc.Int32FromInt32(4), uintptr(0), bp+64) + _sqlite3Put4byte(tls, bp+32+24, (**(**[2]Tu32)(__ccgo_up(bp + 64)))[0]) + _sqlite3Put4byte(tls, bp+32+28, (**(**[2]Tu32)(__ccgo_up(bp + 64)))[int32(1)]) + (*TWal)(unsafe.Pointer(pWal)).FszPage = libc.Uint32FromInt32(szPage) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = uint8(SQLITE_BIGENDIAN) + **(**Tu32)(__ccgo_up(pWal + 72 + 24)) = (**(**[2]Tu32)(__ccgo_up(bp + 64)))[0] + **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) = (**(**[2]Tu32)(__ccgo_up(bp + 64)))[int32(1)] + (*TWal)(unsafe.Pointer(pWal)).FtruncateOnCommit = uint8(1) + rc = _sqlite3OsWrite(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp+32, int32(32), 0) + if rc != SQLITE_OK { + return rc + } + /* Sync the header (unless SQLITE_IOCAP_SEQUENTIAL is true or unless + ** all syncing is turned off by PRAGMA synchronous=OFF). Otherwise + ** an out-of-order write following a WAL restart could result in + ** database corruption. See the ticket: + ** + ** https://sqlite.org/src/info/ff5be73dee + */ + if (*TWal)(unsafe.Pointer(pWal)).FsyncHeader != 0 { + rc = _sqlite3OsSync(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, sync_flags>>int32(2)&int32(0x03)) + if rc != 0 { + return rc + } + } + } + if libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage) != szPage { + return _sqlite3CorruptError(tls, int32(71564)) /* TH3 test case: cov1/corrupt155.test */ + } + /* Setup information needed to write frames into the WAL */ + (**(**TWalWriter)(__ccgo_up(bp))).FpWal = pWal + (**(**TWalWriter)(__ccgo_up(bp))).FpFd = (*TWal)(unsafe.Pointer(pWal)).FpWalFd + (**(**TWalWriter)(__ccgo_up(bp))).FiSyncPoint = 0 + (**(**TWalWriter)(__ccgo_up(bp))).FsyncFlags = sync_flags + (**(**TWalWriter)(__ccgo_up(bp))).FszPage = szPage + iOffset = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32(iFrame+libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + szFrame = szPage + int32(WAL_FRAME_HDRSIZE) + /* Write all frames into the log file exactly once */ + p = pList + for { + if !(p != 0) { + break + } /* 0 normally. Positive == commit flag */ + /* Check if this page has already been written into the wal file by + ** the current transaction. If so, overwrite the existing frame and + ** set Wal.writeLock to WAL_WRITELOCK_RECKSUM - indicating that + ** checksums must be recomputed when the transaction is committed. */ + if iFirst != 0 && ((*TPgHdr)(unsafe.Pointer(p)).FpDirty != 0 || isCommit == 0) { + **(**Tu32)(__ccgo_up(bp + 72)) = uint32(0) + _walFindFrame(tls, pWal, (*TPgHdr)(unsafe.Pointer(p)).Fpgno, bp+72) + if **(**Tu32)(__ccgo_up(bp + 72)) >= iFirst { + iOff = int64(WAL_HDRSIZE) + libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp + 72))-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + int64(WAL_FRAME_HDRSIZE) + if (*TWal)(unsafe.Pointer(pWal)).FiReCksum == uint32(0) || **(**Tu32)(__ccgo_up(bp + 72)) < (*TWal)(unsafe.Pointer(pWal)).FiReCksum { + (*TWal)(unsafe.Pointer(pWal)).FiReCksum = **(**Tu32)(__ccgo_up(bp + 72)) + } + pData = (*TPgHdr)(unsafe.Pointer(p)).FpData + rc = _sqlite3OsWrite(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, pData, szPage, iOff) + if rc != 0 { + return rc + } + v3 = p + 52 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^libc.Int32FromInt32(PGHDR_WAL_APPEND)) + goto _2 + } + } + iFrame = iFrame + 1 + if isCommit != 0 && (*TPgHdr)(unsafe.Pointer(p)).FpDirty == uintptr(0) { + v4 = nTruncate + } else { + v4 = uint32(0) + } + nDbSize = libc.Int32FromUint32(v4) + rc = _walWriteOneFrame(tls, bp, p, nDbSize, iOffset) + if rc != 0 { + return rc + } + pLast = p + iOffset = iOffset + int64(szFrame) + v3 = p + 52 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(PGHDR_WAL_APPEND)) + goto _2 + _2: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + } + /* Recalculate checksums within the wal file if required. */ + if isCommit != 0 && (*TWal)(unsafe.Pointer(pWal)).FiReCksum != 0 { + rc = _walRewriteChecksums(tls, pWal, iFrame) + if rc != 0 { + return rc + } + } + /* If this is the end of a transaction, then we might need to pad + ** the transaction and/or sync the WAL file. + ** + ** Padding and syncing only occur if this set of frames complete a + ** transaction and if PRAGMA synchronous=FULL. If synchronous==NORMAL + ** or synchronous==OFF, then no padding or syncing are needed. + ** + ** If SQLITE_IOCAP_POWERSAFE_OVERWRITE is defined, then padding is not + ** needed and only the sync is done. If padding is needed, then the + ** final frame is repeated (with its commit mark) until the next sector + ** boundary is crossed. Only the part of the WAL prior to the last + ** sector boundary is synced; the part of the last frame that extends + ** past the sector boundary is written after the sync. + */ + if isCommit != 0 && sync_flags&int32(0x03) != 0 { + bSync = int32(1) + if (*TWal)(unsafe.Pointer(pWal)).FpadToSectorBoundary != 0 { + sectorSize = _sqlite3SectorSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd) + (**(**TWalWriter)(__ccgo_up(bp))).FiSyncPoint = (iOffset + int64(sectorSize) - int64(1)) / int64(sectorSize) * int64(sectorSize) + bSync = libc.BoolInt32((**(**TWalWriter)(__ccgo_up(bp))).FiSyncPoint == iOffset) + for iOffset < (**(**TWalWriter)(__ccgo_up(bp))).FiSyncPoint { + rc = _walWriteOneFrame(tls, bp, pLast, libc.Int32FromUint32(nTruncate), iOffset) + if rc != 0 { + return rc + } + iOffset = iOffset + int64(szFrame) + nExtra = nExtra + 1 + } + } + if bSync != 0 { + rc = _sqlite3OsSync(tls, (**(**TWalWriter)(__ccgo_up(bp))).FpFd, sync_flags&int32(0x03)) + } + } + /* If this frame set completes the first transaction in the WAL and + ** if PRAGMA journal_size_limit is set, then truncate the WAL to the + ** journal size limit, if possible. + */ + if isCommit != 0 && (*TWal)(unsafe.Pointer(pWal)).FtruncateOnCommit != 0 && (*TWal)(unsafe.Pointer(pWal)).FmxWalSize >= 0 { + sz = (*TWal)(unsafe.Pointer(pWal)).FmxWalSize + if int64(WAL_HDRSIZE)+libc.Int64FromUint32(iFrame+libc.Uint32FromInt32(nExtra)+libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) > (*TWal)(unsafe.Pointer(pWal)).FmxWalSize { + sz = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32(iFrame+libc.Uint32FromInt32(nExtra)+libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + } + _walLimitSize(tls, pWal, sz) + (*TWal)(unsafe.Pointer(pWal)).FtruncateOnCommit = uint8(0) + } + /* Append data to the wal-index. It is not necessary to lock the + ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index + ** guarantees that there are no other writers, and no data that may + ** be in use by existing readers is being overwritten. + */ + iFrame = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + p = pList + for { + if !(p != 0 && rc == SQLITE_OK) { + break + } + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(p)).Fflags)&int32(PGHDR_WAL_APPEND) == 0 { + goto _6 + } + iFrame = iFrame + 1 + rc = _walIndexAppend(tls, pWal, iFrame, (*TPgHdr)(unsafe.Pointer(p)).Fpgno) + goto _6 + _6: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + } + for rc == SQLITE_OK && nExtra > 0 { + iFrame = iFrame + 1 + nExtra = nExtra - 1 + rc = _walIndexAppend(tls, pWal, iFrame, (*TPgHdr)(unsafe.Pointer(pLast)).Fpgno) + } + if rc == SQLITE_OK { + /* Update the private copy of the header. */ + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage = libc.Uint16FromInt32(szPage&libc.Int32FromInt32(0xff00) | szPage>>libc.Int32FromInt32(16)) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = iFrame + if isCommit != 0 { + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FiChange = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FiChange + 1 + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage = nTruncate + } + /* If this is a commit, update the wal-index header too. */ + if isCommit != 0 { + _walIndexWriteHdr(tls, pWal) + (*TWal)(unsafe.Pointer(pWal)).FiCallback = iFrame + } + } + return rc +} + +// C documentation +// +// /* +// ** Set an entry in the wal-index that will map database page number +// ** pPage into WAL frame iFrame. +// */ +func _walIndexAppend(tls *libc.TLS, pWal uintptr, iFrame Tu32, iPage Tu32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iKey, idx, nByte, nCollide, rc, v2 int32 + var _ /* sLoc at bp+0 */ TWalHashLoc + _, _, _, _, _, _ = iKey, idx, nByte, nCollide, rc, v2 /* Wal-index hash table location */ + rc = _walHashGet(tls, pWal, _walFramePage(tls, iFrame), bp) + /* Assuming the wal-index file was successfully mapped, populate the + ** page number array and hash table entry. + */ + if rc == SQLITE_OK { /* Number of hash collisions */ + idx = libc.Int32FromUint32(iFrame - (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero) + /* If this is the first entry to be added to this hash-table, zero the + ** entire hash table and aPgno[] array before proceeding. + */ + if idx == int32(1) { + nByte = int32(int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash+uintptr(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))*2) - int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno)) + libc.X__builtin___memset_chk(tls, (**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno, 0, libc.Uint64FromInt32(nByte), ^t__predefined_size_t(0)) + } + /* If the entry in aPgno[] is already set, then the previous writer + ** must have exited unexpectedly in the middle of a transaction (after + ** writing one or more dirty pages to the WAL to free up memory). + ** Remove the remnants of that writers uncommitted transaction from + ** the hash-table before writing any new entries. + */ + if **(**Tu32)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno + uintptr(idx-int32(1))*4)) != 0 { + _walCleanupHash(tls, pWal) + } + /* Write the aPgno[] array entry and the hash-table slot. */ + nCollide = idx + iKey = _walHash(tls, iPage) + for { + if !(**(**Tht_slot)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash + uintptr(iKey)*2)) != 0) { + break + } + v2 = nCollide + nCollide = nCollide - 1 + if v2 == 0 { + return _sqlite3CorruptError(tls, int32(68778)) + } + goto _1 + _1: + ; + iKey = _walNextHash(tls, iKey) + } + **(**Tu32)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno + uintptr((idx-int32(1))&(libc.Int32FromInt32(HASHTABLE_NPAGE)-libc.Int32FromInt32(1)))*4)) = iPage + libc.AtomicStoreNUint16((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash+uintptr(iKey)*2, libc.Uint16FromInt32(idx), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + return rc +} + +// C documentation +// +// /* +// ** Obtain a pointer to the iPage'th page of the wal-index. The wal-index +// ** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are +// ** numbered from zero. +// ** +// ** If the wal-index is currently smaller the iPage pages then the size +// ** of the wal-index might be increased, but only if it is safe to do +// ** so. It is safe to enlarge the wal-index if pWal->writeLock is true +// ** or pWal->exclusiveMode==WAL_HEAPMEMORY_MODE. +// ** +// ** Three possible result scenarios: +// ** +// ** (1) rc==SQLITE_OK and *ppPage==Requested-Wal-Index-Page +// ** (2) rc>=SQLITE_ERROR and *ppPage==NULL +// ** (3) rc==SQLITE_OK and *ppPage==NULL // only if iPage==0 +// ** +// ** Scenario (3) can only occur when pWal->writeLock is false and iPage==0 +// */ +func _walIndexPageRealloc(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) (r int32) { + var apNew, v1 uintptr + var nByte Tsqlite3_int64 + var rc int32 + _, _, _, _ = apNew, nByte, rc, v1 + rc = SQLITE_OK + /* Enlarge the pWal->apWiData[] array if required */ + if (*TWal)(unsafe.Pointer(pWal)).FnWiData <= iPage { + nByte = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt64(libc.Int64FromInt32(1)+int64(iPage))) + apNew = _sqlite3Realloc(tls, (*TWal)(unsafe.Pointer(pWal)).FapWiData, libc.Uint64FromInt64(nByte)) + if !(apNew != 0) { + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, apNew+uintptr((*TWal)(unsafe.Pointer(pWal)).FnWiData)*8, 0, uint64(8)*libc.Uint64FromInt32(iPage+libc.Int32FromInt32(1)-(*TWal)(unsafe.Pointer(pWal)).FnWiData), ^t__predefined_size_t(0)) + (*TWal)(unsafe.Pointer(pWal)).FapWiData = apNew + (*TWal)(unsafe.Pointer(pWal)).FnWiData = iPage + int32(1) + } + /* Request a pointer to the required page from the VFS */ + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) == int32(WAL_HEAPMEMORY_MODE) { + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) = _sqlite3MallocZero(tls, uint64(libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4))) + if !(**(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) != 0) { + rc = int32(SQLITE_NOMEM) + } + } else { + rc = _sqlite3OsShmMap(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, iPage, libc.Int32FromUint64(libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4)), libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FwriteLock), (*TWal)(unsafe.Pointer(pWal)).FapWiData+uintptr(iPage)*8) + if rc == SQLITE_OK { + if iPage > 0 && _sqlite3FaultSim(tls, int32(600)) != 0 { + rc = int32(SQLITE_NOMEM) + } + } else { + if rc&int32(0xff) == int32(SQLITE_READONLY) { + v1 = pWal + 66 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(WAL_SHM_RDONLY)) + if rc == int32(SQLITE_READONLY) { + rc = SQLITE_OK + } + } + } + } + **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) + return rc +} + +// C documentation +// +// /* +// ** Recover the wal-index by reading the write-ahead log file. +// ** +// ** This routine first tries to establish an exclusive lock on the +// ** wal-index to prevent other threads/processes from doing anything +// ** with the WAL or wal-index while recovery is running. The +// ** WAL_RECOVER_LOCK is also held so that other threads will know +// ** that this thread is running recovery. If unable to establish +// ** the necessary locks, this routine returns SQLITE_BUSY. +// */ +func _walIndexRecover(tls *libc.TLS, pWal uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var aData, aFrame, aPrivate, pInfo uintptr + var aFrameCksum [2]Tu32 + var i, iLock, isValid, rc, szFrame, szPage int32 + var iFirst, iFrame, iLast, iLastFrame, iPg, magic, nHdr, nHdr32, version Tu32 + var iOffset Ti64 + var v2, v3 uint64 + var _ /* aBuf at bp+8 */ [32]Tu8 + var _ /* aShare at bp+40 */ uintptr + var _ /* nSize at bp+0 */ Ti64 + var _ /* nTruncate at bp+52 */ Tu32 + var _ /* pgno at bp+48 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, aFrame, aFrameCksum, aPrivate, i, iFirst, iFrame, iLast, iLastFrame, iLock, iOffset, iPg, isValid, magic, nHdr, nHdr32, pInfo, rc, szFrame, szPage, version, v2, v3 /* Size of log file */ + aFrameCksum = [2]Tu32{} /* Lock offset to lock for checkpoint */ + /* Obtain an exclusive lock on all byte in the locking range not already + ** locked by the caller. The caller is guaranteed to have locked the + ** WAL_WRITE_LOCK byte, and may have also locked the WAL_CKPT_LOCK byte. + ** If successful, the same bytes that are locked here are unlocked before + ** this function returns. + */ + iLock = int32(WAL_ALL_BUT_WRITE) + libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FckptLock) + rc = _walLockExclusive(tls, pWal, iLock, libc.Int32FromInt32(3)+libc.Int32FromInt32(0)-iLock) + if rc != 0 { + return rc + } + libc.X__builtin___memset_chk(tls, pWal+72, 0, uint64(48), ^t__predefined_size_t(0)) + rc = _sqlite3OsFileSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp) + if rc != SQLITE_OK { + goto recovery_error + } + if **(**Ti64)(__ccgo_up(bp)) > int64(WAL_HDRSIZE) { /* Buffer to load WAL header into */ + aPrivate = uintptr(0) /* Heap copy of *-shm hash being populated */ + aFrame = uintptr(0) /* Last frame in wal, based on nSize alone */ + /* Read in the WAL header. */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp+8, int32(WAL_HDRSIZE), 0) + if rc != SQLITE_OK { + goto recovery_error + } + /* If the database page size is not a power of two, or is greater than + ** SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid + ** data. Similarly, if the 'magic' value is invalid, ignore the whole + ** WAL file. + */ + magic = _sqlite3Get4byte(tls, bp+8) + szPage = libc.Int32FromUint32(_sqlite3Get4byte(tls, bp+8+8)) + if magic&uint32(0xFFFFFFFE) != uint32(WAL_MAGIC) || szPage&(szPage-int32(1)) != 0 || szPage > int32(SQLITE_MAX_PAGE_SIZE) || szPage < int32(512) { + goto finished + } + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = uint8(magic & libc.Uint32FromInt32(0x00000001)) + (*TWal)(unsafe.Pointer(pWal)).FszPage = libc.Uint32FromInt32(szPage) + (*TWal)(unsafe.Pointer(pWal)).FnCkpt = _sqlite3Get4byte(tls, bp+8+12) + libc.X__builtin___memcpy_chk(tls, pWal+72+32, bp+8+16, uint64(8), ^t__predefined_size_t(0)) + /* Verify that the WAL header checksum is correct */ + _walChecksumBytes(tls, libc.BoolInt32(libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN), bp+8, libc.Int32FromInt32(WAL_HDRSIZE)-libc.Int32FromInt32(2)*libc.Int32FromInt32(4), uintptr(0), pWal+72+24) + if **(**Tu32)(__ccgo_up(pWal + 72 + 24)) != _sqlite3Get4byte(tls, bp+8+24) || **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) != _sqlite3Get4byte(tls, bp+8+28) { + goto finished + } + /* Verify that the version number on the WAL format is one that + ** are able to understand */ + version = _sqlite3Get4byte(tls, bp+8+4) + if version != uint32(WAL_MAX_VERSION) { + rc = _sqlite3CantopenError(tls, int32(68910)) + goto finished + } + /* Malloc a buffer to read frames into. */ + szFrame = szPage + int32(WAL_FRAME_HDRSIZE) + aFrame = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32(szFrame)+(libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4)))) + if !(aFrame != 0) { + rc = int32(SQLITE_NOMEM) + goto recovery_error + } + aData = aFrame + 24 + aPrivate = aData + uintptr(szPage) + /* Read all frames from the log file. */ + iLastFrame = libc.Uint32FromInt64((**(**Ti64)(__ccgo_up(bp)) - int64(WAL_HDRSIZE)) / int64(szFrame)) + iPg = uint32(0) + for { + if !(iPg <= libc.Uint32FromInt32(_walFramePage(tls, iLastFrame))) { + break + } + if uint64(iLastFrame) < libc.Uint64FromInt32(HASHTABLE_NPAGE)-(libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4)+uint64(iPg*uint32(HASHTABLE_NPAGE)) { + v2 = uint64(iLastFrame) + } else { + v2 = libc.Uint64FromInt32(HASHTABLE_NPAGE) - (libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4) + uint64(iPg*uint32(HASHTABLE_NPAGE)) + } /* Index of last frame read */ + iLast = uint32(v2) + if iPg == uint32(0) { + v3 = uint64(0) + } else { + v3 = libc.Uint64FromInt32(HASHTABLE_NPAGE) - (libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4) + uint64((iPg-uint32(1))*uint32(HASHTABLE_NPAGE)) + } + iFirst = uint32(uint64(1) + v3) + rc = _walIndexPage(tls, pWal, libc.Int32FromUint32(iPg), bp+40) + if **(**uintptr)(__ccgo_up(bp + 40)) == uintptr(0) { + break + } + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPg)*8)) = aPrivate + iFrame = iFirst + for { + if !(iFrame <= iLast) { + break + } + iOffset = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32(iFrame-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) /* dbsize field from frame header */ + /* Read and decode the next log frame. */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset) + if rc != SQLITE_OK { + break + } + isValid = _walDecodeFrame(tls, pWal, bp+48, bp+52, aData, aFrame) + if !(isValid != 0) { + break + } + rc = _walIndexAppend(tls, pWal, iFrame, **(**Tu32)(__ccgo_up(bp + 48))) + if rc != SQLITE_OK { + break + } + /* If nTruncate is non-zero, this is a commit record. */ + if **(**Tu32)(__ccgo_up(bp + 52)) != 0 { + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = iFrame + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage = **(**Tu32)(__ccgo_up(bp + 52)) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage = libc.Uint16FromInt32(szPage&libc.Int32FromInt32(0xff00) | szPage>>libc.Int32FromInt32(16)) + aFrameCksum[0] = **(**Tu32)(__ccgo_up(pWal + 72 + 24)) + aFrameCksum[int32(1)] = **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) + } + goto _4 + _4: + ; + iFrame = iFrame + 1 + } + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPg)*8)) = **(**uintptr)(__ccgo_up(bp + 40)) + if iPg == uint32(0) { + v2 = libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2) + libc.Uint64FromInt64(40) + } else { + v2 = uint64(0) + } + nHdr = uint32(v2) + nHdr32 = uint32(uint64(nHdr) / uint64(4)) + /* Memcpy() should work fine here, on all reasonable implementations. + ** Technically, memcpy() might change the destination to some + ** intermediate value before setting to the final value, and that might + ** cause a concurrent reader to malfunction. Memcpy() is allowed to + ** do that, according to the spec, but no memcpy() implementation that + ** we know of actually does that, which is why we say that memcpy() + ** is safe for this. Memcpy() is certainly a lot faster. + */ + libc.X__builtin___memcpy_chk(tls, **(**uintptr)(__ccgo_up(bp + 40))+uintptr(nHdr32)*4, aPrivate+uintptr(nHdr32)*4, libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4)-uint64(nHdr), ^t__predefined_size_t(0)) + if iFrame <= iLast { + break + } + goto _1 + _1: + ; + iPg = iPg + 1 + } + Xsqlite3_free(tls, aFrame) + } + goto finished +finished: + ; + if rc == SQLITE_OK { + **(**Tu32)(__ccgo_up(pWal + 72 + 24)) = aFrameCksum[0] + **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) = aFrameCksum[int32(1)] + _walIndexWriteHdr(tls, pWal) + /* Reset the checkpoint-header. This is safe because this thread is + ** currently holding locks that exclude all other writers and + ** checkpointers. Then set the values of read-mark slots 1 through N. + */ + pInfo = _walCkptInfo(tls, pWal) + (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill = uint32(0) + (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + **(**Tu32)(__ccgo_up(pInfo + 4)) = uint32(0) + i = int32(1) + for { + if !(i < libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)) { + break + } + rc = _walLockExclusive(tls, pWal, int32(3)+i, int32(1)) + if rc == SQLITE_OK { + if i == int32(1) && (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0 { + **(**Tu32)(__ccgo_up(pInfo + 4 + uintptr(i)*4)) = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + } else { + **(**Tu32)(__ccgo_up(pInfo + 4 + uintptr(i)*4)) = uint32(READMARK_NOT_USED) + } + _walUnlockExclusive(tls, pWal, int32(3)+i, int32(1)) + } else { + if rc != int32(SQLITE_BUSY) { + goto recovery_error + } + } + goto _6 + _6: + ; + i = i + 1 + } + /* If more than one frame was recovered from the log file, report an + ** event via sqlite3_log(). This is to help with identifying performance + ** problems caused by applications routinely shutting down without + ** checkpointing the log file. + */ + if (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage != 0 { + Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_NOTICE)|libc.Int32FromInt32(1)<hdr, then pWal->hdr is updated to the content of the new header +// ** and *pChanged is set to 1. +// ** +// ** If the checksum cannot be verified return non-zero. If the header +// ** is read successfully and the checksum verified, return zero. +// */ +func _walIndexTryHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var aHdr uintptr + var _ /* aCksum at bp+0 */ [2]Tu32 + var _ /* h1 at bp+8 */ TWalIndexHdr + var _ /* h2 at bp+56 */ TWalIndexHdr + _ = aHdr /* Header in shared memory */ + /* The first page of the wal-index must be mapped at this point. */ + /* Read the header. This might happen concurrently with a write to the + ** same area of shared memory on a different CPU in a SMP, + ** meaning it is possible that an inconsistent snapshot is read + ** from the file. If this happens, return non-zero. + ** + ** tag-20200519-1: + ** There are two copies of the header at the beginning of the wal-index. + ** When reading, read [0] first then [1]. Writes are in the reverse order. + ** Memory barriers are used to prevent the compiler or the hardware from + ** reordering the reads and writes. TSAN and similar tools can sometimes + ** give false-positive warnings about these accesses because the tools do not + ** account for the double-read and the memory barrier. The use of mutexes + ** here would be problematic as the memory being accessed is potentially + ** shared among multiple processes and not all mutex implementations work + ** reliably in that environment. + */ + aHdr = _walIndexHdr(tls, pWal) + libc.X__builtin___memcpy_chk(tls, bp+8, aHdr, uint64(48), ^t__predefined_size_t(0)) /* Possible TSAN false-positive */ + _walShmBarrier(tls, pWal) + libc.X__builtin___memcpy_chk(tls, bp+56, aHdr+1*48, uint64(48), ^t__predefined_size_t(0)) + if libc.Xmemcmp(tls, bp+8, bp+56, uint64(48)) != 0 { + return int32(1) /* Dirty read */ + } + if libc.Int32FromUint8((**(**TWalIndexHdr)(__ccgo_up(bp + 8))).FisInit) == 0 { + return int32(1) /* Malformed header - probably all zeros */ + } + _walChecksumBytes(tls, int32(1), bp+8, libc.Int32FromUint64(libc.Uint64FromInt64(48)-libc.Uint64FromInt64(8)), uintptr(0), bp) + if (**(**[2]Tu32)(__ccgo_up(bp)))[0] != **(**Tu32)(__ccgo_up(bp + 8 + 40)) || (**(**[2]Tu32)(__ccgo_up(bp)))[int32(1)] != **(**Tu32)(__ccgo_up(bp + 8 + 40 + 1*4)) { + return int32(1) /* Checksum does not match */ + } + if libc.Xmemcmp(tls, pWal+72, bp+8, uint64(48)) != 0 { + **(**int32)(__ccgo_up(pChanged)) = int32(1) + libc.X__builtin___memcpy_chk(tls, pWal+72, bp+8, uint64(48), ^t__predefined_size_t(0)) + (*TWal)(unsafe.Pointer(pWal)).FszPage = libc.Uint32FromInt32(libc.Int32FromUint16((*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage)&int32(0xfe00) + libc.Int32FromUint16((*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage)&int32(0x0001)<hdr into the wal-index. +// ** +// ** The checksum on pWal->hdr is updated before it is written. +// */ +func _walIndexWriteHdr(tls *libc.TLS, pWal uintptr) { + var aHdr uintptr + var nCksum int32 + _, _ = aHdr, nCksum + aHdr = _walIndexHdr(tls, pWal) + nCksum = libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0) + 40)) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FisInit = uint8(1) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FiVersion = uint32(WALINDEX_MAX_VERSION) + _walChecksumBytes(tls, int32(1), pWal+72, nCksum, uintptr(0), pWal+72+40) + /* Possible TSAN false-positive. See tag-20200519-1 */ + libc.X__builtin___memcpy_chk(tls, aHdr+1*48, pWal+72, uint64(48), ^t__predefined_size_t(0)) + _walShmBarrier(tls, pWal) + libc.X__builtin___memcpy_chk(tls, aHdr, pWal+72, uint64(48), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Construct a WalInterator object that can be used to loop over all +// ** pages in the WAL following frame nBackfill in ascending order. Frames +// ** nBackfill or earlier may be included - excluding them is an optimization +// ** only. The caller must hold the checkpoint lock. +// ** +// ** On success, make *pp point to the newly allocated WalInterator object +// ** return SQLITE_OK. Otherwise, return an error code. If this routine +// ** returns an error, the value of *pp is undefined. +// ** +// ** The calling routine should invoke walIteratorFree() to destroy the +// ** WalIterator object when it has finished with it. +// */ +func _walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill Tu32, pp uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aIndex, aTmp, p uintptr + var i, j, nSegment, rc int32 + var iLast Tu32 + var nByte Tsqlite3_int64 + var v1 uint32 + var _ /* nEntry at bp+24 */ int32 + var _ /* sLoc at bp+0 */ TWalHashLoc + _, _, _, _, _, _, _, _, _, _ = aIndex, aTmp, i, iLast, j, nByte, nSegment, p, rc, v1 /* Temp space used by merge-sort */ + rc = SQLITE_OK /* Return Code */ + /* This routine only runs while holding the checkpoint lock. And + ** it only runs if there is actually content in the log (mxFrame>0). + */ + iLast = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + /* Allocate space for the WalIterator object. */ + nSegment = _walFramePage(tls, iLast) + int32(1) + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+8) + libc.Uint64FromInt32(nSegment)*uint64(32) + uint64(iLast)*uint64(2)) + if iLast > uint32(HASHTABLE_NPAGE) { + v1 = uint32(HASHTABLE_NPAGE) + } else { + v1 = iLast + } + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)+uint64(2)*uint64(v1)) + if !(p != 0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memset_chk(tls, p, 0, libc.Uint64FromInt64(nByte), ^t__predefined_size_t(0)) + (*TWalIterator)(unsafe.Pointer(p)).FnSegment = nSegment + aTmp = p + uintptr(nByte) + i = _walFramePage(tls, nBackfill+uint32(1)) + for { + if !(rc == SQLITE_OK && i < nSegment) { + break + } + rc = _walHashGet(tls, pWal, i, bp) + if rc == SQLITE_OK { /* Sorted index for this segment */ + if i+int32(1) == nSegment { + **(**int32)(__ccgo_up(bp + 24)) = libc.Int32FromUint32(iLast - (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero) + } else { + **(**int32)(__ccgo_up(bp + 24)) = int32((int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash) - int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno)) / 4) + } + aIndex = p + 8 + uintptr((*TWalIterator)(unsafe.Pointer(p)).FnSegment)*32 + uintptr((**(**TWalHashLoc)(__ccgo_up(bp))).FiZero)*2 + (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero = (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero + 1 + j = 0 + for { + if !(j < **(**int32)(__ccgo_up(bp + 24))) { + break + } + **(**Tht_slot)(__ccgo_up(aIndex + uintptr(j)*2)) = libc.Uint16FromInt32(j) + goto _3 + _3: + ; + j = j + 1 + } + _walMergesort(tls, (**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno, aTmp, aIndex, bp+24) + (*(*TWalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FiZero = libc.Int32FromUint32((**(**TWalHashLoc)(__ccgo_up(bp))).FiZero) + (*(*TWalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FnEntry = **(**int32)(__ccgo_up(bp + 24)) + (*(*TWalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FaIndex = aIndex + (*(*TWalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FaPgno = (**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno + } + goto _2 + _2: + ; + i = i + 1 + } + if rc != SQLITE_OK { + _walIteratorFree(tls, p) + p = uintptr(0) + } + **(**uintptr)(__ccgo_up(pp)) = p + return rc +} + +// C documentation +// +// /* +// ** If the WAL file is currently larger than nMax bytes in size, truncate +// ** it to exactly nMax bytes. If an error occurs while doing so, ignore it. +// */ +func _walLimitSize(tls *libc.TLS, pWal uintptr, nMax Ti64) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rx int32 + var _ /* sz at bp+0 */ Ti64 + _ = rx + _sqlite3BeginBenignMalloc(tls) + rx = _sqlite3OsFileSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp) + if rx == SQLITE_OK && **(**Ti64)(__ccgo_up(bp)) > nMax { + rx = _sqlite3OsTruncate(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, nMax) + } + _sqlite3EndBenignMalloc(tls) + if rx != 0 { + Xsqlite3_log(tls, rx, __ccgo_ts+4657, libc.VaList(bp+16, (*TWal)(unsafe.Pointer(pWal)).FzWalName)) + } +} + +// C documentation +// +// /* +// ** This function merges two sorted lists into a single sorted list. +// ** +// ** aLeft[] and aRight[] are arrays of indices. The sort key is +// ** aContent[aLeft[]] and aContent[aRight[]]. Upon entry, the following +// ** is guaranteed for all J= nRight || **(**Tu32)(__ccgo_up(aContent + uintptr(**(**Tht_slot)(__ccgo_up(aLeft + uintptr(iLeft)*2)))*4)) < **(**Tu32)(__ccgo_up(aContent + uintptr(**(**Tht_slot)(__ccgo_up(aRight + uintptr(iRight)*2)))*4))) { + v1 = iLeft + iLeft = iLeft + 1 + logpage = **(**Tht_slot)(__ccgo_up(aLeft + uintptr(v1)*2)) + } else { + v1 = iRight + iRight = iRight + 1 + logpage = **(**Tht_slot)(__ccgo_up(aRight + uintptr(v1)*2)) + } + dbpage = **(**Tu32)(__ccgo_up(aContent + uintptr(logpage)*4)) + v1 = iOut + iOut = iOut + 1 + **(**Tht_slot)(__ccgo_up(aTmp + uintptr(v1)*2)) = logpage + if iLeft < nLeft && **(**Tu32)(__ccgo_up(aContent + uintptr(**(**Tht_slot)(__ccgo_up(aLeft + uintptr(iLeft)*2)))*4)) == dbpage { + iLeft = iLeft + 1 + } + } + **(**uintptr)(__ccgo_up(paRight)) = aLeft + **(**int32)(__ccgo_up(pnRight)) = iOut + libc.X__builtin___memcpy_chk(tls, aLeft, aTmp, uint64(2)*libc.Uint64FromInt32(iOut), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Sort the elements in list aList using aContent[] as the sort key. +// ** Remove elements with duplicate keys, preferring to keep the +// ** larger aList[] values. +// ** +// ** The aList[] entries are indices into aContent[]. The values in +// ** aList[] are to be sorted so that for all Ja[] of the new WhereTerm is returned on success. +// ** 0 is returned if the new WhereTerm could not be added due to a memory +// ** allocation error. The memory allocation failure will be recorded in +// ** the db->mallocFailed flag so that higher-level functions can detect it. +// ** +// ** This routine will increase the size of the pWC->a[] array as necessary. +// ** +// ** If the wtFlags argument includes TERM_DYNAMIC, then responsibility +// ** for freeing the expression p is assumed by the WhereClause object pWC. +// ** This is true even if this routine fails to allocate a new WhereTerm. +// ** +// ** WARNING: This routine might reallocate the space used to store +// ** WhereTerms. All pointers to WhereTerms should be invalidated after +// ** calling this routine. Such pointers may be reinitialized by referencing +// ** the pWC->a[] array. +// */ +func _whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags Tu16) (r int32) { + var db, pOld, pTerm, v3 uintptr + var idx, v1, v2 int32 + _, _, _, _, _, _, _ = db, idx, pOld, pTerm, v1, v2, v3 + if (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm >= (*TWhereClause)(unsafe.Pointer(pWC)).FnSlot { + pOld = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + db = (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb + (*TWhereClause)(unsafe.Pointer(pWC)).Fa = _sqlite3WhereMalloc(tls, (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo, uint64(uint64(56)*libc.Uint64FromInt32((*TWhereClause)(unsafe.Pointer(pWC)).FnSlot)*uint64(2))) + if (*TWhereClause)(unsafe.Pointer(pWC)).Fa == uintptr(0) { + if libc.Int32FromUint16(wtFlags)&int32(TERM_DYNAMIC) != 0 { + _sqlite3ExprDelete(tls, db, p) + } + (*TWhereClause)(unsafe.Pointer(pWC)).Fa = pOld + return 0 + } + libc.X__builtin___memcpy_chk(tls, (*TWhereClause)(unsafe.Pointer(pWC)).Fa, pOld, uint64(56)*libc.Uint64FromInt32((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm), ^t__predefined_size_t(0)) + (*TWhereClause)(unsafe.Pointer(pWC)).FnSlot = (*TWhereClause)(unsafe.Pointer(pWC)).FnSlot * int32(2) + } + v3 = pWC + 20 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = v2 + idx = v1 + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(v1)*56 + if libc.Int32FromUint16(wtFlags)&int32(TERM_VIRTUAL) == 0 { + (*TWhereClause)(unsafe.Pointer(pWC)).FnBase = (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm + } + if p != 0 && (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Unlikely)) != uint32(0) { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = int16(int32(_sqlite3LogEst(tls, libc.Uint64FromInt32((*TExpr)(unsafe.Pointer(p)).FiTable))) - int32(270)) + } else { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = int16(1) + } + (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr = _sqlite3ExprSkipCollateAndLikely(tls, p) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags = wtFlags + (*TWhereTerm)(unsafe.Pointer(pTerm)).FpWC = pWC + (*TWhereTerm)(unsafe.Pointer(pTerm)).FiParent = -int32(1) + libc.X__builtin___memset_chk(tls, pTerm+20, 0, libc.Uint64FromInt64(56)-uint64(libc.UintptrFromInt32(0)+20), ^t__predefined_size_t(0)) + return idx +} + +// C documentation +// +// /* +// ** pIdx is an index that covers all of the low-number columns used by +// ** pWInfo->pSelect (columns from 0 through 62) or an index that has +// ** expressions terms. Hence, we cannot determine whether or not it is +// ** a covering index by using the colUsed bitmasks. We have to do a search +// ** to see if the index is covering. This routine does that search. +// ** +// ** The return value is one of these: +// ** +// ** 0 The index is definitely not a covering index +// ** +// ** WHERE_IDX_ONLY The index is definitely a covering index +// ** +// ** WHERE_EXPRIDX The index is likely a covering index, but it is +// ** difficult to determine precisely because of the +// ** expressions that are indexed. Score it as a +// ** covering index, but still keep the main table open +// ** just in case we need it. +// ** +// ** This routine is an optimization. It is always safe to return zero. +// ** But returning one of the other two values when zero should have been +// ** returned can lead to incorrect bytecode and assertion faults. +// */ +func _whereIsCoveringIndex(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iTabCur int32) (r Tu32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i, rc int32 + var _ /* ck at bp+0 */ TCoveringIndexCheck + var _ /* w at bp+16 */ TWalker + _, _ = i, rc + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect == uintptr(0) { + /* We don't have access to the full query, so we cannot check to see + ** if pIdx is covering. Assume it is not. */ + return uint32(0) + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x800>>11)) == 0 { + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i >= libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) { + /* pIdx does not index any columns greater than 62, but we know from + ** colMask that columns greater than 62 are used, so this is not a + ** covering index */ + return uint32(0) + } + } + (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FpIdx = pIdx + (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FiTabCur = iTabCur + (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FbExpr = uint8(0) + (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FbUnidx = uint8(0) + libc.X__builtin___memset_chk(tls, bp+16, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp + 16))).FxExprCallback = __ccgo_fp(_whereIsCoveringIndexWalkCallback) + (**(**TWalker)(__ccgo_up(bp + 16))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + *(*uintptr)(unsafe.Pointer(bp + 16 + 40)) = bp + _sqlite3WalkSelect(tls, bp+16, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect) + if (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FbUnidx != 0 { + rc = 0 + } else { + if (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FbExpr != 0 { + rc = int32(WHERE_EXPRIDX) + } else { + rc = int32(WHERE_IDX_ONLY) + } + } + return libc.Uint32FromInt32(rc) +} + +// C documentation +// +// /* +// ** Add all WhereLoop objects for all tables +// */ +func _whereLoopAddAll(tls *libc.TLS, pBuilder uintptr) (r int32) { + var bFirstPastRJ, hasRightCrossJoin, i, iTab, rc int32 + var db, p, pEnd, pItem, pNew, pTabList, pTerm, pWC, pWInfo uintptr + var mPrereq, mPrior, mUnusable TBitmask + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bFirstPastRJ, db, hasRightCrossJoin, i, iTab, mPrereq, mPrior, mUnusable, p, pEnd, pItem, pNew, pTabList, pTerm, pWC, pWInfo, rc + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + mPrereq = uint64(0) + mPrior = uint64(0) + pTabList = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + pEnd = pTabList + 8 + uintptr((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)*80 + db = (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb + rc = SQLITE_OK + bFirstPastRJ = 0 + hasRightCrossJoin = 0 + /* Loop over the tables in the join, from left to right */ + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + /* Verify that pNew has already been initialized */ + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit = uint32(SQLITE_QUERY_PLANNER_LIMIT) + iTab = 0 + pItem = pTabList + 8 + for { + if !(pItem < pEnd) { + break + } + mUnusable = uint64(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FiTab = libc.Uint8FromInt32(iTab) + **(**uint32)(__ccgo_up(pBuilder + 48)) += uint32(SQLITE_QUERY_PLANNER_LIMIT_INCR) + (*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf = _sqlite3WhereGetMask(tls, pWInfo+592, (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor) + if bFirstPastRJ != 0 || libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)|libc.Int32FromInt32(JT_LTORJ)) != 0 { + /* Add prerequisites to prevent reordering of FROM clause terms + ** across CROSS joins and outer joins. The bFirstPastRJ boolean + ** prevents the right operand of a RIGHT JOIN from being swapped with + ** other elements even further to the right. + ** + ** The hasRightCrossJoin flag prevent FROM-clause terms from moving + ** from the right side of a LEFT JOIN or CROSS JOIN over to the + ** left side of that same join. This is a required restriction in + ** the case of LEFT JOIN - an incorrect answer may results if it is + ** not enforced. This restriction is not required for CROSS JOIN. + ** It is provided merely as a means of controlling join order, under + ** the theory that no real-world queries that care about performance + ** actually use the CROSS JOIN syntax. + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_CROSS)) != 0 { + hasRightCrossJoin = int32(1) + } + mPrereq = mPrereq | mPrior + bFirstPastRJ = libc.BoolInt32(libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0) + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x40000>>18) != 0 { + /* joins that result from the EXISTS-to-JOIN optimization should not + ** be moved to the left of any of their dependencies */ + pWC = pWInfo + 104 + i = (*TWhereClause)(unsafe.Pointer(pWC)).FnBase + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(i > 0) { + break + } + if (*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf&(*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll != uint64(0) { + mPrereq = mPrereq | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&((*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf-uint64(1)) + } + goto _2 + _2: + ; + i = i - 1 + pTerm += 56 + } + } else { + if !(hasRightCrossJoin != 0) { + mPrereq = uint64(0) + } + } + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FeTabType) == int32(TABTYP_VTAB) { + p = pItem + 1*80 + for { + if !(p < pEnd) { + break + } + if mUnusable != 0 || libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(p)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)) != 0 { + mUnusable = mUnusable | _sqlite3WhereGetMask(tls, pWInfo+592, (*TSrcItem)(unsafe.Pointer(p)).FiCursor) + } + goto _3 + _3: + ; + p += 80 + } + rc = _whereLoopAddVirtual(tls, pBuilder, mPrereq, mUnusable) + } else { + rc = _whereLoopAddBtree(tls, pBuilder, mPrereq) + } + if rc == SQLITE_OK && (*TWhereClause)(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC)).FhasOr != 0 { + rc = _whereLoopAddOr(tls, pBuilder, mPrereq, mUnusable) + } + mPrior = mPrior | (*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf + if rc != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + if rc == int32(SQLITE_DONE) { + /* We hit the query planner search limit set by iPlanLimit */ + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+24373, 0) + rc = SQLITE_OK + } else { + break + } + } + goto _1 + _1: + ; + iTab = iTab + 1 + pItem += 80 + } + _whereLoopClear(tls, db, pNew) + return rc +} + +// C documentation +// +// /* +// ** Add all WhereLoop objects for a single table of the join where the table +// ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be +// ** a b-tree table, not a virtual table. +// ** +// ** The costs (WhereLoop.rRun) of the b-tree loops added by this function +// ** are calculated as follows: +// ** +// ** For a full scan, assuming the table (or index) contains nRow rows: +// ** +// ** cost = nRow * 3.0 // full-table scan +// ** cost = nRow * K // scan of covering index +// ** cost = nRow * (K+3.0) // scan of non-covering index +// ** +// ** where K is a value between 1.1 and 3.0 set based on the relative +// ** estimated average size of the index and table records. +// ** +// ** For an index scan, where nVisit is the number of index rows visited +// ** by the scan, and nSeek is the number of seek operations required on +// ** the index b-tree: +// ** +// ** cost = nSeek * (log(nRow) + K * nVisit) // covering index +// ** cost = nSeek * (log(nRow) + (K+3.0) * nVisit) // non-covering index +// ** +// ** Normally, nSeek is 1. nSeek values greater than 1 come about if the +// ** WHERE clause includes "x IN (....)" terms used in place of "x=?". Or when +// ** implicit "x IN (SELECT x FROM tbl)" terms are added for skip-scans. +// ** +// ** The estimated values (nRow, nVisit, nSeek) often contain a large amount +// ** of uncertainty. For this reason, scoring is designed to pick plans that +// ** "do the least harm" if the estimates are inaccurate. For example, a +// ** log(nRow) factor is omitted from a non-covering index scan in order to +// ** bias the scoring in favor of using an index, since the worst-case +// ** performance of using an index is far better than the worst-case performance +// ** of a full table scan. +// */ +func _whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq TBitmask) (r int32) { + bp := tls.Alloc(176) + defer tls.Free(176) + var b, iCur, iSortIdx, ii, rc, v5 int32 + var isCov Tu32 + var nLookup, rLogSize, rSize TLogEst + var pFirst, pNew, pProbe, pSrc, pTab, pTabList, pTerm, pTerm1, pWC, pWC2, pWCEnd, pWInfo, v2 uintptr + var _ /* aiColumnPk at bp+164 */ Ti16 + var _ /* aiRowEstPk at bp+160 */ [2]TLogEst + var _ /* m at bp+168 */ TBitmask + var _ /* sPk at bp+0 */ TIndex + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, iCur, iSortIdx, ii, isCov, nLookup, pFirst, pNew, pProbe, pSrc, pTab, pTabList, pTerm, pTerm1, pWC, pWC2, pWCEnd, pWInfo, rLogSize, rSize, rc, v2, v5 /* The aiRowLogEst[] value for the sPk index */ + **(**Ti16)(__ccgo_up(bp + 164)) = int16(-int32(1)) /* Template WhereLoop object */ + rc = SQLITE_OK /* Return code */ + iSortIdx = int32(1) /* Table being queried */ + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + pTabList = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + pSrc = pTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pNew)).FiTab)*80 + pTab = (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab + pWC = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x2>>1) != 0 { + /* An INDEXED BY clause specifies a particular index to use */ + pProbe = *(*uintptr)(unsafe.Pointer(pSrc + 56)) + } else { + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pProbe = (*TTable)(unsafe.Pointer(pTab)).FpIndex + } else { /* First of real indices on the table */ + libc.X__builtin___memset_chk(tls, bp, 0, uint64(160), ^t__predefined_size_t(0)) + (**(**TIndex)(__ccgo_up(bp))).FnKeyCol = uint16(1) + (**(**TIndex)(__ccgo_up(bp))).FnColumn = uint16(1) + (**(**TIndex)(__ccgo_up(bp))).FaiColumn = bp + 164 + (**(**TIndex)(__ccgo_up(bp))).FaiRowLogEst = bp + 160 + (**(**TIndex)(__ccgo_up(bp))).FonError = uint8(OE_Replace) + (**(**TIndex)(__ccgo_up(bp))).FpTable = pTab + (**(**TIndex)(__ccgo_up(bp))).FszIdxRow = int16(3) /* TUNING: Interior rows of IPK table are very small */ + libc.SetBitFieldPtr16Uint32(bp+100, libc.Uint32FromInt32(SQLITE_IDXTYPE_IPK), 0, 0x3) + (**(**[2]TLogEst)(__ccgo_up(bp + 160)))[0] = (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst + (**(**[2]TLogEst)(__ccgo_up(bp + 160)))[int32(1)] = 0 + pFirst = (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FpIndex + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x1>>0) == 0 { + /* The real indices of the table are only considered if the + ** NOT INDEXED qualifier is omitted from the FROM clause */ + (**(**TIndex)(__ccgo_up(bp))).FpNext = pFirst + } + pProbe = bp + } + } + rSize = (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst + /* Automatic indexes */ + if !((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet != 0) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(libc.Int32FromInt32(WHERE_RIGHT_JOIN)|libc.Int32FromInt32(WHERE_OR_SUBCLAUSE)) == 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).Fflags&uint64(SQLITE_AutoIndex) != uint64(0) && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x2>>1) != 0) && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x1>>0) != 0) && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x10>>4) != 0) && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x80>>7) != 0) && libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + pWCEnd = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)*56 + rLogSize = _estLog(tls, rSize) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(rc == SQLITE_OK && pTerm < pWCEnd) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&(*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf != 0 { + goto _1 + } + if _termCanDriveIndex(tls, pTerm, pSrc, uint64(0)) != 0 { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq = uint16(1) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip = uint16(0) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FpIndex = uintptr(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = uint16(1) + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm + /* TUNING: One-time cost for computing the automatic index is + ** estimated to be X*N*log2(N) where N is the number of rows in + ** the table being indexed and where X is 7 (LogEst=28) for normal + ** tables or 0.5 (LogEst=-10) for views and subqueries. The value + ** of X is smaller for views and subqueries so that the query planner + ** will be more aggressive about generating automatic indexes for + ** those objects, since there is no opportunity to add schema + ** indexes on subqueries and views. */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(int32(rLogSize) + int32(rSize)) + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VIEW)) && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Ephemeral) == uint32(0) { + v2 = pNew + 18 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) + libc.Int32FromInt32(28)) + } else { + v2 = pNew + 18 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) - libc.Int32FromInt32(25)) /* Greatly reduced setup cost for auto indexes + ** on ephemeral materializations of views */ + } + if int32((*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup) < 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = 0 + } + /* TUNING: Each index lookup yields 20 rows in the table. This + ** is more than the usual guess of 10 rows, since we have no way + ** of knowing how selective the index will ultimately be. It would + ** not be unreasonable to make this value much larger. */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = int16(43) + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = _sqlite3LogEstAdd(tls, rLogSize, (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut) + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_AUTO_INDEX) + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight + rc = _whereLoopInsert(tls, pBuilder, pNew) + } + goto _1 + _1: + ; + pTerm += 56 + } + } + /* Loop over all indices. If there was an INDEXED BY clause, then only + ** consider index pProbe. */ + for { + if !(rc == SQLITE_OK && pProbe != 0) { + break + } + if (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0) && !(_whereUsablePartialIndex(tls, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor, (*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype, pWC, (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere) != 0) { + /* See ticket [98d973b8f5] */ + goto _4 /* Partial index inappropriate for this query */ + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x100>>8)) != 0 { + goto _4 + } + rSize = **(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst)) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq = uint16(0) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnBtm = uint16(0) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnTop = uint16(0) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnDistinctCol = uint16(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip = uint16(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = uint16(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = uint8(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = 0 + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FpIndex = pProbe + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FpOrderBy = uintptr(0) + b = _indexMightHelpWithOrderBy(tls, pBuilder, pProbe, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor) + /* The ONEPASS_DESIRED flags never occurs together with ORDER BY */ + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_IPK) { + /* Integer primary key index */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_IPK) + /* Full table scan */ + if b != 0 { + v5 = iSortIdx + } else { + v5 = 0 + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = libc.Uint8FromInt32(v5) + /* TUNING: Cost of full table scan is 3.0*N. The 3.0 factor is an + ** extra cost designed to discourage the use of full table scans, + ** since index lookups have better worst-case performance if our + ** stat guesses are wrong. Reduce the 3.0 penalty slightly + ** (to 2.75) if we have valid STAT4 information for the table. + ** At 2.75, a full table scan is preferred over using an index on + ** a column with just two distinct values where each value has about + ** an equal number of appearances. Without STAT4 data, we still want + ** to use an index in that case, since the constraint might be for + ** the scarcer of the two values, and in that case an index lookup is + ** better. + */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = int16(int32(rSize) + int32(16) - int32(2)*libc.BoolInt32((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasStat4) != uint32(0))) + _whereLoopOutputAdjust(tls, pWC, pNew, rSize) + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x4>>2) != 0 { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40>>6) != 0 { + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_COROUTINE) + } + /* Do not set btree.pOrderBy for a recursive CTE. In this case + ** the ORDER BY clause does not determine the overall order that + ** rows are emitted from the CTE in. */ + if (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FpSelect)).FselFlags&uint32(SF_Recursive) == uint32(0) { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FpOrderBy = (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FpSelect)).FpOrderBy + } + } else { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40000>>18) != 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = 0 + } + } + rc = _whereLoopInsert(tls, pBuilder, pNew) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize + if rc != 0 { + break + } + } else { + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x20>>5)) != 0 { + **(**TBitmask)(__ccgo_up(bp + 168)) = uint64(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY) | libc.Int32FromInt32(WHERE_INDEXED)) + } else { + **(**TBitmask)(__ccgo_up(bp + 168)) = (*TSrcItem)(unsafe.Pointer(pSrc)).FcolUsed & (*TIndex)(unsafe.Pointer(pProbe)).FcolNotIdxed + if (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere != 0 { + _wherePartIdxExpr(tls, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse, pProbe, (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere, bp+168, 0, uintptr(0)) + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_INDEXED) + if **(**TBitmask)(__ccgo_up(bp + 168)) == libc.Uint64FromInt32(1)<<(libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1)) || int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x800>>11)) != 0 && !(int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x400>>10)) != 0) && **(**TBitmask)(__ccgo_up(bp + 168)) != uint64(0) { + isCov = _whereIsCoveringIndex(tls, pWInfo, pProbe, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor) + if isCov == uint32(0) { + } else { + **(**TBitmask)(__ccgo_up(bp + 168)) = uint64(0) + **(**Tu32)(__ccgo_up(pNew + 48)) |= isCov + if isCov&uint32(WHERE_IDX_ONLY) != 0 { + } else { + } + } + } else { + if **(**TBitmask)(__ccgo_up(bp + 168)) == uint64(0) && ((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect != uintptr(0) || _sqlite3FaultSim(tls, int32(700)) != 0) { + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY) | libc.Int32FromInt32(WHERE_INDEXED)) + } + } + } + /* Full scan via index */ + if b != 0 || !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) || (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0) || int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x2>>1) != 0 || **(**TBitmask)(__ccgo_up(bp + 168)) == uint64(0) && int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x4>>2)) == 0 && int32((*TIndex)(unsafe.Pointer(pProbe)).FszIdxRow) < int32((*TTable)(unsafe.Pointer(pTab)).FszTabRow) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_ONEPASS_DESIRED) == 0 && _sqlite3Config.FbUseCis != 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_CoverIdxScan)) == uint32(0) { + if b != 0 { + v5 = iSortIdx + } else { + v5 = 0 + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = libc.Uint8FromInt32(v5) + /* The cost of visiting the index rows is N*K, where K is + ** between 1.1 and 3.0, depending on the relative sizes of the + ** index and table rows. */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = int16(int32(rSize) + int32(1) + int32(15)*int32((*TIndex)(unsafe.Pointer(pProbe)).FszIdxRow)/int32((*TTable)(unsafe.Pointer(pTab)).FszTabRow)) + if **(**TBitmask)(__ccgo_up(bp + 168)) != uint64(0) { + /* If this is a non-covering index scan, add in the cost of + ** doing table lookups. The cost will be 3x the number of + ** lookups. Take into account WHERE clause terms that can be + ** satisfied using just the index, and that do not require a + ** table lookup. */ + nLookup = int16(int32(rSize) + int32(16)) + iCur = (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor + pWC2 = pWInfo + 104 + ii = 0 + for { + if !(ii < (*TWhereClause)(unsafe.Pointer(pWC2)).FnTerm) { + break + } + pTerm1 = (*TWhereClause)(unsafe.Pointer(pWC2)).Fa + uintptr(ii)*56 + if !(_sqlite3ExprCoveredByIndex(tls, (*TWhereTerm)(unsafe.Pointer(pTerm1)).FpExpr, iCur, pProbe) != 0) { + break + } + /* pTerm can be evaluated using just the index. So reduce + ** the expected number of table lookups accordingly */ + if int32((*TWhereTerm)(unsafe.Pointer(pTerm1)).FtruthProb) <= 0 { + nLookup = int16(int32(nLookup) + int32((*TWhereTerm)(unsafe.Pointer(pTerm1)).FtruthProb)) + } else { + nLookup = nLookup - 1 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm1)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) != 0 { + nLookup = int16(int32(nLookup) - libc.Int32FromInt32(19)) + } + } + goto _7 + _7: + ; + ii = ii + 1 + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = _sqlite3LogEstAdd(tls, (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun, nLookup) + } + _whereLoopOutputAdjust(tls, pWC, pNew, rSize) + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 && (*TIndex)(unsafe.Pointer(pProbe)).FaColExpr != 0 { + /* Do not do an SCAN of a index-on-expression in a RIGHT JOIN + ** because the cursor used to access the index might not be + ** positioned to the correct row during the right-join no-match + ** loop. */ + } else { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40000>>18) != 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = 0 + } + rc = _whereLoopInsert(tls, pBuilder, pNew) + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize + if rc != 0 { + break + } + } + } + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1 = uint8(0) + rc = _whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, 0) + if libc.Int32FromUint8((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1) == int32(SQLITE_BLDF1_INDEXED) { + /* If a non-unique index is used, or if a prefix of the key for + ** unique index is used (making the index functionally non-unique) + ** then the sqlite_stat1 data becomes important for scoring the + ** plan */ + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_MaybeReanalyze) + } + _sqlite3Stat4ProbeFree(tls, (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec) + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = 0 + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = uintptr(0) + goto _4 + _4: + ; + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x2>>1) != 0 { + v2 = uintptr(0) + } else { + v2 = (*TIndex)(unsafe.Pointer(pProbe)).FpNext + } + pProbe = v2 + iSortIdx = iSortIdx + 1 + } + return rc +} + +// C documentation +// +// /* +// ** Add WhereLoop entries to handle OR terms. This works for either +// ** btrees or virtual tables. +// */ +func _whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq TBitmask, mUnusable TBitmask) (r int32) { + bp := tls.Alloc(720) + defer tls.Free(720) + var i, iCur, j, once, rc int32 + var pItem, pNew, pOrTerm, pOrWC, pOrWCEnd, pTerm, pWC, pWCEnd, pWInfo uintptr + var _ /* sCur at bp+600 */ TWhereOrSet + var _ /* sPrev at bp+656 */ TWhereOrSet + var _ /* sSubBuild at bp+488 */ TWhereLoopBuilder + var _ /* sSum at bp+544 */ TWhereOrSet + var _ /* tempWC at bp+0 */ TWhereClause + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iCur, j, once, pItem, pNew, pOrTerm, pOrWC, pOrWCEnd, pTerm, pWC, pWCEnd, pWInfo, rc + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + rc = SQLITE_OK + pWC = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC + pWCEnd = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)*56 + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + libc.X__builtin___memset_chk(tls, bp+544, 0, uint64(56), ^t__predefined_size_t(0)) + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pNew)).FiTab)*80 + iCur = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + /* The multi-index OR optimization does not work for RIGHT and FULL JOIN */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + return SQLITE_OK + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(pTerm < pWCEnd && rc == SQLITE_OK) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_OR) != 0 && (*TWhereOrInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 32)))).Findexable&(*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf != uint64(0) { + pOrWC = *(*uintptr)(unsafe.Pointer(pTerm + 32)) + pOrWCEnd = (*TWhereClause)(unsafe.Pointer(pOrWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pOrWC)).FnTerm)*56 + once = int32(1) + **(**TWhereLoopBuilder)(__ccgo_up(bp + 488)) = **(**TWhereLoopBuilder)(__ccgo_up(pBuilder)) + (**(**TWhereLoopBuilder)(__ccgo_up(bp + 488))).FpOrSet = bp + 600 + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWC)).Fa + for { + if !(pOrTerm < pOrWCEnd) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_AND) != 0 { + (**(**TWhereLoopBuilder)(__ccgo_up(bp + 488))).FpWC = *(*uintptr)(unsafe.Pointer(pOrTerm + 32)) + } else { + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur { + (**(**TWhereClause)(__ccgo_up(bp))).FpWInfo = (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo + (**(**TWhereClause)(__ccgo_up(bp))).FpOuter = pWC + (**(**TWhereClause)(__ccgo_up(bp))).Fop = uint8(TK_AND) + (**(**TWhereClause)(__ccgo_up(bp))).FnTerm = int32(1) + (**(**TWhereClause)(__ccgo_up(bp))).FnBase = int32(1) + (**(**TWhereClause)(__ccgo_up(bp))).Fa = pOrTerm + (**(**TWhereLoopBuilder)(__ccgo_up(bp + 488))).FpWC = bp + } else { + goto _2 + } + } + (**(**TWhereOrSet)(__ccgo_up(bp + 600))).Fn = uint16(0) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FeTabType) == int32(TABTYP_VTAB) { + rc = _whereLoopAddVirtual(tls, bp+488, mPrereq, mUnusable) + } else { + rc = _whereLoopAddBtree(tls, bp+488, mPrereq) + } + if rc == SQLITE_OK { + rc = _whereLoopAddOr(tls, bp+488, mPrereq, mUnusable) + } + if libc.Int32FromUint16((**(**TWhereOrSet)(__ccgo_up(bp + 600))).Fn) == 0 { + (**(**TWhereOrSet)(__ccgo_up(bp + 544))).Fn = uint16(0) + break + } else { + if once != 0 { + _whereOrMove(tls, bp+544, bp+600) + once = 0 + } else { + _whereOrMove(tls, bp+656, bp+544) + (**(**TWhereOrSet)(__ccgo_up(bp + 544))).Fn = uint16(0) + i = 0 + for { + if !(i < libc.Int32FromUint16((**(**TWhereOrSet)(__ccgo_up(bp + 656))).Fn)) { + break + } + j = 0 + for { + if !(j < libc.Int32FromUint16((**(**TWhereOrSet)(__ccgo_up(bp + 600))).Fn)) { + break + } + _whereOrInsert(tls, bp+544, (**(**TWhereOrCost)(__ccgo_up(bp + 656 + 8 + uintptr(i)*16))).Fprereq|(**(**TWhereOrCost)(__ccgo_up(bp + 600 + 8 + uintptr(j)*16))).Fprereq, _sqlite3LogEstAdd(tls, (**(**TWhereOrCost)(__ccgo_up(bp + 656 + 8 + uintptr(i)*16))).FrRun, (**(**TWhereOrCost)(__ccgo_up(bp + 600 + 8 + uintptr(j)*16))).FrRun), _sqlite3LogEstAdd(tls, (**(**TWhereOrCost)(__ccgo_up(bp + 656 + 8 + uintptr(i)*16))).FnOut, (**(**TWhereOrCost)(__ccgo_up(bp + 600 + 8 + uintptr(j)*16))).FnOut)) + goto _4 + _4: + ; + j = j + 1 + } + goto _3 + _3: + ; + i = i + 1 + } + } + } + goto _2 + _2: + ; + pOrTerm += 56 + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = uint16(1) + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_MULTI_OR) + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = 0 + (*TWhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = uint8(0) + libc.X__builtin___memset_chk(tls, pNew+24, 0, uint64(24), ^t__predefined_size_t(0)) + i = 0 + for { + if !(rc == SQLITE_OK && i < libc.Int32FromUint16((**(**TWhereOrSet)(__ccgo_up(bp + 544))).Fn)) { + break + } + /* TUNING: Currently sSum.a[i].rRun is set to the sum of the costs + ** of all sub-scans required by the OR-scan. However, due to rounding + ** errors, it may be that the cost of the OR-scan is equal to its + ** most expensive sub-scan. Add the smallest possible penalty + ** (equivalent to multiplying the cost by 1.07) to ensure that + ** this does not happen. Otherwise, for WHERE clauses such as the + ** following where there is an index on "y": + ** + ** WHERE likelihood(x=?, 0.99) OR y=? + ** + ** the planner may elect to "OR" together a full-table scan and an + ** index lookup. And other similarly odd results. */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = int16(int32((**(**TWhereOrCost)(__ccgo_up(bp + 544 + 8 + uintptr(i)*16))).FrRun) + int32(1)) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = (**(**TWhereOrCost)(__ccgo_up(bp + 544 + 8 + uintptr(i)*16))).FnOut + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = (**(**TWhereOrCost)(__ccgo_up(bp + 544 + 8 + uintptr(i)*16))).Fprereq + rc = _whereLoopInsert(tls, pBuilder, pNew) + goto _5 + _5: + ; + i = i + 1 + } + } + goto _1 + _1: + ; + pTerm += 56 + } + return rc +} + +// C documentation +// +// /* +// ** Argument pIdxInfo is already populated with all constraints that may +// ** be used by the virtual table identified by pBuilder->pNew->iTab. This +// ** function marks a subset of those constraints usable, invokes the +// ** xBestIndex method and adds the returned plan to pBuilder. +// ** +// ** A constraint is marked usable if: +// ** +// ** * Argument mUsable indicates that its prerequisites are available, and +// ** +// ** * It is not one of the operators specified in the mExclude mask passed +// ** as the fourth argument (which in practice is either WO_IN or 0). +// ** +// ** Argument mPrereq is a mask of tables that must be scanned before the +// ** virtual table in question. These are added to the plans prerequisites +// ** before it is added to pBuilder. +// ** +// ** Output parameter *pbIn is set to true if the plan added to pBuilder +// ** uses one or more WO_IN terms, or false otherwise. +// */ +func _whereLoopAddVirtualOne(tls *libc.TLS, pBuilder uintptr, mPrereq TBitmask, mUsable TBitmask, mExclude Tu16, pIdxInfo uintptr, mNoOmit Tu16, pbIn uintptr, pbRetryLimit uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iTerm, j, mxTerm, nConstraint, rc, v3 int32 + var pHidden, pIdxCons, pNew, pParse, pSrc, pTerm, pTerm1, pUsage, pWC, v4 uintptr + var v5 bool + var v7 uint32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iTerm, j, mxTerm, nConstraint, pHidden, pIdxCons, pNew, pParse, pSrc, pTerm, pTerm1, pUsage, pWC, rc, v3, v4, v5, v7 + pWC = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC + pHidden = pIdxInfo + 1*96 + pUsage = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + rc = SQLITE_OK + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + pParse = (*TWhereInfo)(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpParse + pSrc = (*TWhereInfo)(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pNew)).FiTab)*80 + nConstraint = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint + **(**int32)(__ccgo_up(pbIn)) = 0 + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq + /* Set the usable flag on the subset of constraints identified by + ** arguments mUsable and mExclude. */ + pIdxCons = **(**uintptr)(__ccgo_up(pIdxInfo + 8)) + i = 0 + for { + if !(i < nConstraint) { + break + } + pTerm = _termFromWhereClause(tls, pWC, (*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).FiTermOffset) + (*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable = uint8(0) + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&mUsable == (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&libc.Int32FromUint16(mExclude) == 0 && (pbRetryLimit != 0 || !(_isLimitTerm(tls, pTerm) != 0)) { + (*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable = uint8(1) + } + goto _1 + _1: + ; + i = i + 1 + pIdxCons += 12 + } + /* Initialize the output fields of the sqlite3_index_info structure */ + libc.X__builtin___memset_chk(tls, pUsage, 0, uint64(8)*libc.Uint64FromInt32(nConstraint), ^t__predefined_size_t(0)) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = uintptr(0) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 0 + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1e+99) / libc.Float64FromInt32(2) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(25) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 0 + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FmHandleIn = uint32(0) + /* Invoke the virtual table xBestIndex() method */ + rc = _vtabBestIndex(tls, pParse, (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab, pIdxInfo) + if rc != 0 { + if rc == int32(SQLITE_CONSTRAINT) { + /* If the xBestIndex method returns SQLITE_CONSTRAINT, that means + ** that the particular combination of parameters provided is unusable. + ** Make no entries in the loop table. + */ + _freeIdxStr(tls, pIdxInfo) + return SQLITE_OK + } + return rc + } + mxTerm = -int32(1) + libc.X__builtin___memset_chk(tls, (*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm, 0, uint64(8)*libc.Uint64FromInt32(nConstraint), ^t__predefined_size_t(0)) + libc.X__builtin___memset_chk(tls, pNew+24, 0, uint64(24), ^t__predefined_size_t(0)) + pIdxCons = **(**uintptr)(__ccgo_up(pIdxInfo + 8)) + i = 0 + for { + if !(i < nConstraint) { + break + } + v3 = (**(**Tsqlite3_index_constraint_usage)(__ccgo_up(pUsage + uintptr(i)*8))).FargvIndex - libc.Int32FromInt32(1) + iTerm = v3 + if v3 >= 0 { + j = (*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).FiTermOffset + if v5 = iTerm >= nConstraint || j < 0; !v5 { + v4 = _termFromWhereClause(tls, pWC, j) + pTerm1 = v4 + } + if v5 || v4 == uintptr(0) || **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(iTerm)*8)) != uintptr(0) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24347, libc.VaList(bp+8, (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FzName)) + _freeIdxStr(tls, pIdxInfo) + return int32(SQLITE_ERROR) + } + **(**TBitmask)(__ccgo_up(pNew)) |= (*TWhereTerm)(unsafe.Pointer(pTerm1)).FprereqRight + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(iTerm)*8)) = pTerm1 + if iTerm > mxTerm { + mxTerm = iTerm + } + if (**(**Tsqlite3_index_constraint_usage)(__ccgo_up(pUsage + uintptr(i)*8))).Fomit != 0 { + if i < int32(16) && int32(1)<>0)) != 0 { + Xsqlite3_free(tls, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pNew + 24))).FidxStr) + libc.SetBitFieldPtr8Uint32(pNew+24+4, libc.Uint32FromInt32(0), 0, 0x1) + } + return rc +} + +// C documentation +// +// /* +// ** Increase the memory allocation for pLoop->aLTerm[] to be at least n. +// */ +func _whereLoopResize(tls *libc.TLS, db uintptr, p uintptr, n int32) (r int32) { + var paNew uintptr + _ = paNew + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(p)).FnLSlot) >= n { + return SQLITE_OK + } + n = (n + int32(7)) & ^libc.Int32FromInt32(7) + paNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(8)*libc.Uint64FromInt32(n))) + if paNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, paNew, (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm, uint64(8)*uint64((*TWhereLoop)(unsafe.Pointer(p)).FnLSlot), ^t__predefined_size_t(0)) + if (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm != p+80 { + _sqlite3DbFreeNN(tls, db, (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm) + } + (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm = paNew + (*TWhereLoop)(unsafe.Pointer(p)).FnLSlot = libc.Uint16FromInt32(n) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Transfer content from the second pLoop into the first. +// */ +func _whereLoopXfer(tls *libc.TLS, db uintptr, pTo uintptr, pFrom uintptr) (r int32) { + _whereLoopClearUnion(tls, db, pTo) + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pFrom)).FnLTerm) > libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pTo)).FnLSlot) && _whereLoopResize(tls, db, pTo, libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pFrom)).FnLTerm)) != 0 { + libc.X__builtin___memset_chk(tls, pTo, 0, uint64(libc.UintptrFromInt32(0)+56), ^t__predefined_size_t(0)) + return int32(SQLITE_NOMEM) + } + libc.X__builtin___memcpy_chk(tls, pTo, pFrom, uint64(libc.UintptrFromInt32(0)+56), ^t__predefined_size_t(0)) + libc.X__builtin___memcpy_chk(tls, (*TWhereLoop)(unsafe.Pointer(pTo)).FaLTerm, (*TWhereLoop)(unsafe.Pointer(pFrom)).FaLTerm, uint64((*TWhereLoop)(unsafe.Pointer(pTo)).FnLTerm)*uint64(8), ^t__predefined_size_t(0)) + if (*TWhereLoop)(unsafe.Pointer(pFrom)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != 0 { + libc.SetBitFieldPtr8Uint32(pFrom+24+4, libc.Uint32FromInt32(0), 0, 0x1) + } else { + if (*TWhereLoop)(unsafe.Pointer(pFrom)).FwsFlags&uint32(WHERE_AUTO_INDEX) != uint32(0) { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pFrom + 24))).FpIndex = uintptr(0) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* Attempt to omit tables from a join that do not affect the result. +// ** For a table to not affect the result, the following must be true: +// ** +// ** 1) The query must not be an aggregate. +// ** 2) The table must be the RHS of a LEFT JOIN. +// ** 3) Either the query must be DISTINCT, or else the ON or USING clause +// ** must contain a constraint that limits the scan of the table to +// ** at most a single row. +// ** 4) The table must not be referenced by any part of the query apart +// ** from its own USING or ON clause. +// ** 5) The table must not have an inner-join ON or USING clause if there is +// ** a RIGHT JOIN anywhere in the query. Otherwise the ON/USING clause +// ** might move from the right side to the left side of the RIGHT JOIN. +// ** Note: Due to (2), this condition can only arise if the table is +// ** the right-most table of a subquery that was flattened into the +// ** main query and that subquery was the right-hand operand of an +// ** inner join that held an ON or USING clause. +// ** 6) The ORDER BY clause has 63 or fewer terms +// ** 7) The omit-noop-join optimization is enabled. +// ** +// ** Items (1), (6), and (7) are checked by the caller. +// ** +// ** For example, given: +// ** +// ** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1); +// ** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2); +// ** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3); +// ** +// ** then table t2 can be omitted from the following: +// ** +// ** SELECT v1, v3 FROM t1 +// ** LEFT JOIN t2 ON (t1.ipk=t2.ipk) +// ** LEFT JOIN t3 ON (t1.ipk=t3.ipk) +// ** +// ** or from: +// ** +// ** SELECT DISTINCT v1, v3 FROM t1 +// ** LEFT JOIN t2 +// ** LEFT JOIN t3 ON (t1.ipk=t3.ipk) +// */ +func _whereOmitNoopJoin(tls *libc.TLS, pWInfo uintptr, notReady TBitmask) (r TBitmask) { + var hasRightJoin, i, nByte int32 + var m1, tabUsed TBitmask + var pEnd, pItem, pLoop, pTerm, v4 uintptr + _, _, _, _, _, _, _, _, _, _ = hasRightJoin, i, m1, nByte, pEnd, pItem, pLoop, pTerm, tabUsed, v4 + /* Preconditions checked by the caller */ + /* These two preconditions checked by the caller combine to guarantee + ** condition (1) of the header comment */ + tabUsed = _sqlite3WhereExprListUsage(tls, pWInfo+592, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet) + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { + tabUsed = tabUsed | _sqlite3WhereExprListUsage(tls, pWInfo+592, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy) + } + hasRightJoin = libc.BoolInt32(libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0) + i = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - int32(1) + for { + if !(i >= int32(1)) { + break + } + pLoop = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(i)*112))).FpWLoop + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pLoop)).FiTab)*80 + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_RIGHT)) != int32(JT_LEFT) { + goto _1 + } + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) == 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_ONEROW) == uint32(0) { + goto _1 + } + if tabUsed&(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) { + goto _1 + } + pEnd = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + uintptr((*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.FnTerm)*56 + pTerm = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + for { + if !(pTerm < pEnd) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) { + if !((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) || *(*int32)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + 52)) != (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor { + break + } + } + if hasRightJoin != 0 && (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) != uint32(0) && *(*int32)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + 52)) == (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor { + break /* restriction (5) */ + } + goto _2 + _2: + ; + pTerm += 56 + } + if pTerm < pEnd { + goto _1 + } + m1 = libc.Uint64FromInt32(1)<>libc.Int32FromInt32(1) & ^m1 + notReady = notReady & ^(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf + pTerm = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + for { + if !(pTerm < pEnd) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) { + v4 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(TERM_CODED)) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = uint64(0) + } + goto _3 + _3: + ; + pTerm += 56 + } + if i != libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-int32(1) { + nByte = libc.Int32FromUint64(libc.Uint64FromInt32(libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-libc.Int32FromInt32(1)-i) * uint64(112)) + libc.X__builtin___memmove_chk(tls, pWInfo+856+uintptr(i)*112, pWInfo+856+uintptr(i+int32(1))*112, libc.Uint64FromInt32(nByte), ^t__predefined_size_t(0)) + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel - 1 + goto _1 + _1: + ; + i = i - 1 + } + return notReady +} + +// C documentation +// +// /* +// ** Move the content of pSrc into pDest +// */ +func _whereOrMove(tls *libc.TLS, pDest uintptr, pSrc uintptr) { + (*TWhereOrSet)(unsafe.Pointer(pDest)).Fn = (*TWhereOrSet)(unsafe.Pointer(pSrc)).Fn + libc.X__builtin___memcpy_chk(tls, pDest+8, pSrc+8, uint64((*TWhereOrSet)(unsafe.Pointer(pDest)).Fn)*uint64(16), ^t__predefined_size_t(0)) +} + +// C documentation +// +// /* +// ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine +// ** attempts to find the lowest cost path that visits each WhereLoop +// ** once. This path is then loaded into the pWInfo->a[].pWLoop fields. +// ** +// ** Assume that the total number of output rows that will need to be sorted +// ** will be nRowEst (in the 10*log2 representation). Or, ignore sorting +// ** costs if nRowEst==0. +// ** +// ** Return SQLITE_OK on success or SQLITE_NOMEM of a memory allocation +// ** error occurs. +// */ +func _wherePathSolver(tls *libc.TLS, pWInfo uintptr, nRowEst TLogEst) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aFrom, aSortCost, aTo, pFrom, pLevel, pParse, pSpace, pTo, pWLoop, pX, v11 uintptr + var iLoop, ii, jj, mxChoice, mxI, nFrom, nLoop, nOrder, nOrderBy, nSpace, nTo, rc, rc1, v2 int32 + var isOrdered Ti8 + var maskNew TBitmask + var mxCost, mxUnsort, nOut, rCost, rUnsort TLogEst + var wsFlags Tu32 + var _ /* m at bp+16 */ TBitmask + var _ /* notUsed at bp+8 */ TBitmask + var _ /* revMask at bp+0 */ TBitmask + var _ /* revMask at bp+24 */ TBitmask + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aFrom, aSortCost, aTo, iLoop, ii, isOrdered, jj, maskNew, mxChoice, mxCost, mxI, mxUnsort, nFrom, nLoop, nOrder, nOrderBy, nOut, nSpace, nTo, pFrom, pLevel, pParse, pSpace, pTo, pWLoop, pX, rCost, rUnsort, rc, rc1, wsFlags, v11, v2 /* Loop counters */ + mxI = 0 /* Number of ORDER BY clause terms */ + mxCost = 0 /* Maximum cost of a set of paths */ + mxUnsort = 0 /* Used to divy up the pSpace memory */ + aSortCost = uintptr(0) /* Bytes of space allocated at pSpace */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + nLoop = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) + /* TUNING: mxChoice is the maximum number of possible paths to preserve + ** at each step. Based on the number of loops in the FROM clause: + ** + ** nLoop mxChoice + ** ----- -------- + ** 1 1 // the most common case + ** 2 5 + ** 3+ 12 or 18 // see computeMxChoice() + */ + if nLoop <= int32(1) { + mxChoice = int32(1) + } else { + if nLoop == int32(2) { + mxChoice = int32(5) + } else { + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + mxChoice = int32(1) + } else { + mxChoice = _computeMxChoice(tls, pWInfo) + } + } + } + /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this + ** case the purpose of this call is to estimate the number of rows returned + ** by the overall query. Once this estimate has been obtained, the caller + ** will invoke this function a second time, passing the estimate as the + ** nRowEst parameter. */ + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0) || int32(nRowEst) == 0 { + nOrderBy = 0 + } else { + nOrderBy = (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr + } + /* Allocate and initialize space for aTo, aFrom and aSortCost[] */ + nSpace = libc.Int32FromUint64((uint64(32) + uint64(8)*libc.Uint64FromInt32(nLoop)) * libc.Uint64FromInt32(mxChoice) * uint64(2)) + nSpace = libc.Int32FromUint64(uint64(nSpace) + libc.Uint64FromInt64(2)*libc.Uint64FromInt32(nOrderBy)) + pSpace = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, libc.Uint64FromInt32(nSpace)) + if pSpace == uintptr(0) { + return int32(SQLITE_NOMEM) + } + aTo = pSpace + aFrom = aTo + uintptr(mxChoice)*32 + libc.X__builtin___memset_chk(tls, aFrom, 0, uint64(32), ^t__predefined_size_t(0)) + pX = aFrom + uintptr(mxChoice)*32 + ii = mxChoice * int32(2) + pFrom = aTo + for { + if !(ii > 0) { + break + } + (*TWherePath)(unsafe.Pointer(pFrom)).FaLoop = pX + goto _1 + _1: + ; + ii = ii - 1 + pFrom += 32 + pX = pX + uintptr(nLoop)*8 + } + if nOrderBy != 0 { + /* If there is an ORDER BY clause and it is not being ignored, set up + ** space for the aSortCost[] array. Each element of the aSortCost array + ** is either zero - meaning it has not yet been initialized - or the + ** cost of sorting nRowEst rows of data where the first X terms of + ** the ORDER BY clause are already in order, where X is the array + ** index. */ + aSortCost = pX + libc.X__builtin___memset_chk(tls, aSortCost, 0, uint64(2)*libc.Uint64FromInt32(nOrderBy), ^t__predefined_size_t(0)) + } + /* Seed the search with a single WherePath containing zero WhereLoops. + ** + ** TUNING: Do not let the number of iterations go above 28. If the cost + ** of computing an automatic index is not paid back within the first 28 + ** rows, then do not use the automatic index. */ + if int32((*TParse)(unsafe.Pointer(pParse)).FnQueryLoop) < int32(48) { + v2 = int32((*TParse)(unsafe.Pointer(pParse)).FnQueryLoop) + } else { + v2 = int32(48) + } + (**(**TWherePath)(__ccgo_up(aFrom))).FnRow = int16(v2) + nFrom = int32(1) + if nOrderBy != 0 { + /* If nLoop is zero, then there are no FROM terms in the query. Since + ** in this case the query may return a maximum of one row, the results + ** are already in the requested order. Set isOrdered to nOrderBy to + ** indicate this. Or, if nLoop is greater than zero, set isOrdered to + ** -1, indicating that the result set may or may not be ordered, + ** depending on the loops added to the current plan. */ + if nLoop > 0 { + v2 = -int32(1) + } else { + v2 = nOrderBy + } + (**(**TWherePath)(__ccgo_up(aFrom))).FisOrdered = int8(v2) + } + /* Compute successively longer WherePaths using the previous generation + ** of WherePaths as the basis for the next. Keep track of the mxChoice + ** best paths at each generation */ + iLoop = 0 + for { + if !(iLoop < nLoop) { + break + } + nTo = 0 + ii = 0 + pFrom = aFrom + for { + if !(ii < nFrom) { + break + } + pWLoop = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops + for { + if !(pWLoop != 0) { + break + } /* Mask of rev-order loops for (..) */ + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).Fprereq & ^(*TWherePath)(unsafe.Pointer(pFrom)).FmaskLoop != uint64(0) { + goto _6 + } + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf&(*TWherePath)(unsafe.Pointer(pFrom)).FmaskLoop != uint64(0) { + goto _6 + } + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).FwsFlags&uint32(WHERE_AUTO_INDEX) != uint32(0) && int32((*TWherePath)(unsafe.Pointer(pFrom)).FnRow) < int32(3) { + /* Do not use an automatic index if the this loop is expected + ** to run less than 1.25 times. It is tempting to also exclude + ** automatic index usage on an outer loop, but sometimes an automatic + ** index is useful in the outer loop of a correlated subquery. */ + goto _6 + } + /* At this point, pWLoop is a candidate to be the next loop. + ** Compute its cost */ + rUnsort = int16(int32((*TWhereLoop)(unsafe.Pointer(pWLoop)).FrRun) + int32((*TWherePath)(unsafe.Pointer(pFrom)).FnRow)) + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).FrSetup != 0 { + rUnsort = _sqlite3LogEstAdd(tls, (*TWhereLoop)(unsafe.Pointer(pWLoop)).FrSetup, rUnsort) + } + rUnsort = _sqlite3LogEstAdd(tls, rUnsort, (*TWherePath)(unsafe.Pointer(pFrom)).FrUnsort) + nOut = int16(int32((*TWherePath)(unsafe.Pointer(pFrom)).FnRow) + int32((*TWhereLoop)(unsafe.Pointer(pWLoop)).FnOut)) + maskNew = (*TWherePath)(unsafe.Pointer(pFrom)).FmaskLoop | (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf + isOrdered = (*TWherePath)(unsafe.Pointer(pFrom)).FisOrdered + if int32(isOrdered) < 0 { + **(**TBitmask)(__ccgo_up(bp)) = uint64(0) + isOrdered = _wherePathSatisfiesOrderBy(tls, pWInfo, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags, libc.Uint16FromInt32(iLoop), pWLoop, bp) + } else { + **(**TBitmask)(__ccgo_up(bp)) = (*TWherePath)(unsafe.Pointer(pFrom)).FrevLoop + } + if int32(isOrdered) >= 0 && int32(isOrdered) < nOrderBy { + if int32(**(**TLogEst)(__ccgo_up(aSortCost + uintptr(isOrdered)*2))) == 0 { + **(**TLogEst)(__ccgo_up(aSortCost + uintptr(isOrdered)*2)) = _whereSortingCost(tls, pWInfo, nRowEst, nOrderBy, int32(isOrdered)) + } + /* TUNING: Add a small extra penalty (3) to sorting as an + ** extra encouragement to the query planner to select a plan + ** where the rows emerge in the correct order without any sorting + ** required. */ + rCost = int16(int32(_sqlite3LogEstAdd(tls, rUnsort, **(**TLogEst)(__ccgo_up(aSortCost + uintptr(isOrdered)*2)))) + int32(3)) + } else { + rCost = rUnsort + rUnsort = int16(int32(rUnsort) - libc.Int32FromInt32(2)) /* TUNING: Slight bias in favor of no-sort plans */ + } + /* Check to see if pWLoop should be added to the set of + ** mxChoice best-so-far paths. + ** + ** First look for an existing path among best-so-far paths + ** that: + ** (1) covers the same set of loops, and + ** (2) has a compatible isOrdered value. + ** + ** "Compatible isOrdered value" means either + ** (A) both have isOrdered==-1, or + ** (B) both have isOrder>=0, or + ** (C) ordering does not matter because this is the last round + ** of the solver. + ** + ** The term "((pTo->isOrdered^isOrdered)&0x80)==0" is equivalent + ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))" for the range + ** of legal values for isOrdered, -1..64. + */ + jj = 0 + pTo = aTo + for { + if !(jj < nTo) { + break + } + if (*TWherePath)(unsafe.Pointer(pTo)).FmaskLoop == maskNew && ((int32((*TWherePath)(unsafe.Pointer(pTo)).FisOrdered)^int32(isOrdered))&int32(0x80) == 0 || iLoop == nLoop-int32(1)) { + break + } + goto _7 + _7: + ; + jj = jj + 1 + pTo += 32 + } + if jj >= nTo { + /* None of the existing best-so-far paths match the candidate. */ + if nTo >= mxChoice && (int32(rCost) > int32(mxCost) || int32(rCost) == int32(mxCost) && int32(rUnsort) >= int32(mxUnsort)) { + /* The current candidate is no better than any of the mxChoice + ** paths currently in the best-so-far buffer. So discard + ** this candidate as not viable. */ + goto _6 + } + /* If we reach this points it means that the new candidate path + ** needs to be added to the set of best-so-far paths. */ + if nTo < mxChoice { + /* Increase the size of the aTo set by one */ + v2 = nTo + nTo = nTo + 1 + jj = v2 + } else { + /* New path replaces the prior worst to keep count below mxChoice */ + jj = mxI + } + pTo = aTo + uintptr(jj)*32 + } else { + /* Control reaches here if best-so-far path pTo=aTo[jj] covers the + ** same set of loops and has the same isOrdered setting as the + ** candidate path. Check to see if the candidate should replace + ** pTo or if the candidate should be skipped. + ** + ** The conditional is an expanded vector comparison equivalent to: + ** (pTo->rCost,pTo->nRow,pTo->rUnsort) <= (rCost,nOut,rUnsort) + */ + if int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) < int32(rCost) || int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) == int32(rCost) && int32((*TWherePath)(unsafe.Pointer(pTo)).FnRow) < int32(nOut) || int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) == int32(rCost) && int32((*TWherePath)(unsafe.Pointer(pTo)).FnRow) == int32(nOut) && int32((*TWherePath)(unsafe.Pointer(pTo)).FrUnsort) < int32(rUnsort) || int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) == int32(rCost) && int32((*TWherePath)(unsafe.Pointer(pTo)).FnRow) == int32(nOut) && int32((*TWherePath)(unsafe.Pointer(pTo)).FrUnsort) == int32(rUnsort) && _whereLoopIsNoBetter(tls, pWLoop, **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pTo)).FaLoop + uintptr(iLoop)*8))) != 0 { + /* Discard the candidate path from further consideration */ + goto _6 + } + /* Control reaches here if the candidate path is better than the + ** pTo path. Replace pTo with the candidate. */ + } + /* pWLoop is a winner. Add it to the set of best so far */ + (*TWherePath)(unsafe.Pointer(pTo)).FmaskLoop = (*TWherePath)(unsafe.Pointer(pFrom)).FmaskLoop | (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf + (*TWherePath)(unsafe.Pointer(pTo)).FrevLoop = **(**TBitmask)(__ccgo_up(bp)) + (*TWherePath)(unsafe.Pointer(pTo)).FnRow = nOut + (*TWherePath)(unsafe.Pointer(pTo)).FrCost = rCost + (*TWherePath)(unsafe.Pointer(pTo)).FrUnsort = rUnsort + (*TWherePath)(unsafe.Pointer(pTo)).FisOrdered = isOrdered + libc.X__builtin___memcpy_chk(tls, (*TWherePath)(unsafe.Pointer(pTo)).FaLoop, (*TWherePath)(unsafe.Pointer(pFrom)).FaLoop, uint64(8)*libc.Uint64FromInt32(iLoop), ^t__predefined_size_t(0)) + **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pTo)).FaLoop + uintptr(iLoop)*8)) = pWLoop + if nTo >= mxChoice { + mxI = 0 + mxCost = (**(**TWherePath)(__ccgo_up(aTo))).FrCost + mxUnsort = (**(**TWherePath)(__ccgo_up(aTo))).FnRow + jj = int32(1) + pTo = aTo + 1*32 + for { + if !(jj < mxChoice) { + break + } + if int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) > int32(mxCost) || int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) == int32(mxCost) && int32((*TWherePath)(unsafe.Pointer(pTo)).FrUnsort) > int32(mxUnsort) { + mxCost = (*TWherePath)(unsafe.Pointer(pTo)).FrCost + mxUnsort = (*TWherePath)(unsafe.Pointer(pTo)).FrUnsort + mxI = jj + } + goto _9 + _9: + ; + jj = jj + 1 + pTo += 32 + } + } + goto _6 + _6: + ; + pWLoop = (*TWhereLoop)(unsafe.Pointer(pWLoop)).FpNextLoop + } + goto _5 + _5: + ; + ii = ii + 1 + pFrom += 32 + } + /* Swap the roles of aFrom and aTo for the next generation */ + pFrom = aTo + aTo = aFrom + aFrom = pFrom + nFrom = nTo + goto _4 + _4: + ; + iLoop = iLoop + 1 + } + if nFrom == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24408, 0) + _sqlite3DbFreeNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSpace) + return int32(SQLITE_ERROR) + } + /* Only one path is available, which is the best path */ + pFrom = aFrom + /* Load the lowest cost path into pWInfo */ + iLoop = 0 + for { + if !(iLoop < nLoop) { + break + } + pLevel = pWInfo + 856 + uintptr(iLoop)*112 + v11 = **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(iLoop)*8)) + pWLoop = v11 + (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop = v11 + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom = (*TWhereLoop)(unsafe.Pointer(pWLoop)).FiTab + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur = (*(*TSrcItem)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80))).FiCursor + goto _10 + _10: + ; + iLoop = iLoop + 1 + } + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DISTINCTBY) == 0 && libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == WHERE_DISTINCT_NOOP && nRowEst != 0 { + rc = int32(_wherePathSatisfiesOrderBy(tls, pWInfo, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet, pFrom, uint16(WHERE_DISTINCTBY), libc.Uint16FromInt32(nLoop-int32(1)), **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-int32(1))*8)), bp+8)) + if rc == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet)).FnExpr { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_ORDERED) + } + } + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(0), 2, 0x4) + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = (*TWherePath)(unsafe.Pointer(pFrom)).FisOrdered + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DISTINCTBY) != 0 { + if int32((*TWherePath)(unsafe.Pointer(pFrom)).FisOrdered) == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_ORDERED) + } + /* vvv--- See check-in [12ad822d9b827777] on 2023-03-16 ---vvv */ + } else { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = (*TWherePath)(unsafe.Pointer(pFrom)).FrevLoop + if int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) <= 0 { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = 0 + if nLoop > 0 { + wsFlags = (*TWhereLoop)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-int32(1))*8)))).FwsFlags + if wsFlags&uint32(WHERE_ONEROW) == uint32(0) && wsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_COLUMN_IN)) != libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_COLUMN_IN)) { + **(**TBitmask)(__ccgo_up(bp + 16)) = uint64(0) + rc1 = int32(_wherePathSatisfiesOrderBy(tls, pWInfo, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, uint16(WHERE_ORDERBY_LIMIT), libc.Uint16FromInt32(nLoop-int32(1)), **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-int32(1))*8)), bp+16)) + if rc1 == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 2, 0x4) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = **(**TBitmask)(__ccgo_up(bp + 16)) + } + } + } + } else { + if nLoop != 0 && int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == int32(1) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(libc.Int32FromInt32(WHERE_ORDERBY_MIN)|libc.Int32FromInt32(WHERE_ORDERBY_MAX)) != 0 { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 2, 0x4) + } + } + } + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_SORTBYGROUP) != 0 && int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr && nLoop > 0 { + **(**TBitmask)(__ccgo_up(bp + 24)) = uint64(0) + nOrder = int32(_wherePathSatisfiesOrderBy(tls, pWInfo, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, uint16(0), libc.Uint16FromInt32(nLoop-int32(1)), **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-int32(1))*8)), bp+24)) + if nOrder == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 3, 0x8) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = **(**TBitmask)(__ccgo_up(bp + 24)) + } + } + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut = (*TWherePath)(unsafe.Pointer(pFrom)).FnRow + /* Free temporary memory and return success */ + _sqlite3DbFreeNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSpace) + return SQLITE_OK +} + +func _windowFind(tls *libc.TLS, pParse uintptr, pList uintptr, zName uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p uintptr + _ = p + p = pList + for { + if !(p != 0) { + break + } + if _sqlite3StrICmp(tls, (*TWindow)(unsafe.Pointer(p)).FzName, zName) == 0 { + break + } + goto _1 + _1: + ; + p = (*TWindow)(unsafe.Pointer(p)).FpNextWin + } + if p == uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24602, libc.VaList(bp+8, zName)) + } + return p +} + +// C documentation +// +// /* +// ** Remove any Window objects owned by the expression pExpr from the +// ** Select.pWin list of Select object pSelect. +// */ +func _windowRemoveExprFromSelect(tls *libc.TLS, pSelect uintptr, pExpr uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* sWalker at bp+0 */ TWalker + if (*TSelect)(unsafe.Pointer(pSelect)).FpWin != 0 { + libc.X__builtin___memset_chk(tls, bp, 0, uint64(48), ^t__predefined_size_t(0)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_resolveRemoveWindowsCb) + *(*uintptr)(unsafe.Pointer(bp + 40)) = pSelect + _sqlite3WalkExpr(tls, bp, pExpr) + } +} + +// C documentation +// +// /* +// ** The journal file must be open when this routine is called. A journal +// ** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the +// ** current location. +// ** +// ** The format for the journal header is as follows: +// ** - 8 bytes: Magic identifying journal format. +// ** - 4 bytes: Number of records in journal, or -1 no-sync mode is on. +// ** - 4 bytes: Random number used for page hash. +// ** - 4 bytes: Initial database page count. +// ** - 4 bytes: Sector size used by the process that wrote this journal. +// ** - 4 bytes: Database page size. +// ** +// ** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space. +// */ +func _writeJournalHdr(tls *libc.TLS, pPager uintptr) (r int32) { + var ii, rc int32 + var nHeader, nWrite Tu32 + var zHeader uintptr + var v2 Ti64 + _, _, _, _, _, _ = ii, nHeader, nWrite, rc, zHeader, v2 + rc = SQLITE_OK /* Return code */ + zHeader = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace /* Temporary space used to build header */ + nHeader = libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) /* Loop counter */ + /* Journal file must be open. */ + if nHeader > (*TPager)(unsafe.Pointer(pPager)).FsectorSize { + nHeader = (*TPager)(unsafe.Pointer(pPager)).FsectorSize + } + /* If there are active savepoints and any of them were created + ** since the most recent journal header was written, update the + ** PagerSavepoint.iHdrOffset fields now. + */ + ii = 0 + for { + if !(ii < (*TPager)(unsafe.Pointer(pPager)).FnSavepoint) { + break + } + if (**(**TPagerSavepoint)(__ccgo_up((*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*56))).FiHdrOffset == 0 { + (**(**TPagerSavepoint)(__ccgo_up((*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*56))).FiHdrOffset = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + } + goto _1 + _1: + ; + ii = ii + 1 + } + v2 = _journalHdrOffset(tls, pPager) + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = v2 + (*TPager)(unsafe.Pointer(pPager)).FjournalHdr = v2 + /* + ** Write the nRec Field - the number of page records that follow this + ** journal header. Normally, zero is written to this value at this time. + ** After the records are added to the journal (and the journal synced, + ** if in full-sync mode), the zero is overwritten with the true number + ** of records (see syncJournal()). + ** + ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When + ** reading the journal this value tells SQLite to assume that the + ** rest of the journal file contains valid page records. This assumption + ** is dangerous, as if a failure occurred whilst writing to the journal + ** file it may contain some garbage data. There are two scenarios + ** where this risk can be ignored: + ** + ** * When the pager is in no-sync mode. Corruption can follow a + ** power failure in this case anyway. + ** + ** * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees + ** that garbage data is never appended to the journal file. + */ + if (*TPager)(unsafe.Pointer(pPager)).FnoSync != 0 || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_MEMORY) || _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd)&int32(SQLITE_IOCAP_SAFE_APPEND) != 0 { + libc.X__builtin___memcpy_chk(tls, zHeader, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8), ^t__predefined_size_t(0)) + _sqlite3Put4byte(tls, zHeader+uintptr(8), uint32(0xffffffff)) + } else { + libc.X__builtin___memset_chk(tls, zHeader, 0, libc.Uint64FromInt64(8)+libc.Uint64FromInt32(4), ^t__predefined_size_t(0)) + } + /* The random check-hash initializer */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) != int32(PAGER_JOURNALMODE_MEMORY) { + Xsqlite3_randomness(tls, int32(4), pPager+56) + } + _sqlite3Put4byte(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(4)), (*TPager)(unsafe.Pointer(pPager)).FcksumInit) + /* The initial database size */ + _sqlite3Put4byte(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(8)), (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize) + /* The assumed sector size for this process */ + _sqlite3Put4byte(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(12)), (*TPager)(unsafe.Pointer(pPager)).FsectorSize) + /* The page size */ + _sqlite3Put4byte(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(16)), libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize)) + /* Initializing the tail of the buffer is not necessary. Everything + ** works find if the following memset() is omitted. But initializing + ** the memory prevents valgrind from complaining, so we are willing to + ** take the performance hit. + */ + libc.X__builtin___memset_chk(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(20)), 0, uint64(nHeader)-(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(20)), ^t__predefined_size_t(0)) + /* In theory, it is only necessary to write the 28 bytes that the + ** journal header consumes to the journal file here. Then increment the + ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next + ** record is written to the following sector (leaving a gap in the file + ** that will be implicitly filled in by the OS). + ** + ** However it has been discovered that on some systems this pattern can + ** be significantly slower than contiguously writing data to the file, + ** even if that means explicitly writing data to the block of + ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what + ** is done. + ** + ** The loop is required here in case the sector-size is larger than the + ** database page size. Since the zHeader buffer is only Pager.pageSize + ** bytes in size, more than one call to sqlite3OsWrite() may be required + ** to populate the entire journal header sector. + */ + nWrite = uint32(0) + for { + if !(rc == SQLITE_OK && nWrite < (*TPager)(unsafe.Pointer(pPager)).FsectorSize) { + break + } + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, zHeader, libc.Int32FromUint32(nHeader), (*TPager)(unsafe.Pointer(pPager)).FjournalOff) + **(**Ti64)(__ccgo_up(pPager + 96)) += libc.Int64FromUint32(nHeader) + goto _3 + _3: + ; + nWrite = nWrite + nHeader + } + return rc +} + +// C documentation +// +// /* +// ** Try to increase the size of the parser stack. Return the number +// ** of errors. Return 0 on success. +// */ +func _yyGrowStack(tls *libc.TLS, p uintptr) (r int32) { + var idx, nLimit, newSize, oldSize int32 + var pNew uintptr + _, _, _, _, _ = idx, nLimit, newSize, oldSize, pNew + oldSize = int32(1) + int32((int64((*TyyParser)(unsafe.Pointer(p)).FyystackEnd)-int64((*TyyParser)(unsafe.Pointer(p)).Fyystack))/24) + nLimit = _parserStackSizeLimit(tls, (*TyyParser)(unsafe.Pointer(p)).FpParse) + newSize = oldSize*int32(2) + int32(100) + if newSize > nLimit { + newSize = nLimit + if newSize <= oldSize { + return int32(1) + } + } + idx = int32((int64((*TyyParser)(unsafe.Pointer(p)).Fyytos) - int64((*TyyParser)(unsafe.Pointer(p)).Fyystack)) / 24) + if (*TyyParser)(unsafe.Pointer(p)).Fyystack == p+32 { + pNew = _parserStackRealloc(tls, uintptr(0), uint64(libc.Uint64FromInt32(newSize)*uint64(24)), (*TyyParser)(unsafe.Pointer(p)).FpParse) + if pNew == uintptr(0) { + return int32(1) + } + libc.X__builtin___memcpy_chk(tls, pNew, (*TyyParser)(unsafe.Pointer(p)).Fyystack, libc.Uint64FromInt32(oldSize)*uint64(24), ^t__predefined_size_t(0)) + } else { + pNew = _parserStackRealloc(tls, (*TyyParser)(unsafe.Pointer(p)).Fyystack, uint64(libc.Uint64FromInt32(newSize)*uint64(24)), (*TyyParser)(unsafe.Pointer(p)).FpParse) + if pNew == uintptr(0) { + return int32(1) + } + } + (*TyyParser)(unsafe.Pointer(p)).Fyystack = pNew + (*TyyParser)(unsafe.Pointer(p)).Fyytos = (*TyyParser)(unsafe.Pointer(p)).Fyystack + uintptr(idx)*24 + (*TyyParser)(unsafe.Pointer(p)).FyystackEnd = (*TyyParser)(unsafe.Pointer(p)).Fyystack + uintptr(newSize-int32(1))*24 + return 0 +} + +/* Datatype of the argument to the memory allocated passed as the +** second argument to sqlite3ParserAlloc() below. This can be changed by +** putting an appropriate #define in the %include section of the input +** grammar. + */ + +// C documentation +// +// /* +// ** The following routine is called if the stack overflows. +// */ +func _yyStackOverflow(tls *libc.TLS, yypParser uintptr) { + var pParse uintptr + _ = pParse + pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse + for (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos > (*TyyParser)(unsafe.Pointer(yypParser)).Fyystack { + _yy_pop_parser_stack(tls, yypParser) + } + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + /******** Begin %stack_overflow code ******************************************/ + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25305, 0) + } + /******** End %stack_overflow code ********************************************/ + /* Suppress warning about unused %extra_argument var */ + (*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse +} + +/* +** Print tracing information for a SHIFT action + */ + +// C documentation +// +// /* +// ** Perform a reduce action and the shift that must immediately +// ** follow the reduce. +// ** +// ** The yyLookahead and yyLookaheadToken parameters provide reduce actions +// ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE +// ** if the lookahead token has already been consumed. As this procedure is +// ** only called from one place, optimizing compilers will in-line it, which +// ** means that the extra parameters have no performance impact. +// */ +func _yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead int32, yyLookaheadToken TToken, pParse uintptr) (r uint16) { + bp := tls.Alloc(160) + defer tls.Free(160) + var bNot, bNot1, i, nExpr, yygoto, yysize, v353 int32 + var n Tu32 + var op Tu8 + var p, p1, p2, p3, p4, p5, pB, pDot, pFrom, pFromClause, pLeft, pLhs, pList, pList1, pList2, pList3, pList4, pNew, pOld, pRHS, pRhs, pRight, pSelect, pSelectRHS, pSrc, pSubquery, pSubquery1, temp1, temp11, temp2, temp21, temp3, temp4, yymsp, v352 uintptr + var yyact uint16 + var v357 TToken + var _ /* all at bp+112 */ TToken + var _ /* as at bp+72 */ TToken + var _ /* dest at bp+16 */ TSelectDest + var _ /* iValue at bp+88 */ int32 + var _ /* t at bp+96 */ TToken + var _ /* x at bp+56 */ TToken + var _ /* yylhsminor at bp+0 */ TYYMINORTYPE + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNot, bNot1, i, n, nExpr, op, p, p1, p2, p3, p4, p5, pB, pDot, pFrom, pFromClause, pLeft, pLhs, pList, pList1, pList2, pList3, pList4, pNew, pOld, pRHS, pRhs, pRight, pSelect, pSelectRHS, pSrc, pSubquery, pSubquery1, temp1, temp11, temp2, temp21, temp3, temp4, yyact, yygoto, yymsp, yysize, v352, v353, v357 /* Amount to pop the stack */ + _ = yyLookahead + _ = yyLookaheadToken + yymsp = (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos + switch yyruleno { + case uint32(0): + goto _1 + case uint32(1): + goto _2 + case uint32(2): + goto _3 + case uint32(3): + goto _4 + case uint32(4): + goto _5 + case uint32(6): + goto _6 + case uint32(5): + goto _7 + case uint32(7): + goto _8 + case uint32(328): + goto _9 + case uint32(9): + goto _10 + case uint32(8): + goto _11 + case uint32(10): + goto _12 + case uint32(11): + goto _13 + case uint32(12): + goto _14 + case uint32(13): + goto _15 + case uint32(14): + goto _16 + case uint32(18): + goto _17 + case uint32(15): + goto _18 + case uint32(47): + goto _19 + case uint32(62): + goto _20 + case uint32(72): + goto _21 + case uint32(81): + goto _22 + case uint32(100): + goto _23 + case uint32(246): + goto _24 + case uint32(16): + goto _25 + case uint32(17): + goto _26 + case uint32(19): + goto _27 + case uint32(20): + goto _28 + case uint32(21): + goto _29 + case uint32(22): + goto _30 + case uint32(23): + goto _31 + case uint32(24): + goto _32 + case uint32(25): + goto _33 + case uint32(65): + goto _34 + case uint32(26): + goto _35 + case uint32(106): + goto _36 + case uint32(27): + goto _37 + case uint32(28): + goto _38 + case uint32(29): + goto _39 + case uint32(30): + goto _40 + case uint32(31): + goto _41 + case uint32(67): + goto _42 + case uint32(32): + goto _43 + case uint32(33): + goto _44 + case uint32(34): + goto _45 + case uint32(35): + goto _46 + case uint32(36): + goto _47 + case uint32(37): + goto _48 + case uint32(38): + goto _49 + case uint32(39): + goto _50 + case uint32(40): + goto _51 + case uint32(41): + goto _52 + case uint32(42): + goto _53 + case uint32(43): + goto _54 + case uint32(44): + goto _55 + case uint32(45): + goto _56 + case uint32(46): + goto _57 + case uint32(48): + goto _58 + case uint32(49): + goto _59 + case uint32(50): + goto _60 + case uint32(51): + goto _61 + case uint32(52): + goto _62 + case uint32(53): + goto _63 + case uint32(54): + goto _64 + case uint32(55): + goto _65 + case uint32(56): + goto _66 + case uint32(57): + goto _67 + case uint32(58): + goto _68 + case uint32(59): + goto _69 + case uint32(60): + goto _70 + case uint32(76): + goto _71 + case uint32(61): + goto _72 + case uint32(173): + goto _73 + case uint32(80): + goto _74 + case uint32(63): + goto _75 + case uint32(219): + goto _76 + case uint32(222): + goto _77 + case uint32(247): + goto _78 + case uint32(64): + goto _79 + case uint32(66): + goto _80 + case uint32(68): + goto _81 + case uint32(69): + goto _82 + case uint32(70): + goto _83 + case uint32(71): + goto _84 + case uint32(75): + goto _85 + case uint32(73): + goto _86 + case uint32(74): + goto _87 + case uint32(77): + goto _88 + case uint32(174): + goto _89 + case uint32(78): + goto _90 + case uint32(79): + goto _91 + case uint32(82): + goto _92 + case uint32(83): + goto _93 + case uint32(84): + goto _94 + case uint32(85): + goto _95 + case uint32(86): + goto _96 + case uint32(87): + goto _97 + case uint32(88): + goto _98 + case uint32(91): + goto _99 + case uint32(89): + goto _100 + case uint32(90): + goto _101 + case uint32(92): + goto _102 + case uint32(93): + goto _103 + case uint32(94): + goto _104 + case uint32(95): + goto _105 + case uint32(97): + goto _106 + case uint32(96): + goto _107 + case uint32(98): + goto _108 + case uint32(99): + goto _109 + case uint32(134): + goto _110 + case uint32(101): + goto _111 + case uint32(144): + goto _112 + case uint32(234): + goto _113 + case uint32(237): + goto _114 + case uint32(242): + goto _115 + case uint32(102): + goto _116 + case uint32(103): + goto _117 + case uint32(104): + goto _118 + case uint32(117): + goto _119 + case uint32(105): + goto _120 + case uint32(258): + goto _121 + case uint32(259): + goto _122 + case uint32(110): + goto _123 + case uint32(107): + goto _124 + case uint32(108): + goto _125 + case uint32(109): + goto _126 + case uint32(111): + goto _127 + case uint32(112): + goto _128 + case uint32(113): + goto _129 + case uint32(114): + goto _130 + case uint32(115): + goto _131 + case uint32(131): + goto _132 + case uint32(116): + goto _133 + case uint32(120): + goto _134 + case uint32(118): + goto _135 + case uint32(121): + goto _136 + case uint32(119): + goto _137 + case uint32(122): + goto _138 + case uint32(123): + goto _139 + case uint32(124): + goto _140 + case uint32(125): + goto _141 + case uint32(126): + goto _142 + case uint32(127): + goto _143 + case uint32(128): + goto _144 + case uint32(129): + goto _145 + case uint32(130): + goto _146 + case uint32(132): + goto _147 + case uint32(133): + goto _148 + case uint32(145): + goto _149 + case uint32(135): + goto _150 + case uint32(136): + goto _151 + case uint32(137): + goto _152 + case uint32(138): + goto _153 + case uint32(139): + goto _154 + case uint32(143): + goto _155 + case uint32(140): + goto _156 + case uint32(141): + goto _157 + case uint32(142): + goto _158 + case uint32(148): + goto _159 + case uint32(146): + goto _160 + case uint32(153): + goto _161 + case uint32(155): + goto _162 + case uint32(232): + goto _163 + case uint32(233): + goto _164 + case uint32(252): + goto _165 + case uint32(154): + goto _166 + case uint32(147): + goto _167 + case uint32(156): + goto _168 + case uint32(231): + goto _169 + case uint32(251): + goto _170 + case uint32(149): + goto _171 + case uint32(150): + goto _172 + case uint32(151): + goto _173 + case uint32(152): + goto _174 + case uint32(157): + goto _175 + case uint32(158): + goto _176 + case uint32(159): + goto _177 + case uint32(160): + goto _178 + case uint32(161): + goto _179 + case uint32(162): + goto _180 + case uint32(163): + goto _181 + case uint32(164): + goto _182 + case uint32(165): + goto _183 + case uint32(166): + goto _184 + case uint32(167): + goto _185 + case uint32(168): + goto _186 + case uint32(169): + goto _187 + case uint32(170): + goto _188 + case uint32(171): + goto _189 + case uint32(172): + goto _190 + case uint32(175): + goto _191 + case uint32(176): + goto _192 + case uint32(177): + goto _193 + case uint32(178): + goto _194 + case uint32(179): + goto _195 + case uint32(180): + goto _196 + case uint32(181): + goto _197 + case uint32(182): + goto _198 + case uint32(184): + goto _199 + case uint32(183): + goto _200 + case uint32(185): + goto _201 + case uint32(186): + goto _202 + case uint32(187): + goto _203 + case uint32(188): + goto _204 + case uint32(189): + goto _205 + case uint32(190): + goto _206 + case uint32(191): + goto _207 + case uint32(192): + goto _208 + case uint32(193): + goto _209 + case uint32(194): + goto _210 + case uint32(195): + goto _211 + case uint32(196): + goto _212 + case uint32(197): + goto _213 + case uint32(199): + goto _214 + case uint32(198): + goto _215 + case uint32(200): + goto _216 + case uint32(201): + goto _217 + case uint32(202): + goto _218 + case uint32(203): + goto _219 + case uint32(204): + goto _220 + case uint32(205): + goto _221 + case uint32(206): + goto _222 + case uint32(207): + goto _223 + case uint32(208): + goto _224 + case uint32(209): + goto _225 + case uint32(210): + goto _226 + case uint32(211): + goto _227 + case uint32(212): + goto _228 + case uint32(213): + goto _229 + case uint32(215): + goto _230 + case uint32(214): + goto _231 + case uint32(216): + goto _232 + case uint32(217): + goto _233 + case uint32(221): + goto _234 + case uint32(218): + goto _235 + case uint32(220): + goto _236 + case uint32(223): + goto _237 + case uint32(224): + goto _238 + case uint32(225): + goto _239 + case uint32(226): + goto _240 + case uint32(227): + goto _241 + case uint32(228): + goto _242 + case uint32(229): + goto _243 + case uint32(230): + goto _244 + case uint32(235): + goto _245 + case uint32(236): + goto _246 + case uint32(243): + goto _247 + case uint32(238): + goto _248 + case uint32(239): + goto _249 + case uint32(281): + goto _250 + case uint32(240): + goto _251 + case uint32(241): + goto _252 + case uint32(244): + goto _253 + case uint32(245): + goto _254 + case uint32(248): + goto _255 + case uint32(249): + goto _256 + case uint32(250): + goto _257 + case uint32(253): + goto _258 + case uint32(254): + goto _259 + case uint32(255): + goto _260 + case uint32(256): + goto _261 + case uint32(257): + goto _262 + case uint32(260): + goto _263 + case uint32(261): + goto _264 + case uint32(262): + goto _265 + case uint32(263): + goto _266 + case uint32(264): + goto _267 + case uint32(266): + goto _268 + case uint32(265): + goto _269 + case uint32(267): + goto _270 + case uint32(286): + goto _271 + case uint32(268): + goto _272 + case uint32(287): + goto _273 + case uint32(269): + goto _274 + case uint32(270): + goto _275 + case uint32(271): + goto _276 + case uint32(272): + goto _277 + case uint32(273): + goto _278 + case uint32(274): + goto _279 + case uint32(275): + goto _280 + case uint32(276): + goto _281 + case uint32(277): + goto _282 + case uint32(278): + goto _283 + case uint32(279): + goto _284 + case uint32(280): + goto _285 + case uint32(282): + goto _286 + case uint32(283): + goto _287 + case uint32(284): + goto _288 + case uint32(285): + goto _289 + case uint32(288): + goto _290 + case uint32(289): + goto _291 + case uint32(290): + goto _292 + case uint32(291): + goto _293 + case uint32(292): + goto _294 + case uint32(293): + goto _295 + case uint32(294): + goto _296 + case uint32(295): + goto _297 + case uint32(296): + goto _298 + case uint32(297): + goto _299 + case uint32(298): + goto _300 + case uint32(299): + goto _301 + case uint32(300): + goto _302 + case uint32(301): + goto _303 + case uint32(302): + goto _304 + case uint32(303): + goto _305 + case uint32(304): + goto _306 + case uint32(305): + goto _307 + case uint32(307): + goto _308 + case uint32(306): + goto _309 + case uint32(308): + goto _310 + case uint32(310): + goto _311 + case uint32(309): + goto _312 + case uint32(311): + goto _313 + case uint32(312): + goto _314 + case uint32(313): + goto _315 + case uint32(314): + goto _316 + case uint32(315): + goto _317 + case uint32(316): + goto _318 + case uint32(317): + goto _319 + case uint32(318): + goto _320 + case uint32(319): + goto _321 + case uint32(320): + goto _322 + case uint32(321): + goto _323 + case uint32(322): + goto _324 + case uint32(323): + goto _325 + case uint32(324): + goto _326 + case uint32(325): + goto _327 + case uint32(326): + goto _328 + case uint32(327): + goto _329 + case uint32(331): + goto _330 + case uint32(329): + goto _331 + case uint32(332): + goto _332 + case uint32(330): + goto _333 + case uint32(334): + goto _334 + case uint32(333): + goto _335 + case uint32(335): + goto _336 + case uint32(336): + goto _337 + case uint32(338): + goto _338 + case uint32(337): + goto _339 + case uint32(339): + goto _340 + case uint32(340): + goto _341 + case uint32(341): + goto _342 + case uint32(342): + goto _343 + case uint32(343): + goto _344 + case uint32(344): + goto _345 + case uint32(345): + goto _346 + case uint32(346): + goto _347 + case uint32(347): + goto _348 + default: + goto _349 + } + goto _350 +_1: + ; /* explain ::= EXPLAIN */ + if (*TParse)(unsafe.Pointer(pParse)).FpReprepare == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Fexplain = uint8(1) + } + goto _350 +_2: + ; /* explain ::= EXPLAIN QUERY PLAN */ + if (*TParse)(unsafe.Pointer(pParse)).FpReprepare == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Fexplain = uint8(2) + } + goto _350 +_3: + ; /* cmdx ::= cmd */ + _sqlite3FinishCoding(tls, pParse) + goto _350 +_4: + ; /* cmd ::= BEGIN transtype trans_opt */ + _sqlite3BeginTransaction(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_5: + ; /* transtype ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(TK_DEFERRED) + goto _350 +_7: + ; /* transtype ::= DEFERRED */ +_6: + ; +_8: + ; +_9: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_11: + ; /* cmd ::= COMMIT|END trans_opt */ +_10: + ; + _sqlite3EndTransaction(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor)) + goto _350 +_12: + ; /* cmd ::= SAVEPOINT nm */ + _sqlite3Savepoint(tls, pParse, SAVEPOINT_BEGIN, yymsp+8) + goto _350 +_13: + ; /* cmd ::= RELEASE savepoint_opt nm */ + _sqlite3Savepoint(tls, pParse, int32(SAVEPOINT_RELEASE), yymsp+8) + goto _350 +_14: + ; /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ + _sqlite3Savepoint(tls, pParse, int32(SAVEPOINT_ROLLBACK), yymsp+8) + goto _350 +_15: + ; /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ + _sqlite3StartTable(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_16: + ; /* createkw ::= CREATE */ + _disableLookaside(tls, pParse) + goto _350 +_18: + ; /* ifnotexists ::= */ +_17: + ; +_19: + ; +_20: + ; +_21: + ; +_22: + ; +_23: + ; +_24: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = 0 + goto _350 +_25: + ; /* ifnotexists ::= IF NOT EXISTS */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = int32(1) + goto _350 +_26: + ; /* temp ::= TEMP */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.BoolInt32(libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0) + goto _350 +_27: + ; /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */ + _sqlite3EndTable(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*Tu32)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + goto _350 +_28: + ; /* create_table_args ::= AS select */ + _sqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint32(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_29: + ; /* table_option_set ::= */ + *(*Tu32)(unsafe.Pointer(yymsp + 1*24 + 8)) = uint32(0) + goto _350 +_30: + ; /* table_option_set ::= table_option_set COMMA table_option */ + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) | *(*Tu32)(unsafe.Pointer(yymsp + 8)) + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_31: + ; /* table_option ::= WITHOUT nm */ + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) == uint32(5) && Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), __ccgo_ts+18310, int32(5)) == 0 { + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid) | libc.Int32FromInt32(TF_NoVisibleRowid)) + } else { + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint32(0) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25321, libc.VaList(bp+136, *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)))) + } + goto _350 +_32: + ; /* table_option ::= nm */ + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) == uint32(6) && Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), __ccgo_ts+18246, int32(6)) == 0 { + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = uint32(TF_Strict) + } else { + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = uint32(0) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25321, libc.VaList(bp+136, *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)))) + } + *(*Tu32)(unsafe.Pointer(yymsp + 8)) = *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_33: + ; /* columnname ::= nm typetoken */ + _sqlite3AddColumn(tls, pParse, *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*TToken)(unsafe.Pointer(yymsp + 8))) + goto _350 +_35: + ; /* typetoken ::= */ +_34: + ; +_36: + ; + *(*uint32)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uint32(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_37: + ; /* typetoken ::= typename LP signed RP */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t(*(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) - int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))))) + goto _350 +_38: + ; /* typetoken ::= typename LP signed COMMA signed RP */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t(*(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) - int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))))) + goto _350 +_39: + ; /* typename ::= typename ID|STRING */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + libc.Uint32FromInt32(int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))))) + goto _350 +_40: + ; /* scanpt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = yyLookaheadToken.Fz + goto _350 +_41: + ; /* scantok ::= */ + *(*TToken)(unsafe.Pointer(yymsp + 1*24 + 8)) = yyLookaheadToken + goto _350 +_43: + ; /* ccons ::= CONSTRAINT nm */ +_42: + ; + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_44: + ; /* ccons ::= DEFAULT scantok term */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_45: + ; /* ccons ::= DEFAULT LP expr RP */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))+uintptr(1), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_46: + ; /* ccons ::= DEFAULT PLUS scantok term */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_47: + ; /* ccons ::= DEFAULT MINUS scantok term */ + p = _sqlite3PExpr(tls, pParse, int32(TK_UMINUS), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + _sqlite3AddDefaultValue(tls, pParse, p, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_48: + ; /* ccons ::= DEFAULT scantok ID|INDEXED */ + p1 = _tokenExpr(tls, pParse, int32(TK_STRING), *(*TToken)(unsafe.Pointer(yymsp + 8))) + if p1 != 0 { + _sqlite3ExprIdToTrueFalse(tls, p1) + } + _sqlite3AddDefaultValue(tls, pParse, p1, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) + goto _350 +_49: + ; /* ccons ::= NOT NULL onconf */ + _sqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_50: + ; /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ + _sqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_51: + ; /* ccons ::= UNIQUE onconf */ + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_UNIQUE)) + goto _350 +_52: + ; /* ccons ::= CHECK LP expr RP */ + _sqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_53: + ; /* ccons ::= REFERENCES nm eidlist_opt refargs */ + _sqlite3CreateForeignKey(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_54: + ; /* ccons ::= defer_subclause */ + _sqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_55: + ; /* ccons ::= COLLATE ID|STRING */ + _sqlite3AddCollateType(tls, pParse, yymsp+8) + goto _350 +_56: + ; /* generated ::= LP expr RP */ + _sqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_57: + ; /* generated ::= LP expr RP ID */ + _sqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8) + goto _350 +_58: + ; /* autoinc ::= AUTOINCR */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(1) + goto _350 +_59: + ; /* refargs ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = libc.Int32FromInt32(OE_None) * libc.Int32FromInt32(0x0101) /* EV: R-19803-45884 */ + goto _350 +_60: + ; /* refargs ::= refargs refarg */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) & ^*(*int32)(unsafe.Pointer(yymsp + 8 + 4)) | *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_61: + ; /* refarg ::= MATCH nm */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = 0 + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 4)) = 0x000000 + goto _350 +_62: + ; /* refarg ::= ON INSERT refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = 0 + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = 0x000000 + goto _350 +_63: + ; /* refarg ::= ON DELETE refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = int32(0x0000ff) + goto _350 +_64: + ; /* refarg ::= ON UPDATE refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) << int32(8) + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = int32(0x00ff00) + goto _350 +_65: + ; /* refact ::= SET NULL */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(OE_SetNull) /* EV: R-33326-45252 */ + goto _350 +_66: + ; /* refact ::= SET DEFAULT */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(OE_SetDflt) /* EV: R-33326-45252 */ + goto _350 +_67: + ; /* refact ::= CASCADE */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Cascade) /* EV: R-33326-45252 */ + goto _350 +_68: + ; /* refact ::= RESTRICT */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Restrict) /* EV: R-33326-45252 */ + goto _350 +_69: + ; /* refact ::= NO ACTION */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = OE_None /* EV: R-33326-45252 */ + goto _350 +_70: + ; /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = 0 + goto _350 +_72: + ; /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ +_71: + ; +_73: + ; + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_75: + ; /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ +_74: + ; +_76: + ; +_77: + ; +_78: + ; + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(1) + goto _350 +_79: + ; /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = 0 + goto _350 +_80: + ; /* tconscomma ::= COMMA */ + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName.Fn = uint32(0) + goto _350 +_81: + ; /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ + _sqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), 0) + goto _350 +_82: + ; /* tcons ::= UNIQUE LP sortlist RP onconf */ + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_UNIQUE)) + goto _350 +_83: + ; /* tcons ::= CHECK LP expr RP onconf */ + _sqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_84: + ; /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ + _sqlite3CreateForeignKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + _sqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_86: + ; /* onconf ::= */ +_85: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(OE_Default) + goto _350 +_87: + ; /* onconf ::= ON CONFLICT resolvetype */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_88: + ; /* resolvetype ::= IGNORE */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Ignore) + goto _350 +_90: + ; /* resolvetype ::= REPLACE */ +_89: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Replace) + goto _350 +_91: + ; /* cmd ::= DROP TABLE ifexists fullname */ + _sqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), 0, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_92: + ; /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ + _sqlite3CreateView(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(8))*24+8, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))) + goto _350 +_93: + ; /* cmd ::= DROP VIEW ifexists fullname */ + _sqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), int32(1), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_94: + ; /* cmd ::= select */ + **(**TSelectDest)(__ccgo_up(bp + 16)) = TSelectDest{ + FeDest: uint8(SRT_Output), + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_EncodingFixed) != uint32(0) || _sqlite3ReadSchema(tls, pParse) == SQLITE_OK { + _sqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), bp+16) + } + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_95: + ; /* select ::= WITH wqlist selectnowith */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_96: + ; /* select ::= WITH RECURSIVE wqlist selectnowith */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_97: + ; /* select ::= selectnowith */ + p2 = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + if p2 != 0 { + _parserDoubleLinkSelect(tls, pParse, p2) + } + goto _350 +_98: + ; /* selectnowith ::= selectnowith multiselect_op oneselect */ + pRhs = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + pLhs = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + if pRhs != 0 && (*TSelect)(unsafe.Pointer(pRhs)).FpPrior != 0 { + (**(**TToken)(__ccgo_up(bp + 56))).Fn = uint32(0) + _parserDoubleLinkSelect(tls, pParse, pRhs) + pFrom = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+56, pRhs, uintptr(0)) + pRhs = _sqlite3SelectNew(tls, pParse, uintptr(0), pFrom, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + } + if pRhs != 0 { + (*TSelect)(unsafe.Pointer(pRhs)).Fop = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + (*TSelect)(unsafe.Pointer(pRhs)).FpPrior = pLhs + if pLhs != 0 { + **(**Tu32)(__ccgo_up(pLhs + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) + } + **(**Tu32)(__ccgo_up(pRhs + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != int32(TK_ALL) { + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 2, 0x4) + } + } else { + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pLhs) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = pRhs + goto _350 +_100: + ; /* multiselect_op ::= UNION */ +_99: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-OP*/ + goto _350 +_101: + ; /* multiselect_op ::= UNION ALL */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(TK_ALL) + goto _350 +_102: + ; /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_103: + ; /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)) != 0 { + (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)))).FpWinDefn = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + } else { + _sqlite3WindowListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + } + goto _350 +_104: + ; /* values ::= VALUES LP nexprlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values), uintptr(0)) + goto _350 +_105: + ; /* oneselect ::= mvalues */ + _sqlite3MultiValuesEnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_107: + ; /* mvalues ::= values COMMA LP nexprlist RP */ +_106: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3MultiValues(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_108: + ; /* distinct ::= DISTINCT */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SF_Distinct) + goto _350 +_109: + ; /* distinct ::= ALL */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SF_All) + goto _350 +_111: + ; /* sclp ::= */ +_110: + ; +_112: + ; +_113: + ; +_114: + ; +_115: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_116: + ; /* selcollist ::= sclp scanpt expr scanpt as */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) > uint32(0) { + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+8, int32(1)) + } + _sqlite3ExprListSetSpan(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_117: + ; /* selcollist ::= sclp scanpt STAR */ + p3 = _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_ASTERISK), uintptr(0)) + _sqlite3ExprSetErrorOffset(tls, p3, int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64((*TParse)(unsafe.Pointer(pParse)).FzTail))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), p3) + goto _350 +_118: + ; /* selcollist ::= sclp scanpt nm DOT STAR */ + pRight = _sqlite3PExpr(tls, pParse, int32(TK_ASTERISK), uintptr(0), uintptr(0)) + _sqlite3ExprSetErrorOffset(tls, pRight, int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64((*TParse)(unsafe.Pointer(pParse)).FzTail))) + pLeft = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pDot = _sqlite3PExpr(tls, pParse, int32(TK_DOT), pLeft, pRight) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pDot) + goto _350 +_120: + ; /* as ::= AS nm */ +_119: + ; +_121: + ; +_122: + ; + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_124: + ; /* from ::= */ +_123: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_125: + ; /* from ::= FROM seltablist */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + _sqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_126: + ; /* stl_prefix ::= seltablist joinop */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 && (*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnSrc > 0 { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8 + uintptr((*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnSrc-int32(1))*80))).Ffg.Fjointype = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + 8))) + } + goto _350 +_127: + ; /* seltablist ::= stl_prefix nm dbnm as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + goto _350 +_128: + ; /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, uintptr(0), yymsp+8) + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + goto _350 +_129: + ; /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + _sqlite3SrcListFuncArgs(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + goto _350 +_130: + ; /* seltablist ::= stl_prefix LP select RP as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_131: + ; /* seltablist ::= stl_prefix LP seltablist RP as on_using */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) == uintptr(0) && *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) == uint32(0) && *(*uintptr)(unsafe.Pointer(yymsp + 8)) == uintptr(0) && *(*uintptr)(unsafe.Pointer(yymsp + 8 + 8)) == uintptr(0) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + } else { + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != uintptr(0) && (*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))).FnSrc == int32(1) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) != 0 { + pNew = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) + 8 + uintptr((*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)))).FnSrc-int32(1))*80 + pOld = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + 8 + (*TSrcItem)(unsafe.Pointer(pNew)).FzName = (*TSrcItem)(unsafe.Pointer(pOld)).FzName + if int32(*(*uint32)(unsafe.Pointer(pOld + 24 + 4))&0x4>>2) != 0 { + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 2, 0x4) + *(*uintptr)(unsafe.Pointer(pNew + 72)) = *(*uintptr)(unsafe.Pointer(pOld + 72)) + *(*uintptr)(unsafe.Pointer(pOld + 72)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pOld+24+4, libc.Uint32FromInt32(0), 2, 0x4) + if (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 72)))).FpSelect)).FselFlags&uint32(SF_NestedFrom) != uint32(0) { + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 14, 0x4000) + } + } else { + *(*uintptr)(unsafe.Pointer(pNew + 72)) = *(*uintptr)(unsafe.Pointer(pOld + 72)) + *(*uintptr)(unsafe.Pointer(pOld + 72)) = uintptr(0) + } + if int32(*(*uint32)(unsafe.Pointer(pOld + 24 + 4))&0x8>>3) != 0 { + *(*uintptr)(unsafe.Pointer(pNew + 48)) = *(*uintptr)(unsafe.Pointer(pOld + 48)) + *(*uintptr)(unsafe.Pointer(pOld + 48)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pOld+24+4, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 3, 0x8) + } + (*TSrcItem)(unsafe.Pointer(pOld)).FzName = uintptr(0) + } + _sqlite3SrcListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + } else { + _sqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + pSubquery = _sqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, pSubquery, yymsp+8) + } + } + goto _350 +_133: + ; /* dbnm ::= */ +_132: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + *(*uint32)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uint32(0) + goto _350 +_135: + ; /* fullname ::= nm */ +_134: + ; + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+8, uintptr(0)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+8) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_137: + ; /* fullname ::= nm DOT nm */ +_136: + ; + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+8) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_138: + ; /* xfullname ::= nm AS nm */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, uintptr(0)) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + } else { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzAlias = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, yymsp+8) + } + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_139: + ; /* xfullname ::= nm DOT nm AS nm */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + } else { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzAlias = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, yymsp+8) + } + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_140: + ; /* joinop ::= COMMA|JOIN */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(JT_INNER) + goto _350 +_141: + ; /* joinop ::= JOIN_KW JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), uintptr(0)) /*X-overwrites-A*/ + goto _350 +_142: + ; /* joinop ::= JOIN_KW nm JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0)) /*X-overwrites-A*/ + goto _350 +_143: + ; /* joinop ::= JOIN_KW nm nm JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) /*X-overwrites-A*/ + goto _350 +_144: + ; /* on_using ::= ON expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = uintptr(0) + goto _350 +_145: + ; /* on_using ::= USING LP idlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_146: + ; /* on_using ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uintptr(0) + goto _350 +_147: + ; /* indexed_by ::= INDEXED BY nm */ + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_148: + ; /* indexed_by ::= NOT INDEXED */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = uint32(1) + goto _350 +_150: + ; /* orderby_opt ::= ORDER BY sortlist */ +_149: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_151: + ; /* sortlist ::= sortlist COMMA expr sortorder nulls */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + _sqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_152: + ; /* sortlist ::= expr sortorder nulls */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) /*A-overwrites-Y*/ + _sqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_153: + ; /* sortorder ::= ASC */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = SQLITE_SO_ASC + goto _350 +_154: + ; /* sortorder ::= DESC */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SQLITE_SO_DESC) + goto _350 +_156: + ; /* sortorder ::= */ +_155: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = -int32(1) + goto _350 +_157: + ; /* nulls ::= NULLS FIRST */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = SQLITE_SO_ASC + goto _350 +_158: + ; /* nulls ::= NULLS LAST */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(SQLITE_SO_DESC) + goto _350 +_160: + ; /* having_opt ::= */ +_159: + ; +_161: + ; +_162: + ; +_163: + ; +_164: + ; +_165: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_167: + ; /* having_opt ::= HAVING expr */ +_166: + ; +_168: + ; +_169: + ; +_170: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_171: + ; /* limit_opt ::= LIMIT expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + goto _350 +_172: + ; /* limit_opt ::= LIMIT expr OFFSET expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_173: + ; /* limit_opt ::= LIMIT expr COMMA expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_174: + ; /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + _sqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0)) + goto _350 +_175: + ; /* where_opt_ret ::= RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + goto _350 +_176: + ; /* where_opt_ret ::= WHERE expr RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + goto _350 +_177: + ; /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + _sqlite3ExprListCheckLength(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), __ccgo_ts+25348) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + pFromClause = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + if (*TSrcList)(unsafe.Pointer(pFromClause)).FnSrc > int32(1) { + pSubquery1 = _sqlite3SelectNew(tls, pParse, uintptr(0), pFromClause, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) + (**(**TToken)(__ccgo_up(bp + 72))).Fn = uint32(0) + (**(**TToken)(__ccgo_up(bp + 72))).Fz = uintptr(0) + pFromClause = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+72, pSubquery1, uintptr(0)) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), pFromClause) + } + _sqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0), uintptr(0), uintptr(0)) + goto _350 +_178: + ; /* setlist ::= setlist COMMA nm EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, int32(1)) + goto _350 +_179: + ; /* setlist ::= setlist COMMA LP idlist RP EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) = _sqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_180: + ; /* setlist ::= nm EQ expr */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, int32(1)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_181: + ; /* setlist ::= LP idlist RP EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_182: + ; /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ + _sqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_183: + ; /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ + _sqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0)) + goto _350 +_184: + ; /* upsert ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_185: + ; /* upsert ::= RETURNING selcollist */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_186: + ; /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(11))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_187: + ; /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_188: + ; /* upsert ::= ON CONFLICT DO NOTHING returning */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + goto _350 +_189: + ; /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_190: + ; /* returning ::= RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_191: + ; /* idlist_opt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_192: + ; /* idlist_opt ::= LP idlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_193: + ; /* idlist ::= idlist COMMA nm */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8) + goto _350 +_194: + ; /* idlist ::= nm */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3IdListAppend(tls, pParse, uintptr(0), yymsp+8) /*A-overwrites-Y*/ + goto _350 +_195: + ; /* expr ::= LP expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_196: + ; /* expr ::= ID|INDEXED|JOIN_KW */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_197: + ; /* expr ::= nm DOT nm */ + temp1 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + temp2 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp1, temp2) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_198: + ; /* expr ::= nm DOT nm DOT nm */ + temp11 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + temp21 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + temp3 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) + temp4 = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp21, temp3) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), temp11) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp11, temp4) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_200: + ; /* term ::= NULL|FLOAT|BLOB */ +_199: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*TToken)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_201: + ; /* term ::= INTEGER */ + if _sqlite3GetInt32(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), bp+88) == 0 { + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_INTEGER), yymsp+8, 0) + } else { + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprInt32(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, **(**int32)(__ccgo_up(bp + 88))) + } + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 52)) = int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8))) - int64((*TParse)(unsafe.Pointer(pParse)).FzTail)) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_202: + ; /* expr ::= VARIABLE */ + if !(int32(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + 8))))) == int32('#') && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + 8)) + 1)))])&int32(0x04) != 0) { + n = *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, int32(TK_VARIABLE), *(*TToken)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), n) + } else { + /* When doing a nested parse, one can include terms in an expression + ** that look like this: #1 #2 ... These terms refer to registers + ** in the virtual machine. #N is the N-th register. */ + **(**TToken)(__ccgo_up(bp + 96)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) /*A-overwrites-X*/ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _parserSyntaxError(tls, pParse, bp+96) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = uintptr(0) + } else { + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_REGISTER), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + _sqlite3GetInt32(tls, (**(**TToken)(__ccgo_up(bp + 96))).Fz+1, *(*uintptr)(unsafe.Pointer(yymsp + 8))+44) + } + } + } + goto _350 +_203: + ; /* expr ::= expr COLLATE ID|STRING */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8, int32(1)) + goto _350 +_204: + ; /* expr ::= CAST LP expr AS typetoken RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_CAST), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, int32(1)) + _sqlite3ExprAttachSubtrees(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0)) + goto _350 +_205: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_206: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))) + _sqlite3ExprAddFunctionOrderBy(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_207: + ; /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_208: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_209: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(8))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8))) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprAddFunctionOrderBy(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_210: + ; /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, 0) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_211: + ; /* term ::= CTIME_KW */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_212: + ; /* expr ::= LP nexprlist COMMA expr RP */ + pList = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_VECTOR), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = pList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 4)) |= (*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr)).Fflags & libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)|libc.Int32FromInt32(EP_Subquery)|libc.Int32FromInt32(EP_HasFunc)) + goto _351 + _351: + ; + i = i + 1 + } + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList) + } + goto _350 +_213: + ; /* expr ::= expr AND expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_215: + ; /* expr ::= expr OR expr */ +_214: + ; +_216: + ; +_217: + ; +_218: + ; +_219: + ; +_220: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_221: + ; /* likeop ::= NOT LIKE_KW|MATCH */ + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) |= uint32(0x80000000) /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/ + goto _350 +_222: + ; /* expr ::= expr likeop expr */ + bNot = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) & uint32(0x80000000)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) &= uint32(0x7fffffff) + pList1 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + pList1 = _sqlite3ExprListAppend(tls, pParse, pList1, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprFunction(tls, pParse, pList1, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + if bNot != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), uintptr(0)) + } + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) != 0 { + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + 4)) |= uint32(EP_InfixFunc) + } + goto _350 +_223: + ; /* expr ::= expr likeop expr ESCAPE expr */ + bNot1 = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) & uint32(0x80000000)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) &= uint32(0x7fffffff) + pList2 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList2 = _sqlite3ExprListAppend(tls, pParse, pList2, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + pList2 = _sqlite3ExprListAppend(tls, pParse, pList2, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprFunction(tls, pParse, pList2, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, 0) + if bNot1 != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 4)) |= uint32(EP_InfixFunc) + } + goto _350 +_224: + ; /* expr ::= expr ISNULL|NOTNULL */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExprIsNull(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_225: + ; /* expr ::= expr NOT NULL */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExprIsNull(tls, pParse, int32(TK_NOTNULL), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_226: + ; /* expr ::= expr IS expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_IS), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_227: + ; /* expr ::= expr IS NOT expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_ISNOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_228: + ; /* expr ::= expr IS NOT DISTINCT FROM expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_IS), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_229: + ; /* expr ::= expr IS DISTINCT FROM expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_ISNOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_231: + ; /* expr ::= NOT expr */ +_230: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) /*A-overwrites-B*/ + goto _350 +_232: + ; /* expr ::= PLUS|MINUS expr */ + p4 = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + op = libc.Uint8FromInt32(libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) + (libc.Int32FromInt32(TK_UPLUS) - libc.Int32FromInt32(TK_PLUS))) + if p4 != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p4)).Fop) == int32(TK_UPLUS) { + (*TExpr)(unsafe.Pointer(p4)).Fop = op + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = p4 + } else { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8(op), p4, uintptr(0)) + /*A-overwrites-B*/ + } + goto _350 +_233: + ; /* expr ::= expr PTR expr */ + pList3 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList3 = _sqlite3ExprListAppend(tls, pParse, pList3, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, pList3, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_235: + ; /* between_op ::= BETWEEN */ +_234: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = 0 + goto _350 +_236: + ; /* expr ::= expr between_op expr AND expr */ + pList4 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList4 = _sqlite3ExprListAppend(tls, pParse, pList4, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_BETWEEN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = pList4 + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList4) + } + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_237: + ; /* expr ::= expr in_op LP exprlist RP */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) == uintptr(0) { + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + v352 = __ccgo_ts + 8522 + } else { + v352 = __ccgo_ts + 8527 + } + /* Expressions of the form + ** + ** expr1 IN () + ** expr1 NOT IN () + ** + ** simplify to constants 0 (false) and 1 (true), respectively. + ** + ** Except, do not apply this optimization if expr1 contains a function + ** because that function might be an aggregate (we don't know yet whether + ** it is or not) and if it is an aggregate, that could change the meaning + ** of the whole query. + */ + pB = _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_STRING), v352) + if pB != 0 { + _sqlite3ExprIdToTrueFalse(tls, pB) + } + if !((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)) != libc.Uint32FromInt32(0)) { + _sqlite3ExprUnmapAndDelete(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = pB + } else { + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + v353 = int32(TK_OR) + } else { + v353 = int32(TK_AND) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, v353, pB, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } + } else { + pRHS = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8))).FpExpr + if (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnExpr == int32(1) && _sqlite3ExprIsConstant(tls, pParse, pRHS) != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).Fop) != int32(TK_VECTOR) { + (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8))).FpExpr = uintptr(0) + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + pRHS = _sqlite3PExpr(tls, pParse, int32(TK_UPLUS), pRHS, uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_EQ), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pRHS) + } else { + if (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnExpr == int32(1) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRHS)).Fop) == int32(TK_SELECT) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(pRHS + 32))) + *(*uintptr)(unsafe.Pointer(pRHS + 32)) = uintptr(0) + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) == uintptr(0) { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).FpLeft)).Fop) == int32(TK_VECTOR) { + nExpr = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).FpLeft + 32)))).FnExpr + pSelectRHS = _sqlite3ExprListToValues(tls, pParse, nExpr, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + if pSelectRHS != 0 { + _parserDoubleLinkSelect(tls, pParse, pSelectRHS) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pSelectRHS) + } + } else { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } + } + } + } + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + } + goto _350 +_238: + ; /* expr ::= LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_SELECT), uintptr(0), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_239: + ; /* expr ::= expr in_op LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_240: + ; /* expr ::= expr in_op nm dbnm paren_exprlist */ + pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + pSelect = _sqlite3SelectNew(tls, pParse, uintptr(0), pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + if pSelect != 0 { + v352 = pSrc + } else { + v352 = uintptr(0) + } + _sqlite3SrcListFuncArgs(tls, pParse, v352, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pSelect) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_241: + ; /* expr ::= EXISTS LP select RP */ + v352 = _sqlite3PExpr(tls, pParse, int32(TK_EXISTS), uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = v352 + p5 = v352 + _sqlite3PExprAddSelect(tls, pParse, p5, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_242: + ; /* expr ::= CASE case_operand case_exprlist case_else END */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_CASE), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + v352 = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + v352 = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + } + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = v352 + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } + goto _350 +_243: + ; /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_244: + ; /* case_exprlist ::= WHEN expr THEN expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_245: + ; /* nexprlist ::= nexprlist COMMA expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_246: + ; /* nexprlist ::= expr */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-Y*/ + goto _350 +_248: + ; /* paren_exprlist ::= LP exprlist RP */ +_247: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_249: + ; /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + _sqlite3CreateIndex(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, uintptr(0)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(11))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + 8)), SQLITE_SO_ASC, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), uint8(SQLITE_IDXTYPE_APPDEF)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TParse)(unsafe.Pointer(pParse)).FpNewIndex != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*TIndex)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).FpNewIndex)).FzName, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + } + goto _350 +_251: + ; /* uniqueflag ::= UNIQUE */ +_250: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Abort) + goto _350 +_252: + ; /* uniqueflag ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = OE_None + goto _350 +_253: + ; /* eidlist ::= eidlist COMMA nm collate sortorder */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_254: + ; /* eidlist ::= nm collate sortorder */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _parserAddExprIdListTerm(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-Y*/ + goto _350 +_255: + ; /* cmd ::= DROP INDEX ifexists fullname */ + _sqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_256: + ; /* cmd ::= VACUUM vinto */ + _sqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_257: + ; /* cmd ::= VACUUM nm vinto */ + _sqlite3Vacuum(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_258: + ; /* cmd ::= PRAGMA nm dbnm */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8, uintptr(0), 0) + goto _350 +_259: + ; /* cmd ::= PRAGMA nm dbnm EQ nmnum */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, 0) + goto _350 +_260: + ; /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + goto _350 +_261: + ; /* cmd ::= PRAGMA nm dbnm EQ minus_num */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, int32(1)) + goto _350 +_262: + ; /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, int32(1)) + goto _350 +_263: + ; /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + (**(**TToken)(__ccgo_up(bp + 112))).Fz = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + (**(**TToken)(__ccgo_up(bp + 112))).Fn = libc.Uint32FromInt32(int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))))) + *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + _sqlite3FinishTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), bp+112) + goto _350 +_264: + ; /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + _sqlite3BeginTrigger(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8))) + if *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8 + 8)) == uint32(0) { + v357 = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) + } else { + v357 = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) + } + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)) = v357 /*A-overwrites-T*/ + goto _350 +_265: + ; /* trigger_time ::= BEFORE|AFTER */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_266: + ; /* trigger_time ::= INSTEAD OF */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(TK_INSTEAD) + goto _350 +_267: + ; /* trigger_time ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(TK_BEFORE) + goto _350 +_269: + ; /* trigger_event ::= DELETE|INSERT */ +_268: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 + 8)) = uintptr(0) + goto _350 +_270: + ; /* trigger_event ::= UPDATE OF idlist */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = int32(TK_UPDATE) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_272: + ; /* when_clause ::= */ +_271: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_274: + ; /* when_clause ::= WHEN expr */ +_273: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_275: + ; /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + (*TTriggerStep)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)))).FpLast)).FpNext = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + (*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_276: + ; /* trigger_cmd_list ::= trigger_cmd SEMI */ + (*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_277: + ; /* tridxby ::= INDEXED BY nm */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25357, 0) + goto _350 +_278: + ; /* tridxby ::= NOT INDEXED */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25441, 0) + goto _350 +_279: + ; /* trigger_cmd ::= UPDATE orconf xfullname tridxby SET setlist from where_opt scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerUpdateStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_280: + ; /* trigger_cmd ::= scanpt insert_cmd INTO xfullname idlist_opt select upsert scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerInsertStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_281: + ; /* trigger_cmd ::= DELETE FROM xfullname tridxby where_opt scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerDeleteStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_282: + ; /* trigger_cmd ::= scanpt select scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerSelectStep(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_283: + ; /* expr ::= RAISE LP IGNORE RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + (*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))).FaffExpr = int8(OE_Ignore) + } + goto _350 +_284: + ; /* expr ::= RAISE LP raisetype COMMA expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) != 0 { + (*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)))).FaffExpr = int8(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + } + goto _350 +_285: + ; /* raisetype ::= ROLLBACK */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Rollback) + goto _350 +_286: + ; /* raisetype ::= FAIL */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Fail) + goto _350 +_287: + ; /* cmd ::= DROP TRIGGER ifexists fullname */ + _sqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_288: + ; /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + _sqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_289: + ; /* cmd ::= DETACH database_kw_opt expr */ + _sqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_290: + ; /* cmd ::= REINDEX */ + _sqlite3Reindex(tls, pParse, uintptr(0), uintptr(0)) + goto _350 +_291: + ; /* cmd ::= REINDEX nm dbnm */ + _sqlite3Reindex(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8) + goto _350 +_292: + ; /* cmd ::= ANALYZE */ + _sqlite3Analyze(tls, pParse, uintptr(0), uintptr(0)) + goto _350 +_293: + ; /* cmd ::= ANALYZE nm dbnm */ + _sqlite3Analyze(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8) + goto _350 +_294: + ; /* cmd ::= ALTER TABLE fullname RENAME TO nm */ + _sqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_295: + ; /* cmd ::= alter_add carglist */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))))) + (*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fn + _sqlite3AlterFinishAddColumn(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + goto _350 +_296: + ; /* alter_add ::= ALTER TABLE fullname ADD kwcolumn_opt nm typetoken */ + _disableLookaside(tls, pParse) + _sqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + _sqlite3AddColumn(tls, pParse, *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*TToken)(unsafe.Pointer(yymsp + 8))) + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_297: + ; /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ + _sqlite3AlterDropColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_298: + ; /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + _sqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8) + goto _350 +_299: + ; /* cmd ::= ALTER TABLE fullname DROP CONSTRAINT nm */ + _sqlite3AlterDropConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8, uintptr(0)) + goto _350 +_300: + ; /* cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm DROP NOT NULL */ + _sqlite3AlterDropConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8) + goto _350 +_301: + ; /* cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm SET NOT NULL onconf */ + _sqlite3AlterSetNotNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + goto _350 +_302: + ; /* cmd ::= ALTER TABLE fullname ADD CONSTRAINT nm CHECK LP expr RP onconf */ + _sqlite3AlterAddConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))+uintptr(1), int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))-libc.Int64FromInt32(1)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_303: + ; /* cmd ::= ALTER TABLE fullname ADD CHECK LP expr RP onconf */ + _sqlite3AlterAddConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))+uintptr(1), int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))-libc.Int64FromInt32(1)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_304: + ; /* cmd ::= create_vtab */ + _sqlite3VtabFinishParse(tls, pParse, uintptr(0)) + goto _350 +_305: + ; /* cmd ::= create_vtab LP vtabarglist RP */ + _sqlite3VtabFinishParse(tls, pParse, yymsp+8) + goto _350 +_306: + ; /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + _sqlite3VtabBeginParse(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + goto _350 +_307: + ; /* vtabarg ::= */ + _sqlite3VtabArgInit(tls, pParse) + goto _350 +_309: + ; /* vtabargtoken ::= ANY */ +_308: + ; +_310: + ; + _sqlite3VtabArgExtend(tls, pParse, yymsp+8) + goto _350 +_312: + ; /* with ::= WITH wqlist */ +_311: + ; + _sqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uint8(1)) + goto _350 +_313: + ; /* wqas ::= AS */ + *(*Tu8)(unsafe.Pointer(yymsp + 8)) = uint8(M10d_Any) + goto _350 +_314: + ; /* wqas ::= AS MATERIALIZED */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint8(M10d_Yes) + goto _350 +_315: + ; /* wqas ::= AS NOT MATERIALIZED */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = uint8(M10d_No) + goto _350 +_316: + ; /* wqitem ::= withnm eidlist_opt wqas LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3CteNew(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) /*A-overwrites-X*/ + goto _350 +_317: + ; /* withnm ::= nm */ + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 6, 0x40) + goto _350 +_318: + ; /* wqlist ::= wqitem */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3WithAdd(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_319: + ; /* wqlist ::= wqlist COMMA wqitem */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3WithAdd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_320: + ; /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ + _sqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_321: + ; /* windowdefn ::= nm AS LP window RP */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FzName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uint64(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8 + 8)))) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_322: + ; /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_323: + ; /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(5))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_324: + ; /* window ::= ORDER BY sortlist frame_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_325: + ; /* window ::= nm ORDER BY sortlist frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_326: + ; /* window ::= nm frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_327: + ; /* frame_opt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = _sqlite3WindowAlloc(tls, pParse, 0, int32(TK_UNBOUNDED), uintptr(0), int32(TK_CURRENT), uintptr(0), uint8(0)) + goto _350 +_328: + ; /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)), int32(TK_CURRENT), uintptr(0), *(*Tu8)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_329: + ; /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)), *(*Tu8)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_331: + ; /* frame_bound_s ::= frame_bound */ +_330: + ; + *(*TFrameBound)(unsafe.Pointer(bp)) = *(*TFrameBound)(unsafe.Pointer(yymsp + 8)) + *(*TFrameBound)(unsafe.Pointer(yymsp + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_333: + ; /* frame_bound_s ::= UNBOUNDED PRECEDING */ +_332: + ; +_334: + ; + (*(*TFrameBound)(unsafe.Pointer(bp))).FeType = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) + (*(*TFrameBound)(unsafe.Pointer(bp))).FpExpr = uintptr(0) + *(*TFrameBound)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_335: + ; /* frame_bound ::= expr PRECEDING|FOLLOWING */ + (*(*TFrameBound)(unsafe.Pointer(bp))).FeType = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) + (*(*TFrameBound)(unsafe.Pointer(bp))).FpExpr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + *(*TFrameBound)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_336: + ; /* frame_exclude_opt ::= */ + *(*Tu8)(unsafe.Pointer(yymsp + 1*24 + 8)) = uint8(0) + goto _350 +_337: + ; /* frame_exclude_opt ::= EXCLUDE frame_exclude */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*Tu8)(unsafe.Pointer(yymsp + 8)) + goto _350 +_339: + ; /* frame_exclude ::= NO OTHERS */ +_338: + ; + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint8((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) /*A-overwrites-X*/ + goto _350 +_340: + ; /* frame_exclude ::= GROUP|TIES */ + *(*Tu8)(unsafe.Pointer(yymsp + 8)) = uint8((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_341: + ; /* window_clause ::= WINDOW windowdefn_list */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_342: + ; /* filter_over ::= filter_clause over_clause */ + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_343: + ; /* filter_over ::= over_clause */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_344: + ; /* filter_over ::= filter_clause */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))))).FeFrmType = uint8(TK_FILTER) + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_345: + ; /* over_clause ::= OVER LP window RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_346: + ; /* over_clause ::= OVER nm */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FzName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uint64(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) + } + goto _350 +_347: + ; /* filter_clause ::= FILTER LP WHERE expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_348: + ; /* term ::= QNUMBER */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _tokenExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*TToken)(unsafe.Pointer(yymsp + 8))) + _sqlite3DequoteNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp))))) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_349: + ; + goto _350 + /********** End reduce actions ************************************************/ +_350: + ; + yygoto = libc.Int32FromUint16(_yyRuleInfoLhs[yyruleno]) + yysize = int32(_yyRuleInfoNRhs[yyruleno]) + yyact = _yy_find_reduce_action(tls, (**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(yysize)*24))).Fstateno, libc.Uint16FromInt32(yygoto)) + /* There are no SHIFTREDUCE actions on nonterminals because the table + ** generator has simplified them to pure REDUCE actions. */ + /* It is not possible for a REDUCE to be followed by an error */ + yymsp = yymsp + uintptr(yysize+int32(1))*24 + (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos = yymsp + (*TyyStackEntry)(unsafe.Pointer(yymsp)).Fstateno = yyact + (*TyyStackEntry)(unsafe.Pointer(yymsp)).Fmajor = libc.Uint16FromInt32(yygoto) + return yyact +} + +/* +** The following code executes when the parse fails + */ + +// C documentation +// +// /* +// ** The following code executes when a syntax error first occurs. +// */ +func _yy_syntax_error(tls *libc.TLS, yypParser uintptr, yymajor int32, _yyminor TToken) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*TToken)(unsafe.Pointer(bp)) = _yyminor + var pParse uintptr + _ = pParse + pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse + /************ Begin %syntax_error code ****************************************/ + _ = yymajor /* Silence some compiler warnings */ + if **(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp))).Fz)) != 0 { + _parserSyntaxError(tls, pParse, bp) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25526, 0) + } + /************ End %syntax_error code ******************************************/ + /* Suppress warning about unused %extra_argument variable */ + (*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse +} + +// C documentation +// +// /* +// ** Set up a raw page so that it looks like a database page holding +// ** no entries. +// */ +func _zeroPage(tls *libc.TLS, pPage uintptr, flags int32) { + var data, pBt uintptr + var first, hdr, v1 int32 + _, _, _, _, _ = data, first, hdr, pBt, v1 + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_FAST_SECURE) != 0 { + libc.X__builtin___memset_chk(tls, data+uintptr(hdr), 0, uint64((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(hdr)), ^t__predefined_size_t(0)) + } + **(**uint8)(__ccgo_up(data + uintptr(hdr))) = libc.Uint8FromInt8(int8(flags)) + if flags&int32(PTF_LEAF) == 0 { + v1 = int32(12) + } else { + v1 = int32(8) + } + first = hdr + v1 + libc.X__builtin___memset_chk(tls, data+uintptr(hdr+int32(1)), 0, uint64(4), ^t__predefined_size_t(0)) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7)))) = uint8(0) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)))) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FusableSize >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)) + 1)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FusableSize) + (*TMemPage)(unsafe.Pointer(pPage)).FnFree = libc.Int32FromUint16(uint16((*TBtShared)(unsafe.Pointer(pBt)).FusableSize - libc.Uint32FromInt32(first))) + _decodeFlags(tls, pPage, flags) + (*TMemPage)(unsafe.Pointer(pPage)).FcellOffset = libc.Uint16FromInt32(first) + (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd = data + uintptr((*TBtShared)(unsafe.Pointer(pBt)).FpageSize) + (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx = data + uintptr(first) + (*TMemPage)(unsafe.Pointer(pPage)).FaDataOfst = data + uintptr((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FmaskPage = uint16((*TBtShared)(unsafe.Pointer(pBt)).FpageSize - libc.Uint32FromInt32(1)) + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = uint16(0) + (*TMemPage)(unsafe.Pointer(pPage)).FisInit = uint8(1) +} + +type accessx_descriptor = Taccessx_descriptor + +type afpLockingContext = TafpLockingContext + +type attrgroup_t = Tattrgroup_t + +type attribute_set = Tattribute_set + +type attribute_set_t = Tattribute_set_t + +type attrlist = Tattrlist + +type attrreference = Tattrreference + +type attrreference_t = Tattrreference_t + +type au_asflgs_t = Tau_asflgs_t + +type au_asid_t = Tau_asid_t + +type au_class_t = Tau_class_t + +type au_ctlmode_t = Tau_ctlmode_t + +type au_emod_t = Tau_emod_t + +type au_evclass_map = Tau_evclass_map + +type au_evclass_map_t = Tau_evclass_map_t + +type au_event_t = Tau_event_t + +type au_expire_after = Tau_expire_after + +type au_expire_after_t = Tau_expire_after_t + +type au_fstat_t = Tau_fstat_t + +type au_id_t = Tau_id_t + +type au_mask = Tau_mask + +type au_mask_t = Tau_mask_t + +type au_qctrl = Tau_qctrl + +type au_qctrl_t = Tau_qctrl_t + +type au_session = Tau_session + +type au_session_t = Tau_session_t + +type au_stat_t = Tau_stat_t + +type au_tid = Tau_tid + +type au_tid_addr = Tau_tid_addr + +type au_tid_addr_t = Tau_tid_addr_t + +type au_tid_t = Tau_tid_t + +type audit_fstat = Taudit_fstat + +type audit_stat = Taudit_stat + +type auditinfo = Tauditinfo + +type auditinfo_addr = Tauditinfo_addr + +type auditinfo_addr_t = Tauditinfo_addr_t + +type auditinfo_t = Tauditinfo_t + +type auditpinfo = Tauditpinfo + +type auditpinfo_addr = Tauditpinfo_addr + +type auditpinfo_addr_t = Tauditpinfo_addr_t + +type auditpinfo_t = Tauditpinfo_t + +const bool1 = 0 + +type boolean_t = Tboolean_t + +type cmsghdr = Tcmsghdr + +type cryptex_auth_type_t = Tcryptex_auth_type_t + +type ct_rune_t = Tct_rune_t + +type diskextent = Tdiskextent + +type dl_info = Tdl_info + +/* + * Special handle arguments for dlsym(). + */ + +type extentrecord = Textentrecord + +const false1 = 0 + +type fattributiontag = Tfattributiontag + +type fattributiontag_t = Tfattributiontag_t + +type fchecklv = Tfchecklv + +type fchecklv_t = Tfchecklv_t + +type fgetsigsinfo = Tfgetsigsinfo + +type fgetsigsinfo_t = Tfgetsigsinfo_t + +type fhandle = Tfhandle + +type fhandle_t = Tfhandle_t + +type filesec_property_t = Tfilesec_property_t + +type filesec_t = Tfilesec_t + +type flocktimeout = Tflocktimeout + +type fpunchhole = Tfpunchhole + +type fpunchhole_t = Tfpunchhole_t + +type fsfile_type_t = Tfsfile_type_t + +type fsid = Tfsid + +type fsid_t = Tfsid_t + +type fsignatures = Tfsignatures + +type fsignatures_t = Tfsignatures_t + +type fsobj_id = Tfsobj_id + +type fsobj_id_t = Tfsobj_id_t + +type fsobj_tag_t = Tfsobj_tag_t + +type fsobj_type_t = Tfsobj_type_t + +type fspecread = Tfspecread + +type fspecread_t = Tfspecread_t + +type fssearchblock = Tfssearchblock + +type fstore = Tfstore + +type fstore_t = Tfstore_t + +type fsupplement = Tfsupplement + +type fsupplement_t = Tfsupplement_t + +type fsvolid_t = Tfsvolid_t + +type ftrimactivefile = Tftrimactivefile + +type ftrimactivefile_t = Tftrimactivefile_t + +type graft_args = Tgraft_args + +type graftdmg_args_un = Tgraftdmg_args_un + +type graftdmg_type_t = Tgraftdmg_type_t + +type if_clonereq = Tif_clonereq + +type if_data = Tif_data + +type if_data64 = Tif_data64 + +type if_msghdr = Tif_msghdr + +type if_msghdr2 = Tif_msghdr2 + +type if_nameindex = Tif_nameindex + +type ifa_msghdr = Tifa_msghdr + +type ifaliasreq = Tifaliasreq + +type ifconf = Tifconf + +type ifdevmtu = Tifdevmtu + +type ifdrv = Tifdrv + +type ifkpi = Tifkpi + +type ifma_msghdr = Tifma_msghdr + +type ifma_msghdr2 = Tifma_msghdr2 + +type ifmediareq = Tifmediareq + +type ifqueue = Tifqueue + +type ifreq = Tifreq + +type ifstat = Tifstat + +func init() { + p := unsafe.Pointer(&_nfsIoMethods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_unixClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_unixRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_unixWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_unixTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_unixLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_nfsUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_unixCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixShmLock) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixShmBarrier) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixShmUnmap) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixFetch) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixUnfetch) +} + +func init() { + p := unsafe.Pointer(&_flockIoMethods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_flockClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_unixRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_unixWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_unixTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_flockLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_flockUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_flockCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixShmLock) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixShmBarrier) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixShmUnmap) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixFetch) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixUnfetch) +} + +func init() { + p := unsafe.Pointer(&_nfsIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_nfsIoFinderImpl) +} + +func init() { + p := unsafe.Pointer(&_dotlockIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_dotlockIoFinderImpl) +} + +func init() { + p := unsafe.Pointer(&_aSyscall) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_posixOpen) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(libc.Xclose) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(libc.Xaccess) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(libc.Xgetcwd) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(libc.Xstat) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(libc.Xfstat) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(libc.Xftruncate) + *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(libc.Xfcntl) + *(*uintptr)(unsafe.Add(p, 200)) = __ccgo_fp(libc.Xread) + *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(libc.Xpread) + *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(libc.Xwrite) + *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(libc.Xpwrite) + *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(libc.Xfchmod) + *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(libc.Xunlink) + *(*uintptr)(unsafe.Add(p, 416)) = __ccgo_fp(_openDirectory) + *(*uintptr)(unsafe.Add(p, 440)) = __ccgo_fp(libc.Xmkdir) + *(*uintptr)(unsafe.Add(p, 464)) = __ccgo_fp(libc.Xrmdir) + *(*uintptr)(unsafe.Add(p, 488)) = __ccgo_fp(libc.Xfchown) + *(*uintptr)(unsafe.Add(p, 512)) = __ccgo_fp(libc.Xgeteuid) + *(*uintptr)(unsafe.Add(p, 536)) = __ccgo_fp(libc.Xmmap) + *(*uintptr)(unsafe.Add(p, 560)) = __ccgo_fp(libc.Xmunmap) + *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(_unixGetpagesize) + *(*uintptr)(unsafe.Add(p, 632)) = __ccgo_fp(libc.Xreadlink) + *(*uintptr)(unsafe.Add(p, 656)) = __ccgo_fp(libc.Xlstat) +} + +/* End of the overrideable system calls */ + +func init() { + p := unsafe.Pointer(&_flockIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_flockIoFinderImpl) +} + +func init() { + p := unsafe.Pointer(&_proxyIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_proxyIoFinderImpl) +} + +func init() { + p := unsafe.Pointer(&_aVfs) + *(*uintptr)(unsafe.Add(p, 32)) = uintptr(unsafe.Pointer(&_autolockIoFinder)) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 200)) = uintptr(unsafe.Pointer(&_nolockIoFinder)) + *(*uintptr)(unsafe.Add(p, 208)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 216)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 232)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 248)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 256)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 264)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 280)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 288)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 304)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 328)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 368)) = uintptr(unsafe.Pointer(&_dotlockIoFinder)) + *(*uintptr)(unsafe.Add(p, 376)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 400)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 408)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 416)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 424)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 432)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 440)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 448)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 464)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 472)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 480)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 488)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 496)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 536)) = uintptr(unsafe.Pointer(&_posixIoFinder)) + *(*uintptr)(unsafe.Add(p, 544)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 552)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 560)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 568)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 576)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 584)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 592)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 616)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 624)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 632)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 640)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 648)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 656)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 664)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 704)) = uintptr(unsafe.Pointer(&_posixIoFinder)) + *(*uintptr)(unsafe.Add(p, 712)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 720)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 728)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 736)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 744)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 752)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 760)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 768)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 776)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 784)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 792)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 800)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 808)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 816)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 824)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 832)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 872)) = uintptr(unsafe.Pointer(&_flockIoFinder)) + *(*uintptr)(unsafe.Add(p, 880)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 888)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 896)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 904)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 912)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 920)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 928)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 936)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 944)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 952)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 960)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 968)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 976)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 984)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 992)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 1000)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 1040)) = uintptr(unsafe.Pointer(&_afpIoFinder)) + *(*uintptr)(unsafe.Add(p, 1048)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 1056)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 1064)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 1072)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 1080)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 1088)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 1096)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 1104)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 1112)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 1120)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 1128)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 1136)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 1144)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 1152)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 1160)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 1168)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 1208)) = uintptr(unsafe.Pointer(&_nfsIoFinder)) + *(*uintptr)(unsafe.Add(p, 1216)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 1224)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 1232)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 1240)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 1248)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 1256)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 1264)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 1272)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 1280)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 1288)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 1296)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 1304)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 1312)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 1320)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 1328)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 1336)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 1376)) = uintptr(unsafe.Pointer(&_proxyIoFinder)) + *(*uintptr)(unsafe.Add(p, 1384)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 1392)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 1400)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 1408)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 1416)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 1424)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 1432)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 1440)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 1448)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 1456)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 1464)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 1472)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 1480)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 1488)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 1496)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 1504)) = __ccgo_fp(_unixNextSystemCall) +} + +func init() { + p := unsafe.Pointer(&_afpIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_afpIoFinderImpl) +} + +func init() { + p := unsafe.Pointer(&_proxyIoMethods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_proxyClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_unixRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_unixWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_unixTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_proxyLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_proxyUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_proxyCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixShmLock) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixShmBarrier) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixShmUnmap) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixFetch) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixUnfetch) +} + +func init() { + p := unsafe.Pointer(&_afpIoMethods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_afpClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_unixRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_unixWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_unixTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_afpLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_afpUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_afpCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixShmLock) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixShmBarrier) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixShmUnmap) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixFetch) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixUnfetch) +} + +func init() { + p := unsafe.Pointer(&_autolockIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_autolockIoFinderImpl) +} + +type ino64_t = Tino64_t + +type integer_t = Tinteger_t + +const kGUARD_EXC_MOVE_PROVISIONAL_REPLY_PORT = 0 + +const kGUARD_EXC_PROVISIONAL_REPLY_PORT = 0 + +type kev_dl_proto_data = Tkev_dl_proto_data + +type log2phys = Tlog2phys + +type mach_port_array_t = Tmach_port_array_t + +type mach_port_context_t = Tmach_port_context_t + +type mach_port_delta_t = Tmach_port_delta_t + +type mach_port_flavor_t = Tmach_port_flavor_t + +type mach_port_guard_info = Tmach_port_guard_info + +type mach_port_guard_info_t = Tmach_port_guard_info_t + +type mach_port_info_ext = Tmach_port_info_ext + +type mach_port_info_ext_t = Tmach_port_info_ext_t + +type mach_port_info_t = Tmach_port_info_t + +type mach_port_limits = Tmach_port_limits + +type mach_port_limits_t = Tmach_port_limits_t + +type mach_port_mscount_t = Tmach_port_mscount_t + +type mach_port_msgcount_t = Tmach_port_msgcount_t + +type mach_port_name_array_t = Tmach_port_name_array_t + +type mach_port_name_t = Tmach_port_name_t + +type mach_port_options = Tmach_port_options + +type mach_port_options_ptr_t = Tmach_port_options_ptr_t + +type mach_port_options_t = Tmach_port_options_t + +type mach_port_qos = Tmach_port_qos + +type mach_port_qos_t = Tmach_port_qos_t + +type mach_port_right_t = Tmach_port_right_t + +type mach_port_rights_t = Tmach_port_rights_t + +type mach_port_seqno_t = Tmach_port_seqno_t + +type mach_port_srights_t = Tmach_port_srights_t + +type mach_port_status = Tmach_port_status + +type mach_port_status_t = Tmach_port_status_t + +type mach_port_t = Tmach_port_t + +type mach_port_type_array_t = Tmach_port_type_array_t + +type mach_port_type_t = Tmach_port_type_t + +type mach_port_urefs_t = Tmach_port_urefs_t + +type mach_service_port_info = Tmach_service_port_info + +type mach_service_port_info_data_t = Tmach_service_port_info_data_t + +type mach_service_port_info_t = Tmach_service_port_info_t + +type mach_vm_address_t = Tmach_vm_address_t + +type mach_vm_offset_t = Tmach_vm_offset_t + +type mach_vm_size_t = Tmach_vm_size_t + +type malloc_type_id_t = Tmalloc_type_id_t + +const math_errhandling = 0 + +type mcontext_t = Tmcontext_t + +type mount_t = Tmount_t + +type mpo_flags_t = Tmpo_flags_t + +type msghdr = Tmsghdr + +type natural_t = Tnatural_t + +type net_event_data = Tnet_event_data + +type netfs_status = Tnetfs_status + +type os_block_t = Tos_block_t + +type os_function_t = Tos_function_t + +type ostat = Tostat + +type posix_cred_t = Tposix_cred_t + +type proc_rlimit_control_wakeupmon = Tproc_rlimit_control_wakeupmon + +type proxyLockingContext = TproxyLockingContext + +const pseudo_AF_HDRCMPLT = 35 + +const pseudo_AF_KEY = 29 + +const pseudo_AF_PIP = 25 + +const pseudo_AF_RTIP = 22 + +const pseudo_AF_XTP = 19 + +type radvisory = Tradvisory + +type rlimit = Trlimit + +type rslvmulti_req = Trslvmulti_req + +const ru_first = 0 + +const ru_last = 0 + +type rusage = Trusage + +type rusage_info_current = Trusage_info_current + +type rusage_info_t = Trusage_info_t + +type rusage_info_v0 = Trusage_info_v0 + +type rusage_info_v1 = Trusage_info_v1 + +type rusage_info_v2 = Trusage_info_v2 + +type rusage_info_v3 = Trusage_info_v3 + +type rusage_info_v4 = Trusage_info_v4 + +type rusage_info_v5 = Trusage_info_v5 + +type rusage_info_v6 = Trusage_info_v6 + +type sa_endpoints = Tsa_endpoints + +type sa_endpoints_t = Tsa_endpoints_t + +type sa_family_t = Tsa_family_t + +type sae_associd_t = Tsae_associd_t + +type sae_connid_t = Tsae_connid_t + +type searchstate = Tsearchstate + +type secure_boot_cryptex_args = Tsecure_boot_cryptex_args + +type secure_boot_cryptex_args_t = Tsecure_boot_cryptex_args_t + +type sf_hdtr = Tsf_hdtr + +type sig_atomic_t = Tsig_atomic_t + +type sig_t = Tsig_t + +type sigaction = Tsigaction + +type sigevent = Tsigevent + +type siginfo_t = Tsiginfo_t + +type sigstack = Tsigstack + +type sigval = Tsigval + +type sigvec = Tsigvec + +type so_np_extensions = Tso_np_extensions + +type sockaddr_storage = Tsockaddr_storage + +type socklen_t = Tsocklen_t + +type statfs = Tstatfs + +const sv_onstack = 0 + +type syscall_arg_t = Tsyscall_arg_t + +type t__darwin_blkcnt_t = int64 + +type t__darwin_blksize_t = int32 + +type t__darwin_clock_t = uint64 + +type t__darwin_ct_rune_t = int32 + +type t__darwin_dev_t = int32 + +type t__darwin_fsblkcnt_t = uint32 + +type t__darwin_fsfilcnt_t = uint32 + +type t__darwin_gid_t = uint32 + +type t__darwin_id_t = uint32 + +type t__darwin_ino64_t = uint64 + +type t__darwin_ino_t = uint64 + +type t__darwin_intptr_t = int64 + +type t__darwin_mach_port_name_t = uint32 + +type t__darwin_mach_port_t = uint32 + +type t__darwin_mbstate_t = struct { + F_mbstateL [0]int64 + F__mbstate8 [128]int8 +} + +type t__darwin_mode_t = uint16 + +type t__darwin_natural_t = uint32 + +type t__darwin_nl_item = int32 + +type t__darwin_off_t = int64 + +type t__darwin_pid_t = int32 + +type t__darwin_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} + +type t__darwin_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} + +type t__darwin_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type t__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} + +type t__darwin_pthread_key_t = uint64 + +type t__darwin_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} + +type t__darwin_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type t__darwin_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} + +type t__darwin_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} + +type t__darwin_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} + +type t__darwin_pthread_t = uintptr + +type t__darwin_ptrdiff_t = int64 + +type t__darwin_rune_t = int32 + +type t__darwin_sigaltstack = struct { + Fss_sp uintptr + Fss_size t__darwin_size_t + Fss_flags int32 +} + +type t__darwin_sigset_t = uint32 + +type t__darwin_size_t = uint64 + +type t__darwin_socklen_t = uint32 + +type t__darwin_ssize_t = int64 + +type t__darwin_suseconds_t = int32 + +type t__darwin_time_t = int64 + +type t__darwin_ucontext = struct { + Fuc_onstack int32 + Fuc_sigmask t__darwin_sigset_t + Fuc_stack t__darwin_sigaltstack + Fuc_link uintptr + Fuc_mcsize t__darwin_size_t + Fuc_mcontext uintptr +} + +type t__darwin_uid_t = uint32 + +type t__darwin_useconds_t = uint32 + +type t__darwin_uuid_string_t = [37]int8 + +type t__darwin_uuid_t = [16]uint8 + +type t__darwin_va_list = uintptr + +type t__darwin_wchar_t = int32 + +type t__darwin_wctrans_t = int32 + +type t__darwin_wctype_t = uint32 + +type t__darwin_wint_t = int32 + +type t__double2 = struct { + F__sinval float64 + F__cosval float64 +} + +type t__float2 = struct { + F__sinval float32 + F__cosval float32 +} + +type t__mbstate_t = struct { + F_mbstateL [0]int64 + F__mbstate8 [128]int8 +} + +type t__sigaction = struct { + F__sigaction_u t__sigaction_u + Fsa_tramp uintptr + Fsa_mask Tsigset_t + Fsa_flags int32 +} + +type t__sigaction_u = struct { + F__sa_sigaction [0]uintptr + F__sa_handler uintptr +} + +type t__siginfo = Tsiginfo_t + +type t__sockaddr_header = struct { + Fsa_len t__uint8_t + Fsa_family Tsa_family_t +} + +type text_encoding_t = Ttext_encoding_t + +type timeval32 = Ttimeval32 + +type timeval64 = Ttimeval64 + +const true1 = 1 + +type ucontext_t = Tucontext_t + +type uintmax_t = Tuintmax_t + +/* C99 7.18.4 Macros for minimum-width integer constants. + * + * The standard requires that integer constant macros be defined for all the + * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width + * types are required, the corresponding integer constant macros are defined + * here. This implementation also defines minimum-width types for every other + * integer width that the target implements, so corresponding macros are + * defined below, too. + * + * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the + * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + */ + +/* C99 7.18.2.1 Limits of exact-width integer types. + * C99 7.18.2.2 Limits of minimum-width integer types. + * C99 7.18.2.3 Limits of fastest minimum-width integer types. + * + * The presence of limit macros are completely optional in C99. This + * implementation defines limits for all of the types (exact- and + * minimum-width) that it defines above, using the limits of the minimum-width + * type for any types that do not have exact-width representations. + * + * As in the type definitions, this section takes an approach of + * successive-shrinking to determine which limits to use for the standard (8, + * 16, 32, 64) bit widths when they don't have exact representations. It is + * therefore important that the definitions be kept in order of decending + * widths. + * + * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the + * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + */ + +/* Some utility macros */ + +/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */ +/* C99 7.18.3 Limits of other integer types. */ + +/* C23 7.22.2.4 Width of integer types capable of holding object pointers. */ + +/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ + * is enabled. */ + +/* C99 7.18.2.5 Limits of greatest-width integer types. */ + +/* C23 7.22.2.5 Width of greatest-width integer types. */ + +/* C99 7.18.3 Limits of other integer types. */ + +/* 7.18.4.2 Macros for greatest-width integer constants. */ + +/* C23 7.22.3.x Width of other integer types. */ + +/* +** The following macros are used to cast pointers to integers and +** integers to pointers. The way you do this varies from one compiler +** to the next, so we have developed the following set of #if statements +** to generate appropriate macros for a wide range of compilers. +** +** The correct "ANSI" way to do this is to use the intptr_t type. +** Unfortunately, that typedef is not available on all compilers, or +** if it is available, it requires an #include of specific headers +** that vary from one machine to the next. +** +** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on +** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)). +** So we have to define the macros in different ways depending on the +** compiler. + */ + +/* +** Macros to hint to the compiler that a function should or should not be +** inlined. + */ + +/* +** Make sure that the compiler intrinsics we desire are enabled when +** compiling with an appropriate version of MSVC unless prevented by +** the SQLITE_DISABLE_INTRINSIC define. + */ + +/* +** Enable SQLITE_USE_SEH by default on MSVC builds. Only omit +** SEH support if the -DSQLITE_OMIT_SEH option is given. + */ + +/* +** Enable SQLITE_DIRECT_OVERFLOW_READ, unless the build explicitly +** disables it using -DSQLITE_DIRECT_OVERFLOW_READ=0 + */ +/* In all other cases, enable */ + +/* +** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. +** 0 means mutexes are permanently disable and the library is never +** threadsafe. 1 means the library is serialized which is the highest +** level of threadsafety. 2 means the library is multithreaded - multiple +** threads can use SQLite as long as no two threads try to use the same +** database connection at the same time. +** +** Older versions of SQLite used an optional THREADSAFE macro. +** We support that for legacy. +** +** To ensure that the correct value of "THREADSAFE" is reported when querying +** for compile-time options at runtime (e.g. "PRAGMA compile_options"), this +** logic is partially replicated in ctime.c. If it is updated here, it should +** also be updated there. + */ + +/* +** Powersafe overwrite is on by default. But can be turned off using +** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option. + */ + +/* +** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by +** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in +** which case memory allocation statistics are disabled by default. + */ + +/* +** Exactly one of the following macros must be defined in order to +** specify which memory allocation subsystem to use. +** +** SQLITE_SYSTEM_MALLOC // Use normal system malloc() +** SQLITE_WIN32_MALLOC // Use Win32 native heap API +** SQLITE_ZERO_MALLOC // Use a stub allocator that always fails +** SQLITE_MEMDEBUG // Debugging version of system malloc() +** +** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the +** assert() macro is enabled, each call into the Win32 native heap subsystem +** will cause HeapValidate to be called. If heap validation should fail, an +** assertion will be triggered. +** +** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as +** the default. + */ + +/* +** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the +** sizes of memory allocations below this value where possible. + */ + +/* +** We need to define _XOPEN_SOURCE as follows in order to enable +** recursive mutexes on most Unix systems and fchmod() on OpenBSD. +** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit +** it. + */ + +/* +** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that +** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true, +** make it true by defining or undefining NDEBUG. +** +** Setting NDEBUG makes the code smaller and faster by disabling the +** assert() statements in the code. So we want the default action +** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG +** is set. Thus NDEBUG becomes an opt-in rather than an opt-out +** feature. + */ + +/* +** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on. + */ + +/* +** The testcase() macro is used to aid in coverage testing. When +** doing coverage testing, the condition inside the argument to +** testcase() must be evaluated both true and false in order to +** get full branch coverage. The testcase() macro is inserted +** to help ensure adequate test coverage in places where simple +** condition/decision coverage is inadequate. For example, testcase() +** can be used to make sure boundary values are tested. For +** bitmask tests, testcase() can be used to make sure each bit +** is significant and used at least once. On switch statements +** where multiple cases go to the same block of code, testcase() +** can insure that all cases are evaluated. + */ + +/* +** The TESTONLY macro is used to enclose variable declarations or +** other bits of code that are needed to support the arguments +** within testcase() and assert() macros. + */ + +/* +** Sometimes we need a small amount of code such as a variable initialization +** to setup for a later assert() statement. We do not want this code to +** appear when assert() is disabled. The following macro is therefore +** used to contain that setup code. The "VVA" acronym stands for +** "Verification, Validation, and Accreditation". In other words, the +** code within VVA_ONLY() will only run during verification processes. + */ + +/* +** Disable ALWAYS() and NEVER() (make them pass-throughs) for coverage +** and mutation testing + */ + +/* +** The ALWAYS and NEVER macros surround boolean expressions which +** are intended to always be true or false, respectively. Such +** expressions could be omitted from the code completely. But they +** are included in a few cases in order to enhance the resilience +** of SQLite to unexpected behavior - to make the code "self-healing" +** or "ductile" rather than being "brittle" and crashing at the first +** hint of unplanned behavior. +** +** In other words, ALWAYS and NEVER are added for defensive code. +** +** When doing coverage testing ALWAYS and NEVER are hard-coded to +** be true and false so that the unreachable code they specify will +** not be counted as untested code. + */ + +/* +** Some conditionals are optimizations only. In other words, if the +** conditionals are replaced with a constant 1 (true) or 0 (false) then +** the correct answer is still obtained, though perhaps not as quickly. +** +** The following macros mark these optimizations conditionals. + */ + +/* +** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is +** defined. We need to defend against those failures when testing with +** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches +** during a normal build. The following macro can be used to disable tests +** that are always false except when SQLITE_TEST_REALLOC_STRESS is set. + */ + +/* +** Declarations used for tracing the operating system interfaces. + */ + +/* +** Is the sqlite3ErrName() function needed in the build? Currently, +** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when +** OSTRACE is enabled), and by several "test*.c" files (which are +** compiled using SQLITE_TEST). + */ + +/* +** SQLITE_ENABLE_EXPLAIN_COMMENTS is incompatible with SQLITE_OMIT_EXPLAIN + */ + +/* +** SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTERTABLE + */ + +/* +** Return true (non-zero) if the input is an integer that is too large +** to fit in 32-bits. This macro is used inside of various testcase() +** macros to verify that we have tested SQLite for large-file support. + */ + +/* +** The macro unlikely() is a hint that surrounds a boolean +** expression that is usually false. Macro likely() surrounds +** a boolean expression that is usually true. These hints could, +** in theory, be used by the compiler to generate better code, but +** currently they are just comments for human readers. + */ + +/************** Include hash.h in the middle of sqliteInt.h ******************/ +/************** Begin file hash.h ********************************************/ +/* +** 2001 September 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This is the header file for the generic hash-table implementation +** used in SQLite. + */ + +type user_addr_t = Tuser_addr_t + +type user_long_t = Tuser_long_t + +type user_off_t = Tuser_off_t + +type user_size_t = Tuser_size_t + +type user_ssize_t = Tuser_ssize_t + +type user_time_t = Tuser_time_t + +type user_ulong_t = Tuser_ulong_t + +type uuid_t = Tuuid_t + +type vfs_server = Tvfs_server + +type vfsconf = Tvfsconf + +type vfsidctl = Tvfsidctl + +type vfsquery = Tvfsquery + +type vfsstatfs = Tvfsstatfs + +type vm_map_address_t = Tvm_map_address_t + +type vm_map_offset_t = Tvm_map_offset_t + +type vm_map_size_t = Tvm_map_size_t + +type vnode_t = Tvnode_t + +type vol_attributes_attr = Tvol_attributes_attr + +type vol_attributes_attr_t = Tvol_attributes_attr_t + +type vol_capabilities_attr = Tvol_capabilities_attr + +type vol_capabilities_attr_t = Tvol_capabilities_attr_t + +type vol_capabilities_set_t = Tvol_capabilities_set_t + +type wait = Twait + +type xucred = Txucred diff --git a/internal/engine/lib/sqlite_g_0000000000000007.go b/internal/engine/lib/sqlite_g_0000000000000007.go new file mode 100644 index 0000000..caf9554 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000007.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) + +package sqlite3 + +type Trune_t = int32 + +type rune_t = Trune_t diff --git a/internal/engine/lib/sqlite_g_000000000000000b.go b/internal/engine/lib/sqlite_g_000000000000000b.go new file mode 100644 index 0000000..6e124e6 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000000b.go @@ -0,0 +1,658 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Execute SQL code. Return one of the SQLITE_ success/failure +// ** codes. Also write an error message into memory obtained from +// ** malloc() and make *pzErrMsg point to that message. +// ** +// ** If the SQL is a query, then for each row in the query result +// ** the xCallback() function is called. pArg becomes the first +// ** argument to xCallback(). If xCallback=NULL then no callback +// ** is invoked, even for queries. +// */ +func Xsqlite3_exec(tls *libc.TLS, db uintptr, zSql uintptr, __ccgo_fp_xCallback Tsqlite3_callback, pArg uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azCols, azVals uintptr + var callbackIsInit, i, nCol, rc int32 + var _ /* pStmt at bp+8 */ uintptr + var _ /* zLeftover at bp+0 */ uintptr + _, _, _, _, _, _ = azCols, azVals, callbackIsInit, i, nCol, rc + rc = SQLITE_OK /* Tail of unprocessed SQL */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* The current SQL statement */ + azCols = uintptr(0) /* True if callback data is initialized */ + if !(_sqlite3SafetyCheckOk(tls, db) != 0) { + return _sqlite3MisuseError(tls, int32(142203)) + } + if zSql == uintptr(0) { + zSql = __ccgo_ts + 1702 + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3Error(tls, db, SQLITE_OK) + for rc == SQLITE_OK && **(**int8)(__ccgo_up(zSql)) != 0 { + nCol = 0 + azVals = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp+8, bp) + if rc != SQLITE_OK { + continue + } + if !(**(**uintptr)(__ccgo_up(bp + 8)) != 0) { + /* this happens for a comment or white-space */ + zSql = **(**uintptr)(__ccgo_up(bp)) + continue + } + callbackIsInit = 0 + for int32(1) != 0 { + rc = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) + /* Invoke the callback function if required */ + if __ccgo_fp_xCallback != 0 && (int32(SQLITE_ROW) == rc || int32(SQLITE_DONE) == rc && !(callbackIsInit != 0) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NullCallback) != 0) { + if !(callbackIsInit != 0) { + nCol = Xsqlite3_column_count(tls, **(**uintptr)(__ccgo_up(bp + 8))) + azCols = _sqlite3DbMallocRaw(tls, db, uint64(libc.Uint64FromInt32(libc.Int32FromInt32(2)*nCol+libc.Int32FromInt32(1))*uint64(8))) + if azCols == uintptr(0) { + goto exec_out + } + i = 0 + for { + if !(i < nCol) { + break + } + **(**uintptr)(__ccgo_up(azCols + uintptr(i)*8)) = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) + /* sqlite3VdbeSetColName() installs column names as UTF8 + ** strings so there is no way for sqlite3_column_name() to fail. */ + goto _1 + _1: + ; + i = i + 1 + } + callbackIsInit = int32(1) + } + if rc == int32(SQLITE_ROW) { + azVals = azCols + uintptr(nCol)*8 + i = 0 + for { + if !(i < nCol) { + break + } + **(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) + if !(**(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) != 0) && Xsqlite3_column_type(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) != int32(SQLITE_NULL) { + _sqlite3OomFault(tls, db) + goto exec_out + } + goto _2 + _2: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) = uintptr(0) + } + if (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xCallback})))(tls, pArg, nCol, azVals, azCols) != 0 { + /* EVIDENCE-OF: R-38229-40159 If the callback function to + ** sqlite3_exec() returns non-zero, then sqlite3_exec() will + ** return SQLITE_ABORT. */ + rc = int32(SQLITE_ABORT) + _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + _sqlite3Error(tls, db, int32(SQLITE_ABORT)) + goto exec_out + } + } + if rc != int32(SQLITE_ROW) { + rc = _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + zSql = **(**uintptr)(__ccgo_up(bp)) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zSql)))])&int32(0x01) != 0 { + zSql = zSql + 1 + } + break + } + } + _sqlite3DbFree(tls, db, azCols) + azCols = uintptr(0) + } + goto exec_out +exec_out: + ; + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + _sqlite3DbFree(tls, db, azCols) + rc = _sqlite3ApiExit(tls, db, rc) + if rc != SQLITE_OK && pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = _sqlite3DbStrDup(tls, uintptr(0), Xsqlite3_errmsg(tls, db)) + if **(**uintptr)(__ccgo_up(pzErrMsg)) == uintptr(0) { + rc = int32(SQLITE_NOMEM) + _sqlite3Error(tls, db, int32(SQLITE_NOMEM)) + } + } else { + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +func _fts5ConfigSkipLiteral(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + switch int32(**(**int8)(__ccgo_up(p))) { + case int32('n'): + fallthrough + case int32('N'): + if Xsqlite3_strnicmp(tls, __ccgo_ts+1688, p, int32(4)) == 0 { + p = p + 4 + } else { + p = uintptr(0) + } + case int32('x'): + fallthrough + case int32('X'): + p = p + 1 + if int32(**(**int8)(__ccgo_up(p))) == int32('\'') { + p = p + 1 + for int32(**(**int8)(__ccgo_up(p))) >= int32('a') && int32(**(**int8)(__ccgo_up(p))) <= int32('f') || int32(**(**int8)(__ccgo_up(p))) >= int32('A') && int32(**(**int8)(__ccgo_up(p))) <= int32('F') || int32(**(**int8)(__ccgo_up(p))) >= int32('0') && int32(**(**int8)(__ccgo_up(p))) <= int32('9') { + p = p + 1 + } + if int32(**(**int8)(__ccgo_up(p))) == int32('\'') && 0 == (int64(p)-int64(pIn))%int64(2) { + p = p + 1 + } else { + p = uintptr(0) + } + } else { + p = uintptr(0) + } + case int32('\''): + p = p + 1 + for p != 0 { + if int32(**(**int8)(__ccgo_up(p))) == int32('\'') { + p = p + 1 + if int32(**(**int8)(__ccgo_up(p))) != int32('\'') { + break + } + } + p = p + 1 + if int32(**(**int8)(__ccgo_up(p))) == 0 { + p = uintptr(0) + } + } + default: + /* maybe a number */ + if int32(**(**int8)(__ccgo_up(p))) == int32('+') || int32(**(**int8)(__ccgo_up(p))) == int32('-') { + p = p + 1 + } + for _fts5_isdigit(tls, **(**int8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + /* At this point, if the literal was an integer, the parse is + ** finished. Or, if it is a floating point value, it may continue + ** with either a decimal point or an 'E' character. */ + if int32(**(**int8)(__ccgo_up(p))) == int32('.') && _fts5_isdigit(tls, **(**int8)(__ccgo_up(p + 1))) != 0 { + p = p + uintptr(2) + for _fts5_isdigit(tls, **(**int8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + } + if p == pIn { + p = uintptr(0) + } + break + } + return p +} + +// C documentation +// +// /* c is a control character. Append the canonical JSON representation +// ** of that control character to p. +// ** +// ** This routine assumes that the output buffer has already been enlarged +// ** sufficiently to hold the worst-case encoding plus a nul terminator. +// */ +func _jsonAppendControlChar(tls *libc.TLS, p uintptr, c Tu8) { + if _aSpecial[c] != 0 { + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed))) = int8('\\') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(1)))) = _aSpecial[c] + **(**Tu64)(__ccgo_up(p + 24)) += uint64(2) + } else { + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed))) = int8('\\') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(1)))) = int8('u') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(2)))) = int8('0') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(3)))) = int8('0') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(4)))) = **(**int8)(__ccgo_up(__ccgo_ts + 1724 + uintptr(libc.Int32FromUint8(c)>>int32(4)))) + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(5)))) = **(**int8)(__ccgo_up(__ccgo_ts + 1724 + uintptr(libc.Int32FromUint8(c)&int32(0xf)))) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(6) + } +} + +// C documentation +// +// /* +// ** Expression p is a QNUMBER (quoted number). Dequote the value in p->u.zToken +// ** and set the type to INTEGER or FLOAT. "Quoted" integers or floats are those +// ** that contain '_' characters that must be removed before further processing. +// */ +func _sqlite3DequoteNumber(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bHex int32 + var pIn, pOut, v1, v3 uintptr + var _ /* iValue at bp+0 */ int32 + _, _, _, _, _ = bHex, pIn, pOut, v1, v3 + if p != 0 { + pIn = *(*uintptr)(unsafe.Pointer(p + 8)) + pOut = *(*uintptr)(unsafe.Pointer(p + 8)) + bHex = libc.BoolInt32(int32(**(**int8)(__ccgo_up(pIn))) == int32('0') && (int32(**(**int8)(__ccgo_up(pIn + 1))) == int32('x') || int32(**(**int8)(__ccgo_up(pIn + 1))) == int32('X'))) + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_INTEGER) + for { + if int32(**(**int8)(__ccgo_up(pIn))) != int32('_') { + v3 = pOut + pOut = pOut + 1 + **(**int8)(__ccgo_up(v3)) = **(**int8)(__ccgo_up(pIn)) + if int32(**(**int8)(__ccgo_up(pIn))) == int32('e') || int32(**(**int8)(__ccgo_up(pIn))) == int32('E') || int32(**(**int8)(__ccgo_up(pIn))) == int32('.') { + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_FLOAT) + } + } else { + if bHex == 0 && (!(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + uintptr(-libc.Int32FromInt32(1)))))])&libc.Int32FromInt32(0x04) != 0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + 1)))])&libc.Int32FromInt32(0x04) != 0)) || bHex == int32(1) && (!(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + uintptr(-libc.Int32FromInt32(1)))))])&libc.Int32FromInt32(0x08) != 0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + 1)))])&libc.Int32FromInt32(0x08) != 0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1788, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(p + 8)))) + } + } + goto _2 + _2: + ; + v1 = pIn + pIn = pIn + 1 + if !(**(**int8)(__ccgo_up(v1)) != 0) { + break + } + } + if bHex != 0 { + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_INTEGER) + } + /* tag-20240227-a: If after dequoting, the number is an integer that + ** fits in 32 bits, then it must be converted into EP_IntValue. Other + ** parts of the code expect this. See also tag-20240227-b. */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_INTEGER) && _sqlite3GetInt32(tls, *(*uintptr)(unsafe.Pointer(p + 8)), bp) != 0 { + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(p)).Fu)) = **(**int32)(__ccgo_up(bp)) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(EP_IntValue) + } + } +} + +// C documentation +// +// /* +// ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) +// ** +// ** Return a string described by FORMAT. Conversions as follows: +// ** +// ** %d day of month 01-31 +// ** %e day of month 1-31 +// ** %f ** fractional seconds SS.SSS +// ** %F ISO date. YYYY-MM-DD +// ** %G ISO year corresponding to %V 0000-9999. +// ** %g 2-digit ISO year corresponding to %V 00-99 +// ** %H hour 00-24 +// ** %k hour 0-24 (leading zero converted to space) +// ** %I hour 01-12 +// ** %j day of year 001-366 +// ** %J ** julian day number +// ** %l hour 1-12 (leading zero converted to space) +// ** %m month 01-12 +// ** %M minute 00-59 +// ** %p "AM" or "PM" +// ** %P "am" or "pm" +// ** %R time as HH:MM +// ** %s seconds since 1970-01-01 +// ** %S seconds 00-59 +// ** %T time as HH:MM:SS +// ** %u day of week 1-7 Monday==1, Sunday==7 +// ** %w day of week 0-6 Sunday==0, Monday==1 +// ** %U week of year 00-53 (First Sunday is start of week 01) +// ** %V week of year 01-53 (First week containing Thursday is week 01) +// ** %W week of year 00-53 (First Monday is start of week 01) +// ** %Y year 0000-9999 +// ** %% % +// */ +func _strftimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(208) + defer tls.Free(208) + var c, cf int8 + var db, zFmt, v3 uintptr + var h int32 + var i, j, v2 Tsize_t + var iS Ti64 + var s float64 + var _ /* sRes at bp+48 */ Tsqlite3_str + var _ /* x at bp+0 */ TDateTime + var _ /* y at bp+128 */ TDateTime + var _ /* y at bp+80 */ TDateTime + _, _, _, _, _, _, _, _, _, _, _ = c, cf, db, h, i, iS, j, s, zFmt, v2, v3 + if argc == 0 { + return + } + zFmt = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zFmt == uintptr(0) || _isDate(tls, context, argc-int32(1), argv+uintptr(1)*8, bp) != 0 { + return + } + db = Xsqlite3_context_db_handle(tls, context) + _sqlite3StrAccumInit(tls, bp+48, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up(db + 136))) + _computeJD(tls, bp) + _computeYMD_HMS(tls, bp) + v2 = libc.Uint64FromInt32(0) + j = v2 + i = v2 + for { + if !(**(**int8)(__ccgo_up(zFmt + uintptr(i))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(zFmt + uintptr(i)))) != int32('%') { + goto _1 + } + if j < i { + Xsqlite3_str_append(tls, bp+48, zFmt+uintptr(j), libc.Int32FromUint64(i-j)) + } + i = i + 1 + j = i + uint64(1) + cf = **(**int8)(__ccgo_up(zFmt + uintptr(i))) + switch int32(cf) { + case int32('d'): /* Fall thru */ + fallthrough + case int32('e'): + if int32(cf) == int32('d') { + v3 = __ccgo_ts + 1389 + } else { + v3 = __ccgo_ts + 1394 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FD)) + case int32('f'): /* Fractional seconds. (Non-standard) */ + s = (**(**TDateTime)(__ccgo_up(bp))).Fs + if s > float64(59.999) { + s = float64(59.999) + } + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1398, libc.VaList(bp+184, s)) + case int32('F'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1405, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FY, (**(**TDateTime)(__ccgo_up(bp))).FM, (**(**TDateTime)(__ccgo_up(bp))).FD)) + case int32('G'): /* Fall thru */ + fallthrough + case int32('g'): + **(**TDateTime)(__ccgo_up(bp + 80)) = **(**TDateTime)(__ccgo_up(bp)) + /* Move y so that it is the Thursday in the same week as x */ + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD += int64((int32(3) - _daysAfterMonday(tls, bp)) * int32(86400000)) + (**(**TDateTime)(__ccgo_up(bp + 80))).FvalidYMD = 0 + _computeYMD(tls, bp+80) + if int32(cf) == int32('g') { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1389, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp + 80))).FY%int32(100))) + } else { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1420, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp + 80))).FY)) + } + case int32('H'): + fallthrough + case int32('k'): + if int32(cf) == int32('H') { + v3 = __ccgo_ts + 1389 + } else { + v3 = __ccgo_ts + 1394 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh)) + case int32('I'): /* Fall thru */ + fallthrough + case int32('l'): + h = (**(**TDateTime)(__ccgo_up(bp))).Fh + if h > int32(12) { + h = h - int32(12) + } + if h == 0 { + h = int32(12) + } + if int32(cf) == int32('I') { + v3 = __ccgo_ts + 1389 + } else { + v3 = __ccgo_ts + 1394 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, h)) + case int32('j'): /* Day of year. Jan01==1, Jan02==2, and so forth */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1425, libc.VaList(bp+184, _daysAfterJan01(tls, bp)+int32(1))) + case int32('J'): /* Julian day number. (Non-standard) */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1430, libc.VaList(bp+184, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD)/float64(8.64e+07))) + case int32('m'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1389, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FM)) + case int32('M'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1389, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fm)) + case int32('p'): /* Fall thru */ + fallthrough + case int32('P'): + if (**(**TDateTime)(__ccgo_up(bp))).Fh >= int32(12) { + if int32(cf) == int32('p') { + v3 = __ccgo_ts + 1436 + } else { + v3 = __ccgo_ts + 1439 + } + Xsqlite3_str_append(tls, bp+48, v3, int32(2)) + } else { + if int32(cf) == int32('p') { + v3 = __ccgo_ts + 1442 + } else { + v3 = __ccgo_ts + 1445 + } + Xsqlite3_str_append(tls, bp+48, v3, int32(2)) + } + case int32('R'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1448, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm)) + case int32('s'): + if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1458, libc.VaList(bp+184, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD-libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000000))/float64(1000))) + } else { + iS = (**(**TDateTime)(__ccgo_up(bp))).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000) + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1463, libc.VaList(bp+184, iS)) + } + case int32('S'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1389, libc.VaList(bp+184, int32((**(**TDateTime)(__ccgo_up(bp))).Fs))) + case int32('T'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1468, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm, int32((**(**TDateTime)(__ccgo_up(bp))).Fs))) + case int32('u'): /* Day of week. 1 to 7. Monday==1, Sunday==7 */ + fallthrough + case int32('w'): /* Day of week. 0 to 6. Sunday==0, Monday==1 */ + c = int8(int32(int8(_daysAfterSunday(tls, bp))) + int32('0')) + if int32(c) == int32('0') && int32(cf) == int32('u') { + c = int8('7') + } + Xsqlite3_str_appendchar(tls, bp+48, int32(1), c) + case int32('U'): /* Week num. 00-53. First Sun of the year is week 01 */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1389, libc.VaList(bp+184, (_daysAfterJan01(tls, bp)-_daysAfterSunday(tls, bp)+int32(7))/int32(7))) + case int32('V'): /* Week num. 01-53. First week with a Thur is week 01 */ + **(**TDateTime)(__ccgo_up(bp + 128)) = **(**TDateTime)(__ccgo_up(bp)) + /* Adjust y so that is the Thursday in the same week as x */ + (**(**TDateTime)(__ccgo_up(bp + 128))).FiJD += int64((int32(3) - _daysAfterMonday(tls, bp)) * int32(86400000)) + (**(**TDateTime)(__ccgo_up(bp + 128))).FvalidYMD = 0 + _computeYMD(tls, bp+128) + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1389, libc.VaList(bp+184, _daysAfterJan01(tls, bp+128)/int32(7)+int32(1))) + case int32('W'): /* Week num. 00-53. First Mon of the year is week 01 */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1389, libc.VaList(bp+184, (_daysAfterJan01(tls, bp)-_daysAfterMonday(tls, bp)+int32(7))/int32(7))) + case int32('Y'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1420, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FY)) + case int32('%'): + Xsqlite3_str_appendchar(tls, bp+48, int32(1), int8('%')) + default: + Xsqlite3_str_reset(tls, bp+48) + return + } + goto _1 + _1: + ; + i = i + 1 + } + if j < i { + Xsqlite3_str_append(tls, bp+48, zFmt+uintptr(j), libc.Int32FromUint64(i-j)) + } + _sqlite3ResultStrAccum(tls, context, bp+48) +} + +// C documentation +// +// /* +// ** timediff(DATE1, DATE2) +// ** +// ** Return the amount of time that must be added to DATE2 in order to +// ** convert it into DATE2. The time difference format is: +// ** +// ** +YYYY-MM-DD HH:MM:SS.SSS +// ** +// ** The initial "+" becomes "-" if DATE1 occurs before DATE2. For +// ** date/time values A and B, the following invariant should hold: +// ** +// ** datetime(A) == (datetime(B, timediff(A,B)) +// ** +// ** Both DATE arguments must be either a julian day number, or an +// ** ISO-8601 string. The unix timestamps are not supported by this +// ** routine. +// */ +func _timediffFunc(tls *libc.TLS, context uintptr, NotUsed1 int32, argv uintptr) { + bp := tls.Alloc(192) + defer tls.Free(192) + var M, Y int32 + var sign int8 + var v1 uintptr + var _ /* d1 at bp+0 */ TDateTime + var _ /* d2 at bp+48 */ TDateTime + var _ /* sRes at bp+96 */ Tsqlite3_str + _, _, _, _ = M, Y, sign, v1 + _ = NotUsed1 + if _isDate(tls, context, int32(1), argv, bp) != 0 { + return + } + if _isDate(tls, context, int32(1), argv+1*8, bp+48) != 0 { + return + } + _computeYMD_HMS(tls, bp) + _computeYMD_HMS(tls, bp+48) + if (**(**TDateTime)(__ccgo_up(bp))).FiJD >= (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + sign = int8('+') + Y = (**(**TDateTime)(__ccgo_up(bp))).FY - (**(**TDateTime)(__ccgo_up(bp + 48))).FY + if Y != 0 { + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp))).FY + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = 0 + _computeJD(tls, bp+48) + } + M = (**(**TDateTime)(__ccgo_up(bp))).FM - (**(**TDateTime)(__ccgo_up(bp + 48))).FM + if M < 0 { + Y = Y - 1 + M = M + int32(12) + } + if M != 0 { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp))).FM + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = 0 + _computeJD(tls, bp+48) + } + for (**(**TDateTime)(__ccgo_up(bp))).FiJD < (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + M = M - 1 + if M < 0 { + M = int32(11) + Y = Y - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp + 48))).FM - 1 + if (**(**TDateTime)(__ccgo_up(bp + 48))).FM < int32(1) { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = int32(12) + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp + 48))).FY - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = 0 + _computeJD(tls, bp+48) + } + (**(**TDateTime)(__ccgo_up(bp))).FiJD -= (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD + v1 = bp + *(*Tsqlite3_int64)(unsafe.Pointer(v1)) = Tsqlite3_int64(uint64(*(*Tsqlite3_int64)(unsafe.Pointer(v1))) + libc.Uint64FromInt32(1486995408)*libc.Uint64FromInt32(100000)) + } else { /* d1 (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + M = M - 1 + if M < 0 { + M = int32(11) + Y = Y - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp + 48))).FM + 1 + if (**(**TDateTime)(__ccgo_up(bp + 48))).FM > int32(12) { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = int32(1) + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp + 48))).FY + 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = 0 + _computeJD(tls, bp+48) + } + (**(**TDateTime)(__ccgo_up(bp))).FiJD = (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD - (**(**TDateTime)(__ccgo_up(bp))).FiJD + v1 = bp + *(*Tsqlite3_int64)(unsafe.Pointer(v1)) = Tsqlite3_int64(uint64(*(*Tsqlite3_int64)(unsafe.Pointer(v1))) + libc.Uint64FromInt32(1486995408)*libc.Uint64FromInt32(100000)) + } + _clearYMD_HMS_TZ(tls, bp) + _computeYMD_HMS(tls, bp) + _sqlite3StrAccumInit(tls, bp+96, uintptr(0), uintptr(0), 0, int32(100)) + Xsqlite3_str_appendf(tls, bp+96, __ccgo_ts+1483, libc.VaList(bp+136, int32(sign), Y, M, (**(**TDateTime)(__ccgo_up(bp))).FD-int32(1), (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm, (**(**TDateTime)(__ccgo_up(bp))).Fs)) + _sqlite3ResultStrAccum(tls, context, bp+96) +} + +// C documentation +// +// /* +// ** Turn a relative pathname into a full pathname. The relative path +// ** is stored as a nul-terminated string in the buffer pointed to by +// ** zPath. +// ** +// ** zOut points to a buffer of at least sqlite3_vfs.mxPathname bytes +// ** (in this case, MAX_PATHNAME bytes). The full-path is written to +// ** this buffer before returning. +// */ +func _unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) (r int32) { + bp := tls.Alloc(1056) + defer tls.Free(1056) + var _ /* path at bp+0 */ TDbPath + var _ /* zPwd at bp+24 */ [1026]int8 + _ = pVfs + (**(**TDbPath)(__ccgo_up(bp))).Frc = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnUsed = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnSymlink = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnOut = nOut + (**(**TDbPath)(__ccgo_up(bp))).FzOut = zOut + if int32(**(**int8)(__ccgo_up(zPath))) != int32('/') { + if (*(*func(*libc.TLS, uintptr, Tsize_t) uintptr)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(3)].FpCurrent})))(tls, bp+24, libc.Uint64FromInt64(1026)-libc.Uint64FromInt32(2)) == uintptr(0) { + return _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47211)), __ccgo_ts+3558, zPath, int32(47211)) + } + _appendAllPathElements(tls, bp, bp+24) + } + _appendAllPathElements(tls, bp, zPath) + **(**int8)(__ccgo_up(zOut + uintptr((**(**TDbPath)(__ccgo_up(bp))).FnUsed))) = 0 + if (**(**TDbPath)(__ccgo_up(bp))).Frc != 0 || (**(**TDbPath)(__ccgo_up(bp))).FnUsed < int32(2) { + return _sqlite3CantopenError(tls, int32(47217)) + } + if (**(**TDbPath)(__ccgo_up(bp))).FnSymlink != 0 { + return libc.Int32FromInt32(SQLITE_OK) | libc.Int32FromInt32(2)< float64(0.999) { + ms = float64(0.999) + } + } + } else { + **(**int32)(__ccgo_up(bp + 8)) = 0 + } + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = int8(1) + (*TDateTime)(unsafe.Pointer(p)).Fh = **(**int32)(__ccgo_up(bp)) + (*TDateTime)(unsafe.Pointer(p)).Fm = **(**int32)(__ccgo_up(bp + 4)) + (*TDateTime)(unsafe.Pointer(p)).Fs = float64(**(**int32)(__ccgo_up(bp + 8))) + ms + if _parseTimezone(tls, zDate, p) != 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Parse a timezone extension on the end of a date-time. +// ** The extension is of the form: +// ** +// ** (+/-)HH:MM +// ** +// ** Or the "zulu" notation: +// ** +// ** Z +// ** +// ** If the parse is successful, write the number of minutes +// ** of change in p->tz and return 0. If a parser error occurs, +// ** return non-zero. +// ** +// ** A missing specifier is not considered an error. +// */ +func _parseTimezone(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, sgn int32 + var _ /* nHr at bp+0 */ int32 + var _ /* nMn at bp+4 */ int32 + _, _ = c, sgn + sgn = 0 + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 { + zDate = zDate + 1 + } + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + c = int32(**(**int8)(__ccgo_up(zDate))) + if c == int32('-') { + sgn = -int32(1) + } else { + if c == int32('+') { + sgn = +libc.Int32FromInt32(1) + } else { + if c == int32('Z') || c == int32('z') { + zDate = zDate + 1 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + goto zulu_time + } else { + return libc.BoolInt32(c != 0) + } + } + } + zDate = zDate + 1 + if _getDigits(tls, zDate, __ccgo_ts+1194, libc.VaList(bp+16, bp, bp+4)) != int32(2) { + return int32(1) + } + zDate = zDate + uintptr(5) + (*TDateTime)(unsafe.Pointer(p)).Ftz = sgn * (**(**int32)(__ccgo_up(bp + 4)) + **(**int32)(__ccgo_up(bp))*int32(60)) + if (*TDateTime)(unsafe.Pointer(p)).Ftz == 0 { /* Forum post 2025-09-17T10:12:14z */ + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + } + goto zulu_time +zulu_time: + ; + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 { + zDate = zDate + 1 + } + return libc.BoolInt32(int32(**(**int8)(__ccgo_up(zDate))) != 0) +} + +// C documentation +// +// /* +// ** Parse dates of the form +// ** +// ** YYYY-MM-DD HH:MM:SS.FFF +// ** YYYY-MM-DD HH:MM:SS +// ** YYYY-MM-DD HH:MM +// ** YYYY-MM-DD +// ** +// ** Write the result into the DateTime structure and return 0 +// ** on success and 1 if the input string is not a well-formed +// ** date. +// */ +func _parseYyyyMmDd(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var neg, v1 int32 + var _ /* D at bp+8 */ int32 + var _ /* M at bp+4 */ int32 + var _ /* Y at bp+0 */ int32 + _, _ = neg, v1 + if int32(**(**int8)(__ccgo_up(zDate))) == int32('-') { + zDate = zDate + 1 + neg = int32(1) + } else { + neg = 0 + } + if _getDigits(tls, zDate, __ccgo_ts+1214, libc.VaList(bp+24, bp, bp+4, bp+8)) != int32(3) { + return int32(1) + } + zDate = zDate + uintptr(10) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 || int32('T') == libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zDate))) { + zDate = zDate + 1 + } + if _parseHhMmSs(tls, zDate, p) == 0 { + /* We got the time */ + } else { + if int32(**(**int8)(__ccgo_up(zDate))) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = 0 + } else { + return int32(1) + } + } + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = int8(1) + if neg != 0 { + v1 = -**(**int32)(__ccgo_up(bp)) + } else { + v1 = **(**int32)(__ccgo_up(bp)) + } + (*TDateTime)(unsafe.Pointer(p)).FY = v1 + (*TDateTime)(unsafe.Pointer(p)).FM = **(**int32)(__ccgo_up(bp + 4)) + (*TDateTime)(unsafe.Pointer(p)).FD = **(**int32)(__ccgo_up(bp + 8)) + _computeFloor(tls, p) + if (*TDateTime)(unsafe.Pointer(p)).Ftz != 0 { + _computeJD(tls, p) + } + return 0 +} + +/* Forward declaration */ diff --git a/internal/engine/lib/sqlite_g_0000000000000012.go b/internal/engine/lib/sqlite_g_0000000000000012.go new file mode 100644 index 0000000..cb76144 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000012.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && arm) + +package sqlite3 + +const __ARM_NEON__ = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000000017.go b/internal/engine/lib/sqlite_g_0000000000000017.go new file mode 100644 index 0000000..d16559d --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000017.go @@ -0,0 +1,29 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && arm) + +package sqlite3 + +const __INT_FAST64_FMTd__ = "lld" + +const __INT_FAST64_FMTi__ = "lli" + +const __INT_LEAST64_FMTd__ = "lld" + +const __INT_LEAST64_FMTi__ = "lli" + +const __UINT_FAST64_FMTX__ = "llX" + +const __UINT_FAST64_FMTo__ = "llo" + +const __UINT_FAST64_FMTu__ = "llu" + +const __UINT_FAST64_FMTx__ = "llx" + +const __UINT_LEAST64_FMTX__ = "llX" + +const __UINT_LEAST64_FMTo__ = "llo" + +const __UINT_LEAST64_FMTu__ = "llu" + +const __UINT_LEAST64_FMTx__ = "llx" diff --git a/internal/engine/lib/sqlite_g_000000000000002b.go b/internal/engine/lib/sqlite_g_000000000000002b.go new file mode 100644 index 0000000..d8a1428 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000002b.go @@ -0,0 +1,721 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type Tvm_offset_t = uint64 + +type Tvm_size_t = uint64 + +const __INTMAX_FMTd__ = "ld" + +const __INTMAX_FMTi__ = "li" + +const __UINTMAX_FMTX__ = "lX" + +const __UINTMAX_FMTo__ = "lo" + +const __UINTMAX_FMTu__ = "lu" + +const __UINTMAX_FMTx__ = "lx" + +// C documentation +// +// /* +// ** Allocate and populate an sqlite3_index_info structure. It is the +// ** responsibility of the caller to eventually release the structure +// ** by passing the pointer returned by this function to freeIndexInfo(). +// */ +func _allocateIndexInfo(tls *libc.TLS, pWInfo uintptr, pWC uintptr, mUnusable TBitmask, pSrc uintptr, pmNoOmit uintptr) (r uintptr) { + var bSortByGroup, eDistinct, i, iCol, j, n, nLast, nOrderBy, nTerm, v10 int32 + var mNoOmit, op Tu16 + var p, pE2, pExpr, pExpr1, pHidden, pIdxCons, pIdxInfo, pIdxOrderBy, pOrderBy, pParse, pPk, pTab, pTerm, pUsage, zColl, v3 uintptr + var v12 uint32 + var v7 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bSortByGroup, eDistinct, i, iCol, j, mNoOmit, n, nLast, nOrderBy, nTerm, op, p, pE2, pExpr, pExpr1, pHidden, pIdxCons, pIdxInfo, pIdxOrderBy, pOrderBy, pParse, pPk, pTab, pTerm, pUsage, zColl, v10, v12, v3, v7 + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + mNoOmit = uint16(0) + eDistinct = 0 + pOrderBy = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy + pTab = (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab + /* Find all WHERE clause constraints referring to this virtual table. + ** Mark each term with the TERM_OK flag. Set nTerm to the number of + ** terms found. + */ + p = pWC + nTerm = libc.Int32FromInt32(0) + for { + if !(p != 0) { + break + } + i = 0 + pTerm = (*TWhereClause)(unsafe.Pointer(p)).Fa + for { + if !(i < (*TWhereClause)(unsafe.Pointer(p)).FnTerm) { + break + } + v3 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^libc.Int32FromInt32(TERM_OK)) + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { + goto _2 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&mUnusable != 0 { + goto _2 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & ^libc.Int32FromInt32(WO_EQUIV) == 0 { + goto _2 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VNULL) != 0 { + goto _2 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 && !(_constraintCompatibleWithOuterJoin(tls, pTerm, pSrc) != 0) { + goto _2 + } + nTerm = nTerm + 1 + v3 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(TERM_OK)) + goto _2 + _2: + ; + i = i + 1 + pTerm += 56 + } + goto _1 + _1: + ; + p = (*TWhereClause)(unsafe.Pointer(p)).FpOuter + } + /* If the ORDER BY clause contains only columns in the current + ** virtual table then allocate space for the aOrderBy part of + ** the sqlite3_index_info structure. + */ + nOrderBy = 0 + if pOrderBy != 0 { + n = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr + i = 0 + for { + if !(i < n) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).FpExpr + /* Skip over constant terms in the ORDER BY clause */ + if _sqlite3ExprIsConstant(tls, uintptr(0), pExpr) != 0 { + goto _5 + } + /* Virtual tables are unable to deal with NULLS FIRST */ + if libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_BIGNULL) != 0 { + break + } + /* First case - a direct column references without a COLLATE operator */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { + goto _5 + } + /* 2nd case - a column reference with a COLLATE operator. Only match + ** of the COLLATE operator matches the collation of the column. */ + if v7 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE); v7 { + v3 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pE2 = v3 + } + if v7 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(v3)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pE2)).FiTable == (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { /* The collating sequence name */ + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = (*TExpr)(unsafe.Pointer(pE2)).FiColumn + if int32((*TExpr)(unsafe.Pointer(pE2)).FiColumn) < 0 { + goto _5 + } /* Collseq does not matter for rowid */ + zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr((*TExpr)(unsafe.Pointer(pE2)).FiColumn)*16) + if zColl == uintptr(0) { + zColl = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), zColl) == 0 { + goto _5 + } + } + /* No matches cause a break out of the loop */ + break + goto _5 + _5: + ; + i = i + 1 + } + if i == n { + bSortByGroup = libc.BoolInt32(libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_SORTBYGROUP) != 0) + nOrderBy = n + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DISTINCTBY) != 0 && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x8000>>15) != 0) { + eDistinct = int32(2) + bSortByGroup + } else { + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_GROUPBY) != 0 { + eDistinct = int32(1) - bSortByGroup + } else { + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 { + eDistinct = int32(3) + } + } + } + } + } + /* Allocate the sqlite3_index_info structure + */ + pIdxInfo = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(96)+(libc.Uint64FromInt64(12)+libc.Uint64FromInt64(8))*libc.Uint64FromInt32(nTerm)+uint64(8)*libc.Uint64FromInt32(nOrderBy)+(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(nTerm)*uint64(8)))) + if pIdxInfo == uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1672, 0) + return uintptr(0) + } + pHidden = pIdxInfo + 1*96 + pIdxCons = pHidden + 32 + uintptr(nTerm)*8 + pIdxOrderBy = pIdxCons + uintptr(nTerm)*12 + pUsage = pIdxOrderBy + uintptr(nOrderBy)*8 + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint = pIdxCons + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy = pIdxOrderBy + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage = pUsage + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FcolUsed = libc.Uint64FromInt64(libc.Int64FromUint64((*TSrcItem)(unsafe.Pointer(pSrc)).FcolUsed)) + if libc.BoolInt32((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0)) == 0 { + /* Ensure that all bits associated with PK columns are set. This is to + ** ensure they are available for cases like RIGHT joins or OR loops. */ + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + iCol = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))) + if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + iCol = libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1) + } + **(**Tsqlite3_uint64)(__ccgo_up(pIdxInfo + 88)) |= libc.Uint64FromInt32(1) << iCol + goto _8 + _8: + ; + i = i + 1 + } + } + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FpWC = pWC + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FpParse = pParse + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FeDistinct = eDistinct + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FmIn = uint32(0) + p = pWC + v10 = libc.Int32FromInt32(0) + j = v10 + i = v10 + for { + if !(p != 0) { + break + } + nLast = i + (*TWhereClause)(unsafe.Pointer(p)).FnTerm + pTerm = (*TWhereClause)(unsafe.Pointer(p)).Fa + for { + if !(i < nLast) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_OK) == 0 { + goto _11 + } + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).FiColumn = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).FiTermOffset = i + op = libc.Uint16FromInt32(libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & int32(WO_ALL)) + if libc.Int32FromUint16(op) == int32(WO_IN) { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_SLICE) == 0 { + if j <= int32(31) { + v12 = libc.Uint32FromInt32(1) << j + } else { + v12 = uint32(0) + } + **(**Tu32)(__ccgo_up(pHidden + 20)) |= v12 + } + op = uint16(WO_EQ) + } + if libc.Int32FromUint16(op) == int32(WO_AUX) { + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).Fop = (*TWhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp + } else { + if libc.Int32FromUint16(op)&(libc.Int32FromInt32(WO_ISNULL)|libc.Int32FromInt32(WO_IS)) != 0 { + if libc.Int32FromUint16(op) == int32(WO_ISNULL) { + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).Fop = uint8(SQLITE_INDEX_CONSTRAINT_ISNULL) + } else { + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).Fop = uint8(SQLITE_INDEX_CONSTRAINT_IS) + } + } else { + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).Fop = uint8(op) + /* The direct assignment in the previous line is possible only because + ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The + ** following asserts verify this fact. */ + if libc.Int32FromUint16(op)&(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) != 0 && _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight) != 0 { + if j < int32(16) { + mNoOmit = libc.Uint16FromInt32(int32(mNoOmit) | libc.Int32FromInt32(1)<0 because +// ** cases of nByte<=0 will be intercepted and dealt with by higher level +// ** routines. +// */ +func _sqlite3MemMalloc(tls *libc.TLS, nByte int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p uintptr + _ = p + p = libc.Xmalloc(tls, libc.Uint64FromInt32(nByte+int32(8))) + if p != 0 { + **(**Tsqlite3_int64)(__ccgo_up(p)) = int64(nByte) + p += 8 + } else { + Xsqlite3_log(tls, int32(SQLITE_NOMEM), __ccgo_ts+1598, libc.VaList(bp+8, nByte)) + } + return p +} + +// C documentation +// +// /* +// ** Like realloc(). Resize an allocation previously obtained from +// ** sqlite3MemMalloc(). +// ** +// ** For this low-level interface, we know that pPrior!=0. Cases where +// ** pPrior==0 while have been intercepted by higher-level routine and +// ** redirected to xMalloc. Similarly, we know that nByte>0 because +// ** cases where nByte<=0 will have been intercepted by higher-level +// ** routines and redirected to xFree. +// */ +func _sqlite3MemRealloc(tls *libc.TLS, pPrior uintptr, nByte int32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p uintptr + _ = p + p = pPrior + /* EV: R-46199-30249 */ + p -= 8 + p = libc.Xrealloc(tls, p, libc.Uint64FromInt32(nByte+libc.Int32FromInt32(8))) + if p != 0 { + **(**Tsqlite3_int64)(__ccgo_up(p)) = int64(nByte) + p += 8 + } else { + Xsqlite3_log(tls, int32(SQLITE_NOMEM), __ccgo_ts+1636, libc.VaList(bp+8, _sqlite3MemSize(tls, pPrior), nByte)) + } + return p +} + +// C documentation +// +// /* +// ** Call this routine to record the fact that an OOM (out-of-memory) error +// ** has happened. This routine will set db->mallocFailed, and also +// ** temporarily disable the lookaside memory allocator and interrupt +// ** any running VDBEs. +// ** +// ** Always return a NULL pointer so that this routine can be invoked using +// ** +// ** return sqlite3OomFault(db); +// ** +// ** and thereby avoid unnecessary stack frame allocations for the overwhelmingly +// ** common case where no OOM occurs. +// */ +func _sqlite3OomFault(tls *libc.TLS, db uintptr) (r uintptr) { + var pParse uintptr + _ = pParse + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc) == 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed = uint8(1) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > 0 { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(1), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + if (*Tsqlite3)(unsafe.Pointer(db)).FpParse != 0 { + _sqlite3ErrorMsg(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpParse, __ccgo_ts+1672, 0) + (*TParse)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpParse)).Frc = int32(SQLITE_NOMEM) + pParse = (*TParse)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpParse)).FpOuterParse + for { + if !(pParse != 0) { + break + } + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + goto _1 + _1: + ; + pParse = (*TParse)(unsafe.Pointer(pParse)).FpOuterParse + } + } + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Set the value stored in *pMem should already be a NULL. +// ** Also store a pointer to go with it. +// */ +func _sqlite3VdbeMemSetPointer(tls *libc.TLS, pMem uintptr, pPtr uintptr, zPType uintptr, __ccgo_fp_xDestructor uintptr) { + var v1 uintptr + _ = v1 + _vdbeMemClear(tls, pMem) + if zPType != 0 { + v1 = zPType + } else { + v1 = __ccgo_ts + 1702 + } + *(*uintptr)(unsafe.Pointer(pMem)) = v1 + (*TMem)(unsafe.Pointer(pMem)).Fz = pPtr + (*TMem)(unsafe.Pointer(pMem)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Null) | libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Subtype) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pMem)).FeSubtype = uint8('p') + if __ccgo_fp_xDestructor != 0 { + v1 = __ccgo_fp_xDestructor + } else { + v1 = __ccgo_fp(_sqlite3NoopDestructor) + } + (*TMem)(unsafe.Pointer(pMem)).FxDel = v1 +} + +// C documentation +// +// /* +// ** The unhex() function. This function may be invoked with either one or +// ** two arguments. In both cases the first argument is interpreted as text +// ** a text value containing a set of pairs of hexadecimal digits which are +// ** decoded and returned as a blob. +// ** +// ** If there is only a single argument, then it must consist only of an +// ** even number of hexadecimal digits. Otherwise, return NULL. +// ** +// ** Or, if there is a second argument, then any character that appears in +// ** the second argument is also allowed to appear between pairs of hexadecimal +// ** digits in the first argument. If any other character appears in the +// ** first argument, or if one of the allowed characters appears between +// ** two hexadecimal digits that make up a single byte, NULL is returned. +// ** +// ** The following expressions are all true: +// ** +// ** unhex('ABCD') IS x'ABCD' +// ** unhex('AB CD') IS NULL +// ** unhex('AB CD', ' ') IS x'ABCD' +// ** unhex('A BCD', ' ') IS NULL +// */ +func _unhexFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, d, v2 Tu8 + var ch Tu32 + var nHex, nPass int32 + var p, pBlob, zPass, v1 uintptr + var v3 uint32 + var _ /* zHex at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = c, ch, d, nHex, nPass, p, pBlob, zPass, v1, v2, v3 + zPass = __ccgo_ts + 1702 + nPass = 0 + **(**uintptr)(__ccgo_up(bp)) = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + nHex = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + pBlob = uintptr(0) + p = uintptr(0) + if argc == int32(2) { + zPass = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + nPass = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } + if !(**(**uintptr)(__ccgo_up(bp)) != 0) || !(zPass != 0) { + return + } + v1 = _contextMalloc(tls, pCtx, int64(nHex/int32(2)+int32(1))) + pBlob = v1 + p = v1 + if pBlob != 0 { /* Least significant digit of next byte */ + for { + v2 = **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) + c = v2 + if !(libc.Int32FromUint8(v2) != 0x00) { + break + } + for !(libc.Int32FromUint8(_sqlite3CtypeMap[c])&libc.Int32FromInt32(0x08) != 0) { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) < int32(0x80) { + v1 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v3 = uint32(**(**Tu8)(__ccgo_up(v1))) + } else { + v3 = _sqlite3Utf8Read(tls, bp) + } + ch = v3 + if !(_strContainsChar(tls, zPass, nPass, ch) != 0) { + goto unhex_null + } + c = **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) + if libc.Int32FromUint8(c) == 0x00 { + goto unhex_done + } + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v1 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + d = **(**Tu8)(__ccgo_up(v1)) + if !(libc.Int32FromUint8(_sqlite3CtypeMap[d])&libc.Int32FromInt32(0x08) != 0) { + goto unhex_null + } + v1 = p + p = p + 1 + **(**Tu8)(__ccgo_up(v1)) = libc.Uint8FromInt32(libc.Int32FromUint8(_sqlite3HexToInt(tls, libc.Int32FromUint8(c)))<= csr2.peerVal ) goto lbl; +// ** +// ** The value of parameter op may also be OP_Gt or OP_Le. In these cases the +// ** operator in the above pseudo-code is replaced with ">" or "<=", respectively. +// ** +// ** If the sort-order for the ORDER BY term in the window is DESC, then the +// ** comparison is reversed. Instead of adding regVal to csr1.peerVal, it is +// ** subtracted. And the comparison operator is inverted to - ">=" becomes "<=", +// ** ">" becomes "<", and so on. So, with DESC sort order, if the argument op +// ** is OP_Ge, the generated code is equivalent to: +// ** +// ** if( csr1.peerVal - regVal <= csr2.peerVal ) goto lbl; +// ** +// ** A special type of arithmetic is used such that if csr1.peerVal is not +// ** a numeric type (real or integer), then the result of the addition +// ** or subtraction is a a copy of csr1.peerVal. +// */ +func _windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal int32, csr2 int32, lbl int32) { + var addr, addrDone, addrGe, arith, reg1, reg2, regString, v1 int32 + var pColl, pOrderBy, pParse, v, v2 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrDone, addrGe, arith, pColl, pOrderBy, pParse, reg1, reg2, regString, v, v1, v2 + pParse = (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse + v = _sqlite3GetVdbe(tls, pParse) + pOrderBy = (*TWindow)(unsafe.Pointer((*TWindowCodeArg)(unsafe.Pointer(p)).FpMWin)).FpOrderBy /* ORDER BY clause for window */ + reg1 = _sqlite3GetTempReg(tls, pParse) /* Reg. for csr1.peerVal+regVal */ + reg2 = _sqlite3GetTempReg(tls, pParse) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) /* Reg. for csr2.peerVal */ + regString = v1 /* Reg. for constant value '' */ + arith = int32(OP_Add) /* Jump destination */ + addrDone = _sqlite3VdbeMakeLabel(tls, pParse) + /* Read the peer-value from each cursor into a register */ + _windowReadPeerValues(tls, p, csr1, reg1) + _windowReadPeerValues(tls, p, csr2, reg2) + if libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_DESC) != 0 { + switch op { + case int32(OP_Ge): + op = int32(OP_Le) + case int32(OP_Gt): + op = int32(OP_Lt) + default: + op = int32(OP_Ge) + break + } + arith = int32(OP_Subtract) + } + /* If the BIGNULL flag is set for the ORDER BY, then it is required to + ** consider NULL values to be larger than all other values, instead of + ** the usual smaller. The VDBE opcodes OP_Ge and so on do not handle this + ** (and adding that capability causes a performance regression), so + ** instead if the BIGNULL flag is set then cases where either reg1 or + ** reg2 are NULL are handled separately in the following block. The code + ** generated is equivalent to: + ** + ** if( reg1 IS NULL ){ + ** if( op==OP_Ge ) goto lbl; + ** if( op==OP_Gt && reg2 IS NOT NULL ) goto lbl; + ** if( op==OP_Le && reg2 IS NULL ) goto lbl; + ** }else if( reg2 IS NULL ){ + ** if( op==OP_Le ) goto lbl; + ** } + ** + ** Additionally, if either reg1 or reg2 are NULL but the jump to lbl is + ** not taken, control jumps over the comparison operator coded below this + ** block. */ + if libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_BIGNULL) != 0 { + /* This block runs if reg1 contains a NULL. */ + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_NotNull), reg1) + switch op { + case int32(OP_Ge): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, lbl) + case int32(OP_Gt): + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), reg2, lbl) + case int32(OP_Le): + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), reg2, lbl) + default: /* no-op */ + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrDone) + /* This block runs if reg1 is not NULL, but reg2 is. */ + _sqlite3VdbeJumpHere(tls, v, addr) + if op == int32(OP_Gt) || op == int32(OP_Ge) { + v1 = addrDone + } else { + v1 = lbl + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), reg2, v1) + } + /* Register reg1 currently contains csr1.peerVal (the peer-value from csr1). + ** This block adds (or subtracts for DESC) the numeric value in regVal + ** from it. Or, if reg1 is not numeric (it is a NULL, a text value or a blob), + ** then leave reg1 as it is. In pseudo-code, this is implemented as: + ** + ** if( reg1>='' ) goto addrGe; + ** reg1 = reg1 +/- regVal + ** addrGe: + ** + ** Since all strings and blobs are greater-than-or-equal-to an empty string, + ** the add/subtract is skipped for these, as required. If reg1 is a NULL, + ** then the arithmetic is performed, but since adding or subtracting from + ** NULL is always NULL anyway, this case is handled as required too. */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, regString, 0, __ccgo_ts+1702, -int32(1)) + addrGe = _sqlite3VdbeAddOp3(tls, v, int32(OP_Ge), regString, 0, reg1) + if op == int32(OP_Ge) && arith == int32(OP_Add) || op == int32(OP_Le) && arith == int32(OP_Subtract) { + _sqlite3VdbeAddOp3(tls, v, op, reg2, lbl, reg1) + } + _sqlite3VdbeAddOp3(tls, v, arith, regVal, reg1, reg1) + _sqlite3VdbeJumpHere(tls, v, addrGe) + /* Compare registers reg2 and reg1, taking the jump if required. Note that + ** control skips over this test if the BIGNULL flag is set and either + ** reg1 or reg2 contain a NULL value. */ + _sqlite3VdbeAddOp3(tls, v, op, reg2, lbl, reg1) + pColl = _sqlite3ExprNNCollSeq(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8))).FpExpr) + _sqlite3VdbeAppendP4(tls, v, pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NULLEQ)) + _sqlite3VdbeResolveLabel(tls, v, addrDone) + _sqlite3ReleaseTempReg(tls, pParse, reg1) + _sqlite3ReleaseTempReg(tls, pParse, reg2) +} diff --git a/internal/engine/lib/sqlite_g_000000000000003f.go b/internal/engine/lib/sqlite_g_000000000000003f.go new file mode 100644 index 0000000..1000820 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000003f.go @@ -0,0 +1,1471 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const AT_RESOLVE_BENEATH = 8192 + +const ENOTSUP = 45 + +const IOCPARM_MAX = 8192 + +const MADV_FREE = 5 + +const MAP_RESERVED0080 = 128 + +const MINCORE_INCORE = 1 + +const MINCORE_MODIFIED = 4 + +const MINCORE_MODIFIED_OTHER = 16 + +const MINCORE_REFERENCED = 2 + +const MINCORE_REFERENCED_OTHER = 8 + +const NFDBITS = 0 + +const SF_NOUNLINK = 1048576 + +type T_RuneRange = struct { + F__nranges int32 + F__ranges uintptr +} + +type Tdl_info = TDl_info + +const UF_HIDDEN = 32768 + +const UTIME_NOW = -1 + +const UTIME_OMIT = -2 + +const _CACHED_RUNES = 256 + +const _CRMASK = -256 + +const _CTYPE_A = 256 + +const _CTYPE_B = 131072 + +const _CTYPE_C = 512 + +const _CTYPE_D = 1024 + +const _CTYPE_G = 2048 + +const _CTYPE_I = 524288 + +const _CTYPE_L = 4096 + +const _CTYPE_P = 8192 + +const _CTYPE_Q = 2097152 + +const _CTYPE_R = 262144 + +const _CTYPE_S = 16384 + +const _CTYPE_SW0 = 536870912 + +const _CTYPE_SW1 = 1073741824 + +const _CTYPE_SW2 = 2147483648 + +const _CTYPE_SW3 = 3221225472 + +const _CTYPE_SWM = 3758096384 + +const _CTYPE_SWS = 30 + +const _CTYPE_T = 1048576 + +const _CTYPE_U = 32768 + +const _CTYPE_X = 65536 + +const _POSIX2_FORT_RUN = 200112 + +const _POSIX_MEMLOCK = -1 + +const _POSIX_THREAD_PROCESS_SHARED = 200112 + +type _RuneEntry = T_RuneEntry + +type _RuneRange = T_RuneRange + +const _SC_2_PBS = 59 + +const _SC_2_PBS_ACCOUNTING = 60 + +const _SC_2_PBS_CHECKPOINT = 61 + +const _SC_2_PBS_LOCATE = 62 + +const _SC_2_PBS_MESSAGE = 63 + +const _SC_2_PBS_TRACK = 64 + +const _SC_ADVISORY_INFO = 65 + +const _SC_ASYNCHRONOUS_IO = 28 + +const _SC_ATEXIT_MAX = 107 + +const _SC_BARRIERS = 66 + +const _SC_CLOCK_SELECTION = 67 + +const _SC_CPUTIME = 68 + +const _SC_DELAYTIMER_MAX = 45 + +const _SC_FILE_LOCKING = 69 + +const _SC_FSYNC = 38 + +const _SC_GETGR_R_SIZE_MAX = 70 + +const _SC_GETPW_R_SIZE_MAX = 71 + +const _SC_HOST_NAME_MAX = 72 + +const _SC_IOV_MAX = 56 + +const _SC_IPV6 = 118 + +const _SC_LOGIN_NAME_MAX = 73 + +const _SC_MEMLOCK = 30 + +const _SC_MEMLOCK_RANGE = 31 + +const _SC_MEMORY_PROTECTION = 32 + +const _SC_MESSAGE_PASSING = 33 + +const _SC_MONOTONIC_CLOCK = 74 + +const _SC_MQ_OPEN_MAX = 46 + +const _SC_MQ_PRIO_MAX = 75 + +const _SC_NPROCESSORS_CONF = 57 + +const _SC_NPROCESSORS_ONLN = 58 + +const _SC_PRIORITIZED_IO = 34 + +const _SC_PRIORITY_SCHEDULING = 35 + +const _SC_RAW_SOCKETS = 119 + +const _SC_READER_WRITER_LOCKS = 76 + +const _SC_REALTIME_SIGNALS = 36 + +const _SC_REGEXP = 77 + +const _SC_RTSIG_MAX = 48 + +const _SC_SEMAPHORES = 37 + +const _SC_SEM_NSEMS_MAX = 49 + +const _SC_SEM_VALUE_MAX = 50 + +const _SC_SHARED_MEMORY_OBJECTS = 39 + +const _SC_SHELL = 78 + +const _SC_SIGQUEUE_MAX = 51 + +const _SC_SPAWN = 79 + +const _SC_SPIN_LOCKS = 80 + +const _SC_SPORADIC_SERVER = 81 + +const _SC_SYMLOOP_MAX = 120 + +const _SC_SYNCHRONIZED_IO = 40 + +const _SC_THREADS = 96 + +const _SC_THREAD_ATTR_STACKADDR = 82 + +const _SC_THREAD_ATTR_STACKSIZE = 83 + +const _SC_THREAD_CPUTIME = 84 + +const _SC_THREAD_DESTRUCTOR_ITERATIONS = 85 + +const _SC_THREAD_KEYS_MAX = 86 + +const _SC_THREAD_PRIORITY_SCHEDULING = 89 + +const _SC_THREAD_PRIO_INHERIT = 87 + +const _SC_THREAD_PRIO_PROTECT = 88 + +const _SC_THREAD_PROCESS_SHARED = 90 + +const _SC_THREAD_SAFE_FUNCTIONS = 91 + +const _SC_THREAD_SPORADIC_SERVER = 92 + +const _SC_THREAD_STACK_MIN = 93 + +const _SC_THREAD_THREADS_MAX = 94 + +const _SC_TIMEOUTS = 95 + +const _SC_TIMERS = 41 + +const _SC_TIMER_MAX = 52 + +const _SC_TRACE = 97 + +const _SC_TRACE_EVENT_FILTER = 98 + +const _SC_TRACE_INHERIT = 99 + +const _SC_TRACE_LOG = 100 + +const _SC_TTY_NAME_MAX = 101 + +const _SC_TYPED_MEMORY_OBJECTS = 102 + +const _SC_V6_ILP32_OFF32 = 103 + +const _SC_V6_ILP32_OFFBIG = 104 + +const _SC_V6_LP64_OFF64 = 105 + +const _SC_V6_LPBIG_OFFBIG = 106 + +const _SC_XOPEN_CRYPT = 108 + +const _SC_XOPEN_ENH_I18N = 109 + +const _SC_XOPEN_LEGACY = 110 + +const _SC_XOPEN_REALTIME = 111 + +const _SC_XOPEN_REALTIME_THREADS = 112 + +const _SC_XOPEN_SHM = 113 + +const _SC_XOPEN_STREAMS = 114 + +const _SC_XOPEN_UNIX = 115 + +const _SC_XOPEN_VERSION = 116 + +const _V6_ILP32_OFF32 = -1 + +const __SIGN = 32768 + +var _aDateTimeFuncs = [10]TFuncDef{ + 0: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1289, + }, + 1: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1309, + }, + 2: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1517, + }, + 3: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1522, + }, + 4: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1527, + }, + 5: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1536, + }, + 6: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1545, + }, + 7: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1554, + }, + 8: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1567, + }, + 9: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1585, + }, +} + +// C documentation +// +// /* +// ** Many system calls are accessed through pointer-to-functions so that +// ** they may be overridden at runtime to facilitate fault injection during +// ** testing and sandboxing. The following array holds the names and pointers +// ** to all overrideable system calls. +// */ +var _aSyscall = [29]Tunix_syscall{ + 0: { + FzName: __ccgo_ts + 3540, + }, + 1: { + FzName: __ccgo_ts + 3545, + }, + 2: { + FzName: __ccgo_ts + 3551, + }, + 3: { + FzName: __ccgo_ts + 3558, + }, + 4: { + FzName: __ccgo_ts + 3565, + }, + 5: { + FzName: __ccgo_ts + 3570, + }, + 6: { + FzName: __ccgo_ts + 3576, + }, + 7: { + FzName: __ccgo_ts + 3586, + }, + 8: { + FzName: __ccgo_ts + 3592, + }, + 9: { + FzName: __ccgo_ts + 3597, + }, + 10: { + FzName: __ccgo_ts + 3603, + }, + 11: { + FzName: __ccgo_ts + 3611, + }, + 12: { + FzName: __ccgo_ts + 3617, + }, + 13: { + FzName: __ccgo_ts + 3624, + }, + 14: { + FzName: __ccgo_ts + 3633, + }, + 15: { + FzName: __ccgo_ts + 3640, + }, + 16: { + FzName: __ccgo_ts + 3650, + }, + 17: { + FzName: __ccgo_ts + 3657, + }, + 18: { + FzName: __ccgo_ts + 3671, + }, + 19: { + FzName: __ccgo_ts + 3677, + }, + 20: { + FzName: __ccgo_ts + 3683, + }, + 21: { + FzName: __ccgo_ts + 3690, + }, + 22: { + FzName: __ccgo_ts + 3698, + }, + 23: { + FzName: __ccgo_ts + 3703, + }, + 24: { + FzName: __ccgo_ts + 3710, + }, + 25: { + FzName: __ccgo_ts + 3717, + }, + 26: { + FzName: __ccgo_ts + 3729, + }, + 27: { + FzName: __ccgo_ts + 3738, + }, + 28: { + FzName: __ccgo_ts + 3744, + }, +} + +var _azName = [192]uintptr{ + 0: __ccgo_ts + 1912, + 1: __ccgo_ts + 1922, + 2: __ccgo_ts + 1933, + 3: __ccgo_ts + 1945, + 4: __ccgo_ts + 1956, + 5: __ccgo_ts + 1968, + 6: __ccgo_ts + 1975, + 7: __ccgo_ts + 1983, + 8: __ccgo_ts + 1991, + 9: __ccgo_ts + 1996, + 10: __ccgo_ts + 2001, + 11: __ccgo_ts + 2007, + 12: __ccgo_ts + 2021, + 13: __ccgo_ts + 2027, + 14: __ccgo_ts + 2037, + 15: __ccgo_ts + 2042, + 16: __ccgo_ts + 2047, + 17: __ccgo_ts + 2050, + 18: __ccgo_ts + 2056, + 19: __ccgo_ts + 2063, + 20: __ccgo_ts + 2067, + 21: __ccgo_ts + 2077, + 22: __ccgo_ts + 2084, + 23: __ccgo_ts + 2091, + 24: __ccgo_ts + 2098, + 25: __ccgo_ts + 2105, + 26: __ccgo_ts + 2115, + 27: __ccgo_ts + 2124, + 28: __ccgo_ts + 2135, + 29: __ccgo_ts + 2144, + 30: __ccgo_ts + 2150, + 31: __ccgo_ts + 2160, + 32: __ccgo_ts + 2170, + 33: __ccgo_ts + 2175, + 34: __ccgo_ts + 2189, + 35: __ccgo_ts + 2200, + 36: __ccgo_ts + 2205, + 37: __ccgo_ts + 2212, + 38: __ccgo_ts + 2220, + 39: __ccgo_ts + 2231, + 40: __ccgo_ts + 2236, + 41: __ccgo_ts + 2241, + 42: __ccgo_ts + 2247, + 43: __ccgo_ts + 2253, + 44: __ccgo_ts + 2256, + 45: __ccgo_ts + 2260, + 46: __ccgo_ts + 2266, + 47: __ccgo_ts + 2272, + 48: __ccgo_ts + 2281, + 49: __ccgo_ts + 2292, + 50: __ccgo_ts + 2303, + 51: __ccgo_ts + 2311, + 52: __ccgo_ts + 2318, + 53: __ccgo_ts + 2326, + 54: __ccgo_ts + 2329, + 55: __ccgo_ts + 2332, + 56: __ccgo_ts + 2335, + 57: __ccgo_ts + 2338, + 58: __ccgo_ts + 2341, + 59: __ccgo_ts + 2344, + 60: __ccgo_ts + 2351, + 61: __ccgo_ts + 2360, + 62: __ccgo_ts + 2366, + 63: __ccgo_ts + 2376, + 64: __ccgo_ts + 2389, + 65: __ccgo_ts + 2400, + 66: __ccgo_ts + 2406, + 67: __ccgo_ts + 2413, + 68: __ccgo_ts + 2422, + 69: __ccgo_ts + 2431, + 70: __ccgo_ts + 2438, + 71: __ccgo_ts + 2451, + 72: __ccgo_ts + 2462, + 73: __ccgo_ts + 2467, + 74: __ccgo_ts + 2475, + 75: __ccgo_ts + 2481, + 76: __ccgo_ts + 2488, + 77: __ccgo_ts + 2500, + 78: __ccgo_ts + 2505, + 79: __ccgo_ts + 2514, + 80: __ccgo_ts + 2519, + 81: __ccgo_ts + 2528, + 82: __ccgo_ts + 2533, + 83: __ccgo_ts + 2538, + 84: __ccgo_ts + 2544, + 85: __ccgo_ts + 2552, + 86: __ccgo_ts + 2560, + 87: __ccgo_ts + 2570, + 88: __ccgo_ts + 2578, + 89: __ccgo_ts + 2585, + 90: __ccgo_ts + 2598, + 91: __ccgo_ts + 2603, + 92: __ccgo_ts + 2615, + 93: __ccgo_ts + 2623, + 94: __ccgo_ts + 2630, + 95: __ccgo_ts + 2641, + 96: __ccgo_ts + 2648, + 97: __ccgo_ts + 2655, + 98: __ccgo_ts + 2665, + 99: __ccgo_ts + 2674, + 100: __ccgo_ts + 2685, + 101: __ccgo_ts + 2691, + 102: __ccgo_ts + 2702, + 103: __ccgo_ts + 2712, + 104: __ccgo_ts + 2719, + 105: __ccgo_ts + 2725, + 106: __ccgo_ts + 2735, + 107: __ccgo_ts + 2746, + 108: __ccgo_ts + 2750, + 109: __ccgo_ts + 2759, + 110: __ccgo_ts + 2768, + 111: __ccgo_ts + 2775, + 112: __ccgo_ts + 2785, + 113: __ccgo_ts + 2792, + 114: __ccgo_ts + 2802, + 115: __ccgo_ts + 2811, + 116: __ccgo_ts + 2818, + 117: __ccgo_ts + 2828, + 118: __ccgo_ts + 2836, + 119: __ccgo_ts + 2844, + 120: __ccgo_ts + 2858, + 121: __ccgo_ts + 2872, + 122: __ccgo_ts + 2883, + 123: __ccgo_ts + 2896, + 124: __ccgo_ts + 2907, + 125: __ccgo_ts + 2913, + 126: __ccgo_ts + 2925, + 127: __ccgo_ts + 2934, + 128: __ccgo_ts + 2942, + 129: __ccgo_ts + 2951, + 130: __ccgo_ts + 2960, + 131: __ccgo_ts + 2967, + 132: __ccgo_ts + 2975, + 133: __ccgo_ts + 2982, + 134: __ccgo_ts + 2993, + 135: __ccgo_ts + 3007, + 136: __ccgo_ts + 3018, + 137: __ccgo_ts + 3026, + 138: __ccgo_ts + 3032, + 139: __ccgo_ts + 3040, + 140: __ccgo_ts + 3048, + 141: __ccgo_ts + 3058, + 142: __ccgo_ts + 3071, + 143: __ccgo_ts + 3081, + 144: __ccgo_ts + 3094, + 145: __ccgo_ts + 3103, + 146: __ccgo_ts + 3114, + 147: __ccgo_ts + 3122, + 148: __ccgo_ts + 3128, + 149: __ccgo_ts + 3140, + 150: __ccgo_ts + 3152, + 151: __ccgo_ts + 3160, + 152: __ccgo_ts + 3172, + 153: __ccgo_ts + 3185, + 154: __ccgo_ts + 3195, + 155: __ccgo_ts + 3200, + 156: __ccgo_ts + 3210, + 157: __ccgo_ts + 3222, + 158: __ccgo_ts + 3234, + 159: __ccgo_ts + 3244, + 160: __ccgo_ts + 3250, + 161: __ccgo_ts + 3260, + 162: __ccgo_ts + 3267, + 163: __ccgo_ts + 3279, + 164: __ccgo_ts + 3290, + 165: __ccgo_ts + 3298, + 166: __ccgo_ts + 3307, + 167: __ccgo_ts + 3316, + 168: __ccgo_ts + 3325, + 169: __ccgo_ts + 3332, + 170: __ccgo_ts + 3343, + 171: __ccgo_ts + 3356, + 172: __ccgo_ts + 3366, + 173: __ccgo_ts + 3373, + 174: __ccgo_ts + 3381, + 175: __ccgo_ts + 3390, + 176: __ccgo_ts + 3396, + 177: __ccgo_ts + 3403, + 178: __ccgo_ts + 3411, + 179: __ccgo_ts + 3419, + 180: __ccgo_ts + 3427, + 181: __ccgo_ts + 3437, + 182: __ccgo_ts + 3446, + 183: __ccgo_ts + 3457, + 184: __ccgo_ts + 3468, + 185: __ccgo_ts + 3479, + 186: __ccgo_ts + 3489, + 187: __ccgo_ts + 3495, + 188: __ccgo_ts + 3506, + 189: __ccgo_ts + 3517, + 190: __ccgo_ts + 3522, + 191: __ccgo_ts + 3530, +} + +var _azTypes = [5]uintptr{ + 0: __ccgo_ts + 1172, + 1: __ccgo_ts + 1184, + 2: __ccgo_ts + 1189, + 3: __ccgo_ts + 1167, + 4: __ccgo_ts + 1703, +} + +// C documentation +// +// /* +// ** The CONCAT(...) function. Generate a string result that is the +// ** concatentation of all non-null arguments. +// */ +func _concatFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + _concatFuncCore(tls, context, argc, argv, 0, __ccgo_ts+1702) +} + +// C documentation +// +// /* +// ** Lock the file with the lock specified by parameter eFileLock - one +// ** of the following: +// ** +// ** (1) SHARED_LOCK +// ** (2) RESERVED_LOCK +// ** (3) PENDING_LOCK +// ** (4) EXCLUSIVE_LOCK +// ** +// ** Sometimes when requesting one lock state, additional lock states +// ** are inserted in between. The locking might fail on one of the later +// ** transitions leaving the lock state different from what it started but +// ** still short of its goal. The following chart shows the allowed +// ** transitions and the inserted intermediate states: +// ** +// ** UNLOCKED -> SHARED +// ** SHARED -> RESERVED +// ** SHARED -> (PENDING) -> EXCLUSIVE +// ** RESERVED -> (PENDING) -> EXCLUSIVE +// ** PENDING -> EXCLUSIVE +// ** +// ** This routine will only increase a lock. Use the sqlite3OsUnlock() +// ** routine to lower a locking level. +// ** +// ** With dotfile locking, we really only support state (4): EXCLUSIVE. +// ** But we track the other locking levels internally. +// */ +func _dotlockLock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + var pFile, zLockFile uintptr + var rc, tErrno int32 + _, _, _, _ = pFile, rc, tErrno, zLockFile + pFile = id + zLockFile = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + rc = SQLITE_OK + /* If we have any lock, then the lock file already exists. All we have + ** to do is adjust our internal record of the lock level. + */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) > NO_LOCK { + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = libc.Uint8FromInt32(eFileLock) + /* Always update the timestamp on the old file */ + libc.Xutimes(tls, zLockFile, libc.UintptrFromInt32(0)) + return SQLITE_OK + } + /* grab an exclusive lock */ + rc = (*(*func(*libc.TLS, uintptr, Tmode_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(18)].FpCurrent})))(tls, zLockFile, uint16(0777)) + if rc < 0 { + /* failed to open/create the lock directory */ + tErrno = **(**int32)(__ccgo_up(libc.X__error(tls))) + if int32(EEXIST) == tErrno { + rc = int32(SQLITE_BUSY) + } else { + rc = _sqliteErrorFromPosixError(tls, tErrno, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(15)<iBtPage) is completed. +// ** +// ** The doclist-index for that term is currently stored in-memory within the +// ** Fts5SegWriter.aDlidx[] array. If it is large enough, this function +// ** writes it out to disk. Or, if it is too small to bother with, discards +// ** it. +// ** +// ** Fts5SegWriter.btterm currently contains the first term on page iBtPage. +// */ +func _fts5WriteFlushBtree(tls *libc.TLS, p uintptr, pWriter uintptr) { + var bFlag int32 + var z, v1 uintptr + _, _, _ = bFlag, z, v1 + if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage == 0 { + return + } + bFlag = _fts5WriteFlushDlidx(tls, p, pWriter) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn > 0 { + v1 = (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fp + } else { + v1 = __ccgo_ts + 1702 + } + z = v1 + /* The following was already done in fts5WriteInit(): */ + /* sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid); */ + Xsqlite3_bind_blob(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(2), z, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn, libc.UintptrFromInt32(0)) + Xsqlite3_bind_int64(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(3), int64(bFlag)+int64((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage)< 0 && (*TStrAccum)(unsafe.Pointer(pAccum)).FnChar == uint32(0) { + Xsqlite3_result_text(tls, context, __ccgo_ts+1702, int32(1), libc.UintptrFromInt32(0)) + } else { + zText = Xsqlite3_str_value(tls, pAccum) + Xsqlite3_result_text(tls, context, zText, libc.Int32FromUint32((*TStrAccum)(unsafe.Pointer(pAccum)).FnChar), uintptr(-libc.Int32FromInt32(1))) + } + } + } + } +} + +// C documentation +// +// /* +// ** Log an error that is an API call on a connection pointer that should +// ** not have been used. The "type" of connection pointer is given as the +// ** argument. The zType is a word like "NULL" or "closed" or "invalid". +// */ +func _logBadConnection(tls *libc.TLS, zType uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+1850, libc.VaList(bp+8, zType)) +} + +// C documentation +// +// /* +// ** Attempt to parse the given string into a julian day number. Return +// ** the number of errors. +// ** +// ** The following are acceptable forms for the input string: +// ** +// ** YYYY-MM-DD HH:MM:SS.FFF +/-HH:MM +// ** DDDD.DD +// ** now +// ** +// ** In the first form, the +/-HH:MM is always optional. The fractional +// ** seconds extension (the ".FFF") is optional. The seconds portion +// ** (":SS.FFF") is option. The year and date can be omitted as long +// ** as there is a time string. The time string can be omitted as long +// ** as there is a year and date. +// */ +func _parseDateOrTime(tls *libc.TLS, context uintptr, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* r at bp+0 */ float64 + if _parseYyyyMmDd(tls, zDate, p) == 0 { + return 0 + } else { + if _parseHhMmSs(tls, zDate, p) == 0 { + return 0 + } else { + if _sqlite3StrICmp(tls, zDate, __ccgo_ts+1226) == 0 && _sqlite3NotPureFunc(tls, context) != 0 { + return _setDateTimeToCurrent(tls, context, p) + } else { + if _sqlite3AtoF(tls, zDate, bp) > 0 { + _setRawDateNumber(tls, p, **(**float64)(__ccgo_up(bp))) + return 0 + } else { + if (_sqlite3StrICmp(tls, zDate, __ccgo_ts+1230) == 0 || _sqlite3StrICmp(tls, zDate, __ccgo_ts+1237) == 0) && _sqlite3NotPureFunc(tls, context) != 0 { + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 2, 0x4) + return _setDateTimeToCurrent(tls, context, p) + } + } + } + } + } + return int32(1) +} + +/* The julian day number for 9999-12-31 23:59:59.999 is 5373484.4999999. +** Multiplying this by 86400000 gives 464269060799999 as the maximum value +** for DateTime.iJD. +** +** But some older compilers (ex: gcc 4.2.1 on older Macs) cannot deal with +** such a large integer literal, so we have to encode it. + */ + +// C documentation +// +// /* +// ** Close a file descriptor. +// ** +// ** We assume that close() almost always works, since it is only in a +// ** very sick application or on a very sick platform that it might fail. +// ** If it does fail, simply leak the file descriptor, but do log the +// ** error. +// ** +// ** Note that it is not safe to retry close() after EINTR since the +// ** file descriptor might have already been reused by another thread. +// ** So we don't even try to recover from an EINTR. Just log the error +// ** and move on. +// */ +func _robust_close(tls *libc.TLS, pFile uintptr, h int32, lineno int32) { + var v1 uintptr + _ = v1 + if (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(1)].FpCurrent})))(tls, h) != 0 { + if pFile != 0 { + v1 = (*TunixFile)(unsafe.Pointer(pFile)).FzPath + } else { + v1 = uintptr(0) + } + _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(16)< SHARED +// ** SHARED -> RESERVED +// ** SHARED -> EXCLUSIVE +// ** RESERVED -> (PENDING) -> EXCLUSIVE +// ** PENDING -> EXCLUSIVE +// ** +// ** This routine will only increase a lock. Use the sqlite3OsUnlock() +// ** routine to lower a locking level. +// */ +func _unixLock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pFile, pInode uintptr + var rc, tErrno, v1 int32 + var _ /* lock at bp+0 */ Tflock + _, _, _, _, _ = pFile, pInode, rc, tErrno, v1 + /* The following describes the implementation of the various locks and + ** lock transitions in terms of the POSIX advisory shared and exclusive + ** lock primitives (called read-locks and write-locks below, to avoid + ** confusion with SQLite lock names). The algorithms are complicated + ** slightly in order to be compatible with Windows95 systems simultaneously + ** accessing the same database file, in case that is ever required. + ** + ** Symbols defined in os.h identify the 'pending byte' and the 'reserved + ** byte', each single bytes at well known offsets, and the 'shared byte + ** range', a range of 510 bytes at a well known offset. + ** + ** To obtain a SHARED lock, a read-lock is obtained on the 'pending + ** byte'. If this is successful, 'shared byte range' is read-locked + ** and the lock on the 'pending byte' released. (Legacy note: When + ** SQLite was first developed, Windows95 systems were still very common, + ** and Windows95 lacks a shared-lock capability. So on Windows95, a + ** single randomly selected by from the 'shared byte range' is locked. + ** Windows95 is now pretty much extinct, but this work-around for the + ** lack of shared-locks on Windows95 lives on, for backwards + ** compatibility.) + ** + ** A process may only obtain a RESERVED lock after it has a SHARED lock. + ** A RESERVED lock is implemented by grabbing a write-lock on the + ** 'reserved byte'. + ** + ** An EXCLUSIVE lock may only be requested after either a SHARED or + ** RESERVED lock is held. An EXCLUSIVE lock is implemented by obtaining + ** a write-lock on the entire 'shared byte range'. Since all other locks + ** require a read-lock on one of the bytes within this range, this ensures + ** that no other locks are held on the database. + ** + ** If a process that holds a RESERVED lock requests an EXCLUSIVE, then + ** a PENDING lock is obtained first. A PENDING lock is implemented by + ** obtaining a write-lock on the 'pending byte'. This ensures that no new + ** SHARED locks can be obtained, but existing SHARED locks are allowed to + ** persist. If the call to this function fails to obtain the EXCLUSIVE + ** lock in this case, it holds the PENDING lock instead. The client may + ** then re-attempt the EXCLUSIVE lock later on, after existing SHARED + ** locks have cleared. + */ + rc = SQLITE_OK + pFile = id + tErrno = 0 + /* If there is already a lock of this type or more restrictive on the + ** unixFile, do nothing. Don't use the end_lock: exit path, as + ** unixEnterMutex() hasn't been called yet. + */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) >= eFileLock { + return SQLITE_OK + } + /* Make sure the locking sequence is correct. + ** (1) We never move from unlocked to anything higher than shared lock. + ** (2) SQLite never explicitly requests a pending lock. + ** (3) A shared lock is always held when a reserve lock is requested. + */ + /* This mutex is needed because pFile->pInode is shared across threads + */ + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + /* If some thread using this PID has a lock via a different unixFile* + ** handle that precludes the requested lock, return BUSY. + */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) != libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) && (libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) >= int32(PENDING_LOCK) || eFileLock > int32(SHARED_LOCK)) { + rc = int32(SQLITE_BUSY) + goto end_lock + } + /* If a SHARED lock is requested, and some thread using this PID already + ** has a SHARED or RESERVED lock, then increment reference counts and + ** return SQLITE_OK. + */ + if eFileLock == int32(SHARED_LOCK) && (libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == int32(SHARED_LOCK) || libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == int32(RESERVED_LOCK)) { + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK) + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared + 1 + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock + 1 + goto end_lock + } + /* A PENDING lock is needed before acquiring a SHARED lock and before + ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will + ** be released. + */ + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = SEEK_SET + if eFileLock == int32(SHARED_LOCK) || eFileLock == int32(EXCLUSIVE_LOCK) && libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) == int32(RESERVED_LOCK) { + if eFileLock == int32(SHARED_LOCK) { + v1 = int32(F_RDLCK) + } else { + v1 = int32(F_WRLCK) + } + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(v1) + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte) + if _unixFileLock(tls, pFile, bp) != 0 { + tErrno = **(**int32)(__ccgo_up(libc.X__error(tls))) + rc = _sqliteErrorFromPosixError(tls, tErrno, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(15)< int32(1) { + /* We are trying for an exclusive lock but another thread in this + ** same process is still holding a shared lock. */ + rc = int32(SQLITE_BUSY) + } else { + if _unixIsSharingShmNode(tls, pFile) != 0 { + /* We are in WAL mode and attempting to delete the SHM and WAL + ** files due to closing the connection or changing out of WAL mode, + ** but another process still holds locks on the SHM file, thus + ** indicating that database locks have been broken, perhaps due + ** to a rogue close(open(dbFile)) or similar. + */ + rc = int32(SQLITE_BUSY) + } else { + /* The request was for a RESERVED or EXCLUSIVE lock. It is + ** assumed that there is a SHARED or greater lock on the file + ** already. + */ + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + if eFileLock == int32(RESERVED_LOCK) { + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(1)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + } else { + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(2)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(SHARED_SIZE) + } + if _unixFileLock(tls, pFile, bp) != 0 { + tErrno = **(**int32)(__ccgo_up(libc.X__error(tls))) + rc = _sqliteErrorFromPosixError(tls, tErrno, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(15)< 0 { + nByte = (nByte + int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk) - int64(1)) / int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk) * int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk) + } + rc = _robust_ftruncate(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, nByte) + if rc != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__error(tls)))) + return _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(6)<" (eCond==0) or "FOLLOWING " (eCond==1) or the +// ** value of the second argument to nth_value() (eCond==2) has just been +// ** evaluated and the result left in register reg. This function generates VM +// ** code to check that the value is a non-negative integer and throws an +// ** exception if it is not. +// */ +func _windowCheckValue(tls *libc.TLS, pParse uintptr, reg int32, eCond int32) { + var regString, regZero int32 + var v uintptr + _, _, _ = regString, regZero, v + v = _sqlite3GetVdbe(tls, pParse) + regZero = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regZero) + if eCond >= int32(WINDOW_STARTING_NUM) { + regString = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, regString, 0, __ccgo_ts+1702, -int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ge), regString, _sqlite3VdbeCurrentAddr(tls, v)+int32(2), reg) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(libc.Int32FromInt32(SQLITE_AFF_NUMERIC)|libc.Int32FromInt32(SQLITE_JUMPIFNULL))) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_MustBeInt), reg, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + } + _sqlite3VdbeAddOp3(tls, v, _aOp1[eCond], regZero, _sqlite3VdbeCurrentAddr(tls, v)+int32(2), reg) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_AFF_NUMERIC)) + /* NULL case captured by */ + /* the OP_MustBeInt */ + /* NULL case caught by */ + /* the OP_Ge */ + _sqlite3MayAbort(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), int32(SQLITE_ERROR), int32(OE_Abort)) + _sqlite3VdbeAppendP4(tls, v, _azErr[eCond], -int32(1)) + _sqlite3ReleaseTempReg(tls, pParse, regZero) +} + +type in_addr_t = Tin_addr_t + +type in_port_t = Tin_port_t + +type vm_offset_t = Tvm_offset_t + +type vm_size_t = Tvm_size_t diff --git a/internal/engine/lib/sqlite_g_0000000000000043.go b/internal/engine/lib/sqlite_g_0000000000000043.go new file mode 100644 index 0000000..972cfe7 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000043.go @@ -0,0 +1,63 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && 386) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Return TRUE if pFile has been renamed or unlinked since it was first opened. +// */ +func _fileHasMoved(tls *libc.TLS, pFile uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var _ /* buf at bp+0 */ Tstat + return libc.BoolInt32((*TunixFile)(unsafe.Pointer(pFile)).FpInode != uintptr(0) && ((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).FzPath, bp) != 0 || (**(**Tstat)(__ccgo_up(bp))).Fst_ino != (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FfileId.Fino)) +} + +// C documentation +// +// /* +// ** Memory map or remap the file opened by file-descriptor pFd (if the file +// ** is already mapped, the existing mapping is replaced by the new). Or, if +// ** there already exists a mapping for this file, and there are still +// ** outstanding xFetch() references to it, this function is a no-op. +// ** +// ** If parameter nByte is non-negative, then it is the requested size of +// ** the mapping to create. Otherwise, if nByte is less than zero, then the +// ** requested size is the size of the file on disk. The actual size of the +// ** created mapping is either the requested size or the value configured +// ** using SQLITE_FCNTL_MMAP_LIMIT, whichever is smaller. +// ** +// ** SQLITE_OK is returned if no error occurs (even if the mapping is not +// ** recreated as a result of outstanding references) or an SQLite error +// ** code otherwise. +// */ +func _unixMapfile(tls *libc.TLS, pFd uintptr, nMap Ti64) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var _ /* statbuf at bp+0 */ Tstat + if (*TunixFile)(unsafe.Pointer(pFd)).FnFetchOut > 0 { + return SQLITE_OK + } + if nMap < 0 { /* Low-level file information */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFd)).Fh, bp) != 0 { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)< (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeMax { + nMap = (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeMax + } + if nMap != (*TunixFile)(unsafe.Pointer(pFd)).FmmapSize { + _unixRemapfile(tls, pFd, nMap) + } + return SQLITE_OK +} diff --git a/internal/engine/lib/sqlite_g_00000000000000c0.go b/internal/engine/lib/sqlite_g_00000000000000c0.go new file mode 100644 index 0000000..9e30a1d --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000000c0.go @@ -0,0 +1,887 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const MAP_32BIT = 64 + +// C documentation +// +// /* +// ** Return TRUE if the given SQL string ends in a semicolon. +// ** +// ** Special handling is require for CREATE TRIGGER statements. +// ** Whenever the CREATE TRIGGER keywords are seen, the statement +// ** must end with ";END;". +// ** +// ** This implementation uses a state machine with 8 states: +// ** +// ** (0) INVALID We have not yet seen a non-whitespace character. +// ** +// ** (1) START At the beginning or end of an SQL statement. This routine +// ** returns 1 if it ends in the START state and 0 if it ends +// ** in any other state. +// ** +// ** (2) NORMAL We are in the middle of statement which ends with a single +// ** semicolon. +// ** +// ** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of +// ** a statement. +// ** +// ** (4) CREATE The keyword CREATE has been seen at the beginning of a +// ** statement, possibly preceded by EXPLAIN and/or followed by +// ** TEMP or TEMPORARY +// ** +// ** (5) TRIGGER We are in the middle of a trigger definition that must be +// ** ended by a semicolon, the keyword END, and another semicolon. +// ** +// ** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at +// ** the end of a trigger definition. +// ** +// ** (7) END We've seen the ";END" of the ";END;" that occurs at the end +// ** of a trigger definition. +// ** +// ** Transitions between states above are determined by tokens extracted +// ** from the input. The following tokens are significant: +// ** +// ** (0) tkSEMI A semicolon. +// ** (1) tkWS Whitespace. +// ** (2) tkOTHER Any other SQL token. +// ** (3) tkEXPLAIN The "explain" keyword. +// ** (4) tkCREATE The "create" keyword. +// ** (5) tkTEMP The "temp" or "temporary" keyword. +// ** (6) tkTRIGGER The "trigger" keyword. +// ** (7) tkEND The "end" keyword. +// ** +// ** Whitespace never causes a state transition and is always ignored. +// ** This means that a SQL string of all whitespace is invalid. +// ** +// ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed +// ** to recognize the end of a trigger can be omitted. All we have to do +// ** is look for a semicolon that is not part of an string or comment. +// */ +func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) (r int32) { + var c, nId int32 + var state, token Tu8 + _, _, _, _ = c, nId, state, token + state = uint8(0) /* Value of the next token */ + for **(**int8)(__ccgo_up(zSql)) != 0 { + switch int32(**(**int8)(__ccgo_up(zSql))) { + case int32(';'): /* A semicolon */ + token = uint8(tkSEMI) + case int32(' '): + fallthrough + case int32('\r'): + fallthrough + case int32('\t'): + fallthrough + case int32('\n'): + fallthrough + case int32('\f'): /* White space is ignored */ + token = uint8(tkWS) + case int32('/'): /* C-style comments */ + if int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('*') { + token = uint8(tkOTHER) + break + } + zSql = zSql + uintptr(2) + for **(**int8)(__ccgo_up(zSql)) != 0 && (int32(**(**int8)(__ccgo_up(zSql))) != int32('*') || int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('/')) { + zSql = zSql + 1 + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + return 0 + } + zSql = zSql + 1 + token = uint8(tkWS) + case int32('-'): /* SQL-style comments from "--" to end of line */ + if int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('-') { + token = uint8(tkOTHER) + break + } + for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != int32('\n') { + zSql = zSql + 1 + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + return libc.BoolInt32(libc.Int32FromUint8(state) == int32(1)) + } + token = uint8(tkWS) + case int32('['): /* Microsoft-style identifiers in [...] */ + zSql = zSql + 1 + for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != int32(']') { + zSql = zSql + 1 + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + return 0 + } + token = uint8(tkOTHER) + case int32('`'): /* Grave-accent quoted symbols used by MySQL */ + fallthrough + case int32('"'): /* single- and double-quoted strings */ + fallthrough + case int32('\''): + c = int32(**(**int8)(__ccgo_up(zSql))) + zSql = zSql + 1 + for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != c { + zSql = zSql + 1 + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + return 0 + } + token = uint8(tkOTHER) + default: + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zSql)))])&int32(0x46) != 0 { + nId = int32(1) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zSql + uintptr(nId))))])&int32(0x46) != 0) { + break + } + goto _1 + _1: + ; + nId = nId + 1 + } + switch int32(**(**int8)(__ccgo_up(zSql))) { + case int32('c'): + fallthrough + case int32('C'): + if nId == int32(6) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25188, int32(6)) == 0 { + token = uint8(tkCREATE) + } else { + token = uint8(tkOTHER) + } + case int32('t'): + fallthrough + case int32('T'): + if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+21842, int32(7)) == 0 { + token = uint8(tkTRIGGER) + } else { + if nId == int32(4) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25195, int32(4)) == 0 { + token = uint8(tkTEMP) + } else { + if nId == int32(9) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25200, int32(9)) == 0 { + token = uint8(tkTEMP) + } else { + token = uint8(tkOTHER) + } + } + } + case int32('e'): + fallthrough + case int32('E'): + if nId == int32(3) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25210, int32(3)) == 0 { + token = uint8(tkEND) + } else { + if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25214, int32(7)) == 0 { + token = uint8(tkEXPLAIN) + } else { + token = uint8(tkOTHER) + } + } + default: + token = uint8(tkOTHER) + break + } + zSql = zSql + uintptr(nId-int32(1)) + } else { + /* Operators and special symbols */ + token = uint8(tkOTHER) + } + break + } + state = **(**Tu8)(__ccgo_up(uintptr(unsafe.Pointer(&_trans)) + uintptr(state)*8 + uintptr(token))) + zSql = zSql + 1 + } + return libc.BoolInt32(libc.Int32FromUint8(state) == int32(1)) +} + +// C documentation +// +// /* +// ** Extra floating-point literals to allow in JSON. +// */ +var _aNanInfName = [5]TNanInfName{ + 0: { + Fc1: int8('i'), + Fc2: int8('I'), + Fn: int8(3), + FeType: int8(JSONB_FLOAT), + FnRepl: int8(7), + FzMatch: __ccgo_ts + 26408, + FzRepl: __ccgo_ts + 26412, + }, + 1: { + Fc1: int8('i'), + Fc2: int8('I'), + Fn: int8(8), + FeType: int8(JSONB_FLOAT), + FnRepl: int8(7), + FzMatch: __ccgo_ts + 26420, + FzRepl: __ccgo_ts + 26412, + }, + 2: { + Fc1: int8('n'), + Fc2: int8('N'), + Fn: int8(3), + FnRepl: int8(4), + FzMatch: __ccgo_ts + 1695, + FzRepl: __ccgo_ts + 1690, + }, + 3: { + Fc1: int8('q'), + Fc2: int8('Q'), + Fn: int8(4), + FnRepl: int8(4), + FzMatch: __ccgo_ts + 26429, + FzRepl: __ccgo_ts + 1690, + }, + 4: { + Fc1: int8('s'), + Fc2: int8('S'), + Fn: int8(4), + FnRepl: int8(4), + FzMatch: __ccgo_ts + 26434, + FzRepl: __ccgo_ts + 1690, + }, +} + +// C documentation +// +// /* +// ** Compare the 19-character string zNum against the text representation +// ** value 2^63: 9223372036854775808. Return negative, zero, or positive +// ** if zNum is less than, equal to, or greater than the string. +// ** Note that zNum must contain exactly 19 characters. +// ** +// ** Unlike memcmp() this routine is guaranteed to return the difference +// ** in the values of the last digit if the only difference is in the +// ** last digit. So, for example, +// ** +// ** compare2pow63("9223372036854775800", 1) +// ** +// ** will return -8. +// */ +func _compare2pow63(tls *libc.TLS, zNum uintptr, incr int32) (r int32) { + var c, i int32 + var pow63 uintptr + _, _, _ = c, i, pow63 + c = 0 + /* 012345678901234567 */ + pow63 = __ccgo_ts + 1815 + i = 0 + for { + if !(c == 0 && i < int32(18)) { + break + } + c = (int32(**(**int8)(__ccgo_up(zNum + uintptr(i*incr)))) - int32(**(**int8)(__ccgo_up(pow63 + uintptr(i))))) * int32(10) + goto _1 + _1: + ; + i = i + 1 + } + if c == 0 { + c = int32(**(**int8)(__ccgo_up(zNum + uintptr(int32(18)*incr)))) - int32('8') + } + return c +} + +// C documentation +// +// /* +// ** Process a "special" query. A special query is identified as one with a +// ** MATCH expression that begins with a '*' character. The remainder of +// ** the text passed to the MATCH operator are used as the special query +// ** parameters. +// */ +func _fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var n, rc int32 + var z uintptr + _, _, _ = n, rc, z + rc = SQLITE_OK /* Return code */ + z = zQuery /* Number of bytes in text at z */ + for int32(**(**int8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + n = 0 + for { + if !(**(**int8)(__ccgo_up(z + uintptr(n))) != 0 && int32(**(**int8)(__ccgo_up(z + uintptr(n)))) != int32(' ')) { + break + } + goto _1 + _1: + ; + n = n + 1 + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SPECIAL) + if n == int32(5) && 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+39750, z, n) { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = int64(_sqlite3Fts5IndexReads(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)) + } else { + if n == int32(2) && 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+5648, z, n) { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId + } else { + /* An unrecognized directive. Return an error message. */ + (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+39756, libc.VaList(bp+8, n, z)) + rc = int32(SQLITE_ERROR) + } + } + return rc +} + +// C documentation +// +// /* +// ** Interpret the given string as a temp db location. Return 1 for file +// ** backed temporary databases, 2 for the Red-Black tree in memory database +// ** and 0 to use the compile-time default. +// */ +func _getTempStore(tls *libc.TLS, z uintptr) (r int32) { + if int32(**(**int8)(__ccgo_up(z))) >= int32('0') && int32(**(**int8)(__ccgo_up(z))) <= int32('2') { + return int32(**(**int8)(__ccgo_up(z))) - int32('0') + } else { + if _sqlite3StrICmp(tls, z, __ccgo_ts+17992) == 0 { + return int32(1) + } else { + if _sqlite3StrICmp(tls, z, __ccgo_ts+19033) == 0 { + return int32(2) + } else { + return 0 + } + } + } + return r +} + +// C documentation +// +// /* +// ** Parse a complete JSON string. Return 0 on success or non-zero if there +// ** are any errors. If an error occurs, free all memory held by pParse, +// ** but not pParse itself. +// ** +// ** pParse must be initialized to an empty parse object prior to calling +// ** this routine. +// */ +func _jsonConvertTextToBlob(tls *libc.TLS, pParse uintptr, pCtx uintptr) (r int32) { + var i int32 + var zJson uintptr + _, _ = i, zJson + zJson = (*TJsonParse)(unsafe.Pointer(pParse)).FzJson + i = _jsonTranslateTextToBlob(tls, pParse, uint32(0)) + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + i = -int32(1) + } + if i > 0 { + for _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zJson + uintptr(i))))] != 0 { + i = i + 1 + } + if **(**int8)(__ccgo_up(zJson + uintptr(i))) != 0 { + i = i + _json5Whitespace(tls, zJson+uintptr(i)) + if **(**int8)(__ccgo_up(zJson + uintptr(i))) != 0 { + if pCtx != 0 { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26393, -int32(1)) + } + _jsonParseReset(tls, pParse) + return int32(1) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + } + if i <= 0 { + if pCtx != uintptr(0) { + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, pCtx) + } else { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26393, -int32(1)) + } + } + _jsonParseReset(tls, pParse) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF. +// ** The HH, MM, and SS must each be exactly 2 digits. The +// ** fractional seconds FFFF can be one or more digits. +// ** +// ** Return 1 if there is a parsing error and 0 on success. +// */ +func _parseHhMmSs(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var ms, rScale float64 + var _ /* h at bp+0 */ int32 + var _ /* m at bp+4 */ int32 + var _ /* s at bp+8 */ int32 + _, _ = ms, rScale + ms = float64(0) + if _getDigits(tls, zDate, __ccgo_ts+1204, libc.VaList(bp+24, bp, bp+4)) != int32(2) { + return int32(1) + } + zDate = zDate + uintptr(5) + if int32(**(**int8)(__ccgo_up(zDate))) == int32(':') { + zDate = zDate + 1 + if _getDigits(tls, zDate, __ccgo_ts+1212, libc.VaList(bp+24, bp+8)) != int32(1) { + return int32(1) + } + zDate = zDate + uintptr(2) + if int32(**(**int8)(__ccgo_up(zDate))) == int32('.') && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate + 1)))])&int32(0x04) != 0 { + rScale = float64(1) + zDate = zDate + 1 + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x04) != 0 { + ms = float64(ms*float64(10)) + float64(**(**int8)(__ccgo_up(zDate))) - libc.Float64FromUint8('0') + rScale = rScale * float64(10) + zDate = zDate + 1 + } + ms = ms / rScale + /* Truncate to avoid problems with sub-milliseconds + ** rounding. https://sqlite.org/forum/forumpost/766a2c9231 */ + if ms > float64(0.999) { + ms = float64(0.999) + } + } + } else { + **(**int32)(__ccgo_up(bp + 8)) = 0 + } + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = int8(1) + (*TDateTime)(unsafe.Pointer(p)).Fh = **(**int32)(__ccgo_up(bp)) + (*TDateTime)(unsafe.Pointer(p)).Fm = **(**int32)(__ccgo_up(bp + 4)) + (*TDateTime)(unsafe.Pointer(p)).Fs = float64(**(**int32)(__ccgo_up(bp + 8))) + ms + if _parseTimezone(tls, zDate, p) != 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Parse a timezone extension on the end of a date-time. +// ** The extension is of the form: +// ** +// ** (+/-)HH:MM +// ** +// ** Or the "zulu" notation: +// ** +// ** Z +// ** +// ** If the parse is successful, write the number of minutes +// ** of change in p->tz and return 0. If a parser error occurs, +// ** return non-zero. +// ** +// ** A missing specifier is not considered an error. +// */ +func _parseTimezone(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, sgn int32 + var _ /* nHr at bp+0 */ int32 + var _ /* nMn at bp+4 */ int32 + _, _ = c, sgn + sgn = 0 + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 { + zDate = zDate + 1 + } + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + c = int32(**(**int8)(__ccgo_up(zDate))) + if c == int32('-') { + sgn = -int32(1) + } else { + if c == int32('+') { + sgn = +libc.Int32FromInt32(1) + } else { + if c == int32('Z') || c == int32('z') { + zDate = zDate + 1 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + goto zulu_time + } else { + return libc.BoolInt32(c != 0) + } + } + } + zDate = zDate + 1 + if _getDigits(tls, zDate, __ccgo_ts+1196, libc.VaList(bp+16, bp, bp+4)) != int32(2) { + return int32(1) + } + zDate = zDate + uintptr(5) + (*TDateTime)(unsafe.Pointer(p)).Ftz = sgn * (**(**int32)(__ccgo_up(bp + 4)) + **(**int32)(__ccgo_up(bp))*int32(60)) + if (*TDateTime)(unsafe.Pointer(p)).Ftz == 0 { /* Forum post 2025-09-17T10:12:14z */ + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + } + goto zulu_time +zulu_time: + ; + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 { + zDate = zDate + 1 + } + return libc.BoolInt32(int32(**(**int8)(__ccgo_up(zDate))) != 0) +} + +// C documentation +// +// /* +// ** Parse dates of the form +// ** +// ** YYYY-MM-DD HH:MM:SS.FFF +// ** YYYY-MM-DD HH:MM:SS +// ** YYYY-MM-DD HH:MM +// ** YYYY-MM-DD +// ** +// ** Write the result into the DateTime structure and return 0 +// ** on success and 1 if the input string is not a well-formed +// ** date. +// */ +func _parseYyyyMmDd(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var neg, v1 int32 + var _ /* D at bp+8 */ int32 + var _ /* M at bp+4 */ int32 + var _ /* Y at bp+0 */ int32 + _, _ = neg, v1 + if int32(**(**int8)(__ccgo_up(zDate))) == int32('-') { + zDate = zDate + 1 + neg = int32(1) + } else { + neg = 0 + } + if _getDigits(tls, zDate, __ccgo_ts+1216, libc.VaList(bp+24, bp, bp+4, bp+8)) != int32(3) { + return int32(1) + } + zDate = zDate + uintptr(10) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 || int32('T') == libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zDate))) { + zDate = zDate + 1 + } + if _parseHhMmSs(tls, zDate, p) == 0 { + /* We got the time */ + } else { + if int32(**(**int8)(__ccgo_up(zDate))) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = 0 + } else { + return int32(1) + } + } + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = int8(1) + if neg != 0 { + v1 = -**(**int32)(__ccgo_up(bp)) + } else { + v1 = **(**int32)(__ccgo_up(bp)) + } + (*TDateTime)(unsafe.Pointer(p)).FY = v1 + (*TDateTime)(unsafe.Pointer(p)).FM = **(**int32)(__ccgo_up(bp + 4)) + (*TDateTime)(unsafe.Pointer(p)).FD = **(**int32)(__ccgo_up(bp + 8)) + _computeFloor(tls, p) + if (*TDateTime)(unsafe.Pointer(p)).Ftz != 0 { + _computeJD(tls, p) + } + return 0 +} + +/* Forward declaration */ + +// C documentation +// +// /* +// ** Allocate a private rbu VFS for the rbu handle passed as the only +// ** argument. This VFS will be used unless the call to sqlite3rbu_open() +// ** specified a URI with a vfs=? option in place of a target database +// ** file name. +// */ +func _rbuCreateVfs(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var pVfs uintptr + var _ /* rnd at bp+0 */ int32 + var _ /* zRnd at bp+4 */ [64]int8 + _ = pVfs + Xsqlite3_randomness(tls, int32(4), bp) + Xsqlite3_snprintf(tls, int32(64), bp+4, __ccgo_ts+34261, libc.VaList(bp+80, **(**int32)(__ccgo_up(bp)))) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3rbu_create_vfs(tls, bp+4, uintptr(0)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pVfs = Xsqlite3_vfs_find(tls, bp+4) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FzName + (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRbu = p + } +} + +// C documentation +// +// /* +// ** An error occurred while parsing or otherwise processing a database +// ** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an +// ** ALTER TABLE RENAME COLUMN program. The error message emitted by the +// ** sub-routine is currently stored in pParse->zErrMsg. This function +// ** adds context to the error message and then stores it in pCtx. +// */ +func _renameColumnParseError(tls *libc.TLS, pCtx uintptr, zWhen uintptr, pType uintptr, pObject uintptr, pParse uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var zErr, zN, zT, v1 uintptr + _, _, _, _ = zErr, zN, zT, v1 + zT = Xsqlite3_value_text(tls, pType) + zN = Xsqlite3_value_text(tls, pObject) + if **(**int8)(__ccgo_up(zWhen)) != 0 { + v1 = __ccgo_ts + 11541 + } else { + v1 = __ccgo_ts + 1704 + } + zErr = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+11543, libc.VaList(bp+8, zT, zN, v1, zWhen, (*TParse)(unsafe.Pointer(pParse)).FzErrMsg)) + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zErr) +} + +// C documentation +// +// /* IMP: R-25361-16150 This function is omitted from SQLite by default. It +// ** is only available if the SQLITE_SOUNDEX compile-time option is used +// ** when SQLite is built. +// */ +// /* +// ** Compute the soundex encoding of a word. +// ** +// ** IMP: R-59782-00072 The soundex(X) function returns a string that is the +// ** soundex encoding of the string X. +// */ +func _soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var code, i, j, v3 int32 + var prevcode Tu8 + var zIn uintptr + var _ /* zResult at bp+0 */ [8]int8 + _, _, _, _, _, _ = code, i, j, prevcode, zIn, v3 + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn == uintptr(0) { + zIn = __ccgo_ts + 1704 + } + i = 0 + for { + if !(**(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(zIn + uintptr(i)))])&libc.Int32FromInt32(0x02) != 0)) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if **(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0 { + prevcode = _iCode[libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i))))&int32(0x7f)] + (**(**[8]int8)(__ccgo_up(bp)))[0] = int8(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i)))) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(zIn + uintptr(i)))]) & libc.Int32FromInt32(0x20))) + j = int32(1) + for { + if !(j < int32(4) && **(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0) { + break + } + code = libc.Int32FromUint8(_iCode[libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i))))&int32(0x7f)]) + if code > 0 { + if code != libc.Int32FromUint8(prevcode) { + prevcode = libc.Uint8FromInt32(code) + v3 = j + j = j + 1 + (**(**[8]int8)(__ccgo_up(bp)))[v3] = int8(code + int32('0')) + } + } else { + prevcode = uint8(0) + } + goto _2 + _2: + ; + i = i + 1 + } + for j < int32(4) { + v3 = j + j = j + 1 + (**(**[8]int8)(__ccgo_up(bp)))[v3] = int8('0') + } + (**(**[8]int8)(__ccgo_up(bp)))[j] = 0 + Xsqlite3_result_text(tls, context, bp, int32(4), uintptr(-libc.Int32FromInt32(1))) + } else { + /* IMP: R-64894-50321 The string "?000" is returned if the argument + ** is NULL or contains no ASCII alphabetic characters. */ + Xsqlite3_result_text(tls, context, __ccgo_ts+16594, int32(4), libc.UintptrFromInt32(0)) + } +} + +func _sqlite3Fts5ParseSetDistance(tls *libc.TLS, pParse uintptr, pNear uintptr, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c int8 + var i, nNear int32 + _, _, _ = c, i, nNear + if pNear != 0 { + nNear = 0 + if (*TFts5Token)(unsafe.Pointer(p)).Fn != 0 { + i = 0 + for { + if !(i < (*TFts5Token)(unsafe.Pointer(p)).Fn) { + break + } + c = **(**int8)(__ccgo_up((*TFts5Token)(unsafe.Pointer(p)).Fp + uintptr(i))) + if int32(c) < int32('0') || int32(c) > int32('9') { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38541, libc.VaList(bp+8, (*TFts5Token)(unsafe.Pointer(p)).Fn, (*TFts5Token)(unsafe.Pointer(p)).Fp)) + return + } + if nNear < int32(214748363) { + nNear = nNear*int32(10) + (int32(**(**int8)(__ccgo_up((*TFts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))) - int32('0')) + } + /* ^^^^^^^^^^^^^^^--- Prevent integer overflow */ + goto _1 + _1: + ; + i = i + 1 + } + } else { + nNear = int32(FTS5_DEFAULT_NEARDIST) + } + (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnNear = nNear + } +} + +// C documentation +// +// /* +// ** Append to pStr text that is the SQL literal representation of the +// ** value contained in pValue. +// */ +func _sqlite3QuoteValue(tls *libc.TLS, pStr uintptr, pValue uintptr, bEscape int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var nBlob Ti64 + var zArg, zBlob, zText, v2 uintptr + _, _, _, _, _, _ = i, nBlob, zArg, zBlob, zText, v2 + /* As currently implemented, the string must be initially empty. + ** we might relax this requirement in the future, but that will + ** require enhancements to the implementation. */ + switch Xsqlite3_value_type(tls, pValue) { + case int32(SQLITE_FLOAT): + /* ,--- Show infinity as 9.0e+999 + ** | + ** | ,--- 17 precision guarantees round-trip + ** v v */ + Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+16559, libc.VaList(bp+8, Xsqlite3_value_double(tls, pValue))) + case int32(SQLITE_INTEGER): + Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+1465, libc.VaList(bp+8, Xsqlite3_value_int64(tls, pValue))) + case int32(SQLITE_BLOB): + zBlob = Xsqlite3_value_blob(tls, pValue) + nBlob = int64(Xsqlite3_value_bytes(tls, pValue)) + /* No encoding change */ + _sqlite3StrAccumEnlarge(tls, pStr, nBlob*int64(2)+int64(4)) + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(pStr)).FaccError) == 0 { + zText = (*TStrAccum)(unsafe.Pointer(pStr)).FzText + i = 0 + for { + if !(int64(i) < nBlob) { + break + } + **(**int8)(__ccgo_up(zText + uintptr(i*int32(2)+int32(2)))) = _hexdigits[int32(**(**int8)(__ccgo_up(zBlob + uintptr(i))))>>int32(4)&int32(0x0F)] + **(**int8)(__ccgo_up(zText + uintptr(i*int32(2)+int32(3)))) = _hexdigits[int32(**(**int8)(__ccgo_up(zBlob + uintptr(i))))&int32(0x0F)] + goto _1 + _1: + ; + i = i + 1 + } + **(**int8)(__ccgo_up(zText + uintptr(nBlob*int64(2)+int64(2)))) = int8('\'') + **(**int8)(__ccgo_up(zText + uintptr(nBlob*int64(2)+int64(3)))) = int8('\000') + **(**int8)(__ccgo_up(zText)) = int8('X') + **(**int8)(__ccgo_up(zText + 1)) = int8('\'') + (*TStrAccum)(unsafe.Pointer(pStr)).FnChar = libc.Uint32FromInt64(nBlob*int64(2) + int64(3)) + } + case int32(SQLITE_TEXT): + zArg = Xsqlite3_value_text(tls, pValue) + if bEscape != 0 { + v2 = __ccgo_ts + 16567 + } else { + v2 = __ccgo_ts + 11925 + } + Xsqlite3_str_appendf(tls, pStr, v2, libc.VaList(bp+8, zArg)) + default: + Xsqlite3_str_append(tls, pStr, __ccgo_ts+1705, int32(4)) + break + } +} + +// C documentation +// +// /* +// ** Create a temporary file name in zBuf. zBuf must be allocated +// ** by the calling process and must be big enough to hold at least +// ** pVfs->mxPathname bytes. +// */ +func _unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iLimit, rc, v1 int32 + var zDir uintptr + var v2 bool + var _ /* r at bp+0 */ Tu64 + _, _, _, _, _ = iLimit, rc, zDir, v1, v2 + iLimit = 0 + rc = SQLITE_OK + /* It's odd to simulate an io-error here, but really this is just + ** using the io-error infrastructure to test that SQLite handles this + ** function failing. + */ + **(**int8)(__ccgo_up(zBuf)) = 0 + Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + zDir = _unixTempFileDir(tls) + if zDir == uintptr(0) { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(25)< int32(10) { + rc = int32(SQLITE_ERROR) + break + } + } + } + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + return rc +} + +// C documentation +// +// /* +// ** The following code executes when a syntax error first occurs. +// */ +func _yy_syntax_error(tls *libc.TLS, yypParser uintptr, yymajor int32, _yyminor TToken) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*TToken)(unsafe.Pointer(bp)) = _yyminor + var pParse uintptr + _ = pParse + pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse + /************ Begin %syntax_error code ****************************************/ + _ = yymajor /* Silence some compiler warnings */ + if **(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp))).Fz)) != 0 { + _parserSyntaxError(tls, pParse, bp) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25135, 0) + } + /************ End %syntax_error code ******************************************/ + /* Suppress warning about unused %extra_argument variable */ + (*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse +} diff --git a/internal/engine/lib/sqlite_g_0000000000000202.go b/internal/engine/lib/sqlite_g_0000000000000202.go new file mode 100644 index 0000000..3a9b032 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000202.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (linux && arm64) + +package sqlite3 + +const __GCC_DESTRUCTIVE_SIZE = 256 diff --git a/internal/engine/lib/sqlite_g_0000000000000280.go b/internal/engine/lib/sqlite_g_0000000000000280.go new file mode 100644 index 0000000..342b61b --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000280.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (linux && arm64) + +package sqlite3 + +const __FLT16_IS_IEC_60559__ = 2 diff --git a/internal/engine/lib/sqlite_g_0000000000000300.go b/internal/engine/lib/sqlite_g_0000000000000300.go new file mode 100644 index 0000000..0cf4ad8 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000300.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm) || (linux && arm64) + +package sqlite3 + +const O_LARGEFILE = 131072 diff --git a/internal/engine/lib/sqlite_g_0000000000000330.go b/internal/engine/lib/sqlite_g_0000000000000330.go new file mode 100644 index 0000000..ce98bfb --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000330.go @@ -0,0 +1,11 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && arm) || (freebsd && arm64) || (linux && arm) || (linux && arm64) + +package sqlite3 + +type Twchar_t = uint32 + +const __WCHAR_MAX__ = 4294967295 + +type t__predefined_wchar_t = uint32 diff --git a/internal/engine/lib/sqlite_g_0000000000000332.go b/internal/engine/lib/sqlite_g_0000000000000332.go new file mode 100644 index 0000000..fe6d6d0 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000332.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && arm) || (freebsd && arm64) || (linux && arm) || (linux && arm64) + +package sqlite3 + +const __ARM_FEATURE_UNALIGNED = 1 diff --git a/internal/engine/lib/sqlite_g_000000000000033c.go b/internal/engine/lib/sqlite_g_000000000000033c.go new file mode 100644 index 0000000..47485ad --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000033c.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && arm) || (linux && arm64) + +package sqlite3 + +const O_DIRECT = 65536 diff --git a/internal/engine/lib/sqlite_g_0000000000000488.go b/internal/engine/lib/sqlite_g_0000000000000488.go new file mode 100644 index 0000000..3194aa2 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000000488.go @@ -0,0 +1,204 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (linux && amd64) || (linux && loong64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** This function is called to obtain a shared lock on the database file. +// ** It is illegal to call sqlite3PagerGet() until after this function +// ** has been successfully called. If a shared-lock is already held when +// ** this function is called, it is a no-op. +// ** +// ** The following operations are also performed by this function. +// ** +// ** 1) If the pager is currently in PAGER_OPEN state (no lock held +// ** on the database file), then an attempt is made to obtain a +// ** SHARED lock on the database file. Immediately after obtaining +// ** the SHARED lock, the file-system is checked for a hot-journal, +// ** which is played back if present. Following any hot-journal +// ** rollback, the contents of the cache are validated by checking +// ** the 'change-counter' field of the database file header and +// ** discarded if they are found to be invalid. +// ** +// ** 2) If the pager is running in exclusive-mode, and there are currently +// ** no outstanding references to any pages, and is in the error state, +// ** then an attempt is made to clear the error state by discarding +// ** the contents of the page cache and rolling back any open journal +// ** file. +// ** +// ** If everything is successful, SQLITE_OK is returned. If an IO error +// ** occurs while locking the database, checking for a hot-journal file or +// ** rolling back a journal file, the IO error code is returned. +// */ +func _sqlite3PagerSharedLock(tls *libc.TLS, pPager uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var f, rc int32 + var pVfs uintptr + var _ /* bExists at bp+4 */ int32 + var _ /* bHotJournal at bp+0 */ int32 + var _ /* dbFileVers at bp+12 */ [16]int8 + var _ /* fout at bp+8 */ int32 + _, _, _ = f, pVfs, rc + rc = SQLITE_OK /* Return code */ + /* This routine is only called from b-tree and only when there are no + ** outstanding pages. This implies that the pager state should either + ** be OPEN or READER. READER is only possible if the pager is or was in + ** exclusive access mode. */ + if !((*TPager)(unsafe.Pointer(pPager)).FpWal != libc.UintptrFromInt32(0)) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN { + **(**int32)(__ccgo_up(bp)) = int32(1) /* True if there exists a hot journal-file */ + rc = _pager_wait_on_lock(tls, pPager, int32(SHARED_LOCK)) + if rc != SQLITE_OK { + goto failed + } + /* If a journal file exists, and there is no RESERVED lock on the + ** database file, then it either needs to be played back or deleted. + */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) <= int32(SHARED_LOCK) { + rc = _hasHotJournal(tls, pPager, bp) + } + if rc != SQLITE_OK { + goto failed + } + if **(**int32)(__ccgo_up(bp)) != 0 { + if (*TPager)(unsafe.Pointer(pPager)).FreadOnly != 0 { + rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(3)< int32(1) { + for { + v2 = pPath + 20 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr(v1)))) != int32('/')) { + break + } + } + } + return + } + } + if (*TDbPath)(unsafe.Pointer(pPath)).FnUsed+nName+int32(2) >= (*TDbPath)(unsafe.Pointer(pPath)).FnOut { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = int32(SQLITE_ERROR) + return + } + v2 = pPath + 20 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr(v1))) = uint8('/') + libc.Xmemcpy(tls, (*TDbPath)(unsafe.Pointer(pPath)).FzOut+uintptr((*TDbPath)(unsafe.Pointer(pPath)).FnUsed), zName, libc.Uint64FromInt32(nName)) + **(**int32)(__ccgo_up(pPath + 20)) += nName + if (*TDbPath)(unsafe.Pointer(pPath)).Frc == SQLITE_OK { + **(**uint8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr((*TDbPath)(unsafe.Pointer(pPath)).FnUsed))) = uint8(0) + zIn = (*TDbPath)(unsafe.Pointer(pPath)).FzOut + if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(27)].FpCurrent})))(tls, zIn, bp) != 0 { + if **(**int32)(__ccgo_up(libc.X__errno_location(tls))) != int32(ENOENT) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47142)), __ccgo_ts+3740, zIn, int32(47142)) + } + } else { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFLNK) { + v2 = pPath + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + if v1 > int32(SQLITE_MAX_SYMLINK) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _sqlite3CantopenError(tls, int32(47148)) + return + } + got = (*(*func(*libc.TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(26)].FpCurrent})))(tls, zIn, bp+128, libc.Uint64FromInt64(4098)-libc.Uint64FromInt32(2)) + if got <= 0 || got >= libc.Int64FromInt64(4098)-libc.Int64FromInt32(2) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47153)), __ccgo_ts+3731, zIn, int32(47153)) + return + } + (**(**[4098]uint8)(__ccgo_up(bp + 128)))[got] = uint8(0) + if libc.Int32FromUint8((**(**[4098]uint8)(__ccgo_up(bp + 128)))[0]) == int32('/') { + (*TDbPath)(unsafe.Pointer(pPath)).FnUsed = 0 + } else { + **(**int32)(__ccgo_up(pPath + 20)) -= nName + int32(1) + } + _appendAllPathElements(tls, pPath, bp+128) + } + } + } +} + +// C documentation +// +// /* +// ** This function is called to handle the SQLITE_FCNTL_SIZE_HINT +// ** file-control operation. Enlarge the database to nBytes in size +// ** (rounded up to the next chunk-size). If the database is already +// ** nBytes or larger, this routine is a no-op. +// */ +func _fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte Ti64) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var iWrite, nSize Ti64 + var nBlk, nWrite, rc int32 + var _ /* buf at bp+0 */ Tstat + _, _, _, _, _ = iWrite, nBlk, nSize, nWrite, rc + if (*TunixFile)(unsafe.Pointer(pFile)).FszChunk > 0 { /* Used to hold return values of fstat() */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, bp) != 0 { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)< int64((**(**Tstat)(__ccgo_up(bp))).Fst_size) { + /* If the OS does not have posix_fallocate(), fake it. Write a + ** single byte to the last byte in each block that falls entirely + ** within the extended region. Then, if required, a single byte + ** at offset (nSize-1), to set the size of the file correctly. + ** This is a similar technique to that used by glibc on systems + ** that do not have a real fallocate() call. + */ + nBlk = (**(**Tstat)(__ccgo_up(bp))).Fst_blksize /* File-system block size */ + nWrite = 0 /* Next offset to write to */ + iWrite = int64((**(**Tstat)(__ccgo_up(bp))).Fst_size/int64(nBlk)*int64(nBlk) + int64(nBlk) - int64(1)) + for { + if !(iWrite < nSize+int64(nBlk)-int64(1)) { + break + } + if iWrite >= nSize { + iWrite = nSize - int64(1) + } + nWrite = _seekAndWrite(tls, pFile, iWrite, __ccgo_ts+1704, int32(1)) + if nWrite != int32(1) { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(3)< 0 && nByte > (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize { + if (*TunixFile)(unsafe.Pointer(pFile)).FszChunk <= 0 { + if _robust_ftruncate(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, nByte) != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__errno_location(tls)))) + return _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(6)<= int32(SQLITE_MINIMUM_FILE_DESCRIPTOR) { + break + } + if f&(libc.Int32FromInt32(O_EXCL)|libc.Int32FromInt32(O_CREAT)) == libc.Int32FromInt32(O_EXCL)|libc.Int32FromInt32(O_CREAT) { + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(16)].FpCurrent})))(tls, z) + } + (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(1)].FpCurrent})))(tls, fd) + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3752, libc.VaList(bp+136, z, fd)) + fd = -int32(1) + if (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[0].FpCurrent})))(tls, __ccgo_ts+3795, O_RDONLY, libc.Int32FromUint32(m)) < 0 { + break + } + } + if fd >= 0 { + if m != uint32(0) { + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, fd, bp) == 0 && (**(**Tstat)(__ccgo_up(bp))).Fst_size == 0 && (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(0777) != m { + (*(*func(*libc.TLS, int32, Tmode_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(14)].FpCurrent})))(tls, fd, m) + } + } + } + return fd +} + +// C documentation +// +// /* +// ** Open a shared-memory area associated with open database file pDbFd. +// ** This particular implementation uses mmapped files. +// ** +// ** The file used to implement shared-memory is in the same directory +// ** as the open database file and has the same name as the open database +// ** file with the "-shm" suffix added. For example, if the database file +// ** is "/home/user1/config.db" then the file that is created and mmapped +// ** for shared memory will be called "/home/user1/config.db-shm". +// ** +// ** Another approach to is to use files in /dev/shm or /dev/tmp or an +// ** some other tmpfs mount. But if a file in a different directory +// ** from the database file is used, then differing access permissions +// ** or a chroot() might cause two different processes on the same +// ** database to end up using different files for shared memory - +// ** meaning that their memory would not really be shared - resulting +// ** in database corruption. Nevertheless, this tmpfs file usage +// ** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY="/dev/shm" +// ** or the equivalent. The use of the SQLITE_SHM_DIRECTORY compile-time +// ** option results in an incompatible build of SQLite; builds of SQLite +// ** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the +// ** same database file at the same time, database corruption will likely +// ** result. The SQLITE_SHM_DIRECTORY compile-time option is considered +// ** "unsupported" and may go away in a future SQLite release. +// ** +// ** When opening a new shared-memory file, if no other instances of that +// ** file are currently open, in this process or in other processes, then +// ** the file must be truncated to zero length or have its header cleared. +// ** +// ** If the original database file (pDbFd) is using the "unix-excl" VFS +// ** that means that an exclusive lock is held on the database file and +// ** that no other processes are able to read or write the database. In +// ** that case, we do not really need shared memory. No shared memory +// ** file is created. The shared memory will be simulated with heap memory. +// */ +func _unixOpenSharedMemory(tls *libc.TLS, pDbFd uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var nShmFilename, rc int32 + var p, pInode, pShmNode, zBasePath, zShm, v1 uintptr + var _ /* sStat at bp+0 */ Tstat + _, _, _, _, _, _, _, _ = nShmFilename, p, pInode, pShmNode, rc, zBasePath, zShm, v1 + p = uintptr(0) /* The underlying mmapped file */ + rc = SQLITE_OK /* Size of the SHM filename in bytes */ + /* Allocate space for the new unixShm object. */ + p = Xsqlite3_malloc64(tls, uint64(24)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, p, 0, uint64(24)) + /* Check to see if a unixShmNode object already exists. Reuse an existing + ** one if present. Create a new one if necessary. + */ + _unixEnterMutex(tls) + pInode = (*TunixFile)(unsafe.Pointer(pDbFd)).FpInode + pShmNode = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpShmNode + if pShmNode == uintptr(0) { /* fstat() info for database file */ + zBasePath = (*TunixFile)(unsafe.Pointer(pDbFd)).FzPath + /* Call fstat() to figure out the permissions on the database file. If + ** a new *-shm file is created, an attempt will be made to create it + ** with the same permissions. + */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pDbFd)).Fh, bp) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)<pFirst. This must be done while holding the + ** pShmNode->pShmMutex. + */ + Xsqlite3_mutex_enter(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + (*TunixShm)(unsafe.Pointer(p)).FpNext = (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpFirst + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpFirst = p + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + return rc + /* Jump here on any error */ + goto shm_open_err +shm_open_err: + ; + _unixShmPurge(tls, pDbFd) /* This call frees pShmNode if required */ + Xsqlite3_free(tls, p) + _unixLeaveMutex(tls) + return rc +} + +// C documentation +// +// /* +// ** This function is called to obtain a pointer to region iRegion of the +// ** shared-memory associated with the database file fd. Shared-memory regions +// ** are numbered starting from zero. Each shared-memory region is szRegion +// ** bytes in size. +// ** +// ** If an error occurs, an error code is returned and *pp is set to NULL. +// ** +// ** Otherwise, if the bExtend parameter is 0 and the requested shared-memory +// ** region has not been allocated (by any client, including one running in a +// ** separate process), then *pp is set to NULL and SQLITE_OK returned. If +// ** bExtend is non-zero and the requested shared-memory region has not yet +// ** been allocated, it is allocated by this function. +// ** +// ** If the shared-memory region has already been allocated or is allocated by +// ** this call as described above, then it is mapped into this processes +// ** address space (if it is not already), *pp is set to point to the mapped +// ** memory and SQLITE_OK returned. +// */ +func _unixShmMap(tls *libc.TLS, fd uintptr, iRegion int32, szRegion int32, bExtend int32, pp uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var apNew, p, pDbFd, pMem, pShmNode, zFile, v4 uintptr + var i, iPg, nByte, nMap Ti64 + var nReqRegion, nShmPerMap, rc, v2 int32 + var _ /* sStat at bp+0 */ Tstat + var _ /* x at bp+128 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = apNew, i, iPg, nByte, nMap, nReqRegion, nShmPerMap, p, pDbFd, pMem, pShmNode, rc, zFile, v2, v4 + pDbFd = fd + rc = SQLITE_OK + nShmPerMap = _unixShmRegionPerMap(tls) + /* If the shared-memory file has not yet been opened, open it now. */ + if (*TunixFile)(unsafe.Pointer(pDbFd)).FpShm == uintptr(0) { + rc = _unixOpenSharedMemory(tls, pDbFd) + if rc != SQLITE_OK { + return rc + } + } + p = (*TunixFile)(unsafe.Pointer(pDbFd)).FpShm + pShmNode = (*TunixShm)(unsafe.Pointer(p)).FpShmNode + Xsqlite3_mutex_enter(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked != 0 { + rc = _unixLockSharedMemory(tls, pDbFd, pShmNode) + if rc != SQLITE_OK { + goto shmpage_out + } + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked = uint8(0) + } + /* Minimum number of regions required to be mapped. */ + nReqRegion = (iRegion + nShmPerMap) / nShmPerMap * nShmPerMap + if libc.Int32FromUint16((*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRegion) < nReqRegion { /* New apRegion[] array */ + nByte = int64(nReqRegion) * int64(szRegion) /* Used by fstat() */ + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FszRegion = szRegion + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0 { + /* The requested region is not mapped into this processes address space. + ** Check to see if it has been allocated (i.e. if the wal-index file is + ** large enough to contain the requested region). + */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, bp) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(19)<= 0 { + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 { + v2 = int32(PROT_READ) + } else { + v2 = libc.Int32FromInt32(PROT_READ) | libc.Int32FromInt32(PROT_WRITE) + } + pMem = (*(*func(*libc.TLS, uintptr, Tsize_t, int32, int32, int32, Toff_t) uintptr)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(22)].FpCurrent})))(tls, uintptr(0), libc.Uint64FromInt64(nMap), v2, int32(MAP_SHARED), (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(int64(szRegion)*libc.Int64FromUint16((*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRegion))) + if pMem == uintptr(-libc.Int32FromInt32(1)) { + rc = _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(21)< iRegion { + **(**uintptr)(__ccgo_up(pp)) = **(**uintptr)(__ccgo_up((*TunixShmNode)(unsafe.Pointer(pShmNode)).FapRegion + uintptr(iRegion)*8)) + } else { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 && rc == SQLITE_OK { + rc = int32(SQLITE_READONLY) + } + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + return rc +} + +// C documentation +// +// /* +// ** Check a unixFile that is a database. Verify the following: +// ** +// ** (1) There is exactly one hard link on the file +// ** (2) The file is not a symbolic link +// ** (3) The file has not been renamed or unlinked +// ** +// ** Issue sqlite3_log(SQLITE_WARNING,...) messages if anything is not right. +// */ +func _verifyDbFile(tls *libc.TLS, pFile uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var rc int32 + var _ /* buf at bp+0 */ Tstat + _ = rc + /* These verifications occurs for the main database only */ + if libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFile)).FctrlFlags)&int32(UNIXFILE_NOLOCK) != 0 { + return + } + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, bp) + if rc != 0 { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3836, libc.VaList(bp+136, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if (**(**Tstat)(__ccgo_up(bp))).Fst_nlink == uint32(0) { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3860, libc.VaList(bp+136, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if (**(**Tstat)(__ccgo_up(bp))).Fst_nlink > uint32(1) { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3889, libc.VaList(bp+136, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if _fileHasMoved(tls, pFile) != 0 { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3916, libc.VaList(bp+136, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } +} diff --git a/internal/engine/lib/sqlite_g_0000000000001600.go b/internal/engine/lib/sqlite_g_0000000000001600.go new file mode 100644 index 0000000..081007c --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000001600.go @@ -0,0 +1,294 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm64) || (linux && loong64) || (linux && riscv64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type Tstat = struct { + Fst_dev Tdev_t + Fst_ino Tino_t + Fst_mode Tmode_t + Fst_nlink Tnlink_t + Fst_uid Tuid_t + Fst_gid Tgid_t + Fst_rdev Tdev_t + F__pad uint64 + Fst_size Toff_t + Fst_blksize Tblksize_t + F__pad2 int32 + Fst_blocks Tblkcnt_t + Fst_atim Ttimespec + Fst_mtim Ttimespec + Fst_ctim Ttimespec + F__unused [2]uint32 +} + +// C documentation +// +// /* +// ** Return TRUE if pFile has been renamed or unlinked since it was first opened. +// */ +func _fileHasMoved(tls *libc.TLS, pFile uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* buf at bp+0 */ Tstat + return libc.BoolInt32((*TunixFile)(unsafe.Pointer(pFile)).FpInode != uintptr(0) && ((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).FzPath, bp) != 0 || uint64((**(**Tstat)(__ccgo_up(bp))).Fst_ino) != (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FfileId.Fino)) +} + +// C documentation +// +// /* +// ** Given a file descriptor, locate the unixInodeInfo object that +// ** describes that file descriptor. Create a new one if necessary. The +// ** return value might be uninitialized if an error occurs. +// ** +// ** The global mutex must held when calling this routine. +// ** +// ** Return an appropriate error code. +// */ +func _findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var fd, rc int32 + var pInode uintptr + var _ /* fileId at bp+0 */ TunixFileId + var _ /* statbuf at bp+16 */ Tstat + _, _, _ = fd, pInode, rc /* Low-level file information */ + pInode = uintptr(0) /* Candidate unixInodeInfo object */ + /* Get low-level information about the file that we can used to + ** create a unique name for the file. + */ + fd = (*TunixFile)(unsafe.Pointer(pFile)).Fh + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, fd, bp+16) + if rc != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__errno_location(tls)))) + return int32(SQLITE_IOERR) + } + libc.Xmemset(tls, bp, 0, uint64(16)) + (**(**TunixFileId)(__ccgo_up(bp))).Fdev = (**(**Tstat)(__ccgo_up(bp + 16))).Fst_dev + (**(**TunixFileId)(__ccgo_up(bp))).Fino = uint64((**(**Tstat)(__ccgo_up(bp + 16))).Fst_ino) + pInode = _inodeList + for pInode != 0 && libc.Xmemcmp(tls, bp, pInode, uint64(16)) != 0 { + pInode = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpNext + } + if pInode == uintptr(0) { + pInode = Xsqlite3_malloc64(tls, uint64(80)) + if pInode == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pInode, 0, uint64(80)) + libc.Xmemcpy(tls, pInode, bp, uint64(16)) + if _sqlite3Config.FbCoreMutex != 0 { + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) + if (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex == uintptr(0) { + Xsqlite3_free(tls, pInode) + return int32(SQLITE_NOMEM) + } + } + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnRef = int32(1) + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpNext = _inodeList + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpPrev = uintptr(0) + if _inodeList != 0 { + (*TunixInodeInfo)(unsafe.Pointer(_inodeList)).FpPrev = pInode + } + _inodeList = pInode + } else { + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnRef = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnRef + 1 + } + **(**uintptr)(__ccgo_up(ppInode)) = pInode + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Search for an unused file descriptor that was opened on the database +// ** file (not a journal or super-journal file) identified by pathname +// ** zPath with SQLITE_OPEN_XXX flags matching those passed as the second +// ** argument to this function. +// ** +// ** Such a file descriptor may exist if a database connection was closed +// ** but the associated file descriptor could not be closed because some +// ** other file descriptor open on the same file is holding a file-lock. +// ** Refer to comments in the unixClose() function and the lengthy comment +// ** describing "Posix Advisory Locking" at the start of this file for +// ** further details. Also, ticket #4018. +// ** +// ** If a suitable file descriptor is found, then it is returned. If no +// ** such file descriptor is located, -1 is returned. +// */ +func _findReusableFd(tls *libc.TLS, zPath uintptr, flags int32) (r uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var pInode, pUnused, pp uintptr + var _ /* sStat at bp+0 */ Tstat + _, _, _ = pInode, pUnused, pp + pUnused = uintptr(0) /* Results of stat() call */ + _unixEnterMutex(tls) + /* A stat() call may fail for various reasons. If this happens, it is + ** almost certain that an open() call on the same path will also fail. + ** For this reason, if an error occurs in the stat() call here, it is + ** ignored and -1 is returned. The caller will try to open a new file + ** descriptor on the same path, fail, and return an error to SQLite. + ** + ** Even if a subsequent open() call does succeed, the consequences of + ** not searching for a reusable file descriptor are not dire. */ + if _inodeList != uintptr(0) && 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zPath, bp) { + pInode = _inodeList + for pInode != 0 && ((*TunixInodeInfo)(unsafe.Pointer(pInode)).FfileId.Fdev != (**(**Tstat)(__ccgo_up(bp))).Fst_dev || (*TunixInodeInfo)(unsafe.Pointer(pInode)).FfileId.Fino != uint64((**(**Tstat)(__ccgo_up(bp))).Fst_ino)) { + pInode = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpNext + } + if pInode != 0 { + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + flags = flags & (libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE)) + pp = pInode + 40 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0 && (*TUnixUnusedFd)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).Fflags != flags) { + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 8 + } + pUnused = **(**uintptr)(__ccgo_up(pp)) + if pUnused != 0 { + **(**uintptr)(__ccgo_up(pp)) = (*TUnixUnusedFd)(unsafe.Pointer(pUnused)).FpNext + } + Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + } + } + _unixLeaveMutex(tls) + return pUnused +} + +// C documentation +// +// /* +// ** Test the existence of or access permissions of file zPath. The +// ** test performed depends on the value of flags: +// ** +// ** SQLITE_ACCESS_EXISTS: Return 1 if the file exists +// ** SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable. +// ** SQLITE_ACCESS_READONLY: Return 1 if the file is readable. +// ** +// ** Otherwise return 0. +// */ +func _unixAccess(tls *libc.TLS, NotUsed uintptr, zPath uintptr, flags int32, pResOut uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* buf at bp+0 */ Tstat + _ = NotUsed + /* The spec says there are three possible values for flags. But only + ** two of them are actually used */ + if flags == SQLITE_ACCESS_EXISTS { + **(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32(0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zPath, bp) && (!((**(**Tstat)(__ccgo_up(bp))).Fst_mode&libc.Uint32FromInt32(S_IFMT) == libc.Uint32FromInt32(S_IFREG)) || (**(**Tstat)(__ccgo_up(bp))).Fst_size > 0)) + } else { + **(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zPath, libc.Int32FromInt32(W_OK)|libc.Int32FromInt32(R_OK)) == 0) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Determine the current size of a file in bytes +// */ +func _unixFileSize(tls *libc.TLS, id uintptr, pSize uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var rc int32 + var _ /* buf at bp+0 */ Tstat + _ = rc + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(id)).Fh, bp) + if rc != 0 { + _storeLastErrno(tls, id, **(**int32)(__ccgo_up(libc.X__errno_location(tls)))) + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)< 0 { + return SQLITE_OK + } + if nMap < 0 { /* Low-level file information */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFd)).Fh, bp) != 0 { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)< (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeMax { + nMap = (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeMax + } + if nMap != (*TunixFile)(unsafe.Pointer(pFd)).FmmapSize { + _unixRemapfile(tls, pFd, nMap) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return the name of a directory in which to put temporary files. +// ** If no suitable temporary file directory can be found, return NULL. +// */ +func _unixTempFileDir(tls *libc.TLS) (r uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var i, v1 uint32 + var zDir uintptr + var _ /* buf at bp+0 */ Tstat + _, _, _ = i, zDir, v1 + i = uint32(0) + zDir = Xsqlite3_temp_directory + for int32(1) != 0 { + if zDir != uintptr(0) && (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zDir, bp) == 0 && (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFDIR) && (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zDir, int32(03)) == 0 { + return zDir + } + if uint64(i) >= libc.Uint64FromInt64(48)/libc.Uint64FromInt64(8) { + break + } + v1 = i + i = i + 1 + zDir = _azTempDirs[v1] + } + return uintptr(0) +} diff --git a/internal/engine/lib/sqlite_g_00000000000016c0.go b/internal/engine/lib/sqlite_g_00000000000016c0.go new file mode 100644 index 0000000..8fde52b --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000016c0.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && riscv64) + +package sqlite3 + +const FIOQSIZE = 21600 diff --git a/internal/engine/lib/sqlite_g_0000000000001a00.go b/internal/engine/lib/sqlite_g_0000000000001a00.go new file mode 100644 index 0000000..5280d0d --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000001a00.go @@ -0,0 +1,2491 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm64) || (linux && ppc64le) || (linux && riscv64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Process a pragma statement. +// ** +// ** Pragmas are of this form: +// ** +// ** PRAGMA [schema.]id [= value] +// ** +// ** The identifier might also be a string. The value is a string, and +// ** identifier, or a number. If minusFlag is true, then the value is +// ** a number that was preceded by a minus sign. +// ** +// ** If the left side is "database.id" then pId1 is the database name +// ** and pId2 is the id. If the left side is just "id" then pId1 is the +// ** id and pId2 is any empty string. +// */ +func _sqlite3Pragma(tls *libc.TLS, pParse uintptr, pId1 uintptr, pId2 uintptr, pValue uintptr, minusFlag int32) { + bp := tls.Alloc(240) + defer tls.Free(240) + var a1, a11, addr, addr1, addrCkFault, addrCkOk, addrOk, addrTop, b, bStrict, ckUniq, cnt, doTypeCheck, eAuto, eMode, eMode1, eMode2, i, i1, i10, i2, i3, i4, i5, i6, i7, i8, i9, iAddr, iAddr1, iBt, iCol, iCol1, iCookie, iDb, iDbLast, iEnd, iIdxDb, iLevel, iReg, iTab, iTabCur, iTabDb, iTabDb1, ii, ii1, ii2, ii3, ii4, initNCol, isHidden, isQuick, j2, j3, j4, jmp, jmp2, jmp21, jmp3, jmp4, jmp5, jmp6, jmp61, jmp7, k, k3, kk, label6, labelError, labelOk, loopTop, mx, mxCol, n, nBtree, nCheck, nHidden, nIdx, nIndex, nLimit, p11, p3, p4, r1, r11, r2, rc, regResult, regRow, showInternFunc, size, size1, size2, uniqOk, x1, v2 int32 + var aOp, aOp1, aOp2, aOp3, aOp4, aOp5, aRoot, db, j, j1, k1, k2, k4, p, p1, pBt, pBt1, pBt2, pCheck, pCol, pCol1, pColExpr, pColl, pDb, pEnc, pFK, pFK1, pHash, pIdx, pIdx1, pIdx3, pIdx4, pIdx5, pIdx6, pIdx7, pMod, pObjTab, pPager, pPager1, pParent, pPk, pPk1, pPragma, pPrior, pSchema, pTab, pTab1, pTab10, pTab11, pTab12, pTab2, pTab3, pTab4, pTab5, pTab6, pTab7, pTab8, pTab9, pTbls, pVTab, v, x2, zDb, zErr, zErr1, zErr2, zLeft, zMod, zMode, zOpt, zRet, zRight, zSql, zSubSql, zType, v1, v5 uintptr + var azOrigin [3]uintptr + var cnum Ti16 + var enc Tu8 + var iPrior Tsqlite3_int64 + var iRange, szThreshold TLogEst + var mask Tu64 + var opMask Tu32 + var _ /* N at bp+136 */ Tsqlite3_int64 + var _ /* N at bp+144 */ Tsqlite3_int64 + var _ /* N at bp+152 */ Tsqlite3_int64 + var _ /* N at bp+160 */ Tsqlite3_int64 + var _ /* aFcntl at bp+8 */ [4]uintptr + var _ /* aiCols at bp+96 */ uintptr + var _ /* iDataCur at bp+108 */ int32 + var _ /* iIdxCur at bp+112 */ int32 + var _ /* iLimit at bp+48 */ Ti64 + var _ /* iLimit at bp+56 */ int32 + var _ /* jmp3 at bp+128 */ int32 + var _ /* mxErr at bp+104 */ int32 + var _ /* pDfltValue at bp+120 */ uintptr + var _ /* pDummy at bp+80 */ uintptr + var _ /* pId at bp+0 */ uintptr + var _ /* pIdx at bp+88 */ uintptr + var _ /* res at bp+72 */ int32 + var _ /* size at bp+60 */ int32 + var _ /* sz at bp+64 */ Tsqlite3_int64 + var _ /* x at bp+40 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a1, a11, aOp, aOp1, aOp2, aOp3, aOp4, aOp5, aRoot, addr, addr1, addrCkFault, addrCkOk, addrOk, addrTop, azOrigin, b, bStrict, ckUniq, cnt, cnum, db, doTypeCheck, eAuto, eMode, eMode1, eMode2, enc, i, i1, i10, i2, i3, i4, i5, i6, i7, i8, i9, iAddr, iAddr1, iBt, iCol, iCol1, iCookie, iDb, iDbLast, iEnd, iIdxDb, iLevel, iPrior, iRange, iReg, iTab, iTabCur, iTabDb, iTabDb1, ii, ii1, ii2, ii3, ii4, initNCol, isHidden, isQuick, j, j1, j2, j3, j4, jmp, jmp2, jmp21, jmp3, jmp4, jmp5, jmp6, jmp61, jmp7, k, k1, k2, k3, k4, kk, label6, labelError, labelOk, loopTop, mask, mx, mxCol, n, nBtree, nCheck, nHidden, nIdx, nIndex, nLimit, opMask, p, p1, p11, p3, p4, pBt, pBt1, pBt2, pCheck, pCol, pCol1, pColExpr, pColl, pDb, pEnc, pFK, pFK1, pHash, pIdx, pIdx1, pIdx3, pIdx4, pIdx5, pIdx6, pIdx7, pMod, pObjTab, pPager, pPager1, pParent, pPk, pPk1, pPragma, pPrior, pSchema, pTab, pTab1, pTab10, pTab11, pTab12, pTab2, pTab3, pTab4, pTab5, pTab6, pTab7, pTab8, pTab9, pTbls, pVTab, r1, r11, r2, rc, regResult, regRow, showInternFunc, size, size1, size2, szThreshold, uniqOk, v, x1, x2, zDb, zErr, zErr1, zErr2, zLeft, zMod, zMode, zOpt, zRet, zRight, zSql, zSubSql, zType, v1, v2, v5 + zLeft = uintptr(0) /* Nul-terminated UTF-8 string */ + zRight = uintptr(0) /* Nul-terminated UTF-8 string , or NULL */ + zDb = uintptr(0) /* return value form SQLITE_FCNTL_PRAGMA */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The specific database being pragmaed */ + v = _sqlite3GetVdbe(tls, pParse) /* The pragma */ + if v == uintptr(0) { + return + } + _sqlite3VdbeRunOnlyOnce(tls, v) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(2) + /* Interpret the [schema.] part of the pragma statement. iDb is the + ** index of the database this pragma is being applied to in db.aDb[]. */ + iDb = _sqlite3TwoPartName(tls, pParse, pId1, pId2, bp) + if iDb < 0 { + return + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + /* If the temp database has been explicitly named as part of the + ** pragma, make sure it is open. + */ + if iDb == int32(1) && _sqlite3OpenTempDatabase(tls, pParse) != 0 { + return + } + zLeft = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if !(zLeft != 0) { + return + } + if minusFlag != 0 { + zRight = _sqlite3MPrintf(tls, db, __ccgo_ts+19214, libc.VaList(bp+176, pValue)) + } else { + zRight = _sqlite3NameFromToken(tls, db, pValue) + } + if (*TToken)(unsafe.Pointer(pId2)).Fn > uint32(0) { + v1 = (*TDb)(unsafe.Pointer(pDb)).FzDbSName + } else { + v1 = uintptr(0) + } + zDb = v1 + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_PRAGMA), zLeft, zRight, zDb) != 0 { + goto pragma_out + } + /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS + ** connection. If it returns SQLITE_OK, then assume that the VFS + ** handled the pragma and generate a no-op prepared statement. + ** + ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed, + ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file + ** object corresponding to the database file to which the pragma + ** statement refers. + ** + ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA + ** file control is an array of pointers to strings (char**) in which the + ** second element of the array is the name of the pragma and the third + ** element is the argument to the pragma or NULL if the pragma has no + ** argument. + */ + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0] = uintptr(0) + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(1)] = zLeft + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(2)] = zRight + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(3)] = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 + rc = Xsqlite3_file_control(tls, db, zDb, int32(SQLITE_FCNTL_PRAGMA), bp+8) + if rc == SQLITE_OK { + _sqlite3VdbeSetNumCols(tls, v, int32(1)) + _sqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0], uintptr(-libc.Int32FromInt32(1))) + _returnSingleText(tls, v, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + Xsqlite3_free(tls, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + goto pragma_out + } + if rc != int32(SQLITE_NOTFOUND) { + if (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0] != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3944, libc.VaList(bp+176, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0])) + Xsqlite3_free(tls, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + } + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + goto pragma_out + } + /* Locate the pragma in the lookup table */ + pPragma = _pragmaLocate(tls, zLeft) + if pPragma == uintptr(0) { + /* IMP: R-43042-22504 No error messages are generated if an + ** unknown pragma is issued. */ + goto pragma_out + } + /* Make sure the database schema is loaded if the pragma requires that */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NeedSchema) != 0 { + if _sqlite3ReadSchema(tls, pParse) != 0 { + goto pragma_out + } + } + /* Register the result column names for pragmas that return results */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns) == 0 && (libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns1) == 0 || zRight == uintptr(0)) { + _setPragmaResultColumnNames(tls, v, pPragma) + } + /* Jump to the appropriate pragma handler */ + switch libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FePragTyp) { + /* + ** PRAGMA [schema.]default_cache_size + ** PRAGMA [schema.]default_cache_size=N + ** + ** The first form reports the current persistent setting for the + ** page cache size. The value returned is the maximum number of + ** pages in the page cache. The second form sets both the current + ** page cache size value and the persistent page cache size value + ** stored in the database file. + ** + ** Older versions of SQLite would set the default cache size to a + ** negative number to indicate synchronous=OFF. These days, synchronous + ** is always on by default regardless of the sign of the default cache + ** size. But continue to take the absolute value of the default cache + ** size of historical compatibility. + */ + case int32(PragTyp_DEFAULT_CACHE_SIZE): + _sqlite3VdbeUsesBtree(tls, v, iDb) + if !(zRight != 0) { + **(**int32)(__ccgo_up(pParse + 60)) += int32(2) + aOp = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(36)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_getCacheSize)), _iLn3) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp + 6*24))).Fp1 = -int32(2000) + } else { + size = _sqlite3AbsInt32(tls, _sqlite3Atoi(tls, zRight)) + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_DEFAULT_CACHE_SIZE), size) + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size + _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) + } + break + /* + ** PRAGMA [schema.]page_size + ** PRAGMA [schema.]page_size=N + ** + ** The first form reports the current setting for the + ** database page size in bytes. The second form sets the + ** database page size value. The value can only be set if + ** the database has not yet been created. + */ + fallthrough + case int32(PragTyp_PAGE_SIZE): + pBt = (*TDb)(unsafe.Pointer(pDb)).FpBt + if !(zRight != 0) { + if pBt != 0 { + v2 = _sqlite3BtreeGetPageSize(tls, pBt) + } else { + v2 = 0 + } + size1 = v2 + _returnSingleInt(tls, v, int64(size1)) + } else { + /* Malloc may fail when setting the page-size, as there is an internal + ** buffer that the pager module resizes using sqlite3_realloc(). + */ + (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize = _sqlite3Atoi(tls, zRight) + if int32(SQLITE_NOMEM) == _sqlite3BtreeSetPageSize(tls, pBt, (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { + _sqlite3OomFault(tls, db) + } + } + break + /* + ** PRAGMA [schema.]secure_delete + ** PRAGMA [schema.]secure_delete=ON/OFF/FAST + ** + ** The first form reports the current setting for the + ** secure_delete flag. The second form changes the secure_delete + ** flag setting and reports the new value. + */ + fallthrough + case int32(PragTyp_SECURE_DELETE): + pBt1 = (*TDb)(unsafe.Pointer(pDb)).FpBt + b = -int32(1) + if zRight != 0 { + if Xsqlite3_stricmp(tls, zRight, __ccgo_ts+19218) == 0 { + b = int32(2) + } else { + b = libc.Int32FromUint8(_sqlite3GetBoolean(tls, zRight, uint8(0))) + } + } + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) && b >= 0 { + ii = 0 + for { + if !(ii < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + _sqlite3BtreeSecureDelete(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii)*32))).FpBt, b) + goto _3 + _3: + ; + ii = ii + 1 + } + } + b = _sqlite3BtreeSecureDelete(tls, pBt1, b) + _returnSingleInt(tls, v, int64(b)) + break + /* + ** PRAGMA [schema.]max_page_count + ** PRAGMA [schema.]max_page_count=N + ** + ** The first form reports the current setting for the + ** maximum number of pages in the database file. The + ** second form attempts to change this setting. Both + ** forms return the current setting. + ** + ** The absolute value of N is used. This is undocumented and might + ** change. The only purpose is to provide an easy way to test + ** the sqlite3AbsInt32() function. + ** + ** PRAGMA [schema.]page_count + ** + ** Return the number of pages in the specified database. + */ + fallthrough + case int32(PragTyp_PAGE_COUNT): + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + _sqlite3CodeVerifySchema(tls, pParse, iDb) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + iReg = v2 + if libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(zLeft)))]) == int32('p') { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Pagecount), iDb, iReg) + } else { + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+40) == 0 { + if **(**Ti64)(__ccgo_up(bp + 40)) < 0 { + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + } else { + if **(**Ti64)(__ccgo_up(bp + 40)) > libc.Int64FromUint32(0xfffffffe) { + **(**Ti64)(__ccgo_up(bp + 40)) = libc.Int64FromUint32(0xfffffffe) + } + } + } else { + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MaxPgcnt), iDb, iReg, int32(**(**Ti64)(__ccgo_up(bp + 40)))) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), iReg, int32(1)) + break + /* + ** PRAGMA [schema.]locking_mode + ** PRAGMA [schema.]locking_mode = (normal|exclusive) + */ + fallthrough + case int32(PragTyp_LOCKING_MODE): + zRet = __ccgo_ts + 19009 + eMode = _getLockingMode(tls, zRight) + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) && eMode == -int32(1) { + /* Simple "PRAGMA locking_mode;" statement. This is a query for + ** the current default locking mode (which may be different to + ** the locking-mode of the main database). + */ + eMode = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FdfltLockMode) + } else { + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + ii1 = int32(2) + for { + if !(ii1 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pPager = _sqlite3BtreePager(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii1)*32))).FpBt) + _sqlite3PagerLockingMode(tls, pPager, eMode) + goto _6 + _6: + ; + ii1 = ii1 + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FdfltLockMode = libc.Uint8FromInt32(eMode) + } + pPager = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + eMode = _sqlite3PagerLockingMode(tls, pPager, eMode) + } + if eMode == int32(PAGER_LOCKINGMODE_EXCLUSIVE) { + zRet = __ccgo_ts + 18999 + } + _returnSingleText(tls, v, zRet) + break + /* + ** PRAGMA [schema.]journal_mode + ** PRAGMA [schema.]journal_mode = + ** (delete|persist|off|truncate|memory|wal|off) + */ + fallthrough + case int32(PragTyp_JOURNAL_MODE): /* Loop counter */ + if zRight == uintptr(0) { + /* If there is no "=MODE" part of the pragma, do a query for the + ** current mode */ + eMode1 = -int32(1) + } else { + n = _sqlite3Strlen30(tls, zRight) + eMode1 = 0 + for { + v1 = _sqlite3JournalModename(tls, eMode1) + zMode = v1 + if !(v1 != uintptr(0)) { + break + } + if Xsqlite3_strnicmp(tls, zRight, zMode, n) == 0 { + break + } + goto _7 + _7: + ; + eMode1 = eMode1 + 1 + } + if !(zMode != 0) { + /* If the "=MODE" part does not match any known journal mode, + ** then do a query */ + eMode1 = -int32(1) + } + if eMode1 == int32(PAGER_JOURNALMODE_OFF) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) { + /* Do not allow journal-mode "OFF" in defensive since the database + ** can become corrupted using ordinary SQL when the journal is off */ + eMode1 = -int32(1) + } + } + if eMode1 == -int32(1) && (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ + iDb = 0 + (*TToken)(unsafe.Pointer(pId2)).Fn = uint32(1) + } + ii2 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + for { + if !(ii2 >= 0) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii2)*32))).FpBt != 0 && (ii2 == iDb || (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0)) { + _sqlite3VdbeUsesBtree(tls, v, ii2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_JournalMode), ii2, int32(1), eMode1) + } + goto _9 + _9: + ; + ii2 = ii2 - 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) + break + /* + ** PRAGMA [schema.]journal_size_limit + ** PRAGMA [schema.]journal_size_limit=N + ** + ** Get or set the size limit on rollback journal files. + */ + fallthrough + case int32(PragTyp_JOURNAL_SIZE_LIMIT): + pPager1 = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + **(**Ti64)(__ccgo_up(bp + 48)) = int64(-int32(2)) + if zRight != 0 { + _sqlite3DecOrHexToI64(tls, zRight, bp+48) + if **(**Ti64)(__ccgo_up(bp + 48)) < int64(-int32(1)) { + **(**Ti64)(__ccgo_up(bp + 48)) = int64(-int32(1)) + } + } + **(**Ti64)(__ccgo_up(bp + 48)) = _sqlite3PagerJournalSizeLimit(tls, pPager1, **(**Ti64)(__ccgo_up(bp + 48))) + _returnSingleInt(tls, v, **(**Ti64)(__ccgo_up(bp + 48))) + break + /* + ** PRAGMA [schema.]auto_vacuum + ** PRAGMA [schema.]auto_vacuum=N + ** + ** Get or set the value of the database 'auto-vacuum' parameter. + ** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL + */ + fallthrough + case int32(PragTyp_AUTO_VACUUM): + pBt2 = (*TDb)(unsafe.Pointer(pDb)).FpBt + if !(zRight != 0) { + _returnSingleInt(tls, v, int64(_sqlite3BtreeGetAutoVacuum(tls, pBt2))) + } else { + eAuto = _getAutoVacuum(tls, zRight) + (*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac = libc.Int8FromUint8(libc.Uint8FromInt32(eAuto)) + /* Call SetAutoVacuum() to set initialize the internal auto and + ** incr-vacuum flags. This is required in case this connection + ** creates the database file. It is important that it is created + ** as an auto-vacuum capable db. + */ + rc = _sqlite3BtreeSetAutoVacuum(tls, pBt2, eAuto) + if rc == SQLITE_OK && (eAuto == int32(1) || eAuto == int32(2)) { + iAddr = _sqlite3VdbeCurrentAddr(tls, v) + aOp1 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(20)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_setMeta6)), _iLn11) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp1))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 2*24))).Fp2 = iAddr + int32(4) + (**(**TVdbeOp)(__ccgo_up(aOp1 + 4*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 4*24))).Fp3 = eAuto - int32(1) + _sqlite3VdbeUsesBtree(tls, v, iDb) + } + } + break + /* + ** PRAGMA [schema.]incremental_vacuum(N) + ** + ** Do N steps of incremental vacuuming on a database. + */ + fallthrough + case int32(PragTyp_INCREMENTAL_VACUUM): + **(**int32)(__ccgo_up(bp + 56)) = 0 + if zRight == uintptr(0) || !(_sqlite3GetInt32(tls, zRight, bp+56) != 0) || **(**int32)(__ccgo_up(bp + 56)) <= 0 { + **(**int32)(__ccgo_up(bp + 56)) = int32(0x7fffffff) + } + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp + 56)), int32(1)) + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IncrVacuum), iDb) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResultRow), int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(1), -int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), int32(1), addr) + _sqlite3VdbeJumpHere(tls, v, addr) + break + /* + ** PRAGMA [schema.]cache_size + ** PRAGMA [schema.]cache_size=N + ** + ** The first form reports the current local setting for the + ** page cache size. The second form sets the local + ** page cache size value. If N is positive then that is the + ** number of pages in the cache. If N is negative, then the + ** number of pages is adjusted so that the cache uses -N kibibytes + ** of memory. + */ + fallthrough + case int32(PragTyp_CACHE_SIZE): + if !(zRight != 0) { + _returnSingleInt(tls, v, int64((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size)) + } else { + size2 = _sqlite3Atoi(tls, zRight) + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size2 + _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) + } + break + /* + ** PRAGMA [schema.]cache_spill + ** PRAGMA cache_spill=BOOLEAN + ** PRAGMA [schema.]cache_spill=N + ** + ** The first form reports the current local setting for the + ** page cache spill size. The second form turns cache spill on + ** or off. When turning cache spill on, the size is set to the + ** current cache_size. The third form sets a spill size that + ** may be different form the cache size. + ** If N is positive then that is the + ** number of pages in the cache. If N is negative, then the + ** number of pages is adjusted so that the cache uses -N kibibytes + ** of memory. + ** + ** If the number of cache_spill pages is less then the number of + ** cache_size pages, no spilling occurs until the page count exceeds + ** the number of cache_size pages. + ** + ** The cache_spill=BOOLEAN setting applies to all attached schemas, + ** not just the schema specified. + */ + fallthrough + case int32(PragTyp_CACHE_SPILL): + if !(zRight != 0) { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_CacheSpill) == uint64(0) { + v2 = 0 + } else { + v2 = _sqlite3BtreeSetSpillSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, 0) + } + _returnSingleInt(tls, v, int64(v2)) + } else { + **(**int32)(__ccgo_up(bp + 60)) = int32(1) + if _sqlite3GetInt32(tls, zRight, bp+60) != 0 { + _sqlite3BtreeSetSpillSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, **(**int32)(__ccgo_up(bp + 60))) + } + if _sqlite3GetBoolean(tls, zRight, libc.BoolUint8(**(**int32)(__ccgo_up(bp + 60)) != 0)) != 0 { + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_CacheSpill) + } else { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_CacheSpill) + } + _setAllPagerFlags(tls, db) + } + break + /* + ** PRAGMA [schema.]mmap_size(N) + ** + ** Used to set mapping size limit. The mapping size limit is + ** used to limit the aggregate size of all memory mapped regions of the + ** database file. If this parameter is set to zero, then memory mapping + ** is not used at all. If N is negative, then the default memory map + ** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_SIZE) is set. + ** The parameter N is measured in bytes. + ** + ** This value is advisory. The underlying VFS is free to memory map + ** as little or as much as it wants. Except, if N is set to 0 then the + ** upper layers will never invoke the xFetch interfaces to the VFS. + */ + fallthrough + case int32(PragTyp_MMAP_SIZE): + if zRight != 0 { + _sqlite3DecOrHexToI64(tls, zRight, bp+64) + if **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) < 0 { + **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) = _sqlite3Config.FszMmap + } + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + (*Tsqlite3)(unsafe.Pointer(db)).FszMmap = **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) + } + ii3 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + for { + if !(ii3 >= 0) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii3)*32))).FpBt != 0 && (ii3 == iDb || (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0)) { + _sqlite3BtreeSetMmapLimit(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii3)*32))).FpBt, **(**Tsqlite3_int64)(__ccgo_up(bp + 64))) + } + goto _11 + _11: + ; + ii3 = ii3 - 1 + } + } + **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) = int64(-int32(1)) + rc = Xsqlite3_file_control(tls, db, zDb, int32(SQLITE_FCNTL_MMAP_SIZE), bp+64) + if rc == SQLITE_OK { + _returnSingleInt(tls, v, **(**Tsqlite3_int64)(__ccgo_up(bp + 64))) + } else { + if rc != int32(SQLITE_NOTFOUND) { + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + } + } + break + /* + ** PRAGMA temp_store + ** PRAGMA temp_store = "default"|"memory"|"file" + ** + ** Return or set the local value of the temp_store flag. Changing + ** the local value does not make changes to the disk file and the default + ** value will be restored the next time the database is opened. + ** + ** Note that it is possible for the library compile-time options to + ** override this setting + */ + fallthrough + case int32(PragTyp_TEMP_STORE): + if !(zRight != 0) { + _returnSingleInt(tls, v, libc.Int64FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store)) + } else { + _changeTempStorage(tls, pParse, zRight) + } + break + /* + ** PRAGMA temp_store_directory + ** PRAGMA temp_store_directory = ""|"directory_name" + ** + ** Return or set the local value of the temp_store_directory flag. Changing + ** the value sets a specific directory to be used for temporary files. + ** Setting to a null string reverts to the default temporary directory search. + ** If temporary directory is changed, then invalidateTempStorage. + ** + */ + fallthrough + case int32(PragTyp_TEMP_STORE_DIRECTORY): + Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + if !(zRight != 0) { + _returnSingleText(tls, v, Xsqlite3_temp_directory) + } else { + if **(**uint8)(__ccgo_up(zRight)) != 0 { + rc = _sqlite3OsAccess(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, zRight, int32(SQLITE_ACCESS_READWRITE), bp+72) + if rc != SQLITE_OK || **(**int32)(__ccgo_up(bp + 72)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19223, 0) + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + goto pragma_out + } + } + if libc.Bool(false) || libc.Bool(true) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) <= int32(1) || libc.Bool(libc.Bool(false) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) == int32(1)) { + _invalidateTempStorage(tls, pParse) + } + Xsqlite3_free(tls, Xsqlite3_temp_directory) + if **(**uint8)(__ccgo_up(zRight)) != 0 { + Xsqlite3_temp_directory = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+176, zRight)) + } else { + Xsqlite3_temp_directory = uintptr(0) + } + } + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + break + /* + ** PRAGMA [schema.]synchronous + ** PRAGMA [schema.]synchronous=OFF|ON|NORMAL|FULL|EXTRA + ** + ** Return or set the local value of the synchronous flag. Changing + ** the local value does not make changes to the disk file and the + ** default value will be restored the next time the database is + ** opened. + */ + fallthrough + case int32(PragTyp_SYNCHRONOUS): + if !(zRight != 0) { + _returnSingleInt(tls, v, int64(libc.Int32FromUint8((*TDb)(unsafe.Pointer(pDb)).Fsafety_level)-int32(1))) + } else { + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19248, 0) + } else { + if iDb != int32(1) { + iLevel = (libc.Int32FromUint8(_getSafetyLevel(tls, zRight, 0, uint8(1))) + int32(1)) & int32(PAGER_SYNCHRONOUS_MASK) + if iLevel == 0 { + iLevel = int32(1) + } + (*TDb)(unsafe.Pointer(pDb)).Fsafety_level = libc.Uint8FromInt32(iLevel) + (*TDb)(unsafe.Pointer(pDb)).FbSyncSet = uint8(1) + _setAllPagerFlags(tls, db) + } + } + } + case int32(PragTyp_FLAG): + if zRight == uintptr(0) { + _setPragmaResultColumnNames(tls, v, pPragma) + _returnSingleInt(tls, v, libc.BoolInt64((*Tsqlite3)(unsafe.Pointer(db)).Fflags&(*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != uint64(0))) + } else { + mask = (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg /* Mask of bits to set or clear. */ + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 { + /* Foreign key support may not be enabled or disabled while not + ** in auto-commit mode. */ + mask = mask & libc.Uint64FromInt32(^libc.Int32FromInt32(SQLITE_ForeignKeys)) + } + if _sqlite3GetBoolean(tls, zRight, uint8(0)) != 0 { + if mask&uint64(SQLITE_WriteSchema) == uint64(0) || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) == uint64(0) { + **(**Tu64)(__ccgo_up(db + 48)) |= mask + } + } else { + **(**Tu64)(__ccgo_up(db + 48)) &= ^mask + if mask == uint64(SQLITE_DeferFKs) { + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons = 0 + } + if mask&uint64(SQLITE_WriteSchema) != uint64(0) && Xsqlite3_stricmp(tls, zRight, __ccgo_ts+19301) == 0 { + /* IMP: R-60817-01178 If the argument is "RESET" then schema + ** writing is disabled (as with "PRAGMA writable_schema=OFF") and, + ** in addition, the schema is reloaded. */ + _sqlite3ResetAllSchemasOfConnection(tls, db) + } + } + /* Many of the flag-pragmas modify the code generated by the SQL + ** compiler (eg. count_changes). So add an opcode to expire all + ** compiled SQL statements after modifying a pragma value. + */ + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + _setAllPagerFlags(tls, db) + } + break + /* + ** PRAGMA table_info(
  • ) + ** + ** Return a single row for each column of the named table. The columns of + ** the returned data set are: + ** + ** cid: Column id (numbered from left to right, starting at 0) + ** name: Column name + ** type: Column declaration type. + ** notnull: True if 'NOT NULL' is part of column declaration + ** dflt_value: The default value for the column, if any. + ** pk: Non-zero for PK fields. + */ + fallthrough + case int32(PragTyp_TABLE_INFO): + if zRight != 0 { + _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) + pTab = _sqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb) + if pTab != 0 { + nHidden = 0 + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(7) + _sqlite3ViewGetColumnNames(tls, pParse, pTab) + i = 0 + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + isHidden = 0 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_NOINSERT) != 0 { + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg == uint64(0) { + nHidden = nHidden + 1 + goto _12 + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + isHidden = int32(2) /* GENERATED ALWAYS AS ... VIRTUAL */ + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_STORED) != 0 { + isHidden = int32(3) /* GENERATED ALWAYS AS ... STORED */ + } else { + isHidden = int32(1) /* HIDDEN */ + } + } + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) == 0 { + k = 0 + } else { + if pPk == uintptr(0) { + k = int32(1) + } else { + k = int32(1) + for { + if !(k <= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) && int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(k-int32(1))*2))) != i) { + break + } + goto _13 + _13: + ; + k = k + 1 + } + } + } + pColExpr = _sqlite3ColumnExpr(tls, pTab, pCol) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + v1 = __ccgo_ts + 19307 + } else { + v1 = __ccgo_ts + 19315 + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + if isHidden >= int32(2) || pColExpr == uintptr(0) { + v5 = uintptr(0) + } else { + v5 = *(*uintptr)(unsafe.Pointer(pColExpr + 8)) + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), v1, libc.VaList(bp+176, i-nHidden, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, _sqlite3ColumnType(tls, pCol, __ccgo_ts+1704), v2, v5, k, isHidden)) + goto _12 + _12: + ; + i = i + 1 + pCol += 16 + } + } + } + break + /* + ** PRAGMA table_list + ** + ** Return a single row for each table, virtual table, or view in the + ** entire schema. + ** + ** schema: Name of attached database hold this table + ** name: Name of the table itself + ** type: "table", "view", "virtual", "shadow" + ** ncol: Number of columns + ** wr: True for a WITHOUT ROWID table + ** strict: True for a STRICT table + */ + fallthrough + case int32(PragTyp_TABLE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) + ii4 = 0 + for { + if !(ii4 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if zDb != 0 && Xsqlite3_stricmp(tls, zDb, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FzDbSName) != 0 { + goto _17 + } + /* Ensure that the Table.nCol field is initialized for all views + ** and virtual tables. Each time we initialize a Table.nCol value + ** for a table, that can potentially disrupt the hash table, so restart + ** the initialization scan. + */ + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FpSchema + 8 + initNCol = libc.Int32FromUint32((*THash)(unsafe.Pointer(pHash)).Fcount) + for { + v2 = initNCol + initNCol = initNCol - 1 + if !(v2 != 0) { + break + } + k1 = (*THash)(unsafe.Pointer(pHash)).Ffirst + for { + if !(int32(1) != 0) { + break + } + if k1 == uintptr(0) { + initNCol = 0 + break + } + pTab1 = (*THashElem)(unsafe.Pointer(k1)).Fdata + if int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) == 0 { + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+19322, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab1)).FzName)) + if zSql != 0 { + **(**uintptr)(__ccgo_up(bp + 80)) = uintptr(0) + Xsqlite3_prepare_v3(tls, db, zSql, -int32(1), uint32(SQLITE_PREPARE_DONT_LOG), bp+80, uintptr(0)) + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 80))) + _sqlite3DbFree(tls, db, zSql) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ErrorMsg(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpParse, __ccgo_ts+1674, 0) + (*TParse)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpParse)).Frc = int32(SQLITE_NOMEM) + } + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FpSchema + 8 + break + } + goto _19 + _19: + ; + k1 = (*THashElem)(unsafe.Pointer(k1)).Fnext + } + } + k1 = (*THash)(unsafe.Pointer(pHash)).Ffirst + for { + if !(k1 != 0) { + break + } + pTab2 = (*THashElem)(unsafe.Pointer(k1)).Fdata + if zRight != 0 && Xsqlite3_stricmp(tls, zRight, (*TTable)(unsafe.Pointer(pTab2)).FzName) != 0 { + goto _20 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VIEW) { + zType = __ccgo_ts + 11115 + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VTAB) { + zType = __ccgo_ts + 14300 + } else { + if (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Shadow) != 0 { + zType = __ccgo_ts + 19338 + } else { + zType = __ccgo_ts + 9377 + } + } + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19345, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FzDbSName, _sqlite3PreferredTableName(tls, (*TTable)(unsafe.Pointer(pTab2)).FzName), zType, int32((*TTable)(unsafe.Pointer(pTab2)).FnCol), libc.BoolInt32((*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_WithoutRowid) != uint32(0)), libc.BoolInt32((*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Strict) != uint32(0)))) + goto _20 + _20: + ; + k1 = (*THashElem)(unsafe.Pointer(k1)).Fnext + } + goto _17 + _17: + ; + ii4 = ii4 + 1 + } + case int32(PragTyp_INDEX_INFO): + if zRight != 0 { + pIdx = _sqlite3FindIndex(tls, db, zRight, zDb) + if pIdx == uintptr(0) { + /* If there is no index named zRight, check to see if there is a + ** WITHOUT ROWID table named zRight, and if there is, show the + ** structure of the PRIMARY KEY index for that table. */ + pTab3 = _sqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb) + if pTab3 != 0 && !((*TTable)(unsafe.Pointer(pTab3)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pIdx = _sqlite3PrimaryKeyIndex(tls, pTab3) + } + } + if pIdx != 0 { + iIdxDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIdx)).FpSchema) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + /* PRAGMA index_xinfo (newer version with more rows and columns) */ + mx = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + } else { + /* PRAGMA index_info (legacy version) */ + mx = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + } + pTab3 = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + _sqlite3CodeVerifySchema(tls, pParse, iIdxDb) + i1 = 0 + for { + if !(i1 < mx) { + break + } + cnum = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i1)*2)) + if int32(cnum) < 0 { + v1 = uintptr(0) + } else { + v1 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab3)).FaCol + uintptr(cnum)*16))).FzCnName + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19352, libc.VaList(bp+176, i1, int32(cnum), v1)) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + _sqlite3VdbeMultiLoad(tls, v, int32(4), __ccgo_ts+19357, libc.VaList(bp+176, libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i1)))), **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i1)*8)), libc.BoolInt32(i1 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)))) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), (*TParse)(unsafe.Pointer(pParse)).FnMem) + goto _21 + _21: + ; + i1 = i1 + 1 + } + } + } + case int32(PragTyp_INDEX_LIST): + if zRight != 0 { + pTab4 = _sqlite3FindTable(tls, db, zRight, zDb) + if pTab4 != 0 { + iTabDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab4)).FpSchema) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(5) + _sqlite3CodeVerifySchema(tls, pParse, iTabDb) + pIdx1 = (*TTable)(unsafe.Pointer(pTab4)).FpIndex + i2 = libc.Int32FromInt32(0) + for { + if !(pIdx1 != 0) { + break + } + azOrigin = [3]uintptr{ + 0: __ccgo_ts + 19362, + 1: __ccgo_ts + 19364, + 2: __ccgo_ts + 17851, + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19366, libc.VaList(bp+176, i2, (*TIndex)(unsafe.Pointer(pIdx1)).FzName, libc.BoolInt32(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx1)).FonError) != OE_None), azOrigin[int32(uint32(*(*uint16)(unsafe.Pointer(pIdx1 + 100))&0x3>>0))], libc.BoolInt32((*TIndex)(unsafe.Pointer(pIdx1)).FpPartIdxWhere != uintptr(0)))) + goto _23 + _23: + ; + pIdx1 = (*TIndex)(unsafe.Pointer(pIdx1)).FpNext + i2 = i2 + 1 + } + } + } + case int32(PragTyp_DATABASE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + i3 = 0 + for { + if !(i3 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FpBt == uintptr(0) { + goto _24 + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19372, libc.VaList(bp+176, i3, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FzDbSName, _sqlite3BtreeGetFilename(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FpBt))) + goto _24 + _24: + ; + i3 = i3 + 1 + } + case int32(PragTyp_COLLATION_LIST): + i4 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(2) + p = (*THash)(unsafe.Pointer(db + 648)).Ffirst + for { + if !(p != 0) { + break + } + pColl = (*THashElem)(unsafe.Pointer(p)).Fdata + v2 = i4 + i4 = i4 + 1 + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19376, libc.VaList(bp+176, v2, (*TCollSeq)(unsafe.Pointer(pColl)).FzName)) + goto _25 + _25: + ; + p = (*THashElem)(unsafe.Pointer(p)).Fnext + } + case int32(PragTyp_FUNCTION_LIST): + showInternFunc = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_InternalFunc) != uint32(0)) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + i5 = 0 + for { + if !(i5 < int32(SQLITE_FUNC_HASH_SZ)) { + break + } + p1 = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(i5)*8)) + for { + if !(p1 != 0) { + break + } + _pragmaFunclistLine(tls, v, p1, int32(1), showInternFunc) + goto _28 + _28: + ; + p1 = *(*uintptr)(unsafe.Pointer(p1 + 64)) + } + goto _27 + _27: + ; + i5 = i5 + 1 + } + j = (*THash)(unsafe.Pointer(db + 624)).Ffirst + for { + if !(j != 0) { + break + } + p1 = (*THashElem)(unsafe.Pointer(j)).Fdata + _pragmaFunclistLine(tls, v, p1, 0, showInternFunc) + goto _29 + _29: + ; + j = (*THashElem)(unsafe.Pointer(j)).Fnext + } + case int32(PragTyp_MODULE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(1) + j1 = (*THash)(unsafe.Pointer(db + 576)).Ffirst + for { + if !(j1 != 0) { + break + } + pMod = (*THashElem)(unsafe.Pointer(j1)).Fdata + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+7909, libc.VaList(bp+176, (*TModule)(unsafe.Pointer(pMod)).FzName)) + goto _30 + _30: + ; + j1 = (*THashElem)(unsafe.Pointer(j1)).Fnext + } + case int32(PragTyp_PRAGMA_LIST): + i6 = 0 + for { + if !(i6 < libc.Int32FromUint64(libc.Uint64FromInt64(1584)/libc.Uint64FromInt64(24))) { + break + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+7909, libc.VaList(bp+176, _aPragmaName[i6].FzName)) + goto _31 + _31: + ; + i6 = i6 + 1 + } + case int32(PragTyp_FOREIGN_KEY_LIST): + if zRight != 0 { + pTab5 = _sqlite3FindTable(tls, db, zRight, zDb) + if pTab5 != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab5)).FeTabType) == TABTYP_NORM { + pFK = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab5 + 64))).FpFKey + if pFK != 0 { + iTabDb1 = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab5)).FpSchema) + i7 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(8) + _sqlite3CodeVerifySchema(tls, pParse, iTabDb1) + for pFK != 0 { + j2 = 0 + for { + if !(j2 < (*TFKey)(unsafe.Pointer(pFK)).FnCol) { + break + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19379, libc.VaList(bp+176, i7, j2, (*TFKey)(unsafe.Pointer(pFK)).FzTo, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab5)).FaCol + uintptr((*(*TsColMap)(unsafe.Pointer(pFK + 64 + uintptr(j2)*16))).FiFrom)*16))).FzCnName, (*(*TsColMap)(unsafe.Pointer(pFK + 64 + uintptr(j2)*16))).FzCol, _actionName(tls, **(**Tu8)(__ccgo_up(pFK + 45 + 1))), _actionName(tls, **(**Tu8)(__ccgo_up(pFK + 45))), __ccgo_ts+19388)) + goto _32 + _32: + ; + j2 = j2 + 1 + } + i7 = i7 + 1 + pFK = (*TFKey)(unsafe.Pointer(pFK)).FpNextFrom + } + } + } + } + case int32(PragTyp_FOREIGN_KEY_CHECK): /* child to parent column mapping */ + regResult = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(4) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + regRow = v2 + k2 = (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 8)).Ffirst + for k2 != 0 { + if zRight != 0 { + pTab6 = _sqlite3LocateTable(tls, pParse, uint32(0), zRight, zDb) + k2 = uintptr(0) + } else { + pTab6 = (*THashElem)(unsafe.Pointer(k2)).Fdata + k2 = (*THashElem)(unsafe.Pointer(k2)).Fnext + } + if pTab6 == uintptr(0) || !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab6)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) || (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey == uintptr(0) { + continue + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab6)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab6)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab6)).FzName) + _sqlite3TouchRegister(tls, pParse, int32((*TTable)(unsafe.Pointer(pTab6)).FnCol)+regRow) + _sqlite3OpenTable(tls, pParse, 0, iDb, pTab6, int32(OP_OpenRead)) + _sqlite3VdbeLoadString(tls, v, regResult, (*TTable)(unsafe.Pointer(pTab6)).FzName) + i8 = int32(1) + pFK1 = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey + for { + if !(pFK1 != 0) { + break + } + pParent = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, zDb) + if pParent == uintptr(0) { + goto _35 + } + **(**uintptr)(__ccgo_up(bp + 88)) = uintptr(0) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pParent)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pParent)).FzName) + x1 = _sqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+88, uintptr(0)) + if x1 == 0 { + if **(**uintptr)(__ccgo_up(bp + 88)) == uintptr(0) { + _sqlite3OpenTable(tls, pParse, i8, iDb, pParent, int32(OP_OpenRead)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), i8, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 88)))).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, **(**uintptr)(__ccgo_up(bp + 88))) + } + } else { + k2 = uintptr(0) + break + } + goto _35 + _35: + ; + i8 = i8 + 1 + pFK1 = (*TFKey)(unsafe.Pointer(pFK1)).FpNextFrom + } + if pFK1 != 0 { + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnTab < i8 { + (*TParse)(unsafe.Pointer(pParse)).FnTab = i8 + } + addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), 0) + i8 = int32(1) + pFK1 = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey + for { + if !(pFK1 != 0) { + break + } + pParent = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, zDb) + **(**uintptr)(__ccgo_up(bp + 88)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) + if pParent != 0 { + x1 = _sqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+88, bp+96) + } + addrOk = _sqlite3VdbeMakeLabel(tls, pParse) + /* Generate code to read the child key values into registers + ** regRow..regRow+n. If any of the child key values are NULL, this + ** row cannot cause an FK violation. Jump directly to addrOk in + ** this case. */ + _sqlite3TouchRegister(tls, pParse, regRow+(*TFKey)(unsafe.Pointer(pFK1)).FnCol) + j3 = 0 + for { + if !(j3 < (*TFKey)(unsafe.Pointer(pFK1)).FnCol) { + break + } + if **(**uintptr)(__ccgo_up(bp + 96)) != 0 { + v2 = **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 96)) + uintptr(j3)*4)) + } else { + v2 = (*(*TsColMap)(unsafe.Pointer(pFK1 + 64 + uintptr(j3)*16))).FiFrom + } + iCol = v2 + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab6, 0, iCol, regRow+j3) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regRow+j3, addrOk) + goto _37 + _37: + ; + j3 = j3 + 1 + } + /* Generate code to query the parent index for a matching parent + ** key. If a match is found, jump to addrOk. */ + if **(**uintptr)(__ccgo_up(bp + 88)) != 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), regRow, (*TFKey)(unsafe.Pointer(pFK1)).FnCol, 0, _sqlite3IndexAffinityStr(tls, db, **(**uintptr)(__ccgo_up(bp + 88))), (*TFKey)(unsafe.Pointer(pFK1)).FnCol) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), i8, addrOk, regRow, (*TFKey)(unsafe.Pointer(pFK1)).FnCol) + } else { + if pParent != 0 { + jmp = _sqlite3VdbeCurrentAddr(tls, v) + int32(2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), i8, jmp, regRow) + _sqlite3VdbeGoto(tls, v, addrOk) + } + } + /* Generate code to report an FK violation to the caller. */ + if (*TTable)(unsafe.Pointer(pTab6)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), 0, regResult+int32(1)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regResult+int32(1)) + } + _sqlite3VdbeMultiLoad(tls, v, regResult+int32(2), __ccgo_ts+19393, libc.VaList(bp+176, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, i8-int32(1))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), regResult, int32(4)) + _sqlite3VdbeResolveLabel(tls, v, addrOk) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 96))) + goto _36 + _36: + ; + i8 = i8 + 1 + pFK1 = (*TFKey)(unsafe.Pointer(pFK1)).FpNextFrom + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), 0, addrTop+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addrTop) + } + break + /* Reinstall the LIKE and GLOB functions. The variant of LIKE + ** used will be case sensitive or not depending on the RHS. + */ + fallthrough + case int32(PragTyp_CASE_SENSITIVE_LIKE): + if zRight != 0 { + _sqlite3RegisterLikeFunctions(tls, db, libc.Int32FromUint8(_sqlite3GetBoolean(tls, zRight, uint8(0)))) + } + break + /* PRAGMA integrity_check + ** PRAGMA integrity_check(N) + ** PRAGMA quick_check + ** PRAGMA quick_check(N) + ** + ** Verify the integrity of the database. + ** + ** The "quick_check" is reduced version of + ** integrity_check designed to detect most database corruption + ** without the overhead of cross-checking indexes. Quick_check + ** is linear time whereas integrity_check is O(NlogN). + ** + ** The maximum number of errors is 100 by default. A different default + ** can be specified using a numeric parameter N. + ** + ** Or, the parameter N can be the name of a table. In that case, only + ** the one table named is verified. The freelist is only verified if + ** the named table is "sqlite_schema" (or one of its aliases). + ** + ** All schemas are checked by default. To check just a single + ** schema, use the form: + ** + ** PRAGMA schema.integrity_check; + */ + fallthrough + case int32(PragTyp_INTEGRITY_CHECK): + pObjTab = uintptr(0) /* Check only this one table, if not NULL */ + isQuick = libc.BoolInt32(libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(zLeft)))]) == int32('q')) + /* If the PRAGMA command was of the form "PRAGMA .integrity_check", + ** then iDb is set to the index of the database identified by . + ** In this case, the integrity of database iDb only is verified by + ** the VDBE created below. + ** + ** Otherwise, if the command was simply "PRAGMA integrity_check" (or + ** "PRAGMA quick_check"), then iDb is set to 0. In this case, set iDb + ** to -1 here, to indicate that the VDBE should verify the integrity + ** of all attached databases. */ + if (*TToken)(unsafe.Pointer(pId2)).Fz == uintptr(0) { + iDb = -int32(1) + } + /* Initialize the VDBE program */ + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + /* Set the maximum error count */ + **(**int32)(__ccgo_up(bp + 104)) = int32(SQLITE_INTEGRITY_CHECK_ERROR_MAX) + if zRight != 0 { + if _sqlite3GetInt32(tls, (*TToken)(unsafe.Pointer(pValue)).Fz, bp+104) != 0 { + if **(**int32)(__ccgo_up(bp + 104)) <= 0 { + **(**int32)(__ccgo_up(bp + 104)) = int32(SQLITE_INTEGRITY_CHECK_ERROR_MAX) + } + } else { + if iDb >= 0 { + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + v1 = uintptr(0) + } + pObjTab = _sqlite3LocateTable(tls, pParse, uint32(0), zRight, v1) + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp + 104))-int32(1), int32(1)) /* reg[1] holds errors left */ + /* Do an integrity check on each database file */ + i9 = 0 + for { + if !(i9 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } /* Array of root page numbers of all btrees */ + cnt = 0 /* Number of entries in aRoot[] */ + if libc.Bool(OMIT_TEMPDB != 0) && i9 == int32(1) { + goto _40 + } + if iDb >= 0 && i9 != iDb { + goto _40 + } + _sqlite3CodeVerifySchema(tls, pParse, i9) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) /* tag-20230327-1 */ + /* Do an integrity check of the B-Tree + ** + ** Begin by finding the root pages numbers + ** for all tables and indices in the database. + */ + pTbls = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i9)*32))).FpSchema + 8 + cnt = 0 + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab7 = (*THashElem)(unsafe.Pointer(x2)).Fdata /* Number of indexes on pTab */ + if _tableSkipIntegrityCheck(tls, pTab7, pObjTab) != 0 { + goto _41 + } + if (*TTable)(unsafe.Pointer(pTab7)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + cnt = cnt + 1 + } + nIdx = 0 + pIdx3 = (*TTable)(unsafe.Pointer(pTab7)).FpIndex + for { + if !(pIdx3 != 0) { + break + } + cnt = cnt + 1 + goto _42 + _42: + ; + pIdx3 = (*TIndex)(unsafe.Pointer(pIdx3)).FpNext + nIdx = nIdx + 1 + } + goto _41 + _41: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + if cnt == 0 { + goto _40 + } + if pObjTab != 0 { + cnt = cnt + 1 + } + aRoot = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(cnt+libc.Int32FromInt32(1)))) + if aRoot == uintptr(0) { + break + } + cnt = 0 + if pObjTab != 0 { + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = 0 + } + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab8 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab8, pObjTab) != 0 { + goto _44 + } + if (*TTable)(unsafe.Pointer(pTab8)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab8)).Ftnum) + } + pIdx4 = (*TTable)(unsafe.Pointer(pTab8)).FpIndex + for { + if !(pIdx4 != 0) { + break + } + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx4)).Ftnum) + goto _46 + _46: + ; + pIdx4 = (*TIndex)(unsafe.Pointer(pIdx4)).FpNext + } + goto _44 + _44: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + **(**int32)(__ccgo_up(aRoot)) = cnt + /* Make sure sufficient number of registers have been allocated */ + _sqlite3TouchRegister(tls, pParse, int32(8)+cnt) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, int32(8), int32(8)+cnt) + _sqlite3ClearTempRegCache(tls, pParse) + /* Do the b-tree integrity checks */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_IntegrityCk), int32(1), cnt, int32(8), aRoot, -int32(15)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(i9)) + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), int32(2)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+19397, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i9)*32))).FzDbSName)), -int32(7)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(2), int32(3), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, addr1) + /* Check that the indexes all have the right number of rows */ + if pObjTab != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + cnt = v2 + _sqlite3VdbeLoadString(tls, v, int32(2), __ccgo_ts+19421) + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + iTab = 0 + pTab9 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab9, pObjTab) != 0 { + goto _49 + } + if (*TTable)(unsafe.Pointer(pTab9)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v2 = cnt + cnt = cnt + 1 + iTab = v2 + } else { + iTab = cnt + pIdx5 = (*TTable)(unsafe.Pointer(pTab9)).FpIndex + for { + if !(pIdx5 != 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx5 + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + break + } + iTab = iTab + 1 + goto _51 + _51: + ; + pIdx5 = (*TIndex)(unsafe.Pointer(pIdx5)).FpNext + } + } + pIdx5 = (*TTable)(unsafe.Pointer(pTab9)).FpIndex + for { + if !(pIdx5 != 0) { + break + } + if (*TIndex)(unsafe.Pointer(pIdx5)).FpPartIdxWhere == uintptr(0) { + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), int32(8)+cnt, 0, int32(8)+iTab) + _sqlite3VdbeLoadString(tls, v, int32(4), (*TIndex)(unsafe.Pointer(pIdx5)).FzName) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(2), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, addr1) + } + cnt = cnt + 1 + goto _52 + _52: + ; + pIdx5 = (*TIndex)(unsafe.Pointer(pIdx5)).FpNext + } + goto _49 + _49: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + /* Make sure all the indices are constructed correctly. + */ + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab10 = (*THashElem)(unsafe.Pointer(x2)).Fdata + pPrior = uintptr(0) + r1 = -int32(1) /* Maximum non-virtual column number */ + if _tableSkipIntegrityCheck(tls, pTab10, pObjTab) != 0 { + goto _53 + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab10)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + goto _53 + } + if isQuick != 0 || (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + pPk1 = uintptr(0) + r2 = 0 + } else { + pPk1 = _sqlite3PrimaryKeyIndex(tls, pTab10) + r2 = _sqlite3GetTempRange(tls, pParse, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), int32(1), r2, r2+libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)-int32(1)) + } + _sqlite3OpenTableAndIndices(tls, pParse, pTab10, int32(OP_OpenRead), uint8(0), int32(1), uintptr(0), bp+108, bp+112) + /* reg[7] counts the number of entries in the table. + ** reg[8+i] counts the number of entries in the i-th index + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, int32(7)) + j4 = 0 + pIdx6 = (*TTable)(unsafe.Pointer(pTab10)).FpIndex + for { + if !(pIdx6 != 0) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, int32(8)+j4) /* index entries counter */ + goto _54 + _54: + ; + pIdx6 = (*TIndex)(unsafe.Pointer(pIdx6)).FpNext + j4 = j4 + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), **(**int32)(__ccgo_up(bp + 108)), 0) + loopTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(7), int32(1)) + /* Fetch the right-most column from the table. This will cause + ** the entire record header to be parsed and sanity checked. It + ** will also prepopulate the cursor column cache that is used + ** by the OP_IsType code, so it is a required step. + */ + if (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + mxCol = -int32(1) + j4 = 0 + for { + if !(j4 < int32((*TTable)(unsafe.Pointer(pTab10)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + mxCol = mxCol + 1 + } + goto _55 + _55: + ; + j4 = j4 + 1 + } + if mxCol == int32((*TTable)(unsafe.Pointer(pTab10)).FiPKey) { + mxCol = mxCol - 1 + } + } else { + /* COLFLAG_VIRTUAL columns are not included in the WITHOUT ROWID + ** PK index column-count, so there is no need to account for them + ** in this case. */ + mxCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(_sqlite3PrimaryKeyIndex(tls, pTab10))).FnColumn) - int32(1) + } + if mxCol >= 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 108)), mxCol, int32(3)) + _sqlite3VdbeTypeofColumn(tls, v, int32(3)) + } + if !(isQuick != 0) { + if pPk1 != 0 { + a1 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxGT), **(**int32)(__ccgo_up(bp + 108)), 0, r2, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), r2) + zErr = _sqlite3MPrintf(tls, db, __ccgo_ts+19450, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr, -int32(7)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, a1) + _sqlite3VdbeJumpHere(tls, v, a1+int32(1)) + j4 = 0 + for { + if !(j4 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) { + break + } + _sqlite3ExprCodeLoadIndexColumn(tls, pParse, pPk1, **(**int32)(__ccgo_up(bp + 108)), j4, r2+j4) + goto _56 + _56: + ; + j4 = j4 + 1 + } + } + } + /* Verify datatypes for all columns: + ** + ** (1) NOT NULL columns may not contain a NULL + ** (2) Datatype must be exact for non-ANY columns in STRICT tables + ** (3) Datatype for TEXT columns in non-STRICT tables must be + ** NULL, TEXT, or BLOB. + ** (4) Datatype for numeric columns in non-STRICT tables must not + ** be a TEXT value that can be losslessly converted to numeric. + */ + bStrict = libc.BoolInt32((*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_Strict) != uint32(0)) + j4 = 0 + for { + if !(j4 < int32((*TTable)(unsafe.Pointer(pTab10)).FnCol)) { + break + } + pCol1 = (*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16 /* Check datatypes (besides NOT NULL) */ + if j4 == int32((*TTable)(unsafe.Pointer(pTab10)).FiPKey) { + goto _57 + } + if bStrict != 0 { + doTypeCheck = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4)) > int32(COLTYPE_ANY)) + } else { + doTypeCheck = libc.BoolInt32(libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) > int32(SQLITE_AFF_BLOB)) + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf>>0)) == 0 && !(doTypeCheck != 0) { + goto _57 + } + /* Compute the operands that will be needed for OP_IsType */ + p4 = int32(SQLITE_NULL) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab10, **(**int32)(__ccgo_up(bp + 108)), j4, int32(3)) + p11 = -int32(1) + p3 = int32(3) + } else { + if (*TColumn)(unsafe.Pointer(pCol1)).FiDflt != 0 { + **(**uintptr)(__ccgo_up(bp + 120)) = uintptr(0) + _sqlite3ValueFromExpr(tls, db, _sqlite3ColumnExpr(tls, pTab10, pCol1), (*Tsqlite3)(unsafe.Pointer(db)).Fenc, (*TColumn)(unsafe.Pointer(pCol1)).Faffinity, bp+120) + if **(**uintptr)(__ccgo_up(bp + 120)) != 0 { + p4 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 120))) + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp + 120))) + } + } + p11 = **(**int32)(__ccgo_up(bp + 108)) + if !((*TTable)(unsafe.Pointer(pTab10)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + p3 = _sqlite3TableColumnToIndex(tls, _sqlite3PrimaryKeyIndex(tls, pTab10), j4) + } else { + p3 = int32(_sqlite3TableColumnToStorage(tls, pTab10, int16(j4))) + } + } + labelError = _sqlite3VdbeMakeLabel(tls, pParse) + labelOk = _sqlite3VdbeMakeLabel(tls, pParse) + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf>>0)) != 0 { + jmp2 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + if p11 < 0 { + _sqlite3VdbeChangeP5(tls, v, uint16(0x0f)) /* INT, REAL, TEXT, or BLOB */ + jmp3 = jmp2 + } else { + _sqlite3VdbeChangeP5(tls, v, uint16(0x0d)) /* INT, TEXT, or BLOB */ + /* OP_IsType does not detect NaN values in the database file + ** which should be treated as a NULL. So if the header type + ** is REAL, we have to load the actual data using OP_Column + ** to reliably determine if the value is a NULL. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), p11, p3, int32(3)) + _sqlite3ColumnDefault(tls, v, pTab10, j4, int32(3)) + jmp3 = _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), int32(3), labelOk) + } + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19486, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (*TColumn)(unsafe.Pointer(pCol1)).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + if doTypeCheck != 0 { + _sqlite3VdbeGoto(tls, v, labelError) + _sqlite3VdbeJumpHere(tls, v, jmp2) + _sqlite3VdbeJumpHere(tls, v, jmp3) + } else { + /* VDBE byte code will fall thru */ + } + } + if bStrict != 0 && doTypeCheck != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(_aStdTypeMask[int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4))-int32(1)])) + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19506, libc.VaList(bp+176, _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4))-int32(1)], (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } else { + if !(bStrict != 0) && libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) == int32(SQLITE_AFF_TEXT) { + /* (3) Datatype for TEXT columns in non-STRICT tables must be + ** NULL, TEXT, or BLOB. */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1c)) /* NULL, TEXT, or BLOB */ + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19528, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } else { + if !(bStrict != 0) && libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) { + /* (4) Datatype for numeric columns in non-STRICT tables must not + ** be a TEXT value that can be converted to numeric. */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1b)) /* NULL, INT, FLOAT, or BLOB */ + if p11 >= 0 { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab10, **(**int32)(__ccgo_up(bp + 108)), j4, int32(3)) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), int32(3), int32(1), 0, __ccgo_ts+19551, -int32(1)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), -int32(1), labelOk, int32(3), p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1c)) /* NULL, TEXT, or BLOB */ + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19553, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } + } + } + _sqlite3VdbeResolveLabel(tls, v, labelError) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, labelOk) + goto _57 + _57: + ; + j4 = j4 + 1 + } + /* Verify CHECK constraints */ + if (*TTable)(unsafe.Pointer(pTab10)).FpCheck != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_IgnoreChecks) == uint64(0) { + pCheck = _sqlite3ExprListDup(tls, db, (*TTable)(unsafe.Pointer(pTab10)).FpCheck, 0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + addrCkFault = _sqlite3VdbeMakeLabel(tls, pParse) + addrCkOk = _sqlite3VdbeMakeLabel(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = **(**int32)(__ccgo_up(bp + 108)) + int32(1) + k3 = (*TExprList)(unsafe.Pointer(pCheck)).FnExpr - int32(1) + for { + if !(k3 > 0) { + break + } + _sqlite3ExprIfFalse(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(k3)*32))).FpExpr, addrCkFault, 0) + goto _58 + _58: + ; + k3 = k3 - 1 + } + _sqlite3ExprIfTrue(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pCheck + 8))).FpExpr, addrCkOk, int32(SQLITE_JUMPIFNULL)) + _sqlite3VdbeResolveLabel(tls, v, addrCkFault) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 + zErr2 = _sqlite3MPrintf(tls, db, __ccgo_ts+19573, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr2, -int32(7)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, addrCkOk) + } + _sqlite3ExprListDelete(tls, db, pCheck) + } + if !(isQuick != 0) { /* Omit the remaining tests for quick_check */ + /* Validate index entries for the current row */ + j4 = 0 + pIdx6 = (*TTable)(unsafe.Pointer(pTab10)).FpIndex + for { + if !(pIdx6 != 0) { + break + } + ckUniq = _sqlite3VdbeMakeLabel(tls, pParse) + if pPk1 == pIdx6 { + goto _59 + } + r1 = _sqlite3GenerateIndexKey(tls, pParse, pIdx6, **(**int32)(__ccgo_up(bp + 108)), 0, 0, bp+128, pPrior, r1) + pPrior = pIdx6 + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(8)+j4, int32(1)) /* increment entry count */ + /* Verify that an index entry exists for the current table row */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), **(**int32)(__ccgo_up(bp + 112))+j4, ckUniq, r1, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnColumn)) + jmp21 = _sqlite3VdbeAddOp3(tls, v, int32(OP_IFindKey), **(**int32)(__ccgo_up(bp + 112))+j4, ckUniq, r1) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pIdx6, -int32(6)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+19603, libc.VaList(bp+176, (*TIndex)(unsafe.Pointer(pIdx6)).FzName)), -int32(7)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, ckUniq) + _sqlite3VdbeJumpHere(tls, v, jmp21) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19662) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19667) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(3), int32(3)) + jmp5 = _sqlite3VdbeLoadString(tls, v, int32(4), (*TIndex)(unsafe.Pointer(pIdx6)).FzName) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(3), int32(3)) + jmp4 = _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, ckUniq) + /* The OP_IdxRowid opcode is an optimized version of OP_Column + ** that extracts the rowid off the end of the index record. + ** But it only works correctly if index record does not have + ** any extra bytes at the end. Verify that this is the case. */ + if (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), **(**int32)(__ccgo_up(bp + 112))+j4, int32(3)) + jmp7 = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), int32(3), 0, r1+libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnColumn)-int32(1)) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19688) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19724) + _sqlite3VdbeGoto(tls, v, jmp5-int32(1)) + _sqlite3VdbeJumpHere(tls, v, jmp7) + } + /* Any indexed columns with non-BINARY collations must still hold + ** the exact same text value as the table. */ + label6 = 0 + kk = 0 + for { + if !(kk < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) { + break + } + if **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx6)).FazColl + uintptr(kk)*8)) == uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) { + goto _60 + } + if label6 == 0 { + label6 = _sqlite3VdbeMakeLabel(tls, pParse) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 112))+j4, kk, int32(3)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ne), int32(3), label6, r1+kk) + goto _60 + _60: + ; + kk = kk + 1 + } + if label6 != 0 { + jmp6 = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + _sqlite3VdbeResolveLabel(tls, v, label6) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19662) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19735) + _sqlite3VdbeGoto(tls, v, jmp5-int32(1)) + _sqlite3VdbeJumpHere(tls, v, jmp6) + } + /* For UNIQUE indexes, verify that only one entry exists with the + ** current key. The entry is unique if (1) any column is NULL + ** or (2) the next entry has a different key */ + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx6)).FonError) != OE_None { + uniqOk = _sqlite3VdbeMakeLabel(tls, pParse) + kk = 0 + for { + if !(kk < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) { + break + } + iCol1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx6)).FaiColumn + uintptr(kk)*2))) + if iCol1 >= 0 && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(iCol1)*16 + 8))&0xf>>0)) != 0 { + goto _61 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), r1+kk, uniqOk) + goto _61 + _61: + ; + kk = kk + 1 + } + jmp61 = _sqlite3VdbeAddOp1(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 112))+j4) + _sqlite3VdbeGoto(tls, v, uniqOk) + _sqlite3VdbeJumpHere(tls, v, jmp61) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxGT), **(**int32)(__ccgo_up(bp + 112))+j4, uniqOk, r1, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19762) + _sqlite3VdbeGoto(tls, v, jmp5) + _sqlite3VdbeResolveLabel(tls, v, uniqOk) + } + _sqlite3VdbeJumpHere(tls, v, jmp4) + _sqlite3ResolvePartIdxLabel(tls, pParse, **(**int32)(__ccgo_up(bp + 128))) + goto _59 + _59: + ; + pIdx6 = (*TIndex)(unsafe.Pointer(pIdx6)).FpNext + j4 = j4 + 1 + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 108)), loopTop) + _sqlite3VdbeJumpHere(tls, v, loopTop-int32(1)) + if pPk1 != 0 { + _sqlite3ReleaseTempRange(tls, pParse, r2, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + } + goto _53 + _53: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + /* Second pass to invoke the xIntegrity method on all virtual + ** tables. + */ + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab11 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab11, pObjTab) != 0 { + goto _62 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab11)).FeTabType) == TABTYP_NORM { + goto _62 + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab11)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + goto _62 + } + if int32((*TTable)(unsafe.Pointer(pTab11)).FnCol) <= 0 { + zMod = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).FazArg)) + if _sqlite3HashFind(tls, db+576, zMod) == uintptr(0) { + goto _62 + } + } + _sqlite3ViewGetColumnNames(tls, pParse, pTab11) + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).Fp == uintptr(0) { + goto _62 + } + pVTab = (*TVTable)(unsafe.Pointer((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).Fp)).FpVtab + if pVTab == uintptr(0) { + goto _62 + } + if (*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule == uintptr(0) { + goto _62 + } + if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule)).FiVersion < int32(4) { + goto _62 + } + if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule)).FxIntegrity == uintptr(0) { + goto _62 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_VCheck), i9, int32(3), isQuick) + (*TTable)(unsafe.Pointer(pTab11)).FnTabRef = (*TTable)(unsafe.Pointer(pTab11)).FnTabRef + 1 + _sqlite3VdbeAppendP4(tls, v, pTab11, -int32(17)) + a11 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, a11) + goto _62 + goto _62 + _62: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + goto _40 + _40: + ; + i9 = i9 + 1 + } + aOp2 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(28)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_endCode)), _iLn21) + if aOp2 != 0 { + (**(**TVdbeOp)(__ccgo_up(aOp2))).Fp2 = int32(1) - **(**int32)(__ccgo_up(bp + 104)) + (**(**TVdbeOp)(__ccgo_up(aOp2 + 2*24))).Fp4type = int8(-libc.Int32FromInt32(1)) + *(*uintptr)(unsafe.Pointer(aOp2 + 2*24 + 16)) = __ccgo_ts + 19789 + (**(**TVdbeOp)(__ccgo_up(aOp2 + 5*24))).Fp4type = int8(-libc.Int32FromInt32(1)) + *(*uintptr)(unsafe.Pointer(aOp2 + 5*24 + 16)) = _sqlite3ErrStr(tls, int32(SQLITE_CORRUPT)) + } + _sqlite3VdbeChangeP3(tls, v, 0, _sqlite3VdbeCurrentAddr(tls, v)-int32(2)) + break + /* + ** PRAGMA encoding + ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" + ** + ** In its first form, this pragma returns the encoding of the main + ** database. If the database is not initialized, it is initialized now. + ** + ** The second form of this pragma is a no-op if the main database file + ** has not already been initialized. In this case it sets the default + ** encoding that will be used for the main database file if a new file + ** is created. If an existing main database file is opened, then the + ** default text encoding for the existing database is used. + ** + ** In all cases new databases created using the ATTACH command are + ** created to use the same default text encoding as the main database. If + ** the main database has not been initialized and/or created when ATTACH + ** is executed, this is done before the ATTACH operation. + ** + ** In the second form this pragma sets the text encoding to be used in + ** new database files created using this database handle. It is only + ** useful if invoked immediately after the main database i + */ + fallthrough + case int32(PragTyp_ENCODING): + if !(zRight != 0) { /* "PRAGMA encoding" */ + if _sqlite3ReadSchema(tls, pParse) != 0 { + goto pragma_out + } + _returnSingleText(tls, v, _encnames1[(*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc].FzName) + } else { /* "PRAGMA encoding = XXX" */ + /* Only change the value of sqlite.enc if the database handle is not + ** initialized. If the main database exists, the new sqlite.enc value + ** will be overwritten when the schema is next loaded. If it does not + ** already exists, it will be created to use the new encoding value. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_EncodingFixed) == uint32(0) { + pEnc = uintptr(unsafe.Pointer(&_encnames1)) + for { + if !((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName != 0) { + break + } + if 0 == _sqlite3StrICmp(tls, zRight, (*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName) { + if (*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).Fenc != 0 { + v2 = libc.Int32FromUint8((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).Fenc) + } else { + v2 = int32(SQLITE_UTF16LE) + } + enc = libc.Uint8FromInt32(v2) + (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).Fenc = enc + _sqlite3SetTextEncoding(tls, db, enc) + break + } + goto _63 + _63: + ; + pEnc += 16 + } + if !((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19850, libc.VaList(bp+176, zRight)) + } + } + } + break + /* + ** PRAGMA [schema.]schema_version + ** PRAGMA [schema.]schema_version = + ** + ** PRAGMA [schema.]user_version + ** PRAGMA [schema.]user_version = + ** + ** PRAGMA [schema.]freelist_count + ** + ** PRAGMA [schema.]data_version + ** + ** PRAGMA [schema.]application_id + ** PRAGMA [schema.]application_id = + ** + ** The pragma's schema_version and user_version are used to set or get + ** the value of the schema-version and user-version, respectively. Both + ** the schema-version and the user-version are 32-bit signed integers + ** stored in the database header. + ** + ** The schema-cookie is usually only manipulated internally by SQLite. It + ** is incremented by SQLite whenever the database schema is modified (by + ** creating or dropping a table or index). The schema version is used by + ** SQLite each time a query is executed to ensure that the internal cache + ** of the schema used when compiling the SQL query matches the schema of + ** the database against which the compiled query is actually executed. + ** Subverting this mechanism by using "PRAGMA schema_version" to modify + ** the schema-version is potentially dangerous and may lead to program + ** crashes or database corruption. Use with caution! + ** + ** The user-version is not used internally by SQLite. It may be used by + ** applications for any purpose. + */ + fallthrough + case int32(PragTyp_HEADER_VALUE): + iCookie = libc.Int32FromUint64((*TPragmaName)(unsafe.Pointer(pPragma)).FiArg) /* Which cookie to read or write */ + _sqlite3VdbeUsesBtree(tls, v, iDb) + if zRight != 0 && libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_ReadOnly) == 0 { + aOp3 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_setCookie)), 0) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp3))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp2 = iCookie + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp3 = _sqlite3Atoi(tls, zRight) + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp5 = uint16(1) + if iCookie == int32(BTREE_SCHEMA_VERSION) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) { + /* Do not allow the use of PRAGMA schema_version=VALUE in defensive + ** mode. Change the OP_SetCookie opcode into a no-op. */ + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fopcode = uint8(OP_Noop) + } + } else { + aOp4 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(12)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_readCookie)), 0) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp4))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp4 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp4 + 1*24))).Fp3 = iCookie + _sqlite3VdbeReusable(tls, v) + } + break + /* + ** PRAGMA compile_options + ** + ** Return the names of all compile-time options used in this build, + ** one option per row. + */ + fallthrough + case int32(PragTyp_COMPILE_OPTIONS): + i10 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(1) + for { + v2 = i10 + i10 = i10 + 1 + v1 = Xsqlite3_compileoption_get(tls, v2) + zOpt = v1 + if !(v1 != uintptr(0)) { + break + } + _sqlite3VdbeLoadString(tls, v, int32(1), zOpt) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) + } + _sqlite3VdbeReusable(tls, v) + break + /* + ** PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate + ** + ** Checkpoint the database. + */ + fallthrough + case int32(PragTyp_WAL_CHECKPOINT): + if (*TToken)(unsafe.Pointer(pId2)).Fz != 0 { + v2 = iDb + } else { + v2 = libc.Int32FromInt32(SQLITE_MAX_ATTACHED) + libc.Int32FromInt32(2) + } + iBt = v2 + eMode2 = SQLITE_CHECKPOINT_PASSIVE + if zRight != 0 { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19016) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_FULL) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19875) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_RESTART) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19169) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_TRUNCATE) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19883) == 0 { + eMode2 = -int32(1) + } + } + } + } + } + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Checkpoint), iBt, eMode2, int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(3)) + break + /* + ** PRAGMA wal_autocheckpoint + ** PRAGMA wal_autocheckpoint = N + ** + ** Configure a database connection to automatically checkpoint a database + ** after accumulating N frames in the log. Or query for the current value + ** of N. + */ + fallthrough + case int32(PragTyp_WAL_AUTOCHECKPOINT): + if zRight != 0 { + Xsqlite3_wal_autocheckpoint(tls, db, _sqlite3Atoi(tls, zRight)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxWalCallback == __ccgo_fp(_sqlite3WalDefaultHook) { + v2 = int32(int64((*Tsqlite3)(unsafe.Pointer(db)).FpWalArg)) + } else { + v2 = 0 + } + _returnSingleInt(tls, v, int64(v2)) + break + /* + ** PRAGMA shrink_memory + ** + ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database + ** connection on which it is invoked to free up as much memory as it + ** can, by calling sqlite3_db_release_memory(). + */ + fallthrough + case int32(PragTyp_SHRINK_MEMORY): + Xsqlite3_db_release_memory(tls, db) + break + /* + ** PRAGMA optimize + ** PRAGMA optimize(MASK) + ** PRAGMA schema.optimize + ** PRAGMA schema.optimize(MASK) + ** + ** Attempt to optimize the database. All schemas are optimized in the first + ** two forms, and only the specified schema is optimized in the latter two. + ** + ** The details of optimizations performed by this pragma are expected + ** to change and improve over time. Applications should anticipate that + ** this pragma will perform new optimizations in future releases. + ** + ** The optional argument is a bitmask of optimizations to perform: + ** + ** 0x00001 Debugging mode. Do not actually perform any optimizations + ** but instead return one line of text for each optimization + ** that would have been done. Off by default. + ** + ** 0x00002 Run ANALYZE on tables that might benefit. On by default. + ** See below for additional information. + ** + ** 0x00010 Run all ANALYZE operations using an analysis_limit that + ** is the lessor of the current analysis_limit and the + ** SQLITE_DEFAULT_OPTIMIZE_LIMIT compile-time option. + ** The default value of SQLITE_DEFAULT_OPTIMIZE_LIMIT is + ** currently (2024-02-19) set to 2000, which is such that + ** the worst case run-time for PRAGMA optimize on a 100MB + ** database will usually be less than 100 milliseconds on + ** a RaspberryPI-4 class machine. On by default. + ** + ** 0x10000 Look at tables to see if they need to be reanalyzed + ** due to growth or shrinkage even if they have not been + ** queried during the current connection. Off by default. + ** + ** The default MASK is and always shall be 0x0fffe. In the current + ** implementation, the default mask only covers the 0x00002 optimization, + ** though additional optimizations that are covered by 0x0fffe might be + ** added in the future. Optimizations that are off by default and must + ** be explicitly requested have masks of 0x10000 or greater. + ** + ** DETERMINATION OF WHEN TO RUN ANALYZE + ** + ** In the current implementation, a table is analyzed if only if all of + ** the following are true: + ** + ** (1) MASK bit 0x00002 is set. + ** + ** (2) The table is an ordinary table, not a virtual table or view. + ** + ** (3) The table name does not begin with "sqlite_". + ** + ** (4) One or more of the following is true: + ** (4a) The 0x10000 MASK bit is set. + ** (4b) One or more indexes on the table lacks an entry + ** in the sqlite_stat1 table. + ** (4c) The query planner used sqlite_stat1-style statistics for one + ** or more indexes of the table at some point during the lifetime + ** of the current connection. + ** + ** (5) One or more of the following is true: + ** (5a) One or more indexes on the table lacks an entry + ** in the sqlite_stat1 table. (Same as 4a) + ** (5b) The number of rows in the table has increased or decreased by + ** 10-fold. In other words, the current size of the table is + ** 10 times larger than the size in sqlite_stat1 or else the + ** current size is less than 1/10th the size in sqlite_stat1. + ** + ** The rules for when tables are analyzed are likely to change in + ** future releases. Future versions of SQLite might accept a string + ** literal argument to this pragma that contains a mnemonic description + ** of the options rather than a bitmap. + */ + fallthrough + case int32(PragTyp_OPTIMIZE): /* Analysis limit to use */ + nCheck = 0 /* Number of tables to be optimized */ + nBtree = 0 /* Number of indexes on the current table */ + if zRight != 0 { + opMask = libc.Uint32FromInt32(_sqlite3Atoi(tls, zRight)) + if opMask&uint32(0x02) == uint32(0) { + break + } + } else { + opMask = uint32(0xfffe) + } + if opMask&uint32(0x10) == uint32(0) { + nLimit = 0 + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit > 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit < int32(SQLITE_DEFAULT_OPTIMIZE_LIMIT) { + nLimit = 0 + } else { + nLimit = int32(SQLITE_DEFAULT_OPTIMIZE_LIMIT) + } + } + v1 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + iTabCur = v2 + if zDb != 0 { + v2 = iDb + } else { + v2 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + } + iDbLast = v2 + for { + if !(iDb <= iDbLast) { + break + } + if iDb == int32(1) { + goto _71 + } + _sqlite3CodeVerifySchema(tls, pParse, iDb) + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + k4 = (*THash)(unsafe.Pointer(pSchema + 8)).Ffirst + for { + if !(k4 != 0) { + break + } + pTab12 = (*THashElem)(unsafe.Pointer(k4)).Fdata + /* This only works for ordinary tables */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab12)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + goto _73 + } + /* Do not scan system tables */ + if 0 == Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab12)).FzName, __ccgo_ts+6756, int32(7)) { + goto _73 + } + /* Find the size of the table as last recorded in sqlite_stat1. + ** If any index is unanalyzed, then the threshold is -1 to + ** indicate a new, unanalyzed index + */ + szThreshold = (*TTable)(unsafe.Pointer(pTab12)).FnRowLogEst + nIndex = 0 + pIdx7 = (*TTable)(unsafe.Pointer(pTab12)).FpIndex + for { + if !(pIdx7 != 0) { + break + } + nIndex = nIndex + 1 + if !(int32(uint32(*(*uint16)(unsafe.Pointer(pIdx7 + 100))&0x80>>7)) != 0) { + szThreshold = int16(-int32(1)) /* Always analyze if any index lacks statistics */ + } + goto _74 + _74: + ; + pIdx7 = (*TIndex)(unsafe.Pointer(pIdx7)).FpNext + } + /* If table pTab has not been used in a way that would benefit from + ** having analysis statistics during the current session, then skip it, + ** unless the 0x10000 MASK bit is set. */ + if (*TTable)(unsafe.Pointer(pTab12)).FtabFlags&uint32(TF_MaybeReanalyze) != uint32(0) { + /* Check for size change if stat1 has been used for a query */ + } else { + if opMask&uint32(0x10000) != 0 { + /* Check for size change if 0x10000 is set */ + } else { + if (*TTable)(unsafe.Pointer(pTab12)).FpIndex != uintptr(0) && int32(szThreshold) < 0 { + /* Do analysis if unanalyzed indexes exists */ + } else { + /* Otherwise, we can skip this table */ + goto _73 + } + } + } + nCheck = nCheck + 1 + if nCheck == int32(2) { + /* If ANALYZE might be invoked two or more times, hold a write + ** transaction for efficiency */ + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + } + nBtree = nBtree + (nIndex + int32(1)) + /* Reanalyze if the table is 10 times larger or smaller than + ** the last analysis. Unconditional reanalysis if there are + ** unanalyzed indexes. */ + _sqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab12, int32(OP_OpenRead)) + if int32(szThreshold) >= 0 { + iRange = int16(33) /* 10x size change */ + if int32(szThreshold) >= int32(iRange) { + v2 = int32(szThreshold) - int32(iRange) + } else { + v2 = -int32(1) + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IfSizeBetween), iTabCur, libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3VdbeCurrentAddr(tls, v)+int32(2))+opMask&uint32(1)), v2, int32(szThreshold)+int32(iRange)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iTabCur, libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3VdbeCurrentAddr(tls, v)+int32(2))+opMask&uint32(1))) + } + zSubSql = _sqlite3MPrintf(tls, db, __ccgo_ts+19888, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(pTab12)).FzName)) + if opMask&uint32(0x01) != 0 { + r11 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, r11, 0, zSubSql, -int32(7)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), r11, int32(1)) + } else { + if nLimit != 0 { + v2 = int32(0x02) + } else { + v2 = 00 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_SqlExec), v2, nLimit, 0, zSubSql, -int32(7)) + } + goto _73 + _73: + ; + k4 = (*THashElem)(unsafe.Pointer(k4)).Fnext + } + goto _71 + _71: + ; + iDb = iDb + 1 + } + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + /* In a schema with a large number of tables and indexes, scale back + ** the analysis_limit to avoid excess run-time in the worst case. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) && nLimit > 0 && nBtree > int32(100) { + nLimit = int32(100) * nLimit / nBtree + if nLimit < int32(100) { + nLimit = int32(100) + } + aOp5 = _sqlite3VdbeGetOp(tls, v, 0) + iEnd = _sqlite3VdbeCurrentAddr(tls, v) + iAddr1 = 0 + for { + if !(iAddr1 < iEnd) { + break + } + if libc.Int32FromUint8((**(**TVdbeOp)(__ccgo_up(aOp5 + uintptr(iAddr1)*24))).Fopcode) == int32(OP_SqlExec) { + (**(**TVdbeOp)(__ccgo_up(aOp5 + uintptr(iAddr1)*24))).Fp2 = nLimit + } + goto _77 + _77: + ; + iAddr1 = iAddr1 + 1 + } + } + break + /* + ** PRAGMA busy_timeout + ** PRAGMA busy_timeout = N + ** + ** Call sqlite3_busy_timeout(db, N). Return the current timeout value + ** if one is set. If no busy handler or a different busy handler is set + ** then 0 is returned. Setting the busy_timeout to 0 or negative + ** disables the timeout. + */ + /*case PragTyp_BUSY_TIMEOUT*/ + fallthrough + default: + if zRight != 0 { + Xsqlite3_busy_timeout(tls, db, _sqlite3Atoi(tls, zRight)) + } + _returnSingleInt(tls, v, int64((*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout)) + break + /* + ** PRAGMA soft_heap_limit + ** PRAGMA soft_heap_limit = N + ** + ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the + ** sqlite3_soft_heap_limit64() interface with the argument N, if N is + ** specified and is a non-negative integer. + ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always + ** returns the same integer that would be returned by the + ** sqlite3_soft_heap_limit64(-1) C-language function. + */ + fallthrough + case int32(PragTyp_SOFT_HEAP_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+136) == SQLITE_OK { + Xsqlite3_soft_heap_limit64(tls, **(**Tsqlite3_int64)(__ccgo_up(bp + 136))) + } + _returnSingleInt(tls, v, Xsqlite3_soft_heap_limit64(tls, int64(-int32(1)))) + break + /* + ** PRAGMA hard_heap_limit + ** PRAGMA hard_heap_limit = N + ** + ** Invoke sqlite3_hard_heap_limit64() to query or set the hard heap + ** limit. The hard heap limit can be activated or lowered by this + ** pragma, but not raised or deactivated. Only the + ** sqlite3_hard_heap_limit64() C-language API can raise or deactivate + ** the hard heap limit. This allows an application to set a heap limit + ** constraint that cannot be relaxed by an untrusted SQL script. + */ + fallthrough + case int32(PragTyp_HARD_HEAP_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+144) == SQLITE_OK { + iPrior = Xsqlite3_hard_heap_limit64(tls, int64(-int32(1))) + if **(**Tsqlite3_int64)(__ccgo_up(bp + 144)) > 0 && (iPrior == 0 || iPrior > **(**Tsqlite3_int64)(__ccgo_up(bp + 144))) { + Xsqlite3_hard_heap_limit64(tls, **(**Tsqlite3_int64)(__ccgo_up(bp + 144))) + } + } + _returnSingleInt(tls, v, Xsqlite3_hard_heap_limit64(tls, int64(-int32(1)))) + break + /* + ** PRAGMA threads + ** PRAGMA threads = N + ** + ** Configure the maximum number of worker threads. Return the new + ** maximum, which might be less than requested. + */ + fallthrough + case int32(PragTyp_THREADS): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+152) == SQLITE_OK && **(**Tsqlite3_int64)(__ccgo_up(bp + 152)) >= 0 { + Xsqlite3_limit(tls, db, int32(SQLITE_LIMIT_WORKER_THREADS), int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 152))&libc.Int64FromInt32(0x7fffffff))) + } + _returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, int32(SQLITE_LIMIT_WORKER_THREADS), -int32(1)))) + break + /* + ** PRAGMA analysis_limit + ** PRAGMA analysis_limit = N + ** + ** Configure the maximum number of rows that ANALYZE will examine + ** in each index that it looks at. Return the new limit. + */ + fallthrough + case int32(PragTyp_ANALYSIS_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+160) == SQLITE_OK && **(**Tsqlite3_int64)(__ccgo_up(bp + 160)) >= 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 160)) & libc.Int64FromInt32(0x7fffffff)) + } + _returnSingleInt(tls, v, int64((*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit)) /* IMP: R-57594-65522 */ + break + } /* End of the PRAGMA switch */ + /* The following block is a no-op unless SQLITE_DEBUG is defined. Its only + ** purpose is to execute assert() statements to verify that if the + ** PragFlg_NoColumns1 flag is set and the caller specified an argument + ** to the PRAGMA, the implementation has not added any OP_ResultRow + ** instructions to the VM. */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns1) != 0 && zRight != 0 { + } + goto pragma_out +pragma_out: + ; + _sqlite3DbFree(tls, db, zLeft) + _sqlite3DbFree(tls, db, zRight) +} diff --git a/internal/engine/lib/sqlite_g_0000000000001a80.go b/internal/engine/lib/sqlite_g_0000000000001a80.go new file mode 100644 index 0000000..b6c1bfb --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000001a80.go @@ -0,0 +1,673 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Do various sanity checks on a single page of a tree. Return +// ** the tree depth. Root pages return 0. Parents of root pages +// ** return 1, and so forth. +// ** +// ** These checks are done: +// ** +// ** 1. Make sure that cells and freeblocks do not overlap +// ** but combine to completely cover the page. +// ** 2. Make sure integer cell keys are in order. +// ** 3. Check the integrity of overflow pages. +// ** 4. Recursively call checkTreePage on all children. +// ** 5. Verify that the depth of all children is the same. +// */ +func _checkTreePage(tls *libc.TLS, pCheck uintptr, iPage TPgno, piMinKey uintptr, _maxKey Ti64) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + *(*Ti64)(unsafe.Pointer(bp)) = _maxKey + var cellStart, d2, depth, doCoverageCheck, hdr, i, j, keyCanBeEqual, nCell, nFrag, pgno, rc, saved_v1, saved_v2, size1, v1 int32 + var contentOffset, nPage, pc, prev, size, usableSize Tu32 + var data, heap, pBt, pCell, pCellIdx, saved_zPfx uintptr + var pgnoOvfl TPgno + var savedIsInit Tu8 + var _ /* info at bp+24 */ TCellInfo + var _ /* pPage at bp+8 */ uintptr + var _ /* x at bp+16 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cellStart, contentOffset, d2, data, depth, doCoverageCheck, hdr, heap, i, j, keyCanBeEqual, nCell, nFrag, nPage, pBt, pCell, pCellIdx, pc, pgno, pgnoOvfl, prev, rc, savedIsInit, saved_v1, saved_v2, saved_zPfx, size, size1, usableSize, v1 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Result code from subroutine call */ + depth = -int32(1) /* Number of cells */ + doCoverageCheck = int32(1) /* True if cell coverage checking should be done */ + keyCanBeEqual = int32(1) /* Offset to the start of the cell content area */ + heap = uintptr(0) + prev = uint32(0) /* Next and previous entry on the min-heap */ + saved_zPfx = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx + saved_v1 = libc.Int32FromUint32((*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv1) + saved_v2 = (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv2 + savedIsInit = uint8(0) + /* Check that the page exists + */ + _checkProgress(tls, pCheck) + if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr == 0 { + goto end_of_check + } + pBt = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt + usableSize = (*TBtShared)(unsafe.Pointer(pBt)).FusableSize + if iPage == uint32(0) { + return 0 + } + if _checkRef(tls, pCheck, iPage) != 0 { + return 0 + } + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = __ccgo_ts + 4598 + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv1 = iPage + v1 = _btreeGetPage(tls, pBt, iPage, bp+8, 0) + rc = v1 + if v1 != 0 { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4616, libc.VaList(bp+56, rc)) + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<= 0 && (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0) { + break + } + /* Check cell size */ + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv2 = i + pc = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pCellIdx)))< usableSize-uint32(4) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4770, libc.VaList(bp+56, pc, contentOffset, usableSize-uint32(4))) + doCoverageCheck = 0 + goto _4 + } + pCell = data + uintptr(pc) + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FxParseCell})))(tls, **(**uintptr)(__ccgo_up(bp + 8)), pCell, bp+24) + if pc+uint32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnSize) > usableSize { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4800, 0) + doCoverageCheck = 0 + goto _4 + } + /* Check for integer primary key out of range */ + if (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FintKey != 0 { + if keyCanBeEqual != 0 { + v1 = libc.BoolInt32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnKey > **(**Ti64)(__ccgo_up(bp))) + } else { + v1 = libc.BoolInt32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnKey >= **(**Ti64)(__ccgo_up(bp))) + } + if v1 != 0 { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4824, libc.VaList(bp+56, (**(**TCellInfo)(__ccgo_up(bp + 24))).FnKey)) + } + **(**Ti64)(__ccgo_up(bp)) = (**(**TCellInfo)(__ccgo_up(bp + 24))).FnKey + keyCanBeEqual = 0 /* Only the first key on the page may ==maxKey */ + } + /* Check the content overflow list */ + if (**(**TCellInfo)(__ccgo_up(bp + 24))).FnPayload > uint32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnLocal) { /* First page of the overflow chain */ + nPage = ((**(**TCellInfo)(__ccgo_up(bp + 24))).FnPayload - uint32((**(**TCellInfo)(__ccgo_up(bp + 24))).FnLocal) + usableSize - uint32(5)) / (usableSize - uint32(4)) + pgnoOvfl = _sqlite3Get4byte(tls, pCell+uintptr(libc.Int32FromUint16((**(**TCellInfo)(__ccgo_up(bp + 24))).FnSize)-int32(4))) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _checkPtrmap(tls, pCheck, pgnoOvfl, uint8(PTRMAP_OVERFLOW1), iPage) + } + _checkList(tls, pCheck, 0, pgnoOvfl, nPage) + } + if !((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).Fleaf != 0) { + /* Check sanity of left child page for internal pages */ + pgno = libc.Int32FromUint32(_sqlite3Get4byte(tls, pCell)) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _checkPtrmap(tls, pCheck, libc.Uint32FromInt32(pgno), uint8(PTRMAP_BTREE), iPage) + } + d2 = _checkTreePage(tls, pCheck, libc.Uint32FromInt32(pgno), bp, **(**Ti64)(__ccgo_up(bp))) + keyCanBeEqual = 0 + if d2 != depth { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4848, 0) + depth = d2 + } + } else { + /* Populate the coverage-checking heap for leaf pages */ + _btreeHeapInsert(tls, heap, pc< 0 { + /* For leaf pages, the min-heap has already been initialized and the + ** cells have already been inserted. But for internal pages, that has + ** not yet been done, so do it now */ + if !((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).Fleaf != 0) { + heap = (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fheap + **(**Tu32)(__ccgo_up(heap)) = uint32(0) + i = nCell - int32(1) + for { + if !(i >= 0) { + break + } + pc = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(cellStart+i*int32(2)))))< 0 { + /* Enforced by btreeComputeFreeSpace() */ + size1 = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(i+int32(2)))))<= **(**Tu32)(__ccgo_up(bp + 16))>>libc.Int32FromInt32(16) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4873, libc.VaList(bp+56, **(**Tu32)(__ccgo_up(bp + 16))>>int32(16), iPage)) + break + } else { + nFrag = libc.Int32FromUint32(uint32(nFrag) + (**(**Tu32)(__ccgo_up(bp + 16))>>libc.Int32FromInt32(16) - prev&libc.Uint32FromInt32(0xffff) - libc.Uint32FromInt32(1))) + prev = **(**Tu32)(__ccgo_up(bp + 16)) + } + } + nFrag = libc.Int32FromUint32(uint32(nFrag) + (usableSize - prev&libc.Uint32FromInt32(0xffff) - libc.Uint32FromInt32(1))) + /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments + ** is stored in the fifth field of the b-tree page header. + ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the + ** number of fragmented free bytes within the cell content area. + */ + if **(**Tu32)(__ccgo_up(heap)) == uint32(0) && nFrag != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(7))))) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4910, libc.VaList(bp+56, nFrag, libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(7))))), iPage)) + } + } + goto end_of_check +end_of_check: + ; + if !(doCoverageCheck != 0) { + (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FisInit = savedIsInit + } + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = saved_zPfx + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv1 = libc.Uint32FromInt32(saved_v1) + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv2 = saved_v2 + return depth + int32(1) +} + +// C documentation +// +// /* +// ** Create a new collating function for database "db". The name is zName +// ** and the encoding is enc. +// */ +func _createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc Tu8, pCtx uintptr, __ccgo_fp_xCompare uintptr, __ccgo_fp_xDel uintptr) (r int32) { + var aColl, p, pColl uintptr + var enc2, j int32 + _, _, _, _, _ = aColl, enc2, j, p, pColl + /* If SQLITE_UTF16 is specified as the encoding type, transform this + ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the + ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. + */ + enc2 = libc.Int32FromUint8(enc) + if enc2 == int32(SQLITE_UTF16) || enc2 == int32(SQLITE_UTF16_ALIGNED) { + enc2 = int32(SQLITE_UTF16LE) + } + if enc2 < int32(SQLITE_UTF8) || enc2 > int32(SQLITE_UTF16BE) { + return _sqlite3MisuseError(tls, int32(190075)) + } + /* Check if this call is removing or replacing an existing collation + ** sequence. If so, and there are active VMs, return busy. If there + ** are no active VMs, invalidate any pre-compiled statements. + */ + pColl = _sqlite3FindCollSeq(tls, db, libc.Uint8FromInt32(enc2), zName, 0) + if pColl != 0 && (*TCollSeq)(unsafe.Pointer(pColl)).FxCmp != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_BUSY), __ccgo_ts+25981, 0) + return int32(SQLITE_BUSY) + } + _sqlite3ExpirePreparedStatements(tls, db, 0) + /* If collation sequence pColl was created directly by a call to + ** sqlite3_create_collation, and not generated by synthCollSeq(), + ** then any copies made by synthCollSeq() need to be invalidated. + ** Also, collation destructor - CollSeq.xDel() - function may need + ** to be called. + */ + if libc.Int32FromUint8((*TCollSeq)(unsafe.Pointer(pColl)).Fenc) & ^libc.Int32FromInt32(SQLITE_UTF16_ALIGNED) == enc2 { + aColl = _sqlite3HashFind(tls, db+648, zName) + j = 0 + for { + if !(j < int32(3)) { + break + } + p = aColl + uintptr(j)*40 + if libc.Int32FromUint8((*TCollSeq)(unsafe.Pointer(p)).Fenc) == libc.Int32FromUint8((*TCollSeq)(unsafe.Pointer(pColl)).Fenc) { + if (*TCollSeq)(unsafe.Pointer(p)).FxDel != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TCollSeq)(unsafe.Pointer(p)).FxDel})))(tls, (*TCollSeq)(unsafe.Pointer(p)).FpUser) + } + (*TCollSeq)(unsafe.Pointer(p)).FxCmp = uintptr(0) + } + goto _1 + _1: + ; + j = j + 1 + } + } + } + pColl = _sqlite3FindCollSeq(tls, db, libc.Uint8FromInt32(enc2), zName, int32(1)) + if pColl == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TCollSeq)(unsafe.Pointer(pColl)).FxCmp = __ccgo_fp_xCompare + (*TCollSeq)(unsafe.Pointer(pColl)).FpUser = pCtx + (*TCollSeq)(unsafe.Pointer(pColl)).FxDel = __ccgo_fp_xDel + (*TCollSeq)(unsafe.Pointer(pColl)).Fenc = libc.Uint8FromInt32(enc2 | libc.Int32FromUint8(enc)&libc.Int32FromInt32(SQLITE_UTF16_ALIGNED)) + _sqlite3Error(tls, db, SQLITE_OK) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is exactly the same as sqlite3_create_function(), except +// ** that it is designed to be called by internal code. The difference is +// ** that if a malloc() fails in sqlite3_create_function(), an error code +// ** is returned and the mallocFailed flag cleared. +// */ +func _sqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg int32, enc int32, pUserData uintptr, __ccgo_fp_xSFunc uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr, __ccgo_fp_xValue uintptr, __ccgo_fp_xInverse uintptr, pDestructor uintptr) (r int32) { + var extraFlags, rc int32 + var p, v1 uintptr + _, _, _, _ = extraFlags, p, rc, v1 + if zFunctionName == uintptr(0) || __ccgo_fp_xSFunc != uintptr(0) && __ccgo_fp_xFinal != uintptr(0) || libc.BoolInt32(__ccgo_fp_xFinal == uintptr(0)) != libc.BoolInt32(__ccgo_fp_xStep == uintptr(0)) || libc.BoolInt32(__ccgo_fp_xValue == uintptr(0)) != libc.BoolInt32(__ccgo_fp_xInverse == uintptr(0)) || (nArg < -int32(1) || nArg > int32(SQLITE_MAX_FUNCTION_ARG)) || int32(255) < _sqlite3Strlen30(tls, zFunctionName) { + return _sqlite3MisuseError(tls, int32(189155)) + } + extraFlags = enc & (libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_DIRECTONLY) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_INNOCUOUS) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_SELFORDER1)) + enc = enc & (libc.Int32FromInt32(SQLITE_FUNC_ENCMASK) | libc.Int32FromInt32(SQLITE_ANY)) + /* The SQLITE_INNOCUOUS flag is the same bit as SQLITE_FUNC_UNSAFE. But + ** the meaning is inverted. So flip the bit. */ + extraFlags = extraFlags ^ int32(SQLITE_FUNC_UNSAFE) /* tag-20230109-1 */ + /* If SQLITE_UTF16 is specified as the encoding type, transform this + ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the + ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. + ** + ** If SQLITE_ANY is specified, add three versions of the function + ** to the hash table. + */ + switch enc { + case int32(SQLITE_UTF16): + enc = int32(SQLITE_UTF16LE) + case int32(SQLITE_ANY): + rc = _sqlite3CreateFunc(tls, db, zFunctionName, nArg, int32(SQLITE_UTF8)|extraFlags^int32(SQLITE_FUNC_UNSAFE), pUserData, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, __ccgo_fp_xValue, __ccgo_fp_xInverse, pDestructor) + if rc == SQLITE_OK { + rc = _sqlite3CreateFunc(tls, db, zFunctionName, nArg, int32(SQLITE_UTF16LE)|extraFlags^int32(SQLITE_FUNC_UNSAFE), pUserData, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, __ccgo_fp_xValue, __ccgo_fp_xInverse, pDestructor) + } + if rc != SQLITE_OK { + return rc + } + enc = int32(SQLITE_UTF16BE) + case int32(SQLITE_UTF8): + fallthrough + case int32(SQLITE_UTF16LE): + fallthrough + case int32(SQLITE_UTF16BE): + default: + enc = int32(SQLITE_UTF8) + break + } + /* Check if an existing function is being overridden or deleted. If so, + ** and there are active VMs, then return SQLITE_BUSY. If a function + ** is being overridden/deleted but there are no active VMs, allow the + ** operation to continue but invalidate all precompiled statements. + */ + p = _sqlite3FindFunction(tls, db, zFunctionName, nArg, libc.Uint8FromInt32(enc), uint8(0)) + if p != 0 && (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_ENCMASK) == libc.Uint32FromInt32(enc) && int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) == nArg { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_BUSY), __ccgo_ts+25846, 0) + return int32(SQLITE_BUSY) + } else { + _sqlite3ExpirePreparedStatements(tls, db, 0) + } + } else { + if __ccgo_fp_xSFunc == uintptr(0) && __ccgo_fp_xFinal == uintptr(0) { + /* Trying to delete a function that does not exist. This is a no-op. + ** https://sqlite.org/forum/forumpost/726219164b */ + return SQLITE_OK + } + } + p = _sqlite3FindFunction(tls, db, zFunctionName, nArg, libc.Uint8FromInt32(enc), uint8(1)) + if !(p != 0) { + return int32(SQLITE_NOMEM) + } + /* If an older version of the function with a configured destructor is + ** being replaced invoke the destructor function here. */ + _functionDestroy(tls, db, p) + if pDestructor != 0 { + (*TFuncDestructor)(unsafe.Pointer(pDestructor)).FnRef = (*TFuncDestructor)(unsafe.Pointer(pDestructor)).FnRef + 1 + } + *(*uintptr)(unsafe.Pointer(p + 64)) = pDestructor + (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags = (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_ENCMASK) | libc.Uint32FromInt32(extraFlags) + if __ccgo_fp_xSFunc != 0 { + v1 = __ccgo_fp_xSFunc + } else { + v1 = __ccgo_fp_xStep + } + (*TFuncDef)(unsafe.Pointer(p)).FxSFunc = v1 + (*TFuncDef)(unsafe.Pointer(p)).FxFinalize = __ccgo_fp_xFinal + (*TFuncDef)(unsafe.Pointer(p)).FxValue = __ccgo_fp_xValue + (*TFuncDef)(unsafe.Pointer(p)).FxInverse = __ccgo_fp_xInverse + (*TFuncDef)(unsafe.Pointer(p)).FpUserData = pUserData + (*TFuncDef)(unsafe.Pointer(p)).FnArg = libc.Int16FromUint16(libc.Uint16FromInt32(nArg)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Recover the wal-index by reading the write-ahead log file. +// ** +// ** This routine first tries to establish an exclusive lock on the +// ** wal-index to prevent other threads/processes from doing anything +// ** with the WAL or wal-index while recovery is running. The +// ** WAL_RECOVER_LOCK is also held so that other threads will know +// ** that this thread is running recovery. If unable to establish +// ** the necessary locks, this routine returns SQLITE_BUSY. +// */ +func _walIndexRecover(tls *libc.TLS, pWal uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var aData, aFrame, aPrivate, pInfo uintptr + var aFrameCksum [2]Tu32 + var i, iLock, isValid, rc, szFrame, szPage int32 + var iFirst, iFrame, iLast, iLastFrame, iPg, magic, nHdr, nHdr32, version Tu32 + var iOffset Ti64 + var v2, v3 uint64 + var _ /* aBuf at bp+8 */ [32]Tu8 + var _ /* aShare at bp+40 */ uintptr + var _ /* nSize at bp+0 */ Ti64 + var _ /* nTruncate at bp+52 */ Tu32 + var _ /* pgno at bp+48 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, aFrame, aFrameCksum, aPrivate, i, iFirst, iFrame, iLast, iLastFrame, iLock, iOffset, iPg, isValid, magic, nHdr, nHdr32, pInfo, rc, szFrame, szPage, version, v2, v3 /* Size of log file */ + aFrameCksum = [2]Tu32{} /* Lock offset to lock for checkpoint */ + /* Obtain an exclusive lock on all byte in the locking range not already + ** locked by the caller. The caller is guaranteed to have locked the + ** WAL_WRITE_LOCK byte, and may have also locked the WAL_CKPT_LOCK byte. + ** If successful, the same bytes that are locked here are unlocked before + ** this function returns. + */ + iLock = int32(WAL_ALL_BUT_WRITE) + libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FckptLock) + rc = _walLockExclusive(tls, pWal, iLock, libc.Int32FromInt32(3)+libc.Int32FromInt32(0)-iLock) + if rc != 0 { + return rc + } + libc.Xmemset(tls, pWal+72, 0, uint64(48)) + rc = _sqlite3OsFileSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp) + if rc != SQLITE_OK { + goto recovery_error + } + if **(**Ti64)(__ccgo_up(bp)) > int64(WAL_HDRSIZE) { /* Buffer to load WAL header into */ + aPrivate = uintptr(0) /* Heap copy of *-shm hash being populated */ + aFrame = uintptr(0) /* Last frame in wal, based on nSize alone */ + /* Read in the WAL header. */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp+8, int32(WAL_HDRSIZE), 0) + if rc != SQLITE_OK { + goto recovery_error + } + /* If the database page size is not a power of two, or is greater than + ** SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid + ** data. Similarly, if the 'magic' value is invalid, ignore the whole + ** WAL file. + */ + magic = _sqlite3Get4byte(tls, bp+8) + szPage = libc.Int32FromUint32(_sqlite3Get4byte(tls, bp+8+8)) + if magic&uint32(0xFFFFFFFE) != uint32(WAL_MAGIC) || szPage&(szPage-int32(1)) != 0 || szPage > int32(SQLITE_MAX_PAGE_SIZE) || szPage < int32(512) { + goto finished + } + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = uint8(magic & libc.Uint32FromInt32(0x00000001)) + (*TWal)(unsafe.Pointer(pWal)).FszPage = libc.Uint32FromInt32(szPage) + (*TWal)(unsafe.Pointer(pWal)).FnCkpt = _sqlite3Get4byte(tls, bp+8+12) + libc.Xmemcpy(tls, pWal+72+32, bp+8+16, uint64(8)) + /* Verify that the WAL header checksum is correct */ + _walChecksumBytes(tls, libc.BoolInt32(libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN), bp+8, libc.Int32FromInt32(WAL_HDRSIZE)-libc.Int32FromInt32(2)*libc.Int32FromInt32(4), uintptr(0), pWal+72+24) + if **(**Tu32)(__ccgo_up(pWal + 72 + 24)) != _sqlite3Get4byte(tls, bp+8+24) || **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) != _sqlite3Get4byte(tls, bp+8+28) { + goto finished + } + /* Verify that the version number on the WAL format is one that + ** are able to understand */ + version = _sqlite3Get4byte(tls, bp+8+4) + if version != uint32(WAL_MAX_VERSION) { + rc = _sqlite3CantopenError(tls, int32(68910)) + goto finished + } + /* Malloc a buffer to read frames into. */ + szFrame = szPage + int32(WAL_FRAME_HDRSIZE) + aFrame = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32(szFrame)+(libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4)))) + if !(aFrame != 0) { + rc = int32(SQLITE_NOMEM) + goto recovery_error + } + aData = aFrame + 24 + aPrivate = aData + uintptr(szPage) + /* Read all frames from the log file. */ + iLastFrame = libc.Uint32FromInt64((**(**Ti64)(__ccgo_up(bp)) - int64(WAL_HDRSIZE)) / int64(szFrame)) + iPg = uint32(0) + for { + if !(iPg <= libc.Uint32FromInt32(_walFramePage(tls, iLastFrame))) { + break + } + if uint64(iLastFrame) < libc.Uint64FromInt32(HASHTABLE_NPAGE)-(libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4)+uint64(iPg*uint32(HASHTABLE_NPAGE)) { + v2 = uint64(iLastFrame) + } else { + v2 = libc.Uint64FromInt32(HASHTABLE_NPAGE) - (libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4) + uint64(iPg*uint32(HASHTABLE_NPAGE)) + } /* Index of last frame read */ + iLast = uint32(v2) + if iPg == uint32(0) { + v3 = uint64(0) + } else { + v3 = libc.Uint64FromInt32(HASHTABLE_NPAGE) - (libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4) + uint64((iPg-uint32(1))*uint32(HASHTABLE_NPAGE)) + } + iFirst = uint32(uint64(1) + v3) + rc = _walIndexPage(tls, pWal, libc.Int32FromUint32(iPg), bp+40) + if **(**uintptr)(__ccgo_up(bp + 40)) == uintptr(0) { + break + } + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPg)*8)) = aPrivate + iFrame = iFirst + for { + if !(iFrame <= iLast) { + break + } + iOffset = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32(iFrame-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) /* dbsize field from frame header */ + /* Read and decode the next log frame. */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset) + if rc != SQLITE_OK { + break + } + isValid = _walDecodeFrame(tls, pWal, bp+48, bp+52, aData, aFrame) + if !(isValid != 0) { + break + } + rc = _walIndexAppend(tls, pWal, iFrame, **(**Tu32)(__ccgo_up(bp + 48))) + if rc != SQLITE_OK { + break + } + /* If nTruncate is non-zero, this is a commit record. */ + if **(**Tu32)(__ccgo_up(bp + 52)) != 0 { + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = iFrame + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage = **(**Tu32)(__ccgo_up(bp + 52)) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage = libc.Uint16FromInt32(szPage&libc.Int32FromInt32(0xff00) | szPage>>libc.Int32FromInt32(16)) + aFrameCksum[0] = **(**Tu32)(__ccgo_up(pWal + 72 + 24)) + aFrameCksum[int32(1)] = **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) + } + goto _4 + _4: + ; + iFrame = iFrame + 1 + } + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPg)*8)) = **(**uintptr)(__ccgo_up(bp + 40)) + if iPg == uint32(0) { + v2 = libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2) + libc.Uint64FromInt64(40) + } else { + v2 = uint64(0) + } + nHdr = uint32(v2) + nHdr32 = uint32(uint64(nHdr) / uint64(4)) + /* Memcpy() should work fine here, on all reasonable implementations. + ** Technically, memcpy() might change the destination to some + ** intermediate value before setting to the final value, and that might + ** cause a concurrent reader to malfunction. Memcpy() is allowed to + ** do that, according to the spec, but no memcpy() implementation that + ** we know of actually does that, which is why we say that memcpy() + ** is safe for this. Memcpy() is certainly a lot faster. + */ + libc.Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp + 40))+uintptr(nHdr32)*4, aPrivate+uintptr(nHdr32)*4, libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4)-uint64(nHdr)) + if iFrame <= iLast { + break + } + goto _1 + _1: + ; + iPg = iPg + 1 + } + Xsqlite3_free(tls, aFrame) + } + goto finished +finished: + ; + if rc == SQLITE_OK { + **(**Tu32)(__ccgo_up(pWal + 72 + 24)) = aFrameCksum[0] + **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) = aFrameCksum[int32(1)] + _walIndexWriteHdr(tls, pWal) + /* Reset the checkpoint-header. This is safe because this thread is + ** currently holding locks that exclude all other writers and + ** checkpointers. Then set the values of read-mark slots 1 through N. + */ + pInfo = _walCkptInfo(tls, pWal) + (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill = uint32(0) + (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + **(**Tu32)(__ccgo_up(pInfo + 4)) = uint32(0) + i = int32(1) + for { + if !(i < libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)) { + break + } + rc = _walLockExclusive(tls, pWal, int32(3)+i, int32(1)) + if rc == SQLITE_OK { + if i == int32(1) && (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0 { + **(**Tu32)(__ccgo_up(pInfo + 4 + uintptr(i)*4)) = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + } else { + **(**Tu32)(__ccgo_up(pInfo + 4 + uintptr(i)*4)) = uint32(READMARK_NOT_USED) + } + _walUnlockExclusive(tls, pWal, int32(3)+i, int32(1)) + } else { + if rc != int32(SQLITE_BUSY) { + goto recovery_error + } + } + goto _6 + _6: + ; + i = i + 1 + } + /* If more than one frame was recovered from the log file, report an + ** event via sqlite3_log(). This is to help with identifying performance + ** problems caused by applications routinely shutting down without + ** checkpointing the log file. + */ + if (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage != 0 { + Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_NOTICE)|libc.Int32FromInt32(1)<'sqlite_sequence' AND coalesce(rootpage,1)>0\x00SELECT sql FROM \"%w\".sqlite_schema WHERE type='index'\x00SELECT'INSERT INTO %s.'||quote(name)||' SELECT*FROM\"%w\".'||quote(name)FROM %s.sqlite_schema WHERE type='table'AND coalesce(rootpage,1)>0\x00INSERT INTO %s.sqlite_schema SELECT*FROM \"%w\".sqlite_schema WHERE type IN('view','trigger') OR(type='table'AND rootpage=0)\x00CREATE VIRTUAL TABLE %T\x00UPDATE %Q.sqlite_master SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q WHERE rowid=#%d\x00name=%Q AND sql=%Q\x00vtable constructor called recursively: %s\x00vtable constructor failed: %s\x00vtable constructor did not declare schema: %s\x00no such module: %s\x00syntax error\x00\x00 AND \x00(\x00 (\x00%s=?\x00ANY(%s)\x00>\x00<\x00SEARCH\x00SCAN\x00 EXISTS\x00%s %S%s\x00AUTOMATIC PARTIAL COVERING INDEX\x00AUTOMATIC COVERING INDEX\x00COVERING INDEX %s\x00INDEX %s\x00 USING \x00 USING INTEGER PRIMARY KEY (%s\x00>? AND %s\x00%c?)\x00 VIRTUAL TABLE INDEX \x000x%x:%s\x00%d:%s\x00 LEFT-JOIN\x00BLOOM FILTER ON %S (\x00rowid=?\x00MULTI-INDEX OR\x00INDEX %d\x00RIGHT-JOIN %s\x00regexp\x00NOCASE\x00too many arguments on %s() - max %d\x00automatic index on %s(%s)\x00auto-index\x00%s.xBestIndex malfunction\x00abbreviated query algorithm search\x00no query solution\x00at most %d tables in a join\x00SCAN CONSTANT ROW\x00internal query planner error\x00second argument to nth_value must be a positive integer\x00argument of ntile must be a positive integer\x00no such window: %s\x00RANGE with offset PRECEDING/FOLLOWING requires one ORDER BY expression\x00FILTER clause may only be used with aggregate window functions\x00misuse of aggregate: %s()\x00unsupported frame specification\x00PARTITION clause\x00ORDER BY clause\x00frame specification\x00cannot override %s of window: %s\x00DISTINCT is not supported for window functions\x00frame starting offset must be a non-negative integer\x00frame ending offset must be a non-negative integer\x00frame starting offset must be a non-negative number\x00frame ending offset must be a non-negative number\x00near \"%T\": syntax error\x00ORDER BY\x00LIMIT\x00%s clause should come after %s not before\x00too many terms in compound SELECT\x00syntax error after column name \"%.*s\"\x00Recursion limit\x00unknown table option: %.*s\x00set list\x00the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers\x00the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers\x00incomplete input\x00unrecognized token: \"%T\"\x00%s in \"%s\"\x00create\x00temp\x00temporary\x00end\x00explain\x00unable to close due to unfinalized statements or unfinished backups\x00not an error\x00SQL logic error\x00access permission denied\x00query aborted\x00database is locked\x00database table is locked\x00attempt to write a readonly database\x00interrupted\x00disk I/O error\x00database disk image is malformed\x00unknown operation\x00database or disk is full\x00unable to open database file\x00locking protocol\x00constraint failed\x00datatype mismatch\x00bad parameter or other API misuse\x00authorization denied\x00column index out of range\x00file is not a database\x00notification message\x00warning message\x00unknown error\x00abort due to ROLLBACK\x00another row available\x00no more rows available\x00unable to delete/modify user-function due to active statements\x00unable to use function %s in the requested context\x00unknown database: %s\x00unable to delete/modify collation sequence due to active statements\x00file:\x00localhost\x00invalid uri authority: %.*s\x00vfs\x00cache\x00shared\x00private\x00mode\x00ro\x00rw\x00rwc\x00no such %s mode: %s\x00%s mode not allowed: %s\x00no such vfs: %s\x00RTRIM\x00\x00\x00\x00%s at line %d of [%.10s]\x00database corruption\x00misuse\x00cannot open file\x00no such table column: %s.%s\x00SQLITE_\x00database is deadlocked\x00array\x00object\x00JSON nested too deep\x00JSON cannot hold BLOB values\x00malformed JSON\x00inf\x009.0e999\x00infinity\x00QNaN\x00SNaN\x00json_%s() needs an odd number of arguments\x00\"\\/bfnrt\x00-9e999\x009e999\x00inity\x00\\\"\x00\\u000b\x00\\u00\x00\\u0000\x00,\n\x00: \x00*]\x00not an array element: %Q\x00JSON path too deep\x00bad JSON path: %Q\x00@\x00[\x00#\x00.\"\x00\"\x00json_object() requires an even number of arguments\x00json_object() labels must be TEXT\x00insert\x00set\x00array_insert\x00 \x00FLAGS parameter to json_valid() must be between 1 and 15\x00[]\x00}\x00{}\x00CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,json HIDDEN,root HIDDEN)\x00[%lld]\x00.\"%.*s\"\x00.%.*s\x00$\x00jsonb\x00json_array\x00jsonb_array\x00json_array_insert\x00jsonb_array_insert\x00json_array_length\x00json_error_position\x00json_extract\x00jsonb_extract\x00->\x00->>\x00json_insert\x00jsonb_insert\x00json_object\x00jsonb_object\x00json_patch\x00jsonb_patch\x00json_pretty\x00json_quote\x00json_remove\x00jsonb_remove\x00json_replace\x00jsonb_replace\x00json_set\x00jsonb_set\x00json_type\x00json_valid\x00json_group_array\x00jsonb_group_array\x00json_group_object\x00jsonb_group_object\x00json_each\x00json_tree\x00jsonb_each\x00jsonb_tree\x00data\x00DROP TABLE '%q'.'%q_node';DROP TABLE '%q'.'%q_rowid';DROP TABLE '%q'.'%q_parent';\x00RtreeMatchArg\x00SELECT * FROM %Q.%Q\x00UNIQUE constraint failed: %s.%s\x00rtree constraint failed: %s.(%s<=%s)\x00ALTER TABLE %Q.'%q_node' RENAME TO \"%w_node\";ALTER TABLE %Q.'%q_parent' RENAME TO \"%w_parent\";ALTER TABLE %Q.'%q_rowid' RENAME TO \"%w_rowid\";\x00SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'\x00node\x00INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_node' WHERE nodeno = ?1\x00SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = ?1\x00INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_rowid' WHERE rowid = ?1\x00SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = ?1\x00INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_parent' WHERE nodeno = ?1\x00CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY,nodeno\x00,a%d\x00);CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY,data);\x00CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,parentnode);\x00INSERT INTO \"%w\".\"%w_node\"VALUES(1,zeroblob(%d))\x00INSERT INTO\"%w\".\"%w_rowid\"(rowid,nodeno)VALUES(?1,?2)ON CONFLICT(rowid)DO UPDATE SET nodeno=excluded.nodeno\x00SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1\x00UPDATE \"%w\".\"%w_rowid\"SET \x00a%d=coalesce(?%d,a%d)\x00a%d=?%d\x00 WHERE rowid=?1\x00PRAGMA %Q.page_size\x00SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1\x00undersize RTree blobs in \"%q_node\"\x00Wrong number of columns for an rtree table\x00Too few columns for an rtree table\x00Too many columns for an rtree table\x00Auxiliary rtree columns must be last\x00_node\x00CREATE TABLE x(%.*s INT\x00,%.*s\x00,%.*s REAL\x00,%.*s INT\x00);\x00{%lld\x00 %g\x00Invalid argument to rtreedepth()\x00%z%s%z\x00SELECT data FROM %Q.'%q_node' WHERE nodeno=?\x00Node %lld missing from database\x00SELECT parentnode FROM %Q.'%q_parent' WHERE nodeno=?1\x00SELECT nodeno FROM %Q.'%q_rowid' WHERE rowid=?1\x00%_rowid\x00%_parent\x00Mapping (%lld -> %lld) missing from %s table\x00Found (%lld -> %lld) in %s table, expected (%lld -> %lld)\x00Dimension %d of cell %d on node %lld is corrupt\x00Dimension %d of cell %d on node %lld is corrupt relative to parent\x00Node %lld is too small (%d bytes)\x00Rtree depth out of range (%d)\x00Node %lld is too small for cell count of %d (%d bytes)\x00SELECT count(*) FROM %Q.'%q%s'\x00Wrong number of entries in %%%s table - expected %lld, actual %lld\x00SELECT * FROM %Q.'%q_rowid'\x00Schema corrupt or not an rtree\x00_rowid\x00_parent\x00In RTree %s.%s:\n%z\x00wrong number of arguments to function rtreecheck()\x00[%!g,%!g],\x00[%!g,%!g]]\x00\x00Too many columns for a geopoly table\x00CREATE TABLE x(_shape\x00,%s\x00rtree\x00fullscan\x00_shape does not contain a valid polygon\x00geopoly_overlap\x00geopoly_within\x00geopoly_area\x00geopoly_blob\x00geopoly_json\x00geopoly_svg\x00geopoly_contains_point\x00geopoly_debug\x00geopoly_bbox\x00geopoly_xform\x00geopoly_regular\x00geopoly_ccw\x00geopoly_group_bbox\x00geopoly\x00rtreenode\x00rtreedepth\x00rtreecheck\x00rtree_i32\x00corrupt fossil delta\x00DROP TRIGGER IF EXISTS temp.rbu_insert_tr;DROP TRIGGER IF EXISTS temp.rbu_update1_tr;DROP TRIGGER IF EXISTS temp.rbu_update2_tr;DROP TRIGGER IF EXISTS temp.rbu_delete_tr;\x00AND rootpage!=0 AND rootpage IS NOT NULL\x00SELECT rbu_target_name(name, type='view') AS target, name FROM sqlite_schema WHERE type IN ('table', 'view') AND target IS NOT NULL %s ORDER BY name\x00SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' FROM main.sqlite_schema WHERE type='index' AND tbl_name = ?\x00SELECT (sql COLLATE nocase BETWEEN 'CREATE VIRTUAL' AND 'CREATE VIRTUAM'), rootpage FROM sqlite_schema WHERE name=%Q\x00PRAGMA index_list=%Q\x00SELECT rootpage FROM sqlite_schema WHERE name = %Q\x00PRAGMA table_info=%Q\x00PRAGMA main.index_list = %Q\x00PRAGMA main.index_xinfo = %Q\x00SELECT * FROM '%q'\x00rbu_\x00rbu_rowid\x00may not have\x00requires\x00table %q %s rbu_rowid column\x00PRAGMA table_info(%Q)\x00column missing from %q: %s\x00%z%s\"%w\"\x00%z%s%s\"%w\"%s\x00SELECT max(_rowid_) FROM \"%s%w\"\x00 WHERE _rowid_ > %lld \x00 DESC\x00quote(\x00||','||\x00SELECT %s FROM \"%s%w\" ORDER BY %s LIMIT 1\x00 WHERE (%s) > (%s) \x00_rowid_\x00%z%s \"%w\" COLLATE %Q\x00%z%s \"rbu_imp_%d%w\" COLLATE %Q DESC\x00%z%s quote(\"rbu_imp_%d%w\")\x00SELECT %s FROM \"rbu_imp_%w\" ORDER BY %s LIMIT 1\x00%z%s%s\x00(%s) > (%s)\x00%z%s(%.*s) COLLATE %Q\x00%z%s\"%w\" COLLATE %Q\x00%z%s\"rbu_imp_%d%w\"%s\x00%z%s\"rbu_imp_%d%w\" %s COLLATE %Q\x00%z%s\"rbu_imp_%d%w\" IS ?\x00%z%s%s.\"%w\"\x00%z%sNULL\x00%z, %s._rowid_\x00_rowid_ = ?%d\x00%z%sc%d=?%d\x00_rowid_ = (SELECT id FROM rbu_imposter2 WHERE %z)\x00%z%s\"%w\"=?%d\x00invalid rbu_control value\x00%z%s\"%w\"=rbu_delta(\"%w\", ?%d)\x00%z%s\"%w\"=rbu_fossil_delta(\"%w\", ?%d)\x00PRIMARY KEY(\x00%z%s\"%w\"%s\x00%z)\x00SELECT name FROM sqlite_schema WHERE rootpage = ?\x00%z%sc%d %s COLLATE %Q\x00%z%sc%d%s\x00%z, id INTEGER\x00CREATE TABLE rbu_imposter2(%z, PRIMARY KEY(%z)) WITHOUT ROWID\x00PRIMARY KEY \x00 NOT NULL\x00%z%s\"%w\" %s %sCOLLATE %Q%s\x00%z, %z\x00 WITHOUT ROWID\x00CREATE TABLE \"rbu_imp_%w\"(%z)%s\x00INSERT INTO %s.'rbu_tmp_%q'(rbu_control,%s%s) VALUES(%z)\x00SELECT trim(sql) FROM sqlite_schema WHERE type='index' AND name=?\x00 LIMIT -1 OFFSET %d\x00CREATE TABLE \"rbu_imp_%w\"( %s, PRIMARY KEY( %s ) ) WITHOUT ROWID\x00INSERT INTO \"rbu_imp_%w\" VALUES(%s)\x00DELETE FROM \"rbu_imp_%w\" WHERE %s\x00AND\x00WHERE\x00SELECT %s, 0 AS rbu_control FROM '%q' %s %s %s ORDER BY %s%s\x00SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' %s ORDER BY %s%s\x00SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' %s UNION ALL SELECT %s, rbu_control FROM '%q' %s %s typeof(rbu_control)='integer' AND rbu_control!=1 ORDER BY %s%s\x00rbu_imp_\x00, _rowid_\x00INSERT INTO \"%s%w\"(%s%s) VALUES(%s)\x00DELETE FROM \"%s%w\" WHERE %s\x00, rbu_rowid\x00, 0 AS rbu_rowid\x00CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS SELECT *%s FROM '%q' WHERE 0;\x00CREATE TEMP TRIGGER rbu_delete_tr BEFORE DELETE ON \"%s%w\" BEGIN SELECT rbu_tmp_insert(3, %s);END;CREATE TEMP TRIGGER rbu_update1_tr BEFORE UPDATE ON \"%s%w\" BEGIN SELECT rbu_tmp_insert(3, %s);END;CREATE TEMP TRIGGER rbu_update2_tr AFTER UPDATE ON \"%s%w\" BEGIN SELECT rbu_tmp_insert(4, %s);END;\x00CREATE TEMP TRIGGER rbu_insert_tr AFTER INSERT ON \"%s%w\" BEGIN SELECT rbu_tmp_insert(0, %s);END;\x00,_rowid_ \x00,rbu_rowid\x000 AS \x00SELECT %s,%s rbu_control%s FROM '%q'%s %s %s %s\x00UPDATE \"%s%w\" SET %s WHERE %s\x00SELECT k, v FROM %s.rbu_state\x00file:///%s-vacuum?modeof=%s\x00ATTACH %Q AS stat\x00CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)\x00cannot vacuum wal mode database\x00&\x00file:%s-vactmp?rbu_memory=1%s%s\x00rbu_tmp_insert\x00rbu_fossil_delta\x00rbu_target_name\x00SELECT * FROM sqlite_schema\x00rbu vfs not found\x00PRAGMA main.wal_checkpoint=restart\x00rbu_exclusive_checkpoint\x00%s-oal\x00%s-wal\x00PRAGMA schema_version\x00PRAGMA schema_version = %d\x00INSERT OR REPLACE INTO %s.rbu_state(k, v) VALUES (%d, %d), (%d, %Q), (%d, %Q), (%d, %d), (%d, %lld), (%d, %lld), (%d, %lld), (%d, %lld), (%d, %lld), (%d, %Q) \x00PRAGMA main.%s\x00PRAGMA main.%s = %d\x00PRAGMA writable_schema=1\x00SELECT sql FROM sqlite_schema WHERE sql!='' AND rootpage!=0 AND name!='sqlite_sequence' ORDER BY type DESC\x00SELECT * FROM sqlite_schema WHERE rootpage=0 OR rootpage IS NULL\x00INSERT INTO sqlite_schema VALUES(?,?,?,?,?)\x00PRAGMA writable_schema=0\x00DELETE FROM %s.'rbu_tmp_%q'\x00rbu_state mismatch error\x00rbu_vfs_%d\x00SELECT count(*) FROM sqlite_schema WHERE type='index' AND tbl_name = %Q\x00rbu_index_cnt\x00SELECT 1 FROM sqlite_schema WHERE tbl_name = 'rbu_count'\x00SELECT sum(cnt * (1 + rbu_index_cnt(rbu_target_name(tbl))))FROM rbu_count\x00cannot update wal mode database\x00vacuum\x00update\x00database modified during rbu %s\x00BEGIN IMMEDIATE\x00PRAGMA journal_mode=off\x00-vactmp\x00DELETE FROM stat.rbu_state\x00rbu/zipvfs setup error\x00rbu(%s)/%z\x00rbu_memory\x00/\x00overflow\x00%s%.3x+%.6x\x00%s%.3x/\x00internal\x00leaf\x00corrupted\x00SELECT * FROM (SELECT 'sqlite_schema' AS name,1 AS rootpage,'table' AS type UNION ALL SELECT name,rootpage,type FROM \"%w\".sqlite_schema WHERE rootpage!=0)\x00WHERE name=%Q\x00 ORDER BY name\x00dbstat\x00CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)\x00read-only\x00cannot delete\x00cannot insert\x00no such schema\x00bad page number\x00bad page value\x00failed to open transaction\x00sqlite_dbpage\x00SELECT 0, 'tbl', '', 0, '', 1, 0 UNION ALL SELECT 1, 'idx', '', 0, '', 2, 0 UNION ALL SELECT 2, 'stat', '', 0, '', 0, 0\x00PRAGMA '%q'.table_xinfo('%q')\x00SELECT\x00%z%s\"%w\".\"%w\".\"%w\"=\"%w\".\"%w\".\"%w\"\x00%z%s\"%w\".\"%w\".\"%w\" IS NOT \"%w\".\"%w\".\"%w\"\x00 OR \x00_rowid_, *\x00SELECT %s FROM \"%w\".\"%w\" WHERE NOT EXISTS ( SELECT 1 FROM \"%w\".\"%w\" WHERE %s)\x00%z%s\"%w\".\"%w\".\"%w\"\x00SELECT %s,%s FROM \"%w\".\"%w\", \"%w\".\"%w\" WHERE %s AND (%z)\x00SELECT * FROM %Q.sqlite_schema\x00no such table: %s.%s\x00table schemas do not match\x00, 1\x00 AND (?6 OR ?3 IS stat)\x00tbl, idx\x00?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)\x00tbl, ?2, stat\x00?%d\x00 AND (?%d OR ?%d IS %w.%w)\x00SELECT %s%s FROM %Q.%Q WHERE (%s) IS (%s)\x00SAVEPOINT changeset\x00RELEASE changeset\x00UPDATE main.\x00 SET \x00 = ?\x00 WHERE \x00idx IS CASE WHEN length(?4)=0 AND typeof(?4)='blob' THEN NULL ELSE ?4 END \x00 IS ?\x00DELETE FROM main.\x00 AND (?\x00AND \x00INSERT INTO main.\x00) VALUES(?\x00, ?\x00INSERT INTO main.sqlite_stat1 VALUES(?1, CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END, ?3)\x00DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END AND (?4 OR stat IS ?3)\x00SAVEPOINT replace_op\x00RELEASE replace_op\x00PRAGMA table_list = %Q\x00SELECT %s FROM %Q WHERE (%s) IS (%s)\x00INSERT INTO %Q(%s) VALUES(%s)\x00SAVEPOINT update_op\x00ROLLBACK TO update_op\x00RELEASE update_op\x00SAVEPOINT changeset_apply\x00PRAGMA defer_foreign_keys = 1\x00sqlite3changeset_apply(): no such table: %s\x00sqlite3changeset_apply(): table %s has %d columns, expected %d or more\x00sqlite3changeset_apply(): primary key mismatch for table %s\x00PRAGMA defer_foreign_keys = 0\x00RELEASE changeset_apply\x00ROLLBACK TO changeset_apply\x00undefined\x00invalid change: %s value in PK of old.* record\x00invalid change: defined value in PK of new.* record\x00un\x00invalid change: column %d - old.* value is %sdefined but new.* is %sdefined\x00invalid change: column %d is undefined\x00invalid change: null value in PK\x00fts5: parser stack overflow\x00fts5: syntax error near \"%.*s\"\x00%z%.*s\x00wrong number of arguments to function highlight()\x00wrong number of arguments to function snippet()\x00wrong number of arguments to function fts5_get_locale()\x00non-integer argument passed to function fts5_get_locale()\x00snippet\x00highlight\x00bm25\x00fts5_get_locale\x00prefix\x00malformed prefix=... directive\x00too many prefix indexes (max %d)\x00prefix length out of range (max 999)\x00tokenize\x00multiple tokenize=... directives\x00parse error in tokenize directive\x00content\x00multiple content=... directives\x00%Q.%Q\x00contentless_delete\x00malformed contentless_delete=... directive\x00contentless_unindexed\x00content_rowid\x00multiple content_rowid=... directives\x00columnsize\x00malformed columnsize=... directive\x00locale\x00malformed locale=... directive\x00columns\x00malformed detail=... directive\x00tokendata\x00malformed tokendata=... directive\x00unrecognized option: \"%.*s\"\x00rank\x00reserved fts5 column name: %s\x00unindexed\x00unrecognized column option: %s\x00T.%Q\x00, T.%Q\x00, T.c%d\x00, NULL\x00, T.l%d\x00reserved fts5 table name: %s\x00parse error in \"%s\"\x00contentless_delete=1 requires a contentless table\x00contentless_delete=1 is incompatible with columnsize=0\x00contentless_unindexed=1 requires a contentless table\x00docsize\x00%Q.'%q_%s'\x00CREATE TABLE x(\x00%z%s%Q\x00%z, %Q HIDDEN, %s HIDDEN)\x00pgsz\x00hashsize\x00automerge\x00usermerge\x00crisismerge\x00deletemerge\x00secure-delete\x00insttoken\x00SELECT k, v FROM %Q.'%q_config'\x00version\x00invalid fts5 file format (found %d, expected %d or %d) - run 'rebuild'\x00unterminated string\x00fts5: syntax error near \"%.1s\"\x00OR\x00NOT\x00NEAR\x00expected integer, got \"%.*s\"\x00fts5: column queries are not supported (detail=none)\x00phrase\x00fts5: %s queries are not supported (detail!=full)\x00fts5 expression tree is too large (maximum depth %d)\x00fts5: corruption found reading blob %lld from table \"%s\"\x00fts5: corruption on page %d, segment %d, table \"%s\"\x00fts5: corruption in table \"%s\"\x00block\x00REPLACE INTO '%q'.'%q_data'(id, block) VALUES(?,?)\x00DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?\x00DELETE FROM '%q'.'%q_idx' WHERE segid=?\x00\xff\x00\x00\x01\x00fts5: corrupt structure record for table \"%s\"\x00PRAGMA %Q.data_version\x00SELECT pgno FROM '%q'.'%q_idx' WHERE segid=? AND term<=? ORDER BY term DESC LIMIT 1\x00SELECT pgno FROM '%q'.'%q_idx' WHERE segid=? AND term>? ORDER BY term ASC LIMIT 1\x00INSERT INTO '%q'.'%q_idx'(segid,term,pgno) VALUES(?,?,?)\x00DELETE FROM '%q'.'%q_idx' WHERE (segid, (pgno/2)) = (?1, ?2)\x00REPLACE INTO %Q.'%q_config' VALUES ('version', %d)\x00%s_data\x00id INTEGER PRIMARY KEY, block BLOB\x00segid, term, pgno, PRIMARY KEY(segid, term)\x00\x00\x00SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d ORDER BY 1, 2\x00\x00\x00\x00\x00\x00fts5: checksum mismatch for table \"%s\"\x00recursively defined fts5 content table\x00DESC\x00ASC\x00SELECT rowid, rank FROM %Q.%Q ORDER BY %s(\"%w\"%s%s) %s\x00reads\x00unknown special query: %.*s\x00SELECT %s\x00no such function: %s\x00parse error in rank function: %s\x00%s: table does not support scanning\x00fts5: missing row %lld from content table %s\x00delete-all\x00'delete-all' may only be used with a contentless or external content fts5 table\x00rebuild\x00'rebuild' may not be used with a contentless fts5 table\x00merge\x00integrity-check\x00flush\x00%s a subset of columns on fts5 contentless-delete table: %s\x00%s contentless fts5 table: %s\x00cannot UPDATE\x00'delete' may not be used with a contentless_delete=1 table\x00cannot DELETE from contentless fts5 table: %s\x00fts5_locale() requires locale=1\x00no such cursor: %lld\x00no such tokenizer: %s\x00error in tokenizer constructor\x00fts5_api_ptr\x00fts5: 2026-06-03 19:12:13 d6e03d8c777cfa2d35e3b60d8ec3e0187f3e9f99d8e2ee9cac695fd6fcdf1a24\x00config\x00malformed inverted index for FTS5 table %s.%s\x00unable to validate the inverted index for FTS5 table %s.%s: %s\x00fts5\x00fts5_source_id\x00fts5_locale\x00fts5_insttoken\x00SELECT %s FROM %s T WHERE T.%Q >= ? AND T.%Q <= ? ORDER BY T.%Q ASC\x00SELECT %s FROM %s T WHERE T.%Q <= ? AND T.%Q >= ? ORDER BY T.%Q DESC\x00SELECT %s FROM %s T WHERE T.%Q=?\x00INSERT INTO %Q.'%q_content' VALUES(%s)\x00REPLACE INTO %Q.'%q_content' VALUES(%s)\x00DELETE FROM %Q.'%q_content' WHERE id=?\x00REPLACE INTO %Q.'%q_docsize' VALUES(?,?%s)\x00DELETE FROM %Q.'%q_docsize' WHERE id=?\x00SELECT sz%s FROM %Q.'%q_docsize' WHERE id=?\x00REPLACE INTO %Q.'%q_config' VALUES(?,?)\x00SELECT %s FROM %s AS T\x00%z%s?%d\x00%z,?%d\x00,?\x00,origin\x00DROP TABLE IF EXISTS %Q.'%q_data';DROP TABLE IF EXISTS %Q.'%q_idx';DROP TABLE IF EXISTS %Q.'%q_config';\x00DROP TABLE IF EXISTS %Q.'%q_docsize';\x00DROP TABLE IF EXISTS %Q.'%q_content';\x00ALTER TABLE %Q.'%q_%s' RENAME TO '%q_%s';\x00CREATE TABLE %Q.'%q_%q'(%s)%s\x00fts5: error creating shadow table %q_%s: %s\x00id INTEGER PRIMARY KEY\x00, c%d\x00, l%d\x00id INTEGER PRIMARY KEY, sz BLOB\x00id INTEGER PRIMARY KEY, sz BLOB, origin INTEGER\x00k PRIMARY KEY, v\x00DELETE FROM %Q.'%q_data';DELETE FROM %Q.'%q_idx';\x00DELETE FROM %Q.'%q_docsize';\x00DELETE FROM %Q.'%q_content';\x00SELECT count(*) FROM %Q.'%q_%s'\x00tokenchars\x00separators\x00L* N* Co\x00categories\x00remove_diacritics\x00unicode61\x00porter\x00al\x00ance\x00ence\x00er\x00ic\x00able\x00ible\x00ant\x00ement\x00ment\x00ent\x00ion\x00ou\x00ism\x00ate\x00iti\x00ous\x00ive\x00ize\x00at\x00bl\x00ble\x00iz\x00ational\x00tional\x00tion\x00enci\x00anci\x00izer\x00logi\x00bli\x00alli\x00entli\x00eli\x00e\x00ousli\x00ization\x00ation\x00ator\x00alism\x00iveness\x00fulness\x00ful\x00ousness\x00aliti\x00iviti\x00biliti\x00ical\x00ness\x00icate\x00iciti\x00ative\x00alize\x00eed\x00ee\x00ed\x00ing\x00case_sensitive\x00trigram\x00ascii\x00col\x00row\x00instance\x00fts5vocab: unknown table type: %Q\x00CREATE TABlE vocab(term, col, doc, cnt)\x00CREATE TABlE vocab(term, doc, cnt)\x00CREATE TABlE vocab(term, doc, col, offset)\x00wrong number of vtable arguments\x00recursive definition for %s.%s\x00SELECT t.%Q FROM %Q.%Q AS t WHERE t.%Q MATCH '*id'\x00no such fts5 table: %s.%s\x00fts5vocab\x002026-06-03 19:12:13 d6e03d8c777cfa2d35e3b60d8ec3e0187f3e9f99d8e2ee9cac695fd6fcdf1a24\x00" diff --git a/internal/engine/lib/sqlite_g_0000000000002802.go b/internal/engine/lib/sqlite_g_0000000000002802.go new file mode 100644 index 0000000..5605d56 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000002802.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (linux && ppc64le) || (linux && s390x) + +package sqlite3 + +const FP_FAST_FMAL = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000002880.go b/internal/engine/lib/sqlite_g_0000000000002880.go new file mode 100644 index 0000000..10d333d --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000002880.go @@ -0,0 +1,640 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (linux && ppc64le) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type Tblksize_t = int64 + +// C documentation +// +// /* +// ** This function is called to handle the SQLITE_FCNTL_SIZE_HINT +// ** file-control operation. Enlarge the database to nBytes in size +// ** (rounded up to the next chunk-size). If the database is already +// ** nBytes or larger, this routine is a no-op. +// */ +func _fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte Ti64) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var iWrite, nSize Ti64 + var nBlk, nWrite, rc int32 + var _ /* buf at bp+0 */ Tstat + _, _, _, _, _ = iWrite, nBlk, nSize, nWrite, rc + if (*TunixFile)(unsafe.Pointer(pFile)).FszChunk > 0 { /* Used to hold return values of fstat() */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, bp) != 0 { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)< int64((**(**Tstat)(__ccgo_up(bp))).Fst_size) { + /* If the OS does not have posix_fallocate(), fake it. Write a + ** single byte to the last byte in each block that falls entirely + ** within the extended region. Then, if required, a single byte + ** at offset (nSize-1), to set the size of the file correctly. + ** This is a similar technique to that used by glibc on systems + ** that do not have a real fallocate() call. + */ + nBlk = int32((**(**Tstat)(__ccgo_up(bp))).Fst_blksize) /* File-system block size */ + nWrite = 0 /* Next offset to write to */ + iWrite = int64((**(**Tstat)(__ccgo_up(bp))).Fst_size/int64(nBlk)*int64(nBlk) + int64(nBlk) - int64(1)) + for { + if !(iWrite < nSize+int64(nBlk)-int64(1)) { + break + } + if iWrite >= nSize { + iWrite = nSize - int64(1) + } + nWrite = _seekAndWrite(tls, pFile, iWrite, __ccgo_ts+1704, int32(1)) + if nWrite != int32(1) { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(3)< 0 && nByte > (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize { + if (*TunixFile)(unsafe.Pointer(pFile)).FszChunk <= 0 { + if _robust_ftruncate(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, nByte) != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__errno_location(tls)))) + return _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(6)< 0 { + return SQLITE_OK + } + if nMap < 0 { /* Low-level file information */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFd)).Fh, bp) != 0 { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)< (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeMax { + nMap = (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeMax + } + if nMap != (*TunixFile)(unsafe.Pointer(pFd)).FmmapSize { + _unixRemapfile(tls, pFd, nMap) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Open a shared-memory area associated with open database file pDbFd. +// ** This particular implementation uses mmapped files. +// ** +// ** The file used to implement shared-memory is in the same directory +// ** as the open database file and has the same name as the open database +// ** file with the "-shm" suffix added. For example, if the database file +// ** is "/home/user1/config.db" then the file that is created and mmapped +// ** for shared memory will be called "/home/user1/config.db-shm". +// ** +// ** Another approach to is to use files in /dev/shm or /dev/tmp or an +// ** some other tmpfs mount. But if a file in a different directory +// ** from the database file is used, then differing access permissions +// ** or a chroot() might cause two different processes on the same +// ** database to end up using different files for shared memory - +// ** meaning that their memory would not really be shared - resulting +// ** in database corruption. Nevertheless, this tmpfs file usage +// ** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY="/dev/shm" +// ** or the equivalent. The use of the SQLITE_SHM_DIRECTORY compile-time +// ** option results in an incompatible build of SQLite; builds of SQLite +// ** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the +// ** same database file at the same time, database corruption will likely +// ** result. The SQLITE_SHM_DIRECTORY compile-time option is considered +// ** "unsupported" and may go away in a future SQLite release. +// ** +// ** When opening a new shared-memory file, if no other instances of that +// ** file are currently open, in this process or in other processes, then +// ** the file must be truncated to zero length or have its header cleared. +// ** +// ** If the original database file (pDbFd) is using the "unix-excl" VFS +// ** that means that an exclusive lock is held on the database file and +// ** that no other processes are able to read or write the database. In +// ** that case, we do not really need shared memory. No shared memory +// ** file is created. The shared memory will be simulated with heap memory. +// */ +func _unixOpenSharedMemory(tls *libc.TLS, pDbFd uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var nShmFilename, rc int32 + var p, pInode, pShmNode, zBasePath, zShm, v1 uintptr + var _ /* sStat at bp+0 */ Tstat + _, _, _, _, _, _, _, _ = nShmFilename, p, pInode, pShmNode, rc, zBasePath, zShm, v1 + p = uintptr(0) /* The underlying mmapped file */ + rc = SQLITE_OK /* Size of the SHM filename in bytes */ + /* Allocate space for the new unixShm object. */ + p = Xsqlite3_malloc64(tls, uint64(24)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, p, 0, uint64(24)) + /* Check to see if a unixShmNode object already exists. Reuse an existing + ** one if present. Create a new one if necessary. + */ + _unixEnterMutex(tls) + pInode = (*TunixFile)(unsafe.Pointer(pDbFd)).FpInode + pShmNode = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpShmNode + if pShmNode == uintptr(0) { /* fstat() info for database file */ + zBasePath = (*TunixFile)(unsafe.Pointer(pDbFd)).FzPath + /* Call fstat() to figure out the permissions on the database file. If + ** a new *-shm file is created, an attempt will be made to create it + ** with the same permissions. + */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pDbFd)).Fh, bp) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)<pFirst. This must be done while holding the + ** pShmNode->pShmMutex. + */ + Xsqlite3_mutex_enter(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + (*TunixShm)(unsafe.Pointer(p)).FpNext = (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpFirst + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpFirst = p + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + return rc + /* Jump here on any error */ + goto shm_open_err +shm_open_err: + ; + _unixShmPurge(tls, pDbFd) /* This call frees pShmNode if required */ + Xsqlite3_free(tls, p) + _unixLeaveMutex(tls) + return rc +} + +// C documentation +// +// /* +// ** This function is called to obtain a pointer to region iRegion of the +// ** shared-memory associated with the database file fd. Shared-memory regions +// ** are numbered starting from zero. Each shared-memory region is szRegion +// ** bytes in size. +// ** +// ** If an error occurs, an error code is returned and *pp is set to NULL. +// ** +// ** Otherwise, if the bExtend parameter is 0 and the requested shared-memory +// ** region has not been allocated (by any client, including one running in a +// ** separate process), then *pp is set to NULL and SQLITE_OK returned. If +// ** bExtend is non-zero and the requested shared-memory region has not yet +// ** been allocated, it is allocated by this function. +// ** +// ** If the shared-memory region has already been allocated or is allocated by +// ** this call as described above, then it is mapped into this processes +// ** address space (if it is not already), *pp is set to point to the mapped +// ** memory and SQLITE_OK returned. +// */ +func _unixShmMap(tls *libc.TLS, fd uintptr, iRegion int32, szRegion int32, bExtend int32, pp uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var apNew, p, pDbFd, pMem, pShmNode, zFile, v4 uintptr + var i, iPg, nByte, nMap Ti64 + var nReqRegion, nShmPerMap, rc, v2 int32 + var _ /* sStat at bp+0 */ Tstat + var _ /* x at bp+144 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = apNew, i, iPg, nByte, nMap, nReqRegion, nShmPerMap, p, pDbFd, pMem, pShmNode, rc, zFile, v2, v4 + pDbFd = fd + rc = SQLITE_OK + nShmPerMap = _unixShmRegionPerMap(tls) + /* If the shared-memory file has not yet been opened, open it now. */ + if (*TunixFile)(unsafe.Pointer(pDbFd)).FpShm == uintptr(0) { + rc = _unixOpenSharedMemory(tls, pDbFd) + if rc != SQLITE_OK { + return rc + } + } + p = (*TunixFile)(unsafe.Pointer(pDbFd)).FpShm + pShmNode = (*TunixShm)(unsafe.Pointer(p)).FpShmNode + Xsqlite3_mutex_enter(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked != 0 { + rc = _unixLockSharedMemory(tls, pDbFd, pShmNode) + if rc != SQLITE_OK { + goto shmpage_out + } + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked = uint8(0) + } + /* Minimum number of regions required to be mapped. */ + nReqRegion = (iRegion + nShmPerMap) / nShmPerMap * nShmPerMap + if libc.Int32FromUint16((*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRegion) < nReqRegion { /* New apRegion[] array */ + nByte = int64(nReqRegion) * int64(szRegion) /* Used by fstat() */ + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FszRegion = szRegion + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0 { + /* The requested region is not mapped into this processes address space. + ** Check to see if it has been allocated (i.e. if the wal-index file is + ** large enough to contain the requested region). + */ + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, bp) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(19)<= 0 { + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 { + v2 = int32(PROT_READ) + } else { + v2 = libc.Int32FromInt32(PROT_READ) | libc.Int32FromInt32(PROT_WRITE) + } + pMem = (*(*func(*libc.TLS, uintptr, Tsize_t, int32, int32, int32, Toff_t) uintptr)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(22)].FpCurrent})))(tls, uintptr(0), libc.Uint64FromInt64(nMap), v2, int32(MAP_SHARED), (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(int64(szRegion)*libc.Int64FromUint16((*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRegion))) + if pMem == uintptr(-libc.Int32FromInt32(1)) { + rc = _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(21)< iRegion { + **(**uintptr)(__ccgo_up(pp)) = **(**uintptr)(__ccgo_up((*TunixShmNode)(unsafe.Pointer(pShmNode)).FapRegion + uintptr(iRegion)*8)) + } else { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 && rc == SQLITE_OK { + rc = int32(SQLITE_READONLY) + } + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + return rc +} + +// C documentation +// +// /* +// ** Return the name of a directory in which to put temporary files. +// ** If no suitable temporary file directory can be found, return NULL. +// */ +func _unixTempFileDir(tls *libc.TLS) (r uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var i, v1 uint32 + var zDir uintptr + var _ /* buf at bp+0 */ Tstat + _, _, _ = i, zDir, v1 + i = uint32(0) + zDir = Xsqlite3_temp_directory + for int32(1) != 0 { + if zDir != uintptr(0) && (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zDir, bp) == 0 && (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFDIR) && (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zDir, int32(03)) == 0 { + return zDir + } + if uint64(i) >= libc.Uint64FromInt64(48)/libc.Uint64FromInt64(8) { + break + } + v1 = i + i = i + 1 + zDir = _azTempDirs[v1] + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Check a unixFile that is a database. Verify the following: +// ** +// ** (1) There is exactly one hard link on the file +// ** (2) The file is not a symbolic link +// ** (3) The file has not been renamed or unlinked +// ** +// ** Issue sqlite3_log(SQLITE_WARNING,...) messages if anything is not right. +// */ +func _verifyDbFile(tls *libc.TLS, pFile uintptr) { + bp := tls.Alloc(160) + defer tls.Free(160) + var rc int32 + var _ /* buf at bp+0 */ Tstat + _ = rc + /* These verifications occurs for the main database only */ + if libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFile)).FctrlFlags)&int32(UNIXFILE_NOLOCK) != 0 { + return + } + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, bp) + if rc != 0 { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3836, libc.VaList(bp+152, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if (**(**Tstat)(__ccgo_up(bp))).Fst_nlink == uint64(0) { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3860, libc.VaList(bp+152, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if (**(**Tstat)(__ccgo_up(bp))).Fst_nlink > uint64(1) { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3889, libc.VaList(bp+152, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } + if _fileHasMoved(tls, pFile) != 0 { + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3916, libc.VaList(bp+152, (*TunixFile)(unsafe.Pointer(pFile)).FzPath)) + return + } +} diff --git a/internal/engine/lib/sqlite_g_00000000000028bc.go b/internal/engine/lib/sqlite_g_00000000000028bc.go new file mode 100644 index 0000000..337fd70 --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000028bc.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && amd64) || (linux && ppc64le) || (linux && s390x) + +package sqlite3 + +type Tnlink_t = uint64 diff --git a/internal/engine/lib/sqlite_g_00000000000028c0.go b/internal/engine/lib/sqlite_g_00000000000028c0.go new file mode 100644 index 0000000..5915b4d --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000028c0.go @@ -0,0 +1,124 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && ppc64le) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Find the mode, uid and gid of file zFile. +// */ +func _getFileMode(tls *libc.TLS, zFile uintptr, pMode uintptr, pUid uintptr, pGid uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var rc int32 + var _ /* sStat at bp+0 */ Tstat + _ = rc /* Output of stat() on database file */ + rc = SQLITE_OK + if 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zFile, bp) { + **(**Tmode_t)(__ccgo_up(pMode)) = (**(**Tstat)(__ccgo_up(bp))).Fst_mode & uint32(0777) + **(**Tuid_t)(__ccgo_up(pUid)) = (**(**Tstat)(__ccgo_up(bp))).Fst_uid + **(**Tgid_t)(__ccgo_up(pGid)) = (**(**Tstat)(__ccgo_up(bp))).Fst_gid + } else { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)<= int32(SQLITE_MINIMUM_FILE_DESCRIPTOR) { + break + } + if f&(libc.Int32FromInt32(O_EXCL)|libc.Int32FromInt32(O_CREAT)) == libc.Int32FromInt32(O_EXCL)|libc.Int32FromInt32(O_CREAT) { + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(16)].FpCurrent})))(tls, z) + } + (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(1)].FpCurrent})))(tls, fd) + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+3752, libc.VaList(bp+152, z, fd)) + fd = -int32(1) + if (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[0].FpCurrent})))(tls, __ccgo_ts+3795, O_RDONLY, libc.Int32FromUint32(m)) < 0 { + break + } + } + if fd >= 0 { + if m != uint32(0) { + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(5)].FpCurrent})))(tls, fd, bp) == 0 && (**(**Tstat)(__ccgo_up(bp))).Fst_size == 0 && (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(0777) != m { + (*(*func(*libc.TLS, int32, Tmode_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(14)].FpCurrent})))(tls, fd, m) + } + } + } + return fd +} + +// C documentation +// +// /* +// ** Test the existence of or access permissions of file zPath. The +// ** test performed depends on the value of flags: +// ** +// ** SQLITE_ACCESS_EXISTS: Return 1 if the file exists +// ** SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable. +// ** SQLITE_ACCESS_READONLY: Return 1 if the file is readable. +// ** +// ** Otherwise return 0. +// */ +func _unixAccess(tls *libc.TLS, NotUsed uintptr, zPath uintptr, flags int32, pResOut uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var _ /* buf at bp+0 */ Tstat + _ = NotUsed + /* The spec says there are three possible values for flags. But only + ** two of them are actually used */ + if flags == SQLITE_ACCESS_EXISTS { + **(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32(0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zPath, bp) && (!((**(**Tstat)(__ccgo_up(bp))).Fst_mode&libc.Uint32FromInt32(S_IFMT) == libc.Uint32FromInt32(S_IFREG)) || (**(**Tstat)(__ccgo_up(bp))).Fst_size > 0)) + } else { + **(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zPath, libc.Int32FromInt32(W_OK)|libc.Int32FromInt32(R_OK)) == 0) + } + return SQLITE_OK +} diff --git a/internal/engine/lib/sqlite_g_00000000000034c0.go b/internal/engine/lib/sqlite_g_00000000000034c0.go new file mode 100644 index 0000000..235f49a --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000034c0.go @@ -0,0 +1,15 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && loong64) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +const O_DIRECT = 16384 + +const O_DIRECTORY = 65536 + +const O_LARGEFILE = 32768 + +const O_NOFOLLOW = 131072 + +const O_TMPFILE = 4259840 diff --git a/internal/engine/lib/sqlite_g_00000000000037c0.go b/internal/engine/lib/sqlite_g_00000000000037c0.go new file mode 100644 index 0000000..be3be3a --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000037c0.go @@ -0,0 +1,99 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +const EDEADLOCK = 35 + +const F2FS_IOC_ABORT_VOLATILE_WRITE = 62725 + +const F2FS_IOC_COMMIT_ATOMIC_WRITE = 62722 + +const F2FS_IOC_GET_FEATURES = 2147546380 + +const F2FS_IOC_START_ATOMIC_WRITE = 62721 + +const F2FS_IOC_START_VOLATILE_WRITE = 62723 + +const FIOASYNC = 21586 + +const FIOCLEX = 21585 + +const FIONBIO = 21537 + +const FIONCLEX = 21584 + +const FIONREAD = 21531 + +const MAP_LOCKED = 8192 + +const MAP_NORESERVE = 16384 + +const MCL_ONFAULT = 4 + +const TCFLSH = 21515 + +const TCGETA = 21509 + +const TCGETS = 21505 + +const TCGETX = 21554 + +const TCSBRK = 21513 + +const TCSETA = 21510 + +const TCSETAF = 21512 + +const TCSETAW = 21511 + +const TCSETS = 21506 + +const TCSETSF = 21508 + +const TCSETSW = 21507 + +const TCSETX = 21555 + +const TCSETXF = 21556 + +const TCSETXW = 21557 + +const TCXONC = 21514 + +const TIOCGDEV = 2147767346 + +const TIOCGEXCL = 2147767360 + +const TIOCGISO7816 = 2150126658 + +const TIOCGPGRP = 21519 + +const TIOCGPKT = 2147767352 + +const TIOCGPTLCK = 2147767353 + +const TIOCGPTN = 2147767344 + +const TIOCGPTPEER = 21569 + +const TIOCGWINSZ = 21523 + +const TIOCINQ = 21531 + +const TIOCOUTQ = 21521 + +const TIOCSIG = 1074025526 + +const TIOCSISO7816 = 3223868483 + +const TIOCSPGRP = 21520 + +const TIOCSPTLCK = 1074025521 + +const TIOCSWINSZ = 21524 + +const _IOC_NONE = 0 + +const _IOC_WRITE = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000003a00.go b/internal/engine/lib/sqlite_g_0000000000003a00.go new file mode 100644 index 0000000..e344216 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003a00.go @@ -0,0 +1,27840 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type Tfpos_t = struct { + F__lldata [0]int64 + F__align [0]float64 + F__opaque [16]uint8 +} + +// C documentation +// +// /* +// ** Given the name of a compile-time option, return true if that option +// ** was used and false if not. +// ** +// ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix +// ** is not required for a match. +// */ +func Xsqlite3_compileoption_used(tls *libc.TLS, zOptName uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azCompileOpt uintptr + var i, n int32 + var _ /* nOpt at bp+0 */ int32 + _, _, _ = azCompileOpt, i, n + azCompileOpt = _sqlite3CompileOptions(tls, bp) + if Xsqlite3_strnicmp(tls, zOptName, __ccgo_ts+26299, int32(7)) == 0 { + zOptName = zOptName + uintptr(7) + } + n = _sqlite3Strlen30(tls, zOptName) + /* Since nOpt is normally in single digits, a linear search is + ** adequate. No need for a binary search. */ + i = 0 + for { + if !(i < **(**int32)(__ccgo_up(bp))) { + break + } + if Xsqlite3_strnicmp(tls, zOptName, **(**uintptr)(__ccgo_up(azCompileOpt + uintptr(i)*8)), n) == 0 && _sqlite3IsIdChar(tls, uint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(azCompileOpt + uintptr(i)*8)) + uintptr(n))))) == 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Execute SQL code. Return one of the SQLITE_ success/failure +// ** codes. Also write an error message into memory obtained from +// ** malloc() and make *pzErrMsg point to that message. +// ** +// ** If the SQL is a query, then for each row in the query result +// ** the xCallback() function is called. pArg becomes the first +// ** argument to xCallback(). If xCallback=NULL then no callback +// ** is invoked, even for queries. +// */ +func Xsqlite3_exec(tls *libc.TLS, db uintptr, zSql uintptr, __ccgo_fp_xCallback Tsqlite3_callback, pArg uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azCols, azVals uintptr + var callbackIsInit, i, nCol, rc int32 + var _ /* pStmt at bp+8 */ uintptr + var _ /* zLeftover at bp+0 */ uintptr + _, _, _, _, _, _ = azCols, azVals, callbackIsInit, i, nCol, rc + rc = SQLITE_OK /* Tail of unprocessed SQL */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* The current SQL statement */ + azCols = uintptr(0) /* True if callback data is initialized */ + if !(_sqlite3SafetyCheckOk(tls, db) != 0) { + return _sqlite3MisuseError(tls, int32(142203)) + } + if zSql == uintptr(0) { + zSql = __ccgo_ts + 1704 + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3Error(tls, db, SQLITE_OK) + for rc == SQLITE_OK && **(**uint8)(__ccgo_up(zSql)) != 0 { + nCol = 0 + azVals = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp+8, bp) + if rc != SQLITE_OK { + continue + } + if !(**(**uintptr)(__ccgo_up(bp + 8)) != 0) { + /* this happens for a comment or white-space */ + zSql = **(**uintptr)(__ccgo_up(bp)) + continue + } + callbackIsInit = 0 + for int32(1) != 0 { + rc = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) + /* Invoke the callback function if required */ + if __ccgo_fp_xCallback != 0 && (int32(SQLITE_ROW) == rc || int32(SQLITE_DONE) == rc && !(callbackIsInit != 0) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NullCallback) != 0) { + if !(callbackIsInit != 0) { + nCol = Xsqlite3_column_count(tls, **(**uintptr)(__ccgo_up(bp + 8))) + azCols = _sqlite3DbMallocRaw(tls, db, uint64(libc.Uint64FromInt32(libc.Int32FromInt32(2)*nCol+libc.Int32FromInt32(1))*uint64(8))) + if azCols == uintptr(0) { + goto exec_out + } + i = 0 + for { + if !(i < nCol) { + break + } + **(**uintptr)(__ccgo_up(azCols + uintptr(i)*8)) = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) + /* sqlite3VdbeSetColName() installs column names as UTF8 + ** strings so there is no way for sqlite3_column_name() to fail. */ + goto _1 + _1: + ; + i = i + 1 + } + callbackIsInit = int32(1) + } + if rc == int32(SQLITE_ROW) { + azVals = azCols + uintptr(nCol)*8 + i = 0 + for { + if !(i < nCol) { + break + } + **(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) + if !(**(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) != 0) && Xsqlite3_column_type(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) != int32(SQLITE_NULL) { + _sqlite3OomFault(tls, db) + goto exec_out + } + goto _2 + _2: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) = uintptr(0) + } + if (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xCallback})))(tls, pArg, nCol, azVals, azCols) != 0 { + /* EVIDENCE-OF: R-38229-40159 If the callback function to + ** sqlite3_exec() returns non-zero, then sqlite3_exec() will + ** return SQLITE_ABORT. */ + rc = int32(SQLITE_ABORT) + _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + _sqlite3Error(tls, db, int32(SQLITE_ABORT)) + goto exec_out + } + } + if rc != int32(SQLITE_ROW) { + rc = _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + zSql = **(**uintptr)(__ccgo_up(bp)) + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zSql)))])&int32(0x01) != 0 { + zSql = zSql + 1 + } + break + } + } + _sqlite3DbFree(tls, db, azCols) + azCols = uintptr(0) + } + goto exec_out +exec_out: + ; + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + _sqlite3DbFree(tls, db, azCols) + rc = _sqlite3ApiExit(tls, db, rc) + if rc != SQLITE_OK && pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = _sqlite3DbStrDup(tls, uintptr(0), Xsqlite3_errmsg(tls, db)) + if **(**uintptr)(__ccgo_up(pzErrMsg)) == uintptr(0) { + rc = int32(SQLITE_NOMEM) + _sqlite3Error(tls, db, int32(SQLITE_NOMEM)) + } + } else { + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Render a string given by "fmt" into the StrAccum object. +// */ +func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Tva_list) { + bp := tls.Alloc(128) + defer tls.Free(128) + var adj, c, e2, exp, iRound, idx, ii, ix, j, length, nOut, needQuote, nn, nn1, nn2, nn3, precision, width, x, v2, v3 int32 + var bArgList, base Tu8 + var bufpt, cset, escarg, infop, pArgList, pExpr, pItem, pSel, pToken, pre, z, zExtra, zOut, v4 uintptr + var cThousand, done, flag_alternateform, flag_altform2, flag_dp, flag_leftjustify, flag_long, flag_prefix, flag_rtz, flag_zeropad, xtype, v5, v6, v7, v8, v9 TetByte + var ch, px, wx uint32 + var ch1, prefix, q, x1, v54 uint8 + var i, j1, k, n1, nBack, nCopyBytes, nCtrl, nPad, nPrior, szBufNeeded, v, v90 Ti64 + var longvalue Tsqlite_uint64 + var n Tu64 + var realvalue float64 + var v12 bool + var _ /* buf at bp+0 */ [70]uint8 + var _ /* s at bp+72 */ TFpDecode + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = adj, bArgList, base, bufpt, c, cThousand, ch, ch1, cset, done, e2, escarg, exp, flag_alternateform, flag_altform2, flag_dp, flag_leftjustify, flag_long, flag_prefix, flag_rtz, flag_zeropad, i, iRound, idx, ii, infop, ix, j, j1, k, length, longvalue, n, n1, nBack, nCopyBytes, nCtrl, nOut, nPad, nPrior, needQuote, nn, nn1, nn2, nn3, pArgList, pExpr, pItem, pSel, pToken, pre, precision, prefix, px, q, realvalue, szBufNeeded, v, width, wx, x, x1, xtype, z, zExtra, zOut, v12, v2, v3, v4, v5, v54, v6, v7, v8, v9, v90 /* Thousands separator for %d and %u */ + xtype = uint8(etINVALID) /* Size of the rendering buffer */ + zExtra = uintptr(0) /* True if trailing zeros should be removed */ + pArgList = uintptr(0) /* Conversion buffer */ + /* pAccum never starts out with an empty buffer that was obtained from + ** malloc(). This precondition is required by the mprintf("%z...") + ** optimization. */ + bufpt = uintptr(0) + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_SQLFUNC) != 0 { + pArgList = libc.VaUintptr(&ap) + bArgList = uint8(1) + } else { + bArgList = uint8(0) + } + for { + v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) + c = v2 + if !(v2 != 0) { + break + } + if c != int32('%') { + bufpt = fmt + fmt = libc.Xstrchr(tls, fmt, int32('%')) + if fmt == uintptr(0) { + fmt = bufpt + uintptr(libc.Xstrlen(tls, bufpt)) + } + Xsqlite3_str_append(tls, pAccum, bufpt, int32(int64(fmt)-int64(bufpt))) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) == 0 { + break + } + } + fmt = fmt + 1 + v4 = fmt + v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + c = v2 + if v2 == 0 { + Xsqlite3_str_append(tls, pAccum, __ccgo_ts+1688, int32(1)) + break + } + /* Find out what flags are present */ + v9 = libc.Uint8FromInt32(0) + flag_zeropad = v9 + v8 = v9 + flag_altform2 = v8 + v7 = v8 + flag_alternateform = v7 + v6 = v7 + cThousand = v6 + v5 = v6 + flag_prefix = v5 + flag_leftjustify = v5 + done = uint8(0) + width = 0 + flag_long = uint8(0) + precision = -int32(1) + for { + switch c { + case int32('-'): + flag_leftjustify = uint8(1) + case int32('+'): + flag_prefix = uint8('+') + case int32(' '): + flag_prefix = uint8(' ') + case int32('#'): + flag_alternateform = uint8(1) + case int32('!'): + flag_altform2 = uint8(1) + case int32('0'): + flag_zeropad = uint8(1) + case int32(','): + cThousand = uint8(',') + default: + done = uint8(1) + case int32('l'): + flag_long = uint8(1) + fmt = fmt + 1 + v4 = fmt + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + if c == int32('l') { + fmt = fmt + 1 + v4 = fmt + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + flag_long = uint8(2) + } + done = uint8(1) + case int32('1'): + fallthrough + case int32('2'): + fallthrough + case int32('3'): + fallthrough + case int32('4'): + fallthrough + case int32('5'): + fallthrough + case int32('6'): + fallthrough + case int32('7'): + fallthrough + case int32('8'): + fallthrough + case int32('9'): + wx = libc.Uint32FromInt32(c - int32('0')) + for { + fmt = fmt + 1 + v4 = fmt + v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + c = v2 + if !(v2 >= int32('0') && c <= int32('9')) { + break + } + wx = wx*uint32(10) + libc.Uint32FromInt32(c) - uint32('0') + } + width = libc.Int32FromUint32(wx & uint32(0x7fffffff)) + if c != int32('.') && c != int32('l') { + done = uint8(1) + } else { + fmt = fmt - 1 + } + case int32('*'): + if bArgList != 0 { + width = int32(_getIntArg(tls, pArgList)) + } else { + width = libc.VaInt32(&ap) + } + if width < 0 { + flag_leftjustify = uint8(1) + if width >= -int32(2147483647) { + v2 = -width + } else { + v2 = 0 + } + width = v2 + } + v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(fmt + 1))) + c = v2 + if v2 != int32('.') && c != int32('l') { + fmt = fmt + 1 + v4 = fmt + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + done = uint8(1) + } + case int32('.'): + fmt = fmt + 1 + v4 = fmt + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + if c == int32('*') { + if bArgList != 0 { + precision = int32(_getIntArg(tls, pArgList)) + } else { + precision = libc.VaInt32(&ap) + } + if precision < 0 { + if precision >= -int32(2147483647) { + v2 = -precision + } else { + v2 = -int32(1) + } + precision = v2 + } + fmt = fmt + 1 + v4 = fmt + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + } else { + px = uint32(0) + for c >= int32('0') && c <= int32('9') { + px = px*uint32(10) + libc.Uint32FromInt32(c) - uint32('0') + fmt = fmt + 1 + v4 = fmt + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + } + precision = libc.Int32FromUint32(px & uint32(0x7fffffff)) + } + if c == int32('l') { + fmt = fmt - 1 + } else { + done = uint8(1) + } + break + } + goto _13 + _13: + ; + if v12 = !(done != 0); v12 { + fmt = fmt + 1 + v4 = fmt + v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + c = v2 + } + if !(v12 && v2 != 0) { + break + } + } + /* Fetch the info entry for the field */ + /* Fast hash-table lookup */ + idx = libc.Int32FromUint32(libc.Uint32FromInt32(c) % uint32(23)) + if v12 = libc.Int32FromUint8(_fmtinfo[idx].Ffmttype) == c; !v12 { + v2 = libc.Int32FromUint8(_fmtinfo[idx].FiNxt) + idx = v2 + } + if v12 || libc.Int32FromUint8(_fmtinfo[v2].Ffmttype) == c { + infop = uintptr(unsafe.Pointer(&_fmtinfo)) + uintptr(idx)*7 + xtype = (*Tet_info)(unsafe.Pointer(infop)).Ftype1 + } else { + infop = uintptr(unsafe.Pointer(&_fmtinfo)) + xtype = uint8(etINVALID) + } + /* + ** At this point, variables are initialized as follows: + ** + ** flag_alternateform TRUE if a '#' is present. + ** flag_altform2 TRUE if a '!' is present. + ** flag_prefix '+' or ' ' or zero + ** flag_leftjustify TRUE if a '-' is present or if the + ** field width was negative. + ** flag_zeropad TRUE if the width began with 0. + ** flag_long 1 for "l", 2 for "ll" + ** width The specified field width. This is + ** always non-negative. Zero is the default. + ** precision The specified precision. The default + ** is -1. + ** xtype The class of the conversion. + ** infop Pointer to the appropriate info struct. + */ + switch libc.Int32FromUint8(xtype) { + case int32(etPOINTER): + goto _27 + case etRADIX: + goto _28 + case int32(etORDINAL): + goto _29 + case int32(etDECIMAL): + goto _30 + case int32(etGENERIC): + goto _31 + case int32(etEXP): + goto _32 + case int32(etFLOAT): + goto _33 + case int32(etSIZE): + goto _34 + case int32(etPERCENT): + goto _35 + case int32(etCHARX): + goto _36 + case int32(etDYNSTRING): + goto _37 + case int32(etSTRING): + goto _38 + case int32(etESCAPE_w): + goto _39 + case int32(etESCAPE_Q): + goto _40 + case int32(etESCAPE_q): + goto _41 + case int32(etTOKEN): + goto _42 + case int32(etSRCITEM): + goto _43 + default: + goto _44 + } + goto _45 + _27: + ; + flag_long = uint8(2) + _29: + ; + _28: + ; + cThousand = uint8(0) + _30: + ; + if libc.Int32FromUint8((*Tet_info)(unsafe.Pointer(infop)).Fflags)&int32(FLAG_SIGNED) != 0 { + if bArgList != 0 { + v = _getIntArg(tls, pArgList) + } else { + if flag_long != 0 { + if libc.Int32FromUint8(flag_long) == int32(2) { + v = libc.VaInt64(&ap) + } else { + v = int64(libc.VaInt64(&ap)) + } + } else { + v = int64(libc.VaInt32(&ap)) + } + } + if v < 0 { + longvalue = libc.Uint64FromInt64(^v) + longvalue = longvalue + 1 + prefix = uint8('-') + } else { + longvalue = libc.Uint64FromInt64(v) + prefix = flag_prefix + } + } else { + if bArgList != 0 { + longvalue = libc.Uint64FromInt64(_getIntArg(tls, pArgList)) + } else { + if flag_long != 0 { + if libc.Int32FromUint8(flag_long) == int32(2) { + longvalue = libc.VaUint64(&ap) + } else { + longvalue = uint64(libc.VaUint64(&ap)) + } + } else { + longvalue = uint64(libc.VaUint32(&ap)) + } + } + prefix = uint8(0) + } + if longvalue == uint64(0) { + flag_alternateform = uint8(0) + } + if flag_zeropad != 0 && precision < width-libc.BoolInt32(libc.Int32FromUint8(prefix) != 0) { + precision = width - libc.BoolInt32(libc.Int32FromUint8(prefix) != 0) + } + if precision < libc.Int32FromInt32(SQLITE_PRINT_BUF_SIZE)-libc.Int32FromInt32(10)-libc.Int32FromInt32(SQLITE_PRINT_BUF_SIZE)/libc.Int32FromInt32(3) { + nOut = int32(SQLITE_PRINT_BUF_SIZE) + zOut = bp + } else { + n = libc.Uint64FromInt32(precision) + uint64(10) + if cThousand != 0 { + n = n + libc.Uint64FromInt32(precision/int32(3)) + } + v4 = _printfTempBuf(tls, pAccum, libc.Int64FromUint64(n)) + zExtra = v4 + zOut = v4 + if zOut == uintptr(0) { + return + } + nOut = libc.Int32FromUint64(n) + } + bufpt = zOut + uintptr(nOut-int32(1)) + if libc.Int32FromUint8(xtype) == int32(etORDINAL) { + x = libc.Int32FromUint64(longvalue % libc.Uint64FromInt32(10)) + if x >= int32(4) || longvalue/uint64(10)%uint64(10) == uint64(1) { + x = 0 + } + bufpt = bufpt - 1 + v4 = bufpt + **(**uint8)(__ccgo_up(v4)) = _zOrd[x*int32(2)+int32(1)] + bufpt = bufpt - 1 + v4 = bufpt + **(**uint8)(__ccgo_up(v4)) = _zOrd[x*int32(2)] + } + cset = uintptr(unsafe.Pointer(&_aDigits)) + uintptr((*Tet_info)(unsafe.Pointer(infop)).Fcharset) + base = (*Tet_info)(unsafe.Pointer(infop)).Fbase + for cond := true; cond; cond = longvalue > uint64(0) { /* Convert to ascii */ + bufpt = bufpt - 1 + v4 = bufpt + **(**uint8)(__ccgo_up(v4)) = **(**uint8)(__ccgo_up(cset + uintptr(longvalue%uint64(base)))) + longvalue = longvalue / uint64(base) + } + length = int32(t__predefined_ptrdiff_t(zOut+uintptr(nOut-int32(1))) - int64(bufpt)) + if precision > length { /* zero pad */ + nn = precision - length + bufpt = bufpt - uintptr(nn) + libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(nn)) + length = precision + } + if cThousand != 0 { + nn1 = (length - int32(1)) / int32(3) /* Number of "," to insert */ + ix = (length-int32(1))%int32(3) + int32(1) + bufpt = bufpt - uintptr(nn1) + idx = 0 + for { + if !(nn1 > 0) { + break + } + **(**uint8)(__ccgo_up(bufpt + uintptr(idx))) = **(**uint8)(__ccgo_up(bufpt + uintptr(idx+nn1))) + ix = ix - 1 + if ix == 0 { + idx = idx + 1 + v2 = idx + **(**uint8)(__ccgo_up(bufpt + uintptr(v2))) = cThousand + nn1 = nn1 - 1 + ix = int32(3) + } + goto _50 + _50: + ; + idx = idx + 1 + } + } + if prefix != 0 { + bufpt = bufpt - 1 + v4 = bufpt + **(**uint8)(__ccgo_up(v4)) = prefix + } /* Add sign */ + if flag_alternateform != 0 && (*Tet_info)(unsafe.Pointer(infop)).Fprefix != 0 { + pre = uintptr(unsafe.Pointer(&_aPrefix)) + uintptr((*Tet_info)(unsafe.Pointer(infop)).Fprefix) + for { + v54 = **(**uint8)(__ccgo_up(pre)) + x1 = v54 + if !(libc.Int32FromUint8(v54) != 0) { + break + } + bufpt = bufpt - 1 + v4 = bufpt + **(**uint8)(__ccgo_up(v4)) = x1 + goto _53 + _53: + ; + pre = pre + 1 + } + } + length = int32(t__predefined_ptrdiff_t(zOut+uintptr(nOut-int32(1))) - int64(bufpt)) + goto _45 + _33: + ; + _32: + ; + _31: + ; /* Size needed to hold the output */ + if bArgList != 0 { + realvalue = _getDoubleArg(tls, pArgList) + } else { + realvalue = libc.VaFloat64(&ap) + } + if precision < 0 { + precision = int32(6) + } /* Set default precision */ + if precision > int32(SQLITE_FP_PRECISION_LIMIT) { + precision = int32(SQLITE_FP_PRECISION_LIMIT) + } + if libc.Int32FromUint8(xtype) == int32(etFLOAT) { + iRound = -precision + } else { + if libc.Int32FromUint8(xtype) == int32(etGENERIC) { + if precision == 0 { + precision = int32(1) + } + iRound = precision + } else { + iRound = precision + int32(1) + } + } + if flag_altform2 != 0 { + v2 = int32(20) + } else { + v2 = int32(16) + } + _sqlite3FpDecode(tls, bp+72, realvalue, iRound, v2) + if (**(**TFpDecode)(__ccgo_up(bp + 72))).FisSpecial != 0 { + if libc.Int32FromUint8((**(**TFpDecode)(__ccgo_up(bp + 72))).FisSpecial) == int32(2) { + if flag_zeropad != 0 { + v4 = __ccgo_ts + 1690 + } else { + v4 = __ccgo_ts + 1695 + } + bufpt = v4 + length = _sqlite3Strlen30(tls, bufpt) + goto _45 + } else { + if flag_zeropad != 0 { + **(**uint8)(__ccgo_up((**(**TFpDecode)(__ccgo_up(bp + 72))).Fz)) = uint8('9') + (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP = int32(1000) + (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn = int32(1) + } else { + libc.Xmemcpy(tls, bp, __ccgo_ts+1699, uint64(5)) + bufpt = bp + if libc.Int32FromUint8((**(**TFpDecode)(__ccgo_up(bp + 72))).Fsign) == int32('-') { + /* no-op */ + } else { + if flag_prefix != 0 { + (**(**[70]uint8)(__ccgo_up(bp)))[0] = flag_prefix + } else { + bufpt = bufpt + 1 + } + } + length = _sqlite3Strlen30(tls, bufpt) + goto _45 + } + } + } + if libc.Int32FromUint8((**(**TFpDecode)(__ccgo_up(bp + 72))).Fsign) == int32('-') { + if flag_alternateform != 0 && !(flag_prefix != 0) && libc.Int32FromUint8(xtype) == int32(etFLOAT) && (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP <= iRound { + /* Suppress the minus sign if all of the following are true: + ** * The value displayed is zero + ** * The '#' flag is used + ** * The '+' flag is not used, and + ** * The format is %f + */ + prefix = uint8(0) + } else { + prefix = uint8('-') + } + } else { + prefix = flag_prefix + } + exp = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + /* + ** If the field type is etGENERIC, then convert to either etEXP + ** or etFLOAT, as appropriate. + */ + if libc.Int32FromUint8(xtype) == int32(etGENERIC) { + precision = precision - 1 + flag_rtz = libc.BoolUint8(!(flag_alternateform != 0)) + if exp < -int32(4) || exp > precision { + xtype = uint8(etEXP) + } else { + precision = precision - exp + xtype = uint8(etFLOAT) + } + } else { + flag_rtz = flag_altform2 + } + if libc.Int32FromUint8(xtype) == int32(etEXP) { + e2 = 0 + } else { + e2 = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + } + if e2 > 0 { + v2 = e2 + } else { + v2 = 0 + } + szBufNeeded = int64(v2) + int64(precision) + int64(width) + int64(10) + if cThousand != 0 && e2 > 0 { + szBufNeeded = szBufNeeded + int64((e2+int32(2))/int32(3)) + } + if szBufNeeded+libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) >= libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc) { + if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc == uint32(0) && libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0 { + /* Unable to allocate space in pAccum, perhaps because it + ** is coming from sqlite3_snprintf() or similar. We'll have + ** to render into temporary space and the memcpy() it over. */ + bufpt = Xsqlite3_malloc(tls, int32(szBufNeeded)) + if bufpt == uintptr(0) { + _sqlite3StrAccumSetError(tls, pAccum, uint8(SQLITE_NOMEM)) + return + } + zExtra = bufpt + } else { + if int64(_sqlite3StrAccumEnlarge(tls, pAccum, szBufNeeded)) < szBufNeeded { + v2 = libc.Int32FromInt32(0) + length = v2 + width = v2 + goto _45 + } else { + bufpt = (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + } + } else { + bufpt = (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + zOut = bufpt + if precision > 0 { + v2 = int32(1) + } else { + v2 = 0 + } + flag_dp = libc.Uint8FromInt32(v2 | libc.Int32FromUint8(flag_alternateform) | libc.Int32FromUint8(flag_altform2)) + /* The sign in front of the number */ + if prefix != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = prefix + } + /* Digits prior to the decimal point */ + j = 0 + if e2 < 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = uint8('0') + } else { + if cThousand != 0 { + for { + if !(e2 >= 0) { + break + } + v4 = bufpt + bufpt = bufpt + 1 + if j < (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn { + v3 = j + j = j + 1 + v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up((**(**TFpDecode)(__ccgo_up(bp + 72))).Fz + uintptr(v3)))) + } else { + v2 = int32('0') + } + **(**uint8)(__ccgo_up(v4)) = libc.Uint8FromInt32(v2) + if e2%int32(3) == 0 && e2 > int32(1) { + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(',') + } + goto _63 + _63: + ; + e2 = e2 - 1 + } + } else { + j = e2 + int32(1) + if j > (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn { + j = (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn + } + libc.Xmemcpy(tls, bufpt, (**(**TFpDecode)(__ccgo_up(bp + 72))).Fz, libc.Uint64FromInt32(j)) + bufpt = bufpt + uintptr(j) + e2 = e2 - j + if e2 >= 0 { + libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(e2+int32(1))) + bufpt = bufpt + uintptr(e2+int32(1)) + e2 = -int32(1) + } + } + } + /* The decimal point */ + if flag_dp != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = uint8('.') + } + /* "0" digits after the decimal point but before the first + ** significant digit of the number */ + if e2 < -int32(1) && precision > 0 { + nn2 = -int32(1) - e2 + if nn2 > precision { + nn2 = precision + } + libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(nn2)) + bufpt = bufpt + uintptr(nn2) + precision = precision - nn2 + } + /* Significant digits after the decimal point */ + if precision > 0 { + nn3 = (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn - j + if nn3 > precision { + nn3 = precision + } + if nn3 > 0 { + libc.Xmemcpy(tls, bufpt, (**(**TFpDecode)(__ccgo_up(bp + 72))).Fz+uintptr(j), libc.Uint64FromInt32(nn3)) + bufpt = bufpt + uintptr(nn3) + precision = precision - nn3 + } + if precision > 0 && !(flag_rtz != 0) { + libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(precision)) + bufpt = bufpt + uintptr(precision) + } + } + /* Remove trailing zeros and the "." if no digits follow the "." */ + if flag_rtz != 0 && flag_dp != 0 { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(bufpt + uintptr(-libc.Int32FromInt32(1))))) == int32('0') { + bufpt = bufpt - 1 + v4 = bufpt + **(**uint8)(__ccgo_up(v4)) = uint8(0) + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(bufpt + uintptr(-libc.Int32FromInt32(1))))) == int32('.') { + if flag_altform2 != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = uint8('0') + } else { + bufpt = bufpt - 1 + v4 = bufpt + **(**uint8)(__ccgo_up(v4)) = uint8(0) + } + } + } + /* Add the "eNNN" suffix */ + if libc.Int32FromUint8(xtype) == int32(etEXP) { + exp = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = _aDigits[(*Tet_info)(unsafe.Pointer(infop)).Fcharset] + if exp < 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = uint8('-') + exp = -exp + } else { + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = uint8('+') + } + if exp >= int32(100) { + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = libc.Uint8FromInt32(exp/libc.Int32FromInt32(100) + libc.Int32FromUint8('0')) /* 100's digit */ + exp = exp % int32(100) + } + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = libc.Uint8FromInt32(exp/libc.Int32FromInt32(10) + libc.Int32FromUint8('0')) /* 10's digit */ + v4 = bufpt + bufpt = bufpt + 1 + **(**uint8)(__ccgo_up(v4)) = libc.Uint8FromInt32(exp%libc.Int32FromInt32(10) + libc.Int32FromUint8('0')) /* 1's digit */ + } + length = int32(int64(bufpt) - int64(zOut)) + if length < width { + nPad = int64(width - length) + if flag_leftjustify != 0 { + libc.Xmemset(tls, bufpt, int32(' '), libc.Uint64FromInt64(nPad)) + } else { + if !(flag_zeropad != 0) { + libc.Xmemmove(tls, zOut+uintptr(nPad), zOut, libc.Uint64FromInt32(length)) + libc.Xmemset(tls, zOut, int32(' '), libc.Uint64FromInt64(nPad)) + } else { + adj = libc.BoolInt32(libc.Int32FromUint8(prefix) != 0) + libc.Xmemmove(tls, zOut+uintptr(nPad)+uintptr(adj), zOut+uintptr(adj), libc.Uint64FromInt32(length-adj)) + libc.Xmemset(tls, zOut+uintptr(adj), int32('0'), libc.Uint64FromInt64(nPad)) + } + } + length = width + } + if zExtra == uintptr(0) { + /* The result is being rendered directory into pAccum. This + ** is the command and fast case */ + **(**Tu32)(__ccgo_up(pAccum + 24)) += libc.Uint32FromInt32(length) + **(**uint8)(__ccgo_up(zOut + uintptr(length))) = uint8(0) + goto _1 + } else { + /* We were unable to render directly into pAccum because we + ** couldn't allocate sufficient memory. We need to memcpy() + ** the rendering (or some prefix thereof) into the output + ** buffer. */ + **(**uint8)(__ccgo_up(bufpt)) = uint8(0) + bufpt = zExtra + goto _45 + } + _34: + ; + if !(bArgList != 0) { + **(**int32)(__ccgo_up(libc.VaUintptr(&ap))) = libc.Int32FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _35: + ; + (**(**[70]uint8)(__ccgo_up(bp)))[0] = uint8('%') + bufpt = bp + length = int32(1) + goto _45 + _36: + ; + if bArgList != 0 { + bufpt = _getTextArg(tls, pArgList) + length = int32(1) + if bufpt != 0 { + v4 = bufpt + bufpt = bufpt + 1 + v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + c = v2 + (**(**[70]uint8)(__ccgo_up(bp)))[0] = libc.Uint8FromInt32(v2) + if c&int32(0xc0) == int32(0xc0) { + for length < int32(4) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(bufpt)))&int32(0xc0) == int32(0x80) { + v2 = length + length = length + 1 + v4 = bufpt + bufpt = bufpt + 1 + (**(**[70]uint8)(__ccgo_up(bp)))[v2] = **(**uint8)(__ccgo_up(v4)) + } + } + } else { + (**(**[70]uint8)(__ccgo_up(bp)))[0] = uint8(0) + } + } else { + ch = libc.VaUint32(&ap) + length = _sqlite3AppendOneUtf8Character(tls, bp, ch) + } + if precision > int32(1) { + nPrior = int64(1) + width = width - (precision - int32(1)) + if width > int32(1) && !(flag_leftjustify != 0) { + Xsqlite3_str_appendchar(tls, pAccum, width-int32(1), uint8(' ')) + width = 0 + } + Xsqlite3_str_append(tls, pAccum, bp, length) + precision = precision - 1 + for precision > int32(1) { + if nPrior > int64(precision-int32(1)) { + nPrior = int64(precision - int32(1)) + } + nCopyBytes = int64(length) * nPrior + if _sqlite3StrAccumEnlargeIfNeeded(tls, pAccum, nCopyBytes) != 0 { + break + } + Xsqlite3_str_append(tls, pAccum, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText+uintptr(libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar)-nCopyBytes), int32(nCopyBytes)) + precision = int32(int64(precision) - nPrior) + nPrior = nPrior * int64(2) + } + } + bufpt = bp + flag_altform2 = uint8(1) + goto adjust_width_for_utf8 + _38: + ; + _37: + ; + if bArgList != 0 { + bufpt = _getTextArg(tls, pArgList) + xtype = uint8(etSTRING) + } else { + bufpt = libc.VaUintptr(&ap) + } + if bufpt == uintptr(0) { + bufpt = __ccgo_ts + 1704 + } else { + if libc.Int32FromUint8(xtype) == int32(etDYNSTRING) { + if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar == uint32(0) && (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc != 0 && width == 0 && precision < 0 && libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0 { + /* Special optimization for sqlite3_mprintf("%z..."): + ** Extend an existing memory allocation rather than creating + ** a new one. */ + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText = bufpt + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc = libc.Uint32FromInt32(_sqlite3DbMallocSize(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, bufpt)) + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar = libc.Uint32FromInt32(int32(0x7fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, bufpt))) + v4 = pAccum + 29 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v4))) | libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) + length = 0 + goto _45 + } + zExtra = bufpt + } + } + if precision >= 0 { + if flag_altform2 != 0 { + /* Set length to the number of bytes needed in order to display + ** precision characters */ + z = bufpt + for { + v2 = precision + precision = precision - 1 + if !(v2 > 0 && **(**uint8)(__ccgo_up(z)) != 0) { + break + } + v4 = z + z = z + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { + z = z + 1 + } + } + } + length = int32(int64(z) - int64(bufpt)) + } else { + length = 0 + for { + if !(length < precision && **(**uint8)(__ccgo_up(bufpt + uintptr(length))) != 0) { + break + } + goto _86 + _86: + ; + length = length + 1 + } + } + } else { + length = int32(0x7fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, bufpt)) + } + goto adjust_width_for_utf8 + adjust_width_for_utf8: + ; + if flag_altform2 != 0 && width > 0 { + /* Adjust width to account for extra bytes in UTF-8 characters */ + ii = length - int32(1) + for ii >= 0 { + v2 = ii + ii = ii - 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(bufpt + uintptr(v2))))&int32(0xc0) == int32(0x80) { + width = width + 1 + } + } + } + goto _45 + _41: + ; /* %q: Escape ' characters */ + _40: + ; /* %Q: Escape ' and enclose in '...' */ + _39: + ; + needQuote = 0 + if bArgList != 0 { + escarg = _getTextArg(tls, pArgList) + } else { + escarg = libc.VaUintptr(&ap) + } + if escarg == uintptr(0) { + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + v4 = __ccgo_ts + 1705 + } else { + v4 = __ccgo_ts + 1710 + } + escarg = v4 + } else { + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + needQuote = int32(1) + } + } + if libc.Int32FromUint8(xtype) == int32(etESCAPE_w) { + q = uint8('"') + flag_alternateform = uint8(0) + } else { + q = uint8('\'') + } + /* For %q, %Q, and %w, the precision is the number of bytes (or + ** characters if the ! flags is present) to use from the input. + ** Because of the extra quoting characters inserted, the number + ** of output characters may be larger than the precision. + */ + k = int64(precision) + v90 = libc.Int64FromInt32(0) + n1 = v90 + i = v90 + for { + if v12 = k != 0; v12 { + v54 = **(**uint8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + } + if !(v12 && libc.Int32FromUint8(v54) != 0) { + break + } + if libc.Int32FromUint8(ch1) == libc.Int32FromUint8(q) { + n1 = n1 + 1 + } + if flag_altform2 != 0 && libc.Int32FromUint8(ch1)&int32(0xc0) == int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(escarg + uintptr(i+int64(1)))))&int32(0xc0) == int32(0x80) { + i = i + 1 + } + } + goto _89 + _89: + ; + i = i + 1 + k = k - 1 + } + if flag_alternateform != 0 { + /* For %#q, do unistr()-style backslash escapes for + ** all control characters, and for backslash itself. + ** For %#Q, do the same but only if there is at least + ** one control character. */ + nBack = 0 + nCtrl = 0 + k = 0 + for { + if !(k < i) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(escarg + uintptr(k)))) == int32('\\') { + nBack = nBack + 1 + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(escarg + uintptr(k)))) <= int32(0x1f) { + nCtrl = nCtrl + 1 + } + } + goto _93 + _93: + ; + k = k + 1 + } + if nCtrl != 0 || libc.Int32FromUint8(xtype) == int32(etESCAPE_q) { + n1 = n1 + (nBack + int64(5)*nCtrl) + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + n1 = n1 + int64(10) + needQuote = int32(2) + } + } else { + flag_alternateform = uint8(0) + } + } + n1 = n1 + (i + int64(3)) + if n1 > int64(SQLITE_PRINT_BUF_SIZE) { + v4 = _printfTempBuf(tls, pAccum, n1) + zExtra = v4 + bufpt = v4 + if bufpt == uintptr(0) { + return + } + } else { + bufpt = bp + } + j1 = 0 + if needQuote != 0 { + if needQuote == int32(2) { + libc.Xmemcpy(tls, bufpt+uintptr(j1), __ccgo_ts+1717, uint64(8)) + j1 = j1 + int64(8) + } else { + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('\'') + } + } + k = i + if flag_alternateform != 0 { + i = 0 + for { + if !(i < k) { + break + } + v90 = j1 + j1 = j1 + 1 + v54 = **(**uint8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = v54 + if libc.Int32FromUint8(ch1) == libc.Int32FromUint8(q) { + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = ch1 + } else { + if libc.Int32FromUint8(ch1) == int32('\\') { + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('\\') + } else { + if libc.Int32FromUint8(ch1) <= int32(0x1f) { + **(**uint8)(__ccgo_up(bufpt + uintptr(j1-int64(1)))) = uint8('\\') + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('u') + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('0') + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('0') + v90 = j1 + j1 = j1 + 1 + if libc.Int32FromUint8(ch1) >= int32(0x10) { + v2 = int32('1') + } else { + v2 = int32('0') + } + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = libc.Uint8FromInt32(v2) + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = **(**uint8)(__ccgo_up(__ccgo_ts + 1726 + uintptr(libc.Int32FromUint8(ch1)&int32(0xf)))) + } + } + } + goto _96 + _96: + ; + i = i + 1 + } + } else { + i = 0 + for { + if !(i < k) { + break + } + v90 = j1 + j1 = j1 + 1 + v54 = **(**uint8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = v54 + if libc.Int32FromUint8(ch1) == libc.Int32FromUint8(q) { + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = ch1 + } + goto _107 + _107: + ; + i = i + 1 + } + } + if needQuote != 0 { + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('\'') + if needQuote == int32(2) { + v90 = j1 + j1 = j1 + 1 + **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8(')') + } + } + **(**uint8)(__ccgo_up(bufpt + uintptr(j1))) = uint8(0) + length = int32(j1) + goto adjust_width_for_utf8 + _42: + ; + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_INTERNAL) == 0 { + return + } + if flag_alternateform != 0 { + /* %#T means an Expr pointer that uses Expr.u.zToken */ + pExpr = libc.VaUintptr(&ap) + if pExpr != 0 && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)) { + Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + _sqlite3RecordErrorOffsetOfExpr(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, pExpr) + } + } else { + /* %T means a Token pointer */ + pToken = libc.VaUintptr(&ap) + if pToken != 0 && (*TToken)(unsafe.Pointer(pToken)).Fn != 0 { + Xsqlite3_str_append(tls, pAccum, (*TToken)(unsafe.Pointer(pToken)).Fz, libc.Int32FromUint32((*TToken)(unsafe.Pointer(pToken)).Fn)) + _sqlite3RecordErrorByteOffset(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, (*TToken)(unsafe.Pointer(pToken)).Fz) + } + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _43: + ; + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_INTERNAL) == 0 { + return + } + pItem = libc.VaUintptr(&ap) + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 && !(flag_altform2 != 0) { + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) + } else { + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) == 0 && int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) == 0 && *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { + Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pItem + 72))) + Xsqlite3_str_append(tls, pAccum, __ccgo_ts+1743, int32(1)) + } + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzName) + } else { + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { /* Because of tag-20240424-1 */ + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_NestedFrom) != 0 { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1745, libc.VaList(bp+120, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + } else { + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_MultiValue) != 0 { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1755, libc.VaList(bp+120, *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(pItem)).Fu1)))) + } else { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1776, libc.VaList(bp+120, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + } + } + } + } + } + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _44: + ; + return + _45: + ; /* End switch over the format type */ + /* + ** The text of the conversion is pointed to by "bufpt" and is + ** "length" characters long. The field width is "width". Do + ** the output. Both length and width are in bytes, not characters, + ** at this point. If the "!" flag was present on string conversions + ** indicating that width and precision should be expressed in characters, + ** then the values have been translated prior to reaching this point. + */ + width = width - length + if width > 0 { + if !(flag_leftjustify != 0) { + Xsqlite3_str_appendchar(tls, pAccum, width, uint8(' ')) + } + Xsqlite3_str_append(tls, pAccum, bufpt, length) + if flag_leftjustify != 0 { + Xsqlite3_str_appendchar(tls, pAccum, width, uint8(' ')) + } + } else { + Xsqlite3_str_append(tls, pAccum, bufpt, length) + } + if zExtra != 0 { + _sqlite3DbFree(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, zExtra) + zExtra = uintptr(0) + } + goto _1 + _1: + ; + fmt = fmt + 1 + } /* End for loop over the format string */ +} + +// C documentation +// +// /* +// ** Checkpoint database zDb. +// */ +func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDb, rc int32 + _, _ = iDb, rc /* Schema to checkpoint */ + /* Initialize the output variables to -1 in case an error occurs. */ + if pnLog != 0 { + **(**int32)(__ccgo_up(pnLog)) = -int32(1) + } + if pnCkpt != 0 { + **(**int32)(__ccgo_up(pnCkpt)) = -int32(1) + } + if eMode < -int32(1) || eMode > int32(SQLITE_CHECKPOINT_TRUNCATE) { + /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint + ** mode: */ + return _sqlite3MisuseError(tls, int32(189780)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if zDb != 0 && **(**uint8)(__ccgo_up(zDb)) != 0 { + iDb = _sqlite3FindDbName(tls, db, zDb) + } else { + iDb = libc.Int32FromInt32(SQLITE_MAX_ATTACHED) + libc.Int32FromInt32(2) /* This means process all schemas */ + } + if iDb < 0 { + rc = int32(SQLITE_ERROR) + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_ERROR), __ccgo_ts+25960, libc.VaList(bp+8, zDb)) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 + rc = _sqlite3Checkpoint(tls, db, iDb, eMode, pnLog, pnCkpt) + _sqlite3Error(tls, db, rc) + } + rc = _sqlite3ApiExit(tls, db, rc) + /* If there are no active statements, clear the interrupt flag at this + ** point. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Generate code to construct the Index object for an automatic index +// ** and to set up the WhereLevel object pLevel so that the code generator +// ** makes use of the automatic index. +// */ +func _constructAutomaticIndex(tls *libc.TLS, pParse uintptr, pWC uintptr, notReady TBitmask, pLevel uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var addrCounter, addrInit, addrTop, i, iCol, iCol1, iContinue, mxBitCol, n, nKeyCol, regBase, regRecord, regYield, v3 int32 + var cMask, cMask1, extraCols, idxCols TBitmask + var pColl, pExpr, pIdx, pLoop, pPartial, pSrc, pSubq, pTabList, pTable, pTerm, pWCEnd, pX, v, v10 uintptr + var sentWarning, useBloomFilter Tu8 + var v2 uint64 + var v4 Tu16 + var _ /* zNotUsed at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCounter, addrInit, addrTop, cMask, cMask1, extraCols, i, iCol, iCol1, iContinue, idxCols, mxBitCol, n, nKeyCol, pColl, pExpr, pIdx, pLoop, pPartial, pSrc, pSubq, pTabList, pTable, pTerm, pWCEnd, pX, regBase, regRecord, regYield, sentWarning, useBloomFilter, v, v10, v2, v3, v4 /* Bitmap of additional columns */ + sentWarning = uint8(0) /* True if a warning has been issued */ + useBloomFilter = uint8(0) /* True to also add a Bloom filter */ + pPartial = uintptr(0) /* Partial Index Expression */ + iContinue = 0 /* The FROM clause term to get the next index */ + addrCounter = 0 /* Array of registers where record is assembled */ + /* Generate code to skip over the creation and initialization of the + ** transient index on 2nd and subsequent iterations of the loop. */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + addrInit = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + /* Count the number of columns that will be added to the index + ** and used to match WHERE clause constraints */ + nKeyCol = 0 + pTabList = (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpTabList + pSrc = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + pTable = (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab + pWCEnd = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)*56 + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + idxCols = uint64(0) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(pTerm < pWCEnd) { + break + } + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + /* Make the automatic index a partial index if there are terms in the + ** WHERE clause (or the ON clause of a LEFT join) that constrain which + ** rows of the target table (pSrc) that can be used. */ + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VIRTUAL) == 0 && _sqlite3ExprIsSingleTableConstraint(tls, pExpr, pTabList, libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom), 0) != 0 { + pPartial = _sqlite3ExprAnd(tls, pParse, pPartial, _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0)) + } + if _termCanDriveIndex(tls, pTerm, pSrc, notReady) != 0 { + iCol = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn + if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v2 = libc.Uint64FromInt32(1) << (libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1)) + } else { + v2 = libc.Uint64FromInt32(1) << iCol + } + cMask = v2 + if !(sentWarning != 0) { + Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_WARNING)|libc.Int32FromInt32(1)<= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + extraCols = extraCols | libc.Uint64FromInt32(1)<<(libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1)) + break + } + if idxCols&(libc.Uint64FromInt32(1)<= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v2 = libc.Uint64FromInt32(1) << (libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1)) + } else { + v2 = libc.Uint64FromInt32(1) << iCol1 + } + cMask1 = v2 + if idxCols&cMask1 == uint64(0) { + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + idxCols = idxCols | cMask1 + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) = int16((*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn) + pColl = _sqlite3ExprCompareCollSeq(tls, pParse, pX) + /* TH3 collate01.800 */ + if pColl != 0 { + v10 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v10 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(n)*8)) = v10 + n = n + 1 + if (*TExpr)(unsafe.Pointer(pX)).FpLeft != uintptr(0) && libc.Int32FromUint8(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft)) != int32(SQLITE_AFF_TEXT) { + /* TUNING: only use a Bloom filter on an automatic index + ** if one or more key columns has the ability to hold numeric + ** values, since strings all have the same hash in the Bloom + ** filter implementation and hence a Bloom filter on a text column + ** is not usually helpful. */ + useBloomFilter = uint8(1) + } + } + } + goto _8 + _8: + ; + pTerm += 56 + } + /* Add additional columns needed to make the automatic index into + ** a covering index */ + i = 0 + for { + if !(i < mxBitCol) { + break + } + if extraCols&(libc.Uint64FromInt32(1)<>6) != 0 { + pSubq = *(*uintptr)(unsafe.Pointer(pSrc + 72)) + regYield = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + addrCounter = _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, 0) + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) + addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), regYield) + } else { + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt) + } + if pPartial != 0 { + iContinue = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, int32(SQLITE_JUMPIFNULL)) + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_PARTIALIDX) + } + regRecord = _sqlite3GetTempReg(tls, pParse) + regBase = _sqlite3GenerateIndexKey(tls, pParse, pIdx, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, regRecord, 0, uintptr(0), uintptr(0), 0) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0, regBase, libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq)) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + if pPartial != 0 { + _sqlite3VdbeResolveLabel(tls, v, iContinue) + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40>>6) != 0 { + _sqlite3VdbeChangeP2(tls, v, addrCounter, regBase+n) + _translateColumnToCopy(tls, pParse, addrTop, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FregResult, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + _sqlite3VdbeGoto(tls, v, addrTop) + libc.SetBitFieldPtr32Uint32(pSrc+24+4, libc.Uint32FromInt32(0), 6, 0x40) + _sqlite3VdbeJumpHere(tls, v, addrTop) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, addrTop+int32(1)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_STMTSTATUS_AUTOINDEX)) + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + _sqlite3VdbeJumpHere(tls, v, addrTop) + } + } + _sqlite3ReleaseTempReg(tls, pParse, regRecord) + /* Jump here when skipping the initialization */ + _sqlite3VdbeJumpHere(tls, v, addrInit) + goto end_auto_index_create +end_auto_index_create: + ; + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPartial) +} + +// C documentation +// +// /* +// ** Fill the InitData structure with an error message that indicates +// ** that the database is corrupt. +// */ +func _corruptSchema(tls *libc.TLS, pData uintptr, azObj uintptr, zExtra uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var db, z, zObj, v1 uintptr + _, _, _, _ = db, z, zObj, v1 + db = (*TInitData)(unsafe.Pointer(pData)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TInitData)(unsafe.Pointer(pData)).Frc = int32(SQLITE_NOMEM) + } else { + if **(**uintptr)(__ccgo_up((*TInitData)(unsafe.Pointer(pData)).FpzErrMsg)) != uintptr(0) { + /* A error message has already been generated. Do not overwrite it */ + } else { + if (*TInitData)(unsafe.Pointer(pData)).FmInitFlags&libc.Uint32FromInt32(libc.Int32FromInt32(INITFLAG_AlterMask)) != 0 { + **(**uintptr)(__ccgo_up((*TInitData)(unsafe.Pointer(pData)).FpzErrMsg)) = _sqlite3MPrintf(tls, db, __ccgo_ts+20023, libc.VaList(bp+8, **(**uintptr)(__ccgo_up(azObj)), **(**uintptr)(__ccgo_up(azObj + 1*8)), _azAlterType[(*TInitData)(unsafe.Pointer(pData)).FmInitFlags&uint32(INITFLAG_AlterMask)-uint32(1)], zExtra)) + (*TInitData)(unsafe.Pointer(pData)).Frc = int32(SQLITE_ERROR) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_WriteSchema) != 0 { + (*TInitData)(unsafe.Pointer(pData)).Frc = _sqlite3CorruptError(tls, int32(147813)) + } else { + if **(**uintptr)(__ccgo_up(azObj + 1*8)) != 0 { + v1 = **(**uintptr)(__ccgo_up(azObj + 1*8)) + } else { + v1 = __ccgo_ts + 5259 + } + zObj = v1 + z = _sqlite3MPrintf(tls, db, __ccgo_ts+20051, libc.VaList(bp+8, zObj)) + if zExtra != 0 && **(**uint8)(__ccgo_up(zExtra)) != 0 { + z = _sqlite3MPrintf(tls, db, __ccgo_ts+20082, libc.VaList(bp+8, z, zExtra)) + } + **(**uintptr)(__ccgo_up((*TInitData)(unsafe.Pointer(pData)).FpzErrMsg)) = z + (*TInitData)(unsafe.Pointer(pData)).Frc = _sqlite3CorruptError(tls, int32(147820)) + } + } + } + } +} + +// C documentation +// +// /* +// ** Generate a CREATE TABLE statement appropriate for the given +// ** table. Memory to hold the text of the statement is obtained +// ** from sqliteMalloc() and must be freed by the calling function. +// */ +func _createTableStmt(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, len1, v2 int32 + var n Ti64 + var pCol, zEnd, zSep, zSep2, zStmt, zType uintptr + var _ /* k at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = i, len1, n, pCol, zEnd, zSep, zSep2, zStmt, zType, v2 + n = 0 + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + i = libc.Int32FromInt32(0) + for { + if !(i < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + n = n + (_identLength(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + int64(5)) + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + n = n + _identLength(tls, (*TTable)(unsafe.Pointer(p)).FzName) + if n < int64(50) { + zSep = __ccgo_ts + 1704 + zSep2 = __ccgo_ts + 14346 + zEnd = __ccgo_ts + 5257 + } else { + zSep = __ccgo_ts + 14348 + zSep2 = __ccgo_ts + 14352 + zEnd = __ccgo_ts + 14357 + } + n = n + int64(int32(35)+int32(6)*int32((*TTable)(unsafe.Pointer(p)).FnCol)) + zStmt = _sqlite3DbMallocRaw(tls, uintptr(0), libc.Uint64FromInt64(n)) + if zStmt == uintptr(0) { + _sqlite3OomFault(tls, db) + return uintptr(0) + } + libc.Xmemcpy(tls, zStmt, __ccgo_ts+14360, uint64(13)) + **(**int32)(__ccgo_up(bp)) = int32(13) + _identPut(tls, zStmt, bp, (*TTable)(unsafe.Pointer(p)).FzName) + v2 = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(zStmt + uintptr(v2))) = uint8('(') + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + i = libc.Int32FromInt32(0) + for { + if !(i < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + len1 = _sqlite3Strlen30(tls, zSep) + libc.Xmemcpy(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zSep, libc.Uint64FromInt32(len1)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + len1 + zSep = zSep2 + _identPut(tls, zStmt, bp, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + zType = _azType1[libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity)-int32(SQLITE_AFF_BLOB)] + len1 = _sqlite3Strlen30(tls, zType) + libc.Xmemcpy(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zType, libc.Uint64FromInt32(len1)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + len1 + goto _3 + _3: + ; + i = i + 1 + pCol += 16 + } + len1 = _sqlite3Strlen30(tls, zEnd) + libc.Xmemcpy(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zEnd, libc.Uint64FromInt32(len1+int32(1))) + return zStmt +} + +// C documentation +// +// /* +// ** The first argument points to a nul-terminated string containing a +// ** list of space separated integers. Read the first nOut of these into +// ** the array aOut[]. +// */ +func _decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, aLog uintptr, pIndex uintptr) { + var c, i, sz, v2 int32 + var v TtRowcnt + var z uintptr + _, _, _, _, _, _ = c, i, sz, v, z, v2 + z = zIntArray + if z == uintptr(0) { + z = __ccgo_ts + 1704 + } + i = 0 + for { + if !(**(**uint8)(__ccgo_up(z)) != 0 && i < nOut) { + break + } + v = uint64(0) + for { + v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) + c = v2 + if !(v2 >= int32('0') && c <= int32('9')) { + break + } + v = v*uint64(10) + libc.Uint64FromInt32(c) - uint64('0') + z = z + 1 + } + if aOut != 0 { + **(**TtRowcnt)(__ccgo_up(aOut + uintptr(i)*8)) = v + } + if aLog != 0 { + **(**TLogEst)(__ccgo_up(aLog + uintptr(i)*2)) = _sqlite3LogEst(tls, v) + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + if pIndex != 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 2, 0x4) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 6, 0x40) + for **(**uint8)(__ccgo_up(z)) != 0 { + if Xsqlite3_strglob(tls, __ccgo_ts+13052, z) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 2, 0x4) + } else { + if Xsqlite3_strglob(tls, __ccgo_ts+13063, z) == 0 { + sz = _sqlite3Atoi(tls, z+uintptr(3)) + if sz < int32(2) { + sz = int32(2) + } + (*TIndex)(unsafe.Pointer(pIndex)).FszIdxRow = _sqlite3LogEst(tls, libc.Uint64FromInt32(sz)) + } else { + if Xsqlite3_strglob(tls, __ccgo_ts+13073, z) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 6, 0x40) + } + } + } + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != int32(' ') { + z = z + 1 + } + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + } + } +} + +// C documentation +// +// /* +// ** An SQL user-function registered to do the work of an DETACH statement. The +// ** three arguments to the function come directly from a detach statement: +// ** +// ** DETACH DATABASE x +// ** +// ** SELECT sqlite_detach(x) +// */ +func _detachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var db, pDb, pEntry, pTrig, zName uintptr + var i int32 + var _ /* zErr at bp+0 */ [128]uint8 + _, _, _, _, _, _ = db, i, pDb, pEntry, pTrig, zName + zName = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + db = Xsqlite3_context_db_handle(tls, context) + pDb = uintptr(0) + _ = NotUsed + if zName == uintptr(0) { + zName = __ccgo_ts + 1704 + } + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpBt == uintptr(0) { + goto _1 + } + if _sqlite3DbIsNamed(tls, db, i, zName) != 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i >= (*Tsqlite3)(unsafe.Pointer(db)).FnDb { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13442, libc.VaList(bp+136, zName)) + goto detach_error + } + if i < int32(2) { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13463, libc.VaList(bp+136, zName)) + goto detach_error + } + if _sqlite3BtreeTxnState(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) != SQLITE_TXN_NONE || _sqlite3BtreeIsInBackup(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) != 0 { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13489, libc.VaList(bp+136, zName)) + goto detach_error + } + /* If any TEMP triggers reference the schema being detached, move those + ** triggers to reference the TEMP schema itself. */ + pEntry = (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 56)).Ffirst + for pEntry != 0 { + pTrig = (*THashElem)(unsafe.Pointer(pEntry)).Fdata + if (*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema == (*TDb)(unsafe.Pointer(pDb)).FpSchema { + (*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema = (*TTrigger)(unsafe.Pointer(pTrig)).FpSchema + } + pEntry = (*THashElem)(unsafe.Pointer(pEntry)).Fnext + } + _sqlite3BtreeClose(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + (*TDb)(unsafe.Pointer(pDb)).FpBt = uintptr(0) + (*TDb)(unsafe.Pointer(pDb)).FpSchema = uintptr(0) + _sqlite3CollapseDatabaseArray(tls, db) + return + goto detach_error +detach_error: + ; + Xsqlite3_result_error(tls, context, bp, -int32(1)) +} + +// C documentation +// +// /* +// ** The input to this routine is an WhereTerm structure with only the +// ** "pExpr" field filled in. The job of this routine is to analyze the +// ** subexpression and populate all the other fields of the WhereTerm +// ** structure. +// ** +// ** If the expression is of the form " X" it gets commuted +// ** to the standard form of "X ". +// ** +// ** If the expression is of the form "X Y" where both X and Y are +// ** columns, then the original expression is unchanged and a new virtual +// ** term of the form "Y X" is added to the WHERE clause and +// ** analyzed separately. The original term is marked with TERM_COPIED +// ** and the new term is marked with TERM_DYNAMIC (because it's pExpr +// ** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it +// ** is a commuted copy of a prior term.) The original term has nChild=1 +// ** and the copy has idxParent set to the index of the original term. +// */ +func _exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var c, v12 uint8 + var db, pC, pDup, pExpr, pLeft, pLeft1, pLeft2, pLeft3, pList, pMaskSet, pNew, pNew1, pNewExpr, pNewExpr1, pNewExpr11, pNewExpr2, pNewExpr21, pNewTerm, pNewTerm1, pParse, pRight, pRight1, pStr2, pTerm, pWInfo, t, zCollSeqName, v1 uintptr + var eExtraOp, opMask, wtFlags Tu16 + var extraRight, prereqAll, prereqColumn, prereqExpr, prereqLeft, x TBitmask + var i, i1, i2, i3, idxNew, idxNew1, idxNew11, idxNew2, idxNew21, idxNew3, idxNew4, idxNew5, nLeft, op, res, v2 int32 + var v15 bool + var _ /* aiCurCol at bp+24 */ [2]int32 + var _ /* eOp2 at bp+16 */ uint8 + var _ /* isComplete at bp+8 */ int32 + var _ /* noCase at bp+12 */ int32 + var _ /* pLeft at bp+40 */ uintptr + var _ /* pRight at bp+32 */ uintptr + var _ /* pStr1 at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, db, eExtraOp, extraRight, i, i1, i2, i3, idxNew, idxNew1, idxNew11, idxNew2, idxNew21, idxNew3, idxNew4, idxNew5, nLeft, op, opMask, pC, pDup, pExpr, pLeft, pLeft1, pLeft2, pLeft3, pList, pMaskSet, pNew, pNew1, pNewExpr, pNewExpr1, pNewExpr11, pNewExpr2, pNewExpr21, pNewTerm, pNewTerm1, pParse, pRight, pRight1, pStr2, pTerm, pWInfo, prereqAll, prereqColumn, prereqExpr, prereqLeft, res, t, wtFlags, x, zCollSeqName, v1, v12, v15, v2 + pWInfo = (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo /* Prerequisites of pExpr */ + extraRight = uint64(0) /* Extra dependencies on LEFT JOIN */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* RHS of LIKE/GLOB operator */ + **(**int32)(__ccgo_up(bp + 8)) = 0 /* RHS of LIKE/GLOB ends with wildcard */ + **(**int32)(__ccgo_up(bp + 12)) = 0 /* Top-level operator. pExpr->op */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parsing context */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + **(**uint8)(__ccgo_up(bp + 16)) = uint8(0) /* Number of elements on left side vector */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + pMaskSet = pWInfo + 592 + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + /* Because malloc() has not failed */ + (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 0 + prereqLeft = _sqlite3WhereExprUsage(tls, pMaskSet, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + if op == int32(TK_IN) { + if _sqlite3ExprCheckIN(tls, pParse, pExpr) != 0 { + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } else { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _sqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } + prereqAll = prereqLeft | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight + } else { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _sqlite3WhereExprUsage(tls, pMaskSet, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft == uintptr(0) || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_xIsSelect)|libc.Int32FromInt32(EP_IfNullRow)) != uint32(0) || *(*uintptr)(unsafe.Pointer(pExpr + 32)) != uintptr(0) { + prereqAll = _sqlite3WhereExprUsageNN(tls, pMaskSet, pExpr) + } else { + prereqAll = prereqLeft | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight + } + } + if (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect != 0 { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_VARSELECT)) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + x = _sqlite3WhereGetMask(tls, pMaskSet, *(*int32)(unsafe.Pointer(pExpr + 52))) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) { + prereqAll = prereqAll | x + extraRight = x - uint64(1) /* ON clause terms may not be used with an index + ** on left table of a LEFT JOIN. Ticket #3015 */ + } else { + if prereqAll>>libc.Int32FromInt32(1) >= x { + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) + } + } + } + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = prereqAll + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = -int32(1) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FiParent = -int32(1) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(0) + if _allowedOp(tls, op) != 0 { + pLeft = _sqlite3ExprSkipCollate(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + pRight = _sqlite3ExprSkipCollate(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&prereqLeft == uint64(0) { + v2 = int32(WO_ALL) + } else { + v2 = int32(WO_EQUIV) + } + opMask = libc.Uint16FromInt32(v2) + if (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField > 0 { + pLeft = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 32)) + 8 + uintptr((*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField-int32(1))*32))).FpExpr + } + if _exprMightBeIndexed(tls, pSrc, bp+24, pLeft, op) != 0 { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = (**(**[2]int32)(__ccgo_up(bp + 24)))[0] + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn = (**(**[2]int32)(__ccgo_up(bp + 24)))[int32(1)] + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = libc.Uint16FromInt32(libc.Int32FromUint16(_operatorMask(tls, op)) & libc.Int32FromUint16(opMask)) + } + if op == int32(TK_IS) { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_IS)) + } + if pRight != 0 && _exprMightBeIndexed(tls, pSrc, bp+24, pRight, op) != 0 && !((*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != libc.Uint32FromInt32(0)) { + eExtraOp = uint16(0) /* Extra bits for pNew->eOperator */ + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor >= 0 { + pDup = _sqlite3ExprDup(tls, db, pExpr, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pDup) + return + } + idxNew = _whereClauseInsert(tls, pWC, pDup, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + if idxNew == 0 { + return + } + pNew = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*56 + _markTermAsChild(tls, pWC, idxNew, idxTerm) + if op == int32(TK_IS) { + v1 = pNew + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_IS)) + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + if _termIsEquivalence(tls, pParse, pDup, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList) != 0 { + v1 = pTerm + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(WO_EQUIV)) + eExtraOp = uint16(WO_EQUIV) + } + } else { + pDup = pExpr + pNew = pTerm + } + v1 = pNew + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16(_exprCommute(tls, pParse, pDup))) + (*TWhereTerm)(unsafe.Pointer(pNew)).FleftCursor = (**(**[2]int32)(__ccgo_up(bp + 24)))[0] + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNew + 32))).FleftColumn = (**(**[2]int32)(__ccgo_up(bp + 24)))[int32(1)] + (*TWhereTerm)(unsafe.Pointer(pNew)).FprereqRight = prereqLeft | extraRight + (*TWhereTerm)(unsafe.Pointer(pNew)).FprereqAll = prereqAll + (*TWhereTerm)(unsafe.Pointer(pNew)).FeOperator = libc.Uint16FromInt32((libc.Int32FromUint16(_operatorMask(tls, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pDup)).Fop))) + libc.Int32FromUint16(eExtraOp)) & libc.Int32FromUint16(opMask)) + } else { + if op == int32(TK_ISNULL) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) && 0 == _sqlite3ExprCanBeNull(tls, pLeft) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_TRUEFALSE) /* See tag-20230504-1 */ + *(*uintptr)(unsafe.Pointer(pExpr + 8)) = __ccgo_ts + 8183 + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_IsFalse)) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = uint64(0) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(0) + } + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_BETWEEN) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + i = 0 + for { + if !(i < int32(2)) { + break + } + pNewExpr = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8(_ops[i]), _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, 0), _sqlite3ExprDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr, 0)) + _transferJoinMarkings(tls, pNewExpr, pExpr) + idxNew1 = _whereClauseInsert(tls, pWC, pNewExpr, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + _exprAnalyze(tls, pSrc, pWC, idxNew1) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + _markTermAsChild(tls, pWC, idxNew1, idxTerm) + goto _8 + _8: + ; + i = i + 1 + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_OR) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != libc.Uint32FromInt32(0)) { + _exprAnalyzeOrTerm(tls, pSrc, pWC, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == int32(TK_COLUMN) && int32((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).FiColumn) >= 0 && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) { + pLeft1 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pNewExpr1 = _sqlite3PExpr(tls, pParse, int32(TK_GT), _sqlite3ExprDup(tls, db, pLeft1, 0), _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0)) + idxNew2 = _whereClauseInsert(tls, pWC, pNewExpr1, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC)|libc.Int32FromInt32(TERM_VNULL))) + if idxNew2 != 0 { + pNewTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew2)*56 + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = uint64(0) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*TExpr)(unsafe.Pointer(pLeft1)).FiTable + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNewTerm + 32))).FleftColumn = int32((*TExpr)(unsafe.Pointer(pLeft1)).FiColumn) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ) << (libc.Int32FromInt32(TK_GT) - libc.Int32FromInt32(TK_EQ))) + _markTermAsChild(tls, pWC, idxNew2, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll + } + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_FUNCTION) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) && _isLikeOrGlob(tls, pParse, pExpr, bp, bp+8, bp+12) != 0 { /* Name of collating sequence */ + wtFlags = libc.Uint16FromInt32(libc.Int32FromInt32(TERM_LIKEOPT) | libc.Int32FromInt32(TERM_VIRTUAL) | libc.Int32FromInt32(TERM_DYNAMIC)) + pLeft2 = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr + pStr2 = _sqlite3ExprDup(tls, db, **(**uintptr)(__ccgo_up(bp)), 0) + /* Convert the lower bound to upper-case and the upper bound to + ** lower-case (upper-case is less than lower-case in ASCII) so that + ** the range constraints also work for BLOBs + */ + if **(**int32)(__ccgo_up(bp + 12)) != 0 && !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_LIKE)) + i1 = 0 + for { + v12 = **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 8)) + uintptr(i1))) + c = v12 + if !(libc.Int32FromUint8(v12) != 0) { + break + } + **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 8)) + uintptr(i1))) = libc.Uint8FromInt32(libc.Int32FromUint8(c) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[c]) & libc.Int32FromInt32(0x20))) + **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pStr2 + 8)) + uintptr(i1))) = _sqlite3UpperToLower[c] + goto _11 + _11: + ; + i1 = i1 + 1 + } + } + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { /* Last character before the first wildcard */ + pC = *(*uintptr)(unsafe.Pointer(pStr2 + 8)) + uintptr(_sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pStr2 + 8)))-int32(1)) + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + /* The point is to increment the last character before the first + ** wildcard. But if we increment '@', that will push it into the + ** alphabetic range where case conversions will mess up the + ** inequality. To avoid this, make sure to also run the full + ** LIKE on all candidate expressions by clearing the isComplete flag + */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pC))) == libc.Int32FromUint8('A')-libc.Int32FromInt32(1) { + **(**int32)(__ccgo_up(bp + 8)) = 0 + } + **(**Tu8)(__ccgo_up(pC)) = _sqlite3UpperToLower[**(**Tu8)(__ccgo_up(pC))] + } + /* Increment the value of the last utf8 character in the prefix. */ + for libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pC))) == int32(0xBF) && pC > *(*uintptr)(unsafe.Pointer(pStr2 + 8)) { + **(**Tu8)(__ccgo_up(pC)) = uint8(0x80) + pC = pC - 1 + } + /* isLikeOrGlob() guarantees this */ + **(**Tu8)(__ccgo_up(pC)) = **(**Tu8)(__ccgo_up(pC)) + 1 + } + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + v1 = __ccgo_ts + 23876 + } else { + v1 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + zCollSeqName = v1 + pNewExpr11 = _sqlite3ExprDup(tls, db, pLeft2, 0) + pNewExpr11 = _sqlite3PExpr(tls, pParse, int32(TK_GE), _sqlite3ExprAddCollateString(tls, pParse, pNewExpr11, zCollSeqName), **(**uintptr)(__ccgo_up(bp))) + _transferJoinMarkings(tls, pNewExpr11, pExpr) + idxNew11 = _whereClauseInsert(tls, pWC, pNewExpr11, wtFlags) + pNewExpr21 = _sqlite3ExprDup(tls, db, pLeft2, 0) + pNewExpr21 = _sqlite3PExpr(tls, pParse, int32(TK_LT), _sqlite3ExprAddCollateString(tls, pParse, pNewExpr21, zCollSeqName), pStr2) + _transferJoinMarkings(tls, pNewExpr21, pExpr) + idxNew21 = _whereClauseInsert(tls, pWC, pNewExpr21, wtFlags) + _exprAnalyze(tls, pSrc, pWC, idxNew11) + _exprAnalyze(tls, pSrc, pWC, idxNew21) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + _markTermAsChild(tls, pWC, idxNew11, idxTerm) + _markTermAsChild(tls, pWC, idxNew21, idxTerm) + } + } + } + } + } + } + /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create + ** new terms for each component comparison - "a = ?" and "b = ?". The + ** new terms completely replace the original vector comparison, which is + ** no longer used. + ** + ** This is only required if at least one side of the comparison operation + ** is not a sub-select. + ** + ** tag-20220128a + */ + if v15 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_EQ) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IS); v15 { + v2 = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + nLeft = v2 + } + if v15 && v2 > int32(1) && _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) == nLeft && ((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags&uint32(EP_xIsSelect) == uint32(0) || (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpRight)).Fflags&uint32(EP_xIsSelect) == uint32(0)) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + i2 = 0 + for { + if !(i2 < nLeft) { + break + } + pLeft3 = _sqlite3ExprForVectorField(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, i2, nLeft) + pRight1 = _sqlite3ExprForVectorField(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, i2, nLeft) + pNew1 = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop), pLeft3, pRight1) + _transferJoinMarkings(tls, pNew1, pExpr) + idxNew3 = _whereClauseInsert(tls, pWC, pNew1, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_DYNAMIC)|libc.Int32FromInt32(TERM_SLICE))) + _exprAnalyze(tls, pSrc, pWC, idxNew3) + goto _16 + _16: + ; + i2 = i2 + 1 + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | (libc.Int32FromInt32(TERM_CODED) | libc.Int32FromInt32(TERM_VIRTUAL))) /* Disable the original */ + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(WO_ROWVAL) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IN) && (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField == 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == int32(TK_VECTOR) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && ((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpPrior == uintptr(0) || (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselFlags&uint32(SF_Values) != 0) && (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpWin == uintptr(0) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + i3 = 0 + for { + if !(i3 < _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft)) { + break + } + idxNew4 = _whereClauseInsert(tls, pWC, pExpr, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_SLICE))) + *(*int32)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew4)*56 + 32 + 4)) = i3 + int32(1) + _exprAnalyze(tls, pSrc, pWC, idxNew4) + _markTermAsChild(tls, pWC, idxNew4, idxTerm) + goto _18 + _18: + ; + i3 = i3 + 1 + } + } else { + if libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + res = _isAuxiliaryVtabOperator(tls, db, pExpr, bp+16, bp+40, bp+32) + for { + v2 = res + res = res - 1 + if !(v2 > 0) { + break + } + prereqExpr = _sqlite3WhereExprUsage(tls, pMaskSet, **(**uintptr)(__ccgo_up(bp + 32))) + prereqColumn = _sqlite3WhereExprUsage(tls, pMaskSet, **(**uintptr)(__ccgo_up(bp + 40))) + if prereqExpr&prereqColumn == uint64(0) { + pNewExpr2 = _sqlite3PExpr(tls, pParse, int32(TK_MATCH), uintptr(0), _sqlite3ExprDup(tls, db, **(**uintptr)(__ccgo_up(bp + 32)), 0)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) && pNewExpr2 != 0 { + **(**Tu32)(__ccgo_up(pNewExpr2 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) + *(*int32)(unsafe.Pointer(pNewExpr2 + 52)) = *(*int32)(unsafe.Pointer(pExpr + 52)) + } + idxNew5 = _whereClauseInsert(tls, pWC, pNewExpr2, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + pNewTerm1 = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew5)*56 + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FprereqRight = prereqExpr | extraRight + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FleftCursor = (*TExpr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 40)))).FiTable + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNewTerm1 + 32))).FleftColumn = int32((*TExpr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 40)))).FiColumn) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FeOperator = uint16(WO_AUX) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FeMatchOp = **(**uint8)(__ccgo_up(bp + 16)) + _markTermAsChild(tls, pWC, idxNew5, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FprereqAll = (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll + } + t = **(**uintptr)(__ccgo_up(bp + 40)) + **(**uintptr)(__ccgo_up(bp + 40)) = **(**uintptr)(__ccgo_up(bp + 32)) + **(**uintptr)(__ccgo_up(bp + 32)) = t + } + } + } + } + /* Prevent ON clause terms of a LEFT JOIN from being used to drive + ** an index for tables to the left of the join. + */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + **(**TBitmask)(__ccgo_up(pTerm + 40)) |= extraRight +} + +// C documentation +// +// /* +// ** Generate code to implement special SQL functions that are implemented +// ** in-line rather than by using the usual callbacks. +// */ +func _exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncId int32, target int32) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var aff uint8 + var azAff [6]uintptr + var endCoalesce, i, nFarg int32 + var pA1, pArg, v, v2 uintptr + var _ /* caseExpr at bp+0 */ TExpr + _, _, _, _, _, _, _, _, _ = aff, azAff, endCoalesce, i, nFarg, pA1, pArg, v, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + nFarg = (*TExprList)(unsafe.Pointer(pFarg)).FnExpr + /* All in-line functions have at least one argument */ + switch iFuncId { + case INLINEFUNC_coalesce: + /* Attempt a direct implementation of the built-in COALESCE() and + ** IFNULL() functions. This avoids unnecessary evaluation of + ** arguments past the first non-NULL argument. + */ + endCoalesce = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, target) + i = int32(1) + for { + if !(i < nFarg) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), target, endCoalesce) + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + uintptr(i)*32))).FpExpr, target) + goto _1 + _1: + ; + i = i + 1 + } + _setDoNotMergeFlagOnCopy(tls, v) + _sqlite3VdbeResolveLabel(tls, v, endCoalesce) + case int32(INLINEFUNC_iif): + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_CASE) + *(*uintptr)(unsafe.Pointer(bp + 32)) = pFarg + return _sqlite3ExprCodeTarget(tls, pParse, bp, target) + case int32(INLINEFUNC_sqlite_offset): + pArg = (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pArg)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pArg)).FiTable >= 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Offset), (*TExpr)(unsafe.Pointer(pArg)).FiTable, int32((*TExpr)(unsafe.Pointer(pArg)).FiColumn), target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + default: + /* The UNLIKELY() function is a no-op. The result is the value + ** of the first argument. + */ + target = _sqlite3ExprCodeTarget(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, target) + break + /*********************************************************************** + ** Test-only SQL functions that are only usable if enabled + ** via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS + */ + fallthrough + case int32(INLINEFUNC_expr_compare): + /* Compare two expressions using sqlite3ExprCompare() */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr, -int32(1)), target) + case int32(INLINEFUNC_expr_implies_expr): + /* Compare two expressions using sqlite3ExprImpliesExpr() */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprImpliesExpr(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr, -int32(1)), target) + case int32(INLINEFUNC_implies_nonnull_row): + pA1 = (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA1)).Fop) == int32(TK_COLUMN) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprImpliesNonNullRow(tls, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*TExpr)(unsafe.Pointer(pA1)).FiTable, int32(1)), target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + case int32(INLINEFUNC_affinity): + /* The AFFINITY() function evaluates to a string that describes + ** the type affinity of the argument. This is used for testing of + ** the SQLite type logic. + */ + azAff = [6]uintptr{ + 0: __ccgo_ts + 8482, + 1: __ccgo_ts + 8487, + 2: __ccgo_ts + 8492, + 3: __ccgo_ts + 6492, + 4: __ccgo_ts + 6487, + 5: __ccgo_ts + 8500, + } + aff = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr) + if libc.Int32FromUint8(aff) <= int32(SQLITE_AFF_NONE) { + v2 = __ccgo_ts + 8508 + } else { + v2 = azAff[libc.Int32FromUint8(aff)-int32(SQLITE_AFF_BLOB)] + } + _sqlite3VdbeLoadString(tls, v, target, v2) + break + } + return target +} + +// C documentation +// +// /* +// ** This function is called by unixOpen() to determine the unix permissions +// ** to create new files with. If no error occurs, then SQLITE_OK is returned +// ** and a value suitable for passing as the third argument to open(2) is +// ** written to *pMode. If an IO error occurs, an SQLite error code is +// ** returned and the value of *pMode is not modified. +// ** +// ** In most cases, this routine sets *pMode to 0, which will become +// ** an indication to robust_open() to create the file using +// ** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask. +// ** But if the file being opened is a WAL or regular journal file, then +// ** this function queries the file-system for the permissions on the +// ** corresponding database file and sets *pMode to this value. Whenever +// ** possible, WAL and journal files are created using the same permissions +// ** as the associated database file. +// ** +// ** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the +// ** original filename is unavailable. But 8_3_NAMES is only used for +// ** FAT filesystems and permissions do not matter there, so just use +// ** the default permissions. In 8_3_NAMES mode, leave *pMode set to zero. +// */ +func _findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr, pUid uintptr, pGid uintptr) (r int32) { + bp := tls.Alloc(528) + defer tls.Free(528) + var nDb, rc int32 + var z uintptr + var _ /* zDb at bp+0 */ [513]uint8 + _, _, _ = nDb, rc, z + rc = SQLITE_OK /* Return Code */ + **(**Tmode_t)(__ccgo_up(pMode)) = uint32(0) + **(**Tuid_t)(__ccgo_up(pUid)) = uint32(0) + **(**Tgid_t)(__ccgo_up(pGid)) = uint32(0) + if flags&(libc.Int32FromInt32(SQLITE_OPEN_WAL)|libc.Int32FromInt32(SQLITE_OPEN_MAIN_JOURNAL)) != 0 { /* Number of valid bytes in zDb */ + /* zPath is a path to a WAL or journal file. The following block derives + ** the path to the associated database file from zPath. This block handles + ** the following naming conventions: + ** + ** "-journal" + ** "-wal" + ** "-journalNN" + ** "-walNN" + ** + ** where NN is a decimal number. The NN naming schemes are + ** used by the test_multiplex.c module. + ** + ** In normal operation, the journal file name will always contain + ** a '-' character. However in 8+3 filename mode, or if a corrupt + ** rollback journal specifies a super-journal with a goofy name, then + ** the '-' might be missing or the '-' might be the first character in + ** the filename. In that case, just return SQLITE_OK with *pMode==0. + */ + nDb = _sqlite3Strlen30(tls, zPath) - int32(1) + for nDb > 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(nDb)))) != int32('.') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(nDb)))) == int32('-') { + libc.Xmemcpy(tls, bp, zPath, libc.Uint64FromInt32(nDb)) + (**(**[513]uint8)(__ccgo_up(bp)))[nDb] = uint8('\000') + rc = _getFileMode(tls, bp, pMode, pUid, pGid) + break + } + nDb = nDb - 1 + } + } else { + if flags&int32(SQLITE_OPEN_DELETEONCLOSE) != 0 { + **(**Tmode_t)(__ccgo_up(pMode)) = uint32(0600) + } else { + if flags&int32(SQLITE_OPEN_URI) != 0 { + /* If this is a main database file and the file was opened using a URI + ** filename, check for the "modeof" parameter. If present, interpret + ** its value as a filename and try to copy the mode, uid and gid from + ** that file. */ + z = Xsqlite3_uri_parameter(tls, zPath, __ccgo_ts+4062) + if z != 0 { + rc = _getFileMode(tls, z, pMode, pUid, pGid) + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** This function is called when an UPDATE or DELETE operation is being +// ** compiled on table pTab, which is the parent table of foreign-key pFKey. +// ** If the current operation is an UPDATE, then the pChanges parameter is +// ** passed a pointer to the list of columns being modified. If it is a +// ** DELETE, pChanges is passed a NULL pointer. +// ** +// ** It returns a pointer to a Trigger structure containing a trigger +// ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. +// ** If the action is "NO ACTION" then a NULL pointer is returned (these actions +// ** require no special handling by the triggers sub-system, code for them is +// ** created by fkScanChildren()). +// ** +// ** For example, if pFKey is the foreign key and pTab is table "p" in +// ** the following schema: +// ** +// ** CREATE TABLE p(pk PRIMARY KEY); +// ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE); +// ** +// ** then the returned trigger structure is equivalent to: +// ** +// ** CREATE TRIGGER ... DELETE ON p BEGIN +// ** DELETE FROM c WHERE ck = old.pk; +// ** END; +// ** +// ** The returned pointer is cached as part of the foreign key object. It +// ** is eventually freed along with the rest of the foreign key object by +// ** sqlite3FkDelete(). +// */ +func _fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, pChanges uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var action, i, iAction, iFromCol, nFrom, v2 int32 + var db, pCol, pDflt, pEq, pItem, pItem1, pList, pNew, pRaise, pSelect, pSrc, pStep, pTrigger, pWhen, pWhere, zFrom, v4 uintptr + var _ /* aiCol at bp+8 */ uintptr + var _ /* pIdx at bp+0 */ uintptr + var _ /* tFromCol at bp+48 */ TToken + var _ /* tNew at bp+32 */ TToken + var _ /* tOld at bp+16 */ TToken + var _ /* tToCol at bp+64 */ TToken + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = action, db, i, iAction, iFromCol, nFrom, pCol, pDflt, pEq, pItem, pItem1, pList, pNew, pRaise, pSelect, pSrc, pStep, pTrigger, pWhen, pWhere, zFrom, v2, v4 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Trigger definition to return */ + iAction = libc.BoolInt32(pChanges != uintptr(0)) /* 1 for UPDATE, 0 for DELETE */ + action = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pFKey + 45 + uintptr(iAction)))) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008))< parent key cols */ + pStep = uintptr(0) /* First (only) step of trigger program */ + pWhere = uintptr(0) /* WHERE clause of trigger step */ + pList = uintptr(0) /* Changes list if ON UPDATE CASCADE */ + pSelect = uintptr(0) /* Iterator variable */ + pWhen = uintptr(0) /* WHEN clause for the trigger */ + if _sqlite3FkLocateIndex(tls, pParse, pTab, pFKey, bp, bp+8) != 0 { + return uintptr(0) + } + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + **(**TToken)(__ccgo_up(bp + 16)) = TToken{ + Fz: __ccgo_ts + 6827, + Fn: uint32(3), + } /* Literal "old" token */ + **(**TToken)(__ccgo_up(bp + 32)) = TToken{ + Fz: __ccgo_ts + 6823, + Fn: uint32(3), + } /* tFromCol = OLD.tToCol */ + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v2 = **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + uintptr(i)*4)) + } else { + v2 = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom + } + iFromCol = v2 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v2 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaiColumn + uintptr(i)*2))) + } else { + v2 = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + _sqlite3TokenInit(tls, bp+64, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(v2)*16))).FzCnName) + _sqlite3TokenInit(tls, bp+48, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16))).FzCnName) + /* Create the expression "OLD.zToCol = zFromCol". It is important + ** that the "OLD.zToCol" term is on the LHS of the = operator, so + ** that the affinity and collation sequence associated with the + ** parent table are used for the comparison. */ + pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+16, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+48, 0)) + pWhere = _sqlite3ExprAnd(tls, pParse, pWhere, pEq) + /* For ON UPDATE, construct the next term of the WHEN clause. + ** The final WHEN clause will be like this: + ** + ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) + */ + if pChanges != 0 { + pEq = _sqlite3PExpr(tls, pParse, int32(TK_IS), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+16, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+32, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0))) + pWhen = _sqlite3ExprAnd(tls, pParse, pWhen, pEq) + } + if action != int32(OE_Restrict) && (action != int32(OE_Cascade) || pChanges != 0) { + if action == int32(OE_Cascade) { + pNew = _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+32, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)) + } else { + if action == int32(OE_SetDflt) { + pCol = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + pDflt = uintptr(0) + } else { + pDflt = _sqlite3ColumnExpr(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, pCol) + } + if pDflt != 0 { + pNew = _sqlite3ExprDup(tls, db, pDflt, 0) + } else { + pNew = _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0) + } + } else { + pNew = _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0) + } + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, pNew) + _sqlite3ExprListSetName(tls, pParse, pList, bp+48, 0) + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 8))) + zFrom = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName + nFrom = _sqlite3Strlen30(tls, zFrom) + if action == int32(OE_Restrict) { + pRaise = _sqlite3Expr(tls, db, int32(TK_STRING), __ccgo_ts+5392) + pRaise = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), pRaise, uintptr(0)) + if pRaise != 0 { + (*TExpr)(unsafe.Pointer(pRaise)).FaffExpr = uint8(OE_Abort) + } + pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + if pSrc != 0 { + pItem = pSrc + 8 + (*TSrcItem)(unsafe.Pointer(pItem)).FzName = _sqlite3DbStrDup(tls, db, zFrom) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 16, 0x10000) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = (*TTable)(unsafe.Pointer(pTab)).FpSchema + } + pSelect = _sqlite3SelectNew(tls, pParse, _sqlite3ExprListAppend(tls, pParse, uintptr(0), pRaise), pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + pWhere = uintptr(0) + } + /* Disable lookaside memory allocation */ + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + pTrigger = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt64(72)+libc.Uint64FromInt64(88))) + if pTrigger != 0 { + v4 = pTrigger + 1*72 + (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list = v4 + pStep = v4 + (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + pItem1 = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 + (*TSrcItem)(unsafe.Pointer(pItem1)).FzName = _sqlite3DbStrNDup(tls, db, zFrom, libc.Uint64FromInt32(nFrom)) + *(*uintptr)(unsafe.Pointer(pItem1 + 72)) = (*TTable)(unsafe.Pointer(pTab)).FpSchema + libc.SetBitFieldPtr32Uint32(pItem1+24+4, libc.Uint32FromInt32(1), 16, 0x10000) + } + (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere = _sqlite3ExprDup(tls, db, pWhere, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList = _sqlite3ExprListDup(tls, db, pList, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect = _sqlite3SelectDup(tls, db, pSelect, int32(EXPRDUP_REDUCE)) + if pWhen != 0 { + pWhen = _sqlite3PExpr(tls, pParse, int32(TK_NOT), pWhen, uintptr(0)) + (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen = _sqlite3ExprDup(tls, db, pWhen, int32(EXPRDUP_REDUCE)) + } + } + /* Re-enable the lookaside buffer, if it was disabled earlier. */ + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v2 = 0 + } else { + v2 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v2) + _sqlite3ExprDelete(tls, db, pWhere) + _sqlite3ExprDelete(tls, db, pWhen) + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3SelectDelete(tls, db, pSelect) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == int32(1) { + _fkTriggerDelete(tls, db, pTrigger) + return uintptr(0) + } + switch action { + case int32(OE_Restrict): + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_SELECT) + case int32(OE_Cascade): + if !(pChanges != 0) { + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_DELETE) + break + } + fallthrough + default: + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_UPDATE) + } + (*TTriggerStep)(unsafe.Pointer(pStep)).FpTrig = pTrigger + (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + **(**uintptr)(__ccgo_up(pFKey + 48 + uintptr(iAction)*8)) = pTrigger + if pChanges != 0 { + v2 = int32(TK_UPDATE) + } else { + v2 = int32(TK_DELETE) + } + (*TTrigger)(unsafe.Pointer(pTrigger)).Fop = libc.Uint8FromInt32(v2) + } + return pTrigger +} + +// C documentation +// +// /* +// ** Implementation of the xBestIndex method for FTS5 tables. Within the +// ** WHERE constraint, it searches for the following: +// ** +// ** 1. A MATCH constraint against the table column. +// ** 2. A MATCH constraint against the "rank" column. +// ** 3. A MATCH constraint against some other column. +// ** 4. An == constraint against the rowid column. +// ** 5. A < or <= constraint against the rowid column. +// ** 6. A > or >= constraint against the rowid column. +// ** +// ** Within the ORDER BY, the following are supported: +// ** +// ** 5. ORDER BY rank [ASC|DESC] +// ** 6. ORDER BY rowid [ASC|DESC] +// ** +// ** Information for the xFilter call is passed via both the idxNum and +// ** idxStr variables. Specifically, idxNum is a bitmask of the following +// ** flags used to encode the ORDER BY clause: +// ** +// ** FTS5_BI_ORDER_RANK +// ** FTS5_BI_ORDER_ROWID +// ** FTS5_BI_ORDER_DESC +// ** +// ** idxStr is used to encode data from the WHERE clause. For each argument +// ** passed to the xFilter method, the following is appended to idxStr: +// ** +// ** Match against table column: "m" +// ** Match against rank column: "r" +// ** Match against other column: "M" +// ** LIKE against other column: "L" +// ** GLOB against other column: "G" +// ** Equality constraint against the rowid: "=" +// ** A < or <= against the rowid: "<" +// ** A > or >= against the rowid: ">" +// ** +// ** This function ensures that there is at most one "r" or "=". And that if +// ** there exists an "=" then there is no "<" or ">". +// ** +// ** If an unusable MATCH operator is present in the WHERE clause, then +// ** SQLITE_CONSTRAINT is returned. +// ** +// ** Costs are assigned as follows: +// ** +// ** a) If a MATCH operator is present, the cost depends on the other +// ** constraints also present. As follows: +// ** +// ** * No other constraints: cost=50000.0 +// ** * One rowid range constraint: cost=37500.0 +// ** * Both rowid range constraints: cost=30000.0 +// ** * An == rowid constraint: cost=25000.0 +// ** +// ** b) Otherwise, if there is no MATCH: +// ** +// ** * No other constraints: cost=3000000.0 +// ** * One rowid range constraints: cost=2250000.0 +// ** * Both rowid range constraint: cost=750000.0 +// ** * An == rowid constraint: cost=25.0 +// ** +// ** Costs are not modified by the ORDER BY clause. +// ** +// ** The ratios used in case (a) are based on informal results obtained from +// ** the tool/fts5cost.tcl script. The "MATCH and ==" combination has the +// ** cost set quite high because the query may be a prefix query. Unless +// ** there is a prefix index, prefix queries with rowid constraints are much +// ** more expensive than non-prefix queries with rowid constraints. +// ** +// ** The estimated rows returned is set to the cost/40. For simple queries, +// ** experimental results show that cost/4 might be about right. But for +// ** more complex queries that use multiple terms the number of rows might +// ** be far fewer than this. So we compromise and use cost/40. +// */ +func _fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bSeenEq, bSeenGt, bSeenLt, bSeenRank, i, iCol, iCons, iIdxStr, iSort, idxFlags, nCol, nSeenMatch, op, v2, v3 int32 + var idxStr, p, p1, pConfig, pTab uintptr + var nEstRows Ti64 + var v15 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bSeenEq, bSeenGt, bSeenLt, bSeenRank, i, iCol, iCons, iIdxStr, iSort, idxFlags, idxStr, nCol, nEstRows, nSeenMatch, op, p, p1, pConfig, pTab, v15, v2, v3 + pTab = pVTab + pConfig = (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig + nCol = (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + idxFlags = 0 + iIdxStr = 0 + iCons = 0 + bSeenEq = 0 + bSeenGt = 0 + bSeenLt = 0 + nSeenMatch = 0 + bSeenRank = 0 + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLock != 0 { + (*TFts5Table)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+39647, 0) + return int32(SQLITE_ERROR) + } + idxStr = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint)*int64(8)+int64(1))) + if idxStr == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FidxStr = idxStr + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FneedToFreeIdxStr = int32(1) + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12 + iCol = (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) && iCol >= nCol { + /* A MATCH operator or equivalent */ + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0 || iCol < 0 { + /* As there exists an unusable MATCH constraint this is an + ** unusable plan. Return SQLITE_CONSTRAINT. */ + **(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr))) = uint8(0) + return int32(SQLITE_CONSTRAINT) + } else { + if iCol == nCol+int32(1) { + if bSeenRank != 0 { + goto _1 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**uint8)(__ccgo_up(idxStr + uintptr(v2))) = uint8('r') + bSeenRank = int32(1) + } else { + nSeenMatch = nSeenMatch + 1 + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**uint8)(__ccgo_up(idxStr + uintptr(v2))) = uint8('M') + Xsqlite3_snprintf(tls, int32(6), idxStr+uintptr(iIdxStr), __ccgo_ts+5289, libc.VaList(bp+8, iCol)) + iIdxStr = iIdxStr + libc.Int32FromUint64(libc.Xstrlen(tls, idxStr+uintptr(iIdxStr))) + } + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + } + } else { + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 { + if iCol >= 0 && iCol < nCol && _fts5UsePatternMatch(tls, pConfig, p) != 0 { + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(FTS5_PATTERN_LIKE) { + v3 = int32('L') + } else { + v3 = int32('G') + } + **(**uint8)(__ccgo_up(idxStr + uintptr(v2))) = libc.Uint8FromInt32(v3) + Xsqlite3_snprintf(tls, int32(6), idxStr+uintptr(iIdxStr), __ccgo_ts+5289, libc.VaList(bp+8, iCol)) + idxStr = idxStr + uintptr(libc.Xstrlen(tls, idxStr+uintptr(iIdxStr))) + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + nSeenMatch = nSeenMatch + 1 + } else { + if bSeenEq == 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) && iCol < 0 { + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**uint8)(__ccgo_up(idxStr + uintptr(v2))) = uint8('=') + bSeenEq = int32(1) + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + } + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + if bSeenEq == 0 { + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint) { + break + } + p1 = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12 + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).FiColumn < 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).Fusable != 0 { + op = libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).Fop) + if op == int32(SQLITE_INDEX_CONSTRAINT_LT) || op == int32(SQLITE_INDEX_CONSTRAINT_LE) { + if bSeenLt != 0 { + goto _10 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**uint8)(__ccgo_up(idxStr + uintptr(v2))) = uint8('<') + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + bSeenLt = int32(1) + } else { + if op == int32(SQLITE_INDEX_CONSTRAINT_GT) || op == int32(SQLITE_INDEX_CONSTRAINT_GE) { + if bSeenGt != 0 { + goto _10 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**uint8)(__ccgo_up(idxStr + uintptr(v2))) = uint8('>') + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + bSeenGt = int32(1) + } + } + } + goto _10 + _10: + ; + i = i + 1 + } + } + **(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr))) = uint8('\000') + /* Set idxFlags flags for the ORDER BY clause + ** + ** Note that tokendata=1 tables cannot currently handle "ORDER BY rowid DESC". + */ + if (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == int32(1) { + iSort = (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).FiColumn + if iSort == (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol+int32(1) && nSeenMatch > 0 { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_RANK) + } else { + if iSort == -int32(1) && (!((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).Fdesc != 0) || !((*TFts5Config)(unsafe.Pointer(pConfig)).FbTokendata != 0)) { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_ROWID) + } + } + if idxFlags&(libc.Int32FromInt32(FTS5_BI_ORDER_RANK)|libc.Int32FromInt32(FTS5_BI_ORDER_ROWID)) != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = int32(1) + if (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).Fdesc != 0 { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_DESC) + } + } + } + /* Calculate the estimated cost based on the flags set in idxFlags. */ + if bSeenEq != 0 { + if nSeenMatch != 0 { + v15 = float64(25000) + } else { + v15 = float64(25) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = v15 + _fts5SetEstimatedRows(tls, pInfo, int64(1)) + _fts5SetUniqueFlag(tls, pInfo) + } else { + if nSeenMatch != 0 { + if bSeenLt != 0 && bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(50000) + } else { + if bSeenLt != 0 || bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(37500) + } else { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(50000) + } + } + nEstRows = int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / libc.Float64FromFloat64(40)) + i = int32(1) + for { + if !(i < nSeenMatch) { + break + } + **(**float64)(__ccgo_up(pInfo + 64)) *= float64(2.5) + nEstRows = nEstRows / int64(2) + goto _16 + _16: + ; + i = i + 1 + } + } else { + if bSeenLt != 0 && bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(750000) + } else { + if bSeenLt != 0 || bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(2.25e+06) + } else { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(3e+06) + } + } + nEstRows = int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / libc.Float64FromFloat64(4)) + } + _fts5SetEstimatedRows(tls, pInfo, nEstRows) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxFlags + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Parse a "special" CREATE VIRTUAL TABLE directive and update +// ** configuration object pConfig as appropriate. +// ** +// ** If successful, object pConfig is updated and SQLITE_OK returned. If +// ** an error occurs, an SQLite error code is returned and an error message +// ** may be left in *pzErr. It is the responsibility of the caller to +// ** eventually free any such error message using sqlite3_free(). +// */ +func _fts5ConfigParseSpecial(tls *libc.TLS, pConfig uintptr, zCmd uintptr, zArg uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var azArg, p, p1, p2, pSpace uintptr + var bFirst, nByte, nCmd, nPre, v2 int32 + var nArg Tsqlite3_int64 + var _ /* aDetail at bp+8 */ [4]TFts5Enum + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = azArg, bFirst, nArg, nByte, nCmd, nPre, p, p1, p2, pSpace, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + nCmd = libc.Int32FromUint64(libc.Xstrlen(tls, zCmd)) + if Xsqlite3_strnicmp(tls, __ccgo_ts+37338, zCmd, nCmd) == 0 { + nByte = libc.Int32FromUint64(libc.Uint64FromInt64(4) * libc.Uint64FromInt32(FTS5_MAX_PREFIX_INDEXES)) + bFirst = int32(1) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix == uintptr(0) { + (*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix = _sqlite3Fts5MallocZero(tls, bp, int64(nByte)) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + p = zArg + for int32(1) != 0 { + nPre = 0 + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32(' ') { + p = p + 1 + } + if bFirst == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32(',') { + p = p + 1 + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32(' ') { + p = p + 1 + } + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('\000') { + break + } + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) < int32('0') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) > int32('9') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37345, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + if (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix == int32(FTS5_MAX_PREFIX_INDEXES) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37376, libc.VaList(bp+80, int32(FTS5_MAX_PREFIX_INDEXES))) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) <= int32('9') && nPre < int32(1000) { + nPre = nPre*int32(10) + (libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) - int32('0')) + p = p + 1 + } + if nPre <= 0 || nPre >= int32(1000) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37409, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + **(**int32)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr((*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix)*4)) = nPre + (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix = (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix + 1 + bFirst = 0 + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37446, zCmd, nCmd) == 0 { + p1 = zArg + nArg = libc.Int64FromUint64(libc.Xstrlen(tls, zArg) + uint64(1)) + azArg = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(2))*libc.Uint64FromInt64(nArg))) + if azArg != 0 { + pSpace = azArg + uintptr(nArg)*8 + if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FazArg != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37455, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + nArg = 0 + for { + if !(p1 != 0 && **(**uint8)(__ccgo_up(p1)) != 0) { + break + } + p2 = _fts5ConfigSkipWhitespace(tls, p1) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p2))) == int32('\'') { + p1 = _fts5ConfigSkipLiteral(tls, p2) + } else { + p1 = _fts5ConfigSkipBareword(tls, p2) + } + if p1 != 0 { + libc.Xmemcpy(tls, pSpace, p2, libc.Uint64FromInt64(int64(p1)-int64(p2))) + **(**uintptr)(__ccgo_up(azArg + uintptr(nArg)*8)) = pSpace + _sqlite3Fts5Dequote(tls, pSpace) + pSpace = pSpace + uintptr(int64(p1)-int64(p2)+int64(1)) + p1 = _fts5ConfigSkipWhitespace(tls, p1) + } + goto _1 + _1: + ; + nArg = nArg + 1 + } + if p1 == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37488, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FazArg = azArg + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FnArg = int32(nArg) + azArg = uintptr(0) + } + } + } + Xsqlite3_free(tls, azArg) + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37522, zCmd, nCmd) == 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37530, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + if **(**uint8)(__ccgo_up(zArg)) != 0 { + (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent = int32(FTS5_CONTENT_EXTERNAL) + (*TFts5Config)(unsafe.Pointer(pConfig)).FzContent = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+37562, libc.VaList(bp+80, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, zArg)) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent = int32(FTS5_CONTENT_NONE) + } + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37568, zCmd, nCmd) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('1') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37587, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37630, zCmd, nCmd) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('1') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37587, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessUnindexed = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37652, zCmd, nCmd) == 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FzContentRowid != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37666, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FzContentRowid = _sqlite3Fts5Strndup(tls, bp, zArg, -int32(1)) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37704, zCmd, nCmd) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('1') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37715, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37750, zCmd, nCmd) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('1') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37757, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+5666, zCmd, nCmd) == 0 { + **(**[4]TFts5Enum)(__ccgo_up(bp + 8)) = [4]TFts5Enum{ + 0: { + FzName: __ccgo_ts + 8508, + FeVal: int32(FTS5_DETAIL_NONE), + }, + 1: { + FzName: __ccgo_ts + 19016, + }, + 2: { + FzName: __ccgo_ts + 37788, + FeVal: int32(FTS5_DETAIL_COLUMNS), + }, + 3: {}, + } + v2 = _fts5ConfigSetEnum(tls, bp+8, zArg, pConfig+116) + **(**int32)(__ccgo_up(bp)) = v2 + if v2 != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37796, 0) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37827, zCmd, nCmd) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('1') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37837, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbTokendata = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37871, libc.VaList(bp+80, nCmd, zCmd)) + return int32(SQLITE_ERROR) +} + +func _fts5ConfigSkipLiteral(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) { + case int32('n'): + fallthrough + case int32('N'): + if Xsqlite3_strnicmp(tls, __ccgo_ts+1690, p, int32(4)) == 0 { + p = p + 4 + } else { + p = uintptr(0) + } + case int32('x'): + fallthrough + case int32('X'): + p = p + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('\'') { + p = p + 1 + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) >= int32('a') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) <= int32('f') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) >= int32('A') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) <= int32('F') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) <= int32('9') { + p = p + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('\'') && 0 == (int64(p)-int64(pIn))%int64(2) { + p = p + 1 + } else { + p = uintptr(0) + } + } else { + p = uintptr(0) + } + case int32('\''): + p = p + 1 + for p != 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('\'') { + p = p + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32('\'') { + break + } + } + p = p + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == 0 { + p = uintptr(0) + } + } + default: + /* maybe a number */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('+') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('-') { + p = p + 1 + } + for _fts5_isdigit(tls, **(**uint8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + /* At this point, if the literal was an integer, the parse is + ** finished. Or, if it is a floating point value, it may continue + ** with either a decimal point or an 'E' character. */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('.') && _fts5_isdigit(tls, **(**uint8)(__ccgo_up(p + 1))) != 0 { + p = p + uintptr(2) + for _fts5_isdigit(tls, **(**uint8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + } + if p == pIn { + p = uintptr(0) + } + break + } + return p +} + +// C documentation +// +// /* +// ** Read the first token from the nul-terminated string at *pz. +// */ +func _fts5ExprGetToken(tls *libc.TLS, pParse uintptr, pz uintptr, pToken uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var tok int32 + var z, z2, z21 uintptr + _, _, _, _ = tok, z, z2, z21 + z = **(**uintptr)(__ccgo_up(pz)) + /* Skip past any whitespace */ + for _fts5ExprIsspace(tls, **(**uint8)(__ccgo_up(z))) != 0 { + z = z + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fp = z + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(1) + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) { + case int32('('): + tok = int32(FTS5_LP) + case int32(')'): + tok = int32(FTS5_RP) + case int32('{'): + tok = int32(FTS5_LCP) + case int32('}'): + tok = int32(FTS5_RCP) + case int32(':'): + tok = int32(FTS5_COLON) + case int32(','): + tok = int32(FTS5_COMMA) + case int32('+'): + tok = int32(FTS5_PLUS) + case int32('*'): + tok = int32(FTS5_STAR) + case int32('-'): + tok = int32(FTS5_MINUS) + case int32('^'): + tok = int32(FTS5_CARET) + case int32('\000'): + tok = FTS5_EOF + case int32('"'): + tok = int32(FTS5_STRING) + z2 = z + 1 + for { + if !(int32(1) != 0) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z2))) == int32('"') { + z2 = z2 + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z2))) != int32('"') { + break + } + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z2))) == int32('\000') { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38478, 0) + return FTS5_EOF + } + goto _1 + _1: + ; + z2 = z2 + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(int64(z2) - int64(z)) + default: + if _sqlite3Fts5IsBareword(tls, **(**uint8)(__ccgo_up(z))) == 0 { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38498, libc.VaList(bp+8, z)) + return FTS5_EOF + } + tok = int32(FTS5_STRING) + z21 = z + 1 + for { + if !(_sqlite3Fts5IsBareword(tls, **(**uint8)(__ccgo_up(z21))) != 0) { + break + } + goto _2 + _2: + ; + z21 = z21 + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(int64(z21) - int64(z)) + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(2) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+38529, uint64(2)) == 0 { + tok = int32(FTS5_OR) + } + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(3) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+38532, uint64(3)) == 0 { + tok = int32(FTS5_NOT) + } + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(3) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+32339, uint64(3)) == 0 { + tok = int32(FTS5_AND) + } + break + } + **(**uintptr)(__ccgo_up(pz)) = (*TFts5Token)(unsafe.Pointer(pToken)).Fp + uintptr((*TFts5Token)(unsafe.Pointer(pToken)).Fn) + return tok +} + +// C documentation +// +// /* +// ** This is the xFilter interface for the virtual table. See +// ** the virtual table xFilter method documentation for additional +// ** information. +// ** +// ** There are three possible query strategies: +// ** +// ** 1. Full-text search using a MATCH operator. +// ** 2. A by-rowid lookup. +// ** 3. A full-table scan. +// */ +func _fts5FilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, nVal int32, apVal uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bDesc, bGlob, bInternal, bOrderByRank, bPrefixInsttoken, i, iCol, iIdxStr, rc, v2, v3 int32 + var pConfig, pCsr, pRank, pRowidEq, pRowidGe, pRowidLe, pTab, pzErr, pzErrmsg, zText1, v6 uintptr + var _ /* bFreeAndReset at bp+16 */ int32 + var _ /* pExpr at bp+0 */ uintptr + var _ /* zText at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bDesc, bGlob, bInternal, bOrderByRank, bPrefixInsttoken, i, iCol, iIdxStr, pConfig, pCsr, pRank, pRowidEq, pRowidGe, pRowidLe, pTab, pzErr, pzErrmsg, rc, zText1, v2, v3, v6 + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + pCsr = pCursor + rc = SQLITE_OK /* True if ORDER BY rank */ + pRank = uintptr(0) /* rank MATCH ? expression (or NULL) */ + pRowidEq = uintptr(0) /* rowid = ? expression (or NULL) */ + pRowidLe = uintptr(0) /* rowid <= ? expression (or NULL) */ + pRowidGe = uintptr(0) /* Column on LHS of MATCH operator */ + pzErrmsg = (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg + bPrefixInsttoken = (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken + iIdxStr = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan != 0 { + _fts5FreeCursorComponents(tls, pCsr) + libc.Xmemset(tls, pCsr+32, 0, uint64(184)-libc.Uint64FromInt64(int64(pCsr+32)-int64(pCsr))) + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = pTab + 16 + /* Decode the arguments passed through to this function. */ + i = 0 + for { + if !(i < nVal) { + break + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(v2)))) { + case int32('r'): + pRank = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + case int32('M'): + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 16)) = 0 + bInternal = 0 + rc = _fts5ExtractExprText(tls, pConfig, **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)), bp+8, bp+16) + if rc != SQLITE_OK { + goto filter_out + } + if **(**uintptr)(__ccgo_up(bp + 8)) == uintptr(0) { + **(**uintptr)(__ccgo_up(bp + 8)) = __ccgo_ts + 1704 + } + if Xsqlite3_value_subtype(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8))) == uint32(FTS5_INSTTOKEN_SUBTYPE) { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken = int32(1) + } + iCol = 0 + for cond := true; cond; cond = libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) <= int32('9') { + iCol = iCol*int32(10) + (libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) - int32('0')) + iIdxStr = iIdxStr + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) == int32('*') { + /* The user has issued a query of the form "MATCH '*...'". This + ** indicates that the MATCH expression is not a full text query, + ** but a request for an internal parameter. */ + rc = _fts5SpecialMatch(tls, pTab, pCsr, **(**uintptr)(__ccgo_up(bp + 8))+1) + bInternal = int32(1) + } else { + pzErr = pTab + 16 + rc = _sqlite3Fts5ExprNew(tls, pConfig, 0, iCol, **(**uintptr)(__ccgo_up(bp + 8)), bp, pzErr) + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprAnd(tls, pCsr+64, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + if **(**int32)(__ccgo_up(bp + 16)) != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + _sqlite3Fts5ClearLocale(tls, pConfig) + } + if bInternal != 0 || rc != SQLITE_OK { + goto filter_out + } + case int32('L'): + fallthrough + case int32('G'): + bGlob = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr-int32(1))))) == int32('G')) + zText1 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8))) + iCol = 0 + for cond := true; cond; cond = libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) <= int32('9') { + iCol = iCol*int32(10) + (libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) - int32('0')) + iIdxStr = iIdxStr + 1 + } + if zText1 != 0 { + rc = _sqlite3Fts5ExprPattern(tls, pConfig, bGlob, iCol, zText1, bp) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprAnd(tls, pCsr+64, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + if rc != SQLITE_OK { + goto filter_out + } + case int32('='): + pRowidEq = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + case int32('<'): + pRowidLe = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + default: + pRowidGe = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + break + } + goto _1 + _1: + ; + i = i + 1 + } + if idxNum&int32(FTS5_BI_ORDER_RANK) != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + bOrderByRank = v2 + if idxNum&int32(FTS5_BI_ORDER_DESC) != 0 { + v3 = int32(1) + } else { + v3 = 0 + } + v2 = v3 + bDesc = v2 + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FbDesc = v2 + /* Set the cursor upper and lower rowid limits. Only some strategies + ** actually use them. This is ok, as the xBestIndex() method leaves the + ** sqlite3_index_constraint.omit flag clear for range constraints + ** on the rowid field. */ + if pRowidEq != 0 { + v6 = pRowidEq + pRowidGe = v6 + pRowidLe = v6 + } + if bDesc != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = _fts5GetRowidLimit(tls, pRowidLe, libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< ORDER BY rank" query (ePlan is + ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will + ** return results to the user for this query. The current cursor + ** (pCursor) is used to execute the query issued by function + ** fts5CursorFirstSorted() above. */ + if (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FbDesc != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiLastRowid + } else { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiLastRowid + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SOURCE) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FpExpr + rc = _fts5CursorFirst(tls, pTab, pCsr, bDesc) + } else { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr != 0 { + rc = _fts5CursorParseRank(tls, pConfig, pCsr, pRank) + if rc == SQLITE_OK { + if bOrderByRank != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SORTED_MATCH) + rc = _fts5CursorFirstSorted(tls, pTab, pCsr, bDesc) + } else { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_MATCH) + rc = _fts5CursorFirst(tls, pTab, pCsr, bDesc) + } + } + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FzContent == uintptr(0) { + _fts5SetVtabError(tls, pTab, __ccgo_ts+39848, libc.VaList(bp+32, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + rc = int32(SQLITE_ERROR) + } else { + /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup + ** by rowid (ePlan==FTS5_PLAN_ROWID). */ + if pRowidEq != 0 { + v2 = int32(FTS5_PLAN_ROWID) + } else { + v2 = int32(FTS5_PLAN_SCAN) + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = v2 + rc = _sqlite3Fts5StorageStmt(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, _fts5StmtType(tls, pCsr), pCsr+56, pTab+16) + if rc == SQLITE_OK { + if pRowidEq != uintptr(0) { + Xsqlite3_bind_value(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1), pRowidEq) + } else { + Xsqlite3_bind_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1), (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid) + Xsqlite3_bind_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(2), (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid) + } + rc = _fts5NextMethod(tls, pCursor) + } + } + } + } + goto filter_out +filter_out: + ; + _sqlite3Fts5ExprFree(tls, **(**uintptr)(__ccgo_up(bp))) + (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = pzErrmsg + (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken = bPrefixInsttoken + return rc +} + +func _fts5PorterStep1B(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('e'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42107, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+42111, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(2) + } + } else { + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42114, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_Vowel(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + ret = int32(1) + } + } + } + case int32('n'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42117, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_Vowel(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + ret = int32(1) + } + } + break + } + return ret +} + +/* +** GENERATED CODE ENDS HERE (mkportersteps.tcl) +*************************************************************************** +**************************************************************************/ + +func _fts5PorterStep1B2(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41921, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+41901, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + case int32('b'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41924, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+41927, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + case int32('i'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41931, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+41917, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + break + } + return ret +} + +func _fts5PorterStep2(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41934, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+41901, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(6) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41942, aBuf+uintptr(nBuf-int32(6)), uint64(6)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(6)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(6)), __ccgo_ts+41949, uint64(4)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(6) + int32(4) + } + } + } + case int32('c'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41954, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41850, uint64(4)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41959, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41845, uint64(4)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(4) + } + } + } + case int32('e'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41964, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41917, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + case int32('g'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41969, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+17165, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + case int32('l'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41974, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+41927, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(3) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41978, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41842, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41983, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41886, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41989, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+41993, uint64(1)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(1) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41995, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41909, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } + } + } + } + } + case int32('o'): + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42001, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+41917, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42009, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41901, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42015, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41901, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + } + } + case int32('s'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42020, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41842, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42026, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+41913, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42034, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+42042, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42046, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+41909, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } + } + } + } + case int32('t'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42054, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41842, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42060, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41913, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(6) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42066, aBuf+uintptr(nBuf-int32(6)), uint64(6)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(6)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(6)), __ccgo_ts+41927, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(6) + int32(3) + } + } + } + } + break + } + return ret +} + +func _fts5PorterStep3(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42073, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41858, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(2) + } + } + case int32('s'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42078, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + case int32('t'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42083, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41858, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42089, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41858, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } + } + case int32('u'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42042, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('v'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42095, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + } + } + case int32('z'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42101, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41842, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } + break + } + return ret +} + +func _fts5PorterStep4(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41842, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('c'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41845, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41850, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + } + case int32('e'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41855, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('i'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41858, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('l'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41861, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41866, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + } + case int32('n'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41871, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41875, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(5)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41881, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41886, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + } + } + } + case int32('o'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41890, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1_and_S_or_T(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41894, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + } + case int32('s'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41897, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('t'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41901, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41905, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + } + case int32('u'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41909, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('v'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41913, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('z'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41917, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + break + } + return ret +} + +// C documentation +// +// /* +// ** Allocate a trigram tokenizer. +// */ +func _fts5TriCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + var i, rc, v2 int32 + var pNew, zArg uintptr + _, _, _, _, _ = i, pNew, rc, zArg, v2 + rc = SQLITE_OK + pNew = uintptr(0) + _ = pUnused + if nArg%int32(2) != 0 { + rc = int32(SQLITE_ERROR) + } else { + pNew = Xsqlite3_malloc64(tls, uint64(8)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold = int32(1) + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam = 0 + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + zArg = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42121) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('1') || **(**uint8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) == int32('0')) + } + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41807) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('1') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('2') || **(**uint8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') { + v2 = int32(2) + } else { + v2 = 0 + } + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam = v2 + } + } else { + rc = int32(SQLITE_ERROR) + } + } + goto _1 + _1: + ; + i = i + int32(2) + } + if (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam != 0 && (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold == 0 { + rc = int32(SQLITE_ERROR) + } + if rc != SQLITE_OK { + _fts5TriDelete(tls, pNew) + pNew = uintptr(0) + } + } + } + **(**uintptr)(__ccgo_up(ppOut)) = pNew + return rc +} + +// C documentation +// +// /* +// ** Create a "unicode61" tokenizer. +// */ +func _fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + var i, rc int32 + var p, zArg, zCat uintptr + _, _, _, _, _ = i, p, rc, zArg, zCat + rc = SQLITE_OK /* Return code */ + p = uintptr(0) /* New tokenizer object */ + _ = pUnused + if nArg%int32(2) != 0 { + rc = int32(SQLITE_ERROR) + } else { + p = Xsqlite3_malloc64(tls, uint64(192)) + if p != 0 { + zCat = __ccgo_ts + 41787 + libc.Xmemset(tls, p, 0, uint64(192)) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = int32(FTS5_REMOVE_DIACRITICS_SIMPLE) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold = int32(64) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold)*uint64(1))) + if (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + /* Search for a "categories" argument */ + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41796) { + zCat = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + } + goto _1 + _1: + ; + i = i + int32(2) + } + if rc == SQLITE_OK { + rc = _unicodeSetCategories(tls, p, zCat) + } + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + zArg = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41807) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('1') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) != int32('2') || **(**uint8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) - int32('0') + } + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41765) { + rc = _fts5UnicodeAddExceptions(tls, p, zArg, int32(1)) + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41776) { + rc = _fts5UnicodeAddExceptions(tls, p, zArg, 0) + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41796) { + /* no-op */ + } else { + rc = int32(SQLITE_ERROR) + } + } + } + } + goto _2 + _2: + ; + i = i + int32(2) + } + } else { + rc = int32(SQLITE_NOMEM) + } + if rc != SQLITE_OK { + _fts5UnicodeDelete(tls, p) + p = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppOut)) = p + } + return rc +} + +// C documentation +// +// /* +// ** SQL function: geopoly_svg(X, ....) +// ** +// ** Interpret X as a polygon and render it as a SVG . +// ** Additional arguments are added as attributes to the . +// */ +func _geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var cSep uint8 + var db, p, x, z uintptr + var i int32 + _, _, _, _, _, _ = cSep, db, i, p, x, z + if argc < int32(1) { + return + } + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + if p != 0 { + db = Xsqlite3_context_db_handle(tls, context) + x = Xsqlite3_str_new(tls, db) + cSep = uint8('\'') + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29790, 0) + i = 0 + for { + if !(i < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) { + break + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29808, libc.VaList(bp+8, libc.Int32FromUint8(cSep), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2)+int32(1))*4))))) + cSep = uint8(' ') + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29816, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4))))) + i = int32(1) + for { + if !(i < argc) { + break + } + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if z != 0 && **(**uint8)(__ccgo_up(z)) != 0 { + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29824, libc.VaList(bp+8, z)) + } + goto _2 + _2: + ; + i = i + 1 + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29828, 0) + Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -int32(1), __ccgo_fp(Xsqlite3_free)) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* c is a control character. Append the canonical JSON representation +// ** of that control character to p. +// ** +// ** This routine assumes that the output buffer has already been enlarged +// ** sufficiently to hold the worst-case encoding plus a nul terminator. +// */ +func _jsonAppendControlChar(tls *libc.TLS, p uintptr, c Tu8) { + if _aSpecial[c] != 0 { + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed))) = uint8('\\') + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(1)))) = _aSpecial[c] + **(**Tu64)(__ccgo_up(p + 24)) += uint64(2) + } else { + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed))) = uint8('\\') + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(1)))) = uint8('u') + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(2)))) = uint8('0') + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(3)))) = uint8('0') + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(4)))) = **(**uint8)(__ccgo_up(__ccgo_ts + 1726 + uintptr(libc.Int32FromUint8(c)>>int32(4)))) + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(5)))) = **(**uint8)(__ccgo_up(__ccgo_ts + 1726 + uintptr(libc.Int32FromUint8(c)&int32(0xf)))) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(6) + } +} + +// C documentation +// +// /* +// ** Append the path name for the current element. +// */ +func _jsonAppendPathName(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, k, n Tu32 + var needQuote int32 + var z uintptr + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _ = i, k, n, needQuote, z + if libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeType) == int32(JSONB_ARRAY) { + _jsonPrintf(tls, int32(30), p+56, __ccgo_ts+26876, libc.VaList(bp+16, (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiKey)) + } else { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + needQuote = 0 + n = _jsonbPayloadSize(tls, p+192, (*TJsonEachCursor)(unsafe.Pointer(p)).Fi, bp) + k = (*TJsonEachCursor)(unsafe.Pointer(p)).Fi + n + z = (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(k) + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z)))])&libc.Int32FromInt32(0x02) != 0) { + needQuote = int32(1) + } else { + i = uint32(0) + for { + if !(i < **(**Tu32)(__ccgo_up(bp))) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i))))])&libc.Int32FromInt32(0x06) != 0) { + needQuote = int32(1) + break + } + goto _1 + _1: + ; + i = i + 1 + } + } + if needQuote != 0 { + _jsonPrintf(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+uint32(4)), p+56, __ccgo_ts+26883, libc.VaList(bp+16, **(**Tu32)(__ccgo_up(bp)), z)) + } else { + _jsonPrintf(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+uint32(2)), p+56, __ccgo_ts+26891, libc.VaList(bp+16, **(**Tu32)(__ccgo_up(bp)), z)) + } + } +} + +// C documentation +// +// /* +// ** json_array_length(JSON) +// ** json_array_length(JSON, PATH) +// ** +// ** Return the number of elements in the top-level JSON array. +// ** Return 0 if the input is not a well-formed JSON array. +// */ +func _jsonArrayLengthFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var cnt Tsqlite3_int64 + var eErr Tu8 + var i Tu32 + var p, zPath, v1 uintptr + _, _, _, _, _, _ = cnt, eErr, i, p, zPath, v1 /* The parse */ + cnt = 0 + eErr = uint8(0) + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if p == uintptr(0) { + return + } + if argc == int32(2) { + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zPath == uintptr(0) { + _jsonParseFree(tls, p) + return + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) == int32('$') { + v1 = zPath + uintptr(1) + } else { + v1 = __ccgo_ts + 26603 + } + i = _jsonLookupStep(tls, p, uint32(0), v1, uint32(0)) + if i >= uint32(JSON_LOOKUP_PATHERROR) { + if i == uint32(JSON_LOOKUP_NOTFOUND) { + /* no-op */ + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(i)) + } + eErr = uint8(1) + i = uint32(0) + } + } else { + i = uint32(0) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob + uintptr(i))))&int32(0x0f) == int32(JSONB_ARRAY) { + cnt = libc.Int64FromUint32(_jsonbArrayCount(tls, p, i)) + } + if !(eErr != 0) { + Xsqlite3_result_int64(tls, ctx, cnt) + } + _jsonParseFree(tls, p) +} + +// C documentation +// +// /* Constructor for the json_each virtual table */ +func _jsonEachConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + var pNew uintptr + var rc, v1 int32 + _, _, _ = pNew, rc, v1 + /* Column numbers */ + /* The xBestIndex method assumes that the JSON and ROOT columns are + ** the last two columns in the table. Should this ever changes, be + ** sure to update the xBestIndex method. */ + _ = pzErr + _ = argv + _ = argc + _ = pAux + rc = Xsqlite3_declare_vtab(tls, db, __ccgo_ts+26793) + if rc == SQLITE_OK { + pNew = _sqlite3DbMallocZero(tls, db, uint64(40)) + **(**uintptr)(__ccgo_up(ppVtab)) = pNew + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + (*TJsonEachConnection)(unsafe.Pointer(pNew)).Fdb = db + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv)) + 4))) == int32('b') { + v1 = int32(2) + } else { + v1 = int32(1) + } + (*TJsonEachConnection)(unsafe.Pointer(pNew)).FeMode = libc.Uint8FromInt32(v1) + (*TJsonEachConnection)(unsafe.Pointer(pNew)).FbRecursive = libc.BoolUint8(libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv)) + uintptr(int32(4)+libc.Int32FromUint8((*TJsonEachConnection)(unsafe.Pointer(pNew)).FeMode))))) == int32('t')) + } + return rc +} + +// C documentation +// +// /* Start a search on a new JSON string */ +func _jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, n, v1 Tu32 + var p, zRoot uintptr + var v2 int32 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _ = i, n, p, zRoot, v1, v2 + p = cur + zRoot = uintptr(0) + _ = idxStr + _ = argc + _jsonEachCursorReset(tls, p) + if idxNum == 0 { + return SQLITE_OK + } + libc.Xmemset(tls, p+192, 0, uint64(72)) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FnJPRef = uint32(1) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.Fdb = (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb + if _jsonArgIsJsonb(tls, **(**uintptr)(__ccgo_up(argv)), p+192) != 0 { + /* We have JSONB */ + } else { + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FnJson = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson == uintptr(0) { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + return SQLITE_OK + } + if _jsonConvertTextToBlob(tls, p+192, uintptr(0)) != 0 { + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.Foom != 0 { + return int32(SQLITE_NOMEM) + } + goto json_each_malformed_input + } + } + if idxNum == int32(3) { + zRoot = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zRoot == uintptr(0) { + return SQLITE_OK + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zRoot))) != int32('$') { + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = _jsonBadPathError(tls, uintptr(0), zRoot, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot = libc.Uint32FromInt32(_sqlite3Strlen30(tls, zRoot)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zRoot + 1))) == 0 { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + i = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + } else { + i = _jsonLookupStep(tls, p+192, uint32(0), zRoot+uintptr(1), uint32(0)) + if i >= uint32(JSON_LOOKUP_PATHERROR) { + if i == uint32(JSON_LOOKUP_NOTFOUND) { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = uint32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = uint32(0) + return SQLITE_OK + } + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = _jsonBadPathError(tls, uintptr(0), zRoot, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 + } + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FiLabel != 0 { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FiLabel + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(JSONB_OBJECT) + } else { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(JSONB_ARRAY) + } + } + _jsonAppendRaw(tls, p+56, zRoot, (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot) + } else { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + i = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot = uint32(1) + _jsonAppendRaw(tls, p+56, __ccgo_ts+26897, uint32(1)) + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = uint32(0) + n = _jsonbPayloadSize(tls, p+192, i, bp) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = i + n + **(**Tu32)(__ccgo_up(bp)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i))))&int32(0x0f) >= int32(JSONB_ARRAY) && !((*TJsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0) { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i + n + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i)))) & int32(0x0f)) + (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent = _sqlite3DbMallocZero(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb, uint64(24)) + if (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = uint32(1) + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParentAlloc = uint32(1) + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiKey = 0 + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiEnd = (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiHead = (*TJsonEachCursor)(unsafe.Pointer(p)).Fi + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiValue = i + } + return SQLITE_OK + goto json_each_malformed_input +json_each_malformed_input: + ; + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26393, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 +} + +// C documentation +// +// /* +// ** json_extract(JSON, PATH, ...) +// ** "->"(JSON,PATH) +// ** "->>"(JSON,PATH) +// ** +// ** Return the element described by PATH. Return NULL if that PATH element +// ** is not found. +// ** +// ** If JSON_JSON is set or if more that one PATH argument is supplied then +// ** always return a JSON representation of the result. If JSON_SQL is set, +// ** then always return an SQL representation of the result. If neither flag +// ** is present and argc==2, then return JSON for objects and arrays and SQL +// ** for all other values. +// ** +// ** When multiple PATH arguments are supplied, the result is a JSON array +// ** containing the result of each PATH. +// ** +// ** Abbreviated JSON path expressions are allows if JSON_ABPATH, for +// ** compatibility with PG. +// */ +func _jsonExtractFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var flags, i, nPath int32 + var j Tu32 + var p, zPath uintptr + var _ /* jx at bp+0 */ TJsonString + _, _, _, _, _, _ = flags, i, j, nPath, p, zPath + p = uintptr(0) /* String for array result */ + if argc < int32(2) { + return + } + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if p == uintptr(0) { + return + } + flags = int32(int64(Xsqlite3_user_data(tls, ctx))) + _jsonStringInit(tls, bp, ctx) + if argc > int32(2) { + _jsonAppendChar(tls, bp, uint8('[')) + } + i = int32(1) + for { + if !(i < argc) { + break + } + /* With a single PATH argument */ + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zPath == uintptr(0) { + goto json_extract_error + } + nPath = _sqlite3Strlen30(tls, zPath) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) == int32('$') { + j = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + } else { + if flags&int32(JSON_ABPATH) != 0 { + /* The -> and ->> operators accept abbreviated PATH arguments. This + ** is mostly for compatibility with PostgreSQL, but also for + ** convenience. + ** + ** NUMBER ==> $[NUMBER] // PG compatible + ** LABEL ==> $.LABEL // PG compatible + ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience + ** + ** Updated 2024-05-27: If the NUMBER is negative, then PG counts from + ** the right of the array. Hence for negative NUMBER: + ** + ** NUMBER ==> $[#NUMBER] // PG compatible + */ + _jsonStringInit(tls, bp, ctx) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) == int32(SQLITE_INTEGER) { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26605, uint32(1)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) == int32('-') { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26607, uint32(1)) + } + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+5312, uint32(2)) + } else { + if _jsonAllAlphanum(tls, zPath, nPath) != 0 { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+1743, uint32(1)) + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) == int32('[') && nPath >= int32(3) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(nPath-int32(1))))) == int32(']') { + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + } else { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26609, uint32(2)) + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26612, uint32(1)) + } + } + } + _jsonStringTerminate(tls, bp) + j = _jsonLookupStep(tls, p, uint32(0), (**(**TJsonString)(__ccgo_up(bp))).FzBuf, uint32(0)) + _jsonStringReset(tls, bp) + } else { + _jsonBadPathError(tls, ctx, zPath, 0) + goto json_extract_error + } + } + if j < (*TJsonParse)(unsafe.Pointer(p)).FnBlob { + if argc == int32(2) { + if flags&int32(JSON_JSON) != 0 { + _jsonStringInit(tls, bp, ctx) + _jsonTranslateBlobToText(tls, p, j, bp) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + _jsonStringReset(tls, bp) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } else { + _jsonReturnFromBlob(tls, p, j, ctx, 0) + if flags&(libc.Int32FromInt32(JSON_SQL)|libc.Int32FromInt32(JSON_BLOB)) == 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob + uintptr(j))))&int32(0x0f) >= int32(JSONB_ARRAY) { + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } + } + } else { + _jsonAppendSeparator(tls, bp) + _jsonTranslateBlobToText(tls, p, j, bp) + } + } else { + if j == uint32(JSON_LOOKUP_NOTFOUND) { + if argc == int32(2) { + goto json_extract_error /* Return NULL if not found */ + } else { + _jsonAppendSeparator(tls, bp) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+1690, uint32(4)) + } + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(j)) + goto json_extract_error + } + } + goto _1 + _1: + ; + i = i + 1 + } + if argc > int32(2) { + _jsonAppendChar(tls, bp, uint8(']')) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + if flags&int32(JSON_BLOB) == 0 { + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } + } + goto json_extract_error +json_extract_error: + ; + _jsonStringReset(tls, bp) + _jsonParseFree(tls, p) + return +} + +/* +** Return codes for jsonMergePatch() + */ + +// C documentation +// +// /* +// ** pArg is a function argument that might be an SQL value or a JSON +// ** value. Figure out what it is and encode it as a JSONB blob. +// ** Return the results in pParse. +// ** +// ** pParse is uninitialized upon entry. This routine will handle the +// ** initialization of pParse. The result will be contained in +// ** pParse->aBlob and pParse->nBlob. pParse->aBlob might be dynamically +// ** allocated (if pParse->nBlobAlloc is greater than zero) in which case +// ** the caller is responsible for freeing the space allocated to pParse->aBlob +// ** when it has finished with it. Or pParse->aBlob might be a static string +// ** or a value obtained from sqlite3_value_blob(pArg). +// ** +// ** If the argument is a BLOB that is clearly not a JSONB, then this +// ** function might set an error message in ctx and return non-zero. +// ** It might also set an error message and return non-zero on an OOM error. +// */ +func _jsonFunctionArgToBlob(tls *libc.TLS, ctx uintptr, pArg uintptr, pParse uintptr) (r1 int32) { + var eType, n, n1, nJson int32 + var r float64 + var z, z1, zJson uintptr + _, _, _, _, _, _, _, _ = eType, n, n1, nJson, r, z, z1, zJson + eType = Xsqlite3_value_type(tls, pArg) + libc.Xmemset(tls, pParse, 0, uint64(72)) + (*TJsonParse)(unsafe.Pointer(pParse)).Fdb = Xsqlite3_context_db_handle(tls, ctx) + switch eType { + default: + (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = uintptr(unsafe.Pointer(&_aNull)) + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = uint32(1) + return 0 + case int32(SQLITE_BLOB): + if !(_jsonArgIsJsonb(tls, pArg, pParse) != 0) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26364, -int32(1)) + return int32(1) + } + case int32(SQLITE_TEXT): + zJson = Xsqlite3_value_text(tls, pArg) + nJson = Xsqlite3_value_bytes(tls, pArg) + if zJson == uintptr(0) { + return int32(1) + } + if Xsqlite3_value_subtype(tls, pArg) == uint32(JSON_SUBTYPE) { + (*TJsonParse)(unsafe.Pointer(pParse)).FzJson = zJson + (*TJsonParse)(unsafe.Pointer(pParse)).FnJson = nJson + if _jsonConvertTextToBlob(tls, pParse, ctx) != 0 { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26393, -int32(1)) + _sqlite3DbFree(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob) + libc.Xmemset(tls, pParse, 0, uint64(72)) + return int32(1) + } + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_TEXTRAW), libc.Uint64FromInt32(nJson), zJson) + } + case int32(SQLITE_FLOAT): + r = Xsqlite3_value_double(tls, pArg) + if _sqlite3IsNaN(tls, r) != 0 { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_NULL), uint64(0), uintptr(0)) + } else { + n = Xsqlite3_value_bytes(tls, pArg) + z = Xsqlite3_value_text(tls, pArg) + if z == uintptr(0) { + return int32(1) + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32('I') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26498) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32('-') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('I') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(6), __ccgo_ts+26491) + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), libc.Uint64FromInt32(n), z) + } + } + } + case int32(SQLITE_INTEGER): + n1 = Xsqlite3_value_bytes(tls, pArg) + z1 = Xsqlite3_value_text(tls, pArg) + if z1 == uintptr(0) { + return int32(1) + } + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_INT), libc.Uint64FromInt32(n1), z1) + break + } + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, ctx) + return int32(1) + } else { + return 0 + } + return r1 +} + +// C documentation +// +// /* +// ** Search along zPath to find the Json element specified. Return an +// ** index into pParse->aBlob[] for the start of that element's value. +// ** +// ** If the value found by this routine is the value half of label/value pair +// ** within an object, then set pPath->iLabel to the start of the corresponding +// ** label, before returning. +// ** +// ** Return one of the JSON_LOOKUP error codes if problems are seen. +// ** +// ** This routine will also modify the blob. If pParse->eEdit is one of +// ** JEDIT_DEL, JEDIT_REPL, JEDIT_INS, JEDIT_SET, or JEDIT_AINS, then changes +// ** might be made to the selected value. If an edit is performed, then the +// ** return value does not necessarily point to the select element. If an edit +// ** is performed, the return value is only useful for detecting error +// ** conditions. +// */ +func _jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot Tu32, zPath uintptr, iLabel Tu32) (r Tu32) { + bp := tls.Alloc(224) + defer tls.Free(224) + var i, iEnd, j, k, n, nIns, nKey, rc, v Tu32 + var kk, nn Tu64 + var rawKey, rawLabel, v5 int32 + var x Tu8 + var zKey, zLabel, v4 uintptr + var v3 Tu16 + var _ /* ix at bp+80 */ TJsonParse + var _ /* sz at bp+0 */ Tu32 + var _ /* v at bp+152 */ TJsonParse + var _ /* v at bp+8 */ TJsonParse + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iEnd, j, k, kk, n, nIns, nKey, nn, rawKey, rawLabel, rc, v, x, zKey, zLabel, v3, v4, v5 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) == 0 { + if (*TJsonParse)(unsafe.Pointer(pParse)).FeEdit != 0 && _jsonBlobMakeEditable(tls, pParse, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) != 0 { + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + n + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_DEL) { + if iLabel > uint32(0) { + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + (iRoot - iLabel) + iRoot = iLabel + } + _jsonBlobEdit(tls, pParse, iRoot, **(**Tu32)(__ccgo_up(bp)), uintptr(0), uint32(0)) + } else { + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_INS) { + /* Already exists, so json_insert() is a no-op */ + } else { + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_AINS) { + /* json_array_insert() */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(-libc.Int32FromInt32(1))))) != int32(']') { + return uint32(JSON_LOOKUP_NOTARRAY) + } else { + _jsonBlobEdit(tls, pParse, iRoot, uint32(0), (*TJsonParse)(unsafe.Pointer(pParse)).FaIns, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) + } + } else { + /* json_set() or json_replace() */ + _jsonBlobEdit(tls, pParse, iRoot, **(**Tu32)(__ccgo_up(bp)), (*TJsonParse)(unsafe.Pointer(pParse)).FaIns, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) + } + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiLabel = iLabel + return iRoot + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) == int32('.') { + rawKey = int32(1) + x = **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iRoot))) + zPath = zPath + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) == int32('"') { + zKey = zPath + uintptr(1) + i = uint32(1) + for { + if !(**(**uint8)(__ccgo_up(zPath + uintptr(i))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) != int32('"')) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) == int32('\\') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(i+uint32(1))))) != 0 { + i = i + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + nKey = i - uint32(1) + if **(**uint8)(__ccgo_up(zPath + uintptr(i))) != 0 { + i = i + 1 + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + rawKey = libc.BoolInt32(libc.Xmemchr(tls, zKey, int32('\\'), uint64(nKey)) == uintptr(0)) + } else { + zKey = zPath + i = uint32(0) + for { + if !(**(**uint8)(__ccgo_up(zPath + uintptr(i))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) != int32('.') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) != int32('[')) { + break + } + goto _2 + _2: + ; + i = i + 1 + } + nKey = i + if nKey == uint32(0) { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + if libc.Int32FromUint8(x)&int32(0x0f) != int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + j = iRoot + n /* j is the index of a label */ + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + for j < iEnd { + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(j)))) & int32(0x0f)) + if libc.Int32FromUint8(x) < int32(JSONB_TEXT) || libc.Int32FromUint8(x) > int32(JSONB_TEXTRAW) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + k = j + n /* k is the index of the label text */ + if k+**(**Tu32)(__ccgo_up(bp)) >= iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + zLabel = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(k) + rawLabel = libc.BoolInt32(libc.Int32FromUint8(x) == int32(JSONB_TEXT) || libc.Int32FromUint8(x) == int32(JSONB_TEXTRAW)) + if _jsonLabelCompare(tls, zKey, nKey, rawKey, zLabel, **(**Tu32)(__ccgo_up(bp)), rawLabel) != 0 { + v = k + **(**Tu32)(__ccgo_up(bp)) /* v is the index of the value */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(v))))&int32(0x0f) > int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, v, bp) + if n == uint32(0) || v+n+**(**Tu32)(__ccgo_up(bp)) > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + v4 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v4)) = *(*Tu16)(unsafe.Pointer(v4)) + 1 + v3 = *(*Tu16)(unsafe.Pointer(v4)) + if libc.Int32FromUint16(v3) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = _jsonLookupStep(tls, pParse, v, zPath+uintptr(i), j) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + j = k + **(**Tu32)(__ccgo_up(bp)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(j))))&int32(0x0f) > int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + if j > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) >= int32(JEDIT_INS) { /* Header of the label to be inserted */ + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_AINS) && Xsqlite3_strglob(tls, __ccgo_ts+26538, zPath+uintptr(i)) != 0 { + return uint32(JSON_LOOKUP_NOTARRAY) + } + libc.Xmemset(tls, bp+80, 0, uint64(72)) + (**(**TJsonParse)(__ccgo_up(bp + 80))).Fdb = (*TJsonParse)(unsafe.Pointer(pParse)).Fdb + if rawKey != 0 { + v5 = int32(JSONB_TEXTRAW) + } else { + v5 = int32(JSONB_TEXT5) + } + _jsonBlobAppendNode(tls, bp+80, libc.Uint8FromInt32(v5), uint64(nKey), uintptr(0)) + v4 = pParse + 47 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v4))) | libc.Int32FromUint8((**(**TJsonParse)(__ccgo_up(bp + 80))).Foom)) + rc = _jsonCreateEditSubstructure(tls, pParse, bp+8, zPath+uintptr(i)) + if !(rc >= libc.Uint32FromUint32(JSON_LOOKUP_PATHERROR)) && _jsonBlobMakeEditable(tls, pParse, (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob+nKey+(**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob) != 0 { + nIns = (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob + nKey + (**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob + _jsonBlobEdit(tls, pParse, j, uint32(0), uintptr(0), nIns) + if !((*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0) { + /* Because pParse->oom!=0 */ + /* Because pPasre->oom!=0 */ + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(j), (**(**TJsonParse)(__ccgo_up(bp + 80))).FaBlob, uint64((**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob)) + k = j + (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(k), zKey, uint64(nKey)) + k = k + nKey + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(k), (**(**TJsonParse)(__ccgo_up(bp + 8))).FaBlob, uint64((**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob)) + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + } + } + _jsonParseReset(tls, bp+8) + _jsonParseReset(tls, bp+80) + return rc + } + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) == int32('[') { + kk = uint64(0) + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iRoot)))) & int32(0x0f)) + if libc.Int32FromUint8(x) != int32(JSONB_ARRAY) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + i = uint32(1) + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zPath + uintptr(i))))])&int32(0x04) != 0 { + if kk < uint64(0xffffffff) { + kk = kk*uint64(10) + uint64(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) - uint64('0') + } + /* ^^^^^^^^^^--- Allow kk to be bigger than any JSON array so that + ** we get NOTFOUND instead of PATHERROR, without overflowing kk. */ + i = i + 1 + } + if i < uint32(2) || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) != int32(']') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + 1))) == int32('#') { + kk = uint64(_jsonbArrayCount(tls, pParse, iRoot)) + i = uint32(2) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + 2))) == int32('-') && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zPath + 3)))])&int32(0x04) != 0 { + nn = uint64(0) + i = uint32(3) + for cond := true; cond; cond = libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zPath + uintptr(i))))])&int32(0x04) != 0 { + if nn < uint64(0xffffffff) { + nn = nn*uint64(10) + uint64(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) - uint64('0') + } + /* ^^^^^^^^^^--- Allow nn to be bigger than any JSON array to + ** get NOTFOUND instead of PATHERROR, without overflowing nn. */ + i = i + 1 + } + if nn > kk { + return uint32(JSON_LOOKUP_NOTFOUND) + } + kk = kk - nn + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) != int32(']') { + return uint32(JSON_LOOKUP_PATHERROR) + } + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + j = iRoot + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + for j < iEnd { + if kk == uint64(0) { + v4 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v4)) = *(*Tu16)(unsafe.Pointer(v4)) + 1 + v3 = *(*Tu16)(unsafe.Pointer(v4)) + if libc.Int32FromUint16(v3) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = _jsonLookupStep(tls, pParse, j, zPath+uintptr(i+uint32(1)), uint32(0)) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + kk = kk - 1 + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + if j > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + if kk > uint64(0) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) >= int32(JEDIT_INS) { + rc = _jsonCreateEditSubstructure(tls, pParse, bp+152, zPath+uintptr(i+uint32(1))) + if !(rc >= libc.Uint32FromUint32(JSON_LOOKUP_PATHERROR)) && _jsonBlobMakeEditable(tls, pParse, (**(**TJsonParse)(__ccgo_up(bp + 152))).FnBlob) != 0 { + _jsonBlobEdit(tls, pParse, j, uint32(0), (**(**TJsonParse)(__ccgo_up(bp + 152))).FaBlob, (**(**TJsonParse)(__ccgo_up(bp + 152))).FnBlob) + } + _jsonParseReset(tls, bp+152) + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + return uint32(JSON_LOOKUP_NOTFOUND) +} + +func _jsonObjectCompute(tls *libc.TLS, ctx uintptr, isFinal int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var c uint8 + var flags, inStr int32 + var i, j, v2, v3 Tu64 + var pOgStr, pStr uintptr + var v8 Tsqlite3_destructor_type + var _ /* tmpStr at bp+0 */ TJsonString + _, _, _, _, _, _, _, _, _, _ = c, flags, i, inStr, j, pOgStr, pStr, v2, v3, v8 + flags = int32(int64(Xsqlite3_user_data(tls, ctx))) + pStr = Xsqlite3_aggregate_context(tls, ctx, 0) + if pStr != 0 { + pOgStr = pStr + _jsonAppendRawNZ(tls, pOgStr, __ccgo_ts+26788, uint32(2)) /* Ensure it is zero-terminated */ + _jsonStringTrimOneChar(tls, pOgStr) /* Remove the zero terminator */ + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + if (*TJsonString)(unsafe.Pointer(pStr)).FeErr != 0 { + _jsonReturnString(tls, pStr, uintptr(0), uintptr(0)) + return + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf))) != int32('{') { + inStr = 0 + if !(isFinal != 0) { + /* Work with a temporary copy of the string if this is not the + ** final result */ + _jsonStringInit(tls, bp, ctx) + _jsonAppendRawNZ(tls, bp, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, uint32((*TJsonString)(unsafe.Pointer(pStr)).FnUsed+uint64(1))) + pStr = bp + if (*TJsonString)(unsafe.Pointer(pStr)).FeErr != 0 { + _jsonReturnString(tls, pStr, uintptr(0), uintptr(0)) + return + } + _jsonStringTrimOneChar(tls, pStr) /* Remove zero terminator */ + } + /* Fix up the string by changing the initial "@" flag back to + ** to "{" and removing all subsequence "@" entries, with their + ** associated comma delimeters. */ + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf)) = uint8('{') + v2 = libc.Uint64FromInt32(1) + j = v2 + i = v2 + for { + if !(i < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed) { + break + } + c = **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(i))) + if libc.Int32FromUint8(c) == int32('"') { + inStr = libc.BoolInt32(!(inStr != 0)) + v2 = j + j = j + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = uint8('"') + } else { + if libc.Int32FromUint8(c) == int32('\\') { + v2 = j + j = j + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = uint8('\\') + v2 = j + j = j + 1 + i = i + 1 + v3 = i + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v3))) + } else { + if libc.Int32FromUint8(c) == int32('@') && !(inStr != 0) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(i+uint64(1))))) == int32(',') { + i = i + 1 + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(j-uint64(1))))) == int32(',') { + j = j - 1 + } + } + } else { + v2 = j + j = j + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = c + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(j))) = uint8(0) /* Restore zero terminator */ + (*TJsonString)(unsafe.Pointer(pStr)).FnUsed = j /* Truncate the string */ + } + if flags&int32(JSON_BLOB) != 0 { + _jsonReturnStringAsBlob(tls, pStr) + if isFinal != 0 { + if !((*TJsonString)(unsafe.Pointer(pStr)).FbStatic != 0) { + _sqlite3RCStrUnref(tls, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf) + } + } else { + _jsonStringTrimOneChar(tls, pOgStr) + } + } else { + if isFinal != 0 { + if (*TJsonString)(unsafe.Pointer(pStr)).FbStatic != 0 { + v8 = uintptr(-libc.Int32FromInt32(1)) + } else { + v8 = __ccgo_fp(_sqlite3RCStrUnref) + } + Xsqlite3_result_text(tls, ctx, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed), v8) + (*TJsonString)(unsafe.Pointer(pStr)).FbStatic = uint8(1) + } else { + Xsqlite3_result_text(tls, ctx, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed), uintptr(-libc.Int32FromInt32(1))) + _jsonStringTrimOneChar(tls, pOgStr) + } + } + if pStr != pOgStr { + _jsonStringReset(tls, pStr) + } + } else { + if flags&int32(JSON_BLOB) != 0 { + Xsqlite3_result_blob(tls, ctx, uintptr(unsafe.Pointer(&_emptyObject1)), int32(1), libc.UintptrFromInt32(0)) + } else { + Xsqlite3_result_text(tls, ctx, __ccgo_ts+26790, int32(2), libc.UintptrFromInt32(0)) + } + } + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /* +// ** Implementation of the json_object(NAME,VALUE,...) function. Return a JSON +// ** object that contains all name/value given in arguments. Or if any name +// ** is not a string or if any value is a BLOB, throw an error. +// */ +func _jsonObjectFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var i int32 + var n Tu32 + var z uintptr + var _ /* jx at bp+0 */ TJsonString + _, _, _ = i, n, z + if argc&int32(1) != 0 { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26614, -int32(1)) + return + } + _jsonStringInit(tls, bp, ctx) + _jsonAppendChar(tls, bp, uint8('{')) + i = 0 + for { + if !(i < argc) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) != int32(SQLITE_TEXT) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26665, -int32(1)) + _jsonStringReset(tls, bp) + return + } + _jsonAppendSeparator(tls, bp) + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + n = libc.Uint32FromInt32(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)))) + _jsonAppendString(tls, bp, z, n) + _jsonAppendChar(tls, bp, uint8(':')) + _jsonAppendSqlValue(tls, bp, **(**uintptr)(__ccgo_up(argv + uintptr(i+int32(1))*8))) + goto _1 + _1: + ; + i = i + int32(2) + } + _jsonAppendChar(tls, bp, uint8('}')) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /* +// ** json_group_obj(NAME,VALUE) +// ** +// ** Return a JSON object composed of all names and values in the aggregate. +// ** +// ** Rows for which NAME is NULL do not result in a new entry. However, we +// ** do initially insert a "@" entry into the growing string for each null entry +// ** and change the first character of the string to "@" to signal that the +// ** string contains null entries. The "@" markers are needed in order to +// ** correctly process xInverse() requests. The initial "@" is converted +// ** back into "{" and the "@" null values are removed by jsonObjectCompute(). +// */ +func _jsonObjectStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var n Tu32 + var pStr, z uintptr + _, _, _ = n, pStr, z + _ = argc + pStr = Xsqlite3_aggregate_context(tls, ctx, int32(136)) + if pStr != 0 { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + n = libc.Uint32FromInt32(_sqlite3Strlen30(tls, z)) + if (*TJsonString)(unsafe.Pointer(pStr)).FzBuf == uintptr(0) { + _jsonStringInit(tls, pStr, ctx) + _jsonAppendChar(tls, pStr, uint8('{')) + } else { + if (*TJsonString)(unsafe.Pointer(pStr)).FnUsed > uint64(1) { + _jsonAppendChar(tls, pStr, uint8(',')) + } + } + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + if z != uintptr(0) { + _jsonAppendString(tls, pStr, z, n) + _jsonAppendChar(tls, pStr, uint8(':')) + _jsonAppendSqlValue(tls, pStr, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf)) = uint8('@') + _jsonAppendRawNZ(tls, pStr, __ccgo_ts+26603, uint32(1)) + } + } +} + +// C documentation +// +// /* +// ** Generate a JsonParse object, containing valid JSONB in aBlob and nBlob, +// ** from the SQL function argument pArg. Return a pointer to the new +// ** JsonParse object. +// ** +// ** Ownership of the new JsonParse object is passed to the caller. The +// ** caller should invoke jsonParseFree() on the return value when it +// ** has finished using it. +// ** +// ** If any errors are detected, an appropriate error messages is set +// ** using sqlite3_result_error() or the equivalent and this routine +// ** returns NULL. This routine also returns NULL if the pArg argument +// ** is an SQL NULL value, but no error message is set in that case. This +// ** is so that SQL functions that are given NULL arguments will return +// ** a NULL value. +// */ +func _jsonParseFuncArg(tls *libc.TLS, ctx uintptr, pArg uintptr, flgs Tu32) (r uintptr) { + var db, p, pFromCache, zNew, v2 uintptr + var eType, isRCStr, rc int32 + var nBlob, v1 Tu32 + _, _, _, _, _, _, _, _, _, _ = db, eType, isRCStr, nBlob, p, pFromCache, rc, zNew, v1, v2 /* Datatype of pArg */ + p = uintptr(0) /* Value to be returned */ + pFromCache = uintptr(0) /* The database connection */ + eType = Xsqlite3_value_type(tls, pArg) + if eType == int32(SQLITE_NULL) { + return uintptr(0) + } + pFromCache = _jsonCacheSearch(tls, ctx, pArg) + if pFromCache != 0 { + (*TJsonParse)(unsafe.Pointer(pFromCache)).FnJPRef = (*TJsonParse)(unsafe.Pointer(pFromCache)).FnJPRef + 1 + if flgs&uint32(JSON_EDITABLE) == uint32(0) { + return pFromCache + } + } + db = Xsqlite3_context_db_handle(tls, ctx) + goto rebuild_from_cache +rebuild_from_cache: + ; + p = _sqlite3DbMallocZero(tls, db, uint64(72)) + if p == uintptr(0) { + goto json_pfa_oom + } + libc.Xmemset(tls, p, 0, uint64(72)) + (*TJsonParse)(unsafe.Pointer(p)).Fdb = db + (*TJsonParse)(unsafe.Pointer(p)).FnJPRef = uint32(1) + if pFromCache != uintptr(0) { + nBlob = (*TJsonParse)(unsafe.Pointer(pFromCache)).FnBlob + (*TJsonParse)(unsafe.Pointer(p)).FaBlob = _sqlite3DbMallocRaw(tls, db, uint64(nBlob)) + if (*TJsonParse)(unsafe.Pointer(p)).FaBlob == uintptr(0) { + goto json_pfa_oom + } + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(p)).FaBlob, (*TJsonParse)(unsafe.Pointer(pFromCache)).FaBlob, uint64(nBlob)) + v1 = nBlob + (*TJsonParse)(unsafe.Pointer(p)).FnBlob = v1 + (*TJsonParse)(unsafe.Pointer(p)).FnBlobAlloc = v1 + (*TJsonParse)(unsafe.Pointer(p)).FhasNonstd = (*TJsonParse)(unsafe.Pointer(pFromCache)).FhasNonstd + _jsonParseFree(tls, pFromCache) + return p + } + if eType == int32(SQLITE_BLOB) { + if _jsonArgIsJsonb(tls, pArg, p) != 0 { + if flgs&uint32(JSON_EDITABLE) != uint32(0) && _jsonBlobMakeEditable(tls, p, uint32(0)) == 0 { + goto json_pfa_oom + } + return p + } + /* If the blob is not valid JSONB, fall through into trying to cast + ** the blob into text which is then interpreted as JSON. (tag-20240123-a) + ** + ** This goes against all historical documentation about how the SQLite + ** JSON functions were suppose to work. From the beginning, blob was + ** reserved for expansion and a blob value should have raised an error. + ** But it did not, due to a bug. And many applications came to depend + ** upon this buggy behavior, especially when using the CLI and reading + ** JSON text using readfile(), which returns a blob. For this reason + ** we will continue to support the bug moving forward. + ** See for example https://sqlite.org/forum/forumpost/012136abd5292b8d + */ + } + (*TJsonParse)(unsafe.Pointer(p)).FzJson = Xsqlite3_value_text(tls, pArg) + (*TJsonParse)(unsafe.Pointer(p)).FnJson = Xsqlite3_value_bytes(tls, pArg) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto json_pfa_oom + } + if (*TJsonParse)(unsafe.Pointer(p)).FnJson == 0 { + goto json_pfa_malformed + } + if flgs&uint32(JSON_KEEPERROR) != 0 { + v2 = uintptr(0) + } else { + v2 = ctx + } + if _jsonConvertTextToBlob(tls, p, v2) != 0 { + if flgs&uint32(JSON_KEEPERROR) != 0 { + (*TJsonParse)(unsafe.Pointer(p)).FnErr = uint8(1) + return p + } else { + _jsonParseFree(tls, p) + return uintptr(0) + } + } else { + isRCStr = _sqlite3ValueIsOfClass(tls, pArg, __ccgo_fp(_sqlite3RCStrUnref)) + if !(isRCStr != 0) { + zNew = _sqlite3RCStrNew(tls, libc.Uint64FromInt32((*TJsonParse)(unsafe.Pointer(p)).FnJson)) + if zNew == uintptr(0) { + goto json_pfa_oom + } + libc.Xmemcpy(tls, zNew, (*TJsonParse)(unsafe.Pointer(p)).FzJson, libc.Uint64FromInt32((*TJsonParse)(unsafe.Pointer(p)).FnJson)) + (*TJsonParse)(unsafe.Pointer(p)).FzJson = zNew + **(**uint8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FzJson + uintptr((*TJsonParse)(unsafe.Pointer(p)).FnJson))) = uint8(0) + } else { + _sqlite3RCStrRef(tls, (*TJsonParse)(unsafe.Pointer(p)).FzJson) + } + (*TJsonParse)(unsafe.Pointer(p)).FbJsonIsRCStr = uint8(1) + rc = _jsonCacheInsert(tls, ctx, p) + if rc == int32(SQLITE_NOMEM) { + goto json_pfa_oom + } + if flgs&uint32(JSON_EDITABLE) != 0 { + pFromCache = p + p = uintptr(0) + goto rebuild_from_cache + } + } + return p + goto json_pfa_malformed +json_pfa_malformed: + ; + if flgs&uint32(JSON_KEEPERROR) != 0 { + (*TJsonParse)(unsafe.Pointer(p)).FnErr = uint8(1) + return p + } else { + _jsonParseFree(tls, p) + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26393, -int32(1)) + return uintptr(0) + } + goto json_pfa_oom +json_pfa_oom: + ; + _jsonParseFree(tls, pFromCache) + _jsonParseFree(tls, p) + Xsqlite3_result_error_nomem(tls, ctx) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Return the value of the BLOB node at index i. +// ** +// ** If the value is a primitive, return it as an SQL value. +// ** If the value is an array or object, return it as either +// ** JSON text or the BLOB encoding, depending on the eMode flag +// ** as follows: +// ** +// ** eMode==0 JSONB if the JSON_B flag is set in userdata or +// ** text if the JSON_B flag is omitted from userdata. +// ** +// ** eMode==1 Text +// ** +// ** eMode==2 JSONB +// */ +func _jsonReturnFromBlob(tls *libc.TLS, pParse uintptr, i Tu32, pCtx uintptr, eMode int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bNeg, rc int32 + var c, x uint8 + var db, z, z1, z2, zOut uintptr + var iIn, iOut, n, nOut, szEscape, v19, v20 Tu32 + var r, v16 float64 + var v17 int64 + var _ /* iRes at bp+8 */ Tsqlite3_int64 + var _ /* r at bp+16 */ float64 + var _ /* sz at bp+0 */ Tu32 + var _ /* v at bp+24 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNeg, c, db, iIn, iOut, n, nOut, r, rc, szEscape, x, z, z1, z2, zOut, v16, v17, v19, v20 + db = Xsqlite3_context_db_handle(tls, pCtx) + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26393, -int32(1)) + return + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case JSONB_NULL: + goto _1 + case int32(JSONB_TRUE): + goto _2 + case int32(JSONB_FALSE): + goto _3 + case int32(JSONB_INT): + goto _4 + case int32(JSONB_INT5): + goto _5 + case int32(JSONB_FLOAT): + goto _6 + case int32(JSONB_FLOAT5): + goto _7 + case int32(JSONB_TEXT): + goto _8 + case int32(JSONB_TEXTRAW): + goto _9 + case int32(JSONB_TEXTJ): + goto _10 + case int32(JSONB_TEXT5): + goto _11 + case int32(JSONB_OBJECT): + goto _12 + case int32(JSONB_ARRAY): + goto _13 + default: + goto _14 + } + goto _15 +_1: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_null(tls, pCtx) + goto _15 +_2: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_int(tls, pCtx, int32(1)) + goto _15 +_3: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_int(tls, pCtx, 0) + goto _15 +_5: + ; +_4: + ; + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0 + bNeg = 0 + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto returnfromblob_malformed + } + x = uint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n)))) + if libc.Int32FromUint8(x) == int32('-') { + if **(**Tu32)(__ccgo_up(bp)) < uint32(2) { + goto returnfromblob_malformed + } + n = n + 1 + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) - 1 + bNeg = int32(1) + } + z = _sqlite3DbStrNDup(tls, db, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), libc.Uint64FromInt32(libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))))) + if z == uintptr(0) { + goto returnfromblob_oom + } + rc = _sqlite3DecOrHexToI64(tls, z, bp+8) + _sqlite3DbFree(tls, db, z) + if rc == 0 { + if **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) < 0 { + r = float64(**(**Tsqlite3_uint64)(__ccgo_up(bp + 8))) + if bNeg != 0 { + v16 = -r + } else { + v16 = r + } + Xsqlite3_result_double(tls, pCtx, v16) + } else { + if bNeg != 0 { + v17 = -**(**Tsqlite3_int64)(__ccgo_up(bp + 8)) + } else { + v17 = **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) + } + Xsqlite3_result_int64(tls, pCtx, v17) + } + } else { + if rc == int32(3) && bNeg != 0 { + Xsqlite3_result_int64(tls, pCtx, int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>libc.Int32FromInt32(6)) + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = uint8(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } else { + if **(**Tu32)(__ccgo_up(bp + 24)) < uint32(0x10000) { + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = uint8(uint32(0xe0) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(12)) + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = uint8(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(6)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = uint8(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } else { + if **(**Tu32)(__ccgo_up(bp + 24)) == uint32(JSON_INVALID_CHAR) { + /* Silently ignore illegal unicode */ + } else { + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = uint8(uint32(0xf0) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(18)) + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = uint8(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(12)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = uint8(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(6)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = uint8(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } + } + } + } + iIn = iIn + (szEscape - uint32(1)) + } else { + v19 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v19))) = c + } + goto _18 + _18: + ; + iIn = iIn + 1 + } /* end for() */ + **(**uint8)(__ccgo_up(zOut + uintptr(iOut))) = uint8(0) + Xsqlite3_result_text(tls, pCtx, zOut, libc.Int32FromUint32(iOut), __ccgo_fp(_sqlite3RowSetClear)) + goto _15 +_13: + ; +_12: + ; + if eMode == 0 { + if int32(int64(Xsqlite3_user_data(tls, pCtx)))&int32(JSON_BLOB) != 0 { + eMode = int32(2) + } else { + eMode = int32(1) + } + } + if eMode == int32(2) { + Xsqlite3_result_blob(tls, pCtx, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i), libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+n), uintptr(-libc.Int32FromInt32(1))) + } else { + _jsonReturnTextJsonFromBlob(tls, pCtx, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i), **(**Tu32)(__ccgo_up(bp))+n) + } + goto _15 +_14: + ; + goto returnfromblob_malformed +_15: + ; + return + goto returnfromblob_oom +returnfromblob_oom: + ; + Xsqlite3_result_error_nomem(tls, pCtx) + return + goto returnfromblob_malformed +returnfromblob_malformed: + ; + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26393, -int32(1)) + return +} + +// C documentation +// +// /* +// ** Translate the binary JSONB representation of JSON beginning at +// ** pParse->aBlob[i] into a JSON text string. Append the JSON +// ** text onto the end of pOut. Return the index in pParse->aBlob[] +// ** of the first byte past the end of the element that is translated. +// ** +// ** This is a variant of jsonTranslateBlobToText() that "pretty-prints" +// ** the output. Extra whitespace is inserted to make the JSON easier +// ** for humans to read. +// ** +// ** If an error is detected in the BLOB input, the pOut->eErr flag +// ** might get set to JSTRING_MALFORMED. But not all BLOB input errors +// ** are detected. So a malformed JSONB input might either result +// ** in an error, or in incorrect JSON. +// ** +// ** The pOut->eErr JSTRING_OOM flag is set on a OOM. +// */ +func _jsonTranslateBlobToPrettyText(tls *libc.TLS, pPretty uintptr, i Tu32) (r Tu32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iEnd, j, n Tu32 + var pOut, pParse, v1 uintptr + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _ = iEnd, j, n, pOut, pParse, v1 + pParse = (*TJsonPretty)(unsafe.Pointer(pPretty)).FpParse + pOut = (*TJsonPretty)(unsafe.Pointer(pPretty)).FpOut + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + return (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + uint32(1) + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case int32(JSONB_ARRAY): + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + _jsonAppendChar(tls, pOut, uint8('[')) + if j < iEnd { + _jsonAppendChar(tls, pOut, uint8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent + 1 + if (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent >= uint32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + _jsonPrettyIndent(tls, pPretty) + j = _jsonTranslateBlobToPrettyText(tls, pPretty, j) + if j >= iEnd { + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26532, uint32(2)) + } + _jsonAppendChar(tls, pOut, uint8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent - 1 + _jsonPrettyIndent(tls, pPretty) + } + _jsonAppendChar(tls, pOut, uint8(']')) + i = iEnd + case int32(JSONB_OBJECT): + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + _jsonAppendChar(tls, pOut, uint8('{')) + if j < iEnd { + _jsonAppendChar(tls, pOut, uint8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent + 1 + if (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent >= uint32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = uint16((*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent) + for libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + _jsonPrettyIndent(tls, pPretty) + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + if j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26535, uint32(2)) + j = _jsonTranslateBlobToPrettyText(tls, pPretty, j) + if j >= iEnd { + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26532, uint32(2)) + } + _jsonAppendChar(tls, pOut, uint8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent - 1 + _jsonPrettyIndent(tls, pPretty) + } + _jsonAppendChar(tls, pOut, uint8('}')) + i = iEnd + default: + i = _jsonTranslateBlobToText(tls, pParse, i, pOut) + break + } + return i +} + +// C documentation +// +// /* +// ** Translate the binary JSONB representation of JSON beginning at +// ** pParse->aBlob[i] into a JSON text string. Append the JSON +// ** text onto the end of pOut. Return the index in pParse->aBlob[] +// ** of the first byte past the end of the element that is translated. +// ** +// ** If an error is detected in the BLOB input, the pOut->eErr flag +// ** might get set to JSTRING_MALFORMED. But not all BLOB input errors +// ** are detected. So a malformed JSONB input might either result +// ** in an error, or in incorrect JSON. +// ** +// ** The pOut->eErr JSTRING_OOM flag is set on a OOM. +// */ +func _jsonTranslateBlobToText(tls *libc.TLS, pParse uintptr, i Tu32, pOut uintptr) (r Tu32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOverflow, x, v30, v31 int32 + var iEnd, j, k, k1, k2, n, sz2 Tu32 + var u Tsqlite3_uint64 + var zIn, zIn1, zIn2, v1 uintptr + var v25 Tu16 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bOverflow, iEnd, j, k, k1, k2, n, sz2, u, x, zIn, zIn1, zIn2, v1, v25, v30, v31 + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + return (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + uint32(1) + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case JSONB_NULL: + goto _2 + case int32(JSONB_TRUE): + goto _3 + case int32(JSONB_FALSE): + goto _4 + case int32(JSONB_FLOAT): + goto _5 + case int32(JSONB_INT): + goto _6 + case int32(JSONB_INT5): + goto _7 + case int32(JSONB_FLOAT5): + goto _8 + case int32(JSONB_TEXTJ): + goto _9 + case int32(JSONB_TEXT): + goto _10 + case int32(JSONB_TEXT5): + goto _11 + case int32(JSONB_TEXTRAW): + goto _12 + case int32(JSONB_ARRAY): + goto _13 + case int32(JSONB_OBJECT): + goto _14 + default: + goto _15 + } + goto _16 +_2: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+1690, uint32(4)) + return i + uint32(1) +_3: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+8178, uint32(4)) + return i + uint32(1) +_4: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+8183, uint32(5)) + return i + uint32(1) +_6: + ; +_5: + ; + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + _jsonAppendRaw(tls, pOut, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), **(**Tu32)(__ccgo_up(bp))) + goto _16 +_7: + ; /* Integer literal in hexadecimal notation */ + k = uint32(2) + u = uint64(0) + zIn = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + bOverflow = 0 + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn))) == int32('-') { + _jsonAppendChar(tls, pOut, uint8('-')) + k = k + 1 + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn))) == int32('+') { + k = k + 1 + } + } + for { + if !(k < **(**Tu32)(__ccgo_up(bp))) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zIn + uintptr(k))))])&libc.Int32FromInt32(0x08) != 0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } else { + if u>>libc.Int32FromInt32(60) != uint64(0) { + bOverflow = int32(1) + } else { + u = u*uint64(16) + uint64(_sqlite3HexToInt(tls, libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn + uintptr(k)))))) + } + } + goto _17 + _17: + ; + k = k + 1 + } + if bOverflow != 0 { + v1 = __ccgo_ts + 26412 + } else { + v1 = __ccgo_ts + 13004 + } + _jsonPrintf(tls, int32(100), pOut, v1, libc.VaList(bp+16, u)) + goto _16 +_8: + ; /* Float literal missing digits beside "." */ + k1 = uint32(0) + zIn1 = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn1))) == int32('-') { + _jsonAppendChar(tls, pOut, uint8('-')) + k1 = k1 + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn1 + uintptr(k1)))) == int32('.') { + _jsonAppendChar(tls, pOut, uint8('0')) + } + for { + if !(k1 < **(**Tu32)(__ccgo_up(bp))) { + break + } + _jsonAppendChar(tls, pOut, **(**uint8)(__ccgo_up(zIn1 + uintptr(k1)))) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn1 + uintptr(k1)))) == int32('.') && (k1+uint32(1) == **(**Tu32)(__ccgo_up(bp)) || !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zIn1 + uintptr(k1+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0)) { + _jsonAppendChar(tls, pOut, uint8('0')) + } + goto _20 + _20: + ; + k1 = k1 + 1 + } + goto _16 +_10: + ; +_9: + ; + if (*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(**(**Tu32)(__ccgo_up(bp)))+uint64(2) <= (*TJsonString)(unsafe.Pointer(pOut)).FnAlloc || _jsonStringGrow(tls, pOut, **(**Tu32)(__ccgo_up(bp))+uint32(2)) == 0 { + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pOut)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed))) = uint8('"') + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(pOut)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed)+uintptr(1), (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), uint64(**(**Tu32)(__ccgo_up(bp)))) + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pOut)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(**(**Tu32)(__ccgo_up(bp)))+uint64(1)))) = uint8('"') + **(**Tu64)(__ccgo_up(pOut + 24)) += uint64(**(**Tu32)(__ccgo_up(bp)) + uint32(2)) + } + goto _16 +_11: + ; + sz2 = **(**Tu32)(__ccgo_up(bp)) + zIn2 = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + _jsonAppendChar(tls, pOut, uint8('"')) + for sz2 > uint32(0) { + k2 = uint32(0) + for { + if !(k2 < sz2 && (_jsonIsOk[uint8(**(**uint8)(__ccgo_up(zIn2 + uintptr(k2))))] != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn2 + uintptr(k2)))) == int32('\''))) { + break + } + goto _21 + _21: + ; + k2 = k2 + 1 + } + if k2 > uint32(0) { + _jsonAppendRawNZ(tls, pOut, zIn2, k2) + if k2 >= sz2 { + break + } + zIn2 = zIn2 + uintptr(k2) + sz2 = sz2 - k2 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn2))) == int32('"') { + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26510, uint32(2)) + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + continue + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn2))) <= int32(0x1f) { + if (*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(7) > (*TJsonString)(unsafe.Pointer(pOut)).FnAlloc && _jsonStringGrow(tls, pOut, uint32(7)) != 0 { + break + } + _jsonAppendControlChar(tls, pOut, uint8(**(**uint8)(__ccgo_up(zIn2)))) + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + continue + } + if sz2 < uint32(2) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } + switch libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(zIn2 + 1)))) { + case int32('\''): + _jsonAppendChar(tls, pOut, uint8('\'')) + case int32('v'): + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26513, uint32(6)) + case int32('x'): + if sz2 < uint32(4) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + sz2 = uint32(2) + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26520, uint32(4)) + _jsonAppendRawNZ(tls, pOut, zIn2+2, uint32(2)) + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + case int32('0'): + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26525, uint32(6)) + case int32('\r'): + if sz2 > uint32(2) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn2 + 2))) == int32('\n') { + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + } + case int32('\n'): + case int32(0xe2): + /* '\' followed by either U+2028 or U+2029 is ignored as + ** whitespace. Not that in UTF8, U+2028 is 0xe2 0x80 0x29. + ** U+2029 is the same except for the last byte */ + if sz2 < uint32(4) || int32(0x80) != libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(zIn2 + 2)))) || int32(0xa8) != libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(zIn2 + 3)))) && int32(0xa9) != libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(zIn2 + 3)))) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + sz2 = uint32(2) + break + } + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + default: + _jsonAppendRawNZ(tls, pOut, zIn2, uint32(2)) + break + } + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + } + _jsonAppendChar(tls, pOut, uint8('"')) + goto _16 +_12: + ; + _jsonAppendString(tls, pOut, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), **(**Tu32)(__ccgo_up(bp))) + goto _16 +_13: + ; + _jsonAppendChar(tls, pOut, uint8('[')) + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + v1 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v25 = *(*Tu16)(unsafe.Pointer(v1)) + if libc.Int32FromUint16(v25) > int32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for j < iEnd && libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + _jsonAppendChar(tls, pOut, uint8(',')) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + } + if **(**Tu32)(__ccgo_up(bp)) > uint32(0) { + _jsonStringTrimOneChar(tls, pOut) + } + _jsonAppendChar(tls, pOut, uint8(']')) + goto _16 +_14: + ; + x = 0 + _jsonAppendChar(tls, pOut, uint8('{')) + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + v1 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v25 = *(*Tu16)(unsafe.Pointer(v1)) + if libc.Int32FromUint16(v25) > int32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for j < iEnd && libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + v31 = x + x = x + 1 + if v31&int32(1) != 0 { + v30 = int32(',') + } else { + v30 = int32(':') + } + _jsonAppendChar(tls, pOut, libc.Uint8FromInt32(v30)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if x&int32(1) != 0 || j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + } + if **(**Tu32)(__ccgo_up(bp)) > uint32(0) { + _jsonStringTrimOneChar(tls, pOut) + } + _jsonAppendChar(tls, pOut, uint8('}')) + goto _16 +_15: + ; + goto malformed_jsonb +malformed_jsonb: + ; + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + goto _16 +_16: + ; + return i + n + **(**Tu32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Translate a single element of JSON text at pParse->zJson[i] into +// ** its equivalent binary JSONB representation. Append the translation into +// ** pParse->aBlob[] beginning at pParse->nBlob. The size of +// ** pParse->aBlob[] is increased as necessary. +// ** +// ** Return the index of the first character past the end of the element parsed, +// ** or one of the following special result codes: +// ** +// ** 0 End of input +// ** -1 Syntax error or OOM +// ** -2 '}' seen ** -3 ']' seen \___ For these returns, pParse->iErr is set to +// ** -4 ',' seen / the index in zJson[] of the seen character +// ** -5 ':' seen / +// */ +func _jsonTranslateTextToBlob(tls *libc.TLS, pParse uintptr, i Tu32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, cDelim uint8 + var iBlob, iStart, iThis, j, k1, v46 Tu32 + var k, nn, x, v48 int32 + var opcode, seenE, t Tu8 + var z, v41 uintptr + var v40 Tu16 + var _ /* op at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, cDelim, iBlob, iStart, iThis, j, k, k1, nn, opcode, seenE, t, x, z, v40, v41, v46, v48 + z = (*TJsonParse)(unsafe.Pointer(pParse)).FzJson + goto json_parse_restart +json_parse_restart: + ; + switch libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(z + uintptr(i))))) { + case int32('{'): + goto _1 + case int32('['): + goto _2 + case int32('"'): + goto _3 + case int32('\''): + goto _4 + case int32('t'): + goto _5 + case int32('f'): + goto _6 + case int32('.'): + goto _7 + case int32('9'): + goto _8 + case int32('8'): + goto _9 + case int32('7'): + goto _10 + case int32('6'): + goto _11 + case int32('5'): + goto _12 + case int32('4'): + goto _13 + case int32('3'): + goto _14 + case int32('2'): + goto _15 + case int32('1'): + goto _16 + case int32('0'): + goto _17 + case int32('-'): + goto _18 + case int32('+'): + goto _19 + case int32('}'): + goto _20 + case int32(']'): + goto _21 + case int32(','): + goto _22 + case int32(':'): + goto _23 + case 0: + goto _24 + case int32(0x20): + goto _25 + case int32(0x0d): + goto _26 + case int32(0x0a): + goto _27 + case int32(0x09): + goto _28 + case int32(0xef): + goto _29 + case int32(0xe3): + goto _30 + case int32(0xe2): + goto _31 + case int32(0xe1): + goto _32 + case int32(0xc2): + goto _33 + case int32('/'): + goto _34 + case int32(0x0c): + goto _35 + case int32(0x0b): + goto _36 + case int32('n'): + goto _37 + default: + goto _38 + } + goto _39 +_1: + ; + /* Parse object */ + iThis = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_OBJECT), uint64(libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pParse)).FnJson)-i), uintptr(0)) + v41 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v41)) = *(*Tu16)(unsafe.Pointer(v41)) + 1 + v40 = *(*Tu16)(unsafe.Pointer(v41)) + if libc.Int32FromUint16(v40) > int32(JSON_MAX_DEPTH) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + iStart = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + j = i + uint32(1) + for { + iBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x == -int32(2) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob != iStart { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + break + } + j = j + libc.Uint32FromInt32(_json5Whitespace(tls, z+uintptr(j))) + **(**int32)(__ccgo_up(bp)) = int32(JSONB_TEXT) + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(j))))])&int32(0x42) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32('\\') && _jsonIs4HexB(tls, z+uintptr(j+uint32(1)), bp) != 0 { + k = libc.Int32FromUint32(j + uint32(1)) + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(k))))])&int32(0x46) != 0 && _json5Whitespace(tls, z+uintptr(k)) == 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(k)))) == int32('\\') && _jsonIs4HexB(tls, z+uintptr(k+int32(1)), bp) != 0 { + k = k + 1 + } + _jsonBlobAppendNode(tls, pParse, libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))), uint64(libc.Uint32FromInt32(k)-j), z+uintptr(j)) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + x = k + } else { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + } + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return -int32(1) + } + t = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iBlob)))) & int32(0x0f)) + if libc.Int32FromUint8(t) < int32(JSONB_TEXT) || libc.Int32FromUint8(t) > int32(JSONB_TEXTRAW) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32(':') { + j = j + 1 + } else { + if _jsonIsSpace[uint8(**(**uint8)(__ccgo_up(z + uintptr(j))))] != 0 { + /* strspn() is not helpful here */ + for cond := true; cond; cond = _jsonIsSpace[uint8(**(**uint8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32(':') { + j = j + 1 + goto parse_object_value + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x != -int32(5) { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + uint32(1) + } + goto parse_object_value + parse_object_value: + ; + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _42 + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32('}') { + break + } else { + if _jsonIsSpace[uint8(**(**uint8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(j+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _42 + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32('}') { + break + } + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x == -int32(4) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + goto _42 + } + if x == -int32(2) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + break + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + goto _42 + _42: + ; + j = j + 1 + } + _jsonBlobChangePayloadSize(tls, pParse, iThis, (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-iStart) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + return libc.Int32FromUint32(j + uint32(1)) +_2: + ; + /* Parse array */ + iThis = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_ARRAY), uint64(libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pParse)).FnJson)-i), uintptr(0)) + iStart = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return -int32(1) + } + v41 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v41)) = *(*Tu16)(unsafe.Pointer(v41)) + 1 + v40 = *(*Tu16)(unsafe.Pointer(v41)) + if libc.Int32FromUint16(v40) > int32(JSON_MAX_DEPTH) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + j = i + uint32(1) + for { + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x == -int32(3) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob != iStart { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + break + } + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _45 + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32(']') { + break + } else { + if _jsonIsSpace[uint8(**(**uint8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(j+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _45 + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) == int32(']') { + break + } + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x == -int32(4) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + goto _45 + } + if x == -int32(3) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + break + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + goto _45 + _45: + ; + j = j + 1 + } + _jsonBlobChangePayloadSize(tls, pParse, iThis, (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-iStart) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + return libc.Int32FromUint32(j + uint32(1)) +_4: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + opcode = uint8(JSONB_TEXT) + goto parse_string +_3: + ; + /* Parse string */ + opcode = uint8(JSONB_TEXT) + goto parse_string +parse_string: + ; + cDelim = **(**uint8)(__ccgo_up(z + uintptr(i))) + j = i + uint32(1) + for int32(1) != 0 { + if _jsonIsOk[uint8(**(**uint8)(__ccgo_up(z + uintptr(j))))] != 0 { + if !(_jsonIsOk[uint8(**(**uint8)(__ccgo_up(z + uintptr(j+uint32(1)))))] != 0) { + j = j + uint32(1) + } else { + if !(_jsonIsOk[uint8(**(**uint8)(__ccgo_up(z + uintptr(j+uint32(2)))))] != 0) { + j = j + uint32(2) + } else { + j = j + uint32(3) + continue + } + } + } + c = **(**uint8)(__ccgo_up(z + uintptr(j))) + if libc.Int32FromUint8(c) == libc.Int32FromUint8(cDelim) { + break + } else { + if libc.Int32FromUint8(c) == int32('\\') { + j = j + 1 + v46 = j + c = **(**uint8)(__ccgo_up(z + uintptr(v46))) + if libc.Int32FromUint8(c) == int32('"') || libc.Int32FromUint8(c) == int32('\\') || libc.Int32FromUint8(c) == int32('/') || libc.Int32FromUint8(c) == int32('b') || libc.Int32FromUint8(c) == int32('f') || libc.Int32FromUint8(c) == int32('n') || libc.Int32FromUint8(c) == int32('r') || libc.Int32FromUint8(c) == int32('t') || libc.Int32FromUint8(c) == int32('u') && _jsonIs4Hex(tls, z+uintptr(j+uint32(1))) != 0 { + if libc.Int32FromUint8(opcode) == int32(JSONB_TEXT) { + opcode = uint8(JSONB_TEXTJ) + } + } else { + if libc.Int32FromUint8(c) == int32('\'') || libc.Int32FromUint8(c) == int32('v') || libc.Int32FromUint8(c) == int32('\n') || libc.Int32FromUint8(c) == int32('0') && !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(j+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0) || int32(0xe2) == libc.Int32FromUint8(c) && int32(0x80) == libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(z + uintptr(j+uint32(1)))))) && (int32(0xa8) == libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(z + uintptr(j+uint32(2)))))) || int32(0xa9) == libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(z + uintptr(j+uint32(2))))))) || libc.Int32FromUint8(c) == int32('x') && _jsonIs2Hex(tls, z+uintptr(j+uint32(1))) != 0 { + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + if libc.Int32FromUint8(c) == int32('\r') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('\n') { + j = j + 1 + } + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + } + } else { + if libc.Int32FromUint8(c) <= int32(0x1f) { + if libc.Int32FromUint8(c) == 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + /* Control characters are not allowed in canonical JSON string + ** literals, but are allowed in JSON5 string literals. */ + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + if libc.Int32FromUint8(c) == int32('"') { + opcode = uint8(JSONB_TEXT5) + } + } + } + } + j = j + 1 + } + _jsonBlobAppendNode(tls, pParse, opcode, uint64(j-uint32(1)-i), z+uintptr(i+uint32(1))) + return libc.Int32FromUint32(j + uint32(1)) +_5: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+8178, uint64(4)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(4)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_TRUE)) + return libc.Int32FromUint32(i + uint32(4)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_6: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+8183, uint64(5)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(5)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_FALSE)) + return libc.Int32FromUint32(i + uint32(5)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_19: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x00) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + goto parse_number +_7: + ; + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x03) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + seenE = uint8(0) + goto parse_number_2 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_18: + ; +_17: + ; +_16: + ; +_15: + ; +_14: + ; +_13: + ; +_12: + ; +_11: + ; +_10: + ; +_9: + ; +_8: + ; + /* Parse number */ + t = uint8(0x00) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + goto parse_number +parse_number: + ; + seenE = uint8(0) + c = **(**uint8)(__ccgo_up(z + uintptr(i))) + if libc.Int32FromUint8(c) <= int32('0') { + if libc.Int32FromUint8(c) == int32('0') { + if (libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('x') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('X')) && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(2)))))])&int32(0x08) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x01) + j = i + uint32(3) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(j))))])&int32(0x08) != 0) { + break + } + goto _47 + _47: + ; + j = j + 1 + } + goto parse_number_finish + } else { + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + uint32(1) + return -int32(1) + } + } + } else { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0) { + /* JSON5 allows for "+Infinity" and "-Infinity" using exactly + ** that case. SQLite also allows these in any case and it allows + ** "+inf" and "-inf". */ + if (libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('I') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('i')) && Xsqlite3_strnicmp(tls, z+uintptr(i+uint32(1)), __ccgo_ts+26408, int32(3)) == 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('-') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(6), __ccgo_ts+26491) + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26498) + } + if Xsqlite3_strnicmp(tls, z+uintptr(i+uint32(4)), __ccgo_ts+26504, int32(5)) == 0 { + v48 = int32(9) + } else { + v48 = int32(4) + } + return libc.Int32FromUint32(i + libc.Uint32FromInt32(v48)) + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('.') { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + goto parse_number_2 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('0') { + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + uint32(1) + return -int32(1) + } else { + if (libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(2))))) == int32('x') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(2))))) == int32('X')) && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(3)))))])&int32(0x08) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + j = i + uint32(4) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(j))))])&int32(0x08) != 0) { + break + } + goto _49 + _49: + ; + j = j + 1 + } + goto parse_number_finish + } + } + } + } + } + goto parse_number_2 +parse_number_2: + ; + j = i + uint32(1) + for { + c = **(**uint8)(__ccgo_up(z + uintptr(j))) + if libc.Int32FromUint8(_sqlite3CtypeMap[c])&int32(0x04) != 0 { + goto _50 + } + if libc.Int32FromUint8(c) == int32('.') { + if libc.Int32FromUint8(t)&int32(0x02) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x02)) + goto _50 + } + if libc.Int32FromUint8(c) == int32('e') || libc.Int32FromUint8(c) == int32('E') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-uint32(1))))) < int32('0') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-uint32(1))))) == int32('.') && j-uint32(2) >= i && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(j-uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + if seenE != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x02)) + seenE = uint8(1) + c = **(**uint8)(__ccgo_up(z + uintptr(j+uint32(1)))) + if libc.Int32FromUint8(c) == int32('+') || libc.Int32FromUint8(c) == int32('-') { + j = j + 1 + c = **(**uint8)(__ccgo_up(z + uintptr(j+uint32(1)))) + } + if libc.Int32FromUint8(c) < int32('0') || libc.Int32FromUint8(c) > int32('9') { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + goto _50 + } + break + goto _50 + _50: + ; + j = j + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-uint32(1))))) < int32('0') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-uint32(1))))) == int32('.') && j-uint32(2) >= i && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(j-uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + goto parse_number_finish +parse_number_finish: + ; + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('+') { + i = i + 1 + } + _jsonBlobAppendNode(tls, pParse, libc.Uint8FromInt32(int32(JSONB_INT)+libc.Int32FromUint8(t)), uint64(j-i), z+uintptr(i)) + return libc.Int32FromUint32(j) +_20: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(2) /* End of {...} */ +_21: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(3) /* End of [...] */ +_22: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(4) /* List separator */ +_23: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(5) /* Object label/value separator */ +_24: + ; + return 0 /* End of file */ +_28: + ; +_27: + ; +_26: + ; +_25: + ; + i = i + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(i+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + goto json_parse_restart +_36: + ; +_35: + ; +_34: + ; +_33: + ; +_32: + ; +_31: + ; +_30: + ; +_29: + ; + j = libc.Uint32FromInt32(_json5Whitespace(tls, z+uintptr(i))) + if j > uint32(0) { + i = i + j + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + goto json_parse_restart + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_37: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+1690, uint64(4)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+uint32(4)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_NULL)) + return libc.Int32FromUint32(i + uint32(4)) + } + /* fall-through into the default case that checks for NaN */ +_38: + ; + c = **(**uint8)(__ccgo_up(z + uintptr(i))) + k1 = uint32(0) + for { + if !(uint64(k1) < libc.Uint64FromInt64(120)/libc.Uint64FromInt64(24)) { + break + } + if libc.Int32FromUint8(c) != libc.Int32FromUint8(_aNanInfName[k1].Fc1) && libc.Int32FromUint8(c) != libc.Int32FromUint8(_aNanInfName[k1].Fc2) { + goto _51 + } + nn = libc.Int32FromUint8(_aNanInfName[k1].Fn) + if Xsqlite3_strnicmp(tls, z+uintptr(i), _aNanInfName[k1].FzMatch, nn) != 0 { + goto _51 + } + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i+libc.Uint32FromInt32(nn)))))])&int32(0x06) != 0 { + goto _51 + } + if libc.Int32FromUint8(_aNanInfName[k1].FeType) == int32(JSONB_FLOAT) { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26498) + } else { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_NULL)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + return libc.Int32FromUint32(i + libc.Uint32FromInt32(nn)) + goto _51 + _51: + ; + k1 = k1 + 1 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) /* Syntax error */ +_39: + ; /* End switch(z[i]) */ + return r +} + +// C documentation +// +// /* +// ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up +// ** that name in the set of source tables in pSrcList and make the pExpr +// ** expression node refer back to that source column. The following changes +// ** are made to pExpr: +// ** +// ** pExpr->iDb Set the index in db->aDb[] of the database X +// ** (even if X is implied). +// ** pExpr->iTable Set to the cursor number for the table obtained +// ** from pSrcList. +// ** pExpr->y.pTab Points to the Table structure of X.Y (even if +// ** X and/or Y are implied.) +// ** pExpr->iColumn Set to the column number within the table. +// ** pExpr->op Set to TK_COLUMN. +// ** pExpr->pLeft Any expression this points to is deleted +// ** pExpr->pRight Any expression this points to is deleted. +// ** +// ** The zDb variable is the name of the database (the "X"). This value may be +// ** NULL meaning that name is of the form Y.Z or Z. Any available database +// ** can be used. The zTable variable is the name of the table (the "Y"). This +// ** value can be NULL if zDb is also NULL. If zTable is NULL it +// ** means that the form of the name is Z and that columns from any table +// ** can be used. +// ** +// ** If the name cannot be resolved unambiguously, leave an error message +// ** in pParse and return WRC_Abort. Return WRC_Prune on success. +// */ +func _lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, pRight uintptr, pNC uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var cnt, cntTab, eNewExprOp, hit, i, iCol, j, nSubquery, op, v4 int32 + var db, pEList, pItem, pMatch, pOrig, pSchema, pSel, pSrcList, pTab, pTopNC, pUpsert, zAs, zCol, zErr, v8 uintptr + var v5 uint32 + var _ /* bRowid at bp+8 */ int32 + var _ /* pFJMatch at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cnt, cntTab, db, eNewExprOp, hit, i, iCol, j, nSubquery, op, pEList, pItem, pMatch, pOrig, pSchema, pSel, pSrcList, pTab, pTopNC, pUpsert, zAs, zCol, zErr, v4, v5, v8 /* Loop counters */ + cnt = 0 /* Number of matching column names */ + cntTab = 0 /* Number of potential "rowid" matches */ + nSubquery = 0 /* How many levels of subquery */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Use for looping over pSrcList items */ + pMatch = uintptr(0) /* The matching pSrcList item */ + pTopNC = pNC /* First namecontext in the list */ + pSchema = uintptr(0) /* Schema of the expression */ + eNewExprOp = int32(TK_COLUMN) /* New value for pExpr->op on success */ + pTab = uintptr(0) /* Table holding the row */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Matches for FULL JOIN .. USING */ + zCol = *(*uintptr)(unsafe.Pointer(pRight + 8)) + /* the name context cannot be NULL. */ + /* The Z in X.Y.Z cannot be NULL */ + /* Initialize the node to no-match */ + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = -int32(1) + /* Translate the schema name in zDb into a pointer to the corresponding + ** schema. If not found, pSchema will remain NULL and nothing will match + ** resulting in an appropriate error message toward the end of this routine + */ + if zDb != 0 { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_IsCheck)) != 0 { + /* Silently ignore database qualifiers inside CHECK constraints and + ** partial indices. Do not raise errors because that might break + ** legacy and because it does not hurt anything to just ignore the + ** database name. */ + zDb = uintptr(0) + } else { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if _sqlite3StrICmp(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName, zDb) == 0 { + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i == (*Tsqlite3)(unsafe.Pointer(db)).FnDb && _sqlite3StrICmp(tls, __ccgo_ts+6816, zDb) == 0 { + /* This branch is taken when the main database has been renamed + ** using SQLITE_DBCONFIG_MAINDBNAME. */ + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName + } + } + } + /* Start at the inner-most context and move outward until a match is found */ + for cond := true; cond; cond = pNC != 0 { + pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + if pSrcList != 0 { + i = 0 + pItem = pSrcList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc) { + break + } + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { + /* In this case, pItem is a subquery that has been formed from a + ** parenthesized subset of the FROM clause terms. Example: + ** .... FROM t1 LEFT JOIN (t2 RIGHT JOIN t3 USING(x)) USING(y) ... + ** \_________________________/ + ** This pItem -------------^ + */ + hit = 0 + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + pEList = (*TSelect)(unsafe.Pointer(pSel)).FpEList + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + **(**int32)(__ccgo_up(bp + 8)) = 0 /* True if possible rowid match */ + if !(_sqlite3MatchEName(tls, pEList+8+uintptr(j)*32, zCol, zTab, zDb, bp+8) != 0) { + goto _3 + } + if **(**int32)(__ccgo_up(bp + 8)) == 0 { + if cnt > 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 64)), zCol) < 0 || pMatch == pItem { + /* Two or more tables have the same column name which is + ** not joined by USING. Or, a single table has two columns + ** that match a USING term (if pMatch==pItem). These are both + ** "ambiguous column name" errors. Signal as much by clearing + ** pFJMatch and letting cnt go above 1. */ + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + /* An INNER or LEFT JOIN. Use the left-most table */ + goto _3 + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) == 0 { + /* A RIGHT JOIN. Use the right-most table */ + cnt = 0 + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + /* For a FULL JOIN, we must construct a coalesce() func */ + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + } + } + } + } + cnt = cnt + 1 + hit = int32(1) + } else { + if cnt > 0 { + /* This is a potential rowid match, but there has already been + ** a real match found. So this can be ignored. */ + goto _3 + } + } + cntTab = cntTab + 1 + pMatch = pItem + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(j) + libc.SetBitFieldPtr16Uint32(pEList+8+uintptr(j)*32+16+4, libc.Uint32FromInt32(1), 6, 0x40) + /* rowid cannot be part of a USING clause - assert() this. */ + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 16 + 4))&0x80>>7)) != 0 { + break + } + goto _3 + _3: + ; + j = j + 1 + } + if hit != 0 || zTab == uintptr(0) { + goto _2 + } + } + if zTab != 0 { + if zDb != 0 { + if (*TTable)(unsafe.Pointer(pTab)).FpSchema != pSchema { + goto _2 + } + if pSchema == uintptr(0) && libc.Xstrcmp(tls, zDb, __ccgo_ts+6821) != 0 { + goto _2 + } + } + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != uintptr(0) { + if _sqlite3StrICmp(tls, zTab, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) != 0 { + goto _2 + } + } else { + if _sqlite3StrICmp(tls, zTab, (*TTable)(unsafe.Pointer(pTab)).FzName) != 0 { + if (*TTable)(unsafe.Pointer(pTab)).Ftnum != uint32(1) { + goto _2 + } + if !(_isValidSchemaTableName(tls, zTab, pTab, zDb) != 0) { + goto _2 + } + } + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr+64) + } + } + j = _sqlite3ColumnIndex(tls, pTab, zCol) + if j >= 0 { + if cnt > 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 64)), zCol) < 0 { + /* Two or more tables have the same column name which is + ** not joined by USING. This is an error. Signal as much + ** by clearing pFJMatch and letting cnt go above 1. */ + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + /* An INNER or LEFT JOIN. Use the left-most table */ + goto _2 + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) == 0 { + /* A RIGHT JOIN. Use the right-most table */ + cnt = 0 + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + /* For a FULL JOIN, we must construct a coalesce() func */ + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + } + } + } + } + cnt = cnt + 1 + pMatch = pItem + /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + v4 = -int32(1) + } else { + v4 = int32(int16(j)) + } + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(v4) + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { + _sqlite3SrcItemColumnUsed(tls, pItem, j) + } + } + if 0 == cnt && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) { + /* pTab is a potential ROWID match. Keep track of it and match + ** the ROWID later if that seems appropriate. (Search for "cntTab" + ** to find related code.) Only allow a ROWID match if there is + ** a single ROWID match candidate. + */ + /* The (much more common) non-SQLITE_ALLOW_ROWID_IN_VIEW case is + ** simpler since we require exactly one candidate, which will + ** always be a non-VIEW + */ + cntTab = cntTab + 1 + pMatch = pItem + } + goto _2 + _2: + ; + i = i + 1 + pItem += 80 + } + if pMatch != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSrcItem)(unsafe.Pointer(pMatch)).FiCursor + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pMatch)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + pSchema = (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpSchema + } + } /* if( pSrcList ) */ + /* If we have not already resolved the name, then maybe + ** it is a new.* or old.* trigger argument reference. Or + ** maybe it is an excluded.* from an upsert. Or maybe it is + ** a reference in the RETURNING clause to a table being modified. + */ + if cnt == 0 && zDb == uintptr(0) { + pTab = uintptr(0) + if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != uintptr(0) { + op = libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeTriggerOp) + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UBaseReg) != 0 && (zTab == uintptr(0) || _sqlite3StrICmp(tls, zTab, (*TTable)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).FpTriggerTab)).FzName) == 0 || _isValidSchemaTableName(tls, zTab, (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab, uintptr(0)) != 0) { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = libc.BoolInt32(op != int32(TK_DELETE)) + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } + } else { + if op != int32(TK_DELETE) && zTab != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6823, zTab) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = int32(1) + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } else { + if op != int32(TK_INSERT) && zTab != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6827, zTab) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = 0 + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } + } + } + } + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UUpsert) != 0 && zTab != uintptr(0) { + pUpsert = *(*uintptr)(unsafe.Pointer(pNC + 16)) + if pUpsert != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6831, zTab) == 0 { + pTab = (*(*TSrcItem)(unsafe.Pointer((*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8))).FpSTab + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = int32(EXCLUDED_TABLE_NUMBER) + } + } + if pTab != 0 { + pSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + cntTab = cntTab + 1 + iCol = _sqlite3ColumnIndex(tls, pTab, zCol) + if iCol >= 0 { + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) == iCol { + iCol = -int32(1) + } + } else { + if _sqlite3IsRowid(tls, zCol) != 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) { + iCol = -int32(1) + } else { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } + } + if iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + cnt = cnt + 1 + pMatch = uintptr(0) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == int32(EXCLUDED_TABLE_NUMBER) { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab + eNewExprOp = int32(TK_COLUMN) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TUpsert)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNC + 16)))).FregData + int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + eNewExprOp = int32(TK_REGISTER) + } + } else { + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { + eNewExprOp = int32(TK_REGISTER) + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = uint8(TK_COLUMN) + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = *(*int32)(unsafe.Pointer(&(*TNameContext)(unsafe.Pointer(pNC)).FuNC)) + (int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1))*(*TExpr)(unsafe.Pointer(pExpr)).FiTable + int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + int32(1) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + eNewExprOp = int32(TK_TRIGGER) + if iCol < 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == 0 { + if iCol >= int32(32) { + v5 = uint32(0xffffffff) + } else { + v5 = libc.Uint32FromInt32(1) << iCol + } + **(**Tu32)(__ccgo_up(pParse + 240)) |= v5 + } else { + if iCol >= int32(32) { + v5 = uint32(0xffffffff) + } else { + v5 = libc.Uint32FromInt32(1) << iCol + } + **(**Tu32)(__ccgo_up(pParse + 244)) |= v5 + } + } + } + } + } + } + } + /* + ** Perhaps the name is a reference to the ROWID + */ + if cnt == 0 && cntTab >= int32(1) && pMatch != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) == 0 && _sqlite3IsRowid(tls, zCol) != 0 && ((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) || int32(*(*uint32)(unsafe.Pointer(pMatch + 24 + 4))&0x4000>>14) != 0) { + cnt = cntTab + if int32(*(*uint32)(unsafe.Pointer(pMatch + 24 + 4))&0x4000>>14) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(-int32(1)) + } + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER) + } + /* + ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z + ** might refer to an result-set alias. This happens, for example, when + ** we are resolving names in the WHERE clause of the following command: + ** + ** SELECT a+b AS x FROM table WHERE x<10; + ** + ** In cases like this, replace pExpr with a copy of the expression that + ** forms the result set entry ("a+b" in the example) and return immediately. + ** Note that the expression in the result set should have already been + ** resolved by the time the WHERE clause is resolved. + ** + ** The ability to use an output result-set column in the WHERE, GROUP BY, + ** or HAVING clauses, or as part of a larger expression in the ORDER BY + ** clause is not standard SQL. This is a (goofy) SQLite extension, that + ** is supported for backwards compatibility only. Hence, we issue a warning + ** on sqlite3_log() whenever the capability is used. + */ + if cnt == 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UEList) != 0 && zTab == uintptr(0) { + pEList = *(*uintptr)(unsafe.Pointer(pNC + 16)) + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + zAs = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*32))).FzEName + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME && Xsqlite3_stricmp(tls, zAs, zCol) == 0 { + pOrig = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*32))).FpExpr + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowAgg) == 0 && (*TExpr)(unsafe.Pointer(pOrig)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Agg)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6840, libc.VaList(bp+24, zAs)) + return int32(WRC_Abort) + } + if (*TExpr)(unsafe.Pointer(pOrig)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Win)) != uint32(0) && ((*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowWin) == 0 || pNC != pTopNC) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6871, libc.VaList(bp+24, zAs)) + return int32(WRC_Abort) + } + if _sqlite3ExprVectorSize(tls, pOrig) != int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6908, 0) + return int32(WRC_Abort) + } + _resolveAlias(tls, pParse, pEList, j, pExpr, nSubquery) + cnt = int32(1) + pMatch = uintptr(0) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) + } + goto lookupname_end + } + goto _7 + _7: + ; + j = j + 1 + } + } + /* Advance to the next name context. The loop will exit when either + ** we have a match (cnt>0) or when we run out of name contexts. + */ + if cnt != 0 { + break + } + pNC = (*TNameContext)(unsafe.Pointer(pNC)).FpNext + nSubquery = nSubquery + 1 + } + /* + ** If X and Y are NULL (in other words if only the column name Z is + ** supplied) and the value of Z is enclosed in double-quotes, then + ** Z is a string literal if it doesn't match any column names. In that + ** case, we need to return right away and not make any changes to + ** pExpr. + ** + ** Because no reference was made to outer contexts, the pNC->nRef + ** fields are not changed in any context. + */ + if cnt == 0 && zTab == uintptr(0) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_DblQuoted)) != uint32(0) && _areDoubleQuotedStringsEnabled(tls, db, pTopNC) != 0 { + /* If a double-quoted identifier does not match any known column name, + ** then treat it as a string. + ** + ** This hack was added in the early days of SQLite in a misguided attempt + ** to be compatible with MySQL 3.x, which used double-quotes for strings. + ** I now sorely regret putting in this hack. The effect of this hack is + ** that misspelled identifier names are silently converted into strings + ** rather than causing an error, to the frustration of countless + ** programmers. To all those frustrated programmers, my apologies. + ** + ** Someday, I hope to get rid of this hack. Unfortunately there is + ** a huge amount of legacy SQL that uses it. So for now, we just + ** issue a warning. + */ + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+6926, libc.VaList(bp+24, zCol)) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_STRING) + libc.Xmemset(tls, pExpr+64, 0, uint64(8)) + return int32(WRC_Prune) + } + if _sqlite3ExprIdToTrueFalse(tls, pExpr) != 0 { + return int32(WRC_Prune) + } + } + /* + ** cnt==0 means there was not match. + ** cnt>1 means there were two or more matches. + ** + ** cnt==0 is always an error. cnt>1 is often an error, but might + ** be multiple matches for a NATURAL LEFT JOIN or a LEFT JOIN USING. + */ + if cnt != int32(1) { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + if (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr == cnt-int32(1) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) != uint32(0) { + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) + } else { + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) + } + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_FUNCTION) + *(*uintptr)(unsafe.Pointer(pExpr + 8)) = __ccgo_ts + 6961 + *(*uintptr)(unsafe.Pointer(pExpr + 32)) = **(**uintptr)(__ccgo_up(bp)) + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_DEFER) + cnt = int32(1) + goto lookupname_end + } else { + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + if cnt == 0 { + v8 = __ccgo_ts + 6970 + } else { + v8 = __ccgo_ts + 6985 + } + zErr = v8 + if zDb != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7007, libc.VaList(bp+24, zErr, zDb, zTab, zCol)) + } else { + if zTab != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7020, libc.VaList(bp+24, zErr, zTab, zCol)) + } else { + if cnt == 0 && (*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_DblQuoted)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7030, libc.VaList(bp+24, zErr, zCol)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7091, libc.VaList(bp+24, zErr, zCol)) + } + } + } + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + (*TNameContext)(unsafe.Pointer(pTopNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pTopNC)).FnNcErr + 1 + eNewExprOp = int32(TK_NULL) + } + /* Remove all substructure from pExpr */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)) { + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) + } + /* If a column from a table in pSrcList is referenced, then record + ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes + ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is + ** set if the 63rd or any subsequent column is used. + ** + ** The colUsed mask is an optimization used to help determine if an + ** index is a covering index. The correct answer is still obtained + ** if the mask contains extra set bits. However, it is important to + ** avoid setting bits beyond the maximum column number of the table. + ** (See ticket [b92e5e8ec2cdbaa1]). + ** + ** If a generated column is referenced, set bits for every column + ** of the table. + */ + if pMatch != 0 { + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 { + **(**TBitmask)(__ccgo_up(pMatch + 40)) |= _sqlite3ExprColUsed(tls, pExpr) + } else { + libc.SetBitFieldPtr32Uint32(pMatch+24+4, libc.Uint32FromInt32(1), 15, 0x8000) + } + } + (*TExpr)(unsafe.Pointer(pExpr)).Fop = libc.Uint8FromInt32(eNewExprOp) + goto lookupname_end +lookupname_end: + ; + if cnt == int32(1) { + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FxAuth != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_TRIGGER)) { + _sqlite3AuthRead(tls, pParse, pExpr, pSchema, (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList) + } + /* Increment the nRef value on all name contexts from TopNC up to + ** the point where the name matched. */ + for { + (*TNameContext)(unsafe.Pointer(pTopNC)).FnRef = (*TNameContext)(unsafe.Pointer(pTopNC)).FnRef + 1 + if pTopNC == pNC { + break + } + pTopNC = (*TNameContext)(unsafe.Pointer(pTopNC)).FpNext + goto _9 + _9: + } + return int32(WRC_Prune) + } else { + return int32(WRC_Abort) + } + return r +} + +// C documentation +// +// /* +// ** Open a file descriptor to the directory containing file zFilename. +// ** If successful, *pFd is set to the opened file descriptor and +// ** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM +// ** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined +// ** value. +// ** +// ** The directory file descriptor is used for only one thing - to +// ** fsync() a directory to make sure file creation and deletion events +// ** are flushed to disk. Such fsyncs are not needed on newer +// ** journaling filesystems, but are required on older filesystems. +// ** +// ** This routine can be overridden using the xSetSysCall interface. +// ** The ability to override this routine was added in support of the +// ** chromium sandbox. Opening a directory is a security risk (we are +// ** told) so making it overrideable allows the chromium sandbox to +// ** replace this routine with a harmless no-op. To make this routine +// ** a no-op, replace it with a stub that returns SQLITE_OK but leaves +// ** *pFd set to a negative number. +// ** +// ** If SQLITE_OK is returned, the caller is responsible for closing +// ** the file descriptor *pFd using close(). +// */ +func _openDirectory(tls *libc.TLS, zFilename uintptr, pFd uintptr) (r int32) { + bp := tls.Alloc(544) + defer tls.Free(544) + var fd, ii int32 + var _ /* zDirname at bp+0 */ [513]uint8 + _, _ = fd, ii + fd = -int32(1) + Xsqlite3_snprintf(tls, int32(MAX_PATHNAME), bp, __ccgo_ts+3944, libc.VaList(bp+528, zFilename)) + ii = libc.Int32FromUint64(libc.Xstrlen(tls, bp)) + for { + if !(ii > 0 && libc.Int32FromUint8((**(**[513]uint8)(__ccgo_up(bp)))[ii]) != int32('/')) { + break + } + goto _1 + _1: + ; + ii = ii - 1 + } + if ii > 0 { + (**(**[513]uint8)(__ccgo_up(bp)))[ii] = uint8('\000') + } else { + if libc.Int32FromUint8((**(**[513]uint8)(__ccgo_up(bp)))[0]) != int32('/') { + (**(**[513]uint8)(__ccgo_up(bp)))[0] = uint8('.') + } + (**(**[513]uint8)(__ccgo_up(bp)))[int32(1)] = uint8(0) + } + fd = _robust_open(tls, bp, libc.Int32FromInt32(O_RDONLY)|libc.Int32FromInt32(O_BINARY), uint32(0)) + if fd >= 0 { + } + **(**int32)(__ccgo_up(pFd)) = fd + if fd >= 0 { + return SQLITE_OK + } + return _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(44080)), __ccgo_ts+3659, bp, int32(44080)) +} + +// C documentation +// +// /* +// ** Playback the journal and thus restore the database file to +// ** the state it was in before we started making changes. +// ** +// ** The journal file format is as follows: +// ** +// ** (1) 8 byte prefix. A copy of aJournalMagic[]. +// ** (2) 4 byte big-endian integer which is the number of valid page records +// ** in the journal. If this value is 0xffffffff, then compute the +// ** number of page records from the journal size. +// ** (3) 4 byte big-endian integer which is the initial value for the +// ** sanity checksum. +// ** (4) 4 byte integer which is the number of pages to truncate the +// ** database to during a rollback. +// ** (5) 4 byte big-endian integer which is the sector size. The header +// ** is this many bytes in size. +// ** (6) 4 byte big-endian integer which is the page size. +// ** (7) zero padding out to the next sector size. +// ** (8) Zero or more pages instances, each as follows: +// ** + 4 byte page number. +// ** + pPager->pageSize bytes of data. +// ** + 4 byte checksum +// ** +// ** When we speak of the journal header, we mean the first 7 items above. +// ** Each entry in the journal is an instance of the 8th item. +// ** +// ** Call the value from the second bullet "nRec". nRec is the number of +// ** valid page entries in the journal. In most cases, you can compute the +// ** value of nRec from the size of the journal file. But if a power +// ** failure occurred while the journal was being written, it could be the +// ** case that the size of the journal file had already been increased but +// ** the extra entries had not yet made it safely to disk. In such a case, +// ** the value of nRec computed from the file size would be too large. For +// ** that reason, we always use the nRec value in the header. +// ** +// ** If the nRec value is 0xffffffff it means that nRec should be computed +// ** from the file size. This value is used when the user selects the +// ** no-sync option for the journal. A power failure could lead to corruption +// ** in this case. But for things like temporary table (which will be +// ** deleted when the power is restored) we don't care. +// ** +// ** If the file opened as the journal file is not a well-formed +// ** journal file then all pages up to the first corrupted page are rolled +// ** back (or no pages if the journal header is corrupted). The journal file +// ** is then deleted and SQLITE_OK returned, just as if no corruption had +// ** been encountered. +// ** +// ** If an I/O or malloc() error occurs, the journal-file is not deleted +// ** and an error code is returned. +// ** +// ** The isHot parameter indicates that we are trying to rollback a journal +// ** that might be a hot journal. Or, it could be that the journal is +// ** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE. +// ** If the journal really is hot, reset the pager cache prior rolling +// ** back any content. If the journal is merely persistent, no reset is +// ** needed. +// */ +func _pager_playback(tls *libc.TLS, pPager uintptr, isHot int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var nPlayback, needPagerReset, rc int32 + var pVfs, zSuper uintptr + var u Tu32 + var _ /* mxPg at bp+12 */ TPgno + var _ /* nRec at bp+8 */ Tu32 + var _ /* res at bp+16 */ int32 + var _ /* savedPageSize at bp+20 */ Tu32 + var _ /* szJ at bp+0 */ Ti64 + _, _, _, _, _, _ = nPlayback, needPagerReset, pVfs, rc, u, zSuper + pVfs = (*TPager)(unsafe.Pointer(pPager)).FpVfs /* Unsigned loop counter */ + **(**TPgno)(__ccgo_up(bp + 12)) = uint32(0) /* Result code of a subroutine */ + **(**int32)(__ccgo_up(bp + 16)) = int32(1) /* Value returned by sqlite3OsAccess() */ + zSuper = uintptr(0) /* True to reset page prior to first page rollback */ + nPlayback = 0 /* Total number of pages restored from journal */ + **(**Tu32)(__ccgo_up(bp + 20)) = libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) + /* Figure out how many records are in the journal. Abort early if + ** the journal is empty. + */ + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp) + if rc != SQLITE_OK { + goto end_playback + } + /* Read the super-journal name from the journal, if it is present. + ** If a super-journal file name is specified, but the file is not + ** present on disk, then the journal is not hot and does not need to be + ** played back. + ** + ** TODO: Technically the following is an error because it assumes that + ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that + ** ((pPager->pageSize+8) >= pPager->pVfs->mxPathname+1). Using os_unix.c, + ** mxPathname is 512, which is the same as the minimum allowable value + ** for pageSize, and so this assumption holds. But it might not for some + ** custom VFS. */ + zSuper = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace + rc = _readSuperJournal(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, zSuper, libc.Uint64FromInt64(int64(1)+int64((*Tsqlite3_vfs)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).FpVfs)).FmxPathname))) + if rc == SQLITE_OK && **(**uint8)(__ccgo_up(zSuper)) != 0 { + rc = _sqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+16) + } + zSuper = uintptr(0) + if rc != SQLITE_OK || !(**(**int32)(__ccgo_up(bp + 16)) != 0) { + goto end_playback + } + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + needPagerReset = isHot + /* This loop terminates either when a readJournalHdr() or + ** pager_playback_one_page() call returns SQLITE_DONE or an IO error + ** occurs. + */ + for int32(1) != 0 { + /* Read the next journal header from the journal file. If there are + ** not enough bytes left in the journal file for a complete header, or + ** it is corrupted, then a process must have failed while writing it. + ** This indicates nothing more needs to be rolled back. + */ + rc = _readJournalHdr(tls, pPager, isHot, **(**Ti64)(__ccgo_up(bp)), bp+8, bp+12) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + goto end_playback + } + /* If nRec is 0xffffffff, then this journal was created by a process + ** working in no-sync mode. This means that the rest of the journal + ** file consists of pages, there are no more journal headers. Compute + ** the value of nRec based on this assumption. + */ + if **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0xffffffff) { + **(**Tu32)(__ccgo_up(bp + 8)) = libc.Uint32FromInt32(int32((**(**Ti64)(__ccgo_up(bp)) - libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize)) / ((*TPager)(unsafe.Pointer(pPager)).FpageSize + libc.Int64FromInt32(8)))) + } + /* If nRec is 0 and this rollback is of a transaction created by this + ** process and if this is the final header in the journal, then it means + ** that this part of the journal was being filled but has not yet been + ** synced to disk. Compute the number of pages based on the remaining + ** size of the file. + ** + ** The third term of the test was added to fix ticket #2565. + ** When rolling back a hot journal, nRec==0 always means that the next + ** chunk of the journal contains zero pages to be rolled back. But + ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in + ** the journal, it means that the journal might contain additional + ** pages that need to be rolled back and that the number of pages + ** should be computed based on the journal file size. + */ + if **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0) && !(isHot != 0) && (*TPager)(unsafe.Pointer(pPager)).FjournalHdr+libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) == (*TPager)(unsafe.Pointer(pPager)).FjournalOff { + **(**Tu32)(__ccgo_up(bp + 8)) = libc.Uint32FromInt32(int32((**(**Ti64)(__ccgo_up(bp)) - (*TPager)(unsafe.Pointer(pPager)).FjournalOff) / ((*TPager)(unsafe.Pointer(pPager)).FpageSize + libc.Int64FromInt32(8)))) + } + /* If this is the first header read from the journal, truncate the + ** database file back to its original size. + */ + if (*TPager)(unsafe.Pointer(pPager)).FjournalOff == libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) { + rc = _pager_truncate(tls, pPager, **(**TPgno)(__ccgo_up(bp + 12))) + if rc != SQLITE_OK { + goto end_playback + } + (*TPager)(unsafe.Pointer(pPager)).FdbSize = **(**TPgno)(__ccgo_up(bp + 12)) + if (*TPager)(unsafe.Pointer(pPager)).FmxPgno < **(**TPgno)(__ccgo_up(bp + 12)) { + (*TPager)(unsafe.Pointer(pPager)).FmxPgno = **(**TPgno)(__ccgo_up(bp + 12)) + } + } + /* Copy original pages out of the journal and back into the + ** database file and/or page cache. + */ + u = uint32(0) + for { + if !(u < **(**Tu32)(__ccgo_up(bp + 8))) { + break + } + if needPagerReset != 0 { + _pager_reset(tls, pPager) + needPagerReset = 0 + } + rc = _pager_playback_one_page(tls, pPager, pPager+96, uintptr(0), int32(1), 0) + if rc == SQLITE_OK { + nPlayback = nPlayback + 1 + } else { + if rc == int32(SQLITE_DONE) { + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = **(**Ti64)(__ccgo_up(bp)) + break + } else { + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)<= int32(PAGER_WRITER_DBMOD) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) { + rc = _sqlite3PagerSync(tls, pPager, uintptr(0)) + } + if rc == SQLITE_OK { + rc = _pager_end_transaction(tls, pPager, libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSuper))) != int32('\000')), 0) + } + if rc == SQLITE_OK && **(**uint8)(__ccgo_up(zSuper)) != 0 && **(**int32)(__ccgo_up(bp + 16)) != 0 { + /* If there was a super-journal and this routine will return success, + ** see if it is possible to delete the super-journal. + */ + libc.Xmemset(tls, (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace, 0, uint64(4)) + rc = _pager_delsuper(tls, pPager, zSuper) + } + if isHot != 0 && nPlayback != 0 { + Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_NOTICE)|libc.Int32FromInt32(2)< int32(1) { + return int32(1) + } /* IMP: R-33611-57934 */ + _autoAdjustDate(tls, p) + rc = 0 + } + case int32('c'): + /* + ** ceiling + ** + ** Resolve day-of-month overflow by rolling forward into the next + ** month. As this is the default action, this modifier is really + ** a no-op that is only included for symmetry. See "floor". + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1277) == 0 { + _computeJD(tls, p) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + (*TDateTime)(unsafe.Pointer(p)).FnFloor = uint8(0) + } + case int32('f'): + /* + ** floor + ** + ** Resolve day-of-month overflow by rolling back to the end of the + ** previous month. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1285) == 0 { + _computeJD(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) -= int64(libc.Int32FromUint8((*TDateTime)(unsafe.Pointer(p)).FnFloor) * int32(86400000)) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + } + case int32('j'): + /* + ** julianday + ** + ** Always interpret the prior number as a julian-day value. If this + ** is not the first modifier, or if the prior argument is not a numeric + ** value in the allowed range of julian day numbers understood by + ** SQLite (0..5373484.5) then the result will be NULL. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1291) == 0 { + if idx > int32(1) { + return int32(1) + } /* IMP: R-31176-64601 */ + if (*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0 && int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { + rc = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + } + } + case int32('l'): + /* localtime + ** + ** Assuming the current time value is UTC (a.k.a. GMT), shift it to + ** show local time. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1301) == 0 && _sqlite3NotPureFunc(tls, pCtx) != 0 { + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x10>>4)) != 0 { + v1 = SQLITE_OK + } else { + v1 = _toLocaltime(tls, p, pCtx) + } + rc = v1 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 4, 0x10) + } + case int32('u'): + /* + ** unixepoch + ** + ** Treat the current value of p->s as the number of + ** seconds since 1970. Convert to a real julian day number. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1311) == 0 && int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { + if idx > int32(1) { + return int32(1) + } /* IMP: R-49255-55373 */ + **(**float64)(__ccgo_up(bp)) = float64((*TDateTime)(unsafe.Pointer(p)).Fs*float64(1000)) + float64(2.1086676e+14) + if **(**float64)(__ccgo_up(bp)) >= float64(0) && **(**float64)(__ccgo_up(bp)) < float64(4.642690608e+14) { + _clearYMD_HMS_TZ(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(**(**float64)(__ccgo_up(bp)) + libc.Float64FromFloat64(0.5)) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + rc = 0 + } + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1321) == 0 && _sqlite3NotPureFunc(tls, pCtx) != 0 { + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x8>>3)) == 0 { /* Guess at the corresponding utc time */ + cnt = 0 /* Guess is off by this much */ + _computeJD(tls, p) + v2 = (*TDateTime)(unsafe.Pointer(p)).FiJD + iOrigJD = v2 + iGuess = v2 + iErr = 0 + for { + libc.Xmemset(tls, bp+8, 0, uint64(48)) + iGuess = iGuess - iErr + (**(**TDateTime)(__ccgo_up(bp + 8))).FiJD = iGuess + (**(**TDateTime)(__ccgo_up(bp + 8))).FvalidJD = uint8(1) + rc = _toLocaltime(tls, bp+8, pCtx) + if rc != 0 { + return rc + } + _computeJD(tls, bp+8) + iErr = (**(**TDateTime)(__ccgo_up(bp + 8))).FiJD - iOrigJD + goto _5 + _5: + ; + if v4 = iErr != 0; v4 { + v1 = cnt + cnt = cnt + 1 + } + if !(v4 && v1 < int32(3)) { + break + } + } + libc.Xmemset(tls, p, 0, uint64(48)) + (*TDateTime)(unsafe.Pointer(p)).FiJD = iGuess + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + } + rc = SQLITE_OK + } + } + case int32('w'): + /* + ** weekday N + ** + ** Move the date to the same time on the next occurrence of + ** weekday N where 0==Sunday, 1==Monday, and so forth. If the + ** date is already on the appropriate weekday, this is a no-op. + */ + if v4 = Xsqlite3_strnicmp(tls, z, __ccgo_ts+1325, int32(8)) == 0 && _sqlite3AtoF(tls, z+8, bp) > 0 && **(**float64)(__ccgo_up(bp)) >= float64(0) && **(**float64)(__ccgo_up(bp)) < float64(7); v4 { + v1 = int32(**(**float64)(__ccgo_up(bp))) + n = v1 + } + if v4 && float64(v1) == **(**float64)(__ccgo_up(bp)) { + _computeYMD_HMS(tls, p) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) + _computeJD(tls, p) + Z = ((*TDateTime)(unsafe.Pointer(p)).FiJD + int64(129600000)) / int64(86400000) % int64(7) + if Z > int64(n) { + Z = Z - int64(7) + } + **(**Tsqlite3_int64)(__ccgo_up(p)) += (int64(n) - Z) * int64(86400000) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + } + case int32('s'): + /* + ** start of TTTTT + ** + ** Move the date backwards to the beginning of the current day, + ** or month or year. + ** + ** subsecond + ** subsec + ** + ** Show subsecond precision in the output of datetime() and + ** unixepoch() and strftime('%s'). + */ + if Xsqlite3_strnicmp(tls, z, __ccgo_ts+1334, int32(9)) != 0 { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1232) == 0 || Xsqlite3_stricmp(tls, z, __ccgo_ts+1239) == 0 { + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 2, 0x4) + rc = 0 + } + break + } + if !((*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0) && !((*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0) && !((*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0) { + break + } + z = z + uintptr(9) + _computeYMD(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1) + v1 = libc.Int32FromInt32(0) + (*TDateTime)(unsafe.Pointer(p)).Fm = v1 + (*TDateTime)(unsafe.Pointer(p)).Fh = v1 + (*TDateTime)(unsafe.Pointer(p)).Fs = float64(0) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1344) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) + rc = 0 + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1350) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FM = int32(1) + (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) + rc = 0 + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1355) == 0 { + rc = 0 + } + } + } + case int32('+'): + fallthrough + case int32('-'): + fallthrough + case int32('0'): + fallthrough + case int32('1'): + fallthrough + case int32('2'): + fallthrough + case int32('3'): + fallthrough + case int32('4'): + fallthrough + case int32('5'): + fallthrough + case int32('6'): + fallthrough + case int32('7'): + fallthrough + case int32('8'): + fallthrough + case int32('9'): + z2 = z + db = Xsqlite3_context_db_handle(tls, pCtx) + z0 = **(**uint8)(__ccgo_up(z)) + n = int32(1) + for { + if !(**(**uint8)(__ccgo_up(z + uintptr(n))) != 0) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) == int32(':') { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(n))))])&int32(0x01) != 0 { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) == int32('-') { + if n == int32(5) && _getDigits(tls, z+1, __ccgo_ts+1359, libc.VaList(bp+136, bp+56)) == int32(1) { + break + } + if n == int32(6) && _getDigits(tls, z+1, __ccgo_ts+1363, libc.VaList(bp+136, bp+56)) == int32(1) { + break + } + } + goto _9 + _9: + ; + n = n + 1 + } + zCopy = _sqlite3DbStrNDup(tls, db, z, libc.Uint64FromInt32(n)) + if zCopy == uintptr(0) { + break + } + rx = libc.BoolInt32(_sqlite3AtoF(tls, zCopy, bp) <= 0) + _sqlite3DbFree(tls, db, zCopy) + if rx != 0 { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) == int32('-') { + /* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the + ** specified number of years, months, and days. MM is limited to + ** the range 0-11 and DD is limited to 0-30. + */ + if libc.Int32FromUint8(z0) != int32('+') && libc.Int32FromUint8(z0) != int32('-') { + break + } /* Must start with +/- */ + if n == int32(5) { + if _getDigits(tls, z+1, __ccgo_ts+1367, libc.VaList(bp+136, bp+56, bp+60, bp+64)) != int32(3) { + break + } + } else { + if _getDigits(tls, z+1, __ccgo_ts+1379, libc.VaList(bp+136, bp+56, bp+60, bp+64)) != int32(3) { + break + } + z = z + 1 + } + if **(**int32)(__ccgo_up(bp + 60)) >= int32(12) { + break + } /* M range 0..11 */ + if **(**int32)(__ccgo_up(bp + 64)) >= int32(31) { + break + } /* D range 0..30 */ + _computeYMD_HMS(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) + if libc.Int32FromUint8(z0) == int32('-') { + **(**int32)(__ccgo_up(p + 8)) -= **(**int32)(__ccgo_up(bp + 56)) + **(**int32)(__ccgo_up(p + 12)) -= **(**int32)(__ccgo_up(bp + 60)) + **(**int32)(__ccgo_up(bp + 64)) = -**(**int32)(__ccgo_up(bp + 64)) + } else { + **(**int32)(__ccgo_up(p + 8)) += **(**int32)(__ccgo_up(bp + 56)) + **(**int32)(__ccgo_up(p + 12)) += **(**int32)(__ccgo_up(bp + 60)) + } + if (*TDateTime)(unsafe.Pointer(p)).FM > 0 { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(1)) / int32(12) + } else { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(12)) / int32(12) + } + x = v1 + **(**int32)(__ccgo_up(p + 8)) += x + **(**int32)(__ccgo_up(p + 12)) -= x * int32(12) + _computeFloor(tls, p) + _computeJD(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(0) + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(0) + **(**Tsqlite3_int64)(__ccgo_up(p)) += int64(**(**int32)(__ccgo_up(bp + 64))) * int64(86400000) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 11))) == 0 { + rc = 0 + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + 11)))])&int32(0x01) != 0 && _getDigits(tls, z+12, __ccgo_ts+1204, libc.VaList(bp+136, bp+68, bp+72)) == int32(2) { + z2 = z + 12 + n = int32(2) + } else { + break + } + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z2 + uintptr(n)))) == int32(':') { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z2)))])&libc.Int32FromInt32(0x04) != 0) { + z2 = z2 + 1 + } + libc.Xmemset(tls, bp+80, 0, uint64(48)) + if _parseHhMmSs(tls, z2, bp+80) != 0 { + break + } + _computeJD(tls, bp+80) + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD -= int64(43200000) + day = (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD / int64(86400000) + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD -= day * int64(86400000) + if libc.Int32FromUint8(z0) == int32('-') { + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD = -(**(**TDateTime)(__ccgo_up(bp + 80))).FiJD + } + _computeJD(tls, p) + _clearYMD_HMS_TZ(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) += (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD + rc = 0 + break + } + /* If control reaches this point, it means the transformation is + ** one of the forms like "+NNN days". */ + z = z + uintptr(n) + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z)))])&int32(0x01) != 0 { + z = z + 1 + } + n = _sqlite3Strlen30(tls, z) + if n < int32(3) || n > int32(10) { + break + } + if libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(z + uintptr(n-int32(1)))))]) == int32('s') { + n = n - 1 + } + _computeJD(tls, p) + if **(**float64)(__ccgo_up(bp)) < libc.Float64FromInt32(0) { + v11 = -libc.Float64FromFloat64(0.5) + } else { + v11 = +libc.Float64FromFloat64(0.5) + } + rRounder = v11 + (*TDateTime)(unsafe.Pointer(p)).FnFloor = uint8(0) + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(96)/libc.Uint64FromInt64(16))) { + break + } + if libc.Int32FromUint8(_aXformType[i].FnName) == n && Xsqlite3_strnicmp(tls, uintptr(unsafe.Pointer(&_aXformType))+uintptr(i)*16+1, z, n) == 0 && **(**float64)(__ccgo_up(bp)) > float64(-_aXformType[i].FrLimit) && **(**float64)(__ccgo_up(bp)) < float64(_aXformType[i].FrLimit) { + switch i { + case int32(4): /* Special processing to add months */ + _computeYMD_HMS(tls, p) + **(**int32)(__ccgo_up(p + 12)) += int32(**(**float64)(__ccgo_up(bp))) + if (*TDateTime)(unsafe.Pointer(p)).FM > 0 { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(1)) / int32(12) + } else { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(12)) / int32(12) + } + x = v1 + **(**int32)(__ccgo_up(p + 8)) += x + **(**int32)(__ccgo_up(p + 12)) -= x * int32(12) + _computeFloor(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) + **(**float64)(__ccgo_up(bp)) = **(**float64)(__ccgo_up(bp)) - float64(int32(**(**float64)(__ccgo_up(bp)))) + case int32(5): /* Special processing to add years */ + y = int32(**(**float64)(__ccgo_up(bp))) + _computeYMD_HMS(tls, p) + **(**int32)(__ccgo_up(p + 8)) += y + _computeFloor(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) + **(**float64)(__ccgo_up(bp)) = **(**float64)(__ccgo_up(bp)) - float64(int32(**(**float64)(__ccgo_up(bp)))) + break + } + _computeJD(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) += int64(float64(float64(**(**float64)(__ccgo_up(bp))*libc.Float64FromFloat64(1000))*float64(_aXformType[i].FrXform)) + rRounder) + rc = 0 + break + } + goto _12 + _12: + ; + i = i + 1 + } + _clearYMD_HMS_TZ(tls, p) + default: + break + } + return rc +} + +// C documentation +// +// /* +// ** Pragma virtual table module xConnect method. +// */ +func _pragmaVtabConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var cSep uint8 + var i, j, rc int32 + var pPragma, pTab uintptr + var _ /* acc at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [200]uint8 + _, _, _, _, _, _ = cSep, i, j, pPragma, pTab, rc + pPragma = pAux + pTab = uintptr(0) + cSep = uint8('(') + _ = argc + _ = argv + _sqlite3StrAccumInit(tls, bp, uintptr(0), bp+32, int32(200), 0) + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+19906) + i = 0 + j = libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FiPragCName) + for { + if !(i < libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FnPragCName)) { + break + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+19921, libc.VaList(bp+240, libc.Int32FromUint8(cSep), _pragCName[j])) + cSep = uint8(',') + goto _1 + _1: + ; + i = i + 1 + j = j + 1 + } + if i == 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+19928, libc.VaList(bp+240, (*TPragmaName)(unsafe.Pointer(pPragma)).FzName)) + i = i + 1 + } + j = 0 + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_Result1) != 0 { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+19934) + j = j + 1 + } + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&(libc.Int32FromInt32(PragFlg_SchemaOpt)|libc.Int32FromInt32(PragFlg_SchemaReq)) != 0 { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+19946) + j = j + 1 + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5257, int32(1)) + _sqlite3StrAccumFinish(tls, bp) + rc = Xsqlite3_declare_vtab(tls, db, bp+32) + if rc == SQLITE_OK { + pTab = Xsqlite3_malloc(tls, int32(48)) + if pTab == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pTab, 0, uint64(48)) + (*TPragmaVtab)(unsafe.Pointer(pTab)).FpName = pPragma + (*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb = db + (*TPragmaVtab)(unsafe.Pointer(pTab)).FiHidden = libc.Uint8FromInt32(i) + (*TPragmaVtab)(unsafe.Pointer(pTab)).FnHidden = libc.Uint8FromInt32(j) + } + } else { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+240, Xsqlite3_errmsg(tls, db))) + } + **(**uintptr)(__ccgo_up(ppVtab)) = pTab + return rc +} + +// C documentation +// +// /* +// ** If the error code currently stored in the RBU handle is SQLITE_CONSTRAINT, +// ** then edit any error message string so as to remove all occurrences of +// ** the pattern "rbu_imp_[0-9]*". +// */ +func _rbuEditErrmsg(tls *libc.TLS, p uintptr) { + var i uint32 + var nDel int32 + var nErrmsg Tsize_t + _, _, _ = i, nDel, nErrmsg + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_CONSTRAINT) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg != 0 { + nErrmsg = libc.Xstrlen(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg) + i = uint32(0) + for { + if !(uint64(i) < nErrmsg-uint64(8)) { + break + } + if libc.Xmemcmp(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i), __ccgo_ts+32630, uint64(8)) == 0 { + nDel = int32(8) + for libc.Int32FromUint8(**(**uint8)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + uintptr(i+libc.Uint32FromInt32(nDel))))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + uintptr(i+libc.Uint32FromInt32(nDel))))) <= int32('9') { + nDel = nDel + 1 + } + libc.Xmemmove(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i), (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i+libc.Uint32FromInt32(nDel)), nErrmsg+uint64(1)-uint64(i)-libc.Uint64FromInt32(nDel)) + nErrmsg = nErrmsg - libc.Uint64FromInt32(nDel) + } + goto _1 + _1: + ; + i = i + 1 + } + } +} + +func _rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aIdxCol, zRet, zSql, v1 uintptr + var c uint8 + var i, iIdxCol, nIdxAlloc, nParen, nSpan, nSpan1, rc2, v3 int32 + var _ /* pStmt at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = aIdxCol, c, i, iIdxCol, nIdxAlloc, nParen, nSpan, nSpan1, rc2, zRet, zSql, v1, v3 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + zRet = uintptr(0) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, __ccgo_ts+32118) + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = Xsqlite3_bind_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx, -int32(1), libc.UintptrFromInt32(0)) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zSql = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + if zSql != 0 { + v1 = _rbuStrndup(tls, zSql, bp+8) + zSql = v1 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = v1 + } + if zSql != 0 { + nParen = 0 + iIdxCol = 0 + nIdxAlloc = 0 + i = 0 + for { + if !(**(**uint8)(__ccgo_up(zSql + uintptr(i))) != 0) { + break + } + c = **(**uint8)(__ccgo_up(zSql + uintptr(i))) + /* If necessary, grow the pIter->aIdxCol[] array */ + if iIdxCol == nIdxAlloc { + aIdxCol = Xsqlite3_realloc64(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol, uint64(libc.Uint64FromInt32(nIdxAlloc)*uint64(16)+libc.Uint64FromInt32(16)*libc.Uint64FromInt64(16))) + if aIdxCol == uintptr(0) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_NOMEM) + break + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = aIdxCol + nIdxAlloc = nIdxAlloc + int32(16) + } + if libc.Int32FromUint8(c) == int32('(') { + if nParen == 0 { + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol))).FzSpan = zSql + uintptr(i+int32(1)) + } + nParen = nParen + 1 + } else { + if libc.Int32FromUint8(c) == int32(')') { + nParen = nParen - 1 + if nParen == 0 { + nSpan = int32(t__predefined_ptrdiff_t(zSql+uintptr(i)) - int64((**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan)) + v3 = iIdxCol + iIdxCol = iIdxCol + 1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(v3)*16))).FnSpan = nSpan + i = i + 1 + break + } + } else { + if libc.Int32FromUint8(c) == int32(',') && nParen == int32(1) { + nSpan1 = int32(t__predefined_ptrdiff_t(zSql+uintptr(i)) - int64((**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan)) + v3 = iIdxCol + iIdxCol = iIdxCol + 1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(v3)*16))).FnSpan = nSpan1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan = zSql + uintptr(i+int32(1)) + } else { + if libc.Int32FromUint8(c) == int32('"') || libc.Int32FromUint8(c) == int32('\'') || libc.Int32FromUint8(c) == int32('`') { + i = i + 1 + for { + if !(int32(1) != 0) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i)))) == libc.Int32FromUint8(c) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i+int32(1))))) != libc.Int32FromUint8(c) { + break + } + i = i + 1 + } + goto _5 + _5: + ; + i = i + 1 + } + } else { + if libc.Int32FromUint8(c) == int32('[') { + i = i + 1 + for { + if !(int32(1) != 0) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i)))) == int32(']') { + break + } + goto _6 + _6: + ; + i = i + 1 + } + } else { + if libc.Int32FromUint8(c) == int32('-') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i+int32(1))))) == int32('-') { + i = i + int32(2) + for { + if !(**(**uint8)(__ccgo_up(zSql + uintptr(i))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i)))) != int32('\n')) { + break + } + goto _7 + _7: + ; + i = i + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i)))) == int32('\000') { + break + } + } else { + if libc.Int32FromUint8(c) == int32('/') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i+int32(1))))) == int32('*') { + i = i + int32(2) + for { + if !(**(**uint8)(__ccgo_up(zSql + uintptr(i))) != 0 && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i)))) != int32('*') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i+int32(1))))) != int32('/'))) { + break + } + goto _8 + _8: + ; + i = i + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(i)))) == int32('\000') { + break + } + i = i + 1 + } + } + } + } + } + } + } + goto _2 + _2: + ; + i = i + 1 + } + if **(**uint8)(__ccgo_up(zSql + uintptr(i))) != 0 { + zRet = _rbuStrndup(tls, zSql+uintptr(i), bp+8) + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIdxCol = iIdxCol + } + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = rc2 + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = **(**int32)(__ccgo_up(bp + 8)) + return zRet +} + +// C documentation +// +// /* +// ** Return a nul-terminated string containing the comma separated list of +// ** assignments that should be included following the "SET" keyword of +// ** an UPDATE statement used to update the table object that the iterator +// ** passed as the second argument currently points to if the rbu_control +// ** column of the data_xxx table entry is set to zMask. +// ** +// ** The memory for the returned string is obtained from sqlite3_malloc(). +// ** It is the responsibility of the caller to eventually free it using +// ** sqlite3_free(). +// ** +// ** If an OOM error is encountered when allocating space for the new +// ** string, an error code is left in the rbu handle passed as the first +// ** argument and NULL is returned. Or, if an error has already occurred +// ** when this function is called, NULL is returned immediately, without +// ** attempting the allocation or modifying the stored error code. +// */ +func _rbuObjIterGetSetlist(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var c uint8 + var i int32 + var zList, zSep uintptr + _, _, _, _ = c, i, zList, zSep + zList = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if libc.Int32FromUint64(libc.Xstrlen(tls, zMask)) != (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { + _rbuBadControlError(tls, p) + } else { + zSep = __ccgo_ts + 1704 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + c = **(**uint8)(__ccgo_up(zMask + uintptr(**(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4))))) + if libc.Int32FromUint8(c) == int32('x') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31664, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16214 + } else { + if libc.Int32FromUint8(c) == int32('d') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31703, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16214 + } else { + if libc.Int32FromUint8(c) == int32('f') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31733, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16214 + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + } + return zList +} + +// C documentation +// +// /* +// ** Open the database handle and attach the RBU database as "rbu". If an +// ** error occurs, leave an error code and message in the RBU handle. +// ** +// ** If argument dbMain is not NULL, then it is a database handle already +// ** open on the target database. Use this handle instead of opening a new +// ** one. +// */ +func _rbuOpenDatabase(tls *libc.TLS, p uintptr, dbMain uintptr, pbRetry uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOpen, rc int32 + var pState, zExtra, zFile, zTarget, v1, v2 uintptr + _, _, _, _, _, _, _, _ = bOpen, pState, rc, zExtra, zFile, zTarget, v1, v2 + /* Open the RBU database */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = dbMain + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816, int32(SQLITE_FCNTL_RBUCNT), p) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState == uintptr(0) { + zFile = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState = _rbuMPrintf(tls, p, __ccgo_ts+33351, libc.VaList(bp+8, zFile, zFile)) + } + } + /* If using separate RBU and state databases, attach the state database to + ** the RBU db handle now. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState != 0 { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33379, libc.VaList(bp+8, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState)) + libc.Xmemcpy(tls, p+48, __ccgo_ts+3567, uint64(4)) + } else { + libc.Xmemcpy(tls, p+48, __ccgo_ts+6816, uint64(4)) + } + /* If it has not already been created, create the rbu_state table */ + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33397, libc.VaList(bp+8, p+48)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + bOpen = 0 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu = 0 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd = uintptr(0) + rc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816, int32(SQLITE_FCNTL_RBUCNT), p) + if rc != int32(SQLITE_NOTFOUND) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage >= int32(RBU_STAGE_MOVE) { + bOpen = int32(1) + } else { + pState = _rbuLoadState(tls, p) + if pState != 0 { + bOpen = libc.BoolInt32((*TRbuState)(unsafe.Pointer(pState)).FeStage >= int32(RBU_STAGE_MOVE)) + _rbuFreeState(tls, pState) + } + } + if bOpen != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu <= int32(1))) + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain == uintptr(0) { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == libc.UintptrFromInt32(0)) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget, int32(1)) + } else { + if (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FpWalFd != 0 { + if pbRetry != 0 { + (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FbNolock = uint8(0) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu = uintptr(0) + **(**int32)(__ccgo_up(pbRetry)) = int32(1) + return + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+33463, 0) + } else { + zExtra = uintptr(0) + if libc.Xstrlen(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu) >= uint64(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+26049, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, uint64(5)) { + zExtra = (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu + 5 + for **(**uint8)(__ccgo_up(zExtra)) != 0 { + v1 = zExtra + zExtra = zExtra + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v1))) == int32('?') { + break + } + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zExtra))) == int32('\000') { + zExtra = uintptr(0) + } + } + if zExtra == uintptr(0) { + v1 = __ccgo_ts + 1704 + } else { + v1 = __ccgo_ts + 33495 + } + if zExtra == uintptr(0) { + v2 = __ccgo_ts + 1704 + } else { + v2 = zExtra + } + zTarget = Xsqlite3_mprintf(tls, __ccgo_ts+33497, libc.VaList(bp+8, Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816), v1, v2)) + if zTarget == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + return + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, zTarget, libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu <= int32(1))) + Xsqlite3_free(tls, zTarget) + } + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33529, -int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_rbuTmpInsertFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33544, int32(2), int32(SQLITE_UTF8), uintptr(0), __ccgo_fp(_rbuFossilDeltaFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33561, -int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_rbuTargetNameFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, int32(SQLITE_FCNTL_RBU), p) + } + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33577, 0) + /* Mark the database file just opened as an RBU target database. If + ** this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use. + ** This is an error. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, int32(SQLITE_FCNTL_RBU), p) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_NOTFOUND) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+33605, 0) + } +} + +// C documentation +// +// /* +// ** The implementation of the rbu_target_name() SQL function. This function +// ** accepts one or two arguments. The first argument is the name of a table - +// ** the name of a table in the RBU database. The second, if it is present, is 1 +// ** for a view or 0 for a table. +// ** +// ** For a non-vacuum RBU handle, if the table name matches the pattern: +// ** +// ** data[0-9]_ +// ** +// ** where is any sequence of 1 or more characters, is returned. +// ** Otherwise, if the only argument does not match the above pattern, an SQL +// ** NULL is returned. +// ** +// ** "data_t1" -> "t1" +// ** "data0123_t2" -> "t2" +// ** "dataAB_t3" -> NULL +// ** +// ** For an rbu vacuum handle, a copy of the first argument is returned if +// ** the second argument is either missing or 0 (not a view). +// */ +func _rbuTargetNameFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { + var i int32 + var p, zIn uintptr + _, _, _ = i, p, zIn + p = Xsqlite3_user_data(tls, pCtx) + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn != 0 { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + if argc == int32(1) || 0 == Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) { + Xsqlite3_result_text(tls, pCtx, zIn, -int32(1), libc.UintptrFromInt32(0)) + } + } else { + if libc.Xstrlen(tls, zIn) > uint64(4) && libc.Xmemcmp(tls, __ccgo_ts+27339, zIn, uint64(4)) == 0 { + i = int32(4) + for { + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn + uintptr(i)))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn + uintptr(i)))) <= int32('9')) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn + uintptr(i)))) == int32('_') && **(**uint8)(__ccgo_up(zIn + uintptr(i+int32(1)))) != 0 { + Xsqlite3_result_text(tls, pCtx, zIn+uintptr(i+int32(1)), -int32(1), libc.UintptrFromInt32(0)) + } + } + } + } +} + +// C documentation +// +// /* +// ** This function is called as part of restating an RBU vacuum when the +// ** current operation is writing content to an index. If possible, it +// ** queries the target index b-tree for the largest key already written to +// ** it, then composes and returns an expression that can be used in a WHERE +// ** clause to select the remaining required rows from the source table. +// ** It is only possible to return such an expression if: +// ** +// ** * The index contains no DESC columns, and +// ** * The last key written to the index before the operation was +// ** suspended does not contain any NULL values. +// ** +// ** The expression is of the form: +// ** +// ** (index-field1, index-field2, ...) > (?, ?, ...) +// ** +// ** except that the "?" placeholders are replaced with literal values. +// ** +// ** If the expression cannot be created, NULL is returned. In this case, +// ** the caller has to use an OFFSET clause to extract only the required +// ** rows from the sourct table, just as it does for an RBU update operation. +// */ +func _rbuVacuumIndexStart(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bFailed, i, iCid, iCol int32 + var zCol, zCollate, zLhs, zOrder, zQuoted, zRet, zSelect, zSep, zVector uintptr + var _ /* pSel at bp+8 */ uintptr + var _ /* pXInfo at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = bFailed, i, iCid, iCol, zCol, zCollate, zLhs, zOrder, zQuoted, zRet, zSelect, zSep, zVector + zOrder = uintptr(0) + zLhs = uintptr(0) + zSelect = uintptr(0) + zVector = uintptr(0) + zRet = uintptr(0) + bFailed = 0 + zSep = __ccgo_ts + 1704 + iCol = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30950, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + zCollate = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) != 0 { + bFailed = int32(1) + break + } + if iCid < 0 { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) { + i = 0 + for { + if !(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + } else { + zCol = __ccgo_ts + 31273 + } + } else { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCid)*8)) + } + zLhs = _rbuMPrintf(tls, p, __ccgo_ts+31281, libc.VaList(bp+24, zLhs, zSep, zCol, zCollate)) + zOrder = _rbuMPrintf(tls, p, __ccgo_ts+31302, libc.VaList(bp+24, zOrder, zSep, iCol, zCol, zCollate)) + zSelect = _rbuMPrintf(tls, p, __ccgo_ts+31338, libc.VaList(bp+24, zSelect, zSep, iCol, zCol)) + zSep = __ccgo_ts + 16214 + iCol = iCol + 1 + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + if bFailed != 0 { + goto index_start_out + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31365, libc.VaList(bp+24, zSelect, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + zSep = __ccgo_ts + 1704 + iCol = 0 + for { + if !(iCol < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol) { + break + } + zQuoted = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), iCol) + if zQuoted == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zQuoted))) == int32('N') { + bFailed = int32(1) + break + } + } + zVector = _rbuMPrintf(tls, p, __ccgo_ts+31413, libc.VaList(bp+24, zVector, zSep, zQuoted)) + zSep = __ccgo_ts + 16214 + goto _2 + _2: + ; + iCol = iCol + 1 + } + if !(bFailed != 0) { + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31420, libc.VaList(bp+24, zLhs, zVector)) + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + } + goto index_start_out +index_start_out: + ; + Xsqlite3_free(tls, zOrder) + Xsqlite3_free(tls, zSelect) + Xsqlite3_free(tls, zVector) + Xsqlite3_free(tls, zLhs) + return zRet +} + +// C documentation +// +// /* +// ** Open an rbu file handle. +// */ +func _rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) (r int32) { + var nOpen Tsize_t + var oflags, rc int32 + var pDb, pFd, pMeth, pRbuVfs, pRealVfs, zOpen uintptr + _, _, _, _, _, _, _, _, _ = nOpen, oflags, pDb, pFd, pMeth, pRbuVfs, pRealVfs, rc, zOpen + pRbuVfs = pVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs + pFd = pFile + rc = SQLITE_OK + zOpen = zName + oflags = flags + libc.Xmemset(tls, pFd, 0, uint64(104)) + (*Trbu_file)(unsafe.Pointer(pFd)).FpReal = pFd + 1*104 + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbuVfs = pRbuVfs + (*Trbu_file)(unsafe.Pointer(pFd)).FopenFlags = flags + if zName != 0 { + if flags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + /* A main database has just been opened. The following block sets + ** (pFd->zWal) to point to a buffer owned by SQLite that contains + ** the name of the *-wal file this db connection will use. SQLite + ** happens to pass a pointer to this buffer when using xAccess() + ** or xOpen() to operate on the *-wal file. */ + (*Trbu_file)(unsafe.Pointer(pFd)).FzWal = Xsqlite3_filename_wal(tls, zName) + } else { + if flags&int32(SQLITE_OPEN_WAL) != 0 { + pDb = _rbuFindMaindb(tls, pRbuVfs, zName, 0) + if pDb != 0 { + if (*Trbu_file)(unsafe.Pointer(pDb)).FpRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == int32(RBU_STAGE_OAL) { + if (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FzTarget == uintptr(0) { + zOpen = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FdbRbu, __ccgo_ts+6816) + zOpen = Xsqlite3_filename_wal(tls, zOpen) + } + nOpen = libc.Xstrlen(tls, zOpen) + **(**uint8)(__ccgo_up(zOpen + uintptr(nOpen-uint64(3)))) = uint8('o') + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Trbu_file)(unsafe.Pointer(pDb)).FpRbu + } + (*Trbu_file)(unsafe.Pointer(pDb)).FpWalFd = pFd + } + } + } + } else { + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRbu + } + if oflags&int32(SQLITE_OPEN_MAIN_DB) != 0 && Xsqlite3_uri_boolean(tls, zName, __ccgo_ts+34676, 0) != 0 { + oflags = libc.Int32FromInt32(SQLITE_OPEN_TEMP_DB) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) + zOpen = uintptr(0) + } + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, Tsqlite3_filename, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxOpen})))(tls, pRealVfs, zOpen, (*Trbu_file)(unsafe.Pointer(pFd)).FpReal, oflags, pOutFlags) + } + if (*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods != 0 { + pMeth = (*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods + /* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods + ** pointer and, if the file is a main database file, link it into the + ** mutex protected linked list of all such files. */ + if (*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FiVersion < int32(2) || (*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FxShmLock == uintptr(0) { + (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&_rbuvfs_io_methods1)) + } else { + (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&_rbuvfs_io_methods)) + } + if flags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + _rbuMainlistAdd(tls, pFd) + } + } else { + Xsqlite3_free(tls, (*Trbu_file)(unsafe.Pointer(pFd)).FzDel) + } + return rc +} + +// C documentation +// +// /* +// ** This function edits SQL statement zSql, replacing each token identified +// ** by the linked list pRename with the text of zNew. If argument bQuote is +// ** true, then zNew is always quoted first. If no error occurs, the result +// ** is loaded into context object pCtx as the result. +// ** +// ** Or, if an error occurs (i.e. an OOM condition), an error is left in +// ** pCtx and an SQLite error code returned. +// */ +func _renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, zNew uintptr, bQuote int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pBest, zBuf1, zBuf2, zOut, zQuot, zReplace, v1 uintptr + var iOff, rc int32 + var nNew, nOut, nQuot, nReplace, nSql Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, iOff, nNew, nOut, nQuot, nReplace, nSql, pBest, rc, zBuf1, zBuf2, zOut, zQuot, zReplace, v1 + nNew = int64(_sqlite3Strlen30(tls, zNew)) + nSql = int64(_sqlite3Strlen30(tls, zSql)) + db = Xsqlite3_context_db_handle(tls, pCtx) + rc = SQLITE_OK + zQuot = uintptr(0) + nQuot = 0 + zBuf1 = uintptr(0) + zBuf2 = uintptr(0) + if zNew != 0 { + /* Set zQuot to point to a buffer containing a quoted copy of the + ** identifier zNew. If the corresponding identifier in the original + ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to + ** point to zQuot so that all substitutions are made using the + ** quoted version of the new column name. */ + zQuot = _sqlite3MPrintf(tls, db, __ccgo_ts+11574, libc.VaList(bp+8, zNew)) + if zQuot == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + nQuot = int64(_sqlite3Strlen30(tls, zQuot) - int32(1)) + } + zOut = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nSql)+libc.Uint64FromInt32((*TRenameCtx)(unsafe.Pointer(pRename)).FnList)*libc.Uint64FromInt64(nQuot)+uint64(1)) + } else { + zOut = _sqlite3DbMallocZero(tls, db, (uint64(2)*libc.Uint64FromInt64(nSql)+uint64(1))*uint64(3)) + if zOut != 0 { + zBuf1 = zOut + uintptr(nSql*int64(2)+int64(1)) + zBuf2 = zOut + uintptr(nSql*int64(4)+int64(2)) + } + } + /* At this point pRename->pList contains a list of RenameToken objects + ** corresponding to all tokens in the input SQL that must be replaced + ** with the new column name, or with single-quoted versions of themselves. + ** All that remains is to construct and return the edited SQL string. */ + if zOut != 0 { + nOut = nSql + libc.Xmemcpy(tls, zOut, zSql, libc.Uint64FromInt64(nSql)) + for (*TRenameCtx)(unsafe.Pointer(pRename)).FpList != 0 { + pBest = _renameColumnTokenNext(tls, pRename) + if zNew != 0 { + if bQuote == 0 && _sqlite3IsIdChar(tls, **(**Tu8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz))) != 0 { + nReplace = nNew + zReplace = zNew + } else { + nReplace = nQuot + zReplace = zQuot + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)))) == int32('"') { + nReplace = nReplace + 1 + } + } + } else { + /* Dequote the double-quoted token. Then requote it again, this time + ** using single quotes. If the character immediately following the + ** original token within the input SQL was a single quote ('), then + ** add another space after the new, single-quoted version of the + ** token. This is so that (SELECT "string"'alias') maps to + ** (SELECT 'string' 'alias'), and not (SELECT 'string''alias'). */ + libc.Xmemcpy(tls, zBuf1, (*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz, uint64((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)) + **(**uint8)(__ccgo_up(zBuf1 + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn))) = uint8(0) + _sqlite3Dequote(tls, zBuf1) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)))) == int32('\'') { + v1 = __ccgo_ts + 11541 + } else { + v1 = __ccgo_ts + 1704 + } + Xsqlite3_snprintf(tls, int32(nSql*libc.Int64FromInt32(2)), zBuf2, __ccgo_ts+11580, libc.VaList(bp+8, zBuf1, v1)) + zReplace = zBuf2 + nReplace = int64(_sqlite3Strlen30(tls, zReplace)) + } + iOff = int32(int64((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz) - int64(zSql)) + if libc.Int64FromUint32((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn) != nReplace { + libc.Xmemmove(tls, zOut+uintptr(int64(iOff)+nReplace), zOut+uintptr(libc.Uint32FromInt32(iOff)+(*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn), libc.Uint64FromInt64(nOut-libc.Int64FromUint32(libc.Uint32FromInt32(iOff)+(*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn))) + nOut = nOut + (nReplace - libc.Int64FromUint32((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)) + **(**uint8)(__ccgo_up(zOut + uintptr(nOut))) = uint8('\000') + } + libc.Xmemcpy(tls, zOut+uintptr(iOff), zReplace, libc.Uint64FromInt64(nReplace)) + _sqlite3DbFree(tls, db, pBest) + } + Xsqlite3_result_text(tls, pCtx, zOut, -int32(1), uintptr(-libc.Int32FromInt32(1))) + _sqlite3DbFree(tls, db, zOut) + } else { + rc = int32(SQLITE_NOMEM) + } + Xsqlite3_free(tls, zQuot) + return rc +} + +// C documentation +// +// /* +// ** This routine is callback for sqlite3WalkExpr(). +// ** +// ** Resolve symbolic names into TK_COLUMN operators for the current +// ** node in the expression tree. Return 0 to continue the search down +// ** the tree or 2 to abort the tree walk. +// ** +// ** This routine also does error checking and name resolution for +// ** function names. The operator for aggregate functions is changed +// ** to TK_AGG_FUNCTION. +// */ +func _resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var anRef [8]int32 + var auth, i, is_agg, n, nLeft, nRef, nRight, no_such_func, rc, savedAllowFlags, wrong_num_args, v5 int32 + var enc Tu8 + var p, pDef, pItem, pLeft, pList, pNC, pNC2, pParse, pRight, pRight1, pSel, pSrcList, pWin, zDb, zId, zTable, zType, v4 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = anRef, auth, enc, i, is_agg, n, nLeft, nRef, nRight, no_such_func, p, pDef, pItem, pLeft, pList, pNC, pNC2, pParse, pRight, pRight1, pSel, pSrcList, pWin, rc, savedAllowFlags, wrong_num_args, zDb, zId, zTable, zType, v4, v5 + pNC = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + /* The special operator TK_ROW means use the rowid for the first + ** column in the FROM clause. This is used by the LIMIT and ORDER BY + ** clause processing on UPDATE and DELETE statements, and by + ** UPDATE ... FROM statement processing. + */ + case int32(TK_ROW): + pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + pItem = pSrcList + 8 + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_COLUMN) + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = (*TExpr)(unsafe.Pointer(pExpr)).FiColumn - 1 + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER) + break + /* An optimization: Attempt to convert + ** + ** "expr IS NOT NULL" --> "TRUE" + ** "expr IS NULL" --> "FALSE" + ** + ** if we can prove that "expr" is never NULL. Call this the + ** "NOT NULL strength reduction optimization". + ** + ** If this optimization occurs, also restore the NameContext ref-counts + ** to the state they where in before the "column" LHS expression was + ** resolved. This prevents "column" from being counted as having been + ** referenced, which might prevent a SELECT from being erroneously + ** marked as correlated. + ** + ** 2024-03-28: Beware of aggregates. A bare column of aggregated table + ** can still evaluate to NULL even though it is marked as NOT NULL. + ** Example: + ** + ** CREATE TABLE t1(a INT NOT NULL); + ** SELECT a, a IS NULL, a IS NOT NULL, count(*) FROM t1; + ** + ** The "a IS NULL" and "a IS NOT NULL" expressions cannot be optimized + ** here because at the time this case is hit, we do not yet know whether + ** or not t1 is being aggregated. We have to assume the worst and omit + ** the optimization. The only time it is safe to apply this optimization + ** is within the WHERE clause. + */ + fallthrough + case int32(TK_NOTNULL): + fallthrough + case int32(TK_ISNULL): + i = 0 + p = pNC + for { + if !(p != 0 && i < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) { + break + } + anRef[i] = (*TNameContext)(unsafe.Pointer(p)).FnRef + goto _1 + _1: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + _sqlite3WalkExpr(tls, pWalker, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return int32(WRC_Prune) + } + if _sqlite3ExprCanBeNull(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) != 0 { + /* The expression can be NULL. So the optimization does not apply */ + return int32(WRC_Prune) + } + i = 0 + p = pNC + for { + if !(p != 0) { + break + } + if (*TNameContext)(unsafe.Pointer(p)).FncFlags&int32(NC_Where) == 0 { + return int32(WRC_Prune) /* Not in a WHERE clause. Unsafe to optimize. */ + } + goto _2 + _2: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fu)) = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL)) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= uint32(EP_IntValue) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_INTEGER) + i = 0 + p = pNC + for { + if !(p != 0 && i < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) { + break + } + (*TNameContext)(unsafe.Pointer(p)).FnRef = anRef[i] + goto _3 + _3: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + return int32(WRC_Prune) + /* A column name: ID + ** Or table name and column name: ID.ID + ** Or a database, table and column: ID.ID.ID + ** + ** The TK_ID and TK_OUT cases are combined so that there will only + ** be one call to lookupName(). Then the compiler will in-line + ** lookupName() for a size reduction and performance increase. + */ + fallthrough + case int32(TK_ID): + fallthrough + case int32(TK_DOT): + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_ID) { + zDb = uintptr(0) + zTable = uintptr(0) + pRight = pExpr + } else { + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7200, uintptr(0), pExpr) + } + pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) == int32(TK_ID) { + zDb = uintptr(0) + } else { + zDb = *(*uintptr)(unsafe.Pointer(pLeft + 8)) + pLeft = (*TExpr)(unsafe.Pointer(pRight)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pRight)).FpRight + } + zTable = *(*uintptr)(unsafe.Pointer(pLeft + 8)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, pExpr, pRight) + _sqlite3RenameTokenRemap(tls, pParse, pExpr+64, pLeft) + } + } + return _lookupName(tls, pParse, zDb, zTable, pRight, pNC, pExpr) + /* Resolve function names + */ + fallthrough + case int32(TK_FUNCTION): /* Number of arguments */ + no_such_func = 0 /* True if no such function exists */ + wrong_num_args = 0 /* True if wrong number of arguments */ + is_agg = 0 /* Information about the function */ + enc = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc /* The database encoding */ + savedAllowFlags = (*TNameContext)(unsafe.Pointer(pNC)).FncFlags & (libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_AllowWin)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FeFrmType) != int32(TK_FILTER) { + v4 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + } else { + v4 = uintptr(0) + } + pWin = v4 + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if pList != 0 { + v5 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v5 = 0 + } + n = v5 + zId = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + pDef = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zId, n, enc, uint8(0)) + if pDef == uintptr(0) { + pDef = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zId, -int32(2), enc, uint8(0)) + if pDef == uintptr(0) { + no_such_func = int32(1) + } else { + wrong_num_args = int32(1) + } + } else { + is_agg = libc.BoolInt32((*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0)) + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_UNLIKELY) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Unlikely)) + if n == int32(2) { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = _exprProbability(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7217, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + } else { + /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is + ** equivalent to likelihood(X, 0.0625). + ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is + ** short-hand for likelihood(X,0.0625). + ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand + ** for likelihood(X,0.9375). + ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent + ** to likelihood(X,0.9375). */ + /* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TFuncDef)(unsafe.Pointer(pDef)).FzName))) == int32('u') { + v5 = int32(8388608) + } else { + v5 = int32(125829120) + } + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = v5 + } + } + auth = _sqlite3AuthCheck(tls, pParse, int32(SQLITE_FUNCTION), uintptr(0), (*TFuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0)) + if auth != SQLITE_OK { + if auth == int32(SQLITE_DENY) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7281, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + return int32(WRC_Prune) + } + /* If the function may call sqlite3_value_subtype(), then set the + ** EP_SubtArg flag on all of its argument expressions. This prevents + ** where.c from replacing the expression with a value read from an + ** index on the same expression, which will not have the correct + ** subtype. Also set the flag if the function expression itself is + ** an EP_SubtArg expression. In this case subtypes are required as + ** the function may return a value with a subtype back to its + ** caller using sqlite3_result_value(). */ + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_SUBTYPE) != 0 || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromUint32(EP_SubtArg) != uint32(0) { + _resolveSetExprSubtypeArg(tls, pList) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)|libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG)) != 0 { + /* For the purposes of the EP_ConstFunc flag, date and time + ** functions and other functions that change slowly are considered + ** constant because they are constant for the duration of one query. + ** This allows them to be factored out of inner loops. */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_ConstFunc)) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_CONSTANT) == uint32(0) { + /* Clearly non-deterministic functions like random(), but also + ** date/time functions that use 'now', and other functions like + ** sqlite_version() that might change over time cannot be used + ** in an index or generated column. Curiously, they can be used + ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all + ** allow this. */ + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7317, uintptr(0), pExpr) + } + } else { + /* Must fit in 8 bits */ + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = libc.Uint8FromInt32((*TNameContext)(unsafe.Pointer(pNC)).FncFlags & int32(NC_SelfRef)) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INTERNAL) != uint32(0) && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_InternalFunc) == uint32(0) { + /* Internal-use-only functions are disallowed unless the + ** SQL is being compiled using sqlite3NestedParse() or + ** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be + ** used to activate internal functions for testing purposes */ + no_such_func = int32(1) + pDef = uintptr(0) + } else { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_DIRECT)|libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) != uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_FromDDL) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) + } + _sqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) + } + } + } + if 0 == libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME)) { + if pDef != 0 && (*TFuncDef)(unsafe.Pointer(pDef)).FxValue == uintptr(0) && pWin != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7345, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowAgg) == 0 || is_agg != 0 && (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 && !(pWin != 0) || is_agg != 0 && pWin != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowWin) == 0 { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 || pWin != 0 { + zType = __ccgo_ts + 7388 + } else { + zType = __ccgo_ts + 7395 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7405, libc.VaList(bp+8, zType, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + is_agg = 0 + } else { + if no_such_func != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7433, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if wrong_num_args != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7455, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg == 0 && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7499, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg == 0 && (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3ExprOrderByAggregateError(tls, pParse, pExpr) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + } + } + } + } + } + if is_agg != 0 { + /* Window functions may not be arguments of aggregate functions. + ** Or arguments of other window functions. But aggregate functions + ** may be arguments for window functions. */ + if !(pWin != 0) { + v5 = int32(NC_AllowAgg) + } else { + v5 = 0 + } + **(**int32)(__ccgo_up(pNC + 40)) &= ^(libc.Int32FromInt32(NC_AllowWin) | v5) + } + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) || (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + is_agg = int32(1) + } + } + _sqlite3WalkExprList(tls, pWalker, pList) + if is_agg != 0 { + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32))) + } + if pWin != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + pSel = (*TNameContext)(unsafe.Pointer(pNC)).FpWinSelect + if libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME)) == 0 { + if pSel != 0 { + v4 = (*TSelect)(unsafe.Pointer(pSel)).FpWinDefn + } else { + v4 = uintptr(0) + } + _sqlite3WindowUpdate(tls, pParse, v4, pWin, pDef) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + break + } + } + _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) + _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) + _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpFilter) + _sqlite3WindowLink(tls, pSel, pWin) + **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_HasWin) + } else { + /* For looping up thru outer contexts */ + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_AGG_FUNCTION) + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = uint8(0) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpFilter) + } + pNC2 = pNC + for pNC2 != 0 && _sqlite3ReferencesSrcList(tls, pParse, pExpr, (*TNameContext)(unsafe.Pointer(pNC2)).FpSrcList) == 0 { + v4 = pExpr + 2 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(uint32(*(*Tu8)(unsafe.Pointer(v4))) + (libc.Uint32FromInt32(1) + (*TNameContext)(unsafe.Pointer(pNC2)).FnNestedSelect)) + pNC2 = (*TNameContext)(unsafe.Pointer(pNC2)).FpNext + } + if pNC2 != 0 && pDef != 0 { + v4 = pExpr + 2 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(uint32(*(*Tu8)(unsafe.Pointer(v4))) + (*TNameContext)(unsafe.Pointer(pNC2)).FnNestedSelect) + v4 = pNC2 + 40 + *(*int32)(unsafe.Pointer(v4)) = int32(uint32(*(*int32)(unsafe.Pointer(v4))) | (libc.Uint32FromInt32(NC_HasAgg) | ((*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags^libc.Uint32FromInt32(SQLITE_FUNC_ANYORDER))&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_MINMAX)|libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)))) + } + } + **(**int32)(__ccgo_up(pNC + 40)) |= savedAllowFlags + } + /* FIX ME: Compute pExpr->affinity based on the expected return + ** type of the function + */ + return int32(WRC_Prune) + case int32(TK_EXISTS): + fallthrough + case int32(TK_SELECT): + fallthrough + case int32(TK_IN): + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + nRef = (*TNameContext)(unsafe.Pointer(pNC)).FnRef + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_EXISTS) { + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 4, 0x10) + } + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_SelfRef) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7547, pExpr, pExpr) + } else { + _sqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } + if nRef != (*TNameContext)(unsafe.Pointer(pNC)).FnRef { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 4)) |= uint32(SF_Correlated) + } + **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_Subquery) + } + case int32(TK_VARIABLE): + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IsCheck)|libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7558, pExpr, pExpr) + } + case int32(TK_IS): + fallthrough + case int32(TK_ISNOT): + pRight1 = _sqlite3ExprSkipCollateAndLikely(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", + ** and "x IS NOT FALSE". */ + if pRight1 != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_ID) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_TRUEFALSE)) { + rc = _resolveExprStep(tls, pWalker, pRight1) + if rc == int32(WRC_Abort) { + return int32(WRC_Abort) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_TRUEFALSE) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_TRUTH) + return WRC_Continue + } + } + fallthrough + case int32(TK_BETWEEN): + fallthrough + case int32(TK_EQ): + fallthrough + case int32(TK_NE): + fallthrough + case int32(TK_LT): + fallthrough + case int32(TK_LE): + fallthrough + case int32(TK_GT): + fallthrough + case int32(TK_GE): + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + break + } + nLeft = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_BETWEEN) { + nRight = _sqlite3ExprVectorSize(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr) + if nRight == nLeft { + nRight = _sqlite3ExprVectorSize(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr) + } + } else { + nRight = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + } + if nLeft != nRight { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6908, 0) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + } + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v5 = int32(WRC_Abort) + } else { + v5 = WRC_Continue + } + return v5 +} + +// C documentation +// +// /* +// ** This function is the implementation of both the xConnect and xCreate +// ** methods of the r-tree virtual table. +// ** +// ** argv[0] -> module name +// ** argv[1] -> database name +// ** argv[2] -> table name +// ** argv[...] -> column names... +// */ +func _rtreeInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr, isCreate int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aErrMsg [5]uintptr + var eCoordType, iErr, ii, nDb, nName, rc, v1 int32 + var pRtree, pSql, zArg, zSql uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = aErrMsg, eCoordType, iErr, ii, nDb, nName, pRtree, pSql, rc, zArg, zSql, v1 + rc = SQLITE_OK + if pAux != 0 { + v1 = int32(RTREE_COORD_INT32) + } else { + v1 = RTREE_COORD_REAL32 + } /* Length of string argv[2] */ + eCoordType = v1 + ii = int32(4) + aErrMsg = [5]uintptr{ + 1: __ccgo_ts + 28732, + 2: __ccgo_ts + 28775, + 3: __ccgo_ts + 28810, + 4: __ccgo_ts + 28846, + } + if argc < int32(6) || argc > libc.Int32FromInt32(RTREE_MAX_AUX_COLUMN)+libc.Int32FromInt32(3) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[int32(2)+libc.BoolInt32(argc >= int32(6))])) + return int32(SQLITE_ERROR) + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_CONSTRAINT_SUPPORT), libc.VaList(bp+8, int32(1))) + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + /* Allocate the sqlite3_vtab structure */ + nDb = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 1*8)))) + nName = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + pRtree = Xsqlite3_malloc64(tls, uint64(uint64(976)+libc.Uint64FromInt32(nDb)+libc.Uint64FromInt32(nName*int32(2))+uint64(8))) + if !(pRtree != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pRtree, 0, uint64(976)+libc.Uint64FromInt32(nDb)+libc.Uint64FromInt32(nName*int32(2))+uint64(8)) + (*TRtree)(unsafe.Pointer(pRtree)).FnBusy = uint32(1) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&_rtreeModule)) + (*TRtree)(unsafe.Pointer(pRtree)).FzDb = pRtree + 1*976 + (*TRtree)(unsafe.Pointer(pRtree)).FzName = (*TRtree)(unsafe.Pointer(pRtree)).FzDb + uintptr(nDb+int32(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName = (*TRtree)(unsafe.Pointer(pRtree)).FzName + uintptr(nName+int32(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FeCoordType = libc.Uint8FromInt32(eCoordType) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, **(**uintptr)(__ccgo_up(argv + 1*8)), libc.Uint64FromInt32(nDb)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt32(nName)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt32(nName)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName+uintptr(nName), __ccgo_ts+28883, uint64(6)) + /* Create/Connect to the underlying relational database schema. If + ** that is successful, call sqlite3_declare_vtab() to configure + ** the r-tree table schema. + */ + pSql = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+28889, libc.VaList(bp+8, _rtreeTokenLength(tls, **(**uintptr)(__ccgo_up(argv + 3*8))), **(**uintptr)(__ccgo_up(argv + 3*8)))) + ii = int32(4) + for { + if !(ii < argc) { + break + } + zArg = **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg))) == int32('+') { + (*TRtree)(unsafe.Pointer(pRtree)).FnAux = (*TRtree)(unsafe.Pointer(pRtree)).FnAux + 1 + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+28913, libc.VaList(bp+8, _rtreeTokenLength(tls, zArg+uintptr(1)), zArg+uintptr(1))) + } else { + if libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux) > 0 { + break + } else { + (*TRtree)(unsafe.Pointer(pRtree)).FnDim2 = (*TRtree)(unsafe.Pointer(pRtree)).FnDim2 + 1 + Xsqlite3_str_appendf(tls, pSql, _azFormat[eCoordType], libc.VaList(bp+8, _rtreeTokenLength(tls, zArg), zArg)) + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+28940, 0) + zSql = Xsqlite3_str_finish(tls, pSql) + if !(zSql != 0) { + rc = int32(SQLITE_NOMEM) + } else { + if ii < argc { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[int32(4)])) + rc = int32(SQLITE_ERROR) + } else { + v1 = Xsqlite3_declare_vtab(tls, db, zSql) + rc = v1 + if SQLITE_OK != v1 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + } + } + } + Xsqlite3_free(tls, zSql) + if rc != 0 { + goto rtreeInit_fail + } + (*TRtree)(unsafe.Pointer(pRtree)).FnDim = libc.Uint8FromInt32(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) / int32(2)) + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim) < int32(1) { + iErr = int32(2) + } else { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) > libc.Int32FromInt32(RTREE_MAX_DIMENSIONS)*libc.Int32FromInt32(2) { + iErr = int32(3) + } else { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)%int32(2) != 0 { + iErr = int32(1) + } else { + iErr = 0 + } + } + } + if iErr != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[iErr])) + goto rtreeInit_fail + } + (*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell = libc.Uint8FromInt32(int32(8) + libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)*int32(4)) + /* Figure out the node size to use. */ + rc = _getNodeSize(tls, db, pRtree, isCreate, pzErr) + if rc != 0 { + goto rtreeInit_fail + } + rc = _rtreeSqlInit(tls, pRtree, db, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), isCreate) + if rc != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + goto rtreeInit_fail + } + **(**uintptr)(__ccgo_up(ppVtab)) = pRtree + return SQLITE_OK + goto rtreeInit_fail +rtreeInit_fail: + ; + if rc == SQLITE_OK { + rc = int32(SQLITE_ERROR) + } + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append the string representation of integer iVal +// ** to the buffer. No nul-terminator is written. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendInteger(tls *libc.TLS, p uintptr, iVal int32, pRc uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* aBuf at bp+0 */ [24]uint8 + Xsqlite3_snprintf(tls, libc.Int32FromUint64(libc.Uint64FromInt64(24)-libc.Uint64FromInt32(1)), bp, __ccgo_ts+5289, libc.VaList(bp+32, iVal)) + _sessionAppendStr(tls, p, bp, pRc) +} + +// C documentation +// +// /* +// ** Add a new column to the table currently being constructed. +// ** +// ** The parser calls this routine once for each column declaration +// ** in a CREATE TABLE statement. sqlite3StartTable() gets called +// ** first to get things going. Then this routine is called for each +// ** column. +// */ +func _sqlite3AddColumn(tls *libc.TLS, pParse uintptr, _sName TToken, _sType TToken) { + bp := tls.Alloc(48) + defer tls.Free(48) + *(*TToken)(unsafe.Pointer(bp)) = _sName + *(*TToken)(unsafe.Pointer(bp + 16)) = _sType + var aNew, db, p, pCol, z, zType, v1 uintptr + var affinity uint8 + var eType, h, szEst Tu8 + var i int32 + _, _, _, _, _, _, _, _, _, _, _, _ = aNew, affinity, db, eType, h, i, p, pCol, szEst, z, zType, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + eType = uint8(COLTYPE_CUSTOM) + szEst = uint8(1) + affinity = uint8(SQLITE_AFF_BLOB) + v1 = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + p = v1 + if v1 == uintptr(0) { + return + } + if int32((*TTable)(unsafe.Pointer(p)).FnCol)+int32(1) > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13956, libc.VaList(bp+40, (*TTable)(unsafe.Pointer(p)).FzName)) + return + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + _sqlite3DequoteToken(tls, bp) + } + /* Because keywords GENERATE ALWAYS can be converted into identifiers + ** by the parser, we can sometimes end up with a typename that ends + ** with "generated always". Check for this case and omit the surplus + ** text. */ + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(16) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz+uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-libc.Uint32FromInt32(6)), __ccgo_ts+13979, int32(6)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn -= uint32(6) + for (**(**TToken)(__ccgo_up(bp + 16))).Fn > uint32(0) && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up((**(**TToken)(__ccgo_up(bp + 16))).Fz + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-uint32(1)))))])&int32(0x01) != 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = (**(**TToken)(__ccgo_up(bp + 16))).Fn - 1 + } + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(9) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz+uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-libc.Uint32FromInt32(9)), __ccgo_ts+13986, int32(9)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn -= uint32(9) + for (**(**TToken)(__ccgo_up(bp + 16))).Fn > uint32(0) && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up((**(**TToken)(__ccgo_up(bp + 16))).Fz + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-uint32(1)))))])&int32(0x01) != 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = (**(**TToken)(__ccgo_up(bp + 16))).Fn - 1 + } + } + } + /* Check for standard typenames. For standard typenames we will + ** set the Column.eType field rather than storing the typename after + ** the column name, in order to save space. */ + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(3) { + _sqlite3DequoteToken(tls, bp+16) + i = 0 + for { + if !(i < int32(SQLITE_N_STDTYPE)) { + break + } + if (**(**TToken)(__ccgo_up(bp + 16))).Fn == uint32(_sqlite3StdTypeLen[i]) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz, _sqlite3StdType[i], libc.Int32FromUint32((**(**TToken)(__ccgo_up(bp + 16))).Fn)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = uint32(0) + eType = libc.Uint8FromInt32(i + int32(1)) + affinity = _sqlite3StdTypeAffinity[i] + if libc.Int32FromUint8(affinity) <= int32(SQLITE_AFF_TEXT) { + szEst = uint8(5) + } + break + } + goto _2 + _2: + ; + i = i + 1 + } + } + z = _sqlite3DbMallocRaw(tls, db, libc.Uint64FromInt64(libc.Int64FromUint32((**(**TToken)(__ccgo_up(bp))).Fn)+int64(1)+libc.Int64FromUint32((**(**TToken)(__ccgo_up(bp + 16))).Fn)+libc.BoolInt64((**(**TToken)(__ccgo_up(bp + 16))).Fn > libc.Uint32FromInt32(0)))) + if z == uintptr(0) { + return + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, z, bp) + } + libc.Xmemcpy(tls, z, (**(**TToken)(__ccgo_up(bp))).Fz, uint64((**(**TToken)(__ccgo_up(bp))).Fn)) + **(**uint8)(__ccgo_up(z + uintptr((**(**TToken)(__ccgo_up(bp))).Fn))) = uint8(0) + _sqlite3Dequote(tls, z) + if (*TTable)(unsafe.Pointer(p)).FnCol != 0 && _sqlite3ColumnIndex(tls, p, z) >= 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13996, libc.VaList(bp+40, z)) + _sqlite3DbFree(tls, db, z) + return + } + aNew = _sqlite3DbRealloc(tls, db, (*TTable)(unsafe.Pointer(p)).FaCol, libc.Uint64FromInt64(int64((*TTable)(unsafe.Pointer(p)).FnCol)+libc.Int64FromInt32(1))*uint64(16)) + if aNew == uintptr(0) { + _sqlite3DbFree(tls, db, z) + return + } + (*TTable)(unsafe.Pointer(p)).FaCol = aNew + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr((*TTable)(unsafe.Pointer(p)).FnCol)*16 + libc.Xmemset(tls, pCol, 0, uint64(16)) + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = z + (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, z) + if (**(**TToken)(__ccgo_up(bp + 16))).Fn == uint32(0) { + /* If there is no type specified, columns have the default affinity + ** 'BLOB' with a default size of 4 bytes. */ + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = affinity + libc.SetBitFieldPtr8Uint32(pCol+8, uint32(eType), 4, 0xf0) + (*TColumn)(unsafe.Pointer(pCol)).FszEst = szEst + } else { + zType = z + uintptr(_sqlite3Strlen30(tls, z)) + uintptr(1) + libc.Xmemcpy(tls, zType, (**(**TToken)(__ccgo_up(bp + 16))).Fz, uint64((**(**TToken)(__ccgo_up(bp + 16))).Fn)) + **(**uint8)(__ccgo_up(zType + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn))) = uint8(0) + _sqlite3Dequote(tls, zType) + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3AffinityType(tls, zType, pCol) + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_HASTYPE)) + } + if int32((*TTable)(unsafe.Pointer(p)).FnCol) <= int32(0xff) { + h = uint8(uint64((*TColumn)(unsafe.Pointer(pCol)).FhName) % uint64(16)) + **(**Tu8)(__ccgo_up(p + 104 + uintptr(h))) = libc.Uint8FromInt16((*TTable)(unsafe.Pointer(p)).FnCol) + } + (*TTable)(unsafe.Pointer(p)).FnCol = (*TTable)(unsafe.Pointer(p)).FnCol + 1 + (*TTable)(unsafe.Pointer(p)).FnNVCol = (*TTable)(unsafe.Pointer(p)).FnNVCol + 1 + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName.Fn = uint32(0) +} + +// C documentation +// +// /* +// ** This function is called by the parser upon parsing an +// ** +// ** ALTER TABLE pSrc DROP COLUMN pName +// ** +// ** statement. Argument pSrc contains the possibly qualified name of the +// ** table being edited, and token pName the name of the column to drop. +// */ +func _sqlite3AlterDropColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var addr, i, iCol, iColPos, iCur, iDb, iPos, nField, reg, regOut, regRec, v2 int32 + var aff uint8 + var db, pPk, pTab, v, zCol, zDb, v1 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, aff, db, i, iCol, iColPos, iCur, iDb, iPos, nField, pPk, pTab, reg, regOut, regRec, v, zCol, zDb, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database containing pTab ("main" etc.) */ + zCol = uintptr(0) /* Index of column zCol in pTab->aCol[] */ + /* Look up the table being altered. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_drop_column + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_drop_column + } + /* Make sure this is not an attempt to ALTER a view, virtual table or + ** system table. */ + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_drop_column + } + if SQLITE_OK != _isRealTable(tls, pParse, pTab, int32(1)) { + goto exit_drop_column + } + /* Find the index of the column being dropped. */ + zCol = _sqlite3NameFromToken(tls, db, pName) + if zCol == uintptr(0) { + goto exit_drop_column + } + iCol = _sqlite3ColumnIndex(tls, pTab, zCol) + if iCol < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11207, libc.VaList(bp+8, pName)) + goto exit_drop_column + } + /* Do not allow the user to drop a PRIMARY KEY column or a column + ** constrained by a UNIQUE constraint. */ + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&(libc.Int32FromInt32(COLFLAG_PRIMKEY)|libc.Int32FromInt32(COLFLAG_UNIQUE)) != 0 { + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + v1 = __ccgo_ts + 11592 + } else { + v1 = __ccgo_ts + 5831 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11604, libc.VaList(bp+8, v1, zCol)) + goto exit_drop_column + } + /* Do not allow the number of columns to go to zero */ + if int32((*TTable)(unsafe.Pointer(pTab)).FnCol) <= int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11632, libc.VaList(bp+8, zCol)) + goto exit_drop_column + } + /* Edit the sqlite_schema table */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, zCol) != 0 { + goto exit_drop_column + } + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1)), __ccgo_ts+1704, 0) + _renameFixQuotes(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1))) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11680, libc.VaList(bp+8, zDb, iDb, iCol, (*TTable)(unsafe.Pointer(pTab)).FzName)) + /* Drop and reload the database schema. */ + _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterDrop)) + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1)), __ccgo_ts+11801, int32(1)) + /* Edit rows of table on disk */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + pPk = uintptr(0) + nField = 0 + v = _sqlite3GetVdbe(tls, pParse) + v1 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + iCur = v2 + _sqlite3OpenTable(tls, pParse, iCur, iDb, pTab, int32(OP_OpenWrite)) + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iCur) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + reg = v2 + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iCur, reg) + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnColumn) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iCur, i, reg+i+int32(1)) + goto _6 + _6: + ; + i = i + 1 + } + nField = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + regRec = v2 + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if i != iCol && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + if pPk != 0 { + iPos = _sqlite3TableColumnToIndex(tls, pPk, i) + iColPos = _sqlite3TableColumnToIndex(tls, pPk, iCol) + if iPos < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) { + goto _9 + } + regOut = reg + int32(1) + iPos - libc.BoolInt32(iPos > iColPos) + } else { + regOut = reg + int32(1) + nField + } + if i == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regOut) + } else { + aff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity + if libc.Int32FromUint8(aff) == int32(SQLITE_AFF_REAL) { + (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity = uint8(SQLITE_AFF_NUMERIC) + } + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, i, regOut) + (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity = aff + } + nField = nField + 1 + } + goto _9 + _9: + ; + i = i + 1 + } + if nField == 0 { + /* dbsqlfuzz 5f09e7bcc78b4954d06bf9f2400d7715f48d1fef */ + (*TParse)(unsafe.Pointer(pParse)).FnMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + 1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, reg+int32(1)) + nField = int32(1) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), reg+int32(1), nField, regRec) + if pPk != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iCur, regRec, reg+int32(1), libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iCur, regRec, reg) + } + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iCur, addr+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addr) + } + goto exit_drop_column +exit_drop_column: + ; + _sqlite3DbFree(tls, db, zCol) + _sqlite3SrcListDelete(tls, db, pSrc) +} + +// C documentation +// +// /* +// ** This function is called after an "ALTER TABLE ... ADD" statement +// ** has been parsed. Argument pColDef contains the text of the new +// ** column definition. +// ** +// ** The Table structure pParse->pNewTable was extended to include +// ** the new column during parsing. +// */ +func _sqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pCol, pDflt, pNew, pTab, v, zCol, zDb, zEnd, zTab, v1 uintptr + var iDb, r1, rc int32 + var _ /* pVal at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, iDb, pCol, pDflt, pNew, pTab, r1, rc, v, zCol, zDb, zEnd, zTab, v1 /* Temporary registers */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pNew)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + zTab = (*TTable)(unsafe.Pointer(pNew)).FzName + 16 /* Skip the "sqlite_altertab_" prefix on the name */ + pCol = (*TTable)(unsafe.Pointer(pNew)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pNew)).FnCol)-int32(1))*16 + pDflt = _sqlite3ColumnExpr(tls, pNew, pCol) + pTab = _sqlite3FindTable(tls, db, zTab, zDb) + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + return + } + /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. + ** If there is a NOT NULL constraint, then the default value for the + ** column must not be NULL. + */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+10289, 0) + return + } + if (*TTable)(unsafe.Pointer(pNew)).FpIndex != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+10321, 0) + return + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) == 0 { + /* If the default value for the new column was specified with a + ** literal NULL, then set pDflt to 0. This simplifies checking + ** for an SQL NULL default below. + */ + if pDflt != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == int32(TK_NULL) { + pDflt = uintptr(0) + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FpFKey != 0 && pDflt != 0 { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10348) + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 && !(pDflt != 0) { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10407) + } + /* Ensure the default expression is something that sqlite3ValueFromExpr() + ** can handle (i.e. not CURRENT_TIME etc.) + */ + if pDflt != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _sqlite3ValueFromExpr(tls, db, pDflt, uint8(SQLITE_UTF8), uint8(SQLITE_AFF_BLOB), bp) + if rc != SQLITE_OK { + return + } + if !(**(**uintptr)(__ccgo_up(bp)) != 0) { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10460) + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp))) + } + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_STORED) != 0 { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10506) + } + } + /* Modify the CREATE TABLE statement. */ + zCol = _sqlite3DbStrNDup(tls, db, (*TToken)(unsafe.Pointer(pColDef)).Fz, uint64((*TToken)(unsafe.Pointer(pColDef)).Fn)) + if zCol != 0 { + zEnd = zCol + uintptr((*TToken)(unsafe.Pointer(pColDef)).Fn-uint32(1)) + for zEnd > zCol && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zEnd))) == int32(';') || libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zEnd)))])&int32(0x01) != 0) { + v1 = zEnd + zEnd = zEnd - 1 + **(**uint8)(__ccgo_up(v1)) = uint8('\000') + } + /* substr() operations on characters, but addColOffset is in bytes. So we + ** have to use printf() to translate between these units: */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10533, libc.VaList(bp+16, zDb, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FaddColOffset, zCol, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FaddColOffset, zTab)) + _sqlite3DbFree(tls, db, zCol) + } + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + /* Make sure the schema version is at least 3. But do not upgrade + ** from less than 3 to 4, as that will corrupt any preexisting DESC + ** index. + */ + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_ReadCookie), iDb, r1, int32(BTREE_FILE_FORMAT)) + _sqlite3VdbeUsesBtree(tls, v, iDb) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), r1, -int32(2)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), r1, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_FILE_FORMAT), int32(3)) + _sqlite3ReleaseTempReg(tls, pParse, r1) + /* Reload the table definition */ + _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterAdd)) + /* Verify that constraints are still satisfied */ + if (*TTable)(unsafe.Pointer(pNew)).FpCheck != uintptr(0) || int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 && libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Strict) != uint32(0) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10679, libc.VaList(bp+16, zTab, zDb)) + } + } +} + +// C documentation +// +// /* +// ** Handles the following parser reduction: +// ** +// ** cmd ::= ALTER TABLE pSrc RENAME COLUMN pOld TO pNew +// */ +func _sqlite3AlterRenameColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pOld uintptr, pNew uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bQuote, iCol, iSchema int32 + var db, pTab, zDb, zNew, zOld uintptr + _, _, _, _, _, _, _, _ = bQuote, db, iCol, iSchema, pTab, zDb, zNew, zOld + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Index of column being renamed */ + zOld = uintptr(0) /* Old column name */ + zNew = uintptr(0) /* True to quote the new name */ + /* Locate the table to be altered */ + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_rename_column + } + /* Cannot alter a system table */ + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_rename_column + } + if SQLITE_OK != _isRealTable(tls, pParse, pTab, 0) { + goto exit_rename_column + } + /* Which schema holds the table to be altered */ + iSchema = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*32))).FzDbSName + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + goto exit_rename_column + } + /* Make sure the old name really is a column name in the table to be + ** altered. Set iCol to be the index of the column being renamed */ + zOld = _sqlite3NameFromToken(tls, db, pOld) + if !(zOld != 0) { + goto exit_rename_column + } + iCol = _sqlite3ColumnIndex(tls, pTab, zOld) + if iCol < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11207, libc.VaList(bp+8, pOld)) + goto exit_rename_column + } + /* Ensure the schema contains no double-quoted strings */ + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1)), __ccgo_ts+1704, 0) + _renameFixQuotes(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1))) + /* Do the rename operation using a recursive UPDATE statement that + ** uses the sqlite_rename_column() SQL function to compute the new + ** CREATE statement text for the sqlite_schema table. + */ + _sqlite3MayAbort(tls, pParse) + zNew = _sqlite3NameFromToken(tls, db, pNew) + if !(zNew != 0) { + goto exit_rename_column + } + bQuote = libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up((*TToken)(unsafe.Pointer(pNew)).Fz)))]) & int32(0x80) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11228, libc.VaList(bp+8, zDb, zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, iCol, zNew, bQuote, libc.BoolInt32(iSchema == int32(1)), (*TTable)(unsafe.Pointer(pTab)).FzName)) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11410, libc.VaList(bp+8, zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, iCol, zNew, bQuote)) + /* Drop and reload the database schema. */ + _renameReloadSchema(tls, pParse, iSchema, uint16(INITFLAG_AlterRename)) + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1)), __ccgo_ts+10238, int32(1)) + goto exit_rename_column +exit_rename_column: + ; + _sqlite3SrcListDelete(tls, db, pSrc) + _sqlite3DbFree(tls, db, zOld) + _sqlite3DbFree(tls, db, zNew) + return +} + +// C documentation +// +// /* +// ** This routine does a complete check of the given BTree file. aRoot[] is +// ** an array of pages numbers were each page number is the root page of +// ** a table. nRoot is the number of entries in aRoot. +// ** +// ** A read-only or read-write transaction must be opened before calling +// ** this function. +// ** +// ** Write the number of error seen in *pnErr. Except for some memory +// ** allocation errors, an error message held in memory obtained from +// ** malloc is returned if *pnErr is non-zero. If *pnErr==0 then NULL is +// ** returned. If a memory allocation error occurs, NULL is returned. +// ** +// ** If the first entry in aRoot[] is 0, that indicates that the list of +// ** root pages is incomplete. This is a "partial integrity-check". This +// ** happens when performing an integrity check on a single table. The +// ** zero is skipped, of course. But in addition, the freelist checks +// ** and the checks to make sure every page is referenced are also skipped, +// ** since obviously it is not possible to know which pages are covered by +// ** the unverified btrees. Except, if aRoot[1] is 1, then the freelist +// ** checks are still performed. +// */ +func _sqlite3BtreeIntegrityCheck(tls *libc.TLS, db uintptr, p uintptr, aRoot uintptr, aCnt uintptr, nRoot int32, mxErr int32, pnErr uintptr, pzOut uintptr) (r int32) { + bp := tls.Alloc(272) + defer tls.Free(272) + var bCkFreelist, bPartial int32 + var i, mx, mxInHdr TPgno + var pBt uintptr + var savedDbFlags Tu64 + var _ /* notUsed at bp+232 */ Ti64 + var _ /* sCheck at bp+0 */ TIntegrityCk + var _ /* zErr at bp+128 */ [100]uint8 + _, _, _, _, _, _, _ = bCkFreelist, bPartial, i, mx, mxInHdr, pBt, savedDbFlags + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + savedDbFlags = (*Tsqlite3)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags + bPartial = 0 /* True if not checking all btrees */ + bCkFreelist = int32(1) /* True to scan the freelist */ + /* aRoot[0]==0 means this is a partial check */ + if **(**TPgno)(__ccgo_up(aRoot)) == uint32(0) { + bPartial = int32(1) + if **(**TPgno)(__ccgo_up(aRoot + 1*4)) != uint32(1) { + bCkFreelist = 0 + } + } + _sqlite3BtreeEnter(tls, p) + libc.Xmemset(tls, bp, 0, uint64(128)) + (**(**TIntegrityCk)(__ccgo_up(bp))).Fdb = db + (**(**TIntegrityCk)(__ccgo_up(bp))).FpBt = pBt + (**(**TIntegrityCk)(__ccgo_up(bp))).FpPager = (*TBtShared)(unsafe.Pointer(pBt)).FpPager + (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage = _btreePagecount(tls, (**(**TIntegrityCk)(__ccgo_up(bp))).FpBt) + (**(**TIntegrityCk)(__ccgo_up(bp))).FmxErr = mxErr + _sqlite3StrAccumInit(tls, bp+72, uintptr(0), bp+128, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TIntegrityCk)(__ccgo_up(bp))).FerrMsg.FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + if (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage == uint32(0) { + goto integrity_ck_cleanup + } + (**(**TIntegrityCk)(__ccgo_up(bp))).FaPgRef = _sqlite3MallocZero(tls, uint64((**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage/uint32(8)+uint32(1))) + if !((**(**TIntegrityCk)(__ccgo_up(bp))).FaPgRef != 0) { + _checkOom(tls, bp) + goto integrity_ck_cleanup + } + (**(**TIntegrityCk)(__ccgo_up(bp))).Fheap = _sqlite3PageMalloc(tls, libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FpageSize)) + if (**(**TIntegrityCk)(__ccgo_up(bp))).Fheap == uintptr(0) { + _checkOom(tls, bp) + goto integrity_ck_cleanup + } + i = libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize + libc.Uint32FromInt32(1) + if i <= (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage { + _setPageReferenced(tls, bp, i) + } + /* Check the integrity of the freelist + */ + if bCkFreelist != 0 { + (**(**TIntegrityCk)(__ccgo_up(bp))).FzPfx = __ccgo_ts + 4962 + _checkList(tls, bp, int32(1), _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+32), _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36)) + (**(**TIntegrityCk)(__ccgo_up(bp))).FzPfx = uintptr(0) + } + /* Check all the tables. + */ + if !(bPartial != 0) { + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + mx = uint32(0) + i = uint32(0) + for { + if !(libc.Int32FromUint32(i) < nRoot) { + break + } + if mx < **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) { + mx = **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) + } + goto _1 + _1: + ; + i = i + 1 + } + mxInHdr = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+52) + if mx != mxInHdr { + _checkAppendMsg(tls, bp, __ccgo_ts+4973, libc.VaList(bp+248, mx, mxInHdr)) + } + } else { + if _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+64) != uint32(0) { + _checkAppendMsg(tls, bp, __ccgo_ts+5018, 0) + } + } + } + **(**Tu64)(__ccgo_up((*TBtShared)(unsafe.Pointer(pBt)).Fdb + 48)) &= ^libc.Uint64FromInt32(SQLITE_CellSizeCk) + i = uint32(0) + for { + if !(libc.Int32FromUint32(i) < nRoot && (**(**TIntegrityCk)(__ccgo_up(bp))).FmxErr != 0) { + break + } + (**(**TIntegrityCk)(__ccgo_up(bp))).FnRow = 0 + if **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) != 0 { + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) > uint32(1) && !(bPartial != 0) { + _checkPtrmap(tls, bp, **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)), uint8(PTRMAP_ROOTPAGE), uint32(0)) + } + (**(**TIntegrityCk)(__ccgo_up(bp))).Fv0 = **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) + _checkTreePage(tls, bp, **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)), bp+232, libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< nFilename { + v1 = nFullPathname + } else { + v1 = nFilename + } + zFullPathname = _sqlite3Malloc(tls, libc.Uint64FromInt32(v1)) + (*TBtree)(unsafe.Pointer(p)).Fsharable = uint8(1) + if !(zFullPathname != 0) { + Xsqlite3_free(tls, p) + return int32(SQLITE_NOMEM) + } + if isMemdb != 0 { + libc.Xmemcpy(tls, zFullPathname, zFilename, libc.Uint64FromInt32(nFilename)) + } else { + rc = _sqlite3OsFullPathname(tls, pVfs, zFilename, nFullPathname, zFullPathname) + if rc != 0 { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(2)<= 0) { + break + } + pExisting = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if pExisting != 0 && (*TBtree)(unsafe.Pointer(pExisting)).FpBt == pBt { + Xsqlite3_mutex_leave(tls, mutexShared) + Xsqlite3_mutex_leave(tls, mutexOpen) + Xsqlite3_free(tls, zFullPathname) + Xsqlite3_free(tls, p) + return int32(SQLITE_CONSTRAINT) + } + goto _3 + _3: + ; + iDb = iDb - 1 + } + (*TBtree)(unsafe.Pointer(p)).FpBt = pBt + (*TBtShared)(unsafe.Pointer(pBt)).FnRef = (*TBtShared)(unsafe.Pointer(pBt)).FnRef + 1 + break + } + goto _2 + _2: + ; + pBt = (*TBtShared)(unsafe.Pointer(pBt)).FpNext + } + Xsqlite3_mutex_leave(tls, mutexShared) + Xsqlite3_free(tls, zFullPathname) + } + } + if pBt == uintptr(0) { + /* + ** The following asserts make sure that structures used by the btree are + ** the right size. This is to guard against size changes that result + ** when compiling on a different architecture. + */ + /* Suppress false-positive compiler warning from PVS-Studio */ + libc.Xmemset(tls, bp+16, 0, uint64(8)) + pBt = _sqlite3MallocZero(tls, uint64(152)) + if pBt == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto btree_open_out + } + rc = _sqlite3PagerOpen(tls, pVfs, pBt, zFilename, int32(136), flags, vfsFlags, __ccgo_fp(_pageReinit)) + if rc == SQLITE_OK { + _sqlite3PagerSetMmapLimit(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, (*Tsqlite3)(unsafe.Pointer(db)).FszMmap) + rc = _sqlite3PagerReadFileheader(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, int32(100), bp) + } + if rc != SQLITE_OK { + goto btree_open_out + } + (*TBtShared)(unsafe.Pointer(pBt)).FopenFlags = libc.Uint8FromInt32(flags) + (*TBtShared)(unsafe.Pointer(pBt)).Fdb = db + _sqlite3PagerSetBusyHandler(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, __ccgo_fp(_btreeInvokeBusyHandler), pBt) + (*TBtree)(unsafe.Pointer(p)).FpBt = pBt + (*TBtShared)(unsafe.Pointer(pBt)).FpCursor = uintptr(0) + (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0) + if _sqlite3PagerIsreadonly(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) != 0 { + v4 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(BTS_READ_ONLY)) + } + /* EVIDENCE-OF: R-51873-39618 The page size for a database file is + ** determined by the 2-byte integer located at an offset of 16 bytes from + ** the beginning of the database file. */ + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = libc.Uint32FromInt32(libc.Int32FromUint8((**(**[100]uint8)(__ccgo_up(bp)))[int32(16)])< uint32(SQLITE_MAX_PAGE_SIZE) || ((*TBtShared)(unsafe.Pointer(pBt)).FpageSize-uint32(1))&(*TBtShared)(unsafe.Pointer(pBt)).FpageSize != uint32(0) { + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = uint32(0) + /* If the magic name ":memory:" will create an in-memory database, then + ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if + ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if + ** SQLITE_OMIT_MEMORYDB has been defined, then ":memory:" is just a + ** regular file-name. In this case the auto-vacuum applies as per normal. + */ + if zFilename != 0 && !(isMemdb != 0) { + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(libc.Int32FromInt32(0)) + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(libc.Int32FromInt32(0)) + } + nReserve = uint8(0) + } else { + /* EVIDENCE-OF: R-37497-42412 The size of the reserved region is + ** determined by the one-byte unsigned integer found at an offset of 20 + ** into the database file header. */ + nReserve = (**(**[100]uint8)(__ccgo_up(bp)))[int32(20)] + v4 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + if _sqlite3Get4byte(tls, bp+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(4)*libc.Int32FromInt32(4))) != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(v1) + if _sqlite3Get4byte(tls, bp+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(7)*libc.Int32FromInt32(4))) != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(v1) + } + rc = _sqlite3PagerSetPagesize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pBt+52, libc.Int32FromUint8(nReserve)) + if rc != 0 { + goto btree_open_out + } + (*TBtShared)(unsafe.Pointer(pBt)).FusableSize = (*TBtShared)(unsafe.Pointer(pBt)).FpageSize - uint32(nReserve) + /* 8-byte alignment of pageSize */ + /* Add the new BtShared object to the linked list sharable BtShareds. + */ + (*TBtShared)(unsafe.Pointer(pBt)).FnRef = int32(1) + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + mutexShared1 = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + if libc.Bool(int32(SQLITE_THREADSAFE) != 0) && _sqlite3Config.FbCoreMutex != 0 { + (*TBtShared)(unsafe.Pointer(pBt)).Fmutex = _sqlite3MutexAlloc(tls, SQLITE_MUTEX_FAST) + if (*TBtShared)(unsafe.Pointer(pBt)).Fmutex == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto btree_open_out + } + } + Xsqlite3_mutex_enter(tls, mutexShared1) + (*TBtShared)(unsafe.Pointer(pBt)).FpNext = _sqlite3SharedCacheList + _sqlite3SharedCacheList = pBt + Xsqlite3_mutex_leave(tls, mutexShared1) + } + } + /* If the new Btree uses a sharable pBtShared, then link the new + ** Btree into the list of all sharable Btrees for the same connection. + ** The list is kept in ascending order by pBt address. + */ + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + v4 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + pSib = v4 + if v4 != uintptr(0) && (*TBtree)(unsafe.Pointer(pSib)).Fsharable != 0 { + for (*TBtree)(unsafe.Pointer(pSib)).FpPrev != 0 { + pSib = (*TBtree)(unsafe.Pointer(pSib)).FpPrev + } + if uint64((*TBtree)(unsafe.Pointer(p)).FpBt) < uint64((*TBtree)(unsafe.Pointer(pSib)).FpBt) { + (*TBtree)(unsafe.Pointer(p)).FpNext = pSib + (*TBtree)(unsafe.Pointer(p)).FpPrev = uintptr(0) + (*TBtree)(unsafe.Pointer(pSib)).FpPrev = p + } else { + for (*TBtree)(unsafe.Pointer(pSib)).FpNext != 0 && uint64((*TBtree)(unsafe.Pointer((*TBtree)(unsafe.Pointer(pSib)).FpNext)).FpBt) < uint64((*TBtree)(unsafe.Pointer(p)).FpBt) { + pSib = (*TBtree)(unsafe.Pointer(pSib)).FpNext + } + (*TBtree)(unsafe.Pointer(p)).FpNext = (*TBtree)(unsafe.Pointer(pSib)).FpNext + (*TBtree)(unsafe.Pointer(p)).FpPrev = pSib + if (*TBtree)(unsafe.Pointer(p)).FpNext != 0 { + (*TBtree)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpNext)).FpPrev = p + } + (*TBtree)(unsafe.Pointer(pSib)).FpNext = p + } + break + } + goto _8 + _8: + ; + i = i + 1 + } + } + **(**uintptr)(__ccgo_up(ppBtree)) = p + goto btree_open_out +btree_open_out: + ; + if rc != SQLITE_OK { + if pBt != 0 && (*TBtShared)(unsafe.Pointer(pBt)).FpPager != 0 { + _sqlite3PagerClose(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, uintptr(0)) + } + Xsqlite3_free(tls, pBt) + Xsqlite3_free(tls, p) + **(**uintptr)(__ccgo_up(ppBtree)) = uintptr(0) + } else { + /* If the B-Tree was successfully opened, set the pager-cache size to the + ** default value. Except, when opening on an existing shared pager-cache, + ** do not change the pager-cache size. + */ + if _sqlite3BtreeSchema(tls, p, 0, uintptr(0)) == uintptr(0) { + _sqlite3BtreeSetCacheSize(tls, p, -int32(2000)) + } + pFile = _sqlite3PagerFile(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + if (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods != 0 { + _sqlite3OsFileControlHint(tls, pFile, int32(SQLITE_FCNTL_PDB), pBt+8) + } + } + if mutexOpen != 0 { + Xsqlite3_mutex_leave(tls, mutexOpen) + } + return rc +} + +// C documentation +// +// /* +// ** Remove entries from the sqlite_statN tables (for N in (1,2,3)) +// ** after a DROP INDEX or DROP TABLE command. +// */ +func _sqlite3ClearStatTables(tls *libc.TLS, pParse uintptr, iDb int32, zType uintptr, zName uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i int32 + var zDbName uintptr + var _ /* zTab at bp+0 */ [24]uint8 + _, _ = i, zDbName + zDbName = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName + i = int32(1) + for { + if !(i <= int32(4)) { + break + } + Xsqlite3_snprintf(tls, int32(24), bp, __ccgo_ts+14951, libc.VaList(bp+32, i)) + if _sqlite3FindTable(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, bp, zDbName) != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12936, libc.VaList(bp+32, zDbName, bp, zType, zName)) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Generate code that will construct an ephemeral table containing all terms +// ** in the RHS of an IN operator. The IN operator can be in either of two +// ** forms: +// ** +// ** x IN (4,5,11) -- IN operator with list on right-hand side +// ** x IN (SELECT a FROM b) -- IN operator with subquery on the right +// ** +// ** The pExpr parameter is the IN operator. The cursor number for the +// ** constructed ephemeral table is returned. The first time the ephemeral +// ** table is computed, the cursor number is also stored in pExpr->iTable, +// ** however the cursor number returned might not be the same, as it might +// ** have been duplicated using OP_OpenDup. +// ** +// ** If the LHS expression ("x" in the examples) is a column value, or +// ** the SELECT statement returns a column value, then the affinity of that +// ** column is used to build the index keys. If both 'x' and the +// ** SELECT... statement are columns, then numeric affinity is used +// ** if either column has NUMERIC or INTEGER affinity. If neither +// ** 'x' nor the SELECT... statement are columns, then numeric affinity +// ** is used. +// */ +func _sqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int32, allowBloom int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addr, addrBloom, addrOnce, i, i1, nVal, r1, r2, rc, regBloom, v1 int32 + var p, pCopy, pE2, pEList, pItem, pKeyInfo, pLeft, pList, pSelect, pSig, v, v2 uintptr + var _ /* affinity at bp+40 */ uint8 + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrBloom, addrOnce, i, i1, nVal, p, pCopy, pE2, pEList, pItem, pKeyInfo, pLeft, pList, pSelect, pSig, r1, r2, rc, regBloom, v, v1, v2 + addrOnce = 0 /* the LHS of the IN operator */ + pKeyInfo = uintptr(0) /* The prepared statement under construction */ + pSig = uintptr(0) /* Signature for this subroutine */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* The evaluation of the IN must be repeated every time it + ** is encountered if any of the following is true: + ** + ** * The right-hand side is a correlated subquery + ** * The right-hand side is an expression list containing variables + ** * We are inside a trigger + ** + ** If all of the above are false, then we can compute the RHS just once + ** and reuse it many names. + */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) != libc.Uint32FromInt32(0)) && (*TParse)(unsafe.Pointer(pParse)).FiSelfTab == 0 { + /* Reuse of the RHS is allowed + ** + ** Compute a signature for the RHS of the IN operator to facility + ** finding and reusing prior instances of the same IN operator. + */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselFlags&uint32(SF_All) == uint32(0) { + pSig = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(32)) + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FselId = libc.Int32FromUint32((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselId) + (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff = _exprINAffinity(tls, pParse, pExpr) + } + } + /* Check to see if there is a prior materialization of the RHS of + ** this IN operator. If there is, then make use of that prior + ** materialization rather than recomputing it. + */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) != uint32(0) || _findCompatibleInRhsSubrtn(tls, pParse, pExpr, pSig) != 0 { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8329, libc.VaList(bp+56, (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselId)) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), iTab, (*TExpr)(unsafe.Pointer(pExpr)).FiTable) + _sqlite3VdbeJumpHere(tls, v, addrOnce) + if pSig != 0 { + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSig) + } + return + } + /* Begin coding the subroutine */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn = v1 + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr = _sqlite3VdbeAddOp2(tls, v, int32(OP_BeginSubrtn), 0, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn) + int32(1) + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FbComplete = uint8(0) + (*TSubrtnSig)(unsafe.Pointer(pSig)).FiAddr = (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr + (*TSubrtnSig)(unsafe.Pointer(pSig)).FregReturn = (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn + (*TSubrtnSig)(unsafe.Pointer(pSig)).FiTable = iTab + (*TParse)(unsafe.Pointer(pParse)).FmSubrtnSig = libc.Uint8FromInt32(int32(1) << ((*TSubrtnSig)(unsafe.Pointer(pSig)).FselId & int32(7))) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pSig, -int32(18)) + } + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + /* Check to see if this is a vector IN operator */ + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + nVal = _sqlite3ExprVectorSize(tls, pLeft) + /* Construct the ephemeral table that will contain the content of + ** RHS of the IN operator. + */ + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = iTab + addr = _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, nVal) + pKeyInfo = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, nVal, int32(1)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + /* Case 1: expr IN (SELECT ...) + ** + ** Generate code to write the results of the select into the temporary + ** table allocated and opened above. + */ + pSelect = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + if addrOnce != 0 { + v2 = __ccgo_ts + 1704 + } else { + v2 = __ccgo_ts + 8352 + } + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+8364, libc.VaList(bp+56, v2, (*TSelect)(unsafe.Pointer(pSelect)).FselId)) + /* If the LHS and RHS of the IN operator do not match, that + ** error will have been caught long before we reach this point. */ + if (*TExprList)(unsafe.Pointer(pEList)).FnExpr == nVal { + addrBloom = 0 + _sqlite3SelectDestInit(tls, bp, int32(SRT_Set), iTab) + (**(**TSelectDest)(__ccgo_up(bp))).FzAffSdst = _exprINAffinity(tls, pParse, pExpr) + (*TSelect)(unsafe.Pointer(pSelect)).FiLimit = 0 + if addrOnce != 0 && allowBloom != 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_BloomFilter)) == uint32(0) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regBloom = v1 + addrBloom = _sqlite3VdbeAddOp2(tls, v, int32(OP_Blob), int32(10000), regBloom) + (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 = regBloom + } + /* Caused by OOM in sqlite3KeyInfoAlloc() */ + pCopy = _sqlite3SelectDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect, 0) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + v1 = int32(1) + } else { + v1 = _sqlite3Select(tls, pParse, pCopy, bp) + } + rc = v1 + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCopy) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (**(**TSelectDest)(__ccgo_up(bp))).FzAffSdst) + if addrBloom != 0 { + /* Remember that location of the Bloom filter in the P3 operand + ** of the OP_Once that began this subroutine. tag-202407032019 */ + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, v, addrOnce))).Fp3 = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 + if (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 == 0 { + /* If the Bloom filter won't actually be used, keep it small */ + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, v, addrBloom))).Fp1 = int32(10) + } + } + if rc != 0 { + _sqlite3KeyInfoUnref(tls, pKeyInfo) + return + } + /* OOM will cause exit after sqlite3Select() */ + i = 0 + for { + if !(i < nVal) { + break + } + p = _sqlite3VectorFieldSubexpr(tls, pLeft, i) + *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)) = _sqlite3BinaryCompareCollSeq(tls, pParse, p, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr) + goto _7 + _7: + ; + i = i + 1 + } + } + } else { + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != uintptr(0) { + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + **(**uint8)(__ccgo_up(bp + 40)) = _sqlite3ExprAffinity(tls, pLeft) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(bp + 40))) <= int32(SQLITE_AFF_NONE) { + **(**uint8)(__ccgo_up(bp + 40)) = uint8(SQLITE_AFF_BLOB) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(bp + 40))) == int32(SQLITE_AFF_REAL) { + **(**uint8)(__ccgo_up(bp + 40)) = uint8(SQLITE_AFF_NUMERIC) + } + } + if pKeyInfo != 0 { + *(*uintptr)(unsafe.Pointer(pKeyInfo + 32)) = _sqlite3ExprCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + } + /* Loop through each expression in . */ + r1 = _sqlite3GetTempReg(tls, pParse) + r2 = _sqlite3GetTempReg(tls, pParse) + i1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + pItem = pList + 8 + for { + if !(i1 > 0) { + break + } + pE2 = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + /* If the expression is not constant then we will need to + ** disable the test that was generated above that makes sure + ** this code only executes once. Because for a non-constant + ** expression we need to rerun this code each time. + */ + if addrOnce != 0 && !(_sqlite3ExprIsConstant(tls, pParse, pE2) != 0) { + _sqlite3VdbeChangeToNoop(tls, v, addrOnce-int32(1)) + _sqlite3VdbeChangeToNoop(tls, v, addrOnce) + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + addrOnce = 0 + } + /* Evaluate the expression and insert it into the temp table */ + _sqlite3ExprCode(tls, pParse, pE2, r1) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), r1, int32(1), r2, bp+40, int32(1)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iTab, r2, r1, int32(1)) + goto _8 + _8: + ; + i1 = i1 - 1 + pItem += 32 + } + _sqlite3ReleaseTempReg(tls, pParse, r1) + _sqlite3ReleaseTempReg(tls, pParse, r2) + } + } + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FbComplete = uint8(1) + } + if pKeyInfo != 0 { + _sqlite3VdbeChangeP4(tls, v, addr, pKeyInfo, -int32(9)) + } + if addrOnce != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iTab) + _sqlite3VdbeJumpHere(tls, v, addrOnce) + /* Subroutine return */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr, int32(1)) + _sqlite3ClearTempRegCache(tls, pParse) + } +} + +// C documentation +// +// /* +// ** Generate code for scalar subqueries used as a subquery expression +// ** or EXISTS operator: +// ** +// ** (SELECT a FROM b) -- subquery +// ** EXISTS (SELECT a FROM b) -- EXISTS subquery +// ** +// ** The pExpr parameter is the SELECT or EXISTS operator to be coded. +// ** +// ** Return the register that holds the result. For a multi-column SELECT, +// ** the result is stored in a contiguous array of registers and the +// ** return value is the register of the left-most result column. +// ** Return 0 if an error occurs. +// */ +func _sqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var addrOnce, nReg, rReg, v1 int32 + var db, pLeft, pLimit, pSel, v, v2 uintptr + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _ = addrOnce, db, nReg, pLeft, pLimit, pSel, rReg, v, v1, v2 + addrOnce = 0 /* Address of OP_Once at top of subroutine */ + rReg = 0 /* New limit expression */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return 0 + } + pSel = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + /* If this routine has already been coded, then invoke it as a + ** subroutine. */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) != uint32(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8383, libc.VaList(bp+48, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr) + return (*TExpr)(unsafe.Pointer(pExpr)).FiTable + } + /* Begin coding the subroutine */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn = v1 + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr = _sqlite3VdbeAddOp2(tls, v, int32(OP_BeginSubrtn), 0, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn) + int32(1) + /* The evaluation of the EXISTS/SELECT must be repeated every time it + ** is encountered if any of the following is true: + ** + ** * The right-hand side is a correlated subquery + ** * The right-hand side is an expression list containing variables + ** * We are inside a trigger + ** + ** If all of the above are false, then we can run this code just once + ** save the results, and reuse the same result on subsequent invocations. + */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) != libc.Uint32FromInt32(0)) { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + /* For a SELECT, generate code to put the values for all columns of + ** the first row into an array of registers and return the index of + ** the first register. + ** + ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists) + ** into a register and return that register number. + ** + ** In both cases, the query is augmented with "LIMIT 1". Any + ** preexisting limit is discarded in place of the new LIMIT 1. + */ + if addrOnce != 0 { + v2 = __ccgo_ts + 1704 + } else { + v2 = __ccgo_ts + 8352 + } + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+8401, libc.VaList(bp+48, v2, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) { + v1 = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpEList)).FnExpr + } else { + v1 = int32(1) + } + nReg = v1 + _sqlite3SelectDestInit(tls, bp, 0, (*TParse)(unsafe.Pointer(pParse)).FnMem+int32(1)) + **(**int32)(__ccgo_up(pParse + 60)) += nReg + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) { + (**(**TSelectDest)(__ccgo_up(bp))).FeDest = uint8(SRT_Mem) + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_Distinct) != 0 && (*TSelect)(unsafe.Pointer(pSel)).FpLimit != 0 && (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpRight != 0 { + /* If there is both a DISTINCT and an OFFSET clause, then allocate + ** a separate dest.iSdst array for sqlite3Select() and other + ** routines to populate. In this case results will be copied over + ** into the dest.iSDParm array only after OFFSET processing. This + ** ensures that in the case where OFFSET excludes all rows, the + ** dest.iSDParm array is not left populated with the contents of the + ** last row visited - it should be all NULLs if all rows were + ** excluded by OFFSET. */ + (**(**TSelectDest)(__ccgo_up(bp))).FiSdst = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nReg + } else { + (**(**TSelectDest)(__ccgo_up(bp))).FiSdst = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm + } + (**(**TSelectDest)(__ccgo_up(bp))).FnSdst = nReg + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm, (*TParse)(unsafe.Pointer(pParse)).FnMem) + } else { + (**(**TSelectDest)(__ccgo_up(bp))).FeDest = uint8(SRT_Exists) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm) + } + if (*TSelect)(unsafe.Pointer(pSel)).FpLimit != 0 { + /* The subquery already has a limit. If the pre-existing limit X is + ** not already integer value 1 or 0, then make the new limit X<>0 so that + ** the new limit is either 1 or 0 */ + pLeft = (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpLeft + if libc.BoolInt32((*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != uint32(0)) == 0 || *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pLeft)).Fu)) != int32(1) && *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pLeft)).Fu)) != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pLimit = _sqlite3ExprInt32(tls, db, 0) + if pLimit != 0 { + (*TExpr)(unsafe.Pointer(pLimit)).FaffExpr = uint8(SQLITE_AFF_NUMERIC) + pLimit = _sqlite3PExpr(tls, pParse, int32(TK_NE), _sqlite3ExprDup(tls, db, pLeft, 0), pLimit) + } + _sqlite3ExprDeferredDelete(tls, pParse, pLeft) + (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpLeft = pLimit + } + } else { + /* If there is no pre-existing limit add a limit of 1 */ + pLimit = _sqlite3ExprInt32(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(1)) + (*TSelect)(unsafe.Pointer(pSel)).FpLimit = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), pLimit, uintptr(0)) + } + (*TSelect)(unsafe.Pointer(pSel)).FiLimit = 0 + if _sqlite3Select(tls, pParse, pSel, bp) != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_ERROR) + return 0 + } + v1 = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm + rReg = v1 + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = v1 + if addrOnce != 0 { + _sqlite3VdbeJumpHere(tls, v, addrOnce) + } + /* Subroutine return */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr, int32(1)) + _sqlite3ClearTempRegCache(tls, pParse) + return rReg +} + +// C documentation +// +// /* +// ** Given an expression list (which is really the list of expressions +// ** that form the result set of a SELECT statement) compute appropriate +// ** column names for a table that would hold the expression list. +// ** +// ** All column names will be unique. +// ** +// ** Only the column names are computed. Column.zType, Column.zColl, +// ** and other fields of Column are zeroed. +// ** +// ** Return SQLITE_OK on success. If a memory allocation error occurs, +// ** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM. +// ** +// ** The only guarantee that SQLite makes about column names is that if the +// ** column has an AS clause assigning it a name, that will be the name used. +// ** That is the only documented guarantee. However, countless applications +// ** developed over the years have made baseless assumptions about column names +// ** and will break if those assumptions changes. Hence, use extreme caution +// ** when modifying this routine to avoid breaking legacy. +// ** +// ** See Also: sqlite3GenerateColumnNames() +// */ +func _sqlite3ColumnsFromExprList(tls *libc.TLS, pParse uintptr, pEList uintptr, pnCol uintptr, paCol uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var aCol, db, pCol, pColExpr, pCollide, pTab, pX, zName, v2, v3 uintptr + var i, iCol, j, nCol, nName int32 + var v5 bool + var v8 Tu32 + var _ /* cnt at bp+0 */ Tu32 + var _ /* ht at bp+8 */ THash + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCol, db, i, iCol, j, nCol, nName, pCol, pColExpr, pCollide, pTab, pX, zName, v2, v3, v5, v8 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + _sqlite3HashInit(tls, bp+8) + if pEList != 0 { + nCol = (*TExprList)(unsafe.Pointer(pEList)).FnExpr + aCol = _sqlite3DbMallocZero(tls, db, uint64(uint64(16)*libc.Uint64FromInt32(nCol))) + if nCol > int32(32767) { + nCol = int32(32767) + } + } else { + nCol = 0 + aCol = uintptr(0) + } + **(**Ti16)(__ccgo_up(pnCol)) = int16(nCol) + **(**uintptr)(__ccgo_up(paCol)) = aCol + i = 0 + pCol = aCol + for { + if !(i < nCol && !((*TParse)(unsafe.Pointer(pParse)).FnErr != 0)) { + break + } + pX = pEList + 8 + uintptr(i)*32 + /* Get an appropriate name for the column + */ + v2 = (*TExprList_item)(unsafe.Pointer(pX)).FzEName + zName = v2 + if v2 != uintptr(0) && int32(uint32(*(*uint16)(unsafe.Pointer(pX + 16 + 4))&0x3>>0)) == ENAME_NAME { + /* If the column contains an "AS " phrase, use as the name */ + } else { + pColExpr = _sqlite3ExprSkipCollateAndLikely(tls, (*TExprList_item)(unsafe.Pointer(pX)).FpExpr) + for pColExpr != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_DOT) { + pColExpr = (*TExpr)(unsafe.Pointer(pColExpr)).FpRight + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pColExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) && *(*uintptr)(unsafe.Pointer(pColExpr + 64)) != uintptr(0) { + /* For columns use the column name name */ + iCol = int32((*TExpr)(unsafe.Pointer(pColExpr)).FiColumn) + pTab = *(*uintptr)(unsafe.Pointer(pColExpr + 64)) + if iCol < 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + if iCol >= 0 { + v2 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + } else { + v2 = __ccgo_ts + 17963 + } + zName = v2 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_ID) { + zName = *(*uintptr)(unsafe.Pointer(pColExpr + 8)) + } else { + /* Use the original text of the column expression as its name */ + /* pointer comparison intended */ + } + } + } + if zName != 0 && !(_sqlite3IsTrueOrFalse(tls, zName) != 0) { + zName = _sqlite3DbStrDup(tls, db, zName) + } else { + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+20632, libc.VaList(bp+40, i+int32(1))) + } + /* Make sure the column name is unique. If the name is not unique, + ** append an integer to the name so that it becomes unique. + */ + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + for { + if v5 = zName != 0; v5 { + v2 = _sqlite3HashFind(tls, bp+8, zName) + pCollide = v2 + } + if !(v5 && v2 != uintptr(0)) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pCollide + 16 + 4))&0x80>>7)) != 0 { + v3 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(COLFLAG_NOEXPAND)) + } + nName = _sqlite3Strlen30(tls, zName) + if nName > 0 { + j = nName - int32(1) + for { + if !(j > 0 && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zName + uintptr(j))))])&int32(0x04) != 0) { + break + } + goto _7 + _7: + ; + j = j - 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(j)))) == int32(':') { + nName = j + } + } + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + 1 + v8 = **(**Tu32)(__ccgo_up(bp)) + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+20641, libc.VaList(bp+40, nName, zName, v8)) + _sqlite3ProgressCheck(tls, pParse) + if **(**Tu32)(__ccgo_up(bp)) > uint32(3) { + Xsqlite3_randomness(tls, int32(4), bp) + } + } + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = zName + (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, zName) + if int32(uint32(*(*uint16)(unsafe.Pointer(pX + 16 + 4))&0x100>>8)) != 0 { + v2 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(COLFLAG_NOEXPAND)) + } + if zName != 0 && _sqlite3HashInsert(tls, bp+8, zName, pX) == pX { + _sqlite3OomFault(tls, db) + } + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + _sqlite3HashClear(tls, bp+8) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + j = 0 + for { + if !(j < i) { + break + } + _sqlite3DbFree(tls, db, (**(**TColumn)(__ccgo_up(aCol + uintptr(j)*16))).FzCnName) + goto _10 + _10: + ; + j = j + 1 + } + _sqlite3DbFree(tls, db, aCol) + **(**uintptr)(__ccgo_up(paCol)) = uintptr(0) + **(**Ti16)(__ccgo_up(pnCol)) = 0 + return (*TParse)(unsafe.Pointer(pParse)).Frc + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** All regular columns for table pTab have been puts into registers +// ** starting with iRegStore. The registers that correspond to STORED +// ** or VIRTUAL columns have not yet been initialized. This routine goes +// ** back and computes the values for those columns based on the previously +// ** computed normal columns. +// */ +func _sqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore int32, pTab uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var eProgress, i, ii, jj, x, v2 int32 + var pCol, pOp, pRedo, zP4, v4 uintptr + var _ /* w at bp+0 */ TWalker + _, _, _, _, _, _, _, _, _, _, _ = eProgress, i, ii, jj, pCol, pOp, pRedo, x, zP4, v2, v4 + /* Before computing generated columns, first go through and make sure + ** that appropriate affinity has been applied to the regular columns + */ + _sqlite3TableAffinity(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iRegStore) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasStored) != uint32(0) { + pOp = _sqlite3VdbeGetLastOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Affinity) { + zP4 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + v2 = libc.Int32FromInt32(0) + jj = v2 + ii = v2 + for { + if !(**(**uint8)(__ccgo_up(zP4 + uintptr(jj))) != 0) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(ii)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + goto _1 + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(ii)*16))).FcolFlags)&int32(COLFLAG_STORED) != 0 { + **(**uint8)(__ccgo_up(zP4 + uintptr(jj))) = uint8(SQLITE_AFF_NONE) + } + jj = jj + 1 + goto _1 + _1: + ; + ii = ii + 1 + } + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_TypeCheck) { + /* If an OP_TypeCheck was generated because the table is STRICT, + ** then set the P3 operand to indicate that generated columns should + ** not be checked */ + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 = int32(1) + } + } + } + /* Because there can be multiple generated columns that refer to one another, + ** this is a two-pass algorithm. On the first pass, mark all generated + ** columns as "not available". + */ + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + v4 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_NOTAVAIL)) + } + goto _3 + _3: + ; + i = i + 1 + } + *(*uintptr)(unsafe.Pointer(bp + 40)) = pTab + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprColumnFlagUnion) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = uintptr(0) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + /* On the second pass, compute the value of each NOT-AVAILABLE column. + ** Companion code in the TK_COLUMN case of sqlite3ExprCodeTarget() will + ** compute dependencies and mark remove the COLSPAN_NOTAVAIL mark, as + ** they are needed. + */ + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = -iRegStore + for cond := true; cond; cond = pRedo != 0 && eProgress != 0 { + eProgress = 0 + pRedo = uintptr(0) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_NOTAVAIL) != 0 { + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_BUSY)) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(0) + _sqlite3WalkExpr(tls, bp, _sqlite3ColumnExpr(tls, pTab, pCol)) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^libc.Int32FromInt32(COLFLAG_BUSY)) + if libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode)&int32(COLFLAG_NOTAVAIL) != 0 { + pRedo = pCol + goto _5 + } + eProgress = int32(1) + x = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(i))) + iRegStore + _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab, pCol, x) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^libc.Int32FromInt32(COLFLAG_NOTAVAIL)) + } + goto _5 + _5: + ; + i = i + 1 + } + } + if pRedo != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8452, libc.VaList(bp+56, (*TColumn)(unsafe.Pointer(pRedo)).FzCnName)) + } + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 +} + +// C documentation +// +// /* +// ** This routine is called to create a new foreign key on the table +// ** currently under construction. pFromCol determines which columns +// ** in the current table point to the foreign key. If pFromCol==0 then +// ** connect the key to the last column inserted. pTo is the name of +// ** the table referred to (a.k.a the "parent" table). pToCol is a list +// ** of tables in the parent pTo table. flags contains all +// ** information about the conflict resolution algorithms specified +// ** in the ON DELETE, ON UPDATE and ON INSERT clauses. +// ** +// ** An FKey structure is created and added to the table currently +// ** under construction in the pParse->pNewTable field. +// ** +// ** The foreign key is set for IMMEDIATE processing. A subsequent call +// ** to sqlite3DeferForeignKey() might change this to DEFERRED. +// */ +func _sqlite3CreateForeignKey(tls *libc.TLS, pParse uintptr, pFromCol uintptr, pTo uintptr, pToCol uintptr, flags int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pFKey, pNextTo, z uintptr + var i, iCol, j, n, nCol int32 + var nByte Ti64 + _, _, _, _, _, _, _, _, _, _, _ = db, i, iCol, j, n, nByte, nCol, p, pFKey, pNextTo, z + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pFKey = uintptr(0) + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) { + goto fk_end + } + if pFromCol == uintptr(0) { + iCol = int32((*TTable)(unsafe.Pointer(p)).FnCol) - int32(1) + if iCol < 0 { + goto fk_end + } + if pToCol != 0 && (*TExprList)(unsafe.Pointer(pToCol)).FnExpr != int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15171, libc.VaList(bp+8, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(iCol)*16))).FzCnName, pTo)) + goto fk_end + } + nCol = int32(1) + } else { + if pToCol != 0 && (*TExprList)(unsafe.Pointer(pToCol)).FnExpr != (*TExprList)(unsafe.Pointer(pFromCol)).FnExpr { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15234, 0) + goto fk_end + } else { + nCol = (*TExprList)(unsafe.Pointer(pFromCol)).FnExpr + } + } + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+64) + libc.Uint64FromInt32(nCol)*uint64(16) + uint64((*TToken)(unsafe.Pointer(pTo)).Fn) + uint64(1)) + if pToCol != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pToCol)).FnExpr) { + break + } + nByte = nByte + int64(_sqlite3Strlen30(tls, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName)+int32(1)) + goto _1 + _1: + ; + i = i + 1 + } + } + pFKey = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte)) + if pFKey == uintptr(0) { + goto fk_end + } + (*TFKey)(unsafe.Pointer(pFKey)).FpFrom = p + (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FpFKey + z = pFKey + 64 + uintptr(nCol)*16 + (*TFKey)(unsafe.Pointer(pFKey)).FzTo = z + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, z, pTo) + } + libc.Xmemcpy(tls, z, (*TToken)(unsafe.Pointer(pTo)).Fz, uint64((*TToken)(unsafe.Pointer(pTo)).Fn)) + **(**uint8)(__ccgo_up(z + uintptr((*TToken)(unsafe.Pointer(pTo)).Fn))) = uint8(0) + _sqlite3Dequote(tls, z) + z = z + uintptr((*TToken)(unsafe.Pointer(pTo)).Fn+uint32(1)) + (*TFKey)(unsafe.Pointer(pFKey)).FnCol = nCol + if pFromCol == uintptr(0) { + (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom = int32((*TTable)(unsafe.Pointer(p)).FnCol) - int32(1) + } else { + i = 0 + for { + if !(i < nCol) { + break + } + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + if _sqlite3StrICmp(tls, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(j)*16))).FzCnName, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName) == 0 { + (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FiFrom = j + break + } + goto _3 + _3: + ; + j = j + 1 + } + if j >= int32((*TTable)(unsafe.Pointer(p)).FnCol) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15328, libc.VaList(bp+8, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName)) + goto fk_end + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, pFKey+64+uintptr(i)*16, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName) + } + goto _2 + _2: + ; + i = i + 1 + } + } + if pToCol != 0 { + i = 0 + for { + if !(i < nCol) { + break + } + n = _sqlite3Strlen30(tls, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName) + (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FzCol = z + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, z, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName) + } + libc.Xmemcpy(tls, z, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName, libc.Uint64FromInt32(n)) + **(**uint8)(__ccgo_up(z + uintptr(n))) = uint8(0) + z = z + uintptr(n+int32(1)) + goto _4 + _4: + ; + i = i + 1 + } + } + (*TFKey)(unsafe.Pointer(pFKey)).FisDeferred = uint8(0) + **(**Tu8)(__ccgo_up(pFKey + 45)) = libc.Uint8FromInt32(flags & libc.Int32FromInt32(0xff)) /* ON DELETE action */ + **(**Tu8)(__ccgo_up(pFKey + 45 + 1)) = libc.Uint8FromInt32(flags >> libc.Int32FromInt32(8) & libc.Int32FromInt32(0xff)) /* ON UPDATE action */ + pNextTo = _sqlite3HashInsert(tls, (*TTable)(unsafe.Pointer(p)).FpSchema+80, (*TFKey)(unsafe.Pointer(pFKey)).FzTo, pFKey) + if pNextTo == pFKey { + _sqlite3OomFault(tls, db) + goto fk_end + } + if pNextTo != 0 { + (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo = pNextTo + (*TFKey)(unsafe.Pointer(pNextTo)).FpPrevTo = pFKey + } + /* Link the foreign key to the table as the last step. + */ + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FpFKey = pFKey + pFKey = uintptr(0) + goto fk_end +fk_end: + ; + _sqlite3DbFree(tls, db, pFKey) + _sqlite3ExprListDelete(tls, db, pFromCol) + _sqlite3ExprListDelete(tls, db, pToCol) +} + +// C documentation +// +// /* +// ** Create a new index for an SQL table. pName1.pName2 is the name of the index +// ** and pTblList is the name of the table that is to be indexed. Both will +// ** be NULL for a primary key or an index that is created to satisfy a +// ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse->pNewTable +// ** as the table to be indexed. pParse->pNewTable is a table that is +// ** currently being constructed by a CREATE TABLE statement. +// ** +// ** pList is a list of columns to be indexed. pList will be NULL if this +// ** is a primary key or unique-constraint on the most recent column added +// ** to the table currently under construction. +// */ +func _sqlite3CreateIndex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pTblName uintptr, pList uintptr, onError int32, pStart uintptr, pPIWhere uintptr, sortOrder int32, ifNotExist int32, idxType Tu8) { + bp := tls.Alloc(176) + defer tls.Free(176) + var db, p, pCExpr, pCol, pDb, pExpr, pIdx, pIndex, pListItem, pLoop, pNext, pPk, pTab, pThis, ppFrom, v, z1, z2, zColl, zDb, zName, zStmt, v2 uintptr + var i, iDb, iMem, j, k, n, n1, nColl, nExtra, nExtraCol, nName, requestedSortOrder, sortOrderMask, x, v5 int32 + var _ /* pName at bp+96 */ uintptr + var _ /* prevCol at bp+112 */ TToken + var _ /* sFix at bp+0 */ TDbFixer + var _ /* zExtra at bp+104 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iDb, iMem, j, k, n, n1, nColl, nExtra, nExtraCol, nName, p, pCExpr, pCol, pDb, pExpr, pIdx, pIndex, pListItem, pLoop, pNext, pPk, pTab, pThis, ppFrom, requestedSortOrder, sortOrderMask, v, x, z1, z2, zColl, zDb, zName, zStmt, v2, v5 + pTab = uintptr(0) /* Table to be indexed */ + pIndex = uintptr(0) /* The index to be created */ + zName = uintptr(0) /* 1 to honor DESC in index. 0 to ignore. */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Index of the database that is being written */ + **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) /* For looping over pList */ + nExtra = 0 /* Number of extra columns needed */ + **(**uintptr)(__ccgo_up(bp + 104)) = uintptr(0) /* Extra space after the Index object */ + pPk = uintptr(0) /* PRIMARY KEY index for WITHOUT ROWID tables */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) && libc.Int32FromUint8(idxType) != int32(SQLITE_IDXTYPE_PRIMARYKEY) { + goto exit_create_index + } + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto exit_create_index + } + if _sqlite3HasExplicitNulls(tls, pParse, pList) != 0 { + goto exit_create_index + } + /* + ** Find the table that is to be indexed. Return early if not found. + */ + if pTblName != uintptr(0) { + /* Use the two-part index name to determine the database + ** to search for the table. 'Fix' the table name to this db + ** before looking up the table. + */ + iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp+96) + if iDb < 0 { + goto exit_create_index + } + /* If the index name was unqualified, check if the table + ** is a temp table. If so, set the database to 1. Do not do this + ** if initializing a database schema. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + pTab = _sqlite3SrcListLookup(tls, pParse, pTblName) + if (*TToken)(unsafe.Pointer(pName2)).Fn == uint32(0) && pTab != 0 && (*TTable)(unsafe.Pointer(pTab)).FpSchema == (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema { + iDb = int32(1) + } + } + _sqlite3FixInit(tls, bp, pParse, iDb, __ccgo_ts+15413, **(**uintptr)(__ccgo_up(bp + 96))) + if _sqlite3FixSrcList(tls, bp, pTblName) != 0 { + /* Because the parser constructs pTblName from a single identifier, + ** sqlite3FixSrcList can never fail. */ + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pTblName+8) + if pTab == uintptr(0) { + goto exit_create_index + } + if iDb == int32(1) && (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema != (*TTable)(unsafe.Pointer(pTab)).FpSchema { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15419, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_create_index + } + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + } + } else { + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if !(pTab != 0) { + goto exit_create_index + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+6756, int32(7)) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 && pTblName != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15469, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_create_index + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15497, 0) + goto exit_create_index + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15522, 0) + goto exit_create_index + } + /* + ** Find the name of the index. Make sure there is not already another + ** index or table with the same name. + ** + ** Exception: If we are reading the names of permanent indices from the + ** sqlite_schema table (because some other process changed the schema) and + ** one of the index names collides with the name of a temporary table or + ** index, then we will continue to process this index. + ** + ** If pName==0 it means that we are + ** dealing with a primary key or UNIQUE constraint. We have to invent our + ** own name. + */ + if **(**uintptr)(__ccgo_up(bp + 96)) != 0 { + zName = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp + 96))) + if zName == uintptr(0) { + goto exit_create_index + } + if SQLITE_OK != _sqlite3CheckObjectName(tls, pParse, zName, __ccgo_ts+15413, (*TTable)(unsafe.Pointer(pTab)).FzName) { + goto exit_create_index + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + if _sqlite3FindTable(tls, db, zName, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15556, libc.VaList(bp+136, zName)) + goto exit_create_index + } + } + if _sqlite3FindIndex(tls, db, zName, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0) { + if !(ifNotExist != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15590, libc.VaList(bp+136, zName)) + } else { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3ForceNotReadOnly(tls, pParse) + } + goto exit_create_index + } + } + } else { + pLoop = (*TTable)(unsafe.Pointer(pTab)).FpIndex + n = libc.Int32FromInt32(1) + for { + if !(pLoop != 0) { + break + } + goto _1 + _1: + ; + pLoop = (*TIndex)(unsafe.Pointer(pLoop)).FpNext + n = n + 1 + } + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+15614, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName, n)) + if zName == uintptr(0) { + goto exit_create_index + } + /* Automatic index names generated from within sqlite3_declare_vtab() + ** must have names that are distinct from normal automatic index names. + ** The following statement converts "sqlite3_autoindex..." into + ** "sqlite3_butoindex..." in order to make the names distinct. + ** The "vtab_err.test" test demonstrates the need of this statement. */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + **(**uint8)(__ccgo_up(zName + 7)) = **(**uint8)(__ccgo_up(zName + 7)) + 1 + } + } + /* Check for authorization to create an index. + */ + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + zDb = (*TDb)(unsafe.Pointer(pDb)).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v2 = __ccgo_ts + 6764 + } else { + v2 = __ccgo_ts + 6284 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), v2, uintptr(0), zDb) != 0 { + goto exit_create_index + } + i = int32(SQLITE_CREATE_INDEX) + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + i = int32(SQLITE_CREATE_TEMP_INDEX) + } + if _sqlite3AuthCheck(tls, pParse, i, zName, (*TTable)(unsafe.Pointer(pTab)).FzName, zDb) != 0 { + goto exit_create_index + } + } + /* If pList==0, it means this routine was called to make a primary + ** key out of the last column added to the table under construction. + ** So create a fake list to simulate this. + */ + if pList == uintptr(0) { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1))*16 + v2 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(COLFLAG_UNIQUE)) + _sqlite3TokenInit(tls, bp+112, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + pList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+112, 0)) + if pList == uintptr(0) { + goto exit_create_index + } + _sqlite3ExprListSetSortOrder(tls, pList, sortOrder, -int32(1)) + } else { + _sqlite3ExprListCheckLength(tls, pParse, pList, __ccgo_ts+15413) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + } + /* Figure out how many bytes of space are required to store explicitly + ** specified collation sequence names. + */ + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE) { + nExtra = nExtra + (int32(1) + _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)))) + } + goto _4 + _4: + ; + i = i + 1 + } + /* + ** Allocate the index structure. + */ + nName = _sqlite3Strlen30(tls, zName) + if pPk != 0 { + v5 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } else { + v5 = int32(1) + } + nExtraCol = v5 + pIndex = _sqlite3AllocateIndexObject(tls, db, (*TExprList)(unsafe.Pointer(pList)).FnExpr+nExtraCol, nName+nExtra+int32(1), bp+104) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_create_index + } + (*TIndex)(unsafe.Pointer(pIndex)).FzName = **(**uintptr)(__ccgo_up(bp + 104)) + **(**uintptr)(__ccgo_up(bp + 104)) = **(**uintptr)(__ccgo_up(bp + 104)) + uintptr(nName+int32(1)) + libc.Xmemcpy(tls, (*TIndex)(unsafe.Pointer(pIndex)).FzName, zName, libc.Uint64FromInt32(nName+int32(1))) + (*TIndex)(unsafe.Pointer(pIndex)).FpTable = pTab + (*TIndex)(unsafe.Pointer(pIndex)).FonError = libc.Uint8FromInt32(onError) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.BoolUint32(onError != libc.Int32FromInt32(OE_None)), 3, 0x8) + libc.SetBitFieldPtr16Uint32(pIndex+100, uint32(idxType), 0, 0x3) + (*TIndex)(unsafe.Pointer(pIndex)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol = libc.Uint16FromInt32((*TExprList)(unsafe.Pointer(pList)).FnExpr) + if pPIWhere != 0 { + _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_PartIdx), pPIWhere, uintptr(0)) + (*TIndex)(unsafe.Pointer(pIndex)).FpPartIdxWhere = pPIWhere + pPIWhere = uintptr(0) + } + /* Check to see if we should honor DESC requests on index columns + */ + if libc.Int32FromUint8((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) >= int32(4) { + sortOrderMask = -int32(1) /* Honor DESC */ + } else { + sortOrderMask = 0 /* Ignore DESC */ + } + /* Analyze the list of expressions that form the terms of the index and + ** report any errors. In the common case where the expression is exactly + ** a table column, store that column in aiColumn[]. For general expressions, + ** populate pIndex->aColExpr and store XN_EXPR (-2) in aiColumn[]. + ** + ** TODO: Issue a warning if two or more columns of the index are identical. + ** TODO: Issue a warning if the table primary key is used as part of the + ** index key. + */ + pListItem = pList + 8 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr = pList + pList = uintptr(0) + } + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol)) { + break + } /* Collation sequence name */ + _sqlite3StringToId(tls, (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr) + _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_IdxExpr), (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + pCExpr = _sqlite3ExprSkipCollate(tls, (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCExpr)).Fop) != int32(TK_COLUMN) { + if pTab == (*TParse)(unsafe.Pointer(pParse)).FpNewTable { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15637, 0) + goto exit_create_index + } + if (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr == uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr = pList + pList = uintptr(0) + } + j = -int32(2) + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-libc.Int32FromInt32(2)) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 11, 0x800) + } else { + j = int32((*TExpr)(unsafe.Pointer(pCExpr)).FiColumn) + if j < 0 { + j = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16 + 8))&0xf>>0)) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 3, 0x8) + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 10, 0x400) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 11, 0x800) + } + } + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(j) + } + zColl = uintptr(0) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == int32(TK_COLLATE) { + zColl = *(*uintptr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr + 8)) + nColl = _sqlite3Strlen30(tls, zColl) + int32(1) + libc.Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp + 104)), zColl, libc.Uint64FromInt32(nColl)) + zColl = **(**uintptr)(__ccgo_up(bp + 104)) + **(**uintptr)(__ccgo_up(bp + 104)) = **(**uintptr)(__ccgo_up(bp + 104)) + uintptr(nColl) + nExtra = nExtra - nColl + } else { + if j >= 0 { + zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16) + } + } + if !(zColl != 0) { + zColl = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) && !(_sqlite3LocateCollSeq(tls, pParse, zColl) != 0) { + goto exit_create_index + } + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = zColl + requestedSortOrder = libc.Int32FromUint8((*TExprList_item)(unsafe.Pointer(pListItem)).Ffg.FsortFlags) & sortOrderMask + **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = libc.Uint8FromInt32(requestedSortOrder) + goto _6 + _6: + ; + i = i + 1 + pListItem += 32 + } + /* Append the table key to the end of the index. For WITHOUT ROWID + ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For + ** normal tables (when pPk==0) this will be the rowid. + */ + if pPk != 0 { + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + x = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2))) + if _isDupColumn(tls, pIndex, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol), pPk, j) != 0 { + (*TIndex)(unsafe.Pointer(pIndex)).FnColumn = (*TIndex)(unsafe.Pointer(pIndex)).FnColumn - 1 + } else { + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(x) + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*8)) + **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(j))) + i = i + 1 + } + goto _7 + _7: + ; + j = j + 1 + } + } else { + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-libc.Int32FromInt32(1)) + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + _sqlite3DefaultRowEst(tls, pIndex) + if (*TParse)(unsafe.Pointer(pParse)).FpNewTable == uintptr(0) { + _estimateIndexWidth(tls, pIndex) + } + /* If this index contains every column of its table, then mark + ** it as a covering index */ + _recomputeColumnsNotIndexed(tls, pIndex) + if pTblName != uintptr(0) && libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnColumn) >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 5, 0x20) + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + goto _8 + } + if _sqlite3TableColumnToIndex(tls, pIndex, j) >= 0 { + goto _8 + } + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 5, 0x20) + break + goto _8 + _8: + ; + j = j + 1 + } + } + if pTab == (*TParse)(unsafe.Pointer(pParse)).FpNewTable { + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol) { + goto _9 + } + k = 0 + for { + if !(k < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(k)*2))) != int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(k)*2))) { + break + } + z1 = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(k)*8)) + z2 = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(k)*8)) + if _sqlite3StrICmp(tls, z1, z2) != 0 { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if k == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) { + /* This constraint creates the same index as a previous + ** constraint specified somewhere in the CREATE TABLE statement. + ** However the ON CONFLICT clauses are different. If both this + ** constraint and the previous equivalent constraint have explicit + ** ON CONFLICT clauses this is an error. Otherwise, use the + ** explicitly specified behavior for the index. + */ + if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Default) || libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) == int32(OE_Default)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15698, libc.VaList(bp+136, 0)) + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Default) { + (*TIndex)(unsafe.Pointer(pIdx)).FonError = (*TIndex)(unsafe.Pointer(pIndex)).FonError + } + } + if libc.Int32FromUint8(idxType) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + libc.SetBitFieldPtr16Uint32(pIdx+100, uint32(idxType), 0, 0x3) + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TIndex)(unsafe.Pointer(pIndex)).FpNext = (*TParse)(unsafe.Pointer(pParse)).FpNewIndex + (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex + pIndex = uintptr(0) + } + goto exit_create_index + } + goto _9 + _9: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + /* Link the new Index structure to its table and to the other + ** in-memory database structures. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + if pTblName != uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).Ftnum = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum + if _sqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15740, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = _sqlite3CorruptError(tls, int32(130799)) + goto exit_create_index + } + } + p = _sqlite3HashInsert(tls, (*TIndex)(unsafe.Pointer(pIndex)).FpSchema+32, (*TIndex)(unsafe.Pointer(pIndex)).FzName, pIndex) + if p != 0 { + /* Malloc must have failed */ + _sqlite3OomFault(tls, db) + goto exit_create_index + } + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + } else { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || pTblName != uintptr(0) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v5 = *(*int32)(unsafe.Pointer(v2)) + iMem = v5 + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto exit_create_index + } + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + /* Create the rootpage for the index using CreateIndex. But before + ** doing so, code a Noop instruction and store its address in + ** Index.tnum. This is required in case this index is actually a + ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In + ** that case the convertToWithoutRowidTable() routine will replace + ** the Noop with a Goto to jump over the VDBE code generated below. */ + (*TIndex)(unsafe.Pointer(pIndex)).Ftnum = libc.Uint32FromInt32(_sqlite3VdbeAddOp0(tls, v, int32(OP_Noop))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_CreateBtree), iDb, iMem, int32(BTREE_BLOBKEY)) + /* Gather the complete text of the CREATE INDEX statement into + ** the zStmt variable + */ + if pStart != 0 { + n1 = libc.Int32FromUint32(libc.Uint32FromInt32(int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64((*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz))) + (*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fn) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz + uintptr(n1-int32(1))))) == int32(';') { + n1 = n1 - 1 + } + /* A named index with an explicit CREATE INDEX statement */ + if onError == OE_None { + v2 = __ccgo_ts + 1704 + } else { + v2 = __ccgo_ts + 15757 + } + zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+15765, libc.VaList(bp+136, v2, n1, (*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz)) + } else { + /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ + /* zStmt = sqlite3MPrintf(""); */ + zStmt = uintptr(0) + } + /* Add an entry in sqlite_schema for this index + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+15785, libc.VaList(bp+136, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TIndex)(unsafe.Pointer(pIndex)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, iMem, zStmt)) + _sqlite3DbFree(tls, db, zStmt) + /* Fill the index with data and reparse the schema. Code an OP_Expire + ** to invalidate all pre-compiled statements. + */ + if pTblName != 0 { + _sqlite3RefillIndex(tls, pParse, pIndex, iMem) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+15844, libc.VaList(bp+136, (*TIndex)(unsafe.Pointer(pIndex)).FzName)), uint16(0)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Expire), 0, int32(1)) + } + _sqlite3VdbeJumpHere(tls, v, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIndex)).Ftnum)) + } + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || pTblName == uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).FpNext = (*TTable)(unsafe.Pointer(pTab)).FpIndex + (*TTable)(unsafe.Pointer(pTab)).FpIndex = pIndex + pIndex = uintptr(0) + } else { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex + pIndex = uintptr(0) + } + } + /* Clean up before exiting */ + goto exit_create_index +exit_create_index: + ; + if pIndex != 0 { + _sqlite3FreeIndex(tls, db, pIndex) + } + if pTab != 0 { + ppFrom = pTab + 16 + for { + v2 = **(**uintptr)(__ccgo_up(ppFrom)) + pThis = v2 + if !(v2 != uintptr(0)) { + break + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pThis)).FonError) != int32(OE_Replace) { + goto _14 + } + for { + v2 = (*TIndex)(unsafe.Pointer(pThis)).FpNext + pNext = v2 + if !(v2 != uintptr(0) && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pNext)).FonError) != int32(OE_Replace)) { + break + } + **(**uintptr)(__ccgo_up(ppFrom)) = pNext + (*TIndex)(unsafe.Pointer(pThis)).FpNext = (*TIndex)(unsafe.Pointer(pNext)).FpNext + (*TIndex)(unsafe.Pointer(pNext)).FpNext = pThis + ppFrom = pNext + 40 + } + break + goto _14 + _14: + ; + ppFrom = pThis + 40 + } + } + _sqlite3ExprDelete(tls, db, pPIWhere) + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3SrcListDelete(tls, db, pTblName) + _sqlite3DbFree(tls, db, zName) +} + +// C documentation +// +// /* +// ** The parser calls this routine in order to create a new VIEW +// */ +func _sqlite3CreateView(tls *libc.TLS, pParse uintptr, pBegin uintptr, pName1 uintptr, pName2 uintptr, pCNames uintptr, pSelect uintptr, isTemp int32, noErr int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var db, p, z uintptr + var iDb, n int32 + var _ /* pName at bp+112 */ uintptr + var _ /* sEnd at bp+0 */ TToken + var _ /* sFix at bp+16 */ TDbFixer + _, _, _, _, _ = db, iDb, n, p, z + **(**uintptr)(__ccgo_up(bp + 112)) = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if int32((*TParse)(unsafe.Pointer(pParse)).FnVar) > 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14803, 0) + goto create_view_fail + } + _sqlite3StartTable(tls, pParse, pName1, pName2, isTemp, int32(1), 0, noErr) + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) || (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto create_view_fail + } + /* Legacy versions of SQLite allowed the use of the magic "rowid" column + ** on a view, even though views do not have rowids. The following flag + ** setting fixes this problem. But the fix can be disabled by compiling + ** with -DSQLITE_ALLOW_ROWID_IN_VIEW in case there are legacy apps that + ** depend upon the old buggy behavior. The ability can also be toggled + ** using sqlite3_config(SQLITE_CONFIG_ROWID_IN_VIEW,...) */ + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_NoVisibleRowid) /* Never allow rowid in view */ + _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp+112) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(p)).FpSchema) + _sqlite3FixInit(tls, bp+16, pParse, iDb, __ccgo_ts+11115, **(**uintptr)(__ccgo_up(bp + 112))) + if _sqlite3FixSelect(tls, bp+16, pSelect) != 0 { + goto create_view_fail + } + /* Make a copy of the entire SELECT statement that defines the view. + ** This will force all the Expr.token.z values to be dynamically + ** allocated rather than point to the input string - which means that + ** they will persist after the current sqlite3_exec() call returns. + */ + **(**Tu32)(__ccgo_up(pSelect + 4)) |= uint32(SF_View) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(p)).Fu))).FpSelect = pSelect + pSelect = uintptr(0) + } else { + (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(p)).Fu))).FpSelect = _sqlite3SelectDup(tls, db, pSelect, int32(EXPRDUP_REDUCE)) + } + (*TTable)(unsafe.Pointer(p)).FpCheck = _sqlite3ExprListDup(tls, db, pCNames, int32(EXPRDUP_REDUCE)) + (*TTable)(unsafe.Pointer(p)).FeTabType = uint8(TABTYP_VIEW) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto create_view_fail + } + /* Locate the end of the CREATE VIEW statement. Make sEnd point to + ** the end. + */ + **(**TToken)(__ccgo_up(bp)) = (*TParse)(unsafe.Pointer(pParse)).FsLastToken + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((**(**TToken)(__ccgo_up(bp))).Fz))) != int32(';') { + (**(**TToken)(__ccgo_up(bp))).Fz += uintptr((**(**TToken)(__ccgo_up(bp))).Fn) + } + (**(**TToken)(__ccgo_up(bp))).Fn = uint32(0) + n = int32(int64((**(**TToken)(__ccgo_up(bp))).Fz) - int64((*TToken)(unsafe.Pointer(pBegin)).Fz)) + z = (*TToken)(unsafe.Pointer(pBegin)).Fz + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(n-int32(1)))))])&int32(0x01) != 0 { + n = n - 1 + } + (**(**TToken)(__ccgo_up(bp))).Fz = z + uintptr(n-int32(1)) + (**(**TToken)(__ccgo_up(bp))).Fn = uint32(1) + /* Use sqlite3EndTable() to add the view to the schema table */ + _sqlite3EndTable(tls, pParse, uintptr(0), bp, uint32(0), uintptr(0)) + goto create_view_fail +create_view_fail: + ; + _sqlite3SelectDelete(tls, db, pSelect) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameExprlistUnmap(tls, pParse, pCNames) + } + _sqlite3ExprListDelete(tls, db, pCNames) + return +} + +// C documentation +// +// /* +// ** Transform a UTF-8 integer literal, in either decimal or hexadecimal, +// ** into a 64-bit signed integer. This routine accepts hexadecimal literals, +// ** whereas sqlite3Atoi64() does not. +// ** +// ** Returns: +// ** +// ** 0 Successful transformation. Fits in a 64-bit signed integer. +// ** 1 Excess text after the integer value +// ** 2 Integer too large for a 64-bit signed integer or is malformed +// ** 3 Special case of 9223372036854775808 +// */ +func _sqlite3DecOrHexToI64(tls *libc.TLS, z uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, k, n int32 + var _ /* u at bp+0 */ Tu64 + _, _, _ = i, k, n + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32('0') && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('x') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('X')) { + **(**Tu64)(__ccgo_up(bp)) = uint64(0) + i = int32(2) + for { + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('0')) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + k = i + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(k))))])&int32(0x08) != 0) { + break + } + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))*uint64(16) + uint64(_sqlite3HexToInt(tls, libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(k)))))) + goto _2 + _2: + ; + k = k + 1 + } + libc.Xmemcpy(tls, pOut, bp, uint64(8)) + if k-i > int32(16) { + return int32(2) + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(k)))) != 0 { + return int32(1) + } + return 0 + } else { + n = libc.Int32FromUint64(libc.Uint64FromInt32(0x3fffffff) & libc.Xstrspn(tls, z, __ccgo_ts+1834)) + if **(**uint8)(__ccgo_up(z + uintptr(n))) != 0 { + n = n + 1 + } + return _sqlite3Atoi64(tls, z, pOut, n, uint8(SQLITE_UTF8)) + } + return r +} + +// C documentation +// +// /* +// ** Expression p is a QNUMBER (quoted number). Dequote the value in p->u.zToken +// ** and set the type to INTEGER or FLOAT. "Quoted" integers or floats are those +// ** that contain '_' characters that must be removed before further processing. +// */ +func _sqlite3DequoteNumber(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bHex int32 + var pIn, pOut, v1, v3 uintptr + var _ /* iValue at bp+0 */ int32 + _, _, _, _, _ = bHex, pIn, pOut, v1, v3 + if p != 0 { + pIn = *(*uintptr)(unsafe.Pointer(p + 8)) + pOut = *(*uintptr)(unsafe.Pointer(p + 8)) + bHex = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(pIn))) == int32('0') && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(pIn + 1))) == int32('x') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(pIn + 1))) == int32('X'))) + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_INTEGER) + for { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(pIn))) != int32('_') { + v3 = pOut + pOut = pOut + 1 + **(**uint8)(__ccgo_up(v3)) = **(**uint8)(__ccgo_up(pIn)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(pIn))) == int32('e') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(pIn))) == int32('E') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(pIn))) == int32('.') { + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_FLOAT) + } + } else { + if bHex == 0 && (!(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(pIn + uintptr(-libc.Int32FromInt32(1)))))])&libc.Int32FromInt32(0x04) != 0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(pIn + 1)))])&libc.Int32FromInt32(0x04) != 0)) || bHex == int32(1) && (!(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(pIn + uintptr(-libc.Int32FromInt32(1)))))])&libc.Int32FromInt32(0x08) != 0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(pIn + 1)))])&libc.Int32FromInt32(0x08) != 0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1790, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(p + 8)))) + } + } + goto _2 + _2: + ; + v1 = pIn + pIn = pIn + 1 + if !(**(**uint8)(__ccgo_up(v1)) != 0) { + break + } + } + if bHex != 0 { + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_INTEGER) + } + /* tag-20240227-a: If after dequoting, the number is an integer that + ** fits in 32 bits, then it must be converted into EP_IntValue. Other + ** parts of the code expect this. See also tag-20240227-b. */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_INTEGER) && _sqlite3GetInt32(tls, *(*uintptr)(unsafe.Pointer(p + 8)), bp) != 0 { + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(p)).Fu)) = **(**int32)(__ccgo_up(bp)) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(EP_IntValue) + } + } +} + +// C documentation +// +// /* +// ** This routine is called to report the final ")" that terminates +// ** a CREATE TABLE statement. +// ** +// ** The table structure that other action routines have been building +// ** is added to the internal hash tables, assuming no errors have +// ** occurred. +// ** +// ** An entry for the table is made in the schema table on disk, unless +// ** this is a temporary table or db->init.busy==1. When db->init.busy==1 +// ** it means we are reading the sqlite_schema table because we just +// ** connected to the database or because the sqlite_schema table has +// ** recently changed, so the entry for this table already exists in +// ** the sqlite_schema table. We do not want to create it again. +// ** +// ** If the pSelect argument is not NULL, it means that this routine +// ** was called to create a table generated from a +// ** "CREATE TABLE ... AS SELECT ..." statement. The column names of +// ** the new table will match the result set of the SELECT. +// */ +func _sqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr, tabOpts Tu32, pSelect uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var addrInsLoop, addrTop, iCsr, iDb, ii, ii1, n, nNG, regRec, regRowid, regYield, v4 int32 + var colFlags Tu32 + var db, p, pCol, pDb, pEnd2, pIdx, pOld, pSchema, pSelTab, pX, v, zStmt, zType, zType2, v5 uintptr + var v12 Ti16 + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrInsLoop, addrTop, colFlags, db, iCsr, iDb, ii, ii1, n, nNG, p, pCol, pDb, pEnd2, pIdx, pOld, pSchema, pSelTab, pX, regRec, regRowid, regYield, v, zStmt, zType, zType2, v12, v4, v5 /* The new table */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* An implied index of the table */ + if pEnd == uintptr(0) && pSelect == uintptr(0) { + return + } + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) { + return + } + if pSelect == uintptr(0) && _sqlite3ShadowTableName(tls, db, (*TTable)(unsafe.Pointer(p)).FzName) != 0 { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Shadow) + } + /* If the db->init.busy is 1 it means we are reading the SQL off the + ** "sqlite_schema" or "sqlite_temp_schema" table on the disk. + ** So do not write to the disk again. Extract the root page number + ** for the table from the db->init.newTnum field. (The page number + ** should have been put there by the sqliteOpenCb routine.) + ** + ** If the root page number is 1, that means this is the sqlite_schema + ** table itself. So mark it read-only. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + if pSelect != 0 || !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) && (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1704, 0) + return + } + (*TTable)(unsafe.Pointer(p)).Ftnum = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum + if (*TTable)(unsafe.Pointer(p)).Ftnum == uint32(1) { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Readonly) + } + } + /* Special processing for tables that include the STRICT keyword: + ** + ** * Do not allow custom column datatypes. Every column must have + ** a datatype that is one of INT, INTEGER, REAL, TEXT, or BLOB. + ** + ** * If a PRIMARY KEY is defined, other than the INTEGER PRIMARY KEY, + ** then all columns of the PRIMARY KEY must have a NOT NULL + ** constraint. + */ + if tabOpts&uint32(TF_Strict) != 0 { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Strict) + ii = 0 + for { + if !(ii < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr(ii)*16 + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == COLTYPE_CUSTOM { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14396, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, _sqlite3ColumnType(tls, pCol, __ccgo_ts+1704))) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14429, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + } + return + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == int32(COLTYPE_ANY) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_BLOB) + } + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 && int32((*TTable)(unsafe.Pointer(p)).FiPKey) != ii && int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) == OE_None { + libc.SetBitFieldPtr8Uint32(pCol+8, libc.Uint32FromInt32(OE_Abort), 0, 0xf) + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_HasNotNull) + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + /* Special processing for WITHOUT ROWID Tables */ + if tabOpts&uint32(TF_WithoutRowid) != 0 { + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_Autoincrement) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14456, 0) + return + } + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasPrimaryKey) == uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14506, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName)) + return + } + **(**Tu32)(__ccgo_up(p + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid) | libc.Int32FromInt32(TF_NoVisibleRowid)) + _convertToWithoutRowidTable(tls, pParse, p) + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(p)).FpSchema) + /* Resolve names in all CHECK constraint expressions. + */ + if (*TTable)(unsafe.Pointer(p)).FpCheck != 0 { + _sqlite3ResolveSelfReference(tls, pParse, p, int32(NC_IsCheck), uintptr(0), (*TTable)(unsafe.Pointer(p)).FpCheck) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + /* If errors are seen, delete the CHECK constraints now, else they might + ** actually be used if PRAGMA writable_schema=ON is set. */ + _sqlite3ExprListDelete(tls, db, (*TTable)(unsafe.Pointer(p)).FpCheck) + (*TTable)(unsafe.Pointer(p)).FpCheck = uintptr(0) + } else { + } + } + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasGenerated) != 0 { + nNG = 0 + ii1 = 0 + for { + if !(ii1 < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + colFlags = uint32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(ii1)*16))).FcolFlags) + if colFlags&uint32(COLFLAG_GENERATED) != uint32(0) { + pX = _sqlite3ColumnExpr(tls, p, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(ii1)*16) + if _sqlite3ResolveSelfReference(tls, pParse, p, int32(NC_GenCol), pX, uintptr(0)) != 0 { + /* If there are errors in resolving the expression, change the + ** expression to a NULL. This prevents code generators that operate + ** on the expression from inserting extra parts into the expression + ** tree that have been allocated from lookaside memory, which is + ** illegal in a schema and will lead to errors or heap corruption + ** when the database connection closes. */ + _sqlite3ColumnSetExpr(tls, pParse, p, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(ii1)*16, _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0)) + } + } else { + nNG = nNG + 1 + } + goto _2 + _2: + ; + ii1 = ii1 + 1 + } + if nNG == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14538, 0) + return + } + } + /* Estimate the average row size for the table and for all implied indices */ + _estimateTableWidth(tls, p) + pIdx = (*TTable)(unsafe.Pointer(p)).FpIndex + for { + if !(pIdx != 0) { + break + } + _estimateIndexWidth(tls, pIdx) + goto _3 + _3: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + /* If not initializing, then create a record for the new table + ** in the schema table of the database. + ** + ** If this is a TEMPORARY table, write the entry into the auxiliary + ** file instead of into the main database file. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { /* Text of the CREATE TABLE or CREATE VIEW statement */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + return + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), 0) + /* + ** Initialize zType for the new view or table. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM { + /* A regular table */ + zType = __ccgo_ts + 9377 + zType2 = __ccgo_ts + 14582 + } else { + /* A view */ + zType = __ccgo_ts + 11115 + zType2 = __ccgo_ts + 14588 + } + /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT + ** statement to populate the new table. The root-page number for the + ** new table is in register pParse->u1.cr.regRoot. + ** + ** Once the SELECT has been coded by sqlite3Select(), it is in a + ** suitable state to query for the column names and types to be used + ** by the new table. + ** + ** A shared-cache write-lock is not required to write to the new table, + ** as a schema-lock must have already been obtained to create it. Since + ** a schema-lock excludes all other database users, the write-lock would + ** be redundant. + */ + if pSelect != 0 { /* Write cursor on the new table */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + return + } + v5 = pParse + 56 + v4 = *(*int32)(unsafe.Pointer(v5)) + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + iCsr = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regYield = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regRec = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regRowid = v4 + _sqlite3MayAbort(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenWrite), iCsr, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot, iDb) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_P2ISREG)) + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, addrTop) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + pSelTab = _sqlite3ResultSetOfSelect(tls, pParse, pSelect, uint8(SQLITE_AFF_BLOB)) + if pSelTab == uintptr(0) { + return + } + v12 = (*TTable)(unsafe.Pointer(pSelTab)).FnCol + (*TTable)(unsafe.Pointer(p)).FnNVCol = v12 + (*TTable)(unsafe.Pointer(p)).FnCol = v12 + (*TTable)(unsafe.Pointer(p)).FaCol = (*TTable)(unsafe.Pointer(pSelTab)).FaCol + (*TTable)(unsafe.Pointer(pSelTab)).FnCol = 0 + (*TTable)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) + _sqlite3DeleteTable(tls, db, pSelTab) + _sqlite3SelectDestInit(tls, bp, int32(SRT_Coroutine), regYield) + _sqlite3Select(tls, pParse, pSelect, bp) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + _sqlite3VdbeEndCoroutine(tls, v, regYield) + _sqlite3VdbeJumpHere(tls, v, addrTop-int32(1)) + addrInsLoop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (**(**TSelectDest)(__ccgo_up(bp))).FiSdst, (**(**TSelectDest)(__ccgo_up(bp))).FnSdst, regRec) + _sqlite3TableAffinity(tls, v, p, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iCsr, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iCsr, regRec, regRowid) + _sqlite3VdbeGoto(tls, v, addrInsLoop) + _sqlite3VdbeJumpHere(tls, v, addrInsLoop) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iCsr) + } + /* Compute the complete text of the CREATE statement */ + if pSelect != 0 { + zStmt = _createTableStmt(tls, db, p) + } else { + if tabOpts != 0 { + v5 = pParse + 280 + } else { + v5 = pEnd + } + pEnd2 = v5 + n = int32(int64((*TToken)(unsafe.Pointer(pEnd2)).Fz) - int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TToken)(unsafe.Pointer(pEnd2)).Fz))) != int32(';') { + n = libc.Int32FromUint32(uint32(n) + (*TToken)(unsafe.Pointer(pEnd2)).Fn) + } + zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+14593, libc.VaList(bp+48, zType2, n, (*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + } + /* A slot for the record has already been allocated in the + ** schema table. We just need to update that slot with all + ** the information we've collected. + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+14608, libc.VaList(bp+48, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zType, (*TTable)(unsafe.Pointer(p)).FzName, (*TTable)(unsafe.Pointer(p)).FzName, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot, zStmt, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRowid)) + _sqlite3DbFree(tls, db, zStmt) + _sqlite3ChangeCookie(tls, pParse, iDb) + /* Check to see if we need to create an sqlite_sequence table for + ** keeping track of autoincrement keys. + */ + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_Autoincrement) != uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != libc.Int32FromInt32(PARSE_MODE_NORMAL)) { + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + if (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab == uintptr(0) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+14706, libc.VaList(bp+48, (*TDb)(unsafe.Pointer(pDb)).FzDbSName)) + } + } + /* Reparse everything to update our internal data structures */ + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+14748, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName)), uint16(0)) + /* Test for cycles in generated columns and illegal expressions + ** in CHECK constraints and in DEFAULT clauses. */ + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasGenerated) != 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_SqlExec), int32(0x0001), 0, 0, _sqlite3MPrintf(tls, db, __ccgo_ts+14782, libc.VaList(bp+48, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(p)).FzName)), -int32(7)) + } + } + /* Add the table to the in-memory representation of the database. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + pSchema = (*TTable)(unsafe.Pointer(p)).FpSchema + pOld = _sqlite3HashInsert(tls, pSchema+8, (*TTable)(unsafe.Pointer(p)).FzName, p) + if pOld != 0 { + /* Malloc must have failed inside HashInsert() */ + _sqlite3OomFault(tls, db) + return + } + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + /* If this is the magic sqlite_sequence table used by autoincrement, + ** then record a pointer to this table in the main database structure + ** so that INSERT can find the table easily. */ + if libc.Xstrcmp(tls, (*TTable)(unsafe.Pointer(p)).FzName, __ccgo_ts+9899) == 0 { + (*TSchema)(unsafe.Pointer((*TTable)(unsafe.Pointer(p)).FpSchema)).FpSeqTab = p + } + } + if !(pSelect != 0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM { + if (*TToken)(unsafe.Pointer(pCons)).Fz == uintptr(0) { + pCons = pEnd + } + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FaddColOffset = int32(13) + int32(int64((*TToken)(unsafe.Pointer(pCons)).Fz)-int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + } +} + +// C documentation +// +// /* +// ** Assign a variable number to an expression that encodes a wildcard +// ** in the original SQL statement. +// ** +// ** Wildcards consisting of a single "?" are assigned the next sequential +// ** variable number. +// ** +// ** Wildcards of the form "?nnn" are assigned the number "nnn". We make +// ** sure "nnn" is not too big to avoid a denial of service attack when +// ** the SQL statement comes from an external source. +// ** +// ** Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number +// ** as the previous instance of the same wildcard. Or if this is the first +// ** instance of the wildcard, the next sequential variable number is +// ** assigned. +// */ +func _sqlite3ExprAssignVarNumber(tls *libc.TLS, pParse uintptr, pExpr uintptr, n Tu32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOk, doAdd int32 + var db, z, v2 uintptr + var x, v1 TynVar + var _ /* i at bp+0 */ Ti64 + _, _, _, _, _, _, _ = bOk, db, doAdd, x, z, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pExpr == uintptr(0) { + return + } + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == 0 { + /* Wildcard of the form "?". Assign the next variable number */ + v2 = pParse + 296 + *(*TynVar)(unsafe.Pointer(v2)) = *(*TynVar)(unsafe.Pointer(v2)) + 1 + v1 = *(*TynVar)(unsafe.Pointer(v2)) + x = v1 + } else { + doAdd = 0 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32('?') { + if n == uint32(2) { /*OPTIMIZATION-IF-TRUE*/ + **(**Ti64)(__ccgo_up(bp)) = int64(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) - int32('0')) /* The common case of ?N for a single digit N */ + bOk = int32(1) + } else { + bOk = libc.BoolInt32(0 == _sqlite3Atoi64(tls, z+1, bp, libc.Int32FromUint32(n-uint32(1)), uint8(SQLITE_UTF8))) + } + if bOk == 0 || **(**Ti64)(__ccgo_up(bp)) < int64(1) || **(**Ti64)(__ccgo_up(bp)) > int64(**(**int32)(__ccgo_up(db + 136 + 9*4))) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8059, libc.VaList(bp+16, **(**int32)(__ccgo_up(db + 136 + 9*4)))) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + return + } + x = int16(**(**Ti64)(__ccgo_up(bp))) + if int32(x) > int32((*TParse)(unsafe.Pointer(pParse)).FnVar) { + (*TParse)(unsafe.Pointer(pParse)).FnVar = int16(int32(x)) + doAdd = int32(1) + } else { + if _sqlite3VListNumToName(tls, (*TParse)(unsafe.Pointer(pParse)).FpVList, int32(x)) == uintptr(0) { + doAdd = int32(1) + } + } + } else { + /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable + ** number as the prior appearance of the same name, or if the name + ** has never appeared before, reuse the same variable number + */ + x = int16(_sqlite3VListNameToNum(tls, (*TParse)(unsafe.Pointer(pParse)).FpVList, z, libc.Int32FromUint32(n))) + if int32(x) == 0 { + v2 = pParse + 296 + *(*TynVar)(unsafe.Pointer(v2)) = *(*TynVar)(unsafe.Pointer(v2)) + 1 + v1 = *(*TynVar)(unsafe.Pointer(v2)) + x = v1 + doAdd = int32(1) + } + } + if doAdd != 0 { + (*TParse)(unsafe.Pointer(pParse)).FpVList = _sqlite3VListAdd(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpVList, z, libc.Int32FromUint32(n), int32(x)) + } + } + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = x + if int32(x) > **(**int32)(__ccgo_up(db + 136 + 9*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8102, 0) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + } +} + +// C documentation +// +// /* +// ** Generate code into the current Vdbe to evaluate the given +// ** expression. Attempt to store the results in register "target". +// ** Return the register where results are stored. +// ** +// ** With this routine, there is no guarantee that results will +// ** be stored in target. The result might be stored in some other +// ** register if it is convenient to do so. The calling function +// ** must check the return code and move the results to the desired +// ** register. +// */ +func _sqlite3ExprCodeTarget(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) (r int32) { + bp := tls.Alloc(192) + defer tls.Free(192) + var aListelem, db, db1, pAggInfo, pAggInfo1, pCol, pCol1, pColl, pDef, pDel, pEList, pFarg, pInfo, pLeft, pLeft1, pLeft2, pTab, pTab1, pTab2, pTest, pX, v, z, zBlob, zId, v3 uintptr + var addr, addrINR, addrIsNull, addrIsNull1, aff, bNormal, destIfFalse, destIfNull, endLabel, i, i1, iCol, iCol1, iReg, iSrc, iTab, inReg, isTrue, n, n1, nCol, nExpr, nFarg, nextCase, op, p1, p5, v1 int32 + var constMask Tu32 + var enc, exprOp, okConstFactor Tu8 + var v2 bool + var _ /* opCompare at bp+88 */ TExpr + var _ /* r1 at bp+8 */ int32 + var _ /* r2 at bp+12 */ int32 + var _ /* regFree1 at bp+0 */ int32 + var _ /* regFree2 at bp+4 */ int32 + var _ /* tempX at bp+16 */ TExpr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aListelem, addr, addrINR, addrIsNull, addrIsNull1, aff, bNormal, constMask, db, db1, destIfFalse, destIfNull, enc, endLabel, exprOp, i, i1, iCol, iCol1, iReg, iSrc, iTab, inReg, isTrue, n, n1, nCol, nExpr, nFarg, nextCase, okConstFactor, op, p1, p5, pAggInfo, pAggInfo1, pCol, pCol1, pColl, pDef, pDel, pEList, pFarg, pInfo, pLeft, pLeft1, pLeft2, pTab, pTab1, pTab2, pTest, pX, v, z, zBlob, zId, v1, v2, v3 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* The opcode being coded */ + inReg = target /* Results stored in register inReg */ + **(**int32)(__ccgo_up(bp)) = 0 /* If non-zero free this temporary register */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* Temporary expression node */ + p5 = 0 + goto expr_code_doover +expr_code_doover: + ; + if pExpr == uintptr(0) { + op = int32(TK_NULL) + } else { + if v2 = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr != uintptr(0) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)); v2 { + v1 = _sqlite3IndexedExprLookup(tls, pParse, pExpr, target) + **(**int32)(__ccgo_up(bp + 8)) = v1 + } + if v2 && v1 >= 0 { + return **(**int32)(__ccgo_up(bp + 8)) + } else { + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + } + } + switch op { + case int32(TK_AGG_COLUMN): + pAggInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn { + /* Happens when the left table of a RIGHT JOIN is null and + ** is using an expression index */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + break + } + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32 + if !((*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode != 0) { + return (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + } else { + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx != 0 { + pTab = (*TAggInfo_col)(unsafe.Pointer(pCol)).FpTab + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab, (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn, target) + if pTab == uintptr(0) { + /* No comment added */ + } else { + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn < 0 { + } else { + if libc.Int32FromUint8((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + } + } + } + return target + } else { + if *(*uintptr)(unsafe.Pointer(pExpr + 64)) == uintptr(0) { + /* This case happens when the argument to an aggregate function + ** is rewritten by aggregateConvertIndexedExprRefToColumn() */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), target) + return target + } + } + } + /* Otherwise, fall thru into the TK_COLUMN case */ + fallthrough + case int32(TK_COLUMN): + iTab = (*TExpr)(unsafe.Pointer(pExpr)).FiTable + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != uint32(0) { + iReg = _sqlite3ExprCodeTarget(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + aff = libc.Int32FromUint8(_sqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn))) + if aff > int32(SQLITE_AFF_BLOB) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), iReg, int32(1), 0, uintptr(unsafe.Pointer(&_zAff))+uintptr((aff-int32('B'))*int32(2)), -int32(1)) + } + return iReg + } + if iTab < 0 { + if (*TParse)(unsafe.Pointer(pParse)).FiSelfTab < 0 { + iCol = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + pTab1 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + if iCol < 0 { + return -int32(1) - (*TParse)(unsafe.Pointer(pParse)).FiSelfTab + } + pCol1 = (*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(iCol)*16 + iSrc = int32(_sqlite3TableColumnToStorage(tls, pTab1, int16(iCol))) - (*TParse)(unsafe.Pointer(pParse)).FiSelfTab + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_BUSY) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8452, libc.VaList(bp+168, (*TColumn)(unsafe.Pointer(pCol1)).FzCnName)) + return 0 + } + v3 = pCol1 + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(COLFLAG_BUSY)) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_NOTAVAIL) != 0 { + _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab1, pCol1, iSrc) + } + v3 = pCol1 + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(COLFLAG_BUSY) | libc.Int32FromInt32(COLFLAG_NOTAVAIL))) + return iSrc + } else { + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), iSrc, target) + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + return target + } else { + return iSrc + } + } + } else { + /* Coding an expression that is part of an index where column names + ** in the index refer to the table to which the index belongs */ + iTab = (*TParse)(unsafe.Pointer(pParse)).FiSelfTab - int32(1) + } + } else { + if v2 = (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr != 0; v2 { + v1 = _exprPartidxExprLookup(tls, pParse, pExpr, target) + **(**int32)(__ccgo_up(bp + 8)) = v1 + } + if v2 && 0 != v1 { + return **(**int32)(__ccgo_up(bp + 8)) + } + } + iReg = _sqlite3ExprCodeGetColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), iTab, target, (*TExpr)(unsafe.Pointer(pExpr)).Fop2) + return iReg + case int32(TK_INTEGER): + _codeInteger(tls, pParse, pExpr, 0, target) + return target + case int32(TK_TRUEFALSE): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprTruthValue(tls, pExpr), target) + return target + case int32(TK_FLOAT): + _codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pExpr + 8)), 0, target) + return target + case int32(TK_STRING): + _sqlite3VdbeLoadString(tls, v, target, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + return target + case int32(TK_NULLS): + /* Set a range of registers to NULL. pExpr->y.nReg registers starting + ** with target */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, target, target+*(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fy))-int32(1)) + return target + default: + /* Make NULL the default case so that if a bug causes an illegal + ** Expr node to be passed into this function, it will be handled + ** sanely and not crash. But keep the assert() to bring the problem + ** to the attention of the developers. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + return target + case int32(TK_BLOB): + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + 2 + n = _sqlite3Strlen30(tls, z) - int32(1) + zBlob = _sqlite3HexToBlob(tls, _sqlite3VdbeDb(tls, v), z, n) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Blob), n/int32(2), target, 0, zBlob, -int32(7)) + return target + case int32(TK_VARIABLE): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Variable), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), target) + return target + case int32(TK_REGISTER): + return (*TExpr)(unsafe.Pointer(pExpr)).FiTable + case int32(TK_CAST): + /* Expressions of the form: CAST(pLeft AS token) */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Cast), target, libc.Int32FromUint8(_sqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0)))) + return inReg + case int32(TK_IS): + fallthrough + case int32(TK_ISNOT): + if op == int32(TK_IS) { + v1 = int32(TK_EQ) + } else { + v1 = int32(TK_NE) + } + op = v1 + p5 = int32(SQLITE_NULLEQ) + fallthrough + case int32(TK_LT): + fallthrough + case int32(TK_LE): + fallthrough + case int32(TK_GT): + fallthrough + case int32(TK_GE): + fallthrough + case int32(TK_NE): + fallthrough + case int32(TK_EQ): + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + addrIsNull = 0 + if _sqlite3ExprIsVector(tls, pLeft) != 0 { + _codeVectorCompare(tls, pParse, pExpr, target, libc.Uint8FromInt32(op), libc.Uint8FromInt32(p5)) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) && p5 != int32(SQLITE_NULLEQ) { + addrIsNull = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), inReg) + _codeCompare(tls, pParse, pLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, op, **(**int32)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 12)), _sqlite3VdbeCurrentAddr(tls, v)+int32(2), p5, libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0))) + if p5 == int32(SQLITE_NULLEQ) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, inReg) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_ZeroOrNull), **(**int32)(__ccgo_up(bp + 8)), inReg, **(**int32)(__ccgo_up(bp + 12))) + if addrIsNull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addrIsNull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, inReg) + } + } + } + case int32(TK_AND): + fallthrough + case int32(TK_OR): + inReg = _exprCodeTargetAndOr(tls, pParse, pExpr, target, bp) + case int32(TK_PLUS): + fallthrough + case int32(TK_STAR): + fallthrough + case int32(TK_MINUS): + fallthrough + case int32(TK_REM): + fallthrough + case int32(TK_BITAND): + fallthrough + case int32(TK_BITOR): + fallthrough + case int32(TK_SLASH): + fallthrough + case int32(TK_LSHIFT): + fallthrough + case int32(TK_RSHIFT): + fallthrough + case int32(TK_CONCAT): + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + addrIsNull1 = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) + addrIsNull1 = 0 + } + _sqlite3VdbeAddOp3(tls, v, op, **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 8)), target) + if addrIsNull1 != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addrIsNull1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + case int32(TK_UMINUS): + pLeft1 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft1)).Fop) == int32(TK_INTEGER) { + _codeInteger(tls, pParse, pLeft1, int32(1), target) + return target + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft1)).Fop) == int32(TK_FLOAT) { + _codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pLeft1 + 8)), int32(1), target) + return target + } else { + (**(**TExpr)(__ccgo_up(bp + 16))).Fop = uint8(TK_INTEGER) + (**(**TExpr)(__ccgo_up(bp + 16))).Fflags = libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue) | libc.Int32FromInt32(EP_TokenOnly)) + *(*int32)(unsafe.Pointer(bp + 16 + 8)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, bp+16, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp+4) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Subtract), **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 8)), target) + } + } + case int32(TK_BITNOT): + fallthrough + case int32(TK_NOT): + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + _sqlite3VdbeAddOp2(tls, v, op, **(**int32)(__ccgo_up(bp + 8)), inReg) + case int32(TK_TRUTH): /* IS TRUE or IS FALSE */ + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + isTrue = _sqlite3ExprTruthValue(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + bNormal = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) == int32(TK_IS)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsTrue), **(**int32)(__ccgo_up(bp + 8)), inReg, libc.BoolInt32(!(isTrue != 0)), isTrue^bNormal) + case int32(TK_ISNULL): + fallthrough + case int32(TK_NOTNULL): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), target) + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + addr = _sqlite3VdbeAddOp1(tls, v, op, **(**int32)(__ccgo_up(bp + 8))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, target) + _sqlite3VdbeJumpHere(tls, v, addr) + case int32(TK_AGG_FUNCTION): + pInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if pInfo == uintptr(0) || int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) < 0 || int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pInfo)).FnFunc { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8513, libc.VaList(bp+168, pExpr)) + } else { + return (*TAggInfo)(unsafe.Pointer(pInfo)).FiFirstReg + (*TAggInfo)(unsafe.Pointer(pInfo)).FnColumn + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + } + case int32(TK_FUNCTION): /* The function name */ + constMask = uint32(0) /* Loop counter */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The database connection */ + enc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc /* The text encoding used by this database */ + pColl = uintptr(0) /* A collating sequence */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + return (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FregResult + } + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x80>>7)) != 0 && _sqlite3ExprIsConstantNotJoin(tls, pParse, pExpr) != 0 { + /* SQL functions can be expensive. So try to avoid running them + ** multiple times if we know they always give the same result */ + return _sqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -int32(1)) + } + pFarg = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if pFarg != 0 { + v1 = (*TExprList)(unsafe.Pointer(pFarg)).FnExpr + } else { + v1 = 0 + } + nFarg = v1 + zId = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + pDef = _sqlite3FindFunction(tls, db, zId, nFarg, enc, uint8(0)) + if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8540, libc.VaList(bp+168, pExpr)) + break + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INLINE) != uint32(0) && pFarg != uintptr(0) { + return _exprCodeInlineFunction(tls, pParse, pFarg, int32(int64((*TFuncDef)(unsafe.Pointer(pDef)).FpUserData)), target) + } else { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_DIRECT)|libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) != 0 { + _sqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) + } + } + i = 0 + for { + if !(i < nFarg) { + break + } + if i < int32(32) && _sqlite3ExprIsConstant(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + uintptr(i)*32))).FpExpr) != 0 { + constMask = constMask | libc.Uint32FromInt32(1)<= int32(2) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InfixFunc)) != uint32(0) { + pDef = _sqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr) + } else { + if nFarg > 0 { + pDef = _sqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr) + } + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 { + if !(pColl != 0) { + pColl = (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_CollSeq), 0, 0, 0, pColl, -int32(2)) + } + _sqlite3VdbeAddFunctionCall(tls, pParse, libc.Int32FromUint32(constMask), **(**int32)(__ccgo_up(bp + 8)), target, nFarg, pDef, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2)) + if nFarg != 0 { + if constMask == uint32(0) { + _sqlite3ReleaseTempRange(tls, pParse, **(**int32)(__ccgo_up(bp + 8)), nFarg) + } else { + } + } + return target + case int32(TK_EXISTS): + fallthrough + case int32(TK_SELECT): + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return 0 + } else { + if v2 = op == int32(TK_SELECT) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0); v2 { + v1 = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList)).FnExpr + nCol = v1 + } + if v2 && v1 != int32(1) { + _sqlite3SubselectError(tls, pParse, nCol, int32(1)) + } else { + return _sqlite3CodeSubselect(tls, pParse, pExpr) + } + } + case int32(TK_SELECT_COLUMN): + pLeft2 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if (*TExpr)(unsafe.Pointer(pLeft2)).FiTable == 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn) > libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft2)).Fop2) { + (*TExpr)(unsafe.Pointer(pLeft2)).FiTable = _sqlite3CodeSubselect(tls, pParse, pLeft2) + (*TExpr)(unsafe.Pointer(pLeft2)).Fop2 = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn + } + n1 = _sqlite3ExprVectorSize(tls, pLeft2) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable != n1 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8125, libc.VaList(bp+168, (*TExpr)(unsafe.Pointer(pExpr)).FiTable, n1)) + } + return (*TExpr)(unsafe.Pointer(pLeft2)).FiTable + int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + case int32(TK_IN): + destIfFalse = _sqlite3VdbeMakeLabel(tls, pParse) + destIfNull = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + _sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), target) + _sqlite3VdbeResolveLabel(tls, v, destIfFalse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), target, 0) + _sqlite3VdbeResolveLabel(tls, v, destIfNull) + return target + /* + ** x BETWEEN y AND z + ** + ** This is equivalent to + ** + ** x>=y AND x<=z + ** + ** X is stored in pExpr->pLeft. + ** Y is stored in pExpr->pList->a[0].pExpr. + ** Z is stored in pExpr->pList->a[1].pExpr. + */ + fallthrough + case int32(TK_BETWEEN): + _exprCodeBetween(tls, pParse, pExpr, target, uintptr(0), 0) + return target + case int32(TK_COLLATE): + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != libc.Uint32FromInt32(0)) { + /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called + ** "SOFT-COLLATE" that is added to constraints that are pushed down + ** from outer queries into sub-queries by the WHERE-clause push-down + ** optimization. Clear subtypes as subtypes may not cross a subquery + ** boundary. + */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ClrSubtype), target) + return target + } else { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + goto expr_code_doover /* 2018-04-28: Prevent deep recursion. */ + } + fallthrough + case int32(TK_SPAN): + fallthrough + case int32(TK_UPLUS): + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + goto expr_code_doover /* 2018-04-28: Prevent deep recursion. OSSFuzz. */ + case int32(TK_TRIGGER): + pTab2 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + iCol1 = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + p1 = (*TExpr)(unsafe.Pointer(pExpr)).FiTable*(int32((*TTable)(unsafe.Pointer(pTab2)).FnCol)+int32(1)) + int32(1) + int32(_sqlite3TableColumnToStorage(tls, pTab2, int16(iCol1))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Param), p1, target) + /* If the column has REAL affinity, it may currently be stored as an + ** integer. Use OP_RealAffinity to make sure it is really real. + ** + ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to + ** floating point when extracting it from the record. */ + if iCol1 >= 0 && libc.Int32FromUint8((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab2)).FaCol + uintptr(iCol1)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + } + case int32(TK_VECTOR): + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6908, 0) + break + /* TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions + ** that derive from the right-hand table of a LEFT JOIN. The + ** Expr.iTable value is the table number for the right-hand table. + ** The expression is only evaluated if that table is not currently + ** on a LEFT JOIN NULL row. + */ + fallthrough + case int32(TK_IF_NULL_ROW): + okConstFactor = libc.Uint8FromInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x80 >> 7))) + pAggInfo1 = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if pAggInfo1 != 0 { + if !((*TAggInfo)(unsafe.Pointer(pAggInfo1)).FdirectMode != 0) { + inReg = (*TAggInfo)(unsafe.Pointer(pAggInfo1)).FiFirstReg + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + break + } + if (*TAggInfo)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo)).FuseSortingIdx != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo)(unsafe.Pointer(pAggInfo1)).FsortingIdxPTab, (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo1)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32))).FiSorterColumn, target) + inReg = target + break + } + } + addrINR = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNullRow), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, 0, target) + /* The OP_IfNullRow opcode above can overwrite the result register with + ** NULL. So we have to ensure that the result register is not a value + ** that is suppose to be a constant. Two defenses are needed: + ** (1) Temporarily disable factoring of constant expressions + ** (2) Make sure the computed value really is stored in register + ** "target" and not someplace else. + */ + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) /* note (1) above */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + libc.SetBitFieldPtr16Uint32(pParse+40, uint32(okConstFactor), 7, 0x80) + _sqlite3VdbeJumpHere(tls, v, addrINR) + break + /* + ** Form A: + ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** Form B: + ** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** Form A is can be transformed into the equivalent form B as follows: + ** CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ... + ** WHEN x=eN THEN rN ELSE y END + ** + ** X (if it exists) is in pExpr->pLeft. + ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is + ** odd. The Y is also optional. If the number of elements in x.pList + ** is even, then Y is omitted and the "otherwise" result is NULL. + ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1]. + ** + ** The result of the expression is the Ri for the first matching Ei, + ** or if there is no matching Ei, the ELSE term Y, or if there is + ** no ELSE term, NULL. + */ + fallthrough + case int32(TK_CASE): /* The X expression */ + pTest = uintptr(0) /* X==Ei (form A) or just Ei (form B) */ + pDel = uintptr(0) + db1 = (*TParse)(unsafe.Pointer(pParse)).Fdb + pEList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + aListelem = pEList + 8 + nExpr = (*TExprList)(unsafe.Pointer(pEList)).FnExpr + endLabel = _sqlite3VdbeMakeLabel(tls, pParse) + v3 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pX = v3 + if v3 != uintptr(0) { + pDel = _sqlite3ExprDup(tls, db1, pX, 0) + if (*Tsqlite3)(unsafe.Pointer(db1)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db1, pDel) + break + } + _sqlite3ExprToRegister(tls, pDel, _exprCodeVector(tls, pParse, pDel, bp)) + libc.Xmemset(tls, bp+88, 0, uint64(72)) + (**(**TExpr)(__ccgo_up(bp + 88))).Fop = uint8(TK_EQ) + (**(**TExpr)(__ccgo_up(bp + 88))).FpLeft = pDel + pTest = bp + 88 + /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001: + ** The value in regFree1 might get SCopy-ed into the file result. + ** So make sure that the regFree1 register is not reused for other + ** purposes and possibly overwritten. */ + **(**int32)(__ccgo_up(bp)) = 0 + } + i1 = 0 + for { + if !(i1 < nExpr-int32(1)) { + break + } + if pX != 0 { + (**(**TExpr)(__ccgo_up(bp + 88))).FpRight = (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1)*32))).FpExpr + } else { + pTest = (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1)*32))).FpExpr + } + nextCase = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfFalse(tls, pParse, pTest, nextCase, int32(SQLITE_JUMPIFNULL)) + _sqlite3ExprCode(tls, pParse, (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1+int32(1))*32))).FpExpr, target) + _sqlite3VdbeGoto(tls, v, endLabel) + _sqlite3VdbeResolveLabel(tls, v, nextCase) + goto _13 + _13: + ; + i1 = i1 + int32(2) + } + if nExpr&int32(1) != 0 { + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(nExpr-int32(1))*32))).FpExpr, target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + _sqlite3ExprDelete(tls, db1, pDel) + _setDoNotMergeFlagOnCopy(tls, v) + _sqlite3VdbeResolveLabel(tls, v, endLabel) + case int32(TK_RAISE): + if !((*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0) && !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8564, 0) + return 0 + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(OE_Abort) { + _sqlite3MayAbort(tls, pParse) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(OE_Ignore) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), SQLITE_OK, int32(OE_Ignore)) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { + v1 = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(7)<, ... FROM
    +// ** +// ** If the RHS of the IN operator is a list or a more complex subquery, then +// ** an ephemeral table might need to be generated from the RHS and then +// ** pX->iTable made to point to the ephemeral table instead of an +// ** existing table. In this case, the creation and initialization of the +// ** ephemeral table might be put inside of a subroutine, the EP_Subrtn flag +// ** will be set on pX and the pX->y.sub fields will be set to show where +// ** the subroutine is coded. +// ** +// ** The inFlags parameter must contain, at a minimum, one of the bits +// ** IN_INDEX_MEMBERSHIP or IN_INDEX_LOOP but not both. If inFlags contains +// ** IN_INDEX_MEMBERSHIP, then the generated table will be used for a fast +// ** membership test. When the IN_INDEX_LOOP bit is set, the IN index will +// ** be used to loop over all values of the RHS of the IN operator. +// ** +// ** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate +// ** through the set members) then the b-tree must not contain duplicates. +// ** An ephemeral table will be created unless the selected columns are guaranteed +// ** to be unique - either because it is an INTEGER PRIMARY KEY or due to +// ** a UNIQUE constraint or index. +// ** +// ** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used +// ** for fast set membership tests) then an ephemeral table must +// ** be used unless is a single INTEGER PRIMARY KEY column or an +// ** index can be found with the specified as its left-most. +// ** +// ** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and +// ** if the RHS of the IN operator is a list (not a subquery) then this +// ** routine might decide that creating an ephemeral b-tree for membership +// ** testing is too expensive and return IN_INDEX_NOOP. In that case, the +// ** calling routine should implement the IN operator using a sequence +// ** of Eq or Ne comparison operations. +// ** +// ** When the b-tree is being used for membership tests, the calling function +// ** might need to know whether or not the RHS side of the IN operator +// ** contains a NULL. If prRhsHasNull is not a NULL pointer and +// ** if there is any chance that the (...) might contain a NULL value at +// ** runtime, then a register is allocated and the register number written +// ** to *prRhsHasNull. If there is no chance that the (...) contains a +// ** NULL value, then *prRhsHasNull is left unchanged. +// ** +// ** If a register is allocated and its location stored in *prRhsHasNull, then +// ** the value in that register will be NULL if the b-tree contains one or more +// ** NULL values, and it will be some non-NULL value if the b-tree contains no +// ** NULL values. +// ** +// ** If the aiMap parameter is not NULL, it must point to an array containing +// ** one element for each column returned by the SELECT statement on the RHS +// ** of the IN(...) operator. The i'th entry of the array is populated with the +// ** offset of the index column that matches the i'th column returned by the +// ** SELECT. For example, if the expression and selected index are: +// ** +// ** (?,?,?) IN (SELECT a, b, c FROM t1) +// ** CREATE INDEX i1 ON t1(b, c, a); +// ** +// ** then aiMap[] is populated with {2, 0, 1}. +// */ +func _sqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags Tu32, prRhsHasNull uintptr, aiMap uintptr, piTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var affinity_ok, bloomOk, eType, i, i1, i2, iAddr, iAddr1, iCol, iDb, iTab, j, mustBeUnique, n, nExpr, rMayHaveNull, v1, v10 int32 + var cmpaff, idxaff uint8 + var colUsed, mCol TBitmask + var db, p, pEList, pEList1, pIdx, pLhs, pLhs1, pReq, pRhs, pTab, v, v2 uintptr + var savedNQueryLoop Tu32 + var v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = affinity_ok, bloomOk, cmpaff, colUsed, db, eType, i, i1, i2, iAddr, iAddr1, iCol, iDb, iTab, idxaff, j, mCol, mustBeUnique, n, nExpr, p, pEList, pEList1, pIdx, pLhs, pLhs1, pReq, pRhs, pTab, rMayHaveNull, savedNQueryLoop, v, v1, v10, v2, v5 /* SELECT to the right of IN operator */ + eType = 0 /* True if RHS must be unique */ + v = _sqlite3GetVdbe(tls, pParse) /* Virtual machine being coded */ + mustBeUnique = libc.BoolInt32(inFlags&uint32(IN_INDEX_LOOP) != uint32(0)) + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + iTab = v1 + /* If the RHS of this IN(...) operator is a SELECT, and if it matters + ** whether or not the SELECT result contains NULL values, check whether + ** or not NULL is actually possible (it may not be, for example, due + ** to NOT NULL constraints in the schema). If no NULL values are possible, + ** set prRhsHasNull to 0 before continuing. */ + if prRhsHasNull != 0 && (*TExpr)(unsafe.Pointer(pX)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + pEList = (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32)))).FpEList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if _sqlite3ExprCanBeNull(tls, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr) != 0 { + break + } + goto _3 + _3: + ; + i = i + 1 + } + if i == (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + prRhsHasNull = uintptr(0) + } + } + /* Check to see if an existing table or index can be used to + ** satisfy the query. This is preferable to generating a new + ** ephemeral table. */ + if v5 = (*TParse)(unsafe.Pointer(pParse)).FnErr == 0; v5 { + v2 = _isCandidateForInOpt(tls, pX) + p = v2 + } + if v5 && v2 != uintptr(0) { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database idx for pTab */ + pEList1 = (*TSelect)(unsafe.Pointer(p)).FpEList + nExpr = (*TExprList)(unsafe.Pointer(pEList1)).FnExpr + /* Because of isCandidateForInOpt(p) */ + /* Because of isCandidateForInOpt(p) */ + /* Because of isCandidateForInOpt(p) */ + pTab = (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab + /* Code an OP_Transaction and OP_TableLock for
    . */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab)).FzName) + /* sqlite3GetVdbe() has always been previously called */ + if nExpr == int32(1) && int32((*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList1 + 8))).FpExpr)).FiColumn) < 0 { + /* The "x IN (SELECT rowid FROM table)" case */ + iAddr = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + _sqlite3OpenTable(tls, pParse, iTab, iDb, pTab, int32(OP_OpenRead)) + eType = int32(IN_INDEX_ROWID) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8207, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + _sqlite3VdbeJumpHere(tls, v, iAddr) + } else { /* Iterator variable */ + affinity_ok = int32(1) + /* Check that the affinity that will be used to perform each + ** comparison is the same as the affinity of each column in table + ** on the RHS of the IN operator. If it not, it is not possible to + ** use any index of the RHS table. */ + i1 = 0 + for { + if !(i1 < nExpr && affinity_ok != 0) { + break + } + pLhs = _sqlite3VectorFieldSubexpr(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft, i1) + iCol = int32((*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList1 + 8 + uintptr(i1)*32))).FpExpr)).FiColumn) + idxaff = _sqlite3TableColumnAffinity(tls, pTab, iCol) /* RHS table */ + cmpaff = _sqlite3CompareAffinity(tls, pLhs, idxaff) + switch libc.Int32FromUint8(cmpaff) { + case int32(SQLITE_AFF_BLOB): + case int32(SQLITE_AFF_TEXT): + /* sqlite3CompareAffinity() only returns TEXT if one side or the + ** other has no affinity and the other side is TEXT. Hence, + ** the only way for cmpaff to be TEXT is for idxaff to be TEXT + ** and for the term on the LHS of the IN to have no affinity. */ + default: + affinity_ok = libc.BoolInt32(libc.Int32FromUint8(idxaff) >= int32(SQLITE_AFF_NUMERIC)) + } + goto _6 + _6: + ; + i1 = i1 + 1 + } + if affinity_ok != 0 { + /* Search for an existing index that will work for this IN operator */ + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0 && eType == 0) { + break + } /* Mask for the current column */ + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) < nExpr { + goto _7 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) { + goto _7 + } + /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute + ** BITMASK(nExpr) without overflowing */ + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + goto _7 + } + if mustBeUnique != 0 { + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) > nExpr || libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) > nExpr && !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromInt32(OE_None)) { + goto _7 /* This index is not unique over the IN RHS columns */ + } + } + colUsed = uint64(0) /* Columns of index used so far */ + i1 = 0 + for { + if !(i1 < nExpr) { + break + } + pLhs1 = _sqlite3VectorFieldSubexpr(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft, i1) + pRhs = (*(*TExprList_item)(unsafe.Pointer(pEList1 + 8 + uintptr(i1)*32))).FpExpr + pReq = _sqlite3BinaryCompareCollSeq(tls, pParse, pLhs1, pRhs) + j = 0 + for { + if !(j < nExpr) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) != int32((*TExpr)(unsafe.Pointer(pRhs)).FiColumn) { + goto _9 + } + if pReq != uintptr(0) && _sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pReq)).FzName, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8))) != 0 { + goto _9 + } + break + goto _9 + _9: + ; + j = j + 1 + } + if j == nExpr { + break + } + mCol = libc.Uint64FromInt32(1) << j + if mCol&colUsed != 0 { + break + } /* Each column used only once */ + colUsed = colUsed | mCol + if aiMap != 0 { + **(**int32)(__ccgo_up(aiMap + uintptr(i1)*4)) = j + } + goto _8 + _8: + ; + i1 = i1 + 1 + } + if colUsed == libc.Uint64FromInt32(1)<0 round to min(iRound,mxRound) significant digits total. +// ** +// ** mxRound must be positive. +// ** +// ** The significant digits of the decimal representation are +// ** stored in p->z[] which is a often (but not always) a pointer +// ** into the middle of p->zBuf[]. There are p->n significant digits. +// ** The p->z[] array is *not* zero-terminated. +// */ +func _sqlite3FpDecode(tls *libc.TLS, p uintptr, _r float64, iRound int32, mxRound int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + *(*float64)(unsafe.Pointer(bp)) = _r + var e, i, j, jj, jj1, kk, kk1, kk2, n, nn, v1 int32 + var v2, v21 Tu64 + var z, zBuf uintptr + var _ /* exp at bp+16 */ int32 + var _ /* v at bp+8 */ Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = e, i, j, jj, jj1, kk, kk1, kk2, n, nn, v2, v21, z, zBuf, v1 + **(**int32)(__ccgo_up(bp + 16)) = 0 /* Local alias for p->z */ + (*TFpDecode)(unsafe.Pointer(p)).FisSpecial = uint8(0) + /* Convert negative numbers to positive. Deal with Infinity, 0.0, and + ** NaN. */ + if **(**float64)(__ccgo_up(bp)) < float64(0) { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = uint8('-') + **(**float64)(__ccgo_up(bp)) = -**(**float64)(__ccgo_up(bp)) + } else { + if **(**float64)(__ccgo_up(bp)) == float64(0) { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = uint8('+') + (*TFpDecode)(unsafe.Pointer(p)).Fn = int32(1) + (*TFpDecode)(unsafe.Pointer(p)).FiDP = int32(1) + (*TFpDecode)(unsafe.Pointer(p)).Fz = __ccgo_ts + 1850 + return + } else { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = uint8('+') + } + } + libc.Xmemcpy(tls, bp+8, bp, uint64(8)) + e = libc.Int32FromUint64(**(**Tu64)(__ccgo_up(bp + 8)) >> libc.Int32FromInt32(52) & uint64(0x7ff)) + if e == int32(0x7ff) { + (*TFpDecode)(unsafe.Pointer(p)).FisSpecial = libc.Uint8FromInt32(int32(1) + libc.BoolInt32(**(**Tu64)(__ccgo_up(bp + 8)) != uint64(0x7ff0000000000000))) + (*TFpDecode)(unsafe.Pointer(p)).Fn = 0 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = 0 + (*TFpDecode)(unsafe.Pointer(p)).Fz = p + 16 + return + } + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) & uint64(0x000fffffffffffff) + if e == 0 { + nn = _countLeadingZeros(tls, **(**Tu64)(__ccgo_up(bp + 8))) + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) << libc.Uint64FromInt32(nn) + e = -int32(1074) - nn + } else { + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8))<= int32(18) { + v1 = int32(18) + } else { + v1 = iRound + int32(1) + } + _sqlite3Fp2Convert10(tls, **(**Tu64)(__ccgo_up(bp + 8)), e, v1, bp+8, bp+16) + /* Extract significant digits, start at the right-most slot in p->zBuf + ** and working back to the right. "i" keeps track of the next slot in + ** which to store a digit. */ + zBuf = p + 16 + i = int32(SQLITE_U64_DIGITS) + for **(**Tu64)(__ccgo_up(bp + 8)) >= uint64(10) { + kk = libc.Int32FromUint64(**(**Tu64)(__ccgo_up(bp + 8)) % uint64(100) * uint64(2)) + **(**Tu16)(__ccgo_up(zBuf + uintptr(i-int32(2)))) = **(**Tu16)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3DigitPairs)) + uintptr(kk))) + i = i - int32(2) + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) / uint64(100) + } + if **(**Tu64)(__ccgo_up(bp + 8)) != 0 { + i = i - 1 + v1 = i + **(**uint8)(__ccgo_up(zBuf + uintptr(v1))) = uint8(**(**Tu64)(__ccgo_up(bp + 8)) + uint64('0')) + } + n = int32(SQLITE_U64_DIGITS) - i /* Total number of digits extracted */ + (*TFpDecode)(unsafe.Pointer(p)).FiDP = n + **(**int32)(__ccgo_up(bp + 16)) + if iRound <= 0 { + iRound = (*TFpDecode)(unsafe.Pointer(p)).FiDP - iRound + if iRound == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zBuf + uintptr(i)))) >= int32('5') { + iRound = int32(1) + i = i - 1 + v1 = i + **(**uint8)(__ccgo_up(zBuf + uintptr(v1))) = uint8('0') + n = n + 1 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = (*TFpDecode)(unsafe.Pointer(p)).FiDP + 1 + } + } + z = zBuf + uintptr(i) /* z points to the first digit */ + if iRound > 0 && (iRound < n || n > mxRound) { + if iRound > mxRound { + iRound = mxRound + } + if iRound == int32(17) { + /* If the precision is exactly 17, which only happens with the "!" + ** flag (ex: "%!.17g") then try to reduce the precision if that + ** yields text that will round-trip to the original floating-point. + ** value. Thus, for exaple, 49.47 will render as 49.47, rather than + ** as 49.469999999999999. */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 15))) == int32('9') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 14))) == int32('9') { + jj = int32(14) + for { + if !(jj > 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(jj-int32(1))))) == int32('9')) { + break + } + goto _4 + _4: + ; + jj = jj - 1 + } + if jj == 0 { + v2 = uint64(1) + } else { + v2 = libc.Uint64FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) - int32('0')) + kk1 = int32(1) + for { + if !(kk1 < jj) { + break + } + v2 = v2*uint64(10) + uint64(**(**uint8)(__ccgo_up(z + uintptr(kk1)))) - uint64('0') + goto _5 + _5: + ; + kk1 = kk1 + 1 + } + v2 = v2 + 1 + } + if **(**float64)(__ccgo_up(bp)) == _sqlite3Fp10Convert2(tls, v2, **(**int32)(__ccgo_up(bp + 16))+n-jj) { + iRound = jj + int32(1) + } + } else { + if (*TFpDecode)(unsafe.Pointer(p)).FiDP >= n || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 15))) == int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 14))) == int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 13))) == int32('0') { + jj1 = int32(13) + for { + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(jj1-int32(1))))) == int32('0')) { + break + } + goto _6 + _6: + ; + jj1 = jj1 - 1 + } + v21 = libc.Uint64FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) - int32('0')) + kk2 = int32(1) + for { + if !(kk2 < jj1) { + break + } + v21 = v21*uint64(10) + uint64(**(**uint8)(__ccgo_up(z + uintptr(kk2)))) - uint64('0') + goto _7 + _7: + ; + kk2 = kk2 + 1 + } + if **(**float64)(__ccgo_up(bp)) == _sqlite3Fp10Convert2(tls, v21, **(**int32)(__ccgo_up(bp + 16))+n-jj1) { + iRound = jj1 + int32(1) + } + } + } + } + n = iRound + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(iRound)))) >= int32('5') { + j = iRound - int32(1) + for int32(1) != 0 { + **(**uint8)(__ccgo_up(z + uintptr(j))) = **(**uint8)(__ccgo_up(z + uintptr(j))) + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) <= int32('9') { + break + } + **(**uint8)(__ccgo_up(z + uintptr(j))) = uint8('0') + if j == 0 { + z = z - 1 + **(**uint8)(__ccgo_up(z)) = uint8('1') + n = n + 1 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = (*TFpDecode)(unsafe.Pointer(p)).FiDP + 1 + break + } else { + j = j - 1 + } + } + } + } + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n-int32(1))))) == int32('0') { + n = n - 1 + } + (*TFpDecode)(unsafe.Pointer(p)).Fn = n + (*TFpDecode)(unsafe.Pointer(p)).Fz = z +} + +// C documentation +// +// /* +// ** Arguments nArg/azArg contain the string arguments passed to the xCreate +// ** or xConnect method of the virtual table. This function attempts to +// ** allocate an instance of Fts5Config containing the results of parsing +// ** those arguments. +// ** +// ** If successful, SQLITE_OK is returned and *ppOut is set to point to the +// ** new Fts5Config object. If an error occurs, an SQLite error code is +// ** returned, *ppOut is set to NULL and an error message may be left in +// ** *pzErr. It is the responsibility of the caller to eventually free any +// ** such error message using sqlite3_free(). +// */ +func _sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int32, azArg uintptr, ppOut uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bOption, i int32 + var nByte Tsqlite3_int64 + var pRet, z, zOrig, zTail, v1, v2 uintptr + var _ /* bDummy at bp+28 */ int32 + var _ /* bMustBeCol at bp+24 */ int32 + var _ /* bUnindexed at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + var _ /* zOne at bp+8 */ uintptr + var _ /* zTwo at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _ = bOption, i, nByte, pRet, z, zOrig, zTail, v1, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 4)) = 0 /* True if there are one or more UNINDEXED */ + v1 = Xsqlite3_malloc64(tls, uint64(256)) + pRet = v1 + **(**uintptr)(__ccgo_up(ppOut)) = v1 + if pRet == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pRet, 0, uint64(256)) + (*TFts5Config)(unsafe.Pointer(pRet)).FpGlobal = pGlobal + (*TFts5Config)(unsafe.Pointer(pRet)).Fdb = db + (*TFts5Config)(unsafe.Pointer(pRet)).FiCookie = -int32(1) + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(nArg) * (libc.Uint64FromInt64(8) + libc.Uint64FromInt64(1))) + (*TFts5Config)(unsafe.Pointer(pRet)).FazCol = _sqlite3Fts5MallocZero(tls, bp, nByte) + if (*TFts5Config)(unsafe.Pointer(pRet)).FazCol != 0 { + v1 = (*TFts5Config)(unsafe.Pointer(pRet)).FazCol + uintptr(nArg)*8 + } else { + v1 = uintptr(0) + } + (*TFts5Config)(unsafe.Pointer(pRet)).FabUnindexed = v1 + (*TFts5Config)(unsafe.Pointer(pRet)).FzDb = _sqlite3Fts5Strndup(tls, bp, **(**uintptr)(__ccgo_up(azArg + 1*8)), -int32(1)) + (*TFts5Config)(unsafe.Pointer(pRet)).FzName = _sqlite3Fts5Strndup(tls, bp, **(**uintptr)(__ccgo_up(azArg + 2*8)), -int32(1)) + (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize = int32(1) + (*TFts5Config)(unsafe.Pointer(pRet)).FeDetail = FTS5_DETAIL_FULL + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && Xsqlite3_stricmp(tls, (*TFts5Config)(unsafe.Pointer(pRet)).FzName, __ccgo_ts+37899) == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38010, libc.VaList(bp+40, (*TFts5Config)(unsafe.Pointer(pRet)).FzName)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + i = int32(3) + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < nArg) { + break + } + zOrig = **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + bOption = 0 + **(**int32)(__ccgo_up(bp + 24)) = 0 + z = _fts5ConfigGobbleWord(tls, bp, zOrig, bp+8, bp+24) + z = _fts5ConfigSkipWhitespace(tls, z) + if z != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32('=') { + bOption = int32(1) + z = z + 1 + if **(**int32)(__ccgo_up(bp + 24)) != 0 { + z = uintptr(0) + } + } + z = _fts5ConfigSkipWhitespace(tls, z) + if z != 0 && **(**uint8)(__ccgo_up(z)) != 0 { + z = _fts5ConfigGobbleWord(tls, bp, z, bp+16, bp+28) + if z != 0 && **(**uint8)(__ccgo_up(z)) != 0 { + z = uintptr(0) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if z == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38039, libc.VaList(bp+40, zOrig)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + if bOption != 0 { + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v1 = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + v1 = __ccgo_ts + 1704 + } + if **(**uintptr)(__ccgo_up(bp + 16)) != 0 { + v2 = **(**uintptr)(__ccgo_up(bp + 16)) + } else { + v2 = __ccgo_ts + 1704 + } + **(**int32)(__ccgo_up(bp)) = _fts5ConfigParseSpecial(tls, pRet, v1, v2, pzErr) + } else { + **(**int32)(__ccgo_up(bp)) = _fts5ConfigParseColumn(tls, pRet, **(**uintptr)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp + 16)), pzErr, bp+4) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + } + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 16))) + goto _3 + _3: + ; + i = i + 1 + } + /* We only allow contentless_delete=1 if the table is indeed contentless. */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessDelete != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FeContent != int32(FTS5_CONTENT_NONE) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38059, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* We only allow contentless_delete=1 if columnsize=0 is not present. + ** + ** This restriction may be removed at some point. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessDelete != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38109, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* We only allow contentless_unindexed=1 if the table is actually a + ** contentless one. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessUnindexed != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FeContent != int32(FTS5_CONTENT_NONE) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38164, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* If no zContent option was specified, fill in the default values. */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FzContent == uintptr(0) { + zTail = uintptr(0) + if (*TFts5Config)(unsafe.Pointer(pRet)).FeContent == FTS5_CONTENT_NORMAL { + zTail = __ccgo_ts + 37522 + } else { + if **(**int32)(__ccgo_up(bp + 4)) != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessUnindexed != 0 { + (*TFts5Config)(unsafe.Pointer(pRet)).FeContent = int32(FTS5_CONTENT_UNINDEXED) + zTail = __ccgo_ts + 37522 + } else { + if (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize != 0 { + zTail = __ccgo_ts + 38217 + } + } + } + if zTail != 0 { + (*TFts5Config)(unsafe.Pointer(pRet)).FzContent = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38225, libc.VaList(bp+40, (*TFts5Config)(unsafe.Pointer(pRet)).FzDb, (*TFts5Config)(unsafe.Pointer(pRet)).FzName, zTail)) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FzContentRowid == uintptr(0) { + (*TFts5Config)(unsafe.Pointer(pRet)).FzContentRowid = _sqlite3Fts5Strndup(tls, bp, __ccgo_ts+17963, -int32(1)) + } + /* Formulate the zContentExprlist text */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _fts5ConfigMakeExprlist(tls, pRet) + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + _sqlite3Fts5ConfigFree(tls, pRet) + **(**uintptr)(__ccgo_up(ppOut)) = uintptr(0) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This is the callback routine for the code that initializes the +// ** database. See sqlite3Init() below for additional information. +// ** This routine is also called from the OP_ParseSchema opcode of the VDBE. +// ** +// ** Each callback contains the following information: +// ** +// ** argv[0] = type of object: "table", "index", "trigger", or "view". +// ** argv[1] = name of thing being created +// ** argv[2] = associated table if an index or trigger +// ** argv[3] = root page number for table or index. 0 for trigger or view. +// ** argv[4] = SQL text for the CREATE statement. +// ** +// */ +func _sqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr, NotUsed uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pData, pIndex uintptr + var iDb, rc int32 + var saved_iDb Tu8 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _ = db, iDb, pData, pIndex, rc, saved_iDb + pData = pInit + db = (*TInitData)(unsafe.Pointer(pData)).Fdb + iDb = (*TInitData)(unsafe.Pointer(pData)).FiDb + _ = NotUsed + _ = argc + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_EncodingFixed) + if argv == uintptr(0) { + return 0 + } /* Might happen if EMPTY_RESULT_CALLBACKS are on */ + (*TInitData)(unsafe.Pointer(pData)).FnInitRow = (*TInitData)(unsafe.Pointer(pData)).FnInitRow + 1 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _corruptSchema(tls, pData, argv, uintptr(0)) + return int32(1) + } + if **(**uintptr)(__ccgo_up(argv + 3*8)) == uintptr(0) { + _corruptSchema(tls, pData, argv, uintptr(0)) + } else { + if **(**uintptr)(__ccgo_up(argv + 4*8)) != 0 && int32('c') == libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8)))))]) && int32('r') == libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8)) + 1)))]) { + saved_iDb = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb + /* Return code from sqlite3_prepare() */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(iDb) + if _sqlite3GetUInt32(tls, **(**uintptr)(__ccgo_up(argv + 3*8)), db+192) == 0 || (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum > (*TInitData)(unsafe.Pointer(pData)).FmxPage && (*TInitData)(unsafe.Pointer(pData)).FmxPage > uint32(0) { + if _sqlite3Config.FbExtraSchemaChecks != 0 { + _corruptSchema(tls, pData, argv, __ccgo_ts+15740) + } + } + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(0), 0, 0x1) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = argv + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _sqlite3Prepare(tls, db, **(**uintptr)(__ccgo_up(argv + 4*8)), -int32(1), uint32(0), uintptr(0), bp, uintptr(0)) + rc = (*Tsqlite3)(unsafe.Pointer(db)).FerrCode + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = saved_iDb + /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */ + if SQLITE_OK != rc { + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x1>>0)) != 0 { + } else { + if rc > (*TInitData)(unsafe.Pointer(pData)).Frc { + (*TInitData)(unsafe.Pointer(pData)).Frc = rc + } + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } else { + if rc != int32(SQLITE_INTERRUPT) && rc&int32(0xFF) != int32(SQLITE_LOCKED) { + _corruptSchema(tls, pData, argv, Xsqlite3_errmsg(tls, db)) + } + } + } + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = uintptr(unsafe.Pointer(&_sqlite3StdType)) /* Any array of string ptrs will do */ + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + if **(**uintptr)(__ccgo_up(argv + 1*8)) == uintptr(0) || **(**uintptr)(__ccgo_up(argv + 4*8)) != uintptr(0) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8))))) != 0 { + _corruptSchema(tls, pData, argv, uintptr(0)) + } else { + pIndex = _sqlite3FindIndex(tls, db, **(**uintptr)(__ccgo_up(argv + 1*8)), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + if pIndex == uintptr(0) { + _corruptSchema(tls, pData, argv, __ccgo_ts+20090) + } else { + if _sqlite3GetUInt32(tls, **(**uintptr)(__ccgo_up(argv + 3*8)), pIndex+88) == 0 || (*TIndex)(unsafe.Pointer(pIndex)).Ftnum < uint32(2) || (*TIndex)(unsafe.Pointer(pIndex)).Ftnum > (*TInitData)(unsafe.Pointer(pData)).FmxPage || _sqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 { + if _sqlite3Config.FbExtraSchemaChecks != 0 { + _corruptSchema(tls, pData, argv, __ccgo_ts+15740) + } + } + } + } + } + } + return 0 +} + +// C documentation +// +// /* +// ** Attempt to load an SQLite extension library contained in the file +// ** zFile. The entry point is zProc. zProc may be 0 in which case a +// ** default entry point name (sqlite3_extension_init) is used. Use +// ** of the default name is recommended. +// ** +// ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. +// ** +// ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with +// ** error message text. The calling function should free this memory +// ** by calling sqlite3DbFree(db, ). +// */ +func _sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aHandle, handle, pVfs, zAltEntry, zAltFile, zEntry, v1 uintptr + var c, cnt, iEntry, iFile, ii, ncFile, rc, v3, v8 int32 + var nMsg Tu64 + var xInit Tsqlite3_loadext_entry + var v4 bool + var _ /* zErrmsg at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aHandle, c, cnt, handle, iEntry, iFile, ii, nMsg, ncFile, pVfs, rc, xInit, zAltEntry, zAltFile, zEntry, v1, v3, v4, v8 + pVfs = (*Tsqlite3)(unsafe.Pointer(db)).FpVfs + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zAltEntry = uintptr(0) + nMsg = uint64(libc.Xstrlen(tls, zFile)) + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + /* Ticket #1863. To avoid a creating security problems for older + ** applications that relink against newer versions of SQLite, the + ** ability to run load_extension is turned off by default. One + ** must call either sqlite3_enable_load_extension(db) or + ** sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0) + ** to turn on extension loading. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LoadExtension) == uint64(0) { + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+13671, 0) + } + return int32(SQLITE_ERROR) + } + if zProc != 0 { + v1 = zProc + } else { + v1 = __ccgo_ts + 17587 + } + zEntry = v1 + /* tag-20210611-1. Some dlopen() implementations will segfault if given + ** an oversize filename. Most filesystems have a pathname limit of 4K, + ** so limit the extension filename length to about twice that. + ** https://sqlite.org/forum/forumpost/08a0d6d9bf + ** + ** Later (2023-03-25): Save an extra 6 bytes for the filename suffix. + ** See https://sqlite.org/forum/forumpost/24083b579d. + */ + if nMsg > uint64(FILENAME_MAX) { + goto extension_not_found + } + /* Do not allow sqlite3_load_extension() to link to a copy of the + ** running application, by passing in an empty filename. */ + if nMsg == uint64(0) { + goto extension_not_found + } + handle = _sqlite3OsDlOpen(tls, pVfs, zFile) + ii = 0 + for { + if !(ii < libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(8)) && handle == uintptr(0)) { + break + } + zAltFile = Xsqlite3_mprintf(tls, __ccgo_ts+13632, libc.VaList(bp+16, zFile, _azEndings[ii])) + if zAltFile == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if nMsg+uint64(libc.Xstrlen(tls, _azEndings[ii]))+uint64(1) <= uint64(FILENAME_MAX) { + handle = _sqlite3OsDlOpen(tls, pVfs, zAltFile) + } + Xsqlite3_free(tls, zAltFile) + goto _2 + _2: + ; + ii = ii + 1 + } + if handle == uintptr(0) { + goto extension_not_found + } + xInit = _sqlite3OsDlSym(tls, pVfs, handle, zEntry) + /* If no entry point was specified and the default legacy + ** entry point name "sqlite3_extension_init" was not found, then + ** construct an entry point name "sqlite3_X_init" where the X is + ** replaced by the lowercase value of every ASCII alphabetic + ** character in the filename after the last "/" up to the first ".", + ** and skipping the first three characters if they are "lib". + ** Examples: + ** + ** /usr/local/lib/libExample5.4.3.so ==> sqlite3_example_init + ** C:/lib/mathfuncs.dll ==> sqlite3_mathfuncs_init + ** + ** If that still finds no entry point, repeat a second time but this + ** time include both alphabetic and numeric characters up to the first + ** ".". Example: + ** + ** /usr/local/lib/libExample5.4.3.so ==> sqlite3_example5_init + */ + if xInit == uintptr(0) && zProc == uintptr(0) { + ncFile = _sqlite3Strlen30(tls, zFile) + cnt = 0 + zAltEntry = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(ncFile+int32(30))) + if zAltEntry == uintptr(0) { + _sqlite3OsDlClose(tls, pVfs, handle) + return int32(SQLITE_NOMEM) + } + for { + libc.Xmemcpy(tls, zAltEntry, __ccgo_ts+17610, uint64(8)) + iFile = ncFile - int32(1) + for { + if !(iFile >= 0 && !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zFile + uintptr(iFile)))) == libc.Int32FromUint8('/'))) { + break + } + goto _6 + _6: + ; + iFile = iFile - 1 + } + iFile = iFile + 1 + if Xsqlite3_strnicmp(tls, zFile+uintptr(iFile), __ccgo_ts+17619, int32(3)) == 0 { + iFile = iFile + int32(3) + } + iEntry = int32(8) + for { + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(zFile + uintptr(iFile)))) + c = v3 + if !(v3 != 0 && c != int32('.')) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt32(c)])&int32(0x02) != 0 || cnt != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt32(c)])&int32(0x04) != 0 { + v8 = iEntry + iEntry = iEntry + 1 + **(**uint8)(__ccgo_up(zAltEntry + uintptr(v8))) = _sqlite3UpperToLower[libc.Uint32FromInt32(c)] + } + goto _7 + _7: + ; + iFile = iFile + 1 + } + libc.Xmemcpy(tls, zAltEntry+uintptr(iEntry), __ccgo_ts+17623, uint64(6)) + zEntry = zAltEntry + xInit = _sqlite3OsDlSym(tls, pVfs, handle, zEntry) + goto _5 + _5: + ; + if v4 = xInit == uintptr(0); v4 { + cnt = cnt + 1 + v3 = cnt + } + if !(v4 && v3 < int32(2)) { + break + } + } + } + if xInit == uintptr(0) { + if pzErrMsg != 0 { + nMsg = nMsg + uint64(libc.Xstrlen(tls, zEntry)+uint64(300)) + v1 = Xsqlite3_malloc64(tls, nMsg) + **(**uintptr)(__ccgo_up(bp)) = v1 + **(**uintptr)(__ccgo_up(pzErrMsg)) = v1 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + /* zErrmsg would be NULL if not so */ + Xsqlite3_snprintf(tls, libc.Int32FromUint64(nMsg), **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+17629, libc.VaList(bp+16, zEntry, zFile)) + _sqlite3OsDlError(tls, pVfs, libc.Int32FromUint64(nMsg-uint64(1)), **(**uintptr)(__ccgo_up(bp))) + } + } + _sqlite3OsDlClose(tls, pVfs, handle) + Xsqlite3_free(tls, zAltEntry) + return int32(SQLITE_ERROR) + } + Xsqlite3_free(tls, zAltEntry) + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xInit})))(tls, db, bp, uintptr(unsafe.Pointer(&_sqlite3Apis))) + if rc != 0 { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(1)<aExtension array. */ + aHandle = _sqlite3DbMallocZero(tls, db, uint64(uint64(8)*libc.Uint64FromInt32((*Tsqlite3)(unsafe.Pointer(db)).FnExtension+libc.Int32FromInt32(1)))) + if aHandle == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FnExtension > 0 { + libc.Xmemcpy(tls, aHandle, (*Tsqlite3)(unsafe.Pointer(db)).FaExtension, uint64(8)*libc.Uint64FromInt32((*Tsqlite3)(unsafe.Pointer(db)).FnExtension)) + } + _sqlite3DbFree(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaExtension) + (*Tsqlite3)(unsafe.Pointer(db)).FaExtension = aHandle + v1 = db + 236 + v3 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaExtension + uintptr(v3)*8)) = handle + return SQLITE_OK + goto extension_not_found +extension_not_found: + ; + if pzErrMsg != 0 { + nMsg = nMsg + uint64(300) + v1 = Xsqlite3_malloc64(tls, nMsg) + **(**uintptr)(__ccgo_up(bp)) = v1 + **(**uintptr)(__ccgo_up(pzErrMsg)) = v1 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + /* zErrmsg would be NULL if not so */ + Xsqlite3_snprintf(tls, libc.Int32FromUint64(nMsg), **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+17704, libc.VaList(bp+16, int32(FILENAME_MAX), zFile)) + _sqlite3OsDlError(tls, pVfs, libc.Int32FromUint64(nMsg-uint64(1)), **(**uintptr)(__ccgo_up(bp))) + } + } + return int32(SQLITE_ERROR) +} + +// C documentation +// +// /* +// ** Allocate and initialize a new Pager object and put a pointer to it +// ** in *ppPager. The pager should eventually be freed by passing it +// ** to sqlite3PagerClose(). +// ** +// ** The zFilename argument is the path to the database file to open. +// ** If zFilename is NULL then a randomly-named temporary file is created +// ** and used as the file to be cached. Temporary files are be deleted +// ** automatically when they are closed. If zFilename is ":memory:" then +// ** all information is held in cache. It is never written to disk. +// ** This can be used to implement an in-memory database. +// ** +// ** The nExtra parameter specifies the number of bytes of space allocated +// ** along with each page reference. This space is available to the user +// ** via the sqlite3PagerGetExtra() API. When a new page is allocated, the +// ** first 8 bytes of this space are zeroed but the remainder is uninitialized. +// ** (The extra space is used by btree as the MemPage object.) +// ** +// ** The flags argument is used to specify properties that affect the +// ** operation of the pager. It should be passed some bitwise combination +// ** of the PAGER_* flags. +// ** +// ** The vfsFlags parameter is a bitmask to pass to the flags parameter +// ** of the xOpen() method of the supplied VFS when opening files. +// ** +// ** If the pager object is allocated and the specified file opened +// ** successfully, SQLITE_OK is returned and *ppPager set to point to +// ** the new pager object. If an error occurs, *ppPager is set to NULL +// ** and error code returned. This function may return SQLITE_NOMEM +// ** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or +// ** various SQLITE_IO_XXX errors. +// */ +func _sqlite3PagerOpen(tls *libc.TLS, pVfs uintptr, ppPager uintptr, zFilename uintptr, nExtra int32, flags int32, vfsFlags int32, __ccgo_fp_xReinit uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDc, journalFileSize, memDb, memJM, nPathname, nUriByte, pcacheSize, rc, readOnly, tempFile, useJournal, v4 int32 + var pPtr, z, zPathname, zUri, v1 uintptr + var _ /* fout at bp+12 */ int32 + var _ /* pPager at bp+0 */ uintptr + var _ /* szPageDflt at bp+8 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iDc, journalFileSize, memDb, memJM, nPathname, nUriByte, pPtr, pcacheSize, rc, readOnly, tempFile, useJournal, z, zPathname, zUri, v1, v4 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Pager object to allocate and return */ + rc = SQLITE_OK /* Return code */ + tempFile = 0 /* True for temp files (incl. in-memory files) */ + memDb = 0 /* True if this is an in-memory file */ + memJM = 0 /* Memory journal mode */ + readOnly = 0 /* Bytes to allocate for each journal fd */ + zPathname = uintptr(0) /* Full path to database file */ + nPathname = 0 /* Number of bytes in zPathname */ + useJournal = libc.BoolInt32(flags&int32(PAGER_OMIT_JOURNAL) == 0) /* False to omit journal */ + pcacheSize = _sqlite3PcacheSize(tls) /* Bytes to allocate for PCache */ + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(SQLITE_DEFAULT_PAGE_SIZE) /* Default page size */ + zUri = uintptr(0) /* URI args to copy */ + nUriByte = int32(1) /* Number of bytes of URI args at *zUri */ + /* Figure out how much space is required for each journal file-handle + ** (there are two of them, the main journal and the sub-journal). */ + journalFileSize = (_sqlite3JournalSize(tls, pVfs) + int32(7)) & ^libc.Int32FromInt32(7) + /* Set the output variable to NULL in case an error occurs. */ + **(**uintptr)(__ccgo_up(ppPager)) = uintptr(0) + if flags&int32(PAGER_MEMORY) != 0 { + memDb = int32(1) + if zFilename != 0 && **(**uint8)(__ccgo_up(zFilename)) != 0 { + zPathname = _sqlite3DbStrDup(tls, uintptr(0), zFilename) + if zPathname == uintptr(0) { + return int32(SQLITE_NOMEM) + } + nPathname = _sqlite3Strlen30(tls, zPathname) + zFilename = uintptr(0) + } + } + /* Compute and store the full pathname in an allocated buffer pointed + ** to by zPathname, length nPathname. Or, if this is a temporary file, + ** leave both nPathname and zPathname set to 0. + */ + if zFilename != 0 && **(**uint8)(__ccgo_up(zFilename)) != 0 { + nPathname = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname + int32(1) + zPathname = _sqlite3DbMallocRaw(tls, uintptr(0), libc.Uint64FromInt64(int64(2)*int64(nPathname))) + if zPathname == uintptr(0) { + return int32(SQLITE_NOMEM) + } + **(**uint8)(__ccgo_up(zPathname)) = uint8(0) /* Make sure initialized even if FullPathname() fails */ + rc = _sqlite3OsFullPathname(tls, pVfs, zFilename, nPathname, zPathname) + if rc != SQLITE_OK { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(2)< (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname { + /* This branch is taken when the journal path required by + ** the database being opened will be more than pVfs->mxPathname + ** bytes in length. This means the database cannot be opened, + ** as it will not be possible to open the journal file or even + ** check for a hot-journal before reading. + */ + rc = _sqlite3CantopenError(tls, int32(64423)) + } + if rc != SQLITE_OK { + _sqlite3DbFree(tls, uintptr(0), zPathname) + return rc + } + } + /* Allocate memory for the Pager structure, PCache object, the + ** three file descriptors, the database file name and the journal + ** file name. The layout in memory is as follows: + ** + ** Pager object (sizeof(Pager) bytes) + ** PCache object (sqlite3PcacheSize() bytes) + ** Database file handle (pVfs->szOsFile bytes) + ** Sub-journal file handle (journalFileSize bytes) + ** Main journal file handle (journalFileSize bytes) + ** Ptr back to the Pager (sizeof(Pager*) bytes) + ** \0\0\0\0 database prefix (4 bytes) + ** Database file name (nPathname+1 bytes) + ** URI query parameters (nUriByte bytes) + ** Journal filename (nPathname+8+1 bytes) + ** WAL filename (nPathname+4+1 bytes) + ** \0\0\0 terminator (3 bytes) + ** + ** Some 3rd-party software, over which we have no control, depends on + ** the specific order of the filenames and the \0 separators between them + ** so that it can (for example) find the database filename given the WAL + ** filename without using the sqlite3_filename_database() API. This is a + ** misuse of SQLite and a bug in the 3rd-party software, but the 3rd-party + ** software is in widespread use, so we try to avoid changing the filename + ** order and formatting if possible. In particular, the details of the + ** filename format expected by 3rd-party software should be as follows: + ** + ** - Main Database Path + ** - \0 + ** - Multiple URI components consisting of: + ** - Key + ** - \0 + ** - Value + ** - \0 + ** - \0 + ** - Journal Path + ** - \0 + ** - WAL Path (zWALName) + ** - \0 + ** + ** The sqlite3_create_filename() interface and the databaseFilename() utility + ** that is used by sqlite3_filename_database() and kin also depend on the + ** specific formatting and order of the various filenames, so if the format + ** changes here, be sure to change it there as well. + */ + pPtr = _sqlite3MallocZero(tls, uint64((libc.Uint64FromInt64(312)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32((pcacheSize+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7))+libc.Uint64FromInt32(((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)))+libc.Uint64FromInt32(journalFileSize)*uint64(2)+uint64(__SIZEOF_POINTER__)+uint64(4)+libc.Uint64FromInt32(nPathname)+uint64(1)+libc.Uint64FromInt32(nUriByte)+libc.Uint64FromInt32(nPathname)+uint64(8)+uint64(1)+libc.Uint64FromInt32(nPathname)+uint64(4)+uint64(1)+uint64(3)) + if !(pPtr != 0) { + _sqlite3DbFree(tls, uintptr(0), zPathname) + return int32(SQLITE_NOMEM) + } + **(**uintptr)(__ccgo_up(bp)) = pPtr + pPtr = pPtr + uintptr((libc.Uint64FromInt64(312)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpPCache = pPtr + pPtr = pPtr + uintptr((pcacheSize+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd = pPtr + pPtr = pPtr + uintptr(((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fsjfd = pPtr + pPtr = pPtr + uintptr(journalFileSize) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fjfd = pPtr + pPtr = pPtr + uintptr(journalFileSize) + libc.Xmemcpy(tls, pPtr, bp, uint64(__SIZEOF_POINTER__)) + pPtr = pPtr + uintptr(__SIZEOF_POINTER__) + /* Fill in the Pager.zFilename and pPager.zQueryParam fields */ + pPtr = pPtr + uintptr(4) /* Skip zero prefix */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename = pPtr + if nPathname > 0 { + libc.Xmemcpy(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname)) + pPtr = pPtr + uintptr(nPathname+int32(1)) + if zUri != 0 { + libc.Xmemcpy(tls, pPtr, zUri, libc.Uint64FromInt32(nUriByte)) + pPtr = pPtr + uintptr(nUriByte) + } else { + pPtr = pPtr + 1 + } + } + /* Fill in Pager.zJournal */ + if nPathname > 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzJournal = pPtr + libc.Xmemcpy(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname)) + pPtr = pPtr + uintptr(nPathname) + libc.Xmemcpy(tls, pPtr, __ccgo_ts+4227, uint64(8)) + pPtr = pPtr + uintptr(libc.Int32FromInt32(8)+libc.Int32FromInt32(1)) + } else { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzJournal = uintptr(0) + } + /* Fill in Pager.zWal */ + if nPathname > 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzWal = pPtr + libc.Xmemcpy(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname)) + pPtr = pPtr + uintptr(nPathname) + libc.Xmemcpy(tls, pPtr, __ccgo_ts+4236, uint64(4)) + pPtr = pPtr + uintptr(libc.Int32FromInt32(4)+libc.Int32FromInt32(1)) + } else { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzWal = uintptr(0) + } + _ = pPtr /* Suppress warning about unused pPtr value */ + if nPathname != 0 { + _sqlite3DbFree(tls, uintptr(0), zPathname) + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpVfs = pVfs + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FvfsFlags = libc.Uint32FromInt32(vfsFlags) + /* Open the pager file. + */ + if !(zFilename != 0 && **(**uint8)(__ccgo_up(zFilename)) != 0) { + goto _2 + } + **(**int32)(__ccgo_up(bp + 12)) = 0 /* VFS flags returned by xOpen() */ + rc = _sqlite3OsOpen(tls, pVfs, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd, vfsFlags, bp+12) + v4 = libc.BoolInt32(**(**int32)(__ccgo_up(bp + 12))&libc.Int32FromInt32(SQLITE_OPEN_MEMORY) != libc.Int32FromInt32(0)) + memJM = v4 + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmemVfs = libc.Uint8FromInt32(v4) + readOnly = libc.BoolInt32(**(**int32)(__ccgo_up(bp + 12))&int32(SQLITE_OPEN_READONLY) != 0) + /* If the file was successfully opened for read/write access, + ** choose a default page size in case we have to create the + ** database file. The default page size is the maximum of: + ** + ** + SQLITE_DEFAULT_PAGE_SIZE, + ** + The value returned by sqlite3OsSectorSize() + ** + The largest page size that can be written atomically. + */ + if rc == SQLITE_OK { + iDc = _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd) + if !(readOnly != 0) { + _setSectorSize(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**Tu32)(__ccgo_up(bp + 8)) < (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize { + if (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize > uint32(SQLITE_MAX_DEFAULT_PAGE_SIZE) { + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(SQLITE_MAX_DEFAULT_PAGE_SIZE) + } else { + **(**Tu32)(__ccgo_up(bp + 8)) = (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize + } + } + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnoLock = libc.Uint8FromInt32(Xsqlite3_uri_boolean(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, __ccgo_ts+4241, 0)) + if iDc&int32(SQLITE_IOCAP_IMMUTABLE) != 0 || Xsqlite3_uri_boolean(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, __ccgo_ts+4248, 0) != 0 { + vfsFlags = vfsFlags | int32(SQLITE_OPEN_READONLY) + goto act_like_temp_file + } + } + goto _3 +_2: + ; + /* If a temporary file is requested, it is not opened immediately. + ** In this case we accept the default page size and delay actually + ** opening the file until the first call to OsWrite(). + ** + ** This branch is also run for an in-memory database. An in-memory + ** database is the same as a temp-file that is never written out to + ** disk and uses an in-memory rollback journal. + ** + ** This branch also runs for files marked as immutable. + */ + goto act_like_temp_file +act_like_temp_file: + ; + tempFile = int32(1) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FeState = uint8(PAGER_READER) /* Pretend we already have a lock */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FeLock = uint8(EXCLUSIVE_LOCK) /* Pretend we are in EXCLUSIVE mode */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnoLock = uint8(1) /* Do no locking */ + readOnly = vfsFlags & int32(SQLITE_OPEN_READONLY) +_3: + ; + /* The following call to PagerSetPagesize() serves to set the value of + ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer. + */ + if rc == SQLITE_OK { + rc = _sqlite3PagerSetPagesize(tls, **(**uintptr)(__ccgo_up(bp)), bp+8, -int32(1)) + } + /* Initialize the PCache object. */ + if rc == SQLITE_OK { + nExtra = (nExtra + int32(7)) & ^libc.Int32FromInt32(7) + if !(memDb != 0) { + v1 = __ccgo_fp(_pagerStress) + } else { + v1 = uintptr(0) + } + rc = _sqlite3PcacheOpen(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp + 8))), nExtra, libc.BoolInt32(!(memDb != 0)), v1, **(**uintptr)(__ccgo_up(bp)), (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpPCache) + } + /* If an error occurred above, free the Pager structure and close the file. + */ + if rc != SQLITE_OK { + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd) + _sqlite3PageFree(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpTmpSpace) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + return rc + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FuseJournal = libc.Uint8FromInt32(useJournal) + /* pPager->stmtOpen = 0; */ + /* pPager->stmtInUse = 0; */ + /* pPager->nRef = 0; */ + /* pPager->stmtSize = 0; */ + /* pPager->stmtJSize = 0; */ + /* pPager->nPage = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmxPgno = uint32(SQLITE_MAX_PAGE_COUNT) + /* pPager->state = PAGER_UNLOCK; */ + /* pPager->errMask = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FtempFile = libc.Uint8FromInt32(tempFile) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FexclusiveMode = libc.Uint8FromInt32(tempFile) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FchangeCountDone = (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FtempFile + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmemDb = libc.Uint8FromInt32(memDb) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FreadOnly = libc.Uint8FromInt32(readOnly) + _sqlite3PagerSetFlags(tls, **(**uintptr)(__ccgo_up(bp)), libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DEFAULT_SYNCHRONOUS)+libc.Int32FromInt32(1)|libc.Int32FromInt32(PAGER_CACHESPILL))) + /* pPager->pFirst = 0; */ + /* pPager->pFirstSynced = 0; */ + /* pPager->pLast = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExtra = libc.Uint16FromInt32(nExtra) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalSizeLimit = int64(-int32(1)) + _setSectorSize(tls, **(**uintptr)(__ccgo_up(bp))) + if !(useJournal != 0) { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalMode = uint8(PAGER_JOURNALMODE_OFF) + } else { + if memDb != 0 || memJM != 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalMode = uint8(PAGER_JOURNALMODE_MEMORY) + } + } + /* pPager->xBusyHandler = 0; */ + /* pPager->pBusyHandlerArg = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxReiniter = __ccgo_fp_xReinit + _setGetterMethod(tls, **(**uintptr)(__ccgo_up(bp))) + /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */ + /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */ + **(**uintptr)(__ccgo_up(ppPager)) = **(**uintptr)(__ccgo_up(bp)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is used to parse both URIs and non-URI filenames passed by the +// ** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database +// ** URIs specified as part of ATTACH statements. +// ** +// ** The first argument to this function is the name of the VFS to use (or +// ** a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx" +// ** query parameter. The second argument contains the URI (or non-URI filename) +// ** itself. When this function is called the *pFlags variable should contain +// ** the default flags to open the database handle with. The value stored in +// ** *pFlags may be updated before returning if the URI filename contains +// ** "cache=xxx" or "mode=xxx" query parameters. +// ** +// ** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to +// ** the VFS that should be used to open the database file. *pzFile is set to +// ** point to a buffer containing the name of the file to open. The value +// ** stored in *pzFile is a database name acceptable to sqlite3_uri_parameter() +// ** and is in the same format as names created using sqlite3_create_filename(). +// ** The caller must invoke sqlite3_free_filename() (not sqlite3_free()!) on +// ** the value returned in *pzFile to avoid a memory leak. +// ** +// ** If an error occurs, then an SQLite error code is returned and *pzErrMsg +// ** may be set to point to a buffer containing an English language error +// ** message. It is the responsibility of the caller to eventually release +// ** this buffer by calling sqlite3_free(). +// */ +func _sqlite3ParseUri(tls *libc.TLS, zDefaultVfs uintptr, zUri uintptr, pFlags uintptr, ppVfs uintptr, pzFile uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aMode, z, zFile, zModeType, zOpt, zVal, zVfs uintptr + var c, v2 uint8 + var eState, i, iIn, iOut, limit, mask, mode, nOpt, nUri, nVal, octet, rc, v3, v4 int32 + var flags uint32 + var nByte Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aMode, c, eState, flags, i, iIn, iOut, limit, mask, mode, nByte, nOpt, nUri, nVal, octet, rc, z, zFile, zModeType, zOpt, zVal, zVfs, v2, v3, v4 + rc = SQLITE_OK + flags = **(**uint32)(__ccgo_up(pFlags)) + zVfs = zDefaultVfs + nUri = _sqlite3Strlen30(tls, zUri) + if (flags&uint32(SQLITE_OPEN_URI) != 0 || libc.AtomicLoadNUint8(uintptr(unsafe.Pointer(&_sqlite3Config))+6, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0) && nUri >= int32(5) && libc.Xmemcmp(tls, zUri, __ccgo_ts+26049, uint64(5)) == 0 { /* Input character index */ + iOut = 0 /* Output character index */ + nByte = libc.Uint64FromInt32(nUri + int32(8)) /* Bytes of space to allocate */ + /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen + ** method that there may be extra parameters following the file-name. */ + flags = flags | uint32(SQLITE_OPEN_URI) + iIn = 0 + for { + if !(iIn < nUri) { + break + } + nByte = nByte + libc.BoolUint64(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zUri + uintptr(iIn)))) == libc.Int32FromUint8('&')) + goto _1 + _1: + ; + iIn = iIn + 1 + } + zFile = Xsqlite3_malloc64(tls, nByte) + if !(zFile != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, zFile, 0, uint64(4)) /* 4-byte of 0x00 is the start of DB name marker */ + zFile = zFile + uintptr(4) + iIn = int32(5) + /* Discard the scheme and authority segments of the URI. */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zUri + 5))) == int32('/') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zUri + 6))) == int32('/') { + iIn = int32(7) + for **(**uint8)(__ccgo_up(zUri + uintptr(iIn))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zUri + uintptr(iIn)))) != int32('/') { + iIn = iIn + 1 + } + if iIn != int32(7) && (iIn != int32(16) || libc.Xmemcmp(tls, __ccgo_ts+26055, zUri+7, uint64(9)) != 0) { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26065, libc.VaList(bp+8, iIn-int32(7), zUri+7)) + rc = int32(SQLITE_ERROR) + goto parse_uri_out + } + } + /* Copy the filename and any query parameters into the zFile buffer. + ** Decode %HH escape codes along the way. + ** + ** Within this loop, variable eState may be set to 0, 1 or 2, depending + ** on the parsing context. As follows: + ** + ** 0: Parsing file-name. + ** 1: Parsing name section of a name=value query parameter. + ** 2: Parsing value section of a name=value query parameter. + */ + eState = 0 + for { + v2 = **(**uint8)(__ccgo_up(zUri + uintptr(iIn))) + c = v2 + if !(libc.Int32FromUint8(v2) != 0 && libc.Int32FromUint8(c) != int32('#')) { + break + } + iIn = iIn + 1 + if libc.Int32FromUint8(c) == int32('%') && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zUri + uintptr(iIn))))])&int32(0x08) != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zUri + uintptr(iIn+int32(1)))))])&int32(0x08) != 0 { + v3 = iIn + iIn = iIn + 1 + octet = libc.Int32FromUint8(_sqlite3HexToInt(tls, libc.Int32FromUint8(**(**uint8)(__ccgo_up(zUri + uintptr(v3)))))) << int32(4) + v4 = iIn + iIn = iIn + 1 + octet = octet + libc.Int32FromUint8(_sqlite3HexToInt(tls, libc.Int32FromUint8(**(**uint8)(__ccgo_up(zUri + uintptr(v4)))))) + if octet == 0 { + /* This branch is taken when "%00" appears within the URI. In this + ** case we ignore all text in the remainder of the path, name or + ** value currently being parsed. So ignore the current character + ** and skip to the next "?", "=" or "&", as appropriate. */ + for { + v2 = **(**uint8)(__ccgo_up(zUri + uintptr(iIn))) + c = v2 + if !(libc.Int32FromUint8(v2) != 0 && libc.Int32FromUint8(c) != int32('#') && (eState != 0 || libc.Int32FromUint8(c) != int32('?')) && (eState != int32(1) || libc.Int32FromUint8(c) != int32('=') && libc.Int32FromUint8(c) != int32('&')) && (eState != int32(2) || libc.Int32FromUint8(c) != int32('&'))) { + break + } + iIn = iIn + 1 + } + continue + } + c = libc.Uint8FromInt32(octet) + } else { + if eState == int32(1) && (libc.Int32FromUint8(c) == int32('&') || libc.Int32FromUint8(c) == int32('=')) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zFile + uintptr(iOut-int32(1))))) == 0 { + /* An empty option name. Ignore this option altogether. */ + for **(**uint8)(__ccgo_up(zUri + uintptr(iIn))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zUri + uintptr(iIn)))) != int32('#') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zUri + uintptr(iIn-int32(1))))) != int32('&') { + iIn = iIn + 1 + } + continue + } + if libc.Int32FromUint8(c) == int32('&') { + v3 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zFile + uintptr(v3))) = uint8('\000') + } else { + eState = int32(2) + } + c = uint8(0) + } else { + if eState == 0 && libc.Int32FromUint8(c) == int32('?') || eState == int32(2) && libc.Int32FromUint8(c) == int32('&') { + c = uint8(0) + eState = int32(1) + } + } + } + v3 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zFile + uintptr(v3))) = c + } + if eState == int32(1) { + v3 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zFile + uintptr(v3))) = uint8('\000') + } + libc.Xmemset(tls, zFile+uintptr(iOut), 0, uint64(4)) /* end-of-options + empty journal filenames */ + /* Check if there were any options specified that should be interpreted + ** here. Options that are interpreted here include "vfs" and those that + ** correspond to flags that may be passed to the sqlite3_open_v2() + ** method. */ + zOpt = zFile + uintptr(_sqlite3Strlen30(tls, zFile)+int32(1)) + for **(**uint8)(__ccgo_up(zOpt)) != 0 { + nOpt = _sqlite3Strlen30(tls, zOpt) + zVal = zOpt + uintptr(nOpt+int32(1)) + nVal = _sqlite3Strlen30(tls, zVal) + if nOpt == int32(3) && libc.Xmemcmp(tls, __ccgo_ts+26093, zOpt, uint64(3)) == 0 { + zVfs = zVal + } else { + aMode = uintptr(0) + zModeType = uintptr(0) + mask = 0 + limit = 0 + if nOpt == int32(5) && libc.Xmemcmp(tls, __ccgo_ts+26097, zOpt, uint64(5)) == 0 { + mask = libc.Int32FromInt32(SQLITE_OPEN_SHAREDCACHE) | libc.Int32FromInt32(SQLITE_OPEN_PRIVATECACHE) + aMode = uintptr(unsafe.Pointer(&_aCacheMode)) + limit = mask + zModeType = __ccgo_ts + 26097 + } + if nOpt == int32(4) && libc.Xmemcmp(tls, __ccgo_ts+26118, zOpt, uint64(4)) == 0 { + mask = libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_MEMORY) + aMode = uintptr(unsafe.Pointer(&_aOpenMode)) + limit = libc.Int32FromUint32(libc.Uint32FromInt32(mask) & flags) + zModeType = __ccgo_ts + 3553 + } + if aMode != 0 { + mode = 0 + i = 0 + for { + if !((**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fz != 0) { + break + } + z = (**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fz + if nVal == _sqlite3Strlen30(tls, z) && 0 == libc.Xmemcmp(tls, zVal, z, libc.Uint64FromInt32(nVal)) { + mode = (**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fmode + break + } + goto _9 + _9: + ; + i = i + 1 + } + if mode == 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26133, libc.VaList(bp+8, zModeType, zVal)) + rc = int32(SQLITE_ERROR) + goto parse_uri_out + } + if mode & ^libc.Int32FromInt32(SQLITE_OPEN_MEMORY) > limit { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26153, libc.VaList(bp+8, zModeType, zVal)) + rc = int32(SQLITE_PERM) + goto parse_uri_out + } + flags = flags&libc.Uint32FromInt32(^mask) | libc.Uint32FromInt32(mode) + } + } + zOpt = zVal + uintptr(nVal+int32(1)) + } + } else { + zFile = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nUri+int32(8))) + if !(zFile != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, zFile, 0, uint64(4)) + zFile = zFile + uintptr(4) + if nUri != 0 { + libc.Xmemcpy(tls, zFile, zUri, libc.Uint64FromInt32(nUri)) + } + libc.Xmemset(tls, zFile+uintptr(nUri), 0, uint64(4)) + flags = flags & libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_OPEN_URI)) + } + **(**uintptr)(__ccgo_up(ppVfs)) = Xsqlite3_vfs_find(tls, zVfs) + if **(**uintptr)(__ccgo_up(ppVfs)) == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26177, libc.VaList(bp+8, zVfs)) + rc = int32(SQLITE_ERROR) + } + goto parse_uri_out +parse_uri_out: + ; + if rc != SQLITE_OK { + Xsqlite3_free_filename(tls, zFile) + zFile = uintptr(0) + } + **(**uint32)(__ccgo_up(pFlags)) = flags + **(**uintptr)(__ccgo_up(pzFile)) = zFile + return rc +} + +// C documentation +// +// /* +// ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. +// */ +func _sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags Tu32, pReprepare uintptr, ppStmt uintptr, pzTail uintptr) (r int32) { + bp := tls.Alloc(432) + defer tls.Free(432) + var i, mxLen, rc, v1 int32 + var pBt, pT, zDb, zSqlCopy uintptr + var _ /* sParse at bp+0 */ TParse + _, _, _, _, _, _, _, _ = i, mxLen, pBt, pT, rc, zDb, zSqlCopy, v1 + rc = SQLITE_OK /* Parsing context */ + /* sqlite3ParseObjectInit(&sParse, db); // inlined for performance */ + libc.Xmemset(tls, bp+uintptr(uint64(libc.UintptrFromInt32(0)+8)), 0, uint64(libc.UintptrFromInt32(0)+184)-uint64(libc.UintptrFromInt32(0)+8)) + libc.Xmemset(tls, bp+uintptr(uint64(libc.UintptrFromInt32(0)+280)), 0, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + (**(**TParse)(__ccgo_up(bp))).FpOuterParse = (*Tsqlite3)(unsafe.Pointer(db)).FpParse + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = bp + (**(**TParse)(__ccgo_up(bp))).Fdb = db + if pReprepare != 0 { + (**(**TParse)(__ccgo_up(bp))).FpReprepare = pReprepare + (**(**TParse)(__ccgo_up(bp))).Fexplain = libc.Uint8FromInt32(Xsqlite3_stmt_isexplain(tls, pReprepare)) + } else { + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ErrorMsg(tls, bp, __ccgo_ts+1674, 0) + v1 = libc.Int32FromInt32(SQLITE_NOMEM) + rc = v1 + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = v1 + goto end_prepare + } + /* For a long-term use prepared statement avoid the use of + ** lookaside memory. + */ + if prepFlags&uint32(SQLITE_PREPARE_PERSISTENT) != 0 { + (**(**TParse)(__ccgo_up(bp))).FdisableLookaside = (**(**TParse)(__ccgo_up(bp))).FdisableLookaside + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + } + (**(**TParse)(__ccgo_up(bp))).FprepFlags = uint8(prepFlags & uint32(0xff)) + /* Check to verify that it is possible to get a read lock on all + ** database schemas. The inability to get a read lock indicates that + ** some other database connection is holding a write-lock, which in + ** turn means that the other connection has made uncommitted changes + ** to the schema. + ** + ** Were we to proceed and prepare the statement against the uncommitted + ** schema changes and if those schema changes are subsequently rolled + ** back and different changes are made in their place, then when this + ** prepared statement goes to run the schema cookie would fail to detect + ** the schema change. Disaster would follow. + ** + ** This thread is currently holding mutexes on all Btrees (because + ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it + ** is not possible for another thread to start a new schema change + ** while this routine is running. Hence, we do not need to hold + ** locks on the schema, we just need to make sure nobody else is + ** holding them. + ** + ** Note that setting READ_UNCOMMITTED overrides most lock detection, + ** but it does *not* override schema lock detection, so this all still + ** works even if READ_UNCOMMITTED is set. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FnoSharedCache != 0) { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 { + rc = _sqlite3BtreeSchemaLocked(tls, pBt) + if rc != 0 { + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName + _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+20235, libc.VaList(bp+424, zDb)) + goto end_prepare + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FpDisconnect != 0 { + _sqlite3VtabUnlockList(tls, db) + } + if nBytes >= 0 && (nBytes == 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(nBytes-int32(1))))) != 0) { + mxLen = **(**int32)(__ccgo_up(db + 136 + 1*4)) + if nBytes > mxLen { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_TOOBIG), __ccgo_ts+20265, 0) + rc = _sqlite3ApiExit(tls, db, int32(SQLITE_TOOBIG)) + goto end_prepare + } + zSqlCopy = _sqlite3DbStrNDup(tls, db, zSql, libc.Uint64FromInt32(nBytes)) + if zSqlCopy != 0 { + _sqlite3RunParser(tls, bp, zSqlCopy) + (**(**TParse)(__ccgo_up(bp))).FzTail = zSql + uintptr(int64((**(**TParse)(__ccgo_up(bp))).FzTail)-int64(zSqlCopy)) + _sqlite3DbFree(tls, db, zSqlCopy) + } else { + (**(**TParse)(__ccgo_up(bp))).FzTail = zSql + uintptr(nBytes) + } + } else { + _sqlite3RunParser(tls, bp, zSql) + } + if pzTail != 0 { + **(**uintptr)(__ccgo_up(pzTail)) = (**(**TParse)(__ccgo_up(bp))).FzTail + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { + _sqlite3VdbeSetSql(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe, zSql, int32(int64((**(**TParse)(__ccgo_up(bp))).FzTail)-int64(zSql)), uint8(prepFlags)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (**(**TParse)(__ccgo_up(bp))).Frc = int32(SQLITE_NOMEM) + libc.SetBitFieldPtr16Uint32(bp+40, libc.Uint32FromInt32(0), 8, 0x100) + } + if (**(**TParse)(__ccgo_up(bp))).Frc != SQLITE_OK && (**(**TParse)(__ccgo_up(bp))).Frc != int32(SQLITE_DONE) { + if int32(Tbft(*(*uint16)(unsafe.Pointer(bp + 40))&0x100>>8)) != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { + _schemaIsValid(tls, bp) + } + if (**(**TParse)(__ccgo_up(bp))).FpVdbe != 0 { + _sqlite3VdbeFinalize(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe) + } + rc = (**(**TParse)(__ccgo_up(bp))).Frc + if (**(**TParse)(__ccgo_up(bp))).FzErrMsg != 0 { + _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+3944, libc.VaList(bp+424, (**(**TParse)(__ccgo_up(bp))).FzErrMsg)) + _sqlite3DbFree(tls, db, (**(**TParse)(__ccgo_up(bp))).FzErrMsg) + } else { + _sqlite3Error(tls, db, rc) + } + } else { + **(**uintptr)(__ccgo_up(ppStmt)) = (**(**TParse)(__ccgo_up(bp))).FpVdbe + rc = SQLITE_OK + _sqlite3ErrorClear(tls, db) + } + /* Delete any TriggerPrg structures allocated while parsing this statement. */ + for (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg != 0 { + pT = (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg + (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg = (*TTriggerPrg)(unsafe.Pointer(pT)).FpNext + _sqlite3DbFree(tls, db, pT) + } + goto end_prepare +end_prepare: + ; + _sqlite3ParseObjectReset(tls, bp) + return rc +} + +// C documentation +// +// /* +// ** This routine processes the join information for a SELECT statement. +// ** +// ** * A NATURAL join is converted into a USING join. After that, we +// ** do not need to be concerned with NATURAL joins and we only have +// ** think about USING joins. +// ** +// ** * ON and USING clauses result in extra terms being added to the +// ** WHERE clause to enforce the specified constraints. The extra +// ** WHERE clause terms will be tagged with EP_OuterON or +// ** EP_InnerON so that we know that they originated in ON/USING. +// ** +// ** The terms of a FROM clause are contained in the Select.pSrc structure. +// ** The left most table is the first entry in Select.pSrc. The right-most +// ** table is the last entry. The join operator is held in the entry to +// ** the right. Thus entry 1 contains the join operator for the join between +// ** entries 0 and 1. Any ON or USING clauses associated with the join are +// ** also attached to the right entry. +// ** +// ** This routine returns the number of errors encountered. +// */ +func _sqlite3ProcessJoin(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pE1, pE2, pEq, pFuncArgs, pLeft, pList, pRight, pRightTab, pSrc, pUsing, zName, zName1 uintptr + var i, iRightCol, j, v2 int32 + var joinType Tu32 + var _ /* iLeft at bp+0 */ int32 + var _ /* iLeftCol at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iRightCol, j, joinType, pE1, pE2, pEq, pFuncArgs, pLeft, pList, pRight, pRightTab, pSrc, pUsing, zName, zName1, v2 /* Right table being joined */ + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + pLeft = pSrc + 8 + pRight = pLeft + 1*80 + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc-int32(1)) { + break + } + pRightTab = (*TSrcItem)(unsafe.Pointer(pRight)).FpSTab + if (*TSrcItem)(unsafe.Pointer(pLeft)).FpSTab == uintptr(0) || pRightTab == uintptr(0) { + goto _1 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&int32(JT_OUTER) != 0 { + v2 = int32(EP_OuterON) + } else { + v2 = int32(EP_InnerON) + } + joinType = libc.Uint32FromInt32(v2) + /* If this is a NATURAL join, synthesize an appropriate USING clause + ** to specify which columns should be joined. + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&int32(JT_NATURAL) != 0 { + pUsing = uintptr(0) + if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x800>>11) != 0 || *(*uintptr)(unsafe.Pointer(pRight + 64)) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20314, libc.VaList(bp+16, 0)) + return int32(1) + } + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(pRightTab)).FnCol)) { + break + } /* Name of column in the right table */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer((*TTable)(unsafe.Pointer(pRightTab)).FaCol+uintptr(j)*16)).FcolFlags)&int32(COLFLAG_HIDDEN) != 0 { + goto _3 + } + zName = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*16))).FzCnName + if _tableAndColumnIndex(tls, pSrc, 0, i, zName, uintptr(0), uintptr(0), int32(1)) != 0 { + pUsing = _sqlite3IdListAppend(tls, pParse, pUsing, uintptr(0)) + if pUsing != 0 { + (*(*TIdList_item)(unsafe.Pointer(pUsing + 8 + uintptr((*TIdList)(unsafe.Pointer(pUsing)).FnId-int32(1))*8))).FzName = _sqlite3DbStrDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zName) + } + } + goto _3 + _3: + ; + j = j + 1 + } + if pUsing != 0 { + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 11, 0x800) + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 13, 0x2000) + *(*uintptr)(unsafe.Pointer(pRight + 64)) = pUsing + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(1) + } + } + /* Create extra terms on the WHERE clause for each column named + ** in the USING clause. Example: If the two tables to be joined are + ** A and B and the USING clause names X, Y, and Z, then add this + ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z + ** Report an error if any column mentioned in the USING clause is + ** not contained in both tables to be joined. + */ + if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x800>>11) != 0 { + pList = *(*uintptr)(unsafe.Pointer(pRight + 64)) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + j = 0 + for { + if !(j < (*TIdList)(unsafe.Pointer(pList)).FnId) { + break + } /* Equality constraint. pE1 == pE2 */ + zName1 = (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(j)*8))).FzName + iRightCol = _sqlite3ColumnIndex(tls, pRightTab, zName1) + if iRightCol < 0 || _tableAndColumnIndex(tls, pSrc, 0, i, zName1, bp, bp+4, int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x2000>>13)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20364, libc.VaList(bp+16, zName1)) + return int32(1) + } + pE1 = _sqlite3CreateColumnExpr(tls, db, pSrc, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4))) + _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(**(**int32)(__ccgo_up(bp)))*80, **(**int32)(__ccgo_up(bp + 4))) + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + /* This branch runs if the query contains one or more RIGHT or FULL + ** JOINs. If only a single table on the left side of this join + ** contains the zName column, then this branch is a no-op. + ** But if there are two or more tables on the left side + ** of the join, construct a coalesce() function that gathers all + ** such tables. Raise an error if more than one of those references + ** to zName is not also within a prior USING clause. + ** + ** We really ought to raise an error if there are two or more + ** non-USING references to zName on the left of an INNER or LEFT + ** JOIN. But older versions of SQLite do not do that, so we avoid + ** adding a new error so as to not break legacy applications. + */ + pFuncArgs = uintptr(0) /* Arguments to the coalesce() */ + **(**Tu32)(__ccgo_up(pE1 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + for _tableAndColumnIndex(tls, pSrc, **(**int32)(__ccgo_up(bp))+int32(1), i, zName1, bp, bp+4, int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x2000>>13)) != 0 { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(**(**int32)(__ccgo_up(bp)))*80 + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(**(**int32)(__ccgo_up(bp)))*80 + 64)), zName1) < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20428, libc.VaList(bp+16, zName1)) + break + } + pFuncArgs = _sqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1) + pE1 = _sqlite3CreateColumnExpr(tls, db, pSrc, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4))) + _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(**(**int32)(__ccgo_up(bp)))*80, **(**int32)(__ccgo_up(bp + 4))) + } + if pFuncArgs != 0 { + pFuncArgs = _sqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1) + pE1 = _sqlite3ExprFunction(tls, pParse, pFuncArgs, uintptr(unsafe.Pointer(&_tkCoalesce)), 0) + if pE1 != 0 { + (*TExpr)(unsafe.Pointer(pE1)).FaffExpr = uint8(SQLITE_AFF_DEFER) + } + } + } else { + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i+int32(1))*80))).Ffg.Fjointype)&int32(JT_LEFT) != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + **(**Tu32)(__ccgo_up(pE1 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + } + pE2 = _sqlite3CreateColumnExpr(tls, db, pSrc, i+int32(1), iRightCol) + _sqlite3SrcItemColumnUsed(tls, pRight, iRightCol) + pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), pE1, pE2) + if pEq != 0 { + **(**Tu32)(__ccgo_up(pEq + 4)) |= joinType + *(*int32)(unsafe.Pointer(pEq + 52)) = (*TExpr)(unsafe.Pointer(pE2)).FiTable + } + (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWhere, pEq) + goto _4 + _4: + ; + j = j + 1 + } + } else { + if *(*uintptr)(unsafe.Pointer(pRight + 64)) != 0 { + _sqlite3SetJoinExpr(tls, *(*uintptr)(unsafe.Pointer(pRight + 64)), (*TSrcItem)(unsafe.Pointer(pRight)).FiCursor, joinType) + (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWhere, *(*uintptr)(unsafe.Pointer(pRight + 64))) + *(*uintptr)(unsafe.Pointer(pRight + 64)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 12, 0x1000) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_OnToWhere) + } + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pRightTab)).FeTabType) == int32(TABTYP_VTAB) && joinType == uint32(EP_OuterON) && *(*uintptr)(unsafe.Pointer(pRight + 48)) != 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_OnToWhere) + } + goto _1 + _1: + ; + i = i + 1 + pRight += 80 + pLeft += 80 + } + return 0 +} + +// C documentation +// +// /* +// ** Run the parser on the given SQL string. +// */ +func _sqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr) (r int32) { + bp := tls.Alloc(1280) + defer tls.Free(1280) + var db, pEngine, pParentParse uintptr + var lastTokenParsed, nErr int32 + var mxSqlLen, n Ti64 + var _ /* sEngine at bp+8 */ TyyParser + var _ /* tokenType at bp+0 */ int32 + var _ /* x at bp+1240 */ TToken + _, _, _, _, _, _, _ = db, lastTokenParsed, mxSqlLen, n, nErr, pEngine, pParentParse + nErr = 0 /* The LEMON-generated LALR(1) parser */ + n = 0 /* type of the next token */ + lastTokenParsed = -int32(1) /* type of the previous token */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Max length of an SQL string */ + pParentParse = uintptr(0) /* Space to hold the Lemon-generated Parser object */ + mxSqlLen = int64(**(**int32)(__ccgo_up(db + 136 + 1*4))) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + (*TParse)(unsafe.Pointer(pParse)).Frc = SQLITE_OK + (*TParse)(unsafe.Pointer(pParse)).FzTail = zSql + pEngine = bp + 8 + _sqlite3ParserInit(tls, pEngine, pParse) + pParentParse = (*Tsqlite3)(unsafe.Pointer(db)).FpParse + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = pParse + for int32(1) != 0 { + n = _sqlite3GetToken(tls, zSql, bp) + mxSqlLen = mxSqlLen - n + if mxSqlLen < 0 { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_TOOBIG) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + break + } + if **(**int32)(__ccgo_up(bp)) >= int32(TK_WINDOW) { + if libc.AtomicLoadNInt32(db+432, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0 { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_INTERRUPT) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + break + } + if **(**int32)(__ccgo_up(bp)) == int32(TK_SPACE) { + zSql = zSql + uintptr(n) + continue + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) == 0 { + /* Upon reaching the end of input, call the parser two more times + ** with tokens TK_SEMI and 0, in that order. */ + if lastTokenParsed == int32(TK_SEMI) { + **(**int32)(__ccgo_up(bp)) = 0 + } else { + if lastTokenParsed == 0 { + break + } else { + **(**int32)(__ccgo_up(bp)) = int32(TK_SEMI) + } + } + n = 0 + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_WINDOW) { + **(**int32)(__ccgo_up(bp)) = _analyzeWindowKeyword(tls, zSql+6) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_OVER) { + **(**int32)(__ccgo_up(bp)) = _analyzeOverKeyword(tls, zSql+4, lastTokenParsed) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_FILTER) { + **(**int32)(__ccgo_up(bp)) = _analyzeFilterKeyword(tls, zSql+6, lastTokenParsed) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_COMMENT) && ((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00040))<declareVtab flag is set, do not delete any table + ** structure built up in pParse->pNewTable. The calling code (see vtab.c) + ** will take responsibility for freeing the Table structure. + */ + _sqlite3DeleteTable(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTable) + } + if (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger != 0 && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + _sqlite3DeleteTrigger(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger) + } + if (*TParse)(unsafe.Pointer(pParse)).FpVList != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpVList) + } + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = pParentParse + return nErr +} + +/************** End of tokenize.c ********************************************/ +/************** Begin file complete.c ****************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** An tokenizer for SQL +** +** This file contains C code that implements the sqlite3_complete() API. +** This code used to be part of the tokenizer.c source file. But by +** separating it out, the code will be automatically omitted from +** static links that do not use it. + */ +/* #include "sqliteInt.h" */ + +/* +** This is defined in tokenize.c. We just have to import the definition. + */ + +/* +** Token types used by the sqlite3_complete() routine. See the header +** comments on that procedure for additional information. + */ + +// C documentation +// +// /* +// ** This routine implements the OP_Vacuum opcode of the VDBE. +// */ +func _sqlite3RunVacuum(tls *libc.TLS, pzErrMsg uintptr, db uintptr, iDb int32, pOut uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var i, isMemDb, nDb, nNew, nRes, rc, v1 int32 + var id, pDb, pMain, pTemp, zDbMain, zFilename, zOut uintptr + var pgflags, saved_mDbFlags, saved_openFlags Tu32 + var saved_flags Tu64 + var saved_mTrace Tu8 + var saved_nChange, saved_nTotalChange Ti64 + var _ /* iRandom at bp+0 */ Tu64 + var _ /* meta at bp+64 */ Tu32 + var _ /* sz at bp+56 */ Ti64 + var _ /* zDbVacuum at bp+8 */ [42]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, id, isMemDb, nDb, nNew, nRes, pDb, pMain, pTemp, pgflags, rc, saved_flags, saved_mDbFlags, saved_mTrace, saved_nChange, saved_nTotalChange, saved_openFlags, zDbMain, zFilename, zOut, v1 + rc = SQLITE_OK /* Saved trace settings */ + pDb = uintptr(0) /* Name of output file */ + pgflags = uint32(PAGER_SYNCHRONOUS_OFF) /* Name of the ATTACH-ed database used for vacuum */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+22672) + return int32(SQLITE_ERROR) /* IMP: R-12218-18073 */ + } + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive > int32(1) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+22712) + return int32(SQLITE_ERROR) /* IMP: R-15610-35227 */ + } + saved_openFlags = (*Tsqlite3)(unsafe.Pointer(db)).FopenFlags + if pOut != 0 { + if Xsqlite3_value_type(tls, pOut) != int32(SQLITE_TEXT) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+22755) + return int32(SQLITE_ERROR) + } + zOut = Xsqlite3_value_text(tls, pOut) + **(**uint32)(__ccgo_up(db + 76)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_OPEN_READONLY)) + **(**uint32)(__ccgo_up(db + 76)) |= libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE)) + } else { + zOut = __ccgo_ts + 1704 + } + /* Save the current value of the database flags so that it can be + ** restored before returning. Then set the writable-schema flag, and + ** disable CHECK and foreign key constraints. */ + saved_flags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + saved_mDbFlags = (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags + saved_nChange = (*Tsqlite3)(unsafe.Pointer(db)).FnChange + saved_nTotalChange = (*Tsqlite3)(unsafe.Pointer(db)).FnTotalChange + saved_mTrace = (*Tsqlite3)(unsafe.Pointer(db)).FmTrace + **(**Tu64)(__ccgo_up(db + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_WriteSchema)|libc.Int32FromInt32(SQLITE_IgnoreChecks)) | libc.Uint64FromInt32(libc.Int32FromInt32(0x00040))< 0) { + rc = int32(SQLITE_ERROR) + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+22804) + goto end_of_vacuum + } + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_VacuumInto) + /* For a VACUUM INTO, the pager-flags are set to the same values as + ** they are for the database being vacuumed, except that PAGER_CACHESPILL + ** is always set. */ + pgflags = uint32(uint64((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).Fsafety_level) | (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(PAGER_FLAGS_MASK)) + /* If the VACUUM INTO target file is a URI filename and if the + ** "reserve=N" query parameter is present, reset the reserve to the + ** amount specified, if the amount is within range */ + zFilename = _sqlite3BtreeGetFilename(tls, pTemp) + if zFilename != 0 { + nNew = int32(Xsqlite3_uri_int64(tls, zFilename, __ccgo_ts+22831, int64(nRes))) + if nNew >= 0 && nNew <= int32(255) { + nRes = nNew + } + } + } + _sqlite3BtreeSetCacheSize(tls, pTemp, (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema)).Fcache_size) + _sqlite3BtreeSetSpillSize(tls, pTemp, _sqlite3BtreeSetSpillSize(tls, pMain, 0)) + _sqlite3BtreeSetPagerFlags(tls, pTemp, pgflags|uint32(PAGER_CACHESPILL)) + /* Begin a transaction and take an exclusive lock on the main database + ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below, + ** to ensure that we do not try to change the page-size on a WAL database. + */ + rc = _execSql(tls, db, pzErrMsg, __ccgo_ts+16103) + if rc != SQLITE_OK { + goto end_of_vacuum + } + if pOut == uintptr(0) { + v1 = int32(2) + } else { + v1 = 0 + } + rc = _sqlite3BtreeBeginTrans(tls, pMain, v1, uintptr(0)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + /* Do not attempt to change the page size for a WAL database */ + if _sqlite3PagerGetJournalMode(tls, _sqlite3BtreePager(tls, pMain)) == int32(PAGER_JOURNALMODE_WAL) && pOut == uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize = 0 + } + if _sqlite3BtreeSetPageSize(tls, pTemp, _sqlite3BtreeGetPageSize(tls, pMain), nRes, 0) != 0 || !(isMemDb != 0) && _sqlite3BtreeSetPageSize(tls, pTemp, (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, nRes, 0) != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + goto end_of_vacuum + } + if int32((*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac) >= 0 { + v1 = int32((*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac) + } else { + v1 = _sqlite3BtreeGetAutoVacuum(tls, pMain) + } + _sqlite3BtreeSetAutoVacuum(tls, pTemp, v1) + /* Query the schema of the main database. Create a mirror schema + ** in the temporary database. + */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(nDb) /* force new CREATE statements into vacuum_db */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+22839, libc.VaList(bp+80, zDbMain)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+22947, libc.VaList(bp+80, zDbMain)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + /* Loop through the tables in the main database. For each, do + ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy + ** the contents to the temporary database. + */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+23001, libc.VaList(bp+80, bp+8, zDbMain, bp+8)) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_Vacuum)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + /* Copy the triggers, views, and virtual tables from the main database + ** over to the temporary database. None of these objects has any + ** associated storage, so all we have to do is copy their entries + ** from the schema table. + */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+23138, libc.VaList(bp+80, bp+8, zDbMain)) + if rc != 0 { + goto end_of_vacuum + } + /* Copy Btree meta values */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(10)/libc.Uint64FromInt64(1))) { + break + } + /* GetMeta() and UpdateMeta() cannot fail in this context because + ** we already have page 1 loaded into cache and marked dirty. */ + _sqlite3BtreeGetMeta(tls, pMain, libc.Int32FromUint8(_aCopy[i]), bp+64) + rc = _sqlite3BtreeUpdateMeta(tls, pTemp, libc.Int32FromUint8(_aCopy[i]), **(**Tu32)(__ccgo_up(bp + 64))+uint32(_aCopy[i+int32(1)])) + if rc != SQLITE_OK { + goto end_of_vacuum + } + goto _3 + _3: + ; + i = i + int32(2) + } + if pOut == uintptr(0) { + rc = _sqlite3BtreeCopyFile(tls, pMain, pTemp) + } + if rc != SQLITE_OK { + goto end_of_vacuum + } + rc = _sqlite3BtreeCommit(tls, pTemp) + if rc != SQLITE_OK { + goto end_of_vacuum + } + if pOut == uintptr(0) { + _sqlite3BtreeSetAutoVacuum(tls, pMain, _sqlite3BtreeGetAutoVacuum(tls, pTemp)) + } + if pOut == uintptr(0) { + nRes = _sqlite3BtreeGetRequestedReserve(tls, pTemp) + rc = _sqlite3BtreeSetPageSize(tls, pMain, _sqlite3BtreeGetPageSize(tls, pTemp), nRes, int32(1)) + } + goto end_of_vacuum +end_of_vacuum: + ; + /* Restore the original value of db->flags */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags = saved_mDbFlags + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = saved_flags + (*Tsqlite3)(unsafe.Pointer(db)).FnChange = saved_nChange + (*Tsqlite3)(unsafe.Pointer(db)).FnTotalChange = saved_nTotalChange + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = saved_mTrace + _sqlite3BtreeSetPageSize(tls, pMain, -int32(1), 0, int32(1)) + /* Currently there is an SQL level transaction open on the vacuum + ** database. No locks are held on any other files (since the main file + ** was committed at the btree level). So it safe to end the transaction + ** by manually setting the autoCommit flag to true and detaching the + ** vacuum database. The vacuum_db journal file is deleted when the pager + ** is closed by the DETACH. + */ + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(1) + if pDb != 0 { + _sqlite3BtreeClose(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + (*TDb)(unsafe.Pointer(pDb)).FpBt = uintptr(0) + (*TDb)(unsafe.Pointer(pDb)).FpSchema = uintptr(0) + } + /* This both clears the schemas and reduces the size of the db->aDb[] + ** array. */ + _sqlite3ResetAllSchemasOfConnection(tls, db) + return rc +} + +/* At this point, there is a write transaction open on both the + ** vacuum database and the main database. Assuming no error occurs, + ** both transactions are closed by this block - the main database + ** transaction by sqlite3BtreeCopyFile() and the other by an explicit + ** call to sqlite3BtreeCommit(). + */ + +// C documentation +// +// /* +// ** pTab is a transient Table object that represents a subquery of some +// ** kind (maybe a parenthesized subquery in the FROM clause of a larger +// ** query, or a VIEW, or a CTE). This routine computes type information +// ** for that Table object based on the Select object that implements the +// ** subquery. For the purposes of this routine, "type information" means: +// ** +// ** * The datatype name, as it might appear in a CREATE TABLE statement +// ** * Which collating sequence to use for the column +// ** * The affinity of the column +// */ +func _sqlite3SubqueryColumnTypes(tls *libc.TLS, pParse uintptr, pTab uintptr, pSelect uintptr, aff uint8) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, db, p, pCol, pColl, pS2, zType, v4 uintptr + var i, j, m int32 + var k, n Ti64 + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _ = a, db, i, j, k, m, n, p, pCol, pColl, pS2, zType, v4 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return + } + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + a = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + 8 + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + i = 0 + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + m = 0 + pS2 = pSelect + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags) & libc.Int32FromInt32(COLFLAG_NOINSERT)) + p = (**(**TExprList_item)(__ccgo_up(a + uintptr(i)*32))).FpExpr + /* pCol->szEst = ... // Column size est for SELECT tables never used */ + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3ExprAffinity(tls, p) + for libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) <= int32(SQLITE_AFF_NONE) && (*TSelect)(unsafe.Pointer(pS2)).FpNext != uintptr(0) { + m = m | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + } + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) <= int32(SQLITE_AFF_NONE) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = aff + } + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_TEXT) && ((*TSelect)(unsafe.Pointer(pS2)).FpNext != 0 || pS2 != pSelect) { + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + for { + if !(pS2 != 0) { + break + } + m = m | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + goto _2 + _2: + ; + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + } + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_TEXT) && m&int32(0x01) != 0 { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_BLOB) + } else { + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) && m&int32(0x02) != 0 { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_BLOB) + } + } + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_CAST) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_FLEXNUM) + } + } + zType = _columnTypeImpl(tls, bp, p, uintptr(0), uintptr(0), uintptr(0)) + if zType == uintptr(0) || libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) != libc.Int32FromUint8(_sqlite3AffinityType(tls, zType, uintptr(0))) { + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_NUMERIC) || libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_FLEXNUM) { + zType = __ccgo_ts + 20649 + } else { + zType = uintptr(0) + j = int32(1) + for { + if !(j < int32(SQLITE_N_STDTYPE)) { + break + } + if libc.Int32FromUint8(_sqlite3StdTypeAffinity[j]) == libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) { + zType = _sqlite3StdType[j] + break + } + goto _3 + _3: + ; + j = j + 1 + } + } + } + if zType != 0 { + k = libc.Int64FromUint64(libc.Xstrlen(tls, zType)) + n = libc.Int64FromUint64(libc.Xstrlen(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = _sqlite3DbReallocOrFree(tls, db, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, libc.Uint64FromInt64(n+k+int64(2))) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^(libc.Int32FromInt32(COLFLAG_HASTYPE) | libc.Int32FromInt32(COLFLAG_HASCOLL))) + if (*TColumn)(unsafe.Pointer(pCol)).FzCnName != 0 { + libc.Xmemcpy(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName+uintptr(n+int64(1)), zType, libc.Uint64FromInt64(k+int64(1))) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_HASTYPE)) + } + } + pColl = _sqlite3ExprCollSeq(tls, pParse, p) + if pColl != 0 { + _sqlite3ColumnSetColl(tls, db, pCol, (*TCollSeq)(unsafe.Pointer(pColl)).FzName) + } + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + (*TTable)(unsafe.Pointer(pTab)).FszTabRow = int16(1) /* Any non-zero value works */ +} + +// C documentation +// +// /* +// ** Analyze the ON CONFLICT clause described by pUpsert. Resolve all +// ** symbols in the conflict-target. +// ** +// ** Return SQLITE_OK if everything works, or an error code is something +// ** is wrong. +// */ +func _sqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr, pUpsert uintptr, pAll uintptr) (r int32) { + bp := tls.Alloc(240) + defer tls.Free(240) + var iCursor, ii, jj, nClause, nn, rc int32 + var pExpr, pIdx, pTab, pTarget, pTerm, v2 uintptr + var v3 bool + var _ /* sCol at bp+56 */ [2]TExpr + var _ /* sNC at bp+0 */ TNameContext + var _ /* zWhich at bp+200 */ [16]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _ = iCursor, ii, jj, nClause, nn, pExpr, pIdx, pTab, pTarget, pTerm, rc, v2, v3 /* Index column converted into an Expr */ + nClause = 0 /* Counter of ON CONFLICT clauses */ + /* Resolve all symbolic names in the conflict-target clause, which + ** includes both the list of columns and the optional partial-index + ** WHERE clause. + */ + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pTabList + for { + if !(pUpsert != 0 && (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget != 0) { + break + } + rc = _sqlite3ResolveExprListNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) + if rc != 0 { + return rc + } + rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) + if rc != 0 { + return rc + } + /* Check to see if the conflict target matches the rowid. */ + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab + pTarget = (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget + iCursor = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor + if v3 = (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) && (*TExprList)(unsafe.Pointer(pTarget)).FnExpr == int32(1); v3 { + v2 = (*(*TExprList_item)(unsafe.Pointer(pTarget + 8))).FpExpr + pTerm = v2 + } + if v3 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(v2)).Fop) == int32(TK_COLUMN) && int32((*TExpr)(unsafe.Pointer(pTerm)).FiColumn) == -int32(1) { + /* The conflict-target is the rowid of the primary table */ + goto _1 + } + /* Initialize sCol[0..1] to be an expression parse tree for a + ** single column of an index. The sCol[0] node will be the TK_COLLATE + ** operator and sCol[1] will be the TK_COLUMN operator. Code below + ** will populate the specific collation and column number values + ** prior to comparing against the conflict-target expression. + */ + libc.Xmemset(tls, bp+56, 0, uint64(144)) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].Fop = uint8(TK_COLLATE) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = bp + 56 + 1*72 + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].Fop = uint8(TK_COLUMN) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].FiTable = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor + /* Check for matches against other indexes */ + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromInt32(OE_None)) { + goto _4 + } + if (*TExprList)(unsafe.Pointer(pTarget)).FnExpr != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + goto _4 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + if (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere == uintptr(0) { + goto _4 + } + if _sqlite3ExprCompare(tls, pParse, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere, (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere, iCursor) != 0 { + goto _4 + } + } + nn = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + ii = 0 + for { + if !(ii < nn) { + break + } + *(*uintptr)(unsafe.Pointer(bp + 56 + 8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(ii)*8)) + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2))) == -int32(2) { + pExpr = (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(ii)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLLATE) { + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = pExpr + pExpr = bp + 56 + } + } else { + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = bp + 56 + 1*72 + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].FiColumn = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2)) + pExpr = bp + 56 + } + jj = 0 + for { + if !(jj < nn) { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pTarget + 8 + uintptr(jj)*32))).FpExpr, pExpr, iCursor) < int32(2) { + break /* Column ii of the index matches column jj of target */ + } + goto _6 + _6: + ; + jj = jj + 1 + } + if jj >= nn { + /* The target contains no match for column jj of the index */ + break + } + goto _5 + _5: + ; + ii = ii + 1 + } + if ii < nn { + /* Column ii of the index did not match any term of the conflict target. + ** Continue the search with the next index. */ + goto _4 + } + (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx = pIdx + if _sqlite3UpsertOfIndex(tls, pAll, pIdx) != pUpsert { + /* Really this should be an error. The isDup ON CONFLICT clause will + ** never fire. But this problem was not discovered until three years + ** after multi-CONFLICT upsert was added, and so we silently ignore + ** the problem to prevent breaking applications that might actually + ** have redundant ON CONFLICT clauses. */ + (*TUpsert)(unsafe.Pointer(pUpsert)).FisDup = uint8(1) + } + break + goto _4 + _4: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx == uintptr(0) { + if nClause == 0 && (*TUpsert)(unsafe.Pointer(pUpsert)).FpNextUpsert == uintptr(0) { + (**(**[16]uint8)(__ccgo_up(bp + 200)))[0] = uint8(0) + } else { + Xsqlite3_snprintf(tls, int32(16), bp+200, __ccgo_ts+22587, libc.VaList(bp+224, nClause+int32(1))) + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22591, libc.VaList(bp+224, bp+200)) + return int32(SQLITE_ERROR) + } + goto _1 + _1: + ; + pUpsert = (*TUpsert)(unsafe.Pointer(pUpsert)).FpNextUpsert + nClause = nClause + 1 + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Generate bytecode that does an UPDATE as part of an upsert. +// ** +// ** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK. +// ** In this case parameter iCur is a cursor open on the table b-tree that +// ** currently points to the conflicting table row. Otherwise, if pIdx +// ** is not NULL, then pIdx is the constraint that failed and iCur is a +// ** cursor points to the conflicting row. +// */ +func _sqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab uintptr, pIdx uintptr, iCur int32) { + var db, pPk, pSrc, pTop, v uintptr + var i, iDataCur, iPk, k, nPk, regRowid int32 + _, _, _, _, _, _, _, _, _, _, _ = db, i, iDataCur, iPk, k, nPk, pPk, pSrc, pTop, regRowid, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTop = pUpsert + iDataCur = (*TUpsert)(unsafe.Pointer(pUpsert)).FiDataCur + pUpsert = _sqlite3UpsertOfIndex(tls, pTop, pIdx) + if pIdx != 0 && iCur != iDataCur { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + regRowid = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), iCur, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), iDataCur, 0, regRowid) + _sqlite3ReleaseTempReg(tls, pParse, regRowid) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + iPk = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPk + i = 0 + for { + if !(i < nPk) { + break + } + k = _sqlite3TableColumnToIndex(tls, pIdx, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iCur, k, iPk+i) + goto _1 + _1: + ; + i = i + 1 + } + i = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iDataCur, 0, iPk, nPk) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Halt), int32(SQLITE_CORRUPT), int32(OE_Abort), 0, __ccgo_ts+13726, -int32(1)) + _sqlite3MayAbort(tls, pParse) + _sqlite3VdbeJumpHere(tls, v, i) + } + } + /* pUpsert does not own pTop->pUpsertSrc - the outer INSERT statement does. + ** So we have to make a copy before passing it down into sqlite3Update() */ + pSrc = _sqlite3SrcListDup(tls, db, (*TUpsert)(unsafe.Pointer(pTop)).FpUpsertSrc, 0) + /* excluded.* columns of type REAL need to be converted to a hard real */ + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint8((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), (*TUpsert)(unsafe.Pointer(pTop)).FregData+i) + } + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3Update(tls, pParse, pSrc, _sqlite3ExprListDup(tls, db, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSet, 0), _sqlite3ExprDup(tls, db, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere, 0), int32(OE_Abort), uintptr(0), uintptr(0), pUpsert) +} + +/************** End of upsert.c **********************************************/ +/************** Begin file vacuum.c ******************************************/ +/* +** 2003 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the VACUUM command. +** +** Most of the code in this file may be omitted by defining the +** SQLITE_OMIT_VACUUM macro. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +// C documentation +// +// /* +// ** Execute as much of a VDBE program as we can. +// ** This is the core of sqlite3_step(). +// */ +func _sqlite3VdbeExec(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(1024) + defer tls.Free(1024) + var aCol, aMem, aOffset, aOp, aPermute, aRoot, apArg, apArg1, db, pArgc, pBt, pBt1, pBt2, pBt3, pC, pC1, pC10, pC11, pC12, pC13, pC14, pC15, pC16, pC17, pC18, pC19, pC2, pC20, pC21, pC22, pC23, pC24, pC25, pC26, pC27, pC28, pC29, pC3, pC30, pC31, pC32, pC33, pC34, pC4, pC5, pC6, pC7, pC8, pC9, pCaller, pColl, pCrsr, pCrsr1, pCrsr2, pCrsr3, pCrsr4, pCrsr5, pCrsr6, pCrsr7, pCrsr8, pCtx, pCtx1, pCtx2, pCur, pCur1, pCur2, pCur3, pCur4, pCur5, pCur6, pCx, pCx1, pCx2, pCx3, pData, pData0, pDb, pDb1, pDb2, pDb3, pDest, pDest1, pDest2, pEnd, pFrame, pFrame1, pFrame2, pFrame3, pFrame4, pIdxKey, pIn, pIn1, pIn2, pIn3, pKey, pKeyInfo, pKeyInfo1, pKeyInfo2, pLast, pMem, pMem1, pMem2, pMem3, pMem4, pModule, pModule1, pModule2, pModule3, pModule4, pModule5, pModule6, pName, pNew, pOp, pOrig, pOut, pPager, pProgram, pQuery, pRec, pReg, pRhs, pRt, pSavepoint, pSrc, pTab, pTab1, pTab2, pTab3, pTabCur, pTmp, pVCur1, pVTab, pVar, pVtab, pVtab1, pVtab2, pVtab3, pVtab4, pVtab5, pVtab6, pVtab7, pX, pX1, pnErr, t1, z1, z2, z3, zAffinity, zAffinity1, zData, zDb, zDb1, zEndHdr, zErr, zFilename, zHdr, zHdr1, zName, zPayload, zSchema, zSql, zTab, zTrace, v191, v194 uintptr + var affinity uint8 + var alreadyExists, bRev, c, c1, c2, cnt, cnt1, desiredAutoCommit, eNew, eOld, eqOnly, exists, i, i1, i2, i4, i5, i6, i7, i8, i9, iCompare, iCookie, iDb, iDb1, iDb2, iDb3, iQuery, iRollback, iSavepoint, iSet, ii, ii1, isLegacy, isSchemaChange, isTransaction, len1, n, n1, n2, n4, nArg, nArg1, nCol, nField, nField1, nField2, nHdr, nKeyCol, nMem, nName, nRoot, nStep, nVarint, oc, opflags, p1, p11, p12, p13, p2, p21, pcDest, pcx, rc, res, res11, res13, res14, res21, savedAnalysisLimit, seekResult, v11, v21, wrFlag, v190, v193 int32 + var colCacheCtr, iAddr, iMap, iPrior, idx, len11, n3, p22, p23, serialType, serial_type, v215, v216 Tu32 + var encoding, isWriteLock, mTrace, op, p5, resetSchemaOnFault, vtabOnConflict, v227 Tu8 + var flags1, flags11, flags2, flags3, flags31, newType, nullFlag, type1, type2, typeMask, v192 Tu16 + var h, h1, iKey1, nAlloc, nData, nProgressLimit, nVmStep, offset64, uu Tu64 + var i3, iA, iB1, iKey, iKey2, nByte, nByte1, nByte2, nCellKey, nZero, sz, v256 Ti64 + var newMax, v213 uint32 + var rA, rB float64 + var xAuth Tsqlite3_xauth + var v206 int64 + var v217 bool + var _ /* aRes at bp+760 */ [3]int32 + var _ /* iA at bp+8 */ Ti64 + var _ /* iB at bp+0 */ Ti64 + var _ /* iMeta at bp+104 */ int32 + var _ /* iMeta at bp+108 */ int32 + var _ /* iMoved at bp+608 */ int32 + var _ /* initData at bp+640 */ TInitData + var _ /* m at bp+552 */ TMem + var _ /* nChange at bp+616 */ Ti64 + var _ /* nEntry at bp+96 */ Ti64 + var _ /* nErr at bp+680 */ int32 + var _ /* nullFunc at bp+896 */ TFuncDef + var _ /* pVCur at bp+832 */ uintptr + var _ /* pgno at bp+624 */ TPgno + var _ /* r at bp+120 */ TUnpackedRecord + var _ /* r at bp+168 */ TUnpackedRecord + var _ /* r at bp+208 */ TUnpackedRecord + var _ /* r at bp+464 */ TUnpackedRecord + var _ /* r at bp+512 */ TUnpackedRecord + var _ /* r at bp+704 */ TUnpackedRecord + var _ /* res at bp+112 */ int32 + var _ /* res at bp+160 */ int32 + var _ /* res at bp+248 */ int32 + var _ /* res at bp+320 */ int32 + var _ /* res at bp+376 */ int32 + var _ /* res at bp+392 */ int32 + var _ /* res at bp+396 */ int32 + var _ /* res at bp+400 */ int32 + var _ /* res at bp+404 */ int32 + var _ /* res at bp+456 */ int32 + var _ /* res at bp+696 */ int32 + var _ /* rowid at bp+504 */ Ti64 + var _ /* rowid at bp+968 */ Tsqlite_int64 + var _ /* sContext at bp+848 */ Tsqlite3_context + var _ /* sMem at bp+24 */ TMem + var _ /* sMem at bp+776 */ TMem + var _ /* t at bp+80 */ Tu32 + var _ /* uA at bp+16 */ Tu64 + var _ /* v at bp+312 */ Ti64 + var _ /* v at bp+384 */ Ti64 + var _ /* v at bp+88 */ Tu64 + var _ /* val at bp+744 */ Ti64 + var _ /* x at bp+256 */ TMem + var _ /* x at bp+328 */ TBtreePayload + var _ /* x at bp+408 */ TBtreePayload + var _ /* x at bp+752 */ Ti64 + var _ /* z at bp+688 */ uintptr + var _ /* zErr at bp+632 */ uintptr + var _ /* zErr at bp+840 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCol, aMem, aOffset, aOp, aPermute, aRoot, affinity, alreadyExists, apArg, apArg1, bRev, c, c1, c2, cnt, cnt1, colCacheCtr, db, desiredAutoCommit, eNew, eOld, encoding, eqOnly, exists, flags1, flags11, flags2, flags3, flags31, h, h1, i, i1, i2, i3, i4, i5, i6, i7, i8, i9, iA, iAddr, iB1, iCompare, iCookie, iDb, iDb1, iDb2, iDb3, iKey, iKey1, iKey2, iMap, iPrior, iQuery, iRollback, iSavepoint, iSet, idx, ii, ii1, isLegacy, isSchemaChange, isTransaction, isWriteLock, len1, len11, mTrace, n, n1, n2, n3, n4, nAlloc, nArg, nArg1, nByte, nByte1, nByte2, nCellKey, nCol, nData, nField, nField1, nField2, nHdr, nKeyCol, nMem, nName, nProgressLimit, nRoot, nStep, nVarint, nVmStep, nZero, newMax, newType, nullFlag, oc, offset64, op, opflags, p1, p11, p12, p13, p2, p21, p22, p23, p5, pArgc, pBt, pBt1, pBt2, pBt3, pC, pC1, pC10, pC11, pC12, pC13, pC14, pC15, pC16, pC17, pC18, pC19, pC2, pC20, pC21, pC22, pC23, pC24, pC25, pC26, pC27, pC28, pC29, pC3, pC30, pC31, pC32, pC33, pC34, pC4, pC5, pC6, pC7, pC8, pC9, pCaller, pColl, pCrsr, pCrsr1, pCrsr2, pCrsr3, pCrsr4, pCrsr5, pCrsr6, pCrsr7, pCrsr8, pCtx, pCtx1, pCtx2, pCur, pCur1, pCur2, pCur3, pCur4, pCur5, pCur6, pCx, pCx1, pCx2, pCx3, pData, pData0, pDb, pDb1, pDb2, pDb3, pDest, pDest1, pDest2, pEnd, pFrame, pFrame1, pFrame2, pFrame3, pFrame4, pIdxKey, pIn, pIn1, pIn2, pIn3, pKey, pKeyInfo, pKeyInfo1, pKeyInfo2, pLast, pMem, pMem1, pMem2, pMem3, pMem4, pModule, pModule1, pModule2, pModule3, pModule4, pModule5, pModule6, pName, pNew, pOp, pOrig, pOut, pPager, pProgram, pQuery, pRec, pReg, pRhs, pRt, pSavepoint, pSrc, pTab, pTab1, pTab2, pTab3, pTabCur, pTmp, pVCur1, pVTab, pVar, pVtab, pVtab1, pVtab2, pVtab3, pVtab4, pVtab5, pVtab6, pVtab7, pX, pX1, pcDest, pcx, pnErr, rA, rB, rc, res, res11, res13, res14, res21, resetSchemaOnFault, savedAnalysisLimit, seekResult, serialType, serial_type, sz, t1, type1, type2, typeMask, uu, v11, v21, vtabOnConflict, wrFlag, xAuth, z1, z2, z3, zAffinity, zAffinity1, zData, zDb, zDb1, zEndHdr, zErr, zFilename, zHdr, zHdr1, zName, zPayload, zSchema, zSql, zTab, zTrace, v190, v191, v192, v193, v194, v206, v213, v215, v216, v217, v227, v256 + aOp = (*TVdbe)(unsafe.Pointer(p)).FaOp /* Copy of p->aOp */ + pOp = aOp /* Current operation */ + rc = SQLITE_OK /* Value to return */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb /* The database */ + resetSchemaOnFault = uint8(0) /* Reset schema after an error if positive */ + encoding = (*Tsqlite3)(unsafe.Pointer(db)).Fenc /* The database encoding */ + iCompare = 0 /* Result of last comparison */ + nVmStep = uint64(0) /* Invoke xProgress() when nVmStep reaches this */ + aMem = (*TVdbe)(unsafe.Pointer(p)).FaMem /* Copy of p->aMem */ + pIn1 = uintptr(0) /* 1st input operand */ + pIn2 = uintptr(0) /* 2nd input operand */ + pIn3 = uintptr(0) /* 3rd input operand */ + pOut = uintptr(0) /* Output operand */ + colCacheCtr = uint32(0) /* Column cache counter */ + /*** INSERT STACK UNION HERE ***/ + /* sqlite3_step() verifies this */ + if (*TVdbe)(unsafe.Pointer(p)).FlockMask != uint32(0) { + _sqlite3VdbeEnter(tls, p) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != 0 { + iPrior = **(**Tu32)(__ccgo_up(p + 212 + 4*4)) + nProgressLimit = uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps - iPrior%(*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + } else { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)<= nProgressLimit && (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0) { + nProgressLimit = nProgressLimit + uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)< 0 && int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == P4_NOTUSED { + zErr = _sqlite3ValueText(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, uint8(SQLITE_UTF8)) + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, zErr)) + } else { + if (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+5856, libc.VaList(bp+984, _azType[libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)-int32(1)])) + if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3MPrintf(tls, db, __ccgo_ts+5877, libc.VaList(bp+984, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + } + } else { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + } + } + _sqlite3VdbeLogAbort(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, pOp, aOp) + } + rc = _sqlite3VdbeHalt(tls, p) + if rc == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_BUSY) + } else { + if (*TVdbe)(unsafe.Pointer(p)).Frc != 0 { + v190 = int32(SQLITE_ERROR) + } else { + v190 = int32(SQLITE_DONE) + } + rc = v190 + } + goto vdbe_return + /* Opcode: Integer P1 P2 * * * + ** Synopsis: r[P2]=P1 + ** + ** The 32-bit integer value P1 is written into register P2. + */ + _10: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = int64((*TOp)(unsafe.Pointer(pOp)).Fp1) + goto _189 + /* Opcode: Int64 * P2 * P4 * + ** Synopsis: r[P2]=P4 + ** + ** P4 is a pointer to a 64-bit integer value. + ** Write that value into register P2. + */ + _11: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))) + goto _189 + /* Opcode: Real * P2 * P4 * + ** Synopsis: r[P2]=P4 + ** + ** P4 is a pointer to a 64-bit floating point value. + ** Write that value into register P2. + */ + _12: + ; /* same as TK_FLOAT, out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Real) + *(*float64)(unsafe.Pointer(pOut)) = **(**float64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))) + goto _189 + /* Opcode: String8 * P2 * P4 * + ** Synopsis: r[P2]='P4' + ** + ** P4 points to a nul terminated UTF-8 string. This opcode is transformed + ** into a String opcode before it is executed for the first time. During + ** this transformation, the length of string P4 is computed and stored + ** as the P1 parameter. + */ + _13: + ; /* same as TK_STRING, out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TOp)(unsafe.Pointer(pOp)).Fp1 = _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pOp + 16))) + if libc.Int32FromUint8(encoding) != int32(SQLITE_UTF8) { + rc = _sqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64(-int32(1)), uint8(SQLITE_UTF8), libc.UintptrFromInt32(0)) + if rc != 0 { + goto too_big + } + if SQLITE_OK != _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8(encoding)) { + goto no_mem + } + (*TMem)(unsafe.Pointer(pOut)).FszMalloc = 0 + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Static)) + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(7) { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + (*TOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = (*TMem)(unsafe.Pointer(pOut)).Fz + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (*TMem)(unsafe.Pointer(pOut)).Fn + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 > **(**int32)(__ccgo_up(db + 136)) { + goto too_big + } + (*TOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_String) + /* Fall through to the next case, OP_String */ + /* Opcode: String P1 P2 P3 P4 P5 + ** Synopsis: r[P2]='P4' (len=P1) + ** + ** The string value P4 of length P1 (bytes) is stored in register P2. + ** + ** If P3 is not zero and the content of register P3 is equal to P5, then + ** the datatype of the register P2 is converted to BLOB. The content is + ** the same sequence of bytes, it is merely interpreted as a BLOB instead + ** of a string, as if it had been CAST. In other words: + ** + ** if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB) + */ + _14: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fz = *(*uintptr)(unsafe.Pointer(pOp + 16)) + (*TMem)(unsafe.Pointer(pOut)).Fn = (*TOp)(unsafe.Pointer(pOp)).Fp1 + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: BeginSubrtn * P2 * * * + ** Synopsis: r[P2]=NULL + ** + ** Mark the beginning of a subroutine that can be entered in-line + ** or that can be called using OP_Gosub. The subroutine should + ** be terminated by an OP_Return instruction that has a P1 operand that + ** is the same as the P2 operand to this opcode and that has P3 set to 1. + ** If the subroutine is entered in-line, then the OP_Return will simply + ** fall through. But if the subroutine is entered using OP_Gosub, then + ** the OP_Return will jump back to the first instruction after the OP_Gosub. + ** + ** This routine works by loading a NULL into the P2 register. When the + ** return address register contains a NULL, the OP_Return instruction is + ** a no-op that simply falls through to the next instruction (assuming that + ** the OP_Return opcode has a P3 value of 1). Thus if the subroutine is + ** entered in-line, then the OP_Return will cause in-line execution to + ** continue. But if the subroutine is entered via OP_Gosub, then the + ** OP_Return will cause a return to the address following the OP_Gosub. + ** + ** This opcode is identical to OP_Null. It has a different name + ** only to make the byte code easier to read and verify. + */ + /* Opcode: Null P1 P2 P3 * * + ** Synopsis: r[P2..P3]=NULL + ** + ** Write a NULL into registers P2. If P3 greater than P2, then also write + ** NULL into register P3 and every register in between P2 and P3. If P3 + ** is less than P2 (typically P3 is zero) then only register P2 is + ** set to NULL. + ** + ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that + ** NULL values will not compare equal even if SQLITE_NULLEQ is set on + ** OP_Ne or OP_Eq. + */ + _16: + ; + _15: + ; + pOut = _out2Prerelease(tls, p, pOp) + cnt = (*TOp)(unsafe.Pointer(pOp)).Fp3 - (*TOp)(unsafe.Pointer(pOp)).Fp2 + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + v190 = libc.Int32FromInt32(MEM_Null) | libc.Int32FromInt32(MEM_Cleared) + } else { + v190 = int32(MEM_Null) + } + v192 = libc.Uint16FromInt32(v190) + nullFlag = v192 + (*TMem)(unsafe.Pointer(pOut)).Fflags = v192 + (*TMem)(unsafe.Pointer(pOut)).Fn = 0 + for cnt > 0 { + pOut += 56 + _sqlite3VdbeMemSetNull(tls, pOut) + (*TMem)(unsafe.Pointer(pOut)).Fflags = nullFlag + (*TMem)(unsafe.Pointer(pOut)).Fn = 0 + cnt = cnt - 1 + } + goto _189 + /* Opcode: SoftNull P1 * * * * + ** Synopsis: r[P1]=NULL + ** + ** Set register P1 to have the value NULL as seen by the OP_MakeRecord + ** instruction, but do not free any string or blob memory associated with + ** the register, so that if the value was a string or blob that was + ** previously copied using OP_SCopy, the copies will continue to be valid. + */ + _17: + ; + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_Undefined)|libc.Int32FromInt32(MEM_AffMask)) | int32(MEM_Null)) + goto _189 + /* Opcode: Blob P1 P2 * P4 * + ** Synopsis: r[P2]=P4 (len=P1) + ** + ** P4 points to a blob of data P1 bytes long. Store this + ** blob in register P2. If P4 is a NULL pointer, then construct + ** a zero-filled blob that is P1 bytes long in P2. + */ + _18: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + if *(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0) { + _sqlite3VdbeMemSetZeroBlob(tls, pOut, (*TOp)(unsafe.Pointer(pOp)).Fp1) + if _sqlite3VdbeMemExpandBlob(tls, pOut) != 0 { + goto no_mem + } + } else { + _sqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64((*TOp)(unsafe.Pointer(pOp)).Fp1), uint8(0), uintptr(0)) + } + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: Variable P1 P2 * * * + ** Synopsis: r[P2]=parameter(P1) + ** + ** Transfer the values of bound parameter P1 into register P2 + */ + _19: + ; /* Value being transferred */ + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1-int32(1))*56 + if _sqlite3VdbeMemTooBig(tls, pVar) != 0 { + goto too_big + } + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + } + libc.Xmemcpy(tls, pOut, pVar, uint64(libc.UintptrFromInt32(0)+24)) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Ephem))) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | (libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_FromBind))) + goto _189 + /* Opcode: Move P1 P2 P3 * * + ** Synopsis: r[P2@P3]=r[P1@P3] + ** + ** Move the P3 values in register P1..P1+P3-1 over into + ** registers P2..P2+P3-1. Registers P1..P1+P3-1 are + ** left holding a NULL. It is an error for register ranges + ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error + ** for P3 to be less than 1. + */ + _20: + ; /* Register to copy to */ + n = (*TOp)(unsafe.Pointer(pOp)).Fp3 + p1 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + p2 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pIn1 = aMem + uintptr(p1)*56 + pOut = aMem + uintptr(p2)*56 + for { + _sqlite3VdbeMemMove(tls, pOut, pIn1) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + pIn1 += 56 + pOut += 56 + goto _197 + _197: + ; + n = n - 1 + v190 = n + if !(v190 != 0) { + break + } + } + goto _189 + /* Opcode: Copy P1 P2 P3 * P5 + ** Synopsis: r[P2@P3+1]=r[P1@P3+1] + ** + ** Make a copy of registers P1..P1+P3 into registers P2..P2+P3. + ** + ** If the 0x0002 bit of P5 is set then also clear the MEM_Subtype flag in the + ** destination. The 0x0001 bit of P5 indicates that this Copy opcode cannot + ** be merged. The 0x0001 bit is used by the query planner and does not + ** come into play during query execution. + ** + ** This instruction makes a deep copy of the value. A duplicate + ** is made of any string or blob constant. See also OP_SCopy. + */ + _21: + ; + n1 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + for int32(1) != 0 { + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn1, int32(MEM_Ephem)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Subtype) != 0 && libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(0x0002) != 0 { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + } + v190 = n1 + n1 = n1 - 1 + if v190 == 0 { + break + } + pOut += 56 + pIn1 += 56 + } + goto _189 + /* Opcode: SCopy P1 P2 * * * + ** Synopsis: r[P2]=r[P1] + ** + ** Make a shallow copy of register P1 into register P2. + ** + ** This instruction makes a shallow copy of the value. If the value + ** is a string or blob, then the copy is only a pointer to the + ** original and hence if the original changes so will the copy. + ** Worse, if the original is deallocated, the copy becomes invalid. + ** Thus the program must guarantee that the original will not change + ** during the lifetime of the copy. Use OP_Copy to make a complete + ** copy. + */ + _22: + ; /* out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn1, int32(MEM_Ephem)) + goto _189 + /* Opcode: IntCopy P1 P2 * * * + ** Synopsis: r[P2]=r[P1] + ** + ** Transfer the integer value held in register P1 into register P2. + ** + ** This is an optimized version of SCopy that works only for integer + ** values. + */ + _23: + ; /* out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemSetInt64(tls, pOut, *(*Ti64)(unsafe.Pointer(pIn1))) + goto _189 + /* Opcode: FkCheck * * * * * + ** + ** Halt with an SQLITE_CONSTRAINT error if there are any unresolved + ** foreign key constraint violations. If there are no foreign key + ** constraint violations, this is a no-op. + ** + ** FK constraint violations are also checked when the prepared statement + ** exits. This opcode is used to raise foreign key constraint errors prior + ** to returning results such as a row change count or the result of a + ** RETURNING clause. + */ + _24: + ; + v190 = _sqlite3VdbeCheckFkImmediate(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto abort_due_to_error + } + goto _189 + /* Opcode: ResultRow P1 P2 * * * + ** Synopsis: output=r[P1@P2] + ** + ** The registers P1 through P1+P2-1 contain a single row of + ** results. This opcode causes the sqlite3_step() call to terminate + ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt + ** structure to provide access to the r(P1)..r(P1+P2-1) values as + ** the result row. + */ + _25: + ; + (*TVdbe)(unsafe.Pointer(p)).FcacheCtr = (*TVdbe)(unsafe.Pointer(p)).FcacheCtr + uint32(2) | uint32(1) + (*TVdbe)(unsafe.Pointer(p)).FpResultRow = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto no_mem + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_ROW) != 0 { + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_ROW), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0)) + } + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp)-int64(aOp))/24) + int32(1) + rc = int32(SQLITE_ROW) + goto vdbe_return + /* Opcode: Concat P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]+r[P1] + ** + ** Add the text in register P1 onto the end of the text in + ** register P2 and store the result in register P3. + ** If either the P1 or P2 text are NULL then store NULL in P3. + ** + ** P3 = P2 || P1 + ** + ** It is illegal for P1 and P3 to be the same register. Sometimes, + ** if P3 is the same register as P2, the implementation is able + ** to avoid a memcpy(). + */ + _26: + ; /* Initial flags for P2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags1 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + if (libc.Int32FromUint16(flags1)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags))&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + goto _189 + } + if libc.Int32FromUint16(flags1)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) == 0 { + if _sqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(0)) != 0 { + goto no_mem + } + flags1 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } else { + if libc.Int32FromUint16(flags1)&int32(MEM_Zero) != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pIn1) != 0 { + goto no_mem + } + flags1 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } + } + flags2 = (*TMem)(unsafe.Pointer(pIn2)).Fflags + if libc.Int32FromUint16(flags2)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) == 0 { + if _sqlite3VdbeMemStringify(tls, pIn2, encoding, uint8(0)) != 0 { + goto no_mem + } + flags2 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } else { + if libc.Int32FromUint16(flags2)&int32(MEM_Zero) != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pIn2) != 0 { + goto no_mem + } + flags2 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } + } + nByte = int64((*TMem)(unsafe.Pointer(pIn1)).Fn) + nByte = nByte + int64((*TMem)(unsafe.Pointer(pIn2)).Fn) + if nByte > int64(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + if _sqlite3VdbeMemGrow(tls, pOut, int32(nByte)+int32(2), libc.BoolInt32(pOut == pIn2)) != 0 { + goto no_mem + } + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Str)) + if pOut != pIn2 { + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pOut)).Fz, (*TMem)(unsafe.Pointer(pIn2)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn2)).Fn)) + (*TMem)(unsafe.Pointer(pIn2)).Fflags = flags2 + } + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pOut)).Fz+uintptr((*TMem)(unsafe.Pointer(pIn2)).Fn), (*TMem)(unsafe.Pointer(pIn1)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn)) + (*TMem)(unsafe.Pointer(pIn1)).Fflags = flags1 + if libc.Int32FromUint8(encoding) > int32(SQLITE_UTF8) { + nByte = nByte & int64(^libc.Int32FromInt32(1)) + } + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte))) = uint8(0) + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte+int64(1)))) = uint8(0) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fn = int32(nByte) + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: Add P1 P2 P3 * * + ** Synopsis: r[P3]=r[P1]+r[P2] + ** + ** Add the value in register P1 to the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Multiply P1 P2 P3 * * + ** Synopsis: r[P3]=r[P1]*r[P2] + ** + ** + ** Multiply the value in register P1 by the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Subtract P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]-r[P1] + ** + ** Subtract the value in register P1 from the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Divide P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]/r[P1] + ** + ** Divide the value in register P1 by the value in register P2 + ** and store the result in register P3 (P3=P2/P1). If the value in + ** register P1 is zero, then the result is NULL. If either input is + ** NULL, the result is NULL. + */ + /* Opcode: Remainder P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]%r[P1] + ** + ** Compute the remainder after integer register P2 is divided by + ** register P1 and store the result in register P3. + ** If the value in register P1 is zero the result is NULL. + ** If either operand is NULL, the result is NULL. + */ + _31: + ; /* same as TK_PLUS, in1, in2, out3 */ + _30: + ; /* same as TK_MINUS, in1, in2, out3 */ + _29: + ; /* same as TK_STAR, in1, in2, out3 */ + _28: + ; /* same as TK_SLASH, in1, in2, out3 */ + _27: + ; /* Real value of right operand */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + type1 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + type2 = (*TMem)(unsafe.Pointer(pIn2)).Fflags + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if !(libc.Int32FromUint16(type1)&libc.Int32FromUint16(type2)&int32(MEM_Int) != 0) { + goto _202 + } + goto int_math + int_math: + ; + iA = *(*Ti64)(unsafe.Pointer(pIn1)) + **(**Ti64)(__ccgo_up(bp)) = *(*Ti64)(unsafe.Pointer(pIn2)) + switch libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) { + case int32(OP_Add): + if _sqlite3AddInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Subtract): + if _sqlite3SubInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Multiply): + if _sqlite3MulInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Divide): + if iA == 0 { + goto arithmetic_result_is_null + } + if iA == int64(-int32(1)) && **(**Ti64)(__ccgo_up(bp)) == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>r[P1] + ** + ** Shift the integer value in register P2 to the right by the + ** number of bits specified by the integer in register P1. + ** Store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + _36: + ; /* same as TK_BITAND, in1, in2, out3 */ + _35: + ; /* same as TK_BITOR, in1, in2, out3 */ + _34: + ; /* same as TK_LSHIFT, in1, in2, out3 */ + _33: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if (libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags))&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + goto _189 + } + **(**Ti64)(__ccgo_up(bp + 8)) = _sqlite3VdbeIntValue(tls, pIn2) + iB1 = _sqlite3VdbeIntValue(tls, pIn1) + op = (*TOp)(unsafe.Pointer(pOp)).Fopcode + if libc.Int32FromUint8(op) == int32(OP_BitAnd) { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) & iB1 + } else { + if libc.Int32FromUint8(op) == int32(OP_BitOr) { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) | iB1 + } else { + if iB1 != 0 { + /* If shifting by a negative amount, shift in the other direction */ + if iB1 < 0 { + op = libc.Uint8FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(OP_ShiftLeft) + libc.Int32FromInt32(1) - libc.Int32FromUint8(op)) + if iB1 > int64(-libc.Int32FromInt32(64)) { + v206 = -iB1 + } else { + v206 = int64(64) + } + iB1 = v206 + } + if iB1 >= int64(64) { + if **(**Ti64)(__ccgo_up(bp + 8)) >= 0 || libc.Int32FromUint8(op) == int32(OP_ShiftLeft) { + v190 = 0 + } else { + v190 = -int32(1) + } + **(**Ti64)(__ccgo_up(bp + 8)) = int64(v190) + } else { + libc.Xmemcpy(tls, bp+16, bp+8, uint64(8)) + if libc.Int32FromUint8(op) == int32(OP_ShiftLeft) { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) << libc.Uint64FromInt64(iB1) + } else { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) >> libc.Uint64FromInt64(iB1) + /* Sign-extend on a right shift of a negative number */ + if **(**Ti64)(__ccgo_up(bp + 8)) < 0 { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) | (libc.Uint64FromUint32(0xffffffff)< + **
  • P2=='A' → BLOB + **
  • P2=='B' → TEXT + **
  • P2=='C' → NUMERIC + **
  • P2=='D' → INTEGER + **
  • P2=='E' → REAL + ** + ** + ** A NULL value is not changed by this routine. It remains NULL. + */ + _40: + ; /* in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn1) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + rc = _sqlite3VdbeMemCast(tls, pIn1, libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2), encoding) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Eq P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]==r[P1] + ** + ** Compare the values in register P1 and P3. If reg(P3)==reg(P1) then + ** jump to address P2. + ** + ** The SQLITE_AFF_MASK portion of P5 must be an affinity character - + ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made + ** to coerce both inputs according to this affinity before the + ** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric + ** affinity is used. Note that the affinity conversions are stored + ** back into the input registers P1 and P3. So this opcode can cause + ** persistent changes to registers P1 and P3. + ** + ** Once any conversions have taken place, and neither value is NULL, + ** the values are compared. If both values are blobs then memcmp() is + ** used to determine the results of the comparison. If both values + ** are text, then the appropriate collating function specified in + ** P4 is used to do the comparison. If P4 is not specified then + ** memcmp() is used to compare text string. If both values are + ** numeric, then a numeric comparison is used. If the two values + ** are of different types, then numbers are considered less than + ** strings and strings are considered less than blobs. + ** + ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either + ** true or false and is never NULL. If both operands are NULL then the result + ** of comparison is true. If either operand is NULL then the result is false. + ** If neither operand is NULL the result is the same as it would be if + ** the SQLITE_NULLEQ flag were omitted from P5. + ** + ** This opcode saves the result of comparison for use by the new + ** OP_Jump opcode. + */ + /* Opcode: Ne P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]!=r[P1] + ** + ** This works just like the Eq opcode except that the jump is taken if + ** the operands in registers P1 and P3 are not equal. See the Eq opcode for + ** additional information. + */ + /* Opcode: Lt P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]r[P1] + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than the content of + ** register P1. See the Lt opcode for additional information. + */ + /* Opcode: Ge P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]>=r[P1] + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than or equal to the content of + ** register P1. See the Lt opcode for additional information. + */ + _46: + ; /* same as TK_EQ, jump, in1, in3 */ + _45: + ; /* same as TK_NE, jump, in1, in3 */ + _44: + ; /* same as TK_LT, jump, in1, in3 */ + _43: + ; /* same as TK_LE, jump, in1, in3 */ + _42: + ; /* same as TK_GT, jump, in1, in3 */ + _41: + ; /* Copy of initial value of pIn3->flags */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags11 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + flags3 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + if libc.Int32FromUint16(flags11)&libc.Int32FromUint16(flags3)&int32(MEM_Int) != 0 { + /* Common case of comparison of two integers */ + if *(*Ti64)(unsafe.Pointer(pIn3)) > *(*Ti64)(unsafe.Pointer(pIn1)) { + if **(**uint8)(__ccgo_up(_sqlite3aGTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = +libc.Int32FromInt32(1) + } else { + if *(*Ti64)(unsafe.Pointer(pIn3)) < *(*Ti64)(unsafe.Pointer(pIn1)) { + if **(**uint8)(__ccgo_up(_sqlite3aLTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = -int32(1) + } else { + if **(**uint8)(__ccgo_up(_sqlite3aEQb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = 0 + } + } + goto _189 + } + if (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Null) != 0 { + /* One or both operands are NULL */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(SQLITE_NULLEQ) != 0 { + /* If SQLITE_NULLEQ is set (which will only happen if the operator is + ** OP_Eq or OP_Ne) then take the jump or not depending on whether + ** or not both operands are null. + */ + if libc.Int32FromUint16(flags11)&libc.Int32FromUint16(flags3)&int32(MEM_Null) != 0 && libc.Int32FromUint16(flags3)&int32(MEM_Cleared) == 0 { + res = 0 /* Operands are equal */ + } else { + if libc.Int32FromUint16(flags3)&int32(MEM_Null) != 0 { + v190 = -int32(1) + } else { + v190 = +libc.Int32FromInt32(1) + } + res = v190 /* Operands are not equal */ + } + } else { + /* SQLITE_NULLEQ is clear and at least one operand is NULL, + ** then the result is always NULL. + ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. + */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(SQLITE_JUMPIFNULL) != 0 { + goto jump_to_p2 + } + iCompare = int32(1) /* Operands are not equal */ + goto _189 + } + } else { + /* Neither operand is NULL and we couldn't do the special high-speed + ** integer comparison case. So do a general-case comparison. */ + affinity = libc.Uint8FromInt32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) & int32(SQLITE_AFF_MASK)) + if libc.Int32FromUint8(affinity) >= int32(SQLITE_AFF_NUMERIC) { + if (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Str) != 0 { + if libc.Int32FromUint16(flags11)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn1, 0) + flags3 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + } + if libc.Int32FromUint16(flags3)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn3, 0) + } + } + } else { + if libc.Int32FromUint8(affinity) == int32(SQLITE_AFF_TEXT) && (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Str) != 0 { + if libc.Int32FromUint16(flags11)&int32(MEM_Str) != 0 { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) + } else { + if libc.Int32FromUint16(flags11)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(1)) + flags11 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_TypeMask) | libc.Int32FromUint16(flags11)&int32(MEM_TypeMask)) + if pIn1 == pIn3 { + flags3 = libc.Uint16FromInt32(libc.Int32FromUint16(flags11) | int32(MEM_Str)) + } + } + } + if libc.Int32FromUint16(flags3)&int32(MEM_Str) != 0 { + v191 = pIn3 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) + } else { + if libc.Int32FromUint16(flags3)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemStringify(tls, pIn3, encoding, uint8(1)) + flags3 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn3)).Fflags) & ^libc.Int32FromInt32(MEM_TypeMask) | libc.Int32FromUint16(flags3)&int32(MEM_TypeMask)) + } + } + } + } + res = _sqlite3MemCompare(tls, pIn3, pIn1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + /* At this point, res is negative, zero, or positive if reg[P1] is + ** less than, equal to, or greater than reg[P3], respectively. Compute + ** the answer to this operator in res2, depending on what the comparison + ** operator actually is. The next block of code depends on the fact + ** that the 6 comparison operators are consecutive integers in this + ** order: NE, EQ, GT, LE, LT, GE */ + if res < 0 { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aLTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } else { + if res == 0 { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aEQb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } else { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aGTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } + } + iCompare = res + /* Undo any changes made by applyAffinity() to the input registers. */ + (*TMem)(unsafe.Pointer(pIn3)).Fflags = flags3 + (*TMem)(unsafe.Pointer(pIn1)).Fflags = flags11 + if res21 != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: ElseEq * P2 * * * + ** + ** This opcode must follow an OP_Lt or OP_Gt comparison operator. There + ** can be zero or more OP_ReleaseReg opcodes intervening, but no other + ** opcodes are allowed to occur between this instruction and the previous + ** OP_Lt or OP_Gt. + ** + ** If the result of an OP_Eq comparison on the same two operands as + ** the prior OP_Lt or OP_Gt would have been true, then jump to P2. If + ** the result of an OP_Eq comparison on the two previous operands + ** would have been false or NULL, then fall through. + */ + _47: + ; /* same as TK_ESCAPE, jump */ + if iCompare == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Permutation * * * P4 * + ** + ** Set the permutation used by the OP_Compare operator in the next + ** instruction. The permutation is stored in the P4 operand. + ** + ** The permutation is only valid for the next opcode which must be + ** an OP_Compare that has the OPFLAG_PERMUTE bit set in P5. + ** + ** The first integer in the P4 integer array is the length of the array + ** and does not become part of the permutation. + */ + _48: + ; + goto _189 + /* Opcode: Compare P1 P2 P3 P4 P5 + ** Synopsis: r[P1@P3] <-> r[P2@P3] + ** + ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this + ** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of + ** the comparison for use by the next OP_Jump instruct. + ** + ** If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is + ** determined by the most recent OP_Permutation operator. If the + ** OPFLAG_PERMUTE bit is clear, then register are compared in sequential + ** order. + ** + ** P4 is a KeyInfo structure that defines collating sequences and sort + ** orders for the comparison. The permutation applies to registers + ** only. The KeyInfo elements are used sequentially. + ** + ** The comparison is a sort comparison, so NULLs compare equal, + ** NULLs are less than numbers, numbers are less than strings, + ** and strings are less than blobs. + ** + ** This opcode must be immediately followed by an OP_Jump opcode. + */ + _49: + ; /* The permutation */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_PERMUTE) == 0 { + aPermute = uintptr(0) + } else { + aPermute = *(*uintptr)(unsafe.Pointer(pOp + uintptr(-libc.Int32FromInt32(1))*24 + 16)) + uintptr(1)*4 + } + n2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) + p11 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + p21 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + i = 0 + for { + if !(i < n2) { + break + } + if aPermute != 0 { + v213 = **(**Tu32)(__ccgo_up(aPermute + uintptr(i)*4)) + } else { + v213 = libc.Uint32FromInt32(i) + } + idx = v213 + pColl = *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)) + bRev = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i)))) & int32(KEYINFO_ORDER_DESC) + iCompare = _sqlite3MemCompare(tls, aMem+uintptr(libc.Uint32FromInt32(p11)+idx)*56, aMem+uintptr(libc.Uint32FromInt32(p21)+idx)*56, pColl) + if iCompare != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i))))&int32(KEYINFO_ORDER_BIGNULL) != 0 && (libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr(libc.Uint32FromInt32(p11)+idx)*56))).Fflags)&int32(MEM_Null) != 0 || libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr(libc.Uint32FromInt32(p21)+idx)*56))).Fflags)&int32(MEM_Null) != 0) { + iCompare = -iCompare + } + if bRev != 0 { + iCompare = -iCompare + } + break + } + goto _212 + _212: + ; + i = i + 1 + } + goto _189 + /* Opcode: Jump P1 P2 P3 * * + ** + ** Jump to the instruction at address P1, P2, or P3 depending on whether + ** in the most recent OP_Compare instruction the P1 vector was less than, + ** equal to, or greater than the P2 vector, respectively. + ** + ** This opcode must immediately follow an OP_Compare opcode. + */ + _50: + ; /* jump */ + if iCompare < 0 { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1-int32(1))*24 + } else { + if iCompare == 0 { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2-int32(1))*24 + } else { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3-int32(1))*24 + } + } + goto _189 + /* Opcode: And P1 P2 P3 * * + ** Synopsis: r[P3]=(r[P1] && r[P2]) + ** + ** Take the logical AND of the values in registers P1 and P2 and + ** write the result into register P3. + ** + ** If either P1 or P2 is 0 (false) then the result is 0 even if + ** the other input is NULL. A NULL and true or two NULLs give + ** a NULL output. + */ + /* Opcode: Or P1 P2 P3 * * + ** Synopsis: r[P3]=(r[P1] || r[P2]) + ** + ** Take the logical OR of the values in register P1 and P2 and + ** store the answer in register P3. + ** + ** If either P1 or P2 is nonzero (true) then the result is 1 (true) + ** even if the other input is NULL. A NULL and false or two NULLs + ** give a NULL output. + */ + _52: + ; /* same as TK_AND, in1, in2, out3 */ + _51: + ; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ + v11 = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, int32(2)) + v21 = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, int32(2)) + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_And) { + v11 = libc.Int32FromUint8(_and_logic[v11*int32(3)+v21]) + } else { + v11 = libc.Int32FromUint8(_or_logic[v11*int32(3)+v21]) + } + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if v11 == int32(2) { + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Null)) + } else { + *(*Ti64)(unsafe.Pointer(pOut)) = int64(v11) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Int)) + } + goto _189 + /* Opcode: IsTrue P1 P2 P3 P4 * + ** Synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 + ** + ** This opcode implements the IS TRUE, IS FALSE, IS NOT TRUE, and + ** IS NOT FALSE operators. + ** + ** Interpret the value in register P1 as a boolean value. Store that + ** boolean (a 0 or 1) in register P2. Or if the value in register P1 is + ** NULL, then the P3 is stored in register P2. Invert the answer if P4 + ** is 1. + ** + ** The logic is summarized like this: + ** + **
      + **
    • If P3==0 and P4==0 then r[P2] := r[P1] IS TRUE + **
    • If P3==1 and P4==1 then r[P2] := r[P1] IS FALSE + **
    • If P3==0 and P4==1 then r[P2] := r[P1] IS NOT TRUE + **
    • If P3==1 and P4==0 then r[P2] := r[P1] IS NOT FALSE + **
    + */ + _53: + ; /* in1, out2 */ + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, int64(_sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, (*TOp)(unsafe.Pointer(pOp)).Fp3)^(*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) + goto _189 + /* Opcode: Not P1 P2 * * * + ** Synopsis: r[P2]= !r[P1] + ** + ** Interpret the value in register P1 as a boolean value. Store the + ** boolean complement in register P2. If the value in register P1 is + ** NULL, then a NULL is stored in P2. + */ + _54: + ; /* same as TK_NOT, in1, out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + _sqlite3VdbeMemSetInt64(tls, pOut, libc.BoolInt64(!(_sqlite3VdbeBooleanValue(tls, pIn1, 0) != 0))) + } else { + _sqlite3VdbeMemSetNull(tls, pOut) + } + goto _189 + /* Opcode: BitNot P1 P2 * * * + ** Synopsis: r[P2]= ~r[P1] + ** + ** Interpret the content of register P1 as an integer. Store the + ** ones-complement of the P1 value into register P2. If P1 holds + ** a NULL then store a NULL in P2. + */ + _55: + ; /* same as TK_BITNOT, in1, out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemSetNull(tls, pOut) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) + *(*Ti64)(unsafe.Pointer(pOut)) = ^_sqlite3VdbeIntValue(tls, pIn1) + } + goto _189 + /* Opcode: Once P1 P2 P3 * * + ** + ** Fall through to the next instruction the first time this opcode is + ** encountered on each invocation of the byte-code program. Jump to P2 + ** on the second and all subsequent encounters during the same invocation. + ** + ** Top-level programs determine first invocation by comparing the P1 + ** operand against the P1 operand on the OP_Init opcode at the beginning + ** of the program. If the P1 values differ, then fall through and make + ** the P1 of this opcode equal to the P1 of OP_Init. If P1 values are + ** the same then take the jump. + ** + ** For subprograms, there is a bitmask in the VdbeFrame that determines + ** whether or not the jump should be taken. The bitmask is necessary + ** because the self-altering code trick does not work for recursive + ** triggers. + ** + ** The P3 operand is not used directly by this opcode. However P3 is + ** used by the code generator as follows: If this opcode is the start + ** of a subroutine and that subroutine uses a Bloom filter, then P3 will + ** be the register that holds that Bloom filter. See tag-202407032019 + ** in the source code for implementation details. + */ + _56: + ; /* Address of this instruction */ + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + iAddr = libc.Uint32FromInt32(int32((int64(pOp) - int64((*TVdbe)(unsafe.Pointer(p)).FaOp)) / 24)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TVdbeFrame)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/uint32(8)))))&(int32(1)<<(iAddr&uint32(7))) != 0 { + goto jump_to_p2 + } + v191 = (*TVdbeFrame)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/uint32(8)) + *(*Tu8)(unsafe.Pointer(v191)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v191))) | libc.Int32FromInt32(1)<<(iAddr&libc.Uint32FromInt32(7))) + } else { + if (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp))).Fp1 == (*TOp)(unsafe.Pointer(pOp)).Fp1 { + goto jump_to_p2 + } + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp))).Fp1 + goto _189 + /* Opcode: If P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is true. The value + ** is considered true if it is numeric and non-zero. If the value + ** in P1 is NULL then take the jump if and only if P3 is non-zero. + */ + _57: + ; + c = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, (*TOp)(unsafe.Pointer(pOp)).Fp3) + if c != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IfNot P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is False. The value + ** is considered false if it has a numeric value of zero. If the value + ** in P1 is NULL then take the jump if and only if P3 is non-zero. + */ + _58: + ; + c1 = libc.BoolInt32(!(_sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, libc.BoolInt32(!((*TOp)(unsafe.Pointer(pOp)).Fp3 != 0))) != 0)) + if c1 != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IsNull P1 P2 * * * + ** Synopsis: if r[P1]==NULL goto P2 + ** + ** Jump to P2 if the value in register P1 is NULL. + */ + _59: + ; /* same as TK_ISNULL, jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IsType P1 P2 P3 P4 P5 + ** Synopsis: if typeof(P1.P3) in P5 goto P2 + ** + ** Jump to P2 if the type of a column in a btree is one of the types specified + ** by the P5 bitmask. + ** + ** P1 is normally a cursor on a btree for which the row decode cache is + ** valid through at least column P3. In other words, there should have been + ** a prior OP_Column for column P3 or greater. If the cursor is not valid, + ** then this opcode might give spurious results. + ** The the btree row has fewer than P3 columns, then use P4 as the + ** datatype. + ** + ** If P1 is -1, then P3 is a register number and the datatype is taken + ** from the value in that register. + ** + ** P5 is a bitmask of data types. SQLITE_INTEGER is the least significant + ** (0x01) bit. SQLITE_FLOAT is the 0x02 bit. SQLITE_TEXT is 0x04. + ** SQLITE_BLOB is 0x08. SQLITE_NULL is 0x10. + ** + ** WARNING: This opcode does not reliably distinguish between NULL and REAL + ** when P1>=0. If the database contains a NaN value, this opcode will think + ** that the datatype is REAL when it should be NULL. When P1<0 and the value + ** is already stored in register P3, then this opcode does reliably + ** distinguish between NULL and REAL. The problem only arises then P1>=0. + ** + ** Take the jump to address P2 if and only if the datatype of the + ** value determined by P1 and P3 corresponds to one of the bits in the + ** P5 bitmask. + ** + */ + _60: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp1 >= 0 { + pC = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 < libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) { + serialType = *(*Tu32)(unsafe.Pointer(pC + 120 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*4)) + if serialType >= uint32(12) { + if serialType&uint32(1) != 0 { + typeMask = uint16(0x04) /* SQLITE_TEXT */ + } else { + typeMask = uint16(0x08) /* SQLITE_BLOB */ + } + } else { + typeMask = uint16(_aMask[serialType]) + } + } else { + typeMask = libc.Uint16FromInt32(int32(1) << ((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi - int32(1))) + } + } else { + typeMask = libc.Uint16FromInt32(int32(1) << (Xsqlite3_value_type(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56) - int32(1))) + } + if libc.Int32FromUint16(typeMask)&libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: ZeroOrNull P1 P2 P3 * * + ** Synopsis: r[P2] = 0 OR NULL + ** + ** If both registers P1 and P3 are NOT NULL, then store a zero in + ** register P2. If either registers P1 or P3 are NULL then put + ** a NULL in register P2. + */ + _61: + ; /* in1, in2, out2, in3 */ + if libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56))).Fflags)&int32(MEM_Null) != 0 || libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fflags)&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56) + } else { + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, 0) + } + goto _189 + /* Opcode: NotNull P1 P2 * * * + ** Synopsis: if r[P1]!=NULL goto P2 + ** + ** Jump to P2 if the value in register P1 is not NULL. + */ + _62: + ; /* same as TK_NOTNULL, jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IfNullRow P1 P2 P3 * * + ** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2 + ** + ** Check the cursor P1 to see if it is currently pointing at a NULL row. + ** If it is, then set register P3 to NULL and jump immediately to P2. + ** If P1 is not on a NULL row, then fall through without making any + ** changes. + ** + ** If P1 is not an open cursor, then this opcode is a no-op. + */ + _63: + ; + pC1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pC1 != 0 && (*TVdbeCursor)(unsafe.Pointer(pC1)).FnullRow != 0 { + _sqlite3VdbeMemSetNull(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56) + goto jump_to_p2 + } + goto _189 + /* Opcode: Offset P1 P2 P3 * * + ** Synopsis: r[P3] = sqlite_offset(P1) + ** + ** Store in register r[P3] the byte offset into the database file that is the + ** start of the payload for the record at which that cursor P1 is currently + ** pointing. + ** + ** P2 is the column number for the argument to the sqlite_offset() function. + ** This opcode does not use P2 itself, but the P2 value is used by the + ** code generator. The P1, P2, and P3 operands to this opcode are the + ** same as for OP_Column. + ** + ** This opcode is only available if SQLite is compiled with the + ** -DSQLITE_ENABLE_OFFSET_SQL_FUNC option. + */ + _64: + ; /* The VDBE cursor */ + pC2 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pOut = (*TVdbe)(unsafe.Pointer(p)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if pC2 == uintptr(0) || libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC2)).FeCurType) != CURTYPE_BTREE { + _sqlite3VdbeMemSetNull(tls, pOut) + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC2)).FdeferredMoveto != 0 { + rc = _sqlite3VdbeFinishMoveto(tls, pC2) + if rc != 0 { + goto abort_due_to_error + } + } + if _sqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC2 + 48))) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + } else { + _sqlite3VdbeMemSetInt64(tls, pOut, _sqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC2 + 48)))) + } + } + goto _189 + /* Opcode: Column P1 P2 P3 P4 P5 + ** Synopsis: r[P3]=PX cursor P1 column P2 + ** + ** Interpret the data that cursor P1 points to as a structure built using + ** the MakeRecord instruction. (See the MakeRecord opcode for additional + ** information about the format of the data.) Extract the P2-th column + ** from this record. If there are less than (P2+1) + ** values in the record, extract a NULL. + ** + ** The value extracted is stored in register P3. + ** + ** If the record contains fewer than P2 fields, then extract a NULL. Or, + ** if the P4 argument is a P4_MEM use the value of the P4 argument as + ** the result. + ** + ** If the OPFLAG_LENGTHARG bit is set in P5 then the result is guaranteed + ** to only be used by the length() function or the equivalent. The content + ** of large blobs is not loaded, thus saving CPU cycles. If the + ** OPFLAG_TYPEOFARG bit is set then the result will only be used by the + ** typeof() function or the IS NULL or IS NOT NULL operators or the + ** equivalent. In this case, all content loading can be omitted. + */ + _65: + ; /* PseudoTable input register */ + pC3 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + p22 = libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) + goto op_column_restart + op_column_restart: + ; + aOffset = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaOffset + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus != (*TVdbe)(unsafe.Pointer(p)).FcacheCtr { /*OPTIMIZATION-IF-FALSE*/ + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FnullRow != 0 { + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC3)).FeCurType) == int32(CURTYPE_PSEUDO) && (*TVdbeCursor)(unsafe.Pointer(pC3)).FseekResult > 0 { + /* For the special case of as pseudo-cursor, the seekResult field + ** identifies the register that holds the record */ + pReg = aMem + uintptr((*TVdbeCursor)(unsafe.Pointer(pC3)).FseekResult)*56 + v215 = libc.Uint32FromInt32((*TMem)(unsafe.Pointer(pReg)).Fn) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow = v215 + (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = v215 + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = (*TMem)(unsafe.Pointer(pReg)).Fz + } else { + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + _sqlite3VdbeMemSetNull(tls, pDest) + goto op_column_out + } + } else { + pCrsr = *(*uintptr)(unsafe.Pointer(pC3 + 48)) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FdeferredMoveto != 0 { + if v217 = *(*uintptr)(unsafe.Pointer(pC3 + 16)) != 0; v217 { + v215 = **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pC3 + 16)) + uintptr(uint32(1)+p22)*4)) + iMap = v215 + } + if v217 && v215 > uint32(0) { + pC3 = (*TVdbeCursor)(unsafe.Pointer(pC3)).FpAltCursor + p22 = iMap - uint32(1) + goto op_column_restart + } + rc = _sqlite3VdbeFinishMoveto(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + } else { + if _sqlite3BtreeCursorHasMoved(tls, pCrsr) != 0 { + rc = _sqlite3VdbeHandleMovedCursor(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + goto op_column_restart + } + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = _sqlite3BtreePayloadSize(tls, pCrsr) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = _sqlite3BtreePayloadFetch(tls, pCrsr, pC3+108) + /* Maximum page size is 64KiB */ + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = (*TVdbe)(unsafe.Pointer(p)).FcacheCtr + v215 = uint32(**(**Tu8)(__ccgo_up((*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow))) + **(**Tu32)(__ccgo_up(aOffset)) = v215 + if v215 < uint32(0x80) { + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = uint32(1) + } else { + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = uint32(_sqlite3GetVarint32(tls, (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow, aOffset)) + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = uint16(0) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow < **(**Tu32)(__ccgo_up(aOffset)) { /*OPTIMIZATION-IF-FALSE*/ + /* pC->aRow does not have to hold the entire row, but it does at least + ** need to cover the header of the record. If pC->aRow does not contain + ** the complete header, then set it to zero, forcing the header to be + ** dynamically allocated. */ + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = uintptr(0) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow = uint32(0) + /* Make sure a corrupt database has not given us an oversize header. + ** Do this now to avoid an oversize memory allocation. + ** + ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte + ** types use so much data space that there can only be 4096 and 32 of + ** them, respectively. So the maximum header length results from a + ** 3-byte type for each of the maximum of 32768 columns plus three + ** extra bytes for the header length itself. 32768*3 + 3 = 98307. + */ + if **(**Tu32)(__ccgo_up(aOffset)) > uint32(98307) || **(**Tu32)(__ccgo_up(aOffset)) > (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize { + goto op_column_corrupt + } + } else { + /* This is an optimization. By skipping over the first few tests + ** (ex: pC->nHdrParsed<=p2) in the next section, we achieve a + ** measurable performance gain. + ** + ** This branch is taken even if aOffset[0]==0. Such a record is never + ** generated by SQLite, and could be considered corruption, but we + ** accept it for historical reasons. When aOffset[0]==0, the code this + ** branch jumps to reads past the end of the record, but never more + ** than a few bytes. Even if the record occurs at the end of the page + ** content area, the "page header" comes after the page content and so + ** this overread is harmless. Similar overreads can occur for a corrupt + ** database file. + */ + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + /* Conditional skipped */ + goto op_column_read_header + } + } else { + if _sqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(pC3 + 48))) != 0 { + rc = _sqlite3VdbeHandleMovedCursor(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + goto op_column_restart + } + } + /* Make sure at least the first p2+1 entries of the header have been + ** parsed and valid information is in aOffset[] and pC->aType[]. + */ + if !(uint32((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22) { + goto _219 + } + /* If there is more header available for parsing in the record, try + ** to extract additional fields up through the p2+1-th field + */ + if !((*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset < **(**Tu32)(__ccgo_up(aOffset))) { + goto _221 + } + /* Make sure zData points to enough of the record to cover the header. */ + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + libc.Xmemset(tls, bp+24, 0, uint64(56)) + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(pC3 + 48)), **(**Tu32)(__ccgo_up(aOffset)), bp+24) + if rc != SQLITE_OK { + goto abort_due_to_error + } + zData = (**(**TMem)(__ccgo_up(bp + 24))).Fz + } else { + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + } + /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */ + goto op_column_read_header + op_column_read_header: + ; + i1 = libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) + offset64 = uint64(**(**Tu32)(__ccgo_up(aOffset + uintptr(i1)*4))) + zHdr = zData + uintptr((*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset) + zEndHdr = zData + uintptr(**(**Tu32)(__ccgo_up(aOffset))) + for cond := true; cond; cond = libc.Uint32FromInt32(i1) <= p22 && zHdr < zEndHdr { + v216 = uint32(**(**Tu8)(__ccgo_up(zHdr))) + **(**Tu32)(__ccgo_up(bp + 80)) = v216 + v215 = v216 + *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(i1)*4)) = v215 + if v215 < uint32(0x80) { + zHdr = zHdr + 1 + offset64 = offset64 + uint64(_sqlite3VdbeOneByteSerialTypeLen(tls, uint8(**(**Tu32)(__ccgo_up(bp + 80))))) + } else { + zHdr = zHdr + uintptr(_sqlite3GetVarint32(tls, zHdr, bp+80)) + *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(i1)*4)) = **(**Tu32)(__ccgo_up(bp + 80)) + offset64 = offset64 + uint64(_sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 80)))) + } + i1 = i1 + 1 + v190 = i1 + **(**Tu32)(__ccgo_up(aOffset + uintptr(v190)*4)) = uint32(offset64 & libc.Uint64FromUint32(0xffffffff)) + } + /* The record is corrupt if any of the following are true: + ** (1) the bytes of the header extend past the declared header size + ** (2) the entire header was used but not all data was used + ** (3) the end of the data extends beyond the end of the record. + */ + if zHdr >= zEndHdr && (zHdr > zEndHdr || offset64 != uint64((*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize)) || offset64 > uint64((*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize) { + if **(**Tu32)(__ccgo_up(aOffset)) == uint32(0) { + i1 = 0 + zHdr = zEndHdr + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + _sqlite3VdbeMemRelease(tls, bp+24) + } + goto op_column_corrupt + } + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = libc.Uint16FromInt32(i1) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = libc.Uint32FromInt64(int64(zHdr) - int64(zData)) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + _sqlite3VdbeMemRelease(tls, bp+24) + } + goto _222 + _221: + ; + **(**Tu32)(__ccgo_up(bp + 80)) = uint32(0) + _222: + ; + /* If after trying to extract new entries from the header, nHdrParsed is + ** still not up to p2, that means that the record has fewer than p2 + ** columns. So the result will be either the default value or a NULL. + */ + if uint32((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22 { + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(11) { + _sqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16)), int32(MEM_Static)) + } else { + _sqlite3VdbeMemSetNull(tls, pDest) + } + goto op_column_out + } + goto _220 + _219: + ; + **(**Tu32)(__ccgo_up(bp + 80)) = *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(p22)*4)) + _220: + ; + /* Extract the content for the p2+1-th column. Control can only + ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are + ** all valid. + */ + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pDest)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _sqlite3VdbeMemSetNull(tls, pDest) + } + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow >= **(**Tu32)(__ccgo_up(aOffset + uintptr(p22+uint32(1))*4)) { + /* This is the common case where the desired content fits on the original + ** page - where the content is not on an overflow page */ + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + uintptr(**(**Tu32)(__ccgo_up(aOffset + uintptr(p22)*4))) + if **(**Tu32)(__ccgo_up(bp + 80)) < uint32(12) { + _sqlite3VdbeSerialGet(tls, zData, **(**Tu32)(__ccgo_up(bp + 80)), pDest) + } else { + v190 = libc.Int32FromUint32((**(**Tu32)(__ccgo_up(bp + 80)) - libc.Uint32FromInt32(12)) / libc.Uint32FromInt32(2)) + len1 = v190 + (*TMem)(unsafe.Pointer(pDest)).Fn = v190 + (*TMem)(unsafe.Pointer(pDest)).Fenc = encoding + if (*TMem)(unsafe.Pointer(pDest)).FszMalloc < len1+int32(2) { + if len1 > **(**int32)(__ccgo_up(db + 136)) { + goto too_big + } + (*TMem)(unsafe.Pointer(pDest)).Fflags = uint16(MEM_Null) + if _sqlite3VdbeMemGrow(tls, pDest, len1+int32(2), 0) != 0 { + goto no_mem + } + } else { + (*TMem)(unsafe.Pointer(pDest)).Fz = (*TMem)(unsafe.Pointer(pDest)).FzMalloc + } + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pDest)).Fz, zData, libc.Uint64FromInt32(len1)) + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1))) = uint8(0) + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1+int32(1)))) = uint8(0) + (*TMem)(unsafe.Pointer(pDest)).Fflags = _aFlag1[**(**Tu32)(__ccgo_up(bp + 80))&uint32(1)] + } + } else { + (*TMem)(unsafe.Pointer(pDest)).Fenc = encoding + /* This branch happens only when content is on overflow pages */ + v227 = libc.Uint8FromInt32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) & libc.Int32FromInt32(OPFLAG_BYTELENARG)) + p5 = v227 + if libc.Int32FromUint8(v227) != 0 && (libc.Int32FromUint8(p5) == int32(OPFLAG_TYPEOFARG) || **(**Tu32)(__ccgo_up(bp + 80)) >= uint32(12) && (**(**Tu32)(__ccgo_up(bp + 80))&uint32(1) == uint32(0) || libc.Int32FromUint8(p5) == int32(OPFLAG_BYTELENARG))) || _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 80))) == uint32(0) { + /* Content is irrelevant for + ** 1. the typeof() function, + ** 2. the length(X) function if X is a blob, and + ** 3. if the content length is zero. + ** So we might as well use bogus content rather than reading + ** content from disk. + ** + ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the + ** buffer passed to it, debugging function VdbeMemPrettyPrint() may + ** read more. Use the global constant sqlite3CtypeMap[] as the array, + ** as that array is 256 bytes long (plenty for VdbeMemPrettyPrint()) + ** and it begins with a bunch of zeros. + */ + _sqlite3VdbeSerialGet(tls, uintptr(unsafe.Pointer(&_sqlite3CtypeMap)), **(**Tu32)(__ccgo_up(bp + 80)), pDest) + } else { + rc = _vdbeColumnFromOverflow(tls, pC3, libc.Int32FromUint32(p22), **(**Tu32)(__ccgo_up(bp + 80)), libc.Int64FromUint32(**(**Tu32)(__ccgo_up(aOffset + uintptr(p22)*4))), (*TVdbe)(unsafe.Pointer(p)).FcacheCtr, colCacheCtr, pDest) + if rc != 0 { + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + if rc == int32(SQLITE_TOOBIG) { + goto too_big + } + goto abort_due_to_error + } + } + } + goto op_column_out + op_column_out: + ; + goto _189 + goto op_column_corrupt + op_column_corrupt: + ; + if (**(**TOp)(__ccgo_up(aOp))).Fp3 > 0 { + pOp = aOp + uintptr((**(**TOp)(__ccgo_up(aOp))).Fp3-int32(1))*24 + goto _189 + } else { + rc = _sqlite3CorruptError(tls, int32(99741)) + goto abort_due_to_error + } + /* Opcode: TypeCheck P1 P2 P3 P4 * + ** Synopsis: typecheck(r[P1@P2]) + ** + ** Apply affinities to the range of P2 registers beginning with P1. + ** Take the affinities from the Table object in P4. If any value + ** cannot be coerced into the correct type, then raise an error. + ** + ** If P3==0, then omit checking of VIRTUAL columns. + ** + ** If P3==1, then omit checking of all generated column, both VIRTUAL + ** and STORED. + ** + ** If P3>=2, then only check column number P3-2 in the table (which will + ** be a VIRTUAL column) against the value in reg[P1]. In this case, + ** P2 will be 1. + ** + ** This opcode is similar to OP_Affinity except that this opcode + ** forces the register type to the Table column type. This is used + ** to implement "strict affinity". + ** + ** GENERATED ALWAYS AS ... STATIC columns are only checked if P3 + ** is zero. When P3 is non-zero, no type checking occurs for + ** static generated columns. Virtual columns are computed at query time + ** and so they are never checked. + ** + ** Preconditions: + ** + **
      + **
    • P2 should be the number of non-virtual columns in the + ** table of P4 unless P3>1, in which case P2 will be 1. + **
    • Table P4 is a STRICT table. + **
    + ** + ** If any precondition is false, an assertion fault occurs. + */ + _66: + ; + pTab = *(*uintptr)(unsafe.Pointer(pOp + 16)) + aCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*TOp)(unsafe.Pointer(pOp)).Fp3 < int32(2) { + i2 = 0 + nCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + i2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 - int32(2) + nCol = i2 + int32(1) + } + for { + if !(i2 < nCol) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 && (*TOp)(unsafe.Pointer(pOp)).Fp3 < int32(2) { + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + goto _228 + } + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + pIn1 += 56 + goto _228 + } + } + _applyAffinity(tls, pIn1, (**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).Faffinity, encoding) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + switch int32(uint32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 8)) & 0xf0 >> 4)) { + case int32(COLTYPE_BLOB): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_INTEGER): + fallthrough + case int32(COLTYPE_INT): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Int) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_TEXT): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Str) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_REAL): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Int) != 0 { + /* When applying REAL affinity, if the result is still an MEM_Int + ** that will fit in 6 bytes, then change the type to MEM_IntReal + ** so that we keep the high-resolution integer value but know that + ** the type really wants to be REAL. */ + if *(*Ti64)(unsafe.Pointer(pIn1)) <= int64(140737488355327) && *(*Ti64)(unsafe.Pointer(pIn1)) >= -int64(140737488355328) { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } else { + *(*float64)(unsafe.Pointer(pIn1)) = float64(*(*Ti64)(unsafe.Pointer(pIn1))) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + goto vdbe_type_error + } + } + default: + /* COLTYPE_ANY. Accept anything. */ + break + } + } + pIn1 += 56 + goto _228 + _228: + ; + i2 = i2 + 1 + } + goto _189 + goto vdbe_type_error + vdbe_type_error: + ; + _sqlite3VdbeError(tls, p, __ccgo_ts+5884, libc.VaList(bp+984, _vdbeMemTypeName(tls, pIn1), _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 8))&0xf0>>4))-int32(1)], (*TTable)(unsafe.Pointer(pTab)).FzName, (**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FzCnName)) + rc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(12)<= -int64(140737488355328) { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } else { + *(*float64)(unsafe.Pointer(pIn1)) = float64(*(*Ti64)(unsafe.Pointer(pIn1))) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Str))) + } + } + zAffinity = zAffinity + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zAffinity))) == 0 { + break + } + pIn1 += 56 + } + goto _189 + /* Opcode: MakeRecord P1 P2 P3 P4 * + ** Synopsis: r[P3]=mkrec(r[P1@P2]) + ** + ** Convert P2 registers beginning with P1 into the [record format] + ** use as a data record in a database table or as a key + ** in an index. The OP_Column opcode can decode the record later. + ** + ** P4 may be a string that is P2 characters long. The N-th character of the + ** string indicates the column affinity that should be used for the N-th + ** field of the index key. + ** + ** The mapping from character to affinity is given by the SQLITE_AFF_ + ** macros defined in sqliteInt.h. + ** + ** If P4 is NULL then all index fields have the affinity BLOB. + ** + ** The meaning of P5 depends on whether or not the SQLITE_ENABLE_NULL_TRIM + ** compile-time option is enabled: + ** + ** * If SQLITE_ENABLE_NULL_TRIM is enabled, then the P5 is the index + ** of the right-most table that can be null-trimmed. + ** + ** * If SQLITE_ENABLE_NULL_TRIM is omitted, then P5 has the value + ** OPFLAG_NOCHNG_MAGIC if the OP_MakeRecord opcode is allowed to + ** accept no-change records with serial_type 10. This value is + ** only used inside an assert() and does not affect the end result. + */ + _68: + ; /* Where to write next byte of the payload */ + /* Assuming the record contains N fields, the record format looks + ** like this: + ** + ** ------------------------------------------------------------------------ + ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | + ** ------------------------------------------------------------------------ + ** + ** Data(0) is taken from register P1. Data(1) comes from register P1+1 + ** and so forth. + ** + ** Each type field is a varint representing the serial type of the + ** corresponding data element (see sqlite3VdbeSerialType()). The + ** hdr-size field is also a varint which is the offset from the beginning + ** of the record to data0. + */ + nData = uint64(0) /* Number of bytes of data space */ + nHdr = 0 /* Number of bytes of header space */ + nZero = 0 /* Number of zero bytes at the end of the record */ + nField = (*TOp)(unsafe.Pointer(pOp)).Fp1 + zAffinity1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pData0 = aMem + uintptr(nField)*56 + nField = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pLast = pData0 + uintptr(nField-int32(1))*56 + /* Identify the output register */ + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + /* Apply the requested affinity to all inputs + */ + if zAffinity1 != 0 { + pRec = pData0 + for cond := true; cond; cond = **(**uint8)(__ccgo_up(zAffinity1)) != 0 { + _applyAffinity(tls, pRec, **(**uint8)(__ccgo_up(zAffinity1)), encoding) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zAffinity1))) == int32(SQLITE_AFF_REAL) && libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Int) != 0 { + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } + zAffinity1 = zAffinity1 + 1 + pRec += 56 + } + } + /* Loop through the elements that will make up the record to figure + ** out how much space is required for the new record. After this loop, + ** the Mem.uTemp field of each term should hold the serial-type that will + ** be used for that term in the generated record: + ** + ** Mem.uTemp value type + ** --------------- --------------- + ** 0 NULL + ** 1 1-byte signed integer + ** 2 2-byte signed integer + ** 3 3-byte signed integer + ** 4 4-byte signed integer + ** 5 6-byte signed integer + ** 6 8-byte signed integer + ** 7 IEEE float + ** 8 Integer constant 0 + ** 9 Integer constant 1 + ** 10,11 reserved for expansion + ** N>=12 and even BLOB + ** N>=13 and odd text + ** + ** The following additional values are computed: + ** nHdr Number of bytes needed for the record header + ** nData Number of bytes of data space needed for the record + ** nZero Zero bytes at the end of the record + */ + pRec = pLast + for cond := true; cond; cond = int32(1) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Null) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Zero) != 0 { + /* Values with MEM_Null and MEM_Zero are created by xColumn virtual + ** table methods that never invoke sqlite3_result_xxxxx() while + ** computing an unchanging column value in an UPDATE statement. + ** Give such values a special internal-use-only serial-type of 10 + ** so that they can be passed through to xUpdate and have + ** a true sqlite3_value_nochange(). */ + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(10) + } else { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(0) + } + nHdr = nHdr + 1 + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */ + i3 = *(*Ti64)(unsafe.Pointer(pRec)) + if i3 < 0 { + uu = libc.Uint64FromInt64(^i3) + } else { + uu = libc.Uint64FromInt64(i3) + } + nHdr = nHdr + 1 + if uu <= uint64(127) { + if i3&int64(1) == i3 && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat) >= int32(4) { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(8) + uint32(uu) + } else { + nData = nData + 1 + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(1) + } + } else { + if uu <= uint64(32767) { + nData = nData + uint64(2) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(2) + } else { + if uu <= uint64(8388607) { + nData = nData + uint64(3) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(3) + } else { + if uu <= uint64(2147483647) { + nData = nData + uint64(4) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(4) + } else { + if uu <= uint64(140737488355327) { + nData = nData + uint64(6) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(5) + } else { + nData = nData + uint64(8) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_IntReal) != 0 { + /* If the value is IntReal and is going to take up 8 bytes to store + ** as an integer, then we might as well make it an 8-byte floating + ** point value */ + *(*float64)(unsafe.Pointer(pRec)) = float64(*(*Ti64)(unsafe.Pointer(pRec))) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_IntReal)) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(7) + } else { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(6) + } + } + } + } + } + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Real) != 0 { + nHdr = nHdr + 1 + nData = nData + uint64(8) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(7) + } else { + len11 = libc.Uint32FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn) + serial_type = len11*uint32(2) + uint32(12) + libc.BoolUint32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&libc.Int32FromInt32(MEM_Str) != libc.Int32FromInt32(0)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Zero) != 0 { + serial_type = serial_type + libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu)))*uint32(2) + if nData != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pRec) != 0 { + goto no_mem + } + len11 = len11 + libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu))) + } else { + nZero = nZero + int64(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu))) + } + } + nData = nData + uint64(len11) + nHdr = nHdr + _sqlite3VarintLen(tls, uint64(serial_type)) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = serial_type + } + } + } + if pRec == pData0 { + break + } + pRec -= 56 + } + /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint + ** which determines the total number of bytes in the header. The varint + ** value is the size of the header in bytes including the size varint + ** itself. */ + if nHdr <= int32(126) { + /* The common case */ + nHdr = nHdr + int32(1) + } else { + /* Rare case of a really large header */ + nVarint = _sqlite3VarintLen(tls, libc.Uint64FromInt32(nHdr)) + nHdr = nHdr + nVarint + if nVarint < _sqlite3VarintLen(tls, libc.Uint64FromInt32(nHdr)) { + nHdr = nHdr + 1 + } + } + nByte1 = libc.Int64FromUint64(libc.Uint64FromInt32(nHdr) + nData) + /* Make sure the output register has a buffer large enough to store + ** the new record. The output register (pOp->p3) is not allowed to + ** be one of the input registers (because the following call to + ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used). + */ + if nByte1+nZero <= int64((*TMem)(unsafe.Pointer(pOut)).FszMalloc) { + /* The output register is already large enough to hold the record. + ** No error checks or buffer enlargement is required */ + (*TMem)(unsafe.Pointer(pOut)).Fz = (*TMem)(unsafe.Pointer(pOut)).FzMalloc + } else { + /* Need to make sure that the output is not too big and then enlarge + ** the output register to hold the full result */ + if nByte1+nZero > int64(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + if _sqlite3VdbeMemClearAndResize(tls, pOut, int32(nByte1)) != 0 { + goto no_mem + } + } + (*TMem)(unsafe.Pointer(pOut)).Fn = int32(nByte1) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Blob) + if nZero != 0 { + *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pOut)).Fu)) = int32(nZero) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Zero)) + } + zHdr1 = (*TMem)(unsafe.Pointer(pOut)).Fz + zPayload = zHdr1 + uintptr(nHdr) + /* Write the record */ + if nHdr < int32(0x80) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = libc.Uint8FromInt32(nHdr) + } else { + zHdr1 = zHdr1 + uintptr(_sqlite3PutVarint(tls, zHdr1, libc.Uint64FromInt32(nHdr))) + } + pRec = pData0 + for int32(1) != 0 { + serial_type = (*TMem)(unsafe.Pointer(pRec)).FuTemp + /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more + ** additional varints, one per column. + ** EVIDENCE-OF: R-64536-51728 The values for each column in the record + ** immediately follow the header. */ + if serial_type <= uint32(7) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = uint8(serial_type) + if serial_type == uint32(0) { + /* NULL value. No change in zPayload */ + } else { + if serial_type == uint32(7) { + libc.Xmemcpy(tls, bp+88, pRec, uint64(8)) + } else { + **(**Tu64)(__ccgo_up(bp + 88)) = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(pRec))) + } + len11 = uint32(_sqlite3SmallTypeSizes[serial_type]) + switch len11 { + default: + **(**Tu8)(__ccgo_up(zPayload + 7)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + **(**Tu8)(__ccgo_up(zPayload + 6)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(6): + **(**Tu8)(__ccgo_up(zPayload + 5)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + **(**Tu8)(__ccgo_up(zPayload + 4)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(4): + **(**Tu8)(__ccgo_up(zPayload + 3)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(3): + **(**Tu8)(__ccgo_up(zPayload + 2)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(2): + **(**Tu8)(__ccgo_up(zPayload + 1)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(1): + **(**Tu8)(__ccgo_up(zPayload)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + } + zPayload = zPayload + uintptr(len11) + } + } else { + if serial_type < uint32(0x80) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = uint8(serial_type) + if serial_type >= uint32(14) && (*TMem)(unsafe.Pointer(pRec)).Fn > 0 { + libc.Xmemcpy(tls, zPayload, (*TMem)(unsafe.Pointer(pRec)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn)) + zPayload = zPayload + uintptr((*TMem)(unsafe.Pointer(pRec)).Fn) + } + } else { + zHdr1 = zHdr1 + uintptr(_sqlite3PutVarint(tls, zHdr1, uint64(serial_type))) + if (*TMem)(unsafe.Pointer(pRec)).Fn != 0 { + libc.Xmemcpy(tls, zPayload, (*TMem)(unsafe.Pointer(pRec)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn)) + zPayload = zPayload + uintptr((*TMem)(unsafe.Pointer(pRec)).Fn) + } + } + } + if pRec == pLast { + break + } + pRec += 56 + } + goto _189 + /* Opcode: Count P1 P2 P3 * * + ** Synopsis: r[P2]=count() + ** + ** Store the number of entries (an integer value) in the table or index + ** opened by cursor P1 in register P2. + ** + ** If P3==0, then an exact count is obtained, which involves visiting + ** every btree page of the table. But if P3 is non-zero, an estimate + ** is returned based on the current cursor position. + */ + _69: + ; + pCrsr1 = *(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + 48)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + **(**Ti64)(__ccgo_up(bp + 96)) = _sqlite3BtreeRowCountEst(tls, pCrsr1) + } else { + **(**Ti64)(__ccgo_up(bp + 96)) = 0 /* Not needed. Only used to silence a warning. */ + rc = _sqlite3BtreeCount(tls, db, pCrsr1, bp+96) + if rc != 0 { + goto abort_due_to_error + } + } + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 96)) + goto check_for_interrupt + /* Opcode: Savepoint P1 * * P4 * + ** + ** Open, release or rollback the savepoint named by parameter P4, depending + ** on the value of P1. To open a new savepoint set P1==0 (SAVEPOINT_BEGIN). + ** To release (commit) an existing savepoint set P1==1 (SAVEPOINT_RELEASE). + ** To rollback an existing savepoint set P1==2 (SAVEPOINT_ROLLBACK). + */ + _70: + ; + p12 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + zName = *(*uintptr)(unsafe.Pointer(pOp + 16)) + /* Assert that the p1 parameter is valid. Also that if there is no open + ** transaction, then there cannot be any savepoints. + */ + if p12 == SAVEPOINT_BEGIN { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 { + /* A new savepoint cannot be created if there are active write + ** statements (i.e. open read/write incremental blob handles). + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+5925, 0) + rc = int32(SQLITE_BUSY) + } else { + nName = _sqlite3Strlen30(tls, zName) + /* This call is Ok even if this savepoint is actually a transaction + ** savepoint (and therefore should not prompt xSavepoint()) callbacks. + ** If this is a transaction savepoint being opened, it is guaranteed + ** that the db->aVTrans[] array is empty. */ + rc = _sqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*Tsqlite3)(unsafe.Pointer(db)).FnStatement+(*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint) + if rc != SQLITE_OK { + goto abort_due_to_error + } + /* Create a new savepoint structure. */ + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(32)+libc.Uint64FromInt32(nName)+uint64(1))) + if pNew != 0 { + (*TSavepoint)(unsafe.Pointer(pNew)).FzName = pNew + 1*32 + libc.Xmemcpy(tls, (*TSavepoint)(unsafe.Pointer(pNew)).FzName, zName, libc.Uint64FromInt32(nName+int32(1))) + /* If there is no open transaction, then mark this as a special + ** "transaction savepoint". */ + if (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(1) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + 1 + } + /* Link the new savepoint into the database handle's list. */ + (*TSavepoint)(unsafe.Pointer(pNew)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint + (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint = pNew + (*TSavepoint)(unsafe.Pointer(pNew)).FnDeferredCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons + (*TSavepoint)(unsafe.Pointer(pNew)).FnDeferredImmCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons + } + } + } else { + iSavepoint = 0 + /* Find the named savepoint. If there is no such savepoint, then an + ** an error is returned to the user. */ + pSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint + for { + if !(pSavepoint != 0 && _sqlite3StrICmp(tls, (*TSavepoint)(unsafe.Pointer(pSavepoint)).FzName, zName) != 0) { + break + } + iSavepoint = iSavepoint + 1 + goto _245 + _245: + ; + pSavepoint = (*TSavepoint)(unsafe.Pointer(pSavepoint)).FpNext + } + if !(pSavepoint != 0) { + _sqlite3VdbeError(tls, p, __ccgo_ts+5976, libc.VaList(bp+984, zName)) + rc = int32(SQLITE_ERROR) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 && p12 == int32(SAVEPOINT_RELEASE) { + /* It is not possible to release (commit) a savepoint if there are + ** active write statements. + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+5998, 0) + rc = int32(SQLITE_BUSY) + } else { + /* Determine whether or not this is a transaction savepoint. If so, + ** and this is a RELEASE command, then the current transaction + ** is committed. + */ + isTransaction = libc.BoolInt32((*TSavepoint)(unsafe.Pointer(pSavepoint)).FpNext == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint != 0) + if isTransaction != 0 && p12 == int32(SAVEPOINT_RELEASE) { + v190 = _sqlite3VdbeCheckFkDeferred(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto vdbe_return + } + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(1) + if _sqlite3VdbeHalt(tls, p) == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + v190 = libc.Int32FromInt32(SQLITE_BUSY) + rc = v190 + (*TVdbe)(unsafe.Pointer(p)).Frc = v190 + goto vdbe_return + } + rc = (*TVdbe)(unsafe.Pointer(p)).Frc + if rc != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(0) + } + } else { + iSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint - iSavepoint - int32(1) + if p12 == int32(SAVEPOINT_ROLLBACK) { + isSchemaChange = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_SchemaChange) != uint32(0)) + ii = 0 + for { + if !(ii < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + rc = _sqlite3BtreeTripAllCursors(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii)*32))).FpBt, libc.Int32FromInt32(SQLITE_ABORT)|libc.Int32FromInt32(2)< 0 { + /* If this instruction implements a COMMIT and other VMs are writing + ** return an error indicating that the other VMs must complete first. + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+6052, 0) + rc = int32(SQLITE_BUSY) + goto abort_due_to_error + } else { + v190 = _sqlite3VdbeCheckFkDeferred(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto vdbe_return + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = libc.Uint8FromInt32(desiredAutoCommit) + } + } + } + if _sqlite3VdbeHalt(tls, p) == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = libc.Uint8FromInt32(libc.Int32FromInt32(1) - desiredAutoCommit) + v190 = libc.Int32FromInt32(SQLITE_BUSY) + rc = v190 + (*TVdbe)(unsafe.Pointer(p)).Frc = v190 + goto vdbe_return + } + _sqlite3CloseSavepoints(tls, db) + if (*TVdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rc = int32(SQLITE_DONE) + } else { + rc = int32(SQLITE_ERROR) + } + goto vdbe_return + } else { + if !(desiredAutoCommit != 0) { + v191 = __ccgo_ts + 6107 + } else { + if iRollback != 0 { + v194 = __ccgo_ts + 6155 + } else { + v194 = __ccgo_ts + 6198 + } + v191 = v194 + } + _sqlite3VdbeError(tls, p, v191, 0) + rc = int32(SQLITE_ERROR) + goto abort_due_to_error + } + /* Opcode: Transaction P1 P2 P3 P4 P5 + ** + ** Begin a transaction on database P1 if a transaction is not already + ** active. + ** If P2 is non-zero, then a write-transaction is started, or if a + ** read-transaction is already active, it is upgraded to a write-transaction. + ** If P2 is zero, then a read-transaction is started. If P2 is 2 or more + ** then an exclusive transaction is started. + ** + ** P1 is the index of the database file on which the transaction is + ** started. Index 0 is the main database file and index 1 is the + ** file used for temporary tables. Indices of 2 or more are used for + ** attached databases. + ** + ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is + ** true (this flag is set if the Vdbe may modify more than one row and may + ** throw an ABORT exception), a statement transaction may also be opened. + ** More specifically, a statement transaction is opened iff the database + ** connection is currently not in autocommit mode, or if there are other + ** active statements. A statement transaction allows the changes made by this + ** VDBE to be rolled back after an error without having to roll back the + ** entire transaction. If no error is encountered, the statement transaction + ** will automatically commit when the VDBE halts. + ** + ** If P5!=0 then this opcode also checks the schema cookie against P3 + ** and the schema generation counter against P4. + ** The cookie changes its value whenever the database schema changes. + ** This operation is used to detect when that the cookie has changed + ** and that the current process needs to reread the schema. If the schema + ** cookie in P3 differs from the schema cookie in the database header or + ** if the schema generation counter in P4 differs from the current + ** generation counter, then an SQLITE_SCHEMA error is raised and execution + ** halts. The sqlite3_step() wrapper function might then reprepare the + ** statement and rerun it from the beginning. + */ + _72: + ; + **(**int32)(__ccgo_up(bp + 104)) = 0 + if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(SQLITE_QueryOnly)|libc.Uint64FromInt32(libc.Int32FromInt32(0x00002))<>5)) != 0 && (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 && (libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 || (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1)) { + if (*TVdbe)(unsafe.Pointer(p)).FiStatement == 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnStatement + 1 + (*TVdbe)(unsafe.Pointer(p)).FiStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement + } + rc = _sqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*TVdbe)(unsafe.Pointer(p)).FiStatement-int32(1)) + if rc == SQLITE_OK { + rc = _sqlite3BtreeBeginStmt(tls, pBt, (*TVdbe)(unsafe.Pointer(p)).FiStatement) + } + /* Store the current value of the database handles deferred constraint + ** counter. If the statement transaction needs to be rolled back, + ** the value of this counter needs to be restored too. */ + (*TVdbe)(unsafe.Pointer(p)).FnStmtDefCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons + (*TVdbe)(unsafe.Pointer(p)).FnStmtDefImmCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons + } + } + if rc == SQLITE_OK && (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 && (**(**int32)(__ccgo_up(bp + 104)) != (*TOp)(unsafe.Pointer(pOp)).Fp3 || (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FiGeneration != (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) { + /* + ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema + ** version is checked to ensure that the schema has not changed since the + ** SQL statement was prepared. + */ + _sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg) + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3DbStrDup(tls, db, __ccgo_ts+6239) + /* If the schema-cookie from the database file matches the cookie + ** stored with the in-memory representation of the schema, do + ** not reload the schema from the database file. + ** + ** If virtual-tables are in use, this is not just an optimization. + ** Often, v-tables store their data in other SQLite tables, which + ** are queried from within xNext() and other v-table methods using + ** prepared queries. If such a query is out-of-date, we do not want to + ** discard the database schema, as the user code implementing the + ** v-table would have to be ready for the sqlite3_vtab structure itself + ** to be invalidated whenever sqlite3_step() is called from within + ** a v-table method. + */ + if (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpSchema)).Fschema_cookie != **(**int32)(__ccgo_up(bp + 104)) { + _sqlite3ResetOneSchema(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + } + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 0, 0x3) + rc = int32(SQLITE_SCHEMA) + /* Set changeCntOn to 0 to prevent the value returned by sqlite3_changes() + ** from being modified in sqlite3VdbeHalt(). If this statement is + ** reprepared, changeCntOn will be set again. */ + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 4, 0x10) + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: ReadCookie P1 P2 P3 * * + ** + ** Read cookie number P3 from database P1 and write it into register P2. + ** P3==1 is the schema version. P3==2 is the database format. + ** P3==3 is the recommended pager cache size, and so forth. P1==0 is + ** the main database file and P1==1 is the database file used to store + ** temporary tables. + ** + ** There must be a read-lock on the database (either a transaction + ** must be started or there must be an open cursor) before + ** executing this instruction. + */ + _73: + ; + iDb = (*TOp)(unsafe.Pointer(pOp)).Fp1 + iCookie = (*TOp)(unsafe.Pointer(pOp)).Fp3 + _sqlite3BtreeGetMeta(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt, iCookie, bp+108) + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = int64(**(**int32)(__ccgo_up(bp + 108))) + goto _189 + /* Opcode: SetCookie P1 P2 P3 * P5 + ** + ** Write the integer value P3 into cookie number P2 of database P1. + ** P2==1 is the schema version. P2==2 is the database format. + ** P2==3 is the recommended pager cache + ** size, and so forth. P1==0 is the main database file and P1==1 is the + ** database file used to store temporary tables. + ** + ** A transaction must be started before executing this opcode. + ** + ** If P2 is the SCHEMA_VERSION cookie (cookie number 1) then the internal + ** schema version is set to P3-P5. The "PRAGMA schema_version=N" statement + ** has P5 set to 1, so that the internal schema version will be different + ** from the database schema version, resulting in a schema reset. + */ + _74: + ; + pDb1 = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32 + /* See note about index shifting on OP_ReadCookie */ + rc = _sqlite3BtreeUpdateMeta(tls, (*TDb)(unsafe.Pointer(pDb1)).FpBt, (*TOp)(unsafe.Pointer(pOp)).Fp2, libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3)) + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == int32(BTREE_SCHEMA_VERSION) { + /* When the schema cookie changes, record the new cookie internally */ + **(**Tu32)(__ccgo_up((*TDb)(unsafe.Pointer(pDb1)).FpSchema)) = **(**Tu32)(__ccgo_up(pOp + 12)) - uint32((*TOp)(unsafe.Pointer(pOp)).Fp5) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + _sqlite3FkClearTriggerCache(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + } else { + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == int32(BTREE_FILE_FORMAT) { + /* Record changes in the file format */ + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb1)).FpSchema)).Ffile_format = libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 == int32(1) { + /* Invalidate all prepared statements whenever the TEMP database + ** schema is changed. Ticket #1644 */ + _sqlite3ExpirePreparedStatements(tls, db, 0) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: OpenRead P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** Open a read-only cursor for the database table whose root page is + ** P2 in a database file. The database file is determined by P3. + ** P3==0 means the main database, P3==1 means the database used for + ** temporary tables, and P3>1 means used the corresponding attached + ** database. Give the new cursor an identifier of P1. The P1 + ** values need not be contiguous but all P1 values should be small integers. + ** It is an error for P1 to be negative. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** object, then table being opened must be an [index b-tree] where the + ** KeyInfo object defines the content and collating + ** sequence of that index b-tree. Otherwise, if P4 is an integer + ** value, then the table being opened must be a [table b-tree] with a + ** number of columns no less than the value of P4. + ** + ** See also: OpenWrite, ReopenIdx + */ + /* Opcode: ReopenIdx P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** The ReopenIdx opcode works like OP_OpenRead except that it first + ** checks to see if the cursor on P1 is already open on the same + ** b-tree and if it is this opcode becomes a no-op. In other words, + ** if the cursor is already open, do not reopen it. + ** + ** The ReopenIdx opcode may only be used with P5==0 or P5==OPFLAG_SEEKEQ + ** and with P4 being a P4_KEYINFO object. Furthermore, the P3 value must + ** be the same as every other ReopenIdx or OpenRead for the same cursor + ** number. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    + ** + ** See also: OP_OpenRead, OP_OpenWrite + */ + /* Opcode: OpenWrite P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** Open a read/write cursor named P1 on the table or index whose root + ** page is P2 (or whose root page is held in register P2 if the + ** OPFLAG_P2ISREG bit is set in P5 - see below). + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** object, then table being opened must be an [index b-tree] where the + ** KeyInfo object defines the content and collating + ** sequence of that index b-tree. Otherwise, if P4 is an integer + ** value, then the table being opened must be a [table b-tree] with a + ** number of columns no less than the value of P4. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    • 0x08 OPFLAG_FORDELETE: This cursor is used only to seek + ** and subsequently delete entries in an index btree. This is a + ** hint to the storage engine that the storage engine is allowed to + ** ignore. The hint is not used by the official SQLite b*tree storage + ** engine, but is used by COMDB2. + **
    • 0x10 OPFLAG_P2ISREG: Use the content of register P2 + ** as the root page, not the value of P2 itself. + **
    + ** + ** This instruction works like OpenRead except that it opens the cursor + ** in read/write mode. + ** + ** See also: OP_OpenRead, OP_ReopenIdx + */ + _77: + ; + pCur = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCur != 0 && (*TVdbeCursor)(unsafe.Pointer(pCur)).FpgnoRoot == libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) { + /* Guaranteed by the code generator */ + _sqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pCur + 48))) + goto open_cursor_set_hints + } + /* If the cursor is not currently open or is open on a different + ** index, then fall through into OP_OpenRead to force a reopen */ + _76: + ; /* ncycle */ + _75: + ; + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x3>>0)) == int32(1) { + rc = libc.Int32FromInt32(SQLITE_ABORT) | libc.Int32FromInt32(2)<>2))), 2, 0x4) + *(*uintptr)(unsafe.Pointer(pCx + 16)) = *(*uintptr)(unsafe.Pointer(pOrig + 16)) + libc.SetBitFieldPtr8Uint32(pCx+8, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(pOrig+8, libc.Uint32FromInt32(1), 3, 0x8) + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx + 16)), (*TVdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, int32(BTREE_WRCSR), (*TVdbeCursor)(unsafe.Pointer(pCx)).FpKeyInfo, *(*uintptr)(unsafe.Pointer(pCx + 48))) + /* The sqlite3BtreeCursor() routine can only fail for the first cursor + ** opened for a database. Since there is already an open cursor when this + ** opcode is run, the sqlite3BtreeCursor() cannot fail */ + goto _189 + /* Opcode: OpenEphemeral P1 P2 P3 P4 P5 + ** Synopsis: nColumn=P2 + ** + ** Open a new cursor P1 to a transient table. + ** The cursor is always opened read/write even if + ** the main database is read-only. The ephemeral + ** table is deleted automatically when the cursor is closed. + ** + ** If the cursor P1 is already opened on an ephemeral table, the table + ** is cleared (all content is erased). + ** + ** P2 is the number of columns in the ephemeral table. + ** The cursor points to a BTree table if P4==0 and to a BTree index + ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure + ** that defines the format of keys in the index. + ** + ** The P5 parameter can be a mask of the BTREE_* flags defined + ** in btree.h. These flags control aspects of the operation of + ** the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are + ** added automatically. + ** + ** If P3 is positive, then reg[P3] is modified slightly so that it + ** can be used as zero-length data for OP_Insert. This is an optimization + ** that avoids an extra OP_Blob opcode to initialize that register. + */ + /* Opcode: OpenAutoindex P1 P2 * P4 * + ** Synopsis: nColumn=P2 + ** + ** This opcode works the same as OP_OpenEphemeral. It has a + ** different name to distinguish its use. Tables created using + ** by this opcode will be used for automatically created transient + ** indices in joins. + */ + _80: + ; /* ncycle */ + _79: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp3 > 0 { + /* Make register reg[P3] into a value that can be used as the data + ** form sqlite3BtreeInsert() where the length of the data is zero. */ + /* Only used when number of columns is zero */ + (**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fn = 0 + (**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fz = __ccgo_ts + 1704 + } + pCx1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCx1 != 0 && !(int32(TBool(*(*uint8)(unsafe.Pointer(pCx1 + 8))&0x8>>3)) != 0) && (*TOp)(unsafe.Pointer(pOp)).Fp2 <= int32((*TVdbeCursor)(unsafe.Pointer(pCx1)).FnField) { + /* If the ephemeral table is already open and has no duplicates from + ** OP_OpenDup, then erase all existing content so that the table is + ** empty again, rather than creating a new table. */ + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FseqCount = 0 + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = uint32(CACHE_STALE) + rc = _sqlite3BtreeClearTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), libc.Int32FromUint32((*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot), uintptr(0)) + } else { + pCx1 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_BTREE)) + if pCx1 == uintptr(0) { + goto no_mem + } + libc.SetBitFieldPtr8Uint32(pCx1+8, libc.Uint32FromInt32(1), 0, 0x1) + rc = _sqlite3BtreeOpen(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, pCx1+16, libc.Int32FromInt32(BTREE_OMIT_JOURNAL)|libc.Int32FromInt32(BTREE_SINGLE)|libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5), _vfsFlags) + if rc == SQLITE_OK { + rc = _sqlite3BtreeBeginTrans(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), int32(1), uintptr(0)) + if rc == SQLITE_OK { + /* If a transient index is required, create it by calling + ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before + ** opening it. If a transient table is required, just use the + ** automatically created table with root-page 1 (an BLOB_INTKEY table). + */ + v194 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pKeyInfo2 = v194 + v191 = v194 + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpKeyInfo = v191 + if v191 != uintptr(0) { + rc = _sqlite3BtreeCreateTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), pCx1+68, int32(BTREE_BLOBKEY)|libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)) + if rc == SQLITE_OK { + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, int32(BTREE_WRCSR), pKeyInfo2, *(*uintptr)(unsafe.Pointer(pCx1 + 48))) + } + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FisTable = uint8(0) + } else { + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = uint32(SCHEMA_ROOT) + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), uint32(SCHEMA_ROOT), int32(BTREE_WRCSR), uintptr(0), *(*uintptr)(unsafe.Pointer(pCx1 + 48))) + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FisTable = uint8(1) + } + } + libc.SetBitFieldPtr8Uint32(pCx1+8, libc.BoolUint32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) != libc.Int32FromInt32(BTREE_UNORDERED)), 2, 0x4) + if rc != 0 { + _sqlite3BtreeClose(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16))) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) = uintptr(0) /* Not required; helps with static analysis */ + } else { + } + } + } + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FnullRow = uint8(1) + goto _189 + /* Opcode: SorterOpen P1 P2 P3 P4 * + ** + ** This opcode works like OP_OpenEphemeral except that it opens + ** a transient index that is specifically designed to sort large + ** tables using an external merge-sort algorithm. + ** + ** If argument P3 is non-zero, then it indicates that the sorter may + ** assume that a stable sort considering the first P3 fields of each + ** key is sufficient to produce the required results. + */ + _81: + ; + pCx2 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_SORTER)) + if pCx2 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pCx2)).FpKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) + rc = _sqlite3VdbeSorterInit(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp3, pCx2) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: SequenceTest P1 P2 * * * + ** Synopsis: if( cursor[P1].ctr++ ) pc = P2 + ** + ** P1 is a sorter cursor. If the sequence counter is currently zero, jump + ** to P2. Regardless of whether or not the jump is taken, increment the + ** the sequence value. + */ + _82: + ; + pC4 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + v191 = pC4 + 24 + v256 = *(*Ti64)(unsafe.Pointer(v191)) + *(*Ti64)(unsafe.Pointer(v191)) = *(*Ti64)(unsafe.Pointer(v191)) + 1 + if v256 == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: OpenPseudo P1 P2 P3 * * + ** Synopsis: P3 columns in r[P2] + ** + ** Open a new cursor that points to a fake table that contains a single + ** row of data. The content of that one row is the content of memory + ** register P2. In other words, cursor P1 becomes an alias for the + ** MEM_Blob content contained in register P2. + ** + ** A pseudo-table created by this opcode is used to hold a single + ** row output from the sorter so that the row can be decomposed into + ** individual columns using the OP_Column opcode. The OP_Column opcode + ** is the only cursor opcode that works with a pseudo-table. + ** + ** P3 is the number of fields in the records that will be stored by + ** the pseudo-table. If P2 is 0 or negative then the pseudo-cursor + ** will return NULL for every column. + */ + _83: + ; + pCx3 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp3, uint8(CURTYPE_PSEUDO)) + if pCx3 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FnullRow = uint8(1) + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FseekResult = (*TOp)(unsafe.Pointer(pOp)).Fp2 + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FisTable = uint8(1) + /* Give this pseudo-cursor a fake BtCursor pointer so that pCx + ** can be safely passed to sqlite3VdbeCursorMoveto(). This avoids a test + ** for pCx->eCurType==CURTYPE_BTREE inside of sqlite3VdbeCursorMoveto() + ** which is a performance optimization */ + *(*uintptr)(unsafe.Pointer(pCx3 + 48)) = _sqlite3BtreeFakeValidCursor(tls) + goto _189 + /* Opcode: Close P1 * * * * + ** + ** Close a cursor previously opened as P1. If P1 is not + ** currently open, this instruction is a no-op. + */ + _84: + ; /* ncycle */ + _sqlite3VdbeFreeCursor(tls, p, **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8))) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) = uintptr(0) + goto _189 + /* Opcode: SeekGE P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as the key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than or equal to the key value. If there are no records + ** greater than or equal to the key and P2 is not zero, then jump to P2. + ** + ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this + ** opcode will either land on a record that exactly matches the key, or + ** else it will cause a jump to P2. When the cursor is OPFLAG_SEEKEQ, + ** this opcode must be followed by an IdxLE opcode with the same arguments. + ** The IdxGT opcode will be skipped if this opcode succeeds, but the + ** IdxGT opcode will be used on subsequent loop iterations. The + ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this + ** is an equality search. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + ** + ** See also: Found, NotFound, SeekLt, SeekGt, SeekLe + */ + /* Opcode: SeekGT P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than the key value. If there are no records greater than + ** the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + ** + ** See also: Found, NotFound, SeekLt, SeekGe, SeekLe + */ + /* Opcode: SeekLT P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than the key value. If there are no records less than + ** the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + ** + ** See also: Found, NotFound, SeekGt, SeekGe, SeekLe + */ + /* Opcode: SeekLE P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than or equal to the key value. If there are no records + ** less than or equal to the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + ** + ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this + ** opcode will either land on a record that exactly matches the key, or + ** else it will cause a jump to P2. When the cursor is OPFLAG_SEEKEQ, + ** this opcode must be followed by an IdxLE opcode with the same arguments. + ** The IdxGE opcode will be skipped if this opcode succeeds, but the + ** IdxGE opcode will be used on subsequent loop iterations. The + ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this + ** is an equality search. + ** + ** See also: Found, NotFound, SeekGt, SeekGe, SeekLt + */ + _88: + ; /* jump0, in3, group, ncycle */ + _87: + ; /* jump0, in3, group, ncycle */ + _86: + ; /* jump0, in3, group, ncycle */ + _85: + ; /* Only interested in == results */ + pC5 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + oc = libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) + eqOnly = 0 + (*TVdbeCursor)(unsafe.Pointer(pC5)).FnullRow = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FcacheStatus = uint32(CACHE_STALE) + if (*TVdbeCursor)(unsafe.Pointer(pC5)).FisTable != 0 { + /* The OPFLAG_SEEKEQ/BTREE_SEEK_EQ flag is only set on index cursors */ + /* The input value in P3 might be of any type: integer, real, string, + ** blob, or NULL. But it needs to be an integer before we can do + ** the seek, so convert it. */ + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags31 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + if libc.Int32FromUint16(flags31)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn3, 0) + } + iKey = _sqlite3VdbeIntValue(tls, pIn3) /* Get the integer key value */ + newType = (*TMem)(unsafe.Pointer(pIn3)).Fflags /* Record the type after applying numeric affinity */ + (*TMem)(unsafe.Pointer(pIn3)).Fflags = flags31 /* But convert the type back to its original */ + /* If the P3 value could not be converted into an integer without + ** loss of information, then special processing is required... */ + if libc.Int32FromUint16(newType)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + if libc.Int32FromUint16(newType)&int32(MEM_Real) == 0 { + if libc.Int32FromUint16(newType)&int32(MEM_Null) != 0 || oc >= int32(OP_SeekGE) { + goto jump_to_p2 + } else { + rc = _sqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), bp+112) + if rc != SQLITE_OK { + goto abort_due_to_error + } + goto seek_not_found + } + } + c2 = _sqlite3IntFloatCompare(tls, iKey, *(*float64)(unsafe.Pointer(pIn3))) + /* If the approximation iKey is larger than the actual real search + ** term, substitute >= for > and < for <=. e.g. if the search term + ** is 4.9 and the integer approximation 5: + ** + ** (x > 4.9) -> (x >= 5) + ** (x <= 4.9) -> (x < 5) + */ + if c2 > 0 { + if oc&int32(0x0001) == libc.Int32FromInt32(OP_SeekGT)&libc.Int32FromInt32(0x0001) { + oc = oc - 1 + } + } else { + if c2 < 0 { + if oc&int32(0x0001) == libc.Int32FromInt32(OP_SeekLT)&libc.Int32FromInt32(0x0001) { + oc = oc + 1 + } + } + } + } + rc = _sqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), libc.Int64FromUint64(libc.Uint64FromInt64(iKey)), 0, bp+112) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FmovetoTarget = iKey /* Used by OP_Delete */ + if rc != SQLITE_OK { + goto abort_due_to_error + } + } else { + /* For a cursor with the OPFLAG_SEEKEQ/BTREE_SEEK_EQ hint, only the + ** OP_SeekGE and OP_SeekLE opcodes are allowed, and these must be + ** immediately followed by an OP_IdxGT or OP_IdxLT opcode, respectively, + ** with the same key. + */ + if _sqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), uint32(BTREE_SEEK_EQ)) != 0 { + eqOnly = int32(1) + } + nField2 = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC5)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FnField = libc.Uint16FromInt32(nField2) + /* The next line of code computes as follows, only faster: + ** if( oc==OP_SeekGT || oc==OP_SeekLE ){ + ** r.default_rc = -1; + ** }else{ + ** r.default_rc = +1; + ** } + */ + if int32(1)&(oc-int32(OP_SeekLT)) != 0 { + v190 = -int32(1) + } else { + v190 = +libc.Int32FromInt32(1) + } + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).Fdefault_rc = int8(v190) + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FeqSeen = uint8(0) + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), bp+120, bp+112) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if eqOnly != 0 && libc.Int32FromUint8((**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FeqSeen) == 0 { + goto seek_not_found + } + } + if oc >= int32(OP_SeekGE) { + if **(**int32)(__ccgo_up(bp + 112)) < 0 || **(**int32)(__ccgo_up(bp + 112)) == 0 && oc == int32(OP_SeekGT) { + **(**int32)(__ccgo_up(bp + 112)) = 0 + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), 0) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 112)) = int32(1) + } else { + goto abort_due_to_error + } + } + } else { + **(**int32)(__ccgo_up(bp + 112)) = 0 + } + } else { + if **(**int32)(__ccgo_up(bp + 112)) > 0 || **(**int32)(__ccgo_up(bp + 112)) == 0 && oc == int32(OP_SeekLT) { + **(**int32)(__ccgo_up(bp + 112)) = 0 + rc = _sqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), 0) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 112)) = int32(1) + } else { + goto abort_due_to_error + } + } + } else { + /* res might be negative because the table is empty. Check to + ** see if this is the case. + */ + **(**int32)(__ccgo_up(bp + 112)) = _sqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48))) + } + } + goto seek_not_found + seek_not_found: + ; + if **(**int32)(__ccgo_up(bp + 112)) != 0 { + goto jump_to_p2 + } else { + if eqOnly != 0 { + pOp += 24 /* Skip the OP_IdxLt or OP_IdxGT that follows */ + } + } + goto _189 + /* Opcode: SeekScan P1 P2 * * P5 + ** Synopsis: Scan-ahead up to P1 rows + ** + ** This opcode is a prefix opcode to OP_SeekGE. In other words, this + ** opcode must be immediately followed by OP_SeekGE. This constraint is + ** checked by assert() statements. + ** + ** This opcode uses the P1 through P4 operands of the subsequent + ** OP_SeekGE. In the text that follows, the operands of the subsequent + ** OP_SeekGE opcode are denoted as SeekOP.P1 through SeekOP.P4. Only + ** the P1, P2 and P5 operands of this opcode are also used, and are called + ** This.P1, This.P2 and This.P5. + ** + ** This opcode helps to optimize IN operators on a multi-column index + ** where the IN operator is on the later terms of the index by avoiding + ** unnecessary seeks on the btree, substituting steps to the next row + ** of the b-tree instead. A correct answer is obtained if this opcode + ** is omitted or is a no-op. + ** + ** The SeekGE.P3 and SeekGE.P4 operands identify an unpacked key which + ** is the desired entry that we want the cursor SeekGE.P1 to be pointing + ** to. Call this SeekGE.P3/P4 row the "target". + ** + ** If the SeekGE.P1 cursor is not currently pointing to a valid row, + ** then this opcode is a no-op and control passes through into the OP_SeekGE. + ** + ** If the SeekGE.P1 cursor is pointing to a valid row, then that row + ** might be the target row, or it might be near and slightly before the + ** target row, or it might be after the target row. If the cursor is + ** currently before the target row, then this opcode attempts to position + ** the cursor on or after the target row by invoking sqlite3BtreeStep() + ** on the cursor between 1 and This.P1 times. + ** + ** The This.P5 parameter is a flag that indicates what to do if the + ** cursor ends up pointing at a valid row that is past the target + ** row. If This.P5 is false (0) then a jump is made to SeekGE.P2. If + ** This.P5 is true (non-zero) then a jump is made to This.P2. The P5==0 + ** case occurs when there are no inequality constraints to the right of + ** the IN constraint. The jump to SeekGE.P2 ends the loop. The P5!=0 case + ** occurs when there are inequality constraints to the right of the IN + ** operator. In that case, the This.P2 will point either directly to or + ** to setup code prior to the OP_IdxGT or OP_IdxGE opcode that checks for + ** loop terminate. + ** + ** Possible outcomes from this opcode:
      + ** + **
    1. If the cursor is initially not pointed to any valid row, then + ** fall through into the subsequent OP_SeekGE opcode. + ** + **
    2. If the cursor is left pointing to a row that is before the target + ** row, even after making as many as This.P1 calls to + ** sqlite3BtreeNext(), then also fall through into OP_SeekGE. + ** + **
    3. If the cursor is left pointing at the target row, either because it + ** was at the target row to begin with or because one or more + ** sqlite3BtreeNext() calls moved the cursor to the target row, + ** then jump to This.P2.., + ** + **
    4. If the cursor started out before the target row and a call to + ** to sqlite3BtreeNext() moved the cursor off the end of the index + ** (indicating that the target row definitely does not exist in the + ** btree) then jump to SeekGE.P2, ending the loop. + ** + **
    5. If the cursor ends up on a valid row that is past the target row + ** (indicating that the target row does not exist in the btree) then + ** jump to SeekOP.P2 if This.P5==0 or to This.P2 if This.P5>0. + **
    + */ + _89: + ; + /* If pOp->p5 is clear, then pOp->p2 points to the first instruction past the + ** OP_IdxGT that follows the OP_SeekGE. Otherwise, it points to the first + ** opcode past the OP_SeekGE itself. */ + pC6 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((**(**TOp)(__ccgo_up(pOp + 1*24))).Fp1)*8)) + if !(_sqlite3BtreeCursorIsValidNN(tls, *(*uintptr)(unsafe.Pointer(pC6 + 48))) != 0) { + goto _189 + } + nStep = (*TOp)(unsafe.Pointer(pOp)).Fp1 + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC6)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FnField = libc.Uint16FromInt32(*(*int32)(unsafe.Pointer(pOp + 1*24 + 16))) + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).Fdefault_rc = 0 + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FaMem = aMem + uintptr((**(**TOp)(__ccgo_up(pOp + 1*24))).Fp3)*56 + **(**int32)(__ccgo_up(bp + 160)) = 0 /* Not needed. Only used to silence a warning. */ + _260: + ; + if !(int32(1) != 0) { + goto _259 + } + rc = _sqlite3VdbeIdxKeyCompare(tls, db, pC6, bp+168, bp+160) + if rc != 0 { + goto abort_due_to_error + } + if !(**(**int32)(__ccgo_up(bp + 160)) > 0 && libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == 0) { + goto _261 + } + goto seekscan_search_fail + seekscan_search_fail: + ; + /* Jump to SeekGE.P2, ending the loop */ + pOp += 24 + goto jump_to_p2 + _261: + ; + if **(**int32)(__ccgo_up(bp + 160)) >= 0 { + /* Jump to This.P2, bypassing the OP_SeekGE opcode */ + goto jump_to_p2 + goto _259 + } + if nStep <= 0 { + goto _259 + } + nStep = nStep - 1 + (*TVdbeCursor)(unsafe.Pointer(pC6)).FcacheStatus = uint32(CACHE_STALE) + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC6 + 48)), 0) + if rc != 0 { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + goto seekscan_search_fail + } else { + goto abort_due_to_error + } + } + goto _260 + _259: + ; + goto _189 + /* Opcode: SeekHit P1 P2 P3 * * + ** Synopsis: set P2<=seekHit<=P3 + ** + ** Increase or decrease the seekHit value for cursor P1, if necessary, + ** so that it is no less than P2 and no greater than P3. + ** + ** The seekHit integer represents the maximum of terms in an index for which + ** there is known to be at least one match. If the seekHit value is smaller + ** than the total number of equality terms in an index lookup, then the + ** OP_IfNoHope opcode might run to see if the IN loop can be abandoned + ** early, thus saving work. This is part of the IN-early-out optimization. + ** + ** P1 must be a valid b-tree cursor. + */ + _90: + ; + pC7 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit) < (*TOp)(unsafe.Pointer(pOp)).Fp2 { + (*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit) > (*TOp)(unsafe.Pointer(pOp)).Fp3 { + (*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + goto _189 + /* Opcode: IfNotOpen P1 P2 * * * + ** Synopsis: if( !csr[P1] ) goto P2 + ** + ** If cursor P1 is not open or if P1 is set to a NULL row using the + ** OP_NullRow opcode, then jump to instruction P2. Otherwise, fall through. + */ + _91: + ; + pCur1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCur1 == uintptr(0) || (*TVdbeCursor)(unsafe.Pointer(pCur1)).FnullRow != 0 { + goto jump_to_p2_and_check_for_interrupt + } + goto _189 + /* Opcode: Found P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is a prefix of any entry in P1 then a jump is made to P2 and + ** P1 is left pointing at the matching entry. + ** + ** This operation leaves the cursor in a state where it can be + ** advanced in the forward direction. The Next instruction will work, + ** but not the Prev instruction. + ** + ** See also: NotFound, NoConflict, NotExists. SeekGe + */ + /* Opcode: NotFound P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 + ** does contain an entry whose prefix matches the P3/P4 record then control + ** falls through to the next instruction and P1 is left pointing at the + ** matching entry. + ** + ** This operation leaves the cursor in a state where it cannot be + ** advanced in either direction. In other words, the Next and Prev + ** opcodes do not work after this operation. + ** + ** See also: Found, NotExists, NoConflict, IfNoHope + */ + /* Opcode: IfNoHope P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** Register P3 is the first of P4 registers that form an unpacked + ** record. Cursor P1 is an index btree. P2 is a jump destination. + ** In other words, the operands to this opcode are the same as the + ** operands to OP_NotFound and OP_IdxGT. + ** + ** This opcode is an optimization attempt only. If this opcode always + ** falls through, the correct answer is still obtained, but extra work + ** is performed. + ** + ** A value of N in the seekHit flag of cursor P1 means that there exists + ** a key P3:N that will match some record in the index. We want to know + ** if it is possible for a record P3:P4 to match some record in the + ** index. If it is not possible, we can skip some work. So if seekHit + ** is less than P4, attempt to find out if a match is possible by running + ** OP_NotFound. + ** + ** This opcode is used in IN clause processing for a multi-column key. + ** If an IN clause is attached to an element of the key other than the + ** left-most element, and if there are no matches on the most recent + ** seek over the whole key, then it might be that one of the key element + ** to the left is prohibiting a match, and hence there is "no hope" of + ** any match regardless of how many IN clause elements are checked. + ** In such a case, we abandon the IN clause search early, using this + ** opcode. The opcode name comes from the fact that the + ** jump is taken if there is "no hope" of achieving a match. + ** + ** See also: NotFound, SeekHit + */ + /* Opcode: NoConflict P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** contains any NULL value, jump immediately to P2. If all terms of the + ** record are not-NULL then a check is done to determine if any row in the + ** P1 index btree has a matching key prefix. If there are no matches, jump + ** immediately to P2. If there is a match, fall through and leave the P1 + ** cursor pointing to the matching row. + ** + ** This opcode is similar to OP_NotFound with the exceptions that the + ** branch is always taken if any part of the search key input is NULL. + ** + ** This operation leaves the cursor in a state where it cannot be + ** advanced in either direction. In other words, the Next and Prev + ** opcodes do not work after this operation. + ** + ** See also: NotFound, Found, NotExists + */ + _92: + ; + pC8 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC8)).FseekHit) >= (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi { + goto _189 + } + /* Fall through into OP_NotFound */ + _95: + ; /* jump, in3, ncycle */ + _94: + ; /* jump, in3, ncycle */ + _93: + ; + pC9 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + if libc.Int32FromUint16((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField) > 0 { + /* Key values in an array of registers */ + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).Fdefault_rc = 0 + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 48)), bp+208, pC9+36) + } else { + /* Composite key generated by OP_MakeRecord */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto no_mem + } + pIdxKey = _sqlite3VdbeAllocUnpackedRecord(tls, (*TVdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo) + if pIdxKey == uintptr(0) { + goto no_mem + } + _sqlite3VdbeRecordUnpack(tls, (*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fn, (*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fz, pIdxKey) + (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).Fdefault_rc = 0 + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 48)), pIdxKey, pC9+36) + _sqlite3DbFreeNN(tls, db, pIdxKey) + } + if rc != SQLITE_OK { + goto abort_due_to_error + } + alreadyExists = libc.BoolInt32((*TVdbeCursor)(unsafe.Pointer(pC9)).FseekResult == 0) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FnullRow = libc.Uint8FromInt32(int32(1) - alreadyExists) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = uint32(CACHE_STALE) + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Found) { + if alreadyExists != 0 { + goto jump_to_p2 + } + } else { + if !(alreadyExists != 0) { + goto jump_to_p2 + } + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_NoConflict) { + /* For the OP_NoConflict opcode, take the jump if any of the + ** input fields are NULL, since any key with a NULL will not + ** conflict */ + ii1 = 0 + for { + if !(ii1 < libc.Int32FromUint16((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField)) { + break + } + if libc.Int32FromUint16((**(**TMem)(__ccgo_up((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem + uintptr(ii1)*56))).Fflags)&int32(MEM_Null) != 0 { + goto jump_to_p2 + } + goto _263 + _263: + ; + ii1 = ii1 + 1 + } + } + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_IfNoHope) { + (*TVdbeCursor)(unsafe.Pointer(pC9)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + } + } + goto _189 + /* Opcode: SeekRowid P1 P2 P3 * * + ** Synopsis: intkey=r[P3] + ** + ** P1 is the index of a cursor open on an SQL table btree (with integer + ** keys). If register P3 does not contain an integer or if P1 does not + ** contain a record with rowid P3 then jump immediately to P2. + ** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain + ** a record with rowid P3 then + ** leave the cursor pointing at that record and fall through to the next + ** instruction. + ** + ** The OP_NotExists opcode performs the same operation, but with OP_NotExists + ** the P3 register must be guaranteed to contain an integer value. With this + ** opcode, register P3 might not contain an integer. + ** + ** The OP_NotFound opcode performs the same operation on index btrees + ** (with arbitrary multi-value keys). + ** + ** This opcode leaves the cursor in a state where it cannot be advanced + ** in either direction. In other words, the Next and Prev opcodes will + ** not work following this opcode. + ** + ** See also: Found, NotFound, NoConflict, SeekRowid + */ + /* Opcode: NotExists P1 P2 P3 * * + ** Synopsis: intkey=r[P3] + ** + ** P1 is the index of a cursor open on an SQL table btree (with integer + ** keys). P3 is an integer rowid. If P1 does not contain a record with + ** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an + ** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then + ** leave the cursor pointing at that record and fall through to the next + ** instruction. + ** + ** The OP_SeekRowid opcode performs the same operation but also allows the + ** P3 register to contain a non-integer value, in which case the jump is + ** always taken. This opcode requires that P3 always contain an integer. + ** + ** The OP_NotFound opcode performs the same operation on index btrees + ** (with arbitrary multi-value keys). + ** + ** This opcode leaves the cursor in a state where it cannot be advanced + ** in either direction. In other words, the Next and Prev opcodes will + ** not work following this opcode. + ** + ** See also: Found, NotFound, NoConflict, SeekRowid + */ + _97: + ; + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn3)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + /* If pIn3->u.i does not contain an integer, compute iKey as the + ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted + ** into an integer without loss of information. Take care to avoid + ** changing the datatype of pIn3, however, as it is used by other + ** parts of the prepared statement. */ + *(*TMem)(unsafe.Pointer(bp + 256)) = TMem{} + /* If pIn3->u.i does not contain an integer, compute iKey as the + ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted + ** into an integer without loss of information. Take care to avoid + ** changing the datatype of pIn3, however, as it is used by other + ** parts of the prepared statement. */ + *(*Tsqlite3_value)(unsafe.Pointer(bp + 256)) = **(**TMem)(__ccgo_up(pIn3)) + _applyAffinity(tls, bp+256, uint8(SQLITE_AFF_NUMERIC), encoding) + if libc.Int32FromUint16((**(**TMem)(__ccgo_up(bp + 256))).Fflags)&int32(MEM_Int) == 0 { + goto jump_to_p2 + } + iKey1 = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(bp + 256))) + goto notExistsWithKey + } + /* Fall through into OP_NotExists */ + _96: + ; /* jump, in3, ncycle */ + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + iKey1 = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(pIn3))) + goto notExistsWithKey + notExistsWithKey: + ; + pC10 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr2 = *(*uintptr)(unsafe.Pointer(pC10 + 48)) + **(**int32)(__ccgo_up(bp + 248)) = 0 + rc = _sqlite3BtreeTableMoveto(tls, pCrsr2, libc.Int64FromUint64(iKey1), 0, bp+248) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget = libc.Int64FromUint64(iKey1) /* Used by OP_Delete */ + (*TVdbeCursor)(unsafe.Pointer(pC10)).FnullRow = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = uint32(CACHE_STALE) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FseekResult = **(**int32)(__ccgo_up(bp + 248)) + if **(**int32)(__ccgo_up(bp + 248)) != 0 { + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == 0 { + rc = _sqlite3CorruptError(tls, int32(102023)) + } else { + goto jump_to_p2 + } + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Sequence P1 P2 * * * + ** Synopsis: r[P2]=cursor[P1].ctr++ + ** + ** Find the next available sequence number for cursor P1. + ** Write the sequence number into register P2. + ** The sequence number on the cursor is incremented after this + ** instruction. + */ + _98: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + v191 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + 24 + v256 = *(*Ti64)(unsafe.Pointer(v191)) + *(*Ti64)(unsafe.Pointer(v191)) = *(*Ti64)(unsafe.Pointer(v191)) + 1 + *(*Ti64)(unsafe.Pointer(pOut)) = v256 + goto _189 + /* Opcode: NewRowid P1 P2 P3 * * + ** Synopsis: r[P2]=rowid + ** + ** Get a new integer record number (a.k.a "rowid") used as the key to a table. + ** The record number is not previously used as a key in the database + ** table that cursor P1 points to. The new record number is written + ** written to register P2. + ** + ** If P3>0 then P3 is a register in the root frame of this VDBE that holds + ** the largest previously generated record number. No new record numbers are + ** allowed to be less than this value. When this value reaches its maximum, + ** an SQLITE_FULL error is generated. The P3 register is updated with the ' + ** generated record number. This P3 mechanism is used to help implement the + ** AUTOINCREMENT feature. + */ + _99: + ; /* Root frame of VDBE */ + **(**Ti64)(__ccgo_up(bp + 312)) = 0 + **(**int32)(__ccgo_up(bp + 320)) = 0 + pOut = _out2Prerelease(tls, p, pOp) + pC11 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + /* The next rowid or record number (different terms for the same + ** thing) is obtained in a two-step algorithm. + ** + ** First we attempt to find the largest existing rowid and add one + ** to that. But if the largest existing rowid is already the maximum + ** positive integer, we have to fall through to the second + ** probabilistic algorithm + ** + ** The second algorithm is to select a rowid at random and see if + ** it already exists in the table. If it does not exist, we have + ** succeeded. If the random rowid does exist, we select a new one + ** and try again, up to 100 times. + */ + /* Some compilers complain about constants of the form 0x7fffffffffffffff. + ** Others complain about 0x7ffffffffffffffffLL. The following macro seems + ** to provide the constant while making all compilers happy. + */ + if !(int32(TBool(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0) { + rc = _sqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48)), bp+320) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 320)) != 0 { + **(**Ti64)(__ccgo_up(bp + 312)) = int64(1) /* IMP: R-61914-48074 */ + } else { + **(**Ti64)(__ccgo_up(bp + 312)) = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48))) + if **(**Ti64)(__ccgo_up(bp + 312)) >= libc.Int64FromUint64(libc.Uint64FromInt32(0x7fffffff)<>1)) != 0 { + rc = int32(SQLITE_FULL) /* IMP: R-17817-00630 */ + goto abort_due_to_error + } + if **(**Ti64)(__ccgo_up(bp + 312)) < *(*Ti64)(unsafe.Pointer(pMem))+int64(1) { + **(**Ti64)(__ccgo_up(bp + 312)) = *(*Ti64)(unsafe.Pointer(pMem)) + int64(1) + } + *(*Ti64)(unsafe.Pointer(pMem)) = **(**Ti64)(__ccgo_up(bp + 312)) + } + if int32(TBool(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0 { + /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the + ** largest possible integer (9223372036854775807) then the database + ** engine starts picking positive candidate ROWIDs at random until + ** it finds one that is not previously used. */ + /* We cannot be in random rowid mode if this is + ** an AUTOINCREMENT table. */ + cnt1 = 0 + for { + Xsqlite3_randomness(tls, int32(8), bp+312) + **(**Ti64)(__ccgo_up(bp + 312)) = **(**Ti64)(__ccgo_up(bp + 312)) & (libc.Int64FromUint64(libc.Uint64FromInt32(0x7fffffff)<> libc.Int32FromInt32(1)) + **(**Ti64)(__ccgo_up(bp + 312)) = **(**Ti64)(__ccgo_up(bp + 312)) + 1 /* Ensure that v is greater than zero */ + goto _270 + _270: + ; + v190 = _sqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48)), libc.Int64FromUint64(libc.Uint64FromInt64(**(**Ti64)(__ccgo_up(bp + 312)))), 0, bp+320) + rc = v190 + if v217 = v190 == SQLITE_OK && **(**int32)(__ccgo_up(bp + 320)) == 0; v217 { + cnt1 = cnt1 + 1 + v193 = cnt1 + } + if !(v217 && v193 < int32(100)) { + break + } + } + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 320)) == 0 { + rc = int32(SQLITE_FULL) /* IMP: R-38219-53002 */ + goto abort_due_to_error + } + /* EV: R-40812-03570 */ + } + (*TVdbeCursor)(unsafe.Pointer(pC11)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC11)).FcacheStatus = uint32(CACHE_STALE) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 312)) + goto _189 + /* Opcode: Insert P1 P2 P3 P4 P5 + ** Synopsis: intkey=r[P3] data=r[P2] + ** + ** Write an entry into the table of cursor P1. A new entry is + ** created if it doesn't already exist or the data for an existing + ** entry is overwritten. The data is the value MEM_Blob stored in register + ** number P2. The key is stored in register P3. The key must + ** be a MEM_Int. + ** + ** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is + ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, + ** then rowid is stored for subsequent return by the + ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). + ** + ** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might + ** run faster by avoiding an unnecessary seek on cursor P1. However, + ** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior + ** seeks on the cursor or if the most recent seek used a key equal to P3. + ** + ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an + ** UPDATE operation. Otherwise (if the flag is clear) then this opcode + ** is part of an INSERT operation. The difference is only important to + ** the update hook. + ** + ** Parameter P4 may point to a Table structure, or may be NULL. If it is + ** not NULL, then the update-hook (sqlite3.xUpdateCallback) is invoked + ** following a successful insert. + ** + ** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically + ** allocated, then ownership of P2 is transferred to the pseudo-cursor + ** and register P2 becomes ephemeral. If the cursor is changed, the + ** value of register P2 will then change. Make sure this does not + ** cause any problems.) + ** + ** This instruction only works on tables. The equivalent instruction + ** for indices is OP_IdxInsert. + */ + _100: + ; /* Payload to be inserted */ + pData = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pC12 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pKey = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey = *(*Ti64)(unsafe.Pointer(pKey)) + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(5) && ((*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) { + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TVdbeCursor)(unsafe.Pointer(pC12)).FiDb)*32))).FzDbSName + pTab1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + } else { + pTab1 = uintptr(0) + zDb = uintptr(0) + } + /* Invoke the pre-update hook, if any */ + if pTab1 != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && !(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&libc.Int32FromInt32(OPFLAG_ISUPDATE) != 0) { + _sqlite3VdbePreUpdateHook(tls, p, pC12, int32(SQLITE_INSERT), zDb, pTab1, (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey, (*TOp)(unsafe.Pointer(pOp)).Fp2, -int32(1)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback == uintptr(0) || (*TTable)(unsafe.Pointer(pTab1)).FaCol == uintptr(0) { + /* Prevent post-update hook from running in cases when it should not */ + pTab1 = uintptr(0) + } + } + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_ISNOOP) != 0 { + goto _189 + } + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_LASTROWID) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey + } + } + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FpData = (*TMem)(unsafe.Pointer(pData)).Fz + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnData = (*TMem)(unsafe.Pointer(pData)).Fn + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_USESEEKRESULT) != 0 { + v190 = (*TVdbeCursor)(unsafe.Pointer(pC12)).FseekResult + } else { + v190 = 0 + } + seekResult = v190 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pData)).Fflags)&int32(MEM_Zero) != 0 { + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnZero = *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pData)).Fu)) + } else { + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnZero = 0 + } + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FpKey = uintptr(0) + rc = _sqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC12 + 48)), bp+328, libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&(libc.Int32FromInt32(OPFLAG_APPEND)|libc.Int32FromInt32(OPFLAG_SAVEPOSITION)|libc.Int32FromInt32(OPFLAG_PREFORMAT)), seekResult) + (*TVdbeCursor)(unsafe.Pointer(pC12)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC12)).FcacheStatus = uint32(CACHE_STALE) + colCacheCtr = colCacheCtr + 1 + /* Invoke the update-hook if required. */ + if rc != 0 { + goto abort_due_to_error + } + if pTab1 != 0 { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_ISUPDATE) != 0 { + v190 = int32(SQLITE_UPDATE) + } else { + v190 = int32(SQLITE_INSERT) + } + (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Tsqlite_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg, v190, zDb, (*TTable)(unsafe.Pointer(pTab1)).FzName, (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey) + } + goto _189 + /* Opcode: RowCell P1 P2 P3 * * + ** + ** P1 and P2 are both open cursors. Both must be opened on the same type + ** of table - intkey or index. This opcode is used as part of copying + ** the current row from P2 into P1. If the cursors are opened on intkey + ** tables, register P3 contains the rowid to use with the new record in + ** P1. If they are opened on index tables, P3 is not used. + ** + ** This opcode must be followed by either an Insert or InsertIdx opcode + ** with the OPFLAG_PREFORMAT flag set to complete the insert operation. + */ + _101: + ; /* Rowid value to insert with */ + pDest1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pSrc = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*8)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + v206 = *(*Ti64)(unsafe.Pointer(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56)) + } else { + v206 = 0 + } + iKey2 = v206 + rc = _sqlite3BtreeTransferRow(tls, *(*uintptr)(unsafe.Pointer(pDest1 + 48)), *(*uintptr)(unsafe.Pointer(pSrc + 48)), iKey2) + if rc != SQLITE_OK { + goto abort_due_to_error + } + goto _189 + /* Opcode: Delete P1 P2 P3 P4 P5 + ** + ** Delete the record at which the P1 cursor is currently pointing. + ** + ** If the OPFLAG_SAVEPOSITION bit of the P5 parameter is set, then + ** the cursor will be left pointing at either the next or the previous + ** record in the table. If it is left pointing at the next record, then + ** the next Next instruction will be a no-op. As a result, in this case + ** it is ok to delete a record from within a Next loop. If + ** OPFLAG_SAVEPOSITION bit of P5 is clear, then the cursor will be + ** left in an undefined state. + ** + ** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this + ** delete is one of several associated with deleting a table row and + ** all its associated index entries. Exactly one of those deletes is + ** the "primary" delete. The others are all on OPFLAG_FORDELETE + ** cursors or else are marked with the AUXDELETE flag. + ** + ** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then + ** the row change count is incremented (otherwise not). + ** + ** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the + ** pre-update-hook for deletes is run, but the btree is otherwise unchanged. + ** This happens when the OP_Delete is to be shortly followed by an OP_Insert + ** with the same key, causing the btree entry to be overwritten. + ** + ** P1 must not be pseudo-table. It has to be a real table with + ** multiple rows. + ** + ** If P4 is not NULL then it points to a Table object. In this case either + ** the update or pre-update hook, or both, may be invoked. The P1 cursor must + ** have been positioned using OP_NotFound prior to invoking this opcode in + ** this case. Specifically, if one is configured, the pre-update hook is + ** invoked if P4 is not NULL. The update-hook is invoked if one is configured, + ** P4 is not NULL, and the OPFLAG_NCHANGE flag is set in P2. + ** + ** If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address + ** of the memory cell that contains the value that the rowid of the row will + ** be set to by the update. + */ + _102: + ; + opflags = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pC13 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + /* If the update-hook or pre-update-hook will be invoked, set zDb to + ** the name of the db to pass as to it. Also set local pTab to a copy + ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was + ** last moved with OP_Next or OP_Prev, not Seek or NotFound, set + ** VdbeCursor.movetoTarget to the current rowid. */ + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(5) && ((*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) { + zDb1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TVdbeCursor)(unsafe.Pointer(pC13)).FiDb)*32))).FzDbSName + pTab2 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_SAVEPOSITION) != 0 && (*TVdbeCursor)(unsafe.Pointer(pC13)).FisTable != 0 { + (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC13 + 48))) + } + } else { + zDb1 = uintptr(0) + pTab2 = uintptr(0) + } + /* Invoke the pre-update-hook if required. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && pTab2 != 0 { + if opflags&int32(OPFLAG_ISUPDATE) != 0 { + v190 = int32(SQLITE_UPDATE) + } else { + v190 = int32(SQLITE_DELETE) + } + _sqlite3VdbePreUpdateHook(tls, p, pC13, v190, zDb1, pTab2, (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget, (*TOp)(unsafe.Pointer(pOp)).Fp3, -int32(1)) + } + if opflags&int32(OPFLAG_ISNOOP) != 0 { + goto _189 + } + /* Only flags that can be set are SAVEPOISTION and AUXDELETE */ + rc = _sqlite3BtreeDelete(tls, *(*uintptr)(unsafe.Pointer(pC13 + 48)), uint8((*TOp)(unsafe.Pointer(pOp)).Fp5)) + (*TVdbeCursor)(unsafe.Pointer(pC13)).FcacheStatus = uint32(CACHE_STALE) + colCacheCtr = colCacheCtr + 1 + (*TVdbeCursor)(unsafe.Pointer(pC13)).FseekResult = 0 + if rc != 0 { + goto abort_due_to_error + } + /* Invoke the update-hook if required. */ + if opflags&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + if (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0 && pTab2 != uintptr(0) && (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Tsqlite_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg, int32(SQLITE_DELETE), zDb1, (*TTable)(unsafe.Pointer(pTab2)).FzName, (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget) + } + } + goto _189 + /* Opcode: ResetCount * * * * * + ** + ** The value of the change counter is copied to the database handle + ** change counter (returned by subsequent calls to sqlite3_changes()). + ** Then the VMs internal change counter resets to 0. + ** This is used by trigger programs. + */ + _103: + ; + _sqlite3VdbeSetChanges(tls, db, (*TVdbe)(unsafe.Pointer(p)).FnChange) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + goto _189 + /* Opcode: SorterCompare P1 P2 P3 P4 + ** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2 + ** + ** P1 is a sorter cursor. This instruction compares a prefix of the + ** record blob in register P3 against a prefix of the entry that + ** the sorter cursor currently points to. Only the first P4 fields + ** of r[P3] and the sorter record are compared. + ** + ** If either P3 or the sorter contains a NULL in one of their significant + ** fields (not counting the P4 fields at the end which are ignored) then + ** the comparison is assumed to be equal. + ** + ** Fall through to next instruction if the two records compare equal to + ** each other. Jump to P2 if they are different. + */ + _104: + ; + pC14 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + nKeyCol = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + **(**int32)(__ccgo_up(bp + 376)) = 0 + rc = _sqlite3VdbeSorterCompare(tls, pC14, pIn3, nKeyCol, bp+376) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 376)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: SorterData P1 P2 P3 * * + ** Synopsis: r[P2]=data + ** + ** Write into register P2 the current sorter data for sorter cursor P1. + ** Then clear the column header cache on cursor P3. + ** + ** This opcode is normally used to move a record out of the sorter and into + ** a register that is the source for a pseudo-table cursor created using + ** OpenPseudo. That pseudo-table cursor is the one that is identified by + ** parameter P3. Clearing the P3 column cache as part of this opcode saves + ** us from having to issue a separate NullRow instruction to clear that cache. + */ + _105: + ; + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pC15 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3VdbeSorterRowkey(tls, pC15, pOut) + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*8)))).FcacheStatus = uint32(CACHE_STALE) + goto _189 + /* Opcode: RowData P1 P2 P3 * * + ** Synopsis: r[P2]=data + ** + ** Write into register P2 the complete row content for the row at + ** which cursor P1 is currently pointing. + ** There is no interpretation of the data. + ** It is just copied onto the P2 register exactly as + ** it is found in the database file. + ** + ** If cursor P1 is an index, then the content is the key of the row. + ** If cursor P2 is a table, then the content extracted is the data. + ** + ** If the P1 cursor must be pointing to a valid row (not a NULL row) + ** of a real table, not a pseudo-table. + ** + ** If P3!=0 then this opcode is allowed to make an ephemeral pointer + ** into the database page. That means that the content of the output + ** register will be invalidated as soon as the cursor moves - including + ** moves caused by other cursors that "save" the current cursors + ** position in order that they can write to the same table. If P3==0 + ** then a copy of the data is made into memory. P3!=0 is faster, but + ** P3==0 is safer. + ** + ** If P3!=0 then the content of the P2 register is unsuitable for use + ** in OP_Result and any OP_Result will invalidate the P2 register content. + ** The P2 register content is invalidated by opcodes like OP_Function or + ** by any use of another cursor pointing to the same table. + */ + _106: + ; + pOut = _out2Prerelease(tls, p, pOp) + pC16 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr3 = *(*uintptr)(unsafe.Pointer(pC16 + 48)) + /* The OP_RowData opcodes always follow OP_NotExists or + ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions + ** that might invalidate the cursor. + ** If this were not the case, one of the following assert()s + ** would fail. Should this ever change (because of changes in the code + ** generator) then the fix would be to insert a call to + ** sqlite3VdbeCursorMoveto(). + */ + n3 = _sqlite3BtreePayloadSize(tls, pCrsr3) + if n3 > libc.Uint32FromInt32(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCrsr3, n3, pOut) + if rc != 0 { + goto abort_due_to_error + } + if !((*TOp)(unsafe.Pointer(pOp)).Fp3 != 0) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + } + goto _189 + /* Opcode: Rowid P1 P2 * * * + ** Synopsis: r[P2]=PX rowid of P1 + ** + ** Store in register P2 an integer which is the key of the table entry that + ** P1 is currently point to. + ** + ** P1 can be either an ordinary table or a virtual table. There used to + ** be a separate OP_VRowid opcode for use with virtual tables, but this + ** one opcode now works for both table types. + */ + _107: + ; + pOut = _out2Prerelease(tls, p, pOp) + pC17 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + goto _189 + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FdeferredMoveto != 0 { + **(**Ti64)(__ccgo_up(bp + 384)) = (*TVdbeCursor)(unsafe.Pointer(pC17)).FmovetoTarget + } else { + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC17)).FeCurType) == int32(CURTYPE_VTAB) { + pVtab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pC17 + 48)))).FpVtab + pModule = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule)).FxRowid})))(tls, *(*uintptr)(unsafe.Pointer(pC17 + 48)), bp+384) + _sqlite3VtabImportErrmsg(tls, p, pVtab) + if rc != 0 { + goto abort_due_to_error + } + } else { + rc = _sqlite3VdbeCursorRestore(tls, pC17) + if rc != 0 { + goto abort_due_to_error + } + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + goto _189 + } + **(**Ti64)(__ccgo_up(bp + 384)) = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC17 + 48))) + } + } + } + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 384)) + goto _189 + /* Opcode: NullRow P1 * * * * + ** + ** Move the cursor P1 to a null row. Any OP_Column operations + ** that occur while the cursor is on the null row will always + ** write a NULL. + ** + ** If cursor P1 is not previously opened, open it now to a special + ** pseudo-cursor that always returns NULL for every column. + */ + _108: + ; + pC18 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pC18 == uintptr(0) { + /* If the cursor is not already open, create a special kind of + ** pseudo-cursor that always gives null rows. */ + pC18 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, int32(1), uint8(CURTYPE_PSEUDO)) + if pC18 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pC18)).FseekResult = 0 + (*TVdbeCursor)(unsafe.Pointer(pC18)).FisTable = uint8(1) + libc.SetBitFieldPtr8Uint32(pC18+8, libc.Uint32FromInt32(1), 3, 0x8) + *(*uintptr)(unsafe.Pointer(pC18 + 48)) = _sqlite3BtreeFakeValidCursor(tls) + } + (*TVdbeCursor)(unsafe.Pointer(pC18)).FnullRow = uint8(1) + (*TVdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = uint32(CACHE_STALE) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC18)).FeCurType) == CURTYPE_BTREE { + _sqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pC18 + 48))) + } + goto _189 + /* Opcode: SeekEnd P1 * * * * + ** + ** Position cursor P1 at the end of the btree for the purpose of + ** appending a new entry onto the btree. + ** + ** It is assumed that the cursor is used only for appending and so + ** if the cursor is valid, then the cursor must already be pointing + ** at the end of the btree and so no changes are made to + ** the cursor. + */ + /* Opcode: Last P1 P2 * * * + ** + ** The next use of the Rowid or Column or Prev instruction for P1 + ** will refer to the last entry in the database table or index. + ** If the table or index is empty and P2>0, then jump immediately to P2. + ** If P2 is 0 or if the table or index is not empty, fall through + ** to the following instruction. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + */ + _110: + ; /* ncycle */ + _109: + ; + pC19 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr4 = *(*uintptr)(unsafe.Pointer(pC19 + 48)) + **(**int32)(__ccgo_up(bp + 392)) = 0 + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_SeekEnd) { + (*TVdbeCursor)(unsafe.Pointer(pC19)).FseekResult = -int32(1) + if _sqlite3BtreeCursorIsValidNN(tls, pCrsr4) != 0 { + goto _189 + } + } + rc = _sqlite3BtreeLast(tls, pCrsr4, bp+392) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FnullRow = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 392))) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = uint32(CACHE_STALE) + if rc != 0 { + goto abort_due_to_error + } + if (*TOp)(unsafe.Pointer(pOp)).Fp2 > 0 { + if **(**int32)(__ccgo_up(bp + 392)) != 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: IfSizeBetween P1 P2 P3 P4 * + ** + ** Let N be the approximate number of rows in the table or index + ** with cursor P1 and let X be 10*log2(N) if N is positive or -1 + ** if N is zero. + ** + ** Jump to P2 if X is in between P3 and P4, inclusive. + */ + _111: + ; + pC20 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr5 = *(*uintptr)(unsafe.Pointer(pC20 + 48)) + rc = _sqlite3BtreeFirst(tls, pCrsr5, bp+396) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 396)) != 0 { + sz = int64(-int32(1)) /* -Infinity encoding */ + } else { + sz = _sqlite3BtreeRowCountEst(tls, pCrsr5) + sz = int64(_sqlite3LogEst(tls, libc.Uint64FromInt64(sz))) + } + **(**int32)(__ccgo_up(bp + 396)) = libc.BoolInt32(sz >= int64((*TOp)(unsafe.Pointer(pOp)).Fp3) && sz <= int64((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) + if **(**int32)(__ccgo_up(bp + 396)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: SorterSort P1 P2 * * * + ** + ** After all records have been inserted into the Sorter object + ** identified by P1, invoke this opcode to actually do the sorting. + ** Jump to P2 if there are no records to be sorted. + ** + ** This opcode is an alias for OP_Sort and OP_Rewind that is used + ** for Sorter objects. + */ + /* Opcode: Sort P1 P2 * * * + ** + ** This opcode does exactly the same thing as OP_Rewind except that + ** it increments an undocumented global variable used for testing. + ** + ** Sorting is accomplished by writing records into a sorting index, + ** then rewinding that index and playing it back from beginning to + ** end. We use the OP_Sort opcode instead of OP_Rewind to do the + ** rewinding so that the global variable will be incremented and + ** regression tests can determine whether or not the optimizer is + ** correctly optimizing out sorts. + */ + _113: + ; /* jump ncycle */ + _112: + ; /* jump ncycle */ + **(**Tu32)(__ccgo_up(p + 212 + 2*4)) = **(**Tu32)(__ccgo_up(p + 212 + 2*4)) + 1 + /* Fall through into OP_Rewind */ + /* Opcode: Rewind P1 P2 * * * + ** + ** The next use of the Rowid or Column or Next instruction for P1 + ** will refer to the first entry in the database table or index. + ** If the table or index is empty, jump immediately to P2. + ** If the table or index is not empty, fall through to the following + ** instruction. + ** + ** If P2 is zero, that is an assertion that the P1 table is never + ** empty and hence the jump will never be taken. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + */ + _114: + ; + pC21 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + **(**int32)(__ccgo_up(bp + 400)) = int32(1) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC21)).FeCurType) == int32(CURTYPE_SORTER) { + rc = _sqlite3VdbeSorterRewind(tls, pC21, bp+400) + } else { + pCrsr6 = *(*uintptr)(unsafe.Pointer(pC21 + 48)) + rc = _sqlite3BtreeFirst(tls, pCrsr6, bp+400) + (*TVdbeCursor)(unsafe.Pointer(pC21)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC21)).FcacheStatus = uint32(CACHE_STALE) + } + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(pC21)).FnullRow = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 400))) + if (*TOp)(unsafe.Pointer(pOp)).Fp2 > 0 { + if **(**int32)(__ccgo_up(bp + 400)) != 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: IfEmpty P1 P2 * * * + ** Synopsis: if( empty(P1) ) goto P2 + ** + ** Check to see if the b-tree table that cursor P1 references is empty + ** and jump to P2 if it is. + */ + _115: + ; + pC22 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr7 = *(*uintptr)(unsafe.Pointer(pC22 + 48)) + rc = _sqlite3BtreeIsEmpty(tls, pCrsr7, bp+404) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 404)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Next P1 P2 P3 * P5 + ** + ** Advance cursor P1 so that it points to the next key/data pair in its + ** table or index. If there are no more key/value pairs then fall through + ** to the following instruction. But if the cursor advance was successful, + ** jump immediately to P2. + ** + ** The Next opcode is only valid following an SeekGT, SeekGE, or + ** OP_Rewind opcode used to position the cursor. Next is not allowed + ** to follow SeekLT, SeekLE, or OP_Last. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. P1 must have + ** been opened prior to this opcode or the program will segfault. + ** + ** The P3 value is a hint to the btree implementation. If P3==1, that + ** means P1 is an SQL index and that this instruction could have been + ** omitted if that index had been unique. P3 is usually 0. P3 is + ** always either 0 or 1. + ** + ** If P5 is positive and the jump is taken, then event counter + ** number P5-1 in the prepared statement is incremented. + ** + ** See also: Prev + */ + /* Opcode: Prev P1 P2 P3 * P5 + ** + ** Back up cursor P1 so that it points to the previous key/data pair in its + ** table or index. If there is no previous key/value pairs then fall through + ** to the following instruction. But if the cursor backup was successful, + ** jump immediately to P2. + ** + ** + ** The Prev opcode is only valid following an SeekLT, SeekLE, or + ** OP_Last opcode used to position the cursor. Prev is not allowed + ** to follow SeekGT, SeekGE, or OP_Rewind. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. If P1 is + ** not open then the behavior is undefined. + ** + ** The P3 value is a hint to the btree implementation. If P3==1, that + ** means P1 is an SQL index and that this instruction could have been + ** omitted if that index had been unique. P3 is usually 0. P3 is + ** always either 0 or 1. + ** + ** If P5 is positive and the jump is taken, then event counter + ** number P5-1 in the prepared statement is incremented. + */ + /* Opcode: SorterNext P1 P2 * * P5 + ** + ** This opcode works just like OP_Next except that P1 must be a + ** sorter object for which the OP_SorterSort opcode has been + ** invoked. This opcode advances the cursor to the next sorted + ** record, or jumps to P2 if there are no more sorted records. + */ + _118: + ; + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3VdbeSorterNext(tls, db, pC23) + goto next_tail + _116: + ; /* jump, ncycle */ + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC23 + 48)), (*TOp)(unsafe.Pointer(pOp)).Fp3) + goto next_tail + _117: + ; /* jump, ncycle */ + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC23 + 48)), (*TOp)(unsafe.Pointer(pOp)).Fp3) + goto next_tail + next_tail: + ; + (*TVdbeCursor)(unsafe.Pointer(pC23)).FcacheStatus = uint32(CACHE_STALE) + if rc == SQLITE_OK { + (*TVdbeCursor)(unsafe.Pointer(pC23)).FnullRow = uint8(0) + **(**Tu32)(__ccgo_up(p + 212 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*4)) = **(**Tu32)(__ccgo_up(p + 212 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*4)) + 1 + goto jump_to_p2_and_check_for_interrupt + } + if rc != int32(SQLITE_DONE) { + goto abort_due_to_error + } + rc = SQLITE_OK + (*TVdbeCursor)(unsafe.Pointer(pC23)).FnullRow = uint8(1) + goto check_for_interrupt + /* Opcode: IdxInsert P1 P2 P3 P4 P5 + ** Synopsis: key=r[P2] + ** + ** Register P2 holds an SQL index key made using the + ** MakeRecord instructions. This opcode writes that key + ** into the index P1. Data for the entry is nil. + ** + ** If P4 is not zero, then it is the number of values in the unpacked + ** key of reg(P2). In that case, P3 is the index of the first register + ** for the unpacked key. The availability of the unpacked key can sometimes + ** be an optimization. + ** + ** If P5 has the OPFLAG_APPEND bit set, that is a hint to the b-tree layer + ** that this insert is likely to be an append. + ** + ** If P5 has the OPFLAG_NCHANGE bit set, then the change counter is + ** incremented by this instruction. If the OPFLAG_NCHANGE bit is clear, + ** then the change counter is unchanged. + ** + ** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might + ** run faster by avoiding an unnecessary seek on cursor P1. However, + ** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior + ** seeks on the cursor or if the most recent seek used a key equivalent + ** to P2. + ** + ** This instruction only works for indices. The equivalent instruction + ** for tables is OP_Insert. + */ + _119: + ; + pC24 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn2) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FnKey = int64((*TMem)(unsafe.Pointer(pIn2)).Fn) + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FpKey = (*TMem)(unsafe.Pointer(pIn2)).Fz + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FnMem = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_USESEEKRESULT) != 0 { + v190 = (*TVdbeCursor)(unsafe.Pointer(pC24)).FseekResult + } else { + v190 = 0 + } + rc = _sqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC24 + 48)), bp+408, libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&(libc.Int32FromInt32(OPFLAG_APPEND)|libc.Int32FromInt32(OPFLAG_SAVEPOSITION)|libc.Int32FromInt32(OPFLAG_PREFORMAT)), v190) + (*TVdbeCursor)(unsafe.Pointer(pC24)).FcacheStatus = uint32(CACHE_STALE) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: SorterInsert P1 P2 * * * + ** Synopsis: key=r[P2] + ** + ** Register P2 holds an SQL index key made using the + ** MakeRecord instructions. This opcode writes that key + ** into the sorter P1. Data for the entry is nil. + */ + _120: + ; + pC25 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn2) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + rc = _sqlite3VdbeSorterWrite(tls, pC25, pIn2) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: IdxDelete P1 P2 P3 P4 * + ** Synopsis: key=r[P2@P3] + ** + ** The content of P3 registers starting at register P2 form + ** an unpacked index key. This opcode removes that entry from the + ** index opened by cursor P1. + ** + ** P4 is a pointer to an Index structure. + ** + ** Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found + ** and not in writable_schema mode. + */ + _121: + ; + pC26 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr8 = *(*uintptr)(unsafe.Pointer(pC26 + 48)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC26)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FnField = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).Fdefault_rc = 0 + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + rc = _sqlite3BtreeIndexMoveto(tls, pCrsr8, bp+464, bp+456) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 456)) != 0 { + rc = _sqlite3VdbeFindIndexKey(tls, pCrsr8, *(*uintptr)(unsafe.Pointer(pOp + 16)), bp+464, bp+456, 0) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 456)) != 0 { + if !(_sqlite3WritableSchema(tls, db) != 0) { + rc = _sqlite3ReportError(tls, libc.Int32FromInt32(SQLITE_CORRUPT)|libc.Int32FromInt32(3)< int64(0x7fffffff) { + rc = _sqlite3CorruptError(tls, int32(103352)) + goto abort_due_to_error + } + _sqlite3VdbeMemInit(tls, bp+552, db, uint16(0)) + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCur2, libc.Uint32FromInt64(nCellKey), bp+552) + if rc != 0 { + goto abort_due_to_error + } + res11 = _sqlite3VdbeRecordCompareWithSkip(tls, (**(**TMem)(__ccgo_up(bp + 552))).Fn, (**(**TMem)(__ccgo_up(bp + 552))).Fz, bp+512, 0) + _sqlite3VdbeMemReleaseMalloc(tls, bp+552) + /* End of inlined sqlite3VdbeIdxKeyCompare() */ + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode)&int32(1) == libc.Int32FromInt32(OP_IdxLT)&libc.Int32FromInt32(1) { + res11 = -res11 + } else { + res11 = res11 + 1 + } + if res11 > 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Destroy P1 P2 P3 * * + ** + ** Delete an entire database table or index whose root page in the database + ** file is given by P1. + ** + ** The table being destroyed is in the main database file if P3==0. If + ** P3==1 then the table to be destroyed is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If AUTOVACUUM is enabled then it is possible that another root page + ** might be moved into the newly deleted root page in order to keep all + ** root pages contiguous at the beginning of the database. The former + ** value of the root page that moved - its value before the move occurred - + ** is stored in register P2. If no page movement was required (because the + ** table being dropped was already the last one in the database) then a + ** zero is stored in register P2. If AUTOVACUUM is disabled then a zero + ** is stored in register P2. + ** + ** This opcode throws an error if there are any active reader VMs when + ** it is invoked. This is done to avoid the difficulty associated with + ** updating existing cursors when a root page is moved in an AUTOVACUUM + ** database. This error is thrown even if the database is not an AUTOVACUUM + ** db in order to avoid introducing an incompatibility between autovacuum + ** and non-autovacuum modes. + ** + ** See also: Clear + */ + _129: + ; + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > (*Tsqlite3)(unsafe.Pointer(db)).FnVDestroy+int32(1) { + rc = int32(SQLITE_LOCKED) + (*TVdbe)(unsafe.Pointer(p)).FerrorAction = uint8(OE_Abort) + goto abort_due_to_error + } else { + iDb2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + **(**int32)(__ccgo_up(bp + 608)) = 0 /* Not needed. Only to silence a warning. */ + rc = _sqlite3BtreeDropTable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb2)*32))).FpBt, (*TOp)(unsafe.Pointer(pOp)).Fp1, bp+608) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) + *(*Ti64)(unsafe.Pointer(pOut)) = int64(**(**int32)(__ccgo_up(bp + 608))) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 608)) != 0 { + _sqlite3RootPageMoved(tls, db, iDb2, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 608))), libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp1)) + /* All OP_Destroy operations occur on the same btree */ + resetSchemaOnFault = libc.Uint8FromInt32(iDb2 + int32(1)) + } + } + goto _189 + /* Opcode: Clear P1 P2 P3 + ** + ** Delete all contents of the database table or index whose root page + ** in the database file is given by P1. But, unlike Destroy, do not + ** remove the table or index from the database file. + ** + ** The table being cleared is in the main database file if P2==0. If + ** P2==1 then the table to be cleared is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If the P3 value is non-zero, then the row change count is incremented + ** by the number of rows in the table being cleared. If P3 is greater + ** than zero, then the value stored in register P3 is also incremented + ** by the number of rows in the table being cleared. + ** + ** See also: Destroy + */ + _130: + ; + **(**Ti64)(__ccgo_up(bp + 616)) = 0 + rc = _sqlite3BtreeClearTable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*32))).FpBt, libc.Int32FromUint32(libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp1)), bp+616) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + **(**Ti64)(__ccgo_up(p + 56)) += **(**Ti64)(__ccgo_up(bp + 616)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 > 0 { + *(*Ti64)(unsafe.Pointer(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56)) += **(**Ti64)(__ccgo_up(bp + 616)) + } + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: ResetSorter P1 * * * * + ** + ** Delete all contents from the ephemeral table or sorter + ** that is open on cursor P1. + ** + ** This opcode only works for cursors used for sorting and + ** opened with OP_OpenEphemeral or OP_SorterOpen. + */ + _131: + ; + pC30 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC30)).FeCurType) == int32(CURTYPE_SORTER) { + _sqlite3VdbeSorterReset(tls, db, *(*uintptr)(unsafe.Pointer(pC30 + 48))) + } else { + rc = _sqlite3BtreeClearTableOfCursor(tls, *(*uintptr)(unsafe.Pointer(pC30 + 48))) + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: CreateBtree P1 P2 P3 * * + ** Synopsis: r[P2]=root iDb=P1 flags=P3 + ** + ** Allocate a new b-tree in the main database file if P1==0 or in the + ** TEMP database file if P1==1 or in an attached database if + ** P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table + ** it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table. + ** The root page number of the new b-tree is stored in register P2. + */ + _132: + ; + pOut = _out2Prerelease(tls, p, pOp) + **(**TPgno)(__ccgo_up(bp + 624)) = uint32(0) + pDb3 = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32 + rc = _sqlite3BtreeCreateTable(tls, (*TDb)(unsafe.Pointer(pDb3)).FpBt, bp+624, (*TOp)(unsafe.Pointer(pOp)).Fp3) + if rc != 0 { + goto abort_due_to_error + } + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(**(**TPgno)(__ccgo_up(bp + 624))) + goto _189 + /* Opcode: SqlExec P1 P2 * P4 * + ** + ** Run the SQL statement or statements specified in the P4 string. + ** + ** The P1 parameter is a bitmask of options: + ** + ** 0x0001 Disable Auth and Trace callbacks while the statements + ** in P4 are running. + ** + ** 0x0002 Set db->nAnalysisLimit to P2 while the statements in + ** P4 are running. + ** + */ + _133: + ; + (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec = (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec + 1 + **(**uintptr)(__ccgo_up(bp + 632)) = uintptr(0) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + mTrace = (*Tsqlite3)(unsafe.Pointer(db)).FmTrace + savedAnalysisLimit = (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit + if (*TOp)(unsafe.Pointer(pOp)).Fp1&int32(0x0001) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = uint8(0) + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1&int32(0x0002) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = (*TOp)(unsafe.Pointer(pOp)).Fp2 + } + rc = Xsqlite3_exec(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16)), uintptr(0), uintptr(0), bp+632) + (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec = (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec - 1 + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = mTrace + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = savedAnalysisLimit + if **(**uintptr)(__ccgo_up(bp + 632)) != 0 || rc != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, **(**uintptr)(__ccgo_up(bp + 632)))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 632))) + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + goto abort_due_to_error + } + goto _189 + /* Opcode: ParseSchema P1 * * P4 * + ** + ** Read and parse all entries from the schema table of database P1 + ** that match the WHERE clause P4. If P4 is a NULL pointer, then the + ** entire schema for P1 is reparsed. + ** + ** This opcode invokes the parser to create a new virtual machine, + ** then runs the new virtual machine. It is thus a re-entrant opcode. + */ + _134: + ; + /* Any prepared statement that invokes this opcode will hold mutexes + ** on every btree. This is a prerequisite for invoking + ** sqlite3InitCallback(). + */ + iDb3 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + if *(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0) { + _sqlite3SchemaClear(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FpSchema) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_SchemaKnownOk)) + rc = _sqlite3InitOne(tls, db, iDb3, p+168, uint32((*TOp)(unsafe.Pointer(pOp)).Fp5)) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + } else { + zSchema = __ccgo_ts + 6284 + (**(**TInitData)(__ccgo_up(bp + 640))).Fdb = db + (**(**TInitData)(__ccgo_up(bp + 640))).FiDb = iDb3 + (**(**TInitData)(__ccgo_up(bp + 640))).FpzErrMsg = p + 168 + (**(**TInitData)(__ccgo_up(bp + 640))).FmInitFlags = uint32(0) + (**(**TInitData)(__ccgo_up(bp + 640))).FmxPage = _sqlite3BtreeLastPage(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FpBt) + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+6298, libc.VaList(bp+984, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FzDbSName, zSchema, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(1) + (**(**TInitData)(__ccgo_up(bp + 640))).Frc = SQLITE_OK + (**(**TInitData)(__ccgo_up(bp + 640))).FnInitRow = uint32(0) + rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_sqlite3InitCallback), bp+640, uintptr(0)) + if rc == SQLITE_OK { + rc = (**(**TInitData)(__ccgo_up(bp + 640))).Frc + } + if rc == SQLITE_OK && (**(**TInitData)(__ccgo_up(bp + 640))).FnInitRow == uint32(0) { + /* The OP_ParseSchema opcode with a non-NULL P4 argument should parse + ** at least one SQL statement. Any less than that indicates that + ** the sqlite_schema table is corrupt. */ + rc = _sqlite3CorruptError(tls, int32(103645)) + } + _sqlite3DbFreeNN(tls, db, zSql) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(0) + } + } + if rc != 0 { + _sqlite3ResetAllSchemasOfConnection(tls, db) + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + goto abort_due_to_error + } + goto _189 + /* Opcode: LoadAnalysis P1 * * * * + ** + ** Read the sqlite_stat1 table for database P1 and load the content + ** of that table into the internal index hash table. This will cause + ** the analysis to be used when preparing all subsequent queries. + */ + _135: + ; + rc = _sqlite3AnalysisLoad(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: DropTable P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the table named P4 in database P1. This is called after a table + ** is dropped from disk (using the Destroy opcode) in order to keep + ** the internal representation of the + ** schema consistent with what is on disk. + */ + _136: + ; + _sqlite3UnlinkAndDeleteTable(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: DropIndex P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the index named P4 in database P1. This is called after an index + ** is dropped from disk (using the Destroy opcode) + ** in order to keep the internal representation of the + ** schema consistent with what is on disk. + */ + _137: + ; + _sqlite3UnlinkAndDeleteIndex(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: DropTrigger P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the trigger named P4 in database P1. This is called after a trigger + ** is dropped from disk (using the Destroy opcode) in order to keep + ** the internal representation of the + ** schema consistent with what is on disk. + */ + _138: + ; + _sqlite3UnlinkAndDeleteTrigger(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: IntegrityCk P1 P2 P3 P4 P5 + ** + ** Do an analysis of the currently open database. Store in + ** register (P1+1) the text of an error message describing any problems. + ** If no problems are found, store a NULL in register (P1+1). + ** + ** The register (P1) contains one less than the maximum number of allowed + ** errors. At most reg(P1) errors will be reported. + ** In other words, the analysis stops as soon as reg(P1) errors are + ** seen. Reg(P1) is updated with the number of errors remaining. + ** + ** The root page numbers of all tables in the database are integers + ** stored in P4_INTARRAY argument. + ** + ** If P5 is not zero, the check is done on the auxiliary database + ** file, not the main database file. + ** + ** This opcode is used to implement the integrity_check pragma. + */ + _139: + ; /* Register keeping track of errors remaining */ + nRoot = (*TOp)(unsafe.Pointer(pOp)).Fp2 + aRoot = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pnErr = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1+int32(1))*56 + rc = _sqlite3BtreeIntegrityCheck(tls, db, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*32))).FpBt, aRoot+1*4, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, nRoot, int32(*(*Ti64)(unsafe.Pointer(pnErr)))+int32(1), bp+680, bp+688) + _sqlite3VdbeMemSetNull(tls, pIn1) + if **(**int32)(__ccgo_up(bp + 680)) == 0 { + } else { + if rc != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 688))) + goto abort_due_to_error + } else { + *(*Ti64)(unsafe.Pointer(pnErr)) -= int64(**(**int32)(__ccgo_up(bp + 680)) - int32(1)) + _sqlite3VdbeMemSetStr(tls, pIn1, **(**uintptr)(__ccgo_up(bp + 688)), int64(-int32(1)), uint8(SQLITE_UTF8), __ccgo_fp(Xsqlite3_free)) + } + } + _sqlite3VdbeChangeEncoding(tls, pIn1, libc.Int32FromUint8(encoding)) + goto check_for_interrupt + /* Opcode: IFindKey P1 P2 P3 P4 * + ** + ** This instruction always follows an OP_Found with the same P1, P2 and P3 + ** values as this instruction and a non-zero P4 value. The P4 value to + ** this opcode is of type P4_INDEX and contains a pointer to the Index + ** object of for the index being searched. + ** + ** This opcode uses sqlite3VdbeFindIndexKey() to search around the current + ** cursor location for an index key that exactly matches all fields that + ** are not indexed expressions or references to VIRTUAL generated columns, + ** and either exactly match or are real numbers that are within 2 ULPs of + ** each other if the don't match. + ** + ** To put it another way, this opcode looks for nearby index entries that + ** are very close to the search key, but which might have small differences + ** in floating-point values that come via an expression. + ** + ** If no nearby alternative entry is found in cursor P1, then jump to P2. + ** But if a close match is found, fall through. + ** + ** This opcode is used by PRAGMA integrity_check to help distinguish + ** between truely corrupt indexes and expression indexes that are holding + ** floating-point values that are off by one or two ULPs. + */ + _140: + ; + pC31 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + libc.Xmemset(tls, bp+704, 0, uint64(40)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FnField = (*TIndex)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FnColumn + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC31)).FpKeyInfo + rc = _sqlite3VdbeFindIndexKey(tls, *(*uintptr)(unsafe.Pointer(pC31 + 48)), *(*uintptr)(unsafe.Pointer(pOp + 16)), bp+704, bp+696, int32(1)) + if rc != 0 || **(**int32)(__ccgo_up(bp + 696)) != 0 { + rc = SQLITE_OK + goto jump_to_p2 + } + (*TVdbeCursor)(unsafe.Pointer(pC31)).FnullRow = uint8(0) + goto _189 + /* Opcode: RowSetAdd P1 P2 * * * + ** Synopsis: rowset(P1)=r[P2] + ** + ** Insert the integer value held by register P2 into a RowSet object + ** held in register P1. + ** + ** An assertion fails if P2 is not an integer. + */ + _141: + ; /* in1, in2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + if _sqlite3VdbeMemSetRowSet(tls, pIn1) != 0 { + goto no_mem + } + } + _sqlite3RowSetInsert(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, *(*Ti64)(unsafe.Pointer(pIn2))) + goto _189 + /* Opcode: RowSetRead P1 P2 P3 * * + ** Synopsis: r[P3]=rowset(P1) + ** + ** Extract the smallest value from the RowSet object in P1 + ** and put that value into register P3. + ** Or, if RowSet object P1 is initially empty, leave P3 + ** unchanged and jump to instruction P2. + */ + _142: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 || _sqlite3RowSetNext(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, bp+744) == 0 { + /* The boolean index is empty */ + _sqlite3VdbeMemSetNull(tls, pIn1) + goto jump_to_p2_and_check_for_interrupt + } else { + /* A value was pulled from the index */ + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, **(**Ti64)(__ccgo_up(bp + 744))) + } + goto check_for_interrupt + /* Opcode: RowSetTest P1 P2 P3 P4 + ** Synopsis: if r[P3] in rowset(P1) goto P2 + ** + ** Register P3 is assumed to hold a 64-bit integer value. If register P1 + ** contains a RowSet object and that RowSet object contains + ** the value held in P3, jump to register P2. Otherwise, insert the + ** integer in P3 into the RowSet and continue on to the + ** next opcode. + ** + ** The RowSet object is optimized for the case where sets of integers + ** are inserted in distinct phases, which each set contains no duplicates. + ** Each set is identified by a unique P4 value. The first set + ** must have P4==0, the final set must have P4==-1, and for all other sets + ** must have P4>0. + ** + ** This allows optimizations: (a) when P4==0 there is no need to test + ** the RowSet object for P3, as it is guaranteed not to contain it, + ** (b) when P4==-1 there is no need to insert the value, as it will + ** never be tested for, and (c) when a value that is part of set X is + ** inserted, there is no need to search to see if the same value was + ** previously inserted as part of set X (only if it was previously + ** inserted as part of some other set). + */ + _143: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + iSet = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + /* If there is anything other than a rowset object in memory cell P1, + ** delete it now and initialize P1 with an empty rowset + */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + if _sqlite3VdbeMemSetRowSet(tls, pIn1) != 0 { + goto no_mem + } + } + if iSet != 0 { + exists = _sqlite3RowSetTest(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, iSet, *(*Ti64)(unsafe.Pointer(pIn3))) + if exists != 0 { + goto jump_to_p2 + } + } + if iSet >= 0 { + _sqlite3RowSetInsert(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, *(*Ti64)(unsafe.Pointer(pIn3))) + } + goto _189 + /* Opcode: Program P1 P2 P3 P4 P5 + ** + ** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). + ** + ** P1 contains the address of the memory cell that contains the first memory + ** cell in an array of values used as arguments to the sub-program. P2 + ** contains the address to jump to if the sub-program throws an IGNORE + ** exception using the RAISE() function. P2 might be zero, if there is + ** no possibility that an IGNORE exception will be raised. + ** Register P3 contains the address + ** of a memory cell in this (the parent) VM that is used to allocate the + ** memory required by the sub-vdbe at runtime. + ** + ** P4 is a pointer to the VM containing the trigger program. + ** + ** If P5 is non-zero, then recursive program invocation is enabled. + */ + _144: + ; /* Token identifying trigger */ + pProgram = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pRt = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + /* If the p5 flag is clear, then recursive invocation of triggers is + ** disabled for backwards compatibility (p5 is set if this sub-program + ** is really a trigger, not a foreign key action, and the flag set + ** and cleared by the "PRAGMA recursive_triggers" command is clear). + ** + ** It is recursive invocation of triggers, at the SQL level, that is + ** disabled. In some cases a single trigger may generate more than one + ** SubProgram (if the trigger may be executed with more than one different + ** ON CONFLICT algorithm). SubProgram structures associated with a + ** single trigger all have the same value for the SubProgram.token + ** variable. */ + if (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 { + t1 = (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken + pFrame2 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + for { + if !(pFrame2 != 0 && (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken != t1) { + break + } + goto _278 + _278: + ; + pFrame2 = (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpParent + } + if pFrame2 != 0 { + goto _189 + } + } + if (*TVdbe)(unsafe.Pointer(p)).FnFrame >= **(**int32)(__ccgo_up(db + 136 + 10*4)) { + rc = int32(SQLITE_ERROR) + _sqlite3VdbeError(tls, p, __ccgo_ts+6341, 0) + goto abort_due_to_error + } + /* Register pRt is used to store the memory required to save the state + ** of the current program, and the memory required at runtime to execute + ** the trigger program. If this trigger has been fired before, then pRt + ** is already allocated. Otherwise, it must be initialized. */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRt)).Fflags)&int32(MEM_Blob) == 0 { + /* SubProgram.nMem is set to the number of memory cells used by the + ** program stored in SubProgram.aOp. As well as these, one memory + ** cell is required for each cursor used by the program. Set local + ** variable nMem (and later, VdbeFrame.nChildMem) to this value. + */ + nMem = (*TSubProgram)(unsafe.Pointer(pProgram)).FnMem + (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr + if (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr == 0 { + nMem = nMem + 1 + } + nByte2 = libc.Int64FromUint64(uint64((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32(nMem)*uint64(56)+libc.Uint64FromInt32((*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr)*uint64(8)) + libc.Uint64FromInt64((int64(7)+int64((*TSubProgram)(unsafe.Pointer(pProgram)).FnOp))/int64(8))) + pFrame2 = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte2)) + if !(pFrame2 != 0) { + goto no_mem + } + _sqlite3VdbeMemRelease(tls, pRt) + (*TMem)(unsafe.Pointer(pRt)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Blob) | libc.Int32FromInt32(MEM_Dyn)) + (*TMem)(unsafe.Pointer(pRt)).Fz = pFrame2 + (*TMem)(unsafe.Pointer(pRt)).Fn = int32(nByte2) + (*TMem)(unsafe.Pointer(pRt)).FxDel = __ccgo_fp(_sqlite3VdbeFrameMemDel) + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Fv = p + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem = nMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr = (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaMem = (*TVdbe)(unsafe.Pointer(p)).FaMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnMem = (*TVdbe)(unsafe.Pointer(p)).FnMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FapCsr = (*TVdbe)(unsafe.Pointer(p)).FapCsr + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnCursor = (*TVdbe)(unsafe.Pointer(p)).FnCursor + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnOp = (*TVdbe)(unsafe.Pointer(p)).FnOp + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken = (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken + pEnd = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + uintptr((*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*56 + pMem1 = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + for { + if !(pMem1 != pEnd) { + break + } + (*TMem)(unsafe.Pointer(pMem1)).Fflags = uint16(MEM_Undefined) + (*TMem)(unsafe.Pointer(pMem1)).Fdb = db + goto _279 + _279: + ; + pMem1 += 56 + } + } else { + pFrame2 = (*TMem)(unsafe.Pointer(pRt)).Fz + } + (*TVdbe)(unsafe.Pointer(p)).FnFrame = (*TVdbe)(unsafe.Pointer(p)).FnFrame + 1 + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpParent = (*TVdbe)(unsafe.Pointer(p)).FpFrame + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FlastRowid = (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnDbChange = (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FnChange + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpAuxData = (*TVdbe)(unsafe.Pointer(p)).FpAuxData + (*TVdbe)(unsafe.Pointer(p)).FpAuxData = uintptr(0) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + (*TVdbe)(unsafe.Pointer(p)).FpFrame = pFrame2 + v191 = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + aMem = v191 + (*TVdbe)(unsafe.Pointer(p)).FaMem = v191 + (*TVdbe)(unsafe.Pointer(p)).FnMem = (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem + (*TVdbe)(unsafe.Pointer(p)).FnCursor = libc.Int32FromUint16(libc.Uint16FromInt32((*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr)) + (*TVdbe)(unsafe.Pointer(p)).FapCsr = aMem + uintptr((*TVdbe)(unsafe.Pointer(p)).FnMem)*56 + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce = (*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr)*8 + libc.Xmemset(tls, (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce, 0, libc.Uint64FromInt32(((*TSubProgram)(unsafe.Pointer(pProgram)).FnOp+int32(7))/int32(8))) + v191 = (*TSubProgram)(unsafe.Pointer(pProgram)).FaOp + aOp = v191 + (*TVdbe)(unsafe.Pointer(p)).FaOp = v191 + (*TVdbe)(unsafe.Pointer(p)).FnOp = (*TSubProgram)(unsafe.Pointer(pProgram)).FnOp + pOp = aOp + uintptr(-libc.Int32FromInt32(1))*24 + goto check_for_interrupt + /* Opcode: Param P1 P2 * * * + ** + ** This opcode is only ever present in sub-programs called via the + ** OP_Program instruction. Copy a value currently stored in a memory + ** cell of the calling (parent) frame to cell P2 in the current frames + ** address space. This is used by trigger programs to access the new.* + ** and old.* values. + ** + ** The address of the cell in the parent frame is determined by adding + ** the value of the P1 argument to the value of the P1 argument to the + ** calling OP_Program instruction. + */ + _145: + ; + pOut = _out2Prerelease(tls, p, pOp) + pFrame3 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + pIn = (*TVdbeFrame)(unsafe.Pointer(pFrame3)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1+(**(**TOp)(__ccgo_up((*TVdbeFrame)(unsafe.Pointer(pFrame3)).FaOp + uintptr((*TVdbeFrame)(unsafe.Pointer(pFrame3)).Fpc)*24))).Fp1)*56 + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn, int32(MEM_Ephem)) + goto _189 + /* Opcode: FkCounter P1 P2 * * * + ** Synopsis: fkctr[P1]+=P2 + ** + ** Increment a "constraint counter" by P2 (P2 may be negative or positive). + ** If P1 is non-zero, the database constraint counter is incremented + ** (deferred foreign key constraints). Otherwise, if P1 is zero, the + ** statement counter is incremented (immediate foreign key constraints). + */ + _146: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + **(**Ti64)(__ccgo_up(db + 784)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0 { + **(**Ti64)(__ccgo_up(db + 792)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + **(**Ti64)(__ccgo_up(p + 80)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } + } + goto _189 + /* Opcode: FkIfZero P1 P2 * * * + ** Synopsis: if fkctr[P1]==0 goto P2 + ** + ** This opcode tests if a foreign key constraint-counter is currently zero. + ** If so, jump to instruction P2. Otherwise, fall through to the next + ** instruction. + ** + ** If P1 is non-zero, then the jump is taken if the database constraint-counter + ** is zero (the one that counts deferred constraint violations). If P1 is + ** zero, the jump is taken if the statement constraint-counter is zero + ** (immediate foreign key constraint violations). + */ + _147: + ; /* jump */ + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { + goto jump_to_p2 + } + } else { + if (*TVdbe)(unsafe.Pointer(p)).FnFkConstraint == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: MemMax P1 P2 * * * + ** Synopsis: r[P1]=max(r[P1],r[P2]) + ** + ** P1 is a register in the root frame of this VM (the root frame is + ** different from the current frame if this instruction is being executed + ** within a sub-program). Set the value of register P1 to the maximum of + ** its current value and the value in register P2. + ** + ** This instruction throws an error if the memory cell is not initially + ** an integer. + */ + _148: + ; + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + pFrame4 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + for { + if !((*TVdbeFrame)(unsafe.Pointer(pFrame4)).FpParent != 0) { + break + } + goto _282 + _282: + ; + pFrame4 = (*TVdbeFrame)(unsafe.Pointer(pFrame4)).FpParent + } + pIn1 = (*TVdbeFrame)(unsafe.Pointer(pFrame4)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + } else { + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + } + _sqlite3VdbeMemIntegerify(tls, pIn1) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemIntegerify(tls, pIn2) + if *(*Ti64)(unsafe.Pointer(pIn1)) < *(*Ti64)(unsafe.Pointer(pIn2)) { + *(*Ti64)(unsafe.Pointer(pIn1)) = *(*Ti64)(unsafe.Pointer(pIn2)) + } + goto _189 + /* Opcode: IfPos P1 P2 P3 * * + ** Synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 + ** + ** Register P1 must contain an integer. + ** If the value of register P1 is 1 or greater, subtract P3 from the + ** value in P1 and jump to P2. + ** + ** If the initial value of register P1 is less than 1, then the + ** value is unchanged and control passes through to the next instruction. + */ + _149: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) > 0 { + *(*Ti64)(unsafe.Pointer(pIn1)) -= int64((*TOp)(unsafe.Pointer(pOp)).Fp3) + goto jump_to_p2 + } + goto _189 + /* Opcode: OffsetLimit P1 P2 P3 * * + ** Synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) + ** + ** This opcode performs a commonly used computation associated with + ** LIMIT and OFFSET processing. r[P1] holds the limit counter. r[P3] + ** holds the offset counter. The opcode computes the combined value + ** of the LIMIT and OFFSET and stores that value in r[P2]. The r[P2] + ** value computed is the total number of rows that will need to be + ** visited in order to complete the query. + ** + ** If r[P3] is zero or negative, that means there is no OFFSET + ** and r[P2] is set to be the value of the LIMIT, r[P1]. + ** + ** if r[P1] is zero or negative, that means there is no LIMIT + ** and r[P2] is set to -1. + ** + ** Otherwise, r[P2] is set to the sum of r[P1] and r[P3]. + */ + _150: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + pOut = _out2Prerelease(tls, p, pOp) + **(**Ti64)(__ccgo_up(bp + 752)) = *(*Ti64)(unsafe.Pointer(pIn1)) + if v217 = **(**Ti64)(__ccgo_up(bp + 752)) <= 0; !v217 { + if *(*Ti64)(unsafe.Pointer(pIn3)) > 0 { + v206 = *(*Ti64)(unsafe.Pointer(pIn3)) + } else { + v206 = 0 + } + } + if v217 || _sqlite3AddInt64(tls, bp+752, v206) != 0 { + /* If the LIMIT is less than or equal to zero, loop forever. This + ** is documented. But also, if the LIMIT+OFFSET exceeds 2^63 then + ** also loop forever. This is undocumented. In fact, one could argue + ** that the loop should terminate. But assuming 1 billion iterations + ** per second (far exceeding the capabilities of any current hardware) + ** it would take nearly 300 years to actually reach the limit. So + ** looping forever is a reasonable approximation. */ + *(*Ti64)(unsafe.Pointer(pOut)) = int64(-int32(1)) + } else { + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 752)) + } + goto _189 + /* Opcode: IfNotZero P1 P2 * * * + ** Synopsis: if r[P1]!=0 then r[P1]--, goto P2 + ** + ** Register P1 must contain an integer. If the content of register P1 is + ** initially greater than zero, then decrement the value in register P1. + ** If it is non-zero (negative or positive) and then also jump to P2. + ** If register P1 is initially zero, leave it unchanged and fall through. + */ + _151: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) != 0 { + if *(*Ti64)(unsafe.Pointer(pIn1)) > 0 { + *(*Ti64)(unsafe.Pointer(pIn1)) = *(*Ti64)(unsafe.Pointer(pIn1)) - 1 + } + goto jump_to_p2 + } + goto _189 + /* Opcode: DecrJumpZero P1 P2 * * * + ** Synopsis: if (--r[P1])==0 goto P2 + ** + ** Register P1 must hold an integer. Decrement the value in P1 + ** and jump to P2 if the new value is exactly zero. + */ + _152: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) > int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= 0) { + break + } + *(*uintptr)(unsafe.Pointer(pCtx1 + 48 + uintptr(i4)*8)) = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2+i4)*56 + goto _285 + _285: + ; + i4 = i4 - 1 + } + } + (*TMem)(unsafe.Pointer(pMem2)).Fn = (*TMem)(unsafe.Pointer(pMem2)).Fn + 1 + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxInverse})))(tls, pCtx1, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+48) + } else { + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxSFunc})))(tls, pCtx1, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+48) + } /* IMP: R-24505-23230 */ + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError != 0 { + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError > 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut))) + rc = (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError + } + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag != 0 { + i4 = (**(**TOp)(__ccgo_up(pOp + uintptr(-libc.Int32FromInt32(1))*24))).Fp1 + if i4 != 0 { + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr(i4)*56, int64(1)) + } + (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag = uint8(0) + } + _sqlite3VdbeMemRelease(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut) + (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = uint16(MEM_Null) + (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError = 0 + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: AggFinal P1 P2 * P4 * + ** Synopsis: accum=r[P1] N=P2 + ** + ** P1 is the memory location that is the accumulator for an aggregate + ** or window function. Execute the finalizer function + ** for an aggregate and store the result in P1. + ** + ** P2 is the number of arguments that the step function takes and + ** P4 is a pointer to the FuncDef for this function. The P2 + ** argument is not used by this opcode. It is only there to disambiguate + ** functions that can take varying numbers of arguments. The + ** P4 argument is only needed for the case where + ** the step function was not previously called. + */ + /* Opcode: AggValue * P2 P3 P4 * + ** Synopsis: r[P3]=value N=P2 + ** + ** Invoke the xValue() function and store the result in register P3. + ** + ** P2 is the number of arguments that the step function takes and + ** P4 is a pointer to the FuncDef for this function. The P2 + ** argument is not used by this opcode. It is only there to disambiguate + ** functions that can take varying numbers of arguments. The + ** P4 argument is only needed for the case where + ** the step function was not previously called. + */ + _157: + ; + _156: + ; + pMem3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + rc = _sqlite3VdbeMemAggValue(tls, pMem3, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, *(*uintptr)(unsafe.Pointer(pOp + 16))) + pMem3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + } else { + rc = _sqlite3VdbeMemFinalize(tls, pMem3, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + if rc != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pMem3))) + goto abort_due_to_error + } + _sqlite3VdbeChangeEncoding(tls, pMem3, libc.Int32FromUint8(encoding)) + goto _189 + /* Opcode: Checkpoint P1 P2 P3 * * + ** + ** Checkpoint database P1. This is a no-op if P1 is not currently in + ** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL, + ** RESTART, or TRUNCATE. Write 1 or 0 into mem[P3] if the checkpoint returns + ** SQLITE_BUSY or not, respectively. Write the number of pages in the + ** WAL after the checkpoint into mem[P3+1] and the number of pages + ** in the WAL that have been checkpointed after the checkpoint + ** completes into mem[P3+2]. However on an error, mem[P3+1] and + ** mem[P3+2] are initialized to -1. + */ + _158: + ; /* Write results here */ + (**(**[3]int32)(__ccgo_up(bp + 760)))[0] = 0 + v190 = -libc.Int32FromInt32(1) + (**(**[3]int32)(__ccgo_up(bp + 760)))[int32(2)] = v190 + (**(**[3]int32)(__ccgo_up(bp + 760)))[int32(1)] = v190 + rc = _sqlite3Checkpoint(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, bp+760+1*4, bp+760+2*4) + if rc != 0 { + if rc != int32(SQLITE_BUSY) { + goto abort_due_to_error + } + rc = SQLITE_OK + (**(**[3]int32)(__ccgo_up(bp + 760)))[0] = int32(1) + } + i5 = 0 + pMem4 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + for { + if !(i5 < int32(3)) { + break + } + _sqlite3VdbeMemSetInt64(tls, pMem4, int64((**(**[3]int32)(__ccgo_up(bp + 760)))[i5])) + goto _287 + _287: + ; + i5 = i5 + 1 + pMem4 += 56 + } + goto _189 + /* Opcode: JournalMode P1 P2 P3 * * + ** + ** Change the journal mode of database P1 to P3. P3 must be one of the + ** PAGER_JOURNALMODE_XXX values. If changing between the various rollback + ** modes (delete, truncate, persist, off and memory), this is a simple + ** operation. No IO is required. + ** + ** If changing into or out of WAL mode the procedure is more complicated. + ** + ** Write a string containing the final journal-mode to register P2. + */ + _159: + ; /* Name of database file for pPager */ + pOut = _out2Prerelease(tls, p, pOp) + eNew = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pBt1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + pPager = _sqlite3BtreePager(tls, pBt1) + eOld = _sqlite3PagerGetJournalMode(tls, pPager) + if eNew == -int32(1) { + eNew = eOld + } + if !(_sqlite3PagerOkToChangeJournalMode(tls, pPager) != 0) { + eNew = eOld + } + zFilename = _sqlite3PagerFilename(tls, pPager, int32(1)) + /* Do not allow a transition to journal_mode=WAL for a database + ** in temporary storage or if the VFS does not support shared memory + */ + if eNew == int32(PAGER_JOURNALMODE_WAL) && (_sqlite3Strlen30(tls, zFilename) == 0 || !(_sqlite3PagerWalSupported(tls, pPager) != 0)) { + eNew = eOld + } + if eNew != eOld && (eOld == int32(PAGER_JOURNALMODE_WAL) || eNew == int32(PAGER_JOURNALMODE_WAL)) { + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1) { + rc = int32(SQLITE_ERROR) + if eNew == int32(PAGER_JOURNALMODE_WAL) { + v191 = __ccgo_ts + 6378 + } else { + v191 = __ccgo_ts + 6383 + } + _sqlite3VdbeError(tls, p, __ccgo_ts+6390, libc.VaList(bp+984, v191)) + goto abort_due_to_error + } else { + if eOld == int32(PAGER_JOURNALMODE_WAL) { + /* If leaving WAL mode, close the log file. If successful, the call + ** to PagerCloseWal() checkpoints and deletes the write-ahead-log + ** file. An EXCLUSIVE lock may still be held on the database file + ** after a successful return. + */ + rc = _sqlite3PagerCloseWal(tls, pPager, db) + if rc == SQLITE_OK { + _sqlite3PagerSetJournalMode(tls, pPager, eNew) + } + } else { + if eOld == int32(PAGER_JOURNALMODE_MEMORY) { + /* Cannot transition directly from MEMORY to WAL. Use mode OFF + ** as an intermediate */ + _sqlite3PagerSetJournalMode(tls, pPager, int32(PAGER_JOURNALMODE_OFF)) + } + } + /* Open a transaction on the database file. Regardless of the journal + ** mode, this transaction always uses a rollback journal. + */ + if rc == SQLITE_OK { + if eNew == int32(PAGER_JOURNALMODE_WAL) { + v190 = int32(2) + } else { + v190 = int32(1) + } + rc = _sqlite3BtreeSetVersion(tls, pBt1, v190) + } + } + } + if rc != 0 { + eNew = eOld + } + eNew = _sqlite3PagerSetJournalMode(tls, pPager, eNew) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fz = _sqlite3JournalModename(tls, eNew) + (*TMem)(unsafe.Pointer(pOut)).Fn = _sqlite3Strlen30(tls, (*TMem)(unsafe.Pointer(pOut)).Fz) + (*TMem)(unsafe.Pointer(pOut)).Fenc = uint8(SQLITE_UTF8) + _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8(encoding)) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Vacuum P1 P2 * * * + ** + ** Vacuum the entire database P1. P1 is 0 for "main", and 2 or more + ** for an attached database. The "temp" database may not be vacuumed. + ** + ** If P2 is not zero, then it is a register holding a string which is + ** the file into which the result of vacuum should be written. When + ** P2 is zero, the vacuum overwrites the original database. + */ + _160: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 { + v191 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + } else { + v191 = uintptr(0) + } + rc = _sqlite3RunVacuum(tls, p+168, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, v191) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: IncrVacuum P1 P2 * * * + ** + ** Perform a single step of the incremental vacuum procedure on + ** the P1 database. If the vacuum has finished, jump to instruction + ** P2. Otherwise, fall through to the next instruction. + */ + _161: + ; + pBt2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + rc = _sqlite3BtreeIncrVacuum(tls, pBt2) + if rc != 0 { + if rc != int32(SQLITE_DONE) { + goto abort_due_to_error + } + rc = SQLITE_OK + goto jump_to_p2 + } + goto _189 + /* Opcode: Expire P1 P2 * * * + ** + ** Cause precompiled statements to expire. When an expired statement + ** is executed using sqlite3_step() it will either automatically + ** reprepare itself (if it was originally created using sqlite3_prepare_v2()) + ** or it will fail with SQLITE_SCHEMA. + ** + ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, + ** then only the currently executing statement is expired. + ** + ** If P2 is 0, then SQL statements are expired immediately. If P2 is 1, + ** then running SQL statements are allowed to continue to run to completion. + ** The P2==1 case occurs when a CREATE INDEX or similar schema change happens + ** that might help the statement run faster but which does not affect the + ** correctness of operation. + */ + _162: + ; + if !((*TOp)(unsafe.Pointer(pOp)).Fp1 != 0) { + _sqlite3ExpirePreparedStatements(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2+libc.Int32FromInt32(1)), 0, 0x3) + } + goto _189 + /* Opcode: CursorLock P1 * * * * + ** + ** Lock the btree to which cursor P1 is pointing so that the btree cannot be + ** written by an other cursor. + */ + _163: + ; + pC32 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + _sqlite3BtreeCursorPin(tls, *(*uintptr)(unsafe.Pointer(pC32 + 48))) + goto _189 + /* Opcode: CursorUnlock P1 * * * * + ** + ** Unlock the btree to which cursor P1 is pointing so that it can be + ** written by other cursors. + */ + _164: + ; + pC33 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + _sqlite3BtreeCursorUnpin(tls, *(*uintptr)(unsafe.Pointer(pC33 + 48))) + goto _189 + /* Opcode: TableLock P1 P2 P3 P4 * + ** Synopsis: iDb=P1 root=P2 write=P3 + ** + ** Obtain a lock on a particular table. This instruction is only used when + ** the shared-cache feature is enabled. + ** + ** P1 is the index of the database in sqlite3.aDb[] of the database + ** on which the lock is acquired. A readlock is obtained if P3==0 or + ** a write lock if P3==1. + ** + ** P2 contains the root-page of the table to lock. + ** + ** P4 contains a pointer to the name of the table being locked. This is only + ** used to generate an error message if the lock cannot be obtained. + */ + _165: + ; + isWriteLock = libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + if isWriteLock != 0 || uint64(0) == (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00004))< 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pDest2))) + rc = (**(**Tsqlite3_context)(__ccgo_up(bp + 848))).FisError + } + _sqlite3VdbeChangeEncoding(tls, pDest2, libc.Int32FromUint8(encoding)) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: VNext P1 P2 * * * + ** + ** Advance virtual table P1 to the next row in its result set and + ** jump to instruction P2. Or, if the virtual table has reached + ** the end of its result set, then fall through to the next instruction. + */ + _174: + ; + pCur6 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TVdbeCursor)(unsafe.Pointer(pCur6)).FnullRow != 0 { + goto _189 + } + pVtab5 = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCur6 + 48)))).FpVtab + pModule5 = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab5)).FpModule + /* Invoke the xNext() method of the module. There is no way for the + ** underlying implementation to return an error if one occurs during + ** xNext(). Instead, if an error occurs, true is returned (indicating that + ** data is available) and the error code returned when xColumn or + ** some other method is next invoked on the save virtual table cursor. + */ + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule5)).FxNext})))(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 48))) + _sqlite3VtabImportErrmsg(tls, p, pVtab5) + if rc != 0 { + goto abort_due_to_error + } + res14 = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule5)).FxEof})))(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 48))) + if !(res14 != 0) { + /* If there is data, jump to P2 */ + goto jump_to_p2_and_check_for_interrupt + } + goto check_for_interrupt + /* Opcode: VRename P1 * * P4 * + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** This opcode invokes the corresponding xRename method. The value + ** in register P1 is passed as the zName argument to the xRename method. + */ + _175: + ; + isLegacy = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_LegacyAlter)) + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_LegacyAlter) + pVtab6 = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab + pName = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + rc = _sqlite3VdbeChangeEncoding(tls, pName, int32(SQLITE_UTF8)) + if rc != 0 { + goto abort_due_to_error + } + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVtab6)).FpModule)).FxRename})))(tls, pVtab6, (*TMem)(unsafe.Pointer(pName)).Fz) + if isLegacy == 0 { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_LegacyAlter) + } + _sqlite3VtabImportErrmsg(tls, p, pVtab6) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: VUpdate P1 P2 P3 P4 P5 + ** Synopsis: data=r[P3@P2] + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** This opcode invokes the corresponding xUpdate method. P2 values + ** are contiguous memory cells starting at P3 to pass to the xUpdate + ** invocation. The value in register (P3+P2-1) corresponds to the + ** p2th element of the argv array passed to xUpdate. + ** + ** The xUpdate method will do a DELETE or an INSERT or both. + ** The argv[0] element (which corresponds to memory cell P3) + ** is the rowid of a row to delete. If argv[0] is NULL then no + ** deletion occurs. The argv[1] element is the rowid of the new + ** row. This can be NULL to have the virtual table select the new + ** rowid for itself. The subsequent elements in the array are + ** the values of columns in the new row. + ** + ** If P2==1 then no insert is performed. argv[0] is the rowid of + ** a row to delete. + ** + ** P1 is a boolean flag. If it is set to true and the xUpdate call + ** is successful, then the value returned by sqlite3_last_insert_rowid() + ** is set to the value of the rowid for the row just inserted. + ** + ** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to + ** apply in the case of a constraint failure on an insert or update. + */ + _176: + ; + **(**Tsqlite_int64)(__ccgo_up(bp + 968)) = 0 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto no_mem + } + pVtab7 = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab + if pVtab7 == uintptr(0) || (*Tsqlite3_vtab)(unsafe.Pointer(pVtab7)).FpModule == uintptr(0) { + rc = int32(SQLITE_LOCKED) + goto abort_due_to_error + } + pModule6 = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab7)).FpModule + nArg1 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + if (*Tsqlite3_module)(unsafe.Pointer(pModule6)).FxUpdate != 0 { + vtabOnConflict = (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict + apArg1 = (*TVdbe)(unsafe.Pointer(p)).FapArg + pX1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + i7 = 0 + for { + if !(i7 < nArg1) { + break + } + **(**uintptr)(__ccgo_up(apArg1 + uintptr(i7)*8)) = pX1 + pX1 += 56 + goto _292 + _292: + ; + i7 = i7 + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict = uint8((*TOp)(unsafe.Pointer(pOp)).Fp5) + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule6)).FxUpdate})))(tls, pVtab7, nArg1, apArg1, bp+968) + (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict = vtabOnConflict + _sqlite3VtabImportErrmsg(tls, p, pVtab7) + if rc == SQLITE_OK && (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = **(**Tsqlite_int64)(__ccgo_up(bp + 968)) + } + if rc&int32(0xff) == int32(SQLITE_CONSTRAINT) && (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FbConstraint != 0 { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == int32(OE_Ignore) { + rc = SQLITE_OK + } else { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == int32(OE_Replace) { + v190 = int32(OE_Abort) + } else { + v190 = libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) + } + (*TVdbe)(unsafe.Pointer(p)).FerrorAction = libc.Uint8FromInt32(v190) + } + } else { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + } + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: Pagecount P1 P2 * * * + ** + ** Write the current number of pages in database P1 to memory cell P2. + */ + _177: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(_sqlite3BtreeLastPage(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt)) + goto _189 + /* Opcode: MaxPgcnt P1 P2 P3 * * + ** + ** Try to set the maximum page count for database P1 to the value in P3. + ** Do not let the maximum page count fall below the current page count and + ** do not change the maximum page count value if P3==0. + ** + ** Store the maximum page count after the change in register P2. + */ + _178: + ; + pOut = _out2Prerelease(tls, p, pOp) + pBt3 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + newMax = uint32(0) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + newMax = _sqlite3BtreeLastPage(tls, pBt3) + if newMax < libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) { + newMax = libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(_sqlite3BtreeMaxPageCount(tls, pBt3, newMax)) + goto _189 + /* Opcode: Function P1 P2 P3 P4 * + ** Synopsis: r[P3]=func(r[P2@NP]) + ** + ** Invoke a user function (P4 is a pointer to an sqlite3_context object that + ** contains a pointer to the function to be run) with arguments taken + ** from register P2 and successors. The number of arguments is in + ** the sqlite3_context object that P4 points to. + ** The result of the function is stored + ** in register P3. Register P3 must not be one of the function inputs. + ** + ** P1 is a 32-bit bitmask indicating whether or not each argument to the + ** function was determined to be constant at compile time. If the first + ** argument was constant then bit 0 of P1 is set. This is used to determine + ** whether meta data associated with a user function argument using the + ** sqlite3_set_auxdata() API may be safely retained until the next + ** invocation of this opcode. + ** + ** See also: AggStep, AggFinal, PureFunc + */ + /* Opcode: PureFunc P1 P2 P3 P4 * + ** Synopsis: r[P3]=func(r[P2@NP]) + ** + ** Invoke a user function (P4 is a pointer to an sqlite3_context object that + ** contains a pointer to the function to be run) with arguments taken + ** from register P2 and successors. The number of arguments is in + ** the sqlite3_context object that P4 points to. + ** The result of the function is stored + ** in register P3. Register P3 must not be one of the function inputs. + ** + ** P1 is a 32-bit bitmask indicating whether or not each argument to the + ** function was determined to be constant at compile time. If the first + ** argument was constant then bit 0 of P1 is set. This is used to determine + ** whether meta data associated with a user function argument using the + ** sqlite3_set_auxdata() API may be safely retained until the next + ** invocation of this opcode. + ** + ** This opcode works exactly like OP_Function. The only difference is in + ** its name. This opcode is used in places where the function must be + ** purely non-deterministic. Some built-in date/time functions can be + ** either deterministic of non-deterministic, depending on their arguments. + ** When those function are used in a non-deterministic way, they will check + ** to see if they were called using OP_PureFunc instead of OP_Function, and + ** if they were, they throw an error. + ** + ** See also: AggStep, AggFinal, Function + */ + _180: + ; /* group */ + _179: + ; + pCtx2 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + /* If this function is inside of a trigger, the register array in aMem[] + ** might change from one evaluation to the next. The next block of code + ** checks to see if the register array has changed, and if so it + ** reinitializes the relevant parts of the sqlite3_context object */ + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpOut != pOut { + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpVdbe = p + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpOut = pOut + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fenc = encoding + i8 = libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fargc) - int32(1) + for { + if !(i8 >= 0) { + break + } + *(*uintptr)(unsafe.Pointer(pCtx2 + 48 + uintptr(i8)*8)) = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2+i8)*56 + goto _294 + _294: + ; + i8 = i8 - 1 + } + } + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Null)) + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpFunc)).FxSFunc})))(tls, pCtx2, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fargc), pCtx2+48) /* IMP: R-24505-23230 */ + /* If the function returned an error, throw an exception */ + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError != 0 { + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError > 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pOut))) + rc = (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError + } + _sqlite3VdbeDeleteAuxData(tls, db, p+296, (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FiOp, (*TOp)(unsafe.Pointer(pOp)).Fp1) + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError = 0 + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: ClrSubtype P1 * * * * + ** Synopsis: r[P1].subtype = 0 + ** + ** Clear the subtype from register P1. + */ + _181: + ; /* in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + goto _189 + /* Opcode: GetSubtype P1 P2 * * * + ** Synopsis: r[P2] = r[P1].subtype + ** + ** Extract the subtype value from register P1 and write that subtype + ** into register P2. If P1 has no subtype, then P1 gets a NULL. + */ + _182: + ; /* in1 out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Subtype) != 0 { + _sqlite3VdbeMemSetInt64(tls, pOut, libc.Int64FromUint8((*TMem)(unsafe.Pointer(pIn1)).FeSubtype)) + } else { + _sqlite3VdbeMemSetNull(tls, pOut) + } + goto _189 + /* Opcode: SetSubtype P1 P2 * * * + ** Synopsis: r[P2].subtype = r[P1] + ** + ** Set the subtype value of register P2 to the integer from register P1. + ** If P1 is NULL, clear the subtype from p2. + */ + _183: + ; /* in1 out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) != 0 { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + } else { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Subtype)) + (*TMem)(unsafe.Pointer(pOut)).FeSubtype = libc.Uint8FromInt64(*(*Ti64)(unsafe.Pointer(pIn1)) & libc.Int64FromInt32(0xff)) + } + goto _189 + /* Opcode: FilterAdd P1 * P3 P4 * + ** Synopsis: filter(P1) += key(P3@P4) + ** + ** Compute a hash on the P4 registers starting with r[P3] and + ** add that hash to the bloom filter contained in r[P1]. + */ + _184: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + h = _filterHash(tls, aMem, pOp) + h = h % libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn*libc.Int32FromInt32(8)) + v191 = (*TMem)(unsafe.Pointer(pIn1)).Fz + uintptr(h/uint64(8)) + *(*uint8)(unsafe.Pointer(v191)) = uint8(int32(*(*uint8)(unsafe.Pointer(v191))) | libc.Int32FromInt32(1)<<(h&libc.Uint64FromInt32(7))) + goto _189 + /* Opcode: Filter P1 P2 P3 P4 * + ** Synopsis: if key(P3@P4) not in filter(P1) goto P2 + ** + ** Compute a hash on the key contained in the P4 registers starting + ** with r[P3]. Check to see if that hash is found in the + ** bloom filter hosted by register P1. If it is not present then + ** maybe jump to P2. Otherwise fall through. + ** + ** False negatives are harmless. It is always safe to fall through, + ** even if the value is in the bloom filter. A false negative causes + ** more CPU cycles to be used, but it should still yield the correct + ** answer. However, an incorrect answer may well arise from a + ** false positive - if the jump is taken when it should fall through. + */ + _185: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + h1 = _filterHash(tls, aMem, pOp) + h1 = h1 % libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn*libc.Int32FromInt32(8)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pIn1)).Fz + uintptr(h1/uint64(8)))))&(int32(1)<<(h1&uint64(7))) == 0 { + **(**Tu32)(__ccgo_up(p + 212 + 8*4)) = **(**Tu32)(__ccgo_up(p + 212 + 8*4)) + 1 + goto jump_to_p2 + } else { + **(**Tu32)(__ccgo_up(p + 212 + 7*4)) = **(**Tu32)(__ccgo_up(p + 212 + 7*4)) + 1 + } + goto _189 + /* Opcode: Trace P1 P2 * P4 * + ** + ** Write P4 on the statement trace output if statement tracing is + ** enabled. + ** + ** Operand P1 must be 0x7fffffff and P2 must positive. + */ + /* Opcode: Init P1 P2 P3 P4 * + ** Synopsis: Start at P2 + ** + ** Programs contain a single instance of this opcode as the very first + ** opcode. + ** + ** If tracing is enabled (by the sqlite3_trace()) interface, then + ** the UTF-8 string contained in P4 is emitted on the trace callback. + ** Or if P4 is blank, use the string returned by sqlite3_sql(). + ** + ** If P2 is not zero, jump to instruction P2. + ** + ** Increment the value of P1 so that OP_Once opcodes will jump the + ** first time they are evaluated for this run. + ** + ** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT + ** error is encountered. + */ + _187: + ; + _186: + ; + /* If the P4 argument is not NULL, then it must be an SQL comment string. + ** The "--" string is broken up to prevent false-positives with srcck1.c. + ** + ** This assert() provides evidence for: + ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that + ** would have been returned by the legacy sqlite3_trace() interface by + ** using the X argument when X begins with "--" and invoking + ** sqlite3_expanded_sql(P) otherwise. + */ + /* OP_Init is always instruction 0 */ + if v217 = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&(libc.Int32FromInt32(SQLITE_TRACE_STMT)|libc.Int32FromInt32(SQLITE_TRACE_LEGACY)) != 0 && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat) != int32(254); v217 { + if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 { + v194 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + } else { + v194 = (*TVdbe)(unsafe.Pointer(p)).FzSql + } + v191 = v194 + zTrace = v191 + } + if v217 && v191 != uintptr(0) { + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_LEGACY) != 0 { + z2 = _sqlite3VdbeExpandSql(tls, p, zTrace) + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).Ftrace.FxLegacy})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, z2) + Xsqlite3_free(tls, z2) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > int32(1) { + z3 = _sqlite3MPrintf(tls, db, __ccgo_ts+6481, libc.VaList(bp+984, zTrace)) + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_STMT), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3) + _sqlite3DbFree(tls, db, z3) + } else { + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_STMT), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace) + } + } + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 >= _sqlite3Config.FiOnceResetThreshold { + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Trace) { + goto _189 + } + i9 = int32(1) + for { + if !(i9 < (*TVdbe)(unsafe.Pointer(p)).FnOp) { + break + } + if libc.Int32FromUint8((**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24))).Fopcode) == int32(OP_Once) { + (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24))).Fp1 = 0 + } + goto _302 + _302: + ; + i9 = i9 + 1 + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = 0 + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + 1 + **(**Tu32)(__ccgo_up(p + 212 + 6*4)) = **(**Tu32)(__ccgo_up(p + 212 + 6*4)) + 1 + goto jump_to_p2 + /* Opcode: Noop * * * * * + ** + ** Do nothing. Continue downward to the next opcode. + */ + /* Opcode: Explain P1 P2 P3 P4 * + ** + ** This is the same as OP_Noop during normal query execution. The + ** purpose of this opcode is to hold information about the query + ** plan for the purpose of EXPLAIN QUERY PLAN output. + ** + ** The P4 value is human-readable text that describes the query plan + ** element. Something like "SCAN t1" or "SEARCH t2 USING INDEX t2x1". + ** + ** The P1 value is the ID of the current element and P2 is the parent + ** element for the case of nested query plan elements. If P2 is zero + ** then this element is a top-level element. + ** + ** For loop elements, P3 is the estimated code of each invocation of this + ** element. + ** + ** As with all opcodes, the meanings of the parameters for OP_Explain + ** are subject to change from one release to the next. Applications + ** should not attempt to interpret or use any of the information + ** contained in the OP_Explain opcode. The information provided by this + ** opcode is intended for testing and debugging use only. + */ + _188: + ; /* This is really OP_Noop, OP_Explain */ + goto _189 + /***************************************************************************** + ** The cases of the switch statement above this line should all be indented + ** by 6 spaces. But the left-most 6 spaces have been removed to improve the + ** readability. From this point on down, the normal indentation rules are + ** restored. + *****************************************************************************/ + _189: + ; + /* The following code adds nothing to the actual functionality + ** of the program. It is only here for testing and debugging. + ** On the other hand, it does burn CPU cycles every time through + ** the evaluator loop. So we can leave it out when NDEBUG is defined. + */ + goto _1 + _1: + ; + pOp += 24 + } /* The end of the for(;;) loop the loops through opcodes */ + /* If we reach this point, it means that execution is finished with + ** an error of some kind. + */ + goto abort_due_to_error +abort_due_to_error: + ; + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } else { + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(33)< 0 { + _sqlite3ResetOneSchema(tls, db, libc.Int32FromUint8(resetSchemaOnFault)-int32(1)) + } + /* This is the only way out of this procedure. We have to + ** release the mutexes on btrees that were acquired at the + ** top. */ + goto vdbe_return +vdbe_return: + ; + for nVmStep >= nProgressLimit && (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0) { + nProgressLimit = nProgressLimit + uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)<aVar[]. Then render +// ** the value as a literal in place of the host parameter name. +// */ +func _sqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) (r uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var db, pVar, zStart, v1 uintptr + var enc Tu8 + var i, nOut, nOut1, nextIndex, v2 int32 + var n Ti64 + var _ /* idx at bp+0 */ int32 + var _ /* nToken at bp+8 */ Ti64 + var _ /* out at bp+16 */ TStrAccum + var _ /* utf8 at bp+48 */ TMem + _, _, _, _, _, _, _, _, _, _, _ = db, enc, i, n, nOut, nOut1, nextIndex, pVar, zStart, v1, v2 /* The database connection */ + **(**int32)(__ccgo_up(bp)) = 0 /* Index of a host parameter */ + nextIndex = int32(1) /* Used to convert UTF16 into UTF8 for display */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + _sqlite3StrAccumInit(tls, bp+16, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up(db + 136))) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > int32(1) { + for **(**uint8)(__ccgo_up(zRawSql)) != 0 { + zStart = zRawSql + for { + v1 = zRawSql + zRawSql = zRawSql + 1 + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(v1))) != int32('\n') && **(**uint8)(__ccgo_up(zRawSql)) != 0) { + break + } + } + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+5713, int32(3)) + Xsqlite3_str_append(tls, bp+16, zStart, int32(int64(zRawSql)-int64(zStart))) + } + } else { + if int32((*TVdbe)(unsafe.Pointer(p)).FnVar) == 0 { + Xsqlite3_str_append(tls, bp+16, zRawSql, _sqlite3Strlen30(tls, zRawSql)) + } else { + for **(**uint8)(__ccgo_up(zRawSql)) != 0 { + n = _findNextHostParameter(tls, zRawSql, bp+8) + Xsqlite3_str_append(tls, bp+16, zRawSql, int32(n)) + zRawSql = zRawSql + uintptr(n) + if **(**Ti64)(__ccgo_up(bp + 8)) == 0 { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zRawSql))) == int32('?') { + if **(**Ti64)(__ccgo_up(bp + 8)) > int64(1) { + _sqlite3GetInt32(tls, zRawSql+1, bp) + } else { + **(**int32)(__ccgo_up(bp)) = nextIndex + } + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3VdbeParameterIndex(tls, p, zRawSql, int32(**(**Ti64)(__ccgo_up(bp + 8)))) + } + zRawSql = zRawSql + uintptr(**(**Ti64)(__ccgo_up(bp + 8))) + if **(**int32)(__ccgo_up(bp))+int32(1) > nextIndex { + v2 = **(**int32)(__ccgo_up(bp)) + int32(1) + } else { + v2 = nextIndex + } + nextIndex = v2 + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Null) != 0 { + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+1705, int32(4)) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+1465, libc.VaList(bp+112, *(*Ti64)(unsafe.Pointer(pVar)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Real) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+5717, libc.VaList(bp+112, *(*float64)(unsafe.Pointer(pVar)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Str) != 0 { /* Number of bytes of the string text to include in output */ + enc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) { + libc.Xmemset(tls, bp+48, 0, uint64(56)) + (**(**TMem)(__ccgo_up(bp + 48))).Fdb = db + _sqlite3VdbeMemSetStr(tls, bp+48, (*TMem)(unsafe.Pointer(pVar)).Fz, int64((*TMem)(unsafe.Pointer(pVar)).Fn), enc, libc.UintptrFromInt32(0)) + if int32(SQLITE_NOMEM) == _sqlite3VdbeChangeEncoding(tls, bp+48, int32(SQLITE_UTF8)) { + (**(**TStrAccum)(__ccgo_up(bp + 16))).FaccError = uint8(SQLITE_NOMEM) + (**(**TStrAccum)(__ccgo_up(bp + 16))).FnAlloc = uint32(0) + } + pVar = bp + 48 + } + nOut = (*TMem)(unsafe.Pointer(pVar)).Fn + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+5724, libc.VaList(bp+112, nOut, (*TMem)(unsafe.Pointer(pVar)).Fz)) + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) { + _sqlite3VdbeMemRelease(tls, bp+48) + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Zero) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+5731, libc.VaList(bp+112, *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pVar)).Fu)))) + } else { /* Number of bytes of the blob to include in output */ + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+5744, int32(2)) + nOut1 = (*TMem)(unsafe.Pointer(pVar)).Fn + i = 0 + for { + if !(i < nOut1) { + break + } + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+5747, libc.VaList(bp+112, libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pVar)).Fz + uintptr(i))))&int32(0xff))) + goto _3 + _3: + ; + i = i + 1 + } + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+5752, int32(1)) + } + } + } + } + } + } + } + } + if (**(**TStrAccum)(__ccgo_up(bp + 16))).FaccError != 0 { + Xsqlite3_str_reset(tls, bp+16) + } + return _sqlite3StrAccumFinish(tls, bp+16) +} + +/************** End of vdbetrace.c *******************************************/ +/************** Begin file vdbe.c ********************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** The code in this file implements the function that runs the +** bytecode of a prepared statement. +** +** Various scripts scan this source file in order to generate HTML +** documentation, headers files, or other derived files. The formatting +** of the code in this file is, therefore, important. See other comments +** in this file for details. If in doubt, do not deviate from existing +** commenting and indentation practices when changing or adding code. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +/* +** High-resolution hardware timer used for debugging and testing only. + */ + +/* +** Invoke this macro on memory cells just prior to changing the +** value of the cell. This macro verifies that shallow copies are +** not misused. A shallow copy of a string or blob just copies a +** pointer to the string or blob, not the content. If the original +** is changed while the copy is still in use, the string or blob might +** be changed out from under the copy. This macro verifies that nothing +** like that ever happens. + */ + +/* +** The following global variable is incremented every time a cursor +** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test +** procedures use this information to make sure that indices are +** working correctly. This variable has no function other than to +** help verify the correct operation of the library. + */ + +/* +** When this global variable is positive, it gets decremented once before +** each instruction in the VDBE. When it reaches zero, the u1.isInterrupted +** field of the sqlite3 structure is set in order to simulate an interrupt. +** +** This facility is used for testing purposes only. It does not function +** in an ordinary build. + */ + +/* +** The next global variable is incremented each type the OP_Sort opcode +** is executed. The test procedures use this information to make sure that +** sorting is occurring or not occurring at appropriate times. This variable +** has no function other than to help verify the correct operation of the +** library. + */ + +/* +** The next global variable records the size of the largest MEM_Blob +** or MEM_Str that has been used by a VDBE opcode. The test procedures +** use this information to make sure that the zero-blob functionality +** is working correctly. This variable has no function other than to +** help verify the correct operation of the library. + */ + +/* +** This macro evaluates to true if either the update hook or the preupdate +** hook are enabled for database connect DB. + */ + +/* +** The next global variable is incremented each time the OP_Found opcode +** is executed. This is used to test whether or not the foreign key +** operation implemented using OP_FkIsZero is working. This variable +** has no function other than to help verify the correct operation of the +** library. + */ + +/* +** Test a register to see if it exceeds the current maximum blob size. +** If it does, record the new maximum blob size. + */ + +/* +** Invoke the VDBE coverage callback, if that callback is defined. This +** feature is used for test suite validation only and does not appear an +** production builds. +** +** M is the type of branch. I is the direction taken for this instance of +** the branch. +** +** M: 2 - two-way branch (I=0: fall-thru 1: jump ) +** 3 - two-way + NULL (I=0: fall-thru 1: jump 2: NULL ) +** 4 - OP_Jump (I=0: jump p1 1: jump p2 2: jump p3) +** +** In other words, if M is 2, then I is either 0 (for fall-through) or +** 1 (for when the branch is taken). If M is 3, the I is 0 for an +** ordinary fall-through, I is 1 if the branch was taken, and I is 2 +** if the result of comparison is NULL. For M=3, I=2 the jump may or +** may not be taken, depending on the SQLITE_JUMPIFNULL flags in p5. +** When M is 4, that means that an OP_Jump is being run. I is 0, 1, or 2 +** depending on if the operands are less than, equal, or greater than. +** +** iSrcLine is the source code line (from the __LINE__ macro) that +** generated the VDBE instruction combined with flag bits. The source +** code line number is in the lower 24 bits of iSrcLine and the upper +** 8 bytes are flags. The lower three bits of the flags indicate +** values for I that should never occur. For example, if the branch is +** always taken, the flags should be 0x05 since the fall-through and +** alternate branch are never taken. If a branch is never taken then +** flags should be 0x06 since only the fall-through approach is allowed. +** +** Bit 0x08 of the flags indicates an OP_Jump opcode that is only +** interested in equal or not-equal. In other words, I==0 and I==2 +** should be treated as equivalent +** +** Since only a line number is retained, not the filename, this macro +** only works for amalgamation builds. But that is ok, since these macros +** should be no-ops except for special builds used to measure test coverage. + */ + +/* +** An ephemeral string value (signified by the MEM_Ephem flag) contains +** a pointer to a dynamically allocated string where some other entity +** is responsible for deallocating that string. Because the register +** does not control the string, it might be deleted without the register +** knowing it. +** +** This routine converts an ephemeral string into a dynamically allocated +** string that the register itself controls. In other words, it +** converts an MEM_Ephem string into a string with P.z==P.zMalloc. + */ + +/* Return true if the cursor was opened using the OP_OpenSorter opcode. */ + +// C documentation +// +// /* +// ** Send a "statement aborts" message to the error log. +// */ +func _sqlite3VdbeLogAbort(tls *libc.TLS, p uintptr, rc int32, pOp uintptr, aOp uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var pc int32 + var zPrefix, zSql uintptr + var _ /* zXtra at bp+0 */ [100]uint8 + _, _, _ = pc, zPrefix, zSql + zSql = (*TVdbe)(unsafe.Pointer(p)).FzSql /* Original SQL text */ + zPrefix = __ccgo_ts + 1704 /* Buffer space to store zPrefix */ + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + if *(*uintptr)(unsafe.Pointer(aOp + 16)) != uintptr(0) { + Xsqlite3_snprintf(tls, int32(100), bp, __ccgo_ts+5754, libc.VaList(bp+112, *(*uintptr)(unsafe.Pointer(aOp + 16))+uintptr(3))) + zPrefix = bp + } else { + zPrefix = __ccgo_ts + 5764 + } + } + pc = int32((int64(pOp) - int64(aOp)) / 24) + Xsqlite3_log(tls, rc, __ccgo_ts+5787, libc.VaList(bp+112, pc, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, zPrefix, zSql)) +} + +// C documentation +// +// /* +// ** This function sets the P4 value of an existing OP_Explain opcode to +// ** text describing the loop in pLevel. If the OP_Explain opcode already has +// ** a P4 value, it is freed before it is overwritten. +// */ +func _sqlite3WhereAddExplainText(tls *libc.TLS, pParse uintptr, addr int32, pTabList uintptr, pLevel uintptr, wctrlFlags Tu16) { + bp := tls.Alloc(176) + defer tls.Free(176) + var cRangeOp uint8 + var db, pIdx, pItem, pLoop, pOp, zFmt, zRowid, v1, v2 uintptr + var flags Tu32 + var isSearch int32 + var _ /* str at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [100]uint8 + _, _, _, _, _, _, _, _, _, _, _, _ = cRangeOp, db, flags, isSearch, pIdx, pItem, pLoop, pOp, zFmt, zRowid, v1, v2 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(v1)).Fexplain) == int32(2) || libc.Bool(0 != 0) { + pOp = _sqlite3VdbeGetOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, addr) + pItem = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Initial space for EQP output string */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + flags = (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags + isSearch = libc.BoolInt32(flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_BTM_LIMIT)|libc.Int32FromInt32(WHERE_TOP_LIMIT)) != uint32(0) || flags&uint32(WHERE_VIRTUALTABLE) == uint32(0) && libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) > 0 || libc.Int32FromUint16(wctrlFlags)&(libc.Int32FromInt32(WHERE_ORDERBY_MIN)|libc.Int32FromInt32(WHERE_ORDERBY_MAX)) != 0) + _sqlite3StrAccumInit(tls, bp, db, bp+32, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TStrAccum)(__ccgo_up(bp))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + if isSearch != 0 { + v1 = __ccgo_ts + 23588 + } else { + v1 = __ccgo_ts + 23595 + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x40000>>18) != 0 { + v2 = __ccgo_ts + 23600 + } else { + v2 = __ccgo_ts + 1704 + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23608, libc.VaList(bp+144, v1, pItem, v2)) + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_VIRTUALTABLE)) == uint32(0) { + zFmt = uintptr(0) + pIdx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + if !((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + if isSearch != 0 { + zFmt = __ccgo_ts + 11592 + } + } else { + if flags&uint32(WHERE_PARTIALIDX) != 0 { + zFmt = __ccgo_ts + 23616 + } else { + if flags&uint32(WHERE_AUTO_INDEX) != 0 { + zFmt = __ccgo_ts + 23649 + } else { + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY)|libc.Int32FromInt32(WHERE_EXPRIDX)) != 0 { + zFmt = __ccgo_ts + 23674 + } else { + zFmt = __ccgo_ts + 23692 + } + } + } + } + if zFmt != 0 { + Xsqlite3_str_append(tls, bp, __ccgo_ts+23701, int32(7)) + Xsqlite3_str_appendf(tls, bp, zFmt, libc.VaList(bp+144, (*TIndex)(unsafe.Pointer(pIdx)).FzName)) + _explainIndexRange(tls, bp, pLoop) + } + } else { + if flags&uint32(WHERE_IPK) != uint32(0) && flags&uint32(WHERE_CONSTRAINT) != uint32(0) { + zRowid = __ccgo_ts + 17963 + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23709, libc.VaList(bp+144, zRowid)) + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_EQ)|libc.Int32FromInt32(WHERE_COLUMN_IN)) != 0 { + cRangeOp = uint8('=') + } else { + if flags&uint32(WHERE_BOTH_LIMIT) == uint32(WHERE_BOTH_LIMIT) { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23740, libc.VaList(bp+144, zRowid)) + cRangeOp = uint8('<') + } else { + if flags&uint32(WHERE_BTM_LIMIT) != 0 { + cRangeOp = uint8('>') + } else { + cRangeOp = uint8('<') + } + } + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23750, libc.VaList(bp+144, libc.Int32FromUint8(cRangeOp))) + } else { + if flags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+23755) + if int32(Tu32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x4>>2)) != 0 { + v1 = __ccgo_ts + 23777 + } else { + v1 = __ccgo_ts + 23785 + } + Xsqlite3_str_appendf(tls, bp, v1, libc.VaList(bp+144, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxNum, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxStr)) + } + } + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23791, 0) + } + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16))) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = _sqlite3StrAccumFinish(tls, bp) + } +} + +// C documentation +// +// /* +// ** Add a single OP_Explain opcode that describes a Bloom filter. +// ** +// ** Or if not processing EXPLAIN QUERY PLAN and not in a SQLITE_DEBUG and/or +// ** SQLITE_ENABLE_STMT_SCANSTATUS build, then OP_Explain opcodes are not +// ** required and this routine is a no-op. +// ** +// ** If an OP_Explain opcode is added to the VM, its address is returned. +// ** Otherwise, if no OP_Explain is coded, zero is returned. +// */ +func _sqlite3WhereExplainBloomFilter(tls *libc.TLS, pParse uintptr, pWInfo uintptr, pLevel uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var db, pItem, pLoop, pTab, v, z, zMsg uintptr + var i, ret int32 + var _ /* str at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [100]uint8 + _, _, _, _, _, _, _, _, _ = db, i, pItem, pLoop, pTab, ret, v, z, zMsg + ret = 0 + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* VM being constructed */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Initial space for EQP output string */ + _sqlite3StrAccumInit(tls, bp, db, bp+32, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TStrAccum)(__ccgo_up(bp))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23802, libc.VaList(bp+144, pItem)) + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != 0 { + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) >= 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23571, libc.VaList(bp+144, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TTable)(unsafe.Pointer(pTab)).FiPKey)*16))).FzCnName)) + } else { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23823, 0) + } + } else { + i = libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) + for { + if !(i < libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq)) { + break + } + z = _explainIndexColumnName(tls, (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex, i) + if i > libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) { + Xsqlite3_str_append(tls, bp, __ccgo_ts+23560, int32(5)) + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23571, libc.VaList(bp+144, z)) + goto _1 + _1: + ; + i = i + 1 + } + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5257, int32(1)) + zMsg = _sqlite3StrAccumFinish(tls, bp) + ret = _sqlite3VdbeAddOp4(tls, v, int32(OP_Explain), _sqlite3VdbeCurrentAddr(tls, v), (*TParse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -int32(7)) + return ret +} + +// C documentation +// +// /* +// ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) +// ** +// ** Return a string described by FORMAT. Conversions as follows: +// ** +// ** %d day of month 01-31 +// ** %e day of month 1-31 +// ** %f ** fractional seconds SS.SSS +// ** %F ISO date. YYYY-MM-DD +// ** %G ISO year corresponding to %V 0000-9999. +// ** %g 2-digit ISO year corresponding to %V 00-99 +// ** %H hour 00-24 +// ** %k hour 0-24 (leading zero converted to space) +// ** %I hour 01-12 +// ** %j day of year 001-366 +// ** %J ** julian day number +// ** %l hour 1-12 (leading zero converted to space) +// ** %m month 01-12 +// ** %M minute 00-59 +// ** %p "AM" or "PM" +// ** %P "am" or "pm" +// ** %R time as HH:MM +// ** %s seconds since 1970-01-01 +// ** %S seconds 00-59 +// ** %T time as HH:MM:SS +// ** %u day of week 1-7 Monday==1, Sunday==7 +// ** %w day of week 0-6 Sunday==0, Monday==1 +// ** %U week of year 00-53 (First Sunday is start of week 01) +// ** %V week of year 01-53 (First week containing Thursday is week 01) +// ** %W week of year 00-53 (First Monday is start of week 01) +// ** %Y year 0000-9999 +// ** %% % +// */ +func _strftimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(208) + defer tls.Free(208) + var c, cf uint8 + var db, zFmt, v3 uintptr + var h int32 + var i, j, v2 Tsize_t + var iS Ti64 + var s float64 + var _ /* sRes at bp+48 */ Tsqlite3_str + var _ /* x at bp+0 */ TDateTime + var _ /* y at bp+128 */ TDateTime + var _ /* y at bp+80 */ TDateTime + _, _, _, _, _, _, _, _, _, _, _ = c, cf, db, h, i, iS, j, s, zFmt, v2, v3 + if argc == 0 { + return + } + zFmt = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zFmt == uintptr(0) || _isDate(tls, context, argc-int32(1), argv+uintptr(1)*8, bp) != 0 { + return + } + db = Xsqlite3_context_db_handle(tls, context) + _sqlite3StrAccumInit(tls, bp+48, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up(db + 136))) + _computeJD(tls, bp) + _computeYMD_HMS(tls, bp) + v2 = libc.Uint64FromInt32(0) + j = v2 + i = v2 + for { + if !(**(**uint8)(__ccgo_up(zFmt + uintptr(i))) != 0) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zFmt + uintptr(i)))) != int32('%') { + goto _1 + } + if j < i { + Xsqlite3_str_append(tls, bp+48, zFmt+uintptr(j), libc.Int32FromUint64(i-j)) + } + i = i + 1 + j = i + uint64(1) + cf = **(**uint8)(__ccgo_up(zFmt + uintptr(i))) + switch libc.Int32FromUint8(cf) { + case int32('d'): /* Fall thru */ + fallthrough + case int32('e'): + if libc.Int32FromUint8(cf) == int32('d') { + v3 = __ccgo_ts + 1391 + } else { + v3 = __ccgo_ts + 1396 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FD)) + case int32('f'): /* Fractional seconds. (Non-standard) */ + s = (**(**TDateTime)(__ccgo_up(bp))).Fs + if s > float64(59.999) { + s = float64(59.999) + } + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1400, libc.VaList(bp+184, s)) + case int32('F'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1407, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FY, (**(**TDateTime)(__ccgo_up(bp))).FM, (**(**TDateTime)(__ccgo_up(bp))).FD)) + case int32('G'): /* Fall thru */ + fallthrough + case int32('g'): + **(**TDateTime)(__ccgo_up(bp + 80)) = **(**TDateTime)(__ccgo_up(bp)) + /* Move y so that it is the Thursday in the same week as x */ + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD += int64((int32(3) - _daysAfterMonday(tls, bp)) * int32(86400000)) + (**(**TDateTime)(__ccgo_up(bp + 80))).FvalidYMD = uint8(0) + _computeYMD(tls, bp+80) + if libc.Int32FromUint8(cf) == int32('g') { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp + 80))).FY%int32(100))) + } else { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1422, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp + 80))).FY)) + } + case int32('H'): + fallthrough + case int32('k'): + if libc.Int32FromUint8(cf) == int32('H') { + v3 = __ccgo_ts + 1391 + } else { + v3 = __ccgo_ts + 1396 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh)) + case int32('I'): /* Fall thru */ + fallthrough + case int32('l'): + h = (**(**TDateTime)(__ccgo_up(bp))).Fh + if h > int32(12) { + h = h - int32(12) + } + if h == 0 { + h = int32(12) + } + if libc.Int32FromUint8(cf) == int32('I') { + v3 = __ccgo_ts + 1391 + } else { + v3 = __ccgo_ts + 1396 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, h)) + case int32('j'): /* Day of year. Jan01==1, Jan02==2, and so forth */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1427, libc.VaList(bp+184, _daysAfterJan01(tls, bp)+int32(1))) + case int32('J'): /* Julian day number. (Non-standard) */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1432, libc.VaList(bp+184, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD)/float64(8.64e+07))) + case int32('m'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FM)) + case int32('M'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fm)) + case int32('p'): /* Fall thru */ + fallthrough + case int32('P'): + if (**(**TDateTime)(__ccgo_up(bp))).Fh >= int32(12) { + if libc.Int32FromUint8(cf) == int32('p') { + v3 = __ccgo_ts + 1438 + } else { + v3 = __ccgo_ts + 1441 + } + Xsqlite3_str_append(tls, bp+48, v3, int32(2)) + } else { + if libc.Int32FromUint8(cf) == int32('p') { + v3 = __ccgo_ts + 1444 + } else { + v3 = __ccgo_ts + 1447 + } + Xsqlite3_str_append(tls, bp+48, v3, int32(2)) + } + case int32('R'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1450, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm)) + case int32('s'): + if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1460, libc.VaList(bp+184, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD-libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000000))/float64(1000))) + } else { + iS = (**(**TDateTime)(__ccgo_up(bp))).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000) + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1465, libc.VaList(bp+184, iS)) + } + case int32('S'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, int32((**(**TDateTime)(__ccgo_up(bp))).Fs))) + case int32('T'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1470, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm, int32((**(**TDateTime)(__ccgo_up(bp))).Fs))) + case int32('u'): /* Day of week. 1 to 7. Monday==1, Sunday==7 */ + fallthrough + case int32('w'): /* Day of week. 0 to 6. Sunday==0, Monday==1 */ + c = libc.Uint8FromInt32(libc.Int32FromUint8(libc.Uint8FromInt32(_daysAfterSunday(tls, bp))) + int32('0')) + if libc.Int32FromUint8(c) == int32('0') && libc.Int32FromUint8(cf) == int32('u') { + c = uint8('7') + } + Xsqlite3_str_appendchar(tls, bp+48, int32(1), c) + case int32('U'): /* Week num. 00-53. First Sun of the year is week 01 */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (_daysAfterJan01(tls, bp)-_daysAfterSunday(tls, bp)+int32(7))/int32(7))) + case int32('V'): /* Week num. 01-53. First week with a Thur is week 01 */ + **(**TDateTime)(__ccgo_up(bp + 128)) = **(**TDateTime)(__ccgo_up(bp)) + /* Adjust y so that is the Thursday in the same week as x */ + (**(**TDateTime)(__ccgo_up(bp + 128))).FiJD += int64((int32(3) - _daysAfterMonday(tls, bp)) * int32(86400000)) + (**(**TDateTime)(__ccgo_up(bp + 128))).FvalidYMD = uint8(0) + _computeYMD(tls, bp+128) + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, _daysAfterJan01(tls, bp+128)/int32(7)+int32(1))) + case int32('W'): /* Week num. 00-53. First Mon of the year is week 01 */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (_daysAfterJan01(tls, bp)-_daysAfterMonday(tls, bp)+int32(7))/int32(7))) + case int32('Y'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1422, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FY)) + case int32('%'): + Xsqlite3_str_appendchar(tls, bp+48, int32(1), uint8('%')) + default: + Xsqlite3_str_reset(tls, bp+48) + return + } + goto _1 + _1: + ; + i = i + 1 + } + if j < i { + Xsqlite3_str_append(tls, bp+48, zFmt+uintptr(j), libc.Int32FromUint64(i-j)) + } + _sqlite3ResultStrAccum(tls, context, bp+48) +} + +// C documentation +// +// /* +// ** timediff(DATE1, DATE2) +// ** +// ** Return the amount of time that must be added to DATE2 in order to +// ** convert it into DATE2. The time difference format is: +// ** +// ** +YYYY-MM-DD HH:MM:SS.SSS +// ** +// ** The initial "+" becomes "-" if DATE1 occurs before DATE2. For +// ** date/time values A and B, the following invariant should hold: +// ** +// ** datetime(A) == (datetime(B, timediff(A,B)) +// ** +// ** Both DATE arguments must be either a julian day number, or an +// ** ISO-8601 string. The unix timestamps are not supported by this +// ** routine. +// */ +func _timediffFunc(tls *libc.TLS, context uintptr, NotUsed1 int32, argv uintptr) { + bp := tls.Alloc(192) + defer tls.Free(192) + var M, Y int32 + var sign uint8 + var v1 uintptr + var _ /* d1 at bp+0 */ TDateTime + var _ /* d2 at bp+48 */ TDateTime + var _ /* sRes at bp+96 */ Tsqlite3_str + _, _, _, _ = M, Y, sign, v1 + _ = NotUsed1 + if _isDate(tls, context, int32(1), argv, bp) != 0 { + return + } + if _isDate(tls, context, int32(1), argv+1*8, bp+48) != 0 { + return + } + _computeYMD_HMS(tls, bp) + _computeYMD_HMS(tls, bp+48) + if (**(**TDateTime)(__ccgo_up(bp))).FiJD >= (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + sign = uint8('+') + Y = (**(**TDateTime)(__ccgo_up(bp))).FY - (**(**TDateTime)(__ccgo_up(bp + 48))).FY + if Y != 0 { + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp))).FY + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = uint8(0) + _computeJD(tls, bp+48) + } + M = (**(**TDateTime)(__ccgo_up(bp))).FM - (**(**TDateTime)(__ccgo_up(bp + 48))).FM + if M < 0 { + Y = Y - 1 + M = M + int32(12) + } + if M != 0 { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp))).FM + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = uint8(0) + _computeJD(tls, bp+48) + } + for (**(**TDateTime)(__ccgo_up(bp))).FiJD < (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + M = M - 1 + if M < 0 { + M = int32(11) + Y = Y - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp + 48))).FM - 1 + if (**(**TDateTime)(__ccgo_up(bp + 48))).FM < int32(1) { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = int32(12) + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp + 48))).FY - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = uint8(0) + _computeJD(tls, bp+48) + } + (**(**TDateTime)(__ccgo_up(bp))).FiJD -= (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD + v1 = bp + *(*Tsqlite3_int64)(unsafe.Pointer(v1)) = Tsqlite3_int64(uint64(*(*Tsqlite3_int64)(unsafe.Pointer(v1))) + libc.Uint64FromInt32(1486995408)*libc.Uint64FromInt32(100000)) + } else { /* d1 (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + M = M - 1 + if M < 0 { + M = int32(11) + Y = Y - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp + 48))).FM + 1 + if (**(**TDateTime)(__ccgo_up(bp + 48))).FM > int32(12) { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = int32(1) + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp + 48))).FY + 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = uint8(0) + _computeJD(tls, bp+48) + } + (**(**TDateTime)(__ccgo_up(bp))).FiJD = (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD - (**(**TDateTime)(__ccgo_up(bp))).FiJD + v1 = bp + *(*Tsqlite3_int64)(unsafe.Pointer(v1)) = Tsqlite3_int64(uint64(*(*Tsqlite3_int64)(unsafe.Pointer(v1))) + libc.Uint64FromInt32(1486995408)*libc.Uint64FromInt32(100000)) + } + _clearYMD_HMS_TZ(tls, bp) + _computeYMD_HMS(tls, bp) + _sqlite3StrAccumInit(tls, bp+96, uintptr(0), uintptr(0), 0, int32(100)) + Xsqlite3_str_appendf(tls, bp+96, __ccgo_ts+1485, libc.VaList(bp+136, libc.Int32FromUint8(sign), Y, M, (**(**TDateTime)(__ccgo_up(bp))).FD-int32(1), (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm, (**(**TDateTime)(__ccgo_up(bp))).Fs)) + _sqlite3ResultStrAccum(tls, context, bp+96) +} + +// C documentation +// +// /* +// ** Assuming the input DateTime is UTC, move it to its localtime equivalent. +// */ +func _toLocaltime(tls *libc.TLS, p uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var iYearDiff int32 + var _ /* sLocal at bp+8 */ Ttm + var _ /* t at bp+0 */ Ttime_t + var _ /* x at bp+64 */ TDateTime + _ = iYearDiff + /* Initialize the contents of sLocal to avoid a compiler warning. */ + libc.Xmemset(tls, bp+8, 0, uint64(56)) + _computeJD(tls, p) + if (*TDateTime)(unsafe.Pointer(p)).FiJD < libc.Int64FromInt32(2108667600)*libc.Int64FromInt32(100000) || (*TDateTime)(unsafe.Pointer(p)).FiJD > libc.Int64FromInt32(2130141456)*libc.Int64FromInt32(100000) { + /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only + ** works for years between 1970 and 2037. For dates outside this range, + ** SQLite attempts to map the year into an equivalent year within this + ** range, do the calculation, then map the year back. + */ + **(**TDateTime)(__ccgo_up(bp + 64)) = **(**TDateTime)(__ccgo_up(p)) + _computeYMD_HMS(tls, bp+64) + iYearDiff = int32(2000) + (**(**TDateTime)(__ccgo_up(bp + 64))).FY%int32(4) - (**(**TDateTime)(__ccgo_up(bp + 64))).FY + (**(**TDateTime)(__ccgo_up(bp + 64))).FY += iYearDiff + (**(**TDateTime)(__ccgo_up(bp + 64))).FvalidJD = uint8(0) + _computeJD(tls, bp+64) + **(**Ttime_t)(__ccgo_up(bp)) = int64((**(**TDateTime)(__ccgo_up(bp + 64))).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) + } else { + iYearDiff = 0 + **(**Ttime_t)(__ccgo_up(bp)) = int64((*TDateTime)(unsafe.Pointer(p)).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) + } + if _osLocaltime(tls, bp, bp+8) != 0 { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+1249, -int32(1)) + return int32(SQLITE_ERROR) + } + (*TDateTime)(unsafe.Pointer(p)).FY = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_year + int32(1900) - iYearDiff + (*TDateTime)(unsafe.Pointer(p)).FM = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_mon + int32(1) + (*TDateTime)(unsafe.Pointer(p)).FD = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_mday + (*TDateTime)(unsafe.Pointer(p)).Fh = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_hour + (*TDateTime)(unsafe.Pointer(p)).Fm = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_min + (*TDateTime)(unsafe.Pointer(p)).Fs = float64((**(**Ttm)(__ccgo_up(bp + 8))).Ftm_sec) + float64(float64((*TDateTime)(unsafe.Pointer(p)).FiJD%libc.Int64FromInt32(1000))*float64(0.001)) + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(1) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 1, 0x2) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Implementation of the UNISTR() function. +// ** +// ** This is intended to be a work-alike of the UNISTR() function in +// ** PostgreSQL. Quoting from the PG documentation (PostgreSQL 17 - +// ** scraped on 2025-02-22): +// ** +// ** Evaluate escaped Unicode characters in the argument. Unicode +// ** characters can be specified as \XXXX (4 hexadecimal digits), +// ** \+XXXXXX (6 hexadecimal digits), \uXXXX (4 hexadecimal digits), +// ** or \UXXXXXXXX (8 hexadecimal digits). To specify a backslash, +// ** write two backslashes. All other characters are taken literally. +// */ +func _unistrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j, n, nIn, v1 int32 + var z, zIn, zOut uintptr + var _ /* v at bp+0 */ Tu32 + _, _, _, _, _, _, _, _ = i, j, n, nIn, z, zIn, zOut, v1 + _ = argc + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn == uintptr(0) { + return + } + nIn = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + zOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nIn+int32(1))) + if zOut == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + v1 = libc.Int32FromInt32(0) + j = v1 + i = v1 + for i < nIn { + z = libc.Xstrchr(tls, zIn+uintptr(i), int32('\\')) + if z == uintptr(0) { + n = nIn - i + libc.Xmemmove(tls, zOut+uintptr(j), zIn+uintptr(i), libc.Uint64FromInt32(n)) + j = j + n + break + } + n = int32(int64(z) - t__predefined_ptrdiff_t(zIn+uintptr(i))) + if n > 0 { + libc.Xmemmove(tls, zOut+uintptr(j), zIn+uintptr(i), libc.Uint64FromInt32(n)) + j = j + n + i = i + n + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('\\') { + i = i + int32(2) + v1 = j + j = j + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v1))) = uint8('\\') + } else { + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zIn + uintptr(i+int32(1)))))])&int32(0x08) != 0 { + if !(_isNHex(tls, zIn+uintptr(i+int32(1)), int32(4), bp) != 0) { + goto unistr_error + } + i = i + int32(5) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('+') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(6), bp) != 0) { + goto unistr_error + } + i = i + int32(8) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('u') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(4), bp) != 0) { + goto unistr_error + } + i = i + int32(6) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('U') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(8), bp) != 0) { + goto unistr_error + } + i = i + int32(10) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + goto unistr_error + } + } + } + } + } + } + **(**uint8)(__ccgo_up(zOut + uintptr(j))) = uint8(0) + Xsqlite3_result_text64(tls, context, zOut, libc.Uint64FromInt32(j), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) + return + goto unistr_error +unistr_error: + ; + Xsqlite3_free(tls, zOut) + Xsqlite3_result_error(tls, context, __ccgo_ts+16571, -int32(1)) + return +} + +// C documentation +// +// /* +// ** Turn a relative pathname into a full pathname. The relative path +// ** is stored as a nul-terminated string in the buffer pointed to by +// ** zPath. +// ** +// ** zOut points to a buffer of at least sqlite3_vfs.mxPathname bytes +// ** (in this case, MAX_PATHNAME bytes). The full-path is written to +// ** this buffer before returning. +// */ +func _unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) (r int32) { + bp := tls.Alloc(4128) + defer tls.Free(4128) + var _ /* path at bp+0 */ TDbPath + var _ /* zPwd at bp+24 */ [4098]uint8 + _ = pVfs + (**(**TDbPath)(__ccgo_up(bp))).Frc = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnUsed = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnSymlink = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnOut = nOut + (**(**TDbPath)(__ccgo_up(bp))).FzOut = zOut + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) != int32('/') { + if (*(*func(*libc.TLS, uintptr, Tsize_t) uintptr)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(3)].FpCurrent})))(tls, bp+24, libc.Uint64FromInt64(4098)-libc.Uint64FromInt32(2)) == uintptr(0) { + return _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47211)), __ccgo_ts+3560, zPath, int32(47211)) + } + _appendAllPathElements(tls, bp, bp+24) + } + _appendAllPathElements(tls, bp, zPath) + **(**uint8)(__ccgo_up(zOut + uintptr((**(**TDbPath)(__ccgo_up(bp))).FnUsed))) = uint8(0) + if (**(**TDbPath)(__ccgo_up(bp))).Frc != 0 || (**(**TDbPath)(__ccgo_up(bp))).FnUsed < int32(2) { + return _sqlite3CantopenError(tls, int32(47217)) + } + if (**(**TDbPath)(__ccgo_up(bp))).FnSymlink != 0 { + return libc.Int32FromInt32(SQLITE_OK) | libc.Int32FromInt32(2)< (READWRITE | CREATE) +// ** ReadOnly() -> (READONLY) +// ** OpenExclusive() -> (READWRITE | CREATE | EXCLUSIVE) +// ** +// ** The old OpenExclusive() accepted a boolean argument - "delFlag". If +// ** true, the file was configured to be automatically deleted when the +// ** file handle closed. To achieve the same effect using this new +// ** interface, add the DELETEONCLOSE flag to those specified above for +// ** OpenExclusive(). +// */ +func _unixOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, flags int32, pOutFlags uintptr) (r int32) { + bp := tls.Alloc(528) + defer tls.Free(528) + var ctrlFlags, eType, fd, isCreate, isDelete, isExclusive, isNewJrnl, isReadWrite, isReadonly, noLock, openFlags, rc, rc2 int32 + var p, pReadonly, pUnused, zName uintptr + var _ /* gid at bp+524 */ Tgid_t + var _ /* openMode at bp+516 */ Tmode_t + var _ /* uid at bp+520 */ Tuid_t + var _ /* zTmpname at bp+0 */ [514]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ctrlFlags, eType, fd, isCreate, isDelete, isExclusive, isNewJrnl, isReadWrite, isReadonly, noLock, openFlags, p, pReadonly, pUnused, rc, rc2, zName + p = pFile + fd = -int32(1) /* File descriptor returned by open() */ + openFlags = 0 /* Flags to pass to open() */ + eType = flags & int32(0x0FFF00) /* True to omit locking primitives */ + rc = SQLITE_OK /* Function Return Code */ + ctrlFlags = 0 /* UNIXFILE_* flags */ + isExclusive = flags & int32(SQLITE_OPEN_EXCLUSIVE) + isDelete = flags & int32(SQLITE_OPEN_DELETEONCLOSE) + isCreate = flags & int32(SQLITE_OPEN_CREATE) + isReadonly = flags & int32(SQLITE_OPEN_READONLY) + isReadWrite = flags & int32(SQLITE_OPEN_READWRITE) + /* If creating a super- or main-file journal, this function will open + ** a file-descriptor on the directory too. The first time unixSync() + ** is called the directory file descriptor will be fsync()ed and close()d. + */ + isNewJrnl = libc.BoolInt32(isCreate != 0 && (eType == int32(SQLITE_OPEN_SUPER_JOURNAL) || eType == int32(SQLITE_OPEN_MAIN_JOURNAL) || eType == int32(SQLITE_OPEN_WAL))) + zName = zPath + /* Check the following statements are true: + ** + ** (a) Exactly one of the READWRITE and READONLY flags must be set, and + ** (b) if CREATE is set, then READWRITE must also be set, and + ** (c) if EXCLUSIVE is set, then CREATE must also be set. + ** (d) if DELETEONCLOSE is set, then CREATE must also be set. + */ + /* The main DB, main journal, WAL file and super-journal are never + ** automatically deleted. Nor are they ever temporary files. */ + /* Assert that the upper layer has set one of the "file-type" flags. */ + /* Detect a pid change and reset the PRNG. There is a race condition + ** here such that two or more threads all trying to open databases at + ** the same instant might all reset the PRNG. But multiple resets + ** are harmless. + */ + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_randomnessPid))) != libc.Xgetpid(tls) { + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_randomnessPid)), libc.Xgetpid(tls)) + Xsqlite3_randomness(tls, 0, uintptr(0)) + } + libc.Xmemset(tls, p, 0, uint64(120)) + if eType == int32(SQLITE_OPEN_MAIN_DB) { + pUnused = _findReusableFd(tls, zName, flags) + if pUnused != 0 { + fd = (*TUnixUnusedFd)(unsafe.Pointer(pUnused)).Ffd + } else { + pUnused = Xsqlite3_malloc64(tls, uint64(16)) + if !(pUnused != 0) { + return int32(SQLITE_NOMEM) + } + } + (*TunixFile)(unsafe.Pointer(p)).FpPreallocatedUnused = pUnused + /* Database filenames are double-zero terminated if they are not + ** URIs with parameters. Hence, they can always be passed into + ** sqlite3_uri_parameter(). */ + } else { + if !(zName != 0) { + /* If zName is NULL, the upper layer is requesting a temp file. */ + rc = _unixGetTempname(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname, bp) + if rc != SQLITE_OK { + return rc + } + zName = bp + /* Generated temporary filenames are always double-zero terminated + ** for use by sqlite3_uri_parameter(). */ + } + } + /* Determine the value of the flags parameter passed to POSIX function + ** open(). These must be calculated even if open() is not called, as + ** they may be stored as part of the file handle and used by the + ** 'conch file' locking functions later on. */ + if isReadonly != 0 { + openFlags = openFlags | O_RDONLY + } + if isReadWrite != 0 { + openFlags = openFlags | int32(O_RDWR) + } + if isCreate != 0 { + openFlags = openFlags | int32(O_CREAT) + } + if isExclusive != 0 { + openFlags = openFlags | (libc.Int32FromInt32(O_EXCL) | libc.Int32FromInt32(O_NOFOLLOW)) + } + openFlags = openFlags | (libc.Int32FromInt32(O_LARGEFILE) | libc.Int32FromInt32(O_BINARY) | libc.Int32FromInt32(O_NOFOLLOW)) + if fd < 0 { /* Groupid for the file */ + rc = _findCreateFileMode(tls, zName, flags, bp+516, bp+520, bp+524) + if rc != SQLITE_OK { + return rc + } + fd = _robust_open(tls, zName, openFlags, **(**Tmode_t)(__ccgo_up(bp + 516))) + if fd < 0 { + if isNewJrnl != 0 && **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(EACCES) && (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zName, F_OK) != 0 { + /* If unable to create a journal because the directory is not + ** writable, change the error code to indicate that. */ + rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(6)<zErrMsg. +// */ +func _viewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pSel, pSelTab, v2 uintptr + var eParseMode Tu8 + var nErr, nSelect, nTab, rc, v1 int32 + var xAuth Tsqlite3_xauth + _, _, _, _, _, _, _, _, _, _, _ = db, eParseMode, nErr, nSelect, nTab, pSel, pSelTab, rc, xAuth, v1, v2 /* Copy of the SELECT that implements the view */ + nErr = 0 /* Number of errors encountered */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Saved xAuth pointer */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == int32(TABTYP_VTAB) { + (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock + 1 + rc = _sqlite3VtabCallConnect(tls, pParse, pTable) + (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock - 1 + return rc + } + /* A positive nCol means the columns names for this view are + ** already known. This routine is not called unless either the + ** table is virtual or nCol is zero. + */ + /* A negative nCol is a special marker meaning that we are currently + ** trying to compute the column names. If we enter this routine with + ** a negative nCol, it means two or more views form a loop, like this: + ** + ** CREATE VIEW one AS SELECT * FROM two; + ** CREATE VIEW two AS SELECT * FROM one; + ** + ** Actually, the error above is now caught prior to reaching this point. + ** But the following test is still important as it does come up + ** in the following: + ** + ** CREATE TABLE main.ex1(a); + ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1; + ** SELECT * FROM temp.ex1; + */ + if int32((*TTable)(unsafe.Pointer(pTable)).FnCol) < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14839, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTable)).FzName)) + return int32(1) + } + /* If we get this far, it means we need to compute the table names. + ** Note that the call to sqlite3ResultSetOfSelect() will expand any + ** "*" elements in the results set of the view and will assign cursors + ** to the elements of the FROM clause. But we do not want these changes + ** to be permanent. So the computation is done on a copy of the SELECT + ** statement that defines the view. + */ + pSel = _sqlite3SelectDup(tls, db, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTable)).Fu))).FpSelect, 0) + if pSel != 0 { + eParseMode = (*TParse)(unsafe.Pointer(pParse)).FeParseMode + nTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + nSelect = (*TParse)(unsafe.Pointer(pParse)).FnSelect + (*TParse)(unsafe.Pointer(pParse)).FeParseMode = uint8(PARSE_MODE_NORMAL) + _sqlite3SrcListAssignCursors(tls, pParse, (*TSelect)(unsafe.Pointer(pSel)).FpSrc) + (*TTable)(unsafe.Pointer(pTable)).FnCol = int16(-int32(1)) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + pSelTab = _sqlite3ResultSetOfSelect(tls, pParse, pSel, uint8(SQLITE_AFF_NONE)) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + (*TParse)(unsafe.Pointer(pParse)).FnTab = nTab + (*TParse)(unsafe.Pointer(pParse)).FnSelect = nSelect + if pSelTab == uintptr(0) { + (*TTable)(unsafe.Pointer(pTable)).FnCol = 0 + nErr = nErr + 1 + } else { + if (*TTable)(unsafe.Pointer(pTable)).FpCheck != 0 { + /* CREATE VIEW name(arglist) AS ... + ** The names of the columns in the table are taken from + ** arglist which is stored in pTable->pCheck. The pCheck field + ** normally holds CHECK constraints on an ordinary table, but for + ** a VIEW it holds the list of column names. + */ + _sqlite3ColumnsFromExprList(tls, pParse, (*TTable)(unsafe.Pointer(pTable)).FpCheck, pTable+54, pTable+8) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && int32((*TTable)(unsafe.Pointer(pTable)).FnCol) == (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpEList)).FnExpr { + _sqlite3SubqueryColumnTypes(tls, pParse, pTable, pSel, uint8(SQLITE_AFF_NONE)) + } + } else { + /* CREATE VIEW name AS... without an argument list. Construct + ** the column names from the SELECT statement that defines the view. + */ + (*TTable)(unsafe.Pointer(pTable)).FnCol = (*TTable)(unsafe.Pointer(pSelTab)).FnCol + (*TTable)(unsafe.Pointer(pTable)).FaCol = (*TTable)(unsafe.Pointer(pSelTab)).FaCol + **(**Tu32)(__ccgo_up(pTable + 48)) |= (*TTable)(unsafe.Pointer(pSelTab)).FtabFlags & uint32(COLFLAG_NOINSERT) + (*TTable)(unsafe.Pointer(pSelTab)).FnCol = 0 + (*TTable)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) + } + } + (*TTable)(unsafe.Pointer(pTable)).FnNVCol = (*TTable)(unsafe.Pointer(pTable)).FnCol + _sqlite3DeleteTable(tls, db, pSelTab) + _sqlite3SelectDelete(tls, db, pSel) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v1 = 0 + } else { + v1 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v1) + (*TParse)(unsafe.Pointer(pParse)).FeParseMode = eParseMode + } else { + nErr = nErr + 1 + } + v2 = (*TTable)(unsafe.Pointer(pTable)).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(DB_UnresetViews)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3DeleteColumnNames(tls, db, pTable) + } + return nErr + (*TParse)(unsafe.Pointer(pParse)).FnErr +} + +// C documentation +// +// /* +// ** Invoke a virtual table constructor (either xCreate or xConnect). The +// ** pointer to the function to invoke is passed as the fourth parameter +// ** to this procedure. +// */ +func _vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, __ccgo_fp_xConstruct uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var azArg, pCtx, pVTable, zFormat, zModuleName, zType, v6 uintptr + var i, iCol, iDb, j, nArg, nDel, nType, rc, v4 int32 + var oooHidden Tu16 + var _ /* sCtx at bp+0 */ TVtabCtx + var _ /* zErr at bp+32 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = azArg, i, iCol, iDb, j, nArg, nDel, nType, oooHidden, pCtx, pVTable, rc, zFormat, zModuleName, zType, v4, v6 + nArg = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FnArg + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + azArg = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg + /* Check that the virtual-table is not already being initialized */ + pCtx = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + for { + if !(pCtx != 0) { + break + } + if (*TVtabCtx)(unsafe.Pointer(pCtx)).FpTab == pTab { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+23403, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(SQLITE_LOCKED) + } + goto _1 + _1: + ; + pCtx = (*TVtabCtx)(unsafe.Pointer(pCtx)).FpPrior + } + zModuleName = _sqlite3DbStrDup(tls, db, (*TTable)(unsafe.Pointer(pTab)).FzName) + if !(zModuleName != 0) { + return int32(SQLITE_NOMEM) + } + pVTable = _sqlite3MallocZero(tls, uint64(48)) + if !(pVTable != 0) { + _sqlite3OomFault(tls, db) + _sqlite3DbFree(tls, db, zModuleName) + return int32(SQLITE_NOMEM) + } + (*TVTable)(unsafe.Pointer(pVTable)).Fdb = db + (*TVTable)(unsafe.Pointer(pVTable)).FpMod = pMod + (*TVTable)(unsafe.Pointer(pVTable)).FeVtabRisk = uint8(SQLITE_VTABRISK_Normal) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg + 1*8)) = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Invoke the virtual table constructor */ + (**(**TVtabCtx)(__ccgo_up(bp))).FpTab = pTab + (**(**TVtabCtx)(__ccgo_up(bp))).FpVTable = pVTable + (**(**TVtabCtx)(__ccgo_up(bp))).FpPrior = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + (**(**TVtabCtx)(__ccgo_up(bp))).FbDeclared = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx = bp + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xConstruct})))(tls, db, (*TModule)(unsafe.Pointer(pMod)).FpAux, nArg, azArg, pVTable+16, bp+32) + _sqlite3DeleteTable(tls, db, pTab) + (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx = (**(**TVtabCtx)(__ccgo_up(bp))).FpPrior + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + if SQLITE_OK != rc { + if **(**uintptr)(__ccgo_up(bp + 32)) == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+23445, libc.VaList(bp+48, zModuleName)) + } else { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+3944, libc.VaList(bp+48, **(**uintptr)(__ccgo_up(bp + 32)))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 32))) + } + _sqlite3DbFree(tls, db, pVTable) + } else { + if (*TVTable)(unsafe.Pointer(pVTable)).FpVtab != 0 { + /* Justification of ALWAYS(): A correct vtab constructor must allocate + ** the sqlite3_vtab object if successful. */ + libc.Xmemset(tls, (*TVTable)(unsafe.Pointer(pVTable)).FpVtab, 0, uint64(24)) + (*Tsqlite3_vtab)(unsafe.Pointer((*TVTable)(unsafe.Pointer(pVTable)).FpVtab)).FpModule = (*TModule)(unsafe.Pointer(pMod)).FpModule + (*TModule)(unsafe.Pointer(pMod)).FnRefModule = (*TModule)(unsafe.Pointer(pMod)).FnRefModule + 1 + (*TVTable)(unsafe.Pointer(pVTable)).FnRef = int32(1) + if (**(**TVtabCtx)(__ccgo_up(bp))).FbDeclared == 0 { + zFormat = __ccgo_ts + 23475 + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, zFormat, libc.VaList(bp+48, zModuleName)) + _sqlite3VtabUnlock(tls, pVTable) + rc = int32(SQLITE_ERROR) + } else { + oooHidden = uint16(0) + /* If everything went according to plan, link the new VTable structure + ** into the linked list headed by pTab->u.vtab.p. Then loop through the + ** columns of the table to see if any of them contain the token "hidden". + ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from + ** the type string. */ + (*TVTable)(unsafe.Pointer(pVTable)).FpNext = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp + (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp = pVTable + iCol = 0 + for { + if !(iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + zType = _sqlite3ColumnType(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16, __ccgo_ts+1704) + i = 0 + nType = _sqlite3Strlen30(tls, zType) + i = 0 + for { + if !(i < nType) { + break + } + if 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+17854, zType+uintptr(i), int32(6)) && (i == 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zType + uintptr(i-int32(1))))) == int32(' ')) && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zType + uintptr(i+int32(6))))) == int32('\000') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zType + uintptr(i+int32(6))))) == int32(' ')) { + break + } + goto _3 + _3: + ; + i = i + 1 + } + if i < nType { + if **(**uint8)(__ccgo_up(zType + uintptr(i+int32(6)))) != 0 { + v4 = int32(1) + } else { + v4 = 0 + } + nDel = int32(6) + v4 + j = i + for { + if !(j+nDel <= nType) { + break + } + **(**uint8)(__ccgo_up(zType + uintptr(j))) = **(**uint8)(__ccgo_up(zType + uintptr(j+nDel))) + goto _5 + _5: + ; + j = j + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zType + uintptr(i)))) == int32('\000') && i > 0 { + **(**uint8)(__ccgo_up(zType + uintptr(i-int32(1)))) = uint8('\000') + } + v6 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + 14 + *(*Tu16)(unsafe.Pointer(v6)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v6))) | libc.Int32FromInt32(COLFLAG_HIDDEN)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_HasHidden) + oooHidden = uint16(TF_OOOHidden) + } else { + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(oooHidden) + } + goto _2 + _2: + ; + iCol = iCol + 1 + } + } + } + } + _sqlite3DbFree(tls, db, zModuleName) + return rc +} + +// C documentation +// +// /* +// ** Perform a reduce action and the shift that must immediately +// ** follow the reduce. +// ** +// ** The yyLookahead and yyLookaheadToken parameters provide reduce actions +// ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE +// ** if the lookahead token has already been consumed. As this procedure is +// ** only called from one place, optimizing compilers will in-line it, which +// ** means that the extra parameters have no performance impact. +// */ +func _yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead int32, yyLookaheadToken TToken, pParse uintptr) (r uint16) { + bp := tls.Alloc(160) + defer tls.Free(160) + var bNot, bNot1, i, nExpr, yygoto, yysize, v353 int32 + var n Tu32 + var op Tu8 + var p, p1, p2, p3, p4, p5, pB, pDot, pFrom, pFromClause, pLeft, pLhs, pList, pList1, pList2, pList3, pList4, pNew, pOld, pRHS, pRhs, pRight, pSelect, pSelectRHS, pSrc, pSubquery, pSubquery1, temp1, temp11, temp2, temp21, temp3, temp4, yymsp, v352 uintptr + var yyact uint16 + var v357 TToken + var _ /* all at bp+112 */ TToken + var _ /* as at bp+72 */ TToken + var _ /* dest at bp+16 */ TSelectDest + var _ /* iValue at bp+88 */ int32 + var _ /* t at bp+96 */ TToken + var _ /* x at bp+56 */ TToken + var _ /* yylhsminor at bp+0 */ TYYMINORTYPE + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNot, bNot1, i, n, nExpr, op, p, p1, p2, p3, p4, p5, pB, pDot, pFrom, pFromClause, pLeft, pLhs, pList, pList1, pList2, pList3, pList4, pNew, pOld, pRHS, pRhs, pRight, pSelect, pSelectRHS, pSrc, pSubquery, pSubquery1, temp1, temp11, temp2, temp21, temp3, temp4, yyact, yygoto, yymsp, yysize, v352, v353, v357 /* Amount to pop the stack */ + _ = yyLookahead + _ = yyLookaheadToken + yymsp = (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos + switch yyruleno { + case uint32(0): + goto _1 + case uint32(1): + goto _2 + case uint32(2): + goto _3 + case uint32(3): + goto _4 + case uint32(4): + goto _5 + case uint32(6): + goto _6 + case uint32(5): + goto _7 + case uint32(7): + goto _8 + case uint32(328): + goto _9 + case uint32(9): + goto _10 + case uint32(8): + goto _11 + case uint32(10): + goto _12 + case uint32(11): + goto _13 + case uint32(12): + goto _14 + case uint32(13): + goto _15 + case uint32(14): + goto _16 + case uint32(18): + goto _17 + case uint32(15): + goto _18 + case uint32(47): + goto _19 + case uint32(62): + goto _20 + case uint32(72): + goto _21 + case uint32(81): + goto _22 + case uint32(100): + goto _23 + case uint32(246): + goto _24 + case uint32(16): + goto _25 + case uint32(17): + goto _26 + case uint32(19): + goto _27 + case uint32(20): + goto _28 + case uint32(21): + goto _29 + case uint32(22): + goto _30 + case uint32(23): + goto _31 + case uint32(24): + goto _32 + case uint32(25): + goto _33 + case uint32(65): + goto _34 + case uint32(26): + goto _35 + case uint32(106): + goto _36 + case uint32(27): + goto _37 + case uint32(28): + goto _38 + case uint32(29): + goto _39 + case uint32(30): + goto _40 + case uint32(31): + goto _41 + case uint32(67): + goto _42 + case uint32(32): + goto _43 + case uint32(33): + goto _44 + case uint32(34): + goto _45 + case uint32(35): + goto _46 + case uint32(36): + goto _47 + case uint32(37): + goto _48 + case uint32(38): + goto _49 + case uint32(39): + goto _50 + case uint32(40): + goto _51 + case uint32(41): + goto _52 + case uint32(42): + goto _53 + case uint32(43): + goto _54 + case uint32(44): + goto _55 + case uint32(45): + goto _56 + case uint32(46): + goto _57 + case uint32(48): + goto _58 + case uint32(49): + goto _59 + case uint32(50): + goto _60 + case uint32(51): + goto _61 + case uint32(52): + goto _62 + case uint32(53): + goto _63 + case uint32(54): + goto _64 + case uint32(55): + goto _65 + case uint32(56): + goto _66 + case uint32(57): + goto _67 + case uint32(58): + goto _68 + case uint32(59): + goto _69 + case uint32(60): + goto _70 + case uint32(76): + goto _71 + case uint32(61): + goto _72 + case uint32(173): + goto _73 + case uint32(80): + goto _74 + case uint32(63): + goto _75 + case uint32(219): + goto _76 + case uint32(222): + goto _77 + case uint32(247): + goto _78 + case uint32(64): + goto _79 + case uint32(66): + goto _80 + case uint32(68): + goto _81 + case uint32(69): + goto _82 + case uint32(70): + goto _83 + case uint32(71): + goto _84 + case uint32(75): + goto _85 + case uint32(73): + goto _86 + case uint32(74): + goto _87 + case uint32(77): + goto _88 + case uint32(174): + goto _89 + case uint32(78): + goto _90 + case uint32(79): + goto _91 + case uint32(82): + goto _92 + case uint32(83): + goto _93 + case uint32(84): + goto _94 + case uint32(85): + goto _95 + case uint32(86): + goto _96 + case uint32(87): + goto _97 + case uint32(88): + goto _98 + case uint32(91): + goto _99 + case uint32(89): + goto _100 + case uint32(90): + goto _101 + case uint32(92): + goto _102 + case uint32(93): + goto _103 + case uint32(94): + goto _104 + case uint32(95): + goto _105 + case uint32(97): + goto _106 + case uint32(96): + goto _107 + case uint32(98): + goto _108 + case uint32(99): + goto _109 + case uint32(134): + goto _110 + case uint32(101): + goto _111 + case uint32(144): + goto _112 + case uint32(234): + goto _113 + case uint32(237): + goto _114 + case uint32(242): + goto _115 + case uint32(102): + goto _116 + case uint32(103): + goto _117 + case uint32(104): + goto _118 + case uint32(117): + goto _119 + case uint32(105): + goto _120 + case uint32(258): + goto _121 + case uint32(259): + goto _122 + case uint32(110): + goto _123 + case uint32(107): + goto _124 + case uint32(108): + goto _125 + case uint32(109): + goto _126 + case uint32(111): + goto _127 + case uint32(112): + goto _128 + case uint32(113): + goto _129 + case uint32(114): + goto _130 + case uint32(115): + goto _131 + case uint32(131): + goto _132 + case uint32(116): + goto _133 + case uint32(120): + goto _134 + case uint32(118): + goto _135 + case uint32(121): + goto _136 + case uint32(119): + goto _137 + case uint32(122): + goto _138 + case uint32(123): + goto _139 + case uint32(124): + goto _140 + case uint32(125): + goto _141 + case uint32(126): + goto _142 + case uint32(127): + goto _143 + case uint32(128): + goto _144 + case uint32(129): + goto _145 + case uint32(130): + goto _146 + case uint32(132): + goto _147 + case uint32(133): + goto _148 + case uint32(145): + goto _149 + case uint32(135): + goto _150 + case uint32(136): + goto _151 + case uint32(137): + goto _152 + case uint32(138): + goto _153 + case uint32(139): + goto _154 + case uint32(143): + goto _155 + case uint32(140): + goto _156 + case uint32(141): + goto _157 + case uint32(142): + goto _158 + case uint32(148): + goto _159 + case uint32(146): + goto _160 + case uint32(153): + goto _161 + case uint32(155): + goto _162 + case uint32(232): + goto _163 + case uint32(233): + goto _164 + case uint32(252): + goto _165 + case uint32(154): + goto _166 + case uint32(147): + goto _167 + case uint32(156): + goto _168 + case uint32(231): + goto _169 + case uint32(251): + goto _170 + case uint32(149): + goto _171 + case uint32(150): + goto _172 + case uint32(151): + goto _173 + case uint32(152): + goto _174 + case uint32(157): + goto _175 + case uint32(158): + goto _176 + case uint32(159): + goto _177 + case uint32(160): + goto _178 + case uint32(161): + goto _179 + case uint32(162): + goto _180 + case uint32(163): + goto _181 + case uint32(164): + goto _182 + case uint32(165): + goto _183 + case uint32(166): + goto _184 + case uint32(167): + goto _185 + case uint32(168): + goto _186 + case uint32(169): + goto _187 + case uint32(170): + goto _188 + case uint32(171): + goto _189 + case uint32(172): + goto _190 + case uint32(175): + goto _191 + case uint32(176): + goto _192 + case uint32(177): + goto _193 + case uint32(178): + goto _194 + case uint32(179): + goto _195 + case uint32(180): + goto _196 + case uint32(181): + goto _197 + case uint32(182): + goto _198 + case uint32(184): + goto _199 + case uint32(183): + goto _200 + case uint32(185): + goto _201 + case uint32(186): + goto _202 + case uint32(187): + goto _203 + case uint32(188): + goto _204 + case uint32(189): + goto _205 + case uint32(190): + goto _206 + case uint32(191): + goto _207 + case uint32(192): + goto _208 + case uint32(193): + goto _209 + case uint32(194): + goto _210 + case uint32(195): + goto _211 + case uint32(196): + goto _212 + case uint32(197): + goto _213 + case uint32(199): + goto _214 + case uint32(198): + goto _215 + case uint32(200): + goto _216 + case uint32(201): + goto _217 + case uint32(202): + goto _218 + case uint32(203): + goto _219 + case uint32(204): + goto _220 + case uint32(205): + goto _221 + case uint32(206): + goto _222 + case uint32(207): + goto _223 + case uint32(208): + goto _224 + case uint32(209): + goto _225 + case uint32(210): + goto _226 + case uint32(211): + goto _227 + case uint32(212): + goto _228 + case uint32(213): + goto _229 + case uint32(215): + goto _230 + case uint32(214): + goto _231 + case uint32(216): + goto _232 + case uint32(217): + goto _233 + case uint32(221): + goto _234 + case uint32(218): + goto _235 + case uint32(220): + goto _236 + case uint32(223): + goto _237 + case uint32(224): + goto _238 + case uint32(225): + goto _239 + case uint32(226): + goto _240 + case uint32(227): + goto _241 + case uint32(228): + goto _242 + case uint32(229): + goto _243 + case uint32(230): + goto _244 + case uint32(235): + goto _245 + case uint32(236): + goto _246 + case uint32(243): + goto _247 + case uint32(238): + goto _248 + case uint32(239): + goto _249 + case uint32(281): + goto _250 + case uint32(240): + goto _251 + case uint32(241): + goto _252 + case uint32(244): + goto _253 + case uint32(245): + goto _254 + case uint32(248): + goto _255 + case uint32(249): + goto _256 + case uint32(250): + goto _257 + case uint32(253): + goto _258 + case uint32(254): + goto _259 + case uint32(255): + goto _260 + case uint32(256): + goto _261 + case uint32(257): + goto _262 + case uint32(260): + goto _263 + case uint32(261): + goto _264 + case uint32(262): + goto _265 + case uint32(263): + goto _266 + case uint32(264): + goto _267 + case uint32(266): + goto _268 + case uint32(265): + goto _269 + case uint32(267): + goto _270 + case uint32(286): + goto _271 + case uint32(268): + goto _272 + case uint32(287): + goto _273 + case uint32(269): + goto _274 + case uint32(270): + goto _275 + case uint32(271): + goto _276 + case uint32(272): + goto _277 + case uint32(273): + goto _278 + case uint32(274): + goto _279 + case uint32(275): + goto _280 + case uint32(276): + goto _281 + case uint32(277): + goto _282 + case uint32(278): + goto _283 + case uint32(279): + goto _284 + case uint32(280): + goto _285 + case uint32(282): + goto _286 + case uint32(283): + goto _287 + case uint32(284): + goto _288 + case uint32(285): + goto _289 + case uint32(288): + goto _290 + case uint32(289): + goto _291 + case uint32(290): + goto _292 + case uint32(291): + goto _293 + case uint32(292): + goto _294 + case uint32(293): + goto _295 + case uint32(294): + goto _296 + case uint32(295): + goto _297 + case uint32(296): + goto _298 + case uint32(297): + goto _299 + case uint32(298): + goto _300 + case uint32(299): + goto _301 + case uint32(300): + goto _302 + case uint32(301): + goto _303 + case uint32(302): + goto _304 + case uint32(303): + goto _305 + case uint32(304): + goto _306 + case uint32(305): + goto _307 + case uint32(307): + goto _308 + case uint32(306): + goto _309 + case uint32(308): + goto _310 + case uint32(310): + goto _311 + case uint32(309): + goto _312 + case uint32(311): + goto _313 + case uint32(312): + goto _314 + case uint32(313): + goto _315 + case uint32(314): + goto _316 + case uint32(315): + goto _317 + case uint32(316): + goto _318 + case uint32(317): + goto _319 + case uint32(318): + goto _320 + case uint32(319): + goto _321 + case uint32(320): + goto _322 + case uint32(321): + goto _323 + case uint32(322): + goto _324 + case uint32(323): + goto _325 + case uint32(324): + goto _326 + case uint32(325): + goto _327 + case uint32(326): + goto _328 + case uint32(327): + goto _329 + case uint32(331): + goto _330 + case uint32(329): + goto _331 + case uint32(332): + goto _332 + case uint32(330): + goto _333 + case uint32(334): + goto _334 + case uint32(333): + goto _335 + case uint32(335): + goto _336 + case uint32(336): + goto _337 + case uint32(338): + goto _338 + case uint32(337): + goto _339 + case uint32(339): + goto _340 + case uint32(340): + goto _341 + case uint32(341): + goto _342 + case uint32(342): + goto _343 + case uint32(343): + goto _344 + case uint32(344): + goto _345 + case uint32(345): + goto _346 + case uint32(346): + goto _347 + case uint32(347): + goto _348 + default: + goto _349 + } + goto _350 +_1: + ; /* explain ::= EXPLAIN */ + if (*TParse)(unsafe.Pointer(pParse)).FpReprepare == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Fexplain = uint8(1) + } + goto _350 +_2: + ; /* explain ::= EXPLAIN QUERY PLAN */ + if (*TParse)(unsafe.Pointer(pParse)).FpReprepare == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Fexplain = uint8(2) + } + goto _350 +_3: + ; /* cmdx ::= cmd */ + _sqlite3FinishCoding(tls, pParse) + goto _350 +_4: + ; /* cmd ::= BEGIN transtype trans_opt */ + _sqlite3BeginTransaction(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_5: + ; /* transtype ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(TK_DEFERRED) + goto _350 +_7: + ; /* transtype ::= DEFERRED */ +_6: + ; +_8: + ; +_9: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_11: + ; /* cmd ::= COMMIT|END trans_opt */ +_10: + ; + _sqlite3EndTransaction(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor)) + goto _350 +_12: + ; /* cmd ::= SAVEPOINT nm */ + _sqlite3Savepoint(tls, pParse, SAVEPOINT_BEGIN, yymsp+8) + goto _350 +_13: + ; /* cmd ::= RELEASE savepoint_opt nm */ + _sqlite3Savepoint(tls, pParse, int32(SAVEPOINT_RELEASE), yymsp+8) + goto _350 +_14: + ; /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ + _sqlite3Savepoint(tls, pParse, int32(SAVEPOINT_ROLLBACK), yymsp+8) + goto _350 +_15: + ; /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ + _sqlite3StartTable(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_16: + ; /* createkw ::= CREATE */ + _disableLookaside(tls, pParse) + goto _350 +_18: + ; /* ifnotexists ::= */ +_17: + ; +_19: + ; +_20: + ; +_21: + ; +_22: + ; +_23: + ; +_24: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = 0 + goto _350 +_25: + ; /* ifnotexists ::= IF NOT EXISTS */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = int32(1) + goto _350 +_26: + ; /* temp ::= TEMP */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.BoolInt32(libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0) + goto _350 +_27: + ; /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */ + _sqlite3EndTable(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*Tu32)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + goto _350 +_28: + ; /* create_table_args ::= AS select */ + _sqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint32(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_29: + ; /* table_option_set ::= */ + *(*Tu32)(unsafe.Pointer(yymsp + 1*24 + 8)) = uint32(0) + goto _350 +_30: + ; /* table_option_set ::= table_option_set COMMA table_option */ + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) | *(*Tu32)(unsafe.Pointer(yymsp + 8)) + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_31: + ; /* table_option ::= WITHOUT nm */ + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) == uint32(5) && Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), __ccgo_ts+17963, int32(5)) == 0 { + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid) | libc.Int32FromInt32(TF_NoVisibleRowid)) + } else { + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint32(0) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24930, libc.VaList(bp+136, *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)))) + } + goto _350 +_32: + ; /* table_option ::= nm */ + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) == uint32(6) && Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), __ccgo_ts+17899, int32(6)) == 0 { + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = uint32(TF_Strict) + } else { + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = uint32(0) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24930, libc.VaList(bp+136, *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)))) + } + *(*Tu32)(unsafe.Pointer(yymsp + 8)) = *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_33: + ; /* columnname ::= nm typetoken */ + _sqlite3AddColumn(tls, pParse, *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*TToken)(unsafe.Pointer(yymsp + 8))) + goto _350 +_35: + ; /* typetoken ::= */ +_34: + ; +_36: + ; + *(*uint32)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uint32(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_37: + ; /* typetoken ::= typename LP signed RP */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t(*(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) - int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))))) + goto _350 +_38: + ; /* typetoken ::= typename LP signed COMMA signed RP */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t(*(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) - int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))))) + goto _350 +_39: + ; /* typename ::= typename ID|STRING */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + libc.Uint32FromInt32(int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))))) + goto _350 +_40: + ; /* scanpt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = yyLookaheadToken.Fz + goto _350 +_41: + ; /* scantok ::= */ + *(*TToken)(unsafe.Pointer(yymsp + 1*24 + 8)) = yyLookaheadToken + goto _350 +_43: + ; /* ccons ::= CONSTRAINT nm */ +_42: + ; + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_44: + ; /* ccons ::= DEFAULT scantok term */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_45: + ; /* ccons ::= DEFAULT LP expr RP */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))+uintptr(1), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_46: + ; /* ccons ::= DEFAULT PLUS scantok term */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_47: + ; /* ccons ::= DEFAULT MINUS scantok term */ + p = _sqlite3PExpr(tls, pParse, int32(TK_UMINUS), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + _sqlite3AddDefaultValue(tls, pParse, p, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_48: + ; /* ccons ::= DEFAULT scantok ID|INDEXED */ + p1 = _tokenExpr(tls, pParse, int32(TK_STRING), *(*TToken)(unsafe.Pointer(yymsp + 8))) + if p1 != 0 { + _sqlite3ExprIdToTrueFalse(tls, p1) + } + _sqlite3AddDefaultValue(tls, pParse, p1, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) + goto _350 +_49: + ; /* ccons ::= NOT NULL onconf */ + _sqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_50: + ; /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ + _sqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_51: + ; /* ccons ::= UNIQUE onconf */ + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_UNIQUE)) + goto _350 +_52: + ; /* ccons ::= CHECK LP expr RP */ + _sqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_53: + ; /* ccons ::= REFERENCES nm eidlist_opt refargs */ + _sqlite3CreateForeignKey(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_54: + ; /* ccons ::= defer_subclause */ + _sqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_55: + ; /* ccons ::= COLLATE ID|STRING */ + _sqlite3AddCollateType(tls, pParse, yymsp+8) + goto _350 +_56: + ; /* generated ::= LP expr RP */ + _sqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_57: + ; /* generated ::= LP expr RP ID */ + _sqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8) + goto _350 +_58: + ; /* autoinc ::= AUTOINCR */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(1) + goto _350 +_59: + ; /* refargs ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = libc.Int32FromInt32(OE_None) * libc.Int32FromInt32(0x0101) /* EV: R-19803-45884 */ + goto _350 +_60: + ; /* refargs ::= refargs refarg */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) & ^*(*int32)(unsafe.Pointer(yymsp + 8 + 4)) | *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_61: + ; /* refarg ::= MATCH nm */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = 0 + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 4)) = 0x000000 + goto _350 +_62: + ; /* refarg ::= ON INSERT refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = 0 + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = 0x000000 + goto _350 +_63: + ; /* refarg ::= ON DELETE refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = int32(0x0000ff) + goto _350 +_64: + ; /* refarg ::= ON UPDATE refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) << int32(8) + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = int32(0x00ff00) + goto _350 +_65: + ; /* refact ::= SET NULL */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(OE_SetNull) /* EV: R-33326-45252 */ + goto _350 +_66: + ; /* refact ::= SET DEFAULT */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(OE_SetDflt) /* EV: R-33326-45252 */ + goto _350 +_67: + ; /* refact ::= CASCADE */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Cascade) /* EV: R-33326-45252 */ + goto _350 +_68: + ; /* refact ::= RESTRICT */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Restrict) /* EV: R-33326-45252 */ + goto _350 +_69: + ; /* refact ::= NO ACTION */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = OE_None /* EV: R-33326-45252 */ + goto _350 +_70: + ; /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = 0 + goto _350 +_72: + ; /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ +_71: + ; +_73: + ; + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_75: + ; /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ +_74: + ; +_76: + ; +_77: + ; +_78: + ; + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(1) + goto _350 +_79: + ; /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = 0 + goto _350 +_80: + ; /* tconscomma ::= COMMA */ + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName.Fn = uint32(0) + goto _350 +_81: + ; /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ + _sqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), 0) + goto _350 +_82: + ; /* tcons ::= UNIQUE LP sortlist RP onconf */ + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_UNIQUE)) + goto _350 +_83: + ; /* tcons ::= CHECK LP expr RP onconf */ + _sqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_84: + ; /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ + _sqlite3CreateForeignKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + _sqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_86: + ; /* onconf ::= */ +_85: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(OE_Default) + goto _350 +_87: + ; /* onconf ::= ON CONFLICT resolvetype */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_88: + ; /* resolvetype ::= IGNORE */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Ignore) + goto _350 +_90: + ; /* resolvetype ::= REPLACE */ +_89: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Replace) + goto _350 +_91: + ; /* cmd ::= DROP TABLE ifexists fullname */ + _sqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), 0, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_92: + ; /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ + _sqlite3CreateView(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(8))*24+8, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))) + goto _350 +_93: + ; /* cmd ::= DROP VIEW ifexists fullname */ + _sqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), int32(1), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_94: + ; /* cmd ::= select */ + **(**TSelectDest)(__ccgo_up(bp + 16)) = TSelectDest{ + FeDest: uint8(SRT_Output), + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_EncodingFixed) != uint32(0) || _sqlite3ReadSchema(tls, pParse) == SQLITE_OK { + _sqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), bp+16) + } + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_95: + ; /* select ::= WITH wqlist selectnowith */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_96: + ; /* select ::= WITH RECURSIVE wqlist selectnowith */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_97: + ; /* select ::= selectnowith */ + p2 = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + if p2 != 0 { + _parserDoubleLinkSelect(tls, pParse, p2) + } + goto _350 +_98: + ; /* selectnowith ::= selectnowith multiselect_op oneselect */ + pRhs = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + pLhs = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + if pRhs != 0 && (*TSelect)(unsafe.Pointer(pRhs)).FpPrior != 0 { + (**(**TToken)(__ccgo_up(bp + 56))).Fn = uint32(0) + _parserDoubleLinkSelect(tls, pParse, pRhs) + pFrom = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+56, pRhs, uintptr(0)) + pRhs = _sqlite3SelectNew(tls, pParse, uintptr(0), pFrom, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + } + if pRhs != 0 { + (*TSelect)(unsafe.Pointer(pRhs)).Fop = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + (*TSelect)(unsafe.Pointer(pRhs)).FpPrior = pLhs + if pLhs != 0 { + **(**Tu32)(__ccgo_up(pLhs + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) + } + **(**Tu32)(__ccgo_up(pRhs + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != int32(TK_ALL) { + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 2, 0x4) + } + } else { + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pLhs) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = pRhs + goto _350 +_100: + ; /* multiselect_op ::= UNION */ +_99: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-OP*/ + goto _350 +_101: + ; /* multiselect_op ::= UNION ALL */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(TK_ALL) + goto _350 +_102: + ; /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_103: + ; /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)) != 0 { + (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)))).FpWinDefn = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + } else { + _sqlite3WindowListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + } + goto _350 +_104: + ; /* values ::= VALUES LP nexprlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values), uintptr(0)) + goto _350 +_105: + ; /* oneselect ::= mvalues */ + _sqlite3MultiValuesEnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_107: + ; /* mvalues ::= values COMMA LP nexprlist RP */ +_106: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3MultiValues(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_108: + ; /* distinct ::= DISTINCT */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SF_Distinct) + goto _350 +_109: + ; /* distinct ::= ALL */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SF_All) + goto _350 +_111: + ; /* sclp ::= */ +_110: + ; +_112: + ; +_113: + ; +_114: + ; +_115: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_116: + ; /* selcollist ::= sclp scanpt expr scanpt as */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) > uint32(0) { + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+8, int32(1)) + } + _sqlite3ExprListSetSpan(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_117: + ; /* selcollist ::= sclp scanpt STAR */ + p3 = _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_ASTERISK), uintptr(0)) + _sqlite3ExprSetErrorOffset(tls, p3, int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64((*TParse)(unsafe.Pointer(pParse)).FzTail))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), p3) + goto _350 +_118: + ; /* selcollist ::= sclp scanpt nm DOT STAR */ + pRight = _sqlite3PExpr(tls, pParse, int32(TK_ASTERISK), uintptr(0), uintptr(0)) + _sqlite3ExprSetErrorOffset(tls, pRight, int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64((*TParse)(unsafe.Pointer(pParse)).FzTail))) + pLeft = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pDot = _sqlite3PExpr(tls, pParse, int32(TK_DOT), pLeft, pRight) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pDot) + goto _350 +_120: + ; /* as ::= AS nm */ +_119: + ; +_121: + ; +_122: + ; + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_124: + ; /* from ::= */ +_123: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_125: + ; /* from ::= FROM seltablist */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + _sqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_126: + ; /* stl_prefix ::= seltablist joinop */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 && (*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnSrc > 0 { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8 + uintptr((*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnSrc-int32(1))*80))).Ffg.Fjointype = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + 8))) + } + goto _350 +_127: + ; /* seltablist ::= stl_prefix nm dbnm as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + goto _350 +_128: + ; /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, uintptr(0), yymsp+8) + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + goto _350 +_129: + ; /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + _sqlite3SrcListFuncArgs(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + goto _350 +_130: + ; /* seltablist ::= stl_prefix LP select RP as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_131: + ; /* seltablist ::= stl_prefix LP seltablist RP as on_using */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) == uintptr(0) && *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) == uint32(0) && *(*uintptr)(unsafe.Pointer(yymsp + 8)) == uintptr(0) && *(*uintptr)(unsafe.Pointer(yymsp + 8 + 8)) == uintptr(0) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + } else { + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != uintptr(0) && (*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))).FnSrc == int32(1) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) != 0 { + pNew = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) + 8 + uintptr((*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)))).FnSrc-int32(1))*80 + pOld = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + 8 + (*TSrcItem)(unsafe.Pointer(pNew)).FzName = (*TSrcItem)(unsafe.Pointer(pOld)).FzName + if int32(*(*uint32)(unsafe.Pointer(pOld + 24 + 4))&0x4>>2) != 0 { + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 2, 0x4) + *(*uintptr)(unsafe.Pointer(pNew + 72)) = *(*uintptr)(unsafe.Pointer(pOld + 72)) + *(*uintptr)(unsafe.Pointer(pOld + 72)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pOld+24+4, libc.Uint32FromInt32(0), 2, 0x4) + if (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 72)))).FpSelect)).FselFlags&uint32(SF_NestedFrom) != uint32(0) { + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 14, 0x4000) + } + } else { + *(*uintptr)(unsafe.Pointer(pNew + 72)) = *(*uintptr)(unsafe.Pointer(pOld + 72)) + *(*uintptr)(unsafe.Pointer(pOld + 72)) = uintptr(0) + } + if int32(*(*uint32)(unsafe.Pointer(pOld + 24 + 4))&0x8>>3) != 0 { + *(*uintptr)(unsafe.Pointer(pNew + 48)) = *(*uintptr)(unsafe.Pointer(pOld + 48)) + *(*uintptr)(unsafe.Pointer(pOld + 48)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pOld+24+4, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 3, 0x8) + } + (*TSrcItem)(unsafe.Pointer(pOld)).FzName = uintptr(0) + } + _sqlite3SrcListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + } else { + _sqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + pSubquery = _sqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, pSubquery, yymsp+8) + } + } + goto _350 +_133: + ; /* dbnm ::= */ +_132: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + *(*uint32)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uint32(0) + goto _350 +_135: + ; /* fullname ::= nm */ +_134: + ; + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+8, uintptr(0)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+8) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_137: + ; /* fullname ::= nm DOT nm */ +_136: + ; + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+8) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_138: + ; /* xfullname ::= nm AS nm */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, uintptr(0)) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + } else { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzAlias = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, yymsp+8) + } + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_139: + ; /* xfullname ::= nm DOT nm AS nm */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + } else { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzAlias = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, yymsp+8) + } + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_140: + ; /* joinop ::= COMMA|JOIN */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(JT_INNER) + goto _350 +_141: + ; /* joinop ::= JOIN_KW JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), uintptr(0)) /*X-overwrites-A*/ + goto _350 +_142: + ; /* joinop ::= JOIN_KW nm JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0)) /*X-overwrites-A*/ + goto _350 +_143: + ; /* joinop ::= JOIN_KW nm nm JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) /*X-overwrites-A*/ + goto _350 +_144: + ; /* on_using ::= ON expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = uintptr(0) + goto _350 +_145: + ; /* on_using ::= USING LP idlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_146: + ; /* on_using ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uintptr(0) + goto _350 +_147: + ; /* indexed_by ::= INDEXED BY nm */ + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_148: + ; /* indexed_by ::= NOT INDEXED */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = uint32(1) + goto _350 +_150: + ; /* orderby_opt ::= ORDER BY sortlist */ +_149: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_151: + ; /* sortlist ::= sortlist COMMA expr sortorder nulls */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + _sqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_152: + ; /* sortlist ::= expr sortorder nulls */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) /*A-overwrites-Y*/ + _sqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_153: + ; /* sortorder ::= ASC */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = SQLITE_SO_ASC + goto _350 +_154: + ; /* sortorder ::= DESC */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SQLITE_SO_DESC) + goto _350 +_156: + ; /* sortorder ::= */ +_155: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = -int32(1) + goto _350 +_157: + ; /* nulls ::= NULLS FIRST */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = SQLITE_SO_ASC + goto _350 +_158: + ; /* nulls ::= NULLS LAST */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(SQLITE_SO_DESC) + goto _350 +_160: + ; /* having_opt ::= */ +_159: + ; +_161: + ; +_162: + ; +_163: + ; +_164: + ; +_165: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_167: + ; /* having_opt ::= HAVING expr */ +_166: + ; +_168: + ; +_169: + ; +_170: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_171: + ; /* limit_opt ::= LIMIT expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + goto _350 +_172: + ; /* limit_opt ::= LIMIT expr OFFSET expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_173: + ; /* limit_opt ::= LIMIT expr COMMA expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_174: + ; /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + _sqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0)) + goto _350 +_175: + ; /* where_opt_ret ::= RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + goto _350 +_176: + ; /* where_opt_ret ::= WHERE expr RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + goto _350 +_177: + ; /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + _sqlite3ExprListCheckLength(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), __ccgo_ts+24957) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + pFromClause = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + if (*TSrcList)(unsafe.Pointer(pFromClause)).FnSrc > int32(1) { + pSubquery1 = _sqlite3SelectNew(tls, pParse, uintptr(0), pFromClause, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) + (**(**TToken)(__ccgo_up(bp + 72))).Fn = uint32(0) + (**(**TToken)(__ccgo_up(bp + 72))).Fz = uintptr(0) + pFromClause = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+72, pSubquery1, uintptr(0)) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), pFromClause) + } + _sqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0), uintptr(0), uintptr(0)) + goto _350 +_178: + ; /* setlist ::= setlist COMMA nm EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, int32(1)) + goto _350 +_179: + ; /* setlist ::= setlist COMMA LP idlist RP EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) = _sqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_180: + ; /* setlist ::= nm EQ expr */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, int32(1)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_181: + ; /* setlist ::= LP idlist RP EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_182: + ; /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ + _sqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_183: + ; /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ + _sqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0)) + goto _350 +_184: + ; /* upsert ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_185: + ; /* upsert ::= RETURNING selcollist */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_186: + ; /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(11))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_187: + ; /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_188: + ; /* upsert ::= ON CONFLICT DO NOTHING returning */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + goto _350 +_189: + ; /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_190: + ; /* returning ::= RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_191: + ; /* idlist_opt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_192: + ; /* idlist_opt ::= LP idlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_193: + ; /* idlist ::= idlist COMMA nm */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8) + goto _350 +_194: + ; /* idlist ::= nm */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3IdListAppend(tls, pParse, uintptr(0), yymsp+8) /*A-overwrites-Y*/ + goto _350 +_195: + ; /* expr ::= LP expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_196: + ; /* expr ::= ID|INDEXED|JOIN_KW */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_197: + ; /* expr ::= nm DOT nm */ + temp1 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + temp2 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp1, temp2) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_198: + ; /* expr ::= nm DOT nm DOT nm */ + temp11 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + temp21 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + temp3 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) + temp4 = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp21, temp3) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), temp11) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp11, temp4) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_200: + ; /* term ::= NULL|FLOAT|BLOB */ +_199: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*TToken)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_201: + ; /* term ::= INTEGER */ + if _sqlite3GetInt32(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), bp+88) == 0 { + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_INTEGER), yymsp+8, 0) + } else { + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprInt32(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, **(**int32)(__ccgo_up(bp + 88))) + } + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 52)) = int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8))) - int64((*TParse)(unsafe.Pointer(pParse)).FzTail)) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_202: + ; /* expr ::= VARIABLE */ + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + 8))))) == int32('#') && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + 8)) + 1)))])&int32(0x04) != 0) { + n = *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, int32(TK_VARIABLE), *(*TToken)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), n) + } else { + /* When doing a nested parse, one can include terms in an expression + ** that look like this: #1 #2 ... These terms refer to registers + ** in the virtual machine. #N is the N-th register. */ + **(**TToken)(__ccgo_up(bp + 96)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) /*A-overwrites-X*/ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _parserSyntaxError(tls, pParse, bp+96) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = uintptr(0) + } else { + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_REGISTER), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + _sqlite3GetInt32(tls, (**(**TToken)(__ccgo_up(bp + 96))).Fz+1, *(*uintptr)(unsafe.Pointer(yymsp + 8))+44) + } + } + } + goto _350 +_203: + ; /* expr ::= expr COLLATE ID|STRING */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8, int32(1)) + goto _350 +_204: + ; /* expr ::= CAST LP expr AS typetoken RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_CAST), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, int32(1)) + _sqlite3ExprAttachSubtrees(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0)) + goto _350 +_205: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_206: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))) + _sqlite3ExprAddFunctionOrderBy(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_207: + ; /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_208: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_209: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(8))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8))) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprAddFunctionOrderBy(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_210: + ; /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, 0) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_211: + ; /* term ::= CTIME_KW */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_212: + ; /* expr ::= LP nexprlist COMMA expr RP */ + pList = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_VECTOR), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = pList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 4)) |= (*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr)).Fflags & libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)|libc.Int32FromInt32(EP_Subquery)|libc.Int32FromInt32(EP_HasFunc)) + goto _351 + _351: + ; + i = i + 1 + } + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList) + } + goto _350 +_213: + ; /* expr ::= expr AND expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_215: + ; /* expr ::= expr OR expr */ +_214: + ; +_216: + ; +_217: + ; +_218: + ; +_219: + ; +_220: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_221: + ; /* likeop ::= NOT LIKE_KW|MATCH */ + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) |= uint32(0x80000000) /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/ + goto _350 +_222: + ; /* expr ::= expr likeop expr */ + bNot = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) & uint32(0x80000000)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) &= uint32(0x7fffffff) + pList1 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + pList1 = _sqlite3ExprListAppend(tls, pParse, pList1, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprFunction(tls, pParse, pList1, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + if bNot != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), uintptr(0)) + } + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) != 0 { + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + 4)) |= uint32(EP_InfixFunc) + } + goto _350 +_223: + ; /* expr ::= expr likeop expr ESCAPE expr */ + bNot1 = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) & uint32(0x80000000)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) &= uint32(0x7fffffff) + pList2 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList2 = _sqlite3ExprListAppend(tls, pParse, pList2, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + pList2 = _sqlite3ExprListAppend(tls, pParse, pList2, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprFunction(tls, pParse, pList2, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, 0) + if bNot1 != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 4)) |= uint32(EP_InfixFunc) + } + goto _350 +_224: + ; /* expr ::= expr ISNULL|NOTNULL */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExprIsNull(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_225: + ; /* expr ::= expr NOT NULL */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExprIsNull(tls, pParse, int32(TK_NOTNULL), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_226: + ; /* expr ::= expr IS expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_IS), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_227: + ; /* expr ::= expr IS NOT expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_ISNOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_228: + ; /* expr ::= expr IS NOT DISTINCT FROM expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_IS), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_229: + ; /* expr ::= expr IS DISTINCT FROM expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_ISNOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_231: + ; /* expr ::= NOT expr */ +_230: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) /*A-overwrites-B*/ + goto _350 +_232: + ; /* expr ::= PLUS|MINUS expr */ + p4 = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + op = libc.Uint8FromInt32(libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) + (libc.Int32FromInt32(TK_UPLUS) - libc.Int32FromInt32(TK_PLUS))) + if p4 != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p4)).Fop) == int32(TK_UPLUS) { + (*TExpr)(unsafe.Pointer(p4)).Fop = op + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = p4 + } else { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8(op), p4, uintptr(0)) + /*A-overwrites-B*/ + } + goto _350 +_233: + ; /* expr ::= expr PTR expr */ + pList3 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList3 = _sqlite3ExprListAppend(tls, pParse, pList3, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, pList3, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_235: + ; /* between_op ::= BETWEEN */ +_234: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = 0 + goto _350 +_236: + ; /* expr ::= expr between_op expr AND expr */ + pList4 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList4 = _sqlite3ExprListAppend(tls, pParse, pList4, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_BETWEEN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = pList4 + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList4) + } + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_237: + ; /* expr ::= expr in_op LP exprlist RP */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) == uintptr(0) { + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + v352 = __ccgo_ts + 8178 + } else { + v352 = __ccgo_ts + 8183 + } + /* Expressions of the form + ** + ** expr1 IN () + ** expr1 NOT IN () + ** + ** simplify to constants 0 (false) and 1 (true), respectively. + ** + ** Except, do not apply this optimization if expr1 contains a function + ** because that function might be an aggregate (we don't know yet whether + ** it is or not) and if it is an aggregate, that could change the meaning + ** of the whole query. + */ + pB = _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_STRING), v352) + if pB != 0 { + _sqlite3ExprIdToTrueFalse(tls, pB) + } + if !((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)) != libc.Uint32FromInt32(0)) { + _sqlite3ExprUnmapAndDelete(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = pB + } else { + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + v353 = int32(TK_OR) + } else { + v353 = int32(TK_AND) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, v353, pB, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } + } else { + pRHS = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8))).FpExpr + if (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnExpr == int32(1) && _sqlite3ExprIsConstant(tls, pParse, pRHS) != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).Fop) != int32(TK_VECTOR) { + (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8))).FpExpr = uintptr(0) + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + pRHS = _sqlite3PExpr(tls, pParse, int32(TK_UPLUS), pRHS, uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_EQ), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pRHS) + } else { + if (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnExpr == int32(1) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRHS)).Fop) == int32(TK_SELECT) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(pRHS + 32))) + *(*uintptr)(unsafe.Pointer(pRHS + 32)) = uintptr(0) + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) == uintptr(0) { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).FpLeft)).Fop) == int32(TK_VECTOR) { + nExpr = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).FpLeft + 32)))).FnExpr + pSelectRHS = _sqlite3ExprListToValues(tls, pParse, nExpr, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + if pSelectRHS != 0 { + _parserDoubleLinkSelect(tls, pParse, pSelectRHS) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pSelectRHS) + } + } else { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } + } + } + } + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + } + goto _350 +_238: + ; /* expr ::= LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_SELECT), uintptr(0), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_239: + ; /* expr ::= expr in_op LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_240: + ; /* expr ::= expr in_op nm dbnm paren_exprlist */ + pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + pSelect = _sqlite3SelectNew(tls, pParse, uintptr(0), pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + if pSelect != 0 { + v352 = pSrc + } else { + v352 = uintptr(0) + } + _sqlite3SrcListFuncArgs(tls, pParse, v352, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pSelect) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_241: + ; /* expr ::= EXISTS LP select RP */ + v352 = _sqlite3PExpr(tls, pParse, int32(TK_EXISTS), uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = v352 + p5 = v352 + _sqlite3PExprAddSelect(tls, pParse, p5, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_242: + ; /* expr ::= CASE case_operand case_exprlist case_else END */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_CASE), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + v352 = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + v352 = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + } + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = v352 + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } + goto _350 +_243: + ; /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_244: + ; /* case_exprlist ::= WHEN expr THEN expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_245: + ; /* nexprlist ::= nexprlist COMMA expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_246: + ; /* nexprlist ::= expr */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-Y*/ + goto _350 +_248: + ; /* paren_exprlist ::= LP exprlist RP */ +_247: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_249: + ; /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + _sqlite3CreateIndex(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, uintptr(0)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(11))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + 8)), SQLITE_SO_ASC, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), uint8(SQLITE_IDXTYPE_APPDEF)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TParse)(unsafe.Pointer(pParse)).FpNewIndex != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*TIndex)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).FpNewIndex)).FzName, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + } + goto _350 +_251: + ; /* uniqueflag ::= UNIQUE */ +_250: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Abort) + goto _350 +_252: + ; /* uniqueflag ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = OE_None + goto _350 +_253: + ; /* eidlist ::= eidlist COMMA nm collate sortorder */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_254: + ; /* eidlist ::= nm collate sortorder */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _parserAddExprIdListTerm(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-Y*/ + goto _350 +_255: + ; /* cmd ::= DROP INDEX ifexists fullname */ + _sqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_256: + ; /* cmd ::= VACUUM vinto */ + _sqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_257: + ; /* cmd ::= VACUUM nm vinto */ + _sqlite3Vacuum(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_258: + ; /* cmd ::= PRAGMA nm dbnm */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8, uintptr(0), 0) + goto _350 +_259: + ; /* cmd ::= PRAGMA nm dbnm EQ nmnum */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, 0) + goto _350 +_260: + ; /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + goto _350 +_261: + ; /* cmd ::= PRAGMA nm dbnm EQ minus_num */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, int32(1)) + goto _350 +_262: + ; /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, int32(1)) + goto _350 +_263: + ; /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + (**(**TToken)(__ccgo_up(bp + 112))).Fz = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + (**(**TToken)(__ccgo_up(bp + 112))).Fn = libc.Uint32FromInt32(int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))))) + *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + _sqlite3FinishTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), bp+112) + goto _350 +_264: + ; /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + _sqlite3BeginTrigger(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8))) + if *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8 + 8)) == uint32(0) { + v357 = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) + } else { + v357 = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) + } + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)) = v357 /*A-overwrites-T*/ + goto _350 +_265: + ; /* trigger_time ::= BEFORE|AFTER */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_266: + ; /* trigger_time ::= INSTEAD OF */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(TK_INSTEAD) + goto _350 +_267: + ; /* trigger_time ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(TK_BEFORE) + goto _350 +_269: + ; /* trigger_event ::= DELETE|INSERT */ +_268: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 + 8)) = uintptr(0) + goto _350 +_270: + ; /* trigger_event ::= UPDATE OF idlist */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = int32(TK_UPDATE) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_272: + ; /* when_clause ::= */ +_271: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_274: + ; /* when_clause ::= WHEN expr */ +_273: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_275: + ; /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + (*TTriggerStep)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)))).FpLast)).FpNext = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + (*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_276: + ; /* trigger_cmd_list ::= trigger_cmd SEMI */ + (*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_277: + ; /* tridxby ::= INDEXED BY nm */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24966, 0) + goto _350 +_278: + ; /* tridxby ::= NOT INDEXED */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25050, 0) + goto _350 +_279: + ; /* trigger_cmd ::= UPDATE orconf xfullname tridxby SET setlist from where_opt scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerUpdateStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_280: + ; /* trigger_cmd ::= scanpt insert_cmd INTO xfullname idlist_opt select upsert scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerInsertStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_281: + ; /* trigger_cmd ::= DELETE FROM xfullname tridxby where_opt scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerDeleteStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_282: + ; /* trigger_cmd ::= scanpt select scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerSelectStep(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_283: + ; /* expr ::= RAISE LP IGNORE RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + (*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))).FaffExpr = uint8(OE_Ignore) + } + goto _350 +_284: + ; /* expr ::= RAISE LP raisetype COMMA expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) != 0 { + (*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)))).FaffExpr = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + } + goto _350 +_285: + ; /* raisetype ::= ROLLBACK */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Rollback) + goto _350 +_286: + ; /* raisetype ::= FAIL */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Fail) + goto _350 +_287: + ; /* cmd ::= DROP TRIGGER ifexists fullname */ + _sqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_288: + ; /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + _sqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_289: + ; /* cmd ::= DETACH database_kw_opt expr */ + _sqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_290: + ; /* cmd ::= REINDEX */ + _sqlite3Reindex(tls, pParse, uintptr(0), uintptr(0)) + goto _350 +_291: + ; /* cmd ::= REINDEX nm dbnm */ + _sqlite3Reindex(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8) + goto _350 +_292: + ; /* cmd ::= ANALYZE */ + _sqlite3Analyze(tls, pParse, uintptr(0), uintptr(0)) + goto _350 +_293: + ; /* cmd ::= ANALYZE nm dbnm */ + _sqlite3Analyze(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8) + goto _350 +_294: + ; /* cmd ::= ALTER TABLE fullname RENAME TO nm */ + _sqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_295: + ; /* cmd ::= alter_add carglist */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))))) + (*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fn + _sqlite3AlterFinishAddColumn(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + goto _350 +_296: + ; /* alter_add ::= ALTER TABLE fullname ADD kwcolumn_opt nm typetoken */ + _disableLookaside(tls, pParse) + _sqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + _sqlite3AddColumn(tls, pParse, *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*TToken)(unsafe.Pointer(yymsp + 8))) + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_297: + ; /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ + _sqlite3AlterDropColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_298: + ; /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + _sqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8) + goto _350 +_299: + ; /* cmd ::= ALTER TABLE fullname DROP CONSTRAINT nm */ + _sqlite3AlterDropConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8, uintptr(0)) + goto _350 +_300: + ; /* cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm DROP NOT NULL */ + _sqlite3AlterDropConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8) + goto _350 +_301: + ; /* cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm SET NOT NULL onconf */ + _sqlite3AlterSetNotNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + goto _350 +_302: + ; /* cmd ::= ALTER TABLE fullname ADD CONSTRAINT nm CHECK LP expr RP onconf */ + _sqlite3AlterAddConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))+uintptr(1), int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))-libc.Int64FromInt32(1)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_303: + ; /* cmd ::= ALTER TABLE fullname ADD CHECK LP expr RP onconf */ + _sqlite3AlterAddConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))+uintptr(1), int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))-libc.Int64FromInt32(1)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_304: + ; /* cmd ::= create_vtab */ + _sqlite3VtabFinishParse(tls, pParse, uintptr(0)) + goto _350 +_305: + ; /* cmd ::= create_vtab LP vtabarglist RP */ + _sqlite3VtabFinishParse(tls, pParse, yymsp+8) + goto _350 +_306: + ; /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + _sqlite3VtabBeginParse(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + goto _350 +_307: + ; /* vtabarg ::= */ + _sqlite3VtabArgInit(tls, pParse) + goto _350 +_309: + ; /* vtabargtoken ::= ANY */ +_308: + ; +_310: + ; + _sqlite3VtabArgExtend(tls, pParse, yymsp+8) + goto _350 +_312: + ; /* with ::= WITH wqlist */ +_311: + ; + _sqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uint8(1)) + goto _350 +_313: + ; /* wqas ::= AS */ + *(*Tu8)(unsafe.Pointer(yymsp + 8)) = uint8(M10d_Any) + goto _350 +_314: + ; /* wqas ::= AS MATERIALIZED */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint8(M10d_Yes) + goto _350 +_315: + ; /* wqas ::= AS NOT MATERIALIZED */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = uint8(M10d_No) + goto _350 +_316: + ; /* wqitem ::= withnm eidlist_opt wqas LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3CteNew(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) /*A-overwrites-X*/ + goto _350 +_317: + ; /* withnm ::= nm */ + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 6, 0x40) + goto _350 +_318: + ; /* wqlist ::= wqitem */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3WithAdd(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_319: + ; /* wqlist ::= wqlist COMMA wqitem */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3WithAdd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_320: + ; /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ + _sqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_321: + ; /* windowdefn ::= nm AS LP window RP */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FzName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uint64(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8 + 8)))) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_322: + ; /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_323: + ; /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(5))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_324: + ; /* window ::= ORDER BY sortlist frame_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_325: + ; /* window ::= nm ORDER BY sortlist frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_326: + ; /* window ::= nm frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_327: + ; /* frame_opt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = _sqlite3WindowAlloc(tls, pParse, 0, int32(TK_UNBOUNDED), uintptr(0), int32(TK_CURRENT), uintptr(0), uint8(0)) + goto _350 +_328: + ; /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)), int32(TK_CURRENT), uintptr(0), *(*Tu8)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_329: + ; /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)), *(*Tu8)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_331: + ; /* frame_bound_s ::= frame_bound */ +_330: + ; + *(*TFrameBound)(unsafe.Pointer(bp)) = *(*TFrameBound)(unsafe.Pointer(yymsp + 8)) + *(*TFrameBound)(unsafe.Pointer(yymsp + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_333: + ; /* frame_bound_s ::= UNBOUNDED PRECEDING */ +_332: + ; +_334: + ; + (*(*TFrameBound)(unsafe.Pointer(bp))).FeType = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) + (*(*TFrameBound)(unsafe.Pointer(bp))).FpExpr = uintptr(0) + *(*TFrameBound)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_335: + ; /* frame_bound ::= expr PRECEDING|FOLLOWING */ + (*(*TFrameBound)(unsafe.Pointer(bp))).FeType = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) + (*(*TFrameBound)(unsafe.Pointer(bp))).FpExpr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + *(*TFrameBound)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_336: + ; /* frame_exclude_opt ::= */ + *(*Tu8)(unsafe.Pointer(yymsp + 1*24 + 8)) = uint8(0) + goto _350 +_337: + ; /* frame_exclude_opt ::= EXCLUDE frame_exclude */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*Tu8)(unsafe.Pointer(yymsp + 8)) + goto _350 +_339: + ; /* frame_exclude ::= NO OTHERS */ +_338: + ; + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint8((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) /*A-overwrites-X*/ + goto _350 +_340: + ; /* frame_exclude ::= GROUP|TIES */ + *(*Tu8)(unsafe.Pointer(yymsp + 8)) = uint8((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_341: + ; /* window_clause ::= WINDOW windowdefn_list */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_342: + ; /* filter_over ::= filter_clause over_clause */ + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_343: + ; /* filter_over ::= over_clause */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_344: + ; /* filter_over ::= filter_clause */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))))).FeFrmType = uint8(TK_FILTER) + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_345: + ; /* over_clause ::= OVER LP window RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_346: + ; /* over_clause ::= OVER nm */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FzName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uint64(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) + } + goto _350 +_347: + ; /* filter_clause ::= FILTER LP WHERE expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_348: + ; /* term ::= QNUMBER */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _tokenExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*TToken)(unsafe.Pointer(yymsp + 8))) + _sqlite3DequoteNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp))))) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_349: + ; + goto _350 + /********** End reduce actions ************************************************/ +_350: + ; + yygoto = libc.Int32FromUint16(_yyRuleInfoLhs[yyruleno]) + yysize = int32(_yyRuleInfoNRhs[yyruleno]) + yyact = _yy_find_reduce_action(tls, (**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(yysize)*24))).Fstateno, libc.Uint16FromInt32(yygoto)) + /* There are no SHIFTREDUCE actions on nonterminals because the table + ** generator has simplified them to pure REDUCE actions. */ + /* It is not possible for a REDUCE to be followed by an error */ + yymsp = yymsp + uintptr(yysize+int32(1))*24 + (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos = yymsp + (*TyyStackEntry)(unsafe.Pointer(yymsp)).Fstateno = yyact + (*TyyStackEntry)(unsafe.Pointer(yymsp)).Fmajor = libc.Uint16FromInt32(yygoto) + return yyact +} + +/* +** The following code executes when the parse fails + */ diff --git a/internal/engine/lib/sqlite_g_0000000000003a20.go b/internal/engine/lib/sqlite_g_0000000000003a20.go new file mode 100644 index 0000000..c754b69 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003a20.go @@ -0,0 +1,204 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && arm64) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** This function is called to obtain a shared lock on the database file. +// ** It is illegal to call sqlite3PagerGet() until after this function +// ** has been successfully called. If a shared-lock is already held when +// ** this function is called, it is a no-op. +// ** +// ** The following operations are also performed by this function. +// ** +// ** 1) If the pager is currently in PAGER_OPEN state (no lock held +// ** on the database file), then an attempt is made to obtain a +// ** SHARED lock on the database file. Immediately after obtaining +// ** the SHARED lock, the file-system is checked for a hot-journal, +// ** which is played back if present. Following any hot-journal +// ** rollback, the contents of the cache are validated by checking +// ** the 'change-counter' field of the database file header and +// ** discarded if they are found to be invalid. +// ** +// ** 2) If the pager is running in exclusive-mode, and there are currently +// ** no outstanding references to any pages, and is in the error state, +// ** then an attempt is made to clear the error state by discarding +// ** the contents of the page cache and rolling back any open journal +// ** file. +// ** +// ** If everything is successful, SQLITE_OK is returned. If an IO error +// ** occurs while locking the database, checking for a hot-journal file or +// ** rolling back a journal file, the IO error code is returned. +// */ +func _sqlite3PagerSharedLock(tls *libc.TLS, pPager uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var f, rc int32 + var pVfs uintptr + var _ /* bExists at bp+4 */ int32 + var _ /* bHotJournal at bp+0 */ int32 + var _ /* dbFileVers at bp+12 */ [16]uint8 + var _ /* fout at bp+8 */ int32 + _, _, _ = f, pVfs, rc + rc = SQLITE_OK /* Return code */ + /* This routine is only called from b-tree and only when there are no + ** outstanding pages. This implies that the pager state should either + ** be OPEN or READER. READER is only possible if the pager is or was in + ** exclusive access mode. */ + if !((*TPager)(unsafe.Pointer(pPager)).FpWal != libc.UintptrFromInt32(0)) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN { + **(**int32)(__ccgo_up(bp)) = int32(1) /* True if there exists a hot journal-file */ + rc = _pager_wait_on_lock(tls, pPager, int32(SHARED_LOCK)) + if rc != SQLITE_OK { + goto failed + } + /* If a journal file exists, and there is no RESERVED lock on the + ** database file, then it either needs to be played back or deleted. + */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) <= int32(SHARED_LOCK) { + rc = _hasHotJournal(tls, pPager, bp) + } + if rc != SQLITE_OK { + goto failed + } + if **(**int32)(__ccgo_up(bp)) != 0 { + if (*TPager)(unsafe.Pointer(pPager)).FreadOnly != 0 { + rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(3)<tnum. */ + if wrFlag != 0 { + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fopcode = uint8(OP_OpenWrite) + } + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp2 = libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab)).Ftnum) + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp3 = iDb + /* Configure the number of columns. Configure the cursor to + ** think that the table has one more column than it really + ** does. An OP_Column to retrieve this imaginary column will + ** always return an SQL NULL. This is useful because it means + ** we can invoke OP_Column to fill in the vdbe cursors type + ** and offset cache without causing any IO. + */ + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp4type = int8(-libc.Int32FromInt32(3)) + *(*int32)(unsafe.Pointer(aOp + 1*24 + 16)) = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + int32(1) + (**(**TVdbeOp)(__ccgo_up(aOp + 3*24))).Fp2 = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + (**(**TParse)(__ccgo_up(bp + 8))).FnVar = 0 + (**(**TParse)(__ccgo_up(bp + 8))).FnMem = int32(1) + (**(**TParse)(__ccgo_up(bp + 8))).FnTab = int32(1) + _sqlite3VdbeMakeReady(tls, v, bp+8) + } + } + (*TIncrblob)(unsafe.Pointer(pBlob)).FiCol = libc.Uint16FromInt32(iCol) + (*TIncrblob)(unsafe.Pointer(pBlob)).Fdb = db + _sqlite3BtreeLeaveAll(tls, db) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto blob_open_out + } + rc = _blobSeekToRow(tls, pBlob, iRow, bp) + nAttempt = nAttempt + 1 + v1 = nAttempt + if v1 >= int32(SQLITE_MAX_SCHEMA_RETRY) || rc != int32(SQLITE_SCHEMA) { + break + } + _sqlite3ParseObjectReset(tls, bp+8) + } + goto blob_open_out +blob_open_out: + ; + if rc == SQLITE_OK && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + **(**uintptr)(__ccgo_up(ppBlob)) = pBlob + } else { + if pBlob != 0 && (*TIncrblob)(unsafe.Pointer(pBlob)).FpStmt != 0 { + _sqlite3VdbeFinalize(tls, (*TIncrblob)(unsafe.Pointer(pBlob)).FpStmt) + } + _sqlite3DbFree(tls, db, pBlob) + } + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v8 = __ccgo_ts + 3944 + } else { + v8 = libc.UintptrFromInt32(0) + } + _sqlite3ErrorWithMsg(tls, db, rc, v8, libc.VaList(bp+432, **(**uintptr)(__ccgo_up(bp)))) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + _sqlite3ParseObjectReset(tls, bp+8) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** This function is used to set the schema of a virtual table. It is only +// ** valid to call this function from within the xCreate() or xConnect() of a +// ** virtual table module. +// */ +func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) (r int32) { + bp := tls.Alloc(448) + defer tls.Free(448) + var i, initBusy, rc int32 + var pCtx, pIdx, pNew, pTab, z, v3 uintptr + var v2 Ti16 + var _ /* sParse at bp+0 */ TParse + var _ /* tokenType at bp+416 */ int32 + _, _, _, _, _, _, _, _, _, _ = i, initBusy, pCtx, pIdx, pNew, pTab, rc, z, v2, v3 + rc = SQLITE_OK + /* Verify that the first two keywords in the CREATE TABLE statement + ** really are "CREATE" and "TABLE". If this is not the case, then + ** sqlite3_declare_vtab() is being misused. + */ + z = zCreateTable + i = 0 + for { + if !(_aKeyword1[i] != 0) { + break + } + **(**int32)(__ccgo_up(bp + 416)) = 0 + for cond := true; cond; cond = **(**int32)(__ccgo_up(bp + 416)) == int32(TK_SPACE) || **(**int32)(__ccgo_up(bp + 416)) == int32(TK_COMMENT) { + z = z + uintptr(_sqlite3GetToken(tls, z, bp+416)) + } + if **(**int32)(__ccgo_up(bp + 416)) != libc.Int32FromUint8(_aKeyword1[i]) { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_ERROR), __ccgo_ts+23540, 0) + return int32(SQLITE_ERROR) + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pCtx = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + if !(pCtx != 0) || (*TVtabCtx)(unsafe.Pointer(pCtx)).FbDeclared != 0 { + _sqlite3Error(tls, db, _sqlite3MisuseError(tls, int32(162573))) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return _sqlite3MisuseError(tls, int32(162575)) + } + pTab = (*TVtabCtx)(unsafe.Pointer(pCtx)).FpTab + _sqlite3ParseObjectInit(tls, bp, db) + (**(**TParse)(__ccgo_up(bp))).FeParseMode = uint8(PARSE_MODE_DECLARE_VTAB) + libc.SetBitFieldPtr16Uint32(bp+40, libc.Uint32FromInt32(1), 0, 0x1) + /* We should never be able to reach this point while loading the + ** schema. Nevertheless, defend against that (turn off db->init.busy) + ** in case a bug arises. */ + initBusy = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(0) + (**(**TParse)(__ccgo_up(bp))).FnQueryLoop = int16(1) + if SQLITE_OK == _sqlite3RunParser(tls, bp, zCreateTable) { + if !((*TTable)(unsafe.Pointer(pTab)).FaCol != 0) { + pNew = (**(**TParse)(__ccgo_up(bp))).FpNewTable + (*TTable)(unsafe.Pointer(pTab)).FaCol = (*TTable)(unsafe.Pointer(pNew)).FaCol + _sqlite3ExprListDelete(tls, db, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FpDfltList) + v2 = (*TTable)(unsafe.Pointer(pNew)).FnCol + (*TTable)(unsafe.Pointer(pTab)).FnCol = v2 + (*TTable)(unsafe.Pointer(pTab)).FnNVCol = v2 + **(**Tu32)(__ccgo_up(pTab + 48)) |= (*TTable)(unsafe.Pointer(pNew)).FtabFlags & libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid)|libc.Int32FromInt32(TF_NoVisibleRowid)) + (*TTable)(unsafe.Pointer(pNew)).FnCol = 0 + (*TTable)(unsafe.Pointer(pNew)).FaCol = uintptr(0) + if !((*TTable)(unsafe.Pointer(pNew)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer((*TVtabCtx)(unsafe.Pointer(pCtx)).FpVTable)).FpMod)).FpModule)).FxUpdate != uintptr(0) && libc.Int32FromUint16((*TIndex)(unsafe.Pointer(_sqlite3PrimaryKeyIndex(tls, pNew))).FnKeyCol) != int32(1) { + /* WITHOUT ROWID virtual tables must either be read-only (xUpdate==0) + ** or else must have a single-column PRIMARY KEY */ + rc = int32(SQLITE_ERROR) + } + pIdx = (*TTable)(unsafe.Pointer(pNew)).FpIndex + if pIdx != 0 { + (*TTable)(unsafe.Pointer(pTab)).FpIndex = pIdx + (*TTable)(unsafe.Pointer(pNew)).FpIndex = uintptr(0) + (*TIndex)(unsafe.Pointer(pIdx)).FpTable = pTab + } + } + (*TVtabCtx)(unsafe.Pointer(pCtx)).FbDeclared = int32(1) + } else { + if (**(**TParse)(__ccgo_up(bp))).FzErrMsg != 0 { + v3 = __ccgo_ts + 3944 + } else { + v3 = uintptr(0) + } + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_ERROR), v3, libc.VaList(bp+432, (**(**TParse)(__ccgo_up(bp))).FzErrMsg)) + _sqlite3DbFree(tls, db, (**(**TParse)(__ccgo_up(bp))).FzErrMsg) + rc = int32(SQLITE_ERROR) + } + (**(**TParse)(__ccgo_up(bp))).FeParseMode = uint8(PARSE_MODE_NORMAL) + if (**(**TParse)(__ccgo_up(bp))).FpVdbe != 0 { + _sqlite3VdbeFinalize(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe) + } + _sqlite3DeleteTable(tls, db, (**(**TParse)(__ccgo_up(bp))).FpNewTable) + _sqlite3ParseObjectReset(tls, bp) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = libc.Uint8FromInt32(initBusy) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* Convert zSchema to a MemDB and initialize its content. +// */ +func Xsqlite3_deserialize(tls *libc.TLS, db uintptr, zSchema uintptr, pData uintptr, szDb Tsqlite3_int64, szBuf Tsqlite3_int64, mFlags uint32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iDb, rc int32 + var p, pStore, zSql uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _ = iDb, p, pStore, rc, zSql + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if zSchema == uintptr(0) { + zSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName + } + iDb = _sqlite3FindDbName(tls, db, zSchema) + if iDb < int32(2) && iDb != 0 { + rc = int32(SQLITE_ERROR) + goto end_deserialize + } + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+4185, libc.VaList(bp+16, zSchema)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + Xsqlite3_free(tls, zSql) + } + if rc != 0 { + goto end_deserialize + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(iDb) + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(1), 3, 0x8) + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(0), 3, 0x8) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc != SQLITE_OK { + goto end_deserialize + } + p = _memdbFromDbSchema(tls, db, zSchema) + if p == uintptr(0) { + rc = int32(SQLITE_ERROR) + } else { + pStore = (*TMemFile)(unsafe.Pointer(p)).FpStore + (*TMemStore)(unsafe.Pointer(pStore)).FaData = pData + pData = uintptr(0) + (*TMemStore)(unsafe.Pointer(pStore)).Fsz = szDb + (*TMemStore)(unsafe.Pointer(pStore)).FszAlloc = szBuf + (*TMemStore)(unsafe.Pointer(pStore)).FszMax = szBuf + if (*TMemStore)(unsafe.Pointer(pStore)).FszMax < _sqlite3Config.FmxMemdbSize { + (*TMemStore)(unsafe.Pointer(pStore)).FszMax = _sqlite3Config.FmxMemdbSize + } + (*TMemStore)(unsafe.Pointer(pStore)).FmFlags = mFlags + rc = SQLITE_OK + } + goto end_deserialize +end_deserialize: + ; + if pData != 0 && mFlags&uint32(SQLITE_DESERIALIZE_FREEONCLOSE) != uint32(0) { + Xsqlite3_free(tls, pData) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Return the serialization of a database +// */ +func Xsqlite3_serialize(tls *libc.TLS, db uintptr, zSchema uintptr, piSize uintptr, mFlags uint32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iDb, nPage, pgno, rc, szPage, v1 int32 + var p, pBt, pOut, pPager, pStore, pTo, zSql uintptr + var sz Tsqlite3_int64 + var _ /* pPage at bp+8 */ uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iDb, nPage, p, pBt, pOut, pPager, pStore, pTo, pgno, rc, sz, szPage, zSql, v1 + szPage = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if zSchema == uintptr(0) { + zSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName + } + p = _memdbFromDbSchema(tls, db, zSchema) + iDb = _sqlite3FindDbName(tls, db, zSchema) + if piSize != 0 { + **(**Tsqlite3_int64)(__ccgo_up(piSize)) = int64(-int32(1)) + } + if iDb < 0 { + return uintptr(0) + } + if p != 0 { + pStore = (*TMemFile)(unsafe.Pointer(p)).FpStore + if piSize != 0 { + **(**Tsqlite3_int64)(__ccgo_up(piSize)) = (*TMemStore)(unsafe.Pointer(pStore)).Fsz + } + if mFlags&uint32(SQLITE_SERIALIZE_NOCOPY) != 0 { + pOut = (*TMemStore)(unsafe.Pointer(pStore)).FaData + } else { + pOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64((*TMemStore)(unsafe.Pointer(pStore)).Fsz)) + if pOut != 0 { + libc.Xmemcpy(tls, pOut, (*TMemStore)(unsafe.Pointer(pStore)).FaData, libc.Uint64FromInt64((*TMemStore)(unsafe.Pointer(pStore)).Fsz)) + } + } + return pOut + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if pBt == uintptr(0) { + return uintptr(0) + } + szPage = _sqlite3BtreeGetPageSize(tls, pBt) + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+4137, libc.VaList(bp+24, zSchema)) + if zSql != 0 { + v1 = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + } else { + v1 = int32(SQLITE_NOMEM) + } + rc = v1 + Xsqlite3_free(tls, zSql) + if rc != 0 { + return uintptr(0) + } + rc = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + if rc != int32(SQLITE_ROW) { + pOut = uintptr(0) + } else { + sz = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) * int64(szPage) + if sz == 0 { + Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + Xsqlite3_exec(tls, db, __ccgo_ts+4160, uintptr(0), uintptr(0), uintptr(0)) + rc = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == int32(SQLITE_ROW) { + sz = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) * int64(szPage) + } + } + if piSize != 0 { + **(**Tsqlite3_int64)(__ccgo_up(piSize)) = sz + } + if mFlags&uint32(SQLITE_SERIALIZE_NOCOPY) != 0 { + pOut = uintptr(0) + } else { + pOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(sz)) + if pOut != 0 { + nPage = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + pPager = _sqlite3BtreePager(tls, pBt) + pgno = int32(1) + for { + if !(pgno <= nPage) { + break + } + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pTo = pOut + uintptr(int64(szPage)*int64(pgno-libc.Int32FromInt32(1))) + rc = _sqlite3PagerGet(tls, pPager, libc.Uint32FromInt32(pgno), bp+8, 0) + if rc == SQLITE_OK { + libc.Xmemcpy(tls, pTo, _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 8))), libc.Uint64FromInt32(szPage)) + } else { + libc.Xmemset(tls, pTo, 0, libc.Uint64FromInt32(szPage)) + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + goto _2 + _2: + ; + pgno = pgno + 1 + } + } + } + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return pOut +} + +// C documentation +// +// /* +// ** Return meta information about a specific column of a database table. +// ** See comment in sqlite3.h (sqlite.h.in) for details. +// */ +func Xsqlite3_table_column_metadata(tls *libc.TLS, db uintptr, zDbName uintptr, zTableName uintptr, zColumnName uintptr, pzDataType uintptr, pzCollSeq uintptr, pNotNull uintptr, pPrimaryKey uintptr, pAutoinc uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var autoinc, iCol, notnull, primarykey, rc int32 + var pCol, pTab, zCollSeq, zDataType, v1 uintptr + var _ /* zErrMsg at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = autoinc, iCol, notnull, pCol, pTab, primarykey, rc, zCollSeq, zDataType, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pTab = uintptr(0) + pCol = uintptr(0) + iCol = 0 + zDataType = uintptr(0) + zCollSeq = uintptr(0) + notnull = 0 + primarykey = 0 + autoinc = 0 + /* Ensure the database schema has been loaded */ + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3BtreeEnterAll(tls, db) + rc = _sqlite3Init(tls, db, bp) + if SQLITE_OK != rc { + goto error_out + } + /* Locate the table in question */ + pTab = _sqlite3FindTable(tls, db, zTableName, zDbName) + if !(pTab != 0) || libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + pTab = uintptr(0) + goto error_out + } + /* Find the column for which info is requested */ + if zColumnName == uintptr(0) { + /* Query for existence of table only */ + } else { + iCol = _sqlite3ColumnIndex(tls, pTab, zColumnName) + if iCol >= 0 { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + } else { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) && _sqlite3IsRowid(tls, zColumnName) != 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + if iCol >= 0 { + v1 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + } else { + v1 = uintptr(0) + } + pCol = v1 + } else { + pTab = uintptr(0) + goto error_out + } + } + } + /* The following block stores the meta information that will be returned + ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey + ** and autoinc. At this point there are two possibilities: + ** + ** 1. The specified column name was rowid", "oid" or "_rowid_" + ** and there is no explicitly declared IPK column. + ** + ** 2. The table is not a view and the column name identified an + ** explicitly declared column. Copy meta information from *pCol. + */ + if pCol != 0 { + zDataType = _sqlite3ColumnType(tls, pCol, uintptr(0)) + zCollSeq = _sqlite3ColumnColl(tls, pCol) + notnull = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0) + primarykey = libc.BoolInt32(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0) + autoinc = libc.BoolInt32(int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) == iCol && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Autoincrement) != uint32(0)) + } else { + zDataType = __ccgo_ts + 1178 + primarykey = int32(1) + } + if !(zCollSeq != 0) { + zCollSeq = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + goto error_out +error_out: + ; + _sqlite3BtreeLeaveAll(tls, db) + /* Whether the function call succeeded or failed, set the output parameters + ** to whatever their local counterparts contain. If an error did occur, + ** this has the effect of zeroing all output parameters. + */ + if pzDataType != 0 { + **(**uintptr)(__ccgo_up(pzDataType)) = zDataType + } + if pzCollSeq != 0 { + **(**uintptr)(__ccgo_up(pzCollSeq)) = zCollSeq + } + if pNotNull != 0 { + **(**int32)(__ccgo_up(pNotNull)) = notnull + } + if pPrimaryKey != 0 { + **(**int32)(__ccgo_up(pPrimaryKey)) = primarykey + } + if pAutoinc != 0 { + **(**int32)(__ccgo_up(pAutoinc)) = autoinc + } + if SQLITE_OK == rc && !(pTab != 0) { + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = _sqlite3MPrintf(tls, db, __ccgo_ts+26271, libc.VaList(bp+16, zTableName, zColumnName)) + rc = int32(SQLITE_ERROR) + } + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = __ccgo_ts + 3944 + } else { + v1 = uintptr(0) + } + _sqlite3ErrorWithMsg(tls, db, rc, v1, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp)))) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Begin adding a change to a changegroup object. +// */ +func Xsqlite3changegroup_change_begin(tls *libc.TLS, pGrp uintptr, eOp int32, zTab uintptr, bIndirect int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aBuf uintptr + var nReq, rc, v1 int32 + var _ /* pTab at bp+0 */ uintptr + _, _, _, _ = aBuf, nReq, rc, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab != 0 { + rc = int32(SQLITE_MISUSE) + } else { + if eOp != int32(SQLITE_INSERT) && eOp != int32(SQLITE_UPDATE) && eOp != int32(SQLITE_DELETE) { + rc = int32(SQLITE_ERROR) + } else { + rc = _sessionChangesetFindTable(tls, pGrp, zTab, uintptr(0), bp) + } + } + if rc == SQLITE_OK { + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + if pzErr != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+21299, libc.VaList(bp+16, zTab)) + } + rc = int32(SQLITE_ERROR) + } else { + if eOp == int32(SQLITE_UPDATE) { + v1 = int32(2) + } else { + v1 = int32(1) + } + nReq = (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnCol * v1 + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab = **(**uintptr)(__ccgo_up(bp)) + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp = eOp + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FbIndirect = bIndirect + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc < nReq { + aBuf = Xsqlite3_realloc(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf, libc.Int32FromUint64(libc.Uint64FromInt32(nReq)*uint64(16))) + if aBuf == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, aBuf+uintptr((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc)*16, 0, uint64(16)*libc.Uint64FromInt32(nReq-(*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc)) + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf = aBuf + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc = nReq + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Finish any change currently being constructed by the changegroup object. +// */ +func Xsqlite3changegroup_change_finish(tls *libc.TLS, pGrp uintptr, bDiscard int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aBuf, p, v2, v3 uintptr + var eUndef Tu8 + var ii, isPK, nBuf, nZero, v7 int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = aBuf, eUndef, ii, isPK, nBuf, nZero, p, v2, v3, v7 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab != 0 { + aBuf = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf + if bDiscard == 0 { + nBuf = (*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol + eUndef = uint8(SQLITE_NULL) + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_UPDATE) { + ii = 0 + for { + if !(ii < nBuf) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FabPK + uintptr(ii))) != 0 { + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf <= int32(1) { + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf == int32(1) { + v2 = __ccgo_ts + 1690 + } else { + v2 = __ccgo_ts + 36761 + } + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+36771, libc.VaList(bp+16, v2)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } else { + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii+nBuf)*16))).FnBuf > 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+36818, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + } + } else { + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch == 0 && libc.BoolInt32((**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf > 0) != libc.BoolInt32((**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii+nBuf)*16))).FnBuf > 0) { + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf != 0 { + v2 = __ccgo_ts + 1704 + } else { + v2 = __ccgo_ts + 36870 + } + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii+nBuf)*16))).FnBuf != 0 { + v3 = __ccgo_ts + 1704 + } else { + v3 = __ccgo_ts + 36870 + } + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+36873, libc.VaList(bp+16, ii, v2, v3)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + eUndef = uint8(0x00) + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch == 0 { + nBuf = nBuf * int32(2) + } + } else { + ii = 0 + for { + if !(ii < nBuf) { + break + } + isPK = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FabPK + uintptr(ii)))) + if ((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_INSERT) || (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch == 0 || isPK != 0) && (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+36949, libc.VaList(bp+16, ii)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + if (**(**TSessionBuffer)(__ccgo_up(aBuf + uintptr(ii)*16))).FnBuf == int32(1) && isPK != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+36988, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + goto _5 + _5: + ; + ii = ii + 1 + } + } + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FnBuf = 0 + ii = 0 + for { + if !(ii < nBuf) { + break + } + p = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf + uintptr(ii)*16 + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FabPK + uintptr(ii)))) == 0 { + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_UPDATE) { + p = p + uintptr((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol)*16 + } else { + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_DELETE) { + goto _6 + } + } + } + } + if (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf != 0 { + v7 = (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf + } else { + v7 = int32(1) + } + if 0 == _sessionBufferGrow(tls, pGrp+48+32, int64(v7), bp) { + if (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf != 0 { + libc.Xmemcpy(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FaBuf+uintptr((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FnBuf), (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf, libc.Uint64FromInt32((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf)) + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FnBuf += (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf + } else { + v2 = pGrp + 48 + 32 + 8 + v7 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FaBuf + uintptr(v7))) = eUndef + } + } + goto _6 + _6: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionOneChangeToHash(tls, pGrp, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FbIndirect, (*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FaBuf, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FnBuf, 0) + } + } + /* Reset all aBuf[] entries to "undefined". */ + nZero = (*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_UPDATE) { + nZero = nZero + nZero + } + ii = 0 + for { + if !(ii < nZero) { + break + } + (**(**TSessionBuffer)(__ccgo_up((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf + uintptr(ii)*16))).FnBuf = 0 + goto _10 + _10: + ; + ii = ii + 1 + } + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab = uintptr(0) + } + return **(**int32)(__ccgo_up(bp)) +} + +/************** End of sqlite3session.c **************************************/ +/************** Begin file fts5.c ********************************************/ + +/* +** This, the "fts5.c" source file, is a composite file that is itself +** assembled from the following files: +** +** fts5.h +** fts5Int.h +** fts5parse.h <--- Generated from fts5parse.y by Lemon +** fts5parse.c <--- Generated from fts5parse.y by Lemon +** fts5_aux.c +** fts5_buffer.c +** fts5_config.c +** fts5_expr.c +** fts5_hash.c +** fts5_index.c +** fts5_main.c +** fts5_storage.c +** fts5_tokenize.c +** fts5_unicode2.c +** fts5_varint.c +** fts5_vocab.c + */ + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Interfaces to extend FTS5. Using the interfaces defined in this file, +** FTS5 may be extended with: +** +** * custom tokenizers, and +** * custom auxiliary functions. + */ + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** + */ + +/* #include "fts5.h" */ +/* #include "sqlite3ext.h" */ + +/* #include */ +/* #include */ +/* #include */ + +/* +** Constants for the largest and smallest possible 32-bit signed integers. + */ + +/* Truncate very long tokens to this many bytes. Hard limit is +** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset +** field that occurs at the start of each leaf page (see fts5_index.c). */ + +/* +** Maximum number of prefix indexes on single FTS5 table. This must be +** less than 32. If it is set to anything large than that, an #error +** directive in fts5_index.c will cause the build to fail. + */ + +/* +** Maximum segments permitted in a single index + */ + +/* Name of rank and rowid columns */ + +/* +** The assert_nc() macro is similar to the assert() macro, except that it +** is used for assert() conditions that are true only if it can be +** guranteed that the database is not corrupt. + */ + +/* +** A version of memcmp() that does not cause asan errors if one of the pointer +** parameters is NULL and the number of bytes to compare is zero. + */ + +/* Mark a function parameter as unused, to suppress nuisance compiler +** warnings. */ + +// C documentation +// +// /* +// ** Close the RBU handle. +// */ +func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) (r int32) { + var pDb uintptr + var rc, rc2 int32 + _, _, _ = pDb, rc, rc2 + if p != 0 { + /* Commit the transaction to the *-oal file. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+16118, uintptr(0), uintptr(0), p+64) + } + /* Sync the db file if currently doing an incremental checkpoint */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_CKPT) { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})))(tls, pDb, int32(SQLITE_SYNC_NORMAL)) + } + _rbuSaveState(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16118, uintptr(0), uintptr(0), p+64) + } + /* Close any open statement handles. */ + _rbuObjIterFinalize(tls, p+88) + /* If this is an RBU vacuum handle and the vacuum has either finished + ** successfully or encountered an error, delete the contents of the + ** state table. This causes the next call to sqlite3rbu_vacuum() + ** specifying the current target and state databases to start a new + ** vacuum from scratch. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu != 0 { + rc2 = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+34615, uintptr(0), uintptr(0), uintptr(0)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_DONE) && rc2 != SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc2 + } + } + /* Close the open database handle and VFS object. */ + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + _rbuDeleteVfs(tls, p) + Xsqlite3_free(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FaBuf) + Xsqlite3_free(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FaFrame) + _rbuEditErrmsg(tls, p) + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + if pzErrmsg != 0 { + **(**uintptr)(__ccgo_up(pzErrmsg)) = (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + } else { + Xsqlite3_free(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg) + } + Xsqlite3_free(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState) + Xsqlite3_free(tls, p) + } else { + rc = int32(SQLITE_NOMEM) + **(**uintptr)(__ccgo_up(pzErrmsg)) = uintptr(0) + } + return rc +} + +// C documentation +// +// /* +// ** Step the RBU object. +// */ +func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iSector Tu32 + var pDb, pFrame, pIter uintptr + var rc int32 + var _ /* ptr at bp+0 */ uintptr + _, _, _, _, _ = iSector, pDb, pFrame, pIter, rc + if p != 0 { + switch (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage { + case int32(RBU_STAGE_OAL): + pIter = p + 88 + /* If this is an RBU vacuum operation and the state table was empty + ** when this handle was opened, create the target database schema. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress == 0 && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuCreateTargetSchema(tls, p) + _rbuCopyPragma(tls, p, __ccgo_ts+18936) + _rbuCopyPragma(tls, p, __ccgo_ts+18047) + } + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 { + /* Clean up the rbu_tmp_xxx table for the previous table. It + ** cannot be dropped as there are currently active SQL statements. + ** But the contents can be deleted. */ + if libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+34208, libc.VaList(bp+16, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl)) + } + } else { + _rbuObjIterPrepareAll(tls, p, pIter, 0) + /* Advance to the next row to process. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rc = Xsqlite3_step(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect) + if rc == int32(SQLITE_ROW) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress + 1 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep + 1 + return _rbuStep(tls, p) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = 0 + } + } + _rbuObjIterNext(tls, p, pIter) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuSaveState(tls, p, int32(RBU_STAGE_MOVE)) + _rbuIncrSchemaCookie(tls, p) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+16118, uintptr(0), uintptr(0), p+64) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16118, uintptr(0), uintptr(0), p+64) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_MOVE) + } + case int32(RBU_STAGE_MOVE): + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuMoveOalFile(tls, p) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress + 1 + } + case int32(RBU_STAGE_CKPT): + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep >= (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + /* Sync the db file */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})))(tls, pDb, int32(SQLITE_SYNC_NORMAL)) + /* Update nBackfill */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxShmMap})))(tls, pDb, 0, libc.Int32FromInt32(32)*libc.Int32FromInt32(1024), 0, bp) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**Tu32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 24*4)) = (*Tsqlite3rbu)(unsafe.Pointer(p)).FiMaxFrame + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE) + } + } else { + for cond := true; cond; cond = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep < (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame && iSector == ((**(**TRbuFrame)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(p)).FaFrame + uintptr((*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep)*8))).FiDbPage-uint32(1))/libc.Uint32FromInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector) && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pFrame = (*Tsqlite3rbu)(unsafe.Pointer(p)).FaFrame + uintptr((*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep)*8 + iSector = ((*TRbuFrame)(unsafe.Pointer(pFrame)).FiDbPage - uint32(1)) / libc.Uint32FromInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector) + _rbuCheckpointFrame(tls, p, pFrame) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep + 1 + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress = (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress + 1 + } + default: + break + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + } else { + return int32(SQLITE_NOMEM) + } + return r +} + +// C documentation +// +// /* +// ** Open a handle to begin or resume an RBU VACUUM operation. +// */ +func Xsqlite3rbu_vacuum(tls *libc.TLS, zTarget uintptr, zState uintptr) (r uintptr) { + var n Tsize_t + _ = n + if zTarget == uintptr(0) { + return _rbuMisuseError(tls) + } + if zState != 0 { + n = libc.Xstrlen(tls, zState) + if n >= uint64(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+34607, zState+uintptr(n-uint64(7)), uint64(7)) { + return _rbuMisuseError(tls) + } + } + /* TODO: Check that both arguments are non-NULL */ + return _openRbuHandle(tls, uintptr(0), zTarget, zState) +} + +func Xsqlite3session_diff(tls *libc.TLS, pSession uintptr, zFrom uintptr, zTbl uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bHasPk, bMismatch, i, rc int32 + var db, zDb, zDbExists, zExpr, v1 uintptr + var _ /* abPK at bp+32 */ uintptr + var _ /* azCol at bp+40 */ uintptr + var _ /* bRowid at bp+28 */ int32 + var _ /* d at bp+0 */ TSessionDiffCtx + var _ /* nCol at bp+24 */ int32 + var _ /* pDbExists at bp+48 */ uintptr + var _ /* pTo at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _ = bHasPk, bMismatch, db, i, rc, zDb, zDbExists, zExpr, v1 + zDb = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb + rc = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc + libc.Xmemset(tls, bp, 0, uint64(16)) + _sessionDiffHooks(tls, pSession, bp) + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + if rc == SQLITE_OK { + zExpr = uintptr(0) + db = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb /* Table zTbl */ + /* Locate and if necessary initialize the target table object */ + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach + 1 + rc = _sessionFindTable(tls, pSession, zTbl, bp+16) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach - 1 + if **(**uintptr)(__ccgo_up(bp + 16)) == uintptr(0) { + goto diff_out + } + if _sessionInitTable(tls, pSession, **(**uintptr)(__ccgo_up(bp + 16)), (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb) != 0 { + rc = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc + goto diff_out + } + /* Check the table schemas match */ + if rc == SQLITE_OK { + bHasPk = 0 + bMismatch = 0 + **(**int32)(__ccgo_up(bp + 24)) = 0 /* Columns in zFrom.zTbl */ + **(**int32)(__ccgo_up(bp + 28)) = 0 + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + zDbExists = uintptr(0) + /* Check that database zFrom is attached. */ + zDbExists = Xsqlite3_mprintf(tls, __ccgo_ts+35538, libc.VaList(bp+64, zFrom)) + if zDbExists == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) + rc = Xsqlite3_prepare_v2(tls, db, zDbExists, -int32(1), bp+48, uintptr(0)) + if rc == int32(SQLITE_ERROR) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 24)) = -int32(1) + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 48))) + Xsqlite3_free(tls, zDbExists) + } + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp + 24)) == 0 { + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK != 0 { + v1 = bp + 28 + } else { + v1 = uintptr(0) + } + rc = _sessionTableInfo(tls, uintptr(0), db, zFrom, zTbl, bp+24, uintptr(0), uintptr(0), bp+40, uintptr(0), uintptr(0), bp+32, v1) + } + if rc == SQLITE_OK { + if (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FnCol != **(**int32)(__ccgo_up(bp + 24)) { + if **(**int32)(__ccgo_up(bp + 24)) <= 0 { + rc = int32(SQLITE_SCHEMA) + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+35569, libc.VaList(bp+64, zFrom, zTbl)) + } + } else { + bMismatch = int32(1) + } + } else { + i = 0 + for { + if !(i < **(**int32)(__ccgo_up(bp + 24))) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FabPK + uintptr(i)))) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)) + uintptr(i)))) { + bMismatch = int32(1) + } + if Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 40)) + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FazCol + uintptr(i)*8))) != 0 { + bMismatch = int32(1) + } + if **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)) + uintptr(i))) != 0 { + bHasPk = int32(1) + } + goto _2 + _2: + ; + i = i + 1 + } + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 40))) + if bMismatch != 0 { + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+35590, 0) + } + rc = int32(SQLITE_SCHEMA) + } + if bHasPk == 0 { + /* Ignore tables with no primary keys */ + goto diff_out + } + } + if rc == SQLITE_OK { + zExpr = _sessionExprComparePK(tls, (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FnCol, zDb, zFrom, (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FzName, (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FazCol, (*TSessionTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FabPK) + } + /* Find new rows */ + if rc == SQLITE_OK { + rc = _sessionDiffFindNew(tls, int32(SQLITE_INSERT), pSession, **(**uintptr)(__ccgo_up(bp + 16)), zDb, zFrom, zExpr) + } + /* Find old rows */ + if rc == SQLITE_OK { + rc = _sessionDiffFindNew(tls, int32(SQLITE_DELETE), pSession, **(**uintptr)(__ccgo_up(bp + 16)), zFrom, zDb, zExpr) + } + /* Find modified rows */ + if rc == SQLITE_OK { + rc = _sessionDiffFindModified(tls, pSession, **(**uintptr)(__ccgo_up(bp + 16)), zFrom, zExpr) + } + Xsqlite3_free(tls, zExpr) + } + goto diff_out +diff_out: + ; + _sessionPreupdateHooks(tls, pSession) + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + return rc +} + +/* + ** The following array holds FuncDef structures for all of the functions + ** defined in this file. + ** + ** The array cannot be constant since changes are made to the + ** FuncDef.pHash elements at start-time. The elements of this array + ** are read-only after initialization is complete. + ** + ** For peak efficiency, put the most frequently used function last. + */ +var _aBuiltinFunc = [106]TFuncDef{ + 0: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_FUNC_TEST) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_implies_nonnull_row))), + FzName: __ccgo_ts + 16610, + }, + 1: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_FUNC_TEST) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_expr_compare))), + FzName: __ccgo_ts + 16630, + }, + 2: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_FUNC_TEST) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_expr_implies_expr))), + FzName: __ccgo_ts + 16643, + }, + 3: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_FUNC_TEST) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_affinity))), + FzName: __ccgo_ts + 16661, + }, + 4: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16670, + }, + 5: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DIRECTONLY) | libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)), + FzName: __ccgo_ts + 16678, + }, + 6: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DIRECTONLY) | libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)), + FzName: __ccgo_ts + 16678, + }, + 7: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 16693, + }, + 8: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 16719, + }, + 9: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_FUNC_UNLIKELY)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_unlikely))), + FzName: __ccgo_ts + 16744, + }, + 10: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_FUNC_UNLIKELY)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_unlikely))), + FzName: __ccgo_ts + 16753, + }, + 11: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_FUNC_UNLIKELY)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_unlikely))), + FzName: __ccgo_ts + 16764, + }, + 12: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_sqlite_offset))), + FzName: __ccgo_ts + 16771, + }, + 13: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 16785, + }, + 14: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 16785, + }, + 15: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(2))), + FzName: __ccgo_ts + 16791, + }, + 16: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(2))), + FzName: __ccgo_ts + 16791, + }, + 17: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(3))), + FzName: __ccgo_ts + 16797, + }, + 18: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(3))), + FzName: __ccgo_ts + 16797, + }, + 19: { + FnArg: int16(-int32(3)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16802, + }, + 20: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_MINMAX) | libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)), + FzName: __ccgo_ts + 16802, + }, + 21: { + FnArg: int16(-int32(3)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 16806, + }, + 22: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_MINMAX) | libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 16806, + }, + 23: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_TYPEOF)), + FzName: __ccgo_ts + 16810, + }, + 24: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_TYPEOF) | libc.Int32FromInt32(SQLITE_SUBTYPE)), + FzName: __ccgo_ts + 16817, + }, + 25: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_LENGTH)), + FzName: __ccgo_ts + 16825, + }, + 26: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_BYTELEN)), + FzName: __ccgo_ts + 16832, + }, + 27: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16845, + }, + 28: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16851, + }, + 29: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16858, + }, + 30: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16865, + }, + 31: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16873, + }, + 32: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16878, + }, + 33: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16882, + }, + 34: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16882, + }, + 35: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16888, + }, + 36: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16894, + }, + 37: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16900, + }, + 38: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16904, + }, + 39: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16904, + }, + 40: { + FnArg: int16(-int32(3)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16910, + }, + 41: { + FnArg: int16(-int32(4)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16917, + }, + 42: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 16927, + }, + 43: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16934, + }, + 44: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16941, + }, + 45: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16952, + }, + 46: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 16959, + }, + 47: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 16974, + }, + 48: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 16991, + }, + 49: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17002, + }, + 50: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17009, + }, + 51: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17015, + }, + 52: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17028, + }, + 53: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17046, + }, + 54: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17054, + }, + 55: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17068, + }, + 56: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17076, + }, + 57: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17085, + }, + 58: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17085, + }, + 59: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17092, + }, + 60: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17092, + }, + 61: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17102, + }, + 62: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17106, + }, + 63: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17112, + }, + 64: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_COUNT) | libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)), + FzName: __ccgo_ts + 17116, + }, + 65: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)), + FzName: __ccgo_ts + 17116, + }, + 66: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17122, + }, + 67: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17122, + }, + 68: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 17135, + }, + 69: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_LIKE) | libc.Int32FromInt32(SQLITE_FUNC_CASE)), + FpUserData: uintptr(unsafe.Pointer(&_globInfo)), + FzName: __ccgo_ts + 17146, + }, + 70: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_LIKE)), + FpUserData: uintptr(unsafe.Pointer(&_likeInfoNorm)), + FzName: __ccgo_ts + 16605, + }, + 71: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_LIKE)), + FpUserData: uintptr(unsafe.Pointer(&_likeInfoNorm)), + FzName: __ccgo_ts + 16605, + }, + 72: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17151, + }, + 73: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1277, + }, + 74: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1285, + }, + 75: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17156, + }, + 76: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17162, + }, + 77: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17165, + }, + 78: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(1))), + FzName: __ccgo_ts + 17169, + }, + 79: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FpUserData: uintptr(int64(libc.Int32FromInt32(2))), + FzName: __ccgo_ts + 17175, + }, + 80: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17165, + }, + 81: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17180, + }, + 82: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17184, + }, + 83: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17188, + }, + 84: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17194, + }, + 85: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17198, + }, + 86: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17203, + }, + 87: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17208, + }, + 88: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17213, + }, + 89: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17219, + }, + 90: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17223, + }, + 91: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17227, + }, + 92: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17231, + }, + 93: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17236, + }, + 94: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17241, + }, + 95: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17246, + }, + 96: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17252, + }, + 97: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17258, + }, + 98: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17264, + }, + 99: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17269, + }, + 100: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17277, + }, + 101: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 17285, + }, + 102: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL)), + FzName: __ccgo_ts + 17288, + }, + 103: { + FnArg: int16(-int32(4)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FzName: __ccgo_ts + 6961, + }, + 104: { + FnArg: int16(-int32(4)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_iif))), + FzName: __ccgo_ts + 17293, + }, + 105: { + FnArg: int16(-int32(4)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_INLINE) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(0)), + FpUserData: uintptr(int64(libc.Int32FromInt32(INLINEFUNC_iif))), + FzName: __ccgo_ts + 17297, + }, +} + +var _aJsonFunc = [36]TFuncDef{ + 0: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 13694, + }, + 1: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 26899, + }, + 2: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 26905, + }, + 3: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 26916, + }, + 4: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_AINS) | libc.Int32FromInt32(0)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 26928, + }, + 5: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_AINS) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 26946, + }, + 6: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 26965, + }, + 7: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 26965, + }, + 8: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 26983, + }, + 9: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27003, + }, + 10: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27016, + }, + 11: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_JSON) | libc.Int32FromInt32(0)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27030, + }, + 12: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_SQL) | libc.Int32FromInt32(0)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27033, + }, + 13: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27037, + }, + 14: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27049, + }, + 15: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27062, + }, + 16: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27074, + }, + 17: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27087, + }, + 18: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27098, + }, + 19: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27110, + }, + 20: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27110, + }, + 21: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27122, + }, + 22: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27133, + }, + 23: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27145, + }, + 24: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27158, + }, + 25: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(0) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27171, + }, + 26: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_ISSET) | libc.Int32FromInt32(0)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27185, + }, + 27: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_ISSET) | libc.Int32FromInt32(1)*libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27194, + }, + 28: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27204, + }, + 29: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27204, + }, + 30: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27214, + }, + 31: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(1)*libc.Int32FromInt32(SQLITE_FUNC_RUNONLY) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)), + FzName: __ccgo_ts + 27214, + }, + 32: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC)), + FzName: __ccgo_ts + 27225, + }, + 33: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27242, + }, + 34: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC)), + FzName: __ccgo_ts + 27260, + }, + 35: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(0)*libc.Int32FromInt32(SQLITE_FUNC_NEEDCOLL) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC)), + FpUserData: uintptr(int64(libc.Int32FromInt32(JSON_BLOB))), + FzName: __ccgo_ts + 27278, + }, +} + +/* + ** All default VFSes for unix are contained in the following array. + ** + ** Note that the sqlite3_vfs.pNext field of the VFS object is modified + ** by the SQLite core when the VFS is registered. So the following + ** array cannot be const. + */ +var _aVfs = [4]Tsqlite3_vfs{ + 0: { + FiVersion: int32(3), + FszOsFile: int32(120), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4088, + }, + 1: { + FiVersion: int32(3), + FszOsFile: int32(120), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4093, + }, + 2: { + FiVersion: int32(3), + FszOsFile: int32(120), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 4103, + }, + 3: { + FiVersion: int32(3), + FszOsFile: int32(120), + FmxPathname: int32(MAX_PATHNAME), + FzName: __ccgo_ts + 3983, + }, +} + +// C documentation +// +// /* +// ** Internal SQL function: +// ** +// ** sqlite_add_constraint(SQL, CONSTRAINT-TEXT, ICOL) +// ** +// ** SQL is a CREATE TABLE statement. Return a modified version of +// ** SQL that adds CONSTRAINT-TEXT at the end of the ICOL-th column +// ** definition. (The left-most column defintion is 0.) +// */ +func _addConstraintFunc(tls *libc.TLS, ctx uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var db, zCons, zNew, zSql uintptr + var iCol, ii, nTok int32 + var _ /* iOff at bp+0 */ int32 + var _ /* t at bp+4 */ int32 + _, _, _, _, _, _, _ = db, iCol, ii, nTok, zCons, zNew, zSql + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zCons = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + **(**int32)(__ccgo_up(bp)) = 0 + zNew = uintptr(0) + **(**int32)(__ccgo_up(bp + 4)) = 0 + _ = NotUsed + if _skipCreateTable(tls, ctx, zSql, bp) != 0 { + return + } + ii = 0 + for { + if !(ii <= iCol || iCol < 0 && **(**int32)(__ccgo_up(bp + 4)) != int32(TK_RP)) { + break + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + for int32(1) != 0 { + nTok = _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COMMA) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_RP) { + break + } + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_ILLEGAL) { + Xsqlite3_result_error_code(tls, ctx, _sqlite3CorruptError(tls, int32(123095))) + return + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + nTok + } + goto _1 + _1: + ; + ii = ii + 1 + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getWhitespace(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp)))) + db = Xsqlite3_context_db_handle(tls, ctx) + if iCol < 0 { + zNew = _sqlite3MPrintf(tls, db, __ccgo_ts+11885, libc.VaList(bp+16, **(**int32)(__ccgo_up(bp)), zSql, zCons, zSql+uintptr(**(**int32)(__ccgo_up(bp))))) + } else { + zNew = _sqlite3MPrintf(tls, db, __ccgo_ts+11896, libc.VaList(bp+16, **(**int32)(__ccgo_up(bp)), zSql, zCons, zSql+uintptr(**(**int32)(__ccgo_up(bp))))) + } + Xsqlite3_result_text(tls, ctx, zNew, -int32(1), __ccgo_fp(_sqlite3RowSetClear)) +} + +// C documentation +// +// /* +// ** Add a new module argument to pTable->u.vtab.azArg[]. +// ** The string is not copied - the pointer is stored. The +// ** string will be freed automatically when the table is +// ** deleted. +// */ +func _addModuleArgument(tls *libc.TLS, pParse uintptr, pTable uintptr, zArg uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azModuleArg, db, v2 uintptr + var i, v1 int32 + var nBytes Tsqlite3_int64 + _, _, _, _, _, _ = azModuleArg, db, i, nBytes, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + nBytes = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt32(libc.Int32FromInt32(2)+(*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FnArg)) + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FnArg+int32(3) >= **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13956, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTable)).FzName)) + } + azModuleArg = _sqlite3DbRealloc(tls, db, (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FazArg, libc.Uint64FromInt64(nBytes)) + if azModuleArg == uintptr(0) { + _sqlite3DbFree(tls, db, zArg) + } else { + v2 = pTable + 64 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + i = v1 + **(**uintptr)(__ccgo_up(azModuleArg + uintptr(i)*8)) = zArg + **(**uintptr)(__ccgo_up(azModuleArg + uintptr(i+int32(1))*8)) = uintptr(0) + (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FazArg = azModuleArg + } +} + +// C documentation +// +// /* +// ** Allocate and populate an sqlite3_index_info structure. It is the +// ** responsibility of the caller to eventually release the structure +// ** by passing the pointer returned by this function to freeIndexInfo(). +// */ +func _allocateIndexInfo(tls *libc.TLS, pWInfo uintptr, pWC uintptr, mUnusable TBitmask, pSrc uintptr, pmNoOmit uintptr) (r uintptr) { + var bSortByGroup, eDistinct, i, iCol, j, n, nLast, nOrderBy, nTerm, v10 int32 + var mNoOmit, op Tu16 + var p, pE2, pExpr, pExpr1, pHidden, pIdxCons, pIdxInfo, pIdxOrderBy, pOrderBy, pParse, pPk, pTab, pTerm, pUsage, zColl, v3 uintptr + var v12 uint32 + var v7 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bSortByGroup, eDistinct, i, iCol, j, mNoOmit, n, nLast, nOrderBy, nTerm, op, p, pE2, pExpr, pExpr1, pHidden, pIdxCons, pIdxInfo, pIdxOrderBy, pOrderBy, pParse, pPk, pTab, pTerm, pUsage, zColl, v10, v12, v3, v7 + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + mNoOmit = uint16(0) + eDistinct = 0 + pOrderBy = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy + pTab = (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab + /* Find all WHERE clause constraints referring to this virtual table. + ** Mark each term with the TERM_OK flag. Set nTerm to the number of + ** terms found. + */ + p = pWC + nTerm = libc.Int32FromInt32(0) + for { + if !(p != 0) { + break + } + i = 0 + pTerm = (*TWhereClause)(unsafe.Pointer(p)).Fa + for { + if !(i < (*TWhereClause)(unsafe.Pointer(p)).FnTerm) { + break + } + v3 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^libc.Int32FromInt32(TERM_OK)) + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { + goto _2 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&mUnusable != 0 { + goto _2 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & ^libc.Int32FromInt32(WO_EQUIV) == 0 { + goto _2 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VNULL) != 0 { + goto _2 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 && !(_constraintCompatibleWithOuterJoin(tls, pTerm, pSrc) != 0) { + goto _2 + } + nTerm = nTerm + 1 + v3 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(TERM_OK)) + goto _2 + _2: + ; + i = i + 1 + pTerm += 56 + } + goto _1 + _1: + ; + p = (*TWhereClause)(unsafe.Pointer(p)).FpOuter + } + /* If the ORDER BY clause contains only columns in the current + ** virtual table then allocate space for the aOrderBy part of + ** the sqlite3_index_info structure. + */ + nOrderBy = 0 + if pOrderBy != 0 { + n = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr + i = 0 + for { + if !(i < n) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).FpExpr + /* Skip over constant terms in the ORDER BY clause */ + if _sqlite3ExprIsConstant(tls, uintptr(0), pExpr) != 0 { + goto _5 + } + /* Virtual tables are unable to deal with NULLS FIRST */ + if libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_BIGNULL) != 0 { + break + } + /* First case - a direct column references without a COLLATE operator */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { + goto _5 + } + /* 2nd case - a column reference with a COLLATE operator. Only match + ** of the COLLATE operator matches the collation of the column. */ + if v7 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE); v7 { + v3 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pE2 = v3 + } + if v7 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(v3)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pE2)).FiTable == (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { /* The collating sequence name */ + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = (*TExpr)(unsafe.Pointer(pE2)).FiColumn + if int32((*TExpr)(unsafe.Pointer(pE2)).FiColumn) < 0 { + goto _5 + } /* Collseq does not matter for rowid */ + zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr((*TExpr)(unsafe.Pointer(pE2)).FiColumn)*16) + if zColl == uintptr(0) { + zColl = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), zColl) == 0 { + goto _5 + } + } + /* No matches cause a break out of the loop */ + break + goto _5 + _5: + ; + i = i + 1 + } + if i == n { + bSortByGroup = libc.BoolInt32(libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_SORTBYGROUP) != 0) + nOrderBy = n + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DISTINCTBY) != 0 && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x8000>>15) != 0) { + eDistinct = int32(2) + bSortByGroup + } else { + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_GROUPBY) != 0 { + eDistinct = int32(1) - bSortByGroup + } else { + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 { + eDistinct = int32(3) + } + } + } + } + } + /* Allocate the sqlite3_index_info structure + */ + pIdxInfo = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(96)+(libc.Uint64FromInt64(12)+libc.Uint64FromInt64(8))*libc.Uint64FromInt32(nTerm)+uint64(8)*libc.Uint64FromInt32(nOrderBy)+(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(nTerm)*uint64(8)))) + if pIdxInfo == uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1674, 0) + return uintptr(0) + } + pHidden = pIdxInfo + 1*96 + pIdxCons = pHidden + 32 + uintptr(nTerm)*8 + pIdxOrderBy = pIdxCons + uintptr(nTerm)*12 + pUsage = pIdxOrderBy + uintptr(nOrderBy)*8 + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint = pIdxCons + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy = pIdxOrderBy + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage = pUsage + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FcolUsed = libc.Uint64FromInt64(libc.Int64FromUint64((*TSrcItem)(unsafe.Pointer(pSrc)).FcolUsed)) + if libc.BoolInt32((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0)) == 0 { + /* Ensure that all bits associated with PK columns are set. This is to + ** ensure they are available for cases like RIGHT joins or OR loops. */ + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + iCol = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))) + if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + iCol = libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1) + } + **(**Tsqlite3_uint64)(__ccgo_up(pIdxInfo + 88)) |= libc.Uint64FromInt32(1) << iCol + goto _8 + _8: + ; + i = i + 1 + } + } + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FpWC = pWC + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FpParse = pParse + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FeDistinct = eDistinct + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FmIn = uint32(0) + p = pWC + v10 = libc.Int32FromInt32(0) + j = v10 + i = v10 + for { + if !(p != 0) { + break + } + nLast = i + (*TWhereClause)(unsafe.Pointer(p)).FnTerm + pTerm = (*TWhereClause)(unsafe.Pointer(p)).Fa + for { + if !(i < nLast) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_OK) == 0 { + goto _11 + } + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).FiColumn = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).FiTermOffset = i + op = libc.Uint16FromInt32(libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & int32(WO_ALL)) + if libc.Int32FromUint16(op) == int32(WO_IN) { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_SLICE) == 0 { + if j <= int32(31) { + v12 = libc.Uint32FromInt32(1) << j + } else { + v12 = uint32(0) + } + **(**Tu32)(__ccgo_up(pHidden + 20)) |= v12 + } + op = uint16(WO_EQ) + } + if libc.Int32FromUint16(op) == int32(WO_AUX) { + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).Fop = (*TWhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp + } else { + if libc.Int32FromUint16(op)&(libc.Int32FromInt32(WO_ISNULL)|libc.Int32FromInt32(WO_IS)) != 0 { + if libc.Int32FromUint16(op) == int32(WO_ISNULL) { + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).Fop = uint8(SQLITE_INDEX_CONSTRAINT_ISNULL) + } else { + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).Fop = uint8(SQLITE_INDEX_CONSTRAINT_IS) + } + } else { + (**(**Tsqlite3_index_constraint)(__ccgo_up(pIdxCons + uintptr(j)*12))).Fop = uint8(op) + /* The direct assignment in the previous line is possible only because + ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The + ** following asserts verify this fact. */ + if libc.Int32FromUint16(op)&(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) != 0 && _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight) != 0 { + if j < int32(16) { + mNoOmit = libc.Uint16FromInt32(int32(mNoOmit) | libc.Int32FromInt32(1)<= (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo != uintptr(0) { + break + } /* Resolved by outer context */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + /* If we reach this point, it means that expression pExpr can be + ** translated into a reference to an index column as described by + ** pIEpr. + */ + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_AGG_COLUMN) + (**(**TExpr)(__ccgo_up(bp))).FiTable = (*TIndexedExpr)(unsafe.Pointer(pIEpr)).FiIdxCur + (**(**TExpr)(__ccgo_up(bp))).FiColumn = int16((*TIndexedExpr)(unsafe.Pointer(pIEpr)).FiIdxCol) + _findOrCreateAggInfoColumn(tls, pParse, pAggInfo, bp) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((**(**TExpr)(__ccgo_up(bp))).FiAgg)*32))).FpCExpr = pExpr + (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo + (*TExpr)(unsafe.Pointer(pExpr)).FiAgg = (**(**TExpr)(__ccgo_up(bp))).FiAgg + return int32(WRC_Prune) + case int32(TK_IF_NULL_ROW): + fallthrough + case int32(TK_AGG_COLUMN): + fallthrough + case int32(TK_COLUMN): + /* Check to see if the column is in one of the tables in the FROM + ** clause of the aggregate query */ + if pSrcList != uintptr(0) { + pItem = pSrcList + 8 + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc) { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor { + _findOrCreateAggInfoColumn(tls, pParse, pAggInfo, pExpr) + break + } /* endif pExpr->iTable==pItem->iCursor */ + goto _3 + _3: + ; + i = i + 1 + pItem += 80 + } /* end loop over pSrcList */ + } + return WRC_Continue + case int32(TK_AGG_FUNCTION): + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_InAggFunc) == 0 && (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth == libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) && (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) { + /* Check to see if pExpr is a duplicate of another aggregate + ** function that is already in the pAggInfo structure + */ + pItem1 = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + mxTerm = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 2*4)) + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + if (*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFExpr == pExpr { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), (*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFExpr, pExpr, -int32(1)) == 0 { + break + } + goto _4 + _4: + ; + i = i + 1 + pItem1 += 32 + } + if i > mxTerm { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8614, libc.VaList(bp+80, mxTerm)) + i = mxTerm + } else { + if i >= (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc { + /* pExpr is original. Make a new entry in pAggInfo->aFunc[] + */ + enc = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc + i = _addAggInfoFunc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pAggInfo) + if i >= 0 { + pItem1 = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32 + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFExpr = pExpr + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != 0 { + v5 = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + } else { + v5 = 0 + } + nArg = v5 + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFunc = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(pExpr + 8)), nArg, enc, uint8(0)) + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 && (*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFunc)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) == uint32(0) { + v7 = pParse + 56 + v5 = *(*int32)(unsafe.Pointer(v7)) + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FiOBTab = v5 + pOBList = *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32)) + if (*TExprList)(unsafe.Pointer(pOBList)).FnExpr == int32(1) && nArg == int32(1) && _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pOBList + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr, 0) == 0 { + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FbOBPayload = uint8(0) + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FbOBUnique = libc.BoolUint8((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)) != libc.Uint32FromInt32(0)) + } else { + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FbOBPayload = uint8(1) + } + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FbUseSubtype = libc.BoolUint8((*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pItem1)).FpFunc)).FfuncFlags&uint32(SQLITE_SUBTYPE) != uint32(0)) + } else { + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FiOBTab = -int32(1) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)) != uint32(0) && !((*TAggInfo_func)(unsafe.Pointer(pItem1)).FbOBUnique != 0) { + v7 = pParse + 56 + v5 = *(*int32)(unsafe.Pointer(v7)) + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FiDistinct = v5 + } else { + (*TAggInfo_func)(unsafe.Pointer(pItem1)).FiDistinct = -int32(1) + } + } + } + } + /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry + */ + (*TExpr)(unsafe.Pointer(pExpr)).FiAgg = int16(i) + (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo + return int32(WRC_Prune) + } else { + return WRC_Continue + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Generate code to do an analysis of all indices associated with +// ** a single table. +// */ +func _analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintptr, iStatCur int32, iMem int32, iTab int32) { + var aGotoChng, db, pColl, pIdx, pPk, pStat1, pX, v, zIdxName uintptr + var addrGotoEnd, addrIsNull, addrNext, addrNextRow, doOnce, endDistinctTest, i, iDb, iIdxCur, iTabCur, j, j1, j2, j3, jZeroRows, k, mxCol, nCol, nColTest, nColX, regChng, regCol, regDLt, regEq, regIdxname, regKey, regLt, regNewRowid, regPrev, regRowid, regSample, regSampleRowid, regStat, regStat1, regTabname, regTemp, regTemp2, v1, v2, v3, v4, v5, v6, v7, v8, v9 int32 + var needTableCnt, seekOp Tu8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aGotoChng, addrGotoEnd, addrIsNull, addrNext, addrNextRow, db, doOnce, endDistinctTest, i, iDb, iIdxCur, iTabCur, j, j1, j2, j3, jZeroRows, k, mxCol, nCol, nColTest, nColX, needTableCnt, pColl, pIdx, pPk, pStat1, pX, regChng, regCol, regDLt, regEq, regIdxname, regKey, regLt, regNewRowid, regPrev, regRowid, regSample, regSampleRowid, regStat, regStat1, regTabname, regTemp, regTemp2, seekOp, v, zIdxName, v1, v2, v3, v4, v5, v6, v7, v8, v9 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Loop counter */ + jZeroRows = -int32(1) /* Index of database containing pTab */ + needTableCnt = uint8(1) + v1 = iMem + iMem = iMem + 1 /* True to count the table */ + regNewRowid = v1 + v2 = iMem + iMem = iMem + 1 /* Rowid for the inserted record */ + regStat = v2 + v3 = iMem + iMem = iMem + 1 /* Register to hold StatAccum object */ + regChng = v3 + v4 = iMem + iMem = iMem + 1 /* Index of changed index field */ + regRowid = v4 + v5 = iMem + iMem = iMem + 1 /* Rowid argument passed to stat_push() */ + regTemp = v5 + v6 = iMem + iMem = iMem + 1 /* Temporary use register */ + regTemp2 = v6 + v7 = iMem + iMem = iMem + 1 /* Second temporary use register */ + regTabname = v7 + v8 = iMem + iMem = iMem + 1 /* Register containing table name */ + regIdxname = v8 + v9 = iMem + iMem = iMem + 1 /* Register containing index name */ + regStat1 = v9 /* Value for the stat column of sqlite_stat1 */ + regPrev = iMem /* MUST BE LAST (see below) */ + doOnce = int32(1) /* Flag for a one-time computation */ + pStat1 = uintptr(0) + _sqlite3TouchRegister(tls, pParse, iMem) + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) || pTab == uintptr(0) { + return + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + /* Do not gather statistics on views or virtual tables */ + return + } + if Xsqlite3_strlike(tls, __ccgo_ts+13030, (*TTable)(unsafe.Pointer(pTab)).FzName, uint32('\\')) == 0 { + /* Do not gather statistics on system tables */ + return + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ANALYZE), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) != 0 { + return + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 { + pStat1 = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt64(120)+libc.Uint64FromInt32(13))) + if pStat1 == uintptr(0) { + return + } + (*TTable)(unsafe.Pointer(pStat1)).FzName = pStat1 + 1*120 + libc.Xmemcpy(tls, (*TTable)(unsafe.Pointer(pStat1)).FzName, __ccgo_ts+12833, uint64(13)) + (*TTable)(unsafe.Pointer(pStat1)).FnCol = int16(3) + (*TTable)(unsafe.Pointer(pStat1)).FiPKey = int16(-int32(1)) + _sqlite3VdbeAddOp4(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Noop), 0, 0, 0, pStat1, -int32(7)) + } + /* Establish a read-lock on the table at the shared-cache level. + ** Open a read-only cursor on the table. Also allocate a cursor number + ** to use for scanning indexes (iIdxCur). No index cursor is opened at + ** this time though. */ + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab)).FzName) + v1 = iTab + iTab = iTab + 1 + iTabCur = v1 + v1 = iTab + iTab = iTab + 1 + iIdxCur = v1 + if (*TParse)(unsafe.Pointer(pParse)).FnTab > iTab { + v1 = (*TParse)(unsafe.Pointer(pParse)).FnTab + } else { + v1 = iTab + } + (*TParse)(unsafe.Pointer(pParse)).FnTab = v1 + _sqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab, int32(OP_OpenRead)) + _sqlite3VdbeLoadString(tls, v, regTabname, (*TTable)(unsafe.Pointer(pTab)).FzName) + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } /* Number of columns to test for changes */ + if pOnlyIdx != 0 && pOnlyIdx != pIdx { + goto _13 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) { + needTableCnt = uint8(0) + } + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + nCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + zIdxName = (*TTable)(unsafe.Pointer(pTab)).FzName + nColTest = nCol - int32(1) + } else { + nCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + zIdxName = (*TIndex)(unsafe.Pointer(pIdx)).FzName + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x8>>3)) != 0 { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) - int32(1) + } else { + v1 = nCol - int32(1) + } + nColTest = v1 + } + /* Populate the register containing the index name. */ + _sqlite3VdbeLoadString(tls, v, regIdxname, zIdxName) + /* + ** Pseudo-code for loop that calls stat_push(): + ** + ** regChng = 0 + ** Rewind csr + ** if eof(csr){ + ** stat_init() with count = 0; + ** goto end_of_scan; + ** } + ** count() + ** stat_init() + ** goto chng_addr_0; + ** + ** next_row: + ** regChng = 0 + ** if( idx(0) != regPrev(0) ) goto chng_addr_0 + ** regChng = 1 + ** if( idx(1) != regPrev(1) ) goto chng_addr_1 + ** ... + ** regChng = N + ** goto chng_addr_N + ** + ** chng_addr_0: + ** regPrev(0) = idx(0) + ** chng_addr_1: + ** regPrev(1) = idx(1) + ** ... + ** + ** endDistinctTest: + ** regRowid = idx(rowid) + ** stat_push(P, regChng, regRowid) + ** Next csr + ** if !eof(csr) goto next_row; + ** + ** end_of_scan: + */ + /* Make sure there are enough memory cells allocated to accommodate + ** the regPrev array and a trailing rowid (the rowid slot is required + ** when building a record to insert into the sample column of + ** the sqlite_stat4 table. */ + _sqlite3TouchRegister(tls, pParse, regPrev+nColTest) + /* Open a read-only cursor on the index being analyzed. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), iIdxCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) + /* Implementation of the following: + ** + ** regChng = 0 + ** Rewind csr + ** if eof(csr){ + ** stat_init() with count = 0; + ** goto end_of_scan; + ** } + ** count() + ** stat_init() + ** goto chng_addr_0; + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit, regTemp2) + /* Arguments to stat_init(): + ** (1) the number of columns in the index including the rowid + ** (or for a WITHOUT ROWID table, the number of PK columns), + ** (2) the number of columns in the key without the rowid/pk + ** (3) estimated number of rows in the index. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), nCol, regStat+int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol), regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Count), iIdxCur, regTemp, libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) != uint32(0))) + _sqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat+int32(1), regStat, int32(4), uintptr(unsafe.Pointer(&_statInitFuncdef)), 0) + addrGotoEnd = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iIdxCur) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regChng) + addrNextRow = _sqlite3VdbeCurrentAddr(tls, v) + if nColTest > 0 { + endDistinctTest = _sqlite3VdbeMakeLabel(tls, pParse) /* Array of jump instruction addresses */ + aGotoChng = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(nColTest))) + if aGotoChng == uintptr(0) { + goto _13 + } + /* + ** next_row: + ** regChng = 0 + ** if( idx(0) != regPrev(0) ) goto chng_addr_0 + ** regChng = 1 + ** if( idx(1) != regPrev(1) ) goto chng_addr_1 + ** ... + ** regChng = N + ** goto endDistinctTest + */ + _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + addrNextRow = _sqlite3VdbeCurrentAddr(tls, v) + if nColTest == int32(1) && libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) == int32(1) && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != OE_None { + /* For a single-column UNIQUE index, once we have found a non-NULL + ** row, we know that all the rest will be distinct, so skip + ** subsequent distinctness tests. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), regPrev, endDistinctTest) + } + i = 0 + for { + if !(i < nColTest) { + break + } + pColl = _sqlite3LocateCollSeq(tls, pParse, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*8))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), i, regChng) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, i, regTemp) + **(**int32)(__ccgo_up(aGotoChng + uintptr(i)*4)) = _sqlite3VdbeAddOp4(tls, v, int32(OP_Ne), regTemp, 0, regPrev+i, pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NULLEQ)) + goto _15 + _15: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), nColTest, regChng) + _sqlite3VdbeGoto(tls, v, endDistinctTest) + /* + ** chng_addr_0: + ** regPrev(0) = idx(0) + ** chng_addr_1: + ** regPrev(1) = idx(1) + ** ... + */ + _sqlite3VdbeJumpHere(tls, v, addrNextRow-int32(1)) + i = 0 + for { + if !(i < nColTest) { + break + } + _sqlite3VdbeJumpHere(tls, v, **(**int32)(__ccgo_up(aGotoChng + uintptr(i)*4))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, i, regPrev+i) + goto _16 + _16: + ; + i = i + 1 + } + _sqlite3VdbeResolveLabel(tls, v, endDistinctTest) + _sqlite3DbFree(tls, db, aGotoChng) + } + /* + ** chng_addr_N: + ** regRowid = idx(rowid) // STAT4 only + ** stat_push(P, regChng, regRowid) // 3rd parameter STAT4 only + ** Next csr + ** if !eof(csr) goto next_row; + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), iIdxCur, regRowid) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpTable) + regKey = _sqlite3GetTempRange(tls, pParse, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + k = _sqlite3TableColumnToIndex(tls, pIdx, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, k, regKey+j) + goto _17 + _17: + ; + j = j + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regKey, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol), regRowid) + _sqlite3ReleaseTempRange(tls, pParse, regKey, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + } + } + _sqlite3VdbeAddFunctionCall(tls, pParse, int32(1), regStat, regTemp, libc.Int32FromInt32(2)+libc.Int32FromInt32(IsStat4), uintptr(unsafe.Pointer(&_statPushFuncdef)), 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit != 0 { + j1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), regTemp) + j2 = _sqlite3VdbeAddOp1(tls, v, int32(OP_If), regTemp) + j3 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_SeekGT), iIdxCur, 0, regPrev, int32(1)) + _sqlite3VdbeJumpHere(tls, v, j1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iIdxCur, addrNextRow) + _sqlite3VdbeJumpHere(tls, v, j2) + _sqlite3VdbeJumpHere(tls, v, j3) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iIdxCur, addrNextRow) + } + /* Add the entry to the stat1 table. */ + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + /* Partial indexes might get a zero-entry in sqlite_stat1. But + ** an empty table is omitted from sqlite_stat1. */ + _sqlite3VdbeJumpHere(tls, v, addrGotoEnd) + addrGotoEnd = 0 + } + _callStatGet(tls, pParse, regStat, STAT_GET_STAT1, regStat1) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), regTabname, int32(3), regTemp, __ccgo_ts+13040, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iStatCur, regNewRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iStatCur, regTemp, regNewRowid) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pStat1, -int32(5)) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + /* Add the entries to the stat4 table. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) && (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit == 0 { + regEq = regStat1 + regLt = regStat1 + int32(1) + regDLt = regStat1 + int32(2) + regSample = regStat1 + int32(3) + regCol = regStat1 + int32(4) + regSampleRowid = regCol + nCol + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v1 = int32(OP_NotExists) + } else { + v1 = int32(OP_NotFound) + } + seekOp = libc.Uint8FromInt32(v1) + /* No STAT4 data is generated if the number of rows is zero */ + if addrGotoEnd == 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Cast), regStat1, int32(SQLITE_AFF_INTEGER)) + addrGotoEnd = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), regStat1) + } + if doOnce != 0 { + mxCol = nCol + /* Compute the maximum number of columns in any index */ + pX = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pX != 0) { + break + } /* Number of columns in pX */ + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pX + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + nColX = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pX)).FnKeyCol) + } else { + nColX = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pX)).FnColumn) + } + if nColX > mxCol { + mxCol = nColX + } + goto _19 + _19: + ; + pX = (*TIndex)(unsafe.Pointer(pX)).FpNext + } + /* Allocate space to compute results for the largest index */ + _sqlite3TouchRegister(tls, pParse, regCol+mxCol) + doOnce = 0 + _sqlite3ClearTempRegCache(tls, pParse) /* tag-20230325-1 */ + } + addrNext = _sqlite3VdbeCurrentAddr(tls, v) + _callStatGet(tls, pParse, regStat, int32(STAT_GET_ROWID), regSampleRowid) + addrIsNull = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), regSampleRowid) + _callStatGet(tls, pParse, regStat, int32(STAT_GET_NEQ), regEq) + _callStatGet(tls, pParse, regStat, int32(STAT_GET_NLT), regLt) + _callStatGet(tls, pParse, regStat, int32(STAT_GET_NDLT), regDLt) + _sqlite3VdbeAddOp4Int(tls, v, libc.Int32FromUint8(seekOp), iTabCur, addrNext, regSampleRowid, 0) + i = 0 + for { + if !(i < nCol) { + break + } + _sqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iTabCur, i, regCol+i) + goto _20 + _20: + ; + i = i + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regCol, nCol, regSample) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regTabname, int32(6), regTemp) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iStatCur+int32(1), regNewRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iStatCur+int32(1), regTemp, regNewRowid) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), int32(1), addrNext) /* P1==1 for end-of-loop */ + _sqlite3VdbeJumpHere(tls, v, addrIsNull) + } + /* End of analysis */ + if addrGotoEnd != 0 { + _sqlite3VdbeJumpHere(tls, v, addrGotoEnd) + } + goto _13 + _13: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + /* Create a single sqlite_stat1 entry containing NULL as the index + ** name and the row count as the content. + */ + if pOnlyIdx == uintptr(0) && needTableCnt != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Count), iTabCur, regStat1) + jZeroRows = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), regStat1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regIdxname) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), regTabname, int32(3), regTemp, __ccgo_ts+13040, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iStatCur, regNewRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iStatCur, regTemp, regNewRowid) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pStat1, -int32(5)) + _sqlite3VdbeJumpHere(tls, v, jZeroRows) + } +} + +// C documentation +// +// /* +// ** Generate code that will do an analysis of a single table in +// ** a database. If pOnlyIdx is not NULL then it is a single index +// ** in pTab that should be analyzed. +// */ +func _analyzeTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintptr) { + var iDb, iStatCur int32 + _, _ = iDb, iStatCur + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + iStatCur = (*TParse)(unsafe.Pointer(pParse)).FnTab + **(**int32)(__ccgo_up(pParse + 56)) += int32(3) + if pOnlyIdx != 0 { + _openStatTable(tls, pParse, iDb, iStatCur, (*TIndex)(unsafe.Pointer(pOnlyIdx)).FzName, __ccgo_ts+13044) + } else { + _openStatTable(tls, pParse, iDb, iStatCur, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+13048) + } + _analyzeOneTable(tls, pParse, pTab, pOnlyIdx, iStatCur, (*TParse)(unsafe.Pointer(pParse)).FnMem+int32(1), (*TParse)(unsafe.Pointer(pParse)).FnTab) + _loadAnalysis(tls, pParse, iDb) +} + +// C documentation +// +// /* +// ** An SQL user-function registered to do the work of an ATTACH statement. The +// ** three arguments to the function come directly from an attach statement: +// ** +// ** ATTACH DATABASE x AS y KEY z +// ** +// ** SELECT sqlite_attach(x, y, z) +// ** +// ** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the +// ** third argument. +// ** +// ** If the db->init.reopenMemdb flags is set, then instead of attaching a +// ** new database, close the database on db->init.iDb and reopen it as an +// ** empty MemDB. +// */ +func _attachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var aNew, db, pNew, pNewSchema, pPager, zFile, zName uintptr + var i, iDb, rc int32 + var _ /* flags at bp+16 */ uint32 + var _ /* pNewBt at bp+40 */ uintptr + var _ /* pVfs at bp+32 */ uintptr + var _ /* zErr at bp+8 */ uintptr + var _ /* zErrDyn at bp+24 */ uintptr + var _ /* zPath at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aNew, db, i, iDb, pNew, pNewSchema, pPager, rc, zFile, zName + rc = 0 + db = Xsqlite3_context_db_handle(tls, context) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* New array of Db pointers */ + pNew = uintptr(0) /* Db object for the newly attached database */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + _ = NotUsed + zFile = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zName = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zFile == uintptr(0) { + zFile = __ccgo_ts + 1704 + } + if zName == uintptr(0) { + zName = __ccgo_ts + 1704 + } + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x8>>3)) != 0 { + /* This is not a real ATTACH. Instead, this routine is being called + ** from sqlite3_deserialize() to close database db->init.iDb and + ** reopen it as a MemDB */ + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + pNew = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb)*32 + if _sqlite3BtreeTxnState(tls, (*TDb)(unsafe.Pointer(pNew)).FpBt) != SQLITE_TXN_NONE || _sqlite3BtreeIsInBackup(tls, (*TDb)(unsafe.Pointer(pNew)).FpBt) != 0 { + rc = int32(SQLITE_BUSY) + goto attach_error + } + **(**uintptr)(__ccgo_up(bp + 32)) = Xsqlite3_vfs_find(tls, __ccgo_ts+4116) + if **(**uintptr)(__ccgo_up(bp + 32)) == uintptr(0) { + return + } + rc = _sqlite3BtreeOpen(tls, **(**uintptr)(__ccgo_up(bp + 32)), __ccgo_ts+13247, db, bp+40, 0, int32(SQLITE_OPEN_MAIN_DB)) + if rc == SQLITE_OK { + pNewSchema = _sqlite3SchemaGet(tls, db, **(**uintptr)(__ccgo_up(bp + 40))) + if pNewSchema != 0 { + /* Both the Btree and the new Schema were allocated successfully. + ** Close the old db and update the aDb[] slot with the new memdb + ** values. */ + _sqlite3BtreeClose(tls, (*TDb)(unsafe.Pointer(pNew)).FpBt) + (*TDb)(unsafe.Pointer(pNew)).FpBt = **(**uintptr)(__ccgo_up(bp + 40)) + (*TDb)(unsafe.Pointer(pNew)).FpSchema = pNewSchema + } else { + _sqlite3BtreeClose(tls, **(**uintptr)(__ccgo_up(bp + 40))) + rc = int32(SQLITE_NOMEM) + } + } + if rc != 0 { + goto attach_error + } + } else { + /* This is a real ATTACH + ** + ** Check for the following errors: + ** + ** * Too many attached databases, + ** * Transaction currently open + ** * Specified database name already being used. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnDb >= **(**int32)(__ccgo_up(db + 136 + 7*4))+int32(2) { + **(**uintptr)(__ccgo_up(bp + 24)) = _sqlite3MPrintf(tls, db, __ccgo_ts+13250, libc.VaList(bp+56, **(**int32)(__ccgo_up(db + 136 + 7*4)))) + goto attach_error + } + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if _sqlite3DbIsNamed(tls, db, i, zName) != 0 { + **(**uintptr)(__ccgo_up(bp + 24)) = _sqlite3MPrintf(tls, db, __ccgo_ts+13287, libc.VaList(bp+56, zName)) + goto attach_error + } + goto _1 + _1: + ; + i = i + 1 + } + /* Allocate the new entry in the db->aDb[] array and initialize the schema + ** hash tables. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FaDb == db+696 { + aNew = _sqlite3DbMallocRawNN(tls, db, uint64(libc.Uint64FromInt64(32)*libc.Uint64FromInt32(3))) + if aNew == uintptr(0) { + return + } + libc.Xmemcpy(tls, aNew, (*Tsqlite3)(unsafe.Pointer(db)).FaDb, libc.Uint64FromInt64(32)*libc.Uint64FromInt32(2)) + } else { + aNew = _sqlite3DbRealloc(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaDb, uint64(32)*libc.Uint64FromInt64(libc.Int64FromInt32(1)+int64((*Tsqlite3)(unsafe.Pointer(db)).FnDb))) + if aNew == uintptr(0) { + return + } + } + (*Tsqlite3)(unsafe.Pointer(db)).FaDb = aNew + pNew = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Tsqlite3)(unsafe.Pointer(db)).FnDb)*32 + libc.Xmemset(tls, pNew, 0, uint64(32)) + /* Open the database file. If the btree is successfully opened, use + ** it to obtain the database schema. At this point the schema may + ** or may not be initialized. + */ + **(**uint32)(__ccgo_up(bp + 16)) = (*Tsqlite3)(unsafe.Pointer(db)).FopenFlags + rc = _sqlite3ParseUri(tls, (*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpVfs)).FzName, zFile, bp+16, bp+32, bp, bp+8) + if rc != SQLITE_OK { + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + Xsqlite3_result_error(tls, context, **(**uintptr)(__ccgo_up(bp + 8)), -int32(1)) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00020))<aDb[] array. i.e. put everything back the + ** way we found it. + */ + if rc == SQLITE_OK { + _sqlite3BtreeEnterAll(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_SchemaKnownOk)) + if !(int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x8>>3)) != 0) { + rc = _sqlite3Init(tls, db, bp+24) + } + _sqlite3BtreeLeaveAll(tls, db) + } + if rc != 0 { + if !(int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x8>>3)) != 0) { + iDb = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt != 0 { + _sqlite3BtreeClose(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt) + (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt = uintptr(0) + (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema = uintptr(0) + } + _sqlite3ResetAllSchemasOfConnection(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).FnDb = iDb + if rc == int32(SQLITE_NOMEM) || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)< int32(4) { + (*TVdbe)(unsafe.Pointer(v)).Fpc = int32(4) + rc = _sqlite3VdbeExec(tls, v) + } else { + rc = Xsqlite3_step(tls, (*TIncrblob)(unsafe.Pointer(p)).FpStmt) + } + if rc == int32(SQLITE_ROW) { + pC = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(v)).FapCsr)) + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) > libc.Int32FromUint16((*TIncrblob)(unsafe.Pointer(p)).FiCol) { + v1 = *(*Tu32)(unsafe.Pointer(pC + 120 + uintptr((*TIncrblob)(unsafe.Pointer(p)).FiCol)*4)) + } else { + v1 = uint32(0) + } + type1 = v1 + if type1 < uint32(12) { + if type1 == uint32(0) { + v2 = __ccgo_ts + 1690 + } else { + if type1 == uint32(7) { + v3 = __ccgo_ts + 6487 + } else { + v3 = __ccgo_ts + 6492 + } + v2 = v3 + } + zErr = _sqlite3MPrintf(tls, (*TIncrblob)(unsafe.Pointer(p)).Fdb, __ccgo_ts+6500, libc.VaList(bp+8, v2)) + rc = int32(SQLITE_ERROR) + Xsqlite3_finalize(tls, (*TIncrblob)(unsafe.Pointer(p)).FpStmt) + (*TIncrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) + } else { + (*TIncrblob)(unsafe.Pointer(p)).FiOffset = libc.Int32FromUint32(*(*Tu32)(unsafe.Pointer(pC + 120 + uintptr(libc.Int32FromUint16((*TIncrblob)(unsafe.Pointer(p)).FiCol)+int32((*TVdbeCursor)(unsafe.Pointer(pC)).FnField))*4))) + (*TIncrblob)(unsafe.Pointer(p)).FnByte = libc.Int32FromUint32(_sqlite3VdbeSerialTypeLen(tls, type1)) + (*TIncrblob)(unsafe.Pointer(p)).FpCsr = *(*uintptr)(unsafe.Pointer(pC + 48)) + _sqlite3BtreeIncrblobCursor(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr) + } + } + if rc == int32(SQLITE_ROW) { + rc = SQLITE_OK + } else { + if (*TIncrblob)(unsafe.Pointer(p)).FpStmt != 0 { + rc = Xsqlite3_finalize(tls, (*TIncrblob)(unsafe.Pointer(p)).FpStmt) + (*TIncrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) + if rc == SQLITE_OK { + zErr = _sqlite3MPrintf(tls, (*TIncrblob)(unsafe.Pointer(p)).Fdb, __ccgo_ts+6529, libc.VaList(bp+8, iRow)) + rc = int32(SQLITE_ERROR) + } else { + zErr = _sqlite3MPrintf(tls, (*TIncrblob)(unsafe.Pointer(p)).Fdb, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, (*TIncrblob)(unsafe.Pointer(p)).Fdb))) + } + } + } + **(**uintptr)(__ccgo_up(pzErr)) = zErr + return rc +} + +// C documentation +// +// /* +// ** Check to see if the FROM clause term pFrom has table-valued function +// ** arguments. If it does, leave an error message in pParse and return +// ** non-zero, since pFrom is not allowed to be a table-valued function. +// */ +func _cannotBeFunction(tls *libc.TLS, pParse uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x8>>3) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20992, libc.VaList(bp+8, (*TSrcItem)(unsafe.Pointer(pFrom)).FzName)) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Append a message to the error message string. +// */ +func _checkAppendMsg(tls *libc.TLS, pCheck uintptr, zFormat uintptr, va uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ap Tva_list + _ = ap + _checkProgress(tls, pCheck) + if !((*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0) { + return + } + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr - 1 + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr + 1 + ap = va + if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FnChar != 0 { + Xsqlite3_str_append(tls, pCheck+72, __ccgo_ts+4352, int32(1)) + } + if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx != 0 { + Xsqlite3_str_appendf(tls, pCheck+72, (*TIntegrityCk)(unsafe.Pointer(pCheck)).FzPfx, libc.VaList(bp+8, (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv0, (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv1, (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fv2)) + } + Xsqlite3_str_vappendf(tls, pCheck+72, zFormat, ap) + _ = ap + if libc.Int32FromUint8((*TIntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FaccError) == int32(SQLITE_NOMEM) { + _checkOom(tls, pCheck) + } +} + +// C documentation +// +// /* +// ** Generate an instruction that will put the integer describe by +// ** text z[0..n-1] into register iMem. +// ** +// ** Expr.u.zToken is always UTF8 and zero-terminated. +// */ +func _codeInteger(tls *libc.TLS, pParse uintptr, pExpr uintptr, negFlag int32, iMem int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, i int32 + var v, z, v1 uintptr + var v2 int64 + var _ /* value at bp+0 */ Ti64 + _, _, _, _, _, _ = c, i, v, z, v1, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_IntValue) != 0 { + i = *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fu)) + if negFlag != 0 { + i = -i + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), i, iMem) + } else { + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + c = _sqlite3DecOrHexToI64(tls, z, bp) + if c == int32(3) && !(negFlag != 0) || c == int32(2) || negFlag != 0 && **(**Ti64)(__ccgo_up(bp)) == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<op==TK_IS: op==TK_EQ and p5==SQLITE_NULLEQ +// ** if pExpr->op==TK_ISNOT: op==TK_NE and p5==SQLITE_NULLEQ +// ** otherwise: op==pExpr->op and p5==0 +// */ +func _codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, op Tu8, p5 Tu8) { + bp := tls.Alloc(32) + defer tls.Free(32) + var addrCmp, addrDone, i, isCommuted, nLeft, r1, r2, regLeft, regRight int32 + var opx Tu8 + var pLeft, pRight, v uintptr + var _ /* pL at bp+8 */ uintptr + var _ /* pR at bp+16 */ uintptr + var _ /* regFree1 at bp+0 */ int32 + var _ /* regFree2 at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCmp, addrDone, i, isCommuted, nLeft, opx, pLeft, pRight, r1, r2, regLeft, regRight, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + nLeft = _sqlite3ExprVectorSize(tls, pLeft) + regLeft = 0 + regRight = 0 + opx = op + addrCmp = 0 + addrDone = _sqlite3VdbeMakeLabel(tls, pParse) + isCommuted = libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + if nLeft != _sqlite3ExprVectorSize(tls, pRight) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6908, 0) + return + } + if libc.Int32FromUint8(op) == int32(TK_LE) { + opx = uint8(TK_LT) + } + if libc.Int32FromUint8(op) == int32(TK_GE) { + opx = uint8(TK_GT) + } + if libc.Int32FromUint8(op) == int32(TK_NE) { + opx = uint8(TK_EQ) + } + regLeft = _exprCodeSubselect(tls, pParse, pLeft) + regRight = _exprCodeSubselect(tls, pParse, pRight) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), dest) + i = 0 + for { + if !(int32(1) != 0) { + break + } + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + if addrCmp != 0 { + _sqlite3VdbeJumpHere(tls, v, addrCmp) + } + r1 = _exprVectorRegister(tls, pParse, pLeft, i, regLeft, bp+8, bp) + r2 = _exprVectorRegister(tls, pParse, pRight, i, regRight, bp+16, bp+4) + addrCmp = _sqlite3VdbeCurrentAddr(tls, v) + _codeCompare(tls, pParse, **(**uintptr)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp + 16)), libc.Int32FromUint8(opx), r1, r2, addrDone, libc.Int32FromUint8(p5), isCommuted) + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp))) + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp + 4))) + if (libc.Int32FromUint8(opx) == int32(TK_LT) || libc.Int32FromUint8(opx) == int32(TK_GT)) && i < nLeft-int32(1) { + addrCmp = _sqlite3VdbeAddOp0(tls, v, int32(OP_ElseEq)) + } + if libc.Int32FromUint8(p5) == int32(SQLITE_NULLEQ) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, dest) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_ZeroOrNull), r1, dest, r2) + } + if i == nLeft-int32(1) { + break + } + if libc.Int32FromUint8(opx) == int32(TK_EQ) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), dest, addrDone) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrDone) + if i == nLeft-int32(2) { + opx = op + } + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3VdbeJumpHere(tls, v, addrCmp) + _sqlite3VdbeResolveLabel(tls, v, addrDone) + if libc.Int32FromUint8(op) == int32(TK_NE) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Not), dest, dest) + } +} + +// C documentation +// +// /* +// ** Return a pointer to a string containing the 'declaration type' of the +// ** expression pExpr. The string may be treated as static by the caller. +// ** +// ** The declaration type is the exact datatype definition extracted from the +// ** original CREATE TABLE statement if the expression is a column. The +// ** declaration type for a ROWID field is INTEGER. Exactly when an expression +// ** is considered a column can be complex in the presence of subqueries. The +// ** result-set expression in all of the following SELECT statements is +// ** considered a column by this function. +// ** +// ** SELECT col FROM tbl; +// ** SELECT (SELECT col FROM tbl; +// ** SELECT (SELECT col FROM tbl); +// ** SELECT abc FROM (SELECT col AS abc FROM tbl); +// ** +// ** The declaration type for any expression other than a column is NULL. +// ** +// ** This routine has either 3 or 6 parameters depending on whether or not +// ** the SQLITE_ENABLE_COLUMN_METADATA compile-time option is used. +// */ +func _columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, pzOrigTab uintptr, pzOrigCol uintptr) (r uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var iCol, iDb, j int32 + var p, p1, pS, pS1, pTab, pTabList, zType uintptr + var _ /* sNC at bp+24 */ TNameContext + var _ /* sNC at bp+80 */ TNameContext + var _ /* zOrigCol at bp+16 */ uintptr + var _ /* zOrigDb at bp+0 */ uintptr + var _ /* zOrigTab at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _ = iCol, iDb, j, p, p1, pS, pS1, pTab, pTabList, zType + zType = uintptr(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + case int32(TK_COLUMN): + /* The expression is a column. Locate the table the column is being + ** extracted from in NameContext.pSrcList. This table may be real + ** database table or a subquery. + */ + pTab = uintptr(0) /* Table structure column is extracted from */ + pS = uintptr(0) /* Select the column is extracted from */ + iCol = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) /* Index of column in pTab */ + for pNC != 0 && !(pTab != 0) { + pTabList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + j = 0 + for { + if !(j < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc && (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80))).FiCursor != (*TExpr)(unsafe.Pointer(pExpr)).FiTable) { + break + } + goto _1 + _1: + ; + j = j + 1 + } + if j < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc { + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80))).FpSTab + if int32(*(*uint32)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80 + 24 + 4))&0x4>>2) != 0 { + pS = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80 + 72)))).FpSelect + } else { + pS = uintptr(0) + } + } else { + pNC = (*TNameContext)(unsafe.Pointer(pNC)).FpNext + } + } + if pTab == uintptr(0) { + /* At one time, code such as "SELECT new.x" within a trigger would + ** cause this condition to run. Since then, we have restructured how + ** trigger code is generated and so this condition is no longer + ** possible. However, it can still be true for statements like + ** the following: + ** + ** CREATE TABLE t1(col INTEGER); + ** SELECT (SELECT t1.col) FROM FROM t1; + ** + ** when columnType() is called on the expression "t1.col" in the + ** sub-select. In this case, set the column type to NULL, even + ** though it should really be "INTEGER". + ** + ** This is not a problem, as the column type of "t1.col" is never + ** used. When columnType() is called on the expression + ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT + ** branch below. */ + break + } + if pS != 0 { + /* The "table" is actually a sub-select or a view in the FROM clause + ** of the SELECT statement. Return the declaration type and origin + ** data for the result-set column of the sub-select. + */ + if iCol < (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS)).FpEList)).FnExpr && libc.Bool(libc.Bool(!(libc.Int32FromInt32(ViewCanHaveRowid) != 0)) || iCol >= 0) { + p = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS)).FpEList + 8 + uintptr(iCol)*32))).FpExpr + (**(**TNameContext)(__ccgo_up(bp + 24))).FpSrcList = (*TSelect)(unsafe.Pointer(pS)).FpSrc + (**(**TNameContext)(__ccgo_up(bp + 24))).FpNext = pNC + (**(**TNameContext)(__ccgo_up(bp + 24))).FpParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + zType = _columnTypeImpl(tls, bp+24, p, bp, bp+8, bp+16) + } + } else { + /* A real table or a CTE table */ + if iCol < 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + if iCol < 0 { + zType = __ccgo_ts + 1178 + **(**uintptr)(__ccgo_up(bp + 16)) = __ccgo_ts + 17963 + } else { + **(**uintptr)(__ccgo_up(bp + 16)) = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + zType = _sqlite3ColumnType(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16, uintptr(0)) + } + **(**uintptr)(__ccgo_up(bp + 8)) = (*TTable)(unsafe.Pointer(pTab)).FzName + if (*TNameContext)(unsafe.Pointer(pNC)).FpParse != 0 && (*TTable)(unsafe.Pointer(pTab)).FpSchema != 0 { + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer((*TNameContext)(unsafe.Pointer(pNC)).FpParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + **(**uintptr)(__ccgo_up(bp)) = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TNameContext)(unsafe.Pointer(pNC)).FpParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName + } + } + case int32(TK_SELECT): + pS1 = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + p1 = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS1)).FpEList + 8))).FpExpr + (**(**TNameContext)(__ccgo_up(bp + 80))).FpSrcList = (*TSelect)(unsafe.Pointer(pS1)).FpSrc + (**(**TNameContext)(__ccgo_up(bp + 80))).FpNext = pNC + (**(**TNameContext)(__ccgo_up(bp + 80))).FpParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + zType = _columnTypeImpl(tls, bp+80, p1, bp, bp+8, bp+16) + break + } + if pzOrigDb != 0 { + **(**uintptr)(__ccgo_up(pzOrigDb)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(pzOrigTab)) = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(pzOrigCol)) = **(**uintptr)(__ccgo_up(bp + 16)) + } + return zType +} + +// C documentation +// +// /* +// ** Attempt to transform a query of the form +// ** +// ** SELECT count(*) FROM (SELECT x FROM t1 UNION ALL SELECT y FROM t2) +// ** +// ** Into this: +// ** +// ** SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2) +// ** +// ** The transformation only works if all of the following are true: +// ** +// ** * The subquery is a UNION ALL of two or more terms +// ** * The subquery does not have a LIMIT clause +// ** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries +// ** * The outer query is a simple count(*) with no WHERE clause or other +// ** extraneous syntax. +// ** * None of the subqueries are DISTINCT (forumpost/a860f5fb2e 2025-03-10) +// ** +// ** Return TRUE if the optimization is undertaken. +// */ +func _countOfViewOptimization(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + var db, pCount, pExpr, pFrom, pPrior, pSub, pTerm, v1 uintptr + _, _, _, _, _, _, _, _ = db, pCount, pExpr, pFrom, pPrior, pSub, pTerm, v1 + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Aggregate) == uint32(0) { + return 0 + } /* This is an aggregate */ + if (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr != int32(1) { + return 0 + } /* Single result column */ + if (*TSelect)(unsafe.Pointer(p)).FpWhere != 0 { + return 0 + } + if (*TSelect)(unsafe.Pointer(p)).FpHaving != 0 { + return 0 + } + if (*TSelect)(unsafe.Pointer(p)).FpGroupBy != 0 { + return 0 + } + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 { + return 0 + } + pExpr = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_AGG_FUNCTION) { + return 0 + } /* Result is an aggregate */ + if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), __ccgo_ts+17116) != 0 { + return 0 + } /* Is count() */ + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != uintptr(0) { + return 0 + } /* Must be count(*) */ + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc != int32(1) { + return 0 + } /* One table in FROM */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + return 0 + } /* Not a window function */ + pFrom = (*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x4>>2) == 0 { + return 0 + } /* FROM is a subquery */ + pSub = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + if (*TSelect)(unsafe.Pointer(pSub)).FpPrior == uintptr(0) { + return 0 + } /* Must be a compound */ + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&uint32(SF_CopyCte) != 0 { + return 0 + } /* Not a CTE */ + for cond := true; cond; cond = pSub != 0 { + if libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSub)).Fop) != int32(TK_ALL) && (*TSelect)(unsafe.Pointer(pSub)).FpPrior != 0 { + return 0 + } /* Must be UNION ALL */ + if (*TSelect)(unsafe.Pointer(pSub)).FpWhere != 0 { + return 0 + } /* No WHERE clause */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 { + return 0 + } /* No LIMIT clause */ + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Aggregate)|libc.Int32FromInt32(SF_Distinct)) != 0 { + return 0 /* Not an aggregate nor DISTINCT */ + } + /* Due to the previous */ + pSub = (*TSelect)(unsafe.Pointer(pSub)).FpPrior /* Repeat over compound */ + } + /* If we reach this point then it is OK to perform the transformation */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pCount = pExpr + pExpr = uintptr(0) + pSub = _sqlite3SubqueryDetach(tls, db, pFrom) + _sqlite3SrcListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpSrc) + (*TSelect)(unsafe.Pointer(p)).FpSrc = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt64(80))) + for pSub != 0 { + pPrior = (*TSelect)(unsafe.Pointer(pSub)).FpPrior + (*TSelect)(unsafe.Pointer(pSub)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(pSub)).FpNext = uintptr(0) + **(**Tu32)(__ccgo_up(pSub + 4)) |= uint32(SF_Aggregate) + **(**Tu32)(__ccgo_up(pSub + 4)) &= ^libc.Uint32FromInt32(SF_Compound) + (*TSelect)(unsafe.Pointer(pSub)).FnSelectRow = 0 + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprListDeleteGeneric), (*TSelect)(unsafe.Pointer(pSub)).FpEList) + if pPrior != 0 { + v1 = _sqlite3ExprDup(tls, db, pCount, 0) + } else { + v1 = pCount + } + pTerm = v1 + (*TSelect)(unsafe.Pointer(pSub)).FpEList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), pTerm) + pTerm = _sqlite3PExpr(tls, pParse, int32(TK_SELECT), uintptr(0), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, pTerm, pSub) + if pExpr == uintptr(0) { + pExpr = pTerm + } else { + pExpr = _sqlite3PExpr(tls, pParse, int32(TK_PLUS), pTerm, pExpr) + } + pSub = pPrior + } + (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8))).FpExpr = pExpr + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Aggregate) + return int32(1) +} + +// C documentation +// +// /* +// ** Connect to or create a dbpagevfs virtual table. +// */ +func _dbpageConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = uintptr(0) + rc = SQLITE_OK + _ = pAux + _ = argc + _ = argv + _ = pzErr + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_DIRECTONLY), 0) + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_USES_ALL_SCHEMAS), 0) + rc = Xsqlite3_declare_vtab(tls, db, __ccgo_ts+34933) + if rc == SQLITE_OK { + pTab = Xsqlite3_malloc64(tls, uint64(40)) + if pTab == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc == SQLITE_OK { + libc.Xmemset(tls, pTab, 0, uint64(40)) + (*TDbpageTable)(unsafe.Pointer(pTab)).Fdb = db + } + **(**uintptr)(__ccgo_up(ppVtab)) = pTab + return rc +} + +func _dbpageUpdate(tls *libc.TLS, pVtab uintptr, argc int32, argv uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aPage, pBt, pData, pPager, pTab, zErr, zSchema uintptr + var iDb, isInsert, rc, szPage, v1 int32 + var pgno TPgno + var _ /* pDbPage at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = aPage, iDb, isInsert, pBt, pData, pPager, pTab, pgno, rc, szPage, zErr, zSchema, v1 + pTab = pVtab + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + zErr = uintptr(0) + _ = pRowid + if (*Tsqlite3)(unsafe.Pointer((*TDbpageTable)(unsafe.Pointer(pTab)).Fdb)).Fflags&uint64(SQLITE_Defensive) != 0 { + zErr = __ccgo_ts + 35000 + goto update_fail + } + if argc == int32(1) { + zErr = __ccgo_ts + 35010 + goto update_fail + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + pgno = libc.Uint32FromInt64(Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + isInsert = int32(1) + } else { + pgno = libc.Uint32FromInt64(Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))) + if libc.Uint32FromInt32(Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8)))) != pgno { + zErr = __ccgo_ts + 35024 + goto update_fail + } + isInsert = 0 + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) == int32(SQLITE_NULL) { + iDb = 0 + } else { + zSchema = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + iDb = _sqlite3FindDbName(tls, (*TDbpageTable)(unsafe.Pointer(pTab)).Fdb, zSchema) + if iDb < 0 { + zErr = __ccgo_ts + 35038 + goto update_fail + } + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TDbpageTable)(unsafe.Pointer(pTab)).Fdb)).FaDb + uintptr(iDb)*32))).FpBt + if pgno < uint32(1) || pBt == uintptr(0) { + zErr = __ccgo_ts + 35053 + goto update_fail + } + szPage = _sqlite3BtreeGetPageSize(tls, pBt) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) != int32(SQLITE_BLOB) || Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) != szPage { + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) == int32(SQLITE_NULL) && isInsert != 0 && pgno > uint32(1) { + /* "INSERT INTO dbpage($PGNO,NULL)" causes page number $PGNO and + ** all subsequent pages to be deleted. */ + (*TDbpageTable)(unsafe.Pointer(pTab)).FiDbTrunc = iDb + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = pgno - uint32(1) + pgno = uint32(1) + } else { + zErr = __ccgo_ts + 35069 + goto update_fail + } + } + if _dbpageBeginTrans(tls, pTab) != SQLITE_OK { + zErr = __ccgo_ts + 35084 + goto update_fail + } + pPager = _sqlite3BtreePager(tls, pBt) + rc = _sqlite3PagerGet(tls, pPager, pgno, bp, 0) + if rc == SQLITE_OK { + pData = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + v1 = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp))) + rc = v1 + if v1 == SQLITE_OK && pData != 0 { + aPage = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + libc.Xmemcpy(tls, aPage, pData, libc.Uint64FromInt32(szPage)) + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0) + } + } + if rc != SQLITE_OK { + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0) + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + return rc + goto update_fail +update_fail: + ; + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0) + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, zErr)) + return int32(SQLITE_ERROR) +} + +// C documentation +// +// /* +// ** This function is called to configure the RtreeConstraint object passed +// ** as the second argument for a MATCH constraint. The value passed as the +// ** first argument to this function is the right-hand operand to the MATCH +// ** operator. +// */ +func _deserializeGeometry(tls *libc.TLS, pValue uintptr, pCons uintptr) (r int32) { + var pBlob, pInfo, pSrc uintptr + _, _, _ = pBlob, pInfo, pSrc /* Callback information */ + pSrc = Xsqlite3_value_pointer(tls, pValue, __ccgo_ts+27426) + if pSrc == uintptr(0) { + return int32(SQLITE_ERROR) + } + pInfo = Xsqlite3_malloc64(tls, uint64(112)+uint64((*TRtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize)) + if !(pInfo != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pInfo, 0, uint64(112)) + pBlob = pInfo + 1*112 + libc.Xmemcpy(tls, pBlob, pSrc, uint64((*TRtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize)) + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FpContext = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FpContext + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FnParam = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FaParam = pBlob + 56 + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FapSqlParam = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam + if (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom != 0 { + *(*uintptr)(unsafe.Pointer(pCons + 8)) = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom + } else { + (*TRtreeConstraint)(unsafe.Pointer(pCons)).Fop = int32(RTREE_QUERY) + *(*uintptr)(unsafe.Pointer(pCons + 8)) = (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxQueryFunc + } + (*TRtreeConstraint)(unsafe.Pointer(pCons)).FpInfo = pInfo + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Write code to erase the table with root-page iTable from database iDb. +// ** Also write code to modify the sqlite_schema table and internal schema +// ** if a root-page of another table is moved by the btree-layer whilst +// ** erasing iTable (this can happen with an auto-vacuum database). +// */ +func _destroyRootPage(tls *libc.TLS, pParse uintptr, iTable int32, iDb int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var r1 int32 + var v uintptr + _, _ = r1, v + v = _sqlite3GetVdbe(tls, pParse) + r1 = _sqlite3GetTempReg(tls, pParse) + if iTable < int32(2) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14869, 0) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Destroy), iTable, r1, iDb) + _sqlite3MayAbort(tls, pParse) + /* OP_Destroy stores an in integer r1. If this integer + ** is non-zero, then it is the root page number of a table moved to + ** location iTable. The following code modifies the sqlite_schema table to + ** reflect this. + ** + ** The "#NNN" in the SQL is a special constant that means whatever value + ** is in register NNN. See grammar rules associated with the TK_REGISTER + ** token for additional information. + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+14884, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName, iTable, r1, r1)) + _sqlite3ReleaseTempReg(tls, pParse, r1) +} + +// C documentation +// +// /* +// ** The implementation of internal UDF sqlite_drop_column(). +// ** +// ** Arguments: +// ** +// ** argv[0]: An integer - the index of the schema containing the table +// ** argv[1]: CREATE TABLE statement to modify. +// ** argv[2]: An integer - the index of the column to remove. +// ** +// ** The value returned is a string containing the CREATE TABLE statement +// ** with column argv[2] removed. +// */ +func _dropColumnFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(464) + defer tls.Free(464) + var db, pCol, pEnd, pTab, zDb, zEnd, zNew, zSql uintptr + var iCol, iSchema, rc int32 + var xAuth Tsqlite3_xauth + var _ /* eTok at bp+416 */ int32 + var _ /* sParse at bp+0 */ TParse + _, _, _, _, _, _, _, _, _, _, _, _ = db, iCol, iSchema, pCol, pEnd, pTab, rc, xAuth, zDb, zEnd, zNew, zSql + db = Xsqlite3_context_db_handle(tls, context) + iSchema = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv))) + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*32))).FzDbSName + zNew = uintptr(0) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + _ = NotUsed + rc = _renameParseSql(tls, bp, zDb, db, zSql, libc.BoolInt32(iSchema == int32(1))) + if rc != SQLITE_OK { + goto drop_column_done + } + pTab = (**(**TParse)(__ccgo_up(bp))).FpNewTable + if pTab == uintptr(0) || int32((*TTable)(unsafe.Pointer(pTab)).FnCol) == int32(1) || iCol >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + /* This can happen if the sqlite_schema table is corrupt */ + rc = _sqlite3CorruptError(tls, int32(122622)) + goto drop_column_done + } + if iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1) { + pCol = _renameTokenFind(tls, bp, uintptr(0), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName) + pEnd = _renameTokenFind(tls, bp, uintptr(0), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol+int32(1))*16))).FzCnName) + zEnd = (*TRenameToken)(unsafe.Pointer(pEnd)).Ft.Fz + } else { + /* Point pCol->t.z at the "," immediately preceding the definition of + ** the column being dropped. To do this, start at the name of the + ** previous column, and tokenize until the next ",". */ + pCol = _renameTokenFind(tls, bp, uintptr(0), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol-int32(1))*16))).FzCnName) + for cond := true; cond; cond = **(**int32)(__ccgo_up(bp + 416)) != int32(TK_COMMA) { + (*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz += uintptr(_getConstraintToken(tls, (*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz, bp+416)) + } + (*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz = (*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz - 1 + zEnd = zSql + uintptr((*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FaddColOffset) + } + zNew = _sqlite3MPrintf(tls, db, __ccgo_ts+11585, libc.VaList(bp+432, int64((*TRenameToken)(unsafe.Pointer(pCol)).Ft.Fz)-int64(zSql), zSql, zEnd)) + Xsqlite3_result_text(tls, context, zNew, -int32(1), uintptr(-libc.Int32FromInt32(1))) + Xsqlite3_free(tls, zNew) + goto drop_column_done +drop_column_done: + ; + _renameParseCleanup(tls, bp) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + if rc != SQLITE_OK { + Xsqlite3_result_error_code(tls, context, rc) + } +} + +// C documentation +// +// /* +// ** Internal SQL function sqlite3_drop_constraint(): Given an input +// ** CREATE TABLE statement, return a revised CREATE TABLE statement +// ** with a constraint removed. Two forms, depending on the datatype +// ** of argv[2]: +// ** +// ** sqlite_drop_constraint(SQL, INT) -- Omit NOT NULL from the INT-th column +// ** sqlite_drop_constraint(SQL, TEXT) -- OMIT constraint with name TEXT +// ** +// ** In the first case, the left-most column is 0. +// */ +func _dropConstraintFunc(tls *libc.TLS, ctx uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, zCons, zNew, zSpace, zSql uintptr + var iEnd, iNotNull, iStart, ii, nTok int32 + var _ /* cmp at bp+8 */ int32 + var _ /* iOff at bp+0 */ int32 + var _ /* t at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _ = db, iEnd, iNotNull, iStart, ii, nTok, zCons, zNew, zSpace, zSql + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zCons = uintptr(0) + iNotNull = -int32(1) + **(**int32)(__ccgo_up(bp)) = 0 + iStart = 0 + iEnd = 0 + zNew = uintptr(0) + **(**int32)(__ccgo_up(bp + 4)) = 0 + _ = NotUsed + if zSql == uintptr(0) { + return + } + /* Jump past the "CREATE TABLE" bit. */ + if _skipCreateTable(tls, ctx, zSql, bp) != 0 { + return + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) == int32(SQLITE_INTEGER) { + iNotNull = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + zCons = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } + /* Search for the named constraint within column definitions. */ + ii = 0 + for { + if !(iEnd == 0) { + break + } + /* Now parse the column or table constraint definition. Search + ** for the token CONSTRAINT if this is a DROP CONSTRAINT command, or + ** NOT in the right column if this is a DROP NOT NULL. */ + for int32(1) != 0 { + iStart = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_CONSTRAINT) && (zCons != 0 || iNotNull == ii) { + /* Check if this is the constraint we are searching for. */ + nTok = 0 + **(**int32)(__ccgo_up(bp + 8)) = int32(1) + /* Skip past any whitespace. */ + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getWhitespace(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp)))) + /* Compare the next token - which may be quoted - with the name of + ** the constraint being dropped. */ + nTok = _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + if zCons != 0 { + if _quotedCompare(tls, ctx, **(**int32)(__ccgo_up(bp + 4)), zSql+uintptr(**(**int32)(__ccgo_up(bp))), nTok, zCons, bp+8) != 0 { + return + } + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + nTok + /* The next token is usually the first token of the constraint + ** definition. This is enough to tell the type of the constraint - + ** TK_NOT means it is a NOT NULL, TK_CHECK a CHECK constraint etc. + ** + ** There is also the chance that the next token is TK_CONSTRAINT + ** (or TK_DEFAULT or TK_COLLATE), for example if a table has been + ** created as follows: + ** + ** CREATE TABLE t1(cols, CONSTRAINT one CONSTRAINT two NOT NULL); + ** + ** In this case, allow the "CONSTRAINT one" bit to be dropped by + ** this command if that is what is requested, or to advance to + ** the next iteration of the loop with &zSql[iOff] still pointing + ** to the CONSTRAINT keyword. */ + nTok = _getConstraintToken(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_CONSTRAINT) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_DEFAULT) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COLLATE) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COMMA) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_RP) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_GENERATED) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_AS) { + **(**int32)(__ccgo_up(bp + 4)) = int32(TK_CHECK) + } else { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + nTok + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _getConstraint(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp)))) + } + if **(**int32)(__ccgo_up(bp + 8)) == 0 || iNotNull >= 0 && **(**int32)(__ccgo_up(bp + 4)) == int32(TK_NOT) { + if **(**int32)(__ccgo_up(bp + 4)) != int32(TK_NOT) && **(**int32)(__ccgo_up(bp + 4)) != int32(TK_CHECK) { + _errorMPrintf(tls, ctx, __ccgo_ts+11819, libc.VaList(bp+24, zCons)) + return + } + iEnd = **(**int32)(__ccgo_up(bp)) + break + } + } else { + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_NOT) && iNotNull == ii { + iEnd = **(**int32)(__ccgo_up(bp)) + _getConstraint(tls, zSql+uintptr(**(**int32)(__ccgo_up(bp)))) + break + } else { + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_RP) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_ILLEGAL) { + iEnd = -int32(1) + break + } else { + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COMMA) { + break + } + } + } + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + /* If the constraint has not been found it is an error. */ + if iEnd <= 0 { + if zCons != 0 { + _errorMPrintf(tls, ctx, __ccgo_ts+11853, libc.VaList(bp+24, zCons)) + } else { + /* SQLite follows postgres in that a DROP NOT NULL on a column that is + ** not NOT NULL is not an error. So just return the original SQL here. */ + Xsqlite3_result_text(tls, ctx, zSql, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } + } else { + /* Figure out if an extra space should be inserted after the constraint + ** is removed. And if an additional comma preceding the constraint + ** should be removed. */ + zSpace = __ccgo_ts + 11541 + iEnd = iEnd + _getWhitespace(tls, zSql+uintptr(iEnd)) + _sqlite3GetToken(tls, zSql+uintptr(iEnd), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == int32(TK_RP) || **(**int32)(__ccgo_up(bp + 4)) == int32(TK_COMMA) { + zSpace = __ccgo_ts + 1704 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zSql + uintptr(iStart-int32(1))))) == int32(',') { + iStart = iStart - 1 + } + } + db = Xsqlite3_context_db_handle(tls, ctx) + zNew = _sqlite3MPrintf(tls, db, __ccgo_ts+11876, libc.VaList(bp+24, iStart, zSql, zSpace, zSql+uintptr(iEnd))) + Xsqlite3_result_text(tls, ctx, zNew, -int32(1), __ccgo_fp(_sqlite3RowSetClear)) + } +} + +// C documentation +// +// /* +// ** Execute zSql on database db. +// ** +// ** If zSql returns rows, then each row will have exactly one +// ** column. (This will only happen if zSql begins with "SELECT".) +// ** Take each row of result and call execSql() again recursively. +// ** +// ** The execSqlF() routine does the same thing, except it accepts +// ** a format string as its third argument +// */ +func _execSql(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc, v1 int32 + var zSubSql uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _ = rc, zSubSql, v1 + /* printf("SQL: [%s]\n", zSql); fflush(stdout); */ + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + if rc != SQLITE_OK { + return rc + } + for { + v1 = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = v1 + if !(int32(SQLITE_ROW) == v1) { + break + } + zSubSql = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + /* The secondary SQL must be one of CREATE TABLE, CREATE INDEX, + ** or INSERT. Historically there have been attacks that first + ** corrupt the sqlite_schema.sql field with other kinds of statements + ** then run VACUUM to get those statements to execute at inappropriate + ** times. */ + if zSubSql != 0 && (libc.Xstrncmp(tls, zSubSql, __ccgo_ts+22664, uint64(3)) == 0 || libc.Xstrncmp(tls, zSubSql, __ccgo_ts+22668, uint64(3)) == 0) { + rc = _execSql(tls, db, pzErrMsg, zSubSql) + if rc != SQLITE_OK { + break + } + } + } + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + if rc != 0 { + _sqlite3SetString(tls, pzErrMsg, db, Xsqlite3_errmsg(tls, db)) + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Return the name of the i-th column of the pIdx index. +// */ +func _explainIndexColumnName(tls *libc.TLS, pIdx uintptr, i int32) (r uintptr) { + i = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) + if i == -int32(2) { + return __ccgo_ts + 23553 + } + if i == -int32(1) { + return __ccgo_ts + 17963 + } + return (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(i)*16))).FzCnName +} + +// C documentation +// +// /* +// ** Add a single OP_Explain instruction to the VDBE to explain a simple +// ** count(*) query ("SELECT count(*) FROM pTab"). +// */ +func _explainSimpleCount(tls *libc.TLS, pParse uintptr, pTab uintptr, pIdx uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bCover int32 + var v1, v2 uintptr + _, _, _ = bCover, v1, v2 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fexplain) == int32(2) { + bCover = libc.BoolInt32(pIdx != uintptr(0) && ((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || !(int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == libc.Int32FromInt32(SQLITE_IDXTYPE_PRIMARYKEY)))) + if bCover != 0 { + v1 = __ccgo_ts + 21485 + } else { + v1 = __ccgo_ts + 1704 + } + if bCover != 0 { + v2 = (*TIndex)(unsafe.Pointer(pIdx)).FzName + } else { + v2 = __ccgo_ts + 1704 + } + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+21508, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, v1, v2)) + } +} + +// C documentation +// +// /* +// ** Initialize the contents of the unixFile structure pointed to by pId. +// */ +func _fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename uintptr, ctrlFlags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nFilename, rc int32 + var pLockingStyle, pNew, zLockFile, v1, v2 uintptr + _, _, _, _, _, _, _ = nFilename, pLockingStyle, pNew, rc, zLockFile, v1, v2 + pNew = pId + rc = SQLITE_OK + /* No locking occurs in temporary files */ + (*TunixFile)(unsafe.Pointer(pNew)).Fh = h + (*TunixFile)(unsafe.Pointer(pNew)).FpVfs = pVfs + (*TunixFile)(unsafe.Pointer(pNew)).FzPath = zFilename + (*TunixFile)(unsafe.Pointer(pNew)).FctrlFlags = uint16(libc.Uint8FromInt32(ctrlFlags)) + (*TunixFile)(unsafe.Pointer(pNew)).FmmapSizeMax = _sqlite3Config.FszMmap + if ctrlFlags&int32(UNIXFILE_URI) != 0 { + v1 = zFilename + } else { + v1 = uintptr(0) + } + if Xsqlite3_uri_boolean(tls, v1, __ccgo_ts+3978, int32(SQLITE_POWERSAFE_OVERWRITE)) != 0 { + v2 = pNew + 30 + *(*uint16)(unsafe.Pointer(v2)) = uint16(int32(*(*uint16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(UNIXFILE_PSOW)) + } + if libc.Xstrcmp(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, __ccgo_ts+3983) == 0 { + v1 = pNew + 30 + *(*uint16)(unsafe.Pointer(v1)) = uint16(int32(*(*uint16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(UNIXFILE_EXCL)) + } + if ctrlFlags&int32(UNIXFILE_NOLOCK) != 0 { + pLockingStyle = uintptr(unsafe.Pointer(&_nolockIoMethods)) + } else { + pLockingStyle = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData))})))(tls, zFilename, pNew) + } + if pLockingStyle == uintptr(unsafe.Pointer(&_posixIoMethods)) { + _unixEnterMutex(tls) + rc = _findInodeInfo(tls, pNew, pNew+16) + if rc != SQLITE_OK { + /* If an error occurred in findInodeInfo(), close the file descriptor + ** immediately, before releasing the mutex. findInodeInfo() may fail + ** in two scenarios: + ** + ** (a) A call to fstat() failed. + ** (b) A malloc failed. + ** + ** Scenario (b) may only occur if the process is holding no other + ** file descriptors open on the same file. If there were other file + ** descriptors on this file, then no malloc would be required by + ** findInodeInfo(). If this is the case, it is quite safe to close + ** handle h - as it is guaranteed that no posix locks will be released + ** by doing so. + ** + ** If scenario (a) caused the error then things are not so safe. The + ** implicit assumption here is that if fstat() fails, things are in + ** such bad shape that dropping a lock or two doesn't matter much. + */ + _robust_close(tls, pNew, h, int32(46345)) + h = -int32(1) + } + _unixLeaveMutex(tls) + } else { + if pLockingStyle == uintptr(unsafe.Pointer(&_dotlockIoMethods)) { + nFilename = libc.Int32FromUint64(libc.Xstrlen(tls, zFilename)) + int32(6) + zLockFile = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nFilename)) + if zLockFile == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + Xsqlite3_snprintf(tls, nFilename, zLockFile, __ccgo_ts+3993, libc.VaList(bp+8, zFilename)) + } + (*TunixFile)(unsafe.Pointer(pNew)).FlockingContext = zLockFile + } + } + _storeLastErrno(tls, pNew, 0) + if rc != SQLITE_OK { + if h >= 0 { + _robust_close(tls, pNew, h, int32(46437)) + } + } else { + (*Tsqlite3_file)(unsafe.Pointer(pId)).FpMethods = pLockingStyle + _verifyDbFile(tls, pNew) + } + return rc +} + +// C documentation +// +// /* +// ** Return a pointer corresponding to database zDb (i.e. "main", "temp") +// ** in connection handle pDb. If such a database cannot be found, return +// ** a NULL pointer and write an error message to pErrorDb. +// ** +// ** If the "temp" database is requested, it may need to be opened by this +// ** function. If an error occurs while doing so, return 0 and write an +// ** error message to pErrorDb. +// */ +func _findBtree(tls *libc.TLS, pErrorDb uintptr, pDb uintptr, zDb uintptr) (r uintptr) { + bp := tls.Alloc(432) + defer tls.Free(432) + var i, rc int32 + var _ /* sParse at bp+0 */ TParse + _, _ = i, rc + i = _sqlite3FindDbName(tls, pDb, zDb) + if i == int32(1) { + rc = 0 + _sqlite3ParseObjectInit(tls, bp, pDb) + if _sqlite3OpenTempDatabase(tls, bp) != 0 { + _sqlite3ErrorWithMsg(tls, pErrorDb, (**(**TParse)(__ccgo_up(bp))).Frc, __ccgo_ts+3944, libc.VaList(bp+424, (**(**TParse)(__ccgo_up(bp))).FzErrMsg)) + rc = int32(SQLITE_ERROR) + } + _sqlite3DbFree(tls, pErrorDb, (**(**TParse)(__ccgo_up(bp))).FzErrMsg) + _sqlite3ParseObjectReset(tls, bp) + if rc != 0 { + return uintptr(0) + } + } + if i < 0 { + _sqlite3ErrorWithMsg(tls, pErrorDb, int32(SQLITE_ERROR), __ccgo_ts+5125, libc.VaList(bp+424, zDb)) + return uintptr(0) + } + return (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(pDb)).FaDb + uintptr(i)*32))).FpBt +} + +// C documentation +// +// /* +// ** Search the AggInfo object for an aCol[] entry that has iTable and iColumn. +// ** Return the index in aCol[] of the entry that describes that column. +// ** +// ** If no prior entry is found, create a new one and return -1. The +// ** new column will have an index of pAggInfo->nColumn-1. +// */ +func _findOrCreateAggInfoColumn(tls *libc.TLS, pParse uintptr, pAggInfo uintptr, pExpr uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var j, k, mxTerm, n int32 + var pCol, pE, pGB, pTerm, v4 uintptr + var v3 Tu32 + _, _, _, _, _, _, _, _, _, _ = j, k, mxTerm, n, pCol, pE, pGB, pTerm, v3, v4 + mxTerm = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 2*4)) + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + k = 0 + for { + if !(k < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) { + break + } + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FpCExpr == pExpr { + return + } + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiTable == (*TExpr)(unsafe.Pointer(pExpr)).FiTable && (*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn == int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_IF_NULL_ROW) { + goto fix_up_expr + } + goto _1 + _1: + ; + k = k + 1 + pCol += 32 + } + k = _addAggInfoColumn(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pAggInfo) + if k < 0 { + /* OOM on resize */ + return + } + if k > mxTerm { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8614, libc.VaList(bp+8, mxTerm)) + k = mxTerm + } + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(k)*32 + (*TAggInfo_col)(unsafe.Pointer(pCol)).FpTab = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiTable = (*TExpr)(unsafe.Pointer(pExpr)).FiTable + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = -int32(1) + (*TAggInfo_col)(unsafe.Pointer(pCol)).FpCExpr = pExpr + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_IF_NULL_ROW) { + pGB = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy + pTerm = pGB + 8 + n = (*TExprList)(unsafe.Pointer(pGB)).FnExpr + j = 0 + for { + if !(j < n) { + break + } + pE = (*TExprList_item)(unsafe.Pointer(pTerm)).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pE)).FiTable == (*TExpr)(unsafe.Pointer(pExpr)).FiTable && int32((*TExpr)(unsafe.Pointer(pE)).FiColumn) == int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) { + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = j + break + } + goto _2 + _2: + ; + j = j + 1 + pTerm += 32 + } + } + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn < 0 { + v4 = pAggInfo + 4 + v3 = *(*Tu32)(unsafe.Pointer(v4)) + *(*Tu32)(unsafe.Pointer(v4)) = *(*Tu32)(unsafe.Pointer(v4)) + 1 + (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = libc.Int32FromUint32(v3) + } + goto fix_up_expr +fix_up_expr: + ; + (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_AGG_COLUMN) + } + (*TExpr)(unsafe.Pointer(pExpr)).FiAgg = int16(k) +} + +// C documentation +// +// /* +// ** Expression callback used by sqlite3FixAAAA() routines. +// */ +func _fixExprCb(tls *libc.TLS, p uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pFix uintptr + _ = pFix + pFix = *(*uintptr)(unsafe.Pointer(p + 40)) + if !((*TDbFixer)(unsafe.Pointer(pFix)).FbTemp != 0) { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_VARIABLE) { + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TDbFixer)(unsafe.Pointer(pFix)).FpParse)).Fdb)).Finit1.Fbusy != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + } else { + _sqlite3ErrorMsg(tls, (*TDbFixer)(unsafe.Pointer(pFix)).FpParse, __ccgo_ts+13539, libc.VaList(bp+8, (*TDbFixer)(unsafe.Pointer(pFix)).FzType)) + return int32(WRC_Abort) + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Select callback used by sqlite3FixAAAA() routines. +// */ +func _fixSelectCb(tls *libc.TLS, p uintptr, pSelect uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pFix, pItem, pList uintptr + var i, iDb int32 + _, _, _, _, _, _ = db, i, iDb, pFix, pItem, pList + pFix = *(*uintptr)(unsafe.Pointer(p + 40)) + db = (*TParse)(unsafe.Pointer((*TDbFixer)(unsafe.Pointer(pFix)).FpParse)).Fdb + iDb = _sqlite3FindDbName(tls, db, (*TDbFixer)(unsafe.Pointer(pFix)).FzDb) + pList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + if pList == uintptr(0) { + return WRC_Continue + } + i = 0 + pItem = pList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pList)).FnSrc) { + break + } + if libc.Int32FromUint8((*TDbFixer)(unsafe.Pointer(pFix)).FbTemp) == 0 && int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) == 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) == 0 && *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { + if iDb != _sqlite3FindDbName(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 72))) { + _sqlite3ErrorMsg(tls, (*TDbFixer)(unsafe.Pointer(pFix)).FpParse, __ccgo_ts+13563, libc.VaList(bp+8, (*TDbFixer)(unsafe.Pointer(pFix)).FzType, (*TDbFixer)(unsafe.Pointer(pFix)).FpName, *(*uintptr)(unsafe.Pointer(pItem + 72)))) + return int32(WRC_Abort) + } + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 72))) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 10, 0x400) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 17, 0x20000) + } + *(*uintptr)(unsafe.Pointer(pItem + 72)) = (*TDbFixer)(unsafe.Pointer(pFix)).FpSchema + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 8, 0x100) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 16, 0x10000) + } + if int32(*(*uint32)(unsafe.Pointer(pList + 8 + uintptr(i)*80 + 24 + 4))&0x800>>11) == 0 && _sqlite3WalkExpr(tls, pFix+8, *(*uintptr)(unsafe.Pointer(pList + 8 + uintptr(i)*80 + 64))) != 0 { + return int32(WRC_Abort) + } + goto _1 + _1: + ; + i = i + 1 + pItem += 80 + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpWith != 0 { + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpWith)).FnCte) { + break + } + if _sqlite3WalkSelect(tls, p, (*(*TCte)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpWith + 16 + uintptr(i)*48))).FpSelect) != 0 { + return int32(WRC_Abort) + } + goto _2 + _2: + ; + i = i + 1 + } + } + return WRC_Continue +} + +func _fts5ApiCallback(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iCsrId Ti64 + var pAux, pCsr, pTab uintptr + _, _, _, _ = iCsrId, pAux, pCsr, pTab + pAux = Xsqlite3_user_data(tls, context) + iCsrId = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + pCsr = _fts5CursorFromCsrid(tls, (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal, iCsrId) + if pCsr == uintptr(0) || ((*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 0 || (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan == int32(FTS5_PLAN_SPECIAL)) { + _fts5ResultError(tls, context, __ccgo_ts+40353, libc.VaList(bp+8, iCsrId)) + } else { + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + _fts5ApiInvoke(tls, pAux, pCsr, context, argc-int32(1), argv+1*8) + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer(pTab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer(pTab)).FzErrMsg = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Create an "ascii" tokenizer. +// */ +func _fts5AsciiCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + var i, rc int32 + var p, zArg uintptr + _, _, _, _ = i, p, rc, zArg + rc = SQLITE_OK + p = uintptr(0) + _ = pUnused + if nArg%int32(2) != 0 { + rc = int32(SQLITE_ERROR) + } else { + p = Xsqlite3_malloc64(tls, uint64(128)) + if p == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, p, 0, uint64(128)) + libc.Xmemcpy(tls, p, uintptr(unsafe.Pointer(&_aAsciiTokenChar)), uint64(128)) + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + zArg = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41765) { + _fts5AsciiAddExceptions(tls, p, zArg, int32(1)) + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41776) { + _fts5AsciiAddExceptions(tls, p, zArg, 0) + } else { + rc = int32(SQLITE_ERROR) + } + } + goto _1 + _1: + ; + i = i + int32(2) + } + if rc != SQLITE_OK { + _fts5AsciiDelete(tls, p) + p = uintptr(0) + } + } + } + **(**uintptr)(__ccgo_up(ppOut)) = p + return rc +} + +// C documentation +// +// /* +// ** Populate the Fts5Config.zContentExprlist string. +// */ +func _fts5ConfigMakeExprlist(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var _ /* buf at bp+8 */ TFts5Buffer + var _ /* rc at bp+0 */ int32 + _ = i + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TFts5Buffer)(__ccgo_up(bp + 8)) = TFts5Buffer{} + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+37975, libc.VaList(bp+32, (*TFts5Config)(unsafe.Pointer(p)).FzContentRowid)) + if (*TFts5Config)(unsafe.Pointer(p)).FeContent != int32(FTS5_CONTENT_NONE) { + i = 0 + for { + if !(i < (*TFts5Config)(unsafe.Pointer(p)).FnCol) { + break + } + if (*TFts5Config)(unsafe.Pointer(p)).FeContent == int32(FTS5_CONTENT_EXTERNAL) { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+37980, libc.VaList(bp+32, **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)))) + } else { + if (*TFts5Config)(unsafe.Pointer(p)).FeContent == FTS5_CONTENT_NORMAL || **(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr(i))) != 0 { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+37987, libc.VaList(bp+32, i)) + } else { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+37995, 0) + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + if (*TFts5Config)(unsafe.Pointer(p)).FeContent == FTS5_CONTENT_NORMAL && (*TFts5Config)(unsafe.Pointer(p)).FbLocale != 0 { + i = 0 + for { + if !(i < (*TFts5Config)(unsafe.Pointer(p)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr(i)))) == 0 { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+38002, libc.VaList(bp+32, i)) + } else { + _sqlite3Fts5BufferAppendPrintf(tls, bp, bp+8, __ccgo_ts+37995, 0) + } + goto _2 + _2: + ; + i = i + 1 + } + } + (*TFts5Config)(unsafe.Pointer(p)).FzContentExprlist = (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5ConfigParseColumn(tls *libc.TLS, p uintptr, zCol uintptr, zArg uintptr, pzErr uintptr, pbUnindexed uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc, v1 int32 + var v2 uintptr + _, _, _ = rc, v1, v2 + rc = SQLITE_OK + if 0 == Xsqlite3_stricmp(tls, zCol, __ccgo_ts+37899) || 0 == Xsqlite3_stricmp(tls, zCol, __ccgo_ts+17963) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37904, libc.VaList(bp+8, zCol)) + rc = int32(SQLITE_ERROR) + } else { + if zArg != 0 { + if 0 == Xsqlite3_stricmp(tls, zArg, __ccgo_ts+37934) { + **(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr((*TFts5Config)(unsafe.Pointer(p)).FnCol))) = uint8(1) + **(**int32)(__ccgo_up(pbUnindexed)) = int32(1) + } else { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37944, libc.VaList(bp+8, zArg)) + rc = int32(SQLITE_ERROR) + } + } + } + v2 = p + 32 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(p)).FazCol + uintptr(v1)*8)) = zCol + return rc +} + +// C documentation +// +// /* +// ** +// ** This function is called when the user attempts an UPDATE on a contentless +// ** table. Parameter bRowidModified is true if the UPDATE statement modifies +// ** the rowid value. Parameter apVal[] contains the new values for each user +// ** defined column of the fts5 table. pConfig is the configuration object of the +// ** table being updated (guaranteed to be contentless). The contentless_delete=1 +// ** and contentless_unindexed=1 options may or may not be set. +// ** +// ** This function returns SQLITE_OK if the UPDATE can go ahead, or an SQLite +// ** error code if it cannot. In this case an error message is also loaded into +// ** pConfig. Output parameter (*pbContent) is set to true if the caller should +// ** update the %_content table only - not the FTS index or any other shadow +// ** table. This occurs when an UPDATE modifies only UNINDEXED columns of the +// ** table. +// ** +// ** An UPDATE may proceed if: +// ** +// ** * The only columns modified are UNINDEXED columns, or +// ** +// ** * The contentless_delete=1 option was specified and all of the indexed +// ** columns (not a subset) have been modified. +// */ +func _fts5ContentlessUpdate(tls *libc.TLS, pConfig uintptr, apVal uintptr, bRowidModified int32, pbContent uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bSeenIndex, bSeenIndexNC, ii, rc int32 + var v2 uintptr + _, _, _, _, _ = bSeenIndex, bSeenIndexNC, ii, rc, v2 + bSeenIndex = 0 /* Have seen modified indexed column */ + bSeenIndexNC = 0 /* Have seen unmodified indexed column */ + rc = SQLITE_OK + ii = 0 + for { + if !(ii < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(ii)))) == 0 { + if Xsqlite3_value_nochange(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(ii)*8))) != 0 { + bSeenIndexNC = bSeenIndexNC + 1 + } else { + bSeenIndex = bSeenIndex + 1 + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + if bSeenIndex == 0 && bRowidModified == 0 { + **(**int32)(__ccgo_up(pbContent)) = int32(1) + } else { + if bSeenIndexNC != 0 || (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete == 0 { + rc = int32(SQLITE_ERROR) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete != 0 { + v2 = __ccgo_ts + 40112 + } else { + v2 = __ccgo_ts + 40172 + } + _sqlite3Fts5ConfigErrmsg(tls, pConfig, v2, libc.VaList(bp+8, __ccgo_ts+40202, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + } + return rc +} + +func _fts5CursorFirstSorted(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int32) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var nByte Tsqlite3_int64 + var nPhrase, rc int32 + var pConfig, pSorter, zRank, zRankArgs, v1, v2, v3 uintptr + _, _, _, _, _, _, _, _, _, _ = nByte, nPhrase, pConfig, pSorter, rc, zRank, zRankArgs, v1, v2, v3 + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + zRank = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank + zRankArgs = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs + nPhrase = _sqlite3Fts5ExprPhraseCount(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+24) + libc.Uint64FromInt32((nPhrase+libc.Int32FromInt32(2))/libc.Int32FromInt32(2))*libc.Uint64FromInt64(8)) + pSorter = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pSorter == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pSorter, 0, libc.Uint64FromInt64(nByte)) + (*TFts5Sorter)(unsafe.Pointer(pSorter)).FnIdx = nPhrase + /* TODO: It would be better to have some system for reusing statement + ** handles here, rather than preparing a new one for each query. But that + ** is not possible as SQLite reference counts the virtual table objects. + ** And since the statement required here reads from this very virtual + ** table, saving it creates a circular reference. + ** + ** If SQLite a built-in statement cache, this wouldn't be a problem. */ + if zRankArgs != 0 { + v1 = __ccgo_ts + 16214 + } else { + v1 = __ccgo_ts + 1704 + } + if zRankArgs != 0 { + v2 = zRankArgs + } else { + v2 = __ccgo_ts + 1704 + } + if bDesc != 0 { + v3 = __ccgo_ts + 39686 + } else { + v3 = __ccgo_ts + 39691 + } + rc = _fts5PrepareStatement(tls, pSorter, pConfig, __ccgo_ts+39695, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zRank, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, v1, v2, v3)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = pSorter + if rc == SQLITE_OK { + (*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = pCsr + rc = _fts5SorterNext(tls, pCsr) + (*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = uintptr(0) + } + if rc != SQLITE_OK { + Xsqlite3_finalize(tls, (*TFts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) + Xsqlite3_free(tls, pSorter) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = uintptr(0) + } + return rc +} + +func _fts5CursorParseRank(tls *libc.TLS, pConfig uintptr, pCsr uintptr, pRank uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc int32 + var z uintptr + var _ /* zRank at bp+0 */ uintptr + var _ /* zRankArgs at bp+8 */ uintptr + _, _ = rc, z + rc = SQLITE_OK + if pRank != 0 { + z = Xsqlite3_value_text(tls, pRank) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if z == uintptr(0) { + if Xsqlite3_value_type(tls, pRank) == int32(SQLITE_NULL) { + rc = int32(SQLITE_ERROR) + } + } else { + rc = _sqlite3Fts5ConfigParseRank(tls, z, bp, bp+8) + } + if rc == SQLITE_OK { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank = **(**uintptr)(__ccgo_up(bp)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = **(**uintptr)(__ccgo_up(bp + 8)) + **(**int32)(__ccgo_up(pCsr + 80)) |= int32(FTS5CSR_FREE_ZRANK) + } else { + if rc == int32(SQLITE_ERROR) { + (*Tsqlite3_vtab)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+39815, libc.VaList(bp+24, z)) + } + } + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank = (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = (*TFts5Config)(unsafe.Pointer(pConfig)).FzRankArgs + } else { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank = __ccgo_ts + 37317 + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = uintptr(0) + } + } + return rc +} + +// C documentation +// +// /* +// ** Execute the following SQL: +// ** +// ** DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast +// */ +func _fts5DataDelete(tls *libc.TLS, p uintptr, iFirst Ti64, iLast Ti64) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pConfig, zSql uintptr + _, _ = pConfig, zSql + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return + } + if (*TFts5Index)(unsafe.Pointer(p)).FpDeleter == uintptr(0) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+38930, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + if _fts5IndexPrepareStmt(tls, p, p+88, zSql) != 0 { + return + } + } + Xsqlite3_bind_int64(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter, int32(1), iFirst) + Xsqlite3_bind_int64(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter, int32(2), iLast) + Xsqlite3_step(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter) + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter) +} + +// C documentation +// +// /* +// ** Retrieve a record from the %_data table. +// ** +// ** If an error occurs, NULL is returned and an error left in the +// ** Fts5Index object. +// */ +func _fts5DataRead(tls *libc.TLS, p uintptr, iRowid Ti64) (r uintptr) { + var aOut, pBlob, pConfig, pRet, v1 uintptr + var nAlloc, nByte, szData Ti64 + var rc int32 + _, _, _, _, _, _, _, _, _ = aOut, nAlloc, nByte, pBlob, pConfig, pRet, rc, szData, v1 + pRet = uintptr(0) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rc = SQLITE_OK + if (*TFts5Index)(unsafe.Pointer(p)).FpReader != 0 { + /* This call may return SQLITE_ABORT if there has been a savepoint + ** rollback since it was last used. In this case a new blob handle + ** is required. */ + pBlob = (*TFts5Index)(unsafe.Pointer(p)).FpReader + (*TFts5Index)(unsafe.Pointer(p)).FpReader = uintptr(0) + rc = Xsqlite3_blob_reopen(tls, pBlob, iRowid) + (*TFts5Index)(unsafe.Pointer(p)).FpReader = pBlob + if rc != SQLITE_OK { + _fts5IndexCloseReader(tls, p) + } + if rc == int32(SQLITE_ABORT) { + rc = SQLITE_OK + } + } + /* If the blob handle is not open at this point, open it and seek + ** to the requested entry. */ + if (*TFts5Index)(unsafe.Pointer(p)).FpReader == uintptr(0) && rc == SQLITE_OK { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + rc = Xsqlite3_blob_open(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Index)(unsafe.Pointer(p)).FzDataTbl, __ccgo_ts+38873, iRowid, 0, p+72) + } + /* If either of the sqlite3_blob_open() or sqlite3_blob_reopen() calls + ** above returned SQLITE_ERROR, return SQLITE_CORRUPT_VTAB instead. + ** All the reasons those functions might return SQLITE_ERROR - missing + ** table, missing row, non-blob/text in block column - indicate + ** backing store corruption. */ + if rc == int32(SQLITE_ERROR) { + rc = _fts5IndexCorruptRowid(tls, p, iRowid) + } + if rc == SQLITE_OK { + aOut = uintptr(0) /* Read blob data into this buffer */ + nByte = int64(Xsqlite3_blob_bytes(tls, (*TFts5Index)(unsafe.Pointer(p)).FpReader)) + szData = libc.Int64FromUint64((libc.Uint64FromInt64(16) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + nAlloc = szData + nByte + int64(FTS5_DATA_PADDING) + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nAlloc)) + if pRet != 0 { + (*TFts5Data)(unsafe.Pointer(pRet)).Fnn = int32(nByte) + v1 = pRet + uintptr(szData) + (*TFts5Data)(unsafe.Pointer(pRet)).Fp = v1 + aOut = v1 + } else { + rc = int32(SQLITE_NOMEM) + } + if rc == SQLITE_OK { + rc = Xsqlite3_blob_read(tls, (*TFts5Index)(unsafe.Pointer(p)).FpReader, aOut, int32(nByte), 0) + } + if rc != SQLITE_OK { + Xsqlite3_free(tls, pRet) + pRet = uintptr(0) + } else { + /* TODO1: Fix this */ + **(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(nByte))) = uint8(0x00) + **(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(nByte+int64(1)))) = uint8(0x00) + (*TFts5Data)(unsafe.Pointer(pRet)).FszLeaf = libc.Int32FromUint16(_fts5GetU16(tls, (*TFts5Data)(unsafe.Pointer(pRet)).Fp+2)) + } + } + (*TFts5Index)(unsafe.Pointer(p)).Frc = rc + (*TFts5Index)(unsafe.Pointer(p)).FnRead = (*TFts5Index)(unsafe.Pointer(p)).FnRead + 1 + } + return pRet +} + +// C documentation +// +// /* +// ** Remove all records associated with segment iSegid. +// */ +func _fts5DataRemoveSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iFirst, iLast, iTomb1, iTomb2 Ti64 + var iSegid int32 + var pConfig uintptr + _, _, _, _, _, _ = iFirst, iLast, iSegid, iTomb1, iTomb2, pConfig + iSegid = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid + iFirst = int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnCount})))(tls, pFts) { + Xsqlite3_result_error_code(tls, pCtx, int32(SQLITE_RANGE)) + return + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnLocale})))(tls, pFts, iCol, bp, bp+8) + if rc != SQLITE_OK { + Xsqlite3_result_error_code(tls, pCtx, rc) + return + } + Xsqlite3_result_text(tls, pCtx, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), uintptr(-libc.Int32FromInt32(1))) +} + +// C documentation +// +// /* +// ** Append text to the HighlightContext output string - p->zOut. Argument +// ** z points to a buffer containing n bytes of text to append. If n is +// ** negative, everything up until the first '\0' is appended to the output. +// ** +// ** If *pRc is set to any value other than SQLITE_OK when this function is +// ** called, it is a no-op. If an error (i.e. an OOM condition) is encountered, +// ** *pRc is set to an error code before returning. +// */ +func _fts5HighlightAppend(tls *libc.TLS, pRc uintptr, p uintptr, z uintptr, n int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK && z != 0 { + if n < 0 { + n = libc.Int32FromUint64(libc.Xstrlen(tls, z)) + } + (*THighlightContext)(unsafe.Pointer(p)).FzOut = Xsqlite3_mprintf(tls, __ccgo_ts+37080, libc.VaList(bp+8, (*THighlightContext)(unsafe.Pointer(p)).FzOut, n, z)) + if (*THighlightContext)(unsafe.Pointer(p)).FzOut == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } +} + +// C documentation +// +// /* +// ** Implementation of highlight() function. +// */ +func _fts5HighlightFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var iCol int32 + var zErr uintptr + var _ /* ctx at bp+0 */ THighlightContext + var _ /* nLoc at bp+120 */ int32 + var _ /* pLoc at bp+112 */ uintptr + var _ /* rc at bp+104 */ int32 + _, _ = iCol, zErr + if nVal != int32(3) { + zErr = __ccgo_ts + 37087 + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + return + } + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apVal))) + libc.Xmemset(tls, bp, 0, uint64(104)) + (**(**THighlightContext)(__ccgo_up(bp))).FzOpen = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + (**(**THighlightContext)(__ccgo_up(bp))).FzClose = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + 2*8))) + (**(**THighlightContext)(__ccgo_up(bp))).FiRangeEnd = -int32(1) + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})))(tls, pFts, iCol, bp+24, bp+32) + if **(**int32)(__ccgo_up(bp + 104)) == int32(SQLITE_RANGE) { + Xsqlite3_result_text(tls, pCtx, __ccgo_ts+1704, -int32(1), libc.UintptrFromInt32(0)) + **(**int32)(__ccgo_up(bp + 104)) = SQLITE_OK + } else { + if (**(**THighlightContext)(__ccgo_up(bp))).FzIn != 0 { + **(**uintptr)(__ccgo_up(bp + 112)) = uintptr(0) /* Locale of column iCol */ + **(**int32)(__ccgo_up(bp + 120)) = 0 /* Size of pLoc in bytes */ + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = _fts5CInstIterInit(tls, pApi, pFts, iCol, bp+40) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnLocale})))(tls, pFts, iCol, bp+112, bp+120) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize_v2})))(tls, pFts, (**(**THighlightContext)(__ccgo_up(bp))).FzIn, (**(**THighlightContext)(__ccgo_up(bp))).FnIn, **(**uintptr)(__ccgo_up(bp + 112)), **(**int32)(__ccgo_up(bp + 120)), bp, __ccgo_fp(_fts5HighlightCb)) + } + if (**(**THighlightContext)(__ccgo_up(bp))).FbOpen != 0 { + _fts5HighlightAppend(tls, bp+104, bp, (**(**THighlightContext)(__ccgo_up(bp))).FzClose, -int32(1)) + } + _fts5HighlightAppend(tls, bp+104, bp, (**(**THighlightContext)(__ccgo_up(bp))).FzIn+uintptr((**(**THighlightContext)(__ccgo_up(bp))).FiOff), (**(**THighlightContext)(__ccgo_up(bp))).FnIn-(**(**THighlightContext)(__ccgo_up(bp))).FiOff) + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + Xsqlite3_result_text(tls, pCtx, (**(**THighlightContext)(__ccgo_up(bp))).FzOut, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } + Xsqlite3_free(tls, (**(**THighlightContext)(__ccgo_up(bp))).FzOut) + } + } + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + Xsqlite3_result_error_code(tls, pCtx, **(**int32)(__ccgo_up(bp + 104))) + } +} + +/* +** End of highlight() implementation. +**************************************************************************/ + +// C documentation +// +// /* +// ** SQL used by fts5SegIterNextInit() to find the page to open. +// */ +func _fts5IdxNextStmt(tls *libc.TLS, p uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pConfig uintptr + _ = pConfig + if (*TFts5Index)(unsafe.Pointer(p)).FpIdxNextSelect == uintptr(0) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + _fts5IndexPrepareStmt(tls, p, p+120, Xsqlite3_mprintf(tls, __ccgo_ts+39177, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))) + } + return (*TFts5Index)(unsafe.Pointer(p)).FpIdxNextSelect +} + +func _fts5IdxSelectStmt(tls *libc.TLS, p uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pConfig uintptr + _ = pConfig + if (*TFts5Index)(unsafe.Pointer(p)).FpIdxSelect == uintptr(0) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + _fts5IndexPrepareStmt(tls, p, p+112, Xsqlite3_mprintf(tls, __ccgo_ts+39093, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))) + } + return (*TFts5Index)(unsafe.Pointer(p)).FpIdxSelect +} + +func _fts5IndexDataVersion(tls *libc.TLS, p uintptr) (r Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iVersion Ti64 + _ = iVersion + iVersion = 0 + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*TFts5Index)(unsafe.Pointer(p)).FpDataVersion == uintptr(0) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = _fts5IndexPrepareStmt(tls, p, p+144, Xsqlite3_mprintf(tls, __ccgo_ts+39070, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FzDb))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return 0 + } + } + if int32(SQLITE_ROW) == Xsqlite3_step(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDataVersion) { + iVersion = Xsqlite3_column_int64(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDataVersion, 0) + } + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDataVersion) + } + return iVersion +} + +func _fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bIdxDlidx, bSecureDelete, iDlidxPrevLeaf, iIdxLeaf, iIdxPrevLeaf, iOff, iPg, iPrevLeaf, iRowidOff, iRowidOff1, iSegid, nIdxTerm, rc2, res, v1, v2, v3 int32 + var iDlRowid, iKey, iRow Ti64 + var pConfig, pDlidx, pLeaf, zIdxTerm uintptr + var _ /* iRowid at bp+16 */ Ti64 + var _ /* nTerm at bp+8 */ int32 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bIdxDlidx, bSecureDelete, iDlRowid, iDlidxPrevLeaf, iIdxLeaf, iIdxPrevLeaf, iKey, iOff, iPg, iPrevLeaf, iRow, iRowidOff, iRowidOff1, iSegid, nIdxTerm, pConfig, pDlidx, pLeaf, rc2, res, zIdxTerm, v1, v2, v3 + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + bSecureDelete = libc.BoolInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FiVersion == int32(FTS5_CURRENT_VERSION_SECUREDELETE)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + iIdxPrevLeaf = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst - int32(1) + iDlidxPrevLeaf = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst == 0 { + return + } + _fts5IndexPrepareStmt(tls, p, bp, Xsqlite3_mprintf(tls, __ccgo_ts+39517, libc.VaList(bp+32, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid))) + /* Iterate through the b-tree hierarchy. */ + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { /* Data for this leaf */ + zIdxTerm = Xsqlite3_column_blob(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + nIdxTerm = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + iIdxLeaf = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(2)) + bIdxDlidx = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) + /* If the leaf in question has already been trimmed from the segment, + ** ignore this b-tree entry. Otherwise, load it into memory. */ + if iIdxLeaf < (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { + continue + } + iRow = int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= iOff || iOff >= (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + _fts5IndexCorruptRowid(tls, p, iRow) + } else { + iOff = iOff + _sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+8) + if **(**int32)(__ccgo_up(bp + 8)) < nIdxTerm { + v2 = **(**int32)(__ccgo_up(bp + 8)) + } else { + v2 = nIdxTerm + } + if v2 <= 0 { + v1 = 0 + } else { + if **(**int32)(__ccgo_up(bp + 8)) < nIdxTerm { + v3 = **(**int32)(__ccgo_up(bp + 8)) + } else { + v3 = nIdxTerm + } + v1 = libc.Xmemcmp(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), zIdxTerm, libc.Uint64FromInt32(v3)) + } + res = v1 + if res == 0 { + res = **(**int32)(__ccgo_up(bp + 8)) - nIdxTerm + } + if res < 0 { + _fts5IndexCorruptRowid(tls, p, iRow) + } + } + _fts5IntegrityCheckPgidx(tls, p, iRow, pLeaf) + } + _fts5DataRelease(tls, pLeaf) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + /* Now check that the iter.nEmpty leaves following the current leaf + ** (a) exist and (b) contain no terms. */ + _fts5IndexIntegrityCheckEmpty(tls, p, pSeg, iIdxPrevLeaf+int32(1), iDlidxPrevLeaf+int32(1), iIdxLeaf-int32(1)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + /* If there is a doclist-index, check that it looks right. */ + if bIdxDlidx != 0 { + pDlidx = uintptr(0) /* For iterating through doclist index */ + iPrevLeaf = iIdxLeaf + iSegid = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid + iPg = 0 + pDlidx = _fts5DlidxIterInit(tls, p, 0, iSegid, iIdxLeaf) + for { + if !(_fts5DlidxIterEof(tls, p, pDlidx) == 0) { + break + } + /* Check any rowid-less pages that occur before the current leaf. */ + iPg = iPrevLeaf + int32(1) + for { + if !(iPg < _fts5DlidxIterPgno(tls, pDlidx)) { + break + } + iKey = int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + _fts5IndexCorruptRowid(tls, p, iKey) + } else { + if bSecureDelete == 0 || iRowidOff1 > 0 { + iDlRowid = _fts5DlidxIterRowid(tls, pDlidx) + _sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iRowidOff1), bp+16) + if **(**Ti64)(__ccgo_up(bp + 16)) < iDlRowid || bSecureDelete == 0 && **(**Ti64)(__ccgo_up(bp + 16)) != iDlRowid { + _fts5IndexCorruptRowid(tls, p, iKey) + } + } + } + _fts5DataRelease(tls, pLeaf) + } + goto _4 + _4: + ; + _fts5DlidxIterNext(tls, p, pDlidx) + } + iDlidxPrevLeaf = iPg + _fts5DlidxIterFree(tls, pDlidx) + } else { + iDlidxPrevLeaf = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast + /* TODO: Check there is no doclist index */ + } + iIdxPrevLeaf = iIdxLeaf + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*TFts5Index)(unsafe.Pointer(p)).Frc = rc2 + } + /* Page iter.iLeaf must now be the rightmost leaf-page in the segment */ +} + +func _fts5Init(tls *libc.TLS, db uintptr) (r int32) { + var p, pGlobal uintptr + var rc int32 + _, _, _ = p, pGlobal, rc + pGlobal = uintptr(0) + pGlobal = Xsqlite3_malloc64(tls, uint64(112)) + if pGlobal == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + p = pGlobal + libc.Xmemset(tls, pGlobal, 0, uint64(112)) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fdb = db + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FiVersion = int32(3) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxCreateFunction = __ccgo_fp(_fts5CreateAux) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxCreateTokenizer = __ccgo_fp(_fts5CreateTokenizer) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxFindTokenizer = __ccgo_fp(_fts5FindTokenizer) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxCreateTokenizer_v2 = __ccgo_fp(_fts5CreateTokenizer_v2) + (*TFts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxFindTokenizer_v2 = __ccgo_fp(_fts5FindTokenizer_v2) + /* Initialize pGlobal->aLocaleHdr[] to a 128-bit pseudo-random vector. + ** The constants below were generated randomly. */ + Xsqlite3_randomness(tls, int32(16), pGlobal+96) + **(**Tu32)(__ccgo_up(pGlobal + 96)) ^= uint32(0xF924976D) + **(**Tu32)(__ccgo_up(pGlobal + 96 + 1*4)) ^= uint32(0x16596E13) + **(**Tu32)(__ccgo_up(pGlobal + 96 + 2*4)) ^= uint32(0x7C80BEAA) + **(**Tu32)(__ccgo_up(pGlobal + 96 + 3*4)) ^= uint32(0x9B03A67F) + rc = Xsqlite3_create_module_v2(tls, db, __ccgo_ts+40647, uintptr(unsafe.Pointer(&_fts5Mod)), p, __ccgo_fp(_fts5ModuleDestroy)) + if rc == SQLITE_OK { + rc = _sqlite3Fts5IndexInit(tls, db) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprInit(tls, pGlobal, db) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5AuxInit(tls, pGlobal) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5TokenizerInit(tls, pGlobal) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5VocabInit(tls, pGlobal, db) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+40647, int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_fts5Fts5Func), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+40652, 0, libc.Int32FromInt32(SQLITE_UTF8)|libc.Int32FromInt32(SQLITE_DETERMINISTIC)|libc.Int32FromInt32(SQLITE_INNOCUOUS), p, __ccgo_fp(_fts5SourceIdFunc), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+40667, int32(2), libc.Int32FromInt32(SQLITE_UTF8)|libc.Int32FromInt32(SQLITE_INNOCUOUS)|libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE)|libc.Int32FromInt32(SQLITE_SUBTYPE), p, __ccgo_fp(_fts5LocaleFunc), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+40679, int32(1), libc.Int32FromInt32(SQLITE_UTF8)|libc.Int32FromInt32(SQLITE_INNOCUOUS)|libc.Int32FromInt32(SQLITE_RESULT_SUBTYPE), p, __ccgo_fp(_fts5InsttokenFunc), uintptr(0), uintptr(0)) + } + } + /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file + ** fts5_test_mi.c is compiled and linked into the executable. And call + ** its entry point to enable the matchinfo() demo. */ + return rc +} + +// C documentation +// +// /* +// ** Create a "porter" tokenizer. +// */ +func _fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var az2, pApi, pRet, zBase, v2 uintptr + var nArg2, rc, v1 int32 + var _ /* pUserdata at bp+0 */ uintptr + var _ /* pV2 at bp+8 */ uintptr + _, _, _, _, _, _, _, _ = az2, nArg2, pApi, pRet, rc, zBase, v1, v2 + pApi = pCtx + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zBase = __ccgo_ts + 41825 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + for nArg > 0 { + if Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg)), __ccgo_ts+41835) == 0 { + nArg = nArg - 1 + azArg += 8 + } else { + zBase = **(**uintptr)(__ccgo_up(azArg)) + break + } + } + pRet = Xsqlite3_malloc64(tls, uint64(168)) + if pRet != 0 { + libc.Xmemset(tls, pRet, 0, uint64(168)) + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfts5_api)(unsafe.Pointer(pApi)).FxFindTokenizer_v2})))(tls, pApi, zBase, bp, bp+8) + } else { + rc = int32(SQLITE_NOMEM) + } + if rc == SQLITE_OK { + if nArg > 0 { + v1 = nArg - int32(1) + } else { + v1 = 0 + } + nArg2 = v1 + if nArg2 != 0 { + v2 = azArg + 1*8 + } else { + v2 = uintptr(0) + } + az2 = v2 + libc.Xmemcpy(tls, pRet, **(**uintptr)(__ccgo_up(bp + 8)), uint64(32)) + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterTokenizer)(unsafe.Pointer(pRet)).Ftokenizer_v2.FxCreate})))(tls, **(**uintptr)(__ccgo_up(bp)), az2, nArg2, pRet+32) + } + if rc != SQLITE_OK { + _fts5PorterDelete(tls, pRet) + pRet = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppOut)) = pRet + return rc +} + +// C documentation +// +// /* +// ** Execute the SQL statement: +// ** +// ** DELETE FROM %_idx WHERE (segid, (pgno/2)) = ($iSegid, $iPgno); +// ** +// ** This is used when a secure-delete operation removes the last term +// ** from a segment leaf page. In that case the %_idx entry is removed +// ** too. This is done to ensure that if all instances of a token are +// ** removed from an fts5 database in secure-delete mode, no trace of +// ** the token itself remains in the database. +// */ +func _fts5SecureDeleteIdxEntry(tls *libc.TLS, p uintptr, iSegid int32, iPgno int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + if iPgno != int32(1) { + if (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx == uintptr(0) { + _fts5IndexPrepareStmt(tls, p, p+136, Xsqlite3_mprintf(tls, __ccgo_ts+39316, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FzDb, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FzName))) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_bind_int(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx, int32(1), iSegid) + Xsqlite3_bind_int(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx, int32(2), iPgno) + Xsqlite3_step(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx) + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx) + } + } +} + +// C documentation +// +// /* +// ** If the cursor requires seeking (bSeekRequired flag is set), seek it. +// ** Return SQLITE_OK if no error occurs, or an SQLite error code otherwise. +// ** +// ** If argument bErrormsg is true and an error occurs, an error message may +// ** be left in sqlite3_vtab.zErrMsg. +// */ +func _fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eStmt, rc int32 + var pTab, pTab1, v1 uintptr + _, _, _, _, _ = eStmt, pTab, pTab1, rc, v1 + rc = SQLITE_OK + /* If the cursor does not yet have a statement handle, obtain one now. */ + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt == uintptr(0) { + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + eStmt = _fts5StmtType(tls, pCsr) + if bErrormsg != 0 { + v1 = pTab + 16 + } else { + v1 = uintptr(0) + } + rc = _sqlite3Fts5StorageStmt(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, eStmt, pCsr+56, v1) + } + if rc == SQLITE_OK && (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_CONTENT) != 0 { + pTab1 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + Xsqlite3_reset(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + Xsqlite3_bind_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1), _fts5CursorRowid(tls, pCsr)) + (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab1)).FpConfig)).FbLock = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab1)).FpConfig)).FbLock + 1 + rc = Xsqlite3_step(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab1)).FpConfig)).FbLock = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab1)).FpConfig)).FbLock - 1 + if rc == int32(SQLITE_ROW) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(pCsr + 80)) &= ^libc.Int32FromInt32(FTS5CSR_REQUIRE_CONTENT) + } else { + rc = Xsqlite3_reset(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + if rc == SQLITE_OK { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= 0) { + break + } + pSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr(iSeg)*56 + bDone = 0 + if pPrevIter != 0 { + if _fts5BufferCompare(tls, pSmall, pPrevIter+96) != 0 { + libc.Xmemcpy(tls, pNewIter, pPrevIter, uint64(128)) + libc.Xmemset(tls, pPrevIter, 0, uint64(128)) + bDone = int32(1) + } else { + if (*TFts5SegIter)(unsafe.Pointer(pPrevIter)).FiEndofDoclist > (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pPrevIter)).FpLeaf)).FszLeaf { + _fts5SegIterNextInit(tls, p, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn-int32(1), pSeg, pNewIter) + bDone = int32(1) + } + } + } + if bDone == 0 { + _fts5SegIterSeekInit(tls, p, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn, flags, pSeg, pNewIter) + } + if pPrevIter != 0 { + if (*TFts5SegIter)(unsafe.Pointer(pPrevIter)).FpTombArray != 0 { + (*TFts5SegIter)(unsafe.Pointer(pNewIter)).FpTombArray = (*TFts5SegIter)(unsafe.Pointer(pPrevIter)).FpTombArray + (*TFts5TombstoneArray)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pNewIter)).FpTombArray)).FnRef = (*TFts5TombstoneArray)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pNewIter)).FpTombArray)).FnRef + 1 + } + } else { + _fts5SegIterAllocTombstone(tls, p, pNewIter) + } + pNewIter += 128 + if pPrevIter != 0 { + pPrevIter += 128 + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + goto _4 + _4: + ; + iSeg = iSeg - 1 + } + goto _3 + _3: + ; + iLvl = iLvl + 1 + } + _fts5TokendataSetTermIfEof(tls, pPrev, pSmall) + (*TFts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty = uint8(1) + (*TFts5Iter)(unsafe.Pointer(pNew)).FpColset = pColset + _fts5IterSetOutputCb(tls, p+60, pNew) + /* Loop through all segments in the new iterator. Find the smallest + ** term that any segment-iterator points to. Iterator pNew will be + ** used for this term. Also, set any iterator that points to a term that + ** does not match pToken/nToken to point to EOF */ + pSmall = uintptr(0) + ii = 0 + for { + if !(ii < (*TFts5Iter)(unsafe.Pointer(pNew)).FnSeg) { + break + } + pII = pNew + 104 + uintptr(ii)*128 + if 0 == _fts5IsTokendataPrefix(tls, pII+96, pToken, nToken) { + _fts5SegIterSetEOF(tls, pII) + } + if (*TFts5SegIter)(unsafe.Pointer(pII)).FpLeaf != 0 && (!(pSmall != 0) || _fts5BufferCompare(tls, pSmall, pII+96) > 0) { + pSmall = pII + 96 + } + goto _5 + _5: + ; + ii = ii + 1 + } + /* If pSmall is still NULL at this point, then the new iterator does + ** not point to any terms that match the query. So delete it and break + ** out of the loop - all required iterators have been collected. */ + if pSmall == uintptr(0) { + _fts5IterClose(tls, pNew) + break + } + /* Append this iterator to the set and continue. */ + pSet = _fts5AppendTokendataIter(tls, p, pSet, pNew) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && pSet != 0 { + ii1 = 0 + for { + if !(int64(ii1) < (*TFts5TokenDataIter)(unsafe.Pointer(pSet)).FnIter) { + break + } + pIter = *(*uintptr)(unsafe.Pointer(pSet + 72 + uintptr(ii1)*8)) + iSeg1 = 0 + for { + if !(iSeg1 < (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg) { + break + } + (*(*TFts5SegIter)(unsafe.Pointer(pIter + 104 + uintptr(iSeg1)*128))).Fflags |= int32(FTS5_SEGITER_ONETERM) + goto _7 + _7: + ; + iSeg1 = iSeg1 + 1 + } + _fts5MultiIterFinishSetup(tls, p, pIter) + goto _6 + _6: + ; + ii1 = ii1 + 1 + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pRet = _fts5MultiIterAlloc(tls, p, 0) + } + if pRet != 0 { + (*TFts5Iter)(unsafe.Pointer(pRet)).FnSeg = 0 + (*TFts5Iter)(unsafe.Pointer(pRet)).FpTokenDataIter = pSet + if pSet != 0 { + _fts5IterSetOutputsTokendata(tls, pRet) + } else { + (*TFts5Iter)(unsafe.Pointer(pRet)).Fbase.FbEof = uint8(1) + } + } else { + _fts5TokendataIterDelete(tls, pSet) + } + _fts5StructureRelease(tls, pStruct) + _sqlite3Fts5BufferFree(tls, bp) + return pRet +} + +// C documentation +// +// /* +// ** Implementation of snippet() function. +// */ +func _fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(208) + defer tls.Free(208) + var aSeen, zEllips, zErr uintptr + var i, iBestCol, iBestStart, iCol, ii, jj, nBestScore, nCol, nPhrase, nToken, v1 int32 + var _ /* ctx at bp+0 */ THighlightContext + var _ /* iAdj at bp+184 */ int32 + var _ /* ic at bp+176 */ int32 + var _ /* io at bp+180 */ int32 + var _ /* ip at bp+172 */ int32 + var _ /* nColSize at bp+112 */ int32 + var _ /* nDoc at bp+164 */ int32 + var _ /* nDocsize at bp+168 */ int32 + var _ /* nInst at bp+108 */ int32 + var _ /* nLoc at bp+160 */ int32 + var _ /* nLoc at bp+200 */ int32 + var _ /* nScore at bp+188 */ int32 + var _ /* pLoc at bp+152 */ uintptr + var _ /* pLoc at bp+192 */ uintptr + var _ /* rc at bp+104 */ int32 + var _ /* sFinder at bp+120 */ TFts5SFinder + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aSeen, i, iBestCol, iBestStart, iCol, ii, jj, nBestScore, nCol, nPhrase, nToken, zEllips, zErr, v1 + **(**int32)(__ccgo_up(bp + 104)) = SQLITE_OK /* 5th argument to snippet() */ + **(**int32)(__ccgo_up(bp + 108)) = 0 /* Column containing best snippet */ + iBestStart = 0 /* First token of best snippet */ + nBestScore = 0 /* Score of best snippet */ + **(**int32)(__ccgo_up(bp + 112)) = 0 + if nVal != int32(5) { + zErr = __ccgo_ts + 37137 + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + return + } + nCol = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnCount})))(tls, pFts) + libc.Xmemset(tls, bp, 0, uint64(104)) + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apVal))) + (**(**THighlightContext)(__ccgo_up(bp))).FzOpen = _fts5ValueToText(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + (**(**THighlightContext)(__ccgo_up(bp))).FzClose = _fts5ValueToText(tls, **(**uintptr)(__ccgo_up(apVal + 2*8))) + (**(**THighlightContext)(__ccgo_up(bp))).FiRangeEnd = -int32(1) + zEllips = _fts5ValueToText(tls, **(**uintptr)(__ccgo_up(apVal + 3*8))) + nToken = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apVal + 4*8))) + if iCol >= 0 { + v1 = iCol + } else { + v1 = 0 + } + iBestCol = v1 + nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseCount})))(tls, pFts) + aSeen = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nPhrase)) + if aSeen == uintptr(0) { + **(**int32)(__ccgo_up(bp + 104)) = int32(SQLITE_NOMEM) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})))(tls, pFts, bp+108) + } + libc.Xmemset(tls, bp+120, 0, uint64(32)) + i = 0 + for { + if !(i < nCol) { + break + } + if iCol < 0 || iCol == i { + **(**uintptr)(__ccgo_up(bp + 152)) = uintptr(0) /* Locale of column iCol */ + **(**int32)(__ccgo_up(bp + 160)) = 0 + (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FiPos = 0 + (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FnFirst = 0 + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})))(tls, pFts, i, bp+120+24, bp+164) + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + break + } + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnLocale})))(tls, pFts, i, bp+152, bp+160) + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + break + } + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize_v2})))(tls, pFts, (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FzDoc, **(**int32)(__ccgo_up(bp + 164)), **(**uintptr)(__ccgo_up(bp + 152)), **(**int32)(__ccgo_up(bp + 160)), bp+120, __ccgo_fp(_fts5SentenceFinderCb)) + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + break + } + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})))(tls, pFts, i, bp+168) + if **(**int32)(__ccgo_up(bp + 104)) != SQLITE_OK { + break + } + ii = 0 + for { + if !(**(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK && ii < **(**int32)(__ccgo_up(bp + 108))) { + break + } + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})))(tls, pFts, ii, bp+172, bp+176, bp+180) + if **(**int32)(__ccgo_up(bp + 176)) != i { + goto _3 + } + if **(**int32)(__ccgo_up(bp + 180)) > **(**int32)(__ccgo_up(bp + 168)) { + **(**int32)(__ccgo_up(bp + 104)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< nBestScore { + nBestScore = **(**int32)(__ccgo_up(bp + 188)) + iBestCol = i + iBestStart = **(**int32)(__ccgo_up(bp + 184)) + **(**int32)(__ccgo_up(bp + 112)) = **(**int32)(__ccgo_up(bp + 168)) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK && (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FnFirst != 0 && **(**int32)(__ccgo_up(bp + 168)) > nToken { + jj = 0 + for { + if !(jj < (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FnFirst-int32(1)) { + break + } + if **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj+int32(1))*4)) > **(**int32)(__ccgo_up(bp + 180)) { + break + } + goto _4 + _4: + ; + jj = jj + 1 + } + if **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj)*4)) < **(**int32)(__ccgo_up(bp + 180)) { + libc.Xmemset(tls, aSeen, 0, libc.Uint64FromInt32(nPhrase)) + **(**int32)(__ccgo_up(bp + 104)) = _fts5SnippetScore(tls, pApi, pFts, **(**int32)(__ccgo_up(bp + 168)), aSeen, i, **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj)*4)), nToken, bp+188, uintptr(0)) + if **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj)*4)) == 0 { + v1 = int32(120) + } else { + v1 = int32(100) + } + **(**int32)(__ccgo_up(bp + 188)) = **(**int32)(__ccgo_up(bp + 188)) + v1 + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK && **(**int32)(__ccgo_up(bp + 188)) > nBestScore { + nBestScore = **(**int32)(__ccgo_up(bp + 188)) + iBestCol = i + iBestStart = **(**int32)(__ccgo_up((**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst + uintptr(jj)*4)) + **(**int32)(__ccgo_up(bp + 112)) = **(**int32)(__ccgo_up(bp + 168)) + } + } + } + goto _3 + _3: + ; + ii = ii + 1 + } + } + goto _2 + _2: + ; + i = i + 1 + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})))(tls, pFts, iBestCol, bp+24, bp+32) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK && **(**int32)(__ccgo_up(bp + 112)) == 0 { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})))(tls, pFts, iBestCol, bp+112) + } + if (**(**THighlightContext)(__ccgo_up(bp))).FzIn != 0 { + **(**uintptr)(__ccgo_up(bp + 192)) = uintptr(0) /* Locale of column iBestCol */ + **(**int32)(__ccgo_up(bp + 200)) = 0 /* Bytes in pLoc */ + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = _fts5CInstIterInit(tls, pApi, pFts, iBestCol, bp+40) + } + (**(**THighlightContext)(__ccgo_up(bp))).FiRangeStart = iBestStart + (**(**THighlightContext)(__ccgo_up(bp))).FiRangeEnd = iBestStart + nToken - int32(1) + if iBestStart > 0 { + _fts5HighlightAppend(tls, bp+104, bp, zEllips, -int32(1)) + } + /* Advance iterator ctx.iter so that it points to the first coalesced + ** phrase instance at or following position iBestStart. */ + for (**(**THighlightContext)(__ccgo_up(bp))).Fiter.FiStart >= 0 && (**(**THighlightContext)(__ccgo_up(bp))).Fiter.FiStart < iBestStart && **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = _fts5CInstIterNext(tls, bp+40) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnLocale})))(tls, pFts, iBestCol, bp+192, bp+200) + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 104)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize_v2})))(tls, pFts, (**(**THighlightContext)(__ccgo_up(bp))).FzIn, (**(**THighlightContext)(__ccgo_up(bp))).FnIn, **(**uintptr)(__ccgo_up(bp + 192)), **(**int32)(__ccgo_up(bp + 200)), bp, __ccgo_fp(_fts5HighlightCb)) + } + if (**(**THighlightContext)(__ccgo_up(bp))).FbOpen != 0 { + _fts5HighlightAppend(tls, bp+104, bp, (**(**THighlightContext)(__ccgo_up(bp))).FzClose, -int32(1)) + } + if (**(**THighlightContext)(__ccgo_up(bp))).FiRangeEnd >= **(**int32)(__ccgo_up(bp + 112))-int32(1) { + _fts5HighlightAppend(tls, bp+104, bp, (**(**THighlightContext)(__ccgo_up(bp))).FzIn+uintptr((**(**THighlightContext)(__ccgo_up(bp))).FiOff), (**(**THighlightContext)(__ccgo_up(bp))).FnIn-(**(**THighlightContext)(__ccgo_up(bp))).FiOff) + } else { + _fts5HighlightAppend(tls, bp+104, bp, zEllips, -int32(1)) + } + } + if **(**int32)(__ccgo_up(bp + 104)) == SQLITE_OK { + Xsqlite3_result_text(tls, pCtx, (**(**THighlightContext)(__ccgo_up(bp))).FzOut, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_error_code(tls, pCtx, **(**int32)(__ccgo_up(bp + 104))) + } + Xsqlite3_free(tls, (**(**THighlightContext)(__ccgo_up(bp))).FzOut) + Xsqlite3_free(tls, aSeen) + Xsqlite3_free(tls, (**(**TFts5SFinder)(__ccgo_up(bp + 120))).FaFirst) +} + +/************************************************************************/ + +// C documentation +// +// /* +// ** Prepare the two insert statements - Fts5Storage.pInsertContent and +// ** Fts5Storage.pInsertDocsize - if they have not already been prepared. +// ** Return SQLITE_OK if successful, or an SQLite error code if an error +// ** occurs. +// */ +func _fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var azStmt [12]uintptr + var f, i int32 + var pC, zBind, zSql, v2 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _ = azStmt, f, i, pC, zBind, zSql, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + /* If there is no %_docsize table, there should be no requests for + ** statements to operate on it. */ + if **(**uintptr)(__ccgo_up(p + 48 + uintptr(eStmt)*8)) == uintptr(0) { + azStmt = [12]uintptr{ + 0: __ccgo_ts + 40694, + 1: __ccgo_ts + 40762, + 2: __ccgo_ts + 40831, + 3: __ccgo_ts + 40831, + 4: __ccgo_ts + 40864, + 5: __ccgo_ts + 40903, + 6: __ccgo_ts + 40943, + 7: __ccgo_ts + 40982, + 8: __ccgo_ts + 41025, + 9: __ccgo_ts + 41064, + 10: __ccgo_ts + 41108, + 11: __ccgo_ts + 41148, + } + pC = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + zSql = uintptr(0) + switch eStmt { + case int32(FTS5_STMT_SCAN): + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*TFts5Config)(unsafe.Pointer(pC)).FzContent)) + case FTS5_STMT_SCAN_ASC: + fallthrough + case int32(FTS5_STMT_SCAN_DESC): + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*TFts5Config)(unsafe.Pointer(pC)).FzContent, (*TFts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*TFts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*TFts5Config)(unsafe.Pointer(pC)).FzContentRowid)) + case int32(FTS5_STMT_LOOKUP): + fallthrough + case int32(FTS5_STMT_LOOKUP2): + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*TFts5Config)(unsafe.Pointer(pC)).FzContent, (*TFts5Config)(unsafe.Pointer(pC)).FzContentRowid)) + case int32(FTS5_STMT_INSERT_CONTENT): + fallthrough + case int32(FTS5_STMT_REPLACE_CONTENT): + zBind = uintptr(0) + /* Add bindings for the "c*" columns - those that store the actual + ** table content. If eContent==NORMAL, then there is one binding + ** for each column. Or, if eContent==UNINDEXED, then there are only + ** bindings for the UNINDEXED columns. */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < (*TFts5Config)(unsafe.Pointer(pC)).FnCol+int32(1)) { + break + } + if !(i != 0) || (*TFts5Config)(unsafe.Pointer(pC)).FeContent == FTS5_CONTENT_NORMAL || **(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pC)).FabUnindexed + uintptr(i-int32(1)))) != 0 { + if zBind != 0 { + v2 = __ccgo_ts + 14346 + } else { + v2 = __ccgo_ts + 1704 + } + zBind = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+41171, libc.VaList(bp+16, zBind, v2, i+int32(1))) + } + goto _1 + _1: + ; + i = i + 1 + } + /* Add bindings for any "l*" columns. Only non-UNINDEXED columns + ** require these. */ + if (*TFts5Config)(unsafe.Pointer(pC)).FbLocale != 0 && (*TFts5Config)(unsafe.Pointer(pC)).FeContent == FTS5_CONTENT_NORMAL { + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < (*TFts5Config)(unsafe.Pointer(pC)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pC)).FabUnindexed + uintptr(i)))) == 0 { + zBind = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+41179, libc.VaList(bp+16, zBind, (*TFts5Config)(unsafe.Pointer(pC)).FnCol+i+int32(2))) + } + goto _3 + _3: + ; + i = i + 1 + } + } + zSql = _sqlite3Fts5Mprintf(tls, bp, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzDb, (*TFts5Config)(unsafe.Pointer(pC)).FzName, zBind)) + Xsqlite3_free(tls, zBind) + case int32(FTS5_STMT_REPLACE_DOCSIZE): + if (*TFts5Config)(unsafe.Pointer(pC)).FbContentlessDelete != 0 { + v2 = __ccgo_ts + 41186 + } else { + v2 = __ccgo_ts + 1704 + } + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzDb, (*TFts5Config)(unsafe.Pointer(pC)).FzName, v2)) + case int32(FTS5_STMT_LOOKUP_DOCSIZE): + if (*TFts5Config)(unsafe.Pointer(pC)).FbContentlessDelete != 0 { + v2 = __ccgo_ts + 41189 + } else { + v2 = __ccgo_ts + 1704 + } + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, v2, (*TFts5Config)(unsafe.Pointer(pC)).FzDb, (*TFts5Config)(unsafe.Pointer(pC)).FzName)) + default: + zSql = Xsqlite3_mprintf(tls, azStmt[eStmt], libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pC)).FzDb, (*TFts5Config)(unsafe.Pointer(pC)).FzName)) + break + } + if zSql == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + f = int32(SQLITE_PREPARE_PERSISTENT) + if eStmt > int32(FTS5_STMT_LOOKUP2) { + f = f | int32(SQLITE_PREPARE_NO_VTAB) + } + (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock + 1 + **(**int32)(__ccgo_up(bp)) = Xsqlite3_prepare_v3(tls, (*TFts5Config)(unsafe.Pointer(pC)).Fdb, zSql, -int32(1), libc.Uint32FromInt32(f), p+48+uintptr(eStmt)*8, uintptr(0)) + (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock - 1 + Xsqlite3_free(tls, zSql) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK && pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, (*TFts5Config)(unsafe.Pointer(pC)).Fdb))) + } + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_ERROR) && eStmt > int32(FTS5_STMT_LOOKUP2) && eStmt < int32(FTS5_STMT_SCAN) { + /* One of the internal tables - not the %_content table - is missing. + ** This counts as a corrupted table. */ + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_CORRUPT) + } + } + } + **(**uintptr)(__ccgo_up(ppStmt)) = **(**uintptr)(__ccgo_up(p + 48 + uintptr(eStmt)*8)) + Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(ppStmt))) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Deserialize and return the structure record currently stored in serialized +// ** form within buffer pData/nData. +// ** +// ** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array +// ** are over-allocated by one slot. This allows the structure contents +// ** to be more easily edited. +// ** +// ** If an error occurs, *ppOut is set to NULL and an SQLite error code +// ** returned. Otherwise, *ppOut is set to point to the new object and +// ** SQLITE_OK returned. +// */ +func _fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bStructureV2, i, iLvl, iSeg int32 + var nByte Tsqlite3_int64 + var nOriginCntr Tu64 + var pLvl, pRet, pSeg uintptr + var v3 uint64 + var _ /* nLevel at bp+4 */ int32 + var _ /* nSegment at bp+8 */ int32 + var _ /* nTotal at bp+12 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = bStructureV2, i, iLvl, iSeg, nByte, nOriginCntr, pLvl, pRet, pSeg, v3 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + i = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = 0 /* Bytes of space to allocate at pRet */ + pRet = uintptr(0) /* Structure object to return */ + bStructureV2 = 0 /* True for FTS5_STRUCTURE_V2 */ + nOriginCntr = uint64(0) /* Largest origin value seen so far */ + /* Grab the cookie value */ + if piCookie != 0 { + **(**int32)(__ccgo_up(piCookie)) = _sqlite3Fts5Get32(tls, pData) + } + i = int32(4) + /* Check if this is a V2 structure record. Set bStructureV2 if it is. */ + if 0 == libc.Xmemcmp(tls, pData+uintptr(i), __ccgo_ts+39019, uint64(4)) { + i = i + int32(4) + bStructureV2 = int32(1) + } + /* Read the total number of levels and segments from the start of the + ** structure record. */ + i = i + _sqlite3Fts5GetVarint32(tls, pData+uintptr(i), bp+4) + i = i + _sqlite3Fts5GetVarint32(tls, pData+uintptr(i), bp+8) + if **(**int32)(__ccgo_up(bp + 4)) > int32(FTS5_MAX_SEGMENT) || **(**int32)(__ccgo_up(bp + 4)) < 0 || **(**int32)(__ccgo_up(bp + 8)) > int32(FTS5_MAX_SEGMENT) || **(**int32)(__ccgo_up(bp + 8)) < 0 { + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= nData { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= nData { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 { + v3 = nOriginCntr + } else { + v3 = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 + } + nOriginCntr = v3 + } + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast < (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< 0 && (**(**TFts5StructureLevel)(__ccgo_up(pLvl + uintptr(-libc.Int32FromInt32(1))*16))).FnMerge != 0 && **(**int32)(__ccgo_up(bp + 12)) == 0 { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< uint64(0) { + v1 = libc.Int32FromInt32(4) + libc.Int32FromInt32(4) + libc.Int32FromInt32(9) + libc.Int32FromInt32(9) + libc.Int32FromInt32(9) + } else { + v1 = libc.Int32FromInt32(4) + libc.Int32FromInt32(9) + libc.Int32FromInt32(9) + } /* Cookie value to store */ + nHdr = v1 + libc.Xmemset(tls, bp, 0, uint64(16)) + /* Append the current configuration cookie */ + iCookie = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FiCookie + if iCookie < 0 { + iCookie = 0 + } + if 0 == _sqlite3Fts5BufferSize(tls, p+60, bp, libc.Uint32FromInt32(nHdr)) { + _sqlite3Fts5Put32(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, iCookie) + (**(**TFts5Buffer)(__ccgo_up(bp))).Fn = int32(4) + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnOriginCntr > uint64(0) { + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp)).Fn), __ccgo_ts+39019, uint64(4)) + **(**int32)(__ccgo_up(bp + 8)) += int32(4) + } + **(**int32)(__ccgo_up(bp + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp)).Fn), libc.Uint64FromInt32((*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel)) + **(**int32)(__ccgo_up(bp + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp)).Fn), libc.Uint64FromInt32((*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment)) + **(**int32)(__ccgo_up(bp + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp)).Fn), libc.Uint64FromInt64(libc.Int64FromUint64((*TFts5Structure)(unsafe.Pointer(pStruct)).FnWriteCounter))) + } + iLvl = 0 + for { + if !(iLvl < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } /* Used to iterate through segments */ + pLvl = pStruct + 32 + uintptr(iLvl)*16 + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg)) + iSeg = 0 + for { + if !(iSeg < (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg) { + break + } + pSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*56 + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast)) + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnOriginCntr > uint64(0) { + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromUint64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin1)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromUint64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnPgTombstone)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromUint64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnEntryTombstone)) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromUint64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnEntry)) + } + goto _3 + _3: + ; + iSeg = iSeg + 1 + } + goto _2 + _2: + ; + iLvl = iLvl + 1 + } + _fts5DataWrite(tls, p, int64(FTS5_STRUCTURE_ROWID), (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn) + _sqlite3Fts5BufferFree(tls, bp) + } +} + +// C documentation +// +// /* +// ** This function is the implementation of the xUpdate callback used by +// ** FTS3 virtual tables. It is invoked by SQLite each time a row is to be +// ** inserted, updated or deleted. +// ** +// ** A delete specifies a single argument - the rowid of the row to remove. +// ** +// ** Update and insert operations pass: +// ** +// ** 1. The "old" rowid, or NULL. +// ** 2. The "new" rowid. +// ** 3. Values for each of the nCol matchable columns. +// ** 4. Values for the two hidden columns ( and "rank"). +// */ +func _fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eConflict, eType0, eType1, ii int32 + var iDel, iNew, iNew1, iOld Ti64 + var pConfig, pStorage, pTab, pVal, z uintptr + var _ /* bContent at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = eConflict, eType0, eType1, iDel, iNew, iNew1, iOld, ii, pConfig, pStorage, pTab, pVal, z + pTab = pVtab + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig /* value_type() of apVal[0] */ + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Return code */ + /* A transaction must be open when this is called. */ + if (*TFts5Config)(unsafe.Pointer(pConfig)).Fpgsz == 0 { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ConfigLoad(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig, (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FiCookie) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp)) + } + } + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = pTab + 16 + /* Put any active cursors into REQUIRE_SEEK state. */ + _fts5TripCursors(tls, pTab) + eType0 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apVal))) + if eType0 == int32(SQLITE_NULL) && Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(int32(2)+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*8))) != int32(SQLITE_NULL) { + /* A "special" INSERT op. These are handled separately. */ + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(int32(2)+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*8))) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL && 0 == Xsqlite3_stricmp(tls, __ccgo_ts+19150, z) { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete != 0 { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40216, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + **(**int32)(__ccgo_up(bp)) = _fts5SpecialDelete(tls, pTab, apVal) + } + } else { + **(**int32)(__ccgo_up(bp)) = _fts5SpecialInsert(tls, pTab, z, **(**uintptr)(__ccgo_up(apVal + uintptr(int32(2)+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol+int32(1))*8))) + } + } else { + /* A regular INSERT, UPDATE or DELETE statement. The trick here is that + ** any conflict on the rowid value must be detected before any + ** modifications are made to the database file. There are 4 cases: + ** + ** 1) DELETE + ** 2) UPDATE (rowid not modified) + ** 3) UPDATE (rowid modified) + ** 4) INSERT + ** + ** Cases 3 and 4 may violate the rowid constraint. + */ + eConflict = int32(SQLITE_ABORT) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL || (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete != 0 { + eConflict = Xsqlite3_vtab_on_conflict(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb) + } + /* DELETE */ + if nArg == int32(1) { + /* It is only possible to DELETE from a contentless table if the + ** contentless_delete=1 flag is set. */ + if _fts5IsContentless(tls, pTab, int32(1)) != 0 && (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete == 0 { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40275, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + iDel = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal))) /* Rowid to delete */ + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, uintptr(0), 0) + } + } else { + eType1 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + /* It is an error to write an fts5_locale() value to a table without + ** the locale=1 option. */ + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale == 0 { + ii = 0 + for { + if !(ii < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr(ii+int32(2))*8)) + if _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + _fts5SetVtabError(tls, pTab, __ccgo_ts+40321, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_MISMATCH) + goto update_out + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + if eType0 != int32(SQLITE_INTEGER) { + /* An INSERT statement. If the conflict-mode is REPLACE, first remove + ** the current entry (if any). */ + if eConflict == int32(SQLITE_REPLACE) && eType1 == int32(SQLITE_INTEGER) { + iNew = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) /* Rowid to delete */ + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iNew, uintptr(0), 0) + } + _fts5StorageInsert(tls, bp, pTab, apVal, pRowid) + } else { + pStorage = (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage + iOld = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal))) /* Old rowid */ + iNew1 = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) /* New rowid */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* Content only update */ + /* If this is a contentless table (including contentless_unindexed=1 + ** tables), check if the UPDATE may proceed. */ + if _fts5IsContentless(tls, pTab, int32(1)) != 0 { + **(**int32)(__ccgo_up(bp)) = _fts5ContentlessUpdate(tls, pConfig, apVal+2*8, libc.BoolInt32(iOld != iNew1), bp+4) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto update_out + } + } + if eType1 != int32(SQLITE_INTEGER) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_MISMATCH) + } else { + if iOld != iNew1 { + if eConflict == int32(SQLITE_REPLACE) { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, pStorage, iOld, uintptr(0), int32(1)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, pStorage, iNew1, uintptr(0), 0) + } + _fts5StorageInsert(tls, bp, pTab, apVal, pRowid) + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageFindDeleteRow(tls, pStorage, iOld) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageContentInsert(tls, pStorage, 0, apVal, pRowid) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, pStorage, iOld, uintptr(0), 0) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageIndexInsert(tls, pStorage, apVal, **(**Tsqlite_int64)(__ccgo_up(pRowid))) + } + } + } else { + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + /* This occurs when an UPDATE on a contentless table affects *only* + ** UNINDEXED columns. This is a no-op for contentless_unindexed=0 + ** tables, or a write to the %_content table only for =1 tables. */ + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageFindDeleteRow(tls, pStorage, iOld) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageContentInsert(tls, pStorage, int32(1), apVal, pRowid) + } + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageDelete(tls, pStorage, iOld, uintptr(0), int32(1)) + _fts5StorageInsert(tls, bp, pTab, apVal, pRowid) + } + } + } + _sqlite3Fts5StorageReleaseDeleteRow(tls, pStorage) + } + } + } + goto update_out +update_out: + ; + _sqlite3Fts5IndexCloseReader(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = uintptr(0) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This is the xFilter implementation for the virtual table. +// */ +func _fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused uintptr, nUnused int32, apVal uintptr) (r int32) { + var eType, f, iVal, nTerm, rc, v1 int32 + var pCsr, pEq, pGe, pIndex, pLe, pTab, zCopy, zTerm uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = eType, f, iVal, nTerm, pCsr, pEq, pGe, pIndex, pLe, pTab, rc, zCopy, zTerm, v1 + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + pCsr = pCursor + eType = (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType + rc = SQLITE_OK + iVal = 0 + f = int32(FTS5INDEX_QUERY_SCAN) + zTerm = uintptr(0) + nTerm = 0 + pEq = uintptr(0) + pGe = uintptr(0) + pLe = uintptr(0) + _ = zUnused + _ = nUnused + _fts5VocabResetCursor(tls, pCsr) + if idxNum&int32(FTS5_VOCAB_TERM_EQ) != 0 { + v1 = iVal + iVal = iVal + 1 + pEq = **(**uintptr)(__ccgo_up(apVal + uintptr(v1)*8)) + } + if idxNum&int32(FTS5_VOCAB_TERM_GE) != 0 { + v1 = iVal + iVal = iVal + 1 + pGe = **(**uintptr)(__ccgo_up(apVal + uintptr(v1)*8)) + } + if idxNum&int32(FTS5_VOCAB_TERM_LE) != 0 { + v1 = iVal + iVal = iVal + 1 + pLe = **(**uintptr)(__ccgo_up(apVal + uintptr(v1)*8)) + } + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FcolUsed = idxNum & int32(FTS5_VOCAB_COLUSED_MASK) + if pEq != 0 { + zTerm = Xsqlite3_value_text(tls, pEq) + nTerm = Xsqlite3_value_bytes(tls, pEq) + f = int32(FTS5INDEX_QUERY_NOTOKENDATA) + } else { + if pGe != 0 { + zTerm = Xsqlite3_value_text(tls, pGe) + nTerm = Xsqlite3_value_bytes(tls, pGe) + } + if pLe != 0 { + zCopy = Xsqlite3_value_text(tls, pLe) + if zCopy == uintptr(0) { + zCopy = __ccgo_ts + 1704 + } + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm = Xsqlite3_value_bytes(tls, pLe) + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm)+int64(1))) + if (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zCopy, libc.Uint64FromInt32((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm+int32(1))) + } + } + } + if rc == SQLITE_OK { + pIndex = (*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpIndex + rc = _sqlite3Fts5IndexQuery(tls, pIndex, zTerm, nTerm, f, uintptr(0), pCsr+32) + if rc == SQLITE_OK { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpStruct = _sqlite3Fts5StructureRef(tls, pIndex) + } + } + if rc == SQLITE_OK && eType == int32(FTS5_VOCAB_INSTANCE) { + rc = _fts5VocabInstanceNewTerm(tls, pCsr) + } + if rc == SQLITE_OK && !((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0) && (eType != int32(FTS5_VOCAB_INSTANCE) || (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail != int32(FTS5_DETAIL_NONE)) { + rc = _fts5VocabNextMethod(tls, pCursor) + } + return rc +} + +// C documentation +// +// /* +// ** This function is the implementation of both the xConnect and xCreate +// ** methods of the FTS3 virtual table. +// ** +// ** The argv[] array contains the following: +// ** +// ** argv[0] -> module name ("fts5vocab") +// ** argv[1] -> database name +// ** argv[2] -> table name +// ** +// ** then: +// ** +// ** argv[3] -> name of fts5 table +// ** argv[4] -> type of fts5vocab table +// ** +// ** or, for tables in the TEMP schema only. +// ** +// ** argv[3] -> name of fts5 tables database +// ** argv[4] -> name of fts5 table +// ** argv[5] -> type of fts5vocab table +// */ +func _fts5VocabInitVtab(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVTab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azSchema [3]uintptr + var bDb int32 + var nByte, nDb, nTab Ti64 + var pRet, zDb, zTab, zType, v1, v2, v3 uintptr + var _ /* eType at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _ = azSchema, bDb, nByte, nDb, nTab, pRet, zDb, zTab, zType, v1, v2, v3 + azSchema = [3]uintptr{ + 0: __ccgo_ts + 42201, + 1: __ccgo_ts + 42241, + 2: __ccgo_ts + 42276, + } + pRet = uintptr(0) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + bDb = libc.BoolInt32(argc == int32(6) && libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) == uint64(4) && libc.Xmemcmp(tls, __ccgo_ts+25195, **(**uintptr)(__ccgo_up(argv + 1*8)), uint64(4)) == 0) + if argc != int32(5) && bDb == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+42319, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + if bDb != 0 { + v1 = **(**uintptr)(__ccgo_up(argv + 3*8)) + } else { + v1 = **(**uintptr)(__ccgo_up(argv + 1*8)) + } /* Bytes of space to allocate */ + zDb = v1 + if bDb != 0 { + v2 = **(**uintptr)(__ccgo_up(argv + 4*8)) + } else { + v2 = **(**uintptr)(__ccgo_up(argv + 3*8)) + } + zTab = v2 + if bDb != 0 { + v3 = **(**uintptr)(__ccgo_up(argv + 5*8)) + } else { + v3 = **(**uintptr)(__ccgo_up(argv + 4*8)) + } + zType = v3 + nDb = libc.Int64FromUint64(libc.Xstrlen(tls, zDb) + uint64(1)) + nTab = libc.Int64FromUint64(libc.Xstrlen(tls, zTab) + uint64(1)) + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**int32)(__ccgo_up(bp)) = _fts5VocabTableType(tls, zType, pzErr, bp+4) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_declare_vtab(tls, db, azSchema[**(**int32)(__ccgo_up(bp + 4))]) + } + nByte = libc.Int64FromUint64(uint64(64) + libc.Uint64FromInt64(nDb) + libc.Uint64FromInt64(nTab)) + pRet = _sqlite3Fts5MallocZero(tls, bp, nByte) + if pRet != 0 { + (*TFts5VocabTable)(unsafe.Pointer(pRet)).FpGlobal = pAux + (*TFts5VocabTable)(unsafe.Pointer(pRet)).FeType = **(**int32)(__ccgo_up(bp + 4)) + (*TFts5VocabTable)(unsafe.Pointer(pRet)).Fdb = db + (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl = pRet + 1*64 + (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db = (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl + uintptr(nTab) + libc.Xmemcpy(tls, (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl, zTab, libc.Uint64FromInt64(nTab)) + libc.Xmemcpy(tls, (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db, zDb, libc.Uint64FromInt64(nDb)) + _sqlite3Fts5Dequote(tls, (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl) + _sqlite3Fts5Dequote(tls, (*TFts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db) + } + } + **(**uintptr)(__ccgo_up(ppVTab)) = pRet + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Implementation of xOpen method. +// */ +func _fts5VocabOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var iId, nByte Ti64 + var pCsr, pFts5, pTab, zSql uintptr + var _ /* pStmt at bp+8 */ uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _ = iId, nByte, pCsr, pFts5, pTab, zSql + pTab = pVTab + pFts5 = uintptr(0) + pCsr = uintptr(0) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + zSql = uintptr(0) + if (*TFts5VocabTable)(unsafe.Pointer(pTab)).FbBusy != 0 { + (*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+42352, libc.VaList(bp+24, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl)) + return int32(SQLITE_ERROR) + } + zSql = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+42383, libc.VaList(bp+24, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl)) + if zSql != 0 { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_prepare_v2(tls, (*TFts5VocabTable)(unsafe.Pointer(pTab)).Fdb, zSql, -int32(1), bp+8, uintptr(0)) + } + Xsqlite3_free(tls, zSql) + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_ERROR) { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + } + (*TFts5VocabTable)(unsafe.Pointer(pTab)).FbBusy = uint32(1) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 && Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) == int32(SQLITE_ROW) { + iId = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp + 8)), 0) + pFts5 = _sqlite3Fts5TableFromCsrid(tls, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FpGlobal, iId) + } + (*TFts5VocabTable)(unsafe.Pointer(pTab)).FbBusy = uint32(0) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if pFts5 == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+42434, libc.VaList(bp+24, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*TFts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5FlushToDisk(tls, pFts5) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + nByte = libc.Int64FromUint64(libc.Uint64FromInt32((*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pFts5)).FpConfig)).FnCol)*uint64(8)*uint64(2) + uint64(128)) + pCsr = _sqlite3Fts5MallocZero(tls, bp, nByte) + } + if pCsr != 0 { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5 = pFts5 + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpStmt = **(**uintptr)(__ccgo_up(bp + 8)) + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt = pCsr + 1*128 + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr((*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pFts5)).FpConfig)).FnCol)*8 + } else { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + **(**uintptr)(__ccgo_up(ppCsr)) = pCsr + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5WriteInit(tls *libc.TLS, p uintptr, pWriter uintptr, iSegid int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nBuffer int32 + var pConfig uintptr + _, _ = nBuffer, pConfig + nBuffer = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz + int32(FTS5_DATA_PADDING) + libc.Xmemset(tls, pWriter, 0, uint64(120)) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid = iSegid + _fts5WriteDlidxGrow(tls, p, pWriter, int32(1)) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fpgno = int32(1) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage = uint8(1) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = int32(1) + /* Grow the two buffers to pgsz + padding bytes in size. */ + _sqlite3Fts5BufferSize(tls, p+60, pWriter+8+24, libc.Uint32FromInt32(nBuffer)) + _sqlite3Fts5BufferSize(tls, p+60, pWriter+8+8, libc.Uint32FromInt32(nBuffer)) + if (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter == uintptr(0) { + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + _fts5IndexPrepareStmt(tls, p, p+96, Xsqlite3_mprintf(tls, __ccgo_ts+39259, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* Initialize the 4-byte leaf-page header to 0x00. */ + libc.Xmemset(tls, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fp, 0, uint64(4)) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fn = int32(4) + /* Bind the current output segment id to the index-writer. This is an + ** optimization over binding the same value over and over as rows are + ** inserted into %_idx by the current writer. */ + Xsqlite3_bind_int(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(1), (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid) + } +} + +// C documentation +// +// /* +// ** Code an output subroutine for a coroutine implementation of a +// ** SELECT statement. +// ** +// ** The data to be output is contained in an array of pIn->nSdst registers +// ** starting at register pIn->iSdst. pDest is where the output should +// ** be sent. +// ** +// ** regReturn is the number of the register holding the subroutine +// ** return address. +// ** +// ** If regPrev>0 then it is the first register in a vector that +// ** records the previous output. mem[regPrev] is a flag that is false +// ** if there has been no previous output. If regPrev>0 then code is +// ** generated to suppress duplicates. pKeyInfo is used for comparing +// ** keys. +// ** +// ** If the LIMIT found in p->iLimit is reached, jump immediately to +// ** iBreak. +// */ +func _generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uintptr, pDest uintptr, regReturn int32, regPrev int32, pKeyInfo uintptr, iBreak int32) (r int32) { + var addr, addr1, addr2, iContinue, iParm, iParm1, ii, nKey, r1, r11, r12, r2, r21, r3 int32 + var pSO, v uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addr1, addr2, iContinue, iParm, iParm1, ii, nKey, pSO, r1, r11, r12, r2, r21, r3, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + addr = _sqlite3VdbeCurrentAddr(tls, v) + iContinue = _sqlite3VdbeMakeLabel(tls, pParse) + /* Suppress duplicates for UNION, EXCEPT, and INTERSECT + */ + if regPrev != 0 { + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), regPrev) + addr2 = _sqlite3VdbeAddOp4(tls, v, int32(OP_Compare), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, regPrev+int32(1), (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst, _sqlite3KeyInfoRef(tls, pKeyInfo), -int32(9)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addr2+int32(2), iContinue, addr2+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, regPrev+int32(1), (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst-int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), regPrev) + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return 0 + } + /* Suppress the first OFFSET entries if there is an OFFSET clause + */ + _codeOffset(tls, v, (*TSelect)(unsafe.Pointer(p)).FiOffset, iContinue) + switch libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) { + /* Store the result as data using a unique key. + */ + case int32(SRT_Fifo): + fallthrough + case int32(SRT_DistFifo): + fallthrough + case int32(SRT_Table): + fallthrough + case int32(SRT_EphemTab): + r1 = _sqlite3GetTempReg(tls, pParse) + r2 = _sqlite3GetTempReg(tls, pParse) + iParm = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst, r1) + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) == int32(SRT_DistFifo) { + /* If the destination is DistFifo, then cursor (iParm+1) is open + ** on an ephemeral index that is used to enforce uniqueness on the + ** total result. At this point, we are processing the setup portion + ** of the recursive CTE using the merge algorithm, so the results are + ** guaranteed to be unique anyhow. But we still need to populate the + ** (iParm+1) cursor for use by the subsequent recursive phase. + */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm+int32(1), r1, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iParm, r2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, r1, r2) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + _sqlite3ReleaseTempReg(tls, pParse, r2) + _sqlite3ReleaseTempReg(tls, pParse, r1) + break + /* If any row exist in the result set, record that fact and abort. + */ + fallthrough + case int32(SRT_Exists): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm) + /* The LIMIT clause will terminate the loop for us */ + break + /* If we are creating a set for an "expr IN (SELECT ...)". + */ + fallthrough + case int32(SRT_Set): + r11 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst, r11, (*TSelectDest)(unsafe.Pointer(pDest)).FzAffSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm, r11, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 > 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2, 0, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20465, 0) + } + _sqlite3ReleaseTempReg(tls, pParse, r11) + break + /* If this is a scalar select that is part of an expression, then + ** store the results in the appropriate memory cell and break out + ** of the scan loop. Note that the select might return multiple columns + ** if it is the RHS of a row-value IN operator. + */ + fallthrough + case int32(SRT_Mem): + _sqlite3ExprCodeMove(tls, pParse, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + /* The LIMIT clause will jump out of the loop for us */ + break + /* The results are stored in a sequence of registers + ** starting at pDest->iSdst. Then the co-routine yields. + */ + fallthrough + case int32(SRT_Coroutine): + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 { + (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst = _sqlite3GetTempRange(tls, pParse, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + (*TSelectDest)(unsafe.Pointer(pDest)).FnSdst = (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst + } + _sqlite3ExprCodeMove(tls, pParse, (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm) + break + /* Write the results into a priority queue that is order according to + ** pDest->pOrderBy (in pSO). pDest->iSDParm (in iParm) is the cursor for an + ** index with pSO->nExpr+2 columns. Build a key using pSO for the first + ** pSO->nExpr columns, then make sure all keys are unique by adding a + ** final OP_Sequence column. The last column is the record as a blob. + */ + fallthrough + case int32(SRT_DistQueue): + fallthrough + case int32(SRT_Queue): + iParm1 = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm + pSO = (*TSelectDest)(unsafe.Pointer(pDest)).FpOrderBy + nKey = (*TExprList)(unsafe.Pointer(pSO)).FnExpr + r12 = _sqlite3GetTempReg(tls, pParse) + r21 = _sqlite3GetTempRange(tls, pParse, nKey+int32(2)) + r3 = r21 + nKey + int32(1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst, r3) + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) == int32(SRT_DistQueue) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), iParm1+int32(1), r3) + } + ii = 0 + for { + if !(ii < nKey) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst+libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pSO + 8 + uintptr(ii)*32 + 24)))-int32(1), r21+ii) + goto _1 + _1: + ; + ii = ii + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sequence), iParm1, r21+nKey) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), r21, nKey+int32(2), r12) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm1, r12, r21, nKey+int32(2)) + _sqlite3ReleaseTempReg(tls, pParse, r12) + _sqlite3ReleaseTempRange(tls, pParse, r21, nKey+int32(2)) + break + /* Ignore the output */ + fallthrough + case int32(SRT_Discard): + break + /* If none of the above, then the result destination must be + ** SRT_Output. + ** + ** For SRT_Output, results are stored in a sequence of registers. + ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to + ** return the next row of result. + */ + fallthrough + default: + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), (*TSelectDest)(unsafe.Pointer(pIn)).FiSdst, (*TSelectDest)(unsafe.Pointer(pIn)).FnSdst) + break + } + /* Jump to the end of the loop if the LIMIT is reached. + */ + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_DecrJumpZero), (*TSelect)(unsafe.Pointer(p)).FiLimit, iBreak) + } + /* Generate the subroutine return + */ + _sqlite3VdbeResolveLabel(tls, v, iContinue) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regReturn) + return addr +} + +// C documentation +// +// /* +// ** If the inner loop was generated using a non-null pOrderBy argument, +// ** then the results were placed in a sorter. After the loop is terminated +// ** we need to run the sorter and output the results. The following +// ** routine generates the code needed to do that. +// */ +func _generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, nColumn int32, pDest uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aOutEx, pOrderBy, v, v1, v3 uintptr + var addr, addrBreak, addrContinue, addrOnce, bSeq, eDest, i, i2, iCol, iParm, iRead, iSortTab, iTab, nKey, nRefKey, r1, regRow, regRowid, regSortOut, v2, v4 int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aOutEx, addr, addrBreak, addrContinue, addrOnce, bSeq, eDest, i, i2, iCol, iParm, iRead, iSortTab, iTab, nKey, nRefKey, pOrderBy, r1, regRow, regRowid, regSortOut, v, v1, v2, v3, v4 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* The prepared statement */ + addrBreak = (*TSortCtx)(unsafe.Pointer(pSort)).FlabelDone /* Jump here to exit loop */ + addrContinue = _sqlite3VdbeMakeLabel(tls, pParse) /* Top of output loop. Jump for Next. */ + addrOnce = 0 + pOrderBy = (*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy + eDest = libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) + iParm = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm /* True if sorter record includes seq. no. */ + nRefKey = 0 + aOutEx = (*TSelect)(unsafe.Pointer(p)).FpEList + 8 + nKey = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr - (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + if (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat == 0 || nKey == int32(1) { + if (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat != 0 { + v1 = __ccgo_ts + 20541 + } else { + v1 = __ccgo_ts + 1704 + } + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20555, libc.VaList(bp+8, v1)) + } else { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20586, libc.VaList(bp+8, nKey)) + } + if (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn, (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + _sqlite3VdbeGoto(tls, v, addrBreak) + _sqlite3VdbeResolveLabel(tls, v, (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + } + iTab = (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor + if eDest == int32(SRT_Output) || eDest == int32(SRT_Coroutine) || eDest == int32(SRT_Mem) { + if eDest == int32(SRT_Mem) && (*TSelect)(unsafe.Pointer(p)).FiOffset != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst) + } + regRowid = 0 + regRow = (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst + } else { + regRowid = _sqlite3GetTempReg(tls, pParse) + if eDest == int32(SRT_EphemTab) || eDest == int32(SRT_Table) { + regRow = _sqlite3GetTempReg(tls, pParse) + nColumn = 0 + } else { + regRow = _sqlite3GetTempRange(tls, pParse, nColumn) + } + } + if libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&int32(SORTFLAG_UseSorter) != 0 { + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + regSortOut = v2 + v3 = pParse + 56 + v4 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + iSortTab = v4 + if (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenPseudo), iSortTab, regSortOut, nKey+int32(1)+nColumn+nRefKey) + if addrOnce != 0 { + _sqlite3VdbeJumpHere(tls, v, addrOnce) + } + addr = int32(1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterSort), iTab, addrBreak) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SorterData), iTab, regSortOut, iSortTab) + bSeq = 0 + } else { + addr = int32(1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sort), iTab, addrBreak) + _codeOffset(tls, v, (*TSelect)(unsafe.Pointer(p)).FiOffset, addrContinue) + iSortTab = iTab + bSeq = int32(1) + if (*TSelect)(unsafe.Pointer(p)).FiOffset > 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), (*TSelect)(unsafe.Pointer(p)).FiLimit, -int32(1)) + } + } + i = 0 + iCol = nKey + bSeq - libc.Int32FromInt32(1) + for { + if !(i < nColumn) { + break + } + if libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(aOutEx + uintptr(i)*32 + 24))) == 0 { + iCol = iCol + 1 + } + goto _6 + _6: + ; + i = i + 1 + } + i = nColumn - int32(1) + for { + if !(i >= 0) { + break + } + if *(*Tu16)(unsafe.Pointer(aOutEx + uintptr(i)*32 + 24)) != 0 { + iRead = libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(aOutEx + uintptr(i)*32 + 24))) - int32(1) + } else { + v2 = iCol + iCol = iCol - 1 + iRead = v2 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iSortTab, iRead, regRow+i) + goto _7 + _7: + ; + i = i - 1 + } + switch eDest { + case int32(SRT_Table): + fallthrough + case int32(SRT_EphemTab): + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iSortTab, nKey+bSeq, regRow) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iParm, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, regRow, regRowid) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + case int32(SRT_Set): + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), regRow, nColumn, regRowid, (*TSelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nColumn) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, regRowid, regRow, nColumn) + case int32(SRT_Mem): + /* The LIMIT clause will terminate the loop for us */ + case int32(SRT_Upfrom): + i2 = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regRow+libc.BoolInt32(i2 < 0), nColumn-libc.BoolInt32(i2 < 0), r1) + if i2 < 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, r1, regRow) + } else { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, r1, regRow, i2) + } + default: + if eDest == int32(SRT_Output) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst, nColumn) + } else { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm) + } + break + } + if regRowid != 0 { + if eDest == int32(SRT_Set) { + _sqlite3ReleaseTempRange(tls, pParse, regRow, nColumn) + } else { + _sqlite3ReleaseTempReg(tls, pParse, regRow) + } + _sqlite3ReleaseTempReg(tls, pParse, regRowid) + } + /* The bottom of the loop + */ + _sqlite3VdbeResolveLabel(tls, v, addrContinue) + if libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&int32(SORTFLAG_UseSorter) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterNext), iTab, addr) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iTab, addr) + } + if (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn) + } + _sqlite3VdbeResolveLabel(tls, v, addrBreak) +} + +// C documentation +// +// /* +// ** This routine generates VDBE code to compute the content of a WITH RECURSIVE +// ** query of the form: +// ** +// ** AS ( UNION [ALL] ) +// ** \___________/ \_______________/ +// ** p->pPrior p +// ** +// ** +// ** There is exactly one reference to the recursive-table in the FROM clause +// ** of recursive-query, marked with the SrcList->a[].fg.isRecursive flag. +// ** +// ** The setup-query runs once to generate an initial set of rows that go +// ** into a Queue table. Rows are extracted from the Queue table one by +// ** one. Each row extracted from Queue is output to pDest. Then the single +// ** extracted row (now in the iCurrent table) becomes the content of the +// ** recursive-table for a recursive-query run. The output of the recursive-query +// ** is added back into the Queue table. Then another row is extracted from Queue +// ** and the iteration continues until the Queue table is empty. +// ** +// ** If the compound query operator is UNION then no duplicate rows are ever +// ** inserted into the Queue table. The iDistinct table keeps a copy of all rows +// ** that have ever been inserted into Queue and causes duplicates to be +// ** discarded. If the operator is UNION ALL, then duplicates are allowed. +// ** +// ** If the query has an ORDER BY, then entries in the Queue table are kept in +// ** ORDER BY order and the first entry is extracted for each cycle. Without +// ** an ORDER BY, the Queue table is just a FIFO. +// ** +// ** If a LIMIT clause is provided, then the iteration stops after LIMIT rows +// ** have been output to pDest. A LIMIT of zero means to output no rows and a +// ** negative LIMIT means to output all rows. If there is also an OFFSET clause +// ** with a positive value, then the first OFFSET outputs are discarded rather +// ** than being sent to pDest. The LIMIT count does not begin until after OFFSET +// ** rows have been skipped. +// */ +func _generateWithRecursiveQuery(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var addrBreak, addrCont, addrTop, eDest, i, iCurrent, iDistinct, iQueue, nCol, rc, regCurrent, regLimit, regOffset, v1 int32 + var apColl, pFirstRec, pKeyInfo, pKeyInfo1, pLimit, pOrderBy, pSetup, pSrc, v, v4 uintptr + var _ /* destQueue at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrBreak, addrCont, addrTop, apColl, eDest, i, iCurrent, iDistinct, iQueue, nCol, pFirstRec, pKeyInfo, pKeyInfo1, pLimit, pOrderBy, pSetup, pSrc, rc, regCurrent, regLimit, regOffset, v, v1, v4 + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc /* The FROM clause of the recursive query */ + nCol = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr /* Number of columns in the recursive table */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* CONTINUE and BREAK addresses */ + iCurrent = 0 /* The Queue table */ + iDistinct = 0 /* To ensure unique results if UNION */ + eDest = int32(SRT_Fifo) /* Registers used by LIMIT and OFFSET */ + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20653, 0) + return + } + /* Obtain authorization to do a recursive query */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_RECURSIVE), uintptr(0), uintptr(0), uintptr(0)) != 0 { + return + } + /* Process the LIMIT and OFFSET clauses, if they exist */ + addrBreak = _sqlite3VdbeMakeLabel(tls, pParse) + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(320) /* 4 billion rows */ + _computeLimitRegisters(tls, pParse, p, addrBreak) + pLimit = (*TSelect)(unsafe.Pointer(p)).FpLimit + regLimit = (*TSelect)(unsafe.Pointer(p)).FiLimit + regOffset = (*TSelect)(unsafe.Pointer(p)).FiOffset + (*TSelect)(unsafe.Pointer(p)).FpLimit = uintptr(0) + v1 = libc.Int32FromInt32(0) + (*TSelect)(unsafe.Pointer(p)).FiOffset = v1 + (*TSelect)(unsafe.Pointer(p)).FiLimit = v1 + pOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + /* Locate the cursor number of the Current table */ + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 24 + 4))&0x80>>7) != 0 { + iCurrent = (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FiCursor + break + } + goto _2 + _2: + ; + i = i + 1 + } + /* Allocate cursors numbers for Queue and Distinct. The cursor number for + ** the Distinct table must be exactly one greater than Queue in order + ** for the SRT_DistFifo and SRT_DistQueue destinations to work. */ + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iQueue = v1 + if libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop) == int32(TK_UNION) { + if pOrderBy != 0 { + v1 = int32(SRT_DistQueue) + } else { + v1 = int32(SRT_DistFifo) + } + eDest = v1 + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iDistinct = v1 + } else { + if pOrderBy != 0 { + v1 = int32(SRT_Queue) + } else { + v1 = int32(SRT_Fifo) + } + eDest = v1 + } + _sqlite3SelectDestInit(tls, bp, eDest, iQueue) + /* Allocate cursors for Current, Queue, and Distinct. */ + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regCurrent = v1 + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenPseudo), iCurrent, regCurrent, nCol) + if pOrderBy != 0 { + pKeyInfo = _multiSelectByMergeKeyInfo(tls, pParse, p, int32(1)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), iQueue, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr+int32(2), 0, pKeyInfo, -int32(9)) + (**(**TSelectDest)(__ccgo_up(bp))).FpOrderBy = pOrderBy + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), iQueue, nCol) + } + if iDistinct != 0 { /* For looping through pKeyInfo->aColl[] */ + nCol = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr + pKeyInfo1 = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, nCol, int32(1)) + if pKeyInfo1 != 0 { + i = 0 + apColl = pKeyInfo1 + 32 + for { + if !(i < nCol) { + break + } + **(**uintptr)(__ccgo_up(apColl)) = _multiSelectCollSeq(tls, pParse, p, i) + if uintptr(0) == **(**uintptr)(__ccgo_up(apColl)) { + **(**uintptr)(__ccgo_up(apColl)) = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FpDfltColl + } + goto _11 + _11: + ; + i = i + 1 + apColl += 8 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), iDistinct, nCol, 0, pKeyInfo1, -int32(9)) + } else { + } + } + /* Detach the ORDER BY clause from the compound SELECT */ + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + /* Figure out how many elements of the compound SELECT are part of the + ** recursive query. Make sure no recursive elements use aggregate + ** functions. Mark the recursive elements as UNION ALL even if they + ** are really UNION because the distinctness will be enforced by the + ** iDistinct table. pFirstRec is left pointing to the left-most + ** recursive term of the CTE. + */ + pFirstRec = p + for { + if !(pFirstRec != uintptr(0)) { + break + } + if (*TSelect)(unsafe.Pointer(pFirstRec)).FselFlags&uint32(SF_Aggregate) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20702, 0) + goto end_of_recursive_query + } + (*TSelect)(unsafe.Pointer(pFirstRec)).Fop = uint8(TK_ALL) + if (*TSelect)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior)).FselFlags&uint32(SF_Recursive) == uint32(0) { + break + } + goto _12 + _12: + ; + pFirstRec = (*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior + } + /* Store the results of the setup-query in Queue. */ + pSetup = (*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior + (*TSelect)(unsafe.Pointer(pSetup)).FpNext = uintptr(0) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20744, 0) + rc = _sqlite3Select(tls, pParse, pSetup, bp) + (*TSelect)(unsafe.Pointer(pSetup)).FpNext = p + if rc != 0 { + goto end_of_recursive_query + } + /* Find the next row in the Queue and output that row */ + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iQueue, addrBreak) + /* Transfer the next row in Queue over to Current */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iCurrent) /* To reset column cache */ + if pOrderBy != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iQueue, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr+int32(1), regCurrent) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowData), iQueue, regCurrent) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_Delete), iQueue) + /* Output the single row in Current */ + addrCont = _sqlite3VdbeMakeLabel(tls, pParse) + _codeOffset(tls, v, regOffset, addrCont) + _selectInnerLoop(tls, pParse, p, iCurrent, uintptr(0), uintptr(0), pDest, addrCont, addrBreak) + if regLimit != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_DecrJumpZero), regLimit, addrBreak) + } + _sqlite3VdbeResolveLabel(tls, v, addrCont) + /* Execute the recursive SELECT taking the single row in Current as + ** the value for the recursive-table. Store the results in the Queue. + */ + (*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior = uintptr(0) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20750, 0) + _sqlite3Select(tls, pParse, p, bp) + (*TSelect)(unsafe.Pointer(pFirstRec)).FpPrior = pSetup + /* Keep running the loop until the Queue is empty */ + _sqlite3VdbeGoto(tls, v, addrTop) + _sqlite3VdbeResolveLabel(tls, v, addrBreak) + goto end_of_recursive_query +end_of_recursive_query: + ; + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = pOrderBy + (*TSelect)(unsafe.Pointer(p)).FpLimit = pLimit + return +} + +// C documentation +// +// /* +// ** Each call to sqlite3_rtree_geometry_callback() or +// ** sqlite3_rtree_query_callback() creates an ordinary SQLite +// ** scalar function that is implemented by this routine. +// ** +// ** All this function does is construct an RtreeMatchArg object that +// ** contains the geometry-checking callback routines and a list of +// ** parameters to this function, then return that RtreeMatchArg object +// ** as a BLOB. +// ** +// ** The R-Tree MATCH operator will read the returned BLOB, deserialize +// ** the RtreeMatchArg object, and use the RtreeMatchArg object to figure +// ** out which elements of the R-Tree should be returned by the query. +// */ +func _geomCallback(tls *libc.TLS, ctx uintptr, nArg int32, aArg uintptr) { + var i, memErr int32 + var nBlob Tsqlite3_int64 + var pBlob, pGeomCtx uintptr + _, _, _, _, _ = i, memErr, nBlob, pBlob, pGeomCtx + pGeomCtx = Xsqlite3_user_data(tls, ctx) + memErr = 0 + nBlob = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+56) + libc.Uint64FromInt32(nArg)*uint64(8) + libc.Uint64FromInt32(nArg)*uint64(8)) + pBlob = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nBlob)) + if !(pBlob != 0) { + Xsqlite3_result_error_nomem(tls, ctx) + } else { + (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FiSize = libc.Uint32FromInt64(nBlob) + (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb = **(**TRtreeGeomCallback)(__ccgo_up(pGeomCtx)) + (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam = pBlob + 56 + uintptr(nArg)*8 + (*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam = nArg + i = 0 + for { + if !(i < nArg) { + break + } + **(**uintptr)(__ccgo_up((*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam + uintptr(i)*8)) = Xsqlite3_value_dup(tls, **(**uintptr)(__ccgo_up(aArg + uintptr(i)*8))) + if **(**uintptr)(__ccgo_up((*TRtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam + uintptr(i)*8)) == uintptr(0) { + memErr = int32(1) + } + *(*TRtreeDValue)(unsafe.Pointer(pBlob + 56 + uintptr(i)*8)) = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(aArg + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + if memErr != 0 { + Xsqlite3_result_error_nomem(tls, ctx) + _rtreeMatchArgFree(tls, pBlob) + } else { + Xsqlite3_result_pointer(tls, ctx, pBlob, __ccgo_ts+27426, __ccgo_fp(_rtreeMatchArgFree)) + } + } +} + +// C documentation +// +// /* +// ** This function is the implementation of both the xConnect and xCreate +// ** methods of the geopoly virtual table. +// ** +// ** argv[0] -> module name +// ** argv[1] -> database name +// ** argv[2] -> table name +// ** argv[...] -> column names... +// */ +func _geopolyInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr, isCreate int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var ii, rc, v2 int32 + var nDb, nName Tsqlite3_int64 + var pRtree, pSql, zSql uintptr + _, _, _, _, _, _, _, _ = ii, nDb, nName, pRtree, pSql, rc, zSql, v2 + rc = SQLITE_OK + _ = pAux + if argc >= libc.Int32FromInt32(RTREE_MAX_AUX_COLUMN)+libc.Int32FromInt32(4) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+29841, 0) + return int32(SQLITE_ERROR) + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_CONSTRAINT_SUPPORT), libc.VaList(bp+8, int32(1))) + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + /* Allocate the sqlite3_vtab structure */ + nDb = libc.Int64FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 1*8)))) + nName = libc.Int64FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + pRtree = Xsqlite3_malloc64(tls, uint64(976)+libc.Uint64FromInt64(nDb)+libc.Uint64FromInt64(nName*int64(2))+uint64(8)) + if !(pRtree != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pRtree, 0, uint64(uint64(976)+libc.Uint64FromInt64(nDb)+libc.Uint64FromInt64(nName*int64(2))+uint64(8))) + (*TRtree)(unsafe.Pointer(pRtree)).FnBusy = uint32(1) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&_rtreeModule)) + (*TRtree)(unsafe.Pointer(pRtree)).FzDb = pRtree + 1*976 + (*TRtree)(unsafe.Pointer(pRtree)).FzName = (*TRtree)(unsafe.Pointer(pRtree)).FzDb + uintptr(nDb+int64(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName = (*TRtree)(unsafe.Pointer(pRtree)).FzName + uintptr(nName+int64(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FeCoordType = uint8(RTREE_COORD_REAL32) + (*TRtree)(unsafe.Pointer(pRtree)).FnDim = uint8(2) + (*TRtree)(unsafe.Pointer(pRtree)).FnDim2 = uint8(4) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, **(**uintptr)(__ccgo_up(argv + 1*8)), libc.Uint64FromInt64(nDb)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt64(nName)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt64(nName)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName+uintptr(nName), __ccgo_ts+28883, uint64(6)) + /* Create/Connect to the underlying relational database schema. If + ** that is successful, call sqlite3_declare_vtab() to configure + ** the r-tree table schema. + */ + pSql = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+29878, 0) + (*TRtree)(unsafe.Pointer(pRtree)).FnAux = uint16(1) /* Add one for _shape */ + (*TRtree)(unsafe.Pointer(pRtree)).FnAuxNotNull = uint8(1) /* The _shape column is always not-null */ + ii = int32(3) + for { + if !(ii < argc) { + break + } + (*TRtree)(unsafe.Pointer(pRtree)).FnAux = (*TRtree)(unsafe.Pointer(pRtree)).FnAux + 1 + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+29900, libc.VaList(bp+8, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8)))) + goto _1 + _1: + ; + ii = ii + 1 + } + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+28940, 0) + zSql = Xsqlite3_str_finish(tls, pSql) + if !(zSql != 0) { + rc = int32(SQLITE_NOMEM) + } else { + v2 = Xsqlite3_declare_vtab(tls, db, zSql) + rc = v2 + if SQLITE_OK != v2 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + } + } + Xsqlite3_free(tls, zSql) + if rc != 0 { + goto geopolyInit_fail + } + (*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell = libc.Uint8FromInt32(int32(8) + libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)*int32(4)) + /* Figure out the node size to use. */ + rc = _getNodeSize(tls, db, pRtree, isCreate, pzErr) + if rc != 0 { + goto geopolyInit_fail + } + rc = _rtreeSqlInit(tls, pRtree, db, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), isCreate) + if rc != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + goto geopolyInit_fail + } + **(**uintptr)(__ccgo_up(ppVtab)) = pRtree + return SQLITE_OK + goto geopolyInit_fail +geopolyInit_fail: + ; + if rc == SQLITE_OK { + rc = int32(SQLITE_ERROR) + } + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** The xUpdate method for GEOPOLY module virtual tables. +// ** +// ** For DELETE: +// ** +// ** argv[0] = the rowid to be deleted +// ** +// ** For INSERT: +// ** +// ** argv[0] = SQL NULL +// ** argv[1] = rowid to insert, or an SQL NULL to select automatically +// ** argv[2] = _shape column +// ** argv[3] = first application-defined column.... +// ** +// ** For UPDATE: +// ** +// ** argv[0] = rowid to modify. Never NULL +// ** argv[1] = rowid after the change. Never NULL +// ** argv[2] = new value for _shape +// ** argv[3] = new value for first application-defined column.... +// */ +func _geopolyUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var coordChange, jj, nChange, newRowidValid, oldRowidValid, rc2, steprc int32 + var newRowid, oldRowid Ti64 + var p, pRtree, pUp, v3 uintptr + var v1 int64 + var v4 bool + var _ /* cell at bp+8 */ TRtreeCell + var _ /* pLeaf at bp+56 */ uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = coordChange, jj, nChange, newRowid, newRowidValid, oldRowid, oldRowidValid, p, pRtree, pUp, rc2, steprc, v1, v3, v4 + pRtree = pVtab + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* True if newRowid is valid */ + coordChange = 0 /* Change in coordinates */ + if (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0 { + /* Unable to write to the btree while another cursor is reading from it, + ** since the write might do a rebalance which would disrupt the read + ** cursor. */ + return libc.Int32FromInt32(SQLITE_LOCKED) | libc.Int32FromInt32(2)< int32(1) && Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData + 1*8))) != int32(SQLITE_NULL)) + if newRowidValid != 0 { + v1 = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(aData + 1*8))) + } else { + v1 = 0 + } + newRowid = v1 + (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid = newRowid + if nData > int32(1) && (!(oldRowidValid != 0) || !(Xsqlite3_value_nochange(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) != 0) || oldRowid != newRowid) { + _geopolyBBox(tls, uintptr(0), **(**uintptr)(__ccgo_up(aData + 2*8)), bp+8+8, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_ERROR) { + (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+29919, 0) + } + goto geopoly_update_end + } + coordChange = int32(1) + /* If a rowid value was supplied, check if it is already present in + ** the table. If so, the constraint has failed. */ + if newRowidValid != 0 && (!(oldRowidValid != 0) || oldRowid != newRowid) { + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid, int32(1), (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid) + steprc = Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + **(**int32)(__ccgo_up(bp)) = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + if int32(SQLITE_ROW) == steprc { + if Xsqlite3_vtab_on_conflict(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb) == int32(SQLITE_REPLACE) { + **(**int32)(__ccgo_up(bp)) = _rtreeDeleteRowid(tls, pRtree, (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid) + } else { + **(**int32)(__ccgo_up(bp)) = _rtreeConstraintError(tls, pRtree, 0) + } + } + } + } + /* If aData[0] is not an SQL NULL value, it is the rowid of a + ** record to delete from the r-tree table. The following block does + ** just that. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (nData == int32(1) || coordChange != 0 && oldRowidValid != 0) { + **(**int32)(__ccgo_up(bp)) = _rtreeDeleteRowid(tls, pRtree, oldRowid) + } + /* If the aData[] array contains more than one element, elements + ** (aData[2]..aData[argc-1]) contain a new record to insert into + ** the r-tree structure. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && nData > int32(1) && coordChange != 0 { + /* Insert the new record into the r-tree */ + **(**uintptr)(__ccgo_up(bp + 56)) = uintptr(0) + if !(newRowidValid != 0) { + **(**int32)(__ccgo_up(bp)) = _rtreeNewRowid(tls, pRtree, bp+8) + } + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _ChooseLeaf(tls, pRtree, bp+8, 0, bp+56) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _rtreeInsertCell(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 56)), bp+8, 0) + rc2 = _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 56))) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = rc2 + } + } + } + /* Change the data */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && nData > int32(1) { + pUp = (*TRtree)(unsafe.Pointer(pRtree)).FpWriteAux + nChange = 0 + Xsqlite3_bind_int64(tls, pUp, int32(1), (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid) + if Xsqlite3_value_nochange(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) != 0 { + Xsqlite3_bind_null(tls, pUp, int32(2)) + } else { + p = uintptr(0) + if v4 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) == int32(SQLITE_TEXT); v4 { + v3 = _geopolyFuncParam(tls, uintptr(0), **(**uintptr)(__ccgo_up(aData + 2*8)), bp) + p = v3 + } + if v4 && v3 != uintptr(0) && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + Xsqlite3_bind_blob(tls, pUp, int32(2), p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_bind_value(tls, pUp, int32(2), **(**uintptr)(__ccgo_up(aData + 2*8))) + } + Xsqlite3_free(tls, p) + nChange = int32(1) + } + jj = int32(1) + for { + if !(jj < nData-int32(2)) { + break + } + nChange = nChange + 1 + Xsqlite3_bind_value(tls, pUp, jj+int32(2), **(**uintptr)(__ccgo_up(aData + uintptr(jj+int32(2))*8))) + goto _5 + _5: + ; + jj = jj + 1 + } + if nChange != 0 { + Xsqlite3_step(tls, pUp) + **(**int32)(__ccgo_up(bp)) = Xsqlite3_reset(tls, pUp) + } + } + goto geopoly_update_end +geopoly_update_end: + ; + _rtreeRelease(tls, pRtree) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This function is called from within the xConnect() or xCreate() method to +// ** determine the node-size used by the rtree table being created or connected +// ** to. If successful, pRtree->iNodeSize is populated and SQLITE_OK returned. +// ** Otherwise, an SQLite error code is returned. +// ** +// ** If this function is being called as part of an xConnect(), then the rtree +// ** table already exists. In this case the node-size is determined by inspecting +// ** the root node of the tree. +// ** +// ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size. +// ** This ensures that each node is stored on a single database page. If the +// ** database page-size is so large that more than RTREE_MAXCELLS entries +// ** would fit in a single node, use a smaller node-size. +// */ +func _getNodeSize(tls *libc.TLS, db uintptr, pRtree uintptr, isCreate int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc int32 + var zSql uintptr + var _ /* iPageSize at bp+0 */ int32 + _, _ = rc, zSql + if isCreate != 0 { + **(**int32)(__ccgo_up(bp)) = 0 + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+28620, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb)) + rc = _getIntFromStmt(tls, db, zSql, bp) + if rc == SQLITE_OK { + (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize = **(**int32)(__ccgo_up(bp)) - int32(64) + if int32(4)+libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*int32(RTREE_MAXCELLS) < (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize { + (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize = int32(4) + libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*int32(RTREE_MAXCELLS) + } + } else { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, db))) + } + } else { + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+28640, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName)) + rc = _getIntFromStmt(tls, db, zSql, pRtree+32) + if rc != SQLITE_OK { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, db))) + } else { + if (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize < libc.Int32FromInt32(512)-libc.Int32FromInt32(64) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< uint32(0) { + (*TJsonParse)(unsafe.Pointer(pParse)).FzJson = _sqlite3RCStrRef(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf) + (*TJsonParse)(unsafe.Pointer(pParse)).FnJson = libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(p)).FnUsed) + (*TJsonParse)(unsafe.Pointer(pParse)).FbJsonIsRCStr = uint8(1) + rc = _jsonCacheInsert(tls, ctx, pParse) + if rc == int32(SQLITE_NOMEM) { + Xsqlite3_result_error_nomem(tls, ctx) + _jsonStringReset(tls, p) + return + } + } + Xsqlite3_result_text64(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx, _sqlite3RCStrRef(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf), (*TJsonString)(unsafe.Pointer(p)).FnUsed, __ccgo_fp(_sqlite3RCStrUnref), uint8(SQLITE_UTF8)) + } + } + } else { + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr)&int32(JSTRING_OOM) != 0 { + Xsqlite3_result_error_nomem(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx) + } else { + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr)&int32(JSTRING_TOODEEP) != 0 { + /* error already in p->pCtx */ + } else { + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr)&int32(JSTRING_MALFORMED) != 0 { + Xsqlite3_result_error(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx, __ccgo_ts+26393, -int32(1)) + } + } + } + } + _jsonStringReset(tls, p) +} + +/************************************************************************** +** Utility routines for dealing with JsonParse objects +**************************************************************************/ + +// C documentation +// +// /* Report JSON nested too deep +// */ +func _jsonStringTooDeep(tls *libc.TLS, p uintptr) { + var v1 uintptr + _ = v1 + v1 = p + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_TOODEEP)) + Xsqlite3_result_error(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx, __ccgo_ts+26343, -int32(1)) + _jsonStringReset(tls, p) +} + +// C documentation +// +// /* +// ** json_valid(JSON) +// ** json_valid(JSON, FLAGS) +// ** +// ** Check the JSON argument to see if it is well-formed. The FLAGS argument +// ** encodes the various constraints on what is meant by "well-formed": +// ** +// ** 0x01 Canonical RFC-8259 JSON text +// ** 0x02 JSON text with optional JSON-5 extensions +// ** 0x04 Superficially appears to be JSONB +// ** 0x08 Strictly well-formed JSONB +// ** +// ** If the FLAGS argument is omitted, it defaults to 1. Useful values for +// ** FLAGS include: +// ** +// ** 1 Strict canonical JSON text +// ** 2 JSON text perhaps with JSON-5 extensions +// ** 4 Superficially appears to be JSONB +// ** 5 Canonical JSON text or superficial JSONB +// ** 6 JSON-5 text or superficial JSONB +// ** 8 Strict JSONB +// ** 9 Canonical JSON text or strict JSONB +// ** 10 JSON-5 text or strict JSONB +// ** +// ** Other flag combinations are redundant. For example, every canonical +// ** JSON text is also well-formed JSON-5 text, so FLAG values 2 and 3 +// ** are the same. Similarly, any input that passes a strict JSONB validation +// ** will also pass the superficial validation so 12 through 15 are the same +// ** as 8 through 11 respectively. +// ** +// ** This routine runs in linear time to validate text and when doing strict +// ** JSONB validation. Superficial JSONB validation is constant time, +// ** assuming the BLOB is already in memory. The performance advantage +// ** of superficial JSONB validation is why that option is provided. +// ** Application developers can choose to do fast superficial validation or +// ** slower strict validation, according to their specific needs. +// ** +// ** Only the lower four bits of the FLAGS argument are currently used. +// ** Higher bits are reserved for future expansion. To facilitate +// ** compatibility, the current implementation raises an error if any bit +// ** in FLAGS is set other than the lower four bits. +// ** +// ** The original circa 2015 implementation of the JSON routines in +// ** SQLite only supported canonical RFC-8259 JSON text and the json_valid() +// ** function only accepted one argument. That is why the default value +// ** for the FLAGS argument is 1, since FLAGS=1 causes this routine to only +// ** recognize canonical RFC-8259 JSON text as valid. The extra FLAGS +// ** argument was added when the JSON routines were extended to support +// ** JSON5-like extensions and binary JSONB stored in BLOBs. +// ** +// ** Return Values: +// ** +// ** * Raise an error if FLAGS is outside the range of 1 to 15. +// ** * Return NULL if the input is NULL +// ** * Return 1 if the input is well-formed. +// ** * Return 0 if the input is not well-formed. +// */ +func _jsonValidFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var f Ti64 + var flags, res Tu8 + var p uintptr + var _ /* px at bp+72 */ TJsonParse + var _ /* py at bp+0 */ TJsonParse + _, _, _, _ = f, flags, p, res /* The parse */ + flags = uint8(1) + res = uint8(0) + if argc == int32(2) { + f = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if f < int64(1) || f > int64(15) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26728, -int32(1)) + return + } + flags = libc.Uint8FromInt64(f & int64(0x0f)) + } + switch Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_NULL): + return + case int32(SQLITE_BLOB): + libc.Xmemset(tls, bp, 0, uint64(72)) + if _jsonArgIsJsonb(tls, **(**uintptr)(__ccgo_up(argv)), bp) != 0 { + if libc.Int32FromUint8(flags)&int32(0x04) != 0 { + /* Superficial checking only - accomplished by the + ** jsonArgIsJsonb() call above. */ + res = uint8(1) + } else { + if libc.Int32FromUint8(flags)&int32(0x08) != 0 { + /* Strict checking. Check by translating BLOB->TEXT->BLOB. If + ** no errors occur, call that a "strict check". */ + res = libc.BoolUint8(uint32(0) == _jsonbValidityCheck(tls, bp, uint32(0), (**(**TJsonParse)(__ccgo_up(bp))).FnBlob, uint32(1))) + } + } + break + } + /* Fall through into interpreting the input as text. See note + ** above at tag-20240123-a. */ + fallthrough + default: + if libc.Int32FromUint8(flags)&int32(0x3) == 0 { + break + } + libc.Xmemset(tls, bp+72, 0, uint64(72)) + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(JSON_KEEPERROR)) + if p != 0 { + if (*TJsonParse)(unsafe.Pointer(p)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, ctx) + } else { + if (*TJsonParse)(unsafe.Pointer(p)).FnErr != 0 { + /* no-op */ + } else { + if libc.Int32FromUint8(flags)&int32(0x02) != 0 || libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(p)).FhasNonstd) == 0 { + res = uint8(1) + } + } + } + _jsonParseFree(tls, p) + } else { + Xsqlite3_result_error_nomem(tls, ctx) + } + break + } + Xsqlite3_result_int(tls, ctx, libc.Int32FromUint8(res)) +} + +// C documentation +// +// /* +// ** Implementation of the like() SQL function. This function implements +// ** the built-in LIKE operator. The first argument to the function is the +// ** pattern and the second argument is the string. So, the SQL statements: +// ** +// ** A LIKE B +// ** +// ** is implemented as like(B,A). +// ** +// ** This same function (with a different compareInfo structure) computes +// ** the GLOB operator. +// */ +func _likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pInfo, zA, zB uintptr + var escape Tu32 + var nPat int32 + var _ /* backupInfo at bp+0 */ TcompareInfo + var _ /* zEsc at bp+8 */ uintptr + _, _, _, _, _, _ = db, escape, nPat, pInfo, zA, zB + db = Xsqlite3_context_db_handle(tls, context) + pInfo = Xsqlite3_user_data(tls, context) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_BLOB) || Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) == int32(SQLITE_BLOB) { + Xsqlite3_result_int(tls, context, 0) + return + } + /* Limit the length of the LIKE or GLOB pattern to avoid problems + ** of deep recursion and N*N behavior in patternCompare(). + */ + nPat = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if nPat > **(**int32)(__ccgo_up(db + 136 + 8*4)) { + Xsqlite3_result_error(tls, context, __ccgo_ts+16481, -int32(1)) + return + } + if argc == int32(3) { + /* The escape character string must consist of a single UTF-8 character. + ** Otherwise, return an error. + */ + **(**uintptr)(__ccgo_up(bp + 8)) = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + if **(**uintptr)(__ccgo_up(bp + 8)) == uintptr(0) { + return + } + if _sqlite3Utf8CharLen(tls, **(**uintptr)(__ccgo_up(bp + 8)), -int32(1)) != int32(1) { + Xsqlite3_result_error(tls, context, __ccgo_ts+16514, -int32(1)) + return + } + escape = _sqlite3Utf8Read(tls, bp+8) + if escape == uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchAll) || escape == uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchOne) { + libc.Xmemcpy(tls, bp, pInfo, uint64(4)) + pInfo = bp + if escape == uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchAll) { + (*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchAll = uint8(0) + } + if escape == uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchOne) { + (*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchOne = uint8(0) + } + } + } else { + escape = uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchSet) + } + zB = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zA = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zA != 0 && zB != 0 { + Xsqlite3_result_int(tls, context, libc.BoolInt32(_patternCompare(tls, zB, zA, pInfo, escape) == SQLITE_MATCH)) + } +} + +// C documentation +// +// /* +// ** A function that loads a shared-library extension then returns NULL. +// */ +func _loadExt(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, zFile, zProc uintptr + var _ /* zErrMsg at bp+0 */ uintptr + _, _, _ = db, zFile, zProc + zFile = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + db = Xsqlite3_context_db_handle(tls, context) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + /* Disallow the load_extension() SQL function unless the SQLITE_LoadExtFunc + ** flag is set. See the sqlite3_enable_load_extension() API. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LoadExtFunc) == uint64(0) { + Xsqlite3_result_error(tls, context, __ccgo_ts+13671, -int32(1)) + return + } + if argc == int32(2) { + zProc = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + zProc = uintptr(0) + } + if zFile != 0 && Xsqlite3_load_extension(tls, db, zFile, zProc, bp) != 0 { + Xsqlite3_result_error(tls, context, **(**uintptr)(__ccgo_up(bp)), -int32(1)) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + } +} + +// C documentation +// +// /* +// ** Get a reference to pPage1 of the database file. This will +// ** also acquire a readlock on that file. +// ** +// ** SQLITE_OK is returned on success. If the file is not a +// ** well-formed database file, then SQLITE_CORRUPT is returned. +// ** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM +// ** is returned if we run out of memory. +// */ +func _lockBtree(tls *libc.TLS, pBt uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nPage, pageSize, usableSize Tu32 + var page1, v1 uintptr + var rc, v4 int32 + var _ /* isOpen at bp+12 */ int32 + var _ /* nPageFile at bp+8 */ Tu32 + var _ /* pPage1 at bp+0 */ uintptr + _, _, _, _, _, _, _ = nPage, page1, pageSize, rc, usableSize, v1, v4 /* Number of pages in the database */ + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(0) /* Number of pages in the database file */ + rc = _sqlite3PagerSharedLock(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + if rc != SQLITE_OK { + return rc + } + rc = _btreeGetPage(tls, pBt, uint32(1), bp, 0) + if rc != SQLITE_OK { + return rc + } + /* Do some checking to help insure the file we opened really is + ** a valid database file. + */ + nPage = _sqlite3Get4byte(tls, uintptr(28)+(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData) + _sqlite3PagerPagecount(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, bp+8) + if nPage == uint32(0) || libc.Xmemcmp(tls, uintptr(24)+(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uintptr(92)+(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4)) != 0 { + nPage = **(**Tu32)(__ccgo_up(bp + 8)) + } + if (*Tsqlite3)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags&uint64(SQLITE_ResetDatabase) != uint64(0) { + nPage = uint32(0) + } + if nPage > uint32(0) { + page1 = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData + rc = int32(SQLITE_NOTADB) + /* EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins + ** with the following 16 bytes (in hex): 53 51 4c 69 74 65 20 66 6f 72 6d + ** 61 74 20 33 00. */ + if libc.Xmemcmp(tls, page1, uintptr(unsafe.Pointer(&_zMagicHeader)), uint64(16)) != 0 { + goto page1_init_failed + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(page1 + 18))) > int32(2) { + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_READ_ONLY)) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(page1 + 19))) > int32(2) { + goto page1_init_failed + } + /* If the read version is set to 2, this database should be accessed + ** in WAL mode. If the log is not already open, open it now. Then + ** return SQLITE_OK and return without populating BtShared.pPage1. + ** The caller detects this and calls this function again. This is + ** required as the version of page 1 currently in the page1 buffer + ** may not be the latest version - there may be a newer one in the log + ** file. + */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(page1 + 19))) == int32(2) && libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_NO_WAL) == 0 { + **(**int32)(__ccgo_up(bp + 12)) = 0 + rc = _sqlite3PagerOpenWal(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, bp+12) + if rc != SQLITE_OK { + goto page1_init_failed + } else { + if **(**int32)(__ccgo_up(bp + 12)) == 0 { + _releasePageOne(tls, **(**uintptr)(__ccgo_up(bp))) + return SQLITE_OK + } + } + rc = int32(SQLITE_NOTADB) + } else { + } + /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload + ** fractions and the leaf payload fraction values must be 64, 32, and 32. + ** + ** The original design allowed these amounts to vary, but as of + ** version 3.6.0, we require them to be fixed. + */ + if libc.Xmemcmp(tls, page1+21, __ccgo_ts+4348, uint64(3)) != 0 { + goto page1_init_failed + } + /* EVIDENCE-OF: R-51873-39618 The page size for a database file is + ** determined by the 2-byte integer located at an offset of 16 bytes from + ** the beginning of the database file. */ + pageSize = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(page1 + 16)))< uint32(SQLITE_MAX_PAGE_SIZE) || pageSize <= uint32(256) { + goto page1_init_failed + } + /* EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte + ** integer at offset 20 is the number of bytes of space at the end of + ** each page to reserve for extensions. + ** + ** EVIDENCE-OF: R-37497-42412 The size of the reserved region is + ** determined by the one-byte unsigned integer found at an offset of 20 + ** into the database file header. */ + usableSize = pageSize - uint32(**(**Tu8)(__ccgo_up(page1 + 20))) + if pageSize != (*TBtShared)(unsafe.Pointer(pBt)).FpageSize { + /* After reading the first page of the database assuming a page size + ** of BtShared.pageSize, we have discovered that the page-size is + ** actually pageSize. Unlock the database, leave pBt->pPage1 at + ** zero and return SQLITE_OK. The caller will call this function + ** again with the correct page-size. + */ + _releasePageOne(tls, **(**uintptr)(__ccgo_up(bp))) + (*TBtShared)(unsafe.Pointer(pBt)).FusableSize = usableSize + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = pageSize + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + _freeTempSpace(tls, pBt) + rc = _sqlite3PagerSetPagesize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pBt+52, libc.Int32FromUint32(pageSize-usableSize)) + return rc + } + if nPage > **(**Tu32)(__ccgo_up(bp + 8)) { + if _sqlite3WritableSchema(tls, (*TBtShared)(unsafe.Pointer(pBt)).Fdb) == 0 { + rc = _sqlite3CorruptError(tls, int32(76544)) + goto page1_init_failed + } else { + nPage = **(**Tu32)(__ccgo_up(bp + 8)) + } + } + /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to + ** be less than 480. In other words, if the page size is 512, then the + ** reserved space size cannot exceed 32. */ + if usableSize < uint32(480) { + goto page1_init_failed + } + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = pageSize + (*TBtShared)(unsafe.Pointer(pBt)).FusableSize = usableSize + if _sqlite3Get4byte(tls, page1+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(4)*libc.Int32FromInt32(4))) != 0 { + v4 = int32(1) + } else { + v4 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(v4) + if _sqlite3Get4byte(tls, page1+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(7)*libc.Int32FromInt32(4))) != 0 { + v4 = int32(1) + } else { + v4 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(v4) + } + /* maxLocal is the maximum amount of payload to store locally for + ** a cell. Make sure it is small enough so that at least minFanout + ** cells can will fit on one page. We assume a 10-byte page header. + ** Besides the payload, the cell must store: + ** 2-byte pointer to the cell + ** 4-byte child pointer + ** 9-byte nKey value + ** 4-byte nData value + ** 4-byte overflow page pointer + ** So a cell consists of a 2-byte pointer, a header which is as much as + ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow + ** page pointer. + */ + (*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal = uint16(((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(12))*libc.Uint32FromInt32(64)/libc.Uint32FromInt32(255) - libc.Uint32FromInt32(23)) + (*TBtShared)(unsafe.Pointer(pBt)).FminLocal = uint16(((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(12))*libc.Uint32FromInt32(32)/libc.Uint32FromInt32(255) - libc.Uint32FromInt32(23)) + (*TBtShared)(unsafe.Pointer(pBt)).FmaxLeaf = uint16((*TBtShared)(unsafe.Pointer(pBt)).FusableSize - libc.Uint32FromInt32(35)) + (*TBtShared)(unsafe.Pointer(pBt)).FminLeaf = uint16(((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(12))*libc.Uint32FromInt32(32)/libc.Uint32FromInt32(255) - libc.Uint32FromInt32(23)) + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal) > int32(127) { + (*TBtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload = uint8(127) + } else { + (*TBtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload = uint8((*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal) + } + (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 = **(**uintptr)(__ccgo_up(bp)) + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = nPage + return SQLITE_OK + goto page1_init_failed +page1_init_failed: + ; + _releasePageOne(tls, **(**uintptr)(__ccgo_up(bp))) + (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0) + return rc +} + +// C documentation +// +// /* +// ** Tag the given column as being part of the PRIMARY KEY +// */ +func _makeColumnPartOfPrimaryKey(tls *libc.TLS, pParse uintptr, pCol uintptr) { + var v1 uintptr + _ = v1 + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_PRIMKEY)) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14108, 0) + } +} + +// C documentation +// +// /* +// ** The pFunc is the only aggregate function in the query. Check to see +// ** if the query is a candidate for the min/max optimization. +// ** +// ** If the query is a candidate for the min/max optimization, then set +// ** *ppMinMax to be an ORDER BY clause to be used for the optimization +// ** and return either WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX depending on +// ** whether pFunc is a min() or max() function. +// ** +// ** If the query is not a candidate for the min/max optimization, return +// ** WHERE_ORDERBY_NORMAL (which must be zero). +// ** +// ** This routine must be called after aggregate functions have been +// ** located but before their arguments have been subjected to aggregate +// ** analysis. +// */ +func _minMaxQuery(tls *libc.TLS, db uintptr, pFunc uintptr, ppMinMax uintptr) (r Tu8) { + var eRet int32 + var pEList, pOrderBy, zFunc, v1 uintptr + var sortFlags Tu8 + _, _, _, _, _, _ = eRet, pEList, pOrderBy, sortFlags, zFunc, v1 + eRet = WHERE_ORDERBY_NORMAL + sortFlags = uint8(0) + pEList = *(*uintptr)(unsafe.Pointer(pFunc + 32)) + if pEList == uintptr(0) || (*TExprList)(unsafe.Pointer(pEList)).FnExpr != int32(1) || (*TExpr)(unsafe.Pointer(pFunc)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) || (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_MinMaxOpt)) != uint32(0) { + return libc.Uint8FromInt32(eRet) + } + zFunc = *(*uintptr)(unsafe.Pointer(pFunc + 8)) + if _sqlite3StrICmp(tls, zFunc, __ccgo_ts+16802) == 0 { + eRet = int32(WHERE_ORDERBY_MIN) + if _sqlite3ExprCanBeNull(tls, (*(*TExprList_item)(unsafe.Pointer(pEList + 8))).FpExpr) != 0 { + sortFlags = uint8(KEYINFO_ORDER_BIGNULL) + } + } else { + if _sqlite3StrICmp(tls, zFunc, __ccgo_ts+16806) == 0 { + eRet = int32(WHERE_ORDERBY_MAX) + sortFlags = uint8(KEYINFO_ORDER_DESC) + } else { + return libc.Uint8FromInt32(eRet) + } + } + v1 = _sqlite3ExprListDup(tls, db, pEList, 0) + pOrderBy = v1 + **(**uintptr)(__ccgo_up(ppMinMax)) = v1 + if pOrderBy != 0 { + (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8))).Ffg.FsortFlags = sortFlags + } + return libc.Uint8FromInt32(eRet) +} + +// C documentation +// +// /* +// ** This routine is called to process a compound query form from +// ** two or more separate queries using UNION, UNION ALL, EXCEPT, or +// ** INTERSECT +// ** +// ** "p" points to the right-most of the two queries. the query on the +// ** left is p->pPrior. The left query could also be a compound query +// ** in which case this routine will be called recursively. +// ** +// ** The results of the total query are to be written into a destination +// ** of type eDest with parameter iParm. +// ** +// ** Example 1: Consider a three-way compound SQL statement. +// ** +// ** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3 +// ** +// ** This statement is parsed up as follows: +// ** +// ** SELECT c FROM t3 +// ** | +// ** `-----> SELECT b FROM t2 +// ** | +// ** `------> SELECT a FROM t1 +// ** +// ** The arrows in the diagram above represent the Select.pPrior pointer. +// ** So if this routine is called with p equal to the t3 query, then +// ** pPrior will be the t2 query. p->op will be TK_UNION in this case. +// ** +// ** Notice that because of the way SQLite parses compound SELECTs, the +// ** individual selects always group from left to right. +// */ +func _multiSelect(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var addr, rc int32 + var db, pDelete, pOne, pPrior, v uintptr + var _ /* dest at bp+0 */ TSelectDest + var _ /* nLimit at bp+40 */ int32 + _, _, _, _, _, _, _ = addr, db, pDelete, pOne, pPrior, rc, v + rc = SQLITE_OK /* Alternative data destination */ + pDelete = uintptr(0) /* Database connection */ + /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only + ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT. + */ + /* Calling function guarantees this much */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pPrior = (*TSelect)(unsafe.Pointer(p)).FpPrior + **(**TSelectDest)(__ccgo_up(bp)) = **(**TSelectDest)(__ccgo_up(pDest)) + v = _sqlite3GetVdbe(tls, pParse) + /* The VDBE already created by calling function */ + /* Create the destination temporary table if necessary + */ + if libc.Int32FromUint8((**(**TSelectDest)(__ccgo_up(bp))).FeDest) == int32(SRT_EphemTab) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm, (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr) + (**(**TSelectDest)(__ccgo_up(bp))).FeDest = uint8(SRT_Table) + } + /* Special handling for a compound-select that originates as a VALUES clause. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_MultiValue) != 0 { + rc = _multiSelectValues(tls, pParse, p, bp) + if rc >= 0 { + goto multi_select_end + } + rc = SQLITE_OK + } + /* Make sure all SELECTs in the statement have the same number of elements + ** in their result sets. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Recursive) != uint32(0) && _hasAnchor(tls, p) != 0 { + _generateWithRecursiveQuery(tls, pParse, p, bp) + } else { + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 { + /* If the compound has an ORDER BY clause, then always use the merge + ** algorithm. */ + return _multiSelectByMerge(tls, pParse, p, pDest) + } else { + if libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop) != int32(TK_ALL) { + /* If the compound is EXCEPT, INTERSECT, or UNION (anything other than + ** UNION ALL) then also always use the merge algorithm. However, the + ** multiSelectByMerge() routine requires that the compound have an + ** ORDER BY clause, and it doesn't right now. So invent one first. */ + pOne = _sqlite3ExprInt32(tls, db, int32(1)) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = _sqlite3ExprListAppend(tls, pParse, uintptr(0), pOne) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto multi_select_end + } + *(*Tu16)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy + 8 + 24)) = uint16(1) + return _multiSelectByMerge(tls, pParse, p, pDest) + } else { + /* For a UNION ALL compound without ORDER BY, simply run the left + ** query, then run the right query */ + addr = 0 + **(**int32)(__ccgo_up(bp + 40)) = 0 /* Initialize to suppress harmless compiler warning */ + if (*TSelect)(unsafe.Pointer(pPrior)).FpPrior == uintptr(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20790, 0) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20805, 0) + } + (*TSelect)(unsafe.Pointer(pPrior)).FiLimit = (*TSelect)(unsafe.Pointer(p)).FiLimit + (*TSelect)(unsafe.Pointer(pPrior)).FiOffset = (*TSelect)(unsafe.Pointer(p)).FiOffset + (*TSelect)(unsafe.Pointer(pPrior)).FpLimit = _sqlite3ExprDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpLimit, 0) + rc = _sqlite3Select(tls, pParse, pPrior, bp) + _sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(pPrior)).FpLimit) + (*TSelect)(unsafe.Pointer(pPrior)).FpLimit = uintptr(0) + if rc != 0 { + goto multi_select_end + } + (*TSelect)(unsafe.Pointer(p)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FiLimit = (*TSelect)(unsafe.Pointer(pPrior)).FiLimit + (*TSelect)(unsafe.Pointer(p)).FiOffset = (*TSelect)(unsafe.Pointer(pPrior)).FiOffset + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 { + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), (*TSelect)(unsafe.Pointer(p)).FiLimit) + if (*TSelect)(unsafe.Pointer(p)).FiOffset != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_OffsetLimit), (*TSelect)(unsafe.Pointer(p)).FiLimit, (*TSelect)(unsafe.Pointer(p)).FiOffset+int32(1), (*TSelect)(unsafe.Pointer(p)).FiOffset) + } + } + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20485, 0) + rc = _sqlite3Select(tls, pParse, p, bp) + pDelete = (*TSelect)(unsafe.Pointer(p)).FpPrior + (*TSelect)(unsafe.Pointer(p)).FpPrior = pPrior + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3LogEstAdd(tls, (*TSelect)(unsafe.Pointer(p)).FnSelectRow, (*TSelect)(unsafe.Pointer(pPrior)).FnSelectRow) + if (*TSelect)(unsafe.Pointer(p)).FpLimit != 0 && _sqlite3ExprIsInteger(tls, (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpLimit)).FpLeft, bp+40, pParse) != 0 && **(**int32)(__ccgo_up(bp + 40)) > 0 && int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) > int32(_sqlite3LogEst(tls, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 40))))) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3LogEst(tls, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 40)))) + } + if addr != 0 { + _sqlite3VdbeJumpHere(tls, v, addr) + } + if (*TSelect)(unsafe.Pointer(p)).FpNext == uintptr(0) { + _sqlite3VdbeExplainPop(tls, pParse) + } + } + } + } + goto multi_select_end +multi_select_end: + ; + (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst = (**(**TSelectDest)(__ccgo_up(bp))).FiSdst + (*TSelectDest)(unsafe.Pointer(pDest)).FnSdst = (**(**TSelectDest)(__ccgo_up(bp))).FnSdst + (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 + if pDelete != 0 { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3SelectDeleteGeneric), pDelete) + } + return rc +} + +// C documentation +// +// /* +// ** Generate code for a compound SELECT statement using a merge +// ** algorithm. The compound must have an ORDER BY clause for this +// ** to work. +// ** +// ** We assume a query of the following form: +// ** +// ** ORDER BY +// ** +// ** is one of UNION ALL, UNION, EXCEPT, or INTERSECT. The idea +// ** is to code both and with the ORDER BY clause as +// ** co-routines. Then run the co-routines in parallel and merge the results +// ** into the output. In addition to the two coroutines (called selectA and +// ** selectB) there are 7 subroutines: +// ** +// ** outA: Move the output of the selectA coroutine into the output +// ** of the compound query. +// ** +// ** outB: Move the output of the selectB coroutine into the output +// ** of the compound query. (Only generated for UNION and +// ** UNION ALL. EXCEPT and INTERSECT never output a row that +// ** appears only in B.) +// ** +// ** AltB: Called when there is data from both coroutines and AB. +// ** +// ** EofA: Called when data is exhausted from selectA. +// ** +// ** EofB: Called when data is exhausted from selectB. +// ** +// ** The implementation of the latter five subroutines depend on which +// ** is used: +// ** +// ** +// ** UNION ALL UNION EXCEPT INTERSECT +// ** ------------- ----------------- -------------- ----------------- +// ** AltB: outA, nextA outA, nextA outA, nextA nextA +// ** +// ** AeqB: outA, nextA nextA nextA outA, nextA +// ** +// ** AgtB: outB, nextB outB, nextB nextB nextB +// ** +// ** EofA: outB, nextB outB, nextB halt halt +// ** +// ** EofB: outA, nextA outA, nextA outA, nextA halt +// ** +// ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA +// ** causes an immediate jump to EofA and an EOF on B following nextB causes +// ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or +// ** following nextX causes a jump to the end of the select processing. +// ** +// ** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled +// ** within the output subroutine. The regPrev register set holds the previously +// ** output value. A comparison is made against this value and the output +// ** is skipped if the next results would be the same as the previous. +// ** +// ** The implementation plan is to implement the two coroutines and seven +// ** subroutines first, then put the control logic at the bottom. Like this: +// ** +// ** goto Init +// ** coA: coroutine for left query (A) +// ** coB: coroutine for right query (B) +// ** outA: output one row of A +// ** outB: output one row of B (UNION and UNION ALL only) +// ** EofA: ... +// ** EofB: ... +// ** AltB: ... +// ** AeqB: ... +// ** AgtB: ... +// ** Init: initialize coroutine registers +// ** yield coA, on eof goto EofA +// ** yield coB, on eof goto EofB +// ** Cmpr: Compare A, B +// ** Jump AltB, AeqB, AgtB +// ** End: ... +// ** +// ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not +// ** actually called using Gosub and they do not Return. EofA and EofB loop +// ** until all data is exhausted then jump to the "end" label. AltB, AeqB, +// ** and AgtB jump to either Cmpr or to one of EofA or EofB. +// */ +func _multiSelectByMerge(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aPermute, db, pItem, pItem1, pKeyDup, pKeyMerge, pNew, pOrderBy, pPrior, pSplit, v, v3 uintptr + var addr1, addrAeqB, addrAgtB, addrAltB, addrEofA, addrEofA_noB, addrEofB, addrOutA, addrOutB, addrSelectA, addrSelectB, bKeep, i, j, labelCmpr, labelEnd, nExpr, nOrderBy, nSelect, op, regAddrA, regAddrB, regLimitA, regLimitB, regOutA, regOutB, regPrev, savedLimit, savedOffset, v4 int32 + var _ /* destA at bp+0 */ TSelectDest + var _ /* destB at bp+40 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aPermute, addr1, addrAeqB, addrAgtB, addrAltB, addrEofA, addrEofA_noB, addrEofB, addrOutA, addrOutB, addrSelectA, addrSelectB, bKeep, db, i, j, labelCmpr, labelEnd, nExpr, nOrderBy, nSelect, op, pItem, pItem1, pKeyDup, pKeyMerge, pNew, pOrderBy, pPrior, pSplit, regAddrA, regAddrB, regLimitA, regLimitB, regOutA, regOutB, regPrev, savedLimit, savedOffset, v, v3, v4 /* Address of the output-A subroutine */ + addrOutB = 0 /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */ + pKeyDup = uintptr(0) /* Mapping from ORDER BY terms to result set columns */ + /* "Managed" code needs this. Ticket #3382. */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* Already thrown the error if VDBE alloc failed */ + labelEnd = _sqlite3VdbeMakeLabel(tls, pParse) + labelCmpr = _sqlite3VdbeMakeLabel(tls, pParse) + /* Patch up the ORDER BY clause + */ + op = libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop) + pOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + nOrderBy = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr + /* For operators other than UNION ALL we have to make sure that + ** the ORDER BY clause covers every term of the result set. Add + ** terms to the ORDER BY clause as necessary. + */ + if op != int32(TK_ALL) { + i = int32(1) + for { + if !(libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 && i <= (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr) { + break + } + j = 0 + pItem = pOrderBy + 8 + for { + if !(j < nOrderBy) { + break + } + if libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol) == i { + break + } + goto _2 + _2: + ; + j = j + 1 + pItem += 32 + } + if j == nOrderBy { + pNew = _sqlite3ExprInt32(tls, db, i) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + v3 = _sqlite3ExprListAppend(tls, pParse, pOrderBy, pNew) + pOrderBy = v3 + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = v3 + if pOrderBy != 0 { + v4 = nOrderBy + nOrderBy = nOrderBy + 1 + *(*Tu16)(unsafe.Pointer(pOrderBy + 8 + uintptr(v4)*32 + 24)) = libc.Uint16FromInt32(i) + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + /* Compute the comparison permutation and keyinfo that is used with + ** the permutation to determine if the next row of results comes + ** from selectA or selectB. Also add literal collations to the + ** ORDER BY clause terms so that when selectA and selectB are + ** evaluated, they use the correct collation. + */ + aPermute = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(nOrderBy+libc.Int32FromInt32(1)))) + if aPermute != 0 { + bKeep = 0 + **(**Tu32)(__ccgo_up(aPermute)) = libc.Uint32FromInt32(nOrderBy) + i = int32(1) + pItem1 = pOrderBy + 8 + for { + if !(i <= nOrderBy) { + break + } + **(**Tu32)(__ccgo_up(aPermute + uintptr(i)*4)) = libc.Uint32FromInt32(libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem1 + 24))).FiOrderByCol) - int32(1)) + if **(**Tu32)(__ccgo_up(aPermute + uintptr(i)*4)) != libc.Uint32FromInt32(i)-uint32(1) { + bKeep = int32(1) + } + goto _5 + _5: + ; + i = i + 1 + pItem1 += 32 + } + if bKeep == 0 { + _sqlite3DbFreeNN(tls, db, aPermute) + aPermute = uintptr(0) + } + } + pKeyMerge = _multiSelectByMergeKeyInfo(tls, pParse, p, int32(1)) + /* Allocate a range of temporary registers and the KeyInfo needed + ** for the logic that removes duplicate result rows when the + ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL). + */ + if op == int32(TK_ALL) { + regPrev = 0 + } else { + nExpr = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr + regPrev = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nExpr + int32(1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regPrev) + pKeyDup = _sqlite3KeyInfoAlloc(tls, db, nExpr, int32(1)) + if pKeyDup != 0 { + i = 0 + for { + if !(i < nExpr) { + break + } + *(*uintptr)(unsafe.Pointer(pKeyDup + 32 + uintptr(i)*8)) = _multiSelectCollSeq(tls, pParse, p, i) + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyDup)).FaSortFlags + uintptr(i))) = uint8(0) + goto _6 + _6: + ; + i = i + 1 + } + } + } + /* Separate the left and the right query from one another + */ + nSelect = int32(1) + if (op == int32(TK_ALL) || op == int32(TK_UNION)) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_BalancedMerge)) == uint32(0) { + pSplit = p + for { + if !((*TSelect)(unsafe.Pointer(pSplit)).FpPrior != uintptr(0) && libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSplit)).Fop) == op) { + break + } + nSelect = nSelect + 1 + goto _7 + _7: + ; + pSplit = (*TSelect)(unsafe.Pointer(pSplit)).FpPrior + } + } + if nSelect <= int32(3) { + pSplit = p + } else { + pSplit = p + i = int32(2) + for { + if !(i < nSelect) { + break + } + pSplit = (*TSelect)(unsafe.Pointer(pSplit)).FpPrior + goto _8 + _8: + ; + i = i + int32(2) + } + } + pPrior = (*TSelect)(unsafe.Pointer(pSplit)).FpPrior + (*TSelect)(unsafe.Pointer(pSplit)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(pPrior)).FpNext = uintptr(0) + (*TSelect)(unsafe.Pointer(pPrior)).FpOrderBy = _sqlite3ExprListDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pOrderBy, 0) + _sqlite3ResolveOrderGroupBy(tls, pParse, p, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, __ccgo_ts+7659) + _sqlite3ResolveOrderGroupBy(tls, pParse, pPrior, (*TSelect)(unsafe.Pointer(pPrior)).FpOrderBy, __ccgo_ts+7659) + /* Compute the limit registers */ + _computeLimitRegisters(tls, pParse, p, labelEnd) + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 && op == int32(TK_ALL) { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regLimitA = v4 + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regLimitB = v4 + if (*TSelect)(unsafe.Pointer(p)).FiOffset != 0 { + v4 = (*TSelect)(unsafe.Pointer(p)).FiOffset + int32(1) + } else { + v4 = (*TSelect)(unsafe.Pointer(p)).FiLimit + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), v4, regLimitA) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), regLimitA, regLimitB) + } else { + v4 = libc.Int32FromInt32(0) + regLimitB = v4 + regLimitA = v4 + } + _sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpLimit) + (*TSelect)(unsafe.Pointer(p)).FpLimit = uintptr(0) + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regAddrA = v4 + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regAddrB = v4 + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regOutA = v4 + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v4 = *(*int32)(unsafe.Pointer(v3)) + regOutB = v4 + _sqlite3SelectDestInit(tls, bp, int32(SRT_Coroutine), regAddrA) + _sqlite3SelectDestInit(tls, bp+40, int32(SRT_Coroutine), regAddrB) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20952, libc.VaList(bp+88, _sqlite3SelectOpName(tls, libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop)))) + /* Generate a coroutine to evaluate the SELECT statement to the + ** left of the compound operator - the "A" select. + */ + addrSelectA = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regAddrA, 0, addrSelectA) + (*TSelect)(unsafe.Pointer(pPrior)).FiLimit = regLimitA + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20963, 0) + _sqlite3Select(tls, pParse, pPrior, bp) + _sqlite3VdbeEndCoroutine(tls, v, regAddrA) + _sqlite3VdbeJumpHere(tls, v, addr1) + /* Generate a coroutine to evaluate the SELECT statement on + ** the right - the "B" select + */ + addrSelectB = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regAddrB, 0, addrSelectB) + savedLimit = (*TSelect)(unsafe.Pointer(p)).FiLimit + savedOffset = (*TSelect)(unsafe.Pointer(p)).FiOffset + (*TSelect)(unsafe.Pointer(p)).FiLimit = regLimitB + (*TSelect)(unsafe.Pointer(p)).FiOffset = 0 + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+20968, 0) + _sqlite3Select(tls, pParse, p, bp+40) + (*TSelect)(unsafe.Pointer(p)).FiLimit = savedLimit + (*TSelect)(unsafe.Pointer(p)).FiOffset = savedOffset + _sqlite3VdbeEndCoroutine(tls, v, regAddrB) + /* Generate a subroutine that outputs the current row of the A + ** select as the next output row of the compound select. + */ + addrOutA = _generateOutputSubroutine(tls, pParse, p, bp, pDest, regOutA, regPrev, pKeyDup, labelEnd) + /* Generate a subroutine that outputs the current row of the B + ** select as the next output row of the compound select. + */ + if op == int32(TK_ALL) || op == int32(TK_UNION) { + addrOutB = _generateOutputSubroutine(tls, pParse, p, bp+40, pDest, regOutB, regPrev, pKeyDup, labelEnd) + } + _sqlite3KeyInfoUnref(tls, pKeyDup) + /* Generate a subroutine to run when the results from select A + ** are exhausted and only data in select B remains. + */ + if op == int32(TK_EXCEPT) || op == int32(TK_INTERSECT) { + v4 = labelEnd + addrEofA = v4 + addrEofA_noB = v4 + } else { + addrEofA = _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutB, addrOutB) + addrEofA_noB = _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrB, labelEnd) + _sqlite3VdbeGoto(tls, v, addrEofA) + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3LogEstAdd(tls, (*TSelect)(unsafe.Pointer(p)).FnSelectRow, (*TSelect)(unsafe.Pointer(pPrior)).FnSelectRow) + } + /* Generate a subroutine to run when the results from select B + ** are exhausted and only data in select A remains. + */ + if op == int32(TK_INTERSECT) { + addrEofB = addrEofA + if int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) > int32((*TSelect)(unsafe.Pointer(pPrior)).FnSelectRow) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = (*TSelect)(unsafe.Pointer(pPrior)).FnSelectRow + } + } else { + addrEofB = _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutA, addrOutA) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrA, labelEnd) + _sqlite3VdbeGoto(tls, v, addrEofB) + } + /* Generate code to handle the case of AB + */ + addrAgtB = _sqlite3VdbeCurrentAddr(tls, v) + if op == int32(TK_ALL) || op == int32(TK_UNION) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutB, addrOutB) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrB, addrEofB) + _sqlite3VdbeGoto(tls, v, labelCmpr) + } else { + addrAgtB = addrAgtB + 1 /* Just do next-B. Might as well use the next-B call + ** in the next code block */ + } + /* This code runs once to initialize everything. + */ + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrA, addrEofA_noB) + /* v--- Also the A>B case for EXCEPT and INTERSECT */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regAddrB, addrEofB) + /* Implement the main merge loop + */ + if aPermute != uintptr(0) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Permutation), 0, 0, 0, aPermute, -int32(15)) + } + _sqlite3VdbeResolveLabel(tls, v, labelCmpr) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Compare), (**(**TSelectDest)(__ccgo_up(bp))).FiSdst, (**(**TSelectDest)(__ccgo_up(bp + 40))).FiSdst, nOrderBy, pKeyMerge, -int32(9)) + if aPermute != uintptr(0) { + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_PERMUTE)) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addrAltB, addrAeqB, addrAgtB) + /* Jump to the this point in order to terminate the query. + */ + _sqlite3VdbeResolveLabel(tls, v, labelEnd) + /* Make arrangements to free the 2nd and subsequent arms of the compound + ** after the parse has finished */ + if (*TSelect)(unsafe.Pointer(pSplit)).FpPrior != 0 { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3SelectDeleteGeneric), (*TSelect)(unsafe.Pointer(pSplit)).FpPrior) + } + (*TSelect)(unsafe.Pointer(pSplit)).FpPrior = pPrior + (*TSelect)(unsafe.Pointer(pPrior)).FpNext = pSplit + _sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(pPrior)).FpOrderBy) + (*TSelect)(unsafe.Pointer(pPrior)).FpOrderBy = uintptr(0) + /*** TBD: Insert subroutine calls to close cursors on incomplete + **** subqueries ****/ + _sqlite3VdbeExplainPop(tls, pParse) + return libc.BoolInt32((*TParse)(unsafe.Pointer(pParse)).FnErr != 0) +} + +// C documentation +// +// /* +// ** Obtain a reference to an r-tree node. +// */ +func _nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode Ti64, pParent uintptr, ppNode uintptr) (r int32) { + var pBlob, pNode, v1 uintptr + var rc int32 + _, _, _, _ = pBlob, pNode, rc, v1 + rc = SQLITE_OK + pNode = uintptr(0) + /* Check if the requested node is already in the hash table. If so, + ** increase its reference count and return it. + */ + v1 = _nodeHashLookup(tls, pRtree, iNode) + pNode = v1 + if v1 != uintptr(0) { + if pParent != 0 && pParent != (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent { + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<iDepth to the height + ** of the r-tree structure. A height of zero means all data is stored on + ** the root node. A height of one means the children of the root node + ** are the leaves, and so on. If the depth as specified on the root node + ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt. + */ + if rc == SQLITE_OK && pNode != 0 && iNode == int64(1) { + (*TRtree)(unsafe.Pointer(pRtree)).FiDepth = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData) + if (*TRtree)(unsafe.Pointer(pRtree)).FiDepth > int32(RTREE_MAX_DEPTH) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< ((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize-int32(4))/libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<iCookie) contains the value of the + ** change-counter cookie (the thing that gets incremented when a + ** transaction is committed in rollback mode) currently stored on + ** page 1 of the database file. */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_BUSY) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v2 = __ccgo_ts + 34521 + } else { + v2 = __ccgo_ts + 34528 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+34535, libc.VaList(bp+16, v2)) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + db = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16103, uintptr(0), uintptr(0), p+64) + /* Point the object iterator at the first object */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _rbuObjIterFirst(tls, p, p+88) + } + /* If the RBU database contains no data_xxx tables, declare the RBU + ** update finished. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE) + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuState)(unsafe.Pointer(pState)).FeStage == 0 && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + _rbuCopyPragma(tls, p, __ccgo_ts+18650) + _rbuCopyPragma(tls, p, __ccgo_ts+18062) + } + /* Open transactions both databases. The *-oal file is opened or + ** created at this point. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, __ccgo_ts+34567, uintptr(0), uintptr(0), p+64) + } + /* Check if the main database is a zipvfs db. If it is, set the upper + ** level pager to use "journal_mode=off". This prevents it from + ** generating a large journal using a temp file. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + frc = Xsqlite3_file_control(tls, db, __ccgo_ts+6816, int32(SQLITE_FCNTL_ZIPVFS), uintptr(0)) + if frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, __ccgo_ts+34583, uintptr(0), uintptr(0), p+64) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuSetupOal(tls, p, pState) + } + } + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_MOVE) { + /* no-op */ + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_CKPT) { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == libc.UintptrFromInt32(0)) && _rbuExclusiveCheckpoint(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) != 0 { + /* If the rbu_exclusive_checkpoint=1 URI parameter was specified + ** and an incremental checkpoint is being resumed, attempt an + ** exclusive lock on the db file. If this fails, so be it. */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE) + _rbuLockDatabase(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CKPT) + } + _rbuSetupCheckpoint(tls, p, pState) + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_DONE) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE) + } else { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_CORRUPT) + } + } + } + } + } + _rbuFreeState(tls, pState) + } + return p +} + +// C documentation +// +// /* +// ** This routine generates code that opens the sqlite_statN tables. +// ** The sqlite_stat1 table is always relevant. sqlite_stat2 is now +// ** obsolete. sqlite_stat3 and sqlite_stat4 are only opened when +// ** appropriate compile-time options are provided. +// ** +// ** If the sqlite_statN tables do not previously exist, it is created. +// ** +// ** Argument zWhere may be a pointer to a buffer containing a table name, +// ** or it may be a NULL pointer. If it is not NULL, then all entries in +// ** the sqlite_statN tables associated with the named table are deleted. +// ** If zWhere==0, then code is generated to delete all stat table entries. +// */ +func _openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWhere uintptr, zWhereType uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aCreateTbl [3]Tu8 + var aRoot [3]Tu32 + var db, pDb, pStat, v, zTab, v3 uintptr + var i, nToOpen, v1 int32 + _, _, _, _, _, _, _, _, _, _, _ = aCreateTbl, aRoot, db, i, nToOpen, pDb, pStat, v, zTab, v1, v3 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = _sqlite3GetVdbe(tls, pParse) + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) { + v1 = int32(2) + } else { + v1 = int32(1) + } + nToOpen = v1 + if v == uintptr(0) { + return + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + /* Create new statistic tables if they do not exist, or clear them + ** if they do already exist. + */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(48)/libc.Uint64FromInt64(16))) { + break + } + zTab = _aTable[i].FzName + aCreateTbl[i] = uint8(0) + v3 = _sqlite3FindTable(tls, db, zTab, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) + pStat = v3 + if v3 == uintptr(0) { + if i < nToOpen { + /* The sqlite_statN table does not exist. Create it. Note that a + ** side-effect of the CREATE TABLE statement is to leave the rootpage + ** of the new table in register pParse->regRoot. This is important + ** because the OpenWrite opcode below will be needing it. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12913, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, zTab, _aTable[i].FzCols)) + aRoot[i] = libc.Uint32FromInt32((*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot) + aCreateTbl[i] = uint8(OPFLAG_P2ISREG) + } + } else { + /* The table already exists. If zWhere is not NULL, delete all entries + ** associated with the table zWhere. If zWhere is NULL, delete the + ** entire contents of the table. */ + aRoot[i] = (*TTable)(unsafe.Pointer(pStat)).Ftnum + _sqlite3TableLock(tls, pParse, iDb, aRoot[i], uint8(1), zTab) + if zWhere != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12936, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, zTab, zWhereType, zWhere)) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12966, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, zTab)) + } else { + /* The sqlite_stat[134] table already exists. Delete all rows. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Clear), libc.Int32FromUint32(aRoot[i]), iDb) + } + } + } + goto _2 + _2: + ; + i = i + 1 + } + /* Open the sqlite_stat[134] tables for writing. */ + i = 0 + for { + if !(i < nToOpen) { + break + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_OpenWrite), iStatCur+i, libc.Int32FromUint32(aRoot[i]), iDb, int32(3)) + _sqlite3VdbeChangeP5(tls, v, uint16(aCreateTbl[i])) + goto _4 + _4: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** For a compound SELECT statement, make sure p->pPrior->pNext==p for +// ** all elements in the list. And make sure list length does not exceed +// ** SQLITE_LIMIT_COMPOUND_SELECT. +// */ +func _parserDoubleLinkSelect(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var cnt, mxSelect, v2 int32 + var pLoop, pNext, v1 uintptr + var v3 bool + _, _, _, _, _, _, _ = cnt, mxSelect, pLoop, pNext, v1, v2, v3 + if (*TSelect)(unsafe.Pointer(p)).FpPrior != 0 { + pNext = uintptr(0) + pLoop = p + cnt = int32(1) + for int32(1) != 0 { + (*TSelect)(unsafe.Pointer(pLoop)).FpNext = pNext + **(**Tu32)(__ccgo_up(pLoop + 4)) |= uint32(SF_Compound) + pNext = pLoop + pLoop = (*TSelect)(unsafe.Pointer(pLoop)).FpPrior + if pLoop == uintptr(0) { + break + } + cnt = cnt + 1 + if (*TSelect)(unsafe.Pointer(pLoop)).FpOrderBy != 0 || (*TSelect)(unsafe.Pointer(pLoop)).FpLimit != 0 { + if (*TSelect)(unsafe.Pointer(pLoop)).FpOrderBy != uintptr(0) { + v1 = __ccgo_ts + 24785 + } else { + v1 = __ccgo_ts + 24794 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24800, libc.VaList(bp+8, v1, _sqlite3SelectOpName(tls, libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pNext)).Fop)))) + break + } + } + if v3 = (*TSelect)(unsafe.Pointer(p)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_MultiValue)|libc.Int32FromInt32(SF_Values)) == uint32(0); v3 { + v2 = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 4*4)) + mxSelect = v2 + } + if v3 && v2 > 0 && cnt > mxSelect { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24842, 0) + } + } +} + +// C documentation +// +// /* +// ** Pragma virtual table module xFilter method. +// */ +func _pragmaVtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, j, rc, v1 int32 + var pCsr, pTab, zSql, zText uintptr + var _ /* acc at bp+0 */ TStrAccum + _, _, _, _, _, _, _, _ = i, j, pCsr, pTab, rc, zSql, zText, v1 + pCsr = pVtabCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab + _ = idxNum + _ = idxStr + _pragmaVtabCursorClear(tls, pCsr) + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer((*TPragmaVtab)(unsafe.Pointer(pTab)).FpName)).FmPragFlg)&int32(PragFlg_Result1) != 0 { + v1 = 0 + } else { + v1 = int32(1) + } + j = v1 + i = 0 + for { + if !(i < argc) { + break + } + zText = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zText != 0 { + **(**uintptr)(__ccgo_up(pCsr + 24 + uintptr(j)*8)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+40, zText)) + if **(**uintptr)(__ccgo_up(pCsr + 24 + uintptr(j)*8)) == uintptr(0) { + return int32(SQLITE_NOMEM) + } + } + goto _2 + _2: + ; + i = i + 1 + j = j + 1 + } + _sqlite3StrAccumInit(tls, bp, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up((*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb + 136 + 1*4))) + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+19961) + if **(**uintptr)(__ccgo_up(pCsr + 24 + 1*8)) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+19969, libc.VaList(bp+40, **(**uintptr)(__ccgo_up(pCsr + 24 + 1*8)))) + } + Xsqlite3_str_appendall(tls, bp, (*TPragmaName)(unsafe.Pointer((*TPragmaVtab)(unsafe.Pointer(pTab)).FpName)).FzName) + if **(**uintptr)(__ccgo_up(pCsr + 24)) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+19973, libc.VaList(bp+40, **(**uintptr)(__ccgo_up(pCsr + 24)))) + } + zSql = _sqlite3StrAccumFinish(tls, bp) + if zSql == uintptr(0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_prepare_v2(tls, (*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb, zSql, -int32(1), pCsr+8, uintptr(0)) + Xsqlite3_free(tls, zSql) + if rc != SQLITE_OK { + (*TPragmaVtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+40, Xsqlite3_errmsg(tls, (*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb))) + return rc + } + return _pragmaVtabNext(tls, pVtabCursor) +} + +// C documentation +// +// /* +// ** The second argument passed to this function is the name of a PRAGMA +// ** setting - "page_size", "auto_vacuum", "user_version" or "application_id". +// ** This function executes the following on sqlite3rbu.dbRbu: +// ** +// ** "PRAGMA main.$zPragma" +// ** +// ** where $zPragma is the string passed as the second argument, then +// ** on sqlite3rbu.dbMain: +// ** +// ** "PRAGMA main.$zPragma = $val" +// ** +// ** where $val is the value returned by the first PRAGMA invocation. +// ** +// ** In short, it copies the value of the specified PRAGMA setting from +// ** dbRbu to dbMain. +// */ +func _rbuCopyPragma(tls *libc.TLS, p uintptr, zPragma uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* pPragma at bp+0 */ uintptr + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+33906, libc.VaList(bp+16, zPragma))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33921, libc.VaList(bp+16, zPragma, Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0))) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + } +} + +// C documentation +// +// /* +// ** If an error has already occurred when this function is called, it +// ** immediately returns zero (without doing any work). Or, if an error +// ** occurs during the execution of this function, it sets the error code +// ** in the sqlite3rbu object indicated by the first argument and returns +// ** zero. +// ** +// ** The iterator passed as the second argument is guaranteed to point to +// ** a table (not an index) when this function is called. This function +// ** attempts to create any imposter table required to write to the main +// ** table b-tree of the table before returning. Non-zero is returned if +// ** an imposter table are created, or zero otherwise. +// ** +// ** An imposter table is required in all cases except RBU_PK_VTAB. Only +// ** virtual tables are written to directly. The imposter table has the +// ** same schema as the actual target table (less any UNIQUE constraints). +// ** More precisely, the "same schema" means the same columns, types, +// ** collation sequences. For tables that do not have an external PRIMARY +// ** KEY, it also means the same PRIMARY KEY declaration. +// */ +func _rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iCol, tnum int32 + var zCol, zComma, zPk, zPk1, zSql, v2 uintptr + var _ /* zColl at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = iCol, tnum, zCol, zComma, zPk, zPk1, zSql, v2 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType != int32(RBU_PK_VTAB) { + tnum = (*TRbuObjIter)(unsafe.Pointer(pIter)).FiTnum + zComma = __ccgo_ts + 1704 + zSql = uintptr(0) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, 0, int32(1))) + iCol = 0 + for { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && iCol < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + zPk = __ccgo_ts + 1704 + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCol)*8)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_table_column_metadata(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zCol, uintptr(0), bp, uintptr(0), uintptr(0), uintptr(0)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) && **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iCol))) != 0 { + /* If the target table column is an "INTEGER PRIMARY KEY", add + ** "PRIMARY KEY" to the imposter table column declaration. */ + zPk = __ccgo_ts + 31957 + } + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabNotNull + uintptr(iCol))) != 0 { + v2 = __ccgo_ts + 31970 + } else { + v2 = __ccgo_ts + 1704 + } + zSql = _rbuMPrintf(tls, p, __ccgo_ts+31980, libc.VaList(bp+16, zSql, zComma, zCol, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCol)*8)), zPk, **(**uintptr)(__ccgo_up(bp)), v2)) + zComma = __ccgo_ts + 16214 + goto _1 + _1: + ; + iCol = iCol + 1 + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_WITHOUT_ROWID) { + zPk1 = _rbuWithoutRowidPK(tls, p, pIter) + if zPk1 != 0 { + zSql = _rbuMPrintf(tls, p, __ccgo_ts+32007, libc.VaList(bp+16, zSql, zPk1)) + } + } + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, int32(1), tnum)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_WITHOUT_ROWID) { + v2 = __ccgo_ts + 32014 + } else { + v2 = __ccgo_ts + 1704 + } + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+32029, libc.VaList(bp+16, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zSql, v2)) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, 0, 0)) + } +} + +// C documentation +// +// /* +// ** This function creates the second imposter table used when writing to +// ** a table b-tree where the table has an external primary key. If the +// ** iterator passed as the second argument does not currently point to +// ** a table (not index) with an external primary key, this function is a +// ** no-op. +// ** +// ** Assuming the iterator does point to a table with an external PK, this +// ** function creates a WITHOUT ROWID imposter table named "rbu_imposter2" +// ** used to access that PK index. For example, if the target table is +// ** declared as follows: +// ** +// ** CREATE TABLE t1(a, b TEXT, c REAL, PRIMARY KEY(b, c)); +// ** +// ** then the imposter table schema is: +// ** +// ** CREATE TABLE rbu_imposter2(c1 TEXT, c2 REAL, id INTEGER) WITHOUT ROWID; +// ** +// */ +func _rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bDesc, bKey, iCid, tnum int32 + var zCollate, zCols, zComma, zIdx, zPk, v1 uintptr + var _ /* pQuery at bp+0 */ uintptr + var _ /* pXInfo at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _ = bDesc, bKey, iCid, tnum, zCollate, zCols, zComma, zIdx, zPk, v1 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) { + tnum = (*TRbuObjIter)(unsafe.Pointer(pIter)).FiPkTnum /* Root page of PK index */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* SELECT name ... WHERE rootpage = $tnum */ + zIdx = uintptr(0) /* Name of PK index */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* PRAGMA main.index_xinfo = $zIdx */ + zComma = __ccgo_ts + 1704 + zCols = uintptr(0) /* Used to build up list of table cols */ + zPk = uintptr(0) /* Used to build up table PK declaration */ + /* Figure out the name of the primary key index for the current table. + ** This is needed for the argument to "PRAGMA index_xinfo". Set + ** zIdx to point to a nul-terminated string containing this name. */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, __ccgo_ts+31798) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_bind_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), tnum) + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zIdx = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + } + if zIdx != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30950, libc.VaList(bp+24, zIdx))) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + bKey = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(5)) + if bKey != 0 { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(1)) + bDesc = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(3)) + zCollate = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(4)) + zCols = _rbuMPrintf(tls, p, __ccgo_ts+31848, libc.VaList(bp+24, zCols, zComma, iCid, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCid)*8)), zCollate)) + if bDesc != 0 { + v1 = __ccgo_ts + 31190 + } else { + v1 = __ccgo_ts + 1704 + } + zPk = _rbuMPrintf(tls, p, __ccgo_ts+31870, libc.VaList(bp+24, zPk, zComma, iCid, v1)) + zComma = __ccgo_ts + 16214 + } + } + zCols = _rbuMPrintf(tls, p, __ccgo_ts+31880, libc.VaList(bp+24, zCols)) + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+24, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, int32(1), tnum)) + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+31895, libc.VaList(bp+24, zCols, zPk)) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+24, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, 0, 0)) + } +} + +// C documentation +// +// /* +// ** The RBU handle passed as the only argument has just been opened and +// ** the state database is empty. If this RBU handle was opened for an +// ** RBU vacuum operation, create the schema in the target db. +// */ +func _rbuCreateTargetSchema(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var zSql uintptr + var _ /* pInsert at bp+8 */ uintptr + var _ /* pSql at bp+0 */ uintptr + _, _ = i, zSql + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33941, uintptr(0), uintptr(0), p+64) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, __ccgo_ts+33966) + } + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { + zSql = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, zSql, uintptr(0), uintptr(0), p+64) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, __ccgo_ts+34074) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, __ccgo_ts+34139) + } + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { + i = 0 + for { + if !(i < int32(5)) { + break + } + Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), i+int32(1), Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp)), i)) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34183, uintptr(0), uintptr(0), p+64) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) +} + +// C documentation +// +// /* +// ** Implementation of SQL scalar function rbu_fossil_delta(). +// ** +// ** This function applies a fossil delta patch to a blob. Exactly two +// ** arguments must be passed to this function. The first is the blob to +// ** patch and the second the patch to apply. If no error occurs, this +// ** function returns the patched blob. +// */ +func _rbuFossilDeltaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var aDelta, aOrig, aOut uintptr + var nDelta, nOrig, nOut, nOut2 int32 + _, _, _, _, _, _, _ = aDelta, aOrig, aOut, nDelta, nOrig, nOut, nOut2 + _ = argc + nOrig = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + aOrig = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + nDelta = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + aDelta = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + /* Figure out the size of the output */ + nOut = _rbuDeltaOutputSize(tls, aDelta, nDelta) + if nOut < 0 { + Xsqlite3_result_error(tls, context, __ccgo_ts+30202, -int32(1)) + return + } + aOut = Xsqlite3_malloc(tls, nOut+int32(1)) + if aOut == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + } else { + nOut2 = _rbuDeltaApply(tls, aOrig, nOrig, aDelta, nDelta, aOut) + if nOut2 != nOut { + Xsqlite3_free(tls, aOut) + Xsqlite3_result_error(tls, context, __ccgo_ts+30202, -int32(1)) + } else { + Xsqlite3_result_blob(tls, context, aOut, nOut, __ccgo_fp(Xsqlite3_free)) + } + } +} + +// C documentation +// +// /* +// ** Set output variable *ppStmt to point to an UPDATE statement that may +// ** be used to update the imposter table for the main table b-tree of the +// ** table object that pIter currently points to, assuming that the +// ** rbu_control column of the data_xyz table contains zMask. +// ** +// ** If the zMask string does not specify any columns to update, then this +// ** is not an error. Output variable *ppStmt is set to NULL in this case. +// */ +func _rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, ppStmt uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var nUp int32 + var pUp, pp, zPrefix, zSet, zUpdate, zWhere uintptr + _, _, _, _, _, _, _ = nUp, pUp, pp, zPrefix, zSet, zUpdate, zWhere + pUp = uintptr(0) + nUp = 0 + /* In case an error occurs */ + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + /* Search for an existing statement. If one is found, shift it to the front + ** of the LRU queue and return immediately. Otherwise, leave nUp pointing + ** to the number of statements currently in the cache and pUp to the + ** last object in the list. */ + pp = pIter + 184 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + pUp = **(**uintptr)(__ccgo_up(pp)) + if libc.Xstrcmp(tls, (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask, zMask) == 0 { + **(**uintptr)(__ccgo_up(pp)) = (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext + (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp + **(**uintptr)(__ccgo_up(ppStmt)) = (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate + return SQLITE_OK + } + nUp = nUp + 1 + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 16 + } + if nUp >= int32(SQLITE_RBU_UPDATE_CACHESIZE) { + pp = pIter + 184 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != pUp) { + break + } + goto _2 + _2: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 16 + } + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + Xsqlite3_finalize(tls, (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate) + (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate = uintptr(0) + } else { + pUp = _rbuMalloc(tls, p, libc.Int64FromUint64(uint64(24)+libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)+uint64(1))) + } + if pUp != 0 { + zWhere = _rbuObjIterGetWhere(tls, p, pIter) + zSet = _rbuObjIterGetSetlist(tls, p, pIter, zMask) + zUpdate = uintptr(0) + (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask = pUp + 1*24 + libc.Xmemcpy(tls, (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask, zMask, libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)) + (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate + (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp + if zSet != 0 { + zPrefix = __ccgo_ts + 1704 + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType != int32(RBU_PK_VTAB) { + zPrefix = __ccgo_ts + 32630 + } + zUpdate = Xsqlite3_mprintf(tls, __ccgo_ts+33291, libc.VaList(bp+8, zPrefix, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zSet, zWhere)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pUp+8, p+64, zUpdate) + **(**uintptr)(__ccgo_up(ppStmt)) = (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate + } + Xsqlite3_free(tls, zWhere) + Xsqlite3_free(tls, zSet) + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** Increment the schema cookie of the main database opened by p->dbMain. +// ** +// ** Or, if this is an RBU vacuum, set the schema cookie of the main db +// ** opened by p->dbMain to one more than the schema cookie of the main +// ** db opened by p->dbRbu. +// */ +func _rbuIncrSchemaCookie(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var dbread, v1 uintptr + var iCookie int32 + var _ /* pStmt at bp+0 */ uintptr + _, _, _ = dbread, iCookie, v1 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu + } else { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain + } + dbread = v1 + iCookie = int32(1000000) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, dbread, bp, p+64, __ccgo_ts+33697) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* Coverage: it may be that this sqlite3_step() cannot fail. There + ** is already a transaction open, so the prepared statement cannot + ** throw an SQLITE_SCHEMA exception. The only database page the + ** statement reads is page 1, which is guaranteed to be in the cache. + ** And no memory allocations are required. */ + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iCookie = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33719, libc.VaList(bp+16, iCookie+int32(1))) + } + } +} + +// C documentation +// +// /* +// ** This user-defined SQL function is invoked with a single argument - the +// ** name of a table expected to appear in the target database. It returns +// ** the number of auxilliary indexes on the table. +// */ +func _rbuIndexCntFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, v1 uintptr + var nIndex, rc int32 + var _ /* pStmt at bp+0 */ uintptr + var _ /* zErrmsg at bp+8 */ uintptr + _, _, _, _, _ = db, nIndex, p, rc, v1 + p = Xsqlite3_user_data(tls, pCtx) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu + } else { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain + } + db = v1 + _ = nVal + rc = _prepareFreeAndCollectError(tls, db, bp, bp+8, Xsqlite3_mprintf(tls, __ccgo_ts+34272, libc.VaList(bp+24, Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal)))))) + if rc != SQLITE_OK { + Xsqlite3_result_error(tls, pCtx, **(**uintptr)(__ccgo_up(bp + 8)), -int32(1)) + } else { + nIndex = 0 + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + nIndex = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + Xsqlite3_result_int(tls, pCtx, nIndex) + } else { + Xsqlite3_result_error(tls, pCtx, Xsqlite3_errmsg(tls, db), -int32(1)) + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) +} + +// C documentation +// +// /* +// ** If the RBU database contains the rbu_count table, use it to initialize +// ** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table +// ** is assumed to contain the same columns as: +// ** +// ** CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID; +// ** +// ** There should be one row in the table for each data_xxx table in the +// ** database. The 'tbl' column should contain the name of a data_xxx table, +// ** and the cnt column the number of rows it contains. +// ** +// ** sqlite3rbu.nPhaseOneStep is initialized to the sum of (1 + nIndex) * cnt +// ** for all rows in the rbu_count table, where nIndex is the number of +// ** indexes on the corresponding target database table. +// */ +func _rbuInitPhaseOneSteps(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bExists int32 + var _ /* pStmt at bp+0 */ uintptr + _ = bExists + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + bExists = 0 /* True if rbu_count exists */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = int64(-int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+34344, int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_rbuIndexCntFunc), uintptr(0), uintptr(0)) + /* Check for the rbu_count table. If it does not exist, or if an error + ** occurs, nPhaseOneStep will be left set to -1. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, __ccgo_ts+34358) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + bExists = int32(1) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && bExists != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, __ccgo_ts+34415) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + } +} + +// C documentation +// +// /* +// ** Allocate an RbuState object and load the contents of the rbu_state +// ** table into it. Return a pointer to the new object. It is the +// ** responsibility of the caller to eventually free the object using +// ** sqlite3_free(). +// ** +// ** If an error occurs, leave an error code and message in the rbu handle +// ** and return NULL. +// */ +func _rbuLoadState(tls *libc.TLS, p uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pRet uintptr + var rc2 int32 + var _ /* pStmt at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _ = pRet, rc2 + pRet = uintptr(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pRet = _rbuMalloc(tls, p, int64(80)) + if pRet == uintptr(0) { + return uintptr(0) + } + **(**int32)(__ccgo_up(bp + 8)) = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+33321, libc.VaList(bp+24, p+48))) + for **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + switch Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) { + case int32(RBU_STATE_STAGE): + (*TRbuState)(unsafe.Pointer(pRet)).FeStage = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + if (*TRbuState)(unsafe.Pointer(pRet)).FeStage != int32(RBU_STAGE_OAL) && (*TRbuState)(unsafe.Pointer(pRet)).FeStage != int32(RBU_STAGE_MOVE) && (*TRbuState)(unsafe.Pointer(pRet)).FeStage != int32(RBU_STAGE_CKPT) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_CORRUPT) + } + case int32(RBU_STATE_TBL): + (*TRbuState)(unsafe.Pointer(pRet)).FzTbl = _rbuStrndup(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)), bp+8) + case int32(RBU_STATE_IDX): + (*TRbuState)(unsafe.Pointer(pRet)).FzIdx = _rbuStrndup(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)), bp+8) + case int32(RBU_STATE_ROW): + (*TRbuState)(unsafe.Pointer(pRet)).FnRow = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_PROGRESS): + (*TRbuState)(unsafe.Pointer(pRet)).FnProgress = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_CKPT): + (*TRbuState)(unsafe.Pointer(pRet)).FiWalCksum = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_COOKIE): + (*TRbuState)(unsafe.Pointer(pRet)).FiCookie = libc.Uint32FromInt64(Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1))) + case int32(RBU_STATE_OALSZ): + (*TRbuState)(unsafe.Pointer(pRet)).FiOalSz = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_PHASEONESTEP): + (*TRbuState)(unsafe.Pointer(pRet)).FnPhaseOneStep = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + case int32(RBU_STATE_DATATBL): + (*TRbuState)(unsafe.Pointer(pRet)).FzDataTbl = _rbuStrndup(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)), bp+8) + default: + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_CORRUPT) + break + } + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = rc2 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = **(**int32)(__ccgo_up(bp + 8)) + return pRet +} + +// C documentation +// +// /* +// ** The RBU handle is currently in RBU_STAGE_OAL state, with a SHARED lock +// ** on the database file. This proc moves the *-oal file to the *-wal path, +// ** then reopens the database file (this time in vanilla, non-oal, WAL mode). +// ** If an error occurs, leave an error code and error message in the rbu +// ** handle. +// */ +func _rbuMoveOalFile(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var dbMain, zBase, zMove, zOal, zWal uintptr + _, _, _, _, _ = dbMain, zBase, zMove, zOal, zWal + zBase = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816) + zMove = zBase + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + zMove = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816) + } + zOal = Xsqlite3_mprintf(tls, __ccgo_ts+33683, libc.VaList(bp+8, zMove)) + zWal = Xsqlite3_mprintf(tls, __ccgo_ts+33690, libc.VaList(bp+8, zMove)) + if zWal == uintptr(0) || zOal == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + /* Move the *-oal file to *-wal. At this point connection p->db is + ** holding a SHARED lock on the target database file (because it is + ** in WAL mode). So no other connection may be writing the db. + ** + ** In order to ensure that there are no database readers, an EXCLUSIVE + ** lock is obtained here before the *-oal is moved to *-wal. + */ + dbMain = uintptr(0) + _rbuFileSuffix3(tls, zBase, zWal) + _rbuFileSuffix3(tls, zBase, zOal) + /* Re-open the databases. */ + _rbuObjIterFinalize(tls, p+88) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu = uintptr(0) + dbMain = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget, int32(1)) + if dbMain != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _rbuLockDatabase(tls, dbMain) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3rbu)(unsafe.Pointer(p)).FxRename})))(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FpRenameArg, zOal, zWal) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK || (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) || _rbuExclusiveCheckpoint(tls, dbMain) == 0 { + Xsqlite3_close(tls, dbMain) + dbMain = uintptr(0) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuOpenDatabase(tls, p, dbMain, uintptr(0)) + _rbuSetupCheckpoint(tls, p, uintptr(0)) + } + } + Xsqlite3_free(tls, zWal) + Xsqlite3_free(tls, zOal) +} + +// C documentation +// +// /* +// ** This is a helper function for rbuObjIterCacheTableInfo(). It populates +// ** the pIter->abIndexed[] array. +// */ +func _rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bIndex, bPartial, iCid int32 + var zIdx uintptr + var _ /* pList at bp+0 */ uintptr + var _ /* pXInfo at bp+8 */ uintptr + _, _, _, _ = bIndex, bPartial, iCid, zIdx + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + bIndex = 0 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + libc.Xmemcpy(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, (*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk, uint64(1)*libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30922, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex = 0 + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zIdx = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + bPartial = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if zIdx == uintptr(0) { + break + } + if bPartial != 0 { + libc.Xmemset(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, int32(0x01), uint64(1)*libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30950, libc.VaList(bp+24, zIdx))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(1)) + if iCid >= 0 { + **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed + uintptr(iCid))) = uint8(1) + } + if iCid == -int32(2) { + libc.Xmemset(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, int32(0x01), uint64(1)*libc.Uint64FromInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)) + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + bIndex = int32(1) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex = (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex + 1 + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_WITHOUT_ROWID) { + /* "PRAGMA index_list" includes the main PK b-tree */ + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex = (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIndex - 1 + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + if bIndex == 0 { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed = uintptr(0) + } +} + +// C documentation +// +// /* +// ** If they are not already populated, populate the pIter->azTblCol[], +// ** pIter->abTblPk[], pIter->nTblCol and pIter->bRowid variables according to +// ** the table (not index) that the iterator currently points to. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code otherwise. If +// ** an error does occur, an error code and error message are also left in +// ** the RBU handle. +// */ +func _rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bNotNull, bRbuRowid, i, iOrder, iPk, nCol, t, v2 int32 + var t1, zCopy, zName, zName1, zType, v3 uintptr + var _ /* iTnum at bp+8 */ int32 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNotNull, bRbuRowid, i, iOrder, iPk, nCol, t, t1, zCopy, zName, zName1, zType, v2, v3 + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol == uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + nCol = 0 /* for() loop iterator variable */ + bRbuRowid = 0 /* If input table has column "rbu_rowid" */ + iOrder = 0 + **(**int32)(__ccgo_up(bp + 8)) = 0 + /* Figure out the type of table this step will deal with. */ + _rbuTableType(tls, p, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, pIter+72, bp+8, pIter+108) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NOTABLE { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+21299, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FiTnum = **(**int32)(__ccgo_up(bp + 8)) + } + /* Populate the azTblCol[] and nTblCol variables based on the columns + ** of the input table. Ignore any input table columns that begin with + ** "rbu_". */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30979, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + nCol = Xsqlite3_column_count(tls, **(**uintptr)(__ccgo_up(bp))) + _rbuAllocateIterArrays(tls, p, pIter, nCol) + } + i = 0 + for { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && i < nCol) { + break + } + zName = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), i) + if Xsqlite3_strnicmp(tls, __ccgo_ts+30998, zName, int32(4)) != 0 { + zCopy = _rbuStrndup(tls, zName, p+56) + **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr((*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)*4)) = (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol + v3 = pIter + 16 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(v2)*8)) = zCopy + } else { + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+31003, zName) { + bRbuRowid = int32(1) + } + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && bRbuRowid != libc.BoolInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE)) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + if bRbuRowid != 0 { + v3 = __ccgo_ts + 31013 + } else { + v3 = __ccgo_ts + 31026 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+31035, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, v3)) + } + /* Check that all non-HIDDEN columns in the destination table are also + ** present in the input table. Populate the abTblPk[], azTblType[] and + ** aiTblOrder[] arrays at the same time. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31064, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) + } + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zName1 = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + if zName1 == uintptr(0) { + break + } /* An OOM - finalize() below returns S_NOMEM */ + i = iOrder + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if 0 == libc.Xstrcmp(tls, zName1, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8))) { + break + } + goto _5 + _5: + ; + i = i + 1 + } + if i == (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+31086, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zName1)) + } else { + iPk = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(5)) + bNotNull = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) + zType = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(2)) + if i != iOrder { + t = **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4)) + **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4)) = **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(iOrder)*4)) + **(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(iOrder)*4)) = t + t1 = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iOrder)*8)) + **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iOrder)*8)) = t1 + } + **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iOrder)*8)) = _rbuStrndup(tls, zType, p+56) + **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iOrder))) = libc.Uint8FromInt32(iPk) + **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabNotNull + uintptr(iOrder))) = libc.BoolUint8(libc.Uint8FromInt32(bNotNull) != 0 || iPk != 0) + iOrder = iOrder + 1 + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + _rbuObjIterCacheIndexedCols(tls, p, pIter) + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** Initialize the iterator structure passed as the second argument. +// ** +// ** If no error occurs, SQLITE_OK is returned and the iterator is left +// ** pointing to the first entry. Otherwise, an error code and message is +// ** left in the RBU handle passed as the first argument. A copy of the +// ** error code is returned. +// */ +func _rbuObjIterFirst(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var v1 uintptr + _, _ = rc, v1 + libc.Xmemset(tls, pIter, 0, uint64(192)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = __ccgo_ts + 30394 + } else { + v1 = __ccgo_ts + 1704 + } + rc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30435, libc.VaList(bp+8, v1))) + if rc == SQLITE_OK { + rc = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+8, p+64, __ccgo_ts+30585) + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = int32(1) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + return _rbuObjIterNext(tls, p, pIter) +} + +// C documentation +// +// /* +// ** This function constructs and returns a pointer to a nul-terminated +// ** string containing some SQL clause or list based on one or more of the +// ** column names currently stored in the pIter->azTblCol[] array. +// */ +func _rbuObjIterGetCollist(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var z, zList, zSep uintptr + _, _, _, _ = i, z, zList, zSep + zList = uintptr(0) + zSep = __ccgo_ts + 1704 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + z = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + zList = _rbuMPrintf(tls, p, __ccgo_ts+31113, libc.VaList(bp+8, zList, zSep, z)) + zSep = __ccgo_ts + 16214 + goto _1 + _1: + ; + i = i + 1 + } + return zList +} + +// C documentation +// +// /* +// ** This function is used to create a SELECT list (the list of SQL +// ** expressions that follows a SELECT keyword) for a SELECT statement +// ** used to read from an data_xxx or rbu_tmp_xxx table while updating the +// ** index object currently indicated by the iterator object passed as the +// ** second argument. A "PRAGMA index_xinfo = " statement is used +// ** to obtain the required information. +// ** +// ** If the index is of the following form: +// ** +// ** CREATE INDEX i1 ON t1(c, b COLLATE nocase); +// ** +// ** and "t1" is a table with an explicit INTEGER PRIMARY KEY column +// ** "ipk", the returned string is: +// ** +// ** "`c` COLLATE 'BINARY', `b` COLLATE 'NOCASE', `ipk` COLLATE 'BINARY'" +// ** +// ** As well as the returned string, three other malloc'd strings are +// ** returned via output parameters. As follows: +// ** +// ** pzImposterCols: ... +// ** pzImposterPk: ... +// ** pzWhere: ... +// */ +func _rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterCols uintptr, pzImposterPk uintptr, pzWhere uintptr, pnBind uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bDesc, i, iCid, iSeq, nBind, rc, rc2 int32 + var zAnd, zCol, zCollate, zCom, zImpCols, zImpPK, zOrder, zRet, zType, zWhere, v2 uintptr + var _ /* pXInfo at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bDesc, i, iCid, iSeq, nBind, rc, rc2, zAnd, zCol, zCollate, zCom, zImpCols, zImpPK, zOrder, zRet, zType, zWhere, v2 + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc /* sqlite3_finalize() return code */ + zRet = uintptr(0) /* String to return */ + zImpCols = uintptr(0) /* String to return via *pzImposterCols */ + zImpPK = uintptr(0) /* String to return via *pzImposterPK */ + zWhere = uintptr(0) /* String to return via *pzWhere */ + nBind = 0 /* Value to return via *pnBind */ + zCom = __ccgo_ts + 1704 /* Set to ", " later on */ + zAnd = __ccgo_ts + 1704 /* Set to " AND " later on */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* PRAGMA index_xinfo = ? */ + if rc == SQLITE_OK { + rc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30950, libc.VaList(bp+16, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) + } + for rc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + bDesc = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) + zCollate = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + zCol = uintptr(0) + if iCid == -int32(2) { + iSeq = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+31432, libc.VaList(bp+16, zRet, zCom, (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iSeq)*16))).FnSpan, (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iSeq)*16))).FzSpan, zCollate)) + zType = __ccgo_ts + 1704 + } else { + if iCid < 0 { + /* An integer primary key. If the table has an explicit IPK, use + ** its name. Otherwise, use "rbu_rowid". */ + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) { + i = 0 + for { + if !(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + } else { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + zCol = __ccgo_ts + 31273 + } else { + zCol = __ccgo_ts + 31003 + } + } + zType = __ccgo_ts + 1178 + } else { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCid)*8)) + zType = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCid)*8)) + } + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+31454, libc.VaList(bp+16, zRet, zCom, zCol, zCollate)) + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FbUnique == 0 || Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(5)) != 0 { + if bDesc != 0 { + v2 = __ccgo_ts + 31190 + } else { + v2 = __ccgo_ts + 1704 + } + zOrder = v2 + zImpPK = Xsqlite3_mprintf(tls, __ccgo_ts+31474, libc.VaList(bp+16, zImpPK, zCom, nBind, zCol, zOrder)) + } + zImpCols = Xsqlite3_mprintf(tls, __ccgo_ts+31495, libc.VaList(bp+16, zImpCols, zCom, nBind, zCol, zType, zCollate)) + zWhere = Xsqlite3_mprintf(tls, __ccgo_ts+31528, libc.VaList(bp+16, zWhere, zAnd, nBind, zCol)) + if zRet == uintptr(0) || zImpPK == uintptr(0) || zImpCols == uintptr(0) || zWhere == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + zCom = __ccgo_ts + 16214 + zAnd = __ccgo_ts + 23560 + nBind = nBind + 1 + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + rc = rc2 + } + if rc != SQLITE_OK { + Xsqlite3_free(tls, zRet) + Xsqlite3_free(tls, zImpCols) + Xsqlite3_free(tls, zImpPK) + Xsqlite3_free(tls, zWhere) + zRet = uintptr(0) + zImpCols = uintptr(0) + zImpPK = uintptr(0) + zWhere = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + **(**uintptr)(__ccgo_up(pzImposterCols)) = zImpCols + **(**uintptr)(__ccgo_up(pzImposterPk)) = zImpPK + **(**uintptr)(__ccgo_up(pzWhere)) = zWhere + **(**int32)(__ccgo_up(pnBind)) = nBind + return zRet +} + +// C documentation +// +// /* +// ** Assuming the current table columns are "a", "b" and "c", and the zObj +// ** paramter is passed "old", return a string of the form: +// ** +// ** "old.a, old.b, old.b" +// ** +// ** With the column names escaped. +// ** +// ** For tables with implicit rowids - RBU_PK_EXTERNAL and RBU_PK_NONE, append +// ** the text ", old._rowid_" to the returned value. +// */ +func _rbuObjIterGetOldlist(tls *libc.TLS, p uintptr, pIter uintptr, zObj uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var zCol, zList, zS uintptr + _, _, _, _ = i, zCol, zList, zS + zList = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 { + zS = __ccgo_ts + 1704 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed + uintptr(i))) != 0 { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + zList = Xsqlite3_mprintf(tls, __ccgo_ts+31552, libc.VaList(bp+8, zList, zS, zObj, zCol)) + } else { + zList = Xsqlite3_mprintf(tls, __ccgo_ts+31564, libc.VaList(bp+8, zList, zS)) + } + zS = __ccgo_ts + 16214 + if zList == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + break + } + goto _1 + _1: + ; + i = i + 1 + } + /* For a table with implicit rowids, append "old._rowid_" to the list. */ + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31573, libc.VaList(bp+8, zList, zObj)) + } + } + return zList +} + +// C documentation +// +// /* +// ** Return a comma separated list of the quoted PRIMARY KEY column names, +// ** in order, for the current table. Before each column name, add the text +// ** zPre. After each column name, add the zPost text. Use zSeparator as +// ** the separator text (usually ", "). +// */ +func _rbuObjIterGetPkList(tls *libc.TLS, p uintptr, pIter uintptr, zPre uintptr, zSeparator uintptr, zPost uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, iPk int32 + var zCol, zRet, zSep uintptr + _, _, _, _, _ = i, iPk, zCol, zRet, zSep + iPk = int32(1) + zRet = uintptr(0) + zSep = __ccgo_ts + 1704 + for int32(1) != 0 { + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == iPk { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31122, libc.VaList(bp+8, zRet, zSep, zPre, zCol, zPost)) + zSep = zSeparator + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i == (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { + break + } + iPk = iPk + 1 + } + return zRet +} + +// C documentation +// +// /* +// ** Return an expression that can be used in a WHERE clause to match the +// ** primary key of the current table. For example, if the table is: +// ** +// ** CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c)); +// ** +// ** Return the string: +// ** +// ** "b = ?1 AND c = ?2" +// */ +func _rbuObjIterGetWhere(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, i1 int32 + var zCol, zList, zSep, zSep1 uintptr + _, _, _, _, _, _ = i, i1, zCol, zList, zSep, zSep1 + zList = uintptr(0) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31588, libc.VaList(bp+8, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+int32(1))) + } else { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) { + zSep = __ccgo_ts + 1704 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31602, libc.VaList(bp+8, zList, zSep, i, i+int32(1))) + zSep = __ccgo_ts + 23560 + } + goto _1 + _1: + ; + i = i + 1 + } + zList = _rbuMPrintf(tls, p, __ccgo_ts+31614, libc.VaList(bp+8, zList)) + } else { + zSep1 = __ccgo_ts + 1704 + i1 = 0 + for { + if !(i1 < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i1))) != 0 { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i1)*8)) + zList = _rbuMPrintf(tls, p, __ccgo_ts+31664, libc.VaList(bp+8, zList, zSep1, zCol, i1+int32(1))) + zSep1 = __ccgo_ts + 23560 + } + goto _2 + _2: + ; + i1 = i1 + 1 + } + } + } + return zList +} + +// C documentation +// +// /* +// ** Advance the iterator to the next position. +// ** +// ** If no error occurs, SQLITE_OK is returned and the iterator is left +// ** pointing to the next entry. Otherwise, an error code and message is +// ** left in the RBU handle passed as the first argument. A copy of the +// ** error code is returned. +// */ +func _rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + var pIdx uintptr + var rc, v1 int32 + _, _, _ = pIdx, rc, v1 + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + if rc == SQLITE_OK { + /* Free any SQLite statements used while processing the previous object */ + _rbuObjIterClearStatements(tls, pIter) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+30223, uintptr(0), uintptr(0), p+64) + } + if rc == SQLITE_OK { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 { + _rbuObjIterFreeCols(tls, pIter) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 0 + rc = Xsqlite3_step(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter) + if rc != int32(SQLITE_ROW) { + rc = _resetAndCollectError(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, p+64) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl = uintptr(0) + } else { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl = Xsqlite3_column_text(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, 0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl = Xsqlite3_column_text(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, int32(1)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl != 0 && (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 { + v1 = SQLITE_OK + } else { + v1 = int32(SQLITE_NOMEM) + } + rc = v1 + } + } else { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + pIdx = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter + rc = Xsqlite3_bind_text(tls, pIdx, int32(1), (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, -int32(1), libc.UintptrFromInt32(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_step(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter) + if rc != int32(SQLITE_ROW) { + rc = _resetAndCollectError(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, p+64) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = int32(1) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx = uintptr(0) + } else { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx = Xsqlite3_column_text(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FiTnum = Xsqlite3_column_int(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, int32(1)) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FbUnique = Xsqlite3_column_int(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, int32(2)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx != 0 { + v1 = SQLITE_OK + } else { + v1 = int32(SQLITE_NOMEM) + } + rc = v1 + } + } + } + } + } + if rc != SQLITE_OK { + _rbuObjIterFinalize(tls, pIter) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + return rc +} + +// C documentation +// +// /* +// ** Ensure that the SQLite statement handles required to update the +// ** target database object currently indicated by the iterator passed +// ** as the second argument are available. +// */ +func _rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var bRbuRowid, tnum int32 + var pz, zBind, zBindings, zCollist, zIdx, zLimit, zNewlist, zOldlist, zOrder, zPart, zRbuRowid, zRbuRowid1, zSql, zStart, zStart1, zTbl, zTbl1, zWhere1, zWrite, v1, v2, v3 uintptr + var _ /* nBind at bp+24 */ int32 + var _ /* zImposterCols at bp+0 */ uintptr + var _ /* zImposterPK at bp+8 */ uintptr + var _ /* zWhere at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bRbuRowid, pz, tnum, zBind, zBindings, zCollist, zIdx, zLimit, zNewlist, zOldlist, zOrder, zPart, zRbuRowid, zRbuRowid1, zSql, zStart, zStart1, zTbl, zTbl1, zWhere1, zWrite, v1, v2, v3 + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect == uintptr(0) && _rbuObjIterCacheTableInfo(tls, p, pIter) == SQLITE_OK { + tnum = (*TRbuObjIter)(unsafe.Pointer(pIter)).FiTnum + zCollist = uintptr(0) /* List of indexed columns */ + pz = p + 64 + zIdx = (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx + zLimit = uintptr(0) + if nOffset != 0 { + zLimit = Xsqlite3_mprintf(tls, __ccgo_ts+32184, libc.VaList(bp+40, nOffset)) + if !(zLimit != 0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } + } + if zIdx != 0 { + zTbl = (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Columns for imposter table */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Primary key declaration for imposter */ + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) /* WHERE clause on PK columns */ + zBind = uintptr(0) + zPart = uintptr(0) + **(**int32)(__ccgo_up(bp + 24)) = 0 + zPart = _rbuObjIterGetIndexWhere(tls, p, pIter) + zCollist = _rbuObjIterGetIndexCols(tls, p, pIter, bp, bp+8, bp+16, bp+24) + zBind = _rbuObjIterGetBindlist(tls, p, **(**int32)(__ccgo_up(bp + 24))) + /* Create the imposter table used to write to this index. */ + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+40, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, 0, int32(1))) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+40, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, int32(1), tnum)) + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+32204, libc.VaList(bp+40, zTbl, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 8)))) + Xsqlite3_test_control(tls, int32(SQLITE_TESTCTRL_IMPOSTER), libc.VaList(bp+40, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, 0, 0)) + /* Create the statement to insert index entries */ + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol = **(**int32)(__ccgo_up(bp + 24)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+136, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+32269, libc.VaList(bp+40, zTbl, zBind))) + } + /* And to delete index entries */ + if libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+144, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+32305, libc.VaList(bp+40, zTbl, **(**uintptr)(__ccgo_up(bp + 16))))) + } + /* Create the SELECT statement to read keys in sorted order */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + zStart = uintptr(0) + if nOffset != 0 { + zStart = _rbuVacuumIndexStart(tls, p, pIter) + if zStart != 0 { + Xsqlite3_free(tls, zLimit) + zLimit = uintptr(0) + } + } + if zStart != 0 { + if zPart != 0 { + v2 = __ccgo_ts + 32339 + } else { + v2 = __ccgo_ts + 32343 + } + v1 = v2 + } else { + v1 = __ccgo_ts + 1704 + } + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+32349, libc.VaList(bp+40, zCollist, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart, v1, zStart, zCollist, zLimit)) + Xsqlite3_free(tls, zStart) + } else { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+32410, libc.VaList(bp+40, zCollist, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart, zCollist, zLimit)) + } else { + if zPart != 0 { + v1 = __ccgo_ts + 32339 + } else { + v1 = __ccgo_ts + 32343 + } + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+32471, libc.VaList(bp+40, zCollist, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart, zCollist, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart, v1, zCollist, zLimit)) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+128, pz, zSql) + } else { + Xsqlite3_free(tls, zSql) + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 16))) + Xsqlite3_free(tls, zBind) + Xsqlite3_free(tls, zPart) + } else { + bRbuRowid = libc.BoolInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) + zTbl1 = (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl /* Imposter table name */ + zBindings = _rbuObjIterGetBindlist(tls, p, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+bRbuRowid) + zWhere1 = _rbuObjIterGetWhere(tls, p, pIter) + zOldlist = _rbuObjIterGetOldlist(tls, p, pIter, __ccgo_ts+6827) + zNewlist = _rbuObjIterGetOldlist(tls, p, pIter, __ccgo_ts+6823) + zCollist = _rbuObjIterGetCollist(tls, p, pIter) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol = (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol + /* Create the imposter table or tables (if required). */ + _rbuCreateImposterTable(tls, p, pIter) + _rbuCreateImposterTable2(tls, p, pIter) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) { + v1 = __ccgo_ts + 1704 + } else { + v1 = __ccgo_ts + 32630 + } + zWrite = v1 + /* Create the INSERT statement to write to the target PK b-tree */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if bRbuRowid != 0 { + v1 = __ccgo_ts + 32639 + } else { + v1 = __ccgo_ts + 1704 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+136, pz, Xsqlite3_mprintf(tls, __ccgo_ts+32649, libc.VaList(bp+40, zWrite, zTbl1, zCollist, v1, zBindings))) + } + /* Create the DELETE statement to write to the target PK b-tree. + ** Because it only performs INSERT operations, this is not required for + ** an rbu vacuum handle. */ + if libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+144, pz, Xsqlite3_mprintf(tls, __ccgo_ts+32685, libc.VaList(bp+40, zWrite, zTbl1, zWhere1))) + } + if libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 { + zRbuRowid = __ccgo_ts + 1704 + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + zRbuRowid = __ccgo_ts + 32713 + } + /* Create the rbu_tmp_xxx table and the triggers to populate it. */ + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) { + v1 = __ccgo_ts + 32725 + } else { + v1 = __ccgo_ts + 1704 + } + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+32742, libc.VaList(bp+40, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, v1, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl)) + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+32818, libc.VaList(bp+40, zWrite, zTbl1, zOldlist, zWrite, zTbl1, zOldlist, zWrite, zTbl1, zNewlist)) + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33117, libc.VaList(bp+40, zWrite, zTbl1, zNewlist)) + } + _rbuObjIterPrepareTmpInsert(tls, p, pIter, zCollist, zRbuRowid) + } + /* Create the SELECT statement to read keys from data_xxx */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + zRbuRowid1 = __ccgo_ts + 1704 + zStart1 = uintptr(0) + zOrder = uintptr(0) + if bRbuRowid != 0 { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = __ccgo_ts + 33216 + } else { + v1 = __ccgo_ts + 33226 + } + zRbuRowid1 = v1 + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + if nOffset != 0 { + zStart1 = _rbuVacuumTableStart(tls, p, pIter, bRbuRowid, zWrite) + if zStart1 != 0 { + Xsqlite3_free(tls, zLimit) + zLimit = uintptr(0) + } + } + if bRbuRowid != 0 { + zOrder = _rbuMPrintf(tls, p, __ccgo_ts+31273, 0) + } else { + zOrder = _rbuObjIterGetPkList(tls, p, pIter, __ccgo_ts+1704, __ccgo_ts+16214, __ccgo_ts+1704) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = __ccgo_ts + 33237 + } else { + v1 = __ccgo_ts + 1704 + } + if zStart1 != 0 { + v2 = zStart1 + } else { + v2 = __ccgo_ts + 1704 + } + if zOrder != 0 { + v3 = __ccgo_ts + 24785 + } else { + v3 = __ccgo_ts + 1704 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+128, pz, Xsqlite3_mprintf(tls, __ccgo_ts+33243, libc.VaList(bp+40, zCollist, v1, zRbuRowid1, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, v2, v3, zOrder, zLimit))) + } + Xsqlite3_free(tls, zStart1) + Xsqlite3_free(tls, zOrder) + } + Xsqlite3_free(tls, zWhere1) + Xsqlite3_free(tls, zOldlist) + Xsqlite3_free(tls, zNewlist) + Xsqlite3_free(tls, zBindings) + } + Xsqlite3_free(tls, zCollist) + Xsqlite3_free(tls, zLimit) + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** Prepare a statement used to insert rows into the "rbu_tmp_xxx" table. +// ** Specifically a statement of the form: +// ** +// ** INSERT INTO rbu_tmp_xxx VALUES(?, ?, ? ...); +// ** +// ** The number of bound variables is equal to the number of columns in +// ** the target table, plus one (for the rbu_control column), plus one more +// ** (for the rbu_rowid column) if the target table is an implicit IPK or +// ** virtual table. +// */ +func _rbuObjIterPrepareTmpInsert(tls *libc.TLS, p uintptr, pIter uintptr, zCollist uintptr, zRbuRowid uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bRbuRowid int32 + var zBind uintptr + _, _ = bRbuRowid, zBind + bRbuRowid = libc.BoolInt32((*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE)) + zBind = _rbuObjIterGetBindlist(tls, p, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+int32(1)+bRbuRowid) + if zBind != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+152, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+32061, libc.VaList(bp+8, p+48, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zCollist, zRbuRowid, zBind))) + } +} + +// C documentation +// +// /* +// ** Update the contents of the rbu_state table within the rbu database. The +// ** value stored in the RBU_STATE_STAGE column is eStage. All other values +// ** are determined by inspecting the rbu handle passed as the first argument. +// */ +func _rbuSaveState(tls *libc.TLS, p uintptr, eStage int32) { + bp := tls.Alloc(192) + defer tls.Free(192) + var pFd, v1 uintptr + var rc int32 + var _ /* pInsert at bp+0 */ uintptr + _, _, _ = pFd, rc, v1 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK || (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_DONE) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd + } else { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd + } + pFd = v1 + rc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+33746, libc.VaList(bp+16, p+48, int32(RBU_STATE_STAGE), eStage, int32(RBU_STATE_TBL), (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl, int32(RBU_STATE_IDX), (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzIdx, int32(RBU_STATE_ROW), (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep, int32(RBU_STATE_PROGRESS), (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress, int32(RBU_STATE_CKPT), (*Tsqlite3rbu)(unsafe.Pointer(p)).FiWalCksum, int32(RBU_STATE_COOKIE), libc.Int64FromUint32((*Trbu_file)(unsafe.Pointer(pFd)).FiCookie), int32(RBU_STATE_OALSZ), (*Tsqlite3rbu)(unsafe.Pointer(p)).FiOalSz, int32(RBU_STATE_PHASEONESTEP), (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep, int32(RBU_STATE_DATATBL), (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzDataTbl))) + if rc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + if rc != SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + } +} + +// C documentation +// +// /* +// ** This function is called as part of sqlite3rbu_open() when initializing +// ** an rbu handle in OAL stage. If the rbu update has not started (i.e. +// ** the rbu_state table was empty) it is a no-op. Otherwise, it arranges +// ** things so that the next call to sqlite3rbu_step() continues on from +// ** where the previous rbu handle left off. +// ** +// ** If an error occurs, an error code and error message are left in the +// ** rbu handle passed as the first argument. +// */ +func _rbuSetupOal(tls *libc.TLS, p uintptr, pState uintptr) { + var pIter uintptr + var rc int32 + _, _ = pIter, rc + if (*TRbuState)(unsafe.Pointer(pState)).FzTbl != 0 { + pIter = p + 88 + rc = SQLITE_OK + for rc == SQLITE_OK && (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 && ((*TRbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 || _rbuStrCompare(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx, (*TRbuState)(unsafe.Pointer(pState)).FzIdx) != 0 || (*TRbuState)(unsafe.Pointer(pState)).FzDataTbl == uintptr(0) && _rbuStrCompare(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, (*TRbuState)(unsafe.Pointer(pState)).FzTbl) != 0 || (*TRbuState)(unsafe.Pointer(pState)).FzDataTbl != 0 && _rbuStrCompare(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, (*TRbuState)(unsafe.Pointer(pState)).FzDataTbl) != 0) { + rc = _rbuObjIterNext(tls, p, pIter) + } + if rc == SQLITE_OK && !((*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0) { + rc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+34236, 0) + } + if rc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = (*TRbuState)(unsafe.Pointer(pState)).FnRow + rc = _rbuObjIterPrepareAll(tls, p, p+88, (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } +} + +// C documentation +// +// /* +// ** Argument eType must be one of RBU_INSERT, RBU_DELETE, RBU_IDX_INSERT or +// ** RBU_IDX_DELETE. This function performs the work of a single +// ** sqlite3rbu_step() call for the type of operation specified by eType. +// */ +func _rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { + var i int32 + var pIter, pVal, pWriter uintptr + _, _, _, _ = i, pIter, pVal, pWriter + pIter = p + 88 + /* If this is a delete, decrement nPhaseOneStep by nIndex. If the DELETE + ** statement below does actually delete a row, nPhaseOneStep will be + ** incremented by the same amount when SQL function rbu_tmp_insert() + ** is invoked by the trigger. */ + if eType == int32(RBU_DELETE) { + **(**Ti64)(__ccgo_up(p + 312)) -= int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex) + } + if eType == int32(RBU_IDX_DELETE) || eType == int32(RBU_DELETE) { + pWriter = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpDelete + } else { + pWriter = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpInsert + } + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol) { + break + } + /* If this is an INSERT into a table b-tree and the table has an + ** explicit INTEGER PRIMARY KEY, check that this is not an attempt + ** to write a NULL into the IPK column. That is not permitted. */ + if eType == int32(RBU_INSERT) && (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) && (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) && **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 && Xsqlite3_column_type(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) == int32(SQLITE_NULL) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_MISMATCH) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+25606, 0) + return + } + if eType == int32(RBU_DELETE) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0 { + goto _1 + } + pVal = Xsqlite3_column_value(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, pWriter, i+int32(1), pVal) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + return + } + goto _1 + _1: + ; + i = i + 1 + } + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_EXTERNAL) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + /* For a virtual table, or a table with no primary key, the + ** SELECT statement is: + ** + ** SELECT , rbu_control, rbu_rowid FROM .... + ** + ** Hence column_value(pIter->nCol+1). + */ + pVal = Xsqlite3_column_value(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol+int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, pWriter, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol+int32(1), pVal) + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_step(tls, pWriter) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _resetAndCollectError(tls, pWriter, p+64) + } +} + +// C documentation +// +// /* Determine the type of a table. +// ** +// ** peType is of type (int*), a pointer to an output parameter of type +// ** (int). This call sets the output parameter as follows, depending +// ** on the type of the table specified by parameters dbName and zTbl. +// ** +// ** RBU_PK_NOTABLE: No such table. +// ** RBU_PK_NONE: Table has an implicit rowid. +// ** RBU_PK_IPK: Table has an explicit IPK column. +// ** RBU_PK_EXTERNAL: Table has an external PK index. +// ** RBU_PK_WITHOUT_ROWID: Table is WITHOUT ROWID. +// ** RBU_PK_VTAB: Table is a virtual table. +// ** +// ** Argument *piPk is also of type (int*), and also points to an output +// ** parameter. Unless the table has an external primary key index +// ** (i.e. unless *peType is set to 3), then *piPk is set to zero. Or, +// ** if the table does have an external primary key index, then *piPk +// ** is set to the root page number of the primary key index before +// ** returning. +// ** +// ** ALGORITHM: +// ** +// ** if( no entry exists in sqlite_schema ){ +// ** return RBU_PK_NOTABLE +// ** }else if( sql for the entry starts with "CREATE VIRTUAL" ){ +// ** return RBU_PK_VTAB +// ** }else if( "PRAGMA index_list()" for the table contains a "pk" index ){ +// ** if( the index that is the pk exists in sqlite_schema ){ +// ** *piPK = rootpage of that index. +// ** return RBU_PK_EXTERNAL +// ** }else{ +// ** return RBU_PK_WITHOUT_ROWID +// ** } +// ** }else if( "PRAGMA table_info()" lists one or more "pk" columns ){ +// ** return RBU_PK_IPK +// ** }else{ +// ** return RBU_PK_NONE +// ** } +// */ +func _rbuTableType(tls *libc.TLS, p uintptr, zTab uintptr, peType uintptr, piTnum uintptr, piPk uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i uint32 + var zIdx, zOrig uintptr + var _ /* aStmt at bp+0 */ [4]uintptr + _, _, _ = i, zIdx, zOrig + /* + ** 0) SELECT count(*) FROM sqlite_schema where name=%Q AND IsVirtual(%Q) + ** 1) PRAGMA index_list = ? + ** 2) SELECT count(*) FROM sqlite_schema where name=%Q + ** 3) PRAGMA table_info = ? + */ + **(**[4]uintptr)(__ccgo_up(bp)) = [4]uintptr{} + **(**int32)(__ccgo_up(peType)) = RBU_PK_NOTABLE + **(**int32)(__ccgo_up(piPk)) = 0 + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30710, libc.VaList(bp+40, zTab))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK || Xsqlite3_step(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[0]) != int32(SQLITE_ROW) { + /* Either an error, or no such table. */ + goto rbuTableType_end + } + if Xsqlite3_column_int(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[0], 0) != 0 { + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_VTAB) /* virtual table */ + goto rbuTableType_end + } + **(**int32)(__ccgo_up(piTnum)) = Xsqlite3_column_int(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[0], int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+1*8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30829, libc.VaList(bp+40, zTab))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + goto rbuTableType_end + } + for Xsqlite3_step(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(1)]) == int32(SQLITE_ROW) { + zOrig = Xsqlite3_column_text(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(1)], int32(3)) + zIdx = Xsqlite3_column_text(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(1)], int32(1)) + if zOrig != 0 && zIdx != 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zOrig))) == int32('p') { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+2*8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30850, libc.VaList(bp+40, zIdx))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if Xsqlite3_step(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(2)]) == int32(SQLITE_ROW) { + **(**int32)(__ccgo_up(piPk)) = Xsqlite3_column_int(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(2)], 0) + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_EXTERNAL) + } else { + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_WITHOUT_ROWID) + } + } + goto rbuTableType_end + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+3*8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30901, libc.VaList(bp+40, zTab))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + for Xsqlite3_step(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(3)]) == int32(SQLITE_ROW) { + if Xsqlite3_column_int(tls, (**(**[4]uintptr)(__ccgo_up(bp)))[int32(3)], int32(5)) > 0 { + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_IPK) /* explicit IPK column */ + goto rbuTableType_end + } + } + **(**int32)(__ccgo_up(peType)) = int32(RBU_PK_NONE) + } + goto rbuTableType_end +rbuTableType_end: + ; + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(32)/libc.Uint64FromInt64(8)) { + break + } + _rbuFinalize(tls, p, (**(**[4]uintptr)(__ccgo_up(bp)))[i]) + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** This function is called as part of restarting an RBU vacuum within +// ** stage 1 of the process (while the *-oal file is being built) while +// ** updating a table (not an index). The table may be a rowid table or +// ** a WITHOUT ROWID table. It queries the target database to find the +// ** largest key that has already been written to the target table and +// ** constructs a WHERE clause that can be used to extract the remaining +// ** rows from the source table. For a rowid table, the WHERE clause +// ** is of the form: +// ** +// ** "WHERE _rowid_ > ?" +// ** +// ** and for WITHOUT ROWID tables: +// ** +// ** "WHERE (key1, key2) > (?, ?)" +// ** +// ** Instead of "?" placeholders, the actual WHERE clauses created by +// ** this function contain literal SQL values. +// */ +func _rbuVacuumTableStart(tls *libc.TLS, p uintptr, pIter uintptr, bRowid int32, zWrite uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iMax Tsqlite3_int64 + var zList, zOrder, zRet, zSelect, zVal uintptr + var _ /* pMax at bp+0 */ uintptr + _, _, _, _, _, _ = iMax, zList, zOrder, zRet, zSelect, zVal + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zRet = uintptr(0) + if bRowid != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31135, libc.VaList(bp+16, zWrite, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iMax = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31167, libc.VaList(bp+16, iMax)) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + } else { + zOrder = _rbuObjIterGetPkList(tls, p, pIter, __ccgo_ts+1704, __ccgo_ts+16214, __ccgo_ts+31190) + zSelect = _rbuObjIterGetPkList(tls, p, pIter, __ccgo_ts+31196, __ccgo_ts+31203, __ccgo_ts+5257) + zList = _rbuObjIterGetPkList(tls, p, pIter, __ccgo_ts+1704, __ccgo_ts+16214, __ccgo_ts+1704) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31211, libc.VaList(bp+16, zSelect, zWrite, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zVal = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31253, libc.VaList(bp+16, zList, zVal)) + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + } + Xsqlite3_free(tls, zOrder) + Xsqlite3_free(tls, zSelect) + Xsqlite3_free(tls, zList) + } + return zRet +} + +// C documentation +// +// /* +// ** The iterator currently points to a table (not index) of type +// ** RBU_PK_WITHOUT_ROWID. This function creates the PRIMARY KEY +// ** declaration for the corresponding imposter table. For example, +// ** if the iterator points to a table created as: +// ** +// ** CREATE TABLE t1(a, b, c, PRIMARY KEY(b, a DESC)) WITHOUT ROWID +// ** +// ** this function returns: +// ** +// ** PRIMARY KEY("b", "a" DESC) +// */ +func _rbuWithoutRowidPK(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var z, zCol, zDesc, zIdx, zOrig, zSep, v1 uintptr + var _ /* pXInfo at bp+8 */ uintptr + var _ /* pXList at bp+0 */ uintptr + _, _, _, _, _, _, _ = z, zCol, zDesc, zIdx, zOrig, zSep, v1 + z = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + zSep = __ccgo_ts + 31770 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* PRAGMA index_list = (pIter->zTbl) */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* PRAGMA index_xinfo = */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30922, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zOrig = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) + if zOrig != 0 && libc.Xstrcmp(tls, zOrig, __ccgo_ts+17851) == 0 { + zIdx = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + if zIdx != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30950, libc.VaList(bp+24, zIdx))) + } + break + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(5)) != 0 { + /* int iCid = sqlite3_column_int(pXInfo, 0); */ + zCol = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(2)) + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp + 8)), int32(3)) != 0 { + v1 = __ccgo_ts + 31190 + } else { + v1 = __ccgo_ts + 1704 + } + zDesc = v1 + z = _rbuMPrintf(tls, p, __ccgo_ts+31783, libc.VaList(bp+24, z, zSep, zCol, zDesc)) + zSep = __ccgo_ts + 16214 + } + } + z = _rbuMPrintf(tls, p, __ccgo_ts+31794, libc.VaList(bp+24, z)) + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + } + return z +} + +// C documentation +// +// /* +// ** SQL function: +// ** +// ** sqlite_rename_column(SQL,TYPE,OBJ,DB,TABLE,COL,NEWNAME,QUOTE,TEMP) +// ** +// ** 0. zSql: SQL statement to rewrite +// ** 1. type: Type of object ("table", "view" etc.) +// ** 2. object: Name of object +// ** 3. Database: Database name (e.g. "main") +// ** 4. Table: Table name +// ** 5. iCol: Index of column to rename +// ** 6. zNew: New column name +// ** 7. bQuote: Non-zero if the new column name should be quoted. +// ** 8. bTemp: True if zSql comes from temp schema +// ** +// ** Do a column rename operation on the CREATE statement given in zSql. +// ** The iCol-th column (left-most is 0) of table zTable is renamed from zCol +// ** into zNew. The name should be quoted if bQuote is true. +// ** +// ** This function is used internally by the ALTER TABLE RENAME COLUMN command. +// ** It is only accessible to SQL created using sqlite3NestedParse(). It is +// ** not reachable from ordinary SQL passed into sqlite3_prepare() unless the +// ** SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test setting is enabled. +// */ +func _renameColumnFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(496) + defer tls.Free(496) + var bFKOnly, bQuote, bTemp, i, iCol, rc, v1 int32 + var db, pExpr, pFKey, pIdx, pSelect, pStep, pTab, pTarget, pUpsertSet, zDb, zNew, zOld, zSql, zTable uintptr + var xAuth Tsqlite3_xauth + var _ /* sCtx at bp+0 */ TRenameCtx + var _ /* sParse at bp+32 */ TParse + var _ /* sWalker at bp+448 */ TWalker + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bFKOnly, bQuote, bTemp, db, i, iCol, pExpr, pFKey, pIdx, pSelect, pStep, pTab, pTarget, pUpsertSet, rc, xAuth, zDb, zNew, zOld, zSql, zTable, v1 + db = Xsqlite3_context_db_handle(tls, context) + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + zTable = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + iCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 5*8))) + zNew = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 6*8))) + bQuote = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 7*8))) + bTemp = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 8*8))) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + _ = NotUsed + if zSql == uintptr(0) { + return + } + if zTable == uintptr(0) { + return + } + if zNew == uintptr(0) { + return + } + if iCol < 0 { + return + } + _sqlite3BtreeEnterAll(tls, db) + pTab = _sqlite3FindTable(tls, db, zTable, zDb) + if pTab == uintptr(0) || iCol >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + _sqlite3BtreeLeaveAll(tls, db) + return + } + zOld = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + libc.Xmemset(tls, bp, 0, uint64(32)) + if iCol == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + v1 = -int32(1) + } else { + v1 = iCol + } + (**(**TRenameCtx)(__ccgo_up(bp))).FiCol = v1 + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + rc = _renameParseSql(tls, bp+32, zDb, db, zSql, bTemp) + /* Find tokens that need to be replaced. */ + libc.Xmemset(tls, bp+448, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp + 448))).FpParse = bp + 32 + (**(**TWalker)(__ccgo_up(bp + 448))).FxExprCallback = __ccgo_fp(_renameColumnExprCb) + (**(**TWalker)(__ccgo_up(bp + 448))).FxSelectCallback = __ccgo_fp(_renameColumnSelectCb) + *(*uintptr)(unsafe.Pointer(bp + 448 + 40)) = bp + (**(**TRenameCtx)(__ccgo_up(bp))).FpTab = pTab + if rc != SQLITE_OK { + goto renameColumnFunc_done + } + if (**(**TParse)(__ccgo_up(bp + 32))).FpNewTable != 0 { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FeTabType) == int32(TABTYP_VIEW) { + pSelect = (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).Fu))).FpSelect + **(**Tu32)(__ccgo_up(pSelect + 4)) &= ^libc.Uint32FromInt32(SF_View) + (**(**TParse)(__ccgo_up(bp + 32))).Frc = SQLITE_OK + _sqlite3SelectPrep(tls, bp+32, pSelect, uintptr(0)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + v1 = int32(SQLITE_NOMEM) + } else { + v1 = (**(**TParse)(__ccgo_up(bp + 32))).Frc + } + rc = v1 + if rc == SQLITE_OK { + _sqlite3WalkSelect(tls, bp+448, pSelect) + } + if rc != SQLITE_OK { + goto renameColumnFunc_done + } + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FeTabType) == TABTYP_NORM { + /* A regular table */ + bFKOnly = Xsqlite3_stricmp(tls, zTable, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FzName) + (**(**TRenameCtx)(__ccgo_up(bp))).FpTab = (**(**TParse)(__ccgo_up(bp + 32))).FpNewTable + if bFKOnly == 0 { + if iCol < int32((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FnCol) { + _renameTokenFind(tls, bp+32, bp, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FaCol + uintptr(iCol)*16))).FzCnName) + } + if (**(**TRenameCtx)(__ccgo_up(bp))).FiCol < 0 { + _renameTokenFind(tls, bp+32, bp, (**(**TParse)(__ccgo_up(bp + 32))).FpNewTable+52) + } + _sqlite3WalkExprList(tls, bp+448, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FpCheck) + pIdx = (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FpIndex + for { + if !(pIdx != 0) { + break + } + _sqlite3WalkExprList(tls, bp+448, (*TIndex)(unsafe.Pointer(pIdx)).FaColExpr) + goto _3 + _3: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + pIdx = (**(**TParse)(__ccgo_up(bp + 32))).FpNewIndex + for { + if !(pIdx != 0) { + break + } + _sqlite3WalkExprList(tls, bp+448, (*TIndex)(unsafe.Pointer(pIdx)).FaColExpr) + goto _4 + _4: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FnCol)) { + break + } + pExpr = _sqlite3ColumnExpr(tls, (**(**TParse)(__ccgo_up(bp + 32))).FpNewTable, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable)).FaCol+uintptr(i)*16) + _sqlite3WalkExpr(tls, bp+448, pExpr) + goto _5 + _5: + ; + i = i + 1 + } + } + pFKey = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTable + 64))).FpFKey + for { + if !(pFKey != 0) { + break + } + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + if bFKOnly == 0 && (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FiFrom == iCol { + _renameTokenFind(tls, bp+32, bp, pFKey+64+uintptr(i)*16) + } + if 0 == Xsqlite3_stricmp(tls, (*TFKey)(unsafe.Pointer(pFKey)).FzTo, zTable) && 0 == Xsqlite3_stricmp(tls, (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FzCol, zOld) { + _renameTokenFind(tls, bp+32, bp, (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FzCol) + } + goto _7 + _7: + ; + i = i + 1 + } + goto _6 + _6: + ; + pFKey = (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom + } + } + } + } else { + if (**(**TParse)(__ccgo_up(bp + 32))).FpNewIndex != 0 { + _sqlite3WalkExprList(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewIndex)).FaColExpr) + _sqlite3WalkExpr(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewIndex)).FpPartIdxWhere) + } else { + rc = _renameResolveTrigger(tls, bp+32) + if rc != SQLITE_OK { + goto renameColumnFunc_done + } + pStep = (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTrigger)).Fstep_list + for { + if !(pStep != 0) { + break + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + pTarget = _sqlite3LocateTableItem(tls, bp+32, uint32(0), (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc+8) + if pTarget == pTab { + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0 { + pUpsertSet = (*TUpsert)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert)).FpUpsertSet + _renameColumnElistNames(tls, bp+32, bp, pUpsertSet, zOld) + } + _renameColumnIdlistNames(tls, bp+32, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpIdList, zOld) + _renameColumnElistNames(tls, bp+32, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, zOld) + } + } + goto _8 + _8: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + /* Find tokens to edit in UPDATE OF clause */ + if (**(**TParse)(__ccgo_up(bp + 32))).FpTriggerTab == pTab { + _renameColumnIdlistNames(tls, bp+32, bp, (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp + 32))).FpNewTrigger)).FpColumns, zOld) + } + /* Find tokens to edit in various expressions and selects */ + _renameWalkTrigger(tls, bp+448, (**(**TParse)(__ccgo_up(bp + 32))).FpNewTrigger) + } + } + rc = _renameEditSql(tls, context, bp, zSql, zNew, bQuote) + goto renameColumnFunc_done +renameColumnFunc_done: + ; + if rc != SQLITE_OK { + if rc == int32(SQLITE_ERROR) && _sqlite3WritableSchema(tls, db) != 0 { + Xsqlite3_result_value(tls, context, **(**uintptr)(__ccgo_up(argv))) + } else { + if (**(**TParse)(__ccgo_up(bp + 32))).FzErrMsg != 0 { + _renameColumnParseError(tls, context, __ccgo_ts+1704, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), bp+32) + } else { + Xsqlite3_result_error_code(tls, context, rc) + } + } + } + _renameParseCleanup(tls, bp+32) + _renameTokenFree(tls, db, (**(**TRenameCtx)(__ccgo_up(bp))).FpList) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + _sqlite3BtreeLeaveAll(tls, db) +} + +// C documentation +// +// /* +// ** Parse the SQL statement zSql using Parse object (*p). The Parse object +// ** is initialized by this function before it is used. +// */ +func _renameParseSql(tls *libc.TLS, p uintptr, zDb uintptr, db uintptr, zSql uintptr, bTemp int32) (r int32) { + var flags Tu64 + var iDb, rc int32 + _, _, _ = flags, iDb, rc + _sqlite3ParseObjectInit(tls, p, db) + if zSql == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+11566, int32(7)) != 0 { + return _sqlite3CorruptError(tls, int32(121586)) + } + if bTemp != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(1) + } else { + iDb = _sqlite3FindDbName(tls, db, zDb) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(iDb) + } + (*TParse)(unsafe.Pointer(p)).FeParseMode = uint8(PARSE_MODE_RENAME) + (*TParse)(unsafe.Pointer(p)).Fdb = db + (*TParse)(unsafe.Pointer(p)).FnQueryLoop = int16(1) + flags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + **(**Tu64)(__ccgo_up(db + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(0x00040)) << libc.Int32FromInt32(32) + rc = _sqlite3RunParser(tls, p, zSql) + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = flags + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } + if rc == SQLITE_OK && ((*TParse)(unsafe.Pointer(p)).FpNewTable == uintptr(0) && (*TParse)(unsafe.Pointer(p)).FpNewIndex == uintptr(0) && (*TParse)(unsafe.Pointer(p)).FpNewTrigger == uintptr(0)) { + rc = _sqlite3CorruptError(tls, int32(121607)) + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + return rc +} + +// C documentation +// +// /* +// ** This C function implements an SQL user function that is used by SQL code +// ** generated by the ALTER TABLE ... RENAME command to modify the definition +// ** of any foreign key constraints that use the table being renamed as the +// ** parent table. It is passed three arguments: +// ** +// ** 0: The database containing the table being renamed. +// ** 1. type: Type of object ("table", "view" etc.) +// ** 2. object: Name of object +// ** 3: The complete text of the schema statement being modified, +// ** 4: The old name of the table being renamed, and +// ** 5: The new name of the table being renamed. +// ** 6: True if the schema statement comes from the temp db. +// ** +// ** It returns the new schema statement. For example: +// ** +// ** sqlite_rename_table('main', 'CREATE TABLE t1(a REFERENCES t2)','t2','t3',0) +// ** -> 'CREATE TABLE t1(a REFERENCES t3)' +// */ +func _renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(560) + defer tls.Free(560) + var bQuote, bTemp, i, isLegacy, rc int32 + var db, pFKey, pItem, pSelect, pStep, pTab, pTrigger, zDb, zInput, zNew, zOld uintptr + var xAuth Tsqlite3_xauth + var _ /* sCtx at bp+416 */ TRenameCtx + var _ /* sNC at bp+496 */ TNameContext + var _ /* sParse at bp+0 */ TParse + var _ /* sWalker at bp+448 */ TWalker + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bQuote, bTemp, db, i, isLegacy, pFKey, pItem, pSelect, pStep, pTab, pTrigger, rc, xAuth, zDb, zInput, zNew, zOld + db = Xsqlite3_context_db_handle(tls, context) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zInput = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + zOld = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + zNew = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 5*8))) + bTemp = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 6*8))) + _ = NotUsed + if zInput != 0 && zOld != 0 && zNew != 0 { + bQuote = int32(1) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + _sqlite3BtreeEnterAll(tls, db) + libc.Xmemset(tls, bp+416, 0, uint64(32)) + (**(**TRenameCtx)(__ccgo_up(bp + 416))).FpTab = _sqlite3FindTable(tls, db, zOld, zDb) + libc.Xmemset(tls, bp+448, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp + 448))).FpParse = bp + (**(**TWalker)(__ccgo_up(bp + 448))).FxExprCallback = __ccgo_fp(_renameTableExprCb) + (**(**TWalker)(__ccgo_up(bp + 448))).FxSelectCallback = __ccgo_fp(_renameTableSelectCb) + *(*uintptr)(unsafe.Pointer(bp + 448 + 40)) = bp + 416 + rc = _renameParseSql(tls, bp, zDb, db, zInput, bTemp) + if rc == SQLITE_OK { + isLegacy = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_LegacyAlter)) + if (**(**TParse)(__ccgo_up(bp))).FpNewTable != 0 { + pTab = (**(**TParse)(__ccgo_up(bp))).FpNewTable + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + if isLegacy == 0 { + pSelect = (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTab)).Fu))).FpSelect + libc.Xmemset(tls, bp+496, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp + 496))).FpParse = bp + **(**Tu32)(__ccgo_up(pSelect + 4)) &= ^libc.Uint32FromInt32(SF_View) + _sqlite3SelectPrep(tls, bp, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTab)).Fu))).FpSelect, bp+496) + if (**(**TParse)(__ccgo_up(bp))).FnErr != 0 { + rc = (**(**TParse)(__ccgo_up(bp))).Frc + } else { + _sqlite3WalkSelect(tls, bp+448, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTab)).Fu))).FpSelect) + } + } + } else { + /* Modify any FK definitions to point to the new table. */ + if (isLegacy == 0 || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + pFKey = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey + for { + if !(pFKey != 0) { + break + } + if Xsqlite3_stricmp(tls, (*TFKey)(unsafe.Pointer(pFKey)).FzTo, zOld) == 0 { + _renameTokenFind(tls, bp, bp+416, (*TFKey)(unsafe.Pointer(pFKey)).FzTo) + } + goto _1 + _1: + ; + pFKey = (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom + } + } + /* If this is the table being altered, fix any table refs in CHECK + ** expressions. Also update the name that appears right after the + ** "CREATE [VIRTUAL] TABLE" bit. */ + if Xsqlite3_stricmp(tls, zOld, (*TTable)(unsafe.Pointer(pTab)).FzName) == 0 { + (**(**TRenameCtx)(__ccgo_up(bp + 416))).FpTab = pTab + if isLegacy == 0 { + _sqlite3WalkExprList(tls, bp+448, (*TTable)(unsafe.Pointer(pTab)).FpCheck) + } + _renameTokenFind(tls, bp, bp+416, (*TTable)(unsafe.Pointer(pTab)).FzName) + } + } + } else { + if (**(**TParse)(__ccgo_up(bp))).FpNewIndex != 0 { + _renameTokenFind(tls, bp, bp+416, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewIndex)).FzName) + if isLegacy == 0 { + _sqlite3WalkExpr(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewIndex)).FpPartIdxWhere) + } + } else { + pTrigger = (**(**TParse)(__ccgo_up(bp))).FpNewTrigger + if 0 == Xsqlite3_stricmp(tls, (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTrigger)).Ftable, zOld) && (*TTable)(unsafe.Pointer((**(**TRenameCtx)(__ccgo_up(bp + 416))).FpTab)).FpSchema == (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema { + _renameTokenFind(tls, bp, bp+416, (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTrigger)).Ftable) + } + if isLegacy == 0 { + rc = _renameResolveTrigger(tls, bp) + if rc == SQLITE_OK { + _renameWalkTrigger(tls, bp+448, pTrigger) + pStep = (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list + for { + if !(pStep != 0) { + break + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc)).FnSrc) { + break + } + pItem = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 + uintptr(i)*80 + if 0 == Xsqlite3_stricmp(tls, (*TSrcItem)(unsafe.Pointer(pItem)).FzName, zOld) { + _renameTokenFind(tls, bp, bp+416, (*TSrcItem)(unsafe.Pointer(pItem)).FzName) + } + goto _3 + _3: + ; + i = i + 1 + } + } + goto _2 + _2: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + } + } + } + } + } + if rc == SQLITE_OK { + rc = _renameEditSql(tls, context, bp+416, zInput, zNew, bQuote) + } + if rc != SQLITE_OK { + if rc == int32(SQLITE_ERROR) && _sqlite3WritableSchema(tls, db) != 0 { + Xsqlite3_result_value(tls, context, **(**uintptr)(__ccgo_up(argv + 3*8))) + } else { + if (**(**TParse)(__ccgo_up(bp))).FzErrMsg != 0 { + _renameColumnParseError(tls, context, __ccgo_ts+1704, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), bp) + } else { + Xsqlite3_result_error_code(tls, context, rc) + } + } + } + _renameParseCleanup(tls, bp) + _renameTokenFree(tls, db, (**(**TRenameCtx)(__ccgo_up(bp + 416))).FpList) + _sqlite3BtreeLeaveAll(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + } + return +} + +// C documentation +// +// /* +// ** Generate code to verify that the schemas of database zDb and, if +// ** bTemp is not true, database "temp", can still be parsed. This is +// ** called at the end of the generation of an ALTER TABLE ... RENAME ... +// ** statement to ensure that the operation has not rendered any schema +// ** objects unusable. +// */ +func _renameTestSchema(tls *libc.TLS, pParse uintptr, zDb uintptr, bTemp int32, zWhen uintptr, bNoDQS int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 5, 0x20) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+8671, libc.VaList(bp+8, zDb, zDb, bTemp, zWhen, bNoDQS)) + if bTemp == 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+8846, libc.VaList(bp+8, zDb, zWhen, bNoDQS)) + } +} + +// C documentation +// +// /* +// ** Reset the aggregate accumulator. +// ** +// ** The aggregate accumulator is a set of memory cells that hold +// ** intermediate results while calculating an aggregate. This +// ** routine generates code that stores NULLs in all of those memory +// ** cells. +// */ +func _resetAccumulator(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, nExtra, nReg int32 + var pE, pFunc, pKeyInfo, pKeyInfo1, pOBList, v uintptr + _, _, _, _, _, _, _, _, _ = i, nExtra, nReg, pE, pFunc, pKeyInfo, pKeyInfo1, pOBList, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + nReg = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + if nReg == 0 { + return + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+nReg-int32(1)) + pFunc = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + i = libc.Int32FromInt32(0) + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + if (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct >= 0 { + pE = (*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr + if *(*uintptr)(unsafe.Pointer(pE + 32)) == uintptr(0) || (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pE + 32)))).FnExpr != int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21368, 0) + (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct = -int32(1) + } else { + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, *(*uintptr)(unsafe.Pointer(pE + 32)), 0, 0) + (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiDistAddr = _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct, 0, 0, pKeyInfo, -int32(9)) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+21419, libc.VaList(bp+8, (*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFunc)).FzName)) + } + } + if (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiOBTab >= 0 { + nExtra = 0 + pOBList = *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr)).FpLeft + 32)) + if !((*TAggInfo_func)(unsafe.Pointer(pFunc)).FbOBUnique != 0) { + nExtra = nExtra + 1 /* One extra column for the OP_Sequence */ + } + if (*TAggInfo_func)(unsafe.Pointer(pFunc)).FbOBPayload != 0 { + /* extra columns for the function arguments */ + nExtra = nExtra + (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr + 32)))).FnExpr + } + if (*TAggInfo_func)(unsafe.Pointer(pFunc)).FbUseSubtype != 0 { + nExtra = nExtra + (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr + 32)))).FnExpr + } + pKeyInfo1 = _sqlite3KeyInfoFromExprList(tls, pParse, pOBList, 0, nExtra) + if !((*TAggInfo_func)(unsafe.Pointer(pFunc)).FbOBUnique != 0) && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + (*TKeyInfo)(unsafe.Pointer(pKeyInfo1)).FnKeyField = (*TKeyInfo)(unsafe.Pointer(pKeyInfo1)).FnKeyField + 1 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), (*TAggInfo_func)(unsafe.Pointer(pFunc)).FiOBTab, (*TExprList)(unsafe.Pointer(pOBList)).FnExpr+nExtra, 0, pKeyInfo1, -int32(9)) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+21452, libc.VaList(bp+8, (*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pFunc)).FpFunc)).FzName)) + } + goto _1 + _1: + ; + i = i + 1 + pFunc += 32 + } +} + +// C documentation +// +// /* +// ** Analyze the ORDER BY clause in a compound SELECT statement. Modify +// ** each term of the ORDER BY clause is a constant integer between 1 +// ** and N where N is the number of columns in the compound SELECT. +// ** +// ** ORDER BY terms that are already an integer between 1 and N are +// ** unmodified. ORDER BY terms that are integers outside the range of +// ** 1 through N generate an error. ORDER BY terms that are expressions +// ** are matched against result set expressions of compound SELECT +// ** beginning with the left-most SELECT and working toward the right. +// ** At the first match, the ORDER BY expression is transformed into +// ** the integer column number. +// ** +// ** Return the number of errors seen. +// */ +func _resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pDup, pE, pEList, pItem, pNew, pOrderBy, pParent uintptr + var i, moreToDo int32 + var _ /* iCol at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = db, i, moreToDo, pDup, pE, pEList, pItem, pNew, pOrderBy, pParent + moreToDo = int32(1) + pOrderBy = (*TSelect)(unsafe.Pointer(pSelect)).FpOrderBy + if pOrderBy == uintptr(0) { + return 0 + } + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7625, 0) + return int32(1) + } + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + libc.SetBitFieldPtr16Uint32(pOrderBy+8+uintptr(i)*32+16+4, libc.Uint32FromInt32(0), 2, 0x4) + goto _1 + _1: + ; + i = i + 1 + } + (*TSelect)(unsafe.Pointer(pSelect)).FpNext = uintptr(0) + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + (*TSelect)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpPrior)).FpNext = pSelect + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + for pSelect != 0 && moreToDo != 0 { + moreToDo = 0 + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + i = 0 + pItem = pOrderBy + 8 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + **(**int32)(__ccgo_up(bp)) = -int32(1) + if int32(uint32(*(*uint16)(unsafe.Pointer(pItem + 16 + 4))&0x4>>2)) != 0 { + goto _2 + } + pE = _sqlite3ExprSkipCollateAndLikely(tls, (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr) + if pE == uintptr(0) { + goto _2 + } + if _sqlite3ExprIsInteger(tls, pE, bp, uintptr(0)) != 0 { + if **(**int32)(__ccgo_up(bp)) <= 0 || **(**int32)(__ccgo_up(bp)) > (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + _resolveOutOfRangeError(tls, pParse, __ccgo_ts+7659, i+int32(1), (*TExprList)(unsafe.Pointer(pEList)).FnExpr, pE) + return int32(1) + } + } else { + **(**int32)(__ccgo_up(bp)) = _resolveAsName(tls, pParse, pEList, pE) + if **(**int32)(__ccgo_up(bp)) == 0 { + /* Now test if expression pE matches one of the values returned + ** by pSelect. In the usual case this is done by duplicating the + ** expression, resolving any symbols in it, and then comparing + ** it against each expression returned by the SELECT statement. + ** Once the comparisons are finished, the duplicate expression + ** is deleted. + ** + ** If this is running as part of an ALTER TABLE operation and + ** the symbols resolve successfully, also resolve the symbols in the + ** actual expression. This allows the code in alter.c to modify + ** column references within the ORDER BY expression as required. */ + pDup = _sqlite3ExprDup(tls, db, pE, 0) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + **(**int32)(__ccgo_up(bp)) = _resolveOrderByTermToExprList(tls, pParse, pSelect, pDup) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && **(**int32)(__ccgo_up(bp)) > 0 { + _resolveOrderByTermToExprList(tls, pParse, pSelect, pE) + } + } + _sqlite3ExprDelete(tls, db, pDup) + } + } + if **(**int32)(__ccgo_up(bp)) > 0 { + /* Convert the ORDER BY term into an integer column number iCol, + ** taking care to preserve the COLLATE clause if it exists. */ + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + pNew = _sqlite3ExprInt32(tls, db, **(**int32)(__ccgo_up(bp))) + if pNew == uintptr(0) { + return int32(1) + } + if (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr == pE { + (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr = pNew + } else { + pParent = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pParent)).FpLeft)).Fop) == int32(TK_COLLATE) { + pParent = (*TExpr)(unsafe.Pointer(pParent)).FpLeft + } + (*TExpr)(unsafe.Pointer(pParent)).FpLeft = pNew + } + _sqlite3ExprDelete(tls, db, pE) + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = libc.Uint16FromInt32(**(**int32)(__ccgo_up(bp))) + } + libc.SetBitFieldPtr16Uint32(pItem+16+4, libc.Uint32FromInt32(1), 2, 0x4) + } else { + moreToDo = int32(1) + } + goto _2 + _2: + ; + i = i + 1 + pItem += 32 + } + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpNext + } + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32 + 16 + 4))&0x4>>2)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7665, libc.VaList(bp+16, i+int32(1))) + return int32(1) + } + goto _3 + _3: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** This function checks if argument pFrom refers to a CTE declared by +// ** a WITH clause on the stack currently maintained by the parser (on the +// ** pParse->pWith linked list). And if currently processing a CTE +// ** CTE expression, through routine checks to see if the reference is +// ** a recursive reference to the CTE. +// ** +// ** If pFrom matches a CTE according to either of these two above, pFrom->pSTab +// ** and other fields are populated accordingly. +// ** +// ** Return 0 if no match is found. +// ** Return 1 if a match is found. +// ** Return 2 if an error condition is detected. +// */ +func _resolveFromTermToCte(tls *libc.TLS, pParse uintptr, pWalker uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bMayRecursive, i, iRecTab, rc, v3 int32 + var db, pCte, pCteUse, pEList, pItem, pLeft, pRecTerm, pSavedWith, pSel, pSrc, pTab, v1 uintptr + var _ /* pWith at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bMayRecursive, db, i, iRecTab, pCte, pCteUse, pEList, pItem, pLeft, pRecTerm, pSavedWith, pSel, pSrc, pTab, rc, v1, v3 /* The matching WITH */ + if (*TParse)(unsafe.Pointer(pParse)).FpWith == uintptr(0) { + /* There are no WITH clauses in the stack. No match is possible */ + return 0 + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + /* Prior errors might have left pParse->pWith in a goofy state, so + ** go no further. */ + return 0 + } + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x10000>>16) == 0 && *(*uintptr)(unsafe.Pointer(pFrom + 72)) != uintptr(0) { + /* The FROM term contains a schema qualifier (ex: main.t1) and so + ** it cannot possibly be a CTE reference. */ + return 0 + } + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x400>>10) != 0 { + /* The FROM term is specifically excluded from matching a CTE. + ** (1) It is part of a trigger that used to have zDatabase but had + ** zDatabase removed by sqlite3FixTriggerStep(). + ** (2) This is the first term in the FROM clause of an UPDATE. + */ + return 0 + } + pCte = _searchWith(tls, (*TParse)(unsafe.Pointer(pParse)).FpWith, pFrom, bp) + if pCte != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Initial value of pParse->pWith */ + iRecTab = -int32(1) + /* If pCte->zCteErr is non-NULL at this point, then this is an illegal + ** recursive reference to CTE pCte. Leave an error in pParse and return + ** early. If pCte->zCteErr is NULL, then this is not a recursive reference. + ** In this case, proceed. */ + if (*TCte)(unsafe.Pointer(pCte)).FzCteErr != 0 { + _sqlite3ErrorMsg(tls, pParse, (*TCte)(unsafe.Pointer(pCte)).FzCteErr, libc.VaList(bp+16, (*TCte)(unsafe.Pointer(pCte)).FzName)) + return int32(2) + } + if _cannotBeFunction(tls, pParse, pFrom) != 0 { + return int32(2) + } + pTab = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTab == uintptr(0) { + return int32(2) + } + pCteUse = (*TCte)(unsafe.Pointer(pCte)).FpUse + if pCteUse == uintptr(0) { + v1 = _sqlite3DbMallocZero(tls, db, uint64(20)) + pCteUse = v1 + (*TCte)(unsafe.Pointer(pCte)).FpUse = v1 + if pCteUse == uintptr(0) || _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3DbFree), pCteUse) == uintptr(0) { + _sqlite3DbFree(tls, db, pTab) + return int32(2) + } + (*TCteUse)(unsafe.Pointer(pCteUse)).FeM10d = (*TCte)(unsafe.Pointer(pCte)).FeM10d + } + (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab = pTab + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pTab)).FzName = _sqlite3DbStrDup(tls, db, (*TCte)(unsafe.Pointer(pCte)).FzName) + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(-int32(1)) + (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TF_Ephemeral) | libc.Int32FromInt32(TF_NoVisibleRowid)) + _sqlite3SrcItemAttachSubquery(tls, pParse, pFrom, (*TCte)(unsafe.Pointer(pCte)).FpSelect, int32(1)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(2) + } + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + **(**Tu32)(__ccgo_up(pSel + 4)) |= uint32(SF_CopyCte) + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x2>>1) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21015, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(pFrom + 48)))) + return int32(2) + } + libc.SetBitFieldPtr32Uint32(pFrom+24+4, libc.Uint32FromInt32(1), 9, 0x200) + *(*uintptr)(unsafe.Pointer(pFrom + 56)) = pCteUse + (*TCteUse)(unsafe.Pointer(pCteUse)).FnUse = (*TCteUse)(unsafe.Pointer(pCteUse)).FnUse + 1 + /* Check if this is a recursive CTE. */ + pRecTerm = pSel + bMayRecursive = libc.BoolInt32(libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSel)).Fop) == int32(TK_ALL) || libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSel)).Fop) == int32(TK_UNION)) + for bMayRecursive != 0 && libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pRecTerm)).Fop) == libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSel)).Fop) { + pSrc = (*TSelect)(unsafe.Pointer(pRecTerm)).FpSrc + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + pItem = pSrc + 8 + uintptr(i)*80 + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != uintptr(0) && !(int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x20000>>17) != 0) && !(int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0) && (int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) != 0 || *(*uintptr)(unsafe.Pointer(pItem + 72)) == uintptr(0)) && 0 == _sqlite3StrICmp(tls, (*TSrcItem)(unsafe.Pointer(pItem)).FzName, (*TCte)(unsafe.Pointer(pCte)).FzName) { + (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab = pTab + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 7, 0x80) + if (*TSelect)(unsafe.Pointer(pRecTerm)).FselFlags&uint32(SF_Recursive) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21035, libc.VaList(bp+16, (*TCte)(unsafe.Pointer(pCte)).FzName)) + return int32(2) + } + **(**Tu32)(__ccgo_up(pRecTerm + 4)) |= uint32(SF_Recursive) + if iRecTab < 0 { + v1 = pParse + 56 + v3 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + iRecTab = v3 + } + (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor = iRecTab + } + goto _2 + _2: + ; + i = i + 1 + } + if (*TSelect)(unsafe.Pointer(pRecTerm)).FselFlags&uint32(SF_Recursive) == uint32(0) { + break + } + pRecTerm = (*TSelect)(unsafe.Pointer(pRecTerm)).FpPrior + } + (*TCte)(unsafe.Pointer(pCte)).FzCteErr = __ccgo_ts + 21078 + pSavedWith = (*TParse)(unsafe.Pointer(pParse)).FpWith + (*TParse)(unsafe.Pointer(pParse)).FpWith = **(**uintptr)(__ccgo_up(bp)) + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_Recursive) != 0 { + (*TSelect)(unsafe.Pointer(pRecTerm)).FpWith = (*TSelect)(unsafe.Pointer(pSel)).FpWith + rc = _sqlite3WalkSelect(tls, pWalker, pRecTerm) + (*TSelect)(unsafe.Pointer(pRecTerm)).FpWith = uintptr(0) + if rc != 0 { + (*TParse)(unsafe.Pointer(pParse)).FpWith = pSavedWith + return int32(2) + } + } else { + if _sqlite3WalkSelect(tls, pWalker, pSel) != 0 { + (*TParse)(unsafe.Pointer(pParse)).FpWith = pSavedWith + return int32(2) + } + } + (*TParse)(unsafe.Pointer(pParse)).FpWith = **(**uintptr)(__ccgo_up(bp)) + pLeft = pSel + for { + if !((*TSelect)(unsafe.Pointer(pLeft)).FpPrior != 0) { + break + } + goto _5 + _5: + ; + pLeft = (*TSelect)(unsafe.Pointer(pLeft)).FpPrior + } + pEList = (*TSelect)(unsafe.Pointer(pLeft)).FpEList + if (*TCte)(unsafe.Pointer(pCte)).FpCols != 0 { + if pEList != 0 && (*TExprList)(unsafe.Pointer(pEList)).FnExpr != (*TExprList)(unsafe.Pointer((*TCte)(unsafe.Pointer(pCte)).FpCols)).FnExpr { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21101, libc.VaList(bp+16, (*TCte)(unsafe.Pointer(pCte)).FzName, (*TExprList)(unsafe.Pointer(pEList)).FnExpr, (*TExprList)(unsafe.Pointer((*TCte)(unsafe.Pointer(pCte)).FpCols)).FnExpr)) + (*TParse)(unsafe.Pointer(pParse)).FpWith = pSavedWith + return int32(2) + } + pEList = (*TCte)(unsafe.Pointer(pCte)).FpCols + } + _sqlite3ColumnsFromExprList(tls, pParse, pEList, pTab+54, pTab+8) + if bMayRecursive != 0 { + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_Recursive) != 0 { + (*TCte)(unsafe.Pointer(pCte)).FzCteErr = __ccgo_ts + 21139 + } else { + (*TCte)(unsafe.Pointer(pCte)).FzCteErr = __ccgo_ts + 21173 + } + _sqlite3WalkSelect(tls, pWalker, pSel) + } + (*TCte)(unsafe.Pointer(pCte)).FzCteErr = uintptr(0) + (*TParse)(unsafe.Pointer(pParse)).FpWith = pSavedWith + return int32(1) /* Success */ + } + return 0 /* No match */ +} + +// C documentation +// +// /* +// ** Resolve names in the SELECT statement p and all of its descendants. +// */ +func _resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pGroupBy, pItem, pItem1, pItem2, pLeftmost, pOuterNC, pParse, pSub, pSub1, pWin, zSavedContext uintptr + var i, isCompound, nCompound, nRef, v1 int32 + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, isCompound, nCompound, nRef, pGroupBy, pItem, pItem1, pItem2, pLeftmost, pOuterNC, pParse, pSub, pSub1, pWin, zSavedContext, v1 /* Database connection */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Resolved) != 0 { + return int32(WRC_Prune) + } + pOuterNC = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Normally sqlite3SelectExpand() will be called first and will have + ** already expanded this SELECT. However, if this is a subquery within + ** an expression, sqlite3ResolveExprNames() will be called without a + ** prior call to sqlite3SelectExpand(). When that happens, let + ** sqlite3SelectPrep() do all of the processing for this SELECT. + ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and + ** this routine in the correct order. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Expanded) == uint32(0) { + _sqlite3SelectPrep(tls, pParse, p, pOuterNC) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v1 = int32(WRC_Abort) + } else { + v1 = int32(WRC_Prune) + } + return v1 + } + isCompound = libc.BoolInt32((*TSelect)(unsafe.Pointer(p)).FpPrior != uintptr(0)) + nCompound = 0 + pLeftmost = p + for p != 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_Resolved) + /* Resolve the expressions in the LIMIT and OFFSET clauses. These + ** are not allowed to refer to any names, so pass an empty NameContext. + */ + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpWinSelect = p + if _sqlite3ResolveExprNames(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpLimit) != 0 { + return int32(WRC_Abort) + } + /* If the SF_Converted flags is set, then this Select object was + ** was created by the convertCompoundSelectToSubquery() function. + ** In this case the ORDER BY clause (p->pOrderBy) should be resolved + ** as if it were part of the sub-query, not the parent. This block + ** moves the pOrderBy down to the sub-query. It will be moved back + ** after the names have been resolved. */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Converted) != 0 { + pSub = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + 72)))).FpSelect + (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + } + /* Recursively resolve names in all subqueries in the FROM clause + */ + if pOuterNC != 0 { + (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect = (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect + 1 + } + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc) { + break + } + pItem = (*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + uintptr(i)*80 + /* Test of tag-20240424-1*/ + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 && (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect)).FselFlags&uint32(SF_Resolved) == uint32(0) { + if pOuterNC != 0 { + v1 = (*TNameContext)(unsafe.Pointer(pOuterNC)).FnRef + } else { + v1 = 0 + } + nRef = v1 + zSavedContext = (*TParse)(unsafe.Pointer(pParse)).FzAuthContext + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = (*TSrcItem)(unsafe.Pointer(pItem)).FzName + } + _sqlite3ResolveSelectNames(tls, pParse, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect, pOuterNC) + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedContext + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + /* If the number of references to the outer context changed when + ** expressions in the sub-select were resolved, the sub-select + ** is correlated. It is not required to check the refcount on any + ** but the innermost outer context object, as lookupName() increments + ** the refcount on all contexts between the current one and the + ** context containing the column when it resolves a name. */ + if pOuterNC != 0 { + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.BoolUint32((*TNameContext)(unsafe.Pointer(pOuterNC)).FnRef > nRef), 4, 0x10) + } + } + goto _2 + _2: + ; + i = i + 1 + } + if pOuterNC != 0 && (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect > uint32(0) { + (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect = (*TNameContext)(unsafe.Pointer(pOuterNC)).FnNestedSelect - 1 + } + /* Set up the local name-context to pass to sqlite3ResolveExprNames() to + ** resolve the result-set expression list. + */ + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_AllowWin) + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = (*TSelect)(unsafe.Pointer(p)).FpSrc + (**(**TNameContext)(__ccgo_up(bp))).FpNext = pOuterNC + /* Resolve names in the result set. */ + if _sqlite3ResolveExprListNames(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpEList) != 0 { + return int32(WRC_Abort) + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags &= ^libc.Int32FromInt32(NC_AllowWin) + /* If there are no aggregate functions in the result-set, and no GROUP BY + ** expression, do not allow aggregates in any of the other expressions. + */ + pGroupBy = (*TSelect)(unsafe.Pointer(p)).FpGroupBy + if pGroupBy != 0 || (**(**TNameContext)(__ccgo_up(bp))).FncFlags&int32(NC_HasAgg) != 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= libc.Uint32FromInt32(int32(SF_Aggregate) | (**(**TNameContext)(__ccgo_up(bp))).FncFlags&(libc.Int32FromInt32(NC_MinMaxAgg)|libc.Int32FromInt32(NC_OrderAgg))) + } else { + (**(**TNameContext)(__ccgo_up(bp))).FncFlags &= ^libc.Int32FromInt32(NC_AllowAgg) + } + /* Add the output column list to the name-context before parsing the + ** other expressions in the SELECT statement. This is so that + ** expressions in the WHERE clause (etc.) can refer to expressions by + ** aliases in the result set. + ** + ** Minor point: If this is the case, then the expression will be + ** re-evaluated for each reference to it. + */ + *(*uintptr)(unsafe.Pointer(bp + 16)) = (*TSelect)(unsafe.Pointer(p)).FpEList + (**(**TNameContext)(__ccgo_up(bp))).FncFlags |= int32(NC_UEList) + if (*TSelect)(unsafe.Pointer(p)).FpHaving != 0 { + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Aggregate) == uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7757, 0) + return int32(WRC_Abort) + } + if _sqlite3ResolveExprNames(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpHaving) != 0 { + return int32(WRC_Abort) + } + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags |= int32(NC_Where) + if _sqlite3ResolveExprNames(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpWhere) != 0 { + return int32(WRC_Abort) + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags &= ^libc.Int32FromInt32(NC_Where) + /* Resolve names in table-valued-function arguments */ + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc) { + break + } + pItem1 = (*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + uintptr(i)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x8>>3) != 0 && _sqlite3ResolveExprListNames(tls, bp, *(*uintptr)(unsafe.Pointer(pItem1 + 48))) != 0 { + return int32(WRC_Abort) + } + goto _4 + _4: + ; + i = i + 1 + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + pWin = (*TSelect)(unsafe.Pointer(p)).FpWinDefn + for { + if !(pWin != 0) { + break + } + if _sqlite3ResolveExprListNames(tls, bp, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) != 0 || _sqlite3ResolveExprListNames(tls, bp, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) != 0 { + return int32(WRC_Abort) + } + goto _5 + _5: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags |= libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_AllowWin) + /* If this is a converted compound query, move the ORDER BY clause from + ** the sub-query back to the parent query. At this point each term + ** within the ORDER BY clause has been transformed to an integer value. + ** These integers will be replaced by copies of the corresponding result + ** set expressions by the call to resolveOrderGroupBy() below. */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Converted) != 0 { + pSub1 = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + 72)))).FpSelect + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = (*TSelect)(unsafe.Pointer(pSub1)).FpOrderBy + (*TSelect)(unsafe.Pointer(pSub1)).FpOrderBy = uintptr(0) + } + /* Process the ORDER BY clause for singleton SELECT statements. + ** The ORDER BY clause for compounds SELECT statements is handled + ** below, after all of the result-sets for all of the elements of + ** the compound have been resolved. + ** + ** If there is an ORDER BY clause on a term of a compound-select other + ** than the right-most term, then that is a syntax error. But the error + ** is not detected until much later, and so we need to go ahead and + ** resolve those symbols on the incorrect ORDER BY for consistency. + */ + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != uintptr(0) && isCompound <= nCompound && _resolveOrderGroupBy(tls, bp, p, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, __ccgo_ts+7659) != 0 { + return int32(WRC_Abort) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags &= ^libc.Int32FromInt32(NC_AllowWin) + /* Resolve the GROUP BY clause. At the same time, make sure + ** the GROUP BY clause does not contain aggregate functions. + */ + if pGroupBy != 0 { + if _resolveOrderGroupBy(tls, bp, p, pGroupBy, __ccgo_ts+7796) != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + i = 0 + pItem2 = pGroupBy + 8 + for { + if !(i < (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { + break + } + if (*TExpr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pItem2)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Agg)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7802, 0) + return int32(WRC_Abort) + } + goto _6 + _6: + ; + i = i + 1 + pItem2 += 32 + } + } + /* If this is part of a compound SELECT, check that it has the right + ** number of expressions in the select list. */ + if (*TSelect)(unsafe.Pointer(p)).FpNext != 0 && (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr != (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpNext)).FpEList)).FnExpr { + _sqlite3SelectWrongNumTermsError(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpNext) + return int32(WRC_Abort) + } + /* If the SELECT statement contains ON clauses that were moved into + ** the WHERE clause, go through and verify that none of the terms + ** in the ON clauses reference tables to the right of the ON clause. */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_OnToWhere) != 0 { + _sqlite3SelectCheckOnClauses(tls, pParse, p) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + } + /* Advance to the next term of the compound + */ + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + nCompound = nCompound + 1 + } + /* Resolve the ORDER BY on a compound SELECT after all terms of + ** the compound have been resolved. + */ + if isCompound != 0 && _resolveCompoundOrderBy(tls, pParse, pLeftmost) != 0 { + return int32(WRC_Abort) + } + return int32(WRC_Prune) +} + +// C documentation +// +// /* +// ** Implementation of the round() function +// */ +func _roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var n Ti64 + var zBuf uintptr + var v1 float64 + var _ /* r at bp+0 */ float64 + _, _, _ = n, zBuf, v1 + n = 0 + if argc == int32(2) { + if int32(SQLITE_NULL) == Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) { + return + } + n = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if n > int64(30) { + n = int64(30) + } + if n < 0 { + n = 0 + } + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + return + } + **(**float64)(__ccgo_up(bp)) = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv))) + /* If Y==0 and X will fit in a 64-bit int, + ** handle the rounding directly, + ** otherwise use printf. + */ + if **(**float64)(__ccgo_up(bp)) < -libc.Float64FromFloat64(4.503599627370496e+15) || **(**float64)(__ccgo_up(bp)) > +libc.Float64FromFloat64(4.503599627370496e+15) { + /* The value has no fractional part so there is nothing to round */ + } else { + if n == 0 { + if **(**float64)(__ccgo_up(bp)) < libc.Float64FromInt32(0) { + v1 = -libc.Float64FromFloat64(0.5) + } else { + v1 = +libc.Float64FromFloat64(0.5) + } + **(**float64)(__ccgo_up(bp)) = float64(int64(**(**float64)(__ccgo_up(bp)) + v1)) + } else { + zBuf = Xsqlite3_mprintf(tls, __ccgo_ts+16475, libc.VaList(bp+16, int32(n), **(**float64)(__ccgo_up(bp)))) + if zBuf == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + _sqlite3AtoF(tls, zBuf, bp) + Xsqlite3_free(tls, zBuf) + } + } + Xsqlite3_result_double(tls, context, **(**float64)(__ccgo_up(bp))) +} + +// C documentation +// +// /* +// ** This function is a no-op if there is already an error code stored +// ** in the RtreeCheck object indicated by the first argument. NULL is +// ** returned in this case. +// ** +// ** Otherwise, the contents of rtree table node iNode are loaded from +// ** the database and copied into a buffer obtained from sqlite3_malloc(). +// ** If no error occurs, a pointer to the buffer is returned and (*pnNode) +// ** is set to the size of the buffer in bytes. +// ** +// ** Or, if an error does occur, NULL is returned and an error code left +// ** in the RtreeCheck object. The final value of *pnNode is undefined in +// ** this case. +// */ +func _rtreeCheckGetNode(tls *libc.TLS, pCheck uintptr, iNode Ti64, pnNode uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nNode int32 + var pNode, pRet uintptr + _, _, _ = nNode, pNode, pRet + pRet = uintptr(0) /* Return value */ + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode == uintptr(0) { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode = _rtreeCheckPrepare(tls, pCheck, __ccgo_ts+28993, libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzTab)) + } + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { + Xsqlite3_bind_int64(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, int32(1), iNode) + if Xsqlite3_step(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) == int32(SQLITE_ROW) { + nNode = Xsqlite3_column_bytes(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0) + pNode = Xsqlite3_column_blob(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0) + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nNode)) + if pRet == uintptr(0) { + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, pRet, pNode, libc.Uint64FromInt32(nNode)) + **(**int32)(__ccgo_up(pnNode)) = nNode + } + } + _rtreeCheckReset(tls, pCheck, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && pRet == uintptr(0) { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29038, libc.VaList(bp+8, iNode)) + } + } + return pRet +} + +// C documentation +// +// /* +// ** This function is used to check that the %_parent (if bLeaf==0) or %_rowid +// ** (if bLeaf==1) table contains a specified entry. The schemas of the +// ** two tables are: +// ** +// ** CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER) +// ** CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER, ...) +// ** +// ** In both cases, this function checks that there exists an entry with +// ** IPK value iKey and the second column set to iVal. +// ** +// */ +func _rtreeCheckMapping(tls *libc.TLS, pCheck uintptr, bLeaf int32, iKey Ti64, iVal Ti64) { + bp := tls.Alloc(48) + defer tls.Free(48) + var azSql [2]uintptr + var ii Ti64 + var pStmt, v1 uintptr + var rc int32 + _, _, _, _, _ = azSql, ii, pStmt, rc, v1 + azSql = [2]uintptr{ + 0: __ccgo_ts + 29070, + 1: __ccgo_ts + 29124, + } + if **(**uintptr)(__ccgo_up(pCheck + 40 + uintptr(bLeaf)*8)) == uintptr(0) { + **(**uintptr)(__ccgo_up(pCheck + 40 + uintptr(bLeaf)*8)) = _rtreeCheckPrepare(tls, pCheck, azSql[bLeaf], libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzTab)) + } + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc != SQLITE_OK { + return + } + pStmt = **(**uintptr)(__ccgo_up(pCheck + 40 + uintptr(bLeaf)*8)) + Xsqlite3_bind_int64(tls, pStmt, int32(1), iKey) + rc = Xsqlite3_step(tls, pStmt) + if rc == int32(SQLITE_DONE) { + if bLeaf != 0 { + v1 = __ccgo_ts + 29172 + } else { + v1 = __ccgo_ts + 29180 + } + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29189, libc.VaList(bp+8, iKey, iVal, v1)) + } else { + if rc == int32(SQLITE_ROW) { + ii = Xsqlite3_column_int64(tls, pStmt, 0) + if ii != iVal { + if bLeaf != 0 { + v1 = __ccgo_ts + 29172 + } else { + v1 = __ccgo_ts + 29180 + } + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29234, libc.VaList(bp+8, iKey, ii, v1, iKey, iVal)) + } + } + } + _rtreeCheckReset(tls, pCheck, pStmt) +} + +// C documentation +// +// /* +// ** This function does the bulk of the work for the rtree integrity-check. +// ** It is called by rtreecheck(), which is the SQL function implementation. +// */ +func _rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzReport uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var nAux, rc int32 + var pStmt uintptr + var _ /* check at bp+0 */ TRtreeCheck + _, _, _ = nAux, pStmt, rc /* Common context for various routines */ + pStmt = uintptr(0) /* Used to find column count of rtree table */ + nAux = 0 /* Number of extra columns. */ + /* Initialize the context object */ + libc.Xmemset(tls, bp, 0, uint64(88)) + (**(**TRtreeCheck)(__ccgo_up(bp))).Fdb = db + (**(**TRtreeCheck)(__ccgo_up(bp))).FzDb = zDb + (**(**TRtreeCheck)(__ccgo_up(bp))).FzTab = zTab + /* Find the number of auxiliary columns */ + pStmt = _rtreeCheckPrepare(tls, bp, __ccgo_ts+29624, libc.VaList(bp+96, zDb, zTab)) + if pStmt != 0 { + nAux = Xsqlite3_column_count(tls, pStmt) - int32(2) + Xsqlite3_finalize(tls, pStmt) + } else { + if (**(**TRtreeCheck)(__ccgo_up(bp))).Frc != int32(SQLITE_NOMEM) { + (**(**TRtreeCheck)(__ccgo_up(bp))).Frc = SQLITE_OK + } + } + /* Find number of dimensions in the rtree table. */ + pStmt = _rtreeCheckPrepare(tls, bp, __ccgo_ts+27440, libc.VaList(bp+96, zDb, zTab)) + if pStmt != 0 { + (**(**TRtreeCheck)(__ccgo_up(bp))).FnDim = (Xsqlite3_column_count(tls, pStmt) - int32(1) - nAux) / int32(2) + if (**(**TRtreeCheck)(__ccgo_up(bp))).FnDim < int32(1) { + _rtreeCheckAppendMsg(tls, bp, __ccgo_ts+29652, 0) + } else { + if int32(SQLITE_ROW) == Xsqlite3_step(tls, pStmt) { + (**(**TRtreeCheck)(__ccgo_up(bp))).FbInt = libc.BoolInt32(Xsqlite3_column_type(tls, pStmt, int32(1)) == int32(SQLITE_INTEGER)) + } + } + rc = Xsqlite3_finalize(tls, pStmt) + if rc != int32(SQLITE_CORRUPT) { + (**(**TRtreeCheck)(__ccgo_up(bp))).Frc = rc + } + } + /* Do the actual integrity-check */ + if (**(**TRtreeCheck)(__ccgo_up(bp))).FnDim >= int32(1) { + if (**(**TRtreeCheck)(__ccgo_up(bp))).Frc == SQLITE_OK { + _rtreeCheckNode(tls, bp, 0, uintptr(0), int64(1)) + } + _rtreeCheckCount(tls, bp, __ccgo_ts+29683, int64((**(**TRtreeCheck)(__ccgo_up(bp))).FnLeaf)) + _rtreeCheckCount(tls, bp, __ccgo_ts+29690, int64((**(**TRtreeCheck)(__ccgo_up(bp))).FnNonLeaf)) + } + /* Finalize SQL statements used by the integrity-check */ + Xsqlite3_finalize(tls, (**(**TRtreeCheck)(__ccgo_up(bp))).FpGetNode) + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 40))) + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 40 + 1*8))) + **(**uintptr)(__ccgo_up(pzReport)) = (**(**TRtreeCheck)(__ccgo_up(bp))).FzReport + return (**(**TRtreeCheck)(__ccgo_up(bp))).Frc +} + +func _rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefix uintptr, isCreate int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var appStmt [8]uintptr + var f, i, ii, ii1, rc int32 + var p, p1, zCreate, zFormat, zSql, zSql1 uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = appStmt, f, i, ii, ii1, p, p1, rc, zCreate, zFormat, zSql, zSql1 + rc = SQLITE_OK + f = libc.Int32FromInt32(SQLITE_PREPARE_PERSISTENT) | libc.Int32FromInt32(SQLITE_PREPARE_NO_VTAB) + (*TRtree)(unsafe.Pointer(pRtree)).Fdb = db + if isCreate != 0 { + p = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28144, libc.VaList(bp+8, zDb, zPrefix)) + ii = 0 + for { + if !(ii < libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux)) { + break + } + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28206, libc.VaList(bp+8, ii)) + goto _1 + _1: + ; + ii = ii + 1 + } + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28211, libc.VaList(bp+8, zDb, zPrefix)) + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28275, libc.VaList(bp+8, zDb, zPrefix)) + Xsqlite3_str_appendf(tls, p, __ccgo_ts+28345, libc.VaList(bp+8, zDb, zPrefix, (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize)) + zCreate = Xsqlite3_str_finish(tls, p) + if !(zCreate != 0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_exec(tls, db, zCreate, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_free(tls, zCreate) + if rc != SQLITE_OK { + return rc + } + } + appStmt[0] = pRtree + 128 + appStmt[int32(1)] = pRtree + 136 + appStmt[int32(2)] = pRtree + 144 + appStmt[int32(3)] = pRtree + 152 + appStmt[int32(4)] = pRtree + 160 + appStmt[int32(5)] = pRtree + 168 + appStmt[int32(6)] = pRtree + 176 + appStmt[int32(7)] = pRtree + 184 + rc = _rtreeQueryStat1(tls, db, pRtree) + i = 0 + for { + if !(i < int32(N_STATEMENT) && rc == SQLITE_OK) { + break + } + if i != int32(3) || libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux) == 0 { + zFormat = _azSql[i] + } else { + /* An UPSERT is very slightly slower than REPLACE, but it is needed + ** if there are auxiliary columns */ + zFormat = __ccgo_ts + 28394 + } + zSql = Xsqlite3_mprintf(tls, zFormat, libc.VaList(bp+8, zDb, zPrefix)) + if zSql != 0 { + rc = Xsqlite3_prepare_v3(tls, db, zSql, -int32(1), libc.Uint32FromInt32(f), appStmt[i], uintptr(0)) + } else { + rc = int32(SQLITE_NOMEM) + } + Xsqlite3_free(tls, zSql) + goto _2 + _2: + ; + i = i + 1 + } + if (*TRtree)(unsafe.Pointer(pRtree)).FnAux != 0 && rc != int32(SQLITE_NOMEM) { + (*TRtree)(unsafe.Pointer(pRtree)).FzReadAuxSql = Xsqlite3_mprintf(tls, __ccgo_ts+28502, libc.VaList(bp+8, zDb, zPrefix)) + if (*TRtree)(unsafe.Pointer(pRtree)).FzReadAuxSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + p1 = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, p1, __ccgo_ts+28547, libc.VaList(bp+8, zDb, zPrefix)) + ii1 = 0 + for { + if !(ii1 < libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux)) { + break + } + if ii1 != 0 { + Xsqlite3_str_append(tls, p1, __ccgo_ts+14346, int32(1)) + } + if ii1 < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnAuxNotNull) { + Xsqlite3_str_appendf(tls, p1, __ccgo_ts+28574, libc.VaList(bp+8, ii1, ii1+int32(2), ii1)) + } else { + Xsqlite3_str_appendf(tls, p1, __ccgo_ts+28596, libc.VaList(bp+8, ii1, ii1+int32(2))) + } + goto _3 + _3: + ; + ii1 = ii1 + 1 + } + Xsqlite3_str_appendf(tls, p1, __ccgo_ts+28604, 0) + zSql1 = Xsqlite3_str_finish(tls, p1) + if zSql1 == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v3(tls, db, zSql1, -int32(1), libc.Uint32FromInt32(f), pRtree+192, uintptr(0)) + Xsqlite3_free(tls, zSql1) + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Usage: +// ** +// ** rtreecheck(); +// ** rtreecheck(, ); +// ** +// ** Invoking this SQL function runs an integrity-check on the named rtree +// ** table. The integrity-check verifies the following: +// ** +// ** 1. For each cell in the r-tree structure (%_node table), that: +// ** +// ** a) for each dimension, (coord1 <= coord2). +// ** +// ** b) unless the cell is on the root node, that the cell is bounded +// ** by the parent cell on the parent node. +// ** +// ** c) for leaf nodes, that there is an entry in the %_rowid +// ** table corresponding to the cell's rowid value that +// ** points to the correct node. +// ** +// ** d) for cells on non-leaf nodes, that there is an entry in the +// ** %_parent table mapping from the cell's child node to the +// ** node that it resides on. +// ** +// ** 2. That there are the same number of entries in the %_rowid table +// ** as there are leaf cells in the r-tree structure, and that there +// ** is a leaf cell that corresponds to each entry in the %_rowid table. +// ** +// ** 3. That there are the same number of entries in the %_parent table +// ** as there are non-leaf cells in the r-tree structure, and that +// ** there is a non-leaf cell that corresponds to each entry in the +// ** %_parent table. +// */ +func _rtreecheck(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var zDb, zTab, v1 uintptr + var _ /* zReport at bp+0 */ uintptr + _, _, _, _ = rc, zDb, zTab, v1 + if nArg != int32(1) && nArg != int32(2) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+29717, -int32(1)) + } else { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg))) + if nArg == int32(1) { + zTab = zDb + zDb = __ccgo_ts + 6816 + } else { + zTab = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + } + rc = _rtreeCheckTable(tls, Xsqlite3_context_db_handle(tls, ctx), zDb, zTab, bp) + if rc == SQLITE_OK { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = **(**uintptr)(__ccgo_up(bp)) + } else { + v1 = __ccgo_ts + 19789 + } + Xsqlite3_result_text(tls, ctx, v1, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_error_code(tls, ctx, rc) + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + } +} + +/* Conditionally include the geopoly code */ +/************** Include geopoly.c in the middle of rtree.c *******************/ +/************** Begin file geopoly.c *****************************************/ +/* +** 2018-05-25 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file implements an alternative R-Tree virtual table that +** uses polygons to express the boundaries of 2-dimensional objects. +** +** This file is #include-ed onto the end of "rtree.c" so that it has +** access to all of the R-Tree internals. + */ +/* #include */ + +/* Enable -DGEOPOLY_ENABLE_DEBUG for debugging facilities */ + +/* Character class routines */ +/* Use the SQLite core versions if this routine is part of the + ** SQLite amalgamation */ + +// C documentation +// +// /* +// ** Implementation of a scalar function that decodes r-tree nodes to +// ** human readable strings. This can be used for debugging and analysis. +// ** +// ** The scalar function takes two arguments: (1) the number of dimensions +// ** to the rtree (between 1 and 5, inclusive) and (2) a blob of data containing +// ** an r-tree node. For a two-dimensional r-tree structure called "rt", to +// ** deserialize all nodes, a statement like: +// ** +// ** SELECT rtreenode(2, data) FROM rt_node; +// ** +// ** The human readable string takes the form of a Tcl list with one +// ** entry for each cell in the r-tree node. Each entry is itself a +// ** list, containing the 8-byte rowid/pageno followed by the +// ** *2 coordinates. +// */ +func _rtreenode(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { + bp := tls.Alloc(1088) + defer tls.Free(1088) + var errCode, ii, jj, nData int32 + var pOut uintptr + var _ /* cell at bp+1016 */ TRtreeCell + var _ /* node at bp+0 */ TRtreeNode + var _ /* tree at bp+40 */ TRtree + _, _, _, _, _ = errCode, ii, jj, nData, pOut + _ = nArg + libc.Xmemset(tls, bp, 0, uint64(40)) + libc.Xmemset(tls, bp+40, 0, uint64(976)) + (**(**TRtree)(__ccgo_up(bp + 40))).FnDim = libc.Uint8FromInt32(Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apArg)))) + if libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim) < int32(1) || libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim) > int32(5) { + return + } + (**(**TRtree)(__ccgo_up(bp + 40))).FnDim2 = libc.Uint8FromInt32(libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim) * int32(2)) + (**(**TRtree)(__ccgo_up(bp + 40))).FnBytesPerCell = libc.Uint8FromInt32(int32(8) + int32(8)*libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim)) + (**(**TRtreeNode)(__ccgo_up(bp))).FzData = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + if (**(**TRtreeNode)(__ccgo_up(bp))).FzData == uintptr(0) { + return + } + nData = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + if nData < int32(4) { + return + } + if nData < int32(4)+_readInt16(tls, (*TRtreeNode)(unsafe.Pointer(bp)).FzData+2)*libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnBytesPerCell) { + return + } + pOut = Xsqlite3_str_new(tls, uintptr(0)) + ii = 0 + for { + if !(ii < _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(bp)).FzData+2)) { + break + } + _nodeGetCell(tls, bp+40, bp, ii, bp+1016) + if ii > 0 { + Xsqlite3_str_append(tls, pOut, __ccgo_ts+11541, int32(1)) + } + Xsqlite3_str_appendf(tls, pOut, __ccgo_ts+28943, libc.VaList(bp+1072, (**(**TRtreeCell)(__ccgo_up(bp + 1016))).FiRowid)) + jj = 0 + for { + if !(jj < libc.Int32FromUint8((**(**TRtree)(__ccgo_up(bp + 40))).FnDim2)) { + break + } + Xsqlite3_str_appendf(tls, pOut, __ccgo_ts+28949, libc.VaList(bp+1072, float64(*(*TRtreeValue)(unsafe.Pointer(bp + 1016 + 8 + uintptr(jj)*4))))) + goto _2 + _2: + ; + jj = jj + 1 + } + Xsqlite3_str_append(tls, pOut, __ccgo_ts+26788, int32(1)) + goto _1 + _1: + ; + ii = ii + 1 + } + errCode = Xsqlite3_str_errcode(tls, pOut) + Xsqlite3_result_error_code(tls, ctx, errCode) + Xsqlite3_result_text(tls, ctx, Xsqlite3_str_finish(tls, pOut), -int32(1), __ccgo_fp(Xsqlite3_free)) +} + +// C documentation +// +// /* +// ** The xExpr callback for the search of invalid ON clause terms. +// */ +func _selectCheckOnClausesExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iTab, ii, nSrc int32 + var pCtx, pSrc, v2 uintptr + _, _, _, _, _, _ = iTab, ii, nSrc, pCtx, pSrc, v2 + pCtx = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + /* Check if pExpr is root or near-root of an ON clause constraint that needs + ** to be checked to ensure that it does not refer to tables in its FROM + ** clause to the right of itself. i.e. it is either: + ** + ** + an ON clause on an OUTER join, or + ** + an ON clause on an INNER join within a FROM that features at + ** least one RIGHT or FULL join. + */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) != uint32(0) && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TCheckOnCtx)(unsafe.Pointer(pCtx)).FpSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + /* If CheckOnCtx.iJoin is already set, then fall through and process + ** this expression node as normal. Or, if CheckOnCtx.iJoin is still 0, + ** set it to the cursor number of the RHS of the join to which this + ** ON expression was attached and then iterate through the entire + ** expression. */ + if (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin == 0 { + (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin = *(*int32)(unsafe.Pointer(pExpr + 52)) + _sqlite3WalkExprNN(tls, pWalker, pExpr) + (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin = 0 + return int32(WRC_Prune) + } + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) { + /* A column expression. Find the SrcList (if any) to which it refers. + ** Then, if CheckOnCtx.iJoin indicates that this expression is part of an + ** ON clause from that SrcList (i.e. if iJoin is non-zero), check that it + ** does not refer to a table to the right of CheckOnCtx.iJoin. */ + for cond := true; cond; cond = pCtx != 0 { + pSrc = (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FpSrc + nSrc = (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc + iTab = (*TExpr)(unsafe.Pointer(pExpr)).FiTable + ii = 0 + for { + if !(ii < nSrc && (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(ii)*80))).FiCursor != iTab) { + break + } + goto _1 + _1: + ; + ii = ii + 1 + } + if ii < nSrc { + if (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin != 0 && iTab > (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FiJoin { + if (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FbFuncArg != 0 { + v2 = __ccgo_ts + 21520 + } else { + v2 = __ccgo_ts + 21544 + } + _sqlite3ErrorMsg(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, __ccgo_ts+21554, libc.VaList(bp+8, v2)) + return int32(WRC_Abort) + } + break + } + pCtx = (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FpParent + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** This routine is a Walker callback for "expanding" a SELECT statement. +// ** "Expanding" means to do the following: +// ** +// ** (1) Make sure VDBE cursor numbers have been assigned to every +// ** element of the FROM clause. +// ** +// ** (2) Fill in the pTabList->a[].pTab fields in the SrcList that +// ** defines FROM clause. When views appear in the FROM clause, +// ** fill pTabList->a[].pSelect with a copy of the SELECT statement +// ** that implements the view. A copy is made of the view's SELECT +// ** statement so that we can freely modify or delete that statement +// ** without worrying about messing up the persistent representation +// ** of the view. +// ** +// ** (3) Add terms to the WHERE clause to accommodate the NATURAL keyword +// ** on joins and the ON and USING clause of joins. +// ** +// ** (4) Scan the list of columns in the result set (pEList) looking +// ** for instances of the "*" operator or the TABLE.* operator. +// ** If found, expand each "*" to be every column in every table +// ** and TABLE.* to be every column in TABLE. +// ** +// */ +func _selectExpander(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a, db, pE, pEList, pExpr, pFrom, pLeft, pNestedFrom, pNew, pParse, pRight, pSel, pTab, pTab1, pTabList, pUsing, pX, pX1, zName, zSchemaName, zTName, zTabName, zUName, v2 uintptr + var eCodeOrig Tu8 + var elistFlags Tu32 + var flags, i, iDb, iErrOfst, ii, j, k, longNames, nAdd, rc, tableSeen, v1 int32 + var nCol Ti16 + var selFlags Tu16 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, db, eCodeOrig, elistFlags, flags, i, iDb, iErrOfst, ii, j, k, longNames, nAdd, nCol, pE, pEList, pExpr, pFrom, pLeft, pNestedFrom, pNew, pParse, pRight, pSel, pTab, pTab1, pTabList, pUsing, pX, pX1, rc, selFlags, tableSeen, zName, zSchemaName, zTName, zTabName, zUName, v1, v2 + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + selFlags = uint16((*TSelect)(unsafe.Pointer(p)).FselFlags) + elistFlags = uint32(0) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_Expanded) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + if libc.Int32FromUint16(selFlags)&int32(SF_Expanded) != 0 { + return int32(WRC_Prune) + } + if (*TWalker)(unsafe.Pointer(pWalker)).FeCode != 0 { + /* Renumber selId because it has been copied from a view */ + v2 = pParse + 124 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TSelect)(unsafe.Pointer(p)).FselId = libc.Uint32FromInt32(v1) + } + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + pEList = (*TSelect)(unsafe.Pointer(p)).FpEList + if (*TParse)(unsafe.Pointer(pParse)).FpWith != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_View) != 0 { + if (*TSelect)(unsafe.Pointer(p)).FpWith == uintptr(0) { + (*TSelect)(unsafe.Pointer(p)).FpWith = _sqlite3DbMallocZero(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+16)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(48))) + if (*TSelect)(unsafe.Pointer(p)).FpWith == uintptr(0) { + return int32(WRC_Abort) + } + } + (*TWith)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpWith)).FbView = int32(1) + } + _sqlite3WithPush(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWith, uint8(0)) + /* Make sure cursor numbers have been assigned to all entries in + ** the FROM clause of the SELECT statement. + */ + _sqlite3SrcListAssignCursors(tls, pParse, pTabList) + /* Look up every table named in the FROM clause of the select. If + ** an entry of the FROM clause is a subquery instead of a table or view, + ** then create a transient table structure to describe the subquery. + */ + i = 0 + pFrom = pTabList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + if (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab != 0 { + goto _3 + } + if (*TSrcItem)(unsafe.Pointer(pFrom)).FzName == uintptr(0) { + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + /* A sub-query in the FROM clause of a SELECT */ + if _sqlite3WalkSelect(tls, pWalker, pSel) != 0 { + return int32(WRC_Abort) + } + if _sqlite3ExpandSubquery(tls, pParse, pFrom) != 0 { + return int32(WRC_Abort) + } + } else { + v1 = _resolveFromTermToCte(tls, pParse, pWalker, pFrom) + rc = v1 + if v1 != 0 { + if rc > int32(1) { + return int32(WRC_Abort) + } + pTab = (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab + } else { + /* An ordinary table or view name in the FROM clause */ + v2 = _sqlite3LocateTableItem(tls, pParse, uint32(0), pFrom) + pTab = v2 + (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab = v2 + if pTab == uintptr(0) { + return int32(WRC_Abort) + } + if (*TTable)(unsafe.Pointer(pTab)).FnTabRef >= uint32(0xffff) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21215, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab = uintptr(0) + return int32(WRC_Abort) + } + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) && _cannotBeFunction(tls, pParse, pFrom) != 0 { + return int32(WRC_Abort) + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + eCodeOrig = uint8((*TWalker)(unsafe.Pointer(pWalker)).FeCode) + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + return int32(WRC_Abort) + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_EnableView) == uint64(0) && (*TTable)(unsafe.Pointer(pTab)).FpSchema != (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21254, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + _sqlite3SrcItemAttachSubquery(tls, pParse, pFrom, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTab)).Fu))).FpSelect, int32(1)) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) && (int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x100>>8) != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_FROM_DDL) != 0) && (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp != uintptr(0) && libc.Int32FromUint8((*TVTable)(unsafe.Pointer((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp)).FeVtabRisk) > libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_TrustedSchema) != uint64(0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16345, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + } + nCol = (*TTable)(unsafe.Pointer(pTab)).FnCol + (*TTable)(unsafe.Pointer(pTab)).FnCol = int16(-int32(1)) + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(1) /* Turn on Select.selId renumbering */ + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x4>>2) != 0 { + _sqlite3WalkSelect(tls, pWalker, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect) + } + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(eCodeOrig) + (*TTable)(unsafe.Pointer(pTab)).FnCol = nCol + } + } + } + /* Locate the index named by the INDEXED BY clause, if any. */ + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x2>>1) != 0 && _sqlite3IndexedByLookup(tls, pParse, pFrom) != 0 { + return int32(WRC_Abort) + } + goto _3 + _3: + ; + i = i + 1 + pFrom += 80 + } + /* Process NATURAL keywords, and ON and USING clauses of joins. + */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 || _sqlite3ProcessJoin(tls, pParse, p) != 0 { + return int32(WRC_Abort) + } + /* For every "*" that occurs in the column list, insert the names of + ** all columns in all tables. And for every TABLE.* insert the names + ** of all columns in TABLE. The parser inserted a special expression + ** with the TK_ASTERISK operator for each "*" that it found in the column + ** list. The following code just has to locate the TK_ASTERISK + ** expressions and expand each one to the list of all columns in + ** all tables. + ** + ** The first loop just checks to see if there are any "*" operators + ** that need expanding. + */ + k = 0 + for { + if !(k < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + pE = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(k)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_ASTERISK) { + break + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_DOT) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pE)).FpRight)).Fop) == int32(TK_ASTERISK) { + break + } + elistFlags = elistFlags | (*TExpr)(unsafe.Pointer(pE)).Fflags + goto _6 + _6: + ; + k = k + 1 + } + if k < (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + /* + ** If we get here it means the result set contains one or more "*" + ** operators that need to be expanded. Loop through each expression + ** in the result set and expand them one by one. + */ + a = pEList + 8 + pNew = uintptr(0) + flags = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags) + longNames = libc.BoolInt32(flags&int32(SQLITE_FullColNames) != 0 && flags&int32(SQLITE_ShortColNames) == 0) + k = 0 + for { + if !(k < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + pE = (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FpExpr + elistFlags = elistFlags | (*TExpr)(unsafe.Pointer(pE)).Fflags + pRight = (*TExpr)(unsafe.Pointer(pE)).FpRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) != int32(TK_ASTERISK) && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) != int32(TK_DOT) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) != int32(TK_ASTERISK)) { + /* This particular expression does not need to be expanded. + */ + pNew = _sqlite3ExprListAppend(tls, pParse, pNew, (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FpExpr) + if pNew != 0 { + (*(*TExprList_item)(unsafe.Pointer(pNew + 8 + uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32))).FzEName = (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FzEName + libc.SetBitFieldPtr16Uint32(pNew+8+uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32+16+4, libc.Uint32FromInt32(int32(uint32(*(*uint16)(unsafe.Pointer(a + uintptr(k)*32 + 16 + 4))&0x3>>0))), 0, 0x3) + (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FzEName = uintptr(0) + } + (**(**TExprList_item)(__ccgo_up(a + uintptr(k)*32))).FpExpr = uintptr(0) + } else { + /* This expression is a "*" or a "TABLE.*" and needs to be + ** expanded. */ + tableSeen = 0 /* Set to 1 when TABLE matches */ + zTName = uintptr(0) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_DOT) { + zTName = *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pE)).FpLeft + 8)) + iErrOfst = *(*int32)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pE)).FpRight + 52)) + } else { + iErrOfst = *(*int32)(unsafe.Pointer(pE + 52)) + } + i = 0 + pFrom = pTabList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } /* Number of cols including rowid */ + pTab1 = (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab /* AS name for this data source */ + zSchemaName = uintptr(0) /* USING clause for pFrom[1] */ + v2 = (*TSrcItem)(unsafe.Pointer(pFrom)).FzAlias + zTabName = v2 + if v2 == uintptr(0) { + zTabName = (*TTable)(unsafe.Pointer(pTab1)).FzName + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + break + } + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x4000>>14) != 0 { + pNestedFrom = (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect)).FpEList + } else { + if zTName != 0 && _sqlite3StrICmp(tls, zTName, zTabName) != 0 { + goto _8 + } + pNestedFrom = uintptr(0) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab1)).FpSchema) + if iDb >= 0 { + v2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + v2 = __ccgo_ts + 6821 + } + zSchemaName = v2 + } + if i+int32(1) < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc && int32(*(*uint32)(unsafe.Pointer(pFrom + 1*80 + 24 + 4))&0x800>>11) != 0 && libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) != 0 { + pUsing = *(*uintptr)(unsafe.Pointer(pFrom + 1*80 + 64)) + ii = 0 + for { + if !(ii < (*TIdList)(unsafe.Pointer(pUsing)).FnId) { + break + } + zUName = (*(*TIdList_item)(unsafe.Pointer(pUsing + 8 + uintptr(ii)*8))).FzName + pRight = _sqlite3Expr(tls, db, int32(TK_ID), zUName) + _sqlite3ExprSetErrorOffset(tls, pRight, iErrOfst) + pNew = _sqlite3ExprListAppend(tls, pParse, pNew, pRight) + if pNew != 0 { + pX = pNew + 8 + uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32 + (*TExprList_item)(unsafe.Pointer(pX)).FzEName = _sqlite3MPrintf(tls, db, __ccgo_ts+21285, libc.VaList(bp+8, zUName)) + libc.SetBitFieldPtr16Uint32(pX+16+4, libc.Uint32FromInt32(ENAME_TAB), 0, 0x3) + libc.SetBitFieldPtr16Uint32(pX+16+4, libc.Uint32FromInt32(1), 7, 0x80) + } + goto _11 + _11: + ; + ii = ii + 1 + } + } else { + pUsing = uintptr(0) + } + nAdd = int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) + if (*TTable)(unsafe.Pointer(pTab1)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) && libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) != 0 { + nAdd = nAdd + 1 + } + j = 0 + for { + if !(j < nAdd) { + break + } /* Newly added ExprList term */ + if j == int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) { + zName = _sqlite3RowidAlias(tls, pTab1) + if zName == uintptr(0) { + goto _12 + } + } else { + zName = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(j)*16))).FzCnName + /* If pTab is actually an SF_NestedFrom sub-select, do not + ** expand any ENAME_ROWID columns. */ + if pNestedFrom != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pNestedFrom + 8 + uintptr(j)*32 + 16 + 4))&0x3>>0)) == int32(ENAME_ROWID) { + goto _12 + } + if zTName != 0 && pNestedFrom != 0 && _sqlite3MatchEName(tls, pNestedFrom+8+uintptr(j)*32, uintptr(0), zTName, uintptr(0), uintptr(0)) == 0 { + goto _12 + } + /* If a column is marked as 'hidden', omit it from the expanded + ** result-set list unless the SELECT has the SF_IncludeHidden + ** bit set. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_IncludeHidden) == uint32(0) && libc.Int32FromUint16((*TColumn)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab1)).FaCol+uintptr(j)*16)).FcolFlags)&int32(COLFLAG_HIDDEN) != 0 { + goto _12 + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_NOEXPAND) != 0 && zTName == uintptr(0) && libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) == 0 { + goto _12 + } + } + tableSeen = int32(1) + if i > 0 && zTName == uintptr(0) && libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) == 0 { + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x800>>11) != 0 && _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pFrom + 64)), zName) >= 0 { + /* In a join with a USING clause, omit columns in the + ** using clause from the table on the right. */ + goto _12 + } + } + pRight = _sqlite3Expr(tls, db, int32(TK_ID), zName) + if (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc > int32(1) && (libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pFrom)).Ffg.Fjointype)&int32(JT_LTORJ) == 0 || libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) != 0 || !(_inAnyUsingClause(tls, zName, pFrom, (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc-i-int32(1)) != 0)) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + pLeft = _sqlite3Expr(tls, db, int32(TK_ID), zTabName) + pExpr = _sqlite3PExpr(tls, pParse, int32(TK_DOT), pLeft, pRight) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TExpr)(unsafe.Pointer(pE)).FpLeft != 0 { + _sqlite3RenameTokenRemap(tls, pParse, pLeft, (*TExpr)(unsafe.Pointer(pE)).FpLeft) + } + if zSchemaName != 0 { + pLeft = _sqlite3Expr(tls, db, int32(TK_ID), zSchemaName) + pExpr = _sqlite3PExpr(tls, pParse, int32(TK_DOT), pLeft, pExpr) + } + } else { + pExpr = pRight + } + _sqlite3ExprSetErrorOffset(tls, pExpr, iErrOfst) + pNew = _sqlite3ExprListAppend(tls, pParse, pNew, pExpr) + if pNew == uintptr(0) { + break /* OOM */ + } + pX1 = pNew + 8 + uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32 + if libc.Int32FromUint16(selFlags)&int32(SF_NestedFrom) != 0 && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if pNestedFrom != 0 && libc.Bool(libc.Bool(!(libc.Int32FromInt32(ViewCanHaveRowid) != 0)) || j < (*TExprList)(unsafe.Pointer(pNestedFrom)).FnExpr) { + (*TExprList_item)(unsafe.Pointer(pX1)).FzEName = _sqlite3DbStrDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pNestedFrom + 8 + uintptr(j)*32))).FzEName) + } else { + (*TExprList_item)(unsafe.Pointer(pX1)).FzEName = _sqlite3MPrintf(tls, db, __ccgo_ts+21290, libc.VaList(bp+8, zSchemaName, zTabName, zName)) + } + if j == int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) { + v1 = int32(ENAME_ROWID) + } else { + v1 = int32(ENAME_TAB) + } + libc.SetBitFieldPtr16Uint32(pX1+16+4, libc.Uint32FromInt32(v1), 0, 0x3) + if int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x800>>11) != 0 && _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pFrom + 64)), zName) >= 0 || pUsing != 0 && _sqlite3IdListIndex(tls, pUsing, zName) >= 0 || j < int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_NOEXPAND) != 0 { + libc.SetBitFieldPtr16Uint32(pX1+16+4, libc.Uint32FromInt32(1), 8, 0x100) + } + } else { + if longNames != 0 { + (*TExprList_item)(unsafe.Pointer(pX1)).FzEName = _sqlite3MPrintf(tls, db, __ccgo_ts+13632, libc.VaList(bp+8, zTabName, zName)) + libc.SetBitFieldPtr16Uint32(pX1+16+4, libc.Uint32FromInt32(ENAME_NAME), 0, 0x3) + } else { + (*TExprList_item)(unsafe.Pointer(pX1)).FzEName = _sqlite3DbStrDup(tls, db, zName) + libc.SetBitFieldPtr16Uint32(pX1+16+4, libc.Uint32FromInt32(ENAME_NAME), 0, 0x3) + } + } + goto _12 + _12: + ; + j = j + 1 + } + goto _8 + _8: + ; + i = i + 1 + pFrom += 80 + } + if !(tableSeen != 0) { + if zTName != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21299, libc.VaList(bp+8, zTName)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21317, 0) + } + } + } + goto _7 + _7: + ; + k = k + 1 + } + _sqlite3ExprListDelete(tls, db, pEList) + (*TSelect)(unsafe.Pointer(p)).FpEList = pNew + } + if (*TSelect)(unsafe.Pointer(p)).FpEList != 0 { + if (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21337, 0) + return int32(WRC_Abort) + } + if elistFlags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)|libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_ComplexResult) + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** This routine generates the code for the inside of the inner loop +// ** of a SELECT. +// ** +// ** If srcTab is negative, then the p->pEList expressions +// ** are evaluated in order to get the data for this row. If srcTab is +// ** zero or more, then data is pulled from srcTab and p->pEList is used only +// ** to get the number of columns and the collation sequence for each column. +// */ +func _selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSort uintptr, pDistinct uintptr, pDest uintptr, iContinue int32, iBreak int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var addr, addrTest, eDest, eType, hasDistinct, i, i2, iParm, iTab, j, nKey, nPrefixReg, nResultCol, r1, r11, r12, r13, r2, r21, r3, regOrig, regResult, v1 int32 + var ecelFlags Tu8 + var pEList, pSO, v uintptr + var _ /* sRowLoadInfo at bp+0 */ TRowLoadInfo + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrTest, eDest, eType, ecelFlags, hasDistinct, i, i2, iParm, iTab, j, nKey, nPrefixReg, nResultCol, pEList, pSO, r1, r11, r12, r13, r2, r21, r3, regOrig, regResult, v, v1 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* True if the DISTINCT keyword is present */ + eDest = libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) /* How to dispose of results */ + iParm = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm /* Number of result columns */ + nPrefixReg = 0 /* Start of memory holding full result (or 0) */ + if pDistinct != 0 { + v1 = libc.Int32FromUint8((*TDistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType) + } else { + v1 = WHERE_DISTINCT_NOOP + } + hasDistinct = v1 + if pSort != 0 && (*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy == uintptr(0) { + pSort = uintptr(0) + } + if pSort == uintptr(0) && !(hasDistinct != 0) { + _codeOffset(tls, v, (*TSelect)(unsafe.Pointer(p)).FiOffset, iContinue) + } + /* Pull the requested columns. + */ + nResultCol = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 { + if pSort != 0 { + nPrefixReg = (*TExprList)(unsafe.Pointer((*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr + if !(libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&libc.Int32FromInt32(SORTFLAG_UseSorter) != 0) { + nPrefixReg = nPrefixReg + 1 + } + **(**int32)(__ccgo_up(pParse + 60)) += nPrefixReg + } + (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nResultCol + } else { + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst+nResultCol > (*TParse)(unsafe.Pointer(pParse)).FnMem { + /* This is an error condition that can result, for example, when a SELECT + ** on the right-hand side of an INSERT contains more result columns than + ** there are columns in the table on the left. The error will be caught + ** and reported later. But we need to make sure enough memory is allocated + ** to avoid other spurious errors in the meantime. */ + **(**int32)(__ccgo_up(pParse + 60)) += nResultCol + } + } + (*TSelectDest)(unsafe.Pointer(pDest)).FnSdst = nResultCol + v1 = (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst + regResult = v1 + regOrig = v1 + if srcTab >= 0 { + i = 0 + for { + if !(i < nResultCol) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), srcTab, i, regResult+i) + goto _3 + _3: + ; + i = i + 1 + } + } else { + if eDest != int32(SRT_Exists) { + if eDest == int32(SRT_Mem) || eDest == int32(SRT_Output) || eDest == int32(SRT_Coroutine) { + ecelFlags = uint8(SQLITE_ECEL_DUP) + } else { + ecelFlags = uint8(0) + } + if pSort != 0 && hasDistinct == 0 && eDest != int32(SRT_EphemTab) && eDest != int32(SRT_Table) { + /* For each expression in p->pEList that is a copy of an expression in + ** the ORDER BY clause (pSort->pOrderBy), set the associated + ** iOrderByCol value to one more than the index of the ORDER BY + ** expression within the sort-key that pushOntoSorter() will generate. + ** This allows the p->pEList field to be omitted from the sorted record, + ** saving space and CPU cycles. */ + ecelFlags = libc.Uint8FromInt32(int32(ecelFlags) | (libc.Int32FromInt32(SQLITE_ECEL_OMITREF) | libc.Int32FromInt32(SQLITE_ECEL_REF))) + i = (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + for { + if !(i < (*TExprList)(unsafe.Pointer((*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr) { + break + } + v1 = libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer((*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy + 8 + uintptr(i)*32 + 24))) + j = v1 + if v1 > 0 { + *(*Tu16)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8 + uintptr(j-int32(1))*32 + 24)) = libc.Uint16FromInt32(i + int32(1) - (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat) + } + goto _4 + _4: + ; + i = i + 1 + } + /* Adjust nResultCol to account for columns that are omitted + ** from the sorter by the optimizations in this branch */ + pEList = (*TSelect)(unsafe.Pointer(p)).FpEList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pEList + 8 + uintptr(i)*32 + 24))) > 0 { + nResultCol = nResultCol - 1 + regOrig = 0 + } + goto _6 + _6: + ; + i = i + 1 + } + } + (**(**TRowLoadInfo)(__ccgo_up(bp))).FregResult = regResult + (**(**TRowLoadInfo)(__ccgo_up(bp))).FecelFlags = ecelFlags + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 && libc.Int32FromUint8(ecelFlags)&int32(SQLITE_ECEL_OMITREF) != 0 && nPrefixReg > 0 { + (*TSortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad = bp + regOrig = 0 + } else { + _innerLoopLoadRow(tls, pParse, p, bp) + } + } + } + /* If the DISTINCT keyword was present on the SELECT statement + ** and this row has been seen before, then do not make this row + ** part of the result. + */ + if hasDistinct != 0 { + eType = libc.Int32FromUint8((*TDistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType) + iTab = (*TDistinctCtx)(unsafe.Pointer(pDistinct)).FtabTnct + iTab = _codeDistinct(tls, pParse, eType, iTab, iContinue, (*TSelect)(unsafe.Pointer(p)).FpEList, regResult) + _fixDistinctOpenEph(tls, pParse, eType, iTab, (*TDistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct) + if pSort == uintptr(0) { + _codeOffset(tls, v, (*TSelect)(unsafe.Pointer(p)).FiOffset, iContinue) + } + } + switch eDest { + /* Store the result as data using a unique key. + */ + case int32(SRT_Fifo): + fallthrough + case int32(SRT_DistFifo): + fallthrough + case int32(SRT_Table): + fallthrough + case int32(SRT_EphemTab): + r1 = _sqlite3GetTempRange(tls, pParse, nPrefixReg+int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regResult, nResultCol, r1+nPrefixReg) + if eDest == int32(SRT_DistFifo) { + /* If the destination is DistFifo, then cursor (iParm+1) is open + ** on an ephemeral index. If the current row is already present + ** in the index, do not write it to the output. If not, add the + ** current row to the index and proceed with writing it to the + ** output table as well. */ + addr = _sqlite3VdbeCurrentAddr(tls, v) + int32(4) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iParm+int32(1), addr, r1, 0) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm+int32(1), r1, regResult, nResultCol) + } + if pSort != 0 { + _pushOntoSorter(tls, pParse, pSort, p, r1+nPrefixReg, regOrig, int32(1), nPrefixReg) + } else { + r2 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iParm, r2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, r1, r2) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + _sqlite3ReleaseTempReg(tls, pParse, r2) + } + _sqlite3ReleaseTempRange(tls, pParse, r1, nPrefixReg+int32(1)) + case int32(SRT_Upfrom): + if pSort != 0 { + _pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) + } else { + i2 = (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 + r11 = _sqlite3GetTempReg(tls, pParse) + /* If the UPDATE FROM join is an aggregate that matches no rows, it + ** might still be trying to return one row, because that is what + ** aggregates do. Don't record that empty row in the output table. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regResult, iBreak) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regResult+libc.BoolInt32(i2 < 0), nResultCol-libc.BoolInt32(i2 < 0), r11) + if i2 < 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iParm, r11, regResult) + } else { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, r11, regResult, i2) + } + } + break + /* If we are creating a set for an "expr IN (SELECT ...)" construct, + ** then there should be a single item on the stack. Write this + ** item into the set table with bogus data. + */ + fallthrough + case int32(SRT_Set): + if pSort != 0 { + /* At first glance you would think we could optimize out the + ** ORDER BY in this case since the order of entries in the set + ** does not matter. But there might be a LIMIT clause, in which + ** case the order does matter */ + _pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) + (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 = 0 /* Signal that any Bloom filter is unpopulated */ + } else { + r12 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), regResult, nResultCol, r12, (*TSelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nResultCol) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, r12, regResult, nResultCol) + if (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2, 0, regResult, nResultCol) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20465, 0) + } + _sqlite3ReleaseTempReg(tls, pParse, r12) + } + break + /* If any row exist in the result set, record that fact and abort. + */ + fallthrough + case int32(SRT_Exists): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), iParm) + /* The LIMIT clause will terminate the loop for us */ + break + /* If this is a scalar select that is part of an expression, then + ** store the results in the appropriate memory cell or array of + ** memory cells and break out of the scan loop. + */ + fallthrough + case int32(SRT_Mem): + if pSort != 0 { + _pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) + (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm = regResult + } else { + if regResult != iParm { + /* This occurs in cases where the SELECT had both a DISTINCT and + ** an OFFSET clause. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regResult, iParm, nResultCol-int32(1)) + } + /* The LIMIT clause will jump out of the loop for us */ + } + case int32(SRT_Coroutine): /* Send data to a co-routine */ + fallthrough + case int32(SRT_Output): /* Return the results */ + if pSort != 0 { + _pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) + } else { + if eDest == int32(SRT_Coroutine) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), regResult, nResultCol) + } + } + break + /* Write the results into a priority queue that is order according to + ** pDest->pOrderBy (in pSO). pDest->iSDParm (in iParm) is the cursor for an + ** index with pSO->nExpr+2 columns. Build a key using pSO for the first + ** pSO->nExpr columns, then make sure all keys are unique by adding a + ** final OP_Sequence column. The last column is the record as a blob. + */ + fallthrough + case int32(SRT_DistQueue): + fallthrough + case int32(SRT_Queue): + addrTest = 0 + pSO = (*TSelectDest)(unsafe.Pointer(pDest)).FpOrderBy + nKey = (*TExprList)(unsafe.Pointer(pSO)).FnExpr + r13 = _sqlite3GetTempReg(tls, pParse) + r21 = _sqlite3GetTempRange(tls, pParse, nKey+int32(2)) + r3 = r21 + nKey + int32(1) + if eDest == int32(SRT_DistQueue) { + /* If the destination is DistQueue, then cursor (iParm+1) is open + ** on a second ephemeral index that holds all values every previously + ** added to the queue. */ + addrTest = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iParm+int32(1), 0, regResult, nResultCol) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regResult, nResultCol, r3) + if eDest == int32(SRT_DistQueue) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), iParm+int32(1), r3) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + } + i = 0 + for { + if !(i < nKey) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), regResult+libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pSO + 8 + uintptr(i)*32 + 24)))-int32(1), r21+i) + goto _7 + _7: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sequence), iParm, r21+nKey) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), r21, nKey+int32(2), r13) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iParm, r13, r21, nKey+int32(2)) + if addrTest != 0 { + _sqlite3VdbeJumpHere(tls, v, addrTest) + } + _sqlite3ReleaseTempReg(tls, pParse, r13) + _sqlite3ReleaseTempRange(tls, pParse, r21, nKey+int32(2)) + break + /* Discard the results. This is used for SELECT statements inside + ** the body of a TRIGGER. The purpose of such selects is to call + ** user-defined functions that have side effects. We do not care + ** about the actual results of the select. + */ + fallthrough + default: + break + } + /* Jump to the end of the loop if the LIMIT is reached. Except, if + ** there is a sorter, in which case the sorter has already limited + ** the output for us. + */ + if pSort == uintptr(0) && (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_DecrJumpZero), (*TSelect)(unsafe.Pointer(p)).FiLimit, iBreak) + } +} + +// C documentation +// +// /* +// ** Return a comma-separated list of the fully-qualified (with both database +// ** and table name) column names from table pTab. e.g. +// ** +// ** "main"."t1"."a", "main"."t1"."b", "main"."t1"."c" +// */ +func _sessionAllCols(tls *libc.TLS, zDb uintptr, pTab uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var ii int32 + var zRet, v2 uintptr + _, _, _ = ii, zRet, v2 + zRet = uintptr(0) + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if zRet != 0 { + v2 = __ccgo_ts + 16214 + } else { + v2 = __ccgo_ts + 1704 + } + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+35462, libc.VaList(bp+8, zRet, v2, zDb, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FazCol + uintptr(ii)*8)))) + if !(zRet != 0) { + break + } + goto _1 + _1: + ; + ii = ii + 1 + } + return zRet +} + +// C documentation +// +// /* +// ** Argument pIter is a changeset iterator that has been initialized, but +// ** not yet passed to sqlite3changeset_next(). This function applies the +// ** changeset to the main database attached to handle "db". The supplied +// ** conflict handler callback is invoked to resolve any conflicts encountered +// ** while applying the change. +// */ +func _sessionChangesetApply(tls *libc.TLS, db uintptr, pIter uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xFilterIter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) { + bp := tls.Alloc(368) + defer tls.Free(368) + var bPatchset, i, nMinCol, nTab, rc, rc2, res, schemaMismatch, v2, v3, v4 int32 + var savedFlag Tu64 + var v5, v7 bool + var _ /* abPK at bp+160 */ uintptr + var _ /* nCol at bp+144 */ int32 + var _ /* nFk at bp+168 */ int32 + var _ /* notUsed at bp+172 */ int32 + var _ /* op at bp+148 */ int32 + var _ /* sApply at bp+8 */ TSessionApplyCtx + var _ /* sIter at bp+176 */ Tsqlite3_changeset_iter + var _ /* zNew at bp+152 */ uintptr + var _ /* zTab at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bPatchset, i, nMinCol, nTab, rc, rc2, res, savedFlag, schemaMismatch, v2, v3, v4, v5, v7 + schemaMismatch = 0 + rc = SQLITE_OK /* Return code */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Name of current table */ + nTab = 0 + savedFlag = (*Tsqlite3)(unsafe.Pointer(db)).Fflags & (libc.Uint64FromInt32(libc.Int32FromInt32(0x00008)) << libc.Int32FromInt32(32)) + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db)) + if flags&int32(SQLITE_CHANGESETAPPLY_FKNOACTION) != 0 { + **(**Tu64)(__ccgo_up(db + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(0x00008)) << libc.Int32FromInt32(32) + **(**int32)(__ccgo_up((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)) -= int32(32) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FbNoDiscard = int32(1) + libc.Xmemset(tls, bp+8, 0, uint64(136)) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbRebase = libc.BoolUint8(ppRebase != 0 && pnRebase != 0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbInvertConstraints = libc.BoolInt32(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETAPPLY_INVERT) != 0)) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbIgnoreNoop = libc.BoolUint8(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETAPPLY_IGNORENOOP) != 0)) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbNoUpdateLoop = libc.BoolUint8(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETAPPLY_NOUPDATELOOP) != 0)) + if flags&int32(SQLITE_CHANGESETAPPLY_NOSAVEPOINT) == 0 { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36448, uintptr(0), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36474, uintptr(0), uintptr(0), uintptr(0)) + } + for rc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3changeset_next(tls, pIter) { + Xsqlite3changeset_op(tls, pIter, bp+152, bp+144, bp+148, uintptr(0)) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) || Xsqlite3_strnicmp(tls, **(**uintptr)(__ccgo_up(bp + 152)), **(**uintptr)(__ccgo_up(bp)), nTab+int32(1)) != 0 { + rc = _sessionRetryConstraints(tls, db, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset, **(**uintptr)(__ccgo_up(bp)), bp+8, __ccgo_fp_xConflict, pCtx) + if rc != SQLITE_OK { + break + } + _sessionUpdateFree(tls, bp+8) + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FazCol) /* cast works around VC++ bug */ + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpDelete) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpInsert) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpSelect) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Fdb = db + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpDelete = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpInsert = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpSelect = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol = 0 + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FazCol = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FabPK = uintptr(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbStat1 = 0 + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbDeferConstraints = int32(1) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbRebaseStarted = uint8(0) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbRowid = 0 + libc.Xmemset(tls, bp+8+88, 0, uint64(16)) + /* If an xFilter() callback was specified, invoke it now. If the + ** xFilter callback returns zero, skip this table. If it returns + ** non-zero, proceed. */ + schemaMismatch = libc.BoolInt32(__ccgo_fp_xFilter != 0 && 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xFilter})))(tls, pCtx, **(**uintptr)(__ccgo_up(bp + 152)))) + if schemaMismatch != 0 { + **(**uintptr)(__ccgo_up(bp)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+336, **(**uintptr)(__ccgo_up(bp + 152)))) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + rc = int32(SQLITE_NOMEM) + break + } + nTab = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(bp)))) + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FazCol = **(**uintptr)(__ccgo_up(bp)) + } else { + nMinCol = 0 + Xsqlite3changeset_pk(tls, pIter, bp+160, uintptr(0)) + rc = _sessionTableInfo(tls, uintptr(0), db, __ccgo_ts+6816, **(**uintptr)(__ccgo_up(bp + 152)), bp+8+32, uintptr(0), bp, bp+8+40, uintptr(0), uintptr(0), bp+8+48, bp+8+124) + if rc != SQLITE_OK { + break + } + i = 0 + for { + if !(i < (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FabPK + uintptr(i))) != 0 { + nMinCol = i + int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + if (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol == 0 { + schemaMismatch = int32(1) + Xsqlite3_log(tls, int32(SQLITE_SCHEMA), __ccgo_ts+36504, libc.VaList(bp+336, **(**uintptr)(__ccgo_up(bp)))) + } else { + if (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol < **(**int32)(__ccgo_up(bp + 144)) { + schemaMismatch = int32(1) + Xsqlite3_log(tls, int32(SQLITE_SCHEMA), __ccgo_ts+36548, libc.VaList(bp+336, **(**uintptr)(__ccgo_up(bp)), (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol, **(**int32)(__ccgo_up(bp + 144)))) + } else { + if **(**int32)(__ccgo_up(bp + 144)) < nMinCol || libc.Xmemcmp(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FabPK, **(**uintptr)(__ccgo_up(bp + 160)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 144)))) != 0 { + schemaMismatch = int32(1) + Xsqlite3_log(tls, int32(SQLITE_SCHEMA), __ccgo_ts+36619, libc.VaList(bp+336, **(**uintptr)(__ccgo_up(bp)))) + } else { + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FnCol = **(**int32)(__ccgo_up(bp + 144)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+12833) { + v2 = _sessionStat1Sql(tls, db, bp+8) + rc = v2 + if v2 != 0 { + break + } + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbStat1 = int32(1) + } else { + v2 = _sessionSelectRow(tls, db, **(**uintptr)(__ccgo_up(bp)), bp+8) + rc = v2 + if v5 = v2 != 0; !v5 { + v3 = _sessionDeleteRow(tls, db, **(**uintptr)(__ccgo_up(bp)), bp+8) + rc = v3 + } + if v7 = v5 || v3 != 0; !v7 { + v4 = _sessionInsertRow(tls, db, **(**uintptr)(__ccgo_up(bp)), bp+8) + rc = v4 + } + if v7 || v4 != 0 { + break + } + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbStat1 = 0 + } + } + } + } + nTab = _sqlite3Strlen30(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + /* If there is a schema mismatch on the current table, proceed to the + ** next change. A log message has already been issued. */ + if schemaMismatch != 0 { + continue + } + /* If this is a call to apply_v3(), invoke xFilterIter here. */ + if __ccgo_fp_xFilterIter != 0 && 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xFilterIter})))(tls, pCtx, pIter) { + continue + } + rc = _sessionApplyOneWithRetry(tls, db, pIter, bp+8, __ccgo_fp_xConflict, pCtx) + } + bPatchset = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset + if rc == SQLITE_OK { + rc = Xsqlite3changeset_finalize(tls, pIter) + } else { + Xsqlite3changeset_finalize(tls, pIter) + } + if rc == SQLITE_OK { + rc = _sessionRetryConstraints(tls, db, bPatchset, **(**uintptr)(__ccgo_up(bp)), bp+8, __ccgo_fp_xConflict, pCtx) + } + if rc == SQLITE_OK { + Xsqlite3_db_status(tls, db, int32(SQLITE_DBSTATUS_DEFERRED_FKS), bp+168, bp+172, 0) + if **(**int32)(__ccgo_up(bp + 168)) != 0 { + res = int32(SQLITE_CHANGESET_ABORT) + libc.Xmemset(tls, bp+176, 0, uint64(152)) + (**(**Tsqlite3_changeset_iter)(__ccgo_up(bp + 176))).FnCol = **(**int32)(__ccgo_up(bp + 168)) + res = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xConflict})))(tls, pCtx, int32(SQLITE_CHANGESET_FOREIGN_KEY), bp+176) + if res != SQLITE_CHANGESET_OMIT { + rc = int32(SQLITE_CONSTRAINT) + } + } + } + rc2 = Xsqlite3_exec(tls, db, __ccgo_ts+36679, uintptr(0), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + rc = rc2 + } + if flags&int32(SQLITE_CHANGESETAPPLY_NOSAVEPOINT) == 0 { + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36709, uintptr(0), uintptr(0), uintptr(0)) + } + if rc != SQLITE_OK { + Xsqlite3_exec(tls, db, __ccgo_ts+36733, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_exec(tls, db, __ccgo_ts+36709, uintptr(0), uintptr(0), uintptr(0)) + } + } + if rc == SQLITE_OK && bPatchset == 0 && (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FbRebase != 0 { + **(**uintptr)(__ccgo_up(ppRebase)) = (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Frebase.FaBuf + **(**int32)(__ccgo_up(pnRebase)) = (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Frebase.FnBuf + (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Frebase.FaBuf = uintptr(0) + } + _sessionUpdateFree(tls, bp+8) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpInsert) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpDelete) + Xsqlite3_finalize(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FpSelect) + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FazCol) /* cast works around VC++ bug */ + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Fconstraints.FaBuf) + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).Frebase.FaBuf) + if flags&int32(SQLITE_CHANGESETAPPLY_FKNOACTION) != 0 && savedFlag == uint64(0) { + **(**Tu64)(__ccgo_up(db + 48)) &= ^(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008)) << libc.Int32FromInt32(32)) + **(**int32)(__ccgo_up((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)) -= int32(32) + } + Xsqlite3_set_errmsg(tls, db, rc, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FzErr) + Xsqlite3_free(tls, (**(**TSessionApplyCtx)(__ccgo_up(bp + 8))).FzErr) + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + return rc +} + +// C documentation +// +// /* +// ** Formulate a statement to DELETE a row from database db. Assuming a table +// ** structure like this: +// ** +// ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c)); +// ** +// ** The DELETE statement looks like this: +// ** +// ** DELETE FROM x WHERE a = :1 AND c = :3 AND (:5 OR b IS :2 AND d IS :4) +// ** +// ** Variable :5 (nCol+1) is a boolean. It should be set to 0 if we require +// ** matching b and d values, or 1 otherwise. The second case comes up if the +// ** conflict handler is invoked with NOTFOUND and returns CHANGESET_REPLACE. +// ** +// ** If successful, SQLITE_OK is returned and SessionApplyCtx.pDelete is left +// ** pointing to the prepared version of the SQL statement. +// */ +func _sessionDeleteRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, nPk int32 + var zSep uintptr + var _ /* buf at bp+8 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _, _, _ = i, nPk, zSep + zSep = __ccgo_ts + 1704 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} + nPk = 0 + _sessionAppendStr(tls, bp+8, __ccgo_ts+35937, bp) + _sessionAppendIdent(tls, bp+8, zTab, bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35848, bp) + i = 0 + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 { + nPk = nPk + 1 + _sessionAppendStr(tls, bp+8, zSep, bp) + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35843, bp) + _sessionAppendInteger(tls, bp+8, i+int32(1), bp) + zSep = __ccgo_ts + 23560 + } + goto _1 + _1: + ; + i = i + 1 + } + if nPk < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol { + _sessionAppendStr(tls, bp+8, __ccgo_ts+35955, bp) + _sessionAppendInteger(tls, bp+8, (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol+int32(1), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35367, bp) + zSep = __ccgo_ts + 1704 + i = 0 + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + if !(**(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0) { + _sessionAppendStr(tls, bp+8, zSep, bp) + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35931, bp) + _sessionAppendInteger(tls, bp+8, i+int32(1), bp) + zSep = __ccgo_ts + 35963 + } + goto _2 + _2: + ; + i = i + 1 + } + _sessionAppendStr(tls, bp+8, __ccgo_ts+5257, bp) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionPrepare(tls, db, p+8, p+128, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +func _sessionExprCompareOther(tls *libc.TLS, nCol int32, zDb1 uintptr, zDb2 uintptr, zTab uintptr, azCol uintptr, abPK uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bHave, i int32 + var zRet, zSep uintptr + _, _, _, _ = bHave, i, zRet, zSep + zSep = __ccgo_ts + 1704 + zRet = uintptr(0) + bHave = 0 + i = 0 + for { + if !(i < nCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(abPK + uintptr(i)))) == 0 { + bHave = int32(1) + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+35326, libc.VaList(bp+8, zRet, zSep, zDb1, zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)), zDb2, zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)))) + zSep = __ccgo_ts + 35367 + if zRet == uintptr(0) { + break + } + } + goto _1 + _1: + ; + i = i + 1 + } + if bHave == 0 { + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+1850, 0) + } + return zRet +} + +func _sessionExprComparePK(tls *libc.TLS, nCol int32, zDb1 uintptr, zDb2 uintptr, zTab uintptr, azCol uintptr, abPK uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var i int32 + var zRet, zSep uintptr + _, _, _ = i, zRet, zSep + zSep = __ccgo_ts + 1704 + zRet = uintptr(0) + i = 0 + for { + if !(i < nCol) { + break + } + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+35292, libc.VaList(bp+8, zRet, zSep, zDb1, zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)), zDb2, zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)))) + zSep = __ccgo_ts + 23560 + if zRet == uintptr(0) { + break + } + } + goto _1 + _1: + ; + i = i + 1 + } + return zRet +} + +// C documentation +// +// /* +// ** Generate either a changeset (if argument bPatchset is zero) or a patchset +// ** (if it is non-zero) based on the current contents of the session object +// ** passed as the first argument. +// ** +// ** If no error occurs, SQLITE_OK is returned and the new changeset/patchset +// ** stored in output variables *pnChangeset and *ppChangeset. Or, if an error +// ** occurs, an SQLite error code is returned and both output variables set +// ** to 0. +// */ +func _sessionGenerateChangeset(tls *libc.TLS, pSession uintptr, bPatchset int32, __ccgo_fp_xOutput uintptr, pOut uintptr, pnChangeset uintptr, ppChangeset uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pTab, zName uintptr + var i, iCol, nNoop, nOldCol, nRewind int32 + var _ /* buf at bp+0 */ TSessionBuffer + var _ /* pSel at bp+24 */ uintptr + var _ /* rc at bp+16 */ int32 + _, _, _, _, _, _, _, _, _ = db, i, iCol, nNoop, nOldCol, nRewind, p, pTab, zName + db = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb /* Used to iterate through attached tables */ + **(**TSessionBuffer)(__ccgo_up(bp)) = TSessionBuffer{} /* Return code */ + /* Zero the output variables in case an error occurs. If this session + ** object is already in the error state (sqlite3_session.rc != SQLITE_OK), + ** this call will be a no-op. */ + if __ccgo_fp_xOutput == uintptr(0) { + **(**int32)(__ccgo_up(pnChangeset)) = 0 + **(**uintptr)(__ccgo_up(ppChangeset)) = uintptr(0) + } + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 { + return (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc + } + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db)) + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_exec(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, __ccgo_ts+35786, uintptr(0), uintptr(0), uintptr(0)) + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + return **(**int32)(__ccgo_up(bp + 16)) + } + pTab = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable + for { + if !(**(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && pTab != 0) { + break + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry != 0 { + zName = (*TSessionTable)(unsafe.Pointer(pTab)).FzName /* Used to iterate through hash buckets */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) /* SELECT statement to query table pTab */ + nRewind = (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf /* Size of buffer after writing tbl header */ + nOldCol = (*TSessionTable)(unsafe.Pointer(pTab)).FnCol + /* Check the table schema is still Ok. */ + **(**int32)(__ccgo_up(bp + 16)) = _sessionReinitTable(tls, pSession, pTab) + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && (*TSessionTable)(unsafe.Pointer(pTab)).FnCol != nOldCol { + **(**int32)(__ccgo_up(bp + 16)) = _sessionUpdateChanges(tls, pSession, pTab) + } + /* Write a table header */ + _sessionAppendTableHdr(tls, bp, bPatchset, pTab, bp+16) + /* Build and compile a statement to execute: */ + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionSelectStmt(tls, db, 0, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, zName, (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK, bp+24, uintptr(0)) + } + nNoop = (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnChange && **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK) { + break + } /* Used to iterate through changes */ + p = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*8)) + for { + if !(**(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && p != 0) { + break + } + **(**int32)(__ccgo_up(bp + 16)) = _sessionSelectBind(tls, **(**uintptr)(__ccgo_up(bp + 24)), (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK, p) + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + goto _3 + } + if Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 24))) == int32(SQLITE_ROW) { + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INSERT) { + _sessionAppendByte(tls, bp, uint8(SQLITE_INSERT), bp+16) + _sessionAppendByte(tls, bp, (*TSessionChange)(unsafe.Pointer(p)).FbIndirect, bp+16) + iCol = 0 + for { + if !(iCol < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + _sessionAppendCol(tls, bp, **(**uintptr)(__ccgo_up(bp + 24)), iCol, bp+16) + goto _4 + _4: + ; + iCol = iCol + 1 + } + } else { + **(**int32)(__ccgo_up(bp + 16)) = _sessionAppendUpdate(tls, bp, bPatchset, **(**uintptr)(__ccgo_up(bp + 24)), p, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK) + } + } else { + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(p)).Fop) != int32(SQLITE_INSERT) { + **(**int32)(__ccgo_up(bp + 16)) = _sessionAppendDelete(tls, bp, bPatchset, p, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK) + } + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp + 24))) + } + /* If the buffer is now larger than sessions_strm_chunk_size, pass + ** its contents to the xOutput() callback. */ + if __ccgo_fp_xOutput != 0 && **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf > nNoop && (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf > _sessions_strm_chunk_size { + **(**int32)(__ccgo_up(bp + 16)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf) + nNoop = -int32(1) + (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf = 0 + } + goto _3 + _3: + ; + p = (*TSessionChange)(unsafe.Pointer(p)).FpNext + } + goto _2 + _2: + ; + i = i + 1 + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 24))) + if (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf == nNoop { + (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf = nRewind + } + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + if __ccgo_fp_xOutput == uintptr(0) { + **(**int32)(__ccgo_up(pnChangeset)) = (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf + **(**uintptr)(__ccgo_up(ppChangeset)) = (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf + (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf = uintptr(0) + } else { + if (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf > 0 { + **(**int32)(__ccgo_up(bp + 16)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf) + } + } + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf) + Xsqlite3_exec(tls, db, __ccgo_ts+35806, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** This function is called to initialize the SessionTable.nCol, azCol[] +// ** abPK[] and azDflt[] members of SessionTable object pTab. If these +// ** fields are already initialized, this function is a no-op. +// ** +// ** If an error occurs, an error code is stored in sqlite3_session.rc and +// ** non-zero returned. Or, if no error occurs but the table has no primary +// ** key, sqlite3_session.rc is left set to SQLITE_OK and non-zero returned to +// ** indicate that updates on this table should be ignored. SessionTable.abPK +// ** is set to NULL in this case. +// */ +func _sessionInitTable(tls *libc.TLS, pSession uintptr, pTab uintptr, db uintptr, zDb uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, rc int32 + var v1 uintptr + var _ /* abPK at bp+0 */ uintptr + _, _, _ = i, rc, v1 + rc = SQLITE_OK + if (*TSessionTable)(unsafe.Pointer(pTab)).FnCol == 0 { + Xsqlite3_free(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol) + (*TSessionTable)(unsafe.Pointer(pTab)).FabPK = uintptr(0) + if pSession == uintptr(0) || (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK != 0 { + v1 = pTab + 28 + } else { + v1 = uintptr(0) + } + rc = _sessionTableInfo(tls, pSession, db, zDb, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, pTab+16, pTab+20, uintptr(0), pTab+32, pTab+40, pTab+48, bp, v1) + if rc == SQLITE_OK { + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(i))) != 0 { + (*TSessionTable)(unsafe.Pointer(pTab)).FabPK = **(**uintptr)(__ccgo_up(bp)) + break + } + goto _2 + _2: + ; + i = i + 1 + } + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+12833, (*TSessionTable)(unsafe.Pointer(pTab)).FzName) { + (*TSessionTable)(unsafe.Pointer(pTab)).FbStat1 = int32(1) + } + if pSession != 0 && (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize != 0 { + v1 = pSession + 64 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + uint64(libc.Uint64FromInt32(libc.Int32FromInt32(1)+_sessionVarintLen(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol)+(*TSessionTable)(unsafe.Pointer(pTab)).FnCol)+libc.Xstrlen(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName)+libc.Uint64FromInt32(1))) + } + } + } + if pSession != 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = rc + return libc.BoolInt32(rc != 0 || (*TSessionTable)(unsafe.Pointer(pTab)).FabPK == uintptr(0)) + } + return rc +} + +// C documentation +// +// /* +// ** Formulate and prepare an INSERT statement to add a record to table zTab. +// ** For example: +// ** +// ** INSERT INTO main."zTab" VALUES(?1, ?2, ?3 ...); +// ** +// ** If successful, SQLITE_OK is returned and SessionApplyCtx.pInsert is left +// ** pointing to the prepared version of the SQL statement. +// */ +func _sessionInsertRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var _ /* buf at bp+8 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _ = i + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} + _sessionAppendStr(tls, bp+8, __ccgo_ts+35968, bp) + _sessionAppendIdent(tls, bp+8, zTab, bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+23566, bp) + i = 0 + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + if i != 0 { + _sessionAppendStr(tls, bp+8, __ccgo_ts+16214, bp) + } + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)), bp) + goto _1 + _1: + ; + i = i + 1 + } + _sessionAppendStr(tls, bp+8, __ccgo_ts+35986, bp) + i = int32(1) + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + _sessionAppendStr(tls, bp+8, __ccgo_ts+35997, bp) + goto _2 + _2: + ; + i = i + 1 + } + _sessionAppendStr(tls, bp+8, __ccgo_ts+5257, bp) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionPrepare(tls, db, p+16, p+128, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Prepare a statement against database handle db that SELECTs a single +// ** row containing the default values for each column in table pTab. For +// ** example, if pTab is declared as: +// ** +// ** CREATE TABLE pTab(a PRIMARY KEY, b DEFAULT 123, c DEFAULT 'abcd'); +// ** +// ** Then this function prepares and returns the SQL statement: +// ** +// ** SELECT NULL, 123, 'abcd'; +// */ +func _sessionPrepareDfltStmt(tls *libc.TLS, db uintptr, pTab uintptr, ppStmt uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var ii int32 + var zDflt, zSep, v2 uintptr + var _ /* rc at bp+16 */ int32 + var _ /* sql at bp+0 */ TSessionBuffer + _, _, _, _ = ii, zDflt, zSep, v2 + **(**TSessionBuffer)(__ccgo_up(bp)) = TSessionBuffer{} + **(**int32)(__ccgo_up(bp + 16)) = SQLITE_OK + zSep = __ccgo_ts + 11541 + ii = 0 + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + _sessionAppendPrintf(tls, bp, bp+16, __ccgo_ts+35285, 0) + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FazDflt + uintptr(ii)*8)) != 0 { + v2 = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FazDflt + uintptr(ii)*8)) + } else { + v2 = __ccgo_ts + 1705 + } + zDflt = v2 + _sessionAppendPrintf(tls, bp, bp+16, __ccgo_ts+5227, libc.VaList(bp+32, zSep, zDflt)) + zSep = __ccgo_ts + 16214 + goto _1 + _1: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_prepare_v2(tls, db, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf, -int32(1), ppStmt, uintptr(0)) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** This function is only called from with a pre-update-hook reporting a +// ** change on table pTab (attached to session pSession). The type of change +// ** (UPDATE, INSERT, DELETE) is specified by the first argument. +// ** +// ** Unless one is already present or an error occurs, an entry is added +// ** to the changed-rows hash table associated with table pTab. +// */ +func _sessionPreupdateOneChange(tls *libc.TLS, op int32, iRowid Ti64, pSession uintptr, pTab uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var i, iIdx, iIdx1, nExpect, rc int32 + var p, pC uintptr + var _ /* bNull at bp+4 */ int32 + var _ /* iHash at bp+0 */ int32 + var _ /* nByte at bp+56 */ Tsqlite3_int64 + var _ /* p at bp+64 */ uintptr + var _ /* p at bp+72 */ uintptr + var _ /* stat1 at bp+8 */ TSessionStat1Ctx + _, _, _, _, _, _, _ = i, iIdx, iIdx1, nExpect, p, pC, rc + **(**int32)(__ccgo_up(bp + 4)) = 0 + rc = SQLITE_OK + nExpect = 0 + **(**TSessionStat1Ctx)(__ccgo_up(bp + 8)) = TSessionStat1Ctx{} + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 { + return + } + /* Load table details if required */ + if _sessionInitTable(tls, pSession, pTab, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb) != 0 { + return + } + /* Check the number of columns in this xPreUpdate call matches the + ** number of columns in the table. */ + nExpect = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx) + if (*TSessionTable)(unsafe.Pointer(pTab)).FnTotalCol < nExpect { + if _sessionReinitTable(tls, pSession, pTab) != 0 { + return + } + if _sessionUpdateChanges(tls, pSession, pTab) != 0 { + return + } + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FnTotalCol != nExpect { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = int32(SQLITE_SCHEMA) + return + } + /* Grow the hash table if required */ + if _sessionGrowHash(tls, pSession, 0, pTab) != 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = int32(SQLITE_NOMEM) + return + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FbStat1 != 0 { + (**(**TSessionStat1Ctx)(__ccgo_up(bp + 8))).Fhook = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook + (**(**TSessionStat1Ctx)(__ccgo_up(bp + 8))).FpSession = pSession + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx = bp + 8 + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew = __ccgo_fp(_sessionStat1New) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld = __ccgo_fp(_sessionStat1Old) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount = __ccgo_fp(_sessionStat1Count) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth = __ccgo_fp(_sessionStat1Depth) + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpZeroBlob == uintptr(0) { + p = _sqlite3ValueNew(tls, uintptr(0)) + if p == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto error_out + } + _sqlite3ValueSetStr(tls, p, 0, __ccgo_ts+1704, uint8(0), libc.UintptrFromInt32(0)) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpZeroBlob = p + } + } + /* Calculate the hash-key for this change. If the primary key of the row + ** includes a NULL value, exit early. Such changes are ignored by the + ** session module. */ + rc = _sessionPreupdateHash(tls, pSession, iRowid, pTab, libc.BoolInt32(op == int32(SQLITE_INSERT)), bp, bp+4) + if rc != SQLITE_OK { + goto error_out + } + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + pC = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(**(**int32)(__ccgo_up(bp)))*8)) + for { + if !(pC != 0) { + break + } + if _sessionPreupdateEqual(tls, pSession, iRowid, pTab, pC, op) != 0 { + break + } + goto _1 + _1: + ; + pC = (*TSessionChange)(unsafe.Pointer(pC)).FpNext + } + if pC == uintptr(0) { /* Used to iterate through columns */ + (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry = (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry + 1 + /* Figure out how large an allocation is required */ + **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) = int64(32) + i = (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + iIdx = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(i)*4)) + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) + if op != int32(SQLITE_INSERT) { + /* This may fail if the column has a non-NULL default and was added + ** using ALTER TABLE ADD COLUMN after this record was created. */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp+64) + } else { + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 { + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp+64) + } + } + if rc == SQLITE_OK { + /* This may fail if SQLite value p contains a utf-16 string that must + ** be converted to utf-8 and an OOM error occurs while doing so. */ + rc = _sessionSerializeValue(tls, uintptr(0), **(**uintptr)(__ccgo_up(bp + 64)), bp+56) + } + if rc != SQLITE_OK { + goto error_out + } + goto _2 + _2: + ; + i = i + 1 + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) = **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) + int64(9) /* Size of rowid field - an integer */ + } + /* Allocate the change object */ + pC = _sessionMalloc64(tls, pSession, **(**Tsqlite3_int64)(__ccgo_up(bp + 56))) + if !(pC != 0) { + rc = int32(SQLITE_NOMEM) + goto error_out + } else { + libc.Xmemset(tls, pC, 0, uint64(32)) + (*TSessionChange)(unsafe.Pointer(pC)).FaRecord = pC + 1*32 + } + /* Populate the change object. None of the preupdate_old(), + ** preupdate_new() or SerializeValue() calls below may fail as all + ** required values and encodings have already been cached in memory. + ** It is not possible for an OOM to occur in this block. */ + **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) = 0 + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + **(**Tu8)(__ccgo_up((*TSessionChange)(unsafe.Pointer(pC)).FaRecord)) = uint8(SQLITE_INTEGER) + _sessionPutI64(tls, (*TSessionChange)(unsafe.Pointer(pC)).FaRecord+1, iRowid) + **(**Tsqlite3_int64)(__ccgo_up(bp + 56)) = int64(9) + } + i = (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + **(**uintptr)(__ccgo_up(bp + 72)) = uintptr(0) + iIdx1 = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(i)*4)) + if op != int32(SQLITE_INSERT) { + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx1, bp+72) + } else { + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 { + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx1, bp+72) + } + } + _sessionSerializeValue(tls, (*TSessionChange)(unsafe.Pointer(pC)).FaRecord+uintptr(**(**Tsqlite3_int64)(__ccgo_up(bp + 56))), **(**uintptr)(__ccgo_up(bp + 72)), bp+56) + goto _3 + _3: + ; + i = i + 1 + } + /* Add the change to the hash-table */ + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbIndirect != 0 || (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx) != 0 { + (*TSessionChange)(unsafe.Pointer(pC)).FbIndirect = uint8(1) + } + (*TSessionChange)(unsafe.Pointer(pC)).FnRecordField = libc.Uint16FromInt32((*TSessionTable)(unsafe.Pointer(pTab)).FnCol) + (*TSessionChange)(unsafe.Pointer(pC)).FnRecord = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 56))) + (*TSessionChange)(unsafe.Pointer(pC)).Fop = libc.Uint8FromInt32(op) + (*TSessionChange)(unsafe.Pointer(pC)).FpNext = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(**(**int32)(__ccgo_up(bp)))*8)) + **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(**(**int32)(__ccgo_up(bp)))*8)) = pC + } else { + if (*TSessionChange)(unsafe.Pointer(pC)).FbIndirect != 0 { + /* If the existing change is considered "indirect", but this current + ** change is "direct", mark the change object as direct. */ + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx) == 0 && (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbIndirect == 0 { + (*TSessionChange)(unsafe.Pointer(pC)).FbIndirect = uint8(0) + } + } + } + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize != 0 { + rc = _sessionUpdateMaxSize(tls, op, pSession, pTab, pC) + } + } + /* If an error has occurred, mark the session object as failed. */ + goto error_out +error_out: + ; + if (*TSessionTable)(unsafe.Pointer(pTab)).FbStat1 != 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook = (**(**TSessionStat1Ctx)(__ccgo_up(bp + 8))).Fhook + } + if rc != SQLITE_OK { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = rc + } +} + +// C documentation +// +// /* +// ** Retry the changes accumulated in the pApply->constraints buffer. The +// ** pApply->constraints buffer contains all changes to table zTab that +// ** could not be applied due to SQLITE_CONSTRAINT errors. This function +// ** attempts to apply them as follows: +// ** +// ** 1) It runs through the buffer and attempts to retry each change, +// ** removing any that are successfully applied from the buffer. This +// ** is repeated until no further progress can be made. +// ** +// ** 2) For each UPDATE change in the buffer, try the following in a +// ** savepoint transaction: +// ** +// ** a) DELETE the affected row, +// ** b) Attempt step (1) with remaining changes, +// ** c) Attempt to INSERT a row equivalent to the one that would be +// ** created by applying this UPDATE change. +// ** +// ** If the INSERT in (c) succeeds, the savepoint is committed and all +// ** successfully applied changes are removed from the buffer. Step (2) +// ** is then repeated. +// ** +// ** 3) Once step (2) has been attempted for each UPDATE in the change, +// ** a final attempt is made to apply each remaining change. This time, +// ** if an SQLITE_CONSTRAINT error is encountered, the conflict handler +// ** is invoked and the user has to decide whether to omit the change +// ** or rollback the entire _apply() operation. +// */ +func _sessionRetryConstraints(tls *libc.TLS, db uintptr, bPatchset int32, zTab uintptr, pApply uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iSkip, iThis, iUpdate, rc int32 + var _ /* app at bp+48 */ TSessionBuffer + var _ /* cons at bp+0 */ TSessionBuffer + var _ /* cons at bp+16 */ TSessionBuffer + var _ /* cons at bp+64 */ TSessionBuffer + var _ /* pInsert at bp+40 */ uintptr + var _ /* pUp at bp+32 */ uintptr + _, _, _, _ = iSkip, iThis, iUpdate, rc + rc = SQLITE_OK + iUpdate = 0 + /* Step (1) */ + for (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf != 0 { + **(**TSessionBuffer)(__ccgo_up(bp)) = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints + libc.Xmemset(tls, pApply+88, 0, uint64(16)) + rc = _sessionApplyRetryBuffer(tls, bp, -int32(1), db, bPatchset, zTab, pApply, __ccgo_fp_xConflict, pCtx) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp))).FaBuf) + if rc != SQLITE_OK { + break + } + /* If no progress has been made this round, break out of the loop. */ + if (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf >= (**(**TSessionBuffer)(__ccgo_up(bp))).FnBuf { + break + } + } + /* Step (2) */ + for rc == SQLITE_OK && (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf != 0 && !((*TSessionApplyCtx)(unsafe.Pointer(pApply)).FbNoUpdateLoop != 0) { + **(**TSessionBuffer)(__ccgo_up(bp + 16)) = TSessionBuffer{} + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + iSkip = 0 + rc = _sessionRetryIterInit(tls, pApply+88, bPatchset, zTab, pApply, bp+32) + if rc == SQLITE_OK { + iThis = -int32(1) + for int32(SQLITE_ROW) == Xsqlite3changeset_next(tls, **(**uintptr)(__ccgo_up(bp + 32))) { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 32)))).Fop == int32(SQLITE_UPDATE) { + iThis = iThis + 1 + } + if iThis == iUpdate { + break + } + iSkip = iSkip + 1 + } + if iThis == iUpdate { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36388, uintptr(0), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + rc = _sessionUpdateToDeleteInsert(tls, db, zTab, pApply, **(**uintptr)(__ccgo_up(bp + 32)), bp+40) + } + } + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp + 32))) + if iThis != iUpdate { + break + } + } + if rc == SQLITE_OK { + **(**TSessionBuffer)(__ccgo_up(bp + 16)) = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints + for rc == SQLITE_OK && (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf > 0 { + **(**TSessionBuffer)(__ccgo_up(bp + 48)) = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints + libc.Xmemset(tls, pApply+88, 0, uint64(16)) + rc = _sessionApplyRetryBuffer(tls, bp+48, iSkip, db, bPatchset, zTab, pApply, __ccgo_fp_xConflict, pCtx) + if (**(**TSessionBuffer)(__ccgo_up(bp + 48))).FaBuf != (**(**TSessionBuffer)(__ccgo_up(bp + 16))).FaBuf { + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 48))).FaBuf) + } + if (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf >= (**(**TSessionBuffer)(__ccgo_up(bp + 48))).FnBuf { + break + } + iSkip = -int32(1) + } + } + iUpdate = iUpdate + 1 + if rc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 40))) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 40))) + if rc == int32(SQLITE_CONSTRAINT) { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36408, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_free(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FaBuf) + (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints = **(**TSessionBuffer)(__ccgo_up(bp + 16)) + libc.Xmemset(tls, bp+16, 0, uint64(16)) + } else { + if rc == SQLITE_OK { + iUpdate = 0 + } + } + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36430, uintptr(0), uintptr(0), uintptr(0)) + } + } else { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 40))) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 16))).FaBuf) + } + /* Step (3) */ + if rc == SQLITE_OK && (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf != 0 { + **(**TSessionBuffer)(__ccgo_up(bp + 64)) = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints + libc.Xmemset(tls, pApply+88, 0, uint64(16)) + (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FbDeferConstraints = 0 + rc = _sessionApplyRetryBuffer(tls, bp+64, -int32(1), db, bPatchset, zTab, pApply, __ccgo_fp_xConflict, pCtx) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 64))).FaBuf) + } + return rc +} + +// C documentation +// +// /* +// ** Formulate and prepare an SQL statement to query table zTab by primary +// ** key. Assuming the following table structure: +// ** +// ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c)); +// ** +// ** The SELECT statement looks like this: +// ** +// ** SELECT * FROM x WHERE a = ?1 AND c = ?3 +// ** +// ** If successful, SQLITE_OK is returned and SessionApplyCtx.pSelect is left +// ** pointing to the prepared version of the SQL statement. +// */ +func _sessionSelectRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) (r int32) { + /* TODO */ + return _sessionSelectStmt(tls, db, libc.Int32FromUint8((*TSessionApplyCtx)(unsafe.Pointer(p)).FbIgnoreNoop), __ccgo_ts+6816, zTab, (*TSessionApplyCtx)(unsafe.Pointer(p)).FbRowid, (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol, (*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK, p+24, p+128) +} + +// C documentation +// +// /* +// ** Formulate and prepare a SELECT statement to retrieve a row from table +// ** zTab in database zDb based on its primary key. i.e. +// ** +// ** SELECT *, FROM zDb.zTab WHERE (pk1, pk2,...) IS (?1, ?2,...) +// ** +// ** where is: +// ** +// ** 1 AND (?A OR ?1 IS ) AND ... +// ** +// ** for each non-pk . +// */ +func _sessionSelectStmt(tls *libc.TLS, db uintptr, bIgnoreNoop int32, zDb uintptr, zTab uintptr, bRowid int32, nCol int32, azCol uintptr, abPK uintptr, ppStmt uintptr, pzErrmsg uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var i int32 + var zSep, zSql, v2 uintptr + var _ /* cols at bp+8 */ TSessionBuffer + var _ /* nooptest at bp+24 */ TSessionBuffer + var _ /* pkfield at bp+40 */ TSessionBuffer + var _ /* pkvar at bp+56 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _, _, _, _ = i, zSep, zSql, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + zSql = uintptr(0) + zSep = __ccgo_ts + 1704 + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 24)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 40)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 56)) = TSessionBuffer{} + _sessionAppendStr(tls, bp+24, __ccgo_ts+35617, bp) + if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+12833, zTab) { + _sessionAppendStr(tls, bp+24, __ccgo_ts+35621, bp) + _sessionAppendStr(tls, bp+40, __ccgo_ts+35645, bp) + _sessionAppendStr(tls, bp+56, __ccgo_ts+35654, bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35699, bp) + } else { + i = 0 + for { + if !(i < nCol) { + break + } + if (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf != 0 { + _sessionAppendStr(tls, bp+8, __ccgo_ts+16214, bp) + } + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)), bp) + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + _sessionAppendStr(tls, bp+40, zSep, bp) + _sessionAppendStr(tls, bp+56, zSep, bp) + zSep = __ccgo_ts + 16214 + _sessionAppendIdent(tls, bp+40, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)), bp) + _sessionAppendPrintf(tls, bp+56, bp, __ccgo_ts+35713, libc.VaList(bp+80, i+int32(1))) + } else { + _sessionAppendPrintf(tls, bp+24, bp, __ccgo_ts+35717, libc.VaList(bp+80, i+int32(1)+nCol, i+int32(1), zTab, **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)))) + } + goto _1 + _1: + ; + i = i + 1 + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if bIgnoreNoop != 0 { + v2 = (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf + } else { + v2 = __ccgo_ts + 1704 + } + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+35744, libc.VaList(bp+80, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, v2, zDb, zTab, (**(**TSessionBuffer)(__ccgo_up(bp + 40))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 56))).FaBuf)) + if zSql == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionPrepare(tls, db, ppStmt, pzErrmsg, zSql) + } + Xsqlite3_free(tls, zSql) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 40))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 56))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Prepare statements for applying changes to the sqlite_stat1 table. +// ** These are similar to those created by sessionSelectRow(), +// ** sessionInsertRow(), sessionUpdateRow() and sessionDeleteRow() for +// ** other tables. +// */ +func _sessionStat1Sql(tls *libc.TLS, db uintptr, p uintptr) (r int32) { + var rc int32 + _ = rc + rc = _sessionSelectRow(tls, db, __ccgo_ts+12833, p) + if rc == SQLITE_OK { + rc = _sessionPrepare(tls, db, p+16, uintptr(0), __ccgo_ts+36001) + } + if rc == SQLITE_OK { + rc = _sessionPrepare(tls, db, p+8, uintptr(0), __ccgo_ts+36114) + } + return rc +} + +// C documentation +// +// /* +// ** This function queries the database for the names of the columns of table +// ** zThis, in schema zDb. +// ** +// ** Otherwise, if they are not NULL, variable *pnCol is set to the number +// ** of columns in the database table and variable *pzTab is set to point to a +// ** nul-terminated copy of the table name. *pazCol (if not NULL) is set to +// ** point to an array of pointers to column names. And *pabPK (again, if not +// ** NULL) is set to point to an array of booleans - true if the corresponding +// ** column is part of the primary key. +// ** +// ** For example, if the table is declared as: +// ** +// ** CREATE TABLE tbl1(w, x DEFAULT 'abc', y, z, PRIMARY KEY(w, z)); +// ** +// ** Then the five output variables are populated as follows: +// ** +// ** *pnCol = 4 +// ** *pzTab = "tbl1" +// ** *pazCol = {"w", "x", "y", "z"} +// ** *pazDflt = {NULL, 'abc', NULL, NULL} +// ** *pabPK = {1, 0, 0, 1} +// ** +// ** All returned buffers are part of the same single allocation, which must +// ** be freed using sqlite3_free() by the caller +// */ +func _sessionTableInfo(tls *libc.TLS, pSession uintptr, db uintptr, zDb uintptr, zThis uintptr, pnCol uintptr, pnTotalCol uintptr, pzTab uintptr, pazCol uintptr, pazDflt uintptr, paiIdx uintptr, pabPK uintptr, pbRowid uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var abPK, aiIdx, azCol, azDflt, pAlloc, zDflt, zName, zPragma uintptr + var bRowid, i, nDbCol, nDflt, nName1, nThis, rc int32 + var nByte Tsqlite3_int64 + var nName Tsize_t + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abPK, aiIdx, azCol, azDflt, bRowid, i, nByte, nDbCol, nDflt, nName, nName1, nThis, pAlloc, rc, zDflt, zName, zPragma + nDbCol = 0 + pAlloc = uintptr(0) + azCol = uintptr(0) + azDflt = uintptr(0) + abPK = uintptr(0) + aiIdx = uintptr(0) + bRowid = 0 /* Set to true to use rowid as PK */ + **(**uintptr)(__ccgo_up(pazCol)) = uintptr(0) + **(**uintptr)(__ccgo_up(pabPK)) = uintptr(0) + **(**int32)(__ccgo_up(pnCol)) = 0 + if pnTotalCol != 0 { + **(**int32)(__ccgo_up(pnTotalCol)) = 0 + } + if paiIdx != 0 { + **(**uintptr)(__ccgo_up(paiIdx)) = uintptr(0) + } + if pzTab != 0 { + **(**uintptr)(__ccgo_up(pzTab)) = uintptr(0) + } + if pazDflt != 0 { + **(**uintptr)(__ccgo_up(pazDflt)) = uintptr(0) + } + nThis = _sqlite3Strlen30(tls, zThis) + if nThis == int32(12) && 0 == Xsqlite3_stricmp(tls, __ccgo_ts+12833, zThis) { + rc = Xsqlite3_table_column_metadata(tls, db, zDb, zThis, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */ + zPragma = Xsqlite3_mprintf(tls, __ccgo_ts+35125, 0) + } else { + if rc == int32(SQLITE_ERROR) { + zPragma = Xsqlite3_mprintf(tls, __ccgo_ts+1704, 0) + } else { + return rc + } + } + } else { + zPragma = Xsqlite3_mprintf(tls, __ccgo_ts+35255, libc.VaList(bp+16, zDb, zThis)) + } + if !(zPragma != 0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_prepare_v2(tls, db, zPragma, -int32(1), bp, uintptr(0)) + Xsqlite3_free(tls, zPragma) + if rc != SQLITE_OK { + return rc + } + nByte = int64(nThis + int32(1)) + bRowid = libc.BoolInt32(pbRowid != uintptr(0)) + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + nByte = nByte + int64(Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(1))) /* name */ + nByte = nByte + int64(Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(4))) /* dflt_value */ + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(6)) == 0 { /* !hidden */ + nDbCol = nDbCol + 1 + } + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(5)) != 0 { + bRowid = 0 + } /* pk */ + } + if nDbCol == 0 { + bRowid = 0 + } + nDbCol = nDbCol + bRowid + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Xstrlen(tls, __ccgo_ts+31273))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Uint64FromInt32(nDbCol)*(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(4)+libc.Uint64FromInt64(1)+libc.Uint64FromInt32(1)+libc.Uint64FromInt32(1)))) + pAlloc = _sessionMalloc64(tls, pSession, nByte) + if pAlloc == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pAlloc, 0, libc.Uint64FromInt64(nByte)) + } + } + if rc == SQLITE_OK { + azCol = pAlloc + azDflt = azCol + uintptr(nDbCol)*8 + aiIdx = azDflt + uintptr(nDbCol)*8 + abPK = aiIdx + uintptr(nDbCol)*4 + pAlloc = abPK + uintptr(nDbCol) + if pzTab != 0 { + libc.Xmemcpy(tls, pAlloc, zThis, libc.Uint64FromInt32(nThis+int32(1))) + **(**uintptr)(__ccgo_up(pzTab)) = pAlloc + pAlloc = pAlloc + uintptr(nThis+int32(1)) + } + i = 0 + if bRowid != 0 { + nName = libc.Xstrlen(tls, __ccgo_ts+31273) + libc.Xmemcpy(tls, pAlloc, __ccgo_ts+31273, nName+uint64(1)) + **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)) = pAlloc + pAlloc = pAlloc + uintptr(nName+uint64(1)) + **(**Tu8)(__ccgo_up(abPK + uintptr(i))) = uint8(1) + **(**int32)(__ccgo_up(aiIdx + uintptr(i)*4)) = -int32(1) + i = i + 1 + } + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(6)) == 0 { /* !hidden */ + nName1 = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + nDflt = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + zName = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + zDflt = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + if zName == uintptr(0) { + break + } + libc.Xmemcpy(tls, pAlloc, zName, libc.Uint64FromInt32(nName1+int32(1))) + **(**uintptr)(__ccgo_up(azCol + uintptr(i)*8)) = pAlloc + pAlloc = pAlloc + uintptr(nName1+int32(1)) + if zDflt != 0 { + libc.Xmemcpy(tls, pAlloc, zDflt, libc.Uint64FromInt32(nDflt+int32(1))) + **(**uintptr)(__ccgo_up(azDflt + uintptr(i)*8)) = pAlloc + pAlloc = pAlloc + uintptr(nDflt+int32(1)) + } else { + **(**uintptr)(__ccgo_up(azDflt + uintptr(i)*8)) = uintptr(0) + } + **(**Tu8)(__ccgo_up(abPK + uintptr(i))) = libc.Uint8FromInt32(Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(5))) + **(**int32)(__ccgo_up(aiIdx + uintptr(i)*4)) = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0) + i = i + 1 + } + if pnTotalCol != 0 { + **(**int32)(__ccgo_up(pnTotalCol)) = **(**int32)(__ccgo_up(pnTotalCol)) + 1 + } + } + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + } + /* If successful, populate the output variables. Otherwise, zero them and + ** free any allocation made. An error code will be returned in this case. + */ + if rc == SQLITE_OK { + **(**uintptr)(__ccgo_up(pazCol)) = azCol + if pazDflt != 0 { + **(**uintptr)(__ccgo_up(pazDflt)) = azDflt + } + **(**uintptr)(__ccgo_up(pabPK)) = abPK + **(**int32)(__ccgo_up(pnCol)) = nDbCol + if paiIdx != 0 { + **(**uintptr)(__ccgo_up(paiIdx)) = aiIdx + } + } else { + _sessionFree(tls, pSession, azCol) + } + if pbRowid != 0 { + **(**int32)(__ccgo_up(pbRowid)) = bRowid + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Find a prepared UPDATE statement suitable for the UPDATE step currently +// ** being visited by the iterator. The UPDATE is of the form: +// ** +// ** UPDATE tbl SET col = ?, col2 = ? WHERE pk1 IS ? AND pk2 IS ? +// */ +func _sessionUpdateFind(tls *libc.TLS, pIter uintptr, p uintptr, bPatchset int32, ppStmt uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bStat1, ii, nByte, nCol, nU32, nUp int32 + var pUp, pp, zSep, zSql uintptr + var _ /* buf at bp+8 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = bStat1, ii, nByte, nCol, nU32, nUp, pUp, pp, zSep, zSql + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + pUp = uintptr(0) + nCol = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol + nU32 = ((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol + int32(33)) / int32(32) + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask == uintptr(0) { + (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask = Xsqlite3_malloc(tls, libc.Int32FromUint64(libc.Uint64FromInt32(nU32)*uint64(4))) + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + libc.Xmemset(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, 0, libc.Uint64FromInt32(nU32)*uint64(4)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_CORRUPT) + ii = 0 + for { + if !(ii < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + if **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+ii)*8)) != 0 { + **(**Tu32)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask + uintptr(ii/int32(32))*4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << (ii % libc.Int32FromInt32(32))) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if bPatchset != 0 { + **(**Tu32)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask + uintptr(nCol/int32(32))*4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(1) << (nCol % libc.Int32FromInt32(32))) + } + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp != 0 { + nUp = 0 + pp = p + 64 + for int32(1) != 0 { + nUp = nUp + 1 + if 0 == libc.Xmemcmp(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, (*TSessionUpdate)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FaMask, libc.Uint64FromInt32(nU32)*uint64(4)) { + pUp = **(**uintptr)(__ccgo_up(pp)) + **(**uintptr)(__ccgo_up(pp)) = (*TSessionUpdate)(unsafe.Pointer(pUp)).FpNext + (*TSessionUpdate)(unsafe.Pointer(pUp)).FpNext = (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp + (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp = pUp + break + } + if (*TSessionUpdate)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpNext != 0 { + pp = **(**uintptr)(__ccgo_up(pp)) + 16 + } else { + if nUp >= int32(SESSION_UPDATE_CACHE_SZ) { + Xsqlite3_finalize(tls, (*TSessionUpdate)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpStmt) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(pp))) + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + break + } + } + } + if pUp == uintptr(0) { + nByte = libc.Int32FromUint64(uint64(24) * libc.Uint64FromInt32(nU32) * uint64(4)) + bStat1 = libc.BoolInt32(Xsqlite3_stricmp(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, __ccgo_ts+12833) == 0) + pUp = Xsqlite3_malloc(tls, nByte) + if pUp == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + zSep = __ccgo_ts + 1704 + libc.Xmemset(tls, bp+8, 0, uint64(16)) + (*TSessionUpdate)(unsafe.Pointer(pUp)).FaMask = pUp + 1*24 + libc.Xmemcpy(tls, (*TSessionUpdate)(unsafe.Pointer(pUp)).FaMask, (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, libc.Uint64FromInt32(nU32)*uint64(4)) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35824, bp) + _sessionAppendIdent(tls, bp+8, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35837, bp) + /* Create the assignments part of the UPDATE */ + ii = 0 + for { + if !(ii < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(ii)))) == 0 && **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+ii)*8)) != 0 { + _sessionAppendStr(tls, bp+8, zSep, bp) + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(ii)*8)), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35843, bp) + _sessionAppendInteger(tls, bp+8, ii*int32(2)+int32(1), bp) + zSep = __ccgo_ts + 16214 + } + goto _2 + _2: + ; + ii = ii + 1 + } + /* Create the WHERE clause part of the UPDATE */ + zSep = __ccgo_ts + 1704 + _sessionAppendStr(tls, bp+8, __ccgo_ts+35848, bp) + ii = 0 + for { + if !(ii < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(ii))) != 0 || bPatchset == 0 && **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr(ii)*8)) != 0 { + _sessionAppendStr(tls, bp+8, zSep, bp) + if bStat1 != 0 && ii == int32(1) { + _sessionAppendStr(tls, bp+8, __ccgo_ts+35856, bp) + } else { + _sessionAppendIdent(tls, bp+8, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(ii)*8)), bp) + _sessionAppendStr(tls, bp+8, __ccgo_ts+35931, bp) + _sessionAppendInteger(tls, bp+8, ii*int32(2)+int32(2), bp) + } + zSep = __ccgo_ts + 23560 + } + goto _3 + _3: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + zSql = (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf + **(**int32)(__ccgo_up(bp)) = Xsqlite3_prepare_v2(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).Fdb, zSql, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf, pUp, uintptr(0)) + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + Xsqlite3_free(tls, pUp) + pUp = uintptr(0) + } else { + (*TSessionUpdate)(unsafe.Pointer(pUp)).FpNext = (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp + (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp = pUp + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + } + } + } + if pUp != 0 { + **(**uintptr)(__ccgo_up(ppStmt)) = (*TSessionUpdate)(unsafe.Pointer(pUp)).FpStmt + } else { + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Iterator pUp points to an UPDATE change. This function deletes the +// ** affected row from the database and creates an INSERT statement that +// ** may be used to reinsert the row as it is after the UPDATE change +// ** has been applied. +// ** +// ** If successful, SQLITE_OK is returned and output variable (*ppInsert) +// ** is left pointing to a prepared INSERT statement. It is the responsibility +// ** of the caller to eventually free this statement using sqlite3_finalize(). +// ** Or, if an error occurs, an SQLite error code is returned and (*ppInsert) +// ** set to NULL. pApply->zErr may be set to an error message in this case. +// */ +func _sessionUpdateToDeleteInsert(tls *libc.TLS, db uintptr, zTab uintptr, pApply uintptr, pUp uintptr, ppInsert uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var iCol, ii int32 + var pVal, zComma, zComma2, zInsert, zSelect uintptr + var _ /* bWR at bp+20 */ int32 + var _ /* cols at bp+24 */ TSessionBuffer + var _ /* insbind at bp+40 */ TSessionBuffer + var _ /* pRet at bp+0 */ uintptr + var _ /* pSelect at bp+8 */ uintptr + var _ /* pkcols at bp+56 */ TSessionBuffer + var _ /* rc at bp+16 */ int32 + var _ /* selbind at bp+72 */ TSessionBuffer + _, _, _, _, _, _, _ = iCol, ii, pVal, zComma, zComma2, zInsert, zSelect + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* The INSERT statement */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* SELECT to read current values of row */ + **(**int32)(__ccgo_up(bp + 16)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 20)) = 0 + **(**int32)(__ccgo_up(bp + 16)) = _sessionTableIsWithoutRowid(tls, db, zTab, bp+20) + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + zSelect = uintptr(0) + zInsert = uintptr(0) + **(**TSessionBuffer)(__ccgo_up(bp + 24)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 40)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 56)) = TSessionBuffer{} + **(**TSessionBuffer)(__ccgo_up(bp + 72)) = TSessionBuffer{} + zComma = __ccgo_ts + 1704 + zComma2 = __ccgo_ts + 1704 + ii = 0 + for { + if !(ii < (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol) { + break + } + _sessionAppendStr(tls, bp+24, zComma, bp+16) + _sessionAppendIdent(tls, bp+24, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(pApply)).FazCol + uintptr(ii)*8)), bp+16) + _sessionAppendStr(tls, bp+40, zComma, bp+16) + _sessionAppendStr(tls, bp+40, __ccgo_ts+5259, bp+16) + zComma = __ccgo_ts + 16214 + if **(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK + uintptr(ii))) != 0 { + _sessionAppendStr(tls, bp+56, zComma2, bp+16) + _sessionAppendIdent(tls, bp+56, **(**uintptr)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(pApply)).FazCol + uintptr(ii)*8)), bp+16) + _sessionAppendStr(tls, bp+72, zComma2, bp+16) + _sessionAppendPrintf(tls, bp+72, bp+16, __ccgo_ts+35713, libc.VaList(bp+96, ii+int32(1))) + zComma2 = __ccgo_ts + 16214 + } + goto _1 + _1: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp + 20)) == 0 { + _sessionAppendStr(tls, bp+24, zComma, bp+16) + _sessionAppendStr(tls, bp+24, __ccgo_ts+31273, bp+16) + _sessionAppendStr(tls, bp+40, zComma, bp+16) + _sessionAppendStr(tls, bp+40, __ccgo_ts+5259, bp+16) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + zSelect = Xsqlite3_mprintf(tls, __ccgo_ts+36321, libc.VaList(bp+96, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf, zTab, (**(**TSessionBuffer)(__ccgo_up(bp + 56))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 72))).FaBuf)) + if zSelect == uintptr(0) { + **(**int32)(__ccgo_up(bp + 16)) = int32(SQLITE_NOMEM) + } + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + zInsert = Xsqlite3_mprintf(tls, __ccgo_ts+36358, libc.VaList(bp+96, zTab, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 40))).FaBuf)) + if zInsert == uintptr(0) { + **(**int32)(__ccgo_up(bp + 16)) = int32(SQLITE_NOMEM) + } + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionPrepare(tls, db, bp+8, pApply+128, zSelect) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionPrepare(tls, db, bp, pApply+128, zInsert) + } + Xsqlite3_free(tls, zSelect) + Xsqlite3_free(tls, zInsert) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 40))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 56))).FaBuf) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 72))).FaBuf) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionBindRow(tls, pUp, __ccgo_fp(Xsqlite3changeset_old), (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK, **(**uintptr)(__ccgo_up(bp + 8))) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK && Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) == int32(SQLITE_ROW) { + iCol = 0 + for { + if !(iCol < (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol) { + break + } + pVal = **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pUp)).FapValue + uintptr(iCol+(*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol)*8)) + if pVal == uintptr(0) { + pVal = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), iCol) + } + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp)), iCol+int32(1), pVal) + goto _2 + _2: + ; + iCol = iCol + 1 + } + if **(**int32)(__ccgo_up(bp + 20)) == 0 { + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), iCol+int32(1), Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp + 8)), iCol)) + } + } + _sessionFinalizeStmt(tls, **(**uintptr)(__ccgo_up(bp + 8)), bp+16) + /* Delete the row from the database. */ + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sessionBindRow(tls, pUp, __ccgo_fp(Xsqlite3changeset_old), (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + Xsqlite3_bind_int(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol+int32(1), int32(1)) + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + Xsqlite3_step(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + **(**int32)(__ccgo_up(bp + 16)) = Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + } + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppInsert)) = **(**uintptr)(__ccgo_up(bp)) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** The expression is the default value for the most recently added column +// ** of the table currently under construction. +// ** +// ** Default value expressions must be constant. Raise an exception if this +// ** is not the case. +// ** +// ** This routine is called by the parser while in the middle of +// ** parsing a CREATE TABLE statement. +// */ +func _sqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStart uintptr, zEnd uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var db, p, pCol, pDfltExpr uintptr + var isInit int32 + var _ /* x at bp+0 */ TExpr + _, _, _, _, _ = db, isInit, p, pCol, pDfltExpr + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p != uintptr(0) { + isInit = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) != int32(1)) + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(p)).FnCol)-int32(1))*16 + if !(_sqlite3ExprIsConstantOrFunction(tls, pExpr, libc.Uint8FromInt32(isInit)) != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14022, libc.VaList(bp+80, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14067, 0) + } else { + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_SPAN) + *(*uintptr)(unsafe.Pointer(bp + 8)) = _sqlite3DbSpanDup(tls, db, zStart, zEnd) + (**(**TExpr)(__ccgo_up(bp))).FpLeft = pExpr + (**(**TExpr)(__ccgo_up(bp))).Fflags = uint32(EP_Skip) + pDfltExpr = _sqlite3ExprDup(tls, db, bp, int32(EXPRDUP_REDUCE)) + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8))) + _sqlite3ColumnSetExpr(tls, pParse, p, pCol, pDfltExpr) + } + } + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameExprUnmap(tls, pParse, pExpr) + } + _sqlite3ExprDelete(tls, db, pExpr) +} + +// C documentation +// +// /* Change the most recently parsed column to be a GENERATED ALWAYS AS +// ** column. +// */ +func _sqlite3AddGenerated(tls *libc.TLS, pParse uintptr, pExpr uintptr, pType uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType Tu8 + var pCol, pTab, v1 uintptr + _, _, _, _ = eType, pCol, pTab, v1 + eType = uint8(COLFLAG_VIRTUAL) + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if pTab == uintptr(0) { + /* generated column in an CREATE TABLE IF NOT EXISTS that already exists */ + goto generated_done + } + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1))*16 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14257, 0) + goto generated_done + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) > 0 { + goto generated_error + } + if pType != 0 { + if (*TToken)(unsafe.Pointer(pType)).Fn == uint32(7) && Xsqlite3_strnicmp(tls, __ccgo_ts+14300, (*TToken)(unsafe.Pointer(pType)).Fz, int32(7)) == 0 { + /* no-op */ + } else { + if (*TToken)(unsafe.Pointer(pType)).Fn == uint32(6) && Xsqlite3_strnicmp(tls, __ccgo_ts+14308, (*TToken)(unsafe.Pointer(pType)).Fz, int32(6)) == 0 { + eType = uint8(COLFLAG_STORED) + } else { + goto generated_error + } + } + } + if libc.Int32FromUint8(eType) == int32(COLFLAG_VIRTUAL) { + (*TTable)(unsafe.Pointer(pTab)).FnNVCol = (*TTable)(unsafe.Pointer(pTab)).FnNVCol - 1 + } + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint8(eType)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(eType) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + _makeColumnPartOfPrimaryKey(tls, pParse, pCol) /* For the error message */ + } + if pExpr != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_ID) { + /* The value of a generated column needs to be a real expression, not + ** just a reference to another column, in order for covering index + ** optimizations to work correctly. So if the value is not an expression, + ** turn it into one by adding a unary "+" operator. */ + pExpr = _sqlite3PExpr(tls, pParse, int32(TK_UPLUS), pExpr, uintptr(0)) + } + if pExpr != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_RAISE) { + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = (*TColumn)(unsafe.Pointer(pCol)).Faffinity + } + _sqlite3ColumnSetExpr(tls, pParse, pTab, pCol, pExpr) + pExpr = uintptr(0) + goto generated_done + goto generated_error +generated_error: + ; + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14315, libc.VaList(bp+8, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + goto generated_done +generated_done: + ; + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) +} + +// C documentation +// +// /* +// ** Designate the PRIMARY KEY for the table. pList is a list of names +// ** of columns that form the primary key. If pList is NULL, then the +// ** most recently added column of the table is the primary key. +// ** +// ** A table can have at most one primary key. If the table already has +// ** a primary key (and this is the second primary key) then create an +// ** error. +// ** +// ** If the PRIMARY KEY is on a single column whose datatype is INTEGER, +// ** then we will try to use that column as the rowid. Set the Table.iPKey +// ** field of the table under construction to be the index of the +// ** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is +// ** no INTEGER PRIMARY KEY. +// ** +// ** If the key is not an INTEGER PRIMARY KEY, then create a unique +// ** index for the key. No index is created for INTEGER PRIMARY KEYs. +// */ +func _sqlite3AddPrimaryKey(tls *libc.TLS, pParse uintptr, pList uintptr, onError int32, autoInc int32, sortOrder int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iCol, nTerm int32 + var pCExpr, pCExpr1, pCol, pTab uintptr + _, _, _, _, _, _, _ = i, iCol, nTerm, pCExpr, pCExpr1, pCol, pTab + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + pCol = uintptr(0) + iCol = -int32(1) + if pTab == uintptr(0) { + goto primary_key_exit + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasPrimaryKey) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14160, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto primary_key_exit + } + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_HasPrimaryKey) + if pList == uintptr(0) { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) - int32(1) + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + _makeColumnPartOfPrimaryKey(tls, pParse, pCol) + nTerm = int32(1) + } else { + nTerm = (*TExprList)(unsafe.Pointer(pList)).FnExpr + i = 0 + for { + if !(i < nTerm) { + break + } + pCExpr = _sqlite3ExprSkipCollate(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr) + _sqlite3StringToId(tls, pCExpr) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCExpr)).Fop) == int32(TK_ID) { + iCol = _sqlite3ColumnIndex(tls, pTab, *(*uintptr)(unsafe.Pointer(pCExpr + 8))) + if iCol >= 0 { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + _makeColumnPartOfPrimaryKey(tls, pParse, pCol) + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + if nTerm == int32(1) && pCol != 0 && int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == int32(COLTYPE_INTEGER) && sortOrder != int32(SQLITE_SO_DESC) { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && pList != 0 { + pCExpr1 = _sqlite3ExprSkipCollate(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8))).FpExpr) + _sqlite3RenameTokenRemap(tls, pParse, pTab+52, pCExpr1) + } + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(iCol) + (*TTable)(unsafe.Pointer(pTab)).FkeyConf = libc.Uint8FromInt32(onError) + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(autoInc * int32(TF_Autoincrement)) + if pList != 0 { + (*TParse)(unsafe.Pointer(pParse)).FiPkSortOrder = (*(*TExprList_item)(unsafe.Pointer(pList + 8))).Ffg.FsortFlags + } + _sqlite3HasExplicitNulls(tls, pParse, pList) + } else { + if autoInc != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14201, 0) + } else { + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, onError, uintptr(0), uintptr(0), sortOrder, 0, uint8(SQLITE_IDXTYPE_PRIMARYKEY)) + pList = uintptr(0) + } + } + goto primary_key_exit +primary_key_exit: + ; + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList) + return +} + +// C documentation +// +// /* +// ** Add the RETURNING clause to the parse currently underway. +// ** +// ** This routine creates a special TEMP trigger that will fire for each row +// ** of the DML statement. That TEMP trigger contains a single SELECT +// ** statement with a result set that is the argument of the RETURNING clause. +// ** The trigger has the Trigger.bReturning flag and an opcode of +// ** TK_RETURNING instead of TK_SELECT, so that the trigger code generator +// ** knows to handle it specially. The TEMP trigger is automatically +// ** removed at the end of the parse. +// ** +// ** When this routine is called, we do not yet know if the RETURNING clause +// ** is attached to a DELETE, INSERT, or UPDATE, so construct it as a +// ** RETURNING trigger instead. It will then be converted into the appropriate +// ** type on the first call to sqlite3TriggersExist(). +// */ +func _sqlite3AddReturning(tls *libc.TLS, pParse uintptr, pList uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pHash, pRet uintptr + _, _, _ = db, pHash, pRet + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13902, 0) + } else { + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 3, 0x8) + pRet = _sqlite3DbMallocZero(tls, db, uint64(232)) + if pRet == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pList) + return + } + (*(*struct { + FpReturning uintptr + })(unsafe.Pointer(&(*TParse)(unsafe.Pointer(pParse)).Fu1))).FpReturning = pRet + (*TReturning)(unsafe.Pointer(pRet)).FpParse = pParse + (*TReturning)(unsafe.Pointer(pRet)).FpReturnEL = pList + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3DeleteReturning), pRet) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + Xsqlite3_snprintf(tls, int32(40), pRet+188, __ccgo_ts+13936, libc.VaList(bp+8, pParse)) + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.FzName = pRet + 188 + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.Fop = uint8(TK_RETURNING) + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.Ftr_tm = uint8(TRIGGER_AFTER) + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.FbReturning = uint8(1) + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.FpTabSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + (*TReturning)(unsafe.Pointer(pRet)).FretTrig.Fstep_list = pRet + 88 + (*TReturning)(unsafe.Pointer(pRet)).FretTStep.Fop = uint8(TK_RETURNING) + (*TReturning)(unsafe.Pointer(pRet)).FretTStep.FpTrig = pRet + 16 + (*TReturning)(unsafe.Pointer(pRet)).FretTStep.FpExprList = pList + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 56 + if _sqlite3HashInsert(tls, pHash, pRet+188, pRet+16) == pRet+16 { + _sqlite3OomFault(tls, db) + } +} + +// C documentation +// +// /* +// ** Generate bytecode to implement: +// ** +// ** ALTER TABLE pSrc ADD [CONSTRAINT pName] CHECK(pExpr) +// ** +// ** Any "ON CONFLICT" text that occurs after the "CHECK(...)", up +// ** until pParse->sLastToken, is included as part of the new constraint. +// */ +func _sqlite3AlterAddConstraint(tls *libc.TLS, pParse uintptr, pSrc uintptr, pFirst uintptr, pName uintptr, zExpr uintptr, nExpr int32, pExpr uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var nCons, rc int32 + var pCons, pTab, zName uintptr + var _ /* iDb at bp+0 */ int32 + var _ /* zDb at bp+8 */ uintptr + _, _, _, _, _ = nCons, pCons, pTab, rc, zName + pTab = uintptr(0) /* Table identified by pSrc */ + **(**int32)(__ccgo_up(bp)) = 0 /* Which schema does pTab live in */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Name of the schema in which pTab lives */ + pCons = uintptr(0) /* Result from error checking pExpr */ + /* Look up the table being altered. */ + pTab = _alterFindTable(tls, pParse, pSrc, bp, bp+8, int32(1)) + if !(pTab != 0) { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + return + } + /* Verify that the new CHECK constraint does not contain any + ** internal-use-only function. Forum post 2026-05-10T01:11:28Z + */ + rc = _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_IsCheck), pExpr, uintptr(0)) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + if rc != 0 { + return + } + /* If this new constraint has a name, check that it is not a duplicate of + ** an existing constraint. It is an error if it is. */ + if pName != 0 { + zName = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pName) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12283, libc.VaList(bp+24, zName, int32(SQLITE_ERROR), **(**uintptr)(__ccgo_up(bp + 8)), (*TTable)(unsafe.Pointer(pTab)).FzName, zName)) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zName) + } + /* Search for a constraint violation. Throw an exception if one is found. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12448, libc.VaList(bp+24, int32(SQLITE_CONSTRAINT), **(**uintptr)(__ccgo_up(bp + 8)), (*TTable)(unsafe.Pointer(pTab)).FzName, nExpr, zExpr)) + /* Edit the SQL for the named table. */ + pCons = (*TToken)(unsafe.Pointer(pFirst)).Fz + nCons = _alterRtrimConstraint(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCons, int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64(pCons))) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12528, libc.VaList(bp+24, **(**uintptr)(__ccgo_up(bp + 8)), nCons, pCons, (*TTable)(unsafe.Pointer(pTab)).FzName)) + /* Finally, reload the database schema. */ + _renameReloadSchema(tls, pParse, **(**int32)(__ccgo_up(bp)), uint16(INITFLAG_AlterDropCons)) +} + +// C documentation +// +// /* +// ** This function is called by the parser after the table-name in +// ** an "ALTER TABLE ADD" statement is parsed. Argument +// ** pSrc is the full-name of the table being altered. +// ** +// ** This routine makes a (partial) copy of the Table structure +// ** for the table being altered and sets Parse.pNewTable to point +// ** to it. Routines called by the parser as the column definition +// ** is parsed (i.e. sqlite3AddColumn()) add the new Column data to +// ** the copy. The copy of the Table structure is deleted by tokenize.c +// ** after parsing is finished. +// ** +// ** Routine sqlite3AlterFinishAddColumn() will be called to complete +// ** coding the "ALTER TABLE ... ADD" statement. +// */ +func _sqlite3AlterBeginAddColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pCol, pNew, pTab uintptr + var i, iDb, nAlloc int32 + _, _, _, _, _, _, _ = db, i, iDb, nAlloc, pCol, pNew, pTab + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Look up the table being altered. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_begin_add_column + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_begin_add_column + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11032, 0) + goto exit_begin_add_column + } + /* Make sure this is not an attempt to ALTER a view. */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11066, 0) + goto exit_begin_add_column + } + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_begin_add_column + } + _sqlite3MayAbort(tls, pParse) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + /* Put a copy of the Table struct in Parse.pNewTable for the + ** sqlite3AddColumn() function and friends to modify. But modify + ** the name by adding an "sqlite_altertab_" prefix. By adding this + ** prefix, we insure that the name will not collide with an existing + ** table because user table are not allowed to have the "sqlite_" + ** prefix on their name. + */ + pNew = _sqlite3DbMallocZero(tls, db, uint64(120)) + if !(pNew != 0) { + goto exit_begin_add_column + } + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = pNew + (*TTable)(unsafe.Pointer(pNew)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pNew)).FnCol = (*TTable)(unsafe.Pointer(pTab)).FnCol + nAlloc = (int32((*TTable)(unsafe.Pointer(pNew)).FnCol)-int32(1))/int32(8)*int32(8) + int32(8) + (*TTable)(unsafe.Pointer(pNew)).FaCol = _sqlite3DbMallocZero(tls, db, uint64(16)*uint64(libc.Uint32FromInt32(nAlloc))) + (*TTable)(unsafe.Pointer(pNew)).FzName = _sqlite3MPrintf(tls, db, __ccgo_ts+11096, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + if !((*TTable)(unsafe.Pointer(pNew)).FaCol != 0) || !((*TTable)(unsafe.Pointer(pNew)).FzName != 0) { + goto exit_begin_add_column + } + libc.Xmemcpy(tls, (*TTable)(unsafe.Pointer(pNew)).FaCol, (*TTable)(unsafe.Pointer(pTab)).FaCol, uint64(16)*libc.Uint64FromInt16((*TTable)(unsafe.Pointer(pNew)).FnCol)) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pNew)).FnCol)) { + break + } + pCol = (*TTable)(unsafe.Pointer(pNew)).FaCol + uintptr(i)*16 + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = _sqlite3DbStrDup(tls, db, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + goto _1 + _1: + ; + i = i + 1 + } + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FpDfltList = _sqlite3ExprListDup(tls, db, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpDfltList, 0) + (*TTable)(unsafe.Pointer(pNew)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FaddColOffset = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FaddColOffset + goto exit_begin_add_column +exit_begin_add_column: + ; + _sqlite3SrcListDelete(tls, db, pSrc) + return +} + +// C documentation +// +// /* +// ** Generate bytecode for one of: +// ** +// ** (1) ALTER TABLE pSrc DROP CONSTRAINT pCons +// ** (2) ALTER TABLE pSrc ALTER pCol DROP NOT NULL +// ** +// ** One of pCons and pCol must be NULL and the other non-null. +// */ +func _sqlite3AlterDropConstraint(tls *libc.TLS, pParse uintptr, pSrc uintptr, pCons uintptr, pCol uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pTab, z, zArg uintptr + var _ /* iCol at bp+16 */ int32 + var _ /* iDb at bp+0 */ int32 + var _ /* zDb at bp+8 */ uintptr + _, _, _, _ = db, pTab, z, zArg + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTab = uintptr(0) + **(**int32)(__ccgo_up(bp)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + zArg = uintptr(0) + pTab = _alterFindTable(tls, pParse, pSrc, bp, bp+8, libc.BoolInt32(pCons != uintptr(0))) + if !(pTab != 0) { + return + } + if pCons != 0 { + z = _sqlite3NameFromToken(tls, db, pCons) + zArg = _sqlite3MPrintf(tls, db, __ccgo_ts+11925, libc.VaList(bp+32, z)) + _sqlite3DbFree(tls, db, z) + } else { + if _alterFindCol(tls, pParse, pTab, pCol, bp+16) != 0 { + return + } + zArg = _sqlite3MPrintf(tls, db, __ccgo_ts+5289, libc.VaList(bp+32, **(**int32)(__ccgo_up(bp + 16)))) + } + /* Edit the SQL for the named table. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11928, libc.VaList(bp+32, **(**uintptr)(__ccgo_up(bp + 8)), zArg, (*TTable)(unsafe.Pointer(pTab)).FzName)) + _sqlite3DbFree(tls, db, zArg) + /* Finally, reload the database schema. */ + _renameReloadSchema(tls, pParse, **(**int32)(__ccgo_up(bp)), uint16(INITFLAG_AlterDropCons)) +} + +// C documentation +// +// /* +// ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" +// ** command. +// */ +func _sqlite3AlterRenameTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pTab, pVTab, v, zDb, zName, zTabName, v2 uintptr + var i, iDb, nTabName, v1 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iDb, nTabName, pTab, pVTab, v, zDb, zName, zTabName, v1, v2 /* Table being renamed */ + zName = uintptr(0) /* NULL-terminated version of pName */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pVTab = uintptr(0) /* Non-zero if this is a v-tab with an xRename() */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_rename_table + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_rename_table + } + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Get a NULL terminated version of the new table name. */ + zName = _sqlite3NameFromToken(tls, db, pName) + if !(zName != 0) { + goto exit_rename_table + } + /* Check that a table or index named 'zName' does not already exist + ** in database iDb. If so, this is an error. + */ + if _sqlite3FindTable(tls, db, zName, zDb) != 0 || _sqlite3FindIndex(tls, db, zName, zDb) != 0 || _sqlite3IsShadowTableOf(tls, db, pTab, zName) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+9318, libc.VaList(bp+8, zName)) + goto exit_rename_table + } + /* Make sure it is not a system table being altered, or a reserved name + ** that the table is being renamed to. + */ + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_rename_table + } + if SQLITE_OK != _sqlite3CheckObjectName(tls, pParse, zName, __ccgo_ts+9377, zName) { + goto exit_rename_table + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+9383, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_rename_table + } + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + goto exit_rename_table + } + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto exit_rename_table + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + pVTab = _sqlite3GetVTable(tls, db, pTab) + if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer((*TVTable)(unsafe.Pointer(pVTab)).FpVtab)).FpModule)).FxRename == uintptr(0) { + pVTab = uintptr(0) + } + } + /* Begin a transaction for database iDb. Then modify the schema cookie + ** (since the ALTER TABLE modifies the schema). Call sqlite3MayAbort(), + ** as the scalar functions (e.g. sqlite_rename_table()) invoked by the + ** nested SQL may raise an exception. */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto exit_rename_table + } + _sqlite3MayAbort(tls, pParse) + /* figure out how many UTF-8 characters are in zName */ + zTabName = (*TTable)(unsafe.Pointer(pTab)).FzName + nTabName = _sqlite3Utf8CharLen(tls, zTabName, -int32(1)) + /* Rewrite all CREATE TABLE, INDEX, TRIGGER or VIEW statements in + ** the schema to use the new table name. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9410, libc.VaList(bp+8, zDb, zDb, zTabName, zName, libc.BoolInt32(iDb == int32(1)), zTabName)) + /* Update the tbl_name and name columns of the sqlite_schema table + ** as required. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9594, libc.VaList(bp+8, zDb, zName, zName, zName, nTabName, zTabName)) + /* If the sqlite_sequence table exists in this database, then update + ** it with the new table name. + */ + if _sqlite3FindTable(tls, db, __ccgo_ts+9899, zDb) != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9915, libc.VaList(bp+8, zDb, zName, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + /* If the table being renamed is not itself part of the temp database, + ** edit view and trigger definitions within the temp database + ** as required. */ + if iDb != int32(1) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9973, libc.VaList(bp+8, zDb, zTabName, zName, zTabName, zDb, zName)) + } + /* If this is a virtual table, invoke the xRename() function if + ** one is defined. The xRename() callback will modify the names + ** of any resources used by the v-table implementation (including other + ** SQLite tables) that are identified by the name of the virtual table. + */ + if pVTab != 0 { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + i = v1 + _sqlite3VdbeLoadString(tls, v, i, zName) + _sqlite3VdbeAddOp4(tls, v, int32(OP_VRename), i, 0, 0, pVTab, -int32(12)) + } + _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterRename)) + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1)), __ccgo_ts+10238, 0) + goto exit_rename_table +exit_rename_table: + ; + _sqlite3SrcListDelete(tls, db, pSrc) + _sqlite3DbFree(tls, db, zName) +} + +// C documentation +// +// /* +// ** Prepare a statement of the form: +// ** +// ** ALTER TABLE pSrc ALTER pCol SET NOT NULL +// */ +func _sqlite3AlterSetNotNull(tls *libc.TLS, pParse uintptr, pSrc uintptr, pCol uintptr, pFirst uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var nCons int32 + var pCons, pTab uintptr + var _ /* iCol at bp+0 */ int32 + var _ /* iDb at bp+4 */ int32 + var _ /* zDb at bp+8 */ uintptr + _, _, _ = nCons, pCons, pTab + pTab = uintptr(0) + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pCons = uintptr(0) + nCons = 0 + /* Look up the table being altered. */ + pTab = _alterFindTable(tls, pParse, pSrc, bp+4, bp+8, 0) + if !(pTab != 0) { + return + } + /* Find the column being altered. */ + if _alterFindCol(tls, pParse, pTab, pCol, bp) != 0 { + return + } + /* Find the length in bytes of the constraint definition */ + pCons = (*TToken)(unsafe.Pointer(pFirst)).Fz + nCons = _alterRtrimConstraint(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCons, int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64(pCons))) + /* Search for a constraint violation. Throw an exception if one is found. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12051, libc.VaList(bp+24, int32(SQLITE_CONSTRAINT), **(**uintptr)(__ccgo_up(bp + 8)), (*TTable)(unsafe.Pointer(pTab)).FzName, libc.Int32FromUint32((*TToken)(unsafe.Pointer(pCol)).Fn), (*TToken)(unsafe.Pointer(pCol)).Fz)) + /* Edit the SQL for the named table. */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12132, libc.VaList(bp+24, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp)), nCons, pCons, **(**int32)(__ccgo_up(bp)), (*TTable)(unsafe.Pointer(pTab)).FzName)) + /* Finally, reload the database schema. */ + _renameReloadSchema(tls, pParse, **(**int32)(__ccgo_up(bp + 4)), uint16(INITFLAG_AlterDropCons)) +} + +// C documentation +// +// /* +// ** Load the content of the sqlite_stat1 and sqlite_stat4 tables. The +// ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] +// ** arrays. The contents of sqlite_stat4 are used to populate the +// ** Index.aSample[] arrays. +// ** +// ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR +// ** is returned. In this case, even if SQLITE_ENABLE_STAT4 was defined +// ** during compilation and the sqlite_stat4 table is present, no data is +// ** read from it. +// ** +// ** If SQLITE_ENABLE_STAT4 was defined during compilation and the +// ** sqlite_stat4 table is not present in the database, SQLITE_ERROR is +// ** returned. However, in this case, data is read from the sqlite_stat1 +// ** table (if it is present) before returning. +// ** +// ** If an OOM error occurs, this function always sets db->mallocFailed. +// ** This means if the caller does not care about other errors, the return +// ** code may be ignored. +// */ +func _sqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, pIdx, pIdx1, pIdx2, pSchema, pStat1, pTab, zSql, v3 uintptr + var rc, v5 int32 + var _ /* sInfo at bp+0 */ TanalysisInfo + _, _, _, _, _, _, _, _, _, _, _ = i, pIdx, pIdx1, pIdx2, pSchema, pStat1, pTab, rc, zSql, v3, v5 + rc = SQLITE_OK + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + /* Clear any prior statistics */ + i = (*THash)(unsafe.Pointer(pSchema + 8)).Ffirst + for { + if !(i != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(i)).Fdata + **(**Tu32)(__ccgo_up(pTab + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(TF_HasStat1)) + goto _1 + _1: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + i = (*THash)(unsafe.Pointer(pSchema + 32)).Ffirst + for { + if !(i != 0) { + break + } + pIdx = (*THashElem)(unsafe.Pointer(i)).Fdata + libc.SetBitFieldPtr16Uint32(pIdx+100, libc.Uint32FromInt32(0), 7, 0x80) + _sqlite3DeleteIndexSamples(tls, db, pIdx) + (*TIndex)(unsafe.Pointer(pIdx)).FaSample = uintptr(0) + goto _2 + _2: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + /* Load new statistics out of the sqlite_stat1 table */ + (**(**TanalysisInfo)(__ccgo_up(bp))).Fdb = db + (**(**TanalysisInfo)(__ccgo_up(bp))).FzDatabase = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + v3 = _sqlite3FindTable(tls, db, __ccgo_ts+12833, (**(**TanalysisInfo)(__ccgo_up(bp))).FzDatabase) + pStat1 = v3 + if v3 != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pStat1)).FeTabType) == TABTYP_NORM { + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+13206, libc.VaList(bp+24, (**(**TanalysisInfo)(__ccgo_up(bp))).FzDatabase)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_analysisLoader), bp, uintptr(0)) + _sqlite3DbFree(tls, db, zSql) + } + } + /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */ + i = (*THash)(unsafe.Pointer(pSchema + 32)).Ffirst + for { + if !(i != 0) { + break + } + pIdx1 = (*THashElem)(unsafe.Pointer(i)).Fdata + if !(int32(uint32(*(*uint16)(unsafe.Pointer(pIdx1 + 100))&0x80>>7)) != 0) { + _sqlite3DefaultRowEst(tls, pIdx1) + } + goto _4 + _4: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + /* Load the statistics from the sqlite_stat4 table. */ + if rc == SQLITE_OK { + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + rc = _loadStat4(tls, db, (**(**TanalysisInfo)(__ccgo_up(bp))).FzDatabase) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v5 = 0 + } else { + v5 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v5) + } + i = (*THash)(unsafe.Pointer(pSchema + 32)).Ffirst + for { + if !(i != 0) { + break + } + pIdx2 = (*THashElem)(unsafe.Pointer(i)).Fdata + Xsqlite3_free(tls, (*TIndex)(unsafe.Pointer(pIdx2)).FaiRowEst) + (*TIndex)(unsafe.Pointer(pIdx2)).FaiRowEst = uintptr(0) + goto _6 + _6: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + return rc +} + +/************** End of analyze.c *********************************************/ +/************** Begin file attach.c ******************************************/ +/* +** 2003 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the ATTACH and DETACH commands. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** The pExpr should be a TK_COLUMN expression. The table referred to +// ** is in pTabList or else it is the NEW or OLD table of a trigger. +// ** Check to see if it is OK to read this particular column. +// ** +// ** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN +// ** instruction into a TK_NULL. If the auth function returns SQLITE_DENY, +// ** then generate an error. +// */ +func _sqlite3AuthRead(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSchema uintptr, pTabList uintptr) { + var iCol, iDb, iSrc int32 + var pTab, zCol uintptr + _, _, _, _, _ = iCol, iDb, iSrc, pTab, zCol + pTab = uintptr(0) /* Index of column in table */ + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSchema) + if iDb < 0 { + /* An attempt to read a column out of a subquery or other + ** temporary table. */ + return + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_TRIGGER) { + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } else { + iSrc = 0 + for { + if !(iSrc < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(iSrc)*80))).FiCursor { + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(iSrc)*80))).FpSTab + break + } + goto _1 + _1: + ; + iSrc = iSrc + 1 + } + } + iCol = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + if pTab == uintptr(0) { + return + } + if iCol >= 0 { + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + } else { + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) >= 0 { + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TTable)(unsafe.Pointer(pTab)).FiPKey)*16))).FzCnName + } else { + zCol = __ccgo_ts + 8197 + } + } + if int32(SQLITE_IGNORE) == _sqlite3AuthReadCol(tls, pParse, (*TTable)(unsafe.Pointer(pTab)).FzName, zCol, iDb) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + } +} + +// C documentation +// +// /* +// ** Invoke the authorization callback for permission to read column zCol from +// ** table zTab in database zDb. This function assumes that an authorization +// ** callback has been registered (i.e. that sqlite3.xAuth is not NULL). +// ** +// ** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed +// ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE +// ** is treated as SQLITE_DENY. In this case an error is left in pParse. +// */ +func _sqlite3AuthReadCol(tls *libc.TLS, pParse uintptr, zTab uintptr, zCol uintptr, iDb int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, z, zDb uintptr + var rc int32 + _, _, _, _ = db, rc, z, zDb + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database handle */ + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName /* Auth callback return code */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + return SQLITE_OK + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxAuth})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpAuthArg, int32(SQLITE_READ), zTab, zCol, zDb, (*TParse)(unsafe.Pointer(pParse)).FzAuthContext) + if rc == int32(SQLITE_DENY) { + z = Xsqlite3_mprintf(tls, __ccgo_ts+13632, libc.VaList(bp+8, zTab, zCol)) + if (*Tsqlite3)(unsafe.Pointer(db)).FnDb > int32(2) || iDb != 0 { + z = Xsqlite3_mprintf(tls, __ccgo_ts+13638, libc.VaList(bp+8, zDb, z)) + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13644, libc.VaList(bp+8, z)) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_AUTH) + } else { + if rc != int32(SQLITE_IGNORE) && rc != SQLITE_OK { + _sqliteAuthBadReturnCode(tls, pParse) + } + } + return rc +} + +// C documentation +// +// /* +// ** Load all automatic extensions. +// ** +// ** If anything goes wrong, set an error in the database connection. +// */ +func _sqlite3AutoLoadExtensions(tls *libc.TLS, db uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var go1, rc, v2 int32 + var i Tu32 + var mutex, pThunk uintptr + var xInit Tsqlite3_loadext_entry + var v3 bool + var _ /* zErrmsg at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = go1, i, mutex, pThunk, rc, xInit, v2, v3 + go1 = int32(1) + if _sqlite3Autoext.FnExt == uint32(0) { + /* Common case: early out without every having to acquire a mutex */ + return + } + i = uint32(0) + for { + if !(go1 != 0) { + break + } + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + pThunk = uintptr(unsafe.Pointer(&_sqlite3Apis)) + Xsqlite3_mutex_enter(tls, mutex) + if i >= _sqlite3Autoext.FnExt { + xInit = uintptr(0) + go1 = 0 + } else { + xInit = **(**uintptr)(__ccgo_up(_sqlite3Autoext.FaExt + uintptr(i)*8)) + } + Xsqlite3_mutex_leave(tls, mutex) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if v3 = xInit != 0; v3 { + v2 = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xInit})))(tls, db, bp, pThunk) + rc = v2 + } + if v3 && v2 != 0 { + _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+17741, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp)))) + go1 = 0 + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + goto _1 + _1: + ; + i = i + 1 + } +} + +/************** End of loadext.c *********************************************/ +/************** Begin file pragma.c ******************************************/ +/* +** 2003 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the PRAGMA command. + */ +/* #include "sqliteInt.h" */ + +/*************************************************************************** +** The "pragma.h" include file is an automatically generated file that +** that includes the PragType_XXXX macro definitions and the aPragmaName[] +** object. This ensures that the aPragmaName[] table is arranged in +** lexicographical order to facility a binary search of the pragma name. +** Do not edit pragma.h directly. Edit and rerun the script in at +** ../tool/mkpragmatab.tcl. */ +/************** Include pragma.h in the middle of pragma.c *******************/ +/************** Begin file pragma.h ******************************************/ +/* DO NOT EDIT! +** This file is automatically generated by the script at +** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit +** that script and rerun it. + */ + +/* The various pragma types */ + +/* Property flags associated with various pragma. */ + +// C documentation +// +// /* +// ** Generate VDBE code for a BEGIN statement. +// */ +func _sqlite3BeginTransaction(tls *libc.TLS, pParse uintptr, type1 int32) { + var db, pBt, v uintptr + var eTxnType, i int32 + _, _, _, _, _ = db, eTxnType, i, pBt, v + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_TRANSACTION), __ccgo_ts+16103, uintptr(0), uintptr(0)) != 0 { + return + } + v = _sqlite3GetVdbe(tls, pParse) + if !(v != 0) { + return + } + if type1 != int32(TK_DEFERRED) { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 && _sqlite3BtreeIsReadonly(tls, pBt) != 0 { + eTxnType = 0 /* Read txn */ + } else { + if type1 == int32(TK_EXCLUSIVE) { + eTxnType = int32(2) /* Exclusive txn */ + } else { + eTxnType = int32(1) /* Write txn */ + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Transaction), i, eTxnType) + _sqlite3VdbeUsesBtree(tls, v, i) + goto _1 + _1: + ; + i = i + 1 + } + } + _sqlite3VdbeAddOp0(tls, v, int32(OP_AutoCommit)) +} + +// C documentation +// +// /* +// ** This is called by the parser when it sees a CREATE TRIGGER statement +// ** up to the point of the BEGIN before the trigger actions. A Trigger +// ** structure is generated based on the information available and stored +// ** in pParse->pNewTrigger. After the trigger actions have been parsed, the +// ** sqlite3FinishTrigger() function is called to complete the trigger +// ** construction process. +// */ +func _sqlite3BeginTrigger(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, tr_tm int32, op int32, pColumns uintptr, pTableName uintptr, pWhen uintptr, isTemp int32, noErr int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var code, iDb, iTabDb, v4 int32 + var db, pTab, pTrigger, zDb, zDbTrig, zName, v1 uintptr + var _ /* pName at bp+0 */ uintptr + var _ /* sFix at bp+8 */ TDbFixer + _, _, _, _, _, _, _, _, _, _, _ = code, db, iDb, iTabDb, pTab, pTrigger, zDb, zDbTrig, zName, v1, v4 + pTrigger = uintptr(0) /* Table that the trigger fires off of */ + zName = uintptr(0) /* Name of the trigger */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* State vector for the DB fixer */ + /* pName1->z might be NULL, but not pName1 itself */ + if isTemp != 0 { + /* If TEMP was specified, then the trigger name may not be qualified. */ + if (*TToken)(unsafe.Pointer(pName2)).Fn > uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21796, 0) + goto trigger_cleanup + } + iDb = int32(1) + **(**uintptr)(__ccgo_up(bp)) = pName1 + } else { + /* Figure out the db that the trigger will be created in */ + iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp) + if iDb < 0 { + goto trigger_cleanup + } + } + if !(pTableName != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto trigger_cleanup + } + /* A long-standing parser bug is that this syntax was allowed: + ** + ** CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab .... + ** ^^^^^^^^ + ** + ** To maintain backwards compatibility, ignore the database + ** name on pTableName if we are reparsing out of the schema table + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 && iDb != int32(1) { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pTableName + 8 + 72))) + *(*uintptr)(unsafe.Pointer(pTableName + 8 + 72)) = uintptr(0) + } + /* If the trigger name was unqualified, and the table is a temp table, + ** then set iDb to 1 to create the trigger in the temporary database. + ** If sqlite3SrcListLookup() returns 0, indicating the table does not + ** exist, the error is caught by the block below. + */ + pTab = _sqlite3SrcListLookup(tls, pParse, pTableName) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 && (*TToken)(unsafe.Pointer(pName2)).Fn == uint32(0) && pTab != 0 && (*TTable)(unsafe.Pointer(pTab)).FpSchema == (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema { + iDb = int32(1) + } + /* Ensure the table name matches database name and that the table exists */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto trigger_cleanup + } + _sqlite3FixInit(tls, bp+8, pParse, iDb, __ccgo_ts+21842, **(**uintptr)(__ccgo_up(bp))) + if _sqlite3FixSrcList(tls, bp+8, pTableName) != 0 { + goto trigger_cleanup + } + pTab = _sqlite3SrcListLookup(tls, pParse, pTableName) + if !(pTab != 0) { + /* The table does not exist. */ + goto trigger_orphan_error + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21850, 0) + goto trigger_orphan_error + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Shadow) != uint32(0) && _sqlite3ReadOnlyShadowTables(tls, db) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21891, 0) + goto trigger_orphan_error + } + /* Check that the trigger name is not reserved and that no trigger of the + ** specified name exists */ + zName = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if zName == uintptr(0) { + goto trigger_cleanup + } + if _sqlite3CheckObjectName(tls, pParse, zName, __ccgo_ts+21842, (*TTable)(unsafe.Pointer(pTab)).FzName) != 0 { + goto trigger_cleanup + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema+56, zName) != 0 { + if !(noErr != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21931, libc.VaList(bp+112, **(**uintptr)(__ccgo_up(bp)))) + } else { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + } + goto trigger_cleanup + } + } + /* NB: The SQLITE_ALLOW_TRIGGERS_ON_SYSTEM_TABLES compile-time option is + ** experimental and unsupported. Do not use it unless understand the + ** implications and you cannot get by without this capability. */ + /* Do not create a trigger on a system table */ + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+6756, int32(7)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21957, 0) + goto trigger_cleanup + } + /* INSTEAD of triggers are only for views and views only support INSTEAD + ** of triggers. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) && tr_tm != int32(TK_INSTEAD) { + if tr_tm == int32(TK_BEFORE) { + v1 = __ccgo_ts + 21995 + } else { + v1 = __ccgo_ts + 22002 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22008, libc.VaList(bp+112, v1, pTableName+8)) + goto trigger_orphan_error + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VIEW)) && tr_tm == int32(TK_INSTEAD) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22045, libc.VaList(bp+112, pTableName+8)) + goto trigger_orphan_error + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + iTabDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + code = int32(SQLITE_CREATE_TRIGGER) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iTabDb)*32))).FzDbSName + if isTemp != 0 { + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FzDbSName + } else { + v1 = zDb + } + zDbTrig = v1 + if iTabDb == int32(1) || isTemp != 0 { + code = int32(SQLITE_CREATE_TEMP_TRIGGER) + } + if _sqlite3AuthCheck(tls, pParse, code, zName, (*TTable)(unsafe.Pointer(pTab)).FzName, zDbTrig) != 0 { + goto trigger_cleanup + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iTabDb == int32(1) { + v1 = __ccgo_ts + 6764 + } else { + v1 = __ccgo_ts + 6284 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), v1, uintptr(0), zDb) != 0 { + goto trigger_cleanup + } + } + /* INSTEAD OF triggers can only appear on views and BEFORE triggers + ** cannot appear on views. So we might as well translate every + ** INSTEAD OF trigger into a BEFORE trigger. It simplifies code + ** elsewhere. + */ + if tr_tm == int32(TK_INSTEAD) { + tr_tm = int32(TK_BEFORE) + } + /* Build the Trigger object */ + pTrigger = _sqlite3DbMallocZero(tls, db, uint64(72)) + if pTrigger == uintptr(0) { + goto trigger_cleanup + } + (*TTrigger)(unsafe.Pointer(pTrigger)).FzName = zName + zName = uintptr(0) + (*TTrigger)(unsafe.Pointer(pTrigger)).Ftable = _sqlite3DbStrDup(tls, db, (*(*TSrcItem)(unsafe.Pointer(pTableName + 8))).FzName) + (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + (*TTrigger)(unsafe.Pointer(pTrigger)).Fop = libc.Uint8FromInt32(op) + if tr_tm == int32(TK_BEFORE) { + v4 = int32(TRIGGER_BEFORE) + } else { + v4 = int32(TRIGGER_AFTER) + } + (*TTrigger)(unsafe.Pointer(pTrigger)).Ftr_tm = libc.Uint8FromInt32(v4) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, (*TTrigger)(unsafe.Pointer(pTrigger)).Ftable, (*(*TSrcItem)(unsafe.Pointer(pTableName + 8))).FzName) + (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen = pWhen + pWhen = uintptr(0) + } else { + (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen = _sqlite3ExprDup(tls, db, pWhen, int32(EXPRDUP_REDUCE)) + } + (*TTrigger)(unsafe.Pointer(pTrigger)).FpColumns = pColumns + pColumns = uintptr(0) + (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger = pTrigger + goto trigger_cleanup +trigger_cleanup: + ; + _sqlite3DbFree(tls, db, zName) + _sqlite3SrcListDelete(tls, db, pTableName) + _sqlite3IdListDelete(tls, db, pColumns) + _sqlite3ExprDelete(tls, db, pWhen) + if !((*TParse)(unsafe.Pointer(pParse)).FpNewTrigger != 0) { + _sqlite3DeleteTrigger(tls, db, pTrigger) + } else { + } + return + goto trigger_orphan_error +trigger_orphan_error: + ; + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) == int32(1) { + /* Ticket #3810. + ** Normally, whenever a table is dropped, all associated triggers are + ** dropped too. But if a TEMP trigger is created on a non-TEMP table + ** and the table is dropped by a different database connection, the + ** trigger is not visible to the database connection that does the + ** drop so the trigger cannot be dropped. This results in an + ** "orphaned trigger" - a trigger whose associated table is missing. + ** + ** 2020-11-05 see also https://sqlite.org/forum/forumpost/157dc791df + */ + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(1), 0, 0x1) + } + goto trigger_cleanup +} + +// C documentation +// +// /* +// ** This routine is used to check if the UTF-8 string zName is a legal +// ** unqualified name for a new schema object (table, index, view or +// ** trigger). All names are legal except those that begin with the string +// ** "sqlite_" (in upper, lower or mixed case). This portion of the namespace +// ** is reserved for internal use. +// ** +// ** When parsing the sqlite_schema table, this routine also checks to +// ** make sure the "type", "name", and "tbl_name" columns are consistent +// ** with the SQL. +// */ +func _sqlite3CheckObjectName(tls *libc.TLS, pParse uintptr, zName uintptr, zType uintptr, zTblName uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db uintptr + _ = db + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if _sqlite3WritableSchema(tls, db) != 0 || int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x6>>1)) != 0 || !(_sqlite3Config.FbExtraSchemaChecks != 0) { + /* Skip these error checks for writable_schema=ON */ + return SQLITE_OK + } + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + if Xsqlite3_stricmp(tls, zType, **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit))) != 0 || Xsqlite3_stricmp(tls, zName, **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit + 1*8))) != 0 || Xsqlite3_stricmp(tls, zTblName, **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit + 2*8))) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1704, 0) /* corruptSchema() will supply the error */ + return int32(SQLITE_ERROR) + } + } else { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && 0 == Xsqlite3_strnicmp(tls, zName, __ccgo_ts+6756, int32(7)) || _sqlite3ReadOnlyShadowTables(tls, db) != 0 && _sqlite3ShadowTableName(tls, db, zName) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13763, libc.VaList(bp+8, zName)) + return int32(SQLITE_ERROR) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Generate code to drop a table. +// */ +func _sqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int32, isView int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pDb, pTrigger, v uintptr + _, _, _, _ = db, pDb, pTrigger, v + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + v = _sqlite3GetVdbe(tls, pParse) + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3VdbeAddOp0(tls, v, int32(OP_VBegin)) + } + /* Drop all triggers associated with the table being dropped. Code + ** is generated to remove entries from sqlite_schema and/or + ** sqlite_temp_schema if required. + */ + pTrigger = _sqlite3TriggerList(tls, pParse, pTab) + for pTrigger != 0 { + _sqlite3DropTriggerPtr(tls, pParse, pTrigger) + pTrigger = (*TTrigger)(unsafe.Pointer(pTrigger)).FpNext + } + /* Remove any entries of the sqlite_sequence table associated with + ** the table being dropped. This is done before the table is dropped + ** at the btree level, in case the sqlite_sequence table needs to + ** move as a result of the drop (can happen in auto-vacuum mode). + */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Autoincrement) != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+14965, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + /* Drop all entries in the schema table that refer to the + ** table. The program name loops through the schema table and deletes + ** every row that refers to a table of the same name as the one being + ** dropped. Triggers are handled separately because a trigger can be + ** created in the temp database that refers to a table in another + ** database. + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+15010, libc.VaList(bp+8, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, (*TTable)(unsafe.Pointer(pTab)).FzName)) + if !(isView != 0) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + _destroyTable(tls, pParse, pTab) + } + /* Remove the table entry from SQLite's internal schema and modify + ** the schema cookie. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_VDestroy), iDb, 0, 0, (*TTable)(unsafe.Pointer(pTab)).FzName, 0) + _sqlite3MayAbort(tls, pParse) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_DropTable), iDb, 0, 0, (*TTable)(unsafe.Pointer(pTab)).FzName, 0) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqliteViewResetAll(tls, db, iDb) +} + +// C documentation +// +// /* +// ** Return true if zName points to a name that may be used to refer to +// ** database iDb attached to handle db. +// */ +func _sqlite3DbIsNamed(tls *libc.TLS, db uintptr, iDb int32, zName uintptr) (r int32) { + return libc.BoolInt32(_sqlite3StrICmp(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zName) == 0 || iDb == 0 && _sqlite3StrICmp(tls, __ccgo_ts+6816, zName) == 0) +} + +// C documentation +// +// /* +// ** Generate code for a DELETE FROM statement. +// ** +// ** DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL; +// ** \________/ \________________/ +// ** pTabList pWhere +// */ +func _sqlite3DeleteFrom(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWhere uintptr, pOrderBy uintptr, pLimit uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aToOpen, db, pIdx, pPk, pTab, pTrigger, pVTab, pWInfo, v, v3 uintptr + var addrBypass, addrEphOpen, addrLoop, bComplex, count, eOnePass, i, iAddrOnce, iDb, iEphCur, iKey, iPk, iRowSet, iTabCur, isView, memCnt, nIdx, rcauth, v1, v2 int32 + var nKey, nPk Ti16 + var wcf Tu16 + var _ /* aiCurOnePass at bp+80 */ [2]int32 + var _ /* iDataCur at bp+0 */ int32 + var _ /* iIdxCur at bp+4 */ int32 + var _ /* sContext at bp+8 */ TAuthContext + var _ /* sNC at bp+24 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aToOpen, addrBypass, addrEphOpen, addrLoop, bComplex, count, db, eOnePass, i, iAddrOnce, iDb, iEphCur, iKey, iPk, iRowSet, iTabCur, isView, memCnt, nIdx, nKey, nPk, pIdx, pPk, pTab, pTrigger, pVTab, pWInfo, rcauth, v, wcf, v1, v2, v3 /* Cursor number for the table */ + **(**int32)(__ccgo_up(bp)) = 0 /* VDBE cursor for the canonical data source */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* Database number */ + memCnt = 0 /* The write cursors opened by WHERE_ONEPASS */ + aToOpen = uintptr(0) /* The PRIMARY KEY index on the table */ + iPk = 0 /* First of nPk registers holding PRIMARY KEY value */ + nPk = int16(1) /* Number of memory cells in the row key */ + iEphCur = 0 /* Ephemeral table holding all primary key values */ + iRowSet = 0 /* Register for rowset of rows to delete */ + addrBypass = 0 /* Address of jump over the delete logic */ + addrLoop = 0 /* Top of the delete loop */ + addrEphOpen = 0 /* List of table triggers, if required */ + libc.Xmemset(tls, bp+8, 0, uint64(16)) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto delete_from_cleanup + } + /* Locate the table which we want to delete. This table has to be + ** put in an SrcList structure because some of the subroutines we + ** will be calling are designed to work with multiple tables and expect + ** an SrcList* parameter instead of just a Table* parameter. + */ + pTab = _sqlite3SrcListLookup(tls, pParse, pTabList) + if pTab == uintptr(0) { + goto delete_from_cleanup + } + /* Figure out if we have any triggers and if the table being + ** deleted from is a view + */ + pTrigger = _sqlite3TriggersExist(tls, pParse, pTab, int32(TK_DELETE), uintptr(0), uintptr(0)) + isView = libc.BoolInt32(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW)) + bComplex = libc.BoolInt32(pTrigger != 0 || _sqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0) + /* If pTab is really a view, make sure it has been initialized. + */ + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto delete_from_cleanup + } + if _sqlite3IsReadOnly(tls, pParse, pTab, pTrigger) != 0 { + goto delete_from_cleanup + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + rcauth = _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + if rcauth == int32(SQLITE_DENY) { + goto delete_from_cleanup + } + /* Assign cursor numbers to the table and all its indices. + */ + v3 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = v2 + (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor = v1 + iTabCur = v1 + nIdx = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + (*TParse)(unsafe.Pointer(pParse)).FnTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + 1 + goto _4 + _4: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + nIdx = nIdx + 1 + } + /* Start the view context + */ + if isView != 0 { + _sqlite3AuthContextPush(tls, pParse, bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName) + } + /* Begin generating code. + */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto delete_from_cleanup + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _sqlite3VdbeCountChanges(tls, v) + } + _sqlite3BeginWriteOperation(tls, pParse, bComplex, iDb) + /* If we are trying to delete from a view, realize that view into + ** an ephemeral table. + */ + if isView != 0 { + _sqlite3MaterializeView(tls, pParse, pTab, pWhere, pOrderBy, pLimit, iTabCur) + v1 = iTabCur + **(**int32)(__ccgo_up(bp + 4)) = v1 + **(**int32)(__ccgo_up(bp)) = v1 + pOrderBy = uintptr(0) + pLimit = uintptr(0) + } + /* Resolve the column names in the WHERE clause. + */ + libc.Xmemset(tls, bp+24, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp + 24))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp + 24))).FpSrcList = pTabList + if _sqlite3ResolveExprNames(tls, bp+24, pWhere) != 0 { + goto delete_from_cleanup + } + /* Initialize the counter of the number of rows deleted, if + ** we are counting rows. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00001))<>3)) != 0) { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = *(*int32)(unsafe.Pointer(v3)) + memCnt = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, memCnt) + } + /* Special case: A DELETE without a WHERE clause deletes everything. + ** It is easier just to erase the whole table. Prior to version 3.6.5, + ** this optimization caused the row change count (the value returned by + ** API function sqlite3_count_changes) to be set incorrectly. + ** + ** The "rcauth==SQLITE_OK" terms is the + ** IMPLEMENTATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and + ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but + ** the truncate optimization is disabled and all rows are deleted + ** individually. + */ + if rcauth == SQLITE_OK && pWhere == uintptr(0) && !(bComplex != 0) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) && (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback == uintptr(0) { + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(1), (*TTable)(unsafe.Pointer(pTab)).FzName) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + if memCnt != 0 { + v1 = memCnt + } else { + v1 = -int32(1) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_Clear), libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab)).Ftnum), iDb, v1, (*TTable)(unsafe.Pointer(pTab)).FzName, -int32(1)) + } + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) && !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + if memCnt != 0 { + v1 = memCnt + } else { + v1 = -int32(1) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Clear), libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx)).Ftnum), iDb, v1) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Clear), libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx)).Ftnum), iDb) + } + goto _9 + _9: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } else { + wcf = libc.Uint16FromInt32(libc.Int32FromInt32(WHERE_ONEPASS_DESIRED) | libc.Int32FromInt32(WHERE_DUPLICATES_OK)) + if (**(**TNameContext)(__ccgo_up(bp + 24))).FncFlags&int32(NC_Subquery) != 0 { + bComplex = int32(1) + } + if bComplex != 0 { + v1 = 0 + } else { + v1 = int32(WHERE_ONEPASS_MULTIROW) + } + wcf = libc.Uint16FromInt32(int32(wcf) | v1) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + /* For a rowid table, initialize the RowSet to an empty set */ + pPk = uintptr(0) + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = *(*int32)(unsafe.Pointer(v3)) + iRowSet = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, iRowSet) + } else { + /* For a WITHOUT ROWID table, create an ephemeral table used to + ** hold all primary keys for rows to be deleted. */ + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int16FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + iPk = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(nPk) + v3 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + iEphCur = v1 + addrEphOpen = _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), iEphCur, int32(nPk)) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) + } + /* Construct a query to find the rowid or primary key for every row + ** to be deleted, based on the WHERE clause. Set variable eOnePass + ** to indicate the strategy used to implement this delete: + ** + ** ONEPASS_OFF: Two-pass approach - use a FIFO for rowids/PK values. + ** ONEPASS_SINGLE: One-pass approach - at most one row deleted. + ** ONEPASS_MULTI: One-pass approach - any number of rows may be deleted. + */ + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, uintptr(0), uintptr(0), uintptr(0), wcf, iTabCur+int32(1)) + if pWInfo == uintptr(0) { + goto delete_from_cleanup + } + eOnePass = _sqlite3WhereOkOnePass(tls, pWInfo, bp+80) + if eOnePass != int32(ONEPASS_SINGLE) { + _sqlite3MultiWrite(tls, pParse) + } + if _sqlite3WhereUsesDeferredSeek(tls, pWInfo) != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_FinishSeek), iTabCur) + } + /* Keep track of the number of rows to be deleted */ + if memCnt != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), memCnt, int32(1)) + } + /* Extract the rowid or primary key for the current row */ + if pPk != 0 { + i = 0 + for { + if !(i < int32(nPk)) { + break + } + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iTabCur, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))), iPk+i) + goto _16 + _16: + ; + i = i + 1 + } + iKey = iPk + } else { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = *(*int32)(unsafe.Pointer(v3)) + iKey = v1 + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iTabCur, -int32(1), iKey) + } + if eOnePass != ONEPASS_OFF { + /* For ONEPASS, no need to store the rowid/primary-key. There is only + ** one, so just keep it in its register(s) and fall through to the + ** delete code. */ + nKey = nPk /* OP_Found will use an unpacked key */ + aToOpen = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(nIdx+int32(2))) + if aToOpen == uintptr(0) { + _sqlite3WhereEnd(tls, pWInfo) + goto delete_from_cleanup + } + libc.Xmemset(tls, aToOpen, int32(1), libc.Uint64FromInt32(nIdx+int32(1))) + **(**Tu8)(__ccgo_up(aToOpen + uintptr(nIdx+int32(1)))) = uint8(0) + if (**(**[2]int32)(__ccgo_up(bp + 80)))[0] >= 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr((**(**[2]int32)(__ccgo_up(bp + 80)))[0]-iTabCur))) = uint8(0) + } + if (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] >= 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr((**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)]-iTabCur))) = uint8(0) + } + if addrEphOpen != 0 { + _sqlite3VdbeChangeToNoop(tls, v, addrEphOpen) + } + addrBypass = _sqlite3VdbeMakeLabel(tls, pParse) + } else { + if pPk != 0 { + /* Add the PK key for this row to the temporary table */ + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = *(*int32)(unsafe.Pointer(v3)) + iKey = v1 + nKey = 0 /* Zero tells OP_Found to use a composite key */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), iPk, int32(nPk), iKey, _sqlite3IndexAffinityStr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPk), int32(nPk)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iEphCur, iKey, iPk, int32(nPk)) + } else { + /* Add the rowid of the row to be deleted to the RowSet */ + nKey = int16(1) /* OP_DeferredSeek always uses a single rowid */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowSetAdd), iRowSet, iKey) + } + _sqlite3WhereEnd(tls, pWInfo) + } + /* Unless this is a view, open cursors for the table we are + ** deleting from and all its indices. If this is a view, then the + ** only effect this statement has is to fire the INSTEAD OF + ** triggers. + */ + if !(isView != 0) { + iAddrOnce = 0 + if eOnePass == int32(ONEPASS_MULTI) { + iAddrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + _sqlite3OpenTableAndIndices(tls, pParse, pTab, int32(OP_OpenWrite), uint8(OPFLAG_FORDELETE), iTabCur, aToOpen, bp, bp+4) + if eOnePass == int32(ONEPASS_MULTI) { + _sqlite3VdbeJumpHereOrPopInst(tls, v, iAddrOnce) + } + } + /* Set up a loop over the rowids/primary-keys that were found in the + ** where-clause loop above. + */ + if eOnePass != ONEPASS_OFF { + /* OP_Found will use an unpacked key */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) && **(**Tu8)(__ccgo_up(aToOpen + uintptr(**(**int32)(__ccgo_up(bp))-iTabCur))) != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), **(**int32)(__ccgo_up(bp)), addrBypass, iKey, int32(nKey)) + } + } else { + if pPk != 0 { + addrLoop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iEphCur) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEphCur, 0, iKey) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowData), iEphCur, iKey) + } + /* OP_Found will use a composite key */ + } else { + addrLoop = _sqlite3VdbeAddOp3(tls, v, int32(OP_RowSetRead), iRowSet, 0, iKey) + } + } + /* Delete the row */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + pVTab = _sqlite3GetVTable(tls, db, pTab) + _sqlite3VtabMakeWritable(tls, pParse, pTab) + _sqlite3MayAbort(tls, pParse) + if eOnePass == int32(ONEPASS_SINGLE) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iTabCur) + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).FisMultiWrite = uint8(0) + } + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_VUpdate), 0, int32(1), iKey, pVTab, -int32(12)) + _sqlite3VdbeChangeP5(tls, v, uint16(OE_Abort)) + } else { + count = libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0) /* True to count changes */ + _sqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), iKey, nKey, libc.Uint8FromInt32(count), uint8(OE_Default), libc.Uint8FromInt32(eOnePass), (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)]) + } + /* End of the loop over all rowids/primary-keys. */ + if eOnePass != ONEPASS_OFF { + _sqlite3VdbeResolveLabel(tls, v, addrBypass) + _sqlite3WhereEnd(tls, pWInfo) + } else { + if pPk != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iEphCur, addrLoop+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addrLoop) + } else { + _sqlite3VdbeGoto(tls, v, addrLoop) + _sqlite3VdbeJumpHere(tls, v, addrLoop) + } + } + } /* End non-truncate path */ + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0) { + _sqlite3AutoincrementEnd(tls, pParse) + } + /* Return the number of rows that were deleted. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + if memCnt != 0 { + _sqlite3CodeChangeCount(tls, v, memCnt, __ccgo_ts+16445) + } + goto delete_from_cleanup +delete_from_cleanup: + ; + _sqlite3AuthContextPop(tls, bp+8) + _sqlite3SrcListDelete(tls, db, pTabList) + _sqlite3ExprDelete(tls, db, pWhere) + if aToOpen != 0 { + _sqlite3DbNNFreeNN(tls, db, aToOpen) + } + return +} + +/* Make sure "isView" and other macros defined above are undefined. Otherwise +** they may interfere with compilation of other functions in this file +** (or in another file, if this file becomes part of the amalgamation). */ + +// C documentation +// +// /* +// ** This routine will drop an existing named index. This routine +// ** implements the DROP INDEX statement. +// */ +func _sqlite3DropIndex(tls *libc.TLS, pParse uintptr, pName uintptr, ifExists int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var code, iDb int32 + var db, pIndex, pTab, v, zDb, zTab, v1 uintptr + _, _, _, _, _, _, _, _, _ = code, db, iDb, pIndex, pTab, v, zDb, zTab, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_drop_index + } + /* Never called with prior non-OOM errors */ + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto exit_drop_index + } + pIndex = _sqlite3FindIndex(tls, db, (*(*TSrcItem)(unsafe.Pointer(pName + 8))).FzName, *(*uintptr)(unsafe.Pointer(pName + 8 + 72))) + if pIndex == uintptr(0) { + if !(ifExists != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15871, libc.VaList(bp+8, pName+8)) + } else { + _sqlite3CodeVerifyNamedSchema(tls, pParse, *(*uintptr)(unsafe.Pointer(pName + 8 + 72))) + _sqlite3ForceNotReadOnly(tls, pParse) + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + goto exit_drop_index + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIndex + 100))&0x3>>0)) != SQLITE_IDXTYPE_APPDEF { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15889, libc.VaList(bp+8, 0)) + goto exit_drop_index + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIndex)).FpSchema) + code = int32(SQLITE_DROP_INDEX) + pTab = (*TIndex)(unsafe.Pointer(pIndex)).FpTable + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v1 = __ccgo_ts + 6764 + } else { + v1 = __ccgo_ts + 6284 + } + zTab = v1 + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), zTab, uintptr(0), zDb) != 0 { + goto exit_drop_index + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + code = int32(SQLITE_DROP_TEMP_INDEX) + } + if _sqlite3AuthCheck(tls, pParse, code, (*TIndex)(unsafe.Pointer(pIndex)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, zDb) != 0 { + goto exit_drop_index + } + /* Generate code to remove the index and from the schema table */ + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+15962, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TIndex)(unsafe.Pointer(pIndex)).FzName)) + _sqlite3ClearStatTables(tls, pParse, iDb, __ccgo_ts+13044, (*TIndex)(unsafe.Pointer(pIndex)).FzName) + _sqlite3ChangeCookie(tls, pParse, iDb) + _destroyRootPage(tls, pParse, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIndex)).Ftnum), iDb) + _sqlite3VdbeAddOp4(tls, v, int32(OP_DropIndex), iDb, 0, 0, (*TIndex)(unsafe.Pointer(pIndex)).FzName, 0) + } + goto exit_drop_index +exit_drop_index: + ; + _sqlite3SrcListDelete(tls, db, pName) +} + +// C documentation +// +// /* +// ** This routine is called to do the work of a DROP TABLE statement. +// ** pName is the name of the table to be dropped. +// */ +func _sqlite3DropTable(tls *libc.TLS, pParse uintptr, pName uintptr, isView int32, noErr int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var code, iDb int32 + var db, pTab, v, zArg2, zDb, zTab, v1 uintptr + _, _, _, _, _, _, _, _, _ = code, db, iDb, pTab, v, zArg2, zDb, zTab, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_drop_table + } + if _sqlite3ReadSchema(tls, pParse) != 0 { + goto exit_drop_table + } + if noErr != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr = (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr + 1 + } + pTab = _sqlite3LocateTableItem(tls, pParse, libc.Uint32FromInt32(isView), pName+8) + if noErr != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr = (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr - 1 + } + if pTab == uintptr(0) { + if noErr != 0 { + _sqlite3CodeVerifyNamedSchema(tls, pParse, *(*uintptr)(unsafe.Pointer(pName + 8 + 72))) + _sqlite3ForceNotReadOnly(tls, pParse) + } + goto exit_drop_table + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + /* If pTab is a virtual table, call ViewGetColumnNames() to ensure + ** it is initialized. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) && _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto exit_drop_table + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v1 = __ccgo_ts + 6764 + } else { + v1 = __ccgo_ts + 6284 + } + zTab = v1 + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + zArg2 = uintptr(0) + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), zTab, uintptr(0), zDb) != 0 { + goto exit_drop_table + } + if isView != 0 { + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + code = int32(SQLITE_DROP_TEMP_VIEW) + } else { + code = int32(SQLITE_DROP_VIEW) + } + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + code = int32(SQLITE_DROP_VTABLE) + zArg2 = (*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer(_sqlite3GetVTable(tls, db, pTab))).FpMod)).FzName + } else { + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + code = int32(SQLITE_DROP_TEMP_TABLE) + } else { + code = int32(SQLITE_DROP_TABLE) + } + } + } + if _sqlite3AuthCheck(tls, pParse, code, (*TTable)(unsafe.Pointer(pTab)).FzName, zArg2, zDb) != 0 { + goto exit_drop_table + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0), zDb) != 0 { + goto exit_drop_table + } + if _tableMayNotBeDropped(tls, db, pTab) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15077, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_drop_table + } + /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used + ** on a table. + */ + if isView != 0 && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VIEW)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15105, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_drop_table + } + if !(isView != 0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15139, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_drop_table + } + /* Generate code to remove the table from the schema table + ** on disk. + */ + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + if !(isView != 0) { + _sqlite3ClearStatTables(tls, pParse, iDb, __ccgo_ts+13048, (*TTable)(unsafe.Pointer(pTab)).FzName) + _sqlite3FkDropTable(tls, pParse, pName, pTab) + } + _sqlite3CodeDropTable(tls, pParse, pTab, iDb, isView) + } + goto exit_drop_table +exit_drop_table: + ; + _sqlite3SrcListDelete(tls, db, pName) +} + +// C documentation +// +// /* +// ** This function is called to drop a trigger from the database schema. +// ** +// ** This may be called directly from the parser and therefore identifies +// ** the trigger by name. The sqlite3DropTriggerPtr() routine does the +// ** same job as this routine except it takes a pointer to the trigger +// ** instead of the trigger name. +// **/ +func _sqlite3DropTrigger(tls *libc.TLS, pParse uintptr, pName uintptr, noErr int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pTrigger, zDb, zName uintptr + var i, j, v2 int32 + _, _, _, _, _, _, _ = db, i, j, pTrigger, zDb, zName, v2 + pTrigger = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto drop_trigger_cleanup + } + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto drop_trigger_cleanup + } + zDb = *(*uintptr)(unsafe.Pointer(pName + 8 + 72)) + zName = (*(*TSrcItem)(unsafe.Pointer(pName + 8))).FzName + i = OMIT_TEMPDB + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if i < int32(2) { + v2 = i ^ int32(1) + } else { + v2 = i + } + j = v2 /* Search TEMP before MAIN */ + if zDb != 0 && _sqlite3DbIsNamed(tls, db, j, zDb) == 0 { + goto _1 + } + pTrigger = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*32))).FpSchema+56, zName) + if pTrigger != 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if !(pTrigger != 0) { + if !(noErr != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22338, libc.VaList(bp+8, pName+8)) + } else { + _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + goto drop_trigger_cleanup + } + _sqlite3DropTriggerPtr(tls, pParse, pTrigger) + goto drop_trigger_cleanup +drop_trigger_cleanup: + ; + _sqlite3SrcListDelete(tls, db, pName) +} + +// C documentation +// +// /* +// ** Drop a trigger given a pointer to that trigger. +// */ +func _sqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var code, iDb int32 + var db, pTable, v, zDb, zTab, v1 uintptr + _, _, _, _, _, _, _, _ = code, db, iDb, pTable, v, zDb, zTab, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema) + pTable = _tableOfTrigger(tls, pTrigger) + if pTable != 0 { + code = int32(SQLITE_DROP_TRIGGER) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v1 = __ccgo_ts + 6764 + } else { + v1 = __ccgo_ts + 6284 + } + zTab = v1 + if iDb == int32(1) { + code = int32(SQLITE_DROP_TEMP_TRIGGER) + } + if _sqlite3AuthCheck(tls, pParse, code, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName, (*TTable)(unsafe.Pointer(pTable)).FzName, zDb) != 0 || _sqlite3AuthCheck(tls, pParse, int32(SQLITE_DELETE), zTab, uintptr(0), zDb) != 0 { + return + } + } + /* Generate code to destroy the database record of the trigger. + */ + v1 = _sqlite3GetVdbe(tls, pParse) + v = v1 + if v1 != uintptr(0) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+22358, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName)) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddOp4(tls, v, int32(OP_DropTrigger), iDb, 0, 0, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName, 0) + } +} + +// C documentation +// +// /* +// ** Return a static string that describes the kind of error specified in the +// ** argument. +// */ +func _sqlite3ErrStr(tls *libc.TLS, rc int32) (r uintptr) { + var zErr uintptr + _ = zErr + zErr = __ccgo_ts + 25765 + switch rc { + case libc.Int32FromInt32(SQLITE_ABORT) | libc.Int32FromInt32(2)<= 0 && rc < libc.Int32FromUint64(libc.Uint64FromInt64(232)/libc.Uint64FromInt64(8)) && _aMsg[rc] != uintptr(0) { + zErr = _aMsg[rc] + } + break + } + return zErr +} + +// C documentation +// +// /* +// ** The SrcItem structure passed as the second argument represents a +// ** sub-query in the FROM clause of a SELECT statement. This function +// ** allocates and populates the SrcItem.pTab object. If successful, +// ** SQLITE_OK is returned. Otherwise, if an OOM error is encountered, +// ** SQLITE_NOMEM. +// */ +func _sqlite3ExpandSubquery(tls *libc.TLS, pParse uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pSel, pTab, v1 uintptr + var v2 int32 + _, _, _, _ = pSel, pTab, v1, v2 + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + v1 = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(120)) + pTab = v1 + (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab = v1 + if pTab == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = uint32(1) + if (*TSrcItem)(unsafe.Pointer(pFrom)).FzAlias != 0 { + (*TTable)(unsafe.Pointer(pTab)).FzName = _sqlite3DbStrDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TSrcItem)(unsafe.Pointer(pFrom)).FzAlias) + } else { + (*TTable)(unsafe.Pointer(pTab)).FzName = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+21211, libc.VaList(bp+8, pFrom)) + } + for (*TSelect)(unsafe.Pointer(pSel)).FpPrior != 0 { + pSel = (*TSelect)(unsafe.Pointer(pSel)).FpPrior + } + _sqlite3ColumnsFromExprList(tls, pParse, (*TSelect)(unsafe.Pointer(pSel)).FpEList, pTab+54, pTab+8) + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(-int32(1)) + (*TTable)(unsafe.Pointer(pTab)).FeTabType = uint8(TABTYP_VIEW) + (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) + /* The usual case - do not allow ROWID on a subquery */ + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TF_Ephemeral) | libc.Int32FromInt32(TF_NoVisibleRowid)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = SQLITE_OK + } + return v2 +} + +// C documentation +// +// /* +// ** Attach an ORDER BY clause to a function call. +// ** +// ** functionname( arguments ORDER BY sortlist ) +// ** \_____________________/ \______/ +// ** pExpr pOrderBy +// ** +// ** The ORDER BY clause is inserted into a new Expr node of type TK_ORDER +// ** and added to the Expr.pLeft field of the parent TK_FUNCTION node. +// */ +func _sqlite3ExprAddFunctionOrderBy(tls *libc.TLS, pParse uintptr, pExpr uintptr, pOrderBy uintptr) { + var db, pOB uintptr + _, _ = db, pOB + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pOrderBy == uintptr(0) { + return + } + if pExpr == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pOrderBy) + return + } + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) == uintptr(0) || (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr == 0 { + /* Ignore ORDER BY on zero-argument aggregates */ + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprListDeleteGeneric), pOrderBy) + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FeFrmType) != int32(TK_FILTER) { + _sqlite3ExprOrderByAggregateError(tls, pParse, pExpr) + _sqlite3ExprListDelete(tls, db, pOrderBy) + return + } + if (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7625, 0) + _sqlite3ExprListDelete(tls, db, pOrderBy) + return + } + pOB = _sqlite3ExprAlloc(tls, db, int32(TK_ORDER), uintptr(0), 0) + if pOB == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pOrderBy) + return + } + *(*uintptr)(unsafe.Pointer(pOB + 32)) = pOrderBy + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = pOB + **(**Tu32)(__ccgo_up(pOB + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FullSize)) +} + +// C documentation +// +// /* +// ** Check that argument nHeight is less than or equal to the maximum +// ** expression depth allowed. If it is not, leave an error message in +// ** pParse. +// */ +func _sqlite3ExprCheckHeight(tls *libc.TLS, pParse uintptr, nHeight int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var mxHeight, rc int32 + _, _ = mxHeight, rc + rc = SQLITE_OK + mxHeight = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 3*4)) + if nHeight > mxHeight { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7861, libc.VaList(bp+8, mxHeight)) + rc = int32(SQLITE_ERROR) + } + return rc +} + +// C documentation +// +// /* +// ** Generate code to extract the value of the iCol-th column of a table. +// */ +func _sqlite3ExprCodeGetColumnOfTable(tls *libc.TLS, v uintptr, pTab uintptr, iTabCur int32, iCol int32, regOut int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var op, savedSelfTab, x int32 + var pCol, pParse, v1 uintptr + _, _, _, _, _, _ = op, pCol, pParse, savedSelfTab, x, v1 + if iCol < 0 || iCol == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iTabCur, regOut) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + op = int32(OP_VColumn) + x = iCol + } else { + v1 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + pCol = v1 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(v1)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + pParse = _sqlite3VdbeParser(tls, v) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_BUSY) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8452, libc.VaList(bp+8, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + } else { + savedSelfTab = (*TParse)(unsafe.Pointer(pParse)).FiSelfTab + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_BUSY)) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = iTabCur + int32(1) + _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab, pCol, regOut) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = savedSelfTab + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(COLFLAG_BUSY)) + } + return + } else { + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + x = _sqlite3TableColumnToIndex(tls, _sqlite3PrimaryKeyIndex(tls, pTab), iCol) + op = int32(OP_Column) + } else { + x = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + op = int32(OP_Column) + } + } + } + _sqlite3VdbeAddOp3(tls, v, op, iTabCur, x, regOut) + _sqlite3ColumnDefault(tls, v, pTab, iCol, regOut) + } +} + +// C documentation +// +// /* +// ** Construct a new expression node for a function with multiple +// ** arguments. +// */ +func _sqlite3ExprFunction(tls *libc.TLS, pParse uintptr, pList uintptr, pToken uintptr, eDistinct int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pNew uintptr + _, _ = db, pNew + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pNew = _sqlite3ExprAlloc(tls, db, int32(TK_FUNCTION), pToken, int32(1)) + if pNew == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pList) /* Avoid memory leak when malloc fails */ + return uintptr(0) + } + *(*int32)(unsafe.Pointer(pNew + 52)) = int32(int64((*TToken)(unsafe.Pointer(pToken)).Fz) - int64((*TParse)(unsafe.Pointer(pParse)).FzTail)) + if pList != 0 && (*TExprList)(unsafe.Pointer(pList)).FnExpr > **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 6*4)) && !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7955, libc.VaList(bp+8, pToken)) + } + *(*uintptr)(unsafe.Pointer(pNew + 32)) = pList + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)) + _sqlite3ExprSetHeightAndFlags(tls, pParse, pNew) + if eDistinct == int32(SF_Distinct) { + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)) + } + return pNew +} + +// C documentation +// +// /* +// ** pColumns and pExpr form a vector assignment which is part of the SET +// ** clause of an UPDATE statement. Like this: +// ** +// ** (a,b,c) = (expr1,expr2,expr3) +// ** Or: (a,b,c) = (SELECT x,y,z FROM ....) +// ** +// ** For each term of the vector assignment, append new entries to the +// ** expression list pList. In the case of a subquery on the RHS, append +// ** TK_SELECT_COLUMN expressions. +// */ +func _sqlite3ExprListAppendVector(tls *libc.TLS, pParse uintptr, pList uintptr, pColumns uintptr, pExpr uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pFirst, pSubExpr uintptr + var i, iFirst, n, v1 int32 + var v3 bool + _, _, _, _, _, _, _, _ = db, i, iFirst, n, pFirst, pSubExpr, v1, v3 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pList != 0 { + v1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v1 = 0 + } + iFirst = v1 + /* pColumns can only be NULL due to an OOM but an OOM will cause an + ** exit prior to this routine being invoked */ + if pColumns == uintptr(0) { + goto vector_append_error + } + if pExpr == uintptr(0) { + goto vector_append_error + } + /* If the RHS is a vector, then we can immediately check to see that + ** the size of the RHS and LHS match. But if the RHS is a SELECT, + ** wildcards ("*") in the result set of the SELECT must be expanded before + ** we can do the size check, so defer the size check until code generation. + */ + if v3 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_SELECT); v3 { + v1 = _sqlite3ExprVectorSize(tls, pExpr) + n = v1 + } + if v3 && (*TIdList)(unsafe.Pointer(pColumns)).FnId != v1 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8125, libc.VaList(bp+8, (*TIdList)(unsafe.Pointer(pColumns)).FnId, n)) + goto vector_append_error + } + i = 0 + for { + if !(i < (*TIdList)(unsafe.Pointer(pColumns)).FnId) { + break + } + pSubExpr = _sqlite3ExprForVectorField(tls, pParse, pExpr, i, (*TIdList)(unsafe.Pointer(pColumns)).FnId) + if pSubExpr == uintptr(0) { + goto _4 + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, pSubExpr) + if pList != 0 { + (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr((*TExprList)(unsafe.Pointer(pList)).FnExpr-int32(1))*32))).FzEName = (*(*TIdList_item)(unsafe.Pointer(pColumns + 8 + uintptr(i)*8))).FzName + (*(*TIdList_item)(unsafe.Pointer(pColumns + 8 + uintptr(i)*8))).FzName = uintptr(0) + } + goto _4 + _4: + ; + i = i + 1 + } + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) && pList != uintptr(0) { + pFirst = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(iFirst)*32))).FpExpr + /* Store the SELECT statement in pRight so it will be deleted when + ** sqlite3ExprListDelete() is called */ + (*TExpr)(unsafe.Pointer(pFirst)).FpRight = pExpr + pExpr = uintptr(0) + /* Remember the size of the LHS in iTable so that we can check that + ** the RHS and LHS sizes match during code generation. */ + (*TExpr)(unsafe.Pointer(pFirst)).FiTable = (*TIdList)(unsafe.Pointer(pColumns)).FnId + } + goto vector_append_error +vector_append_error: + ; + _sqlite3ExprUnmapAndDelete(tls, pParse, pExpr) + _sqlite3IdListDelete(tls, db, pColumns) + return pList +} + +// C documentation +// +// /* +// ** If the expression list pEList contains more than iLimit elements, +// ** leave an error message in pParse. +// */ +func _sqlite3ExprListCheckLength(tls *libc.TLS, pParse uintptr, pEList uintptr, zObject uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var mx int32 + _ = mx + mx = **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 2*4)) + if pEList != 0 && (*TExprList)(unsafe.Pointer(pEList)).FnExpr > mx { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8155, libc.VaList(bp+8, zObject)) + } +} + +// C documentation +// +// /* +// ** Expression list pEList is a list of vector values. This function +// ** converts the contents of pEList to a VALUES(...) Select statement +// ** returning 1 row for each element of the list. For example, the +// ** expression list: +// ** +// ** ( (1,2), (3,4) (5,6) ) +// ** +// ** is translated to the equivalent of: +// ** +// ** VALUES(1,2), (3,4), (5,6) +// ** +// ** Each of the vector values in pEList must contain exactly nElem terms. +// ** If a list element that is not a vector or does not contain nElem terms, +// ** an error message is left in pParse. +// ** +// ** This is used as part of processing IN(...) expressions with a list +// ** of vectors on the RHS. e.g. "... IN ((1,2), (3,4), (5,6))". +// */ +func _sqlite3ExprListToValues(tls *libc.TLS, pParse uintptr, nElem int32, pEList uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ii, nExprElem int32 + var pExpr, pRet, pSel, v2 uintptr + _, _, _, _, _, _ = ii, nExprElem, pExpr, pRet, pSel, v2 + pRet = uintptr(0) + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_VECTOR) { + nExprElem = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + } else { + nExprElem = int32(1) + } + if nExprElem != nElem { + if nExprElem > int32(1) { + v2 = __ccgo_ts + 7909 + } else { + v2 = __ccgo_ts + 1704 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7911, libc.VaList(bp+8, nExprElem, v2, nElem)) + break + } + pSel = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 32)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values), uintptr(0)) + *(*uintptr)(unsafe.Pointer(pExpr + 32)) = uintptr(0) + if pSel != 0 { + if pRet != 0 { + (*TSelect)(unsafe.Pointer(pSel)).Fop = uint8(TK_ALL) + (*TSelect)(unsafe.Pointer(pSel)).FpPrior = pRet + } + pRet = pSel + } + goto _1 + _1: + ; + ii = ii + 1 + } + if pRet != 0 && (*TSelect)(unsafe.Pointer(pRet)).FpPrior != 0 { + **(**Tu32)(__ccgo_up(pRet + 4)) |= uint32(SF_MultiValue) + } + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pEList) + return pRet +} + +// C documentation +// +// /* +// ** Parameter zName points to a nul-terminated buffer containing the name +// ** of a database ("main", "temp" or the name of an attached db). This +// ** function returns the index of the named database in db->aDb[], or +// ** -1 if the named db cannot be found. +// */ +func _sqlite3FindDbName(tls *libc.TLS, db uintptr, zName uintptr) (r int32) { + var i int32 + var pDb uintptr + _, _ = i, pDb + i = -int32(1) /* Database number */ + if zName != 0 { + i = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + for { + if !(i >= 0) { + break + } + if 0 == Xsqlite3_stricmp(tls, (*TDb)(unsafe.Pointer(pDb)).FzDbSName, zName) { + break + } + /* "main" is always an acceptable alias for the primary database + ** even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME. */ + if i == 0 && 0 == Xsqlite3_stricmp(tls, __ccgo_ts+6816, zName) { + break + } + goto _1 + _1: + ; + i = i - 1 + pDb -= 32 + } + } + return i +} + +// C documentation +// +// /* +// ** Locate the in-memory structure that describes a particular database +// ** table given the name of that table and (optionally) the name of the +// ** database containing the table. Return NULL if not found. +// ** +// ** If zDatabase is 0, all databases are searched for the table and the +// ** first matching table is returned. (No checking for duplicate table +// ** names is done.) The search order is TEMP first, then MAIN, then any +// ** auxiliary databases added using the ATTACH command. +// ** +// ** See also sqlite3LocateTable(). +// */ +func _sqlite3FindTable(tls *libc.TLS, db uintptr, zName uintptr, zDatabase uintptr) (r uintptr) { + var i int32 + var p uintptr + _, _ = i, p + p = uintptr(0) + /* All mutexes are required for schema access. Make sure we hold them. */ + if zDatabase != 0 { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if _sqlite3StrICmp(tls, zDatabase, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName) == 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i >= (*Tsqlite3)(unsafe.Pointer(db)).FnDb { + /* No match against the official names. But always match "main" + ** to schema 0 as a legacy fallback. */ + if _sqlite3StrICmp(tls, zDatabase, __ccgo_ts+6816) == 0 { + i = 0 + } else { + return uintptr(0) + } + } + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema+8, zName) + if p == uintptr(0) && Xsqlite3_strnicmp(tls, zName, __ccgo_ts+6756, int32(7)) == 0 { + if i == int32(1) { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6783+7) == 0 || _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6802+7) == 0 || _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6284+7) == 0 { + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema+8, __ccgo_ts+6764) + } + } else { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6802+7) == 0 { + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema+8, __ccgo_ts+6284) + } + } + } + } else { + /* Match against TEMP first */ + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema+8, zName) + if p != 0 { + return p + } + /* The main database is second */ + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema+8, zName) + if p != 0 { + return p + } + /* Attached databases are in order of attachment */ + i = int32(2) + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema+8, zName) + if p != 0 { + break + } + goto _2 + _2: + ; + i = i + 1 + } + if p == uintptr(0) && Xsqlite3_strnicmp(tls, zName, __ccgo_ts+6756, int32(7)) == 0 { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6802+7) == 0 { + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema+8, __ccgo_ts+6284) + } else { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6783+7) == 0 { + p = _sqlite3HashFind(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema+8, __ccgo_ts+6764) + } + } + } + } + return p +} + +// C documentation +// +// /* +// ** This routine is called after all of the trigger actions have been parsed +// ** in order to complete the process of building the trigger. +// */ +func _sqlite3FinishTrigger(tls *libc.TLS, pParse uintptr, pStepList uintptr, pAll uintptr) { + bp := tls.Alloc(160) + defer tls.Free(160) + var db, pHash, pLink, pStep, pTab, pTrig, v, z, zName uintptr + var iDb int32 + var _ /* nameToken at bp+96 */ TToken + var _ /* sFix at bp+0 */ TDbFixer + _, _, _, _, _, _, _, _, _, _ = db, iDb, pHash, pLink, pStep, pTab, pTrig, v, z, zName + pTrig = (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger /* Name of trigger */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Trigger name for error reporting */ + (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger = uintptr(0) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 || !(pTrig != 0) { + goto triggerfinish_cleanup + } + zName = (*TTrigger)(unsafe.Pointer(pTrig)).FzName + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTrigger)(unsafe.Pointer(pTrig)).FpSchema) + (*TTrigger)(unsafe.Pointer(pTrig)).Fstep_list = pStepList + for pStepList != 0 { + (*TTriggerStep)(unsafe.Pointer(pStepList)).FpTrig = pTrig + pStepList = (*TTriggerStep)(unsafe.Pointer(pStepList)).FpNext + } + _sqlite3TokenInit(tls, bp+96, (*TTrigger)(unsafe.Pointer(pTrig)).FzName) + _sqlite3FixInit(tls, bp, pParse, iDb, __ccgo_ts+21842, bp+96) + if _sqlite3FixTriggerStep(tls, bp, (*TTrigger)(unsafe.Pointer(pTrig)).Fstep_list) != 0 || _sqlite3FixExpr(tls, bp, (*TTrigger)(unsafe.Pointer(pTrig)).FpWhen) != 0 { + goto triggerfinish_cleanup + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger = pTrig + pTrig = uintptr(0) + } else { + /* if we are not initializing, + ** build the sqlite_schema entry + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + /* If this is a new CREATE TABLE statement, and if shadow tables + ** are read-only, and the trigger makes a change to a shadow table, + ** then raise an error - do not allow the trigger to be created. */ + if _sqlite3ReadOnlyShadowTables(tls, db) != 0 { + pStep = (*TTrigger)(unsafe.Pointer(pTrig)).Fstep_list + for { + if !(pStep != 0) { + break + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != uintptr(0) && _sqlite3ShadowTableName(tls, db, (*(*TSrcItem)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8))).FzName) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22091, libc.VaList(bp+120, (*TTrigger)(unsafe.Pointer(pTrig)).FzName, (*(*TSrcItem)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8))).FzName)) + goto triggerfinish_cleanup + } + goto _1 + _1: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + } + /* Make an entry in the sqlite_schema table */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto triggerfinish_cleanup + } + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + z = _sqlite3DbStrNDup(tls, db, (*TToken)(unsafe.Pointer(pAll)).Fz, uint64((*TToken)(unsafe.Pointer(pAll)).Fn)) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+22139, libc.VaList(bp+120, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zName, (*TTrigger)(unsafe.Pointer(pTrig)).Ftable, z)) + _sqlite3DbFree(tls, db, z) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+22214, libc.VaList(bp+120, zName)), uint16(0)) + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + pLink = pTrig + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 56 + pTrig = _sqlite3HashInsert(tls, pHash, zName, pTrig) + if pTrig != 0 { + _sqlite3OomFault(tls, db) + } else { + if (*TTrigger)(unsafe.Pointer(pLink)).FpSchema == (*TTrigger)(unsafe.Pointer(pLink)).FpTabSchema { + pTab = _sqlite3HashFind(tls, (*TTrigger)(unsafe.Pointer(pLink)).FpTabSchema+8, (*TTrigger)(unsafe.Pointer(pLink)).Ftable) + (*TTrigger)(unsafe.Pointer(pLink)).FpNext = (*TTable)(unsafe.Pointer(pTab)).FpTrigger + (*TTable)(unsafe.Pointer(pTab)).FpTrigger = pLink + } + } + } + goto triggerfinish_cleanup +triggerfinish_cleanup: + ; + _sqlite3DeleteTrigger(tls, db, pTrig) + _sqlite3DeleteTriggerStep(tls, db, pStepList) +} + +// C documentation +// +// /* +// ** A foreign key constraint requires that the key columns in the parent +// ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. +// ** Given that pParent is the parent table for foreign key constraint pFKey, +// ** search the schema for a unique index on the parent key columns. +// ** +// ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY +// ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx +// ** is set to point to the unique index. +// ** +// ** If the parent key consists of a single column (the foreign key constraint +// ** is not a composite foreign key), output variable *paiCol is set to NULL. +// ** Otherwise, it is set to point to an allocated array of size N, where +// ** N is the number of columns in the parent key. The first element of the +// ** array is the index of the child table column that is mapped by the FK +// ** constraint to the parent table column stored in the left-most column +// ** of index *ppIdx. The second element of the array is the index of the +// ** child table column that corresponds to the second left-most column of +// ** *ppIdx, and so on. +// ** +// ** If the required index cannot be found, either because: +// ** +// ** 1) The named parent key columns do not exist, or +// ** +// ** 2) The named parent key columns do exist, but are not subject to a +// ** UNIQUE or PRIMARY KEY constraint, or +// ** +// ** 3) No parent key columns were provided explicitly as part of the +// ** foreign key definition, and the parent table does not have a +// ** PRIMARY KEY, or +// ** +// ** 4) No parent key columns were provided explicitly as part of the +// ** foreign key definition, and the PRIMARY KEY of the parent table +// ** consists of a different number of columns to the child key in +// ** the child table. +// ** +// ** then non-zero is returned, and a "foreign key mismatch" error loaded +// ** into pParse. If an OOM error occurs, non-zero is returned and the +// ** pParse->db->mallocFailed flag is set. +// */ +func _sqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey uintptr, ppIdx uintptr, paiCol uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aiCol, pIdx, zDfltColl, zIdxCol, zKey uintptr + var i, i1, j, nCol int32 + var iCol Ti16 + _, _, _, _, _, _, _, _, _, _ = aiCol, i, i1, iCol, j, nCol, pIdx, zDfltColl, zIdxCol, zKey + pIdx = uintptr(0) /* Value to return via *ppIdx */ + aiCol = uintptr(0) /* Value to return via *paiCol */ + nCol = (*TFKey)(unsafe.Pointer(pFKey)).FnCol /* Number of columns in parent key */ + zKey = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FzCol /* Name of left-most parent key column */ + /* The caller is responsible for zeroing output parameters. */ + /* If this is a non-composite (single column) foreign key, check if it + ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx + ** and *paiCol set to zero and return early. + ** + ** Otherwise, for a composite foreign key (more than one column), allocate + ** space for the aiCol array (returned via output parameter *paiCol). + ** Non-composite foreign keys do not require the aiCol array. + */ + if nCol == int32(1) { + /* The FK maps to the IPK if any of the following are true: + ** + ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly + ** mapped to the primary key of table pParent, or + ** 2) The FK is explicitly mapped to a column declared as INTEGER + ** PRIMARY KEY. + */ + if int32((*TTable)(unsafe.Pointer(pParent)).FiPKey) >= 0 { + if !(zKey != 0) { + return 0 + } + if !(_sqlite3StrICmp(tls, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pParent)).FaCol + uintptr((*TTable)(unsafe.Pointer(pParent)).FiPKey)*16))).FzCnName, zKey) != 0) { + return 0 + } + } + } else { + if paiCol != 0 { + aiCol = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(libc.Uint64FromInt32(nCol)*uint64(4))) + if !(aiCol != 0) { + return int32(1) + } + **(**uintptr)(__ccgo_up(paiCol)) = aiCol + } + } + pIdx = (*TTable)(unsafe.Pointer(pParent)).FpIndex + for { + if !(pIdx != 0) { + break + } + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) == nCol && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != OE_None && (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) { + /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number + ** of columns. If each indexed column corresponds to a foreign key + ** column of pFKey, then this index is a winner. */ + if zKey == uintptr(0) { + /* If zKey is NULL, then this foreign key is implicitly mapped to + ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be + ** identified by the test. */ + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + if aiCol != 0 { + i = 0 + for { + if !(i < nCol) { + break + } + **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) = (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FiFrom + goto _2 + _2: + ; + i = i + 1 + } + } + break + } + } else { + i1 = 0 + for { + if !(i1 < nCol) { + break + } + iCol = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i1)*2)) /* Name of indexed column */ + if int32(iCol) < 0 { + break + } /* No foreign keys against expression indexes */ + /* If the index uses a collation sequence that is different from + ** the default collation sequence for the column, this index is + ** unusable. Bail out early in this case. */ + zDfltColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pParent)).FaCol+uintptr(iCol)*16) + if !(zDfltColl != 0) { + zDfltColl = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + if _sqlite3StrICmp(tls, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i1)*8)), zDfltColl) != 0 { + break + } + zIdxCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pParent)).FaCol + uintptr(iCol)*16))).FzCnName + j = 0 + for { + if !(j < nCol) { + break + } + if _sqlite3StrICmp(tls, (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(j)*16))).FzCol, zIdxCol) == 0 { + if aiCol != 0 { + **(**int32)(__ccgo_up(aiCol + uintptr(i1)*4)) = (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(j)*16))).FiFrom + } + break + } + goto _4 + _4: + ; + j = j + 1 + } + if j == nCol { + break + } + goto _3 + _3: + ; + i1 = i1 + 1 + } + if i1 == nCol { + break + } /* pIdx is usable */ + } + } + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if !(pIdx != 0) { + if !(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x1>>0)) != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17300, libc.VaList(bp+8, (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName, (*TFKey)(unsafe.Pointer(pFKey)).FzTo)) + } + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, aiCol) + return int32(1) + } + **(**uintptr)(__ccgo_up(ppIdx)) = pIdx + return 0 +} + +func _sqlite3Fts5AuxInit(tls *libc.TLS, pApi uintptr) (r int32) { + var aBuiltin [4]struct { + FzFunc uintptr + FpUserData uintptr + FxFunc Tfts5_extension_function + FxDestroy uintptr + } + var i, rc int32 + _, _, _ = aBuiltin, i, rc + aBuiltin = [4]struct { + FzFunc uintptr + FpUserData uintptr + FxFunc Tfts5_extension_function + FxDestroy uintptr + }{ + 0: { + FzFunc: __ccgo_ts + 37299, + FxFunc: __ccgo_fp(_fts5SnippetFunction), + }, + 1: { + FzFunc: __ccgo_ts + 37307, + FxFunc: __ccgo_fp(_fts5HighlightFunction), + }, + 2: { + FzFunc: __ccgo_ts + 37317, + FxFunc: __ccgo_fp(_fts5Bm25Function), + }, + 3: { + FzFunc: __ccgo_ts + 37322, + FxFunc: __ccgo_fp(_fts5GetLocaleFunction), + }, + } + rc = SQLITE_OK /* To iterate through builtin functions */ + i = 0 + for { + if !(rc == SQLITE_OK && i < libc.Int32FromUint64(libc.Uint64FromInt64(128)/libc.Uint64FromInt64(32))) { + break + } + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, Tfts5_extension_function, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfts5_api)(unsafe.Pointer(pApi)).FxCreateFunction})))(tls, pApi, aBuiltin[i].FzFunc, aBuiltin[i].FpUserData, aBuiltin[i].FxFunc, aBuiltin[i].FxDestroy) + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** + */ + +/* #include "fts5Int.h" */ + +// C documentation +// +// /* +// ** Call sqlite3_declare_vtab() based on the contents of the configuration +// ** object passed as the only argument. Return SQLITE_OK if successful, or +// ** an SQLite error code if an error occurs. +// */ +func _sqlite3Fts5ConfigDeclareVtab(tls *libc.TLS, pConfig uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var zSep, zSql, v2 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _ = i, zSep, zSql, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + zSql = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38236, 0) + i = 0 + for { + if !(zSql != 0 && i < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if i == 0 { + v2 = __ccgo_ts + 1704 + } else { + v2 = __ccgo_ts + 16214 + } + zSep = v2 + zSql = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38252, libc.VaList(bp+16, zSql, zSep, **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(i)*8)))) + goto _1 + _1: + ; + i = i + 1 + } + zSql = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38259, libc.VaList(bp+16, zSql, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, __ccgo_ts+37899)) + if zSql != 0 { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_declare_vtab(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql) + Xsqlite3_free(tls, zSql) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Load the contents of the %_config table into memory. +// */ +func _sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iVersion int32 + var pVal, zK, zSelect, zSql uintptr + var _ /* bDummy at bp+12 */ int32 + var _ /* p at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _, _, _, _ = iVersion, pVal, zK, zSelect, zSql + zSelect = __ccgo_ts + 38367 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = SQLITE_OK + iVersion = 0 + /* Set default values */ + (*TFts5Config)(unsafe.Pointer(pConfig)).Fpgsz = int32(FTS5_DEFAULT_PAGE_SIZE) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = int32(FTS5_DEFAULT_AUTOMERGE) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = int32(FTS5_DEFAULT_USERMERGE) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = int32(FTS5_DEFAULT_CRISISMERGE) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnHashSize = libc.Int32FromInt32(1024) * libc.Int32FromInt32(1024) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnDeleteMerge = int32(FTS5_DEFAULT_DELETE_AUTOMERGE) + zSql = _sqlite3Fts5Mprintf(tls, bp+8, zSelect, libc.VaList(bp+24, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + if zSql != 0 { + **(**int32)(__ccgo_up(bp + 8)) = Xsqlite3_prepare_v2(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -int32(1), bp, uintptr(0)) + Xsqlite3_free(tls, zSql) + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zK = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + pVal = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + if 0 == Xsqlite3_stricmp(tls, zK, __ccgo_ts+38399) { + iVersion = Xsqlite3_value_int(tls, pVal) + } else { + **(**int32)(__ccgo_up(bp + 12)) = 0 + _sqlite3Fts5ConfigSetValue(tls, pConfig, zK, pVal, bp+12) + } + } + **(**int32)(__ccgo_up(bp + 8)) = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && iVersion != int32(FTS5_CURRENT_VERSION) && iVersion != int32(FTS5_CURRENT_VERSION_SECUREDELETE) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_ERROR) + _sqlite3Fts5ConfigErrmsg(tls, pConfig, __ccgo_ts+38407, libc.VaList(bp+24, iVersion, int32(FTS5_CURRENT_VERSION), int32(FTS5_CURRENT_VERSION_SECUREDELETE))) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FiVersion = iVersion + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + (*TFts5Config)(unsafe.Pointer(pConfig)).FiCookie = iCookie + } + return **(**int32)(__ccgo_up(bp + 8)) +} + +func _sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVal uintptr, pbBadkey uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bVal, bVal1, nAutomerge, nCrisisMerge, nHashSize, nUsermerge, nVal, pgsz, rc, v1 int32 + var zIn uintptr + var _ /* zRank at bp+0 */ uintptr + var _ /* zRankArgs at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = bVal, bVal1, nAutomerge, nCrisisMerge, nHashSize, nUsermerge, nVal, pgsz, rc, zIn, v1 + rc = SQLITE_OK + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38285) { + pgsz = 0 + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + pgsz = Xsqlite3_value_int(tls, pVal) + } + if pgsz < int32(32) || pgsz > libc.Int32FromInt32(64)*libc.Int32FromInt32(1024) { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).Fpgsz = pgsz + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38290) { + nHashSize = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nHashSize = Xsqlite3_value_int(tls, pVal) + } + if nHashSize <= 0 { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FnHashSize = nHashSize + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38299) { + nAutomerge = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nAutomerge = Xsqlite3_value_int(tls, pVal) + } + if nAutomerge < 0 || nAutomerge > int32(64) { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + if nAutomerge == int32(1) { + nAutomerge = int32(FTS5_DEFAULT_AUTOMERGE) + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = nAutomerge + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38309) { + nUsermerge = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nUsermerge = Xsqlite3_value_int(tls, pVal) + } + if nUsermerge < int32(2) || nUsermerge > int32(16) { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = nUsermerge + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38319) { + nCrisisMerge = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nCrisisMerge = Xsqlite3_value_int(tls, pVal) + } + if nCrisisMerge < 0 { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + if nCrisisMerge <= int32(1) { + nCrisisMerge = int32(FTS5_DEFAULT_CRISISMERGE) + } + if nCrisisMerge >= int32(FTS5_MAX_SEGMENT) { + nCrisisMerge = libc.Int32FromInt32(FTS5_MAX_SEGMENT) - libc.Int32FromInt32(1) + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = nCrisisMerge + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38331) { + nVal = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + nVal = Xsqlite3_value_int(tls, pVal) + } else { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } + if nVal < 0 { + nVal = int32(FTS5_DEFAULT_DELETE_AUTOMERGE) + } + if nVal > int32(100) { + nVal = 0 + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FnDeleteMerge = nVal + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+37899) { + zIn = Xsqlite3_value_text(tls, pVal) + rc = _sqlite3Fts5ConfigParseRank(tls, zIn, bp, bp+8) + if rc == SQLITE_OK { + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzRankArgs) + (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank = **(**uintptr)(__ccgo_up(bp)) + (*TFts5Config)(unsafe.Pointer(pConfig)).FzRankArgs = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + if rc == int32(SQLITE_ERROR) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38343) { + bVal = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + bVal = Xsqlite3_value_int(tls, pVal) + } + if bVal < 0 { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + if bVal != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FbSecureDelete = v1 + } + } else { + if 0 == Xsqlite3_stricmp(tls, zKey, __ccgo_ts+38357) { + bVal1 = -int32(1) + if int32(SQLITE_INTEGER) == Xsqlite3_value_numeric_type(tls, pVal) { + bVal1 = Xsqlite3_value_int(tls, pVal) + } + if bVal1 < 0 { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } else { + if bVal1 != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken = v1 + } + } else { + **(**int32)(__ccgo_up(pbBadkey)) = int32(1) + } + } + } + } + } + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Run internal checks to ensure that the FTS index (a) is internally +// ** consistent and (b) contains entries for which the XOR of the checksums +// ** as calculated by sqlite3Fts5IndexEntryCksum() is cksum. +// ** +// ** Return SQLITE_CORRUPT if any of the internal checks fail, or if the +// ** checksum does not match. Return SQLITE_OK if all checks pass without +// ** error, or some other SQLite error code if another error (e.g. OOM) +// ** occurs. +// */ +func _sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum Tu64, bUseCksum int32) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var cksum2 Tu64 + var eDetail, flags, iCol, iLvl, iSeg, iTokOff int32 + var iRowid Ti64 + var pSeg, pStruct, z uintptr + var _ /* iOff at bp+40 */ int32 + var _ /* iPos at bp+32 */ Ti64 + var _ /* n at bp+24 */ int32 + var _ /* pIter at bp+16 */ uintptr + var _ /* poslist at bp+0 */ TFts5Buffer + _, _, _, _, _, _, _, _, _, _, _ = cksum2, eDetail, flags, iCol, iLvl, iRowid, iSeg, iTokOff, pSeg, pStruct, z + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail + cksum2 = uint64(0) /* Checksum based on contents of indexes */ + **(**TFts5Buffer)(__ccgo_up(bp)) = TFts5Buffer{} + flags = int32(FTS5INDEX_QUERY_NOOUTPUT) + /* Load the FTS index structure */ + pStruct = _fts5StructureRead(tls, p) + if pStruct == uintptr(0) { + return _fts5IndexReturn(tls, p) + } + /* Check that the internal nodes of each segment match the leaves */ + iLvl = 0 + for { + if !(iLvl < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + iSeg = 0 + for { + if !(iSeg < (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg) { + break + } + pSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr(iSeg)*56 + _fts5IndexIntegrityCheckSegment(tls, p, pSeg) + goto _2 + _2: + ; + iSeg = iSeg + 1 + } + goto _1 + _1: + ; + iLvl = iLvl + 1 + } + /* The cksum argument passed to this function is a checksum calculated + ** based on all expected entries in the FTS index (including prefix index + ** entries). This block checks that a checksum calculated based on the + ** actual contents of FTS index is identical. + ** + ** Two versions of the same checksum are calculated. The first (stack + ** variable cksum2) based on entries extracted from the full-text index + ** while doing a linear scan of each individual index in turn. + ** + ** As each term visited by the linear scans, a separate query for the + ** same term is performed. cksum3 is calculated based on the entries + ** extracted by these queries. + */ + _fts5MultiIterNew(tls, p, pStruct, flags, uintptr(0), uintptr(0), 0, -int32(1), 0, bp+16) + for { + if !(_fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp + 16))) == 0) { + break + } /* Size of term in bytes */ + **(**Ti64)(__ccgo_up(bp + 32)) = 0 /* Position read from poslist */ + **(**int32)(__ccgo_up(bp + 40)) = 0 /* Offset within poslist */ + iRowid = _fts5MultiIterRowid(tls, **(**uintptr)(__ccgo_up(bp + 16))) + z = _fts5MultiIterTerm(tls, **(**uintptr)(__ccgo_up(bp + 16)), bp+24) + /* If this is a new term, query for it. Update cksum3 with the results. */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + if eDetail == int32(FTS5_DETAIL_NONE) { + if 0 == _fts5MultiIterIsEmpty(tls, p, **(**uintptr)(__ccgo_up(bp + 16))) { + cksum2 = cksum2 ^ _sqlite3Fts5IndexEntryCksum(tls, iRowid, 0, 0, -int32(1), z, **(**int32)(__ccgo_up(bp + 24))) + } + } else { + (**(**TFts5Buffer)(__ccgo_up(bp))).Fn = 0 + _fts5SegiterPoslist(tls, p, **(**uintptr)(__ccgo_up(bp + 16))+104+uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FaFirst + 1*4))).FiFirst)*128, uintptr(0), bp) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, uint32(4), __ccgo_ts+39603) + for 0 == _sqlite3Fts5PoslistNext64(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn, bp+40, bp+32) { + iCol = int32(**(**Ti64)(__ccgo_up(bp + 32)) >> libc.Int32FromInt32(32) & libc.Int64FromInt32(0x7FFFFFFF)) + iTokOff = int32(**(**Ti64)(__ccgo_up(bp + 32)) & libc.Int64FromInt32(0x7FFFFFFF)) + cksum2 = cksum2 ^ _sqlite3Fts5IndexEntryCksum(tls, iRowid, iCol, iTokOff, -int32(1), z, **(**int32)(__ccgo_up(bp + 24))) + } + } + goto _3 + _3: + ; + _fts5MultiIterNext(tls, p, **(**uintptr)(__ccgo_up(bp + 16)), 0, 0) + } + _fts5MultiIterFree(tls, **(**uintptr)(__ccgo_up(bp + 16))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bUseCksum != 0 && cksum != cksum2 { + (*TFts5Index)(unsafe.Pointer(p)).Frc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< int32(1) { + pRet = _fts5ParsePhraseToAnd(tls, pParse, pNear) + } else { + if eType == int32(FTS5_NOT) { + nChild = int32(2) + } else { + if eType == int32(FTS5_AND) || eType == int32(FTS5_OR) { + nChild = int32(2) + if (*TFts5ExprNode)(unsafe.Pointer(pLeft)).FeType == eType { + nChild = nChild + ((*TFts5ExprNode)(unsafe.Pointer(pLeft)).FnChild - int32(1)) + } + if (*TFts5ExprNode)(unsafe.Pointer(pRight)).FeType == eType { + nChild = nChild + ((*TFts5ExprNode)(unsafe.Pointer(pRight)).FnChild - int32(1)) + } + } + } + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+48) + libc.Uint64FromInt32(nChild)*libc.Uint64FromInt64(8)) + pRet = _sqlite3Fts5MallocZero(tls, pParse+16, nByte) + if pRet != 0 { + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FeType = eType + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FpNear = pNear + _fts5ExprAssignXNext(tls, pRet) + if eType == int32(FTS5_STRING) { + iPhrase = 0 + for { + if !(iPhrase < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + (*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(iPhrase)*8)))).FpNode = pRet + if (*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(iPhrase)*8)))).FnTerm == 0 { + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FxNext = uintptr(0) + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FeType = FTS5_EOF + } + goto _1 + _1: + ; + iPhrase = iPhrase + 1 + } + if (*TFts5Config)(unsafe.Pointer((*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail != FTS5_DETAIL_FULL { + pPhrase = *(*uintptr)(unsafe.Pointer(pNear + 24)) + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase != int32(1) || (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > int32(1) || (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0 && (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32))).FbFirst != 0 { + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == int32(1) { + v2 = __ccgo_ts + 38623 + } else { + v2 = __ccgo_ts + 38536 + } + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38630, libc.VaList(bp+8, v2)) + _sqlite3Fts5ParseNodeFree(tls, pRet) + pRet = uintptr(0) + pNear = uintptr(0) + } + } + } else { + _fts5ExprAddChildren(tls, pRet, pLeft) + _fts5ExprAddChildren(tls, pRet, pRight) + v2 = libc.UintptrFromInt32(0) + pRight = v2 + pLeft = v2 + if (*TFts5ExprNode)(unsafe.Pointer(pRet)).FiHeight > int32(SQLITE_FTS5_MAX_EXPR_DEPTH) { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38680, libc.VaList(bp+8, int32(SQLITE_FTS5_MAX_EXPR_DEPTH))) + _sqlite3Fts5ParseNodeFree(tls, pRet) + pRet = uintptr(0) + } + } + } + } + } + if pRet == uintptr(0) { + _sqlite3Fts5ParseNodeFree(tls, pLeft) + _sqlite3Fts5ParseNodeFree(tls, pRight) + _sqlite3Fts5ParseNearsetFree(tls, pNear) + } + return pRet +} + +// C documentation +// +// /* +// ** Check that the contents of the FTS index match that of the %_content +// ** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return +// ** some other SQLite error code if an error occurs while attempting to +// ** determine this. +// */ +func _sqlite3Fts5StorageIntegrity(tls *libc.TLS, p uintptr, iArg int32) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aColSize, aTotalSize, pConfig, pVal uintptr + var bUseCksum, i, i1, iCol, rc, rc2 int32 + var _ /* ctx at bp+0 */ TFts5IntegrityCtx + var _ /* nLoc at bp+72 */ int32 + var _ /* nRow at bp+80 */ Ti64 + var _ /* nRow at bp+88 */ Ti64 + var _ /* nText at bp+56 */ int32 + var _ /* pLoc at bp+64 */ uintptr + var _ /* pScan at bp+40 */ uintptr + var _ /* pText at bp+48 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aColSize, aTotalSize, bUseCksum, i, i1, iCol, pConfig, pVal, rc, rc2 + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + rc = SQLITE_OK + libc.Xmemset(tls, bp, 0, uint64(40)) + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FpConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + aTotalSize = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*(libc.Uint64FromInt64(4)+libc.Uint64FromInt64(8)))) + if !(aTotalSize != 0) { + return int32(SQLITE_NOMEM) + } + aColSize = aTotalSize + uintptr((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*8 + libc.Xmemset(tls, aTotalSize, 0, uint64(8)*libc.Uint64FromInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)) + bUseCksum = libc.BoolInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL || (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_EXTERNAL) && iArg != 0) + if bUseCksum != 0 { + /* Generate the expected index checksum based on the contents of the + ** %_content table. This block stores the checksum in ctx.cksum. */ + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_SCAN), bp+40, uintptr(0)) + if rc == SQLITE_OK { + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 40))) { + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FiRowid = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp + 40)), 0) + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FszCol = 0 + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + rc = _sqlite3Fts5StorageDocsize(tls, p, (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FiRowid, aColSize) + } + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + rc = _sqlite3Fts5TermsetNew(tls, bp+24) + } + i = 0 + for { + if !(rc == SQLITE_OK && i < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i)))) == 0 { + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 56)) = 0 + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 72)) = 0 + pVal = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp + 40)), i+int32(1)) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_EXTERNAL) && _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + rc = _sqlite3Fts5DecodeLocaleValue(tls, pVal, bp+48, bp+56, bp+64, bp+72) + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL && (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 { + iCol = i + int32(1) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + **(**uintptr)(__ccgo_up(bp + 64)) = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 40)), iCol) + **(**int32)(__ccgo_up(bp + 72)) = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp + 40)), iCol) + } + **(**uintptr)(__ccgo_up(bp + 48)) = Xsqlite3_value_text(tls, pVal) + **(**int32)(__ccgo_up(bp + 56)) = Xsqlite3_value_bytes(tls, pVal) + } + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FiCol = i + (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FszCol = 0 + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_COLUMNS) { + rc = _sqlite3Fts5TermsetNew(tls, bp+24) + } + if rc == SQLITE_OK { + _sqlite3Fts5SetLocale(tls, pConfig, **(**uintptr)(__ccgo_up(bp + 64)), **(**int32)(__ccgo_up(bp + 72))) + rc = _sqlite3Fts5Tokenize(tls, pConfig, int32(FTS5_TOKENIZE_DOCUMENT), **(**uintptr)(__ccgo_up(bp + 48)), **(**int32)(__ccgo_up(bp + 56)), bp, __ccgo_fp(_fts5StorageIntegrityCallback)) + _sqlite3Fts5ClearLocale(tls, pConfig) + } + /* If this is not a columnsize=0 database, check that the number + ** of tokens in the value matches the aColSize[] value read from + ** the %_docsize table. */ + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 && (**(**TFts5IntegrityCtx)(__ccgo_up(bp))).FszCol != **(**int32)(__ccgo_up(aColSize + uintptr(i)*4)) { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< */ + +// C documentation +// +// /* +// ** Compute the column names for a SELECT statement. +// ** +// ** The only guarantee that SQLite makes about column names is that if the +// ** column has an AS clause assigning it a name, that will be the name used. +// ** That is the only documented guarantee. However, countless applications +// ** developed over the years have made baseless assumptions about column names +// ** and will break if those assumptions changes. Hence, use extreme caution +// ** when modifying this routine to avoid breaking legacy. +// ** +// ** See Also: sqlite3ColumnsFromExprList() +// ** +// ** The PRAGMA short_column_names and PRAGMA full_column_names settings are +// ** deprecated. The default setting is short=ON, full=OFF. 99.9% of all +// ** applications should operate this way. Nevertheless, we need to support the +// ** other modes for legacy: +// ** +// ** short=OFF, full=OFF: Column name is the text of the expression has it +// ** originally appears in the SELECT statement. In +// ** other words, the zSpan of the result expression. +// ** +// ** short=ON, full=OFF: (This is the default setting). If the result +// ** refers directly to a table column, then the +// ** result column name is just the table column +// ** name: COLUMN. Otherwise use zSpan. +// ** +// ** full=ON, short=ANY: If the result refers directly to a table column, +// ** then the result column name with the table name +// ** prefix, ex: TABLE.COLUMN. Otherwise use zSpan. +// */ +func _sqlite3GenerateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pEList, pTab, pTabList, v, z, zCol, zName, zName1, v2 uintptr + var fullName, i, iCol, srcName int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, fullName, i, iCol, p, pEList, pTab, pTabList, srcName, v, z, zCol, zName, zName1, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* COLUMN or TABLE.COLUMN if no AS clause and is direct */ + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x20>>5)) != 0 { + return + } + /* Column names are determined by the left-most term of a compound select */ + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + pTabList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 5, 0x20) + fullName = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_FullColNames) != uint64(0)) + srcName = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ShortColNames) != uint64(0) || fullName != 0) + _sqlite3VdbeSetNumCols(tls, v, (*TExprList)(unsafe.Pointer(pEList)).FnExpr) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + p = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr + /* Agg processing has not run yet */ + /* Covering idx not yet coded */ + if (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME { + /* An AS clause always takes first priority */ + zName = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName, uintptr(-libc.Int32FromInt32(1))) + } else { + if srcName != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_COLUMN) { + iCol = int32((*TExpr)(unsafe.Pointer(p)).FiColumn) + pTab = *(*uintptr)(unsafe.Pointer(p + 64)) + if iCol < 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + if iCol < 0 { + zCol = __ccgo_ts + 17963 + } else { + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + } + if fullName != 0 { + zName1 = uintptr(0) + zName1 = _sqlite3MPrintf(tls, db, __ccgo_ts+13632, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, zCol)) + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName1, __ccgo_fp(_sqlite3RowSetClear)) + } else { + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zCol, uintptr(-libc.Int32FromInt32(1))) + } + } else { + z = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName + if z == uintptr(0) { + v2 = _sqlite3MPrintf(tls, db, __ccgo_ts+20632, libc.VaList(bp+8, i+int32(1))) + } else { + v2 = _sqlite3DbStrDup(tls, db, z) + } + z = v2 + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, z, __ccgo_fp(_sqlite3RowSetClear)) + } + } + goto _1 + _1: + ; + i = i + 1 + } + _generateColumnTypes(tls, pParse, pTabList, pEList) +} + +// C documentation +// +// /* +// ** Generate code to do constraint checks prior to an INSERT or an UPDATE +// ** on table pTab. +// ** +// ** The regNewData parameter is the first register in a range that contains +// ** the data to be inserted or the data after the update. There will be +// ** pTab->nCol+1 registers in this range. The first register (the one +// ** that regNewData points to) will contain the new rowid, or NULL in the +// ** case of a WITHOUT ROWID table. The second register in the range will +// ** contain the content of the first table column. The third register will +// ** contain the content of the second table column. And so forth. +// ** +// ** The regOldData parameter is similar to regNewData except that it contains +// ** the data prior to an UPDATE rather than afterwards. regOldData is zero +// ** for an INSERT. This routine can distinguish between UPDATE and INSERT by +// ** checking regOldData for zero. +// ** +// ** For an UPDATE, the pkChng boolean is true if the true primary key (the +// ** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table) +// ** might be modified by the UPDATE. If pkChng is false, then the key of +// ** the iDataCur content table is guaranteed to be unchanged by the UPDATE. +// ** +// ** For an INSERT, the pkChng boolean indicates whether or not the rowid +// ** was explicitly specified as part of the INSERT statement. If pkChng +// ** is zero, it means that the either rowid is computed automatically or +// ** that the table is a WITHOUT ROWID table and has no rowid. On an INSERT, +// ** pkChng will only be true if the INSERT statement provides an integer +// ** value for either the rowid column or its INTEGER PRIMARY KEY alias. +// ** +// ** The code generated by this routine will store new index entries into +// ** registers identified by aRegIdx[]. No index entry is created for +// ** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is +// ** the same as the order of indices on the linked list of indices +// ** at pTab->pIndex. +// ** +// ** (2019-05-07) The generated code also creates a new record for the +// ** main table, if pTab is a rowid table, and stores that record in the +// ** register identified by aRegIdx[nIdx] - in other words in the first +// ** entry of aRegIdx[] past the last index. It is important that the +// ** record be generated during constraint checks to avoid affinity changes +// ** to the register content that occur after constraint checks but before +// ** the new record is inserted. +// ** +// ** The caller must have already opened writeable cursors on the main +// ** table and all applicable indices (that is to say, all indices for which +// ** aRegIdx[] is not zero). iDataCur is the cursor for the main table when +// ** inserting or updating a rowid table, or the cursor for the PRIMARY KEY +// ** index when operating on a WITHOUT ROWID table. iIdxCur is the cursor +// ** for the first index in the pTab->pIndex list. Cursors for other indices +// ** are at iIdxCur+N for the N-th element of the pTab->pIndex list. +// ** +// ** This routine also generates code to check constraints. NOT NULL, +// ** CHECK, and UNIQUE constraints are all checked. If a constraint fails, +// ** then the appropriate action is performed. There are five possible +// ** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE. +// ** +// ** Constraint type Action What Happens +// ** --------------- ---------- ---------------------------------------- +// ** any ROLLBACK The current transaction is rolled back and +// ** sqlite3_step() returns immediately with a +// ** return code of SQLITE_CONSTRAINT. +// ** +// ** any ABORT Back out changes from the current command +// ** only (do not do a complete rollback) then +// ** cause sqlite3_step() to return immediately +// ** with SQLITE_CONSTRAINT. +// ** +// ** any FAIL Sqlite3_step() returns immediately with a +// ** return code of SQLITE_CONSTRAINT. The +// ** transaction is not rolled back and any +// ** changes to prior rows are retained. +// ** +// ** any IGNORE The attempt in insert or update the current +// ** row is skipped, without throwing an error. +// ** Processing continues with the next row. +// ** (There is an immediate jump to ignoreDest.) +// ** +// ** NOT NULL REPLACE The NULL value is replace by the default +// ** value for that column. If the default value +// ** is NULL, the action is the same as ABORT. +// ** +// ** UNIQUE REPLACE The other row that conflicts with the row +// ** being inserted is removed. +// ** +// ** CHECK REPLACE Illegal. The results in an exception. +// ** +// ** Which action to take is determined by the overrideError parameter. +// ** Or if overrideError==OE_Default, then the pParse->onError parameter +// ** is used. Or if pParse->onError==OE_Default then the onError value +// ** for the constraint is used. +// */ +func _sqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintptr, aRegIdx uintptr, iDataCur int32, iIdxCur int32, regNewData int32, regOldData int32, pkChng Tu8, overrideError Tu8, ignoreDest int32, pbMayReplace uintptr, aiChng uintptr, pUpsert uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addr1, addrBypass, addrConflictCk, addrJump, addrRecheck, addrRowidOk, addrUniqueOk, allOk, b2ndPass, i, iField, iReg, iThisCur, ipkBottom, ipkTop, isGenerated, jj, lblRecheckOk, nCol, nConflictCk, nGenerated, nIdx, nPkField, nReplaceTrig, nSeenReplace, onError, op, p2, regCmp, regIdx, regR, regRec, regTrigCnt, seenReplace, upsertIpkDelay, upsertIpkReturn, x, x1, v2 int32 + var bAffinityDone, isUpdate Tu8 + var bUsed, db, p4, pCheck, pCol, pCopy, pExpr, pIdx, pPk, pTerm, pTrigger, pUpsertClause, v, zMsg, zName, zP4, v8 uintptr + var nByte Tu64 + var _ /* ix at bp+0 */ int32 + var _ /* sIdxIter at bp+8 */ TIndexIterator + var _ /* x at bp+32 */ TVdbeOp + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, addrBypass, addrConflictCk, addrJump, addrRecheck, addrRowidOk, addrUniqueOk, allOk, b2ndPass, bAffinityDone, bUsed, db, i, iField, iReg, iThisCur, ipkBottom, ipkTop, isGenerated, isUpdate, jj, lblRecheckOk, nByte, nCol, nConflictCk, nGenerated, nIdx, nPkField, nReplaceTrig, nSeenReplace, onError, op, p2, p4, pCheck, pCol, pCopy, pExpr, pIdx, pPk, pTerm, pTrigger, pUpsertClause, regCmp, regIdx, regR, regRec, regTrigCnt, seenReplace, upsertIpkDelay, upsertIpkReturn, v, x, x1, zMsg, zName, zP4, v2, v8 /* Pointer to one of the indices */ + pPk = uintptr(0) /* Conflict resolution strategy */ + seenReplace = 0 /* Number of fields in PRIMARY KEY. 1 for ROWID tables */ + pUpsertClause = uintptr(0) /* True if this is an UPDATE operation */ + bAffinityDone = uint8(0) /* True if the OP_Affinity operation has been run */ + upsertIpkReturn = 0 /* Address of Goto at end of IPK uniqueness check */ + upsertIpkDelay = 0 /* Address of Goto to bypass initial IPK check */ + ipkTop = 0 /* Top of the IPK uniqueness check */ + ipkBottom = 0 /* Register used to count replace trigger invocations */ + addrRecheck = 0 /* Jump here to recheck all uniqueness constraints */ + lblRecheckOk = 0 /* List of DELETE triggers on the table pTab */ + nReplaceTrig = 0 /* Index iterator */ + isUpdate = libc.BoolUint8(regOldData != 0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* This table is not a VIEW */ + nCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for + ** normal rowid tables. nPkField is the number of key fields in the + ** pPk index or 1 for a rowid table. In other words, nPkField is the + ** number of fields in the true primary key of the table. */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + pPk = uintptr(0) + nPkField = int32(1) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPkField = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } + /* Record that this module has started */ + /* Test all NOT NULL constraints. + */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasNotNull) != 0 { + b2ndPass = 0 /* True if currently running 2nd pass */ + nSeenReplace = 0 /* Number of ON CONFLICT REPLACE operations */ + nGenerated = 0 /* Number of generated columns with NOT NULL */ + for int32(1) != 0 { /* Make 2 passes over columns. Exit loop via "break" */ + i = 0 + for { + if !(i < nCol) { + break + } /* Register holding column value */ + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 /* non-zero if column is generated */ + onError = int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8)) & 0xf >> 0)) + if onError == OE_None { + goto _1 + } /* No NOT NULL on this column */ + if i == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + goto _1 /* ROWID is never NULL */ + } + isGenerated = libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags) & int32(COLFLAG_GENERATED) + if isGenerated != 0 && !(b2ndPass != 0) { + nGenerated = nGenerated + 1 + goto _1 /* Generated columns processed on 2nd pass */ + } + if aiChng != 0 && **(**int32)(__ccgo_up(aiChng + uintptr(i)*4)) < 0 && !(isGenerated != 0) { + /* Do not check NOT NULL on columns that do not change */ + goto _1 + } + if libc.Int32FromUint8(overrideError) != int32(OE_Default) { + onError = libc.Int32FromUint8(overrideError) + } else { + if onError == int32(OE_Default) { + onError = int32(OE_Abort) + } + } + if onError == int32(OE_Replace) { + if b2ndPass != 0 || libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) == 0 { + onError = int32(OE_Abort) + } else { + } + } else { + if b2ndPass != 0 && !(isGenerated != 0) { + goto _1 + } + } + iReg = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(i))) + regNewData + int32(1) + switch onError { + case int32(OE_Replace): + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_NotNull), iReg) + nSeenReplace = nSeenReplace + 1 + _sqlite3ExprCodeCopy(tls, pParse, _sqlite3ColumnExpr(tls, pTab, pCol), iReg) + _sqlite3VdbeJumpHere(tls, v, addr1) + case int32(OE_Abort): + _sqlite3MayAbort(tls, pParse) + fallthrough + case int32(OE_Rollback): + fallthrough + case int32(OE_Fail): + zMsg = _sqlite3MPrintf(tls, db, __ccgo_ts+13632, libc.VaList(bp+64, (*TTable)(unsafe.Pointer(pTab)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_HaltIfNull), libc.Int32FromInt32(SQLITE_CONSTRAINT)|libc.Int32FromInt32(5)< 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != uint32(0) { + /* If any NOT NULL ON CONFLICT REPLACE constraints fired on the + ** first pass, recomputed values for all generated columns, as + ** those values might depend on columns affected by the REPLACE. + */ + _sqlite3ComputeGeneratedColumns(tls, pParse, regNewData+int32(1), pTab) + } + } /* end of 2-pass loop */ + } /* end if( has-not-null-constraints ) */ + /* Test all CHECK constraints + */ + if (*TTable)(unsafe.Pointer(pTab)).FpCheck != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_IgnoreChecks) == uint64(0) { + pCheck = (*TTable)(unsafe.Pointer(pTab)).FpCheck + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + int32(1)) + if libc.Int32FromUint8(overrideError) != int32(OE_Default) { + v2 = libc.Int32FromUint8(overrideError) + } else { + v2 = int32(OE_Abort) + } + onError = v2 + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pCheck)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(i)*32))).FpExpr + if aiChng != 0 && !(_sqlite3ExprReferencesUpdatedColumn(tls, pExpr, aiChng, libc.Int32FromUint8(pkChng)) != 0) { + /* The check constraints do not reference any of the columns being + ** updated so there is no point it verifying the check constraint */ + goto _3 + } + if libc.Int32FromUint8(bAffinityDone) == 0 { + _sqlite3TableAffinity(tls, v, pTab, regNewData+int32(1)) + bAffinityDone = uint8(1) + } + allOk = _sqlite3VdbeMakeLabel(tls, pParse) + pCopy = _sqlite3ExprDup(tls, db, pExpr, 0) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + _sqlite3ExprIfTrue(tls, pParse, pCopy, allOk, int32(SQLITE_JUMPIFNULL)) + } + _sqlite3ExprDelete(tls, db, pCopy) + if onError == int32(OE_Ignore) { + _sqlite3VdbeGoto(tls, v, ignoreDest) + } else { + zName = (*(*TExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(i)*32))).FzEName + if onError == int32(OE_Replace) { + onError = int32(OE_Abort) + } /* IMP: R-26383-51744 */ + _sqlite3HaltConstraint(tls, pParse, libc.Int32FromInt32(SQLITE_CONSTRAINT)|libc.Int32FromInt32(1)<>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + v2 = regIdx + } else { + v2 = regR + } + regCmp = v2 + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + p4 = _sqlite3LocateCollSeq(tls, pParse, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(i)*8))) + x1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))) + if i == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)-int32(1) { + addrJump = addrUniqueOk + op = int32(OP_Eq) + } + x1 = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(x1))) + _sqlite3VdbeAddOp4(tls, v, op, regOldData+int32(1)+x1, addrJump, regCmp+i, p4, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL)) + goto _14 + _14: + ; + i = i + 1 + } + } + } + } + /* Generate code that executes if the new index entry is not unique */ + switch onError { + case int32(OE_Rollback): + fallthrough + case int32(OE_Abort): + fallthrough + case int32(OE_Fail): + _sqlite3UniqueConstraint(tls, pParse, onError, pIdx) + case int32(OE_Update): + _sqlite3UpsertDoUpdate(tls, pParse, pUpsert, pTab, pIdx, iIdxCur+**(**int32)(__ccgo_up(bp))) + fallthrough + case int32(OE_Ignore): + _sqlite3VdbeGoto(tls, v, ignoreDest) + default: /* Number of opcodes in conflict check logic */ + nConflictCk = _sqlite3VdbeCurrentAddr(tls, v) - addrConflictCk + if regTrigCnt != 0 { + _sqlite3MultiWrite(tls, pParse) + nReplaceTrig = nReplaceTrig + 1 + } + if pTrigger != 0 && isUpdate != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_CursorLock), iDataCur) + } + if pIdx == pPk { + v2 = int32(ONEPASS_SINGLE) + } else { + v2 = ONEPASS_OFF + } + _sqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, iDataCur, iIdxCur, regR, int16(nPkField), uint8(0), uint8(OE_Replace), libc.Uint8FromInt32(v2), iThisCur) + if pTrigger != 0 && isUpdate != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_CursorUnlock), iDataCur) + } + if regTrigCnt != 0 { /* Jump destination to bypass recheck logic */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), regTrigCnt, int32(1)) /* incr trigger cnt */ + addrBypass = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) /* Bypass recheck */ + /* Here we insert code that will be invoked after all constraint + ** checks have run, if and only if one or more replace triggers + ** fired. */ + _sqlite3VdbeResolveLabel(tls, v, lblRecheckOk) + lblRecheckOk = _sqlite3VdbeMakeLabel(tls, pParse) + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + /* Bypass the recheck if this partial index is not defined + ** for the current row */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regIdx-int32(1), lblRecheckOk) + } + /* Copy the constraint check code from above, except change + ** the constraint-ok jump destination to be the address of + ** the next retest block */ + for nConflictCk > 0 { /* Conflict check opcode to copy */ + /* The sqlite3VdbeAddOp4() call might reallocate the opcode array. + ** Hence, make a complete copy of the opcode, rather than using + ** a pointer to the opcode. */ + **(**TVdbeOp)(__ccgo_up(bp + 32)) = **(**TVdbeOp)(__ccgo_up(_sqlite3VdbeGetOp(tls, v, addrConflictCk))) + if libc.Int32FromUint8((**(**TVdbeOp)(__ccgo_up(bp + 32))).Fopcode) != int32(OP_IdxRowid) { + if libc.Int32FromUint8(_sqlite3OpcodeProperty[(**(**TVdbeOp)(__ccgo_up(bp + 32))).Fopcode])&int32(OPFLG_JUMP) != 0 { + p2 = lblRecheckOk + } else { + p2 = (**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp2 + } + if int32((**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp4type) == -int32(3) { + v8 = uintptr(int64(*(*int32)(unsafe.Pointer(bp + 32 + 16)))) + } else { + v8 = *(*uintptr)(unsafe.Pointer(bp + 32 + 16)) + } + zP4 = v8 + _sqlite3VdbeAddOp4(tls, v, libc.Int32FromUint8((**(**TVdbeOp)(__ccgo_up(bp + 32))).Fopcode), (**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp1, p2, (**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp3, zP4, int32((**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp4type)) + _sqlite3VdbeChangeP5(tls, v, (**(**TVdbeOp)(__ccgo_up(bp + 32))).Fp5) + } + nConflictCk = nConflictCk - 1 + addrConflictCk = addrConflictCk + 1 + } + /* If the retest fails, issue an abort */ + _sqlite3UniqueConstraint(tls, pParse, int32(OE_Abort), pIdx) + _sqlite3VdbeJumpHere(tls, v, addrBypass) /* Terminate the recheck bypass */ + } + seenReplace = int32(1) + break + } + _sqlite3VdbeResolveLabel(tls, v, addrUniqueOk) + if regR != regIdx { + _sqlite3ReleaseTempRange(tls, pParse, regR, nPkField) + } + if pUpsertClause != 0 && upsertIpkReturn != 0 && _sqlite3UpsertNextIsIPK(tls, pUpsertClause) != 0 { + _sqlite3VdbeGoto(tls, v, upsertIpkDelay+int32(1)) + _sqlite3VdbeJumpHere(tls, v, upsertIpkReturn) + upsertIpkReturn = 0 + } + goto _9 + _9: + ; + pIdx = _indexIteratorNext(tls, bp+8, bp) + } + /* If the IPK constraint is a REPLACE, run it last */ + if ipkTop != 0 { + _sqlite3VdbeGoto(tls, v, ipkTop) + _sqlite3VdbeJumpHere(tls, v, ipkBottom) + } + /* Recheck all uniqueness constraints after replace triggers have run */ + if nReplaceTrig != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNot), regTrigCnt, lblRecheckOk) + if !(pPk != 0) { + if isUpdate != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), regNewData, addrRecheck, regOldData) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL)) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iDataCur, addrRecheck, regNewData) + _sqlite3RowidConstraint(tls, pParse, int32(OE_Abort), pTab) + } else { + _sqlite3VdbeGoto(tls, v, addrRecheck) + } + _sqlite3VdbeResolveLabel(tls, v, lblRecheckOk) + } + /* Generate the table record */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + regRec = **(**int32)(__ccgo_up(aRegIdx + uintptr(**(**int32)(__ccgo_up(bp)))*4)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regNewData+int32(1), int32((*TTable)(unsafe.Pointer(pTab)).FnNVCol), regRec) + if !(bAffinityDone != 0) { + _sqlite3TableAffinity(tls, v, pTab, 0) + } + } + **(**int32)(__ccgo_up(pbMayReplace)) = seenReplace +} + +// C documentation +// +// /* +// ** This routine generates VDBE code that causes a single row of a +// ** single table to be deleted. Both the original table entry and +// ** all indices are removed. +// ** +// ** Preconditions: +// ** +// ** 1. iDataCur is an open cursor on the btree that is the canonical data +// ** store for the table. (This will be either the table itself, +// ** in the case of a rowid table, or the PRIMARY KEY index in the case +// ** of a WITHOUT ROWID table.) +// ** +// ** 2. Read/write cursors for all indices of pTab must be open as +// ** cursor number iIdxCur+i for the i-th index. +// ** +// ** 3. The primary key for the row to be deleted must be stored in a +// ** sequence of nPk memory cells starting at iPk. If nPk==0 that means +// ** that a search record formed from OP_MakeRecord is contained in the +// ** single memory location iPk. +// ** +// ** eMode: +// ** Parameter eMode may be passed either ONEPASS_OFF (0), ONEPASS_SINGLE, or +// ** ONEPASS_MULTI. If eMode is not ONEPASS_OFF, then the cursor +// ** iDataCur already points to the row to delete. If eMode is ONEPASS_OFF +// ** then this function must seek iDataCur to the entry identified by iPk +// ** and nPk before reading from it. +// ** +// ** If eMode is ONEPASS_MULTI, then this call is being made as part +// ** of a ONEPASS delete that affects multiple rows. In this case, if +// ** iIdxNoSeek is a valid cursor number (>=0) and is not the same as +// ** iDataCur, then its position should be preserved following the delete +// ** operation. Or, if iIdxNoSeek is not a valid cursor number, the +// ** position of iDataCur should be preserved instead. +// ** +// ** iIdxNoSeek: +// ** If iIdxNoSeek is a valid cursor number (>=0) not equal to iDataCur, +// ** then it identifies an index cursor (from within array of cursors +// ** starting at iIdxCur) that already points to the index entry to be deleted. +// ** Except, this optimization is disabled if there are BEFORE triggers since +// ** the trigger body might have moved the cursor. +// */ +func _sqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTrigger uintptr, iDataCur int32, iIdxCur int32, iPk int32, nPk Ti16, count Tu8, onconf Tu8, eMode Tu8, iIdxNoSeek int32) { + var addrStart, iCol, iLabel, iOld, kk, v1 int32 + var mask Tu32 + var opSeek, p5 Tu8 + var v uintptr + _, _, _, _, _, _, _, _, _, _ = addrStart, iCol, iLabel, iOld, kk, mask, opSeek, p5, v, v1 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Vdbe */ + iOld = 0 /* Seek opcode */ + /* Vdbe is guaranteed to have been allocated by this stage. */ + /* Seek cursor iCur to the row to delete. If this row no longer exists + ** (this can happen if a trigger program has already deleted it), do + ** not attempt to delete it or fire any DELETE triggers. */ + iLabel = _sqlite3VdbeMakeLabel(tls, pParse) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v1 = int32(OP_NotExists) + } else { + v1 = int32(OP_NotFound) + } + opSeek = libc.Uint8FromInt32(v1) + if libc.Int32FromUint8(eMode) == ONEPASS_OFF { + _sqlite3VdbeAddOp4Int(tls, v, libc.Int32FromUint8(opSeek), iDataCur, iLabel, iPk, int32(nPk)) + } + /* If there are any triggers to fire, allocate a range of registers to + ** use for the old.* references in the triggers. */ + if _sqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0 || pTrigger != 0 { /* Start of BEFORE trigger programs */ + /* TODO: Could use temporary registers here. Also could attempt to + ** avoid copying the contents of the rowid register. */ + mask = _sqlite3TriggerColmask(tls, pParse, pTrigger, uintptr(0), 0, libc.Int32FromInt32(TRIGGER_BEFORE)|libc.Int32FromInt32(TRIGGER_AFTER), pTab, libc.Int32FromUint8(onconf)) + mask = mask | _sqlite3FkOldmask(tls, pParse, pTab) + iOld = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(1) + int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + /* Populate the OLD.* pseudo-table register array. These values will be + ** used by any BEFORE and AFTER triggers that exist. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), iPk, iOld) + iCol = 0 + for { + if !(iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if mask == uint32(0xffffffff) || iCol <= int32(31) && mask&(libc.Uint32FromInt32(1)<= 0 && iIdxNoSeek != iDataCur { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Delete), iIdxNoSeek) + } + if libc.Int32FromUint8(eMode) == int32(ONEPASS_MULTI) { + p5 = libc.Uint8FromInt32(int32(p5) | libc.Int32FromInt32(OPFLAG_SAVEPOSITION)) + } + _sqlite3VdbeChangeP5(tls, v, uint16(p5)) + } + /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to + ** handle rows (possibly in other tables) that refer via a foreign key + ** to the row just deleted. */ + _sqlite3FkActions(tls, pParse, pTab, uintptr(0), iOld, uintptr(0), 0) + /* Invoke AFTER DELETE trigger programs. */ + if pTrigger != 0 { + _sqlite3CodeRowTrigger(tls, pParse, pTrigger, int32(TK_DELETE), uintptr(0), int32(TRIGGER_AFTER), pTab, iOld, libc.Int32FromUint8(onconf), iLabel) + } + /* Jump here if the row had already been deleted before any BEFORE + ** trigger programs were invoked. Or if a trigger program throws a + ** RAISE(IGNORE) exception. */ + _sqlite3VdbeResolveLabel(tls, v, iLabel) +} + +// C documentation +// +// /* +// ** If expression list pList contains an expression that was parsed with +// ** an explicit "NULLS FIRST" or "NULLS LAST" clause, leave an error in +// ** pParse and return non-zero. Otherwise, return zero. +// */ +func _sqlite3HasExplicitNulls(tls *libc.TLS, pParse uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var sf Tu8 + var v2 uintptr + _, _, _ = i, sf, v2 + if pList != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pList + 8 + uintptr(i)*32 + 16 + 4))&0x20>>5)) != 0 { + sf = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).Ffg.FsortFlags + if libc.Int32FromUint8(sf) == 0 || libc.Int32FromUint8(sf) == int32(3) { + v2 = __ccgo_ts + 15374 + } else { + v2 = __ccgo_ts + 15380 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15385, libc.VaList(bp+8, v2)) + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + } + return 0 +} + +// C documentation +// +// /* +// ** If the source-list item passed as an argument was augmented with an +// ** INDEXED BY clause, then try to locate the specified index. If there +// ** was such a clause and the named index cannot be found, return +// ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate +// ** pFrom->pIndex and return SQLITE_OK. +// */ +func _sqlite3IndexedByLookup(tls *libc.TLS, pParse uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pIdx, pTab, zIndexedBy uintptr + _, _, _ = pIdx, pTab, zIndexedBy + pTab = (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab + zIndexedBy = *(*uintptr)(unsafe.Pointer(pFrom + 48)) + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0 && _sqlite3StrICmp(tls, (*TIndex)(unsafe.Pointer(pIdx)).FzName, zIndexedBy) != 0) { + break + } + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if !(pIdx != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20974, libc.VaList(bp+8, zIndexedBy, 0)) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + return int32(SQLITE_ERROR) + } + *(*uintptr)(unsafe.Pointer(pFrom + 56)) = pIdx + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Attempt to read the database schema and initialize internal +// ** data structures for a single database file. The index of the +// ** database file is given by iDb. iDb==0 is used for the main +// ** database. iDb==1 should never be used. iDb>=2 is used for +// ** auxiliary databases. Return one of the SQLITE_ error codes to +// ** indicate success or failure. +// */ +func _sqlite3InitOne(tls *libc.TLS, db uintptr, iDb int32, pzErrMsg uintptr, mFlags Tu32) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var encoding Tu8 + var i, mask, openedTransaction, rc, size int32 + var pDb, zSchemaTabName, zSql, v1, v2 uintptr + var xAuth Tsqlite3_xauth + var _ /* azArg at bp+0 */ [6]uintptr + var _ /* initData at bp+72 */ TInitData + var _ /* meta at bp+48 */ [5]int32 + _, _, _, _, _, _, _, _, _, _, _, _ = encoding, i, mask, openedTransaction, pDb, rc, size, xAuth, zSchemaTabName, zSql, v1, v2 + openedTransaction = 0 + mask = libc.Int32FromUint32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&libc.Uint32FromInt32(DBFLAG_EncodingFixed) | libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_EncodingFixed))) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(1) + /* Construct the in-memory representation schema tables (sqlite_schema or + ** sqlite_temp_schema) by invoking the parser directly. The appropriate + ** table name will be inserted automatically by the parser so we can just + ** use the abbreviation "x" here. The parser will also automatically tag + ** the schema table as read-only. */ + (**(**[6]uintptr)(__ccgo_up(bp)))[0] = __ccgo_ts + 9377 + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v2 = __ccgo_ts + 6764 + } else { + v2 = __ccgo_ts + 6284 + } + v1 = v2 + zSchemaTabName = v1 + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(1)] = v1 + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(2)] = (**(**[6]uintptr)(__ccgo_up(bp)))[int32(1)] + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(3)] = __ccgo_ts + 20103 + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(4)] = __ccgo_ts + 20105 + (**(**[6]uintptr)(__ccgo_up(bp)))[int32(5)] = uintptr(0) + (**(**TInitData)(__ccgo_up(bp + 72))).Fdb = db + (**(**TInitData)(__ccgo_up(bp + 72))).FiDb = iDb + (**(**TInitData)(__ccgo_up(bp + 72))).Frc = SQLITE_OK + (**(**TInitData)(__ccgo_up(bp + 72))).FpzErrMsg = pzErrMsg + (**(**TInitData)(__ccgo_up(bp + 72))).FmInitFlags = mFlags + (**(**TInitData)(__ccgo_up(bp + 72))).FnInitRow = uint32(0) + (**(**TInitData)(__ccgo_up(bp + 72))).FmxPage = uint32(0) + _sqlite3InitCallback(tls, bp+72, int32(5), bp, uintptr(0)) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(mask) + if (**(**TInitData)(__ccgo_up(bp + 72))).Frc != 0 { + rc = (**(**TInitData)(__ccgo_up(bp + 72))).Frc + goto error_out + } + /* Create a cursor to hold the database open + */ + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpBt == uintptr(0) { + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(DB_SchemaLoaded)) + rc = SQLITE_OK + goto error_out + } + /* If there is not already a read-only (or read-write) transaction opened + ** on the b-tree database, open one now. If a transaction is opened, it + ** will be closed before this function returns. */ + _sqlite3BtreeEnter(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + if _sqlite3BtreeTxnState(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) == SQLITE_TXN_NONE { + rc = _sqlite3BtreeBeginTrans(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, 0, uintptr(0)) + if rc != SQLITE_OK { + _sqlite3SetString(tls, pzErrMsg, db, _sqlite3ErrStr(tls, rc)) + goto initone_error_out + } + openedTransaction = int32(1) + } + /* Get the database meta information. + ** + ** Meta values are as follows: + ** meta[0] Schema cookie. Changes with each schema change. + ** meta[1] File format of schema layer. + ** meta[2] Size of the page cache. + ** meta[3] Largest rootpage (auto/incr_vacuum mode) + ** meta[4] Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE + ** meta[5] User version + ** meta[6] Incremental vacuum mode + ** meta[7] unused + ** meta[8] unused + ** meta[9] unused + ** + ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to + ** the possible values of meta[4]. + */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(20)/libc.Uint64FromInt64(4))) { + break + } + _sqlite3BtreeGetMeta(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, i+int32(1), bp+48+uintptr(i)*4) + goto _4 + _4: + ; + i = i + 1 + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ResetDatabase) != uint64(0) { + libc.Xmemset(tls, bp+48, 0, uint64(20)) + } + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_SCHEMA_VERSION)-libc.Int32FromInt32(1)] + /* If opening a non-empty database, check the text encoding. For the + ** main database, set sqlite3.enc to the encoding of the main database. + ** For an attached db, it is an error if the encoding is not the same + ** as sqlite3.enc. + */ + if (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_TEXT_ENCODING)-libc.Int32FromInt32(1)] != 0 { /* text encoding */ + if iDb == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_EncodingFixed) == uint32(0) { + /* If opening the main database, set ENC(db). */ + encoding = libc.Uint8FromInt32(libc.Int32FromUint8(libc.Uint8FromInt32((**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_TEXT_ENCODING)-libc.Int32FromInt32(1)])) & int32(3)) + if libc.Int32FromUint8(encoding) == 0 { + encoding = uint8(SQLITE_UTF8) + } + _sqlite3SetTextEncoding(tls, db, encoding) + } else { + /* If opening an attached database, the encoding much match ENC(db) */ + if (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_TEXT_ENCODING)-libc.Int32FromInt32(1)]&int32(3) != libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Fenc) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+13346) + rc = int32(SQLITE_ERROR) + goto initone_error_out + } + } + } + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fenc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + if (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size == 0 { + size = _sqlite3AbsInt32(tls, (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_DEFAULT_CACHE_SIZE)-libc.Int32FromInt32(1)]) + if size == 0 { + size = -int32(2000) + } + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size + _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) + } + /* + ** file_format==1 Version 3.0.0. + ** file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN + ** file_format==3 Version 3.1.4. // ditto but with non-NULL defaults + ** file_format==4 Version 3.3.0. // DESC indices. Boolean constants + */ + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = libc.Uint8FromInt32((**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_FILE_FORMAT)-libc.Int32FromInt32(1)]) + if libc.Int32FromUint8((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) == 0 { + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = uint8(1) + } + if libc.Int32FromUint8((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) > int32(SQLITE_MAX_FILE_FORMAT) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+20177) + rc = int32(SQLITE_ERROR) + goto initone_error_out + } + /* Ticket #2804: When we open a database in the newer file format, + ** clear the legacy_file_format pragma flag so that a VACUUM will + ** not downgrade the database and thus invalidate any descending + ** indices that the user might have created. + */ + if iDb == 0 && (**(**[5]int32)(__ccgo_up(bp + 48)))[libc.Int32FromInt32(BTREE_FILE_FORMAT)-libc.Int32FromInt32(1)] >= int32(4) { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_LegacyFileFmt) + } + /* Read the schema information out of the schema tables + */ + (**(**TInitData)(__ccgo_up(bp + 72))).FmxPage = _sqlite3BtreeLastPage(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+20201, libc.VaList(bp+120, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zSchemaTabName)) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_sqlite3InitCallback), bp+72, uintptr(0)) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + if rc == SQLITE_OK { + rc = (**(**TInitData)(__ccgo_up(bp + 72))).Frc + } + _sqlite3DbFree(tls, db, zSql) + if rc == SQLITE_OK { + _sqlite3AnalysisLoad(tls, db, iDb) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + _sqlite3ResetAllSchemasOfConnection(tls, db) + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + } else { + if rc == SQLITE_OK || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NoSchemaError) != 0 && rc != int32(SQLITE_NOMEM) { + /* Hack: If the SQLITE_NoSchemaError flag is set, then consider + ** the schema loaded, even if errors (other than OOM) occurred. In + ** this situation the current sqlite3_prepare() operation will fail, + ** but the following one will attempt to compile the supplied statement + ** against whatever subset of the schema was loaded before the error + ** occurred. + ** + ** The primary purpose of this is to allow access to the sqlite_schema + ** table even when its contents have been corrupted. + */ + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(DB_SchemaLoaded)) + rc = SQLITE_OK + } + } + /* Jump here for an error that occurs after successfully allocating + ** curMain and calling sqlite3BtreeEnter(). For an error that occurs + ** before that point, jump to error_out. + */ + goto initone_error_out +initone_error_out: + ; + if openedTransaction != 0 { + _sqlite3BtreeCommit(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + } + _sqlite3BtreeLeave(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + goto error_out +error_out: + ; + if rc != 0 { + if rc == int32(SQLITE_NOMEM) || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)< and its indices +// ** put VALUES clause expressions into registers +// ** write the resulting record into
  • +// ** cleanup +// ** +// ** The three remaining templates assume the statement is of the form +// ** +// ** INSERT INTO
    SELECT ... +// ** +// ** If the SELECT clause is of the restricted form "SELECT * FROM " - +// ** in other words if the SELECT pulls all columns from a single table +// ** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and +// ** if and are distinct tables but have identical +// ** schemas, including all the same indices, then a special optimization +// ** is invoked that copies raw records from over to . +// ** See the xferOptimization() function for the implementation of this +// ** template. This is the 2nd template. +// ** +// ** open a write cursor to
    +// ** open read cursor on +// ** transfer all records in over to
    +// ** close cursors +// ** foreach index on
    +// ** open a write cursor on the
    index +// ** open a read cursor on the corresponding index +// ** transfer all records from the read to the write cursors +// ** close cursors +// ** end foreach +// ** +// ** The 3rd template is for when the second template does not apply +// ** and the SELECT clause does not read from
    at any time. +// ** The generated code follows this template: +// ** +// ** X <- A +// ** goto B +// ** A: setup for the SELECT +// ** loop over the rows in the SELECT +// ** load values into registers R..R+n +// ** yield X +// ** end loop +// ** cleanup after the SELECT +// ** end-coroutine X +// ** B: open write cursor to
    and its indices +// ** C: yield X, at EOF goto D +// ** insert the select result into
    from R..R+n +// ** goto C +// ** D: cleanup +// ** +// ** The 4th template is used if the insert statement takes its +// ** values from a SELECT but the data is being inserted into a table +// ** that is also read as part of the SELECT. In the third form, +// ** we have to use an intermediate table to store the results of +// ** the select. The template is like this: +// ** +// ** X <- A +// ** goto B +// ** A: setup for the SELECT +// ** loop over the tables in the SELECT +// ** load value into register R..R+n +// ** yield X +// ** end loop +// ** cleanup after the SELECT +// ** end co-routine R +// ** B: open temp table +// ** L: yield X, at EOF goto M +// ** insert row from R..R+n into temp table +// ** goto L +// ** M: open write cursor to
    and its indices +// ** rewind temp table +// ** C: loop over rows of intermediate table +// ** transfer values form intermediate table into
    +// ** end loop +// ** D: cleanup +// */ +func _sqlite3Insert(tls *libc.TLS, pParse uintptr, pTabList uintptr, pSelect uintptr, pColumn uintptr, onError int32, pUpsert uintptr) { + bp := tls.Alloc(160) + defer tls.Free(160) + var aRegIdx, aTabColMap, db, pIdx, pIpk, pItem, pList, pNx, pSubq, pTab, pTrigger, pVTab, pX, v, v5 uintptr + var addr1, addr11, addrCont, addrInsTop, addrL, addrTop, bUseSeek, endOfLoop, i, iDb, iRegStore, ipkColumn, isView, j, k, nColumn, nHidden, nIdx, rc, regAutoinc, regCols, regData, regFromSelect, regIns, regRec, regRowCount, regRowid, regTempRowid, regYield, srcTab, y, v1 int32 + var appendFlag, bIdListInOrder, useTempTable, withoutRowid Tu8 + var colFlags, v20 Tu32 + var _ /* dest at bp+8 */ TSelectDest + var _ /* iDataCur at bp+0 */ int32 + var _ /* iIdxCur at bp+4 */ int32 + var _ /* isReplace at bp+112 */ int32 + var _ /* sNC at bp+56 */ TNameContext + var _ /* tmask at bp+48 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aRegIdx, aTabColMap, addr1, addr11, addrCont, addrInsTop, addrL, addrTop, appendFlag, bIdListInOrder, bUseSeek, colFlags, db, endOfLoop, i, iDb, iRegStore, ipkColumn, isView, j, k, nColumn, nHidden, nIdx, pIdx, pIpk, pItem, pList, pNx, pSubq, pTab, pTrigger, pVTab, pX, rc, regAutoinc, regCols, regData, regFromSelect, regIns, regRec, regRowCount, regRowid, regTempRowid, regYield, srcTab, useTempTable, v, withoutRowid, y, v1, v20, v5 /* Number of columns in the data */ + nHidden = 0 /* Number of hidden columns if TABLE is virtual */ + **(**int32)(__ccgo_up(bp)) = 0 /* VDBE cursor that is the main data repository */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* First index cursor */ + ipkColumn = -int32(1) /* Label for the end of the insertion loop */ + srcTab = 0 /* Data comes from this temporary cursor if >=0 */ + addrInsTop = 0 /* Jump to label "D" */ + addrCont = 0 /* Index of database holding TABLE */ + useTempTable = uint8(0) /* Store SELECT results in intermediate table */ + appendFlag = uint8(0) /* True if IDLIST is in table order */ + pList = uintptr(0) /* Register in which to store next column */ + /* Register allocations */ + regFromSelect = 0 /* Base register for data coming from SELECT */ + regAutoinc = 0 /* Register holding the AUTOINCREMENT counter */ + regRowCount = 0 /* register holding first column to insert */ + aRegIdx = uintptr(0) /* One register allocated to each index */ + aTabColMap = uintptr(0) /* Mask of trigger times */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto insert_cleanup + } + (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSDParm = 0 /* Suppress a harmless compiler warning */ + /* If the Select object is really just a simple VALUES() list with a + ** single row (the common case) then keep that one row of values + ** and discard the other (unused) parts of the pSelect object + */ + if pSelect != 0 && (*TSelect)(unsafe.Pointer(pSelect)).FselFlags&uint32(SF_Values) != uint32(0) && (*TSelect)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0) { + pList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + (*TSelect)(unsafe.Pointer(pSelect)).FpEList = uintptr(0) + _sqlite3SelectDelete(tls, db, pSelect) + pSelect = uintptr(0) + } + /* Locate the table into which we will be inserting new information. + */ + pTab = _sqlite3SrcListLookup(tls, pParse, pTabList) + if pTab == uintptr(0) { + goto insert_cleanup + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) != 0 { + goto insert_cleanup + } + withoutRowid = libc.BoolUint8(!((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0))) + /* Figure out if we have any triggers and if the table being + ** inserted into is a view + */ + pTrigger = _sqlite3TriggersExist(tls, pParse, pTab, int32(TK_INSERT), uintptr(0), bp+48) + isView = libc.BoolInt32(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW)) + /* If pTab is really a view, make sure it has been initialized. + ** ViewGetColumnNames() is a no-op if pTab is not a view. + */ + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto insert_cleanup + } + /* Cannot insert into a read-only table. + */ + if _sqlite3IsReadOnly(tls, pParse, pTab, pTrigger) != 0 { + goto insert_cleanup + } + /* Allocate a VDBE + */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto insert_cleanup + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _sqlite3VdbeCountChanges(tls, v) + } + _sqlite3BeginWriteOperation(tls, pParse, libc.BoolInt32(pSelect != 0 || pTrigger != 0), iDb) + /* If the statement is of the form + ** + ** INSERT INTO SELECT * FROM ; + ** + ** Then special optimizations can be applied that make the transfer + ** very fast and which reduce fragmentation of indices. + ** + ** This is the 2nd template. + */ + if pColumn == uintptr(0) && pSelect != uintptr(0) && pTrigger == uintptr(0) && _xferOptimization(tls, pParse, pTab, pSelect, onError, iDb) != 0 { + goto insert_end + } + /* If this is an AUTOINCREMENT table, look up the sequence number in the + ** sqlite_sequence table and store it in memory cell regAutoinc. + */ + regAutoinc = _autoIncBegin(tls, pParse, iDb, pTab) + /* Allocate a block registers to hold the rowid and the values + ** for all columns of the new row. + */ + v1 = (*TParse)(unsafe.Pointer(pParse)).FnMem + libc.Int32FromInt32(1) + regIns = v1 + regRowid = v1 + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + int32(1) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + regRowid = regRowid + 1 + (*TParse)(unsafe.Pointer(pParse)).FnMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + 1 + } + regData = regRowid + int32(1) + /* If the INSERT statement included an IDLIST term, then make sure + ** all elements of the IDLIST really are columns of the table and + ** remember the column indices. + ** + ** If the table has an INTEGER PRIMARY KEY column and that column + ** is named in the IDLIST, then record in the ipkColumn variable + ** the index into IDLIST of the primary key column. ipkColumn is + ** the index of the primary key as it appears in IDLIST, not as + ** is appears in the original table. (The index of the INTEGER + ** PRIMARY KEY in the original table is pTab->iPKey.) After this + ** loop, if ipkColumn==(-1), that means that integer primary key + ** is unspecified, and hence the table is either WITHOUT ROWID or + ** it will automatically generated an integer primary key. + ** + ** bIdListInOrder is true if the columns in IDLIST are in storage + ** order. This enables an optimization that avoids shuffling the + ** columns into storage order. False negatives are harmless, + ** but false positives will cause database corruption. + */ + bIdListInOrder = libc.BoolUint8((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(libc.Int32FromInt32(TF_OOOHidden)|libc.Int32FromInt32(TF_HasStored)) == uint32(0)) + if pColumn != 0 { + aTabColMap = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt16((*TTable)(unsafe.Pointer(pTab)).FnCol)*uint64(4))) + if aTabColMap == uintptr(0) { + goto insert_cleanup + } + i = 0 + for { + if !(i < (*TIdList)(unsafe.Pointer(pColumn)).FnId) { + break + } + j = _sqlite3ColumnIndex(tls, pTab, (*(*TIdList_item)(unsafe.Pointer(pColumn + 8 + uintptr(i)*8))).FzName) + if j >= 0 { + if **(**int32)(__ccgo_up(aTabColMap + uintptr(j)*4)) == 0 { + **(**int32)(__ccgo_up(aTabColMap + uintptr(j)*4)) = i + int32(1) + } + if i != j { + bIdListInOrder = uint8(0) + } + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + ipkColumn = i + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&(libc.Int32FromInt32(COLFLAG_STORED)|libc.Int32FromInt32(COLFLAG_VIRTUAL)) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17345, libc.VaList(bp+128, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FzCnName)) + goto insert_cleanup + } + } else { + if _sqlite3IsRowid(tls, (*(*TIdList_item)(unsafe.Pointer(pColumn + 8 + uintptr(i)*8))).FzName) != 0 && !(withoutRowid != 0) { + ipkColumn = i + bIdListInOrder = uint8(0) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17386, libc.VaList(bp+128, pTabList+8, (*(*TIdList_item)(unsafe.Pointer(pColumn + 8 + uintptr(i)*8))).FzName)) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + goto insert_cleanup + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + /* Figure out how many columns of data are supplied. If the data + ** is coming from a SELECT statement, then generate a co-routine that + ** produces a single row of the SELECT on each invocation. The + ** co-routine is the common header to the 3rd and 4th templates. + */ + if pSelect != 0 { /* Result code */ + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc == int32(1) && int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + 24 + 4))&0x40>>6) != 0 && (*TSelect)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0) { + pItem = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + pSubq = *(*uintptr)(unsafe.Pointer(pItem + 72)) + (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSDParm = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + regFromSelect = (*TSubquery)(unsafe.Pointer(pSubq)).FregResult + nColumn = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(pSubq)).FpSelect)).FpEList)).FnExpr + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+17418, libc.VaList(bp+128, pItem)) + if bIdListInOrder != 0 && nColumn == int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + regData = regFromSelect + regRowid = regData - int32(1) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + v1 = int32(1) + } else { + v1 = 0 + } + regIns = regRowid - v1 + } + } else { + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v1 = *(*int32)(unsafe.Pointer(v5)) /* Top of the co-routine */ + regYield = v1 + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, addrTop) + _sqlite3SelectDestInit(tls, bp+8, int32(SRT_Coroutine), regYield) + if bIdListInOrder != 0 { + v1 = regData + } else { + v1 = 0 + } + (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSdst = v1 + (**(**TSelectDest)(__ccgo_up(bp + 8))).FnSdst = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + rc = _sqlite3Select(tls, pParse, pSelect, bp+8) + regFromSelect = (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSdst + if rc != 0 || (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto insert_cleanup + } + _sqlite3VdbeEndCoroutine(tls, v, regYield) + _sqlite3VdbeJumpHere(tls, v, addrTop-int32(1)) /* label B: */ + nColumn = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList)).FnExpr + } + /* Set useTempTable to TRUE if the result of the SELECT statement + ** should be written into a temporary table (template 4). Set to + ** FALSE if each output row of the SELECT can be written directly into + ** the destination table (template 3). + ** + ** A temp table must be used if the table being updated is also one + ** of the tables being read by the SELECT statement. Also use a + ** temp table in the case of row triggers. + */ + if pTrigger != 0 || _readsTable(tls, pParse, iDb, pTab) != 0 { + useTempTable = uint8(1) + } + if useTempTable != 0 { /* Label "L" */ + v5 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v5)) + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + srcTab = v1 + regRec = _sqlite3GetTempReg(tls, pParse) + regTempRowid = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), srcTab, nColumn) + addrL = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSDParm) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regFromSelect, nColumn, regRec) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), srcTab, regTempRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), srcTab, regRec, regTempRowid) + _sqlite3VdbeGoto(tls, v, addrL) + _sqlite3VdbeJumpHere(tls, v, addrL) + _sqlite3ReleaseTempReg(tls, pParse, regRec) + _sqlite3ReleaseTempReg(tls, pParse, regTempRowid) + } + } else { + libc.Xmemset(tls, bp+56, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp + 56))).FpParse = pParse + srcTab = -int32(1) + if pList != 0 { + nColumn = (*TExprList)(unsafe.Pointer(pList)).FnExpr + if _sqlite3ResolveExprListNames(tls, bp+56, pList) != 0 { + goto insert_cleanup + } + } else { + nColumn = 0 + } + } + /* If there is no IDLIST term but the table has an integer primary + ** key, the set the ipkColumn variable to the integer primary key + ** column index in the original table definition. + */ + if pColumn == uintptr(0) && nColumn > 0 { + ipkColumn = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + if ipkColumn >= 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != uint32(0) { + i = ipkColumn - int32(1) + for { + if !(i >= 0) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + ipkColumn = ipkColumn - 1 + } + goto _9 + _9: + ; + i = i - 1 + } + } + /* Make sure the number of columns in the source data matches the number + ** of columns to be inserted into the table. + */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(libc.Int32FromInt32(TF_HasGenerated)|libc.Int32FromInt32(TF_HasHidden)) != uint32(0) { + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_NOINSERT) != 0 { + nHidden = nHidden + 1 + } + goto _10 + _10: + ; + i = i + 1 + } + } + if nColumn != int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-nHidden { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17426, libc.VaList(bp+128, pTabList+8, int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-nHidden, nColumn)) + goto insert_cleanup + } + } + if pColumn != uintptr(0) && nColumn != (*TIdList)(unsafe.Pointer(pColumn)).FnId { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17478, libc.VaList(bp+128, nColumn, (*TIdList)(unsafe.Pointer(pColumn)).FnId)) + goto insert_cleanup + } + /* Initialize the count of rows to be inserted + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00001))<>3)) != 0) { + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v1 = *(*int32)(unsafe.Pointer(v5)) + regRowCount = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regRowCount) + } + /* If this is not a view, open the table and and all indices */ + if !(isView != 0) { + nIdx = _sqlite3OpenTableAndIndices(tls, pParse, pTab, int32(OP_OpenWrite), uint8(0), -int32(1), uintptr(0), bp, bp+4) + aRegIdx = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(nIdx+libc.Int32FromInt32(2)))) + if aRegIdx == uintptr(0) { + goto insert_cleanup + } + i = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(i < nIdx) { + break + } + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v1 = *(*int32)(unsafe.Pointer(v5)) + **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)) = v1 + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + goto _13 + _13: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + i = i + 1 + } + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v1 = *(*int32)(unsafe.Pointer(v5)) + **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)) = v1 /* Register to store the table record */ + } + if pUpsert != 0 { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17503, libc.VaList(bp+128, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto insert_cleanup + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+17549, 0) + goto insert_cleanup + } + if _sqlite3HasExplicitNulls(tls, pParse, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) != 0 { + goto insert_cleanup + } + (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor = **(**int32)(__ccgo_up(bp)) + pNx = pUpsert + for cond := true; cond; cond = pNx != uintptr(0) { + (*TUpsert)(unsafe.Pointer(pNx)).FpUpsertSrc = pTabList + (*TUpsert)(unsafe.Pointer(pNx)).FregData = regData + (*TUpsert)(unsafe.Pointer(pNx)).FiDataCur = **(**int32)(__ccgo_up(bp)) + (*TUpsert)(unsafe.Pointer(pNx)).FiIdxCur = **(**int32)(__ccgo_up(bp + 4)) + if (*TUpsert)(unsafe.Pointer(pNx)).FpUpsertTarget != 0 { + if _sqlite3UpsertAnalyzeTarget(tls, pParse, pTabList, pNx, pUpsert) != 0 { + goto insert_cleanup + } + } + pNx = (*TUpsert)(unsafe.Pointer(pNx)).FpNextUpsert + } + } + /* This is the top of the main insertion loop */ + if useTempTable != 0 { + /* This block codes the top of loop only. The complete loop is the + ** following pseudocode (template 4): + ** + ** rewind temp table, if empty goto D + ** C: loop over rows of intermediate table + ** transfer values form intermediate table into
    + ** end loop + ** D: ... + */ + addrInsTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), srcTab) + addrCont = _sqlite3VdbeCurrentAddr(tls, v) + } else { + if pSelect != 0 { + /* This block codes the top of loop only. The complete loop is the + ** following pseudocode (template 3): + ** + ** C: yield X, at EOF goto D + ** insert the select result into
    from R..R+n + ** goto C + ** D: ... + */ + v1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (**(**TSelectDest)(__ccgo_up(bp + 8))).FiSDParm) + addrCont = v1 + addrInsTop = v1 + if ipkColumn >= 0 { + /* tag-20191021-001: If the INTEGER PRIMARY KEY is being generated by the + ** SELECT, go ahead and copy the value into the rowid slot now, so that + ** the value does not get overwritten by a NULL at tag-20191021-002. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), regFromSelect+ipkColumn, regRowid) + } + } + } + /* Compute data for ordinary columns of the new entry. Values + ** are written in storage order into registers starting with regData. + ** Only ordinary columns are computed in this loop. The rowid + ** (if there is one) is computed later and generated columns are + ** computed after the rowid since they might depend on the value + ** of the rowid. + */ + nHidden = 0 + iRegStore = regData + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if i == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + /* tag-20191021-002: References to the INTEGER PRIMARY KEY are filled + ** using the rowid. So put a NULL in the IPK slot of the record to avoid + ** using excess space. The file format definition requires this extra + ** NULL - we cannot optimize further by skipping the column completely */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_SoftNull), iRegStore) + goto _19 + } + v20 = uint32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags) + colFlags = v20 + if v20&uint32(COLFLAG_NOINSERT) != uint32(0) { + nHidden = nHidden + 1 + if colFlags&uint32(COLFLAG_VIRTUAL) != uint32(0) { + /* Virtual columns do not participate in OP_MakeRecord. So back up + ** iRegStore by one slot to compensate for the iRegStore++ in the + ** outer for() loop */ + iRegStore = iRegStore - 1 + goto _19 + } else { + if colFlags&uint32(COLFLAG_STORED) != uint32(0) { + /* Stored columns are computed later. But if there are BEFORE + ** triggers, the slots used for stored columns will be OP_Copy-ed + ** to a second block of registers, so the register needs to be + ** initialized to NULL to avoid an uninitialized register read */ + if **(**int32)(__ccgo_up(bp + 48))&int32(TRIGGER_BEFORE) != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_SoftNull), iRegStore) + } + goto _19 + } else { + if pColumn == uintptr(0) { + /* Hidden columns that are not explicitly named in the INSERT + ** get their default value */ + _sqlite3ExprCodeFactorable(tls, pParse, _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16), iRegStore) + goto _19 + } + } + } + } + if pColumn != 0 { + j = **(**int32)(__ccgo_up(aTabColMap + uintptr(i)*4)) + if j == 0 { + /* A column not named in the insert column list gets its + ** default value */ + _sqlite3ExprCodeFactorable(tls, pParse, _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16), iRegStore) + goto _19 + } + k = j - int32(1) + } else { + if nColumn == 0 { + /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */ + _sqlite3ExprCodeFactorable(tls, pParse, _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16), iRegStore) + goto _19 + } else { + k = i - nHidden + } + } + if useTempTable != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), srcTab, k, iRegStore) + } else { + if pSelect != 0 { + if regFromSelect != regData { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), regFromSelect+k, iRegStore) + } + } else { + pX = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(k)*32))).FpExpr + y = _sqlite3ExprCodeTarget(tls, pParse, pX, iRegStore) + if y != iRegStore { + if (*TExpr)(unsafe.Pointer(pX)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + v1 = int32(OP_Copy) + } else { + v1 = int32(OP_SCopy) + } + _sqlite3VdbeAddOp2(tls, v, v1, y, iRegStore) + } + } + } + goto _19 + _19: + ; + i = i + 1 + iRegStore = iRegStore + 1 + } + /* Run the BEFORE and INSTEAD OF triggers, if there are any + */ + endOfLoop = _sqlite3VdbeMakeLabel(tls, pParse) + if **(**int32)(__ccgo_up(bp + 48))&int32(TRIGGER_BEFORE) != 0 { + regCols = _sqlite3GetTempRange(tls, pParse, int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1)) + /* build the NEW.* reference row. Note that if there is an INTEGER + ** PRIMARY KEY into which a NULL is being inserted, that NULL will be + ** translated into a unique ID for the row. But on a BEFORE trigger, + ** we do not know what the unique ID will be (because the insert has + ** not happened yet) so we substitute a rowid of -1 + */ + if ipkColumn < 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), -int32(1), regCols) + } else { + if useTempTable != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), srcTab, ipkColumn, regCols) + } else { + /* Otherwise useTempTable is true */ + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ipkColumn)*32))).FpExpr, regCols) + } + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_NotNull), regCols) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), -int32(1), regCols) + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp1(tls, v, int32(OP_MustBeInt), regCols) + } + /* Copy the new data already generated. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regRowid+int32(1), regCols+int32(1), int32((*TTable)(unsafe.Pointer(pTab)).FnNVCol)-int32(1)) + /* Compute the new value for generated columns after all other + ** columns have already been computed. This must be done after + ** computing the ROWID in case one of the generated columns + ** refers to the ROWID. */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != 0 { + _sqlite3ComputeGeneratedColumns(tls, pParse, regCols+int32(1), pTab) + } + /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger, + ** do not attempt any conversions before assembling the record. + ** If this is a real table, attempt conversions as required by the + ** table column affinities. + */ + if !(isView != 0) { + _sqlite3TableAffinity(tls, v, pTab, regCols+int32(1)) + } + /* Fire BEFORE or INSTEAD OF triggers */ + _sqlite3CodeRowTrigger(tls, pParse, pTrigger, int32(TK_INSERT), uintptr(0), int32(TRIGGER_BEFORE), pTab, regCols-int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1), onError, endOfLoop) + _sqlite3ReleaseTempRange(tls, pParse, regCols, int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1)) + } + if !(isView != 0) { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + /* The row that the VUpdate opcode will delete: none */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regIns) + } + if ipkColumn >= 0 { + /* Compute the new rowid */ + if useTempTable != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), srcTab, ipkColumn, regRowid) + } else { + if pSelect != 0 { + /* Rowid already initialized at tag-20191021-001 */ + } else { + pIpk = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ipkColumn)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pIpk)).Fop) == int32(TK_NULL) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_NewRowid), **(**int32)(__ccgo_up(bp)), regRowid, regAutoinc) + appendFlag = uint8(1) + } else { + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ipkColumn)*32))).FpExpr, regRowid) + } + } + } + /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid + ** to generate a unique primary key value. + */ + if !(appendFlag != 0) { + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + addr11 = _sqlite3VdbeAddOp1(tls, v, int32(OP_NotNull), regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_NewRowid), **(**int32)(__ccgo_up(bp)), regRowid, regAutoinc) + _sqlite3VdbeJumpHere(tls, v, addr11) + } else { + addr11 = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regRowid, addr11+int32(2)) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_MustBeInt), regRowid) + } + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) || withoutRowid != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regRowid) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_NewRowid), **(**int32)(__ccgo_up(bp)), regRowid, regAutoinc) + appendFlag = uint8(1) + } + } + _autoIncStep(tls, pParse, regAutoinc, regRowid) + /* Compute the new value for generated columns after all other + ** columns have already been computed. This must be done after + ** computing the ROWID in case one of the generated columns + ** is derived from the INTEGER PRIMARY KEY. */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != 0 { + _sqlite3ComputeGeneratedColumns(tls, pParse, regRowid+int32(1), pTab) + } + /* Generate code to check constraints and generate index keys and + ** do the insertion. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + pVTab = _sqlite3GetVTable(tls, db, pTab) + _sqlite3VtabMakeWritable(tls, pParse, pTab) + _sqlite3VdbeAddOp4(tls, v, int32(OP_VUpdate), int32(1), int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(2), regIns, pVTab, -int32(12)) + if onError == int32(OE_Default) { + v1 = int32(OE_Abort) + } else { + v1 = onError + } + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(v1)) + _sqlite3MayAbort(tls, pParse) + } else { + **(**int32)(__ccgo_up(bp + 112)) = 0 /* True to use OPFLAG_SEEKRESULT */ + _sqlite3GenerateConstraintChecks(tls, pParse, pTab, aRegIdx, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), regIns, 0, libc.BoolUint8(ipkColumn >= 0), libc.Uint8FromInt32(onError), endOfLoop, bp+112, uintptr(0), pUpsert) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 { + _sqlite3FkCheck(tls, pParse, pTab, 0, regIns, uintptr(0), 0) + } + /* Set the OPFLAG_USESEEKRESULT flag if either (a) there are no REPLACE + ** constraints or (b) there are no triggers and this table is not a + ** parent table in a foreign key constraint. It is safe to set the + ** flag in the second case as if any REPLACE constraint is hit, an + ** OP_Delete or OP_IdxDelete instruction will be executed on each + ** cursor that is disturbed. And these instructions both clear the + ** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT + ** functionality. */ + bUseSeek = libc.BoolInt32(**(**int32)(__ccgo_up(bp + 112)) == 0 || !(_sqlite3VdbeHasSubProgram(tls, v) != 0)) + _sqlite3CompleteInsertion(tls, pParse, pTab, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), regIns, aRegIdx, 0, libc.Int32FromUint8(appendFlag), bUseSeek) + } + } + /* Update the count of rows that are inserted + */ + if regRowCount != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), regRowCount, int32(1)) + } + if pTrigger != 0 { + /* Code AFTER triggers */ + _sqlite3CodeRowTrigger(tls, pParse, pTrigger, int32(TK_INSERT), uintptr(0), int32(TRIGGER_AFTER), pTab, regData-int32(2)-int32((*TTable)(unsafe.Pointer(pTab)).FnCol), onError, endOfLoop) + } + /* The bottom of the main insertion loop, if the data source + ** is a SELECT statement. + */ + _sqlite3VdbeResolveLabel(tls, v, endOfLoop) + if useTempTable != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), srcTab, addrCont) + _sqlite3VdbeJumpHere(tls, v, addrInsTop) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), srcTab) + } else { + if pSelect != 0 { + _sqlite3VdbeGoto(tls, v, addrCont) + _sqlite3VdbeJumpHere(tls, v, addrInsTop) + } + } + goto insert_end +insert_end: + ; + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0) { + _sqlite3AutoincrementEnd(tls, pParse) + } + /* + ** Return the number of rows inserted. If this routine is + ** generating code because of a call to sqlite3NestedParse(), do not + ** invoke the callback function. + */ + if regRowCount != 0 { + _sqlite3CodeChangeCount(tls, v, regRowCount, __ccgo_ts+17570) + } + goto insert_cleanup +insert_cleanup: + ; + _sqlite3SrcListDelete(tls, db, pTabList) + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3UpsertDelete(tls, db, pUpsert) + _sqlite3SelectDelete(tls, db, pSelect) + if pColumn != 0 { + _sqlite3IdListDelete(tls, db, pColumn) + _sqlite3DbFree(tls, db, aTabColMap) + } + if aRegIdx != 0 { + _sqlite3DbNNFreeNN(tls, db, aRegIdx) + } +} + +/* Make sure "isView" and other macros defined above are undefined. Otherwise +** they may interfere with compilation of other functions in this file +** (or in another file, if this file becomes part of the amalgamation). */ + +/* +** Meanings of bits in of pWalker->eCode for +** sqlite3ExprReferencesUpdatedColumn() + */ + +// C documentation +// +// /* +// ** Given 1 to 3 identifiers preceding the JOIN keyword, determine the +// ** type of join. Return an integer constant that expresses that type +// ** in terms of the following bit values: +// ** +// ** JT_INNER +// ** JT_CROSS +// ** JT_OUTER +// ** JT_NATURAL +// ** JT_LEFT +// ** JT_RIGHT +// ** +// ** A full outer join is the combination of JT_LEFT and JT_RIGHT. +// ** +// ** If an illegal or unsupported join type is seen, then still return +// ** a join type, but put an error in the pParse structure. +// ** +// ** These are the valid join types: +// ** +// ** +// ** pA pB pC Return Value +// ** ------- ----- ----- ------------ +// ** CROSS - - JT_CROSS +// ** INNER - - JT_INNER +// ** LEFT - - JT_LEFT|JT_OUTER +// ** LEFT OUTER - JT_LEFT|JT_OUTER +// ** RIGHT - - JT_RIGHT|JT_OUTER +// ** RIGHT OUTER - JT_RIGHT|JT_OUTER +// ** FULL - - JT_LEFT|JT_RIGHT|JT_OUTER +// ** FULL OUTER - JT_LEFT|JT_RIGHT|JT_OUTER +// ** NATURAL INNER - JT_NATURAL|JT_INNER +// ** NATURAL LEFT - JT_NATURAL|JT_LEFT|JT_OUTER +// ** NATURAL LEFT OUTER JT_NATURAL|JT_LEFT|JT_OUTER +// ** NATURAL RIGHT - JT_NATURAL|JT_RIGHT|JT_OUTER +// ** NATURAL RIGHT OUTER JT_NATURAL|JT_RIGHT|JT_OUTER +// ** NATURAL FULL - JT_NATURAL|JT_LEFT|JT_RIGHT +// ** NATURAL FULL OUTER JT_NATRUAL|JT_LEFT|JT_RIGHT +// ** +// ** To preserve historical compatibly, SQLite also accepts a variety +// ** of other non-standard and in many cases nonsensical join types. +// ** This routine makes as much sense at it can from the nonsense join +// ** type and returns a result. Examples of accepted nonsense join types +// ** include but are not limited to: +// ** +// ** INNER CROSS JOIN -> same as JOIN +// ** NATURAL CROSS JOIN -> same as NATURAL JOIN +// ** OUTER LEFT JOIN -> same as LEFT JOIN +// ** LEFT NATURAL JOIN -> same as NATURAL LEFT JOIN +// ** LEFT RIGHT JOIN -> same as FULL JOIN +// ** RIGHT OUTER FULL JOIN -> same as FULL JOIN +// ** CROSS CROSS CROSS JOIN -> same as JOIN +// ** +// ** The only restrictions on the join type name are: +// ** +// ** * "INNER" cannot appear together with "OUTER", "LEFT", "RIGHT", +// ** or "FULL". +// ** +// ** * "CROSS" cannot appear together with "OUTER", "LEFT", "RIGHT, +// ** or "FULL". +// ** +// ** * If "OUTER" is present then there must also be one of +// ** "LEFT", "RIGHT", or "FULL" +// */ +func _sqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var apAll [3]uintptr + var i, j, jointype int32 + var p, zSp1, zSp2 uintptr + _, _, _, _, _, _, _ = apAll, i, j, jointype, p, zSp1, zSp2 + jointype = 0 + apAll[0] = pA + apAll[int32(1)] = pB + apAll[int32(2)] = pC + i = 0 + for { + if !(i < int32(3) && apAll[i] != 0) { + break + } + p = apAll[i] + j = 0 + for { + if !(j < libc.Int32FromUint64(libc.Uint64FromInt64(21)/libc.Uint64FromInt64(3))) { + break + } + if (*TToken)(unsafe.Pointer(p)).Fn == uint32(_aKeyword[j].FnChar) && Xsqlite3_strnicmp(tls, (*TToken)(unsafe.Pointer(p)).Fz, uintptr(unsafe.Pointer(&_zKeyText))+uintptr(_aKeyword[j].Fi), libc.Int32FromUint32((*TToken)(unsafe.Pointer(p)).Fn)) == 0 { + jointype = jointype | libc.Int32FromUint8(_aKeyword[j].Fcode) + break + } + goto _2 + _2: + ; + j = j + 1 + } + if j >= libc.Int32FromUint64(libc.Uint64FromInt64(21)/libc.Uint64FromInt64(3)) { + jointype = jointype | int32(JT_ERROR) + break + } + goto _1 + _1: + ; + i = i + 1 + } + if jointype&(libc.Int32FromInt32(JT_INNER)|libc.Int32FromInt32(JT_OUTER)) == libc.Int32FromInt32(JT_INNER)|libc.Int32FromInt32(JT_OUTER) || jointype&int32(JT_ERROR) != 0 || jointype&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_RIGHT)) == int32(JT_OUTER) { + zSp1 = __ccgo_ts + 11541 + zSp2 = __ccgo_ts + 11541 + if pB == uintptr(0) { + zSp1 = zSp1 + 1 + } + if pC == uintptr(0) { + zSp2 = zSp2 + 1 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20284, libc.VaList(bp+8, pA, zSp1, pB, zSp2, pC)) + jointype = int32(JT_INNER) + } + return jointype +} + +// C documentation +// +// /* +// ** Locate the in-memory structure that describes a particular database +// ** table given the name of that table and (optionally) the name of the +// ** database containing the table. Return NULL if not found. Also leave an +// ** error message in pParse->zErrMsg. +// ** +// ** The difference between this routine and sqlite3FindTable() is that this +// ** routine leaves an error message in pParse->zErrMsg where +// ** sqlite3FindTable() does not. +// */ +func _sqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags Tu32, zName uintptr, zDbase uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pMod, zMsg, v1 uintptr + _, _, _, _, _ = db, p, pMod, zMsg, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_SchemaKnownOk) == uint32(0) && SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + return uintptr(0) + } + p = _sqlite3FindTable(tls, db, zName, zDbase) + if p == uintptr(0) { + /* If zName is the not the name of a table in the schema created using + ** CREATE, then check to see if it is the name of an virtual table that + ** can be an eponymous virtual table. */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_NO_VTAB) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { + pMod = _sqlite3HashFind(tls, db+576, zName) + if pMod == uintptr(0) && Xsqlite3_strnicmp(tls, zName, __ccgo_ts+13686, int32(7)) == 0 { + pMod = _sqlite3PragmaVtabRegister(tls, db, zName) + } + if pMod == uintptr(0) && Xsqlite3_strnicmp(tls, zName, __ccgo_ts+13694, int32(4)) == 0 { + pMod = _sqlite3JsonVtabRegister(tls, db, zName) + } + if pMod != 0 && _sqlite3VtabEponymousTableInit(tls, pParse, pMod) != 0 { + return (*TModule)(unsafe.Pointer(pMod)).FpEpoTab + } + } + if flags&uint32(LOCATE_NOERR) != 0 { + return uintptr(0) + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == int32(TABTYP_VTAB) && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_NO_VTAB) != 0 { + p = uintptr(0) + } + } + if p == uintptr(0) { + if flags&uint32(LOCATE_VIEW) != 0 { + v1 = __ccgo_ts + 13699 + } else { + v1 = __ccgo_ts + 13712 + } + zMsg = v1 + if zDbase != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7020, libc.VaList(bp+8, zMsg, zDbase, zName)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7091, libc.VaList(bp+8, zMsg, zName)) + } + } else { + } + return p +} + +// C documentation +// +// /* +// ** Like malloc(), but remember the size of the allocation +// ** so that we can find it later using sqlite3MemSize(). +// ** +// ** For this low-level routine, we are guaranteed that nByte>0 because +// ** cases of nByte<=0 will be intercepted and dealt with by higher level +// ** routines. +// */ +func _sqlite3MemMalloc(tls *libc.TLS, nByte int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p uintptr + _ = p + p = libc.Xmalloc(tls, libc.Uint64FromInt32(nByte+int32(8))) + if p != 0 { + **(**Tsqlite3_int64)(__ccgo_up(p)) = int64(nByte) + p += 8 + } else { + Xsqlite3_log(tls, int32(SQLITE_NOMEM), __ccgo_ts+1600, libc.VaList(bp+8, nByte)) + } + return p +} + +// C documentation +// +// /* +// ** Like realloc(). Resize an allocation previously obtained from +// ** sqlite3MemMalloc(). +// ** +// ** For this low-level interface, we know that pPrior!=0. Cases where +// ** pPrior==0 while have been intercepted by higher-level routine and +// ** redirected to xMalloc. Similarly, we know that nByte>0 because +// ** cases where nByte<=0 will have been intercepted by higher-level +// ** routines and redirected to xFree. +// */ +func _sqlite3MemRealloc(tls *libc.TLS, pPrior uintptr, nByte int32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p uintptr + _ = p + p = pPrior + /* EV: R-46199-30249 */ + p -= 8 + p = libc.Xrealloc(tls, p, libc.Uint64FromInt32(nByte+libc.Int32FromInt32(8))) + if p != 0 { + **(**Tsqlite3_int64)(__ccgo_up(p)) = int64(nByte) + p += 8 + } else { + Xsqlite3_log(tls, int32(SQLITE_NOMEM), __ccgo_ts+1638, libc.VaList(bp+8, _sqlite3MemSize(tls, pPrior), nByte)) + } + return p +} + +// C documentation +// +// /* +// ** Cause a function to throw an error if it was call from OP_PureFunc +// ** rather than OP_Function. +// ** +// ** OP_PureFunc means that the function must be deterministic, and should +// ** throw an error if it is given inputs that would make it non-deterministic. +// ** This routine is invoked by date/time functions that use non-deterministic +// ** features such as 'now'. +// */ +func _sqlite3NotPureFunc(tls *libc.TLS, pCtx uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pOp, zContext, zMsg uintptr + _, _, _ = pOp, zContext, zMsg + if (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe == uintptr(0) { + return int32(1) + } + pOp = (*TVdbe)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe)).FaOp + uintptr((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FiOp)*24 + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_PureFunc) { + if libc.Int32FromUint16((*TVdbeOp)(unsafe.Pointer(pOp)).Fp5)&int32(NC_IsCheck) != 0 { + zContext = __ccgo_ts + 5422 + } else { + if libc.Int32FromUint16((*TVdbeOp)(unsafe.Pointer(pOp)).Fp5)&int32(NC_GenCol) != 0 { + zContext = __ccgo_ts + 5441 + } else { + zContext = __ccgo_ts + 5460 + } + } + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+5469, libc.VaList(bp+8, (*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpFunc)).FzName, zContext)) + Xsqlite3_result_error(tls, pCtx, zMsg, -int32(1)) + Xsqlite3_free(tls, zMsg) + return 0 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Call this routine to record the fact that an OOM (out-of-memory) error +// ** has happened. This routine will set db->mallocFailed, and also +// ** temporarily disable the lookaside memory allocator and interrupt +// ** any running VDBEs. +// ** +// ** Always return a NULL pointer so that this routine can be invoked using +// ** +// ** return sqlite3OomFault(db); +// ** +// ** and thereby avoid unnecessary stack frame allocations for the overwhelmingly +// ** common case where no OOM occurs. +// */ +func _sqlite3OomFault(tls *libc.TLS, db uintptr) (r uintptr) { + var pParse uintptr + _ = pParse + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc) == 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed = uint8(1) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > 0 { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(1), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + if (*Tsqlite3)(unsafe.Pointer(db)).FpParse != 0 { + _sqlite3ErrorMsg(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpParse, __ccgo_ts+1674, 0) + (*TParse)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpParse)).Frc = int32(SQLITE_NOMEM) + pParse = (*TParse)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpParse)).FpOuterParse + for { + if !(pParse != 0) { + break + } + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + goto _1 + _1: + ; + pParse = (*TParse)(unsafe.Pointer(pParse)).FpOuterParse + } + } + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Make sure the TEMP database is open and available for use. Return +// ** the number of errors. Leave any error messages in the pParse structure. +// */ +func _sqlite3OpenTempDatabase(tls *libc.TLS, pParse uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db uintptr + var rc int32 + var _ /* pBt at bp+0 */ uintptr + _, _ = db, rc + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt == uintptr(0) && !((*TParse)(unsafe.Pointer(pParse)).Fexplain != 0) { + rc = _sqlite3BtreeOpen(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, bp, 0, _flags) + if rc != SQLITE_OK { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16133, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + return int32(1) + } + (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt = **(**uintptr)(__ccgo_up(bp)) + if int32(SQLITE_NOMEM) == _sqlite3BtreeSetPageSize(tls, **(**uintptr)(__ccgo_up(bp)), (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { + _sqlite3OomFault(tls, db) + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** Turn bulk memory into a valid Parse object and link that Parse object +// ** into database connection db. +// ** +// ** Call sqlite3ParseObjectReset() to undo this operation. +// ** +// ** Caution: Do not confuse this routine with sqlite3ParseObjectInit() which +// ** is generated by Lemon. +// */ +func _sqlite3ParseObjectInit(tls *libc.TLS, pParse uintptr, db uintptr) { + libc.Xmemset(tls, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+8)), 0, uint64(libc.UintptrFromInt32(0)+184)-uint64(libc.UintptrFromInt32(0)+8)) + libc.Xmemset(tls, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), 0, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + (*TParse)(unsafe.Pointer(pParse)).FpOuterParse = (*Tsqlite3)(unsafe.Pointer(db)).FpParse + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = pParse + (*TParse)(unsafe.Pointer(pParse)).Fdb = db + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1674, 0) + } +} + +/* +** Maximum number of times that we will try again to prepare a statement +** that returns SQLITE_ERROR_RETRY. + */ + +// C documentation +// +// /* +// ** Generate code for the REINDEX command. +// ** +// ** REINDEX -- 1 +// ** REINDEX -- 2 +// ** REINDEX ?.? -- 3 +// ** REINDEX ?.? -- 4 +// ** REINDEX EXPRESSIONS -- 5 +// ** +// ** Form 1 causes all indexes in all attached databases to be rebuilt. +// ** Form 2 rebuilds all indexes in all databases that use the named +// ** collating function. Forms 3 and 4 rebuild the named index or all +// ** indexes associated with the named table, respectively. Form 5 +// ** rebuilds all expression indexes in addition to all collations, +// ** indexes, or tables named "EXPRESSIONS". +// ** +// ** If the name is ambiguous such that it matches two or more of +// ** forms 2 through 5, then rebuild the union of all matching indexes, +// ** taken care to avoid rebuilding the same index more than once. +// */ +func _sqlite3Reindex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bAll, bMatch, iDb, iReDb, isExprIdx int32 + var db, k, pDb, pIdx, pReIndex, pReTab, pTab, z, zColl, zDb, v1 uintptr + var v2 bool + var _ /* pObjName at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bAll, bMatch, db, iDb, iReDb, isExprIdx, k, pDb, pIdx, pReIndex, pReTab, pTab, z, zColl, zDb, v1, v2 + z = uintptr(0) /* Name of a table or index or collation */ + zDb = uintptr(0) /* Name of the database */ + iReDb = -int32(1) /* The database index number */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Name of the table or index to be reindexed */ + bMatch = 0 /* At least one name match */ + zColl = uintptr(0) /* Rebuild indexes using this collation */ + pReTab = uintptr(0) /* Rebuild all indexes of this table */ + pReIndex = uintptr(0) /* Rebuild this index */ + isExprIdx = 0 /* Rebuild all expression indexes */ + bAll = 0 /* Rebuild all indexes */ + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + return + } + if pName1 == uintptr(0) { + /* rebuild all indexes */ + bMatch = int32(1) + bAll = int32(1) + } else { + if pName2 == uintptr(0) || (*TToken)(unsafe.Pointer(pName2)).Fz == uintptr(0) { + z = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pName1) + if z == uintptr(0) { + return + } + } else { + iReDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp) + if iReDb < 0 { + return + } + z = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if z == uintptr(0) { + return + } + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iReDb)*32))).FzDbSName + } + } + if !(bAll != 0) { + if zDb == uintptr(0) && _sqlite3StrICmp(tls, z, __ccgo_ts+16226) == 0 { + isExprIdx = int32(1) + bMatch = int32(1) + } + if zDb == uintptr(0) && _sqlite3FindCollSeq(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, z, 0) != uintptr(0) { + zColl = z + bMatch = int32(1) + } + if v2 = zColl == uintptr(0); v2 { + v1 = _sqlite3FindTable(tls, db, z, zDb) + pReTab = v1 + } + if v2 && v1 != uintptr(0) { + bMatch = int32(1) + } + if v2 = zColl == uintptr(0); v2 { + v1 = _sqlite3FindIndex(tls, db, z, zDb) + pReIndex = v1 + } + if v2 && v1 != uintptr(0) { + bMatch = int32(1) + } + } + if bMatch != 0 { + iDb = 0 + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + for { + if !(iDb < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if iReDb >= 0 && iReDb != iDb { + goto _5 + } + k = (*THash)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema + 8)).Ffirst + for { + if !(k != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(k)).Fdata + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + goto _6 + } + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if bAll != 0 || pTab == pReTab || pIdx == pReIndex || isExprIdx != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x800>>11)) != 0 || zColl != uintptr(0) && _collationMatch(tls, zColl, pIdx) != 0 { + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + _sqlite3RefillIndex(tls, pParse, pIdx, -int32(1)) + } + goto _7 + _7: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } /* End loop over indexes of pTab */ + goto _6 + _6: + ; + k = (*THashElem)(unsafe.Pointer(k)).Fnext + } /* End loop over tables of iDb */ + goto _5 + _5: + ; + iDb = iDb + 1 + pDb += 32 + } /* End loop over databases */ + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16238, 0) + } + _sqlite3DbFree(tls, db, z) + return +} + +// C documentation +// +// /* +// ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of +// ** the SELECT statement pSelect. If any term is reference to a +// ** result set expression (as determined by the ExprList.a.u.x.iOrderByCol +// ** field) then convert that term into a copy of the corresponding result set +// ** column. +// ** +// ** If any errors are detected, add an error message to pParse and +// ** return non-zero. Return zero if no errors are seen. +// */ +func _sqlite3ResolveOrderGroupBy(tls *libc.TLS, pParse uintptr, pSelect uintptr, pOrderBy uintptr, zType uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pEList, pItem uintptr + var i int32 + _, _, _, _ = db, i, pEList, pItem + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pOrderBy == uintptr(0) || (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return 0 + } + if (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7726, libc.VaList(bp+8, zType)) + return int32(1) + } + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + /* sqlite3SelectNew() guarantees this */ + i = 0 + pItem = pOrderBy + 8 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + if (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol != 0 { + if libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol) > (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + _resolveOutOfRangeError(tls, pParse, zType, i+int32(1), (*TExprList)(unsafe.Pointer(pEList)).FnExpr, uintptr(0)) + return int32(1) + } + _resolveAlias(tls, pParse, pEList, libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol)-int32(1), (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr, 0) + } + goto _1 + _1: + ; + i = i + 1 + pItem += 32 + } + return 0 +} + +// C documentation +// +// /* +// ** Return a pointer to a buffer containing a usable rowid alias for table +// ** pTab. An alias is usable if there is not an explicit user-defined column +// ** of the same name. +// */ +func _sqlite3RowidAlias(tls *libc.TLS, pTab uintptr) (r uintptr) { + var azOpt [3]uintptr + var ii int32 + _, _ = azOpt, ii + azOpt = [3]uintptr{ + 0: __ccgo_ts + 8189, + 1: __ccgo_ts + 8197, + 2: __ccgo_ts + 8203, + } + ii = 0 + for { + if !(ii < libc.Int32FromUint64(libc.Uint64FromInt64(24)/libc.Uint64FromInt64(8))) { + break + } + if _sqlite3ColumnIndex(tls, pTab, azOpt[ii]) < 0 { + return azOpt[ii] + } + goto _1 + _1: + ; + ii = ii + 1 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Code an OP_Halt due to non-unique rowid. +// */ +func _sqlite3RowidConstraint(tls *libc.TLS, pParse uintptr, onError int32, pTab uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc int32 + var zMsg uintptr + _, _ = rc, zMsg + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) >= 0 { + zMsg = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+13632, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TTable)(unsafe.Pointer(pTab)).FiPKey)*16))).FzCnName)) + rc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(6)<zErrMsg. +// ** +// ** This routine does NOT free the Select structure passed in. The +// ** calling function needs to do that. +// ** +// ** This is a long function. The following is an outline of the processing +// ** steps, with tags referencing various milestones: +// ** +// ** * Resolve names and similar preparation tag-select-0100 +// ** * Scan of the FROM clause tag-select-0200 +// ** + OUTER JOIN strength reduction tag-select-0220 +// ** + Sub-query ORDER BY removal tag-select-0230 +// ** + Query flattening tag-select-0240 +// ** * Separate subroutine for compound-SELECT tag-select-0300 +// ** * WHERE-clause constant propagation tag-select-0330 +// ** * Count()-of-VIEW optimization tag-select-0350 +// ** * Scan of the FROM clause again tag-select-0400 +// ** + Authorize unreferenced tables tag-select-0410 +// ** + Predicate push-down optimization tag-select-0420 +// ** + Omit unused subquery columns optimization tag-select-0440 +// ** + Generate code to implement subqueries tag-select-0480 +// ** - Co-routines tag-select-0482 +// ** - Reuse previously computed CTE tag-select-0484 +// ** - REuse previously computed VIEW tag-select-0486 +// ** - Materialize a VIEW or CTE tag-select-0488 +// ** * DISTINCT ORDER BY -> GROUP BY optimization tag-select-0500 +// ** * Set up for ORDER BY tag-select-0600 +// ** * Create output table tag-select-0630 +// ** * Prepare registers for LIMIT tag-select-0650 +// ** * Setup for DISTINCT tag-select-0680 +// ** * Generate code for non-aggregate and non-GROUP BY tag-select-0700 +// ** * Generate code for aggregate and/or GROUP BY tag-select-0800 +// ** + GROUP BY queries tag-select-0810 +// ** + non-GROUP BY queries tag-select-0820 +// ** - Special case of count() w/o GROUP BY tag-select-0821 +// ** - General case of non-GROUP BY aggregates tag-select-0822 +// ** * Sort results, as needed tag-select-0900 +// ** * Internal self-checks tag-select-1000 +// */ +func _sqlite3Select(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var addr1, addrEnd, addrGosub, addrOutputRow, addrReset, addrSetAbort, addrSortingIdx, addrTop, addrTopOfLoop, eDist, eDist1, groupBySort, i, iAMem, iAbortFlag, iBMem, iBreak, iCont, iCsr, iDb, iDb1, iEnd, iOrderByCol, iUseFlag, ii, isAgg, j, k, nCol, nGroupBy, onceAddr, orderByGrp, rc, regAcc, regBase, regGosub, regOutputRow, regRecord, regReset, sortOut, sortPTab, topAddr, v12, v15 int32 + var db, p0, pAggInfo, pBase, pBest, pCol, pCteUse, pCteUse1, pDistinct, pDistinct1, pEList, pExpr, pF, pF1, pGroupBy, pHaving, pI2, pIdx, pItem, pItem1, pItem2, pKeyInfo, pKeyInfo1, pKeyInfo2, pPrior, pPriorSubq, pSub, pSub1, pSubq, pTab, pTab1, pTabList, pWInfo, pWhere, pWin, pX, v, zDb, zSavedAuthContext, v1, v3 uintptr + var distFlag, distFlag1, wctrlFlags Tu16 + var iRoot TPgno + var minMaxFlag Tu8 + var _ /* dest at bp+72 */ TSelectDest + var _ /* pMinMaxOrderBy at bp+64 */ uintptr + var _ /* sDistinct at bp+0 */ TDistinctCtx + var _ /* sNC at bp+112 */ TNameContext + var _ /* sSort at bp+16 */ TSortCtx + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, addrEnd, addrGosub, addrOutputRow, addrReset, addrSetAbort, addrSortingIdx, addrTop, addrTopOfLoop, db, distFlag, distFlag1, eDist, eDist1, groupBySort, i, iAMem, iAbortFlag, iBMem, iBreak, iCont, iCsr, iDb, iDb1, iEnd, iOrderByCol, iRoot, iUseFlag, ii, isAgg, j, k, minMaxFlag, nCol, nGroupBy, onceAddr, orderByGrp, p0, pAggInfo, pBase, pBest, pCol, pCteUse, pCteUse1, pDistinct, pDistinct1, pEList, pExpr, pF, pF1, pGroupBy, pHaving, pI2, pIdx, pItem, pItem1, pItem2, pKeyInfo, pKeyInfo1, pKeyInfo2, pPrior, pPriorSubq, pSub, pSub1, pSubq, pTab, pTab1, pTabList, pWInfo, pWhere, pWin, pX, rc, regAcc, regBase, regGosub, regOutputRow, regRecord, regReset, sortOut, sortPTab, topAddr, v, wctrlFlags, zDb, zSavedAuthContext, v1, v12, v15, v3 /* True for select lists like "count(*)" */ + pEList = uintptr(0) /* The HAVING clause. May be NULL */ + pAggInfo = uintptr(0) /* Aggregate information */ + rc = int32(1) /* The database connection */ + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) /* Flag for min/max queries */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = _sqlite3GetVdbe(tls, pParse) + if p == uintptr(0) || (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(1) + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_SELECT), uintptr(0), uintptr(0), uintptr(0)) != 0 { + return int32(1) + } + /* tag-select-0100 */ + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) <= int32(SRT_DistQueue) { + /* All of these destinations are also able to ignore the ORDER BY clause */ + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprListDeleteGeneric), (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + } + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Distinct) + } + _sqlite3SelectPrep(tls, pParse, p, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto select_end + } + /* If the SF_UFSrcCheck flag is set, then this function is being called + ** as part of populating the temp table for an UPDATE...FROM statement. + ** In this case, it is an error if the target object (pSrc->a[0]) name + ** or alias is duplicated within FROM clause (pSrc->a[1..n]). + ** + ** Postgres disallows this case too. The reason is that some other + ** systems handle this case differently, and not all the same way, + ** which is just confusing. To avoid this, we follow PG's lead and + ** disallow it altogether. */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_UFSrcCheck) != 0 { + p0 = (*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + if _sameSrcAlias(tls, p0, (*TSelect)(unsafe.Pointer(p)).FpSrc) != 0 { + if (*TSrcItem)(unsafe.Pointer(p0)).FzAlias != 0 { + v1 = (*TSrcItem)(unsafe.Pointer(p0)).FzAlias + } else { + v1 = (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(p0)).FpSTab)).FzName + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21588, libc.VaList(bp+176, v1)) + goto select_end + } + /* Clear the SF_UFSrcCheck flag. The check has already been performed, + ** and leaving this flag set can cause errors if a compound sub-query + ** in p->pSrc is flattened into this query and this function called + ** again as part of compound SELECT processing. */ + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_UFSrcCheck) + } + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) == int32(SRT_Output) { + _sqlite3GenerateColumnNames(tls, pParse, p) + } + if _sqlite3WindowRewrite(tls, pParse, p) != 0 { + goto select_end + } + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + isAgg = libc.BoolInt32((*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Aggregate) != uint32(0)) + libc.Xmemset(tls, bp+16, 0, uint64(48)) + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + /* Try to do various optimizations (flattening subqueries, and strength + ** reduction of join operators) in the FROM clause up into the main query + ** tag-select-0200 + */ + i = 0 + for { + if !(!((*TSelect)(unsafe.Pointer(p)).FpPrior != 0) && i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + pItem = pTabList + 8 + uintptr(i)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { + v1 = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + } else { + v1 = uintptr(0) + } + pSub = v1 + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + /* The expander should have already created transient Table objects + ** even for FROM clause elements such as subqueries that do not correspond + ** to a real table */ + /* Try to simplify joins: + ** + ** LEFT JOIN -> JOIN + ** RIGHT JOIN -> JOIN + ** FULL JOIN -> RIGHT JOIN + ** + ** If terms of the i-th table are used in the WHERE clause in such a + ** way that the i-th table cannot be the NULL row of a join, then + ** perform the appropriate simplification. This is called + ** "OUTER JOIN strength reduction" in the SQLite documentation. + ** tag-select-0220 + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0 && _sqlite3ExprImpliesNonNullRow(tls, (*TSelect)(unsafe.Pointer(p)).FpWhere, (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor, libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LTORJ)) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_SimplifyJoin)) == uint32(0) { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + v1 = pItem + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(JT_LEFT)) + } else { + v1 = pItem + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(JT_LEFT) | libc.Int32FromInt32(JT_OUTER))) + _unsetJoinExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpWhere, (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor, 0) + } + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + j = i + int32(1) + for { + if !(j < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + pI2 = pTabList + 8 + uintptr(j)*80 + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pI2)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pI2)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + v1 = pI2 + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(JT_RIGHT)) + } else { + v1 = pI2 + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(JT_RIGHT) | libc.Int32FromInt32(JT_OUTER))) + _unsetJoinExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpWhere, (*TSrcItem)(unsafe.Pointer(pI2)).FiCursor, int32(1)) + } + } + goto _6 + _6: + ; + j = j + 1 + } + j = (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc - int32(1) + for { + if !(j >= 0) { + break + } + v1 = pTabList + 8 + uintptr(j)*80 + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(JT_LTORJ)) + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(j)*80))).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + break + } + goto _9 + _9: + ; + j = j - 1 + } + } + } + /* No further action if this term of the FROM clause is not a subquery */ + if pSub == uintptr(0) { + goto _2 + } + /* Catch mismatch in the declared columns of a view and the number of + ** columns in the SELECT on the RHS */ + if int32((*TTable)(unsafe.Pointer(pTab)).FnCol) != (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpEList)).FnExpr { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+21642, libc.VaList(bp+176, int32((*TTable)(unsafe.Pointer(pTab)).FnCol), (*TTable)(unsafe.Pointer(pTab)).FzName, (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpEList)).FnExpr)) + goto select_end + } + /* Do not attempt the usual optimizations (flattening and ORDER BY + ** elimination) on a MATERIALIZED common table expression because + ** a MATERIALIZED common table expression is an optimization fence. + */ + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x200>>9) != 0 && libc.Int32FromUint8((*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 56)))).FeM10d) == M10d_Yes { + goto _2 + } + /* Do not try to flatten an aggregate subquery. + ** + ** Flattening an aggregate subquery is only possible if the outer query + ** is not a join. But if the outer query is not a join, then the subquery + ** will be implemented as a co-routine and there is no advantage to + ** flattening in that case. + */ + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&uint32(SF_Aggregate) != uint32(0) { + goto _2 + } + /* tag-select-0230: + ** If a FROM-clause subquery has an ORDER BY clause that is not + ** really doing anything, then delete it now so that it does not + ** interfere with query flattening. See the discussion at + ** https://sqlite.org/forum/forumpost/2d76f2bcf65d256a + ** + ** Beware of these cases where the ORDER BY clause may not be safely + ** omitted: + ** + ** (1) There is also a LIMIT clause + ** (2) The subquery was added to help with window-function + ** processing + ** (3) The subquery is in the FROM clause of an UPDATE + ** (4) The outer query uses an aggregate function other than + ** the built-in count(), min(), or max(). + ** (5) The ORDER BY isn't going to accomplish anything because + ** one of: + ** (a) The outer query has a different ORDER BY clause + ** (b) The subquery is part of a join + ** See forum post 062d576715d277c8 + ** (6) The subquery is not a recursive CTE. ORDER BY has a different + ** meaning for recursive CTEs and this optimization does not + ** apply. + ** + ** Also retain the ORDER BY if the OmitOrderBy optimization is disabled. + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != uintptr(0) && ((*TSelect)(unsafe.Pointer(p)).FpOrderBy != uintptr(0) || (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc > int32(1)) && (*TSelect)(unsafe.Pointer(pSub)).FpLimit == uintptr(0) && (*TSelect)(unsafe.Pointer(pSub)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_OrderByReqd)|libc.Int32FromInt32(SF_Recursive)) == uint32(0) && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_OrderByReqd) == uint32(0) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OmitOrderBy)) == uint32(0) { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprListDeleteGeneric), (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy) + (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0) + } + /* If the outer query contains a "complex" result set (that is, + ** if the result set of the outer query uses functions or subqueries) + ** and if the subquery contains an ORDER BY clause and if + ** it will be implemented as a co-routine, then do not flatten. This + ** restriction allows SQL constructs like this: + ** + ** SELECT expensive_function(x) + ** FROM (SELECT x FROM tab ORDER BY y LIMIT 10); + ** + ** The expensive_function() is only computed on the 10 rows that + ** are output, rather than every row of the table. + ** + ** The requirement that the outer query have a complex result set + ** means that flattening does occur on simpler SQL constraints without + ** the expensive_function() like: + ** + ** SELECT x FROM (SELECT x FROM tab ORDER BY y LIMIT 10); + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != uintptr(0) && i == 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_ComplexResult) != uint32(0) && ((*TSrcList)(unsafe.Pointer(pTabList)).FnSrc == int32(1) || libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + 1*80))).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)) != 0) { + goto _2 + } + /* tag-select-0240 */ + if _flattenSubquery(tls, pParse, p, i, isAgg) != 0 { + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto select_end + } + /* This subquery can be absorbed into its parent. */ + i = -int32(1) + } + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + if !(libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) <= libc.Int32FromInt32(SRT_Fifo)) { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + } + goto _2 + _2: + ; + i = i + 1 + } + /* Handle compound SELECT statements using the separate multiSelect() + ** procedure. tag-select-0300 + */ + if (*TSelect)(unsafe.Pointer(p)).FpPrior != 0 { + rc = _multiSelect(tls, pParse, p, pDest) + if (*TSelect)(unsafe.Pointer(p)).FpNext == uintptr(0) { + _sqlite3VdbeExplainPop(tls, pParse) + } + return rc + } + /* If there may be an "EXISTS (SELECT ...)" in the WHERE clause, attempt + ** to change it into a join. */ + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x10>>4)) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_ExistsToJoin)) == uint32(0) { + _existsToJoin(tls, pParse, p, (*TSelect)(unsafe.Pointer(p)).FpWhere) + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + } + /* Do the WHERE-clause constant propagation optimization if this is + ** a join. No need to spend time on this operation for non-join queries + ** as the equivalent optimization will be handled by query planner in + ** sqlite3WhereBegin(). tag-select-0330 + */ + if (*TSelect)(unsafe.Pointer(p)).FpWhere != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpWhere)).Fop) == int32(TK_AND) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_PropagateConst)) == uint32(0) && _propagateConstants(tls, pParse, p) != 0 { + } else { + } + /* tag-select-0350 */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_QueryFlattener)|libc.Int32FromInt32(SQLITE_CountOfView)) == uint32(0) && _countOfViewOptimization(tls, pParse, p) != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + } + /* Loop over all terms in the FROM clause and do two things for each term: + ** + ** (1) Authorize unreferenced tables + ** (2) Generate code for all sub-queries + ** + ** tag-select-0400 + */ + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + pItem1 = pTabList + 8 + uintptr(i)*80 + /* Authorized unreferenced tables. tag-select-0410 + ** + ** Issue SQLITE_READ authorizations with a fake column name for any + ** tables that are referenced but from which no values are extracted. + ** Examples of where these kinds of null SQLITE_READ authorizations + ** would occur: + ** + ** SELECT count(*) FROM t1; -- SQLITE_READ t1."" + ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2."" + ** + ** The fake column name is an empty string. It is possible for a table to + ** have a column named by the empty string, in which case there is no way to + ** distinguish between an unreferenced table and an actual reference to the + ** "" column. The original design was for the fake column name to be a NULL, + ** which would be unambiguous. But legacy authorization callbacks might + ** assume the column name is non-NULL and segfault. The use of an empty + ** string for the fake column name seems safer. + */ + if (*TSrcItem)(unsafe.Pointer(pItem1)).FcolUsed == uint64(0) && (*TSrcItem)(unsafe.Pointer(pItem1)).FzName != uintptr(0) { + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x10000>>16) != 0 { + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(pItem1 + 72))) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x4>>2) != 0 { + zDb = uintptr(0) + } else { + zDb = *(*uintptr)(unsafe.Pointer(pItem1 + 72)) + } + } + _sqlite3AuthCheck(tls, pParse, int32(SQLITE_READ), (*TSrcItem)(unsafe.Pointer(pItem1)).FzName, __ccgo_ts+1704, zDb) + } + /* Generate code for all sub-queries in the FROM clause + */ + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x4>>2) == 0 { + goto _11 + } + pSubq = *(*uintptr)(unsafe.Pointer(pItem1 + 72)) + pSub1 = (*TSubquery)(unsafe.Pointer(pSubq)).FpSelect + /* The code for a subquery should only be generated once. */ + if (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub != 0 { + goto _11 + } + /* Increment Parse.nHeight by the height of the largest expression + ** tree referred to by this, the parent select. The child select + ** may contain expression trees of at most + ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit + ** more conservative than necessary, but much easier than enforcing + ** an exact limit. + */ + **(**int32)(__ccgo_up(pParse + 308)) += _sqlite3SelectExprHeight(tls, p) + /* Make copies of constant WHERE-clause terms in the outer query down + ** inside the subquery. This can help the subquery to run more efficiently. + ** This is the "predicate push-down optimization". tag-select-0420 + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_PushDown)) == uint32(0) && (int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x200>>9) == 0 || libc.Int32FromUint8((*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 56)))).FeM10d) != M10d_Yes && (*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 56)))).FnUse < int32(2)) && _pushDownWhereTerms(tls, pParse, pSub1, (*TSelect)(unsafe.Pointer(p)).FpWhere, pTabList, i) != 0 { + } else { + } + /* Convert unused result columns of the subquery into simple NULL + ** expressions, to avoid unneeded searching and computation. + ** tag-select-0440 + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_NullUnusedCols)) == uint32(0) && _disableUnusedSubqueryResultColumns(tls, pItem1) != 0 { + } + zSavedAuthContext = (*TParse)(unsafe.Pointer(pParse)).FzAuthContext + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = (*TSrcItem)(unsafe.Pointer(pItem1)).FzName + /* Generate byte-code to implement the subquery tag-select-0480 + */ + if _fromClauseTermCanBeCoroutine(tls, pParse, pTabList, i, libc.Int32FromUint32((*TSelect)(unsafe.Pointer(p)).FselFlags)) != 0 { + /* Implement a co-routine that will return a single row of the result + ** set on each invocation. tag-select-0482 + */ + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn = v12 + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn, 0, addrTop) + (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub = addrTop + _sqlite3SelectDestInit(tls, bp+72, int32(SRT_Coroutine), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21682, libc.VaList(bp+176, pItem1)) + _sqlite3Select(tls, pParse, pSub1, bp+72) + (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem1)).FpSTab)).FnRowLogEst = (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow + libc.SetBitFieldPtr32Uint32(pItem1+24+4, libc.Uint32FromInt32(1), 6, 0x40) + (*TSubquery)(unsafe.Pointer(pSubq)).FregResult = (**(**TSelectDest)(__ccgo_up(bp + 72))).FiSdst + _sqlite3VdbeEndCoroutine(tls, v, (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn) + _sqlite3VdbeJumpHere(tls, v, addrTop-int32(1)) + _sqlite3ClearTempRegCache(tls, pParse) + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x200>>9) != 0 && (*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 56)))).FaddrM9e > 0 { + /* This is a CTE for which materialization code has already been + ** generated. Invoke the subroutine to compute the materialization, + ** then make the pItem->iCursor be a copy of the ephemeral table that + ** holds the result of the materialization. tag-select-0484 */ + pCteUse = *(*uintptr)(unsafe.Pointer(pItem1 + 56)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TCteUse)(unsafe.Pointer(pCteUse)).FregRtn, (*TCteUse)(unsafe.Pointer(pCteUse)).FaddrM9e) + if (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor != (*TCteUse)(unsafe.Pointer(pCteUse)).FiCur { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor, (*TCteUse)(unsafe.Pointer(pCteUse)).FiCur) + } + (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow = (*TCteUse)(unsafe.Pointer(pCteUse)).FnRowEst + } else { + v1 = _isSelfJoinView(tls, pTabList, pItem1, 0, i) + pPrior = v1 + if v1 != uintptr(0) { + pPriorSubq = *(*uintptr)(unsafe.Pointer(pPrior + 72)) + if (*TSubquery)(unsafe.Pointer(pPriorSubq)).FaddrFillSub != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TSubquery)(unsafe.Pointer(pPriorSubq)).FregReturn, (*TSubquery)(unsafe.Pointer(pPriorSubq)).FaddrFillSub) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor, (*TSrcItem)(unsafe.Pointer(pPrior)).FiCursor) + (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow = (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(pPriorSubq)).FpSelect)).FnSelectRow + } else { + onceAddr = 0 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn = v12 + topAddr = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub = topAddr + int32(1) + libc.SetBitFieldPtr32Uint32(pItem1+24+4, libc.Uint32FromInt32(1), 5, 0x20) + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x10>>4) == 0 { + /* If the subquery is not correlated and if we are not inside of + ** a trigger, then we only need to compute the value of the subquery + ** once. */ + onceAddr = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } else { + } + _sqlite3SelectDestInit(tls, bp+72, int32(SRT_EphemTab), (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+21697, libc.VaList(bp+176, pItem1)) + _sqlite3Select(tls, pParse, pSub1, bp+72) + (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem1)).FpSTab)).FnRowLogEst = (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow + if onceAddr != 0 { + _sqlite3VdbeJumpHere(tls, v, onceAddr) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Return), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn, topAddr+int32(1)) + _sqlite3VdbeJumpHere(tls, v, topAddr) + _sqlite3ClearTempRegCache(tls, pParse) + if int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x200>>9) != 0 && int32(*(*uint32)(unsafe.Pointer(pItem1 + 24 + 4))&0x10>>4) == 0 { + pCteUse1 = *(*uintptr)(unsafe.Pointer(pItem1 + 56)) + (*TCteUse)(unsafe.Pointer(pCteUse1)).FaddrM9e = (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub + (*TCteUse)(unsafe.Pointer(pCteUse1)).FregRtn = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + (*TCteUse)(unsafe.Pointer(pCteUse1)).FiCur = (*TSrcItem)(unsafe.Pointer(pItem1)).FiCursor + (*TCteUse)(unsafe.Pointer(pCteUse1)).FnRowEst = (*TSelect)(unsafe.Pointer(pSub1)).FnSelectRow + } + } + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + **(**int32)(__ccgo_up(pParse + 308)) -= _sqlite3SelectExprHeight(tls, p) + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedAuthContext + goto _11 + _11: + ; + i = i + 1 + } + /* Various elements of the SELECT copied into local variables for + ** convenience */ + pEList = (*TSelect)(unsafe.Pointer(p)).FpEList + pWhere = (*TSelect)(unsafe.Pointer(p)).FpWhere + pGroupBy = (*TSelect)(unsafe.Pointer(p)).FpGroupBy + pHaving = (*TSelect)(unsafe.Pointer(p)).FpHaving + (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct = libc.BoolUint8((*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != uint32(0)) + /* tag-select-0500 + ** + ** If the query is DISTINCT with an ORDER BY but is not an aggregate, and + ** if the select-list is the same as the ORDER BY list, then this query + ** can be rewritten as a GROUP BY. In other words, this: + ** + ** SELECT DISTINCT xyz FROM ... ORDER BY xyz + ** + ** is transformed to: + ** + ** SELECT xyz FROM ... GROUP BY xyz ORDER BY xyz + ** + ** The second form is preferred as a single index (or temp-table) may be + ** used for both the ORDER BY and DISTINCT processing. As originally + ** written the query must use a temp-table for at least one of the ORDER + ** BY and DISTINCT, and an index or separate temp-table for the other. + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Distinct)|libc.Int32FromInt32(SF_Aggregate)) == uint32(SF_Distinct) && _sqlite3CopySortOrder(tls, pEList, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy) != 0 && _sqlite3ExprListCompare(tls, pEList, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy, -int32(1)) == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_GroupByOrder)) == uint32(0) && (*TSelect)(unsafe.Pointer(p)).FpWin == uintptr(0) { + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Distinct) + v1 = _sqlite3ExprListDup(tls, db, pEList, 0) + (*TSelect)(unsafe.Pointer(p)).FpGroupBy = v1 + pGroupBy = v1 + if pGroupBy != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { + break + } + *(*Tu16)(unsafe.Pointer(pGroupBy + 8 + uintptr(i)*32 + 24)) = libc.Uint16FromInt32(i + int32(1)) + goto _18 + _18: + ; + i = i + 1 + } + } + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_Aggregate) + /* Notice that even thought SF_Distinct has been cleared from p->selFlags, + ** the sDistinct.isTnct is still set. Hence, isTnct represents the + ** original setting of the SF_Distinct flag, not the current setting */ + (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct = uint8(2) + } + /* If there is an ORDER BY clause, then create an ephemeral index to + ** do the sorting. But this sorting ephemeral index might end up + ** being unused if the data can be extracted in pre-sorted order. + ** If that is the case, then the OP_OpenEphemeral instruction will be + ** changed to an OP_Noop once we figure out that the sorting index is + ** not needed. The sSort.addrSortIndex variable is used to facilitate + ** that change. tag-select-0600 + */ + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy != 0 { + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy, 0, (*TExprList)(unsafe.Pointer(pEList)).FnExpr) + v1 = pParse + 56 + v12 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + (**(**TSortCtx)(__ccgo_up(bp + 16))).FiECursor = v12 + (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex = _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), (**(**TSortCtx)(__ccgo_up(bp + 16))).FiECursor, (*TExprList)(unsafe.Pointer((**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy)).FnExpr+int32(1)+(*TExprList)(unsafe.Pointer(pEList)).FnExpr, 0, pKeyInfo, -int32(9)) + } else { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex = -int32(1) + } + /* If the output is destined for a temporary table, open that table. + ** tag-select-0630 + */ + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) == int32(SRT_EphemTab) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*TExprList)(unsafe.Pointer(pEList)).FnExpr) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_NestedFrom) != 0 { + ii = (*TExprList)(unsafe.Pointer(pEList)).FnExpr - int32(1) + for { + if !(ii > 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32 + 16 + 4))&0x40>>6)) == 0) { + break + } + _sqlite3ExprDelete(tls, db, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32))).FpExpr) + _sqlite3DbFree(tls, db, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32))).FzEName) + (*TExprList)(unsafe.Pointer(pEList)).FnExpr = (*TExprList)(unsafe.Pointer(pEList)).FnExpr - 1 + goto _21 + _21: + ; + ii = ii - 1 + } + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32 + 16 + 4))&0x40>>6)) == 0 { + (*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*32))).FpExpr)).Fop = uint8(TK_NULL) + } + goto _22 + _22: + ; + ii = ii + 1 + } + } + } + /* Set the limiter. tag-select-0650 + */ + iEnd = _sqlite3VdbeMakeLabel(tls, pParse) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_FixedLimit) == uint32(0) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(320) /* 4 billion rows */ + } + if (*TSelect)(unsafe.Pointer(p)).FpLimit != 0 { + _computeLimitRegisters(tls, pParse, p, iEnd) + } + if (*TSelect)(unsafe.Pointer(p)).FiLimit == 0 && (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex >= 0 { + _sqlite3VdbeChangeOpcode(tls, v, (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex, uint8(OP_SorterOpen)) + v1 = bp + 16 + 36 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SORTFLAG_UseSorter)) + } + /* Open an ephemeral index to use for the distinct set. tag-select-0680 + */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != 0 { + v1 = pParse + 56 + v12 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + (**(**TDistinctCtx)(__ccgo_up(bp))).FtabTnct = v12 + (**(**TDistinctCtx)(__ccgo_up(bp))).FaddrTnct = _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenEphemeral), (**(**TDistinctCtx)(__ccgo_up(bp))).FtabTnct, 0, 0, _sqlite3KeyInfoFromExprList(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpEList, 0, 0), -int32(9)) + _sqlite3VdbeChangeP5(tls, v, uint16(BTREE_UNORDERED)) + (**(**TDistinctCtx)(__ccgo_up(bp))).FeTnctType = uint8(WHERE_DISTINCT_UNORDERED) + } else { + (**(**TDistinctCtx)(__ccgo_up(bp))).FeTnctType = uint8(WHERE_DISTINCT_NOOP) + } + if !(isAgg != 0) && pGroupBy == uintptr(0) { + if (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct != 0 { + v12 = int32(WHERE_WANT_DISTINCT) + } else { + v12 = 0 + } + /* No aggregate functions and no GROUP BY clause. tag-select-0700 */ + wctrlFlags = uint16(libc.Uint32FromInt32(v12) | (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_FixedLimit)) + pWin = (*TSelect)(unsafe.Pointer(p)).FpWin /* Main window object (or NULL) */ + if pWin != 0 { + _sqlite3WindowCodeInit(tls, pParse, p) + } + /* Begin the database scan. */ + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy, (*TSelect)(unsafe.Pointer(p)).FpEList, p, wctrlFlags, int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow)) + if pWInfo == uintptr(0) { + goto select_end + } + if int32(_sqlite3WhereOutputRowCount(tls, pWInfo)) < int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3WhereOutputRowCount(tls, pWInfo) + if libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) <= int32(SRT_DistQueue) && libc.Int32FromUint8((*TSelectDest)(unsafe.Pointer(pDest)).FeDest) >= int32(SRT_DistFifo) { + /* TUNING: For a UNION CTE, because UNION is implies DISTINCT, + ** reduce the estimated output row count by 8 (LogEst 30). + ** Search for tag-20250414a to see other cases */ + v1 = p + 2 + *(*TLogEst)(unsafe.Pointer(v1)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v1))) - libc.Int32FromInt32(30)) + } + } + if (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct != 0 && _sqlite3WhereIsDistinct(tls, pWInfo) != 0 { + (**(**TDistinctCtx)(__ccgo_up(bp))).FeTnctType = libc.Uint8FromInt32(_sqlite3WhereIsDistinct(tls, pWInfo)) + } + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy != 0 { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FnOBSat = _sqlite3WhereIsOrdered(tls, pWInfo) + (**(**TSortCtx)(__ccgo_up(bp + 16))).FlabelOBLopt = _sqlite3WhereOrderByLimitOptLabel(tls, pWInfo) + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FnOBSat == (*TExprList)(unsafe.Pointer((**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy)).FnExpr { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = uintptr(0) + } + } + /* If sorting index that was created by a prior OP_OpenEphemeral + ** instruction ended up not being needed, then change the OP_OpenEphemeral + ** into an OP_Noop. + */ + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex >= 0 && (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy == uintptr(0) { + _sqlite3VdbeChangeToNoop(tls, v, (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex) + } + if pWin != 0 { + addrGosub = _sqlite3VdbeMakeLabel(tls, pParse) + iCont = _sqlite3VdbeMakeLabel(tls, pParse) + iBreak = _sqlite3VdbeMakeLabel(tls, pParse) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + regGosub = v12 + _sqlite3WindowCodeStep(tls, pParse, p, pWInfo, regGosub, addrGosub) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, iBreak) + _sqlite3VdbeResolveLabel(tls, v, addrGosub) + (**(**TSortCtx)(__ccgo_up(bp + 16))).FlabelOBLopt = 0 + _selectInnerLoop(tls, pParse, p, -int32(1), bp+16, bp, pDest, iCont, iBreak) + _sqlite3VdbeResolveLabel(tls, v, iCont) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regGosub) + _sqlite3VdbeResolveLabel(tls, v, iBreak) + } else { + /* Use the standard inner loop. */ + _selectInnerLoop(tls, pParse, p, -int32(1), bp+16, bp, pDest, _sqlite3WhereContinueLabel(tls, pWInfo), _sqlite3WhereBreakLabel(tls, pWInfo)) + /* End the database scan loop. + */ + _sqlite3WhereEnd(tls, pWInfo) + } + } else { /* End of processing for this SELECT */ + sortPTab = 0 /* Pseudotable used to decode sorting results */ + sortOut = 0 /* Output register from the sorter */ + orderByGrp = 0 /* True if the GROUP BY and ORDER BY are the same */ + /* Remove any and all aliases between the result set and the + ** GROUP BY clause. + */ + if pGroupBy != 0 { /* For looping over expression in a list */ + k = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr + pItem2 = (*TSelect)(unsafe.Pointer(p)).FpEList + 8 + for { + if !(k > 0) { + break + } + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem2 + 24))).FiAlias = uint16(0) + goto _30 + _30: + ; + k = k - 1 + pItem2 += 32 + } + k = (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + pItem2 = pGroupBy + 8 + for { + if !(k > 0) { + break + } + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem2 + 24))).FiAlias = uint16(0) + goto _31 + _31: + ; + k = k - 1 + pItem2 += 32 + } + if int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) > int32(66) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(66) + } + /* If there is both a GROUP BY and an ORDER BY clause and they are + ** identical, then it may be possible to disable the ORDER BY clause + ** on the grounds that the GROUP BY will cause elements to come out + ** in the correct order. It also may not - the GROUP BY might use a + ** database index that causes rows to be grouped together as required + ** but not actually sorted. Either way, record the fact that the + ** ORDER BY and GROUP BY clauses are the same by setting the orderByGrp + ** variable. */ + if _sqlite3CopySortOrder(tls, pGroupBy, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy) != 0 && _sqlite3ExprListCompare(tls, pGroupBy, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy, -int32(1)) == 0 { + orderByGrp = int32(1) + } + } else { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = 0 + } + /* Create a label to jump to when we want to abort the query */ + addrEnd = _sqlite3VdbeMakeLabel(tls, pParse) + /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in + ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the + ** SELECT statement. + */ + pAggInfo = _sqlite3DbMallocZero(tls, db, uint64(64)) + if pAggInfo != 0 { + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_agginfoFree), pAggInfo) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FselId = (*TSelect)(unsafe.Pointer(p)).FselId + libc.Xmemset(tls, bp+112, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp + 112))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp + 112))).FpSrcList = pTabList + *(*uintptr)(unsafe.Pointer(bp + 112 + 16)) = pAggInfo + if pGroupBy != 0 { + v12 = (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + } else { + v12 = 0 + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn = libc.Uint32FromInt32(v12) + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy = pGroupBy + _sqlite3ExprAnalyzeAggList(tls, bp+112, pEList) + _sqlite3ExprAnalyzeAggList(tls, bp+112, (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy) + if pHaving != 0 { + if pGroupBy != 0 { + _havingToWhere(tls, pParse, p) + pWhere = (*TSelect)(unsafe.Pointer(p)).FpWhere + } + _sqlite3ExprAnalyzeAggregates(tls, bp+112, pHaving) + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + if (*TSelect)(unsafe.Pointer(p)).FpGroupBy == uintptr(0) && (*TSelect)(unsafe.Pointer(p)).FpHaving == uintptr(0) && (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == int32(1) { + minMaxFlag = _minMaxQuery(tls, db, (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr, bp+64) + } else { + minMaxFlag = uint8(WHERE_ORDERBY_NORMAL) + } + _analyzeAggFuncArgs(tls, pAggInfo, bp+112) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto select_end + } + /* Processing for aggregates with GROUP BY is very different and + ** much more complex than aggregates without a GROUP BY. tag-select-0810 + */ + if pGroupBy != 0 { /* Return address register for reset subroutine */ + pDistinct = uintptr(0) + distFlag = uint16(0) + eDist = WHERE_DISTINCT_NOOP + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == int32(1) && (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FiDistinct >= 0 && (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr != uintptr(0) && (*TExpr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr)).Fflags&uint32(EP_xIsSelect) == uint32(0) && *(*uintptr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr + 32)) != uintptr(0) { + pExpr = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr + 32)) + 8))).FpExpr + pExpr = _sqlite3ExprDup(tls, db, pExpr, 0) + pDistinct = _sqlite3ExprListDup(tls, db, pGroupBy, 0) + pDistinct = _sqlite3ExprListAppend(tls, pParse, pDistinct, pExpr) + if pDistinct != 0 { + v12 = libc.Int32FromInt32(WHERE_WANT_DISTINCT) | libc.Int32FromInt32(WHERE_AGG_DISTINCT) + } else { + v12 = 0 + } + distFlag = libc.Uint16FromInt32(v12) + } + /* If there is a GROUP BY clause we might need a sorting index to + ** implement it. Allocate that sorting index now. If it turns out + ** that we do not need it after all, the OP_SorterOpen instruction + ** will be converted into a Noop. + */ + v1 = pParse + 56 + v12 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx = v12 + pKeyInfo1 = _sqlite3KeyInfoFromExprList(tls, pParse, pGroupBy, 0, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) + addrSortingIdx = _sqlite3VdbeAddOp4(tls, v, int32(OP_SorterOpen), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, libc.Int32FromUint32((*TAggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn), 0, pKeyInfo1, -int32(9)) + /* Initialize memory locations used by GROUP BY aggregate processing + */ + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + iUseFlag = v12 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + iAbortFlag = v12 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + regOutputRow = v12 + addrOutputRow = _sqlite3VdbeMakeLabel(tls, pParse) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + regReset = v12 + addrReset = _sqlite3VdbeMakeLabel(tls, pParse) + iAMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + iBMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, iAbortFlag) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, iAMem, iAMem+(*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr-int32(1)) + _sqlite3ExprNullRegisterRange(tls, pParse, iAMem, (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) + /* Begin a loop that will extract all source rows in GROUP BY order. + ** This might involve two separate loops with an OP_Sort in between, or + ** it might be a single loop that uses an index to extract information + ** in the right order to begin with. + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regReset, addrReset) + if libc.Int32FromUint8((**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct) == int32(2) { + v12 = int32(WHERE_DISTINCTBY) + } else { + v12 = int32(WHERE_GROUPBY) + } + if orderByGrp != 0 { + v15 = int32(WHERE_SORTBYGROUP) + } else { + v15 = 0 + } + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, pGroupBy, pDistinct, p, libc.Uint16FromInt32(v12|v15|libc.Int32FromUint16(distFlag)), 0) + if pWInfo == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pDistinct) + goto select_end + } + if (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr != 0 { + _optimizeAggregateUseOfIndexedExpr(tls, pParse, p, pAggInfo, bp+112) + } + _assignAggregateRegisters(tls, pParse, pAggInfo) + eDist = _sqlite3WhereIsDistinct(tls, pWInfo) + if _sqlite3WhereIsOrdered(tls, pWInfo) == (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr { + /* The optimizer is able to deliver rows in group by order so + ** we do not have to sort. The OP_OpenEphemeral table will be + ** cancelled later because we still need to use the pKeyInfo + */ + groupBySort = 0 + } else { + if (**(**TDistinctCtx)(__ccgo_up(bp))).FisTnct != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) == uint32(0) { + v1 = __ccgo_ts + 21713 + } else { + v1 = __ccgo_ts + 21722 + } + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20518, libc.VaList(bp+176, v1)) + groupBySort = int32(1) + nGroupBy = (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr + nCol = nGroupBy + j = nGroupBy + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) { + break + } + if (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(i)*32))).FiSorterColumn >= j { + nCol = nCol + 1 + j = j + 1 + } + goto _47 + _47: + ; + i = i + 1 + } + regBase = _sqlite3GetTempRange(tls, pParse, nCol) + _sqlite3ExprCodeExprList(tls, pParse, pGroupBy, regBase, 0, uint8(0)) + j = nGroupBy + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = uint8(1) + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) { + break + } + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(i)*32 + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn >= j { + _sqlite3ExprCode(tls, pParse, (*TAggInfo_col)(unsafe.Pointer(pCol)).FpCExpr, j+regBase) + j = j + 1 + } + goto _48 + _48: + ; + i = i + 1 + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = uint8(0) + regRecord = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regBase, nCol, regRecord) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterInsert), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, regRecord) + _sqlite3ReleaseTempReg(tls, pParse, regRecord) + _sqlite3ReleaseTempRange(tls, pParse, regBase, nCol) + _sqlite3WhereEnd(tls, pWInfo) + v1 = pParse + 56 + v15 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = v15 + sortPTab = v12 + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab = v12 + sortOut = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenPseudo), sortPTab, sortOut, nCol) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterSort), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrEnd) + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx = uint8(1) + } + /* If there are entries in pAgggInfo->aFunc[] that contain subexpressions + ** that are indexed (and that were previously identified and tagged + ** in optimizeAggregateUseOfIndexedExpr()) then those subexpressions + ** must now be converted into a TK_AGG_COLUMN node so that the value + ** is correctly pulled from the index rather than being recomputed. */ + if (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr != 0 { + _aggregateConvertIndexedExprRefToColumn(tls, pAggInfo) + } + /* If the index or temporary table used by the GROUP BY sort + ** will naturally deliver rows in the order required by the ORDER BY + ** clause, cancel the ephemeral table open coded earlier. + ** + ** This is an optimization - the correct answer should result regardless. + ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER to + ** disable this optimization for testing purposes. */ + if orderByGrp != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_GroupByOrder)) == uint32(0) && (groupBySort != 0 || _sqlite3WhereIsSorted(tls, pWInfo) != 0) { + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = uintptr(0) + _sqlite3VdbeChangeToNoop(tls, v, (**(**TSortCtx)(__ccgo_up(bp + 16))).FaddrSortIndex) + } + /* Evaluate the current GROUP BY terms and store in b0, b1, b2... + ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth) + ** Then compare the current GROUP BY terms against the GROUP BY terms + ** from the previous row currently stored in a0, a1, a2... + */ + addrTopOfLoop = _sqlite3VdbeCurrentAddr(tls, v) + if groupBySort != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_SorterData), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, sortOut, sortPTab) + } + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { + break + } + iOrderByCol = libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pGroupBy + 8 + uintptr(j)*32 + 24))) + if groupBySort != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), sortPTab, j, iBMem+j) + } else { + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = uint8(1) + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pGroupBy + 8 + uintptr(j)*32))).FpExpr, iBMem+j) + } + if iOrderByCol != 0 { + pX = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8 + uintptr(iOrderByCol-int32(1))*32))).FpExpr + pBase = _sqlite3ExprSkipCollateAndLikely(tls, pX) + for pBase != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pBase)).Fop) == int32(TK_IF_NULL_ROW) { + pX = (*TExpr)(unsafe.Pointer(pBase)).FpLeft + pBase = _sqlite3ExprSkipCollateAndLikely(tls, pX) + } + if pBase != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pBase)).Fop) != int32(TK_AGG_COLUMN) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pBase)).Fop) != int32(TK_REGISTER) { + _sqlite3ExprToRegister(tls, pX, iAMem+j) + } + } + goto _52 + _52: + ; + j = j + 1 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_Compare), iAMem, iBMem, (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr, _sqlite3KeyInfoRef(tls, pKeyInfo1), -int32(9)) + addr1 = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addr1+int32(1), 0, addr1+int32(1)) + /* Generate code that runs whenever the GROUP BY changes. + ** Changes in the GROUP BY are detected by the previous code + ** block. If there were no changes, this block is skipped. + ** + ** This code copies current group by terms in b0,b1,b2,... + ** over to a0,a1,a2. It then calls the output subroutine + ** and resets the aggregate accumulator registers in preparation + ** for the next GROUP BY batch. + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutputRow, addrOutputRow) + _sqlite3ExprCodeMove(tls, pParse, iBMem, iAMem, (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), iAbortFlag, addrEnd) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regReset, addrReset) + /* Update the aggregate accumulators based on the content of + ** the current row + */ + _sqlite3VdbeJumpHere(tls, v, addr1) + _updateAccumulator(tls, pParse, iUseFlag, pAggInfo, eDist) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), iUseFlag) + /* End of the loop + */ + if groupBySort != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterNext), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrTopOfLoop) + } else { + _sqlite3WhereEnd(tls, pWInfo) + _sqlite3VdbeChangeToNoop(tls, v, addrSortingIdx) + } + _sqlite3ExprListDelete(tls, db, pDistinct) + /* Output the final row of result + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regOutputRow, addrOutputRow) + /* Jump over the subroutines + */ + _sqlite3VdbeGoto(tls, v, addrEnd) + /* Generate a subroutine that outputs a single row of the result + ** set. This subroutine first looks at the iUseFlag. If iUseFlag + ** is less than or equal to zero, the subroutine is a no-op. If + ** the processing calls for the query to abort, this subroutine + ** increments the iAbortFlag memory location before returning in + ** order to signal the caller to abort. + */ + addrSetAbort = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), iAbortFlag) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regOutputRow) + _sqlite3VdbeResolveLabel(tls, v, addrOutputRow) + addrOutputRow = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), iUseFlag, addrOutputRow+int32(2)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regOutputRow) + _finalizeAggFunctions(tls, pParse, pAggInfo) + _sqlite3ExprIfFalse(tls, pParse, pHaving, addrOutputRow+int32(1), int32(SQLITE_JUMPIFNULL)) + _selectInnerLoop(tls, pParse, p, -int32(1), bp+16, bp, pDest, addrOutputRow+int32(1), addrSetAbort) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regOutputRow) + /* Generate a subroutine that will reset the group-by accumulator + */ + _sqlite3VdbeResolveLabel(tls, v, addrReset) + _resetAccumulator(tls, pParse, pAggInfo) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, iUseFlag) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regReset) + if libc.Int32FromUint16(distFlag) != 0 && eDist != WHERE_DISTINCT_NOOP { + pF = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + _fixDistinctOpenEph(tls, pParse, eDist, (*TAggInfo_func)(unsafe.Pointer(pF)).FiDistinct, (*TAggInfo_func)(unsafe.Pointer(pF)).FiDistAddr) + } + } else { + v1 = _isSimpleCount(tls, p, pAggInfo) + pTab1 = v1 + if v1 != uintptr(0) { + /* tag-select-0821 + ** + ** If isSimpleCount() returns a pointer to a Table structure, then + ** the SQL statement is of the form: + ** + ** SELECT count(*) FROM + ** + ** where the Table structure returned represents table . + ** + ** This statement is so common that it is optimized specially. The + ** OP_Count instruction is executed either on the intkey table that + ** contains the data for table or on one of its indexes. It + ** is better to execute the op on an index, as indexes are almost + ** always spread across less pages than their corresponding tables. + */ + iDb1 = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab1)).FpSchema) + v3 = pParse + 56 + v12 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + iCsr = v12 /* Iterator variable */ + pKeyInfo2 = uintptr(0) /* Keyinfo for scanned index */ + pBest = uintptr(0) /* Best index found so far */ + iRoot = (*TTable)(unsafe.Pointer(pTab1)).Ftnum /* Root page of scanned b-tree */ + _sqlite3CodeVerifySchema(tls, pParse, iDb1) + _sqlite3TableLock(tls, pParse, iDb1, (*TTable)(unsafe.Pointer(pTab1)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab1)).FzName) + /* Search for the index that has the lowest scan cost. + ** + ** (2011-04-15) Do not do a full scan of an unordered index. + ** + ** (2013-10-03) Do not count the entries in a partial index. + ** + ** In practice the KeyInfo structure will not be used. It is only + ** passed to keep OP_OpenRead happy. + */ + if !((*TTable)(unsafe.Pointer(pTab1)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pBest = _sqlite3PrimaryKeyIndex(tls, pTab1) + } + if !(int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + 24 + 4))&0x1>>0) != 0) { + pIdx = (*TTable)(unsafe.Pointer(pTab1)).FpIndex + for { + if !(pIdx != 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x4>>2)) == 0 && int32((*TIndex)(unsafe.Pointer(pIdx)).FszIdxRow) < int32((*TTable)(unsafe.Pointer(pTab1)).FszTabRow) && (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) && (!(pBest != 0) || int32((*TIndex)(unsafe.Pointer(pIdx)).FszIdxRow) < int32((*TIndex)(unsafe.Pointer(pBest)).FszIdxRow)) { + pBest = pIdx + } + goto _56 + _56: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } + if pBest != 0 { + iRoot = (*TIndex)(unsafe.Pointer(pBest)).Ftnum + pKeyInfo2 = _sqlite3KeyInfoOfIndex(tls, pParse, pBest) + } + /* Open a read-only cursor, execute the OP_Count, close the cursor. */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_OpenRead), iCsr, libc.Int32FromUint32(iRoot), iDb1, int32(1)) + if pKeyInfo2 != 0 { + _sqlite3VdbeChangeP4(tls, v, -int32(1), pKeyInfo2, -int32(9)) + } + _assignAggregateRegisters(tls, pParse, pAggInfo) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Count), iCsr, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+(*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn+0) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iCsr) + _explainSimpleCount(tls, pParse, pTab1, pBest) + } else { + /* The general case of an aggregate query without GROUP BY + ** tag-select-0822 */ + regAcc = 0 /* "populate accumulators" flag */ + pDistinct1 = uintptr(0) + distFlag1 = uint16(0) + /* If there are accumulator registers but no min() or max() functions + ** without FILTER clauses, allocate register regAcc. Register regAcc + ** will contain 0 the first time the inner loop runs, and 1 thereafter. + ** The code generated by updateAccumulator() uses this to ensure + ** that the accumulator registers are (a) updated only once if + ** there are no min() or max functions or (b) always updated for the + ** first row visited by the aggregate, so that they are updated at + ** least once even if the FILTER clause means the min() or max() + ** function visits zero rows. */ + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0 { + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + if (*TExpr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32))).FpFExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + goto _57 + } + if (*TFuncDef)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32))).FpFunc)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 { + break + } + goto _57 + _57: + ; + i = i + 1 + } + if i == (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc { + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v12 = *(*int32)(unsafe.Pointer(v1)) + regAcc = v12 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regAcc) + } + } else { + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == int32(1) && (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FiDistinct >= 0 { + pDistinct1 = *(*uintptr)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFExpr + 32)) + if pDistinct1 != 0 { + v12 = libc.Int32FromInt32(WHERE_WANT_DISTINCT) | libc.Int32FromInt32(WHERE_AGG_DISTINCT) + } else { + v12 = 0 + } + distFlag1 = libc.Uint16FromInt32(v12) + } + } + _assignAggregateRegisters(tls, pParse, pAggInfo) + /* This case runs if the aggregate has no GROUP BY clause. The + ** processing is much simpler since there is only a single row + ** of output. + */ + _resetAccumulator(tls, pParse, pAggInfo) + /* If this query is a candidate for the min/max optimization, then + ** minMaxFlag will have been previously set to either + ** WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX and pMinMaxOrderBy will + ** be an appropriate ORDER BY expression for the optimization. + */ + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, **(**uintptr)(__ccgo_up(bp + 64)), pDistinct1, p, libc.Uint16FromInt32(libc.Int32FromUint8(minMaxFlag)|libc.Int32FromUint16(distFlag1)), 0) + if pWInfo == uintptr(0) { + goto select_end + } + eDist1 = _sqlite3WhereIsDistinct(tls, pWInfo) + _updateAccumulator(tls, pParse, regAcc, pAggInfo, eDist1) + if eDist1 != WHERE_DISTINCT_NOOP { + pF1 = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + if pF1 != 0 { + _fixDistinctOpenEph(tls, pParse, eDist1, (*TAggInfo_func)(unsafe.Pointer(pF1)).FiDistinct, (*TAggInfo_func)(unsafe.Pointer(pF1)).FiDistAddr) + } + } + if regAcc != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), regAcc) + } + if minMaxFlag != 0 { + _sqlite3WhereMinMaxOptEarlyOut(tls, v, pWInfo) + } + _sqlite3WhereEnd(tls, pWInfo) + _finalizeAggFunctions(tls, pParse, pAggInfo) + } + (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy = uintptr(0) + _sqlite3ExprIfFalse(tls, pParse, pHaving, addrEnd, int32(SQLITE_JUMPIFNULL)) + _selectInnerLoop(tls, pParse, p, -int32(1), uintptr(0), uintptr(0), pDest, addrEnd, addrEnd) + } + _sqlite3VdbeResolveLabel(tls, v, addrEnd) + } /* endif aggregate query */ + if libc.Int32FromUint8((**(**TDistinctCtx)(__ccgo_up(bp))).FeTnctType) == int32(WHERE_DISTINCT_UNORDERED) { + _explainTempTable(tls, pParse, __ccgo_ts+21713) + } + /* If there is an ORDER BY clause, then we need to sort the results + ** and send them to the callback one by one. tag-select-0900 + */ + if (**(**TSortCtx)(__ccgo_up(bp + 16))).FpOrderBy != 0 { + _generateSortTail(tls, pParse, p, bp+16, (*TExprList)(unsafe.Pointer(pEList)).FnExpr, pDest) + } + /* Jump here to skip this query + */ + _sqlite3VdbeResolveLabel(tls, v, iEnd) + /* The SELECT has been coded. If there is an error in the Parse structure, + ** set the return code to 1. Otherwise 0. */ + rc = libc.BoolInt32((*TParse)(unsafe.Pointer(pParse)).FnErr > 0) + /* Control jumps to here if an error is encountered above, or upon + ** successful coding of the SELECT. + */ + goto select_end +select_end: + ; + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp + 64))) + _sqlite3VdbeExplainPop(tls, pParse) + return rc +} + +/************** End of select.c **********************************************/ +/************** Begin file table.c *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the sqlite3_get_table() and sqlite3_free_table() +** interface routines. These are just wrappers around the main +** interface routine of sqlite3_exec(). +** +** These routines are in a separate files so that they will not be linked +** if they are not used. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** This routine is called by the parser to add a new term to the +// ** end of a growing FROM clause. The "p" parameter is the part of +// ** the FROM clause that has already been constructed. "p" is NULL +// ** if this is the first term of the FROM clause. pTable and pDatabase +// ** are the name of the table and database named in the FROM clause term. +// ** pDatabase is NULL if the database name qualifier is missing - the +// ** usual case. If the term has an alias, then pAlias points to the +// ** alias token. If the term is a subquery, then pSubquery is the +// ** SELECT statement that the subquery encodes. The pTable and +// ** pDatabase parameters are NULL for subqueries. The pOn and pUsing +// ** parameters are the content of the ON and USING clauses. +// ** +// ** Return a new SrcList which encodes is the FROM with the new +// ** term added. +// */ +func _sqlite3SrcListAppendFromTerm(tls *libc.TLS, pParse uintptr, p uintptr, pTable uintptr, pDatabase uintptr, pAlias uintptr, pSubquery uintptr, pOnUsing uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pItem, pToken, v1 uintptr + _, _, _, _ = db, pItem, pToken, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if !(p != 0) && pOnUsing != uintptr(0) && ((*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn != 0 || (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing != 0) { + if (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn != 0 { + v1 = __ccgo_ts + 16058 + } else { + v1 = __ccgo_ts + 16061 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16067, libc.VaList(bp+8, v1)) + goto append_from_error + } + p = _sqlite3SrcListAppend(tls, pParse, p, pTable, pDatabase) + if p == uintptr(0) { + goto append_from_error + } + pItem = p + 8 + uintptr((*TSrcList)(unsafe.Pointer(p)).FnSrc-int32(1))*80 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { + if pDatabase != 0 && (*TToken)(unsafe.Pointer(pDatabase)).Fz != 0 { + v1 = pDatabase + } else { + v1 = pTable + } + pToken = v1 + _sqlite3RenameTokenMap(tls, pParse, (*TSrcItem)(unsafe.Pointer(pItem)).FzName, pToken) + } + if (*TToken)(unsafe.Pointer(pAlias)).Fn != 0 { + (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias = _sqlite3NameFromToken(tls, db, pAlias) + } + if pSubquery != 0 { + if _sqlite3SrcItemAttachSubquery(tls, pParse, pItem, pSubquery, 0) != 0 { + if (*TSelect)(unsafe.Pointer(pSubquery)).FselFlags&uint32(SF_NestedFrom) != 0 { + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 14, 0x4000) + } + } + } + if pOnUsing == uintptr(0) { + *(*uintptr)(unsafe.Pointer(pItem + 64)) = uintptr(0) + } else { + if (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing != 0 { + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 11, 0x800) + *(*uintptr)(unsafe.Pointer(pItem + 64)) = (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing + } else { + *(*uintptr)(unsafe.Pointer(pItem + 64)) = (*TOnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn + } + } + return p + goto append_from_error +append_from_error: + ; + _sqlite3ClearOnOrUsing(tls, db, pOnUsing) + _sqlite3SelectDelete(tls, db, pSubquery) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Expand the space allocated for the given SrcList object by +// ** creating nExtra new slots beginning at iStart. iStart is zero based. +// ** New slots are zeroed. +// ** +// ** For example, suppose a SrcList initially contains two entries: A,B. +// ** To append 3 new entries onto the end, do this: +// ** +// ** sqlite3SrcListEnlarge(db, pSrclist, 3, 2); +// ** +// ** After the call above it would contain: A, B, nil, nil, nil. +// ** If the iStart argument had been 1 instead of 2, then the result +// ** would have been: A, nil, nil, nil, B. To prepend the new slots, +// ** the iStart value would be 0. The result then would +// ** be: nil, nil, nil, A, B. +// ** +// ** If a memory allocation fails or the SrcList becomes too large, leave +// ** the original SrcList unchanged, return NULL, and leave an error message +// ** in pParse. +// */ +func _sqlite3SrcListEnlarge(tls *libc.TLS, pParse uintptr, pSrc uintptr, nExtra int32, iStart int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pNew uintptr + var i int32 + var nAlloc Tsqlite3_int64 + _, _, _, _ = db, i, nAlloc, pNew + /* Sanity checking on calling parameters */ + /* Allocate additional space if needed */ + if libc.Uint32FromInt32((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc)+libc.Uint32FromInt32(nExtra) > (*TSrcList)(unsafe.Pointer(pSrc)).FnAlloc { + nAlloc = int64(2)*int64((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) + int64(nExtra) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc+nExtra >= int32(SQLITE_MAX_SRCLIST) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16022, libc.VaList(bp+8, int32(SQLITE_MAX_SRCLIST))) + return uintptr(0) + } + if nAlloc > int64(SQLITE_MAX_SRCLIST) { + nAlloc = int64(SQLITE_MAX_SRCLIST) + } + pNew = _sqlite3DbRealloc(tls, db, pSrc, uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt64(nAlloc)*libc.Uint64FromInt64(80)) + if pNew == uintptr(0) { + return uintptr(0) + } + pSrc = pNew + (*TSrcList)(unsafe.Pointer(pSrc)).FnAlloc = libc.Uint32FromInt64(nAlloc) + } + /* Move existing slots that come after the newly inserted slots + ** out of the way */ + i = (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc - int32(1) + for { + if !(i >= iStart) { + break + } + *(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i+nExtra)*80)) = *(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80)) + goto _1 + _1: + ; + i = i - 1 + } + **(**int32)(__ccgo_up(pSrc)) += nExtra + /* Zero the newly allocated slots */ + libc.Xmemset(tls, pSrc+8+uintptr(iStart)*80, 0, uint64(80)*libc.Uint64FromInt32(nExtra)) + i = iStart + for { + if !(i < iStart+nExtra) { + break + } + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FiCursor = -int32(1) + goto _2 + _2: + ; + i = i + 1 + } + /* Return a pointer to the enlarged SrcList */ + return pSrc +} + +// C documentation +// +// /* +// ** Begin constructing a new table representation in memory. This is +// ** the first of several action routines that get called in response +// ** to a CREATE TABLE statement. In particular, this routine is called +// ** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp +// ** flag is true if the table should be stored in the auxiliary database +// ** file instead of in the main database file. This is normally the case +// ** when the "TEMP" or "TEMPORARY" keyword occurs in between +// ** CREATE and TABLE. +// ** +// ** The new table record is initialized and put in pParse->pNewTable. +// ** As more of the CREATE TABLE statement is parsed, additional action +// ** routines will be called to add more information to this record. +// ** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine +// ** is called to complete the construction of the new table record. +// */ +func _sqlite3StartTable(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, isTemp int32, isView int32, isVirtual int32, noErr int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var addr1, fileFormat, iDb, reg1, reg2, reg3, v7, v8 int32 + var db, pTable, v, zDb, zDb1, zName, v1 uintptr + var v6 bool + var _ /* pName at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, db, fileFormat, iDb, pTable, reg1, reg2, reg3, v, zDb, zDb1, zName, v1, v6, v7, v8 + zName = uintptr(0) /* The name of the new table */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Unqualified name of the table to create */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum == uint32(1) { + /* Special case: Parsing the sqlite_schema or sqlite_temp_schema schema */ + iDb = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v1 = __ccgo_ts + 6764 + } else { + v1 = __ccgo_ts + 6284 + } + zName = _sqlite3DbStrDup(tls, db, v1) + **(**uintptr)(__ccgo_up(bp)) = pName1 + } else { + /* The common case */ + iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp) + if iDb < 0 { + return + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && isTemp != 0 && (*TToken)(unsafe.Pointer(pName2)).Fn > uint32(0) && iDb != int32(1) { + /* If creating a temp table, the name may not be qualified. Unless + ** the database name is "temp" anyway. */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13805, 0) + return + } + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && isTemp != 0 { + iDb = int32(1) + } + zName = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, zName, **(**uintptr)(__ccgo_up(bp))) + } + } + (*TParse)(unsafe.Pointer(pParse)).FsNameToken = **(**TToken)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) + if zName == uintptr(0) { + return + } + if isView != 0 { + v1 = __ccgo_ts + 11115 + } else { + v1 = __ccgo_ts + 9377 + } + if _sqlite3CheckObjectName(tls, pParse, zName, v1, zName) != 0 { + goto begin_table_error + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) == int32(1) { + isTemp = int32(1) + } + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && isTemp == int32(1) { + v1 = __ccgo_ts + 6764 + } else { + v1 = __ccgo_ts + 6284 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), v1, uintptr(0), zDb) != 0 { + goto begin_table_error + } + if !(isVirtual != 0) && _sqlite3AuthCheck(tls, pParse, libc.Int32FromUint8(_aCode[isTemp+int32(2)*isView]), zName, uintptr(0), zDb) != 0 { + goto begin_table_error + } + /* Make sure the new table name does not collide with an existing + ** index or table name in the same database. Issue an error message if + ** it does. The exception is if the statement being parsed was passed + ** to an sqlite3_declare_vtab() call. In that case only the column names + ** and types will be used, so there is no need to test for namespace + ** collisions. + */ + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != libc.Int32FromInt32(PARSE_MODE_NORMAL)) { + zDb1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto begin_table_error + } + pTable = _sqlite3FindTable(tls, db, zName, zDb1) + if pTable != 0 { + if !(noErr != 0) { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == int32(TABTYP_VIEW) { + v1 = __ccgo_ts + 11115 + } else { + v1 = __ccgo_ts + 9377 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13846, libc.VaList(bp+16, v1, **(**uintptr)(__ccgo_up(bp)))) + } else { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3ForceNotReadOnly(tls, pParse) + } + goto begin_table_error + } + if _sqlite3FindIndex(tls, db, zName, zDb1) != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13867, libc.VaList(bp+16, zName)) + goto begin_table_error + } + } + pTable = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTable == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + goto begin_table_error + } + (*TTable)(unsafe.Pointer(pTable)).FzName = zName + (*TTable)(unsafe.Pointer(pTable)).FiPKey = int16(-int32(1)) + (*TTable)(unsafe.Pointer(pTable)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*TTable)(unsafe.Pointer(pTable)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pTable)).FnRowLogEst = int16(200) + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = pTable + /* Begin generating the code that will insert the table record into + ** the schema table. Note in particular that we must go ahead + ** and allocate the record number for the table entry now. Before any + ** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause + ** indices to be created and the table record must come before the + ** indices. Hence, the record number for the table must be allocated + ** now. + */ + if v6 = !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0); v6 { + v1 = _sqlite3GetVdbe(tls, pParse) + v = v1 + } + if v6 && v1 != uintptr(0) { + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + if isVirtual != 0 { + _sqlite3VdbeAddOp0(tls, v, int32(OP_VBegin)) + } + /* If the file format and encoding in the database have not been set, + ** set them now. + */ + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v8 = *(*int32)(unsafe.Pointer(v1)) + v7 = v8 + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRowid = v7 + reg1 = v7 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v8 = *(*int32)(unsafe.Pointer(v1)) + v7 = v8 + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot = v7 + reg2 = v7 + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v7 = *(*int32)(unsafe.Pointer(v1)) + reg3 = v7 + _sqlite3VdbeAddOp3(tls, v, int32(OP_ReadCookie), iDb, reg3, int32(BTREE_FILE_FORMAT)) + _sqlite3VdbeUsesBtree(tls, v, iDb) + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_If), reg3) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LegacyFileFmt) != uint64(0) { + v7 = int32(1) + } else { + v7 = int32(SQLITE_MAX_FILE_FORMAT) + } + fileFormat = v7 + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_FILE_FORMAT), fileFormat) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_TEXT_ENCODING), libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Fenc)) + _sqlite3VdbeJumpHere(tls, v, addr1) + /* This just creates a place-holder record in the sqlite_schema table. + ** The record created does not contain anything yet. It will be replaced + ** by the real entry in code generated at sqlite3EndTable(). + ** + ** The rowid for the new entry is left in register pParse->u1.cr.regRowid. + ** The root page of the new table is left in reg pParse->u1.cr.regRoot. + ** The rowid and root page number values are needed by the code that + ** sqlite3EndTable will generate. + */ + if isView != 0 || isVirtual != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, reg2) + } else { + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FaddrCrTab = _sqlite3VdbeAddOp3(tls, v, int32(OP_CreateBtree), iDb, reg2, int32(BTREE_INTKEY)) + } + _sqlite3OpenSchemaTable(tls, pParse, iDb) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), 0, reg1) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Blob), int32(6), reg3, 0, uintptr(unsafe.Pointer(&_nullRow)), -int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), 0, reg3, reg1) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND)) + _sqlite3VdbeAddOp0(tls, v, int32(OP_Close)) + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x6>>1)) != 0 { + **(**Tu32)(__ccgo_up(pTable + 48)) |= uint32(TF_Imposter) + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x6>>1)) >= int32(2) { + **(**Tu32)(__ccgo_up(pTable + 48)) |= uint32(TF_Readonly) + } + } + } + /* Normal (non-error) return. */ + return + /* If an error occurs, we jump here */ + goto begin_table_error +begin_table_error: + ; + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + _sqlite3DbFree(tls, db, zName) + return +} + +// C documentation +// +// /* +// ** Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation. +// */ +func _sqlite3UniqueConstraint(tls *libc.TLS, pParse uintptr, onError int32, pIdx uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var j, v2 int32 + var pTab, zCol, zErr uintptr + var _ /* errMsg at bp+0 */ TStrAccum + _, _, _, _, _ = j, pTab, zCol, zErr, v2 + pTab = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + _sqlite3StrAccumInit(tls, bp, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), 0, **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136))) + if (*TIndex)(unsafe.Pointer(pIdx)).FaColExpr != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+16203, libc.VaList(bp+40, (*TIndex)(unsafe.Pointer(pIdx)).FzName)) + } else { + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2)))*16))).FzCnName + if j != 0 { + Xsqlite3_str_append(tls, bp, __ccgo_ts+16214, int32(2)) + } + Xsqlite3_str_appendall(tls, bp, (*TTable)(unsafe.Pointer(pTab)).FzName) + Xsqlite3_str_append(tls, bp, __ccgo_ts+1743, int32(1)) + Xsqlite3_str_appendall(tls, bp, zCol) + goto _1 + _1: + ; + j = j + 1 + } + } + zErr = _sqlite3StrAccumFinish(tls, bp) + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + v2 = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(6)<nExpr, else 0 */ + /* Register Allocations */ + regRowCount = 0 /* A count of rows changed */ + regOldRowid = 0 /* The old rowid */ + regNewRowid = 0 /* The new rowid */ + regNew = 0 /* Content of the NEW.* table in triggers */ + regOld = 0 /* Content of OLD.* table in triggers */ + regRowSet = 0 /* Rowset of rows to be updated */ + regKey = 0 /* composite PRIMARY KEY value */ + libc.Xmemset(tls, bp, 0, uint64(16)) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto update_cleanup + } + /* Locate the table which we want to update. + */ + pTab = _sqlite3SrcListLookup(tls, pParse, pTabList) + if pTab == uintptr(0) { + goto update_cleanup + } + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + /* Figure out if we have any triggers and if the table being + ** updated is a view. + */ + pTrigger = _sqlite3TriggersExist(tls, pParse, pTab, int32(TK_UPDATE), pChanges, bp+72) + isView = libc.BoolInt32(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW)) + /* If there was a FROM clause, set nChangeFrom to the number of expressions + ** in the change-list. Otherwise, set it to 0. There cannot be a FROM + ** clause if this function is being called to generate code for part of + ** an UPSERT statement. */ + if (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc > int32(1) { + v1 = (*TExprList)(unsafe.Pointer(pChanges)).FnExpr + } else { + v1 = 0 + } + nChangeFrom = v1 + if _sqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { + goto update_cleanup + } + if _sqlite3IsReadOnly(tls, pParse, pTab, pTrigger) != 0 { + goto update_cleanup + } + /* Allocate a cursors for the main database table and for all indices. + ** The index cursors might not be used, but if they are used they + ** need to occur right after the database cursor. So go ahead and + ** allocate enough space, just in case. + */ + v4 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = v2 + iDataCur = v1 + iBaseCur = v1 + iIdxCur = iDataCur + int32(1) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v4 = uintptr(0) + } else { + v4 = _sqlite3PrimaryKeyIndex(tls, pTab) + } + pPk = v4 + nIdx = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if pPk == pIdx { + iDataCur = (*TParse)(unsafe.Pointer(pParse)).FnTab + } + (*TParse)(unsafe.Pointer(pParse)).FnTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + 1 + goto _6 + _6: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + nIdx = nIdx + 1 + } + if pUpsert != 0 { + /* On an UPSERT, reuse the same cursors already opened by INSERT */ + iDataCur = (*TUpsert)(unsafe.Pointer(pUpsert)).FiDataCur + iIdxCur = (*TUpsert)(unsafe.Pointer(pUpsert)).FiIdxCur + (*TParse)(unsafe.Pointer(pParse)).FnTab = iBaseCur + } + (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor = iDataCur + /* Allocate space for aXRef[], aRegIdx[], and aToOpen[]. + ** Initialize aXRef[] and aToOpen[] to their default values. + */ + aXRef = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+nIdx+libc.Int32FromInt32(1))+libc.Uint64FromInt32(nIdx)+uint64(2))) + if aXRef == uintptr(0) { + goto update_cleanup + } + aRegIdx = aXRef + uintptr((*TTable)(unsafe.Pointer(pTab)).FnCol)*4 + aToOpen = aRegIdx + uintptr(nIdx)*4 + libc.UintptrFromInt32(1)*4 + libc.Xmemset(tls, aToOpen, int32(1), libc.Uint64FromInt32(nIdx+int32(1))) + **(**Tu8)(__ccgo_up(aToOpen + uintptr(nIdx+int32(1)))) = uint8(0) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + **(**int32)(__ccgo_up(aXRef + uintptr(i)*4)) = -int32(1) + goto _7 + _7: + ; + i = i + 1 + } + /* Initialize the name-context */ + libc.Xmemset(tls, bp+16, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp + 16))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp + 16))).FpSrcList = pTabList + *(*uintptr)(unsafe.Pointer(bp + 16 + 16)) = pUpsert + (**(**TNameContext)(__ccgo_up(bp + 16))).FncFlags = int32(NC_UUpsert) + /* Begin generating code. */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto update_cleanup + } + /* Resolve the column names in all the expressions of the + ** of the UPDATE statement. Also find the column index + ** for each column to be updated in the pChanges array. For each + ** column to be updated, make sure we have authorization to change + ** that column. + */ + v8 = libc.Uint8FromInt32(0) + chngPk = v8 + chngRowid = v8 + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pChanges)).FnExpr) { + break + } + /* If this is an UPDATE with a FROM clause, do not resolve expressions + ** here. The call to sqlite3Select() below will do that. */ + if nChangeFrom == 0 && _sqlite3ResolveExprNames(tls, bp+16, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FpExpr) != 0 { + goto update_cleanup + } + j = _sqlite3ColumnIndex(tls, pTab, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FzEName) + if j >= 0 { + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + chngRowid = uint8(1) + pRowidExpr = (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FpExpr + iRowidExpr = i + } else { + if pPk != 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + chngPk = uint8(1) + } else { + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22538, libc.VaList(bp+112, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FzCnName)) + goto update_cleanup + } + } + } + **(**int32)(__ccgo_up(aXRef + uintptr(j)*4)) = i + } else { + if pPk == uintptr(0) && _sqlite3IsRowid(tls, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FzEName) != 0 { + j = -int32(1) + chngRowid = uint8(1) + pRowidExpr = (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FpExpr + iRowidExpr = i + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11906, libc.VaList(bp+112, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FzEName)) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + goto update_cleanup + } + } + if j < 0 { + v4 = __ccgo_ts + 8197 + } else { + v4 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FzCnName + } + rc = _sqlite3AuthCheck(tls, pParse, int32(SQLITE_UPDATE), (*TTable)(unsafe.Pointer(pTab)).FzName, v4, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + if rc == int32(SQLITE_DENY) { + goto update_cleanup + } else { + if rc == int32(SQLITE_IGNORE) { + **(**int32)(__ccgo_up(aXRef + uintptr(j)*4)) = -int32(1) + } + } + goto _9 + _9: + ; + i = i + 1 + } + chngKey = libc.Uint8FromInt32(libc.Int32FromUint8(chngRowid) + libc.Int32FromUint8(chngPk)) + /* Mark generated columns as changing if their generator expressions + ** reference any changing column. The actual aXRef[] value for + ** generated expressions is not used, other than to check to see that it + ** is non-negative, so the value of aXRef[] for generated columns can be + ** set to any non-negative number. We use 99999 so that the value is + ** obvious when looking at aXRef[] in a symbolic debugger. + */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != 0 { + for cond := true; cond; cond = bProgress != 0 { + bProgress = 0 + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if **(**int32)(__ccgo_up(aXRef + uintptr(i)*4)) >= 0 { + goto _11 + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_GENERATED) == 0 { + goto _11 + } + if _sqlite3ExprReferencesUpdatedColumn(tls, _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16), aXRef, libc.Int32FromUint8(chngRowid)) != 0 { + **(**int32)(__ccgo_up(aXRef + uintptr(i)*4)) = int32(99999) + bProgress = int32(1) + } + goto _11 + _11: + ; + i = i + 1 + } + } + } + /* The SET expressions are not actually used inside the WHERE loop. + ** So reset the colUsed mask. Unless this is a virtual table. In that + ** case, set all bits of the colUsed mask (to ensure that the virtual + ** table implementation makes all columns available). + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + v12 = libc.Uint64FromInt32(-libc.Int32FromInt32(1)) + } else { + v12 = uint64(0) + } + (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FcolUsed = v12 + hasFK = _sqlite3FkRequired(tls, pParse, pTab, aXRef, libc.Int32FromUint8(chngKey)) + /* There is one entry in the aRegIdx[] array for each index on the table + ** being updated. Fill in aRegIdx[] with a register number that will hold + ** the key for accessing each index. + */ + if onError == int32(OE_Replace) { + **(**int32)(__ccgo_up(bp + 88)) = int32(1) + } + nAllIdx = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if chngKey != 0 || hasFK > int32(1) || pIdx == pPk || _indexWhereClauseMightChange(tls, pIdx, aXRef, libc.Int32FromUint8(chngRowid)) != 0 { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + reg = v1 + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } else { + reg = 0 + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + if _indexColumnIsBeingUpdated(tls, pIdx, i, aXRef, libc.Int32FromUint8(chngRowid)) != 0 { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + reg = v1 + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + if onError == int32(OE_Default) && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Replace) { + **(**int32)(__ccgo_up(bp + 88)) = int32(1) + } + break + } + goto _16 + _16: + ; + i = i + 1 + } + } + if reg == 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr(nAllIdx+int32(1)))) = uint8(0) + } + **(**int32)(__ccgo_up(aRegIdx + uintptr(nAllIdx)*4)) = reg + goto _13 + _13: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + nAllIdx = nAllIdx + 1 + } + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + **(**int32)(__ccgo_up(aRegIdx + uintptr(nAllIdx)*4)) = v1 /* Register storing the table record */ + if **(**int32)(__ccgo_up(bp + 88)) != 0 { + /* If REPLACE conflict resolution might be invoked, open cursors on all + ** indexes in case they are needed to delete records. */ + libc.Xmemset(tls, aToOpen, int32(1), libc.Uint64FromInt32(nIdx+int32(1))) + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _sqlite3VdbeCountChanges(tls, v) + } + _sqlite3BeginWriteOperation(tls, pParse, libc.BoolInt32(pTrigger != 0 || hasFK != 0), iDb) + /* Allocate required registers. */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + /* For now, regRowSet and aRegIdx[nAllIdx] share the same register. + ** If regRowSet turns out to be needed, then aRegIdx[nAllIdx] will be + ** reallocated. aRegIdx[nAllIdx] is the register in which the main + ** table record is written. regRowSet holds the RowSet for the + ** two-pass update algorithm. */ + regRowSet = **(**int32)(__ccgo_up(aRegIdx + uintptr(nAllIdx)*4)) + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v2 = *(*int32)(unsafe.Pointer(v4)) + v1 = v2 + regNewRowid = v1 + regOldRowid = v1 + if chngPk != 0 || pTrigger != 0 || hasFK != 0 { + regOld = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } + if chngKey != 0 || pTrigger != 0 || hasFK != 0 { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regNewRowid = v1 + } + regNew = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } + /* Start the view context. */ + if isView != 0 { + _sqlite3AuthContextPush(tls, pParse, bp, (*TTable)(unsafe.Pointer(pTab)).FzName) + } + /* If we are trying to update a view, realize that view into + ** an ephemeral table. + */ + if nChangeFrom == 0 && isView != 0 { + _sqlite3MaterializeView(tls, pParse, pTab, pWhere, pOrderBy, pLimit, iDataCur) + pOrderBy = uintptr(0) + pLimit = uintptr(0) + } + /* Resolve the column names in all the expressions in the + ** WHERE clause. + */ + if nChangeFrom == 0 && _sqlite3ResolveExprNames(tls, bp+16, pWhere) != 0 { + goto update_cleanup + } + /* Virtual tables must be handled separately */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _updateVirtualTable(tls, pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, pWhere, onError) + goto update_cleanup + } + /* Jump to labelBreak to abandon further processing of this UPDATE */ + v1 = _sqlite3VdbeMakeLabel(tls, pParse) + labelBreak = v1 + labelContinue = v1 + /* Not an UPSERT. Normal processing. Begin by + ** initialize the count of updated rows */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00001))<>3)) != 0) && pUpsert == uintptr(0) { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regRowCount = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regRowCount) + } + if nChangeFrom == 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, regRowSet, regOldRowid) + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iEph = v1 + addrOpen = _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenEphemeral), iEph, 0, regRowSet) + } else { + if pPk != 0 { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } else { + v1 = 0 + } + nPk = int16(v1) + iPk = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(nPk) + **(**int32)(__ccgo_up(pParse + 60)) += nChangeFrom + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regKey = v1 + if pUpsert == uintptr(0) { + if isView != 0 { + v1 = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + v1 = 0 + } + nEphCol = int32(nPk) + nChangeFrom + v1 + v4 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iEph = v2 + if pPk != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, iPk, iPk+int32(nPk)-int32(1)) + } + addrOpen = _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), iEph, nEphCol) + if pPk != 0 { + pKeyInfo = _sqlite3KeyInfoOfIndex(tls, pParse, pPk) + if pKeyInfo != 0 { + (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField = libc.Uint16FromInt32(nEphCol) + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + } + } + if nChangeFrom != 0 { + _updateFromSelect(tls, pParse, iEph, pPk, pChanges, pTabList, pWhere, pOrderBy, pLimit) + if isView != 0 { + iDataCur = iEph + } + } + } + } + if nChangeFrom != 0 { + _sqlite3MultiWrite(tls, pParse) + eOnePass = ONEPASS_OFF + nKey = int32(nPk) + regKey = iPk + } else { + if pUpsert != 0 { + /* If this is an UPSERT, then all cursors have already been opened by + ** the outer INSERT and the data cursor should be pointing at the row + ** that is to be updated. So bypass the code that searches for the + ** row(s) to be updated. + */ + pWInfo = uintptr(0) + eOnePass = int32(ONEPASS_SINGLE) + _sqlite3ExprIfFalse(tls, pParse, pWhere, labelBreak, int32(SQLITE_JUMPIFNULL)) + bFinishSeek = 0 + } else { + /* Begin the database scan. + ** + ** Do not consider a single-pass strategy for a multi-row update if + ** there is anything that might disrupt the cursor being used to do + ** the UPDATE: + ** (1) This is a nested UPDATE + ** (2) There are triggers + ** (3) There are FOREIGN KEY constraints + ** (4) There are REPLACE conflict handlers + ** (5) There are subqueries in the WHERE clause + */ + flags = int32(WHERE_ONEPASS_DESIRED) + if !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) && !(pTrigger != 0) && !(hasFK != 0) && !(chngKey != 0) && !(**(**int32)(__ccgo_up(bp + 88)) != 0) && (pWhere == uintptr(0) || !((*TExpr)(unsafe.Pointer(pWhere)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != libc.Uint32FromInt32(0))) { + flags = flags | int32(WHERE_ONEPASS_MULTIROW) + } + pWInfo = _sqlite3WhereBegin(tls, pParse, pTabList, pWhere, uintptr(0), uintptr(0), uintptr(0), libc.Uint16FromInt32(flags), iIdxCur) + if pWInfo == uintptr(0) { + goto update_cleanup + } + /* A one-pass strategy that might update more than one row may not + ** be used if any column of the index used for the scan is being + ** updated. Otherwise, if there is an index on "b", statements like + ** the following could create an infinite loop: + ** + ** UPDATE t1 SET b=b+1 WHERE b>? + ** + ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI + ** strategy that uses an index for which one or more columns are being + ** updated. */ + eOnePass = _sqlite3WhereOkOnePass(tls, pWInfo, bp+80) + bFinishSeek = _sqlite3WhereUsesDeferredSeek(tls, pWInfo) + if eOnePass != int32(ONEPASS_SINGLE) { + _sqlite3MultiWrite(tls, pParse) + if eOnePass == int32(ONEPASS_MULTI) { + iCur = (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] + if iCur >= 0 && iCur != iDataCur && **(**Tu8)(__ccgo_up(aToOpen + uintptr(iCur-iBaseCur))) != 0 { + eOnePass = ONEPASS_OFF + } + } + } + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + /* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF + ** mode, write the rowid into the FIFO. In either of the one-pass modes, + ** leave it in register regOldRowid. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iDataCur, regOldRowid) + if eOnePass == ONEPASS_OFF { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + **(**int32)(__ccgo_up(aRegIdx + uintptr(nAllIdx)*4)) = v1 + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iEph, regRowSet, regOldRowid) + } else { + if addrOpen != 0 { + _sqlite3VdbeChangeToNoop(tls, v, addrOpen) + } + } + } else { + /* Read the PK of the current row into an array of registers. In + ** ONEPASS_OFF mode, serialize the array into a record and store it in + ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change + ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table + ** is not required) and leave the PK fields in the array of registers. */ + i = 0 + for { + if !(i < int32(nPk)) { + break + } + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))), iPk+i) + goto _39 + _39: + ; + i = i + 1 + } + if eOnePass != 0 { + if addrOpen != 0 { + _sqlite3VdbeChangeToNoop(tls, v, addrOpen) + } + nKey = int32(nPk) + regKey = iPk + } else { + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), iPk, int32(nPk), regKey, _sqlite3IndexAffinityStr(tls, db, pPk), int32(nPk)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iEph, regKey, iPk, int32(nPk)) + } + } + } + if pUpsert == uintptr(0) { + if nChangeFrom == 0 && eOnePass != int32(ONEPASS_MULTI) { + _sqlite3WhereEnd(tls, pWInfo) + } + if !(isView != 0) { + addrOnce = 0 + **(**int32)(__ccgo_up(bp + 92)) = 0 + **(**int32)(__ccgo_up(bp + 96)) = 0 + /* Open every index that needs updating. */ + if eOnePass != ONEPASS_OFF { + if (**(**[2]int32)(__ccgo_up(bp + 80)))[0] >= 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr((**(**[2]int32)(__ccgo_up(bp + 80)))[0]-iBaseCur))) = uint8(0) + } + if (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] >= 0 { + **(**Tu8)(__ccgo_up(aToOpen + uintptr((**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)]-iBaseCur))) = uint8(0) + } + } + if eOnePass == int32(ONEPASS_MULTI) && nIdx-libc.BoolInt32((**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] >= 0) > 0 { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + _sqlite3OpenTableAndIndices(tls, pParse, pTab, int32(OP_OpenWrite), uint8(0), iBaseCur, aToOpen, bp+92, bp+96) + if addrOnce != 0 { + _sqlite3VdbeJumpHereOrPopInst(tls, v, addrOnce) + } + } + /* Top of the update loop */ + if eOnePass != ONEPASS_OFF { + if (**(**[2]int32)(__ccgo_up(bp + 80)))[0] != iDataCur && (**(**[2]int32)(__ccgo_up(bp + 80)))[int32(1)] != iDataCur { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), iDataCur, labelBreak, regKey, nKey) + } + if eOnePass != int32(ONEPASS_SINGLE) { + labelContinue = _sqlite3VdbeMakeLabel(tls, pParse) + } + if pPk != 0 { + v1 = regKey + } else { + v1 = regOldRowid + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), v1, labelBreak) + } else { + if pPk != 0 || nChangeFrom != 0 { + labelContinue = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iEph, labelBreak) + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + if nChangeFrom != 0 { + if !(isView != 0) { + if pPk != 0 { + i = 0 + for { + if !(i < int32(nPk)) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEph, i, iPk+i) + goto _41 + _41: + ; + i = i + 1 + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), iDataCur, labelContinue, iPk, int32(nPk)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iEph, regOldRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iDataCur, labelContinue, regOldRowid) + } + } + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowData), iEph, regKey) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), iDataCur, labelContinue, regKey, 0) + } + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iEph, labelBreak) + labelContinue = _sqlite3VdbeMakeLabel(tls, pParse) + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iEph, regOldRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iDataCur, labelContinue, regOldRowid) + } + } + } + /* If the rowid value will change, set register regNewRowid to + ** contain the new value. If the rowid is not being modified, + ** then regNewRowid is the same register as regOldRowid, which is + ** already populated. */ + if chngRowid != 0 { + if nChangeFrom == 0 { + _sqlite3ExprCode(tls, pParse, pRowidExpr, regNewRowid) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEph, iRowidExpr, regNewRowid) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_MustBeInt), regNewRowid) + } + /* Compute the old pre-UPDATE content of the row being changed, if that + ** information is needed */ + if chngPk != 0 || hasFK != 0 || pTrigger != 0 { + if hasFK != 0 { + v42 = _sqlite3FkOldmask(tls, pParse, pTab) + } else { + v42 = uint32(0) + } + oldmask = v42 + oldmask = oldmask | _sqlite3TriggerColmask(tls, pParse, pTrigger, pChanges, 0, libc.Int32FromInt32(TRIGGER_BEFORE)|libc.Int32FromInt32(TRIGGER_AFTER), pTab, onError) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + colFlags = uint32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags) + k = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(i))) + regOld + if oldmask == uint32(0xffffffff) || i < int32(32) && oldmask&(libc.Uint32FromInt32(1)<= 0 { + if nChangeFrom != 0 { + if isView != 0 { + v1 = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + v1 = int32(nPk) + } + nOff = v1 + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEph, nOff+j, k) + } else { + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(j)*32))).FpExpr, k) + } + } else { + if 0 == **(**int32)(__ccgo_up(bp + 72))&int32(TRIGGER_BEFORE) || i > int32(31) || libc.Uint32FromInt32(newmask)&(libc.Uint32FromInt32(1)< int32(1) || chngKey != 0 { + v1 = 0 + } else { + v1 = int32(OPFLAG_ISNOOP) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Delete), iDataCur, int32(OPFLAG_ISUPDATE)|v1, regNewRowid) + if eOnePass == int32(ONEPASS_MULTI) { + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION)) + } + if !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { + _sqlite3VdbeAppendP4(tls, v, pTab, -int32(5)) + } + if hasFK != 0 { + _sqlite3FkCheck(tls, pParse, pTab, 0, regNewRowid, aXRef, libc.Int32FromUint8(chngKey)) + } + /* Insert the new index entries and the new record. */ + if eOnePass == int32(ONEPASS_MULTI) { + v1 = int32(OPFLAG_SAVEPOSITION) + } else { + v1 = 0 + } + _sqlite3CompleteInsertion(tls, pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx, int32(OPFLAG_ISUPDATE)|v1, 0, 0) + /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to + ** handle rows (possibly in other tables) that refer via a foreign key + ** to the row just updated. */ + if hasFK != 0 { + _sqlite3FkActions(tls, pParse, pTab, pChanges, regOldRowid, aXRef, libc.Int32FromUint8(chngKey)) + } + } + /* Increment the row counter + */ + if regRowCount != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), regRowCount, int32(1)) + } + if pTrigger != 0 { + _sqlite3CodeRowTrigger(tls, pParse, pTrigger, int32(TK_UPDATE), pChanges, int32(TRIGGER_AFTER), pTab, regOldRowid, onError, labelContinue) + } + /* Repeat the above with the next record to be updated, until + ** all record selected by the WHERE clause have been updated. + */ + if eOnePass == int32(ONEPASS_SINGLE) { + /* Nothing to do at end-of-loop for a single-pass */ + } else { + if eOnePass == int32(ONEPASS_MULTI) { + _sqlite3VdbeResolveLabel(tls, v, labelContinue) + _sqlite3WhereEnd(tls, pWInfo) + } else { + _sqlite3VdbeResolveLabel(tls, v, labelContinue) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iEph, addrTop) + } + } + _sqlite3VdbeResolveLabel(tls, v, labelBreak) + /* Update the sqlite_sequence table by storing the content of the + ** maximum rowid counter values recorded while inserting into + ** autoincrement tables. + */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0) && pUpsert == uintptr(0) { + _sqlite3AutoincrementEnd(tls, pParse) + } + /* + ** Return the number of rows that were changed, if we are tracking + ** that information. + */ + if regRowCount != 0 { + _sqlite3CodeChangeCount(tls, v, regRowCount, __ccgo_ts+22574) + } + goto update_cleanup +update_cleanup: + ; + _sqlite3AuthContextPop(tls, bp) + _sqlite3DbFree(tls, db, aXRef) /* Also frees aRegIdx[] and aToOpen[] */ + _sqlite3SrcListDelete(tls, db, pTabList) + _sqlite3ExprListDelete(tls, db, pChanges) + _sqlite3ExprDelete(tls, db, pWhere) + return +} + +/* Make sure "isView" and other macros defined above are undefined. Otherwise +** they may interfere with compilation of other functions in this file +** (or in another file, if this file becomes part of the amalgamation). */ + +// C documentation +// +// /* +// ** Compute a string that describes the P4 parameter for an opcode. +// ** Use zTemp for any required temporary buffer space. +// */ +func _sqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var ai, pColl, pColl1, pDef, pDef1, pKeyInfo, pMem, pSig, pVtab, zColl, zP4, v2, v3 uintptr + var i, n Tu32 + var j, v6 int32 + var _ /* x at bp+0 */ TStrAccum + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ai, i, j, n, pColl, pColl1, pDef, pDef1, pKeyInfo, pMem, pSig, pVtab, zColl, zP4, v2, v3, v6 + zP4 = uintptr(0) + _sqlite3StrAccumInit(tls, bp, uintptr(0), uintptr(0), 0, int32(SQLITE_MAX_LENGTH)) + switch int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) { + case -int32(9): + pKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5232, libc.VaList(bp+40, libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField))) + j = 0 + for { + if !(j < libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField)) { + break + } + pColl = *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(j)*8)) + if pColl != 0 { + v2 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v2 = __ccgo_ts + 1704 + } + zColl = v2 + if libc.Xstrcmp(tls, zColl, __ccgo_ts+5237) == 0 { + zColl = __ccgo_ts + 5244 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j))))&int32(KEYINFO_ORDER_DESC) != 0 { + v2 = __ccgo_ts + 5225 + } else { + v2 = __ccgo_ts + 1704 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j))))&int32(KEYINFO_ORDER_BIGNULL) != 0 { + v3 = __ccgo_ts + 5246 + } else { + v3 = __ccgo_ts + 1704 + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5249, libc.VaList(bp+40, v2, v3, zColl)) + goto _1 + _1: + ; + j = j + 1 + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5257, int32(1)) + case -int32(2): + pColl1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5273, libc.VaList(bp+40, (*TCollSeq)(unsafe.Pointer(pColl1)).FzName, _encnames[(*TCollSeq)(unsafe.Pointer(pColl1)).Fenc])) + case -int32(8): + pDef = *(*uintptr)(unsafe.Pointer(pOp + 16)) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5282, libc.VaList(bp+40, (*TFuncDef)(unsafe.Pointer(pDef)).FzName, int32((*TFuncDef)(unsafe.Pointer(pDef)).FnArg))) + case -int32(16): + pDef1 = (*Tsqlite3_context)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpFunc + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5282, libc.VaList(bp+40, (*TFuncDef)(unsafe.Pointer(pDef1)).FzName, int32((*TFuncDef)(unsafe.Pointer(pDef1)).FnArg))) + case -int32(14): + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+1465, libc.VaList(bp+40, **(**Ti64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))))) + case -int32(3): + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5289, libc.VaList(bp+40, (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) + case -int32(13): + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+1432, libc.VaList(bp+40, **(**float64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))))) + case -int32(11): + pMem = *(*uintptr)(unsafe.Pointer(pOp + 16)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Str) != 0 { + zP4 = (*TMem)(unsafe.Pointer(pMem)).Fz + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+1465, libc.VaList(bp+40, *(*Ti64)(unsafe.Pointer(pMem)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Real) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+1432, libc.VaList(bp+40, *(*float64)(unsafe.Pointer(pMem)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Null) != 0 { + zP4 = __ccgo_ts + 1705 + } else { + zP4 = __ccgo_ts + 5292 + } + } + } + } + case -int32(12): + pVtab = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5299, libc.VaList(bp+40, pVtab)) + case -int32(15): + ai = *(*uintptr)(unsafe.Pointer(pOp + 16)) + n = **(**Tu32)(__ccgo_up(ai)) /* The first element of an INTARRAY is always the + ** count of the number of elements to follow */ + i = uint32(1) + for { + if !(i <= n) { + break + } + if i == uint32(1) { + v6 = int32('[') + } else { + v6 = int32(',') + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5307, libc.VaList(bp+40, v6, **(**Tu32)(__ccgo_up(ai + uintptr(i)*4)))) + goto _5 + _5: + ; + i = i + 1 + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5312, int32(1)) + case -int32(4): + zP4 = __ccgo_ts + 5314 + case -int32(5): + zP4 = (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FzName + case -int32(6): + zP4 = (*TIndex)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FzName + case -int32(18): + pSig = *(*uintptr)(unsafe.Pointer(pOp + 16)) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+5322, libc.VaList(bp+40, (*TSubrtnSig)(unsafe.Pointer(pSig)).FselId, (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff)) + default: + zP4 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + } + if zP4 != 0 { + Xsqlite3_str_appendall(tls, bp, zP4) + } + if libc.Int32FromUint8((**(**TStrAccum)(__ccgo_up(bp))).FaccError)&int32(SQLITE_NOMEM) != 0 { + _sqlite3OomFault(tls, db) + } + return _sqlite3StrAccumFinish(tls, bp) +} + +// C documentation +// +// /* +// ** Set the value stored in *pMem should already be a NULL. +// ** Also store a pointer to go with it. +// */ +func _sqlite3VdbeMemSetPointer(tls *libc.TLS, pMem uintptr, pPtr uintptr, zPType uintptr, __ccgo_fp_xDestructor uintptr) { + var v1 uintptr + _ = v1 + _vdbeMemClear(tls, pMem) + if zPType != 0 { + v1 = zPType + } else { + v1 = __ccgo_ts + 1704 + } + *(*uintptr)(unsafe.Pointer(pMem)) = v1 + (*TMem)(unsafe.Pointer(pMem)).Fz = pPtr + (*TMem)(unsafe.Pointer(pMem)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Null) | libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Subtype) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pMem)).FeSubtype = uint8('p') + if __ccgo_fp_xDestructor != 0 { + v1 = __ccgo_fp_xDestructor + } else { + v1 = __ccgo_fp(_sqlite3NoopDestructor) + } + (*TMem)(unsafe.Pointer(pMem)).FxDel = v1 +} + +// C documentation +// +// /* +// ** Expression pExpr is a vector that has been used in a context where +// ** it is not permitted. If pExpr is a sub-select vector, this routine +// ** loads the Parse object with a message of the form: +// ** +// ** "sub-select returns N columns - expected 1" +// ** +// ** Or, if it is a regular scalar vector: +// ** +// ** "row value misused" +// */ +func _sqlite3VectorErrorMsg(tls *libc.TLS, pParse uintptr, pExpr uintptr) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _sqlite3SubselectError(tls, pParse, (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList)).FnExpr, int32(1)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6908, 0) + } +} + +// C documentation +// +// /* +// ** This function is invoked by the parser to call the xConnect() method +// ** of the virtual table pTab. If an error occurs, an error code is returned +// ** and an error left in pParse. +// ** +// ** This call is a no-op if table pTab is not a virtual table. +// */ +func _sqlite3VtabCallConnect(tls *libc.TLS, pParse uintptr, pTab uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pMod, zMod, zModule uintptr + var rc int32 + var _ /* zErr at bp+0 */ uintptr + _, _, _, _, _ = db, pMod, rc, zMod, zModule + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if _sqlite3GetVTable(tls, db, pTab) != 0 { + return SQLITE_OK + } + /* Locate the required virtual table module */ + zMod = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg)) + pMod = _sqlite3HashFind(tls, db+576, zMod) + if !(pMod != 0) { + zModule = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg)) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+23521, libc.VaList(bp+16, zModule)) + rc = int32(SQLITE_ERROR) + } else { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _vtabCallConstructor(tls, db, pTab, pMod, (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxConnect, bp) + if rc != SQLITE_OK { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3944, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp)))) + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + } + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** This function is invoked by the vdbe to call the xCreate method +// ** of the virtual table named zTab in database iDb. +// ** +// ** If an error occurs, *pzErr is set to point to an English language +// ** description of the error and an SQLITE_XXX error code is returned. +// ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr. +// */ +func _sqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pMod, pTab, zMod uintptr + var rc int32 + _, _, _, _ = pMod, pTab, rc, zMod + rc = SQLITE_OK + pTab = _sqlite3FindTable(tls, db, zTab, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + /* Locate the required virtual table module */ + zMod = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg)) + pMod = _sqlite3HashFind(tls, db+576, zMod) + /* If the module has been registered and includes a Create method, + ** invoke it now. If the module has not been registered, return an + ** error. Otherwise, do nothing. + */ + if pMod == uintptr(0) || (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxCreate == uintptr(0) || (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxDestroy == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+23521, libc.VaList(bp+8, zMod)) + rc = int32(SQLITE_ERROR) + } else { + rc = _vtabCallConstructor(tls, db, pTab, pMod, (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxCreate, pzErr) + } + /* Justification of ALWAYS(): The xConstructor method is required to + ** create a valid sqlite3_vtab if it returns SQLITE_OK. */ + if rc == SQLITE_OK && _sqlite3GetVTable(tls, db, pTab) != 0 { + rc = _growVTrans(tls, db) + if rc == SQLITE_OK { + _addToVTrans(tls, db, _sqlite3GetVTable(tls, db, pTab)) + } + } + return rc +} + +// C documentation +// +// /* +// ** The parser calls this routine after the CREATE VIRTUAL TABLE statement +// ** has been completely parsed. +// */ +func _sqlite3VtabFinishParse(tls *libc.TLS, pParse uintptr, pEnd uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var db, pOld, pSchema, pTab, v, zName, zStmt, zWhere, v2 uintptr + var iDb, iReg, v1 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = db, iDb, iReg, pOld, pSchema, pTab, v, zName, zStmt, zWhere, v1, v2 + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable /* The table being constructed */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The database connection */ + if pTab == uintptr(0) { + return + } + _addArgumentToVtab(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FsArg.Fz = uintptr(0) + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FnArg < int32(1) { + return + } + /* If the CREATE VIRTUAL TABLE statement is being entered for the + ** first time (in other words if the virtual table is actually being + ** created now instead of just being read out of sqlite_schema) then + ** do additional initialization work and store the statement text + ** in the sqlite_schema table. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + _sqlite3MayAbort(tls, pParse) + /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ + if pEnd != 0 { + (*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fn = libc.Uint32FromInt32(int32(int64((*TToken)(unsafe.Pointer(pEnd)).Fz)-int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz))) + (*TToken)(unsafe.Pointer(pEnd)).Fn + } + zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+23261, libc.VaList(bp+8, pParse+224)) + /* A slot for the record has already been allocated in the + ** schema table. We just need to update that slot with all + ** the information we've collected. + ** + ** The VM register number pParse->u1.cr.regRowid holds the rowid of an + ** entry in the sqlite_schema table that was created for this vtab + ** by sqlite3StartTable(). + */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+23285, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(pTab)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, zStmt, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRowid)) + v = _sqlite3GetVdbe(tls, pParse) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + zWhere = _sqlite3MPrintf(tls, db, __ccgo_ts+23384, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, zStmt)) + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, zWhere, uint16(0)) + _sqlite3DbFree(tls, db, zStmt) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + iReg = v1 + _sqlite3VdbeLoadString(tls, v, iReg, (*TTable)(unsafe.Pointer(pTab)).FzName) + _sqlite3VdbeAddOp2(tls, v, int32(OP_VCreate), iDb, iReg) + } else { + pSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + zName = (*TTable)(unsafe.Pointer(pTab)).FzName + _sqlite3MarkAllShadowTablesOf(tls, db, pTab) + pOld = _sqlite3HashInsert(tls, pSchema+8, zName, pTab) + if pOld != 0 { + _sqlite3OomFault(tls, db) + /* Malloc must have failed inside HashInsert() */ + return + } + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Generate the beginning of the loop used for WHERE clause processing. +// ** The return value is a pointer to an opaque structure that contains +// ** information needed to terminate the loop. Later, the calling routine +// ** should invoke sqlite3WhereEnd() with the return value of this function +// ** in order to complete the WHERE clause processing. +// ** +// ** If an error occurs, this routine returns NULL. +// ** +// ** The basic idea is to do a nested loop, one loop for each table in +// ** the FROM clause of a select. (INSERT and UPDATE statements are the +// ** same as a SELECT with only a single table in the FROM clause.) For +// ** example, if the SQL is this: +// ** +// ** SELECT * FROM t1, t2, t3 WHERE ...; +// ** +// ** Then the code generated is conceptually like the following: +// ** +// ** foreach row1 in t1 do \ Code generated +// ** foreach row2 in t2 do |-- by sqlite3WhereBegin() +// ** foreach row3 in t3 do / +// ** ... +// ** end \ Code generated +// ** end |-- by sqlite3WhereEnd() +// ** end / +// ** +// ** Note that the loops might not be nested in the order in which they +// ** appear in the FROM clause if a different order is better able to make +// ** use of indices. Note also that when the IN operator appears in +// ** the WHERE clause, it might result in additional nested loops for +// ** scanning through all values on the right-hand side of the IN. +// ** +// ** There are Btree cursors associated with each table. t1 uses cursor +// ** number pTabList->a[0].iCursor. t2 uses the cursor pTabList->a[1].iCursor. +// ** And so forth. This routine generates code to open those VDBE cursors +// ** and sqlite3WhereEnd() generates the code to close them. +// ** +// ** The code that sqlite3WhereBegin() generates leaves the cursors named +// ** in pTabList pointing at their appropriate entries. The [...] code +// ** can use OP_Column and OP_Rowid opcodes on these cursors to extract +// ** data from the various tables of the loop. +// ** +// ** If the WHERE clause is empty, the foreach loops must each scan their +// ** entire tables. Thus a three-way join is an O(N^3) operation. But if +// ** the tables have indices and there are terms in the WHERE clause that +// ** refer to those indices, a complete table scan can be avoided and the +// ** code will run much faster. Most of the work of this routine is checking +// ** to see if there are indices that can be used to speed up the loop. +// ** +// ** Terms of the WHERE clause are also used to limit which rows actually +// ** make it to the "..." in the middle of the loop. After each "foreach", +// ** terms of the WHERE clause that use only terms in that loop and outer +// ** loops are evaluated and if false a jump is made around all subsequent +// ** inner loops (or around the "..." if the test occurs within the inner- +// ** most loop) +// ** +// ** OUTER JOINS +// ** +// ** An outer join of tables t1 and t2 is conceptually coded as follows: +// ** +// ** foreach row1 in t1 do +// ** flag = 0 +// ** foreach row2 in t2 do +// ** start: +// ** ... +// ** flag = 1 +// ** end +// ** if flag==0 then +// ** move the row2 cursor to a null row +// ** goto start +// ** fi +// ** end +// ** +// ** ORDER BY CLAUSE PROCESSING +// ** +// ** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause +// ** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement +// ** if there is one. If there is no ORDER BY clause or if this routine +// ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL. +// ** +// ** The iIdxCur parameter is the cursor number of an index. If +// ** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index +// ** to use for OR clause processing. The WHERE clause should use this +// ** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is +// ** the first cursor in an array of cursors for all indices. iIdxCur should +// ** be used to compute the appropriate cursor depending on which index is +// ** used. +// */ +func _sqlite3WhereBegin(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWhere uintptr, pOrderBy uintptr, pResultSet uintptr, pSelect uintptr, wctrlFlags Tu16, iAuxArg int32) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addrExplain, bOnerow, iCur, iDb, iIndexCur, iOnce, ii, n, nByteWInfo, nTabList, op, op1, rc, wsFlags, wsFlags1, v1 int32 + var b, notReady TBitmask + var bFordelete Tu8 + var db, p, pInfo, pIx, pJ, pLevel, pLoop, pMaskSet, pPk, pRJ, pSrc, pSubq, pT, pTab, pTabItem, pVTab, pWInfo, pX, v, v7, v8 uintptr + var v19 bool + var _ /* sWLB at bp+0 */ TWhereLoopBuilder + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrExplain, b, bFordelete, bOnerow, db, iCur, iDb, iIndexCur, iOnce, ii, n, nByteWInfo, nTabList, notReady, op, op1, p, pInfo, pIx, pJ, pLevel, pLoop, pMaskSet, pPk, pRJ, pSrc, pSubq, pT, pTab, pTabItem, pVTab, pWInfo, pX, rc, v, wsFlags, wsFlags1, v1, v19, v7, v8 /* Will become the return value of this function */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Return code */ + bFordelete = uint8(0) /* OPFLAG_FORDELETE or zero, as appropriate */ + /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */ + /* Variable initialization */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + libc.Xmemset(tls, bp, 0, uint64(56)) + /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */ + if pOrderBy != 0 && (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + pOrderBy = uintptr(0) + wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & ^libc.Int32FromInt32(WHERE_WANT_DISTINCT)) + wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) | libc.Int32FromInt32(WHERE_KEEP_ALL_JOINS)) /* Disable omit-noop-join opt */ + } + /* The number of tables in the FROM clause is limited by the number of + ** bits in a Bitmask + */ + if (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc > libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24035, libc.VaList(bp+64, libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)))) + return uintptr(0) + } + /* This function normally generates a nested loop for all tables in + ** pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should + ** only generate code for the first table in pTabList and assume that + ** any cursors associated with subsequent tables are uninitialized. + */ + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) != 0 { + v1 = int32(1) + } else { + v1 = (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc + } + nTabList = v1 + /* Allocate and initialize the WhereInfo structure that will become the + ** return value. A single allocation is used to store the WhereInfo + ** struct, the contents of WhereInfo.a[], the WhereClause structure + ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte + ** field (type Bitmask) it must be aligned on an 8-byte boundary on + ** some architectures. Hence the ROUND8() below. + */ + nByteWInfo = libc.Int32FromUint64((uint64(libc.UintptrFromInt32(0)+856) + libc.Uint64FromInt32(nTabList)*libc.Uint64FromInt64(112) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + pWInfo = _sqlite3DbMallocRawNN(tls, db, uint64(libc.Uint64FromInt32(nByteWInfo)+uint64(104))) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3DbFree(tls, db, pWInfo) + pWInfo = uintptr(0) + goto whereBeginError + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse = pParse + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList = pTabList + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pOrderBy + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet = pResultSet + v1 = -libc.Int32FromInt32(1) + **(**int32)(__ccgo_up(pWInfo + 40 + 1*4)) = v1 + **(**int32)(__ccgo_up(pWInfo + 40)) = v1 + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel = libc.Uint8FromInt32(nTabList) + v1 = _sqlite3VdbeMakeLabel(tls, pParse) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiContinue = v1 + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak = v1 + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags = wctrlFlags + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiLimit = int16(iAuxArg) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop = int32((*TParse)(unsafe.Pointer(pParse)).FnQueryLoop) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect = pSelect + libc.Xmemset(tls, pWInfo+65, 0, uint64(libc.UintptrFromInt32(0)+104)-uint64(libc.UintptrFromInt32(0)+65)) + libc.Xmemset(tls, pWInfo+856, 0, uint64(104)+libc.Uint64FromInt32(nTabList)*uint64(112)) + /* ONEPASS defaults to OFF */ + pMaskSet = pWInfo + 592 + (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn = 0 + **(**int32)(__ccgo_up(pMaskSet + 8)) = -int32(99) /* Initialize ix[0] to a value that can never be + ** a valid cursor number, to avoid an initial + ** test for pMaskSet->n==0 in sqlite3WhereGetMask() */ + (**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpWInfo = pWInfo + (**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpWC = pWInfo + 104 + (**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpNew = pWInfo + uintptr(nByteWInfo) + _whereLoopInit(tls, (**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpNew) + /* Split the WHERE clause into separate subexpressions where each + ** subexpression is separated by an AND operator. + */ + _sqlite3WhereClauseInit(tls, pWInfo+104, pWInfo) + _sqlite3WhereSplit(tls, pWInfo+104, pWhere, uint8(TK_AND)) + /* Special case: No FROM clause + */ + if nTabList == 0 { + if pOrderBy != 0 { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = int8((*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) + } + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DistinctOpt)) == uint32(0) { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_UNIQUE) + } + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect != 0 && (*TSelect)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FselFlags&uint32(SF_MultiValue) == uint32(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+24063, 0) + } + } else { + /* Assign a bit from the bitmask to every term in the FROM clause. + ** + ** The N-th term of the FROM clause is assigned a bitmask of 1<nSrc tables in + ** pTabList, not just the first nTabList tables. nTabList is normally + ** equal to pTabList->nSrc but might be shortened to 1 if the + ** WHERE_OR_SUBCLAUSE flag is set. + */ + ii = 0 + for { + _createMask(tls, pMaskSet, (*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(ii)*80))).FiCursor) + _sqlite3WhereTabFuncArgs(tls, pParse, pTabList+8+uintptr(ii)*80, pWInfo+104) + goto _5 + _5: + ; + ii = ii + 1 + v1 = ii + if !(v1 < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + } + } + /* Analyze all of the subexpressions. */ + _sqlite3WhereExprAnalyze(tls, pTabList, pWInfo+104) + if pSelect != 0 && (*TSelect)(unsafe.Pointer(pSelect)).FpLimit != 0 { + _sqlite3WhereAddLimit(tls, pWInfo+104, pSelect) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto whereBeginError + } + /* The False-WHERE-Term-Bypass optimization: + ** + ** If there are WHERE terms that are false, then no rows will be output, + ** so skip over all of the code generated here. + ** + ** Conditions: + ** + ** (1) The WHERE term must not refer to any tables in the join. + ** (2) The term must not come from an ON clause on the + ** right-hand side of a LEFT or FULL JOIN. + ** (3) The term must not come from an ON clause, or there must be + ** no RIGHT or FULL OUTER joins in pTabList. + ** (4) If the expression contains non-deterministic functions + ** that are not within a sub-select. This is not required + ** for correctness but rather to preserves SQLite's legacy + ** behaviour in the following two cases: + ** + ** WHERE random()>0; -- eval random() once per row + ** WHERE (SELECT random())>0; -- eval random() just once overall + ** + ** Note that the Where term need not be a constant in order for this + ** optimization to apply, though it does need to be constant relative to + ** the current subquery (condition 1). The term might include variables + ** from outer queries so that the value of the term changes from one + ** invocation of the current subquery to the next. + */ + ii = 0 + for { + if !(ii < (*TWhereClause)(unsafe.Pointer((**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpWC)).FnBase) { + break + } + pT = (*TWhereClause)(unsafe.Pointer((**(**TWhereLoopBuilder)(__ccgo_up(bp))).FpWC)).Fa + uintptr(ii)*56 /* The expression of pT */ + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pT)).FwtFlags)&int32(TERM_VIRTUAL) != 0 { + goto _6 + } + pX = (*TWhereTerm)(unsafe.Pointer(pT)).FpExpr + if (*TWhereTerm)(unsafe.Pointer(pT)).FprereqAll == uint64(0) && (nTabList == 0 || _exprIsDeterministic(tls, pX) != 0) && !((*TExpr)(unsafe.Pointer(pX)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) != uint32(0) && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0) { + _sqlite3ExprIfFalse(tls, pParse, pX, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak, int32(SQLITE_JUMPIFNULL)) + v7 = pT + 18 + *(*Tu16)(unsafe.Pointer(v7)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v7))) | libc.Int32FromInt32(TERM_CODED)) + } + goto _6 + _6: + ; + ii = ii + 1 + } + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DistinctOpt)) != uint32(0) { + /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via + ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */ + wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & ^libc.Int32FromInt32(WHERE_WANT_DISTINCT)) + v7 = pWInfo + 60 + *(*Tu16)(unsafe.Pointer(v7)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v7))) & ^libc.Int32FromInt32(WHERE_WANT_DISTINCT)) + } else { + if _isDistinctRedundant(tls, pParse, pTabList, pWInfo+104, pResultSet) != 0 { + /* The DISTINCT marking is pointless. Ignore it. */ + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_UNIQUE) + } else { + if pOrderBy == uintptr(0) { + /* Try to ORDER BY the result set to make distinct processing easier */ + v7 = pWInfo + 60 + *(*Tu16)(unsafe.Pointer(v7)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v7))) | libc.Int32FromInt32(WHERE_DISTINCTBY)) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pResultSet + } + } + } + } + /* Construct the WhereLoop objects */ + if nTabList != int32(1) || _whereShortCut(tls, bp) == 0 { + rc = _whereLoopAddAll(tls, bp) + if rc != 0 { + goto whereBeginError + } + /* If one or more WhereTerm.truthProb values were used in estimating + ** loop parameters, but then those truthProb values were subsequently + ** changed based on STAT4 information while computing subsequent loops, + ** then we need to rerun the whole loop building process so that all + ** loops will be built using the revised truthProb values. */ + if libc.Int32FromUint8((**(**TWhereLoopBuilder)(__ccgo_up(bp))).FbldFlags2)&int32(SQLITE_BLDF2_2NDPASS) != 0 { + for (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops != 0 { + p = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops = (*TWhereLoop)(unsafe.Pointer(p)).FpNextLoop + _whereLoopDelete(tls, db, p) + } + rc = _whereLoopAddAll(tls, bp) + if rc != 0 { + goto whereBeginError + } + } + _wherePathSolver(tls, pWInfo, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto whereBeginError + } + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { + _whereInterstageHeuristic(tls, pWInfo) + if int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut) < 0 { + v1 = int32(1) + } else { + v1 = int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut) + int32(1) + } + _wherePathSolver(tls, pWInfo, int16(v1)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto whereBeginError + } + } + /* TUNING: Assume that a DISTINCT clause on a subquery reduces + ** the output size by a factor of 8 (LogEst -30). Search for + ** tag-20250414a to see other cases. + */ + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 { + v7 = pWInfo + 70 + *(*TLogEst)(unsafe.Pointer(v7)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v7))) - libc.Int32FromInt32(30)) + } + } + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ReverseOrder) != uint64(0) { + _whereReverseScanOrder(tls, pWInfo) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto whereBeginError + } + /* Attempt to omit tables from a join that do not affect the result. + ** See the comment on whereOmitNoopJoin() for further information. + ** + ** This query optimization is factored out into a separate "no-inline" + ** procedure to keep the sqlite3WhereBegin() procedure from becoming + ** too large. If sqlite3WhereBegin() becomes too large, that prevents + ** some C-compiler optimizers from in-lining the + ** sqlite3WhereCodeOneLoopStart() procedure, and it is important to + ** in-line sqlite3WhereCodeOneLoopStart() for performance reasons. + */ + notReady = ^libc.Uint64FromInt32(0) + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) >= int32(2) && pResultSet != uintptr(0) && 0 == libc.Int32FromUint16(wctrlFlags)&(libc.Int32FromInt32(WHERE_AGG_DISTINCT)|libc.Int32FromInt32(WHERE_KEEP_ALL_JOINS)) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OmitNoopJoin)) == uint32(0) { + notReady = _whereOmitNoopJoin(tls, pWInfo, notReady) + nTabList = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) + } + /* Check to see if there are any SEARCH loops that might benefit from + ** using a Bloom filter. + */ + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) >= int32(2) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_BloomFilter)) == uint32(0) { + _whereCheckIfBloomFilterIsUseful(tls, pWInfo) + } + v7 = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + 28 + *(*TLogEst)(unsafe.Pointer(v7)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v7))) + int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut)) + /* If the caller is an UPDATE or DELETE statement that is requesting + ** to use a one-pass algorithm, determine if this is appropriate. + ** + ** A one-pass approach can be used if the caller has requested one + ** and either (a) the scan visits at most one row or (b) each + ** of the following are true: + ** + ** * the caller has indicated that a one-pass approach can be used + ** with multiple rows (by setting WHERE_ONEPASS_MULTIROW), and + ** * the table is not a virtual table, and + ** * either the scan does not use the OR optimization or the caller + ** is a DELETE operation (WHERE_DUPLICATES_OK is only specified + ** for DELETE). + ** + ** The last qualification is because an UPDATE statement uses + ** WhereInfo.aiCurOnePass[1] to determine whether or not it really can + ** use a one-pass approach, and this is not set accurately for scans + ** that use the OR optimization. + */ + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_ONEPASS_DESIRED) != 0 { + wsFlags = libc.Int32FromUint32((*TWhereLoop)(unsafe.Pointer((*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856))).FpWLoop)).FwsFlags) + bOnerow = libc.BoolInt32(wsFlags&int32(WHERE_ONEROW) != 0) + if bOnerow != 0 || 0 != libc.Int32FromUint16(wctrlFlags)&int32(WHERE_ONEPASS_MULTIROW) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) && (0 == wsFlags&int32(WHERE_MULTI_OR) || libc.Int32FromUint16(wctrlFlags)&int32(WHERE_DUPLICATES_OK) != 0) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OnePass)) == uint32(0) { + if bOnerow != 0 { + v1 = int32(ONEPASS_SINGLE) + } else { + v1 = int32(ONEPASS_MULTI) + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass = libc.Uint8FromInt32(v1) + if (*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) && wsFlags&int32(WHERE_IDX_ONLY) != 0 { + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_ONEPASS_MULTIROW) != 0 { + bFordelete = uint8(OPFLAG_FORDELETE) + } + (*TWhereLoop)(unsafe.Pointer((*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856))).FpWLoop)).FwsFlags = libc.Uint32FromInt32(wsFlags & ^libc.Int32FromInt32(WHERE_IDX_ONLY)) + } + } + } + /* Open all tables in the pTabList and any indices selected for + ** searching those tables. + */ + ii = 0 + pLevel = pWInfo + 856 + for { + if !(ii < nTabList) { + break + } + pTabItem = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + pTab = (*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk = _sqlite3VdbeMakeLabel(tls, pParse) + if ii == 0 || libc.Int32FromUint8((**(**TSrcItem)(__ccgo_up(pTabItem))).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk + } else { + if (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(ii-int32(1))*112))).FpRJ != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(ii-int32(1))*112))).FaddrBrk + } else { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(ii-int32(1))*112))).FaddrHalt + } + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Ephemeral) != uint32(0) || libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + /* Do nothing */ + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { + pVTab = _sqlite3GetVTable(tls, db, pTab) + iCur = (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor + _sqlite3VdbeAddOp4(tls, v, int32(OP_VOpen), iCur, 0, 0, pVTab, -int32(12)) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + /* noop */ + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IDX_ONLY) == uint32(0) && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) == 0 || libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + op = int32(OP_OpenRead) + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF { + op = int32(OP_OpenWrite) + **(**int32)(__ccgo_up(pWInfo + 40)) = (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor + } + _sqlite3OpenTable(tls, pParse, (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor, iDb, pTab, op) + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF && int32((*TTable)(unsafe.Pointer(pTab)).FnCol) < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(libc.Int32FromInt32(TF_HasGenerated)|libc.Int32FromInt32(TF_WithoutRowid)) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_AUTO_INDEX)|libc.Int32FromInt32(WHERE_BLOOMFILTER)) == uint32(0) { + /* If we know that only a prefix of the record will be used, + ** it is advantageous to reduce the "column count" field in + ** the P4 operand of the OP_OpenRead/Write opcode. */ + b = (*TSrcItem)(unsafe.Pointer(pTabItem)).FcolUsed + n = 0 + for { + if !(b != 0) { + break + } + goto _15 + _15: + ; + b = b >> int32(1) + n = n + 1 + } + _sqlite3VdbeChangeP4(tls, v, -int32(1), uintptr(int64(n)), -int32(3)) + } + _sqlite3VdbeChangeP5(tls, v, uint16(bFordelete)) + if ii >= int32(2) && libc.Int32FromUint8((**(**TSrcItem)(__ccgo_up(pTabItem))).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_LEFT)) == 0 && (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt == (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856))).FaddrHalt { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfEmpty), (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak) + } + } else { + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab)).FzName) + } + } + } + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_INDEXED) != 0 { + pIx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + op1 = int32(OP_OpenRead) + /* iAuxArg is always set to a positive value if ONEPASS is possible */ + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) != 0 { + /* This is one term of an OR-optimization using the PRIMARY KEY of a + ** WITHOUT ROWID table. No need for a separate index */ + iIndexCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur + op1 = 0 + } else { + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF { + pJ = (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab)).FpIndex + iIndexCur = iAuxArg + for pJ != 0 && pJ != pIx { + iIndexCur = iIndexCur + 1 + pJ = (*TIndex)(unsafe.Pointer(pJ)).FpNext + } + op1 = int32(OP_OpenWrite) + **(**int32)(__ccgo_up(pWInfo + 40 + 1*4)) = iIndexCur + } else { + if iAuxArg != 0 && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) != 0 { + iIndexCur = iAuxArg + op1 = int32(OP_ReopenIdx) + } else { + v7 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v7)) + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + iIndexCur = v1 + if int32(uint32(*(*uint16)(unsafe.Pointer(pIx + 100))&0x800>>11)) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_IndexedExpr)) == uint32(0) { + _whereAddIndexedExpr(tls, pParse, pIx, iIndexCur, pTabItem) + } + if (*TIndex)(unsafe.Pointer(pIx)).FpPartIdxWhere != 0 && libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + _wherePartIdxExpr(tls, pParse, pIx, (*TIndex)(unsafe.Pointer(pIx)).FpPartIdxWhere, uintptr(0), iIndexCur, pTabItem) + } + } + } + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = iIndexCur + if op1 != 0 { + _sqlite3VdbeAddOp3(tls, v, op1, iIndexCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIx)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pIx) + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_CONSTRAINT) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_RANGE)|libc.Int32FromInt32(WHERE_SKIPSCAN)) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BIGNULL_SORT) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_SEEKSCAN) == uint32(0) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_ORDERBY_MIN) == 0 && libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) != int32(WHERE_DISTINCT_ORDERED) { + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SEEKEQ)) + } + } + } + if iDb >= 0 { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + } + if v19 = libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0; v19 { + v7 = _sqlite3WhereMalloc(tls, pWInfo, uint64(20)) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ = v7 + } + if v19 && v7 != uintptr(0) { + pRJ = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + v8 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v8)) + *(*int32)(unsafe.Pointer(v8)) = *(*int32)(unsafe.Pointer(v8)) + 1 + (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch = v1 + v7 = pParse + 60 + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + v1 = *(*int32)(unsafe.Pointer(v7)) + (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Blob), int32(65536), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom) + v7 = pParse + 60 + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + v1 = *(*int32)(unsafe.Pointer(v7)) + (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, int32(1)) + pInfo = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(1), 0) + if pInfo != 0 { + *(*uintptr)(unsafe.Pointer(pInfo + 32)) = uintptr(0) + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pInfo)).FaSortFlags)) = uint8(0) + _sqlite3VdbeAppendP4(tls, v, pInfo, -int32(9)) + } + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) + } + **(**Tu32)(__ccgo_up(pLoop + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(WHERE_IDX_ONLY)) + /* The nature of RIGHT JOIN processing is such that it messes up + ** the output order. So omit any ORDER BY/GROUP BY elimination + ** optimizations. We need to do an actual sort for RIGHT JOIN. */ + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = 0 + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_UNORDERED) + } + goto _14 + _14: + ; + ii = ii + 1 + pLevel += 112 + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiTop = _sqlite3VdbeCurrentAddr(tls, v) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto whereBeginError + } + /* Generate the code to do the search. Each iteration of the for + ** loop below generates code for a single nested loop of the VM + ** program. + */ + ii = 0 + for { + if !(ii < nTabList) { + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto whereBeginError + } + pLevel = pWInfo + 856 + uintptr(ii)*112 + wsFlags1 = libc.Int32FromUint32((*TWhereLoop)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags) + pSrc = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x20>>5) != 0 { + iOnce = 0 + pSubq = *(*uintptr)(unsafe.Pointer(pSrc + 72)) + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x10>>4) == 0 { + iOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } else { + iOnce = 0 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) + if iOnce != 0 { + _sqlite3VdbeJumpHere(tls, v, iOnce) + } + } + if wsFlags1&(libc.Int32FromInt32(WHERE_AUTO_INDEX)|libc.Int32FromInt32(WHERE_BLOOMFILTER)) != 0 { + if wsFlags1&int32(WHERE_AUTO_INDEX) != 0 { + _constructAutomaticIndex(tls, pParse, pWInfo+104, notReady, pLevel) + } else { + _sqlite3ConstructBloomFilter(tls, pWInfo, ii, pLevel, notReady) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto whereBeginError + } + } + addrExplain = _sqlite3WhereExplainOneScan(tls, pParse, pTabList, pLevel, wctrlFlags) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBody = _sqlite3VdbeCurrentAddr(tls, v) + notReady = _sqlite3WhereCodeOneLoopStart(tls, pParse, v, pWInfo, ii, pLevel, notReady) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiContinue = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont + if wsFlags1&int32(WHERE_MULTI_OR) == 0 && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) == 0 { + _ = addrExplain + } + goto _26 + _26: + ; + ii = ii + 1 + } + /* Done. */ + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiEndWhere = _sqlite3VdbeCurrentAddr(tls, v) + return pWInfo + /* Jump here if malloc fails */ + goto whereBeginError +whereBeginError: + ; + if pWInfo != 0 { + (*TParse)(unsafe.Pointer(pParse)).FnQueryLoop = int16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop) + _whereInfoFree(tls, db, pWInfo) + } + return uintptr(0) +} + +/* +** Part of sqlite3WhereEnd() will rewrite opcodes to reference the +** index rather than the main table. In SQLITE_DEBUG mode, we want +** to trace those changes if PRAGMA vdbe_addoptrace=on. This routine +** does that. + */ + +// C documentation +// +// /* +// ** Generate code for the start of the iLevel-th loop in the WHERE clause +// ** implementation described by pWInfo. +// */ +func _sqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWInfo uintptr, iLevel int32, pLevel uintptr, notReady TBitmask) (r2 TBitmask) { + bp := tls.Alloc(112) + defer tls.Free(112) + var aMoveOp [4]Tu8 + var addrBrk, addrCont, addrExplain, addrNotFound, addrNxt, addrSeekScan, bRev, endEq, iCache, iCol, iCol1, iCovCur, iCur, iFld, iIdxCur, iIn, iLoop, iLoopBody, iNext, iPk, iPk1, iReg, iReleaseReg, iRetInit, iRowidReg, iSet, iTab, iTarget, iTerm, ii, j, jmp1, jmp11, k, memEndValue, nConstraint, nConstraint1, nExtraReg, nNotReady, nPk, nPk1, omitTable, op, op1, r, r1, r11, regBase, regBignull, regReturn, regRowid, regRowset, regYield, skipLikeAddr, start, startEq, start_constraints, testOp, untestedTerms, v1, v2 int32 + var bSeekPastNull, bStopAtNull, t1, t2 Tu8 + var db, origSrc, pAlt, pAndExpr, pCompare, pCov, pDelete, pE, pE1, pEnd, pExpr, pIdx, pLeft, pLoop, pOp, pOrExpr, pOrTab, pOrTerm, pOrWc, pPk, pPk1, pPk2, pPk3, pRJ, pRJ1, pRangeEnd, pRangeStart, pRight, pRight1, pRight2, pRight3, pStart, pSubLoop, pSubWInfo, pSubq, pTab, pTab1, pTabItem, pTerm, pWC, pX, pX1, t, zEndAff, v4, v8 uintptr + var m TBitmask + var nBtm, nEq, nTop Tu16 + var v6 uint32 + var v15 bool + var _ /* rTemp at bp+0 */ int32 + var _ /* sEAlt at bp+16 */ TExpr + var _ /* zStartAff at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aMoveOp, addrBrk, addrCont, addrExplain, addrNotFound, addrNxt, addrSeekScan, bRev, bSeekPastNull, bStopAtNull, db, endEq, iCache, iCol, iCol1, iCovCur, iCur, iFld, iIdxCur, iIn, iLoop, iLoopBody, iNext, iPk, iPk1, iReg, iReleaseReg, iRetInit, iRowidReg, iSet, iTab, iTarget, iTerm, ii, j, jmp1, jmp11, k, m, memEndValue, nBtm, nConstraint, nConstraint1, nEq, nExtraReg, nNotReady, nPk, nPk1, nTop, omitTable, op, op1, origSrc, pAlt, pAndExpr, pCompare, pCov, pDelete, pE, pE1, pEnd, pExpr, pIdx, pLeft, pLoop, pOp, pOrExpr, pOrTab, pOrTerm, pOrWc, pPk, pPk1, pPk2, pPk3, pRJ, pRJ1, pRangeEnd, pRangeStart, pRight, pRight1, pRight2, pRight3, pStart, pSubLoop, pSubWInfo, pSubq, pTab, pTab1, pTabItem, pTerm, pWC, pX, pX1, r, r1, r11, regBase, regBignull, regReturn, regRowid, regRowset, regYield, skipLikeAddr, start, startEq, start_constraints, t, t1, t2, testOp, untestedTerms, zEndAff, v1, v15, v2, v4, v6, v8 /* Jump here to continue with next cycle */ + iRowidReg = 0 /* Rowid is stored in this register, if not zero */ + iReleaseReg = 0 /* Temp register to free before returning */ + pIdx = uintptr(0) /* Iteration of constraint generator loop */ + pWC = pWInfo + 104 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + pTabItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + iCur = (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor + (*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady = notReady & ^_sqlite3WhereGetMask(tls, pWInfo+592, iCur) + bRev = libc.Int32FromUint64((*TWhereInfo)(unsafe.Pointer(pWInfo)).FrevMask >> iLevel & uint64(1)) + /* Create labels for the "break" and "continue" instructions + ** for the current loop. Jump to addrBrk to break out of a loop. + ** Jump to cont to go immediately to the next iteration of the + ** loop. + ** + ** When there is an IN operator, we also have a "addrNxt" label that + ** means to continue with the next IN value combination. When + ** there are no IN operators in the constraints, the "addrNxt" label + ** is the same as "addrBrk". + */ + v1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt = v1 + addrBrk = v1 + v1 = _sqlite3VdbeMakeLabel(tls, pParse) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont = v1 + addrCont = v1 + /* If this is the right table of a LEFT OUTER JOIN, allocate and + ** initialize a memory cell that records if this table matches any + ** row of the left table of the join. + */ + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom) > 0 && libc.Int32FromUint8((**(**TSrcItem)(__ccgo_up(pTabItem))).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + } + /* Special case of a FROM clause subquery implemented as a co-routine */ + if int32(*(*uint32)(unsafe.Pointer(pTabItem + 24 + 4))&0x40>>6) != 0 { + pSubq = *(*uintptr)(unsafe.Pointer(pTabItem + 72)) + regYield = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Yield), regYield, addrBrk) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Goto) + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { + nConstraint = libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) + iReg = _sqlite3GetTempRange(tls, pParse, nConstraint+int32(2)) + addrNotFound = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk + j = 0 + for { + if !(j < nConstraint) { + break + } + iTarget = iReg + j + int32(2) + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) + if pTerm == uintptr(0) { + goto _5 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_IN) != 0 { + if j <= int32(31) { + v6 = libc.Uint32FromInt32(1) << j + } else { + v6 = uint32(0) + } + if v6&(*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FmHandleIn != 0 { + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + iTab = v1 + v8 = pParse + 60 + *(*int32)(unsafe.Pointer(v8)) = *(*int32)(unsafe.Pointer(v8)) + 1 + v2 = *(*int32)(unsafe.Pointer(v8)) + iCache = v2 + _sqlite3CodeRhsOfIN(tls, pParse, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, iTab, 0) + _sqlite3VdbeAddOp3(tls, v, int32(OP_VInitIn), iTab, iTarget, iCache) + } else { + _codeEqualityTerm(tls, pParse, pTerm, pLevel, j, bRev, iTarget) + addrNotFound = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt + } + } else { + pRight = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight + _codeExprOrVector(tls, pParse, pRight, iTarget, int32(1)) + if libc.Int32FromUint8((*TWhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp) == int32(SQLITE_INDEX_CONSTRAINT_OFFSET) && int32(Tu32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x2>>1)) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TSelect)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FiOffset) + } + } + goto _5 + _5: + ; + j = j + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxNum, iReg) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), nConstraint, iReg+int32(1)) + /* The instruction immediately prior to OP_VFilter must be an OP_Integer + ** that sets the "argc" value for xVFilter. This is necessary for + ** resolveP2() to work correctly. See tag-20250207a. */ + if int32(Tu32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x1>>0)) != 0 { + v1 = -int32(7) + } else { + v1 = -int32(1) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_VFilter), iCur, addrNotFound, iReg, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxStr, v1) + libc.SetBitFieldPtr8Uint32(pLoop+24+4, libc.Uint32FromInt32(0), 0, 0x1) + /* An OOM inside of AddOp4(OP_VFilter) instruction above might have freed + ** the u.vtab.idxStr. NULL it out to prevent a use-after-free */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxStr = uintptr(0) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass != 0 { + v1 = int32(OP_Noop) + } else { + v1 = int32(OP_VNext) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = libc.Uint8FromInt32(v1) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = _sqlite3VdbeCurrentAddr(tls, v) + j = 0 + for { + if !(j < nConstraint) { + break + } + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) + if j < int32(16) && libc.Int32FromUint16((*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FomitMask)>>j&int32(1) != 0 { + _disableTerm(tls, pLevel, pTerm) + goto _13 + } + if v15 = libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_IN) != 0; v15 { + if j <= int32(31) { + v6 = libc.Uint32FromInt32(1) << j + } else { + v6 = uint32(0) + } + } + if v15 && v6&(*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FmHandleIn == uint32(0) && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { /* IN loop corresponding to the j-th constraint */ + /* Reload the constraint value into reg[iReg+j+2]. The same value + ** was loaded into the same register prior to the OP_VFilter, but + ** the xFilter implementation might have changed the datatype or + ** encoding of the value in the register, so it *must* be reloaded. + */ + iIn = 0 + for { + if !(iIn < (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn) { + break + } + pOp = _sqlite3VdbeGetOp(tls, v, (**(**TInLoop)(__ccgo_up((*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FaInLoop + uintptr(iIn)*20))).FaddrInTop) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Column) && (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 == iReg+j+int32(2) || libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Rowid) && (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 == iReg+j+int32(2) { + _sqlite3VdbeAddOp3(tls, v, libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode), (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1, (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2, (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3) + break + } + goto _16 + _16: + ; + iIn = iIn + 1 + } + /* Generate code that will continue to the next row if + ** the IN constraint is not satisfied + */ + pCompare = _sqlite3PExpr(tls, pParse, int32(TK_EQ), uintptr(0), uintptr(0)) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + iFld = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField + pLeft = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft + if iFld > 0 { + (*TExpr)(unsafe.Pointer(pCompare)).FpLeft = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 32)) + 8 + uintptr(iFld-int32(1))*32))).FpExpr + } else { + (*TExpr)(unsafe.Pointer(pCompare)).FpLeft = pLeft + } + v4 = _sqlite3Expr(tls, db, int32(TK_REGISTER), uintptr(0)) + pRight1 = v4 + (*TExpr)(unsafe.Pointer(pCompare)).FpRight = v4 + if pRight1 != 0 { + (*TExpr)(unsafe.Pointer(pRight1)).FiTable = iReg + j + int32(2) + _sqlite3ExprIfFalse(tls, pParse, pCompare, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont, int32(SQLITE_JUMPIFNULL)) + } + (*TExpr)(unsafe.Pointer(pCompare)).FpLeft = uintptr(0) + } + _sqlite3ExprDelete(tls, db, pCompare) + } + goto _13 + _13: + ; + j = j + 1 + } + /* These registers need to be preserved in case there is an IN operator + ** loop. So we could deallocate the registers here (and potentially + ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems + ** simpler and safer to simply not reuse the registers. + ** + ** sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2); + */ + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_IN)|libc.Int32FromInt32(WHERE_COLUMN_EQ)) != uint32(0) { + /* Case 2: We can directly reference a single row using an + ** equality comparison against the ROWID field. Or + ** we reference multiple rows using a "rowid IN (...)" + ** construct. + */ + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + iReleaseReg = v1 + iRowidReg = _codeEqualityTerm(tls, pParse, pTerm, pLevel, 0, bRev, iReleaseReg) + if iRowidReg != iReleaseReg { + _sqlite3ReleaseTempReg(tls, pParse, iReleaseReg) + } + addrNxt = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_MustBeInt), iRowidReg, addrNxt) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Filter), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, addrNxt, iRowidReg, int32(1)) + _filterPullDown(tls, pParse, pWInfo, iLevel, addrNxt, notReady) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), iCur, addrNxt, iRowidReg) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Noop) + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_COLUMN_RANGE) != uint32(0) { + /* Case 3: We have an inequality comparison against the ROWID field. + */ + testOp = int32(OP_Noop) + memEndValue = 0 + j = 0 + v4 = libc.UintptrFromInt32(0) + pEnd = v4 + pStart = v4 + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BTM_LIMIT) != 0 { + v1 = j + j = j + 1 + pStart = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(v1)*8)) + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_TOP_LIMIT) != 0 { + v1 = j + j = j + 1 + pEnd = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(v1)*8)) + } + if bRev != 0 { + pTerm = pStart + pStart = pEnd + pEnd = pTerm + } + if pStart != 0 { /* Cursor seek operation */ + /* The following constant maps TK_xx codes into corresponding + ** seek opcodes. It depends on a particular ordering of TK_xx + */ + aMoveOp = [4]Tu8{ + 0: uint8(OP_SeekGT), + 1: uint8(OP_SeekLE), + 2: uint8(OP_SeekLT), + 3: uint8(OP_SeekGE), + } + /* Make sure the ordering.. */ + /* ... of the TK_xx values... */ + /* ... is correct. */ + pX = (*TWhereTerm)(unsafe.Pointer(pStart)).FpExpr + /* transitive constraints */ + if _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pX)).FpRight) != 0 { + v1 = _sqlite3GetTempReg(tls, pParse) + **(**int32)(__ccgo_up(bp)) = v1 + r11 = v1 + _codeExprOrVector(tls, pParse, (*TExpr)(unsafe.Pointer(pX)).FpRight, r11, int32(1)) + op = libc.Int32FromUint8(aMoveOp[(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop)-int32(TK_GT)-int32(1))&int32(0x3)|int32(0x1)]) + } else { + r11 = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pX)).FpRight, bp) + _disableTerm(tls, pLevel, pStart) + op = libc.Int32FromUint8(aMoveOp[libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop)-int32(TK_GT)]) + } + _sqlite3VdbeAddOp3(tls, v, op, iCur, addrBrk, r11) + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp))) + } else { + if bRev != 0 { + v1 = int32(OP_Last) + } else { + v1 = int32(OP_Rewind) + } + _sqlite3VdbeAddOp2(tls, v, v1, iCur, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt) + } + if pEnd != 0 { + pX1 = (*TWhereTerm)(unsafe.Pointer(pEnd)).FpExpr + /* Transitive constraints */ + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + memEndValue = v1 + _codeExprOrVector(tls, pParse, (*TExpr)(unsafe.Pointer(pX1)).FpRight, memEndValue, int32(1)) + if 0 == _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pX1)).FpRight) && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX1)).Fop) == int32(TK_LT) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX1)).Fop) == int32(TK_GT)) { + if bRev != 0 { + v1 = int32(OP_Le) + } else { + v1 = int32(OP_Ge) + } + testOp = v1 + } else { + if bRev != 0 { + v1 = int32(OP_Lt) + } else { + v1 = int32(OP_Gt) + } + testOp = v1 + } + if 0 == _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pX1)).FpRight) { + _disableTerm(tls, pLevel, pEnd) + } + } + start = _sqlite3VdbeCurrentAddr(tls, v) + if bRev != 0 { + v1 = int32(OP_Prev) + } else { + v1 = int32(OP_Next) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = libc.Uint8FromInt32(v1) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = start + if testOp != int32(OP_Noop) { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + iRowidReg = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iCur, iRowidReg) + _sqlite3VdbeAddOp3(tls, v, testOp, memEndValue, addrBrk, iRowidReg) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(libc.Int32FromInt32(SQLITE_AFF_NUMERIC)|libc.Int32FromInt32(SQLITE_JUMPIFNULL))) + } + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_INDEXED) != 0 { + nEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq /* Number of == or IN terms */ + nBtm = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm /* Length of BTM vector */ + nTop = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop /* Base register holding constraint values */ + pRangeStart = uintptr(0) /* Inequality constraint at range start */ + pRangeEnd = uintptr(0) /* The VDBE cursor for the index */ + nExtraReg = 0 /* Affinity for start of range constraint */ + zEndAff = uintptr(0) /* Affinity for end of range constraint */ + bSeekPastNull = uint8(0) /* True to seek past initial nulls */ + bStopAtNull = uint8(0) /* True if we use the index only */ + regBignull = 0 /* big-null flag register */ + addrSeekScan = 0 /* Opcode of the OP_SeekScan, if any */ + pIdx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + iIdxCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + /* Find any inequality constraint terms for the start and end + ** of the range. + */ + j = libc.Int32FromUint16(nEq) + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BTM_LIMIT) != 0 { + v1 = j + j = j + 1 + pRangeStart = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(v1)*8)) + if nExtraReg > libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm) { + v1 = nExtraReg + } else { + v1 = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm) + } + nExtraReg = v1 + /* Like optimization range constraints always occur in pairs */ + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_TOP_LIMIT) != 0 { + v1 = j + j = j + 1 + pRangeEnd = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(v1)*8)) + if nExtraReg > libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop) { + v1 = nExtraReg + } else { + v1 = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop) + } + nExtraReg = v1 + if pRangeStart == uintptr(0) { + j = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(nEq)*2))) + if j >= 0 && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(j)*16 + 8))&0xf>>0)) == 0 || j == -int32(2) { + bSeekPastNull = uint8(1) + } + } + } + /* If the WHERE_BIGNULL_SORT flag is set, then index column nEq uses + ** a non-default "big-null" sort (either ASC NULLS LAST or DESC NULLS + ** FIRST). In both cases separate ordered scans are made of those + ** index entries for which the column is null and for those for which + ** it is not. For an ASC sort, the non-NULL entries are scanned first. + ** For DESC, NULL entries are scanned first. + */ + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_TOP_LIMIT)|libc.Int32FromInt32(WHERE_BTM_LIMIT)) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BIGNULL_SORT) != uint32(0) { + nExtraReg = int32(1) + bSeekPastNull = uint8(1) + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v2 = *(*int32)(unsafe.Pointer(v4)) + v1 = v2 + regBignull = v1 + (*TWhereLevel)(unsafe.Pointer(pLevel)).FregBignull = v1 + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regBignull) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull = _sqlite3VdbeMakeLabel(tls, pParse) + } + /* If we are doing a reverse order scan on an ascending index, or + ** a forward order scan on a descending index, interchange the + ** start and end terms (pRangeStart and pRangeEnd). + */ + if libc.Int32FromUint16(nEq) < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) && bRev == libc.BoolInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) == SQLITE_SO_ASC) { + t = pRangeEnd + pRangeEnd = pRangeStart + pRangeStart = t + t1 = bSeekPastNull + bSeekPastNull = bStopAtNull + bStopAtNull = t1 + t2 = uint8(nBtm) + nBtm = nTop + nTop = uint16(t2) + } + if iLevel > 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_SEEKSCAN) != uint32(0) { + /* In case OP_SeekScan is used, ensure that the index cursor does not + ** point to a valid row for the first iteration of this loop. */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iIdxCur) + } + /* Generate code to evaluate all constraint terms using == or IN + ** and store the values of those terms in an array of registers + ** starting at regBase. + */ + regBase = _codeAllEqualityTerms(tls, pParse, pLevel, bRev, nExtraReg, bp+8) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 && nTop != 0 { + zEndAff = _sqlite3DbStrDup(tls, db, **(**uintptr)(__ccgo_up(bp + 8))+uintptr(nEq)) + } + if regBignull != 0 { + v1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull + } else { + v1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt + } + addrNxt = v1 + startEq = libc.BoolInt32(!(pRangeStart != 0) || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pRangeStart)).FeOperator)&(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) != 0) + endEq = libc.BoolInt32(!(pRangeEnd != 0) || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pRangeEnd)).FeOperator)&(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) != 0) + start_constraints = libc.BoolInt32(pRangeStart != 0 || libc.Int32FromUint16(nEq) > 0) + /* Seek the index cursor to the start of the range. */ + nConstraint1 = libc.Int32FromUint16(nEq) + if pRangeStart != 0 { + pRight2 = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pRangeStart)).FpExpr)).FpRight + _codeExprOrVector(tls, pParse, pRight2, regBase+libc.Int32FromUint16(nEq), libc.Int32FromUint16(nBtm)) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pRangeStart)).FwtFlags)&int32(TERM_VNULL) == 0 && _sqlite3ExprCanBeNull(tls, pRight2) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regBase+libc.Int32FromUint16(nEq), addrNxt) + } + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _updateRangeAffinityStr(tls, pRight2, libc.Int32FromUint16(nBtm), **(**uintptr)(__ccgo_up(bp + 8))+uintptr(nEq)) + } + nConstraint1 = nConstraint1 + libc.Int32FromUint16(nBtm) + if _sqlite3ExprIsVector(tls, pRight2) == 0 { + _disableTerm(tls, pLevel, pRangeStart) + } else { + startEq = int32(1) + } + bSeekPastNull = uint8(0) + } else { + if bSeekPastNull != 0 { + startEq = 0 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regBase+libc.Int32FromUint16(nEq)) + start_constraints = int32(1) + nConstraint1 = nConstraint1 + 1 + } else { + if regBignull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regBase+libc.Int32FromUint16(nEq)) + start_constraints = int32(1) + nConstraint1 = nConstraint1 + 1 + } + } + } + _codeApplyAffinity(tls, pParse, regBase, nConstraint1-libc.Int32FromUint8(bSeekPastNull), **(**uintptr)(__ccgo_up(bp + 8))) + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) > 0 && nConstraint1 == libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) { + /* The skip-scan logic inside the call to codeAllEqualityConstraints() + ** above has already left the cursor sitting on the correct row, + ** so no further seeking is needed */ + } else { + if regBignull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), regBignull) + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Filter), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, addrNxt, regBase, libc.Int32FromUint16(nEq)) + _filterPullDown(tls, pParse, pWInfo, iLevel, addrNxt, notReady) + } + op1 = libc.Int32FromUint8(_aStartOp[start_constraints< int32(1))*int32(4)+int32(2)+bRev]) + _sqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase, nConstraint1-startEq) + } + } + /* Load the value for the inequality constraint at the end of the + ** range (if any). + */ + nConstraint1 = libc.Int32FromUint16(nEq) + if pRangeEnd != 0 { + pRight3 = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pRangeEnd)).FpExpr)).FpRight + _codeExprOrVector(tls, pParse, pRight3, regBase+libc.Int32FromUint16(nEq), libc.Int32FromUint16(nTop)) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pRangeEnd)).FwtFlags)&int32(TERM_VNULL) == 0 && _sqlite3ExprCanBeNull(tls, pRight3) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regBase+libc.Int32FromUint16(nEq), addrNxt) + } + if zEndAff != 0 { + _updateRangeAffinityStr(tls, pRight3, libc.Int32FromUint16(nTop), zEndAff) + _codeApplyAffinity(tls, pParse, regBase+libc.Int32FromUint16(nEq), libc.Int32FromUint16(nTop), zEndAff) + } else { + } + nConstraint1 = nConstraint1 + libc.Int32FromUint16(nTop) + if _sqlite3ExprIsVector(tls, pRight3) == 0 { + _disableTerm(tls, pLevel, pRangeEnd) + } else { + endEq = int32(1) + } + } else { + if bStopAtNull != 0 { + if regBignull == 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regBase+libc.Int32FromUint16(nEq)) + endEq = 0 + } + nConstraint1 = nConstraint1 + 1 + } + } + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _sqlite3DbNNFreeNN(tls, db, **(**uintptr)(__ccgo_up(bp + 8))) + } + if zEndAff != 0 { + _sqlite3DbNNFreeNN(tls, db, zEndAff) + } + /* Top of the loop body */ + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = _sqlite3VdbeCurrentAddr(tls, v) + /* Check if the index cursor is past the end of the range. */ + if nConstraint1 != 0 { + if regBignull != 0 { + /* Except, skip the end-of-range check while doing the NULL-scan */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNot), regBignull, _sqlite3VdbeCurrentAddr(tls, v)+int32(3)) + } + op1 = libc.Int32FromUint8(_aEndOp[bRev*int32(2)+endEq]) + _sqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase, nConstraint1) + if addrSeekScan != 0 { + _sqlite3VdbeJumpHere(tls, v, addrSeekScan) + } + } + if regBignull != 0 { + /* During a NULL-scan, check to see if we have reached the end of + ** the NULLs */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_If), regBignull, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + op1 = libc.Int32FromUint8(_aEndOp[bRev*int32(2)+libc.Int32FromUint8(bSeekPastNull)]) + _sqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase, nConstraint1+libc.Int32FromUint8(bSeekPastNull)) + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_EARLYOUT) != uint32(0) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekHit), iIdxCur, libc.Int32FromUint16(nEq), libc.Int32FromUint16(nEq)) + } + /* Seek the table cursor, if required */ + omitTable = libc.BoolInt32((*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IDX_ONLY) != uint32(0) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(libc.Int32FromInt32(WHERE_OR_SUBCLAUSE)|libc.Int32FromInt32(WHERE_RIGHT_JOIN)) == 0) + if omitTable != 0 { + /* pIdx is a covering index. No need to access the main table. */ + } else { + if (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _codeDeferredSeek(tls, pWInfo, pIdx, iCur, iIdxCur) + } else { + if iCur != iIdxCur { + pPk = _sqlite3PrimaryKeyIndex(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpTable) + iRowidReg = _sqlite3GetTempRange(tls, pParse, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + k = _sqlite3TableColumnToIndex(tls, pIdx, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, k, iRowidReg+j) + goto _40 + _40: + ; + j = j + 1 + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), iCur, addrCont, iRowidReg, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + } + } + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0 { + /* If a partial index is driving the loop, try to eliminate WHERE clause + ** terms from the query that must be true due to the WHERE clause of + ** the partial index. This optimization does not work on an outer join, + ** as shown by: + ** + ** 2019-11-02 ticket 623eff57e76d45f6 (LEFT JOIN) + ** 2025-05-29 forum post 7dee41d32506c4ae (RIGHT JOIN) + */ + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 && (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ == uintptr(0) { + _whereApplyPartialIndexConstraints(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere, iCur, pWC) + } + } else { + /* The following assert() is not a requirement, merely an observation: + ** The OR-optimization doesn't work for the right hand table of + ** a LEFT JOIN: */ + } + /* Record the instruction used to terminate the loop. */ + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_ONEROW) != 0 || (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn != 0 && regBignull == 0 && _whereLoopIsOneRow(tls, pLoop) != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Noop) + } else { + if bRev != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Prev) + } else { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Next) + } + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iIdxCur + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_UNQ_WANTED) != uint32(0) { + v1 = int32(1) + } else { + v1 = 0 + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp3 = libc.Uint8FromInt32(v1) + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_CONSTRAINT) == uint32(0) { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp5 = uint8(SQLITE_STMTSTATUS_FULLSCAN_STEP) + } else { + } + if omitTable != 0 { + pIdx = uintptr(0) + } + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_MULTI_OR) != 0 { /* Shortened table list or OR-clause generation */ + pCov = uintptr(0) + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 /* Potential covering index (or NULL) */ + iCovCur = v1 + v8 = pParse + 60 + *(*int32)(unsafe.Pointer(v8)) = *(*int32)(unsafe.Pointer(v8)) + 1 + v2 = *(*int32)(unsafe.Pointer(v8)) /* Cursor used for index scans (if any) */ + regReturn = v2 /* Register used with OP_Gosub */ + regRowset = 0 /* Register for RowSet object */ + regRowid = 0 /* Register holding rowid */ + iLoopBody = _sqlite3VdbeMakeLabel(tls, pParse) /* Address of regReturn init */ + untestedTerms = 0 /* Loop counter */ + pAndExpr = uintptr(0) /* An ".. AND (...)" expression */ + pTab = (*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) + pOrWc = *(*uintptr)(unsafe.Pointer(pTerm + 32)) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Return) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = regReturn + /* Set up a new SrcList in pOrTab containing the table being scanned + ** by this loop in the a[0] slot and all notReady tables in a[1..] slots. + ** This becomes the SrcList in the recursive call to sqlite3WhereBegin(). + */ + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) > int32(1) || int32(*(*uint32)(unsafe.Pointer(pTabItem + 24 + 4))&0x40000>>18) != 0 { /* Original list of tables */ + nNotReady = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - iLevel - int32(1) + pOrTab = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32(nNotReady+libc.Int32FromInt32(1))*libc.Uint64FromInt64(80))) + if pOrTab == uintptr(0) { + return notReady + } + (*TSrcList)(unsafe.Pointer(pOrTab)).FnAlloc = uint32(libc.Uint8FromInt32(nNotReady + libc.Int32FromInt32(1))) + (*TSrcList)(unsafe.Pointer(pOrTab)).FnSrc = libc.Int32FromUint32((*TSrcList)(unsafe.Pointer(pOrTab)).FnAlloc) + libc.Xmemcpy(tls, pOrTab+8, pTabItem, uint64(80)) + origSrc = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + k = int32(1) + for { + if !(k <= nNotReady) { + break + } + libc.Xmemcpy(tls, pOrTab+8+uintptr(k)*80, origSrc+uintptr((**(**TWhereLevel)(__ccgo_up(pLevel + uintptr(k)*112))).FiFrom)*80, uint64(80)) + goto _46 + _46: + ; + k = k + 1 + } + /* Clear the fromExists flag on the OR-optimized table entry so that + ** the calls to sqlite3WhereEnd() do not code early-exits after the + ** first row is visited. The early exit applies to this table's + ** overall loop - including the multiple OR branches and any WHERE + ** conditions not passed to the sub-loops - not to the sub-loops. */ + libc.SetBitFieldPtr32Uint32(pOrTab+8+24+4, libc.Uint32FromInt32(0), 18, 0x40000) + } else { + pOrTab = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + } + /* Initialize the rowset register to contain NULL. An SQL NULL is + ** equivalent to an empty rowset. Or, create an ephemeral index + ** capable of holding primary keys in the case of a WITHOUT ROWID. + ** + ** Also initialize regReturn to contain the address of the instruction + ** immediately following the OP_Return at the bottom of the loop. This + ** is required in a few obscure LEFT JOIN cases where control jumps + ** over the top of the loop into the body of it. In this case the + ** correct response for the end-of-loop code (the OP_Return) is to + ** fall through to the next instruction, just as an OP_Next does if + ** called on an uninitialized cursor. + */ + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DUPLICATES_OK) == 0 { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regRowset = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regRowset) + } else { + pPk1 = _sqlite3PrimaryKeyIndex(tls, pTab) + v4 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + regRowset = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), regRowset, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pPk1) + } + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + regRowid = v1 + } + iRetInit = _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regReturn) + /* If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y + ** Then for every term xN, evaluate as the subexpression: xN AND y + ** That way, terms in y that are factored into the disjunction will + ** be picked up by the recursive calls to sqlite3WhereBegin() below. + ** + ** Actually, each subexpression is converted to "xN AND w" where w is + ** the "interesting" terms of z - terms that did not originate in the + ** ON or USING clause of a LEFT JOIN, and terms that are usable as + ** indices. + ** + ** This optimization also only applies if the (x1 OR x2 OR ...) term + ** is not contained in the ON clause of a LEFT JOIN. + ** See ticket http://sqlite.org/src/info/f2369304e4 + ** + ** 2022-02-04: Do not push down slices of a row-value comparison. + ** In other words, "w" or "y" may not be a slice of a vector. Otherwise, + ** the initialization of the right-hand operand of the vector comparison + ** might not occur, or might occur only in an OR branch that is not + ** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1. + ** + ** 2022-03-03: Do not push down expressions that involve subqueries. + ** The subquery might get coded as a subroutine. Any table-references + ** in the subquery might be resolved to index-references for the index on + ** the OR branch in which the subroutine is coded. But if the subroutine + ** is invoked from a different OR branch that uses a different index, such + ** index-references will not work. tag-20220303a + ** https://sqlite.org/forum/forumpost/36937b197273d403 + */ + if (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm > int32(1) { + iTerm = 0 + for { + if !(iTerm < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + pExpr = (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iTerm)*56))).FpExpr + if (*TWhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*56 == pTerm { + goto _53 + } + if libc.Int32FromUint16((**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iTerm)*56))).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_CODED)|libc.Int32FromInt32(TERM_SLICE)) != 0 { + goto _53 + } + if libc.Int32FromUint16((**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iTerm)*56))).FeOperator)&int32(WO_ALL) == 0 { + goto _53 + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + goto _53 + } /* tag-20220303a */ + pExpr = _sqlite3ExprDup(tls, db, pExpr, 0) + pAndExpr = _sqlite3ExprAnd(tls, pParse, pAndExpr, pExpr) + goto _53 + _53: + ; + iTerm = iTerm + 1 + } + if pAndExpr != 0 { + /* The extra 0x10000 bit on the opcode is masked off and does not + ** become part of the new Expr.op. However, it does make the + ** op==TK_AND comparison inside of sqlite3PExpr() false, and this + ** prevents sqlite3PExpr() from applying the AND short-circuit + ** optimization, which we do not want here. */ + pAndExpr = _sqlite3PExpr(tls, pParse, libc.Int32FromInt32(TK_AND)|libc.Int32FromInt32(0x10000), uintptr(0), pAndExpr) + } + } + /* Run a separate WHERE clause for each term of the OR clause. After + ** eliminating duplicates from other WHERE clauses, the action for each + ** sub-WHERE clause is to to invoke the main loop body as a subroutine. + */ + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+23831, 0) + ii = 0 + for { + if !(ii < (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm) { + break + } + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr(ii)*56 + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_AND) != 0 { /* Info for single OR-term scan */ + pOrExpr = (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr /* Local copy of OR clause term */ + jmp1 = 0 /* Address of jump operation */ + /* See TH3 vtab25.400 and ticket 614b25314c766238 */ + v4 = _sqlite3ExprDup(tls, db, pOrExpr, 0) + pOrExpr = v4 + pDelete = v4 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pDelete) + goto _54 + } + if pAndExpr != 0 { + (*TExpr)(unsafe.Pointer(pAndExpr)).FpLeft = pOrExpr + pOrExpr = pAndExpr + } + /* Loop through table entries that match term pOrTerm. */ + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+23846, libc.VaList(bp+96, ii+int32(1))) + pSubWInfo = _sqlite3WhereBegin(tls, pParse, pOrTab, pOrExpr, uintptr(0), uintptr(0), uintptr(0), uint16(WHERE_OR_SUBCLAUSE), iCovCur) + if pSubWInfo != 0 { + addrExplain = _sqlite3WhereExplainOneScan(tls, pParse, pOrTab, pSubWInfo+856, uint16(0)) + _ = addrExplain + /* This is the sub-WHERE clause body. First skip over + ** duplicate rows from prior sub-WHERE clauses, and record the + ** rowid (or PRIMARY KEY) for the current row so that the same + ** row will be skipped in subsequent sub-WHERE clauses. + */ + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DUPLICATES_OK) == 0 { + if ii == (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm-int32(1) { + v1 = -int32(1) + } else { + v1 = ii + } + iSet = v1 + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, -int32(1), regRowid) + jmp1 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_RowSetTest), regRowset, 0, regRowid, iSet) + } else { + pPk2 = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk2)).FnKeyCol) + /* Read the PK into an array of temp registers. */ + r = _sqlite3GetTempRange(tls, pParse, nPk) + iPk = 0 + for { + if !(iPk < nPk) { + break + } + iCol = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk2)).FaiColumn + uintptr(iPk)*2))) + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, iCol, r+iPk) + goto _57 + _57: + ; + iPk = iPk + 1 + } + /* Check if the temp table already contains this key. If so, + ** the row has already been included in the result set and + ** can be ignored (by jumping past the Gosub below). Otherwise, + ** insert the key into the temp table and proceed with processing + ** the row. + ** + ** Use some of the same optimizations as OP_RowSetTest: If iSet + ** is zero, assume that the key cannot already be present in + ** the temp table. And if iSet is -1, assume that there is no + ** need to insert the key into the temp table, as it will never + ** be tested for. */ + if iSet != 0 { + jmp1 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), regRowset, 0, r, nPk) + } + if iSet >= 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), r, nPk, regRowid) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), regRowset, regRowid, r, nPk) + if iSet != 0 { + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + } + } + /* Release the array of temp registers */ + _sqlite3ReleaseTempRange(tls, pParse, r, nPk) + } + } + /* Invoke the main loop body as a subroutine */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), regReturn, iLoopBody) + /* Jump here (skipping the main loop body subroutine) if the + ** current sub-WHERE row is a duplicate from prior sub-WHEREs. */ + if jmp1 != 0 { + _sqlite3VdbeJumpHere(tls, v, jmp1) + } + /* The pSubWInfo->untestedTerms flag means that this OR term + ** contained one or more AND term from a notReady table. The + ** terms from the notReady table could not be tested and will + ** need to be tested later. + */ + if int32(uint32(*(*uint8)(unsafe.Pointer(pSubWInfo + 68))&0x2>>1)) != 0 { + untestedTerms = int32(1) + } + /* If all of the OR-connected terms are optimized using the same + ** index, and the index is opened using the same cursor number + ** by each call to sqlite3WhereBegin() made by this loop, it may + ** be possible to use that index as a covering index. + ** + ** If the call to sqlite3WhereBegin() above resulted in a scan that + ** uses an index, and this is either the first OR-connected term + ** processed or the index is the same as that used by all previous + ** terms, set pCov to the candidate covering index. Otherwise, set + ** pCov to NULL to indicate that no candidate covering index will + ** be available. + */ + pSubLoop = (*(*TWhereLevel)(unsafe.Pointer(pSubWInfo + 856))).FpWLoop + if (*TWhereLoop)(unsafe.Pointer(pSubLoop)).FwsFlags&uint32(WHERE_INDEXED) != uint32(0) && (ii == 0 || (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pSubLoop + 24))).FpIndex == pCov) && ((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || !(int32(uint32(*(*uint16)(unsafe.Pointer((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pSubLoop + 24))).FpIndex + 100))&0x3>>0)) == libc.Int32FromInt32(SQLITE_IDXTYPE_PRIMARYKEY))) { + pCov = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pSubLoop + 24))).FpIndex + } else { + pCov = uintptr(0) + } + if _sqlite3WhereUsesDeferredSeek(tls, pSubWInfo) != 0 { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 0, 0x1) + } + /* Finish the loop through table entries that match term pOrTerm. */ + _sqlite3WhereEnd(tls, pSubWInfo) + _sqlite3VdbeExplainPop(tls, pParse) + } + _sqlite3ExprDelete(tls, db, pDelete) + } + goto _54 + _54: + ; + ii = ii + 1 + } + _sqlite3VdbeExplainPop(tls, pParse) + *(*uintptr)(unsafe.Pointer(&(*TWhereLevel)(unsafe.Pointer(pLevel)).Fu)) = pCov + if pCov != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = iCovCur + } + if pAndExpr != 0 { + (*TExpr)(unsafe.Pointer(pAndExpr)).FpLeft = uintptr(0) + _sqlite3ExprDelete(tls, db, pAndExpr) + } + _sqlite3VdbeChangeP1(tls, v, iRetInit, _sqlite3VdbeCurrentAddr(tls, v)) + _sqlite3VdbeGoto(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + _sqlite3VdbeResolveLabel(tls, v, iLoopBody) + /* Set the P2 operand of the OP_Return opcode that will end the current + ** loop to point to this spot, which is the top of the next containing + ** loop. The byte-code formatter will use that P2 value as a hint to + ** indent everything in between the this point and the final OP_Return. + ** See tag-20220407a in vdbe.c and shell.c */ + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = _sqlite3VdbeCurrentAddr(tls, v) + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList != pOrTab { + _sqlite3DbFreeNN(tls, db, pOrTab) + } + if !(untestedTerms != 0) { + _disableTerm(tls, pLevel, pTerm) + } + } else { + if int32(*(*uint32)(unsafe.Pointer(pTabItem + 24 + 4))&0x80>>7) != 0 { + /* Tables marked isRecursive have only a single row that is stored in + ** a pseudo-cursor. No need to Rewind or Next such cursors. */ + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = uint8(OP_Noop) + } else { + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fop = _aStep[bRev] + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2 = int32(1) + _sqlite3VdbeAddOp2(tls, v, libc.Int32FromUint8(_aStart[bRev]), iCur, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt) + (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp5 = uint8(SQLITE_STMTSTATUS_FULLSCAN_STEP) + } + } + } + } + } + } + } + /* Insert code to test every subexpression that can be completely + ** computed using the current set of tables. + ** + ** This loop may run between one and three times, depending on the + ** constraints to be generated. The value of stack variable iLoop + ** determines the constraints coded by each iteration, as follows: + ** + ** iLoop==1: Code only expressions that are entirely covered by pIdx. + ** iLoop==2: Code remaining expressions that do not contain correlated + ** sub-queries. + ** iLoop==3: Code all remaining expressions. + ** + ** An effort is made to skip unnecessary iterations of the loop. + ** + ** This optimization of causing simple query restrictions to occur before + ** more complex one is call the "push-down" optimization in MySQL. Here + ** in SQLite, the name is "MySQL push-down", since there is also another + ** totally unrelated optimization called "WHERE-clause push-down". + ** Sometimes the qualifier is omitted, resulting in an ambiguity, so beware. + */ + if pIdx != 0 { + v1 = int32(1) + } else { + v1 = int32(2) + } + iLoop = v1 + for cond := true; cond; cond = iLoop > 0 { + iNext = 0 /* Next value for iLoop */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + j = (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm + for { + if !(j > 0) { + break + } + skipLikeAddr = 0 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_CODED)) != 0 { + goto _59 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady != uint64(0) { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 1, 0x2) + goto _59 + } + pE = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + if !((*TExpr)(unsafe.Pointer(pE)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != libc.Uint32FromInt32(0)) { + /* Defer processing WHERE clause constraints until after outer + ** join processing. tag-20220513a */ + goto _59 + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_LEFT) == int32(JT_LEFT) && !((*TExpr)(unsafe.Pointer(pE)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) { + goto _59 + } else { + m = _sqlite3WhereGetMask(tls, pWInfo+592, *(*int32)(unsafe.Pointer(pE + 52))) + if m&(*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady != 0 { + /* An ON clause that is not ripe */ + goto _59 + } + } + } + } + if iLoop == int32(1) && !(_sqlite3ExprCoveredByIndex(tls, pE, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, pIdx) != 0) { + iNext = int32(2) + goto _59 + } + if iLoop < int32(3) && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VARSELECT) != 0 { + if iNext == 0 { + iNext = int32(3) + } + goto _59 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_LIKECOND) != 0 { + /* If the TERM_LIKECOND flag is set, that means that the range search + ** is sufficient to guarantee that the LIKE operator is true, so we + ** can skip the call to the like(A,B) function. But this only works + ** for strings. So do not skip the call to the function on the pass + ** that compares BLOBs. */ + goto _59 + } + _sqlite3ExprIfFalse(tls, pParse, pE, addrCont, int32(SQLITE_JUMPIFNULL)) + if skipLikeAddr != 0 { + _sqlite3VdbeJumpHere(tls, v, skipLikeAddr) + } + v4 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(TERM_CODED)) + goto _59 + _59: + ; + j = j - 1 + pTerm += 56 + } + iLoop = iNext + } + /* Insert code to test for implied constraints based on transitivity + ** of the "==" operator. + ** + ** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123" + ** and we are coding the t1 loop and the t2 loop has not yet coded, + ** then we cannot use the "t1.a=t2.b" constraint, but we can code + ** the implied "t1.a=123" constraint. + */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + j = (*TWhereClause)(unsafe.Pointer(pWC)).FnBase + for { + if !(j > 0) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_CODED)) != 0 { + goto _61 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) == 0 { + goto _61 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_EQUIV) == 0 { + goto _61 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != iCur { + goto _61 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + goto _61 + } + pE1 = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + pAlt = _sqlite3WhereFindTerm(tls, pWC, iCur, (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn, notReady, libc.Uint32FromInt32(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IN)|libc.Int32FromInt32(WO_IS)), uintptr(0)) + if pAlt == uintptr(0) { + goto _61 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pAlt)).FwtFlags)&int32(TERM_CODED) != 0 { + goto _61 + } + if (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != uint32(0) { + goto _61 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pAlt)).FeOperator)&int32(WO_IN) != 0 && (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAlt)).FpExpr + 32)))).FpEList)).FnExpr > int32(1) { + goto _61 + } + **(**TExpr)(__ccgo_up(bp + 16)) = **(**TExpr)(__ccgo_up((*TWhereTerm)(unsafe.Pointer(pAlt)).FpExpr)) + (**(**TExpr)(__ccgo_up(bp + 16))).FpLeft = (*TExpr)(unsafe.Pointer(pE1)).FpLeft + _sqlite3ExprIfFalse(tls, pParse, bp+16, addrCont, int32(SQLITE_JUMPIFNULL)) + v4 = pAlt + 18 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(TERM_CODED)) + goto _61 + _61: + ; + j = j - 1 + pTerm += 56 + } + /* For a RIGHT OUTER JOIN, record the fact that the current row has + ** been matched at least once. + */ + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 { + jmp11 = 0 + pRJ = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + /* pTab is the right-hand table of the RIGHT JOIN. Generate code that + ** will record that the current row of that table has been matched at + ** least once. This is accomplished by storing the PK for the row in + ** both the iMatch index and the regBloom Bloom filter. + */ + pTab1 = (*(*TSrcItem)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80))).FpSTab + if (*TTable)(unsafe.Pointer(pTab1)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + r1 = _sqlite3GetTempRange(tls, pParse, int32(2)) + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab1, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, -int32(1), r1+int32(1)) + nPk1 = int32(1) + } else { + pPk3 = _sqlite3PrimaryKeyIndex(tls, pTab1) + nPk1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk3)).FnKeyCol) + r1 = _sqlite3GetTempRange(tls, pParse, nPk1+int32(1)) + iPk1 = 0 + for { + if !(iPk1 < nPk1) { + break + } + iCol1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk3)).FaiColumn + uintptr(iPk1)*2))) + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab1, iCur, iCol1, r1+int32(1)+iPk1) + goto _63 + _63: + ; + iPk1 = iPk1 + 1 + } + } + jmp11 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, 0, r1+int32(1), nPk1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), r1+int32(1), nPk1, r1) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, r1, r1+int32(1), nPk1) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom, 0, r1+int32(1), nPk1) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + _sqlite3VdbeJumpHere(tls, v, jmp11) + _sqlite3ReleaseTempRange(tls, pParse, r1, nPk1+int32(1)) + } + /* For a LEFT OUTER JOIN, generate code that will record the fact that + ** at least one row of the right table has matched the left table. + */ + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ == uintptr(0) { + goto code_outer_join_constraints /* WHERE clause constraints */ + } + } + if !((*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0) { + goto _64 + } + /* Create a subroutine used to process all interior loops and code + ** of the RIGHT JOIN. During normal operation, the subroutine will + ** be in-line with the rest of the code. But at the end, a separate + ** loop will run that invokes this subroutine for unmatched rows + ** of pTab, with all tables to left begin set to NULL. + */ + pRJ1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + _sqlite3VdbeAddOp2(tls, v, int32(OP_BeginSubrtn), 0, (*TWhereRightJoin)(unsafe.Pointer(pRJ1)).FregReturn) + (*TWhereRightJoin)(unsafe.Pointer(pRJ1)).FaddrSubrtn = _sqlite3VdbeCurrentAddr(tls, v) + (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn + 1 + /* WHERE clause constraints must be deferred until after outer join + ** row elimination has completed, since WHERE clause constraints apply + ** to the results of the OUTER JOIN. The following loop generates the + ** appropriate WHERE clause constraint checks. tag-20220513a. + */ + goto code_outer_join_constraints +code_outer_join_constraints: + ; + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + j = libc.Int32FromInt32(0) + for { + if !(j < (*TWhereClause)(unsafe.Pointer(pWC)).FnBase) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_CODED)) != 0 { + goto _65 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady != uint64(0) { + goto _65 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + goto _65 + } + _sqlite3ExprIfFalse(tls, pParse, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, int32(SQLITE_JUMPIFNULL)) + v4 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(TERM_CODED)) + goto _65 + _65: + ; + j = j + 1 + pTerm += 56 + } +_64: + ; + return (*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady +} + +// C documentation +// +// /* +// ** Generate the end of the WHERE loop. See comments on +// ** sqlite3WhereBegin() for additional information. +// */ +func _sqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { + var addr, addrIfNull, addrSeek, bEarlyOut, i, iDb, iEnd, j, j1, k, last, m, n, n1, nRJ, op, r1, ws, x, v4 int32 + var db, p, pIdx, pIdx1, pIn, pIx, pLastOp, pLevel, pLoop, pOp, pParse, pPk, pRJ, pSrc, pTab, pTabItem, pTabList, v, v2 uintptr + var v3, v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrIfNull, addrSeek, bEarlyOut, db, i, iDb, iEnd, j, j1, k, last, m, n, n1, nRJ, op, p, pIdx, pIdx1, pIn, pIx, pLastOp, pLevel, pLoop, pOp, pParse, pPk, pRJ, pSrc, pTab, pTabItem, pTabList, r1, v, ws, x, v2, v3, v4, v5 + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pTabList = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + iEnd = _sqlite3VdbeCurrentAddr(tls, v) + nRJ = 0 + addrSeek = 0 + /* Generate loop termination code. + */ + i = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - int32(1) + for { + if !(i >= 0) { + break + } + pLevel = pWInfo + 856 + uintptr(i)*112 + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 { + /* Terminate the subroutine that forms the interior of the loop of + ** the RIGHT JOIN table */ + pRJ = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont) + /* Replace addrCont with a new label that will never be used, just so + ** the subsequent call to resolve pLevel->addrCont will have something + ** to resolve. */ + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont = _sqlite3VdbeMakeLabel(tls, pParse) + (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FendSubrtn = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn, (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FaddrSubrtn, int32(1)) + nRJ = nRJ + 1 + } + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop) != int32(OP_Noop) { + if v3 = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == int32(WHERE_DISTINCT_ORDERED) && i == libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-int32(1) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_INDEXED) != uint32(0); v3 { + v2 = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + pIdx = v2 + } + if v5 = v3 && int32(uint32(*(*uint16)(unsafe.Pointer(v2 + 100))&0x80>>7)) != 0; v5 { + v4 = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnDistinctCol) + n = v4 + } + if v5 && v4 > 0 && int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst + uintptr(n)*2))) >= int32(36) { + r1 = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + addrIfNull = 0 /* Init to avoid false-positive compiler warning */ + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + addrIfNull = _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNullRow), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, r1) + } + j = 0 + for { + if !(j < n) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, j, r1+j) + goto _6 + _6: + ; + j = j + 1 + } + **(**int32)(__ccgo_up(pParse + 60)) += n + int32(1) + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop) == int32(OP_Prev) { + v4 = int32(OP_SeekLT) + } else { + v4 = int32(OP_SeekGT) + } + op = v4 + addrSeek = _sqlite3VdbeAddOp4Int(tls, v, op, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, 0, r1, n) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), int32(1), (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + _sqlite3VdbeJumpHere(tls, v, addrIfNull) + } + } + } + if int32(*(*uint32)(unsafe.Pointer(pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + 24 + 4))&0x40000>>18) != 0 { + /* This is an EXISTS-to-JOIN optimization loop. If this loop sees a + ** successful row, it should break out of itself. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + } + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrCont) + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop) != int32(OP_Noop) { + _sqlite3VdbeAddOp3(tls, v, libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop), (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2, libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fp3)) + _sqlite3VdbeChangeP5(tls, v, uint16((*TWhereLevel)(unsafe.Pointer(pLevel)).Fp5)) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregBignull != 0 { + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_DecrJumpZero), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregBignull, (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp2-int32(1)) + } + if addrSeek != 0 { + _sqlite3VdbeJumpHere(tls, v, addrSeek) + addrSeek = 0 + } + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_ABLE) != uint32(0) && (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn > 0 { + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt) + j1 = (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn + pIn = (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FaInLoop + uintptr(j1-int32(1))*20 + for { + if !(j1 > 0) { + break + } + _sqlite3VdbeJumpHere(tls, v, (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop+int32(1)) + if libc.Int32FromUint8((*TInLoop)(unsafe.Pointer(pIn)).FeEndLoopOp) != int32(OP_Noop) { + if (*TInLoop)(unsafe.Pointer(pIn)).FnPrefix != 0 { + bEarlyOut = libc.BoolInt32((*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_VIRTUALTABLE) == uint32(0) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_EARLYOUT) != uint32(0)) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + /* For LEFT JOIN queries, cursor pIn->iCur may not have been + ** opened yet. This occurs for WHERE clauses such as + ** "a = ? AND b IN (...)", where the index is on (a, b). If + ** the RHS of the (a=?) is NULL, then the "b IN (...)" may + ** never have been coded, but the body of the loop run to + ** return the null-row. So, if the cursor is not open yet, + ** jump over the OP_Next or OP_Prev instruction about to + ** be coded. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNotOpen), (*TInLoop)(unsafe.Pointer(pIn)).FiCur, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)+bEarlyOut) + } + if bEarlyOut != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IfNoHope), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, _sqlite3VdbeCurrentAddr(tls, v)+int32(2), (*TInLoop)(unsafe.Pointer(pIn)).FiBase, (*TInLoop)(unsafe.Pointer(pIn)).FnPrefix) + /* Retarget the OP_IsNull against the left operand of IN so + ** it jumps past the OP_IfNoHope. This is because the + ** OP_IsNull also bypasses the OP_Affinity opcode that is + ** required by OP_IfNoHope. */ + _sqlite3VdbeJumpHere(tls, v, (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop+int32(1)) + } + } + _sqlite3VdbeAddOp2(tls, v, libc.Int32FromUint8((*TInLoop)(unsafe.Pointer(pIn)).FeEndLoopOp), (*TInLoop)(unsafe.Pointer(pIn)).FiCur, (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop) + } + _sqlite3VdbeJumpHere(tls, v, (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop-int32(1)) + goto _8 + _8: + ; + j1 = j1 - 1 + pIn -= 20 + } + } + _sqlite3VdbeResolveLabel(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*TWhereRightJoin)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ)).FregReturn, 0, int32(1)) + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip != 0 { + _sqlite3VdbeGoto(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip) + _sqlite3VdbeJumpHere(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip) + _sqlite3VdbeJumpHere(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip-int32(2)) + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { + ws = libc.Int32FromUint32((*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags) + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfPos), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + if ws&int32(WHERE_IDX_ONLY) == 0 { + pSrc = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40>>6) != 0 { + n1 = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FregResult + m = int32((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FnCol) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, n1, n1+m-int32(1)) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) + } + if ws&int32(WHERE_INDEXED) != 0 || ws&int32(WHERE_MULTI_OR) != 0 && *(*uintptr)(unsafe.Pointer(&(*TWhereLevel)(unsafe.Pointer(pLevel)).Fu)) != 0 { + if ws&int32(WHERE_MULTI_OR) != 0 { + pIx = *(*uintptr)(unsafe.Pointer(&(*TWhereLevel)(unsafe.Pointer(pLevel)).Fu)) + iDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIx)).FpSchema) + _sqlite3VdbeAddOp3(tls, v, int32(OP_ReopenIdx), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIx)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pIx) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + } + if libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).Fop) == int32(OP_Return) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TWhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) + } else { + _sqlite3VdbeGoto(tls, v, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) + } + _sqlite3VdbeJumpHere(tls, v, addr) + } + goto _1 + _1: + ; + i = i - 1 + } + i = 0 + pLevel = pWInfo + 856 + for { + if !(i < libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)) { + break + } + pIdx1 = uintptr(0) + pTabItem = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + pTab = (*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + /* Do RIGHT JOIN processing. Generate code that will output the + ** unmatched rows of the right operand of the RIGHT JOIN with + ** all of the columns of the left operand set to NULL. + */ + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 { + _sqlite3WhereRightJoinLoop(tls, pWInfo, i, pLevel) + goto _9 + } + /* For a co-routine, change all OP_Column references to the table of + ** the co-routine into OP_Copy of result contained in a register. + ** OP_Rowid becomes OP_Null. + */ + if int32(*(*uint32)(unsafe.Pointer(pTabItem + 24 + 4))&0x40>>6) != 0 { + _translateColumnToCopy(tls, pParse, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBody, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTabItem + 72)))).FregResult, 0) + goto _9 + } + /* If this scan uses an index, make VDBE code substitutions to read data + ** from the index instead of from the table where possible. In some cases + ** this optimization prevents the table from ever being read, which can + ** yield a significant performance boost. + ** + ** Calls to the code generator in between sqlite3WhereBegin and + ** sqlite3WhereEnd will have created code that references the table + ** directly. This loop scans all that code looking for opcodes + ** that reference the table and converts them into opcodes that + ** reference the index. + */ + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_INDEXED)|libc.Int32FromInt32(WHERE_IDX_ONLY)) != 0 { + pIdx1 = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_MULTI_OR) != 0 { + pIdx1 = *(*uintptr)(unsafe.Pointer(&(*TWhereLevel)(unsafe.Pointer(pLevel)).Fu)) + } + } + if pIdx1 != 0 && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + if libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF || !((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx1)).FpTable)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + last = iEnd + } else { + last = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiEndWhere + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx1 + 100))&0x800>>11)) != 0 { + p = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + for p != 0 { + if (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur == (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur { + (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur = -int32(1) + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur = -int32(1) + } + p = (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext + } + } + k = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBody + int32(1) + pOp = _sqlite3VdbeGetOp(tls, v, k) + pLastOp = pOp + uintptr(last-k)*24 + for { + if (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 != (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur { + /* no-op */ + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Column) || libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Offset) { + x = (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Offset) { + /* Do not need to translate the column number */ + } else { + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + x = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(x)*2))) + } else { + x = int32(_sqlite3StorageColumnToTable(tls, pTab, int16(x))) + } + } + x = _sqlite3TableColumnToIndex(tls, pIdx1, x) + if x >= 0 { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 = x + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + } else { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY)|libc.Int32FromInt32(WHERE_EXPRIDX)) != 0 { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IDX_ONLY) != 0 { + /* An error. pLoop is supposed to be a covering index loop, + ** and yet the VM code refers to a column of the table that + ** is not part of the index. */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24081, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_INTERNAL) + } else { + /* The WHERE_EXPRIDX flag is set by the planner when it is likely + ** that pLoop is a covering index loop, but it is not possible + ** to be 100% sure. In this case, any OP_Explain opcode + ** corresponding to this loop describes the index as a "COVERING + ** INDEX". But, pOp proves that pLoop is not actually a covering + ** index loop. So clear the WHERE_EXPRIDX flag and rewrite the + ** text that accompanies the OP_Explain opcode, if any. */ + **(**Tu32)(__ccgo_up(pLoop + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(WHERE_EXPRIDX)) + _sqlite3WhereAddExplainText(tls, pParse, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBody-int32(1), pTabList, pLevel, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) + } + } + } + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Rowid) { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + (*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_IdxRowid) + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_IfNullRow) { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + } + } + } + } + goto _11 + _11: + ; + pOp += 24 + v2 = pOp + if !(v2 < pLastOp) { + break + } + } + } + goto _9 + _9: + ; + i = i + 1 + pLevel += 112 + } + /* The "break" point is here, just past the end of the outer loop. + ** Set it. + */ + _sqlite3VdbeResolveLabel(tls, v, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak) + /* Final cleanup + */ + (*TParse)(unsafe.Pointer(pParse)).FnQueryLoop = int16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop) + _whereInfoFree(tls, db, pWInfo) + v2 = pParse + 35 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) - nRJ) + return +} + +/************** End of where.c ***********************************************/ +/************** Begin file window.c ******************************************/ +/* +** 2018 May 08 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* + */ +/* #include "sqliteInt.h" */ + +/* +** SELECT REWRITING +** +** Any SELECT statement that contains one or more window functions in +** either the select list or ORDER BY clause (the only two places window +** functions may be used) is transformed by function sqlite3WindowRewrite() +** in order to support window function processing. For example, with the +** schema: +** +** CREATE TABLE t1(a, b, c, d, e, f, g); +** +** the statement: +** +** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM t1 ORDER BY e; +** +** is transformed to: +** +** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM ( +** SELECT a, e, c, d, b FROM t1 ORDER BY c, d +** ) ORDER BY e; +** +** The flattening optimization is disabled when processing this transformed +** SELECT statement. This allows the implementation of the window function +** (in this case max()) to process rows sorted in order of (c, d), which +** makes things easier for obvious reasons. More generally: +** +** * FROM, WHERE, GROUP BY and HAVING clauses are all moved to +** the sub-query. +** +** * ORDER BY, LIMIT and OFFSET remain part of the parent query. +** +** * Terminals from each of the expression trees that make up the +** select-list and ORDER BY expressions in the parent query are +** selected by the sub-query. For the purposes of the transformation, +** terminals are column references and aggregate functions. +** +** If there is more than one window function in the SELECT that uses +** the same window declaration (the OVER bit), then a single scan may +** be used to process more than one window function. For example: +** +** SELECT max(b) OVER (PARTITION BY c ORDER BY d), +** min(e) OVER (PARTITION BY c ORDER BY d) +** FROM t1; +** +** is transformed in the same way as the example above. However: +** +** SELECT max(b) OVER (PARTITION BY c ORDER BY d), +** min(e) OVER (PARTITION BY a ORDER BY b) +** FROM t1; +** +** Must be transformed to: +** +** SELECT max(b) OVER (PARTITION BY c ORDER BY d) FROM ( +** SELECT e, min(e) OVER (PARTITION BY a ORDER BY b), c, d, b FROM +** SELECT a, e, c, d, b FROM t1 ORDER BY a, b +** ) ORDER BY c, d +** ) ORDER BY e; +** +** so that both min() and max() may process rows in the order defined by +** their respective window declarations. +** +** INTERFACE WITH SELECT.C +** +** When processing the rewritten SELECT statement, code in select.c calls +** sqlite3WhereBegin() to begin iterating through the results of the +** sub-query, which is always implemented as a co-routine. It then calls +** sqlite3WindowCodeStep() to process rows and finish the scan by calling +** sqlite3WhereEnd(). +** +** sqlite3WindowCodeStep() generates VM code so that, for each row returned +** by the sub-query a sub-routine (OP_Gosub) coded by select.c is invoked. +** When the sub-routine is invoked: +** +** * The results of all window-functions for the row are stored +** in the associated Window.regResult registers. +** +** * The required terminal values are stored in the current row of +** temp table Window.iEphCsr. +** +** In some cases, depending on the window frame and the specific window +** functions invoked, sqlite3WindowCodeStep() caches each entire partition +** in a temp table before returning any rows. In other cases it does not. +** This detail is encapsulated within this file, the code generated by +** select.c is the same in either case. +** +** BUILT-IN WINDOW FUNCTIONS +** +** This implementation features the following built-in window functions: +** +** row_number() +** rank() +** dense_rank() +** percent_rank() +** cume_dist() +** ntile(N) +** lead(expr [, offset [, default]]) +** lag(expr [, offset [, default]]) +** first_value(expr) +** last_value(expr) +** nth_value(expr, N) +** +** These are the same built-in window functions supported by Postgres. +** Although the behaviour of aggregate window functions (functions that +** can be used as either aggregates or window functions) allows them to +** be implemented using an API, built-in window functions are much more +** esoteric. Additionally, some window functions (e.g. nth_value()) +** may only be implemented by caching the entire partition in memory. +** As such, some built-in window functions use the same API as aggregate +** window functions and some are implemented directly using VDBE +** instructions. Additionally, for those functions that use the API, the +** window frame is sometimes modified before the SELECT statement is +** rewritten. For example, regardless of the specified window frame, the +** row_number() function always uses: +** +** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW +** +** See sqlite3WindowUpdate() for details. +** +** As well as some of the built-in window functions, aggregate window +** functions min() and max() are implemented using VDBE instructions if +** the start of the window frame is declared as anything other than +** UNBOUNDED PRECEDING. + */ + +// C documentation +// +// /* +// ** Generate the code for the loop that finds all non-matched terms +// ** for a RIGHT JOIN. +// */ +func _sqlite3WhereRightJoinLoop(tls *libc.TLS, pWInfo uintptr, iLevel int32, pLevel uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var addrCont, iCol, iCur, iIdxCur, iPk, jmp, k, nPk, r, v3 int32 + var mAll TBitmask + var pFrom, pLoop, pParse, pPk, pRJ, pRight, pSubWInfo, pSubWhere, pSubq, pTab, pTabItem, pTerm, pWC, v, v4 uintptr + var _ /* uSrc at bp+0 */ struct { + FfromSpace [0][88]Tu8 + FsSrc TSrcList + F__ccgo_pad2 [80]byte + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCont, iCol, iCur, iIdxCur, iPk, jmp, k, mAll, nPk, pFrom, pLoop, pParse, pPk, pRJ, pRight, pSubWInfo, pSubWhere, pSubq, pTab, pTabItem, pTerm, pWC, r, v, v3, v4 + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pRJ = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpRJ + pSubWhere = uintptr(0) + pWC = pWInfo + 104 + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + pTabItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + mAll = uint64(0) + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+23855, libc.VaList(bp+96, (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab)).FzName)) + k = 0 + for { + if !(k < iLevel) { + break + } + pRight = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(k)*112))).FiFrom)*80 + mAll = mAll | (*TWhereLoop)(unsafe.Pointer((*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(k)*112))).FpWLoop)).FmaskSelf + if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x40>>6) != 0 { + pSubq = *(*uintptr)(unsafe.Pointer(pRight + 72)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (*TSubquery)(unsafe.Pointer(pSubq)).FregResult, (*TSubquery)(unsafe.Pointer(pSubq)).FregResult+(*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(pSubq)).FpSelect)).FpEList)).FnExpr-int32(1)) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(k)*112))).FiTabCur) + iIdxCur = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(k)*112))).FiIdxCur + if iIdxCur != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iIdxCur) + } + goto _1 + _1: + ; + k = k + 1 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&int32(JT_LTORJ) == 0 { + mAll = mAll | (*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf + k = 0 + for { + if !(k < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(k)*56 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_SLICE)) != 0 && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != int32(WO_ROWVAL) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & ^mAll != 0 { + goto _2 + } + if (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + goto _2 + } + pSubWhere = _sqlite3ExprAnd(tls, pParse, pSubWhere, _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, 0)) + goto _2 + _2: + ; + k = k + 1 + } + } + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur != 0 { + /* pSubWhere may contain expressions that read from an index on the + ** table on the RHS of the right join. All such expressions first test + ** if the index is pointing at a NULL row, and if so, read from the + ** table cursor instead. So ensure that the index cursor really is + ** pointing at a NULL row here, so that no values are read from it during + ** the scan of the RHS of the RIGHT join below. */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + } + pFrom = bp + (*TSrcList)(unsafe.Pointer(pFrom)).FnSrc = int32(1) + (*TSrcList)(unsafe.Pointer(pFrom)).FnAlloc = uint32(1) + libc.Xmemcpy(tls, pFrom+8, pTabItem, uint64(80)) + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).Ffg.Fjointype = uint8(0) + (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn + 1 + pSubWInfo = _sqlite3WhereBegin(tls, pParse, pFrom, pSubWhere, uintptr(0), uintptr(0), uintptr(0), uint16(WHERE_RIGHT_JOIN), 0) + if pSubWInfo != 0 { + iCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v3 = *(*int32)(unsafe.Pointer(v4)) + r = v3 + addrCont = _sqlite3WhereContinueLabel(tls, pSubWInfo) + pTab = (*TSrcItem)(unsafe.Pointer(pTabItem)).FpSTab + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, -int32(1), r) + nPk = int32(1) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + **(**int32)(__ccgo_up(pParse + 60)) += nPk - int32(1) + iPk = 0 + for { + if !(iPk < nPk) { + break + } + iCol = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(iPk)*2))) + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, iCol, r+iPk) + goto _5 + _5: + ; + iPk = iPk + 1 + } + } + jmp = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Filter), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom, 0, r, nPk) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, addrCont, r, nPk) + _sqlite3VdbeJumpHere(tls, v, jmp) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn, (*TWhereRightJoin)(unsafe.Pointer(pRJ)).FaddrSubrtn) + _sqlite3WhereEnd(tls, pSubWInfo) + } + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSubWhere) + _sqlite3VdbeExplainPop(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn - 1 +} + +// C documentation +// +// /* +// ** For table-valued-functions, transform the function arguments into +// ** new WHERE clause terms. +// ** +// ** Each function argument translates into an equality constraint against +// ** a HIDDEN column in the table. +// */ +func _sqlite3WhereTabFuncArgs(tls *libc.TLS, pParse uintptr, pItem uintptr, pWC uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var j, k, v2 int32 + var joinType Tu32 + var pArgs, pColRef, pRhs, pTab, pTerm uintptr + _, _, _, _, _, _, _, _, _ = j, joinType, k, pArgs, pColRef, pRhs, pTab, pTerm, v2 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x8>>3) == 0 { + return + } + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + pArgs = *(*uintptr)(unsafe.Pointer(pItem + 48)) + if pArgs == uintptr(0) { + return + } + v2 = libc.Int32FromInt32(0) + k = v2 + j = v2 + for { + if !(j < (*TExprList)(unsafe.Pointer(pArgs)).FnExpr) { + break + } + for k < int32((*TTable)(unsafe.Pointer(pTab)).FnCol) && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(k)*16))).FcolFlags)&int32(COLFLAG_HIDDEN) == 0 { + k = k + 1 + } + if k >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+23883, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName, j)) + return + } + pColRef = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_COLUMN), uintptr(0), 0) + if pColRef == uintptr(0) { + return + } + (*TExpr)(unsafe.Pointer(pColRef)).FiTable = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + v2 = k + k = k + 1 + (*TExpr)(unsafe.Pointer(pColRef)).FiColumn = int16(v2) + *(*uintptr)(unsafe.Pointer(pColRef + 64)) = pTab + **(**TBitmask)(__ccgo_up(pItem + 40)) |= _sqlite3ExprColUsed(tls, pColRef) + pRhs = _sqlite3PExpr(tls, pParse, int32(TK_UPLUS), _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*(*TExprList_item)(unsafe.Pointer(pArgs + 8 + uintptr(j)*32))).FpExpr, 0), uintptr(0)) + pTerm = _sqlite3PExpr(tls, pParse, int32(TK_EQ), pColRef, pRhs) + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + /* testtag-20230227a */ + /* testtag-20230227b */ + joinType = uint32(EP_OuterON) + } else { + /* testtag-20230227c */ + joinType = uint32(EP_InnerON) + } + _sqlite3SetJoinExpr(tls, pTerm, (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor, joinType) + _whereClauseInsert(tls, pWC, pTerm, uint16(TERM_DYNAMIC)) + goto _1 + _1: + ; + j = j + 1 + } +} + +/************** End of whereexpr.c *******************************************/ +/************** Begin file where.c *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This module contains C code that generates VDBE code used to process +** the WHERE clause of SQL statements. This module is responsible for +** generating the code that loops through a table looking for applicable +** rows. Indices are selected and used to speed the search when doing +** so is applicable. Because this module is responsible for selecting +** indices, you might also think of this module as the "query optimizer". + */ +/* #include "sqliteInt.h" */ +/* #include "whereInt.h" */ + +// C documentation +// +// /* +// ** Allocate and return a new Window object describing a Window Definition. +// */ +func _sqlite3WindowAlloc(tls *libc.TLS, pParse uintptr, eType int32, eStart int32, pStart uintptr, eEnd int32, pEnd uintptr, eExclude Tu8) (r uintptr) { + var bImplicitFrame int32 + var pWin uintptr + _, _ = bImplicitFrame, pWin + pWin = uintptr(0) + bImplicitFrame = 0 + /* Parser assures the following: */ + if eType == 0 { + bImplicitFrame = int32(1) + eType = int32(TK_RANGE) + } + /* Additionally, the + ** starting boundary type may not occur earlier in the following list than + ** the ending boundary type: + ** + ** UNBOUNDED PRECEDING + ** PRECEDING + ** CURRENT ROW + ** FOLLOWING + ** UNBOUNDED FOLLOWING + ** + ** The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending + ** boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting + ** frame boundary. + */ + if eStart == int32(TK_CURRENT) && eEnd == int32(TK_PRECEDING) || eStart == int32(TK_FOLLOWING) && (eEnd == int32(TK_PRECEDING) || eEnd == int32(TK_CURRENT)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24390, 0) + goto windowAllocErr + } + pWin = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) + if pWin == uintptr(0) { + goto windowAllocErr + } + (*TWindow)(unsafe.Pointer(pWin)).FeFrmType = libc.Uint8FromInt32(eType) + (*TWindow)(unsafe.Pointer(pWin)).FeStart = libc.Uint8FromInt32(eStart) + (*TWindow)(unsafe.Pointer(pWin)).FeEnd = libc.Uint8FromInt32(eEnd) + if libc.Int32FromUint8(eExclude) == 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_WindowFunc)) != uint32(0) { + eExclude = uint8(TK_NO) + } + (*TWindow)(unsafe.Pointer(pWin)).FeExclude = eExclude + (*TWindow)(unsafe.Pointer(pWin)).FbImplicitFrame = libc.Uint8FromInt32(bImplicitFrame) + (*TWindow)(unsafe.Pointer(pWin)).FpEnd = _sqlite3WindowOffsetExpr(tls, pParse, pEnd) + (*TWindow)(unsafe.Pointer(pWin)).FpStart = _sqlite3WindowOffsetExpr(tls, pParse, pStart) + return pWin + goto windowAllocErr +windowAllocErr: + ; + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pEnd) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pStart) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Attach window object pWin to expression p. +// */ +func _sqlite3WindowAttach(tls *libc.TLS, pParse uintptr, p uintptr, pWin uintptr) { + if p != 0 { + *(*uintptr)(unsafe.Pointer(p + 64)) = pWin + **(**Tu32)(__ccgo_up(p + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc) | libc.Int32FromInt32(EP_FullSize)) + (*TWindow)(unsafe.Pointer(pWin)).FpOwner = p + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_Distinct) != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeFrmType) != int32(TK_FILTER) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24508, 0) + } + } else { + _sqlite3WindowDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pWin) + } +} + +// C documentation +// +// /* +// ** This function is called immediately after resolving the function name +// ** for a window function within a SELECT statement. Argument pList is a +// ** linked list of WINDOW definitions for the current SELECT statement. +// ** Argument pFunc is the function definition just resolved and pWin +// ** is the Window object representing the associated OVER clause. This +// ** function updates the contents of pWin as follows: +// ** +// ** * If the OVER clause referred to a named window (as in "max(x) OVER win"), +// ** search list pList for a matching WINDOW definition, and update pWin +// ** accordingly. If no such WINDOW clause can be found, leave an error +// ** in pParse. +// ** +// ** * If the function is a built-in window function that requires the +// ** window to be coerced (see "BUILT-IN WINDOW FUNCTIONS" at the top +// ** of this file), pWin is updated here. +// */ +func _sqlite3WindowUpdate(tls *libc.TLS, pParse uintptr, pList uintptr, pWin uintptr, pFunc uintptr) { + var aUp [8]struct { + FzFunc uintptr + FeFrmType int32 + FeStart int32 + FeEnd int32 + } + var db, p, v2 uintptr + var i int32 + _, _, _, _, _ = aUp, db, i, p, v2 + if (*TWindow)(unsafe.Pointer(pWin)).FzName != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeFrmType) == 0 { + p = _windowFind(tls, pParse, pList, (*TWindow)(unsafe.Pointer(pWin)).FzName) + if p == uintptr(0) { + return + } + (*TWindow)(unsafe.Pointer(pWin)).FpPartition = _sqlite3ExprListDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWindow)(unsafe.Pointer(p)).FpPartition, 0) + (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy = _sqlite3ExprListDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWindow)(unsafe.Pointer(p)).FpOrderBy, 0) + (*TWindow)(unsafe.Pointer(pWin)).FpStart = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWindow)(unsafe.Pointer(p)).FpStart, 0) + (*TWindow)(unsafe.Pointer(pWin)).FpEnd = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TWindow)(unsafe.Pointer(p)).FpEnd, 0) + (*TWindow)(unsafe.Pointer(pWin)).FeStart = (*TWindow)(unsafe.Pointer(p)).FeStart + (*TWindow)(unsafe.Pointer(pWin)).FeEnd = (*TWindow)(unsafe.Pointer(p)).FeEnd + (*TWindow)(unsafe.Pointer(pWin)).FeFrmType = (*TWindow)(unsafe.Pointer(p)).FeFrmType + (*TWindow)(unsafe.Pointer(pWin)).FeExclude = (*TWindow)(unsafe.Pointer(p)).FeExclude + } else { + _sqlite3WindowChain(tls, pParse, pWin, pList) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeFrmType) == int32(TK_RANGE) && ((*TWindow)(unsafe.Pointer(pWin)).FpStart != 0 || (*TWindow)(unsafe.Pointer(pWin)).FpEnd != 0) && ((*TWindow)(unsafe.Pointer(pWin)).FpOrderBy == uintptr(0) || (*TExprList)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOrderBy)).FnExpr != int32(1)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24230, 0) + } else { + if (*TFuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TWindow)(unsafe.Pointer(pWin)).FpFilter != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24301, 0) + } else { + aUp = [8]struct { + FzFunc uintptr + FeFrmType int32 + FeStart int32 + FeEnd int32 + }{ + 0: { + FzFunc: uintptr(unsafe.Pointer(&_row_numberName)), + FeFrmType: int32(TK_ROWS), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_CURRENT), + }, + 1: { + FzFunc: uintptr(unsafe.Pointer(&_dense_rankName)), + FeFrmType: int32(TK_RANGE), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_CURRENT), + }, + 2: { + FzFunc: uintptr(unsafe.Pointer(&_rankName)), + FeFrmType: int32(TK_RANGE), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_CURRENT), + }, + 3: { + FzFunc: uintptr(unsafe.Pointer(&_percent_rankName)), + FeFrmType: int32(TK_GROUPS), + FeStart: int32(TK_CURRENT), + FeEnd: int32(TK_UNBOUNDED), + }, + 4: { + FzFunc: uintptr(unsafe.Pointer(&_cume_distName)), + FeFrmType: int32(TK_GROUPS), + FeStart: int32(TK_FOLLOWING), + FeEnd: int32(TK_UNBOUNDED), + }, + 5: { + FzFunc: uintptr(unsafe.Pointer(&_ntileName)), + FeFrmType: int32(TK_ROWS), + FeStart: int32(TK_CURRENT), + FeEnd: int32(TK_UNBOUNDED), + }, + 6: { + FzFunc: uintptr(unsafe.Pointer(&_leadName)), + FeFrmType: int32(TK_ROWS), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_UNBOUNDED), + }, + 7: { + FzFunc: uintptr(unsafe.Pointer(&_lagName)), + FeFrmType: int32(TK_ROWS), + FeStart: int32(TK_UNBOUNDED), + FeEnd: int32(TK_CURRENT), + }, + } + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(192)/libc.Uint64FromInt64(24))) { + break + } + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == aUp[i].FzFunc { + _sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FpStart) + _sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FpEnd) + v2 = libc.UintptrFromInt32(0) + (*TWindow)(unsafe.Pointer(pWin)).FpStart = v2 + (*TWindow)(unsafe.Pointer(pWin)).FpEnd = v2 + (*TWindow)(unsafe.Pointer(pWin)).FeFrmType = libc.Uint8FromInt32(aUp[i].FeFrmType) + (*TWindow)(unsafe.Pointer(pWin)).FeStart = libc.Uint8FromInt32(aUp[i].FeStart) + (*TWindow)(unsafe.Pointer(pWin)).FeEnd = libc.Uint8FromInt32(aUp[i].FeEnd) + (*TWindow)(unsafe.Pointer(pWin)).FeExclude = uint8(0) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeStart) == int32(TK_FOLLOWING) { + (*TWindow)(unsafe.Pointer(pWin)).FpStart = _sqlite3ExprInt32(tls, db, int32(1)) + } + break + } + goto _1 + _1: + ; + i = i + 1 + } + } + } + } + (*TWindow)(unsafe.Pointer(pWin)).FpWFunc = pFunc +} + +// C documentation +// +// /* +// ** This routine is invoked once per CTE by the parser while parsing a +// ** WITH clause. The CTE described by the third argument is added to +// ** the WITH clause of the second argument. If the second argument is +// ** NULL, then a new WITH argument is created. +// */ +func _sqlite3WithAdd(tls *libc.TLS, pParse uintptr, pWith uintptr, pCte uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pNew, zName, v3 uintptr + var i, v2 int32 + _, _, _, _, _, _ = db, i, pNew, zName, v2, v3 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pCte == uintptr(0) { + return pWith + } + /* Check that the CTE name is unique within this WITH clause. If + ** not, store an error in the Parse structure. */ + zName = (*TCte)(unsafe.Pointer(pCte)).FzName + if zName != 0 && pWith != 0 { + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer(pWith)).FnCte) { + break + } + if _sqlite3StrICmp(tls, zName, (*(*TCte)(unsafe.Pointer(pWith + 16 + uintptr(i)*48))).FzName) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16284, libc.VaList(bp+8, zName)) + } + goto _1 + _1: + ; + i = i + 1 + } + } + if pWith != 0 { + pNew = _sqlite3DbRealloc(tls, db, pWith, uint64(uint64(libc.UintptrFromInt32(0)+16)+libc.Uint64FromInt32((*TWith)(unsafe.Pointer(pWith)).FnCte+libc.Int32FromInt32(1))*libc.Uint64FromInt64(48))) + } else { + pNew = _sqlite3DbMallocZero(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+16)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(48))) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3CteDelete(tls, db, pCte) + pNew = pWith + } else { + v3 = pNew + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + *(*TCte)(unsafe.Pointer(pNew + 16 + uintptr(v2)*48)) = **(**TCte)(__ccgo_up(pCte)) + _sqlite3DbFree(tls, db, pCte) + } + return pNew +} + +func _sqlite3_geopoly_init(tls *libc.TLS, db uintptr) (r int32) { + var enc, rc int32 + var i uint32 + _, _, _ = enc, i, rc + rc = SQLITE_OK + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(288)/libc.Uint64FromInt64(24) && rc == SQLITE_OK) { + break + } + if _aFunc[i].FbPure != 0 { + enc = libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_INNOCUOUS) + } else { + enc = libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_DIRECTONLY) + } + rc = Xsqlite3_create_function(tls, db, _aFunc[i].FzName, int32(_aFunc[i].FnArg), enc, uintptr(0), _aFunc[i].FxFunc, uintptr(0), uintptr(0)) + goto _1 + _1: + ; + i = i + 1 + } + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(24)/libc.Uint64FromInt64(24) && rc == SQLITE_OK) { + break + } + rc = Xsqlite3_create_function(tls, db, _aAgg[i].FzName, int32(1), libc.Int32FromInt32(SQLITE_UTF8)|libc.Int32FromInt32(SQLITE_DETERMINISTIC)|libc.Int32FromInt32(SQLITE_INNOCUOUS), uintptr(0), uintptr(0), _aAgg[i].FxStep, _aAgg[i].FxFinal) + goto _2 + _2: + ; + i = i + 1 + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_module_v2(tls, db, __ccgo_ts+30152, uintptr(unsafe.Pointer(&_geopolyModule)), uintptr(0), uintptr(0)) + } + return rc +} + +// C documentation +// +// /* +// ** This routine is called once for each row in the result table. Its job +// ** is to fill in the TabResult structure appropriately, allocating new +// ** memory as necessary. +// */ +func _sqlite3_get_table_cb(tls *libc.TLS, pArg uintptr, nCol int32, argv uintptr, colv uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azNew, p, z, v3 uintptr + var i, n, need int32 + var v2 Tu32 + _, _, _, _, _, _, _, _ = azNew, i, n, need, p, z, v2, v3 + p = pArg /* A single column of result */ + /* Make sure there is enough space in p->azResult to hold everything + ** we need to remember from this invocation of the callback. + */ + if (*TTabResult)(unsafe.Pointer(p)).FnRow == uint32(0) && argv != uintptr(0) { + need = nCol * int32(2) + } else { + need = nCol + } + if (*TTabResult)(unsafe.Pointer(p)).FnData+libc.Uint32FromInt32(need) > (*TTabResult)(unsafe.Pointer(p)).FnAlloc { + (*TTabResult)(unsafe.Pointer(p)).FnAlloc = (*TTabResult)(unsafe.Pointer(p)).FnAlloc*uint32(2) + libc.Uint32FromInt32(need) + azNew = _sqlite3Realloc(tls, (*TTabResult)(unsafe.Pointer(p)).FazResult, uint64(8)*uint64((*TTabResult)(unsafe.Pointer(p)).FnAlloc)) + if azNew == uintptr(0) { + goto malloc_failed + } + (*TTabResult)(unsafe.Pointer(p)).FazResult = azNew + } + /* If this is the first row, then generate an extra row containing + ** the names of all columns. + */ + if (*TTabResult)(unsafe.Pointer(p)).FnRow == uint32(0) { + (*TTabResult)(unsafe.Pointer(p)).FnColumn = libc.Uint32FromInt32(nCol) + i = 0 + for { + if !(i < nCol) { + break + } + z = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, **(**uintptr)(__ccgo_up(colv + uintptr(i)*8)))) + if z == uintptr(0) { + goto malloc_failed + } + v3 = p + 28 + v2 = *(*Tu32)(unsafe.Pointer(v3)) + *(*Tu32)(unsafe.Pointer(v3)) = *(*Tu32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up((*TTabResult)(unsafe.Pointer(p)).FazResult + uintptr(v2)*8)) = z + goto _1 + _1: + ; + i = i + 1 + } + } else { + if libc.Int32FromUint32((*TTabResult)(unsafe.Pointer(p)).FnColumn) != nCol { + Xsqlite3_free(tls, (*TTabResult)(unsafe.Pointer(p)).FzErrMsg) + (*TTabResult)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+21731, 0) + (*TTabResult)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + return int32(1) + } + } + /* Copy over the row data + */ + if argv != uintptr(0) { + i = 0 + for { + if !(i < nCol) { + break + } + if **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)) == uintptr(0) { + z = uintptr(0) + } else { + n = _sqlite3Strlen30(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + int32(1) + z = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(n)) + if z == uintptr(0) { + goto malloc_failed + } + libc.Xmemcpy(tls, z, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)), libc.Uint64FromInt32(n)) + } + v3 = p + 28 + v2 = *(*Tu32)(unsafe.Pointer(v3)) + *(*Tu32)(unsafe.Pointer(v3)) = *(*Tu32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up((*TTabResult)(unsafe.Pointer(p)).FazResult + uintptr(v2)*8)) = z + goto _4 + _4: + ; + i = i + 1 + } + (*TTabResult)(unsafe.Pointer(p)).FnRow = (*TTabResult)(unsafe.Pointer(p)).FnRow + 1 + } + return 0 + goto malloc_failed +malloc_failed: + ; + (*TTabResult)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + return int32(1) +} + +// C documentation +// +// /* +// ** Connect to or create a new DBSTAT virtual table. +// */ +func _statConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iDb, rc int32 + var pTab uintptr + var _ /* nm at bp+0 */ TToken + _, _, _ = iDb, pTab, rc + pTab = uintptr(0) + rc = SQLITE_OK + _ = pAux + if argc >= int32(4) { + _sqlite3TokenInit(tls, bp, **(**uintptr)(__ccgo_up(argv + 3*8))) + iDb = _sqlite3FindDb(tls, db, bp) + if iDb < 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+13442, libc.VaList(bp+24, **(**uintptr)(__ccgo_up(argv + 3*8)))) + return int32(SQLITE_ERROR) + } + } else { + iDb = 0 + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_DIRECTONLY), 0) + rc = Xsqlite3_declare_vtab(tls, db, uintptr(unsafe.Pointer(&_zDbstatSchema))) + if rc == SQLITE_OK { + pTab = Xsqlite3_malloc64(tls, uint64(40)) + if pTab == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc == SQLITE_OK { + libc.Xmemset(tls, pTab, 0, uint64(40)) + (*TStatTable)(unsafe.Pointer(pTab)).Fdb = db + (*TStatTable)(unsafe.Pointer(pTab)).FiDb = iDb + } + **(**uintptr)(__ccgo_up(ppVtab)) = pTab + return rc +} + +// C documentation +// +// /* Initialize a cursor according to the query plan idxNum using the +// ** arguments in argv[0]. See statBestIndex() for a description of the +// ** meaning of the bits in idxNum. +// */ +func _statFilter(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iArg, rc, v1 int32 + var pCsr, pSql, pTab, zDbase, zName, zSql uintptr + _, _, _, _, _, _, _, _, _ = iArg, pCsr, pSql, pTab, rc, zDbase, zName, zSql, v1 + pCsr = pCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab /* String value of pSql */ + iArg = 0 /* Count of argv[] parameters used so far */ + rc = SQLITE_OK /* Result of this operation */ + zName = uintptr(0) /* Only provide analysis of this table */ + _ = argc + _ = idxStr + _statResetCsr(tls, pCsr) + Xsqlite3_finalize(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) + if idxNum&int32(0x01) != 0 { + v1 = iArg + iArg = iArg + 1 + /* schema=? constraint is present. Get its value */ + zDbase = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8))) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb = _sqlite3FindDbName(tls, (*TStatTable)(unsafe.Pointer(pTab)).Fdb, zDbase) + if (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb < 0 { + (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FisEof = uint8(1) + return SQLITE_OK + } + } else { + (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb = (*TStatTable)(unsafe.Pointer(pTab)).FiDb + } + if idxNum&int32(0x02) != 0 { + /* name=? constraint is present */ + v1 = iArg + iArg = iArg + 1 + zName = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8))) + } + if idxNum&int32(0x04) != 0 { + /* aggregate=? constraint is present */ + v1 = iArg + iArg = iArg + 1 + (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg = libc.BoolUint8(Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8))) != float64(0)) + } else { + (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg = uint8(0) + } + pSql = Xsqlite3_str_new(tls, (*TStatTable)(unsafe.Pointer(pTab)).Fdb) + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+34742, libc.VaList(bp+8, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TStatTable)(unsafe.Pointer(pTab)).Fdb)).FaDb + uintptr((*TStatCursor)(unsafe.Pointer(pCsr)).FiDb)*32))).FzDbSName)) + if zName != 0 { + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+34897, libc.VaList(bp+8, zName)) + } + if idxNum&int32(0x08) != 0 { + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+34911, 0) + } + zSql = Xsqlite3_str_finish(tls, pSql) + if zSql == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, (*TStatTable)(unsafe.Pointer(pTab)).Fdb, zSql, -int32(1), pCsr+8, uintptr(0)) + Xsqlite3_free(tls, zSql) + } + if rc == SQLITE_OK { + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = -int32(1) + rc = _statNext(tls, pCursor) + } + return rc +} + +// C documentation +// +// /* +// ** Implementation of the stat_get(P,J) SQL function. This routine is +// ** used to query statistical information that has been gathered into +// ** the StatAccum object by prior calls to stat_push(). The P parameter +// ** has type BLOB but it is really just a pointer to the StatAccum object. +// ** The content to returned is determined by the parameter J +// ** which is one of the STAT_GET_xxxx values defined above. +// ** +// ** The stat_get(P,J) function is not available to generic SQL. It is +// ** inserted as part of a manually constructed bytecode program. (See +// ** the callStatGet() routine below.) It is guaranteed that the P +// ** parameter will always be a pointer to a StatAccum object, never a +// ** NULL. +// ** +// ** If STAT4 is not enabled, then J is always +// ** STAT_GET_STAT1 and is hence omitted and this routine becomes +// ** a one-parameter function, stat_get(P), that always returns the +// ** stat1 table entry information. +// */ +func _statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var aCnt, p, pS uintptr + var eCall, i, i1 int32 + var iVal, nDistinct Tu64 + var v1 uint64 + var _ /* sStat at bp+0 */ Tsqlite3_str + var _ /* sStat at bp+32 */ Tsqlite3_str + _, _, _, _, _, _, _, _, _ = aCnt, eCall, i, i1, iVal, nDistinct, p, pS, v1 + p = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + /* STAT4 has a parameter on this routine. */ + eCall = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if eCall == STAT_GET_STAT1 { + /* Loop counter */ + _sqlite3StrAccumInit(tls, bp, uintptr(0), uintptr(0), 0, ((*TStatAccum)(unsafe.Pointer(p)).FnKeyCol+int32(1))*int32(100)) + if (*TStatAccum)(unsafe.Pointer(p)).FnSkipAhead != 0 { + v1 = (*TStatAccum)(unsafe.Pointer(p)).FnEst + } else { + v1 = (*TStatAccum)(unsafe.Pointer(p)).FnRow + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+13004, libc.VaList(bp+72, v1)) + i = 0 + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FnKeyCol) { + break + } + nDistinct = **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(i)*8)) + uint64(1) + iVal = ((*TStatAccum)(unsafe.Pointer(p)).FnRow + nDistinct - uint64(1)) / nDistinct + if iVal == uint64(2) && (*TStatAccum)(unsafe.Pointer(p)).FnRow*uint64(10) <= nDistinct*uint64(11) { + iVal = uint64(1) + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+13009, libc.VaList(bp+72, iVal)) + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3ResultStrAccum(tls, context, bp) + } else { + if eCall == int32(STAT_GET_ROWID) { + if (*TStatAccum)(unsafe.Pointer(p)).FiGet < 0 { + _samplePushPrevious(tls, p, 0) + (*TStatAccum)(unsafe.Pointer(p)).FiGet = 0 + } + if (*TStatAccum)(unsafe.Pointer(p)).FiGet < (*TStatAccum)(unsafe.Pointer(p)).FnSample { + pS = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiGet)*48 + if (*TStatSample)(unsafe.Pointer(pS)).FnRowid == uint32(0) { + Xsqlite3_result_int64(tls, context, *(*Ti64)(unsafe.Pointer(pS + 24))) + } else { + Xsqlite3_result_blob(tls, context, *(*uintptr)(unsafe.Pointer(pS + 24)), libc.Int32FromUint32((*TStatSample)(unsafe.Pointer(pS)).FnRowid), uintptr(-libc.Int32FromInt32(1))) + } + } + } else { + aCnt = uintptr(0) + switch eCall { + case int32(STAT_GET_NEQ): + aCnt = (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiGet)*48))).FanEq + case int32(STAT_GET_NLT): + aCnt = (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiGet)*48))).FanLt + default: + aCnt = (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiGet)*48))).FanDLt + (*TStatAccum)(unsafe.Pointer(p)).FiGet = (*TStatAccum)(unsafe.Pointer(p)).FiGet + 1 + break + } + _sqlite3StrAccumInit(tls, bp+32, uintptr(0), uintptr(0), 0, (*TStatAccum)(unsafe.Pointer(p)).FnCol*int32(100)) + i1 = 0 + for { + if !(i1 < (*TStatAccum)(unsafe.Pointer(p)).FnCol) { + break + } + Xsqlite3_str_appendf(tls, bp+32, __ccgo_ts+13015, libc.VaList(bp+72, **(**TtRowcnt)(__ccgo_up(aCnt + uintptr(i1)*8)))) + goto _3 + _3: + ; + i1 = i1 + 1 + } + if (**(**Tsqlite3_str)(__ccgo_up(bp + 32))).FnChar != 0 { + (**(**Tsqlite3_str)(__ccgo_up(bp + 32))).FnChar = (**(**Tsqlite3_str)(__ccgo_up(bp + 32))).FnChar - 1 + } + _sqlite3ResultStrAccum(tls, context, bp+32) + } + } + _ = argc +} + +// C documentation +// +// /* +// ** Move a DBSTAT cursor to the next entry. Normally, the next +// ** entry will be the next page, but in aggregated mode (pCsr->isAgg!=0), +// ** the next entry is the next btree. +// */ +func _statNext(tls *libc.TLS, pCursor uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, iOvfl, nPayload, nUsable, rc, v3 int32 + var iRoot Tu32 + var p, p1, pBt, pCell, pCsr, pPager, pTab, z, v1 uintptr + var _ /* nPage at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iOvfl, iRoot, nPayload, nUsable, p, p1, pBt, pCell, pCsr, pPager, pTab, rc, z, v1, v3 + pCsr = pCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TStatTable)(unsafe.Pointer(pTab)).Fdb)).FaDb + uintptr((*TStatCursor)(unsafe.Pointer(pCsr)).FiDb)*32))).FpBt + pPager = _sqlite3BtreePager(tls, pBt) + Xsqlite3_free(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath) + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath = uintptr(0) + goto statNextRestart +statNextRestart: + ; + if (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage < 0 { + /* Start measuring space on the next btree */ + _statResetCounts(tls, pCsr) + rc = Xsqlite3_step(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + if rc == int32(SQLITE_ROW) { + iRoot = libc.Uint32FromInt64(Xsqlite3_column_int64(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1))) + _sqlite3PagerPagecount(tls, pPager, bp) + if **(**int32)(__ccgo_up(bp)) == 0 { + (*TStatCursor)(unsafe.Pointer(pCsr)).FisEof = uint8(1) + return Xsqlite3_reset(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + } + rc = _statGetPage(tls, pBt, iRoot, pCsr+24) + (**(**TStatPage)(__ccgo_up(pCsr + 24))).FiPgno = iRoot + (**(**TStatPage)(__ccgo_up(pCsr + 24))).FiCell = 0 + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + v1 = Xsqlite3_mprintf(tls, __ccgo_ts+34687, 0) + z = v1 + (**(**TStatPage)(__ccgo_up(pCsr + 24))).FzPath = v1 + if z == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = 0 + (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage = int32(1) + } else { + (*TStatCursor)(unsafe.Pointer(pCsr)).FisEof = uint8(1) + return Xsqlite3_reset(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + } + } else { + /* Continue analyzing the btree previously started */ + p = pCsr + 24 + uintptr((*TStatCursor)(unsafe.Pointer(pCsr)).FiPage)*64 + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + _statResetCounts(tls, pCsr) + } + for (*TStatPage)(unsafe.Pointer(p)).FiCell < (*TStatPage)(unsafe.Pointer(p)).FnCell { + pCell = (*TStatPage)(unsafe.Pointer(p)).FaCell + uintptr((*TStatPage)(unsafe.Pointer(p)).FiCell)*32 + for (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl < (*TStatCell)(unsafe.Pointer(pCell)).FnOvfl { + _sqlite3BtreeEnter(tls, pBt) + nUsable = _sqlite3BtreeGetPageSize(tls, pBt) - _sqlite3BtreeGetReserveNoMutex(tls, pBt) + _sqlite3BtreeLeave(tls, pBt) + (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage = (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage + 1 + _statSizeAndOffset(tls, pCsr) + if (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl < (*TStatCell)(unsafe.Pointer(pCell)).FnOvfl-int32(1) { + **(**Ti64)(__ccgo_up(pCsr + 2128)) += int64(nUsable - int32(4)) + } else { + **(**Ti64)(__ccgo_up(pCsr + 2128)) += int64((*TStatCell)(unsafe.Pointer(pCell)).FnLastOvfl) + **(**Ti64)(__ccgo_up(pCsr + 2120)) += int64(nUsable - int32(4) - (*TStatCell)(unsafe.Pointer(pCell)).FnLastOvfl) + } + iOvfl = (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl + (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl = (*TStatCell)(unsafe.Pointer(pCell)).FiOvfl + 1 + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + (*TStatCursor)(unsafe.Pointer(pCsr)).FzName = Xsqlite3_column_text(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt, 0) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPageno = **(**Tu32)(__ccgo_up((*TStatCell)(unsafe.Pointer(pCell)).FaOvfl + uintptr(iOvfl)*4)) + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype = __ccgo_ts + 34689 + v1 = Xsqlite3_mprintf(tls, __ccgo_ts+34698, libc.VaList(bp+16, (*TStatPage)(unsafe.Pointer(p)).FzPath, (*TStatPage)(unsafe.Pointer(p)).FiCell, iOvfl)) + z = v1 + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath = v1 + if z == uintptr(0) { + v3 = int32(SQLITE_NOMEM) + } else { + v3 = SQLITE_OK + } + return v3 + } + } + if (*TStatPage)(unsafe.Pointer(p)).FiRightChildPg != 0 { + break + } + (*TStatPage)(unsafe.Pointer(p)).FiCell = (*TStatPage)(unsafe.Pointer(p)).FiCell + 1 + } + if !((*TStatPage)(unsafe.Pointer(p)).FiRightChildPg != 0) || (*TStatPage)(unsafe.Pointer(p)).FiCell > (*TStatPage)(unsafe.Pointer(p)).FnCell { + _statClearPage(tls, p) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage - 1 + if (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0 && (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage < 0 { + /* label-statNext-done: When computing aggregate space usage over + ** an entire btree, this is the exit point from this function */ + return SQLITE_OK + } + goto statNextRestart /* Tail recursion */ + } + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage + 1 + if (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage >= libc.Int32FromUint64(libc.Uint64FromInt64(2048)/libc.Uint64FromInt64(64)) { + _statResetCsr(tls, pCsr) + return _sqlite3CorruptError(tls, int32(232191)) + } + if (*TStatPage)(unsafe.Pointer(p)).FiCell == (*TStatPage)(unsafe.Pointer(p)).FnCell { + (**(**TStatPage)(__ccgo_up(p + 1*64))).FiPgno = (*TStatPage)(unsafe.Pointer(p)).FiRightChildPg + } else { + (**(**TStatPage)(__ccgo_up(p + 1*64))).FiPgno = (**(**TStatCell)(__ccgo_up((*TStatPage)(unsafe.Pointer(p)).FaCell + uintptr((*TStatPage)(unsafe.Pointer(p)).FiCell)*32))).FiChildPg + } + rc = _statGetPage(tls, pBt, (**(**TStatPage)(__ccgo_up(p + 1*64))).FiPgno, p+1*64) + (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage = (*TStatCursor)(unsafe.Pointer(pCsr)).FnPage + 1 + (**(**TStatPage)(__ccgo_up(p + 1*64))).FiCell = 0 + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + v1 = Xsqlite3_mprintf(tls, __ccgo_ts+34710, libc.VaList(bp+16, (*TStatPage)(unsafe.Pointer(p)).FzPath, (*TStatPage)(unsafe.Pointer(p)).FiCell)) + z = v1 + (**(**TStatPage)(__ccgo_up(p + 1*64))).FzPath = v1 + if z == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + (*TStatPage)(unsafe.Pointer(p)).FiCell = (*TStatPage)(unsafe.Pointer(p)).FiCell + 1 + } + /* Populate the StatCursor fields with the values to be returned + ** by the xColumn() and xRowid() methods. + */ + if rc == SQLITE_OK { + p1 = pCsr + 24 + uintptr((*TStatCursor)(unsafe.Pointer(pCsr)).FiPage)*64 + (*TStatCursor)(unsafe.Pointer(pCsr)).FzName = Xsqlite3_column_text(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt, 0) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPageno = (*TStatPage)(unsafe.Pointer(p1)).FiPgno + rc = _statDecodePage(tls, pBt, p1) + if rc == SQLITE_OK { + _statSizeAndOffset(tls, pCsr) + switch libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p1)).Fflags) { + case int32(0x05): /* table internal */ + fallthrough + case int32(0x02): /* index internal */ + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype = __ccgo_ts + 34718 + case int32(0x0D): /* table leaf */ + fallthrough + case int32(0x0A): /* index leaf */ + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype = __ccgo_ts + 34727 + default: + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype = __ccgo_ts + 34732 + break + } + **(**int32)(__ccgo_up(pCsr + 2108)) += (*TStatPage)(unsafe.Pointer(p1)).FnCell + **(**Ti64)(__ccgo_up(pCsr + 2120)) += int64((*TStatPage)(unsafe.Pointer(p1)).FnUnused) + if (*TStatPage)(unsafe.Pointer(p1)).FnMxPayload > (*TStatCursor)(unsafe.Pointer(pCsr)).FnMxPayload { + (*TStatCursor)(unsafe.Pointer(pCsr)).FnMxPayload = (*TStatPage)(unsafe.Pointer(p1)).FnMxPayload + } + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + v1 = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, (*TStatPage)(unsafe.Pointer(p1)).FzPath)) + z = v1 + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath = v1 + if z == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + nPayload = 0 + i = 0 + for { + if !(i < (*TStatPage)(unsafe.Pointer(p1)).FnCell) { + break + } + nPayload = nPayload + (**(**TStatCell)(__ccgo_up((*TStatPage)(unsafe.Pointer(p1)).FaCell + uintptr(i)*32))).FnLocal + goto _6 + _6: + ; + i = i + 1 + } + **(**Ti64)(__ccgo_up(pCsr + 2128)) += int64(nPayload) + /* If computing aggregate space usage by btree, continue with the + ** next page. The loop will exit via the return at label-statNext-done + */ + if (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0 { + goto statNextRestart + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Scan through the expression pExpr. Replace every reference to +// ** a column in table number iTable with a copy of the iColumn-th +// ** entry in pEList. (But leave references to the ROWID column +// ** unchanged.) +// ** +// ** This routine is part of the flattening procedure. A subquery +// ** whose result set is defined by pEList appears as entry in the +// ** FROM clause of a SELECT such that the VDBE cursor assigned to that +// ** FORM clause entry is iTable. This routine makes the necessary +// ** changes to pExpr so that it refers directly to the source table +// ** of the subquery rather the result set of the subquery. +// */ +func _substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var db, pColl, pCopy, pNat, pNew, pWin, v1 uintptr + var iColumn int32 + var _ /* ifNullRow at bp+0 */ TExpr + _, _, _, _, _, _, _, _ = db, iColumn, pColl, pCopy, pNat, pNew, pWin, v1 + if pExpr == uintptr(0) { + return uintptr(0) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) && *(*int32)(unsafe.Pointer(pExpr + 52)) == (*TSubstContext)(unsafe.Pointer(pSubst)).FiTable { + *(*int32)(unsafe.Pointer(pExpr + 52)) = (*TSubstContext)(unsafe.Pointer(pSubst)).FiNewTable + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TSubstContext)(unsafe.Pointer(pSubst)).FiTable && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != libc.Uint32FromInt32(0)) { + iColumn = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + pCopy = (*(*TExprList_item)(unsafe.Pointer((*TSubstContext)(unsafe.Pointer(pSubst)).FpEList + 8 + uintptr(iColumn)*32))).FpExpr + if _sqlite3ExprIsVector(tls, pCopy) != 0 { + _sqlite3VectorErrorMsg(tls, (*TSubstContext)(unsafe.Pointer(pSubst)).FpParse, pCopy) + } else { + db = (*TParse)(unsafe.Pointer((*TSubstContext)(unsafe.Pointer(pSubst)).FpParse)).Fdb + if (*TSubstContext)(unsafe.Pointer(pSubst)).FisOuterJoin != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCopy)).Fop) != int32(TK_COLUMN) || (*TExpr)(unsafe.Pointer(pCopy)).FiTable != (*TSubstContext)(unsafe.Pointer(pSubst)).FiNewTable) { + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_IF_NULL_ROW) + (**(**TExpr)(__ccgo_up(bp))).FpLeft = pCopy + (**(**TExpr)(__ccgo_up(bp))).FiTable = (*TSubstContext)(unsafe.Pointer(pSubst)).FiNewTable + (**(**TExpr)(__ccgo_up(bp))).FiColumn = int16(-int32(99)) + (**(**TExpr)(__ccgo_up(bp))).Fflags = uint32(EP_IfNullRow) + pCopy = bp + } + pNew = _sqlite3ExprDup(tls, db, pCopy, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pNew) + return pExpr + } + if (*TSubstContext)(unsafe.Pointer(pSubst)).FisOuterJoin != 0 { + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pNew)).Fop) == int32(TK_TRUEFALSE) { + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pNew)).Fu)) = _sqlite3ExprTruthValue(tls, pNew) + (*TExpr)(unsafe.Pointer(pNew)).Fop = uint8(TK_INTEGER) + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) + } + /* Ensure that the expression now has an implicit collation sequence, + ** just as it did when it was a column of a view or sub-query. */ + pNat = _sqlite3ExprCollSeq(tls, (*TSubstContext)(unsafe.Pointer(pSubst)).FpParse, pNew) + pColl = _sqlite3ExprCollSeq(tls, (*TSubstContext)(unsafe.Pointer(pSubst)).FpParse, (*(*TExprList_item)(unsafe.Pointer((*TSubstContext)(unsafe.Pointer(pSubst)).FpCList + 8 + uintptr(iColumn)*32))).FpExpr) + if pNat != pColl || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pNew)).Fop) != int32(TK_COLUMN) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pNew)).Fop) != int32(TK_COLLATE) { + if pColl != 0 { + v1 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v1 = __ccgo_ts + 5237 + } + pNew = _sqlite3ExprAddCollateString(tls, (*TSubstContext)(unsafe.Pointer(pSubst)).FpParse, pNew, v1) + } + **(**Tu32)(__ccgo_up(pNew + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + _sqlite3SetJoinExpr(tls, pNew, *(*int32)(unsafe.Pointer(pExpr + 52)), (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON))) + } + _sqlite3ExprDelete(tls, db, pExpr) + pExpr = pNew + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IF_NULL_ROW) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TSubstContext)(unsafe.Pointer(pSubst)).FiTable { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSubstContext)(unsafe.Pointer(pSubst)).FiNewTable + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_FUNCTION) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) >= (*TSubstContext)(unsafe.Pointer(pSubst)).FnSelDepth { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop2 - 1 + } + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = _substExpr(tls, pSubst, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = _substExpr(tls, pSubst, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _substSelect(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 32)), int32(1)) + } else { + _substExprList(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + pWin = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + (*TWindow)(unsafe.Pointer(pWin)).FpFilter = _substExpr(tls, pSubst, (*TWindow)(unsafe.Pointer(pWin)).FpFilter) + _substExprList(tls, pSubst, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) + _substExprList(tls, pSubst, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) + } + } + return pExpr +} + +// C documentation +// +// /* +// ** Allocate space to hold a new trigger step. The allocated space +// ** holds both the TriggerStep object and the TriggerStep.target.z string. +// ** +// ** If an OOM error occurs, NULL is returned and db->mallocFailed is set. +// */ +func _triggerStepAllocate(tls *libc.TLS, pParse uintptr, op Tu8, pTabList uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var db, pNew, pTriggerStep uintptr + _, _, _ = db, pNew, pTriggerStep + pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTriggerStep = uintptr(0) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + if pNew != 0 && (*TTrigger)(unsafe.Pointer(pNew)).FpSchema != (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema && *(*uintptr)(unsafe.Pointer(pTabList + 8 + 72)) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22243, 0) + } else { + pTriggerStep = _sqlite3DbMallocZero(tls, db, uint64(88)) + if pTriggerStep != 0 { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc = _sqlite3SrcListDup(tls, db, pTabList, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = op + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = _triggerSpanDup(tls, db, zStart, zEnd) + if (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc != 0 && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc + 8))).FzName, (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FzName) + } + } + } + } + _sqlite3SrcListDelete(tls, db, pTabList) + return pTriggerStep +} + +// C documentation +// +// /* +// ** The unhex() function. This function may be invoked with either one or +// ** two arguments. In both cases the first argument is interpreted as text +// ** a text value containing a set of pairs of hexadecimal digits which are +// ** decoded and returned as a blob. +// ** +// ** If there is only a single argument, then it must consist only of an +// ** even number of hexadecimal digits. Otherwise, return NULL. +// ** +// ** Or, if there is a second argument, then any character that appears in +// ** the second argument is also allowed to appear between pairs of hexadecimal +// ** digits in the first argument. If any other character appears in the +// ** first argument, or if one of the allowed characters appears between +// ** two hexadecimal digits that make up a single byte, NULL is returned. +// ** +// ** The following expressions are all true: +// ** +// ** unhex('ABCD') IS x'ABCD' +// ** unhex('AB CD') IS NULL +// ** unhex('AB CD', ' ') IS x'ABCD' +// ** unhex('A BCD', ' ') IS NULL +// */ +func _unhexFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, d, v2 Tu8 + var ch Tu32 + var nHex, nPass int32 + var p, pBlob, zPass, v1 uintptr + var v3 uint32 + var _ /* zHex at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = c, ch, d, nHex, nPass, p, pBlob, zPass, v1, v2, v3 + zPass = __ccgo_ts + 1704 + nPass = 0 + **(**uintptr)(__ccgo_up(bp)) = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + nHex = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + pBlob = uintptr(0) + p = uintptr(0) + if argc == int32(2) { + zPass = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + nPass = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } + if !(**(**uintptr)(__ccgo_up(bp)) != 0) || !(zPass != 0) { + return + } + v1 = _contextMalloc(tls, pCtx, int64(nHex/int32(2)+int32(1))) + pBlob = v1 + p = v1 + if pBlob != 0 { /* Least significant digit of next byte */ + for { + v2 = **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) + c = v2 + if !(libc.Int32FromUint8(v2) != 0x00) { + break + } + for !(libc.Int32FromUint8(_sqlite3CtypeMap[c])&libc.Int32FromInt32(0x08) != 0) { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) < int32(0x80) { + v1 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v3 = uint32(**(**Tu8)(__ccgo_up(v1))) + } else { + v3 = _sqlite3Utf8Read(tls, bp) + } + ch = v3 + if !(_strContainsChar(tls, zPass, nPass, ch) != 0) { + goto unhex_null + } + c = **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) + if libc.Int32FromUint8(c) == 0x00 { + goto unhex_done + } + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v1 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + d = **(**Tu8)(__ccgo_up(v1)) + if !(libc.Int32FromUint8(_sqlite3CtypeMap[d])&libc.Int32FromInt32(0x08) != 0) { + goto unhex_null + } + v1 = p + p = p + 1 + **(**Tu8)(__ccgo_up(v1)) = libc.Uint8FromInt32(libc.Int32FromUint8(_sqlite3HexToInt(tls, libc.Int32FromUint8(c)))< _sqlite3Config.FmxMmap { + newLimit = _sqlite3Config.FmxMmap + } + /* The value of newLimit may be eventually cast to (size_t) and passed + ** to mmap(). Restrict its value to 2GB if (size_t) is not at least a + ** 64-bit type. */ + if newLimit > 0 && libc.Bool(uint64(8) < uint64(8)) { + newLimit = newLimit & libc.Int64FromInt32(0x7FFFFFFF) + } + **(**Ti64)(__ccgo_up(pArg)) = (*TunixFile)(unsafe.Pointer(pFile)).FmmapSizeMax + if newLimit >= 0 && newLimit != (*TunixFile)(unsafe.Pointer(pFile)).FmmapSizeMax && (*TunixFile)(unsafe.Pointer(pFile)).FnFetchOut == 0 { + (*TunixFile)(unsafe.Pointer(pFile)).FmmapSizeMax = newLimit + if (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize > 0 { + _unixUnmapfile(tls, pFile) + rc1 = _unixMapfile(tls, pFile, int64(-int32(1))) + } + } + return rc1 + case int32(SQLITE_FCNTL_EXTERNAL_READER): + return _unixFcntlExternalReader(tls, id, pArg) + } + return int32(SQLITE_NOTFOUND) +} + +// C documentation +// +// /* +// ** Write nBuf bytes of random data to the supplied buffer zBuf. +// */ +func _unixRandomness(tls *libc.TLS, NotUsed uintptr, nBuf int32, zBuf uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var fd, got int32 + var _ /* rp at bp+8 */ Tpid_t + var _ /* t at bp+0 */ Ttime_t + _, _ = fd, got + _ = NotUsed + /* We have to initialize zBuf to prevent valgrind from reporting + ** errors. The reports issued by valgrind are incorrect - we would + ** prefer that the randomness be increased by making use of the + ** uninitialized space in zBuf - but valgrind errors tend to worry + ** some users. Rather than argue, it seems easier just to initialize + ** the whole array and silence valgrind, even if that means less randomness + ** in the random seed. + ** + ** When testing, initializing zBuf[] to zero is all we do. That means + ** that we always use the same random number sequence. This makes the + ** tests repeatable. + */ + libc.Xmemset(tls, zBuf, 0, libc.Uint64FromInt32(nBuf)) + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_randomnessPid)), libc.Xgetpid(tls)) + fd = _robust_open(tls, __ccgo_ts+4075, O_RDONLY, uint32(0)) + if fd < 0 { + libc.Xtime(tls, bp) + libc.Xmemcpy(tls, zBuf, bp, uint64(8)) + **(**Tpid_t)(__ccgo_up(bp + 8)) = libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_randomnessPid))) + libc.Xmemcpy(tls, zBuf+uintptr(8), bp+8, uint64(4)) + nBuf = libc.Int32FromUint64(libc.Uint64FromInt64(8) + libc.Uint64FromInt64(4)) + } else { + for cond := true; cond; cond = got < 0 && **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(EINTR) { + got = int32((*(*func(*libc.TLS, int32, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(8)].FpCurrent})))(tls, fd, zBuf, libc.Uint64FromInt32(nBuf))) + } + _robust_close(tls, uintptr(0), fd, int32(47319)) + } + return nBuf +} + +// C documentation +// +// /* +// ** Attempt to set the size of the memory mapping maintained by file +// ** descriptor pFd to nNew bytes. Any existing mapping is discarded. +// ** +// ** If successful, this function sets the following variables: +// ** +// ** unixFile.pMapRegion +// ** unixFile.mmapSize +// ** unixFile.mmapSizeActual +// ** +// ** If unsuccessful, an error message is logged via sqlite3_log() and +// ** the three variables above are zeroed. In this case SQLite should +// ** continue accessing the database using the xRead() and xWrite() +// ** methods. +// */ +func _unixRemapfile(tls *libc.TLS, pFd uintptr, nNew Ti64) { + var flags, h int32 + var nOrig, nReuse Ti64 + var pNew, pOrig, pReq, zErr uintptr + var v1 Tsqlite3_int64 + _, _, _, _, _, _, _, _, _ = flags, h, nOrig, nReuse, pNew, pOrig, pReq, zErr, v1 + zErr = __ccgo_ts + 3700 + h = (*TunixFile)(unsafe.Pointer(pFd)).Fh /* File descriptor open on db file */ + pOrig = (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion /* Pointer to current file mapping */ + nOrig = (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeActual /* Size of pOrig region in bytes */ + pNew = uintptr(0) /* Location of new mapping */ + flags = int32(PROT_READ) /* Flags to pass to mmap() */ + if pOrig != 0 { + nReuse = (*TunixFile)(unsafe.Pointer(pFd)).FmmapSize + pReq = pOrig + uintptr(nReuse) + /* Unmap any pages of the existing mapping that cannot be reused. */ + if nReuse != nOrig { + (*(*func(*libc.TLS, uintptr, Tsize_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(23)].FpCurrent})))(tls, pReq, libc.Uint64FromInt64(nOrig-nReuse)) + } + pNew = (*(*func(*libc.TLS, uintptr, Tsize_t, Tsize_t, int32, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(24)].FpCurrent})))(tls, pOrig, libc.Uint64FromInt64(nReuse), libc.Uint64FromInt64(nNew), int32(MREMAP_MAYMOVE), 0) + zErr = __ccgo_ts + 3712 + /* The attempt to extend the existing mapping failed. Free it. */ + if pNew == uintptr(-libc.Int32FromInt32(1)) || pNew == uintptr(0) { + (*(*func(*libc.TLS, uintptr, Tsize_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(23)].FpCurrent})))(tls, pOrig, libc.Uint64FromInt64(nReuse)) + } + } + /* If pNew is still NULL, try to create an entirely new mapping. */ + if pNew == uintptr(0) { + pNew = (*(*func(*libc.TLS, uintptr, Tsize_t, int32, int32, int32, Toff_t) uintptr)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(22)].FpCurrent})))(tls, uintptr(0), libc.Uint64FromInt64(nNew), flags, int32(MAP_SHARED), h, 0) + } + if pNew == uintptr(-libc.Int32FromInt32(1)) { + pNew = uintptr(0) + nNew = 0 + _unixLogErrorAtLine(tls, SQLITE_OK, zErr, (*TunixFile)(unsafe.Pointer(pFd)).FzPath, int32(45837)) + /* If the mmap() above failed, assume that all subsequent mmap() calls + ** will probably fail too. Fall back to using xRead/xWrite exclusively + ** in this case. */ + (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeMax = 0 + } + (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion = pNew + v1 = nNew + (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeActual = v1 + (*TunixFile)(unsafe.Pointer(pFd)).FmmapSize = v1 +} + +// C documentation +// +// /* +// ** Make sure all writes to a particular file are committed to disk. +// ** +// ** If dataOnly==0 then both the file itself and its metadata (file +// ** size, access time, etc) are synced. If dataOnly!=0 then only the +// ** file data is synced. +// ** +// ** Under Unix, also make sure that the directory entry for the file +// ** has been created by fsync-ing the directory that contains the file. +// ** If we do not do this and we encounter a power failure, the directory +// ** entry for the journal might not exist after we reboot. The next +// ** SQLite to access the file will not know that the journal exists (because +// ** the directory entry for the journal was never created) and the transaction +// ** will not roll back - possibly leading to database corruption. +// */ +func _unixSync(tls *libc.TLS, id uintptr, flags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var isDataOnly, isFullsync, rc int32 + var pFile, v1 uintptr + var _ /* dirfd at bp+0 */ int32 + _, _, _, _, _ = isDataOnly, isFullsync, pFile, rc, v1 + pFile = id + isDataOnly = flags & int32(SQLITE_SYNC_DATAONLY) + isFullsync = libc.BoolInt32(flags&int32(0x0F) == int32(SQLITE_SYNC_FULL)) + /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */ + /* Unix cannot, but some systems may return SQLITE_FULL from here. This + ** line is to test that doing so does not cause any problems. + */ + rc = _full_fsync(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, isFullsync, isDataOnly) + if rc != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__errno_location(tls)))) + return _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(4)<= int32(SQLITE_TXN_WRITE) { + rc = _sqlite3BtreeCommitPhaseOne(tls, pBt1, uintptr(0)) + } + goto _2 + _2: + ; + i = i + 1 + } + } + /* Do the commit only if all databases successfully complete phase 1. + ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an + ** IO error while deleting or truncating a journal file. It is unlikely, + ** but could happen. In this case abandon processing and return the error. + */ + i = 0 + for { + if !(rc == SQLITE_OK && i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + txn = _sqlite3BtreeTxnState(tls, pBt2) + if txn != SQLITE_TXN_NONE { + rc = _sqlite3BtreeCommitPhaseTwo(tls, pBt2, 0) + } + goto _3 + _3: + ; + i = i + 1 + } + if rc == SQLITE_OK { + _sqlite3VtabCommit(tls, db) + } + } else { + pVfs = (*Tsqlite3)(unsafe.Pointer(db)).FpVfs + zSuper = uintptr(0) /* File-name for the super-journal */ + zMainFile = _sqlite3BtreeGetFilename(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpBt) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + offset = 0 + retryCount = 0 + /* Select a super-journal file name */ + nMainFile = _sqlite3Strlen30(tls, zMainFile) + zSuper = _sqlite3MPrintf(tls, db, __ccgo_ts+5338, libc.VaList(bp+24, 0, zMainFile, 0)) + if zSuper == uintptr(0) { + return int32(SQLITE_NOMEM) + } + zSuper = zSuper + uintptr(4) + for cond := true; cond; cond = rc == SQLITE_OK && **(**int32)(__ccgo_up(bp + 8)) != 0 { + if retryCount != 0 { + if retryCount > int32(100) { + Xsqlite3_log(tls, int32(SQLITE_FULL), __ccgo_ts+5350, libc.VaList(bp+24, zSuper)) + _sqlite3OsDelete(tls, pVfs, zSuper, 0) + break + } else { + if retryCount == int32(1) { + Xsqlite3_log(tls, int32(SQLITE_FULL), __ccgo_ts+5364, libc.VaList(bp+24, zSuper)) + } + } + } + retryCount = retryCount + 1 + Xsqlite3_randomness(tls, int32(4), bp+12) + Xsqlite3_snprintf(tls, int32(13), zSuper+uintptr(nMainFile), __ccgo_ts+5379, libc.VaList(bp+24, **(**Tu32)(__ccgo_up(bp + 12))>>libc.Int32FromInt32(8)&uint32(0xffffff), **(**Tu32)(__ccgo_up(bp + 12))&uint32(0xff))) + /* The antipenultimate character of the super-journal name must + ** be "9" to avoid name collisions when using 8+3 filenames. */ + rc = _sqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+8) + } + if rc == SQLITE_OK { + /* Open the super-journal. */ + rc = _sqlite3OsOpenMalloc(tls, pVfs, zSuper, bp, libc.Int32FromInt32(SQLITE_OPEN_READWRITE)|libc.Int32FromInt32(SQLITE_OPEN_CREATE)|libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE)|libc.Int32FromInt32(SQLITE_OPEN_SUPER_JOURNAL), uintptr(0)) + } + if rc != SQLITE_OK { + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + return rc + } + /* Write the name of each database file in the transaction into the new + ** super-journal file. If an error occurs at this point close + ** and delete the super-journal file. All the individual journal files + ** still have 'null' as the super-journal pointer, so they will roll + ** back independently if a failure occurs. + */ + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt3 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if _sqlite3BtreeTxnState(tls, pBt3) == int32(SQLITE_TXN_WRITE) { + zFile = _sqlite3BtreeGetJournalname(tls, pBt3) + if zFile == uintptr(0) { + goto _4 /* Ignore TEMP and :memory: databases */ + } + rc = _sqlite3OsWrite(tls, **(**uintptr)(__ccgo_up(bp)), zFile, _sqlite3Strlen30(tls, zFile)+int32(1), offset) + offset = offset + int64(_sqlite3Strlen30(tls, zFile)+int32(1)) + if rc != SQLITE_OK { + _sqlite3OsCloseFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3OsDelete(tls, pVfs, zSuper, 0) + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + return rc + } + } + goto _4 + _4: + ; + i = i + 1 + } + /* Sync the super-journal file. If the IOCAP_SEQUENTIAL device + ** flag is set this is not required. + */ + if v6 = 0 == _sqlite3OsDeviceCharacteristics(tls, **(**uintptr)(__ccgo_up(bp)))&int32(SQLITE_IOCAP_SEQUENTIAL); v6 { + v5 = _sqlite3OsSync(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_SYNC_NORMAL)) + rc = v5 + } + if v6 && SQLITE_OK != v5 { + _sqlite3OsCloseFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3OsDelete(tls, pVfs, zSuper, 0) + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + return rc + } + /* Sync all the db files involved in the transaction. The same call + ** sets the super-journal pointer in each individual journal. If + ** an error occurs here, do not delete the super-journal file. + ** + ** If the error occurs during the first call to + ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the + ** super-journal file will be orphaned. But we cannot delete it, + ** in case the super-journal file name was written into the journal + ** file before the failure occurred. + */ + i = 0 + for { + if !(rc == SQLITE_OK && i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt4 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt4 != 0 { + rc = _sqlite3BtreeCommitPhaseOne(tls, pBt4, zSuper) + } + goto _7 + _7: + ; + i = i + 1 + } + _sqlite3OsCloseFree(tls, **(**uintptr)(__ccgo_up(bp))) + if rc != SQLITE_OK { + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + return rc + } + /* Delete the super-journal file. This commits the transaction. After + ** doing this the directory is synced again before any individual + ** transaction files are deleted. + */ + rc = _sqlite3OsDelete(tls, pVfs, zSuper, int32(1)) + _sqlite3DbFree(tls, db, zSuper-uintptr(4)) + zSuper = uintptr(0) + if rc != 0 { + return rc + } + /* All files and directories have already been synced, so the following + ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and + ** deleting or truncating journals. If something goes wrong while + ** this is happening we don't really care. The integrity of the + ** transaction is already guaranteed, but some stray 'cold' journals + ** may be lying around. Returning an error code won't help matters. + */ + _sqlite3BeginBenignMalloc(tls) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt5 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt5 != 0 { + _sqlite3BtreeCommitPhaseTwo(tls, pBt5, int32(1)) + } + goto _8 + _8: + ; + i = i + 1 + } + _sqlite3EndBenignMalloc(tls) + _sqlite3VtabCommit(tls, db) + } + return rc +} + +// C documentation +// +// /******************************* sqlite3_bind_ *************************** +// ** +// ** Routines used to attach values to wildcards in a compiled SQL statement. +// */ +// /* +// ** Unbind the value bound to variable i in virtual machine p. This is the +// ** the same as binding a NULL value to the column. If the "i" parameter is +// ** out of range, then SQLITE_RANGE is returned. Otherwise SQLITE_OK. +// ** +// ** A successful evaluation of this routine acquires the mutex on p. +// ** the mutex is released if any kind of error occurs. +// ** +// ** The error code stored in database p->db is overwritten with the return +// ** value in any case. +// ** +// ** (tag-20240917-01) If vdbeUnbind(p,(u32)(i-1)) returns SQLITE_OK, +// ** that means all of the the following will be true: +// ** +// ** p!=0 +// ** p->pVar!=0 +// ** i>0 +// ** i<=p->nVar +// ** +// ** An assert() is normally added after vdbeUnbind() to help static analyzers +// ** realize this. +// */ +func _vdbeUnbind(tls *libc.TLS, p uintptr, i uint32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pVar uintptr + var v1 uint32 + var v2 bool + _, _, _ = pVar, v1, v2 + if _vdbeSafetyNotNull(tls, p) != 0 { + return _sqlite3MisuseError(tls, int32(95215)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FeVdbeState) != int32(VDBE_READY_STATE) { + _sqlite3Error(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, _sqlite3MisuseError(tls, int32(95219))) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+5673, libc.VaList(bp+8, (*TVdbe)(unsafe.Pointer(p)).FzSql)) + return _sqlite3MisuseError(tls, int32(95223)) + } + if i >= libc.Uint32FromInt16((*TVdbe)(unsafe.Pointer(p)).FnVar) { + _sqlite3Error(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, int32(SQLITE_RANGE)) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + return int32(SQLITE_RANGE) + } + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56 + _sqlite3VdbeMemRelease(tls, pVar) + (*TMem)(unsafe.Pointer(pVar)).Fflags = uint16(MEM_Null) + (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FerrCode = SQLITE_OK + /* If the bit corresponding to this variable in Vdbe.expmask is set, then + ** binding a new value to this variable invalidates the current query plan. + ** + ** IMPLEMENTATION-OF: R-57496-20354 If the specific value bound to a host + ** parameter in the WHERE clause might influence the choice of query plan + ** for a statement, then the statement will be automatically recompiled, + ** as if there had been a schema change, on the first sqlite3_step() call + ** following any change to the bindings of that parameter. + */ + if v2 = (*TVdbe)(unsafe.Pointer(p)).Fexpmask != uint32(0); v2 { + if i >= uint32(31) { + v1 = uint32(0x80000000) + } else { + v1 = libc.Uint32FromInt32(1) << i + } + } + if v2 && (*TVdbe)(unsafe.Pointer(p)).Fexpmask&v1 != uint32(0) { + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 0, 0x3) + } + return SQLITE_OK +} + +// C documentation +// +// /* Return true if table pTab is read-only. +// ** +// ** A table is read-only if any of the following are true: +// ** +// ** 1) It is a virtual table and no implementation of the xUpdate method +// ** has been provided +// ** +// ** 2) A trigger is currently being coded and the table is a virtual table +// ** that is SQLITE_VTAB_DIRECTONLY or if PRAGMA trusted_schema=OFF and +// ** the table is not SQLITE_VTAB_INNOCUOUS. +// ** +// ** 3) It is a system table (i.e. sqlite_schema), this call is not +// ** part of a nested parse and writable_schema pragma has not +// ** been specified +// ** +// ** 4) The table is a shadow table, the database connection is in +// ** defensive mode, and the current sqlite3_prepare() +// ** is for a top-level SQL statement. +// */ +func _vtabIsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer(_sqlite3GetVTable(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pTab))).FpMod)).FpModule)).FxUpdate == uintptr(0) { + return int32(1) + } + /* Within triggers: + ** * Do not allow DELETE, INSERT, or UPDATE of SQLITE_VTAB_DIRECTONLY + ** virtual tables + ** * Only allow DELETE, INSERT, or UPDATE of non-SQLITE_VTAB_INNOCUOUS + ** virtual tables if PRAGMA trusted_schema=ON. + */ + if ((*TParse)(unsafe.Pointer(pParse)).FpToplevel != uintptr(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_FROM_DDL) != 0) && libc.Int32FromUint8((*TVTable)(unsafe.Pointer((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp)).FeVtabRisk) > libc.BoolInt32((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_TrustedSchema) != uint64(0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16345, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + } + return 0 +} + +// C documentation +// +// /* +// ** Add all WhereLoop objects for all tables +// */ +func _whereLoopAddAll(tls *libc.TLS, pBuilder uintptr) (r int32) { + var bFirstPastRJ, hasRightCrossJoin, i, iTab, rc int32 + var db, p, pEnd, pItem, pNew, pTabList, pTerm, pWC, pWInfo uintptr + var mPrereq, mPrior, mUnusable TBitmask + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bFirstPastRJ, db, hasRightCrossJoin, i, iTab, mPrereq, mPrior, mUnusable, p, pEnd, pItem, pNew, pTabList, pTerm, pWC, pWInfo, rc + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + mPrereq = uint64(0) + mPrior = uint64(0) + pTabList = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + pEnd = pTabList + 8 + uintptr((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)*80 + db = (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb + rc = SQLITE_OK + bFirstPastRJ = 0 + hasRightCrossJoin = 0 + /* Loop over the tables in the join, from left to right */ + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + /* Verify that pNew has already been initialized */ + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit = uint32(SQLITE_QUERY_PLANNER_LIMIT) + iTab = 0 + pItem = pTabList + 8 + for { + if !(pItem < pEnd) { + break + } + mUnusable = uint64(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FiTab = libc.Uint8FromInt32(iTab) + **(**uint32)(__ccgo_up(pBuilder + 48)) += uint32(SQLITE_QUERY_PLANNER_LIMIT_INCR) + (*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf = _sqlite3WhereGetMask(tls, pWInfo+592, (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor) + if bFirstPastRJ != 0 || libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)|libc.Int32FromInt32(JT_LTORJ)) != 0 { + /* Add prerequisites to prevent reordering of FROM clause terms + ** across CROSS joins and outer joins. The bFirstPastRJ boolean + ** prevents the right operand of a RIGHT JOIN from being swapped with + ** other elements even further to the right. + ** + ** The hasRightCrossJoin flag prevent FROM-clause terms from moving + ** from the right side of a LEFT JOIN or CROSS JOIN over to the + ** left side of that same join. This is a required restriction in + ** the case of LEFT JOIN - an incorrect answer may results if it is + ** not enforced. This restriction is not required for CROSS JOIN. + ** It is provided merely as a means of controlling join order, under + ** the theory that no real-world queries that care about performance + ** actually use the CROSS JOIN syntax. + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_CROSS)) != 0 { + hasRightCrossJoin = int32(1) + } + mPrereq = mPrereq | mPrior + bFirstPastRJ = libc.BoolInt32(libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0) + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x40000>>18) != 0 { + /* joins that result from the EXISTS-to-JOIN optimization should not + ** be moved to the left of any of their dependencies */ + pWC = pWInfo + 104 + i = (*TWhereClause)(unsafe.Pointer(pWC)).FnBase + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(i > 0) { + break + } + if (*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf&(*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll != uint64(0) { + mPrereq = mPrereq | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&((*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf-uint64(1)) + } + goto _2 + _2: + ; + i = i - 1 + pTerm += 56 + } + } else { + if !(hasRightCrossJoin != 0) { + mPrereq = uint64(0) + } + } + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FeTabType) == int32(TABTYP_VTAB) { + p = pItem + 1*80 + for { + if !(p < pEnd) { + break + } + if mUnusable != 0 || libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(p)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)) != 0 { + mUnusable = mUnusable | _sqlite3WhereGetMask(tls, pWInfo+592, (*TSrcItem)(unsafe.Pointer(p)).FiCursor) + } + goto _3 + _3: + ; + p += 80 + } + rc = _whereLoopAddVirtual(tls, pBuilder, mPrereq, mUnusable) + } else { + rc = _whereLoopAddBtree(tls, pBuilder, mPrereq) + } + if rc == SQLITE_OK && (*TWhereClause)(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC)).FhasOr != 0 { + rc = _whereLoopAddOr(tls, pBuilder, mPrereq, mUnusable) + } + mPrior = mPrior | (*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf + if rc != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + if rc == int32(SQLITE_DONE) { + /* We hit the query planner search limit set by iPlanLimit */ + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+23982, 0) + rc = SQLITE_OK + } else { + break + } + } + goto _1 + _1: + ; + iTab = iTab + 1 + pItem += 80 + } + _whereLoopClear(tls, db, pNew) + return rc +} + +// C documentation +// +// /* +// ** Argument pIdxInfo is already populated with all constraints that may +// ** be used by the virtual table identified by pBuilder->pNew->iTab. This +// ** function marks a subset of those constraints usable, invokes the +// ** xBestIndex method and adds the returned plan to pBuilder. +// ** +// ** A constraint is marked usable if: +// ** +// ** * Argument mUsable indicates that its prerequisites are available, and +// ** +// ** * It is not one of the operators specified in the mExclude mask passed +// ** as the fourth argument (which in practice is either WO_IN or 0). +// ** +// ** Argument mPrereq is a mask of tables that must be scanned before the +// ** virtual table in question. These are added to the plans prerequisites +// ** before it is added to pBuilder. +// ** +// ** Output parameter *pbIn is set to true if the plan added to pBuilder +// ** uses one or more WO_IN terms, or false otherwise. +// */ +func _whereLoopAddVirtualOne(tls *libc.TLS, pBuilder uintptr, mPrereq TBitmask, mUsable TBitmask, mExclude Tu16, pIdxInfo uintptr, mNoOmit Tu16, pbIn uintptr, pbRetryLimit uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iTerm, j, mxTerm, nConstraint, rc, v3 int32 + var pHidden, pIdxCons, pNew, pParse, pSrc, pTerm, pTerm1, pUsage, pWC, v4 uintptr + var v5 bool + var v7 uint32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iTerm, j, mxTerm, nConstraint, pHidden, pIdxCons, pNew, pParse, pSrc, pTerm, pTerm1, pUsage, pWC, rc, v3, v4, v5, v7 + pWC = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC + pHidden = pIdxInfo + 1*96 + pUsage = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + rc = SQLITE_OK + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + pParse = (*TWhereInfo)(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpParse + pSrc = (*TWhereInfo)(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pNew)).FiTab)*80 + nConstraint = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint + **(**int32)(__ccgo_up(pbIn)) = 0 + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq + /* Set the usable flag on the subset of constraints identified by + ** arguments mUsable and mExclude. */ + pIdxCons = **(**uintptr)(__ccgo_up(pIdxInfo + 8)) + i = 0 + for { + if !(i < nConstraint) { + break + } + pTerm = _termFromWhereClause(tls, pWC, (*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).FiTermOffset) + (*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable = uint8(0) + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&mUsable == (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&libc.Int32FromUint16(mExclude) == 0 && (pbRetryLimit != 0 || !(_isLimitTerm(tls, pTerm) != 0)) { + (*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable = uint8(1) + } + goto _1 + _1: + ; + i = i + 1 + pIdxCons += 12 + } + /* Initialize the output fields of the sqlite3_index_info structure */ + libc.Xmemset(tls, pUsage, 0, uint64(8)*libc.Uint64FromInt32(nConstraint)) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = uintptr(0) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 0 + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1e+99) / libc.Float64FromInt32(2) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(25) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 0 + (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FmHandleIn = uint32(0) + /* Invoke the virtual table xBestIndex() method */ + rc = _vtabBestIndex(tls, pParse, (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab, pIdxInfo) + if rc != 0 { + if rc == int32(SQLITE_CONSTRAINT) { + /* If the xBestIndex method returns SQLITE_CONSTRAINT, that means + ** that the particular combination of parameters provided is unusable. + ** Make no entries in the loop table. + */ + _freeIdxStr(tls, pIdxInfo) + return SQLITE_OK + } + return rc + } + mxTerm = -int32(1) + libc.Xmemset(tls, (*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm, 0, uint64(8)*libc.Uint64FromInt32(nConstraint)) + libc.Xmemset(tls, pNew+24, 0, uint64(24)) + pIdxCons = **(**uintptr)(__ccgo_up(pIdxInfo + 8)) + i = 0 + for { + if !(i < nConstraint) { + break + } + v3 = (**(**Tsqlite3_index_constraint_usage)(__ccgo_up(pUsage + uintptr(i)*8))).FargvIndex - libc.Int32FromInt32(1) + iTerm = v3 + if v3 >= 0 { + j = (*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).FiTermOffset + if v5 = iTerm >= nConstraint || j < 0; !v5 { + v4 = _termFromWhereClause(tls, pWC, j) + pTerm1 = v4 + } + if v5 || v4 == uintptr(0) || **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(iTerm)*8)) != uintptr(0) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+23956, libc.VaList(bp+8, (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FzName)) + _freeIdxStr(tls, pIdxInfo) + return int32(SQLITE_ERROR) + } + **(**TBitmask)(__ccgo_up(pNew)) |= (*TWhereTerm)(unsafe.Pointer(pTerm1)).FprereqRight + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(iTerm)*8)) = pTerm1 + if iTerm > mxTerm { + mxTerm = iTerm + } + if (**(**Tsqlite3_index_constraint_usage)(__ccgo_up(pUsage + uintptr(i)*8))).Fomit != 0 { + if i < int32(16) && int32(1)<>0)) != 0 { + Xsqlite3_free(tls, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pNew + 24))).FidxStr) + libc.SetBitFieldPtr8Uint32(pNew+24+4, libc.Uint32FromInt32(0), 0, 0x1) + } + return rc +} + +// C documentation +// +// /* +// ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine +// ** attempts to find the lowest cost path that visits each WhereLoop +// ** once. This path is then loaded into the pWInfo->a[].pWLoop fields. +// ** +// ** Assume that the total number of output rows that will need to be sorted +// ** will be nRowEst (in the 10*log2 representation). Or, ignore sorting +// ** costs if nRowEst==0. +// ** +// ** Return SQLITE_OK on success or SQLITE_NOMEM of a memory allocation +// ** error occurs. +// */ +func _wherePathSolver(tls *libc.TLS, pWInfo uintptr, nRowEst TLogEst) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aFrom, aSortCost, aTo, pFrom, pLevel, pParse, pSpace, pTo, pWLoop, pX, v11 uintptr + var iLoop, ii, jj, mxChoice, mxI, nFrom, nLoop, nOrder, nOrderBy, nSpace, nTo, rc, rc1, v2 int32 + var isOrdered Ti8 + var maskNew TBitmask + var mxCost, mxUnsort, nOut, rCost, rUnsort TLogEst + var wsFlags Tu32 + var _ /* m at bp+16 */ TBitmask + var _ /* notUsed at bp+8 */ TBitmask + var _ /* revMask at bp+0 */ TBitmask + var _ /* revMask at bp+24 */ TBitmask + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aFrom, aSortCost, aTo, iLoop, ii, isOrdered, jj, maskNew, mxChoice, mxCost, mxI, mxUnsort, nFrom, nLoop, nOrder, nOrderBy, nOut, nSpace, nTo, pFrom, pLevel, pParse, pSpace, pTo, pWLoop, pX, rCost, rUnsort, rc, rc1, wsFlags, v11, v2 /* Loop counters */ + mxI = 0 /* Number of ORDER BY clause terms */ + mxCost = 0 /* Maximum cost of a set of paths */ + mxUnsort = 0 /* Used to divy up the pSpace memory */ + aSortCost = uintptr(0) /* Bytes of space allocated at pSpace */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + nLoop = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) + /* TUNING: mxChoice is the maximum number of possible paths to preserve + ** at each step. Based on the number of loops in the FROM clause: + ** + ** nLoop mxChoice + ** ----- -------- + ** 1 1 // the most common case + ** 2 5 + ** 3+ 12 or 18 // see computeMxChoice() + */ + if nLoop <= int32(1) { + mxChoice = int32(1) + } else { + if nLoop == int32(2) { + mxChoice = int32(5) + } else { + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + mxChoice = int32(1) + } else { + mxChoice = _computeMxChoice(tls, pWInfo) + } + } + } + /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this + ** case the purpose of this call is to estimate the number of rows returned + ** by the overall query. Once this estimate has been obtained, the caller + ** will invoke this function a second time, passing the estimate as the + ** nRowEst parameter. */ + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0) || int32(nRowEst) == 0 { + nOrderBy = 0 + } else { + nOrderBy = (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr + } + /* Allocate and initialize space for aTo, aFrom and aSortCost[] */ + nSpace = libc.Int32FromUint64((uint64(32) + uint64(8)*libc.Uint64FromInt32(nLoop)) * libc.Uint64FromInt32(mxChoice) * uint64(2)) + nSpace = libc.Int32FromUint64(uint64(nSpace) + libc.Uint64FromInt64(2)*libc.Uint64FromInt32(nOrderBy)) + pSpace = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, libc.Uint64FromInt32(nSpace)) + if pSpace == uintptr(0) { + return int32(SQLITE_NOMEM) + } + aTo = pSpace + aFrom = aTo + uintptr(mxChoice)*32 + libc.Xmemset(tls, aFrom, 0, uint64(32)) + pX = aFrom + uintptr(mxChoice)*32 + ii = mxChoice * int32(2) + pFrom = aTo + for { + if !(ii > 0) { + break + } + (*TWherePath)(unsafe.Pointer(pFrom)).FaLoop = pX + goto _1 + _1: + ; + ii = ii - 1 + pFrom += 32 + pX = pX + uintptr(nLoop)*8 + } + if nOrderBy != 0 { + /* If there is an ORDER BY clause and it is not being ignored, set up + ** space for the aSortCost[] array. Each element of the aSortCost array + ** is either zero - meaning it has not yet been initialized - or the + ** cost of sorting nRowEst rows of data where the first X terms of + ** the ORDER BY clause are already in order, where X is the array + ** index. */ + aSortCost = pX + libc.Xmemset(tls, aSortCost, 0, uint64(2)*libc.Uint64FromInt32(nOrderBy)) + } + /* Seed the search with a single WherePath containing zero WhereLoops. + ** + ** TUNING: Do not let the number of iterations go above 28. If the cost + ** of computing an automatic index is not paid back within the first 28 + ** rows, then do not use the automatic index. */ + if int32((*TParse)(unsafe.Pointer(pParse)).FnQueryLoop) < int32(48) { + v2 = int32((*TParse)(unsafe.Pointer(pParse)).FnQueryLoop) + } else { + v2 = int32(48) + } + (**(**TWherePath)(__ccgo_up(aFrom))).FnRow = int16(v2) + nFrom = int32(1) + if nOrderBy != 0 { + /* If nLoop is zero, then there are no FROM terms in the query. Since + ** in this case the query may return a maximum of one row, the results + ** are already in the requested order. Set isOrdered to nOrderBy to + ** indicate this. Or, if nLoop is greater than zero, set isOrdered to + ** -1, indicating that the result set may or may not be ordered, + ** depending on the loops added to the current plan. */ + if nLoop > 0 { + v2 = -int32(1) + } else { + v2 = nOrderBy + } + (**(**TWherePath)(__ccgo_up(aFrom))).FisOrdered = int8(v2) + } + /* Compute successively longer WherePaths using the previous generation + ** of WherePaths as the basis for the next. Keep track of the mxChoice + ** best paths at each generation */ + iLoop = 0 + for { + if !(iLoop < nLoop) { + break + } + nTo = 0 + ii = 0 + pFrom = aFrom + for { + if !(ii < nFrom) { + break + } + pWLoop = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops + for { + if !(pWLoop != 0) { + break + } /* Mask of rev-order loops for (..) */ + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).Fprereq & ^(*TWherePath)(unsafe.Pointer(pFrom)).FmaskLoop != uint64(0) { + goto _6 + } + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf&(*TWherePath)(unsafe.Pointer(pFrom)).FmaskLoop != uint64(0) { + goto _6 + } + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).FwsFlags&uint32(WHERE_AUTO_INDEX) != uint32(0) && int32((*TWherePath)(unsafe.Pointer(pFrom)).FnRow) < int32(3) { + /* Do not use an automatic index if the this loop is expected + ** to run less than 1.25 times. It is tempting to also exclude + ** automatic index usage on an outer loop, but sometimes an automatic + ** index is useful in the outer loop of a correlated subquery. */ + goto _6 + } + /* At this point, pWLoop is a candidate to be the next loop. + ** Compute its cost */ + rUnsort = int16(int32((*TWhereLoop)(unsafe.Pointer(pWLoop)).FrRun) + int32((*TWherePath)(unsafe.Pointer(pFrom)).FnRow)) + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).FrSetup != 0 { + rUnsort = _sqlite3LogEstAdd(tls, (*TWhereLoop)(unsafe.Pointer(pWLoop)).FrSetup, rUnsort) + } + rUnsort = _sqlite3LogEstAdd(tls, rUnsort, (*TWherePath)(unsafe.Pointer(pFrom)).FrUnsort) + nOut = int16(int32((*TWherePath)(unsafe.Pointer(pFrom)).FnRow) + int32((*TWhereLoop)(unsafe.Pointer(pWLoop)).FnOut)) + maskNew = (*TWherePath)(unsafe.Pointer(pFrom)).FmaskLoop | (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf + isOrdered = (*TWherePath)(unsafe.Pointer(pFrom)).FisOrdered + if int32(isOrdered) < 0 { + **(**TBitmask)(__ccgo_up(bp)) = uint64(0) + isOrdered = _wherePathSatisfiesOrderBy(tls, pWInfo, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags, libc.Uint16FromInt32(iLoop), pWLoop, bp) + } else { + **(**TBitmask)(__ccgo_up(bp)) = (*TWherePath)(unsafe.Pointer(pFrom)).FrevLoop + } + if int32(isOrdered) >= 0 && int32(isOrdered) < nOrderBy { + if int32(**(**TLogEst)(__ccgo_up(aSortCost + uintptr(isOrdered)*2))) == 0 { + **(**TLogEst)(__ccgo_up(aSortCost + uintptr(isOrdered)*2)) = _whereSortingCost(tls, pWInfo, nRowEst, nOrderBy, int32(isOrdered)) + } + /* TUNING: Add a small extra penalty (3) to sorting as an + ** extra encouragement to the query planner to select a plan + ** where the rows emerge in the correct order without any sorting + ** required. */ + rCost = int16(int32(_sqlite3LogEstAdd(tls, rUnsort, **(**TLogEst)(__ccgo_up(aSortCost + uintptr(isOrdered)*2)))) + int32(3)) + } else { + rCost = rUnsort + rUnsort = int16(int32(rUnsort) - libc.Int32FromInt32(2)) /* TUNING: Slight bias in favor of no-sort plans */ + } + /* Check to see if pWLoop should be added to the set of + ** mxChoice best-so-far paths. + ** + ** First look for an existing path among best-so-far paths + ** that: + ** (1) covers the same set of loops, and + ** (2) has a compatible isOrdered value. + ** + ** "Compatible isOrdered value" means either + ** (A) both have isOrdered==-1, or + ** (B) both have isOrder>=0, or + ** (C) ordering does not matter because this is the last round + ** of the solver. + ** + ** The term "((pTo->isOrdered^isOrdered)&0x80)==0" is equivalent + ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))" for the range + ** of legal values for isOrdered, -1..64. + */ + jj = 0 + pTo = aTo + for { + if !(jj < nTo) { + break + } + if (*TWherePath)(unsafe.Pointer(pTo)).FmaskLoop == maskNew && ((int32((*TWherePath)(unsafe.Pointer(pTo)).FisOrdered)^int32(isOrdered))&int32(0x80) == 0 || iLoop == nLoop-int32(1)) { + break + } + goto _7 + _7: + ; + jj = jj + 1 + pTo += 32 + } + if jj >= nTo { + /* None of the existing best-so-far paths match the candidate. */ + if nTo >= mxChoice && (int32(rCost) > int32(mxCost) || int32(rCost) == int32(mxCost) && int32(rUnsort) >= int32(mxUnsort)) { + /* The current candidate is no better than any of the mxChoice + ** paths currently in the best-so-far buffer. So discard + ** this candidate as not viable. */ + goto _6 + } + /* If we reach this points it means that the new candidate path + ** needs to be added to the set of best-so-far paths. */ + if nTo < mxChoice { + /* Increase the size of the aTo set by one */ + v2 = nTo + nTo = nTo + 1 + jj = v2 + } else { + /* New path replaces the prior worst to keep count below mxChoice */ + jj = mxI + } + pTo = aTo + uintptr(jj)*32 + } else { + /* Control reaches here if best-so-far path pTo=aTo[jj] covers the + ** same set of loops and has the same isOrdered setting as the + ** candidate path. Check to see if the candidate should replace + ** pTo or if the candidate should be skipped. + ** + ** The conditional is an expanded vector comparison equivalent to: + ** (pTo->rCost,pTo->nRow,pTo->rUnsort) <= (rCost,nOut,rUnsort) + */ + if int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) < int32(rCost) || int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) == int32(rCost) && int32((*TWherePath)(unsafe.Pointer(pTo)).FnRow) < int32(nOut) || int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) == int32(rCost) && int32((*TWherePath)(unsafe.Pointer(pTo)).FnRow) == int32(nOut) && int32((*TWherePath)(unsafe.Pointer(pTo)).FrUnsort) < int32(rUnsort) || int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) == int32(rCost) && int32((*TWherePath)(unsafe.Pointer(pTo)).FnRow) == int32(nOut) && int32((*TWherePath)(unsafe.Pointer(pTo)).FrUnsort) == int32(rUnsort) && _whereLoopIsNoBetter(tls, pWLoop, **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pTo)).FaLoop + uintptr(iLoop)*8))) != 0 { + /* Discard the candidate path from further consideration */ + goto _6 + } + /* Control reaches here if the candidate path is better than the + ** pTo path. Replace pTo with the candidate. */ + } + /* pWLoop is a winner. Add it to the set of best so far */ + (*TWherePath)(unsafe.Pointer(pTo)).FmaskLoop = (*TWherePath)(unsafe.Pointer(pFrom)).FmaskLoop | (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf + (*TWherePath)(unsafe.Pointer(pTo)).FrevLoop = **(**TBitmask)(__ccgo_up(bp)) + (*TWherePath)(unsafe.Pointer(pTo)).FnRow = nOut + (*TWherePath)(unsafe.Pointer(pTo)).FrCost = rCost + (*TWherePath)(unsafe.Pointer(pTo)).FrUnsort = rUnsort + (*TWherePath)(unsafe.Pointer(pTo)).FisOrdered = isOrdered + libc.Xmemcpy(tls, (*TWherePath)(unsafe.Pointer(pTo)).FaLoop, (*TWherePath)(unsafe.Pointer(pFrom)).FaLoop, uint64(8)*libc.Uint64FromInt32(iLoop)) + **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pTo)).FaLoop + uintptr(iLoop)*8)) = pWLoop + if nTo >= mxChoice { + mxI = 0 + mxCost = (**(**TWherePath)(__ccgo_up(aTo))).FrCost + mxUnsort = (**(**TWherePath)(__ccgo_up(aTo))).FnRow + jj = int32(1) + pTo = aTo + 1*32 + for { + if !(jj < mxChoice) { + break + } + if int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) > int32(mxCost) || int32((*TWherePath)(unsafe.Pointer(pTo)).FrCost) == int32(mxCost) && int32((*TWherePath)(unsafe.Pointer(pTo)).FrUnsort) > int32(mxUnsort) { + mxCost = (*TWherePath)(unsafe.Pointer(pTo)).FrCost + mxUnsort = (*TWherePath)(unsafe.Pointer(pTo)).FrUnsort + mxI = jj + } + goto _9 + _9: + ; + jj = jj + 1 + pTo += 32 + } + } + goto _6 + _6: + ; + pWLoop = (*TWhereLoop)(unsafe.Pointer(pWLoop)).FpNextLoop + } + goto _5 + _5: + ; + ii = ii + 1 + pFrom += 32 + } + /* Swap the roles of aFrom and aTo for the next generation */ + pFrom = aTo + aTo = aFrom + aFrom = pFrom + nFrom = nTo + goto _4 + _4: + ; + iLoop = iLoop + 1 + } + if nFrom == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24017, 0) + _sqlite3DbFreeNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSpace) + return int32(SQLITE_ERROR) + } + /* Only one path is available, which is the best path */ + pFrom = aFrom + /* Load the lowest cost path into pWInfo */ + iLoop = 0 + for { + if !(iLoop < nLoop) { + break + } + pLevel = pWInfo + 856 + uintptr(iLoop)*112 + v11 = **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(iLoop)*8)) + pWLoop = v11 + (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop = v11 + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom = (*TWhereLoop)(unsafe.Pointer(pWLoop)).FiTab + (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur = (*(*TSrcItem)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80))).FiCursor + goto _10 + _10: + ; + iLoop = iLoop + 1 + } + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DISTINCTBY) == 0 && libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == WHERE_DISTINCT_NOOP && nRowEst != 0 { + rc = int32(_wherePathSatisfiesOrderBy(tls, pWInfo, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet, pFrom, uint16(WHERE_DISTINCTBY), libc.Uint16FromInt32(nLoop-int32(1)), **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-int32(1))*8)), bp+8)) + if rc == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet)).FnExpr { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_ORDERED) + } + } + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(0), 2, 0x4) + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = (*TWherePath)(unsafe.Pointer(pFrom)).FisOrdered + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_DISTINCTBY) != 0 { + if int32((*TWherePath)(unsafe.Pointer(pFrom)).FisOrdered) == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_ORDERED) + } + /* vvv--- See check-in [12ad822d9b827777] on 2023-03-16 ---vvv */ + } else { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = (*TWherePath)(unsafe.Pointer(pFrom)).FrevLoop + if int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) <= 0 { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = 0 + if nLoop > 0 { + wsFlags = (*TWhereLoop)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-int32(1))*8)))).FwsFlags + if wsFlags&uint32(WHERE_ONEROW) == uint32(0) && wsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_COLUMN_IN)) != libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_COLUMN_IN)) { + **(**TBitmask)(__ccgo_up(bp + 16)) = uint64(0) + rc1 = int32(_wherePathSatisfiesOrderBy(tls, pWInfo, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, uint16(WHERE_ORDERBY_LIMIT), libc.Uint16FromInt32(nLoop-int32(1)), **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-int32(1))*8)), bp+16)) + if rc1 == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 2, 0x4) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = **(**TBitmask)(__ccgo_up(bp + 16)) + } + } + } + } else { + if nLoop != 0 && int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == int32(1) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(libc.Int32FromInt32(WHERE_ORDERBY_MIN)|libc.Int32FromInt32(WHERE_ORDERBY_MAX)) != 0 { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 2, 0x4) + } + } + } + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_SORTBYGROUP) != 0 && int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr && nLoop > 0 { + **(**TBitmask)(__ccgo_up(bp + 24)) = uint64(0) + nOrder = int32(_wherePathSatisfiesOrderBy(tls, pWInfo, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, uint16(0), libc.Uint16FromInt32(nLoop-int32(1)), **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-int32(1))*8)), bp+24)) + if nOrder == (*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 3, 0x8) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = **(**TBitmask)(__ccgo_up(bp + 24)) + } + } + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut = (*TWherePath)(unsafe.Pointer(pFrom)).FnRow + /* Free temporary memory and return success */ + _sqlite3DbFreeNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSpace) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is called as part of generating VM programs for RANGE +// ** offset PRECEDING/FOLLOWING frame boundaries. Assuming "ASC" order for +// ** the ORDER BY term in the window, and that argument op is OP_Ge, it generates +// ** code equivalent to: +// ** +// ** if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl; +// ** +// ** The value of parameter op may also be OP_Gt or OP_Le. In these cases the +// ** operator in the above pseudo-code is replaced with ">" or "<=", respectively. +// ** +// ** If the sort-order for the ORDER BY term in the window is DESC, then the +// ** comparison is reversed. Instead of adding regVal to csr1.peerVal, it is +// ** subtracted. And the comparison operator is inverted to - ">=" becomes "<=", +// ** ">" becomes "<", and so on. So, with DESC sort order, if the argument op +// ** is OP_Ge, the generated code is equivalent to: +// ** +// ** if( csr1.peerVal - regVal <= csr2.peerVal ) goto lbl; +// ** +// ** A special type of arithmetic is used such that if csr1.peerVal is not +// ** a numeric type (real or integer), then the result of the addition +// ** or subtraction is a a copy of csr1.peerVal. +// */ +func _windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal int32, csr2 int32, lbl int32) { + var addr, addrDone, addrGe, arith, reg1, reg2, regString, v1 int32 + var pColl, pOrderBy, pParse, v, v2 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrDone, addrGe, arith, pColl, pOrderBy, pParse, reg1, reg2, regString, v, v1, v2 + pParse = (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse + v = _sqlite3GetVdbe(tls, pParse) + pOrderBy = (*TWindow)(unsafe.Pointer((*TWindowCodeArg)(unsafe.Pointer(p)).FpMWin)).FpOrderBy /* ORDER BY clause for window */ + reg1 = _sqlite3GetTempReg(tls, pParse) /* Reg. for csr1.peerVal+regVal */ + reg2 = _sqlite3GetTempReg(tls, pParse) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) /* Reg. for csr2.peerVal */ + regString = v1 /* Reg. for constant value '' */ + arith = int32(OP_Add) /* Jump destination */ + addrDone = _sqlite3VdbeMakeLabel(tls, pParse) + /* Read the peer-value from each cursor into a register */ + _windowReadPeerValues(tls, p, csr1, reg1) + _windowReadPeerValues(tls, p, csr2, reg2) + if libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_DESC) != 0 { + switch op { + case int32(OP_Ge): + op = int32(OP_Le) + case int32(OP_Gt): + op = int32(OP_Lt) + default: + op = int32(OP_Ge) + break + } + arith = int32(OP_Subtract) + } + /* If the BIGNULL flag is set for the ORDER BY, then it is required to + ** consider NULL values to be larger than all other values, instead of + ** the usual smaller. The VDBE opcodes OP_Ge and so on do not handle this + ** (and adding that capability causes a performance regression), so + ** instead if the BIGNULL flag is set then cases where either reg1 or + ** reg2 are NULL are handled separately in the following block. The code + ** generated is equivalent to: + ** + ** if( reg1 IS NULL ){ + ** if( op==OP_Ge ) goto lbl; + ** if( op==OP_Gt && reg2 IS NOT NULL ) goto lbl; + ** if( op==OP_Le && reg2 IS NULL ) goto lbl; + ** }else if( reg2 IS NULL ){ + ** if( op==OP_Le ) goto lbl; + ** } + ** + ** Additionally, if either reg1 or reg2 are NULL but the jump to lbl is + ** not taken, control jumps over the comparison operator coded below this + ** block. */ + if libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_BIGNULL) != 0 { + /* This block runs if reg1 contains a NULL. */ + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_NotNull), reg1) + switch op { + case int32(OP_Ge): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, lbl) + case int32(OP_Gt): + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), reg2, lbl) + case int32(OP_Le): + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), reg2, lbl) + default: /* no-op */ + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrDone) + /* This block runs if reg1 is not NULL, but reg2 is. */ + _sqlite3VdbeJumpHere(tls, v, addr) + if op == int32(OP_Gt) || op == int32(OP_Ge) { + v1 = addrDone + } else { + v1 = lbl + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), reg2, v1) + } + /* Register reg1 currently contains csr1.peerVal (the peer-value from csr1). + ** This block adds (or subtracts for DESC) the numeric value in regVal + ** from it. Or, if reg1 is not numeric (it is a NULL, a text value or a blob), + ** then leave reg1 as it is. In pseudo-code, this is implemented as: + ** + ** if( reg1>='' ) goto addrGe; + ** reg1 = reg1 +/- regVal + ** addrGe: + ** + ** Since all strings and blobs are greater-than-or-equal-to an empty string, + ** the add/subtract is skipped for these, as required. If reg1 is a NULL, + ** then the arithmetic is performed, but since adding or subtracting from + ** NULL is always NULL anyway, this case is handled as required too. */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, regString, 0, __ccgo_ts+1704, -int32(1)) + addrGe = _sqlite3VdbeAddOp3(tls, v, int32(OP_Ge), regString, 0, reg1) + if op == int32(OP_Ge) && arith == int32(OP_Add) || op == int32(OP_Le) && arith == int32(OP_Subtract) { + _sqlite3VdbeAddOp3(tls, v, op, reg2, lbl, reg1) + } + _sqlite3VdbeAddOp3(tls, v, arith, regVal, reg1, reg1) + _sqlite3VdbeJumpHere(tls, v, addrGe) + /* Compare registers reg2 and reg1, taking the jump if required. Note that + ** control skips over this test if the BIGNULL flag is set and either + ** reg1 or reg2 contain a NULL value. */ + _sqlite3VdbeAddOp3(tls, v, op, reg2, lbl, reg1) + pColl = _sqlite3ExprNNCollSeq(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8))).FpExpr) + _sqlite3VdbeAppendP4(tls, v, pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NULLEQ)) + _sqlite3VdbeResolveLabel(tls, v, addrDone) + _sqlite3ReleaseTempReg(tls, pParse, reg1) + _sqlite3ReleaseTempReg(tls, pParse, reg2) +} diff --git a/internal/engine/lib/sqlite_g_0000000000003a83.go b/internal/engine/lib/sqlite_g_0000000000003a83.go new file mode 100644 index 0000000..5ba78d4 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003a83.go @@ -0,0 +1,282 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && amd64) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Query the database. But instead of invoking a callback for each row, +// ** malloc() for space to hold the result and return the entire results +// ** at the conclusion of the call. +// ** +// ** The result that is written to ***pazResult is held in memory obtained +// ** from malloc(). But the caller cannot free this memory directly. +// ** Instead, the entire table should be passed to sqlite3_free_table() when +// ** the calling procedure is finished using it. +// */ +func Xsqlite3_get_table(tls *libc.TLS, db uintptr, zSql uintptr, pazResult uintptr, pnRow uintptr, pnColumn uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var azNew uintptr + var rc int32 + var _ /* res at bp+0 */ TTabResult + _, _ = azNew, rc + **(**uintptr)(__ccgo_up(pazResult)) = uintptr(0) + if pnColumn != 0 { + **(**int32)(__ccgo_up(pnColumn)) = 0 + } + if pnRow != 0 { + **(**int32)(__ccgo_up(pnRow)) = 0 + } + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + (**(**TTabResult)(__ccgo_up(bp))).FzErrMsg = uintptr(0) + (**(**TTabResult)(__ccgo_up(bp))).FnRow = uint32(0) + (**(**TTabResult)(__ccgo_up(bp))).FnColumn = uint32(0) + (**(**TTabResult)(__ccgo_up(bp))).FnData = uint32(1) + (**(**TTabResult)(__ccgo_up(bp))).FnAlloc = uint32(20) + (**(**TTabResult)(__ccgo_up(bp))).Frc = SQLITE_OK + (**(**TTabResult)(__ccgo_up(bp))).FazResult = Xsqlite3_malloc64(tls, uint64(8)*uint64((**(**TTabResult)(__ccgo_up(bp))).FnAlloc)) + if (**(**TTabResult)(__ccgo_up(bp))).FazResult == uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = int32(SQLITE_NOMEM) + return int32(SQLITE_NOMEM) + } + **(**uintptr)(__ccgo_up((**(**TTabResult)(__ccgo_up(bp))).FazResult)) = uintptr(0) + rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_sqlite3_get_table_cb), bp, pzErrMsg) + **(**uintptr)(__ccgo_up((**(**TTabResult)(__ccgo_up(bp))).FazResult)) = uintptr(libc.Int64FromUint32((**(**TTabResult)(__ccgo_up(bp))).FnData)) + if rc&int32(0xff) == int32(SQLITE_ABORT) { + Xsqlite3_free_table(tls, (**(**TTabResult)(__ccgo_up(bp))).FazResult+1*8) + if (**(**TTabResult)(__ccgo_up(bp))).FzErrMsg != 0 { + if pzErrMsg != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(pzErrMsg))) + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+48, (**(**TTabResult)(__ccgo_up(bp))).FzErrMsg)) + } + Xsqlite3_free(tls, (**(**TTabResult)(__ccgo_up(bp))).FzErrMsg) + } + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = (**(**TTabResult)(__ccgo_up(bp))).Frc /* Assume 32-bit assignment is atomic */ + return (**(**TTabResult)(__ccgo_up(bp))).Frc + } + Xsqlite3_free(tls, (**(**TTabResult)(__ccgo_up(bp))).FzErrMsg) + if rc != SQLITE_OK { + Xsqlite3_free_table(tls, (**(**TTabResult)(__ccgo_up(bp))).FazResult+1*8) + return rc + } + if (**(**TTabResult)(__ccgo_up(bp))).FnAlloc > (**(**TTabResult)(__ccgo_up(bp))).FnData { + azNew = _sqlite3Realloc(tls, (**(**TTabResult)(__ccgo_up(bp))).FazResult, uint64(8)*uint64((**(**TTabResult)(__ccgo_up(bp))).FnData)) + if azNew == uintptr(0) { + Xsqlite3_free_table(tls, (**(**TTabResult)(__ccgo_up(bp))).FazResult+1*8) + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = int32(SQLITE_NOMEM) + return int32(SQLITE_NOMEM) + } + (**(**TTabResult)(__ccgo_up(bp))).FazResult = azNew + } + **(**uintptr)(__ccgo_up(pazResult)) = (**(**TTabResult)(__ccgo_up(bp))).FazResult + 1*8 + if pnColumn != 0 { + **(**int32)(__ccgo_up(pnColumn)) = libc.Int32FromUint32((**(**TTabResult)(__ccgo_up(bp))).FnColumn) + } + if pnRow != 0 { + **(**int32)(__ccgo_up(pnRow)) = libc.Int32FromUint32((**(**TTabResult)(__ccgo_up(bp))).FnRow) + } + return rc +} + +// C documentation +// +// /* +// ** Implementation of the sqlite_log() function. This is a wrapper around +// ** sqlite3_log(). The return value is NULL. The function exists purely for +// ** its side-effects. +// */ +func _errlogFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + _ = argc + _ = context + Xsqlite3_log(tls, Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv))), __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))))) +} + +// C documentation +// +// /* +// ** Advance the cursor to the next row in the table that matches the +// ** search criteria. +// ** +// ** Return SQLITE_OK if nothing goes wrong. SQLITE_OK is returned +// ** even if we reach end-of-file. The fts5EofMethod() will be called +// ** subsequently to determine whether or not an EOF was hit. +// */ +func _fts5NextMethod(tls *libc.TLS, pCursor uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pConfig, pCsr uintptr + var rc, v1 int32 + var _ /* bSkip at bp+0 */ int32 + _, _, _, _ = pConfig, pCsr, rc, v1 + pCsr = pCursor + /* If this cursor uses FTS5_PLAN_MATCH and this is a tokendata=1 table, + ** clear any token mappings accumulated at the fts5_index.c level. In + ** other cases, specifically FTS5_PLAN_SOURCE and FTS5_PLAN_SORTED_MATCH, + ** we need to retain the mappings for the entire query. */ + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan == int32(FTS5_PLAN_MATCH) && (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FpConfig)).FbTokendata != 0 { + _sqlite3Fts5ExprClearTokens(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + } + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan < int32(3) { + **(**int32)(__ccgo_up(bp)) = 0 + v1 = _fts5CursorReseek(tls, pCsr, bp) + rc = v1 + if v1 != 0 || **(**int32)(__ccgo_up(bp)) != 0 { + return rc + } + rc = _sqlite3Fts5ExprNext(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid) + **(**int32)(__ccgo_up(pCsr + 80)) |= _sqlite3Fts5ExprEof(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + _fts5CsrNewrow(tls, pCsr) + } else { + switch (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan { + case int32(FTS5_PLAN_SPECIAL): + **(**int32)(__ccgo_up(pCsr + 80)) |= int32(FTS5CSR_EOF) + rc = SQLITE_OK + case int32(FTS5_PLAN_SORTED_MATCH): + rc = _fts5SorterNext(tls, pCsr) + default: + pConfig = (*TFts5Table)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FpConfig + (*TFts5Config)(unsafe.Pointer(pConfig)).FbLock = (*TFts5Config)(unsafe.Pointer(pConfig)).FbLock + 1 + rc = Xsqlite3_step(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + (*TFts5Config)(unsafe.Pointer(pConfig)).FbLock = (*TFts5Config)(unsafe.Pointer(pConfig)).FbLock - 1 + if rc != int32(SQLITE_ROW) { + **(**int32)(__ccgo_up(pCsr + 80)) |= int32(FTS5CSR_EOF) + rc = Xsqlite3_reset(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + if rc != SQLITE_OK { + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb))) + } + } else { + rc = SQLITE_OK + **(**int32)(__ccgo_up(pCsr + 80)) |= int32(FTS5CSR_REQUIRE_DOCSIZE) + } + break + } + } + return rc +} + +// C documentation +// +// /* +// ** Check to see if virtual table module pMod can be have an eponymous +// ** virtual table instance. If it can, create one if one does not already +// ** exist. Return non-zero if either the eponymous virtual table instance +// ** exists when this routine returns or if an attempt to create it failed +// ** and an error message was left in pParse. +// ** +// ** An eponymous virtual table instance is one that is named after its +// ** module, and more importantly, does not require a CREATE VIRTUAL TABLE +// ** statement in order to come into existence. Eponymous virtual table +// ** instances always exist. They cannot be DROP-ed. +// ** +// ** Any virtual table module for which xConnect and xCreate are the same +// ** method can have an eponymous virtual table instance. +// */ +func _sqlite3VtabEponymousTableInit(tls *libc.TLS, pParse uintptr, pMod uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pModule, pTab uintptr + var rc int32 + var _ /* zErr at bp+0 */ uintptr + _, _, _, _ = db, pModule, pTab, rc + pModule = (*TModule)(unsafe.Pointer(pMod)).FpModule + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TModule)(unsafe.Pointer(pMod)).FpEpoTab != 0 { + return int32(1) + } + if (*Tsqlite3_module)(unsafe.Pointer(pModule)).FxCreate != uintptr(0) && (*Tsqlite3_module)(unsafe.Pointer(pModule)).FxCreate != (*Tsqlite3_module)(unsafe.Pointer(pModule)).FxConnect { + return 0 + } + pTab = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTab == uintptr(0) { + return 0 + } + (*TTable)(unsafe.Pointer(pTab)).FzName = _sqlite3DbStrDup(tls, db, (*TModule)(unsafe.Pointer(pMod)).FzName) + if (*TTable)(unsafe.Pointer(pTab)).FzName == uintptr(0) { + _sqlite3DbFree(tls, db, pTab) + return 0 + } + (*TModule)(unsafe.Pointer(pMod)).FpEpoTab = pTab + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pTab)).FeTabType = uint8(TABTYP_VTAB) + (*TTable)(unsafe.Pointer(pTab)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(-int32(1)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_Eponymous) + _addModuleArgument(tls, pParse, pTab, _sqlite3DbStrDup(tls, db, (*TTable)(unsafe.Pointer(pTab)).FzName)) + _addModuleArgument(tls, pParse, pTab, uintptr(0)) + _addModuleArgument(tls, pParse, pTab, _sqlite3DbStrDup(tls, db, (*TTable)(unsafe.Pointer(pTab)).FzName)) + (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock + 1 + rc = _vtabCallConstructor(tls, db, pTab, pMod, (*Tsqlite3_module)(unsafe.Pointer(pModule)).FxConnect, bp) + (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock - 1 + if rc != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3944, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp)))) + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + _sqlite3VtabEponymousTableClear(tls, db, pMod) + } + return int32(1) +} + +// C documentation +// +// /* +// ** The table object reference passed as the second argument to this function +// ** must represent a virtual table. This function invokes the xBestIndex() +// ** method of the virtual table with the sqlite3_index_info object that +// ** comes in as the 3rd argument to this function. +// ** +// ** If an error occurs, pParse is populated with an error message and an +// ** appropriate error code is returned. A return of SQLITE_CONSTRAINT from +// ** xBestIndex is not considered an error. SQLITE_CONSTRAINT indicates that +// ** the current configuration of "unusable" flags in sqlite3_index_info can +// ** not result in a valid plan. +// ** +// ** Whether or not an error is returned, it is the responsibility of the +// ** caller to eventually free p->idxStr if p->needToFreeIdxStr indicates +// ** that this is required. +// */ +func _vtabBestIndex(tls *libc.TLS, pParse uintptr, pTab uintptr, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pVtab uintptr + var rc int32 + _, _ = pVtab, rc + pVtab = (*TVTable)(unsafe.Pointer(_sqlite3GetVTable(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pTab))).FpVtab + (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FnSchemaLock + 1 + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule)).FxBestIndex})))(tls, pVtab, p) + (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FnSchemaLock - 1 + if rc != SQLITE_OK && rc != int32(SQLITE_CONSTRAINT) { + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb) + } else { + if !((*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3944, libc.VaList(bp+8, _sqlite3ErrStr(tls, rc))) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3944, libc.VaList(bp+8, (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg)) + } + } + } + if (*TVTable)(unsafe.Pointer((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp)).FbAllSchemas != 0 { + _sqlite3VtabUsesAllSchemas(tls, pParse) + } + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = uintptr(0) + return rc +} diff --git a/internal/engine/lib/sqlite_g_0000000000003ac0.go b/internal/engine/lib/sqlite_g_0000000000003ac0.go new file mode 100644 index 0000000..b278e9f --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003ac0.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +const __PIE__ = 2 + +const __pie__ = 2 diff --git a/internal/engine/lib/sqlite_g_0000000000003ac3.go b/internal/engine/lib/sqlite_g_0000000000003ac3.go new file mode 100644 index 0000000..6c1a21e --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003ac3.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +const __PIC__ = 2 + +const __pic__ = 2 diff --git a/internal/engine/lib/sqlite_g_0000000000003b00.go b/internal/engine/lib/sqlite_g_0000000000003b00.go new file mode 100644 index 0000000..f13be00 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003b00.go @@ -0,0 +1,885 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Return TRUE if the given SQL string ends in a semicolon. +// ** +// ** Special handling is require for CREATE TRIGGER statements. +// ** Whenever the CREATE TRIGGER keywords are seen, the statement +// ** must end with ";END;". +// ** +// ** This implementation uses a state machine with 8 states: +// ** +// ** (0) INVALID We have not yet seen a non-whitespace character. +// ** +// ** (1) START At the beginning or end of an SQL statement. This routine +// ** returns 1 if it ends in the START state and 0 if it ends +// ** in any other state. +// ** +// ** (2) NORMAL We are in the middle of statement which ends with a single +// ** semicolon. +// ** +// ** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of +// ** a statement. +// ** +// ** (4) CREATE The keyword CREATE has been seen at the beginning of a +// ** statement, possibly preceded by EXPLAIN and/or followed by +// ** TEMP or TEMPORARY +// ** +// ** (5) TRIGGER We are in the middle of a trigger definition that must be +// ** ended by a semicolon, the keyword END, and another semicolon. +// ** +// ** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at +// ** the end of a trigger definition. +// ** +// ** (7) END We've seen the ";END" of the ";END;" that occurs at the end +// ** of a trigger definition. +// ** +// ** Transitions between states above are determined by tokens extracted +// ** from the input. The following tokens are significant: +// ** +// ** (0) tkSEMI A semicolon. +// ** (1) tkWS Whitespace. +// ** (2) tkOTHER Any other SQL token. +// ** (3) tkEXPLAIN The "explain" keyword. +// ** (4) tkCREATE The "create" keyword. +// ** (5) tkTEMP The "temp" or "temporary" keyword. +// ** (6) tkTRIGGER The "trigger" keyword. +// ** (7) tkEND The "end" keyword. +// ** +// ** Whitespace never causes a state transition and is always ignored. +// ** This means that a SQL string of all whitespace is invalid. +// ** +// ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed +// ** to recognize the end of a trigger can be omitted. All we have to do +// ** is look for a semicolon that is not part of an string or comment. +// */ +func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) (r int32) { + var c, nId int32 + var state, token Tu8 + _, _, _, _ = c, nId, state, token + state = uint8(0) /* Value of the next token */ + for **(**uint8)(__ccgo_up(zSql)) != 0 { + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) { + case int32(';'): /* A semicolon */ + token = uint8(tkSEMI) + case int32(' '): + fallthrough + case int32('\r'): + fallthrough + case int32('\t'): + fallthrough + case int32('\n'): + fallthrough + case int32('\f'): /* White space is ignored */ + token = uint8(tkWS) + case int32('/'): /* C-style comments */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + 1))) != int32('*') { + token = uint8(tkOTHER) + break + } + zSql = zSql + uintptr(2) + for **(**uint8)(__ccgo_up(zSql)) != 0 && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) != int32('*') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + 1))) != int32('/')) { + zSql = zSql + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) == 0 { + return 0 + } + zSql = zSql + 1 + token = uint8(tkWS) + case int32('-'): /* SQL-style comments from "--" to end of line */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + 1))) != int32('-') { + token = uint8(tkOTHER) + break + } + for **(**uint8)(__ccgo_up(zSql)) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) != int32('\n') { + zSql = zSql + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) == 0 { + return libc.BoolInt32(libc.Int32FromUint8(state) == int32(1)) + } + token = uint8(tkWS) + case int32('['): /* Microsoft-style identifiers in [...] */ + zSql = zSql + 1 + for **(**uint8)(__ccgo_up(zSql)) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) != int32(']') { + zSql = zSql + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) == 0 { + return 0 + } + token = uint8(tkOTHER) + case int32('`'): /* Grave-accent quoted symbols used by MySQL */ + fallthrough + case int32('"'): /* single- and double-quoted strings */ + fallthrough + case int32('\''): + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) + zSql = zSql + 1 + for **(**uint8)(__ccgo_up(zSql)) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) != c { + zSql = zSql + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) == 0 { + return 0 + } + token = uint8(tkOTHER) + default: + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zSql)))])&int32(0x46) != 0 { + nId = int32(1) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zSql + uintptr(nId))))])&int32(0x46) != 0) { + break + } + goto _1 + _1: + ; + nId = nId + 1 + } + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql))) { + case int32('c'): + fallthrough + case int32('C'): + if nId == int32(6) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25188, int32(6)) == 0 { + token = uint8(tkCREATE) + } else { + token = uint8(tkOTHER) + } + case int32('t'): + fallthrough + case int32('T'): + if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+21842, int32(7)) == 0 { + token = uint8(tkTRIGGER) + } else { + if nId == int32(4) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25195, int32(4)) == 0 { + token = uint8(tkTEMP) + } else { + if nId == int32(9) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25200, int32(9)) == 0 { + token = uint8(tkTEMP) + } else { + token = uint8(tkOTHER) + } + } + } + case int32('e'): + fallthrough + case int32('E'): + if nId == int32(3) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25210, int32(3)) == 0 { + token = uint8(tkEND) + } else { + if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25214, int32(7)) == 0 { + token = uint8(tkEXPLAIN) + } else { + token = uint8(tkOTHER) + } + } + default: + token = uint8(tkOTHER) + break + } + zSql = zSql + uintptr(nId-int32(1)) + } else { + /* Operators and special symbols */ + token = uint8(tkOTHER) + } + break + } + state = **(**Tu8)(__ccgo_up(uintptr(unsafe.Pointer(&_trans)) + uintptr(state)*8 + uintptr(token))) + zSql = zSql + 1 + } + return libc.BoolInt32(libc.Int32FromUint8(state) == int32(1)) +} + +// C documentation +// +// /* +// ** Extra floating-point literals to allow in JSON. +// */ +var _aNanInfName = [5]TNanInfName{ + 0: { + Fc1: uint8('i'), + Fc2: uint8('I'), + Fn: uint8(3), + FeType: uint8(JSONB_FLOAT), + FnRepl: uint8(7), + FzMatch: __ccgo_ts + 26408, + FzRepl: __ccgo_ts + 26412, + }, + 1: { + Fc1: uint8('i'), + Fc2: uint8('I'), + Fn: uint8(8), + FeType: uint8(JSONB_FLOAT), + FnRepl: uint8(7), + FzMatch: __ccgo_ts + 26420, + FzRepl: __ccgo_ts + 26412, + }, + 2: { + Fc1: uint8('n'), + Fc2: uint8('N'), + Fn: uint8(3), + FnRepl: uint8(4), + FzMatch: __ccgo_ts + 1695, + FzRepl: __ccgo_ts + 1690, + }, + 3: { + Fc1: uint8('q'), + Fc2: uint8('Q'), + Fn: uint8(4), + FnRepl: uint8(4), + FzMatch: __ccgo_ts + 26429, + FzRepl: __ccgo_ts + 1690, + }, + 4: { + Fc1: uint8('s'), + Fc2: uint8('S'), + Fn: uint8(4), + FnRepl: uint8(4), + FzMatch: __ccgo_ts + 26434, + FzRepl: __ccgo_ts + 1690, + }, +} + +// C documentation +// +// /* +// ** Compare the 19-character string zNum against the text representation +// ** value 2^63: 9223372036854775808. Return negative, zero, or positive +// ** if zNum is less than, equal to, or greater than the string. +// ** Note that zNum must contain exactly 19 characters. +// ** +// ** Unlike memcmp() this routine is guaranteed to return the difference +// ** in the values of the last digit if the only difference is in the +// ** last digit. So, for example, +// ** +// ** compare2pow63("9223372036854775800", 1) +// ** +// ** will return -8. +// */ +func _compare2pow63(tls *libc.TLS, zNum uintptr, incr int32) (r int32) { + var c, i int32 + var pow63 uintptr + _, _, _ = c, i, pow63 + c = 0 + /* 012345678901234567 */ + pow63 = __ccgo_ts + 1815 + i = 0 + for { + if !(c == 0 && i < int32(18)) { + break + } + c = (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zNum + uintptr(i*incr)))) - libc.Int32FromUint8(**(**uint8)(__ccgo_up(pow63 + uintptr(i))))) * int32(10) + goto _1 + _1: + ; + i = i + 1 + } + if c == 0 { + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(zNum + uintptr(int32(18)*incr)))) - int32('8') + } + return c +} + +// C documentation +// +// /* +// ** Process a "special" query. A special query is identified as one with a +// ** MATCH expression that begins with a '*' character. The remainder of +// ** the text passed to the MATCH operator are used as the special query +// ** parameters. +// */ +func _fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var n, rc int32 + var z uintptr + _, _, _ = n, rc, z + rc = SQLITE_OK /* Return code */ + z = zQuery /* Number of bytes in text at z */ + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + n = 0 + for { + if !(**(**uint8)(__ccgo_up(z + uintptr(n))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) != int32(' ')) { + break + } + goto _1 + _1: + ; + n = n + 1 + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SPECIAL) + if n == int32(5) && 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+39750, z, n) { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = int64(_sqlite3Fts5IndexReads(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)) + } else { + if n == int32(2) && 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+5648, z, n) { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId + } else { + /* An unrecognized directive. Return an error message. */ + (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+39756, libc.VaList(bp+8, n, z)) + rc = int32(SQLITE_ERROR) + } + } + return rc +} + +// C documentation +// +// /* +// ** Interpret the given string as a temp db location. Return 1 for file +// ** backed temporary databases, 2 for the Red-Black tree in memory database +// ** and 0 to use the compile-time default. +// */ +func _getTempStore(tls *libc.TLS, z uintptr) (r int32) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) <= int32('2') { + return libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) - int32('0') + } else { + if _sqlite3StrICmp(tls, z, __ccgo_ts+17992) == 0 { + return int32(1) + } else { + if _sqlite3StrICmp(tls, z, __ccgo_ts+19033) == 0 { + return int32(2) + } else { + return 0 + } + } + } + return r +} + +// C documentation +// +// /* +// ** Parse a complete JSON string. Return 0 on success or non-zero if there +// ** are any errors. If an error occurs, free all memory held by pParse, +// ** but not pParse itself. +// ** +// ** pParse must be initialized to an empty parse object prior to calling +// ** this routine. +// */ +func _jsonConvertTextToBlob(tls *libc.TLS, pParse uintptr, pCtx uintptr) (r int32) { + var i int32 + var zJson uintptr + _, _ = i, zJson + zJson = (*TJsonParse)(unsafe.Pointer(pParse)).FzJson + i = _jsonTranslateTextToBlob(tls, pParse, uint32(0)) + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + i = -int32(1) + } + if i > 0 { + for _jsonIsSpace[uint8(**(**uint8)(__ccgo_up(zJson + uintptr(i))))] != 0 { + i = i + 1 + } + if **(**uint8)(__ccgo_up(zJson + uintptr(i))) != 0 { + i = i + _json5Whitespace(tls, zJson+uintptr(i)) + if **(**uint8)(__ccgo_up(zJson + uintptr(i))) != 0 { + if pCtx != 0 { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26393, -int32(1)) + } + _jsonParseReset(tls, pParse) + return int32(1) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + } + if i <= 0 { + if pCtx != uintptr(0) { + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, pCtx) + } else { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26393, -int32(1)) + } + } + _jsonParseReset(tls, pParse) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF. +// ** The HH, MM, and SS must each be exactly 2 digits. The +// ** fractional seconds FFFF can be one or more digits. +// ** +// ** Return 1 if there is a parsing error and 0 on success. +// */ +func _parseHhMmSs(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var ms, rScale float64 + var _ /* h at bp+0 */ int32 + var _ /* m at bp+4 */ int32 + var _ /* s at bp+8 */ int32 + _, _ = ms, rScale + ms = float64(0) + if _getDigits(tls, zDate, __ccgo_ts+1204, libc.VaList(bp+24, bp, bp+4)) != int32(2) { + return int32(1) + } + zDate = zDate + uintptr(5) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDate))) == int32(':') { + zDate = zDate + 1 + if _getDigits(tls, zDate, __ccgo_ts+1212, libc.VaList(bp+24, bp+8)) != int32(1) { + return int32(1) + } + zDate = zDate + uintptr(2) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDate))) == int32('.') && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zDate + 1)))])&int32(0x04) != 0 { + rScale = float64(1) + zDate = zDate + 1 + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zDate)))])&int32(0x04) != 0 { + ms = float64(ms*float64(10)) + float64(**(**uint8)(__ccgo_up(zDate))) - libc.Float64FromUint8('0') + rScale = rScale * float64(10) + zDate = zDate + 1 + } + ms = ms / rScale + /* Truncate to avoid problems with sub-milliseconds + ** rounding. https://sqlite.org/forum/forumpost/766a2c9231 */ + if ms > float64(0.999) { + ms = float64(0.999) + } + } + } else { + **(**int32)(__ccgo_up(bp + 8)) = 0 + } + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1) + (*TDateTime)(unsafe.Pointer(p)).Fh = **(**int32)(__ccgo_up(bp)) + (*TDateTime)(unsafe.Pointer(p)).Fm = **(**int32)(__ccgo_up(bp + 4)) + (*TDateTime)(unsafe.Pointer(p)).Fs = float64(**(**int32)(__ccgo_up(bp + 8))) + ms + if _parseTimezone(tls, zDate, p) != 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Parse a timezone extension on the end of a date-time. +// ** The extension is of the form: +// ** +// ** (+/-)HH:MM +// ** +// ** Or the "zulu" notation: +// ** +// ** Z +// ** +// ** If the parse is successful, write the number of minutes +// ** of change in p->tz and return 0. If a parser error occurs, +// ** return non-zero. +// ** +// ** A missing specifier is not considered an error. +// */ +func _parseTimezone(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, sgn int32 + var _ /* nHr at bp+0 */ int32 + var _ /* nMn at bp+4 */ int32 + _, _ = c, sgn + sgn = 0 + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zDate)))])&int32(0x01) != 0 { + zDate = zDate + 1 + } + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDate))) + if c == int32('-') { + sgn = -int32(1) + } else { + if c == int32('+') { + sgn = +libc.Int32FromInt32(1) + } else { + if c == int32('Z') || c == int32('z') { + zDate = zDate + 1 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + goto zulu_time + } else { + return libc.BoolInt32(c != 0) + } + } + } + zDate = zDate + 1 + if _getDigits(tls, zDate, __ccgo_ts+1196, libc.VaList(bp+16, bp, bp+4)) != int32(2) { + return int32(1) + } + zDate = zDate + uintptr(5) + (*TDateTime)(unsafe.Pointer(p)).Ftz = sgn * (**(**int32)(__ccgo_up(bp + 4)) + **(**int32)(__ccgo_up(bp))*int32(60)) + if (*TDateTime)(unsafe.Pointer(p)).Ftz == 0 { /* Forum post 2025-09-17T10:12:14z */ + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + } + goto zulu_time +zulu_time: + ; + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zDate)))])&int32(0x01) != 0 { + zDate = zDate + 1 + } + return libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDate))) != 0) +} + +// C documentation +// +// /* +// ** Parse dates of the form +// ** +// ** YYYY-MM-DD HH:MM:SS.FFF +// ** YYYY-MM-DD HH:MM:SS +// ** YYYY-MM-DD HH:MM +// ** YYYY-MM-DD +// ** +// ** Write the result into the DateTime structure and return 0 +// ** on success and 1 if the input string is not a well-formed +// ** date. +// */ +func _parseYyyyMmDd(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var neg, v1 int32 + var _ /* D at bp+8 */ int32 + var _ /* M at bp+4 */ int32 + var _ /* Y at bp+0 */ int32 + _, _ = neg, v1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDate))) == int32('-') { + zDate = zDate + 1 + neg = int32(1) + } else { + neg = 0 + } + if _getDigits(tls, zDate, __ccgo_ts+1216, libc.VaList(bp+24, bp, bp+4, bp+8)) != int32(3) { + return int32(1) + } + zDate = zDate + uintptr(10) + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zDate)))])&int32(0x01) != 0 || int32('T') == libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zDate))) { + zDate = zDate + 1 + } + if _parseHhMmSs(tls, zDate, p) == 0 { + /* We got the time */ + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDate))) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(0) + } else { + return int32(1) + } + } + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(1) + if neg != 0 { + v1 = -**(**int32)(__ccgo_up(bp)) + } else { + v1 = **(**int32)(__ccgo_up(bp)) + } + (*TDateTime)(unsafe.Pointer(p)).FY = v1 + (*TDateTime)(unsafe.Pointer(p)).FM = **(**int32)(__ccgo_up(bp + 4)) + (*TDateTime)(unsafe.Pointer(p)).FD = **(**int32)(__ccgo_up(bp + 8)) + _computeFloor(tls, p) + if (*TDateTime)(unsafe.Pointer(p)).Ftz != 0 { + _computeJD(tls, p) + } + return 0 +} + +/* Forward declaration */ + +// C documentation +// +// /* +// ** Allocate a private rbu VFS for the rbu handle passed as the only +// ** argument. This VFS will be used unless the call to sqlite3rbu_open() +// ** specified a URI with a vfs=? option in place of a target database +// ** file name. +// */ +func _rbuCreateVfs(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var pVfs uintptr + var _ /* rnd at bp+0 */ int32 + var _ /* zRnd at bp+4 */ [64]uint8 + _ = pVfs + Xsqlite3_randomness(tls, int32(4), bp) + Xsqlite3_snprintf(tls, int32(64), bp+4, __ccgo_ts+34261, libc.VaList(bp+80, **(**int32)(__ccgo_up(bp)))) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3rbu_create_vfs(tls, bp+4, uintptr(0)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pVfs = Xsqlite3_vfs_find(tls, bp+4) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FzName + (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRbu = p + } +} + +// C documentation +// +// /* +// ** An error occurred while parsing or otherwise processing a database +// ** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an +// ** ALTER TABLE RENAME COLUMN program. The error message emitted by the +// ** sub-routine is currently stored in pParse->zErrMsg. This function +// ** adds context to the error message and then stores it in pCtx. +// */ +func _renameColumnParseError(tls *libc.TLS, pCtx uintptr, zWhen uintptr, pType uintptr, pObject uintptr, pParse uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var zErr, zN, zT, v1 uintptr + _, _, _, _ = zErr, zN, zT, v1 + zT = Xsqlite3_value_text(tls, pType) + zN = Xsqlite3_value_text(tls, pObject) + if **(**uint8)(__ccgo_up(zWhen)) != 0 { + v1 = __ccgo_ts + 11541 + } else { + v1 = __ccgo_ts + 1704 + } + zErr = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+11543, libc.VaList(bp+8, zT, zN, v1, zWhen, (*TParse)(unsafe.Pointer(pParse)).FzErrMsg)) + Xsqlite3_result_error(tls, pCtx, zErr, -int32(1)) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zErr) +} + +// C documentation +// +// /* IMP: R-25361-16150 This function is omitted from SQLite by default. It +// ** is only available if the SQLITE_SOUNDEX compile-time option is used +// ** when SQLite is built. +// */ +// /* +// ** Compute the soundex encoding of a word. +// ** +// ** IMP: R-59782-00072 The soundex(X) function returns a string that is the +// ** soundex encoding of the string X. +// */ +func _soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var code, i, j, v3 int32 + var prevcode Tu8 + var zIn uintptr + var _ /* zResult at bp+0 */ [8]uint8 + _, _, _, _, _, _ = code, i, j, prevcode, zIn, v3 + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn == uintptr(0) { + zIn = __ccgo_ts + 1704 + } + i = 0 + for { + if !(**(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(zIn + uintptr(i)))])&libc.Int32FromInt32(0x02) != 0)) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if **(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0 { + prevcode = _iCode[libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i))))&int32(0x7f)] + (**(**[8]uint8)(__ccgo_up(bp)))[0] = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i)))) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(zIn + uintptr(i)))]) & libc.Int32FromInt32(0x20))) + j = int32(1) + for { + if !(j < int32(4) && **(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0) { + break + } + code = libc.Int32FromUint8(_iCode[libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i))))&int32(0x7f)]) + if code > 0 { + if code != libc.Int32FromUint8(prevcode) { + prevcode = libc.Uint8FromInt32(code) + v3 = j + j = j + 1 + (**(**[8]uint8)(__ccgo_up(bp)))[v3] = libc.Uint8FromInt32(code + int32('0')) + } + } else { + prevcode = uint8(0) + } + goto _2 + _2: + ; + i = i + 1 + } + for j < int32(4) { + v3 = j + j = j + 1 + (**(**[8]uint8)(__ccgo_up(bp)))[v3] = uint8('0') + } + (**(**[8]uint8)(__ccgo_up(bp)))[j] = uint8(0) + Xsqlite3_result_text(tls, context, bp, int32(4), uintptr(-libc.Int32FromInt32(1))) + } else { + /* IMP: R-64894-50321 The string "?000" is returned if the argument + ** is NULL or contains no ASCII alphabetic characters. */ + Xsqlite3_result_text(tls, context, __ccgo_ts+16594, int32(4), libc.UintptrFromInt32(0)) + } +} + +func _sqlite3Fts5ParseSetDistance(tls *libc.TLS, pParse uintptr, pNear uintptr, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c uint8 + var i, nNear int32 + _, _, _ = c, i, nNear + if pNear != 0 { + nNear = 0 + if (*TFts5Token)(unsafe.Pointer(p)).Fn != 0 { + i = 0 + for { + if !(i < (*TFts5Token)(unsafe.Pointer(p)).Fn) { + break + } + c = **(**uint8)(__ccgo_up((*TFts5Token)(unsafe.Pointer(p)).Fp + uintptr(i))) + if libc.Int32FromUint8(c) < int32('0') || libc.Int32FromUint8(c) > int32('9') { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38541, libc.VaList(bp+8, (*TFts5Token)(unsafe.Pointer(p)).Fn, (*TFts5Token)(unsafe.Pointer(p)).Fp)) + return + } + if nNear < int32(214748363) { + nNear = nNear*int32(10) + (libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TFts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))) - int32('0')) + } + /* ^^^^^^^^^^^^^^^--- Prevent integer overflow */ + goto _1 + _1: + ; + i = i + 1 + } + } else { + nNear = int32(FTS5_DEFAULT_NEARDIST) + } + (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnNear = nNear + } +} + +// C documentation +// +// /* +// ** Append to pStr text that is the SQL literal representation of the +// ** value contained in pValue. +// */ +func _sqlite3QuoteValue(tls *libc.TLS, pStr uintptr, pValue uintptr, bEscape int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var nBlob Ti64 + var zArg, zBlob, zText, v2 uintptr + _, _, _, _, _, _ = i, nBlob, zArg, zBlob, zText, v2 + /* As currently implemented, the string must be initially empty. + ** we might relax this requirement in the future, but that will + ** require enhancements to the implementation. */ + switch Xsqlite3_value_type(tls, pValue) { + case int32(SQLITE_FLOAT): + /* ,--- Show infinity as 9.0e+999 + ** | + ** | ,--- 17 precision guarantees round-trip + ** v v */ + Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+16559, libc.VaList(bp+8, Xsqlite3_value_double(tls, pValue))) + case int32(SQLITE_INTEGER): + Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+1465, libc.VaList(bp+8, Xsqlite3_value_int64(tls, pValue))) + case int32(SQLITE_BLOB): + zBlob = Xsqlite3_value_blob(tls, pValue) + nBlob = int64(Xsqlite3_value_bytes(tls, pValue)) + /* No encoding change */ + _sqlite3StrAccumEnlarge(tls, pStr, nBlob*int64(2)+int64(4)) + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(pStr)).FaccError) == 0 { + zText = (*TStrAccum)(unsafe.Pointer(pStr)).FzText + i = 0 + for { + if !(int64(i) < nBlob) { + break + } + **(**uint8)(__ccgo_up(zText + uintptr(i*int32(2)+int32(2)))) = _hexdigits[libc.Int32FromUint8(**(**uint8)(__ccgo_up(zBlob + uintptr(i))))>>int32(4)&int32(0x0F)] + **(**uint8)(__ccgo_up(zText + uintptr(i*int32(2)+int32(3)))) = _hexdigits[libc.Int32FromUint8(**(**uint8)(__ccgo_up(zBlob + uintptr(i))))&int32(0x0F)] + goto _1 + _1: + ; + i = i + 1 + } + **(**uint8)(__ccgo_up(zText + uintptr(nBlob*int64(2)+int64(2)))) = uint8('\'') + **(**uint8)(__ccgo_up(zText + uintptr(nBlob*int64(2)+int64(3)))) = uint8('\000') + **(**uint8)(__ccgo_up(zText)) = uint8('X') + **(**uint8)(__ccgo_up(zText + 1)) = uint8('\'') + (*TStrAccum)(unsafe.Pointer(pStr)).FnChar = libc.Uint32FromInt64(nBlob*int64(2) + int64(3)) + } + case int32(SQLITE_TEXT): + zArg = Xsqlite3_value_text(tls, pValue) + if bEscape != 0 { + v2 = __ccgo_ts + 16567 + } else { + v2 = __ccgo_ts + 11925 + } + Xsqlite3_str_appendf(tls, pStr, v2, libc.VaList(bp+8, zArg)) + default: + Xsqlite3_str_append(tls, pStr, __ccgo_ts+1705, int32(4)) + break + } +} + +// C documentation +// +// /* +// ** Create a temporary file name in zBuf. zBuf must be allocated +// ** by the calling process and must be big enough to hold at least +// ** pVfs->mxPathname bytes. +// */ +func _unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iLimit, rc, v1 int32 + var zDir uintptr + var v2 bool + var _ /* r at bp+0 */ Tu64 + _, _, _, _, _ = iLimit, rc, zDir, v1, v2 + iLimit = 0 + rc = SQLITE_OK + /* It's odd to simulate an io-error here, but really this is just + ** using the io-error infrastructure to test that SQLite handles this + ** function failing. + */ + **(**uint8)(__ccgo_up(zBuf)) = uint8(0) + Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + zDir = _unixTempFileDir(tls) + if zDir == uintptr(0) { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(25)< int32(10) { + rc = int32(SQLITE_ERROR) + break + } + } + } + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + return rc +} + +// C documentation +// +// /* +// ** The following code executes when a syntax error first occurs. +// */ +func _yy_syntax_error(tls *libc.TLS, yypParser uintptr, yymajor int32, _yyminor TToken) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*TToken)(unsafe.Pointer(bp)) = _yyminor + var pParse uintptr + _ = pParse + pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse + /************ Begin %syntax_error code ****************************************/ + _ = yymajor /* Silence some compiler warnings */ + if **(**uint8)(__ccgo_up((**(**TToken)(__ccgo_up(bp))).Fz)) != 0 { + _parserSyntaxError(tls, pParse, bp) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25135, 0) + } + /************ End %syntax_error code ******************************************/ + /* Suppress warning about unused %extra_argument variable */ + (*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse +} diff --git a/internal/engine/lib/sqlite_g_0000000000003b80.go b/internal/engine/lib/sqlite_g_0000000000003b80.go new file mode 100644 index 0000000..93ed51d --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003b80.go @@ -0,0 +1,81 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** The DMS lock has not yet been taken on shm file pShmNode. Attempt to +// ** take it now. Return SQLITE_OK if successful, or an SQLite error +// ** code otherwise. +// ** +// ** If the DMS cannot be locked because this is a readonly_shm=1 +// ** connection and no other process already holds a lock, return +// ** SQLITE_READONLY_CANTINIT and set pShmNode->isUnlocked=1. +// */ +func _unixLockSharedMemory(tls *libc.TLS, pDbFd uintptr, pShmNode uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var rc int32 + var _ /* lock at bp+0 */ Tflock + _ = rc + rc = SQLITE_OK + /* Use F_GETLK to determine the locks other processes are holding + ** on the DMS byte. If it indicates that another process is holding + ** a SHARED lock, then this process may also take a SHARED lock + ** and proceed with opening the *-shm file. + ** + ** Or, if no other process is holding any lock, then this process + ** is the first to open it. In this case take an EXCLUSIVE lock on the + ** DMS byte and truncate the *-shm file to zero bytes in size. Then + ** downgrade to a SHARED lock on the DMS byte. + ** + ** If another process is holding an EXCLUSIVE lock on the DMS byte, + ** return SQLITE_BUSY to the caller (it will try again). An earlier + ** version of this code attempted the SHARED lock at this point. But + ** this introduced a subtle race condition: if the process holding + ** EXCLUSIVE failed just before truncating the *-shm file, then this + ** process might open and use the *-shm file without truncating it. + ** And if the *-shm file has been corrupted by a power failure or + ** system crash, the database itself may also become corrupt. */ + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0 + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64((libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4) + libc.Int32FromInt32(SQLITE_SHM_NLOCK)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int32(F_GETLK), libc.VaList(bp+40, bp)) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(15)<pBlockingConnection. +// ** +// ** If there is no blocking connection, the callback is invoked immediately, +// ** before this routine returns. +// ** +// ** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate +// ** a deadlock. +// ** +// ** Otherwise, make arrangements to invoke xNotify when pOther drops +// ** its locks. +// ** +// ** Each call to this routine overrides any prior callbacks registered +// ** on the same "db". If xNotify==0 then any prior callbacks are immediately +// ** cancelled. +// */ +func Xsqlite3_unlock_notify(tls *libc.TLS, db uintptr, __ccgo_fp_xNotify uintptr, _pArg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _pArg + var p, v2 uintptr + var rc int32 + _, _, _ = p, rc, v2 + rc = SQLITE_OK + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _enterMutex(tls) + if __ccgo_fp_xNotify == uintptr(0) { + _removeFromBlockedList(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockConnection = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FxUnlockNotify = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockArg = uintptr(0) + } else { + if uintptr(0) == (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection { + /* The blocking transaction has been concluded. Or there never was a + ** blocking transaction. In either case, invoke the notify callback + ** immediately. + */ + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xNotify})))(tls, bp, int32(1)) + } else { + p = (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection + for { + if !(p != 0 && p != db) { + break + } + goto _1 + _1: + ; + p = (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection + } + if p != 0 { + rc = int32(SQLITE_LOCKED) /* Deadlock detected. */ + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockConnection = (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection + (*Tsqlite3)(unsafe.Pointer(db)).FxUnlockNotify = __ccgo_fp_xNotify + (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockArg = **(**uintptr)(__ccgo_up(bp)) + _removeFromBlockedList(tls, db) + _addToBlockedList(tls, db) + } + } + } + _leaveMutex(tls) + if rc != 0 { + v2 = __ccgo_ts + 26307 + } else { + v2 = uintptr(0) + } + _sqlite3ErrorWithMsg(tls, db, rc, v2, 0) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +func Xsqlite3rbu_savestate(tls *libc.TLS, p uintptr) (r int32) { + var pDb, zBegin, v1 uintptr + var rc int32 + _, _, _, _ = pDb, rc, zBegin, v1 + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + if rc == int32(SQLITE_DONE) { + return SQLITE_OK + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+16118, uintptr(0), uintptr(0), uintptr(0)) + } + } + /* Sync the db file */ + if rc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_CKPT) { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})))(tls, pDb, int32(SQLITE_SYNC_NORMAL)) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + _rbuSaveState(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage) + rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) { + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16118, uintptr(0), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + v1 = __ccgo_ts + 16103 + } else { + v1 = __ccgo_ts + 34567 + } + zBegin = v1 + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, zBegin, uintptr(0), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34567, uintptr(0), uintptr(0), uintptr(0)) + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + return rc +} + +var _aAgg = [1]struct { + FxStep uintptr + FxFinal uintptr + FzName uintptr +}{ + 0: { + FzName: __ccgo_ts + 30133, + }, +} + +var _aAlterTableFuncs = [9]TFuncDef{ + 0: { + FnArg: int16(9), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12651, + }, + 1: { + FnArg: int16(7), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12672, + }, + 2: { + FnArg: int16(7), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12692, + }, + 3: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12711, + }, + 4: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12730, + }, + 5: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12753, + }, + 6: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12776, + }, + 7: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12788, + }, + 8: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FzName: __ccgo_ts + 12810, + }, +} + +var _aCacheMode = [3]struct { + Fz uintptr + Fmode int32 +}{ + 0: { + Fz: __ccgo_ts + 26103, + Fmode: int32(SQLITE_OPEN_SHAREDCACHE), + }, + 1: { + Fz: __ccgo_ts + 26110, + Fmode: int32(SQLITE_OPEN_PRIVATECACHE), + }, + 2: {}, +} + +var _aDateTimeFuncs = [10]TFuncDef{ + 0: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1291, + }, + 1: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1311, + }, + 2: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1519, + }, + 3: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1524, + }, + 4: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1529, + }, + 5: { + FnArg: int16(-int32(1)), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1538, + }, + 6: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)), + FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)), + FzName: __ccgo_ts + 1547, + }, + 7: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1556, + }, + 8: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1569, + }, + 9: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)), + FzName: __ccgo_ts + 1587, + }, +} + +var _aFunc = [12]struct { + FxFunc uintptr + FnArg int8 + FbPure uint8 + FzName uintptr +}{ + 0: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 29990, + }, + 1: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30003, + }, + 2: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30016, + }, + 3: { + FnArg: int8(-int32(1)), + FbPure: uint8(1), + FzName: __ccgo_ts + 30029, + }, + 4: { + FnArg: int8(2), + FbPure: uint8(1), + FzName: __ccgo_ts + 29975, + }, + 5: { + FnArg: int8(3), + FbPure: uint8(1), + FzName: __ccgo_ts + 30041, + }, + 6: { + FnArg: int8(2), + FbPure: uint8(1), + FzName: __ccgo_ts + 29959, + }, + 7: { + FnArg: int8(1), + FzName: __ccgo_ts + 30064, + }, + 8: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30078, + }, + 9: { + FnArg: int8(7), + FbPure: uint8(1), + FzName: __ccgo_ts + 30091, + }, + 10: { + FnArg: int8(4), + FbPure: uint8(1), + FzName: __ccgo_ts + 30105, + }, + 11: { + FnArg: int8(1), + FbPure: uint8(1), + FzName: __ccgo_ts + 30121, + }, +} + +var _aMsg = [29]uintptr{ + 0: __ccgo_ts + 25290, + 1: __ccgo_ts + 25303, + 3: __ccgo_ts + 25319, + 4: __ccgo_ts + 25344, + 5: __ccgo_ts + 25358, + 6: __ccgo_ts + 25377, + 7: __ccgo_ts + 1674, + 8: __ccgo_ts + 25402, + 9: __ccgo_ts + 25439, + 10: __ccgo_ts + 25451, + 11: __ccgo_ts + 25466, + 12: __ccgo_ts + 25499, + 13: __ccgo_ts + 25517, + 14: __ccgo_ts + 25542, + 15: __ccgo_ts + 25571, + 17: __ccgo_ts + 6239, + 18: __ccgo_ts + 5590, + 19: __ccgo_ts + 25588, + 20: __ccgo_ts + 25606, + 21: __ccgo_ts + 25624, + 23: __ccgo_ts + 25658, + 25: __ccgo_ts + 25679, + 26: __ccgo_ts + 25705, + 27: __ccgo_ts + 25728, + 28: __ccgo_ts + 25749, +} + +var _aOp = [4]struct { + FzOp uintptr + FeOp uint8 +}{ + 0: { + FzOp: __ccgo_ts + 17812, + FeOp: uint8(SQLITE_INDEX_CONSTRAINT_MATCH), + }, + 1: { + FzOp: __ccgo_ts + 17146, + FeOp: uint8(SQLITE_INDEX_CONSTRAINT_GLOB), + }, + 2: { + FzOp: __ccgo_ts + 16605, + FeOp: uint8(SQLITE_INDEX_CONSTRAINT_LIKE), + }, + 3: { + FzOp: __ccgo_ts + 23869, + FeOp: uint8(SQLITE_INDEX_CONSTRAINT_REGEXP), + }, +} + +var _aOpenMode = [5]struct { + Fz uintptr + Fmode int32 +}{ + 0: { + Fz: __ccgo_ts + 26123, + Fmode: int32(SQLITE_OPEN_READONLY), + }, + 1: { + Fz: __ccgo_ts + 26126, + Fmode: int32(SQLITE_OPEN_READWRITE), + }, + 2: { + Fz: __ccgo_ts + 26129, + Fmode: libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE), + }, + 3: { + Fz: __ccgo_ts + 19033, + Fmode: int32(SQLITE_OPEN_MEMORY), + }, + 4: {}, +} + +var _aPragmaName = [66]TPragmaName{ + 0: { + FzName: __ccgo_ts + 18032, + FePragTyp: uint8(PragTyp_ANALYSIS_LIMIT), + FmPragFlg: uint8(PragFlg_Result0), + }, + 1: { + FzName: __ccgo_ts + 18047, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)), + FiArg: uint64(BTREE_APPLICATION_ID), + }, + 2: { + FzName: __ccgo_ts + 18062, + FePragTyp: uint8(PragTyp_AUTO_VACUUM), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 3: { + FzName: __ccgo_ts + 18074, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_AutoIndex), + }, + 4: { + FzName: __ccgo_ts + 18090, + FePragTyp: uint8(PragTyp_BUSY_TIMEOUT), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(56), + FnPragCName: uint8(1), + }, + 5: { + FzName: __ccgo_ts + 18013, + FePragTyp: uint8(PragTyp_CACHE_SIZE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 6: { + FzName: __ccgo_ts + 18103, + FePragTyp: uint8(PragTyp_CACHE_SPILL), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 7: { + FzName: __ccgo_ts + 18115, + FePragTyp: uint8(PragTyp_CASE_SENSITIVE_LIKE), + FmPragFlg: uint8(PragFlg_NoColumns), + }, + 8: { + FzName: __ccgo_ts + 18135, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_CellSizeCk), + }, + 9: { + FzName: __ccgo_ts + 18151, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_CkptFullFSync), + }, + 10: { + FzName: __ccgo_ts + 18172, + FePragTyp: uint8(PragTyp_COLLATION_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(33), + FnPragCName: uint8(2), + }, + 11: { + FzName: __ccgo_ts + 18187, + FePragTyp: uint8(PragTyp_COMPILE_OPTIONS), + FmPragFlg: uint8(PragFlg_Result0), + }, + 12: { + FzName: __ccgo_ts + 18203, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(0x00001)) << libc.Int32FromInt32(32), + }, + 13: { + FzName: __ccgo_ts + 18217, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_ReadOnly) | libc.Int32FromInt32(PragFlg_Result0)), + FiArg: uint64(BTREE_DATA_VERSION), + }, + 14: { + FzName: __ccgo_ts + 18230, + FePragTyp: uint8(PragTyp_DATABASE_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(50), + FnPragCName: uint8(3), + }, + 15: { + FzName: __ccgo_ts + 18244, + FePragTyp: uint8(PragTyp_DEFAULT_CACHE_SIZE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiPragCName: uint8(55), + FnPragCName: uint8(1), + }, + 16: { + FzName: __ccgo_ts + 18263, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_DeferFKs), + }, + 17: { + FzName: __ccgo_ts + 18282, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_NullCallback), + }, + 18: { + FzName: __ccgo_ts + 18305, + FePragTyp: uint8(PragTyp_ENCODING), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 19: { + FzName: __ccgo_ts + 18314, + FePragTyp: uint8(PragTyp_FOREIGN_KEY_CHECK), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(43), + FnPragCName: uint8(4), + }, + 20: { + FzName: __ccgo_ts + 18332, + FePragTyp: uint8(PragTyp_FOREIGN_KEY_LIST), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FnPragCName: uint8(8), + }, + 21: { + FzName: __ccgo_ts + 18349, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_ForeignKeys), + }, + 22: { + FzName: __ccgo_ts + 18362, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_ReadOnly) | libc.Int32FromInt32(PragFlg_Result0)), + }, + 23: { + FzName: __ccgo_ts + 18377, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_FullColNames), + }, + 24: { + FzName: __ccgo_ts + 18395, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_FullFSync), + }, + 25: { + FzName: __ccgo_ts + 18405, + FePragTyp: uint8(PragTyp_FUNCTION_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(15), + FnPragCName: uint8(6), + }, + 26: { + FzName: __ccgo_ts + 18419, + FePragTyp: uint8(PragTyp_HARD_HEAP_LIMIT), + FmPragFlg: uint8(PragFlg_Result0), + }, + 27: { + FzName: __ccgo_ts + 18435, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_IgnoreChecks), + }, + 28: { + FzName: __ccgo_ts + 18460, + FePragTyp: uint8(PragTyp_INCREMENTAL_VACUUM), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_NoColumns)), + }, + 29: { + FzName: __ccgo_ts + 18479, + FePragTyp: uint8(PragTyp_INDEX_INFO), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(27), + FnPragCName: uint8(3), + }, + 30: { + FzName: __ccgo_ts + 18490, + FePragTyp: uint8(PragTyp_INDEX_LIST), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(33), + FnPragCName: uint8(5), + }, + 31: { + FzName: __ccgo_ts + 18501, + FePragTyp: uint8(PragTyp_INDEX_INFO), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(27), + FnPragCName: uint8(6), + FiArg: uint64(1), + }, + 32: { + FzName: __ccgo_ts + 18513, + FePragTyp: uint8(PragTyp_INTEGRITY_CHECK), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + }, + 33: { + FzName: __ccgo_ts + 18529, + FePragTyp: uint8(PragTyp_JOURNAL_MODE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 34: { + FzName: __ccgo_ts + 18542, + FePragTyp: uint8(PragTyp_JOURNAL_SIZE_LIMIT), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 35: { + FzName: __ccgo_ts + 18561, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_LegacyAlter), + }, + 36: { + FzName: __ccgo_ts + 18580, + FePragTyp: uint8(PragTyp_LOCKING_MODE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 37: { + FzName: __ccgo_ts + 18593, + FePragTyp: uint8(PragTyp_PAGE_COUNT), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 38: { + FzName: __ccgo_ts + 18608, + FePragTyp: uint8(PragTyp_MMAP_SIZE), + }, + 39: { + FzName: __ccgo_ts + 18618, + FePragTyp: uint8(PragTyp_MODULE_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(9), + FnPragCName: uint8(1), + }, + 40: { + FzName: __ccgo_ts + 18630, + FePragTyp: uint8(PragTyp_OPTIMIZE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_NeedSchema)), + }, + 41: { + FzName: __ccgo_ts + 18639, + FePragTyp: uint8(PragTyp_PAGE_COUNT), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)), + }, + 42: { + FzName: __ccgo_ts + 18650, + FePragTyp: uint8(PragTyp_PAGE_SIZE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 43: { + FzName: __ccgo_ts + 18660, + FePragTyp: uint8(PragTyp_PRAGMA_LIST), + FmPragFlg: uint8(PragFlg_Result0), + FiPragCName: uint8(9), + FnPragCName: uint8(1), + }, + 44: { + FzName: __ccgo_ts + 18672, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_QueryOnly), + }, + 45: { + FzName: __ccgo_ts + 18683, + FePragTyp: uint8(PragTyp_INTEGRITY_CHECK), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + }, + 46: { + FzName: __ccgo_ts + 18695, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(0x00004)) << libc.Int32FromInt32(32), + }, + 47: { + FzName: __ccgo_ts + 18712, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_RecTriggers), + }, + 48: { + FzName: __ccgo_ts + 18731, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_ReverseOrder), + }, + 49: { + FzName: __ccgo_ts + 18757, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)), + FiArg: uint64(BTREE_SCHEMA_VERSION), + }, + 50: { + FzName: __ccgo_ts + 18772, + FePragTyp: uint8(PragTyp_SECURE_DELETE), + FmPragFlg: uint8(PragFlg_Result0), + }, + 51: { + FzName: __ccgo_ts + 18786, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_ShortColNames), + }, + 52: { + FzName: __ccgo_ts + 18805, + FePragTyp: uint8(PragTyp_SHRINK_MEMORY), + FmPragFlg: uint8(PragFlg_NoColumns), + }, + 53: { + FzName: __ccgo_ts + 18819, + FePragTyp: uint8(PragTyp_SOFT_HEAP_LIMIT), + FmPragFlg: uint8(PragFlg_Result0), + }, + 54: { + FzName: __ccgo_ts + 18835, + FePragTyp: uint8(PragTyp_SYNCHRONOUS), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 55: { + FzName: __ccgo_ts + 18847, + FePragTyp: uint8(PragTyp_TABLE_INFO), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(8), + FnPragCName: uint8(6), + }, + 56: { + FzName: __ccgo_ts + 18858, + FePragTyp: uint8(PragTyp_TABLE_LIST), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1)), + FiPragCName: uint8(21), + FnPragCName: uint8(6), + }, + 57: { + FzName: __ccgo_ts + 18869, + FePragTyp: uint8(PragTyp_TABLE_INFO), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)), + FiPragCName: uint8(8), + FnPragCName: uint8(7), + FiArg: uint64(1), + }, + 58: { + FzName: __ccgo_ts + 18881, + FePragTyp: uint8(PragTyp_TEMP_STORE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + }, + 59: { + FzName: __ccgo_ts + 18892, + FePragTyp: uint8(PragTyp_TEMP_STORE_DIRECTORY), + FmPragFlg: uint8(PragFlg_NoColumns1), + }, + 60: { + FzName: __ccgo_ts + 18913, + FePragTyp: uint8(PragTyp_THREADS), + FmPragFlg: uint8(PragFlg_Result0), + }, + 61: { + FzName: __ccgo_ts + 18921, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: uint64(SQLITE_TrustedSchema), + }, + 62: { + FzName: __ccgo_ts + 18936, + FePragTyp: uint8(PragTyp_HEADER_VALUE), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)), + FiArg: uint64(BTREE_USER_VERSION), + }, + 63: { + FzName: __ccgo_ts + 18949, + FePragTyp: uint8(PragTyp_WAL_AUTOCHECKPOINT), + }, + 64: { + FzName: __ccgo_ts + 18968, + FePragTyp: uint8(PragTyp_WAL_CHECKPOINT), + FmPragFlg: uint8(PragFlg_NeedSchema), + FiPragCName: uint8(47), + FnPragCName: uint8(3), + }, + 65: { + FzName: __ccgo_ts + 18983, + FePragTyp: uint8(PragTyp_FLAG), + FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)), + FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_WriteSchema) | libc.Int32FromInt32(SQLITE_NoSchemaError)), + }, +} + +/* Number of pragmas: 68 on by default, 78 total. */ + +/************** End of pragma.h **********************************************/ +/************** Continuing where we left off in pragma.c *********************/ + +/* +** When the 0x10 bit of PRAGMA optimize is set, any ANALYZE commands +** will be run with an analysis_limit set to the lessor of the value of +** the following macro or to the actual analysis_limit if it is non-zero, +** in order to prevent PRAGMA optimize from running for too long. +** +** The value of 2000 is chosen empirically so that the worst-case run-time +** for PRAGMA optimize does not exceed 100 milliseconds against a variety +** of test databases on a RaspberryPI-4 compiled using -Os and without +** -DSQLITE_DEBUG. Of course, your mileage may vary. For the purpose of +** this paragraph, "worst-case" means that ANALYZE ends up being +** run on every table in the database. The worst case typically only +** happens if PRAGMA optimize is run on a database file for which ANALYZE +** has not been previously run and the 0x10000 flag is included so that +** all tables are analyzed. The usual case for PRAGMA optimize is that +** no ANALYZE commands will be run at all, or if any ANALYZE happens it +** will be against a single table, so that expected timing for PRAGMA +** optimize on a PI-4 is more like 1 millisecond or less with the 0x10000 +** flag or less than 100 microseconds without the 0x10000 flag. +** +** An analysis limit of 2000 is almost always sufficient for the query +** planner to fully characterize an index. The additional accuracy from +** a larger analysis is not usually helpful. + */ + +// C documentation +// +// /* +// ** Many system calls are accessed through pointer-to-functions so that +// ** they may be overridden at runtime to facilitate fault injection during +// ** testing and sandboxing. The following array holds the names and pointers +// ** to all overrideable system calls. +// */ +var _aSyscall = [29]Tunix_syscall{ + 0: { + FzName: __ccgo_ts + 3542, + }, + 1: { + FzName: __ccgo_ts + 3547, + }, + 2: { + FzName: __ccgo_ts + 3553, + }, + 3: { + FzName: __ccgo_ts + 3560, + }, + 4: { + FzName: __ccgo_ts + 3567, + }, + 5: { + FzName: __ccgo_ts + 3572, + }, + 6: { + FzName: __ccgo_ts + 3578, + }, + 7: { + FzName: __ccgo_ts + 3588, + }, + 8: { + FzName: __ccgo_ts + 3594, + }, + 9: { + FzName: __ccgo_ts + 3599, + }, + 10: { + FzName: __ccgo_ts + 3605, + }, + 11: { + FzName: __ccgo_ts + 3613, + }, + 12: { + FzName: __ccgo_ts + 3619, + }, + 13: { + FzName: __ccgo_ts + 3626, + }, + 14: { + FzName: __ccgo_ts + 3635, + }, + 15: { + FzName: __ccgo_ts + 3642, + }, + 16: { + FzName: __ccgo_ts + 3652, + }, + 17: { + FzName: __ccgo_ts + 3659, + }, + 18: { + FzName: __ccgo_ts + 3673, + }, + 19: { + FzName: __ccgo_ts + 3679, + }, + 20: { + FzName: __ccgo_ts + 3685, + }, + 21: { + FzName: __ccgo_ts + 3692, + }, + 22: { + FzName: __ccgo_ts + 3700, + }, + 23: { + FzName: __ccgo_ts + 3705, + }, + 24: { + FzName: __ccgo_ts + 3712, + }, + 25: { + FzName: __ccgo_ts + 3719, + }, + 26: { + FzName: __ccgo_ts + 3731, + }, + 27: { + FzName: __ccgo_ts + 3740, + }, + 28: { + FzName: __ccgo_ts + 3746, + }, +} + +var _aTable = [3]struct { + FzName uintptr + FzCols uintptr +}{ + 0: { + FzName: __ccgo_ts + 12833, + FzCols: __ccgo_ts + 12846, + }, + 1: { + FzName: __ccgo_ts + 12859, + FzCols: __ccgo_ts + 12872, + }, + 2: { + FzName: __ccgo_ts + 12900, + }, +} + +/* +** Recommended number of samples for sqlite_stat4 + */ + +// C documentation +// +// /* +// ** Implementation of the abs() function. +// ** +// ** IMP: R-23979-26855 The abs(X) function returns the absolute value of +// ** the numeric argument X. +// */ +func _absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var iVal Ti64 + var rVal float64 + _, _ = iVal, rVal + _ = argc + switch Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_INTEGER): + iVal = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + if iVal < 0 { + if iVal == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<mallocFailed to true. +// ** +// ** C-style comments at the end are preserved. "--" style comments are +// ** removed because the comment terminator might be \000, and we are about +// ** to insert the pCons[] text into the middle of a larger string, and that +// ** will have the effect of removing the comment terminator and messing up +// ** the syntax. +// */ +func _alterRtrimConstraint(tls *libc.TLS, db uintptr, pCons uintptr, nCons int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iEnd, iOff, nToken int32 + var zTmp uintptr + var _ /* t at bp+0 */ int32 + _, _, _, _ = iEnd, iOff, nToken, zTmp + zTmp = _sqlite3MPrintf(tls, db, __ccgo_ts+12046, libc.VaList(bp+16, nCons, pCons)) + iOff = 0 + iEnd = 0 + if zTmp == uintptr(0) { + return 0 + } + for int32(1) != 0 { + **(**int32)(__ccgo_up(bp)) = 0 + nToken = int32(_sqlite3GetToken(tls, zTmp+uintptr(iOff), bp)) + if **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) { + break + } + if **(**int32)(__ccgo_up(bp)) != int32(TK_SPACE) && (**(**int32)(__ccgo_up(bp)) != int32(TK_COMMENT) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zTmp + uintptr(iOff)))) != int32('-')) { + iEnd = iOff + nToken + } + iOff = iOff + nToken + } + _sqlite3DbFree(tls, db, zTmp) + return iEnd +} + +var _attach_func = TFuncDef{ + FnArg: int16(3), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 13525, +} + +var _az = [3]uintptr{ + 0: __ccgo_ts + 16103, + 1: __ccgo_ts + 16125, + 2: __ccgo_ts + 16109, +} + +var _azAlterType = [4]uintptr{ + 0: __ccgo_ts + 19977, + 1: __ccgo_ts + 19984, + 2: __ccgo_ts + 19996, + 3: __ccgo_ts + 20007, +} + +var _azEnc = [4]uintptr{ + 1: __ccgo_ts + 19182, + 2: __ccgo_ts + 19187, + 3: __ccgo_ts + 19195, +} + +/* Shared library endings to try if zFile cannot be loaded as written */ +var _azEndings = [1]uintptr{ + 0: __ccgo_ts + 17584, +} + +var _azErr = [5]uintptr{ + 0: __ccgo_ts + 24555, + 1: __ccgo_ts + 24608, + 2: __ccgo_ts + 24110, + 3: __ccgo_ts + 24659, + 4: __ccgo_ts + 24711, +} + +// C documentation +// +// /* +// ** Column names appropriate for EXPLAIN or EXPLAIN QUERY PLAN. +// */ +var _azExplainColNames8 = [12]uintptr{ + 0: __ccgo_ts + 5613, + 1: __ccgo_ts + 5618, + 2: __ccgo_ts + 5625, + 3: __ccgo_ts + 5628, + 4: __ccgo_ts + 5631, + 5: __ccgo_ts + 5634, + 6: __ccgo_ts + 5637, + 7: __ccgo_ts + 5640, + 8: __ccgo_ts + 5648, + 9: __ccgo_ts + 5651, + 10: __ccgo_ts + 5658, + 11: __ccgo_ts + 5666, +} + +var _azFormat = [2]uintptr{ + 0: __ccgo_ts + 28919, + 1: __ccgo_ts + 28930, +} + +var _azInsType = [3]uintptr{ + 0: __ccgo_ts + 26699, + 1: __ccgo_ts + 26706, + 2: __ccgo_ts + 26710, +} + +var _azModeName = [6]uintptr{ + 0: __ccgo_ts + 19150, + 1: __ccgo_ts + 19157, + 2: __ccgo_ts + 19165, + 3: __ccgo_ts + 19169, + 4: __ccgo_ts + 19033, + 5: __ccgo_ts + 19178, +} + +var _azModule = [4]uintptr{ + 0: __ccgo_ts + 27297, + 1: __ccgo_ts + 27307, + 2: __ccgo_ts + 27317, + 3: __ccgo_ts + 27328, +} + +/* In SQLite core */ + +/* #include */ + +/* +** If building separately, we will need some setup that is normally +** found in sqliteInt.h + */ + +/* Macro to check for 4-byte alignment. Only used inside of assert() */ + +/* #include */ +/* #include */ +/* #include */ +/* #include */ + +/* The following macro is used to suppress compiler warnings. + */ + +var _azName = [192]uintptr{ + 0: __ccgo_ts + 1914, + 1: __ccgo_ts + 1924, + 2: __ccgo_ts + 1935, + 3: __ccgo_ts + 1947, + 4: __ccgo_ts + 1958, + 5: __ccgo_ts + 1970, + 6: __ccgo_ts + 1977, + 7: __ccgo_ts + 1985, + 8: __ccgo_ts + 1993, + 9: __ccgo_ts + 1998, + 10: __ccgo_ts + 2003, + 11: __ccgo_ts + 2009, + 12: __ccgo_ts + 2023, + 13: __ccgo_ts + 2029, + 14: __ccgo_ts + 2039, + 15: __ccgo_ts + 2044, + 16: __ccgo_ts + 2049, + 17: __ccgo_ts + 2052, + 18: __ccgo_ts + 2058, + 19: __ccgo_ts + 2065, + 20: __ccgo_ts + 2069, + 21: __ccgo_ts + 2079, + 22: __ccgo_ts + 2086, + 23: __ccgo_ts + 2093, + 24: __ccgo_ts + 2100, + 25: __ccgo_ts + 2107, + 26: __ccgo_ts + 2117, + 27: __ccgo_ts + 2126, + 28: __ccgo_ts + 2137, + 29: __ccgo_ts + 2146, + 30: __ccgo_ts + 2152, + 31: __ccgo_ts + 2162, + 32: __ccgo_ts + 2172, + 33: __ccgo_ts + 2177, + 34: __ccgo_ts + 2191, + 35: __ccgo_ts + 2202, + 36: __ccgo_ts + 2207, + 37: __ccgo_ts + 2214, + 38: __ccgo_ts + 2222, + 39: __ccgo_ts + 2233, + 40: __ccgo_ts + 2238, + 41: __ccgo_ts + 2243, + 42: __ccgo_ts + 2249, + 43: __ccgo_ts + 2255, + 44: __ccgo_ts + 2258, + 45: __ccgo_ts + 2262, + 46: __ccgo_ts + 2268, + 47: __ccgo_ts + 2274, + 48: __ccgo_ts + 2283, + 49: __ccgo_ts + 2294, + 50: __ccgo_ts + 2305, + 51: __ccgo_ts + 2313, + 52: __ccgo_ts + 2320, + 53: __ccgo_ts + 2328, + 54: __ccgo_ts + 2331, + 55: __ccgo_ts + 2334, + 56: __ccgo_ts + 2337, + 57: __ccgo_ts + 2340, + 58: __ccgo_ts + 2343, + 59: __ccgo_ts + 2346, + 60: __ccgo_ts + 2353, + 61: __ccgo_ts + 2362, + 62: __ccgo_ts + 2368, + 63: __ccgo_ts + 2378, + 64: __ccgo_ts + 2391, + 65: __ccgo_ts + 2402, + 66: __ccgo_ts + 2408, + 67: __ccgo_ts + 2415, + 68: __ccgo_ts + 2424, + 69: __ccgo_ts + 2433, + 70: __ccgo_ts + 2440, + 71: __ccgo_ts + 2453, + 72: __ccgo_ts + 2464, + 73: __ccgo_ts + 2469, + 74: __ccgo_ts + 2477, + 75: __ccgo_ts + 2483, + 76: __ccgo_ts + 2490, + 77: __ccgo_ts + 2502, + 78: __ccgo_ts + 2507, + 79: __ccgo_ts + 2516, + 80: __ccgo_ts + 2521, + 81: __ccgo_ts + 2530, + 82: __ccgo_ts + 2535, + 83: __ccgo_ts + 2540, + 84: __ccgo_ts + 2546, + 85: __ccgo_ts + 2554, + 86: __ccgo_ts + 2562, + 87: __ccgo_ts + 2572, + 88: __ccgo_ts + 2580, + 89: __ccgo_ts + 2587, + 90: __ccgo_ts + 2600, + 91: __ccgo_ts + 2605, + 92: __ccgo_ts + 2617, + 93: __ccgo_ts + 2625, + 94: __ccgo_ts + 2632, + 95: __ccgo_ts + 2643, + 96: __ccgo_ts + 2650, + 97: __ccgo_ts + 2657, + 98: __ccgo_ts + 2667, + 99: __ccgo_ts + 2676, + 100: __ccgo_ts + 2687, + 101: __ccgo_ts + 2693, + 102: __ccgo_ts + 2704, + 103: __ccgo_ts + 2714, + 104: __ccgo_ts + 2721, + 105: __ccgo_ts + 2727, + 106: __ccgo_ts + 2737, + 107: __ccgo_ts + 2748, + 108: __ccgo_ts + 2752, + 109: __ccgo_ts + 2761, + 110: __ccgo_ts + 2770, + 111: __ccgo_ts + 2777, + 112: __ccgo_ts + 2787, + 113: __ccgo_ts + 2794, + 114: __ccgo_ts + 2804, + 115: __ccgo_ts + 2813, + 116: __ccgo_ts + 2820, + 117: __ccgo_ts + 2830, + 118: __ccgo_ts + 2838, + 119: __ccgo_ts + 2846, + 120: __ccgo_ts + 2860, + 121: __ccgo_ts + 2874, + 122: __ccgo_ts + 2885, + 123: __ccgo_ts + 2898, + 124: __ccgo_ts + 2909, + 125: __ccgo_ts + 2915, + 126: __ccgo_ts + 2927, + 127: __ccgo_ts + 2936, + 128: __ccgo_ts + 2944, + 129: __ccgo_ts + 2953, + 130: __ccgo_ts + 2962, + 131: __ccgo_ts + 2969, + 132: __ccgo_ts + 2977, + 133: __ccgo_ts + 2984, + 134: __ccgo_ts + 2995, + 135: __ccgo_ts + 3009, + 136: __ccgo_ts + 3020, + 137: __ccgo_ts + 3028, + 138: __ccgo_ts + 3034, + 139: __ccgo_ts + 3042, + 140: __ccgo_ts + 3050, + 141: __ccgo_ts + 3060, + 142: __ccgo_ts + 3073, + 143: __ccgo_ts + 3083, + 144: __ccgo_ts + 3096, + 145: __ccgo_ts + 3105, + 146: __ccgo_ts + 3116, + 147: __ccgo_ts + 3124, + 148: __ccgo_ts + 3130, + 149: __ccgo_ts + 3142, + 150: __ccgo_ts + 3154, + 151: __ccgo_ts + 3162, + 152: __ccgo_ts + 3174, + 153: __ccgo_ts + 3187, + 154: __ccgo_ts + 3197, + 155: __ccgo_ts + 3202, + 156: __ccgo_ts + 3212, + 157: __ccgo_ts + 3224, + 158: __ccgo_ts + 3236, + 159: __ccgo_ts + 3246, + 160: __ccgo_ts + 3252, + 161: __ccgo_ts + 3262, + 162: __ccgo_ts + 3269, + 163: __ccgo_ts + 3281, + 164: __ccgo_ts + 3292, + 165: __ccgo_ts + 3300, + 166: __ccgo_ts + 3309, + 167: __ccgo_ts + 3318, + 168: __ccgo_ts + 3327, + 169: __ccgo_ts + 3334, + 170: __ccgo_ts + 3345, + 171: __ccgo_ts + 3358, + 172: __ccgo_ts + 3368, + 173: __ccgo_ts + 3375, + 174: __ccgo_ts + 3383, + 175: __ccgo_ts + 3392, + 176: __ccgo_ts + 3398, + 177: __ccgo_ts + 3405, + 178: __ccgo_ts + 3413, + 179: __ccgo_ts + 3421, + 180: __ccgo_ts + 3429, + 181: __ccgo_ts + 3439, + 182: __ccgo_ts + 3448, + 183: __ccgo_ts + 3459, + 184: __ccgo_ts + 3470, + 185: __ccgo_ts + 3481, + 186: __ccgo_ts + 3491, + 187: __ccgo_ts + 3497, + 188: __ccgo_ts + 3508, + 189: __ccgo_ts + 3519, + 190: __ccgo_ts + 3524, + 191: __ccgo_ts + 3532, +} + +var _azName1 = [3]uintptr{ + 0: __ccgo_ts + 27730, + 1: __ccgo_ts + 5651, + 2: __ccgo_ts + 17963, +} + +var _azName2 = [5]uintptr{ + 0: __ccgo_ts + 40531, + 1: __ccgo_ts + 37522, + 2: __ccgo_ts + 27339, + 3: __ccgo_ts + 38217, + 4: __ccgo_ts + 13044, +} + +var _azOne = [1]uintptr{ + 0: __ccgo_ts + 11541, +} + +var _azSql = [8]uintptr{ + 0: __ccgo_ts + 27735, + 1: __ccgo_ts + 27788, + 2: __ccgo_ts + 27833, + 3: __ccgo_ts + 27885, + 4: __ccgo_ts + 27939, + 5: __ccgo_ts + 27984, + 6: __ccgo_ts + 28042, + 7: __ccgo_ts + 28097, +} + +// C documentation +// +// /* +// ** Directories to consider for temp files. +// */ +var _azTempDirs = [6]uintptr{ + 2: __ccgo_ts + 4001, + 3: __ccgo_ts + 4010, + 4: __ccgo_ts + 4019, + 5: __ccgo_ts + 1743, +} + +var _azType = [4]uintptr{ + 0: __ccgo_ts + 5822, + 1: __ccgo_ts + 5831, + 2: __ccgo_ts + 5838, + 3: __ccgo_ts + 5844, +} + +var _azType1 = [6]uintptr{ + 0: __ccgo_ts + 1704, + 1: __ccgo_ts + 14374, + 2: __ccgo_ts + 14380, + 3: __ccgo_ts + 14385, + 4: __ccgo_ts + 14390, + 5: __ccgo_ts + 14380, +} + +var _azType2 = [5]uintptr{ + 0: __ccgo_ts + 6492, + 1: __ccgo_ts + 6487, + 2: __ccgo_ts + 8487, + 3: __ccgo_ts + 8482, + 4: __ccgo_ts + 1690, +} + +var _azTypes = [5]uintptr{ + 0: __ccgo_ts + 1174, + 1: __ccgo_ts + 1186, + 2: __ccgo_ts + 1191, + 3: __ccgo_ts + 1169, + 4: __ccgo_ts + 1705, +} + +// C documentation +// +// /* +// ** Check the integrity of the freelist or of an overflow page list. +// ** Verify that the number of pages on the list is N. +// */ +func _checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage TPgno, N Tu32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var expected, n Tu32 + var i, nErrAtStart int32 + var iFreePage TPgno + var pOvflData, v2 uintptr + var _ /* pOvflPage at bp+0 */ uintptr + _, _, _, _, _, _, _ = expected, i, iFreePage, n, nErrAtStart, pOvflData, v2 + expected = N + nErrAtStart = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr + for iPage != uint32(0) && (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0 { + if _checkRef(tls, pCheck, iPage) != 0 { + break + } + N = N - 1 + if _sqlite3PagerGet(tls, (*TIntegrityCk)(unsafe.Pointer(pCheck)).FpPager, iPage, bp, 0) != 0 { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4485, libc.VaList(bp+16, iPage)) + break + } + pOvflData = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + if isFreeList != 0 { + n = _sqlite3Get4byte(tls, pOvflData+4) + if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 { + _checkPtrmap(tls, pCheck, iPage, uint8(PTRMAP_FREEPAGE), uint32(0)) + } + if n > (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FusableSize/uint32(4)-uint32(2) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4507, libc.VaList(bp+16, iPage)) + N = N - 1 + } else { + i = 0 + for { + if !(i < libc.Int32FromUint32(n)) { + break + } + iFreePage = _sqlite3Get4byte(tls, pOvflData+uintptr(int32(8)+i*int32(4))) + if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 { + _checkPtrmap(tls, pCheck, iFreePage, uint8(PTRMAP_FREEPAGE), uint32(0)) + } + _checkRef(tls, pCheck, iFreePage) + goto _1 + _1: + ; + i = i + 1 + } + N = N - n + } + } else { + /* If this database supports auto-vacuum and iPage is not the last + ** page in this overflow list, check that the pointer-map entry for + ** the following page matches iPage. + */ + if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 && N > uint32(0) { + i = libc.Int32FromUint32(_sqlite3Get4byte(tls, pOvflData)) + _checkPtrmap(tls, pCheck, libc.Uint32FromInt32(i), uint8(PTRMAP_OVERFLOW2), iPage) + } + } + iPage = _sqlite3Get4byte(tls, pOvflData) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + } + if N != 0 && nErrAtStart == (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr { + if isFreeList != 0 { + v2 = __ccgo_ts + 4546 + } else { + v2 = __ccgo_ts + 4551 + } + _checkAppendMsg(tls, pCheck, __ccgo_ts+4572, libc.VaList(bp+16, v2, expected-N, expected)) + } +} + +// C documentation +// +// /* +// ** Check that the entry in the pointer-map for page iChild maps to +// ** page iParent, pointer type ptrType. If not, append an error message +// ** to pCheck. +// */ +func _checkPtrmap(tls *libc.TLS, pCheck uintptr, iChild TPgno, eType Tu8, iParent TPgno) { + bp := tls.Alloc(64) + defer tls.Free(64) + var rc int32 + var _ /* ePtrmapType at bp+0 */ Tu8 + var _ /* iPtrmapParent at bp+4 */ TPgno + _ = rc + rc = _ptrmapGet(tls, (*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt, iChild, bp, bp+4) + if rc != SQLITE_OK { + if rc == int32(SQLITE_NOMEM) || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<zErrMsg. +// ** Return 1 if there are 2 or more references to the page and 0 if +// ** if this is the first reference to the page. +// ** +// ** Also check that the page number is in bounds. +// */ +func _checkRef(tls *libc.TLS, pCheck uintptr, iPage TPgno) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if iPage > (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnCkPage || iPage == uint32(0) { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4354, libc.VaList(bp+8, iPage)) + return int32(1) + } + if _getPageReferenced(tls, pCheck, iPage) != 0 { + _checkAppendMsg(tls, pCheck, __ccgo_ts+4377, libc.VaList(bp+8, iPage)) + return int32(1) + } + _setPageReferenced(tls, pCheck, iPage) + return 0 +} + +// C documentation +// +// /* +// ** The CONCAT(...) function. Generate a string result that is the +// ** concatentation of all non-null arguments. +// */ +func _concatFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + _concatFuncCore(tls, context, argc, argv, 0, __ccgo_ts+1704) +} + +var _detach_func = TFuncDef{ + FnArg: int16(1), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 13511, +} + +func _disallowAggregatesInOrderByCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_FUNCTION) && (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) { + _sqlite3ErrorMsg(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, __ccgo_ts+24364, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(pExpr + 8)))) + } + return WRC_Continue +} + +var _encnames = [4]uintptr{ + 0: __ccgo_ts + 5259, + 1: __ccgo_ts + 5261, + 2: __ccgo_ts + 5263, + 3: __ccgo_ts + 5268, +} + +var _encnames1 = [9]struct { + FzName uintptr + Fenc Tu8 +}{ + 0: { + FzName: __ccgo_ts + 19792, + Fenc: uint8(SQLITE_UTF8), + }, + 1: { + FzName: __ccgo_ts + 19797, + Fenc: uint8(SQLITE_UTF8), + }, + 2: { + FzName: __ccgo_ts + 19803, + Fenc: uint8(SQLITE_UTF16LE), + }, + 3: { + FzName: __ccgo_ts + 19812, + Fenc: uint8(SQLITE_UTF16BE), + }, + 4: { + FzName: __ccgo_ts + 19821, + Fenc: uint8(SQLITE_UTF16LE), + }, + 5: { + FzName: __ccgo_ts + 19829, + Fenc: uint8(SQLITE_UTF16BE), + }, + 6: { + FzName: __ccgo_ts + 19837, + }, + 7: { + FzName: __ccgo_ts + 19844, + }, + 8: {}, +} + +// C documentation +// +// /* +// ** This routine is a helper for explainIndexRange() below +// ** +// ** pStr holds the text of an expression that we are building up one term +// ** at a time. This routine adds a new term to the end of the expression. +// ** Terms are separated by AND so add the "AND" text for second and subsequent +// ** terms only. +// */ +func _explainAppendTerm(tls *libc.TLS, pStr uintptr, pIdx uintptr, nTerm int32, iTerm int32, bAnd int32, zOp uintptr) { + var i int32 + _ = i + if bAnd != 0 { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23560, int32(5)) + } + if nTerm > int32(1) { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23566, int32(1)) + } + i = 0 + for { + if !(i < nTerm) { + break + } + if i != 0 { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+14346, int32(1)) + } + Xsqlite3_str_appendall(tls, pStr, _explainIndexColumnName(tls, pIdx, iTerm+i)) + goto _1 + _1: + ; + i = i + 1 + } + if nTerm > int32(1) { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+5257, int32(1)) + } + Xsqlite3_str_append(tls, pStr, zOp, int32(1)) + if nTerm > int32(1) { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23566, int32(1)) + } + i = 0 + for { + if !(i < nTerm) { + break + } + if i != 0 { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+14346, int32(1)) + } + Xsqlite3_str_append(tls, pStr, __ccgo_ts+5259, int32(1)) + goto _2 + _2: + ; + i = i + 1 + } + if nTerm > int32(1) { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+5257, int32(1)) + } +} + +// C documentation +// +// /* +// ** Argument pLevel describes a strategy for scanning table pTab. This +// ** function appends text to pStr that describes the subset of table +// ** rows scanned by the strategy in the form of an SQL expression. +// ** +// ** For example, if the query: +// ** +// ** SELECT * FROM t1 WHERE a=1 AND b>2; +// ** +// ** is run and there is an index on (a, b), then this function returns a +// ** string similar to: +// ** +// ** "a=? AND b>?" +// */ +func _explainIndexRange(tls *libc.TLS, pStr uintptr, pLoop uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j int32 + var nEq, nSkip Tu16 + var pIndex, z, v2 uintptr + _, _, _, _, _, _, _ = i, j, nEq, nSkip, pIndex, z, v2 + pIndex = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + nEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq + nSkip = (*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip + if libc.Int32FromUint16(nEq) == 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_BTM_LIMIT)|libc.Int32FromInt32(WHERE_TOP_LIMIT)) == uint32(0) { + return + } + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23568, int32(2)) + i = 0 + for { + if !(i < libc.Int32FromUint16(nEq)) { + break + } + z = _explainIndexColumnName(tls, pIndex, i) + if i != 0 { + Xsqlite3_str_append(tls, pStr, __ccgo_ts+23560, int32(5)) + } + if i >= libc.Int32FromUint16(nSkip) { + v2 = __ccgo_ts + 23571 + } else { + v2 = __ccgo_ts + 23576 + } + Xsqlite3_str_appendf(tls, pStr, v2, libc.VaList(bp+8, z)) + goto _1 + _1: + ; + i = i + 1 + } + j = i + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BTM_LIMIT) != 0 { + _explainAppendTerm(tls, pStr, pIndex, libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm), j, i, __ccgo_ts+23584) + i = int32(1) + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_TOP_LIMIT) != 0 { + _explainAppendTerm(tls, pStr, pIndex, libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop), j, i, __ccgo_ts+23586) + } + Xsqlite3_str_append(tls, pStr, __ccgo_ts+5257, int32(1)) +} + +// C documentation +// +// /* +// ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function +// ** is a no-op. Otherwise, it adds a single row of output to the EQP result, +// ** where the caption is of the form: +// ** +// ** "USE TEMP B-TREE FOR xxx" +// ** +// ** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which +// ** is determined by the zUsage argument. +// */ +func _explainTempTable(tls *libc.TLS, pParse uintptr, zUsage uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20518, libc.VaList(bp+8, zUsage)) +} + +/* +** Assign expression b to lvalue a. A second, no-op, version of this macro +** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code +** in sqlite3Select() to assign values to structure member variables that +** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the +** code with #ifndef directives. + */ + +// C documentation +// +// /* +// ** Implementation of the fts5() function used by clients to obtain the +// ** API pointer. +// */ +func _fts5Fts5Func(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var pGlobal, ppApi uintptr + _, _ = pGlobal, ppApi + pGlobal = Xsqlite3_user_data(tls, pCtx) + _ = nArg + ppApi = Xsqlite3_value_pointer(tls, **(**uintptr)(__ccgo_up(apArg)), __ccgo_ts+40427) + if ppApi != 0 { + **(**uintptr)(__ccgo_up(ppApi)) = pGlobal + } +} + +func _fts5IndexCorruptIdx(tls *libc.TLS, pIdx uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + (*TFts5Index)(unsafe.Pointer(pIdx)).Frc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<iBtPage) is completed. +// ** +// ** The doclist-index for that term is currently stored in-memory within the +// ** Fts5SegWriter.aDlidx[] array. If it is large enough, this function +// ** writes it out to disk. Or, if it is too small to bother with, discards +// ** it. +// ** +// ** Fts5SegWriter.btterm currently contains the first term on page iBtPage. +// */ +func _fts5WriteFlushBtree(tls *libc.TLS, p uintptr, pWriter uintptr) { + var bFlag int32 + var z, v1 uintptr + _, _, _ = bFlag, z, v1 + if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage == 0 { + return + } + bFlag = _fts5WriteFlushDlidx(tls, p, pWriter) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn > 0 { + v1 = (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fp + } else { + v1 = __ccgo_ts + 1704 + } + z = v1 + /* The following was already done in fts5WriteInit(): */ + /* sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid); */ + Xsqlite3_bind_blob(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(2), z, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn, libc.UintptrFromInt32(0)) + Xsqlite3_bind_int64(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(3), int64(bFlag)+int64((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage)< (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystack { + _fts5yy_pop_parser_stack(tls, fts5yypParser) + } + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + /******** Begin %stack_overflow code ******************************************/ + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+37021, 0) + /******** End %stack_overflow code ********************************************/ + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse /* Suppress warning about unused %extra_argument var */ +} + +/* +** Print tracing information for a SHIFT action + */ + +// C documentation +// +// /* +// ** The following code executes when a syntax error first occurs. +// */ +func _fts5yy_syntax_error(tls *libc.TLS, fts5yypParser uintptr, fts5yymajor int32, fts5yyminor TFts5Token) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pParse uintptr + _ = pParse + pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse + /************ Begin %syntax_error code ****************************************/ + _ = fts5yymajor /* Silence a compiler warning */ + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+37049, libc.VaList(bp+8, fts5yyminor.Fn, fts5yyminor.Fp)) + /************ End %syntax_error code ******************************************/ + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse /* Suppress warning about unused %extra_argument variable */ +} + +// C documentation +// +// /* +// ** Rtree virtual table module xBestIndex method. There are three +// ** table scan strategies to choose from (in order from most to +// ** least desirable): +// ** +// ** idxNum idxStr Strategy +// ** ------------------------------------------------ +// ** 1 "rowid" Direct lookup by rowid. +// ** 2 "rtree" R-tree overlap query using geopoly_overlap() +// ** 3 "rtree" R-tree within query using geopoly_within() +// ** 4 "fullscan" full-table scan. +// ** ------------------------------------------------ +// */ +func _geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + var iFuncTerm, iRowidTerm, idxNum, ii int32 + var p uintptr + _, _, _, _, _ = iFuncTerm, iRowidTerm, idxNum, ii, p + iRowidTerm = -int32(1) + iFuncTerm = -int32(1) + idxNum = 0 + _ = tab + ii = 0 + for { + if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12 + if !((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) { + goto _1 + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) { + iRowidTerm = ii + break + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) >= int32(SQLITE_INDEX_CONSTRAINT_FUNCTION) { + /* p->op==SQLITE_INDEX_CONSTRAINT_FUNCTION for geopoly_overlap() + ** p->op==(SQLITE_INDEX_CONTRAINT_FUNCTION+1) for geopoly_within(). + ** See geopolyFindFunction() */ + iFuncTerm = ii + idxNum = libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - int32(SQLITE_INDEX_CONSTRAINT_FUNCTION) + int32(2) + } + goto _1 + _1: + ; + ii = ii + 1 + } + if iRowidTerm >= 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 17963 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8))).Fomit = uint8(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(30) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = int32(SQLITE_INDEX_SCAN_UNIQUE) + return SQLITE_OK + } + if iFuncTerm >= 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 29904 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8))).Fomit = uint8(0) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(300) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10) + return SQLITE_OK + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(4) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 29910 + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(3e+06) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100000) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Report that geopoly_overlap() is an overloaded function suitable +// ** for use in xBestIndex. +// */ +func _geopolyFindFunction(tls *libc.TLS, pVtab uintptr, nArg int32, zName uintptr, __ccgo_fp_pxFunc uintptr, ppArg uintptr) (r int32) { + _ = pVtab + _ = nArg + if Xsqlite3_stricmp(tls, zName, __ccgo_ts+29959) == 0 { + **(**uintptr)(__ccgo_up(__ccgo_fp_pxFunc)) = __ccgo_fp(_geopolyOverlapFunc) + **(**uintptr)(__ccgo_up(ppArg)) = uintptr(0) + return int32(SQLITE_INDEX_CONSTRAINT_FUNCTION) + } + if Xsqlite3_stricmp(tls, zName, __ccgo_ts+29975) == 0 { + **(**uintptr)(__ccgo_up(__ccgo_fp_pxFunc)) = __ccgo_fp(_geopolyWithinFunc) + **(**uintptr)(__ccgo_up(ppArg)) = uintptr(0) + return libc.Int32FromInt32(SQLITE_INDEX_CONSTRAINT_FUNCTION) + libc.Int32FromInt32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** SQL function: geopoly_json(X) +// ** +// ** Interpret X as a polygon and render it as a JSON array +// ** of coordinates. Or, if X is not a valid polygon, return NULL. +// */ +func _geopolyJsonFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, x uintptr + var i int32 + _, _, _, _ = db, i, p, x + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + _ = argc + if p != 0 { + db = Xsqlite3_context_db_handle(tls, context) + x = Xsqlite3_str_new(tls, db) + Xsqlite3_str_append(tls, x, __ccgo_ts+26605, int32(1)) + i = 0 + for { + if !(i < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) { + break + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29768, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2)+int32(1))*4))))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29779, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4))))) + Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -int32(1), __ccgo_fp(Xsqlite3_free)) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Interpret the given string as an auto-vacuum mode value. +// ** +// ** The following strings, "none", "full" and "incremental" are +// ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively. +// */ +func _getAutoVacuum(tls *libc.TLS, z uintptr) (r int32) { + var i, v1 int32 + _, _ = i, v1 + if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+8508) { + return BTREE_AUTOVACUUM_NONE + } + if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19016) { + return int32(BTREE_AUTOVACUUM_FULL) + } + if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19021) { + return int32(BTREE_AUTOVACUUM_INCR) + } + i = _sqlite3Atoi(tls, z) + if i >= 0 && i <= int32(2) { + v1 = i + } else { + v1 = 0 + } + return libc.Int32FromUint8(libc.Uint8FromInt32(v1)) +} + +// C documentation +// +// /* +// ** Interpret the given string as a locking mode value. +// */ +func _getLockingMode(tls *libc.TLS, z uintptr) (r int32) { + if z != 0 { + if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+18999) { + return int32(PAGER_LOCKINGMODE_EXCLUSIVE) + } + if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19009) { + return PAGER_LOCKINGMODE_NORMAL + } + } + return -int32(1) +} + +func _groupConcatValue(tls *libc.TLS, context uintptr) { + var pAccum, pGCC, zText uintptr + _, _, _ = pAccum, pGCC, zText + pGCC = Xsqlite3_aggregate_context(tls, context, 0) + if pGCC != 0 { + pAccum = pGCC + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(pAccum)).FaccError) == int32(SQLITE_TOOBIG) { + Xsqlite3_result_error_toobig(tls, context) + } else { + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(pAccum)).FaccError) == int32(SQLITE_NOMEM) { + Xsqlite3_result_error_nomem(tls, context) + } else { + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum > 0 && (*TStrAccum)(unsafe.Pointer(pAccum)).FnChar == uint32(0) { + Xsqlite3_result_text(tls, context, __ccgo_ts+1704, int32(1), libc.UintptrFromInt32(0)) + } else { + zText = Xsqlite3_str_value(tls, pAccum) + Xsqlite3_result_text(tls, context, zText, libc.Int32FromUint32((*TStrAccum)(unsafe.Pointer(pAccum)).FnChar), uintptr(-libc.Int32FromInt32(1))) + } + } + } + } +} + +// C documentation +// +// /* +// ** Parameter zName is the name of a table that is about to be altered +// ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN). +// ** If the table is a system table, this function leaves an error message +// ** in pParse->zErr (system tables may not be altered) and returns non-zero. +// ** +// ** Or, if zName is not a system table, zero is returned. +// */ +func _isAlterableTable(tls *libc.TLS, pParse uintptr, pTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if 0 == Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+6756, int32(7)) || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Eponymous) != uint32(0) || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Shadow) != uint32(0) && _sqlite3ReadOnlyShadowTables(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8643, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Return true if the pExpr term from the RETURNING clause argument +// ** list is of the form "*". Raise an error if the terms if of the +// ** form "table.*". +// */ +func _isAsteriskTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr) (r int32) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pTerm)).Fop) == int32(TK_ASTERISK) { + return int32(1) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pTerm)).Fop) != int32(TK_DOT) { + return 0 + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pTerm)).FpRight)).Fop) != int32(TK_ASTERISK) { + return 0 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22482, 0) + return int32(1) +} + +// C documentation +// +// /* +// ** Parameter pTab is the subject of an ALTER TABLE ... RENAME COLUMN +// ** command. This function checks if the table is a view or virtual +// ** table (columns of views or virtual tables may not be renamed). If so, +// ** it loads an error message into pParse and returns non-zero. +// ** +// ** Or, if pTab is not a view or virtual table, zero is returned. +// */ +func _isRealTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iOp int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var azMsg [3]uintptr + var zType uintptr + _, _ = azMsg, zType + zType = uintptr(0) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + zType = __ccgo_ts + 11115 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + zType = __ccgo_ts + 11120 + } + if zType != 0 { + azMsg = [3]uintptr{ + 0: __ccgo_ts + 11134, + 1: __ccgo_ts + 11152, + 2: __ccgo_ts + 11169, + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11189, libc.VaList(bp+8, azMsg[iOp], zType, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Return TRUE (non-zero) if zTab is a valid name for the schema table pTab. +// */ +func _isValidSchemaTableName(tls *libc.TLS, zTab uintptr, pTab uintptr, zDb uintptr) (r int32) { + var zLegacy uintptr + _ = zLegacy + if Xsqlite3_strnicmp(tls, zTab, __ccgo_ts+6756, int32(7)) != 0 { + return 0 + } + zLegacy = (*TTable)(unsafe.Pointer(pTab)).FzName + if libc.Xstrcmp(tls, zLegacy+uintptr(7), __ccgo_ts+6764+7) == 0 { + if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6783+7) == 0 { + return int32(1) + } + if zDb == uintptr(0) { + return 0 + } + if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6284+7) == 0 { + return int32(1) + } + if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6802+7) == 0 { + return int32(1) + } + } else { + if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6802+7) == 0 { + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** Generate a path error. +// ** +// ** The specifics of the error are determined by the rc argument. +// ** +// ** rc error +// ** ----------------- ---------------------- +// ** JSON_LOOKUP_ARRAY "not an array" +// ** JSON_LOOKUP_TOODEEP "JSON nested too deep" +// ** JSON_LOOKUP_ERROR "malformed JSON" +// ** otherwise... "bad JSON path" +// ** +// ** If ctx is not NULL then push the error message into ctx and return NULL. +// ** If ctx is NULL, then return the text of the error message. +// */ +func _jsonBadPathError(tls *libc.TLS, ctx uintptr, zPath uintptr, rc int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var zMsg uintptr + _ = zMsg + if rc == libc.Int32FromUint32(JSON_LOOKUP_NOTARRAY) { + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26541, libc.VaList(bp+8, zPath)) + } else { + if rc == libc.Int32FromUint32(JSON_LOOKUP_ERROR) { + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26393, 0) + } else { + if rc == libc.Int32FromUint32(JSON_LOOKUP_TOODEEP) { + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26566, 0) + } else { + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26585, libc.VaList(bp+8, zPath)) + } + } + } + if ctx == uintptr(0) { + return zMsg + } + if zMsg != 0 { + Xsqlite3_result_error(tls, ctx, zMsg, -int32(1)) + Xsqlite3_free(tls, zMsg) + } else { + Xsqlite3_result_error_nomem(tls, ctx) + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** json_replace(JSON, PATH, VALUE, ...) +// ** +// ** Replace the value at PATH with VALUE. If PATH does not already exist, +// ** this routine is a no-op. If JSON or PATH is malformed, throw an error. +// */ +func _jsonReplaceFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + if argc < int32(1) { + return + } + if argc&int32(1) == 0 { + _jsonWrongNumArgs(tls, ctx, __ccgo_ts+17068) + return + } + _jsonInsertIntoBlob(tls, ctx, argc, argv, int32(JEDIT_REPL)) +} + +// C documentation +// +// /* +// ** Report the wrong number of arguments for json_insert(), json_replace() +// ** or json_set(). +// */ +func _jsonWrongNumArgs(tls *libc.TLS, pCtx uintptr, zFuncName uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var zMsg uintptr + _ = zMsg + zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26439, libc.VaList(bp+8, zFuncName)) + Xsqlite3_result_error(tls, pCtx, zMsg, -int32(1)) + Xsqlite3_free(tls, zMsg) +} + +/**************************************************************************** +** Utility routines for dealing with the binary BLOB representation of JSON +****************************************************************************/ + +// C documentation +// +// /* Human-readable names for the JSONB values. The index for each +// ** string must correspond to the JSONB_* integer above. +// */ +var _jsonbType = [17]uintptr{ + 0: __ccgo_ts + 1690, + 1: __ccgo_ts + 8178, + 2: __ccgo_ts + 8183, + 3: __ccgo_ts + 6492, + 4: __ccgo_ts + 6492, + 5: __ccgo_ts + 6487, + 6: __ccgo_ts + 6487, + 7: __ccgo_ts + 8487, + 8: __ccgo_ts + 8487, + 9: __ccgo_ts + 8487, + 10: __ccgo_ts + 8487, + 11: __ccgo_ts + 26330, + 12: __ccgo_ts + 26336, + 13: __ccgo_ts + 1704, + 14: __ccgo_ts + 1704, + 15: __ccgo_ts + 1704, + 16: __ccgo_ts + 1704, +} + +// C documentation +// +// /* +// ** Check a single element of the JSONB in pParse for validity. +// ** +// ** The element to be checked starts at offset i and must end at on the +// ** last byte before iEnd. +// ** +// ** Return 0 if everything is correct. Return the 1-based byte offset of the +// ** error if a problem is detected. (In other words, if the error is at offset +// ** 0, return 1). +// */ +func _jsonbValidityCheck(tls *libc.TLS, pParse uintptr, i Tu32, iEnd Tu32, iDepth Tu32) (r Tu32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var cnt, j, k, n, sub, sub1, szC Tu32 + var seen, x Tu8 + var z uintptr + var v1 uint32 + var _ /* c at bp+4 */ Tu32 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _ = cnt, j, k, n, seen, sub, sub1, szC, x, z, v1 + if iDepth > uint32(JSON_MAX_DEPTH) { + return i + uint32(1) + } + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + return i + uint32(1) + } /* Checked by caller */ + if i+n+**(**Tu32)(__ccgo_up(bp)) != iEnd { + return i + uint32(1) + } /* Checked by caller */ + z = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(i)))) & int32(0x0f)) + switch libc.Int32FromUint8(x) { + case JSONB_NULL: + fallthrough + case int32(JSONB_TRUE): + fallthrough + case int32(JSONB_FALSE): + if n+**(**Tu32)(__ccgo_up(bp)) == uint32(1) { + v1 = uint32(0) + } else { + v1 = i + uint32(1) + } + return v1 + case int32(JSONB_INT): + if **(**Tu32)(__ccgo_up(bp)) < uint32(1) { + return i + uint32(1) + } + j = i + n + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') { + j = j + 1 + if **(**Tu32)(__ccgo_up(bp)) < uint32(2) { + return i + uint32(1) + } + } + k = i + n + **(**Tu32)(__ccgo_up(bp)) + for j < k { + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x04) != 0 { + j = j + 1 + } else { + return j + uint32(1) + } + } + return uint32(0) + case int32(JSONB_INT5): + if **(**Tu32)(__ccgo_up(bp)) < uint32(3) { + return i + uint32(1) + } + j = i + n + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') { + if **(**Tu32)(__ccgo_up(bp)) < uint32(4) { + return i + uint32(1) + } + j = j + 1 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('0') { + return i + uint32(1) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('x') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('X') { + return j + uint32(2) + } + j = j + uint32(2) + k = i + n + **(**Tu32)(__ccgo_up(bp)) + for j < k { + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x08) != 0 { + j = j + 1 + } else { + return j + uint32(1) + } + } + return uint32(0) + case int32(JSONB_FLOAT): + fallthrough + case int32(JSONB_FLOAT5): + seen = uint8(0) /* 0: initial. 1: '.' seen 2: 'e' seen */ + if **(**Tu32)(__ccgo_up(bp)) < uint32(2) { + return i + uint32(1) + } + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') { + j = j + 1 + if **(**Tu32)(__ccgo_up(bp)) < uint32(3) { + return i + uint32(1) + } + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('.') { + if libc.Int32FromUint8(x) == int32(JSONB_FLOAT) { + return j + uint32(1) + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))])&libc.Int32FromInt32(0x04) != 0) { + return j + uint32(1) + } + j = j + uint32(2) + seen = uint8(1) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('0') && libc.Int32FromUint8(x) == int32(JSONB_FLOAT) { + if j+uint32(3) > k { + return j + uint32(1) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('.') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('e') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('E') { + return j + uint32(1) + } + j = j + 1 + } + } + for { + if !(j < k) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x04) != 0 { + goto _2 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('.') { + if libc.Int32FromUint8(seen) > 0 { + return j + uint32(1) + } + if libc.Int32FromUint8(x) == int32(JSONB_FLOAT) && (j == k-uint32(1) || !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))])&libc.Int32FromInt32(0x04) != 0)) { + return j + uint32(1) + } + seen = uint8(1) + goto _2 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('e') || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('E') { + if libc.Int32FromUint8(seen) == int32(2) { + return j + uint32(1) + } + if j == k-uint32(1) { + return j + uint32(1) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('+') || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('-') { + j = j + 1 + if j == k-uint32(1) { + return j + uint32(1) + } + } + seen = uint8(2) + goto _2 + } + return j + uint32(1) + goto _2 + _2: + ; + j = j + 1 + } + if libc.Int32FromUint8(seen) == 0 { + return i + uint32(1) + } + return uint32(0) + case int32(JSONB_TEXT): + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + for j < k { + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(j)))] != 0) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\'') { + return j + uint32(1) + } + j = j + 1 + } + return uint32(0) + case int32(JSONB_TEXTJ): + fallthrough + case int32(JSONB_TEXT5): + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + for j < k { + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(j)))] != 0) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\'') { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('"') { + if libc.Int32FromUint8(x) == int32(JSONB_TEXTJ) { + return j + uint32(1) + } + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) <= int32(0x1f) { + /* Control characters in JSON5 string literals are ok */ + if libc.Int32FromUint8(x) == int32(JSONB_TEXTJ) { + return j + uint32(1) + } + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\\') || j+uint32(1) >= k { + return j + uint32(1) + } else { + if libc.Xstrchr(tls, __ccgo_ts+26482, libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1)))))) != uintptr(0) { + j = j + 1 + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('u') { + if j+uint32(5) >= k { + return j + uint32(1) + } + if !(_jsonIs4Hex(tls, z+uintptr(j+uint32(2))) != 0) { + return j + uint32(1) + } + j = j + 1 + } else { + if libc.Int32FromUint8(x) != int32(JSONB_TEXT5) { + return j + uint32(1) + } else { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) + szC = _jsonUnescapeOneChar(tls, z+uintptr(j), k-j, bp+4) + if **(**Tu32)(__ccgo_up(bp + 4)) == uint32(JSON_INVALID_CHAR) { + return j + uint32(1) + } + j = j + (szC - uint32(1)) + } + } + } + } + } + } + } + j = j + 1 + } + return uint32(0) + case int32(JSONB_TEXTRAW): + return uint32(0) + case int32(JSONB_ARRAY): + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + for j < k { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return j + uint32(1) + } + if j+n+**(**Tu32)(__ccgo_up(bp)) > k { + return j + uint32(1) + } + sub = _jsonbValidityCheck(tls, pParse, j, j+n+**(**Tu32)(__ccgo_up(bp)), iDepth+uint32(1)) + if sub != 0 { + return sub + } + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + return uint32(0) + case int32(JSONB_OBJECT): + cnt = uint32(0) + j = i + n + k = j + **(**Tu32)(__ccgo_up(bp)) + for j < k { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return j + uint32(1) + } + if j+n+**(**Tu32)(__ccgo_up(bp)) > k { + return j + uint32(1) + } + if cnt&uint32(1) == uint32(0) { + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) & int32(0x0f)) + if libc.Int32FromUint8(x) < int32(JSONB_TEXT) || libc.Int32FromUint8(x) > int32(JSONB_TEXTRAW) { + return j + uint32(1) + } + } + sub1 = _jsonbValidityCheck(tls, pParse, j, j+n+**(**Tu32)(__ccgo_up(bp)), iDepth+uint32(1)) + if sub1 != 0 { + return sub1 + } + cnt = cnt + 1 + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + if cnt&uint32(1) != uint32(0) { + return j + uint32(1) + } + return uint32(0) + default: + return i + uint32(1) + } + return r +} + +// C documentation +// +// /* +// ** Load content from the sqlite_stat4 table into +// ** the Index.aSample[] arrays of all indices. +// */ +func _loadStat4(tls *libc.TLS, db uintptr, zDb uintptr) (r int32) { + var pStat4, v1 uintptr + var rc int32 + var v2 bool + _, _, _, _ = pStat4, rc, v1, v2 + rc = SQLITE_OK + if v2 = (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0); v2 { + v1 = _sqlite3FindTable(tls, db, __ccgo_ts+12859, zDb) + pStat4 = v1 + } + if v2 && v1 != uintptr(0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pStat4)).FeTabType) == TABTYP_NORM { + rc = _loadStatTbl(tls, db, __ccgo_ts+13085, __ccgo_ts+13154, zDb) + } + return rc +} + +// C documentation +// +// /* +// ** Log an error that is an API call on a connection pointer that should +// ** not have been used. The "type" of connection pointer is given as the +// ** argument. The zType is a word like "NULL" or "closed" or "invalid". +// */ +func _logBadConnection(tls *libc.TLS, zType uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+1852, libc.VaList(bp+8, zType)) +} + +// C documentation +// +// /* +// ** File control method. For custom operations on an memdb-file. +// */ +func _memdbFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iLimit Tsqlite3_int64 + var p uintptr + var rc int32 + _, _, _ = iLimit, p, rc + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + rc = int32(SQLITE_NOTFOUND) + _memdbEnter(tls, p) + if op == int32(SQLITE_FCNTL_VFSNAME) { + **(**uintptr)(__ccgo_up(pArg)) = Xsqlite3_mprintf(tls, __ccgo_ts+4122, libc.VaList(bp+8, (*TMemStore)(unsafe.Pointer(p)).FaData, (*TMemStore)(unsafe.Pointer(p)).Fsz)) + rc = SQLITE_OK + } + if op == int32(SQLITE_FCNTL_SIZE_LIMIT) { + iLimit = **(**Tsqlite3_int64)(__ccgo_up(pArg)) + if iLimit < (*TMemStore)(unsafe.Pointer(p)).Fsz { + if iLimit < 0 { + iLimit = (*TMemStore)(unsafe.Pointer(p)).FszMax + } else { + iLimit = (*TMemStore)(unsafe.Pointer(p)).Fsz + } + } + (*TMemStore)(unsafe.Pointer(p)).FszMax = iLimit + **(**Tsqlite3_int64)(__ccgo_up(pArg)) = iLimit + rc = SQLITE_OK + } + _memdbLeave(tls, p) + return rc +} + +var _memdb_vfs = Tsqlite3_vfs{ + FiVersion: int32(2), + FmxPathname: int32(1024), + FzName: __ccgo_ts + 4116, +} + +// C documentation +// +// /* +// ** Handle the special case of a compound-select that originates from a +// ** VALUES clause. By handling this as a special case, we avoid deep +// ** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT +// ** on a VALUES clause. +// ** +// ** Because the Select object originates from a VALUES clause: +// ** (1) There is no LIMIT or OFFSET or else there is a LIMIT of exactly 1 +// ** (2) All terms are UNION ALL +// ** (3) There is no ORDER BY clause +// ** +// ** The "LIMIT of exactly 1" case of condition (1) comes about when a VALUES +// ** clause occurs within scalar expression (ex: "SELECT (VALUES(1),(2),(3))"). +// ** The sqlite3CodeSubselect will have added the LIMIT 1 clause in tht case. +// ** Since the limit is exactly 1, we only need to evaluate the left-most VALUES. +// */ +func _multiSelectValues(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bShowAll, nRow, rc int32 + var v1 uintptr + _, _, _, _ = bShowAll, nRow, rc, v1 + nRow = int32(1) + rc = 0 + bShowAll = libc.BoolInt32((*TSelect)(unsafe.Pointer(p)).FpLimit == uintptr(0)) + for cond := true; cond; cond = int32(1) != 0 { + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 { + return -int32(1) + } + if (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) { + break + } + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + nRow = nRow + bShowAll + } + if nRow == int32(1) { + v1 = __ccgo_ts + 1704 + } else { + v1 = __ccgo_ts + 20765 + } + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20767, libc.VaList(bp+8, nRow, v1)) + for p != 0 { + _selectInnerLoop(tls, pParse, p, -int32(1), uintptr(0), uintptr(0), pDest, int32(1), int32(1)) + if !(bShowAll != 0) { + break + } + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(nRow) + p = (*TSelect)(unsafe.Pointer(p)).FpNext + } + return rc +} + +// C documentation +// +// /* +// ** Report an error that an expression is not valid for some set of +// ** pNC->ncFlags values determined by validMask. +// ** +// ** static void notValid( +// ** Parse *pParse, // Leave error message here +// ** NameContext *pNC, // The name context +// ** const char *zMsg, // Type of error +// ** int validMask, // Set of contexts for which prohibited +// ** Expr *pExpr // Invalidate this expression on error +// ** ){...} +// ** +// ** As an optimization, since the conditional is almost always false +// ** (because errors are rare), the conditional is moved outside of the +// ** function call using a macro. +// */ +func _notValidImpl(tls *libc.TLS, pParse uintptr, pNC uintptr, zMsg uintptr, pExpr uintptr, pError uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var zIn uintptr + _ = zIn + zIn = __ccgo_ts + 7098 + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_IdxExpr) != 0 { + zIn = __ccgo_ts + 7126 + } else { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_IsCheck) != 0 { + zIn = __ccgo_ts + 7144 + } else { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_GenCol) != 0 { + zIn = __ccgo_ts + 7162 + } + } + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7180, libc.VaList(bp+8, zMsg, zIn)) + if pExpr != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + } + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pError) +} + +// C documentation +// +// /* +// ** Implementation of ntile(). This assumes that the window frame has +// ** been coerced to: +// ** +// ** ROWS CURRENT ROW AND UNBOUNDED FOLLOWING +// */ +func _ntileStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + _ = nArg + p = Xsqlite3_aggregate_context(tls, pCtx, int32(24)) + if p != 0 { + if (*TNtileCtx)(unsafe.Pointer(p)).FnTotal == 0 { + (*TNtileCtx)(unsafe.Pointer(p)).FnParam = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apArg))) + if (*TNtileCtx)(unsafe.Pointer(p)).FnParam <= 0 { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+24166, -int32(1)) + } + } + (*TNtileCtx)(unsafe.Pointer(p)).FnTotal = (*TNtileCtx)(unsafe.Pointer(p)).FnTotal + 1 + } +} + +// C documentation +// +// /* +// ** Attempt to parse the given string into a julian day number. Return +// ** the number of errors. +// ** +// ** The following are acceptable forms for the input string: +// ** +// ** YYYY-MM-DD HH:MM:SS.FFF +/-HH:MM +// ** DDDD.DD +// ** now +// ** +// ** In the first form, the +/-HH:MM is always optional. The fractional +// ** seconds extension (the ".FFF") is optional. The seconds portion +// ** (":SS.FFF") is option. The year and date can be omitted as long +// ** as there is a time string. The time string can be omitted as long +// ** as there is a year and date. +// */ +func _parseDateOrTime(tls *libc.TLS, context uintptr, zDate uintptr, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* r at bp+0 */ float64 + if _parseYyyyMmDd(tls, zDate, p) == 0 { + return 0 + } else { + if _parseHhMmSs(tls, zDate, p) == 0 { + return 0 + } else { + if _sqlite3StrICmp(tls, zDate, __ccgo_ts+1228) == 0 && _sqlite3NotPureFunc(tls, context) != 0 { + return _setDateTimeToCurrent(tls, context, p) + } else { + if _sqlite3AtoF(tls, zDate, bp) > 0 { + _setRawDateNumber(tls, p, **(**float64)(__ccgo_up(bp))) + return 0 + } else { + if (_sqlite3StrICmp(tls, zDate, __ccgo_ts+1232) == 0 || _sqlite3StrICmp(tls, zDate, __ccgo_ts+1239) == 0) && _sqlite3NotPureFunc(tls, context) != 0 { + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 2, 0x4) + return _setDateTimeToCurrent(tls, context, p) + } + } + } + } + } + return int32(1) +} + +/* The julian day number for 9999-12-31 23:59:59.999 is 5373484.4999999. +** Multiplying this by 86400000 gives 464269060799999 as the maximum value +** for DateTime.iJD. +** +** But some older compilers (ex: gcc 4.2.1 on older Macs) cannot deal with +** such a large integer literal, so we have to encode it. + */ + +// C documentation +// +// /* Add a single new term to an ExprList that is used to store a +// ** list of identifiers. Report an error if the ID list contains +// ** a COLLATE clause or an ASC or DESC keyword, except ignore the +// ** error while parsing a legacy schema. +// */ +func _parserAddExprIdListTerm(tls *libc.TLS, pParse uintptr, pPrior uintptr, pIdToken uintptr, hasCollate int32, sortOrder int32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p uintptr + _ = p + p = _sqlite3ExprListAppend(tls, pParse, pPrior, uintptr(0)) + if (hasCollate != 0 || sortOrder != -int32(1)) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24876, libc.VaList(bp+8, (*TToken)(unsafe.Pointer(pIdToken)).Fn, (*TToken)(unsafe.Pointer(pIdToken)).Fz)) + } + _sqlite3ExprListSetName(tls, pParse, p, pIdToken, int32(1)) + return p +} + +/**************** End of %include directives **********************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ +/**************** End token definitions ***************************************/ + +// C documentation +// +// /* +// ** Generate a syntax error +// */ +func _parserSyntaxError(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24761, libc.VaList(bp+8, p)) +} + +// C documentation +// +// /* Names of columns for pragmas that return multi-column result +// ** or that return single-column results where the name of the +// ** result column is different from the name of the pragma +// */ +var _pragCName = [57]uintptr{ + 0: __ccgo_ts + 5648, + 1: __ccgo_ts + 17780, + 2: __ccgo_ts + 9377, + 3: __ccgo_ts + 17784, + 4: __ccgo_ts + 17789, + 5: __ccgo_ts + 17792, + 6: __ccgo_ts + 17802, + 7: __ccgo_ts + 17812, + 8: __ccgo_ts + 17818, + 9: __ccgo_ts + 17822, + 10: __ccgo_ts + 17827, + 11: __ccgo_ts + 17832, + 12: __ccgo_ts + 17840, + 13: __ccgo_ts + 17851, + 14: __ccgo_ts + 17854, + 15: __ccgo_ts + 17822, + 16: __ccgo_ts + 17861, + 17: __ccgo_ts + 17827, + 18: __ccgo_ts + 17869, + 19: __ccgo_ts + 17873, + 20: __ccgo_ts + 17878, + 21: __ccgo_ts + 17884, + 22: __ccgo_ts + 17822, + 23: __ccgo_ts + 17827, + 24: __ccgo_ts + 17891, + 25: __ccgo_ts + 17896, + 26: __ccgo_ts + 17899, + 27: __ccgo_ts + 17906, + 28: __ccgo_ts + 17818, + 29: __ccgo_ts + 17822, + 30: __ccgo_ts + 17912, + 31: __ccgo_ts + 17917, + 32: __ccgo_ts + 17922, + 33: __ccgo_ts + 17780, + 34: __ccgo_ts + 17822, + 35: __ccgo_ts + 17926, + 36: __ccgo_ts + 17933, + 37: __ccgo_ts + 17940, + 38: __ccgo_ts + 13048, + 39: __ccgo_ts + 13044, + 40: __ccgo_ts + 17948, + 41: __ccgo_ts + 17953, + 42: __ccgo_ts + 17958, + 43: __ccgo_ts + 9377, + 44: __ccgo_ts + 17963, + 45: __ccgo_ts + 5651, + 46: __ccgo_ts + 17969, + 47: __ccgo_ts + 17974, + 48: __ccgo_ts + 17165, + 49: __ccgo_ts + 17979, + 50: __ccgo_ts + 17780, + 51: __ccgo_ts + 17822, + 52: __ccgo_ts + 17992, + 53: __ccgo_ts + 17997, + 54: __ccgo_ts + 18006, + 55: __ccgo_ts + 18013, + 56: __ccgo_ts + 18024, +} + +// C documentation +// +// /* +// ** Create zero or more entries in the output for the SQL functions +// ** defined by FuncDef p. +// */ +func _pragmaFunclistLine(tls *libc.TLS, v uintptr, p uintptr, isBuiltin int32, showInternFuncs int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var mask Tu32 + var zType uintptr + _, _ = mask, zType + mask = libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_DIRECTONLY) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_INNOCUOUS) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL)) + if showInternFuncs != 0 { + mask = uint32(0xffffffff) + } + for { + if !(p != 0) { + break + } + if (*TFuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) { + goto _1 + } + if (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_INTERNAL) != uint32(0) && showInternFuncs == 0 { + goto _1 + } + if (*TFuncDef)(unsafe.Pointer(p)).FxValue != uintptr(0) { + zType = __ccgo_ts + 19203 + } else { + if (*TFuncDef)(unsafe.Pointer(p)).FxFinalize != uintptr(0) { + zType = __ccgo_ts + 19205 + } else { + zType = __ccgo_ts + 7909 + } + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19207, libc.VaList(bp+8, (*TFuncDef)(unsafe.Pointer(p)).FzName, isBuiltin, zType, _azEnc[(*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_ENCMASK)], int32((*TFuncDef)(unsafe.Pointer(p)).FnArg), (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&mask^uint32(SQLITE_INNOCUOUS))) + goto _1 + _1: + ; + p = (*TFuncDef)(unsafe.Pointer(p)).FpNext + } +} + +// C documentation +// +// /* +// ** The SELECT statement iterating through the keys for the current object +// ** (p->objiter.pSelect) currently points to a valid row. However, there +// ** is something wrong with the rbu_control value in the rbu_control value +// ** stored in the (p->nCol+1)'th column. Set the error code and error message +// ** of the RBU handle to something reflecting this. +// */ +func _rbuBadControlError(tls *libc.TLS, p uintptr) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+31677, 0) +} + +// C documentation +// +// /* +// ** If there is a "*-oal" file in the file-system corresponding to the +// ** target database in the file-system, delete it. If an error occurs, +// ** leave an error code and error message in the rbu handle. +// */ +func _rbuDeleteOalFile(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var zOal uintptr + var _ /* pVfs at bp+0 */ uintptr + _ = zOal + zOal = _rbuMPrintf(tls, p, __ccgo_ts+33683, libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget)) + if zOal != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, int32(SQLITE_FCNTL_VFS_POINTER), bp) + (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxDelete})))(tls, **(**uintptr)(__ccgo_up(bp)), zOal, 0) + Xsqlite3_free(tls, zOal) + } +} + +// C documentation +// +// /* +// ** Return true if the database handle passed as the only argument +// ** was opened with the rbu_exclusive_checkpoint=1 URI parameter +// ** specified. Or false otherwise. +// */ +func _rbuExclusiveCheckpoint(tls *libc.TLS, db uintptr) (r int32) { + var zUri uintptr + _ = zUri + zUri = Xsqlite3_db_filename(tls, db, uintptr(0)) + return Xsqlite3_uri_boolean(tls, zUri, __ccgo_ts+33658, 0) +} + +// C documentation +// +// /* +// ** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if +// ** successful, or an SQLite error code otherwise. +// */ +func _rbuLockDatabase(tls *libc.TLS, db uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* fd at bp+0 */ uintptr + _ = rc + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + Xsqlite3_file_control(tls, db, __ccgo_ts+6816, int32(RBU_ZIPVFS_CTRL_FILE_POINTER), bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + Xsqlite3_file_control(tls, db, __ccgo_ts+6816, int32(SQLITE_FCNTL_FILE_POINTER), bp) + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_SHARED)) + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxUnlock})))(tls, **(**uintptr)(__ccgo_up(bp)), SQLITE_LOCK_NONE) + } + Xsqlite3_file_control(tls, db, __ccgo_ts+6816, int32(RBU_ZIPVFS_CTRL_FILE_POINTER), bp) + } else { + Xsqlite3_file_control(tls, db, __ccgo_ts+6816, int32(SQLITE_FCNTL_FILE_POINTER), bp) + } + if rc == SQLITE_OK && (*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods != 0 { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_SHARED)) + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_EXCLUSIVE)) + } + } + return rc +} + +// C documentation +// +// /* +// ** This function is called as part of initializing or reinitializing an +// ** incremental checkpoint. +// ** +// ** It populates the sqlite3rbu.aFrame[] array with the set of +// ** (wal frame -> db page) copy operations required to checkpoint the +// ** current wal file, and obtains the set of shm locks required to safely +// ** perform the copy operations directly on the file-system. +// ** +// ** If argument pState is not NULL, then the incremental checkpoint is +// ** being resumed. In this case, if the checksum of the wal-index-header +// ** following recovery is not the same as the checksum saved in the RbuState +// ** object, then the rbu handle is set to DONE state. This occurs if some +// ** other client appends a transaction to the wal file in the middle of +// ** an incremental checkpoint. +// */ +func _rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { + var nSectorSize, rc2, v1 int32 + var pDb, pWal uintptr + _, _, _, _, _ = nSectorSize, pDb, pWal, rc2, v1 + /* If pState is NULL, then the wal file may not have been opened and + ** recovered. Running a read-statement here to ensure that doing so + ** does not interfere with the "capture" process below. */ + if pState == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33577, uintptr(0), uintptr(0), uintptr(0)) + } + } + /* Assuming no error has occurred, run a "restart" checkpoint with the + ** sqlite3rbu.eStage variable set to CAPTURE. This turns on the following + ** special behaviour in the rbu VFS: + ** + ** * If the exclusive shm WRITER or READ0 lock cannot be obtained, + ** the checkpoint fails with SQLITE_BUSY (normally SQLite would + ** proceed with running a passive checkpoint instead of failing). + ** + ** * Attempts to read from the *-wal file or write to the database file + ** do not perform any IO. Instead, the frame/page combinations that + ** would be read/written are recorded in the sqlite3rbu.aFrame[] + ** array. + ** + ** * Calls to xShmLock(UNLOCK) to release the exclusive shm WRITER, + ** READ0 and CHECKPOINT locks taken as part of the checkpoint are + ** no-ops. These locks will not be released until the connection + ** is closed. + ** + ** * Attempting to xSync() the database file causes an SQLITE_NOTICE + ** error. + ** + ** As a result, unless an error (i.e. OOM or SQLITE_BUSY) occurs, the + ** checkpoint below fails with SQLITE_NOTICE, and leaves the aFrame[] + ** array populated with a set of (frame -> page) mappings. Because the + ** WRITER, CHECKPOINT and READ0 locks are still held, it is safe to copy + ** data from the wal file into the database file according to the + ** contents of aFrame[]. + */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CAPTURE) + rc2 = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33623, uintptr(0), uintptr(0), uintptr(0)) + if rc2 != int32(SQLITE_NOTICE) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc2 + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame > 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CKPT) + if pState != 0 { + v1 = (*TRbuState)(unsafe.Pointer(pState)).FnRow + } else { + v1 = 0 + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = v1 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FaBuf = _rbuMalloc(tls, p, int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FiWalCksum = _rbuShmChecksum(tls, p) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame == 0 || pState != 0 && (*TRbuState)(unsafe.Pointer(pState)).FiWalCksum != (*Tsqlite3rbu)(unsafe.Pointer(p)).FiWalCksum { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE) + } else { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + pWal = (*Trbu_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd)).FpReal + nSectorSize = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSectorSize})))(tls, pDb) + if nSectorSize > (*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector = nSectorSize / (*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz + } else { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector = int32(1) + } + /* Call xSync() on the wal file. This causes SQLite to sync the + ** directory in which the target database and the wal file reside, in + ** case it has not been synced since the rename() call in + ** rbuMoveOalFile(). */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pWal)).FpMethods)).FxSync})))(tls, pWal, int32(SQLITE_SYNC_NORMAL)) + } + } +} + +// C documentation +// +// /* +// ** File control method. For custom operations on an rbuVfs-file. +// */ +func _rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p, pRbu, pRbu1, pRbuVfs, xControl, zIn, zOut uintptr + var rc int32 + var _ /* dummy at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = p, pRbu, pRbu1, pRbuVfs, rc, xControl, zIn, zOut + p = pFile + xControl = (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileControl + if op == int32(SQLITE_FCNTL_RBU) { + pRbu = pArg + /* First try to find another RBU vfs lower down in the vfs stack. If + ** one is found, this vfs will operate in pass-through mode. The lower + ** level vfs will do the special RBU handling. */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, op, pArg) + if rc == int32(SQLITE_NOTFOUND) { + /* Now search for a zipvfs instance lower down in the VFS stack. If + ** one is found, this is an error. */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, int32(SQLITE_FCNTL_ZIPVFS), bp) + if rc == SQLITE_OK { + rc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+34642, 0) + } else { + if rc == int32(SQLITE_NOTFOUND) { + (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FpTargetFd = p + (*Trbu_file)(unsafe.Pointer(p)).FpRbu = pRbu + _rbuMainlistAdd(tls, p) + if (*Trbu_file)(unsafe.Pointer(p)).FpWalFd != 0 { + (*Trbu_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpWalFd)).FpRbu = pRbu + } + rc = SQLITE_OK + } + } + } + return rc + } else { + if op == int32(SQLITE_FCNTL_RBUCNT) { + pRbu1 = pArg + (*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FnRbu = (*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FnRbu + 1 + (*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FpRbuFd = p + (*Trbu_file)(unsafe.Pointer(p)).FbNolock = uint8(1) + } + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, op, pArg) + if rc == SQLITE_OK && op == int32(SQLITE_FCNTL_VFSNAME) { + pRbuVfs = (*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs + zIn = **(**uintptr)(__ccgo_up(pArg)) + zOut = Xsqlite3_mprintf(tls, __ccgo_ts+34665, libc.VaList(bp+16, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fbase.FzName, zIn)) + **(**uintptr)(__ccgo_up(pArg)) = zOut + if zOut == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +// C documentation +// +// /* +// ** Generate VM code to replace any double-quoted strings (but not double-quoted +// ** identifiers) within the "sql" column of the sqlite_schema table in +// ** database zDb with their single-quoted equivalents. If argument bTemp is +// ** not true, similarly update all SQL statements in the sqlite_schema table +// ** of the temp db. +// */ +func _renameFixQuotes(tls *libc.TLS, pParse uintptr, zDb uintptr, bTemp int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9020, libc.VaList(bp+8, zDb, zDb)) + if bTemp == 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+9167, 0) + } +} + +// C documentation +// +// /* +// ** Generate an ORDER BY or GROUP BY term out-of-range error. +// */ +func _resolveOutOfRangeError(tls *libc.TLS, pParse uintptr, zType uintptr, i int32, mx int32, pError uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7569, libc.VaList(bp+8, i, zType, mx)) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pError) +} + +// C documentation +// +// /* +// ** Close a file descriptor. +// ** +// ** We assume that close() almost always works, since it is only in a +// ** very sick application or on a very sick platform that it might fail. +// ** If it does fail, simply leak the file descriptor, but do log the +// ** error. +// ** +// ** Note that it is not safe to retry close() after EINTR since the +// ** file descriptor might have already been reused by another thread. +// ** So we don't even try to recover from an EINTR. Just log the error +// ** and move on. +// */ +func _robust_close(tls *libc.TLS, pFile uintptr, h int32, lineno int32) { + var v1 uintptr + _ = v1 + if (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(1)].FpCurrent})))(tls, h) != 0 { + if pFile != 0 { + v1 = (*TunixFile)(unsafe.Pointer(pFile)).FzPath + } else { + v1 = uintptr(0) + } + _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(16)<x2 conditions) and adds an error message to the RtreeCheck object +// ** if they are not. +// ** +// ** Additionally, if pParent is not NULL, then it is assumed to point to +// ** the array of coordinates on the parent page that bound the page +// ** containing pCell. In this case it is also verified that the two +// ** sets of coordinates are mutually consistent and an error message added +// ** to the RtreeCheck object if they are not. +// */ +func _rtreeCheckCellCoord(tls *libc.TLS, pCheck uintptr, iNode Ti64, iCell int32, pCell uintptr, pParent uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, v2, v3 int32 + var v5 bool + var _ /* c1 at bp+0 */ TRtreeCoord + var _ /* c2 at bp+4 */ TRtreeCoord + var _ /* p1 at bp+8 */ TRtreeCoord + var _ /* p2 at bp+12 */ TRtreeCoord + _, _, _, _ = i, v2, v3, v5 + i = 0 + for { + if !(i < (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim) { + break + } + _readCoord(tls, pCell+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(2)*i), bp) + _readCoord(tls, pCell+uintptr(int32(4)*(int32(2)*i+int32(1))), bp+4) + /* printf("%e, %e\n", c1.u.f, c2.u.f); */ + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 { + v2 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp)) > *(*int32)(unsafe.Pointer(bp + 4))) + } else { + v2 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp)) > *(*TRtreeValue)(unsafe.Pointer(bp + 4))) + } + if v2 != 0 { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29292, libc.VaList(bp+24, i, iCell, iNode)) + } + if pParent != 0 { + _readCoord(tls, pParent+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(2)*i), bp+8) + _readCoord(tls, pParent+uintptr(int32(4)*(int32(2)*i+int32(1))), bp+12) + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 { + v2 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp)) < *(*int32)(unsafe.Pointer(bp + 8))) + } else { + v2 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp)) < *(*TRtreeValue)(unsafe.Pointer(bp + 8))) + } + if v5 = v2 != 0; !v5 { + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 { + v3 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp + 4)) > *(*int32)(unsafe.Pointer(bp + 12))) + } else { + v3 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp + 4)) > *(*TRtreeValue)(unsafe.Pointer(bp + 12))) + } + } + if v5 || v3 != 0 { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29340, libc.VaList(bp+24, i, iCell, iNode)) + } + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** The second argument to this function must be either "_rowid" or +// ** "_parent". This function checks that the number of entries in the +// ** %_rowid or %_parent table is exactly nExpect. If not, it adds +// ** an error message to the report in the RtreeCheck object indicated +// ** by the first argument. +// */ +func _rtreeCheckCount(tls *libc.TLS, pCheck uintptr, zTbl uintptr, nExpect Ti64) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nActual Ti64 + var pCount uintptr + _, _ = nActual, pCount + if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { + pCount = _rtreeCheckPrepare(tls, pCheck, __ccgo_ts+29526, libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzTab, zTbl)) + if pCount != 0 { + if Xsqlite3_step(tls, pCount) == int32(SQLITE_ROW) { + nActual = Xsqlite3_column_int64(tls, pCount, 0) + if nActual != nExpect { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29557, libc.VaList(bp+8, zTbl, nExpect, nActual)) + } + } + (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_finalize(tls, pCount) + } + } +} + +// C documentation +// +// /* +// ** Run rtreecheck() checks on node iNode, which is at depth iDepth within +// ** the r-tree structure. Argument aParent points to the array of coordinates +// ** that bound node iNode on the parent node. +// ** +// ** If any problems are discovered, an error message is appended to the +// ** report accumulated in the RtreeCheck object. +// */ +func _rtreeCheckNode(tls *libc.TLS, pCheck uintptr, iDepth int32, aParent uintptr, iNode Ti64) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aNode, pCell uintptr + var i, nCell int32 + var iVal Ti64 + var _ /* nNode at bp+0 */ int32 + _, _, _, _, _ = aNode, i, iVal, nCell, pCell + aNode = uintptr(0) + **(**int32)(__ccgo_up(bp)) = 0 + aNode = _rtreeCheckGetNode(tls, pCheck, iNode, bp) + if aNode != 0 { + if **(**int32)(__ccgo_up(bp)) < int32(4) { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29407, libc.VaList(bp+16, iNode, **(**int32)(__ccgo_up(bp)))) + } else { /* Used to iterate through cells */ + if aParent == uintptr(0) { + iDepth = _readInt16(tls, aNode) + if iDepth > int32(RTREE_MAX_DEPTH) { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29441, libc.VaList(bp+16, iDepth)) + Xsqlite3_free(tls, aNode) + return + } + } + nCell = _readInt16(tls, aNode+2) + if int32(4)+nCell*(int32(8)+(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim*int32(2)*int32(4)) > **(**int32)(__ccgo_up(bp)) { + _rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29471, libc.VaList(bp+16, iNode, nCell, **(**int32)(__ccgo_up(bp)))) + } else { + i = 0 + for { + if !(i < nCell) { + break + } + pCell = aNode + uintptr(int32(4)+i*(int32(8)+(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim*int32(2)*int32(4))) + iVal = _readInt64(tls, pCell) + _rtreeCheckCellCoord(tls, pCheck, iNode, i, pCell+8, aParent) + if iDepth > 0 { + _rtreeCheckMapping(tls, pCheck, 0, iVal, iNode) + _rtreeCheckNode(tls, pCheck, iDepth-int32(1), pCell+8, iVal) + (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf = (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf + 1 + } else { + _rtreeCheckMapping(tls, pCheck, int32(1), iVal, iNode) + (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnLeaf = (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnLeaf + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + } + } + Xsqlite3_free(tls, aNode) + } +} + +// C documentation +// +// /* +// ** A constraint has failed while inserting a row into an rtree table. +// ** Assuming no OOM error occurs, this function sets the error message +// ** (at pRtree->base.zErrMsg) to an appropriate value and returns +// ** SQLITE_CONSTRAINT. +// ** +// ** Parameter iCol is the index of the leftmost column involved in the +// ** constraint failure. If it is 0, then the constraint that failed is +// ** the unique constraint on the id column. Otherwise, it is the rtree +// ** (c1<=c2) constraint on columns iCol and iCol+1 that has failed. +// ** +// ** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT. +// */ +func _rtreeConstraintError(tls *libc.TLS, pRtree uintptr, iCol int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var rc, v1 int32 + var zCol, zCol1, zCol2, zSql uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _ = rc, zCol, zCol1, zCol2, zSql, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+27440, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName)) + if zSql != 0 { + rc = Xsqlite3_prepare_v2(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zSql, -int32(1), bp, uintptr(0)) + } else { + rc = int32(SQLITE_NOMEM) + } + Xsqlite3_free(tls, zSql) + if rc == SQLITE_OK { + if iCol == 0 { + zCol = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), 0) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+27460, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zCol)) + } else { + zCol1 = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), iCol) + zCol2 = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), iCol+int32(1)) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+27492, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zCol1, zCol2)) + } + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + v1 = int32(SQLITE_CONSTRAINT) + } else { + v1 = rc + } + return v1 +} + +// C documentation +// +// /* +// ** Rtree virtual table module xDestroy method. +// */ +func _rtreeDestroy(tls *libc.TLS, pVtab uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var pRtree, zCreate uintptr + var rc int32 + _, _, _ = pRtree, rc, zCreate + pRtree = pVtab + zCreate = Xsqlite3_mprintf(tls, __ccgo_ts+27344, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName)) + if !(zCreate != 0) { + rc = int32(SQLITE_NOMEM) + } else { + _nodeBlobReset(tls, pRtree) + rc = Xsqlite3_exec(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zCreate, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_free(tls, zCreate) + } + if rc == SQLITE_OK { + _rtreeRelease(tls, pRtree) + } + return rc +} + +// C documentation +// +// /* +// ** Implementation of the xIntegrity method for Rtree. +// */ +func _rtreeIntegrity(tls *libc.TLS, pVtab uintptr, zSchema uintptr, zName uintptr, isQuick int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pRtree uintptr + var rc int32 + _, _ = pRtree, rc + pRtree = pVtab + _ = zSchema + _ = zName + _ = isQuick + rc = _rtreeCheckTable(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, pzErr) + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(pzErr)) != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+29698, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, **(**uintptr)(__ccgo_up(pzErr)))) + if **(**uintptr)(__ccgo_up(pzErr)) == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +// C documentation +// +// /* +// ** This function populates the pRtree->nRowEst variable with an estimate +// ** of the number of rows in the virtual table. If possible, this is based +// ** on sqlite_stat1 data. Otherwise, use RTREE_DEFAULT_ROWEST. +// */ +func _rtreeQueryStat1(tls *libc.TLS, db uintptr, pRtree uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nRow Ti64 + var rc, v1 int32 + var zFmt, zSql uintptr + var v2 int64 + var _ /* p at bp+0 */ uintptr + _, _, _, _, _, _ = nRow, rc, zFmt, zSql, v1, v2 + zFmt = __ccgo_ts + 27674 + nRow = int64(RTREE_MIN_ROWEST) + rc = Xsqlite3_table_column_metadata(tls, db, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, __ccgo_ts+12833, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + if rc != SQLITE_OK { + (*TRtree)(unsafe.Pointer(pRtree)).FnRowEst = int64(RTREE_DEFAULT_ROWEST) + if rc == int32(SQLITE_ERROR) { + v1 = SQLITE_OK + } else { + v1 = rc + } + return v1 + } + zSql = Xsqlite3_mprintf(tls, zFmt, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + if rc == SQLITE_OK { + if Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { + nRow = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + Xsqlite3_free(tls, zSql) + } + if nRow > int64(libc.Int32FromInt32(RTREE_MIN_ROWEST)) { + v2 = nRow + } else { + v2 = int64(libc.Int32FromInt32(RTREE_MIN_ROWEST)) + } + (*TRtree)(unsafe.Pointer(pRtree)).FnRowEst = v2 + return rc +} + +// C documentation +// +// /* +// ** The xRename method for rtree module virtual tables. +// */ +func _rtreeRename(tls *libc.TLS, pVtab uintptr, zNewName uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var pRtree, zSql uintptr + var rc int32 + _, _, _ = pRtree, rc, zSql + pRtree = pVtab + rc = int32(SQLITE_NOMEM) + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+27529, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName)) + if zSql != 0 { + _nodeBlobReset(tls, pRtree) + rc = Xsqlite3_exec(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zSql, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3_free(tls, zSql) + } + return rc +} + +// C documentation +// +// /* This routine implements an SQL function that returns the "depth" parameter +// ** from the front of a blob that is an r-tree node. For example: +// ** +// ** SELECT rtreedepth(data) FROM rt_node WHERE nodeno=1; +// ** +// ** The depth value is 0 for all nodes other than the root node, and the root +// ** node always has nodeno=1, so the example above is the primary use for this +// ** routine. This routine is intended for testing and analysis only. +// */ +func _rtreedepth(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { + var zBlob uintptr + _ = zBlob + _ = nArg + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apArg))) != int32(SQLITE_BLOB) || Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg))) < int32(2) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+28953, -int32(1)) + } else { + zBlob = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(apArg))) + if zBlob != 0 { + Xsqlite3_result_int(tls, ctx, _readInt16(tls, zBlob)) + } else { + Xsqlite3_result_error_nomem(tls, ctx) + } + } +} + +// C documentation +// +// /* +// ** Attempt to apply the change that the iterator passed as the first argument +// ** currently points to to the database. If a conflict is encountered, invoke +// ** the conflict handler callback. +// ** +// ** The difference between this function and sessionApplyOne() is that this +// ** function handles the case where the conflict-handler is invoked and +// ** returns SQLITE_CHANGESET_REPLACE - indicating that the change should be +// ** retried in some manner. +// */ +func _sessionApplyOneWithRetry(tls *libc.TLS, db uintptr, pIter uintptr, pApply uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* bReplace at bp+0 */ int32 + var _ /* bRetry at bp+4 */ int32 + _ = rc + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, bp, bp+4) + if rc == SQLITE_OK { + /* If the bRetry flag is set, the change has not been applied due to an + ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and + ** a row with the correct PK is present in the db, but one or more other + ** fields do not contain the expected values) and the conflict handler + ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation, + ** but pass NULL as the final argument so that sessionApplyOneOp() ignores + ** the SQLITE_CHANGESET_DATA problem. */ + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0)) + } else { + if **(**int32)(__ccgo_up(bp)) != 0 { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36258, uintptr(0), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + rc = _sessionBindRow(tls, pIter, __ccgo_fp(Xsqlite3changeset_new), (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + Xsqlite3_bind_int(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol+int32(1), int32(1)) + } + if rc == SQLITE_OK { + Xsqlite3_step(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + rc = Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete) + } + if rc == SQLITE_OK { + rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_exec(tls, db, __ccgo_ts+36279, uintptr(0), uintptr(0), uintptr(0)) + } + } + } + } + return rc +} + +func _sessionDiffFindModified(tls *libc.TLS, pSession uintptr, pTab uintptr, zFrom uintptr, zExpr uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iRowid Ti64 + var pDiffCtx, z1, z2, zExpr2, zStmt uintptr + var rc int32 + var v1 int64 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = iRowid, pDiffCtx, rc, z1, z2, zExpr2, zStmt, v1 + rc = SQLITE_OK + zExpr2 = _sessionExprCompareOther(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, zFrom, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK) + if zExpr2 == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + z1 = _sessionAllCols(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, pTab) + z2 = _sessionAllCols(tls, zFrom, pTab) + zStmt = Xsqlite3_mprintf(tls, __ccgo_ts+35481, libc.VaList(bp+16, z1, z2, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zFrom, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zExpr, zExpr2)) + if zStmt == uintptr(0) || z1 == uintptr(0) || z2 == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, zStmt, -int32(1), bp, uintptr(0)) + if rc == SQLITE_OK { + pDiffCtx = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx + (*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FpStmt = **(**uintptr)(__ccgo_up(bp)) + (*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FnOldOff = (*TSessionTable)(unsafe.Pointer(pTab)).FnCol + for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + v1 = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0) + } else { + v1 = 0 + } + iRowid = v1 + _sessionPreupdateOneChange(tls, int32(SQLITE_UPDATE), iRowid, pSession, pTab) + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + Xsqlite3_free(tls, zStmt) + Xsqlite3_free(tls, z1) + Xsqlite3_free(tls, z2) + } + return rc +} + +func _sessionSelectFindNew(tls *libc.TLS, zDb1 uintptr, zDb2 uintptr, bRowid int32, zTbl uintptr, zExpr uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var zRet, zSel, v1 uintptr + _, _, _ = zRet, zSel, v1 + if bRowid != 0 { + v1 = __ccgo_ts + 35372 + } else { + v1 = __ccgo_ts + 6821 + } + zSel = v1 + zRet = Xsqlite3_mprintf(tls, __ccgo_ts+35383, libc.VaList(bp+8, zSel, zDb1, zTbl, zDb2, zTbl, zExpr)) + return zRet +} + +// C documentation +// +// /* +// ** Check if table zTab in the "main" database of db is a WITHOUT ROWID +// ** table. +// ** +// ** If no error occurs, return SQLITE_OK and set output variable (*pbWR) to +// ** true if zTab is a WITHOUT ROWID table, or false otherwise. Or, if an +// ** error does occur, return an SQLite error code. The final value of (*pbWR) +// ** is undefined in this case. +// */ +func _sessionTableIsWithoutRowid(tls *libc.TLS, db uintptr, zTab uintptr, pbWR uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc int32 + var zSql uintptr + var _ /* pList at bp+0 */ uintptr + _, _ = rc, zSql + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zSql = uintptr(0) + rc = SQLITE_OK + zSql = Xsqlite3_mprintf(tls, __ccgo_ts+36298, libc.VaList(bp+16, zTab)) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0)) + Xsqlite3_free(tls, zSql) + } + if rc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + **(**int32)(__ccgo_up(pbWR)) = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Do an authorization check using the code and arguments given. Return +// ** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY. If SQLITE_DENY +// ** is returned, then the error count and error message in pParse are +// ** modified appropriately. +// */ +func _sqlite3AuthCheck(tls *libc.TLS, pParse uintptr, code int32, zArg1 uintptr, zArg2 uintptr, zArg3 uintptr) (r int32) { + var db uintptr + var rc int32 + _, _ = db, rc + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Don't do any authorization checks if the database is initializing + ** or if the parser is being invoked from within sqlite3_declare_vtab. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FxAuth == uintptr(0) || (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + return SQLITE_OK + } + /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the + ** callback are either NULL pointers or zero-terminated strings that + ** contain additional details about the action to be authorized. + ** + ** The following testcase() macros show that any of the 3rd through 6th + ** parameters can be either NULL or a string. */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxAuth})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpAuthArg, code, zArg1, zArg2, zArg3, (*TParse)(unsafe.Pointer(pParse)).FzAuthContext) + if rc == int32(SQLITE_DENY) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13671, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_AUTH) + } else { + if rc != SQLITE_OK && rc != int32(SQLITE_IGNORE) { + rc = int32(SQLITE_DENY) + _sqliteAuthBadReturnCode(tls, pParse) + } + } + return rc +} + +func _sqlite3CantopenError(tls *libc.TLS, lineno int32) (r int32) { + return _sqlite3ReportError(tls, int32(SQLITE_CANTOPEN), lineno, __ccgo_ts+26254) +} + +// C documentation +// +// /* +// ** Close an existing SQLite database +// */ +func _sqlite3Close(tls *libc.TLS, db uintptr, forceZombie int32) (r int32) { + var p uintptr + _ = p + if !(db != 0) { + /* EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or + ** sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. */ + return SQLITE_OK + } + if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) { + return _sqlite3MisuseError(tls, int32(188460)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_CLOSE) != 0 { + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_CLOSE), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, db, uintptr(0)) + } + /* Force xDisconnect calls on all virtual tables */ + _disconnectAllVtab(tls, db) + /* If a transaction is open, the disconnectAllVtab() call above + ** will not have called the xDisconnect() method on any virtual + ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback() + ** call will do so. We need to do this before the check for active + ** SQL statements below, as the v-table implementation may be storing + ** some prepared statements internally. + */ + _sqlite3VtabRollback(tls, db) + /* Legacy behavior (sqlite3_close() behavior) is to return + ** SQLITE_BUSY if the connection can not be closed immediately. + */ + if !(forceZombie != 0) && _connectionIsBusy(tls, db) != 0 { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_BUSY), __ccgo_ts+25222, 0) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return int32(SQLITE_BUSY) + } + for (*Tsqlite3)(unsafe.Pointer(db)).FpDbData != 0 { + p = (*Tsqlite3)(unsafe.Pointer(db)).FpDbData + (*Tsqlite3)(unsafe.Pointer(db)).FpDbData = (*TDbClientData)(unsafe.Pointer(p)).FpNext + if (*TDbClientData)(unsafe.Pointer(p)).FxDestructor != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TDbClientData)(unsafe.Pointer(p)).FxDestructor})))(tls, (*TDbClientData)(unsafe.Pointer(p)).FpData) + } + Xsqlite3_free(tls, p) + } + /* Convert the connection into a zombie and then close it. + */ + (*Tsqlite3)(unsafe.Pointer(db)).FeOpenState = uint8(SQLITE_STATE_ZOMBIE) + _sqlite3LeaveMutexAndCloseZombie(tls, db) + return SQLITE_OK +} + +func _sqlite3CorruptError(tls *libc.TLS, lineno int32) (r int32) { + return _sqlite3ReportError(tls, int32(SQLITE_CORRUPT), lineno, __ccgo_ts+26227) +} + +// C documentation +// +// /* +// ** Invoke this routine to register the "dbpage" virtual table module +// */ +func _sqlite3DbpageRegister(tls *libc.TLS, db uintptr) (r int32) { + return Xsqlite3_create_module(tls, db, __ccgo_ts+35111, uintptr(unsafe.Pointer(&_dbpage_module)), uintptr(0)) +} + +// C documentation +// +// /* +// ** Invoke this routine to register the "dbstat" virtual table module +// */ +func _sqlite3DbstatRegister(tls *libc.TLS, db uintptr) (r int32) { + return Xsqlite3_create_module(tls, db, __ccgo_ts+34926, uintptr(unsafe.Pointer(&_dbstat_module)), uintptr(0)) +} + +// C documentation +// +// /* +// ** Generate VDBE code for a COMMIT or ROLLBACK statement. +// ** Code for ROLLBACK is generated if eType==TK_ROLLBACK. Otherwise +// ** code is generated for a COMMIT. +// */ +func _sqlite3EndTransaction(tls *libc.TLS, pParse uintptr, eType int32) { + var isRollback int32 + var v, v1 uintptr + _, _, _ = isRollback, v, v1 + isRollback = libc.BoolInt32(eType == int32(TK_ROLLBACK)) + if isRollback != 0 { + v1 = __ccgo_ts + 16109 + } else { + v1 = __ccgo_ts + 16118 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_TRANSACTION), v1, uintptr(0), uintptr(0)) != 0 { + return + } + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AutoCommit), int32(1), isRollback) + } +} + +// C documentation +// +// /* +// ** Write code that will raise an error if the table described by +// ** zDb and zTab is not empty. +// */ +func _sqlite3ErrorIfNotEmpty(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zErr uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10251, libc.VaList(bp+8, zErr, zDb, zTab)) +} + +// C documentation +// +// /* +// ** Check to see if a function is usable according to current access +// ** rules: +// ** +// ** SQLITE_FUNC_DIRECT - Only usable from top-level SQL +// ** +// ** SQLITE_FUNC_UNSAFE - Usable if TRUSTED_SCHEMA or from +// ** top-level SQL +// ** +// ** If the function is not usable, create an error. +// */ +func _sqlite3ExprFunctionUsable(tls *libc.TLS, pParse uintptr, pExpr uintptr, pDef uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) != uint32(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_FROM_DDL) != 0 { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_DIRECT) != uint32(0) || (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_TrustedSchema) == uint64(0) { + /* Functions prohibited in triggers and views if: + ** (1) tagged with SQLITE_DIRECTONLY + ** (2) not tagged with SQLITE_INNOCUOUS (which means it + ** is tagged with SQLITE_FUNC_UNSAFE) and + ** SQLITE_DBCONFIG_TRUSTED_SCHEMA is off (meaning + ** that the schema is possibly tainted). + */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8039, libc.VaList(bp+8, pExpr)) + } + } +} + +// C documentation +// +// /* +// ** Report an error when attempting to use an ORDER BY clause within +// ** the arguments of a non-aggregate function. +// */ +func _sqlite3ExprOrderByAggregateError(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7989, libc.VaList(bp+8, p)) +} + +// C documentation +// +// /* +// ** Create the shadow table named zPost, with definition zDefn. Return +// ** SQLITE_OK if successful, or an SQLite error code otherwise. +// */ +func _sqlite3Fts5CreateTable(tls *libc.TLS, pConfig uintptr, zPost uintptr, zDefn uintptr, bWithout int32, pzErr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var rc int32 + var v1 uintptr + var _ /* zErr at bp+0 */ uintptr + _, _ = rc, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if bWithout != 0 { + v1 = __ccgo_ts + 32014 + } else { + v1 = __ccgo_ts + 1704 + } + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, bp, __ccgo_ts+41419, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zPost, zDefn, v1)) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+41449, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zPost, **(**uintptr)(__ccgo_up(bp)))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Drop all shadow tables. Return SQLITE_OK if successful or an SQLite error +// ** code otherwise. +// */ +func _sqlite3Fts5DropAll(tls *libc.TLS, pConfig uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var rc int32 + _ = rc + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41197, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41301, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41339, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + return rc +} + +// C documentation +// +// /* +// ** Apply colset pColset to expression node pExpr and all of its descendents. +// */ +func _sqlite3Fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pExpr uintptr, pColset uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* pFree at bp+0 */ uintptr + **(**uintptr)(__ccgo_up(bp)) = pColset + if (*TFts5Config)(unsafe.Pointer((*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38570, 0) + } else { + _fts5ParseSetColset(tls, pParse, pExpr, pColset, bp) + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) +} + +// C documentation +// +// /* +// ** Delete all entries in the FTS5 index. +// */ +func _sqlite3Fts5StorageDeleteAll(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pConfig uintptr + var rc int32 + _, _ = pConfig, rc + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + (*TFts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0 + /* Delete the contents of the %_data and %_docsize tables. */ + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41625, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41675, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_UNINDEXED) { + rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41704, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + } + /* Reinitialize the %_data table. This call creates the initial structure + ** and averages records. */ + if rc == SQLITE_OK { + rc = _sqlite3Fts5IndexReinit(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5StorageConfigValue(tls, p, __ccgo_ts+38399, uintptr(0), int32(FTS5_CURRENT_VERSION)) + } + return rc +} + +func _sqlite3Fts5StorageRename(tls *libc.TLS, pStorage uintptr, zName uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pConfig uintptr + var _ /* rc at bp+0 */ int32 + _ = pConfig + pConfig = (*TFts5Storage)(unsafe.Pointer(pStorage)).FpConfig + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageSync(tls, pStorage) + _fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+27339, zName) + _fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+13044, zName) + _fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+40531, zName) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + _fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+38217, zName) + } + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { + _fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+37522, zName) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Return true if the tokenizer described by p->azArg[] is the trigram +// ** tokenizer. This tokenizer needs to be loaded before xBestIndex is +// ** called for the first time in order to correctly handle LIKE/GLOB. +// */ +func _sqlite3Fts5TokenizerPreload(tls *libc.TLS, p uintptr) (r int32) { + return libc.BoolInt32((*TFts5TokenizerConfig)(unsafe.Pointer(p)).FnArg >= int32(1) && 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up((*TFts5TokenizerConfig)(unsafe.Pointer(p)).FazArg)), __ccgo_ts+42136)) +} + +func _sqlite3Fts5VocabInit(tls *libc.TLS, pGlobal uintptr, db uintptr) (r int32) { + var p uintptr + _ = p + p = pGlobal + return Xsqlite3_create_module_v2(tls, db, __ccgo_ts+42460, uintptr(unsafe.Pointer(&_fts5Vocab)), p, uintptr(0)) +} + +// C documentation +// +// /* +// ** This function is responsible for invoking the collation factory callback +// ** or substituting a collation sequence of a different encoding when the +// ** requested collation sequence is not available in the desired encoding. +// ** +// ** If it is not NULL, then pColl must point to the database native encoding +// ** collation sequence with name zName, length nName. +// ** +// ** The return value is either the collation sequence to be used in database +// ** db for collation type name zName, length nName, or NULL, if no collation +// ** sequence can be found. If no collation is found, leave an error message. +// ** +// ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq() +// */ +func _sqlite3GetCollSeq(tls *libc.TLS, pParse uintptr, enc Tu8, pColl uintptr, zName uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, p uintptr + _, _ = db, p + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = pColl + if !(p != 0) { + p = _sqlite3FindCollSeq(tls, db, enc, zName, 0) + } + if !(p != 0) || !((*TCollSeq)(unsafe.Pointer(p)).FxCmp != 0) { + /* No collation sequence of this type for this encoding is registered. + ** Call the collation factory to see if it can supply us with one. + */ + _callCollNeeded(tls, db, libc.Int32FromUint8(enc), zName) + p = _sqlite3FindCollSeq(tls, db, enc, zName, 0) + } + if p != 0 && !((*TCollSeq)(unsafe.Pointer(p)).FxCmp != 0) && _synthCollSeq(tls, db, p) != 0 { + p = uintptr(0) + } + if p == uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16314, libc.VaList(bp+8, zName)) + (*TParse)(unsafe.Pointer(pParse)).Frc = libc.Int32FromInt32(SQLITE_ERROR) | libc.Int32FromInt32(1)< generate an error message and return 1. +// ** If pTab is writable but other errors have occurred -> return 1. +// ** If pTab is writable and no prior errors -> return 0; +// */ +func _sqlite3IsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr, pTrigger uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + if _tabIsReadOnly(tls, pParse, pTab) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16378, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(1) + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) && (pTrigger == uintptr(0) || (*TTrigger)(unsafe.Pointer(pTrigger)).FbReturning != 0 && (*TTrigger)(unsafe.Pointer(pTrigger)).FpNext == uintptr(0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16407, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Return TRUE if the given string is a row-id column name. +// */ +func _sqlite3IsRowid(tls *libc.TLS, z uintptr) (r int32) { + if _sqlite3StrICmp(tls, z, __ccgo_ts+8189) == 0 { + return int32(1) + } + if _sqlite3StrICmp(tls, z, __ccgo_ts+8197) == 0 { + return int32(1) + } + if _sqlite3StrICmp(tls, z, __ccgo_ts+8203) == 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Check the input string to see if it is "true" or "false" (in any case). +// ** +// ** If the string is.... Return +// ** "true" EP_IsTrue +// ** "false" EP_IsFalse +// ** anything else 0 +// */ +func _sqlite3IsTrueOrFalse(tls *libc.TLS, zIn uintptr) (r Tu32) { + if _sqlite3StrICmp(tls, zIn, __ccgo_ts+8178) == 0 { + return uint32(EP_IsTrue) + } + if _sqlite3StrICmp(tls, zIn, __ccgo_ts+8183) == 0 { + return uint32(EP_IsFalse) + } + return uint32(0) +} + +func _sqlite3MisuseError(tls *libc.TLS, lineno int32) (r int32) { + return _sqlite3ReportError(tls, int32(SQLITE_MISUSE), lineno, __ccgo_ts+26247) +} + +// C documentation +// +// /* +// ** Open the sqlite_schema table stored in database number iDb for +// ** writing. The table is opened using cursor 0. +// */ +func _sqlite3OpenSchemaTable(tls *libc.TLS, p uintptr, iDb int32) { + var v uintptr + _ = v + v = _sqlite3GetVdbe(tls, p) + _sqlite3TableLock(tls, p, iDb, uint32(SCHEMA_ROOT), uint8(1), __ccgo_ts+6284) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_OpenWrite), 0, int32(SCHEMA_ROOT), iDb, int32(5)) + if (*TParse)(unsafe.Pointer(p)).FnTab == 0 { + (*TParse)(unsafe.Pointer(p)).FnTab = int32(1) + } +} + +// C documentation +// +// /* +// ** This function is called when the user invokes "PRAGMA wal_checkpoint", +// ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint() +// ** or wal_blocking_checkpoint() API functions. +// ** +// ** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART. +// */ +func _sqlite3PagerCheckpoint(tls *libc.TLS, pPager uintptr, db uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) (r int32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + rc = SQLITE_OK + if (*TPager)(unsafe.Pointer(pPager)).FpWal == uintptr(0) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_WAL) { + /* This only happens when a database file is zero bytes in size opened and + ** then "PRAGMA journal_mode=WAL" is run and then sqlite3_wal_checkpoint() + ** is invoked without any intervening transactions. We need to start + ** a transaction to initialize pWal. The PRAGMA table_list statement is + ** used for this since it starts transactions on every database file, + ** including all ATTACHed databases. This seems expensive for a single + ** sqlite3_wal_checkpoint() call, but it happens very rarely. + ** https://sqlite.org/forum/forumpost/fd0f19d229156939 + */ + Xsqlite3_exec(tls, db, __ccgo_ts+4258, uintptr(0), uintptr(0), uintptr(0)) + } + if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + if eMode <= SQLITE_CHECKPOINT_PASSIVE { + v1 = uintptr(0) + } else { + v1 = (*TPager)(unsafe.Pointer(pPager)).FxBusyHandler + } + rc = _sqlite3WalCheckpoint(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, db, eMode, v1, (*TPager)(unsafe.Pointer(pPager)).FpBusyHandlerArg, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FwalSyncFlags), int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace, pnLog, pnCkpt) + } + return rc +} + +// C documentation +// +// /* +// ** Return the preferred table name for system tables. Translate legacy +// ** names into the new preferred names, as appropriate. +// */ +func _sqlite3PreferredTableName(tls *libc.TLS, zName uintptr) (r uintptr) { + if Xsqlite3_strnicmp(tls, zName, __ccgo_ts+6756, int32(7)) == 0 { + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6284+7) == 0 { + return __ccgo_ts + 6802 + } + if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6764+7) == 0 { + return __ccgo_ts + 6783 + } + } + return zName +} + +// C documentation +// +// /* +// ** Re-register the built-in LIKE functions. The caseSensitive +// ** parameter determines whether or not the LIKE operator is case +// ** sensitive. +// */ +func _sqlite3RegisterLikeFunctions(tls *libc.TLS, db uintptr, caseSensitive int32) { + var flags, nArg int32 + var pDef, pInfo uintptr + _, _, _, _ = flags, nArg, pDef, pInfo + if caseSensitive != 0 { + pInfo = uintptr(unsafe.Pointer(&_likeInfoAlt)) + flags = libc.Int32FromInt32(SQLITE_FUNC_LIKE) | libc.Int32FromInt32(SQLITE_FUNC_CASE) + } else { + pInfo = uintptr(unsafe.Pointer(&_likeInfoNorm)) + flags = int32(SQLITE_FUNC_LIKE) + } + nArg = int32(2) + for { + if !(nArg <= int32(3)) { + break + } + _sqlite3CreateFunc(tls, db, __ccgo_ts+16605, nArg, int32(SQLITE_UTF8), pInfo, __ccgo_fp(_likeFunc), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + pDef = _sqlite3FindFunction(tls, db, __ccgo_ts+16605, nArg, uint8(SQLITE_UTF8), uint8(0)) + /* The sqlite3CreateFunc() call above cannot fail + ** because the "like" SQL-function already exists */ + **(**Tu32)(__ccgo_up(pDef + 4)) |= libc.Uint32FromInt32(flags) + **(**Tu32)(__ccgo_up(pDef + 4)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) + goto _1 + _1: + ; + nArg = nArg + 1 + } +} + +// C documentation +// +// /* +// ** This routine does per-connection function registration. Most +// ** of the built-in functions above are part of the global function set. +// ** This routine only deals with those that are not global. +// */ +func _sqlite3RegisterPerConnectionBuiltinFunctions(tls *libc.TLS, db uintptr) { + var rc int32 + _ = rc + rc = Xsqlite3_overload_function(tls, db, __ccgo_ts+16599, int32(2)) + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } +} + +// C documentation +// +// /* +// ** The following routines are substitutes for constants SQLITE_CORRUPT, +// ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_NOMEM and possibly other error +// ** constants. They serve two purposes: +// ** +// ** 1. Serve as a convenient place to set a breakpoint in a debugger +// ** to detect when version error conditions occurs. +// ** +// ** 2. Invoke sqlite3_log() to provide the source code location where +// ** a low-level error is first detected. +// */ +func _sqlite3ReportError(tls *libc.TLS, iErr int32, lineno int32, zType uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + Xsqlite3_log(tls, iErr, __ccgo_ts+26202, libc.VaList(bp+8, zType, lineno, uintptr(20)+Xsqlite3_sourceid(tls))) + return iErr +} + +// C documentation +// +// /* +// ** Use the content of the StrAccum passed as the second argument +// ** as the result of an SQL function. +// */ +func _sqlite3ResultStrAccum(tls *libc.TLS, pCtx uintptr, p uintptr) { + if (*TStrAccum)(unsafe.Pointer(p)).FaccError != 0 { + Xsqlite3_result_error_code(tls, pCtx, libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FaccError)) + Xsqlite3_str_reset(tls, p) + } else { + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&int32(SQLITE_PRINTF_MALLOCED) != 0 { + Xsqlite3_result_text(tls, pCtx, (*TStrAccum)(unsafe.Pointer(p)).FzText, libc.Int32FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar), __ccgo_fp(_sqlite3RowSetClear)) + } else { + Xsqlite3_result_text(tls, pCtx, __ccgo_ts+1704, 0, libc.UintptrFromInt32(0)) + Xsqlite3_str_reset(tls, p) + } + } +} + +// C documentation +// +// /* +// ** Register the r-tree module with database handle db. This creates the +// ** virtual table module "rtree" and the debugging/analysis scalar +// ** function "rtreenode". +// */ +func _sqlite3RtreeInit(tls *libc.TLS, db uintptr) (r int32) { + var c, c1 uintptr + var rc, utf8 int32 + _, _, _, _ = c, c1, rc, utf8 + utf8 = int32(SQLITE_UTF8) + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+30160, int32(2), utf8, uintptr(0), __ccgo_fp(_rtreenode), uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+30170, int32(1), utf8, uintptr(0), __ccgo_fp(_rtreedepth), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = Xsqlite3_create_function(tls, db, __ccgo_ts+30181, -int32(1), utf8, uintptr(0), __ccgo_fp(_rtreecheck), uintptr(0), uintptr(0)) + } + if rc == SQLITE_OK { + c = libc.UintptrFromInt32(RTREE_COORD_REAL32) + rc = Xsqlite3_create_module_v2(tls, db, __ccgo_ts+29904, uintptr(unsafe.Pointer(&_rtreeModule)), c, uintptr(0)) + } + if rc == SQLITE_OK { + c1 = libc.UintptrFromInt32(RTREE_COORD_INT32) + rc = Xsqlite3_create_module_v2(tls, db, __ccgo_ts+30192, uintptr(unsafe.Pointer(&_rtreeModule)), c1, uintptr(0)) + } + if rc == SQLITE_OK { + rc = _sqlite3_geopoly_init(tls, db) + } + return rc +} + +// C documentation +// +// /* +// ** Check to make sure we have a valid db pointer. This test is not +// ** foolproof but it does provide some measure of protection against +// ** misuse of the interface such as passing in db pointers that are +// ** NULL or which have been previously closed. If this routine returns +// ** 1 it means that the db pointer is valid and 0 if it should not be +// ** dereferenced for any reason. The calling function should invoke +// ** SQLITE_MISUSE immediately. +// ** +// ** sqlite3SafetyCheckOk() requires that the db pointer be valid for +// ** use. sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to +// ** open properly and is not fit for general use but which can be +// ** used as an argument to sqlite3_errmsg() or sqlite3_close(). +// */ +func _sqlite3SafetyCheckOk(tls *libc.TLS, db uintptr) (r int32) { + var eOpenState Tu8 + _ = eOpenState + if db == uintptr(0) { + _logBadConnection(tls, __ccgo_ts+1705) + return 0 + } + eOpenState = (*Tsqlite3)(unsafe.Pointer(db)).FeOpenState + if libc.Int32FromUint8(eOpenState) != int32(SQLITE_STATE_OPEN) { + if _sqlite3SafetyCheckSickOrOk(tls, db) != 0 { + _logBadConnection(tls, __ccgo_ts+1897) + } + return 0 + } else { + return int32(1) + } + return r +} + +func _sqlite3SafetyCheckSickOrOk(tls *libc.TLS, db uintptr) (r int32) { + var eOpenState Tu8 + _ = eOpenState + eOpenState = (*Tsqlite3)(unsafe.Pointer(db)).FeOpenState + if libc.Int32FromUint8(eOpenState) != int32(SQLITE_STATE_SICK) && libc.Int32FromUint8(eOpenState) != int32(SQLITE_STATE_OPEN) && libc.Int32FromUint8(eOpenState) != int32(SQLITE_STATE_BUSY) { + _logBadConnection(tls, __ccgo_ts+1906) + return 0 + } else { + return int32(1) + } + return r +} + +// C documentation +// +// /* +// ** Name of the connection operator, used for error messages. +// */ +func _sqlite3SelectOpName(tls *libc.TLS, id int32) (r uintptr) { + var z uintptr + _ = z + switch id { + case int32(TK_ALL): + z = __ccgo_ts + 20485 + case int32(TK_INTERSECT): + z = __ccgo_ts + 20495 + case int32(TK_EXCEPT): + z = __ccgo_ts + 20505 + default: + z = __ccgo_ts + 20512 + break + } + return z +} + +// C documentation +// +// /* +// ** Error message for when two or more terms of a compound select have different +// ** size result sets. +// */ +func _sqlite3SelectWrongNumTermsError(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Values) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20824, 0) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20870, libc.VaList(bp+8, _sqlite3SelectOpName(tls, libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop)))) + } +} + +var _sqlite3StdType = [6]uintptr{ + 0: __ccgo_ts + 1165, + 1: __ccgo_ts + 1169, + 2: __ccgo_ts + 1174, + 3: __ccgo_ts + 1178, + 4: __ccgo_ts + 1186, + 5: __ccgo_ts + 1191, +} + +/************** End of global.c **********************************************/ +/************** Begin file status.c ******************************************/ +/* +** 2008 June 18 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This module implements the sqlite3_status() interface and related +** functionality. + */ +/* #include "sqliteInt.h" */ +/************** Include vdbeInt.h in the middle of status.c ******************/ +/************** Begin file vdbeInt.h *****************************************/ +/* +** 2003 September 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This is the header file for information that is private to the +** VDBE. This information used to all be at the top of the single +** source code file "vdbe.c". When that file became too big (over +** 6000 lines long) it was split up into several smaller files and +** this header information was factored out. + */ + +/* +** The maximum number of times that a statement will try to reparse +** itself before giving up and returning SQLITE_SCHEMA. + */ + +/* +** VDBE_DISPLAY_P4 is true or false depending on whether or not the +** "explain" P4 display logic is enabled. + */ + +// C documentation +// +// /* +// ** Load the Parse object passed as the first argument with an error +// ** message of the form: +// ** +// ** "sub-select returns N columns - expected M" +// */ +func _sqlite3SubselectError(tls *libc.TLS, pParse uintptr, nActual int32, nExpect int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var zFmt uintptr + _ = zFmt + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + zFmt = __ccgo_ts + 8285 + _sqlite3ErrorMsg(tls, pParse, zFmt, libc.VaList(bp+8, nActual, nExpect)) + } +} + +// C documentation +// +// /* The table or view or trigger name is passed to this routine via tokens +// ** pName1 and pName2. If the table name was fully qualified, for example: +// ** +// ** CREATE TABLE xxx.yyy (...); +// ** +// ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if +// ** the table name is not fully qualified, i.e.: +// ** +// ** CREATE TABLE yyy(...); +// ** +// ** Then pName1 is set to "yyy" and pName2 is "". +// ** +// ** This routine sets the *ppUnqual pointer to point at the token (pName1 or +// ** pName2) that stores the unqualified table name. The index of the +// ** database "xxx" is returned. +// */ +func _sqlite3TwoPartName(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pUnqual uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db uintptr + var iDb int32 + _, _ = db, iDb /* Database holding the object */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TToken)(unsafe.Pointer(pName2)).Fn > uint32(0) { + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13726, 0) + return -int32(1) + } + **(**uintptr)(__ccgo_up(pUnqual)) = pName2 + iDb = _sqlite3FindDb(tls, db, pName1) + if iDb < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13743, libc.VaList(bp+8, pName1)) + return -int32(1) + } + } else { + iDb = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb) + **(**uintptr)(__ccgo_up(pUnqual)) = pName1 + } + return iDb +} + +// C documentation +// +// /* +// ** Window *pWin has just been created from a WINDOW clause. Token pBase +// ** is the base window. Earlier windows from the same WINDOW clause are +// ** stored in the linked list starting at pWin->pNextWin. This function +// ** either updates *pWin according to the base specification, or else +// ** leaves an error in pParse. +// */ +func _sqlite3WindowChain(tls *libc.TLS, pParse uintptr, pWin uintptr, pList uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pExist, zErr uintptr + _, _, _ = db, pExist, zErr + if (*TWindow)(unsafe.Pointer(pWin)).FzBase != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pExist = _windowFind(tls, pParse, pList, (*TWindow)(unsafe.Pointer(pWin)).FzBase) + if pExist != 0 { + zErr = uintptr(0) + /* Check for errors */ + if (*TWindow)(unsafe.Pointer(pWin)).FpPartition != 0 { + zErr = __ccgo_ts + 24422 + } else { + if (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy != 0 && (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy != 0 { + zErr = __ccgo_ts + 24439 + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pExist)).FbImplicitFrame) == 0 { + zErr = __ccgo_ts + 24455 + } + } + } + if zErr != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24475, libc.VaList(bp+8, zErr, (*TWindow)(unsafe.Pointer(pWin)).FzBase)) + } else { + (*TWindow)(unsafe.Pointer(pWin)).FpPartition = _sqlite3ExprListDup(tls, db, (*TWindow)(unsafe.Pointer(pExist)).FpPartition, 0) + if (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy != 0 { + (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy = _sqlite3ExprListDup(tls, db, (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy, 0) + } + _sqlite3DbFree(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FzBase) + (*TWindow)(unsafe.Pointer(pWin)).FzBase = uintptr(0) + } + } + } +} + +// C documentation +// +// /* +// ** An array of names of all compile-time options. This array should +// ** be sorted A-Z. +// ** +// ** This array looks large, but in a typical installation actually uses +// ** only a handful of compile-time options, so most times this array is usually +// ** rather short and uses little memory space. +// */ +var _sqlite3azCompileOpt = [56]uintptr{ + 0: __ccgo_ts, + 1: __ccgo_ts + 20, + 2: __ccgo_ts + 40, + 3: __ccgo_ts + 59, + 4: __ccgo_ts + 84, + 5: __ccgo_ts + 106, + 6: __ccgo_ts + 136, + 7: __ccgo_ts + 156, + 8: __ccgo_ts + 176, + 9: __ccgo_ts + 199, + 10: __ccgo_ts + 224, + 11: __ccgo_ts + 251, + 12: __ccgo_ts + 276, + 13: __ccgo_ts + 298, + 14: __ccgo_ts + 330, + 15: __ccgo_ts + 356, + 16: __ccgo_ts + 381, + 17: __ccgo_ts + 402, + 18: __ccgo_ts + 420, + 19: __ccgo_ts + 443, + 20: __ccgo_ts + 462, + 21: __ccgo_ts + 481, + 22: __ccgo_ts + 493, + 23: __ccgo_ts + 508, + 24: __ccgo_ts + 530, + 25: __ccgo_ts + 555, + 26: __ccgo_ts + 578, + 27: __ccgo_ts + 600, + 28: __ccgo_ts + 611, + 29: __ccgo_ts + 624, + 30: __ccgo_ts + 639, + 31: __ccgo_ts + 655, + 32: __ccgo_ts + 668, + 33: __ccgo_ts + 689, + 34: __ccgo_ts + 713, + 35: __ccgo_ts + 736, + 36: __ccgo_ts + 752, + 37: __ccgo_ts + 768, + 38: __ccgo_ts + 792, + 39: __ccgo_ts + 819, + 40: __ccgo_ts + 839, + 41: __ccgo_ts + 861, + 42: __ccgo_ts + 883, + 43: __ccgo_ts + 913, + 44: __ccgo_ts + 938, + 45: __ccgo_ts + 964, + 46: __ccgo_ts + 984, + 47: __ccgo_ts + 1010, + 48: __ccgo_ts + 1033, + 49: __ccgo_ts + 1059, + 50: __ccgo_ts + 1081, + 51: __ccgo_ts + 1102, + 52: __ccgo_ts + 1117, + 53: __ccgo_ts + 1125, + 54: __ccgo_ts + 1139, + 55: __ccgo_ts + 1152, +} + +// C documentation +// +// /* +// ** Write an error message into pParse->zErrMsg that explains that the +// ** user-supplied authorization function returned an illegal value. +// */ +func _sqliteAuthBadReturnCode(tls *libc.TLS, pParse uintptr) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13609, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) +} + +var _statGetFuncdef = TFuncDef{ + FnArg: int16(libc.Int32FromInt32(1) + libc.Int32FromInt32(IsStat4)), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 13021, +} + +var _statInitFuncdef = TFuncDef{ + FnArg: int16(4), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 12984, +} + +var _statPushFuncdef = TFuncDef{ + FnArg: int16(libc.Int32FromInt32(2) + libc.Int32FromInt32(IsStat4)), + FfuncFlags: uint32(SQLITE_UTF8), + FzName: __ccgo_ts + 12994, +} + +func _sumFinalize(tls *libc.TLS, context uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, context, 0) + if p != 0 && (*TSumCtx)(unsafe.Pointer(p)).Fcnt > 0 { + if (*TSumCtx)(unsafe.Pointer(p)).Fapprox != 0 { + if (*TSumCtx)(unsafe.Pointer(p)).Fovrfl != 0 { + Xsqlite3_result_error(tls, context, __ccgo_ts+16458, -int32(1)) + } else { + if !(_sqlite3IsOverflow(tls, (*TSumCtx)(unsafe.Pointer(p)).FrErr) != 0) { + Xsqlite3_result_double(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FrSum+(*TSumCtx)(unsafe.Pointer(p)).FrErr) + } else { + Xsqlite3_result_double(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FrSum) + } + } + } else { + Xsqlite3_result_int64(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FiSum) + } + } +} + +// C documentation +// +// /* +// ** Return true if it is not allowed to drop the given table +// */ +func _tableMayNotBeDropped(tls *libc.TLS, db uintptr, pTab uintptr) (r int32) { + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+6756, int32(7)) == 0 { + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName+uintptr(7), __ccgo_ts+3567, int32(4)) == 0 { + return 0 + } + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName+uintptr(7), __ccgo_ts+7558, int32(10)) == 0 { + return 0 + } + return int32(1) + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Shadow) != uint32(0) && _sqlite3ReadOnlyShadowTables(tls, db) != 0 { + return int32(1) + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Eponymous) != 0 { + return int32(1) + } + return 0 +} + +var _tkCoalesce = TToken{ + Fz: __ccgo_ts + 6961, + Fn: uint32(8), +} + +// C documentation +// +// /* +// ** Return a list of all triggers on table pTab if there exists at least +// ** one trigger that must be fired when an operation of type 'op' is +// ** performed on the table, and, if that operation is an UPDATE, if at +// ** least one of the columns in pChanges is being modified. +// */ +func _triggersReallyExist(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32, pChanges uintptr, pMask uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var mask int32 + var p, pList, v1 uintptr + _, _, _, _ = mask, p, pList, v1 + mask = 0 + pList = uintptr(0) + pList = _sqlite3TriggerList(tls, pParse, pTab) + if pList != uintptr(0) { + p = pList + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_EnableTrigger) == uint64(0) && (*TTable)(unsafe.Pointer(pTab)).FpTrigger != uintptr(0) && _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTrigger)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FpTrigger)).FpSchema) != int32(1) { + /* The SQLITE_DBCONFIG_ENABLE_TRIGGER setting is off. That means that + ** only TEMP triggers are allowed. Truncate the pList so that it + ** includes only TEMP triggers */ + if pList == (*TTable)(unsafe.Pointer(pTab)).FpTrigger { + pList = uintptr(0) + goto exit_triggers_exist + } + for (*TTrigger)(unsafe.Pointer(p)).FpNext != 0 && (*TTrigger)(unsafe.Pointer(p)).FpNext != (*TTable)(unsafe.Pointer(pTab)).FpTrigger { + p = (*TTrigger)(unsafe.Pointer(p)).FpNext + } + (*TTrigger)(unsafe.Pointer(p)).FpNext = uintptr(0) + p = pList + } + for cond := true; cond; cond = p != 0 { + if libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == op && _checkColumnOverlap(tls, (*TTrigger)(unsafe.Pointer(p)).FpColumns, pChanges) != 0 { + mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm) + } else { + if libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == int32(TK_RETURNING) { + /* The first time a RETURNING trigger is seen, the "op" value tells + ** us what time of trigger it should be. */ + (*TTrigger)(unsafe.Pointer(p)).Fop = libc.Uint8FromInt32(op) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + if op != int32(TK_INSERT) { + if op == int32(TK_DELETE) { + v1 = __ccgo_ts + 22420 + } else { + v1 = __ccgo_ts + 22427 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22434, libc.VaList(bp+8, v1)) + } + (*TTrigger)(unsafe.Pointer(p)).Ftr_tm = uint8(TRIGGER_BEFORE) + } else { + (*TTrigger)(unsafe.Pointer(p)).Ftr_tm = uint8(TRIGGER_AFTER) + } + mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm) + } else { + if (*TTrigger)(unsafe.Pointer(p)).FbReturning != 0 && libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == int32(TK_INSERT) && op == int32(TK_UPDATE) && (*TParse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) { + /* Also fire a RETURNING trigger for an UPSERT */ + mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm) + } + } + } + p = (*TTrigger)(unsafe.Pointer(p)).FpNext + } + } + goto exit_triggers_exist +exit_triggers_exist: + ; + if pMask != 0 { + **(**int32)(__ccgo_up(pMask)) = mask + } + if mask != 0 { + v1 = pList + } else { + v1 = uintptr(0) + } + return v1 +} + +// C documentation +// +// /* +// ** Delete the file at zPath. If the dirSync argument is true, fsync() +// ** the directory after deleting the file. +// */ +func _unixDelete(tls *libc.TLS, NotUsed uintptr, zPath uintptr, dirSync int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* fd at bp+0 */ int32 + _ = rc + rc = SQLITE_OK + _ = NotUsed + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(16)].FpCurrent})))(tls, zPath) == -int32(1) { + if **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(ENOENT) { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(23)< 0 { + nByte = (nByte + int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk) - int64(1)) / int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk) * int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk) + } + rc = _robust_ftruncate(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, nByte) + if rc != 0 { + _storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__errno_location(tls)))) + return _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(6)< nMax { + rx = _sqlite3OsTruncate(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, nMax) + } + _sqlite3EndBenignMalloc(tls) + if rx != 0 { + Xsqlite3_log(tls, rx, __ccgo_ts+4313, libc.VaList(bp+16, (*TWal)(unsafe.Pointer(pWal)).FzWalName)) + } +} + +// C documentation +// +// /* +// ** A "PRECEDING " (eCond==0) or "FOLLOWING " (eCond==1) or the +// ** value of the second argument to nth_value() (eCond==2) has just been +// ** evaluated and the result left in register reg. This function generates VM +// ** code to check that the value is a non-negative integer and throws an +// ** exception if it is not. +// */ +func _windowCheckValue(tls *libc.TLS, pParse uintptr, reg int32, eCond int32) { + var regString, regZero int32 + var v uintptr + _, _, _ = regString, regZero, v + v = _sqlite3GetVdbe(tls, pParse) + regZero = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regZero) + if eCond >= int32(WINDOW_STARTING_NUM) { + regString = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, regString, 0, __ccgo_ts+1704, -int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ge), regString, _sqlite3VdbeCurrentAddr(tls, v)+int32(2), reg) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(libc.Int32FromInt32(SQLITE_AFF_NUMERIC)|libc.Int32FromInt32(SQLITE_JUMPIFNULL))) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_MustBeInt), reg, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + } + _sqlite3VdbeAddOp3(tls, v, _aOp1[eCond], regZero, _sqlite3VdbeCurrentAddr(tls, v)+int32(2), reg) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_AFF_NUMERIC)) + /* NULL case captured by */ + /* the OP_MustBeInt */ + /* NULL case caught by */ + /* the OP_Ge */ + _sqlite3MayAbort(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), int32(SQLITE_ERROR), int32(OE_Abort)) + _sqlite3VdbeAppendP4(tls, v, _azErr[eCond], -int32(1)) + _sqlite3ReleaseTempReg(tls, pParse, regZero) +} + +func _windowFind(tls *libc.TLS, pParse uintptr, pList uintptr, zName uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p uintptr + _ = p + p = pList + for { + if !(p != 0) { + break + } + if _sqlite3StrICmp(tls, (*TWindow)(unsafe.Pointer(p)).FzName, zName) == 0 { + break + } + goto _1 + _1: + ; + p = (*TWindow)(unsafe.Pointer(p)).FpNextWin + } + if p == uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24211, libc.VaList(bp+8, zName)) + } + return p +} + +// C documentation +// +// /* +// ** The following routine is called if the stack overflows. +// */ +func _yyStackOverflow(tls *libc.TLS, yypParser uintptr) { + var pParse uintptr + _ = pParse + pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse + for (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos > (*TyyParser)(unsafe.Pointer(yypParser)).Fyystack { + _yy_pop_parser_stack(tls, yypParser) + } + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + /******** Begin %stack_overflow code ******************************************/ + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24914, 0) + } + /******** End %stack_overflow code ********************************************/ + /* Suppress warning about unused %extra_argument var */ + (*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse +} + +/* +** Print tracing information for a SHIFT action + */ diff --git a/internal/engine/lib/sqlite_g_0000000000003bc3.go b/internal/engine/lib/sqlite_g_0000000000003bc3.go new file mode 100644 index 0000000..790f15a --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003bc3.go @@ -0,0 +1,471 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Move an existing blob handle to point to a different row of the same +// ** database table. +// ** +// ** If an error occurs, or if the specified row does not exist or does not +// ** contain a blob or text value, then an error code is returned and the +// ** database handle error code and message set. If this happens, then all +// ** subsequent calls to sqlite3_blob_xxx() functions (except blob_close()) +// ** immediately return SQLITE_ABORT. +// */ +func Xsqlite3_blob_reopen(tls *libc.TLS, pBlob uintptr, iRow Tsqlite3_int64) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, v1 uintptr + var rc int32 + var _ /* zErr at bp+0 */ uintptr + _, _, _, _ = db, p, rc, v1 + p = pBlob + if p == uintptr(0) { + return _sqlite3MisuseError(tls, int32(106369)) + } + db = (*TIncrblob)(unsafe.Pointer(p)).Fdb + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if (*TIncrblob)(unsafe.Pointer(p)).FpStmt == uintptr(0) { + /* If there is no statement handle, then the blob-handle has + ** already been invalidated. Return SQLITE_ABORT in this case. + */ + rc = int32(SQLITE_ABORT) + } else { + (*TVdbe)(unsafe.Pointer((*TIncrblob)(unsafe.Pointer(p)).FpStmt)).Frc = SQLITE_OK + rc = _blobSeekToRow(tls, p, iRow, bp) + if rc != SQLITE_OK { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = __ccgo_ts + 3944 + } else { + v1 = libc.UintptrFromInt32(0) + } + _sqlite3ErrorWithMsg(tls, db, rc, v1, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp)))) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp))) + } + } + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +/************** End of vdbeblob.c ********************************************/ +/************** Begin file vdbesort.c ****************************************/ +/* +** 2011-07-09 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code for the VdbeSorter object, used in concert with +** a VdbeCursor to sort large numbers of keys for CREATE INDEX statements +** or by SELECT statements with ORDER BY clauses that cannot be satisfied +** using indexes and without LIMIT clauses. +** +** The VdbeSorter object implements a multi-threaded external merge sort +** algorithm that is efficient even if the number of elements being sorted +** exceeds the available memory. +** +** Here is the (internal, non-API) interface between this module and the +** rest of the SQLite system: +** +** sqlite3VdbeSorterInit() Create a new VdbeSorter object. +** +** sqlite3VdbeSorterWrite() Add a single new row to the VdbeSorter +** object. The row is a binary blob in the +** OP_MakeRecord format that contains both +** the ORDER BY key columns and result columns +** in the case of a SELECT w/ ORDER BY, or +** the complete record for an index entry +** in the case of a CREATE INDEX. +** +** sqlite3VdbeSorterRewind() Sort all content previously added. +** Position the read cursor on the +** first sorted element. +** +** sqlite3VdbeSorterNext() Advance the read cursor to the next sorted +** element. +** +** sqlite3VdbeSorterRowkey() Return the complete binary blob for the +** row currently under the read cursor. +** +** sqlite3VdbeSorterCompare() Compare the binary blob for the row +** currently under the read cursor against +** another binary blob X and report if +** X is strictly less than the read cursor. +** Used to enforce uniqueness in a +** CREATE UNIQUE INDEX statement. +** +** sqlite3VdbeSorterClose() Close the VdbeSorter object and reclaim +** all resources. +** +** sqlite3VdbeSorterReset() Refurbish the VdbeSorter for reuse. This +** is like Close() followed by Init() only +** much faster. +** +** The interfaces above must be called in a particular order. Write() can +** only occur in between Init()/Reset() and Rewind(). Next(), Rowkey(), and +** Compare() can only occur in between Rewind() and Close()/Reset(). i.e. +** +** Init() +** for each record: Write() +** Rewind() +** Rowkey()/Compare() +** Next() +** Close() +** +** Algorithm: +** +** Records passed to the sorter via calls to Write() are initially held +** unsorted in main memory. Assuming the amount of memory used never exceeds +** a threshold, when Rewind() is called the set of records is sorted using +** an in-memory merge sort. In this case, no temporary files are required +** and subsequent calls to Rowkey(), Next() and Compare() read records +** directly from main memory. +** +** If the amount of space used to store records in main memory exceeds the +** threshold, then the set of records currently in memory are sorted and +** written to a temporary file in "Packed Memory Array" (PMA) format. +** A PMA created at this point is known as a "level-0 PMA". Higher levels +** of PMAs may be created by merging existing PMAs together - for example +** merging two or more level-0 PMAs together creates a level-1 PMA. +** +** The threshold for the amount of main memory to use before flushing +** records to a PMA is roughly the same as the limit configured for the +** page-cache of the main database. Specifically, the threshold is set to +** the value returned by "PRAGMA main.page_size" multiplied by +** that returned by "PRAGMA main.cache_size", in bytes. +** +** If the sorter is running in single-threaded mode, then all PMAs generated +** are appended to a single temporary file. Or, if the sorter is running in +** multi-threaded mode then up to (N+1) temporary files may be opened, where +** N is the configured number of worker threads. In this case, instead of +** sorting the records and writing the PMA to a temporary file itself, the +** calling thread usually launches a worker thread to do so. Except, if +** there are already N worker threads running, the main thread does the work +** itself. +** +** The sorter is running in multi-threaded mode if (a) the library was built +** with pre-processor symbol SQLITE_MAX_WORKER_THREADS set to a value greater +** than zero, and (b) worker threads have been enabled at runtime by calling +** "PRAGMA threads=N" with some value of N greater than 0. +** +** When Rewind() is called, any data remaining in memory is flushed to a +** final PMA. So at this point the data is stored in some number of sorted +** PMAs within temporary files on disk. +** +** If there are fewer than SORTER_MAX_MERGE_COUNT PMAs in total and the +** sorter is running in single-threaded mode, then these PMAs are merged +** incrementally as keys are retrieved from the sorter by the VDBE. The +** MergeEngine object, described in further detail below, performs this +** merge. +** +** Or, if running in multi-threaded mode, then a background thread is +** launched to merge the existing PMAs. Once the background thread has +** merged T bytes of data into a single sorted PMA, the main thread +** begins reading keys from that PMA while the background thread proceeds +** with merging the next T bytes of data. And so on. +** +** Parameter T is set to half the value of the memory threshold used +** by Write() above to determine when to create a new PMA. +** +** If there are more than SORTER_MAX_MERGE_COUNT PMAs in total when +** Rewind() is called, then a hierarchy of incremental-merges is used. +** First, T bytes of data from the first SORTER_MAX_MERGE_COUNT PMAs on +** disk are merged together. Then T bytes of data from the second set, and +** so on, such that no operation ever merges more than SORTER_MAX_MERGE_COUNT +** PMAs at a time. This done is to improve locality. +** +** If running in multi-threaded mode and there are more than +** SORTER_MAX_MERGE_COUNT PMAs on disk when Rewind() is called, then more +** than one background thread may be created. Specifically, there may be +** one background thread for each temporary file on disk, and one background +** thread to merge the output of each of the others to a single PMA for +** the main thread to read from. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +/* +** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various +** messages to stderr that may be helpful in understanding the performance +** characteristics of the sorter in multi-threaded mode. + */ + +/* +** Hard-coded maximum amount of data to accumulate in memory before flushing +** to a level 0 PMA. The purpose of this limit is to prevent various integer +** overflows. 512MiB. + */ + +// C documentation +// +// /* +// ** Declare that a function has been overloaded by a virtual table. +// ** +// ** If the function already exists as a regular global function, then +// ** this routine is a no-op. If the function does not exist, then create +// ** a new one that always throws a run-time error. +// ** +// ** When virtual tables intend to provide an overloaded function, they +// ** should call this routine to make sure the global function exists. +// ** A global function must exist in order for name resolution to work +// ** properly. +// */ +func Xsqlite3_overload_function(tls *libc.TLS, db uintptr, zName uintptr, nArg int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var zCopy uintptr + _, _ = rc, zCopy + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + rc = libc.BoolInt32(_sqlite3FindFunction(tls, db, zName, nArg, uint8(SQLITE_UTF8), uint8(0)) != uintptr(0)) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if rc != 0 { + return SQLITE_OK + } + zCopy = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, zName)) + if zCopy == uintptr(0) { + return int32(SQLITE_NOMEM) + } + return Xsqlite3_create_function_v2(tls, db, zName, nArg, int32(SQLITE_UTF8), zCopy, __ccgo_fp(_sqlite3InvalidFunction), uintptr(0), uintptr(0), __ccgo_fp(Xsqlite3_free)) +} + +// C documentation +// +// /* +// ** Set the error code and error message associated with the database handle. +// ** +// ** This routine is intended to be called by outside extensions (ex: the +// ** Session extension). Internal logic should invoke sqlite3Error() or +// ** sqlite3ErrorWithMsg() directly. +// */ +func Xsqlite3_set_errmsg(tls *libc.TLS, db uintptr, errcode int32, zMsg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + _ = rc + rc = SQLITE_OK + if !(_sqlite3SafetyCheckOk(tls, db) != 0) { + return _sqlite3MisuseError(tls, int32(189943)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if zMsg != 0 { + _sqlite3ErrorWithMsg(tls, db, errcode, __ccgo_ts+3944, libc.VaList(bp+8, zMsg)) + } else { + _sqlite3Error(tls, db, errcode) + } + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Provide a database schema to the changegroup object. +// */ +func Xsqlite3changegroup_schema(tls *libc.TLS, pGrp uintptr, db uintptr, zDb uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + _ = rc + rc = SQLITE_OK + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList != 0 || (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb != 0 { + /* Cannot add a schema after one or more calls to sqlite3changegroup_add(), + ** or after sqlite3changegroup_schema() has already been called. */ + rc = int32(SQLITE_MISUSE) + } else { + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FzDb = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, zDb)) + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FzDb == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb = db + } + } + return rc +} + +func _fts5PrepareStatement(tls *libc.TLS, ppStmt uintptr, pConfig uintptr, zFmt uintptr, va uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ap Tva_list + var rc int32 + var zSql uintptr + var _ /* pRet at bp+0 */ uintptr + _, _, _ = ap, rc, zSql + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + ap = va + zSql = Xsqlite3_vmprintf(tls, zFmt, ap) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_prepare_v3(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -int32(1), uint32(SQLITE_PREPARE_PERSISTENT), bp, uintptr(0)) + if rc != SQLITE_OK { + _sqlite3Fts5ConfigErrmsg(tls, pConfig, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb))) + } + Xsqlite3_free(tls, zSql) + } + _ = ap + **(**uintptr)(__ccgo_up(ppStmt)) = **(**uintptr)(__ccgo_up(bp)) + return rc +} + +// C documentation +// +// /* +// ** Populate buffer zOut with the full canonical pathname corresponding +// ** to the pathname in zPath. zOut is guaranteed to point to a buffer +// ** of at least (INST_MAX_PATHNAME+1) bytes. +// */ +func _memdbFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + _ = pVfs + Xsqlite3_snprintf(tls, nOut, zOut, __ccgo_ts+3944, libc.VaList(bp+8, zPath)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Prepare the SQL statement in buffer zSql against database handle db. +// ** If successful, set *ppStmt to point to the new statement and return +// ** SQLITE_OK. +// ** +// ** Otherwise, if an error does occur, set *ppStmt to NULL and return +// ** an SQLite error code. Additionally, set output variable *pzErrmsg to +// ** point to a buffer containing an error message. It is the responsibility +// ** of the caller to (eventually) free this buffer using sqlite3_free(). +// */ +func _prepareAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg uintptr, zSql uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + _ = rc + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), ppStmt, uintptr(0)) + if rc != SQLITE_OK { + **(**uintptr)(__ccgo_up(pzErrmsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + } + return rc +} + +// C documentation +// +// /* +// ** Finalize the statement passed as the second argument. +// ** +// ** If the sqlite3_finalize() call indicates that an error occurs, and the +// ** rbu handle error code is not already set, set the error code and error +// ** message accordingly. +// */ +func _rbuFinalize(tls *libc.TLS, p uintptr, pStmt uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db uintptr + var rc int32 + _, _ = db, rc + db = Xsqlite3_db_handle(tls, pStmt) + rc = Xsqlite3_finalize(tls, pStmt) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && rc != SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + } +} + +func _rbuOpenDbhandle(tls *libc.TLS, p uintptr, zName uintptr, bUseVfs int32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var flags int32 + var v1 uintptr + var _ /* db at bp+0 */ uintptr + _, _ = flags, v1 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + flags = libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_URI) + if bUseVfs != 0 { + v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName + } else { + v1 = uintptr(0) + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_open_v2(tls, zName, bp, flags, v1) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+16, Xsqlite3_errmsg(tls, **(**uintptr)(__ccgo_up(bp))))) + Xsqlite3_close(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + return **(**uintptr)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Reset the SQL statement passed as the first argument. Return a copy +// ** of the value returned by sqlite3_reset(). +// ** +// ** If an error has occurred, then set *pzErrmsg to point to a buffer +// ** containing an error message. It is the responsibility of the caller +// ** to eventually free this buffer using sqlite3_free(). +// */ +func _resetAndCollectError(tls *libc.TLS, pStmt uintptr, pzErrmsg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + _ = rc + rc = Xsqlite3_reset(tls, pStmt) + if rc != SQLITE_OK { + **(**uintptr)(__ccgo_up(pzErrmsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, Xsqlite3_db_handle(tls, pStmt)))) + } + return rc +} + +func _sessionPrepare(tls *libc.TLS, db uintptr, pp uintptr, pzErrmsg uintptr, zSql uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + _ = rc + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), pp, uintptr(0)) + if pzErrmsg != 0 && rc != SQLITE_OK { + **(**uintptr)(__ccgo_up(pzErrmsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + } + return rc +} + +// C documentation +// +// /* +// ** SQLite calls this function immediately after a call to unixDlSym() or +// ** unixDlOpen() fails (returns a null pointer). If a more detailed error +// ** message is available, it is written to zBufOut. If no error message +// ** is available, zBufOut is left unmodified and SQLite uses a default +// ** error message. +// */ +func _unixDlError(tls *libc.TLS, NotUsed uintptr, nBuf int32, zBufOut uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var zErr uintptr + _ = zErr + _ = NotUsed + _unixEnterMutex(tls) + zErr = libc.Xdlerror(tls) + if zErr != 0 { + Xsqlite3_snprintf(tls, nBuf, zBufOut, __ccgo_ts+3944, libc.VaList(bp+8, zErr)) + } + _unixLeaveMutex(tls) +} diff --git a/internal/engine/lib/sqlite_g_0000000000003e00.go b/internal/engine/lib/sqlite_g_0000000000003e00.go new file mode 100644 index 0000000..cd592bc --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003e00.go @@ -0,0 +1,11 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +const __FP_FAST_FMAF32 = 1 + +const __FP_FAST_FMAF32x = 1 + +const __FP_FAST_FMAF64 = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000003e80.go b/internal/engine/lib/sqlite_g_0000000000003e80.go new file mode 100644 index 0000000..eeffa12 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003e80.go @@ -0,0 +1,882 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const F_GETLK = 5 + +const F_GETLK64 = 5 + +const F_SETLK = 6 + +const F_SETLK64 = 6 + +const F_SETLKW = 7 + +const F_SETLKW64 = 7 + +const SIOCGSTAMP = 35078 + +const SIOCGSTAMPNS = 35079 + +type Tcpu_set_t = struct { + F__bits [16]uint64 +} + +type Tfd_set = struct { + Ffds_bits [16]uint64 +} + +type Tpthread_attr_t = struct { + F__u struct { + F__vi [0][14]int32 + F__s [0][7]uint64 + F__i [14]int32 + } +} + +type Tpthread_barrier_t = struct { + F__u struct { + F__vi [0][8]int32 + F__p [0][4]uintptr + F__i [8]int32 + } +} + +type Tpthread_cond_t = struct { + F__u struct { + F__vi [0][12]int32 + F__p [0][6]uintptr + F__i [12]int32 + } +} + +type Tpthread_mutex_t = struct { + F__u struct { + F__vi [0][10]int32 + F__p [0][5]uintptr + F__i [10]int32 + } +} + +type Tpthread_rwlock_t = struct { + F__u struct { + F__vi [0][14]int32 + F__p [0][7]uintptr + F__i [14]int32 + } +} + +type Tsched_param = struct { + Fsched_priority int32 + F__reserved1 int32 + F__reserved2 [2]struct { + F__reserved1 Ttime_t + F__reserved2 int64 + } + F__reserved3 int32 +} + +type Tsigset_t = struct { + F__bits [16]uint64 +} + +// C documentation +// +// /* +// ** Initialize SQLite. +// ** +// ** This routine must be called to initialize the memory allocation, +// ** VFS, and mutex subsystems prior to doing any serious work with +// ** SQLite. But as long as you do not compile with SQLITE_OMIT_AUTOINIT +// ** this routine will be called automatically by key routines such as +// ** sqlite3_open(). +// ** +// ** This routine is a no-op except on its very first call for the process, +// ** or for the first call after a call to sqlite3_shutdown. +// ** +// ** The first thread to call this routine runs the initialization to +// ** completion. If subsequent threads call this routine before the first +// ** thread has finished the initialization process, then the subsequent +// ** threads must block until the first thread finishes with the initialization. +// ** +// ** The first thread might call this routine recursively. Recursive +// ** calls to this routine should not block, of course. Otherwise the +// ** initialization process would never complete. +// ** +// ** Let X be the first thread to enter this routine. Let Y be some other +// ** thread. Then while the initial invocation of this routine by X is +// ** incomplete, it is required that: +// ** +// ** * Calls to this routine from Y must block until the outer-most +// ** call by X completes. +// ** +// ** * Recursive calls to this routine from thread X return immediately +// ** without blocking. +// */ +func Xsqlite3_initialize(tls *libc.TLS) (r int32) { + var pMainMtx uintptr + var rc int32 + _, _ = pMainMtx, rc /* Result code */ + /* If the following assert() fails on some obscure processor/compiler + ** combination, the work-around is to set the correct pointer + ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */ + /* If SQLite is already completely initialized, then this call + ** to sqlite3_initialize() should be a no-op. But the initialization + ** must be complete. So isInit must not be set until the very end + ** of this routine. + */ + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340) != 0 { + _sqlite3MemoryBarrier(tls) + return SQLITE_OK + } + /* Make sure the mutex subsystem is initialized. If unable to + ** initialize the mutex subsystem, return early with the error. + ** If the system is so sick that we are unable to allocate a mutex, + ** there is not much SQLite is going to be able to do. + ** + ** The mutex subsystem must take care of serializing its own + ** initialization. + */ + rc = _sqlite3MutexInit(tls) + if rc != 0 { + return rc + } + /* Initialize the malloc() system and the recursive pInitMutex mutex. + ** This operation is protected by the STATIC_MAIN mutex. Note that + ** MutexAlloc() is called for a static mutex prior to initializing the + ** malloc subsystem - this implies that the allocation of a static + ** mutex must not require support from the malloc subsystem. + */ + pMainMtx = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + Xsqlite3_mutex_enter(tls, pMainMtx) + _sqlite3Config.FisMutexInit = int32(1) + if !(_sqlite3Config.FisMallocInit != 0) { + rc = _sqlite3MallocInit(tls) + } + if rc == SQLITE_OK { + _sqlite3Config.FisMallocInit = int32(1) + if !(_sqlite3Config.FpInitMutex != 0) { + _sqlite3Config.FpInitMutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_RECURSIVE)) + if _sqlite3Config.FbCoreMutex != 0 && !(_sqlite3Config.FpInitMutex != 0) { + rc = int32(SQLITE_NOMEM) + } + } + } + if rc == SQLITE_OK { + _sqlite3Config.FnRefInitMutex = _sqlite3Config.FnRefInitMutex + 1 + } + Xsqlite3_mutex_leave(tls, pMainMtx) + /* If rc is not SQLITE_OK at this point, then either the malloc + ** subsystem could not be initialized or the system failed to allocate + ** the pInitMutex mutex. Return an error in either case. */ + if rc != SQLITE_OK { + return rc + } + /* Do the rest of the initialization under the recursive mutex so + ** that we will be able to handle recursive calls into + ** sqlite3_initialize(). The recursive calls normally come through + ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other + ** recursive calls might also be possible. + ** + ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls + ** to the xInit method, so the xInit method need not be threadsafe. + ** + ** The following mutex is what serializes access to the appdef pcache xInit + ** methods. The sqlite3_pcache_methods.xInit() all is embedded in the + ** call to sqlite3PcacheInitialize(). + */ + Xsqlite3_mutex_enter(tls, _sqlite3Config.FpInitMutex) + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340) == 0 && _sqlite3Config.FinProgress == 0 { + _sqlite3Config.FinProgress = int32(1) + libc.Xmemset(tls, uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)), 0, uint64(184)) + _sqlite3RegisterBuiltinFunctions(tls) + if _sqlite3Config.FisPCacheInit == 0 { + rc = _sqlite3PcacheInitialize(tls) + } + if rc == SQLITE_OK { + _sqlite3Config.FisPCacheInit = int32(1) + rc = _sqlite3OsInit(tls) + } + if rc == SQLITE_OK { + rc = _sqlite3MemdbInit(tls) + } + if rc == SQLITE_OK { + _sqlite3PCacheBufferSetup(tls, _sqlite3Config.FpPage, _sqlite3Config.FszPage, _sqlite3Config.FnPage) + } + if rc == SQLITE_OK { + _sqlite3MemoryBarrier(tls) + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340, int32(1)) + } + _sqlite3Config.FinProgress = 0 + } + Xsqlite3_mutex_leave(tls, _sqlite3Config.FpInitMutex) + /* Go back under the static mutex and clean up the recursive + ** mutex to prevent a resource leak. + */ + Xsqlite3_mutex_enter(tls, pMainMtx) + _sqlite3Config.FnRefInitMutex = _sqlite3Config.FnRefInitMutex - 1 + if _sqlite3Config.FnRefInitMutex <= 0 { + Xsqlite3_mutex_free(tls, _sqlite3Config.FpInitMutex) + _sqlite3Config.FpInitMutex = uintptr(0) + } + Xsqlite3_mutex_leave(tls, pMainMtx) + /* The following is just a sanity check to make sure SQLite has + ** been compiled correctly. It is important to run this code, but + ** we don't want to run it too often and soak up CPU cycles for no + ** reason. So we run it once during initialization. + */ + /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT + ** compile-time option. + */ + return rc +} + +const __INT_FAST16_MAX__ = 9223372036854775807 + +const __INT_FAST16_WIDTH__ = 64 + +const __INT_FAST32_MAX__ = 9223372036854775807 + +const __INT_FAST32_WIDTH__ = 64 + +const __UINT_FAST16_MAX__ = 18446744073709551615 + +const __UINT_FAST32_MAX__ = 18446744073709551615 + +// C documentation +// +// /* +// ** Lower the locking level on file descriptor pFile to eFileLock. eFileLock +// ** must be either NO_LOCK or SHARED_LOCK. +// ** +// ** If the locking level of the file descriptor is already at or below +// ** the requested locking level, this routine is a no-op. +// ** +// ** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED +// ** the byte range is divided into 2 parts and the first part is unlocked then +// ** set to a read lock, then the other part is simply unlocked. This works +// ** around a bug in BSD NFS lockd (also seen on MacOSX 10.3+) that fails to +// ** remove the write lock on a region when a read lock is set. +// */ +func _posixUnlock(tls *libc.TLS, id uintptr, eFileLock int32, handleNFSUnlock int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pFile, pInode uintptr + var rc int32 + var v1 Toff_t + var _ /* lock at bp+0 */ Tflock + _, _, _, _ = pFile, pInode, rc, v1 + pFile = id + rc = SQLITE_OK + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) <= eFileLock { + return SQLITE_OK + } + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) > int32(SHARED_LOCK) { + /* downgrading to a shared lock on NFS involves clearing the write lock + ** before establishing the readlock - to avoid a race condition we downgrade + ** the lock in 2 blocks, so that part of the range will be covered by a + ** write lock until the rest is covered by a read lock: + ** 1: [WWWWW] + ** 2: [....W] + ** 3: [RRRRW] + ** 4: [RRRR.] + */ + if eFileLock == int32(SHARED_LOCK) { + _ = handleNFSUnlock + (**(**Tflock)(__ccgo_up(bp))).Fl_type = F_RDLCK + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0 + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(2)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(SHARED_SIZE) + if _unixFileLock(tls, pFile, bp) != 0 { + /* In theory, the call to unixFileLock() cannot fail because another + ** process is holding an incompatible lock. If it does, this + ** indicates that the other process is not following the locking + ** protocol. If this happens, return SQLITE_IOERR_RDLOCK. Returning + ** SQLITE_BUSY would confuse the upper layer (in practice it causes + ** an assert to fail). */ + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(9)< +// **
  • SQLITE_MUTEX_FAST +// **
  • SQLITE_MUTEX_RECURSIVE +// **
  • SQLITE_MUTEX_STATIC_MAIN +// **
  • SQLITE_MUTEX_STATIC_MEM +// **
  • SQLITE_MUTEX_STATIC_OPEN +// **
  • SQLITE_MUTEX_STATIC_PRNG +// **
  • SQLITE_MUTEX_STATIC_LRU +// **
  • SQLITE_MUTEX_STATIC_PMEM +// **
  • SQLITE_MUTEX_STATIC_APP1 +// **
  • SQLITE_MUTEX_STATIC_APP2 +// **
  • SQLITE_MUTEX_STATIC_APP3 +// **
  • SQLITE_MUTEX_STATIC_VFS1 +// **
  • SQLITE_MUTEX_STATIC_VFS2 +// **
  • SQLITE_MUTEX_STATIC_VFS3 +// ** +// ** +// ** The first two constants cause sqlite3_mutex_alloc() to create +// ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE +// ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. +// ** The mutex implementation does not need to make a distinction +// ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does +// ** not want to. But SQLite will only request a recursive mutex in +// ** cases where it really needs one. If a faster non-recursive mutex +// ** implementation is available on the host platform, the mutex subsystem +// ** might return such a mutex in response to SQLITE_MUTEX_FAST. +// ** +// ** The other allowed parameters to sqlite3_mutex_alloc() each return +// ** a pointer to a static preexisting mutex. Six static mutexes are +// ** used by the current version of SQLite. Future versions of SQLite +// ** may add additional static mutexes. Static mutexes are for internal +// ** use by SQLite only. Applications that use SQLite mutexes should +// ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or +// ** SQLITE_MUTEX_RECURSIVE. +// ** +// ** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST +// ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() +// ** returns a different mutex on every call. But for the static +// ** mutex types, the same mutex is returned on every call that has +// ** the same type number. +// */ +func _pthreadMutexAlloc(tls *libc.TLS, iType int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p uintptr + var _ /* recursiveAttr at bp+0 */ Tpthread_mutexattr_t + _ = p + switch iType { + case int32(SQLITE_MUTEX_RECURSIVE): + p = _sqlite3MallocZero(tls, uint64(40)) + if p != 0 { + libc.Xpthread_mutexattr_init(tls, bp) + libc.Xpthread_mutexattr_settype(tls, bp, int32(PTHREAD_MUTEX_RECURSIVE)) + libc.Xpthread_mutex_init(tls, p, bp) + libc.Xpthread_mutexattr_destroy(tls, bp) + } + case SQLITE_MUTEX_FAST: + p = _sqlite3MallocZero(tls, uint64(40)) + if p != 0 { + libc.Xpthread_mutex_init(tls, p, uintptr(0)) + } + default: + p = uintptr(unsafe.Pointer(&_staticMutexes)) + uintptr(iType-int32(2))*40 + break + } + return p +} + +// C documentation +// +// /* +// ** Seek to the offset passed as the second argument, then read cnt +// ** bytes into pBuf. Return the number of bytes actually read. +// ** +// ** To avoid stomping the errno value on a failed read the lastErrno value +// ** is set before returning. +// */ +func _seekAndRead(tls *libc.TLS, id uintptr, offset Tsqlite3_int64, pBuf uintptr, cnt int32) (r int32) { + var got, prior int32 + _, _ = got, prior + prior = 0 + for cond := true; cond; cond = got > 0 { + got = int32((*(*func(*libc.TLS, int32, uintptr, Tsize_t, Toff_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(9)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(id)).Fh, pBuf, libc.Uint64FromInt32(cnt), offset)) + if got == cnt { + break + } + if got < 0 { + if **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(EINTR) { + got = int32(1) + continue + } + prior = 0 + _storeLastErrno(tls, id, **(**int32)(__ccgo_up(libc.X__errno_location(tls)))) + break + } else { + if got > 0 { + cnt = cnt - got + offset = offset + int64(got) + prior = prior + got + pBuf = uintptr(got) + pBuf + } + } + } + return got + prior +} + +// C documentation +// +// /* +// ** Attempt to seek the file-descriptor passed as the first argument to +// ** absolute offset iOff, then attempt to write nBuf bytes of data from +// ** pBuf to it. If an error occurs, return -1 and set *piErrno. Otherwise, +// ** return the actual number of bytes written (which may be less than +// ** nBuf). +// */ +func _seekAndWriteFd(tls *libc.TLS, fd int32, iOff Ti64, pBuf uintptr, nBuf int32, piErrno uintptr) (r int32) { + var rc int32 + _ = rc + rc = 0 /* Value returned by system call */ + nBuf = nBuf & int32(0x1ffff) + for cond := true; cond; cond = rc < 0 && **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(EINTR) { + rc = int32((*(*func(*libc.TLS, int32, uintptr, Tsize_t, Toff_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(12)].FpCurrent})))(tls, fd, pBuf, libc.Uint64FromInt32(nBuf), iOff)) + } + if rc < 0 { + **(**int32)(__ccgo_up(piErrno)) = **(**int32)(__ccgo_up(libc.X__errno_location(tls))) + } + return rc +} + +func _sqlite3MutexInit(tls *libc.TLS) (r int32) { + mu.Lock() + defer mu.Unlock() + var pFrom, pTo uintptr + var rc int32 + _, _, _ = pFrom, pTo, rc + rc = SQLITE_OK + if !(_sqlite3Config.Fmutex.FxMutexAlloc != 0) { + pTo = uintptr(unsafe.Pointer(&_sqlite3Config)) + 96 + if _sqlite3Config.FbCoreMutex != 0 { + pFrom = _sqlite3DefaultMutex(tls) + } else { + pFrom = _sqlite3NoopMutex(tls) + } + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexInit = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexInit + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexEnd = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexEnd + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexFree = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexFree + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexEnter = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexEnter + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexTry = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexTry + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexLeave = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexLeave + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexHeld = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexHeld + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexNotheld = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexNotheld + _sqlite3MemoryBarrier(tls) + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexAlloc = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexAlloc + } + rc = (*(*func(*libc.TLS) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexInit})))(tls) + _sqlite3MemoryBarrier(tls) + return rc +} + +// C documentation +// +// /* Create a new thread */ +func _sqlite3ThreadCreate(tls *libc.TLS, ppThread uintptr, __ccgo_fp_xTask uintptr, pIn uintptr) (r int32) { + var p uintptr + var rc int32 + _, _ = p, rc + /* This routine is never used in single-threaded mode */ + **(**uintptr)(__ccgo_up(ppThread)) = uintptr(0) + p = _sqlite3Malloc(tls, uint64(40)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, p, 0, uint64(40)) + (*TSQLiteThread)(unsafe.Pointer(p)).FxTask = __ccgo_fp_xTask + (*TSQLiteThread)(unsafe.Pointer(p)).FpIn = pIn + /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a + ** function that returns SQLITE_ERROR when passed the argument 200, that + ** forces worker threads to run sequentially and deterministically + ** for testing purposes. */ + if _sqlite3FaultSim(tls, int32(200)) != 0 { + rc = int32(1) + } else { + rc = libc.Xpthread_create(tls, p, uintptr(0), __ccgo_fp_xTask, pIn) + } + if rc != 0 { + (*TSQLiteThread)(unsafe.Pointer(p)).Fdone = int32(1) + (*TSQLiteThread)(unsafe.Pointer(p)).FpOut = (*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xTask})))(tls, pIn) + } + **(**uintptr)(__ccgo_up(ppThread)) = p + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Use F_GETLK to check whether or not there are any readers with open +// ** wal-mode transactions in other processes on database file pFile. If +// ** no error occurs, return SQLITE_OK and set (*piOut) to 1 if there are +// ** such transactions, or 0 otherwise. If an error occurs, return an +// ** SQLite error code. The final value of *piOut is undefined in this +// ** case. +// */ +func _unixFcntlExternalReader(tls *libc.TLS, pFile uintptr, piOut uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pShmNode uintptr + var rc int32 + var _ /* f at bp+0 */ Tflock + _, _ = pShmNode, rc + rc = SQLITE_OK + **(**int32)(__ccgo_up(piOut)) = 0 + if (*TunixFile)(unsafe.Pointer(pFile)).FpShm != 0 { + pShmNode = (*TunixShm)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpShm)).FpShmNode + libc.Xmemset(tls, bp, 0, uint64(32)) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0 + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64((libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4) + libc.Int32FromInt32(3)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(libc.Int32FromInt32(SQLITE_SHM_NLOCK) - libc.Int32FromInt32(3)) + Xsqlite3_mutex_enter(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int32(F_GETLK), libc.VaList(bp+40, bp)) < 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(15)<=3 && ofst int32(1) { + bUnlock = 0 + **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) = **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) - 1 + v1 = p + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromUint16(mask)) + } + } + if bUnlock != 0 { + rc = _unixShmSystemLock(tls, pDbFd, int32(F_UNLCK), ofst+(libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4), n) + if rc == SQLITE_OK { + libc.Xmemset(tls, aLock+uintptr(ofst)*4, 0, uint64(4)*libc.Uint64FromInt32(n)) + v1 = p + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromUint16(mask)) + v1 = p + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromUint16(mask)) + } + } + } else { + if flags&int32(SQLITE_SHM_SHARED) != 0 { + /* Case (b) - a shared lock. */ + if **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) < 0 { + /* An exclusive lock is held by some other connection. BUSY. */ + rc = int32(SQLITE_BUSY) + } else { + if **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) == 0 { + rc = _unixShmSystemLock(tls, pDbFd, F_RDLCK, ofst+(libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4), n) + } + } + /* Get the local shared locks */ + if rc == SQLITE_OK { + v1 = p + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16(mask)) + **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) = **(**int32)(__ccgo_up(aLock + uintptr(ofst)*4)) + 1 + } + } else { + /* Make sure no sibling connections hold locks that will block this + ** lock. If any do, return SQLITE_BUSY right away. */ + ii = ofst + for { + if !(ii < ofst+n) { + break + } + if **(**int32)(__ccgo_up(aLock + uintptr(ii)*4)) != 0 { + rc = int32(SQLITE_BUSY) + break + } + goto _5 + _5: + ; + ii = ii + 1 + } + /* Get the exclusive locks at the system level. Then if successful + ** also update the in-memory values. */ + if rc == SQLITE_OK { + rc = _unixShmSystemLock(tls, pDbFd, int32(F_WRLCK), ofst+(libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4), n) + if rc == SQLITE_OK { + v1 = p + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16(mask)) + ii = ofst + for { + if !(ii < ofst+n) { + break + } + **(**int32)(__ccgo_up(aLock + uintptr(ii)*4)) = -int32(1) + goto _7 + _7: + ; + ii = ii + 1 + } + } + } + } + } + } + /* Drop the mutexes acquired above. */ + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + } + return rc +} + +func init() { + p := unsafe.Pointer(&_aSyscall) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_posixOpen) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(libc.Xclose) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(libc.Xaccess) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(libc.Xgetcwd) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(libc.Xstat) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(libc.Xfstat) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(libc.Xftruncate) + *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(libc.Xfcntl) + *(*uintptr)(unsafe.Add(p, 200)) = __ccgo_fp(libc.Xread) + *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(libc.Xpread) + *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(libc.Xwrite) + *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(libc.Xpwrite) + *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(libc.Xfchmod) + *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(libc.Xunlink) + *(*uintptr)(unsafe.Add(p, 416)) = __ccgo_fp(_openDirectory) + *(*uintptr)(unsafe.Add(p, 440)) = __ccgo_fp(libc.Xmkdir) + *(*uintptr)(unsafe.Add(p, 464)) = __ccgo_fp(libc.Xrmdir) + *(*uintptr)(unsafe.Add(p, 488)) = __ccgo_fp(libc.Xfchown) + *(*uintptr)(unsafe.Add(p, 512)) = __ccgo_fp(libc.Xgeteuid) + *(*uintptr)(unsafe.Add(p, 536)) = __ccgo_fp(libc.Xmmap) + *(*uintptr)(unsafe.Add(p, 560)) = __ccgo_fp(libc.Xmunmap) + *(*uintptr)(unsafe.Add(p, 584)) = __ccgo_fp(libc.Xmremap) + *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(_unixGetpagesize) + *(*uintptr)(unsafe.Add(p, 632)) = __ccgo_fp(libc.Xreadlink) + *(*uintptr)(unsafe.Add(p, 656)) = __ccgo_fp(libc.Xlstat) +} + +/* End of the overrideable system calls */ + +func init() { + p := unsafe.Pointer(&_sMutex1) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_pthreadMutexInit) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_pthreadMutexEnd) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_pthreadMutexAlloc) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_pthreadMutexFree) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_pthreadMutexEnter) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_pthreadMutexTry) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_pthreadMutexLeave) +} + +/************** End of mutex_unix.c ******************************************/ +/************** Begin file mutex_w32.c ***************************************/ +/* +** 2007 August 14 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the C functions that implement mutexes for Win32. + */ +/* #include "sqliteInt.h" */ + +/* +** The code in this file is only used if we are compiling multithreaded +** on a Win32 system. + */ + +/************** End of mutex_w32.c *******************************************/ +/************** Begin file malloc.c ******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** Memory allocation functions used throughout sqlite. + */ +/* #include "sqliteInt.h" */ +/* #include */ diff --git a/internal/engine/lib/sqlite_g_0000000000003e83.go b/internal/engine/lib/sqlite_g_0000000000003e83.go new file mode 100644 index 0000000..759eb10 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003e83.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +const _POSIX_V6_LP64_OFF64 = 1 + +const _POSIX_V7_LP64_OFF64 = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000003ea8.go b/internal/engine/lib/sqlite_g_0000000000003ea8.go new file mode 100644 index 0000000..a1afcbe --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003ea8.go @@ -0,0 +1,231 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type Tfd_mask = uint64 + +const __LONG_MAX = 9223372036854775807 + +// C documentation +// +// /* +// ** This function performs the parts of the "close file" operation +// ** common to all locking schemes. It closes the directory and file +// ** handles, if they are valid, and sets all fields of the unixFile +// ** structure to 0. +// ** +// ** It is *not* necessary to hold the mutex when this routine is called, +// ** even on VxWorks. A mutex will be acquired on VxWorks by the +// ** vxworksReleaseFileId() routine. +// */ +func _closeUnixFile(tls *libc.TLS, id uintptr) (r int32) { + var pFile uintptr + _ = pFile + pFile = id + _unixUnmapfile(tls, pFile) + if (*TunixFile)(unsafe.Pointer(pFile)).Fh >= 0 { + _robust_close(tls, pFile, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(42499)) + (*TunixFile)(unsafe.Pointer(pFile)).Fh = -int32(1) + } + Xsqlite3_free(tls, (*TunixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused) + libc.Xmemset(tls, pFile, 0, uint64(120)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Obtain a reference to a memory mapped page object for page number pgno. +// ** The new object will use the pointer pData, obtained from xFetch(). +// ** If successful, set *ppPage to point to the new page reference +// ** and return SQLITE_OK. Otherwise, return an SQLite error code and set +// ** *ppPage to zero. +// ** +// ** Page references obtained by calling this function should be released +// ** by calling pagerReleaseMapPage(). +// */ +func _pagerAcquireMapPage(tls *libc.TLS, pPager uintptr, pgno TPgno, pData uintptr, ppPage uintptr) (r int32) { + var p, v1 uintptr + _, _ = p, v1 /* Memory mapped page to return */ + if (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist != 0 { + v1 = (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist + p = v1 + **(**uintptr)(__ccgo_up(ppPage)) = v1 + (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + (*TPgHdr)(unsafe.Pointer(p)).FpDirty = uintptr(0) + libc.Xmemset(tls, (*TPgHdr)(unsafe.Pointer(p)).FpExtra, 0, uint64(8)) + } else { + v1 = _sqlite3MallocZero(tls, uint64(80)+uint64((*TPager)(unsafe.Pointer(pPager)).FnExtra)) + p = v1 + **(**uintptr)(__ccgo_up(ppPage)) = v1 + if p == uintptr(0) { + _sqlite3OsUnfetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1))*(*TPager)(unsafe.Pointer(pPager)).FpageSize, pData) + return int32(SQLITE_NOMEM) + } + (*TPgHdr)(unsafe.Pointer(p)).FpExtra = p + 1*80 + (*TPgHdr)(unsafe.Pointer(p)).Fflags = uint16(PGHDR_MMAP) + (*TPgHdr)(unsafe.Pointer(p)).FnRef = int64(1) + (*TPgHdr)(unsafe.Pointer(p)).FpPager = pPager + } + (*TPgHdr)(unsafe.Pointer(p)).Fpgno = pgno + (*TPgHdr)(unsafe.Pointer(p)).FpData = pData + (*TPager)(unsafe.Pointer(pPager)).FnMmapOut = (*TPager)(unsafe.Pointer(pPager)).FnMmapOut + 1 + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Find the current time (in Universal Coordinated Time). Write into *piNow +// ** the current time and date as a Julian Day number times 86_400_000. In +// ** other words, write into *piNow the number of milliseconds since the Julian +// ** epoch of noon in Greenwich on November 24, 4714 B.C according to the +// ** proleptic Gregorian calendar. +// ** +// ** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date +// ** cannot be found. +// */ +func _unixCurrentTimeInt64(tls *libc.TLS, NotUsed uintptr, piNow uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* sNow at bp+0 */ Ttimeval + _ = rc + rc = SQLITE_OK + libc.Xgettimeofday(tls, bp, uintptr(0)) /* Cannot fail given valid arguments */ + **(**Tsqlite3_int64)(__ccgo_up(piNow)) = _unixEpoch + int64(1000)*int64((**(**Ttimeval)(__ccgo_up(bp))).Ftv_sec) + int64((**(**Ttimeval)(__ccgo_up(bp))).Ftv_usec/int64(1000)) + _ = NotUsed + return rc +} + +// C documentation +// +// /* +// ** Read data from a file into a buffer. Return SQLITE_OK if all +// ** bytes were read successfully and SQLITE_IOERR if anything goes +// ** wrong. +// */ +func _unixRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Tsqlite3_int64) (r int32) { + var got, nCopy int32 + var pFile uintptr + _, _, _ = got, nCopy, pFile + pFile = id + /* If this is a database file (not a journal, super-journal or temp + ** file), the bytes in the locking range should never be read or written. */ + /* Deal with as much of this read request as possible by transferring + ** data from the memory mapping using memcpy(). */ + if offset < (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize { + if offset+int64(amt) <= (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize { + libc.Xmemcpy(tls, pBuf, (*TunixFile)(unsafe.Pointer(pFile)).FpMapRegion+uintptr(offset), libc.Uint64FromInt32(amt)) + return SQLITE_OK + } else { + nCopy = int32((*TunixFile)(unsafe.Pointer(pFile)).FmmapSize - offset) + libc.Xmemcpy(tls, pBuf, (*TunixFile)(unsafe.Pointer(pFile)).FpMapRegion+uintptr(offset), libc.Uint64FromInt32(nCopy)) + pBuf = pBuf + uintptr(nCopy) + amt = amt - nCopy + offset = offset + int64(nCopy) + } + } + got = _seekAndRead(tls, pFile, offset, pBuf, amt) + if got == amt { + return SQLITE_OK + } else { + if got < 0 { + /* pFile->lastErrno has been set by seekAndRead(). + ** Usually we return SQLITE_IOERR_READ here, though for some + ** kinds of errors we return SQLITE_IOERR_CORRUPTFS. The + ** SQLITE_IOERR_CORRUPTFS will be converted into SQLITE_CORRUPT + ** prior to returning to the application by the sqlite3ApiExit() + ** routine. + */ + switch (*TunixFile)(unsafe.Pointer(pFile)).FlastErrno { + case int32(ERANGE): + fallthrough + case int32(EIO): + fallthrough + case int32(ENXIO): + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(33)< int32(63) || libc.Uint64FromInt32(1)< int64(SQLITE_MAX_MMAP_SIZE) { + mxMmap = int64(SQLITE_MAX_MMAP_SIZE) + } + if szMmap < 0 { + szMmap = SQLITE_DEFAULT_MMAP_SIZE + } + if szMmap > mxMmap { + szMmap = mxMmap + } + _sqlite3Config.FmxMmap = mxMmap + _sqlite3Config.FszMmap = szMmap + case int32(SQLITE_CONFIG_PMASZ): + _sqlite3Config.FszPma = libc.VaUint32(&ap) + case int32(SQLITE_CONFIG_STMTJRNL_SPILL): + _sqlite3Config.FnStmtSpill = libc.VaInt32(&ap) + case int32(SQLITE_CONFIG_MEMDB_MAXSIZE): + _sqlite3Config.FmxMemdbSize = libc.VaInt64(&ap) + case int32(SQLITE_CONFIG_ROWID_IN_VIEW): + pVal = libc.VaUintptr(&ap) + **(**int32)(__ccgo_up(pVal)) = 0 + default: + rc = int32(SQLITE_ERROR) + break + } + _ = ap + return rc +} + +// C documentation +// +// /* The page getter for when memory-mapped I/O is enabled */ +func _getPageMMap(tls *libc.TLS, pPager uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bMmapOk, rc int32 + var _ /* iFrame at bp+8 */ Tu32 + var _ /* pData at bp+16 */ uintptr + var _ /* pPg at bp+0 */ uintptr + _, _ = bMmapOk, rc + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(0) /* Frame to read from WAL file */ + /* It is acceptable to use a read-only (mmap) page for any page except + ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY + ** flag was specified by the caller. And so long as the db is not a + ** temporary or in-memory database. */ + bMmapOk = libc.BoolInt32(pgno > uint32(1) && (libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_READER) || flags&int32(PAGER_GET_READONLY) != 0)) + /* Optimization note: Adding the "pgno<=1" term before "pgno==0" here + ** allows the compiler optimizer to reuse the results of the "pgno>1" + ** test in the previous statement, and avoid testing pgno==0 in the + ** common case where pgno is large. */ + if pgno <= uint32(1) && pgno == uint32(0) { + return _sqlite3CorruptError(tls, int32(65272)) + } + if bMmapOk != 0 && (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + rc = _sqlite3WalFindFrame(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pgno, bp+8) + if rc != SQLITE_OK { + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return rc + } + } + if bMmapOk != 0 && **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0) { + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + rc = _sqlite3OsFetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1))*(*TPager)(unsafe.Pointer(pPager)).FpageSize, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), bp+16) + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 16)) != 0 { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) > int32(PAGER_READER) || (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 { + **(**uintptr)(__ccgo_up(bp)) = _sqlite3PagerLookup(tls, pPager, pgno) + } + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + rc = _pagerAcquireMapPage(tls, pPager, pgno, **(**uintptr)(__ccgo_up(bp + 16)), bp) + } else { + _sqlite3OsUnfetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1))*(*TPager)(unsafe.Pointer(pPager)).FpageSize, **(**uintptr)(__ccgo_up(bp + 16))) + } + if **(**uintptr)(__ccgo_up(bp)) != 0 { + **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up(bp)) + return SQLITE_OK + } + } + if rc != SQLITE_OK { + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return rc + } + } + return _getPageNormal(tls, pPager, pgno, ppPage, flags) +} + +// C documentation +// +// /* +// ** If pFd->sectorSize is non-zero when this function is called, it is a +// ** no-op. Otherwise, the values of pFd->sectorSize and +// ** pFd->deviceCharacteristics are set according to the file-system +// ** characteristics. +// ** +// ** There are two versions of this function. One for QNX and one for all +// ** other systems. +// */ +func _setDeviceCharacteristics(tls *libc.TLS, pFd uintptr) { + if (*TunixFile)(unsafe.Pointer(pFd)).FsectorSize == 0 { + /* Set the POWERSAFE_OVERWRITE flag if requested. */ + if libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFd)).FctrlFlags)&int32(UNIXFILE_PSOW) != 0 { + **(**int32)(__ccgo_up(pFd + 116)) |= int32(SQLITE_IOCAP_POWERSAFE_OVERWRITE) + } + **(**int32)(__ccgo_up(pFd + 116)) |= int32(SQLITE_IOCAP_SUBPAGE_READ) + (*TunixFile)(unsafe.Pointer(pFd)).FsectorSize = int32(SQLITE_DEFAULT_SECTOR_SIZE) + } +} + +// C documentation +// +// /* +// ** If it is currently memory mapped, unmap file pFd. +// */ +func _unixUnmapfile(tls *libc.TLS, pFd uintptr) { + if (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion != 0 { + (*(*func(*libc.TLS, uintptr, Tsize_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(23)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion, libc.Uint64FromInt64((*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeActual)) + (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion = uintptr(0) + (*TunixFile)(unsafe.Pointer(pFd)).FmmapSize = 0 + (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeActual = 0 + } +} diff --git a/internal/engine/lib/sqlite_g_0000000000003ec0.go b/internal/engine/lib/sqlite_g_0000000000003ec0.go new file mode 100644 index 0000000..055095e --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003ec0.go @@ -0,0 +1,48 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +type Tflock = struct { + Fl_type int16 + Fl_whence int16 + Fl_start Toff_t + Fl_len Toff_t + Fl_pid Tpid_t +} + +type Tmax_align_t = struct { + F__ll int64 + F__ld float64 +} + +type Tstatx = struct { + Fstx_mask Tuint32_t + Fstx_blksize Tuint32_t + Fstx_attributes Tuint64_t + Fstx_nlink Tuint32_t + Fstx_uid Tuint32_t + Fstx_gid Tuint32_t + Fstx_mode Tuint16_t + F__pad0 [1]Tuint16_t + Fstx_ino Tuint64_t + Fstx_size Tuint64_t + Fstx_blocks Tuint64_t + Fstx_attributes_mask Tuint64_t + Fstx_atime Tstatx_timestamp + Fstx_btime Tstatx_timestamp + Fstx_ctime Tstatx_timestamp + Fstx_mtime Tstatx_timestamp + Fstx_rdev_major Tuint32_t + Fstx_rdev_minor Tuint32_t + Fstx_dev_major Tuint32_t + Fstx_dev_minor Tuint32_t + F__pad1 [14]Tuint64_t +} + +type Tstatx_timestamp = struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + F__pad Tuint32_t +} diff --git a/internal/engine/lib/sqlite_g_0000000000003eec.go b/internal/engine/lib/sqlite_g_0000000000003eec.go new file mode 100644 index 0000000..d5c41c1 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003eec.go @@ -0,0 +1,33 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +// C documentation +// +// /* +// ** The unixFile structure is subclass of sqlite3_file specific to the unix +// ** VFS implementations. +// */ +type TunixFile = struct { + FpMethod uintptr + FpVfs uintptr + FpInode uintptr + Fh int32 + FeFileLock uint8 + FctrlFlags uint16 + FlastErrno int32 + FlockingContext uintptr + FpPreallocatedUnused uintptr + FzPath uintptr + FpShm uintptr + FszChunk int32 + FnFetchOut int32 + FmmapSize Tsqlite3_int64 + FmmapSizeActual Tsqlite3_int64 + FmmapSizeMax Tsqlite3_int64 + FpMapRegion uintptr + FsectorSize int32 + FdeviceCharacteristics int32 +} diff --git a/internal/engine/lib/sqlite_g_0000000000003f80.go b/internal/engine/lib/sqlite_g_0000000000003f80.go new file mode 100644 index 0000000..8305afb --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003f80.go @@ -0,0 +1,159 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** This routine checks if there is a RESERVED lock held on the specified +// ** file by this or any other process. If such a lock is held, set *pResOut +// ** to a non-zero value otherwise *pResOut is set to zero. The return value +// ** is set to SQLITE_OK unless an I/O error occurs during lock checking. +// */ +func _unixCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pFile uintptr + var rc, reserved int32 + var _ /* lock at bp+0 */ Tflock + _, _, _ = pFile, rc, reserved + rc = SQLITE_OK + reserved = 0 + pFile = id + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex) + /* Check if a thread in this process holds such a lock */ + if libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FeFileLock) > int32(SHARED_LOCK) { + reserved = int32(1) + } + /* Otherwise see if some other process holds it. + */ + if !(reserved != 0) && !((*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FbProcessLock != 0) { + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0 + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(1)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(F_GETLK), libc.VaList(bp+40, bp)) != 0 { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(14)<iBusyTimeout +** value is set, then it is the number of milliseconds to wait before +** failing the lock. The iBusyTimeout value is always reset back to +** zero on each call. +** +** If SQLITE_ENABLE_SETLK_TIMEOUT is not defined, then do a non-blocking +** attempt to set the lock. + */ + +// C documentation +// +// /* +// ** Attempt to set a system-lock on the file pFile. The lock is +// ** described by pLock. +// ** +// ** If the pFile was opened read/write from unix-excl, then the only lock +// ** ever obtained is an exclusive lock, and it is obtained exactly once +// ** the first time any lock is attempted. All subsequent system locking +// ** operations become no-ops. Locking operations still happen internally, +// ** in order to coordinate access between separate database connections +// ** within this process, but all of that is handled in memory and the +// ** operating system does not participate. +// ** +// ** This function is a pass-through to fcntl(F_SETLK) if pFile is using +// ** any VFS other than "unix-excl" or if pFile is opened on "unix-excl" +// ** and is read-only. +// ** +// ** Zero is returned if the call completes successfully, or -1 if a call +// ** to fcntl() fails. In this case, errno is set appropriately (by fcntl()). +// */ +func _unixFileLock(tls *libc.TLS, pFile uintptr, pLock uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pInode uintptr + var rc int32 + var _ /* lock at bp+0 */ Tflock + _, _ = pInode, rc + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + if libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFile)).FctrlFlags)&(libc.Int32FromInt32(UNIXFILE_EXCL)|libc.Int32FromInt32(UNIXFILE_RDONLY)) == int32(UNIXFILE_EXCL) { + if libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock) == 0 { + /* assert( pInode->nLock==0 ); <-- Not true if unix-excl READONLY used */ + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0 + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(2)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(SHARED_SIZE) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(F_SETLK), libc.VaList(bp+40, bp)) + if rc < 0 { + return rc + } + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock = uint8(1) + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock + 1 + } else { + rc = 0 + } + } else { + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(F_SETLK), libc.VaList(bp+40, pLock)) + } + return rc +} + +// C documentation +// +// /* +// ** Apply posix advisory locks for all bytes from ofst through ofst+n-1. +// ** +// ** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking +// ** otherwise. +// */ +func _unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, n int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pShmNode uintptr + var rc, res int32 + var _ /* f at bp+0 */ Tflock + _, _, _ = pShmNode, rc, res /* The posix advisory locking structure */ + rc = SQLITE_OK /* Result code form fcntl() */ + pShmNode = (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FpShmNode + /* Assert that the parameters are within expected range and that the + ** correct mutex or mutexes are held. */ + if ofst == (libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4)+libc.Int32FromInt32(SQLITE_SHM_NLOCK) { + } else { + } + /* Shared locks never span more than one byte */ + /* Locks are within range */ + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0 { + /* Initialize the locking parameters */ + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(lockType) + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0 + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(ofst) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(n) + res = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int32(F_SETLK), libc.VaList(bp+40, bp)) + if res == -int32(1) { + rc = int32(SQLITE_BUSY) + } + } + /* Do debug tracing */ + return rc +} diff --git a/internal/engine/lib/sqlite_g_0000000000003fc0.go b/internal/engine/lib/sqlite_g_0000000000003fc0.go new file mode 100644 index 0000000..a96161f --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003fc0.go @@ -0,0 +1,3114 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const AT_EACCESS = 512 + +const AT_EMPTY_PATH = 4096 + +const AT_NO_AUTOMOUNT = 2048 + +const AT_RECURSIVE = 32768 + +const AT_REMOVEDIR = 512 + +const AT_STATX_DONT_SYNC = 16384 + +const AT_STATX_FORCE_SYNC = 8192 + +const AT_STATX_SYNC_AS_STAT = 0 + +const AT_STATX_SYNC_TYPE = 24576 + +const AT_SYMLINK_NOFOLLOW = 256 + +const CLOCKS_PER_SEC = 1000000 + +const CLOCK_BOOTTIME = 7 + +const CLOCK_BOOTTIME_ALARM = 9 + +const CLOCK_MONOTONIC_COARSE = 6 + +const CLOCK_MONOTONIC_RAW = 4 + +const CLOCK_REALTIME_ALARM = 8 + +const CLOCK_REALTIME_COARSE = 5 + +const CLOCK_SGI_CYCLE = 10 + +const CLOCK_TAI = 11 + +const CLONE_CHILD_CLEARTID = 2097152 + +const CLONE_CHILD_SETTID = 16777216 + +const CLONE_DETACHED = 4194304 + +const CLONE_FILES = 1024 + +const CLONE_FS = 512 + +const CLONE_IO = 2147483648 + +const CLONE_NEWCGROUP = 33554432 + +const CLONE_NEWIPC = 134217728 + +const CLONE_NEWNET = 1073741824 + +const CLONE_NEWNS = 131072 + +const CLONE_NEWPID = 536870912 + +const CLONE_NEWTIME = 128 + +const CLONE_NEWUSER = 268435456 + +const CLONE_NEWUTS = 67108864 + +const CLONE_PARENT = 32768 + +const CLONE_PARENT_SETTID = 1048576 + +const CLONE_PIDFD = 4096 + +const CLONE_PTRACE = 8192 + +const CLONE_SETTLS = 524288 + +const CLONE_SIGHAND = 2048 + +const CLONE_SYSVSEM = 262144 + +const CLONE_THREAD = 65536 + +const CLONE_UNTRACED = 8388608 + +const CLONE_VFORK = 16384 + +const CLONE_VM = 256 + +const CPU_SETSIZE = 1024 + +const CSIGNAL = 255 + +const DN_ACCESS = 1 + +const DN_ATTRIB = 32 + +const DN_CREATE = 4 + +const DN_DELETE = 8 + +const DN_MODIFY = 2 + +const DN_MULTISHOT = 2147483648 + +const DN_RENAME = 16 + +const EADDRINUSE = 98 + +const EADDRNOTAVAIL = 99 + +const EADV = 68 + +const EAFNOSUPPORT = 97 + +const EALREADY = 114 + +const EBADE = 52 + +const EBADFD = 77 + +const EBADMSG = 74 + +const EBADR = 53 + +const EBADRQC = 56 + +const EBADSLT = 57 + +const EBFONT = 59 + +const ECANCELED = 125 + +const ECHRNG = 44 + +const ECOMM = 70 + +const ECONNABORTED = 103 + +const ECONNREFUSED = 111 + +const ECONNRESET = 104 + +const EDEADLK = 35 + +const EDESTADDRREQ = 89 + +const EDOTDOT = 73 + +const EDQUOT = 122 + +const EHOSTDOWN = 112 + +const EHOSTUNREACH = 113 + +const EHWPOISON = 133 + +const EIDRM = 43 + +const EINPROGRESS = 115 + +const EISCONN = 106 + +const EISNAM = 120 + +const EKEYEXPIRED = 127 + +const EKEYREJECTED = 129 + +const EKEYREVOKED = 128 + +const EL2HLT = 51 + +const EL2NSYNC = 45 + +const EL3HLT = 46 + +const EL3RST = 47 + +const ELIBACC = 79 + +const ELIBBAD = 80 + +const ELIBEXEC = 83 + +const ELIBMAX = 82 + +const ELIBSCN = 81 + +const ELNRNG = 48 + +const ELOOP = 40 + +const EMEDIUMTYPE = 124 + +const EMSGSIZE = 90 + +const EMULTIHOP = 72 + +const ENAMETOOLONG = 36 + +const ENAVAIL = 119 + +const ENETDOWN = 100 + +const ENETRESET = 102 + +const ENETUNREACH = 101 + +const ENOANO = 55 + +const ENOBUFS = 105 + +const ENOCSI = 50 + +const ENODATA = 61 + +const ENOKEY = 126 + +const ENOLCK = 37 + +const ENOLINK = 67 + +const ENOMEDIUM = 123 + +const ENOMSG = 42 + +const ENONET = 64 + +const ENOPKG = 65 + +const ENOPROTOOPT = 92 + +const ENOSR = 63 + +const ENOSTR = 60 + +const ENOSYS = 38 + +const ENOTCONN = 107 + +const ENOTEMPTY = 39 + +const ENOTNAM = 118 + +const ENOTRECOVERABLE = 131 + +const ENOTSOCK = 88 + +const ENOTSUP = 95 + +const ENOTUNIQ = 76 + +const EOPNOTSUPP = 95 + +const EOVERFLOW = 75 + +const EOWNERDEAD = 130 + +const EPFNOSUPPORT = 96 + +const EPROTO = 71 + +const EPROTONOSUPPORT = 93 + +const EPROTOTYPE = 91 + +const EREMCHG = 78 + +const EREMOTE = 66 + +const EREMOTEIO = 121 + +const ERESTART = 85 + +const ERFKILL = 132 + +const ESHUTDOWN = 108 + +const ESOCKTNOSUPPORT = 94 + +const ESRMNT = 69 + +const ESTALE = 116 + +const ESTRPIPE = 86 + +const ETIME = 62 + +const ETIMEDOUT = 110 + +const ETOOMANYREFS = 109 + +const EUCLEAN = 117 + +const EUNATCH = 49 + +const EUSERS = 87 + +const EWOULDBLOCK = 11 + +const EXFULL = 54 + +const F2FS_FEATURE_ATOMIC_WRITE = 4 + +const F2FS_IOCTL_MAGIC = 245 + +const FALLOC_FL_KEEP_SIZE = 1 + +const FALLOC_FL_PUNCH_HOLE = 2 + +const FAPPEND = 1024 + +const FASYNC = 8192 + +const FFSYNC = 1052672 + +const FILENAME_MAX = 4096 + +const FIOGETOWN = 35075 + +const FIOSETOWN = 35073 + +const FNDELAY = 2048 + +const FNONBLOCK = 2048 + +const FOPEN_MAX = 1000 + +const FP_NAN = 0 + +const FP_ZERO = 2 + +const F_ADD_SEALS = 1033 + +const F_CANCELLK = 1029 + +const F_DUPFD_CLOEXEC = 1030 + +const F_GETLEASE = 1025 + +const F_GETOWN = 9 + +const F_GETOWNER_UIDS = 17 + +const F_GETOWN_EX = 16 + +const F_GETPIPE_SZ = 1032 + +const F_GETSIG = 11 + +const F_GET_FILE_RW_HINT = 1037 + +const F_GET_RW_HINT = 1035 + +const F_GET_SEALS = 1034 + +const F_NOTIFY = 1026 + +const F_OFD_GETLK = 36 + +const F_OFD_SETLK = 37 + +const F_OFD_SETLKW = 38 + +const F_OWNER_GID = 2 + +const F_OWNER_PGRP = 2 + +const F_OWNER_PID = 1 + +const F_OWNER_TID = 0 + +const F_RDLCK = 0 + +const F_SEAL_FUTURE_WRITE = 16 + +const F_SETLEASE = 1024 + +const F_SETOWN = 8 + +const F_SETOWN_EX = 15 + +const F_SETPIPE_SZ = 1031 + +const F_SETSIG = 10 + +const F_SET_FILE_RW_HINT = 1038 + +const F_SET_RW_HINT = 1036 + +const F_WRLCK = 1 + +const HAVE_MREMAP = 1 + +const L_ctermid = 20 + +const L_cuserid = 20 + +const L_tmpnam = 20 + +const MADV_COLD = 20 + +const MADV_DODUMP = 17 + +const MADV_DOFORK = 11 + +const MADV_DONTDUMP = 16 + +const MADV_DONTFORK = 10 + +const MADV_FREE = 8 + +const MADV_HUGEPAGE = 14 + +const MADV_HWPOISON = 100 + +const MADV_KEEPONFORK = 19 + +const MADV_MERGEABLE = 12 + +const MADV_NOHUGEPAGE = 15 + +const MADV_PAGEOUT = 21 + +const MADV_REMOVE = 9 + +const MADV_SOFT_OFFLINE = 101 + +const MADV_UNMERGEABLE = 13 + +const MADV_WIPEONFORK = 18 + +const MAP_ANON = 32 + +const MAP_ANONYMOUS = 32 + +const MAP_DENYWRITE = 2048 + +const MAP_EXECUTABLE = 4096 + +const MAP_FIXED_NOREPLACE = 1048576 + +const MAP_GROWSDOWN = 256 + +const MAP_HUGETLB = 262144 + +const MAP_HUGE_16GB = 2281701376 + +const MAP_HUGE_16KB = 939524096 + +const MAP_HUGE_16MB = 1610612736 + +const MAP_HUGE_1GB = 2013265920 + +const MAP_HUGE_1MB = 1342177280 + +const MAP_HUGE_256MB = 1879048192 + +const MAP_HUGE_2GB = 2080374784 + +const MAP_HUGE_2MB = 1409286144 + +const MAP_HUGE_32MB = 1677721600 + +const MAP_HUGE_512KB = 1275068416 + +const MAP_HUGE_512MB = 1946157056 + +const MAP_HUGE_64KB = 1073741824 + +const MAP_HUGE_8MB = 1543503872 + +const MAP_HUGE_MASK = 63 + +const MAP_HUGE_SHIFT = 26 + +const MAP_NONBLOCK = 65536 + +const MAP_POPULATE = 32768 + +const MAP_SHARED_VALIDATE = 3 + +const MAP_STACK = 131072 + +const MAP_SYNC = 524288 + +const MAP_TYPE = 15 + +const MAX_HANDLE_SZ = 128 + +const MLOCK_ONFAULT = 1 + +const MREMAP_DONTUNMAP = 4 + +const MREMAP_FIXED = 2 + +const MREMAP_MAYMOVE = 1 + +const N_6PACK = 7 + +const N_AX25 = 5 + +const N_CAIF = 20 + +const N_GIGASET_M101 = 16 + +const N_GSM0710 = 21 + +const N_HCI = 15 + +const N_HDLC = 13 + +const N_IRDA = 11 + +const N_MASC = 8 + +const N_MOUSE = 2 + +const N_NCI = 25 + +const N_NULL = 27 + +const N_PPP = 3 + +const N_PPS = 18 + +const N_PROFIBUS_FDL = 10 + +const N_R3964 = 9 + +const N_SLCAN = 17 + +const N_SLIP = 1 + +const N_SMSBLOCK = 12 + +const N_SPEAKUP = 26 + +const N_STRIP = 4 + +const N_SYNC_PPP = 14 + +const N_TI_WL = 22 + +const N_TRACEROUTER = 24 + +const N_TRACESINK = 23 + +const N_TTY = 0 + +const N_V253 = 19 + +const N_X25 = 6 + +const O_ACCMODE = 2097155 + +const O_APPEND = 1024 + +const O_ASYNC = 8192 + +const O_CLOEXEC = 524288 + +const O_CREAT = 64 + +const O_DSYNC = 4096 + +const O_EXCL = 128 + +const O_EXEC = 2097152 + +const O_NDELAY = 2048 + +const O_NOATIME = 262144 + +const O_NOCTTY = 256 + +const O_NONBLOCK = 2048 + +const O_PATH = 2097152 + +const O_RSYNC = 1052672 + +const O_SEARCH = 2097152 + +const O_SYNC = 1052672 + +const O_TRUNC = 512 + +const O_TTY_INIT = 0 + +const POSIX_CLOSE_RESTART = 0 + +const PROT_GROWSDOWN = 16777216 + +const PROT_GROWSUP = 33554432 + +const PTHREAD_BARRIER_SERIAL_THREAD = -1 + +const PTHREAD_CANCELED = -1 + +const PTHREAD_CANCEL_ASYNCHRONOUS = 1 + +const PTHREAD_CANCEL_DEFERRED = 0 + +const PTHREAD_CANCEL_DISABLE = 1 + +const PTHREAD_CANCEL_ENABLE = 0 + +const PTHREAD_CANCEL_MASKED = 2 + +const PTHREAD_CREATE_DETACHED = 1 + +const PTHREAD_CREATE_JOINABLE = 0 + +const PTHREAD_EXPLICIT_SCHED = 1 + +const PTHREAD_INHERIT_SCHED = 0 + +const PTHREAD_MUTEX_DEFAULT = 0 + +const PTHREAD_MUTEX_ERRORCHECK = 2 + +const PTHREAD_MUTEX_NORMAL = 0 + +const PTHREAD_MUTEX_RECURSIVE = 1 + +const PTHREAD_MUTEX_ROBUST = 1 + +const PTHREAD_MUTEX_STALLED = 0 + +const PTHREAD_ONCE_INIT = 0 + +const PTHREAD_PRIO_INHERIT = 1 + +const PTHREAD_PRIO_NONE = 0 + +const PTHREAD_PRIO_PROTECT = 2 + +const PTHREAD_PROCESS_PRIVATE = 0 + +const PTHREAD_PROCESS_SHARED = 1 + +const PTHREAD_SCOPE_PROCESS = 1 + +const PTHREAD_SCOPE_SYSTEM = 0 + +const P_tmpdir = "/tmp" + +const RTLD_NOLOAD = 4 + +const RWF_WRITE_LIFE_NOT_SET = 0 + +const RWH_WRITE_LIFE_EXTREME = 5 + +const RWH_WRITE_LIFE_LONG = 4 + +const RWH_WRITE_LIFE_MEDIUM = 3 + +const RWH_WRITE_LIFE_NONE = 1 + +const RWH_WRITE_LIFE_SHORT = 2 + +const SCHED_BATCH = 3 + +const SCHED_DEADLINE = 6 + +const SCHED_FIFO = 1 + +const SCHED_IDLE = 5 + +const SCHED_OTHER = 0 + +const SCHED_RESET_ON_FORK = 1073741824 + +const SCHED_RR = 2 + +const SIOCADDDLCI = 35200 + +const SIOCADDMULTI = 35121 + +const SIOCADDRT = 35083 + +const SIOCATMARK = 35077 + +const SIOCDARP = 35155 + +const SIOCDELDLCI = 35201 + +const SIOCDELMULTI = 35122 + +const SIOCDELRT = 35084 + +const SIOCDEVPRIVATE = 35312 + +const SIOCDIFADDR = 35126 + +const SIOCDRARP = 35168 + +const SIOCGARP = 35156 + +const SIOCGIFADDR = 35093 + +const SIOCGIFBR = 35136 + +const SIOCGIFBRDADDR = 35097 + +const SIOCGIFCONF = 35090 + +const SIOCGIFCOUNT = 35128 + +const SIOCGIFDSTADDR = 35095 + +const SIOCGIFENCAP = 35109 + +const SIOCGIFFLAGS = 35091 + +const SIOCGIFHWADDR = 35111 + +const SIOCGIFINDEX = 35123 + +const SIOCGIFMAP = 35184 + +const SIOCGIFMEM = 35103 + +const SIOCGIFMETRIC = 35101 + +const SIOCGIFMTU = 35105 + +const SIOCGIFNAME = 35088 + +const SIOCGIFNETMASK = 35099 + +const SIOCGIFPFLAGS = 35125 + +const SIOCGIFSLAVE = 35113 + +const SIOCGIFTXQLEN = 35138 + +const SIOCGPGRP = 35076 + +const SIOCGRARP = 35169 + +const SIOCPROTOPRIVATE = 35296 + +const SIOCRTMSG = 35085 + +const SIOCSARP = 35157 + +const SIOCSIFADDR = 35094 + +const SIOCSIFBR = 35137 + +const SIOCSIFBRDADDR = 35098 + +const SIOCSIFDSTADDR = 35096 + +const SIOCSIFENCAP = 35110 + +const SIOCSIFFLAGS = 35092 + +const SIOCSIFHWADDR = 35108 + +const SIOCSIFHWBROADCAST = 35127 + +const SIOCSIFLINK = 35089 + +const SIOCSIFMAP = 35185 + +const SIOCSIFMEM = 35104 + +const SIOCSIFMETRIC = 35102 + +const SIOCSIFMTU = 35106 + +const SIOCSIFNAME = 35107 + +const SIOCSIFNETMASK = 35100 + +const SIOCSIFPFLAGS = 35124 + +const SIOCSIFSLAVE = 35120 + +const SIOCSIFTXQLEN = 35139 + +const SIOCSPGRP = 35074 + +const SIOCSRARP = 35170 + +const SIOGIFINDEX = 35123 + +const SPLICE_F_GIFT = 8 + +const SPLICE_F_MORE = 4 + +const SPLICE_F_MOVE = 1 + +const SPLICE_F_NONBLOCK = 2 + +const SQLITE_MAX_PATHLEN = 4096 + +const SQLITE_MUTEX_NREF = 0 + +const STATX_ALL = 4095 + +const STATX_ATIME = 32 + +const STATX_BASIC_STATS = 2047 + +const STATX_BLOCKS = 1024 + +const STATX_BTIME = 2048 + +const STATX_CTIME = 128 + +const STATX_GID = 16 + +const STATX_INO = 256 + +const STATX_MODE = 2 + +const STATX_MTIME = 64 + +const STATX_NLINK = 4 + +const STATX_SIZE = 512 + +const STATX_TYPE = 1 + +const STATX_UID = 8 + +const SYNC_FILE_RANGE_WAIT_AFTER = 4 + +const SYNC_FILE_RANGE_WAIT_BEFORE = 1 + +const SYNC_FILE_RANGE_WRITE = 2 + +const TCSBRKP = 21541 + +const TIOCCBRK = 21544 + +const TIOCCONS = 21533 + +const TIOCEXCL = 21516 + +const TIOCGETD = 21540 + +const TIOCGICOUNT = 21597 + +const TIOCGLCKTRMIOS = 21590 + +const TIOCGRS485 = 21550 + +const TIOCGSERIAL = 21534 + +const TIOCGSID = 21545 + +const TIOCGSOFTCAR = 21529 + +const TIOCLINUX = 21532 + +const TIOCMBIC = 21527 + +const TIOCMBIS = 21526 + +const TIOCMGET = 21525 + +const TIOCMIWAIT = 21596 + +const TIOCMSET = 21528 + +const TIOCM_LOOP = 32768 + +const TIOCM_OUT1 = 8192 + +const TIOCM_OUT2 = 16384 + +const TIOCNOTTY = 21538 + +const TIOCNXCL = 21517 + +const TIOCPKT = 21536 + +const TIOCSBRK = 21543 + +const TIOCSCTTY = 21518 + +const TIOCSERCONFIG = 21587 + +const TIOCSERGETLSR = 21593 + +const TIOCSERGETMULTI = 21594 + +const TIOCSERGSTRUCT = 21592 + +const TIOCSERGWILD = 21588 + +const TIOCSERSETMULTI = 21595 + +const TIOCSERSWILD = 21589 + +const TIOCSER_TEMT = 1 + +const TIOCSETD = 21539 + +const TIOCSLCKTRMIOS = 21591 + +const TIOCSRS485 = 21551 + +const TIOCSSERIAL = 21535 + +const TIOCSSOFTCAR = 21530 + +const TIOCSTI = 21522 + +const TIOCVHANGUP = 21559 + +const TMP_MAX = 10000 + +type TSQLiteThread = struct { + Ftid Tpthread_t + Fdone int32 + FpOut uintptr + FxTask uintptr + FpIn uintptr +} + +type T_G_fpos64_t = Tfpos_t + +type T_IO_cookie_io_functions_t = Tcookie_io_functions_t + +type Tf_owner_ex = struct { + Ftype1 int32 + Fpid Tpid_t +} + +type Tfile_handle = struct { + Fhandle_bytes uint32 + Fhandle_type int32 +} + +type Tpthread_barrierattr_t = struct { + F__attr uint32 +} + +type Tpthread_condattr_t = struct { + F__attr uint32 +} + +type Tpthread_key_t = uint32 + +type Tpthread_mutexattr_t = struct { + F__attr uint32 +} + +type Tpthread_once_t = int32 + +type Tpthread_rwlockattr_t = struct { + F__attr [2]uint32 +} + +type Tpthread_spinlock_t = int32 + +// C documentation +// +// /* +// ** CAPI3REF: Mutex Handle +// ** +// ** The mutex module within SQLite defines [sqlite3_mutex] to be an +// ** abstract type for a mutex object. The SQLite core never looks +// ** at the internal representation of an [sqlite3_mutex]. It only +// ** deals with pointers to the [sqlite3_mutex] object. +// ** +// ** Mutexes are created using [sqlite3_mutex_alloc()]. +// */ +type Tsqlite3_mutex = struct { + Fmutex Tpthread_mutex_t +} + +const WINT_MAX = 4294967295 + +const _CS_GNU_LIBC_VERSION = 2 + +const _CS_GNU_LIBPTHREAD_VERSION = 3 + +const _CS_PATH = 0 + +const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS = 4 + +const _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 + +const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 + +const _CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 + +const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 + +const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 + +const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 + +const _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 + +const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 + +const _CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 + +const _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 + +const _CS_POSIX_V6_LP64_OFF64_LIBS = 1126 + +const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 + +const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 + +const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 + +const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 + +const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 + +const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 1 + +const _CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 + +const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 + +const _CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 + +const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 + +const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 + +const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 + +const _CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 + +const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 + +const _CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 + +const _CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 + +const _CS_POSIX_V7_LP64_OFF64_LIBS = 1142 + +const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 + +const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 + +const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 + +const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 + +const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 + +const _CS_POSIX_V7_THREADS_CFLAGS = 1150 + +const _CS_POSIX_V7_THREADS_LDFLAGS = 1151 + +const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS = 5 + +const _CS_V6_ENV = 1148 + +const _CS_V7_ENV = 1149 + +const _GNU_SOURCE = 1 + +type _G_fpos64_t = T_G_fpos64_t + +const _IOC_READ = 2 + +type _IO_cookie_io_functions_t = T_IO_cookie_io_functions_t + +const _PC_2_SYMLINKS = 20 + +const _PC_ALLOC_SIZE_MIN = 18 + +const _PC_ASYNC_IO = 10 + +const _PC_CHOWN_RESTRICTED = 6 + +const _PC_LINK_MAX = 0 + +const _PC_MAX_CANON = 1 + +const _PC_MAX_INPUT = 2 + +const _PC_NAME_MAX = 3 + +const _PC_NO_TRUNC = 7 + +const _PC_PATH_MAX = 4 + +const _PC_PIPE_BUF = 5 + +const _PC_PRIO_IO = 11 + +const _PC_SOCK_MAXBUF = 12 + +const _PC_SYNC_IO = 9 + +const _PC_VDISABLE = 8 + +const _POSIX2_C_BIND = 200809 + +const _POSIX_ADVISORY_INFO = 200809 + +const _POSIX_ASYNCHRONOUS_IO = 200809 + +const _POSIX_BARRIERS = 200809 + +const _POSIX_CLOCK_SELECTION = 200809 + +const _POSIX_FSYNC = 200809 + +const _POSIX_IPV6 = 200809 + +const _POSIX_MAPPED_FILES = 200809 + +const _POSIX_MEMLOCK = 200809 + +const _POSIX_MEMLOCK_RANGE = 200809 + +const _POSIX_MEMORY_PROTECTION = 200809 + +const _POSIX_MESSAGE_PASSING = 200809 + +const _POSIX_RAW_SOCKETS = 200809 + +const _POSIX_READER_WRITER_LOCKS = 200809 + +const _POSIX_REALTIME_SIGNALS = 200809 + +const _POSIX_SEMAPHORES = 200809 + +const _POSIX_SPIN_LOCKS = 200809 + +const _POSIX_THREADS = 200809 + +const _POSIX_THREAD_ATTR_STACKADDR = 200809 + +const _POSIX_THREAD_ATTR_STACKSIZE = 200809 + +const _POSIX_THREAD_PRIORITY_SCHEDULING = 200809 + +const _POSIX_THREAD_PROCESS_SHARED = 200809 + +const _POSIX_THREAD_SAFE_FUNCTIONS = 200809 + +const _POSIX_TIMEOUTS = 200809 + +const _POSIX_VDISABLE = 0 + +const _SC_2_CHAR_TERM = 95 + +const _SC_2_C_BIND = 47 + +const _SC_2_C_DEV = 48 + +const _SC_2_FORT_DEV = 49 + +const _SC_2_FORT_RUN = 50 + +const _SC_2_LOCALEDEF = 52 + +const _SC_2_PBS = 168 + +const _SC_2_PBS_ACCOUNTING = 169 + +const _SC_2_PBS_CHECKPOINT = 175 + +const _SC_2_PBS_LOCATE = 170 + +const _SC_2_PBS_MESSAGE = 171 + +const _SC_2_PBS_TRACK = 172 + +const _SC_2_SW_DEV = 51 + +const _SC_2_UPE = 97 + +const _SC_2_VERSION = 46 + +const _SC_ADVISORY_INFO = 132 + +const _SC_AIO_LISTIO_MAX = 23 + +const _SC_AIO_MAX = 24 + +const _SC_AIO_PRIO_DELTA_MAX = 25 + +const _SC_ARG_MAX = 0 + +const _SC_ASYNCHRONOUS_IO = 12 + +const _SC_ATEXIT_MAX = 87 + +const _SC_AVPHYS_PAGES = 86 + +const _SC_BARRIERS = 133 + +const _SC_BC_BASE_MAX = 36 + +const _SC_BC_DIM_MAX = 37 + +const _SC_BC_SCALE_MAX = 38 + +const _SC_BC_STRING_MAX = 39 + +const _SC_CHILD_MAX = 1 + +const _SC_CLK_TCK = 2 + +const _SC_CLOCK_SELECTION = 137 + +const _SC_COLL_WEIGHTS_MAX = 40 + +const _SC_CPUTIME = 138 + +const _SC_DELAYTIMER_MAX = 26 + +const _SC_EXPR_NEST_MAX = 42 + +const _SC_FSYNC = 15 + +const _SC_GETGR_R_SIZE_MAX = 69 + +const _SC_GETPW_R_SIZE_MAX = 70 + +const _SC_HOST_NAME_MAX = 180 + +const _SC_IOV_MAX = 60 + +const _SC_IPV6 = 235 + +const _SC_JOB_CONTROL = 7 + +const _SC_LINE_MAX = 43 + +const _SC_LOGIN_NAME_MAX = 71 + +const _SC_MAPPED_FILES = 16 + +const _SC_MEMLOCK = 17 + +const _SC_MEMLOCK_RANGE = 18 + +const _SC_MEMORY_PROTECTION = 19 + +const _SC_MESSAGE_PASSING = 20 + +const _SC_MINSIGSTKSZ = 249 + +const _SC_MONOTONIC_CLOCK = 149 + +const _SC_MQ_OPEN_MAX = 27 + +const _SC_MQ_PRIO_MAX = 28 + +const _SC_NGROUPS_MAX = 3 + +const _SC_NPROCESSORS_CONF = 83 + +const _SC_NPROCESSORS_ONLN = 84 + +const _SC_NZERO = 109 + +const _SC_OPEN_MAX = 4 + +const _SC_PAGESIZE = 30 + +const _SC_PAGE_SIZE = 30 + +const _SC_PASS_MAX = 88 + +const _SC_PHYS_PAGES = 85 + +const _SC_PRIORITIZED_IO = 13 + +const _SC_PRIORITY_SCHEDULING = 10 + +const _SC_RAW_SOCKETS = 236 + +const _SC_READER_WRITER_LOCKS = 153 + +const _SC_REALTIME_SIGNALS = 9 + +const _SC_REGEXP = 155 + +const _SC_RE_DUP_MAX = 44 + +const _SC_RTSIG_MAX = 31 + +const _SC_SAVED_IDS = 8 + +const _SC_SEMAPHORES = 21 + +const _SC_SEM_NSEMS_MAX = 32 + +const _SC_SEM_VALUE_MAX = 33 + +const _SC_SHARED_MEMORY_OBJECTS = 22 + +const _SC_SHELL = 157 + +const _SC_SIGQUEUE_MAX = 34 + +const _SC_SIGSTKSZ = 250 + +const _SC_SPAWN = 159 + +const _SC_SPIN_LOCKS = 154 + +const _SC_SPORADIC_SERVER = 160 + +const _SC_SS_REPL_MAX = 241 + +const _SC_STREAMS = 174 + +const _SC_STREAM_MAX = 5 + +const _SC_SYMLOOP_MAX = 173 + +const _SC_SYNCHRONIZED_IO = 14 + +const _SC_THREADS = 67 + +const _SC_THREAD_CPUTIME = 139 + +const _SC_THREAD_DESTRUCTOR_ITERATIONS = 73 + +const _SC_THREAD_KEYS_MAX = 74 + +const _SC_THREAD_PRIORITY_SCHEDULING = 79 + +const _SC_THREAD_PRIO_INHERIT = 80 + +const _SC_THREAD_PRIO_PROTECT = 81 + +const _SC_THREAD_PROCESS_SHARED = 82 + +const _SC_THREAD_ROBUST_PRIO_INHERIT = 247 + +const _SC_THREAD_ROBUST_PRIO_PROTECT = 248 + +const _SC_THREAD_SAFE_FUNCTIONS = 68 + +const _SC_THREAD_SPORADIC_SERVER = 161 + +const _SC_THREAD_STACK_MIN = 75 + +const _SC_THREAD_THREADS_MAX = 76 + +const _SC_TIMEOUTS = 164 + +const _SC_TIMERS = 11 + +const _SC_TIMER_MAX = 35 + +const _SC_TRACE = 181 + +const _SC_TRACE_EVENT_FILTER = 182 + +const _SC_TRACE_EVENT_NAME_MAX = 242 + +const _SC_TRACE_INHERIT = 183 + +const _SC_TRACE_LOG = 184 + +const _SC_TRACE_NAME_MAX = 243 + +const _SC_TRACE_SYS_MAX = 244 + +const _SC_TRACE_USER_EVENT_MAX = 245 + +const _SC_TTY_NAME_MAX = 72 + +const _SC_TYPED_MEMORY_OBJECTS = 165 + +const _SC_TZNAME_MAX = 6 + +const _SC_UIO_MAXIOV = 60 + +const _SC_V6_ILP32_OFF32 = 176 + +const _SC_V6_ILP32_OFFBIG = 177 + +const _SC_V6_LP64_OFF64 = 178 + +const _SC_V6_LPBIG_OFFBIG = 179 + +const _SC_V7_ILP32_OFF32 = 237 + +const _SC_V7_ILP32_OFFBIG = 238 + +const _SC_V7_LP64_OFF64 = 239 + +const _SC_V7_LPBIG_OFFBIG = 240 + +const _SC_VERSION = 29 + +const _SC_XBS5_ILP32_OFF32 = 125 + +const _SC_XBS5_ILP32_OFFBIG = 126 + +const _SC_XBS5_LP64_OFF64 = 127 + +const _SC_XBS5_LPBIG_OFFBIG = 128 + +const _SC_XOPEN_CRYPT = 92 + +const _SC_XOPEN_ENH_I18N = 93 + +const _SC_XOPEN_LEGACY = 129 + +const _SC_XOPEN_REALTIME = 130 + +const _SC_XOPEN_REALTIME_THREADS = 131 + +const _SC_XOPEN_SHM = 94 + +const _SC_XOPEN_STREAMS = 246 + +const _SC_XOPEN_UNIX = 91 + +const _SC_XOPEN_VERSION = 89 + +const _SC_XOPEN_XCU_VERSION = 90 + +const _SC_XOPEN_XPG2 = 98 + +const _SC_XOPEN_XPG3 = 99 + +const _SC_XOPEN_XPG4 = 100 + +const _STDC_PREDEF_H = 1 + +const _XOPEN_VERSION = 700 + +const __BIG_ENDIAN = 4321 + +const __LITTLE_ENDIAN = 1234 + +const __PDP_ENDIAN = 3412 + +const __STDC_IEC_559_COMPLEX__ = 1 + +const __STDC_IEC_559__ = 1 + +const __STDC_IEC_60559_BFP__ = 201404 + +const __STDC_IEC_60559_COMPLEX__ = 201404 + +const __STDC_ISO_10646__ = 201706 + +const __USE_TIME_BITS64 = 1 + +const __WINT_MAX__ = 4294967295 + +const __gnu_linux__ = 1 + +const __inline = 0 + +const __linux = 1 + +const __linux__ = 1 + +const __tm_gmtoff = 0 + +const __tm_zone = 0 + +// C documentation +// +// /* +// ** Lock the file with the lock specified by parameter eFileLock - one +// ** of the following: +// ** +// ** (1) SHARED_LOCK +// ** (2) RESERVED_LOCK +// ** (3) PENDING_LOCK +// ** (4) EXCLUSIVE_LOCK +// ** +// ** Sometimes when requesting one lock state, additional lock states +// ** are inserted in between. The locking might fail on one of the later +// ** transitions leaving the lock state different from what it started but +// ** still short of its goal. The following chart shows the allowed +// ** transitions and the inserted intermediate states: +// ** +// ** UNLOCKED -> SHARED +// ** SHARED -> RESERVED +// ** SHARED -> (PENDING) -> EXCLUSIVE +// ** RESERVED -> (PENDING) -> EXCLUSIVE +// ** PENDING -> EXCLUSIVE +// ** +// ** This routine will only increase a lock. Use the sqlite3OsUnlock() +// ** routine to lower a locking level. +// ** +// ** With dotfile locking, we really only support state (4): EXCLUSIVE. +// ** But we track the other locking levels internally. +// */ +func _dotlockLock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + var pFile, zLockFile uintptr + var rc, tErrno int32 + _, _, _, _ = pFile, rc, tErrno, zLockFile + pFile = id + zLockFile = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext + rc = SQLITE_OK + /* If we have any lock, then the lock file already exists. All we have + ** to do is adjust our internal record of the lock level. + */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) > NO_LOCK { + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = libc.Uint8FromInt32(eFileLock) + /* Always update the timestamp on the old file */ + libc.Xutimes(tls, zLockFile, libc.UintptrFromInt32(0)) + return SQLITE_OK + } + /* grab an exclusive lock */ + rc = (*(*func(*libc.TLS, uintptr, Tmode_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(18)].FpCurrent})))(tls, zLockFile, uint32(0777)) + if rc < 0 { + /* failed to open/create the lock directory */ + tErrno = **(**int32)(__ccgo_up(libc.X__errno_location(tls))) + if int32(EEXIST) == tErrno { + rc = int32(SQLITE_BUSY) + } else { + rc = _sqliteErrorFromPosixError(tls, tErrno, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(15)< */ +/* #include "vdbeInt.h" */ + +var _staticMutexes = [12]Tsqlite3_mutex{} + +// C documentation +// +// /* +// ** The xGetLastError() method is designed to return a better +// ** low-level error message when operating-system problems come up +// ** during SQLite operation. Only the integer return code is currently +// ** used. +// */ +func _unixGetLastError(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32, NotUsed3 uintptr) (r int32) { + _ = NotUsed + _ = NotUsed2 + _ = NotUsed3 + return **(**int32)(__ccgo_up(libc.X__errno_location(tls))) +} + +/* +************************ End of sqlite3_vfs methods *************************** +******************************************************************************/ + +/****************************************************************************** +************************** Begin Proxy Locking ******************************** +** +** Proxy locking is a "uber-locking-method" in this sense: It uses the +** other locking methods on secondary lock files. Proxy locking is a +** meta-layer over top of the primitive locking implemented above. For +** this reason, the division that implements of proxy locking is deferred +** until late in the file (here) after all of the other I/O methods have +** been defined - so that the primitive locking methods are available +** as services to help with the implementation of proxy locking. +** +**** +** +** The default locking schemes in SQLite use byte-range locks on the +** database file to coordinate safe, concurrent access by multiple readers +** and writers [http://sqlite.org/lockingv3.html]. The five file locking +** states (UNLOCKED, PENDING, SHARED, RESERVED, EXCLUSIVE) are implemented +** as POSIX read & write locks over fixed set of locations (via fsctl), +** on AFP and SMB only exclusive byte-range locks are available via fsctl +** with _IOWR('z', 23, struct ByteRangeLockPB2) to track the same 5 states. +** To simulate a F_RDLCK on the shared range, on AFP a randomly selected +** address in the shared range is taken for a SHARED lock, the entire +** shared range is taken for an EXCLUSIVE lock): +** +** PENDING_BYTE 0x40000000 +** RESERVED_BYTE 0x40000001 +** SHARED_RANGE 0x40000002 -> 0x40000200 +** +** This works well on the local file system, but shows a nearly 100x +** slowdown in read performance on AFP because the AFP client disables +** the read cache when byte-range locks are present. Enabling the read +** cache exposes a cache coherency problem that is present on all OS X +** supported network file systems. NFS and AFP both observe the +** close-to-open semantics for ensuring cache coherency +** [http://nfs.sourceforge.net/#faq_a8], which does not effectively +** address the requirements for concurrent database access by multiple +** readers and writers +** [http://www.nabble.com/SQLite-on-NFS-cache-coherency-td15655701.html]. +** +** To address the performance and cache coherency issues, proxy file locking +** changes the way database access is controlled by limiting access to a +** single host at a time and moving file locks off of the database file +** and onto a proxy file on the local file system. +** +** +** Using proxy locks +** ----------------- +** +** C APIs +** +** sqlite3_file_control(db, dbname, SQLITE_FCNTL_SET_LOCKPROXYFILE, +** | ":auto:"); +** sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE, +** &); +** +** +** SQL pragmas +** +** PRAGMA [database.]lock_proxy_file= | :auto: +** PRAGMA [database.]lock_proxy_file +** +** Specifying ":auto:" means that if there is a conch file with a matching +** host ID in it, the proxy path in the conch file will be used, otherwise +** a proxy path based on the user's temp dir +** (via confstr(_CS_DARWIN_USER_TEMP_DIR,...)) will be used and the +** actual proxy file name is generated from the name and path of the +** database file. For example: +** +** For database path "/Users/me/foo.db" +** The lock path will be "/sqliteplocks/_Users_me_foo.db:auto:") +** +** Once a lock proxy is configured for a database connection, it can not +** be removed, however it may be switched to a different proxy path via +** the above APIs (assuming the conch file is not being held by another +** connection or process). +** +** +** How proxy locking works +** ----------------------- +** +** Proxy file locking relies primarily on two new supporting files: +** +** * conch file to limit access to the database file to a single host +** at a time +** +** * proxy file to act as a proxy for the advisory locks normally +** taken on the database +** +** The conch file - to use a proxy file, sqlite must first "hold the conch" +** by taking an sqlite-style shared lock on the conch file, reading the +** contents and comparing the host's unique host ID (see below) and lock +** proxy path against the values stored in the conch. The conch file is +** stored in the same directory as the database file and the file name +** is patterned after the database file name as ".-conch". +** If the conch file does not exist, or its contents do not match the +** host ID and/or proxy path, then the lock is escalated to an exclusive +** lock and the conch file contents is updated with the host ID and proxy +** path and the lock is downgraded to a shared lock again. If the conch +** is held by another process (with a shared lock), the exclusive lock +** will fail and SQLITE_BUSY is returned. +** +** The proxy file - a single-byte file used for all advisory file locks +** normally taken on the database file. This allows for safe sharing +** of the database file for multiple readers and writers on the same +** host (the conch ensures that they all use the same local lock file). +** +** Requesting the lock proxy does not immediately take the conch, it is +** only taken when the first request to lock database file is made. +** This matches the semantics of the traditional locking behavior, where +** opening a connection to a database file does not take a lock on it. +** The shared lock and an open file descriptor are maintained until +** the connection to the database is closed. +** +** The proxy file and the lock file are never deleted so they only need +** to be created the first time they are used. +** +** Configuration options +** --------------------- +** +** SQLITE_PREFER_PROXY_LOCKING +** +** Database files accessed on non-local file systems are +** automatically configured for proxy locking, lock files are +** named automatically using the same logic as +** PRAGMA lock_proxy_file=":auto:" +** +** SQLITE_PROXY_DEBUG +** +** Enables the logging of error messages during host id file +** retrieval and creation +** +** LOCKPROXYDIR +** +** Overrides the default directory used for lock proxy files that +** are named automatically via the ":auto:" setting +** +** SQLITE_DEFAULT_PROXYDIR_PERMISSIONS +** +** Permissions to use when creating a directory for storing the +** lock proxy files, only used when LOCKPROXYDIR is not set. +** +** +** As mentioned above, when compiled with SQLITE_PREFER_PROXY_LOCKING, +** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will +** force proxy locking to be used for every database file opened, and 0 +** will force automatic proxy locking to be disabled for all database +** files (explicitly calling the SQLITE_FCNTL_SET_LOCKPROXYFILE pragma or +** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING). + */ + +/* +** Proxy locking is only available on MacOSX + */ +/* +** The proxy locking style is intended for use with AFP filesystems. +** And since AFP is only supported on MacOSX, the proxy locking is also +** restricted to MacOSX. +** +** +******************* End of the proxy lock implementation ********************** +******************************************************************************/ + +// C documentation +// +// /* +// ** Lock the file with the lock specified by parameter eFileLock - one +// ** of the following: +// ** +// ** (1) SHARED_LOCK +// ** (2) RESERVED_LOCK +// ** (3) PENDING_LOCK +// ** (4) EXCLUSIVE_LOCK +// ** +// ** Sometimes when requesting one lock state, additional lock states +// ** are inserted in between. The locking might fail on one of the later +// ** transitions leaving the lock state different from what it started but +// ** still short of its goal. The following chart shows the allowed +// ** transitions and the inserted intermediate states: +// ** +// ** UNLOCKED -> SHARED +// ** SHARED -> RESERVED +// ** SHARED -> EXCLUSIVE +// ** RESERVED -> (PENDING) -> EXCLUSIVE +// ** PENDING -> EXCLUSIVE +// ** +// ** This routine will only increase a lock. Use the sqlite3OsUnlock() +// ** routine to lower a locking level. +// */ +func _unixLock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pFile, pInode uintptr + var rc, tErrno, v1 int32 + var _ /* lock at bp+0 */ Tflock + _, _, _, _, _ = pFile, pInode, rc, tErrno, v1 + /* The following describes the implementation of the various locks and + ** lock transitions in terms of the POSIX advisory shared and exclusive + ** lock primitives (called read-locks and write-locks below, to avoid + ** confusion with SQLite lock names). The algorithms are complicated + ** slightly in order to be compatible with Windows95 systems simultaneously + ** accessing the same database file, in case that is ever required. + ** + ** Symbols defined in os.h identify the 'pending byte' and the 'reserved + ** byte', each single bytes at well known offsets, and the 'shared byte + ** range', a range of 510 bytes at a well known offset. + ** + ** To obtain a SHARED lock, a read-lock is obtained on the 'pending + ** byte'. If this is successful, 'shared byte range' is read-locked + ** and the lock on the 'pending byte' released. (Legacy note: When + ** SQLite was first developed, Windows95 systems were still very common, + ** and Windows95 lacks a shared-lock capability. So on Windows95, a + ** single randomly selected by from the 'shared byte range' is locked. + ** Windows95 is now pretty much extinct, but this work-around for the + ** lack of shared-locks on Windows95 lives on, for backwards + ** compatibility.) + ** + ** A process may only obtain a RESERVED lock after it has a SHARED lock. + ** A RESERVED lock is implemented by grabbing a write-lock on the + ** 'reserved byte'. + ** + ** An EXCLUSIVE lock may only be requested after either a SHARED or + ** RESERVED lock is held. An EXCLUSIVE lock is implemented by obtaining + ** a write-lock on the entire 'shared byte range'. Since all other locks + ** require a read-lock on one of the bytes within this range, this ensures + ** that no other locks are held on the database. + ** + ** If a process that holds a RESERVED lock requests an EXCLUSIVE, then + ** a PENDING lock is obtained first. A PENDING lock is implemented by + ** obtaining a write-lock on the 'pending byte'. This ensures that no new + ** SHARED locks can be obtained, but existing SHARED locks are allowed to + ** persist. If the call to this function fails to obtain the EXCLUSIVE + ** lock in this case, it holds the PENDING lock instead. The client may + ** then re-attempt the EXCLUSIVE lock later on, after existing SHARED + ** locks have cleared. + */ + rc = SQLITE_OK + pFile = id + tErrno = 0 + /* If there is already a lock of this type or more restrictive on the + ** unixFile, do nothing. Don't use the end_lock: exit path, as + ** unixEnterMutex() hasn't been called yet. + */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) >= eFileLock { + return SQLITE_OK + } + /* Make sure the locking sequence is correct. + ** (1) We never move from unlocked to anything higher than shared lock. + ** (2) SQLite never explicitly requests a pending lock. + ** (3) A shared lock is always held when a reserve lock is requested. + */ + /* This mutex is needed because pFile->pInode is shared across threads + */ + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + /* If some thread using this PID has a lock via a different unixFile* + ** handle that precludes the requested lock, return BUSY. + */ + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) != libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) && (libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) >= int32(PENDING_LOCK) || eFileLock > int32(SHARED_LOCK)) { + rc = int32(SQLITE_BUSY) + goto end_lock + } + /* If a SHARED lock is requested, and some thread using this PID already + ** has a SHARED or RESERVED lock, then increment reference counts and + ** return SQLITE_OK. + */ + if eFileLock == int32(SHARED_LOCK) && (libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == int32(SHARED_LOCK) || libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == int32(RESERVED_LOCK)) { + (*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK) + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared + 1 + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock + 1 + goto end_lock + } + /* A PENDING lock is needed before acquiring a SHARED lock and before + ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will + ** be released. + */ + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0 + if eFileLock == int32(SHARED_LOCK) || eFileLock == int32(EXCLUSIVE_LOCK) && libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) == int32(RESERVED_LOCK) { + if eFileLock == int32(SHARED_LOCK) { + v1 = F_RDLCK + } else { + v1 = int32(F_WRLCK) + } + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(v1) + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte) + if _unixFileLock(tls, pFile, bp) != 0 { + tErrno = **(**int32)(__ccgo_up(libc.X__errno_location(tls))) + rc = _sqliteErrorFromPosixError(tls, tErrno, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(15)< int32(1) { + /* We are trying for an exclusive lock but another thread in this + ** same process is still holding a shared lock. */ + rc = int32(SQLITE_BUSY) + } else { + if _unixIsSharingShmNode(tls, pFile) != 0 { + /* We are in WAL mode and attempting to delete the SHM and WAL + ** files due to closing the connection or changing out of WAL mode, + ** but another process still holds locks on the SHM file, thus + ** indicating that database locks have been broken, perhaps due + ** to a rogue close(open(dbFile)) or similar. + */ + rc = int32(SQLITE_BUSY) + } else { + /* The request was for a RESERVED or EXCLUSIVE lock. It is + ** assumed that there is a SHARED or greater lock on the file + ** already. + */ + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + if eFileLock == int32(RESERVED_LOCK) { + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(1)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1) + } else { + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(2)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(SHARED_SIZE) + } + if _unixFileLock(tls, pFile, bp) != 0 { + tErrno = **(**int32)(__ccgo_up(libc.X__errno_location(tls))) + rc = _sqliteErrorFromPosixError(tls, tErrno, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(15)< +**
  • [[SQLITE_FCNTL_LOCKSTATE]] +** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This +** opcode causes the xFileControl method to write the current state of +** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], +** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) +** into an integer that the pArg argument points to. +** This capability is only available if SQLite is compiled with [SQLITE_DEBUG]. +** +**
  • [[SQLITE_FCNTL_SIZE_HINT]] +** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS +** layer a hint of how large the database file will grow to be during the +** current transaction. This hint is not guaranteed to be accurate but it +** is often close. The underlying VFS might choose to preallocate database +** file space based on this hint in order to help writes to the database +** file run faster. +** +**
  • [[SQLITE_FCNTL_SIZE_LIMIT]] +** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that +** implements [sqlite3_deserialize()] to set an upper bound on the size +** of the in-memory database. The argument is a pointer to a [sqlite3_int64]. +** If the integer pointed to is negative, then it is filled in with the +** current limit. Otherwise the limit is set to the larger of the value +** of the integer pointed to and the current database size. The integer +** pointed to is set to the new limit. +** +**
  • [[SQLITE_FCNTL_CHUNK_SIZE]] +** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS +** extends and truncates the database file in chunks of a size specified +** by the user. The fourth argument to [sqlite3_file_control()] should +** point to an integer (type int) containing the new chunk-size to use +** for the nominated database. Allocating database file space in large +** chunks (say 1MB at a time), may reduce file-system fragmentation and +** improve performance on some systems. +** +**
  • [[SQLITE_FCNTL_FILE_POINTER]] +** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer +** to the [sqlite3_file] object associated with a particular database +** connection. See also [SQLITE_FCNTL_JOURNAL_POINTER]. +** +**
  • [[SQLITE_FCNTL_JOURNAL_POINTER]] +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer +** to the [sqlite3_file] object associated with the journal file (either +** the [rollback journal] or the [write-ahead log]) for a particular database +** connection. See also [SQLITE_FCNTL_FILE_POINTER]. +** +**
  • [[SQLITE_FCNTL_SYNC_OMITTED]] +** The SQLITE_FCNTL_SYNC_OMITTED file-control is no longer used. +** +**
  • [[SQLITE_FCNTL_SYNC]] +** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and +** sent to the VFS immediately before the xSync method is invoked on a +** database file descriptor. Or, if the xSync method is not invoked +** because the user has configured SQLite with +** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place +** of the xSync method. In most cases, the pointer argument passed with +** this file-control is NULL. However, if the database file is being synced +** as part of a multi-database commit, the argument points to a nul-terminated +** string containing the transactions super-journal file name. VFSes that +** do not need this signal should silently ignore this opcode. Applications +** should not call [sqlite3_file_control()] with this opcode as doing so may +** disrupt the operation of the specialized VFSes that do require it. +** +**
  • [[SQLITE_FCNTL_COMMIT_PHASETWO]] +** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite +** and sent to the VFS after a transaction has been committed immediately +** but before the database is unlocked. VFSes that do not need this signal +** should silently ignore this opcode. Applications should not call +** [sqlite3_file_control()] with this opcode as doing so may disrupt the +** operation of the specialized VFSes that do require it. +** +**
  • [[SQLITE_FCNTL_WIN32_AV_RETRY]] +** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic +** retry counts and intervals for certain disk I/O operations for the +** windows [VFS] in order to provide robustness in the presence of +** anti-virus programs. By default, the windows VFS will retry file read, +** file write, and file delete operations up to 10 times, with a delay +** of 25 milliseconds before the first retry and with the delay increasing +** by an additional 25 milliseconds with each subsequent retry. This +** opcode allows these two values (10 retries and 25 milliseconds of delay) +** to be adjusted. The values are changed for all database connections +** within the same process. The argument is a pointer to an array of two +** integers where the first integer is the new retry count and the second +** integer is the delay. If either integer is negative, then the setting +** is not changed but instead the prior value of that setting is written +** into the array entry, allowing the current retry settings to be +** interrogated. The zDbName parameter is ignored. +** +**
  • [[SQLITE_FCNTL_PERSIST_WAL]] +** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the +** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary +** write ahead log ([WAL file]) and shared memory +** files used for transaction control +** are automatically deleted when the latest connection to the database +** closes. Setting persistent WAL mode causes those files to persist after +** close. Persisting the files is useful when other processes that do not +** have write permission on the directory containing the database file want +** to read the database file, as the WAL and shared memory files must exist +** in order for the database to be readable. The fourth parameter to +** [sqlite3_file_control()] for this opcode should be a pointer to an integer. +** That integer is 0 to disable persistent WAL mode or 1 to enable persistent +** WAL mode. If the integer is -1, then it is overwritten with the current +** WAL persistence setting. +** +**
  • [[SQLITE_FCNTL_POWERSAFE_OVERWRITE]] +** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the +** persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting +** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the +** xDeviceCharacteristics methods. The fourth parameter to +** [sqlite3_file_control()] for this opcode should be a pointer to an integer. +** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage +** mode. If the integer is -1, then it is overwritten with the current +** zero-damage mode setting. +** +**
  • [[SQLITE_FCNTL_OVERWRITE]] +** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening +** a write transaction to indicate that, unless it is rolled back for some +** reason, the entire database file will be overwritten by the current +** transaction. This is used by VACUUM operations. +** +**
  • [[SQLITE_FCNTL_VFSNAME]] +** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of +** all [VFSes] in the VFS stack. The names of all VFS shims and the +** final bottom-level VFS are written into memory obtained from +** [sqlite3_malloc()] and the result is stored in the char* variable +** that the fourth parameter of [sqlite3_file_control()] points to. +** The caller is responsible for freeing the memory when done. As with +** all file-control actions, there is no guarantee that this will actually +** do anything. Callers should initialize the char* variable to a NULL +** pointer in case this file-control is not implemented. This file-control +** is intended for diagnostic use only. +** +**
  • [[SQLITE_FCNTL_VFS_POINTER]] +** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level +** [VFSes] currently in use. ^(The argument X in +** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be +** of type "[sqlite3_vfs] **". This opcode will set *X +** to a pointer to the top-level VFS.)^ +** ^When there are multiple VFS shims in the stack, this opcode finds the +** upper-most shim only. +** +**
  • [[SQLITE_FCNTL_PRAGMA]] +** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] +** file control is sent to the open [sqlite3_file] object corresponding +** to the database file to which the pragma statement refers. ^The argument +** to the [SQLITE_FCNTL_PRAGMA] file control is an array of +** pointers to strings (char**) in which the second element of the array +** is the name of the pragma and the third element is the argument to the +** pragma or NULL if the pragma has no argument. ^The handler for an +** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element +** of the char** argument point to a string obtained from [sqlite3_mprintf()] +** or the equivalent and that string will become the result of the pragma or +** the error message if the pragma fails. ^If the +** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal +** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] +** file control returns [SQLITE_OK], then the parser assumes that the +** VFS has handled the PRAGMA itself and the parser generates a no-op +** prepared statement if result string is NULL, or that returns a copy +** of the result string if the string is non-NULL. +** ^If the [SQLITE_FCNTL_PRAGMA] file control returns +** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means +** that the VFS encountered an error while handling the [PRAGMA] and the +** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] +** file control occurs at the beginning of pragma statement analysis and so +** it is able to override built-in [PRAGMA] statements. +** +**
  • [[SQLITE_FCNTL_BUSYHANDLER]] +** ^The [SQLITE_FCNTL_BUSYHANDLER] +** file-control may be invoked by SQLite on the database file handle +** shortly after it is opened in order to provide a custom VFS with access +** to the connection's busy-handler callback. The argument is of type (void**) +** - an array of two (void *) values. The first (void *) actually points +** to a function of type (int (*)(void *)). In order to invoke the connection's +** busy-handler, this function should be invoked with the second (void *) in +** the array as the only argument. If it returns non-zero, then the operation +** should be retried. If it returns zero, the custom VFS should abandon the +** current operation. +** +**
  • [[SQLITE_FCNTL_TEMPFILENAME]] +** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control +** to have SQLite generate a +** temporary filename using the same algorithm that is followed to generate +** temporary filenames for TEMP tables and other internal uses. The +** argument should be a char** which will be filled with the filename +** written into memory obtained from [sqlite3_malloc()]. The caller should +** invoke [sqlite3_free()] on the result to avoid a memory leak. +** +**
  • [[SQLITE_FCNTL_MMAP_SIZE]] +** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the +** maximum number of bytes that will be used for memory-mapped I/O. +** The argument is a pointer to a value of type sqlite3_int64 that +** is an advisory maximum number of bytes in the file to memory map. The +** pointer is overwritten with the old value. The limit is not changed if +** the value originally pointed to is negative, and so the current limit +** can be queried by passing in a pointer to a negative number. This +** file-control is used internally to implement [PRAGMA mmap_size]. +** +**
  • [[SQLITE_FCNTL_TRACE]] +** The [SQLITE_FCNTL_TRACE] file control provides advisory information +** to the VFS about what the higher layers of the SQLite stack are doing. +** This file control is used by some VFS activity tracing [shims]. +** The argument is a zero-terminated string. Higher layers in the +** SQLite stack may generate instances of this file control if +** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled. +** +**
  • [[SQLITE_FCNTL_HAS_MOVED]] +** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a +** pointer to an integer and it writes a boolean into that integer depending +** on whether or not the file has been renamed, moved, or deleted since it +** was first opened. +** +**
  • [[SQLITE_FCNTL_WIN32_GET_HANDLE]] +** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the +** underlying native file handle associated with a file handle. This file +** control interprets its argument as a pointer to a native file handle and +** writes the resulting value there. +** +**
  • [[SQLITE_FCNTL_WIN32_SET_HANDLE]] +** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This +** opcode causes the xFileControl method to swap the file handle with the one +** pointed to by the pArg argument. This capability is used during testing +** and only needs to be supported when SQLITE_TEST is defined. +** +**
  • [[SQLITE_FCNTL_NULL_IO]] +** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor +** or file handle for the [sqlite3_file] object such that it will no longer +** read or write to the database file. +** +**
  • [[SQLITE_FCNTL_WAL_BLOCK]] +** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might +** be advantageous to block on the next WAL lock if the lock is not immediately +** available. The WAL subsystem issues this signal during rare +** circumstances in order to fix a problem with priority inversion. +** Applications should not use this file-control. +** +**
  • [[SQLITE_FCNTL_ZIPVFS]] +** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other +** VFS should return SQLITE_NOTFOUND for this opcode. +** +**
  • [[SQLITE_FCNTL_RBU]] +** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by +** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for +** this opcode. +** +**
  • [[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]] +** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then +** the file descriptor is placed in "batch write mode", which +** means all subsequent write operations will be deferred and done +** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. Systems +** that do not support batch atomic writes will return SQLITE_NOTFOUND. +** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to +** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or +** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make +** no VFS interface calls on the same [sqlite3_file] file descriptor +** except for calls to the xWrite method and the xFileControl method +** with [SQLITE_FCNTL_SIZE_HINT]. +** +**
  • [[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]] +** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write +** operations since the previous successful call to +** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically. +** This file control returns [SQLITE_OK] if and only if the writes were +** all performed successfully and have been committed to persistent storage. +** ^Regardless of whether or not it is successful, this file control takes +** the file descriptor out of batch write mode so that all subsequent +** write operations are independent. +** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without +** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. +** +**
  • [[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]] +** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write +** operations since the previous successful call to +** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. +** ^This file control takes the file descriptor out of batch write mode +** so that all subsequent write operations are independent. +** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without +** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. +** +**
  • [[SQLITE_FCNTL_LOCK_TIMEOUT]] +** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode is used to configure a VFS +** to block for up to M milliseconds before failing when attempting to +** obtain a file lock using the xLock or xShmLock methods of the VFS. +** The parameter is a pointer to a 32-bit signed integer that contains +** the value that M is to be set to. Before returning, the 32-bit signed +** integer is overwritten with the previous value of M. +** +**
  • [[SQLITE_FCNTL_BLOCK_ON_CONNECT]] +** The [SQLITE_FCNTL_BLOCK_ON_CONNECT] opcode is used to configure the +** VFS to block when taking a SHARED lock to connect to a wal mode database. +** This is used to implement the functionality associated with +** SQLITE_SETLK_BLOCK_ON_CONNECT. +** +**
  • [[SQLITE_FCNTL_DATA_VERSION]] +** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to +** a database file. The argument is a pointer to a 32-bit unsigned integer. +** The "data version" for the pager is written into the pointer. The +** "data version" changes whenever any change occurs to the corresponding +** database file, either through SQL statements on the same database +** connection or through transactions committed by separate database +** connections possibly in other processes. The [sqlite3_total_changes()] +** interface can be used to find if any database on the connection has changed, +** but that interface responds to changes on TEMP as well as MAIN and does +** not provide a mechanism to detect changes to MAIN only. Also, the +** [sqlite3_total_changes()] interface responds to internal changes only and +** omits changes made by other database connections. The +** [PRAGMA data_version] command provides a mechanism to detect changes to +** a single attached database that occur due to other database connections, +** but omits changes implemented by the database connection on which it is +** called. This file control is the only mechanism to detect changes that +** happen either internally or externally and that are associated with +** a particular attached database. +** +**
  • [[SQLITE_FCNTL_CKPT_START]] +** The [SQLITE_FCNTL_CKPT_START] opcode is invoked from within a checkpoint +** in wal mode before the client starts to copy pages from the wal +** file to the database file. +** +**
  • [[SQLITE_FCNTL_CKPT_DONE]] +** The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint +** in wal mode after the client has finished copying pages from the wal +** file to the database file, but before the *-shm file is updated to +** record the fact that the pages have been checkpointed. +** +**
  • [[SQLITE_FCNTL_EXTERNAL_READER]] +** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect +** whether or not there is a database client in another process with a wal-mode +** transaction open on the database or not. It is only available on unix. The +** (void*) argument passed with this file-control should be a pointer to a +** value of type (int). The integer value is set to 1 if the database is a wal +** mode database and there exists at least one client in another process that +** currently has an SQL transaction open on the database. It is set to 0 if +** the database is not a wal-mode db, or if there is no such connection in any +** other process. This opcode cannot be used to detect transactions opened +** by clients within the current process, only within other processes. +** +**
  • [[SQLITE_FCNTL_CKSM_FILE]] +** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use internally by the +** [checksum VFS shim] only. +** +**
  • [[SQLITE_FCNTL_RESET_CACHE]] +** If there is currently no transaction open on the database, and the +** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control +** purges the contents of the in-memory page cache. If there is an open +** transaction, or if the db is a temp-db, this opcode is a no-op, not an error. +** +**
  • [[SQLITE_FCNTL_FILESTAT]] +** The [SQLITE_FCNTL_FILESTAT] opcode returns low-level diagnostic information +** about the [sqlite3_file] objects used access the database and journal files +** for the given schema. The fourth parameter to [sqlite3_file_control()] +** should be an initialized [sqlite3_str] pointer. JSON text describing +** various aspects of the sqlite3_file object is appended to the sqlite3_str. +** The SQLITE_FCNTL_FILESTAT opcode is usually a no-op, unless compile-time +** options are used to enable it. +** + */ + +/* deprecated names */ + +/* reserved file-control numbers: +** 101 +** 102 +** 103 + */ + +type sqlite3_mutex = Tsqlite3_mutex + +const stat64 = 0 + +type statx = Tstatx + +type statx_timestamp = Tstatx_timestamp + +type t__isoc_va_list = uintptr + +type t__ptcb = struct { + F__f uintptr + F__x uintptr + F__next uintptr +} + +/* +** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are +** intended for use only inside assert() statements. On some platforms, +** there might be race conditions that can cause these routines to +** deliver incorrect results. In particular, if pthread_equal() is +** not an atomic operation, then these routines might delivery +** incorrect results. On most platforms, pthread_equal() is a +** comparison of two integers and is therefore atomic. But we are +** told that HPUX is not such a platform. If so, then these routines +** will not always work correctly on HPUX. +** +** On those platforms where pthread_equal() is not atomic, SQLite +** should be compiled without -DSQLITE_DEBUG and with -DNDEBUG to +** make sure no assert() statements are evaluated and hence these +** routines are never called. + */ + +type t__sigset_t = Tsigset_t + +type timezone = Ttimezone + +/* +** Try to determine if gethostuuid() is available based on standard +** macros. This might sometimes compute the wrong value for some +** obscure platforms. For those cases, simply compile with one of +** the following: +** +** -DHAVE_GETHOSTUUID=0 +** -DHAVE_GETHOSTUUID=1 +** +** None if this matters except when building on Apple products with +** -DSQLITE_ENABLE_LOCKING_STYLE. + */ + +/* +** Allowed values of unixFile.fsFlags + */ + +/* +** If we are to be thread-safe, include the pthreads header. + */ +/* # include */ + +/* +** Default permissions when creating a new file + */ + +/* +** Default permissions when creating auto proxy dir + */ + +/* +** Maximum supported path-length. + */ + +/* +** Maximum supported symbolic links + */ + +/* +** Remove and stub certain info for WASI (WebAssembly System +** Interface) builds. + */ + +/* Always cast the getpid() return type for compatibility with +** kernel modules in VxWorks. */ + +/* +** Only set the lastErrno if the error code is a real error and not +** a normal expected return code of SQLITE_BUSY or SQLITE_OK + */ + +const tmpfile64 = 0 + +const truncate64 = 0 + +type uint_fast32_t = Tuint_fast32_t + +/* +** The following macros are used to cast pointers to integers and +** integers to pointers. The way you do this varies from one compiler +** to the next, so we have developed the following set of #if statements +** to generate appropriate macros for a wide range of compilers. +** +** The correct "ANSI" way to do this is to use the intptr_t type. +** Unfortunately, that typedef is not available on all compilers, or +** if it is available, it requires an #include of specific headers +** that vary from one machine to the next. +** +** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on +** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)). +** So we have to define the macros in different ways depending on the +** compiler. + */ + +/* +** Macros to hint to the compiler that a function should or should not be +** inlined. + */ + +/* +** Make sure that the compiler intrinsics we desire are enabled when +** compiling with an appropriate version of MSVC unless prevented by +** the SQLITE_DISABLE_INTRINSIC define. + */ + +/* +** Enable SQLITE_USE_SEH by default on MSVC builds. Only omit +** SEH support if the -DSQLITE_OMIT_SEH option is given. + */ + +/* +** Enable SQLITE_DIRECT_OVERFLOW_READ, unless the build explicitly +** disables it using -DSQLITE_DIRECT_OVERFLOW_READ=0 + */ +/* In all other cases, enable */ + +/* +** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. +** 0 means mutexes are permanently disable and the library is never +** threadsafe. 1 means the library is serialized which is the highest +** level of threadsafety. 2 means the library is multithreaded - multiple +** threads can use SQLite as long as no two threads try to use the same +** database connection at the same time. +** +** Older versions of SQLite used an optional THREADSAFE macro. +** We support that for legacy. +** +** To ensure that the correct value of "THREADSAFE" is reported when querying +** for compile-time options at runtime (e.g. "PRAGMA compile_options"), this +** logic is partially replicated in ctime.c. If it is updated here, it should +** also be updated there. + */ + +/* +** Powersafe overwrite is on by default. But can be turned off using +** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option. + */ + +/* +** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by +** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in +** which case memory allocation statistics are disabled by default. + */ + +/* +** Exactly one of the following macros must be defined in order to +** specify which memory allocation subsystem to use. +** +** SQLITE_SYSTEM_MALLOC // Use normal system malloc() +** SQLITE_WIN32_MALLOC // Use Win32 native heap API +** SQLITE_ZERO_MALLOC // Use a stub allocator that always fails +** SQLITE_MEMDEBUG // Debugging version of system malloc() +** +** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the +** assert() macro is enabled, each call into the Win32 native heap subsystem +** will cause HeapValidate to be called. If heap validation should fail, an +** assertion will be triggered. +** +** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as +** the default. + */ + +/* +** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the +** sizes of memory allocations below this value where possible. + */ + +/* +** We need to define _XOPEN_SOURCE as follows in order to enable +** recursive mutexes on most Unix systems and fchmod() on OpenBSD. +** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit +** it. + */ + +/* +** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that +** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true, +** make it true by defining or undefining NDEBUG. +** +** Setting NDEBUG makes the code smaller and faster by disabling the +** assert() statements in the code. So we want the default action +** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG +** is set. Thus NDEBUG becomes an opt-in rather than an opt-out +** feature. + */ + +/* +** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on. + */ + +/* +** The testcase() macro is used to aid in coverage testing. When +** doing coverage testing, the condition inside the argument to +** testcase() must be evaluated both true and false in order to +** get full branch coverage. The testcase() macro is inserted +** to help ensure adequate test coverage in places where simple +** condition/decision coverage is inadequate. For example, testcase() +** can be used to make sure boundary values are tested. For +** bitmask tests, testcase() can be used to make sure each bit +** is significant and used at least once. On switch statements +** where multiple cases go to the same block of code, testcase() +** can insure that all cases are evaluated. + */ + +/* +** The TESTONLY macro is used to enclose variable declarations or +** other bits of code that are needed to support the arguments +** within testcase() and assert() macros. + */ + +/* +** Sometimes we need a small amount of code such as a variable initialization +** to setup for a later assert() statement. We do not want this code to +** appear when assert() is disabled. The following macro is therefore +** used to contain that setup code. The "VVA" acronym stands for +** "Verification, Validation, and Accreditation". In other words, the +** code within VVA_ONLY() will only run during verification processes. + */ + +/* +** Disable ALWAYS() and NEVER() (make them pass-throughs) for coverage +** and mutation testing + */ + +/* +** The ALWAYS and NEVER macros surround boolean expressions which +** are intended to always be true or false, respectively. Such +** expressions could be omitted from the code completely. But they +** are included in a few cases in order to enhance the resilience +** of SQLite to unexpected behavior - to make the code "self-healing" +** or "ductile" rather than being "brittle" and crashing at the first +** hint of unplanned behavior. +** +** In other words, ALWAYS and NEVER are added for defensive code. +** +** When doing coverage testing ALWAYS and NEVER are hard-coded to +** be true and false so that the unreachable code they specify will +** not be counted as untested code. + */ + +/* +** Some conditionals are optimizations only. In other words, if the +** conditionals are replaced with a constant 1 (true) or 0 (false) then +** the correct answer is still obtained, though perhaps not as quickly. +** +** The following macros mark these optimizations conditionals. + */ + +/* +** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is +** defined. We need to defend against those failures when testing with +** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches +** during a normal build. The following macro can be used to disable tests +** that are always false except when SQLITE_TEST_REALLOC_STRESS is set. + */ + +/* +** Declarations used for tracing the operating system interfaces. + */ + +/* +** Is the sqlite3ErrName() function needed in the build? Currently, +** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when +** OSTRACE is enabled), and by several "test*.c" files (which are +** compiled using SQLITE_TEST). + */ + +/* +** SQLITE_ENABLE_EXPLAIN_COMMENTS is incompatible with SQLITE_OMIT_EXPLAIN + */ + +/* +** SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTERTABLE + */ + +/* +** Return true (non-zero) if the input is an integer that is too large +** to fit in 32-bits. This macro is used inside of various testcase() +** macros to verify that we have tested SQLite for large-file support. + */ + +/* +** The macro unlikely() is a hint that surrounds a boolean +** expression that is usually false. Macro likely() surrounds +** a boolean expression that is usually true. These hints could, +** in theory, be used by the compiler to generate better code, but +** currently they are just comments for human readers. + */ + +/************** Include hash.h in the middle of sqliteInt.h ******************/ +/************** Begin file hash.h ********************************************/ +/* +** 2001 September 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This is the header file for the generic hash-table implementation +** used in SQLite. + */ diff --git a/internal/engine/lib/sqlite_g_0000000000003fc3.go b/internal/engine/lib/sqlite_g_0000000000003fc3.go new file mode 100644 index 0000000..bf9fbf0 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003fc3.go @@ -0,0 +1,28 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +const FP_ILOGBNAN = -2147483648 + +const HAVE_PREAD = 1 + +const HAVE_PWRITE = 1 + +type Tiovec = struct { + Fiov_base uintptr + Fiov_len Tsize_t +} + +const USE_PREAD = 1 + +const WNOHANG = 1 + +const WUNTRACED = 2 + +const _XOPEN_ENH_I18N = 1 + +const _XOPEN_UNIX = 1 + +type iovec = Tiovec diff --git a/internal/engine/lib/sqlite_g_0000000000003fd7.go b/internal/engine/lib/sqlite_g_0000000000003fd7.go new file mode 100644 index 0000000..bbc3b5f --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003fd7.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && arm) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +type Tkey_t = int32 diff --git a/internal/engine/lib/sqlite_g_0000000000003ffc.go b/internal/engine/lib/sqlite_g_0000000000003ffc.go new file mode 100644 index 0000000..681bc50 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003ffc.go @@ -0,0 +1,46 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +const F_SEAL_GROW = 4 + +const F_SEAL_SEAL = 1 + +const F_SEAL_SHRINK = 2 + +const F_SEAL_WRITE = 8 + +const MFD_ALLOW_SEALING = 2 + +const MFD_CLOEXEC = 1 + +const MFD_HUGETLB = 4 + +const RTLD_DI_LINKMAP = 2 + +const SEEK_DATA = 3 + +const SEEK_HOLE = 4 + +type Tcookie_io_functions_t = struct { + Fread uintptr + Fwrite uintptr + Fseek uintptr + Fclose1 uintptr +} + +type Ttimer_t = uintptr + +const _PC_REC_INCR_XFER_SIZE = 14 + +const _PC_REC_MAX_XFER_SIZE = 15 + +const _PC_REC_MIN_XFER_SIZE = 16 + +const _PC_REC_XFER_ALIGN = 17 + +type cookie_io_functions_t = Tcookie_io_functions_t + +type uintmax_t = Tuintmax_t diff --git a/internal/engine/lib/sqlite_g_0000000000003fff.go b/internal/engine/lib/sqlite_g_0000000000003fff.go new file mode 100644 index 0000000..9a28abe --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000003fff.go @@ -0,0 +1,221 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** This function is a no-op if the pager is in exclusive mode and not +// ** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN +// ** state. +// ** +// ** If the pager is not in exclusive-access mode, the database file is +// ** completely unlocked. If the file is unlocked and the file-system does +// ** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is +// ** closed (if it is open). +// ** +// ** If the pager is in ERROR state when this function is called, the +// ** contents of the pager cache are discarded before switching back to +// ** the OPEN state. Regardless of whether the pager is in exclusive-mode +// ** or not, any journal file left in the file-system will be treated +// ** as a hot-journal and rolled back the next time a read-transaction +// ** is opened (by this or by any other connection). +// */ +func _pager_unlock(tls *libc.TLS, pPager uintptr) { + var iDc, rc, v1 int32 + _, _, _ = iDc, rc, v1 + _sqlite3BitvecDestroy(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal) + (*TPager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0) + _releaseAllSavepoints(tls, pPager) + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_ERROR) { + /* If an IO error occurs in wal.c while attempting to wrap the wal file, + ** then the Wal object may be holding a write-lock but no read-lock. + ** This call ensures that the write-lock is dropped as well. We cannot + ** have sqlite3WalEndReadTransaction() drop the write-lock, as it once + ** did, because this would break "BEGIN EXCLUSIVE" handling for + ** SQLITE_ENABLE_SETLK_TIMEOUT builds. */ + _sqlite3WalEndWriteTransaction(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) + } + _sqlite3WalEndReadTransaction(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_OPEN) + } else { + if !((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) { + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) { + v1 = _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd) + } else { + v1 = 0 + } /* Error code returned by pagerUnlockDb() */ + iDc = v1 + /* If the operating system support deletion of open files, then + ** close the journal file when dropping the database lock. Otherwise + ** another connection with journal_mode=delete might delete the file + ** out from under us. + */ + if 0 == iDc&int32(SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN) || int32(1) != libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode)&int32(5) { + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) + } + /* If the pager is in the ERROR state and the call to unlock the database + ** file fails, set the current lock to UNKNOWN_LOCK. See the comment + ** above the #define for UNKNOWN_LOCK for an explanation of why this + ** is necessary. + */ + rc = _pagerUnlockDb(tls, pPager, NO_LOCK) + if rc != SQLITE_OK && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_ERROR) { + (*TPager)(unsafe.Pointer(pPager)).FeLock = libc.Uint8FromInt32(libc.Int32FromInt32(EXCLUSIVE_LOCK) + libc.Int32FromInt32(1)) + } + /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here + ** without clearing the error code. This is intentional - the error + ** code is cleared and the cache reset in the block below. + */ + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_OPEN) + } + } + /* If Pager.errCode is set, the contents of the pager cache cannot be + ** trusted. Now that there are no outstanding references to the pager, + ** it can safely move back to PAGER_OPEN state. This happens in both + ** normal and exclusive-locking mode. + */ + if (*TPager)(unsafe.Pointer(pPager)).FerrCode != 0 { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FtempFile) == 0 { + _pager_reset(tls, pPager) + (*TPager)(unsafe.Pointer(pPager)).FchangeCountDone = uint8(0) + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_OPEN) + } else { + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) { + v1 = PAGER_OPEN + } else { + v1 = int32(PAGER_READER) + } + (*TPager)(unsafe.Pointer(pPager)).FeState = libc.Uint8FromInt32(v1) + } + if (*TPager)(unsafe.Pointer(pPager)).FbUseFetch != 0 { + _sqlite3OsUnfetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, 0, uintptr(0)) + } + (*TPager)(unsafe.Pointer(pPager)).FerrCode = SQLITE_OK + _setGetterMethod(tls, pPager) + } + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + (*TPager)(unsafe.Pointer(pPager)).FjournalHdr = 0 + (*TPager)(unsafe.Pointer(pPager)).FsetSuper = uint8(0) +} + +// C documentation +// +// /* +// ** If possible, return a pointer to a mapping of file fd starting at offset +// ** iOff. The mapping must be valid for at least nAmt bytes. +// ** +// ** If such a pointer can be obtained, store it in *pp and return SQLITE_OK. +// ** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK. +// ** Finally, if an error does occur, return an SQLite error code. The final +// ** value of *pp is undefined in this case. +// ** +// ** If this function does return a pointer, the caller must eventually +// ** release the reference by calling unixUnfetch(). +// */ +func _unixFetch(tls *libc.TLS, fd uintptr, iOff Ti64, nAmt int32, pp uintptr) (r int32) { + var nEofBuffer, rc int32 + var pFd uintptr + _, _, _ = nEofBuffer, pFd, rc + pFd = fd /* The underlying database file */ + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + if (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeMax > 0 { + /* Ensure that there is always at least a 256 byte buffer of addressable + ** memory following the returned page. If the database is corrupt, + ** SQLite may overread the page slightly (in practice only a few bytes, + ** but 256 is safe, round, number). */ + nEofBuffer = int32(256) + if (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion == uintptr(0) { + rc = _unixMapfile(tls, pFd, int64(-int32(1))) + if rc != SQLITE_OK { + return rc + } + } + if (*TunixFile)(unsafe.Pointer(pFd)).FmmapSize >= iOff+int64(nAmt)+int64(nEofBuffer) { + **(**uintptr)(__ccgo_up(pp)) = (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion + uintptr(iOff) + (*TunixFile)(unsafe.Pointer(pFd)).FnFetchOut = (*TunixFile)(unsafe.Pointer(pFd)).FnFetchOut + 1 + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** If the third argument is non-NULL, then this function releases a +// ** reference obtained by an earlier call to unixFetch(). The second +// ** argument passed to this function must be the same as the corresponding +// ** argument that was passed to the unixFetch() invocation. +// ** +// ** Or, if the third argument is NULL, then this function is being called +// ** to inform the VFS layer that, according to POSIX, any existing mapping +// ** may now be invalid and should be unmapped. +// */ +func _unixUnfetch(tls *libc.TLS, fd uintptr, iOff Ti64, p uintptr) (r int32) { + var pFd uintptr + _ = pFd + pFd = fd /* The underlying database file */ + _ = iOff + /* If p==0 (unmap the entire file) then there must be no outstanding + ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference), + ** then there must be at least one outstanding. */ + /* If p!=0, it must match the iOff value. */ + if p != 0 { + (*TunixFile)(unsafe.Pointer(pFd)).FnFetchOut = (*TunixFile)(unsafe.Pointer(pFd)).FnFetchOut - 1 + } else { + _unixUnmapfile(tls, pFd) + } + return SQLITE_OK +} + +/* +** Here ends the implementation of all sqlite3_file methods. +** +********************** End sqlite3_file Methods ******************************* +******************************************************************************/ + +/* +** This division contains definitions of sqlite3_io_methods objects that +** implement various file locking strategies. It also contains definitions +** of "finder" functions. A finder-function is used to locate the appropriate +** sqlite3_io_methods object for a particular database file. The pAppData +** field of the sqlite3_vfs VFS objects are initialized to be pointers to +** the correct finder-function for that VFS. +** +** Most finder functions return a pointer to a fixed sqlite3_io_methods +** object. The only interesting finder-function is autolockIoFinder, which +** looks at the filesystem type and tries to guess the best locking +** strategy from that. +** +** For finder-function F, two objects are created: +** +** (1) The real finder-function named "FImpt()". +** +** (2) A constant pointer to this function named just "F". +** +** +** A pointer to the F pointer is used as the pAppData value for VFS +** objects. We have to do this instead of letting pAppData point +** directly at the finder-function since C90 rules prevent a void* +** from be cast into a function pointer. +** +** +** Each instance of this macro generates two objects: +** +** * A constant sqlite3_io_methods object call METHOD that has locking +** methods CLOSE, LOCK, UNLOCK, CKRESLOCK. +** +** * An I/O method finder function called FINDER that returns a pointer +** to the METHOD object in the previous bullet. + */ + +type fd_mask = Tfd_mask diff --git a/internal/engine/lib/sqlite_g_0000000000004003.go b/internal/engine/lib/sqlite_g_0000000000004003.go new file mode 100644 index 0000000..9f0e2fa --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000004003.go @@ -0,0 +1,86 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (netbsd && amd64) + +package sqlite3 + +const CHARCLASS_NAME_MAX = 14 + +const COLL_WEIGHTS_MAX = 2 + +const ENOATTR = 93 + +const EXPR_NEST_MAX = 32 + +const FP_NAN = 1 + +const GID_MAX = 2147483647 + +const LINE_MAX = 2048 + +const LINK_MAX = 32767 + +const MAP_NORESERVE = 64 + +const MAP_RENAME = 32 + +const NGROUPS_MAX = 16 + +const NZERO = 20 + +const PATH_MAX = 1024 + +const PIPE_BUF = 512 + +const RE_DUP_MAX = 255 + +const TIOCGSIZE = "TIOCGWINSZ" + +const TIOCSSIZE = "TIOCSWINSZ" + +type Texception = struct { + Ftype1 int32 + Fname uintptr + Farg1 float64 + Farg2 float64 + Fretval float64 +} + +type Tidtype_t = int32 + +type Tkauth_cred_t = uintptr + +type Tswblk_t = int32 + +type Tttysize = struct { + Fts_lines uint16 + Fts_cols uint16 + Fts_xxx uint16 + Fts_yyy uint16 +} + +const UID_MAX = 2147483647 + +const X_TLOSS = 0 + +const _POSIX2_VERSION = 200112 + +const _POSIX_THREAD_KEYS_MAX = 128 + +const _P_ALL = 0 + +const _P_PID = 1 + +type exception = Texception + +type idtype_t = Tidtype_t + +type kauth_cred_t = Tkauth_cred_t + +type stack_t = Tstack_t + +type swblk_t = Tswblk_t + +type t__sFILE = TFILE + +type ttysize = Tttysize diff --git a/internal/engine/lib/sqlite_g_0000000000004007.go b/internal/engine/lib/sqlite_g_0000000000004007.go new file mode 100644 index 0000000..77a9a88 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000004007.go @@ -0,0 +1,36 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (netbsd && amd64) + +package sqlite3 + +import ( + "github.com/hanzoai/sqlite/internal/libc" +) + +const _POSIX_VERSION = 200112 + +// C documentation +// +// /* +// ** Find the current time (in Universal Coordinated Time). Write into *piNow +// ** the current time and date as a Julian Day number times 86_400_000. In +// ** other words, write into *piNow the number of milliseconds since the Julian +// ** epoch of noon in Greenwich on November 24, 4714 B.C according to the +// ** proleptic Gregorian calendar. +// ** +// ** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date +// ** cannot be found. +// */ +func _unixCurrentTimeInt64(tls *libc.TLS, NotUsed uintptr, piNow uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* sNow at bp+0 */ Ttimeval + _ = rc + rc = SQLITE_OK + libc.Xgettimeofday(tls, bp, uintptr(0)) /* Cannot fail given valid arguments */ + **(**Tsqlite3_int64)(__ccgo_up(piNow)) = _unixEpoch + int64(1000)*int64((**(**Ttimeval)(__ccgo_up(bp))).Ftv_sec) + int64((**(**Ttimeval)(__ccgo_up(bp))).Ftv_usec/int32(1000)) + _ = NotUsed + return rc +} diff --git a/internal/engine/lib/sqlite_g_0000000000004017.go b/internal/engine/lib/sqlite_g_0000000000004017.go new file mode 100644 index 0000000..16de6bd --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000004017.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && arm) || (netbsd && amd64) + +package sqlite3 + +type Tsuseconds_t = int32 diff --git a/internal/engine/lib/sqlite_g_000000000000403f.go b/internal/engine/lib/sqlite_g_000000000000403f.go new file mode 100644 index 0000000..57b43ff --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000403f.go @@ -0,0 +1,56 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (netbsd && amd64) + +package sqlite3 + +const EOVERFLOW = 84 + +const MAP_HASSEMAPHORE = 512 + +const S_IFWHT = 57344 + +const TMP_MAX = 308915776 + +type Tin_addr_t = uint32 + +type Tin_port_t = uint16 + +type Tqaddr_t = uintptr + +const __SALC = 16384 + +const __SAPP = 256 + +const __SEOF = 32 + +const __SERR = 64 + +const __SLBF = 1 + +const __SMBF = 128 + +const __SMOD = 8192 + +const __SNBF = 2 + +const __SNPT = 2048 + +const __SOFF = 4096 + +const __SOPT = 1024 + +const __SRD = 4 + +const __SRW = 16 + +const __SSTR = 512 + +const __SWR = 8 + +type qaddr_t = Tqaddr_t + +type t__sbuf = struct { + F_base uintptr + F_size int32 +} diff --git a/internal/engine/lib/sqlite_g_0000000000004080.go b/internal/engine/lib/sqlite_g_0000000000004080.go new file mode 100644 index 0000000..938f872 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000004080.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (netbsd && amd64) + +package sqlite3 + +const __MMX_WITH_SSE__ = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000005ffc.go b/internal/engine/lib/sqlite_g_0000000000005ffc.go new file mode 100644 index 0000000..cdae34d --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000005ffc.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) + +package sqlite3 + +const POSIX_FADV_DONTNEED = 4 + +const POSIX_FADV_NOREUSE = 5 diff --git a/internal/engine/lib/sqlite_g_0000000000007cc0.go b/internal/engine/lib/sqlite_g_0000000000007cc0.go new file mode 100644 index 0000000..dfd51e0 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000007cc0.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) + +package sqlite3 + +const __WCHAR_MIN__ = -2147483648 diff --git a/internal/engine/lib/sqlite_g_0000000000007f80.go b/internal/engine/lib/sqlite_g_0000000000007f80.go new file mode 100644 index 0000000..2b330e5 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000007f80.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) + +package sqlite3 + +const __FLT_EVAL_METHOD_TS_18661_3__ = 0 + +const __FLT_EVAL_METHOD__ = 0 diff --git a/internal/engine/lib/sqlite_g_0000000000007fc0.go b/internal/engine/lib/sqlite_g_0000000000007fc0.go new file mode 100644 index 0000000..3702dd3 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000007fc0.go @@ -0,0 +1,15 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) + +package sqlite3 + +const FP_SUBNORMAL = 3 + +const MS_SYNC = 4 + +const UTIME_NOW = 1073741823 + +const UTIME_OMIT = 1073741822 + +const _POSIX_SPAWN = 200809 diff --git a/internal/engine/lib/sqlite_g_0000000000007fc3.go b/internal/engine/lib/sqlite_g_0000000000007fc3.go new file mode 100644 index 0000000..f220bab --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000007fc3.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) + +package sqlite3 + +const FP_ILOGB0 = -2147483648 diff --git a/internal/engine/lib/sqlite_g_0000000000007ffc.go b/internal/engine/lib/sqlite_g_0000000000007ffc.go new file mode 100644 index 0000000..fa5a57b --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000007ffc.go @@ -0,0 +1,25 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) + +package sqlite3 + +const AT_SYMLINK_FOLLOW = 1024 + +const POSIX_FADV_NORMAL = 0 + +const POSIX_FADV_RANDOM = 1 + +const POSIX_FADV_SEQUENTIAL = 2 + +const POSIX_FADV_WILLNEED = 3 + +const RTLD_NODELETE = 4096 + +type Tdev_t = uint64 + +type pthread_barrier_t = Tpthread_barrier_t + +type pthread_barrierattr_t = Tpthread_barrierattr_t + +type pthread_spinlock_t = Tpthread_spinlock_t diff --git a/internal/engine/lib/sqlite_g_0000000000007fff.go b/internal/engine/lib/sqlite_g_0000000000007fff.go new file mode 100644 index 0000000..e852968 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000007fff.go @@ -0,0 +1,51 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) + +package sqlite3 + +import ( + "github.com/hanzoai/sqlite/internal/libc" +) + +const MS_INVALIDATE = 2 + +type Tpthread_t = uintptr + +const __restrict = 0 + +// C documentation +// +// /* +// ** Return the system page size. +// ** +// ** This function should not be called directly by other code in this file. +// ** Instead, it should be called via macro osGetpagesize(). +// */ +func _unixGetpagesize(tls *libc.TLS) (r int32) { + return int32(libc.Xsysconf(tls, int32(_SC_PAGESIZE))) +} + +/* +** Constants used for locking + */ + +type pthread_attr_t = Tpthread_attr_t + +type pthread_cond_t = Tpthread_cond_t + +type pthread_condattr_t = Tpthread_condattr_t + +type pthread_key_t = Tpthread_key_t + +type pthread_mutex_t = Tpthread_mutex_t + +type pthread_mutexattr_t = Tpthread_mutexattr_t + +type pthread_once_t = Tpthread_once_t + +type pthread_rwlock_t = Tpthread_rwlock_t + +type pthread_rwlockattr_t = Tpthread_rwlockattr_t + +type pthread_t = Tpthread_t diff --git a/internal/engine/lib/sqlite_g_000000000000800d.go b/internal/engine/lib/sqlite_g_000000000000800d.go new file mode 100644 index 0000000..9a82e76 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000800d.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && 386) || (freebsd && amd64) || (openbsd && amd64) + +package sqlite3 + +const __BITINT_MAXWIDTH__ = 8388608 + +const __NO_MATH_INLINES = 1 diff --git a/internal/engine/lib/sqlite_g_000000000000c089.go b/internal/engine/lib/sqlite_g_000000000000c089.go new file mode 100644 index 0000000..4e6110a --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000c089.go @@ -0,0 +1,15 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && amd64) || (linux && amd64) || (netbsd && amd64) || (openbsd && amd64) + +package sqlite3 + +const __MMX__ = 1 + +const __SSE2_MATH__ = 1 + +const __SSE2__ = 1 + +const __SSE_MATH__ = 1 + +const __SSE__ = 1 diff --git a/internal/engine/lib/sqlite_g_000000000000c08d.go b/internal/engine/lib/sqlite_g_000000000000c08d.go new file mode 100644 index 0000000..7cb13ba --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000c08d.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && 386) || (freebsd && amd64) || (linux && amd64) || (netbsd && amd64) || (openbsd && amd64) + +package sqlite3 + +const __code_model_small__ = 1 diff --git a/internal/engine/lib/sqlite_g_000000000000c488.go b/internal/engine/lib/sqlite_g_000000000000c488.go new file mode 100644 index 0000000..c2d4763 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000c488.go @@ -0,0 +1,3153 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (linux && amd64) || (linux && loong64) || (netbsd && amd64) || (openbsd && amd64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Allocate memory to hold names for a database, journal file, WAL file, +// ** and query parameters. The pointer returned is valid for use by +// ** sqlite3_filename_database() and sqlite3_uri_parameter() and related +// ** functions. +// ** +// ** Memory layout must be compatible with that generated by the pager +// ** and expected by sqlite3_uri_parameter() and databaseName(). +// */ +func Xsqlite3_create_filename(tls *libc.TLS, zDatabase uintptr, zJournal uintptr, zWal uintptr, nParam int32, azParam uintptr) (r uintptr) { + var i int32 + var nByte Tsqlite3_int64 + var p, pResult, v2 uintptr + _, _, _, _, _ = i, nByte, p, pResult, v2 + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, zDatabase) + libc.Xstrlen(tls, zJournal) + libc.Xstrlen(tls, zWal) + uint64(10)) + i = 0 + for { + if !(i < nParam*int32(2)) { + break + } + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(azParam + uintptr(i)*8)))+libc.Uint64FromInt32(1))) + goto _1 + _1: + ; + i = i + 1 + } + v2 = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + p = v2 + pResult = v2 + if p == uintptr(0) { + return uintptr(0) + } + libc.Xmemset(tls, p, 0, uint64(4)) + p = p + uintptr(4) + p = _appendText(tls, p, zDatabase) + i = 0 + for { + if !(i < nParam*int32(2)) { + break + } + p = _appendText(tls, p, **(**uintptr)(__ccgo_up(azParam + uintptr(i)*8))) + goto _3 + _3: + ; + i = i + 1 + } + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = 0 + p = _appendText(tls, p, zJournal) + p = _appendText(tls, p, zWal) + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = 0 + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = 0 + return pResult + uintptr(4) +} + +// C documentation +// +// /* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...) +// ** functions. +// ** +// ** Return a string value that is the concatenation of all non-null +// ** entries in argv[]. Use zSep as the separator. +// */ +func _concatFuncCore(tls *libc.TLS, context uintptr, argc int32, argv uintptr, nSep int32, zSep uintptr) { + var bNotNull, i, k int32 + var j, n Ti64 + var v, z uintptr + _, _, _, _, _, _, _ = bNotNull, i, j, k, n, v, z + n = 0 + bNotNull = 0 + i = 0 + for { + if !(i < argc) { + break + } + n = n + int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)))) + goto _1 + _1: + ; + i = i + 1 + } + n = n + int64(argc-libc.Int32FromInt32(1))*int64(nSep) + z = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(n+int64(1))) + if z == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + j = 0 + i = 0 + for { + if !(i < argc) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) != int32(SQLITE_NULL) { + k = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + v = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if v != uintptr(0) { + if bNotNull != 0 && nSep > 0 { + libc.Xmemcpy(tls, z+uintptr(j), zSep, libc.Uint64FromInt32(nSep)) + j = j + int64(nSep) + } + libc.Xmemcpy(tls, z+uintptr(j), v, libc.Uint64FromInt32(k)) + j = j + int64(k) + bNotNull = int32(1) + } + } + goto _2 + _2: + ; + i = i + 1 + } + **(**int8)(__ccgo_up(z + uintptr(j))) = 0 + Xsqlite3_result_text64(tls, context, z, libc.Uint64FromInt64(j), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) +} + +// C documentation +// +// /* +// ** Analyze a term that consists of two or more OR-connected +// ** subterms. So in: +// ** +// ** ... WHERE (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13) +// ** ^^^^^^^^^^^^^^^^^^^^ +// ** +// ** This routine analyzes terms such as the middle term in the above example. +// ** A WhereOrTerm object is computed and attached to the term under +// ** analysis, regardless of the outcome of the analysis. Hence: +// ** +// ** WhereTerm.wtFlags |= TERM_ORINFO +// ** WhereTerm.u.pOrInfo = a dynamically allocated WhereOrTerm object +// ** +// ** The term being analyzed must have two or more of OR-connected subterms. +// ** A single subterm might be a set of AND-connected sub-subterms. +// ** Examples of terms under analysis: +// ** +// ** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5 +// ** (B) x=expr1 OR expr2=x OR x=expr3 +// ** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15) +// ** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*') +// ** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6) +// ** (F) x>A OR (x=A AND y>=B) +// ** +// ** CASE 1: +// ** +// ** If all subterms are of the form T.C=expr for some single column of C and +// ** a single table T (as shown in example B above) then create a new virtual +// ** term that is an equivalent IN expression. In other words, if the term +// ** being analyzed is: +// ** +// ** x = expr1 OR expr2 = x OR x = expr3 +// ** +// ** then create a new virtual term like this: +// ** +// ** x IN (expr1,expr2,expr3) +// ** +// ** CASE 2: +// ** +// ** If there are exactly two disjuncts and one side has x>A and the other side +// ** has x=A (for the same x and A) then add a new virtual conjunct term to the +// ** WHERE clause of the form "x>=A". Example: +// ** +// ** x>A OR (x=A AND y>B) adds: x>=A +// ** +// ** The added conjunct can sometimes be helpful in query planning. +// ** +// ** CASE 3: +// ** +// ** If all subterms are indexable by a single table T, then set +// ** +// ** WhereTerm.eOperator = WO_OR +// ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T +// ** +// ** A subterm is "indexable" if it is of the form +// ** "T.C " where C is any column of table T and +// ** is one of "=", "<", "<=", ">", ">=", "IS NULL", or "IN". +// ** A subterm is also indexable if it is an AND of two or more +// ** subsubterms at least one of which is indexable. Indexable AND +// ** subterms have their eOperator set to WO_AND and they have +// ** u.pAndInfo set to a dynamically allocated WhereAndTerm object. +// ** +// ** From another point of view, "indexable" means that the subterm could +// ** potentially be used with an index if an appropriate index exists. +// ** This analysis does not consider whether or not the index exists; that +// ** is decided elsewhere. This analysis only looks at whether subterms +// ** appropriate for indexing exist. +// ** +// ** All examples A through E above satisfy case 3. But if a term +// ** also satisfies case 1 (such as B) we know that the optimizer will +// ** always prefer case 1, so in that case we pretend that case 3 is not +// ** satisfied. +// ** +// ** It might be the case that multiple tables are indexable. For example, +// ** (E) above is indexable on tables P, Q, and R. +// ** +// ** Terms that satisfy case 3 are candidates for lookup by using +// ** separate indices to find rowids for each subterm and composing +// ** the union of all rowids using a RowSet object. This is similar +// ** to "bitmap indices" in other database engines. +// ** +// ** OTHERWISE: +// ** +// ** If none of cases 1, 2, or 3 apply, then leave the eOperator set to +// ** zero. This term is not useful for search. +// */ +func _exprAnalyzeOrTerm(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { + var affLeft, affRight, i, iColumn, iCursor, iOne, iTwo, idxNew, j, j1, okToChngToIN, v7, v9 int32 + var b, b1, chngToIN, indexable TBitmask + var db, pAndInfo, pAndTerm, pAndWC, pDup, pExpr, pLeft, pLeft1, pList, pNew, pOne, pOrInfo, pOrTerm, pOrWc, pOther, pParse, pTerm, pTwo, pWInfo, v1, v2 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = affLeft, affRight, b, b1, chngToIN, db, i, iColumn, iCursor, iOne, iTwo, idxNew, indexable, j, j1, okToChngToIN, pAndInfo, pAndTerm, pAndWC, pDup, pExpr, pLeft, pLeft1, pList, pNew, pOne, pOrInfo, pOrTerm, pOrWc, pOther, pParse, pTerm, pTwo, pWInfo, v1, v2, v7, v9 + pWInfo = (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo /* WHERE clause processing context */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parser context */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 /* The term to be analyzed */ + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr /* Tables that are indexable, satisfying case 2 */ + /* + ** Break the OR clause into its separate subterms. The subterms are + ** stored in a WhereClause structure containing within the WhereOrInfo + ** object that is attached to the original OR clause term. + */ + v1 = _sqlite3DbMallocZero(tls, db, uint64(496)) + pOrInfo = v1 + *(*uintptr)(unsafe.Pointer(pTerm + 32)) = v1 + if pOrInfo == uintptr(0) { + return + } + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_ORINFO)) + pOrWc = pOrInfo + libc.Xmemset(tls, pOrWc+40, 0, uint64(448)) + _sqlite3WhereClauseInit(tls, pOrWc, pWInfo) + _sqlite3WhereSplit(tls, pOrWc, pExpr, uint8(TK_OR)) + _sqlite3WhereExprAnalyze(tls, pSrc, pOrWc) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + /* + ** Compute the set of tables that might satisfy cases 1 or 3. + */ + indexable = ^libc.Uint64FromInt32(0) + chngToIN = ^libc.Uint64FromInt32(0) + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + for { + if !(i >= 0 && indexable != 0) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_SINGLE) == 0 { + chngToIN = uint64(0) + pAndInfo = _sqlite3DbMallocRawNN(tls, db, uint64(488)) + if pAndInfo != 0 { + b = uint64(0) + *(*uintptr)(unsafe.Pointer(pOrTerm + 32)) = pAndInfo + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_ANDINFO)) + (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator = uint16(WO_AND) + (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor = -int32(1) + pAndWC = pAndInfo + libc.Xmemset(tls, pAndWC+40, 0, uint64(448)) + _sqlite3WhereClauseInit(tls, pAndWC, (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo) + _sqlite3WhereSplit(tls, pAndWC, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr, uint8(TK_AND)) + _sqlite3WhereExprAnalyze(tls, pSrc, pAndWC) + (*TWhereClause)(unsafe.Pointer(pAndWC)).FpOuter = pWC + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + j = 0 + pAndTerm = (*TWhereClause)(unsafe.Pointer(pAndWC)).Fa + for { + if !(j < (*TWhereClause)(unsafe.Pointer(pAndWC)).FnTerm) { + break + } + if _allowedOp(tls, libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAndTerm)).FpExpr)).Fop)) != 0 || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pAndTerm)).FeOperator) == int32(WO_AUX) { + b = b | _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pAndTerm)).FleftCursor) + } + goto _5 + _5: + ; + j = j + 1 + pAndTerm += 56 + } + } + indexable = indexable & b + } + } else { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_COPIED) != 0 { + /* Skip this term for now. We revisit it when we process the + ** corresponding TERM_VIRTUAL term */ + } else { + b1 = _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_VIRTUAL) != 0 { + pOther = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FiParent)*56 + b1 = b1 | _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOther)).FleftCursor) + } + indexable = indexable & b1 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_EQ) == 0 { + chngToIN = uint64(0) + } else { + chngToIN = chngToIN & b1 + } + } + } + goto _3 + _3: + ; + i = i - 1 + pOrTerm += 56 + } + /* + ** Record the set of tables that satisfy case 3. The set might be + ** empty. + */ + (*TWhereOrInfo)(unsafe.Pointer(pOrInfo)).Findexable = indexable + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(WO_OR) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = -int32(1) + if indexable != 0 { + (*TWhereClause)(unsafe.Pointer(pWC)).FhasOr = uint8(1) + } + /* For a two-way OR, attempt to implementation case 2. + */ + if indexable != 0 && (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm == int32(2) { + iOne = 0 + for { + v7 = iOne + iOne = iOne + 1 + v1 = _whereNthSubterm(tls, (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa, v7) + pOne = v1 + if !(v1 != uintptr(0)) { + break + } + iTwo = 0 + for { + v9 = iTwo + iTwo = iTwo + 1 + v2 = _whereNthSubterm(tls, (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa+1*56, v9) + pTwo = v2 + if !(v2 != uintptr(0)) { + break + } + _whereCombineDisjuncts(tls, pSrc, pWC, pOne, pTwo) + } + } + } + /* + ** chngToIN holds a set of tables that *might* satisfy case 1. But + ** we have to do some additional checking to see if case 1 really + ** is satisfied. + ** + ** chngToIN will hold either 0, 1, or 2 bits. The 0-bit case means + ** that there is no possibility of transforming the OR clause into an + ** IN operator because one or more terms in the OR clause contain + ** something other than == on a column in the single table. The 1-bit + ** case means that every term of the OR clause is of the form + ** "table.column=expr" for some single table. The one bit that is set + ** will correspond to the common table. We still need to check to make + ** sure the same column is used on all terms. The 2-bit case is when + ** the all terms are of the form "table1.column=table2.column". It + ** might be possible to form an IN operator with either table1.column + ** or table2.column as the LHS if either is common to every term of + ** the OR clause. + ** + ** Note that terms of the form "table.column1=table.column2" (the + ** same table on both sizes of the ==) cannot be optimized. + */ + if chngToIN != 0 { + okToChngToIN = 0 /* True if the conversion to IN is valid */ + iColumn = -int32(1) /* Column index on lhs of IN operator */ + iCursor = -int32(1) /* Table cursor common to all terms */ + j1 = 0 /* Loop counter */ + /* Search for a table and column that appears on one side or the + ** other of the == operator in every subterm. That table and column + ** will be recorded in iCursor and iColumn. There might not be any + ** such table and column. Set okToChngToIN if an appropriate table + ** and column is found but leave okToChngToIN false if not found. + */ + j1 = 0 + for { + if !(j1 < int32(2) && !(okToChngToIN != 0)) { + break + } + pLeft = uintptr(0) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + for { + if !(i >= 0) { + break + } + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(TERM_OK)) + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCursor { + /* This is the 2-bit case and we are on the second iteration and + ** current term is from the first iteration. So skip this term. */ + goto _11 + } + if chngToIN&_sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) == uint64(0) { + /* This term must be of the form t1.a==t2.b where t2 is in the + ** chngToIN set but t1 is not. This term will be either preceded + ** or followed by an inverted copy (t2.b==t1.a). Skip this term + ** and use its inversion. */ + goto _11 + } + iColumn = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pOrTerm + 32))).FleftColumn + iCursor = (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor + pLeft = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft + break + goto _11 + _11: + ; + i = i - 1 + pOrTerm += 56 + } + if i < 0 { + /* No candidate table+column was found. This can only occur + ** on the second iteration */ + break + } + /* We have found a candidate table and column. Check to see if that + ** table and column is common to every term in the OR clause */ + okToChngToIN = int32(1) + for { + if !(i >= 0 && okToChngToIN != 0) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor != iCursor { + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(TERM_OK)) + } else { + if (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pOrTerm + 32))).FleftColumn != iColumn || iColumn == -int32(2) && _sqlite3ExprCompare(tls, pParse, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft, pLeft, -int32(1)) != 0 { + okToChngToIN = 0 + } else { + /* If the right-hand side is also a column, then the affinities + ** of both right and left sides must be such that no type + ** conversions are required on the right. (Ticket #2249) + */ + affRight = int32(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpRight)) + affLeft = int32(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft)) + if affRight != 0 && affRight != affLeft { + okToChngToIN = 0 + } else { + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_OK)) + } + } + } + goto _13 + _13: + ; + i = i - 1 + pOrTerm += 56 + } + goto _10 + _10: + ; + j1 = j1 + 1 + } + /* At this point, okToChngToIN is true if original pTerm satisfies + ** case 1. In that case, construct a new virtual term that is + ** pTerm converted into an IN operator. + */ + if okToChngToIN != 0 { /* A transient duplicate expression */ + pList = uintptr(0) /* The RHS of the IN operator */ + pLeft1 = uintptr(0) /* The complete IN operator */ + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + for { + if !(i >= 0) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_OK) == 0 { + goto _16 + } + pDup = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpRight, 0) + pList = _sqlite3ExprListAppend(tls, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse, pList, pDup) + pLeft1 = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft + goto _16 + _16: + ; + i = i - 1 + pOrTerm += 56 + } + pDup = _sqlite3ExprDup(tls, db, pLeft1, 0) + pNew = _sqlite3PExpr(tls, pParse, int32(TK_IN), pDup, uintptr(0)) + if pNew != 0 { + _transferJoinMarkings(tls, pNew, pExpr) + *(*uintptr)(unsafe.Pointer(pNew + 32)) = pList + idxNew = _whereClauseInsert(tls, pWC, pNew, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + _exprAnalyze(tls, pSrc, pWC, idxNew) + /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where reused */ + _markTermAsChild(tls, pWC, idxNew, idxTerm) + } else { + _sqlite3ExprListDelete(tls, db, pList) + } + } + } +} + +// C documentation +// +// /* +// ** Gobble up the first bareword or quoted word from the input buffer zIn. +// ** Return a pointer to the character immediately following the last in +// ** the gobbled word if successful, or a NULL pointer otherwise (failed +// ** to find close-quote character). +// ** +// ** Before returning, set pzOut to point to a new buffer containing a +// ** nul-terminated, dequoted copy of the gobbled word. If the word was +// ** quoted, *pbQuoted is also set to 1 before returning. +// ** +// ** If *pRc is other than SQLITE_OK when this function is called, it is +// ** a no-op (NULL is returned). Otherwise, if an OOM occurs within this +// ** function, *pRc is set to SQLITE_NOMEM before returning. *pRc is *not* +// ** set if a parse error (failed to find close quote) occurs. +// */ +func _fts5ConfigGobbleWord(tls *libc.TLS, pRc uintptr, zIn uintptr, pzOut uintptr, pbQuoted uintptr) (r uintptr) { + var ii int32 + var nIn Tsqlite3_int64 + var zOut, zRet uintptr + _, _, _, _ = ii, nIn, zOut, zRet + zRet = uintptr(0) + nIn = libc.Int64FromUint64(libc.Xstrlen(tls, zIn)) + zOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nIn+int64(1))) + **(**int32)(__ccgo_up(pbQuoted)) = 0 + **(**uintptr)(__ccgo_up(pzOut)) = uintptr(0) + if zOut == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, zOut, zIn, libc.Uint64FromInt64(nIn+libc.Int64FromInt32(1))) + if _fts5_isopenquote(tls, **(**int8)(__ccgo_up(zOut))) != 0 { + ii = _fts5Dequote(tls, zOut) + zRet = zIn + uintptr(ii) + **(**int32)(__ccgo_up(pbQuoted)) = int32(1) + } else { + zRet = _fts5ConfigSkipBareword(tls, zIn) + if zRet != 0 { + **(**int8)(__ccgo_up(zOut + uintptr(int64(zRet)-int64(zIn)))) = int8('\000') + } + } + } + if zRet == uintptr(0) { + Xsqlite3_free(tls, zOut) + } else { + **(**uintptr)(__ccgo_up(pzOut)) = zOut + } + return zRet +} + +// C documentation +// +// /* +// ** Implementation of fts5_locale(LOCALE, TEXT) function. +// ** +// ** If parameter LOCALE is NULL, or a zero-length string, then a copy of +// ** TEXT is returned. Otherwise, both LOCALE and TEXT are interpreted as +// ** text, and the value returned is a blob consisting of: +// ** +// ** * The 4 bytes 0x00, 0xE0, 0xB2, 0xEb (FTS5_LOCALE_HEADER). +// ** * The LOCALE, as utf-8 text, followed by +// ** * 0x00, followed by +// ** * The TEXT, as utf-8 text. +// ** +// ** There is no final nul-terminator following the TEXT value. +// */ +func _fts5LocaleFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var nBlob, nLocale, nText Ti64 + var p, pBlob, pCsr, zLocale, zText, v1 uintptr + _, _, _, _, _, _, _, _, _ = nBlob, nLocale, nText, p, pBlob, pCsr, zLocale, zText, v1 + zLocale = uintptr(0) + nLocale = 0 + zText = uintptr(0) + nText = 0 + _ = nArg + zLocale = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg))) + nLocale = int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg)))) + zText = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + nText = int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg + 1*8)))) + if zLocale == uintptr(0) || int32(**(**int8)(__ccgo_up(zLocale))) == int32('\000') { + Xsqlite3_result_text(tls, pCtx, zText, int32(nText), uintptr(-libc.Int32FromInt32(1))) + } else { + p = Xsqlite3_user_data(tls, pCtx) + pBlob = uintptr(0) + pCsr = uintptr(0) + nBlob = 0 + nBlob = int64(libc.Int32FromInt64(16)) + nLocale + int64(1) + nText + pBlob = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nBlob)) + if pBlob == uintptr(0) { + Xsqlite3_result_error_nomem(tls, pCtx) + return + } + pCsr = pBlob + libc.Xmemcpy(tls, pCsr, p+96, libc.Uint64FromInt32(libc.Int32FromInt64(16))) + pCsr = pCsr + uintptr(libc.Int32FromInt64(16)) + libc.Xmemcpy(tls, pCsr, zLocale, libc.Uint64FromInt64(nLocale)) + pCsr = pCsr + uintptr(nLocale) + v1 = pCsr + pCsr = pCsr + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8(0x00) + if zText != 0 { + libc.Xmemcpy(tls, pCsr, zText, libc.Uint64FromInt64(nText)) + } + Xsqlite3_result_blob(tls, pCtx, pBlob, int32(nBlob), __ccgo_fp(Xsqlite3_free)) + } +} + +func _fts5PorterCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken int32, iStart int32, iEnd int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aBuf, p uintptr + var c int8 + var v1 int32 + var _ /* nBuf at bp+0 */ int32 + _, _, _, _ = aBuf, c, p, v1 + p = pCtx + if nToken > int32(FTS5_PORTER_MAX_TOKEN) || nToken < int32(3) { + goto pass_through + } + aBuf = (*TPorterContext)(unsafe.Pointer(p)).FaBuf + **(**int32)(__ccgo_up(bp)) = nToken + libc.Xmemcpy(tls, aBuf, pToken, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))) + /* Step 1. */ + _fts5PorterStep1A(tls, aBuf, bp) + if _fts5PorterStep1B(tls, aBuf, bp) != 0 { + if _fts5PorterStep1B2(tls, aBuf, bp) == 0 { + c = **(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1)))) + if _fts5PorterIsVowel(tls, c, 0) == 0 && int32(c) != int32('l') && int32(c) != int32('s') && int32(c) != int32('z') && int32(c) == int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(2))))) { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } else { + if _fts5Porter_MEq1(tls, aBuf, **(**int32)(__ccgo_up(bp))) != 0 && _fts5Porter_Ostar(tls, aBuf, **(**int32)(__ccgo_up(bp))) != 0 { + v1 = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(aBuf + uintptr(v1))) = int8('e') + } + } + } + } + /* Step 1C. */ + if int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('y') && _fts5Porter_Vowel(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 { + **(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1)))) = int8('i') + } + /* Steps 2 through 4. */ + _fts5PorterStep2(tls, aBuf, bp) + _fts5PorterStep3(tls, aBuf, bp) + _fts5PorterStep4(tls, aBuf, bp) + /* Step 5a. */ + if int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('e') { + if _fts5Porter_MGt1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 || _fts5Porter_MEq1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 && !(_fts5Porter_Ostar(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0) { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } + } + /* Step 5b. */ + if **(**int32)(__ccgo_up(bp)) > int32(1) && int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('l') && int32(**(**int8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(2))))) == int32('l') && _fts5Porter_MGt1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } + return (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterContext)(unsafe.Pointer(p)).FxToken})))(tls, (*TPorterContext)(unsafe.Pointer(p)).FpCtx, tflags, aBuf, **(**int32)(__ccgo_up(bp)), iStart, iEnd) + goto pass_through +pass_through: + ; + return (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterContext)(unsafe.Pointer(p)).FxToken})))(tls, (*TPorterContext)(unsafe.Pointer(p)).FpCtx, tflags, pToken, nToken, iStart, iEnd) + return r +} + +// C documentation +// +// /* +// ** Trigram tokenizer tokenize routine. +// */ +func _fts5TriTokenize(tls *libc.TLS, pTok uintptr, pCtx uintptr, unusedFlags int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aStart [3]int32 + var iCode Tu32 + var iNext, ii, rc int32 + var p, z1, zEof, zIn, zOut, v1 uintptr + var _ /* aBuf at bp+0 */ [32]int8 + _, _, _, _, _, _, _, _, _, _, _ = aStart, iCode, iNext, ii, p, rc, z1, zEof, zIn, zOut, v1 + p = pTok + rc = SQLITE_OK + zOut = bp + zIn = pText + if zIn != 0 { + v1 = zIn + uintptr(nText) + } else { + v1 = uintptr(0) + } + zEof = v1 + iCode = uint32(0) /* Input offset of each character in aBuf[] */ + _ = unusedFlags + /* Populate aBuf[] with the characters for the first trigram. */ + ii = 0 + for { + if !(ii < int32(3)) { + break + } + for cond := true; cond; cond = iCode == uint32(0) { + aStart[ii] = int32(int64(zIn) - int64(pText)) + if zIn >= zEof { + return SQLITE_OK + } + v1 = zIn + zIn = zIn + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v1))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zIn < zEof && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn)))&int32(0xc0) == int32(0x80) { + v1 = zIn + zIn = zIn + 1 + iCode = iCode<>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + /* At the start of each iteration of this loop: + ** + ** aBuf: Contains 3 characters. The 3 characters of the next trigram. + ** zOut: Points to the byte following the last character in aBuf. + ** aStart[3]: Contains the byte offset in the input text corresponding + ** to the start of each of the three characters in the buffer. + */ + for int32(1) != 0 { + /* Read characters from the input up until the first non-diacritic */ + for cond := true; cond; cond = iCode == uint32(0) { + iNext = int32(int64(zIn) - int64(pText)) + if zIn >= zEof { + iCode = uint32(0) + break + } + v1 = zIn + zIn = zIn + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v1))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zIn < zEof && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn)))&int32(0xc0) == int32(0x80) { + v1 = zIn + zIn = zIn + 1 + iCode = iCode<= int32(0xc0) { + for libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z1))))&int32(0xc0) == int32(0x80) { + z1 = z1 + 1 + } + } + libc.Xmemmove(tls, bp, z1, libc.Uint64FromInt64(int64(zOut)-int64(z1))) + zOut = zOut - uintptr(int64(z1)-t__predefined_ptrdiff_t(bp)) + if iCode < uint32(0x00080) { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = libc.Int8FromUint8(uint8(iCode & libc.Uint32FromInt32(0xFF))) + } else { + if iCode < uint32(0x00800) { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xC0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + /* Update the aStart[] array */ + aStart[0] = aStart[int32(1)] + aStart[int32(1)] = aStart[int32(2)] + aStart[int32(2)] = iNext + } + return rc +} + +func _fts5UnicodeTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + var a, aFold, p, pEnd, zCsr, zOut, zTerm, v3 uintptr + var iCode Tu32 + var ie, is, nFold, rc, v7 int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, aFold, iCode, ie, is, nFold, p, pEnd, rc, zCsr, zOut, zTerm, v3, v7 + p = pTokenizer + rc = SQLITE_OK + a = p + zTerm = pText + uintptr(nText) + zCsr = pText + /* Output buffer */ + aFold = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold + nFold = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold + pEnd = aFold + uintptr(nFold-int32(6)) + _ = iUnused + /* Each iteration of this loop gobbles up a contiguous run of separators, + ** then the next token. */ +_2: + ; + if !(rc == SQLITE_OK) { + goto _1 + } /* non-ASCII codepoint read from input */ + zOut = aFold + /* Skip any separator characters. */ + for int32(1) != 0 { + if zCsr >= zTerm { + goto tokenize_done + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0x80) != 0 { + /* A character outside of the ascii range. Skip past it if it is + ** a separator character. Or break out of the loop if it is not. */ + is = int32(int64(zCsr) - int64(pText)) + v3 = zCsr + zCsr = zCsr + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v3))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zCsr < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0xc0) == int32(0x80) { + v3 = zCsr + zCsr = zCsr + 1 + iCode = iCode< pEnd { + aFold = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nFold)*int64(2))) + if aFold == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto tokenize_done + } + zOut = aFold + uintptr(int64(zOut)-int64((*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold)) + libc.Xmemcpy(tls, aFold, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold, libc.Uint64FromInt32(nFold)) + Xsqlite3_free(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold = aFold + v7 = nFold * libc.Int32FromInt32(2) + nFold = v7 + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold = v7 + pEnd = aFold + uintptr(nFold-int32(6)) + } + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0x80) != 0) { + goto _8 + } + /* An non-ascii-range character. Fold it into the output buffer if + ** it is a token character, or break out of the loop if it is not. */ + v3 = zCsr + zCsr = zCsr + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v3))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zCsr < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0xc0) == int32(0x80) { + v3 = zCsr + zCsr = zCsr + 1 + iCode = iCode<>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + } + goto _13 +_12: + ; + goto _5 +_13: + ; + goto _9 +_8: + ; + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(a + uintptr(**(**uint8)(__ccgo_up(zCsr)))))) == 0) { + goto _24 + } + /* An ascii-range separator character. End of token. */ + goto _5 + goto _25 +_24: + ; + goto ascii_tokenchar +ascii_tokenchar: + ; + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) >= int32('A') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) <= int32('Z') { + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = int8(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) + int32(32)) + } else { + v3 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v3)) = libc.Int8FromUint8(**(**uint8)(__ccgo_up(zCsr))) + } + zCsr = zCsr + 1 +_25: + ; +_9: + ; + ie = int32(int64(zCsr) - int64(pText)) + goto _6 +_5: + ; + /* Invoke the token callback */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xToken})))(tls, pCtx, 0, aFold, int32(int64(zOut)-int64(aFold)), is, ie) + goto _2 +_1: + ; + goto tokenize_done +tokenize_done: + ; + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + return rc +} + +/************************************************************************** +** Start of porter stemmer implementation. + */ + +/* Any tokens larger than this (in bytes) are passed through without +** stemming. */ + +// C documentation +// +// /* +// ** If the input is a well-formed JSON array of coordinates with at least +// ** four coordinates and where each coordinate is itself a two-value array, +// ** then convert the JSON into a GeoPoly object and return a pointer to +// ** that object. +// ** +// ** If any error occurs, return NULL. +// */ +func _geopolyParseJson(tls *libc.TLS, z uintptr, pRc uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aNew, pOut, v1 uintptr + var c int8 + var ii, rc int32 + var v2 bool + var _ /* s at bp+0 */ TGeoParse + var _ /* x at bp+32 */ int32 + _, _, _, _, _, _, _ = aNew, c, ii, pOut, rc, v1, v2 + rc = SQLITE_OK + libc.Xmemset(tls, bp, 0, uint64(32)) + (**(**TGeoParse)(__ccgo_up(bp))).Fz = z + if int32(_geopolySkipSpace(tls, bp)) == int32('[') { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + for int32(_geopolySkipSpace(tls, bp)) == int32('[') { + ii = 0 + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + if (**(**TGeoParse)(__ccgo_up(bp))).FnVertex >= (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc { + (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc = (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc*int32(2) + int32(16) + aNew = Xsqlite3_realloc64(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa, uint64(libc.Uint64FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnAlloc)*uint64(4)*uint64(2))) + if aNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + break + } + (**(**TGeoParse)(__ccgo_up(bp))).Fa = aNew + } + for { + if ii <= int32(1) { + v1 = (**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)+ii)*4 + } else { + v1 = uintptr(0) + } + if !(_geopolyParseNumber(tls, bp, v1) != 0) { + break + } + ii = ii + 1 + if ii == int32(2) { + (**(**TGeoParse)(__ccgo_up(bp))).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex + 1 + } + c = _geopolySkipSpace(tls, bp) + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + if int32(c) == int32(',') { + continue + } + if int32(c) == int32(']') && ii >= int32(2) { + break + } + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + rc = int32(SQLITE_ERROR) + goto parse_json_err + } + if int32(_geopolySkipSpace(tls, bp)) == int32(',') { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + continue + } + break + } + if v2 = int32(_geopolySkipSpace(tls, bp)) == int32(']') && (**(**TGeoParse)(__ccgo_up(bp))).FnVertex >= int32(4) && **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa)) == **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)-int32(2))*4)) && **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + 1*4)) == **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)-int32(1))*4)); v2 { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + } + if v2 && int32(_geopolySkipSpace(tls, bp)) == libc.Int32FromInt32(0) { + **(**int32)(__ccgo_up(bp + 32)) = int32(1) + (**(**TGeoParse)(__ccgo_up(bp))).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex - 1 /* Remove the redundant vertex at the end */ + pOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(40)+uint64(libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2))*libc.Uint64FromInt64(int64((**(**TGeoParse)(__ccgo_up(bp))).FnVertex)-libc.Int64FromInt32(4))) + **(**int32)(__ccgo_up(bp + 32)) = int32(1) + if pOut == uintptr(0) { + goto parse_json_err + } + (*TGeoPoly)(unsafe.Pointer(pOut)).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex + libc.Xmemcpy(tls, pOut+8, (**(**TGeoParse)(__ccgo_up(bp))).Fa, libc.Uint64FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2))*uint64(4)) + **(**uint8)(__ccgo_up(pOut + 4)) = **(**uint8)(__ccgo_up(bp + 32)) + **(**uint8)(__ccgo_up(pOut + 4 + 1)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex >> int32(16) & int32(0xff)) + **(**uint8)(__ccgo_up(pOut + 4 + 2)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex >> int32(8) & int32(0xff)) + **(**uint8)(__ccgo_up(pOut + 4 + 3)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex & int32(0xff)) + Xsqlite3_free(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa) + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = SQLITE_OK + } + return pOut + } else { + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + rc = int32(SQLITE_ERROR) + } + } + goto parse_json_err +parse_json_err: + ; + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = rc + } + Xsqlite3_free(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa) + return uintptr(0) +} + +// C documentation +// +// /* Append the N-byte string in zIn to the end of the JsonString string +// ** under construction. Enclose the string in double-quotes ("...") and +// ** escape any double-quotes or backslash characters contained within the +// ** string. +// ** +// ** This routine is a high-runner. There is a measurable performance +// ** increase associated with unwinding the jsonIsOk[] loop. +// */ +func _jsonAppendString(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + var c Tu8 + var k Tu32 + var z, v2 uintptr + var v1 Tu64 + _, _, _, _, _ = c, k, z, v1, v2 + z = zIn + if z == uintptr(0) { + return + } + if uint64(N)+(*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(2) >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(2)) != 0 { + return + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = int8('"') + for int32(1) != 0 { + k = uint32(0) + /* The following while() is the 4-way unwound equivalent of + ** + ** while( k= N { + for k < N && _jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k)))] != 0 { + k = k + 1 + } + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k)))] != 0) { + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(1))))] != 0) { + k = k + uint32(1) + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(2))))] != 0) { + k = k + uint32(2) + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(3))))] != 0) { + k = k + uint32(3) + break + } else { + k = k + uint32(4) + } + } + if k >= N { + if k > uint32(0) { + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), z, uint64(k)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(k) + } + break + } + if k > uint32(0) { + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), z, uint64(k)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(k) + z = z + uintptr(k) + N = N - k + } + c = **(**Tu8)(__ccgo_up(z)) + if libc.Int32FromUint8(c) == int32('"') || libc.Int32FromUint8(c) == int32('\\') { + if (*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(N)+uint64(3) > (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(3)) != 0 { + return + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = int8('\\') + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = libc.Int8FromUint8(c) + } else { + if libc.Int32FromUint8(c) == int32('\'') { + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = libc.Int8FromUint8(c) + } else { + if (*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(N)+uint64(7) > (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(7)) != 0 { + return + } + _jsonAppendControlChar(tls, p, c) + } + } + z = z + 1 + N = N - 1 + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = int8('"') +} + +// C documentation +// +// /* This helper routine for jsonLookupStep() populates pIns with +// ** binary data that is to be inserted into pParse. +// ** +// ** In the common case, pIns just points to pParse->aIns and pParse->nIns. +// ** But if the zPath of the original edit operation includes path elements +// ** that go deeper, additional substructure must be created. +// ** +// ** For example: +// ** +// ** json_insert('{}', '$.a.b.c', 123); +// ** +// ** The search stops at '$.a' But additional substructure must be +// ** created for the ".b.c" part of the patch so that the final result +// ** is: {"a":{"b":{"c"::123}}}. This routine populates pIns with +// ** the binary equivalent of {"b":{"c":123}} so that it can be inserted. +// ** +// ** The caller is responsible for resetting pIns when it has finished +// ** using the substructure. +// */ +func _jsonCreateEditSubstructure(tls *libc.TLS, pParse uintptr, pIns uintptr, zTail uintptr) (r Tu32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + libc.Xmemset(tls, pIns, 0, uint64(72)) + (*TJsonParse)(unsafe.Pointer(pIns)).Fdb = (*TJsonParse)(unsafe.Pointer(pParse)).Fdb + if int32(**(**int8)(__ccgo_up(zTail))) == 0 { + /* No substructure. Just insert what is given in pParse. */ + (*TJsonParse)(unsafe.Pointer(pIns)).FaBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FaIns + (*TJsonParse)(unsafe.Pointer(pIns)).FnBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FnIns + rc = 0 + } else { + /* Construct the binary substructure */ + (*TJsonParse)(unsafe.Pointer(pIns)).FnBlob = uint32(1) + (*TJsonParse)(unsafe.Pointer(pIns)).FaBlob = uintptr(unsafe.Pointer(&_emptyObject)) + libc.BoolUintptr(int32(**(**int8)(__ccgo_up(zTail))) == int32('.')) + (*TJsonParse)(unsafe.Pointer(pIns)).FeEdit = (*TJsonParse)(unsafe.Pointer(pParse)).FeEdit + (*TJsonParse)(unsafe.Pointer(pIns)).FnIns = (*TJsonParse)(unsafe.Pointer(pParse)).FnIns + (*TJsonParse)(unsafe.Pointer(pIns)).FaIns = (*TJsonParse)(unsafe.Pointer(pParse)).FaIns + (*TJsonParse)(unsafe.Pointer(pIns)).FiDepth = libc.Uint16FromInt32(libc.Int32FromUint16((*TJsonParse)(unsafe.Pointer(pParse)).FiDepth) + int32(1)) + if libc.Int32FromUint16((*TJsonParse)(unsafe.Pointer(pIns)).FiDepth) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = libc.Int32FromUint32(_jsonLookupStep(tls, pIns, uint32(0), zTail, uint32(0))) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + v1 = pParse + 47 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pIns)).Foom)) + } + return libc.Uint32FromInt32(rc) /* Error code only */ +} + +// C documentation +// +// /* +// ** json_error_position(JSON) +// ** +// ** If the argument is NULL, return NULL +// ** +// ** If the argument is BLOB, do a full validity check and return non-zero +// ** if the check fails. The return value is the approximate 1-based offset +// ** to the byte of the element that contains the first error. +// ** +// ** Otherwise interpret the argument is TEXT (even if it is numeric) and +// ** return the 1-based character position for where the parser first recognized +// ** that the input was not valid JSON, or return 0 if the input text looks +// ** ok. JSON-5 extensions are accepted. +// */ +func _jsonErrorFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iErrPos Ti64 + var k Tu32 + var _ /* s at bp+0 */ TJsonParse + _, _ = iErrPos, k + iErrPos = 0 + _ = argc + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TJsonParse)(__ccgo_up(bp))).Fdb = Xsqlite3_context_db_handle(tls, ctx) + if _jsonArgIsJsonb(tls, **(**uintptr)(__ccgo_up(argv)), bp) != 0 { + iErrPos = libc.Int64FromUint32(_jsonbValidityCheck(tls, bp, uint32(0), (**(**TJsonParse)(__ccgo_up(bp))).FnBlob, uint32(1))) + } else { + (**(**TJsonParse)(__ccgo_up(bp))).FzJson = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if (**(**TJsonParse)(__ccgo_up(bp))).FzJson == uintptr(0) { + return + } /* NULL input or OOM */ + (**(**TJsonParse)(__ccgo_up(bp))).FnJson = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if _jsonConvertTextToBlob(tls, bp, uintptr(0)) != 0 { + if (**(**TJsonParse)(__ccgo_up(bp))).Foom != 0 { + iErrPos = int64(-int32(1)) + } else { + /* Because s.oom is false */ + k = uint32(0) + for { + if !(k < (**(**TJsonParse)(__ccgo_up(bp))).FiErr && **(**int8)(__ccgo_up((**(**TJsonParse)(__ccgo_up(bp))).FzJson + uintptr(k))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up((**(**TJsonParse)(__ccgo_up(bp))).FzJson + uintptr(k))))&int32(0xc0) != int32(0x80) { + iErrPos = iErrPos + 1 + } + goto _1 + _1: + ; + k = k + 1 + } + iErrPos = iErrPos + 1 + } + } + } + _jsonParseReset(tls, bp) + if iErrPos < 0 { + Xsqlite3_result_error_nomem(tls, ctx) + } else { + Xsqlite3_result_int64(tls, ctx, iErrPos) + } +} + +// C documentation +// +// /* +// ** Open an mem file handle. +// */ +func _memdbOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFd uintptr, flags int32, pOutFlags uintptr) (r int32) { + var apNew, p, pFile, pVfsMutex, v3 uintptr + var i, szName, v2 int32 + _, _, _, _, _, _, _, _ = apNew, i, p, pFile, pVfsMutex, szName, v2, v3 + pFile = pFd + p = uintptr(0) + _ = pVfs + libc.Xmemset(tls, pFile, 0, uint64(24)) + szName = _sqlite3Strlen30(tls, zName) + if szName > int32(1) && (int32(**(**int8)(__ccgo_up(zName))) == int32('/') || int32(**(**int8)(__ccgo_up(zName))) == int32('\\')) { + pVfsMutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1)) + Xsqlite3_mutex_enter(tls, pVfsMutex) + i = 0 + for { + if !(i < _memdb_g.FnMemStore) { + break + } + if libc.Xstrcmp(tls, (*TMemStore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(i)*8)))).FzFName, zName) == 0 { + p = **(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(i)*8)) + break + } + goto _1 + _1: + ; + i = i + 1 + } + if p == uintptr(0) { + p = _sqlite3Malloc(tls, uint64(72)+libc.Uint64FromInt64(int64(szName))+uint64(3)) + if p == uintptr(0) { + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + apNew = _sqlite3Realloc(tls, _memdb_g.FapMemStore, uint64(8)*libc.Uint64FromInt64(libc.Int64FromInt32(1)+int64(_memdb_g.FnMemStore))) + if apNew == uintptr(0) { + Xsqlite3_free(tls, p) + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + v3 = uintptr(unsafe.Pointer(&_memdb_g)) + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up(apNew + uintptr(v2)*8)) = p + _memdb_g.FapMemStore = apNew + libc.Xmemset(tls, p, 0, uint64(72)) + (*TMemStore)(unsafe.Pointer(p)).FmFlags = libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DESERIALIZE_RESIZEABLE) | libc.Int32FromInt32(SQLITE_DESERIALIZE_FREEONCLOSE)) + (*TMemStore)(unsafe.Pointer(p)).FszMax = _sqlite3Config.FmxMemdbSize + (*TMemStore)(unsafe.Pointer(p)).FzFName = p + 1*72 + libc.Xmemcpy(tls, (*TMemStore)(unsafe.Pointer(p)).FzFName, zName, libc.Uint64FromInt32(szName+int32(1))) + (*TMemStore)(unsafe.Pointer(p)).FpMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) + if (*TMemStore)(unsafe.Pointer(p)).FpMutex == uintptr(0) { + _memdb_g.FnMemStore = _memdb_g.FnMemStore - 1 + Xsqlite3_free(tls, p) + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + (*TMemStore)(unsafe.Pointer(p)).FnRef = int32(1) + _memdbEnter(tls, p) + } else { + _memdbEnter(tls, p) + (*TMemStore)(unsafe.Pointer(p)).FnRef = (*TMemStore)(unsafe.Pointer(p)).FnRef + 1 + } + Xsqlite3_mutex_leave(tls, pVfsMutex) + } else { + p = _sqlite3Malloc(tls, uint64(72)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, p, 0, uint64(72)) + (*TMemStore)(unsafe.Pointer(p)).FmFlags = libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DESERIALIZE_RESIZEABLE) | libc.Int32FromInt32(SQLITE_DESERIALIZE_FREEONCLOSE)) + (*TMemStore)(unsafe.Pointer(p)).FszMax = _sqlite3Config.FmxMemdbSize + } + (*TMemFile)(unsafe.Pointer(pFile)).FpStore = p + if pOutFlags != uintptr(0) { + **(**int32)(__ccgo_up(pOutFlags)) = flags | int32(SQLITE_OPEN_MEMORY) + } + (*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods = uintptr(unsafe.Pointer(&_memdb_io_methods)) + _memdbLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Apply a delta. +// ** +// ** The output buffer should be big enough to hold the whole output +// ** file and a NUL terminator at the end. The delta_output_size() +// ** routine will determine this size for you. +// ** +// ** The delta string should be null-terminated. But the delta string +// ** may contain embedded NUL characters (if the input and output are +// ** binary files) so we also have to pass in the length of the delta in +// ** the lenDelta parameter. +// ** +// ** This function returns the size of the output file in bytes (excluding +// ** the final NUL terminator character). Except, if the delta string is +// ** malformed or intended for use with a source file other than zSrc, +// ** then this routine returns -1. +// ** +// ** Refer to the delta_create() documentation above for a description +// ** of the delta file format. +// */ +func _rbuDeltaApply(tls *libc.TLS, zSrc uintptr, lenSrc int32, _zDelta uintptr, _lenDelta int32, zOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _zDelta + *(*int32)(unsafe.Pointer(bp + 8)) = _lenDelta + var cnt, limit, ofst, total uint32 + _, _, _, _ = cnt, limit, ofst, total + total = uint32(0) + limit = _rbuDeltaGetInt(tls, bp, bp+8) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32('\n') { + /* ERROR: size integer not terminated by "\n" */ + return -int32(1) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + for **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0 && **(**int32)(__ccgo_up(bp + 8)) > 0 { + cnt = _rbuDeltaGetInt(tls, bp, bp+8) + switch int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) { + case int32('@'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + ofst = _rbuDeltaGetInt(tls, bp, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) > 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(',') { + /* ERROR: copy command not terminated by ',' */ + return -int32(1) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + total = total + cnt + if total > limit { + /* ERROR: copy exceeds output file size */ + return -int32(1) + } + if uint64(ofst)+uint64(cnt) > libc.Uint64FromInt32(lenSrc) { + /* ERROR: copy extends past end of input */ + return -int32(1) + } + libc.Xmemcpy(tls, zOut, zSrc+uintptr(ofst), uint64(cnt)) + zOut = zOut + uintptr(cnt) + case int32(':'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + total = total + cnt + if total > limit { + /* ERROR: insert command gives an output larger than predicted */ + return -int32(1) + } + if libc.Int32FromUint32(cnt) > **(**int32)(__ccgo_up(bp + 8)) { + /* ERROR: insert count exceeds size of delta */ + return -int32(1) + } + libc.Xmemcpy(tls, zOut, **(**uintptr)(__ccgo_up(bp)), uint64(cnt)) + zOut = zOut + uintptr(cnt) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(cnt) + **(**int32)(__ccgo_up(bp + 8)) = libc.Int32FromUint32(uint32(**(**int32)(__ccgo_up(bp + 8))) - cnt) + case int32(';'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + **(**int8)(__ccgo_up(zOut)) = 0 + if total != limit { + /* ERROR: generated size does not match predicted size */ + return -int32(1) + } + return libc.Int32FromUint32(total) + default: + /* ERROR: unknown delta operator */ + return -int32(1) + } + } + /* ERROR: unterminated delta */ + return -int32(1) +} + +// C documentation +// +// /* +// ** Rtree virtual table module xBestIndex method. There are three +// ** table scan strategies to choose from (in order from most to +// ** least desirable): +// ** +// ** idxNum idxStr Strategy +// ** ------------------------------------------------ +// ** 1 Unused Direct lookup by rowid. +// ** 2 See below R-tree query or full-table scan. +// ** ------------------------------------------------ +// ** +// ** If strategy 1 is used, then idxStr is not meaningful. If strategy +// ** 2 is used, idxStr is formatted to contain 2 bytes for each +// ** constraint used. The first two bytes of idxStr correspond to +// ** the constraint in sqlite3_index_info.aConstraintUsage[] with +// ** (argvIndex==1) etc. +// ** +// ** The first of each pair of bytes in idxStr identifies the constraint +// ** operator as follows: +// ** +// ** Operator Byte Value +// ** ---------------------- +// ** = 0x41 ('A') +// ** <= 0x42 ('B') +// ** < 0x43 ('C') +// ** >= 0x44 ('D') +// ** > 0x45 ('E') +// ** MATCH 0x46 ('F') +// ** ---------------------- +// ** +// ** The second of each pair of bytes identifies the coordinate column +// ** to which the constraint applies. The leftmost coordinate column +// ** is 'a', the second from the left 'b' etc. +// */ +func _rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bMatch, iIdx, ii, jj, rc, v4 int32 + var doOmit, op Tu8 + var nRow Ti64 + var p, pRtree uintptr + var _ /* zIdxStr at bp+0 */ [41]int8 + _, _, _, _, _, _, _, _, _, _, _ = bMatch, doOmit, iIdx, ii, jj, nRow, op, p, pRtree, rc, v4 + pRtree = tab + rc = SQLITE_OK + bMatch = 0 /* Estimated rows returned by this scan */ + iIdx = 0 + libc.Xmemset(tls, bp, 0, uint64(41)) + /* Check if there exists a MATCH constraint - even an unusable one. If there + ** is, do not consider the lookup-by-rowid plan as using such a plan would + ** require the VDBE to evaluate the MATCH constraint, which is not currently + ** possible. */ + ii = 0 + for { + if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + if libc.Int32FromUint8((**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12))).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH) { + bMatch = int32(1) + } + goto _1 + _1: + ; + ii = ii + 1 + } + ii = 0 + for { + if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint && iIdx < libc.Int32FromUint64(libc.Uint64FromInt64(41)-libc.Uint64FromInt32(1))) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12 + if bMatch == 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) { + jj = 0 + for { + if !(jj < ii) { + break + } + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).FargvIndex = 0 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).Fomit = uint8(0) + goto _3 + _3: + ; + jj = jj + 1 + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).Fomit = uint8(1) + /* This strategy involves a two rowid lookups on an B-Tree structures + ** and then a linear search of an R-Tree node. This should be + ** considered almost as quick as a direct rowid lookup (for which + ** sqlite uses an internal cost of 0.0). It is expected to return + ** a single row. + */ + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(30) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = int32(SQLITE_INDEX_SCAN_UNIQUE) + return SQLITE_OK + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 && ((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn > 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH)) { + doOmit = uint8(1) + switch libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) { + case int32(SQLITE_INDEX_CONSTRAINT_EQ): + op = uint8(RTREE_EQ) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_GT): + op = uint8(RTREE_GT) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_LE): + op = uint8(RTREE_LE) + case int32(SQLITE_INDEX_CONSTRAINT_LT): + op = uint8(RTREE_LT) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_GE): + op = uint8(RTREE_GE) + case int32(SQLITE_INDEX_CONSTRAINT_MATCH): + op = uint8(RTREE_MATCH) + default: + op = uint8(0) + break + } + if op != 0 { + v4 = iIdx + iIdx = iIdx + 1 + (**(**[41]int8)(__ccgo_up(bp)))[v4] = libc.Int8FromUint8(op) + v4 = iIdx + iIdx = iIdx + 1 + (**(**[41]int8)(__ccgo_up(bp)))[v4] = int8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn - libc.Int32FromInt32(1) + libc.Int32FromUint8('0')) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).FargvIndex = iIdx / int32(2) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).Fomit = doOmit + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(2) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = int32(1) + if iIdx > 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = Xsqlite3_malloc(tls, iIdx+int32(1)) + if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr, bp, libc.Uint64FromInt32(iIdx+int32(1))) + } + nRow = (*TRtree)(unsafe.Pointer(pRtree)).FnRowEst >> (iIdx / int32(2)) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(libc.Float64FromFloat64(6) * float64(nRow)) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = nRow + return rc +} + +// C documentation +// +// /* +// ** Rtree virtual table module xFilter method. +// */ +func _rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eType, eType1, ii, rc int32 + var iRowid Ti64 + var iVal Tsqlite3_int64 + var p, p1, pCsr, pNew, pRtree uintptr + var _ /* iCell at bp+8 */ int32 + var _ /* iNode at bp+24 */ Ti64 + var _ /* pLeaf at bp+16 */ uintptr + var _ /* pRoot at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = eType, eType1, iRowid, iVal, ii, p, p1, pCsr, pNew, pRtree, rc + pRtree = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab + pCsr = pVtabCursor + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 8)) = 0 + _rtreeReference(tls, pRtree) + /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ + _resetCursor(tls, pCsr) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FiStrategy = idxNum + if idxNum == int32(1) { /* Search point for the leaf */ + iRowid = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + **(**Ti64)(__ccgo_up(bp + 24)) = 0 + eType = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) && 0 == _sqlite3IntFloatCompare(tls, iRowid, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))) { + rc = _findLeafNode(tls, pRtree, iRowid, bp+16, bp+24) + } else { + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + } + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 16)) != uintptr(0) { + p = _rtreeSearchPointNew(tls, pCsr, float64(0), uint8(0)) + /* Always returns pCsr->sPoint */ + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp + 16)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).Fid = **(**Ti64)(__ccgo_up(bp + 24)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = uint8(PARTLY_WITHIN) + rc = _nodeRowidIndex(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 16)), iRowid, bp+8) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 8))) + } else { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FatEOF = uint8(1) + } + } else { + /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array + ** with the configured constraints. + */ + rc = _nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp) + if rc == SQLITE_OK && argc > 0 { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = Xsqlite3_malloc64(tls, uint64(uint64(24)*libc.Uint64FromInt32(argc))) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = argc + if !((*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint != 0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, uint64(24)*libc.Uint64FromInt32(argc)) + libc.Xmemset(tls, pCsr+128, 0, uint64(4)*libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiDepth+libc.Int32FromInt32(1))) + ii = 0 + for { + if !(ii < argc) { + break + } + p1 = (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint + uintptr(ii)*24 + eType1 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8))) + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32(**(**int8)(__ccgo_up(idxStr + uintptr(ii*int32(2))))) + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(**(**int8)(__ccgo_up(idxStr + uintptr(ii*int32(2)+int32(1))))) - int32('0') + if (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop >= int32(RTREE_MATCH) { + /* A MATCH operator. The right-hand-side must be a blob that + ** can be cast into an RtreeMatchArg object. One created using + ** an sqlite3_rtree_geometry_callback() SQL user function. + */ + rc = _deserializeGeometry(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8)), p1) + if rc != SQLITE_OK { + break + } + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FnCoord = libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FanQueue = pCsr + 128 + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FmxLevel = (*TRtree)(unsafe.Pointer(pRtree)).FiDepth + int32(1) + } else { + if eType1 == int32(SQLITE_INTEGER) { + iVal = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8))) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(iVal) + if iVal >= libc.Int64FromInt32(1)<bPoint was FALSE */ + return int32(SQLITE_NOMEM) + } + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = uint8(0) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = uint8(PARTLY_WITHIN) + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _rtreeStepToLeaf(tls, pCsr) + } + } + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** This routine is the core allocator for Expr nodes. +// ** +// ** Construct a new expression node and return a pointer to it. Memory +// ** for this node and for the pToken argument is a single allocation +// ** obtained from sqlite3DbMalloc(). The calling function +// ** is responsible for making sure the node eventually gets freed. +// ** +// ** If dequote is true, then the token (if it exists) is dequoted. +// ** If dequote is false, no dequoting is performed. The deQuote +// ** parameter is ignored if pToken is NULL or if the token does not +// ** appear to be quoted. If the quotes were of the form "..." (double-quotes) +// ** then the EP_DblQuoted flag is set on the expression node. +// ** +// ** Special case (tag-20240227-a): If op==TK_INTEGER and pToken points to +// ** a string that can be translated into a 32-bit integer, then the token is +// ** not stored in u.zToken. Instead, the integer values is written +// ** into u.iValue and the EP_IntValue flag is set. No extra storage +// ** is allocated to hold the integer text and the dequote flag is ignored. +// ** See also tag-20240227-b. +// */ +func _sqlite3ExprAlloc(tls *libc.TLS, db uintptr, op int32, pToken uintptr, dequote int32) (r uintptr) { + var nExtra int32 + var pNew uintptr + var v1 uint32 + _, _, _ = nExtra, pNew, v1 + if pToken != 0 { + v1 = (*TToken)(unsafe.Pointer(pToken)).Fn + uint32(1) + } else { + v1 = uint32(0) + } + nExtra = libc.Int32FromUint32(v1) + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(72)+libc.Uint64FromInt32(nExtra))) + if pNew != 0 { + libc.Xmemset(tls, pNew, 0, uint64(72)) + (*TExpr)(unsafe.Pointer(pNew)).Fop = libc.Uint8FromInt32(op) + (*TExpr)(unsafe.Pointer(pNew)).FiAgg = int16(-int32(1)) + if nExtra != 0 { + *(*uintptr)(unsafe.Pointer(pNew + 8)) = pNew + 1*72 + if (*TToken)(unsafe.Pointer(pToken)).Fn != 0 { + libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(pNew + 8)), (*TToken)(unsafe.Pointer(pToken)).Fz, uint64((*TToken)(unsafe.Pointer(pToken)).Fn)) + } + **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pNew + 8)) + uintptr((*TToken)(unsafe.Pointer(pToken)).Fn))) = 0 + if dequote != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pNew + 8)))))])&int32(0x80) != 0 { + _sqlite3DequoteExpr(tls, pNew) + } + } + (*TExpr)(unsafe.Pointer(pNew)).FnHeight = int32(1) + } + return pNew +} + +// C documentation +// +// /* +// ** Locate a user function given a name, a number of arguments and a flag +// ** indicating whether the function prefers UTF-16 over UTF-8. Return a +// ** pointer to the FuncDef structure that defines that function, or return +// ** NULL if the function does not exist. +// ** +// ** If the createFlag argument is true, then a new (blank) FuncDef +// ** structure is created and liked into the "db" structure if a +// ** no matching function previously existed. +// ** +// ** If nArg is -2, then the first valid function found is returned. A +// ** function is valid if xSFunc is non-zero. The nArg==(-2) +// ** case is used to see if zName is a valid function name for some number +// ** of arguments. If nArg is -2, then createFlag must be 0. +// ** +// ** If createFlag is false, then a function with the required name and +// ** number of arguments may be returned even if the eTextRep flag does not +// ** match that requested. +// */ +func _sqlite3FindFunction(tls *libc.TLS, db uintptr, zName uintptr, nArg int32, enc Tu8, createFlag Tu8) (r uintptr) { + var bestScore, h, nName, score, score1 int32 + var p, pBest, pOther, z, v1 uintptr + var v2 bool + _, _, _, _, _, _, _, _, _, _, _ = bestScore, h, nName, p, pBest, pOther, score, score1, z, v1, v2 /* Iterator variable */ + pBest = uintptr(0) /* Best match found so far */ + bestScore = 0 /* Length of the name */ + nName = _sqlite3Strlen30(tls, zName) + /* First search for a match amongst the application-defined functions. + */ + p = _sqlite3HashFind(tls, db+624, zName) + for p != 0 { + score = _matchQuality(tls, p, nArg, enc) + if score > bestScore { + pBest = p + bestScore = score + } + p = (*TFuncDef)(unsafe.Pointer(p)).FpNext + } + /* If no match is found, search the built-in functions. + ** + ** If the DBFLAG_PreferBuiltin flag is set, then search the built-in + ** functions even if a prior app-defined function was found. And give + ** priority to built-in functions. + ** + ** Except, if createFlag is true, that means that we are trying to + ** install a new function. Whatever FuncDef structure is returned it will + ** have fields overwritten with new information appropriate for the + ** new function. But the FuncDefs for built-in functions are read-only. + ** So we must not search for built-ins when creating a new function. + */ + if !(createFlag != 0) && (pBest == uintptr(0) || (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_PreferBuiltin) != uint32(0)) { + bestScore = 0 + h = (libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zName)))]) + nName) % int32(SQLITE_FUNC_HASH_SZ) + p = _sqlite3FunctionSearch(tls, h, zName) + for p != 0 { + score1 = _matchQuality(tls, p, nArg, enc) + if score1 > bestScore { + pBest = p + bestScore = score1 + } + p = (*TFuncDef)(unsafe.Pointer(p)).FpNext + } + } + /* If the createFlag parameter is true and the search did not reveal an + ** exact match for the name, number of arguments and encoding, then add a + ** new entry to the hash table and return it. + */ + if v2 = createFlag != 0 && bestScore < int32(FUNC_PERFECT_MATCH); v2 { + v1 = _sqlite3DbMallocZero(tls, db, uint64(uint64(72)+libc.Uint64FromInt32(nName)+uint64(1))) + pBest = v1 + } + if v2 && v1 != uintptr(0) { + (*TFuncDef)(unsafe.Pointer(pBest)).FzName = pBest + 1*72 + (*TFuncDef)(unsafe.Pointer(pBest)).FnArg = libc.Int16FromUint16(libc.Uint16FromInt32(nArg)) + (*TFuncDef)(unsafe.Pointer(pBest)).FfuncFlags = uint32(enc) + libc.Xmemcpy(tls, pBest+1*72, zName, libc.Uint64FromInt32(nName+int32(1))) + z = (*TFuncDef)(unsafe.Pointer(pBest)).FzName + for { + if !(**(**Tu8)(__ccgo_up(z)) != 0) { + break + } + **(**Tu8)(__ccgo_up(z)) = _sqlite3UpperToLower[**(**Tu8)(__ccgo_up(z))] + goto _3 + _3: + ; + z = z + 1 + } + pOther = _sqlite3HashInsert(tls, db+624, (*TFuncDef)(unsafe.Pointer(pBest)).FzName, pBest) + if pOther == pBest { + _sqlite3DbFree(tls, db, pBest) + _sqlite3OomFault(tls, db) + return uintptr(0) + } else { + (*TFuncDef)(unsafe.Pointer(pBest)).FpNext = pOther + } + } + if pBest != 0 && ((*TFuncDef)(unsafe.Pointer(pBest)).FxSFunc != 0 || createFlag != 0) { + return pBest + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Parameter zIn contains a rank() function specification. The format of +// ** this is: +// ** +// ** + Bareword (function name) +// ** + Open parenthesis - "(" +// ** + Zero or more SQL literals in a comma separated list +// ** + Close parenthesis - ")" +// */ +func _sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRankArgs uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p, pArgs, pRank, zRank, zRankArgs uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _ = p, pArgs, pRank, zRank, zRankArgs + p = zIn + zRank = uintptr(0) + zRankArgs = uintptr(0) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**uintptr)(__ccgo_up(pzRank)) = uintptr(0) + **(**uintptr)(__ccgo_up(pzRankArgs)) = uintptr(0) + if p == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + p = _fts5ConfigSkipWhitespace(tls, p) + pRank = p + p = _fts5ConfigSkipBareword(tls, p) + if p != 0 { + zRank = _sqlite3Fts5MallocZero(tls, bp, int64(uintptr(1)+p)-int64(pRank)) + if zRank != 0 { + libc.Xmemcpy(tls, zRank, pRank, libc.Uint64FromInt64(int64(p)-int64(pRank))) + } + } else { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + p = _fts5ConfigSkipWhitespace(tls, p) + if int32(**(**int8)(__ccgo_up(p))) != int32('(') { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + p = p + 1 + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + p = _fts5ConfigSkipWhitespace(tls, p) + pArgs = p + if int32(**(**int8)(__ccgo_up(p))) != int32(')') { + p = _fts5ConfigSkipArgs(tls, p) + if p == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + zRankArgs = _sqlite3Fts5MallocZero(tls, bp, int64(uintptr(1)+p)-int64(pArgs)) + if zRankArgs != 0 { + libc.Xmemcpy(tls, zRankArgs, pArgs, libc.Uint64FromInt64(int64(p)-int64(pArgs))) + } + } + } + } + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + Xsqlite3_free(tls, zRank) + } else { + **(**uintptr)(__ccgo_up(pzRank)) = zRank + **(**uintptr)(__ccgo_up(pzRankArgs)) = zRankArgs + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Add an entry to the in-memory hash table. The key is the concatenation +// ** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos). +// ** +// ** (bByte || pToken) -> (iRowid,iCol,iPos) +// ** +// ** Or, if iCol is negative, then the value is a delete marker. +// */ +func _sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid Ti64, iCol int32, iPos int32, bByte int8, pToken uintptr, nToken int32) (r int32) { + var bNew, nIncr, rc, v2 int32 + var iDiff Tu64 + var iHash uint32 + var nByte, nNew Tsqlite3_int64 + var p, pNew, pPtr, pp, zKey, zKey1, v6 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNew, iDiff, iHash, nByte, nIncr, nNew, p, pNew, pPtr, pp, rc, zKey, zKey1, v2, v6 + nIncr = 0 /* If non-delete entry should be written */ + bNew = libc.BoolInt32((*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL) + /* Attempt to locate an existing hash entry */ + iHash = _fts5HashKey2(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot, libc.Uint8FromInt8(bByte), pToken, nToken) + p = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) + for { + if !(p != 0) { + break + } + zKey = p + 1*48 + if int32(**(**int8)(__ccgo_up(zKey))) == int32(bByte) && (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey == nToken+int32(1) && libc.Xmemcmp(tls, zKey+1, pToken, libc.Uint64FromInt32(nToken)) == 0 { + break + } + goto _1 + _1: + ; + p = (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext + } + /* If an existing hash entry cannot be found, create a new one. */ + if p == uintptr(0) { + nByte = libc.Int64FromUint64(uint64(48) + libc.Uint64FromInt32(nToken+libc.Int32FromInt32(1)) + uint64(1) + uint64(64)) + if nByte < int64(128) { + nByte = int64(128) + } + /* Grow the Fts5Hash.aSlot[] array if necessary. */ + if (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry*int32(2) >= (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot { + rc = _fts5HashResize(tls, pHash) + if rc != SQLITE_OK { + return rc + } + iHash = _fts5HashKey2(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot, libc.Uint8FromInt8(bByte), pToken, nToken) + } + /* Allocate new Fts5HashEntry and add it to the hash table. */ + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if !(p != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, p, 0, uint64(48)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc = int32(nByte) + zKey1 = p + 1*48 + **(**int8)(__ccgo_up(zKey1)) = bByte + libc.Xmemcpy(tls, zKey1+1, pToken, libc.Uint64FromInt32(nToken)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey = nToken + int32(1) + **(**int8)(__ccgo_up(zKey1 + uintptr(nToken+int32(1)))) = int8('\000') + (*TFts5HashEntry)(unsafe.Pointer(p)).FnData = libc.Int32FromUint64(libc.Uint64FromInt32(nToken+int32(1)) + uint64(48)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) = p + (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry = (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry + 1 + /* Add the first rowid field to the hash-entry */ + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, p+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt64(iRowid)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid + (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail != int32(FTS5_DETAIL_NONE) { + **(**int32)(__ccgo_up(p + 24)) += int32(1) + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v2 = 0 + } else { + v2 = -int32(1) + } + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + } + } else { + /* Appending to an existing hash-entry. Check that there is enough + ** space to append the largest possible new entry. Worst case scenario + ** is: + ** + ** + 9 bytes for a new rowid, + ** + 4 byte reserved for the "poslist size" varint. + ** + 1 byte for a "new column" byte, + ** + 3 bytes for a new column number (16-bit max) as a varint, + ** + 5 bytes for the new position offset (32-bit max). + */ + if (*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc-(*TFts5HashEntry)(unsafe.Pointer(p)).FnData < libc.Int32FromInt32(9)+libc.Int32FromInt32(4)+libc.Int32FromInt32(1)+libc.Int32FromInt32(3)+libc.Int32FromInt32(5) { + nNew = int64((*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc * int32(2)) + pNew = Xsqlite3_realloc64(tls, p, libc.Uint64FromInt64(nNew)) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TFts5HashEntry)(unsafe.Pointer(pNew)).FnAlloc = int32(nNew) + pp = (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != p) { + break + } + goto _3 + _3: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + } + **(**uintptr)(__ccgo_up(pp)) = pNew + p = pNew + } + nIncr = nIncr - (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + } + pPtr = p + /* If this is a new rowid, append the 4-byte size field for the previous + ** entry, and the new rowid for this entry. */ + if iRowid != (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid { + iDiff = libc.Uint64FromInt64(iRowid) - libc.Uint64FromInt64((*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid) + _fts5HashAddPoslistSize(tls, pHash, p, uintptr(0)) + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), iDiff) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid + bNew = int32(1) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail != int32(FTS5_DETAIL_NONE) { + **(**int32)(__ccgo_up(p + 24)) += int32(1) + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v2 = 0 + } else { + v2 = -int32(1) + } + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = 0 + } + } + if iCol >= 0 { + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == int32(FTS5_DETAIL_NONE) { + (*TFts5HashEntry)(unsafe.Pointer(p)).FbContent = uint8(1) + } else { + /* Append a new column value, if necessary */ + if iCol != int32((*TFts5HashEntry)(unsafe.Pointer(p)).FiCol) { + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v6 = p + 24 + v2 = *(*int32)(unsafe.Pointer(v6)) + *(*int32)(unsafe.Pointer(v6)) = *(*int32)(unsafe.Pointer(v6)) + 1 + **(**Tu8)(__ccgo_up(pPtr + uintptr(v2))) = uint8(0x01) + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt32(iCol)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(iCol) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = 0 + } else { + bNew = int32(1) + v2 = iCol + iPos = v2 + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + } + } + /* Append the new position offset, if necessary */ + if bNew != 0 { + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt32(iPos-(*TFts5HashEntry)(unsafe.Pointer(p)).FiPos+int32(2))) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = iPos + } + } + } else { + /* This is a delete. Set the delete flag. */ + (*TFts5HashEntry)(unsafe.Pointer(p)).FbDel = uint8(1) + } + nIncr = nIncr + (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + **(**int32)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FpnByte)) += nIncr + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return a nul-terminated copy of the string indicated by pIn. If nIn +// ** is non-negative, then it is the length of the string in bytes. Otherwise, +// ** the length of the string is determined using strlen(). +// ** +// ** It is the responsibility of the caller to eventually free the returned +// ** buffer using sqlite3_free(). If an OOM error occurs, NULL is returned. +// */ +func _sqlite3Fts5Strndup(tls *libc.TLS, pRc uintptr, pIn uintptr, nIn int32) (r uintptr) { + var zRet uintptr + _ = zRet + zRet = uintptr(0) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + if nIn < 0 { + nIn = libc.Int32FromUint64(libc.Xstrlen(tls, pIn)) + } + zRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nIn)+int64(1))) + if zRet != 0 { + libc.Xmemcpy(tls, zRet, pIn, libc.Uint64FromInt32(nIn)) + **(**int8)(__ccgo_up(zRet + uintptr(nIn))) = int8('\000') + } else { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } + return zRet +} + +func _sqlite3Fts5TermsetAdd(tls *libc.TLS, p uintptr, iIdx int32, pTerm uintptr, nTerm int32, pbPresent uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var hash Tu32 + var i int32 + var pEntry uintptr + var _ /* rc at bp+0 */ int32 + _, _, _ = hash, i, pEntry + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**int32)(__ccgo_up(pbPresent)) = 0 + if p != 0 { + hash = uint32(13) + /* Calculate a hash value for this term. This is the same hash checksum + ** used by the fts5_hash.c module. This is not important for correct + ** operation of the module, but is necessary to ensure that some tests + ** designed to produce hash table collisions really do work. */ + i = nTerm - int32(1) + for { + if !(i >= 0) { + break + } + hash = hash<= 0 && c <= int32(9)) { + break + } + v = v*int64(10) + int64(c) + goto _2 + _2: + ; + i = i + 1 + } + /* The longest decimal representation of a 32 bit integer is 10 digits: + ** + ** 1234567890 + ** 2^31 -> 2147483648 + */ + if i > int32(10) { + return 0 + } + if v-int64(neg) > int64(2147483647) { + return 0 + } + if neg != 0 { + v = -v + } + **(**int32)(__ccgo_up(pValue)) = int32(v) + return int32(1) +} + +// C documentation +// +// /* +// ** Render an signed 64-bit integer as text. Store the result in zOut[] and +// ** return the length of the string that was stored, in bytes. The value +// ** returned does not include the zero terminator at the end of the output +// ** string. +// ** +// ** The caller must ensure that zOut[] is at least 21 bytes in size. +// */ +func _sqlite3Int64ToText(tls *libc.TLS, v Ti64, zOut uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, kk, v2 int32 + var x Tu64 + var v1 uint64 + var _ /* u at bp+0 */ struct { + FforceAlignment [0]Tu16 + Fa [21]int8 + F__ccgo_pad2 [1]byte + } + _, _, _, _, _ = i, kk, x, v1, v2 + if v > 0 { + x = libc.Uint64FromInt64(v) + } else { + if v == 0 { + **(**int8)(__ccgo_up(zOut)) = int8('0') + **(**int8)(__ccgo_up(zOut + 1)) = 0 + return int32(1) + } else { + if v == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= uint64(10) { + kk = libc.Int32FromUint64(x % uint64(100) * uint64(2)) + **(**Tu16)(__ccgo_up(bp + uintptr(i-int32(2)))) = **(**Tu16)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3DigitPairs)) + uintptr(kk))) + i = i - int32(2) + x = x / uint64(100) + } + if x != 0 { + i = i - 1 + v2 = i + **(**int8)(__ccgo_up(bp + uintptr(v2))) = libc.Int8FromUint64(x + uint64('0')) + } + if v < 0 { + i = i - 1 + v2 = i + **(**int8)(__ccgo_up(bp + uintptr(v2))) = int8('-') + } + libc.Xmemcpy(tls, zOut, bp+uintptr(i), uint64(21)-libc.Uint64FromInt32(i)) + return libc.Int32FromUint64(libc.Uint64FromInt64(21) - libc.Uint64FromInt32(1) - libc.Uint64FromInt32(i)) +} + +// C documentation +// +// /* +// ** pExpr points to an expression which implements a function. If +// ** it is appropriate to apply the LIKE optimization to that function +// ** then set aWc[0] through aWc[2] to the wildcard characters and the +// ** escape character and then return TRUE. If the function is not a +// ** LIKE-style function then return FALSE. +// ** +// ** The expression "a LIKE b ESCAPE c" is only considered a valid LIKE +// ** operator if c is a string literal that is exactly one byte in length. +// ** That one byte is stored in aWc[3]. aWc[3] is set to zero if there is +// ** no ESCAPE clause. +// ** +// ** *pIsNocase is set to true if uppercase and lowercase are equivalent for +// ** the function (default for LIKE). If the function makes the distinction +// ** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to +// ** false. +// */ +func _sqlite3IsLikeFunction(tls *libc.TLS, db uintptr, pExpr uintptr, pIsNocase uintptr, aWc uintptr) (r int32) { + var nExpr int32 + var pDef, pEscape, zEscape uintptr + _, _, _, _ = nExpr, pDef, pEscape, zEscape + if !(*(*uintptr)(unsafe.Pointer(pExpr + 32)) != 0) { + return 0 + } + nExpr = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + pDef = _sqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8)), nExpr, uint8(SQLITE_UTF8), uint8(0)) + if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_LIKE) == uint32(0) { + return 0 + } + /* The memcpy() statement assumes that the wildcard characters are + ** the first three statements in the compareInfo structure. The + ** asserts() that follow verify that assumption + */ + libc.Xmemcpy(tls, aWc, (*TFuncDef)(unsafe.Pointer(pDef)).FpUserData, uint64(3)) + if nExpr < int32(3) { + **(**int8)(__ccgo_up(aWc + 3)) = 0 + } else { + pEscape = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 2*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pEscape)).Fop) != int32(TK_STRING) { + return 0 + } + zEscape = *(*uintptr)(unsafe.Pointer(pEscape + 8)) + if int32(**(**int8)(__ccgo_up(zEscape))) == 0 || int32(**(**int8)(__ccgo_up(zEscape + 1))) != 0 { + return 0 + } + if int32(**(**int8)(__ccgo_up(zEscape))) == int32(**(**int8)(__ccgo_up(aWc))) { + return 0 + } + if int32(**(**int8)(__ccgo_up(zEscape))) == int32(**(**int8)(__ccgo_up(aWc + 1))) { + return 0 + } + **(**int8)(__ccgo_up(aWc + 3)) = **(**int8)(__ccgo_up(zEscape)) + } + **(**int32)(__ccgo_up(pIsNocase)) = libc.BoolInt32((*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_CASE) == uint32(0)) + return int32(1) +} + +/* Mathematical Constants */ + +// C documentation +// +// /* +// ** Add a new name/number pair to a VList. This might require that the +// ** VList object be reallocated, so return the new VList. If an OOM +// ** error occurs, the original VList returned and the +// ** db->mallocFailed flag is set. +// ** +// ** A VList is really just an array of integers. To destroy a VList, +// ** simply pass it to sqlite3DbFree(). +// ** +// ** The first integer is the number of integers allocated for the whole +// ** VList. The second integer is the number of integers actually used. +// ** Each name/number pair is encoded by subsequent groups of 3 or more +// ** integers. +// ** +// ** Each name/number pair starts with two integers which are the numeric +// ** value for the pair and the size of the name/number pair, respectively. +// ** The text name overlays one or more following integers. The text name +// ** is always zero-terminated. +// ** +// ** Conceptually: +// ** +// ** struct VList { +// ** int nAlloc; // Number of allocated slots +// ** int nUsed; // Number of used slots +// ** struct VListEntry { +// ** int iValue; // Value for this entry +// ** int nSlot; // Slots used by this entry +// ** // ... variable name goes here +// ** } a[0]; +// ** } +// ** +// ** During code generation, pointers to the variable names within the +// ** VList are taken. When that happens, nAlloc is set to zero as an +// ** indication that the VList may never again be enlarged, since the +// ** accompanying realloc() would invalidate the pointers. +// */ +func _sqlite3VListAdd(tls *libc.TLS, db uintptr, pIn uintptr, zName uintptr, nName int32, iVal int32) (r uintptr) { + var i, nInt int32 + var nAlloc Tsqlite3_int64 + var pOut, z uintptr + var v1 int64 + _, _, _, _, _, _ = i, nAlloc, nInt, pOut, z, v1 /* Index in pIn[] where zName is stored */ + nInt = nName/int32(4) + int32(3) + /* Verify ok to add new elements */ + if pIn == uintptr(0) || **(**TVList)(__ccgo_up(pIn + 1*4))+nInt > **(**TVList)(__ccgo_up(pIn)) { + if pIn != 0 { + v1 = int64(2) * int64(**(**TVList)(__ccgo_up(pIn))) + } else { + v1 = int64(10) + } + /* Enlarge the allocation */ + nAlloc = v1 + int64(nInt) + pOut = _sqlite3DbRealloc(tls, db, pIn, libc.Uint64FromInt64(nAlloc)*uint64(4)) + if pOut == uintptr(0) { + return pIn + } + if pIn == uintptr(0) { + **(**TVList)(__ccgo_up(pOut + 1*4)) = int32(2) + } + pIn = pOut + **(**TVList)(__ccgo_up(pIn)) = int32(nAlloc) + } + i = **(**TVList)(__ccgo_up(pIn + 1*4)) + **(**TVList)(__ccgo_up(pIn + uintptr(i)*4)) = iVal + **(**TVList)(__ccgo_up(pIn + uintptr(i+int32(1))*4)) = nInt + z = pIn + uintptr(i+int32(2))*4 + **(**TVList)(__ccgo_up(pIn + 1*4)) = i + nInt + libc.Xmemcpy(tls, z, zName, libc.Uint64FromInt32(nName)) + **(**int8)(__ccgo_up(z + uintptr(nName))) = 0 + return pIn +} + +// C documentation +// +// /* +// ** This routine checks for a byte-order mark at the beginning of the +// ** UTF-16 string stored in *pMem. If one is present, it is removed and +// ** the encoding of the Mem adjusted. This routine does not do any +// ** byte-swapping, it just sets Mem.enc appropriately. +// ** +// ** The allocation (static, dynamic etc.) and encoding of the Mem may be +// ** changed by this function. +// */ +func _sqlite3VdbeMemHandleBom(tls *libc.TLS, pMem uintptr) (r int32) { + var b1, b2, bom Tu8 + var rc int32 + var v1 uintptr + _, _, _, _, _ = b1, b2, bom, rc, v1 + rc = SQLITE_OK + bom = uint8(0) + if (*TMem)(unsafe.Pointer(pMem)).Fn > int32(1) { + b1 = **(**Tu8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz)) + b2 = **(**Tu8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + libc.UintptrFromInt32(1))) + if libc.Int32FromUint8(b1) == int32(0xFE) && libc.Int32FromUint8(b2) == int32(0xFF) { + bom = uint8(SQLITE_UTF16BE) + } + if libc.Int32FromUint8(b1) == int32(0xFF) && libc.Int32FromUint8(b2) == int32(0xFE) { + bom = uint8(SQLITE_UTF16LE) + } + } + if bom != 0 { + rc = _sqlite3VdbeMemMakeWriteable(tls, pMem) + if rc == SQLITE_OK { + **(**int32)(__ccgo_up(pMem + 16)) -= int32(2) + libc.Xmemmove(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, (*TMem)(unsafe.Pointer(pMem)).Fz+2, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn)) + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = int8('\000') + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn+int32(1)))) = int8('\000') + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pMem)).Fenc = bom + } + } + return rc +} + +// C documentation +// +// /* +// ** Change the value of a Mem to be a string or a BLOB. +// ** +// ** The memory management strategy depends on the value of the xDel +// ** parameter. If the value passed is SQLITE_TRANSIENT, then the +// ** string is copied into a (possibly existing) buffer managed by the +// ** Mem structure. Otherwise, any existing buffer is freed and the +// ** pointer copied. +// ** +// ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH +// ** size limit) then no memory allocation occurs. If the string can be +// ** stored without allocating memory, then it is. If a memory allocation +// ** is required to store the string, then value of pMem is unchanged. In +// ** either case, SQLITE_TOOBIG is returned. +// ** +// ** The "enc" parameter is the text encoding for the string, or zero +// ** to store a blob. +// ** +// ** If n is negative, then the string consists of all bytes up to but +// ** excluding the first zero character. The n parameter must be +// ** non-negative for blobs. +// */ +func _sqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n Ti64, enc Tu8, __ccgo_fp_xDel uintptr) (r int32) { + var flags Tu16 + var iLimit, v2 int32 + var nAlloc, nByte Ti64 + var v3 int64 + _, _, _, _, _, _ = flags, iLimit, nAlloc, nByte, v2, v3 + nByte = n /* New value for pMem->flags */ + /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ + if !(z != 0) { + _sqlite3VdbeMemSetNull(tls, pMem) + return SQLITE_OK + } + if (*TMem)(unsafe.Pointer(pMem)).Fdb != 0 { + iLimit = **(**int32)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fdb + 136)) + } else { + iLimit = int32(SQLITE_MAX_LENGTH) + } + if nByte < 0 { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, z)) + } else { + nByte = 0 + for { + if !(nByte <= int64(iLimit) && int32(**(**int8)(__ccgo_up(z + uintptr(nByte))))|int32(**(**int8)(__ccgo_up(z + uintptr(nByte+int64(1))))) != 0) { + break + } + goto _1 + _1: + ; + nByte = nByte + int64(2) + } + } + flags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term)) + } else { + if libc.Int32FromUint8(enc) == 0 { + flags = uint16(MEM_Blob) + enc = uint8(SQLITE_UTF8) + } else { + flags = uint16(MEM_Str) + } + } + if nByte > int64(iLimit) { + if __ccgo_fp_xDel != 0 && __ccgo_fp_xDel != uintptr(-libc.Int32FromInt32(1)) { + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, z) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, z) + } + } + _sqlite3VdbeMemSetNull(tls, pMem) + return _sqlite3ErrorToParser(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, int32(SQLITE_TOOBIG)) + } + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + if __ccgo_fp_xDel == uintptr(-libc.Int32FromInt32(1)) { + nAlloc = nByte + if libc.Int32FromUint16(flags)&int32(MEM_Term) != 0 { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + v2 = int32(1) + } else { + v2 = int32(2) + } + nAlloc = nAlloc + int64(v2) + } + if nAlloc > int64(libc.Int32FromInt32(32)) { + v3 = nAlloc + } else { + v3 = int64(libc.Int32FromInt32(32)) + } + if _sqlite3VdbeMemClearAndResize(tls, pMem, int32(v3)) != 0 { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, z, libc.Uint64FromInt64(nAlloc)) + } else { + _sqlite3VdbeMemRelease(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = z + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = (*TMem)(unsafe.Pointer(pMem)).Fz + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } else { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + if __ccgo_fp_xDel == libc.UintptrFromInt32(0) { + v2 = int32(MEM_Static) + } else { + v2 = int32(MEM_Dyn) + } + flags = libc.Uint16FromInt32(int32(flags) | v2) + } + } + (*TMem)(unsafe.Pointer(pMem)).Fn = int32(nByte & libc.Int64FromInt32(0x7fffffff)) + (*TMem)(unsafe.Pointer(pMem)).Fflags = flags + (*TMem)(unsafe.Pointer(pMem)).Fenc = enc + if libc.Int32FromUint8(enc) > int32(SQLITE_UTF8) && _sqlite3VdbeMemHandleBom(tls, pMem) != 0 { + return int32(SQLITE_NOMEM) + } + return SQLITE_OK +} + +// C documentation +// +// /* Like sqlite3VdbeMemSetStr() except: +// ** +// ** enc is always SQLITE_UTF8 +// ** pMem->db is always non-NULL +// */ +func _sqlite3VdbeMemSetText(tls *libc.TLS, pMem uintptr, z uintptr, n Ti64, __ccgo_fp_xDel uintptr) (r int32) { + var flags Tu16 + var nAlloc, nByte Ti64 + var v1 int64 + _, _, _, _ = flags, nAlloc, nByte, v1 + nByte = n + /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ + if !(z != 0) { + _sqlite3VdbeMemSetNull(tls, pMem) + return SQLITE_OK + } + if nByte < 0 { + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, z)) + flags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term)) + } else { + flags = uint16(MEM_Str) + } + if nByte > int64(**(**int32)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fdb + 136))) { + if __ccgo_fp_xDel != 0 && __ccgo_fp_xDel != uintptr(-libc.Int32FromInt32(1)) { + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, z) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, z) + } + } + _sqlite3VdbeMemSetNull(tls, pMem) + return _sqlite3ErrorToParser(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, int32(SQLITE_TOOBIG)) + } + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + if __ccgo_fp_xDel == uintptr(-libc.Int32FromInt32(1)) { + nAlloc = nByte + int64(1) + if nAlloc > int64(libc.Int32FromInt32(32)) { + v1 = nAlloc + } else { + v1 = int64(libc.Int32FromInt32(32)) + } + if _sqlite3VdbeMemClearAndResize(tls, pMem, int32(v1)) != 0 { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, z, libc.Uint64FromInt64(nByte)) + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr(nByte))) = 0 + } else { + _sqlite3VdbeMemRelease(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = z + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = (*TMem)(unsafe.Pointer(pMem)).Fz + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + (*TMem)(unsafe.Pointer(pMem)).FxDel = uintptr(0) + } else { + if __ccgo_fp_xDel == libc.UintptrFromInt32(0) { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + flags = libc.Uint16FromInt32(int32(flags) | libc.Int32FromInt32(MEM_Static)) + } else { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + flags = libc.Uint16FromInt32(int32(flags) | libc.Int32FromInt32(MEM_Dyn)) + } + } + } + (*TMem)(unsafe.Pointer(pMem)).Fflags = flags + (*TMem)(unsafe.Pointer(pMem)).Fn = int32(nByte & libc.Int64FromInt32(0x7fffffff)) + (*TMem)(unsafe.Pointer(pMem)).Fenc = uint8(SQLITE_UTF8) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** If the SELECT statement passed as the second argument does not invoke +// ** any SQL window functions, this function is a no-op. Otherwise, it +// ** rewrites the SELECT statement so that window function xStep functions +// ** are invoked in the correct order as described under "SELECT REWRITING" +// ** at the top of this file. +// */ +func _sqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pArgs, pFilter, pGroupBy, pHaving, pMWin, pSort, pSrc, pSub, pTab, pTab2, pWhere, pWin, v, v2 uintptr + var nSave, rc, v1 int32 + var selFlags Tu32 + var _ /* pSublist at bp+0 */ uintptr + var _ /* w at bp+8 */ TWalker + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, nSave, pArgs, pFilter, pGroupBy, pHaving, pMWin, pSort, pSrc, pSub, pTab, pTab2, pWhere, pWin, rc, selFlags, v, v1, v2 + rc = SQLITE_OK + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 && (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_WinRewrite) == uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + v = _sqlite3GetVdbe(tls, pParse) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pSub = uintptr(0) /* The subquery */ + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + pWhere = (*TSelect)(unsafe.Pointer(p)).FpWhere + pGroupBy = (*TSelect)(unsafe.Pointer(p)).FpGroupBy + pHaving = (*TSelect)(unsafe.Pointer(p)).FpHaving + pSort = uintptr(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Expression list for sub-query */ + pMWin = (*TSelect)(unsafe.Pointer(p)).FpWin + selFlags = (*TSelect)(unsafe.Pointer(p)).FselFlags + pTab = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTab == uintptr(0) { + return _sqlite3ErrorToParser(tls, db, int32(SQLITE_NOMEM)) + } + _sqlite3AggInfoPersistWalkerInit(tls, bp+8, pParse) + _sqlite3WalkSelect(tls, bp+8, p) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Aggregate) == uint32(0) { + (**(**TWalker)(__ccgo_up(bp + 8))).FxExprCallback = __ccgo_fp(_disallowAggregatesInOrderByCb) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback = uintptr(0) + _sqlite3WalkExprList(tls, bp+8, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + } + (*TSelect)(unsafe.Pointer(p)).FpSrc = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpWhere = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpGroupBy = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpHaving = uintptr(0) + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Aggregate) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_WinRewrite) + /* Create the ORDER BY clause for the sub-select. This is the concatenation + ** of the window PARTITION and ORDER BY clauses. Then, if this makes it + ** redundant, remove the ORDER BY from the parent SELECT. */ + pSort = _exprListAppendList(tls, pParse, uintptr(0), (*TWindow)(unsafe.Pointer(pMWin)).FpPartition, int32(1)) + pSort = _exprListAppendList(tls, pParse, pSort, (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy, int32(1)) + if pSort != 0 && (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 && (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr <= (*TExprList)(unsafe.Pointer(pSort)).FnExpr { + nSave = (*TExprList)(unsafe.Pointer(pSort)).FnExpr + (*TExprList)(unsafe.Pointer(pSort)).FnExpr = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr + if _sqlite3ExprListCompare(tls, pSort, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, -int32(1)) == 0 { + _sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + } + (*TExprList)(unsafe.Pointer(pSort)).FnExpr = nSave + } + /* Assign a cursor number for the ephemeral table used to buffer rows. + ** The OpenEphemeral instruction is coded later, after it is known how + ** many columns the table will have. */ + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr = v1 + **(**int32)(__ccgo_up(pParse + 56)) += int32(3) + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, (*TSelect)(unsafe.Pointer(p)).FpEList, pTab, bp) + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, pTab, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol = v1 + /* Append the PARTITION BY and ORDER BY expressions to the to the + ** sub-select expression list. They are required to figure out where + ** boundaries for partitions and sets of peer rows lie. */ + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), (*TWindow)(unsafe.Pointer(pMWin)).FpPartition, 0) + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy, 0) + /* Append the arguments passed to each window function to the + ** sub-select expression list. Also allocate two registers for each + ** window function - one for the accumulator, another for interim + ** results. */ + pWin = pMWin + for { + if !(pWin != 0) { + break + } + pArgs = *(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)) + if (*TFuncDef)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpWFunc)).FfuncFlags&uint32(SQLITE_SUBTYPE) != 0 { + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, pArgs, pTab, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pWin)).FiArgCol = v1 + (*TWindow)(unsafe.Pointer(pWin)).FbExprArgs = uint8(1) + } else { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pWin)).FiArgCol = v1 + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pArgs, 0) + } + if (*TWindow)(unsafe.Pointer(pWin)).FpFilter != 0 { + pFilter = _sqlite3ExprDup(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FpFilter, 0) + **(**uintptr)(__ccgo_up(bp)) = _sqlite3ExprListAppend(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pFilter) + } + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pWin)).FregAccum = v1 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pWin)).FregResult = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregAccum) + goto _4 + _4: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + /* If there is no ORDER BY or PARTITION BY clause, and the window + ** function accepts zero arguments, and there are no other columns + ** selected (e.g. "SELECT row_number() OVER () FROM t1"), it is possible + ** that pSublist is still NULL here. Add a constant expression here to + ** keep everything legal in this case. + */ + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3ExprInt32(tls, db, 0)) + } + pSub = _sqlite3SelectNew(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pSrc, pWhere, pGroupBy, pHaving, pSort, uint32(0), uintptr(0)) + (*TSelect)(unsafe.Pointer(p)).FpSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + /* Due to db->mallocFailed test inside + ** of sqlite3DbMallocRawNN() called from + ** sqlite3SrcListAppend() */ + if (*TSelect)(unsafe.Pointer(p)).FpSrc == uintptr(0) { + _sqlite3SelectDelete(tls, db, pSub) + } else { + if _sqlite3SrcItemAttachSubquery(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpSrc+8, pSub, 0) != 0 { + libc.SetBitFieldPtr32Uint32((*TSelect)(unsafe.Pointer(p)).FpSrc+8+24+4, libc.Uint32FromInt32(1), 4, 0x10) + _sqlite3SrcListAssignCursors(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpSrc) + **(**Tu32)(__ccgo_up(pSub + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(SF_Expanded) | libc.Int32FromInt32(SF_OrderByReqd)) + pTab2 = _sqlite3ResultSetOfSelect(tls, pParse, pSub, int8(SQLITE_AFF_NONE)) + **(**Tu32)(__ccgo_up(pSub + 4)) |= selFlags & uint32(SF_Aggregate) + if pTab2 == uintptr(0) { + /* Might actually be some other kind of error, but in that case + ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get + ** the correct error message regardless. */ + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, pTab, pTab2, uint64(120)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_Ephemeral) + (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab = pTab + pTab = pTab2 + libc.Xmemset(tls, bp+8, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp + 8))).FxExprCallback = __ccgo_fp(_sqlite3WindowExtraAggFuncDepth) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback = __ccgo_fp(_sqlite3WalkerDepthIncrease) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback2 = __ccgo_fp(_sqlite3WalkerDepthDecrease) + _sqlite3WalkSelect(tls, bp+8, pSub) + } + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } + /* Defer deleting the temporary table pTab because if an error occurred, + ** there could still be references to that table embedded in the + ** result-set or ORDER BY clause of the SELECT statement p. */ + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3DbFree), pTab) + } + return rc +} + +// C documentation +// +// /* Construct a new Expr object from a single token */ +func _tokenExpr(tls *libc.TLS, pParse uintptr, op int32, _t TToken) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*TToken)(unsafe.Pointer(bp)) = _t + var p, v1 uintptr + _, _ = p, v1 + p = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(72)+uint64((**(**TToken)(__ccgo_up(bp))).Fn)+uint64(1)) + if p != 0 { + /* memset(p, 0, sizeof(Expr)); */ + (*TExpr)(unsafe.Pointer(p)).Fop = libc.Uint8FromInt32(op) + (*TExpr)(unsafe.Pointer(p)).FaffExpr = 0 + (*TExpr)(unsafe.Pointer(p)).Fflags = uint32(EP_Leaf) + /* p->iAgg = -1; // Not required */ + v1 = libc.UintptrFromInt32(0) + (*TExpr)(unsafe.Pointer(p)).FpRight = v1 + (*TExpr)(unsafe.Pointer(p)).FpLeft = v1 + (*TExpr)(unsafe.Pointer(p)).FpAggInfo = uintptr(0) + libc.Xmemset(tls, p+32, 0, uint64(8)) + libc.Xmemset(tls, p+64, 0, uint64(8)) + (*TExpr)(unsafe.Pointer(p)).Fop2 = uint8(0) + (*TExpr)(unsafe.Pointer(p)).FiTable = 0 + (*TExpr)(unsafe.Pointer(p)).FiColumn = 0 + *(*uintptr)(unsafe.Pointer(p + 8)) = p + 1*72 + libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(p + 8)), (**(**TToken)(__ccgo_up(bp))).Fz, uint64((**(**TToken)(__ccgo_up(bp))).Fn)) + **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(p + 8)) + uintptr((**(**TToken)(__ccgo_up(bp))).Fn))) = 0 + *(*int32)(unsafe.Pointer(p + 52)) = int32(int64((**(**TToken)(__ccgo_up(bp))).Fz) - int64((*TParse)(unsafe.Pointer(pParse)).FzTail)) + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(p + 8)))))])&int32(0x80) != 0 { + _sqlite3DequoteExpr(tls, p) + } + (*TExpr)(unsafe.Pointer(p)).FnHeight = int32(1) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return _sqlite3RenameTokenMap(tls, pParse, p, bp) + } + } + return p +} + +// C documentation +// +// /* +// ** Set up a raw page so that it looks like a database page holding +// ** no entries. +// */ +func _zeroPage(tls *libc.TLS, pPage uintptr, flags int32) { + var data, pBt uintptr + var first, hdr, v1 int32 + _, _, _, _, _ = data, first, hdr, pBt, v1 + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_FAST_SECURE) != 0 { + libc.Xmemset(tls, data+uintptr(hdr), 0, uint64((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(hdr))) + } + **(**uint8)(__ccgo_up(data + uintptr(hdr))) = libc.Uint8FromInt8(int8(flags)) + if flags&int32(PTF_LEAF) == 0 { + v1 = int32(12) + } else { + v1 = int32(8) + } + first = hdr + v1 + libc.Xmemset(tls, data+uintptr(hdr+int32(1)), 0, uint64(4)) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7)))) = uint8(0) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)))) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FusableSize >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)) + 1)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FusableSize) + (*TMemPage)(unsafe.Pointer(pPage)).FnFree = libc.Int32FromUint16(uint16((*TBtShared)(unsafe.Pointer(pBt)).FusableSize - libc.Uint32FromInt32(first))) + _decodeFlags(tls, pPage, flags) + (*TMemPage)(unsafe.Pointer(pPage)).FcellOffset = libc.Uint16FromInt32(first) + (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd = data + uintptr((*TBtShared)(unsafe.Pointer(pBt)).FpageSize) + (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx = data + uintptr(first) + (*TMemPage)(unsafe.Pointer(pPage)).FaDataOfst = data + uintptr((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FmaskPage = uint16((*TBtShared)(unsafe.Pointer(pBt)).FpageSize - libc.Uint32FromInt32(1)) + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = uint16(0) + (*TMemPage)(unsafe.Pointer(pPage)).FisInit = uint8(1) +} diff --git a/internal/engine/lib/sqlite_g_000000000000c48b.go b/internal/engine/lib/sqlite_g_000000000000c48b.go new file mode 100644 index 0000000..7db98dd --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000c48b.go @@ -0,0 +1,4278 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (linux && amd64) || (linux && loong64) || (netbsd && amd64) || (openbsd && amd64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** This function is called from within a pre-update callback to retrieve +// ** a field of the row currently being updated or deleted. +// */ +func Xsqlite3_preupdate_old(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aRec, p, pCol, pDflt, pMem, v1 uintptr + var iStore, nByte, rc int32 + var nRec Tu32 + var _ /* pVal at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aRec, iStore, nByte, nRec, p, pCol, pDflt, pMem, rc, v1 + rc = SQLITE_OK + iStore = 0 + p = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate + /* Test that this call is being made from within an SQLITE_DELETE or + ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */ + if !(p != 0) || (*TPreUpdate)(unsafe.Pointer(p)).Fop == int32(SQLITE_INSERT) { + rc = _sqlite3MisuseError(tls, int32(95782)) + goto preupdate_old_out + } + if (*TPreUpdate)(unsafe.Pointer(p)).FpPk != 0 { + iStore = _sqlite3TableColumnToIndex(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpPk, iIdx) + } else { + if iIdx >= int32((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FnCol) { + rc = _sqlite3MisuseError(tls, int32(95788)) + goto preupdate_old_out + } else { + iStore = int32(_sqlite3TableColumnToStorage(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpTab, int16(iIdx))) + } + } + if iStore >= int32((*TVdbeCursor)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField) || iStore < 0 { + rc = int32(SQLITE_RANGE) + goto preupdate_old_out + } + if iIdx == int32((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FiPKey) { + v1 = p + 80 + pMem = v1 + **(**uintptr)(__ccgo_up(ppValue)) = v1 + _sqlite3VdbeMemSetInt64(tls, pMem, (*TPreUpdate)(unsafe.Pointer(p)).FiKey1) + } else { + /* If the old.* record has not yet been loaded into memory, do so now. */ + if (*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked == uintptr(0) { + nRec = _sqlite3BtreePayloadSize(tls, *(*uintptr)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpCsr + 48))) + aRec = _sqlite3DbMallocRaw(tls, db, uint64(nRec)) + if !(aRec != 0) { + goto preupdate_old_out + } + rc = _sqlite3BtreePayload(tls, *(*uintptr)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpCsr + 48)), uint32(0), nRec, aRec) + if rc == SQLITE_OK { + (*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked = _vdbeUnpackRecord(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpKeyinfo, libc.Int32FromUint32(nRec), aRec) + if !((*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked != 0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc != SQLITE_OK { + _sqlite3DbFree(tls, db, aRec) + goto preupdate_old_out + } + (*TPreUpdate)(unsafe.Pointer(p)).FaRecord = aRec + } + v1 = (*TUnpackedRecord)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked)).FaMem + uintptr(iStore)*56 + **(**uintptr)(__ccgo_up(ppValue)) = v1 + pMem = v1 + if iStore >= libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked)).FnField) { + /* This occurs when the table has been extended using ALTER TABLE + ** ADD COLUMN. The value to return is the default value of the column. */ + pCol = (*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol + uintptr(iIdx)*16 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) > 0 { + if (*TPreUpdate)(unsafe.Pointer(p)).FapDflt == uintptr(0) { + nByte = libc.Int32FromUint64(uint64(8) * libc.Uint64FromInt16((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FnCol)) + (*TPreUpdate)(unsafe.Pointer(p)).FapDflt = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt32(nByte)) + if (*TPreUpdate)(unsafe.Pointer(p)).FapDflt == uintptr(0) { + goto preupdate_old_out + } + } + if **(**uintptr)(__ccgo_up((*TPreUpdate)(unsafe.Pointer(p)).FapDflt + uintptr(iIdx)*8)) == uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pDflt = (*(*TExprList_item)(unsafe.Pointer((*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab + 64))).FpDfltList + 8 + uintptr(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt)-int32(1))*32))).FpExpr + rc = _sqlite3ValueFromExpr(tls, db, pDflt, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, libc.Uint8FromInt8((*TColumn)(unsafe.Pointer(pCol)).Faffinity), bp) + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + rc = _sqlite3CorruptError(tls, int32(95844)) + } + **(**uintptr)(__ccgo_up((*TPreUpdate)(unsafe.Pointer(p)).FapDflt + uintptr(iIdx)*8)) = **(**uintptr)(__ccgo_up(bp)) + } + **(**uintptr)(__ccgo_up(ppValue)) = **(**uintptr)(__ccgo_up((*TPreUpdate)(unsafe.Pointer(p)).FapDflt + uintptr(iIdx)*8)) + } else { + **(**uintptr)(__ccgo_up(ppValue)) = _columnNullValue(tls) + } + } else { + if int32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol + uintptr(iIdx)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemRealify(tls, pMem) + } + } + } + } + goto preupdate_old_out +preupdate_old_out: + ; + _sqlite3Error(tls, db, rc) + return _sqlite3ApiExit(tls, db, rc) +} + +// C documentation +// +// /* +// ** Append N copies of character c to the given string buffer. +// */ +func Xsqlite3_str_appendchar(tls *libc.TLS, p uintptr, N int32, c int8) { + var v1 int32 + var v2 bool + var v4 Tu32 + var v5 uintptr + _, _, _, _ = v1, v2, v4, v5 + if v2 = libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(p)).FnChar)+int64(N) >= libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(p)).FnAlloc); v2 { + v1 = _sqlite3StrAccumEnlarge(tls, p, int64(N)) + N = v1 + } + if v2 && v1 <= 0 { + return + } + for { + v1 = N + N = N - 1 + if !(v1 > 0) { + break + } + v5 = p + 24 + v4 = *(*Tu32)(unsafe.Pointer(v5)) + *(*Tu32)(unsafe.Pointer(v5)) = *(*Tu32)(unsafe.Pointer(v5)) + 1 + **(**int8)(__ccgo_up((*Tsqlite3_str)(unsafe.Pointer(p)).FzText + uintptr(v4))) = c + } +} + +// C documentation +// +// /* +// ** Processing is determine by the affinity parameter: +// ** +// ** SQLITE_AFF_INTEGER: +// ** SQLITE_AFF_REAL: +// ** SQLITE_AFF_NUMERIC: +// ** Try to convert pRec to an integer representation or a +// ** floating-point representation if an integer representation +// ** is not possible. Note that the integer representation is +// ** always preferred, even if the affinity is REAL, because +// ** an integer representation is more space efficient on disk. +// ** +// ** SQLITE_AFF_FLEXNUM: +// ** If the value is text, then try to convert it into a number of +// ** some kind (integer or real) but do not make any other changes. +// ** +// ** SQLITE_AFF_TEXT: +// ** Convert pRec to a text representation. +// ** +// ** SQLITE_AFF_BLOB: +// ** SQLITE_AFF_NONE: +// ** No-op. pRec is unchanged. +// */ +func _applyAffinity(tls *libc.TLS, pRec uintptr, affinity int8, enc Tu8) { + var v1 uintptr + _ = v1 + if int32(affinity) >= int32(SQLITE_AFF_NUMERIC) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Int) == 0 { /*OPTIMIZATION-IF-FALSE*/ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Str) != 0 { + _applyNumericAffinity(tls, pRec, int32(1)) + } + } else { + if int32(affinity) <= int32(SQLITE_AFF_REAL) { + _sqlite3VdbeIntegerAffinity(tls, pRec) + } + } + } + } else { + if int32(affinity) == int32(SQLITE_AFF_TEXT) { + /* Only attempt the conversion to TEXT if there is an integer or real + ** representation (blob and NULL do not get converted) but no string + ** representation. It would be harmless to repeat the conversion if + ** there is already a string rep, but it is pointless to waste those + ** CPU cycles. */ + if 0 == libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Str) { /*OPTIMIZATION-IF-FALSE*/ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemStringify(tls, pRec, enc, uint8(1)) + } + } + v1 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_IntReal))) + } + } +} + +// C documentation +// +// /* +// ** Generate code that will evaluate all == and IN constraints for an +// ** index scan. +// ** +// ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c). +// ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10 +// ** The index has as many as three equality constraints, but in this +// ** example, the third "c" value is an inequality. So only two +// ** constraints are coded. This routine will generate code to evaluate +// ** a==5 and b IN (1,2,3). The current values for a and b will be stored +// ** in consecutive registers and the index of the first register is returned. +// ** +// ** In the example above nEq==2. But this subroutine works for any value +// ** of nEq including 0. If nEq==0, this routine is nearly a no-op. +// ** The only thing it does is allocate the pLevel->iMem memory cell and +// ** compute the affinity string. +// ** +// ** The nExtraReg parameter is 0 or 1. It is 0 if all WHERE clause constraints +// ** are == or IN and are covered by the nEq. nExtraReg is 1 if there is +// ** an inequality constraint (such as the "c>=5 AND c<10" in the example) that +// ** occurs after the nEq quality constraints. +// ** +// ** This routine allocates a range of nEq+nExtraReg memory cells and returns +// ** the index of the first memory cell in that range. The code that +// ** calls this routine will use that memory range to store keys for +// ** start and termination conditions of the loop. +// ** key value of the loop. If one or more IN operators appear, then +// ** this routine allocates an additional nEq memory cells for internal +// ** use. +// ** +// ** Before returning, *pzAff is set to point to a buffer containing a +// ** copy of the column affinity string of the index allocated using +// ** sqlite3DbMalloc(). Except, entries in the copy of the string associated +// ** with equality constraints that use BLOB or NONE affinity are set to +// ** SQLITE_AFF_BLOB. This is to deal with SQL such as the following: +// ** +// ** CREATE TABLE t1(a TEXT PRIMARY KEY, b); +// ** SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b; +// ** +// ** In the example above, the index on t1(a) has TEXT affinity. But since +// ** the right hand side of the equality constraint (t2.b) has BLOB/NONE affinity, +// ** no conversion should be attempted before using a t2.b value as part of +// ** a key to search the index. Hence the first byte in the returned affinity +// ** string in this example would be set to SQLITE_AFF_BLOB. +// */ +func _codeAllEqualityTerms(tls *libc.TLS, pParse uintptr, pLevel uintptr, bRev int32, nExtraReg int32, pzAff uintptr) (r int32) { + var iIdxCur, j, nReg, r1, regBase, v1 int32 + var nEq, nSkip Tu16 + var pIdx, pLoop, pRight, pTerm, v, zAff uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iIdxCur, j, nEq, nReg, nSkip, pIdx, pLoop, pRight, pTerm, r1, regBase, v, zAff, v1 /* Number of left-most columns to skip */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Affinity string to return */ + /* This module is only called on query plans that use an index. */ + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + nEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq + nSkip = (*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip + pIdx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + /* Figure out how many memory cells we will need then allocate them. + */ + regBase = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + nReg = libc.Int32FromUint16(nEq) + nExtraReg + **(**int32)(__ccgo_up(pParse + 60)) += nReg + zAff = _sqlite3DbStrDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, _sqlite3IndexAffinityStr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pIdx)) + if nSkip != 0 { + iIdxCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, regBase, regBase+libc.Int32FromUint16(nSkip)-int32(1)) + if bRev != 0 { + v1 = int32(OP_Last) + } else { + v1 = int32(OP_Rewind) + } + _sqlite3VdbeAddOp1(tls, v, v1, iIdxCur) + j = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + if bRev != 0 { + v1 = int32(OP_SeekLT) + } else { + v1 = int32(OP_SeekGT) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip = _sqlite3VdbeAddOp4Int(tls, v, v1, iIdxCur, 0, regBase, libc.Int32FromUint16(nSkip)) + _sqlite3VdbeJumpHere(tls, v, j) + j = 0 + for { + if !(j < libc.Int32FromUint16(nSkip)) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, j, regBase+j) + goto _3 + _3: + ; + j = j + 1 + } + } + /* Evaluate the equality constraints + */ + j = libc.Int32FromUint16(nSkip) + for { + if !(j < libc.Int32FromUint16(nEq)) { + break + } + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) + /* The following testcase is true for indices with redundant columns. + ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ + r1 = _codeEqualityTerm(tls, pParse, pTerm, pLevel, j, bRev, regBase+j) + if r1 != regBase+j { + if nReg == int32(1) { + _sqlite3ReleaseTempReg(tls, pParse, regBase) + regBase = r1 + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), r1, regBase+j) + } + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_IN) != 0 { + if (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&uint32(EP_xIsSelect) != 0 { + /* No affinity ever needs to be (or should be) applied to a value + ** from the RHS of an "? IN (SELECT ...)" expression. The + ** sqlite3FindInIndex() routine has already ensured that the + ** affinity of the comparison has been applied to the value. */ + if zAff != 0 { + **(**int8)(__ccgo_up(zAff + uintptr(j))) = int8(SQLITE_AFF_BLOB) + } + } + } else { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_ISNULL) == 0 { + pRight = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_IS) == 0 && _sqlite3ExprCanBeNull(tls, pRight) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regBase+j, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + if int32(_sqlite3CompareAffinity(tls, pRight, **(**int8)(__ccgo_up(zAff + uintptr(j))))) == int32(SQLITE_AFF_BLOB) { + **(**int8)(__ccgo_up(zAff + uintptr(j))) = int8(SQLITE_AFF_BLOB) + } + if _sqlite3ExprNeedsNoAffinityChange(tls, pRight, **(**int8)(__ccgo_up(zAff + uintptr(j)))) != 0 { + **(**int8)(__ccgo_up(zAff + uintptr(j))) = int8(SQLITE_AFF_BLOB) + } + } + } + } + goto _4 + _4: + ; + j = j + 1 + } + **(**uintptr)(__ccgo_up(pzAff)) = zAff + return regBase +} + +// C documentation +// +// /* +// ** Return a pointer to the column affinity string associated with index +// ** pIdx. A column affinity string has one character for each column in +// ** the table, according to the affinity of the column: +// ** +// ** Character Column affinity +// ** ------------------------------ +// ** 'A' BLOB +// ** 'B' TEXT +// ** 'C' NUMERIC +// ** 'D' INTEGER +// ** 'F' REAL +// ** +// ** An extra 'D' is appended to the end of the string to cover the +// ** rowid that appears as the last column in every index. +// ** +// ** Memory for the buffer containing the column index affinity string +// ** is managed along with the rest of the Index structure. It will be +// ** released when sqlite3DeleteIndex() is called. +// */ +func _computeIndexAffStr(tls *libc.TLS, db uintptr, pIdx uintptr) (r uintptr) { + var aff int8 + var n int32 + var pTab uintptr + var x Ti16 + _, _, _, _ = aff, n, pTab, x + pTab = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + (*TIndex)(unsafe.Pointer(pIdx)).FzColAff = _sqlite3DbMallocRaw(tls, uintptr(0), libc.Uint64FromInt32(libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)+int32(1))) + if !((*TIndex)(unsafe.Pointer(pIdx)).FzColAff != 0) { + _sqlite3OomFault(tls, db) + return uintptr(0) + } + n = 0 + for { + if !(n < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) { + break + } + x = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) + if int32(x) >= 0 { + aff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(x)*16))).Faffinity + } else { + if int32(x) == -int32(1) { + aff = int8(SQLITE_AFF_INTEGER) + } else { + aff = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(n)*32))).FpExpr) + } + } + if int32(aff) < int32(SQLITE_AFF_BLOB) { + aff = int8(SQLITE_AFF_BLOB) + } + if int32(aff) > int32(SQLITE_AFF_NUMERIC) { + aff = int8(SQLITE_AFF_NUMERIC) + } + **(**int8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FzColAff + uintptr(n))) = aff + goto _1 + _1: + ; + n = n + 1 + } + **(**int8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FzColAff + uintptr(n))) = 0 + return (*TIndex)(unsafe.Pointer(pIdx)).FzColAff +} + +// C documentation +// +// /* +// ** Add a new entry to the pConst object. Except, do not add duplicate +// ** pColumn entries. Also, do not add if doing so would not be appropriate. +// ** +// ** The caller guarantees the pColumn is a column and pValue is a constant. +// ** This routine has to do some additional checks before completing the +// ** insert. +// */ +func _constInsert(tls *libc.TLS, pConst uintptr, pColumn uintptr, pValue uintptr, pExpr uintptr) { + var i int32 + var pE2 uintptr + _, _ = i, pE2 + if (*TExpr)(unsafe.Pointer(pColumn)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != uint32(0) { + return + } + if int32(_sqlite3ExprAffinity(tls, pValue)) != 0 { + return + } + if !(_sqlite3IsBinary(tls, _sqlite3ExprCompareCollSeq(tls, (*TWhereConst)(unsafe.Pointer(pConst)).FpParse, pExpr)) != 0) { + return + } + /* 2018-10-25 ticket [cf5ed20f] + ** Make sure the same pColumn is not inserted more than once */ + i = 0 + for { + if !(i < (*TWhereConst)(unsafe.Pointer(pConst)).FnConst) { + break + } + pE2 = **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*int32(2))*8)) + if (*TExpr)(unsafe.Pointer(pE2)).FiTable == (*TExpr)(unsafe.Pointer(pColumn)).FiTable && int32((*TExpr)(unsafe.Pointer(pE2)).FiColumn) == int32((*TExpr)(unsafe.Pointer(pColumn)).FiColumn) { + return /* Already present. Return without doing anything. */ + } + goto _1 + _1: + ; + i = i + 1 + } + if int32(_sqlite3ExprAffinity(tls, pColumn)) <= int32(SQLITE_AFF_BLOB) { + (*TWhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob = int32(1) + } + (*TWhereConst)(unsafe.Pointer(pConst)).FnConst = (*TWhereConst)(unsafe.Pointer(pConst)).FnConst + 1 + (*TWhereConst)(unsafe.Pointer(pConst)).FapExpr = _sqlite3DbReallocOrFree(tls, (*TParse)(unsafe.Pointer((*TWhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb, (*TWhereConst)(unsafe.Pointer(pConst)).FapExpr, uint64(libc.Uint64FromInt32((*TWhereConst)(unsafe.Pointer(pConst)).FnConst*int32(2))*uint64(8))) + if (*TWhereConst)(unsafe.Pointer(pConst)).FapExpr == uintptr(0) { + (*TWhereConst)(unsafe.Pointer(pConst)).FnConst = 0 + } else { + **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr((*TWhereConst)(unsafe.Pointer(pConst)).FnConst*int32(2)-int32(2))*8)) = pColumn + **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr((*TWhereConst)(unsafe.Pointer(pConst)).FnConst*int32(2)-int32(1))*8)) = pValue + } +} + +// C documentation +// +// /* +// ** Argument pExpr is an (?, ?...) IN(...) expression. This +// ** function allocates and returns a nul-terminated string containing +// ** the affinities to be used for each column of the comparison. +// ** +// ** It is the responsibility of the caller to ensure that the returned +// ** string is eventually freed using sqlite3DbFree(). +// */ +func _exprINAffinity(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r uintptr) { + var a int8 + var i, nVal int32 + var pA, pLeft, pSelect, zRet, v1 uintptr + _, _, _, _, _, _, _, _ = a, i, nVal, pA, pLeft, pSelect, zRet, v1 + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + nVal = _sqlite3ExprVectorSize(tls, pLeft) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + v1 = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + } else { + v1 = uintptr(0) + } + pSelect = v1 + zRet = _sqlite3DbMallocRaw(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, libc.Uint64FromInt64(int64(1)+int64(nVal))) + if zRet != 0 { + i = 0 + for { + if !(i < nVal) { + break + } + pA = _sqlite3VectorFieldSubexpr(tls, pLeft, i) + a = _sqlite3ExprAffinity(tls, pA) + if pSelect != 0 { + **(**int8)(__ccgo_up(zRet + uintptr(i))) = _sqlite3CompareAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList + 8 + uintptr(i)*32))).FpExpr, a) + } else { + **(**int8)(__ccgo_up(zRet + uintptr(i))) = a + } + goto _2 + _2: + ; + i = i + 1 + } + **(**int8)(__ccgo_up(zRet + uintptr(nVal))) = int8('\000') + } + return zRet +} + +// C documentation +// +// /* +// ** Interpret the given string as a safety level. Return 0 for OFF, +// ** 1 for ON or NORMAL, 2 for FULL, and 3 for EXTRA. Return 1 for an empty or +// ** unrecognized string argument. The FULL and EXTRA option is disallowed +// ** if the omitFull parameter it 1. +// ** +// ** Note that the values returned are one less that the values that +// ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done +// ** to support legacy SQL code. The safety level used to be boolean +// ** and older scripts may have used numbers 0 for OFF and 1 for ON. +// */ +func _getSafetyLevel(tls *libc.TLS, z uintptr, omitFull int32, dflt Tu8) (r Tu8) { + var i, n int32 + _, _ = i, n + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z)))])&int32(0x04) != 0 { + return libc.Uint8FromInt32(_sqlite3Atoi(tls, z)) + } + n = _sqlite3Strlen30(tls, z) + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1))) { + break + } + if libc.Int32FromUint8(_iLength[i]) == n && Xsqlite3_strnicmp(tls, uintptr(unsafe.Pointer(&_zText))+uintptr(_iOffset[i]), z, n) == 0 && (!(omitFull != 0) || libc.Int32FromUint8(_iValue[i]) <= int32(1)) { + return _iValue[i] + } + goto _1 + _1: + ; + i = i + 1 + } + return dflt +} + +func _groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var db, pGCC, pnsl, zSep, zVal uintptr + var firstTerm, i, nA, nSep, nVal, v1 int32 + _, _, _, _, _, _, _, _, _, _, _ = db, firstTerm, i, nA, nSep, nVal, pGCC, pnsl, zSep, zVal, v1 + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + return + } + pGCC = Xsqlite3_aggregate_context(tls, context, int32(48)) + if pGCC != 0 { + db = Xsqlite3_context_db_handle(tls, context) + firstTerm = libc.BoolInt32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc == uint32(0)) + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc = libc.Uint32FromInt32(**(**int32)(__ccgo_up(db + 136))) + if argc == int32(1) { + if !(firstTerm != 0) { + Xsqlite3_str_appendchar(tls, pGCC, int32(1), int8(',')) + } else { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength = int32(1) + } + } else { + if !(firstTerm != 0) { + zSep = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + nSep = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zSep != 0 { + Xsqlite3_str_append(tls, pGCC, zSep, nSep) + } else { + nSep = 0 + } + if nSep != (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength || (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths != uintptr(0) { + pnsl = (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths + if pnsl == uintptr(0) { + /* First separator length variation seen, start tracking them. */ + pnsl = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum+libc.Int32FromInt32(1))*uint64(4))) + if pnsl != uintptr(0) { + i = 0 + nA = (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum - int32(1) + for i < nA { + v1 = i + i = i + 1 + **(**int32)(__ccgo_up(pnsl + uintptr(v1)*4)) = (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength + } + } + } else { + pnsl = Xsqlite3_realloc64(tls, pnsl, uint64(libc.Uint64FromInt32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum)*uint64(4))) + } + if pnsl != uintptr(0) { + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum > 0 { + **(**int32)(__ccgo_up(pnsl + uintptr((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum-int32(1))*4)) = nSep + } + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths = pnsl + } else { + _sqlite3StrAccumSetError(tls, pGCC, uint8(SQLITE_NOMEM)) + } + } + } else { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } + } + **(**int32)(__ccgo_up(pGCC + 32)) += int32(1) + zVal = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + nVal = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if zVal != 0 { + Xsqlite3_str_append(tls, pGCC, zVal, nVal) + } + } +} + +// C documentation +// +// /* +// ** The hex() function. Interpret the argument as a blob. Return +// ** a hexadecimal rendering as text. +// */ +func _hexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var c uint8 + var i, n int32 + var pBlob, z, zHex, v1 uintptr + _, _, _, _, _, _, _ = c, i, n, pBlob, z, zHex, v1 + _ = argc + pBlob = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + /* No encoding change */ + v1 = _contextMalloc(tls, context, int64(n)*int64(2)+int64(1)) + zHex = v1 + z = v1 + if zHex != 0 { + i = 0 + for { + if !(i < n) { + break + } + c = **(**uint8)(__ccgo_up(pBlob)) + v1 = z + z = z + 1 + **(**int8)(__ccgo_up(v1)) = _hexdigits[libc.Int32FromUint8(c)>>int32(4)&int32(0xf)] + v1 = z + z = z + 1 + **(**int8)(__ccgo_up(v1)) = _hexdigits[libc.Int32FromUint8(c)&int32(0xf)] + goto _2 + _2: + ; + i = i + 1 + pBlob = pBlob + 1 + } + **(**int8)(__ccgo_up(z)) = 0 + Xsqlite3_result_text64(tls, context, zHex, libc.Uint64FromInt64(int64(z)-int64(zHex)), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) + } +} + +// C documentation +// +// /* +// ** Term pTerm is guaranteed to be a WO_IN term. It may be a component term +// ** of a vector IN expression of the form "(x, y, ...) IN (SELECT ...)". +// ** This function checks to see if the term is compatible with an index +// ** column with affinity idxaff (one of the SQLITE_AFF_XYZ values). If so, +// ** it returns a pointer to the name of the collation sequence (e.g. "BINARY" +// ** or "NOCASE") used by the comparison in pTerm. If it is not compatible +// ** with affinity idxaff, NULL is returned. +// */ +func _indexInAffinityOk(tls *libc.TLS, pParse uintptr, pTerm uintptr, idxaff Tu8) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iField int32 + var pRet, pX, v1 uintptr + var _ /* inexpr at bp+0 */ TExpr + _, _, _, _ = iField, pRet, pX, v1 + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft) != 0 { + iField = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField - int32(1) + (**(**TExpr)(__ccgo_up(bp))).Fflags = uint32(0) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_EQ) + (**(**TExpr)(__ccgo_up(bp))).FpLeft = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pX)).FpLeft + 32)) + 8 + uintptr(iField)*32))).FpExpr + (**(**TExpr)(__ccgo_up(bp))).FpRight = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32)))).FpEList + 8 + uintptr(iField)*32))).FpExpr + pX = bp + } + if _sqlite3IndexAffinityOk(tls, pX, libc.Int8FromUint8(idxaff)) != 0 { + pRet = _sqlite3ExprCompareCollSeq(tls, pParse, pX) + if pRet != 0 { + v1 = (*TCollSeq)(unsafe.Pointer(pRet)).FzName + } else { + v1 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + return v1 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Check to see if the given expression is a LIKE or GLOB operator that +// ** can be optimized using inequality constraints. Return TRUE if it is +// ** so and false if not. +// ** +// ** In order for the operator to be optimizible, the RHS must be a string +// ** literal that does not begin with a wildcard. The LHS must be a column +// ** that may only be NULL, a string, or a BLOB, never a number. (This means +// ** that virtual tables cannot participate in the LIKE optimization.) The +// ** collating sequence for the column on the LHS must be appropriate for +// ** the operator. +// */ +func _isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr, pisComplete uintptr, pnoCase uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, v1 Tu8 + var cnt, iCol, iFrom, iTo, isNum, op, r1, rc, v3 int32 + var db, pLeft, pList, pPrefix, pReprepare, pRight, pVal, v, z, zNew uintptr + var _ /* rDummy at bp+16 */ float64 + var _ /* wc at bp+0 */ [4]Tu8 + var _ /* z2 at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, cnt, db, iCol, iFrom, iTo, isNum, op, pLeft, pList, pPrefix, pReprepare, pRight, pVal, r1, rc, v, z, zNew, v1, v3 + z = uintptr(0) /* Wildcard characters */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + pVal = uintptr(0) /* Result code to return */ + if !(_sqlite3IsLikeFunction(tls, db, pExpr, pnoCase, bp) != 0) { + return 0 + } + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + pLeft = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr + pRight = _sqlite3ExprSkipCollate(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8))).FpExpr) + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) + if op == int32(TK_VARIABLE) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_EnableQPSG) == uint64(0) { + pReprepare = (*TParse)(unsafe.Pointer(pParse)).FpReprepare + iCol = int32((*TExpr)(unsafe.Pointer(pRight)).FiColumn) + pVal = _sqlite3VdbeGetBoundValue(tls, pReprepare, iCol, uint8(SQLITE_AFF_BLOB)) + if pVal != 0 && Xsqlite3_value_type(tls, pVal) == int32(SQLITE_TEXT) { + z = Xsqlite3_value_text(tls, pVal) + } + _sqlite3VdbeSetVarmask(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, iCol) + } else { + if op == int32(TK_STRING) { + z = *(*uintptr)(unsafe.Pointer(pRight + 8)) + } + } + if z != 0 { + /* Count the number of prefix bytes prior to the first wildcard, + ** U+fffd character, or malformed utf-8. If the underlying database + ** has a UTF16LE encoding, then only consider ASCII characters. Note that + ** the encoding of z[] is UTF8 - we are dealing with only UTF8 here in this + ** code, but the database engine itself might be processing content using a + ** different encoding. */ + cnt = 0 + for { + v1 = **(**Tu8)(__ccgo_up(z + uintptr(cnt))) + c = v1 + if !(libc.Int32FromUint8(v1) != 0 && libc.Int32FromUint8(c) != libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[0]) && libc.Int32FromUint8(c) != libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(1)]) && libc.Int32FromUint8(c) != libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(2)])) { + break + } + cnt = cnt + 1 + if libc.Int32FromUint8(c) == libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(3)]) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(cnt)))) > 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(cnt)))) < int32(0x80) { + cnt = cnt + 1 + } else { + if libc.Int32FromUint8(c) >= int32(0x80) { + **(**uintptr)(__ccgo_up(bp + 8)) = z + uintptr(cnt) - uintptr(1) + if libc.Int32FromUint8(c) == int32(0xff) || _sqlite3Utf8Read(tls, bp+8) == uint32(0xfffd) || libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Fenc) == int32(SQLITE_UTF16LE) { + cnt = cnt - 1 + break + } else { + cnt = int32(int64(**(**uintptr)(__ccgo_up(bp + 8))) - int64(z)) + } + } + } + } + /* The optimization is possible only if (1) the pattern does not begin + ** with a wildcard and if (2) the non-wildcard prefix does not end with + ** an (illegal 0xff) character, or (3) the pattern does not consist of + ** a single escape character. The second condition is necessary so + ** that we can increment the prefix key to find an upper bound for the + ** range search. The third is because the caller assumes that the pattern + ** consists of at least one character after all escapes have been + ** removed. */ + if (cnt > int32(1) || cnt > 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z))) != libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(3)])) && int32(255) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(cnt-int32(1))))) { + /* A "complete" match if the pattern ends with "*" or "%" */ + **(**int32)(__ccgo_up(pisComplete)) = libc.BoolInt32(libc.Int32FromUint8(c) == libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[0]) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(cnt+int32(1))))) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Fenc) != int32(SQLITE_UTF16LE)) + /* Get the pattern prefix. Remove all escapes from the prefix. */ + pPrefix = _sqlite3Expr(tls, db, int32(TK_STRING), z) + if pPrefix != 0 { + zNew = *(*uintptr)(unsafe.Pointer(pPrefix + 8)) + **(**int8)(__ccgo_up(zNew + uintptr(cnt))) = 0 + v3 = libc.Int32FromInt32(0) + iTo = v3 + iFrom = v3 + for { + if !(iFrom < cnt) { + break + } + if int32(**(**int8)(__ccgo_up(zNew + uintptr(iFrom)))) == libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(3)]) { + iFrom = iFrom + 1 + } + v3 = iTo + iTo = iTo + 1 + **(**int8)(__ccgo_up(zNew + uintptr(v3))) = **(**int8)(__ccgo_up(zNew + uintptr(iFrom))) + goto _2 + _2: + ; + iFrom = iFrom + 1 + } + **(**int8)(__ccgo_up(zNew + uintptr(iTo))) = 0 + /* If the LHS is not an ordinary column with TEXT affinity, then the + ** pattern prefix boundaries (both the start and end boundaries) must + ** not look like a number. Otherwise the pattern might be treated as + ** a number, which will invalidate the LIKE optimization. + ** + ** Getting this right has been a persistent source of bugs in the + ** LIKE optimization. See, for example: + ** 2018-09-10 https://sqlite.org/src/info/c94369cae9b561b1 + ** 2019-05-02 https://sqlite.org/src/info/b043a54c3de54b28 + ** 2019-06-10 https://sqlite.org/src/info/fd76310a5e843e07 + ** 2019-06-14 https://sqlite.org/src/info/ce8717f0885af975 + ** 2019-09-03 https://sqlite.org/src/info/0f0428096f17252a + */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) != int32(TK_COLUMN) || int32(_sqlite3ExprAffinity(tls, pLeft)) != int32(SQLITE_AFF_TEXT) || (*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) && *(*uintptr)(unsafe.Pointer(pLeft + 64)) != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64)))).FeTabType) == int32(TABTYP_VTAB) { + isNum = _sqlite3AtoF(tls, zNew, bp+16) + if isNum <= 0 { + if iTo == int32(1) && int32(**(**int8)(__ccgo_up(zNew))) == int32('-') { + isNum = +libc.Int32FromInt32(1) + } else { + **(**int8)(__ccgo_up(zNew + uintptr(iTo-int32(1)))) = **(**int8)(__ccgo_up(zNew + uintptr(iTo-int32(1)))) + 1 + isNum = _sqlite3AtoF(tls, zNew, bp+16) + **(**int8)(__ccgo_up(zNew + uintptr(iTo-int32(1)))) = **(**int8)(__ccgo_up(zNew + uintptr(iTo-int32(1)))) - 1 + } + } + if isNum > 0 { + _sqlite3ExprDelete(tls, db, pPrefix) + _sqlite3ValueFree(tls, pVal) + return 0 + } + } + } + **(**uintptr)(__ccgo_up(ppPrefix)) = pPrefix + /* If the RHS pattern is a bound parameter, make arrangements to + ** reprepare the statement when that parameter is rebound */ + if op == int32(TK_VARIABLE) { + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + _sqlite3VdbeSetVarmask(tls, v, int32((*TExpr)(unsafe.Pointer(pRight)).FiColumn)) + if **(**int32)(__ccgo_up(pisComplete)) != 0 && **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pRight + 8)) + 1)) != 0 { + /* If the rhs of the LIKE expression is a variable, and the current + ** value of the variable means there is no need to invoke the LIKE + ** function, then no OP_Variable will be added to the program. + ** This causes problems for the sqlite3_bind_parameter_name() + ** API. To work around them, add a dummy OP_Variable here. + */ + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3ExprCodeTarget(tls, pParse, pRight, r1) + _sqlite3VdbeChangeP3(tls, v, _sqlite3VdbeCurrentAddr(tls, v)-int32(1), 0) + _sqlite3ReleaseTempReg(tls, pParse, r1) + } + } + } else { + z = uintptr(0) + } + } + rc = libc.BoolInt32(z != uintptr(0)) + _sqlite3ValueFree(tls, pVal) + return rc +} + +// C documentation +// +// /* Return the value of a column */ +func _jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, iColumn int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType Tu8 + var i, i1, i2, j, n, n1 Tu32 + var nBase Tu64 + var p uintptr + var _ /* x at bp+0 */ Ti64 + _, _, _, _, _, _, _, _, _ = eType, i, i1, i2, j, n, n1, nBase, p + p = cur + switch iColumn { + case JEACH_KEY: + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent == uint32(0) { + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot == uint32(1) { + break + } + j = libc.Uint32FromInt32(_jsonEachPathLength(tls, p)) + n = (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot - j + if n == uint32(0) { + break + } else { + if int32(**(**int8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf + uintptr(j)))) == int32('[') { + _sqlite3Atoi64(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf+uintptr(j+uint32(1)), bp, libc.Int32FromUint32(n-uint32(1)), uint8(SQLITE_UTF8)) + Xsqlite3_result_int64(tls, ctx, **(**Ti64)(__ccgo_up(bp))) + } else { + if int32(**(**int8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf + uintptr(j+uint32(1))))) == int32('"') { + Xsqlite3_result_text(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf+uintptr(j+uint32(2)), libc.Int32FromUint32(n-uint32(3)), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_text(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf+uintptr(j+uint32(1)), libc.Int32FromUint32(n-uint32(1)), uintptr(-libc.Int32FromInt32(1))) + } + } + } + break + } + if libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeType) == int32(JSONB_OBJECT) { + _jsonReturnFromBlob(tls, p+192, (*TJsonEachCursor)(unsafe.Pointer(p)).Fi, ctx, int32(1)) + } else { + Xsqlite3_result_int64(tls, ctx, (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiKey) + } + case int32(JEACH_VALUE): + i = libc.Uint32FromInt32(_jsonSkipLabel(tls, p)) + _jsonReturnFromBlob(tls, p+192, i, ctx, libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeMode)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i))))&int32(0x0f) >= int32(JSONB_ARRAY) { + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } + case int32(JEACH_TYPE): + i1 = libc.Uint32FromInt32(_jsonSkipLabel(tls, p)) + eType = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i1)))) & int32(0x0f)) + Xsqlite3_result_text(tls, ctx, _jsonbType[eType], -int32(1), libc.UintptrFromInt32(0)) + case int32(JEACH_ATOM): + i2 = libc.Uint32FromInt32(_jsonSkipLabel(tls, p)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i2))))&int32(0x0f) < int32(JSONB_ARRAY) { + _jsonReturnFromBlob(tls, p+192, i2, ctx, int32(1)) + } + case int32(JEACH_ID): + Xsqlite3_result_int64(tls, ctx, libc.Int64FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).Fi)) + case int32(JEACH_PARENT): + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent > uint32(0) && (*TJsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { + Xsqlite3_result_int64(tls, ctx, libc.Int64FromUint32((**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiHead)) + } + case int32(JEACH_FULLKEY): + nBase = (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent != 0 { + _jsonAppendPathName(tls, p) + } + Xsqlite3_result_text64(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed, uintptr(-libc.Int32FromInt32(1)), uint8(SQLITE_UTF8)) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed = nBase + case int32(JEACH_PATH): + n1 = libc.Uint32FromInt32(_jsonEachPathLength(tls, p)) + Xsqlite3_result_text64(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf, uint64(n1), uintptr(-libc.Int32FromInt32(1)), uint8(SQLITE_UTF8)) + default: + Xsqlite3_result_text(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf, libc.Int32FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot), libc.UintptrFromInt32(0)) + case int32(JEACH_JSON): + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson == uintptr(0) { + Xsqlite3_result_blob(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob, libc.Int32FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FnBlob), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_text(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } + break + } + return SQLITE_OK +} + +// C documentation +// +// /* Length of the path for rowid==0 in bRecursive mode. +// */ +func _jsonEachPathLength(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var cSaved int8 + var n, x Tu32 + var z uintptr + var _ /* sz at bp+0 */ Tu32 + _, _, _, _ = cSaved, n, x, z + n = uint32((*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed) + z = (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf + if (*TJsonEachCursor)(unsafe.Pointer(p)).FiRowid == uint32(0) && (*TJsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 && n >= uint32(2) { + for n > uint32(1) { + n = n - 1 + if int32(**(**int8)(__ccgo_up(z + uintptr(n)))) == int32('[') || int32(**(**int8)(__ccgo_up(z + uintptr(n)))) == int32('.') { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + cSaved = **(**int8)(__ccgo_up(z + uintptr(n))) + **(**int8)(__ccgo_up(z + uintptr(n))) = 0 + x = _jsonLookupStep(tls, p+192, uint32(0), z+uintptr(1), uint32(0)) + **(**int8)(__ccgo_up(z + uintptr(n))) = cSaved + if x >= uint32(JSON_LOOKUP_PATHERROR) { + continue + } + if x+_jsonbPayloadSize(tls, p+192, x, bp) == (*TJsonEachCursor)(unsafe.Pointer(p)).Fi { + break + } + } + } + } + return libc.Int32FromUint32(n) +} + +// C documentation +// +// /* argv[0] is a BLOB that seems likely to be a JSONB. Subsequent +// ** arguments come in pairs where each pair contains a JSON path and +// ** content to insert or set at that patch. Do the updates +// ** and return the result. +// ** +// ** The specific operation is determined by eEdit, which can be one +// ** of JEDIT_INS, JEDIT_REPL, JEDIT_SET, or JEDIT_AINS. +// */ +func _jsonInsertIntoBlob(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr, eEdit int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var flgs, i, v1 int32 + var p, zPath uintptr + var rc Tu32 + var _ /* ax at bp+0 */ TJsonParse + _, _, _, _, _, _ = flgs, i, p, rc, zPath, v1 + rc = uint32(0) + zPath = uintptr(0) + if argc == int32(1) { + v1 = 0 + } else { + v1 = int32(JSON_EDITABLE) + } + flgs = v1 + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), libc.Uint32FromInt32(flgs)) + if p == uintptr(0) { + return + } + i = int32(1) + for { + if !(i < argc-int32(1)) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) == int32(SQLITE_NULL) { + goto _2 + } + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zPath == uintptr(0) { + Xsqlite3_result_error_nomem(tls, ctx) + _jsonParseFree(tls, p) + return + } + if int32(**(**int8)(__ccgo_up(zPath))) != int32('$') { + goto jsonInsertIntoBlob_patherror + } + if _jsonFunctionArgToBlob(tls, ctx, **(**uintptr)(__ccgo_up(argv + uintptr(i+int32(1))*8)), bp) != 0 { + _jsonParseReset(tls, bp) + _jsonParseFree(tls, p) + return + } + if int32(**(**int8)(__ccgo_up(zPath + 1))) == 0 { + if eEdit == int32(JEDIT_REPL) || eEdit == int32(JEDIT_SET) { + _jsonBlobEdit(tls, p, uint32(0), (*TJsonParse)(unsafe.Pointer(p)).FnBlob, (**(**TJsonParse)(__ccgo_up(bp))).FaBlob, (**(**TJsonParse)(__ccgo_up(bp))).FnBlob) + } + rc = uint32(0) + } else { + (*TJsonParse)(unsafe.Pointer(p)).FeEdit = libc.Uint8FromInt32(eEdit) + (*TJsonParse)(unsafe.Pointer(p)).FnIns = (**(**TJsonParse)(__ccgo_up(bp))).FnBlob + (*TJsonParse)(unsafe.Pointer(p)).FaIns = (**(**TJsonParse)(__ccgo_up(bp))).FaBlob + (*TJsonParse)(unsafe.Pointer(p)).Fdelta = 0 + (*TJsonParse)(unsafe.Pointer(p)).FiDepth = uint16(0) + rc = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + } + _jsonParseReset(tls, bp) + if rc == uint32(JSON_LOOKUP_NOTFOUND) { + goto _2 + } + if rc >= uint32(JSON_LOOKUP_PATHERROR) { + goto jsonInsertIntoBlob_patherror + } + goto _2 + _2: + ; + i = i + int32(2) + } + _jsonReturnParse(tls, ctx, p) + _jsonParseFree(tls, p) + return + goto jsonInsertIntoBlob_patherror +jsonInsertIntoBlob_patherror: + ; + _jsonParseFree(tls, p) + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(rc)) + return +} + +// C documentation +// +// /* +// ** json_remove(JSON, PATH, ...) +// ** +// ** Remove the named elements from JSON and return the result. malformed +// ** JSON or PATH arguments result in an error. +// */ +func _jsonRemoveFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var i, v1 int32 + var p, zPath uintptr + var rc Tu32 + _, _, _, _, _ = i, p, rc, zPath, v1 /* The parse */ + zPath = uintptr(0) /* Subroutine return code */ + if argc < int32(1) { + return + } + if argc > int32(1) { + v1 = int32(JSON_EDITABLE) + } else { + v1 = 0 + } + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), libc.Uint32FromInt32(v1)) + if p == uintptr(0) { + return + } + i = int32(1) + for { + if !(i < argc) { + break + } + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zPath == uintptr(0) { + goto json_remove_done + } + if int32(**(**int8)(__ccgo_up(zPath))) != int32('$') { + goto json_remove_patherror + } + if int32(**(**int8)(__ccgo_up(zPath + 1))) == 0 { + /* json_remove(j,'$') returns NULL */ + goto json_remove_done + } + (*TJsonParse)(unsafe.Pointer(p)).FeEdit = uint8(JEDIT_DEL) + (*TJsonParse)(unsafe.Pointer(p)).Fdelta = 0 + rc = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + if rc >= uint32(JSON_LOOKUP_PATHERROR) { + if rc == uint32(JSON_LOOKUP_NOTFOUND) { + goto _2 /* No-op */ + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(rc)) + } + goto json_remove_done + } + goto _2 + _2: + ; + i = i + 1 + } + _jsonReturnParse(tls, ctx, p) + _jsonParseFree(tls, p) + return + goto json_remove_patherror +json_remove_patherror: + ; + _jsonBadPathError(tls, ctx, zPath, 0) + goto json_remove_done +json_remove_done: + ; + _jsonParseFree(tls, p) + return +} + +// C documentation +// +// /* +// ** json_type(JSON) +// ** json_type(JSON, PATH) +// ** +// ** Return the top-level "type" of a JSON string. json_type() raises an +// ** error if either the JSON or PATH inputs are not well-formed. +// */ +func _jsonTypeFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var i Tu32 + var p, zPath uintptr + _, _, _ = i, p, zPath /* The parse */ + zPath = uintptr(0) + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if p == uintptr(0) { + return + } + if argc == int32(2) { + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zPath == uintptr(0) { + goto json_type_done + } + if int32(**(**int8)(__ccgo_up(zPath))) != int32('$') { + _jsonBadPathError(tls, ctx, zPath, 0) + goto json_type_done + } + i = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + if i >= uint32(JSON_LOOKUP_PATHERROR) { + if i == uint32(JSON_LOOKUP_NOTFOUND) { + /* no-op */ + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(i)) + } + goto json_type_done + } + } else { + i = uint32(0) + } + Xsqlite3_result_text(tls, ctx, _jsonbType[libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob + uintptr(i))))&int32(0x0f)], -int32(1), libc.UintptrFromInt32(0)) + goto json_type_done +json_type_done: + ; + _jsonParseFree(tls, p) +} + +// C documentation +// +// /* +// ** Parameter zSuper is the name of a super-journal file. A single journal +// ** file that referred to the super-journal file has just been rolled back. +// ** This routine checks if it is possible to delete the super-journal file, +// ** and does so if it is. +// ** +// ** Argument zSuper may point to Pager.pTmpSpace. So that buffer is not +// ** available for use within this function. +// ** +// ** When a super-journal file is created, it is populated with the names +// ** of all of its child journals, one after another, formatted as utf-8 +// ** encoded text. The end of each child journal file is marked with a +// ** nul-terminator byte (0x00). i.e. the entire contents of a super-journal +// ** file for a transaction involving two databases might be: +// ** +// ** "/home/bill/a.db-journal\x00/home/bill/b.db-journal\x00" +// ** +// ** A super-journal file may only be deleted once all of its child +// ** journals have been rolled back. +// ** +// ** This function reads the contents of the super-journal file into +// ** memory and loops through each of the child journal names. For +// ** each child journal, it checks if: +// ** +// ** * if the child journal exists, and if so +// ** * if the child journal contains a reference to super-journal +// ** file zSuper +// ** +// ** If a child journal can be found that matches both of the criteria +// ** above, this function returns without doing anything. Otherwise, if +// ** no such child journal can be found, file zSuper is deleted from +// ** the file-system using sqlite3OsDelete(). +// ** +// ** If an IO error within this function, an error code is returned. This +// ** function allocates memory by calling sqlite3Malloc(). If an allocation +// ** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors +// ** occur, SQLITE_OK is returned. +// ** +// ** TODO: This function allocates a single block of memory to load +// ** the entire contents of the super-journal file. This could be +// ** a couple of kilobytes or so - potentially larger than the page +// ** size. +// */ +func _pager_delsuper(tls *libc.TLS, pPager uintptr, zSuper uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, flags, flags1, rc int32 + var nSuperPtr Ti64 + var pJournal, pSuper, pVfs, zFree, zJournal, zSuperJournal, zSuperPtr uintptr + var v1, v2, v3 int8 + var _ /* exists at bp+8 */ int32 + var _ /* nSuperJournal at bp+0 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, flags, flags1, nSuperPtr, pJournal, pSuper, pVfs, rc, zFree, zJournal, zSuperJournal, zSuperPtr, v1, v2, v3 + pVfs = (*TPager)(unsafe.Pointer(pPager)).FpVfs /* Malloc'd child-journal file descriptor */ + zSuperJournal = uintptr(0) /* Space to hold super-journal filename */ + zFree = uintptr(0) /* Amount of space allocated to zSuperPtr[] */ + /* Allocate space for both the pJournal and pSuper file descriptors. + ** If successful, open the super-journal file for reading. + */ + pSuper = _sqlite3MallocZero(tls, libc.Uint64FromInt64(int64(2)*int64((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile))) + if !(pSuper != 0) { + rc = int32(SQLITE_NOMEM) + pJournal = uintptr(0) + } else { + flags = libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_SUPER_JOURNAL) + rc = _sqlite3OsOpen(tls, pVfs, zSuper, pSuper, flags, uintptr(0)) + pJournal = pSuper + uintptr((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + } + if rc != SQLITE_OK { + goto delsuper_out + } + /* Load the entire super-journal file into space obtained from + ** sqlite3_malloc() and pointed to by zSuperJournal. Also obtain + ** sufficient space (in zSuperPtr) to hold the names of super-journal + ** files extracted from regular rollback-journals. + */ + rc = _sqlite3OsFileSize(tls, pSuper, bp) + if rc != SQLITE_OK { + goto delsuper_out + } + nSuperPtr = int64(1) + int64((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname) + zFree = _sqlite3Malloc(tls, libc.Uint64FromInt64(int64(4)+**(**Ti64)(__ccgo_up(bp))+int64(2)+nSuperPtr+int64(2))) + if !(zFree != 0) { + rc = int32(SQLITE_NOMEM) + goto delsuper_out + } else { + } + v3 = libc.Int8FromInt32(0) + **(**int8)(__ccgo_up(zFree + 3)) = v3 + v2 = v3 + **(**int8)(__ccgo_up(zFree + 2)) = v2 + v1 = v2 + **(**int8)(__ccgo_up(zFree + 1)) = v1 + **(**int8)(__ccgo_up(zFree)) = v1 + zSuperJournal = zFree + 4 + zSuperPtr = zSuperJournal + uintptr(**(**Ti64)(__ccgo_up(bp))+int64(2)) + rc = _sqlite3OsRead(tls, pSuper, zSuperJournal, int32(**(**Ti64)(__ccgo_up(bp))), 0) + if rc != SQLITE_OK { + goto delsuper_out + } + **(**int8)(__ccgo_up(zSuperJournal + uintptr(**(**Ti64)(__ccgo_up(bp))))) = 0 + **(**int8)(__ccgo_up(zSuperJournal + uintptr(**(**Ti64)(__ccgo_up(bp))+int64(1)))) = 0 + zJournal = zSuperJournal + for int64(zJournal)-int64(zSuperJournal) < **(**Ti64)(__ccgo_up(bp)) { + rc = _sqlite3OsAccess(tls, pVfs, zJournal, SQLITE_ACCESS_EXISTS, bp+8) + if rc != SQLITE_OK { + goto delsuper_out + } + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + flags1 = libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_SUPER_JOURNAL) + rc = _sqlite3OsOpen(tls, pVfs, zJournal, pJournal, flags1, uintptr(0)) + if rc != SQLITE_OK { + goto delsuper_out + } + rc = _readSuperJournal(tls, pJournal, zSuperPtr, libc.Uint64FromInt64(nSuperPtr)) + _sqlite3OsClose(tls, pJournal) + if rc != SQLITE_OK { + goto delsuper_out + } + c = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zSuperPtr))) != 0 && libc.Xstrcmp(tls, zSuperPtr, zSuper) == 0) + if c != 0 { + /* We have a match. Do not delete the super-journal file. */ + goto delsuper_out + } + } + zJournal = zJournal + uintptr(_sqlite3Strlen30(tls, zJournal)+libc.Int32FromInt32(1)) + } + _sqlite3OsClose(tls, pSuper) + rc = _sqlite3OsDelete(tls, pVfs, zSuper, 0) + goto delsuper_out +delsuper_out: + ; + Xsqlite3_free(tls, zFree) + if pSuper != 0 { + _sqlite3OsClose(tls, pSuper) + Xsqlite3_free(tls, pSuper) + } + return rc +} + +// C documentation +// +// /* +// ** Compare two UTF-8 strings for equality where the first string is +// ** a GLOB or LIKE expression. Return values: +// ** +// ** SQLITE_MATCH: Match +// ** SQLITE_NOMATCH: No match +// ** SQLITE_NOWILDCARDMATCH: No match in spite of having * or % wildcards. +// ** +// ** Globbing rules: +// ** +// ** '*' Matches any sequence of zero or more characters. +// ** +// ** '?' Matches exactly one character. +// ** +// ** [...] Matches one character from the enclosed list of +// ** characters. +// ** +// ** [^...] Matches one character not in the enclosed list. +// ** +// ** With the [...] and [^...] matching, a ']' character can be included +// ** in the list by making it the first character after '[' or '^'. A +// ** range of characters can be specified using '-'. Example: +// ** "[a-z]" matches any single lower-case letter. To match a '-', make +// ** it the last character in the list. +// ** +// ** Like matching rules: +// ** +// ** '%' Matches any sequence of zero or more characters +// ** +// *** '_' Matches any one character +// ** +// ** Ec Where E is the "esc" character and c is any other +// ** character, including '%', '_', and esc, match exactly c. +// ** +// ** The comments within this routine usually assume glob matching. +// ** +// ** This routine is usually quick, but can be N**2 in the worst case. +// */ +func _patternCompare(tls *libc.TLS, _zPattern uintptr, _zString uintptr, pInfo uintptr, matchOther Tu32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + *(*uintptr)(unsafe.Pointer(bp)) = _zPattern + *(*uintptr)(unsafe.Pointer(bp + 8)) = _zString + var bMatch, bMatch1, bMatch2, invert, seen, v13 int32 + var c, c2, matchAll, matchOne, prior_c, v1, v4 Tu32 + var noCase Tu8 + var zEscaped, v3, v6 uintptr + var v2, v5 uint32 + var _ /* zStop at bp+18 */ [3]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bMatch, bMatch1, bMatch2, c, c2, invert, matchAll, matchOne, noCase, prior_c, seen, zEscaped, v1, v13, v2, v3, v4, v5, v6 /* Next pattern and input string chars */ + matchOne = uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchOne) /* "?" or "_" */ + matchAll = uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchAll) /* "*" or "%" */ + noCase = (*TcompareInfo)(unsafe.Pointer(pInfo)).FnoCase /* True if uppercase==lowercase */ + zEscaped = uintptr(0) /* One past the last escaped input char */ + for { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) < int32(0x80) { + v3 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v2 = uint32(**(**Tu8)(__ccgo_up(v3))) + } else { + v2 = _sqlite3Utf8Read(tls, bp) + } + v1 = v2 + c = v1 + if !(v1 != uint32(0)) { + break + } + if c == matchAll { /* Match "*" */ + /* Skip over multiple "*" characters in the pattern. If there + ** are also "?" characters, skip those as well, but consume a + ** single character of the input string for each "?" skipped */ + for { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) < int32(0x80) { + v6 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v5 = uint32(**(**Tu8)(__ccgo_up(v6))) + } else { + v5 = _sqlite3Utf8Read(tls, bp) + } + v4 = v5 + c = v4 + if !(v4 == matchAll || c == matchOne && matchOne != uint32(0)) { + break + } + if c == matchOne && _sqlite3Utf8Read(tls, bp+8) == uint32(0) { + return int32(SQLITE_NOWILDCARDMATCH) + } + } + if c == uint32(0) { + return SQLITE_MATCH /* "*" at the end of the pattern matches */ + } else { + if c == matchOther { + if libc.Int32FromUint8((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 { + c = _sqlite3Utf8Read(tls, bp) + if c == uint32(0) { + return int32(SQLITE_NOWILDCARDMATCH) + } + } else { + /* "[...]" immediately follows the "*". We have to do a slow + ** recursive search in this case, but it is an unusual case. */ + /* '[' is a single-byte character */ + for **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != 0 { + bMatch = _patternCompare(tls, **(**uintptr)(__ccgo_up(bp))+uintptr(-libc.Int32FromInt32(1)), **(**uintptr)(__ccgo_up(bp + 8)), pInfo, matchOther) + if bMatch != int32(SQLITE_NOMATCH) { + return bMatch + } + v3 = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v3))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))))&int32(0xc0) == int32(0x80) { + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + } + } + } + return int32(SQLITE_NOWILDCARDMATCH) + } + } + } + /* At this point variable c contains the first character of the + ** pattern string past the "*". Search in the input string for the + ** first matching character and recursively continue the match from + ** that point. + ** + ** For a case-insensitive search, set variable cx to be the same as + ** c but in the other case and search the input string for either + ** c or cx. + */ + if c < uint32(0x80) { + if noCase != 0 { + (**(**[3]int8)(__ccgo_up(bp + 18)))[0] = libc.Int8FromUint32(c & libc.Uint32FromInt32(^(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(c)]) & libc.Int32FromInt32(0x20)))) + (**(**[3]int8)(__ccgo_up(bp + 18)))[int32(1)] = libc.Int8FromUint8(_sqlite3UpperToLower[uint8(c)]) + (**(**[3]int8)(__ccgo_up(bp + 18)))[int32(2)] = 0 + } else { + (**(**[3]int8)(__ccgo_up(bp + 18)))[0] = libc.Int8FromUint32(c) + (**(**[3]int8)(__ccgo_up(bp + 18)))[int32(1)] = 0 + } + for int32(1) != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(libc.Xstrcspn(tls, **(**uintptr)(__ccgo_up(bp + 8)), bp+18)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) == 0 { + break + } + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + bMatch1 = _patternCompare(tls, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 8)), pInfo, matchOther) + if bMatch1 != int32(SQLITE_NOMATCH) { + return bMatch1 + } + } + } else { + for { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) < int32(0x80) { + v3 = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + v2 = uint32(**(**Tu8)(__ccgo_up(v3))) + } else { + v2 = _sqlite3Utf8Read(tls, bp+8) + } + v1 = v2 + c2 = v1 + if !(v1 != uint32(0)) { + break + } + if c2 != c { + continue + } + bMatch2 = _patternCompare(tls, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 8)), pInfo, matchOther) + if bMatch2 != int32(SQLITE_NOMATCH) { + return bMatch2 + } + } + } + return int32(SQLITE_NOWILDCARDMATCH) + } + if c == matchOther { + if libc.Int32FromUint8((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 { + c = _sqlite3Utf8Read(tls, bp) + if c == uint32(0) { + return int32(SQLITE_NOMATCH) + } + zEscaped = **(**uintptr)(__ccgo_up(bp)) + } else { + prior_c = uint32(0) + seen = 0 + invert = 0 + c = _sqlite3Utf8Read(tls, bp+8) + if c == uint32(0) { + return int32(SQLITE_NOMATCH) + } + c2 = _sqlite3Utf8Read(tls, bp) + if c2 == uint32('^') { + invert = int32(1) + c2 = _sqlite3Utf8Read(tls, bp) + } + if c2 == uint32(']') { + if c == uint32(']') { + seen = int32(1) + } + c2 = _sqlite3Utf8Read(tls, bp) + } + for c2 != 0 && c2 != uint32(']') { + if c2 == uint32('-') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(']') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != 0 && prior_c > uint32(0) { + c2 = _sqlite3Utf8Read(tls, bp) + if c >= prior_c && c <= c2 { + seen = int32(1) + } + prior_c = uint32(0) + } else { + if c == c2 { + seen = int32(1) + } + prior_c = c2 + } + c2 = _sqlite3Utf8Read(tls, bp) + } + if c2 == uint32(0) || seen^invert == 0 { + return int32(SQLITE_NOMATCH) + } + continue + } + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) < int32(0x80) { + v3 = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + v2 = uint32(**(**Tu8)(__ccgo_up(v3))) + } else { + v2 = _sqlite3Utf8Read(tls, bp+8) + } + c2 = v2 + if c == c2 { + continue + } + if noCase != 0 && libc.Int32FromUint8(_sqlite3UpperToLower[uint8(c)]) == libc.Int32FromUint8(_sqlite3UpperToLower[uint8(c2)]) && c < uint32(0x80) && c2 < uint32(0x80) { + continue + } + if c == matchOne && **(**uintptr)(__ccgo_up(bp)) != zEscaped && c2 != uint32(0) { + continue + } + return int32(SQLITE_NOMATCH) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) == 0 { + v13 = SQLITE_MATCH + } else { + v13 = int32(SQLITE_NOMATCH) + } + return v13 +} + +// C documentation +// +// /* +// ** This is a Walker expression callback. pExpr is a node from the WHERE +// ** clause of a SELECT statement. This function examines pExpr to see if +// ** any substitutions based on the contents of pWalker->u.pConst should +// ** be made to pExpr or its immediate children. +// ** +// ** A substitution is made if: +// ** +// ** + pExpr is a column with an affinity other than BLOB that matches +// ** one of the columns in pWalker->u.pConst, or +// ** +// ** + pExpr is a binary comparison operator (=, <=, >=, <, >) that +// ** uses an affinity other than TEXT and one of its immediate +// ** children is a column that matches one of the columns in +// ** pWalker->u.pConst. +// */ +func _propagateConstantExprRewrite(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var pConst uintptr + _ = pConst + pConst = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + if (*TWhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) >= int32(TK_EQ) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) <= int32(TK_GE) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IS) { + _propagateConstantExprRewriteOne(tls, pConst, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, 0) + if **(**Tu8)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FpOomFault)) != 0 { + return int32(WRC_Prune) + } + if int32(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft)) != int32(SQLITE_AFF_TEXT) { + _propagateConstantExprRewriteOne(tls, pConst, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, 0) + } + } + } + return _propagateConstantExprRewriteOne(tls, pConst, pExpr, (*TWhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob) +} + +// C documentation +// +// /* +// ** This is a helper function for Walker callback propagateConstantExprRewrite(). +// ** +// ** Argument pExpr is a candidate expression to be replaced by a value. If +// ** pExpr is equivalent to one of the columns named in pWalker->u.pConst, +// ** then overwrite it with the corresponding value. Except, do not do so +// ** if argument bIgnoreAffBlob is non-zero and the affinity of pExpr +// ** is SQLITE_AFF_BLOB. +// */ +func _propagateConstantExprRewriteOne(tls *libc.TLS, pConst uintptr, pExpr uintptr, bIgnoreAffBlob int32) (r int32) { + var i int32 + var pColumn uintptr + _, _ = i, pColumn + if **(**Tu8)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FpOomFault)) != 0 { + return int32(WRC_Prune) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLUMN) { + return WRC_Continue + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&(libc.Uint32FromInt32(EP_FixedCol)|(*TWhereConst)(unsafe.Pointer(pConst)).FmExcludeOn) != uint32(0) { + return WRC_Continue + } + i = 0 + for { + if !(i < (*TWhereConst)(unsafe.Pointer(pConst)).FnConst) { + break + } + pColumn = **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*int32(2))*8)) + if pColumn == pExpr { + goto _1 + } + if (*TExpr)(unsafe.Pointer(pColumn)).FiTable != (*TExpr)(unsafe.Pointer(pExpr)).FiTable { + goto _1 + } + if int32((*TExpr)(unsafe.Pointer(pColumn)).FiColumn) != int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) { + goto _1 + } + if bIgnoreAffBlob != 0 && int32(_sqlite3ExprAffinity(tls, pColumn)) <= int32(SQLITE_AFF_BLOB) { + break + } + /* A match is found. Add the EP_FixedCol property */ + (*TWhereConst)(unsafe.Pointer(pConst)).FnChng = (*TWhereConst)(unsafe.Pointer(pConst)).FnChng + 1 + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer((*TWhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb, **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*int32(2)+int32(1))*8)), 0) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TWhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb)).FmallocFailed != 0 { + return int32(WRC_Prune) + } + break + goto _1 + _1: + ; + i = i + 1 + } + return int32(WRC_Prune) +} + +func _rbuDeltaOutputSize(tls *libc.TLS, _zDelta uintptr, _lenDelta int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _zDelta + *(*int32)(unsafe.Pointer(bp + 8)) = _lenDelta + var size int32 + _ = size + size = libc.Int32FromUint32(_rbuDeltaGetInt(tls, bp, bp+8)) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32('\n') { + /* ERROR: size integer not terminated by "\n" */ + return -int32(1) + } + return size +} + +/* +** End of code taken from fossil. +*************************************************************************/ + +// C documentation +// +// /* +// ** When this is called the journal file for pager pPager must be open. +// ** This function attempts to read a super-journal file name from the +// ** end of the file and, if successful, copies it into memory supplied +// ** by the caller. See comments above writeSuperJournal() for the format +// ** used to store a super-journal file name at the end of a journal file. +// ** +// ** zSuper must point to a buffer of at least nSuper bytes allocated by +// ** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is +// ** enough space to write the super-journal name). If the super-journal +// ** name in the journal is longer than nSuper bytes (including a +// ** nul-terminator), then this is handled as if no super-journal name +// ** were present in the journal. +// ** +// ** If a super-journal file name is present at the end of the journal +// ** file, then it is copied into the buffer pointed to by zSuper. A +// ** nul-terminator byte is appended to the buffer following the +// ** super-journal file name. +// ** +// ** If it is determined that no super-journal file name is present +// ** zSuper[0] is set to 0 and SQLITE_OK returned. +// ** +// ** If an error occurs while reading from the journal file, an SQLite +// ** error code is returned. +// */ +func _readSuperJournal(tls *libc.TLS, pJrnl uintptr, zSuper uintptr, nSuper Tu64) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc, v1, v2, v4, v6, v8 int32 + var u Tu32 + var v3, v5, v7, v9 bool + var _ /* aMagic at bp+24 */ [8]uint8 + var _ /* cksum at bp+16 */ Tu32 + var _ /* len at bp+0 */ Tu32 + var _ /* szJ at bp+8 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _ = rc, u, v1, v2, v3, v4, v5, v6, v7, v8, v9 /* A buffer to hold the magic header */ + **(**int8)(__ccgo_up(zSuper)) = int8('\000') + v1 = _sqlite3OsFileSize(tls, pJrnl, bp+8) + rc = v1 + if v3 = SQLITE_OK != v1 || **(**Ti64)(__ccgo_up(bp + 8)) < int64(16); !v3 { + v2 = _read32bits(tls, pJrnl, **(**Ti64)(__ccgo_up(bp + 8))-int64(16), bp) + rc = v2 + } + if v5 = v3 || SQLITE_OK != v2 || uint64(**(**Tu32)(__ccgo_up(bp))) >= nSuper || libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp))) > **(**Ti64)(__ccgo_up(bp + 8))-int64(16) || **(**Tu32)(__ccgo_up(bp)) == uint32(0); !v5 { + v4 = _read32bits(tls, pJrnl, **(**Ti64)(__ccgo_up(bp + 8))-int64(12), bp+16) + rc = v4 + } + if v7 = v5 || SQLITE_OK != v4; !v7 { + v6 = _sqlite3OsRead(tls, pJrnl, bp+24, int32(8), **(**Ti64)(__ccgo_up(bp + 8))-int64(8)) + rc = v6 + } + if v9 = v7 || SQLITE_OK != v6 || libc.Xmemcmp(tls, bp+24, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8)) != 0; !v9 { + v8 = _sqlite3OsRead(tls, pJrnl, zSuper, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))), **(**Ti64)(__ccgo_up(bp + 8))-int64(16)-libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp)))) + rc = v8 + } + if v9 || SQLITE_OK != v8 { + return rc + } + /* See if the checksum matches the super-journal name */ + u = uint32(0) + for { + if !(u < **(**Tu32)(__ccgo_up(bp))) { + break + } + **(**Tu32)(__ccgo_up(bp + 16)) = **(**Tu32)(__ccgo_up(bp + 16)) - libc.Uint32FromInt8(**(**int8)(__ccgo_up(zSuper + uintptr(u)))) + goto _10 + _10: + ; + u = u + 1 + } + if **(**Tu32)(__ccgo_up(bp + 16)) != 0 { + /* If the checksum doesn't add up, then one or more of the disk sectors + ** containing the super-journal filename is corrupted. This means + ** definitely roll back, so just return SQLITE_OK and report a (nul) + ** super-journal filename. + */ + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + } + **(**int8)(__ccgo_up(zSuper + uintptr(**(**Tu32)(__ccgo_up(bp))))) = int8('\000') + **(**int8)(__ccgo_up(zSuper + uintptr(**(**Tu32)(__ccgo_up(bp))+uint32(1)))) = int8('\000') + return SQLITE_OK +} + +// C documentation +// +// /* +// ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect. +// ** The Name context of the SELECT statement is pNC. zType is either +// ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is. +// ** +// ** This routine resolves each term of the clause into an expression. +// ** If the order-by term is an integer I between 1 and N (where N is the +// ** number of columns in the result set of the SELECT) then the expression +// ** in the resolution is a copy of the I-th result-set expression. If +// ** the order-by term is an identifier that corresponds to the AS-name of +// ** a result-set expression, then the term resolves to a copy of the +// ** result-set expression. Otherwise, the expression is resolved in +// ** the usual way - using sqlite3ResolveExprNames(). +// ** +// ** This routine returns the number of errors. If errors occur, then +// ** an appropriate error message might be left in pParse. (OOM errors +// ** excepted.) +// */ +func _resolveOrderGroupBy(tls *libc.TLS, pNC uintptr, pSelect uintptr, pOrderBy uintptr, zType uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j, nResult int32 + var pE, pE2, pItem, pParse uintptr + var _ /* iCol at bp+0 */ int32 + _, _, _, _, _, _, _ = i, j, nResult, pE, pE2, pItem, pParse /* Number of terms in the result set */ + nResult = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList)).FnExpr + pParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + i = 0 + pItem = pOrderBy + 8 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + pE = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + pE2 = _sqlite3ExprSkipCollateAndLikely(tls, pE) + if pE2 == uintptr(0) { + goto _1 + } + if int32(**(**int8)(__ccgo_up(zType))) != int32('G') { + **(**int32)(__ccgo_up(bp)) = _resolveAsName(tls, pParse, (*TSelect)(unsafe.Pointer(pSelect)).FpEList, pE2) + if **(**int32)(__ccgo_up(bp)) > 0 { + /* If an AS-name match is found, mark this ORDER BY column as being + ** a copy of the iCol-th result-set column. The subsequent call to + ** sqlite3ResolveOrderGroupBy() will convert the expression to a + ** copy of the iCol-th result-set expression. */ + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = libc.Uint16FromInt32(**(**int32)(__ccgo_up(bp))) + goto _1 + } + } + if _sqlite3ExprIsInteger(tls, pE2, bp, uintptr(0)) != 0 { + /* The ORDER BY term is an integer constant. Again, set the column + ** number so that sqlite3ResolveOrderGroupBy() will convert the + ** order-by term to a copy of the result-set expression */ + if **(**int32)(__ccgo_up(bp)) < int32(1) || **(**int32)(__ccgo_up(bp)) > int32(0xffff) { + _resolveOutOfRangeError(tls, pParse, zType, i+int32(1), nResult, pE2) + return int32(1) + } + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = libc.Uint16FromInt32(**(**int32)(__ccgo_up(bp))) + goto _1 + } + /* Otherwise, treat the ORDER BY term as an ordinary expression */ + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = uint16(0) + if _sqlite3ResolveExprNames(tls, pNC, pE) != 0 { + return int32(1) + } + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList)).FnExpr) { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), pE, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList + 8 + uintptr(j)*32))).FpExpr, -int32(1)) == 0 { + /* Since this expression is being changed into a reference + ** to an identical expression in the result set, remove all Window + ** objects belonging to the expression from the Select.pWin list. */ + _windowRemoveExprFromSelect(tls, pSelect, pE) + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = libc.Uint16FromInt32(j + int32(1)) + } + goto _2 + _2: + ; + j = j + 1 + } + goto _1 + _1: + ; + i = i + 1 + pItem += 32 + } + return _sqlite3ResolveOrderGroupBy(tls, pParse, pSelect, pOrderBy, zType) +} + +// C documentation +// +// /* +// ** Add a new CHECK constraint to the table currently under construction. +// */ +func _sqlite3AddCheckConstraint(tls *libc.TLS, pParse uintptr, pCheckExpr uintptr, zStart uintptr, zEnd uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pTab uintptr + var _ /* t at bp+0 */ TToken + _, _ = db, pTab + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pTab != 0 && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == libc.Int32FromInt32(PARSE_MODE_DECLARE_VTAB)) && !(_sqlite3BtreeIsReadonly(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb)*32))).FpBt) != 0) { + (*TTable)(unsafe.Pointer(pTab)).FpCheck = _sqlite3ExprListAppend(tls, pParse, (*TTable)(unsafe.Pointer(pTab)).FpCheck, pCheckExpr) + if (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName.Fn != 0 { + _sqlite3ExprListSetName(tls, pParse, (*TTable)(unsafe.Pointer(pTab)).FpCheck, pParse+248+16, int32(1)) + } else { + zStart = zStart + 1 + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zStart)))])&int32(0x01) != 0) { + break + } + goto _1 + _1: + ; + zStart = zStart + 1 + } + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zEnd + uintptr(-libc.Int32FromInt32(1)))))])&int32(0x01) != 0 { + zEnd = zEnd - 1 + } + (**(**TToken)(__ccgo_up(bp))).Fz = zStart + (**(**TToken)(__ccgo_up(bp))).Fn = libc.Uint32FromInt32(int32(int64(zEnd) - int64((**(**TToken)(__ccgo_up(bp))).Fz))) + _sqlite3ExprListSetName(tls, pParse, (*TTable)(unsafe.Pointer(pTab)).FpCheck, bp, int32(1)) + } + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCheckExpr) + } +} + +// C documentation +// +// /* +// ** The most recently coded instruction was an OP_Column to retrieve the +// ** i-th column of table pTab. This routine sets the P4 parameter of the +// ** OP_Column to the default value, if any. +// ** +// ** The default value of a column is specified by a DEFAULT clause in the +// ** column definition. This was either supplied by the user when the table +// ** was created, or added later to the table definition by an ALTER TABLE +// ** command. If the latter, then the row-records in the table btree on disk +// ** may not contain a value for the column and the default value, taken +// ** from the P4 parameter of the OP_Column instruction, is returned instead. +// ** If the former, then all row-records are guaranteed to include a value +// ** for the column and the P4 value is not required. +// ** +// ** Column definitions created by an ALTER TABLE command may only have +// ** literal default values specified: a number, null or a string. (If a more +// ** complicated default expression value was provided, it is evaluated +// ** when the ALTER TABLE is executed and one of the literal values written +// ** into the sqlite_schema table.) +// ** +// ** Therefore, the P4 parameter is only required if the default value for +// ** the column is a literal number, string or null. The sqlite3ValueFromExpr() +// ** function is capable of transforming these types of expressions into +// ** sqlite3_value objects. +// ** +// ** If column as REAL affinity and the table is an ordinary b-tree table +// ** (not a virtual table) then the value might have been stored as an +// ** integer. In that case, add an OP_RealAffinity opcode to make sure +// ** it has been converted into REAL. +// */ +func _sqlite3ColumnDefault(tls *libc.TLS, v uintptr, pTab uintptr, i int32, iReg int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var enc Tu8 + var pCol uintptr + var _ /* pValue at bp+0 */ uintptr + _, _ = enc, pCol + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + if (*TColumn)(unsafe.Pointer(pCol)).FiDflt != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + enc = (*Tsqlite3)(unsafe.Pointer(_sqlite3VdbeDb(tls, v))).Fenc + _sqlite3ValueFromExpr(tls, _sqlite3VdbeDb(tls, v), _sqlite3ColumnExpr(tls, pTab, pCol), enc, libc.Uint8FromInt8((*TColumn)(unsafe.Pointer(pCol)).Faffinity), bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + _sqlite3VdbeAppendP4(tls, v, **(**uintptr)(__ccgo_up(bp)), -int32(11)) + } + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_REAL) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), iReg) + } +} + +// C documentation +// +// /* +// ** The text between zStart and zEnd represents a phrase within a larger +// ** SQL statement. Make a copy of this phrase in space obtained form +// ** sqlite3DbMalloc(). Omit leading and trailing whitespace. +// */ +func _sqlite3DbSpanDup(tls *libc.TLS, db uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var n int32 + _ = n + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zStart)))])&int32(0x01) != 0 { + zStart = zStart + 1 + } + n = int32(int64(zEnd) - int64(zStart)) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zStart + uintptr(n-int32(1)))))])&int32(0x01) != 0 { + n = n - 1 + } + return _sqlite3DbStrNDup(tls, db, zStart, libc.Uint64FromInt32(n)) +} + +// C documentation +// +// /* +// ** If the input token p is quoted, try to adjust the token to remove +// ** the quotes. This is not always possible: +// ** +// ** "abc" -> abc +// ** "ab""cd" -> (not possible because of the interior "") +// ** +// ** Remove the quotes if possible. This is a optimization. The overall +// ** system should still return the correct answer even if this routine +// ** is always a no-op. +// */ +func _sqlite3DequoteToken(tls *libc.TLS, p uintptr) { + var i uint32 + _ = i + if (*TToken)(unsafe.Pointer(p)).Fn < uint32(2) { + return + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up((*TToken)(unsafe.Pointer(p)).Fz)))])&libc.Int32FromInt32(0x80) != 0) { + return + } + i = uint32(1) + for { + if !(i < (*TToken)(unsafe.Pointer(p)).Fn-uint32(1)) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up((*TToken)(unsafe.Pointer(p)).Fz + uintptr(i))))])&int32(0x80) != 0 { + return + } + goto _1 + _1: + ; + i = i + 1 + } + **(**uint32)(__ccgo_up(p + 8)) -= uint32(2) + (*TToken)(unsafe.Pointer(p)).Fz = (*TToken)(unsafe.Pointer(p)).Fz + 1 +} + +// C documentation +// +// /* +// ** Return the 'affinity' of the expression pExpr if any. +// ** +// ** If pExpr is a column, a reference to a column via an 'AS' alias, +// ** or a sub-select with a column as the return value, then the +// ** affinity of that column is returned. Otherwise, 0x00 is returned, +// ** indicating no affinity for the expression. +// ** +// ** i.e. the WHERE clause expressions in the following statements all +// ** have an affinity: +// ** +// ** CREATE TABLE t1(a); +// ** SELECT * FROM t1 WHERE a; +// ** SELECT a AS b FROM t1 WHERE b; +// ** SELECT * FROM t1 WHERE (select a from t1); +// */ +func _sqlite3ExprAffinity(tls *libc.TLS, pExpr uintptr) (r int8) { + var op int32 + _ = op + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + for int32(1) != 0 { + if op == int32(TK_COLUMN) || op == int32(TK_AGG_COLUMN) && *(*uintptr)(unsafe.Pointer(pExpr + 64)) != uintptr(0) { + return _sqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn)) + } + if op == int32(TK_SELECT) { + return _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList + 8))).FpExpr) + } + if op == int32(TK_CAST) { + return _sqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0)) + } + if op == int32(TK_SELECT_COLUMN) { + return _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32)))).FpEList + 8 + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiColumn)*32))).FpExpr) + } + if op == int32(TK_VECTOR) || op == int32(TK_FUNCTION) && int32((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(SQLITE_AFF_DEFER) { + return _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Skip)|libc.Int32FromInt32(EP_IfNullRow)) != uint32(0) { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + continue + } + if op != int32(TK_REGISTER) { + break + } + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) + if op == int32(TK_REGISTER) { + break + } + } + return (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr +} + +// C documentation +// +// /* +// ** Generate code that will compute the value of generated column pCol +// ** and store the result in register regOut +// */ +func _sqlite3ExprCodeGeneratedColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, pCol uintptr, regOut int32) { + var iAddr, nErr, p3 int32 + var v uintptr + _, _, _, _ = iAddr, nErr, p3, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + nErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + if (*TParse)(unsafe.Pointer(pParse)).FiSelfTab > 0 { + iAddr = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNullRow), (*TParse)(unsafe.Pointer(pParse)).FiSelfTab-int32(1), 0, regOut) + } else { + iAddr = 0 + } + _sqlite3ExprCodeCopy(tls, pParse, _sqlite3ColumnExpr(tls, pTab, pCol), regOut) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Strict) != uint32(0) { + p3 = int32(2) + int32((int64(pCol)-int64((*TTable)(unsafe.Pointer(pTab)).FaCol))/16) + _sqlite3VdbeAddOp4(tls, v, int32(OP_TypeCheck), regOut, int32(1), p3, pTab, -int32(5)) + } else { + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_TEXT) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), regOut, int32(1), 0, pCol+9, int32(1)) + } + } + if iAddr != 0 { + _sqlite3VdbeJumpHere(tls, v, iAddr) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr > nErr { + (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FerrByteOffset = -int32(1) + } +} + +// C documentation +// +// /* +// ** Generate code for an IN expression. +// ** +// ** x IN (SELECT ...) +// ** x IN (value, value, ...) +// ** +// ** The left-hand side (LHS) is a scalar or vector expression. The +// ** right-hand side (RHS) is an array of zero or more scalar values, or a +// ** subquery. If the RHS is a subquery, the number of result columns must +// ** match the number of columns in the vector on the LHS. If the RHS is +// ** a list of values, the LHS must be a scalar. +// ** +// ** The IN operator is true if the LHS value is contained within the RHS. +// ** The result is false if the LHS is definitely not in the RHS. The +// ** result is NULL if the presence of the LHS in the RHS cannot be +// ** determined due to NULLs. +// ** +// ** This routine generates code that jumps to destIfFalse if the LHS is not +// ** contained within the RHS. If due to NULLs we cannot determine if the LHS +// ** is contained in the RHS then jump to destIfNull. If the LHS is contained +// ** within the RHS then fall through. +// ** +// ** See the separate in-operator.md documentation file in the canonical +// ** SQLite source tree for additional information. +// */ +func _sqlite3ExprCodeIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, destIfFalse int32, destIfNull int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var addrTop, addrTruthOp, destNotNull, destStep2, destStep6, eType, i, ii, labelOk, nVector, op, op1, r2, r3, rLhs, rLhsOrig, regCkNull, v3 int32 + var aiMap, p, p1, pColl, pColl1, pLeft, pList, pOp, pRhs, v, zAff, v1 uintptr + var okConstFactor Tu8 + var _ /* iDummy at bp+4 */ int32 + var _ /* iTab at bp+8 */ int32 + var _ /* rRhsHasNull at bp+0 */ int32 + var _ /* regToFree at bp+12 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrTop, addrTruthOp, aiMap, destNotNull, destStep2, destStep6, eType, i, ii, labelOk, nVector, okConstFactor, op, op1, p, p1, pColl, pColl1, pLeft, pList, pOp, pRhs, r2, r3, rLhs, rLhsOrig, regCkNull, v, zAff, v1, v3 + **(**int32)(__ccgo_up(bp)) = 0 /* Statement under construction */ + aiMap = uintptr(0) /* Map from vector field to index column */ + zAff = uintptr(0) /* Where to jump when NULLs seen in step 2 */ + destStep6 = 0 /* Top of the step-6 loop */ + **(**int32)(__ccgo_up(bp + 8)) = 0 /* Index to use */ + okConstFactor = libc.Uint8FromInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x80 >> 7))) + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if _sqlite3ExprCheckIN(tls, pParse, pExpr) != 0 { + return + } + zAff = _exprINAffinity(tls, pParse, pExpr) + nVector = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + aiMap = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(libc.Uint64FromInt32(nVector)*uint64(4))) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + goto sqlite3ExprCodeIN_oom_error + } + /* Attempt to compute the RHS. After this step, if anything other than + ** IN_INDEX_NOOP is returned, the table opened with cursor iTab + ** contains the values that make up the RHS. If IN_INDEX_NOOP is returned, + ** the RHS has not yet been coded. */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* OOM detected prior to this routine */ + if destIfFalse == destIfNull { + v1 = uintptr(0) + } else { + v1 = bp + } + eType = _sqlite3FindInIndex(tls, pParse, pExpr, libc.Uint32FromInt32(libc.Int32FromInt32(IN_INDEX_MEMBERSHIP)|libc.Int32FromInt32(IN_INDEX_NOOP_OK)), v1, aiMap, bp+8) + /* Code the LHS, the from " IN (...)". If the LHS is a + ** vector, then it is stored in an array of nVector registers starting + ** at r1. + ** + ** sqlite3FindInIndex() might have reordered the fields of the LHS vector + ** so that the fields are in the same order as an existing index. The + ** aiMap[] array contains a mapping from the original LHS field order to + ** the field order that matches the RHS index. + ** + ** Avoid factoring the LHS of the IN(...) expression out of the loop, + ** even if it is constant, as OP_Affinity may be used on the register + ** by code generated below. */ + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) + rLhs = _exprCodeVector(tls, pParse, pLeft, bp+4) + libc.SetBitFieldPtr16Uint32(pParse+40, uint32(okConstFactor), 7, 0x80) + /* If sqlite3FindInIndex() did not find or create an index that is + ** suitable for evaluating the IN operator, then evaluate using a + ** sequence of comparisons. + ** + ** This is step (1) in the in-operator.md optimized algorithm. + */ + if eType == int32(IN_INDEX_NOOP) { + labelOk = _sqlite3VdbeMakeLabel(tls, pParse) + regCkNull = 0 + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + pColl = _sqlite3ExprCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if destIfNull != destIfFalse { + regCkNull = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_BitAnd), rLhs, rLhs, regCkNull) + } + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + r2 = _sqlite3ExprCodeTemp(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr, bp+12) + if regCkNull != 0 && _sqlite3ExprCanBeNull(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr) != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_BitAnd), regCkNull, r2, regCkNull) + } + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp + 12))) + if ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr-int32(1) || destIfNull != destIfFalse { + if rLhs != r2 { + v3 = int32(OP_Eq) + } else { + v3 = int32(OP_NotNull) + } + op = v3 + _sqlite3VdbeAddOp4(tls, v, op, rLhs, labelOk, r2, pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt8(**(**int8)(__ccgo_up(zAff)))) + } else { + if rLhs != r2 { + v3 = int32(OP_Ne) + } else { + v3 = int32(OP_IsNull) + } + op1 = v3 + _sqlite3VdbeAddOp4(tls, v, op1, rLhs, destIfFalse, r2, pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(int32(**(**int8)(__ccgo_up(zAff)))|int32(SQLITE_JUMPIFNULL))) + } + goto _2 + _2: + ; + ii = ii + 1 + } + if regCkNull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regCkNull, destIfNull) + _sqlite3VdbeGoto(tls, v, destIfFalse) + } + _sqlite3VdbeResolveLabel(tls, v, labelOk) + _sqlite3ReleaseTempReg(tls, pParse, regCkNull) + goto sqlite3ExprCodeIN_finished + } + if eType != int32(IN_INDEX_ROWID) { + /* If this IN operator will use an index, then the order of columns in the + ** vector might be different from the order in the index. In that case, + ** we need to reorder the LHS values to be in index order. Run Affinity + ** before reordering the columns, so that the affinity is correct. + */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), rLhs, nVector, 0, zAff, nVector) + i = 0 + for { + if !(i < nVector && **(**int32)(__ccgo_up(aiMap + uintptr(i)*4)) == i) { + break + } + goto _5 + _5: + ; + i = i + 1 + } /* Are LHS fields reordered? */ + if i != nVector { + /* Need to reorder the LHS fields according to aiMap */ + rLhsOrig = rLhs + rLhs = _sqlite3GetTempRange(tls, pParse, nVector) + i = 0 + for { + if !(i < nVector) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), rLhsOrig+i, rLhs+**(**int32)(__ccgo_up(aiMap + uintptr(i)*4)), 0) + goto _6 + _6: + ; + i = i + 1 + } + _sqlite3ReleaseTempReg(tls, pParse, rLhsOrig) + } + } + /* Step 2: Check to see if the LHS contains any NULL columns. If the + ** LHS does contain NULLs then the result must be either FALSE or NULL. + ** We will then skip the binary search of the RHS. + */ + if destIfNull == destIfFalse { + destStep2 = destIfFalse + } else { + v3 = _sqlite3VdbeMakeLabel(tls, pParse) + destStep6 = v3 + destStep2 = v3 + } + i = 0 + for { + if !(i < nVector) { + break + } + p = _sqlite3VectorFieldSubexpr(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, i) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto sqlite3ExprCodeIN_oom_error + } + if _sqlite3ExprCanBeNull(tls, p) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), rLhs+i, destStep2) + } + goto _8 + _8: + ; + i = i + 1 + } + /* Step 3. The LHS is now known to be non-NULL. Do the binary search + ** of the RHS using the LHS as a probe. If found, the result is + ** true. + */ + if eType == int32(IN_INDEX_ROWID) { + /* In this case, the RHS is the ROWID of table b-tree and so we also + ** know that the RHS is non-NULL. Hence, we combine steps 3 and 4 + ** into a single opcode. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), **(**int32)(__ccgo_up(bp + 8)), destIfFalse, rLhs) + addrTruthOp = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) /* Return True */ + } else { + if destIfFalse == destIfNull { + /* Combine Step 3 and Step 5 into a single opcode */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) != uint32(0) { + pOp = _sqlite3VdbeGetOp(tls, v, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr) + if (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 > 0 { /* tag-202407032019 */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Filter), (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3, destIfFalse, rLhs, nVector) + } + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), **(**int32)(__ccgo_up(bp + 8)), destIfFalse, rLhs, nVector) + goto sqlite3ExprCodeIN_finished + } + /* Ordinary Step 3, for the case where FALSE and NULL are distinct */ + addrTruthOp = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), **(**int32)(__ccgo_up(bp + 8)), 0, rLhs, nVector) + } + /* Step 4. If the RHS is known to be non-NULL and we did not find + ** an match on the search above, then the result must be FALSE. + */ + if **(**int32)(__ccgo_up(bp)) != 0 && nVector == int32(1) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), **(**int32)(__ccgo_up(bp)), destIfFalse) + } + /* Step 5. If we do not care about the difference between NULL and + ** FALSE, then just return false. + */ + if destIfFalse == destIfNull { + _sqlite3VdbeGoto(tls, v, destIfFalse) + } + /* Step 6: Loop through rows of the RHS. Compare each row to the LHS. + ** If any comparison is NULL, then the result is NULL. If all + ** comparisons are FALSE then the final result is FALSE. + ** + ** For a scalar LHS, it is sufficient to check just the first row + ** of the RHS. + */ + if destStep6 != 0 { + _sqlite3VdbeResolveLabel(tls, v, destStep6) + } + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), **(**int32)(__ccgo_up(bp + 8)), destIfFalse) + if nVector > int32(1) { + destNotNull = _sqlite3VdbeMakeLabel(tls, pParse) + } else { + /* For nVector==1, combine steps 6 and 7 by immediately returning + ** FALSE if the first comparison is not NULL */ + destNotNull = destIfFalse + } + i = 0 + for { + if !(i < nVector) { + break + } + r3 = _sqlite3GetTempReg(tls, pParse) + p1 = _sqlite3VectorFieldSubexpr(tls, pLeft, i) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + pRhs = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList + 8 + uintptr(i)*32))).FpExpr + pColl1 = _sqlite3BinaryCompareCollSeq(tls, pParse, p1, pRhs) + } else { + /* If the RHS of the IN(...) expression are scalar expressions, do + ** not consider their collation sequences. The documentation says + ** "The collating sequence used for expressions of the form "x IN (y, z, + ** ...)" is the collating sequence of x.". */ + pColl1 = _sqlite3ExprCollSeq(tls, pParse, p1) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 8)), i, r3) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Ne), rLhs+i, destNotNull, r3, pColl1, -int32(2)) + _sqlite3ReleaseTempReg(tls, pParse, r3) + goto _9 + _9: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, destIfNull) + if nVector > int32(1) { + _sqlite3VdbeResolveLabel(tls, v, destNotNull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 8)), addrTop+int32(1)) + /* Step 7: If we reach this point, we know that the result must + ** be false. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, destIfFalse) + } + /* Jumps here in order to return true. */ + _sqlite3VdbeJumpHere(tls, v, addrTruthOp) + goto sqlite3ExprCodeIN_finished +sqlite3ExprCodeIN_finished: + ; + goto sqlite3ExprCodeIN_oom_error +sqlite3ExprCodeIN_oom_error: + ; + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, aiMap) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zAff) +} + +// C documentation +// +// /* +// ** Return the collation sequence for the expression pExpr. If +// ** there is no defined collating sequence, return NULL. +// ** +// ** See also: sqlite3ExprNNCollSeq() +// ** +// ** The sqlite3ExprNNCollSeq() works the same exact that it returns the +// ** default collation if pExpr has no defined collation. +// ** +// ** The collating sequence might be determined by a COLLATE operator +// ** or by the presence of a column with a defined collating sequence. +// ** COLLATE operators take first precedence. Left operands take +// ** precedence over right operands. +// */ +func _sqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r uintptr) { + var db, p, pColl, pNext, zColl uintptr + var i, j, op, v1 int32 + _, _, _, _, _, _, _, _, _ = db, i, j, op, p, pColl, pNext, zColl, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pColl = uintptr(0) + p = pExpr + for p != 0 { + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) + if op == int32(TK_REGISTER) { + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop2) + } + if op == int32(TK_AGG_COLUMN) && *(*uintptr)(unsafe.Pointer(p + 64)) != uintptr(0) || op == int32(TK_COLUMN) || op == int32(TK_TRIGGER) { + v1 = int32((*TExpr)(unsafe.Pointer(p)).FiColumn) + j = v1 + if v1 >= 0 { + zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FaCol+uintptr(j)*16) + pColl = _sqlite3FindCollSeq(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, zColl, 0) + } + break + } + if op == int32(TK_CAST) || op == int32(TK_UPLUS) { + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + continue + } + if op == int32(TK_VECTOR) || op == int32(TK_FUNCTION) && int32((*TExpr)(unsafe.Pointer(p)).FaffExpr) == int32(SQLITE_AFF_DEFER) { + p = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)) + 8))).FpExpr + continue + } + if op == int32(TK_COLLATE) { + pColl = _sqlite3GetCollSeq(tls, pParse, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, uintptr(0), *(*uintptr)(unsafe.Pointer(p + 8))) + break + } + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_Collate) != 0 { + if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 && (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(p)).FpLeft)).Fflags&uint32(EP_Collate) != uint32(0) { + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + } else { + pNext = (*TExpr)(unsafe.Pointer(p)).FpRight + /* The Expr.x union is never used at the same time as Expr.pRight */ + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) == uint32(0) && *(*uintptr)(unsafe.Pointer(p + 32)) != uintptr(0) && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)))).FnExpr) { + break + } + if (*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)) + 8 + uintptr(i)*32))).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != uint32(0) { + pNext = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)) + 8 + uintptr(i)*32))).FpExpr + break + } + goto _2 + _2: + ; + i = i + 1 + } + } + p = pNext + } + } else { + break + } + } + if _sqlite3CheckCollSeq(tls, pParse, pColl) != 0 { + pColl = uintptr(0) + } + return pColl +} + +// C documentation +// +// /* +// ** Make a guess at all the possible datatypes of the result that could +// ** be returned by an expression. Return a bitmask indicating the answer: +// ** +// ** 0x01 Numeric +// ** 0x02 Text +// ** 0x04 Blob +// ** +// ** If the expression must return NULL, then 0x00 is returned. +// */ +func _sqlite3ExprDataType(tls *libc.TLS, pExpr uintptr) (r int32) { + var aff, ii, res int32 + var pList uintptr + _, _, _, _ = aff, ii, pList, res + for pExpr != 0 { + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + case int32(TK_COLLATE): + fallthrough + case int32(TK_IF_NULL_ROW): + fallthrough + case int32(TK_UPLUS): + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + case int32(TK_NULL): + pExpr = uintptr(0) + case int32(TK_STRING): + return int32(0x02) + case int32(TK_BLOB): + return int32(0x04) + case int32(TK_CONCAT): + return int32(0x06) + case int32(TK_VARIABLE): + fallthrough + case int32(TK_AGG_FUNCTION): + fallthrough + case int32(TK_FUNCTION): + return int32(0x07) + case int32(TK_COLUMN): + fallthrough + case int32(TK_AGG_COLUMN): + fallthrough + case int32(TK_SELECT): + fallthrough + case int32(TK_CAST): + fallthrough + case int32(TK_SELECT_COLUMN): + fallthrough + case int32(TK_VECTOR): + aff = int32(_sqlite3ExprAffinity(tls, pExpr)) + if aff >= int32(SQLITE_AFF_NUMERIC) { + return int32(0x05) + } + if aff == int32(SQLITE_AFF_TEXT) { + return int32(0x06) + } + return int32(0x07) + case int32(TK_CASE): + res = 0 + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + ii = int32(1) + for { + if !(ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + res = res | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr) + goto _1 + _1: + ; + ii = ii + int32(2) + } + if (*TExprList)(unsafe.Pointer(pList)).FnExpr%int32(2) != 0 { + res = res | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr((*TExprList)(unsafe.Pointer(pList)).FnExpr-int32(1))*32))).FpExpr) + } + return res + default: + return int32(0x01) + } /* End of switch(op) */ + } /* End of while(pExpr) */ + return 0x00 +} + +// C documentation +// +// /* +// ** Return true if the expression is one of the following: +// ** +// ** CASE WHEN x THEN y END +// ** CASE WHEN x THEN y ELSE NULL END +// ** CASE WHEN x THEN y ELSE false END +// ** iif(x,y) +// ** iif(x,y,NULL) +// ** iif(x,y,false) +// */ +func _sqlite3ExprIsIIF(tls *libc.TLS, db uintptr, pExpr uintptr) (r int32) { + var pDef, pList, z uintptr + _, _, _ = pDef, pList, z + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_FUNCTION) { + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + if int32(**(**int8)(__ccgo_up(z))) != int32('i') && int32(**(**int8)(__ccgo_up(z))) != int32('I') { + return 0 + } + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) == uintptr(0) { + return 0 + } + pDef = _sqlite3FindFunction(tls, db, z, (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, uint8(0)) + if pDef == uintptr(0) { + return 0 + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INLINE) == uint32(0) { + return 0 + } + if int32(int64((*TFuncDef)(unsafe.Pointer(pDef)).FpUserData)) != int32(INLINEFUNC_iif) { + return 0 + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_CASE) { + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != uintptr(0) { + return 0 + } + } else { + return 0 + } + } + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if (*TExprList)(unsafe.Pointer(pList)).FnExpr == int32(2) { + return int32(1) + } + if (*TExprList)(unsafe.Pointer(pList)).FnExpr == int32(3) && _sqlite3ExprIsNotTrue(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 2*32))).FpExpr) != 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** This function is only called when using the special 'trigram' tokenizer. +// ** Argument zText contains the text of a LIKE or GLOB pattern matched +// ** against column iCol. This function creates and compiles an FTS5 MATCH +// ** expression that will match a superset of the rows matched by the LIKE or +// ** GLOB. If successful, SQLITE_OK is returned. Otherwise, an SQLite error +// ** code. +// */ +func _sqlite3Fts5ExprPattern(tls *libc.TLS, pConfig uintptr, bGlob int32, iCol int32, zText uintptr, pp uintptr) (r int32) { + var aSpec [3]int8 + var bAnd, i, iFirst, iOut, jj, rc, v1 int32 + var nText Ti64 + var zExpr uintptr + _, _, _, _, _, _, _, _, _, _ = aSpec, bAnd, i, iFirst, iOut, jj, nText, rc, zExpr, v1 + nText = libc.Int64FromUint64(libc.Xstrlen(tls, zText)) + zExpr = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nText*int64(4)+int64(1))) + rc = SQLITE_OK + if zExpr == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + iOut = 0 + i = 0 + iFirst = 0 + if bGlob == 0 { + aSpec[0] = int8('_') + aSpec[int32(1)] = int8('%') + aSpec[int32(2)] = 0 + } else { + aSpec[0] = int8('*') + aSpec[int32(1)] = int8('?') + aSpec[int32(2)] = int8('[') + } + for int64(i) <= nText { + if int64(i) == nText || int32(**(**int8)(__ccgo_up(zText + uintptr(i)))) == int32(aSpec[0]) || int32(**(**int8)(__ccgo_up(zText + uintptr(i)))) == int32(aSpec[int32(1)]) || int32(**(**int8)(__ccgo_up(zText + uintptr(i)))) == int32(aSpec[int32(2)]) { + if _fts5ExprCountChar(tls, zText+uintptr(iFirst), i-iFirst) >= int32(3) { + v1 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zExpr + uintptr(v1))) = int8('"') + jj = iFirst + for { + if !(jj < i) { + break + } + v1 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zExpr + uintptr(v1))) = **(**int8)(__ccgo_up(zText + uintptr(jj))) + if int32(**(**int8)(__ccgo_up(zText + uintptr(jj)))) == int32('"') { + v1 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zExpr + uintptr(v1))) = int8('"') + } + goto _2 + _2: + ; + jj = jj + 1 + } + v1 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zExpr + uintptr(v1))) = int8('"') + v1 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zExpr + uintptr(v1))) = int8(' ') + } + if int32(**(**int8)(__ccgo_up(zText + uintptr(i)))) == int32(aSpec[int32(2)]) { + i = i + int32(2) + if int32(**(**int8)(__ccgo_up(zText + uintptr(i-int32(1))))) == int32('^') { + i = i + 1 + } + for int64(i) < nText && int32(**(**int8)(__ccgo_up(zText + uintptr(i)))) != int32(']') { + i = i + 1 + } + } + iFirst = i + int32(1) + } + i = i + 1 + } + if iOut > 0 { + bAnd = 0 + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail != FTS5_DETAIL_FULL { + bAnd = int32(1) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + iCol = (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + } + } + **(**int8)(__ccgo_up(zExpr + uintptr(iOut))) = int8('\000') + rc = _sqlite3Fts5ExprNew(tls, pConfig, bAnd, iCol, zExpr, pp, (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg) + } else { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + Xsqlite3_free(tls, zExpr) + } + return rc +} + +// C documentation +// +// /* +// ** Return true if pTab is a virtual table and zName is a shadow table name +// ** for that virtual table. +// */ +func _sqlite3IsShadowTableOf(tls *libc.TLS, db uintptr, pTab uintptr, zName uintptr) (r int32) { + var nName int32 + var pMod uintptr + _, _ = nName, pMod /* Module for the virtual table */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + return 0 + } + nName = _sqlite3Strlen30(tls, (*TTable)(unsafe.Pointer(pTab)).FzName) + if Xsqlite3_strnicmp(tls, zName, (*TTable)(unsafe.Pointer(pTab)).FzName, nName) != 0 { + return 0 + } + if int32(**(**int8)(__ccgo_up(zName + uintptr(nName)))) != int32('_') { + return 0 + } + pMod = _sqlite3HashFind(tls, db+576, **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg))) + if pMod == uintptr(0) { + return 0 + } + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FiVersion < int32(3) { + return 0 + } + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxShadowName == uintptr(0) { + return 0 + } + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxShadowName})))(tls, zName+uintptr(nName)+uintptr(1)) +} + +// C documentation +// +// /* +// ** Table pTab is a virtual table. If it the virtual table implementation +// ** exists and has an xShadowName method, then loop over all other ordinary +// ** tables within the same schema looking for shadow tables of pTab, and mark +// ** any shadow tables seen using the TF_Shadow flag. +// */ +func _sqlite3MarkAllShadowTablesOf(tls *libc.TLS, db uintptr, pTab uintptr) { + var k, pMod, pOther uintptr + var nName int32 + _, _, _, _ = k, nName, pMod, pOther /* For looping through the symbol table */ + pMod = _sqlite3HashFind(tls, db+576, **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg))) + if pMod == uintptr(0) { + return + } + if (*TModule)(unsafe.Pointer(pMod)).FpModule == uintptr(0) { + return + } + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FiVersion < int32(3) { + return + } + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxShadowName == uintptr(0) { + return + } + nName = _sqlite3Strlen30(tls, (*TTable)(unsafe.Pointer(pTab)).FzName) + k = (*THash)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FpSchema + 8)).Ffirst + for { + if !(k != 0) { + break + } + pOther = (*THashElem)(unsafe.Pointer(k)).Fdata + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pOther)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + goto _1 + } + if (*TTable)(unsafe.Pointer(pOther)).FtabFlags&uint32(TF_Shadow) != 0 { + goto _1 + } + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pOther)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, nName) == 0 && int32(**(**int8)(__ccgo_up((*TTable)(unsafe.Pointer(pOther)).FzName + uintptr(nName)))) == int32('_') && (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxShadowName})))(tls, (*TTable)(unsafe.Pointer(pOther)).FzName+uintptr(nName)+uintptr(1)) != 0 { + **(**Tu32)(__ccgo_up(pOther + 48)) |= uint32(TF_Shadow) + } + goto _1 + _1: + ; + k = (*THashElem)(unsafe.Pointer(k)).Fnext + } +} + +// C documentation +// +// /* +// ** This function is used to allocate and populate UnpackedRecord +// ** structures intended to be compared against sample index keys stored +// ** in the sqlite_stat4 table. +// ** +// ** A single call to this function populates zero or more fields of the +// ** record starting with field iVal (fields are numbered from left to +// ** right starting with 0). A single field is populated if: +// ** +// ** * (pExpr==0). In this case the value is assumed to be an SQL NULL, +// ** +// ** * The expression is a bound variable, and this is a reprepare, or +// ** +// ** * The sqlite3ValueFromExpr() function is able to extract a value +// ** from the expression (i.e. the expression is a literal value). +// ** +// ** Or, if pExpr is a TK_VECTOR, one field is populated for each of the +// ** vector components that match either of the two latter criteria listed +// ** above. +// ** +// ** Before any value is appended to the record, the affinity of the +// ** corresponding column within index pIdx is applied to it. Before +// ** this function returns, output parameter *pnExtract is set to the +// ** number of values appended to the record. +// ** +// ** When this function is called, *ppRec must either point to an object +// ** allocated by an earlier call to this function, or must be NULL. If it +// ** is NULL and a value can be successfully extracted, a new UnpackedRecord +// ** is allocated (and *ppRec set to point to it) before returning. +// ** +// ** Unless an error is encountered, SQLITE_OK is returned. It is not an +// ** error if a value cannot be extracted from pExpr. If an error does +// ** occur, an SQLite error code is returned. +// */ +func _sqlite3Stat4ProbeSetValue(tls *libc.TLS, pParse uintptr, pIdx uintptr, ppRec uintptr, pExpr uintptr, nElem int32, iVal int32, pnExtract uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aff Tu8 + var i, nExtract, rc int32 + var pElem, v2 uintptr + var _ /* alloc at bp+0 */ TValueNewStat4Ctx + var _ /* pVal at bp+32 */ uintptr + _, _, _, _, _, _ = aff, i, nExtract, pElem, rc, v2 + rc = SQLITE_OK + nExtract = 0 + if pExpr == uintptr(0) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_SELECT) { + (**(**TValueNewStat4Ctx)(__ccgo_up(bp))).FpParse = pParse + (**(**TValueNewStat4Ctx)(__ccgo_up(bp))).FpIdx = pIdx + (**(**TValueNewStat4Ctx)(__ccgo_up(bp))).FppRec = ppRec + i = 0 + for { + if !(i < nElem) { + break + } + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + if pExpr != 0 { + v2 = _sqlite3VectorFieldSubexpr(tls, pExpr, i) + } else { + v2 = uintptr(0) + } + pElem = v2 + aff = libc.Uint8FromInt8(_sqlite3IndexColumnAffinity(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pIdx, iVal+i)) + (**(**TValueNewStat4Ctx)(__ccgo_up(bp))).FiVal = iVal + i + rc = _stat4ValueFromExpr(tls, pParse, pElem, aff, bp, bp+32) + if !(**(**uintptr)(__ccgo_up(bp + 32)) != 0) { + break + } + nExtract = nExtract + 1 + goto _1 + _1: + ; + i = i + 1 + } + } + **(**int32)(__ccgo_up(pnExtract)) = nExtract + return rc +} + +// C documentation +// +// /* +// ** Compute an affinity string for a table. Space is obtained +// ** from sqlite3DbMalloc(). The caller is responsible for freeing +// ** the space when done. +// */ +func _sqlite3TableAffinityStr(tls *libc.TLS, db uintptr, pTab uintptr) (r uintptr) { + var i, j, v2, v3 int32 + var zColAff uintptr + _, _, _, _, _ = i, j, zColAff, v2, v3 + zColAff = _sqlite3DbMallocRaw(tls, db, libc.Uint64FromInt32(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1))) + if zColAff != 0 { + v2 = libc.Int32FromInt32(0) + j = v2 + i = v2 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + v3 = j + j = j + 1 + **(**int8)(__ccgo_up(zColAff + uintptr(v3))) = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity + } + goto _1 + _1: + ; + i = i + 1 + } + for cond := true; cond; cond = j >= 0 && int32(**(**int8)(__ccgo_up(zColAff + uintptr(j)))) <= int32(SQLITE_AFF_BLOB) { + v2 = j + j = j - 1 + **(**int8)(__ccgo_up(zColAff + uintptr(v2))) = 0 + } + } + return zColAff +} + +// C documentation +// +// /* +// ** Return the number of the variable named zName, if it is in VList. +// ** or return 0 if there is no such variable. +// */ +func _sqlite3VListNameToNum(tls *libc.TLS, pIn uintptr, zName uintptr, nName int32) (r int32) { + var i, mx int32 + var z uintptr + _, _, _ = i, mx, z + if pIn == uintptr(0) { + return 0 + } + mx = **(**TVList)(__ccgo_up(pIn + 1*4)) + i = int32(2) + for cond := true; cond; cond = i < mx { + z = pIn + uintptr(i+int32(2))*4 + if libc.Xstrncmp(tls, z, zName, libc.Uint64FromInt32(nName)) == 0 && int32(**(**int8)(__ccgo_up(z + uintptr(nName)))) == 0 { + return **(**TVList)(__ccgo_up(pIn + uintptr(i)*4)) + } + i = i + **(**TVList)(__ccgo_up(pIn + uintptr(i+int32(1))*4)) + } + return 0 +} + +/************** End of util.c ************************************************/ +/************** Begin file hash.c ********************************************/ +/* +** 2001 September 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This is the implementation of generic hash-tables +** used in SQLite. + */ +/* #include "sqliteInt.h" */ +/* #include */ + +// C documentation +// +// /* +// ** Print into memory obtained from sqliteMalloc(). Use the internal +// ** %-conversion extensions. +// */ +func _sqlite3VMPrintf(tls *libc.TLS, db uintptr, zFormat uintptr, ap Tva_list) (r uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var z uintptr + var _ /* acc at bp+72 */ TStrAccum + var _ /* zBase at bp+0 */ [70]int8 + _ = z + _sqlite3StrAccumInit(tls, bp+72, db, bp, int32(70), **(**int32)(__ccgo_up(db + 136))) + (**(**TStrAccum)(__ccgo_up(bp + 72))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + Xsqlite3_str_vappendf(tls, bp+72, zFormat, ap) + z = _sqlite3StrAccumFinish(tls, bp+72) + if libc.Int32FromUint8((**(**TStrAccum)(__ccgo_up(bp + 72))).FaccError) == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + return z +} + +// C documentation +// +// /* +// ** If pMem is already a string, detect if it is a zero-terminated +// ** string, or make it into one if possible, and mark it as such. +// ** +// ** This is an optimization. Correct operation continues even if +// ** this routine is a no-op. +// ** +// ** Return true if the strig is zero-terminated after this routine is +// ** called and false if it is not. +// */ +func _sqlite3VdbeMemZeroTerminateIfAble(tls *libc.TLS, pMem uintptr) (r int32) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Term)|libc.Int32FromInt32(MEM_Ephem)|libc.Int32FromInt32(MEM_Static)) != int32(MEM_Str) { + /* pMem must be a string, and it cannot be an ephemeral or static string */ + return 0 + } + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) != int32(SQLITE_UTF8) { + return 0 + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Dyn) != 0 { + if (*TMem)(unsafe.Pointer(pMem)).FxDel == __ccgo_fp(Xsqlite3_free) && Xsqlite3_msize(tls, (*TMem)(unsafe.Pointer(pMem)).Fz) >= libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn+libc.Int32FromInt32(1)) { + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = 0 + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + return int32(1) + } + if (*TMem)(unsafe.Pointer(pMem)).FxDel == __ccgo_fp(_sqlite3RCStrUnref) { + /* Blindly assume that all RCStr objects are zero-terminated */ + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + return int32(1) + } + } else { + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc >= (*TMem)(unsafe.Pointer(pMem)).Fn+int32(1) { + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = 0 + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** This is called by code in select.c before it calls sqlite3WhereBegin() +// ** to begin iterating through the sub-query results. It is used to allocate +// ** and initialize registers and cursors used by sqlite3WindowCodeStep(). +// */ +func _sqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) { + var nEphExpr, nExpr, v1 int32 + var p, pKeyInfo, pList, pMWin, pWin, v, v2 uintptr + _, _, _, _, _, _, _, _, _, _ = nEphExpr, nExpr, p, pKeyInfo, pList, pMWin, pWin, v, v1, v2 + nEphExpr = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + 72)))).FpSelect)).FpEList)).FnExpr + pMWin = (*TSelect)(unsafe.Pointer(pSelect)).FpWin + v = _sqlite3GetVdbe(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr, nEphExpr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr+int32(1), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr+int32(2), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr+int32(3), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + /* Allocate registers to use for PARTITION BY values, if any. Initialize + ** said registers to NULL. */ + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + nExpr = (*TExprList)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pMWin)).FpPartition)).FnExpr + (*TWindow)(unsafe.Pointer(pMWin)).FregPart = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nExpr + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pMWin)).FregPart, (*TWindow)(unsafe.Pointer(pMWin)).FregPart+nExpr-int32(1)) + } + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pMWin)).FregOne = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TWindow)(unsafe.Pointer(pMWin)).FregOne) + if (*TWindow)(unsafe.Pointer(pMWin)).FeExclude != 0 { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid = v1 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pMWin)).FregEndRowid = v1 + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pMWin)).FcsrApp = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pMWin)).FregEndRowid) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pMWin)).FcsrApp, (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + return + } + pWin = pMWin + for { + if !(pWin != 0) { + break + } + p = (*TWindow)(unsafe.Pointer(pWin)).FpWFunc + if (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_MINMAX) != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeStart) != int32(TK_UNBOUNDED) { + pList = *(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)) + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, pList, 0, 0) + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pWin)).FcsrApp = v1 + (*TWindow)(unsafe.Pointer(pWin)).FregApp = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(3) + if pKeyInfo != 0 && int32(**(**int8)(__ccgo_up((*TFuncDef)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpWFunc)).FzName + 1))) == int32('i') { + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags)) = uint8(KEYINFO_ORDER_DESC) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, int32(2)) + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(1)) + } else { + if (*TFuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&_nth_valueName)) || (*TFuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&_first_valueName)) { + /* Allocate two registers at pWin->regApp. These will be used to + ** store the start and end index of the current frame. */ + (*TWindow)(unsafe.Pointer(pWin)).FregApp = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pWin)).FcsrApp = v1 + **(**int32)(__ccgo_up(pParse + 60)) += int32(2) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + } else { + if (*TFuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&_leadName)) || (*TFuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&_lagName)) { + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pWin)).FcsrApp = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + } + } + } + goto _9 + _9: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } +} + +// C documentation +// +// /* +// ** Return TRUE if the WHERE clause term pTerm is of a form where it +// ** could be used with an index to access pSrc, assuming an appropriate +// ** index existed. +// */ +func _termCanDriveIndex(tls *libc.TLS, pTerm uintptr, pSrc uintptr, notReady TBitmask) (r int32) { + var aff int8 + var leftCol int32 + _, _ = aff, leftCol + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { + return 0 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) == 0 { + return 0 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 && !(_constraintCompatibleWithOuterJoin(tls, pTerm, pSrc) != 0) { + return 0 /* See https://sqlite.org/forum/forumpost/51e6959f61 */ + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight¬Ready != uint64(0) { + return 0 + } + leftCol = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn + if leftCol < 0 { + return 0 + } + aff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FaCol + uintptr(leftCol)*16))).Faffinity + if !(_sqlite3IndexAffinityOk(tls, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, aff) != 0) { + return 0 + } + return _columnIsGoodIndexCandidate(tls, (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab, leftCol) +} + +// C documentation +// +// /* +// ** For OP_Column, factor out the case where content is loaded from +// ** overflow pages, so that the code to implement this case is separate +// ** the common case where all content fits on the page. Factoring out +// ** the code reduces register pressure and helps the common case +// ** to run faster. +// */ +func _vdbeColumnFromOverflow(tls *libc.TLS, pC uintptr, iCol int32, t Tu32, iOffset Ti64, cacheStatus Tu32, colCacheCtr Tu32, pDest uintptr) (r int32) { + var db, pBuf, pCache, v1 uintptr + var encoding, len1, rc int32 + _, _, _, _, _, _, _ = db, encoding, len1, pBuf, pCache, rc, v1 + db = (*TMem)(unsafe.Pointer(pDest)).Fdb + encoding = libc.Int32FromUint8((*TMem)(unsafe.Pointer(pDest)).Fenc) + len1 = libc.Int32FromUint32(_sqlite3VdbeSerialTypeLen(tls, t)) + if len1 > **(**int32)(__ccgo_up(db + 136)) { + return int32(SQLITE_TOOBIG) + } + if len1 > int32(4000) && (*TVdbeCursor)(unsafe.Pointer(pC)).FpKeyInfo == uintptr(0) { + if int32(TBool(*(*uint8)(unsafe.Pointer(pC + 8))&0x10>>4)) == 0 { + (*TVdbeCursor)(unsafe.Pointer(pC)).FpCache = _sqlite3DbMallocZero(tls, db, uint64(32)) + if (*TVdbeCursor)(unsafe.Pointer(pC)).FpCache == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.SetBitFieldPtr8Uint32(pC+8, libc.Uint32FromInt32(1), 4, 0x10) + } + pCache = (*TVdbeCursor)(unsafe.Pointer(pC)).FpCache + if (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue == uintptr(0) || (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FiCol != iCol || (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FcacheStatus != cacheStatus || (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FcolCacheCtr != colCacheCtr || (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FiOffset != _sqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC + 48))) { + if (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue != 0 { + _sqlite3RCStrUnref(tls, (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue) + } + v1 = _sqlite3RCStrNew(tls, libc.Uint64FromInt32(len1+int32(3))) + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue = v1 + pBuf = v1 + if pBuf == uintptr(0) { + return int32(SQLITE_NOMEM) + } + rc = _sqlite3BtreePayload(tls, *(*uintptr)(unsafe.Pointer(pC + 48)), libc.Uint32FromInt64(iOffset), libc.Uint32FromInt32(len1), pBuf) + if rc != 0 { + return rc + } + **(**int8)(__ccgo_up(pBuf + uintptr(len1))) = 0 + **(**int8)(__ccgo_up(pBuf + uintptr(len1+int32(1)))) = 0 + **(**int8)(__ccgo_up(pBuf + uintptr(len1+int32(2)))) = 0 + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FiCol = iCol + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FcacheStatus = cacheStatus + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FcolCacheCtr = colCacheCtr + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FiOffset = _sqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC + 48))) + } else { + pBuf = (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue + } + _sqlite3RCStrRef(tls, pBuf) + if t&uint32(1) != 0 { + rc = _sqlite3VdbeMemSetStr(tls, pDest, pBuf, int64(len1), libc.Uint8FromInt32(encoding), __ccgo_fp(_sqlite3RCStrUnref)) + v1 = pDest + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + } else { + rc = _sqlite3VdbeMemSetStr(tls, pDest, pBuf, int64(len1), uint8(0), __ccgo_fp(_sqlite3RCStrUnref)) + } + } else { + rc = _sqlite3VdbeMemFromBtree(tls, *(*uintptr)(unsafe.Pointer(pC + 48)), libc.Uint32FromInt64(iOffset), libc.Uint32FromInt32(len1), pDest) + if rc != 0 { + return rc + } + _sqlite3VdbeSerialGet(tls, (*TMem)(unsafe.Pointer(pDest)).Fz, t, pDest) + if t&uint32(1) != uint32(0) && encoding == int32(SQLITE_UTF8) { + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1))) = 0 + v1 = pDest + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + } + } + v1 = pDest + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Ephem)) + return rc +} + +// C documentation +// +// /* +// ** The index pIdx is used by a query and contains one or more expressions. +// ** In other words pIdx is an index on an expression. iIdxCur is the cursor +// ** number for the index and iDataCur is the cursor number for the corresponding +// ** table. +// ** +// ** This routine adds IndexedExpr entries to the Parse->pIdxEpr field for +// ** each of the expressions in the index so that the expression code generator +// ** will know to replace occurrences of the indexed expression with +// ** references to the corresponding column of the index. +// */ +func _whereAddIndexedExpr(tls *libc.TLS, pParse uintptr, pIdx uintptr, iIdxCur int32, pTabItem uintptr) { + var i, j int32 + var p, pArg, pExpr, pTab uintptr + _, _, _, _, _, _ = i, j, p, pArg, pExpr, pTab + pTab = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) { + break + } + j = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) + if j == -int32(2) { + pExpr = (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(i)*32))).FpExpr + } else { + if j >= 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + pExpr = _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16) + } else { + goto _1 + } + } + if _sqlite3ExprIsConstant(tls, uintptr(0), pExpr) != 0 { + goto _1 + } + p = _sqlite3DbMallocRaw(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(32)) + if p == uintptr(0) { + break + } + (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) + (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur = (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur = iIdxCur + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol = i + (*TIndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow = libc.BoolUint8(libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0) + if _sqlite3IndexAffinityStr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pIdx) != 0 { + (*TIndexedExpr)(unsafe.Pointer(p)).Faff = libc.Uint8FromInt8(**(**int8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FzColAff + uintptr(i)))) + } + (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr = p + if (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext == uintptr(0) { + pArg = pParse + 96 + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_whereIndexedExprCleanup), pArg) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** This function is called for a partial index - one with a WHERE clause - in +// ** two scenarios. In both cases, it determines whether or not the WHERE +// ** clause on the index implies that a column of the table may be safely +// ** replaced by a constant expression. For example, in the following +// ** SELECT: +// ** +// ** CREATE INDEX i1 ON t1(b, c) WHERE a=; +// ** SELECT a, b, c FROM t1 WHERE a= AND b=?; +// ** +// ** The "a" in the select-list may be replaced by , iff: +// ** +// ** (a) is a constant expression, and +// ** (b) The (a=) comparison uses the BINARY collation sequence, and +// ** (c) Column "a" has an affinity other than NONE or BLOB. +// ** +// ** If argument pItem is NULL, then pMask must not be NULL. In this case this +// ** function is being called as part of determining whether or not pIdx +// ** is a covering index. This function clears any bits in (*pMask) +// ** corresponding to columns that may be replaced by constants as described +// ** above. +// ** +// ** Otherwise, if pItem is not NULL, then this function is being called +// ** as part of coding a loop that uses index pIdx. In this case, add entries +// ** to the Parse.pIdxPartExpr list for each column that can be replaced +// ** by a constant. +// */ +func _wherePartIdxExpr(tls *libc.TLS, pParse uintptr, pIdx uintptr, pPart uintptr, pMask uintptr, iIdxCur int32, pItem uintptr) { + var aff Tu8 + var bNullRow int32 + var db, p, pArg, pLeft, pRight uintptr + _, _, _, _, _, _, _ = aff, bNullRow, db, p, pArg, pLeft, pRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pPart)).Fop) == int32(TK_AND) { + _wherePartIdxExpr(tls, pParse, pIdx, (*TExpr)(unsafe.Pointer(pPart)).FpRight, pMask, iIdxCur, pItem) + pPart = (*TExpr)(unsafe.Pointer(pPart)).FpLeft + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pPart)).Fop) == int32(TK_EQ) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pPart)).Fop) == int32(TK_IS) { + pLeft = (*TExpr)(unsafe.Pointer(pPart)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pPart)).FpRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) != int32(TK_COLUMN) { + return + } + if !(_sqlite3ExprIsConstant(tls, uintptr(0), pRight) != 0) { + return + } + if !(_sqlite3IsBinary(tls, _sqlite3ExprCompareCollSeq(tls, pParse, pPart)) != 0) { + return + } + if int32((*TExpr)(unsafe.Pointer(pLeft)).FiColumn) < 0 { + return + } + aff = libc.Uint8FromInt8((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pLeft)).FiColumn)*16))).Faffinity) + if libc.Int32FromUint8(aff) >= int32(SQLITE_AFF_TEXT) { + if pItem != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = _sqlite3DbMallocRaw(tls, db, uint64(32)) + if p != 0 { + bNullRow = libc.BoolInt32(libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0) + (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr = _sqlite3ExprDup(tls, db, pRight, 0) + (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur = iIdxCur + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol = int32((*TExpr)(unsafe.Pointer(pLeft)).FiColumn) + (*TIndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow = libc.Uint8FromInt32(bNullRow) + (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext = (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr + (*TIndexedExpr)(unsafe.Pointer(p)).Faff = aff + (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr = p + if (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext == uintptr(0) { + pArg = pParse + 104 + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_whereIndexedExprCleanup), pArg) + } + } + } else { + if int32((*TExpr)(unsafe.Pointer(pLeft)).FiColumn) < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + **(**TBitmask)(__ccgo_up(pMask)) &= ^(libc.Uint64FromInt32(1) << (*TExpr)(unsafe.Pointer(pLeft)).FiColumn) + } + } + } + } +} + +// C documentation +// +// /* +// ** This function is called to estimate the number of rows visited by a +// ** range-scan on a skip-scan index. For example: +// ** +// ** CREATE INDEX i1 ON t1(a, b, c); +// ** SELECT * FROM t1 WHERE a=? AND c BETWEEN ? AND ?; +// ** +// ** Value pLoop->nOut is currently set to the estimated number of rows +// ** visited for scanning (a=? AND b=?). This function reduces that estimate +// ** by some factor to account for the (c BETWEEN ? AND ?) expression based +// ** on the stat4 data for the index. this scan will be performed multiple +// ** times (once for each (a,b) combination that matches a=?) is dealt with +// ** by the caller. +// ** +// ** It does this by scanning through all stat4 samples, comparing values +// ** extracted from pLower and pUpper with the corresponding column in each +// ** sample. If L and U are the number of samples found to be less than or +// ** equal to the values extracted from pLower and pUpper respectively, and +// ** N is the total number of samples, the pLoop->nOut value is adjusted +// ** as follows: +// ** +// ** nOut = nOut * ( min(U - L, 1) / N ) +// ** +// ** If pLower is NULL, or a value cannot be extracted from the term, L is +// ** set to zero. If pUpper is NULL, or a value cannot be extracted from it, +// ** U is set to N. +// ** +// ** Normally, this function sets *pbDone to 1 before returning. However, +// ** if no value can be extracted from either pLower or pUpper (and so the +// ** estimate of the number of rows delivered remains unchanged), *pbDone +// ** is left as is. +// ** +// ** If an error occurs, an SQLite error code is returned. Otherwise, +// ** SQLITE_OK. +// */ +func _whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper uintptr, pLoop uintptr, pbDone uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aff Tu8 + var db, p, pColl, v3 uintptr + var i, nAdjust, nDiff, nEq, nLower, nUpper, rc, res, res1, v1 int32 + var _ /* p1 at bp+0 */ uintptr + var _ /* p2 at bp+8 */ uintptr + var _ /* pVal at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aff, db, i, nAdjust, nDiff, nEq, nLower, nUpper, p, pColl, rc, res, res1, v1, v3 + p = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + nEq = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + nLower = -int32(1) + nUpper = (*TIndex)(unsafe.Pointer(p)).FnSample + int32(1) + rc = SQLITE_OK + aff = libc.Uint8FromInt8(_sqlite3IndexColumnAffinity(tls, db, p, nEq)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Value extracted from pLower */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Value extracted from pUpper */ + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) /* Value extracted from record */ + pColl = _sqlite3LocateCollSeq(tls, pParse, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(p)).FazColl + uintptr(nEq)*8))) + if pLower != 0 { + rc = _sqlite3Stat4ValueFromExpr(tls, pParse, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight, aff, bp) + nLower = 0 + } + if pUpper != 0 && rc == SQLITE_OK { + rc = _sqlite3Stat4ValueFromExpr(tls, pParse, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight, aff, bp+8) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v1 = 0 + } else { + v1 = (*TIndex)(unsafe.Pointer(p)).FnSample + } + nUpper = v1 + } + if **(**uintptr)(__ccgo_up(bp)) != 0 || **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + i = 0 + for { + if !(rc == SQLITE_OK && i < (*TIndex)(unsafe.Pointer(p)).FnSample) { + break + } + rc = _sqlite3Stat4Column(tls, db, (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(p)).FaSample + uintptr(i)*40))).Fp, (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(p)).FaSample + uintptr(i)*40))).Fn, nEq, bp+16) + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp)) != 0 { + res = _sqlite3MemCompare(tls, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 16)), pColl) + if res >= 0 { + nLower = nLower + 1 + } + } + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + res1 = _sqlite3MemCompare(tls, **(**uintptr)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp + 16)), pColl) + if res1 >= 0 { + nUpper = nUpper + 1 + } + } + goto _2 + _2: + ; + i = i + 1 + } + nDiff = nUpper - nLower + if nDiff <= 0 { + nDiff = int32(1) + } + /* If there is both an upper and lower bound specified, and the + ** comparisons indicate that they are close together, use the fallback + ** method (assume that the scan visits 1/64 of the rows) for estimating + ** the number of rows visited. Otherwise, estimate the number of rows + ** using the method described in the header comment for this function. */ + if nDiff != int32(1) || pUpper == uintptr(0) || pLower == uintptr(0) { + nAdjust = int32(_sqlite3LogEst(tls, libc.Uint64FromInt32((*TIndex)(unsafe.Pointer(p)).FnSample))) - int32(_sqlite3LogEst(tls, libc.Uint64FromInt32(nDiff))) + v3 = pLoop + 22 + *(*TLogEst)(unsafe.Pointer(v3)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v3))) - nAdjust) + **(**int32)(__ccgo_up(pbDone)) = int32(1) + } + } else { + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp + 8))) + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp + 16))) + return rc +} + +// C documentation +// +// /* +// ** Term pTerm is a vector range comparison operation. The first comparison +// ** in the vector can be optimized using column nEq of the index. This +// ** function returns the total number of vector elements that can be used +// ** as part of the range comparison. +// ** +// ** For example, if the query is: +// ** +// ** WHERE a = ? AND (b, c, d) > (?, ?, ?) +// ** +// ** and the index: +// ** +// ** CREATE INDEX ... ON (a, b, c, d, e) +// ** +// ** then this function would be invoked with nEq=1. The value returned in +// ** this case is 3. +// */ +func _whereRangeVectorLen(tls *libc.TLS, pParse uintptr, iCur int32, pIdx uintptr, nEq int32, pTerm uintptr) (r int32) { + var aff, idxaff int8 + var i, nCmp, v1 int32 + var pColl, pLhs, pRhs, t uintptr + _, _, _, _, _, _, _, _, _ = aff, i, idxaff, nCmp, pColl, pLhs, pRhs, t, v1 + nCmp = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft) + if nCmp < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)-nEq { + v1 = nCmp + } else { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) - nEq + } + nCmp = v1 + i = int32(1) + for { + if !(i < nCmp) { + break + } /* Comparison affinity */ + idxaff = 0 + pLhs = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft + 32)) + 8 + uintptr(i)*32))).FpExpr + pRhs = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight + if (*TExpr)(unsafe.Pointer(pRhs)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + pRhs = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRhs + 32)))).FpEList + 8 + uintptr(i)*32))).FpExpr + } else { + pRhs = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRhs + 32)) + 8 + uintptr(i)*32))).FpExpr + } + /* Check that the LHS of the comparison is a column reference to + ** the right column of the right source table. And that the sort + ** order of the index column is the same as the sort order of the + ** leftmost index column. */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLhs)).Fop) != int32(TK_COLUMN) || (*TExpr)(unsafe.Pointer(pLhs)).FiTable != iCur || int32((*TExpr)(unsafe.Pointer(pLhs)).FiColumn) != int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i+nEq)*2))) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i+nEq)))) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) { + break + } + aff = _sqlite3CompareAffinity(tls, pRhs, _sqlite3ExprAffinity(tls, pLhs)) + idxaff = _sqlite3TableColumnAffinity(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpTable, int32((*TExpr)(unsafe.Pointer(pLhs)).FiColumn)) + if int32(aff) != int32(idxaff) { + break + } + if (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0) { + t = pRhs + pRhs = pLhs + pLhs = t + } + pColl = _sqlite3BinaryCompareCollSeq(tls, pParse, pLhs, pRhs) + if pColl == uintptr(0) { + break + } + if _sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pColl)).FzName, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i+nEq)*8))) != 0 { + break + } + goto _2 + _2: + ; + i = i + 1 + } + return i +} + +/* +** Adjust the cost C by the costMult factor T. This only occurs if +** compiled with -DSQLITE_ENABLE_COSTMULT + */ + +// C documentation +// +// /* +// ** Advance to the next WhereTerm that matches according to the criteria +// ** established when the pScan object was initialized by whereScanInit(). +// ** Return NULL if there are no more matching WhereTerms. +// */ +func _whereScanNext(tls *libc.TLS, pScan uintptr) (r uintptr) { + var iColumn Ti16 + var iCur, j, k int32 + var pColl, pParse, pTerm, pWC, pX, zCollName, v2 uintptr + var v3 bool + _, _, _, _, _, _, _, _, _, _, _, _ = iColumn, iCur, j, k, pColl, pParse, pTerm, pWC, pX, zCollName, v2, v3 /* The term being tested */ + k = (*TWhereScan)(unsafe.Pointer(pScan)).Fk /* Where to start scanning */ + pWC = (*TWhereScan)(unsafe.Pointer(pScan)).FpWC + for int32(1) != 0 { + iColumn = **(**Ti16)(__ccgo_up(pScan + 88 + uintptr(libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv)-int32(1))*2)) + iCur = **(**int32)(__ccgo_up(pScan + 44 + uintptr(libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv)-int32(1))*4)) + for cond := true; cond; cond = pWC != uintptr(0) { + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(k)*56 + for { + if !(k < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor == iCur && (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn == int32(iColumn) && (int32(iColumn) != -int32(2) || _sqlite3ExprCompareSkip(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft, (*TWhereScan)(unsafe.Pointer(pScan)).FpIdxExpr, iCur) == 0) && (libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv) <= int32(1) || !((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0))) { + if v3 = libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_EQUIV) != 0 && libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv) < libc.Int32FromUint64(libc.Uint64FromInt64(44)/libc.Uint64FromInt64(4)); v3 { + v2 = _whereRightSubexprIsColumn(tls, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr) + pX = v2 + } + if v3 && v2 != uintptr(0) { + j = 0 + for { + if !(j < libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv)) { + break + } + if **(**int32)(__ccgo_up(pScan + 44 + uintptr(j)*4)) == (*TExpr)(unsafe.Pointer(pX)).FiTable && int32(**(**Ti16)(__ccgo_up(pScan + 88 + uintptr(j)*2))) == int32((*TExpr)(unsafe.Pointer(pX)).FiColumn) { + break + } + goto _4 + _4: + ; + j = j + 1 + } + if j == libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv) { + **(**int32)(__ccgo_up(pScan + 44 + uintptr(j)*4)) = (*TExpr)(unsafe.Pointer(pX)).FiTable + **(**Ti16)(__ccgo_up(pScan + 88 + uintptr(j)*2)) = (*TExpr)(unsafe.Pointer(pX)).FiColumn + (*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv = (*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv + 1 + } + } + if uint32((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(*TWhereScan)(unsafe.Pointer(pScan)).FopMask != uint32(0) { + /* Verify the affinity and collating sequence match */ + if (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName != 0 && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_ISNULL) == 0 { + pParse = (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_IN) != 0 { + zCollName = _indexInAffinityOk(tls, pParse, pTerm, libc.Uint8FromInt8((*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff)) + if !(zCollName != 0) { + goto _1 + } + } else { + if !(_sqlite3IndexAffinityOk(tls, pX, (*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff) != 0) { + goto _1 + } + pColl = _sqlite3ExprCompareCollSeq(tls, pParse, pX) + if pColl != 0 { + v2 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v2 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + zCollName = v2 + } + if _sqlite3StrICmp(tls, zCollName, (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName) != 0 { + goto _1 + } + } + if v3 = libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) != 0; v3 { + pX = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight + } + if v3 && pX != libc.UintptrFromInt32(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pX)).FiTable == **(**int32)(__ccgo_up(pScan + 44)) && int32((*TExpr)(unsafe.Pointer(pX)).FiColumn) == int32(**(**Ti16)(__ccgo_up(pScan + 88))) { + goto _1 + } + (*TWhereScan)(unsafe.Pointer(pScan)).FpWC = pWC + (*TWhereScan)(unsafe.Pointer(pScan)).Fk = k + int32(1) + return pTerm + } + } + goto _1 + _1: + ; + k = k + 1 + pTerm += 56 + } + pWC = (*TWhereClause)(unsafe.Pointer(pWC)).FpOuter + k = 0 + } + if libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv) >= libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv) { + break + } + pWC = (*TWhereScan)(unsafe.Pointer(pScan)).FpOrigWC + k = 0 + (*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv = (*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv + 1 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Write the supplied super-journal name into the journal file for pager +// ** pPager at the current location. The super-journal name must be the last +// ** thing written to a journal file. If the pager is in full-sync mode, the +// ** journal file descriptor is advanced to the next sector boundary before +// ** anything is written. The format is: +// ** +// ** + 4 bytes: PAGER_SJ_PGNO. +// ** + N bytes: super-journal filename in utf-8. +// ** + 4 bytes: N (length of super-journal name in bytes, no nul-terminator). +// ** + 4 bytes: super-journal name checksum. +// ** + 8 bytes: aJournalMagic[]. +// ** +// ** The super-journal page checksum is the sum of the bytes in the super-journal +// ** name, where each byte is interpreted as a signed 8-bit integer. +// ** +// ** If zSuper is a NULL pointer (occurs for a single database transaction), +// ** this call is a no-op. +// */ +func _writeSuperJournal(tls *libc.TLS, pPager uintptr, zSuper uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var cksum Tu32 + var iHdrOff Ti64 + var nSuper, rc, v2, v3, v5, v7, v9 int32 + var v10, v4, v6, v8 bool + var _ /* jrnlSize at bp+0 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = cksum, iHdrOff, nSuper, rc, v10, v2, v3, v4, v5, v6, v7, v8, v9 /* Size of journal file on disk */ + cksum = uint32(0) /* Checksum of string zSuper */ + if !(zSuper != 0) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_MEMORY) || !((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != libc.UintptrFromInt32(0)) { + return SQLITE_OK + } + (*TPager)(unsafe.Pointer(pPager)).FsetSuper = uint8(1) + /* Calculate the length in bytes and the checksum of zSuper */ + nSuper = 0 + for { + if !(**(**int8)(__ccgo_up(zSuper + uintptr(nSuper))) != 0) { + break + } + cksum = cksum + libc.Uint32FromInt8(**(**int8)(__ccgo_up(zSuper + uintptr(nSuper)))) + goto _1 + _1: + ; + nSuper = nSuper + 1 + } + /* If in full-sync mode, advance to the next disk sector before writing + ** the super-journal name. This is in case the previous page written to + ** the journal has already been synced. + */ + if (*TPager)(unsafe.Pointer(pPager)).FfullSync != 0 { + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = _journalHdrOffset(tls, pPager) + } + iHdrOff = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + /* Write the super-journal data to the end of the journal file. If + ** an error occurs, return the error code to the caller. + */ + v2 = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff, (*TPager)(unsafe.Pointer(pPager)).FlckPgno) + rc = v2 + if v4 = 0 != v2; !v4 { + v3 = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, zSuper, nSuper, iHdrOff+int64(4)) + rc = v3 + } + if v6 = v4 || 0 != v3; !v6 { + v5 = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(4)+int64(nSuper), libc.Uint32FromInt32(nSuper)) + rc = v5 + } + if v8 = v6 || 0 != v5; !v8 { + v7 = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(4)+int64(nSuper)+int64(4), cksum) + rc = v7 + } + if v10 = v8 || 0 != v7; !v10 { + v9 = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&_aJournalMagic)), int32(8), iHdrOff+int64(4)+int64(nSuper)+int64(8)) + rc = v9 + } + if v10 || 0 != v9 { + return rc + } + **(**Ti64)(__ccgo_up(pPager + 96)) += int64(nSuper + libc.Int32FromInt32(20)) + /* If the pager is in persistent-journal mode, then the physical + ** journal-file may extend past the end of the super-journal name + ** and 8 bytes of magic data just written to the file. This is + ** dangerous because the code to rollback a hot-journal file + ** will not be able to find the super-journal name to determine + ** whether or not the journal is hot. + ** + ** Easiest thing to do in this scenario is to truncate the journal + ** file to the required size. + */ + v2 = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp) + rc = v2 + if SQLITE_OK == v2 && **(**Ti64)(__ccgo_up(bp)) > (*TPager)(unsafe.Pointer(pPager)).FjournalOff { + rc = _sqlite3OsTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, (*TPager)(unsafe.Pointer(pPager)).FjournalOff) + } + return rc +} + +// C documentation +// +// /* +// ** Attempt the transfer optimization on INSERTs of the form +// ** +// ** INSERT INTO tab1 SELECT * FROM tab2; +// ** +// ** The xfer optimization transfers raw records from tab2 over to tab1. +// ** Columns are not decoded and reassembled, which greatly improves +// ** performance. Raw index records are transferred in the same way. +// ** +// ** The xfer optimization is only attempted if tab1 and tab2 are compatible. +// ** There are lots of rules for determining compatibility - see comments +// ** embedded in the code for details. +// ** +// ** This routine returns TRUE if the optimization is guaranteed to be used. +// ** Sometimes the xfer optimization will only work if the destination table +// ** is empty - a factor that can only be determined at run-time. In that +// ** case, this routine generates code for the xfer optimization but also +// ** does a test to see if the destination table is empty and jumps over the +// ** xfer optimization code if the test fails. In that case, this routine +// ** returns FALSE so that the caller will know to go ahead and generate +// ** an unoptimized transfer. This routine also returns FALSE if there +// ** is no chance that the xfer optimization can be applied. +// ** +// ** This optimization is particularly useful at making VACUUM run faster. +// */ +func _xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uintptr, onError int32, iDbDest int32) (r int32) { + var addr1, addr2, destHasUniqueIdx, emptyDestTest, emptySrcTest, i, iDbSrc, iDest, iSrc, regAutoinc, regData, regRowid, v4 int32 + var db, pDestCol, pDestExpr, pDestIdx, pEList, pItem, pSrc, pSrcCol, pSrcExpr, pSrcIdx, v, zColl, v5 uintptr + var idxInsFlags, insFlags Tu8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, addr2, db, destHasUniqueIdx, emptyDestTest, emptySrcTest, i, iDbSrc, iDest, iSrc, idxInsFlags, insFlags, pDestCol, pDestExpr, pDestIdx, pEList, pItem, pSrc, pSrcCol, pSrcExpr, pSrcIdx, regAutoinc, regData, regRowid, v, zColl, v4, v5 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Loop addresses */ + emptyDestTest = 0 /* Address of test for empty pDest */ + emptySrcTest = 0 /* Memory register used by AUTOINC */ + destHasUniqueIdx = 0 /* Registers holding data and rowid */ + if (*TParse)(unsafe.Pointer(pParse)).FpWith != 0 || (*TSelect)(unsafe.Pointer(pSelect)).FpWith != 0 { + /* Do not attempt to process this query if there are an WITH clauses + ** attached to it. Proceeding may generate a false "no such table: xxx" + ** error if pSelect reads from a CTE named "xxx". */ + return 0 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pDest)).FeTabType) == int32(TABTYP_VTAB) { + return 0 /* tab1 must not be a virtual table */ + } + if onError == int32(OE_Default) { + if int32((*TTable)(unsafe.Pointer(pDest)).FiPKey) >= 0 { + onError = libc.Int32FromUint8((*TTable)(unsafe.Pointer(pDest)).FkeyConf) + } + if onError == int32(OE_Default) { + onError = int32(OE_Abort) + } + } + /* allocated even if there is no FROM clause */ + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc != int32(1) { + return 0 /* FROM clause must have exactly one term */ + } + if int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + 24 + 4))&0x4>>2) != 0 { + return 0 /* FROM clause cannot contain a subquery */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpWhere != 0 { + return 0 /* SELECT may not have a WHERE clause */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpOrderBy != 0 { + return 0 /* SELECT may not have an ORDER BY clause */ + } + /* Do not need to test for a HAVING clause. If HAVING is present but + ** there is no ORDER BY, we will get an error. */ + if (*TSelect)(unsafe.Pointer(pSelect)).FpGroupBy != 0 { + return 0 /* SELECT may not have a GROUP BY clause */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpLimit != 0 { + return 0 /* SELECT may not have a LIMIT clause */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + return 0 /* SELECT may not be a compound query */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FselFlags&uint32(SF_Distinct) != 0 { + return 0 /* SELECT may not be DISTINCT */ + } + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + if (*TExprList)(unsafe.Pointer(pEList)).FnExpr != int32(1) { + return 0 /* The result set must have exactly one column */ + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList + 8))).FpExpr)).Fop) != int32(TK_ASTERISK) { + return 0 /* The result set must be the special operator "*" */ + } + /* At this point we have established that the statement is of the + ** correct syntactic form to participate in this optimization. Now + ** we have to check the semantics. + */ + pItem = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + pSrc = _sqlite3LocateTableItem(tls, pParse, uint32(0), pItem) + if pSrc == uintptr(0) { + return 0 /* FROM clause does not contain a real table */ + } + if (*TTable)(unsafe.Pointer(pSrc)).Ftnum == (*TTable)(unsafe.Pointer(pDest)).Ftnum && (*TTable)(unsafe.Pointer(pSrc)).FpSchema == (*TTable)(unsafe.Pointer(pDest)).FpSchema { + /* Possible due to bad sqlite_schema.rootpage */ + return 0 /* tab1 and tab2 may not be the same table */ + } + if libc.BoolInt32((*TTable)(unsafe.Pointer(pDest)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0)) != libc.BoolInt32((*TTable)(unsafe.Pointer(pSrc)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0)) { + return 0 /* source and destination must both be WITHOUT ROWID or not */ + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pSrc)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + return 0 /* tab2 may not be a view or virtual table */ + } + if int32((*TTable)(unsafe.Pointer(pDest)).FnCol) != int32((*TTable)(unsafe.Pointer(pSrc)).FnCol) { + return 0 /* Number of columns must be the same in tab1 and tab2 */ + } + if int32((*TTable)(unsafe.Pointer(pDest)).FiPKey) != int32((*TTable)(unsafe.Pointer(pSrc)).FiPKey) { + return 0 /* Both tables must have the same INTEGER PRIMARY KEY */ + } + if (*TTable)(unsafe.Pointer(pDest)).FtabFlags&uint32(TF_Strict) != uint32(0) && (*TTable)(unsafe.Pointer(pSrc)).FtabFlags&uint32(TF_Strict) == uint32(0) { + return 0 /* Cannot feed from a non-strict into a strict table */ + } + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pDest)).FnCol)) { + break + } + pDestCol = (*TTable)(unsafe.Pointer(pDest)).FaCol + uintptr(i)*16 + pSrcCol = (*TTable)(unsafe.Pointer(pSrc)).FaCol + uintptr(i)*16 + /* Even if tables t1 and t2 have identical schemas, if they contain + ** generated columns, then this statement is semantically incorrect: + ** + ** INSERT INTO t2 SELECT * FROM t1; + ** + ** The reason is that generated column values are returned by the + ** the SELECT statement on the right but the INSERT statement on the + ** left wants them to be omitted. + ** + ** Nevertheless, this is a useful notational shorthand to tell SQLite + ** to do a bulk transfer all of the content from t1 over to t2. + ** + ** We could, in theory, disable this (except for internal use by the + ** VACUUM command where it is actually needed). But why do that? It + ** seems harmless enough, and provides a useful service. + */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pDestCol)).FcolFlags)&int32(COLFLAG_GENERATED) != libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pSrcCol)).FcolFlags)&int32(COLFLAG_GENERATED) { + return 0 /* Both columns have the same generated-column type */ + } + /* But the transfer is only allowed if both the source and destination + ** tables have the exact same expressions for generated columns. + ** This requirement could be relaxed for VIRTUAL columns, I suppose. + */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pDestCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + if _sqlite3ExprCompare(tls, uintptr(0), _sqlite3ColumnExpr(tls, pSrc, pSrcCol), _sqlite3ColumnExpr(tls, pDest, pDestCol), -int32(1)) != 0 { + return 0 /* Different generator expressions */ + } + } + if int32((*TColumn)(unsafe.Pointer(pDestCol)).Faffinity) != int32((*TColumn)(unsafe.Pointer(pSrcCol)).Faffinity) { + return 0 /* Affinity must be the same on all columns */ + } + if Xsqlite3_stricmp(tls, _sqlite3ColumnColl(tls, pDestCol), _sqlite3ColumnColl(tls, pSrcCol)) != 0 { + return 0 /* Collating sequence must be the same on all columns */ + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pDestCol + 8))&0xf>>0)) != 0 && !(int32(uint32(*(*uint8)(unsafe.Pointer(pSrcCol + 8))&0xf>>0)) != 0) { + return 0 /* tab2 must be NOT NULL if tab1 is */ + } + /* Default values for second and subsequent columns need to match. */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pDestCol)).FcolFlags)&int32(COLFLAG_GENERATED) == 0 && i > 0 { + pDestExpr = _sqlite3ColumnExpr(tls, pDest, pDestCol) + pSrcExpr = _sqlite3ColumnExpr(tls, pSrc, pSrcCol) + if libc.BoolInt32(pDestExpr == uintptr(0)) != libc.BoolInt32(pSrcExpr == uintptr(0)) || pDestExpr != uintptr(0) && libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(pDestExpr + 8)), *(*uintptr)(unsafe.Pointer(pSrcExpr + 8))) != 0 { + return 0 /* Default values must be the same for all columns */ + } + } + goto _1 + _1: + ; + i = i + 1 + } + pDestIdx = (*TTable)(unsafe.Pointer(pDest)).FpIndex + for { + if !(pDestIdx != 0) { + break + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pDestIdx)).FonError) != OE_None { + destHasUniqueIdx = int32(1) + } + pSrcIdx = (*TTable)(unsafe.Pointer(pSrc)).FpIndex + for { + if !(pSrcIdx != 0) { + break + } + if _xferCompatibleIndex(tls, pDestIdx, pSrcIdx) != 0 { + break + } + goto _3 + _3: + ; + pSrcIdx = (*TIndex)(unsafe.Pointer(pSrcIdx)).FpNext + } + if pSrcIdx == uintptr(0) { + return 0 /* pDestIdx has no corresponding index in pSrc */ + } + if (*TIndex)(unsafe.Pointer(pSrcIdx)).Ftnum == (*TIndex)(unsafe.Pointer(pDestIdx)).Ftnum && (*TTable)(unsafe.Pointer(pSrc)).FpSchema == (*TTable)(unsafe.Pointer(pDest)).FpSchema && _sqlite3FaultSim(tls, int32(411)) == SQLITE_OK { + /* The sqlite3FaultSim() call allows this corruption test to be + ** bypassed during testing, in order to exercise other corruption tests + ** further downstream. */ + return 0 /* Corrupt schema - two indexes on the same btree */ + } + goto _2 + _2: + ; + pDestIdx = (*TIndex)(unsafe.Pointer(pDestIdx)).FpNext + } + if (*TTable)(unsafe.Pointer(pDest)).FpCheck != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) && _sqlite3ExprListCompare(tls, (*TTable)(unsafe.Pointer(pSrc)).FpCheck, (*TTable)(unsafe.Pointer(pDest)).FpCheck, -int32(1)) != 0 { + return 0 /* Tables have different CHECK constraints. Ticket #2252 */ + } + /* Disallow the transfer optimization if the destination table contains + ** any foreign key constraints. This is more restrictive than necessary. + ** But the main beneficiary of the transfer optimization is the VACUUM + ** command, and the VACUUM command disables foreign key constraints. So + ** the extra complication to make this rule less restrictive is probably + ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != uint64(0) && (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pDest + 64))).FpFKey != uintptr(0) { + return 0 + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00001))<= 0 { + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iSrc, regRowid) + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) { + addr2 = _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iDest, 0, regRowid) + _sqlite3RowidConstraint(tls, pParse, onError, pDest) + _sqlite3VdbeJumpHere(tls, v, addr2) + } + _autoIncStep(tls, pParse, regAutoinc, regRowid) + } else { + if (*TTable)(unsafe.Pointer(pDest)).FpIndex == uintptr(0) && !((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&libc.Uint32FromInt32(DBFLAG_VacuumInto) != 0) { + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iDest, regRowid) + } else { + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iSrc, regRowid) + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_SeekEnd), iDest) + insFlags = libc.Uint8FromInt32(libc.Int32FromInt32(OPFLAG_APPEND) | libc.Int32FromInt32(OPFLAG_USESEEKRESULT) | libc.Int32FromInt32(OPFLAG_PREFORMAT)) + } else { + insFlags = libc.Uint8FromInt32(libc.Int32FromInt32(OPFLAG_NCHANGE) | libc.Int32FromInt32(OPFLAG_LASTROWID) | libc.Int32FromInt32(OPFLAG_APPEND) | libc.Int32FromInt32(OPFLAG_PREFORMAT)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_RowData), iSrc, regData, int32(1)) + insFlags = libc.Uint8FromInt32(int32(insFlags) & ^libc.Int32FromInt32(OPFLAG_PREFORMAT)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_RowCell), iDest, iSrc, regRowid) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iDest, regData, regRowid) + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) { + _sqlite3VdbeChangeP4(tls, v, -int32(1), pDest, -int32(5)) + } + _sqlite3VdbeChangeP5(tls, v, uint16(insFlags)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iSrc, addr1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iSrc, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iDest, 0) + } else { + _sqlite3TableLock(tls, pParse, iDbDest, (*TTable)(unsafe.Pointer(pDest)).Ftnum, uint8(1), (*TTable)(unsafe.Pointer(pDest)).FzName) + _sqlite3TableLock(tls, pParse, iDbSrc, (*TTable)(unsafe.Pointer(pSrc)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pSrc)).FzName) + } + pDestIdx = (*TTable)(unsafe.Pointer(pDest)).FpIndex + for { + if !(pDestIdx != 0) { + break + } + idxInsFlags = uint8(0) + pSrcIdx = (*TTable)(unsafe.Pointer(pSrc)).FpIndex + for { + if !(pSrcIdx != 0) { + break + } + if _xferCompatibleIndex(tls, pDestIdx, pSrcIdx) != 0 { + break + } + goto _9 + _9: + ; + pSrcIdx = (*TIndex)(unsafe.Pointer(pSrcIdx)).FpNext + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), iSrc, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pSrcIdx)).Ftnum), iDbSrc) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pSrcIdx) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenWrite), iDest, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pDestIdx)).Ftnum), iDbDest) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pDestIdx) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_BULKCSR)) + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iSrc, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) != 0 { + /* This INSERT command is part of a VACUUM operation, which guarantees + ** that the destination table is empty. If all indexed columns use + ** collation sequence BINARY, then it can also be assumed that the + ** index will be populated by inserting keys in strictly sorted + ** order. In this case, instead of seeking within the b-tree as part + ** of every OP_IdxInsert opcode, an OP_SeekEnd is added before the + ** OP_IdxInsert to seek to the point within the b-tree where each key + ** should be inserted. This is faster. + ** + ** If any of the indexed columns use a collation sequence other than + ** BINARY, this optimization is disabled. This is because the user + ** might change the definition of a collation sequence and then run + ** a VACUUM command. In that case keys may not be written in strictly + ** sorted order. */ + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pSrcIdx)).FnColumn)) { + break + } + zColl = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pSrcIdx)).FazColl + uintptr(i)*8)) + if Xsqlite3_stricmp(tls, uintptr(unsafe.Pointer(&_sqlite3StrBINARY)), zColl) != 0 { + break + } + goto _10 + _10: + ; + i = i + 1 + } + if i == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pSrcIdx)).FnColumn) { + idxInsFlags = libc.Uint8FromInt32(libc.Int32FromInt32(OPFLAG_USESEEKRESULT) | libc.Int32FromInt32(OPFLAG_PREFORMAT)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_SeekEnd), iDest) + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowCell), iDest, iSrc) + } + } else { + if !((*TTable)(unsafe.Pointer(pSrc)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pDestIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + idxInsFlags = libc.Uint8FromInt32(int32(idxInsFlags) | libc.Int32FromInt32(OPFLAG_NCHANGE)) + } + } + if libc.Int32FromUint8(idxInsFlags) != libc.Int32FromInt32(OPFLAG_USESEEKRESULT)|libc.Int32FromInt32(OPFLAG_PREFORMAT) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_RowData), iSrc, regData, int32(1)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) && !((*TTable)(unsafe.Pointer(pDest)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pDestIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + _codeWithoutRowidPreupdate(tls, pParse, pDest, iDest, regData) + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), iDest, regData) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(libc.Int32FromUint8(idxInsFlags)|int32(OPFLAG_APPEND))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iSrc, addr1+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iSrc, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iDest, 0) + goto _8 + _8: + ; + pDestIdx = (*TIndex)(unsafe.Pointer(pDestIdx)).FpNext + } + if emptySrcTest != 0 { + _sqlite3VdbeJumpHere(tls, v, emptySrcTest) + } + _sqlite3ReleaseTempReg(tls, pParse, regRowid) + _sqlite3ReleaseTempReg(tls, pParse, regData) + if emptyDestTest != 0 { + _sqlite3AutoincrementEnd(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), SQLITE_OK, 0) + _sqlite3VdbeJumpHere(tls, v, emptyDestTest) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iDest, 0) + return 0 + } else { + return int32(1) + } + return r +} diff --git a/internal/engine/lib/sqlite_g_000000000000c4cf.go b/internal/engine/lib/sqlite_g_000000000000c4cf.go new file mode 100644 index 0000000..fa06907 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000000c4cf.go @@ -0,0 +1,2244 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (linux && 386) || (linux && amd64) || (linux && loong64) || (netbsd && amd64) || (openbsd && amd64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* Truncate the text of the string to be no more than N bytes. */ +func Xsqlite3_str_truncate(tls *libc.TLS, p uintptr, N int32) { + if p != uintptr(0) && N >= 0 && libc.Uint32FromInt32(N) < (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar { + (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar = libc.Uint32FromInt32(N) + **(**int8)(__ccgo_up((*Tsqlite3_str)(unsafe.Pointer(p)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(p)).FnChar))) = 0 + } +} + +// C documentation +// +// /* +// ** Append all path elements in zPath to the DbPath under construction. +// */ +func _appendAllPathElements(tls *libc.TLS, pPath uintptr, zPath uintptr) { + var i, j, v1 int32 + _, _, _ = i, j, v1 + i = 0 + j = 0 + for { + for **(**int8)(__ccgo_up(zPath + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32('/') { + i = i + 1 + } + if i > j { + _appendOnePathElement(tls, pPath, zPath+uintptr(j), i-j) + } + j = i + int32(1) + goto _2 + _2: + ; + v1 = i + i = i + 1 + if !(**(**int8)(__ccgo_up(zPath + uintptr(v1))) != 0) { + break + } + } +} + +// C documentation +// +// /* +// ** Return the P5 value that should be used for a binary comparison +// ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2. +// */ +func _binaryCompareP5(tls *libc.TLS, pExpr1 uintptr, pExpr2 uintptr, jumpIfNull int32) (r Tu8) { + var aff Tu8 + _ = aff + aff = libc.Uint8FromInt8(_sqlite3ExprAffinity(tls, pExpr2)) + aff = libc.Uint8FromInt32(libc.Int32FromUint8(libc.Uint8FromInt8(_sqlite3CompareAffinity(tls, pExpr1, libc.Int8FromUint8(aff)))) | libc.Int32FromUint8(libc.Uint8FromInt32(jumpIfNull))) + return aff +} + +func _fts5AsciiAddExceptions(tls *libc.TLS, p uintptr, zArg uintptr, bTokenChars int32) { + var i int32 + _ = i + i = 0 + for { + if !(**(**int8)(__ccgo_up(zArg + uintptr(i))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(zArg + uintptr(i))))&int32(0x80) == 0 { + **(**uint8)(__ccgo_up(p + uintptr(int32(**(**int8)(__ccgo_up(zArg + uintptr(i))))))) = libc.Uint8FromInt32(bTokenChars) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Tokenize some text using the ascii tokenizer. +// */ +func _fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, p, pFold uintptr + var ie, is, nByte, nFold, rc int32 + var _ /* aFold at bp+0 */ [64]int8 + _, _, _, _, _, _, _, _ = a, ie, is, nByte, nFold, p, pFold, rc + p = pTokenizer + rc = SQLITE_OK + is = 0 + nFold = int32(64) + pFold = bp + a = p + _ = iUnused + for is < nText && rc == SQLITE_OK { + /* Skip any leading divider characters. */ + for is < nText && (int32(**(**int8)(__ccgo_up(pText + uintptr(is))))&int32(0x80) == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(a + uintptr(int32(**(**int8)(__ccgo_up(pText + uintptr(is)))))))) == 0) { + is = is + 1 + } + if is == nText { + break + } + /* Count the token characters */ + ie = is + int32(1) + for ie < nText && (int32(**(**int8)(__ccgo_up(pText + uintptr(ie))))&int32(0x80) != 0 || **(**uint8)(__ccgo_up(a + uintptr(int32(**(**int8)(__ccgo_up(pText + uintptr(ie))))))) != 0) { + ie = ie + 1 + } + /* Fold to lower case */ + nByte = ie - is + if nByte > nFold { + if pFold != bp { + Xsqlite3_free(tls, pFold) + } + pFold = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nByte)*int64(2))) + if pFold == uintptr(0) { + rc = int32(SQLITE_NOMEM) + break + } + nFold = nByte * int32(2) + } + _asciiFold(tls, pFold, pText+uintptr(is), nByte) + /* Invoke the token callback */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xToken})))(tls, pCtx, 0, pFold, nByte, is, ie) + is = ie + int32(1) + } + if pFold != bp { + Xsqlite3_free(tls, pFold) + } + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + return rc +} + +/************************************************************************** +** Start of unicode61 tokenizer implementation. + */ + +/* +** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied +** from the sqlite3 source file utf.c. If this file is compiled as part +** of the amalgamation, they are not required. + */ + +// C documentation +// +// /* +// ** pIn is a UTF-8 encoded string, nIn bytes in size. Return the number of +// ** unicode characters in the string. +// */ +func _fts5IndexCharlen(tls *libc.TLS, pIn uintptr, nIn int32) (r int32) { + var i, nChar, v1 int32 + _, _, _ = i, nChar, v1 + nChar = 0 + i = 0 + for i < nIn { + v1 = i + i = i + 1 + if libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + uintptr(v1))))) >= int32(0xc0) { + for i < nIn && int32(**(**int8)(__ccgo_up(pIn + uintptr(i))))&int32(0xc0) == int32(0x80) { + i = i + 1 + } + } + nChar = nChar + 1 + } + return nChar +} + +// C documentation +// +// /* Parse out a number. Write the value into *pVal if pVal!=0. +// ** return non-zero on success and zero if the next token is not a number. +// */ +func _geopolyParseNumber(tls *libc.TLS, p uintptr, pVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c int8 + var j, seenDP, seenE, v2 int32 + var z uintptr + var _ /* r at bp+0 */ float64 + _, _, _, _, _, _ = c, j, seenDP, seenE, z, v2 + c = _geopolySkipSpace(tls, p) + z = (*TGeoParse)(unsafe.Pointer(p)).Fz + j = 0 + seenDP = 0 + seenE = 0 + if int32(c) == int32('-') { + j = int32(1) + c = libc.Int8FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) + } + if int32(c) == int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j+int32(1))))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j+int32(1))))) <= int32('9') { + return 0 + } + for { + c = libc.Int8FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(c)])&int32(0x04) != 0 { + goto _1 + } + if int32(c) == int32('.') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-int32(1))))) == int32('-') { + return 0 + } + if seenDP != 0 { + return 0 + } + seenDP = int32(1) + goto _1 + } + if int32(c) == int32('e') || int32(c) == int32('E') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-int32(1))))) < int32('0') { + return 0 + } + if seenE != 0 { + return -int32(1) + } + v2 = libc.Int32FromInt32(1) + seenE = v2 + seenDP = v2 + c = libc.Int8FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j+int32(1))))) + if int32(c) == int32('+') || int32(c) == int32('-') { + j = j + 1 + c = libc.Int8FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j+int32(1))))) + } + if int32(c) < int32('0') || int32(c) > int32('9') { + return 0 + } + goto _1 + } + break + goto _1 + _1: + ; + j = j + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-int32(1))))) < int32('0') { + return 0 + } + if pVal != 0 { + _sqlite3AtoF(tls, (*TGeoParse)(unsafe.Pointer(p)).Fz, bp) + **(**TGeoCoord)(__ccgo_up(pVal)) = float32(**(**float64)(__ccgo_up(bp))) + } + **(**uintptr)(__ccgo_up(p)) += uintptr(j) + return int32(1) +} + +// C documentation +// +// /* Skip whitespace. Return the next non-whitespace character. */ +func _geopolySkipSpace(tls *libc.TLS, p uintptr) (r int8) { + for _geopolyIsSpace[**(**uint8)(__ccgo_up((*TGeoParse)(unsafe.Pointer(p)).Fz))] != 0 { + (*TGeoParse)(unsafe.Pointer(p)).Fz = (*TGeoParse)(unsafe.Pointer(p)).Fz + 1 + } + return libc.Int8FromUint8(**(**uint8)(__ccgo_up((*TGeoParse)(unsafe.Pointer(p)).Fz))) +} + +// C documentation +// +// /* +// ** Convert zDate into one or more integers according to the conversion +// ** specifier zFormat. +// ** +// ** zFormat[] contains 4 characters for each integer converted, except for +// ** the last integer which is specified by three characters. The meaning +// ** of a four-character format specifiers ABCD is: +// ** +// ** A: number of digits to convert. Always "2" or "4". +// ** B: minimum value. Always "0" or "1". +// ** C: maximum value, decoded as: +// ** a: 12 +// ** b: 14 +// ** c: 24 +// ** d: 31 +// ** e: 59 +// ** f: 9999 +// ** D: the separator character, or \000 to indicate this is the +// ** last number to convert. +// ** +// ** Example: To translate an ISO-8601 date YYYY-MM-DD, the format would +// ** be "40f-21a-20c". The "40f-" indicates the 4-digit year followed by "-". +// ** The "21a-" indicates the 2-digit month followed by "-". The "20c" indicates +// ** the 2-digit day which is the last integer in the set. +// ** +// ** The function returns the number of successful conversions. +// */ +func _getDigits(tls *libc.TLS, zDate uintptr, zFormat uintptr, va uintptr) (r int32) { + var N, min, nextC, v1 int8 + var ap Tva_list + var cnt, val int32 + var max Tu16 + _, _, _, _, _, _, _, _ = N, ap, cnt, max, min, nextC, val, v1 + cnt = 0 + ap = va + for cond := true; cond; cond = nextC != 0 { + N = int8(int32(**(**int8)(__ccgo_up(zFormat))) - int32('0')) + min = int8(int32(**(**int8)(__ccgo_up(zFormat + 1))) - int32('0')) + val = 0 + max = _aMx[int32(**(**int8)(__ccgo_up(zFormat + 2)))-int32('a')] + nextC = **(**int8)(__ccgo_up(zFormat + 3)) + val = 0 + for { + v1 = N + N = N - 1 + if !(v1 != 0) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&libc.Int32FromInt32(0x04) != 0) { + goto end_getDigits + } + val = val*int32(10) + int32(**(**int8)(__ccgo_up(zDate))) - int32('0') + zDate = zDate + 1 + } + if val < int32(min) || val > libc.Int32FromUint16(max) || int32(nextC) != 0 && int32(nextC) != int32(**(**int8)(__ccgo_up(zDate))) { + goto end_getDigits + } + **(**int32)(__ccgo_up(libc.VaUintptr(&ap))) = val + zDate = zDate + 1 + cnt = cnt + 1 + zFormat = zFormat + uintptr(4) + } + goto end_getDigits +end_getDigits: + ; + _ = ap + return cnt +} + +// C documentation +// +// /* +// ** The first parameter is a pointer to an output buffer. The second +// ** parameter is a pointer to an integer that contains the offset at +// ** which to write into the output buffer. This function copies the +// ** nul-terminated string pointed to by the third parameter, zSignedIdent, +// ** to the specified offset in the buffer and updates *pIdx to refer +// ** to the first byte after the last byte written before returning. +// ** +// ** If the string zSignedIdent consists entirely of alphanumeric +// ** characters, does not begin with a digit and is not an SQL keyword, +// ** then it is copied to the output buffer exactly as it is. Otherwise, +// ** it is quoted using double-quotes. +// */ +func _identPut(tls *libc.TLS, z uintptr, pIdx uintptr, zSignedIdent uintptr) { + var i, j, needQuote, v2 int32 + var zIdent uintptr + _, _, _, _, _ = i, j, needQuote, zIdent, v2 + zIdent = zSignedIdent + i = **(**int32)(__ccgo_up(pIdx)) + j = 0 + for { + if !(**(**uint8)(__ccgo_up(zIdent + uintptr(j))) != 0) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(zIdent + uintptr(j)))])&libc.Int32FromInt32(0x06) != 0) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIdent + uintptr(j)))) != int32('_') { + break + } + goto _1 + _1: + ; + j = j + 1 + } + needQuote = libc.BoolInt32(libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(zIdent))])&int32(0x04) != 0 || _sqlite3KeywordCode(tls, zIdent, j) != int32(TK_ID) || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIdent + uintptr(j)))) != 0 || j == 0) + if needQuote != 0 { + v2 = i + i = i + 1 + **(**int8)(__ccgo_up(z + uintptr(v2))) = int8('"') + } + j = 0 + for { + if !(**(**uint8)(__ccgo_up(zIdent + uintptr(j))) != 0) { + break + } + v2 = i + i = i + 1 + **(**int8)(__ccgo_up(z + uintptr(v2))) = libc.Int8FromUint8(**(**uint8)(__ccgo_up(zIdent + uintptr(j)))) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIdent + uintptr(j)))) == int32('"') { + v2 = i + i = i + 1 + **(**int8)(__ccgo_up(z + uintptr(v2))) = int8('"') + } + goto _3 + _3: + ; + j = j + 1 + } + if needQuote != 0 { + v2 = i + i = i + 1 + **(**int8)(__ccgo_up(z + uintptr(v2))) = int8('"') + } + **(**int8)(__ccgo_up(z + uintptr(i))) = 0 + **(**int32)(__ccgo_up(pIdx)) = i +} + +// C documentation +// +// /* +// ** Return true if z[] begins with N hexadecimal digits, and write +// ** a decoding of those digits into *pVal. Or return false if any +// ** one of the first N characters in z[] is not a hexadecimal digit. +// */ +func _isNHex(tls *libc.TLS, z uintptr, N int32, pVal uintptr) (r int32) { + var i int32 + var v Tu32 + _, _ = i, v + v = uint32(0) + i = 0 + for { + if !(i < N) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i))))])&libc.Int32FromInt32(0x08) != 0) { + return 0 + } + v = v<= uint32(0xc0) { + sz = _sqlite3Utf8ReadLimited(tls, zLeft, libc.Int32FromUint32(nLeft), bp) + zLeft = zLeft + uintptr(sz) + nLeft = nLeft - libc.Uint32FromInt32(sz) + } else { + zLeft = zLeft + 1 + nLeft = nLeft - 1 + } + } else { + n = _jsonUnescapeOneChar(tls, zLeft, nLeft, bp) + zLeft = zLeft + uintptr(n) + nLeft = nLeft - n + } + } + if nRight == uint32(0) { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) + } else { + if rawRight != 0 || int32(**(**int8)(__ccgo_up(zRight))) != int32('\\') { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(**(**Tu8)(__ccgo_up(zRight))) + if **(**Tu32)(__ccgo_up(bp + 4)) >= uint32(0xc0) { + sz1 = _sqlite3Utf8ReadLimited(tls, zRight, libc.Int32FromUint32(nRight), bp+4) + zRight = zRight + uintptr(sz1) + nRight = nRight - libc.Uint32FromInt32(sz1) + } else { + zRight = zRight + 1 + nRight = nRight - 1 + } + } else { + n1 = _jsonUnescapeOneChar(tls, zRight, nRight, bp+4) + zRight = zRight + uintptr(n1) + nRight = nRight - n1 + } + } + if **(**Tu32)(__ccgo_up(bp)) != **(**Tu32)(__ccgo_up(bp + 4)) { + return 0 + } + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + return int32(1) + } + } + return r +} + +// C documentation +// +// /* Make sure there is a zero terminator on p->zBuf[] +// ** +// ** Return true on success. Return false if an OOM prevents this +// ** from happening. +// */ +func _jsonStringTerminate(tls *libc.TLS, p uintptr) (r int32) { + _jsonAppendChar(tls, p, 0) + _jsonStringTrimOneChar(tls, p) + return libc.BoolInt32(libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr) == 0) +} + +// C documentation +// +// /* +// ** Input z[0..n] defines JSON escape sequence including the leading '\\'. +// ** Decode that escape sequence into a single character. Write that +// ** character into *piOut. Return the number of bytes in the escape sequence. +// ** +// ** If there is a syntax error of some kind (for example too few characters +// ** after the '\\' to complete the encoding) then *piOut is set to +// ** JSON_INVALID_CHAR. +// */ +func _jsonUnescapeOneChar(tls *libc.TLS, z uintptr, n Tu32, piOut uintptr) (r Tu32) { + var nSkip, v, vlo, v1 Tu32 + var sz, v3 int32 + var v2 bool + _, _, _, _, _, _, _ = nSkip, sz, v, vlo, v1, v2, v3 + if n < uint32(2) { + **(**Tu32)(__ccgo_up(piOut)) = uint32(JSON_INVALID_CHAR) + return n + } + switch libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + 1)))) { + case int32('u'): + if n < uint32(6) { + **(**Tu32)(__ccgo_up(piOut)) = uint32(JSON_INVALID_CHAR) + return n + } + v = _jsonHexToInt4(tls, z+2) + if v2 = v&uint32(0xfc00) == uint32(0xd800) && n >= uint32(12) && int32(**(**int8)(__ccgo_up(z + 6))) == int32('\\') && int32(**(**int8)(__ccgo_up(z + 7))) == int32('u'); v2 { + v1 = _jsonHexToInt4(tls, z+8) + vlo = v1 + } + if v2 && v1&uint32(0xfc00) == uint32(0xdc00) { + **(**Tu32)(__ccgo_up(piOut)) = v&uint32(0x3ff)< uint32(2) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + 2)))])&int32(0x04) != 0 { + v3 = int32(JSON_INVALID_CHAR) + } else { + v3 = 0 + } + **(**Tu32)(__ccgo_up(piOut)) = libc.Uint32FromInt32(v3) + return uint32(2) + case int32('\''): + fallthrough + case int32('"'): + fallthrough + case int32('/'): + fallthrough + case int32('\\'): + **(**Tu32)(__ccgo_up(piOut)) = libc.Uint32FromInt8(**(**int8)(__ccgo_up(z + 1))) + return uint32(2) + case int32('x'): + if n < uint32(4) { + **(**Tu32)(__ccgo_up(piOut)) = uint32(JSON_INVALID_CHAR) + return n + } + **(**Tu32)(__ccgo_up(piOut)) = libc.Uint32FromInt32(libc.Int32FromUint8(_jsonHexToInt(tls, int32(**(**int8)(__ccgo_up(z + 2)))))< 0) { + break + } + if libc.Int64FromUint8(_aKWLen[i]) != n { + goto _1 + } + zKW = uintptr(unsafe.Pointer(&_zKWText)) + uintptr(_aKWOffset[i]) + if int32(**(**int8)(__ccgo_up(z))) & ^libc.Int32FromInt32(0x20) != int32(**(**int8)(__ccgo_up(zKW))) { + goto _1 + } + if int32(**(**int8)(__ccgo_up(z + 1))) & ^libc.Int32FromInt32(0x20) != int32(**(**int8)(__ccgo_up(zKW + 1))) { + goto _1 + } + j = int64(2) + for j < n && int32(**(**int8)(__ccgo_up(z + uintptr(j)))) & ^libc.Int32FromInt32(0x20) == int32(**(**int8)(__ccgo_up(zKW + uintptr(j)))) { + j = j + 1 + } + if j < n { + goto _1 + } + /* REINDEX */ + /* INDEXED */ + /* INDEX */ + /* DESC */ + /* ESCAPE */ + /* EACH */ + /* CHECK */ + /* KEY */ + /* BEFORE */ + /* FOREIGN */ + /* FOR */ + /* IGNORE */ + /* REGEXP */ + /* EXPLAIN */ + /* INSTEAD */ + /* ADD */ + /* DATABASE */ + /* AS */ + /* SELECT */ + /* TABLE */ + /* LEFT */ + /* THEN */ + /* END */ + /* DEFERRABLE */ + /* ELSE */ + /* EXCLUDE */ + /* DELETE */ + /* TEMPORARY */ + /* TEMP */ + /* OR */ + /* ISNULL */ + /* NULLS */ + /* SAVEPOINT */ + /* INTERSECT */ + /* TIES */ + /* NOTNULL */ + /* NOT */ + /* NO */ + /* NULL */ + /* LIKE */ + /* EXCEPT */ + /* TRANSACTION */ + /* ACTION */ + /* ON */ + /* NATURAL */ + /* ALTER */ + /* RAISE */ + /* EXCLUSIVE */ + /* EXISTS */ + /* CONSTRAINT */ + /* INTO */ + /* OFFSET */ + /* OF */ + /* SET */ + /* TRIGGER */ + /* RANGE */ + /* GENERATED */ + /* DETACH */ + /* HAVING */ + /* GLOB */ + /* BEGIN */ + /* INNER */ + /* REFERENCES */ + /* UNIQUE */ + /* QUERY */ + /* WITHOUT */ + /* WITH */ + /* OUTER */ + /* RELEASE */ + /* ATTACH */ + /* BETWEEN */ + /* NOTHING */ + /* GROUPS */ + /* GROUP */ + /* CASCADE */ + /* ASC */ + /* DEFAULT */ + /* CASE */ + /* COLLATE */ + /* CREATE */ + /* CURRENT_DATE */ + /* IMMEDIATE */ + /* JOIN */ + /* INSERT */ + /* MATCH */ + /* PLAN */ + /* ANALYZE */ + /* PRAGMA */ + /* MATERIALIZED */ + /* DEFERRED */ + /* DISTINCT */ + /* IS */ + /* UPDATE */ + /* VALUES */ + /* VIRTUAL */ + /* ALWAYS */ + /* WHEN */ + /* WHERE */ + /* RECURSIVE */ + /* ABORT */ + /* AFTER */ + /* RENAME */ + /* AND */ + /* DROP */ + /* PARTITION */ + /* AUTOINCREMENT */ + /* TO */ + /* IN */ + /* CAST */ + /* COLUMN */ + /* COMMIT */ + /* CONFLICT */ + /* CROSS */ + /* CURRENT_TIMESTAMP */ + /* CURRENT_TIME */ + /* CURRENT */ + /* PRECEDING */ + /* FAIL */ + /* LAST */ + /* FILTER */ + /* REPLACE */ + /* FIRST */ + /* FOLLOWING */ + /* FROM */ + /* FULL */ + /* LIMIT */ + /* IF */ + /* ORDER */ + /* RESTRICT */ + /* OTHERS */ + /* OVER */ + /* RETURNING */ + /* RIGHT */ + /* ROLLBACK */ + /* ROWS */ + /* ROW */ + /* UNBOUNDED */ + /* UNION */ + /* USING */ + /* VACUUM */ + /* VIEW */ + /* WINDOW */ + /* DO */ + /* BY */ + /* INITIALLY */ + /* ALL */ + /* PRIMARY */ + **(**int32)(__ccgo_up(pType)) = libc.Int32FromUint8(_aKWCode[i]) + break + goto _1 + _1: + ; + i = libc.Int64FromUint8(_aKWNext[i]) + } + return n +} + +func _lowerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var i, n int32 + var z1, z2 uintptr + _, _, _, _ = i, n, z1, z2 + _ = argc + z2 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + /* Verify that the call to _bytes() does not invalidate the _text() pointer */ + if z2 != 0 { + z1 = _contextMalloc(tls, context, int64(n)+int64(1)) + if z1 != 0 { + i = 0 + for { + if !(i < n) { + break + } + **(**int8)(__ccgo_up(z1 + uintptr(i))) = libc.Int8FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z2 + uintptr(i))))]) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_result_text(tls, context, z1, n, __ccgo_fp(Xsqlite3_free)) + } + } +} + +/* +** Some functions like COALESCE() and IFNULL() and UNLIKELY() are implemented +** as VDBE code so that unused argument values do not have to be computed. +** However, we still need some kind of function implementation for this +** routines in the function table. The noopFunc macro provides this. +** noopFunc will never be called so it doesn't matter what the implementation +** is. We might as well use the "version()" function as a substitute. + */ + +// C documentation +// +// /* +// ** Write an entry into the pointer map. +// ** +// ** This routine updates the pointer map entry for page number 'key' +// ** so that it maps to type 'eType' and parent page number 'pgno'. +// ** +// ** If *pRC is initially non-zero (non-SQLITE_OK) then this routine is +// ** a no-op. If an error occurs, the appropriate error code is written +// ** into *pRC. +// */ +func _ptrmapPut(tls *libc.TLS, pBt uintptr, key TPgno, eType Tu8, parent TPgno, pRC uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iPtrmap TPgno + var offset, rc, v1 int32 + var pPtrmap uintptr + var _ /* pDbPage at bp+0 */ uintptr + _, _, _, _, _ = iPtrmap, offset, pPtrmap, rc, v1 /* Return code from subfunctions */ + if **(**int32)(__ccgo_up(pRC)) != 0 { + return + } + /* The super-journal page number must never be used as a pointer map page */ + if key == uint32(0) { + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(74216)) + return + } + iPtrmap = _ptrmapPageno(tls, pBt, key) + rc = _sqlite3PagerGet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, iPtrmap, bp, 0) + if rc != SQLITE_OK { + **(**int32)(__ccgo_up(pRC)) = rc + return + } + if int32(**(**int8)(__ccgo_up(_sqlite3PagerGetExtra(tls, **(**uintptr)(__ccgo_up(bp)))))) != 0 { + /* The first byte of the extra data is the MemPage.isInit byte. + ** If that byte is set, it means this page is also being used + ** as a btree page. */ + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(74229)) + goto ptrmap_exit + } + offset = libc.Int32FromUint32(libc.Uint32FromInt32(5) * (key - iPtrmap - libc.Uint32FromInt32(1))) + if offset < 0 { + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(74234)) + goto ptrmap_exit + } + pPtrmap = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + if libc.Int32FromUint8(eType) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pPtrmap + uintptr(offset)))) || _sqlite3Get4byte(tls, pPtrmap+uintptr(offset+int32(1))) != parent { + v1 = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp))) + rc = v1 + **(**int32)(__ccgo_up(pRC)) = v1 + if rc == SQLITE_OK { + **(**Tu8)(__ccgo_up(pPtrmap + uintptr(offset))) = eType + _sqlite3Put4byte(tls, pPtrmap+uintptr(offset+int32(1)), parent) + } + } + goto ptrmap_exit +ptrmap_exit: + ; + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) +} + +// C documentation +// +// /* +// ** Scan the column type name zType (length nType) and return the +// ** associated affinity type. +// ** +// ** This routine does a case-independent search of zType for the +// ** substrings in the following table. If one of the substrings is +// ** found, the corresponding affinity is returned. If zType contains +// ** more than one of the substrings, entries toward the top of +// ** the table take priority. For example, if zType is 'BLOBINT', +// ** SQLITE_AFF_INTEGER is returned. +// ** +// ** Substring | Affinity +// ** -------------------------------- +// ** 'INT' | SQLITE_AFF_INTEGER +// ** 'CHAR' | SQLITE_AFF_TEXT +// ** 'CLOB' | SQLITE_AFF_TEXT +// ** 'TEXT' | SQLITE_AFF_TEXT +// ** 'BLOB' | SQLITE_AFF_BLOB +// ** 'REAL' | SQLITE_AFF_REAL +// ** 'FLOA' | SQLITE_AFF_REAL +// ** 'DOUB' | SQLITE_AFF_REAL +// ** +// ** If none of the substrings in the above table are found, +// ** SQLITE_AFF_NUMERIC is returned. +// */ +func _sqlite3AffinityType(tls *libc.TLS, zIn uintptr, pCol uintptr) (r int8) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aff int8 + var h Tu32 + var x Tu8 + var zChar uintptr + var _ /* v at bp+0 */ int32 + _, _, _, _ = aff, h, x, zChar + h = uint32(0) + aff = int8(SQLITE_AFF_NUMERIC) + zChar = uintptr(0) + for **(**int8)(__ccgo_up(zIn)) != 0 { + x = **(**Tu8)(__ccgo_up(zIn)) + h = h< r=(k/4+1) */ + _sqlite3GetInt32(tls, zChar, bp) + break + } + zChar = zChar + 1 + } + } else { + **(**int32)(__ccgo_up(bp)) = int32(16) /* BLOB, TEXT, CLOB -> r=5 (approx 20 bytes)*/ + } + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp))/int32(4) + int32(1) + if **(**int32)(__ccgo_up(bp)) > int32(255) { + **(**int32)(__ccgo_up(bp)) = int32(255) + } + (*TColumn)(unsafe.Pointer(pCol)).FszEst = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))) + } + return aff +} + +// C documentation +// +// /* +// ** Write a single UTF8 character whose value is v into the +// ** buffer starting at zOut. zOut must be sized to hold at +// ** least four bytes. Return the number of bytes needed +// ** to encode the new character. +// */ +func _sqlite3AppendOneUtf8Character(tls *libc.TLS, zOut uintptr, v Tu32) (r int32) { + if v < uint32(0x00080) { + **(**int8)(__ccgo_up(zOut)) = libc.Int8FromUint8(uint8(v & libc.Uint32FromInt32(0xff))) + return int32(1) + } + if v < uint32(0x00800) { + **(**int8)(__ccgo_up(zOut)) = int8(int32(0xc0) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1f)))) + **(**int8)(__ccgo_up(zOut + 1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(v&libc.Uint32FromInt32(0x3f)))) + return int32(2) + } + if v < uint32(0x10000) { + **(**int8)(__ccgo_up(zOut)) = int8(int32(0xe0) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0f)))) + **(**int8)(__ccgo_up(zOut + 1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3f)))) + **(**int8)(__ccgo_up(zOut + 2)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(v&libc.Uint32FromInt32(0x3f)))) + return int32(3) + } + **(**int8)(__ccgo_up(zOut)) = int8(int32(0xf0) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + **(**int8)(__ccgo_up(zOut + 1)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3f)))) + **(**int8)(__ccgo_up(zOut + 2)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3f)))) + **(**int8)(__ccgo_up(zOut + 3)) = int8(int32(0x80) + libc.Int32FromUint8(uint8(v&libc.Uint32FromInt32(0x3f)))) + return int32(4) +} + +// C documentation +// +// /* +// ** Convert zNum to a 64-bit signed integer. zNum must be decimal. This +// ** routine does *not* accept hexadecimal notation. +// ** +// ** Returns: +// ** +// ** -1 Not even a prefix of the input text looks like an integer +// ** 0 Successful transformation. Fits in a 64-bit signed integer. +// ** 1 Excess non-space text after the integer value +// ** 2 Integer too large for a 64-bit signed integer or is malformed +// ** 3 Special case of 9223372036854775808 +// ** +// ** length is the number of bytes in the string (bytes, not characters). +// ** The string is not necessarily zero-terminated. The encoding is +// ** given by enc. +// */ +func _sqlite3Atoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32, enc Tu8) (r int32) { + var c, v3 uint32 + var i, incr, j, jj, neg, nonNum, rc, v6 int32 + var u Tu64 + var zEnd, zStart uintptr + var v4 bool + var v5 int64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, i, incr, j, jj, neg, nonNum, rc, u, zEnd, zStart, v3, v4, v5, v6 + u = uint64(0) + neg = 0 + c = uint32(0) + nonNum = 0 + zEnd = zNum + uintptr(length) + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + incr = int32(1) + } else { + incr = int32(2) + length = length & ^libc.Int32FromInt32(1) + i = int32(3) - libc.Int32FromUint8(enc) + for { + if !(i < length && int32(**(**int8)(__ccgo_up(zNum + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + int32(2) + } + nonNum = libc.BoolInt32(i < length) + zEnd = zNum + uintptr(i^int32(1)) + zNum = zNum + uintptr(libc.Int32FromUint8(enc)&libc.Int32FromInt32(1)) + } + for zNum < zEnd && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zNum)))])&int32(0x01) != 0 { + zNum = zNum + uintptr(incr) + } + if zNum < zEnd { + if int32(**(**int8)(__ccgo_up(zNum))) == int32('-') { + neg = int32(1) + zNum = zNum + uintptr(incr) + } else { + if int32(**(**int8)(__ccgo_up(zNum))) == int32('+') { + zNum = zNum + uintptr(incr) + } + } + } + zStart = zNum + for zNum < zEnd && int32(**(**int8)(__ccgo_up(zNum))) == int32('0') { + zNum = zNum + uintptr(incr) + } /* Skip leading zeros. */ + i = 0 + for { + if v4 = zNum+uintptr(i) < zEnd; v4 { + v3 = libc.Uint32FromInt8(**(**int8)(__ccgo_up(zNum + uintptr(i)))) - libc.Uint32FromUint8('0') + c = v3 + } + if !(v4 && v3 <= uint32(9)) { + break + } + u = u*uint64(10) + uint64(c) + goto _2 + _2: + ; + i = i + incr + } + if u > libc.Uint64FromInt64(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< int32(19)*incr { + v6 = int32(1) + } else { + v6 = _compare2pow63(tls, zNum, incr) + } + j = v6 + if j < 0 { + /* zNum is less than 9223372036854775808 so it fits */ + return rc + } else { + if neg != 0 { + v5 = int64(-libc.Int32FromInt32(1)) - (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< 0 { + /* zNum is greater than 9223372036854775808 so it overflows */ + return int32(2) + } else { + /* zNum is exactly 9223372036854775808. Fits if negative. The + ** special case 2 overflow if positive */ + if neg != 0 { + v6 = rc + } else { + v6 = int32(3) + } + return v6 + } + } + } + return r +} + +// C documentation +// +// /* +// ** Return the collating sequence name for a column +// */ +func _sqlite3ColumnColl(tls *libc.TLS, pCol uintptr) (r uintptr) { + var z uintptr + _ = z + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASCOLL) == 0 { + return uintptr(0) + } + z = (*TColumn)(unsafe.Pointer(pCol)).FzCnName + for **(**int8)(__ccgo_up(z)) != 0 { + z = z + 1 + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { + for cond := true; cond; cond = **(**int8)(__ccgo_up(z)) != 0 { + z = z + 1 + } + } + return z + uintptr(1) +} + +// C documentation +// +// /* +// ** Convert an SQL-style quoted string into a normal string by removing +// ** the quote characters. The conversion is done in-place. If the +// ** input does not begin with a quote character, then this routine +// ** is a no-op. +// ** +// ** The input string must be zero-terminated. A new zero-terminator +// ** is added to the dequoted string. +// ** +// ** The return value is -1 if no dequoting occurs or the length of the +// ** dequoted string, exclusive of the zero terminator, if dequoting does +// ** occur. +// ** +// ** 2002-02-14: This routine is extended to remove MS-Access style +// ** brackets from around identifiers. For example: "[a-b-c]" becomes +// ** "a-b-c". +// */ +func _sqlite3Dequote(tls *libc.TLS, z uintptr) { + var i, j, v2 int32 + var quote int8 + _, _, _, _ = i, j, quote, v2 + if z == uintptr(0) { + return + } + quote = **(**int8)(__ccgo_up(z)) + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(quote)])&libc.Int32FromInt32(0x80) != 0) { + return + } + if int32(quote) == int32('[') { + quote = int8(']') + } + i = int32(1) + j = libc.Int32FromInt32(0) + for { + if int32(**(**int8)(__ccgo_up(z + uintptr(i)))) == int32(quote) { + if int32(**(**int8)(__ccgo_up(z + uintptr(i+int32(1))))) == int32(quote) { + v2 = j + j = j + 1 + **(**int8)(__ccgo_up(z + uintptr(v2))) = quote + i = i + 1 + } else { + break + } + } else { + v2 = j + j = j + 1 + **(**int8)(__ccgo_up(z + uintptr(v2))) = **(**int8)(__ccgo_up(z + uintptr(i))) + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int8)(__ccgo_up(z + uintptr(j))) = 0 +} + +func _sqlite3DequoteExpr(tls *libc.TLS, p uintptr) { + var v1 int32 + _ = v1 + if int32(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(p + 8))))) == int32('"') { + v1 = libc.Int32FromInt32(EP_Quoted) | libc.Int32FromInt32(EP_DblQuoted) + } else { + v1 = int32(EP_Quoted) + } + **(**Tu32)(__ccgo_up(p + 4)) |= libc.Uint32FromInt32(v1) + _sqlite3Dequote(tls, *(*uintptr)(unsafe.Pointer(p + 8))) +} + +// C documentation +// +// /* +// ** Return TRUE if the given expression is a constant which would be +// ** unchanged by OP_Affinity with the affinity given in the second +// ** argument. +// ** +// ** This routine is used to determine if the OP_Affinity operation +// ** can be omitted. When in doubt return FALSE. A false negative +// ** is harmless. A false positive, however, can result in the wrong +// ** answer. +// */ +func _sqlite3ExprNeedsNoAffinityChange(tls *libc.TLS, p uintptr, aff int8) (r int32) { + var op Tu8 + var unaryMinus int32 + _, _ = op, unaryMinus + unaryMinus = 0 + if int32(aff) == int32(SQLITE_AFF_BLOB) { + return int32(1) + } + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UPLUS) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UMINUS) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UMINUS) { + unaryMinus = int32(1) + } + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + } + op = (*TExpr)(unsafe.Pointer(p)).Fop + if libc.Int32FromUint8(op) == int32(TK_REGISTER) { + op = (*TExpr)(unsafe.Pointer(p)).Fop2 + } + switch libc.Int32FromUint8(op) { + case int32(TK_INTEGER): + return libc.BoolInt32(int32(aff) >= int32(SQLITE_AFF_NUMERIC)) + case int32(TK_FLOAT): + return libc.BoolInt32(int32(aff) >= int32(SQLITE_AFF_NUMERIC)) + case int32(TK_STRING): + return libc.BoolInt32(!(unaryMinus != 0) && int32(aff) == int32(SQLITE_AFF_TEXT)) + case int32(TK_BLOB): + return libc.BoolInt32(!(unaryMinus != 0)) + case int32(TK_COLUMN): + /* p cannot be part of a CHECK constraint */ + return libc.BoolInt32(int32(aff) >= int32(SQLITE_AFF_NUMERIC) && int32((*TExpr)(unsafe.Pointer(p)).FiColumn) < 0) + default: + return 0 + } + return r +} + +// C documentation +// +// /* +// ** Argument p points to a buffer containing utf-8 text that is n bytes in +// ** size. Return the number of bytes in the nChar character prefix of the +// ** buffer, or 0 if there are less than nChar characters in total. +// */ +func _sqlite3Fts5IndexCharlenToBytelen(tls *libc.TLS, p uintptr, nByte int32, nChar int32) (r int32) { + var i, n, v2 int32 + _, _, _ = i, n, v2 + n = 0 + i = 0 + for { + if !(i < nChar) { + break + } + if n >= nByte { + return 0 + } /* Input contains fewer than nChar chars */ + v2 = n + n = n + 1 + if libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(p + uintptr(v2))))) >= int32(0xc0) { + if n >= nByte { + return 0 + } + for int32(**(**int8)(__ccgo_up(p + uintptr(n))))&int32(0xc0) == int32(0x80) { + n = n + 1 + if n >= nByte { + if i+int32(1) == nChar { + break + } + return 0 + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + return n +} + +// C documentation +// +// /* +// ** Return a simple checksum value based on the arguments. +// */ +func _sqlite3Fts5IndexEntryCksum(tls *libc.TLS, iRowid Ti64, iCol int32, iPos int32, iIdx int32, pTerm uintptr, nTerm int32) (r Tu64) { + var i int32 + var ret Tu64 + _, _ = i, ret + ret = libc.Uint64FromInt64(iRowid) + ret = ret + (ret<= 0 { + ret = ret + (ret< uint64(4294967296) { + **(**Tu32)(__ccgo_up(pI)) = uint32(0) + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + if i == 0 || int32(**(**int8)(__ccgo_up(z + uintptr(i)))) != 0 { + **(**Tu32)(__ccgo_up(pI)) = uint32(0) + return 0 + } + **(**Tu32)(__ccgo_up(pI)) = uint32(v) + return int32(1) +} + +/* +** The variable-length integer encoding is as follows: +** +** KEY: +** A = 0xxxxxxx 7 bits of data and one flag bit +** B = 1xxxxxxx 7 bits of data and one flag bit +** C = xxxxxxxx 8 bits of data +** +** 7 bits - A +** 14 bits - BA +** 21 bits - BBA +** 28 bits - BBBA +** 35 bits - BBBBA +** 42 bits - BBBBBA +** 49 bits - BBBBBBA +** 56 bits - BBBBBBBA +** 64 bits - BBBBBBBBC + */ + +// C documentation +// +// /* +// ** Convert a BLOB literal of the form "x'hhhhhh'" into its binary +// ** value. Return a pointer to its binary value. Space to hold the +// ** binary value has been obtained from malloc and must be freed by +// ** the calling routine. +// */ +func _sqlite3HexToBlob(tls *libc.TLS, db uintptr, z uintptr, n int32) (r uintptr) { + var i int32 + var zBlob uintptr + _, _ = i, zBlob + zBlob = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(n/int32(2)+int32(1))) + n = n - 1 + if zBlob != 0 { + i = 0 + for { + if !(i < n) { + break + } + **(**int8)(__ccgo_up(zBlob + uintptr(i/int32(2)))) = int8(libc.Int32FromUint8(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(z + uintptr(i))))))<pIdxEpr. +// ** If it is, then resolve the expression by reading from the index and +// ** return the register into which the value has been read. If pExpr is +// ** not an indexed expression, then return negative. +// */ +func _sqlite3IndexedExprLookup(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) (r int32) { + var addr, iDataCur int32 + var exprAff Tu8 + var p, v uintptr + _, _, _, _, _ = addr, exprAff, iDataCur, p, v + p = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + for { + if !(p != 0) { + break + } + iDataCur = (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur + if iDataCur < 0 { + goto _1 + } + if (*TParse)(unsafe.Pointer(pParse)).FiSelfTab != 0 { + if (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur != (*TParse)(unsafe.Pointer(pParse)).FiSelfTab-int32(1) { + goto _1 + } + iDataCur = -int32(1) + } + if _sqlite3ExprCompare(tls, uintptr(0), pExpr, (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr, iDataCur) != 0 { + goto _1 + } + exprAff = libc.Uint8FromInt8(_sqlite3ExprAffinity(tls, pExpr)) + if libc.Int32FromUint8(exprAff) <= int32(SQLITE_AFF_BLOB) && libc.Int32FromUint8((*TIndexedExpr)(unsafe.Pointer(p)).Faff) != int32(SQLITE_AFF_BLOB) || libc.Int32FromUint8(exprAff) == int32(SQLITE_AFF_TEXT) && libc.Int32FromUint8((*TIndexedExpr)(unsafe.Pointer(p)).Faff) != int32(SQLITE_AFF_TEXT) || libc.Int32FromUint8(exprAff) >= int32(SQLITE_AFF_NUMERIC) && libc.Int32FromUint8((*TIndexedExpr)(unsafe.Pointer(p)).Faff) != int32(SQLITE_AFF_NUMERIC) { + /* Affinity mismatch on a generated column */ + goto _1 + } + /* Functions that might set a subtype should not be replaced by the + ** value taken from an expression index if they are themselves an + ** argument to another scalar function or aggregate. + ** https://sqlite.org/forum/forumpost/68d284c86b082c3e */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromUint32(EP_SubtArg) != uint32(0) && _sqlite3ExprCanReturnSubtype(tls, pParse, pExpr) != 0 { + goto _1 + } + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if (*TIndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow != 0 { + /* If the index is on a NULL row due to an outer join, then we + ** cannot extract the value from the index. The value must be + ** computed using the original expression. */ + addr = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNullRow), (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur, addr+int32(3), target) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur, (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol, target) + _sqlite3VdbeGoto(tls, v, 0) + p = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr = uintptr(0) + _sqlite3ExprCode(tls, pParse, pExpr, target) + (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr = p + _sqlite3VdbeJumpHere(tls, v, addr+int32(2)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur, (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol, target) + } + return target + goto _1 + _1: + ; + p = (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext + } + return -int32(1) /* Not found */ +} + +// C documentation +// +// /* +// ** This routine implements the uncommon and slower path for +// ** sqlite3MemRealValueRC() that has to deal with input strings +// ** that are not UTF8 or that are not zero-terminated. It is +// ** broken out into a separate no-inline routine so that the +// ** main sqlite3MemRealValueRC() routine can avoid unnecessary +// ** stack pushes. +// ** +// ** A text->float translation of pMem->z is written into *pValue. +// ** +// ** Result code invariants: +// ** +// ** rc==0 => ERROR: Input string not well-formed, or OOM +// ** rc<0 => Some prefix of the input is well-formed +// ** rc>0 => All of the input is well-formed +// ** (rc&2)==0 => The number is expressed as an integer, with no +// ** decimal point or eNNN suffix. +// */ +func _sqlite3MemRealValueRCSlowPath(tls *libc.TLS, pMem uintptr, pValue uintptr) (r int32) { + var i, j, n, rc, v2 int32 + var z, zCopy, zCopy1 uintptr + _, _, _, _, _, _, _, _ = i, j, n, rc, z, zCopy, zCopy1, v2 + rc = SQLITE_OK + **(**float64)(__ccgo_up(pValue)) = float64(0) + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) == int32(SQLITE_UTF8) { + zCopy = _sqlite3DbStrNDup(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn)) + if zCopy != 0 { + rc = _sqlite3AtoF(tls, zCopy, pValue) + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, zCopy) + } + return rc + } else { + n = (*TMem)(unsafe.Pointer(pMem)).Fn & ^libc.Int32FromInt32(1) + zCopy1 = _sqlite3DbMallocRaw(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, libc.Uint64FromInt32(n/int32(2)+int32(2))) + if zCopy1 != 0 { + z = (*TMem)(unsafe.Pointer(pMem)).Fz + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) == int32(SQLITE_UTF16LE) { + v2 = libc.Int32FromInt32(0) + j = v2 + i = v2 + for { + if !(i < n-int32(1)) { + break + } + **(**int8)(__ccgo_up(zCopy1 + uintptr(j))) = **(**int8)(__ccgo_up(z + uintptr(i))) + if int32(**(**int8)(__ccgo_up(z + uintptr(i+int32(1))))) != 0 { + break + } + goto _1 + _1: + ; + i = i + int32(2) + j = j + 1 + } + } else { + v2 = libc.Int32FromInt32(0) + j = v2 + i = v2 + for { + if !(i < n-int32(1)) { + break + } + if int32(**(**int8)(__ccgo_up(z + uintptr(i)))) != 0 { + break + } + **(**int8)(__ccgo_up(zCopy1 + uintptr(j))) = **(**int8)(__ccgo_up(z + uintptr(i+int32(1)))) + goto _3 + _3: + ; + i = i + int32(2) + j = j + 1 + } + } + **(**int8)(__ccgo_up(zCopy1 + uintptr(j))) = 0 + rc = _sqlite3AtoF(tls, zCopy1, pValue) + if i < n { + rc = -int32(100) + } + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, zCopy1) + } + return rc + } + return r +} + +func _sqlite3StrAccumFinish(tls *libc.TLS, p uintptr) (r uintptr) { + if (*TStrAccum)(unsafe.Pointer(p)).FzText != 0 { + **(**int8)(__ccgo_up((*TStrAccum)(unsafe.Pointer(p)).FzText + uintptr((*TStrAccum)(unsafe.Pointer(p)).FnChar))) = 0 + if (*TStrAccum)(unsafe.Pointer(p)).FmxAlloc > uint32(0) && !(libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED) != libc.Int32FromInt32(0)) { + return _strAccumFinishRealloc(tls, p) + } + } + return (*TStrAccum)(unsafe.Pointer(p)).FzText +} + +// C documentation +// +// /* +// ** Compute an 8-bit hash on a string that is insensitive to case differences +// */ +func _sqlite3StrIHash(tls *libc.TLS, z uintptr) (r Tu8) { + var h Tu8 + _ = h + h = uint8(0) + if z == uintptr(0) { + return uint8(0) + } + for **(**int8)(__ccgo_up(z)) != 0 { + h = libc.Uint8FromInt32(int32(h) + libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z)))])) + z = z + 1 + } + return h +} + +// C documentation +// +// /* +// ** Exported version of applyAffinity(). This one works on sqlite3_value*, +// ** not the internal Mem* type. +// */ +func _sqlite3ValueApplyAffinity(tls *libc.TLS, pVal uintptr, affinity Tu8, enc Tu8) { + _applyAffinity(tls, pVal, libc.Int8FromUint8(affinity), enc) +} + +// C documentation +// +// /* +// ** Move data out of a btree key or data field and into a Mem structure. +// ** The data is payload from the entry that pCur is currently pointing +// ** to. offset and amt determine what portion of the data or key to retrieve. +// ** The result is written into the pMem element. +// ** +// ** The pMem object must have been initialized. This routine will use +// ** pMem->zMalloc to hold the content from the btree, if possible. New +// ** pMem->zMalloc space will be allocated if necessary. The calling routine +// ** is responsible for making sure that the pMem object is eventually +// ** destroyed. +// ** +// ** If this routine fails for any reason (malloc returns NULL or unable +// ** to read from the disk) then the pMem is left in an inconsistent state. +// */ +func _sqlite3VdbeMemFromBtree(tls *libc.TLS, pCur uintptr, offset Tu32, amt Tu32, pMem uintptr) (r int32) { + var rc, v1 int32 + _, _ = rc, v1 + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Null) + if amt >= uint32(SQLITE_MAX_ALLOCATION_SIZE) { + return int32(SQLITE_NOMEM) + } + if uint64(amt)+uint64(offset) > libc.Uint64FromInt64(_sqlite3BtreeMaxRecordSize(tls, pCur)) { + return _sqlite3CorruptError(tls, int32(86966)) + } + v1 = _sqlite3VdbeMemClearAndResize(tls, pMem, libc.Int32FromUint32(amt+uint32(1))) + rc = v1 + if SQLITE_OK == v1 { + rc = _sqlite3BtreePayload(tls, pCur, offset, amt, (*TMem)(unsafe.Pointer(pMem)).Fz) + if rc == SQLITE_OK { + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr(amt))) = 0 /* Overrun area used when reading malformed records */ + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Blob) + (*TMem)(unsafe.Pointer(pMem)).Fn = libc.Int32FromUint32(amt) + } else { + _sqlite3VdbeMemRelease(tls, pMem) + } + } + return rc +} + +// C documentation +// +// /* +// ** The hashing function. +// */ +func _strHash(tls *libc.TLS, z uintptr) (r uint32) { + var h uint32 + var v1 uintptr + _, _ = h, v1 + h = uint32(0) + for **(**int8)(__ccgo_up(z)) != 0 { /*OPTIMIZATION-IF-TRUE*/ + /* Knuth multiplicative hashing. (Sorting & Searching, p. 510). + ** 0x9e3779b1 is 2654435761 which is the closest prime number to + ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. + ** + ** Only bits 0xdf for ASCII and bits 0xbf for EBCDIC each octet are + ** hashed since the omitted bits determine the upper/lower case difference. + */ + v1 = z + z = z + 1 + h = h + libc.Uint32FromInt32(int32(0xdf)&libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(v1))))) + h = h * uint32(0x9e3779b1) + } + return h +} + +// C documentation +// +// /* +// ** We already know that pExpr is a binary operator where both operands are +// ** column references. This routine checks to see if pExpr is an equivalence +// ** relation: +// ** 1. The SQLITE_Transitive optimization must be enabled +// ** 2. Must be either an == or an IS operator +// ** 3. Not originating in the ON clause of an OUTER JOIN +// ** 4. The operator is not IS or else the query does not contain RIGHT JOIN +// ** 5. The affinities of A and B must be compatible +// ** 6. Both operands use the same collating sequence, and they must not +// ** use explicit COLLATE clauses. +// ** If this routine returns TRUE, that means that the RHS can be substituted +// ** for the LHS anyplace else in the WHERE clause where the LHS column occurs. +// ** This is an optimization. No harm comes from returning 0. But if 1 is +// ** returned when it should not be, then incorrect answers might result. +// */ +func _termIsEquivalence(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSrc uintptr) (r int32) { + var aff1, aff2 int8 + _, _ = aff1, aff2 + if !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Transitive)) == libc.Uint32FromInt32(0)) { + return 0 + } /* (1) */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_EQ) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_IS) { + return 0 + } /* (2) */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_Collate)) != uint32(0) { + return 0 + } /* (3) */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IS) && (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc >= int32(2) && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + return 0 /* (4) */ + } + aff1 = _sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + aff2 = _sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if int32(aff1) != int32(aff2) && (!(int32(aff1) >= libc.Int32FromInt32(SQLITE_AFF_NUMERIC)) || !(int32(aff2) >= libc.Int32FromInt32(SQLITE_AFF_NUMERIC))) { + return 0 /* (5) */ + } + if !(_sqlite3ExprCollSeqMatch(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) != 0) { + return 0 /* (6) */ + } + return int32(1) +} + +// C documentation +// +// /* +// ** Duplicate a range of text from an SQL statement, then convert all +// ** whitespace characters into ordinary space characters. +// */ +func _triggerSpanDup(tls *libc.TLS, db uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var i int32 + var z uintptr + _, _ = i, z + z = _sqlite3DbSpanDup(tls, db, zStart, zEnd) + if z != 0 { + i = 0 + for { + if !(**(**int8)(__ccgo_up(z + uintptr(i))) != 0) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i))))])&int32(0x01) != 0 { + **(**int8)(__ccgo_up(z + uintptr(i))) = int8(' ') + } + goto _1 + _1: + ; + i = i + 1 + } + } + return z +} + +// C documentation +// +// /* +// ** Implementation of the upper() and lower() SQL functions. +// */ +func _upperFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var i, n int32 + var z1, z2 uintptr + _, _, _, _ = i, n, z1, z2 + _ = argc + z2 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + /* Verify that the call to _bytes() does not invalidate the _text() pointer */ + if z2 != 0 { + z1 = _contextMalloc(tls, context, int64(n)+int64(1)) + if z1 != 0 { + i = 0 + for { + if !(i < n) { + break + } + **(**int8)(__ccgo_up(z1 + uintptr(i))) = int8(int32(**(**int8)(__ccgo_up(z2 + uintptr(i)))) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z2 + uintptr(i))))]) & libc.Int32FromInt32(0x20))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_result_text(tls, context, z1, n, __ccgo_fp(Xsqlite3_free)) + } + } +} diff --git a/internal/engine/lib/sqlite_g_0000000000010022.go b/internal/engine/lib/sqlite_g_0000000000010022.go new file mode 100644 index 0000000..ea67a89 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000010022.go @@ -0,0 +1,19 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && arm64) || (openbsd && arm64) + +package sqlite3 + +const __ARM_ALIGN_MAX_STACK_PWR = 4 + +const __ARM_FEATURE_DIRECTED_ROUNDING = 1 + +const __ARM_FEATURE_DIV = 1 + +const __ARM_NEON_FP = 14 + +const __ARM_STATE_ZA = 1 + +const __ARM_STATE_ZT0 = 1 + +const __HAVE_FUNCTION_MULTI_VERSIONING = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000010032.go b/internal/engine/lib/sqlite_g_0000000000010032.go new file mode 100644 index 0000000..168a826 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000010032.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && arm) || (freebsd && arm64) || (openbsd && arm64) + +package sqlite3 + +const __ARM_FEATURE_LDREX = 15 + +const __BITINT_MAXWIDTH__ = 128 diff --git a/internal/engine/lib/sqlite_g_0000000000010222.go b/internal/engine/lib/sqlite_g_0000000000010222.go new file mode 100644 index 0000000..8b0df35 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000010222.go @@ -0,0 +1,27 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && arm64) || (linux && arm64) || (openbsd && arm64) + +package sqlite3 + +const __AARCH64EL__ = 1 + +const __AARCH64_CMODEL_SMALL__ = 1 + +const __ARM_64BIT_STATE = 1 + +const __ARM_ARCH = 8 + +const __ARM_ARCH_ISA_A64 = 1 + +const __ARM_FEATURE_FMA = 1 + +const __ARM_FEATURE_IDIV = 1 + +const __ARM_FEATURE_NUMERIC_MAXMIN = 1 + +const __ARM_FP = 14 + +const __ARM_PCS_AAPCS64 = 1 + +const __aarch64__ = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000010232.go b/internal/engine/lib/sqlite_g_0000000000010232.go new file mode 100644 index 0000000..db2981f --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000010232.go @@ -0,0 +1,13 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && arm) || (freebsd && arm64) || (linux && arm64) || (openbsd && arm64) + +package sqlite3 + +const __ARM_ARCH_PROFILE = 65 + +const __ARM_FP16_ARGS = 1 + +const __ARM_FP16_FORMAT_IEEE = 1 + +const __ARM_NEON = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000010332.go b/internal/engine/lib/sqlite_g_0000000000010332.go new file mode 100644 index 0000000..d562320 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000010332.go @@ -0,0 +1,11 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && arm) || (freebsd && arm64) || (linux && arm) || (linux && arm64) || (openbsd && arm64) + +package sqlite3 + +const __ARM_FEATURE_CLZ = 1 + +const __ARM_SIZEOF_MINIMAL_ENUM = 4 + +const __ARM_SIZEOF_WCHAR_T = 4 diff --git a/internal/engine/lib/sqlite_g_0000000000011620.go b/internal/engine/lib/sqlite_g_0000000000011620.go new file mode 100644 index 0000000..c19e1f8 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000011620.go @@ -0,0 +1,21 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && arm64) || (linux && arm64) || (linux && loong64) || (linux && riscv64) || (openbsd && arm64) + +package sqlite3 + +const __DECIMAL_DIG__ = 36 + +const __LDBL_DECIMAL_DIG__ = 36 + +const __LDBL_DIG__ = 33 + +const __LDBL_MANT_DIG__ = 113 + +const __LDBL_MAX_10_EXP__ = 4932 + +const __LDBL_MAX_EXP__ = 16384 + +const __LDBL_MIN_10_EXP__ = -4931 + +const __LDBL_MIN_EXP__ = -16381 diff --git a/internal/engine/lib/sqlite_g_0000000000011a20.go b/internal/engine/lib/sqlite_g_0000000000011a20.go new file mode 100644 index 0000000..7ffd8ed --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000011a20.go @@ -0,0 +1,81 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && arm64) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Compile the UTF-16 encoded SQL statement zSql into a statement handle. +// */ +func _sqlite3Prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags Tu32, ppStmt uintptr, pzTail uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var chars_parsed, rc, sz, sz1 int32 + var z, z1, zSql8 uintptr + var _ /* zTail8 at bp+0 */ uintptr + _, _, _, _, _, _, _ = chars_parsed, rc, sz, sz1, z, z1, zSql8 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + if !(_sqlite3SafetyCheckOk(tls, db) != 0) || zSql == uintptr(0) { + return _sqlite3MisuseError(tls, int32(148771)) + } + /* Make sure nBytes is non-negative and correct. It should be the + ** number of bytes until the end of the input buffer or until the first + ** U+0000 character. If the input nBytes is odd, convert it into + ** an even number. If the input nBytes is negative, then the input + ** must be terminated by at least one U+0000 character */ + if nBytes >= 0 { + z = zSql + sz = 0 + for { + if !(sz < nBytes && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(sz)))) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(sz+int32(1))))) != 0)) { + break + } + goto _1 + _1: + ; + sz = sz + int32(2) + } + nBytes = sz + } else { + z1 = zSql + sz1 = 0 + for { + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z1 + uintptr(sz1)))) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z1 + uintptr(sz1+int32(1))))) != 0) { + break + } + goto _2 + _2: + ; + sz1 = sz1 + int32(2) + } + nBytes = sz1 + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + zSql8 = _sqlite3Utf16to8(tls, db, zSql, nBytes, uint8(SQLITE_UTF16LE)) + if zSql8 != 0 { + rc = _sqlite3LockAndPrepare(tls, db, zSql8, -int32(1), prepFlags, uintptr(0), ppStmt, bp) + } + if **(**uintptr)(__ccgo_up(bp)) != 0 && pzTail != 0 { + /* If sqlite3_prepare returns a tail pointer, we calculate the + ** equivalent pointer into the UTF-16 string by counting the unicode + ** characters between zSql8 and zTail8, and then returning a pointer + ** the same number of characters into the UTF-16 string. + */ + chars_parsed = _sqlite3Utf8CharLen(tls, zSql8, int32(int64(**(**uintptr)(__ccgo_up(bp)))-int64(zSql8))) + **(**uintptr)(__ccgo_up(pzTail)) = zSql + uintptr(_sqlite3Utf16ByteLen(tls, zSql, nBytes, chars_parsed)) + } + _sqlite3DbFree(tls, db, zSql8) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} diff --git a/internal/engine/lib/sqlite_g_0000000000012a23.go b/internal/engine/lib/sqlite_g_0000000000012a23.go new file mode 100644 index 0000000..9e84e78 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000012a23.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && arm64) || (linux && arm64) || (linux && ppc64le) || (linux && s390x) || (openbsd && arm64) + +package sqlite3 + +const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000013a00.go b/internal/engine/lib/sqlite_g_0000000000013a00.go new file mode 100644 index 0000000..c7f2b13 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000013a00.go @@ -0,0 +1,164 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Rtree virtual table module xBestIndex method. There are three +// ** table scan strategies to choose from (in order from most to +// ** least desirable): +// ** +// ** idxNum idxStr Strategy +// ** ------------------------------------------------ +// ** 1 Unused Direct lookup by rowid. +// ** 2 See below R-tree query or full-table scan. +// ** ------------------------------------------------ +// ** +// ** If strategy 1 is used, then idxStr is not meaningful. If strategy +// ** 2 is used, idxStr is formatted to contain 2 bytes for each +// ** constraint used. The first two bytes of idxStr correspond to +// ** the constraint in sqlite3_index_info.aConstraintUsage[] with +// ** (argvIndex==1) etc. +// ** +// ** The first of each pair of bytes in idxStr identifies the constraint +// ** operator as follows: +// ** +// ** Operator Byte Value +// ** ---------------------- +// ** = 0x41 ('A') +// ** <= 0x42 ('B') +// ** < 0x43 ('C') +// ** >= 0x44 ('D') +// ** > 0x45 ('E') +// ** MATCH 0x46 ('F') +// ** ---------------------- +// ** +// ** The second of each pair of bytes identifies the coordinate column +// ** to which the constraint applies. The leftmost coordinate column +// ** is 'a', the second from the left 'b' etc. +// */ +func _rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bMatch, iIdx, ii, jj, rc, v4 int32 + var doOmit, op Tu8 + var nRow Ti64 + var p, pRtree uintptr + var _ /* zIdxStr at bp+0 */ [41]uint8 + _, _, _, _, _, _, _, _, _, _, _ = bMatch, doOmit, iIdx, ii, jj, nRow, op, p, pRtree, rc, v4 + pRtree = tab + rc = SQLITE_OK + bMatch = 0 /* Estimated rows returned by this scan */ + iIdx = 0 + libc.Xmemset(tls, bp, 0, uint64(41)) + /* Check if there exists a MATCH constraint - even an unusable one. If there + ** is, do not consider the lookup-by-rowid plan as using such a plan would + ** require the VDBE to evaluate the MATCH constraint, which is not currently + ** possible. */ + ii = 0 + for { + if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + if libc.Int32FromUint8((**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12))).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH) { + bMatch = int32(1) + } + goto _1 + _1: + ; + ii = ii + 1 + } + ii = 0 + for { + if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint && iIdx < libc.Int32FromUint64(libc.Uint64FromInt64(41)-libc.Uint64FromInt32(1))) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12 + if bMatch == 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) { + jj = 0 + for { + if !(jj < ii) { + break + } + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).FargvIndex = 0 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).Fomit = uint8(0) + goto _3 + _3: + ; + jj = jj + 1 + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8))).Fomit = uint8(1) + /* This strategy involves a two rowid lookups on an B-Tree structures + ** and then a linear search of an R-Tree node. This should be + ** considered almost as quick as a direct rowid lookup (for which + ** sqlite uses an internal cost of 0.0). It is expected to return + ** a single row. + */ + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(30) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = int32(SQLITE_INDEX_SCAN_UNIQUE) + return SQLITE_OK + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 && ((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn > 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH)) { + doOmit = uint8(1) + switch libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) { + case int32(SQLITE_INDEX_CONSTRAINT_EQ): + op = uint8(RTREE_EQ) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_GT): + op = uint8(RTREE_GT) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_LE): + op = uint8(RTREE_LE) + case int32(SQLITE_INDEX_CONSTRAINT_LT): + op = uint8(RTREE_LT) + doOmit = uint8(0) + case int32(SQLITE_INDEX_CONSTRAINT_GE): + op = uint8(RTREE_GE) + case int32(SQLITE_INDEX_CONSTRAINT_MATCH): + op = uint8(RTREE_MATCH) + default: + op = uint8(0) + break + } + if op != 0 { + v4 = iIdx + iIdx = iIdx + 1 + (**(**[41]uint8)(__ccgo_up(bp)))[v4] = op + v4 = iIdx + iIdx = iIdx + 1 + (**(**[41]uint8)(__ccgo_up(bp)))[v4] = libc.Uint8FromInt32((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn - libc.Int32FromInt32(1) + libc.Int32FromUint8('0')) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).FargvIndex = iIdx / int32(2) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8))).Fomit = doOmit + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(2) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = int32(1) + if iIdx > 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = Xsqlite3_malloc(tls, iIdx+int32(1)) + if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr, bp, libc.Uint64FromInt32(iIdx+int32(1))) + } + nRow = (*TRtree)(unsafe.Pointer(pRtree)).FnRowEst >> (iIdx / int32(2)) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(libc.Float64FromFloat64(6) * float64(nRow)) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = nRow + return rc +} diff --git a/internal/engine/lib/sqlite_g_0000000000013a20.go b/internal/engine/lib/sqlite_g_0000000000013a20.go new file mode 100644 index 0000000..51c418e --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000013a20.go @@ -0,0 +1,8453 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && arm64) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type TColumn = struct { + FzCnName uintptr + F__ccgo8 uint8 + Faffinity uint8 + FszEst Tu8 + FhName Tu8 + FiDflt Tu16 + FcolFlags Tu16 +} + +// C documentation +// +// /* +// ** A structure for holding a single date and time. +// */ +type TDateTime = struct { + FiJD Tsqlite3_int64 + FY int32 + FM int32 + FD int32 + Fh int32 + Fm int32 + Ftz int32 + Fs float64 + FvalidJD uint8 + FvalidYMD uint8 + FvalidHMS uint8 + FnFloor uint8 + F__ccgo44 uint8 +} + +type TExpr = struct { + Fop Tu8 + FaffExpr uint8 + Fop2 Tu8 + Fflags Tu32 + Fu struct { + FiValue [0]int32 + FzToken uintptr + } + FpLeft uintptr + FpRight uintptr + Fx struct { + FpSelect [0]uintptr + FpList uintptr + } + FnHeight int32 + FiTable int32 + FiColumn TynVar + FiAgg Ti16 + Fw struct { + FiOfst [0]int32 + FiJoin int32 + } + FpAggInfo uintptr + Fy struct { + FpWin [0]uintptr + FnReg [0]int32 + Fsub [0]struct { + FiAddr int32 + FregReturn int32 + } + FpTab uintptr + } +} + +type TJsonString = struct { + FpCtx uintptr + FzBuf uintptr + FnAlloc Tu64 + FnUsed Tu64 + FbStatic Tu8 + FeErr Tu8 + FzSpace [100]uint8 +} + +// C documentation +// +// /* +// ** Each open file is managed by a separate instance of the "Pager" structure. +// */ +type TPager = struct { + FpVfs uintptr + FexclusiveMode Tu8 + FjournalMode Tu8 + FuseJournal Tu8 + FnoSync Tu8 + FfullSync Tu8 + FextraSync Tu8 + FsyncFlags Tu8 + FwalSyncFlags Tu8 + FtempFile Tu8 + FnoLock Tu8 + FreadOnly Tu8 + FmemDb Tu8 + FmemVfs Tu8 + FeState Tu8 + FeLock Tu8 + FchangeCountDone Tu8 + FsetSuper Tu8 + FdoNotSpill Tu8 + FsubjInMemory Tu8 + FbUseFetch Tu8 + FhasHeldSharedLock Tu8 + FdbSize TPgno + FdbOrigSize TPgno + FdbFileSize TPgno + FdbHintSize TPgno + FerrCode int32 + FnRec int32 + FcksumInit Tu32 + FnSubRec Tu32 + FpInJournal uintptr + Ffd uintptr + Fjfd uintptr + Fsjfd uintptr + FjournalOff Ti64 + FjournalHdr Ti64 + FpBackup uintptr + FaSavepoint uintptr + FnSavepoint int32 + FiDataVersion Tu32 + FdbFileVers [16]uint8 + FnMmapOut int32 + FszMmap Tsqlite3_int64 + FpMmapFreelist uintptr + FnExtra Tu16 + FnReserve Ti16 + FvfsFlags Tu32 + FsectorSize Tu32 + FmxPgno TPgno + FlckPgno TPgno + FpageSize Ti64 + FjournalSizeLimit Ti64 + FzFilename uintptr + FzJournal uintptr + FxBusyHandler uintptr + FpBusyHandlerArg uintptr + FaStat [4]Tu32 + FxReiniter uintptr + FxGet uintptr + FpTmpSpace uintptr + FpPCache uintptr + FpWal uintptr + FzWal uintptr +} + +type Tsqlite3rbu = struct { + FeStage int32 + FdbMain uintptr + FdbRbu uintptr + FzTarget uintptr + FzRbu uintptr + FzState uintptr + FzStateDb [5]uint8 + Frc int32 + FzErrmsg uintptr + FnStep int32 + FnProgress Tsqlite3_int64 + Fobjiter TRbuObjIter + FzVfsName uintptr + FpTargetFd uintptr + FnPagePerSector int32 + FiOalSz Ti64 + FnPhaseOneStep Ti64 + FpRenameArg uintptr + FxRename uintptr + FiMaxFrame Tu32 + FmLock Tu32 + FnFrame int32 + FnFrameAlloc int32 + FaFrame uintptr + Fpgsz int32 + FaBuf uintptr + FiWalCksum Ti64 + FszTemp Ti64 + FszTempLimit Ti64 + FnRbu int32 + FpRbuFd uintptr +} + +// C documentation +// +// /* +// ** Allocate memory to hold names for a database, journal file, WAL file, +// ** and query parameters. The pointer returned is valid for use by +// ** sqlite3_filename_database() and sqlite3_uri_parameter() and related +// ** functions. +// ** +// ** Memory layout must be compatible with that generated by the pager +// ** and expected by sqlite3_uri_parameter() and databaseName(). +// */ +func Xsqlite3_create_filename(tls *libc.TLS, zDatabase uintptr, zJournal uintptr, zWal uintptr, nParam int32, azParam uintptr) (r uintptr) { + var i int32 + var nByte Tsqlite3_int64 + var p, pResult, v2 uintptr + _, _, _, _, _ = i, nByte, p, pResult, v2 + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, zDatabase) + libc.Xstrlen(tls, zJournal) + libc.Xstrlen(tls, zWal) + uint64(10)) + i = 0 + for { + if !(i < nParam*int32(2)) { + break + } + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(azParam + uintptr(i)*8)))+libc.Uint64FromInt32(1))) + goto _1 + _1: + ; + i = i + 1 + } + v2 = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + p = v2 + pResult = v2 + if p == uintptr(0) { + return uintptr(0) + } + libc.Xmemset(tls, p, 0, uint64(4)) + p = p + uintptr(4) + p = _appendText(tls, p, zDatabase) + i = 0 + for { + if !(i < nParam*int32(2)) { + break + } + p = _appendText(tls, p, **(**uintptr)(__ccgo_up(azParam + uintptr(i)*8))) + goto _3 + _3: + ; + i = i + 1 + } + v2 = p + p = p + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(0) + p = _appendText(tls, p, zJournal) + p = _appendText(tls, p, zWal) + v2 = p + p = p + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(0) + v2 = p + p = p + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(0) + return pResult + uintptr(4) +} + +// C documentation +// +// /* +// ** Return the sqlite3_file for the main database given the name +// ** of the corresponding WAL or Journal name as passed into +// ** xOpen. +// */ +func Xsqlite3_database_file_object(tls *libc.TLS, zName uintptr) (r uintptr) { + var p, pPager uintptr + _, _ = p, pPager + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(1))))) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(2))))) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(3))))) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(4))))) != 0 { + zName = zName - 1 + } + p = zName - uintptr(4) - uintptr(8) + pPager = **(**uintptr)(__ccgo_up(p)) + return (*TPager)(unsafe.Pointer(pPager)).Ffd +} + +// C documentation +// +// /* +// ** This function is called from within a pre-update callback to retrieve +// ** a field of the row currently being updated or deleted. +// */ +func Xsqlite3_preupdate_old(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aRec, p, pCol, pDflt, pMem, v1 uintptr + var iStore, nByte, rc int32 + var nRec Tu32 + var _ /* pVal at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aRec, iStore, nByte, nRec, p, pCol, pDflt, pMem, rc, v1 + rc = SQLITE_OK + iStore = 0 + p = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate + /* Test that this call is being made from within an SQLITE_DELETE or + ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */ + if !(p != 0) || (*TPreUpdate)(unsafe.Pointer(p)).Fop == int32(SQLITE_INSERT) { + rc = _sqlite3MisuseError(tls, int32(95782)) + goto preupdate_old_out + } + if (*TPreUpdate)(unsafe.Pointer(p)).FpPk != 0 { + iStore = _sqlite3TableColumnToIndex(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpPk, iIdx) + } else { + if iIdx >= int32((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FnCol) { + rc = _sqlite3MisuseError(tls, int32(95788)) + goto preupdate_old_out + } else { + iStore = int32(_sqlite3TableColumnToStorage(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpTab, int16(iIdx))) + } + } + if iStore >= int32((*TVdbeCursor)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField) || iStore < 0 { + rc = int32(SQLITE_RANGE) + goto preupdate_old_out + } + if iIdx == int32((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FiPKey) { + v1 = p + 80 + pMem = v1 + **(**uintptr)(__ccgo_up(ppValue)) = v1 + _sqlite3VdbeMemSetInt64(tls, pMem, (*TPreUpdate)(unsafe.Pointer(p)).FiKey1) + } else { + /* If the old.* record has not yet been loaded into memory, do so now. */ + if (*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked == uintptr(0) { + nRec = _sqlite3BtreePayloadSize(tls, *(*uintptr)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpCsr + 48))) + aRec = _sqlite3DbMallocRaw(tls, db, uint64(nRec)) + if !(aRec != 0) { + goto preupdate_old_out + } + rc = _sqlite3BtreePayload(tls, *(*uintptr)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpCsr + 48)), uint32(0), nRec, aRec) + if rc == SQLITE_OK { + (*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked = _vdbeUnpackRecord(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpKeyinfo, libc.Int32FromUint32(nRec), aRec) + if !((*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked != 0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc != SQLITE_OK { + _sqlite3DbFree(tls, db, aRec) + goto preupdate_old_out + } + (*TPreUpdate)(unsafe.Pointer(p)).FaRecord = aRec + } + v1 = (*TUnpackedRecord)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked)).FaMem + uintptr(iStore)*56 + **(**uintptr)(__ccgo_up(ppValue)) = v1 + pMem = v1 + if iStore >= libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpUnpacked)).FnField) { + /* This occurs when the table has been extended using ALTER TABLE + ** ADD COLUMN. The value to return is the default value of the column. */ + pCol = (*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol + uintptr(iIdx)*16 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) > 0 { + if (*TPreUpdate)(unsafe.Pointer(p)).FapDflt == uintptr(0) { + nByte = libc.Int32FromUint64(uint64(8) * libc.Uint64FromInt16((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FnCol)) + (*TPreUpdate)(unsafe.Pointer(p)).FapDflt = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt32(nByte)) + if (*TPreUpdate)(unsafe.Pointer(p)).FapDflt == uintptr(0) { + goto preupdate_old_out + } + } + if **(**uintptr)(__ccgo_up((*TPreUpdate)(unsafe.Pointer(p)).FapDflt + uintptr(iIdx)*8)) == uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pDflt = (*(*TExprList_item)(unsafe.Pointer((*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab + 64))).FpDfltList + 8 + uintptr(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt)-int32(1))*32))).FpExpr + rc = _sqlite3ValueFromExpr(tls, db, pDflt, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, (*TColumn)(unsafe.Pointer(pCol)).Faffinity, bp) + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + rc = _sqlite3CorruptError(tls, int32(95844)) + } + **(**uintptr)(__ccgo_up((*TPreUpdate)(unsafe.Pointer(p)).FapDflt + uintptr(iIdx)*8)) = **(**uintptr)(__ccgo_up(bp)) + } + **(**uintptr)(__ccgo_up(ppValue)) = **(**uintptr)(__ccgo_up((*TPreUpdate)(unsafe.Pointer(p)).FapDflt + uintptr(iIdx)*8)) + } else { + **(**uintptr)(__ccgo_up(ppValue)) = _columnNullValue(tls) + } + } else { + if libc.Int32FromUint8((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol + uintptr(iIdx)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemRealify(tls, pMem) + } + } + } + } + goto preupdate_old_out +preupdate_old_out: + ; + _sqlite3Error(tls, db, rc) + return _sqlite3ApiExit(tls, db, rc) +} + +// C documentation +// +// /* +// ** Append N copies of character c to the given string buffer. +// */ +func Xsqlite3_str_appendchar(tls *libc.TLS, p uintptr, N int32, c uint8) { + var v1 int32 + var v2 bool + var v4 Tu32 + var v5 uintptr + _, _, _, _ = v1, v2, v4, v5 + if v2 = libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(p)).FnChar)+int64(N) >= libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(p)).FnAlloc); v2 { + v1 = _sqlite3StrAccumEnlarge(tls, p, int64(N)) + N = v1 + } + if v2 && v1 <= 0 { + return + } + for { + v1 = N + N = N - 1 + if !(v1 > 0) { + break + } + v5 = p + 24 + v4 = *(*Tu32)(unsafe.Pointer(v5)) + *(*Tu32)(unsafe.Pointer(v5)) = *(*Tu32)(unsafe.Pointer(v5)) + 1 + **(**uint8)(__ccgo_up((*Tsqlite3_str)(unsafe.Pointer(p)).FzText + uintptr(v4))) = c + } +} + +// C documentation +// +// /* +// ** Print into memory obtained from sqlite3_malloc(). Omit the internal +// ** %-conversion extensions. +// */ +func Xsqlite3_vmprintf(tls *libc.TLS, zFormat uintptr, ap Tva_list) (r uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var z uintptr + var _ /* acc at bp+72 */ TStrAccum + var _ /* zBase at bp+0 */ [70]uint8 + _ = z + if Xsqlite3_initialize(tls) != 0 { + return uintptr(0) + } + _sqlite3StrAccumInit(tls, bp+72, uintptr(0), bp, int32(70), int32(SQLITE_MAX_LENGTH)) + Xsqlite3_str_vappendf(tls, bp+72, zFormat, ap) + z = _sqlite3StrAccumFinish(tls, bp+72) + return z +} + +// C documentation +// +// /* +// ** Processing is determine by the affinity parameter: +// ** +// ** SQLITE_AFF_INTEGER: +// ** SQLITE_AFF_REAL: +// ** SQLITE_AFF_NUMERIC: +// ** Try to convert pRec to an integer representation or a +// ** floating-point representation if an integer representation +// ** is not possible. Note that the integer representation is +// ** always preferred, even if the affinity is REAL, because +// ** an integer representation is more space efficient on disk. +// ** +// ** SQLITE_AFF_FLEXNUM: +// ** If the value is text, then try to convert it into a number of +// ** some kind (integer or real) but do not make any other changes. +// ** +// ** SQLITE_AFF_TEXT: +// ** Convert pRec to a text representation. +// ** +// ** SQLITE_AFF_BLOB: +// ** SQLITE_AFF_NONE: +// ** No-op. pRec is unchanged. +// */ +func _applyAffinity(tls *libc.TLS, pRec uintptr, affinity uint8, enc Tu8) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint8(affinity) >= int32(SQLITE_AFF_NUMERIC) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Int) == 0 { /*OPTIMIZATION-IF-FALSE*/ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Str) != 0 { + _applyNumericAffinity(tls, pRec, int32(1)) + } + } else { + if libc.Int32FromUint8(affinity) <= int32(SQLITE_AFF_REAL) { + _sqlite3VdbeIntegerAffinity(tls, pRec) + } + } + } + } else { + if libc.Int32FromUint8(affinity) == int32(SQLITE_AFF_TEXT) { + /* Only attempt the conversion to TEXT if there is an integer or real + ** representation (blob and NULL do not get converted) but no string + ** representation. It would be harmless to repeat the conversion if + ** there is already a string rep, but it is pointless to waste those + ** CPU cycles. */ + if 0 == libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Str) { /*OPTIMIZATION-IF-FALSE*/ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemStringify(tls, pRec, enc, uint8(1)) + } + } + v1 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_IntReal))) + } + } +} + +// C documentation +// +// /* +// ** Generate code that will evaluate all == and IN constraints for an +// ** index scan. +// ** +// ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c). +// ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10 +// ** The index has as many as three equality constraints, but in this +// ** example, the third "c" value is an inequality. So only two +// ** constraints are coded. This routine will generate code to evaluate +// ** a==5 and b IN (1,2,3). The current values for a and b will be stored +// ** in consecutive registers and the index of the first register is returned. +// ** +// ** In the example above nEq==2. But this subroutine works for any value +// ** of nEq including 0. If nEq==0, this routine is nearly a no-op. +// ** The only thing it does is allocate the pLevel->iMem memory cell and +// ** compute the affinity string. +// ** +// ** The nExtraReg parameter is 0 or 1. It is 0 if all WHERE clause constraints +// ** are == or IN and are covered by the nEq. nExtraReg is 1 if there is +// ** an inequality constraint (such as the "c>=5 AND c<10" in the example) that +// ** occurs after the nEq quality constraints. +// ** +// ** This routine allocates a range of nEq+nExtraReg memory cells and returns +// ** the index of the first memory cell in that range. The code that +// ** calls this routine will use that memory range to store keys for +// ** start and termination conditions of the loop. +// ** key value of the loop. If one or more IN operators appear, then +// ** this routine allocates an additional nEq memory cells for internal +// ** use. +// ** +// ** Before returning, *pzAff is set to point to a buffer containing a +// ** copy of the column affinity string of the index allocated using +// ** sqlite3DbMalloc(). Except, entries in the copy of the string associated +// ** with equality constraints that use BLOB or NONE affinity are set to +// ** SQLITE_AFF_BLOB. This is to deal with SQL such as the following: +// ** +// ** CREATE TABLE t1(a TEXT PRIMARY KEY, b); +// ** SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b; +// ** +// ** In the example above, the index on t1(a) has TEXT affinity. But since +// ** the right hand side of the equality constraint (t2.b) has BLOB/NONE affinity, +// ** no conversion should be attempted before using a t2.b value as part of +// ** a key to search the index. Hence the first byte in the returned affinity +// ** string in this example would be set to SQLITE_AFF_BLOB. +// */ +func _codeAllEqualityTerms(tls *libc.TLS, pParse uintptr, pLevel uintptr, bRev int32, nExtraReg int32, pzAff uintptr) (r int32) { + var iIdxCur, j, nReg, r1, regBase, v1 int32 + var nEq, nSkip Tu16 + var pIdx, pLoop, pRight, pTerm, v, zAff uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iIdxCur, j, nEq, nReg, nSkip, pIdx, pLoop, pRight, pTerm, r1, regBase, v, zAff, v1 /* Number of left-most columns to skip */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Affinity string to return */ + /* This module is only called on query plans that use an index. */ + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + nEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq + nSkip = (*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip + pIdx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + /* Figure out how many memory cells we will need then allocate them. + */ + regBase = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + nReg = libc.Int32FromUint16(nEq) + nExtraReg + **(**int32)(__ccgo_up(pParse + 60)) += nReg + zAff = _sqlite3DbStrDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, _sqlite3IndexAffinityStr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pIdx)) + if nSkip != 0 { + iIdxCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, regBase, regBase+libc.Int32FromUint16(nSkip)-int32(1)) + if bRev != 0 { + v1 = int32(OP_Last) + } else { + v1 = int32(OP_Rewind) + } + _sqlite3VdbeAddOp1(tls, v, v1, iIdxCur) + j = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + if bRev != 0 { + v1 = int32(OP_SeekLT) + } else { + v1 = int32(OP_SeekGT) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip = _sqlite3VdbeAddOp4Int(tls, v, v1, iIdxCur, 0, regBase, libc.Int32FromUint16(nSkip)) + _sqlite3VdbeJumpHere(tls, v, j) + j = 0 + for { + if !(j < libc.Int32FromUint16(nSkip)) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iIdxCur, j, regBase+j) + goto _3 + _3: + ; + j = j + 1 + } + } + /* Evaluate the equality constraints + */ + j = libc.Int32FromUint16(nSkip) + for { + if !(j < libc.Int32FromUint16(nEq)) { + break + } + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) + /* The following testcase is true for indices with redundant columns. + ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ + r1 = _codeEqualityTerm(tls, pParse, pTerm, pLevel, j, bRev, regBase+j) + if r1 != regBase+j { + if nReg == int32(1) { + _sqlite3ReleaseTempReg(tls, pParse, regBase) + regBase = r1 + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), r1, regBase+j) + } + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_IN) != 0 { + if (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&uint32(EP_xIsSelect) != 0 { + /* No affinity ever needs to be (or should be) applied to a value + ** from the RHS of an "? IN (SELECT ...)" expression. The + ** sqlite3FindInIndex() routine has already ensured that the + ** affinity of the comparison has been applied to the value. */ + if zAff != 0 { + **(**uint8)(__ccgo_up(zAff + uintptr(j))) = uint8(SQLITE_AFF_BLOB) + } + } + } else { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_ISNULL) == 0 { + pRight = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_IS) == 0 && _sqlite3ExprCanBeNull(tls, pRight) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regBase+j, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + if libc.Int32FromUint8(_sqlite3CompareAffinity(tls, pRight, **(**uint8)(__ccgo_up(zAff + uintptr(j))))) == int32(SQLITE_AFF_BLOB) { + **(**uint8)(__ccgo_up(zAff + uintptr(j))) = uint8(SQLITE_AFF_BLOB) + } + if _sqlite3ExprNeedsNoAffinityChange(tls, pRight, **(**uint8)(__ccgo_up(zAff + uintptr(j)))) != 0 { + **(**uint8)(__ccgo_up(zAff + uintptr(j))) = uint8(SQLITE_AFF_BLOB) + } + } + } + } + goto _4 + _4: + ; + j = j + 1 + } + **(**uintptr)(__ccgo_up(pzAff)) = zAff + return regBase +} + +// C documentation +// +// /* +// ** Generate code for the RETURNING trigger. Unlike other triggers +// ** that invoke a subprogram in the bytecode, the code for RETURNING +// ** is generated in-line. +// */ +func _codeReturningTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintptr, regIn int32) { + bp := tls.Alloc(272) + defer tls.Free(272) + var db, pCol, pFrom, pNew, pReturning, v, v2 uintptr + var i, nCol, reg, v1 int32 + var _ /* sNC at bp+208 */ TNameContext + var _ /* sSelect at bp+0 */ TSelect + var _ /* uSrc at bp+120 */ struct { + FfromSpace [0][88]Tu8 + FsSrc TSrcList + F__ccgo_pad2 [80]byte + } + _, _, _, _, _, _, _, _, _, _, _ = db, i, nCol, pCol, pFrom, pNew, pReturning, reg, v, v1, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if !(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0) { + /* This RETURNING trigger must be for a different statement as + ** this statement lacks a RETURNING clause. */ + return + } + pReturning = (*(*struct { + FpReturning uintptr + })(unsafe.Pointer(&(*TParse)(unsafe.Pointer(pParse)).Fu1))).FpReturning + if pTrigger != pReturning+16 { + /* This RETURNING trigger is for a different statement */ + return + } + libc.Xmemset(tls, bp, 0, uint64(120)) + libc.Xmemset(tls, bp+120, 0, uint64(88)) + pFrom = bp + 120 + (**(**TSelect)(__ccgo_up(bp))).FpEList = _sqlite3ExprListDup(tls, db, (*TReturning)(unsafe.Pointer(pReturning)).FpReturnEL, 0) + (**(**TSelect)(__ccgo_up(bp))).FpSrc = pFrom + (*TSrcList)(unsafe.Pointer(pFrom)).FnSrc = int32(1) + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FpSTab = pTab + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FzName = (*TTable)(unsafe.Pointer(pTab)).FzName /* tag-20240424-1 */ + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FiCursor = -int32(1) + _sqlite3SelectPrep(tls, pParse, bp, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + _sqlite3GenerateColumnNames(tls, pParse, bp) + } + _sqlite3ExprListDelete(tls, db, (**(**TSelect)(__ccgo_up(bp))).FpEList) + pNew = _sqlite3ExpandReturning(tls, pParse, (*TReturning)(unsafe.Pointer(pReturning)).FpReturnEL, pTab) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + libc.Xmemset(tls, bp+208, 0, uint64(56)) + if (*TReturning)(unsafe.Pointer(pReturning)).FnRetCol == 0 { + (*TReturning)(unsafe.Pointer(pReturning)).FnRetCol = (*TExprList)(unsafe.Pointer(pNew)).FnExpr + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur = v1 + } + (**(**TNameContext)(__ccgo_up(bp + 208))).FpParse = pParse + *(*int32)(unsafe.Pointer(bp + 208 + 16)) = regIn + (**(**TNameContext)(__ccgo_up(bp + 208))).FncFlags = int32(NC_UBaseReg) + (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = (*TTrigger)(unsafe.Pointer(pTrigger)).Fop + (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = pTab + if _sqlite3ResolveExprListNames(tls, bp+208, pNew) == SQLITE_OK && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + nCol = (*TExprList)(unsafe.Pointer(pNew)).FnExpr + reg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + _sqlite3ProcessReturningSubqueries(tls, pNew, pTab) + **(**int32)(__ccgo_up(pParse + 60)) += nCol + int32(2) + (*TReturning)(unsafe.Pointer(pReturning)).FiRetReg = reg + i = 0 + for { + if !(i < nCol) { + break + } + pCol = (*(*TExprList_item)(unsafe.Pointer(pNew + 8 + uintptr(i)*32))).FpExpr + /* Due to !db->mallocFailed ~9 lines above */ + _sqlite3ExprCodeFactorable(tls, pParse, pCol, reg+i) + if libc.Int32FromUint8(_sqlite3ExprAffinity(tls, pCol)) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), reg+i) + } + goto _3 + _3: + ; + i = i + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), reg, i, reg+i) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur, reg+i+int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur, reg+i, reg+i+int32(1)) + } + } + _sqlite3ExprListDelete(tls, db, pNew) + (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = uint8(0) + (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = uintptr(0) +} + +// C documentation +// +// /* +// ** pExpr is a comparison operator. Return the type affinity that should +// ** be applied to both operands prior to doing the comparison. +// */ +func _comparisonAffinity(tls *libc.TLS, pExpr uintptr) (r uint8) { + var aff uint8 + _ = aff + aff = _sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if (*TExpr)(unsafe.Pointer(pExpr)).FpRight != 0 { + aff = _sqlite3CompareAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, aff) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + aff = _sqlite3CompareAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList + 8))).FpExpr, aff) + } else { + if libc.Int32FromUint8(aff) == 0 { + aff = uint8(SQLITE_AFF_BLOB) + } + } + } + return aff +} + +// C documentation +// +// /* +// ** Return true if any of the result-set columns in the compound query +// ** have incompatible affinities on one or more arms of the compound. +// */ +func _compoundHasDifferentAffinities(tls *libc.TLS, p uintptr) (r int32) { + var aff uint8 + var ii int32 + var pList, pSub1 uintptr + _, _, _, _ = aff, ii, pList, pSub1 + pList = (*TSelect)(unsafe.Pointer(p)).FpEList + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + aff = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr) + pSub1 = (*TSelect)(unsafe.Pointer(p)).FpPrior + for { + if !(pSub1 != 0) { + break + } + if libc.Int32FromUint8(_sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub1)).FpEList + 8 + uintptr(ii)*32))).FpExpr)) != libc.Int32FromUint8(aff) { + return int32(1) + } + goto _2 + _2: + ; + pSub1 = (*TSelect)(unsafe.Pointer(pSub1)).FpPrior + } + goto _1 + _1: + ; + ii = ii + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Return a pointer to the column affinity string associated with index +// ** pIdx. A column affinity string has one character for each column in +// ** the table, according to the affinity of the column: +// ** +// ** Character Column affinity +// ** ------------------------------ +// ** 'A' BLOB +// ** 'B' TEXT +// ** 'C' NUMERIC +// ** 'D' INTEGER +// ** 'F' REAL +// ** +// ** An extra 'D' is appended to the end of the string to cover the +// ** rowid that appears as the last column in every index. +// ** +// ** Memory for the buffer containing the column index affinity string +// ** is managed along with the rest of the Index structure. It will be +// ** released when sqlite3DeleteIndex() is called. +// */ +func _computeIndexAffStr(tls *libc.TLS, db uintptr, pIdx uintptr) (r uintptr) { + var aff uint8 + var n int32 + var pTab uintptr + var x Ti16 + _, _, _, _ = aff, n, pTab, x + pTab = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + (*TIndex)(unsafe.Pointer(pIdx)).FzColAff = _sqlite3DbMallocRaw(tls, uintptr(0), libc.Uint64FromInt32(libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)+int32(1))) + if !((*TIndex)(unsafe.Pointer(pIdx)).FzColAff != 0) { + _sqlite3OomFault(tls, db) + return uintptr(0) + } + n = 0 + for { + if !(n < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) { + break + } + x = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) + if int32(x) >= 0 { + aff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(x)*16))).Faffinity + } else { + if int32(x) == -int32(1) { + aff = uint8(SQLITE_AFF_INTEGER) + } else { + aff = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(n)*32))).FpExpr) + } + } + if libc.Int32FromUint8(aff) < int32(SQLITE_AFF_BLOB) { + aff = uint8(SQLITE_AFF_BLOB) + } + if libc.Int32FromUint8(aff) > int32(SQLITE_AFF_NUMERIC) { + aff = uint8(SQLITE_AFF_NUMERIC) + } + **(**uint8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FzColAff + uintptr(n))) = aff + goto _1 + _1: + ; + n = n + 1 + } + **(**uint8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FzColAff + uintptr(n))) = uint8(0) + return (*TIndex)(unsafe.Pointer(pIdx)).FzColAff +} + +// C documentation +// +// /* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...) +// ** functions. +// ** +// ** Return a string value that is the concatenation of all non-null +// ** entries in argv[]. Use zSep as the separator. +// */ +func _concatFuncCore(tls *libc.TLS, context uintptr, argc int32, argv uintptr, nSep int32, zSep uintptr) { + var bNotNull, i, k int32 + var j, n Ti64 + var v, z uintptr + _, _, _, _, _, _, _ = bNotNull, i, j, k, n, v, z + n = 0 + bNotNull = 0 + i = 0 + for { + if !(i < argc) { + break + } + n = n + int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)))) + goto _1 + _1: + ; + i = i + 1 + } + n = n + int64(argc-libc.Int32FromInt32(1))*int64(nSep) + z = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(n+int64(1))) + if z == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + j = 0 + i = 0 + for { + if !(i < argc) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) != int32(SQLITE_NULL) { + k = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + v = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if v != uintptr(0) { + if bNotNull != 0 && nSep > 0 { + libc.Xmemcpy(tls, z+uintptr(j), zSep, libc.Uint64FromInt32(nSep)) + j = j + int64(nSep) + } + libc.Xmemcpy(tls, z+uintptr(j), v, libc.Uint64FromInt32(k)) + j = j + int64(k) + bNotNull = int32(1) + } + } + goto _2 + _2: + ; + i = i + 1 + } + **(**uint8)(__ccgo_up(z + uintptr(j))) = uint8(0) + Xsqlite3_result_text64(tls, context, z, libc.Uint64FromInt64(j), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) +} + +// C documentation +// +// /* +// ** Add a new entry to the pConst object. Except, do not add duplicate +// ** pColumn entries. Also, do not add if doing so would not be appropriate. +// ** +// ** The caller guarantees the pColumn is a column and pValue is a constant. +// ** This routine has to do some additional checks before completing the +// ** insert. +// */ +func _constInsert(tls *libc.TLS, pConst uintptr, pColumn uintptr, pValue uintptr, pExpr uintptr) { + var i int32 + var pE2 uintptr + _, _ = i, pE2 + if (*TExpr)(unsafe.Pointer(pColumn)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != uint32(0) { + return + } + if libc.Int32FromUint8(_sqlite3ExprAffinity(tls, pValue)) != 0 { + return + } + if !(_sqlite3IsBinary(tls, _sqlite3ExprCompareCollSeq(tls, (*TWhereConst)(unsafe.Pointer(pConst)).FpParse, pExpr)) != 0) { + return + } + /* 2018-10-25 ticket [cf5ed20f] + ** Make sure the same pColumn is not inserted more than once */ + i = 0 + for { + if !(i < (*TWhereConst)(unsafe.Pointer(pConst)).FnConst) { + break + } + pE2 = **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*int32(2))*8)) + if (*TExpr)(unsafe.Pointer(pE2)).FiTable == (*TExpr)(unsafe.Pointer(pColumn)).FiTable && int32((*TExpr)(unsafe.Pointer(pE2)).FiColumn) == int32((*TExpr)(unsafe.Pointer(pColumn)).FiColumn) { + return /* Already present. Return without doing anything. */ + } + goto _1 + _1: + ; + i = i + 1 + } + if libc.Int32FromUint8(_sqlite3ExprAffinity(tls, pColumn)) <= int32(SQLITE_AFF_BLOB) { + (*TWhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob = int32(1) + } + (*TWhereConst)(unsafe.Pointer(pConst)).FnConst = (*TWhereConst)(unsafe.Pointer(pConst)).FnConst + 1 + (*TWhereConst)(unsafe.Pointer(pConst)).FapExpr = _sqlite3DbReallocOrFree(tls, (*TParse)(unsafe.Pointer((*TWhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb, (*TWhereConst)(unsafe.Pointer(pConst)).FapExpr, uint64(libc.Uint64FromInt32((*TWhereConst)(unsafe.Pointer(pConst)).FnConst*int32(2))*uint64(8))) + if (*TWhereConst)(unsafe.Pointer(pConst)).FapExpr == uintptr(0) { + (*TWhereConst)(unsafe.Pointer(pConst)).FnConst = 0 + } else { + **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr((*TWhereConst)(unsafe.Pointer(pConst)).FnConst*int32(2)-int32(2))*8)) = pColumn + **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr((*TWhereConst)(unsafe.Pointer(pConst)).FnConst*int32(2)-int32(1))*8)) = pValue + } +} + +// C documentation +// +// /* +// ** Analyze a term that consists of two or more OR-connected +// ** subterms. So in: +// ** +// ** ... WHERE (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13) +// ** ^^^^^^^^^^^^^^^^^^^^ +// ** +// ** This routine analyzes terms such as the middle term in the above example. +// ** A WhereOrTerm object is computed and attached to the term under +// ** analysis, regardless of the outcome of the analysis. Hence: +// ** +// ** WhereTerm.wtFlags |= TERM_ORINFO +// ** WhereTerm.u.pOrInfo = a dynamically allocated WhereOrTerm object +// ** +// ** The term being analyzed must have two or more of OR-connected subterms. +// ** A single subterm might be a set of AND-connected sub-subterms. +// ** Examples of terms under analysis: +// ** +// ** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5 +// ** (B) x=expr1 OR expr2=x OR x=expr3 +// ** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15) +// ** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*') +// ** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6) +// ** (F) x>A OR (x=A AND y>=B) +// ** +// ** CASE 1: +// ** +// ** If all subterms are of the form T.C=expr for some single column of C and +// ** a single table T (as shown in example B above) then create a new virtual +// ** term that is an equivalent IN expression. In other words, if the term +// ** being analyzed is: +// ** +// ** x = expr1 OR expr2 = x OR x = expr3 +// ** +// ** then create a new virtual term like this: +// ** +// ** x IN (expr1,expr2,expr3) +// ** +// ** CASE 2: +// ** +// ** If there are exactly two disjuncts and one side has x>A and the other side +// ** has x=A (for the same x and A) then add a new virtual conjunct term to the +// ** WHERE clause of the form "x>=A". Example: +// ** +// ** x>A OR (x=A AND y>B) adds: x>=A +// ** +// ** The added conjunct can sometimes be helpful in query planning. +// ** +// ** CASE 3: +// ** +// ** If all subterms are indexable by a single table T, then set +// ** +// ** WhereTerm.eOperator = WO_OR +// ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T +// ** +// ** A subterm is "indexable" if it is of the form +// ** "T.C " where C is any column of table T and +// ** is one of "=", "<", "<=", ">", ">=", "IS NULL", or "IN". +// ** A subterm is also indexable if it is an AND of two or more +// ** subsubterms at least one of which is indexable. Indexable AND +// ** subterms have their eOperator set to WO_AND and they have +// ** u.pAndInfo set to a dynamically allocated WhereAndTerm object. +// ** +// ** From another point of view, "indexable" means that the subterm could +// ** potentially be used with an index if an appropriate index exists. +// ** This analysis does not consider whether or not the index exists; that +// ** is decided elsewhere. This analysis only looks at whether subterms +// ** appropriate for indexing exist. +// ** +// ** All examples A through E above satisfy case 3. But if a term +// ** also satisfies case 1 (such as B) we know that the optimizer will +// ** always prefer case 1, so in that case we pretend that case 3 is not +// ** satisfied. +// ** +// ** It might be the case that multiple tables are indexable. For example, +// ** (E) above is indexable on tables P, Q, and R. +// ** +// ** Terms that satisfy case 3 are candidates for lookup by using +// ** separate indices to find rowids for each subterm and composing +// ** the union of all rowids using a RowSet object. This is similar +// ** to "bitmap indices" in other database engines. +// ** +// ** OTHERWISE: +// ** +// ** If none of cases 1, 2, or 3 apply, then leave the eOperator set to +// ** zero. This term is not useful for search. +// */ +func _exprAnalyzeOrTerm(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { + var affLeft, affRight, i, iColumn, iCursor, iOne, iTwo, idxNew, j, j1, okToChngToIN, v7, v9 int32 + var b, b1, chngToIN, indexable TBitmask + var db, pAndInfo, pAndTerm, pAndWC, pDup, pExpr, pLeft, pLeft1, pList, pNew, pOne, pOrInfo, pOrTerm, pOrWc, pOther, pParse, pTerm, pTwo, pWInfo, v1, v2 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = affLeft, affRight, b, b1, chngToIN, db, i, iColumn, iCursor, iOne, iTwo, idxNew, indexable, j, j1, okToChngToIN, pAndInfo, pAndTerm, pAndWC, pDup, pExpr, pLeft, pLeft1, pList, pNew, pOne, pOrInfo, pOrTerm, pOrWc, pOther, pParse, pTerm, pTwo, pWInfo, v1, v2, v7, v9 + pWInfo = (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo /* WHERE clause processing context */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parser context */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 /* The term to be analyzed */ + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr /* Tables that are indexable, satisfying case 2 */ + /* + ** Break the OR clause into its separate subterms. The subterms are + ** stored in a WhereClause structure containing within the WhereOrInfo + ** object that is attached to the original OR clause term. + */ + v1 = _sqlite3DbMallocZero(tls, db, uint64(496)) + pOrInfo = v1 + *(*uintptr)(unsafe.Pointer(pTerm + 32)) = v1 + if pOrInfo == uintptr(0) { + return + } + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_ORINFO)) + pOrWc = pOrInfo + libc.Xmemset(tls, pOrWc+40, 0, uint64(448)) + _sqlite3WhereClauseInit(tls, pOrWc, pWInfo) + _sqlite3WhereSplit(tls, pOrWc, pExpr, uint8(TK_OR)) + _sqlite3WhereExprAnalyze(tls, pSrc, pOrWc) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + /* + ** Compute the set of tables that might satisfy cases 1 or 3. + */ + indexable = ^libc.Uint64FromInt32(0) + chngToIN = ^libc.Uint64FromInt32(0) + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + for { + if !(i >= 0 && indexable != 0) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_SINGLE) == 0 { + chngToIN = uint64(0) + pAndInfo = _sqlite3DbMallocRawNN(tls, db, uint64(488)) + if pAndInfo != 0 { + b = uint64(0) + *(*uintptr)(unsafe.Pointer(pOrTerm + 32)) = pAndInfo + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_ANDINFO)) + (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator = uint16(WO_AND) + (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor = -int32(1) + pAndWC = pAndInfo + libc.Xmemset(tls, pAndWC+40, 0, uint64(448)) + _sqlite3WhereClauseInit(tls, pAndWC, (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo) + _sqlite3WhereSplit(tls, pAndWC, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr, uint8(TK_AND)) + _sqlite3WhereExprAnalyze(tls, pSrc, pAndWC) + (*TWhereClause)(unsafe.Pointer(pAndWC)).FpOuter = pWC + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + j = 0 + pAndTerm = (*TWhereClause)(unsafe.Pointer(pAndWC)).Fa + for { + if !(j < (*TWhereClause)(unsafe.Pointer(pAndWC)).FnTerm) { + break + } + if _allowedOp(tls, libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pAndTerm)).FpExpr)).Fop)) != 0 || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pAndTerm)).FeOperator) == int32(WO_AUX) { + b = b | _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pAndTerm)).FleftCursor) + } + goto _5 + _5: + ; + j = j + 1 + pAndTerm += 56 + } + } + indexable = indexable & b + } + } else { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_COPIED) != 0 { + /* Skip this term for now. We revisit it when we process the + ** corresponding TERM_VIRTUAL term */ + } else { + b1 = _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_VIRTUAL) != 0 { + pOther = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FiParent)*56 + b1 = b1 | _sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOther)).FleftCursor) + } + indexable = indexable & b1 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_EQ) == 0 { + chngToIN = uint64(0) + } else { + chngToIN = chngToIN & b1 + } + } + } + goto _3 + _3: + ; + i = i - 1 + pOrTerm += 56 + } + /* + ** Record the set of tables that satisfy case 3. The set might be + ** empty. + */ + (*TWhereOrInfo)(unsafe.Pointer(pOrInfo)).Findexable = indexable + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(WO_OR) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = -int32(1) + if indexable != 0 { + (*TWhereClause)(unsafe.Pointer(pWC)).FhasOr = uint8(1) + } + /* For a two-way OR, attempt to implementation case 2. + */ + if indexable != 0 && (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm == int32(2) { + iOne = 0 + for { + v7 = iOne + iOne = iOne + 1 + v1 = _whereNthSubterm(tls, (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa, v7) + pOne = v1 + if !(v1 != uintptr(0)) { + break + } + iTwo = 0 + for { + v9 = iTwo + iTwo = iTwo + 1 + v2 = _whereNthSubterm(tls, (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa+1*56, v9) + pTwo = v2 + if !(v2 != uintptr(0)) { + break + } + _whereCombineDisjuncts(tls, pSrc, pWC, pOne, pTwo) + } + } + } + /* + ** chngToIN holds a set of tables that *might* satisfy case 1. But + ** we have to do some additional checking to see if case 1 really + ** is satisfied. + ** + ** chngToIN will hold either 0, 1, or 2 bits. The 0-bit case means + ** that there is no possibility of transforming the OR clause into an + ** IN operator because one or more terms in the OR clause contain + ** something other than == on a column in the single table. The 1-bit + ** case means that every term of the OR clause is of the form + ** "table.column=expr" for some single table. The one bit that is set + ** will correspond to the common table. We still need to check to make + ** sure the same column is used on all terms. The 2-bit case is when + ** the all terms are of the form "table1.column=table2.column". It + ** might be possible to form an IN operator with either table1.column + ** or table2.column as the LHS if either is common to every term of + ** the OR clause. + ** + ** Note that terms of the form "table.column1=table.column2" (the + ** same table on both sizes of the ==) cannot be optimized. + */ + if chngToIN != 0 { + okToChngToIN = 0 /* True if the conversion to IN is valid */ + iColumn = -int32(1) /* Column index on lhs of IN operator */ + iCursor = -int32(1) /* Table cursor common to all terms */ + j1 = 0 /* Loop counter */ + /* Search for a table and column that appears on one side or the + ** other of the == operator in every subterm. That table and column + ** will be recorded in iCursor and iColumn. There might not be any + ** such table and column. Set okToChngToIN if an appropriate table + ** and column is found but leave okToChngToIN false if not found. + */ + j1 = 0 + for { + if !(j1 < int32(2) && !(okToChngToIN != 0)) { + break + } + pLeft = uintptr(0) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + for { + if !(i >= 0) { + break + } + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(TERM_OK)) + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCursor { + /* This is the 2-bit case and we are on the second iteration and + ** current term is from the first iteration. So skip this term. */ + goto _11 + } + if chngToIN&_sqlite3WhereGetMask(tls, pWInfo+592, (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) == uint64(0) { + /* This term must be of the form t1.a==t2.b where t2 is in the + ** chngToIN set but t1 is not. This term will be either preceded + ** or followed by an inverted copy (t2.b==t1.a). Skip this term + ** and use its inversion. */ + goto _11 + } + iColumn = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pOrTerm + 32))).FleftColumn + iCursor = (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor + pLeft = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft + break + goto _11 + _11: + ; + i = i - 1 + pOrTerm += 56 + } + if i < 0 { + /* No candidate table+column was found. This can only occur + ** on the second iteration */ + break + } + /* We have found a candidate table and column. Check to see if that + ** table and column is common to every term in the OR clause */ + okToChngToIN = int32(1) + for { + if !(i >= 0 && okToChngToIN != 0) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor != iCursor { + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(TERM_OK)) + } else { + if (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pOrTerm + 32))).FleftColumn != iColumn || iColumn == -int32(2) && _sqlite3ExprCompare(tls, pParse, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft, pLeft, -int32(1)) != 0 { + okToChngToIN = 0 + } else { + /* If the right-hand side is also a column, then the affinities + ** of both right and left sides must be such that no type + ** conversions are required on the right. (Ticket #2249) + */ + affRight = libc.Int32FromUint8(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpRight)) + affLeft = libc.Int32FromUint8(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft)) + if affRight != 0 && affRight != affLeft { + okToChngToIN = 0 + } else { + v1 = pOrTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_OK)) + } + } + } + goto _13 + _13: + ; + i = i - 1 + pOrTerm += 56 + } + goto _10 + _10: + ; + j1 = j1 + 1 + } + /* At this point, okToChngToIN is true if original pTerm satisfies + ** case 1. In that case, construct a new virtual term that is + ** pTerm converted into an IN operator. + */ + if okToChngToIN != 0 { /* A transient duplicate expression */ + pList = uintptr(0) /* The RHS of the IN operator */ + pLeft1 = uintptr(0) /* The complete IN operator */ + i = (*TWhereClause)(unsafe.Pointer(pOrWc)).FnTerm - int32(1) + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWc)).Fa + for { + if !(i >= 0) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&int32(TERM_OK) == 0 { + goto _16 + } + pDup = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpRight, 0) + pList = _sqlite3ExprListAppend(tls, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse, pList, pDup) + pLeft1 = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft + goto _16 + _16: + ; + i = i - 1 + pOrTerm += 56 + } + pDup = _sqlite3ExprDup(tls, db, pLeft1, 0) + pNew = _sqlite3PExpr(tls, pParse, int32(TK_IN), pDup, uintptr(0)) + if pNew != 0 { + _transferJoinMarkings(tls, pNew, pExpr) + *(*uintptr)(unsafe.Pointer(pNew + 32)) = pList + idxNew = _whereClauseInsert(tls, pWC, pNew, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + _exprAnalyze(tls, pSrc, pWC, idxNew) + /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where reused */ + _markTermAsChild(tls, pWC, idxNew, idxTerm) + } else { + _sqlite3ExprListDelete(tls, db, pList) + } + } + } +} + +// C documentation +// +// /* +// ** Argument pExpr is an (?, ?...) IN(...) expression. This +// ** function allocates and returns a nul-terminated string containing +// ** the affinities to be used for each column of the comparison. +// ** +// ** It is the responsibility of the caller to ensure that the returned +// ** string is eventually freed using sqlite3DbFree(). +// */ +func _exprINAffinity(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r uintptr) { + var a uint8 + var i, nVal int32 + var pA, pLeft, pSelect, zRet, v1 uintptr + _, _, _, _, _, _, _, _ = a, i, nVal, pA, pLeft, pSelect, zRet, v1 + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + nVal = _sqlite3ExprVectorSize(tls, pLeft) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + v1 = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + } else { + v1 = uintptr(0) + } + pSelect = v1 + zRet = _sqlite3DbMallocRaw(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, libc.Uint64FromInt64(int64(1)+int64(nVal))) + if zRet != 0 { + i = 0 + for { + if !(i < nVal) { + break + } + pA = _sqlite3VectorFieldSubexpr(tls, pLeft, i) + a = _sqlite3ExprAffinity(tls, pA) + if pSelect != 0 { + **(**uint8)(__ccgo_up(zRet + uintptr(i))) = _sqlite3CompareAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList + 8 + uintptr(i)*32))).FpExpr, a) + } else { + **(**uint8)(__ccgo_up(zRet + uintptr(i))) = a + } + goto _2 + _2: + ; + i = i + 1 + } + **(**uint8)(__ccgo_up(zRet + uintptr(nVal))) = uint8('\000') + } + return zRet +} + +// C documentation +// +// /* +// ** Return true if all expressions in the expression-list passed as the +// ** only argument are both constant and have no affinity. +// */ +func _exprListIsNoAffinity(tls *libc.TLS, pParse uintptr, pRow uintptr) (r int32) { + var ii int32 + var pExpr uintptr + _, _ = ii, pExpr + if _exprListIsConstant(tls, pParse, pRow) == 0 { + return 0 + } + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pRow)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pRow + 8 + uintptr(ii)*32))).FpExpr + if 0 != libc.Int32FromUint8(_sqlite3ExprAffinity(tls, pExpr)) { + return 0 + } + goto _1 + _1: + ; + ii = ii + 1 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Return an Expr object that refers to a memory register corresponding +// ** to column iCol of table pTab. +// ** +// ** regBase is the first of an array of register that contains the data +// ** for pTab. regBase itself holds the rowid. regBase+1 holds the first +// ** column. regBase+2 holds the second column, and so forth. +// */ +func _exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int32, iCol Ti16) (r uintptr) { + var db, pCol, pExpr, zColl uintptr + _, _, _, _ = db, pCol, pExpr, zColl + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pExpr = _sqlite3Expr(tls, db, int32(TK_REGISTER), uintptr(0)) + if pExpr != 0 { + if int32(iCol) >= 0 && int32(iCol) != int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = regBase + int32(_sqlite3TableColumnToStorage(tls, pTab, iCol)) + int32(1) + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = (*TColumn)(unsafe.Pointer(pCol)).Faffinity + zColl = _sqlite3ColumnColl(tls, pCol) + if zColl == uintptr(0) { + zColl = (*TCollSeq)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl)).FzName + } + pExpr = _sqlite3ExprAddCollateString(tls, pParse, pExpr, zColl) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = regBase + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER) + } + } + return pExpr +} + +// C documentation +// +// /* +// ** Gobble up the first bareword or quoted word from the input buffer zIn. +// ** Return a pointer to the character immediately following the last in +// ** the gobbled word if successful, or a NULL pointer otherwise (failed +// ** to find close-quote character). +// ** +// ** Before returning, set pzOut to point to a new buffer containing a +// ** nul-terminated, dequoted copy of the gobbled word. If the word was +// ** quoted, *pbQuoted is also set to 1 before returning. +// ** +// ** If *pRc is other than SQLITE_OK when this function is called, it is +// ** a no-op (NULL is returned). Otherwise, if an OOM occurs within this +// ** function, *pRc is set to SQLITE_NOMEM before returning. *pRc is *not* +// ** set if a parse error (failed to find close quote) occurs. +// */ +func _fts5ConfigGobbleWord(tls *libc.TLS, pRc uintptr, zIn uintptr, pzOut uintptr, pbQuoted uintptr) (r uintptr) { + var ii int32 + var nIn Tsqlite3_int64 + var zOut, zRet uintptr + _, _, _, _ = ii, nIn, zOut, zRet + zRet = uintptr(0) + nIn = libc.Int64FromUint64(libc.Xstrlen(tls, zIn)) + zOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nIn+int64(1))) + **(**int32)(__ccgo_up(pbQuoted)) = 0 + **(**uintptr)(__ccgo_up(pzOut)) = uintptr(0) + if zOut == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, zOut, zIn, libc.Uint64FromInt64(nIn+libc.Int64FromInt32(1))) + if _fts5_isopenquote(tls, **(**uint8)(__ccgo_up(zOut))) != 0 { + ii = _fts5Dequote(tls, zOut) + zRet = zIn + uintptr(ii) + **(**int32)(__ccgo_up(pbQuoted)) = int32(1) + } else { + zRet = _fts5ConfigSkipBareword(tls, zIn) + if zRet != 0 { + **(**uint8)(__ccgo_up(zOut + uintptr(int64(zRet)-int64(zIn)))) = uint8('\000') + } + } + } + if zRet == uintptr(0) { + Xsqlite3_free(tls, zOut) + } else { + **(**uintptr)(__ccgo_up(pzOut)) = zOut + } + return zRet +} + +// C documentation +// +// /* +// ** Implementation of fts5_locale(LOCALE, TEXT) function. +// ** +// ** If parameter LOCALE is NULL, or a zero-length string, then a copy of +// ** TEXT is returned. Otherwise, both LOCALE and TEXT are interpreted as +// ** text, and the value returned is a blob consisting of: +// ** +// ** * The 4 bytes 0x00, 0xE0, 0xB2, 0xEb (FTS5_LOCALE_HEADER). +// ** * The LOCALE, as utf-8 text, followed by +// ** * 0x00, followed by +// ** * The TEXT, as utf-8 text. +// ** +// ** There is no final nul-terminator following the TEXT value. +// */ +func _fts5LocaleFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var nBlob, nLocale, nText Ti64 + var p, pBlob, pCsr, zLocale, zText, v1 uintptr + _, _, _, _, _, _, _, _, _ = nBlob, nLocale, nText, p, pBlob, pCsr, zLocale, zText, v1 + zLocale = uintptr(0) + nLocale = 0 + zText = uintptr(0) + nText = 0 + _ = nArg + zLocale = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg))) + nLocale = int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg)))) + zText = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apArg + 1*8))) + nText = int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg + 1*8)))) + if zLocale == uintptr(0) || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zLocale))) == int32('\000') { + Xsqlite3_result_text(tls, pCtx, zText, int32(nText), uintptr(-libc.Int32FromInt32(1))) + } else { + p = Xsqlite3_user_data(tls, pCtx) + pBlob = uintptr(0) + pCsr = uintptr(0) + nBlob = 0 + nBlob = int64(libc.Int32FromInt64(16)) + nLocale + int64(1) + nText + pBlob = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nBlob)) + if pBlob == uintptr(0) { + Xsqlite3_result_error_nomem(tls, pCtx) + return + } + pCsr = pBlob + libc.Xmemcpy(tls, pCsr, p+96, libc.Uint64FromInt32(libc.Int32FromInt64(16))) + pCsr = pCsr + uintptr(libc.Int32FromInt64(16)) + libc.Xmemcpy(tls, pCsr, zLocale, libc.Uint64FromInt64(nLocale)) + pCsr = pCsr + uintptr(nLocale) + v1 = pCsr + pCsr = pCsr + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8(0x00) + if zText != 0 { + libc.Xmemcpy(tls, pCsr, zText, libc.Uint64FromInt64(nText)) + } + Xsqlite3_result_blob(tls, pCtx, pBlob, int32(nBlob), __ccgo_fp(Xsqlite3_free)) + } +} + +func _fts5PorterCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken int32, iStart int32, iEnd int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aBuf, p uintptr + var c uint8 + var v1 int32 + var _ /* nBuf at bp+0 */ int32 + _, _, _, _ = aBuf, c, p, v1 + p = pCtx + if nToken > int32(FTS5_PORTER_MAX_TOKEN) || nToken < int32(3) { + goto pass_through + } + aBuf = (*TPorterContext)(unsafe.Pointer(p)).FaBuf + **(**int32)(__ccgo_up(bp)) = nToken + libc.Xmemcpy(tls, aBuf, pToken, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))) + /* Step 1. */ + _fts5PorterStep1A(tls, aBuf, bp) + if _fts5PorterStep1B(tls, aBuf, bp) != 0 { + if _fts5PorterStep1B2(tls, aBuf, bp) == 0 { + c = **(**uint8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1)))) + if _fts5PorterIsVowel(tls, c, 0) == 0 && libc.Int32FromUint8(c) != int32('l') && libc.Int32FromUint8(c) != int32('s') && libc.Int32FromUint8(c) != int32('z') && libc.Int32FromUint8(c) == libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(2))))) { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } else { + if _fts5Porter_MEq1(tls, aBuf, **(**int32)(__ccgo_up(bp))) != 0 && _fts5Porter_Ostar(tls, aBuf, **(**int32)(__ccgo_up(bp))) != 0 { + v1 = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(aBuf + uintptr(v1))) = uint8('e') + } + } + } + } + /* Step 1C. */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('y') && _fts5Porter_Vowel(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 { + **(**uint8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1)))) = uint8('i') + } + /* Steps 2 through 4. */ + _fts5PorterStep2(tls, aBuf, bp) + _fts5PorterStep3(tls, aBuf, bp) + _fts5PorterStep4(tls, aBuf, bp) + /* Step 5a. */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('e') { + if _fts5Porter_MGt1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 || _fts5Porter_MEq1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 && !(_fts5Porter_Ostar(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0) { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } + } + /* Step 5b. */ + if **(**int32)(__ccgo_up(bp)) > int32(1) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))))) == int32('l') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(**(**int32)(__ccgo_up(bp))-int32(2))))) == int32('l') && _fts5Porter_MGt1(tls, aBuf, **(**int32)(__ccgo_up(bp))-int32(1)) != 0 { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) - 1 + } + return (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterContext)(unsafe.Pointer(p)).FxToken})))(tls, (*TPorterContext)(unsafe.Pointer(p)).FpCtx, tflags, aBuf, **(**int32)(__ccgo_up(bp)), iStart, iEnd) + goto pass_through +pass_through: + ; + return (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterContext)(unsafe.Pointer(p)).FxToken})))(tls, (*TPorterContext)(unsafe.Pointer(p)).FpCtx, tflags, pToken, nToken, iStart, iEnd) + return r +} + +// C documentation +// +// /* +// ** Trigram tokenizer tokenize routine. +// */ +func _fts5TriTokenize(tls *libc.TLS, pTok uintptr, pCtx uintptr, unusedFlags int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aStart [3]int32 + var iCode Tu32 + var iNext, ii, rc int32 + var p, z1, zEof, zIn, zOut, v1 uintptr + var _ /* aBuf at bp+0 */ [32]uint8 + _, _, _, _, _, _, _, _, _, _, _ = aStart, iCode, iNext, ii, p, rc, z1, zEof, zIn, zOut, v1 + p = pTok + rc = SQLITE_OK + zOut = bp + zIn = pText + if zIn != 0 { + v1 = zIn + uintptr(nText) + } else { + v1 = uintptr(0) + } + zEof = v1 + iCode = uint32(0) /* Input offset of each character in aBuf[] */ + _ = unusedFlags + /* Populate aBuf[] with the characters for the first trigram. */ + ii = 0 + for { + if !(ii < int32(3)) { + break + } + for cond := true; cond; cond = iCode == uint32(0) { + aStart[ii] = int32(int64(zIn) - int64(pText)) + if zIn >= zEof { + return SQLITE_OK + } + v1 = zIn + zIn = zIn + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v1))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zIn < zEof && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn)))&int32(0xc0) == int32(0x80) { + v1 = zIn + zIn = zIn + 1 + iCode = iCode<>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + /* At the start of each iteration of this loop: + ** + ** aBuf: Contains 3 characters. The 3 characters of the next trigram. + ** zOut: Points to the byte following the last character in aBuf. + ** aStart[3]: Contains the byte offset in the input text corresponding + ** to the start of each of the three characters in the buffer. + */ + for int32(1) != 0 { + /* Read characters from the input up until the first non-diacritic */ + for cond := true; cond; cond = iCode == uint32(0) { + iNext = int32(int64(zIn) - int64(pText)) + if zIn >= zEof { + iCode = uint32(0) + break + } + v1 = zIn + zIn = zIn + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v1))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zIn < zEof && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn)))&int32(0xc0) == int32(0x80) { + v1 = zIn + zIn = zIn + 1 + iCode = iCode<= int32(0xc0) { + for libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(z1))))&int32(0xc0) == int32(0x80) { + z1 = z1 + 1 + } + } + libc.Xmemmove(tls, bp, z1, libc.Uint64FromInt64(int64(zOut)-int64(z1))) + zOut = zOut - uintptr(int64(z1)-t__predefined_ptrdiff_t(bp)) + if iCode < uint32(0x00080) { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(iCode & libc.Uint32FromInt32(0xFF)) + } else { + if iCode < uint32(0x00800) { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xC0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + /* Update the aStart[] array */ + aStart[0] = aStart[int32(1)] + aStart[int32(1)] = aStart[int32(2)] + aStart[int32(2)] = iNext + } + return rc +} + +func _fts5UnicodeTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + var a, aFold, p, pEnd, zCsr, zOut, zTerm, v3 uintptr + var iCode Tu32 + var ie, is, nFold, rc, v7 int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, aFold, iCode, ie, is, nFold, p, pEnd, rc, zCsr, zOut, zTerm, v3, v7 + p = pTokenizer + rc = SQLITE_OK + a = p + zTerm = pText + uintptr(nText) + zCsr = pText + /* Output buffer */ + aFold = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold + nFold = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold + pEnd = aFold + uintptr(nFold-int32(6)) + _ = iUnused + /* Each iteration of this loop gobbles up a contiguous run of separators, + ** then the next token. */ +_2: + ; + if !(rc == SQLITE_OK) { + goto _1 + } /* non-ASCII codepoint read from input */ + zOut = aFold + /* Skip any separator characters. */ + for int32(1) != 0 { + if zCsr >= zTerm { + goto tokenize_done + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0x80) != 0 { + /* A character outside of the ascii range. Skip past it if it is + ** a separator character. Or break out of the loop if it is not. */ + is = int32(int64(zCsr) - int64(pText)) + v3 = zCsr + zCsr = zCsr + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v3))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zCsr < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0xc0) == int32(0x80) { + v3 = zCsr + zCsr = zCsr + 1 + iCode = iCode< pEnd { + aFold = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nFold)*int64(2))) + if aFold == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto tokenize_done + } + zOut = aFold + uintptr(int64(zOut)-int64((*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold)) + libc.Xmemcpy(tls, aFold, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold, libc.Uint64FromInt32(nFold)) + Xsqlite3_free(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold = aFold + v7 = nFold * libc.Int32FromInt32(2) + nFold = v7 + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold = v7 + pEnd = aFold + uintptr(nFold-int32(6)) + } + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0x80) != 0) { + goto _8 + } + /* An non-ascii-range character. Fold it into the output buffer if + ** it is a token character, or break out of the loop if it is not. */ + v3 = zCsr + zCsr = zCsr + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v3))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zCsr < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0xc0) == int32(0x80) { + v3 = zCsr + zCsr = zCsr + 1 + iCode = iCode<>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + if iCode < uint32(0x10000) { + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(int32(0xE0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } else { + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(int32(0xF0) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(iCode&libc.Uint32FromInt32(0x3F)))) + } + } + } + } + goto _13 +_12: + ; + goto _5 +_13: + ; + goto _9 +_8: + ; + if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(a + uintptr(**(**uint8)(__ccgo_up(zCsr)))))) == 0) { + goto _24 + } + /* An ascii-range separator character. End of token. */ + goto _5 + goto _25 +_24: + ; + goto ascii_tokenchar +ascii_tokenchar: + ; + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) >= int32('A') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) <= int32('Z') { + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr))) + int32(32)) + } else { + v3 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v3)) = uint8(**(**uint8)(__ccgo_up(zCsr))) + } + zCsr = zCsr + 1 +_25: + ; +_9: + ; + ie = int32(int64(zCsr) - int64(pText)) + goto _6 +_5: + ; + /* Invoke the token callback */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xToken})))(tls, pCtx, 0, aFold, int32(int64(zOut)-int64(aFold)), is, ie) + goto _2 +_1: + ; + goto tokenize_done +tokenize_done: + ; + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + return rc +} + +/************************************************************************** +** Start of porter stemmer implementation. + */ + +/* Any tokens larger than this (in bytes) are passed through without +** stemming. */ + +// C documentation +// +// /* +// ** If the input is a well-formed JSON array of coordinates with at least +// ** four coordinates and where each coordinate is itself a two-value array, +// ** then convert the JSON into a GeoPoly object and return a pointer to +// ** that object. +// ** +// ** If any error occurs, return NULL. +// */ +func _geopolyParseJson(tls *libc.TLS, z uintptr, pRc uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aNew, pOut, v1 uintptr + var c uint8 + var ii, rc int32 + var v2 bool + var _ /* s at bp+0 */ TGeoParse + var _ /* x at bp+32 */ int32 + _, _, _, _, _, _, _ = aNew, c, ii, pOut, rc, v1, v2 + rc = SQLITE_OK + libc.Xmemset(tls, bp, 0, uint64(32)) + (**(**TGeoParse)(__ccgo_up(bp))).Fz = z + if libc.Int32FromUint8(_geopolySkipSpace(tls, bp)) == int32('[') { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + for libc.Int32FromUint8(_geopolySkipSpace(tls, bp)) == int32('[') { + ii = 0 + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + if (**(**TGeoParse)(__ccgo_up(bp))).FnVertex >= (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc { + (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc = (**(**TGeoParse)(__ccgo_up(bp))).FnAlloc*int32(2) + int32(16) + aNew = Xsqlite3_realloc64(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa, uint64(libc.Uint64FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnAlloc)*uint64(4)*uint64(2))) + if aNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + break + } + (**(**TGeoParse)(__ccgo_up(bp))).Fa = aNew + } + for { + if ii <= int32(1) { + v1 = (**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)+ii)*4 + } else { + v1 = uintptr(0) + } + if !(_geopolyParseNumber(tls, bp, v1) != 0) { + break + } + ii = ii + 1 + if ii == int32(2) { + (**(**TGeoParse)(__ccgo_up(bp))).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex + 1 + } + c = _geopolySkipSpace(tls, bp) + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + if libc.Int32FromUint8(c) == int32(',') { + continue + } + if libc.Int32FromUint8(c) == int32(']') && ii >= int32(2) { + break + } + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + rc = int32(SQLITE_ERROR) + goto parse_json_err + } + if libc.Int32FromUint8(_geopolySkipSpace(tls, bp)) == int32(',') { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + continue + } + break + } + if v2 = libc.Int32FromUint8(_geopolySkipSpace(tls, bp)) == int32(']') && (**(**TGeoParse)(__ccgo_up(bp))).FnVertex >= int32(4) && **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa)) == **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)-int32(2))*4)) && **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + 1*4)) == **(**TGeoCoord)(__ccgo_up((**(**TGeoParse)(__ccgo_up(bp))).Fa + uintptr((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2)-int32(1))*4)); v2 { + (**(**TGeoParse)(__ccgo_up(bp))).Fz = (**(**TGeoParse)(__ccgo_up(bp))).Fz + 1 + } + if v2 && libc.Int32FromUint8(_geopolySkipSpace(tls, bp)) == libc.Int32FromInt32(0) { + **(**int32)(__ccgo_up(bp + 32)) = int32(1) + (**(**TGeoParse)(__ccgo_up(bp))).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex - 1 /* Remove the redundant vertex at the end */ + pOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(40)+uint64(libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2))*libc.Uint64FromInt64(int64((**(**TGeoParse)(__ccgo_up(bp))).FnVertex)-libc.Int64FromInt32(4))) + **(**int32)(__ccgo_up(bp + 32)) = int32(1) + if pOut == uintptr(0) { + goto parse_json_err + } + (*TGeoPoly)(unsafe.Pointer(pOut)).FnVertex = (**(**TGeoParse)(__ccgo_up(bp))).FnVertex + libc.Xmemcpy(tls, pOut+8, (**(**TGeoParse)(__ccgo_up(bp))).Fa, libc.Uint64FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex*int32(2))*uint64(4)) + **(**uint8)(__ccgo_up(pOut + 4)) = **(**uint8)(__ccgo_up(bp + 32)) + **(**uint8)(__ccgo_up(pOut + 4 + 1)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex >> int32(16) & int32(0xff)) + **(**uint8)(__ccgo_up(pOut + 4 + 2)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex >> int32(8) & int32(0xff)) + **(**uint8)(__ccgo_up(pOut + 4 + 3)) = libc.Uint8FromInt32((**(**TGeoParse)(__ccgo_up(bp))).FnVertex & int32(0xff)) + Xsqlite3_free(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa) + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = SQLITE_OK + } + return pOut + } else { + (**(**TGeoParse)(__ccgo_up(bp))).FnErr = (**(**TGeoParse)(__ccgo_up(bp))).FnErr + 1 + rc = int32(SQLITE_ERROR) + } + } + goto parse_json_err +parse_json_err: + ; + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = rc + } + Xsqlite3_free(tls, (**(**TGeoParse)(__ccgo_up(bp))).Fa) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Interpret the given string as a safety level. Return 0 for OFF, +// ** 1 for ON or NORMAL, 2 for FULL, and 3 for EXTRA. Return 1 for an empty or +// ** unrecognized string argument. The FULL and EXTRA option is disallowed +// ** if the omitFull parameter it 1. +// ** +// ** Note that the values returned are one less that the values that +// ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done +// ** to support legacy SQL code. The safety level used to be boolean +// ** and older scripts may have used numbers 0 for OFF and 1 for ON. +// */ +func _getSafetyLevel(tls *libc.TLS, z uintptr, omitFull int32, dflt Tu8) (r Tu8) { + var i, n int32 + _, _ = i, n + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z)))])&int32(0x04) != 0 { + return libc.Uint8FromInt32(_sqlite3Atoi(tls, z)) + } + n = _sqlite3Strlen30(tls, z) + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1))) { + break + } + if libc.Int32FromUint8(_iLength[i]) == n && Xsqlite3_strnicmp(tls, uintptr(unsafe.Pointer(&_zText))+uintptr(_iOffset[i]), z, n) == 0 && (!(omitFull != 0) || libc.Int32FromUint8(_iValue[i]) <= int32(1)) { + return _iValue[i] + } + goto _1 + _1: + ; + i = i + 1 + } + return dflt +} + +func _groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var db, pGCC, pnsl, zSep, zVal uintptr + var firstTerm, i, nA, nSep, nVal, v1 int32 + _, _, _, _, _, _, _, _, _, _, _ = db, firstTerm, i, nA, nSep, nVal, pGCC, pnsl, zSep, zVal, v1 + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + return + } + pGCC = Xsqlite3_aggregate_context(tls, context, int32(48)) + if pGCC != 0 { + db = Xsqlite3_context_db_handle(tls, context) + firstTerm = libc.BoolInt32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc == uint32(0)) + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc = libc.Uint32FromInt32(**(**int32)(__ccgo_up(db + 136))) + if argc == int32(1) { + if !(firstTerm != 0) { + Xsqlite3_str_appendchar(tls, pGCC, int32(1), uint8(',')) + } else { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength = int32(1) + } + } else { + if !(firstTerm != 0) { + zSep = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + nSep = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zSep != 0 { + Xsqlite3_str_append(tls, pGCC, zSep, nSep) + } else { + nSep = 0 + } + if nSep != (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength || (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths != uintptr(0) { + pnsl = (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths + if pnsl == uintptr(0) { + /* First separator length variation seen, start tracking them. */ + pnsl = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum+libc.Int32FromInt32(1))*uint64(4))) + if pnsl != uintptr(0) { + i = 0 + nA = (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum - int32(1) + for i < nA { + v1 = i + i = i + 1 + **(**int32)(__ccgo_up(pnsl + uintptr(v1)*4)) = (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength + } + } + } else { + pnsl = Xsqlite3_realloc64(tls, pnsl, uint64(libc.Uint64FromInt32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum)*uint64(4))) + } + if pnsl != uintptr(0) { + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum > 0 { + **(**int32)(__ccgo_up(pnsl + uintptr((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum-int32(1))*4)) = nSep + } + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths = pnsl + } else { + _sqlite3StrAccumSetError(tls, pGCC, uint8(SQLITE_NOMEM)) + } + } + } else { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + } + } + **(**int32)(__ccgo_up(pGCC + 32)) += int32(1) + zVal = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + nVal = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if zVal != 0 { + Xsqlite3_str_append(tls, pGCC, zVal, nVal) + } + } +} + +// C documentation +// +// /* +// ** The hex() function. Interpret the argument as a blob. Return +// ** a hexadecimal rendering as text. +// */ +func _hexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var c uint8 + var i, n int32 + var pBlob, z, zHex, v1 uintptr + _, _, _, _, _, _, _ = c, i, n, pBlob, z, zHex, v1 + _ = argc + pBlob = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + /* No encoding change */ + v1 = _contextMalloc(tls, context, int64(n)*int64(2)+int64(1)) + zHex = v1 + z = v1 + if zHex != 0 { + i = 0 + for { + if !(i < n) { + break + } + c = **(**uint8)(__ccgo_up(pBlob)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = _hexdigits[libc.Int32FromUint8(c)>>int32(4)&int32(0xf)] + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = _hexdigits[libc.Int32FromUint8(c)&int32(0xf)] + goto _2 + _2: + ; + i = i + 1 + pBlob = pBlob + 1 + } + **(**uint8)(__ccgo_up(z)) = uint8(0) + Xsqlite3_result_text64(tls, context, zHex, libc.Uint64FromInt64(int64(z)-int64(zHex)), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) + } +} + +// C documentation +// +// /* +// ** Term pTerm is guaranteed to be a WO_IN term. It may be a component term +// ** of a vector IN expression of the form "(x, y, ...) IN (SELECT ...)". +// ** This function checks to see if the term is compatible with an index +// ** column with affinity idxaff (one of the SQLITE_AFF_XYZ values). If so, +// ** it returns a pointer to the name of the collation sequence (e.g. "BINARY" +// ** or "NOCASE") used by the comparison in pTerm. If it is not compatible +// ** with affinity idxaff, NULL is returned. +// */ +func _indexInAffinityOk(tls *libc.TLS, pParse uintptr, pTerm uintptr, idxaff Tu8) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iField int32 + var pRet, pX, v1 uintptr + var _ /* inexpr at bp+0 */ TExpr + _, _, _, _ = iField, pRet, pX, v1 + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft) != 0 { + iField = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField - int32(1) + (**(**TExpr)(__ccgo_up(bp))).Fflags = uint32(0) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_EQ) + (**(**TExpr)(__ccgo_up(bp))).FpLeft = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pX)).FpLeft + 32)) + 8 + uintptr(iField)*32))).FpExpr + (**(**TExpr)(__ccgo_up(bp))).FpRight = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32)))).FpEList + 8 + uintptr(iField)*32))).FpExpr + pX = bp + } + if _sqlite3IndexAffinityOk(tls, pX, idxaff) != 0 { + pRet = _sqlite3ExprCompareCollSeq(tls, pParse, pX) + if pRet != 0 { + v1 = (*TCollSeq)(unsafe.Pointer(pRet)).FzName + } else { + v1 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + return v1 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Process time function arguments. argv[0] is a date-time stamp. +// ** argv[1] and following are modifiers. Parse them all and write +// ** the resulting time into the DateTime structure p. Return 0 +// ** on success and 1 if there are any errors. +// ** +// ** If there are zero parameters (if even argv[0] is undefined) +// ** then assume a default value of "now" for argv[0]. +// */ +func _isDate(tls *libc.TLS, context uintptr, argc int32, argv uintptr, p uintptr) (r int32) { + var eType, i, n, v1 int32 + var z uintptr + _, _, _, _, _ = eType, i, n, z, v1 + libc.Xmemset(tls, p, 0, uint64(48)) + if argc == 0 { + if !(_sqlite3NotPureFunc(tls, context) != 0) { + return int32(1) + } + return _setDateTimeToCurrent(tls, context, p) + } + v1 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) + eType = v1 + if v1 == int32(SQLITE_FLOAT) || eType == int32(SQLITE_INTEGER) { + _setRawDateNumber(tls, p, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))) + } else { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if !(z != 0) || _parseDateOrTime(tls, context, z, p) != 0 { + return int32(1) + } + } + i = int32(1) + for { + if !(i < argc) { + break + } + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if z == uintptr(0) || _parseModifier(tls, context, z, n, p, i) != 0 { + return int32(1) + } + goto _2 + _2: + ; + i = i + 1 + } + _computeJD(tls, p) + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x2>>1)) != 0 || !(_validJulianDay(tls, (*TDateTime)(unsafe.Pointer(p)).FiJD) != 0) { + return int32(1) + } + if argc == int32(1) && (*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0 && (*TDateTime)(unsafe.Pointer(p)).FD > int32(28) { + /* Make sure a YYYY-MM-DD is normalized. + ** Example: 2023-02-31 -> 2023-03-03 */ + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(0) + } + return 0 +} + +/* +** The following routines implement the various date and time functions +** of SQLite. + */ + +// C documentation +// +// /* +// ** Check to see if the given expression is a LIKE or GLOB operator that +// ** can be optimized using inequality constraints. Return TRUE if it is +// ** so and false if not. +// ** +// ** In order for the operator to be optimizible, the RHS must be a string +// ** literal that does not begin with a wildcard. The LHS must be a column +// ** that may only be NULL, a string, or a BLOB, never a number. (This means +// ** that virtual tables cannot participate in the LIKE optimization.) The +// ** collating sequence for the column on the LHS must be appropriate for +// ** the operator. +// */ +func _isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr, pisComplete uintptr, pnoCase uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, v1 Tu8 + var cnt, iCol, iFrom, iTo, isNum, op, r1, rc, v3 int32 + var db, pLeft, pList, pPrefix, pReprepare, pRight, pVal, v, z, zNew uintptr + var _ /* rDummy at bp+16 */ float64 + var _ /* wc at bp+0 */ [4]Tu8 + var _ /* z2 at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, cnt, db, iCol, iFrom, iTo, isNum, op, pLeft, pList, pPrefix, pReprepare, pRight, pVal, r1, rc, v, z, zNew, v1, v3 + z = uintptr(0) /* Wildcard characters */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + pVal = uintptr(0) /* Result code to return */ + if !(_sqlite3IsLikeFunction(tls, db, pExpr, pnoCase, bp) != 0) { + return 0 + } + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + pLeft = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr + pRight = _sqlite3ExprSkipCollate(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8))).FpExpr) + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) + if op == int32(TK_VARIABLE) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_EnableQPSG) == uint64(0) { + pReprepare = (*TParse)(unsafe.Pointer(pParse)).FpReprepare + iCol = int32((*TExpr)(unsafe.Pointer(pRight)).FiColumn) + pVal = _sqlite3VdbeGetBoundValue(tls, pReprepare, iCol, uint8(SQLITE_AFF_BLOB)) + if pVal != 0 && Xsqlite3_value_type(tls, pVal) == int32(SQLITE_TEXT) { + z = Xsqlite3_value_text(tls, pVal) + } + _sqlite3VdbeSetVarmask(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, iCol) + } else { + if op == int32(TK_STRING) { + z = *(*uintptr)(unsafe.Pointer(pRight + 8)) + } + } + if z != 0 { + /* Count the number of prefix bytes prior to the first wildcard, + ** U+fffd character, or malformed utf-8. If the underlying database + ** has a UTF16LE encoding, then only consider ASCII characters. Note that + ** the encoding of z[] is UTF8 - we are dealing with only UTF8 here in this + ** code, but the database engine itself might be processing content using a + ** different encoding. */ + cnt = 0 + for { + v1 = **(**Tu8)(__ccgo_up(z + uintptr(cnt))) + c = v1 + if !(libc.Int32FromUint8(v1) != 0 && libc.Int32FromUint8(c) != libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[0]) && libc.Int32FromUint8(c) != libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(1)]) && libc.Int32FromUint8(c) != libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(2)])) { + break + } + cnt = cnt + 1 + if libc.Int32FromUint8(c) == libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(3)]) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(cnt)))) > 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(cnt)))) < int32(0x80) { + cnt = cnt + 1 + } else { + if libc.Int32FromUint8(c) >= int32(0x80) { + **(**uintptr)(__ccgo_up(bp + 8)) = z + uintptr(cnt) - uintptr(1) + if libc.Int32FromUint8(c) == int32(0xff) || _sqlite3Utf8Read(tls, bp+8) == uint32(0xfffd) || libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Fenc) == int32(SQLITE_UTF16LE) { + cnt = cnt - 1 + break + } else { + cnt = int32(int64(**(**uintptr)(__ccgo_up(bp + 8))) - int64(z)) + } + } + } + } + /* The optimization is possible only if (1) the pattern does not begin + ** with a wildcard and if (2) the non-wildcard prefix does not end with + ** an (illegal 0xff) character, or (3) the pattern does not consist of + ** a single escape character. The second condition is necessary so + ** that we can increment the prefix key to find an upper bound for the + ** range search. The third is because the caller assumes that the pattern + ** consists of at least one character after all escapes have been + ** removed. */ + if (cnt > int32(1) || cnt > 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z))) != libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(3)])) && int32(255) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(cnt-int32(1))))) { + /* A "complete" match if the pattern ends with "*" or "%" */ + **(**int32)(__ccgo_up(pisComplete)) = libc.BoolInt32(libc.Int32FromUint8(c) == libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[0]) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(cnt+int32(1))))) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Fenc) != int32(SQLITE_UTF16LE)) + /* Get the pattern prefix. Remove all escapes from the prefix. */ + pPrefix = _sqlite3Expr(tls, db, int32(TK_STRING), z) + if pPrefix != 0 { + zNew = *(*uintptr)(unsafe.Pointer(pPrefix + 8)) + **(**uint8)(__ccgo_up(zNew + uintptr(cnt))) = uint8(0) + v3 = libc.Int32FromInt32(0) + iTo = v3 + iFrom = v3 + for { + if !(iFrom < cnt) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zNew + uintptr(iFrom)))) == libc.Int32FromUint8((**(**[4]Tu8)(__ccgo_up(bp)))[int32(3)]) { + iFrom = iFrom + 1 + } + v3 = iTo + iTo = iTo + 1 + **(**uint8)(__ccgo_up(zNew + uintptr(v3))) = **(**uint8)(__ccgo_up(zNew + uintptr(iFrom))) + goto _2 + _2: + ; + iFrom = iFrom + 1 + } + **(**uint8)(__ccgo_up(zNew + uintptr(iTo))) = uint8(0) + /* If the LHS is not an ordinary column with TEXT affinity, then the + ** pattern prefix boundaries (both the start and end boundaries) must + ** not look like a number. Otherwise the pattern might be treated as + ** a number, which will invalidate the LIKE optimization. + ** + ** Getting this right has been a persistent source of bugs in the + ** LIKE optimization. See, for example: + ** 2018-09-10 https://sqlite.org/src/info/c94369cae9b561b1 + ** 2019-05-02 https://sqlite.org/src/info/b043a54c3de54b28 + ** 2019-06-10 https://sqlite.org/src/info/fd76310a5e843e07 + ** 2019-06-14 https://sqlite.org/src/info/ce8717f0885af975 + ** 2019-09-03 https://sqlite.org/src/info/0f0428096f17252a + */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) != int32(TK_COLUMN) || libc.Int32FromUint8(_sqlite3ExprAffinity(tls, pLeft)) != int32(SQLITE_AFF_TEXT) || (*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) && *(*uintptr)(unsafe.Pointer(pLeft + 64)) != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64)))).FeTabType) == int32(TABTYP_VTAB) { + isNum = _sqlite3AtoF(tls, zNew, bp+16) + if isNum <= 0 { + if iTo == int32(1) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zNew))) == int32('-') { + isNum = +libc.Int32FromInt32(1) + } else { + **(**uint8)(__ccgo_up(zNew + uintptr(iTo-int32(1)))) = **(**uint8)(__ccgo_up(zNew + uintptr(iTo-int32(1)))) + 1 + isNum = _sqlite3AtoF(tls, zNew, bp+16) + **(**uint8)(__ccgo_up(zNew + uintptr(iTo-int32(1)))) = **(**uint8)(__ccgo_up(zNew + uintptr(iTo-int32(1)))) - 1 + } + } + if isNum > 0 { + _sqlite3ExprDelete(tls, db, pPrefix) + _sqlite3ValueFree(tls, pVal) + return 0 + } + } + } + **(**uintptr)(__ccgo_up(ppPrefix)) = pPrefix + /* If the RHS pattern is a bound parameter, make arrangements to + ** reprepare the statement when that parameter is rebound */ + if op == int32(TK_VARIABLE) { + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + _sqlite3VdbeSetVarmask(tls, v, int32((*TExpr)(unsafe.Pointer(pRight)).FiColumn)) + if **(**int32)(__ccgo_up(pisComplete)) != 0 && **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pRight + 8)) + 1)) != 0 { + /* If the rhs of the LIKE expression is a variable, and the current + ** value of the variable means there is no need to invoke the LIKE + ** function, then no OP_Variable will be added to the program. + ** This causes problems for the sqlite3_bind_parameter_name() + ** API. To work around them, add a dummy OP_Variable here. + */ + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3ExprCodeTarget(tls, pParse, pRight, r1) + _sqlite3VdbeChangeP3(tls, v, _sqlite3VdbeCurrentAddr(tls, v)-int32(1), 0) + _sqlite3ReleaseTempReg(tls, pParse, r1) + } + } + } else { + z = uintptr(0) + } + } + rc = libc.BoolInt32(z != uintptr(0)) + _sqlite3ValueFree(tls, pVal) + return rc +} + +func _jsonAppendChar(tls *libc.TLS, p uintptr, c uint8) { + var v1 Tu64 + var v2 uintptr + _, _ = v1, v2 + if (*TJsonString)(unsafe.Pointer(p)).FnUsed >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc { + _jsonAppendCharExpand(tls, p, c) + } else { + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = c + } +} + +// C documentation +// +// /* Append a single character +// */ +func _jsonAppendCharExpand(tls *libc.TLS, p uintptr, c uint8) { + var v1 Tu64 + var v2 uintptr + _, _ = v1, v2 + if _jsonStringGrow(tls, p, uint32(1)) != 0 { + return + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = c +} + +// C documentation +// +// /* Append the N-byte string in zIn to the end of the JsonString string +// ** under construction. Enclose the string in double-quotes ("...") and +// ** escape any double-quotes or backslash characters contained within the +// ** string. +// ** +// ** This routine is a high-runner. There is a measurable performance +// ** increase associated with unwinding the jsonIsOk[] loop. +// */ +func _jsonAppendString(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + var c Tu8 + var k Tu32 + var z, v2 uintptr + var v1 Tu64 + _, _, _, _, _ = c, k, z, v1, v2 + z = zIn + if z == uintptr(0) { + return + } + if uint64(N)+(*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(2) >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(2)) != 0 { + return + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = uint8('"') + for int32(1) != 0 { + k = uint32(0) + /* The following while() is the 4-way unwound equivalent of + ** + ** while( k= N { + for k < N && _jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k)))] != 0 { + k = k + 1 + } + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k)))] != 0) { + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(1))))] != 0) { + k = k + uint32(1) + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(2))))] != 0) { + k = k + uint32(2) + break + } + if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(k+uint32(3))))] != 0) { + k = k + uint32(3) + break + } else { + k = k + uint32(4) + } + } + if k >= N { + if k > uint32(0) { + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), z, uint64(k)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(k) + } + break + } + if k > uint32(0) { + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), z, uint64(k)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(k) + z = z + uintptr(k) + N = N - k + } + c = **(**Tu8)(__ccgo_up(z)) + if libc.Int32FromUint8(c) == int32('"') || libc.Int32FromUint8(c) == int32('\\') { + if (*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(N)+uint64(3) > (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(3)) != 0 { + return + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = uint8('\\') + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = c + } else { + if libc.Int32FromUint8(c) == int32('\'') { + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = c + } else { + if (*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(N)+uint64(7) > (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, N+uint32(7)) != 0 { + return + } + _jsonAppendControlChar(tls, p, c) + } + } + z = z + 1 + N = N - 1 + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = uint8('"') +} + +// C documentation +// +// /* +// ** Implementation of the json_array(VALUE,...) function. Return a JSON +// ** array that contains all values given in arguments. Or if any argument +// ** is a BLOB, throw an error. +// */ +func _jsonArrayFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var i int32 + var _ /* jx at bp+0 */ TJsonString + _ = i + _jsonStringInit(tls, bp, ctx) + _jsonAppendChar(tls, bp, uint8('[')) + i = 0 + for { + if !(i < argc) { + break + } + _jsonAppendSeparator(tls, bp) + _jsonAppendSqlValue(tls, bp, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + _jsonAppendChar(tls, bp, uint8(']')) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /**************************************************************************** +// ** Aggregate SQL function implementations +// ****************************************************************************/ +// /* +// ** json_group_array(VALUE) +// ** +// ** Return a JSON array composed of all values in the aggregate. +// */ +func _jsonArrayStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var pStr uintptr + _ = pStr + _ = argc + pStr = Xsqlite3_aggregate_context(tls, ctx, int32(136)) + if pStr != 0 { + if (*TJsonString)(unsafe.Pointer(pStr)).FzBuf == uintptr(0) { + _jsonStringInit(tls, pStr, ctx) + _jsonAppendChar(tls, pStr, uint8('[')) + } else { + if (*TJsonString)(unsafe.Pointer(pStr)).FnUsed > uint64(1) { + _jsonAppendChar(tls, pStr, uint8(',')) + } + } + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + _jsonAppendSqlValue(tls, pStr, **(**uintptr)(__ccgo_up(argv))) + } +} + +// C documentation +// +// /* This helper routine for jsonLookupStep() populates pIns with +// ** binary data that is to be inserted into pParse. +// ** +// ** In the common case, pIns just points to pParse->aIns and pParse->nIns. +// ** But if the zPath of the original edit operation includes path elements +// ** that go deeper, additional substructure must be created. +// ** +// ** For example: +// ** +// ** json_insert('{}', '$.a.b.c', 123); +// ** +// ** The search stops at '$.a' But additional substructure must be +// ** created for the ".b.c" part of the patch so that the final result +// ** is: {"a":{"b":{"c"::123}}}. This routine populates pIns with +// ** the binary equivalent of {"b":{"c":123}} so that it can be inserted. +// ** +// ** The caller is responsible for resetting pIns when it has finished +// ** using the substructure. +// */ +func _jsonCreateEditSubstructure(tls *libc.TLS, pParse uintptr, pIns uintptr, zTail uintptr) (r Tu32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + libc.Xmemset(tls, pIns, 0, uint64(72)) + (*TJsonParse)(unsafe.Pointer(pIns)).Fdb = (*TJsonParse)(unsafe.Pointer(pParse)).Fdb + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zTail))) == 0 { + /* No substructure. Just insert what is given in pParse. */ + (*TJsonParse)(unsafe.Pointer(pIns)).FaBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FaIns + (*TJsonParse)(unsafe.Pointer(pIns)).FnBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FnIns + rc = 0 + } else { + /* Construct the binary substructure */ + (*TJsonParse)(unsafe.Pointer(pIns)).FnBlob = uint32(1) + (*TJsonParse)(unsafe.Pointer(pIns)).FaBlob = uintptr(unsafe.Pointer(&_emptyObject)) + libc.BoolUintptr(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zTail))) == int32('.')) + (*TJsonParse)(unsafe.Pointer(pIns)).FeEdit = (*TJsonParse)(unsafe.Pointer(pParse)).FeEdit + (*TJsonParse)(unsafe.Pointer(pIns)).FnIns = (*TJsonParse)(unsafe.Pointer(pParse)).FnIns + (*TJsonParse)(unsafe.Pointer(pIns)).FaIns = (*TJsonParse)(unsafe.Pointer(pParse)).FaIns + (*TJsonParse)(unsafe.Pointer(pIns)).FiDepth = libc.Uint16FromInt32(libc.Int32FromUint16((*TJsonParse)(unsafe.Pointer(pParse)).FiDepth) + int32(1)) + if libc.Int32FromUint16((*TJsonParse)(unsafe.Pointer(pIns)).FiDepth) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = libc.Int32FromUint32(_jsonLookupStep(tls, pIns, uint32(0), zTail, uint32(0))) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + v1 = pParse + 47 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pIns)).Foom)) + } + return libc.Uint32FromInt32(rc) /* Error code only */ +} + +// C documentation +// +// /* Return the value of a column */ +func _jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, iColumn int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType Tu8 + var i, i1, i2, j, n, n1 Tu32 + var nBase Tu64 + var p uintptr + var _ /* x at bp+0 */ Ti64 + _, _, _, _, _, _, _, _, _ = eType, i, i1, i2, j, n, n1, nBase, p + p = cur + switch iColumn { + case JEACH_KEY: + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent == uint32(0) { + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot == uint32(1) { + break + } + j = libc.Uint32FromInt32(_jsonEachPathLength(tls, p)) + n = (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot - j + if n == uint32(0) { + break + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf + uintptr(j)))) == int32('[') { + _sqlite3Atoi64(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf+uintptr(j+uint32(1)), bp, libc.Int32FromUint32(n-uint32(1)), uint8(SQLITE_UTF8)) + Xsqlite3_result_int64(tls, ctx, **(**Ti64)(__ccgo_up(bp))) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf + uintptr(j+uint32(1))))) == int32('"') { + Xsqlite3_result_text(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf+uintptr(j+uint32(2)), libc.Int32FromUint32(n-uint32(3)), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_text(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf+uintptr(j+uint32(1)), libc.Int32FromUint32(n-uint32(1)), uintptr(-libc.Int32FromInt32(1))) + } + } + } + break + } + if libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeType) == int32(JSONB_OBJECT) { + _jsonReturnFromBlob(tls, p+192, (*TJsonEachCursor)(unsafe.Pointer(p)).Fi, ctx, int32(1)) + } else { + Xsqlite3_result_int64(tls, ctx, (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiKey) + } + case int32(JEACH_VALUE): + i = libc.Uint32FromInt32(_jsonSkipLabel(tls, p)) + _jsonReturnFromBlob(tls, p+192, i, ctx, libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeMode)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i))))&int32(0x0f) >= int32(JSONB_ARRAY) { + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } + case int32(JEACH_TYPE): + i1 = libc.Uint32FromInt32(_jsonSkipLabel(tls, p)) + eType = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i1)))) & int32(0x0f)) + Xsqlite3_result_text(tls, ctx, _jsonbType[eType], -int32(1), libc.UintptrFromInt32(0)) + case int32(JEACH_ATOM): + i2 = libc.Uint32FromInt32(_jsonSkipLabel(tls, p)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i2))))&int32(0x0f) < int32(JSONB_ARRAY) { + _jsonReturnFromBlob(tls, p+192, i2, ctx, int32(1)) + } + case int32(JEACH_ID): + Xsqlite3_result_int64(tls, ctx, libc.Int64FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).Fi)) + case int32(JEACH_PARENT): + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent > uint32(0) && (*TJsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { + Xsqlite3_result_int64(tls, ctx, libc.Int64FromUint32((**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiHead)) + } + case int32(JEACH_FULLKEY): + nBase = (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent != 0 { + _jsonAppendPathName(tls, p) + } + Xsqlite3_result_text64(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed, uintptr(-libc.Int32FromInt32(1)), uint8(SQLITE_UTF8)) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed = nBase + case int32(JEACH_PATH): + n1 = libc.Uint32FromInt32(_jsonEachPathLength(tls, p)) + Xsqlite3_result_text64(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf, uint64(n1), uintptr(-libc.Int32FromInt32(1)), uint8(SQLITE_UTF8)) + default: + Xsqlite3_result_text(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf, libc.Int32FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot), libc.UintptrFromInt32(0)) + case int32(JEACH_JSON): + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson == uintptr(0) { + Xsqlite3_result_blob(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob, libc.Int32FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FnBlob), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_text(tls, ctx, (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } + break + } + return SQLITE_OK +} + +// C documentation +// +// /* Length of the path for rowid==0 in bRecursive mode. +// */ +func _jsonEachPathLength(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var cSaved uint8 + var n, x Tu32 + var z uintptr + var _ /* sz at bp+0 */ Tu32 + _, _, _, _ = cSaved, n, x, z + n = uint32((*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed) + z = (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FzBuf + if (*TJsonEachCursor)(unsafe.Pointer(p)).FiRowid == uint32(0) && (*TJsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 && n >= uint32(2) { + for n > uint32(1) { + n = n - 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) == int32('[') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) == int32('.') { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + cSaved = **(**uint8)(__ccgo_up(z + uintptr(n))) + **(**uint8)(__ccgo_up(z + uintptr(n))) = uint8(0) + x = _jsonLookupStep(tls, p+192, uint32(0), z+uintptr(1), uint32(0)) + **(**uint8)(__ccgo_up(z + uintptr(n))) = cSaved + if x >= uint32(JSON_LOOKUP_PATHERROR) { + continue + } + if x+_jsonbPayloadSize(tls, p+192, x, bp) == (*TJsonEachCursor)(unsafe.Pointer(p)).Fi { + break + } + } + } + } + return libc.Int32FromUint32(n) +} + +// C documentation +// +// /* +// ** json_error_position(JSON) +// ** +// ** If the argument is NULL, return NULL +// ** +// ** If the argument is BLOB, do a full validity check and return non-zero +// ** if the check fails. The return value is the approximate 1-based offset +// ** to the byte of the element that contains the first error. +// ** +// ** Otherwise interpret the argument is TEXT (even if it is numeric) and +// ** return the 1-based character position for where the parser first recognized +// ** that the input was not valid JSON, or return 0 if the input text looks +// ** ok. JSON-5 extensions are accepted. +// */ +func _jsonErrorFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iErrPos Ti64 + var k Tu32 + var _ /* s at bp+0 */ TJsonParse + _, _ = iErrPos, k + iErrPos = 0 + _ = argc + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TJsonParse)(__ccgo_up(bp))).Fdb = Xsqlite3_context_db_handle(tls, ctx) + if _jsonArgIsJsonb(tls, **(**uintptr)(__ccgo_up(argv)), bp) != 0 { + iErrPos = libc.Int64FromUint32(_jsonbValidityCheck(tls, bp, uint32(0), (**(**TJsonParse)(__ccgo_up(bp))).FnBlob, uint32(1))) + } else { + (**(**TJsonParse)(__ccgo_up(bp))).FzJson = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if (**(**TJsonParse)(__ccgo_up(bp))).FzJson == uintptr(0) { + return + } /* NULL input or OOM */ + (**(**TJsonParse)(__ccgo_up(bp))).FnJson = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if _jsonConvertTextToBlob(tls, bp, uintptr(0)) != 0 { + if (**(**TJsonParse)(__ccgo_up(bp))).Foom != 0 { + iErrPos = int64(-int32(1)) + } else { + /* Because s.oom is false */ + k = uint32(0) + for { + if !(k < (**(**TJsonParse)(__ccgo_up(bp))).FiErr && **(**uint8)(__ccgo_up((**(**TJsonParse)(__ccgo_up(bp))).FzJson + uintptr(k))) != 0) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((**(**TJsonParse)(__ccgo_up(bp))).FzJson + uintptr(k))))&int32(0xc0) != int32(0x80) { + iErrPos = iErrPos + 1 + } + goto _1 + _1: + ; + k = k + 1 + } + iErrPos = iErrPos + 1 + } + } + } + _jsonParseReset(tls, bp) + if iErrPos < 0 { + Xsqlite3_result_error_nomem(tls, ctx) + } else { + Xsqlite3_result_int64(tls, ctx, iErrPos) + } +} + +// C documentation +// +// /* +// ** This method works for both json_group_array() and json_group_object(). +// ** It works by removing the first element of the group by searching forward +// ** to the first comma (",") that is not within a string and deleting all +// ** text through that comma. +// */ +func _jsonGroupInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var c, v2 uint8 + var i uint32 + var inStr, nNest int32 + var pStr, z uintptr + var v3 bool + _, _, _, _, _, _, _, _ = c, i, inStr, nNest, pStr, z, v2, v3 + inStr = 0 + nNest = 0 + _ = argc + _ = argv + pStr = Xsqlite3_aggregate_context(tls, ctx, 0) + /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will + ** always have been called to initialize it */ + if !(pStr != 0) { + return + } + z = (*TJsonString)(unsafe.Pointer(pStr)).FzBuf + i = uint32(1) + for { + if v3 = uint64(i) < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed; v3 { + v2 = **(**uint8)(__ccgo_up(z + uintptr(i))) + c = v2 + } + if !(v3 && (libc.Int32FromUint8(v2) != int32(',') || inStr != 0 || nNest != 0)) { + break + } + if libc.Int32FromUint8(c) == int32('"') { + inStr = libc.BoolInt32(!(inStr != 0)) + } else { + if libc.Int32FromUint8(c) == int32('\\') { + i = i + 1 + } else { + if !(inStr != 0) { + if libc.Int32FromUint8(c) == int32('{') || libc.Int32FromUint8(c) == int32('[') { + nNest = nNest + 1 + } + if libc.Int32FromUint8(c) == int32('}') || libc.Int32FromUint8(c) == int32(']') { + nNest = nNest - 1 + } + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + if uint64(i) < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed { + **(**Tu64)(__ccgo_up(pStr + 24)) -= uint64(i) + libc.Xmemmove(tls, z+1, z+uintptr(i+uint32(1)), (*TJsonString)(unsafe.Pointer(pStr)).FnUsed-uint64(1)) + **(**uint8)(__ccgo_up(z + uintptr((*TJsonString)(unsafe.Pointer(pStr)).FnUsed))) = uint8(0) + } else { + (*TJsonString)(unsafe.Pointer(pStr)).FnUsed = uint64(1) + } +} + +// C documentation +// +// /* argv[0] is a BLOB that seems likely to be a JSONB. Subsequent +// ** arguments come in pairs where each pair contains a JSON path and +// ** content to insert or set at that patch. Do the updates +// ** and return the result. +// ** +// ** The specific operation is determined by eEdit, which can be one +// ** of JEDIT_INS, JEDIT_REPL, JEDIT_SET, or JEDIT_AINS. +// */ +func _jsonInsertIntoBlob(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr, eEdit int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var flgs, i, v1 int32 + var p, zPath uintptr + var rc Tu32 + var _ /* ax at bp+0 */ TJsonParse + _, _, _, _, _, _ = flgs, i, p, rc, zPath, v1 + rc = uint32(0) + zPath = uintptr(0) + if argc == int32(1) { + v1 = 0 + } else { + v1 = int32(JSON_EDITABLE) + } + flgs = v1 + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), libc.Uint32FromInt32(flgs)) + if p == uintptr(0) { + return + } + i = int32(1) + for { + if !(i < argc-int32(1)) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) == int32(SQLITE_NULL) { + goto _2 + } + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zPath == uintptr(0) { + Xsqlite3_result_error_nomem(tls, ctx) + _jsonParseFree(tls, p) + return + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) != int32('$') { + goto jsonInsertIntoBlob_patherror + } + if _jsonFunctionArgToBlob(tls, ctx, **(**uintptr)(__ccgo_up(argv + uintptr(i+int32(1))*8)), bp) != 0 { + _jsonParseReset(tls, bp) + _jsonParseFree(tls, p) + return + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + 1))) == 0 { + if eEdit == int32(JEDIT_REPL) || eEdit == int32(JEDIT_SET) { + _jsonBlobEdit(tls, p, uint32(0), (*TJsonParse)(unsafe.Pointer(p)).FnBlob, (**(**TJsonParse)(__ccgo_up(bp))).FaBlob, (**(**TJsonParse)(__ccgo_up(bp))).FnBlob) + } + rc = uint32(0) + } else { + (*TJsonParse)(unsafe.Pointer(p)).FeEdit = libc.Uint8FromInt32(eEdit) + (*TJsonParse)(unsafe.Pointer(p)).FnIns = (**(**TJsonParse)(__ccgo_up(bp))).FnBlob + (*TJsonParse)(unsafe.Pointer(p)).FaIns = (**(**TJsonParse)(__ccgo_up(bp))).FaBlob + (*TJsonParse)(unsafe.Pointer(p)).Fdelta = 0 + (*TJsonParse)(unsafe.Pointer(p)).FiDepth = uint16(0) + rc = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + } + _jsonParseReset(tls, bp) + if rc == uint32(JSON_LOOKUP_NOTFOUND) { + goto _2 + } + if rc >= uint32(JSON_LOOKUP_PATHERROR) { + goto jsonInsertIntoBlob_patherror + } + goto _2 + _2: + ; + i = i + int32(2) + } + _jsonReturnParse(tls, ctx, p) + _jsonParseFree(tls, p) + return + goto jsonInsertIntoBlob_patherror +jsonInsertIntoBlob_patherror: + ; + _jsonParseFree(tls, p) + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(rc)) + return +} + +// C documentation +// +// /* +// ** json_remove(JSON, PATH, ...) +// ** +// ** Remove the named elements from JSON and return the result. malformed +// ** JSON or PATH arguments result in an error. +// */ +func _jsonRemoveFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var i, v1 int32 + var p, zPath uintptr + var rc Tu32 + _, _, _, _, _ = i, p, rc, zPath, v1 /* The parse */ + zPath = uintptr(0) /* Subroutine return code */ + if argc < int32(1) { + return + } + if argc > int32(1) { + v1 = int32(JSON_EDITABLE) + } else { + v1 = 0 + } + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), libc.Uint32FromInt32(v1)) + if p == uintptr(0) { + return + } + i = int32(1) + for { + if !(i < argc) { + break + } + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zPath == uintptr(0) { + goto json_remove_done + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) != int32('$') { + goto json_remove_patherror + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + 1))) == 0 { + /* json_remove(j,'$') returns NULL */ + goto json_remove_done + } + (*TJsonParse)(unsafe.Pointer(p)).FeEdit = uint8(JEDIT_DEL) + (*TJsonParse)(unsafe.Pointer(p)).Fdelta = 0 + rc = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + if rc >= uint32(JSON_LOOKUP_PATHERROR) { + if rc == uint32(JSON_LOOKUP_NOTFOUND) { + goto _2 /* No-op */ + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(rc)) + } + goto json_remove_done + } + goto _2 + _2: + ; + i = i + 1 + } + _jsonReturnParse(tls, ctx, p) + _jsonParseFree(tls, p) + return + goto json_remove_patherror +json_remove_patherror: + ; + _jsonBadPathError(tls, ctx, zPath, 0) + goto json_remove_done +json_remove_done: + ; + _jsonParseFree(tls, p) + return +} + +// C documentation +// +// /* +// ** json_type(JSON) +// ** json_type(JSON, PATH) +// ** +// ** Return the top-level "type" of a JSON string. json_type() raises an +// ** error if either the JSON or PATH inputs are not well-formed. +// */ +func _jsonTypeFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var i Tu32 + var p, zPath uintptr + _, _, _ = i, p, zPath /* The parse */ + zPath = uintptr(0) + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if p == uintptr(0) { + return + } + if argc == int32(2) { + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zPath == uintptr(0) { + goto json_type_done + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath))) != int32('$') { + _jsonBadPathError(tls, ctx, zPath, 0) + goto json_type_done + } + i = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + if i >= uint32(JSON_LOOKUP_PATHERROR) { + if i == uint32(JSON_LOOKUP_NOTFOUND) { + /* no-op */ + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(i)) + } + goto json_type_done + } + } else { + i = uint32(0) + } + Xsqlite3_result_text(tls, ctx, _jsonbType[libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob + uintptr(i))))&int32(0x0f)], -int32(1), libc.UintptrFromInt32(0)) + goto json_type_done +json_type_done: + ; + _jsonParseFree(tls, p) +} + +// C documentation +// +// /* +// ** Open an mem file handle. +// */ +func _memdbOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFd uintptr, flags int32, pOutFlags uintptr) (r int32) { + var apNew, p, pFile, pVfsMutex, v3 uintptr + var i, szName, v2 int32 + _, _, _, _, _, _, _, _ = apNew, i, p, pFile, pVfsMutex, szName, v2, v3 + pFile = pFd + p = uintptr(0) + _ = pVfs + libc.Xmemset(tls, pFile, 0, uint64(24)) + szName = _sqlite3Strlen30(tls, zName) + if szName > int32(1) && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName))) == int32('/') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName))) == int32('\\')) { + pVfsMutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1)) + Xsqlite3_mutex_enter(tls, pVfsMutex) + i = 0 + for { + if !(i < _memdb_g.FnMemStore) { + break + } + if libc.Xstrcmp(tls, (*TMemStore)(unsafe.Pointer(**(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(i)*8)))).FzFName, zName) == 0 { + p = **(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(i)*8)) + break + } + goto _1 + _1: + ; + i = i + 1 + } + if p == uintptr(0) { + p = _sqlite3Malloc(tls, uint64(72)+libc.Uint64FromInt64(int64(szName))+uint64(3)) + if p == uintptr(0) { + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + apNew = _sqlite3Realloc(tls, _memdb_g.FapMemStore, uint64(8)*libc.Uint64FromInt64(libc.Int64FromInt32(1)+int64(_memdb_g.FnMemStore))) + if apNew == uintptr(0) { + Xsqlite3_free(tls, p) + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + v3 = uintptr(unsafe.Pointer(&_memdb_g)) + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up(apNew + uintptr(v2)*8)) = p + _memdb_g.FapMemStore = apNew + libc.Xmemset(tls, p, 0, uint64(72)) + (*TMemStore)(unsafe.Pointer(p)).FmFlags = libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DESERIALIZE_RESIZEABLE) | libc.Int32FromInt32(SQLITE_DESERIALIZE_FREEONCLOSE)) + (*TMemStore)(unsafe.Pointer(p)).FszMax = _sqlite3Config.FmxMemdbSize + (*TMemStore)(unsafe.Pointer(p)).FzFName = p + 1*72 + libc.Xmemcpy(tls, (*TMemStore)(unsafe.Pointer(p)).FzFName, zName, libc.Uint64FromInt32(szName+int32(1))) + (*TMemStore)(unsafe.Pointer(p)).FpMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) + if (*TMemStore)(unsafe.Pointer(p)).FpMutex == uintptr(0) { + _memdb_g.FnMemStore = _memdb_g.FnMemStore - 1 + Xsqlite3_free(tls, p) + Xsqlite3_mutex_leave(tls, pVfsMutex) + return int32(SQLITE_NOMEM) + } + (*TMemStore)(unsafe.Pointer(p)).FnRef = int32(1) + _memdbEnter(tls, p) + } else { + _memdbEnter(tls, p) + (*TMemStore)(unsafe.Pointer(p)).FnRef = (*TMemStore)(unsafe.Pointer(p)).FnRef + 1 + } + Xsqlite3_mutex_leave(tls, pVfsMutex) + } else { + p = _sqlite3Malloc(tls, uint64(72)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, p, 0, uint64(72)) + (*TMemStore)(unsafe.Pointer(p)).FmFlags = libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DESERIALIZE_RESIZEABLE) | libc.Int32FromInt32(SQLITE_DESERIALIZE_FREEONCLOSE)) + (*TMemStore)(unsafe.Pointer(p)).FszMax = _sqlite3Config.FmxMemdbSize + } + (*TMemFile)(unsafe.Pointer(pFile)).FpStore = p + if pOutFlags != uintptr(0) { + **(**int32)(__ccgo_up(pOutFlags)) = flags | int32(SQLITE_OPEN_MEMORY) + } + (*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods = uintptr(unsafe.Pointer(&_memdb_io_methods)) + _memdbLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Parameter zSuper is the name of a super-journal file. A single journal +// ** file that referred to the super-journal file has just been rolled back. +// ** This routine checks if it is possible to delete the super-journal file, +// ** and does so if it is. +// ** +// ** Argument zSuper may point to Pager.pTmpSpace. So that buffer is not +// ** available for use within this function. +// ** +// ** When a super-journal file is created, it is populated with the names +// ** of all of its child journals, one after another, formatted as utf-8 +// ** encoded text. The end of each child journal file is marked with a +// ** nul-terminator byte (0x00). i.e. the entire contents of a super-journal +// ** file for a transaction involving two databases might be: +// ** +// ** "/home/bill/a.db-journal\x00/home/bill/b.db-journal\x00" +// ** +// ** A super-journal file may only be deleted once all of its child +// ** journals have been rolled back. +// ** +// ** This function reads the contents of the super-journal file into +// ** memory and loops through each of the child journal names. For +// ** each child journal, it checks if: +// ** +// ** * if the child journal exists, and if so +// ** * if the child journal contains a reference to super-journal +// ** file zSuper +// ** +// ** If a child journal can be found that matches both of the criteria +// ** above, this function returns without doing anything. Otherwise, if +// ** no such child journal can be found, file zSuper is deleted from +// ** the file-system using sqlite3OsDelete(). +// ** +// ** If an IO error within this function, an error code is returned. This +// ** function allocates memory by calling sqlite3Malloc(). If an allocation +// ** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors +// ** occur, SQLITE_OK is returned. +// ** +// ** TODO: This function allocates a single block of memory to load +// ** the entire contents of the super-journal file. This could be +// ** a couple of kilobytes or so - potentially larger than the page +// ** size. +// */ +func _pager_delsuper(tls *libc.TLS, pPager uintptr, zSuper uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, flags, flags1, rc int32 + var nSuperPtr Ti64 + var pJournal, pSuper, pVfs, zFree, zJournal, zSuperJournal, zSuperPtr uintptr + var v1, v2, v3 uint8 + var _ /* exists at bp+8 */ int32 + var _ /* nSuperJournal at bp+0 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, flags, flags1, nSuperPtr, pJournal, pSuper, pVfs, rc, zFree, zJournal, zSuperJournal, zSuperPtr, v1, v2, v3 + pVfs = (*TPager)(unsafe.Pointer(pPager)).FpVfs /* Malloc'd child-journal file descriptor */ + zSuperJournal = uintptr(0) /* Space to hold super-journal filename */ + zFree = uintptr(0) /* Amount of space allocated to zSuperPtr[] */ + /* Allocate space for both the pJournal and pSuper file descriptors. + ** If successful, open the super-journal file for reading. + */ + pSuper = _sqlite3MallocZero(tls, libc.Uint64FromInt64(int64(2)*int64((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile))) + if !(pSuper != 0) { + rc = int32(SQLITE_NOMEM) + pJournal = uintptr(0) + } else { + flags = libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_SUPER_JOURNAL) + rc = _sqlite3OsOpen(tls, pVfs, zSuper, pSuper, flags, uintptr(0)) + pJournal = pSuper + uintptr((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + } + if rc != SQLITE_OK { + goto delsuper_out + } + /* Load the entire super-journal file into space obtained from + ** sqlite3_malloc() and pointed to by zSuperJournal. Also obtain + ** sufficient space (in zSuperPtr) to hold the names of super-journal + ** files extracted from regular rollback-journals. + */ + rc = _sqlite3OsFileSize(tls, pSuper, bp) + if rc != SQLITE_OK { + goto delsuper_out + } + nSuperPtr = int64(1) + int64((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname) + zFree = _sqlite3Malloc(tls, libc.Uint64FromInt64(int64(4)+**(**Ti64)(__ccgo_up(bp))+int64(2)+nSuperPtr+int64(2))) + if !(zFree != 0) { + rc = int32(SQLITE_NOMEM) + goto delsuper_out + } else { + } + v3 = libc.Uint8FromInt32(0) + **(**uint8)(__ccgo_up(zFree + 3)) = v3 + v2 = v3 + **(**uint8)(__ccgo_up(zFree + 2)) = v2 + v1 = v2 + **(**uint8)(__ccgo_up(zFree + 1)) = v1 + **(**uint8)(__ccgo_up(zFree)) = v1 + zSuperJournal = zFree + 4 + zSuperPtr = zSuperJournal + uintptr(**(**Ti64)(__ccgo_up(bp))+int64(2)) + rc = _sqlite3OsRead(tls, pSuper, zSuperJournal, int32(**(**Ti64)(__ccgo_up(bp))), 0) + if rc != SQLITE_OK { + goto delsuper_out + } + **(**uint8)(__ccgo_up(zSuperJournal + uintptr(**(**Ti64)(__ccgo_up(bp))))) = uint8(0) + **(**uint8)(__ccgo_up(zSuperJournal + uintptr(**(**Ti64)(__ccgo_up(bp))+int64(1)))) = uint8(0) + zJournal = zSuperJournal + for int64(zJournal)-int64(zSuperJournal) < **(**Ti64)(__ccgo_up(bp)) { + rc = _sqlite3OsAccess(tls, pVfs, zJournal, SQLITE_ACCESS_EXISTS, bp+8) + if rc != SQLITE_OK { + goto delsuper_out + } + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + flags1 = libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_SUPER_JOURNAL) + rc = _sqlite3OsOpen(tls, pVfs, zJournal, pJournal, flags1, uintptr(0)) + if rc != SQLITE_OK { + goto delsuper_out + } + rc = _readSuperJournal(tls, pJournal, zSuperPtr, libc.Uint64FromInt64(nSuperPtr)) + _sqlite3OsClose(tls, pJournal) + if rc != SQLITE_OK { + goto delsuper_out + } + c = libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSuperPtr))) != 0 && libc.Xstrcmp(tls, zSuperPtr, zSuper) == 0) + if c != 0 { + /* We have a match. Do not delete the super-journal file. */ + goto delsuper_out + } + } + zJournal = zJournal + uintptr(_sqlite3Strlen30(tls, zJournal)+libc.Int32FromInt32(1)) + } + _sqlite3OsClose(tls, pSuper) + rc = _sqlite3OsDelete(tls, pVfs, zSuper, 0) + goto delsuper_out +delsuper_out: + ; + Xsqlite3_free(tls, zFree) + if pSuper != 0 { + _sqlite3OsClose(tls, pSuper) + Xsqlite3_free(tls, pSuper) + } + return rc +} + +// C documentation +// +// /* +// ** Compare two UTF-8 strings for equality where the first string is +// ** a GLOB or LIKE expression. Return values: +// ** +// ** SQLITE_MATCH: Match +// ** SQLITE_NOMATCH: No match +// ** SQLITE_NOWILDCARDMATCH: No match in spite of having * or % wildcards. +// ** +// ** Globbing rules: +// ** +// ** '*' Matches any sequence of zero or more characters. +// ** +// ** '?' Matches exactly one character. +// ** +// ** [...] Matches one character from the enclosed list of +// ** characters. +// ** +// ** [^...] Matches one character not in the enclosed list. +// ** +// ** With the [...] and [^...] matching, a ']' character can be included +// ** in the list by making it the first character after '[' or '^'. A +// ** range of characters can be specified using '-'. Example: +// ** "[a-z]" matches any single lower-case letter. To match a '-', make +// ** it the last character in the list. +// ** +// ** Like matching rules: +// ** +// ** '%' Matches any sequence of zero or more characters +// ** +// *** '_' Matches any one character +// ** +// ** Ec Where E is the "esc" character and c is any other +// ** character, including '%', '_', and esc, match exactly c. +// ** +// ** The comments within this routine usually assume glob matching. +// ** +// ** This routine is usually quick, but can be N**2 in the worst case. +// */ +func _patternCompare(tls *libc.TLS, _zPattern uintptr, _zString uintptr, pInfo uintptr, matchOther Tu32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + *(*uintptr)(unsafe.Pointer(bp)) = _zPattern + *(*uintptr)(unsafe.Pointer(bp + 8)) = _zString + var bMatch, bMatch1, bMatch2, invert, seen, v13 int32 + var c, c2, matchAll, matchOne, prior_c, v1, v4 Tu32 + var noCase Tu8 + var zEscaped, v3, v6 uintptr + var v2, v5 uint32 + var _ /* zStop at bp+18 */ [3]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bMatch, bMatch1, bMatch2, c, c2, invert, matchAll, matchOne, noCase, prior_c, seen, zEscaped, v1, v13, v2, v3, v4, v5, v6 /* Next pattern and input string chars */ + matchOne = uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchOne) /* "?" or "_" */ + matchAll = uint32((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchAll) /* "*" or "%" */ + noCase = (*TcompareInfo)(unsafe.Pointer(pInfo)).FnoCase /* True if uppercase==lowercase */ + zEscaped = uintptr(0) /* One past the last escaped input char */ + for { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) < int32(0x80) { + v3 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v2 = uint32(**(**Tu8)(__ccgo_up(v3))) + } else { + v2 = _sqlite3Utf8Read(tls, bp) + } + v1 = v2 + c = v1 + if !(v1 != uint32(0)) { + break + } + if c == matchAll { /* Match "*" */ + /* Skip over multiple "*" characters in the pattern. If there + ** are also "?" characters, skip those as well, but consume a + ** single character of the input string for each "?" skipped */ + for { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) < int32(0x80) { + v6 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v5 = uint32(**(**Tu8)(__ccgo_up(v6))) + } else { + v5 = _sqlite3Utf8Read(tls, bp) + } + v4 = v5 + c = v4 + if !(v4 == matchAll || c == matchOne && matchOne != uint32(0)) { + break + } + if c == matchOne && _sqlite3Utf8Read(tls, bp+8) == uint32(0) { + return int32(SQLITE_NOWILDCARDMATCH) + } + } + if c == uint32(0) { + return SQLITE_MATCH /* "*" at the end of the pattern matches */ + } else { + if c == matchOther { + if libc.Int32FromUint8((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 { + c = _sqlite3Utf8Read(tls, bp) + if c == uint32(0) { + return int32(SQLITE_NOWILDCARDMATCH) + } + } else { + /* "[...]" immediately follows the "*". We have to do a slow + ** recursive search in this case, but it is an unusual case. */ + /* '[' is a single-byte character */ + for **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != 0 { + bMatch = _patternCompare(tls, **(**uintptr)(__ccgo_up(bp))+uintptr(-libc.Int32FromInt32(1)), **(**uintptr)(__ccgo_up(bp + 8)), pInfo, matchOther) + if bMatch != int32(SQLITE_NOMATCH) { + return bMatch + } + v3 = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v3))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))))&int32(0xc0) == int32(0x80) { + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + } + } + } + return int32(SQLITE_NOWILDCARDMATCH) + } + } + } + /* At this point variable c contains the first character of the + ** pattern string past the "*". Search in the input string for the + ** first matching character and recursively continue the match from + ** that point. + ** + ** For a case-insensitive search, set variable cx to be the same as + ** c but in the other case and search the input string for either + ** c or cx. + */ + if c < uint32(0x80) { + if noCase != 0 { + (**(**[3]uint8)(__ccgo_up(bp + 18)))[0] = uint8(c & libc.Uint32FromInt32(^(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(c)]) & libc.Int32FromInt32(0x20)))) + (**(**[3]uint8)(__ccgo_up(bp + 18)))[int32(1)] = _sqlite3UpperToLower[uint8(c)] + (**(**[3]uint8)(__ccgo_up(bp + 18)))[int32(2)] = uint8(0) + } else { + (**(**[3]uint8)(__ccgo_up(bp + 18)))[0] = uint8(c) + (**(**[3]uint8)(__ccgo_up(bp + 18)))[int32(1)] = uint8(0) + } + for int32(1) != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(libc.Xstrcspn(tls, **(**uintptr)(__ccgo_up(bp + 8)), bp+18)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) == 0 { + break + } + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + bMatch1 = _patternCompare(tls, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 8)), pInfo, matchOther) + if bMatch1 != int32(SQLITE_NOMATCH) { + return bMatch1 + } + } + } else { + for { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) < int32(0x80) { + v3 = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + v2 = uint32(**(**Tu8)(__ccgo_up(v3))) + } else { + v2 = _sqlite3Utf8Read(tls, bp+8) + } + v1 = v2 + c2 = v1 + if !(v1 != uint32(0)) { + break + } + if c2 != c { + continue + } + bMatch2 = _patternCompare(tls, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 8)), pInfo, matchOther) + if bMatch2 != int32(SQLITE_NOMATCH) { + return bMatch2 + } + } + } + return int32(SQLITE_NOWILDCARDMATCH) + } + if c == matchOther { + if libc.Int32FromUint8((*TcompareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 { + c = _sqlite3Utf8Read(tls, bp) + if c == uint32(0) { + return int32(SQLITE_NOMATCH) + } + zEscaped = **(**uintptr)(__ccgo_up(bp)) + } else { + prior_c = uint32(0) + seen = 0 + invert = 0 + c = _sqlite3Utf8Read(tls, bp+8) + if c == uint32(0) { + return int32(SQLITE_NOMATCH) + } + c2 = _sqlite3Utf8Read(tls, bp) + if c2 == uint32('^') { + invert = int32(1) + c2 = _sqlite3Utf8Read(tls, bp) + } + if c2 == uint32(']') { + if c == uint32(']') { + seen = int32(1) + } + c2 = _sqlite3Utf8Read(tls, bp) + } + for c2 != 0 && c2 != uint32(']') { + if c2 == uint32('-') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(']') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != 0 && prior_c > uint32(0) { + c2 = _sqlite3Utf8Read(tls, bp) + if c >= prior_c && c <= c2 { + seen = int32(1) + } + prior_c = uint32(0) + } else { + if c == c2 { + seen = int32(1) + } + prior_c = c2 + } + c2 = _sqlite3Utf8Read(tls, bp) + } + if c2 == uint32(0) || seen^invert == 0 { + return int32(SQLITE_NOMATCH) + } + continue + } + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) < int32(0x80) { + v3 = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 1 + v2 = uint32(**(**Tu8)(__ccgo_up(v3))) + } else { + v2 = _sqlite3Utf8Read(tls, bp+8) + } + c2 = v2 + if c == c2 { + continue + } + if noCase != 0 && libc.Int32FromUint8(_sqlite3UpperToLower[uint8(c)]) == libc.Int32FromUint8(_sqlite3UpperToLower[uint8(c2)]) && c < uint32(0x80) && c2 < uint32(0x80) { + continue + } + if c == matchOne && **(**uintptr)(__ccgo_up(bp)) != zEscaped && c2 != uint32(0) { + continue + } + return int32(SQLITE_NOMATCH) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) == 0 { + v13 = SQLITE_MATCH + } else { + v13 = int32(SQLITE_NOMATCH) + } + return v13 +} + +// C documentation +// +// /* +// ** This is a Walker expression callback. pExpr is a node from the WHERE +// ** clause of a SELECT statement. This function examines pExpr to see if +// ** any substitutions based on the contents of pWalker->u.pConst should +// ** be made to pExpr or its immediate children. +// ** +// ** A substitution is made if: +// ** +// ** + pExpr is a column with an affinity other than BLOB that matches +// ** one of the columns in pWalker->u.pConst, or +// ** +// ** + pExpr is a binary comparison operator (=, <=, >=, <, >) that +// ** uses an affinity other than TEXT and one of its immediate +// ** children is a column that matches one of the columns in +// ** pWalker->u.pConst. +// */ +func _propagateConstantExprRewrite(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var pConst uintptr + _ = pConst + pConst = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + if (*TWhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) >= int32(TK_EQ) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) <= int32(TK_GE) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IS) { + _propagateConstantExprRewriteOne(tls, pConst, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, 0) + if **(**Tu8)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FpOomFault)) != 0 { + return int32(WRC_Prune) + } + if libc.Int32FromUint8(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft)) != int32(SQLITE_AFF_TEXT) { + _propagateConstantExprRewriteOne(tls, pConst, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, 0) + } + } + } + return _propagateConstantExprRewriteOne(tls, pConst, pExpr, (*TWhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob) +} + +// C documentation +// +// /* +// ** This is a helper function for Walker callback propagateConstantExprRewrite(). +// ** +// ** Argument pExpr is a candidate expression to be replaced by a value. If +// ** pExpr is equivalent to one of the columns named in pWalker->u.pConst, +// ** then overwrite it with the corresponding value. Except, do not do so +// ** if argument bIgnoreAffBlob is non-zero and the affinity of pExpr +// ** is SQLITE_AFF_BLOB. +// */ +func _propagateConstantExprRewriteOne(tls *libc.TLS, pConst uintptr, pExpr uintptr, bIgnoreAffBlob int32) (r int32) { + var i int32 + var pColumn uintptr + _, _ = i, pColumn + if **(**Tu8)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FpOomFault)) != 0 { + return int32(WRC_Prune) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLUMN) { + return WRC_Continue + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&(libc.Uint32FromInt32(EP_FixedCol)|(*TWhereConst)(unsafe.Pointer(pConst)).FmExcludeOn) != uint32(0) { + return WRC_Continue + } + i = 0 + for { + if !(i < (*TWhereConst)(unsafe.Pointer(pConst)).FnConst) { + break + } + pColumn = **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*int32(2))*8)) + if pColumn == pExpr { + goto _1 + } + if (*TExpr)(unsafe.Pointer(pColumn)).FiTable != (*TExpr)(unsafe.Pointer(pExpr)).FiTable { + goto _1 + } + if int32((*TExpr)(unsafe.Pointer(pColumn)).FiColumn) != int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) { + goto _1 + } + if bIgnoreAffBlob != 0 && libc.Int32FromUint8(_sqlite3ExprAffinity(tls, pColumn)) <= int32(SQLITE_AFF_BLOB) { + break + } + /* A match is found. Add the EP_FixedCol property */ + (*TWhereConst)(unsafe.Pointer(pConst)).FnChng = (*TWhereConst)(unsafe.Pointer(pConst)).FnChng + 1 + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer((*TWhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb, **(**uintptr)(__ccgo_up((*TWhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*int32(2)+int32(1))*8)), 0) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TWhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb)).FmallocFailed != 0 { + return int32(WRC_Prune) + } + break + goto _1 + _1: + ; + i = i + 1 + } + return int32(WRC_Prune) +} + +// C documentation +// +// /* +// ** Apply a delta. +// ** +// ** The output buffer should be big enough to hold the whole output +// ** file and a NUL terminator at the end. The delta_output_size() +// ** routine will determine this size for you. +// ** +// ** The delta string should be null-terminated. But the delta string +// ** may contain embedded NUL characters (if the input and output are +// ** binary files) so we also have to pass in the length of the delta in +// ** the lenDelta parameter. +// ** +// ** This function returns the size of the output file in bytes (excluding +// ** the final NUL terminator character). Except, if the delta string is +// ** malformed or intended for use with a source file other than zSrc, +// ** then this routine returns -1. +// ** +// ** Refer to the delta_create() documentation above for a description +// ** of the delta file format. +// */ +func _rbuDeltaApply(tls *libc.TLS, zSrc uintptr, lenSrc int32, _zDelta uintptr, _lenDelta int32, zOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _zDelta + *(*int32)(unsafe.Pointer(bp + 8)) = _lenDelta + var cnt, limit, ofst, total uint32 + _, _, _, _ = cnt, limit, ofst, total + total = uint32(0) + limit = _rbuDeltaGetInt(tls, bp, bp+8) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32('\n') { + /* ERROR: size integer not terminated by "\n" */ + return -int32(1) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + for **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0 && **(**int32)(__ccgo_up(bp + 8)) > 0 { + cnt = _rbuDeltaGetInt(tls, bp, bp+8) + switch libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) { + case int32('@'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + ofst = _rbuDeltaGetInt(tls, bp, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) > 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(',') { + /* ERROR: copy command not terminated by ',' */ + return -int32(1) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + total = total + cnt + if total > limit { + /* ERROR: copy exceeds output file size */ + return -int32(1) + } + if uint64(ofst)+uint64(cnt) > libc.Uint64FromInt32(lenSrc) { + /* ERROR: copy extends past end of input */ + return -int32(1) + } + libc.Xmemcpy(tls, zOut, zSrc+uintptr(ofst), uint64(cnt)) + zOut = zOut + uintptr(cnt) + case int32(':'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + total = total + cnt + if total > limit { + /* ERROR: insert command gives an output larger than predicted */ + return -int32(1) + } + if libc.Int32FromUint32(cnt) > **(**int32)(__ccgo_up(bp + 8)) { + /* ERROR: insert count exceeds size of delta */ + return -int32(1) + } + libc.Xmemcpy(tls, zOut, **(**uintptr)(__ccgo_up(bp)), uint64(cnt)) + zOut = zOut + uintptr(cnt) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(cnt) + **(**int32)(__ccgo_up(bp + 8)) = libc.Int32FromUint32(uint32(**(**int32)(__ccgo_up(bp + 8))) - cnt) + case int32(';'): + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int32)(__ccgo_up(bp + 8)) = **(**int32)(__ccgo_up(bp + 8)) - 1 + **(**uint8)(__ccgo_up(zOut)) = uint8(0) + if total != limit { + /* ERROR: generated size does not match predicted size */ + return -int32(1) + } + return libc.Int32FromUint32(total) + default: + /* ERROR: unknown delta operator */ + return -int32(1) + } + } + /* ERROR: unterminated delta */ + return -int32(1) +} + +func _rbuDeltaOutputSize(tls *libc.TLS, _zDelta uintptr, _lenDelta int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _zDelta + *(*int32)(unsafe.Pointer(bp + 8)) = _lenDelta + var size int32 + _ = size + size = libc.Int32FromUint32(_rbuDeltaGetInt(tls, bp, bp+8)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32('\n') { + /* ERROR: size integer not terminated by "\n" */ + return -int32(1) + } + return size +} + +/* +** End of code taken from fossil. +*************************************************************************/ + +// C documentation +// +// /* +// ** This function does the work for an sqlite3rbu_step() call. +// ** +// ** The object-iterator (p->objiter) currently points to a valid object, +// ** and the input cursor (p->objiter.pSelect) currently points to a valid +// ** input row. Perform whatever processing is required and return. +// ** +// ** If no error occurs, SQLITE_OK is returned. Otherwise, an error code +// ** and message is left in the RBU handle and a copy of the error code +// ** returned. +// */ +func _rbuStep(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c uint8 + var eType, i int32 + var pIter, pVal uintptr + var _ /* pUpdate at bp+8 */ uintptr + var _ /* zMask at bp+0 */ uintptr + _, _, _, _, _ = c, eType, i, pIter, pVal + pIter = p + 88 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + eType = _rbuStepType(tls, p, bp) + if eType != 0 { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) && (eType == int32(RBU_IDX_DELETE) || eType == int32(RBU_IDX_INSERT)) { + _rbuBadControlError(tls, p) + } else { + if eType == int32(RBU_REPLACE) { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + **(**Ti64)(__ccgo_up(p + 312)) += int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex) + _rbuStepOneOp(tls, p, int32(RBU_DELETE)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuStepOneOp(tls, p, int32(RBU_INSERT)) + } + } else { + if eType != int32(RBU_UPDATE) { + _rbuStepOneOp(tls, p, eType) + } else { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**Ti64)(__ccgo_up(p + 312)) -= int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex) + _rbuGetUpdateStmt(tls, p, pIter, **(**uintptr)(__ccgo_up(bp)), bp+8) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + i = 0 + for { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol) { + break + } + c = **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(**(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4))))) + pVal = Xsqlite3_column_value(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 || libc.Int32FromUint8(c) != int32('.') { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), i+int32(1), pVal) + } + goto _1 + _1: + ; + i = i + 1 + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && ((*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE)) { + /* Bind the rbu_rowid value to column _rowid_ */ + pVal = Xsqlite3_column_value(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol+int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol+int32(1), pVal) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _resetAndCollectError(tls, **(**uintptr)(__ccgo_up(bp + 8)), p+64) + } + } + } + } + } + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** When this is called the journal file for pager pPager must be open. +// ** This function attempts to read a super-journal file name from the +// ** end of the file and, if successful, copies it into memory supplied +// ** by the caller. See comments above writeSuperJournal() for the format +// ** used to store a super-journal file name at the end of a journal file. +// ** +// ** zSuper must point to a buffer of at least nSuper bytes allocated by +// ** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is +// ** enough space to write the super-journal name). If the super-journal +// ** name in the journal is longer than nSuper bytes (including a +// ** nul-terminator), then this is handled as if no super-journal name +// ** were present in the journal. +// ** +// ** If a super-journal file name is present at the end of the journal +// ** file, then it is copied into the buffer pointed to by zSuper. A +// ** nul-terminator byte is appended to the buffer following the +// ** super-journal file name. +// ** +// ** If it is determined that no super-journal file name is present +// ** zSuper[0] is set to 0 and SQLITE_OK returned. +// ** +// ** If an error occurs while reading from the journal file, an SQLite +// ** error code is returned. +// */ +func _readSuperJournal(tls *libc.TLS, pJrnl uintptr, zSuper uintptr, nSuper Tu64) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rc, v1, v2, v4, v6, v8 int32 + var u Tu32 + var v3, v5, v7, v9 bool + var _ /* aMagic at bp+24 */ [8]uint8 + var _ /* cksum at bp+16 */ Tu32 + var _ /* len at bp+0 */ Tu32 + var _ /* szJ at bp+8 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _ = rc, u, v1, v2, v3, v4, v5, v6, v7, v8, v9 /* A buffer to hold the magic header */ + **(**uint8)(__ccgo_up(zSuper)) = uint8('\000') + v1 = _sqlite3OsFileSize(tls, pJrnl, bp+8) + rc = v1 + if v3 = SQLITE_OK != v1 || **(**Ti64)(__ccgo_up(bp + 8)) < int64(16); !v3 { + v2 = _read32bits(tls, pJrnl, **(**Ti64)(__ccgo_up(bp + 8))-int64(16), bp) + rc = v2 + } + if v5 = v3 || SQLITE_OK != v2 || uint64(**(**Tu32)(__ccgo_up(bp))) >= nSuper || libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp))) > **(**Ti64)(__ccgo_up(bp + 8))-int64(16) || **(**Tu32)(__ccgo_up(bp)) == uint32(0); !v5 { + v4 = _read32bits(tls, pJrnl, **(**Ti64)(__ccgo_up(bp + 8))-int64(12), bp+16) + rc = v4 + } + if v7 = v5 || SQLITE_OK != v4; !v7 { + v6 = _sqlite3OsRead(tls, pJrnl, bp+24, int32(8), **(**Ti64)(__ccgo_up(bp + 8))-int64(8)) + rc = v6 + } + if v9 = v7 || SQLITE_OK != v6 || libc.Xmemcmp(tls, bp+24, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8)) != 0; !v9 { + v8 = _sqlite3OsRead(tls, pJrnl, zSuper, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))), **(**Ti64)(__ccgo_up(bp + 8))-int64(16)-libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp)))) + rc = v8 + } + if v9 || SQLITE_OK != v8 { + return rc + } + /* See if the checksum matches the super-journal name */ + u = uint32(0) + for { + if !(u < **(**Tu32)(__ccgo_up(bp))) { + break + } + **(**Tu32)(__ccgo_up(bp + 16)) = **(**Tu32)(__ccgo_up(bp + 16)) - uint32(**(**uint8)(__ccgo_up(zSuper + uintptr(u)))) + goto _10 + _10: + ; + u = u + 1 + } + if **(**Tu32)(__ccgo_up(bp + 16)) != 0 { + /* If the checksum doesn't add up, then one or more of the disk sectors + ** containing the super-journal filename is corrupted. This means + ** definitely roll back, so just return SQLITE_OK and report a (nul) + ** super-journal filename. + */ + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + } + **(**uint8)(__ccgo_up(zSuper + uintptr(**(**Tu32)(__ccgo_up(bp))))) = uint8('\000') + **(**uint8)(__ccgo_up(zSuper + uintptr(**(**Tu32)(__ccgo_up(bp))+uint32(1)))) = uint8('\000') + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This is the routine that actually formats the sqlite3_log() message. +// ** We house it in a separate routine from sqlite3_log() to avoid using +// ** stack space on small-stack systems when logging is disabled. +// ** +// ** sqlite3_log() must render into a static buffer. It cannot dynamically +// ** allocate memory because it might be called while the memory allocator +// ** mutex is held. +// ** +// ** sqlite3_str_vappendf() might ask for *temporary* memory allocations for +// ** certain format characters (%q) or for very large precisions or widths. +// ** Care must be taken that any sqlite3_log() calls that occur while the +// ** memory mutex is held do not use these mechanisms. +// */ +func _renderLogMsg(tls *libc.TLS, iErrCode int32, zFormat uintptr, ap Tva_list) { + bp := tls.Alloc(736) + defer tls.Free(736) + var _ /* acc at bp+0 */ TStrAccum + var _ /* zMsg at bp+32 */ [700]uint8 /* Complete log message */ + _sqlite3StrAccumInit(tls, bp, uintptr(0), bp+32, int32(700), 0) + Xsqlite3_str_vappendf(tls, bp, zFormat, ap) + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.FxLog})))(tls, _sqlite3Config.FpLogArg, iErrCode, _sqlite3StrAccumFinish(tls, bp)) +} + +// C documentation +// +// /* +// ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect. +// ** The Name context of the SELECT statement is pNC. zType is either +// ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is. +// ** +// ** This routine resolves each term of the clause into an expression. +// ** If the order-by term is an integer I between 1 and N (where N is the +// ** number of columns in the result set of the SELECT) then the expression +// ** in the resolution is a copy of the I-th result-set expression. If +// ** the order-by term is an identifier that corresponds to the AS-name of +// ** a result-set expression, then the term resolves to a copy of the +// ** result-set expression. Otherwise, the expression is resolved in +// ** the usual way - using sqlite3ResolveExprNames(). +// ** +// ** This routine returns the number of errors. If errors occur, then +// ** an appropriate error message might be left in pParse. (OOM errors +// ** excepted.) +// */ +func _resolveOrderGroupBy(tls *libc.TLS, pNC uintptr, pSelect uintptr, pOrderBy uintptr, zType uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j, nResult int32 + var pE, pE2, pItem, pParse uintptr + var _ /* iCol at bp+0 */ int32 + _, _, _, _, _, _, _ = i, j, nResult, pE, pE2, pItem, pParse /* Number of terms in the result set */ + nResult = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList)).FnExpr + pParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + i = 0 + pItem = pOrderBy + 8 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + pE = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + pE2 = _sqlite3ExprSkipCollateAndLikely(tls, pE) + if pE2 == uintptr(0) { + goto _1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zType))) != int32('G') { + **(**int32)(__ccgo_up(bp)) = _resolveAsName(tls, pParse, (*TSelect)(unsafe.Pointer(pSelect)).FpEList, pE2) + if **(**int32)(__ccgo_up(bp)) > 0 { + /* If an AS-name match is found, mark this ORDER BY column as being + ** a copy of the iCol-th result-set column. The subsequent call to + ** sqlite3ResolveOrderGroupBy() will convert the expression to a + ** copy of the iCol-th result-set expression. */ + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = libc.Uint16FromInt32(**(**int32)(__ccgo_up(bp))) + goto _1 + } + } + if _sqlite3ExprIsInteger(tls, pE2, bp, uintptr(0)) != 0 { + /* The ORDER BY term is an integer constant. Again, set the column + ** number so that sqlite3ResolveOrderGroupBy() will convert the + ** order-by term to a copy of the result-set expression */ + if **(**int32)(__ccgo_up(bp)) < int32(1) || **(**int32)(__ccgo_up(bp)) > int32(0xffff) { + _resolveOutOfRangeError(tls, pParse, zType, i+int32(1), nResult, pE2) + return int32(1) + } + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = libc.Uint16FromInt32(**(**int32)(__ccgo_up(bp))) + goto _1 + } + /* Otherwise, treat the ORDER BY term as an ordinary expression */ + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = uint16(0) + if _sqlite3ResolveExprNames(tls, pNC, pE) != 0 { + return int32(1) + } + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList)).FnExpr) { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), pE, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpEList + 8 + uintptr(j)*32))).FpExpr, -int32(1)) == 0 { + /* Since this expression is being changed into a reference + ** to an identical expression in the result set, remove all Window + ** objects belonging to the expression from the Select.pWin list. */ + _windowRemoveExprFromSelect(tls, pSelect, pE) + (*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol = libc.Uint16FromInt32(j + int32(1)) + } + goto _2 + _2: + ; + j = j + 1 + } + goto _1 + _1: + ; + i = i + 1 + pItem += 32 + } + return _sqlite3ResolveOrderGroupBy(tls, pParse, pSelect, pOrderBy, zType) +} + +// C documentation +// +// /* +// ** Rtree virtual table module xFilter method. +// */ +func _rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eType, eType1, ii, rc int32 + var iRowid Ti64 + var iVal Tsqlite3_int64 + var p, p1, pCsr, pNew, pRtree uintptr + var _ /* iCell at bp+8 */ int32 + var _ /* iNode at bp+24 */ Ti64 + var _ /* pLeaf at bp+16 */ uintptr + var _ /* pRoot at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = eType, eType1, iRowid, iVal, ii, p, p1, pCsr, pNew, pRtree, rc + pRtree = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab + pCsr = pVtabCursor + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 8)) = 0 + _rtreeReference(tls, pRtree) + /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ + _resetCursor(tls, pCsr) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FiStrategy = idxNum + if idxNum == int32(1) { /* Search point for the leaf */ + iRowid = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + **(**Ti64)(__ccgo_up(bp + 24)) = 0 + eType = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) && 0 == _sqlite3IntFloatCompare(tls, iRowid, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))) { + rc = _findLeafNode(tls, pRtree, iRowid, bp+16, bp+24) + } else { + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + } + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 16)) != uintptr(0) { + p = _rtreeSearchPointNew(tls, pCsr, float64(0), uint8(0)) + /* Always returns pCsr->sPoint */ + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp + 16)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).Fid = **(**Ti64)(__ccgo_up(bp + 24)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = uint8(PARTLY_WITHIN) + rc = _nodeRowidIndex(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 16)), iRowid, bp+8) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 8))) + } else { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FatEOF = uint8(1) + } + } else { + /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array + ** with the configured constraints. + */ + rc = _nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp) + if rc == SQLITE_OK && argc > 0 { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = Xsqlite3_malloc64(tls, uint64(uint64(24)*libc.Uint64FromInt32(argc))) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = argc + if !((*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint != 0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, uint64(24)*libc.Uint64FromInt32(argc)) + libc.Xmemset(tls, pCsr+128, 0, uint64(4)*libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiDepth+libc.Int32FromInt32(1))) + ii = 0 + for { + if !(ii < argc) { + break + } + p1 = (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint + uintptr(ii)*24 + eType1 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8))) + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(ii*int32(2))))) + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = libc.Int32FromUint8(**(**uint8)(__ccgo_up(idxStr + uintptr(ii*int32(2)+int32(1))))) - int32('0') + if (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop >= int32(RTREE_MATCH) { + /* A MATCH operator. The right-hand-side must be a blob that + ** can be cast into an RtreeMatchArg object. One created using + ** an sqlite3_rtree_geometry_callback() SQL user function. + */ + rc = _deserializeGeometry(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8)), p1) + if rc != SQLITE_OK { + break + } + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FnCoord = libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FanQueue = pCsr + 128 + (*Tsqlite3_rtree_query_info)(unsafe.Pointer((*TRtreeConstraint)(unsafe.Pointer(p1)).FpInfo)).FmxLevel = (*TRtree)(unsafe.Pointer(pRtree)).FiDepth + int32(1) + } else { + if eType1 == int32(SQLITE_INTEGER) { + iVal = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8))) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(iVal) + if iVal >= libc.Int64FromInt32(1)<bPoint was FALSE */ + return int32(SQLITE_NOMEM) + } + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = uint8(0) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = uint8(PARTLY_WITHIN) + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _rtreeStepToLeaf(tls, pCsr) + } + } + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo() +// ** interface. +// ** +// ** For each FROM-clause subquery, add Column.zType, Column.zColl, and +// ** Column.affinity information to the Table structure that represents +// ** the result set of that subquery. +// ** +// ** The Table structure that represents the result set was constructed +// ** by selectExpander() but the type and collation and affinity information +// ** was omitted at that point because identifiers had not yet been resolved. +// ** This routine is called after identifier resolution. +// */ +func _selectAddSubqueryTypeInfo(tls *libc.TLS, pWalker uintptr, p uintptr) { + var i int32 + var pFrom, pParse, pSel, pTab, pTabList uintptr + _, _, _, _, _, _ = i, pFrom, pParse, pSel, pTab, pTabList + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_HasTypeInfo) != 0 { + return + } + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_HasTypeInfo) + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + i = 0 + pFrom = pTabList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + pTab = (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Ephemeral) != uint32(0) && int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x4>>2) != 0 { + /* A sub-query in the FROM clause of a SELECT */ + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + _sqlite3SubqueryColumnTypes(tls, pParse, pTab, pSel, uint8(SQLITE_AFF_NONE)) + } + goto _1 + _1: + ; + i = i + 1 + pFrom += 80 + } +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append the string zStr enclosed in quotes (") and +// ** with any embedded quote characters escaped to the buffer. No +// ** nul-terminator byte is written. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendIdent(tls *libc.TLS, p uintptr, zStr uintptr, pRc uintptr) { + var nStr int32 + var zIn, zOut, v1, v2 uintptr + _, _, _, _, _ = nStr, zIn, zOut, v1, v2 + nStr = _sqlite3Strlen30(tls, zStr)*int32(2) + int32(2) + int32(2) + if 0 == _sessionBufferGrow(tls, p, int64(nStr), pRc) { + zOut = (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf) + zIn = zStr + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = uint8('"') + if zIn != uintptr(0) { + for **(**uint8)(__ccgo_up(zIn)) != 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn))) == int32('"') { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = uint8('"') + } + v1 = zOut + zOut = zOut + 1 + v2 = zIn + zIn = zIn + 1 + **(**uint8)(__ccgo_up(v1)) = **(**uint8)(__ccgo_up(v2)) + } + } + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = uint8('"') + (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf = int32(int64(zOut) - int64((*TSessionBuffer)(unsafe.Pointer(p)).FaBuf)) + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf))) = uint8(0x00) + } +} + +// C documentation +// +// /* +// ** Add a new CHECK constraint to the table currently under construction. +// */ +func _sqlite3AddCheckConstraint(tls *libc.TLS, pParse uintptr, pCheckExpr uintptr, zStart uintptr, zEnd uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pTab uintptr + var _ /* t at bp+0 */ TToken + _, _ = db, pTab + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pTab != 0 && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == libc.Int32FromInt32(PARSE_MODE_DECLARE_VTAB)) && !(_sqlite3BtreeIsReadonly(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb)*32))).FpBt) != 0) { + (*TTable)(unsafe.Pointer(pTab)).FpCheck = _sqlite3ExprListAppend(tls, pParse, (*TTable)(unsafe.Pointer(pTab)).FpCheck, pCheckExpr) + if (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName.Fn != 0 { + _sqlite3ExprListSetName(tls, pParse, (*TTable)(unsafe.Pointer(pTab)).FpCheck, pParse+248+16, int32(1)) + } else { + zStart = zStart + 1 + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zStart)))])&int32(0x01) != 0) { + break + } + goto _1 + _1: + ; + zStart = zStart + 1 + } + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zEnd + uintptr(-libc.Int32FromInt32(1)))))])&int32(0x01) != 0 { + zEnd = zEnd - 1 + } + (**(**TToken)(__ccgo_up(bp))).Fz = zStart + (**(**TToken)(__ccgo_up(bp))).Fn = libc.Uint32FromInt32(int32(int64(zEnd) - int64((**(**TToken)(__ccgo_up(bp))).Fz))) + _sqlite3ExprListSetName(tls, pParse, (*TTable)(unsafe.Pointer(pTab)).FpCheck, bp, int32(1)) + } + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCheckExpr) + } +} + +// C documentation +// +// /* +// ** The most recently coded instruction was an OP_Column to retrieve the +// ** i-th column of table pTab. This routine sets the P4 parameter of the +// ** OP_Column to the default value, if any. +// ** +// ** The default value of a column is specified by a DEFAULT clause in the +// ** column definition. This was either supplied by the user when the table +// ** was created, or added later to the table definition by an ALTER TABLE +// ** command. If the latter, then the row-records in the table btree on disk +// ** may not contain a value for the column and the default value, taken +// ** from the P4 parameter of the OP_Column instruction, is returned instead. +// ** If the former, then all row-records are guaranteed to include a value +// ** for the column and the P4 value is not required. +// ** +// ** Column definitions created by an ALTER TABLE command may only have +// ** literal default values specified: a number, null or a string. (If a more +// ** complicated default expression value was provided, it is evaluated +// ** when the ALTER TABLE is executed and one of the literal values written +// ** into the sqlite_schema table.) +// ** +// ** Therefore, the P4 parameter is only required if the default value for +// ** the column is a literal number, string or null. The sqlite3ValueFromExpr() +// ** function is capable of transforming these types of expressions into +// ** sqlite3_value objects. +// ** +// ** If column as REAL affinity and the table is an ordinary b-tree table +// ** (not a virtual table) then the value might have been stored as an +// ** integer. In that case, add an OP_RealAffinity opcode to make sure +// ** it has been converted into REAL. +// */ +func _sqlite3ColumnDefault(tls *libc.TLS, v uintptr, pTab uintptr, i int32, iReg int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var enc Tu8 + var pCol uintptr + var _ /* pValue at bp+0 */ uintptr + _, _ = enc, pCol + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + if (*TColumn)(unsafe.Pointer(pCol)).FiDflt != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + enc = (*Tsqlite3)(unsafe.Pointer(_sqlite3VdbeDb(tls, v))).Fenc + _sqlite3ValueFromExpr(tls, _sqlite3VdbeDb(tls, v), _sqlite3ColumnExpr(tls, pTab, pCol), enc, (*TColumn)(unsafe.Pointer(pCol)).Faffinity, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + _sqlite3VdbeAppendP4(tls, v, **(**uintptr)(__ccgo_up(bp)), -int32(11)) + } + } + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_REAL) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), iReg) + } +} + +// C documentation +// +// /* +// ** The text between zStart and zEnd represents a phrase within a larger +// ** SQL statement. Make a copy of this phrase in space obtained form +// ** sqlite3DbMalloc(). Omit leading and trailing whitespace. +// */ +func _sqlite3DbSpanDup(tls *libc.TLS, db uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var n int32 + _ = n + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zStart)))])&int32(0x01) != 0 { + zStart = zStart + 1 + } + n = int32(int64(zEnd) - int64(zStart)) + for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zStart + uintptr(n-int32(1)))))])&int32(0x01) != 0 { + n = n - 1 + } + return _sqlite3DbStrNDup(tls, db, zStart, libc.Uint64FromInt32(n)) +} + +func _sqlite3DbStrNDup(tls *libc.TLS, db uintptr, z uintptr, n Tu64) (r uintptr) { + var zNew, v1 uintptr + _, _ = zNew, v1 + if z != 0 { + v1 = _sqlite3DbMallocRawNN(tls, db, n+uint64(1)) + } else { + v1 = uintptr(0) + } + zNew = v1 + if zNew != 0 { + libc.Xmemcpy(tls, zNew, z, n) + **(**uint8)(__ccgo_up(zNew + uintptr(n))) = uint8(0) + } + return zNew +} + +// C documentation +// +// /* +// ** If the input token p is quoted, try to adjust the token to remove +// ** the quotes. This is not always possible: +// ** +// ** "abc" -> abc +// ** "ab""cd" -> (not possible because of the interior "") +// ** +// ** Remove the quotes if possible. This is a optimization. The overall +// ** system should still return the correct answer even if this routine +// ** is always a no-op. +// */ +func _sqlite3DequoteToken(tls *libc.TLS, p uintptr) { + var i uint32 + _ = i + if (*TToken)(unsafe.Pointer(p)).Fn < uint32(2) { + return + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up((*TToken)(unsafe.Pointer(p)).Fz)))])&libc.Int32FromInt32(0x80) != 0) { + return + } + i = uint32(1) + for { + if !(i < (*TToken)(unsafe.Pointer(p)).Fn-uint32(1)) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up((*TToken)(unsafe.Pointer(p)).Fz + uintptr(i))))])&int32(0x80) != 0 { + return + } + goto _1 + _1: + ; + i = i + 1 + } + **(**uint32)(__ccgo_up(p + 8)) -= uint32(2) + (*TToken)(unsafe.Pointer(p)).Fz = (*TToken)(unsafe.Pointer(p)).Fz + 1 +} + +// C documentation +// +// /* +// ** Return the 'affinity' of the expression pExpr if any. +// ** +// ** If pExpr is a column, a reference to a column via an 'AS' alias, +// ** or a sub-select with a column as the return value, then the +// ** affinity of that column is returned. Otherwise, 0x00 is returned, +// ** indicating no affinity for the expression. +// ** +// ** i.e. the WHERE clause expressions in the following statements all +// ** have an affinity: +// ** +// ** CREATE TABLE t1(a); +// ** SELECT * FROM t1 WHERE a; +// ** SELECT a AS b FROM t1 WHERE b; +// ** SELECT * FROM t1 WHERE (select a from t1); +// */ +func _sqlite3ExprAffinity(tls *libc.TLS, pExpr uintptr) (r uint8) { + var op int32 + _ = op + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + for int32(1) != 0 { + if op == int32(TK_COLUMN) || op == int32(TK_AGG_COLUMN) && *(*uintptr)(unsafe.Pointer(pExpr + 64)) != uintptr(0) { + return _sqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn)) + } + if op == int32(TK_SELECT) { + return _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList + 8))).FpExpr) + } + if op == int32(TK_CAST) { + return _sqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0)) + } + if op == int32(TK_SELECT_COLUMN) { + return _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32)))).FpEList + 8 + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiColumn)*32))).FpExpr) + } + if op == int32(TK_VECTOR) || op == int32(TK_FUNCTION) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(SQLITE_AFF_DEFER) { + return _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Skip)|libc.Int32FromInt32(EP_IfNullRow)) != uint32(0) { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + continue + } + if op != int32(TK_REGISTER) { + break + } + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) + if op == int32(TK_REGISTER) { + break + } + } + return (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr +} + +// C documentation +// +// /* +// ** This routine is the core allocator for Expr nodes. +// ** +// ** Construct a new expression node and return a pointer to it. Memory +// ** for this node and for the pToken argument is a single allocation +// ** obtained from sqlite3DbMalloc(). The calling function +// ** is responsible for making sure the node eventually gets freed. +// ** +// ** If dequote is true, then the token (if it exists) is dequoted. +// ** If dequote is false, no dequoting is performed. The deQuote +// ** parameter is ignored if pToken is NULL or if the token does not +// ** appear to be quoted. If the quotes were of the form "..." (double-quotes) +// ** then the EP_DblQuoted flag is set on the expression node. +// ** +// ** Special case (tag-20240227-a): If op==TK_INTEGER and pToken points to +// ** a string that can be translated into a 32-bit integer, then the token is +// ** not stored in u.zToken. Instead, the integer values is written +// ** into u.iValue and the EP_IntValue flag is set. No extra storage +// ** is allocated to hold the integer text and the dequote flag is ignored. +// ** See also tag-20240227-b. +// */ +func _sqlite3ExprAlloc(tls *libc.TLS, db uintptr, op int32, pToken uintptr, dequote int32) (r uintptr) { + var nExtra int32 + var pNew uintptr + var v1 uint32 + _, _, _ = nExtra, pNew, v1 + if pToken != 0 { + v1 = (*TToken)(unsafe.Pointer(pToken)).Fn + uint32(1) + } else { + v1 = uint32(0) + } + nExtra = libc.Int32FromUint32(v1) + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(72)+libc.Uint64FromInt32(nExtra))) + if pNew != 0 { + libc.Xmemset(tls, pNew, 0, uint64(72)) + (*TExpr)(unsafe.Pointer(pNew)).Fop = libc.Uint8FromInt32(op) + (*TExpr)(unsafe.Pointer(pNew)).FiAgg = int16(-int32(1)) + if nExtra != 0 { + *(*uintptr)(unsafe.Pointer(pNew + 8)) = pNew + 1*72 + if (*TToken)(unsafe.Pointer(pToken)).Fn != 0 { + libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(pNew + 8)), (*TToken)(unsafe.Pointer(pToken)).Fz, uint64((*TToken)(unsafe.Pointer(pToken)).Fn)) + } + **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pNew + 8)) + uintptr((*TToken)(unsafe.Pointer(pToken)).Fn))) = uint8(0) + if dequote != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pNew + 8)))))])&int32(0x80) != 0 { + _sqlite3DequoteExpr(tls, pNew) + } + } + (*TExpr)(unsafe.Pointer(pNew)).FnHeight = int32(1) + } + return pNew +} + +// C documentation +// +// /* +// ** Generate code that will compute the value of generated column pCol +// ** and store the result in register regOut +// */ +func _sqlite3ExprCodeGeneratedColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, pCol uintptr, regOut int32) { + var iAddr, nErr, p3 int32 + var v uintptr + _, _, _, _ = iAddr, nErr, p3, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + nErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + if (*TParse)(unsafe.Pointer(pParse)).FiSelfTab > 0 { + iAddr = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNullRow), (*TParse)(unsafe.Pointer(pParse)).FiSelfTab-int32(1), 0, regOut) + } else { + iAddr = 0 + } + _sqlite3ExprCodeCopy(tls, pParse, _sqlite3ColumnExpr(tls, pTab, pCol), regOut) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Strict) != uint32(0) { + p3 = int32(2) + int32((int64(pCol)-int64((*TTable)(unsafe.Pointer(pTab)).FaCol))/16) + _sqlite3VdbeAddOp4(tls, v, int32(OP_TypeCheck), regOut, int32(1), p3, pTab, -int32(5)) + } else { + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_TEXT) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), regOut, int32(1), 0, pCol+9, int32(1)) + } + } + if iAddr != 0 { + _sqlite3VdbeJumpHere(tls, v, iAddr) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr > nErr { + (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FerrByteOffset = -int32(1) + } +} + +// C documentation +// +// /* +// ** Generate code for an IN expression. +// ** +// ** x IN (SELECT ...) +// ** x IN (value, value, ...) +// ** +// ** The left-hand side (LHS) is a scalar or vector expression. The +// ** right-hand side (RHS) is an array of zero or more scalar values, or a +// ** subquery. If the RHS is a subquery, the number of result columns must +// ** match the number of columns in the vector on the LHS. If the RHS is +// ** a list of values, the LHS must be a scalar. +// ** +// ** The IN operator is true if the LHS value is contained within the RHS. +// ** The result is false if the LHS is definitely not in the RHS. The +// ** result is NULL if the presence of the LHS in the RHS cannot be +// ** determined due to NULLs. +// ** +// ** This routine generates code that jumps to destIfFalse if the LHS is not +// ** contained within the RHS. If due to NULLs we cannot determine if the LHS +// ** is contained in the RHS then jump to destIfNull. If the LHS is contained +// ** within the RHS then fall through. +// ** +// ** See the separate in-operator.md documentation file in the canonical +// ** SQLite source tree for additional information. +// */ +func _sqlite3ExprCodeIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, destIfFalse int32, destIfNull int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var addrTop, addrTruthOp, destNotNull, destStep2, destStep6, eType, i, ii, labelOk, nVector, op, op1, r2, r3, rLhs, rLhsOrig, regCkNull, v3 int32 + var aiMap, p, p1, pColl, pColl1, pLeft, pList, pOp, pRhs, v, zAff, v1 uintptr + var okConstFactor Tu8 + var _ /* iDummy at bp+4 */ int32 + var _ /* iTab at bp+8 */ int32 + var _ /* rRhsHasNull at bp+0 */ int32 + var _ /* regToFree at bp+12 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrTop, addrTruthOp, aiMap, destNotNull, destStep2, destStep6, eType, i, ii, labelOk, nVector, okConstFactor, op, op1, p, p1, pColl, pColl1, pLeft, pList, pOp, pRhs, r2, r3, rLhs, rLhsOrig, regCkNull, v, zAff, v1, v3 + **(**int32)(__ccgo_up(bp)) = 0 /* Statement under construction */ + aiMap = uintptr(0) /* Map from vector field to index column */ + zAff = uintptr(0) /* Where to jump when NULLs seen in step 2 */ + destStep6 = 0 /* Top of the step-6 loop */ + **(**int32)(__ccgo_up(bp + 8)) = 0 /* Index to use */ + okConstFactor = libc.Uint8FromInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x80 >> 7))) + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if _sqlite3ExprCheckIN(tls, pParse, pExpr) != 0 { + return + } + zAff = _exprINAffinity(tls, pParse, pExpr) + nVector = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + aiMap = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(libc.Uint64FromInt32(nVector)*uint64(4))) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + goto sqlite3ExprCodeIN_oom_error + } + /* Attempt to compute the RHS. After this step, if anything other than + ** IN_INDEX_NOOP is returned, the table opened with cursor iTab + ** contains the values that make up the RHS. If IN_INDEX_NOOP is returned, + ** the RHS has not yet been coded. */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* OOM detected prior to this routine */ + if destIfFalse == destIfNull { + v1 = uintptr(0) + } else { + v1 = bp + } + eType = _sqlite3FindInIndex(tls, pParse, pExpr, libc.Uint32FromInt32(libc.Int32FromInt32(IN_INDEX_MEMBERSHIP)|libc.Int32FromInt32(IN_INDEX_NOOP_OK)), v1, aiMap, bp+8) + /* Code the LHS, the from " IN (...)". If the LHS is a + ** vector, then it is stored in an array of nVector registers starting + ** at r1. + ** + ** sqlite3FindInIndex() might have reordered the fields of the LHS vector + ** so that the fields are in the same order as an existing index. The + ** aiMap[] array contains a mapping from the original LHS field order to + ** the field order that matches the RHS index. + ** + ** Avoid factoring the LHS of the IN(...) expression out of the loop, + ** even if it is constant, as OP_Affinity may be used on the register + ** by code generated below. */ + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) + rLhs = _exprCodeVector(tls, pParse, pLeft, bp+4) + libc.SetBitFieldPtr16Uint32(pParse+40, uint32(okConstFactor), 7, 0x80) + /* If sqlite3FindInIndex() did not find or create an index that is + ** suitable for evaluating the IN operator, then evaluate using a + ** sequence of comparisons. + ** + ** This is step (1) in the in-operator.md optimized algorithm. + */ + if eType == int32(IN_INDEX_NOOP) { + labelOk = _sqlite3VdbeMakeLabel(tls, pParse) + regCkNull = 0 + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + pColl = _sqlite3ExprCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if destIfNull != destIfFalse { + regCkNull = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_BitAnd), rLhs, rLhs, regCkNull) + } + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + r2 = _sqlite3ExprCodeTemp(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr, bp+12) + if regCkNull != 0 && _sqlite3ExprCanBeNull(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr) != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_BitAnd), regCkNull, r2, regCkNull) + } + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp + 12))) + if ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr-int32(1) || destIfNull != destIfFalse { + if rLhs != r2 { + v3 = int32(OP_Eq) + } else { + v3 = int32(OP_NotNull) + } + op = v3 + _sqlite3VdbeAddOp4(tls, v, op, rLhs, labelOk, r2, pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, uint16(**(**uint8)(__ccgo_up(zAff)))) + } else { + if rLhs != r2 { + v3 = int32(OP_Ne) + } else { + v3 = int32(OP_IsNull) + } + op1 = v3 + _sqlite3VdbeAddOp4(tls, v, op1, rLhs, destIfFalse, r2, pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zAff)))|int32(SQLITE_JUMPIFNULL))) + } + goto _2 + _2: + ; + ii = ii + 1 + } + if regCkNull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regCkNull, destIfNull) + _sqlite3VdbeGoto(tls, v, destIfFalse) + } + _sqlite3VdbeResolveLabel(tls, v, labelOk) + _sqlite3ReleaseTempReg(tls, pParse, regCkNull) + goto sqlite3ExprCodeIN_finished + } + if eType != int32(IN_INDEX_ROWID) { + /* If this IN operator will use an index, then the order of columns in the + ** vector might be different from the order in the index. In that case, + ** we need to reorder the LHS values to be in index order. Run Affinity + ** before reordering the columns, so that the affinity is correct. + */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), rLhs, nVector, 0, zAff, nVector) + i = 0 + for { + if !(i < nVector && **(**int32)(__ccgo_up(aiMap + uintptr(i)*4)) == i) { + break + } + goto _5 + _5: + ; + i = i + 1 + } /* Are LHS fields reordered? */ + if i != nVector { + /* Need to reorder the LHS fields according to aiMap */ + rLhsOrig = rLhs + rLhs = _sqlite3GetTempRange(tls, pParse, nVector) + i = 0 + for { + if !(i < nVector) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), rLhsOrig+i, rLhs+**(**int32)(__ccgo_up(aiMap + uintptr(i)*4)), 0) + goto _6 + _6: + ; + i = i + 1 + } + _sqlite3ReleaseTempReg(tls, pParse, rLhsOrig) + } + } + /* Step 2: Check to see if the LHS contains any NULL columns. If the + ** LHS does contain NULLs then the result must be either FALSE or NULL. + ** We will then skip the binary search of the RHS. + */ + if destIfNull == destIfFalse { + destStep2 = destIfFalse + } else { + v3 = _sqlite3VdbeMakeLabel(tls, pParse) + destStep6 = v3 + destStep2 = v3 + } + i = 0 + for { + if !(i < nVector) { + break + } + p = _sqlite3VectorFieldSubexpr(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, i) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto sqlite3ExprCodeIN_oom_error + } + if _sqlite3ExprCanBeNull(tls, p) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), rLhs+i, destStep2) + } + goto _8 + _8: + ; + i = i + 1 + } + /* Step 3. The LHS is now known to be non-NULL. Do the binary search + ** of the RHS using the LHS as a probe. If found, the result is + ** true. + */ + if eType == int32(IN_INDEX_ROWID) { + /* In this case, the RHS is the ROWID of table b-tree and so we also + ** know that the RHS is non-NULL. Hence, we combine steps 3 and 4 + ** into a single opcode. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), **(**int32)(__ccgo_up(bp + 8)), destIfFalse, rLhs) + addrTruthOp = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) /* Return True */ + } else { + if destIfFalse == destIfNull { + /* Combine Step 3 and Step 5 into a single opcode */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) != uint32(0) { + pOp = _sqlite3VdbeGetOp(tls, v, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr) + if (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 > 0 { /* tag-202407032019 */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Filter), (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3, destIfFalse, rLhs, nVector) + } + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_NotFound), **(**int32)(__ccgo_up(bp + 8)), destIfFalse, rLhs, nVector) + goto sqlite3ExprCodeIN_finished + } + /* Ordinary Step 3, for the case where FALSE and NULL are distinct */ + addrTruthOp = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), **(**int32)(__ccgo_up(bp + 8)), 0, rLhs, nVector) + } + /* Step 4. If the RHS is known to be non-NULL and we did not find + ** an match on the search above, then the result must be FALSE. + */ + if **(**int32)(__ccgo_up(bp)) != 0 && nVector == int32(1) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), **(**int32)(__ccgo_up(bp)), destIfFalse) + } + /* Step 5. If we do not care about the difference between NULL and + ** FALSE, then just return false. + */ + if destIfFalse == destIfNull { + _sqlite3VdbeGoto(tls, v, destIfFalse) + } + /* Step 6: Loop through rows of the RHS. Compare each row to the LHS. + ** If any comparison is NULL, then the result is NULL. If all + ** comparisons are FALSE then the final result is FALSE. + ** + ** For a scalar LHS, it is sufficient to check just the first row + ** of the RHS. + */ + if destStep6 != 0 { + _sqlite3VdbeResolveLabel(tls, v, destStep6) + } + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), **(**int32)(__ccgo_up(bp + 8)), destIfFalse) + if nVector > int32(1) { + destNotNull = _sqlite3VdbeMakeLabel(tls, pParse) + } else { + /* For nVector==1, combine steps 6 and 7 by immediately returning + ** FALSE if the first comparison is not NULL */ + destNotNull = destIfFalse + } + i = 0 + for { + if !(i < nVector) { + break + } + r3 = _sqlite3GetTempReg(tls, pParse) + p1 = _sqlite3VectorFieldSubexpr(tls, pLeft, i) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + pRhs = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList + 8 + uintptr(i)*32))).FpExpr + pColl1 = _sqlite3BinaryCompareCollSeq(tls, pParse, p1, pRhs) + } else { + /* If the RHS of the IN(...) expression are scalar expressions, do + ** not consider their collation sequences. The documentation says + ** "The collating sequence used for expressions of the form "x IN (y, z, + ** ...)" is the collating sequence of x.". */ + pColl1 = _sqlite3ExprCollSeq(tls, pParse, p1) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 8)), i, r3) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Ne), rLhs+i, destNotNull, r3, pColl1, -int32(2)) + _sqlite3ReleaseTempReg(tls, pParse, r3) + goto _9 + _9: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, destIfNull) + if nVector > int32(1) { + _sqlite3VdbeResolveLabel(tls, v, destNotNull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 8)), addrTop+int32(1)) + /* Step 7: If we reach this point, we know that the result must + ** be false. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, destIfFalse) + } + /* Jumps here in order to return true. */ + _sqlite3VdbeJumpHere(tls, v, addrTruthOp) + goto sqlite3ExprCodeIN_finished +sqlite3ExprCodeIN_finished: + ; + goto sqlite3ExprCodeIN_oom_error +sqlite3ExprCodeIN_oom_error: + ; + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, aiMap) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zAff) +} + +// C documentation +// +// /* +// ** Return the collation sequence for the expression pExpr. If +// ** there is no defined collating sequence, return NULL. +// ** +// ** See also: sqlite3ExprNNCollSeq() +// ** +// ** The sqlite3ExprNNCollSeq() works the same exact that it returns the +// ** default collation if pExpr has no defined collation. +// ** +// ** The collating sequence might be determined by a COLLATE operator +// ** or by the presence of a column with a defined collating sequence. +// ** COLLATE operators take first precedence. Left operands take +// ** precedence over right operands. +// */ +func _sqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r uintptr) { + var db, p, pColl, pNext, zColl uintptr + var i, j, op, v1 int32 + _, _, _, _, _, _, _, _, _ = db, i, j, op, p, pColl, pNext, zColl, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pColl = uintptr(0) + p = pExpr + for p != 0 { + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) + if op == int32(TK_REGISTER) { + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop2) + } + if op == int32(TK_AGG_COLUMN) && *(*uintptr)(unsafe.Pointer(p + 64)) != uintptr(0) || op == int32(TK_COLUMN) || op == int32(TK_TRIGGER) { + v1 = int32((*TExpr)(unsafe.Pointer(p)).FiColumn) + j = v1 + if v1 >= 0 { + zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FaCol+uintptr(j)*16) + pColl = _sqlite3FindCollSeq(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, zColl, 0) + } + break + } + if op == int32(TK_CAST) || op == int32(TK_UPLUS) { + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + continue + } + if op == int32(TK_VECTOR) || op == int32(TK_FUNCTION) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).FaffExpr) == int32(SQLITE_AFF_DEFER) { + p = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)) + 8))).FpExpr + continue + } + if op == int32(TK_COLLATE) { + pColl = _sqlite3GetCollSeq(tls, pParse, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, uintptr(0), *(*uintptr)(unsafe.Pointer(p + 8))) + break + } + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_Collate) != 0 { + if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 && (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(p)).FpLeft)).Fflags&uint32(EP_Collate) != uint32(0) { + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + } else { + pNext = (*TExpr)(unsafe.Pointer(p)).FpRight + /* The Expr.x union is never used at the same time as Expr.pRight */ + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) == uint32(0) && *(*uintptr)(unsafe.Pointer(p + 32)) != uintptr(0) && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)))).FnExpr) { + break + } + if (*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)) + 8 + uintptr(i)*32))).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != uint32(0) { + pNext = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)) + 8 + uintptr(i)*32))).FpExpr + break + } + goto _2 + _2: + ; + i = i + 1 + } + } + p = pNext + } + } else { + break + } + } + if _sqlite3CheckCollSeq(tls, pParse, pColl) != 0 { + pColl = uintptr(0) + } + return pColl +} + +// C documentation +// +// /* +// ** Make a guess at all the possible datatypes of the result that could +// ** be returned by an expression. Return a bitmask indicating the answer: +// ** +// ** 0x01 Numeric +// ** 0x02 Text +// ** 0x04 Blob +// ** +// ** If the expression must return NULL, then 0x00 is returned. +// */ +func _sqlite3ExprDataType(tls *libc.TLS, pExpr uintptr) (r int32) { + var aff, ii, res int32 + var pList uintptr + _, _, _, _ = aff, ii, pList, res + for pExpr != 0 { + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + case int32(TK_COLLATE): + fallthrough + case int32(TK_IF_NULL_ROW): + fallthrough + case int32(TK_UPLUS): + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + case int32(TK_NULL): + pExpr = uintptr(0) + case int32(TK_STRING): + return int32(0x02) + case int32(TK_BLOB): + return int32(0x04) + case int32(TK_CONCAT): + return int32(0x06) + case int32(TK_VARIABLE): + fallthrough + case int32(TK_AGG_FUNCTION): + fallthrough + case int32(TK_FUNCTION): + return int32(0x07) + case int32(TK_COLUMN): + fallthrough + case int32(TK_AGG_COLUMN): + fallthrough + case int32(TK_SELECT): + fallthrough + case int32(TK_CAST): + fallthrough + case int32(TK_SELECT_COLUMN): + fallthrough + case int32(TK_VECTOR): + aff = libc.Int32FromUint8(_sqlite3ExprAffinity(tls, pExpr)) + if aff >= int32(SQLITE_AFF_NUMERIC) { + return int32(0x05) + } + if aff == int32(SQLITE_AFF_TEXT) { + return int32(0x06) + } + return int32(0x07) + case int32(TK_CASE): + res = 0 + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + ii = int32(1) + for { + if !(ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + res = res | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr) + goto _1 + _1: + ; + ii = ii + int32(2) + } + if (*TExprList)(unsafe.Pointer(pList)).FnExpr%int32(2) != 0 { + res = res | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr((*TExprList)(unsafe.Pointer(pList)).FnExpr-int32(1))*32))).FpExpr) + } + return res + default: + return int32(0x01) + } /* End of switch(op) */ + } /* End of while(pExpr) */ + return 0x00 +} + +// C documentation +// +// /* +// ** Return true if the expression is one of the following: +// ** +// ** CASE WHEN x THEN y END +// ** CASE WHEN x THEN y ELSE NULL END +// ** CASE WHEN x THEN y ELSE false END +// ** iif(x,y) +// ** iif(x,y,NULL) +// ** iif(x,y,false) +// */ +func _sqlite3ExprIsIIF(tls *libc.TLS, db uintptr, pExpr uintptr) (r int32) { + var pDef, pList, z uintptr + _, _, _ = pDef, pList, z + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_FUNCTION) { + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != int32('i') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != int32('I') { + return 0 + } + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) == uintptr(0) { + return 0 + } + pDef = _sqlite3FindFunction(tls, db, z, (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, uint8(0)) + if pDef == uintptr(0) { + return 0 + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INLINE) == uint32(0) { + return 0 + } + if int32(int64((*TFuncDef)(unsafe.Pointer(pDef)).FpUserData)) != int32(INLINEFUNC_iif) { + return 0 + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_CASE) { + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != uintptr(0) { + return 0 + } + } else { + return 0 + } + } + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if (*TExprList)(unsafe.Pointer(pList)).FnExpr == int32(2) { + return int32(1) + } + if (*TExprList)(unsafe.Pointer(pList)).FnExpr == int32(3) && _sqlite3ExprIsNotTrue(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 2*32))).FpExpr) != 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Locate a user function given a name, a number of arguments and a flag +// ** indicating whether the function prefers UTF-16 over UTF-8. Return a +// ** pointer to the FuncDef structure that defines that function, or return +// ** NULL if the function does not exist. +// ** +// ** If the createFlag argument is true, then a new (blank) FuncDef +// ** structure is created and liked into the "db" structure if a +// ** no matching function previously existed. +// ** +// ** If nArg is -2, then the first valid function found is returned. A +// ** function is valid if xSFunc is non-zero. The nArg==(-2) +// ** case is used to see if zName is a valid function name for some number +// ** of arguments. If nArg is -2, then createFlag must be 0. +// ** +// ** If createFlag is false, then a function with the required name and +// ** number of arguments may be returned even if the eTextRep flag does not +// ** match that requested. +// */ +func _sqlite3FindFunction(tls *libc.TLS, db uintptr, zName uintptr, nArg int32, enc Tu8, createFlag Tu8) (r uintptr) { + var bestScore, h, nName, score, score1 int32 + var p, pBest, pOther, z, v1 uintptr + var v2 bool + _, _, _, _, _, _, _, _, _, _, _ = bestScore, h, nName, p, pBest, pOther, score, score1, z, v1, v2 /* Iterator variable */ + pBest = uintptr(0) /* Best match found so far */ + bestScore = 0 /* Length of the name */ + nName = _sqlite3Strlen30(tls, zName) + /* First search for a match amongst the application-defined functions. + */ + p = _sqlite3HashFind(tls, db+624, zName) + for p != 0 { + score = _matchQuality(tls, p, nArg, enc) + if score > bestScore { + pBest = p + bestScore = score + } + p = (*TFuncDef)(unsafe.Pointer(p)).FpNext + } + /* If no match is found, search the built-in functions. + ** + ** If the DBFLAG_PreferBuiltin flag is set, then search the built-in + ** functions even if a prior app-defined function was found. And give + ** priority to built-in functions. + ** + ** Except, if createFlag is true, that means that we are trying to + ** install a new function. Whatever FuncDef structure is returned it will + ** have fields overwritten with new information appropriate for the + ** new function. But the FuncDefs for built-in functions are read-only. + ** So we must not search for built-ins when creating a new function. + */ + if !(createFlag != 0) && (pBest == uintptr(0) || (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_PreferBuiltin) != uint32(0)) { + bestScore = 0 + h = (libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(zName)))]) + nName) % int32(SQLITE_FUNC_HASH_SZ) + p = _sqlite3FunctionSearch(tls, h, zName) + for p != 0 { + score1 = _matchQuality(tls, p, nArg, enc) + if score1 > bestScore { + pBest = p + bestScore = score1 + } + p = (*TFuncDef)(unsafe.Pointer(p)).FpNext + } + } + /* If the createFlag parameter is true and the search did not reveal an + ** exact match for the name, number of arguments and encoding, then add a + ** new entry to the hash table and return it. + */ + if v2 = createFlag != 0 && bestScore < int32(FUNC_PERFECT_MATCH); v2 { + v1 = _sqlite3DbMallocZero(tls, db, uint64(uint64(72)+libc.Uint64FromInt32(nName)+uint64(1))) + pBest = v1 + } + if v2 && v1 != uintptr(0) { + (*TFuncDef)(unsafe.Pointer(pBest)).FzName = pBest + 1*72 + (*TFuncDef)(unsafe.Pointer(pBest)).FnArg = libc.Int16FromUint16(libc.Uint16FromInt32(nArg)) + (*TFuncDef)(unsafe.Pointer(pBest)).FfuncFlags = uint32(enc) + libc.Xmemcpy(tls, pBest+1*72, zName, libc.Uint64FromInt32(nName+int32(1))) + z = (*TFuncDef)(unsafe.Pointer(pBest)).FzName + for { + if !(**(**Tu8)(__ccgo_up(z)) != 0) { + break + } + **(**Tu8)(__ccgo_up(z)) = _sqlite3UpperToLower[**(**Tu8)(__ccgo_up(z))] + goto _3 + _3: + ; + z = z + 1 + } + pOther = _sqlite3HashInsert(tls, db+624, (*TFuncDef)(unsafe.Pointer(pBest)).FzName, pBest) + if pOther == pBest { + _sqlite3DbFree(tls, db, pBest) + _sqlite3OomFault(tls, db) + return uintptr(0) + } else { + (*TFuncDef)(unsafe.Pointer(pBest)).FpNext = pOther + } + } + if pBest != 0 && ((*TFuncDef)(unsafe.Pointer(pBest)).FxSFunc != 0 || createFlag != 0) { + return pBest + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Parameter zIn contains a rank() function specification. The format of +// ** this is: +// ** +// ** + Bareword (function name) +// ** + Open parenthesis - "(" +// ** + Zero or more SQL literals in a comma separated list +// ** + Close parenthesis - ")" +// */ +func _sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRankArgs uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p, pArgs, pRank, zRank, zRankArgs uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _ = p, pArgs, pRank, zRank, zRankArgs + p = zIn + zRank = uintptr(0) + zRankArgs = uintptr(0) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**uintptr)(__ccgo_up(pzRank)) = uintptr(0) + **(**uintptr)(__ccgo_up(pzRankArgs)) = uintptr(0) + if p == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + p = _fts5ConfigSkipWhitespace(tls, p) + pRank = p + p = _fts5ConfigSkipBareword(tls, p) + if p != 0 { + zRank = _sqlite3Fts5MallocZero(tls, bp, int64(uintptr(1)+p)-int64(pRank)) + if zRank != 0 { + libc.Xmemcpy(tls, zRank, pRank, libc.Uint64FromInt64(int64(p)-int64(pRank))) + } + } else { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + p = _fts5ConfigSkipWhitespace(tls, p) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32('(') { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + p = p + 1 + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + p = _fts5ConfigSkipWhitespace(tls, p) + pArgs = p + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32(')') { + p = _fts5ConfigSkipArgs(tls, p) + if p == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + zRankArgs = _sqlite3Fts5MallocZero(tls, bp, int64(uintptr(1)+p)-int64(pArgs)) + if zRankArgs != 0 { + libc.Xmemcpy(tls, zRankArgs, pArgs, libc.Uint64FromInt64(int64(p)-int64(pArgs))) + } + } + } + } + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + Xsqlite3_free(tls, zRank) + } else { + **(**uintptr)(__ccgo_up(pzRank)) = zRank + **(**uintptr)(__ccgo_up(pzRankArgs)) = zRankArgs + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This function is only called when using the special 'trigram' tokenizer. +// ** Argument zText contains the text of a LIKE or GLOB pattern matched +// ** against column iCol. This function creates and compiles an FTS5 MATCH +// ** expression that will match a superset of the rows matched by the LIKE or +// ** GLOB. If successful, SQLITE_OK is returned. Otherwise, an SQLite error +// ** code. +// */ +func _sqlite3Fts5ExprPattern(tls *libc.TLS, pConfig uintptr, bGlob int32, iCol int32, zText uintptr, pp uintptr) (r int32) { + var aSpec [3]uint8 + var bAnd, i, iFirst, iOut, jj, rc, v1 int32 + var nText Ti64 + var zExpr uintptr + _, _, _, _, _, _, _, _, _, _ = aSpec, bAnd, i, iFirst, iOut, jj, nText, rc, zExpr, v1 + nText = libc.Int64FromUint64(libc.Xstrlen(tls, zText)) + zExpr = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nText*int64(4)+int64(1))) + rc = SQLITE_OK + if zExpr == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + iOut = 0 + i = 0 + iFirst = 0 + if bGlob == 0 { + aSpec[0] = uint8('_') + aSpec[int32(1)] = uint8('%') + aSpec[int32(2)] = uint8(0) + } else { + aSpec[0] = uint8('*') + aSpec[int32(1)] = uint8('?') + aSpec[int32(2)] = uint8('[') + } + for int64(i) <= nText { + if int64(i) == nText || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zText + uintptr(i)))) == libc.Int32FromUint8(aSpec[0]) || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zText + uintptr(i)))) == libc.Int32FromUint8(aSpec[int32(1)]) || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zText + uintptr(i)))) == libc.Int32FromUint8(aSpec[int32(2)]) { + if _fts5ExprCountChar(tls, zText+uintptr(iFirst), i-iFirst) >= int32(3) { + v1 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zExpr + uintptr(v1))) = uint8('"') + jj = iFirst + for { + if !(jj < i) { + break + } + v1 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zExpr + uintptr(v1))) = **(**uint8)(__ccgo_up(zText + uintptr(jj))) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zText + uintptr(jj)))) == int32('"') { + v1 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zExpr + uintptr(v1))) = uint8('"') + } + goto _2 + _2: + ; + jj = jj + 1 + } + v1 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zExpr + uintptr(v1))) = uint8('"') + v1 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(zExpr + uintptr(v1))) = uint8(' ') + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zText + uintptr(i)))) == libc.Int32FromUint8(aSpec[int32(2)]) { + i = i + int32(2) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zText + uintptr(i-int32(1))))) == int32('^') { + i = i + 1 + } + for int64(i) < nText && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zText + uintptr(i)))) != int32(']') { + i = i + 1 + } + } + iFirst = i + int32(1) + } + i = i + 1 + } + if iOut > 0 { + bAnd = 0 + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail != FTS5_DETAIL_FULL { + bAnd = int32(1) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + iCol = (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + } + } + **(**uint8)(__ccgo_up(zExpr + uintptr(iOut))) = uint8('\000') + rc = _sqlite3Fts5ExprNew(tls, pConfig, bAnd, iCol, zExpr, pp, (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg) + } else { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + Xsqlite3_free(tls, zExpr) + } + return rc +} + +// C documentation +// +// /* +// ** Add an entry to the in-memory hash table. The key is the concatenation +// ** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos). +// ** +// ** (bByte || pToken) -> (iRowid,iCol,iPos) +// ** +// ** Or, if iCol is negative, then the value is a delete marker. +// */ +func _sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid Ti64, iCol int32, iPos int32, bByte uint8, pToken uintptr, nToken int32) (r int32) { + var bNew, nIncr, rc, v2 int32 + var iDiff Tu64 + var iHash uint32 + var nByte, nNew Tsqlite3_int64 + var p, pNew, pPtr, pp, zKey, zKey1, v6 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNew, iDiff, iHash, nByte, nIncr, nNew, p, pNew, pPtr, pp, rc, zKey, zKey1, v2, v6 + nIncr = 0 /* If non-delete entry should be written */ + bNew = libc.BoolInt32((*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL) + /* Attempt to locate an existing hash entry */ + iHash = _fts5HashKey2(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot, bByte, pToken, nToken) + p = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) + for { + if !(p != 0) { + break + } + zKey = p + 1*48 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zKey))) == libc.Int32FromUint8(bByte) && (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey == nToken+int32(1) && libc.Xmemcmp(tls, zKey+1, pToken, libc.Uint64FromInt32(nToken)) == 0 { + break + } + goto _1 + _1: + ; + p = (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext + } + /* If an existing hash entry cannot be found, create a new one. */ + if p == uintptr(0) { + nByte = libc.Int64FromUint64(uint64(48) + libc.Uint64FromInt32(nToken+libc.Int32FromInt32(1)) + uint64(1) + uint64(64)) + if nByte < int64(128) { + nByte = int64(128) + } + /* Grow the Fts5Hash.aSlot[] array if necessary. */ + if (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry*int32(2) >= (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot { + rc = _fts5HashResize(tls, pHash) + if rc != SQLITE_OK { + return rc + } + iHash = _fts5HashKey2(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot, bByte, pToken, nToken) + } + /* Allocate new Fts5HashEntry and add it to the hash table. */ + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if !(p != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, p, 0, uint64(48)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc = int32(nByte) + zKey1 = p + 1*48 + **(**uint8)(__ccgo_up(zKey1)) = bByte + libc.Xmemcpy(tls, zKey1+1, pToken, libc.Uint64FromInt32(nToken)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey = nToken + int32(1) + **(**uint8)(__ccgo_up(zKey1 + uintptr(nToken+int32(1)))) = uint8('\000') + (*TFts5HashEntry)(unsafe.Pointer(p)).FnData = libc.Int32FromUint64(libc.Uint64FromInt32(nToken+int32(1)) + uint64(48)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) = p + (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry = (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry + 1 + /* Add the first rowid field to the hash-entry */ + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, p+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt64(iRowid)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid + (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail != int32(FTS5_DETAIL_NONE) { + **(**int32)(__ccgo_up(p + 24)) += int32(1) + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v2 = 0 + } else { + v2 = -int32(1) + } + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + } + } else { + /* Appending to an existing hash-entry. Check that there is enough + ** space to append the largest possible new entry. Worst case scenario + ** is: + ** + ** + 9 bytes for a new rowid, + ** + 4 byte reserved for the "poslist size" varint. + ** + 1 byte for a "new column" byte, + ** + 3 bytes for a new column number (16-bit max) as a varint, + ** + 5 bytes for the new position offset (32-bit max). + */ + if (*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc-(*TFts5HashEntry)(unsafe.Pointer(p)).FnData < libc.Int32FromInt32(9)+libc.Int32FromInt32(4)+libc.Int32FromInt32(1)+libc.Int32FromInt32(3)+libc.Int32FromInt32(5) { + nNew = int64((*TFts5HashEntry)(unsafe.Pointer(p)).FnAlloc * int32(2)) + pNew = Xsqlite3_realloc64(tls, p, libc.Uint64FromInt64(nNew)) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TFts5HashEntry)(unsafe.Pointer(pNew)).FnAlloc = int32(nNew) + pp = (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != p) { + break + } + goto _3 + _3: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + } + **(**uintptr)(__ccgo_up(pp)) = pNew + p = pNew + } + nIncr = nIncr - (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + } + pPtr = p + /* If this is a new rowid, append the 4-byte size field for the previous + ** entry, and the new rowid for this entry. */ + if iRowid != (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid { + iDiff = libc.Uint64FromInt64(iRowid) - libc.Uint64FromInt64((*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid) + _fts5HashAddPoslistSize(tls, pHash, p, uintptr(0)) + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), iDiff) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid + bNew = int32(1) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail != int32(FTS5_DETAIL_NONE) { + **(**int32)(__ccgo_up(p + 24)) += int32(1) + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v2 = 0 + } else { + v2 = -int32(1) + } + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = 0 + } + } + if iCol >= 0 { + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == int32(FTS5_DETAIL_NONE) { + (*TFts5HashEntry)(unsafe.Pointer(p)).FbContent = uint8(1) + } else { + /* Append a new column value, if necessary */ + if iCol != int32((*TFts5HashEntry)(unsafe.Pointer(p)).FiCol) { + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { + v6 = p + 24 + v2 = *(*int32)(unsafe.Pointer(v6)) + *(*int32)(unsafe.Pointer(v6)) = *(*int32)(unsafe.Pointer(v6)) + 1 + **(**Tu8)(__ccgo_up(pPtr + uintptr(v2))) = uint8(0x01) + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt32(iCol)) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(iCol) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = 0 + } else { + bNew = int32(1) + v2 = iCol + iPos = v2 + (*TFts5HashEntry)(unsafe.Pointer(p)).FiCol = int16(v2) + } + } + /* Append the new position offset, if necessary */ + if bNew != 0 { + **(**int32)(__ccgo_up(p + 24)) += _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FnData), libc.Uint64FromInt32(iPos-(*TFts5HashEntry)(unsafe.Pointer(p)).FiPos+int32(2))) + (*TFts5HashEntry)(unsafe.Pointer(p)).FiPos = iPos + } + } + } else { + /* This is a delete. Set the delete flag. */ + (*TFts5HashEntry)(unsafe.Pointer(p)).FbDel = uint8(1) + } + nIncr = nIncr + (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + **(**int32)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FpnByte)) += nIncr + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return a nul-terminated copy of the string indicated by pIn. If nIn +// ** is non-negative, then it is the length of the string in bytes. Otherwise, +// ** the length of the string is determined using strlen(). +// ** +// ** It is the responsibility of the caller to eventually free the returned +// ** buffer using sqlite3_free(). If an OOM error occurs, NULL is returned. +// */ +func _sqlite3Fts5Strndup(tls *libc.TLS, pRc uintptr, pIn uintptr, nIn int32) (r uintptr) { + var zRet uintptr + _ = zRet + zRet = uintptr(0) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + if nIn < 0 { + nIn = libc.Int32FromUint64(libc.Xstrlen(tls, pIn)) + } + zRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nIn)+int64(1))) + if zRet != 0 { + libc.Xmemcpy(tls, zRet, pIn, libc.Uint64FromInt32(nIn)) + **(**uint8)(__ccgo_up(zRet + uintptr(nIn))) = uint8('\000') + } else { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } + return zRet +} + +func _sqlite3Fts5TermsetAdd(tls *libc.TLS, p uintptr, iIdx int32, pTerm uintptr, nTerm int32, pbPresent uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var hash Tu32 + var i int32 + var pEntry uintptr + var _ /* rc at bp+0 */ int32 + _, _, _ = hash, i, pEntry + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**int32)(__ccgo_up(pbPresent)) = 0 + if p != 0 { + hash = uint32(13) + /* Calculate a hash value for this term. This is the same hash checksum + ** used by the fts5_hash.c module. This is not important for correct + ** operation of the module, but is necessary to ensure that some tests + ** designed to produce hash table collisions really do work. */ + i = nTerm - int32(1) + for { + if !(i >= 0) { + break + } + hash = hash<= 0 && c <= int32(9)) { + break + } + v = v*int64(10) + int64(c) + goto _2 + _2: + ; + i = i + 1 + } + /* The longest decimal representation of a 32 bit integer is 10 digits: + ** + ** 1234567890 + ** 2^31 -> 2147483648 + */ + if i > int32(10) { + return 0 + } + if v-int64(neg) > int64(2147483647) { + return 0 + } + if neg != 0 { + v = -v + } + **(**int32)(__ccgo_up(pValue)) = int32(v) + return int32(1) +} + +// C documentation +// +// /* +// ** Insert a new FuncDef into a FuncDefHash hash table. +// */ +func _sqlite3InsertBuiltinFuncs(tls *libc.TLS, aDef uintptr, nDef int32) { + var h, i, nName int32 + var pOther, zName uintptr + _, _, _, _, _ = h, i, nName, pOther, zName + i = 0 + for { + if !(i < nDef) { + break + } + zName = (**(**TFuncDef)(__ccgo_up(aDef + uintptr(i)*72))).FzName + nName = _sqlite3Strlen30(tls, zName) + h = (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName))) + nName) % int32(SQLITE_FUNC_HASH_SZ) + pOther = _sqlite3FunctionSearch(tls, h, zName) + if pOther != 0 { + (**(**TFuncDef)(__ccgo_up(aDef + uintptr(i)*72))).FpNext = (*TFuncDef)(unsafe.Pointer(pOther)).FpNext + (*TFuncDef)(unsafe.Pointer(pOther)).FpNext = aDef + uintptr(i)*72 + } else { + (**(**TFuncDef)(__ccgo_up(aDef + uintptr(i)*72))).FpNext = uintptr(0) + *(*uintptr)(unsafe.Pointer(aDef + uintptr(i)*72 + 64)) = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(h)*8)) + **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(h)*8)) = aDef + uintptr(i)*72 + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Render an signed 64-bit integer as text. Store the result in zOut[] and +// ** return the length of the string that was stored, in bytes. The value +// ** returned does not include the zero terminator at the end of the output +// ** string. +// ** +// ** The caller must ensure that zOut[] is at least 21 bytes in size. +// */ +func _sqlite3Int64ToText(tls *libc.TLS, v Ti64, zOut uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, kk, v2 int32 + var x Tu64 + var v1 uint64 + var _ /* u at bp+0 */ struct { + FforceAlignment [0]Tu16 + Fa [21]uint8 + F__ccgo_pad2 [1]byte + } + _, _, _, _, _ = i, kk, x, v1, v2 + if v > 0 { + x = libc.Uint64FromInt64(v) + } else { + if v == 0 { + **(**uint8)(__ccgo_up(zOut)) = uint8('0') + **(**uint8)(__ccgo_up(zOut + 1)) = uint8(0) + return int32(1) + } else { + if v == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= uint64(10) { + kk = libc.Int32FromUint64(x % uint64(100) * uint64(2)) + **(**Tu16)(__ccgo_up(bp + uintptr(i-int32(2)))) = **(**Tu16)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3DigitPairs)) + uintptr(kk))) + i = i - int32(2) + x = x / uint64(100) + } + if x != 0 { + i = i - 1 + v2 = i + **(**uint8)(__ccgo_up(bp + uintptr(v2))) = uint8(x + uint64('0')) + } + if v < 0 { + i = i - 1 + v2 = i + **(**uint8)(__ccgo_up(bp + uintptr(v2))) = uint8('-') + } + libc.Xmemcpy(tls, zOut, bp+uintptr(i), uint64(21)-libc.Uint64FromInt32(i)) + return libc.Int32FromUint64(libc.Uint64FromInt64(21) - libc.Uint64FromInt32(1) - libc.Uint64FromInt32(i)) +} + +// C documentation +// +// /* +// ** pExpr points to an expression which implements a function. If +// ** it is appropriate to apply the LIKE optimization to that function +// ** then set aWc[0] through aWc[2] to the wildcard characters and the +// ** escape character and then return TRUE. If the function is not a +// ** LIKE-style function then return FALSE. +// ** +// ** The expression "a LIKE b ESCAPE c" is only considered a valid LIKE +// ** operator if c is a string literal that is exactly one byte in length. +// ** That one byte is stored in aWc[3]. aWc[3] is set to zero if there is +// ** no ESCAPE clause. +// ** +// ** *pIsNocase is set to true if uppercase and lowercase are equivalent for +// ** the function (default for LIKE). If the function makes the distinction +// ** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to +// ** false. +// */ +func _sqlite3IsLikeFunction(tls *libc.TLS, db uintptr, pExpr uintptr, pIsNocase uintptr, aWc uintptr) (r int32) { + var nExpr int32 + var pDef, pEscape, zEscape uintptr + _, _, _, _ = nExpr, pDef, pEscape, zEscape + if !(*(*uintptr)(unsafe.Pointer(pExpr + 32)) != 0) { + return 0 + } + nExpr = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + pDef = _sqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8)), nExpr, uint8(SQLITE_UTF8), uint8(0)) + if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_LIKE) == uint32(0) { + return 0 + } + /* The memcpy() statement assumes that the wildcard characters are + ** the first three statements in the compareInfo structure. The + ** asserts() that follow verify that assumption + */ + libc.Xmemcpy(tls, aWc, (*TFuncDef)(unsafe.Pointer(pDef)).FpUserData, uint64(3)) + if nExpr < int32(3) { + **(**uint8)(__ccgo_up(aWc + 3)) = uint8(0) + } else { + pEscape = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 2*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pEscape)).Fop) != int32(TK_STRING) { + return 0 + } + zEscape = *(*uintptr)(unsafe.Pointer(pEscape + 8)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zEscape))) == 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zEscape + 1))) != 0 { + return 0 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zEscape))) == libc.Int32FromUint8(**(**uint8)(__ccgo_up(aWc))) { + return 0 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zEscape))) == libc.Int32FromUint8(**(**uint8)(__ccgo_up(aWc + 1))) { + return 0 + } + **(**uint8)(__ccgo_up(aWc + 3)) = **(**uint8)(__ccgo_up(zEscape)) + } + **(**int32)(__ccgo_up(pIsNocase)) = libc.BoolInt32((*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_CASE) == uint32(0)) + return int32(1) +} + +/* Mathematical Constants */ + +// C documentation +// +// /* +// ** Return true if pTab is a virtual table and zName is a shadow table name +// ** for that virtual table. +// */ +func _sqlite3IsShadowTableOf(tls *libc.TLS, db uintptr, pTab uintptr, zName uintptr) (r int32) { + var nName int32 + var pMod uintptr + _, _ = nName, pMod /* Module for the virtual table */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + return 0 + } + nName = _sqlite3Strlen30(tls, (*TTable)(unsafe.Pointer(pTab)).FzName) + if Xsqlite3_strnicmp(tls, zName, (*TTable)(unsafe.Pointer(pTab)).FzName, nName) != 0 { + return 0 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(nName)))) != int32('_') { + return 0 + } + pMod = _sqlite3HashFind(tls, db+576, **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg))) + if pMod == uintptr(0) { + return 0 + } + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FiVersion < int32(3) { + return 0 + } + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxShadowName == uintptr(0) { + return 0 + } + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxShadowName})))(tls, zName+uintptr(nName)+uintptr(1)) +} + +// C documentation +// +// /* +// ** Table pTab is a virtual table. If it the virtual table implementation +// ** exists and has an xShadowName method, then loop over all other ordinary +// ** tables within the same schema looking for shadow tables of pTab, and mark +// ** any shadow tables seen using the TF_Shadow flag. +// */ +func _sqlite3MarkAllShadowTablesOf(tls *libc.TLS, db uintptr, pTab uintptr) { + var k, pMod, pOther uintptr + var nName int32 + _, _, _, _ = k, nName, pMod, pOther /* For looping through the symbol table */ + pMod = _sqlite3HashFind(tls, db+576, **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg))) + if pMod == uintptr(0) { + return + } + if (*TModule)(unsafe.Pointer(pMod)).FpModule == uintptr(0) { + return + } + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FiVersion < int32(3) { + return + } + if (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxShadowName == uintptr(0) { + return + } + nName = _sqlite3Strlen30(tls, (*TTable)(unsafe.Pointer(pTab)).FzName) + k = (*THash)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FpSchema + 8)).Ffirst + for { + if !(k != 0) { + break + } + pOther = (*THashElem)(unsafe.Pointer(k)).Fdata + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pOther)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + goto _1 + } + if (*TTable)(unsafe.Pointer(pOther)).FtabFlags&uint32(TF_Shadow) != 0 { + goto _1 + } + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pOther)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, nName) == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TTable)(unsafe.Pointer(pOther)).FzName + uintptr(nName)))) == int32('_') && (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer(pMod)).FpModule)).FxShadowName})))(tls, (*TTable)(unsafe.Pointer(pOther)).FzName+uintptr(nName)+uintptr(1)) != 0 { + **(**Tu32)(__ccgo_up(pOther + 48)) |= uint32(TF_Shadow) + } + goto _1 + _1: + ; + k = (*THashElem)(unsafe.Pointer(k)).Fnext + } +} + +// C documentation +// +// /* +// ** Subqueries store the original database, table and column names for their +// ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN", +// ** and mark the expression-list item by setting ExprList.a[].fg.eEName +// ** to ENAME_TAB. +// ** +// ** Check to see if the zSpan/eEName of the expression-list item passed to this +// ** routine matches the zDb, zTab, and zCol. If any of zDb, zTab, and zCol are +// ** NULL then those fields will match anything. Return true if there is a match, +// ** or false otherwise. +// ** +// ** SF_NestedFrom subqueries also store an entry for the implicit rowid (or +// ** _rowid_, or oid) column by setting ExprList.a[].fg.eEName to ENAME_ROWID, +// ** and setting zSpan to "DATABASE.TABLE.". This type of pItem +// ** argument matches if zCol is a rowid alias. If it is not NULL, (*pbRowid) +// ** is set to 1 if there is this kind of match. +// */ +func _sqlite3MatchEName(tls *libc.TLS, pItem uintptr, zCol uintptr, zTab uintptr, zDb uintptr, pbRowid uintptr) (r int32) { + var eEName, n int32 + var zSpan uintptr + _, _, _ = eEName, n, zSpan + eEName = int32(uint32(*(*uint16)(unsafe.Pointer(pItem + 16 + 4)) & 0x3 >> 0)) + if eEName != int32(ENAME_TAB) && (eEName != int32(ENAME_ROWID) || pbRowid == uintptr(0)) { + return 0 + } + zSpan = (*TExprList_item)(unsafe.Pointer(pItem)).FzEName + n = 0 + for { + if !(**(**uint8)(__ccgo_up(zSpan + uintptr(n))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSpan + uintptr(n)))) != int32('.')) { + break + } + goto _1 + _1: + ; + n = n + 1 + } + if zDb != 0 && (Xsqlite3_strnicmp(tls, zSpan, zDb, n) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDb + uintptr(n)))) != 0) { + return 0 + } + zSpan = zSpan + uintptr(n+int32(1)) + n = 0 + for { + if !(**(**uint8)(__ccgo_up(zSpan + uintptr(n))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSpan + uintptr(n)))) != int32('.')) { + break + } + goto _2 + _2: + ; + n = n + 1 + } + if zTab != 0 && (Xsqlite3_strnicmp(tls, zSpan, zTab, n) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zTab + uintptr(n)))) != 0) { + return 0 + } + zSpan = zSpan + uintptr(n+int32(1)) + if zCol != 0 { + if eEName == int32(ENAME_TAB) && _sqlite3StrICmp(tls, zSpan, zCol) != 0 { + return 0 + } + if eEName == int32(ENAME_ROWID) && _sqlite3IsRowid(tls, zCol) == 0 { + return 0 + } + } + if eEName == int32(ENAME_ROWID) { + **(**int32)(__ccgo_up(pbRowid)) = int32(1) + } + return int32(1) +} + +// C documentation +// +// /* +// ** Run the parser and code generator recursively in order to generate +// ** code for the SQL statement given onto the end of the pParse context +// ** currently under construction. Notes: +// ** +// ** * The final OP_Halt is not appended and other initialization +// ** and finalization steps are omitted because those are handling by the +// ** outermost parser. +// ** +// ** * Built-in SQL functions always take precedence over application-defined +// ** SQL functions. In other words, it is not possible to override a +// ** built-in function. +// */ +func _sqlite3NestedParse(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var ap Tva_list + var db, zSql uintptr + var savedDbFlags Tu32 + var _ /* saveBuf at bp+0 */ [136]uint8 + _, _, _, _ = ap, db, savedDbFlags, zSql + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + savedDbFlags = (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + if (*TParse)(unsafe.Pointer(pParse)).FeParseMode != 0 { + return + } + /* Nesting should only be of limited depth */ + ap = va + zSql = _sqlite3VMPrintf(tls, db, zFormat, ap) + _ = ap + if zSql == uintptr(0) { + /* This can result either from an OOM or because the formatted string + ** exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set + ** an error */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_TOOBIG) + } + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + return + } + (*TParse)(unsafe.Pointer(pParse)).Fnested = (*TParse)(unsafe.Pointer(pParse)).Fnested + 1 + libc.Xmemcpy(tls, bp, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + libc.Xmemset(tls, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), 0, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_PreferBuiltin) + _sqlite3RunParser(tls, pParse, zSql) + (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags = savedDbFlags + _sqlite3DbFree(tls, db, zSql) + libc.Xmemcpy(tls, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), bp, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + (*TParse)(unsafe.Pointer(pParse)).Fnested = (*TParse)(unsafe.Pointer(pParse)).Fnested - 1 +} + +// C documentation +// +// /* +// ** Given a SELECT statement, generate a Table structure that describes +// ** the result set of that SELECT. +// */ +func _sqlite3ResultSetOfSelect(tls *libc.TLS, pParse uintptr, pSelect uintptr, aff uint8) (r uintptr) { + var db, pTab uintptr + var savedFlags Tu64 + _, _, _ = db, pTab, savedFlags + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + savedFlags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_FullColNames) + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_ShortColNames) + _sqlite3SelectPrep(tls, pParse, pSelect, uintptr(0)) + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = savedFlags + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return uintptr(0) + } + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + pTab = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTab == uintptr(0) { + return uintptr(0) + } + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pTab)).FzName = uintptr(0) + (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) + _sqlite3ColumnsFromExprList(tls, pParse, (*TSelect)(unsafe.Pointer(pSelect)).FpEList, pTab+54, pTab+8) + _sqlite3SubqueryColumnTypes(tls, pParse, pTab, pSelect, aff) + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(-int32(1)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3DeleteTable(tls, db, pTab) + return uintptr(0) + } + return pTab +} + +// C documentation +// +// /* +// ** This function is used to allocate and populate UnpackedRecord +// ** structures intended to be compared against sample index keys stored +// ** in the sqlite_stat4 table. +// ** +// ** A single call to this function populates zero or more fields of the +// ** record starting with field iVal (fields are numbered from left to +// ** right starting with 0). A single field is populated if: +// ** +// ** * (pExpr==0). In this case the value is assumed to be an SQL NULL, +// ** +// ** * The expression is a bound variable, and this is a reprepare, or +// ** +// ** * The sqlite3ValueFromExpr() function is able to extract a value +// ** from the expression (i.e. the expression is a literal value). +// ** +// ** Or, if pExpr is a TK_VECTOR, one field is populated for each of the +// ** vector components that match either of the two latter criteria listed +// ** above. +// ** +// ** Before any value is appended to the record, the affinity of the +// ** corresponding column within index pIdx is applied to it. Before +// ** this function returns, output parameter *pnExtract is set to the +// ** number of values appended to the record. +// ** +// ** When this function is called, *ppRec must either point to an object +// ** allocated by an earlier call to this function, or must be NULL. If it +// ** is NULL and a value can be successfully extracted, a new UnpackedRecord +// ** is allocated (and *ppRec set to point to it) before returning. +// ** +// ** Unless an error is encountered, SQLITE_OK is returned. It is not an +// ** error if a value cannot be extracted from pExpr. If an error does +// ** occur, an SQLite error code is returned. +// */ +func _sqlite3Stat4ProbeSetValue(tls *libc.TLS, pParse uintptr, pIdx uintptr, ppRec uintptr, pExpr uintptr, nElem int32, iVal int32, pnExtract uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aff Tu8 + var i, nExtract, rc int32 + var pElem, v2 uintptr + var _ /* alloc at bp+0 */ TValueNewStat4Ctx + var _ /* pVal at bp+32 */ uintptr + _, _, _, _, _, _ = aff, i, nExtract, pElem, rc, v2 + rc = SQLITE_OK + nExtract = 0 + if pExpr == uintptr(0) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_SELECT) { + (**(**TValueNewStat4Ctx)(__ccgo_up(bp))).FpParse = pParse + (**(**TValueNewStat4Ctx)(__ccgo_up(bp))).FpIdx = pIdx + (**(**TValueNewStat4Ctx)(__ccgo_up(bp))).FppRec = ppRec + i = 0 + for { + if !(i < nElem) { + break + } + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + if pExpr != 0 { + v2 = _sqlite3VectorFieldSubexpr(tls, pExpr, i) + } else { + v2 = uintptr(0) + } + pElem = v2 + aff = _sqlite3IndexColumnAffinity(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pIdx, iVal+i) + (**(**TValueNewStat4Ctx)(__ccgo_up(bp))).FiVal = iVal + i + rc = _stat4ValueFromExpr(tls, pParse, pElem, aff, bp, bp+32) + if !(**(**uintptr)(__ccgo_up(bp + 32)) != 0) { + break + } + nExtract = nExtract + 1 + goto _1 + _1: + ; + i = i + 1 + } + } + **(**int32)(__ccgo_up(pnExtract)) = nExtract + return rc +} + +// C documentation +// +// /* +// ** Compute an affinity string for a table. Space is obtained +// ** from sqlite3DbMalloc(). The caller is responsible for freeing +// ** the space when done. +// */ +func _sqlite3TableAffinityStr(tls *libc.TLS, db uintptr, pTab uintptr) (r uintptr) { + var i, j, v2, v3 int32 + var zColAff uintptr + _, _, _, _, _ = i, j, zColAff, v2, v3 + zColAff = _sqlite3DbMallocRaw(tls, db, libc.Uint64FromInt32(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1))) + if zColAff != 0 { + v2 = libc.Int32FromInt32(0) + j = v2 + i = v2 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + v3 = j + j = j + 1 + **(**uint8)(__ccgo_up(zColAff + uintptr(v3))) = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity + } + goto _1 + _1: + ; + i = i + 1 + } + for cond := true; cond; cond = j >= 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zColAff + uintptr(j)))) <= int32(SQLITE_AFF_BLOB) { + v2 = j + j = j - 1 + **(**uint8)(__ccgo_up(zColAff + uintptr(v2))) = uint8(0) + } + } + return zColAff +} + +// C documentation +// +// /* +// ** Return the affinity character for a single column of a table. +// */ +func _sqlite3TableColumnAffinity(tls *libc.TLS, pTab uintptr, iCol int32) (r uint8) { + if iCol < 0 || iCol >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + return uint8(SQLITE_AFF_INTEGER) + } + return (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).Faffinity +} + +// C documentation +// +// /* +// ** Add a new name/number pair to a VList. This might require that the +// ** VList object be reallocated, so return the new VList. If an OOM +// ** error occurs, the original VList returned and the +// ** db->mallocFailed flag is set. +// ** +// ** A VList is really just an array of integers. To destroy a VList, +// ** simply pass it to sqlite3DbFree(). +// ** +// ** The first integer is the number of integers allocated for the whole +// ** VList. The second integer is the number of integers actually used. +// ** Each name/number pair is encoded by subsequent groups of 3 or more +// ** integers. +// ** +// ** Each name/number pair starts with two integers which are the numeric +// ** value for the pair and the size of the name/number pair, respectively. +// ** The text name overlays one or more following integers. The text name +// ** is always zero-terminated. +// ** +// ** Conceptually: +// ** +// ** struct VList { +// ** int nAlloc; // Number of allocated slots +// ** int nUsed; // Number of used slots +// ** struct VListEntry { +// ** int iValue; // Value for this entry +// ** int nSlot; // Slots used by this entry +// ** // ... variable name goes here +// ** } a[0]; +// ** } +// ** +// ** During code generation, pointers to the variable names within the +// ** VList are taken. When that happens, nAlloc is set to zero as an +// ** indication that the VList may never again be enlarged, since the +// ** accompanying realloc() would invalidate the pointers. +// */ +func _sqlite3VListAdd(tls *libc.TLS, db uintptr, pIn uintptr, zName uintptr, nName int32, iVal int32) (r uintptr) { + var i, nInt int32 + var nAlloc Tsqlite3_int64 + var pOut, z uintptr + var v1 int64 + _, _, _, _, _, _ = i, nAlloc, nInt, pOut, z, v1 /* Index in pIn[] where zName is stored */ + nInt = nName/int32(4) + int32(3) + /* Verify ok to add new elements */ + if pIn == uintptr(0) || **(**TVList)(__ccgo_up(pIn + 1*4))+nInt > **(**TVList)(__ccgo_up(pIn)) { + if pIn != 0 { + v1 = int64(2) * int64(**(**TVList)(__ccgo_up(pIn))) + } else { + v1 = int64(10) + } + /* Enlarge the allocation */ + nAlloc = v1 + int64(nInt) + pOut = _sqlite3DbRealloc(tls, db, pIn, libc.Uint64FromInt64(nAlloc)*uint64(4)) + if pOut == uintptr(0) { + return pIn + } + if pIn == uintptr(0) { + **(**TVList)(__ccgo_up(pOut + 1*4)) = int32(2) + } + pIn = pOut + **(**TVList)(__ccgo_up(pIn)) = int32(nAlloc) + } + i = **(**TVList)(__ccgo_up(pIn + 1*4)) + **(**TVList)(__ccgo_up(pIn + uintptr(i)*4)) = iVal + **(**TVList)(__ccgo_up(pIn + uintptr(i+int32(1))*4)) = nInt + z = pIn + uintptr(i+int32(2))*4 + **(**TVList)(__ccgo_up(pIn + 1*4)) = i + nInt + libc.Xmemcpy(tls, z, zName, libc.Uint64FromInt32(nName)) + **(**uint8)(__ccgo_up(z + uintptr(nName))) = uint8(0) + return pIn +} + +// C documentation +// +// /* +// ** Return the number of the variable named zName, if it is in VList. +// ** or return 0 if there is no such variable. +// */ +func _sqlite3VListNameToNum(tls *libc.TLS, pIn uintptr, zName uintptr, nName int32) (r int32) { + var i, mx int32 + var z uintptr + _, _, _ = i, mx, z + if pIn == uintptr(0) { + return 0 + } + mx = **(**TVList)(__ccgo_up(pIn + 1*4)) + i = int32(2) + for cond := true; cond; cond = i < mx { + z = pIn + uintptr(i+int32(2))*4 + if libc.Xstrncmp(tls, z, zName, libc.Uint64FromInt32(nName)) == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(nName)))) == 0 { + return **(**TVList)(__ccgo_up(pIn + uintptr(i)*4)) + } + i = i + **(**TVList)(__ccgo_up(pIn + uintptr(i+int32(1))*4)) + } + return 0 +} + +/************** End of util.c ************************************************/ +/************** Begin file hash.c ********************************************/ +/* +** 2001 September 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This is the implementation of generic hash-tables +** used in SQLite. + */ +/* #include "sqliteInt.h" */ +/* #include */ + +// C documentation +// +// /* +// ** Print into memory obtained from sqliteMalloc(). Use the internal +// ** %-conversion extensions. +// */ +func _sqlite3VMPrintf(tls *libc.TLS, db uintptr, zFormat uintptr, ap Tva_list) (r uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var z uintptr + var _ /* acc at bp+72 */ TStrAccum + var _ /* zBase at bp+0 */ [70]uint8 + _ = z + _sqlite3StrAccumInit(tls, bp+72, db, bp, int32(70), **(**int32)(__ccgo_up(db + 136))) + (**(**TStrAccum)(__ccgo_up(bp + 72))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + Xsqlite3_str_vappendf(tls, bp+72, zFormat, ap) + z = _sqlite3StrAccumFinish(tls, bp+72) + if libc.Int32FromUint8((**(**TStrAccum)(__ccgo_up(bp + 72))).FaccError) == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + return z +} + +// C documentation +// +// /* +// ** This routine checks for a byte-order mark at the beginning of the +// ** UTF-16 string stored in *pMem. If one is present, it is removed and +// ** the encoding of the Mem adjusted. This routine does not do any +// ** byte-swapping, it just sets Mem.enc appropriately. +// ** +// ** The allocation (static, dynamic etc.) and encoding of the Mem may be +// ** changed by this function. +// */ +func _sqlite3VdbeMemHandleBom(tls *libc.TLS, pMem uintptr) (r int32) { + var b1, b2, bom Tu8 + var rc int32 + var v1 uintptr + _, _, _, _, _ = b1, b2, bom, rc, v1 + rc = SQLITE_OK + bom = uint8(0) + if (*TMem)(unsafe.Pointer(pMem)).Fn > int32(1) { + b1 = **(**Tu8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz)) + b2 = **(**Tu8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + libc.UintptrFromInt32(1))) + if libc.Int32FromUint8(b1) == int32(0xFE) && libc.Int32FromUint8(b2) == int32(0xFF) { + bom = uint8(SQLITE_UTF16BE) + } + if libc.Int32FromUint8(b1) == int32(0xFF) && libc.Int32FromUint8(b2) == int32(0xFE) { + bom = uint8(SQLITE_UTF16LE) + } + } + if bom != 0 { + rc = _sqlite3VdbeMemMakeWriteable(tls, pMem) + if rc == SQLITE_OK { + **(**int32)(__ccgo_up(pMem + 16)) -= int32(2) + libc.Xmemmove(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, (*TMem)(unsafe.Pointer(pMem)).Fz+2, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn)) + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = uint8('\000') + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn+int32(1)))) = uint8('\000') + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pMem)).Fenc = bom + } + } + return rc +} + +// C documentation +// +// /* +// ** Change the value of a Mem to be a string or a BLOB. +// ** +// ** The memory management strategy depends on the value of the xDel +// ** parameter. If the value passed is SQLITE_TRANSIENT, then the +// ** string is copied into a (possibly existing) buffer managed by the +// ** Mem structure. Otherwise, any existing buffer is freed and the +// ** pointer copied. +// ** +// ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH +// ** size limit) then no memory allocation occurs. If the string can be +// ** stored without allocating memory, then it is. If a memory allocation +// ** is required to store the string, then value of pMem is unchanged. In +// ** either case, SQLITE_TOOBIG is returned. +// ** +// ** The "enc" parameter is the text encoding for the string, or zero +// ** to store a blob. +// ** +// ** If n is negative, then the string consists of all bytes up to but +// ** excluding the first zero character. The n parameter must be +// ** non-negative for blobs. +// */ +func _sqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n Ti64, enc Tu8, __ccgo_fp_xDel uintptr) (r int32) { + var flags Tu16 + var iLimit, v2 int32 + var nAlloc, nByte Ti64 + var v3 int64 + _, _, _, _, _, _ = flags, iLimit, nAlloc, nByte, v2, v3 + nByte = n /* New value for pMem->flags */ + /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ + if !(z != 0) { + _sqlite3VdbeMemSetNull(tls, pMem) + return SQLITE_OK + } + if (*TMem)(unsafe.Pointer(pMem)).Fdb != 0 { + iLimit = **(**int32)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fdb + 136)) + } else { + iLimit = int32(SQLITE_MAX_LENGTH) + } + if nByte < 0 { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, z)) + } else { + nByte = 0 + for { + if !(nByte <= int64(iLimit) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(nByte))))|libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(nByte+int64(1))))) != 0) { + break + } + goto _1 + _1: + ; + nByte = nByte + int64(2) + } + } + flags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term)) + } else { + if libc.Int32FromUint8(enc) == 0 { + flags = uint16(MEM_Blob) + enc = uint8(SQLITE_UTF8) + } else { + flags = uint16(MEM_Str) + } + } + if nByte > int64(iLimit) { + if __ccgo_fp_xDel != 0 && __ccgo_fp_xDel != uintptr(-libc.Int32FromInt32(1)) { + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, z) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, z) + } + } + _sqlite3VdbeMemSetNull(tls, pMem) + return _sqlite3ErrorToParser(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, int32(SQLITE_TOOBIG)) + } + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + if __ccgo_fp_xDel == uintptr(-libc.Int32FromInt32(1)) { + nAlloc = nByte + if libc.Int32FromUint16(flags)&int32(MEM_Term) != 0 { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + v2 = int32(1) + } else { + v2 = int32(2) + } + nAlloc = nAlloc + int64(v2) + } + if nAlloc > int64(libc.Int32FromInt32(32)) { + v3 = nAlloc + } else { + v3 = int64(libc.Int32FromInt32(32)) + } + if _sqlite3VdbeMemClearAndResize(tls, pMem, int32(v3)) != 0 { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, z, libc.Uint64FromInt64(nAlloc)) + } else { + _sqlite3VdbeMemRelease(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = z + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = (*TMem)(unsafe.Pointer(pMem)).Fz + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } else { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + if __ccgo_fp_xDel == libc.UintptrFromInt32(0) { + v2 = int32(MEM_Static) + } else { + v2 = int32(MEM_Dyn) + } + flags = libc.Uint16FromInt32(int32(flags) | v2) + } + } + (*TMem)(unsafe.Pointer(pMem)).Fn = int32(nByte & libc.Int64FromInt32(0x7fffffff)) + (*TMem)(unsafe.Pointer(pMem)).Fflags = flags + (*TMem)(unsafe.Pointer(pMem)).Fenc = enc + if libc.Int32FromUint8(enc) > int32(SQLITE_UTF8) && _sqlite3VdbeMemHandleBom(tls, pMem) != 0 { + return int32(SQLITE_NOMEM) + } + return SQLITE_OK +} + +// C documentation +// +// /* Like sqlite3VdbeMemSetStr() except: +// ** +// ** enc is always SQLITE_UTF8 +// ** pMem->db is always non-NULL +// */ +func _sqlite3VdbeMemSetText(tls *libc.TLS, pMem uintptr, z uintptr, n Ti64, __ccgo_fp_xDel uintptr) (r int32) { + var flags Tu16 + var nAlloc, nByte Ti64 + var v1 int64 + _, _, _, _ = flags, nAlloc, nByte, v1 + nByte = n + /* If z is a NULL pointer, set pMem to contain an SQL NULL. */ + if !(z != 0) { + _sqlite3VdbeMemSetNull(tls, pMem) + return SQLITE_OK + } + if nByte < 0 { + nByte = libc.Int64FromUint64(libc.Xstrlen(tls, z)) + flags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term)) + } else { + flags = uint16(MEM_Str) + } + if nByte > int64(**(**int32)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fdb + 136))) { + if __ccgo_fp_xDel != 0 && __ccgo_fp_xDel != uintptr(-libc.Int32FromInt32(1)) { + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, z) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, z) + } + } + _sqlite3VdbeMemSetNull(tls, pMem) + return _sqlite3ErrorToParser(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, int32(SQLITE_TOOBIG)) + } + /* The following block sets the new values of Mem.z and Mem.xDel. It + ** also sets a flag in local variable "flags" to indicate the memory + ** management (one of MEM_Dyn or MEM_Static). + */ + if __ccgo_fp_xDel == uintptr(-libc.Int32FromInt32(1)) { + nAlloc = nByte + int64(1) + if nAlloc > int64(libc.Int32FromInt32(32)) { + v1 = nAlloc + } else { + v1 = int64(libc.Int32FromInt32(32)) + } + if _sqlite3VdbeMemClearAndResize(tls, pMem, int32(v1)) != 0 { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, z, libc.Uint64FromInt64(nByte)) + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr(nByte))) = uint8(0) + } else { + _sqlite3VdbeMemRelease(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = z + if __ccgo_fp_xDel == __ccgo_fp(_sqlite3RowSetClear) { + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = (*TMem)(unsafe.Pointer(pMem)).Fz + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + (*TMem)(unsafe.Pointer(pMem)).FxDel = uintptr(0) + } else { + if __ccgo_fp_xDel == libc.UintptrFromInt32(0) { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + flags = libc.Uint16FromInt32(int32(flags) | libc.Int32FromInt32(MEM_Static)) + } else { + (*TMem)(unsafe.Pointer(pMem)).FxDel = __ccgo_fp_xDel + flags = libc.Uint16FromInt32(int32(flags) | libc.Int32FromInt32(MEM_Dyn)) + } + } + } + (*TMem)(unsafe.Pointer(pMem)).Fflags = flags + (*TMem)(unsafe.Pointer(pMem)).Fn = int32(nByte & libc.Int64FromInt32(0x7fffffff)) + (*TMem)(unsafe.Pointer(pMem)).Fenc = uint8(SQLITE_UTF8) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** If pMem is already a string, detect if it is a zero-terminated +// ** string, or make it into one if possible, and mark it as such. +// ** +// ** This is an optimization. Correct operation continues even if +// ** this routine is a no-op. +// ** +// ** Return true if the strig is zero-terminated after this routine is +// ** called and false if it is not. +// */ +func _sqlite3VdbeMemZeroTerminateIfAble(tls *libc.TLS, pMem uintptr) (r int32) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Term)|libc.Int32FromInt32(MEM_Ephem)|libc.Int32FromInt32(MEM_Static)) != int32(MEM_Str) { + /* pMem must be a string, and it cannot be an ephemeral or static string */ + return 0 + } + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) != int32(SQLITE_UTF8) { + return 0 + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Dyn) != 0 { + if (*TMem)(unsafe.Pointer(pMem)).FxDel == __ccgo_fp(Xsqlite3_free) && Xsqlite3_msize(tls, (*TMem)(unsafe.Pointer(pMem)).Fz) >= libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn+libc.Int32FromInt32(1)) { + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = uint8(0) + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + return int32(1) + } + if (*TMem)(unsafe.Pointer(pMem)).FxDel == __ccgo_fp(_sqlite3RCStrUnref) { + /* Blindly assume that all RCStr objects are zero-terminated */ + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + return int32(1) + } + } else { + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc >= (*TMem)(unsafe.Pointer(pMem)).Fn+int32(1) { + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = uint8(0) + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** This is called by code in select.c before it calls sqlite3WhereBegin() +// ** to begin iterating through the sub-query results. It is used to allocate +// ** and initialize registers and cursors used by sqlite3WindowCodeStep(). +// */ +func _sqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) { + var nEphExpr, nExpr, v1 int32 + var p, pKeyInfo, pList, pMWin, pWin, v, v2 uintptr + _, _, _, _, _, _, _, _, _, _ = nEphExpr, nExpr, p, pKeyInfo, pList, pMWin, pWin, v, v1, v2 + nEphExpr = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + 72)))).FpSelect)).FpEList)).FnExpr + pMWin = (*TSelect)(unsafe.Pointer(pSelect)).FpWin + v = _sqlite3GetVdbe(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr, nEphExpr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr+int32(1), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr+int32(2), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr+int32(3), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + /* Allocate registers to use for PARTITION BY values, if any. Initialize + ** said registers to NULL. */ + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + nExpr = (*TExprList)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pMWin)).FpPartition)).FnExpr + (*TWindow)(unsafe.Pointer(pMWin)).FregPart = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nExpr + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pMWin)).FregPart, (*TWindow)(unsafe.Pointer(pMWin)).FregPart+nExpr-int32(1)) + } + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pMWin)).FregOne = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TWindow)(unsafe.Pointer(pMWin)).FregOne) + if (*TWindow)(unsafe.Pointer(pMWin)).FeExclude != 0 { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid = v1 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pMWin)).FregEndRowid = v1 + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pMWin)).FcsrApp = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pMWin)).FregEndRowid) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pMWin)).FcsrApp, (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + return + } + pWin = pMWin + for { + if !(pWin != 0) { + break + } + p = (*TWindow)(unsafe.Pointer(pWin)).FpWFunc + if (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_MINMAX) != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeStart) != int32(TK_UNBOUNDED) { + pList = *(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)) + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, pList, 0, 0) + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pWin)).FcsrApp = v1 + (*TWindow)(unsafe.Pointer(pWin)).FregApp = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(3) + if pKeyInfo != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TFuncDef)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpWFunc)).FzName + 1))) == int32('i') { + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags)) = uint8(KEYINFO_ORDER_DESC) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, int32(2)) + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(1)) + } else { + if (*TFuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&_nth_valueName)) || (*TFuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&_first_valueName)) { + /* Allocate two registers at pWin->regApp. These will be used to + ** store the start and end index of the current frame. */ + (*TWindow)(unsafe.Pointer(pWin)).FregApp = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pWin)).FcsrApp = v1 + **(**int32)(__ccgo_up(pParse + 60)) += int32(2) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + } else { + if (*TFuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&_leadName)) || (*TFuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&_lagName)) { + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pWin)).FcsrApp = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr) + } + } + } + goto _9 + _9: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } +} + +// C documentation +// +// /* +// ** If the SELECT statement passed as the second argument does not invoke +// ** any SQL window functions, this function is a no-op. Otherwise, it +// ** rewrites the SELECT statement so that window function xStep functions +// ** are invoked in the correct order as described under "SELECT REWRITING" +// ** at the top of this file. +// */ +func _sqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pArgs, pFilter, pGroupBy, pHaving, pMWin, pSort, pSrc, pSub, pTab, pTab2, pWhere, pWin, v, v2 uintptr + var nSave, rc, v1 int32 + var selFlags Tu32 + var _ /* pSublist at bp+0 */ uintptr + var _ /* w at bp+8 */ TWalker + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, nSave, pArgs, pFilter, pGroupBy, pHaving, pMWin, pSort, pSrc, pSub, pTab, pTab2, pWhere, pWin, rc, selFlags, v, v1, v2 + rc = SQLITE_OK + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 && (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_WinRewrite) == uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + v = _sqlite3GetVdbe(tls, pParse) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pSub = uintptr(0) /* The subquery */ + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + pWhere = (*TSelect)(unsafe.Pointer(p)).FpWhere + pGroupBy = (*TSelect)(unsafe.Pointer(p)).FpGroupBy + pHaving = (*TSelect)(unsafe.Pointer(p)).FpHaving + pSort = uintptr(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Expression list for sub-query */ + pMWin = (*TSelect)(unsafe.Pointer(p)).FpWin + selFlags = (*TSelect)(unsafe.Pointer(p)).FselFlags + pTab = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTab == uintptr(0) { + return _sqlite3ErrorToParser(tls, db, int32(SQLITE_NOMEM)) + } + _sqlite3AggInfoPersistWalkerInit(tls, bp+8, pParse) + _sqlite3WalkSelect(tls, bp+8, p) + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Aggregate) == uint32(0) { + (**(**TWalker)(__ccgo_up(bp + 8))).FxExprCallback = __ccgo_fp(_disallowAggregatesInOrderByCb) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback = uintptr(0) + _sqlite3WalkExprList(tls, bp+8, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + } + (*TSelect)(unsafe.Pointer(p)).FpSrc = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpWhere = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpGroupBy = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpHaving = uintptr(0) + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Aggregate) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_WinRewrite) + /* Create the ORDER BY clause for the sub-select. This is the concatenation + ** of the window PARTITION and ORDER BY clauses. Then, if this makes it + ** redundant, remove the ORDER BY from the parent SELECT. */ + pSort = _exprListAppendList(tls, pParse, uintptr(0), (*TWindow)(unsafe.Pointer(pMWin)).FpPartition, int32(1)) + pSort = _exprListAppendList(tls, pParse, pSort, (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy, int32(1)) + if pSort != 0 && (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 && (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr <= (*TExprList)(unsafe.Pointer(pSort)).FnExpr { + nSave = (*TExprList)(unsafe.Pointer(pSort)).FnExpr + (*TExprList)(unsafe.Pointer(pSort)).FnExpr = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr + if _sqlite3ExprListCompare(tls, pSort, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, -int32(1)) == 0 { + _sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + } + (*TExprList)(unsafe.Pointer(pSort)).FnExpr = nSave + } + /* Assign a cursor number for the ephemeral table used to buffer rows. + ** The OpenEphemeral instruction is coded later, after it is known how + ** many columns the table will have. */ + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr = v1 + **(**int32)(__ccgo_up(pParse + 56)) += int32(3) + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, (*TSelect)(unsafe.Pointer(p)).FpEList, pTab, bp) + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, pTab, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol = v1 + /* Append the PARTITION BY and ORDER BY expressions to the to the + ** sub-select expression list. They are required to figure out where + ** boundaries for partitions and sets of peer rows lie. */ + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), (*TWindow)(unsafe.Pointer(pMWin)).FpPartition, 0) + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy, 0) + /* Append the arguments passed to each window function to the + ** sub-select expression list. Also allocate two registers for each + ** window function - one for the accumulator, another for interim + ** results. */ + pWin = pMWin + for { + if !(pWin != 0) { + break + } + pArgs = *(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)) + if (*TFuncDef)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpWFunc)).FfuncFlags&uint32(SQLITE_SUBTYPE) != 0 { + _selectWindowRewriteEList(tls, pParse, pMWin, pSrc, pArgs, pTab, bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pWin)).FiArgCol = v1 + (*TWindow)(unsafe.Pointer(pWin)).FbExprArgs = uint8(1) + } else { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr + } else { + v1 = 0 + } + (*TWindow)(unsafe.Pointer(pWin)).FiArgCol = v1 + **(**uintptr)(__ccgo_up(bp)) = _exprListAppendList(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pArgs, 0) + } + if (*TWindow)(unsafe.Pointer(pWin)).FpFilter != 0 { + pFilter = _sqlite3ExprDup(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FpFilter, 0) + **(**uintptr)(__ccgo_up(bp)) = _sqlite3ExprListAppend(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pFilter) + } + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pWin)).FregAccum = v1 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWindow)(unsafe.Pointer(pWin)).FregResult = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregAccum) + goto _4 + _4: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + /* If there is no ORDER BY or PARTITION BY clause, and the window + ** function accepts zero arguments, and there are no other columns + ** selected (e.g. "SELECT row_number() OVER () FROM t1"), it is possible + ** that pSublist is still NULL here. Add a constant expression here to + ** keep everything legal in this case. + */ + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3ExprInt32(tls, db, 0)) + } + pSub = _sqlite3SelectNew(tls, pParse, **(**uintptr)(__ccgo_up(bp)), pSrc, pWhere, pGroupBy, pHaving, pSort, uint32(0), uintptr(0)) + (*TSelect)(unsafe.Pointer(p)).FpSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + /* Due to db->mallocFailed test inside + ** of sqlite3DbMallocRawNN() called from + ** sqlite3SrcListAppend() */ + if (*TSelect)(unsafe.Pointer(p)).FpSrc == uintptr(0) { + _sqlite3SelectDelete(tls, db, pSub) + } else { + if _sqlite3SrcItemAttachSubquery(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpSrc+8, pSub, 0) != 0 { + libc.SetBitFieldPtr32Uint32((*TSelect)(unsafe.Pointer(p)).FpSrc+8+24+4, libc.Uint32FromInt32(1), 4, 0x10) + _sqlite3SrcListAssignCursors(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpSrc) + **(**Tu32)(__ccgo_up(pSub + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(SF_Expanded) | libc.Int32FromInt32(SF_OrderByReqd)) + pTab2 = _sqlite3ResultSetOfSelect(tls, pParse, pSub, uint8(SQLITE_AFF_NONE)) + **(**Tu32)(__ccgo_up(pSub + 4)) |= selFlags & uint32(SF_Aggregate) + if pTab2 == uintptr(0) { + /* Might actually be some other kind of error, but in that case + ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get + ** the correct error message regardless. */ + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, pTab, pTab2, uint64(120)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_Ephemeral) + (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab = pTab + pTab = pTab2 + libc.Xmemset(tls, bp+8, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp + 8))).FxExprCallback = __ccgo_fp(_sqlite3WindowExtraAggFuncDepth) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback = __ccgo_fp(_sqlite3WalkerDepthIncrease) + (**(**TWalker)(__ccgo_up(bp + 8))).FxSelectCallback2 = __ccgo_fp(_sqlite3WalkerDepthDecrease) + _sqlite3WalkSelect(tls, bp+8, pSub) + } + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } + /* Defer deleting the temporary table pTab because if an error occurred, + ** there could still be references to that table embedded in the + ** result-set or ORDER BY clause of the SELECT statement p. */ + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3DbFree), pTab) + } + return rc +} + +// C documentation +// +// /* +// ** Return TRUE if the WHERE clause term pTerm is of a form where it +// ** could be used with an index to access pSrc, assuming an appropriate +// ** index existed. +// */ +func _termCanDriveIndex(tls *libc.TLS, pTerm uintptr, pSrc uintptr, notReady TBitmask) (r int32) { + var aff uint8 + var leftCol int32 + _, _ = aff, leftCol + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { + return 0 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) == 0 { + return 0 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 && !(_constraintCompatibleWithOuterJoin(tls, pTerm, pSrc) != 0) { + return 0 /* See https://sqlite.org/forum/forumpost/51e6959f61 */ + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight¬Ready != uint64(0) { + return 0 + } + leftCol = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn + if leftCol < 0 { + return 0 + } + aff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FaCol + uintptr(leftCol)*16))).Faffinity + if !(_sqlite3IndexAffinityOk(tls, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, aff) != 0) { + return 0 + } + return _columnIsGoodIndexCandidate(tls, (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab, leftCol) +} + +// C documentation +// +// /* Construct a new Expr object from a single token */ +func _tokenExpr(tls *libc.TLS, pParse uintptr, op int32, _t TToken) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*TToken)(unsafe.Pointer(bp)) = _t + var p, v1 uintptr + _, _ = p, v1 + p = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(72)+uint64((**(**TToken)(__ccgo_up(bp))).Fn)+uint64(1)) + if p != 0 { + /* memset(p, 0, sizeof(Expr)); */ + (*TExpr)(unsafe.Pointer(p)).Fop = libc.Uint8FromInt32(op) + (*TExpr)(unsafe.Pointer(p)).FaffExpr = uint8(0) + (*TExpr)(unsafe.Pointer(p)).Fflags = uint32(EP_Leaf) + /* p->iAgg = -1; // Not required */ + v1 = libc.UintptrFromInt32(0) + (*TExpr)(unsafe.Pointer(p)).FpRight = v1 + (*TExpr)(unsafe.Pointer(p)).FpLeft = v1 + (*TExpr)(unsafe.Pointer(p)).FpAggInfo = uintptr(0) + libc.Xmemset(tls, p+32, 0, uint64(8)) + libc.Xmemset(tls, p+64, 0, uint64(8)) + (*TExpr)(unsafe.Pointer(p)).Fop2 = uint8(0) + (*TExpr)(unsafe.Pointer(p)).FiTable = 0 + (*TExpr)(unsafe.Pointer(p)).FiColumn = 0 + *(*uintptr)(unsafe.Pointer(p + 8)) = p + 1*72 + libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(p + 8)), (**(**TToken)(__ccgo_up(bp))).Fz, uint64((**(**TToken)(__ccgo_up(bp))).Fn)) + **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(p + 8)) + uintptr((**(**TToken)(__ccgo_up(bp))).Fn))) = uint8(0) + *(*int32)(unsafe.Pointer(p + 52)) = int32(int64((**(**TToken)(__ccgo_up(bp))).Fz) - int64((*TParse)(unsafe.Pointer(pParse)).FzTail)) + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(p + 8)))))])&int32(0x80) != 0 { + _sqlite3DequoteExpr(tls, p) + } + (*TExpr)(unsafe.Pointer(p)).FnHeight = int32(1) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return _sqlite3RenameTokenMap(tls, pParse, p, bp) + } + } + return p +} + +func _unicodeSetCategories(tls *libc.TLS, p uintptr, zCat uintptr) (r int32) { + var z uintptr + _ = z + z = zCat + for **(**uint8)(__ccgo_up(z)) != 0 { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32(' ') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32('\t') { + z = z + 1 + } + if **(**uint8)(__ccgo_up(z)) != 0 && _sqlite3Fts5UnicodeCatParse(tls, z, p+160) != 0 { + return int32(SQLITE_ERROR) + } + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != int32(' ') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != int32('\t') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != int32('\000') { + z = z + 1 + } + } + _sqlite3Fts5UnicodeAscii(tls, p+160, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** For OP_Column, factor out the case where content is loaded from +// ** overflow pages, so that the code to implement this case is separate +// ** the common case where all content fits on the page. Factoring out +// ** the code reduces register pressure and helps the common case +// ** to run faster. +// */ +func _vdbeColumnFromOverflow(tls *libc.TLS, pC uintptr, iCol int32, t Tu32, iOffset Ti64, cacheStatus Tu32, colCacheCtr Tu32, pDest uintptr) (r int32) { + var db, pBuf, pCache, v1 uintptr + var encoding, len1, rc int32 + _, _, _, _, _, _, _ = db, encoding, len1, pBuf, pCache, rc, v1 + db = (*TMem)(unsafe.Pointer(pDest)).Fdb + encoding = libc.Int32FromUint8((*TMem)(unsafe.Pointer(pDest)).Fenc) + len1 = libc.Int32FromUint32(_sqlite3VdbeSerialTypeLen(tls, t)) + if len1 > **(**int32)(__ccgo_up(db + 136)) { + return int32(SQLITE_TOOBIG) + } + if len1 > int32(4000) && (*TVdbeCursor)(unsafe.Pointer(pC)).FpKeyInfo == uintptr(0) { + if int32(TBool(*(*uint8)(unsafe.Pointer(pC + 8))&0x10>>4)) == 0 { + (*TVdbeCursor)(unsafe.Pointer(pC)).FpCache = _sqlite3DbMallocZero(tls, db, uint64(32)) + if (*TVdbeCursor)(unsafe.Pointer(pC)).FpCache == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.SetBitFieldPtr8Uint32(pC+8, libc.Uint32FromInt32(1), 4, 0x10) + } + pCache = (*TVdbeCursor)(unsafe.Pointer(pC)).FpCache + if (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue == uintptr(0) || (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FiCol != iCol || (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FcacheStatus != cacheStatus || (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FcolCacheCtr != colCacheCtr || (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FiOffset != _sqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC + 48))) { + if (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue != 0 { + _sqlite3RCStrUnref(tls, (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue) + } + v1 = _sqlite3RCStrNew(tls, libc.Uint64FromInt32(len1+int32(3))) + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue = v1 + pBuf = v1 + if pBuf == uintptr(0) { + return int32(SQLITE_NOMEM) + } + rc = _sqlite3BtreePayload(tls, *(*uintptr)(unsafe.Pointer(pC + 48)), libc.Uint32FromInt64(iOffset), libc.Uint32FromInt32(len1), pBuf) + if rc != 0 { + return rc + } + **(**uint8)(__ccgo_up(pBuf + uintptr(len1))) = uint8(0) + **(**uint8)(__ccgo_up(pBuf + uintptr(len1+int32(1)))) = uint8(0) + **(**uint8)(__ccgo_up(pBuf + uintptr(len1+int32(2)))) = uint8(0) + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FiCol = iCol + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FcacheStatus = cacheStatus + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FcolCacheCtr = colCacheCtr + (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FiOffset = _sqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC + 48))) + } else { + pBuf = (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue + } + _sqlite3RCStrRef(tls, pBuf) + if t&uint32(1) != 0 { + rc = _sqlite3VdbeMemSetStr(tls, pDest, pBuf, int64(len1), libc.Uint8FromInt32(encoding), __ccgo_fp(_sqlite3RCStrUnref)) + v1 = pDest + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + } else { + rc = _sqlite3VdbeMemSetStr(tls, pDest, pBuf, int64(len1), uint8(0), __ccgo_fp(_sqlite3RCStrUnref)) + } + } else { + rc = _sqlite3VdbeMemFromBtree(tls, *(*uintptr)(unsafe.Pointer(pC + 48)), libc.Uint32FromInt64(iOffset), libc.Uint32FromInt32(len1), pDest) + if rc != 0 { + return rc + } + _sqlite3VdbeSerialGet(tls, (*TMem)(unsafe.Pointer(pDest)).Fz, t, pDest) + if t&uint32(1) != uint32(0) && encoding == int32(SQLITE_UTF8) { + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1))) = uint8(0) + v1 = pDest + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + } + } + v1 = pDest + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Ephem)) + return rc +} + +// C documentation +// +// /* +// ** It is already known that pMem contains an unterminated string. +// ** Add the zero terminator. +// ** +// ** Three bytes of zero are added. In this way, there is guaranteed +// ** to be a double-zero byte at an even byte boundary in order to +// ** terminate a UTF16 string, even if the initial size of the buffer +// ** is an odd number of bytes. +// */ +func _vdbeMemAddTerminator(tls *libc.TLS, pMem uintptr) (r int32) { + var v1 uintptr + _ = v1 + if _sqlite3VdbeMemGrow(tls, pMem, (*TMem)(unsafe.Pointer(pMem)).Fn+int32(3), int32(1)) != 0 { + return int32(SQLITE_NOMEM) + } + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = uint8(0) + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn+int32(1)))) = uint8(0) + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn+int32(2)))) = uint8(0) + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** The index pIdx is used by a query and contains one or more expressions. +// ** In other words pIdx is an index on an expression. iIdxCur is the cursor +// ** number for the index and iDataCur is the cursor number for the corresponding +// ** table. +// ** +// ** This routine adds IndexedExpr entries to the Parse->pIdxEpr field for +// ** each of the expressions in the index so that the expression code generator +// ** will know to replace occurrences of the indexed expression with +// ** references to the corresponding column of the index. +// */ +func _whereAddIndexedExpr(tls *libc.TLS, pParse uintptr, pIdx uintptr, iIdxCur int32, pTabItem uintptr) { + var i, j int32 + var p, pArg, pExpr, pTab uintptr + _, _, _, _, _, _ = i, j, p, pArg, pExpr, pTab + pTab = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) { + break + } + j = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) + if j == -int32(2) { + pExpr = (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(i)*32))).FpExpr + } else { + if j >= 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + pExpr = _sqlite3ColumnExpr(tls, pTab, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16) + } else { + goto _1 + } + } + if _sqlite3ExprIsConstant(tls, uintptr(0), pExpr) != 0 { + goto _1 + } + p = _sqlite3DbMallocRaw(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(32)) + if p == uintptr(0) { + break + } + (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) + (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur = (*TSrcItem)(unsafe.Pointer(pTabItem)).FiCursor + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur = iIdxCur + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol = i + (*TIndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow = libc.BoolUint8(libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0) + if _sqlite3IndexAffinityStr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pIdx) != 0 { + (*TIndexedExpr)(unsafe.Pointer(p)).Faff = uint8(**(**uint8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FzColAff + uintptr(i)))) + } + (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr = p + if (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext == uintptr(0) { + pArg = pParse + 96 + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_whereIndexedExprCleanup), pArg) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** This function is called for a partial index - one with a WHERE clause - in +// ** two scenarios. In both cases, it determines whether or not the WHERE +// ** clause on the index implies that a column of the table may be safely +// ** replaced by a constant expression. For example, in the following +// ** SELECT: +// ** +// ** CREATE INDEX i1 ON t1(b, c) WHERE a=; +// ** SELECT a, b, c FROM t1 WHERE a= AND b=?; +// ** +// ** The "a" in the select-list may be replaced by , iff: +// ** +// ** (a) is a constant expression, and +// ** (b) The (a=) comparison uses the BINARY collation sequence, and +// ** (c) Column "a" has an affinity other than NONE or BLOB. +// ** +// ** If argument pItem is NULL, then pMask must not be NULL. In this case this +// ** function is being called as part of determining whether or not pIdx +// ** is a covering index. This function clears any bits in (*pMask) +// ** corresponding to columns that may be replaced by constants as described +// ** above. +// ** +// ** Otherwise, if pItem is not NULL, then this function is being called +// ** as part of coding a loop that uses index pIdx. In this case, add entries +// ** to the Parse.pIdxPartExpr list for each column that can be replaced +// ** by a constant. +// */ +func _wherePartIdxExpr(tls *libc.TLS, pParse uintptr, pIdx uintptr, pPart uintptr, pMask uintptr, iIdxCur int32, pItem uintptr) { + var aff Tu8 + var bNullRow int32 + var db, p, pArg, pLeft, pRight uintptr + _, _, _, _, _, _, _ = aff, bNullRow, db, p, pArg, pLeft, pRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pPart)).Fop) == int32(TK_AND) { + _wherePartIdxExpr(tls, pParse, pIdx, (*TExpr)(unsafe.Pointer(pPart)).FpRight, pMask, iIdxCur, pItem) + pPart = (*TExpr)(unsafe.Pointer(pPart)).FpLeft + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pPart)).Fop) == int32(TK_EQ) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pPart)).Fop) == int32(TK_IS) { + pLeft = (*TExpr)(unsafe.Pointer(pPart)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pPart)).FpRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) != int32(TK_COLUMN) { + return + } + if !(_sqlite3ExprIsConstant(tls, uintptr(0), pRight) != 0) { + return + } + if !(_sqlite3IsBinary(tls, _sqlite3ExprCompareCollSeq(tls, pParse, pPart)) != 0) { + return + } + if int32((*TExpr)(unsafe.Pointer(pLeft)).FiColumn) < 0 { + return + } + aff = uint8((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pLeft)).FiColumn)*16))).Faffinity) + if libc.Int32FromUint8(aff) >= int32(SQLITE_AFF_TEXT) { + if pItem != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = _sqlite3DbMallocRaw(tls, db, uint64(32)) + if p != 0 { + bNullRow = libc.BoolInt32(libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0) + (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr = _sqlite3ExprDup(tls, db, pRight, 0) + (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur = iIdxCur + (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol = int32((*TExpr)(unsafe.Pointer(pLeft)).FiColumn) + (*TIndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow = libc.Uint8FromInt32(bNullRow) + (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext = (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr + (*TIndexedExpr)(unsafe.Pointer(p)).Faff = aff + (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr = p + if (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext == uintptr(0) { + pArg = pParse + 104 + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_whereIndexedExprCleanup), pArg) + } + } + } else { + if int32((*TExpr)(unsafe.Pointer(pLeft)).FiColumn) < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + **(**TBitmask)(__ccgo_up(pMask)) &= ^(libc.Uint64FromInt32(1) << (*TExpr)(unsafe.Pointer(pLeft)).FiColumn) + } + } + } + } +} + +// C documentation +// +// /* +// ** This function is called to estimate the number of rows visited by a +// ** range-scan on a skip-scan index. For example: +// ** +// ** CREATE INDEX i1 ON t1(a, b, c); +// ** SELECT * FROM t1 WHERE a=? AND c BETWEEN ? AND ?; +// ** +// ** Value pLoop->nOut is currently set to the estimated number of rows +// ** visited for scanning (a=? AND b=?). This function reduces that estimate +// ** by some factor to account for the (c BETWEEN ? AND ?) expression based +// ** on the stat4 data for the index. this scan will be performed multiple +// ** times (once for each (a,b) combination that matches a=?) is dealt with +// ** by the caller. +// ** +// ** It does this by scanning through all stat4 samples, comparing values +// ** extracted from pLower and pUpper with the corresponding column in each +// ** sample. If L and U are the number of samples found to be less than or +// ** equal to the values extracted from pLower and pUpper respectively, and +// ** N is the total number of samples, the pLoop->nOut value is adjusted +// ** as follows: +// ** +// ** nOut = nOut * ( min(U - L, 1) / N ) +// ** +// ** If pLower is NULL, or a value cannot be extracted from the term, L is +// ** set to zero. If pUpper is NULL, or a value cannot be extracted from it, +// ** U is set to N. +// ** +// ** Normally, this function sets *pbDone to 1 before returning. However, +// ** if no value can be extracted from either pLower or pUpper (and so the +// ** estimate of the number of rows delivered remains unchanged), *pbDone +// ** is left as is. +// ** +// ** If an error occurs, an SQLite error code is returned. Otherwise, +// ** SQLITE_OK. +// */ +func _whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper uintptr, pLoop uintptr, pbDone uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aff Tu8 + var db, p, pColl, v3 uintptr + var i, nAdjust, nDiff, nEq, nLower, nUpper, rc, res, res1, v1 int32 + var _ /* p1 at bp+0 */ uintptr + var _ /* p2 at bp+8 */ uintptr + var _ /* pVal at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aff, db, i, nAdjust, nDiff, nEq, nLower, nUpper, p, pColl, rc, res, res1, v1, v3 + p = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + nEq = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + nLower = -int32(1) + nUpper = (*TIndex)(unsafe.Pointer(p)).FnSample + int32(1) + rc = SQLITE_OK + aff = _sqlite3IndexColumnAffinity(tls, db, p, nEq) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Value extracted from pLower */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Value extracted from pUpper */ + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) /* Value extracted from record */ + pColl = _sqlite3LocateCollSeq(tls, pParse, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(p)).FazColl + uintptr(nEq)*8))) + if pLower != 0 { + rc = _sqlite3Stat4ValueFromExpr(tls, pParse, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight, aff, bp) + nLower = 0 + } + if pUpper != 0 && rc == SQLITE_OK { + rc = _sqlite3Stat4ValueFromExpr(tls, pParse, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight, aff, bp+8) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v1 = 0 + } else { + v1 = (*TIndex)(unsafe.Pointer(p)).FnSample + } + nUpper = v1 + } + if **(**uintptr)(__ccgo_up(bp)) != 0 || **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + i = 0 + for { + if !(rc == SQLITE_OK && i < (*TIndex)(unsafe.Pointer(p)).FnSample) { + break + } + rc = _sqlite3Stat4Column(tls, db, (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(p)).FaSample + uintptr(i)*40))).Fp, (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(p)).FaSample + uintptr(i)*40))).Fn, nEq, bp+16) + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp)) != 0 { + res = _sqlite3MemCompare(tls, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 16)), pColl) + if res >= 0 { + nLower = nLower + 1 + } + } + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + res1 = _sqlite3MemCompare(tls, **(**uintptr)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp + 16)), pColl) + if res1 >= 0 { + nUpper = nUpper + 1 + } + } + goto _2 + _2: + ; + i = i + 1 + } + nDiff = nUpper - nLower + if nDiff <= 0 { + nDiff = int32(1) + } + /* If there is both an upper and lower bound specified, and the + ** comparisons indicate that they are close together, use the fallback + ** method (assume that the scan visits 1/64 of the rows) for estimating + ** the number of rows visited. Otherwise, estimate the number of rows + ** using the method described in the header comment for this function. */ + if nDiff != int32(1) || pUpper == uintptr(0) || pLower == uintptr(0) { + nAdjust = int32(_sqlite3LogEst(tls, libc.Uint64FromInt32((*TIndex)(unsafe.Pointer(p)).FnSample))) - int32(_sqlite3LogEst(tls, libc.Uint64FromInt32(nDiff))) + v3 = pLoop + 22 + *(*TLogEst)(unsafe.Pointer(v3)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v3))) - nAdjust) + **(**int32)(__ccgo_up(pbDone)) = int32(1) + } + } else { + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp + 8))) + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp + 16))) + return rc +} + +// C documentation +// +// /* +// ** Term pTerm is a vector range comparison operation. The first comparison +// ** in the vector can be optimized using column nEq of the index. This +// ** function returns the total number of vector elements that can be used +// ** as part of the range comparison. +// ** +// ** For example, if the query is: +// ** +// ** WHERE a = ? AND (b, c, d) > (?, ?, ?) +// ** +// ** and the index: +// ** +// ** CREATE INDEX ... ON (a, b, c, d, e) +// ** +// ** then this function would be invoked with nEq=1. The value returned in +// ** this case is 3. +// */ +func _whereRangeVectorLen(tls *libc.TLS, pParse uintptr, iCur int32, pIdx uintptr, nEq int32, pTerm uintptr) (r int32) { + var aff, idxaff uint8 + var i, nCmp, v1 int32 + var pColl, pLhs, pRhs, t uintptr + _, _, _, _, _, _, _, _, _ = aff, i, idxaff, nCmp, pColl, pLhs, pRhs, t, v1 + nCmp = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft) + if nCmp < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)-nEq { + v1 = nCmp + } else { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) - nEq + } + nCmp = v1 + i = int32(1) + for { + if !(i < nCmp) { + break + } /* Comparison affinity */ + idxaff = uint8(0) + pLhs = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft + 32)) + 8 + uintptr(i)*32))).FpExpr + pRhs = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight + if (*TExpr)(unsafe.Pointer(pRhs)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + pRhs = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRhs + 32)))).FpEList + 8 + uintptr(i)*32))).FpExpr + } else { + pRhs = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRhs + 32)) + 8 + uintptr(i)*32))).FpExpr + } + /* Check that the LHS of the comparison is a column reference to + ** the right column of the right source table. And that the sort + ** order of the index column is the same as the sort order of the + ** leftmost index column. */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLhs)).Fop) != int32(TK_COLUMN) || (*TExpr)(unsafe.Pointer(pLhs)).FiTable != iCur || int32((*TExpr)(unsafe.Pointer(pLhs)).FiColumn) != int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i+nEq)*2))) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i+nEq)))) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) { + break + } + aff = _sqlite3CompareAffinity(tls, pRhs, _sqlite3ExprAffinity(tls, pLhs)) + idxaff = _sqlite3TableColumnAffinity(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpTable, int32((*TExpr)(unsafe.Pointer(pLhs)).FiColumn)) + if libc.Int32FromUint8(aff) != libc.Int32FromUint8(idxaff) { + break + } + if (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0) { + t = pRhs + pRhs = pLhs + pLhs = t + } + pColl = _sqlite3BinaryCompareCollSeq(tls, pParse, pLhs, pRhs) + if pColl == uintptr(0) { + break + } + if _sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pColl)).FzName, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i+nEq)*8))) != 0 { + break + } + goto _2 + _2: + ; + i = i + 1 + } + return i +} + +/* +** Adjust the cost C by the costMult factor T. This only occurs if +** compiled with -DSQLITE_ENABLE_COSTMULT + */ + +// C documentation +// +// /* +// ** Initialize a WHERE clause scanner object. Return a pointer to the +// ** first match. Return NULL if there are no matches. +// ** +// ** The scanner will be searching the WHERE clause pWC. It will look +// ** for terms of the form "X " where X is column iColumn of table +// ** iCur. Or if pIdx!=0 then X is column iColumn of index pIdx. pIdx +// ** must be one of the indexes of table iCur. +// ** +// ** The must be one of the operators described by opMask. +// ** +// ** If the search is for X and the WHERE clause contains terms of the +// ** form X=Y then this routine might also return terms of the form +// ** "Y ". The number of levels of transitivity is limited, +// ** but is enough to handle most commonly occurring SQL statements. +// ** +// ** If X is not the INTEGER PRIMARY KEY then X must be compatible with +// ** index pIdx. +// */ +func _whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColumn int32, opMask Tu32, pIdx uintptr) (r uintptr) { + var j int32 + _ = j + (*TWhereScan)(unsafe.Pointer(pScan)).FpOrigWC = pWC + (*TWhereScan)(unsafe.Pointer(pScan)).FpWC = pWC + (*TWhereScan)(unsafe.Pointer(pScan)).FpIdxExpr = uintptr(0) + (*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff = uint8(0) + (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName = uintptr(0) + (*TWhereScan)(unsafe.Pointer(pScan)).FopMask = opMask + (*TWhereScan)(unsafe.Pointer(pScan)).Fk = 0 + **(**int32)(__ccgo_up(pScan + 44)) = iCur + (*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv = uint8(1) + (*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv = uint8(1) + if pIdx != 0 { + j = iColumn + iColumn = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) + if iColumn == int32((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FiPKey) { + iColumn = -int32(1) + } else { + if iColumn >= 0 { + (*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(iColumn)*16))).Faffinity + (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8)) + } else { + if iColumn == -int32(2) { + (*TWhereScan)(unsafe.Pointer(pScan)).FpIdxExpr = (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(j)*32))).FpExpr + (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8)) + **(**Ti16)(__ccgo_up(pScan + 88)) = int16(-libc.Int32FromInt32(2)) + return _whereScanInitIndexExpr(tls, pScan) + } + } + } + } else { + if iColumn == -int32(2) { + return uintptr(0) + } + } + **(**Ti16)(__ccgo_up(pScan + 88)) = int16(iColumn) + return _whereScanNext(tls, pScan) +} + +// C documentation +// +// /* +// ** Advance to the next WhereTerm that matches according to the criteria +// ** established when the pScan object was initialized by whereScanInit(). +// ** Return NULL if there are no more matching WhereTerms. +// */ +func _whereScanNext(tls *libc.TLS, pScan uintptr) (r uintptr) { + var iColumn Ti16 + var iCur, j, k int32 + var pColl, pParse, pTerm, pWC, pX, zCollName, v2 uintptr + var v3 bool + _, _, _, _, _, _, _, _, _, _, _, _ = iColumn, iCur, j, k, pColl, pParse, pTerm, pWC, pX, zCollName, v2, v3 /* The term being tested */ + k = (*TWhereScan)(unsafe.Pointer(pScan)).Fk /* Where to start scanning */ + pWC = (*TWhereScan)(unsafe.Pointer(pScan)).FpWC + for int32(1) != 0 { + iColumn = **(**Ti16)(__ccgo_up(pScan + 88 + uintptr(libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv)-int32(1))*2)) + iCur = **(**int32)(__ccgo_up(pScan + 44 + uintptr(libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv)-int32(1))*4)) + for cond := true; cond; cond = pWC != uintptr(0) { + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(k)*56 + for { + if !(k < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor == iCur && (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn == int32(iColumn) && (int32(iColumn) != -int32(2) || _sqlite3ExprCompareSkip(tls, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft, (*TWhereScan)(unsafe.Pointer(pScan)).FpIdxExpr, iCur) == 0) && (libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv) <= int32(1) || !((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0))) { + if v3 = libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_EQUIV) != 0 && libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv) < libc.Int32FromUint64(libc.Uint64FromInt64(44)/libc.Uint64FromInt64(4)); v3 { + v2 = _whereRightSubexprIsColumn(tls, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr) + pX = v2 + } + if v3 && v2 != uintptr(0) { + j = 0 + for { + if !(j < libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv)) { + break + } + if **(**int32)(__ccgo_up(pScan + 44 + uintptr(j)*4)) == (*TExpr)(unsafe.Pointer(pX)).FiTable && int32(**(**Ti16)(__ccgo_up(pScan + 88 + uintptr(j)*2))) == int32((*TExpr)(unsafe.Pointer(pX)).FiColumn) { + break + } + goto _4 + _4: + ; + j = j + 1 + } + if j == libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv) { + **(**int32)(__ccgo_up(pScan + 44 + uintptr(j)*4)) = (*TExpr)(unsafe.Pointer(pX)).FiTable + **(**Ti16)(__ccgo_up(pScan + 88 + uintptr(j)*2)) = (*TExpr)(unsafe.Pointer(pX)).FiColumn + (*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv = (*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv + 1 + } + } + if uint32((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(*TWhereScan)(unsafe.Pointer(pScan)).FopMask != uint32(0) { + /* Verify the affinity and collating sequence match */ + if (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName != 0 && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_ISNULL) == 0 { + pParse = (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_IN) != 0 { + zCollName = _indexInAffinityOk(tls, pParse, pTerm, (*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff) + if !(zCollName != 0) { + goto _1 + } + } else { + if !(_sqlite3IndexAffinityOk(tls, pX, (*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff) != 0) { + goto _1 + } + pColl = _sqlite3ExprCompareCollSeq(tls, pParse, pX) + if pColl != 0 { + v2 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v2 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + zCollName = v2 + } + if _sqlite3StrICmp(tls, zCollName, (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName) != 0 { + goto _1 + } + } + if v3 = libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) != 0; v3 { + pX = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight + } + if v3 && pX != libc.UintptrFromInt32(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pX)).FiTable == **(**int32)(__ccgo_up(pScan + 44)) && int32((*TExpr)(unsafe.Pointer(pX)).FiColumn) == int32(**(**Ti16)(__ccgo_up(pScan + 88))) { + goto _1 + } + (*TWhereScan)(unsafe.Pointer(pScan)).FpWC = pWC + (*TWhereScan)(unsafe.Pointer(pScan)).Fk = k + int32(1) + return pTerm + } + } + goto _1 + _1: + ; + k = k + 1 + pTerm += 56 + } + pWC = (*TWhereClause)(unsafe.Pointer(pWC)).FpOuter + k = 0 + } + if libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv) >= libc.Int32FromUint8((*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv) { + break + } + pWC = (*TWhereScan)(unsafe.Pointer(pScan)).FpOrigWC + k = 0 + (*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv = (*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv + 1 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Write the supplied super-journal name into the journal file for pager +// ** pPager at the current location. The super-journal name must be the last +// ** thing written to a journal file. If the pager is in full-sync mode, the +// ** journal file descriptor is advanced to the next sector boundary before +// ** anything is written. The format is: +// ** +// ** + 4 bytes: PAGER_SJ_PGNO. +// ** + N bytes: super-journal filename in utf-8. +// ** + 4 bytes: N (length of super-journal name in bytes, no nul-terminator). +// ** + 4 bytes: super-journal name checksum. +// ** + 8 bytes: aJournalMagic[]. +// ** +// ** The super-journal page checksum is the sum of the bytes in the super-journal +// ** name, where each byte is interpreted as a signed 8-bit integer. +// ** +// ** If zSuper is a NULL pointer (occurs for a single database transaction), +// ** this call is a no-op. +// */ +func _writeSuperJournal(tls *libc.TLS, pPager uintptr, zSuper uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var cksum Tu32 + var iHdrOff Ti64 + var nSuper, rc, v2, v3, v5, v7, v9 int32 + var v10, v4, v6, v8 bool + var _ /* jrnlSize at bp+0 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = cksum, iHdrOff, nSuper, rc, v10, v2, v3, v4, v5, v6, v7, v8, v9 /* Size of journal file on disk */ + cksum = uint32(0) /* Checksum of string zSuper */ + if !(zSuper != 0) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_MEMORY) || !((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != libc.UintptrFromInt32(0)) { + return SQLITE_OK + } + (*TPager)(unsafe.Pointer(pPager)).FsetSuper = uint8(1) + /* Calculate the length in bytes and the checksum of zSuper */ + nSuper = 0 + for { + if !(**(**uint8)(__ccgo_up(zSuper + uintptr(nSuper))) != 0) { + break + } + cksum = cksum + uint32(**(**uint8)(__ccgo_up(zSuper + uintptr(nSuper)))) + goto _1 + _1: + ; + nSuper = nSuper + 1 + } + /* If in full-sync mode, advance to the next disk sector before writing + ** the super-journal name. This is in case the previous page written to + ** the journal has already been synced. + */ + if (*TPager)(unsafe.Pointer(pPager)).FfullSync != 0 { + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = _journalHdrOffset(tls, pPager) + } + iHdrOff = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + /* Write the super-journal data to the end of the journal file. If + ** an error occurs, return the error code to the caller. + */ + v2 = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff, (*TPager)(unsafe.Pointer(pPager)).FlckPgno) + rc = v2 + if v4 = 0 != v2; !v4 { + v3 = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, zSuper, nSuper, iHdrOff+int64(4)) + rc = v3 + } + if v6 = v4 || 0 != v3; !v6 { + v5 = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(4)+int64(nSuper), libc.Uint32FromInt32(nSuper)) + rc = v5 + } + if v8 = v6 || 0 != v5; !v8 { + v7 = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(4)+int64(nSuper)+int64(4), cksum) + rc = v7 + } + if v10 = v8 || 0 != v7; !v10 { + v9 = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&_aJournalMagic)), int32(8), iHdrOff+int64(4)+int64(nSuper)+int64(8)) + rc = v9 + } + if v10 || 0 != v9 { + return rc + } + **(**Ti64)(__ccgo_up(pPager + 96)) += int64(nSuper + libc.Int32FromInt32(20)) + /* If the pager is in persistent-journal mode, then the physical + ** journal-file may extend past the end of the super-journal name + ** and 8 bytes of magic data just written to the file. This is + ** dangerous because the code to rollback a hot-journal file + ** will not be able to find the super-journal name to determine + ** whether or not the journal is hot. + ** + ** Easiest thing to do in this scenario is to truncate the journal + ** file to the required size. + */ + v2 = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp) + rc = v2 + if SQLITE_OK == v2 && **(**Ti64)(__ccgo_up(bp)) > (*TPager)(unsafe.Pointer(pPager)).FjournalOff { + rc = _sqlite3OsTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, (*TPager)(unsafe.Pointer(pPager)).FjournalOff) + } + return rc +} + +// C documentation +// +// /* +// ** Attempt the transfer optimization on INSERTs of the form +// ** +// ** INSERT INTO tab1 SELECT * FROM tab2; +// ** +// ** The xfer optimization transfers raw records from tab2 over to tab1. +// ** Columns are not decoded and reassembled, which greatly improves +// ** performance. Raw index records are transferred in the same way. +// ** +// ** The xfer optimization is only attempted if tab1 and tab2 are compatible. +// ** There are lots of rules for determining compatibility - see comments +// ** embedded in the code for details. +// ** +// ** This routine returns TRUE if the optimization is guaranteed to be used. +// ** Sometimes the xfer optimization will only work if the destination table +// ** is empty - a factor that can only be determined at run-time. In that +// ** case, this routine generates code for the xfer optimization but also +// ** does a test to see if the destination table is empty and jumps over the +// ** xfer optimization code if the test fails. In that case, this routine +// ** returns FALSE so that the caller will know to go ahead and generate +// ** an unoptimized transfer. This routine also returns FALSE if there +// ** is no chance that the xfer optimization can be applied. +// ** +// ** This optimization is particularly useful at making VACUUM run faster. +// */ +func _xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uintptr, onError int32, iDbDest int32) (r int32) { + var addr1, addr2, destHasUniqueIdx, emptyDestTest, emptySrcTest, i, iDbSrc, iDest, iSrc, regAutoinc, regData, regRowid, v4 int32 + var db, pDestCol, pDestExpr, pDestIdx, pEList, pItem, pSrc, pSrcCol, pSrcExpr, pSrcIdx, v, zColl, v5 uintptr + var idxInsFlags, insFlags Tu8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, addr2, db, destHasUniqueIdx, emptyDestTest, emptySrcTest, i, iDbSrc, iDest, iSrc, idxInsFlags, insFlags, pDestCol, pDestExpr, pDestIdx, pEList, pItem, pSrc, pSrcCol, pSrcExpr, pSrcIdx, regAutoinc, regData, regRowid, v, zColl, v4, v5 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Loop addresses */ + emptyDestTest = 0 /* Address of test for empty pDest */ + emptySrcTest = 0 /* Memory register used by AUTOINC */ + destHasUniqueIdx = 0 /* Registers holding data and rowid */ + if (*TParse)(unsafe.Pointer(pParse)).FpWith != 0 || (*TSelect)(unsafe.Pointer(pSelect)).FpWith != 0 { + /* Do not attempt to process this query if there are an WITH clauses + ** attached to it. Proceeding may generate a false "no such table: xxx" + ** error if pSelect reads from a CTE named "xxx". */ + return 0 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pDest)).FeTabType) == int32(TABTYP_VTAB) { + return 0 /* tab1 must not be a virtual table */ + } + if onError == int32(OE_Default) { + if int32((*TTable)(unsafe.Pointer(pDest)).FiPKey) >= 0 { + onError = libc.Int32FromUint8((*TTable)(unsafe.Pointer(pDest)).FkeyConf) + } + if onError == int32(OE_Default) { + onError = int32(OE_Abort) + } + } + /* allocated even if there is no FROM clause */ + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc != int32(1) { + return 0 /* FROM clause must have exactly one term */ + } + if int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + 24 + 4))&0x4>>2) != 0 { + return 0 /* FROM clause cannot contain a subquery */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpWhere != 0 { + return 0 /* SELECT may not have a WHERE clause */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpOrderBy != 0 { + return 0 /* SELECT may not have an ORDER BY clause */ + } + /* Do not need to test for a HAVING clause. If HAVING is present but + ** there is no ORDER BY, we will get an error. */ + if (*TSelect)(unsafe.Pointer(pSelect)).FpGroupBy != 0 { + return 0 /* SELECT may not have a GROUP BY clause */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpLimit != 0 { + return 0 /* SELECT may not have a LIMIT clause */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + return 0 /* SELECT may not be a compound query */ + } + if (*TSelect)(unsafe.Pointer(pSelect)).FselFlags&uint32(SF_Distinct) != 0 { + return 0 /* SELECT may not be DISTINCT */ + } + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + if (*TExprList)(unsafe.Pointer(pEList)).FnExpr != int32(1) { + return 0 /* The result set must have exactly one column */ + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList + 8))).FpExpr)).Fop) != int32(TK_ASTERISK) { + return 0 /* The result set must be the special operator "*" */ + } + /* At this point we have established that the statement is of the + ** correct syntactic form to participate in this optimization. Now + ** we have to check the semantics. + */ + pItem = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + pSrc = _sqlite3LocateTableItem(tls, pParse, uint32(0), pItem) + if pSrc == uintptr(0) { + return 0 /* FROM clause does not contain a real table */ + } + if (*TTable)(unsafe.Pointer(pSrc)).Ftnum == (*TTable)(unsafe.Pointer(pDest)).Ftnum && (*TTable)(unsafe.Pointer(pSrc)).FpSchema == (*TTable)(unsafe.Pointer(pDest)).FpSchema { + /* Possible due to bad sqlite_schema.rootpage */ + return 0 /* tab1 and tab2 may not be the same table */ + } + if libc.BoolInt32((*TTable)(unsafe.Pointer(pDest)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0)) != libc.BoolInt32((*TTable)(unsafe.Pointer(pSrc)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0)) { + return 0 /* source and destination must both be WITHOUT ROWID or not */ + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pSrc)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + return 0 /* tab2 may not be a view or virtual table */ + } + if int32((*TTable)(unsafe.Pointer(pDest)).FnCol) != int32((*TTable)(unsafe.Pointer(pSrc)).FnCol) { + return 0 /* Number of columns must be the same in tab1 and tab2 */ + } + if int32((*TTable)(unsafe.Pointer(pDest)).FiPKey) != int32((*TTable)(unsafe.Pointer(pSrc)).FiPKey) { + return 0 /* Both tables must have the same INTEGER PRIMARY KEY */ + } + if (*TTable)(unsafe.Pointer(pDest)).FtabFlags&uint32(TF_Strict) != uint32(0) && (*TTable)(unsafe.Pointer(pSrc)).FtabFlags&uint32(TF_Strict) == uint32(0) { + return 0 /* Cannot feed from a non-strict into a strict table */ + } + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pDest)).FnCol)) { + break + } + pDestCol = (*TTable)(unsafe.Pointer(pDest)).FaCol + uintptr(i)*16 + pSrcCol = (*TTable)(unsafe.Pointer(pSrc)).FaCol + uintptr(i)*16 + /* Even if tables t1 and t2 have identical schemas, if they contain + ** generated columns, then this statement is semantically incorrect: + ** + ** INSERT INTO t2 SELECT * FROM t1; + ** + ** The reason is that generated column values are returned by the + ** the SELECT statement on the right but the INSERT statement on the + ** left wants them to be omitted. + ** + ** Nevertheless, this is a useful notational shorthand to tell SQLite + ** to do a bulk transfer all of the content from t1 over to t2. + ** + ** We could, in theory, disable this (except for internal use by the + ** VACUUM command where it is actually needed). But why do that? It + ** seems harmless enough, and provides a useful service. + */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pDestCol)).FcolFlags)&int32(COLFLAG_GENERATED) != libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pSrcCol)).FcolFlags)&int32(COLFLAG_GENERATED) { + return 0 /* Both columns have the same generated-column type */ + } + /* But the transfer is only allowed if both the source and destination + ** tables have the exact same expressions for generated columns. + ** This requirement could be relaxed for VIRTUAL columns, I suppose. + */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pDestCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + if _sqlite3ExprCompare(tls, uintptr(0), _sqlite3ColumnExpr(tls, pSrc, pSrcCol), _sqlite3ColumnExpr(tls, pDest, pDestCol), -int32(1)) != 0 { + return 0 /* Different generator expressions */ + } + } + if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pDestCol)).Faffinity) != libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pSrcCol)).Faffinity) { + return 0 /* Affinity must be the same on all columns */ + } + if Xsqlite3_stricmp(tls, _sqlite3ColumnColl(tls, pDestCol), _sqlite3ColumnColl(tls, pSrcCol)) != 0 { + return 0 /* Collating sequence must be the same on all columns */ + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pDestCol + 8))&0xf>>0)) != 0 && !(int32(uint32(*(*uint8)(unsafe.Pointer(pSrcCol + 8))&0xf>>0)) != 0) { + return 0 /* tab2 must be NOT NULL if tab1 is */ + } + /* Default values for second and subsequent columns need to match. */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pDestCol)).FcolFlags)&int32(COLFLAG_GENERATED) == 0 && i > 0 { + pDestExpr = _sqlite3ColumnExpr(tls, pDest, pDestCol) + pSrcExpr = _sqlite3ColumnExpr(tls, pSrc, pSrcCol) + if libc.BoolInt32(pDestExpr == uintptr(0)) != libc.BoolInt32(pSrcExpr == uintptr(0)) || pDestExpr != uintptr(0) && libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(pDestExpr + 8)), *(*uintptr)(unsafe.Pointer(pSrcExpr + 8))) != 0 { + return 0 /* Default values must be the same for all columns */ + } + } + goto _1 + _1: + ; + i = i + 1 + } + pDestIdx = (*TTable)(unsafe.Pointer(pDest)).FpIndex + for { + if !(pDestIdx != 0) { + break + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pDestIdx)).FonError) != OE_None { + destHasUniqueIdx = int32(1) + } + pSrcIdx = (*TTable)(unsafe.Pointer(pSrc)).FpIndex + for { + if !(pSrcIdx != 0) { + break + } + if _xferCompatibleIndex(tls, pDestIdx, pSrcIdx) != 0 { + break + } + goto _3 + _3: + ; + pSrcIdx = (*TIndex)(unsafe.Pointer(pSrcIdx)).FpNext + } + if pSrcIdx == uintptr(0) { + return 0 /* pDestIdx has no corresponding index in pSrc */ + } + if (*TIndex)(unsafe.Pointer(pSrcIdx)).Ftnum == (*TIndex)(unsafe.Pointer(pDestIdx)).Ftnum && (*TTable)(unsafe.Pointer(pSrc)).FpSchema == (*TTable)(unsafe.Pointer(pDest)).FpSchema && _sqlite3FaultSim(tls, int32(411)) == SQLITE_OK { + /* The sqlite3FaultSim() call allows this corruption test to be + ** bypassed during testing, in order to exercise other corruption tests + ** further downstream. */ + return 0 /* Corrupt schema - two indexes on the same btree */ + } + goto _2 + _2: + ; + pDestIdx = (*TIndex)(unsafe.Pointer(pDestIdx)).FpNext + } + if (*TTable)(unsafe.Pointer(pDest)).FpCheck != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) && _sqlite3ExprListCompare(tls, (*TTable)(unsafe.Pointer(pSrc)).FpCheck, (*TTable)(unsafe.Pointer(pDest)).FpCheck, -int32(1)) != 0 { + return 0 /* Tables have different CHECK constraints. Ticket #2252 */ + } + /* Disallow the transfer optimization if the destination table contains + ** any foreign key constraints. This is more restrictive than necessary. + ** But the main beneficiary of the transfer optimization is the VACUUM + ** command, and the VACUUM command disables foreign key constraints. So + ** the extra complication to make this rule less restrictive is probably + ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != uint64(0) && (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pDest + 64))).FpFKey != uintptr(0) { + return 0 + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00001))<= 0 { + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iSrc, regRowid) + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) { + addr2 = _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iDest, 0, regRowid) + _sqlite3RowidConstraint(tls, pParse, onError, pDest) + _sqlite3VdbeJumpHere(tls, v, addr2) + } + _autoIncStep(tls, pParse, regAutoinc, regRowid) + } else { + if (*TTable)(unsafe.Pointer(pDest)).FpIndex == uintptr(0) && !((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&libc.Uint32FromInt32(DBFLAG_VacuumInto) != 0) { + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iDest, regRowid) + } else { + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iSrc, regRowid) + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_SeekEnd), iDest) + insFlags = libc.Uint8FromInt32(libc.Int32FromInt32(OPFLAG_APPEND) | libc.Int32FromInt32(OPFLAG_USESEEKRESULT) | libc.Int32FromInt32(OPFLAG_PREFORMAT)) + } else { + insFlags = libc.Uint8FromInt32(libc.Int32FromInt32(OPFLAG_NCHANGE) | libc.Int32FromInt32(OPFLAG_LASTROWID) | libc.Int32FromInt32(OPFLAG_APPEND) | libc.Int32FromInt32(OPFLAG_PREFORMAT)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_RowData), iSrc, regData, int32(1)) + insFlags = libc.Uint8FromInt32(int32(insFlags) & ^libc.Int32FromInt32(OPFLAG_PREFORMAT)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_RowCell), iDest, iSrc, regRowid) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iDest, regData, regRowid) + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) { + _sqlite3VdbeChangeP4(tls, v, -int32(1), pDest, -int32(5)) + } + _sqlite3VdbeChangeP5(tls, v, uint16(insFlags)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iSrc, addr1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iSrc, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iDest, 0) + } else { + _sqlite3TableLock(tls, pParse, iDbDest, (*TTable)(unsafe.Pointer(pDest)).Ftnum, uint8(1), (*TTable)(unsafe.Pointer(pDest)).FzName) + _sqlite3TableLock(tls, pParse, iDbSrc, (*TTable)(unsafe.Pointer(pSrc)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pSrc)).FzName) + } + pDestIdx = (*TTable)(unsafe.Pointer(pDest)).FpIndex + for { + if !(pDestIdx != 0) { + break + } + idxInsFlags = uint8(0) + pSrcIdx = (*TTable)(unsafe.Pointer(pSrc)).FpIndex + for { + if !(pSrcIdx != 0) { + break + } + if _xferCompatibleIndex(tls, pDestIdx, pSrcIdx) != 0 { + break + } + goto _9 + _9: + ; + pSrcIdx = (*TIndex)(unsafe.Pointer(pSrcIdx)).FpNext + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), iSrc, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pSrcIdx)).Ftnum), iDbSrc) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pSrcIdx) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenWrite), iDest, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pDestIdx)).Ftnum), iDbDest) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pDestIdx) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_BULKCSR)) + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iSrc, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) != 0 { + /* This INSERT command is part of a VACUUM operation, which guarantees + ** that the destination table is empty. If all indexed columns use + ** collation sequence BINARY, then it can also be assumed that the + ** index will be populated by inserting keys in strictly sorted + ** order. In this case, instead of seeking within the b-tree as part + ** of every OP_IdxInsert opcode, an OP_SeekEnd is added before the + ** OP_IdxInsert to seek to the point within the b-tree where each key + ** should be inserted. This is faster. + ** + ** If any of the indexed columns use a collation sequence other than + ** BINARY, this optimization is disabled. This is because the user + ** might change the definition of a collation sequence and then run + ** a VACUUM command. In that case keys may not be written in strictly + ** sorted order. */ + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pSrcIdx)).FnColumn)) { + break + } + zColl = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pSrcIdx)).FazColl + uintptr(i)*8)) + if Xsqlite3_stricmp(tls, uintptr(unsafe.Pointer(&_sqlite3StrBINARY)), zColl) != 0 { + break + } + goto _10 + _10: + ; + i = i + 1 + } + if i == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pSrcIdx)).FnColumn) { + idxInsFlags = libc.Uint8FromInt32(libc.Int32FromInt32(OPFLAG_USESEEKRESULT) | libc.Int32FromInt32(OPFLAG_PREFORMAT)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_SeekEnd), iDest) + _sqlite3VdbeAddOp2(tls, v, int32(OP_RowCell), iDest, iSrc) + } + } else { + if !((*TTable)(unsafe.Pointer(pSrc)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pDestIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + idxInsFlags = libc.Uint8FromInt32(int32(idxInsFlags) | libc.Int32FromInt32(OPFLAG_NCHANGE)) + } + } + if libc.Int32FromUint8(idxInsFlags) != libc.Int32FromInt32(OPFLAG_USESEEKRESULT)|libc.Int32FromInt32(OPFLAG_PREFORMAT) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_RowData), iSrc, regData, int32(1)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) && !((*TTable)(unsafe.Pointer(pDest)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pDestIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + _codeWithoutRowidPreupdate(tls, pParse, pDest, iDest, regData) + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), iDest, regData) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(libc.Int32FromUint8(idxInsFlags)|int32(OPFLAG_APPEND))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iSrc, addr1+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iSrc, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iDest, 0) + goto _8 + _8: + ; + pDestIdx = (*TIndex)(unsafe.Pointer(pDestIdx)).FpNext + } + if emptySrcTest != 0 { + _sqlite3VdbeJumpHere(tls, v, emptySrcTest) + } + _sqlite3ReleaseTempReg(tls, pParse, regRowid) + _sqlite3ReleaseTempReg(tls, pParse, regData) + if emptyDestTest != 0 { + _sqlite3AutoincrementEnd(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), SQLITE_OK, 0) + _sqlite3VdbeJumpHere(tls, v, emptyDestTest) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), iDest, 0) + return 0 + } else { + return int32(1) + } + return r +} + +// C documentation +// +// /* +// ** Set up a raw page so that it looks like a database page holding +// ** no entries. +// */ +func _zeroPage(tls *libc.TLS, pPage uintptr, flags int32) { + var data, pBt uintptr + var first, hdr, v1 int32 + _, _, _, _, _ = data, first, hdr, pBt, v1 + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_FAST_SECURE) != 0 { + libc.Xmemset(tls, data+uintptr(hdr), 0, uint64((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-libc.Uint32FromInt32(hdr))) + } + **(**uint8)(__ccgo_up(data + uintptr(hdr))) = uint8(libc.Uint8FromInt32(flags)) + if flags&int32(PTF_LEAF) == 0 { + v1 = int32(12) + } else { + v1 = int32(8) + } + first = hdr + v1 + libc.Xmemset(tls, data+uintptr(hdr+int32(1)), 0, uint64(4)) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7)))) = uint8(0) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)))) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FusableSize >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)) + 1)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FusableSize) + (*TMemPage)(unsafe.Pointer(pPage)).FnFree = libc.Int32FromUint16(uint16((*TBtShared)(unsafe.Pointer(pBt)).FusableSize - libc.Uint32FromInt32(first))) + _decodeFlags(tls, pPage, flags) + (*TMemPage)(unsafe.Pointer(pPage)).FcellOffset = libc.Uint16FromInt32(first) + (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd = data + uintptr((*TBtShared)(unsafe.Pointer(pBt)).FpageSize) + (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx = data + uintptr(first) + (*TMemPage)(unsafe.Pointer(pPage)).FaDataOfst = data + uintptr((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FmaskPage = uint16((*TBtShared)(unsafe.Pointer(pBt)).FpageSize - libc.Uint32FromInt32(1)) + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = uint16(0) + (*TMemPage)(unsafe.Pointer(pPage)).FisInit = uint8(1) +} diff --git a/internal/engine/lib/sqlite_g_0000000000013b10.go b/internal/engine/lib/sqlite_g_0000000000013b10.go new file mode 100644 index 0000000..89a5320 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000013b10.go @@ -0,0 +1,253 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && arm) || (linux && arm) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** If the DateTime p is raw number, try to figure out if it is +// ** a julian day number of a unix timestamp. Set the p value +// ** appropriately. +// */ +func _autoAdjustDate(tls *libc.TLS, p uintptr) { + var r float64 + _ = r + if !(int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0) || (*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0 { + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + } else { + if (*TDateTime)(unsafe.Pointer(p)).Fs >= float64(int64(-libc.Int32FromInt32(21086676))*libc.Int64FromInt32(10000)) && (*TDateTime)(unsafe.Pointer(p)).Fs <= float64(libc.Int64FromInt32(25340230)*libc.Int64FromInt32(10000)+libc.Int64FromInt32(799)) { + r = float64((*TDateTime)(unsafe.Pointer(p)).Fs*float64(1000)) + float64(2.1086676e+14) + _clearYMD_HMS_TZ(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(r + libc.Float64FromFloat64(0.5)) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + } + } +} + +// C documentation +// +// /* +// ** Convert from YYYY-MM-DD HH:MM:SS to julian day. We always assume +// ** that the YYYY-MM-DD is according to the Gregorian calendar. +// ** +// ** Reference: Meeus page 61 +// */ +func _computeJD(tls *libc.TLS, p uintptr) { + var A, B, D, M, X1, X2, Y int32 + _, _, _, _, _, _, _ = A, B, D, M, X1, X2, Y + if (*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0 { + return + } + if (*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0 { + Y = (*TDateTime)(unsafe.Pointer(p)).FY + M = (*TDateTime)(unsafe.Pointer(p)).FM + D = (*TDateTime)(unsafe.Pointer(p)).FD + } else { + Y = int32(2000) /* If no YMD specified, assume 2000-Jan-01 */ + M = int32(1) + D = int32(1) + } + if Y < -int32(4713) || Y > int32(9999) || int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { + _datetimeError(tls, p) + return + } + if M <= int32(2) { + Y = Y - 1 + M = M + int32(12) + } + A = (Y + int32(4800)) / int32(100) + B = int32(38) - A + A/int32(4) + X1 = int32(36525) * (Y + int32(4716)) / int32(100) + X2 = int32(306001) * (M + int32(1)) / int32(10000) + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(float64((float64(X1+X2+D+B) - libc.Float64FromFloat64(1524.5)) * libc.Float64FromInt32(86400000))) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1) + if (*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0 { + **(**Tsqlite3_int64)(__ccgo_up(p)) += int64((*TDateTime)(unsafe.Pointer(p)).Fh*int32(3600000)+(*TDateTime)(unsafe.Pointer(p)).Fm*int32(60000)) + int64(float64((*TDateTime)(unsafe.Pointer(p)).Fs*libc.Float64FromInt32(1000))+libc.Float64FromFloat64(0.5)) + if (*TDateTime)(unsafe.Pointer(p)).Ftz != 0 { + **(**Tsqlite3_int64)(__ccgo_up(p)) -= int64((*TDateTime)(unsafe.Pointer(p)).Ftz * int32(60000)) + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(0) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(0) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + } + } +} + +// C documentation +// +// /* +// ** Compute the Year, Month, and Day from the julian day number. +// */ +func _computeYMD(tls *libc.TLS, p uintptr) { + var A, B, C, D, E, X1, Z, alpha, v1 int32 + _, _, _, _, _, _, _, _, _ = A, B, C, D, E, X1, Z, alpha, v1 + if (*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0 { + return + } + if !((*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0) { + (*TDateTime)(unsafe.Pointer(p)).FY = int32(2000) + (*TDateTime)(unsafe.Pointer(p)).FM = int32(1) + (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) + } else { + if !(_validJulianDay(tls, (*TDateTime)(unsafe.Pointer(p)).FiJD) != 0) { + _datetimeError(tls, p) + return + } else { + Z = int32(((*TDateTime)(unsafe.Pointer(p)).FiJD + libc.Int64FromInt32(43200000)) / libc.Int64FromInt32(86400000)) + alpha = int32((float64(Z)+libc.Float64FromFloat64(32044.75))/libc.Float64FromFloat64(36524.25)) - int32(52) + A = Z + int32(1) + alpha - (alpha+int32(100))/int32(4) + int32(25) + B = A + int32(1524) + C = int32((float64(B) - libc.Float64FromFloat64(122.1)) / libc.Float64FromFloat64(365.25)) + D = int32(36525) * (C & int32(32767)) / int32(100) + E = int32(float64(B-D) / libc.Float64FromFloat64(30.6001)) + X1 = int32(float64(libc.Float64FromFloat64(30.6001) * float64(E))) + (*TDateTime)(unsafe.Pointer(p)).FD = B - D - X1 + if E < int32(14) { + v1 = E - int32(1) + } else { + v1 = E - int32(13) + } + (*TDateTime)(unsafe.Pointer(p)).FM = v1 + if (*TDateTime)(unsafe.Pointer(p)).FM > int32(2) { + v1 = C - int32(4716) + } else { + v1 = C - int32(4715) + } + (*TDateTime)(unsafe.Pointer(p)).FY = v1 + } + } + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(1) +} + +// C documentation +// +// /* +// ** datetime( TIMESTRING, MOD, MOD, ...) +// ** +// ** Return YYYY-MM-DD HH:MM:SS +// */ +func _datetimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var Y, n, s int32 + var _ /* x at bp+0 */ TDateTime + var _ /* zBuf at bp+48 */ [32]uint8 + _, _, _ = Y, n, s + if _isDate(tls, context, argc, argv, bp) == 0 { + _computeYMD_HMS(tls, bp) + Y = (**(**TDateTime)(__ccgo_up(bp))).FY + if Y < 0 { + Y = -Y + } + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(1)] = libc.Uint8FromInt32(int32('0') + Y/int32(1000)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(2)] = libc.Uint8FromInt32(int32('0') + Y/int32(100)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(3)] = libc.Uint8FromInt32(int32('0') + Y/int32(10)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(4)] = libc.Uint8FromInt32(int32('0') + Y%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(5)] = uint8('-') + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(6)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FM/int32(10)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(7)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FM%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(8)] = uint8('-') + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(9)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FD/int32(10)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(10)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FD%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(11)] = uint8(' ') + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(12)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fh/int32(10)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(13)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fh%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(14)] = uint8(':') + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(15)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fm/int32(10)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(16)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fm%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(17)] = uint8(':') + if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { + s = int32(float64(libc.Float64FromFloat64(1000)*(**(**TDateTime)(__ccgo_up(bp))).Fs) + libc.Float64FromFloat64(0.5)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(18)] = libc.Uint8FromInt32(int32('0') + s/int32(10000)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(19)] = libc.Uint8FromInt32(int32('0') + s/int32(1000)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(20)] = uint8('.') + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(21)] = libc.Uint8FromInt32(int32('0') + s/int32(100)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(22)] = libc.Uint8FromInt32(int32('0') + s/int32(10)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(23)] = libc.Uint8FromInt32(int32('0') + s%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(24)] = uint8(0) + n = int32(24) + } else { + s = int32((**(**TDateTime)(__ccgo_up(bp))).Fs) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(18)] = libc.Uint8FromInt32(int32('0') + s/int32(10)%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(19)] = libc.Uint8FromInt32(int32('0') + s%int32(10)) + (**(**[32]uint8)(__ccgo_up(bp + 48)))[int32(20)] = uint8(0) + n = int32(20) + } + if (**(**TDateTime)(__ccgo_up(bp))).FY < 0 { + (**(**[32]uint8)(__ccgo_up(bp + 48)))[0] = uint8('-') + Xsqlite3_result_text(tls, context, bp+48, n, uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_text(tls, context, bp+48+1, n-int32(1), uintptr(-libc.Int32FromInt32(1))) + } + } +} + +// C documentation +// +// /* +// ** Input "r" is a numeric quantity which might be a julian day number, +// ** or the number of seconds since 1970. If the value if r is within +// ** range of a julian day number, install it as such and set validJD. +// ** If the value is a valid unix timestamp, put it in p->s and set p->rawS. +// */ +func _setRawDateNumber(tls *libc.TLS, p uintptr, r float64) { + (*TDateTime)(unsafe.Pointer(p)).Fs = r + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 0, 0x1) + if r >= float64(0) && r < float64(5.3734845e+06) { + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(float64(r*libc.Float64FromFloat64(8.64e+07)) + libc.Float64FromFloat64(0.5)) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1) + } +} + +// C documentation +// +// /* +// ** time( TIMESTRING, MOD, MOD, ...) +// ** +// ** Return HH:MM:SS +// */ +func _timeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var n, s int32 + var _ /* x at bp+0 */ TDateTime + var _ /* zBuf at bp+48 */ [16]uint8 + _, _ = n, s + if _isDate(tls, context, argc, argv, bp) == 0 { + _computeHMS(tls, bp) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[0] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fh/int32(10)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(1)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fh%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(2)] = uint8(':') + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(3)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fm/int32(10)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(4)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fm%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(5)] = uint8(':') + if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { + s = int32(float64(libc.Float64FromFloat64(1000)*(**(**TDateTime)(__ccgo_up(bp))).Fs) + libc.Float64FromFloat64(0.5)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(6)] = libc.Uint8FromInt32(int32('0') + s/int32(10000)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(7)] = libc.Uint8FromInt32(int32('0') + s/int32(1000)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(8)] = uint8('.') + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(9)] = libc.Uint8FromInt32(int32('0') + s/int32(100)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(10)] = libc.Uint8FromInt32(int32('0') + s/int32(10)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(11)] = libc.Uint8FromInt32(int32('0') + s%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(12)] = uint8(0) + n = int32(12) + } else { + s = int32((**(**TDateTime)(__ccgo_up(bp))).Fs) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(6)] = libc.Uint8FromInt32(int32('0') + s/int32(10)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(7)] = libc.Uint8FromInt32(int32('0') + s%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(8)] = uint8(0) + n = int32(8) + } + Xsqlite3_result_text(tls, context, bp+48, n, uintptr(-libc.Int32FromInt32(1))) + } +} diff --git a/internal/engine/lib/sqlite_g_0000000000013b30.go b/internal/engine/lib/sqlite_g_0000000000013b30.go new file mode 100644 index 0000000..2131c68 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000013b30.go @@ -0,0 +1,5143 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && arm) || (freebsd && arm64) || (linux && arm) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* The DblquoteStr object holds the text of a double-quoted +// ** string for a prepared statement. A linked list of these objects +// ** is constructed during statement parsing and is held on Vdbe.pDblStr. +// ** When computing a normalized SQL statement for an SQL statement, that +// ** list is consulted for each double-quoted identifier to see if the +// ** identifier should really be a string literal. +// */ +type TDblquoteStr = struct { + FpNextStr uintptr + Fz [8]uint8 +} + +type TFpDecode = struct { + Fn int32 + FiDP int32 + Fz uintptr + FzBuf [21]uint8 + Fsign uint8 + FisSpecial uint8 +} + +// C documentation +// +// /* +// ** Extra floating-point literals to allow in JSON. +// */ +type TNanInfName = struct { + Fc1 uint8 + Fc2 uint8 + Fn uint8 + FeType uint8 + FnRepl uint8 + FzMatch uintptr + FzRepl uintptr +} + +type TPorterTokenizer = struct { + Ftokenizer_v2 Tfts5_tokenizer_v2 + FpTokenizer uintptr + FaBuf [128]uint8 +} + +type TReturning = struct { + FpParse uintptr + FpReturnEL uintptr + FretTrig TTrigger + FretTStep TTriggerStep + FiRetCur int32 + FnRetCol int32 + FiRetReg int32 + FzName [40]uint8 +} + +type TWhereScan = struct { + FpOrigWC uintptr + FpWC uintptr + FzCollName uintptr + FpIdxExpr uintptr + Fk int32 + FopMask Tu32 + Fidxaff uint8 + FiEquiv uint8 + FnEquiv uint8 + FaiCur [11]int32 + FaiColumn [11]Ti16 +} + +// C documentation +// +// /* +// ** Each builtin conversion character (ex: the 'd' in "%d") is described +// ** by an instance of the following structure +// */ +type Tet_info = struct { + Ffmttype uint8 + Fbase TetByte + Fflags TetByte + Ftype1 TetByte + Fcharset TetByte + Fprefix TetByte + FiNxt uint8 +} + +func Xsqlite3_filename_journal(tls *libc.TLS, zFilename uintptr) (r uintptr) { + if zFilename == uintptr(0) { + return uintptr(0) + } + zFilename = _databaseName(tls, zFilename) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + for zFilename != 0 && **(**uint8)(__ccgo_up(zFilename)) != 0 { + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + } + return zFilename + uintptr(1) +} + +func Xsqlite3_snprintf(tls *libc.TLS, n int32, zBuf uintptr, zFormat uintptr, va uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ap Tva_list + var _ /* acc at bp+0 */ TStrAccum + _ = ap + if n <= 0 { + return zBuf + } + _sqlite3StrAccumInit(tls, bp, uintptr(0), zBuf, n, 0) + ap = va + Xsqlite3_str_vappendf(tls, bp, zFormat, ap) + _ = ap + **(**uint8)(__ccgo_up(zBuf + uintptr((**(**TStrAccum)(__ccgo_up(bp))).FnChar))) = uint8(0) + return zBuf +} + +/* Maximum size of an sqlite3_log() message. */ + +// C documentation +// +// /* Truncate the text of the string to be no more than N bytes. */ +func Xsqlite3_str_truncate(tls *libc.TLS, p uintptr, N int32) { + if p != uintptr(0) && N >= 0 && libc.Uint32FromInt32(N) < (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar { + (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar = libc.Uint32FromInt32(N) + **(**uint8)(__ccgo_up((*Tsqlite3_str)(unsafe.Pointer(p)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(p)).FnChar))) = uint8(0) + } +} + +// C documentation +// +// /* Return the current value for p */ +func Xsqlite3_str_value(tls *libc.TLS, p uintptr) (r uintptr) { + if p == uintptr(0) || (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar == uint32(0) { + return uintptr(0) + } + **(**uint8)(__ccgo_up((*Tsqlite3_str)(unsafe.Pointer(p)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(p)).FnChar))) = uint8(0) + return (*Tsqlite3_str)(unsafe.Pointer(p)).FzText +} + +// C documentation +// +// /* +// ** Return a pointer to the name of Nth query parameter of the filename. +// */ +func Xsqlite3_uri_key(tls *libc.TLS, zFilename uintptr, N int32) (r uintptr) { + var v1 int32 + var v2 bool + var v3 uintptr + _, _, _ = v1, v2, v3 + if zFilename == uintptr(0) || N < 0 { + return uintptr(0) + } + zFilename = _databaseName(tls, zFilename) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + for { + if v2 = zFilename != 0 && **(**uint8)(__ccgo_up(zFilename)) != 0; v2 { + v1 = N + N = N - 1 + } + if !(v2 && v1 > 0) { + break + } + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + } + if **(**uint8)(__ccgo_up(zFilename)) != 0 { + v3 = zFilename + } else { + v3 = uintptr(0) + } + return v3 +} + +// C documentation +// +// /* +// ** CAPI3REF: Run-Time Library Version Numbers +// ** KEYWORDS: sqlite3_version sqlite3_sourceid +// ** +// ** These interfaces provide the same information as the [SQLITE_VERSION], +// ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros +// ** but are associated with the library instead of the header file. ^(Cautious +// ** programmers might include assert() statements in their application to +// ** verify that values returned by these interfaces match the macros in +// ** the header, and thus ensure that the application is +// ** compiled with matching library and header files. +// ** +// **
    +//	** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
    +//	** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
    +//	** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
    +//	** 
    )^ +// ** +// ** ^The sqlite3_version[] string constant contains the text of the +// ** [SQLITE_VERSION] macro. ^The sqlite3_libversion() function returns a +// ** pointer to the sqlite3_version[] string constant. The sqlite3_libversion() +// ** function is provided for use in DLLs since DLL users usually do not have +// ** direct access to string constants within the DLL. ^The +// ** sqlite3_libversion_number() function returns an integer equal to +// ** [SQLITE_VERSION_NUMBER]. ^(The sqlite3_sourceid() function returns +// ** a pointer to a string constant whose value is the same as the +// ** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built +// ** using an edited copy of [the amalgamation], then the last four characters +// ** of the hash might be different from [SQLITE_SOURCE_ID].)^ +// ** +// ** See also: [sqlite_version()] and [sqlite_source_id()]. +// */ +var Xsqlite3_version = [7]uint8{'3', '.', '5', '3', '.', '2'} + +// C documentation +// +// /* +// ** sqlite3_snprintf() works like snprintf() except that it ignores the +// ** current locale settings. This is important for SQLite because we +// ** are not able to use a "," as the decimal point in place of "." as +// ** specified by some locales. +// ** +// ** Oops: The first two arguments of sqlite3_snprintf() are backwards +// ** from the snprintf() standard. Unfortunately, it is too late to change +// ** this without breaking compatibility, so we just have to live with the +// ** mistake. +// ** +// ** sqlite3_vsnprintf() is the varargs version. +// */ +func Xsqlite3_vsnprintf(tls *libc.TLS, n int32, zBuf uintptr, zFormat uintptr, ap Tva_list) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* acc at bp+0 */ TStrAccum + if n <= 0 { + return zBuf + } + _sqlite3StrAccumInit(tls, bp, uintptr(0), zBuf, n, 0) + Xsqlite3_str_vappendf(tls, bp, zFormat, ap) + **(**uint8)(__ccgo_up(zBuf + uintptr((**(**TStrAccum)(__ccgo_up(bp))).FnChar))) = uint8(0) + return zBuf +} + +const __CHAR_UNSIGNED__ = 1 + +var _aDigits = [33]uint8{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'} + +var _aPrefix = [7]uint8{'-', 'x', '0', 0, 'X', '0'} + +var _aSpecial = [32]uint8{ + 8: uint8('b'), + 9: uint8('t'), + 10: uint8('n'), + 12: uint8('f'), + 13: uint8('r'), +} + +// C documentation +// +// /* +// ** The following table defines various date transformations of the form +// ** +// ** 'NNN days' +// ** +// ** Where NNN is an arbitrary floating-point number and "days" can be one +// ** of several units of time. +// */ +var _aXformType = [6]struct { + FnName Tu8 + FzName [7]uint8 + FrLimit float32 + FrXform float32 +}{ + 0: { + FnName: uint8(6), + FzName: [7]uint8{'s', 'e', 'c', 'o', 'n', 'd'}, + FrLimit: float32(4.6427e+14), + FrXform: float32(1), + }, + 1: { + FnName: uint8(6), + FzName: [7]uint8{'m', 'i', 'n', 'u', 't', 'e'}, + FrLimit: float32(7.7379e+12), + FrXform: float32(60), + }, + 2: { + FnName: uint8(4), + FzName: [7]uint8{'h', 'o', 'u', 'r'}, + FrLimit: float32(1.2897e+11), + FrXform: float32(3600), + }, + 3: { + FnName: uint8(3), + FzName: [7]uint8{'d', 'a', 'y'}, + FrLimit: float32(5.373485e+06), + FrXform: float32(86400), + }, + 4: { + FnName: uint8(5), + FzName: [7]uint8{'m', 'o', 'n', 't', 'h'}, + FrLimit: float32(176546), + FrXform: float32(2.592e+06), + }, + 5: { + FnName: uint8(4), + FzName: [7]uint8{'y', 'e', 'a', 'r'}, + FrLimit: float32(14713), + FrXform: float32(3.1536e+07), + }, +} + +// C documentation +// +// /* +// ** Append all path elements in zPath to the DbPath under construction. +// */ +func _appendAllPathElements(tls *libc.TLS, pPath uintptr, zPath uintptr) { + var i, j, v1 int32 + _, _, _ = i, j, v1 + i = 0 + j = 0 + for { + for **(**uint8)(__ccgo_up(zPath + uintptr(i))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPath + uintptr(i)))) != int32('/') { + i = i + 1 + } + if i > j { + _appendOnePathElement(tls, pPath, zPath+uintptr(j), i-j) + } + j = i + int32(1) + goto _2 + _2: + ; + v1 = i + i = i + 1 + if !(**(**uint8)(__ccgo_up(zPath + uintptr(v1))) != 0) { + break + } + } +} + +func _asciiFold(tls *libc.TLS, aOut uintptr, aIn uintptr, nByte int32) { + var c uint8 + var i int32 + _, _ = c, i + i = 0 + for { + if !(i < nByte) { + break + } + c = **(**uint8)(__ccgo_up(aIn + uintptr(i))) + if libc.Int32FromUint8(c) >= int32('A') && libc.Int32FromUint8(c) <= int32('Z') { + c = libc.Uint8FromInt32(int32(c) + libc.Int32FromInt32(32)) + } + **(**uint8)(__ccgo_up(aOut + uintptr(i))) = c + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Return the P5 value that should be used for a binary comparison +// ** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2. +// */ +func _binaryCompareP5(tls *libc.TLS, pExpr1 uintptr, pExpr2 uintptr, jumpIfNull int32) (r Tu8) { + var aff Tu8 + _ = aff + aff = _sqlite3ExprAffinity(tls, pExpr2) + aff = libc.Uint8FromInt32(libc.Int32FromUint8(_sqlite3CompareAffinity(tls, pExpr1, aff)) | libc.Int32FromUint8(libc.Uint8FromInt32(jumpIfNull))) + return aff +} + +// C documentation +// +// /* +// ** Clear the YMD and HMS and the TZ +// */ +func _clearYMD_HMS_TZ(tls *libc.TLS, p uintptr) { + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(0) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(0) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 +} + +/* +** On recent Windows platforms, the localtime_s() function is available +** as part of the "Secure CRT". It is essentially equivalent to +** localtime_r() available under most POSIX platforms, except that the +** order of the parameters is reversed. +** +** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. +** +** If the user has not indicated to use localtime_r() or localtime_s() +** already, check for an MSVC build environment that provides +** localtime_s(). + */ + +// C documentation +// +// /* +// ** Code an OP_Affinity opcode to apply the column affinity string zAff +// ** to the n registers starting at base. +// ** +// ** As an optimization, SQLITE_AFF_BLOB and SQLITE_AFF_NONE entries (which +// ** are no-ops) at the beginning and end of zAff are ignored. If all entries +// ** in zAff are SQLITE_AFF_BLOB or SQLITE_AFF_NONE, then no code gets generated. +// ** +// ** This routine makes its own copy of zAff so that the caller is free +// ** to modify zAff after this routine returns. +// */ +func _codeApplyAffinity(tls *libc.TLS, pParse uintptr, base int32, n int32, zAff uintptr) { + var v uintptr + _ = v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if zAff == uintptr(0) { + return + } + /* Adjust base and n to skip over SQLITE_AFF_BLOB and SQLITE_AFF_NONE + ** entries at the beginning and end of the affinity string. + */ + for n > 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zAff))) <= int32(SQLITE_AFF_BLOB) { + n = n - 1 + base = base + 1 + zAff = zAff + 1 + } + for n > int32(1) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zAff + uintptr(n-int32(1))))) <= int32(SQLITE_AFF_BLOB) { + n = n - 1 + } + /* Code the OP_Affinity opcode if there is anything left to do. */ + if n > 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), base, n, 0, zAff, n) + } +} + +// C documentation +// +// /* +// ** Given the YYYY-MM-DD information current in p, determine if there +// ** is day-of-month overflow and set nFloor to the number of days that +// ** would need to be subtracted from the date in order to bring the +// ** date back to the end of the month. +// */ +func _computeFloor(tls *libc.TLS, p uintptr) { + if (*TDateTime)(unsafe.Pointer(p)).FD <= int32(28) { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = uint8(0) + } else { + if int32(1)<<(*TDateTime)(unsafe.Pointer(p)).FM&int32(0x15aa) != 0 { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = uint8(0) + } else { + if (*TDateTime)(unsafe.Pointer(p)).FM != int32(2) { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = libc.BoolUint8((*TDateTime)(unsafe.Pointer(p)).FD == libc.Int32FromInt32(31)) + } else { + if (*TDateTime)(unsafe.Pointer(p)).FY%int32(4) != 0 || (*TDateTime)(unsafe.Pointer(p)).FY%int32(100) == 0 && (*TDateTime)(unsafe.Pointer(p)).FY%int32(400) != 0 { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = libc.Uint8FromInt32((*TDateTime)(unsafe.Pointer(p)).FD - int32(28)) + } else { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = libc.Uint8FromInt32((*TDateTime)(unsafe.Pointer(p)).FD - int32(29)) + } + } + } + } +} + +// C documentation +// +// /* +// ** Compute the Hour, Minute, and Seconds from the julian day number. +// */ +func _computeHMS(tls *libc.TLS, p uintptr) { + var day_min, day_ms int32 + _, _ = day_min, day_ms /* milliseconds, minutes into the day */ + if (*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0 { + return + } + _computeJD(tls, p) + day_ms = int32(((*TDateTime)(unsafe.Pointer(p)).FiJD + libc.Int64FromInt32(43200000)) % libc.Int64FromInt32(86400000)) + (*TDateTime)(unsafe.Pointer(p)).Fs = float64(day_ms%libc.Int32FromInt32(60000)) / float64(1000) + day_min = day_ms / int32(60000) + (*TDateTime)(unsafe.Pointer(p)).Fm = day_min % int32(60) + (*TDateTime)(unsafe.Pointer(p)).Fh = day_min / int32(60) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1) +} + +var _cume_distName = [10]uint8{'c', 'u', 'm', 'e', '_', 'd', 'i', 's', 't'} + +// C documentation +// +// /* +// ** The Pager stores the Database filename, Journal filename, and WAL filename +// ** consecutively in memory, in that order. The database filename is prefixed +// ** by four zero bytes. Locate the start of the database filename by searching +// ** backwards for the first byte following four consecutive zero bytes. +// ** +// ** This only works if the filename passed in was obtained from the Pager. +// */ +func _databaseName(tls *libc.TLS, zName uintptr) (r uintptr) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(1))))) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(2))))) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(3))))) != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(4))))) != 0 { + zName = zName - 1 + } + return zName +} + +// C documentation +// +// /* +// ** date( TIMESTRING, MOD, MOD, ...) +// ** +// ** Return YYYY-MM-DD +// */ +func _dateFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var Y int32 + var _ /* x at bp+0 */ TDateTime + var _ /* zBuf at bp+48 */ [16]uint8 + _ = Y + if _isDate(tls, context, argc, argv, bp) == 0 { + _computeYMD(tls, bp) + Y = (**(**TDateTime)(__ccgo_up(bp))).FY + if Y < 0 { + Y = -Y + } + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(1)] = libc.Uint8FromInt32(int32('0') + Y/int32(1000)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(2)] = libc.Uint8FromInt32(int32('0') + Y/int32(100)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(3)] = libc.Uint8FromInt32(int32('0') + Y/int32(10)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(4)] = libc.Uint8FromInt32(int32('0') + Y%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(5)] = uint8('-') + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(6)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FM/int32(10)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(7)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FM%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(8)] = uint8('-') + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(9)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FD/int32(10)%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(10)] = libc.Uint8FromInt32(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FD%int32(10)) + (**(**[16]uint8)(__ccgo_up(bp + 48)))[int32(11)] = uint8(0) + if (**(**TDateTime)(__ccgo_up(bp))).FY < 0 { + (**(**[16]uint8)(__ccgo_up(bp + 48)))[0] = uint8('-') + Xsqlite3_result_text(tls, context, bp+48, int32(11), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_text(tls, context, bp+48+1, int32(10), uintptr(-libc.Int32FromInt32(1))) + } + } +} + +// C documentation +// +// /* +// ** Compute the number of days after the most recent January 1. +// ** +// ** In other words, compute the zero-based day number for the +// ** current year: +// ** +// ** Jan01 = 0, Jan02 = 1, ..., Jan31 = 30, Feb01 = 31, ... +// ** Dec31 = 364 or 365. +// */ +func _daysAfterJan01(tls *libc.TLS, pDate uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* jan01 at bp+0 */ TDateTime + **(**TDateTime)(__ccgo_up(bp)) = **(**TDateTime)(__ccgo_up(pDate)) + (**(**TDateTime)(__ccgo_up(bp))).FvalidJD = uint8(0) + (**(**TDateTime)(__ccgo_up(bp))).FM = int32(1) + (**(**TDateTime)(__ccgo_up(bp))).FD = int32(1) + _computeJD(tls, bp) + return int32(((*TDateTime)(unsafe.Pointer(pDate)).FiJD - (**(**TDateTime)(__ccgo_up(bp))).FiJD + libc.Int64FromInt32(43200000)) / libc.Int64FromInt32(86400000)) +} + +var _dense_rankName = [11]uint8{'d', 'e', 'n', 's', 'e', '_', 'r', 'a', 'n', 'k'} + +// C documentation +// +// /* +// ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of +// ** bytes in this text up to but excluding the first character in +// ** a host parameter. If the text contains no host parameters, return +// ** the total number of bytes in the text. +// */ +func _findNextHostParameter(tls *libc.TLS, zSql uintptr, pnToken uintptr) (r Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var n, nTotal Ti64 + var _ /* tokenType at bp+0 */ int32 + _, _ = n, nTotal + nTotal = 0 + **(**Ti64)(__ccgo_up(pnToken)) = 0 + for **(**uint8)(__ccgo_up(zSql)) != 0 { + n = _sqlite3GetToken(tls, zSql, bp) + if **(**int32)(__ccgo_up(bp)) == int32(TK_VARIABLE) { + **(**Ti64)(__ccgo_up(pnToken)) = n + break + } + nTotal = nTotal + n + zSql = zSql + uintptr(n) + } + return nTotal +} + +var _first_valueName = [12]uint8{'f', 'i', 'r', 's', 't', '_', 'v', 'a', 'l', 'u', 'e'} + +var _fmtinfo = [23]Tet_info{ + 0: { + Ffmttype: uint8('s'), + Fflags: uint8(4), + Ftype1: uint8(etSTRING), + FiNxt: uint8(1), + }, + 1: { + Ffmttype: uint8('E'), + Fflags: uint8(1), + Ftype1: uint8(etEXP), + Fcharset: uint8(14), + }, + 2: { + Ffmttype: uint8('u'), + Fbase: uint8(10), + Ftype1: uint8(etDECIMAL), + FiNxt: uint8(3), + }, + 3: { + Ffmttype: uint8('G'), + Fflags: uint8(1), + Ftype1: uint8(etGENERIC), + Fcharset: uint8(14), + }, + 4: { + Ffmttype: uint8('w'), + Fflags: uint8(4), + Ftype1: uint8(etESCAPE_w), + }, + 5: { + Ffmttype: uint8('x'), + Fbase: uint8(16), + Fcharset: uint8(16), + Fprefix: uint8(1), + }, + 6: { + Ffmttype: uint8('c'), + Ftype1: uint8(etCHARX), + }, + 7: { + Ffmttype: uint8('z'), + Fflags: uint8(4), + Ftype1: uint8(etDYNSTRING), + FiNxt: uint8(6), + }, + 8: { + Ffmttype: uint8('d'), + Fbase: uint8(10), + Fflags: uint8(1), + Ftype1: uint8(etDECIMAL), + }, + 9: { + Ffmttype: uint8('e'), + Fflags: uint8(1), + Ftype1: uint8(etEXP), + Fcharset: uint8(30), + }, + 10: { + Ffmttype: uint8('f'), + Fflags: uint8(1), + Ftype1: uint8(etFLOAT), + }, + 11: { + Ffmttype: uint8('g'), + Fflags: uint8(1), + Ftype1: uint8(etGENERIC), + Fcharset: uint8(30), + }, + 12: { + Ffmttype: uint8('Q'), + Fflags: uint8(4), + Ftype1: uint8(etESCAPE_Q), + }, + 13: { + Ffmttype: uint8('i'), + Fbase: uint8(10), + Fflags: uint8(1), + Ftype1: uint8(etDECIMAL), + }, + 14: { + Ffmttype: uint8('%'), + Ftype1: uint8(etPERCENT), + FiNxt: uint8(16), + }, + 15: { + Ffmttype: uint8('T'), + Ftype1: uint8(etTOKEN), + }, + 16: { + Ffmttype: uint8('S'), + Ftype1: uint8(etSRCITEM), + }, + 17: { + Ffmttype: uint8('X'), + Fbase: uint8(16), + Fprefix: uint8(4), + }, + 18: { + Ffmttype: uint8('n'), + Ftype1: uint8(etSIZE), + }, + 19: { + Ffmttype: uint8('o'), + Fbase: uint8(8), + Fprefix: uint8(2), + FiNxt: uint8(17), + }, + 20: { + Ffmttype: uint8('p'), + Fbase: uint8(16), + Ftype1: uint8(etPOINTER), + Fprefix: uint8(1), + }, + 21: { + Ffmttype: uint8('q'), + Fflags: uint8(4), + Ftype1: uint8(etESCAPE_q), + }, + 22: { + Ffmttype: uint8('r'), + Fbase: uint8(10), + Fflags: uint8(1), + Ftype1: uint8(etORDINAL), + }, +} + +/* Additional Notes: +** +** %S Takes a pointer to SrcItem. Shows name or database.name +** %!S Like %S but prefer the zName over the zAlias + */ + +func _fts5AsciiAddExceptions(tls *libc.TLS, p uintptr, zArg uintptr, bTokenChars int32) { + var i int32 + _ = i + i = 0 + for { + if !(**(**uint8)(__ccgo_up(zArg + uintptr(i))) != 0) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg + uintptr(i))))&int32(0x80) == 0 { + **(**uint8)(__ccgo_up(p + uintptr(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zArg + uintptr(i))))))) = libc.Uint8FromInt32(bTokenChars) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Tokenize some text using the ascii tokenizer. +// */ +func _fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, p, pFold uintptr + var ie, is, nByte, nFold, rc int32 + var _ /* aFold at bp+0 */ [64]uint8 + _, _, _, _, _, _, _, _ = a, ie, is, nByte, nFold, p, pFold, rc + p = pTokenizer + rc = SQLITE_OK + is = 0 + nFold = int32(64) + pFold = bp + a = p + _ = iUnused + for is < nText && rc == SQLITE_OK { + /* Skip any leading divider characters. */ + for is < nText && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(pText + uintptr(is))))&int32(0x80) == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(a + uintptr(libc.Int32FromUint8(**(**uint8)(__ccgo_up(pText + uintptr(is)))))))) == 0) { + is = is + 1 + } + if is == nText { + break + } + /* Count the token characters */ + ie = is + int32(1) + for ie < nText && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(pText + uintptr(ie))))&int32(0x80) != 0 || **(**uint8)(__ccgo_up(a + uintptr(libc.Int32FromUint8(**(**uint8)(__ccgo_up(pText + uintptr(ie))))))) != 0) { + ie = ie + 1 + } + /* Fold to lower case */ + nByte = ie - is + if nByte > nFold { + if pFold != bp { + Xsqlite3_free(tls, pFold) + } + pFold = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nByte)*int64(2))) + if pFold == uintptr(0) { + rc = int32(SQLITE_NOMEM) + break + } + nFold = nByte * int32(2) + } + _asciiFold(tls, pFold, pText+uintptr(is), nByte) + /* Invoke the token callback */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xToken})))(tls, pCtx, 0, pFold, nByte, is, ie) + is = ie + int32(1) + } + if pFold != bp { + Xsqlite3_free(tls, pFold) + } + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + return rc +} + +/************************************************************************** +** Start of unicode61 tokenizer implementation. + */ + +/* +** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied +** from the sqlite3 source file utf.c. If this file is compiled as part +** of the amalgamation, they are not required. + */ + +// C documentation +// +// /* +// ** Argument pIn points to the first character in what is expected to be +// ** a comma-separated list of SQL literals followed by a ')' character. +// ** If it actually is this, return a pointer to the ')'. Otherwise, return +// ** NULL to indicate a parse error. +// */ +func _fts5ConfigSkipArgs(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + for int32(1) != 0 { + p = _fts5ConfigSkipWhitespace(tls, p) + p = _fts5ConfigSkipLiteral(tls, p) + p = _fts5ConfigSkipWhitespace(tls, p) + if p == uintptr(0) || libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32(')') { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32(',') { + p = uintptr(0) + break + } + p = p + 1 + } + return p +} + +// C documentation +// +// /* +// ** Argument pIn points to a character that is part of a nul-terminated +// ** string. Return a pointer to the first character following *pIn in +// ** the string that is not a "bareword" character. +// */ +func _fts5ConfigSkipBareword(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + for _sqlite3Fts5IsBareword(tls, **(**uint8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + if p == pIn { + p = uintptr(0) + } + return p +} + +// C documentation +// +// /* +// ** Argument pIn points to a character that is part of a nul-terminated +// ** string. Return a pointer to the first character following *pIn in +// ** the string that is not a white-space character. +// */ +func _fts5ConfigSkipWhitespace(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + if p != 0 { + for _fts5_iswhitespace(tls, **(**uint8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + } + return p +} + +// C documentation +// +// /* +// ** The first character of the string pointed to by argument z is guaranteed +// ** to be an open-quote character (see function fts5_isopenquote()). +// ** +// ** This function searches for the corresponding close-quote character within +// ** the string and, if found, dequotes the string in place and adds a new +// ** nul-terminator byte. +// ** +// ** If the close-quote is found, the value returned is the byte offset of +// ** the character immediately following it. Or, if the close-quote is not +// ** found, -1 is returned. If -1 is returned, the buffer is left in an +// ** undefined state. +// */ +func _fts5Dequote(tls *libc.TLS, z uintptr) (r int32) { + var iIn, iOut, v1, v2 int32 + var q uint8 + _, _, _, _, _ = iIn, iOut, q, v1, v2 + iIn = int32(1) + iOut = 0 + q = **(**uint8)(__ccgo_up(z)) + /* Set stack variable q to the close-quote character */ + if libc.Int32FromUint8(q) == int32('[') { + q = uint8(']') + } + for **(**uint8)(__ccgo_up(z + uintptr(iIn))) != 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(iIn)))) == libc.Int32FromUint8(q) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(iIn+int32(1))))) != libc.Int32FromUint8(q) { + /* Character iIn was the close quote. */ + iIn = iIn + 1 + break + } else { + /* Character iIn and iIn+1 form an escaped quote character. Skip + ** the input cursor past both and copy a single quote character + ** to the output buffer. */ + iIn = iIn + int32(2) + v1 = iOut + iOut = iOut + 1 + **(**uint8)(__ccgo_up(z + uintptr(v1))) = q + } + } else { + v1 = iOut + iOut = iOut + 1 + v2 = iIn + iIn = iIn + 1 + **(**uint8)(__ccgo_up(z + uintptr(v1))) = **(**uint8)(__ccgo_up(z + uintptr(v2))) + } + } + **(**uint8)(__ccgo_up(z + uintptr(iOut))) = uint8('\000') + return iIn +} + +// C documentation +// +// /* +// ** Assuming that buffer z is at least nByte bytes in size and contains a +// ** valid utf-8 string, return the number of characters in the string. +// */ +func _fts5ExprCountChar(tls *libc.TLS, z uintptr, nByte int32) (r int32) { + var ii, nRet int32 + _, _ = ii, nRet + nRet = 0 + ii = 0 + for { + if !(ii < nByte) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(ii))))&int32(0xC0) != int32(0x80) { + nRet = nRet + 1 + } + goto _1 + _1: + ; + ii = ii + 1 + } + return nRet +} + +func _fts5ExprIsspace(tls *libc.TLS, t uint8) (r int32) { + return libc.BoolInt32(libc.Int32FromUint8(t) == int32(' ') || libc.Int32FromUint8(t) == int32('\t') || libc.Int32FromUint8(t) == int32('\n') || libc.Int32FromUint8(t) == int32('\r')) +} + +// C documentation +// +// /* +// ** pIn is a UTF-8 encoded string, nIn bytes in size. Return the number of +// ** unicode characters in the string. +// */ +func _fts5IndexCharlen(tls *libc.TLS, pIn uintptr, nIn int32) (r int32) { + var i, nChar, v1 int32 + _, _, _ = i, nChar, v1 + nChar = 0 + i = 0 + for i < nIn { + v1 = i + i = i + 1 + if libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(pIn + uintptr(v1))))) >= int32(0xc0) { + for i < nIn && libc.Int32FromUint8(**(**uint8)(__ccgo_up(pIn + uintptr(i))))&int32(0xc0) == int32(0x80) { + i = i + 1 + } + } + nChar = nChar + 1 + } + return nChar +} + +func _fts5PorterGobbleVC(tls *libc.TLS, zStem uintptr, nStem int32, bPrevCons int32) (r int32) { + var bCons, i, v2 int32 + _, _, _ = bCons, i, v2 + bCons = bPrevCons + /* Scan for a vowel */ + i = 0 + for { + if !(i < nStem) { + break + } + v2 = libc.BoolInt32(!(_fts5PorterIsVowel(tls, **(**uint8)(__ccgo_up(zStem + uintptr(i))), bCons) != 0)) + bCons = v2 + if 0 == v2 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + /* Scan for a consonent */ + i = i + 1 + for { + if !(i < nStem) { + break + } + v2 = libc.BoolInt32(!(_fts5PorterIsVowel(tls, **(**uint8)(__ccgo_up(zStem + uintptr(i))), bCons) != 0)) + bCons = v2 + if v2 != 0 { + return i + int32(1) + } + goto _3 + _3: + ; + i = i + 1 + } + return 0 +} + +func _fts5PorterIsVowel(tls *libc.TLS, c uint8, bYIsVowel int32) (r int32) { + return libc.BoolInt32(libc.Int32FromUint8(c) == int32('a') || libc.Int32FromUint8(c) == int32('e') || libc.Int32FromUint8(c) == int32('i') || libc.Int32FromUint8(c) == int32('o') || libc.Int32FromUint8(c) == int32('u') || bYIsVowel != 0 && libc.Int32FromUint8(c) == int32('y')) +} + +func _fts5PorterStep1A(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) { + var nBuf int32 + _ = nBuf + nBuf = **(**int32)(__ccgo_up(pnBuf)) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(1))))) == int32('s') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) == int32('e') { + if nBuf > int32(4) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(4))))) == int32('s') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(3))))) == int32('s') || nBuf > int32(3) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(3))))) == int32('i') { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } else { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(1) + } + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) != int32('s') { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(1) + } + } + } +} + +// C documentation +// +// /* porter rule condition: (m > 1 and (*S or *T)) */ +func _fts5Porter_MGt1_and_S_or_T(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) { + return libc.BoolInt32((libc.Int32FromUint8(**(**uint8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('s') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('t')) && _fts5Porter_MGt1(tls, zStem, nStem) != 0) +} + +// C documentation +// +// /* porter rule condition: (*o) */ +func _fts5Porter_Ostar(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) { + var bCons, i, mask int32 + _, _, _ = bCons, i, mask + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('w') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('x') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('y') { + return 0 + } else { + mask = 0 + bCons = 0 + i = 0 + for { + if !(i < nStem) { + break + } + bCons = libc.BoolInt32(!(_fts5PorterIsVowel(tls, **(**uint8)(__ccgo_up(zStem + uintptr(i))), bCons) != 0)) + mask = mask< 0)) != 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +/************************************************************************** +*************************************************************************** +** GENERATED CODE STARTS HERE (mkportersteps.tcl) + */ + +// C documentation +// +// /* +// ** pToken is a buffer nToken bytes in size that may or may not contain +// ** an embedded 0x00 byte. If it does, return the number of bytes in +// ** the buffer before the 0x00. If it does not, return nToken. +// */ +func _fts5QueryTerm(tls *libc.TLS, pToken uintptr, nToken int32) (r int32) { + var ii int32 + _ = ii + ii = 0 + for { + if !(ii < nToken && **(**uint8)(__ccgo_up(pToken + uintptr(ii))) != 0) { + break + } + goto _1 + _1: + ; + ii = ii + 1 + } + return ii +} + +// C documentation +// +// /* +// ** This function is an xTokenize() callback used by the auxiliary snippet() +// ** function. Its job is to identify tokens that are the first in a sentence. +// ** For each such token, an entry is added to the SFinder.aFirst[] array. +// */ +func _fts5SentenceFinderCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iStartOff int32, iEndOff int32) (r int32) { + var c uint8 + var i, rc int32 + var p uintptr + _, _, _, _ = c, i, p, rc + rc = SQLITE_OK + _ = pToken + _ = nToken + _ = iEndOff + if tflags&int32(FTS5_TOKEN_COLOCATED) == 0 { + p = pContext + if (*TFts5SFinder)(unsafe.Pointer(p)).FiPos > 0 { + c = uint8(0) + i = iStartOff - int32(1) + for { + if !(i >= 0) { + break + } + c = **(**uint8)(__ccgo_up((*TFts5SFinder)(unsafe.Pointer(p)).FzDoc + uintptr(i))) + if libc.Int32FromUint8(c) != int32(' ') && libc.Int32FromUint8(c) != int32('\t') && libc.Int32FromUint8(c) != int32('\n') && libc.Int32FromUint8(c) != int32('\r') { + break + } + goto _1 + _1: + ; + i = i - 1 + } + if i != iStartOff-int32(1) && (libc.Int32FromUint8(c) == int32('.') || libc.Int32FromUint8(c) == int32(':')) { + rc = _fts5SentenceFinderAdd(tls, p, (*TFts5SFinder)(unsafe.Pointer(p)).FiPos) + } + } else { + rc = _fts5SentenceFinderAdd(tls, p, 0) + } + (*TFts5SFinder)(unsafe.Pointer(p)).FiPos = (*TFts5SFinder)(unsafe.Pointer(p)).FiPos + 1 + } + return rc +} + +func _fts5_isdigit(tls *libc.TLS, a uint8) (r int32) { + return libc.BoolInt32(libc.Int32FromUint8(a) >= int32('0') && libc.Int32FromUint8(a) <= int32('9')) +} + +func _fts5_isopenquote(tls *libc.TLS, x uint8) (r int32) { + return libc.BoolInt32(libc.Int32FromUint8(x) == int32('"') || libc.Int32FromUint8(x) == int32('\'') || libc.Int32FromUint8(x) == int32('[') || libc.Int32FromUint8(x) == int32('`')) +} + +func _fts5_iswhitespace(tls *libc.TLS, x uint8) (r int32) { + return libc.BoolInt32(libc.Int32FromUint8(x) == int32(' ')) +} + +// C documentation +// +// /* +// ** Growing our own isspace() routine this way is twice as fast as +// ** the library isspace() function. +// */ +var _geopolyIsSpace = [256]uint8{ + 9: uint8(1), + 10: uint8(1), + 13: uint8(1), + 32: uint8(1), +} + +/* Compiler and version */ + +// C documentation +// +// /* Parse out a number. Write the value into *pVal if pVal!=0. +// ** return non-zero on success and zero if the next token is not a number. +// */ +func _geopolyParseNumber(tls *libc.TLS, p uintptr, pVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c uint8 + var j, seenDP, seenE, v2 int32 + var z uintptr + var _ /* r at bp+0 */ float64 + _, _, _, _, _, _ = c, j, seenDP, seenE, z, v2 + c = _geopolySkipSpace(tls, p) + z = (*TGeoParse)(unsafe.Pointer(p)).Fz + j = 0 + seenDP = 0 + seenE = 0 + if libc.Int32FromUint8(c) == int32('-') { + j = int32(1) + c = uint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) + } + if libc.Int32FromUint8(c) == int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j+int32(1))))) >= int32('0') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j+int32(1))))) <= int32('9') { + return 0 + } + for { + c = uint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) + if libc.Int32FromUint8(_sqlite3CtypeMap[c])&int32(0x04) != 0 { + goto _1 + } + if libc.Int32FromUint8(c) == int32('.') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-int32(1))))) == int32('-') { + return 0 + } + if seenDP != 0 { + return 0 + } + seenDP = int32(1) + goto _1 + } + if libc.Int32FromUint8(c) == int32('e') || libc.Int32FromUint8(c) == int32('E') { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-int32(1))))) < int32('0') { + return 0 + } + if seenE != 0 { + return -int32(1) + } + v2 = libc.Int32FromInt32(1) + seenE = v2 + seenDP = v2 + c = uint8(**(**uint8)(__ccgo_up(z + uintptr(j+int32(1))))) + if libc.Int32FromUint8(c) == int32('+') || libc.Int32FromUint8(c) == int32('-') { + j = j + 1 + c = uint8(**(**uint8)(__ccgo_up(z + uintptr(j+int32(1))))) + } + if libc.Int32FromUint8(c) < int32('0') || libc.Int32FromUint8(c) > int32('9') { + return 0 + } + goto _1 + } + break + goto _1 + _1: + ; + j = j + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j-int32(1))))) < int32('0') { + return 0 + } + if pVal != 0 { + _sqlite3AtoF(tls, (*TGeoParse)(unsafe.Pointer(p)).Fz, bp) + **(**TGeoCoord)(__ccgo_up(pVal)) = float32(**(**float64)(__ccgo_up(bp))) + } + **(**uintptr)(__ccgo_up(p)) += uintptr(j) + return int32(1) +} + +// C documentation +// +// /* Skip whitespace. Return the next non-whitespace character. */ +func _geopolySkipSpace(tls *libc.TLS, p uintptr) (r uint8) { + for _geopolyIsSpace[**(**uint8)(__ccgo_up((*TGeoParse)(unsafe.Pointer(p)).Fz))] != 0 { + (*TGeoParse)(unsafe.Pointer(p)).Fz = (*TGeoParse)(unsafe.Pointer(p)).Fz + 1 + } + return uint8(**(**uint8)(__ccgo_up((*TGeoParse)(unsafe.Pointer(p)).Fz))) +} + +// C documentation +// +// /* +// ** Convert zDate into one or more integers according to the conversion +// ** specifier zFormat. +// ** +// ** zFormat[] contains 4 characters for each integer converted, except for +// ** the last integer which is specified by three characters. The meaning +// ** of a four-character format specifiers ABCD is: +// ** +// ** A: number of digits to convert. Always "2" or "4". +// ** B: minimum value. Always "0" or "1". +// ** C: maximum value, decoded as: +// ** a: 12 +// ** b: 14 +// ** c: 24 +// ** d: 31 +// ** e: 59 +// ** f: 9999 +// ** D: the separator character, or \000 to indicate this is the +// ** last number to convert. +// ** +// ** Example: To translate an ISO-8601 date YYYY-MM-DD, the format would +// ** be "40f-21a-20c". The "40f-" indicates the 4-digit year followed by "-". +// ** The "21a-" indicates the 2-digit month followed by "-". The "20c" indicates +// ** the 2-digit day which is the last integer in the set. +// ** +// ** The function returns the number of successful conversions. +// */ +func _getDigits(tls *libc.TLS, zDate uintptr, zFormat uintptr, va uintptr) (r int32) { + var N, min, nextC, v1 uint8 + var ap Tva_list + var cnt, val int32 + var max Tu16 + _, _, _, _, _, _, _, _ = N, ap, cnt, max, min, nextC, val, v1 + cnt = 0 + ap = va + for cond := true; cond; cond = nextC != 0 { + N = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zFormat))) - int32('0')) + min = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(zFormat + 1))) - int32('0')) + val = 0 + max = _aMx[libc.Int32FromUint8(**(**uint8)(__ccgo_up(zFormat + 2)))-int32('a')] + nextC = **(**uint8)(__ccgo_up(zFormat + 3)) + val = 0 + for { + v1 = N + N = N - 1 + if !(v1 != 0) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zDate)))])&libc.Int32FromInt32(0x04) != 0) { + goto end_getDigits + } + val = val*int32(10) + libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDate))) - int32('0') + zDate = zDate + 1 + } + if val < libc.Int32FromUint8(min) || val > libc.Int32FromUint16(max) || libc.Int32FromUint8(nextC) != 0 && libc.Int32FromUint8(nextC) != libc.Int32FromUint8(**(**uint8)(__ccgo_up(zDate))) { + goto end_getDigits + } + **(**int32)(__ccgo_up(libc.VaUintptr(&ap))) = val + zDate = zDate + 1 + cnt = cnt + 1 + zFormat = zFormat + uintptr(4) + } + goto end_getDigits +end_getDigits: + ; + _ = ap + return cnt +} + +// C documentation +// +// /* Array for converting from half-bytes (nybbles) into ASCII hex +// ** digits. */ +var _hexdigits = [16]uint8{ + 0: uint8('0'), + 1: uint8('1'), + 2: uint8('2'), + 3: uint8('3'), + 4: uint8('4'), + 5: uint8('5'), + 6: uint8('6'), + 7: uint8('7'), + 8: uint8('8'), + 9: uint8('9'), + 10: uint8('A'), + 11: uint8('B'), + 12: uint8('C'), + 13: uint8('D'), + 14: uint8('E'), + 15: uint8('F'), +} + +// C documentation +// +// /* +// ** Measure the number of characters needed to output the given +// ** identifier. The number returned includes any quotes used +// ** but does not include the null terminator. +// ** +// ** The estimate is conservative. It might be larger that what is +// ** really needed. +// */ +func _identLength(tls *libc.TLS, z uintptr) (r Ti64) { + var n Ti64 + _ = n + n = 0 + for { + if !(**(**uint8)(__ccgo_up(z)) != 0) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32('"') { + n = n + 1 + } + goto _1 + _1: + ; + n = n + 1 + z = z + 1 + } + return n + int64(2) +} + +// C documentation +// +// /* +// ** The first parameter is a pointer to an output buffer. The second +// ** parameter is a pointer to an integer that contains the offset at +// ** which to write into the output buffer. This function copies the +// ** nul-terminated string pointed to by the third parameter, zSignedIdent, +// ** to the specified offset in the buffer and updates *pIdx to refer +// ** to the first byte after the last byte written before returning. +// ** +// ** If the string zSignedIdent consists entirely of alphanumeric +// ** characters, does not begin with a digit and is not an SQL keyword, +// ** then it is copied to the output buffer exactly as it is. Otherwise, +// ** it is quoted using double-quotes. +// */ +func _identPut(tls *libc.TLS, z uintptr, pIdx uintptr, zSignedIdent uintptr) { + var i, j, needQuote, v2 int32 + var zIdent uintptr + _, _, _, _, _ = i, j, needQuote, zIdent, v2 + zIdent = zSignedIdent + i = **(**int32)(__ccgo_up(pIdx)) + j = 0 + for { + if !(**(**uint8)(__ccgo_up(zIdent + uintptr(j))) != 0) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(zIdent + uintptr(j)))])&libc.Int32FromInt32(0x06) != 0) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIdent + uintptr(j)))) != int32('_') { + break + } + goto _1 + _1: + ; + j = j + 1 + } + needQuote = libc.BoolInt32(libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(zIdent))])&int32(0x04) != 0 || _sqlite3KeywordCode(tls, zIdent, j) != int32(TK_ID) || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIdent + uintptr(j)))) != 0 || j == 0) + if needQuote != 0 { + v2 = i + i = i + 1 + **(**uint8)(__ccgo_up(z + uintptr(v2))) = uint8('"') + } + j = 0 + for { + if !(**(**uint8)(__ccgo_up(zIdent + uintptr(j))) != 0) { + break + } + v2 = i + i = i + 1 + **(**uint8)(__ccgo_up(z + uintptr(v2))) = uint8(**(**uint8)(__ccgo_up(zIdent + uintptr(j)))) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIdent + uintptr(j)))) == int32('"') { + v2 = i + i = i + 1 + **(**uint8)(__ccgo_up(z + uintptr(v2))) = uint8('"') + } + goto _3 + _3: + ; + j = j + 1 + } + if needQuote != 0 { + v2 = i + i = i + 1 + **(**uint8)(__ccgo_up(z + uintptr(v2))) = uint8('"') + } + **(**uint8)(__ccgo_up(z + uintptr(i))) = uint8(0) + **(**int32)(__ccgo_up(pIdx)) = i +} + +// C documentation +// +// /* +// ** The input pBlob is guaranteed to be a Blob that is not marked +// ** with MEM_Zero. Return true if it could be a zero-blob. +// */ +func _isAllZero(tls *libc.TLS, z uintptr, n int32) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < n) { + break + } + if **(**uint8)(__ccgo_up(z + uintptr(i))) != 0 { + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Return true if z[] begins with N hexadecimal digits, and write +// ** a decoding of those digits into *pVal. Or return false if any +// ** one of the first N characters in z[] is not a hexadecimal digit. +// */ +func _isNHex(tls *libc.TLS, z uintptr, N int32, pVal uintptr) (r int32) { + var i int32 + var v Tu32 + _, _ = i, v + v = uint32(0) + i = 0 + for { + if !(i < N) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i))))])&libc.Int32FromInt32(0x08) != 0) { + return 0 + } + v = v<= uint32(0xc0) { + sz = _sqlite3Utf8ReadLimited(tls, zLeft, libc.Int32FromUint32(nLeft), bp) + zLeft = zLeft + uintptr(sz) + nLeft = nLeft - libc.Uint32FromInt32(sz) + } else { + zLeft = zLeft + 1 + nLeft = nLeft - 1 + } + } else { + n = _jsonUnescapeOneChar(tls, zLeft, nLeft, bp) + zLeft = zLeft + uintptr(n) + nLeft = nLeft - n + } + } + if nRight == uint32(0) { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) + } else { + if rawRight != 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zRight))) != int32('\\') { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(**(**Tu8)(__ccgo_up(zRight))) + if **(**Tu32)(__ccgo_up(bp + 4)) >= uint32(0xc0) { + sz1 = _sqlite3Utf8ReadLimited(tls, zRight, libc.Int32FromUint32(nRight), bp+4) + zRight = zRight + uintptr(sz1) + nRight = nRight - libc.Uint32FromInt32(sz1) + } else { + zRight = zRight + 1 + nRight = nRight - 1 + } + } else { + n1 = _jsonUnescapeOneChar(tls, zRight, nRight, bp+4) + zRight = zRight + uintptr(n1) + nRight = nRight - n1 + } + } + if **(**Tu32)(__ccgo_up(bp)) != **(**Tu32)(__ccgo_up(bp + 4)) { + return 0 + } + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + return int32(1) + } + } + return r +} + +// C documentation +// +// /* +// ** The set of all space characters recognized by jsonIsspace(). +// ** Useful as the second argument to strspn(). +// */ +var _jsonSpaces = [5]uint8{9, 10, 13, ' '} + +// C documentation +// +// /* Make sure there is a zero terminator on p->zBuf[] +// ** +// ** Return true on success. Return false if an OOM prevents this +// ** from happening. +// */ +func _jsonStringTerminate(tls *libc.TLS, p uintptr) (r int32) { + _jsonAppendChar(tls, p, uint8(0)) + _jsonStringTrimOneChar(tls, p) + return libc.BoolInt32(libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr) == 0) +} + +// C documentation +// +// /* +// ** Input z[0..n] defines JSON escape sequence including the leading '\\'. +// ** Decode that escape sequence into a single character. Write that +// ** character into *piOut. Return the number of bytes in the escape sequence. +// ** +// ** If there is a syntax error of some kind (for example too few characters +// ** after the '\\' to complete the encoding) then *piOut is set to +// ** JSON_INVALID_CHAR. +// */ +func _jsonUnescapeOneChar(tls *libc.TLS, z uintptr, n Tu32, piOut uintptr) (r Tu32) { + var nSkip, v, vlo, v1 Tu32 + var sz, v3 int32 + var v2 bool + _, _, _, _, _, _, _ = nSkip, sz, v, vlo, v1, v2, v3 + if n < uint32(2) { + **(**Tu32)(__ccgo_up(piOut)) = uint32(JSON_INVALID_CHAR) + return n + } + switch libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(z + 1)))) { + case int32('u'): + if n < uint32(6) { + **(**Tu32)(__ccgo_up(piOut)) = uint32(JSON_INVALID_CHAR) + return n + } + v = _jsonHexToInt4(tls, z+2) + if v2 = v&uint32(0xfc00) == uint32(0xd800) && n >= uint32(12) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 6))) == int32('\\') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 7))) == int32('u'); v2 { + v1 = _jsonHexToInt4(tls, z+8) + vlo = v1 + } + if v2 && v1&uint32(0xfc00) == uint32(0xdc00) { + **(**Tu32)(__ccgo_up(piOut)) = v&uint32(0x3ff)< uint32(2) && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + 2)))])&int32(0x04) != 0 { + v3 = int32(JSON_INVALID_CHAR) + } else { + v3 = 0 + } + **(**Tu32)(__ccgo_up(piOut)) = libc.Uint32FromInt32(v3) + return uint32(2) + case int32('\''): + fallthrough + case int32('"'): + fallthrough + case int32('/'): + fallthrough + case int32('\\'): + **(**Tu32)(__ccgo_up(piOut)) = uint32(**(**uint8)(__ccgo_up(z + 1))) + return uint32(2) + case int32('x'): + if n < uint32(4) { + **(**Tu32)(__ccgo_up(piOut)) = uint32(JSON_INVALID_CHAR) + return n + } + **(**Tu32)(__ccgo_up(piOut)) = libc.Uint32FromInt32(libc.Int32FromUint8(_jsonHexToInt(tls, libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 2)))))< 0) { + break + } + if libc.Int64FromUint8(_aKWLen[i]) != n { + goto _1 + } + zKW = uintptr(unsafe.Pointer(&_zKWText)) + uintptr(_aKWOffset[i]) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) & ^libc.Int32FromInt32(0x20) != libc.Int32FromUint8(**(**uint8)(__ccgo_up(zKW))) { + goto _1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) & ^libc.Int32FromInt32(0x20) != libc.Int32FromUint8(**(**uint8)(__ccgo_up(zKW + 1))) { + goto _1 + } + j = int64(2) + for j < n && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(j)))) & ^libc.Int32FromInt32(0x20) == libc.Int32FromUint8(**(**uint8)(__ccgo_up(zKW + uintptr(j)))) { + j = j + 1 + } + if j < n { + goto _1 + } + /* REINDEX */ + /* INDEXED */ + /* INDEX */ + /* DESC */ + /* ESCAPE */ + /* EACH */ + /* CHECK */ + /* KEY */ + /* BEFORE */ + /* FOREIGN */ + /* FOR */ + /* IGNORE */ + /* REGEXP */ + /* EXPLAIN */ + /* INSTEAD */ + /* ADD */ + /* DATABASE */ + /* AS */ + /* SELECT */ + /* TABLE */ + /* LEFT */ + /* THEN */ + /* END */ + /* DEFERRABLE */ + /* ELSE */ + /* EXCLUDE */ + /* DELETE */ + /* TEMPORARY */ + /* TEMP */ + /* OR */ + /* ISNULL */ + /* NULLS */ + /* SAVEPOINT */ + /* INTERSECT */ + /* TIES */ + /* NOTNULL */ + /* NOT */ + /* NO */ + /* NULL */ + /* LIKE */ + /* EXCEPT */ + /* TRANSACTION */ + /* ACTION */ + /* ON */ + /* NATURAL */ + /* ALTER */ + /* RAISE */ + /* EXCLUSIVE */ + /* EXISTS */ + /* CONSTRAINT */ + /* INTO */ + /* OFFSET */ + /* OF */ + /* SET */ + /* TRIGGER */ + /* RANGE */ + /* GENERATED */ + /* DETACH */ + /* HAVING */ + /* GLOB */ + /* BEGIN */ + /* INNER */ + /* REFERENCES */ + /* UNIQUE */ + /* QUERY */ + /* WITHOUT */ + /* WITH */ + /* OUTER */ + /* RELEASE */ + /* ATTACH */ + /* BETWEEN */ + /* NOTHING */ + /* GROUPS */ + /* GROUP */ + /* CASCADE */ + /* ASC */ + /* DEFAULT */ + /* CASE */ + /* COLLATE */ + /* CREATE */ + /* CURRENT_DATE */ + /* IMMEDIATE */ + /* JOIN */ + /* INSERT */ + /* MATCH */ + /* PLAN */ + /* ANALYZE */ + /* PRAGMA */ + /* MATERIALIZED */ + /* DEFERRED */ + /* DISTINCT */ + /* IS */ + /* UPDATE */ + /* VALUES */ + /* VIRTUAL */ + /* ALWAYS */ + /* WHEN */ + /* WHERE */ + /* RECURSIVE */ + /* ABORT */ + /* AFTER */ + /* RENAME */ + /* AND */ + /* DROP */ + /* PARTITION */ + /* AUTOINCREMENT */ + /* TO */ + /* IN */ + /* CAST */ + /* COLUMN */ + /* COMMIT */ + /* CONFLICT */ + /* CROSS */ + /* CURRENT_TIMESTAMP */ + /* CURRENT_TIME */ + /* CURRENT */ + /* PRECEDING */ + /* FAIL */ + /* LAST */ + /* FILTER */ + /* REPLACE */ + /* FIRST */ + /* FOLLOWING */ + /* FROM */ + /* FULL */ + /* LIMIT */ + /* IF */ + /* ORDER */ + /* RESTRICT */ + /* OTHERS */ + /* OVER */ + /* RETURNING */ + /* RIGHT */ + /* ROLLBACK */ + /* ROWS */ + /* ROW */ + /* UNBOUNDED */ + /* UNION */ + /* USING */ + /* VACUUM */ + /* VIEW */ + /* WINDOW */ + /* DO */ + /* BY */ + /* INITIALLY */ + /* ALL */ + /* PRIMARY */ + **(**int32)(__ccgo_up(pType)) = libc.Int32FromUint8(_aKWCode[i]) + break + goto _1 + _1: + ; + i = libc.Int64FromUint8(_aKWNext[i]) + } + return n +} + +var _lagName = [4]uint8{'l', 'a', 'g'} + +var _last_valueName = [11]uint8{'l', 'a', 's', 't', '_', 'v', 'a', 'l', 'u', 'e'} + +var _leadName = [5]uint8{'l', 'e', 'a', 'd'} + +func _lowerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var i, n int32 + var z1, z2 uintptr + _, _, _, _ = i, n, z1, z2 + _ = argc + z2 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + /* Verify that the call to _bytes() does not invalidate the _text() pointer */ + if z2 != 0 { + z1 = _contextMalloc(tls, context, int64(n)+int64(1)) + if z1 != 0 { + i = 0 + for { + if !(i < n) { + break + } + **(**uint8)(__ccgo_up(z1 + uintptr(i))) = _sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(z2 + uintptr(i))))] + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_result_text(tls, context, z1, n, __ccgo_fp(Xsqlite3_free)) + } + } +} + +/* +** Some functions like COALESCE() and IFNULL() and UNLIKELY() are implemented +** as VDBE code so that unused argument values do not have to be computed. +** However, we still need some kind of function implementation for this +** routines in the function table. The noopFunc macro provides this. +** noopFunc will never be called so it doesn't matter what the implementation +** is. We might as well use the "version()" function as a substitute. + */ + +var _nth_valueName = [10]uint8{'n', 't', 'h', '_', 'v', 'a', 'l', 'u', 'e'} + +var _ntileName = [6]uint8{'n', 't', 'i', 'l', 'e'} + +/* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */ +var _nullRow = [6]uint8{ + 0: uint8(6), +} + +/* Set properties of a table column based on the (magical) +** name of the column. + */ + +var _percent_rankName = [13]uint8{'p', 'e', 'r', 'c', 'e', 'n', 't', '_', 'r', 'a', 'n', 'k'} + +// C documentation +// +// /* +// ** Write an entry into the pointer map. +// ** +// ** This routine updates the pointer map entry for page number 'key' +// ** so that it maps to type 'eType' and parent page number 'pgno'. +// ** +// ** If *pRC is initially non-zero (non-SQLITE_OK) then this routine is +// ** a no-op. If an error occurs, the appropriate error code is written +// ** into *pRC. +// */ +func _ptrmapPut(tls *libc.TLS, pBt uintptr, key TPgno, eType Tu8, parent TPgno, pRC uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iPtrmap TPgno + var offset, rc, v1 int32 + var pPtrmap uintptr + var _ /* pDbPage at bp+0 */ uintptr + _, _, _, _, _ = iPtrmap, offset, pPtrmap, rc, v1 /* Return code from subfunctions */ + if **(**int32)(__ccgo_up(pRC)) != 0 { + return + } + /* The super-journal page number must never be used as a pointer map page */ + if key == uint32(0) { + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(74216)) + return + } + iPtrmap = _ptrmapPageno(tls, pBt, key) + rc = _sqlite3PagerGet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, iPtrmap, bp, 0) + if rc != SQLITE_OK { + **(**int32)(__ccgo_up(pRC)) = rc + return + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3PagerGetExtra(tls, **(**uintptr)(__ccgo_up(bp)))))) != 0 { + /* The first byte of the extra data is the MemPage.isInit byte. + ** If that byte is set, it means this page is also being used + ** as a btree page. */ + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(74229)) + goto ptrmap_exit + } + offset = libc.Int32FromUint32(libc.Uint32FromInt32(5) * (key - iPtrmap - libc.Uint32FromInt32(1))) + if offset < 0 { + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(74234)) + goto ptrmap_exit + } + pPtrmap = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + if libc.Int32FromUint8(eType) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pPtrmap + uintptr(offset)))) || _sqlite3Get4byte(tls, pPtrmap+uintptr(offset+int32(1))) != parent { + v1 = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp))) + rc = v1 + **(**int32)(__ccgo_up(pRC)) = v1 + if rc == SQLITE_OK { + **(**Tu8)(__ccgo_up(pPtrmap + uintptr(offset))) = eType + _sqlite3Put4byte(tls, pPtrmap+uintptr(offset+int32(1)), parent) + } + } + goto ptrmap_exit +ptrmap_exit: + ; + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) +} + +var _rankName = [5]uint8{'r', 'a', 'n', 'k'} + +// C documentation +// +// /* +// ** Return a nul-terminated string consisting of nByte comma separated +// ** "?" expressions. For example, if nByte is 3, return a pointer to +// ** a buffer containing the string "?,?,?". +// ** +// ** The memory for the returned string is obtained from sqlite3_malloc(). +// ** It is the responsibility of the caller to eventually free it using +// ** sqlite3_free(). +// ** +// ** If an OOM error is encountered when allocating space for the new +// ** string, an error code is left in the rbu handle passed as the first +// ** argument and NULL is returned. Or, if an error has already occurred +// ** when this function is called, NULL is returned immediately, without +// ** attempting the allocation or modifying the stored error code. +// */ +func _rbuObjIterGetBindlist(tls *libc.TLS, p uintptr, nBind int32) (r uintptr) { + var i, v2 int32 + var nByte Tsqlite3_int64 + var zRet uintptr + _, _, _, _ = i, nByte, zRet, v2 + zRet = uintptr(0) + nByte = int64(2)*int64(nBind) + int64(1) + zRet = _rbuMalloc(tls, p, nByte) + if zRet != 0 { + i = 0 + for { + if !(i < nBind) { + break + } + **(**uint8)(__ccgo_up(zRet + uintptr(i*int32(2)))) = uint8('?') + if i+int32(1) == nBind { + v2 = int32('\000') + } else { + v2 = int32(',') + } + **(**uint8)(__ccgo_up(zRet + uintptr(i*int32(2)+int32(1)))) = libc.Uint8FromInt32(v2) + goto _1 + _1: + ; + i = i + 1 + } + } + return zRet +} + +// C documentation +// +// /* +// ** Static names for the built-in window function names. These static +// ** names are used, rather than string literals, so that FuncDef objects +// ** can be associated with a particular window function by direct +// ** comparison of the zName pointer. Example: +// ** +// ** if( pFuncDef->zName==row_valueName ){ ... } +// */ +var _row_numberName = [11]uint8{'r', 'o', 'w', '_', 'n', 'u', 'm', 'b', 'e', 'r'} + +// C documentation +// +// /* +// ** Set the time to the current time reported by the VFS. +// ** +// ** Return the number of errors. +// */ +func _setDateTimeToCurrent(tls *libc.TLS, context uintptr, p uintptr) (r int32) { + (*TDateTime)(unsafe.Pointer(p)).FiJD = _sqlite3StmtCurrentTime(tls, context) + if (*TDateTime)(unsafe.Pointer(p)).FiJD > 0 { + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + _clearYMD_HMS_TZ(tls, p) + return 0 + } else { + return int32(1) + } + return r +} + +// C documentation +// +// /* +// ** Scan the column type name zType (length nType) and return the +// ** associated affinity type. +// ** +// ** This routine does a case-independent search of zType for the +// ** substrings in the following table. If one of the substrings is +// ** found, the corresponding affinity is returned. If zType contains +// ** more than one of the substrings, entries toward the top of +// ** the table take priority. For example, if zType is 'BLOBINT', +// ** SQLITE_AFF_INTEGER is returned. +// ** +// ** Substring | Affinity +// ** -------------------------------- +// ** 'INT' | SQLITE_AFF_INTEGER +// ** 'CHAR' | SQLITE_AFF_TEXT +// ** 'CLOB' | SQLITE_AFF_TEXT +// ** 'TEXT' | SQLITE_AFF_TEXT +// ** 'BLOB' | SQLITE_AFF_BLOB +// ** 'REAL' | SQLITE_AFF_REAL +// ** 'FLOA' | SQLITE_AFF_REAL +// ** 'DOUB' | SQLITE_AFF_REAL +// ** +// ** If none of the substrings in the above table are found, +// ** SQLITE_AFF_NUMERIC is returned. +// */ +func _sqlite3AffinityType(tls *libc.TLS, zIn uintptr, pCol uintptr) (r uint8) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aff uint8 + var h Tu32 + var x Tu8 + var zChar uintptr + var _ /* v at bp+0 */ int32 + _, _, _, _ = aff, h, x, zChar + h = uint32(0) + aff = uint8(SQLITE_AFF_NUMERIC) + zChar = uintptr(0) + for **(**uint8)(__ccgo_up(zIn)) != 0 { + x = **(**Tu8)(__ccgo_up(zIn)) + h = h< r=(k/4+1) */ + _sqlite3GetInt32(tls, zChar, bp) + break + } + zChar = zChar + 1 + } + } else { + **(**int32)(__ccgo_up(bp)) = int32(16) /* BLOB, TEXT, CLOB -> r=5 (approx 20 bytes)*/ + } + } + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp))/int32(4) + int32(1) + if **(**int32)(__ccgo_up(bp)) > int32(255) { + **(**int32)(__ccgo_up(bp)) = int32(255) + } + (*TColumn)(unsafe.Pointer(pCol)).FszEst = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))) + } + return aff +} + +// C documentation +// +// /* +// ** Write a single UTF8 character whose value is v into the +// ** buffer starting at zOut. zOut must be sized to hold at +// ** least four bytes. Return the number of bytes needed +// ** to encode the new character. +// */ +func _sqlite3AppendOneUtf8Character(tls *libc.TLS, zOut uintptr, v Tu32) (r int32) { + if v < uint32(0x00080) { + **(**uint8)(__ccgo_up(zOut)) = uint8(v & libc.Uint32FromInt32(0xff)) + return int32(1) + } + if v < uint32(0x00800) { + **(**uint8)(__ccgo_up(zOut)) = libc.Uint8FromInt32(int32(0xc0) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1f)))) + **(**uint8)(__ccgo_up(zOut + 1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(v&libc.Uint32FromInt32(0x3f)))) + return int32(2) + } + if v < uint32(0x10000) { + **(**uint8)(__ccgo_up(zOut)) = libc.Uint8FromInt32(int32(0xe0) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0f)))) + **(**uint8)(__ccgo_up(zOut + 1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3f)))) + **(**uint8)(__ccgo_up(zOut + 2)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(v&libc.Uint32FromInt32(0x3f)))) + return int32(3) + } + **(**uint8)(__ccgo_up(zOut)) = libc.Uint8FromInt32(int32(0xf0) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + **(**uint8)(__ccgo_up(zOut + 1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3f)))) + **(**uint8)(__ccgo_up(zOut + 2)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(v>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3f)))) + **(**uint8)(__ccgo_up(zOut + 3)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(v&libc.Uint32FromInt32(0x3f)))) + return int32(4) +} + +// C documentation +// +// /* +// ** Convert zNum to a 64-bit signed integer. zNum must be decimal. This +// ** routine does *not* accept hexadecimal notation. +// ** +// ** Returns: +// ** +// ** -1 Not even a prefix of the input text looks like an integer +// ** 0 Successful transformation. Fits in a 64-bit signed integer. +// ** 1 Excess non-space text after the integer value +// ** 2 Integer too large for a 64-bit signed integer or is malformed +// ** 3 Special case of 9223372036854775808 +// ** +// ** length is the number of bytes in the string (bytes, not characters). +// ** The string is not necessarily zero-terminated. The encoding is +// ** given by enc. +// */ +func _sqlite3Atoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32, enc Tu8) (r int32) { + var c, v3 uint32 + var i, incr, j, jj, neg, nonNum, rc, v6 int32 + var u Tu64 + var zEnd, zStart uintptr + var v4 bool + var v5 int64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, i, incr, j, jj, neg, nonNum, rc, u, zEnd, zStart, v3, v4, v5, v6 + u = uint64(0) + neg = 0 + c = uint32(0) + nonNum = 0 + zEnd = zNum + uintptr(length) + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + incr = int32(1) + } else { + incr = int32(2) + length = length & ^libc.Int32FromInt32(1) + i = int32(3) - libc.Int32FromUint8(enc) + for { + if !(i < length && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zNum + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + int32(2) + } + nonNum = libc.BoolInt32(i < length) + zEnd = zNum + uintptr(i^int32(1)) + zNum = zNum + uintptr(libc.Int32FromUint8(enc)&libc.Int32FromInt32(1)) + } + for zNum < zEnd && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zNum)))])&int32(0x01) != 0 { + zNum = zNum + uintptr(incr) + } + if zNum < zEnd { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zNum))) == int32('-') { + neg = int32(1) + zNum = zNum + uintptr(incr) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zNum))) == int32('+') { + zNum = zNum + uintptr(incr) + } + } + } + zStart = zNum + for zNum < zEnd && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zNum))) == int32('0') { + zNum = zNum + uintptr(incr) + } /* Skip leading zeros. */ + i = 0 + for { + if v4 = zNum+uintptr(i) < zEnd; v4 { + v3 = uint32(**(**uint8)(__ccgo_up(zNum + uintptr(i)))) - libc.Uint32FromUint8('0') + c = v3 + } + if !(v4 && v3 <= uint32(9)) { + break + } + u = u*uint64(10) + uint64(c) + goto _2 + _2: + ; + i = i + incr + } + if u > libc.Uint64FromInt64(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< int32(19)*incr { + v6 = int32(1) + } else { + v6 = _compare2pow63(tls, zNum, incr) + } + j = v6 + if j < 0 { + /* zNum is less than 9223372036854775808 so it fits */ + return rc + } else { + if neg != 0 { + v5 = int64(-libc.Int32FromInt32(1)) - (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< 0 { + /* zNum is greater than 9223372036854775808 so it overflows */ + return int32(2) + } else { + /* zNum is exactly 9223372036854775808. Fits if negative. The + ** special case 2 overflow if positive */ + if neg != 0 { + v6 = rc + } else { + v6 = int32(3) + } + return v6 + } + } + } + return r +} + +// C documentation +// +// /* +// ** Return the collating sequence name for a column +// */ +func _sqlite3ColumnColl(tls *libc.TLS, pCol uintptr) (r uintptr) { + var z uintptr + _ = z + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASCOLL) == 0 { + return uintptr(0) + } + z = (*TColumn)(unsafe.Pointer(pCol)).FzCnName + for **(**uint8)(__ccgo_up(z)) != 0 { + z = z + 1 + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { + for cond := true; cond; cond = **(**uint8)(__ccgo_up(z)) != 0 { + z = z + 1 + } + } + return z + uintptr(1) +} + +// C documentation +// +// /* +// ** pExpr is an operand of a comparison operator. aff2 is the +// ** type affinity of the other operand. This routine returns the +// ** type affinity that should be used for the comparison operator. +// */ +func _sqlite3CompareAffinity(tls *libc.TLS, pExpr uintptr, aff2 uint8) (r uint8) { + var aff1 uint8 + var v1 int32 + _, _ = aff1, v1 + aff1 = _sqlite3ExprAffinity(tls, pExpr) + if libc.Int32FromUint8(aff1) > int32(SQLITE_AFF_NONE) && libc.Int32FromUint8(aff2) > int32(SQLITE_AFF_NONE) { + /* Both sides of the comparison are columns. If one has numeric + ** affinity, use that. Otherwise use no affinity. + */ + if libc.Int32FromUint8(aff1) >= int32(SQLITE_AFF_NUMERIC) || libc.Int32FromUint8(aff2) >= int32(SQLITE_AFF_NUMERIC) { + return uint8(SQLITE_AFF_NUMERIC) + } else { + return uint8(SQLITE_AFF_BLOB) + } + } else { + /* One side is a column, the other is not. Use the columns affinity. */ + if libc.Int32FromUint8(aff1) <= int32(SQLITE_AFF_NONE) { + v1 = libc.Int32FromUint8(aff2) + } else { + v1 = libc.Int32FromUint8(aff1) + } + return libc.Uint8FromInt32(v1 | int32(SQLITE_AFF_NONE)) + } + return r +} + +// C documentation +// +// /* +// ** Convert an SQL-style quoted string into a normal string by removing +// ** the quote characters. The conversion is done in-place. If the +// ** input does not begin with a quote character, then this routine +// ** is a no-op. +// ** +// ** The input string must be zero-terminated. A new zero-terminator +// ** is added to the dequoted string. +// ** +// ** The return value is -1 if no dequoting occurs or the length of the +// ** dequoted string, exclusive of the zero terminator, if dequoting does +// ** occur. +// ** +// ** 2002-02-14: This routine is extended to remove MS-Access style +// ** brackets from around identifiers. For example: "[a-b-c]" becomes +// ** "a-b-c". +// */ +func _sqlite3Dequote(tls *libc.TLS, z uintptr) { + var i, j, v2 int32 + var quote uint8 + _, _, _, _ = i, j, quote, v2 + if z == uintptr(0) { + return + } + quote = **(**uint8)(__ccgo_up(z)) + if !(libc.Int32FromUint8(_sqlite3CtypeMap[quote])&libc.Int32FromInt32(0x80) != 0) { + return + } + if libc.Int32FromUint8(quote) == int32('[') { + quote = uint8(']') + } + i = int32(1) + j = libc.Int32FromInt32(0) + for { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == libc.Int32FromUint8(quote) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+int32(1))))) == libc.Int32FromUint8(quote) { + v2 = j + j = j + 1 + **(**uint8)(__ccgo_up(z + uintptr(v2))) = quote + i = i + 1 + } else { + break + } + } else { + v2 = j + j = j + 1 + **(**uint8)(__ccgo_up(z + uintptr(v2))) = **(**uint8)(__ccgo_up(z + uintptr(i))) + } + goto _1 + _1: + ; + i = i + 1 + } + **(**uint8)(__ccgo_up(z + uintptr(j))) = uint8(0) +} + +func _sqlite3DequoteExpr(tls *libc.TLS, p uintptr) { + var v1 int32 + _ = v1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(p + 8))))) == int32('"') { + v1 = libc.Int32FromInt32(EP_Quoted) | libc.Int32FromInt32(EP_DblQuoted) + } else { + v1 = int32(EP_Quoted) + } + **(**Tu32)(__ccgo_up(p + 4)) |= libc.Uint32FromInt32(v1) + _sqlite3Dequote(tls, *(*uintptr)(unsafe.Pointer(p + 8))) +} + +// C documentation +// +// /* +// ** Digit pairs used to convert a U64 or I64 into text, two digits +// ** at a time. +// */ +var _sqlite3DigitPairs = *(*struct { + FforceAlignment [0]int16 + Fa [201]uint8 + F__ccgo_pad2 [1]byte +})(unsafe.Pointer(&struct { + f [201]uint8 + _ [1]byte +}{f: [201]uint8{'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'}})) + +/* +** ARMv6, ARMv7, PPC32 are known to not support hardware u64 division. + */ + +// C documentation +// +// /* +// ** Return TRUE if the given expression is a constant which would be +// ** unchanged by OP_Affinity with the affinity given in the second +// ** argument. +// ** +// ** This routine is used to determine if the OP_Affinity operation +// ** can be omitted. When in doubt return FALSE. A false negative +// ** is harmless. A false positive, however, can result in the wrong +// ** answer. +// */ +func _sqlite3ExprNeedsNoAffinityChange(tls *libc.TLS, p uintptr, aff uint8) (r int32) { + var op Tu8 + var unaryMinus int32 + _, _ = op, unaryMinus + unaryMinus = 0 + if libc.Int32FromUint8(aff) == int32(SQLITE_AFF_BLOB) { + return int32(1) + } + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UPLUS) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UMINUS) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UMINUS) { + unaryMinus = int32(1) + } + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + } + op = (*TExpr)(unsafe.Pointer(p)).Fop + if libc.Int32FromUint8(op) == int32(TK_REGISTER) { + op = (*TExpr)(unsafe.Pointer(p)).Fop2 + } + switch libc.Int32FromUint8(op) { + case int32(TK_INTEGER): + return libc.BoolInt32(libc.Int32FromUint8(aff) >= int32(SQLITE_AFF_NUMERIC)) + case int32(TK_FLOAT): + return libc.BoolInt32(libc.Int32FromUint8(aff) >= int32(SQLITE_AFF_NUMERIC)) + case int32(TK_STRING): + return libc.BoolInt32(!(unaryMinus != 0) && libc.Int32FromUint8(aff) == int32(SQLITE_AFF_TEXT)) + case int32(TK_BLOB): + return libc.BoolInt32(!(unaryMinus != 0)) + case int32(TK_COLUMN): + /* p cannot be part of a CHECK constraint */ + return libc.BoolInt32(libc.Int32FromUint8(aff) >= int32(SQLITE_AFF_NUMERIC) && int32((*TExpr)(unsafe.Pointer(p)).FiColumn) < 0) + default: + return 0 + } + return r +} + +// C documentation +// +// /* +// ** The argument must be a TK_TRUEFALSE Expr node. Return 1 if it is TRUE +// ** and 0 if it is FALSE. +// */ +func _sqlite3ExprTruthValue(tls *libc.TLS, pExpr uintptr) (r int32) { + pExpr = _sqlite3ExprSkipCollateAndLikely(tls, pExpr) + return libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pExpr + 8)) + 4))) == 0) +} + +// C documentation +// +// /* +// ** Value pVal is guaranteed to be an fts5_locale() value, according to +// ** sqlite3Fts5IsLocaleValue(). This function extracts the text and locale +// ** from the value and returns them separately. +// ** +// ** If successful, SQLITE_OK is returned and (*ppText) and (*ppLoc) set +// ** to point to buffers containing the text and locale, as utf-8, +// ** respectively. In this case output parameters (*pnText) and (*pnLoc) are +// ** set to the sizes in bytes of these two buffers. +// ** +// ** Or, if an error occurs, then an SQLite error code is returned. The final +// ** value of the four output parameters is undefined in this case. +// */ +func _sqlite3Fts5DecodeLocaleValue(tls *libc.TLS, pVal uintptr, ppText uintptr, pnText uintptr, ppLoc uintptr, pnLoc uintptr) (r int32) { + var n, nLoc int32 + var p uintptr + _, _, _ = n, nLoc, p + p = Xsqlite3_value_blob(tls, pVal) + n = Xsqlite3_value_bytes(tls, pVal) + nLoc = 0 + nLoc = libc.Int32FromInt64(16) + for { + if !(**(**uint8)(__ccgo_up(p + uintptr(nLoc))) != 0) { + break + } + if nLoc == n-int32(1) { + return int32(SQLITE_MISMATCH) + } + goto _1 + _1: + ; + nLoc = nLoc + 1 + } + **(**uintptr)(__ccgo_up(ppLoc)) = p + uintptr(libc.Int32FromInt64(16)) + **(**int32)(__ccgo_up(pnLoc)) = nLoc - libc.Int32FromInt64(16) + **(**uintptr)(__ccgo_up(ppText)) = p + uintptr(nLoc+int32(1)) + **(**int32)(__ccgo_up(pnText)) = n - nLoc - int32(1) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Convert an SQL-style quoted string into a normal string by removing +// ** the quote characters. The conversion is done in-place. If the +// ** input does not begin with a quote character, then this routine +// ** is a no-op. +// ** +// ** Examples: +// ** +// ** "abc" becomes abc +// ** 'xyz' becomes xyz +// ** [pqr] becomes pqr +// ** `mno` becomes mno +// */ +func _sqlite3Fts5Dequote(tls *libc.TLS, z uintptr) { + var quote uint8 + _ = quote /* Quote character (if any ) */ + quote = **(**uint8)(__ccgo_up(z)) + if libc.Int32FromUint8(quote) == int32('[') || libc.Int32FromUint8(quote) == int32('\'') || libc.Int32FromUint8(quote) == int32('"') || libc.Int32FromUint8(quote) == int32('`') { + _fts5Dequote(tls, z) + } +} + +// C documentation +// +// /* +// ** Argument p points to a buffer containing utf-8 text that is n bytes in +// ** size. Return the number of bytes in the nChar character prefix of the +// ** buffer, or 0 if there are less than nChar characters in total. +// */ +func _sqlite3Fts5IndexCharlenToBytelen(tls *libc.TLS, p uintptr, nByte int32, nChar int32) (r int32) { + var i, n, v2 int32 + _, _, _ = i, n, v2 + n = 0 + i = 0 + for { + if !(i < nChar) { + break + } + if n >= nByte { + return 0 + } /* Input contains fewer than nChar chars */ + v2 = n + n = n + 1 + if libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(p + uintptr(v2))))) >= int32(0xc0) { + if n >= nByte { + return 0 + } + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(p + uintptr(n))))&int32(0xc0) == int32(0x80) { + n = n + 1 + if n >= nByte { + if i+int32(1) == nChar { + break + } + return 0 + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + return n +} + +// C documentation +// +// /* +// ** Return a simple checksum value based on the arguments. +// */ +func _sqlite3Fts5IndexEntryCksum(tls *libc.TLS, iRowid Ti64, iCol int32, iPos int32, iIdx int32, pTerm uintptr, nTerm int32) (r Tu64) { + var i int32 + var ret Tu64 + _, _ = i, ret + ret = libc.Uint64FromInt64(iRowid) + ret = ret + (ret<= 0 { + ret = ret + (ret< uint64(4294967296) { + **(**Tu32)(__ccgo_up(pI)) = uint32(0) + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + if i == 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) != 0 { + **(**Tu32)(__ccgo_up(pI)) = uint32(0) + return 0 + } + **(**Tu32)(__ccgo_up(pI)) = uint32(v) + return int32(1) +} + +/* +** The variable-length integer encoding is as follows: +** +** KEY: +** A = 0xxxxxxx 7 bits of data and one flag bit +** B = 1xxxxxxx 7 bits of data and one flag bit +** C = xxxxxxxx 8 bits of data +** +** 7 bits - A +** 14 bits - BA +** 21 bits - BBA +** 28 bits - BBBA +** 35 bits - BBBBA +** 42 bits - BBBBBA +** 49 bits - BBBBBBA +** 56 bits - BBBBBBBA +** 64 bits - BBBBBBBBC + */ + +// C documentation +// +// /* +// ** Convert a BLOB literal of the form "x'hhhhhh'" into its binary +// ** value. Return a pointer to its binary value. Space to hold the +// ** binary value has been obtained from malloc and must be freed by +// ** the calling routine. +// */ +func _sqlite3HexToBlob(tls *libc.TLS, db uintptr, z uintptr, n int32) (r uintptr) { + var i int32 + var zBlob uintptr + _, _ = i, zBlob + zBlob = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(n/int32(2)+int32(1))) + n = n - 1 + if zBlob != 0 { + i = 0 + for { + if !(i < n) { + break + } + **(**uint8)(__ccgo_up(zBlob + uintptr(i/int32(2)))) = libc.Uint8FromInt32(libc.Int32FromUint8(_sqlite3HexToInt(tls, libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i))))))<= int32(SQLITE_AFF_NUMERIC)) +} + +// C documentation +// +// /* +// ** Return the affinity for a single column of an index. +// */ +func _sqlite3IndexColumnAffinity(tls *libc.TLS, db uintptr, pIdx uintptr, iCol int32) (r uint8) { + if !((*TIndex)(unsafe.Pointer(pIdx)).FzColAff != 0) { + if _sqlite3IndexAffinityStr(tls, db, pIdx) == uintptr(0) { + return uint8(SQLITE_AFF_BLOB) + } + } + return **(**uint8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FzColAff + uintptr(iCol))) +} + +// C documentation +// +// /* +// ** Check to see if pExpr is one of the indexed expressions on pParse->pIdxEpr. +// ** If it is, then resolve the expression by reading from the index and +// ** return the register into which the value has been read. If pExpr is +// ** not an indexed expression, then return negative. +// */ +func _sqlite3IndexedExprLookup(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) (r int32) { + var addr, iDataCur int32 + var exprAff Tu8 + var p, v uintptr + _, _, _, _, _ = addr, exprAff, iDataCur, p, v + p = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + for { + if !(p != 0) { + break + } + iDataCur = (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur + if iDataCur < 0 { + goto _1 + } + if (*TParse)(unsafe.Pointer(pParse)).FiSelfTab != 0 { + if (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur != (*TParse)(unsafe.Pointer(pParse)).FiSelfTab-int32(1) { + goto _1 + } + iDataCur = -int32(1) + } + if _sqlite3ExprCompare(tls, uintptr(0), pExpr, (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr, iDataCur) != 0 { + goto _1 + } + exprAff = _sqlite3ExprAffinity(tls, pExpr) + if libc.Int32FromUint8(exprAff) <= int32(SQLITE_AFF_BLOB) && libc.Int32FromUint8((*TIndexedExpr)(unsafe.Pointer(p)).Faff) != int32(SQLITE_AFF_BLOB) || libc.Int32FromUint8(exprAff) == int32(SQLITE_AFF_TEXT) && libc.Int32FromUint8((*TIndexedExpr)(unsafe.Pointer(p)).Faff) != int32(SQLITE_AFF_TEXT) || libc.Int32FromUint8(exprAff) >= int32(SQLITE_AFF_NUMERIC) && libc.Int32FromUint8((*TIndexedExpr)(unsafe.Pointer(p)).Faff) != int32(SQLITE_AFF_NUMERIC) { + /* Affinity mismatch on a generated column */ + goto _1 + } + /* Functions that might set a subtype should not be replaced by the + ** value taken from an expression index if they are themselves an + ** argument to another scalar function or aggregate. + ** https://sqlite.org/forum/forumpost/68d284c86b082c3e */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromUint32(EP_SubtArg) != uint32(0) && _sqlite3ExprCanReturnSubtype(tls, pParse, pExpr) != 0 { + goto _1 + } + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if (*TIndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow != 0 { + /* If the index is on a NULL row due to an outer join, then we + ** cannot extract the value from the index. The value must be + ** computed using the original expression. */ + addr = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNullRow), (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur, addr+int32(3), target) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur, (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol, target) + _sqlite3VdbeGoto(tls, v, 0) + p = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr = uintptr(0) + _sqlite3ExprCode(tls, pParse, pExpr, target) + (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr = p + _sqlite3VdbeJumpHere(tls, v, addr+int32(2)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur, (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol, target) + } + return target + goto _1 + _1: + ; + p = (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext + } + return -int32(1) /* Not found */ +} + +// C documentation +// +// /* +// ** This routine implements the uncommon and slower path for +// ** sqlite3MemRealValueRC() that has to deal with input strings +// ** that are not UTF8 or that are not zero-terminated. It is +// ** broken out into a separate no-inline routine so that the +// ** main sqlite3MemRealValueRC() routine can avoid unnecessary +// ** stack pushes. +// ** +// ** A text->float translation of pMem->z is written into *pValue. +// ** +// ** Result code invariants: +// ** +// ** rc==0 => ERROR: Input string not well-formed, or OOM +// ** rc<0 => Some prefix of the input is well-formed +// ** rc>0 => All of the input is well-formed +// ** (rc&2)==0 => The number is expressed as an integer, with no +// ** decimal point or eNNN suffix. +// */ +func _sqlite3MemRealValueRCSlowPath(tls *libc.TLS, pMem uintptr, pValue uintptr) (r int32) { + var i, j, n, rc, v2 int32 + var z, zCopy, zCopy1 uintptr + _, _, _, _, _, _, _, _ = i, j, n, rc, z, zCopy, zCopy1, v2 + rc = SQLITE_OK + **(**float64)(__ccgo_up(pValue)) = float64(0) + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) == int32(SQLITE_UTF8) { + zCopy = _sqlite3DbStrNDup(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn)) + if zCopy != 0 { + rc = _sqlite3AtoF(tls, zCopy, pValue) + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, zCopy) + } + return rc + } else { + n = (*TMem)(unsafe.Pointer(pMem)).Fn & ^libc.Int32FromInt32(1) + zCopy1 = _sqlite3DbMallocRaw(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, libc.Uint64FromInt32(n/int32(2)+int32(2))) + if zCopy1 != 0 { + z = (*TMem)(unsafe.Pointer(pMem)).Fz + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) == int32(SQLITE_UTF16LE) { + v2 = libc.Int32FromInt32(0) + j = v2 + i = v2 + for { + if !(i < n-int32(1)) { + break + } + **(**uint8)(__ccgo_up(zCopy1 + uintptr(j))) = **(**uint8)(__ccgo_up(z + uintptr(i))) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+int32(1))))) != 0 { + break + } + goto _1 + _1: + ; + i = i + int32(2) + j = j + 1 + } + } else { + v2 = libc.Int32FromInt32(0) + j = v2 + i = v2 + for { + if !(i < n-int32(1)) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) != 0 { + break + } + **(**uint8)(__ccgo_up(zCopy1 + uintptr(j))) = **(**uint8)(__ccgo_up(z + uintptr(i+int32(1)))) + goto _3 + _3: + ; + i = i + int32(2) + j = j + 1 + } + } + **(**uint8)(__ccgo_up(zCopy1 + uintptr(j))) = uint8(0) + rc = _sqlite3AtoF(tls, zCopy1, pValue) + if i < n { + rc = -int32(100) + } + _sqlite3DbFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, zCopy1) + } + return rc + } + return r +} + +func _sqlite3OsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nPathOut int32, zPathOut uintptr) (r int32) { + **(**uint8)(__ccgo_up(zPathOut)) = uint8(0) + return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxFullPathname})))(tls, pVfs, zPath, nPathOut, zPathOut) +} + +var _sqlite3StdTypeAffinity = [6]uint8{ + 0: uint8(SQLITE_AFF_NUMERIC), + 1: uint8(SQLITE_AFF_BLOB), + 2: uint8(SQLITE_AFF_INTEGER), + 3: uint8(SQLITE_AFF_INTEGER), + 4: uint8(SQLITE_AFF_REAL), + 5: uint8(SQLITE_AFF_TEXT), +} + +func _sqlite3StrAccumFinish(tls *libc.TLS, p uintptr) (r uintptr) { + if (*TStrAccum)(unsafe.Pointer(p)).FzText != 0 { + **(**uint8)(__ccgo_up((*TStrAccum)(unsafe.Pointer(p)).FzText + uintptr((*TStrAccum)(unsafe.Pointer(p)).FnChar))) = uint8(0) + if (*TStrAccum)(unsafe.Pointer(p)).FmxAlloc > uint32(0) && !(libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED) != libc.Int32FromInt32(0)) { + return _strAccumFinishRealloc(tls, p) + } + } + return (*TStrAccum)(unsafe.Pointer(p)).FzText +} + +// C documentation +// +// /* +// ** Name of the default collating sequence +// */ +var _sqlite3StrBINARY = [7]uint8{'B', 'I', 'N', 'A', 'R', 'Y'} + +// C documentation +// +// /* +// ** Compute an 8-bit hash on a string that is insensitive to case differences +// */ +func _sqlite3StrIHash(tls *libc.TLS, z uintptr) (r Tu8) { + var h Tu8 + _ = h + h = uint8(0) + if z == uintptr(0) { + return uint8(0) + } + for **(**uint8)(__ccgo_up(z)) != 0 { + h = libc.Uint8FromInt32(int32(h) + libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(z)))])) + z = z + 1 + } + return h +} + +// C documentation +// +// /* +// ** Exported version of applyAffinity(). This one works on sqlite3_value*, +// ** not the internal Mem* type. +// */ +func _sqlite3ValueApplyAffinity(tls *libc.TLS, pVal uintptr, affinity Tu8, enc Tu8) { + _applyAffinity(tls, pVal, affinity, enc) +} + +// C documentation +// +// /* +// ** Move data out of a btree key or data field and into a Mem structure. +// ** The data is payload from the entry that pCur is currently pointing +// ** to. offset and amt determine what portion of the data or key to retrieve. +// ** The result is written into the pMem element. +// ** +// ** The pMem object must have been initialized. This routine will use +// ** pMem->zMalloc to hold the content from the btree, if possible. New +// ** pMem->zMalloc space will be allocated if necessary. The calling routine +// ** is responsible for making sure that the pMem object is eventually +// ** destroyed. +// ** +// ** If this routine fails for any reason (malloc returns NULL or unable +// ** to read from the disk) then the pMem is left in an inconsistent state. +// */ +func _sqlite3VdbeMemFromBtree(tls *libc.TLS, pCur uintptr, offset Tu32, amt Tu32, pMem uintptr) (r int32) { + var rc, v1 int32 + _, _ = rc, v1 + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Null) + if amt >= uint32(SQLITE_MAX_ALLOCATION_SIZE) { + return int32(SQLITE_NOMEM) + } + if uint64(amt)+uint64(offset) > libc.Uint64FromInt64(_sqlite3BtreeMaxRecordSize(tls, pCur)) { + return _sqlite3CorruptError(tls, int32(86966)) + } + v1 = _sqlite3VdbeMemClearAndResize(tls, pMem, libc.Int32FromUint32(amt+uint32(1))) + rc = v1 + if SQLITE_OK == v1 { + rc = _sqlite3BtreePayload(tls, pCur, offset, amt, (*TMem)(unsafe.Pointer(pMem)).Fz) + if rc == SQLITE_OK { + **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr(amt))) = uint8(0) /* Overrun area used when reading malformed records */ + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Blob) + (*TMem)(unsafe.Pointer(pMem)).Fn = libc.Int32FromUint32(amt) + } else { + _sqlite3VdbeMemRelease(tls, pMem) + } + } + return rc +} + +// C documentation +// +// /* +// ** Generate code that initializes multiple registers to string or integer +// ** constants. The registers begin with iDest and increase consecutively. +// ** One register is initialized for each characgter in zTypes[]. For each +// ** "s" character in zTypes[], the register is a string if the argument is +// ** not NULL, or OP_Null if the value is a null pointer. For each "i" character +// ** in zTypes[], the register is initialized to an integer. +// ** +// ** If the input string does not end with "X" then an OP_ResultRow instruction +// ** is generated for the values inserted. +// */ +func _sqlite3VdbeMultiLoad(tls *libc.TLS, p uintptr, iDest int32, zTypes uintptr, va uintptr) { + var ap Tva_list + var c, v2 uint8 + var i, v3 int32 + var z uintptr + _, _, _, _, _, _ = ap, c, i, z, v2, v3 + ap = va + i = 0 + for { + v2 = **(**uint8)(__ccgo_up(zTypes + uintptr(i))) + c = v2 + if !(libc.Int32FromUint8(v2) != 0) { + break + } + if libc.Int32FromUint8(c) == int32('s') { + z = libc.VaUintptr(&ap) + if z == uintptr(0) { + v3 = int32(OP_Null) + } else { + v3 = int32(OP_String8) + } + _sqlite3VdbeAddOp4(tls, p, v3, 0, iDest+i, 0, z, 0) + } else { + if libc.Int32FromUint8(c) == int32('i') { + _sqlite3VdbeAddOp2(tls, p, int32(OP_Integer), libc.VaInt32(&ap), iDest+i) + } else { + goto skip_op_resultrow + } + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, p, int32(OP_ResultRow), iDest, i) + goto skip_op_resultrow +skip_op_resultrow: + ; + _ = ap +} + +// C documentation +// +// /* +// ** Elements of sqlite3Stat[] are protected by either the memory allocator +// ** mutex, or by the pcache1 mutex. The following array determines which. +// */ +var _statMutex = [10]uint8{ + 1: uint8(1), + 2: uint8(1), + 7: uint8(1), +} + +/* The "wsdStat" macro will resolve to the status information +** state vector. If writable static data is unsupported on the target, +** we have to locate the state vector at run-time. In the more common +** case where writable static data is supported, wsdStat can refer directly +** to the "sqlite3Stat" state vector declared above. + */ + +// C documentation +// +// /* +// ** The hashing function. +// */ +func _strHash(tls *libc.TLS, z uintptr) (r uint32) { + var h uint32 + var v1 uintptr + _, _ = h, v1 + h = uint32(0) + for **(**uint8)(__ccgo_up(z)) != 0 { /*OPTIMIZATION-IF-TRUE*/ + /* Knuth multiplicative hashing. (Sorting & Searching, p. 510). + ** 0x9e3779b1 is 2654435761 which is the closest prime number to + ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. + ** + ** Only bits 0xdf for ASCII and bits 0xbf for EBCDIC each octet are + ** hashed since the omitted bits determine the upper/lower case difference. + */ + v1 = z + z = z + 1 + h = h + libc.Uint32FromInt32(int32(0xdf)&libc.Int32FromUint8(uint8(**(**uint8)(__ccgo_up(v1))))) + h = h * uint32(0x9e3779b1) + } + return h +} + +// C documentation +// +// /* +// ** We already know that pExpr is a binary operator where both operands are +// ** column references. This routine checks to see if pExpr is an equivalence +// ** relation: +// ** 1. The SQLITE_Transitive optimization must be enabled +// ** 2. Must be either an == or an IS operator +// ** 3. Not originating in the ON clause of an OUTER JOIN +// ** 4. The operator is not IS or else the query does not contain RIGHT JOIN +// ** 5. The affinities of A and B must be compatible +// ** 6. Both operands use the same collating sequence, and they must not +// ** use explicit COLLATE clauses. +// ** If this routine returns TRUE, that means that the RHS can be substituted +// ** for the LHS anyplace else in the WHERE clause where the LHS column occurs. +// ** This is an optimization. No harm comes from returning 0. But if 1 is +// ** returned when it should not be, then incorrect answers might result. +// */ +func _termIsEquivalence(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSrc uintptr) (r int32) { + var aff1, aff2 uint8 + _, _ = aff1, aff2 + if !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Transitive)) == libc.Uint32FromInt32(0)) { + return 0 + } /* (1) */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_EQ) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_IS) { + return 0 + } /* (2) */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_Collate)) != uint32(0) { + return 0 + } /* (3) */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IS) && (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc >= int32(2) && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + return 0 /* (4) */ + } + aff1 = _sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + aff2 = _sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if libc.Int32FromUint8(aff1) != libc.Int32FromUint8(aff2) && (!(libc.Int32FromUint8(aff1) >= libc.Int32FromInt32(SQLITE_AFF_NUMERIC)) || !(libc.Int32FromUint8(aff2) >= libc.Int32FromInt32(SQLITE_AFF_NUMERIC))) { + return 0 /* (5) */ + } + if !(_sqlite3ExprCollSeqMatch(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) != 0) { + return 0 /* (6) */ + } + return int32(1) +} + +// C documentation +// +// /* +// ** Duplicate a range of text from an SQL statement, then convert all +// ** whitespace characters into ordinary space characters. +// */ +func _triggerSpanDup(tls *libc.TLS, db uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var i int32 + var z uintptr + _, _ = i, z + z = _sqlite3DbSpanDup(tls, db, zStart, zEnd) + if z != 0 { + i = 0 + for { + if !(**(**uint8)(__ccgo_up(z + uintptr(i))) != 0) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(i))))])&int32(0x01) != 0 { + **(**uint8)(__ccgo_up(z + uintptr(i))) = uint8(' ') + } + goto _1 + _1: + ; + i = i + 1 + } + } + return z +} + +// C documentation +// +// /* +// ** Expression pRight, which is the RHS of a comparison operation, is +// ** either a vector of n elements or, if n==1, a scalar expression. +// ** Before the comparison operation, affinity zAff is to be applied +// ** to the pRight values. This function modifies characters within the +// ** affinity string to SQLITE_AFF_BLOB if either: +// ** +// ** * the comparison will be performed with no affinity, or +// ** * the affinity change in zAff is guaranteed not to change the value. +// */ +func _updateRangeAffinityStr(tls *libc.TLS, pRight uintptr, n int32, zAff uintptr) { + var i int32 + var p uintptr + _, _ = i, p + i = 0 + for { + if !(i < n) { + break + } + p = _sqlite3VectorFieldSubexpr(tls, pRight, i) + if libc.Int32FromUint8(_sqlite3CompareAffinity(tls, p, **(**uint8)(__ccgo_up(zAff + uintptr(i))))) == int32(SQLITE_AFF_BLOB) || _sqlite3ExprNeedsNoAffinityChange(tls, p, **(**uint8)(__ccgo_up(zAff + uintptr(i)))) != 0 { + **(**uint8)(__ccgo_up(zAff + uintptr(i))) = uint8(SQLITE_AFF_BLOB) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Implementation of the upper() and lower() SQL functions. +// */ +func _upperFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var i, n int32 + var z1, z2 uintptr + _, _, _, _ = i, n, z1, z2 + _ = argc + z2 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + /* Verify that the call to _bytes() does not invalidate the _text() pointer */ + if z2 != 0 { + z1 = _contextMalloc(tls, context, int64(n)+int64(1)) + if z1 != 0 { + i = 0 + for { + if !(i < n) { + break + } + **(**uint8)(__ccgo_up(z1 + uintptr(i))) = libc.Uint8FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z2 + uintptr(i)))) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z2 + uintptr(i))))]) & libc.Int32FromInt32(0x20))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_result_text(tls, context, z1, n, __ccgo_fp(Xsqlite3_free)) + } + } +} + +// C documentation +// +// /* +// ** This routine does the core work of extracting URI parameters from a +// ** database filename for the sqlite3_uri_parameter() interface. +// */ +func _uriParameter(tls *libc.TLS, zFilename uintptr, zParam uintptr) (r uintptr) { + var x int32 + _ = x + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + for zFilename != uintptr(0) && **(**uint8)(__ccgo_up(zFilename)) != 0 { + x = libc.Xstrcmp(tls, zFilename, zParam) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + if x == 0 { + return zFilename + } + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Write a 32-bit integer into the given file descriptor. Return SQLITE_OK +// ** on success or an error code is something goes wrong. +// */ +func _write32bits(tls *libc.TLS, fd uintptr, offset Ti64, val Tu32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ac at bp+0 */ [4]uint8 + _sqlite3Put4byte(tls, bp, val) + return _sqlite3OsWrite(tls, fd, bp, int32(4), offset) +} + +var _zAff = [10]uint8{'B', 0, 'C', 0, 'D', 0, 'E', 0, 'F'} + +// C documentation +// +// /* +// ** Page paths: +// ** +// ** The value of the 'path' column describes the path taken from the +// ** root-node of the b-tree structure to each page. The value of the +// ** root-node path is '/'. +// ** +// ** The value of the path for the left-most child page of the root of +// ** a b-tree is '/000/'. (Btrees store content ordered from left to right +// ** so the pages to the left have smaller keys than the pages to the right.) +// ** The next to left-most child of the root page is +// ** '/001', and so on, each sibling page identified by a 3-digit hex +// ** value. The children of the 451st left-most sibling have paths such +// ** as '/1c2/000/, '/1c2/001/' etc. +// ** +// ** Overflow pages are specified by appending a '+' character and a +// ** six-digit hexadecimal value to the path to the cell they are linked +// ** from. For example, the three overflow pages in a chain linked from +// ** the left-most cell of the 450th child of the root page are identified +// ** by the paths: +// ** +// ** '/1c2/000+000000' // First page in overflow chain +// ** '/1c2/000+000001' // Second page in overflow chain +// ** '/1c2/000+000002' // Third page in overflow chain +// ** +// ** If the paths are sorted using the BINARY collation sequence, then +// ** the overflow pages associated with a cell will appear earlier in the +// ** sort-order than its child page: +// ** +// ** '/1c2/000/' // Left-most child of 451st child of root +// */ +var _zDbstatSchema = [258]uint8{'C', 'R', 'E', 'A', 'T', 'E', ' ', 'T', 'A', 'B', 'L', 'E', ' ', 'x', '(', ' ', 'n', 'a', 'm', 'e', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'E', 'X', 'T', ',', ' ', 'p', 'a', 't', 'h', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'E', 'X', 'T', ',', ' ', 'p', 'a', 'g', 'e', 'n', 'o', ' ', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'p', 'a', 'g', 'e', 't', 'y', 'p', 'e', ' ', ' ', ' ', 'T', 'E', 'X', 'T', ',', ' ', 'n', 'c', 'e', 'l', 'l', ' ', ' ', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'p', 'a', 'y', 'l', 'o', 'a', 'd', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'u', 'n', 'u', 's', 'e', 'd', ' ', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'm', 'x', '_', 'p', 'a', 'y', 'l', 'o', 'a', 'd', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'p', 'g', 'o', 'f', 'f', 's', 'e', 't', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'p', 'g', 's', 'i', 'z', 'e', ' ', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 's', 'c', 'h', 'e', 'm', 'a', ' ', ' ', ' ', ' ', ' ', 'T', 'E', 'X', 'T', ' ', 'H', 'I', 'D', 'D', 'E', 'N', ',', ' ', 'a', 'g', 'g', 'r', 'e', 'g', 'a', 't', 'e', ' ', ' ', 'B', 'O', 'O', 'L', 'E', 'A', 'N', ' ', 'H', 'I', 'D', 'D', 'E', 'N', ')'} + +var _zFake = [8]uint8{} + +// C documentation +// +// /* +// ** The sqlite3KeywordCode function looks up an identifier to determine if +// ** it is a keyword. If it is a keyword, the token code of that keyword is +// ** returned. If the input is not a keyword, TK_ID is returned. +// ** +// ** The implementation of this routine was generated by a program, +// ** mkkeywordhash.c, located in the tool subdirectory of the distribution. +// ** The output of the mkkeywordhash.c program is written into a file +// ** named keywordhash.h and then included into this source file by +// ** the #include below. +// */ +// /************** Include keywordhash.h in the middle of tokenize.c ************/ +// /************** Begin file keywordhash.h *************************************/ +// /***** This file contains automatically generated code ****** +// ** +// ** The code in this file has been automatically generated by +// ** +// ** sqlite/tool/mkkeywordhash.c +// ** +// ** The code in this file implements a function that determines whether +// ** or not a given identifier is really an SQL keyword. The same thing +// ** might be implemented more directly using a hand-written hash table. +// ** But by using this automatically generated code, the size of the code +// ** is substantially reduced. This is important for embedded applications +// ** on platforms with limited memory. +// */ +// /* Hash score: 231 */ +// /* zKWText[] encodes 1007 bytes of keyword text in 667 bytes */ +// /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ +// /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */ +// /* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */ +// /* CONSTRAINTOFFSETRIGGERANGENERATEDETACHAVINGLOBEGINNEREFERENCES */ +// /* UNIQUERYWITHOUTERELEASEATTACHBETWEENOTHINGROUPSCASCADEFAULT */ +// /* CASECOLLATECREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZE */ +// /* PRAGMATERIALIZEDEFERREDISTINCTUPDATEVALUESVIRTUALWAYSWHENWHERE */ +// /* CURSIVEABORTAFTERENAMEANDROPARTITIONAUTOINCREMENTCASTCOLUMN */ +// /* COMMITCONFLICTCROSSCURRENT_TIMESTAMPRECEDINGFAILASTFILTER */ +// /* EPLACEFIRSTFOLLOWINGFROMFULLIMITIFORDERESTRICTOTHERSOVER */ +// /* ETURNINGRIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBY */ +// /* INITIALLYPRIMARY */ +var _zKWText = [666]uint8{ + 0: uint8('R'), + 1: uint8('E'), + 2: uint8('I'), + 3: uint8('N'), + 4: uint8('D'), + 5: uint8('E'), + 6: uint8('X'), + 7: uint8('E'), + 8: uint8('D'), + 9: uint8('E'), + 10: uint8('S'), + 11: uint8('C'), + 12: uint8('A'), + 13: uint8('P'), + 14: uint8('E'), + 15: uint8('A'), + 16: uint8('C'), + 17: uint8('H'), + 18: uint8('E'), + 19: uint8('C'), + 20: uint8('K'), + 21: uint8('E'), + 22: uint8('Y'), + 23: uint8('B'), + 24: uint8('E'), + 25: uint8('F'), + 26: uint8('O'), + 27: uint8('R'), + 28: uint8('E'), + 29: uint8('I'), + 30: uint8('G'), + 31: uint8('N'), + 32: uint8('O'), + 33: uint8('R'), + 34: uint8('E'), + 35: uint8('G'), + 36: uint8('E'), + 37: uint8('X'), + 38: uint8('P'), + 39: uint8('L'), + 40: uint8('A'), + 41: uint8('I'), + 42: uint8('N'), + 43: uint8('S'), + 44: uint8('T'), + 45: uint8('E'), + 46: uint8('A'), + 47: uint8('D'), + 48: uint8('D'), + 49: uint8('A'), + 50: uint8('T'), + 51: uint8('A'), + 52: uint8('B'), + 53: uint8('A'), + 54: uint8('S'), + 55: uint8('E'), + 56: uint8('L'), + 57: uint8('E'), + 58: uint8('C'), + 59: uint8('T'), + 60: uint8('A'), + 61: uint8('B'), + 62: uint8('L'), + 63: uint8('E'), + 64: uint8('F'), + 65: uint8('T'), + 66: uint8('H'), + 67: uint8('E'), + 68: uint8('N'), + 69: uint8('D'), + 70: uint8('E'), + 71: uint8('F'), + 72: uint8('E'), + 73: uint8('R'), + 74: uint8('R'), + 75: uint8('A'), + 76: uint8('B'), + 77: uint8('L'), + 78: uint8('E'), + 79: uint8('L'), + 80: uint8('S'), + 81: uint8('E'), + 82: uint8('X'), + 83: uint8('C'), + 84: uint8('L'), + 85: uint8('U'), + 86: uint8('D'), + 87: uint8('E'), + 88: uint8('L'), + 89: uint8('E'), + 90: uint8('T'), + 91: uint8('E'), + 92: uint8('M'), + 93: uint8('P'), + 94: uint8('O'), + 95: uint8('R'), + 96: uint8('A'), + 97: uint8('R'), + 98: uint8('Y'), + 99: uint8('I'), + 100: uint8('S'), + 101: uint8('N'), + 102: uint8('U'), + 103: uint8('L'), + 104: uint8('L'), + 105: uint8('S'), + 106: uint8('A'), + 107: uint8('V'), + 108: uint8('E'), + 109: uint8('P'), + 110: uint8('O'), + 111: uint8('I'), + 112: uint8('N'), + 113: uint8('T'), + 114: uint8('E'), + 115: uint8('R'), + 116: uint8('S'), + 117: uint8('E'), + 118: uint8('C'), + 119: uint8('T'), + 120: uint8('I'), + 121: uint8('E'), + 122: uint8('S'), + 123: uint8('N'), + 124: uint8('O'), + 125: uint8('T'), + 126: uint8('N'), + 127: uint8('U'), + 128: uint8('L'), + 129: uint8('L'), + 130: uint8('I'), + 131: uint8('K'), + 132: uint8('E'), + 133: uint8('X'), + 134: uint8('C'), + 135: uint8('E'), + 136: uint8('P'), + 137: uint8('T'), + 138: uint8('R'), + 139: uint8('A'), + 140: uint8('N'), + 141: uint8('S'), + 142: uint8('A'), + 143: uint8('C'), + 144: uint8('T'), + 145: uint8('I'), + 146: uint8('O'), + 147: uint8('N'), + 148: uint8('A'), + 149: uint8('T'), + 150: uint8('U'), + 151: uint8('R'), + 152: uint8('A'), + 153: uint8('L'), + 154: uint8('T'), + 155: uint8('E'), + 156: uint8('R'), + 157: uint8('A'), + 158: uint8('I'), + 159: uint8('S'), + 160: uint8('E'), + 161: uint8('X'), + 162: uint8('C'), + 163: uint8('L'), + 164: uint8('U'), + 165: uint8('S'), + 166: uint8('I'), + 167: uint8('V'), + 168: uint8('E'), + 169: uint8('X'), + 170: uint8('I'), + 171: uint8('S'), + 172: uint8('T'), + 173: uint8('S'), + 174: uint8('C'), + 175: uint8('O'), + 176: uint8('N'), + 177: uint8('S'), + 178: uint8('T'), + 179: uint8('R'), + 180: uint8('A'), + 181: uint8('I'), + 182: uint8('N'), + 183: uint8('T'), + 184: uint8('O'), + 185: uint8('F'), + 186: uint8('F'), + 187: uint8('S'), + 188: uint8('E'), + 189: uint8('T'), + 190: uint8('R'), + 191: uint8('I'), + 192: uint8('G'), + 193: uint8('G'), + 194: uint8('E'), + 195: uint8('R'), + 196: uint8('A'), + 197: uint8('N'), + 198: uint8('G'), + 199: uint8('E'), + 200: uint8('N'), + 201: uint8('E'), + 202: uint8('R'), + 203: uint8('A'), + 204: uint8('T'), + 205: uint8('E'), + 206: uint8('D'), + 207: uint8('E'), + 208: uint8('T'), + 209: uint8('A'), + 210: uint8('C'), + 211: uint8('H'), + 212: uint8('A'), + 213: uint8('V'), + 214: uint8('I'), + 215: uint8('N'), + 216: uint8('G'), + 217: uint8('L'), + 218: uint8('O'), + 219: uint8('B'), + 220: uint8('E'), + 221: uint8('G'), + 222: uint8('I'), + 223: uint8('N'), + 224: uint8('N'), + 225: uint8('E'), + 226: uint8('R'), + 227: uint8('E'), + 228: uint8('F'), + 229: uint8('E'), + 230: uint8('R'), + 231: uint8('E'), + 232: uint8('N'), + 233: uint8('C'), + 234: uint8('E'), + 235: uint8('S'), + 236: uint8('U'), + 237: uint8('N'), + 238: uint8('I'), + 239: uint8('Q'), + 240: uint8('U'), + 241: uint8('E'), + 242: uint8('R'), + 243: uint8('Y'), + 244: uint8('W'), + 245: uint8('I'), + 246: uint8('T'), + 247: uint8('H'), + 248: uint8('O'), + 249: uint8('U'), + 250: uint8('T'), + 251: uint8('E'), + 252: uint8('R'), + 253: uint8('E'), + 254: uint8('L'), + 255: uint8('E'), + 256: uint8('A'), + 257: uint8('S'), + 258: uint8('E'), + 259: uint8('A'), + 260: uint8('T'), + 261: uint8('T'), + 262: uint8('A'), + 263: uint8('C'), + 264: uint8('H'), + 265: uint8('B'), + 266: uint8('E'), + 267: uint8('T'), + 268: uint8('W'), + 269: uint8('E'), + 270: uint8('E'), + 271: uint8('N'), + 272: uint8('O'), + 273: uint8('T'), + 274: uint8('H'), + 275: uint8('I'), + 276: uint8('N'), + 277: uint8('G'), + 278: uint8('R'), + 279: uint8('O'), + 280: uint8('U'), + 281: uint8('P'), + 282: uint8('S'), + 283: uint8('C'), + 284: uint8('A'), + 285: uint8('S'), + 286: uint8('C'), + 287: uint8('A'), + 288: uint8('D'), + 289: uint8('E'), + 290: uint8('F'), + 291: uint8('A'), + 292: uint8('U'), + 293: uint8('L'), + 294: uint8('T'), + 295: uint8('C'), + 296: uint8('A'), + 297: uint8('S'), + 298: uint8('E'), + 299: uint8('C'), + 300: uint8('O'), + 301: uint8('L'), + 302: uint8('L'), + 303: uint8('A'), + 304: uint8('T'), + 305: uint8('E'), + 306: uint8('C'), + 307: uint8('R'), + 308: uint8('E'), + 309: uint8('A'), + 310: uint8('T'), + 311: uint8('E'), + 312: uint8('C'), + 313: uint8('U'), + 314: uint8('R'), + 315: uint8('R'), + 316: uint8('E'), + 317: uint8('N'), + 318: uint8('T'), + 319: uint8('_'), + 320: uint8('D'), + 321: uint8('A'), + 322: uint8('T'), + 323: uint8('E'), + 324: uint8('I'), + 325: uint8('M'), + 326: uint8('M'), + 327: uint8('E'), + 328: uint8('D'), + 329: uint8('I'), + 330: uint8('A'), + 331: uint8('T'), + 332: uint8('E'), + 333: uint8('J'), + 334: uint8('O'), + 335: uint8('I'), + 336: uint8('N'), + 337: uint8('S'), + 338: uint8('E'), + 339: uint8('R'), + 340: uint8('T'), + 341: uint8('M'), + 342: uint8('A'), + 343: uint8('T'), + 344: uint8('C'), + 345: uint8('H'), + 346: uint8('P'), + 347: uint8('L'), + 348: uint8('A'), + 349: uint8('N'), + 350: uint8('A'), + 351: uint8('L'), + 352: uint8('Y'), + 353: uint8('Z'), + 354: uint8('E'), + 355: uint8('P'), + 356: uint8('R'), + 357: uint8('A'), + 358: uint8('G'), + 359: uint8('M'), + 360: uint8('A'), + 361: uint8('T'), + 362: uint8('E'), + 363: uint8('R'), + 364: uint8('I'), + 365: uint8('A'), + 366: uint8('L'), + 367: uint8('I'), + 368: uint8('Z'), + 369: uint8('E'), + 370: uint8('D'), + 371: uint8('E'), + 372: uint8('F'), + 373: uint8('E'), + 374: uint8('R'), + 375: uint8('R'), + 376: uint8('E'), + 377: uint8('D'), + 378: uint8('I'), + 379: uint8('S'), + 380: uint8('T'), + 381: uint8('I'), + 382: uint8('N'), + 383: uint8('C'), + 384: uint8('T'), + 385: uint8('U'), + 386: uint8('P'), + 387: uint8('D'), + 388: uint8('A'), + 389: uint8('T'), + 390: uint8('E'), + 391: uint8('V'), + 392: uint8('A'), + 393: uint8('L'), + 394: uint8('U'), + 395: uint8('E'), + 396: uint8('S'), + 397: uint8('V'), + 398: uint8('I'), + 399: uint8('R'), + 400: uint8('T'), + 401: uint8('U'), + 402: uint8('A'), + 403: uint8('L'), + 404: uint8('W'), + 405: uint8('A'), + 406: uint8('Y'), + 407: uint8('S'), + 408: uint8('W'), + 409: uint8('H'), + 410: uint8('E'), + 411: uint8('N'), + 412: uint8('W'), + 413: uint8('H'), + 414: uint8('E'), + 415: uint8('R'), + 416: uint8('E'), + 417: uint8('C'), + 418: uint8('U'), + 419: uint8('R'), + 420: uint8('S'), + 421: uint8('I'), + 422: uint8('V'), + 423: uint8('E'), + 424: uint8('A'), + 425: uint8('B'), + 426: uint8('O'), + 427: uint8('R'), + 428: uint8('T'), + 429: uint8('A'), + 430: uint8('F'), + 431: uint8('T'), + 432: uint8('E'), + 433: uint8('R'), + 434: uint8('E'), + 435: uint8('N'), + 436: uint8('A'), + 437: uint8('M'), + 438: uint8('E'), + 439: uint8('A'), + 440: uint8('N'), + 441: uint8('D'), + 442: uint8('R'), + 443: uint8('O'), + 444: uint8('P'), + 445: uint8('A'), + 446: uint8('R'), + 447: uint8('T'), + 448: uint8('I'), + 449: uint8('T'), + 450: uint8('I'), + 451: uint8('O'), + 452: uint8('N'), + 453: uint8('A'), + 454: uint8('U'), + 455: uint8('T'), + 456: uint8('O'), + 457: uint8('I'), + 458: uint8('N'), + 459: uint8('C'), + 460: uint8('R'), + 461: uint8('E'), + 462: uint8('M'), + 463: uint8('E'), + 464: uint8('N'), + 465: uint8('T'), + 466: uint8('C'), + 467: uint8('A'), + 468: uint8('S'), + 469: uint8('T'), + 470: uint8('C'), + 471: uint8('O'), + 472: uint8('L'), + 473: uint8('U'), + 474: uint8('M'), + 475: uint8('N'), + 476: uint8('C'), + 477: uint8('O'), + 478: uint8('M'), + 479: uint8('M'), + 480: uint8('I'), + 481: uint8('T'), + 482: uint8('C'), + 483: uint8('O'), + 484: uint8('N'), + 485: uint8('F'), + 486: uint8('L'), + 487: uint8('I'), + 488: uint8('C'), + 489: uint8('T'), + 490: uint8('C'), + 491: uint8('R'), + 492: uint8('O'), + 493: uint8('S'), + 494: uint8('S'), + 495: uint8('C'), + 496: uint8('U'), + 497: uint8('R'), + 498: uint8('R'), + 499: uint8('E'), + 500: uint8('N'), + 501: uint8('T'), + 502: uint8('_'), + 503: uint8('T'), + 504: uint8('I'), + 505: uint8('M'), + 506: uint8('E'), + 507: uint8('S'), + 508: uint8('T'), + 509: uint8('A'), + 510: uint8('M'), + 511: uint8('P'), + 512: uint8('R'), + 513: uint8('E'), + 514: uint8('C'), + 515: uint8('E'), + 516: uint8('D'), + 517: uint8('I'), + 518: uint8('N'), + 519: uint8('G'), + 520: uint8('F'), + 521: uint8('A'), + 522: uint8('I'), + 523: uint8('L'), + 524: uint8('A'), + 525: uint8('S'), + 526: uint8('T'), + 527: uint8('F'), + 528: uint8('I'), + 529: uint8('L'), + 530: uint8('T'), + 531: uint8('E'), + 532: uint8('R'), + 533: uint8('E'), + 534: uint8('P'), + 535: uint8('L'), + 536: uint8('A'), + 537: uint8('C'), + 538: uint8('E'), + 539: uint8('F'), + 540: uint8('I'), + 541: uint8('R'), + 542: uint8('S'), + 543: uint8('T'), + 544: uint8('F'), + 545: uint8('O'), + 546: uint8('L'), + 547: uint8('L'), + 548: uint8('O'), + 549: uint8('W'), + 550: uint8('I'), + 551: uint8('N'), + 552: uint8('G'), + 553: uint8('F'), + 554: uint8('R'), + 555: uint8('O'), + 556: uint8('M'), + 557: uint8('F'), + 558: uint8('U'), + 559: uint8('L'), + 560: uint8('L'), + 561: uint8('I'), + 562: uint8('M'), + 563: uint8('I'), + 564: uint8('T'), + 565: uint8('I'), + 566: uint8('F'), + 567: uint8('O'), + 568: uint8('R'), + 569: uint8('D'), + 570: uint8('E'), + 571: uint8('R'), + 572: uint8('E'), + 573: uint8('S'), + 574: uint8('T'), + 575: uint8('R'), + 576: uint8('I'), + 577: uint8('C'), + 578: uint8('T'), + 579: uint8('O'), + 580: uint8('T'), + 581: uint8('H'), + 582: uint8('E'), + 583: uint8('R'), + 584: uint8('S'), + 585: uint8('O'), + 586: uint8('V'), + 587: uint8('E'), + 588: uint8('R'), + 589: uint8('E'), + 590: uint8('T'), + 591: uint8('U'), + 592: uint8('R'), + 593: uint8('N'), + 594: uint8('I'), + 595: uint8('N'), + 596: uint8('G'), + 597: uint8('R'), + 598: uint8('I'), + 599: uint8('G'), + 600: uint8('H'), + 601: uint8('T'), + 602: uint8('R'), + 603: uint8('O'), + 604: uint8('L'), + 605: uint8('L'), + 606: uint8('B'), + 607: uint8('A'), + 608: uint8('C'), + 609: uint8('K'), + 610: uint8('R'), + 611: uint8('O'), + 612: uint8('W'), + 613: uint8('S'), + 614: uint8('U'), + 615: uint8('N'), + 616: uint8('B'), + 617: uint8('O'), + 618: uint8('U'), + 619: uint8('N'), + 620: uint8('D'), + 621: uint8('E'), + 622: uint8('D'), + 623: uint8('U'), + 624: uint8('N'), + 625: uint8('I'), + 626: uint8('O'), + 627: uint8('N'), + 628: uint8('U'), + 629: uint8('S'), + 630: uint8('I'), + 631: uint8('N'), + 632: uint8('G'), + 633: uint8('V'), + 634: uint8('A'), + 635: uint8('C'), + 636: uint8('U'), + 637: uint8('U'), + 638: uint8('M'), + 639: uint8('V'), + 640: uint8('I'), + 641: uint8('E'), + 642: uint8('W'), + 643: uint8('I'), + 644: uint8('N'), + 645: uint8('D'), + 646: uint8('O'), + 647: uint8('W'), + 648: uint8('B'), + 649: uint8('Y'), + 650: uint8('I'), + 651: uint8('N'), + 652: uint8('I'), + 653: uint8('T'), + 654: uint8('I'), + 655: uint8('A'), + 656: uint8('L'), + 657: uint8('L'), + 658: uint8('Y'), + 659: uint8('P'), + 660: uint8('R'), + 661: uint8('I'), + 662: uint8('M'), + 663: uint8('A'), + 664: uint8('R'), + 665: uint8('Y'), +} + +/* 0123456789 123456789 123456789 123 */ +var _zKeyText = [34]uint8{'n', 'a', 't', 'u', 'r', 'a', 'l', 'e', 'f', 't', 'o', 'u', 't', 'e', 'r', 'i', 'g', 'h', 't', 'f', 'u', 'l', 'l', 'i', 'n', 'n', 'e', 'r', 'c', 'r', 'o', 's', 's'} + +// C documentation +// +// /* +// ** The header string that appears at the beginning of every +// ** SQLite database. +// */ +var _zMagicHeader = [16]uint8{'S', 'Q', 'L', 'i', 't', 'e', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', '3'} + +/* +** Set this global variable to 1 to enable tracing using the TRACE +** macro. + */ + +/* +** Extract a 2-byte big-endian integer from an array of unsigned bytes. +** But if the value is zero, make it 65536. +** +** This routine is used to extract the "offset to cell content area" value +** from the header of a btree page. If the page size is 65536 and the page +** is empty, the offset should be 65536, but the 2-byte value stores zero. +** This routine makes the necessary adjustment to 65536. + */ + +/* +** Values passed as the 5th argument to allocateBtreePage() + */ + +/* +** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not +** defined, or 0 if it is. For example: +** +** bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum); + */ + +var _zOrd = [9]uint8{'t', 'h', 's', 't', 'n', 'd', 'r', 'd'} + +/* End of function */ + +/* 123456789 123456789 123 */ +var _zText = [25]uint8{'o', 'n', 'o', 'f', 'f', 'a', 'l', 's', 'e', 'y', 'e', 's', 't', 'r', 'u', 'e', 'x', 't', 'r', 'a', 'f', 'u', 'l', 'l'} + +var _zeroHdr = [28]uint8{} diff --git a/internal/engine/lib/sqlite_g_0000000000013e02.go b/internal/engine/lib/sqlite_g_0000000000013e02.go new file mode 100644 index 0000000..62c3022 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000013e02.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && arm64) + +package sqlite3 + +const FP_FAST_FMA = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000013e22.go b/internal/engine/lib/sqlite_g_0000000000013e22.go new file mode 100644 index 0000000..f4ee535 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000013e22.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && arm64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && arm64) + +package sqlite3 + +const __FP_FAST_FMA = 1 + +const __FP_FAST_FMAF = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000013e3e.go b/internal/engine/lib/sqlite_g_0000000000013e3e.go new file mode 100644 index 0000000..781c1cd --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000013e3e.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && arm64) + +package sqlite3 + +const FP_FAST_FMAF = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000018003.go b/internal/engine/lib/sqlite_g_0000000000018003.go new file mode 100644 index 0000000..083371d --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000018003.go @@ -0,0 +1,47 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Tdev_t = int32 + +type Tflock = struct { + Fl_start Toff_t + Fl_len Toff_t + Fl_pid Tpid_t + Fl_type int16 + Fl_whence int16 +} + +type Tsigset_t = uint32 + +type Twint_t = int32 + +const _POSIX2_SW_DEV = 200112 + +const _POSIX_ADVISORY_INFO = -1 + +const _POSIX_ASYNCHRONOUS_IO = -1 + +const _POSIX_MESSAGE_PASSING = -1 + +const _POSIX_PRIORITY_SCHEDULING = -1 + +const _POSIX_REALTIME_SIGNALS = -1 + +const _POSIX_THREAD_PRIORITY_SCHEDULING = -1 + +const _POSIX_THREAD_PRIO_INHERIT = -1 + +const _POSIX_THREAD_PRIO_PROTECT = -1 + +const _POSIX_TIMERS = -1 + +const _POSIX_V6_ILP32_OFF32 = -1 + +const _POSIX_V7_ILP32_OFF32 = -1 + +const _XOPEN_CRYPT = 1 + +const __STDC_NO_THREADS__ = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000018017.go b/internal/engine/lib/sqlite_g_0000000000018017.go new file mode 100644 index 0000000..604dff6 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000018017.go @@ -0,0 +1,17 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && arm) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __INT64_FMTd__ = "lld" + +const __INT64_FMTi__ = "lli" + +const __UINT64_FMTX__ = "llX" + +const __UINT64_FMTo__ = "llo" + +const __UINT64_FMTu__ = "llu" + +const __UINT64_FMTx__ = "llx" diff --git a/internal/engine/lib/sqlite_g_000000000001802b.go b/internal/engine/lib/sqlite_g_000000000001802b.go new file mode 100644 index 0000000..b16a17f --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001802b.go @@ -0,0 +1,33 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __INTPTR_FMTd__ = "ld" + +const __INTPTR_FMTi__ = "li" + +const __POINTER_WIDTH__ = 64 + +const __PTRDIFF_FMTd__ = "ld" + +const __PTRDIFF_FMTi__ = "li" + +const __SIZE_FMTX__ = "lX" + +const __SIZE_FMTo__ = "lo" + +const __SIZE_FMTu__ = "lu" + +const __SIZE_FMTx__ = "lx" + +const __UINTPTR_FMTX__ = "lX" + +const __UINTPTR_FMTo__ = "lo" + +const __UINTPTR_FMTu__ = "lu" + +const __UINTPTR_FMTx__ = "lx" + +const __UINTPTR_WIDTH__ = 64 diff --git a/internal/engine/lib/sqlite_g_000000000001803d.go b/internal/engine/lib/sqlite_g_000000000001803d.go new file mode 100644 index 0000000..24478a4 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001803d.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __OBJC_BOOL_IS_BOOL = 0 diff --git a/internal/engine/lib/sqlite_g_000000000001803f.go b/internal/engine/lib/sqlite_g_000000000001803f.go new file mode 100644 index 0000000..f204064 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001803f.go @@ -0,0 +1,327 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const DST_AUST = 2 + +const DST_CAN = 6 + +const DST_EET = 5 + +const DST_MET = 4 + +const DST_NONE = 0 + +const DST_USA = 1 + +const DST_WET = 3 + +const FFSYNC = 128 + +const FNONBLOCK = 4 + +const MAP_COPY = 2 + +const _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 2 + +const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 3 + +const _CS_POSIX_V6_ILP32_OFF32_LIBS = 4 + +const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 5 + +const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 6 + +const _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 7 + +const _CS_POSIX_V6_LP64_OFF64_CFLAGS = 8 + +const _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 9 + +const _CS_POSIX_V6_LP64_OFF64_LIBS = 10 + +const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 11 + +const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 12 + +const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 13 + +const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 14 + +const _POSIX2_FORT_DEV = -1 + +const _POSIX2_PBS = -1 + +const _POSIX2_PBS_ACCOUNTING = -1 + +const _POSIX2_PBS_CHECKPOINT = -1 + +const _POSIX2_PBS_LOCATE = -1 + +const _POSIX2_PBS_MESSAGE = -1 + +const _POSIX2_PBS_TRACK = -1 + +const _POSIX2_UPE = 200112 + +const _POSIX_FSYNC = 200112 + +const _POSIX_MAPPED_FILES = 200112 + +const _POSIX_MEMORY_PROTECTION = 200112 + +const _POSIX_SPAWN = 200112 + +const _POSIX_SPORADIC_SERVER = -1 + +const _POSIX_SYNCHRONIZED_IO = -1 + +const _POSIX_THREAD_SPORADIC_SERVER = -1 + +const _POSIX_TRACE = -1 + +const _POSIX_TRACE_EVENT_FILTER = -1 + +const _POSIX_TRACE_INHERIT = -1 + +const _POSIX_TRACE_LOG = -1 + +const _POSIX_TYPED_MEMORY_OBJECTS = -1 + +const _SC_AIO_LISTIO_MAX = 42 + +const _SC_AIO_MAX = 43 + +const _SC_AIO_PRIO_DELTA_MAX = 44 + +const _SC_CLK_TCK = 3 + +const _XOPEN_LEGACY = -1 + +const _XOPEN_REALTIME = -1 + +const _XOPEN_REALTIME_THREADS = -1 + +const _XOPEN_SHM = 1 + +const _XOPEN_STREAMS = -1 + +const __CLANG_ATOMIC_BOOL_LOCK_FREE = 2 + +const __CLANG_ATOMIC_CHAR16_T_LOCK_FREE = 2 + +const __CLANG_ATOMIC_CHAR32_T_LOCK_FREE = 2 + +const __CLANG_ATOMIC_CHAR_LOCK_FREE = 2 + +const __CLANG_ATOMIC_INT_LOCK_FREE = 2 + +const __CLANG_ATOMIC_LLONG_LOCK_FREE = 2 + +const __CLANG_ATOMIC_LONG_LOCK_FREE = 2 + +const __CLANG_ATOMIC_POINTER_LOCK_FREE = 2 + +const __CLANG_ATOMIC_SHORT_LOCK_FREE = 2 + +const __CLANG_ATOMIC_WCHAR_T_LOCK_FREE = 2 + +const __CONSTANT_CFSTRINGS__ = 1 + +const __DBL_DENORM_MIN__ = 0 + +const __DBL_EPSILON__ = 0 + +const __DBL_MAX__ = 0 + +const __DBL_NORM_MAX__ = 0 + +const __FPCLASS_NEGINF = 4 + +const __FPCLASS_NEGNORMAL = 8 + +const __FPCLASS_NEGSUBNORMAL = 16 + +const __FPCLASS_NEGZERO = 32 + +const __FPCLASS_POSINF = 512 + +const __FPCLASS_POSNORMAL = 256 + +const __FPCLASS_POSSUBNORMAL = 128 + +const __FPCLASS_POSZERO = 64 + +const __FPCLASS_QNAN = 2 + +const __FPCLASS_SNAN = 1 + +const __GNUC__ = 4 + +const __GXX_ABI_VERSION = 1002 + +const __INT16_FMTd__ = "hd" + +const __INT16_FMTi__ = "hi" + +const __INT16_TYPE__ = 0 + +const __INT32_FMTd__ = "d" + +const __INT32_FMTi__ = "i" + +const __INT64_C_SUFFIX__ = 0 + +const __INT8_FMTd__ = "hhd" + +const __INT8_FMTi__ = "hhi" + +const __INTMAX_C_SUFFIX__ = 0 + +const __INT_FAST16_FMTd__ = "hd" + +const __INT_FAST16_FMTi__ = "hi" + +const __INT_FAST32_FMTd__ = "d" + +const __INT_FAST32_FMTi__ = "i" + +const __INT_FAST8_FMTd__ = "hhd" + +const __INT_FAST8_FMTi__ = "hhi" + +const __INT_LEAST16_FMTd__ = "hd" + +const __INT_LEAST16_FMTi__ = "hi" + +const __INT_LEAST16_TYPE__ = 0 + +const __INT_LEAST32_FMTd__ = "d" + +const __INT_LEAST32_FMTi__ = "i" + +const __INT_LEAST8_FMTd__ = "hhd" + +const __INT_LEAST8_FMTi__ = "hhi" + +const __LLONG_WIDTH__ = 64 + +const __MEMORY_SCOPE_DEVICE = 1 + +const __MEMORY_SCOPE_SINGLE = 4 + +const __MEMORY_SCOPE_SYSTEM = 0 + +const __MEMORY_SCOPE_WRKGRP = 2 + +const __MEMORY_SCOPE_WVFRNT = 3 + +const __NO_MATH_ERRNO__ = 1 + +const __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES = 3 + +const __OPENCL_MEMORY_SCOPE_DEVICE = 2 + +const __OPENCL_MEMORY_SCOPE_SUB_GROUP = 4 + +const __OPENCL_MEMORY_SCOPE_WORK_GROUP = 1 + +const __OPENCL_MEMORY_SCOPE_WORK_ITEM = 0 + +const __STDC_EMBED_EMPTY__ = 2 + +const __STDC_EMBED_FOUND__ = 1 + +const __STDC_EMBED_NOT_FOUND__ = 0 + +const __UINT16_FMTX__ = "hX" + +const __UINT16_FMTo__ = "ho" + +const __UINT16_FMTu__ = "hu" + +const __UINT16_FMTx__ = "hx" + +const __UINT32_C_SUFFIX__ = 0 + +const __UINT32_FMTX__ = "X" + +const __UINT32_FMTo__ = "o" + +const __UINT32_FMTu__ = "u" + +const __UINT32_FMTx__ = "x" + +const __UINT64_C_SUFFIX__ = 0 + +const __UINT8_FMTX__ = "hhX" + +const __UINT8_FMTo__ = "hho" + +const __UINT8_FMTu__ = "hhu" + +const __UINT8_FMTx__ = "hhx" + +const __UINTMAX_C_SUFFIX__ = 0 + +const __UINTMAX_WIDTH__ = 64 + +const __UINT_FAST16_FMTX__ = "hX" + +const __UINT_FAST16_FMTo__ = "ho" + +const __UINT_FAST16_FMTu__ = "hu" + +const __UINT_FAST16_FMTx__ = "hx" + +const __UINT_FAST32_FMTX__ = "X" + +const __UINT_FAST32_FMTo__ = "o" + +const __UINT_FAST32_FMTu__ = "u" + +const __UINT_FAST32_FMTx__ = "x" + +const __UINT_FAST8_FMTX__ = "hhX" + +const __UINT_FAST8_FMTo__ = "hho" + +const __UINT_FAST8_FMTu__ = "hhu" + +const __UINT_FAST8_FMTx__ = "hhx" + +const __UINT_LEAST16_FMTX__ = "hX" + +const __UINT_LEAST16_FMTo__ = "ho" + +const __UINT_LEAST16_FMTu__ = "hu" + +const __UINT_LEAST16_FMTx__ = "hx" + +const __UINT_LEAST32_FMTX__ = "X" + +const __UINT_LEAST32_FMTo__ = "o" + +const __UINT_LEAST32_FMTu__ = "u" + +const __UINT_LEAST32_FMTx__ = "x" + +const __UINT_LEAST8_FMTX__ = "hhX" + +const __UINT_LEAST8_FMTo__ = "hho" + +const __UINT_LEAST8_FMTu__ = "hhu" + +const __UINT_LEAST8_FMTx__ = "hhx" + +const __clang__ = 1 + +const __clang_literal_encoding__ = "UTF-8" + +const __clang_wide_literal_encoding__ = "UTF-32" + +const __llvm__ = 1 + +type clockinfo = Tclockinfo diff --git a/internal/engine/lib/sqlite_g_000000000001843f.go b/internal/engine/lib/sqlite_g_000000000001843f.go new file mode 100644 index 0000000..baaf6c3 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001843f.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && loong64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __GNUC_PATCHLEVEL__ = 1 diff --git a/internal/engine/lib/sqlite_g_000000000001883f.go b/internal/engine/lib/sqlite_g_000000000001883f.go new file mode 100644 index 0000000..c743e19 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001883f.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && ppc64le) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __LITTLE_ENDIAN__ = 1 diff --git a/internal/engine/lib/sqlite_g_00000000000192bb.go b/internal/engine/lib/sqlite_g_00000000000192bb.go new file mode 100644 index 0000000..9a3ca78 --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000192bb.go @@ -0,0 +1,35 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && riscv64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __FLT16_DECIMAL_DIG__ = 5 + +const __FLT16_DENORM_MIN__ = 0 + +const __FLT16_DIG__ = 3 + +const __FLT16_EPSILON__ = 0 + +const __FLT16_HAS_DENORM__ = 1 + +const __FLT16_HAS_INFINITY__ = 1 + +const __FLT16_HAS_QUIET_NAN__ = 1 + +const __FLT16_MANT_DIG__ = 11 + +const __FLT16_MAX_10_EXP__ = 4 + +const __FLT16_MAX_EXP__ = 16 + +const __FLT16_MAX__ = 0 + +const __FLT16_MIN_10_EXP__ = -4 + +const __FLT16_MIN_EXP__ = -13 + +const __FLT16_MIN__ = 0 + +const __FLT16_NORM_MAX__ = 0 diff --git a/internal/engine/lib/sqlite_g_0000000000019600.go b/internal/engine/lib/sqlite_g_0000000000019600.go new file mode 100644 index 0000000..555a3ad --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000019600.go @@ -0,0 +1,33 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm64) || (linux && loong64) || (linux && riscv64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Find the mode, uid and gid of file zFile. +// */ +func _getFileMode(tls *libc.TLS, zFile uintptr, pMode uintptr, pUid uintptr, pGid uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var rc int32 + var _ /* sStat at bp+0 */ Tstat + _ = rc /* Output of stat() on database file */ + rc = SQLITE_OK + if 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(4)].FpCurrent})))(tls, zFile, bp) { + **(**Tmode_t)(__ccgo_up(pMode)) = (**(**Tstat)(__ccgo_up(bp))).Fst_mode & uint32(0777) + **(**Tuid_t)(__ccgo_up(pUid)) = (**(**Tstat)(__ccgo_up(bp))).Fst_uid + **(**Tgid_t)(__ccgo_up(pGid)) = (**(**Tstat)(__ccgo_up(bp))).Fst_gid + } else { + rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(7)<nLock==0 ); <-- Not true if unix-excl READONLY used */ + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = SEEK_SET + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(2)) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(SHARED_SIZE) + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK) + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(F_SETLK), libc.VaList(bp+32, bp)) + if rc < 0 { + return rc + } + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock = uint8(1) + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock + 1 + } else { + rc = 0 + } + } else { + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, int32(F_SETLK), libc.VaList(bp+32, pLock)) + } + return rc +} + +// C documentation +// +// /* +// ** Apply posix advisory locks for all bytes from ofst through ofst+n-1. +// ** +// ** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking +// ** otherwise. +// */ +func _unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, n int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pShmNode uintptr + var rc, res int32 + var _ /* f at bp+0 */ Tflock + _, _, _ = pShmNode, rc, res /* The posix advisory locking structure */ + rc = SQLITE_OK /* Result code form fcntl() */ + pShmNode = (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FpShmNode + /* Assert that the parameters are within expected range and that the + ** correct mutex or mutexes are held. */ + if ofst == (libc.Int32FromInt32(22)+libc.Int32FromInt32(SQLITE_SHM_NLOCK))*libc.Int32FromInt32(4)+libc.Int32FromInt32(SQLITE_SHM_NLOCK) { + } else { + } + /* Shared locks never span more than one byte */ + /* Locks are within range */ + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0 { + /* Initialize the locking parameters */ + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(lockType) + (**(**Tflock)(__ccgo_up(bp))).Fl_whence = SEEK_SET + (**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(ofst) + (**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(n) + res = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int32(F_SETLK), libc.VaList(bp+32, bp)) + if res == -int32(1) { + rc = int32(SQLITE_BUSY) + } + } + /* Do debug tracing */ + return rc +} diff --git a/internal/engine/lib/sqlite_g_000000000001c007.go b/internal/engine/lib/sqlite_g_000000000001c007.go new file mode 100644 index 0000000..9edd54d --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001c007.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __const = 0 + +const __signed = 0 diff --git a/internal/engine/lib/sqlite_g_000000000001c017.go b/internal/engine/lib/sqlite_g_000000000001c017.go new file mode 100644 index 0000000..1b815be --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001c017.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && arm) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Tsegsz_t = int32 diff --git a/internal/engine/lib/sqlite_g_000000000001c02b.go b/internal/engine/lib/sqlite_g_000000000001c02b.go new file mode 100644 index 0000000..85b4122 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001c02b.go @@ -0,0 +1,33 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* Create a new thread */ +func _sqlite3ThreadCreate(tls *libc.TLS, ppThread uintptr, __ccgo_fp_xTask uintptr, pIn uintptr) (r int32) { + var p uintptr + _ = p + **(**uintptr)(__ccgo_up(ppThread)) = uintptr(0) + p = _sqlite3Malloc(tls, uint64(24)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if int32(int64(p))/int32(17)&int32(1) != 0 { + (*TSQLiteThread)(unsafe.Pointer(p)).FxTask = __ccgo_fp_xTask + (*TSQLiteThread)(unsafe.Pointer(p)).FpIn = pIn + } else { + (*TSQLiteThread)(unsafe.Pointer(p)).FxTask = uintptr(0) + (*TSQLiteThread)(unsafe.Pointer(p)).FpResult = (*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xTask})))(tls, pIn) + } + **(**uintptr)(__ccgo_up(ppThread)) = p + return SQLITE_OK +} diff --git a/internal/engine/lib/sqlite_g_000000000001c03f.go b/internal/engine/lib/sqlite_g_000000000001c03f.go new file mode 100644 index 0000000..5024b00 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001c03f.go @@ -0,0 +1,530 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const ACCESSPERMS = 511 + +const ALLPERMS = 4095 + +const DEFFILEMODE = 438 + +const EADDRINUSE = 48 + +const EADDRNOTAVAIL = 49 + +const EAFNOSUPPORT = 47 + +const EAGAIN = 35 + +const EALREADY = 37 + +const EAUTH = 80 + +const EBADRPC = 72 + +const ECONNABORTED = 53 + +const ECONNREFUSED = 61 + +const ECONNRESET = 54 + +const EDEADLK = 11 + +const EDESTADDRREQ = 39 + +const EDQUOT = 69 + +const EFTYPE = 79 + +const EHOSTDOWN = 64 + +const EHOSTUNREACH = 65 + +const EINPROGRESS = 36 + +const EISCONN = 56 + +const ELOOP = 62 + +const EMSGSIZE = 40 + +const ENAMETOOLONG = 63 + +const ENEEDAUTH = 81 + +const ENETDOWN = 50 + +const ENETRESET = 52 + +const ENETUNREACH = 51 + +const ENOBUFS = 55 + +const ENOLCK = 77 + +const ENOPROTOOPT = 42 + +const ENOSYS = 78 + +const ENOTCONN = 57 + +const ENOTEMPTY = 66 + +const ENOTSOCK = 38 + +const EPFNOSUPPORT = 46 + +const EPROCLIM = 67 + +const EPROCUNAVAIL = 76 + +const EPROGMISMATCH = 75 + +const EPROGUNAVAIL = 74 + +const EPROTONOSUPPORT = 43 + +const EPROTOTYPE = 41 + +const EREMOTE = 71 + +const ERPCMISMATCH = 73 + +const ESHUTDOWN = 58 + +const ESOCKTNOSUPPORT = 44 + +const ESTALE = 70 + +const ETIMEDOUT = 60 + +const ETOOMANYREFS = 59 + +const EUSERS = 68 + +const EWOULDBLOCK = 35 + +const FAPPEND = 8 + +const FASYNC = 64 + +const FILENAME_MAX = 1024 + +const FNDELAY = 4 + +const FREAD = 1 + +const FWRITE = 2 + +const F_GETOWN = 5 + +const F_RDLCK = 1 + +const F_SETOWN = 6 + +const F_WRLCK = 3 + +const HAVE_MREMAP = 0 + +const IOCPARM_MASK = 8191 + +const LOCK_EX = 2 + +const LOCK_NB = 4 + +const LOCK_SH = 1 + +const LOCK_UN = 8 + +const L_ctermid = 1024 + +const L_tmpnam = 1024 + +const MAP_ANON = 4096 + +const MAP_ANONYMOUS = 4096 + +const O_ACCMODE = 3 + +const O_APPEND = 8 + +const O_ASYNC = 64 + +const O_CREAT = 512 + +const O_EXCL = 2048 + +const O_EXLOCK = 32 + +const O_FSYNC = 128 + +const O_LARGEFILE = 0 + +const O_NDELAY = 4 + +const O_NOFOLLOW = 256 + +const O_NONBLOCK = 4 + +const O_SHLOCK = 16 + +const O_SYNC = 128 + +const O_TRUNC = 1024 + +const PPPDISC = 5 + +const RTLD_DEFAULT = -2 + +const RTLD_SELF = -3 + +const SF_APPEND = 262144 + +const SF_ARCHIVED = 65536 + +const SF_IMMUTABLE = 131072 + +const SLIPDISC = 4 + +const SQLITE_MAX_PATHLEN = 1024 + +const S_BLKSIZE = 512 + +const S_ISTXT = 512 + +type TSQLiteThread = struct { + FxTask uintptr + FpIn uintptr + FpResult uintptr +} + +const TTYDISC = 0 + +type Tfixpt_t = uint32 + +const UF_APPEND = 4 + +const UF_IMMUTABLE = 2 + +const UF_NODUMP = 1 + +const UF_OPAQUE = 8 + +const UF_SETTABLE = 65535 + +const WINT_MAX = 2147483647 + +const WINT_MIN = -2147483648 + +const _CS_PATH = 1 + +const _PC_CHOWN_RESTRICTED = 7 + +const _PC_LINK_MAX = 1 + +const _PC_MAX_CANON = 2 + +const _PC_MAX_INPUT = 3 + +const _PC_NAME_MAX = 4 + +const _PC_NO_TRUNC = 8 + +const _PC_PATH_MAX = 5 + +const _PC_PIPE_BUF = 6 + +const _PC_VDISABLE = 9 + +const _POSIX2_C_BIND = 200112 + +const _POSIX_CLOCK_SELECTION = -1 + +const _POSIX_PRIORITIZED_IO = -1 + +const _POSIX_READER_WRITER_LOCKS = 200112 + +const _POSIX_THREADS = 200112 + +const _POSIX_THREAD_ATTR_STACKADDR = 200112 + +const _POSIX_THREAD_ATTR_STACKSIZE = 200112 + +const _QUAD_HIGHWORD = 1 + +const _QUAD_LOWWORD = 0 + +const _SC_2_CHAR_TERM = 20 + +const _SC_2_C_BIND = 18 + +const _SC_2_C_DEV = 19 + +const _SC_2_FORT_DEV = 21 + +const _SC_2_FORT_RUN = 22 + +const _SC_2_LOCALEDEF = 23 + +const _SC_2_SW_DEV = 24 + +const _SC_2_UPE = 25 + +const _SC_2_VERSION = 17 + +const _SC_ARG_MAX = 1 + +const _SC_BC_BASE_MAX = 9 + +const _SC_BC_DIM_MAX = 10 + +const _SC_BC_SCALE_MAX = 11 + +const _SC_BC_STRING_MAX = 12 + +const _SC_CHILD_MAX = 2 + +const _SC_COLL_WEIGHTS_MAX = 13 + +const _SC_EXPR_NEST_MAX = 14 + +const _SC_JOB_CONTROL = 6 + +const _SC_LINE_MAX = 15 + +const _SC_NGROUPS_MAX = 4 + +const _SC_OPEN_MAX = 5 + +const _SC_RE_DUP_MAX = 16 + +const _SC_SAVED_IDS = 7 + +const _SC_STREAM_MAX = 26 + +const _SC_TZNAME_MAX = 27 + +const _SC_VERSION = 8 + +const __WINT_MAX__ = 2147483647 + +const __WINT_TYPE__ = 0 + +const __volatile = 0 + +// C documentation +// +// /* This variable holds the process id (pid) from when the xRandomness() +// ** method was called. If xOpen() is called from a different process id, +// ** indicating that a fork() has occurred, the PRNG will be reset. +// */ +var _randomnessPid = int32(0) + +/* +** Allowed values for the unixFile.ctrlFlags bitmask: + */ + +/* +** Include code that is common to all os_*.c files + */ +/* #include "os_common.h" */ + +/* +** Define various macros that are missing from some systems. + */ + +/* +** The threadid macro resolves to the thread-id or to 0. Used for +** testing and debugging only. + */ + +/* +** HAVE_MREMAP defaults to true on Linux and false everywhere else. + */ + +/* +** Explicitly call the 64-bit version of lseek() on Android. Otherwise, lseek() +** is the 32-bit version, even if _FILE_OFFSET_BITS=64 is defined. + */ + +// C documentation +// +// /* +// ** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation +// ** is used regardless of the run-time threadsafety setting. +// */ +func _sqlite3DefaultMutex(tls *libc.TLS) (r uintptr) { + return _sqlite3NoopMutex(tls) +} + +/************** End of mutex_noop.c ******************************************/ +/************** Begin file mutex_unix.c **************************************/ +/* +** 2007 August 28 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the C functions that implement mutexes for pthreads + */ +/* #include "sqliteInt.h" */ + +/* +** The code in this file is only used if we are compiling threadsafe +** under unix with pthreads. +** +** Note that this implementation requires a version of pthreads that +** supports recursive mutexes. + */ + +/************** End of mutex_unix.c ******************************************/ +/************** Begin file mutex_w32.c ***************************************/ +/* +** 2007 August 14 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the C functions that implement mutexes for Win32. + */ +/* #include "sqliteInt.h" */ + +/* +** The code in this file is only used if we are compiling multithreaded +** on a Win32 system. + */ + +/************** End of mutex_w32.c *******************************************/ +/************** Begin file malloc.c ******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** Memory allocation functions used throughout sqlite. + */ +/* #include "sqliteInt.h" */ +/* #include */ + +// C documentation +// +// /* Get the results of the thread */ +func _sqlite3ThreadJoin(tls *libc.TLS, p uintptr, ppOut uintptr) (r int32) { + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if (*TSQLiteThread)(unsafe.Pointer(p)).FxTask != 0 { + **(**uintptr)(__ccgo_up(ppOut)) = (*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TSQLiteThread)(unsafe.Pointer(p)).FxTask})))(tls, (*TSQLiteThread)(unsafe.Pointer(p)).FpIn) + } else { + **(**uintptr)(__ccgo_up(ppOut)) = (*TSQLiteThread)(unsafe.Pointer(p)).FpResult + } + Xsqlite3_free(tls, p) + return SQLITE_OK +} + +/****************************** End Single-Threaded *************************/ + +/************** End of threads.c *********************************************/ +/************** Begin file utf.c *********************************************/ +/* +** 2004 April 13 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains routines used to translate between UTF-8, +** UTF-16, UTF-16BE, and UTF-16LE. +** +** Notes on UTF-8: +** +** Byte-0 Byte-1 Byte-2 Byte-3 Value +** 0xxxxxxx 00000000 00000000 0xxxxxxx +** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx +** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx +** 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx 000uuuuu zzzzyyyy yyxxxxxx +** +** +** Notes on UTF-16: (with wwww+1==uuuuu) +** +** Word-0 Word-1 Value +** 110110ww wwzzzzyy 110111yy yyxxxxxx 000uuuuu zzzzyyyy yyxxxxxx +** zzzzyyyy yyxxxxxx 00000000 zzzzyyyy yyxxxxxx +** +** +** BOM or Byte Order Mark: +** 0xff 0xfe little-endian utf-16 follows +** 0xfe 0xff big-endian utf-16 follows +** + */ +/* #include "sqliteInt.h" */ +/* #include */ +/* #include "vdbeInt.h" */ + +// C documentation +// +// /* +// ** Implement a memory barrier or memory fence on shared memory. +// ** +// ** All loads and stores begun before the barrier must complete before +// ** any load or store begun after the barrier. +// */ +func _unixShmBarrier(tls *libc.TLS, fd uintptr) { + _ = fd + /* compiler-defined memory barrier */ + _unixEnterMutex(tls) /* Also mutex, for redundancy */ + _unixLeaveMutex(tls) +} + +type daddr_t = Tdaddr_t + +type fixpt_t = Tfixpt_t + +type rlim_t = Trlim_t + +type segsz_t = Tsegsz_t + +type t__int16_t = int16 + +type t__int32_t = int32 + +type t__int64_t = int64 + +type t__int8_t = int8 + +type t__uint16_t = uint16 + +type t__uint32_t = uint32 + +type t__uint64_t = uint64 + +type t__uint8_t = uint8 diff --git a/internal/engine/lib/sqlite_g_000000000001c17f.go b/internal/engine/lib/sqlite_g_000000000001c17f.go new file mode 100644 index 0000000..d9467f7 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001c17f.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && arm) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __INT_FAST16_TYPE__ = 0 diff --git a/internal/engine/lib/sqlite_g_000000000001d740.go b/internal/engine/lib/sqlite_g_000000000001d740.go new file mode 100644 index 0000000..a264909 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001d740.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Tnlink_t = uint32 diff --git a/internal/engine/lib/sqlite_g_000000000001d77f.go b/internal/engine/lib/sqlite_g_000000000001d77f.go new file mode 100644 index 0000000..bee8ee9 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001d77f.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Tblksize_t = int32 diff --git a/internal/engine/lib/sqlite_g_000000000001dea8.go b/internal/engine/lib/sqlite_g_000000000001dea8.go new file mode 100644 index 0000000..d0c81f6 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001dea8.go @@ -0,0 +1,1468 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** This routine redistributes cells on the iParentIdx'th child of pParent +// ** (hereafter "the page") and up to 2 siblings so that all pages have about the +// ** same amount of free space. Usually a single sibling on either side of the +// ** page are used in the balancing, though both siblings might come from one +// ** side if the page is the first or last child of its parent. If the page +// ** has fewer than 2 siblings (something which can only happen if the page +// ** is a root page or a child of a root page) then all available siblings +// ** participate in the balancing. +// ** +// ** The number of siblings of the page might be increased or decreased by +// ** one or two in an effort to keep pages nearly full but not over full. +// ** +// ** Note that when this routine is called, some of the cells on the page +// ** might not actually be stored in MemPage.aData[]. This can happen +// ** if the page is overfull. This routine ensures that all cells allocated +// ** to the page and its siblings fit into MemPage.aData[] before returning. +// ** +// ** In the course of balancing the page and its siblings, cells may be +// ** inserted into or removed from the parent page (pParent). Doing so +// ** may cause the parent page to become overfull or underfull. If this +// ** happens, it is the responsibility of the caller to invoke the correct +// ** balancing routine to fix this problem (see the balance() routine). +// ** +// ** If this routine fails for any reason, it might leave the database +// ** in a corrupted state. So if this routine fails, the database should +// ** be rolled back. +// ** +// ** The third argument to this function, aOvflSpace, is a pointer to a +// ** buffer big enough to hold one page. If while inserting cells into the parent +// ** page (pParent) the parent page becomes overfull, this buffer is +// ** used to store the parent's overflow cells. Because this function inserts +// ** a maximum of four divider cells into the parent page, and the maximum +// ** size of a cell stored within an internal node is always less than 1/4 +// ** of the page-size, the aOvflSpace[] buffer is guaranteed to be large +// ** enough for all overflow cells. +// ** +// ** If aOvflSpace is set to a null pointer, this function returns +// ** SQLITE_NOMEM. +// */ +func _balance_nonroot(tls *libc.TLS, pParent uintptr, iParentIdx int32, aOvflSpace uintptr, isRoot int32, bBulk int32) (r1 int32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var aData, aSpace1, p, pBt, pCell, pCell1, pNew1, pNew2, pOld, pOld1, pOld2, pRight, pSrcEnd, pTemp, pTemp1, piCell, piEnd, v17 uintptr + var aPgno [5]TPgno + var apDiv [2]uintptr + var apNew [5]uintptr + var cntNew, cntOld [5]int32 + var cntOldNext, d, i, iB, iNew, iNew1, iOff, iOld, iOld1, iOvflSpace, iPg, iSpace1, j, k, leafData, limit, nMaxCells, nNew, nNewCell, nOld, nxDiv, pageFlags, r, sz1, sz2, szD, szLeft, szR, szRight, usableSpace, v1 int32 + var fgA, fgB, leafCorrection, maskPage, sz Tu16 + var key Tu32 + var pgnoA, pgnoB, pgnoTemp TPgno + var szScratch Tu64 + var v13, v14 bool + var v18 uint32 + var _ /* abDone at bp+60 */ [5]Tu8 + var _ /* apOld at bp+8 */ [3]uintptr + var _ /* b at bp+72 */ TCellArray + var _ /* info at bp+184 */ TCellInfo + var _ /* pNew at bp+176 */ uintptr + var _ /* pgno at bp+52 */ TPgno + var _ /* rc at bp+0 */ int32 + var _ /* szNew at bp+32 */ [5]int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, aPgno, aSpace1, apDiv, apNew, cntNew, cntOld, cntOldNext, d, fgA, fgB, i, iB, iNew, iNew1, iOff, iOld, iOld1, iOvflSpace, iPg, iSpace1, j, k, key, leafCorrection, leafData, limit, maskPage, nMaxCells, nNew, nNewCell, nOld, nxDiv, p, pBt, pCell, pCell1, pNew1, pNew2, pOld, pOld1, pOld2, pRight, pSrcEnd, pTemp, pTemp1, pageFlags, pgnoA, pgnoB, pgnoTemp, piCell, piEnd, r, sz, sz1, sz2, szD, szLeft, szR, szRight, szScratch, usableSpace, v1, v13, v14, v17, v18 /* The whole database */ + nMaxCells = 0 /* Allocated size of apCell, szCell, aFrom. */ + nNew = 0 /* Next divider slot in pParent->aCell[] */ + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Value of pPage->aData[0] */ + iSpace1 = 0 /* First unused byte of aSpace1[] */ + iOvflSpace = 0 /* Parsed information on cells being balanced */ + libc.Xmemset(tls, bp+60, 0, uint64(5)) + libc.Xmemset(tls, bp+72, 0, libc.Uint64FromInt64(104)-libc.Uint64FromInt64(4)) + **(**int32)(__ccgo_up(bp + 72 + 80 + uintptr(libc.Int32FromInt32(NB)*libc.Int32FromInt32(2)-libc.Int32FromInt32(1))*4)) = int32(0x7fffffff) + pBt = (*TMemPage)(unsafe.Pointer(pParent)).FpBt + /* At this point pParent may have at most one overflow cell. And if + ** this overflow cell is present, it must be the cell with + ** index iParentIdx. This scenario comes about when this function + ** is called (indirectly) from sqlite3BtreeDelete(). + */ + if !(aOvflSpace != 0) { + return int32(SQLITE_NOMEM) + } + /* Find the sibling pages to balance. Also locate the cells in pParent + ** that divide the siblings. An attempt is made to find NN siblings on + ** either side of pPage. More siblings are taken from one side, however, + ** if there are fewer than NN siblings on the other side. If pParent + ** has NB or fewer children then all children of pParent are taken. + ** + ** This loop also drops the divider cells from the parent page. This + ** way, the remainder of the function does not have to deal with any + ** overflow cells in the parent page, since if any existed they will + ** have already been removed. + */ + i = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FnOverflow) + libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FnCell) + if i < int32(2) { + nxDiv = 0 + } else { + if iParentIdx == 0 { + nxDiv = 0 + } else { + if iParentIdx == i { + nxDiv = i - int32(2) + bBulk + } else { + nxDiv = iParentIdx - int32(1) + } + } + i = int32(2) - bBulk + } + nOld = i + int32(1) + if i+nxDiv-libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FnOverflow) == libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FnCell) { + pRight = (*TMemPage)(unsafe.Pointer(pParent)).FaData + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FhdrOffset)+int32(8)) + } else { + pRight = (*TMemPage)(unsafe.Pointer(pParent)).FaData + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pParent)).FaCellIdx + uintptr(int32(2)*(i+nxDiv-libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FnOverflow))))))< 0 { + if limit < libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pOld + 28))) { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81599)) + goto balance_cleanup + } + limit = libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pOld + 28))) + j = 0 + for { + if !(j < limit) { + break + } + **(**uintptr)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FapCell + uintptr((**(**TCellArray)(__ccgo_up(bp + 72))).FnCell)*8)) = aData + uintptr(libc.Int32FromUint16(maskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(piCell)))< usableSpace { + if i+int32(1) >= k { + k = i + int32(2) + if k > libc.Int32FromInt32(NB)+libc.Int32FromInt32(2) { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81700)) + goto balance_cleanup + } + (**(**[5]int32)(__ccgo_up(bp + 32)))[k-int32(1)] = 0 + cntNew[k-int32(1)] = (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell + } + sz1 = int32(2) + libc.Int32FromUint16(_cachedCellSize(tls, bp+72, cntNew[i]-int32(1))) + **(**int32)(__ccgo_up(bp + 32 + uintptr(i)*4)) -= sz1 + if !(leafData != 0) { + if cntNew[i] < (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell { + sz1 = int32(2) + libc.Int32FromUint16(_cachedCellSize(tls, bp+72, cntNew[i])) + } else { + sz1 = 0 + } + } + **(**int32)(__ccgo_up(bp + 32 + uintptr(i+int32(1))*4)) += sz1 + cntNew[i] = cntNew[i] - 1 + } + for cntNew[i] < (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell { + sz1 = int32(2) + libc.Int32FromUint16(_cachedCellSize(tls, bp+72, cntNew[i])) + if (**(**[5]int32)(__ccgo_up(bp + 32)))[i]+sz1 > usableSpace { + break + } + **(**int32)(__ccgo_up(bp + 32 + uintptr(i)*4)) += sz1 + cntNew[i] = cntNew[i] + 1 + if !(leafData != 0) { + if cntNew[i] < (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell { + sz1 = int32(2) + libc.Int32FromUint16(_cachedCellSize(tls, bp+72, cntNew[i])) + } else { + sz1 = 0 + } + } + **(**int32)(__ccgo_up(bp + 32 + uintptr(i+int32(1))*4)) -= sz1 + } + if cntNew[i] >= (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell { + k = i + int32(1) + } else { + if i > 0 { + v1 = cntNew[i-int32(1)] + } else { + v1 = 0 + } + if cntNew[i] <= v1 { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81733)) + goto balance_cleanup + } + } + goto _9 + _9: + ; + i = i + 1 + } + /* + ** The packing computed by the previous block is biased toward the siblings + ** on the left side (siblings with smaller keys). The left siblings are + ** always nearly full, while the right-most sibling might be nearly empty. + ** The next block of code attempts to adjust the packing of siblings to + ** get a better balance. + ** + ** This adjustment is more than an optimization. The packing above might + ** be so out of balance as to be illegal. For example, the right-most + ** sibling might be completely empty. This adjustment is not optional. + */ + i = k - int32(1) + for { + if !(i > 0) { + break + } + szRight = (**(**[5]int32)(__ccgo_up(bp + 32)))[i] /* Size of sibling on the right */ + szLeft = (**(**[5]int32)(__ccgo_up(bp + 32)))[i-int32(1)] /* Index of first cell to the left of right sibling */ + r = cntNew[i-int32(1)] - int32(1) + d = r + int32(1) - leafData + _cachedCellSize(tls, bp+72, d) + for cond := true; cond; cond = r >= 0 { + szR = libc.Int32FromUint16(_cachedCellSize(tls, bp+72, r)) + szD = libc.Int32FromUint16(**(**Tu16)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FszCell + uintptr(d)*2))) + if v14 = szRight != 0; v14 { + if v13 = bBulk != 0; !v13 { + if i == k-int32(1) { + v1 = 0 + } else { + v1 = int32(2) + } + } + } + if v14 && (v13 || szRight+szD+int32(2) > szLeft-(szR+v1)) { + break + } + szRight = szRight + (szD + int32(2)) + szLeft = szLeft - (szR + int32(2)) + cntNew[i-int32(1)] = r + r = r - 1 + d = d - 1 + } + (**(**[5]int32)(__ccgo_up(bp + 32)))[i] = szRight + (**(**[5]int32)(__ccgo_up(bp + 32)))[i-int32(1)] = szLeft + if i > int32(1) { + v1 = cntNew[i-int32(2)] + } else { + v1 = 0 + } + if cntNew[i-int32(1)] <= v1 { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81777)) + goto balance_cleanup + } + goto _11 + _11: + ; + i = i - 1 + } + /* Sanity check: For a non-corrupt database file one of the following + ** must be true: + ** (1) We found one or more cells (cntNew[0])>0), or + ** (2) pPage is a virtual root page. A virtual root page is when + ** the real root page is page 1 and we are the only child of + ** that page. + */ + /* + ** Allocate k new pages. Reuse old pages where possible. + */ + pageFlags = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer((**(**[3]uintptr)(__ccgo_up(bp + 8)))[0])).FaData))) + i = 0 + for { + if !(i < k) { + break + } + if i < nOld { + v17 = (**(**[3]uintptr)(__ccgo_up(bp + 8)))[i] + apNew[i] = v17 + **(**uintptr)(__ccgo_up(bp + 176)) = v17 + (**(**[3]uintptr)(__ccgo_up(bp + 8)))[i] = uintptr(0) + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 176)))).FpDbPage) + nNew = nNew + 1 + if _sqlite3PagerPageRefcount(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 176)))).FpDbPage) != int32(1)+libc.BoolInt32(i == iParentIdx-nxDiv) && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(81810)) + } + if **(**int32)(__ccgo_up(bp)) != 0 { + goto balance_cleanup + } + } else { + if bBulk != 0 { + v18 = uint32(1) + } else { + v18 = **(**TPgno)(__ccgo_up(bp + 52)) + } + **(**int32)(__ccgo_up(bp)) = _allocateBtreePage(tls, pBt, bp+176, bp+52, v18, uint8(0)) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto balance_cleanup + } + _zeroPage(tls, **(**uintptr)(__ccgo_up(bp + 176)), pageFlags) + apNew[i] = **(**uintptr)(__ccgo_up(bp + 176)) + nNew = nNew + 1 + cntOld[i] = (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell + /* Set the pointer-map entry for the new sibling page. */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _ptrmapPut(tls, pBt, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 176)))).Fpgno, uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(pParent)).Fpgno, bp) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto balance_cleanup + } + } + } + goto _16 + _16: + ; + i = i + 1 + } + /* + ** Reassign page numbers so that the new pages are in ascending order. + ** This helps to keep entries in the disk file in order so that a scan + ** of the table is closer to a linear scan through the file. That in turn + ** helps the operating system to deliver pages from the disk more rapidly. + ** + ** An O(N*N) sort algorithm is used, but since N is never more than NB+2 + ** (5), that is not a performance concern. + ** + ** When NB==3, this one optimization makes the database about 25% faster + ** for large insertions and deletions. + */ + i = 0 + for { + if !(i < nNew) { + break + } + aPgno[i] = (*TMemPage)(unsafe.Pointer(apNew[i])).Fpgno + goto _19 + _19: + ; + i = i + 1 + } + i = 0 + for { + if !(i < nNew-int32(1)) { + break + } + iB = i + j = i + int32(1) + for { + if !(j < nNew) { + break + } + if (*TMemPage)(unsafe.Pointer(apNew[j])).Fpgno < (*TMemPage)(unsafe.Pointer(apNew[iB])).Fpgno { + iB = j + } + goto _21 + _21: + ; + j = j + 1 + } + /* If apNew[i] has a page number that is bigger than any of the + ** subsequence apNew[i] entries, then swap apNew[i] with the subsequent + ** entry that has the smallest page number (which we know to be + ** entry apNew[iB]). + */ + if iB != i { + pgnoA = (*TMemPage)(unsafe.Pointer(apNew[i])).Fpgno + pgnoB = (*TMemPage)(unsafe.Pointer(apNew[iB])).Fpgno + pgnoTemp = libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize + uint32(1) + fgA = (*TDbPage)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(apNew[i])).FpDbPage)).Fflags + fgB = (*TDbPage)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(apNew[iB])).FpDbPage)).Fflags + _sqlite3PagerRekey(tls, (*TMemPage)(unsafe.Pointer(apNew[i])).FpDbPage, pgnoTemp, fgB) + _sqlite3PagerRekey(tls, (*TMemPage)(unsafe.Pointer(apNew[iB])).FpDbPage, pgnoA, fgA) + _sqlite3PagerRekey(tls, (*TMemPage)(unsafe.Pointer(apNew[i])).FpDbPage, pgnoB, fgB) + (*TMemPage)(unsafe.Pointer(apNew[i])).Fpgno = pgnoB + (*TMemPage)(unsafe.Pointer(apNew[iB])).Fpgno = pgnoA + } + goto _20 + _20: + ; + i = i + 1 + } + _sqlite3Put4byte(tls, pRight, (*TMemPage)(unsafe.Pointer(apNew[nNew-int32(1)])).Fpgno) + /* If the sibling pages are not leaves, ensure that the right-child pointer + ** of the right-most new sibling page is set to the value that was + ** originally in the same field of the right-most old sibling page. */ + if pageFlags&int32(PTF_LEAF) == 0 && nOld != nNew { + if nNew > nOld { + pOld1 = apNew[nOld-int32(1)] + } else { + pOld1 = (**(**[3]uintptr)(__ccgo_up(bp + 8)))[nOld-int32(1)] + } + libc.Xmemcpy(tls, (*TMemPage)(unsafe.Pointer(apNew[nNew-int32(1)])).FaData+8, (*TMemPage)(unsafe.Pointer(pOld1)).FaData+8, uint64(4)) + } + /* Make any required updates to pointer map entries associated with + ** cells stored on sibling pages following the balance operation. Pointer + ** map entries associated with divider cells are set by the insertCell() + ** routine. The associated pointer map entries are: + ** + ** a) if the cell contains a reference to an overflow chain, the + ** entry associated with the first page in the overflow chain, and + ** + ** b) if the sibling pages are not leaves, the child page associated + ** with the cell. + ** + ** If the sibling pages are not leaves, then the pointer map entry + ** associated with the right-child of each sibling may also need to be + ** updated. This happens below, after the sibling pages have been + ** populated, not here. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + v17 = apNew[0] + pOld2 = v17 + pNew1 = v17 + cntOldNext = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pNew1)).FnCell) + libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pNew1)).FnOverflow) + iNew = 0 + iOld = 0 + i = 0 + for { + if !(i < (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell) { + break + } + pCell = **(**uintptr)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FapCell + uintptr(i)*8)) + for i == cntOldNext { + iOld = iOld + 1 + if iOld < nNew { + v17 = apNew[iOld] + } else { + v17 = (**(**[3]uintptr)(__ccgo_up(bp + 8)))[iOld] + } + pOld2 = v17 + cntOldNext = cntOldNext + (libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pOld2)).FnCell) + libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pOld2)).FnOverflow) + libc.BoolInt32(!(leafData != 0))) + } + if i == cntNew[iNew] { + iNew = iNew + 1 + v1 = iNew + pNew1 = apNew[v1] + if !(leafData != 0) { + goto _23 + } + } + /* Cell pCell is destined for new sibling page pNew. Originally, it + ** was either part of sibling page iOld (possibly an overflow cell), + ** or else the divider cell to the left of sibling page iOld. So, + ** if sibling page iOld had the same page number as pNew, and if + ** pCell really was a part of sibling page iOld (not a divider or + ** overflow cell), we can skip updating the pointer map entries. */ + if iOld >= nNew || (*TMemPage)(unsafe.Pointer(pNew1)).Fpgno != aPgno[iOld] || !(uint64(pCell) >= uint64((*TMemPage)(unsafe.Pointer(pOld2)).FaData) && uint64(pCell) < uint64((*TMemPage)(unsafe.Pointer(pOld2)).FaDataEnd)) { + if !(leafCorrection != 0) { + _ptrmapPut(tls, pBt, _sqlite3Get4byte(tls, pCell), uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(pNew1)).Fpgno, bp) + } + if libc.Int32FromUint16(_cachedCellSize(tls, bp+72, i)) > libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pNew1)).FminLocal) { + _ptrmapPutOvflPtr(tls, pNew1, pOld2, pCell, bp) + } + if **(**int32)(__ccgo_up(bp)) != 0 { + goto balance_cleanup + } + } + goto _23 + _23: + ; + i = i + 1 + } + } + /* Insert new divider cells into pParent. */ + i = 0 + for { + if !(i < nNew-int32(1)) { + break + } + pNew2 = apNew[i] + j = cntNew[i] + pCell1 = **(**uintptr)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FapCell + uintptr(j)*8)) + sz2 = libc.Int32FromUint16(**(**Tu16)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FszCell + uintptr(j)*2))) + libc.Int32FromUint16(leafCorrection) + pTemp1 = aOvflSpace + uintptr(iOvflSpace) + if !((*TMemPage)(unsafe.Pointer(pNew2)).Fleaf != 0) { + libc.Xmemcpy(tls, (*TMemPage)(unsafe.Pointer(pNew2)).FaData+8, pCell1, uint64(4)) + } else { + if leafData != 0 { + j = j - 1 + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pNew2)).FxParseCell})))(tls, pNew2, **(**uintptr)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FapCell + uintptr(j)*8)), bp+184) + pCell1 = pTemp1 + sz2 = int32(4) + _sqlite3PutVarint(tls, pCell1+4, libc.Uint64FromInt64((**(**TCellInfo)(__ccgo_up(bp + 184))).FnKey)) + pTemp1 = uintptr(0) + } else { + pCell1 = pCell1 - uintptr(4) + /* Obscure case for non-leaf-data trees: If the cell at pCell was + ** previously stored on a leaf node, and its reported size was 4 + ** bytes, then it may actually be smaller than this + ** (see btreeParseCellPtr(), 4 bytes is the minimum size of + ** any cell). But it is important to pass the correct size to + ** insertCell(), so reparse the cell now. + ** + ** This can only happen for b-trees used to evaluate "IN (SELECT ...)" + ** and WITHOUT ROWID tables with exactly one column which is the + ** primary key. + */ + if libc.Int32FromUint16(**(**Tu16)(__ccgo_up((**(**TCellArray)(__ccgo_up(bp + 72))).FszCell + uintptr(j)*2))) == int32(4) { + sz2 = libc.Int32FromUint16((*(*func(*libc.TLS, uintptr, uintptr) Tu16)(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pParent)).FxCellSize})))(tls, pParent, pCell1)) + } + } + } + iOvflSpace = iOvflSpace + sz2 + k = 0 + for { + if !(**(**int32)(__ccgo_up(bp + 72 + 80 + uintptr(k)*4)) <= j) { + break + } + goto _27 + _27: + ; + k = k + 1 + } + pSrcEnd = **(**uintptr)(__ccgo_up(bp + 72 + 32 + uintptr(k)*8)) + if uint64(pCell1) < uint64(pSrcEnd) && uint64(pCell1+uintptr(sz2)) > uint64(pSrcEnd) { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(82016)) + goto balance_cleanup + } + **(**int32)(__ccgo_up(bp)) = _insertCell(tls, pParent, nxDiv+i, pCell1, sz2, pTemp1, (*TMemPage)(unsafe.Pointer(pNew2)).Fpgno) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto balance_cleanup + } + goto _26 + _26: + ; + i = i + 1 + } + /* Now update the actual sibling pages. The order in which they are updated + ** is important, as this code needs to avoid disrupting any page from which + ** cells may still to be read. In practice, this means: + ** + ** (1) If cells are moving left (from apNew[iPg] to apNew[iPg-1]) + ** then it is not safe to update page apNew[iPg] until after + ** the left-hand sibling apNew[iPg-1] has been updated. + ** + ** (2) If cells are moving right (from apNew[iPg] to apNew[iPg+1]) + ** then it is not safe to update page apNew[iPg] until after + ** the right-hand sibling apNew[iPg+1] has been updated. + ** + ** If neither of the above apply, the page is safe to update. + ** + ** The iPg value in the following loop starts at nNew-1 goes down + ** to 0, then back up to nNew-1 again, thus making two passes over + ** the pages. On the initial downward pass, only condition (1) above + ** needs to be tested because (2) will always be true from the previous + ** step. On the upward pass, both conditions are always true, so the + ** upwards pass simply processes pages that were missed on the downward + ** pass. + */ + i = int32(1) - nNew + for { + if !(i < nNew) { + break + } + if i < 0 { + v1 = -i + } else { + v1 = i + } + iPg = v1 + if (**(**[5]Tu8)(__ccgo_up(bp + 60)))[iPg] != 0 { + goto _28 + } /* Skip pages already processed */ + if i >= 0 || cntOld[iPg-int32(1)] >= cntNew[iPg-int32(1)] { + /* Verify condition (1): If cells are moving left, update iPg + ** only after iPg-1 has already been updated. */ + /* Verify condition (2): If cells are moving right, update iPg + ** only after iPg+1 has already been updated. */ + if iPg == 0 { + v1 = libc.Int32FromInt32(0) + iOld1 = v1 + iNew1 = v1 + nNewCell = cntNew[0] + } else { + if iPg < nOld { + v1 = cntOld[iPg-int32(1)] + libc.BoolInt32(!(leafData != 0)) + } else { + v1 = (**(**TCellArray)(__ccgo_up(bp + 72))).FnCell + } + iOld1 = v1 + iNew1 = cntNew[iPg-int32(1)] + libc.BoolInt32(!(leafData != 0)) + nNewCell = cntNew[iPg] - iNew1 + } + **(**int32)(__ccgo_up(bp)) = _editPage(tls, apNew[iPg], iOld1, iNew1, nNewCell, bp+72) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto balance_cleanup + } + (**(**[5]Tu8)(__ccgo_up(bp + 60)))[iPg] = (**(**[5]Tu8)(__ccgo_up(bp + 60)))[iPg] + 1 + (*TMemPage)(unsafe.Pointer(apNew[iPg])).FnFree = usableSpace - (**(**[5]int32)(__ccgo_up(bp + 32)))[iPg] + } + goto _28 + _28: + ; + i = i + 1 + } + /* All pages have been processed exactly once */ + if isRoot != 0 && libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FnCell) == 0 && libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pParent)).FhdrOffset) <= (*TMemPage)(unsafe.Pointer(apNew[0])).FnFree { + /* The root page of the b-tree now contains no cells. The only sibling + ** page is the right-child of the parent. Copy the contents of the + ** child page into the parent, decreasing the overall height of the + ** b-tree structure by one. This is described as the "balance-shallower" + ** sub-algorithm in some documentation. + ** + ** If this is an auto-vacuum database, the call to copyNodeContent() + ** sets all pointer-map entries corresponding to database image pages + ** for which the pointer is stored within the content being copied. + ** + ** It is critical that the child page be defragmented before being + ** copied into the parent, because if the parent is page 1 then it will + ** by smaller than the child due to the database header, and so all the + ** free space needs to be up front. + */ + **(**int32)(__ccgo_up(bp)) = _defragmentPage(tls, apNew[0], -int32(1)) + _copyNodeContent(tls, apNew[0], pParent, bp) + _freePage(tls, apNew[0], bp) + } else { + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && !(leafCorrection != 0) { + /* Fix the pointer map entries associated with the right-child of each + ** sibling page. All other pointer map entries have already been taken + ** care of. */ + i = 0 + for { + if !(i < nNew) { + break + } + key = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(apNew[i])).FaData+8) + _ptrmapPut(tls, pBt, key, uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(apNew[i])).Fpgno, bp) + goto _32 + _32: + ; + i = i + 1 + } + } + } + /* Free any old pages that were not reused as new pages. + */ + i = nNew + for { + if !(i < nOld) { + break + } + _freePage(tls, (**(**[3]uintptr)(__ccgo_up(bp + 8)))[i], bp) + goto _33 + _33: + ; + i = i + 1 + } + /* + ** Cleanup before returning. + */ + goto balance_cleanup +balance_cleanup: + ; + _sqlite3DbFree(tls, uintptr(0), (**(**TCellArray)(__ccgo_up(bp + 72))).FapCell) + i = 0 + for { + if !(i < nOld) { + break + } + _releasePage(tls, (**(**[3]uintptr)(__ccgo_up(bp + 8)))[i]) + goto _34 + _34: + ; + i = i + 1 + } + i = 0 + for { + if !(i < nNew) { + break + } + _releasePage(tls, apNew[i]) + goto _35 + _35: + ; + i = i + 1 + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* Move the cursor so that it points to an entry in an index table +// ** near the key pIdxKey. Return a success code. +// ** +// ** If an exact match is not found, then the cursor is always +// ** left pointing at a leaf page which would hold the entry if it +// ** were present. The cursor might point to an entry that comes +// ** before or after the key. +// ** +// ** An integer is written into *pRes which is the result of +// ** comparing the key with the entry to which the cursor is +// ** pointing. The meaning of the integer written into +// ** *pRes is as follows: +// ** +// ** *pRes<0 The cursor is left pointing at an entry that +// ** is smaller than pIdxKey or if the table is empty +// ** and the cursor is therefore left point to nothing. +// ** +// ** *pRes==0 The cursor is left pointing at an entry that +// ** exactly matches pIdxKey. +// ** +// ** *pRes>0 The cursor is left pointing at an entry that +// ** is larger than pIdxKey. +// ** +// ** The pIdxKey->eqSeen field is set to 1 if there +// ** exists an entry in the table that exactly matches pIdxKey. +// */ +func _sqlite3BtreeIndexMoveto(tls *libc.TLS, pCur uintptr, pIdxKey uintptr, pRes uintptr) (r int32) { + var c, c1, idx, lwr, nCell, nOverrun, rc, upr, v1 int32 + var chldPg TPgno + var pCell, pCellBody, pCellKey, pPage, v3 uintptr + var xRecordCompare TRecordCompare + var v10 Ti8 + var v2 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, c1, chldPg, idx, lwr, nCell, nOverrun, pCell, pCellBody, pCellKey, pPage, rc, upr, xRecordCompare, v1, v10, v2, v3 + xRecordCompare = _sqlite3VdbeFindCompare(tls, pIdxKey) + (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode = uint8(0) + /* Check to see if we can skip a lot of work. Two cases: + ** + ** (1) If the cursor is already pointing to the very last cell + ** in the table and the pIdxKey search key is greater than or + ** equal to that last cell, then no movement is required. + ** + ** (2) If the cursor is on the last page of the table and the first + ** cell on that last page is less than or equal to the pIdxKey + ** search key, then we can start the search on the current page + ** without needing to go back to root. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID && (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf != 0 && _cursorOnLastPage(tls, pCur) != 0 { + if v2 = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) == libc.Int32FromUint16((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell)-int32(1); v2 { + v1 = _indexCellCompare(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage, libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix), pIdxKey, xRecordCompare) + c = v1 + } + if v2 && v1 <= 0 && libc.Int32FromUint8((*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode) == SQLITE_OK { + **(**int32)(__ccgo_up(pRes)) = c + return SQLITE_OK /* Cursor already pointing at the correct spot */ + } + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) > 0 && _indexCellCompare(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage, 0, pIdxKey, xRecordCompare) <= 0 && libc.Int32FromUint8((*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode) == SQLITE_OK { + v3 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(BTCF_ValidOvfl) | libc.Int32FromInt32(BTCF_AtLast))) + if !((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FisInit != 0) { + return _sqlite3CorruptError(tls, int32(79227)) + } + goto bypass_moveto_root /* Start search on the current page */ + } + (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode = uint8(SQLITE_OK) + } + rc = _moveToRoot(tls, pCur) + if rc != 0 { + if rc == int32(SQLITE_EMPTY) { + **(**int32)(__ccgo_up(pRes)) = -int32(1) + return SQLITE_OK + } + return rc + } + goto bypass_moveto_root +bypass_moveto_root: + ; + for { + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage /* Pointer to current cell in pPage */ + /* pPage->nCell must be greater than zero. If this is the root-page + ** the cursor would have been INVALID above and this for(;;) loop + ** not run. If this is not the root-page, then the moveToChild() routine + ** would have already detected db corruption. Similarly, pPage must + ** be the right kind (index or table) of b-tree page. Otherwise + ** a moveToChild() or moveToRoot() call would have detected corruption. */ + lwr = 0 + upr = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) - int32(1) + idx = upr >> int32(1) /* idx = (lwr+upr)/2; */ + for { /* Size of the pCell cell in bytes */ + pCell = (*TMemPage)(unsafe.Pointer(pPage)).FaDataOfst + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*idx))))< (*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBt)).FnPage { + rc = _sqlite3CorruptError(tls, int32(79314)) + goto moveto_index_finish + } + pCellKey = _sqlite3Malloc(tls, libc.Uint64FromInt32(nCell)+libc.Uint64FromInt32(nOverrun)) + if pCellKey == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto moveto_index_finish + } + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(idx) + rc = _accessPayload(tls, pCur, uint32(0), libc.Uint32FromInt32(nCell), pCellKey, 0) + libc.Xmemset(tls, pCellKey+uintptr(nCell), 0, libc.Uint64FromInt32(nOverrun)) /* Fix uninit warnings */ + v3 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & ^libc.Int32FromInt32(BTCF_ValidOvfl)) + if rc != 0 { + Xsqlite3_free(tls, pCellKey) + goto moveto_index_finish + } + c1 = _sqlite3VdbeRecordCompare(tls, nCell, pCellKey, pIdxKey) + Xsqlite3_free(tls, pCellKey) + } + } + if c1 < 0 { + lwr = idx + int32(1) + } else { + if c1 > 0 { + upr = idx - int32(1) + } else { + **(**int32)(__ccgo_up(pRes)) = 0 + rc = SQLITE_OK + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(idx) + if (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode != 0 { + rc = _sqlite3CorruptError(tls, int32(79346)) + } + goto moveto_index_finish + } + } + if lwr > upr { + break + } + idx = (lwr + upr) >> int32(1) /* idx = (lwr+upr)/2 */ + goto _5 + _5: + } + if (*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(idx) + **(**int32)(__ccgo_up(pRes)) = c1 + rc = SQLITE_OK + goto moveto_index_finish + } + if lwr >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + chldPg = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(8))) + } else { + chldPg = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*lwr))))<ix = (u16)lwr; + ** rc = moveToChild(pCur, chldPg); + ** if( rc ) break; + */ + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + v3 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) >= libc.Int32FromInt32(BTCURSOR_MAX_DEPTH)-libc.Int32FromInt32(1) { + return _sqlite3CorruptError(tls, int32(79377)) + } + **(**Tu16)(__ccgo_up(pCur + 88 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*2)) = libc.Uint16FromInt32(lwr) + **(**uintptr)(__ccgo_up(pCur + 144 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*8)) = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = uint16(0) + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = (*TBtCursor)(unsafe.Pointer(pCur)).FiPage + 1 + rc = _getAndInitPage(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBt, chldPg, pCur+136, libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags)) + if rc == SQLITE_OK && (libc.Int32FromUint16((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell) < int32(1) || libc.Int32FromUint8((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FintKey) != libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurIntKey)) { + _releasePage(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage) + rc = _sqlite3CorruptError(tls, int32(79388)) + } + if rc != 0 { + v3 = pCur + 84 + *(*Ti8)(unsafe.Pointer(v3)) = *(*Ti8)(unsafe.Pointer(v3)) - 1 + v10 = *(*Ti8)(unsafe.Pointer(v3)) + (*TBtCursor)(unsafe.Pointer(pCur)).FpPage = **(**uintptr)(__ccgo_up(pCur + 144 + uintptr(v10)*8)) + break + } + /* + ***** End of in-lined moveToChild() call */ + goto _4 + _4: + } + goto moveto_index_finish +moveto_index_finish: + ; + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + return rc +} + +// C documentation +// +// /* +// ** Insert a new record into the BTree. The content of the new record +// ** is described by the pX object. The pCur cursor is used only to +// ** define what table the record should be inserted into, and is left +// ** pointing at a random location. +// ** +// ** For a table btree (used for rowid tables), only the pX.nKey value of +// ** the key is used. The pX.pKey value must be NULL. The pX.nKey is the +// ** rowid or INTEGER PRIMARY KEY of the row. The pX.nData,pData,nZero fields +// ** hold the content of the row. +// ** +// ** For an index btree (used for indexes and WITHOUT ROWID tables), the +// ** key is an arbitrary byte sequence stored in pX.pKey,nKey. The +// ** pX.pData,nData,nZero fields must be zero. +// ** +// ** If the seekResult parameter is non-zero, then a successful call to +// ** sqlite3BtreeIndexMoveto() to seek cursor pCur to (pKey,nKey) has already +// ** been performed. In other words, if seekResult!=0 then the cursor +// ** is currently pointing to a cell that will be adjacent to the cell +// ** to be inserted. If seekResult<0 then pCur points to a cell that is +// ** smaller then (pKey,nKey). If seekResult>0 then pCur points to a cell +// ** that is larger than (pKey,nKey). +// ** +// ** If seekResult==0, that means pCur is pointing at some unknown location. +// ** In that case, this routine must seek the cursor to the correct insertion +// ** point for (pKey,nKey) before doing the insertion. For index btrees, +// ** if pX->nMem is non-zero, then pX->aMem contains pointers to the unpacked +// ** key values and pX->aMem can be used instead of pX->pKey to avoid having +// ** to decode the key. +// */ +func _sqlite3BtreeInsert(tls *libc.TLS, pCur uintptr, pX uintptr, flags int32, seekResult int32) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var idx int32 + var newCell, oldCell, p, pPage, v1 uintptr + var ovfl TPgno + var v2 Tu16 + var _ /* info at bp+104 */ TCellInfo + var _ /* info at bp+128 */ TCellInfo + var _ /* loc at bp+4 */ int32 + var _ /* r at bp+16 */ TUnpackedRecord + var _ /* rc at bp+0 */ int32 + var _ /* szNew at bp+8 */ int32 + var _ /* x2 at bp+56 */ TBtreePayload + _, _, _, _, _, _, _, _ = idx, newCell, oldCell, ovfl, p, pPage, v1, v2 + **(**int32)(__ccgo_up(bp + 4)) = seekResult /* -1: before desired location +1: after */ + **(**int32)(__ccgo_up(bp + 8)) = 0 + p = (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree + newCell = uintptr(0) + /* Save the positions of any other cursors open on this table. + ** + ** In some cases, the call to btreeMoveto() below is a no-op. For + ** example, when inserting data into a table with auto-generated integer + ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the + ** integer key to use. It then calls this function to actually insert the + ** data into the intkey B-Tree. In this case btreeMoveto() recognizes + ** that the cursor is already where it needs to be and returns without + ** doing any work. To avoid thwarting these optimizations, it is important + ** not to clear the cursor here. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_Multiple) != 0 { + **(**int32)(__ccgo_up(bp)) = _saveAllCursors(tls, (*TBtree)(unsafe.Pointer(p)).FpBt, (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + if **(**int32)(__ccgo_up(bp + 4)) != 0 && int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) < 0 { + /* This can only happen if the schema is corrupt such that there is more + ** than one table or index with the same root page as used by the cursor. + ** Which can only happen if the SQLITE_NoSchemaError flag was set when + ** the schema was loaded. This cannot be asserted though, as a user might + ** set the flag, load the schema, and then unset the flag. */ + return _sqlite3CorruptError(tls, int32(82581)) + } + } + /* Ensure that the cursor is not in the CURSOR_FAULT state and that it + ** points to a valid cell. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) >= int32(CURSOR_REQUIRESEEK) { + **(**int32)(__ccgo_up(bp)) = _moveToRoot(tls, pCur) + if **(**int32)(__ccgo_up(bp)) != 0 && **(**int32)(__ccgo_up(bp)) != int32(SQLITE_EMPTY) { + return **(**int32)(__ccgo_up(bp)) + } + } + /* Assert that the caller has been consistent. If this cursor was opened + ** expecting an index b-tree, then the caller should be inserting blob + ** keys with no associated data. If the cursor was opened expecting an + ** intkey table, the caller should be inserting integer keys with a + ** blob of associated data. */ + if (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo == uintptr(0) { + /* If this is an insert into a table b-tree, invalidate any incrblob + ** cursors open on the row being replaced */ + if (*TBtree)(unsafe.Pointer(p)).FhasIncrblobCur != 0 { + _invalidateIncrblobCursors(tls, p, (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, (*TBtreePayload)(unsafe.Pointer(pX)).FnKey, 0) + } + /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing + ** to a row with the same key as the new entry being inserted. + */ + /* On the other hand, BTREE_SAVEPOSITION==0 does not imply + ** that the cursor is not pointing to a row to be overwritten. + ** So do a complete check. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_ValidNKey) != 0 && (*TBtreePayload)(unsafe.Pointer(pX)).FnKey == (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey { + /* The cursor is pointing to the entry that is to be + ** overwritten */ + if libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize) != 0 && (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload == libc.Uint32FromInt32((*TBtreePayload)(unsafe.Pointer(pX)).FnData)+libc.Uint32FromInt32((*TBtreePayload)(unsafe.Pointer(pX)).FnZero) { + /* New entry is the same size as the old. Do an overwrite */ + return _btreeOverwriteCell(tls, pCur, pX) + } + } else { + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + /* The cursor is *not* pointing to the cell to be overwritten, nor + ** to an adjacent cell. Move the cursor so that it is pointing either + ** to the cell to be overwritten or an adjacent cell. + */ + **(**int32)(__ccgo_up(bp)) = _sqlite3BtreeTableMoveto(tls, pCur, (*TBtreePayload)(unsafe.Pointer(pX)).FnKey, libc.BoolInt32(flags&int32(BTREE_APPEND) != 0), bp+4) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + } + } else { + /* This is an index or a WITHOUT ROWID table */ + /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing + ** to a row with the same key as the new entry being inserted. + */ + /* If the cursor is not already pointing either to the cell to be + ** overwritten, or if a new cell is being inserted, if the cursor is + ** not pointing to an immediately adjacent cell, then move the cursor + ** so that it does. + */ + if **(**int32)(__ccgo_up(bp + 4)) == 0 && flags&int32(BTREE_SAVEPOSITION) == 0 { + if (*TBtreePayload)(unsafe.Pointer(pX)).FnMem != 0 { + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).FpKeyInfo = (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).FaMem = (*TBtreePayload)(unsafe.Pointer(pX)).FaMem + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).FnField = (*TBtreePayload)(unsafe.Pointer(pX)).FnMem + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).Fdefault_rc = 0 + (**(**TUnpackedRecord)(__ccgo_up(bp + 16))).FeqSeen = uint8(0) + **(**int32)(__ccgo_up(bp)) = _sqlite3BtreeIndexMoveto(tls, pCur, bp+16, bp+4) + } else { + **(**int32)(__ccgo_up(bp)) = _btreeMoveto(tls, pCur, (*TBtreePayload)(unsafe.Pointer(pX)).FpKey, (*TBtreePayload)(unsafe.Pointer(pX)).FnKey, libc.BoolInt32(flags&int32(BTREE_APPEND) != 0), bp+4) + } + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + /* If the cursor is currently pointing to an entry to be overwritten + ** and the new content is the same as as the old, then use the + ** overwrite optimization. + */ + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + _getCellInfo(tls, pCur) + if (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == (*TBtreePayload)(unsafe.Pointer(pX)).FnKey { + (**(**TBtreePayload)(__ccgo_up(bp + 56))).FpData = (*TBtreePayload)(unsafe.Pointer(pX)).FpKey + (**(**TBtreePayload)(__ccgo_up(bp + 56))).FnData = int32((*TBtreePayload)(unsafe.Pointer(pX)).FnKey) + (**(**TBtreePayload)(__ccgo_up(bp + 56))).FnZero = 0 + return _btreeOverwriteCell(tls, pCur, bp+56) + } + } + } + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + if (*TMemPage)(unsafe.Pointer(pPage)).FnFree < 0 { + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) > int32(CURSOR_INVALID) { + /* ^^^^^--- due to the moveToRoot() call above */ + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(82704)) + } else { + **(**int32)(__ccgo_up(bp)) = _btreeComputeFreeSpace(tls, pPage) + } + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + newCell = (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpTmpSpace + if flags&int32(BTREE_PREFORMAT) != 0 { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 8)) = (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FnPreformatSize + if **(**int32)(__ccgo_up(bp + 8)) < int32(4) { + **(**int32)(__ccgo_up(bp + 8)) = int32(4) + **(**uint8)(__ccgo_up(newCell + 3)) = uint8(0) + } + if (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FautoVacuum != 0 && **(**int32)(__ccgo_up(bp + 8)) > libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell})))(tls, pPage, newCell, bp+104) + if (**(**TCellInfo)(__ccgo_up(bp + 104))).FnPayload != uint32((**(**TCellInfo)(__ccgo_up(bp + 104))).FnLocal) { + ovfl = _sqlite3Get4byte(tls, newCell+uintptr(**(**int32)(__ccgo_up(bp + 8))-int32(4))) + _ptrmapPut(tls, (*TBtree)(unsafe.Pointer(p)).FpBt, ovfl, uint8(PTRMAP_OVERFLOW1), (*TMemPage)(unsafe.Pointer(pPage)).Fpgno, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto end_insert + } + } + } + } else { + **(**int32)(__ccgo_up(bp)) = _fillInCell(tls, pPage, newCell, pX, bp+8) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto end_insert + } + } + idx = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + if idx >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + return _sqlite3CorruptError(tls, int32(82746)) + } + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto end_insert + } + oldCell = (*TMemPage)(unsafe.Pointer(pPage)).FaData + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*idx))))< (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd { + return _sqlite3CorruptError(tls, int32(82776)) + } + libc.Xmemcpy(tls, oldCell, newCell, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 8)))) + return SQLITE_OK + } + _dropCell(tls, pPage, idx, libc.Int32FromUint16((**(**TCellInfo)(__ccgo_up(bp + 128))).FnSize), bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto end_insert + } + } else { + if **(**int32)(__ccgo_up(bp + 4)) < 0 && libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) > 0 { + v1 = pCur + 86 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v2 = *(*Tu16)(unsafe.Pointer(v1)) + idx = libc.Int32FromUint16(v2) + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + } else { + } + } + **(**int32)(__ccgo_up(bp)) = _insertCellFast(tls, pPage, idx, newCell, **(**int32)(__ccgo_up(bp + 8))) + /* If no error has occurred and pPage has an overflow cell, call balance() + ** to redistribute the cells within the tree. Since balance() may move + ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey + ** variables. + ** + ** Previous versions of SQLite called moveToRoot() to move the cursor + ** back to the root page as balance() used to invalidate the contents + ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that, + ** set the cursor state to "invalid". This makes common insert operations + ** slightly faster. + ** + ** There is a subtle but important optimization here too. When inserting + ** multiple records into an intkey b-tree using a single cursor (as can + ** happen while processing an "INSERT INTO ... SELECT" statement), it + ** is advantageous to leave the cursor pointing to the last entry in + ** the b-tree if possible. If the cursor is left pointing to the last + ** entry in the table, and the next row inserted has an integer key + ** larger than the largest existing key, it is possible to insert the + ** row without seeking the cursor. This can be a big performance boost. + */ + if (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow != 0 { + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + **(**int32)(__ccgo_up(bp)) = _balance(tls, pCur) + /* Must make sure nOverflow is reset to zero even if the balance() + ** fails. Internal data structure corruption will result otherwise. + ** Also, set the cursor state to invalid. This stops saveCursorPosition() + ** from trying to save the current position of the cursor. */ + (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnOverflow = uint8(0) + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID) + if flags&int32(BTREE_SAVEPOSITION) != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + _btreeReleaseAllCursorPages(tls, pCur) + if (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo != 0 { + (*TBtCursor)(unsafe.Pointer(pCur)).FpKey = _sqlite3Malloc(tls, libc.Uint64FromInt64((*TBtreePayload)(unsafe.Pointer(pX)).FnKey)) + if (*TBtCursor)(unsafe.Pointer(pCur)).FpKey == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpKey, (*TBtreePayload)(unsafe.Pointer(pX)).FpKey, libc.Uint64FromInt64((*TBtreePayload)(unsafe.Pointer(pX)).FnKey)) + } + } + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_REQUIRESEEK) + (*TBtCursor)(unsafe.Pointer(pCur)).FnKey = (*TBtreePayload)(unsafe.Pointer(pX)).FnKey + } + } + goto end_insert +end_insert: + ; + return **(**int32)(__ccgo_up(bp)) + return r +} + +// C documentation +// +// /* +// ** This function encodes a single frame header and writes it to a buffer +// ** supplied by the caller. A frame-header is made up of a series of +// ** 4-byte big-endian integers, as follows: +// ** +// ** 0: Page number. +// ** 4: For commit records, the size of the database image in pages +// ** after the commit. For all other records, zero. +// ** 8: Salt-1 (copied from the wal-header) +// ** 12: Salt-2 (copied from the wal-header) +// ** 16: Checksum-1. +// ** 20: Checksum-2. +// */ +func _walEncodeFrame(tls *libc.TLS, pWal uintptr, iPage Tu32, nTruncate Tu32, aData uintptr, aFrame uintptr) { + var aCksum uintptr + var nativeCksum int32 + _, _ = aCksum, nativeCksum /* True for native byte-order checksums */ + aCksum = pWal + 72 + 24 + _sqlite3Put4byte(tls, aFrame, iPage) + _sqlite3Put4byte(tls, aFrame+4, nTruncate) + if (*TWal)(unsafe.Pointer(pWal)).FiReCksum == uint32(0) { + libc.Xmemcpy(tls, aFrame+8, pWal+72+32, uint64(8)) + nativeCksum = libc.BoolInt32(libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN) + _walChecksumBytes(tls, nativeCksum, aFrame, int32(8), aCksum, aCksum) + _walChecksumBytes(tls, nativeCksum, aData, libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum) + _sqlite3Put4byte(tls, aFrame+16, **(**Tu32)(__ccgo_up(aCksum))) + _sqlite3Put4byte(tls, aFrame+20, **(**Tu32)(__ccgo_up(aCksum + 1*4))) + } else { + libc.Xmemset(tls, aFrame+8, 0, uint64(16)) + } +} diff --git a/internal/engine/lib/sqlite_g_000000000001deab.go b/internal/engine/lib/sqlite_g_000000000001deab.go new file mode 100644 index 0000000..0f7e7d1 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001deab.go @@ -0,0 +1,577 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** This version of balance() handles the common special case where +// ** a new entry is being inserted on the extreme right-end of the +// ** tree, in other words, when the new entry will become the largest +// ** entry in the tree. +// ** +// ** Instead of trying to balance the 3 right-most leaf pages, just add +// ** a new page to the right-hand side and put the one new entry in +// ** that page. This leaves the right side of the tree somewhat +// ** unbalanced. But odds are that we will be inserting new entries +// ** at the end soon afterwards so the nearly empty page will quickly +// ** fill up. On average. +// ** +// ** pPage is the leaf page which is the right-most page in the tree. +// ** pParent is its parent. pPage must have a single overflow entry +// ** which is also the right-most entry on the page. +// ** +// ** The pSpace buffer is used to store a temporary copy of the divider +// ** cell that will be inserted into pParent. Such a cell consists of a 4 +// ** byte page number followed by a variable length integer. In other +// ** words, at most 13 bytes. Hence the pSpace buffer must be at +// ** least 13 bytes in size. +// */ +func _balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var pBt, pOut, pStop, v1, v3 uintptr + var v2 Tu8 + var _ /* b at bp+32 */ TCellArray + var _ /* pCell at bp+16 */ uintptr + var _ /* pNew at bp+0 */ uintptr + var _ /* pgnoNew at bp+12 */ TPgno + var _ /* rc at bp+8 */ int32 + var _ /* szCell at bp+24 */ Tu16 + _, _, _, _, _, _ = pBt, pOut, pStop, v1, v2, v3 + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt /* Page number of pNew */ + if libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) == 0 { + return _sqlite3CorruptError(tls, int32(81151)) + } /* dbfuzz001.test */ + /* Allocate a new page. This page will become the right-sibling of + ** pPage. Make the parent page writable, so that the new divider cell + ** may be inserted. If both these operations are successful, proceed. + */ + **(**int32)(__ccgo_up(bp + 8)) = _allocateBtreePage(tls, pBt, bp, bp+12, uint32(0), uint8(0)) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + pOut = pSpace + 4 + **(**uintptr)(__ccgo_up(bp + 16)) = **(**uintptr)(__ccgo_up(pPage + 40)) + **(**Tu16)(__ccgo_up(bp + 24)) = (*(*func(*libc.TLS, uintptr, uintptr) Tu16)(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize})))(tls, pPage, **(**uintptr)(__ccgo_up(bp + 16))) + _zeroPage(tls, **(**uintptr)(__ccgo_up(bp)), libc.Int32FromInt32(PTF_INTKEY)|libc.Int32FromInt32(PTF_LEAFDATA)|libc.Int32FromInt32(PTF_LEAF)) + (**(**TCellArray)(__ccgo_up(bp + 32))).FnCell = int32(1) + (**(**TCellArray)(__ccgo_up(bp + 32))).FpRef = pPage + (**(**TCellArray)(__ccgo_up(bp + 32))).FapCell = bp + 16 + (**(**TCellArray)(__ccgo_up(bp + 32))).FszCell = bp + 24 + **(**uintptr)(__ccgo_up(bp + 32 + 32)) = (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd + **(**int32)(__ccgo_up(bp + 32 + 80)) = int32(2) + **(**int32)(__ccgo_up(bp + 32 + 80 + uintptr(libc.Int32FromInt32(NB)*libc.Int32FromInt32(2)-libc.Int32FromInt32(1))*4)) = int32(0x7fffffff) + **(**int32)(__ccgo_up(bp + 8)) = _rebuildPage(tls, bp+32, 0, int32(1), **(**uintptr)(__ccgo_up(bp))) + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + return **(**int32)(__ccgo_up(bp + 8)) + } + (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnFree = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FcellOffset) - uint32(2) - uint32(**(**Tu16)(__ccgo_up(bp + 24)))) + /* If this is an auto-vacuum database, update the pointer map + ** with entries for the new page, and any pointer from the + ** cell on the page to an overflow page. If either of these + ** operations fails, the return code is set, but the contents + ** of the parent page are still manipulated by the code below. + ** That is Ok, at this point the parent page is guaranteed to + ** be marked as dirty. Returning an error code will cause a + ** rollback, undoing any changes made to the parent page. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _ptrmapPut(tls, pBt, **(**TPgno)(__ccgo_up(bp + 12)), uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(pParent)).Fpgno, bp+8) + if libc.Int32FromUint16(**(**Tu16)(__ccgo_up(bp + 24))) > libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FminLocal) { + _ptrmapPutOvflPtr(tls, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 16)), bp+8) + } + } + /* Create a divider cell to insert into pParent. The divider cell + ** consists of a 4-byte page number (the page number of pPage) and + ** a variable length key value (which must be the same value as the + ** largest key on pPage). + ** + ** To find the largest key value on pPage, first find the right-most + ** cell on pPage. The first two fields of this cell are the + ** record-length (a variable length integer at most 32-bits in size) + ** and the key value (a variable length integer, may have any value). + ** The first of the while(...) loops below skips over the record-length + ** field. The second while(...) loop copies the key value from the + ** cell on pPage into the pSpace buffer. + */ + **(**uintptr)(__ccgo_up(bp + 16)) = (*TMemPage)(unsafe.Pointer(pPage)).FaData + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell)-int32(1))))))< _btreePagecount(tls, pBt) { + return _sqlite3CorruptError(tls, int32(83360)) + } + **(**int32)(__ccgo_up(bp + 8)) = _getAndInitPage(tls, pBt, pgno, bp, 0) + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + return **(**int32)(__ccgo_up(bp + 8)) + } + if libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FopenFlags)&int32(BTREE_SINGLE) == 0 && _sqlite3PagerPageRefcount(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) != int32(1)+libc.BoolInt32(pgno == uint32(1)) { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3CorruptError(tls, int32(83367)) + goto cleardatabasepage_out + } + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FhdrOffset) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnCell)) { + break + } + pCell = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaCellIdx + uintptr(int32(2)*i))))<aiIdx[pCur->iPage] value is set to the index of the parent cell + ** of the page, or to the number of cells in the page if the next page + ** to visit is the right-child of its parent. + ** + ** If all pages in the tree have been visited, return SQLITE_OK to the + ** caller. + */ + if (*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { + for cond := true; cond; cond = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell) { + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 { + /* All pages of the b-tree have been visited. Return successfully. */ + **(**Ti64)(__ccgo_up(pnEntry)) = nEntry + return _moveToRoot(tls, pCur) + } + _moveToParent(tls, pCur) + } + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = (*TBtCursor)(unsafe.Pointer(pCur)).Fix + 1 + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + } + /* Descend to the child node of the cell that the cursor currently + ** points at. This is the right-child if (iIdx==pPage->nCell). + */ + iIdx = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) + if iIdx == libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + rc = _moveToChild(tls, pCur, _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(8)))) + } else { + rc = _moveToChild(tls, pCur, _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*iIdx))))<= int32(CURSOR_REQUIRESEEK) { + **(**int32)(__ccgo_up(bp)) = _btreeRestoreCursorPosition(tls, pCur) + if **(**int32)(__ccgo_up(bp)) != 0 || libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { + return **(**int32)(__ccgo_up(bp)) + } + } else { + return _sqlite3CorruptError(tls, int32(82999)) + } + } + iCellDepth = int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) + iCellIdx = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + if libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) <= iCellIdx { + return _sqlite3CorruptError(tls, int32(83008)) + } + pCell = (*TMemPage)(unsafe.Pointer(pPage)).FaData + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*iCellIdx))))< libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FusableSize*libc.Uint32FromInt32(2)/libc.Uint32FromInt32(3)) || libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) == int32(1) { + /* A b-tree rebalance will be required after deleting this entry. + ** Save the cursor key. */ + **(**int32)(__ccgo_up(bp)) = _saveCursorKey(tls, pCur) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } else { + bPreserve = uint8(2) + } + } + /* If the page containing the entry to delete is not a leaf page, move + ** the cursor to the largest entry in the tree that is smaller than + ** the entry being deleted. This cell will replace the cell being deleted + ** from the internal node. The 'previous' entry is used for this instead + ** of the 'next' entry, as the previous entry is always a part of the + ** sub-tree headed by the child page of the cell being deleted. This makes + ** balancing the tree following the delete operation easier. */ + if !((*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0) { + **(**int32)(__ccgo_up(bp)) = _sqlite3BtreePrevious(tls, pCur, 0) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + /* Save the positions of any other cursors open on this table before + ** making any modifications. */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_Multiple) != 0 { + **(**int32)(__ccgo_up(bp)) = _saveAllCursors(tls, pBt, (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + /* If this is a delete operation to remove a row from a table b-tree, + ** invalidate any incrblob cursors open on the row being deleted. */ + if (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo == uintptr(0) && (*TBtree)(unsafe.Pointer(p)).FhasIncrblobCur != 0 { + _invalidateIncrblobCursors(tls, p, (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey, 0) + } + /* Make the page containing the entry to be deleted writable. Then free any + ** overflow pages associated with the entry and finally remove the cell + ** itself from within the page. */ + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell})))(tls, pPage, pCell, bp+8) + if uint32((**(**TCellInfo)(__ccgo_up(bp + 8))).FnLocal) != (**(**TCellInfo)(__ccgo_up(bp + 8))).FnPayload { + **(**int32)(__ccgo_up(bp)) = _clearCellOverflow(tls, pPage, pCell, bp+8) + } else { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + } + _dropCell(tls, pPage, iCellIdx, libc.Int32FromUint16((**(**TCellInfo)(__ccgo_up(bp + 8))).FnSize), bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + /* If the cell deleted was not located on a leaf page, then the cursor + ** is currently pointing to the largest entry in the sub-tree headed + ** by the child-page of the cell that was just deleted from an internal + ** node. The cell from the leaf node needs to be moved to the internal + ** node to replace the deleted cell. */ + if !((*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0) { + pLeaf = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + if (*TMemPage)(unsafe.Pointer(pLeaf)).FnFree < 0 { + **(**int32)(__ccgo_up(bp)) = _btreeComputeFreeSpace(tls, pLeaf) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + if iCellDepth < int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)-int32(1) { + n = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pCur + 144 + uintptr(iCellDepth+int32(1))*8)))).Fpgno + } else { + n = (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).Fpgno + } + pCell = (*TMemPage)(unsafe.Pointer(pLeaf)).FaData + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pLeaf)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pLeaf)).FaCellIdx + uintptr(int32(2)*(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pLeaf)).FnCell)-int32(1))))))< iCellDepth { + _releasePageNotNull(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage) + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = (*TBtCursor)(unsafe.Pointer(pCur)).FiPage - 1 + for int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth { + v2 = pCur + 84 + v1 = *(*Ti8)(unsafe.Pointer(v2)) + *(*Ti8)(unsafe.Pointer(v2)) = *(*Ti8)(unsafe.Pointer(v2)) - 1 + _releasePage(tls, **(**uintptr)(__ccgo_up(pCur + 144 + uintptr(v1)*8))) + } + (*TBtCursor)(unsafe.Pointer(pCur)).FpPage = **(**uintptr)(__ccgo_up(pCur + 144 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*8)) + **(**int32)(__ccgo_up(bp)) = _balance(tls, pCur) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if libc.Int32FromUint8(bPreserve) > int32(1) { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_SKIPNEXT) + if iCellIdx >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + (*TBtCursor)(unsafe.Pointer(pCur)).FskipNext = -int32(1) + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) - int32(1)) + } else { + (*TBtCursor)(unsafe.Pointer(pCur)).FskipNext = int32(1) + } + } else { + **(**int32)(__ccgo_up(bp)) = _moveToRoot(tls, pCur) + if bPreserve != 0 { + _btreeReleaseAllCursorPages(tls, pCur) + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_REQUIRESEEK) + } + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_EMPTY) { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + } + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** zIn is a UTF-16 encoded unicode string at least nByte bytes long. +// ** Return the number of bytes in the first nChar unicode characters +// ** in pZ. nChar must be non-negative. Surrogate pairs count as a single +// ** character. +// */ +func _sqlite3Utf16ByteLen(tls *libc.TLS, zIn uintptr, nByte int32, nChar int32) (r int32) { + var c, n int32 + var z, zEnd uintptr + _, _, _, _ = c, n, z, zEnd + z = zIn + zEnd = z + uintptr(nByte-int32(1)) + n = 0 + if true { + z = z + 1 + } + for n < nChar && z <= zEnd { + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) + z = z + uintptr(2) + if c >= int32(0xd8) && c < int32(0xdc) && z <= zEnd && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) >= int32(0xdc) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) < int32(0xe0) { + z = z + uintptr(2) + } + n = n + 1 + } + return int32(int64(z)-int64(zIn)) - libc.BoolInt32(true) +} + +// C documentation +// +// /* +// ** Check to see if the frame with header in aFrame[] and content +// ** in aData[] is valid. If it is a valid frame, fill *piPage and +// ** *pnTruncate and return true. Return if the frame is not valid. +// */ +func _walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uintptr, aData uintptr, aFrame uintptr) (r int32) { + var aCksum uintptr + var nativeCksum int32 + var pgno Tu32 + _, _, _ = aCksum, nativeCksum, pgno /* True for native byte-order checksums */ + aCksum = pWal + 72 + 24 /* Page number of the frame */ + /* A frame is only valid if the salt values in the frame-header + ** match the salt values in the wal-header. + */ + if libc.Xmemcmp(tls, pWal+72+32, aFrame+8, uint64(8)) != 0 { + return 0 + } + /* A frame is only valid if the page number is greater than zero. + */ + pgno = _sqlite3Get4byte(tls, aFrame) + if pgno == uint32(0) { + return 0 + } + /* A frame is only valid if a checksum of the WAL header, + ** all prior frames, the first 16 bytes of this frame-header, + ** and the frame-data matches the checksum in the last 8 + ** bytes of this frame-header. + */ + nativeCksum = libc.BoolInt32(libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN) + _walChecksumBytes(tls, nativeCksum, aFrame, int32(8), aCksum, aCksum) + _walChecksumBytes(tls, nativeCksum, aData, libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum) + if **(**Tu32)(__ccgo_up(aCksum)) != _sqlite3Get4byte(tls, aFrame+16) || **(**Tu32)(__ccgo_up(aCksum + 1*4)) != _sqlite3Get4byte(tls, aFrame+20) { + /* Checksum failed. */ + return 0 + } + /* If we reach this point, the frame is valid. Return the page number + ** and the new database size. + */ + **(**Tu32)(__ccgo_up(piPage)) = pgno + **(**Tu32)(__ccgo_up(pnTruncate)) = _sqlite3Get4byte(tls, aFrame+4) + return int32(1) +} diff --git a/internal/engine/lib/sqlite_g_000000000001dfff.go b/internal/engine/lib/sqlite_g_000000000001dfff.go new file mode 100644 index 0000000..313f862 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001dfff.go @@ -0,0 +1,611 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const BYTE_ORDER = 1234 + +func Xsqlite3_bind_text16(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, n int32, __ccgo_fp_xDel uintptr) (r int32) { + return _bindText(tls, pStmt, i, zData, libc.Int64FromUint64(libc.Uint64FromInt32(n) & ^libc.Uint64FromInt32(1)), __ccgo_fp_xDel, uint8(SQLITE_UTF16LE)) +} + +func Xsqlite3_bind_text64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData Tsqlite3_uint64, __ccgo_fp_xDel uintptr, enc uint8) (r int32) { + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) && libc.Int32FromUint8(enc) != int32(SQLITE_UTF8_ZT) { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF16) { + enc = uint8(SQLITE_UTF16LE) + } + nData = nData & ^libc.Uint64FromInt32(1) + } + return _bindText(tls, pStmt, i, zData, libc.Int64FromUint64(nData), __ccgo_fp_xDel, enc) +} + +// C documentation +// +// /* +// ** Register a new collation sequence with the database handle db. +// */ +func Xsqlite3_create_collation16(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, __ccgo_fp_xCompare uintptr) (r int32) { + var rc int32 + var zName8 uintptr + _, _ = rc, zName8 + rc = SQLITE_OK + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + zName8 = _sqlite3Utf16to8(tls, db, zName, -int32(1), uint8(SQLITE_UTF16LE)) + if zName8 != 0 { + rc = _createCollation(tls, db, zName8, libc.Uint8FromInt32(enc), pCtx, __ccgo_fp_xCompare, uintptr(0)) + _sqlite3DbFree(tls, db, zName8) + } + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +func Xsqlite3_result_text16(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, __ccgo_fp_xDel uintptr) { + _setResultStrOrError(tls, pCtx, z, libc.Int32FromUint64(libc.Uint64FromInt32(n) & ^libc.Uint64FromInt32(1)), uint8(SQLITE_UTF16LE), __ccgo_fp_xDel) +} + +func Xsqlite3_result_text64(tls *libc.TLS, pCtx uintptr, z uintptr, n Tsqlite3_uint64, __ccgo_fp_xDel uintptr, enc uint8) { + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) && libc.Int32FromUint8(enc) != int32(SQLITE_UTF8_ZT) { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF16) { + enc = uint8(SQLITE_UTF16LE) + } + n = n & ^libc.Uint64FromInt32(1) + } + if n > uint64(0x7fffffff) { + _invokeValueDestructor(tls, z, __ccgo_fp_xDel, pCtx) + } else { + _setResultStrOrError(tls, pCtx, z, libc.Int32FromUint64(n), enc, __ccgo_fp_xDel) + _sqlite3VdbeMemZeroTerminateIfAble(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut) + } +} + +// C documentation +// +// /* +// ** Do additional sanity check after btreeInitPage() if +// ** PRAGMA cell_size_check=ON +// */ +func _btreeCellSizeCheck(tls *libc.TLS, pPage uintptr) (r int32) { + var cellOffset, i, iCellFirst, iCellLast, pc, sz, usableSize int32 + var data uintptr + _, _, _, _, _, _, _, _ = cellOffset, data, i, iCellFirst, iCellLast, pc, sz, usableSize /* Start of cell content area */ + iCellFirst = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FcellOffset) + int32(2)*libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) + usableSize = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) + iCellLast = usableSize - int32(4) + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + cellOffset = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FcellOffset) + if !((*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0) { + iCellLast = iCellLast - 1 + } + i = 0 + for { + if !(i < libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell)) { + break + } + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(cellOffset+i*int32(2)))))< iCellLast { + return _sqlite3CorruptError(tls, int32(75335)) + } + sz = libc.Int32FromUint16((*(*func(*libc.TLS, uintptr, uintptr) Tu16)(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize})))(tls, pPage, data+uintptr(pc))) + if pc+sz > usableSize { + return _sqlite3CorruptError(tls, int32(75340)) + } + goto _1 + _1: + ; + i = i + 1 + } + return SQLITE_OK +} + +func _btreeParseCell(tls *libc.TLS, pPage uintptr, iCell int32, pInfo uintptr) { + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell})))(tls, pPage, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*iCell))))<= int32(CURSOR_REQUIRESEEK) { + v1 = _btreeRestoreCursorPosition(tls, pCur) + } else { + v1 = SQLITE_OK + } + rc = v1 + if rc != SQLITE_OK { + return rc + } + if int32(CURSOR_INVALID) == libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) { + return int32(SQLITE_DONE) + } + if int32(CURSOR_SKIPNEXT) == libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_VALID) + if (*TBtCursor)(unsafe.Pointer(pCur)).FskipNext < 0 { + return SQLITE_OK + } + } + } + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + if _sqlite3FaultSim(tls, int32(412)) != 0 { + (*TMemPage)(unsafe.Pointer(pPage)).FisInit = uint8(0) + } + if !((*TMemPage)(unsafe.Pointer(pPage)).FisInit != 0) { + return _sqlite3CorruptError(tls, int32(79582)) + } + if !((*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0) { + idx = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) + rc = _moveToChild(tls, pCur, _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*idx))))< (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) { + return _sqlite3CorruptError(tls, int32(77042)) + } + if iFrom == _sqlite3Get4byte(tls, pCell+uintptr((**(**TCellInfo)(__ccgo_up(bp))).FnSize)-uintptr(4)) { + _sqlite3Put4byte(tls, pCell+uintptr((**(**TCellInfo)(__ccgo_up(bp))).FnSize)-uintptr(4), iTo) + break + } + } + } else { + if pCell+uintptr(4) > (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) { + return _sqlite3CorruptError(tls, int32(77051)) + } + if _sqlite3Get4byte(tls, pCell) == iFrom { + _sqlite3Put4byte(tls, pCell, iTo) + break + } + } + goto _2 + _2: + ; + i = i + 1 + } + if i == nCell { + if libc.Int32FromUint8(eType) != int32(PTRMAP_BTREE) || _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(8))) != iFrom { + return _sqlite3CorruptError(tls, int32(77063)) + } + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(8)), iTo) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Move the cursor down to the left-most leaf entry beneath the +// ** entry to which it is currently pointing. +// ** +// ** The left-most leaf is the one with the smallest key - the first +// ** in ascending order. +// */ +func _moveToLeftmost(tls *libc.TLS, pCur uintptr) (r int32) { + var pPage, v1 uintptr + var pgno TPgno + var rc int32 + var v2 bool + _, _, _, _, _ = pPage, pgno, rc, v1, v2 + rc = SQLITE_OK + for { + if v2 = rc == SQLITE_OK; v2 { + v1 = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + pPage = v1 + } + if !(v2 && !((*TMemPage)(unsafe.Pointer(v1)).Fleaf != 0)) { + break + } + pgno = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix)))))<0 The cursor is left pointing at an entry that +// ** is larger than intKey. +// */ +func _sqlite3BtreeTableMoveto(tls *libc.TLS, pCur uintptr, intKey Ti64, biasRight int32, pRes uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, idx, lwr, rc, upr int32 + var chldPg TPgno + var pCell, pPage, v3 uintptr + var _ /* nCellKey at bp+0 */ Ti64 + _, _, _, _, _, _, _, _, _ = c, chldPg, idx, lwr, pCell, pPage, rc, upr, v3 + /* If the cursor is already positioned at the point we are trying + ** to move to, then just return without doing any work */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID && libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_ValidNKey) != 0 { + if (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == intKey { + **(**int32)(__ccgo_up(pRes)) = 0 + return SQLITE_OK + } + if (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey < intKey { + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_AtLast) != 0 { + **(**int32)(__ccgo_up(pRes)) = -int32(1) + return SQLITE_OK + } + /* If the requested key is one more than the previous key, then + ** try to get there using sqlite3BtreeNext() rather than a full + ** binary search. This is an optimization only. The correct answer + ** is still obtained without this case, only a little more slowly. */ + if (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey+int64(1) == intKey { + **(**int32)(__ccgo_up(pRes)) = 0 + rc = _sqlite3BtreeNext(tls, pCur, 0) + if rc == SQLITE_OK { + _getCellInfo(tls, pCur) + if (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == intKey { + return SQLITE_OK + } + } else { + if rc != int32(SQLITE_DONE) { + return rc + } + } + } + } + } + rc = _moveToRoot(tls, pCur) + if rc != 0 { + if rc == int32(SQLITE_EMPTY) { + **(**int32)(__ccgo_up(pRes)) = -int32(1) + return SQLITE_OK + } + return rc + } + for { + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage /* Pointer to current cell in pPage */ + /* pPage->nCell must be greater than zero. If this is the root-page + ** the cursor would have been INVALID above and this for(;;) loop + ** not run. If this is not the root-page, then the moveToChild() routine + ** would have already detected db corruption. Similarly, pPage must + ** be the right kind (index or table) of b-tree page. Otherwise + ** a moveToChild() or moveToRoot() call would have detected corruption. */ + lwr = 0 + upr = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) - int32(1) + idx = upr >> (int32(1) - biasRight) /* idx = biasRight ? upr : (lwr+upr)/2; */ + for { + pCell = (*TMemPage)(unsafe.Pointer(pPage)).FaDataOfst + uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*idx))))<= (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd { + return _sqlite3CorruptError(tls, int32(79032)) + } + } + } + _sqlite3GetVarint(tls, pCell, bp) + if **(**Ti64)(__ccgo_up(bp)) < intKey { + lwr = idx + int32(1) + if lwr > upr { + c = -int32(1) + break + } + } else { + if **(**Ti64)(__ccgo_up(bp)) > intKey { + upr = idx - int32(1) + if lwr > upr { + c = +libc.Int32FromInt32(1) + break + } + } else { + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(idx) + if !((*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0) { + lwr = idx + goto moveto_table_next_layer + } else { + v3 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) | libc.Int32FromInt32(BTCF_ValidNKey)) + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey = **(**Ti64)(__ccgo_up(bp)) + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + **(**int32)(__ccgo_up(pRes)) = 0 + return SQLITE_OK + } + } + } + idx = (lwr + upr) >> int32(1) /* idx = (lwr+upr)/2; */ + goto _2 + _2: + } + if (*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = libc.Uint16FromInt32(idx) + **(**int32)(__ccgo_up(pRes)) = c + rc = SQLITE_OK + goto moveto_table_finish + } + goto moveto_table_next_layer + moveto_table_next_layer: + ; + if lwr >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + chldPg = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(8))) + } else { + chldPg = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaskPage)&(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*lwr))))<> libc.Int32FromInt32(56) & int64(0xFF)) + **(**Tu8)(__ccgo_up(p + 1)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(48) & int64(0xFF)) + **(**Tu8)(__ccgo_up(p + 2)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(40) & int64(0xFF)) + **(**Tu8)(__ccgo_up(p + 3)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(32) & int64(0xFF)) + **(**Tu8)(__ccgo_up(p + 4)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(24) & int64(0xFF)) + **(**Tu8)(__ccgo_up(p + 5)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(16) & int64(0xFF)) + **(**Tu8)(__ccgo_up(p + 6)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(8) & int64(0xFF)) + **(**Tu8)(__ccgo_up(p + 7)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(0) & int64(0xFF)) + return int32(8) +} diff --git a/internal/engine/lib/sqlite_g_000000000001f7ff.go b/internal/engine/lib/sqlite_g_000000000001f7ff.go new file mode 100644 index 0000000..8376e58 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001f7ff.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const MCL_CURRENT = 1 + +const MCL_FUTURE = 2 diff --git a/internal/engine/lib/sqlite_g_000000000001fc8f.go b/internal/engine/lib/sqlite_g_000000000001fc8f.go new file mode 100644 index 0000000..3c17a53 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001fc8f.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (linux && amd64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const __WCHAR_TYPE__ = 0 diff --git a/internal/engine/lib/sqlite_g_000000000001fccf.go b/internal/engine/lib/sqlite_g_000000000001fccf.go new file mode 100644 index 0000000..578e537 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001fccf.go @@ -0,0 +1,11 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (linux && 386) || (linux && amd64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Twchar_t = int32 + +const __WCHAR_MAX__ = 2147483647 + +type t__predefined_wchar_t = int32 diff --git a/internal/engine/lib/sqlite_g_000000000001fe80.go b/internal/engine/lib/sqlite_g_000000000001fe80.go new file mode 100644 index 0000000..2496a72 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001fe80.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Tulong = uint64 diff --git a/internal/engine/lib/sqlite_g_000000000001fe88.go b/internal/engine/lib/sqlite_g_000000000001fe88.go new file mode 100644 index 0000000..e089089 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001fe88.go @@ -0,0 +1,242 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Implementation of bm25() function. +// */ +func _fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var D, b, k1, score, w, v2 float64 + var aFreq uintptr + var i, rc int32 + var _ /* ic at bp+16 */ int32 + var _ /* io at bp+20 */ int32 + var _ /* ip at bp+12 */ int32 + var _ /* nInst at bp+8 */ int32 + var _ /* nTok at bp+24 */ int32 + var _ /* pData at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _ = D, aFreq, b, i, k1, rc, score, w, v2 + k1 = float64(1.2) /* Constant "k1" from BM25 formula */ + b = float64(0.75) /* Error code */ + score = float64(0) /* Iterator variable */ + **(**int32)(__ccgo_up(bp + 8)) = 0 /* Value returned by xInstCount() */ + D = float64(0) /* Total number of tokens in row */ + aFreq = uintptr(0) /* Array of phrase freq. for current row */ + /* Calculate the phrase frequency (symbol "f(qi,D)" in the documentation) + ** for each phrase in the query for the current row. */ + rc = _fts5Bm25GetData(tls, pApi, pFts, bp) + if rc == SQLITE_OK { + aFreq = (*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaFreq + libc.Xmemset(tls, aFreq, 0, uint64(8)*libc.Uint64FromInt32((*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnPhrase)) + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})))(tls, pFts, bp+8) + } + i = 0 + for { + if !(rc == SQLITE_OK && i < **(**int32)(__ccgo_up(bp + 8))) { + break + } + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})))(tls, pFts, i, bp+12, bp+16, bp+20) + if rc == SQLITE_OK { + if nVal > **(**int32)(__ccgo_up(bp + 16)) { + v2 = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(**(**int32)(__ccgo_up(bp + 16)))*8))) + } else { + v2 = float64(1) + } + w = v2 + **(**float64)(__ccgo_up(aFreq + uintptr(**(**int32)(__ccgo_up(bp + 12)))*8)) += w + } + goto _1 + _1: + ; + i = i + 1 + } + /* Figure out the total size of the current row in tokens. */ + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})))(tls, pFts, -int32(1), bp+24) + D = float64(**(**int32)(__ccgo_up(bp + 24))) + } + /* Determine and return the BM25 score for the current row. Or, if an + ** error has occurred, throw an exception. */ + if rc == SQLITE_OK { + i = 0 + for { + if !(i < (*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnPhrase) { + break + } + score = score + float64(**(**float64)(__ccgo_up((*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaIDF + uintptr(i)*8))*(float64(**(**float64)(__ccgo_up(aFreq + uintptr(i)*8))*(k1+libc.Float64FromFloat64(1)))/(**(**float64)(__ccgo_up(aFreq + uintptr(i)*8))+float64(k1*(libc.Float64FromInt32(1)-b+float64(b*D)/(*TFts5Bm25Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Favgdl))))) + goto _3 + _3: + ; + i = i + 1 + } + Xsqlite3_result_double(tls, pCtx, float64(-libc.Float64FromFloat64(1)*score)) + } else { + Xsqlite3_result_error_code(tls, pCtx, rc) + } +} + +// C documentation +// +// /* +// ** Determine the overlap between two polygons +// */ +func _geopolyOverlap(tls *libc.TLS, p1 uintptr, p2 uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iMask, needSort, rc, v1 int32 + var nByte, nVertex Tsqlite3_int64 + var p, pActive, pPrev, pSeg, pThisEvent, v5 uintptr + var rX, y, v2 float64 + var _ /* aOverlap at bp+0 */ [4]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iMask, nByte, nVertex, needSort, p, pActive, pPrev, pSeg, pThisEvent, rX, rc, y, v1, v2, v5 + nVertex = int64((*TGeoPoly)(unsafe.Pointer(p1)).FnVertex + (*TGeoPoly)(unsafe.Pointer(p2)).FnVertex + int32(2)) + rc = 0 + needSort = 0 + pActive = uintptr(0) + nByte = libc.Int64FromUint64(uint64(32)*libc.Uint64FromInt64(nVertex)*uint64(2) + uint64(48)*libc.Uint64FromInt64(nVertex) + uint64(24)) + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if p == uintptr(0) { + return -int32(1) + } + (*TGeoOverlap)(unsafe.Pointer(p)).FaEvent = p + 1*24 + (*TGeoOverlap)(unsafe.Pointer(p)).FaSegment = (*TGeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr(nVertex*int64(2))*32 + v1 = libc.Int32FromInt32(0) + (*TGeoOverlap)(unsafe.Pointer(p)).FnSegment = v1 + (*TGeoOverlap)(unsafe.Pointer(p)).FnEvent = v1 + _geopolyAddSegments(tls, p, p1, uint8(1)) + _geopolyAddSegments(tls, p, p2, uint8(2)) + pThisEvent = _geopolySortEventsByX(tls, (*TGeoOverlap)(unsafe.Pointer(p)).FaEvent, (*TGeoOverlap)(unsafe.Pointer(p)).FnEvent) + if pThisEvent != 0 && (*TGeoEvent)(unsafe.Pointer(pThisEvent)).Fx == float64(0) { + v2 = -libc.Float64FromFloat64(1) + } else { + v2 = float64(0) + } + rX = v2 + libc.Xmemset(tls, bp, 0, uint64(4)) + for pThisEvent != 0 { + if (*TGeoEvent)(unsafe.Pointer(pThisEvent)).Fx != rX { + pPrev = uintptr(0) + iMask = 0 + rX = (*TGeoEvent)(unsafe.Pointer(pThisEvent)).Fx + if needSort != 0 { + pActive = _geopolySortSegmentsByYAndC(tls, pActive) + needSort = 0 + } + pSeg = pActive + for { + if !(pSeg != 0) { + break + } + if pPrev != 0 { + if (*TGeoSegment)(unsafe.Pointer(pPrev)).Fy != (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy { + (**(**[4]uint8)(__ccgo_up(bp)))[iMask] = uint8(1) + } + } + iMask = iMask ^ libc.Int32FromUint8((*TGeoSegment)(unsafe.Pointer(pSeg)).Fside) + pPrev = pSeg + goto _3 + _3: + ; + pSeg = (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext + } + pPrev = uintptr(0) + pSeg = pActive + for { + if !(pSeg != 0) { + break + } + y = float64((*TGeoSegment)(unsafe.Pointer(pSeg)).FC*rX) + (*TGeoSegment)(unsafe.Pointer(pSeg)).FB + (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy = y + if pPrev != 0 { + if (*TGeoSegment)(unsafe.Pointer(pPrev)).Fy > (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy && libc.Int32FromUint8((*TGeoSegment)(unsafe.Pointer(pPrev)).Fside) != libc.Int32FromUint8((*TGeoSegment)(unsafe.Pointer(pSeg)).Fside) { + rc = int32(1) + goto geopolyOverlapDone + } else { + if (*TGeoSegment)(unsafe.Pointer(pPrev)).Fy != (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy { + (**(**[4]uint8)(__ccgo_up(bp)))[iMask] = uint8(1) + } + } + } + iMask = iMask ^ libc.Int32FromUint8((*TGeoSegment)(unsafe.Pointer(pSeg)).Fside) + pPrev = pSeg + goto _4 + _4: + ; + pSeg = (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext + } + } + if (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FeType == 0 { + /* Add a segment */ + pSeg = (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg + (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy = float64((*TGeoSegment)(unsafe.Pointer(pSeg)).Fy0) + (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext = pActive + pActive = pSeg + needSort = int32(1) + } else { + /* Remove a segment */ + if pActive == (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg { + if pActive != 0 { + v5 = (*TGeoSegment)(unsafe.Pointer(pActive)).FpNext + } else { + v5 = uintptr(0) + } + pActive = v5 + } else { + pSeg = pActive + for { + if !(pSeg != 0) { + break + } + if (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext == (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg { + if (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext != 0 { + v5 = (*TGeoSegment)(unsafe.Pointer((*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext)).FpNext + } else { + v5 = uintptr(0) + } + (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext = v5 + break + } + goto _6 + _6: + ; + pSeg = (*TGeoSegment)(unsafe.Pointer(pSeg)).FpNext + } + } + } + pThisEvent = (*TGeoEvent)(unsafe.Pointer(pThisEvent)).FpNext + } + if libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(3)]) == 0 { + rc = 0 + } else { + if libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(1)]) != 0 && libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(2)]) == 0 { + rc = int32(3) + } else { + if libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(1)]) == 0 && libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(2)]) != 0 { + rc = int32(2) + } else { + if libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(1)]) == 0 && libc.Int32FromUint8((**(**[4]uint8)(__ccgo_up(bp)))[int32(2)]) == 0 { + rc = int32(4) + } else { + rc = int32(1) + } + } + } + } + goto geopolyOverlapDone +geopolyOverlapDone: + ; + Xsqlite3_free(tls, p) + return rc +} diff --git a/internal/engine/lib/sqlite_g_000000000001fe8b.go b/internal/engine/lib/sqlite_g_000000000001fe8b.go new file mode 100644 index 0000000..4d27ebb --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001fe8b.go @@ -0,0 +1,63 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Function: geopoly_regular(X,Y,R,N) +// ** +// ** Construct a simple, convex, regular polygon centered at X, Y +// ** with circumradius R and with N sides. +// */ +func _geopolyRegularFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var n int32 + var p uintptr + var r, rAngle, x, y float64 + var _ /* i at bp+0 */ int32 + _, _, _, _, _, _ = n, p, r, rAngle, x, y + x = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv))) + y = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + r = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + n = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + _ = argc + if n < int32(3) || r <= float64(0) { + return + } + if n > int32(1000) { + n = int32(1000) + } + p = Xsqlite3_malloc64(tls, uint64(uint64(40)+libc.Uint64FromInt32((n-int32(1))*int32(2))*uint64(4))) + if p == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + **(**int32)(__ccgo_up(bp)) = int32(1) + **(**uint8)(__ccgo_up(p + 4)) = **(**uint8)(__ccgo_up(bp)) + **(**uint8)(__ccgo_up(p + 4 + 1)) = uint8(0) + **(**uint8)(__ccgo_up(p + 4 + 2)) = libc.Uint8FromInt32(n >> int32(8) & int32(0xff)) + **(**uint8)(__ccgo_up(p + 4 + 3)) = libc.Uint8FromInt32(n & int32(0xff)) + **(**int32)(__ccgo_up(bp)) = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) < n) { + break + } + rAngle = float64(float64(libc.Float64FromFloat64(2)*libc.Float64FromFloat64(3.141592653589793))*float64(**(**int32)(__ccgo_up(bp)))) / float64(n) + **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(**(**int32)(__ccgo_up(bp))*int32(2))*4)) = float32(x - float64(r*_geopolySine(tls, rAngle-float64(libc.Float64FromFloat64(0.5)*libc.Float64FromFloat64(3.141592653589793))))) + **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(**(**int32)(__ccgo_up(bp))*int32(2)+int32(1))*4)) = float32(y + float64(r*_geopolySine(tls, rAngle))) + goto _1 + _1: + ; + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + } + Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*n, uintptr(-libc.Int32FromInt32(1))) + Xsqlite3_free(tls, p) +} diff --git a/internal/engine/lib/sqlite_g_000000000001fea8.go b/internal/engine/lib/sqlite_g_000000000001fea8.go new file mode 100644 index 0000000..ebd0ca4 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001fea8.go @@ -0,0 +1,19873 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type Ttimespec = struct { + Ftv_sec Ttime_t + Ftv_nsec int64 +} + +// C documentation +// +// /* +// ** Initialize the operating system interface. +// ** +// ** This routine registers all VFS implementations for unix-like operating +// ** systems. This routine, and the sqlite3_os_end() routine that follows, +// ** should be the only routines in this file that are visible from other +// ** files. +// ** +// ** This routine is called once during SQLite initialization and by a +// ** single thread. The memory allocation and mutex subsystems have not +// ** necessarily been initialized when this routine is called, and so they +// ** should not be used. +// */ +func Xsqlite3_os_init(tls *libc.TLS) (r int32) { + var i uint32 + _ = i + /* Double-check that the aSyscall[] array has been constructed + ** correctly. See ticket [bb3a86e890c8e96ab] */ + /* Register all VFSes defined in the aVfs[] array */ + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(672)/libc.Uint64FromInt64(168)) { + break + } + Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&_aVfs))+uintptr(i)*168, libc.BoolInt32(i == uint32(0))) + goto _1 + _1: + ; + i = i + 1 + } + _unixBigLock = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1)) + /* Validate lock assumptions */ + /* Number of available locks */ + /* Start of locking area */ + /* Locks: + ** WRITE UNIX_SHM_BASE 120 + ** CKPT UNIX_SHM_BASE+1 121 + ** RECOVER UNIX_SHM_BASE+2 122 + ** READ-0 UNIX_SHM_BASE+3 123 + ** READ-1 UNIX_SHM_BASE+4 124 + ** READ-2 UNIX_SHM_BASE+5 125 + ** READ-3 UNIX_SHM_BASE+6 126 + ** READ-4 UNIX_SHM_BASE+7 127 + ** DMS UNIX_SHM_BASE+8 128 + */ + /* Byte offset of the deadman-switch */ + /* Initialize temp file dir array. */ + _unixTempFileInit(tls) + return SQLITE_OK +} + +/* + ** The following macro defines an initializer for an sqlite3_vfs object. + ** The name of the VFS is NAME. The pAppData is a pointer to a pointer + ** to the "finder" function. (pAppData is a pointer to a pointer because + ** silly C90 rules prohibit a void* from being cast to a function pointer + ** and so we have to go through the intermediate pointer to avoid problems + ** when compiling with -pedantic-errors on GCC.) + ** + ** The FINDER parameter to this macro is the name of the pointer to the + ** finder-function. The finder-function returns a pointer to the + ** sqlite_io_methods object that implements the desired locking + ** behaviors. See the division above that contains the IOMETHODS + ** macro for addition information on finder-functions. + ** + ** Most finders simply return a pointer to a fixed sqlite3_io_methods + ** object. But the "autolockIoFinder" available on MacOSX does a little + ** more than that; it looks at the filesystem type that hosts the + ** database file and tries to choose an locking method appropriate for + ** that filesystem time. + */ + +// C documentation +// +// /* +// ** Return N random bytes. +// */ +func Xsqlite3_randomness(tls *libc.TLS, N int32, pBuf uintptr) { + var mutex, pVfs, zBuf, v1 uintptr + _, _, _, _ = mutex, pVfs, zBuf, v1 + zBuf = pBuf + if Xsqlite3_initialize(tls) != 0 { + return + } + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_PRNG)) + Xsqlite3_mutex_enter(tls, mutex) + if N <= 0 || pBuf == uintptr(0) { + **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)))) = uint32(0) + Xsqlite3_mutex_leave(tls, mutex) + return + } + /* Initialize the state of the random number generator once, + ** the first time this routine is called. + */ + if **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)))) == uint32(0) { + pVfs = Xsqlite3_vfs_find(tls, uintptr(0)) + libc.Xmemcpy(tls, uintptr(unsafe.Pointer(&_sqlite3Prng)), uintptr(unsafe.Pointer(&_chacha20_init)), uint64(16)) + if pVfs == uintptr(0) { + libc.Xmemset(tls, uintptr(unsafe.Pointer(&_sqlite3Prng))+4*4, 0, uint64(44)) + } else { + _sqlite3OsRandomness(tls, pVfs, int32(44), uintptr(unsafe.Pointer(&_sqlite3Prng))+4*4) + } + **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 15*4)) = **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 12*4)) + **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 12*4)) = uint32(0) + _sqlite3Prng.Fn = uint8(0) + } + for int32(1) != 0 { + if N <= libc.Int32FromUint8(_sqlite3Prng.Fn) { + libc.Xmemcpy(tls, zBuf, uintptr(unsafe.Pointer(&_sqlite3Prng))+64+uintptr(libc.Int32FromUint8(_sqlite3Prng.Fn)-N), libc.Uint64FromInt32(N)) + v1 = uintptr(unsafe.Pointer(&_sqlite3Prng)) + 128 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) - N) + break + } + if libc.Int32FromUint8(_sqlite3Prng.Fn) > 0 { + libc.Xmemcpy(tls, zBuf, uintptr(unsafe.Pointer(&_sqlite3Prng))+64, uint64(_sqlite3Prng.Fn)) + N = N - libc.Int32FromUint8(_sqlite3Prng.Fn) + zBuf = zBuf + uintptr(_sqlite3Prng.Fn) + } + **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 12*4)) = **(**Tu32)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Prng)) + 12*4)) + 1 + _chacha_block(tls, uintptr(unsafe.Pointer(&_sqlite3Prng))+64, uintptr(unsafe.Pointer(&_sqlite3Prng))) + _sqlite3Prng.Fn = uint8(64) + } + Xsqlite3_mutex_leave(tls, mutex) +} + +// C documentation +// +// /* +// ** Add new client data to a database connection. +// */ +func Xsqlite3_set_clientdata(tls *libc.TLS, db uintptr, zName uintptr, pData uintptr, __ccgo_fp_xDestructor uintptr) (r int32) { + var n Tsize_t + var p, pp uintptr + _, _, _ = n, p, pp + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pp = db + 808 + p = (*Tsqlite3)(unsafe.Pointer(db)).FpDbData + for { + if !(p != 0 && libc.Xstrcmp(tls, p+24, zName) != 0) { + break + } + pp = p + goto _1 + _1: + ; + p = (*TDbClientData)(unsafe.Pointer(p)).FpNext + } + if p != 0 { + if (*TDbClientData)(unsafe.Pointer(p)).FxDestructor != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TDbClientData)(unsafe.Pointer(p)).FxDestructor})))(tls, (*TDbClientData)(unsafe.Pointer(p)).FpData) + } + if pData == uintptr(0) { + **(**uintptr)(__ccgo_up(pp)) = (*TDbClientData)(unsafe.Pointer(p)).FpNext + Xsqlite3_free(tls, p) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK + } + } else { + if pData == uintptr(0) { + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK + } else { + n = libc.Xstrlen(tls, zName) + p = Xsqlite3_malloc64(tls, uint64(uint64(libc.UintptrFromInt32(0)+24)+(n+libc.Uint64FromInt32(1)))) + if p == uintptr(0) { + if __ccgo_fp_xDestructor != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDestructor})))(tls, pData) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, p+24, zName, n+uint64(1)) + (*TDbClientData)(unsafe.Pointer(p)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).FpDbData + (*Tsqlite3)(unsafe.Pointer(db)).FpDbData = p + } + } + (*TDbClientData)(unsafe.Pointer(p)).FpData = pData + (*TDbClientData)(unsafe.Pointer(p)).FxDestructor = __ccgo_fp_xDestructor + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Append N bytes of text from z to the StrAccum object. Increase the +// ** size of the memory allocation for StrAccum if necessary. +// */ +func Xsqlite3_str_append(tls *libc.TLS, p uintptr, z uintptr, N int32) { + if (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar+libc.Uint32FromInt32(N) >= (*Tsqlite3_str)(unsafe.Pointer(p)).FnAlloc { + _enlargeAndAppend(tls, p, z, N) + } else { + if N != 0 { + **(**Tu32)(__ccgo_up(p + 24)) += libc.Uint32FromInt32(N) + libc.Xmemcpy(tls, (*Tsqlite3_str)(unsafe.Pointer(p)).FzText+uintptr((*Tsqlite3_str)(unsafe.Pointer(p)).FnChar-libc.Uint32FromInt32(N)), z, libc.Uint64FromInt32(N)) + } + } +} + +// C documentation +// +// /* Make a copy of an sqlite3_value object +// */ +func Xsqlite3_value_dup(tls *libc.TLS, pOrig uintptr) (r uintptr) { + var pNew, v1 uintptr + _, _ = pNew, v1 + if pOrig == uintptr(0) { + return uintptr(0) + } + pNew = Xsqlite3_malloc(tls, int32(56)) + if pNew == uintptr(0) { + return uintptr(0) + } + libc.Xmemset(tls, pNew, 0, uint64(56)) + libc.Xmemcpy(tls, pNew, pOrig, uint64(libc.UintptrFromInt32(0)+24)) + v1 = pNew + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Dyn)) + (*Tsqlite3_value)(unsafe.Pointer(pNew)).Fdb = uintptr(0) + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pNew)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) != 0 { + v1 = pNew + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Dyn))) + v1 = pNew + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Ephem)) + if _sqlite3VdbeMemMakeWriteable(tls, pNew) != SQLITE_OK { + _sqlite3ValueFree(tls, pNew) + pNew = uintptr(0) + } + } else { + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pNew)).Fflags)&int32(MEM_Null) != 0 { + /* Do not duplicate pointer values */ + v1 = pNew + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Term) | libc.Int32FromInt32(MEM_Subtype))) + } + } + return pNew +} + +// C documentation +// +// /* +// ** Configure the change currently under construction with a blob value. +// */ +func Xsqlite3changegroup_change_blob(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, pVal uintptr, nVal int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte Tsqlite3_int64 + var rc, v1 int32 + var _ /* pBuf at bp+0 */ uintptr + _, _, _ = nByte, rc, v1 + nByte = int64(int32(1)+_sessionVarintLen(tls, nVal)) + int64(nVal) + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + v1 = _checkChangeParams(tls, pGrp, bNew, iCol, nByte, bp) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_BLOB) + (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnBuf = int32(1) + _sessionVarintPut(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+1, nVal) + libc.Xmemcpy(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnBuf), pVal, libc.Uint64FromInt32(nVal)) + **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 8)) += nVal + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Configure the change currently under construction with a text value. +// */ +func Xsqlite3changegroup_change_text(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, pVal uintptr, nVal int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte Tsqlite3_int64 + var nText, rc, v2 int32 + var v1 uint64 + var _ /* pBuf at bp+0 */ uintptr + _, _, _, _, _ = nByte, nText, rc, v1, v2 + if nVal >= 0 { + v1 = libc.Uint64FromInt32(nVal) + } else { + v1 = libc.Xstrlen(tls, pVal) + } + nText = libc.Int32FromUint64(v1) + nByte = int64(int32(1) + _sessionVarintLen(tls, nText) + nText) + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + v2 = _checkChangeParams(tls, pGrp, bNew, iCol, nByte, bp) + rc = v2 + if SQLITE_OK != v2 { + return rc + } + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_TEXT) + (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnBuf = int32(1) + _sessionVarintPut(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+1, nText) + libc.Xmemcpy(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnBuf), pVal, libc.Uint64FromInt32(nText)) + **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 8)) += nText + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Create an RBU VFS named zName that accesses the underlying file-system +// ** via existing VFS zParent. The new object is registered as a non-default +// ** VFS with SQLite before returning. +// */ +func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) (r int32) { + var nByte, nName Tsize_t + var pNew, pParent, zSpace, v1 uintptr + var rc int32 + _, _, _, _, _, _, _ = nByte, nName, pNew, pParent, rc, zSpace, v1 + pNew = uintptr(0) /* Newly allocated VFS */ + rc = SQLITE_OK + nName = libc.Xstrlen(tls, zName) + nByte = uint64(208) + nName + uint64(1) + pNew = Xsqlite3_malloc64(tls, nByte) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { /* Parent VFS */ + libc.Xmemset(tls, pNew, 0, nByte) + pParent = Xsqlite3_vfs_find(tls, zParent) + if pParent == uintptr(0) { + rc = int32(SQLITE_NOTFOUND) + } else { + libc.Xmemcpy(tls, pNew, uintptr(unsafe.Pointer(&_vfs_template)), uint64(168)) + (*Trbu_vfs)(unsafe.Pointer(pNew)).Fbase.FmxPathname = (*Tsqlite3_vfs)(unsafe.Pointer(pParent)).FmxPathname + (*Trbu_vfs)(unsafe.Pointer(pNew)).Fbase.FszOsFile = libc.Int32FromUint64(uint64(104) + libc.Uint64FromInt32((*Tsqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile)) + (*Trbu_vfs)(unsafe.Pointer(pNew)).FpRealVfs = pParent + v1 = pNew + 1*208 + zSpace = v1 + (*Trbu_vfs)(unsafe.Pointer(pNew)).Fbase.FzName = v1 + libc.Xmemcpy(tls, zSpace, zName, nName) + /* Allocate the mutex and register the new VFS (not as the default) */ + (*Trbu_vfs)(unsafe.Pointer(pNew)).Fmutex = Xsqlite3_mutex_alloc(tls, int32(SQLITE_MUTEX_RECURSIVE)) + if (*Trbu_vfs)(unsafe.Pointer(pNew)).Fmutex == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = Xsqlite3_vfs_register(tls, pNew, 0) + } + } + if rc != SQLITE_OK { + Xsqlite3_mutex_free(tls, (*Trbu_vfs)(unsafe.Pointer(pNew)).Fmutex) + Xsqlite3_free(tls, pNew) + } + } + return rc +} + +// C documentation +// +// /* +// ** Attach a table to a session. All subsequent changes made to the table +// ** while the session object is enabled will be recorded. +// ** +// ** Only tables that have a PRIMARY KEY defined may be attached. It does +// ** not matter if the PRIMARY KEY is an "INTEGER PRIMARY KEY" (rowid alias) +// ** or not. +// */ +func Xsqlite3session_attach(tls *libc.TLS, pSession uintptr, zName uintptr) (r int32) { + var nByte, nName, rc int32 + var pTab, ppTab uintptr + _, _, _, _, _ = nByte, nName, pTab, ppTab, rc + rc = SQLITE_OK + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + if !(zName != 0) { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = int32(1) + } else { /* Number of bytes in string zName */ + /* First search for an existing entry. If one is found, this call is + ** a no-op. Return early. */ + nName = _sqlite3Strlen30(tls, zName) + pTab = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable + for { + if !(pTab != 0) { + break + } + if 0 == Xsqlite3_strnicmp(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zName, nName+int32(1)) { + break + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + if !(pTab != 0) { + /* Allocate new SessionTable object. */ + nByte = libc.Int32FromUint64(uint64(88) + libc.Uint64FromInt32(nName) + uint64(1)) + pTab = _sessionMalloc64(tls, pSession, int64(nByte)) + if !(pTab != 0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pTab, 0, uint64(88)) + (*TSessionTable)(unsafe.Pointer(pTab)).FzName = pTab + 1*88 + libc.Xmemcpy(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zName, libc.Uint64FromInt32(nName+int32(1))) + ppTab = pSession + 88 + for { + if !(**(**uintptr)(__ccgo_up(ppTab)) != 0) { + break + } + goto _2 + _2: + ; + ppTab = **(**uintptr)(__ccgo_up(ppTab)) + } + **(**uintptr)(__ccgo_up(ppTab)) = pTab + } + } + } + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb)) + return rc +} + +// C documentation +// +// /* +// ** Create a session object. This session object will record changes to +// ** database zDb attached to connection db. +// */ +func Xsqlite3session_create(tls *libc.TLS, db uintptr, zDb uintptr, ppSession uintptr) (r int32) { + var nDb int32 + var pNew, pOld uintptr + _, _, _ = nDb, pNew, pOld /* Session object already attached to db */ + nDb = _sqlite3Strlen30(tls, zDb) /* Length of zDb in bytes */ + /* Zero the output value in case an error occurs. */ + **(**uintptr)(__ccgo_up(ppSession)) = uintptr(0) + /* Allocate and populate the new session object. */ + pNew = Xsqlite3_malloc64(tls, uint64(uint64(136)+libc.Uint64FromInt32(nDb)+uint64(1))) + if !(pNew != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pNew, 0, uint64(136)) + (*Tsqlite3_session)(unsafe.Pointer(pNew)).Fdb = db + (*Tsqlite3_session)(unsafe.Pointer(pNew)).FzDb = pNew + 1*136 + (*Tsqlite3_session)(unsafe.Pointer(pNew)).FbEnable = int32(1) + libc.Xmemcpy(tls, (*Tsqlite3_session)(unsafe.Pointer(pNew)).FzDb, zDb, libc.Uint64FromInt32(nDb+int32(1))) + _sessionPreupdateHooks(tls, pNew) + /* Add the new session object to the linked list of session objects + ** attached to database handle $db. Do this under the cover of the db + ** handle mutex. */ + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db)) + pOld = Xsqlite3_preupdate_hook(tls, db, __ccgo_fp(_xPreUpdate), pNew) + (*Tsqlite3_session)(unsafe.Pointer(pNew)).FpNext = pOld + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + **(**uintptr)(__ccgo_up(ppSession)) = pNew + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Arguments aIdx, aCell and aSpare all point to arrays of size +// ** nIdx. The aIdx array contains the set of integers from 0 to +// ** (nIdx-1) in no particular order. This function sorts the values +// ** in aIdx according to dimension iDim of the cells in aCell. The +// ** minimum value of dimension iDim is considered first, the +// ** maximum used to break ties. +// ** +// ** The aSpare array is used as temporary working space by the +// ** sorting algorithm. +// */ +func _SortByDimension(tls *libc.TLS, pRtree uintptr, aIdx uintptr, nIdx int32, iDim int32, aCell uintptr, aSpare uintptr) { + var aLeft, aRight uintptr + var iLeft, iRight, nLeft, nRight int32 + var xleft1, xleft2, xright1, xright2 TRtreeDValue + var v1, v2, v3, v4 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aLeft, aRight, iLeft, iRight, nLeft, nRight, xleft1, xleft2, xright1, xright2, v1, v2, v3, v4 + if nIdx > int32(1) { + iLeft = 0 + iRight = 0 + nLeft = nIdx / int32(2) + nRight = nIdx - nLeft + aLeft = aIdx + aRight = aIdx + uintptr(nLeft)*4 + _SortByDimension(tls, pRtree, aLeft, nLeft, iDim, aCell, aSpare) + _SortByDimension(tls, pRtree, aRight, nRight, iDim, aCell, aSpare) + libc.Xmemcpy(tls, aSpare, aLeft, uint64(4)*libc.Uint64FromInt32(nLeft)) + aLeft = aSpare + for iLeft < nLeft || iRight < nRight { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v1 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*int32(2))*4))) + } else { + v1 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*int32(2))*4))) + } + xleft1 = v1 + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v2 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*int32(2)+int32(1))*4))) + } else { + v2 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*int32(2)+int32(1))*4))) + } + xleft2 = v2 + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v3 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*int32(2))*4))) + } else { + v3 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*int32(2))*4))) + } + xright1 = v3 + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v4 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*int32(2)+int32(1))*4))) + } else { + v4 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(**(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*int32(2)+int32(1))*4))) + } + xright2 = v4 + if iLeft != nLeft && (iRight == nRight || xleft1 < xright1 || xleft1 == xright1 && xleft2 < xright2) { + **(**int32)(__ccgo_up(aIdx + uintptr(iLeft+iRight)*4)) = **(**int32)(__ccgo_up(aLeft + uintptr(iLeft)*4)) + iLeft = iLeft + 1 + } else { + **(**int32)(__ccgo_up(aIdx + uintptr(iLeft+iRight)*4)) = **(**int32)(__ccgo_up(aRight + uintptr(iRight)*4)) + iRight = iRight + 1 + } + } + } +} + +func _SplitNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var aCell, aiUsed, pLeft, pParent, pRight uintptr + var i, nCell, newCellIsRight, rc, v2, v3 int32 + var iRowid, iRowid1 Ti64 + var v4, v5 bool + var _ /* iCell at bp+96 */ int32 + var _ /* leftbbox at bp+0 */ TRtreeCell + var _ /* rightbbox at bp+48 */ TRtreeCell + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCell, aiUsed, i, iRowid, iRowid1, nCell, newCellIsRight, pLeft, pParent, pRight, rc, v2, v3, v4, v5 + newCellIsRight = 0 + rc = SQLITE_OK + nCell = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) + pLeft = uintptr(0) + pRight = uintptr(0) + /* Allocate an array and populate it with a copy of pCell and + ** all cells from node pLeft. Then zero the original node. + */ + aCell = Xsqlite3_malloc64(tls, uint64((libc.Uint64FromInt64(48)+libc.Uint64FromInt64(4))*libc.Uint64FromInt32(nCell+libc.Int32FromInt32(1)))) + if !(aCell != 0) { + rc = int32(SQLITE_NOMEM) + goto splitnode_out + } + aiUsed = aCell + uintptr(nCell+int32(1))*48 + libc.Xmemset(tls, aiUsed, 0, uint64(4)*libc.Uint64FromInt32(nCell+libc.Int32FromInt32(1))) + i = 0 + for { + if !(i < nCell) { + break + } + _nodeGetCell(tls, pRtree, pNode, i, aCell+uintptr(i)*48) + goto _1 + _1: + ; + i = i + 1 + } + _nodeZero(tls, pRtree, pNode) + libc.Xmemcpy(tls, aCell+uintptr(nCell)*48, pCell, uint64(48)) + nCell = nCell + 1 + if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) { + pRight = _nodeNew(tls, pRtree, pNode) + pLeft = _nodeNew(tls, pRtree, pNode) + (*TRtree)(unsafe.Pointer(pRtree)).FiDepth = (*TRtree)(unsafe.Pointer(pRtree)).FiDepth + 1 + (*TRtreeNode)(unsafe.Pointer(pNode)).FisDirty = int32(1) + _writeInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData, (*TRtree)(unsafe.Pointer(pRtree)).FiDepth) + } else { + pLeft = pNode + pRight = _nodeNew(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pLeft)).FpParent) + (*TRtreeNode)(unsafe.Pointer(pLeft)).FnRef = (*TRtreeNode)(unsafe.Pointer(pLeft)).FnRef + 1 + } + if !(pLeft != 0) || !(pRight != 0) { + rc = int32(SQLITE_NOMEM) + goto splitnode_out + } + libc.Xmemset(tls, (*TRtreeNode)(unsafe.Pointer(pLeft)).FzData, 0, libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize)) + libc.Xmemset(tls, (*TRtreeNode)(unsafe.Pointer(pRight)).FzData, 0, libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize)) + rc = _splitNodeStartree(tls, pRtree, aCell, nCell, pLeft, pRight, bp, bp+48) + if rc != SQLITE_OK { + goto splitnode_out + } + /* Ensure both child nodes have node numbers assigned to them by calling + ** nodeWrite(). Node pRight always needs a node number, as it was created + ** by nodeNew() above. But node pLeft sometimes already has a node number. + ** In this case avoid the all to nodeWrite(). + */ + v2 = _nodeWrite(tls, pRtree, pRight) + rc = v2 + if v5 = SQLITE_OK != v2; !v5 { + if v4 = 0 == (*TRtreeNode)(unsafe.Pointer(pLeft)).FiNode; v4 { + v3 = _nodeWrite(tls, pRtree, pLeft) + rc = v3 + } + } + if v5 || v4 && SQLITE_OK != v3 { + goto splitnode_out + } + (**(**TRtreeCell)(__ccgo_up(bp + 48))).FiRowid = (*TRtreeNode)(unsafe.Pointer(pRight)).FiNode + (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid = (*TRtreeNode)(unsafe.Pointer(pLeft)).FiNode + if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) { + rc = _rtreeInsertCell(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pLeft)).FpParent, bp, iHeight+int32(1)) + if rc != SQLITE_OK { + goto splitnode_out + } + } else { + pParent = (*TRtreeNode)(unsafe.Pointer(pLeft)).FpParent + rc = _nodeParentIndex(tls, pRtree, pLeft, bp+96) + if rc == SQLITE_OK { + _nodeOverwriteCell(tls, pRtree, pParent, bp, **(**int32)(__ccgo_up(bp + 96))) + rc = _AdjustTree(tls, pRtree, pParent, bp) + } + if rc != SQLITE_OK { + goto splitnode_out + } + } + v2 = _rtreeInsertCell(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pRight)).FpParent, bp+48, iHeight+int32(1)) + rc = v2 + if v2 != 0 { + goto splitnode_out + } + i = 0 + for { + if !(i < _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pRight)).FzData+2)) { + break + } + iRowid = _nodeGetRowid(tls, pRtree, pRight, i) + rc = _updateMapping(tls, pRtree, iRowid, pRight, iHeight) + if iRowid == (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid { + newCellIsRight = int32(1) + } + if rc != SQLITE_OK { + goto splitnode_out + } + goto _7 + _7: + ; + i = i + 1 + } + if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) { + i = 0 + for { + if !(i < _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pLeft)).FzData+2)) { + break + } + iRowid1 = _nodeGetRowid(tls, pRtree, pLeft, i) + rc = _updateMapping(tls, pRtree, iRowid1, pLeft, iHeight) + if rc != SQLITE_OK { + goto splitnode_out + } + goto _8 + _8: + ; + i = i + 1 + } + } else { + if newCellIsRight == 0 { + rc = _updateMapping(tls, pRtree, (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid, pLeft, iHeight) + } + } + goto splitnode_out +splitnode_out: + ; + _nodeRelease(tls, pRtree, pRight) + _nodeRelease(tls, pRtree, pLeft) + Xsqlite3_free(tls, aCell) + return rc +} + +// C documentation +// +// /* +// ** This function is used to read or overwrite payload information +// ** for the entry that the pCur cursor is pointing to. The eOp +// ** argument is interpreted as follows: +// ** +// ** 0: The operation is a read. Populate the overflow cache. +// ** 1: The operation is a write. Populate the overflow cache. +// ** +// ** A total of "amt" bytes are read or written beginning at "offset". +// ** Data is read to or from the buffer pBuf. +// ** +// ** The content being read or written might appear on the main page +// ** or be scattered out on multiple overflow pages. +// ** +// ** If the current cursor entry uses one or more overflow pages +// ** this function may allocate space for and lazily populate +// ** the overflow page-list cache array (BtCursor.aOverflow). +// ** Subsequent calls use this cache to make seeking to the supplied offset +// ** more efficient. +// ** +// ** Once an overflow page-list cache has been allocated, it must be +// ** invalidated if some other cursor writes to the same table, or if +// ** the cursor is moved to a different row. Additionally, in auto-vacuum +// ** mode, the following events may invalidate an overflow page-list cache. +// ** +// ** * An incremental vacuum, +// ** * A commit in auto_vacuum="full" mode, +// ** * Creating a table (may require moving an overflow page). +// */ +func _accessPayload(tls *libc.TLS, pCur uintptr, offset Tu32, amt Tu32, pBuf uintptr, eOp int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, a1, iIdx, rc, v2 int32 + var aNew, aPayload, aWrite, fd, pBt, pBufStart, pPage, v1 uintptr + var nOvfl Ti64 + var ovflSize Tu32 + var _ /* aSave at bp+4 */ [4]Tu8 + var _ /* nextPage at bp+0 */ TPgno + var _ /* pDbPage at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, a1, aNew, aPayload, aWrite, fd, iIdx, nOvfl, ovflSize, pBt, pBufStart, pPage, rc, v1, v2 + rc = SQLITE_OK + iIdx = 0 + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage /* Btree page of current entry */ + pBt = (*TBtCursor)(unsafe.Pointer(pCur)).FpBt /* Btree this cursor belongs to */ + pBufStart = pBuf /* Start of original out buffer */ + if libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + return _sqlite3CorruptError(tls, int32(78282)) + } + _getCellInfo(tls, pCur) + aPayload = (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload + if libc.Uint64FromInt64(int64(aPayload)-int64((*TMemPage)(unsafe.Pointer(pPage)).FaData)) > uint64((*TBtShared)(unsafe.Pointer(pBt)).FusableSize-uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) { + /* Trying to read or write past the end of the data is an error. The + ** conditional above is really: + ** &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize] + ** but is recast into its current form to avoid integer overflow problems + */ + return _sqlite3CorruptError(tls, int32(78297)) + } + /* Check if data must be read/written to/from the btree page itself. */ + if offset < uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) { + a = libc.Int32FromUint32(amt) + if libc.Uint32FromInt32(a)+offset > uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) { + a = libc.Int32FromUint32(uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) - offset) + } + rc = _copyPayload(tls, aPayload+uintptr(offset), pBuf, a, eOp, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + offset = uint32(0) + pBuf = pBuf + uintptr(a) + amt = amt - libc.Uint32FromInt32(a) + } else { + offset = offset - uint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) + } + if rc == SQLITE_OK && amt > uint32(0) { + ovflSize = (*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32(4) + **(**TPgno)(__ccgo_up(bp)) = _sqlite3Get4byte(tls, aPayload+uintptr((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) + /* If the BtCursor.aOverflow[] has not been allocated, allocate it now. + ** + ** The aOverflow[] array is sized at one entry for each overflow page + ** in the overflow chain. The page number of the first overflow page is + ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array + ** means "not yet known" (the cache is lazily populated). + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_ValidOvfl) == 0 { + nOvfl = libc.Int64FromUint32((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload) + nOvfl = (nOvfl - libc.Int64FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) + libc.Int64FromUint32(ovflSize) - int64(1)) / libc.Int64FromUint32(ovflSize) + if (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow == uintptr(0) || nOvfl*int64(libc.Int32FromInt64(4)) > int64(_sqlite3MallocSize(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow)) { + if _sqlite3FaultSim(tls, int32(413)) != 0 { + aNew = uintptr(0) + } else { + aNew = _sqlite3Realloc(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow, libc.Uint64FromInt64(nOvfl*int64(2))*uint64(4)) + } + if aNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow = aNew + } + } + libc.Xmemset(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow, 0, uint64(libc.Uint64FromInt64(nOvfl)*uint64(4))) + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTCF_ValidOvfl)) + } else { + /* Sanity check the validity of the overflow page cache */ + /* If the overflow page-list cache has been allocated and the + ** entry for the first required overflow page is valid, skip + ** directly to it. + */ + if **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(offset/ovflSize)*4)) != 0 { + iIdx = libc.Int32FromUint32(offset / ovflSize) + **(**TPgno)(__ccgo_up(bp)) = **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx)*4)) + offset = offset % ovflSize + } + } + for **(**TPgno)(__ccgo_up(bp)) != 0 { + /* If required, populate the overflow page-list cache. */ + if **(**TPgno)(__ccgo_up(bp)) > (*TBtShared)(unsafe.Pointer(pBt)).FnPage { + return _sqlite3CorruptError(tls, int32(78370)) + } + **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx)*4)) = **(**TPgno)(__ccgo_up(bp)) + if offset >= ovflSize { + /* The only reason to read this page is to obtain the page + ** number for the next page in the overflow chain. The page + ** data is not required. So first try to lookup the overflow + ** page-list cache, if any, then fall back to the getOverflowPage() + ** function. + */ + if **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx+int32(1))*4)) != 0 { + **(**TPgno)(__ccgo_up(bp)) = **(**TPgno)(__ccgo_up((*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx+int32(1))*4)) + } else { + rc = _getOverflowPage(tls, pBt, **(**TPgno)(__ccgo_up(bp)), uintptr(0), bp) + } + offset = offset - ovflSize + } else { + /* Need to read this page properly. It contains some of the + ** range of data that is being read (eOp==0) or written (eOp!=0). + */ + a1 = libc.Int32FromUint32(amt) + if libc.Uint32FromInt32(a1)+offset > ovflSize { + a1 = libc.Int32FromUint32(ovflSize - offset) + } + /* If all the following are true: + ** + ** 1) this is a read operation, and + ** 2) data is required from the start of this overflow page, and + ** 3) there are no dirty pages in the page-cache + ** 4) the database is file-backed, and + ** 5) the page is not in the WAL file + ** 6) at least 4 bytes have already been read into the output buffer + ** + ** then data can be read directly from the database file into the + ** output buffer, bypassing the page-cache altogether. This speeds + ** up loading large records that span many overflow pages. + */ + if eOp == 0 && offset == uint32(0) && _sqlite3PagerDirectReadOk(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, **(**TPgno)(__ccgo_up(bp))) != 0 && pBuf+uintptr(-libc.Int32FromInt32(4)) >= pBufStart { + fd = _sqlite3PagerFile(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + aWrite = pBuf + uintptr(-libc.Int32FromInt32(4)) + /* due to (6) */ + libc.Xmemcpy(tls, bp+4, aWrite, uint64(4)) + rc = _sqlite3OsRead(tls, fd, aWrite, a1+int32(4), libc.Int64FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FpageSize)*libc.Int64FromUint32(**(**TPgno)(__ccgo_up(bp))-libc.Uint32FromInt32(1))) + **(**TPgno)(__ccgo_up(bp)) = _sqlite3Get4byte(tls, aWrite) + libc.Xmemcpy(tls, aWrite, bp+4, uint64(4)) + } else { + if eOp == 0 { + v2 = int32(PAGER_GET_READONLY) + } else { + v2 = 0 + } + rc = _sqlite3PagerGet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, **(**TPgno)(__ccgo_up(bp)), bp+8, v2) + if rc == SQLITE_OK { + if eOp != 0 && (_sqlite3PagerPageRefcount(tls, **(**uintptr)(__ccgo_up(bp + 8))) != int32(1) || (*TMemPage)(unsafe.Pointer(_sqlite3PagerGetExtra(tls, **(**uintptr)(__ccgo_up(bp + 8))))).FisInit != 0) { + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return _sqlite3CorruptError(tls, int32(78440)) + } + aPayload = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**TPgno)(__ccgo_up(bp)) = _sqlite3Get4byte(tls, aPayload) + rc = _copyPayload(tls, aPayload+uintptr(offset+uint32(4)), pBuf, a1, eOp, **(**uintptr)(__ccgo_up(bp + 8))) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + offset = uint32(0) + } + } + amt = amt - libc.Uint32FromInt32(a1) + if amt == uint32(0) { + return rc + } + pBuf = pBuf + uintptr(a1) + } + if rc != 0 { + break + } + iIdx = iIdx + 1 + } + } + if rc == SQLITE_OK && amt > uint32(0) { + /* Overflow chain ends prematurely */ + return _sqlite3CorruptError(tls, int32(78460)) + } + return rc +} + +// C documentation +// +// /* +// ** Allocate a new page from the database file. +// ** +// ** The new page is marked as dirty. (In other words, sqlite3PagerWrite() +// ** has already been called on the new page.) The new page has also +// ** been referenced and the calling routine is responsible for calling +// ** sqlite3PagerUnref() on the new page when it is done. +// ** +// ** SQLITE_OK is returned on success. Any other return value indicates +// ** an error. *ppPage is set to NULL in the event of an error. +// ** +// ** If the "nearby" parameter is not 0, then an effort is made to +// ** locate a page close to the page number "nearby". This can be used in an +// ** attempt to keep related pages close to each other in the database file, +// ** which in turn can make database access faster. +// ** +// ** If the eMode parameter is BTALLOC_EXACT and the nearby page exists +// ** anywhere on the free-list, then it is guaranteed to be returned. If +// ** eMode is BTALLOC_LT then the page returned will be less than or equal +// ** to nearby if any such page exists. If eMode is BTALLOC_ANY then there +// ** are no restrictions on which page is returned. +// */ +func _allocateBtreePage(tls *libc.TLS, pBt uintptr, ppPage uintptr, pPgno uintptr, nearby TPgno, eMode Tu8) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aData, pPage1, pPrevTrunk uintptr + var bNoContent, d2, dist, noContent, rc, v5 int32 + var closest, i, k, n, nSearch, v1 Tu32 + var iNewTrunk, iPage, iTrunk, mxPage TPgno + var searchList Tu8 + var v2 bool + var _ /* eType at bp+8 */ Tu8 + var _ /* pNewTrunk at bp+16 */ uintptr + var _ /* pPg at bp+24 */ uintptr + var _ /* pTrunk at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, bNoContent, closest, d2, dist, i, iNewTrunk, iPage, iTrunk, k, mxPage, n, nSearch, noContent, pPage1, pPrevTrunk, rc, searchList, v1, v2, v5 /* Number of leaves on the trunk of the freelist */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pPrevTrunk = uintptr(0) /* Total size of the database file */ + pPage1 = (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 + mxPage = _btreePagecount(tls, pBt) + /* EVIDENCE-OF: R-21003-45125 The 4-byte big-endian integer at offset 36 + ** stores the total number of pages on the freelist. */ + n = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+36) + if n >= mxPage { + return _sqlite3CorruptError(tls, int32(79672)) + } + if n > uint32(0) { + searchList = uint8(0) /* If the free-list must be searched for 'nearby' */ + nSearch = uint32(0) /* Count of the number of search attempts */ + /* If eMode==BTALLOC_EXACT and a query of the pointer-map + ** shows that the page 'nearby' is somewhere on the free-list, then + ** the entire-list will be searched for that page. + */ + if libc.Int32FromUint8(eMode) == int32(BTALLOC_EXACT) { + if nearby <= mxPage { + rc = _ptrmapGet(tls, pBt, nearby, bp+8, uintptr(0)) + if rc != 0 { + return rc + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp + 8))) == int32(PTRMAP_FREEPAGE) { + searchList = uint8(1) + } + } + } else { + if libc.Int32FromUint8(eMode) == int32(BTALLOC_LE) { + searchList = uint8(1) + } + } + /* Decrement the free-list count by 1. Set iTrunk to the index of the + ** first free-list trunk page. iPrevTrunk is initially 1. + */ + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FpDbPage) + if rc != 0 { + return rc + } + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+36, n-uint32(1)) + /* The code within this loop is run only once if the 'searchList' variable + ** is not true. Otherwise, it runs once for each trunk-page on the + ** free-list until the page 'nearby' is located (eMode==BTALLOC_EXACT) + ** or until a page less than 'nearby' is located (eMode==BTALLOC_LT) + */ + for cond := true; cond; cond = searchList != 0 { + pPrevTrunk = **(**uintptr)(__ccgo_up(bp)) + if pPrevTrunk != 0 { + /* EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page + ** is the page number of the next freelist trunk page in the list or + ** zero if this is the last freelist trunk page. */ + iTrunk = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FaData) + } else { + /* EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32 + ** stores the page number of the first page of the freelist, or zero if + ** the freelist is empty. */ + iTrunk = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32) + } + if v2 = iTrunk > mxPage; !v2 { + v1 = nSearch + nSearch = nSearch + 1 + } + if v2 || v1 > n { + rc = _sqlite3CorruptError(tls, int32(79728)) + } else { + rc = _btreeGetUnusedPage(tls, pBt, iTrunk, bp, 0) + } + if rc != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + goto end_allocate_page + } + /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page + ** is the number of leaf page pointers to follow. */ + k = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+4) + if k == uint32(0) && !(searchList != 0) { + /* The trunk has no leaves and the list is not being searched. + ** So extract the trunk page itself and use it as the newly + ** allocated page */ + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if rc != 0 { + goto end_allocate_page + } + **(**TPgno)(__ccgo_up(pPgno)) = iTrunk + libc.Xmemcpy(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4)) + **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if k > (*TBtShared)(unsafe.Pointer(pBt)).FusableSize/libc.Uint32FromInt32(4)-libc.Uint32FromInt32(2) { + /* Value of k is out of range. Database corruption */ + rc = _sqlite3CorruptError(tls, int32(79757)) + goto end_allocate_page + } else { + if searchList != 0 && (nearby == iTrunk || iTrunk < nearby && libc.Int32FromUint8(eMode) == int32(BTALLOC_LE)) { + /* The list is being searched and this trunk page is the page + ** to allocate, regardless of whether it has leaves. + */ + **(**TPgno)(__ccgo_up(pPgno)) = iTrunk + **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up(bp)) + searchList = uint8(0) + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if rc != 0 { + goto end_allocate_page + } + if k == uint32(0) { + if !(pPrevTrunk != 0) { + libc.Xmemcpy(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4)) + } else { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage) + if rc != SQLITE_OK { + goto end_allocate_page + } + libc.Xmemcpy(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FaData, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4)) + } + } else { + iNewTrunk = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+8) + if iNewTrunk > mxPage { + rc = _sqlite3CorruptError(tls, int32(79791)) + goto end_allocate_page + } + rc = _btreeGetUnusedPage(tls, pBt, iNewTrunk, bp+16, 0) + if rc != SQLITE_OK { + goto end_allocate_page + } + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FpDbPage) + if rc != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 16))) + goto end_allocate_page + } + libc.Xmemcpy(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FaData, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData, uint64(4)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FaData+4, k-uint32(1)) + libc.Xmemcpy(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FaData+8, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+12, uint64((k-uint32(1))*uint32(4))) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 16))) + if !(pPrevTrunk != 0) { + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32, iNewTrunk) + } else { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage) + if rc != 0 { + goto end_allocate_page + } + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPrevTrunk)).FaData, iNewTrunk) + } + } + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if k > uint32(0) { + aData = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData + if nearby > uint32(0) { + closest = uint32(0) + if libc.Int32FromUint8(eMode) == int32(BTALLOC_LE) { + i = uint32(0) + for { + if !(i < k) { + break + } + iPage = _sqlite3Get4byte(tls, aData+uintptr(uint32(8)+i*uint32(4))) + if iPage <= nearby { + closest = i + break + } + goto _3 + _3: + ; + i = i + 1 + } + } else { + dist = _sqlite3AbsInt32(tls, libc.Int32FromUint32(_sqlite3Get4byte(tls, aData+8)-nearby)) + i = uint32(1) + for { + if !(i < k) { + break + } + d2 = _sqlite3AbsInt32(tls, libc.Int32FromUint32(_sqlite3Get4byte(tls, aData+uintptr(uint32(8)+i*uint32(4)))-nearby)) + if d2 < dist { + closest = i + dist = d2 + } + goto _4 + _4: + ; + i = i + 1 + } + } + } else { + closest = uint32(0) + } + iPage = _sqlite3Get4byte(tls, aData+uintptr(uint32(8)+closest*uint32(4))) + if iPage > mxPage || iPage < uint32(2) { + rc = _sqlite3CorruptError(tls, int32(79856)) + goto end_allocate_page + } + if !(searchList != 0) || (iPage == nearby || iPage < nearby && libc.Int32FromUint8(eMode) == int32(BTALLOC_LE)) { + **(**TPgno)(__ccgo_up(pPgno)) = iPage + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if rc != 0 { + goto end_allocate_page + } + if closest < k-uint32(1) { + libc.Xmemcpy(tls, aData+uintptr(uint32(8)+closest*uint32(4)), aData+uintptr(uint32(4)+k*uint32(4)), uint64(4)) + } + _sqlite3Put4byte(tls, aData+4, k-uint32(1)) + if !(_btreeGetHasContent(tls, pBt, **(**TPgno)(__ccgo_up(pPgno))) != 0) { + v5 = int32(PAGER_GET_NOCONTENT) + } else { + v5 = 0 + } + noContent = v5 + rc = _btreeGetUnusedPage(tls, pBt, **(**TPgno)(__ccgo_up(pPgno)), ppPage, noContent) + if rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppPage)))).FpDbPage) + if rc != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(ppPage))) + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + } + } + searchList = uint8(0) + } + } + } + } + } + _releasePage(tls, pPrevTrunk) + pPrevTrunk = uintptr(0) + } + } else { + if 0 == libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FbDoTruncate) { + v5 = int32(PAGER_GET_NOCONTENT) + } else { + v5 = 0 + } + /* There are no pages on the freelist, so append a new page to the + ** database image. + ** + ** Normally, new pages allocated by this block can be requested from the + ** pager layer with the 'no-content' flag set. This prevents the pager + ** from trying to read the pages content from disk. However, if the + ** current transaction has already run one or more incremental-vacuum + ** steps, then the page we are about to allocate may contain content + ** that is required in the event of a rollback. In this case, do + ** not set the no-content flag. This causes the pager to load and journal + ** the current page content before overwriting it. + ** + ** Note that the pager will not actually attempt to load or journal + ** content for any page that really does lie past the end of the database + ** file on disk. So the effects of disabling the no-content optimization + ** here are confined to those pages that lie between the end of the + ** database image and the end of the database file. + */ + bNoContent = v5 + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) + if rc != 0 { + return rc + } + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + 1 + if (*TBtShared)(unsafe.Pointer(pBt)).FnPage == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + 1 + } + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && _ptrmapPageno(tls, pBt, (*TBtShared)(unsafe.Pointer(pBt)).FnPage) == (*TBtShared)(unsafe.Pointer(pBt)).FnPage { + /* If *pPgno refers to a pointer-map page, allocate two new pages + ** at the end of the file instead of one. The first allocated page + ** becomes a new pointer-map page, the second is used by the caller. + */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + rc = _btreeGetUnusedPage(tls, pBt, (*TBtShared)(unsafe.Pointer(pBt)).FnPage, bp+24, bNoContent) + if rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 24)))).FpDbPage) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 24))) + } + if rc != 0 { + return rc + } + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + 1 + if (*TBtShared)(unsafe.Pointer(pBt)).FnPage == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + 1 + } + } + _sqlite3Put4byte(tls, uintptr(28)+(*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData, (*TBtShared)(unsafe.Pointer(pBt)).FnPage) + **(**TPgno)(__ccgo_up(pPgno)) = (*TBtShared)(unsafe.Pointer(pBt)).FnPage + rc = _btreeGetUnusedPage(tls, pBt, **(**TPgno)(__ccgo_up(pPgno)), ppPage, bNoContent) + if rc != 0 { + return rc + } + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppPage)))).FpDbPage) + if rc != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(ppPage))) + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + } + } + goto end_allocate_page +end_allocate_page: + ; + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + _releasePage(tls, pPrevTrunk) + return rc +} + +// C documentation +// +// /* +// ** Allocate VdbeCursor number iCur. Return a pointer to it. Return NULL +// ** if we run out of memory. +// */ +func _allocateCursor(tls *libc.TLS, p uintptr, iCur int32, nField int32, eCurType Tu8) (r uintptr) { + var nByte Ti64 + var pCx, pMem, v1 uintptr + _, _, _, _ = nByte, pCx, pMem, v1 + if iCur > 0 { + v1 = (*TVdbe)(unsafe.Pointer(p)).FaMem + uintptr((*TVdbe)(unsafe.Pointer(p)).FnMem-iCur)*56 + } else { + v1 = (*TVdbe)(unsafe.Pointer(p)).FaMem + } + /* Find the memory cell that will be used to store the blob of memory + ** required for this VdbeCursor structure. It is convenient to use a + ** vdbe memory cell to manage the memory allocation required for a + ** VdbeCursor structure for the following reasons: + ** + ** * Sometimes cursor numbers are used for a couple of different + ** purposes in a vdbe program. The different uses might require + ** different sized allocations. Memory cells provide growable + ** allocations. + ** + ** * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can + ** be freed lazily via the sqlite3_release_memory() API. This + ** minimizes the number of malloc calls made by the system. + ** + ** The memory cell for cursor 0 is aMem[0]. The rest are allocated from + ** the top of the register space. Cursor 1 is at Mem[p->nMem-1]. + ** Cursor 2 is at Mem[p->nMem-2]. And so forth. + */ + pMem = v1 + pCx = uintptr(0) + nByte = libc.Int64FromUint64((uint64(libc.UintptrFromInt32(0)+120)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7)) + libc.Uint64FromInt32(nField+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + if libc.Int32FromUint8(eCurType) == CURTYPE_BTREE { + nByte = nByte + int64(_sqlite3BtreeCursorSize(tls)) + } + if **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) != 0 { /*OPTIMIZATION-IF-FALSE*/ + _sqlite3VdbeFreeCursorNN(tls, p, **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8))) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) = uintptr(0) + } + /* There used to be a call to sqlite3VdbeMemClearAndResize() to make sure + ** the pMem used to hold space for the cursor has enough storage available + ** in pMem->zMalloc. But for the special case of the aMem[] entries used + ** to hold cursors, it is faster to in-line the logic. */ + if int64((*TMem)(unsafe.Pointer(pMem)).FszMalloc) < nByte { + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc > 0 { + _sqlite3DbFreeNN(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } + v1 = _sqlite3DbMallocRaw(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, libc.Uint64FromInt64(nByte)) + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = v1 + (*TMem)(unsafe.Pointer(pMem)).Fz = v1 + if (*TMem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) { + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = 0 + return uintptr(0) + } + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = int32(nByte) + } + v1 = (*TMem)(unsafe.Pointer(pMem)).FzMalloc + pCx = v1 + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) = v1 + libc.Xmemset(tls, pCx, 0, uint64(libc.UintptrFromInt32(0)+40)) + (*TVdbeCursor)(unsafe.Pointer(pCx)).FeCurType = eCurType + (*TVdbeCursor)(unsafe.Pointer(pCx)).FnField = int16(nField) + (*TVdbeCursor)(unsafe.Pointer(pCx)).FaOffset = pCx + 120 + uintptr(nField)*4 + if libc.Int32FromUint8(eCurType) == CURTYPE_BTREE { + *(*uintptr)(unsafe.Pointer(pCx + 48)) = (*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((uint64(libc.UintptrFromInt32(0)+120)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32(nField+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + _sqlite3BtreeCursorZero(tls, *(*uintptr)(unsafe.Pointer(pCx + 48))) + } + return pCx +} + +// C documentation +// +// /* +// ** Make sure pBt->pTmpSpace points to an allocation of +// ** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child +// ** pointer. +// */ +func _allocateTempSpace(tls *libc.TLS, pBt uintptr) (r int32) { + var pCur uintptr + _ = pCur + /* This routine is called only by btreeCursor() when allocating the + ** first write cursor for the BtShared object */ + (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace = _sqlite3PageMalloc(tls, libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FpageSize)) + if (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace == uintptr(0) { + pCur = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor + (*TBtShared)(unsafe.Pointer(pBt)).FpCursor = (*TBtCursor)(unsafe.Pointer(pCur)).FpNext /* Unlink the cursor */ + libc.Xmemset(tls, pCur, 0, uint64(296)) + return int32(SQLITE_NOMEM) + } + /* One of the uses of pBt->pTmpSpace is to format cells before + ** inserting them into a leaf page (function fillInCell()). If + ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes + ** by the various routines that manipulate binary cells. Which + ** can mean that fillInCell() only initializes the first 2 or 3 + ** bytes of pTmpSpace, but that the first 4 bytes are copied from + ** it into a database page. This is not actually a problem, but it + ** does cause a valgrind error when the 1 or 2 bytes of uninitialized + ** data is passed to system call write(). So to avoid this error, + ** zero the first 4 bytes of temp space here. + ** + ** Also: Provide four bytes of initialized space before the + ** beginning of pTmpSpace as an area available to prepend the + ** left-child pointer to the beginning of a cell. + */ + libc.Xmemset(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace, 0, uint64(8)) + **(**uintptr)(__ccgo_up(pBt + 136)) += uintptr(4) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Parameter zSrcData points to a buffer containing the data for +// ** page iSrcPg from the source database. Copy this data into the +// ** destination database. +// */ +func _backupOnePage(tls *libc.TLS, p uintptr, iSrcPg TPgno, zSrcData uintptr, bUpdate int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDest TPgno + var iEnd, iOff Ti64 + var nCopy, nDestPgsz, nSrcPgsz, rc, v1, v3 int32 + var pDestPager, zDestData, zIn, zOut uintptr + var v5 bool + var _ /* pDestPg at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iDest, iEnd, iOff, nCopy, nDestPgsz, nSrcPgsz, pDestPager, rc, zDestData, zIn, zOut, v1, v3, v5 + pDestPager = _sqlite3BtreePager(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest) + nSrcPgsz = _sqlite3BtreeGetPageSize(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc) + nDestPgsz = _sqlite3BtreeGetPageSize(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest) + if nSrcPgsz < nDestPgsz { + v1 = nSrcPgsz + } else { + v1 = nDestPgsz + } + nCopy = v1 + iEnd = libc.Int64FromUint32(iSrcPg) * int64(nSrcPgsz) + rc = SQLITE_OK + /* This loop runs once for each destination page spanned by the source + ** page. For each iteration, variable iOff is set to the byte offset + ** of the destination page. + */ + iOff = iEnd - int64(nSrcPgsz) + for { + if !(rc == SQLITE_OK && iOff < iEnd) { + break + } + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + iDest = libc.Uint32FromInt64(iOff/int64(nDestPgsz)) + uint32(1) + if iDest == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize+libc.Uint32FromInt32(1) { + goto _2 + } + v1 = _sqlite3PagerGet(tls, pDestPager, iDest, bp, 0) + rc = v1 + if v5 = SQLITE_OK == v1; v5 { + v3 = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp))) + rc = v3 + } + if v5 && SQLITE_OK == v3 { + zIn = zSrcData + uintptr(iOff%int64(nSrcPgsz)) + zDestData = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + zOut = zDestData + uintptr(iOff%int64(nDestPgsz)) + /* Copy the data from the source page into the destination page. + ** Then clear the Btree layer MemPage.isInit flag. Both this module + ** and the pager code use this trick (clearing the first byte + ** of the page 'extra' space to invalidate the Btree layers + ** cached parse of the page). MemPage.isInit is marked + ** "MUST BE FIRST" for this purpose. + */ + libc.Xmemcpy(tls, zOut, zIn, libc.Uint64FromInt32(nCopy)) + **(**Tu8)(__ccgo_up(_sqlite3PagerGetExtra(tls, **(**uintptr)(__ccgo_up(bp))))) = uint8(0) + if iOff == 0 && bUpdate == 0 { + _sqlite3Put4byte(tls, zOut+28, _sqlite3BtreeLastPage(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc)) + } + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + goto _2 + _2: + ; + iOff = iOff + int64(nDestPgsz) + } + return rc +} + +// C documentation +// +// /* +// ** This function is called when the root page of a b-tree structure is +// ** overfull (has one or more overflow pages). +// ** +// ** A new child page is allocated and the contents of the current root +// ** page, including overflow cells, are copied into the child. The root +// ** page is then overwritten to make it an empty page with the right-child +// ** pointer pointing to the new page. +// ** +// ** Before returning, all pointer-map entries corresponding to pages +// ** that the new child-page now contains pointers to are updated. The +// ** entry corresponding to the new right-child pointer of the root +// ** page is also updated. +// ** +// ** If successful, *ppChild is set to contain a reference to the child +// ** page and SQLITE_OK is returned. In this case the caller is required +// ** to call releasePage() on *ppChild exactly once. If an error occurs, +// ** an error code is returned and *ppChild is set to 0. +// */ +func _balance_deeper(tls *libc.TLS, pRoot uintptr, ppChild uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pBt uintptr + var _ /* pChild at bp+8 */ uintptr + var _ /* pgnoChild at bp+16 */ TPgno + var _ /* rc at bp+0 */ int32 + _ = pBt /* Return value from subprocedures */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Pointer to a new child page */ + **(**TPgno)(__ccgo_up(bp + 16)) = uint32(0) /* Page number of the new child page */ + pBt = (*TMemPage)(unsafe.Pointer(pRoot)).FpBt /* The BTree */ + /* Make pRoot, the root page of the b-tree, writable. Allocate a new + ** page that will become the new right-child of pPage. Copy the contents + ** of the node stored on pRoot into the new child page. + */ + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pRoot)).FpDbPage) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _allocateBtreePage(tls, pBt, bp+8, bp+16, (*TMemPage)(unsafe.Pointer(pRoot)).Fpgno, uint8(0)) + _copyNodeContent(tls, pRoot, **(**uintptr)(__ccgo_up(bp + 8)), bp) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _ptrmapPut(tls, pBt, **(**TPgno)(__ccgo_up(bp + 16)), uint8(PTRMAP_BTREE), (*TMemPage)(unsafe.Pointer(pRoot)).Fpgno, bp) + } + } + if **(**int32)(__ccgo_up(bp)) != 0 { + **(**uintptr)(__ccgo_up(ppChild)) = uintptr(0) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return **(**int32)(__ccgo_up(bp)) + } + /* Copy the overflow cells from pRoot to pChild */ + libc.Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp + 8))+28, pRoot+28, uint64((*TMemPage)(unsafe.Pointer(pRoot)).FnOverflow)*uint64(2)) + libc.Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp + 8))+40, pRoot+40, uint64((*TMemPage)(unsafe.Pointer(pRoot)).FnOverflow)*uint64(8)) + (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FnOverflow = (*TMemPage)(unsafe.Pointer(pRoot)).FnOverflow + /* Zero the contents of pRoot. Then install pChild as the right-child. */ + _zeroPage(tls, pRoot, libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData))) & ^libc.Int32FromInt32(PTF_LEAF)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pRoot)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pRoot)).FhdrOffset)+int32(8)), **(**TPgno)(__ccgo_up(bp + 16))) + **(**uintptr)(__ccgo_up(ppChild)) = **(**uintptr)(__ccgo_up(bp + 8)) + return SQLITE_OK +} + +// C documentation +// +// /* Overwrite content from pX into pDest. Only do the write if the +// ** content is different from what is already there. +// */ +func _btreeOverwriteContent(tls *libc.TLS, pPage uintptr, pDest uintptr, pX uintptr, iOffset int32, iAmt int32) (r int32) { + var i, nData, rc, rc1, rc2 int32 + _, _, _, _, _ = i, nData, rc, rc1, rc2 + nData = (*TBtreePayload)(unsafe.Pointer(pX)).FnData - iOffset + if nData <= 0 { + i = 0 + for { + if !(i < iAmt && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pDest + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i < iAmt { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if rc != 0 { + return rc + } + libc.Xmemset(tls, pDest+uintptr(i), 0, libc.Uint64FromInt32(iAmt-i)) + } + } else { + if nData < iAmt { + /* Mixed read data and zeros at the end. Make a recursive call + ** to write the zeros then fall through to write the real data */ + rc1 = _btreeOverwriteContent(tls, pPage, pDest+uintptr(nData), pX, iOffset+nData, iAmt-nData) + if rc1 != 0 { + return rc1 + } + iAmt = nData + } + if libc.Xmemcmp(tls, pDest, (*TBtreePayload)(unsafe.Pointer(pX)).FpData+uintptr(iOffset), libc.Uint64FromInt32(iAmt)) != 0 { + rc2 = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if rc2 != 0 { + return rc2 + } + /* In a corrupt database, it is possible for the source and destination + ** buffers to overlap. This is harmless since the database is already + ** corrupt but it does cause valgrind and ASAN warnings. So use + ** memmove(). */ + libc.Xmemmove(tls, pDest, (*TBtreePayload)(unsafe.Pointer(pX)).FpData+uintptr(iOffset), libc.Uint64FromInt32(iAmt)) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This procedure generates VDBE code for a single invocation of either the +// ** sqlite_detach() or sqlite_attach() SQL user functions. +// */ +func _codeAttach(tls *libc.TLS, pParse uintptr, type1 int32, pFunc uintptr, pAuthArg uintptr, pFilename uintptr, pDbname uintptr, pKey uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, v, zAuthArg uintptr + var rc, regArgs int32 + var _ /* sName at bp+0 */ TNameContext + _, _, _, _, _ = db, rc, regArgs, v, zAuthArg + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto attach_end + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto attach_end + } + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + if SQLITE_OK != _resolveAttachExpr(tls, bp, pFilename) || SQLITE_OK != _resolveAttachExpr(tls, bp, pDbname) || SQLITE_OK != _resolveAttachExpr(tls, bp, pKey) { + goto attach_end + } + if pAuthArg != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pAuthArg)).Fop) == int32(TK_STRING) { + zAuthArg = *(*uintptr)(unsafe.Pointer(pAuthArg + 8)) + } else { + zAuthArg = uintptr(0) + } + rc = _sqlite3AuthCheck(tls, pParse, type1, zAuthArg, uintptr(0), uintptr(0)) + if rc != SQLITE_OK { + goto attach_end + } + } + v = _sqlite3GetVdbe(tls, pParse) + regArgs = _sqlite3GetTempRange(tls, pParse, int32(4)) + _sqlite3ExprCode(tls, pParse, pFilename, regArgs) + _sqlite3ExprCode(tls, pParse, pDbname, regArgs+int32(1)) + _sqlite3ExprCode(tls, pParse, pKey, regArgs+int32(2)) + if v != 0 { + _sqlite3VdbeAddFunctionCall(tls, pParse, 0, regArgs+int32(3)-int32((*TFuncDef)(unsafe.Pointer(pFunc)).FnArg), regArgs+int32(3), int32((*TFuncDef)(unsafe.Pointer(pFunc)).FnArg), pFunc, 0) + /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this + ** statement only). For DETACH, set it to false (expire all existing + ** statements). + */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_Expire), libc.BoolInt32(type1 == int32(SQLITE_ATTACH))) + } + goto attach_end +attach_end: + ; + _sqlite3ExprDelete(tls, db, pFilename) + _sqlite3ExprDelete(tls, db, pDbname) + _sqlite3ExprDelete(tls, db, pKey) +} + +// C documentation +// +// /* +// ** Detect compound SELECT statements that use an ORDER BY clause with +// ** an alternative collating sequence. +// ** +// ** SELECT ... FROM t1 EXCEPT SELECT ... FROM t2 ORDER BY .. COLLATE ... +// ** +// ** These are rewritten as a subquery: +// ** +// ** SELECT * FROM (SELECT ... FROM t1 EXCEPT SELECT ... FROM t2) +// ** ORDER BY ... COLLATE ... +// ** +// ** This transformation is necessary because the multiSelectByMerge() routine +// ** above that generates the code for a compound SELECT with an ORDER BY clause +// ** uses a merge algorithm that requires the same collating sequence on the +// ** result columns as on the ORDER BY clause. See ticket +// ** http://sqlite.org/src/info/6709574d2a +// ** +// ** This transformation is only needed for EXCEPT, INTERSECT, and UNION. +// ** The UNION ALL operator works fine with multiSelectByMerge() even when +// ** there are COLLATE terms in the ORDER BY. +// */ +func _convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, db, pNew, pNewSrc, pParse, pX uintptr + var i int32 + var _ /* dummy at bp+0 */ TToken + _, _, _, _, _, _, _ = a, db, i, pNew, pNewSrc, pParse, pX + if (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) { + return WRC_Continue + } + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy == uintptr(0) { + return WRC_Continue + } + pX = p + for { + if !(pX != 0 && (libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pX)).Fop) == int32(TK_ALL) || libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pX)).Fop) == int32(TK_SELECT))) { + break + } + goto _1 + _1: + ; + pX = (*TSelect)(unsafe.Pointer(pX)).FpPrior + } + if pX == uintptr(0) { + return WRC_Continue + } + a = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + 8 + /* If iOrderByCol is already non-zero, then it has already been matched + ** to a result column of the SELECT statement. This occurs when the + ** SELECT is rewritten for window-functions processing and then passed + ** to sqlite3SelectPrep() and similar a second time. The rewriting done + ** by this function is not required in this case. */ + if *(*Tu16)(unsafe.Pointer(a + 24)) != 0 { + return WRC_Continue + } + i = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr - int32(1) + for { + if !(i >= 0) { + break + } + if (*TExpr)(unsafe.Pointer((**(**TExprList_item)(__ccgo_up(a + uintptr(i)*32))).FpExpr)).Fflags&uint32(EP_Collate) != 0 { + break + } + goto _2 + _2: + ; + i = i - 1 + } + if i < 0 { + return WRC_Continue + } + /* If we reach this point, that means the transformation is required. */ + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pNew = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pNew == uintptr(0) { + return int32(WRC_Abort) + } + libc.Xmemset(tls, bp, 0, uint64(16)) + pNewSrc = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp, pNew, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + _sqlite3SrcListDelete(tls, db, pNewSrc) + return int32(WRC_Abort) + } + **(**TSelect)(__ccgo_up(pNew)) = **(**TSelect)(__ccgo_up(p)) + (*TSelect)(unsafe.Pointer(p)).FpSrc = pNewSrc + (*TSelect)(unsafe.Pointer(p)).FpEList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3Expr(tls, db, int32(TK_ASTERISK), uintptr(0))) + (*TSelect)(unsafe.Pointer(p)).Fop = uint8(TK_SELECT) + (*TSelect)(unsafe.Pointer(p)).FpWhere = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpGroupBy = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpHaving = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpOrderBy = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpNext = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpWith = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpWinDefn = uintptr(0) + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(SF_Compound) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_Converted) + (*TSelect)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pNew)).FpPrior)).FpNext = pNew + (*TSelect)(unsafe.Pointer(pNew)).FpLimit = uintptr(0) + return WRC_Continue +} + +// C documentation +// +// /* +// ** This function is used to copy the contents of the b-tree node stored +// ** on page pFrom to page pTo. If page pFrom was not a leaf page, then +// ** the pointer-map entries for each child page are updated so that the +// ** parent page stored in the pointer map is page pTo. If pFrom contained +// ** any cells with overflow page pointers, then the corresponding pointer +// ** map entries are also updated so that the parent page is page pTo. +// ** +// ** If pFrom is currently carrying any overflow cells (entries in the +// ** MemPage.apOvfl[] array), they are not copied to pTo. +// ** +// ** Before returning, page pTo is reinitialized using btreeInitPage(). +// ** +// ** The performance of this function is not critical. It is only used by +// ** the balance_shallower() and balance_deeper() procedures, neither of +// ** which are called often under normal circumstances. +// */ +func _copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) { + var aFrom, aTo, pBt uintptr + var iData, iFromHdr, iToHdr, rc, v1 int32 + _, _, _, _, _, _, _, _ = aFrom, aTo, iData, iFromHdr, iToHdr, pBt, rc, v1 + if **(**int32)(__ccgo_up(pRC)) == SQLITE_OK { + pBt = (*TMemPage)(unsafe.Pointer(pFrom)).FpBt + aFrom = (*TMemPage)(unsafe.Pointer(pFrom)).FaData + aTo = (*TMemPage)(unsafe.Pointer(pTo)).FaData + iFromHdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pFrom)).FhdrOffset) + if (*TMemPage)(unsafe.Pointer(pTo)).Fpgno == uint32(1) { + v1 = int32(100) + } else { + v1 = 0 + } + iToHdr = v1 + /* Copy the b-tree node content from page pFrom to page pTo. */ + iData = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aFrom + uintptr(iFromHdr+int32(5)))))<z element. +// */ +func _createAggContext(tls *libc.TLS, p uintptr, nByte int32) (r uintptr) { + var pMem uintptr + _ = pMem + pMem = (*Tsqlite3_context)(unsafe.Pointer(p)).FpMem + if nByte <= 0 { + _sqlite3VdbeMemSetNull(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = uintptr(0) + } else { + _sqlite3VdbeMemClearAndResize(tls, pMem, nByte) + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Agg) + *(*uintptr)(unsafe.Pointer(pMem)) = (*Tsqlite3_context)(unsafe.Pointer(p)).FpFunc + if (*TMem)(unsafe.Pointer(pMem)).Fz != 0 { + libc.Xmemset(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, 0, libc.Uint64FromInt32(nByte)) + } + } + return (*TMem)(unsafe.Pointer(pMem)).Fz +} + +func _dbReallocFinish(tls *libc.TLS, db uintptr, p uintptr, n Tu64) (r uintptr) { + var pNew uintptr + _ = pNew + pNew = uintptr(0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + if _isLookaside(tls, db, p) != 0 { + pNew = _sqlite3DbMallocRawNN(tls, db, n) + if pNew != 0 { + libc.Xmemcpy(tls, pNew, p, libc.Uint64FromInt32(_lookasideMallocSize(tls, db, p))) + _sqlite3DbFree(tls, db, p) + } + } else { + pNew = _sqlite3Realloc(tls, p, n) + if !(pNew != 0) { + _sqlite3OomFault(tls, db) + } + } + } + return pNew +} + +// C documentation +// +// /* +// ** Defragment the page given. This routine reorganizes cells within the +// ** page so that there are no free-blocks on the free-block list. +// ** +// ** Parameter nMaxFrag is the maximum amount of fragmented space that may be +// ** present in the page after this routine returns. +// ** +// ** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a +// ** b-tree page so that there are no freeblocks or fragment bytes, all +// ** unused bytes are contained in the unallocated space region, and all +// ** cells are packed tightly at the end of the page. +// */ +func _defragmentPage(tls *libc.TLS, pPage uintptr, nMaxFrag int32) (r int32) { + var cbrk, cellOffset, hdr, i, iCellFirst, iCellLast, iCellStart, iFree, iFree2, nCell, pc, size, sz, sz2, top, usableSize int32 + var data, pAddr, pAddr1, pEnd, src, temp uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cbrk, cellOffset, data, hdr, i, iCellFirst, iCellLast, iCellStart, iFree, iFree2, nCell, pAddr, pAddr1, pEnd, pc, size, src, sz, sz2, temp, top, usableSize /* First cell offset in input */ + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) + cellOffset = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FcellOffset) + nCell = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) + iCellFirst = cellOffset + int32(2)*nCell + usableSize = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) + /* This block handles pages with two or fewer free blocks and nMaxFrag + ** or fewer fragmented bytes. In this case it is faster to move the + ** two (or one) blocks of cells using memmove() and add the required + ** offsets to each pointer in the cell-pointer array than it is to + ** reconstruct the entire page. */ + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7))))) <= nMaxFrag { + iFree = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(hdr+int32(1)))))< usableSize-int32(4) { + return _sqlite3CorruptError(tls, int32(74790)) + } + if iFree != 0 { + iFree2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree))))< usableSize-int32(4) { + return _sqlite3CorruptError(tls, int32(74793)) + } + if 0 == iFree2 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree2)))) == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree2+int32(1))))) == 0 { + pEnd = data + uintptr(cellOffset+nCell*int32(2)) + sz2 = 0 + sz = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree+int32(2)))))<= iFree { + return _sqlite3CorruptError(tls, int32(74801)) + } + if iFree2 != 0 { + if iFree+sz > iFree2 { + return _sqlite3CorruptError(tls, int32(74804)) + } + sz2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFree2+int32(2)))))< usableSize { + return _sqlite3CorruptError(tls, int32(74806)) + } + libc.Xmemmove(tls, data+uintptr(iFree+sz+sz2), data+uintptr(iFree+sz), libc.Uint64FromInt32(iFree2-(iFree+sz))) + sz = sz + sz2 + } else { + if iFree+sz > usableSize { + return _sqlite3CorruptError(tls, int32(74810)) + } + } + cbrk = top + sz + libc.Xmemmove(tls, data+uintptr(cbrk), data+uintptr(top), libc.Uint64FromInt32(iFree-top)) + pAddr = data + uintptr(cellOffset) + for { + if !(pAddr < pEnd) { + break + } + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pAddr)))<> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pAddr + 1)) = libc.Uint8FromInt32(pc + sz) + } else { + if pc < iFree2 { + **(**Tu8)(__ccgo_up(pAddr)) = libc.Uint8FromInt32((pc + sz2) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pAddr + 1)) = libc.Uint8FromInt32(pc + sz2) + } + } + goto _1 + _1: + ; + pAddr = pAddr + uintptr(2) + } + goto defragment_out + } + } + } + cbrk = usableSize + iCellLast = usableSize - int32(4) + iCellStart = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)))))< 0 { + temp = _sqlite3PagerTempSpace(tls, (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FpPager) + libc.Xmemcpy(tls, temp, data, libc.Uint64FromInt32(usableSize)) + src = temp + i = 0 + for { + if !(i < nCell) { + break + } /* The i-th cell pointer */ + pAddr1 = data + uintptr(cellOffset+i*int32(2)) + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pAddr1)))< iCellLast { + return _sqlite3CorruptError(tls, int32(74843)) + } + size = libc.Int32FromUint16((*(*func(*libc.TLS, uintptr, uintptr) Tu16)(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize})))(tls, pPage, src+uintptr(pc))) + cbrk = cbrk - size + if cbrk < iCellStart || pc+size > usableSize { + return _sqlite3CorruptError(tls, int32(74849)) + } + **(**Tu8)(__ccgo_up(pAddr1)) = libc.Uint8FromInt32(cbrk >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pAddr1 + 1)) = libc.Uint8FromInt32(cbrk) + libc.Xmemcpy(tls, data+uintptr(cbrk), src+uintptr(pc), libc.Uint64FromInt32(size)) + goto _2 + _2: + ; + i = i + 1 + } + } + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7)))) = uint8(0) + goto defragment_out +defragment_out: + ; + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(hdr+int32(7)))))+cbrk-iCellFirst != (*TMemPage)(unsafe.Pointer(pPage)).FnFree { + return _sqlite3CorruptError(tls, int32(74863)) + } + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)))) = libc.Uint8FromInt32(cbrk >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(5)) + 1)) = libc.Uint8FromInt32(cbrk) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(1)))) = uint8(0) + **(**uint8)(__ccgo_up(data + uintptr(hdr+int32(2)))) = uint8(0) + libc.Xmemset(tls, data+uintptr(iCellFirst), 0, libc.Uint64FromInt32(cbrk-iCellFirst)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Remove the i-th cell from pPage. This routine effects pPage only. +// ** The cell content is not freed or deallocated. It is assumed that +// ** the cell content has been copied someplace else. This routine just +// ** removes the reference to the cell from pPage. +// ** +// ** "sz" must be the number of bytes in the cell. +// */ +func _dropCell(tls *libc.TLS, pPage uintptr, idx int32, sz int32, pRC uintptr) { + var data, ptr uintptr + var hdr, rc int32 + var pc Tu32 + _, _, _, _, _ = data, hdr, pc, ptr, rc /* Beginning of the header. 0 most pages. 100 page 1 */ + if **(**int32)(__ccgo_up(pRC)) != 0 { + return + } + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + ptr = (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(int32(2)*idx) + pc = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(ptr)))< (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize { + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(80423)) + return + } + rc = _freeSpace(tls, pPage, libc.Int32FromUint32(pc), sz) + if rc != 0 { + **(**int32)(__ccgo_up(pRC)) = rc + return + } + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = (*TMemPage)(unsafe.Pointer(pPage)).FnCell - 1 + if libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) == 0 { + libc.Xmemset(tls, data+uintptr(hdr+int32(1)), 0, uint64(4)) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(7)))) = uint8(0) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(5)))) = uint8((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(5)) + 1)) = uint8((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) + (*TMemPage)(unsafe.Pointer(pPage)).FnFree = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize - uint32((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) - uint32((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) - uint32(8)) + } else { + libc.Xmemmove(tls, ptr, ptr+uintptr(2), libc.Uint64FromInt32(int32(2)*(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell)-idx))) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(3)))) = libc.Uint8FromInt32(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(3)) + 1)) = uint8((*TMemPage)(unsafe.Pointer(pPage)).FnCell) + **(**int32)(__ccgo_up(pPage + 20)) += int32(2) + } +} + +// C documentation +// +// /* +// ** pCArray contains pointers to and sizes of all cells in the page being +// ** balanced. The current page, pPg, has pPg->nCell cells starting with +// ** pCArray->apCell[iOld]. After balancing, this page should hold nNew cells +// ** starting at apCell[iNew]. +// ** +// ** This routine makes the necessary adjustments to pPg so that it contains +// ** the correct cells after being balanced. +// ** +// ** The pPg->nFree field is invalid when this function returns. It is the +// ** responsibility of the caller to set it correctly. +// */ +func _editPage(tls *libc.TLS, pPg uintptr, iOld int32, iNew int32, nNew int32, pCArray uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aData, pBegin, pCellptr uintptr + var hdr, i, iCell, iNewEnd, iOldEnd, nAdd, nCell, nShift, nTail, v1 int32 + var _ /* pData at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, hdr, i, iCell, iNewEnd, iOldEnd, nAdd, nCell, nShift, nTail, pBegin, pCellptr, v1 + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FhdrOffset) + pBegin = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(nNew*int32(2)) + nCell = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPg)).FnCell) + iOldEnd = iOld + libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPg)).FnCell) + libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FnOverflow) + iNewEnd = iNew + nNew + /* Remove cells from the start and end of the page */ + if iOld < iNew { + nShift = _pageFreeArray(tls, pPg, iOld, iNew-iOld, pCArray) + if nShift > nCell { + return _sqlite3CorruptError(tls, int32(81033)) + } + libc.Xmemmove(tls, (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx, (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx+uintptr(nShift*int32(2)), libc.Uint64FromInt32(nCell*int32(2))) + nCell = nCell - nShift + } + if iNewEnd < iOldEnd { + nTail = _pageFreeArray(tls, pPg, iNewEnd, iOldEnd-iNewEnd, pCArray) + nCell = nCell - nTail + } + **(**uintptr)(__ccgo_up(bp)) = aData + uintptr(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)))))< (*TMemPage)(unsafe.Pointer(pPg)).FaDataEnd { + goto editpage_fail + } + /* Add cells to the start of the page */ + if iNew < iOld { + if nNew < iOld-iNew { + v1 = nNew + } else { + v1 = iOld - iNew + } + nAdd = v1 + pCellptr = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + libc.Xmemmove(tls, pCellptr+uintptr(nAdd*int32(2)), pCellptr, libc.Uint64FromInt32(nCell*int32(2))) + if _pageInsertArray(tls, pPg, pBegin, bp, pCellptr, iNew, nAdd, pCArray) != 0 { + goto editpage_fail + } + nCell = nCell + nAdd + } + /* Add any overflow cells */ + i = 0 + for { + if !(i < libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FnOverflow)) { + break + } + iCell = iOld + libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pPg + 28 + uintptr(i)*2))) - iNew + if iCell >= 0 && iCell < nNew { + pCellptr = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(iCell*int32(2)) + if nCell > iCell { + libc.Xmemmove(tls, pCellptr+2, pCellptr, libc.Uint64FromInt32((nCell-iCell)*int32(2))) + } + nCell = nCell + 1 + _cachedCellSize(tls, pCArray, iCell+iNew) + if _pageInsertArray(tls, pPg, pBegin, bp, pCellptr, iCell+iNew, int32(1), pCArray) != 0 { + goto editpage_fail + } + } + goto _2 + _2: + ; + i = i + 1 + } + /* Append cells to the end of the page */ + pCellptr = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(nCell*int32(2)) + if _pageInsertArray(tls, pPg, pBegin, bp, pCellptr, iNew+nCell, nNew-nCell, pCArray) != 0 { + goto editpage_fail + } + (*TMemPage)(unsafe.Pointer(pPg)).FnCell = libc.Uint16FromInt32(nNew) + (*TMemPage)(unsafe.Pointer(pPg)).FnOverflow = uint8(0) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(3)))) = libc.Uint8FromInt32(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPg)).FnCell) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(3)) + 1)) = uint8((*TMemPage)(unsafe.Pointer(pPg)).FnCell) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)))) = libc.Uint8FromInt64((int64(**(**uintptr)(__ccgo_up(bp))) - int64(aData)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)) + 1)) = libc.Uint8FromInt64(int64(**(**uintptr)(__ccgo_up(bp))) - int64(aData)) + return SQLITE_OK + goto editpage_fail +editpage_fail: + ; + /* Unable to edit this page. Rebuild it from scratch instead. */ + if nNew < int32(1) { + return _sqlite3CorruptError(tls, int32(81111)) + } + _populateCellCache(tls, pCArray, iNew, nNew) + return _rebuildPage(tls, pCArray, iNew, nNew, pPg) +} + +// C documentation +// +// /* +// ** The StrAccum "p" is not large enough to accept N new bytes of z[]. +// ** So enlarge if first, then do the append. +// ** +// ** This is a helper routine to sqlite3_str_append() that does special-case +// ** work (enlarging the buffer) using tail recursion, so that the +// ** sqlite3_str_append() routine can use fast calling semantics. +// */ +func _enlargeAndAppend(tls *libc.TLS, p uintptr, z uintptr, N int32) { + N = _sqlite3StrAccumEnlarge(tls, p, int64(N)) + if N > 0 { + libc.Xmemcpy(tls, (*TStrAccum)(unsafe.Pointer(p)).FzText+uintptr((*TStrAccum)(unsafe.Pointer(p)).FnChar), z, libc.Uint64FromInt32(N)) + **(**Tu32)(__ccgo_up(p + 24)) += libc.Uint32FromInt32(N) + } +} + +// C documentation +// +// /* +// ** Argument pWhere is the WHERE clause belonging to SELECT statement p. This +// ** function attempts to transform expressions of the form: +// ** +// ** EXISTS (SELECT ...) +// ** +// ** into joins. For example, given +// ** +// ** CREATE TABLE sailors(sid INTEGER PRIMARY KEY, name TEXT); +// ** CREATE TABLE reserves(sid INT, day DATE, PRIMARY KEY(sid, day)); +// ** +// ** SELECT name FROM sailors AS S WHERE EXISTS ( +// ** SELECT * FROM reserves AS R WHERE S.sid = R.sid AND R.day = '2022-10-25' +// ** ); +// ** +// ** the SELECT statement may be transformed as follows: +// ** +// ** SELECT name FROM sailors AS S, reserves AS R +// ** WHERE S.sid = R.sid AND R.day = '2022-10-25'; +// ** +// ** **Approximately**. Really, we have to ensure that the FROM-clause term +// ** that was formerly inside the EXISTS is only executed once. This is handled +// ** by setting the SrcItem.fg.fromExists flag, which then causes code in +// ** the where.c file to exit the corresponding loop after the first successful +// ** match (if any). +// */ +func _existsToJoin(tls *libc.TLS, pParse uintptr, p uintptr, pWhere uintptr) { + var aCsrMap, db, pRight, pSub, pSubWhere uintptr + _, _, _, _, _ = aCsrMap, db, pRight, pSub, pSubWhere + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && pWhere != uintptr(0) && !((*TExpr)(unsafe.Pointer(pWhere)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != libc.Uint32FromInt32(0)) && (*TSelect)(unsafe.Pointer(p)).FpSrc != uintptr(0) && (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) && ((*TSelect)(unsafe.Pointer(p)).FpLimit == uintptr(0) || (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpLimit)).FpRight == uintptr(0)) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pWhere)).Fop) == int32(TK_AND) { + pRight = (*TExpr)(unsafe.Pointer(pWhere)).FpRight + _existsToJoin(tls, pParse, p, (*TExpr)(unsafe.Pointer(pWhere)).FpLeft) + _existsToJoin(tls, pParse, p, pRight) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pWhere)).Fop) == int32(TK_EXISTS) { + pSub = *(*uintptr)(unsafe.Pointer(pWhere + 32)) + pSubWhere = (*TSelect)(unsafe.Pointer(pSub)).FpWhere + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpSrc)).FnSrc == int32(1) && (*TSelect)(unsafe.Pointer(pSub)).FselFlags&uint32(SF_Aggregate) == uint32(0) && !(int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpSrc + 8 + 24 + 4))&0x4>>2) != 0) && (*TSelect)(unsafe.Pointer(pSub)).FpLimit == uintptr(0) && (*TSelect)(unsafe.Pointer(pSub)).FpPrior == uintptr(0) { + /* Before combining the sub-select with the parent, renumber the + ** cursor used by the subselect. This is because the EXISTS expression + ** might be a copy of another EXISTS expression from somewhere + ** else in the tree, and in this case it is important that it use + ** a unique cursor number. */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + aCsrMap = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt32((*TParse)(unsafe.Pointer(pParse)).FnTab+libc.Int32FromInt32(2))*uint64(4))) + if aCsrMap == uintptr(0) { + return + } + **(**int32)(__ccgo_up(aCsrMap)) = (*TParse)(unsafe.Pointer(pParse)).FnTab + int32(1) + _renumberCursors(tls, pParse, pSub, -int32(1), aCsrMap) + _sqlite3DbFree(tls, db, aCsrMap) + libc.Xmemset(tls, pWhere, 0, uint64(72)) + (*TExpr)(unsafe.Pointer(pWhere)).Fop = uint8(TK_INTEGER) + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pWhere)).Fu)) = int32(1) + **(**Tu32)(__ccgo_up(pWhere + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) + libc.SetBitFieldPtr32Uint32((*TSelect)(unsafe.Pointer(pSub)).FpSrc+8+24+4, libc.Uint32FromInt32(1), 18, 0x40000) + (*TSelect)(unsafe.Pointer(p)).FpSrc = _sqlite3SrcListAppendList(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpSrc, (*TSelect)(unsafe.Pointer(pSub)).FpSrc) + if pSubWhere != 0 { + (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3PExpr(tls, pParse, int32(TK_AND), (*TSelect)(unsafe.Pointer(p)).FpWhere, pSubWhere) + (*TSelect)(unsafe.Pointer(pSub)).FpWhere = uintptr(0) + } + (*TSelect)(unsafe.Pointer(pSub)).FpSrc = uintptr(0) + _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3SelectDeleteGeneric), pSub) + } + } + } + } +} + +// C documentation +// +// /* +// ** Generate code for a BETWEEN operator. +// ** +// ** x BETWEEN y AND z +// ** +// ** The above is equivalent to +// ** +// ** x>=y AND x<=z +// ** +// ** Code it as such, taking care to do the common subexpression +// ** elimination of x. +// ** +// ** The xJumpIf parameter determines details: +// ** +// ** NULL: Store the boolean result in reg[dest] +// ** sqlite3ExprIfTrue: Jump to dest if true +// ** sqlite3ExprIfFalse: Jump to dest if false +// ** +// ** The jumpIfNull parameter is ignored if xJumpIf is NULL. +// */ +func _exprCodeBetween(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, __ccgo_fp_xJump uintptr, jumpIfNull int32) { + bp := tls.Alloc(224) + defer tls.Free(224) + var db, pDel uintptr + var _ /* compLeft at bp+72 */ TExpr + var _ /* compRight at bp+144 */ TExpr + var _ /* exprAnd at bp+0 */ TExpr + var _ /* regFree1 at bp+216 */ int32 + _, _ = db, pDel /* The x<=z term */ + **(**int32)(__ccgo_up(bp + 216)) = 0 /* Temporary use register */ + pDel = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + libc.Xmemset(tls, bp+72, 0, uint64(72)) + libc.Xmemset(tls, bp+144, 0, uint64(72)) + libc.Xmemset(tls, bp, 0, uint64(72)) + pDel = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, 0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_AND) + (**(**TExpr)(__ccgo_up(bp))).FpLeft = bp + 72 + (**(**TExpr)(__ccgo_up(bp))).FpRight = bp + 144 + (**(**TExpr)(__ccgo_up(bp + 72))).Fop = uint8(TK_GE) + (**(**TExpr)(__ccgo_up(bp + 72))).FpLeft = pDel + (**(**TExpr)(__ccgo_up(bp + 72))).FpRight = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr + (**(**TExpr)(__ccgo_up(bp + 144))).Fop = uint8(TK_LE) + (**(**TExpr)(__ccgo_up(bp + 144))).FpLeft = pDel + (**(**TExpr)(__ccgo_up(bp + 144))).FpRight = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr + _sqlite3ExprToRegister(tls, pDel, _exprCodeVector(tls, pParse, pDel, bp+216)) + if __ccgo_fp_xJump != 0 { + (*(*func(*libc.TLS, uintptr, uintptr, int32, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xJump})))(tls, pParse, bp, dest, jumpIfNull) + } else { + /* Mark the expression is being from the ON or USING clause of a join + ** so that the sqlite3ExprCodeTarget() routine will not attempt to move + ** it into the Parse.pConstExpr list. We should use a new bit for this, + ** for clarity, but we are out of bits in the Expr.flags field so we + ** have to reuse the EP_OuterON bit. Bummer. */ + **(**Tu32)(__ccgo_up(pDel + 4)) |= uint32(EP_OuterON) + _sqlite3ExprCodeTarget(tls, pParse, bp, dest) + } + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp + 216))) + } + _sqlite3ExprDelete(tls, db, pDel) + /* Ensure adequate test coverage */ +} + +// C documentation +// +// /* +// ** This function is similar to sqlite3ExprDup(), except that if pEdupBuf +// ** is not NULL then it points to memory that can be used to store a copy +// ** of the input Expr p together with its p->u.zToken (if any). pEdupBuf +// ** is updated with the new buffer tail prior to returning. +// */ +func _exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pEdupBuf uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nAlloc, nNewSize, nToken, v2 int32 + var nSize, staticFlag Tu32 + var nStructSize uint32 + var pNew, zToken, v1 uintptr + var _ /* sEdupBuf at bp+0 */ TEdupBuf + _, _, _, _, _, _, _, _, _, _ = nAlloc, nNewSize, nSize, nStructSize, nToken, pNew, staticFlag, zToken, v1, v2 /* EP_Static if space not obtained from malloc */ + nToken = -int32(1) /* Space needed for p->u.zToken. -1 means unknown */ + /* Figure out where to write the new Expr structure. */ + if pEdupBuf != 0 { + (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc = (*TEdupBuf)(unsafe.Pointer(pEdupBuf)).FzAlloc + staticFlag = uint32(EP_Static) + } else { + if dupFlags != 0 { + nAlloc = _dupedExprSize(tls, p) + } else { + if !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)) && *(*uintptr)(unsafe.Pointer(p + 8)) != 0 { + nToken = libc.Int32FromUint64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(p + 8)))&uint64(0x3fffffff) + uint64(1)) + nAlloc = libc.Int32FromUint64((libc.Uint64FromInt64(72) + libc.Uint64FromInt32(nToken) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + } else { + nToken = 0 + nAlloc = libc.Int32FromUint64((libc.Uint64FromInt64(72) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + } + } + (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(nAlloc)) + staticFlag = uint32(0) + } + pNew = (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc + if pNew != 0 { + /* Set nNewSize to the size allocated for the structure pointed to + ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or + ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed + ** by the copy of the p->u.zToken string (if any). + */ + nStructSize = libc.Uint32FromInt32(_dupedExprStructSize(tls, p, dupFlags)) + nNewSize = libc.Int32FromUint32(nStructSize & uint32(0xfff)) + if nToken < 0 { + if !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)) && *(*uintptr)(unsafe.Pointer(p + 8)) != 0 { + nToken = _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8))) + int32(1) + } else { + nToken = 0 + } + } + if dupFlags != 0 { + libc.Xmemcpy(tls, (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc, p, libc.Uint64FromInt32(nNewSize)) + } else { + nSize = libc.Uint32FromInt32(_exprStructSize(tls, p)) + libc.Xmemcpy(tls, (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc, p, uint64(nSize)) + if uint64(nSize) < uint64(72) { + libc.Xmemset(tls, (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc+uintptr(nSize), 0, uint64(72)-uint64(nSize)) + } + nNewSize = int32(72) + } + /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ + **(**Tu32)(__ccgo_up(pNew + 4)) &= libc.Uint32FromInt32(^(libc.Int32FromInt32(EP_Reduced) | libc.Int32FromInt32(EP_TokenOnly) | libc.Int32FromInt32(EP_Static))) + **(**Tu32)(__ccgo_up(pNew + 4)) |= nStructSize & libc.Uint32FromInt32(libc.Int32FromInt32(EP_Reduced)|libc.Int32FromInt32(EP_TokenOnly)) + **(**Tu32)(__ccgo_up(pNew + 4)) |= staticFlag + if dupFlags != 0 { + } + /* Copy the p->u.zToken string, if any. */ + if nToken > 0 { + v1 = (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc + uintptr(nNewSize) + *(*uintptr)(unsafe.Pointer(pNew + 8)) = v1 + zToken = v1 + libc.Xmemcpy(tls, zToken, *(*uintptr)(unsafe.Pointer(p + 8)), libc.Uint64FromInt32(nToken)) + nNewSize = nNewSize + nToken + } + (**(**TEdupBuf)(__ccgo_up(bp))).FzAlloc += uintptr((nNewSize + libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)) + if ((*TExpr)(unsafe.Pointer(p)).Fflags|(*TExpr)(unsafe.Pointer(pNew)).Fflags)&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) == uint32(0) { + /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + *(*uintptr)(unsafe.Pointer(pNew + 32)) = _sqlite3SelectDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 32)), dupFlags) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) != int32(TK_ORDER) { + v2 = dupFlags + } else { + v2 = 0 + } + *(*uintptr)(unsafe.Pointer(pNew + 32)) = _sqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 32)), v2) + } + if (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + *(*uintptr)(unsafe.Pointer(pNew + 64)) = _sqlite3WindowDup(tls, db, pNew, *(*uintptr)(unsafe.Pointer(p + 64))) + } + /* Fill in pNew->pLeft and pNew->pRight. */ + if dupFlags != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_SELECT_COLUMN) { + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = (*TExpr)(unsafe.Pointer(p)).FpLeft + } else { + if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 { + v1 = _exprDup(tls, db, (*TExpr)(unsafe.Pointer(p)).FpLeft, int32(EXPRDUP_REDUCE), bp) + } else { + v1 = uintptr(0) + } + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = v1 + } + if (*TExpr)(unsafe.Pointer(p)).FpRight != 0 { + v1 = _exprDup(tls, db, (*TExpr)(unsafe.Pointer(p)).FpRight, int32(EXPRDUP_REDUCE), bp) + } else { + v1 = uintptr(0) + } + (*TExpr)(unsafe.Pointer(pNew)).FpRight = v1 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_SELECT_COLUMN) { + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = (*TExpr)(unsafe.Pointer(p)).FpLeft + } else { + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(p)).FpLeft, 0) + } + (*TExpr)(unsafe.Pointer(pNew)).FpRight = _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(p)).FpRight, 0) + } + } + } + if pEdupBuf != 0 { + libc.Xmemcpy(tls, pEdupBuf, bp, uint64(8)) + } + return pNew +} + +// C documentation +// +// /* +// ** Return true if the expression contains no non-deterministic SQL +// ** functions. Do not consider non-deterministic SQL functions that are +// ** part of sub-select statements. +// */ +func _exprIsDeterministic(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(1) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprNodeIsDeterministic) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkFail) + _sqlite3WalkExpr(tls, bp, p) + return libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) +} + +// C documentation +// +// /* +// ** Create the byte sequence used to represent a cell on page pPage +// ** and write that byte sequence into pCell[]. Overflow pages are +// ** allocated and filled in as necessary. The calling procedure +// ** is responsible for making sure sufficient space has been allocated +// ** for pCell[]. +// ** +// ** Note that pCell does not necessary need to point to the pPage->aData +// ** area. pCell might point to some temporary storage. The cell will +// ** be constructed in this temporary area then copied into pPage->aData +// ** later. +// */ +func _fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType Tu8 + var mn, n, nHeader, nPayload, nSrc, spaceLeft, v1 int32 + var pBt, pPayload, pPrior, pSrc, pToRelease uintptr + var pgnoPtrmap TPgno + var _ /* pOvfl at bp+8 */ uintptr + var _ /* pgnoOvfl at bp+4 */ TPgno + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = eType, mn, n, nHeader, nPayload, nSrc, pBt, pPayload, pPrior, pSrc, pToRelease, pgnoPtrmap, spaceLeft, v1 + /* pPage is not necessarily writeable since pCell might be auxiliary + ** buffer space that is separate from the pPage buffer area */ + /* Fill in the header. */ + nHeader = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + if (*TMemPage)(unsafe.Pointer(pPage)).FintKey != 0 { + nPayload = (*TBtreePayload)(unsafe.Pointer(pX)).FnData + (*TBtreePayload)(unsafe.Pointer(pX)).FnZero + pSrc = (*TBtreePayload)(unsafe.Pointer(pX)).FpData + nSrc = (*TBtreePayload)(unsafe.Pointer(pX)).FnData + /* fillInCell() only called for leaves */ + if libc.Uint32FromInt32(nPayload) < libc.Uint32FromInt32(0x80) { + **(**uint8)(__ccgo_up(pCell + uintptr(nHeader))) = libc.Uint8FromInt32(nPayload) + v1 = libc.Int32FromInt32(1) + } else { + v1 = _sqlite3PutVarint(tls, pCell+uintptr(nHeader), libc.Uint64FromInt32(nPayload)) + } + nHeader = nHeader + libc.Int32FromUint8(libc.Uint8FromInt32(v1)) + nHeader = nHeader + _sqlite3PutVarint(tls, pCell+uintptr(nHeader), **(**Tu64)(__ccgo_up(pX + 8))) + } else { + v1 = int32((*TBtreePayload)(unsafe.Pointer(pX)).FnKey) + nPayload = v1 + nSrc = v1 + pSrc = (*TBtreePayload)(unsafe.Pointer(pX)).FpKey + if libc.Uint32FromInt32(nPayload) < libc.Uint32FromInt32(0x80) { + **(**uint8)(__ccgo_up(pCell + uintptr(nHeader))) = libc.Uint8FromInt32(nPayload) + v1 = libc.Int32FromInt32(1) + } else { + v1 = _sqlite3PutVarint(tls, pCell+uintptr(nHeader), libc.Uint64FromInt32(nPayload)) + } + nHeader = nHeader + libc.Int32FromUint8(libc.Uint8FromInt32(v1)) + } + /* Fill in the payload */ + pPayload = pCell + uintptr(nHeader) + if nPayload <= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + /* This is the common case where everything fits on the btree page + ** and no overflow pages are required. */ + n = nHeader + nPayload + if n < int32(4) { + n = int32(4) + **(**uint8)(__ccgo_up(pPayload + uintptr(nPayload))) = uint8(0) + } + **(**int32)(__ccgo_up(pnSize)) = n + libc.Xmemcpy(tls, pPayload, pSrc, libc.Uint64FromInt32(nSrc)) + libc.Xmemset(tls, pPayload+uintptr(nSrc), 0, libc.Uint64FromInt32(nPayload-nSrc)) + return SQLITE_OK + } + /* If we reach this point, it means that some of the content will need + ** to spill onto overflow pages. + */ + mn = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FminLocal) + n = libc.Int32FromUint32(libc.Uint32FromInt32(mn) + libc.Uint32FromInt32(nPayload-mn)%((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-uint32(4))) + if n > libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + n = mn + } + spaceLeft = n + **(**int32)(__ccgo_up(pnSize)) = n + nHeader + int32(4) + pPrior = pCell + uintptr(nHeader+n) + pToRelease = uintptr(0) + **(**TPgno)(__ccgo_up(bp + 4)) = uint32(0) + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt + /* At this point variables should be set as follows: + ** + ** nPayload Total payload size in bytes + ** pPayload Begin writing payload here + ** spaceLeft Space available at pPayload. If nPayload>spaceLeft, + ** that means content must spill into overflow pages. + ** *pnSize Size of the local cell (not counting overflow pages) + ** pPrior Where to write the pgno of the first overflow page + ** + ** Use a call to btreeParseCellPtr() to verify that the values above + ** were computed correctly. + */ + /* Write the payload into the local Cell and any extra into overflow pages */ + for int32(1) != 0 { + n = nPayload + if n > spaceLeft { + n = spaceLeft + } + /* If pToRelease is not zero than pPayload points into the data area + ** of pToRelease. Make sure pToRelease is still writeable. */ + /* If pPayload is part of the data area of pPage, then make sure pPage + ** is still writeable */ + if nSrc >= n { + libc.Xmemcpy(tls, pPayload, pSrc, libc.Uint64FromInt32(n)) + } else { + if nSrc > 0 { + n = nSrc + libc.Xmemcpy(tls, pPayload, pSrc, libc.Uint64FromInt32(n)) + } else { + libc.Xmemset(tls, pPayload, 0, libc.Uint64FromInt32(n)) + } + } + nPayload = nPayload - n + if nPayload <= 0 { + break + } + pPayload = pPayload + uintptr(n) + pSrc = pSrc + uintptr(n) + nSrc = nSrc - n + spaceLeft = spaceLeft - n + if spaceLeft == 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pgnoPtrmap = **(**TPgno)(__ccgo_up(bp + 4)) /* Overflow page pointer-map entry page */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + for cond := true; cond; cond = _ptrmapPageno(tls, pBt, **(**TPgno)(__ccgo_up(bp + 4))) == **(**TPgno)(__ccgo_up(bp + 4)) || **(**TPgno)(__ccgo_up(bp + 4)) == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + **(**TPgno)(__ccgo_up(bp + 4)) = **(**TPgno)(__ccgo_up(bp + 4)) + 1 + } + } + **(**int32)(__ccgo_up(bp)) = _allocateBtreePage(tls, pBt, bp+8, bp+4, **(**TPgno)(__ccgo_up(bp + 4)), uint8(0)) + /* If the database supports auto-vacuum, and the second or subsequent + ** overflow page is being allocated, add an entry to the pointer-map + ** for that page now. + ** + ** If this is the first overflow page, then write a partial entry + ** to the pointer-map. If we write nothing to this pointer-map slot, + ** then the optimistic overflow chain processing in clearCell() + ** may misinterpret the uninitialized values and delete the + ** wrong pages from the database. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if pgnoPtrmap != 0 { + v1 = int32(PTRMAP_OVERFLOW2) + } else { + v1 = int32(PTRMAP_OVERFLOW1) + } + eType = libc.Uint8FromInt32(v1) + _ptrmapPut(tls, pBt, **(**TPgno)(__ccgo_up(bp + 4)), eType, pgnoPtrmap, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + } + if **(**int32)(__ccgo_up(bp)) != 0 { + _releasePage(tls, pToRelease) + return **(**int32)(__ccgo_up(bp)) + } + /* If pToRelease is not zero than pPrior points into the data area + ** of pToRelease. Make sure pToRelease is still writeable. */ + /* If pPrior is part of the data area of pPage, then make sure pPage + ** is still writeable */ + _sqlite3Put4byte(tls, pPrior, **(**TPgno)(__ccgo_up(bp + 4))) + _releasePage(tls, pToRelease) + pToRelease = **(**uintptr)(__ccgo_up(bp + 8)) + pPrior = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData + _sqlite3Put4byte(tls, pPrior, uint32(0)) + pPayload = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData + 4 + spaceLeft = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32(4)) + } + } + _releasePage(tls, pToRelease) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Locate and return an entry from the db.aCollSeq hash table. If the entry +// ** specified by zName and nName is not found and parameter 'create' is +// ** true, then create a new entry. Otherwise return NULL. +// ** +// ** Each pointer stored in the sqlite3.aCollSeq hash table contains an +// ** array of three CollSeq structures. The first is the collation sequence +// ** preferred for UTF-8, the second UTF-16le, and the third UTF-16be. +// ** +// ** Stored immediately after the three collation sequences is a copy of +// ** the collation sequence name. A pointer to this string is stored in +// ** each collation sequence structure. +// */ +func _findCollSeqEntry(tls *libc.TLS, db uintptr, zName uintptr, create int32) (r uintptr) { + var nName int32 + var pColl, pDel uintptr + _, _, _ = nName, pColl, pDel + pColl = _sqlite3HashFind(tls, db+648, zName) + if uintptr(0) == pColl && create != 0 { + nName = _sqlite3Strlen30(tls, zName) + int32(1) + pColl = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt32(3)*libc.Uint64FromInt64(40)+libc.Uint64FromInt32(nName))) + if pColl != 0 { + pDel = uintptr(0) + (**(**TCollSeq)(__ccgo_up(pColl))).FzName = pColl + 3*40 + (**(**TCollSeq)(__ccgo_up(pColl))).Fenc = uint8(SQLITE_UTF8) + (**(**TCollSeq)(__ccgo_up(pColl + 1*40))).FzName = pColl + 3*40 + (**(**TCollSeq)(__ccgo_up(pColl + 1*40))).Fenc = uint8(SQLITE_UTF16LE) + (**(**TCollSeq)(__ccgo_up(pColl + 2*40))).FzName = pColl + 3*40 + (**(**TCollSeq)(__ccgo_up(pColl + 2*40))).Fenc = uint8(SQLITE_UTF16BE) + libc.Xmemcpy(tls, (**(**TCollSeq)(__ccgo_up(pColl))).FzName, zName, libc.Uint64FromInt32(nName)) + pDel = _sqlite3HashInsert(tls, db+648, (**(**TCollSeq)(__ccgo_up(pColl))).FzName, pColl) + /* If a malloc() failure occurred in sqlite3HashInsert(), it will + ** return the pColl pointer to be deleted (because it wasn't added + ** to the hash table). + */ + if pDel != uintptr(0) { + _sqlite3OomFault(tls, db) + _sqlite3DbFree(tls, db, pDel) + pColl = uintptr(0) + } + } + } + return pColl +} + +// C documentation +// +// /* +// ** This function is called to generate code executed when a row is deleted +// ** from the parent table of foreign key constraint pFKey and, if pFKey is +// ** deferred, when a row is inserted into the same table. When generating +// ** code for an SQL UPDATE operation, this function may be called twice - +// ** once to "delete" the old row and once to "insert" the new row. +// ** +// ** Parameter nIncr is passed -1 when inserting a row (as this may decrease +// ** the number of FK violations in the db) or +1 when deleting one (as this +// ** may increase the number of FK constraint problems). +// ** +// ** The code generated by this function scans through the rows in the child +// ** table that correspond to the parent table row being deleted or inserted. +// ** For each child row found, one of the following actions is taken: +// ** +// ** Operation | FK type | Action taken +// ** -------------------------------------------------------------------------- +// ** DELETE immediate Increment the "immediate constraint counter". +// ** +// ** INSERT immediate Decrement the "immediate constraint counter". +// ** +// ** DELETE deferred Increment the "deferred constraint counter". +// ** +// ** INSERT deferred Decrement the "deferred constraint counter". +// ** +// ** These operations are identified in the comment at the top of this file +// ** (fkey.c) as "I.2" and "D.2". +// */ +func _fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, pIdx uintptr, pFKey uintptr, aiCol uintptr, regData int32, nIncr int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pAll, pEq, pEq1, pLeft, pLeft1, pNe, pRight, pRight1, pWInfo, pWhere, v, zCol uintptr + var i, iFkIfZero, v2 int32 + var iCol, iCol1 Ti16 + var _ /* sNameContext at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iCol, iCol1, iFkIfZero, pAll, pEq, pEq1, pLeft, pLeft1, pNe, pRight, pRight1, pWInfo, pWhere, v, zCol, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Iterator variable */ + pWhere = uintptr(0) /* Context used by sqlite3WhereXXX() */ + iFkIfZero = 0 /* Address of OP_FkIfZero */ + v = _sqlite3GetVdbe(tls, pParse) + if nIncr < 0 { + iFkIfZero = _sqlite3VdbeAddOp2(tls, v, int32(OP_FkIfZero), libc.Int32FromUint8((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred), 0) + } + /* Create an Expr object representing an SQL expression like: + ** + ** = AND = ... + ** + ** The collation sequence used for the comparison should be that of + ** the parent key columns. The affinity of the parent key column should + ** be applied to each child key value before the comparison takes place. + */ + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } /* Name of column in child table */ + if pIdx != 0 { + v2 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) + } else { + v2 = -int32(1) + } + iCol = int16(v2) + pLeft = _exprTableRegister(tls, pParse, pTab, regData, iCol) + if aiCol != 0 { + v2 = **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) + } else { + v2 = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom + } + iCol = int16(v2) + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iCol)*16))).FzCnName + pRight = _sqlite3Expr(tls, db, int32(TK_ID), zCol) + pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), pLeft, pRight) + pWhere = _sqlite3ExprAnd(tls, pParse, pWhere, pEq) + goto _1 + _1: + ; + i = i + 1 + } + /* If the child table is the same as the parent table, then add terms + ** to the WHERE clause that prevent this entry from being scanned. + ** The added WHERE clause terms are like this: + ** + ** $current_rowid!=rowid + ** NOT( $current_a==a AND $current_b==b AND ... ) + ** + ** The first form is used for rowid tables. The second form is used + ** for WITHOUT ROWID tables. In the second form, the *parent* key is + ** (a,b,...). Either the parent or primary key could be used to + ** uniquely identify the current row, but the parent key is more convenient + ** as the required values have already been loaded into registers + ** by the caller. + */ + if pTab == (*TFKey)(unsafe.Pointer(pFKey)).FpFrom && nIncr > 0 { /* Column ref to child table */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + pLeft1 = _exprTableRegister(tls, pParse, pTab, regData, int16(-int32(1))) + pRight1 = _exprTableColumn(tls, db, pTab, (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FiCursor, int16(-int32(1))) + pNe = _sqlite3PExpr(tls, pParse, int32(TK_NE), pLeft1, pRight1) + } else { + pAll = uintptr(0) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + iCol1 = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)) + pLeft1 = _exprTableRegister(tls, pParse, pTab, regData, iCol1) + pRight1 = _sqlite3Expr(tls, db, int32(TK_ID), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol1)*16))).FzCnName) + pEq1 = _sqlite3PExpr(tls, pParse, int32(TK_IS), pLeft1, pRight1) + pAll = _sqlite3ExprAnd(tls, pParse, pAll, pEq1) + goto _4 + _4: + ; + i = i + 1 + } + pNe = _sqlite3PExpr(tls, pParse, int32(TK_NOT), pAll, uintptr(0)) + } + pWhere = _sqlite3ExprAnd(tls, pParse, pWhere, pNe) + } + /* Resolve the references in the WHERE clause. */ + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pSrc + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + _sqlite3ResolveExprNames(tls, bp, pWhere) + /* Create VDBE to loop through the entries in pSrc that match the WHERE + ** clause. For each row found, increment either the deferred or immediate + ** foreign key constraint counter. */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + pWInfo = _sqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint16(0), 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_FkCounter), libc.Int32FromUint8((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) + if pWInfo != 0 { + _sqlite3WhereEnd(tls, pWInfo) + } + } + /* Clean up the WHERE clause constructed above. */ + _sqlite3ExprDelete(tls, db, pWhere) + if iFkIfZero != 0 { + _sqlite3VdbeJumpHereOrPopInst(tls, v, iFkIfZero) + } +} + +// C documentation +// +// /* +// ** This routine attempts to flatten subqueries as a performance optimization. +// ** This routine returns 1 if it makes changes and 0 if no flattening occurs. +// ** +// ** To understand the concept of flattening, consider the following +// ** query: +// ** +// ** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5 +// ** +// ** The default way of implementing this query is to execute the +// ** subquery first and store the results in a temporary table, then +// ** run the outer query on that temporary table. This requires two +// ** passes over the data. Furthermore, because the temporary table +// ** has no indices, the WHERE clause on the outer query cannot be +// ** optimized. +// ** +// ** This routine attempts to rewrite queries such as the above into +// ** a single flat select, like this: +// ** +// ** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5 +// ** +// ** The code generated for this simplification gives the same result +// ** but only has to scan the data once. And because indices might +// ** exist on the table t1, a complete scan of the data might be +// ** avoided. +// ** +// ** Flattening is subject to the following constraints: +// ** +// ** (**) We no longer attempt to flatten aggregate subqueries. Was: +// ** The subquery and the outer query cannot both be aggregates. +// ** +// ** (**) We no longer attempt to flatten aggregate subqueries. Was: +// ** (2) If the subquery is an aggregate then +// ** (2a) the outer query must not be a join and +// ** (2b) the outer query must not use subqueries +// ** other than the one FROM-clause subquery that is a candidate +// ** for flattening. (This is due to ticket [2f7170d73bf9abf80] +// ** from 2015-02-09.) +// ** +// ** (3) If the subquery is the right operand of a LEFT JOIN then +// ** (3a) the subquery may not be a join +// ** (**) Was (3b): "the FROM clause of the subquery may not contain +// ** a virtual table" +// ** (**) Was: "The outer query may not have a GROUP BY." This case +// ** is now managed correctly +// ** (3d) the outer query may not be DISTINCT. +// ** See also (26) for restrictions on RIGHT JOIN. +// ** +// ** (4) The subquery can not be DISTINCT. +// ** +// ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT +// ** sub-queries that were excluded from this optimization. Restriction +// ** (4) has since been expanded to exclude all DISTINCT subqueries. +// ** +// ** (**) We no longer attempt to flatten aggregate subqueries. Was: +// ** If the subquery is aggregate, the outer query may not be DISTINCT. +// ** +// ** (7) The subquery must have a FROM clause. TODO: For subqueries without +// ** A FROM clause, consider adding a FROM clause with the special +// ** table sqlite_once that consists of a single row containing a +// ** single NULL. +// ** +// ** (8) If the subquery uses LIMIT then the outer query may not be a join. +// ** +// ** (9) If the subquery uses LIMIT then the outer query may not be aggregate. +// ** +// ** (**) Restriction (10) was removed from the code on 2005-02-05 but we +// ** accidentally carried the comment forward until 2014-09-15. Original +// ** constraint: "If the subquery is aggregate then the outer query +// ** may not use LIMIT." +// ** +// ** (11) The subquery and the outer query may not both have ORDER BY clauses. +// ** +// ** (**) Not implemented. Subsumed into restriction (3). Was previously +// ** a separate restriction deriving from ticket #350. +// ** +// ** (13) The subquery and outer query may not both use LIMIT. +// ** +// ** (14) The subquery may not use OFFSET. +// ** +// ** (15) If the outer query is part of a compound select, then the +// ** subquery may not use LIMIT. +// ** (See ticket #2339 and ticket [02a8e81d44]). +// ** +// ** (16) If the outer query is aggregate, then the subquery may not +// ** use ORDER BY. (Ticket #2942) This used to not matter +// ** until we introduced the group_concat() function. +// ** +// ** (17) If the subquery is a compound select, then +// ** (17a) all compound operators must be a UNION ALL, and +// ** (17b) no terms within the subquery compound may be aggregate +// ** or DISTINCT, and +// ** (17c) every term within the subquery compound must have a FROM clause +// ** (17d) the outer query may not be +// ** (17d1) aggregate, or +// ** (17d2) DISTINCT +// ** (17e) the subquery may not contain window functions, and +// ** (17f) the subquery must not be the RHS of a LEFT JOIN. +// ** (17g) either the subquery is the first element of the outer +// ** query or there are no RIGHT or FULL JOINs in any arm +// ** of the subquery. (This is a duplicate of condition (27b).) +// ** (17h) The corresponding result set expressions in all arms of the +// ** compound must have the same affinity. +// ** +// ** The parent and sub-query may contain WHERE clauses. Subject to +// ** rules (11), (13) and (14), they may also contain ORDER BY, +// ** LIMIT and OFFSET clauses. The subquery cannot use any compound +// ** operator other than UNION ALL because all the other compound +// ** operators have an implied DISTINCT which is disallowed by +// ** restriction (4). +// ** +// ** Also, each component of the sub-query must return the same number +// ** of result columns. This is actually a requirement for any compound +// ** SELECT statement, but all the code here does is make sure that no +// ** such (illegal) sub-query is flattened. The caller will detect the +// ** syntax error and return a detailed message. +// ** +// ** (18) If the sub-query is a compound select, then all terms of the +// ** ORDER BY clause of the parent must be copies of a term returned +// ** by the parent query. +// ** +// ** (19) If the subquery uses LIMIT then the outer query may not +// ** have a WHERE clause. +// ** +// ** (20) If the sub-query is a compound select, then it must not use +// ** an ORDER BY clause. Ticket #3773. We could relax this constraint +// ** somewhat by saying that the terms of the ORDER BY clause must +// ** appear as unmodified result columns in the outer query. But we +// ** have other optimizations in mind to deal with that case. +// ** +// ** (21) If the subquery uses LIMIT then the outer query may not be +// ** DISTINCT. (See ticket [752e1646fc]). +// ** +// ** (22) The subquery may not be a recursive CTE. +// ** +// ** (23) If the outer query is a recursive CTE, then the sub-query may not be +// ** a compound query. This restriction is because transforming the +// ** parent to a compound query confuses the code that handles +// ** recursive queries in multiSelect(). +// ** +// ** (**) We no longer attempt to flatten aggregate subqueries. Was: +// ** The subquery may not be an aggregate that uses the built-in min() or +// ** or max() functions. (Without this restriction, a query like: +// ** "SELECT x FROM (SELECT max(y), x FROM t1)" would not necessarily +// ** return the value X for which Y was maximal.) +// ** +// ** (25) If either the subquery or the parent query contains a window +// ** function in the select list or ORDER BY clause, flattening +// ** is not attempted. +// ** +// ** (26) The subquery may not be the right operand of a RIGHT JOIN. +// ** See also (3) for restrictions on LEFT JOIN. +// ** +// ** (27) The subquery may not contain a FULL or RIGHT JOIN unless it +// ** is the first element of the parent query. Two subcases: +// ** (27a) the subquery is not a compound query. +// ** (27b) the subquery is a compound query and the RIGHT JOIN occurs +// ** in any arm of the compound query. (See also (17g).) +// ** +// ** (28) The subquery is not a MATERIALIZED CTE. (This is handled +// ** in the caller before ever reaching this routine.) +// ** +// ** +// ** In this routine, the "p" parameter is a pointer to the outer query. +// ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query +// ** uses aggregates. +// ** +// ** If flattening is not attempted, this routine is a no-op and returns 0. +// ** If flattening is attempted this routine returns 1. +// ** +// ** All of the expression analysis must occur on both the outer query and +// ** the subquery before this routine runs. +// */ +func _flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAgg int32) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aCsrMap, db, pItem, pItemTab, pLimit, pNew, pOrderBy, pOrderBy1, pParent, pPrior, pSrc, pSub, pSub1, pSubSrc, pSubitem, pTabToDel, pToplevel, pWhere, zSavedAuthContext, v5 uintptr + var i, iNewParent, iParent, ii, isOuterJoin, nSubSrc, v4 int32 + var jointype Tu8 + var _ /* w at bp+0 */ TWalker + var _ /* x at bp+48 */ TSubstContext + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCsrMap, db, i, iNewParent, iParent, ii, isOuterJoin, jointype, nSubSrc, pItem, pItemTab, pLimit, pNew, pOrderBy, pOrderBy1, pParent, pPrior, pSrc, pSub, pSub1, pSubSrc, pSubitem, pTabToDel, pToplevel, pWhere, zSavedAuthContext, v4, v5 + zSavedAuthContext = (*TParse)(unsafe.Pointer(pParse)).FzAuthContext /* VDBE cursor number of the pSub result set temp table */ + iNewParent = -int32(1) /* Replacement table for iParent */ + isOuterJoin = 0 /* The subquery */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Walker to persist agginfo data */ + aCsrMap = uintptr(0) + /* Check to see if flattening is permitted. Return 0 if not. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_QueryFlattener)) != uint32(0) { + return 0 + } + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + pSubitem = pSrc + 8 + uintptr(iFrom)*80 + iParent = (*TSrcItem)(unsafe.Pointer(pSubitem)).FiCursor + pSub = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSubitem + 72)))).FpSelect + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 || (*TSelect)(unsafe.Pointer(pSub)).FpWin != 0 { + return 0 + } /* Restriction (25) */ + pSubSrc = (*TSelect)(unsafe.Pointer(pSub)).FpSrc + /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, + ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET + ** because they could be computed at compile-time. But when LIMIT and OFFSET + ** became arbitrary expressions, we were forced to add restrictions (13) + ** and (14). */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && (*TSelect)(unsafe.Pointer(p)).FpLimit != 0 { + return 0 + } /* Restriction (13) */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub)).FpLimit)).FpRight != 0 { + return 0 + } /* Restriction (14) */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Compound) != uint32(0) && (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 { + return 0 /* Restriction (15) */ + } + if (*TSrcList)(unsafe.Pointer(pSubSrc)).FnSrc == 0 { + return 0 + } /* Restriction (7) */ + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&uint32(SF_Distinct) != 0 { + return 0 + } /* Restriction (4) */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && ((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc > int32(1) || isAgg != 0) { + return 0 /* Restrictions (8)(9) */ + } + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 && (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + return 0 /* Restriction (11) */ + } + if isAgg != 0 && (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + return 0 + } /* Restriction (16) */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && (*TSelect)(unsafe.Pointer(p)).FpWhere != 0 { + return 0 + } /* Restriction (19) */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != uint32(0) { + return 0 /* Restriction (21) */ + } + if (*TSelect)(unsafe.Pointer(pSub)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Recursive)) != 0 { + return 0 /* Restrictions (22) */ + } + /* + ** If the subquery is the right operand of a LEFT JOIN, then the + ** subquery may not be a join itself (3a). Example of why this is not + ** allowed: + ** + ** t1 LEFT OUTER JOIN (t2 JOIN t3) + ** + ** If we flatten the above, we would get + ** + ** (t1 LEFT OUTER JOIN t2) JOIN t3 + ** + ** which is not at all the same thing. + ** + ** See also tickets #306, #350, and #3300. + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_LTORJ)) != 0 { + if (*TSrcList)(unsafe.Pointer(pSubSrc)).FnSrc > int32(1) || (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != uint32(0) || libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + return 0 + } + isOuterJoin = int32(1) + } + /* True by restriction (7) */ + if iFrom > 0 && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSubSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + return 0 /* Restriction (27a) */ + } + /* Condition (28) is blocked by the caller */ + /* Restriction (17): If the sub-query is a compound SELECT, then it must + ** use only the UNION ALL operator. And none of the simple select queries + ** that make up the compound SELECT are allowed to be aggregate or distinct + ** queries. + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpPrior != 0 { + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + return 0 /* Restriction (20) */ + } + if isAgg != 0 || (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Distinct) != uint32(0) || isOuterJoin > 0 { + return 0 /* (17d1), (17d2), or (17f) */ + } + pSub1 = pSub + for { + if !(pSub1 != 0) { + break + } + if (*TSelect)(unsafe.Pointer(pSub1)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Distinct)|libc.Int32FromInt32(SF_Aggregate)) != uint32(0) || (*TSelect)(unsafe.Pointer(pSub1)).FpPrior != 0 && libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pSub1)).Fop) != int32(TK_ALL) || (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub1)).FpSrc)).FnSrc < int32(1) || (*TSelect)(unsafe.Pointer(pSub1)).FpWin != 0 { + return 0 + } + if iFrom > 0 && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub1)).FpSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + /* Without this restriction, the JT_LTORJ flag would end up being + ** omitted on left-hand tables of the right join that is being + ** flattened. */ + return 0 /* Restrictions (17g), (27b) */ + } + goto _1 + _1: + ; + pSub1 = (*TSelect)(unsafe.Pointer(pSub1)).FpPrior + } + /* Restriction (18). */ + if (*TSelect)(unsafe.Pointer(p)).FpOrderBy != 0 { + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy)).FnExpr) { + break + } + if libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpOrderBy + 8 + uintptr(ii)*32 + 24))) == 0 { + return 0 + } + goto _2 + _2: + ; + ii = ii + 1 + } + } + /* Restriction (23) */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Recursive) != 0 { + return 0 + } + /* Restriction (17h) */ + if _compoundHasDifferentAffinities(tls, pSub) != 0 { + return 0 + } + if (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc > int32(1) { + if (*TParse)(unsafe.Pointer(pParse)).FnSelect > int32(500) { + return 0 + } + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FlttnUnionAll)) != uint32(0) { + return 0 + } + aCsrMap = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(int64((*TParse)(unsafe.Pointer(pParse)).FnTab)+libc.Int64FromInt32(1))*uint64(4)) + if aCsrMap != 0 { + **(**int32)(__ccgo_up(aCsrMap)) = (*TParse)(unsafe.Pointer(pParse)).FnTab + } + } + } + /***** If we reach this point, flattening is permitted. *****/ + /* Authorize the subquery */ + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = (*TSrcItem)(unsafe.Pointer(pSubitem)).FzName + _sqlite3AuthCheck(tls, pParse, int32(SQLITE_SELECT), uintptr(0), uintptr(0), uintptr(0)) + (*TParse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedAuthContext + /* Delete the transient structures associated with the subquery */ + if int32(*(*uint32)(unsafe.Pointer(pSubitem + 24 + 4))&0x4>>2) != 0 { + pSub1 = _sqlite3SubqueryDetach(tls, db, pSubitem) + } else { + pSub1 = uintptr(0) + } + _sqlite3DbFree(tls, db, (*TSrcItem)(unsafe.Pointer(pSubitem)).FzName) + _sqlite3DbFree(tls, db, (*TSrcItem)(unsafe.Pointer(pSubitem)).FzAlias) + (*TSrcItem)(unsafe.Pointer(pSubitem)).FzName = uintptr(0) + (*TSrcItem)(unsafe.Pointer(pSubitem)).FzAlias = uintptr(0) + /* If the sub-query is a compound SELECT statement, then (by restrictions + ** 17 and 18 above) it must be a UNION ALL and the parent query must + ** be of the form: + ** + ** SELECT FROM () + ** + ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block + ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or + ** OFFSET clauses and joins them to the left-hand-side of the original + ** using UNION ALL operators. In this case N is the number of simple + ** select statements in the compound sub-query. + ** + ** Example: + ** + ** SELECT a+1 FROM ( + ** SELECT x FROM tab + ** UNION ALL + ** SELECT y FROM tab + ** UNION ALL + ** SELECT abs(z*2) FROM tab2 + ** ) WHERE a!=5 ORDER BY 1 + ** + ** Transformed into: + ** + ** SELECT x+1 FROM tab WHERE x+1!=5 + ** UNION ALL + ** SELECT y+1 FROM tab WHERE y+1!=5 + ** UNION ALL + ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5 + ** ORDER BY 1 + ** + ** We call this the "compound-subquery flattening". + */ + pSub = (*TSelect)(unsafe.Pointer(pSub)).FpPrior + for { + if !(pSub != 0) { + break + } + pOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + pLimit = (*TSelect)(unsafe.Pointer(p)).FpLimit + pPrior = (*TSelect)(unsafe.Pointer(p)).FpPrior + pItemTab = (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab + (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(p)).FpLimit = uintptr(0) + pNew = _sqlite3SelectDup(tls, db, p, 0) + (*TSelect)(unsafe.Pointer(p)).FpLimit = pLimit + (*TSelect)(unsafe.Pointer(p)).FpOrderBy = pOrderBy + (*TSelect)(unsafe.Pointer(p)).Fop = uint8(TK_ALL) + (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab = pItemTab + if pNew == uintptr(0) { + (*TSelect)(unsafe.Pointer(p)).FpPrior = pPrior + } else { + v5 = pParse + 124 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + (*TSelect)(unsafe.Pointer(pNew)).FselId = libc.Uint32FromInt32(v4) + if aCsrMap != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + _renumberCursors(tls, pParse, pNew, iFrom, aCsrMap) + } + (*TSelect)(unsafe.Pointer(pNew)).FpPrior = pPrior + if pPrior != 0 { + (*TSelect)(unsafe.Pointer(pPrior)).FpNext = pNew + } + (*TSelect)(unsafe.Pointer(pNew)).FpNext = p + (*TSelect)(unsafe.Pointer(p)).FpPrior = pNew + } + goto _3 + _3: + ; + pSub = (*TSelect)(unsafe.Pointer(pSub)).FpPrior + } + _sqlite3DbFree(tls, db, aCsrMap) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3SrcItemAttachSubquery(tls, pParse, pSubitem, pSub1, 0) + return int32(1) + } + /* Defer deleting the Table object associated with the + ** subquery until code generation is + ** complete, since there may still exist Expr.pTab entries that + ** refer to the subquery even after flattening. Ticket #3346. + ** + ** pSubitem->pSTab is always non-NULL by test restrictions and tests above. + */ + if (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab != uintptr(0) { + pTabToDel = (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab + if (*TTable)(unsafe.Pointer(pTabToDel)).FnTabRef == uint32(1) { + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v5 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v5 = pParse + } + pToplevel = v5 + _sqlite3ParserAddCleanup(tls, pToplevel, __ccgo_fp(_sqlite3DeleteTableGeneric), pTabToDel) + } else { + (*TTable)(unsafe.Pointer(pTabToDel)).FnTabRef = (*TTable)(unsafe.Pointer(pTabToDel)).FnTabRef - 1 + } + (*TSrcItem)(unsafe.Pointer(pSubitem)).FpSTab = uintptr(0) + } + /* The following loop runs once for each term in a compound-subquery + ** flattening (as described above). If we are doing a different kind + ** of flattening - a flattening other than a compound-subquery flattening - + ** then this loop only runs once. + ** + ** This loop moves all of the FROM elements of the subquery into the + ** the FROM clause of the outer query. Before doing this, remember + ** the cursor number for the original outer query FROM element in + ** iParent. The iParent cursor will never be used. Subsequent code + ** will scan expressions looking for iParent references and replace + ** those references with expressions that resolve to the subquery FROM + ** elements we are now copying in. + */ + pSub = pSub1 + pParent = p + for { + if !(pParent != 0) { + break + } + jointype = (*TSrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype + pSubSrc = (*TSelect)(unsafe.Pointer(pSub)).FpSrc /* FROM clause of subquery */ + nSubSrc = (*TSrcList)(unsafe.Pointer(pSubSrc)).FnSrc /* Number of terms in subquery FROM clause */ + pSrc = (*TSelect)(unsafe.Pointer(pParent)).FpSrc /* FROM clause of the outer query */ + /* The subquery uses a single slot of the FROM clause of the outer + ** query. If the subquery has more than one element in its FROM clause, + ** then expand the outer query to make space for it to hold all elements + ** of the subquery. + ** + ** Example: + ** + ** SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB; + ** + ** The outer query has 3 slots in its FROM clause. One slot of the + ** outer query (the middle slot) is used by the subquery. The next + ** block of code will expand the outer query FROM clause to 4 slots. + ** The middle slot is expanded to two slots in order to make space + ** for the two elements in the FROM clause of the subquery. + */ + if nSubSrc > int32(1) { + pSrc = _sqlite3SrcListEnlarge(tls, pParse, pSrc, nSubSrc-int32(1), iFrom+int32(1)) + if pSrc == uintptr(0) { + break + } + (*TSelect)(unsafe.Pointer(pParent)).FpSrc = pSrc + pSubitem = pSrc + 8 + uintptr(iFrom)*80 + } + /* Transfer the FROM clause terms from the subquery into the + ** outer query. + */ + iNewParent = (*(*TSrcItem)(unsafe.Pointer(pSubSrc + 8))).FiCursor + i = 0 + for { + if !(i < nSubSrc) { + break + } + pItem = pSrc + 8 + uintptr(i+iFrom)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) != 0 { + _sqlite3IdListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 64))) + } + **(**TSrcItem)(__ccgo_up(pItem)) = *(*TSrcItem)(unsafe.Pointer(pSubSrc + 8 + uintptr(i)*80)) + v5 = pItem + 24 + *(*Tu8)(unsafe.Pointer(v5)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v5))) | libc.Int32FromUint8(jointype)&libc.Int32FromInt32(JT_LTORJ)) + libc.Xmemset(tls, pSubSrc+8+uintptr(i)*80, 0, uint64(80)) + goto _8 + _8: + ; + i = i + 1 + } + v5 = pSubitem + 24 + *(*Tu8)(unsafe.Pointer(v5)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v5))) | libc.Int32FromUint8(jointype)) + /* Begin substituting subquery result set expressions for + ** references to the iParent in the outer query. + ** + ** Example: + ** + ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b; + ** \ \_____________ subquery __________/ / + ** \_____________________ outer query ______________________________/ + ** + ** We look at every expression in the outer query and every place we see + ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + /* At this point, any non-zero iOrderByCol values indicate that the + ** ORDER BY column expression is identical to the iOrderByCol'th + ** expression returned by SELECT statement pSub. Since these values + ** do not necessarily correspond to columns in SELECT statement pParent, + ** zero them before transferring the ORDER BY clause. + ** + ** Not doing this may cause an error if a subsequent call to this + ** function attempts to flatten a compound sub-query into pParent. + ** See ticket [d11a6e908f]. + */ + pOrderBy1 = (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy1)).FnExpr) { + break + } + *(*Tu16)(unsafe.Pointer(pOrderBy1 + 8 + uintptr(i)*32 + 24)) = uint16(0) + goto _11 + _11: + ; + i = i + 1 + } + (*TSelect)(unsafe.Pointer(pParent)).FpOrderBy = pOrderBy1 + (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0) + } + pWhere = (*TSelect)(unsafe.Pointer(pSub)).FpWhere + (*TSelect)(unsafe.Pointer(pSub)).FpWhere = uintptr(0) + if isOuterJoin > 0 { + _sqlite3SetJoinExpr(tls, pWhere, iNewParent, uint32(EP_OuterON)) + } + if pWhere != 0 { + if (*TSelect)(unsafe.Pointer(pParent)).FpWhere != 0 { + (*TSelect)(unsafe.Pointer(pParent)).FpWhere = _sqlite3PExpr(tls, pParse, int32(TK_AND), pWhere, (*TSelect)(unsafe.Pointer(pParent)).FpWhere) + } else { + (*TSelect)(unsafe.Pointer(pParent)).FpWhere = pWhere + } + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + (**(**TSubstContext)(__ccgo_up(bp + 48))).FpParse = pParse + (**(**TSubstContext)(__ccgo_up(bp + 48))).FiTable = iParent + (**(**TSubstContext)(__ccgo_up(bp + 48))).FiNewTable = iNewParent + (**(**TSubstContext)(__ccgo_up(bp + 48))).FisOuterJoin = isOuterJoin + (**(**TSubstContext)(__ccgo_up(bp + 48))).FnSelDepth = 0 + (**(**TSubstContext)(__ccgo_up(bp + 48))).FpEList = (*TSelect)(unsafe.Pointer(pSub)).FpEList + (**(**TSubstContext)(__ccgo_up(bp + 48))).FpCList = _findLeftmostExprlist(tls, pSub) + _substSelect(tls, bp+48, pParent, 0) + } + /* The flattened query is a compound if either the inner or the + ** outer query is a compound. */ + **(**Tu32)(__ccgo_up(pParent + 4)) |= (*TSelect)(unsafe.Pointer(pSub)).FselFlags & uint32(SF_Compound) + /* restriction (17b) */ + /* + ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; + ** + ** One is tempted to try to add a and b to combine the limits. But this + ** does not work if either limit is negative. + */ + if (*TSelect)(unsafe.Pointer(pSub)).FpLimit != 0 { + (*TSelect)(unsafe.Pointer(pParent)).FpLimit = (*TSelect)(unsafe.Pointer(pSub)).FpLimit + (*TSelect)(unsafe.Pointer(pSub)).FpLimit = uintptr(0) + } + /* Recompute the SrcItem.colUsed masks for the flattened + ** tables. */ + i = 0 + for { + if !(i < nSubSrc) { + break + } + _recomputeColumnsUsed(tls, pParent, pSrc+8+uintptr(i+iFrom)*80) + goto _12 + _12: + ; + i = i + 1 + } + goto _7 + _7: + ; + pParent = (*TSelect)(unsafe.Pointer(pParent)).FpPrior + pSub = (*TSelect)(unsafe.Pointer(pSub)).FpPrior + } + /* Finally, delete what is left of the subquery and return success. + */ + _sqlite3AggInfoPersistWalkerInit(tls, bp, pParse) + _sqlite3WalkSelect(tls, bp, pSub1) + _sqlite3SelectDelete(tls, db, pSub1) + return int32(1) +} + +// C documentation +// +// /* +// ** This function is used to add page iPage to the database file free-list. +// ** It is assumed that the page is not already a part of the free-list. +// ** +// ** The value passed as the second argument to this function is optional. +// ** If the caller happens to have a pointer to the MemPage object +// ** corresponding to page iPage handy, it may pass it as the second value. +// ** Otherwise, it may pass NULL. +// ** +// ** If a pointer to a MemPage object is passed as the second argument, +// ** its reference count is not altered by this function. +// */ +func _freePage2(tls *libc.TLS, pBt uintptr, pMemPage uintptr, iPage TPgno) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iTrunk TPgno + var nFree, nLeaf Tu32 + var pPage1 uintptr + var v1, v3 int32 + var v2, v4 bool + var _ /* pPage at bp+8 */ uintptr + var _ /* pTrunk at bp+0 */ uintptr + var _ /* rc at bp+16 */ int32 + _, _, _, _, _, _, _, _ = iTrunk, nFree, nLeaf, pPage1, v1, v2, v3, v4 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Free-list trunk page */ + iTrunk = uint32(0) /* Page number of free-list trunk page */ + pPage1 = (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 /* Initial number of pages on free-list */ + if iPage < uint32(2) || iPage > (*TBtShared)(unsafe.Pointer(pBt)).FnPage { + return _sqlite3CorruptError(tls, int32(79983)) + } + if pMemPage != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = pMemPage + _sqlite3PagerRef(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + } else { + **(**uintptr)(__ccgo_up(bp + 8)) = _btreePageLookup(tls, pBt, iPage) + } + /* Increment the free page count on pPage1 */ + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FpDbPage) + if **(**int32)(__ccgo_up(bp + 16)) != 0 { + goto freepage_out + } + nFree = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+36) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+36, nFree+uint32(1)) + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_SECURE_DELETE) != 0 { + /* If the secure_delete option is enabled, then + ** always fully overwrite deleted information with zeros. + */ + if v2 = !(**(**uintptr)(__ccgo_up(bp + 8)) != 0); v2 { + v1 = _btreeGetPage(tls, pBt, iPage, bp+8, 0) + **(**int32)(__ccgo_up(bp + 16)) = v1 + } + if v4 = v2 && v1 != 0; !v4 { + v3 = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + **(**int32)(__ccgo_up(bp + 16)) = v3 + } + if v4 || v3 != 0 { + goto freepage_out + } + libc.Xmemset(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData, 0, uint64((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpBt)).FpageSize)) + } + /* If the database supports auto-vacuum, write an entry in the pointer-map + ** to indicate that the page is free. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _ptrmapPut(tls, pBt, iPage, uint8(PTRMAP_FREEPAGE), uint32(0), bp+16) + if **(**int32)(__ccgo_up(bp + 16)) != 0 { + goto freepage_out + } + } + /* Now manipulate the actual database free-list structure. There are two + ** possibilities. If the free-list is currently empty, or if the first + ** trunk page in the free-list is full, then this page will become a + ** new free-list trunk page. Otherwise, it will become a leaf of the + ** first trunk page in the current free-list. This block tests if it + ** is possible to add the page as a new free-list leaf. + */ + if nFree != uint32(0) { /* Initial number of leaf cells on trunk page */ + iTrunk = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32) + if iTrunk > _btreePagecount(tls, pBt) { + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3CorruptError(tls, int32(80030)) + goto freepage_out + } + **(**int32)(__ccgo_up(bp + 16)) = _btreeGetPage(tls, pBt, iTrunk, bp, 0) + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + goto freepage_out + } + nLeaf = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+4) + if nLeaf > (*TBtShared)(unsafe.Pointer(pBt)).FusableSize/uint32(4)-uint32(2) { + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3CorruptError(tls, int32(80041)) + goto freepage_out + } + if nLeaf < (*TBtShared)(unsafe.Pointer(pBt)).FusableSize/uint32(4)-uint32(8) { + /* In this case there is room on the trunk page to insert the page + ** being freed as a new leaf. + ** + ** Note that the trunk page is not really full until it contains + ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have + ** coded. But due to a coding error in versions of SQLite prior to + ** 3.6.0, databases with freelist trunk pages holding more than + ** usableSize/4 - 8 entries will be reported as corrupt. In order + ** to maintain backwards compatibility with older versions of SQLite, + ** we will continue to restrict the number of entries to usableSize/4 - 8 + ** for now. At some point in the future (once everyone has upgraded + ** to 3.6.0 or later) we should consider fixing the conditional above + ** to read "usableSize/4-2" instead of "usableSize/4-8". + ** + ** EVIDENCE-OF: R-19920-11576 However, newer versions of SQLite still + ** avoid using the last six entries in the freelist trunk page array in + ** order that database files created by newer versions of SQLite can be + ** read by older versions of SQLite. + */ + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+4, nLeaf+uint32(1)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+uintptr(uint32(8)+nLeaf*uint32(4)), iPage) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 && libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_SECURE_DELETE) == 0 { + _sqlite3PagerDontWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + } + **(**int32)(__ccgo_up(bp + 16)) = _btreeSetHasContent(tls, pBt, iPage) + } + goto freepage_out + } + } + /* If control flows to this point, then it was not possible to add the + ** the page being freed as a leaf page of the first trunk in the free-list. + ** Possibly because the free-list is empty, or possibly because the + ** first trunk in the free-list is full. Either way, the page being freed + ** will become the new first trunk page in the free-list. + */ + if v2 = **(**uintptr)(__ccgo_up(bp + 8)) == uintptr(0); v2 { + v1 = _btreeGetPage(tls, pBt, iPage, bp+8, 0) + **(**int32)(__ccgo_up(bp + 16)) = v1 + } + if v2 && SQLITE_OK != v1 { + goto freepage_out + } + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + if **(**int32)(__ccgo_up(bp + 16)) != SQLITE_OK { + goto freepage_out + } + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData, iTrunk) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FaData+4, uint32(0)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+32, iPage) + goto freepage_out +freepage_out: + ; + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FisInit = uint8(0) + } + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** Return a section of the pPage->aData to the freelist. +// ** The first byte of the new free block is pPage->aData[iStart] +// ** and the size of the block is iSize bytes. +// ** +// ** Adjacent freeblocks are coalesced. +// ** +// ** Even though the freeblock list was checked by btreeComputeFreeSpace(), +// ** that routine will not detect overlap between cells or freeblocks. Nor +// ** does it detect cells or freeblocks that encroach into the reserved bytes +// ** at the end of the page. So do additional corruption checks inside this +// ** routine and return SQLITE_CORRUPT if any problems are found. +// */ +func _freeSpace(tls *libc.TLS, pPage uintptr, iStart int32, iSize int32) (r int32) { + var data, pTmp, v2 uintptr + var hdr Tu8 + var iEnd, iFreeBlk, iOrigSize, iPtr, iPtrEnd, nFrag, x, v1 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = data, hdr, iEnd, iFreeBlk, iOrigSize, iPtr, iPtrEnd, nFrag, pTmp, x, v1, v2 /* Page header size. 0 or 100 */ + nFrag = 0 /* Reduction in fragmentation */ + iOrigSize = iSize /* Offset to cell content area */ + iEnd = iStart + iSize /* First byte past the iStart buffer */ + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData /* Temporary ptr into data[] */ + /* Minimum cell size is 4 */ + /* The list of freeblocks must be in ascending order. Find the + ** spot on the list where iStart should be inserted. + */ + hdr = (*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset + iPtr = libc.Int32FromUint8(hdr) + int32(1) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iPtr+int32(1))))) == 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iPtr)))) == 0 { + iFreeBlk = 0 /* Shortcut for the case when the freelist is empty */ + } else { + for { + v1 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iPtr))))< libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize)-int32(4) { /* TH3: corrupt081.100 */ + return _sqlite3CorruptError(tls, int32(75094)) + } + /* At this point: + ** iFreeBlk: First freeblock after iStart, or zero if none + ** iPtr: The address of a pointer to iFreeBlk + ** + ** Check to see if iFreeBlk should be coalesced onto the end of iStart. + */ + if iFreeBlk != 0 && iEnd+int32(3) >= iFreeBlk { + nFrag = iFreeBlk - iEnd + if iEnd > iFreeBlk { + return _sqlite3CorruptError(tls, int32(75106)) + } + iEnd = iFreeBlk + (libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFreeBlk+int32(2)))))< libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) { + return _sqlite3CorruptError(tls, int32(75109)) + } + iSize = iEnd - iStart + iFreeBlk = libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iFreeBlk))))< libc.Int32FromUint8(hdr)+int32(1) { + iPtrEnd = iPtr + (libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(iPtr+int32(2)))))<= iStart { + if iPtrEnd > iStart { + return _sqlite3CorruptError(tls, int32(75122)) + } + nFrag = nFrag + (iStart - iPtrEnd) + iSize = iEnd - iPtr + iStart = iPtr + } + } + if nFrag > libc.Int32FromUint8(**(**uint8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(7))))) { + return _sqlite3CorruptError(tls, int32(75128)) + } + v2 = data + uintptr(libc.Int32FromUint8(hdr)+int32(7)) + *(*uint8)(unsafe.Pointer(v2)) = uint8(int32(*(*uint8)(unsafe.Pointer(v2))) - libc.Int32FromUint8(libc.Uint8FromInt32(nFrag))) + } + pTmp = data + uintptr(libc.Int32FromUint8(hdr)+int32(5)) + x = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTmp)))<> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(1)) + 1)) = libc.Uint8FromInt32(iFreeBlk) + **(**uint8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(5)))) = libc.Uint8FromInt32(iEnd >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(5)) + 1)) = libc.Uint8FromInt32(iEnd) + } else { + /* Insert the new freeblock into the freelist */ + **(**uint8)(__ccgo_up(data + uintptr(iPtr))) = libc.Uint8FromInt32(iStart >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(iPtr) + 1)) = libc.Uint8FromInt32(iStart) + **(**uint8)(__ccgo_up(data + uintptr(iStart))) = libc.Uint8FromInt32(iFreeBlk >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(iStart) + 1)) = libc.Uint8FromInt32(iFreeBlk) + **(**uint8)(__ccgo_up(data + uintptr(iStart+int32(2)))) = libc.Uint8FromInt32(libc.Int32FromUint16(libc.Uint16FromInt32(iSize)) >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(data + uintptr(iStart+int32(2)) + 1)) = uint8(libc.Uint16FromInt32(iSize)) + } + **(**int32)(__ccgo_up(pPage + 20)) += iOrigSize + return SQLITE_OK +} + +func _fts5AppendPoslist(tls *libc.TLS, p uintptr, iDelta Tu64, pMulti uintptr, pBuf uintptr) { + var nByte, nData, v1 int32 + var v2 bool + _, _, _, _ = nByte, nData, v1, v2 + nData = (*TFts5Iter)(unsafe.Pointer(pMulti)).Fbase.FnData + nByte = nData + int32(9) + int32(9) + int32(FTS5_DATA_ZERO_PADDING) + if v2 = (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK; v2 { + if libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)+libc.Uint32FromInt32(nByte) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) { + v1 = 0 + } else { + v1 = _sqlite3Fts5BufferSize(tls, p+60, pBuf, libc.Uint32FromInt32(nByte+(*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + } + } + if v2 && 0 == v1 { + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), iDelta) + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), libc.Uint64FromInt32(nData*libc.Int32FromInt32(2))) + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), (*TFts5Iter)(unsafe.Pointer(pMulti)).Fbase.FpData, libc.Uint64FromInt32(nData)) + **(**int32)(__ccgo_up(pBuf + 8)) += nData + libc.Xmemset(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), 0, uint64(FTS5_DATA_ZERO_PADDING)) + } +} + +// C documentation +// +// /* +// ** This function appends iterator pAppend to Fts5TokenDataIter pIn and +// ** returns the result. +// */ +func _fts5AppendTokendataIter(tls *libc.TLS, p uintptr, pIn uintptr, pAppend uintptr) (r uintptr) { + var nAlloc, nByte, v2 Ti64 + var pNew, pRet, v3 uintptr + var v1 int64 + _, _, _, _, _, _, _ = nAlloc, nByte, pNew, pRet, v1, v2, v3 + pRet = pIn + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if pIn == uintptr(0) || (*TFts5TokenDataIter)(unsafe.Pointer(pIn)).FnIter == (*TFts5TokenDataIter)(unsafe.Pointer(pIn)).FnIterAlloc { + if pIn != 0 { + v1 = (*TFts5TokenDataIter)(unsafe.Pointer(pIn)).FnIterAlloc * int64(2) + } else { + v1 = int64(16) + } + nAlloc = v1 + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+72) + libc.Uint64FromInt64(nAlloc+libc.Int64FromInt32(1))*libc.Uint64FromInt64(104)) + pNew = Xsqlite3_realloc64(tls, pIn, libc.Uint64FromInt64(nByte)) + if pNew == uintptr(0) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + if pIn == uintptr(0) { + libc.Xmemset(tls, pNew, 0, libc.Uint64FromInt64(nByte)) + } + pRet = pNew + (*TFts5TokenDataIter)(unsafe.Pointer(pNew)).FnIterAlloc = nAlloc + } + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + _fts5IterClose(tls, pAppend) + } else { + v3 = pRet + 40 + v2 = *(*Ti64)(unsafe.Pointer(v3)) + *(*Ti64)(unsafe.Pointer(v3)) = *(*Ti64)(unsafe.Pointer(v3)) + 1 + *(*uintptr)(unsafe.Pointer(pRet + 72 + uintptr(v2)*8)) = pAppend + } + return pRet +} + +// C documentation +// +// /* +// ** Set *ppData to point to the Fts5Bm25Data object for the current query. +// ** If the object has not already been allocated, allocate and populate it +// ** now. +// */ +func _fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, nPhrase, rc int32 + var idf float64 + var nByte Tsqlite3_int64 + var p uintptr + var _ /* nHit at bp+16 */ Tsqlite3_int64 + var _ /* nRow at bp+0 */ Tsqlite3_int64 + var _ /* nToken at bp+8 */ Tsqlite3_int64 + _, _, _, _, _, _ = i, idf, nByte, nPhrase, p, rc + rc = SQLITE_OK /* Object to return */ + p = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxGetAuxdata})))(tls, pFts, 0) + if p == uintptr(0) { /* Number of phrases in query */ + **(**Tsqlite3_int64)(__ccgo_up(bp)) = 0 /* Number of rows in table */ + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0 + /* Allocate the Fts5Bm25Data object */ + nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseCount})))(tls, pFts) + nByte = libc.Int64FromUint64(uint64(32) + libc.Uint64FromInt32(nPhrase*int32(2))*uint64(8)) + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if p == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, p, 0, libc.Uint64FromInt64(nByte)) + (*TFts5Bm25Data)(unsafe.Pointer(p)).FnPhrase = nPhrase + (*TFts5Bm25Data)(unsafe.Pointer(p)).FaIDF = p + 1*32 + (*TFts5Bm25Data)(unsafe.Pointer(p)).FaFreq = (*TFts5Bm25Data)(unsafe.Pointer(p)).FaIDF + uintptr(nPhrase)*8 + } + /* Calculate the average document length for this FTS5 table */ + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxRowCount})))(tls, pFts, bp) + } + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnTotalSize})))(tls, pFts, -int32(1), bp+8) + } + if rc == SQLITE_OK { + (*TFts5Bm25Data)(unsafe.Pointer(p)).Favgdl = float64(**(**Tsqlite3_int64)(__ccgo_up(bp + 8))) / float64(**(**Tsqlite3_int64)(__ccgo_up(bp))) + } + /* Calculate an IDF for each phrase in the query */ + i = 0 + for { + if !(rc == SQLITE_OK && i < nPhrase) { + break + } + **(**Tsqlite3_int64)(__ccgo_up(bp + 16)) = 0 + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxQueryPhrase})))(tls, pFts, i, bp+16, __ccgo_fp(_fts5CountCb)) + if rc == SQLITE_OK { + /* Calculate the IDF (Inverse Document Frequency) for phrase i. + ** This is done using the standard BM25 formula as found on wikipedia: + ** + ** IDF = log( (N - nHit + 0.5) / (nHit + 0.5) ) + ** + ** where "N" is the total number of documents in the set and nHit + ** is the number that contain at least one instance of the phrase + ** under consideration. + ** + ** The problem with this is that if (N < 2*nHit), the IDF is + ** negative. Which is undesirable. So the minimum allowable IDF is + ** (1e-6) - roughly the same as a term that appears in just over + ** half of set of 5,000,000 documents. */ + idf = libc.Xlog(tls, (float64(**(**Tsqlite3_int64)(__ccgo_up(bp))-**(**Tsqlite3_int64)(__ccgo_up(bp + 16)))+float64(0.5))/(float64(**(**Tsqlite3_int64)(__ccgo_up(bp + 16)))+float64(0.5))) + if idf <= float64(0) { + idf = float64(1e-06) + } + **(**float64)(__ccgo_up((*TFts5Bm25Data)(unsafe.Pointer(p)).FaIDF + uintptr(i)*8)) = idf + } + goto _1 + _1: + ; + i = i + 1 + } + if rc != SQLITE_OK { + Xsqlite3_free(tls, p) + } else { + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxSetAuxdata})))(tls, pFts, p, __ccgo_fp(Xsqlite3_free)) + } + if rc != SQLITE_OK { + p = uintptr(0) + } + } + **(**uintptr)(__ccgo_up(ppData)) = p + return rc +} + +// C documentation +// +// /* +// ** If argument pOrig is NULL, or if (*pRc) is set to anything other than +// ** SQLITE_OK when this function is called, NULL is returned. +// ** +// ** Otherwise, a copy of (*pOrig) is made into memory obtained from +// ** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation +// ** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned. +// */ +func _fts5CloneColset(tls *libc.TLS, pRc uintptr, pOrig uintptr) (r uintptr) { + var nByte Tsqlite3_int64 + var pRet uintptr + _, _ = nByte, pRet + if pOrig != 0 { + nByte = libc.Int64FromUint64(libc.Uint64FromInt64(8) * libc.Uint64FromInt32(((*TFts5Colset)(unsafe.Pointer(pOrig)).FnCol+libc.Int32FromInt32(2))/libc.Int32FromInt32(2))) + pRet = _sqlite3Fts5MallocZero(tls, pRc, nByte) + if pRet != 0 { + libc.Xmemcpy(tls, pRet, pOrig, libc.Uint64FromInt64(nByte)) + } + } else { + pRet = uintptr(0) + } + return pRet +} + +// C documentation +// +// /* +// ** Register a new auxiliary function with global context pGlobal. +// */ +func _fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr, __ccgo_fp_xFunc Tfts5_extension_function, __ccgo_fp_xDestroy uintptr) (r int32) { + var nByte, nName Tsqlite3_int64 + var pAux, pGlobal uintptr + var rc int32 + _, _, _, _, _ = nByte, nName, pAux, pGlobal, rc + pGlobal = pApi + rc = Xsqlite3_overload_function(tls, (*TFts5Global)(unsafe.Pointer(pGlobal)).Fdb, zName, -int32(1)) + if rc == SQLITE_OK { /* Bytes of space to allocate */ + nName = libc.Int64FromUint64(libc.Xstrlen(tls, zName) + uint64(1)) + nByte = libc.Int64FromUint64(uint64(48) + libc.Uint64FromInt64(nName)) + pAux = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pAux != 0 { + libc.Xmemset(tls, pAux, 0, libc.Uint64FromInt64(nByte)) + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc = pAux + 1*48 + libc.Xmemcpy(tls, (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc, zName, libc.Uint64FromInt64(nName)) + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal = pGlobal + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpUserData = pUserData + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxFunc = __ccgo_fp_xFunc + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy = __ccgo_fp_xDestroy + (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpNext = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpAux + (*TFts5Global)(unsafe.Pointer(pGlobal)).FpAux = pAux + } else { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +func _fts5DlidxIterInit(tls *libc.TLS, p uintptr, bRev int32, iSegid int32, iLeafPg int32) (r uintptr) { + var bDone, i int32 + var iRowid Ti64 + var nByte Tsqlite3_int64 + var pIter, pLvl, pNew uintptr + _, _, _, _, _, _, _ = bDone, i, iRowid, nByte, pIter, pLvl, pNew + pIter = uintptr(0) + bDone = 0 + i = 0 + for { + if !((*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bDone == 0) { + break + } + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+8) + libc.Uint64FromInt32(i+libc.Int32FromInt32(1))*libc.Uint64FromInt64(32)) + pNew = Xsqlite3_realloc64(tls, pIter, libc.Uint64FromInt64(nByte)) + if pNew == uintptr(0) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + iRowid = int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(1))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(i)<iLeafOffset is the + ** offset of the first byte in the position-list for the entry to + ** remove. Immediately before this comes two varints that will also + ** need to be removed: + ** + ** + the rowid or delta rowid value for the entry, and + ** + the size of the position list in bytes. + ** + ** Or, in detail=none mode, there is a single varint prior to + ** pSeg->iLeafOffset - the rowid or delta rowid value. + ** + ** This block sets the following variables: + ** + ** iStart: + ** The offset of the first byte of the rowid or delta-rowid + ** value for the doclist entry being removed. + ** + ** iDelta: + ** The value of the rowid or delta-rowid value for the doclist + ** entry being removed. + ** + ** iNextOff: + ** The offset of the next entry following the position list + ** for the one being removed. If the position list for this + ** entry overflows onto the next leaf page, this value will be + ** greater than pLeaf->szLeaf. + */ + /* Start-Of-Position-list */ + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno { + iStart = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafOffset + } else { + iStart = libc.Int32FromUint16(_fts5GetU16(tls, aPg)) + } + if iStart > nPg { + _fts5IndexCorruptIdx(tls, p) + Xsqlite3_free(tls, aIdx) + return + } + iSOP = iStart + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iStart), bp)) + if bDetailNone != 0 { + for int64(iSOP) < (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aPg + uintptr(iSOP)))) == 0x00 { + iSOP = iSOP + 1 + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aPg + uintptr(iSOP)))) == 0x00 { + iSOP = iSOP + 1 + } + iStart = iSOP + iSOP = iStart + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iStart), bp)) + } + iNextOff = iSOP + if iNextOff < (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aPg + uintptr(iNextOff)))) == 0x00 { + iNextOff = iNextOff + 1 + } + if iNextOff < (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aPg + uintptr(iNextOff)))) == 0x00 { + iNextOff = iNextOff + 1 + } + } else { + **(**int32)(__ccgo_up(bp + 12)) = 0 + iSOP = iSOP + _sqlite3Fts5GetVarint32(tls, aPg+uintptr(iSOP), bp+12) + for int64(iSOP) < (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset { + iStart = iSOP + **(**int32)(__ccgo_up(bp + 12))/int32(2) + iSOP = iStart + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iStart), bp)) + iSOP = iSOP + _sqlite3Fts5GetVarint32(tls, aPg+uintptr(iSOP), bp+12) + } + iNextOff = iSOP + (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos + } + iOff = iStart + /* If the position-list for the entry being removed flows over past + ** the end of this page, delete the portion of the position-list on the + ** next page and beyond. + ** + ** Set variable bLastInDoclist to true if this entry happens + ** to be the last rowid in the doclist for its term. */ + if iNextOff >= iPgIdx { + pgno = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno + int32(1) + _fts5SecureDeleteOverflow(tls, p, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg, pgno, bp+8) + iNextOff = iPgIdx + } + if libc.Int32FromUint8((*TFts5SegIter)(unsafe.Pointer(pSeg)).FbDel) == 0 { + if iNextOff != iPgIdx { + /* Loop through the page-footer. If iNextOff (offset of the + ** entry following the one we are removing) is equal to the + ** offset of a key on this page, then the entry is the last + ** in its doclist. */ + iKeyOff = 0 + iIdx = 0 + for { + if !(iIdx < nIdx) { + break + } + **(**Tu32)(__ccgo_up(bp + 16)) = uint32(0) + iIdx = iIdx + _sqlite3Fts5GetVarint32(tls, aIdx+uintptr(iIdx), bp+16) + iKeyOff = libc.Int32FromUint32(uint32(iKeyOff) + **(**Tu32)(__ccgo_up(bp + 16))) + if iKeyOff == iNextOff { + **(**int32)(__ccgo_up(bp + 8)) = int32(1) + } + goto _1 + _1: + } + } + /* If this is (a) the first rowid on a page and (b) is not followed by + ** another position list on the same page, set the "first-rowid" field + ** of the header to 0. */ + if libc.Int32FromUint16(_fts5GetU16(tls, aPg)) == iStart && (**(**int32)(__ccgo_up(bp + 8)) != 0 || iNextOff == iPgIdx) { + _fts5PutU16(tls, aPg, uint16(0)) + } + } + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FbDel != 0 { + iOff = iOff + _sqlite3Fts5PutVarint(tls, aPg+uintptr(iOff), **(**Tu64)(__ccgo_up(bp))) + v2 = iOff + iOff = iOff + 1 + **(**Tu8)(__ccgo_up(aPg + uintptr(v2))) = uint8(0x01) + } else { + if **(**int32)(__ccgo_up(bp + 8)) == 0 { + if iNextOff != iPgIdx { + **(**Tu64)(__ccgo_up(bp + 24)) = uint64(0) + iNextOff = iNextOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iNextOff), bp+24)) + iOff = iOff + _sqlite3Fts5PutVarint(tls, aPg+uintptr(iOff), **(**Tu64)(__ccgo_up(bp))+**(**Tu64)(__ccgo_up(bp + 24))) + } + } else { + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno && iStart == (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafOffset { + /* The entry being removed was the only position list in its + ** doclist. Therefore the term needs to be removed as well. */ + iKey = 0 + iKeyOff1 = 0 + /* Set iKeyOff to the offset of the term that will be removed - the + ** last offset in the footer that is not greater than iStart. */ + iIdx = 0 + for { + if !(iIdx < nIdx) { + break + } + **(**Tu32)(__ccgo_up(bp + 32)) = uint32(0) + iIdx = iIdx + _sqlite3Fts5GetVarint32(tls, aIdx+uintptr(iIdx), bp+32) + if libc.Uint32FromInt32(iKeyOff1)+**(**Tu32)(__ccgo_up(bp + 32)) > libc.Uint32FromInt32(iStart) { + break + } + iKeyOff1 = libc.Int32FromUint32(uint32(iKeyOff1) + **(**Tu32)(__ccgo_up(bp + 32))) + goto _3 + _3: + ; + iKey = iKey + 1 + } + /* Set iDelKeyOff to the value of the footer entry to remove from + ** the page. */ + v2 = iKeyOff1 + iOff = v2 + iDelKeyOff = v2 + if iNextOff != iPgIdx { + /* This is the only position-list associated with the term, and there + ** is another term following it on this page. So the subsequent term + ** needs to be moved to replace the term associated with the entry + ** being removed. */ + **(**Tu64)(__ccgo_up(bp + 40)) = uint64(0) + **(**Tu64)(__ccgo_up(bp + 48)) = uint64(0) + **(**Tu64)(__ccgo_up(bp + 56)) = uint64(0) + **(**Tu64)(__ccgo_up(bp + 64)) = uint64(0) + iDelKeyOff = iNextOff + iNextOff = iNextOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iNextOff), bp+56)) + iNextOff = iNextOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iNextOff), bp+64)) + if iKey != int32(1) { + iKeyOff1 = iKeyOff1 + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iKeyOff1), bp+40)) + } + iKeyOff1 = iKeyOff1 + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, aPg+uintptr(iKeyOff1), bp+48)) + if **(**Tu64)(__ccgo_up(bp + 40)) < **(**Tu64)(__ccgo_up(bp + 56)) { + v5 = **(**Tu64)(__ccgo_up(bp + 40)) + } else { + v5 = **(**Tu64)(__ccgo_up(bp + 56)) + } + **(**Tu64)(__ccgo_up(bp + 40)) = v5 + **(**Tu64)(__ccgo_up(bp + 48)) = **(**Tu64)(__ccgo_up(bp + 56)) + **(**Tu64)(__ccgo_up(bp + 64)) - **(**Tu64)(__ccgo_up(bp + 40)) + if libc.Uint64FromInt32(iKeyOff1)+**(**Tu64)(__ccgo_up(bp + 48)) > libc.Uint64FromInt32(iPgIdx) || libc.Uint64FromInt32(iNextOff)+**(**Tu64)(__ccgo_up(bp + 64)) > libc.Uint64FromInt32(iPgIdx) { + _fts5IndexCorruptIdx(tls, p) + } else { + if iKey != int32(1) { + iOff = iOff + _sqlite3Fts5PutVarint(tls, aPg+uintptr(iOff), **(**Tu64)(__ccgo_up(bp + 40))) + } + iOff = iOff + _sqlite3Fts5PutVarint(tls, aPg+uintptr(iOff), **(**Tu64)(__ccgo_up(bp + 48))) + if **(**Tu64)(__ccgo_up(bp + 56)) > libc.Uint64FromInt32((*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn) { + _fts5IndexCorruptIdx(tls, p) + } else { + if **(**Tu64)(__ccgo_up(bp + 56)) > **(**Tu64)(__ccgo_up(bp + 40)) { + libc.Xmemcpy(tls, aPg+uintptr(iOff), (*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp+uintptr(**(**Tu64)(__ccgo_up(bp + 40))), uint64(**(**Tu64)(__ccgo_up(bp + 56))-**(**Tu64)(__ccgo_up(bp + 40)))) + iOff = libc.Int32FromUint64(uint64(iOff) + (**(**Tu64)(__ccgo_up(bp + 56)) - **(**Tu64)(__ccgo_up(bp + 40)))) + } + } + libc.Xmemmove(tls, aPg+uintptr(iOff), aPg+uintptr(iNextOff), uint64(**(**Tu64)(__ccgo_up(bp + 64)))) + iOff = libc.Int32FromUint64(uint64(iOff) + **(**Tu64)(__ccgo_up(bp + 64))) + iNextOff = libc.Int32FromUint64(uint64(iNextOff) + **(**Tu64)(__ccgo_up(bp + 64))) + } + } + } else { + if iStart == int32(4) { + /* The entry being removed may be the only position list in + ** its doclist. */ + iPgno = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno - int32(1) + for { + if !(iPgno > (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno) { + break + } + pPg = _fts5DataRead(tls, p, int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))<= nTermIdx { + break + } + iTermIdx = iTermIdx + nByte + } + nTermIdx = iTermIdx + if iTermOff > int64((*TFts5Data)(unsafe.Pointer(pTerm)).FszLeaf) { + _fts5IndexCorruptIdx(tls, p) + } else { + libc.Xmemmove(tls, (*TFts5Data)(unsafe.Pointer(pTerm)).Fp+uintptr(iTermOff), (*TFts5Data)(unsafe.Pointer(pTerm)).Fp+uintptr((*TFts5Data)(unsafe.Pointer(pTerm)).FszLeaf), libc.Uint64FromInt32(nTermIdx)) + _fts5PutU16(tls, (*TFts5Data)(unsafe.Pointer(pTerm)).Fp+2, libc.Uint16FromInt64(iTermOff)) + _fts5DataWrite(tls, p, iId, (*TFts5Data)(unsafe.Pointer(pTerm)).Fp, int32(iTermOff+int64(nTermIdx))) + if nTermIdx == 0 { + _fts5SecureDeleteIdxEntry(tls, p, iSegid, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno) + } + } + } + _fts5DataRelease(tls, pTerm) + } + } + } + } + } + /* Assuming no error has occurred, this block does final edits to the + ** leaf page before writing it back to disk. Input variables are: + ** + ** nPg: Total initial size of leaf page. + ** iPgIdx: Initial offset of page footer. + ** + ** iOff: Offset to move data to + ** iNextOff: Offset to move data from + */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + nMove = nPg - iNextOff /* Number of bytes to move */ + nShift = iNextOff - iOff /* Distance to move them */ + iPrevKeyOut = 0 + iKeyIn = 0 + if nMove > 0 { + libc.Xmemmove(tls, aPg+uintptr(iOff), aPg+uintptr(iNextOff), libc.Uint64FromInt32(nMove)) + } + iPgIdx = iPgIdx - nShift + nPg = iPgIdx + _fts5PutU16(tls, aPg+2, libc.Uint16FromInt32(iPgIdx)) + iIdx = 0 + for { + if !(iIdx < nIdx) { + break + } + **(**Tu32)(__ccgo_up(bp + 76)) = uint32(0) + iIdx = iIdx + _sqlite3Fts5GetVarint32(tls, aIdx+uintptr(iIdx), bp+76) + iKeyIn = libc.Int32FromUint32(uint32(iKeyIn) + **(**Tu32)(__ccgo_up(bp + 76))) + if iKeyIn != iDelKeyOff { + if iKeyIn > iOff { + v2 = nShift + } else { + v2 = 0 + } + iKeyOut = iKeyIn - v2 + nPg = nPg + _sqlite3Fts5PutVarint(tls, aPg+uintptr(nPg), libc.Uint64FromInt32(iKeyOut-iPrevKeyOut)) + iPrevKeyOut = iKeyOut + } + goto _7 + _7: + } + if iPgIdx == nPg && nIdx > 0 && (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno != int32(1) { + _fts5SecureDeleteIdxEntry(tls, p, iSegid, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno) + } + _fts5DataWrite(tls, p, int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))< (*TFts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 48 + uintptr(ii)*8)))).FiHeight+int32(1) { + v1 = (*TFts5ExprNode)(unsafe.Pointer(p)).FiHeight + } else { + v1 = (*TFts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 48 + uintptr(ii)*8)))).FiHeight + int32(1) + } + (*TFts5ExprNode)(unsafe.Pointer(p)).FiHeight = v1 + goto _3 + _3: + ; + ii = ii + 1 + } +} + +// C documentation +// +// /* +// ** The near-set object passed as the first argument contains more than +// ** one phrase. All phrases currently point to the same row. The +// ** Fts5ExprPhrase.poslist buffers are populated accordingly. This function +// ** tests if the current row contains instances of each phrase sufficiently +// ** close together to meet the NEAR constraint. Non-zero is returned if it +// ** does, or zero otherwise. +// ** +// ** If in/out parameter (*pRc) is set to other than SQLITE_OK when this +// ** function is called, it is a no-op. Or, if an error (e.g. SQLITE_NOMEM) +// ** occurs within this function (*pRc) is set accordingly before returning. +// ** The return value is undefined in both these cases. +// ** +// ** If no error occurs and non-zero (a match) is returned, the position-list +// ** of each phrase object is edited to contain only those entries that +// ** meet the constraint before returning. +// */ +func _fts5ExprNearIsMatch(tls *libc.TLS, pRc uintptr, pNear uintptr) (r int32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var a, apPhrase, pPos, pPoslist, pWriter uintptr + var bMatch, bRet, i, iAdv int32 + var iMax, iMin, iPos Ti64 + var nByte Tsqlite3_int64 + var _ /* aStatic at bp+0 */ [4]TFts5NearTrimmer + var _ /* rc at bp+192 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = a, apPhrase, bMatch, bRet, i, iAdv, iMax, iMin, iPos, nByte, pPos, pPoslist, pWriter + a = bp + apPhrase = pNear + 24 + **(**int32)(__ccgo_up(bp + 192)) = **(**int32)(__ccgo_up(pRc)) + /* If the aStatic[] array is not large enough, allocate a large array + ** using sqlite3_malloc(). This approach could be improved upon. */ + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase > libc.Int32FromUint64(libc.Uint64FromInt64(192)/libc.Uint64FromInt64(48)) { + nByte = libc.Int64FromUint64(uint64(48) * libc.Uint64FromInt32((*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase)) + a = _sqlite3Fts5MallocZero(tls, bp+192, nByte) + } else { + libc.Xmemset(tls, bp, 0, uint64(192)) + } + if **(**int32)(__ccgo_up(bp + 192)) != SQLITE_OK { + **(**int32)(__ccgo_up(pRc)) = **(**int32)(__ccgo_up(bp + 192)) + return 0 + } + /* Initialize a lookahead iterator for each phrase. After passing the + ** buffer and buffer size to the lookaside-reader init function, zero + ** the phrase poslist buffer. The new poslist for the phrase (containing + ** the same entries as the original with some entries removed on account + ** of the NEAR constraint) is written over the original even as it is + ** being read. This is safe as the entries for the new poslist are a + ** subset of the old, so it is not possible for data yet to be read to + ** be overwritten. */ + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + pPoslist = **(**uintptr)(__ccgo_up(apPhrase + uintptr(i)*8)) + 8 + _fts5LookaheadReaderInit(tls, (*TFts5Buffer)(unsafe.Pointer(pPoslist)).Fp, (*TFts5Buffer)(unsafe.Pointer(pPoslist)).Fn, a+uintptr(i)*48) + (*TFts5Buffer)(unsafe.Pointer(pPoslist)).Fn = 0 + (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).FpOut = pPoslist + goto _1 + _1: + ; + i = i + 1 + } + for int32(1) != 0 { + /* This block advances the phrase iterators until they point to a set of + ** entries that together comprise a match. */ + iMax = (**(**TFts5NearTrimmer)(__ccgo_up(a))).Freader.FiPos + for cond := true; cond; cond = bMatch == 0 { + bMatch = int32(1) + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + pPos = a + uintptr(i)*48 + iMin = iMax - int64((*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(i)*8)))).FnTerm) - int64((*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnNear) + if (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos < iMin || (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos > iMax { + bMatch = 0 + for (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos < iMin { + if _fts5LookaheadReaderNext(tls, pPos) != 0 { + goto ismatch_out + } + } + if (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos > iMax { + iMax = (*TFts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + /* Add an entry to each output position list */ + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + iPos = (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).Freader.FiPos + pWriter = a + uintptr(i)*48 + 32 + if (*TFts5Buffer)(unsafe.Pointer((**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).FpOut)).Fn == 0 || iPos != (*TFts5PoslistWriter)(unsafe.Pointer(pWriter)).FiPrev { + _sqlite3Fts5PoslistWriterAppend(tls, (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).FpOut, pWriter, iPos) + } + goto _3 + _3: + ; + i = i + 1 + } + iAdv = 0 + iMin = (**(**TFts5NearTrimmer)(__ccgo_up(a))).Freader.FiLookahead + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + if (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).Freader.FiLookahead < iMin { + iMin = (**(**TFts5NearTrimmer)(__ccgo_up(a + uintptr(i)*48))).Freader.FiLookahead + iAdv = i + } + goto _4 + _4: + ; + i = i + 1 + } + if _fts5LookaheadReaderNext(tls, a+uintptr(iAdv)*48) != 0 { + goto ismatch_out + } + } + goto ismatch_out +ismatch_out: + ; + bRet = libc.BoolInt32((*TFts5Buffer)(unsafe.Pointer((**(**TFts5NearTrimmer)(__ccgo_up(a))).FpOut)).Fn > 0) + **(**int32)(__ccgo_up(pRc)) = **(**int32)(__ccgo_up(bp + 192)) + if a != bp { + Xsqlite3_free(tls, a) + } + return bRet + return r +} + +// C documentation +// +// /* +// ** All individual term iterators in pPhrase are guaranteed to be valid and +// ** pointing to the same rowid when this function is called. This function +// ** checks if the current rowid really is a match, and if so populates +// ** the pPhrase->poslist buffer accordingly. Output parameter *pbMatch +// ** is set to true if this is really a match, or false otherwise. +// ** +// ** SQLITE_OK is returned if an error occurs, or an SQLite error code +// ** otherwise. It is not considered an error code if the current rowid is +// ** not a match. +// */ +func _fts5ExprPhraseIsMatch(tls *libc.TLS, pNode uintptr, pPhrase uintptr, pbMatch uintptr) (r int32) { + bp := tls.Alloc(176) + defer tls.Free(176) + var aIter, pPos, pTerm uintptr + var bFirst, bFlag, bMatch, i, rc int32 + var iAdj, iPos Ti64 + var nByte Tsqlite3_int64 + var _ /* a at bp+144 */ uintptr + var _ /* aStatic at bp+8 */ [4]TFts5PoslistReader + var _ /* buf at bp+152 */ TFts5Buffer + var _ /* n at bp+136 */ int32 + var _ /* writer at bp+0 */ TFts5PoslistWriter + _, _, _, _, _, _, _, _, _, _, _ = aIter, bFirst, bFlag, bMatch, i, iAdj, iPos, nByte, pPos, pTerm, rc + **(**TFts5PoslistWriter)(__ccgo_up(bp)) = TFts5PoslistWriter{} + aIter = bp + 8 + rc = SQLITE_OK + bFirst = libc.Int32FromUint8((*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32))).FbFirst) + _sqlite3Fts5BufferZero(tls, pPhrase+8) + /* If the aStatic[] array is not large enough, allocate a large array + ** using sqlite3_malloc(). This approach could be improved upon. */ + if (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > libc.Int32FromUint64(libc.Uint64FromInt64(128)/libc.Uint64FromInt64(32)) { + nByte = libc.Int64FromUint64(uint64(32) * libc.Uint64FromInt32((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm)) + aIter = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if !(aIter != 0) { + return int32(SQLITE_NOMEM) + } + } + libc.Xmemset(tls, aIter, 0, uint64(32)*libc.Uint64FromInt32((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm)) + /* Initialize a term iterator for each term in the phrase */ + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + pTerm = pPhrase + 32 + uintptr(i)*40 + **(**int32)(__ccgo_up(bp + 136)) = 0 + bFlag = 0 + **(**uintptr)(__ccgo_up(bp + 144)) = uintptr(0) + if (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { + **(**TFts5Buffer)(__ccgo_up(bp + 152)) = TFts5Buffer{} + rc = _fts5ExprSynonymList(tls, pTerm, (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid, bp+152, bp+144, bp+136) + if rc != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 144))) + goto ismatch_out + } + if **(**uintptr)(__ccgo_up(bp + 144)) == (**(**TFts5Buffer)(__ccgo_up(bp + 152))).Fp { + bFlag = int32(1) + } + } else { + **(**uintptr)(__ccgo_up(bp + 144)) = (*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter)).FpData + **(**int32)(__ccgo_up(bp + 136)) = (*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter)).FnData + } + _sqlite3Fts5PoslistReaderInit(tls, **(**uintptr)(__ccgo_up(bp + 144)), **(**int32)(__ccgo_up(bp + 136)), aIter+uintptr(i)*32) + (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).FbFlag = libc.Uint8FromInt32(bFlag) + if (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).FbEof != 0 { + goto ismatch_out + } + goto _1 + _1: + ; + i = i + 1 + } + for int32(1) != 0 { + iPos = (**(**TFts5PoslistReader)(__ccgo_up(aIter))).FiPos + for cond := true; cond; cond = bMatch == 0 { + bMatch = int32(1) + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + pPos = aIter + uintptr(i)*32 + iAdj = iPos + int64(i) + if (*TFts5PoslistReader)(unsafe.Pointer(pPos)).FiPos != iAdj { + bMatch = 0 + for (*TFts5PoslistReader)(unsafe.Pointer(pPos)).FiPos < iAdj { + if _sqlite3Fts5PoslistReaderNext(tls, pPos) != 0 { + goto ismatch_out + } + } + if (*TFts5PoslistReader)(unsafe.Pointer(pPos)).FiPos > iAdj { + iPos = (*TFts5PoslistReader)(unsafe.Pointer(pPos)).FiPos - int64(i) + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + /* Append position iPos to the output */ + if bFirst == 0 || int32(iPos&libc.Int64FromInt32(0x7FFFFFFF)) == 0 { + rc = _sqlite3Fts5PoslistWriterAppend(tls, pPhrase+8, bp, iPos) + if rc != SQLITE_OK { + goto ismatch_out + } + } + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + if _sqlite3Fts5PoslistReaderNext(tls, aIter+uintptr(i)*32) != 0 { + goto ismatch_out + } + goto _3 + _3: + ; + i = i + 1 + } + } + goto ismatch_out +ismatch_out: + ; + **(**int32)(__ccgo_up(pbMatch)) = libc.BoolInt32((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn > 0) + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + if (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).FbFlag != 0 { + Xsqlite3_free(tls, (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).Fa) + } + goto _4 + _4: + ; + i = i + 1 + } + if aIter != bp+8 { + Xsqlite3_free(tls, aIter) + } + return rc +} + +// C documentation +// +// /* +// ** Argument pTerm must be a synonym iterator. +// */ +func _fts5ExprSynonymList(tls *libc.TLS, pTerm uintptr, iRowid Ti64, pBuf uintptr, pa uintptr, pn uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var aIter, aNew, p, pIter uintptr + var i, nAlloc, nIter, rc int32 + var iMin, iPrev Ti64 + var nByte Tsqlite3_int64 + var _ /* aStatic at bp+0 */ [4]TFts5PoslistReader + var _ /* writer at bp+128 */ TFts5PoslistWriter + _, _, _, _, _, _, _, _, _, _, _ = aIter, aNew, i, iMin, iPrev, nAlloc, nByte, nIter, p, pIter, rc + aIter = bp + nIter = 0 + nAlloc = int32(4) + rc = SQLITE_OK + p = pTerm + for { + if !(p != 0) { + break + } + pIter = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter + if libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer(pIter)).FbEof) == 0 && (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == iRowid { + if (*TFts5IndexIter)(unsafe.Pointer(pIter)).FnData == 0 { + goto _1 + } + if nIter == nAlloc { + nByte = libc.Int64FromUint64(uint64(32) * libc.Uint64FromInt32(nAlloc) * uint64(2)) + aNew = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if aNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto synonym_poslist_out + } + libc.Xmemcpy(tls, aNew, aIter, uint64(32)*libc.Uint64FromInt32(nIter)) + nAlloc = nAlloc * int32(2) + if aIter != bp { + Xsqlite3_free(tls, aIter) + } + aIter = aNew + } + _sqlite3Fts5PoslistReaderInit(tls, (*TFts5IndexIter)(unsafe.Pointer(pIter)).FpData, (*TFts5IndexIter)(unsafe.Pointer(pIter)).FnData, aIter+uintptr(nIter)*32) + nIter = nIter + 1 + } + goto _1 + _1: + ; + p = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpSynonym + } + if nIter == int32(1) { + **(**uintptr)(__ccgo_up(pa)) = (**(**TFts5PoslistReader)(__ccgo_up(aIter))).Fa + **(**int32)(__ccgo_up(pn)) = (**(**TFts5PoslistReader)(__ccgo_up(aIter))).Fn + } else { + **(**TFts5PoslistWriter)(__ccgo_up(bp + 128)) = TFts5PoslistWriter{} + iPrev = int64(-int32(1)) + _sqlite3Fts5BufferZero(tls, pBuf) + for int32(1) != 0 { + iMin = libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)<= (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn+**(**int32)(__ccgo_up(bp + 160))+int32(1) { + /* The entire doclist will fit on the current leaf. */ + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), **(**uintptr)(__ccgo_up(bp + 152)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 160)))) + **(**int32)(__ccgo_up(pBuf + 8)) += **(**int32)(__ccgo_up(bp + 160)) + } else { + bTermWritten = libc.BoolInt32(!(bSecureDelete != 0)) + iRowid = 0 + iPrev = 0 + iOff = 0 + /* The entire doclist will not fit on this leaf. The following + ** loop iterates through the poslists that make up the current + ** doclist. */ + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && iOff < **(**int32)(__ccgo_up(bp + 160)) { + **(**Tu64)(__ccgo_up(bp + 168)) = uint64(0) + iOff = iOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, **(**uintptr)(__ccgo_up(bp + 152))+uintptr(iOff), bp+168)) + iRowid = libc.Int64FromUint64(uint64(iRowid) + **(**Tu64)(__ccgo_up(bp + 168))) + /* If in secure delete mode, and if this entry in the poslist is + ** in fact a delete, then edit the existing segments directly + ** using fts5FlushSecureDelete(). */ + if bSecureDelete != 0 { + if eDetail == int32(FTS5_DETAIL_NONE) { + if iOff < **(**int32)(__ccgo_up(bp + 160)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == 0x00 && !(_fts5FlushSecureDelete(tls, p, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 136)), **(**int32)(__ccgo_up(bp + 144)), iRowid) != 0) { + iOff = iOff + 1 + if iOff < **(**int32)(__ccgo_up(bp + 160)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == 0x00 { + iOff = iOff + 1 + **(**int32)(__ccgo_up(bp + 160)) = 0 + } else { + continue + } + } + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff))))&int32(0x01) != 0 && !(_fts5FlushSecureDelete(tls, p, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 136)), **(**int32)(__ccgo_up(bp + 144)), iRowid) != 0) { + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == int32(0x01) { + iOff = iOff + 1 + continue + } + } + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bTermWritten == 0 { + _fts5WriteAppendTerm(tls, p, bp+16, **(**int32)(__ccgo_up(bp + 144)), **(**uintptr)(__ccgo_up(bp + 136))) + bTermWritten = int32(1) + } + if (**(**TFts5SegWriter)(__ccgo_up(bp + 16))).FbFirstRowidInPage != 0 { + _fts5PutU16(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp, libc.Uint16FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)) /* first rowid on page */ + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), libc.Uint64FromInt64(iRowid)) + (**(**TFts5SegWriter)(__ccgo_up(bp + 16))).FbFirstRowidInPage = uint8(0) + _fts5WriteDlidxAppend(tls, p, bp+16, iRowid) + } else { + iRowidDelta = libc.Uint64FromInt64(iRowid) - libc.Uint64FromInt64(iPrev) + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), iRowidDelta) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { + break + } + iPrev = iRowid + if eDetail == int32(FTS5_DETAIL_NONE) { + if iOff < **(**int32)(__ccgo_up(bp + 160)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == 0 { + v2 = pBuf + 8 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(v1))) = uint8(0) + iOff = iOff + 1 + if iOff < **(**int32)(__ccgo_up(bp + 160)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff)))) == 0 { + v2 = pBuf + 8 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(v1))) = uint8(0) + iOff = iOff + 1 + } + } + if (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn >= pgsz { + _fts5WriteFlushLeaf(tls, p, bp+16) + } + } else { + **(**int32)(__ccgo_up(bp + 176)) = 0 + **(**int32)(__ccgo_up(bp + 180)) = 0 + nCopy = _fts5GetPoslistSize(tls, **(**uintptr)(__ccgo_up(bp + 152))+uintptr(iOff), bp+180, bp+176) + if **(**int32)(__ccgo_up(bp + 176)) != 0 && bSecureDelete != 0 { + _sqlite3Fts5BufferAppendVarint(tls, p+60, pBuf, int64(**(**int32)(__ccgo_up(bp + 180)))*int64(2)) + iOff = iOff + nCopy + nCopy = **(**int32)(__ccgo_up(bp + 180)) + } else { + nCopy = nCopy + **(**int32)(__ccgo_up(bp + 180)) + } + if (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn+nCopy <= pgsz { + /* The entire poslist will fit on the current leaf. So copy + ** it in one go. */ + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), **(**uintptr)(__ccgo_up(bp + 152))+uintptr(iOff), libc.Uint64FromInt32(nCopy)) + **(**int32)(__ccgo_up(pBuf + 8)) += nCopy + } else { + /* The entire poslist will not fit on this leaf. So it needs + ** to be broken into sections. The only qualification being + ** that each varint must be stored contiguously. */ + pPoslist = **(**uintptr)(__ccgo_up(bp + 152)) + uintptr(iOff) + iPos = 0 + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + nSpace = pgsz - (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn - (*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn + n = 0 + if nCopy-iPos <= nSpace { + n = nCopy - iPos + } else { + n = _fts5PoslistPrefix(tls, pPoslist+uintptr(iPos), nSpace) + } + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), pPoslist+uintptr(iPos), libc.Uint64FromInt32(n)) + **(**int32)(__ccgo_up(pBuf + 8)) += n + iPos = iPos + n + if (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn >= pgsz { + _fts5WriteFlushLeaf(tls, p, bp+16) + } + if iPos >= nCopy { + break + } + } + } + iOff = iOff + nCopy + } + } + } + /* TODO2: Doclist terminator written here. */ + /* pBuf->p[pBuf->n++] = '\0'; */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _sqlite3Fts5HashScanNext(tls, pHash) + } + } + _fts5WriteFinish(tls, p, bp+16, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) > 0 { + /* Update the Fts5Structure. It is written back to the database by the + ** fts5StructureRelease() call below. */ + if (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnLevel == 0 { + _fts5StructureAddLevel(tls, p+60, bp) + } + _fts5StructureExtendLevel(tls, p+60, **(**uintptr)(__ccgo_up(bp)), 0, int32(1), 0) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + v2 = **(**uintptr)(__ccgo_up(bp)) + 32 + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + pSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 32))).FaSeg + uintptr(v1)*56 + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid = iSegid + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst = int32(1) + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast = **(**int32)(__ccgo_up(bp + 8)) + if (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr > uint64(0) { + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin1 = (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 = (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnEntry = libc.Uint64FromInt32((*TFts5Index)(unsafe.Pointer(p)).FnPendingRow) + (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr = (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnOriginCntr + 1 + } + (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnSegment = (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnSegment + 1 + } + _fts5StructurePromote(tls, p, 0, **(**uintptr)(__ccgo_up(bp))) + } + } + } + _fts5IndexAutomerge(tls, p, bp, **(**int32)(__ccgo_up(bp + 8))+(*TFts5Index)(unsafe.Pointer(p)).FnContentlessDelete) + _fts5IndexCrisismerge(tls, p, bp) + _fts5StructureWrite(tls, p, **(**uintptr)(__ccgo_up(bp))) + _fts5StructureRelease(tls, **(**uintptr)(__ccgo_up(bp))) +} + +func _fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) { + var eStmt int32 + var pData, pNext, pSorter, pTab uintptr + _, _, _, _, _ = eStmt, pData, pNext, pSorter, pTab + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter) + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst) + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt != 0 { + eStmt = _fts5StmtType(tls, pCsr) + _sqlite3Fts5StorageStmtRelease(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, eStmt, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) + } + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 { + pSorter = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter + Xsqlite3_finalize(tls, (*TFts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) + Xsqlite3_free(tls, pSorter) + } + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan != int32(FTS5_PLAN_SOURCE) { + _sqlite3Fts5ExprFree(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + } + pData = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata + for { + if !(pData != 0) { + break + } + pNext = (*TFts5Auxdata)(unsafe.Pointer(pData)).FpNext + if (*TFts5Auxdata)(unsafe.Pointer(pData)).FxDelete != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Auxdata)(unsafe.Pointer(pData)).FxDelete})))(tls, (*TFts5Auxdata)(unsafe.Pointer(pData)).FpPtr) + } + Xsqlite3_free(tls, pData) + goto _1 + _1: + ; + pData = pNext + } + Xsqlite3_finalize(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpRankArgStmt) + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg) + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_FREE_ZRANK) != 0 { + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRank) + Xsqlite3_free(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs) + } + _sqlite3Fts5IndexCloseReader(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) + libc.Xmemset(tls, pCsr+32, 0, uint64(184)-libc.Uint64FromInt64(int64(pCsr+32)-int64(pCsr))) +} + +func _fts5HashAddPoslistSize(tls *libc.TLS, pHash uintptr, p uintptr, p2 uintptr) (r int32) { + var nByte, nData, nPos, nRet, nSz, v2 int32 + var pPtr, v1 uintptr + _, _, _, _, _, _, _, _ = nByte, nData, nPos, nRet, nSz, pPtr, v1, v2 + nRet = 0 + if (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist != 0 { + if p2 != 0 { + v1 = p2 + } else { + v1 = p + } + pPtr = v1 + nData = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if (*TFts5Hash)(unsafe.Pointer(pHash)).FeDetail == int32(FTS5_DETAIL_NONE) { + if (*TFts5HashEntry)(unsafe.Pointer(p)).FbDel != 0 { + v2 = nData + nData = nData + 1 + **(**Tu8)(__ccgo_up(pPtr + uintptr(v2))) = uint8(0x00) + if (*TFts5HashEntry)(unsafe.Pointer(p)).FbContent != 0 { + v2 = nData + nData = nData + 1 + **(**Tu8)(__ccgo_up(pPtr + uintptr(v2))) = uint8(0x00) + } + } + } else { + nSz = nData - (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist - int32(1) /* Size in bytes */ + nPos = nSz*int32(2) + libc.Int32FromUint8((*TFts5HashEntry)(unsafe.Pointer(p)).FbDel) /* Value of nPos field */ + if nPos <= int32(127) { + **(**Tu8)(__ccgo_up(pPtr + uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist))) = libc.Uint8FromInt32(nPos) + } else { + nByte = _sqlite3Fts5GetVarintLen(tls, libc.Uint32FromInt32(nPos)) + libc.Xmemmove(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist+nByte), pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist+int32(1)), libc.Uint64FromInt32(nSz)) + _sqlite3Fts5PutVarint(tls, pPtr+uintptr((*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist), libc.Uint64FromInt32(nPos)) + nData = nData + (nByte - int32(1)) + } + } + nRet = nData - (*TFts5HashEntry)(unsafe.Pointer(p)).FnData + if p2 == uintptr(0) { + (*TFts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = 0 + (*TFts5HashEntry)(unsafe.Pointer(p)).FbDel = uint8(0) + (*TFts5HashEntry)(unsafe.Pointer(p)).FbContent = uint8(0) + (*TFts5HashEntry)(unsafe.Pointer(p)).FnData = nData + } + } + return nRet +} + +// C documentation +// +// /* +// ** Link all tokens from hash table iHash into a list in sorted order. The +// ** tokens are not removed from the hash table. +// */ +func _fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, ppSorted uintptr) (r int32) { + var ap, pEntry, pIter, pList uintptr + var i, iSlot, nMergeSlot int32 + _, _, _, _, _, _, _ = ap, i, iSlot, nMergeSlot, pEntry, pIter, pList + nMergeSlot = int32(32) + **(**uintptr)(__ccgo_up(ppSorted)) = uintptr(0) + ap = Xsqlite3_malloc64(tls, uint64(uint64(8)*libc.Uint64FromInt32(nMergeSlot))) + if !(ap != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, ap, 0, uint64(8)*libc.Uint64FromInt32(nMergeSlot)) + iSlot = 0 + for { + if !(iSlot < (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot) { + break + } + pIter = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iSlot)*8)) + for { + if !(pIter != 0) { + break + } + if pTerm == uintptr(0) || (*TFts5HashEntry)(unsafe.Pointer(pIter)).FnKey >= nTerm && 0 == libc.Xmemcmp(tls, pIter+1*48, pTerm, libc.Uint64FromInt32(nTerm)) { + pEntry = pIter + (*TFts5HashEntry)(unsafe.Pointer(pEntry)).FpScanNext = uintptr(0) + i = 0 + for { + if !(**(**uintptr)(__ccgo_up(ap + uintptr(i)*8)) != 0) { + break + } + pEntry = _fts5HashEntryMerge(tls, pEntry, **(**uintptr)(__ccgo_up(ap + uintptr(i)*8))) + **(**uintptr)(__ccgo_up(ap + uintptr(i)*8)) = uintptr(0) + goto _3 + _3: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up(ap + uintptr(i)*8)) = pEntry + } + goto _2 + _2: + ; + pIter = (*TFts5HashEntry)(unsafe.Pointer(pIter)).FpHashNext + } + goto _1 + _1: + ; + iSlot = iSlot + 1 + } + pList = uintptr(0) + i = 0 + for { + if !(i < nMergeSlot) { + break + } + pList = _fts5HashEntryMerge(tls, pList, **(**uintptr)(__ccgo_up(ap + uintptr(i)*8))) + goto _4 + _4: + ; + i = i + 1 + } + Xsqlite3_free(tls, ap) + **(**uintptr)(__ccgo_up(ppSorted)) = pList + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Resize the hash table by doubling the number of slots. +// */ +func _fts5HashResize(tls *libc.TLS, pHash uintptr) (r int32) { + var apNew, apOld, p uintptr + var i, nNew int32 + var iHash uint32 + _, _, _, _, _, _ = apNew, apOld, i, iHash, nNew, p + nNew = (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot * int32(2) + apOld = (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + apNew = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32(nNew)*uint64(8))) + if !(apNew != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, apNew, 0, libc.Uint64FromInt32(nNew)*uint64(8)) + i = 0 + for { + if !(i < (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot) { + break + } + for **(**uintptr)(__ccgo_up(apOld + uintptr(i)*8)) != 0 { + p = **(**uintptr)(__ccgo_up(apOld + uintptr(i)*8)) + **(**uintptr)(__ccgo_up(apOld + uintptr(i)*8)) = (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext + iHash = _fts5HashKey(tls, nNew, p+1*48, (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey) + (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext = **(**uintptr)(__ccgo_up(apNew + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up(apNew + uintptr(iHash)*8)) = p + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, apOld) + (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot = nNew + (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot = apNew + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Parameter pPos points to a buffer containing a position list, size nPos. +// ** This function filters it according to pColset (which must be non-NULL) +// ** and sets pIter->base.pData/nData to point to the new position list. +// ** If memory is required for the new position list, use buffer pIter->poslist. +// ** Or, if the new position list is a contiguous subset of the input, set +// ** pIter->base.pData/nData to point directly to it. +// ** +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. If an OOM error is encountered, *pRc is set to SQLITE_NOMEM +// ** before returning. +// */ +func _fts5IndexExtractColset(tls *libc.TLS, pRc uintptr, pColset uintptr, pPos uintptr, nPos int32, pIter uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aCopy, p, pEnd, v1 uintptr + var i int32 + var v2 bool + var _ /* iCurrent at bp+0 */ int32 + _, _, _, _, _, _ = aCopy, i, p, pEnd, v1, v2 + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + p = pPos + aCopy = p + pEnd = p + uintptr(nPos) /* One byte past end of position list */ + i = 0 + **(**int32)(__ccgo_up(bp)) = 0 + if (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol > int32(1) && _sqlite3Fts5BufferSize(tls, pRc, pIter+40, libc.Uint32FromInt32(nPos)) != 0 { + return + } + for int32(1) != 0 { + for *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) < **(**int32)(__ccgo_up(bp)) { + i = i + 1 + if i == (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol { + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn + return + } + } + /* Advance pointer p until it points to pEnd or an 0x01 byte that is + ** not part of a varint */ + for p < pEnd && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(p))) != int32(0x01) { + for { + if v2 = p < pEnd; v2 { + v1 = p + p = p + 1 + } + if !(v2 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v1)))&int32(0x80) != 0) { + break + } + } + } + if *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) == **(**int32)(__ccgo_up(bp)) { + if (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol == int32(1) { + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = aCopy + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = int32(int64(p) - int64(aCopy)) + return + } + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(pIter+40)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pIter+40)).Fn), aCopy, libc.Uint64FromInt64(int64(p)-int64(aCopy))) + v1 = pIter + 40 + 8 + *(*int32)(unsafe.Pointer(v1)) = int32(int64(*(*int32)(unsafe.Pointer(v1))) + (int64(p) - int64(aCopy))) + } + if p >= pEnd { + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn + return + } + v1 = p + p = p + 1 + aCopy = v1 + v1 = p + p = p + 1 + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v1))) + if **(**int32)(__ccgo_up(bp))&int32(0x80) != 0 { + p = p - 1 + p = p + uintptr(_sqlite3Fts5GetVarint32(tls, p, bp)) + } + } + } +} + +// C documentation +// +// /* +// ** +// */ +func _fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, pnRem uintptr) { + bp := tls.Alloc(160) + defer tls.Free(160) + var bOldest, bTermWritten, eDetail, flags, i, iSegid, nInput, nMove, nPos, nRem, v1 int32 + var pLvl, pLvlOut, pOld, pSeg, pSegIter, pStruct, pTerm uintptr + var v4 bool + var _ /* nTerm at bp+144 */ int32 + var _ /* pIter at bp+0 */ uintptr + var _ /* term at bp+128 */ TFts5Buffer + var _ /* writer at bp+8 */ TFts5SegWriter + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bOldest, bTermWritten, eDetail, flags, i, iSegid, nInput, nMove, nPos, nRem, pLvl, pLvlOut, pOld, pSeg, pSegIter, pStruct, pTerm, v1, v4 + pStruct = **(**uintptr)(__ccgo_up(ppStruct)) + pLvl = pStruct + 32 + uintptr(iLvl)*16 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if pnRem != 0 { + v1 = **(**int32)(__ccgo_up(pnRem)) + } else { + v1 = 0 + } /* Iterator to read input data */ + nRem = v1 /* True if the output segment is the oldest */ + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail + flags = int32(FTS5INDEX_QUERY_NOOUTPUT) + bTermWritten = 0 /* True if current term already output */ + libc.Xmemset(tls, bp+8, 0, uint64(120)) + libc.Xmemset(tls, bp+128, 0, uint64(16)) + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 { + pLvlOut = pStruct + 32 + uintptr(iLvl+int32(1))*16 + nInput = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge + pSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FaSeg + uintptr((*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg-int32(1))*56 + _fts5WriteInit(tls, p, bp+8, (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid) + (**(**TFts5SegWriter)(__ccgo_up(bp + 8))).Fwriter.Fpgno = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast + int32(1) + (**(**TFts5SegWriter)(__ccgo_up(bp + 8))).FiBtPage = 0 + } else { + iSegid = _fts5AllocateSegid(tls, p, pStruct) + /* Extend the Fts5Structure object as required to ensure the output + ** segment exists. */ + if iLvl == (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel-int32(1) { + _fts5StructureAddLevel(tls, p+60, ppStruct) + pStruct = **(**uintptr)(__ccgo_up(ppStruct)) + } + _fts5StructureExtendLevel(tls, p+60, pStruct, iLvl+int32(1), int32(1), 0) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + pLvl = pStruct + 32 + uintptr(iLvl)*16 + pLvlOut = pStruct + 32 + uintptr(iLvl+int32(1))*16 + _fts5WriteInit(tls, p, bp+8, iSegid) + /* Add the new segment to the output level */ + pSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FaSeg + uintptr((*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg)*56 + (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg + 1 + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst = int32(1) + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid = iSegid + (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment + 1 + /* Read input from all segments in the input level */ + nInput = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg + /* Set the range of origins that will go into the output segment. */ + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnOriginCntr > uint64(0) { + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin1 = (**(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg))).FiOrigin1 + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 = (**(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg-int32(1))*56))).FiOrigin2 + } + } + bOldest = libc.BoolInt32((*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg == int32(1) && (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel == iLvl+int32(2)) + _fts5MultiIterNew(tls, p, pStruct, flags, uintptr(0), uintptr(0), 0, iLvl, nInput, bp) + for { + if !(_fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp))) == 0) { + break + } + pSegIter = **(**uintptr)(__ccgo_up(bp)) + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaFirst + 1*4))).FiFirst)*128 + pTerm = _fts5MultiIterTerm(tls, **(**uintptr)(__ccgo_up(bp)), bp+144) + if v4 = **(**int32)(__ccgo_up(bp + 144)) != (**(**TFts5Buffer)(__ccgo_up(bp + 128))).Fn; !v4 { + if **(**int32)(__ccgo_up(bp + 144)) <= 0 { + v1 = 0 + } else { + v1 = libc.Xmemcmp(tls, pTerm, (**(**TFts5Buffer)(__ccgo_up(bp + 128))).Fp, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 144)))) + } + } + if v4 || v1 != 0 { + if pnRem != 0 && (**(**TFts5SegWriter)(__ccgo_up(bp + 8))).FnLeafWritten > nRem { + break + } + _sqlite3Fts5BufferSet(tls, p+60, bp+128, **(**int32)(__ccgo_up(bp + 144)), pTerm) + bTermWritten = 0 + } + /* Check for key annihilation. */ + if (*TFts5SegIter)(unsafe.Pointer(pSegIter)).FnPos == 0 && (bOldest != 0 || libc.Int32FromUint8((*TFts5SegIter)(unsafe.Pointer(pSegIter)).FbDel) == 0) { + goto _2 + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bTermWritten == 0 { + /* This is a new term. Append a term to the output segment. */ + _fts5WriteAppendTerm(tls, p, bp+8, **(**int32)(__ccgo_up(bp + 144)), pTerm) + bTermWritten = int32(1) + } + /* Append the rowid to the output */ + /* WRITEPOSLISTSIZE */ + _fts5WriteAppendRowid(tls, p, bp+8, _fts5MultiIterRowid(tls, **(**uintptr)(__ccgo_up(bp)))) + if eDetail == int32(FTS5_DETAIL_NONE) { + if (*TFts5SegIter)(unsafe.Pointer(pSegIter)).FbDel != 0 { + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp+8+8+8, libc.Int64FromInt32(0)) + if (*TFts5SegIter)(unsafe.Pointer(pSegIter)).FnPos > 0 { + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp+8+8+8, libc.Int64FromInt32(0)) + } + } + } else { + /* Append the position-list data to the output */ + nPos = (*TFts5SegIter)(unsafe.Pointer(pSegIter)).FnPos*int32(2) + libc.Int32FromUint8((*TFts5SegIter)(unsafe.Pointer(pSegIter)).FbDel) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp+8+8+8, int64(nPos)) + _fts5ChunkIterate(tls, p, pSegIter, bp+8, __ccgo_fp(_fts5MergeChunkCallback)) + } + goto _2 + _2: + ; + _fts5MultiIterNext(tls, p, **(**uintptr)(__ccgo_up(bp)), 0, 0) + } + /* Flush the last leaf page to disk. Set the output segment b-tree height + ** and last leaf page number at the same time. */ + _fts5WriteFinish(tls, p, bp+8, pSeg+8) + if _fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp))) != 0 { + /* Remove the redundant segments from the %_data table */ + i = 0 + for { + if !(i < nInput) { + break + } + pOld = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(i)*56 + **(**Tu64)(__ccgo_up(pSeg + 48)) += (*TFts5StructureSegment)(unsafe.Pointer(pOld)).FnEntry - (*TFts5StructureSegment)(unsafe.Pointer(pOld)).FnEntryTombstone + _fts5DataRemoveSegment(tls, p, pOld) + goto _5 + _5: + ; + i = i + 1 + } + /* Remove the redundant segments from the input level */ + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg != nInput { + nMove = libc.Int32FromUint64(libc.Uint64FromInt32((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg-nInput) * uint64(56)) + libc.Xmemmove(tls, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(nInput)*56, libc.Uint64FromInt32(nMove)) + } + **(**int32)(__ccgo_up(pStruct + 24)) -= nInput + **(**int32)(__ccgo_up(pLvl + 4)) -= nInput + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge = 0 + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast == 0 { + (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg - 1 + (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment - 1 + } + } else { + _fts5TrimSegments(tls, p, **(**uintptr)(__ccgo_up(bp))) + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge = nInput + } + _fts5MultiIterFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3Fts5BufferFree(tls, bp+128) + if pnRem != 0 { + **(**int32)(__ccgo_up(pnRem)) -= (**(**TFts5SegWriter)(__ccgo_up(bp + 8))).FnLeafWritten + } +} + +// C documentation +// +// /* +// ** Array aBuf[] contains nBuf doclists. These are all merged in with the +// ** doclist in buffer p1. +// */ +func _fts5MergePrefixLists(tls *libc.TLS, p uintptr, p1 uintptr, nBuf int32, aBuf uintptr) { + bp := tls.Alloc(1072) + defer tls.Free(1072) + var i, nMerge, nOut, nTail, nTmp int32 + var iLastRowid Ti64 + var pI, pNext, pSave, pThis, pThis1, pX uintptr + var _ /* aMerger at bp+0 */ [16]TPrefixMerger + var _ /* iPrev at bp+1064 */ Ti64 + var _ /* out at bp+1032 */ TFts5Buffer + var _ /* pHead at bp+1024 */ uintptr + var _ /* tmp at bp+1048 */ TFts5Buffer + _, _, _, _, _, _, _, _, _, _, _, _ = i, iLastRowid, nMerge, nOut, nTail, nTmp, pI, pNext, pSave, pThis, pThis1, pX + **(**uintptr)(__ccgo_up(bp + 1024)) = uintptr(0) + nOut = 0 + **(**TFts5Buffer)(__ccgo_up(bp + 1032)) = TFts5Buffer{} + **(**TFts5Buffer)(__ccgo_up(bp + 1048)) = TFts5Buffer{} + iLastRowid = 0 + /* Initialize a doclist-iterator for each input buffer. Arrange them in + ** a linked-list starting at pHead in ascending order of rowid. Avoid + ** linking any iterators already at EOF into the linked list at all. */ + libc.Xmemset(tls, bp, 0, uint64(64)*libc.Uint64FromInt32(nBuf+libc.Int32FromInt32(1))) + **(**uintptr)(__ccgo_up(bp + 1024)) = bp + uintptr(nBuf)*64 + _fts5DoclistIterInit(tls, p1, **(**uintptr)(__ccgo_up(bp + 1024))) + i = 0 + for { + if !(i < nBuf) { + break + } + _fts5DoclistIterInit(tls, aBuf+uintptr(i)*16, bp+uintptr(i)*64) + _fts5PrefixMergerInsertByRowid(tls, bp+1024, bp+uintptr(i)*64) + nOut = nOut + (**(**TFts5Buffer)(__ccgo_up(aBuf + uintptr(i)*16))).Fn + goto _1 + _1: + ; + i = i + 1 + } + if nOut == 0 { + return + } + nOut = nOut + ((*TFts5Buffer)(unsafe.Pointer(p1)).Fn + int32(9) + int32(10)*nBuf) + /* The maximum size of the output is equal to the sum of the + ** input sizes + 1 varint (9 bytes). The extra varint is because if the + ** first rowid in one input is a large negative number, and the first in + ** the other a non-negative number, the delta for the non-negative + ** number will be larger on disk than the literal integer value + ** was. + ** + ** Or, if the input position-lists are corrupt, then the output might + ** include up to (nBuf+1) extra 10-byte positions created by interpreting -1 + ** (the value PoslistNext64() uses for EOF) as a position and appending + ** it to the output. This can happen at most once for each input + ** position-list, hence (nBuf+1) 10 byte paddings. */ + if _sqlite3Fts5BufferSize(tls, p+60, bp+1032, libc.Uint32FromInt32(nOut)) != 0 { + return + } + for **(**uintptr)(__ccgo_up(bp + 1024)) != 0 { + **(**int32)(__ccgo_up(bp + 1032 + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), libc.Uint64FromInt64((*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).Fiter.FiRowid)-libc.Uint64FromInt64(iLastRowid)) + iLastRowid = (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).Fiter.FiRowid + if (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FpNext != 0 && iLastRowid == (*TPrefixMerger)(unsafe.Pointer((*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FpNext)).Fiter.FiRowid { + /* Merge data from two or more poslists */ + **(**Ti64)(__ccgo_up(bp + 1064)) = 0 + nTmp = int32(FTS5_DATA_ZERO_PADDING) + nMerge = 0 + pSave = **(**uintptr)(__ccgo_up(bp + 1024)) + pThis = uintptr(0) + nTail = 0 + **(**uintptr)(__ccgo_up(bp + 1024)) = uintptr(0) + for pSave != 0 && (*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FiRowid == iLastRowid { + pNext = (*TPrefixMerger)(unsafe.Pointer(pSave)).FpNext + (*TPrefixMerger)(unsafe.Pointer(pSave)).FiOff = 0 + (*TPrefixMerger)(unsafe.Pointer(pSave)).FiPos = 0 + (*TPrefixMerger)(unsafe.Pointer(pSave)).FaPos = (*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FaPoslist + uintptr((*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnSize) + _sqlite3Fts5PoslistNext64(tls, (*TPrefixMerger)(unsafe.Pointer(pSave)).FaPos, (*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnPoslist, pSave+40, pSave+32) + nTmp = nTmp + ((*TPrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnPoslist + int32(10)) + nMerge = nMerge + 1 + _fts5PrefixMergerInsertByPosition(tls, bp+1024, pSave) + pSave = pNext + } + if **(**uintptr)(__ccgo_up(bp + 1024)) == uintptr(0) || (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FpNext == uintptr(0) { + _fts5IndexCorruptIdx(tls, p) + break + } + /* See the earlier comment in this function for an explanation of why + ** corrupt input position lists might cause the output to consume + ** at most nMerge*10 bytes of unexpected space. */ + if _sqlite3Fts5BufferSize(tls, p+60, bp+1048, libc.Uint32FromInt32(nTmp+nMerge*int32(10))) != 0 { + break + } + _sqlite3Fts5BufferZero(tls, bp+1048) + pThis = **(**uintptr)(__ccgo_up(bp + 1024)) + **(**uintptr)(__ccgo_up(bp + 1024)) = (*TPrefixMerger)(unsafe.Pointer(pThis)).FpNext + _sqlite3Fts5PoslistSafeAppend(tls, bp+1048, bp+1064, (*TPrefixMerger)(unsafe.Pointer(pThis)).FiPos) + _sqlite3Fts5PoslistNext64(tls, (*TPrefixMerger)(unsafe.Pointer(pThis)).FaPos, (*TPrefixMerger)(unsafe.Pointer(pThis)).Fiter.FnPoslist, pThis+40, pThis+32) + _fts5PrefixMergerInsertByPosition(tls, bp+1024, pThis) + for (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FpNext != 0 { + pThis = **(**uintptr)(__ccgo_up(bp + 1024)) + if (*TPrefixMerger)(unsafe.Pointer(pThis)).FiPos != **(**Ti64)(__ccgo_up(bp + 1064)) { + _sqlite3Fts5PoslistSafeAppend(tls, bp+1048, bp+1064, (*TPrefixMerger)(unsafe.Pointer(pThis)).FiPos) + } + _sqlite3Fts5PoslistNext64(tls, (*TPrefixMerger)(unsafe.Pointer(pThis)).FaPos, (*TPrefixMerger)(unsafe.Pointer(pThis)).Fiter.FnPoslist, pThis+40, pThis+32) + **(**uintptr)(__ccgo_up(bp + 1024)) = (*TPrefixMerger)(unsafe.Pointer(pThis)).FpNext + _fts5PrefixMergerInsertByPosition(tls, bp+1024, pThis) + } + if (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FiPos != **(**Ti64)(__ccgo_up(bp + 1064)) { + _sqlite3Fts5PoslistSafeAppend(tls, bp+1048, bp+1064, (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FiPos) + } + nTail = (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).Fiter.FnPoslist - (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FiOff + /* WRITEPOSLISTSIZE */ + if (**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fn+nTail > nTmp-int32(FTS5_DATA_ZERO_PADDING) { + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _fts5IndexCorruptIdx(tls, p) + } + break + } + **(**int32)(__ccgo_up(bp + 1032 + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), libc.Uint64FromInt32(((**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fn+nTail)*libc.Int32FromInt32(2))) + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), (**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fp, libc.Uint64FromInt32((**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fn)) + **(**int32)(__ccgo_up(bp + 1032 + 8)) += (**(**TFts5Buffer)(__ccgo_up(bp + 1048))).Fn + if nTail > 0 { + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FaPos+uintptr((*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 1024)))).FiOff), libc.Uint64FromInt32(nTail)) + **(**int32)(__ccgo_up(bp + 1032 + 8)) += nTail + } + **(**uintptr)(__ccgo_up(bp + 1024)) = pSave + i = 0 + for { + if !(i < nBuf+int32(1)) { + break + } + pX = bp + uintptr(i)*64 + if (*TPrefixMerger)(unsafe.Pointer(pX)).Fiter.FaPoslist != 0 && (*TPrefixMerger)(unsafe.Pointer(pX)).Fiter.FiRowid == iLastRowid { + _fts5DoclistIterNext(tls, pX) + _fts5PrefixMergerInsertByRowid(tls, bp+1024, pX) + } + goto _2 + _2: + ; + i = i + 1 + } + } else { + /* Copy poslist from pHead to output */ + pThis1 = **(**uintptr)(__ccgo_up(bp + 1024)) + pI = pThis1 + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+1032)).Fn), (*TFts5DoclistIter)(unsafe.Pointer(pI)).FaPoslist, libc.Uint64FromInt32((*TFts5DoclistIter)(unsafe.Pointer(pI)).FnPoslist+(*TFts5DoclistIter)(unsafe.Pointer(pI)).FnSize)) + **(**int32)(__ccgo_up(bp + 1032 + 8)) += (*TFts5DoclistIter)(unsafe.Pointer(pI)).FnPoslist + (*TFts5DoclistIter)(unsafe.Pointer(pI)).FnSize + _fts5DoclistIterNext(tls, pI) + **(**uintptr)(__ccgo_up(bp + 1024)) = (*TPrefixMerger)(unsafe.Pointer(pThis1)).FpNext + _fts5PrefixMergerInsertByRowid(tls, bp+1024, pThis1) + } + } + _sqlite3Fts5BufferFree(tls, p1) + _sqlite3Fts5BufferFree(tls, bp+1048) + libc.Xmemset(tls, (**(**TFts5Buffer)(__ccgo_up(bp + 1032))).Fp+uintptr((**(**TFts5Buffer)(__ccgo_up(bp + 1032))).Fn), 0, uint64(FTS5_DATA_ZERO_PADDING)) + **(**TFts5Buffer)(__ccgo_up(p1)) = **(**TFts5Buffer)(__ccgo_up(bp + 1032)) +} + +// C documentation +// +// /* +// ** This is the equivalent of fts5MergePrefixLists() for detail=none mode. +// ** In this case the buffers consist of a delta-encoded list of rowids only. +// */ +func _fts5MergeRowidLists(tls *libc.TLS, p uintptr, p1 uintptr, nBuf int32, aBuf uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iOut Ti64 + var p2 uintptr + var _ /* i1 at bp+0 */ int32 + var _ /* i2 at bp+4 */ int32 + var _ /* iRowid1 at bp+8 */ Ti64 + var _ /* iRowid2 at bp+16 */ Ti64 + var _ /* out at bp+24 */ TFts5Buffer + _, _ = iOut, p2 + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**Ti64)(__ccgo_up(bp + 8)) = 0 + **(**Ti64)(__ccgo_up(bp + 16)) = 0 + iOut = 0 + p2 = aBuf + _ = nBuf + libc.Xmemset(tls, bp+24, 0, uint64(16)) + _sqlite3Fts5BufferSize(tls, p+60, bp+24, libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(p1)).Fn+(*TFts5Buffer)(unsafe.Pointer(p2)).Fn)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + _fts5NextRowid(tls, p1, bp, bp+8) + _fts5NextRowid(tls, p2, bp+4, bp+16) + for **(**int32)(__ccgo_up(bp)) >= 0 || **(**int32)(__ccgo_up(bp + 4)) >= 0 { + if **(**int32)(__ccgo_up(bp)) >= 0 && (**(**int32)(__ccgo_up(bp + 4)) < 0 || **(**Ti64)(__ccgo_up(bp + 8)) < **(**Ti64)(__ccgo_up(bp + 16))) { + **(**int32)(__ccgo_up(bp + 24 + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp+24)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+24)).Fn), libc.Uint64FromInt64(**(**Ti64)(__ccgo_up(bp + 8))-iOut)) + iOut = **(**Ti64)(__ccgo_up(bp + 8)) + _fts5NextRowid(tls, p1, bp, bp+8) + } else { + **(**int32)(__ccgo_up(bp + 24 + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(bp+24)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(bp+24)).Fn), libc.Uint64FromInt64(**(**Ti64)(__ccgo_up(bp + 16))-iOut)) + iOut = **(**Ti64)(__ccgo_up(bp + 16)) + if **(**int32)(__ccgo_up(bp)) >= 0 && **(**Ti64)(__ccgo_up(bp + 8)) == **(**Ti64)(__ccgo_up(bp + 16)) { + _fts5NextRowid(tls, p1, bp, bp+8) + } + _fts5NextRowid(tls, p2, bp+4, bp+16) + } + } + _fts5BufferSwap(tls, bp+24, p1) + _sqlite3Fts5BufferFree(tls, bp+24) +} + +// C documentation +// +// /* +// ** This function is used by xCreateTokenizer_v2() and xCreateTokenizer(). +// ** It allocates and partially populates a new Fts5TokenizerModule object. +// ** The new object is already linked into the Fts5Global context before +// ** returning. +// ** +// ** If successful, SQLITE_OK is returned and a pointer to the new +// ** Fts5TokenizerModule object returned via output parameter (*ppNew). All +// ** that is required is for the caller to fill in the methods in +// ** Fts5TokenizerModule.x1 and x2, and to set Fts5TokenizerModule.bV2Native +// ** as appropriate. +// ** +// ** If an error occurs, an SQLite error code is returned and the final value +// ** of (*ppNew) undefined. +// */ +func _fts5NewTokenizerModule(tls *libc.TLS, pGlobal uintptr, zName uintptr, pUserData uintptr, __ccgo_fp_xDestroy uintptr, ppNew uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte, nName Tsqlite3_int64 + var pNew, v1 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _ = nByte, nName, pNew, v1 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Bytes of space to allocate */ + nName = libc.Int64FromUint64(libc.Xstrlen(tls, zName) + uint64(1)) + nByte = libc.Int64FromUint64(uint64(96) + libc.Uint64FromInt64(nName)) + v1 = _sqlite3Fts5MallocZero(tls, bp, nByte) + pNew = v1 + **(**uintptr)(__ccgo_up(ppNew)) = v1 + if pNew != 0 { + (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FzName = pNew + 1*96 + libc.Xmemcpy(tls, (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FzName, zName, libc.Uint64FromInt64(nName)) + (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FpUserData = pUserData + (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FxDestroy = __ccgo_fp_xDestroy + (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FpNext = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpTok + (*TFts5Global)(unsafe.Pointer(pGlobal)).FpTok = pNew + if (*TFts5TokenizerModule)(unsafe.Pointer(pNew)).FpNext == uintptr(0) { + (*TFts5Global)(unsafe.Pointer(pGlobal)).FpDfltTok = pNew + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Implementation of xOpen method. +// */ +func _fts5OpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) (r int32) { + var nByte Tsqlite3_int64 + var pConfig, pCsr, pGlobal, pTab, v2 uintptr + var rc int32 + var v1 Ti64 + _, _, _, _, _, _, _, _ = nByte, pConfig, pCsr, pGlobal, pTab, rc, v1, v2 + pTab = pVTab + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + pCsr = uintptr(0) /* Return code */ + rc = _fts5NewTransaction(tls, pTab) + if rc == SQLITE_OK { + nByte = libc.Int64FromUint64(uint64(184) + libc.Uint64FromInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)*uint64(4)) + pCsr = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pCsr != 0 { + pGlobal = (*TFts5FullTable)(unsafe.Pointer(pTab)).FpGlobal + libc.Xmemset(tls, pCsr, 0, libc.Uint64FromInt64(nByte)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize = pCsr + 1*184 + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpNext = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpCsr + (*TFts5Global)(unsafe.Pointer(pGlobal)).FpCsr = pCsr + v2 = pGlobal + 56 + *(*Ti64)(unsafe.Pointer(v2)) = *(*Ti64)(unsafe.Pointer(v2)) + 1 + v1 = *(*Ti64)(unsafe.Pointer(v2)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId = v1 + } else { + rc = int32(SQLITE_NOMEM) + } + } + **(**uintptr)(__ccgo_up(ppCsr)) = pCsr + return rc +} + +// C documentation +// +// /* +// ** Callback for tokenizing terms used by ParseTerm(). +// */ +func _fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var SZALLOC, nNew, v1 int32 + var nByte Tsqlite3_int64 + var pCtx, pNew, pPhrase, pSyn, pTerm, v3 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = SZALLOC, nByte, nNew, pCtx, pNew, pPhrase, pSyn, pTerm, v1, v3 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + SZALLOC = int32(8) + pCtx = pContext + pPhrase = (*TTokenCtx)(unsafe.Pointer(pCtx)).FpPhrase + _ = iUnused1 + _ = iUnused2 + /* If an error has already occurred, this is a no-op */ + if (*TTokenCtx)(unsafe.Pointer(pCtx)).Frc != SQLITE_OK { + return (*TTokenCtx)(unsafe.Pointer(pCtx)).Frc + } + if nToken > int32(FTS5_MAX_TOKEN_SIZE) { + nToken = int32(FTS5_MAX_TOKEN_SIZE) + } + if pPhrase != 0 && (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0 && tflags&int32(FTS5_TOKEN_COLOCATED) != 0 { + nByte = libc.Int64FromUint64(libc.Uint64FromInt64(40) + libc.Uint64FromInt64(16) + libc.Uint64FromInt32(nToken) + uint64(1)) + pSyn = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pSyn == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pSyn, 0, libc.Uint64FromInt64(nByte)) + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpTerm = pSyn + uintptr(40) + uintptr(16) + v1 = nToken + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FnQueryTerm = v1 + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FnFullTerm = v1 + if (*TFts5Config)(unsafe.Pointer((*TTokenCtx)(unsafe.Pointer(pCtx)).FpConfig)).FbTokendata != 0 { + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FnQueryTerm = libc.Int32FromUint64(libc.Xstrlen(tls, (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpTerm)) + } + libc.Xmemcpy(tls, (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpTerm, pToken, libc.Uint64FromInt32(nToken)) + (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpSynonym = (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32 + uintptr((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm-int32(1))*40))).FpSynonym + (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32 + uintptr((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm-int32(1))*40))).FpSynonym = pSyn + } + } else { + if pPhrase == uintptr(0) || (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm%SZALLOC == 0 { + if pPhrase != 0 { + v1 = (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm + } else { + v1 = 0 + } + nNew = SZALLOC + v1 + pNew = Xsqlite3_realloc64(tls, pPhrase, uint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(nNew+libc.Int32FromInt32(1))*libc.Uint64FromInt64(40))) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + } else { + if pPhrase == uintptr(0) { + libc.Xmemset(tls, pNew, 0, uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(40)) + } + v3 = pNew + pPhrase = v3 + (*TTokenCtx)(unsafe.Pointer(pCtx)).FpPhrase = v3 + (*TFts5ExprPhrase)(unsafe.Pointer(pNew)).FnTerm = nNew - SZALLOC + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + v3 = pPhrase + 24 + v1 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + pTerm = pPhrase + 32 + uintptr(v1)*40 + libc.Xmemset(tls, pTerm, 0, uint64(40)) + (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpTerm = _sqlite3Fts5Strndup(tls, bp, pToken, nToken) + v1 = nToken + (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FnQueryTerm = v1 + (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FnFullTerm = v1 + if (*TFts5Config)(unsafe.Pointer((*TTokenCtx)(unsafe.Pointer(pCtx)).FpConfig)).FbTokendata != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FnQueryTerm = libc.Int32FromUint64(libc.Xstrlen(tls, (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpTerm)) + } + } + } + (*TTokenCtx)(unsafe.Pointer(pCtx)).Frc = **(**int32)(__ccgo_up(bp)) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Return a "position-list blob" corresponding to the current position of +// ** cursor pCsr via sqlite3_result_blob(). A position-list blob contains +// ** the current position-list for each phrase in the query associated with +// ** cursor pCsr. +// ** +// ** A position-list blob begins with (nPhrase-1) varints, where nPhrase is +// ** the number of phrases in the query. Following the varints are the +// ** concatenated position lists for each phrase, in order. +// ** +// ** The first varint (if it exists) contains the size of the position list +// ** for phrase 0. The second (same disclaimer) contains the size of position +// ** list 1. And so on. There is no size field for the final position list, +// ** as it can be derived from the total size of the blob. +// */ +func _fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var i, nByte, nPhrase, nPoslist int32 + var _ /* dummy at bp+24 */ uintptr + var _ /* dummy at bp+40 */ uintptr + var _ /* nByte at bp+48 */ int32 + var _ /* nPoslist at bp+64 */ int32 + var _ /* pPoslist at bp+32 */ uintptr + var _ /* pPoslist at bp+56 */ uintptr + var _ /* rc at bp+0 */ int32 + var _ /* val at bp+8 */ TFts5Buffer + _, _, _, _ = i, nByte, nPhrase, nPoslist + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + nPhrase = _sqlite3Fts5ExprPhraseCount(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + libc.Xmemset(tls, bp+8, 0, uint64(16)) + switch (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FeDetail { + case FTS5_DETAIL_FULL: + goto _1 + case int32(FTS5_DETAIL_COLUMNS): + goto _2 + default: + goto _3 + } + goto _4 +_1: + ; + /* Append the varints */ + i = 0 +_7: + ; + if !(i < nPhrase-int32(1)) { + goto _5 + } + nByte = _sqlite3Fts5ExprPoslist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+24) + _sqlite3Fts5BufferAppendVarint(tls, bp, bp+8, int64(nByte)) + goto _6 +_6: + ; + i = i + 1 + goto _7 + goto _5 +_5: + ; + /* Append the position lists */ + i = 0 + for { + if !(i < nPhrase) { + break + } + nPoslist = _sqlite3Fts5ExprPoslist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+32) + _sqlite3Fts5BufferAppendBlob(tls, bp, bp+8, libc.Uint32FromInt32(nPoslist), **(**uintptr)(__ccgo_up(bp + 32))) + goto _8 + _8: + ; + i = i + 1 + } + goto _4 +_2: + ; + /* Append the varints */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < nPhrase-int32(1)) { + break + } + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ExprPhraseCollist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+40, bp+48) + _sqlite3Fts5BufferAppendVarint(tls, bp, bp+8, int64(**(**int32)(__ccgo_up(bp + 48)))) + goto _9 + _9: + ; + i = i + 1 + } + /* Append the position lists */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < nPhrase) { + break + } + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ExprPhraseCollist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+56, bp+64) + _sqlite3Fts5BufferAppendBlob(tls, bp, bp+8, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 64))), **(**uintptr)(__ccgo_up(bp + 56))) + goto _10 + _10: + ; + i = i + 1 + } + goto _4 +_3: + ; + goto _4 +_4: + ; + Xsqlite3_result_blob(tls, pCtx, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fn, __ccgo_fp(Xsqlite3_free)) + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5PoslistCallback(tls *libc.TLS, pUnused uintptr, pContext uintptr, pChunk uintptr, nChunk int32) { + _ = pUnused + if nChunk > 0 { + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer(pContext)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pContext)).Fn), pChunk, libc.Uint64FromInt32(nChunk)) + **(**int32)(__ccgo_up(pContext + 8)) += nChunk + } +} + +func _fts5PoslistFilterCallback(tls *libc.TLS, pUnused uintptr, pContext uintptr, pChunk uintptr, nChunk int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iEnd, iStart, v1 int32 + var pCtx uintptr + var _ /* iCol at bp+0 */ int32 + var _ /* iCol at bp+4 */ int32 + _, _, _, _, _ = i, iEnd, iStart, pCtx, v1 + pCtx = pContext + _ = pUnused + if nChunk > 0 { + /* Search through to find the first varint with value 1. This is the + ** start of the next columns hits. */ + i = 0 + iStart = 0 + if (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState == int32(2) { + v1 = i + i = i + 1 + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pChunk + uintptr(v1)))) + if **(**int32)(__ccgo_up(bp))&int32(0x80) != 0 { + i = i - 1 + i = i + _sqlite3Fts5GetVarint32(tls, pChunk+uintptr(i), bp) + } + if _fts5IndexColsetTest(tls, (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpColset, **(**int32)(__ccgo_up(bp))) != 0 { + (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = int32(1) + **(**int32)(__ccgo_up((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), libc.Uint64FromInt32(libc.Int32FromInt32(1))) + } else { + (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = 0 + } + } + for cond := true; cond; cond = i < nChunk { + for i < nChunk && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pChunk + uintptr(i)))) != int32(0x01) { + iEnd = i + int32(9) + for { + v1 = i + i = i + 1 + if !(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pChunk + uintptr(v1))))&int32(0x80) != 0 && i < iEnd) { + break + } + } + } + if (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState != 0 { + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), pChunk+uintptr(iStart), libc.Uint64FromInt32(i-iStart)) + **(**int32)(__ccgo_up((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 8)) += i - iStart + } + if i < nChunk { + iStart = i + i = i + 1 + if i >= nChunk { + (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = int32(2) + } else { + v1 = i + i = i + 1 + **(**int32)(__ccgo_up(bp + 4)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pChunk + uintptr(v1)))) + if **(**int32)(__ccgo_up(bp + 4))&int32(0x80) != 0 { + i = i - 1 + i = i + _sqlite3Fts5GetVarint32(tls, pChunk+uintptr(i), bp+4) + } + (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = _fts5IndexColsetTest(tls, (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpColset, **(**int32)(__ccgo_up(bp + 4))) + if (*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState != 0 { + libc.Xmemcpy(tls, (*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), pChunk+uintptr(iStart), libc.Uint64FromInt32(i-iStart)) + **(**int32)(__ccgo_up((*TPoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 8)) += i - iStart + iStart = i + } + } + } + } + } +} + +// C documentation +// +// /* +// ** This is called when a secure-delete operation removes a position-list +// ** that overflows onto segment page iPgno of segment pSeg. This function +// ** rewrites node iPgno, and possibly one or more of its right-hand peers, +// ** to remove this portion of the position list. +// ** +// ** Output variable (*pbLastInDoclist) is set to true if the position-list +// ** removed is followed by a new term or the end-of-segment, or false if +// ** it is followed by another rowid/position list. +// */ +func _fts5SecureDeleteOverflow(tls *libc.TLS, p uintptr, pSeg uintptr, iPgno int32, pbLastInDoclist uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aIdx, aPg, pLeaf uintptr + var bDetailNone, i1, i2, nIdx, nPg, nShift, pgno int32 + var iRowid Ti64 + var _ /* aEmpty at bp+4 */ [4]Tu8 + var _ /* iFirst at bp+8 */ int32 + var _ /* iNext at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = aIdx, aPg, bDetailNone, i1, i2, iRowid, nIdx, nPg, nShift, pLeaf, pgno + bDetailNone = libc.BoolInt32((*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == libc.Int32FromInt32(FTS5_DETAIL_NONE)) + pLeaf = uintptr(0) + **(**int32)(__ccgo_up(pbLastInDoclist)) = int32(1) + pgno = iPgno + for { + if !((*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && pgno <= (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast) { + break + } + iRowid = int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf || (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn < (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf || **(**int32)(__ccgo_up(bp)) < int32(4) { + _fts5IndexCorruptRowid(tls, p, iRowid) + break + } else { + nShift = **(**int32)(__ccgo_up(bp)) - int32(4) + nIdx = 0 + aIdx = uintptr(0) + /* Unless the current page footer is 0 bytes in size (in which case + ** the new page footer will be as well), allocate and populate a + ** buffer containing the new page footer. Set stack variables aIdx + ** and nIdx accordingly. */ + if (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn > (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + **(**int32)(__ccgo_up(bp + 8)) = 0 + i1 = (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf + i2 = 0 + i1 = i1 + _sqlite3Fts5GetVarint32(tls, aPg+uintptr(i1), bp+8) + if **(**int32)(__ccgo_up(bp + 8)) < **(**int32)(__ccgo_up(bp)) { + _fts5IndexCorruptRowid(tls, p, iRowid) + break + } + aIdx = _sqlite3Fts5MallocZero(tls, p+60, int64((*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn-(*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf+int32(2))) + if aIdx == uintptr(0) { + break + } + i2 = _sqlite3Fts5PutVarint(tls, aIdx, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 8))-nShift)) + if i1 < (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn { + libc.Xmemcpy(tls, aIdx+uintptr(i2), aPg+uintptr(i1), libc.Uint64FromInt32((*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn-i1)) + i2 = i2 + ((*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn - i1) + } + nIdx = i2 + } + /* Modify the contents of buffer aPg[]. Set nPg to the new size + ** in bytes. The new page is always smaller than the old. */ + nPg = (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf - nShift + libc.Xmemmove(tls, aPg+4, aPg+uintptr(int32(4)+nShift), libc.Uint64FromInt32(nPg-int32(4))) + _fts5PutU16(tls, aPg+2, libc.Uint16FromInt32(nPg)) + if _fts5GetU16(tls, aPg) != 0 { + _fts5PutU16(tls, aPg, uint16(4)) + } + if nIdx > 0 { + libc.Xmemcpy(tls, aPg+uintptr(nPg), aIdx, libc.Uint64FromInt32(nIdx)) + nPg = nPg + nIdx + } + Xsqlite3_free(tls, aIdx) + /* Write the new page to disk and exit the loop */ + _fts5DataWrite(tls, p, iRowid, aPg, nPg) + break + } + } + } + goto _1 + _1: + ; + pgno = pgno + 1 + } + _fts5DataRelease(tls, pLeaf) +} + +// C documentation +// +// /* +// ** Iterator pIter currently points to a valid entry (not EOF). This +// ** function appends the position list data for the current entry to +// ** buffer pBuf. It does not make a copy of the position-list size +// ** field. +// */ +func _fts5SegiterPoslist(tls *libc.TLS, p uintptr, pSeg uintptr, pColset uintptr, pBuf uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var v1 int32 + var _ /* sCtx at bp+0 */ TPoslistCallbackCtx + var _ /* sCtx at bp+24 */ TPoslistOffsetsCtx + _ = v1 + if libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)+libc.Uint32FromInt32((*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos+libc.Int32FromInt32(FTS5_DATA_ZERO_PADDING)) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) { + v1 = 0 + } else { + v1 = _sqlite3Fts5BufferSize(tls, p+60, pBuf, libc.Uint32FromInt32((*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos+int32(FTS5_DATA_ZERO_PADDING)+(*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + } + if 0 == v1 { + libc.Xmemset(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos), 0, uint64(FTS5_DATA_ZERO_PADDING)) + if pColset == uintptr(0) { + _fts5ChunkIterate(tls, p, pSeg, pBuf, __ccgo_fp(_fts5PoslistCallback)) + } else { + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_FULL { + (**(**TPoslistCallbackCtx)(__ccgo_up(bp))).FpBuf = pBuf + (**(**TPoslistCallbackCtx)(__ccgo_up(bp))).FpColset = pColset + (**(**TPoslistCallbackCtx)(__ccgo_up(bp))).FeState = _fts5IndexColsetTest(tls, pColset, 0) + _fts5ChunkIterate(tls, p, pSeg, bp, __ccgo_fp(_fts5PoslistFilterCallback)) + } else { + libc.Xmemset(tls, bp+24, 0, uint64(24)) + (**(**TPoslistOffsetsCtx)(__ccgo_up(bp + 24))).FpBuf = pBuf + (**(**TPoslistOffsetsCtx)(__ccgo_up(bp + 24))).FpColset = pColset + _fts5ChunkIterate(tls, p, pSeg, bp+24, __ccgo_fp(_fts5PoslistOffsetsCallback)) + } + } + } +} + +func _fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, iIdx int32, pToken uintptr, nToken int32, pColset uintptr, ppIter uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var i, iFree, v3 int32 + var pCtx, pData, pStruct uintptr + var _ /* s at bp+0 */ TPrefixSetupCtx + var _ /* s2 at bp+72 */ TTokendataSetupCtx + _, _, _, _, _, _ = i, iFree, pCtx, pData, pStruct, v3 + libc.Xmemset(tls, bp, 0, uint64(72)) + libc.Xmemset(tls, bp+72, 0, uint64(16)) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge = int32(1) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FiLastRowid = 0 + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnBuf = int32(32) + if iIdx == 0 && (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_FULL && (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FbPrefixInsttoken != 0 { + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FpTokendata = bp + 72 + (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT = _fts5IdxMalloc(tls, p, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+72)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(104))) + } + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxMerge = __ccgo_fp(_fts5MergeRowidLists) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxAppend = __ccgo_fp(_fts5AppendRowid) + } else { + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge = libc.Int32FromInt32(FTS5_MERGE_NLIST) - libc.Int32FromInt32(1) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnBuf = (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge * int32(8) /* Sufficient to merge (16^8)==(2^32) lists */ + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxMerge = __ccgo_fp(_fts5MergePrefixLists) + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxAppend = __ccgo_fp(_fts5AppendPoslist) + } + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FaBuf = _fts5IdxMalloc(tls, p, libc.Int64FromUint64(uint64(16)*libc.Uint64FromInt32((**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnBuf))) + pStruct = _fts5StructureRead(tls, p) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pCtx = bp + /* If iIdx is non-zero, then it is the number of a prefix-index for + ** prefixes 1 character longer than the prefix being queried for. That + ** index contains all the doclists required, except for the one + ** corresponding to the prefix itself. That one is extracted from the + ** main term index here. */ + if iIdx != 0 { + **(**Tu8)(__ccgo_up(pToken)) = uint8('0') + _fts5VisitEntries(tls, p, pColset, pToken, nToken, 0, __ccgo_fp(_prefixIterSetupCb), pCtx) + } + **(**Tu8)(__ccgo_up(pToken)) = libc.Uint8FromInt32(int32('0') + iIdx) + _fts5VisitEntries(tls, p, pColset, pToken, nToken, int32(1), __ccgo_fp(_prefixIterSetupCb), pCtx) + i = 0 + for { + if !(i < (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnBuf) { + break + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(**(**TPrefixSetupCtx)(__ccgo_up(bp))).FxMerge})))(tls, p, bp+48, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FaBuf+uintptr(i)*16) + } + iFree = i + for { + if !(iFree < i+(**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge) { + break + } + _sqlite3Fts5BufferFree(tls, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FaBuf+uintptr(iFree)*16) + goto _2 + _2: + ; + iFree = iFree + 1 + } + goto _1 + _1: + ; + i = i + (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FnMerge + } + pData = _fts5IdxMalloc(tls, p, libc.Int64FromUint64(uint64(16)+libc.Uint64FromInt64(int64((**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fn))+uint64(FTS5_DATA_ZERO_PADDING))) + if pData != 0 { + (*TFts5Data)(unsafe.Pointer(pData)).Fp = pData + 1*16 + v3 = (**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fn + (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf = v3 + (*TFts5Data)(unsafe.Pointer(pData)).Fnn = v3 + if (**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fn != 0 { + libc.Xmemcpy(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fp, libc.Uint64FromInt32((**(**TPrefixSetupCtx)(__ccgo_up(bp))).Fdoclist.Fn)) + } + _fts5MultiIterNew2(tls, p, pData, bDesc, ppIter) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FpTokendata != 0 { + _fts5TokendataIterSortMap(tls, p, (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT) + (*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppIter)))).FpTokenDataIter = (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT + (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT = uintptr(0) + } + } + _fts5TokendataIterDelete(tls, (**(**TTokendataSetupCtx)(__ccgo_up(bp + 72))).FpT) + _sqlite3Fts5BufferFree(tls, bp+48) + _fts5StructureRelease(tls, pStruct) + Xsqlite3_free(tls, (**(**TPrefixSetupCtx)(__ccgo_up(bp))).FaBuf) +} + +// C documentation +// +// /* +// ** pIter is a prefix query. This function populates pIter->pTokenDataIter +// ** with an Fts5TokenDataIter object containing mappings for all rows +// ** matched by the query. +// */ +func _fts5SetupPrefixIterTokendata(tls *libc.TLS, pIter uintptr, pToken uintptr, nToken int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p uintptr + var _ /* ctx at bp+16 */ TTokendataSetupCtx + var _ /* token at bp+0 */ TFts5Buffer + _ = p + p = (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex + **(**TFts5Buffer)(__ccgo_up(bp)) = TFts5Buffer{} + libc.Xmemset(tls, bp+16, 0, uint64(16)) + if !(libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(bp)).Fn)+libc.Uint32FromInt32(nToken+libc.Int32FromInt32(1)) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(bp)).FnSpace)) { + _sqlite3Fts5BufferSize(tls, p+60, bp, libc.Uint32FromInt32(nToken+int32(1)+(*TFts5Buffer)(unsafe.Pointer(bp)).Fn)) + } + (**(**TTokendataSetupCtx)(__ccgo_up(bp + 16))).FpT = _sqlite3Fts5MallocZero(tls, p+60, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+72)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(104))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* Fill in the token prefix to search for */ + **(**Tu8)(__ccgo_up((**(**TFts5Buffer)(__ccgo_up(bp))).Fp)) = uint8('0') + libc.Xmemcpy(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp+1, pToken, libc.Uint64FromInt32(nToken)) + (**(**TFts5Buffer)(__ccgo_up(bp))).Fn = nToken + int32(1) + _fts5VisitEntries(tls, p, uintptr(0), (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn, int32(1), __ccgo_fp(_prefixIterSetupTokendataCb), bp+16) + _fts5TokendataIterSortMap(tls, p, (**(**TTokendataSetupCtx)(__ccgo_up(bp + 16))).FpT) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter = (**(**TTokendataSetupCtx)(__ccgo_up(bp + 16))).FpT + } else { + _fts5TokendataIterDelete(tls, (**(**TTokendataSetupCtx)(__ccgo_up(bp + 16))).FpT) + } + _sqlite3Fts5BufferFree(tls, bp) + return _fts5IndexReturn(tls, p) +} + +// C documentation +// +// /* +// ** Add a level to the Fts5Structure.aLevel[] array of structure object +// ** (*ppStruct). +// */ +func _fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) { + var nByte Tsqlite3_int64 + var nLevel int32 + var pStruct uintptr + _, _, _ = nByte, nLevel, pStruct + _fts5StructureMakeWritable(tls, pRc, ppStruct) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + pStruct = **(**uintptr)(__ccgo_up(ppStruct)) + nLevel = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32) + libc.Uint64FromInt32(nLevel+libc.Int32FromInt32(2))*libc.Uint64FromInt64(16)) + pStruct = Xsqlite3_realloc64(tls, pStruct, libc.Uint64FromInt64(nByte)) + if pStruct != 0 { + libc.Xmemset(tls, pStruct+32+uintptr(nLevel)*16, 0, uint64(16)) + (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel + 1 + **(**uintptr)(__ccgo_up(ppStruct)) = pStruct + } else { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } +} + +// C documentation +// +// /* +// ** Extend level iLvl so that there is room for at least nExtra more +// ** segments. +// */ +func _fts5StructureExtendLevel(tls *libc.TLS, pRc uintptr, pStruct uintptr, iLvl int32, nExtra int32, bInsert int32) { + var aNew, pLvl uintptr + var nByte Tsqlite3_int64 + var nMove int32 + _, _, _, _ = aNew, nByte, nMove, pLvl + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + pLvl = pStruct + 32 + uintptr(iLvl)*16 + nByte = libc.Int64FromUint64(libc.Uint64FromInt32((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg+nExtra) * uint64(56)) + aNew = Xsqlite3_realloc64(tls, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg, libc.Uint64FromInt64(nByte)) + if aNew != 0 { + if bInsert == 0 { + libc.Xmemset(tls, aNew+uintptr((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg)*56, 0, uint64(56)*libc.Uint64FromInt32(nExtra)) + } else { + nMove = libc.Int32FromUint64(libc.Uint64FromInt32((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg) * uint64(56)) + libc.Xmemmove(tls, aNew+uintptr(nExtra)*56, aNew, libc.Uint64FromInt32(nMove)) + libc.Xmemset(tls, aNew, 0, uint64(56)*libc.Uint64FromInt32(nExtra)) + } + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = aNew + } else { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } +} + +// C documentation +// +// /* +// ** Ensure that structure object (*pp) is writable. +// ** +// ** This function is a no-op if (*pRc) is not SQLITE_OK when it is called. If +// ** an error occurs, (*pRc) is set to an SQLite error code before returning. +// */ +func _fts5StructureMakeWritable(tls *libc.TLS, pRc uintptr, pp uintptr) { + var i int32 + var nByte Ti64 + var p, pLvl, pNew uintptr + _, _, _, _, _ = i, nByte, p, pLvl, pNew + p = **(**uintptr)(__ccgo_up(pp)) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK && (*TFts5Structure)(unsafe.Pointer(p)).FnRef > int32(1) { + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32) + libc.Uint64FromInt32((*TFts5Structure)(unsafe.Pointer(p)).FnLevel)*libc.Uint64FromInt64(16)) + pNew = _sqlite3Fts5MallocZero(tls, pRc, nByte) + if pNew != 0 { + libc.Xmemcpy(tls, pNew, p, libc.Uint64FromInt64(nByte)) + i = 0 + for { + if !(i < (*TFts5Structure)(unsafe.Pointer(p)).FnLevel) { + break + } + (*(*TFts5StructureLevel)(unsafe.Pointer(pNew + 32 + uintptr(i)*16))).FaSeg = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < (*TFts5Structure)(unsafe.Pointer(p)).FnLevel) { + break + } + pLvl = pNew + 32 + uintptr(i)*16 + nByte = libc.Int64FromUint64(uint64(56) * libc.Uint64FromInt32((*(*TFts5StructureLevel)(unsafe.Pointer(pNew + 32 + uintptr(i)*16))).FnSeg)) + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = _sqlite3Fts5MallocZero(tls, pRc, nByte) + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg == uintptr(0) { + i = 0 + for { + if !(i < (*TFts5Structure)(unsafe.Pointer(p)).FnLevel) { + break + } + Xsqlite3_free(tls, (*(*TFts5StructureLevel)(unsafe.Pointer(pNew + 32 + uintptr(i)*16))).FaSeg) + goto _3 + _3: + ; + i = i + 1 + } + Xsqlite3_free(tls, pNew) + return + } + libc.Xmemcpy(tls, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg, (*(*TFts5StructureLevel)(unsafe.Pointer(p + 32 + uintptr(i)*16))).FaSeg, libc.Uint64FromInt64(nByte)) + goto _2 + _2: + ; + i = i + 1 + } + (*TFts5Structure)(unsafe.Pointer(p)).FnRef = (*TFts5Structure)(unsafe.Pointer(p)).FnRef - 1 + (*TFts5Structure)(unsafe.Pointer(pNew)).FnRef = int32(1) + } + **(**uintptr)(__ccgo_up(pp)) = pNew + } +} + +// C documentation +// +// /* +// ** Sort the contents of the pT->aMap[] array. +// ** +// ** The sorting algorithm requires a malloc(). If this fails, an error code +// ** is left in Fts5Index.rc before returning. +// */ +func _fts5TokendataIterSortMap(tls *libc.TLS, p uintptr, pT uintptr) { + var a1, a2, aTmp, tmp uintptr + var i1, n1, n2 int32 + var nByte, nHalf Ti64 + var v3, v4 int64 + _, _, _, _, _, _, _, _, _, _, _ = a1, a2, aTmp, i1, n1, n2, nByte, nHalf, tmp, v3, v4 + aTmp = uintptr(0) + nByte = libc.Int64FromUint64(libc.Uint64FromInt64((*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap) * uint64(24)) + aTmp = _sqlite3Fts5MallocZero(tls, p+60, nByte) + if aTmp != 0 { + a1 = (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaMap + a2 = aTmp + nHalf = int64(1) + for { + if !(nHalf < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap) { + break + } + i1 = 0 + for { + if !(int64(i1) < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap) { + break + } + if nHalf < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap-int64(i1) { + v3 = nHalf + } else { + v3 = (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap - int64(i1) + } + n1 = int32(v3) + if nHalf < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap-int64(i1)-int64(n1) { + v4 = nHalf + } else { + v4 = (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap - int64(i1) - int64(n1) + } + n2 = int32(v4) + _fts5TokendataMerge(tls, a1+uintptr(i1)*24, n1, a1+uintptr(i1+n1)*24, n2, a2+uintptr(i1)*24) + goto _2 + _2: + ; + i1 = int32(int64(i1) + nHalf*libc.Int64FromInt32(2)) + } + tmp = a1 + a1 = a2 + a2 = tmp + goto _1 + _1: + ; + nHalf = nHalf * int64(2) + } + if a1 != (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaMap { + libc.Xmemcpy(tls, (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaMap, a1, uint64(libc.Uint64FromInt64((*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap)*uint64(24))) + } + Xsqlite3_free(tls, aTmp) + } +} + +// C documentation +// +// /* +// ** Iterator pIter was used to iterate through the input segments of on an +// ** incremental merge operation. This function is called if the incremental +// ** merge step has finished but the input has not been completely exhausted. +// */ +func _fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, iId, iOff, nDiff int32 + var iLeafRowid Ti64 + var pData, pSeg uintptr + var _ /* aHdr at bp+16 */ [4]Tu8 + var _ /* buf at bp+0 */ TFts5Buffer + _, _, _, _, _, _, _ = i, iId, iLeafRowid, iOff, nDiff, pData, pSeg + libc.Xmemset(tls, bp, 0, uint64(16)) + i = 0 + for { + if !(i < (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg && (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { + break + } + pSeg = pIter + 104 + uintptr(i)*128 + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg == uintptr(0) { + /* no-op */ + } else { + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf == uintptr(0) { + /* All keys from this input segment have been transfered to the output. + ** Set both the first and last page-numbers to 0 to indicate that the + ** segment is now empty. */ + (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoLast = 0 + (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoFirst = 0 + } else { + iOff = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafOffset + iId = (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid + **(**[4]Tu8)(__ccgo_up(bp + 16)) = [4]Tu8{} + iLeafRowid = int64(iId)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))< (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf { + /* This can occur if the pages that the segments occupy overlap - if + ** a single page has been assigned to more than one segment. In + ** this case a prior iteration of this loop may have corrupted the + ** segment currently being trimmed. */ + _fts5IndexCorruptRowid(tls, p, iLeafRowid) + } else { + _sqlite3Fts5BufferZero(tls, bp) + if !(libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(bp)).Fn)+libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer(pData)).Fnn) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(bp)).FnSpace)) { + _sqlite3Fts5BufferSize(tls, p+60, bp, libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer(pData)).Fnn+(*TFts5Buffer)(unsafe.Pointer(bp)).Fn)) + } + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, uint32(4), bp+16) + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn)) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, libc.Uint32FromInt32((*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn), (*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer(pData)).FszLeaf-iOff), (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr(iOff)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + /* Set the szLeaf field */ + _fts5PutU16(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp+2, libc.Uint16FromInt32((**(**TFts5Buffer)(__ccgo_up(bp))).Fn)) + } + /* Set up the new page-index array */ + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, libc.Int64FromInt32(4)) + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno && (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist < (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf && (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff <= (*TFts5Data)(unsafe.Pointer(pData)).Fnn { + nDiff = (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf - (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist + _sqlite3Fts5BufferAppendVarint(tls, p+60, bp, int64((**(**TFts5Buffer)(__ccgo_up(bp))).Fn)-int64(1)-int64(nDiff)-int64(4)) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer(pData)).Fnn-(*TFts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff), (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr((*TFts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff)) + } + (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoFirst = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno + _fts5DataDelete(tls, p, int64(iId)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))< 0 { + aNew = Xsqlite3_realloc64(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaiException, uint64(libc.Uint64FromInt32(n+(*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException)*uint64(4))) + if aNew != 0 { + nNew = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException + zCsr = z + zTerm = z + uintptr(n) + for zCsr < zTerm { + v1 = zCsr + zCsr = zCsr + 1 + iCode = uint32(**(**uint8)(__ccgo_up(v1))) + if iCode >= uint32(0xc0) { + iCode = uint32(_sqlite3Utf8Trans1[iCode-uint32(0xc0)]) + for zCsr < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zCsr)))&int32(0xc0) == int32(0x80) { + v1 = zCsr + zCsr = zCsr + 1 + iCode = iCode< iCode { + break + } + goto _3 + _3: + ; + i = i + 1 + } + libc.Xmemmove(tls, aNew+uintptr(i+int32(1))*4, aNew+uintptr(i)*4, libc.Uint64FromInt32(nNew-i)*uint64(4)) + **(**int32)(__ccgo_up(aNew + uintptr(i)*4)) = libc.Int32FromUint32(iCode) + nNew = nNew + 1 + } + } + } + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaiException = aNew + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException = nNew + } else { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +// C documentation +// +// /* +// ** Advance the cursor to the next row in the table. +// */ +func _fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bCmp, eDetail, iCol, ii1, nCmp, nCol, nPos, v2 int32 + var pCsr, pPos, pTab, zTerm uintptr + var v3 Ti64 + var _ /* iOff at bp+16 */ int32 + var _ /* iPos at bp+8 */ Ti64 + var _ /* ii at bp+20 */ Tu32 + var _ /* nTerm at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = bCmp, eDetail, iCol, ii1, nCmp, nCol, nPos, pCsr, pPos, pTab, zTerm, v2, v3 + pCsr = pCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StructureTest(tls, (*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpIndex, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpStruct) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp)) + } + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid + 1 + if (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType == int32(FTS5_VOCAB_INSTANCE) { + return _fts5VocabInstanceNext(tls, pCsr) + } + if (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol + 1 + for { + if !((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol) { + break + } + if **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) != 0 { + break + } + goto _1 + _1: + ; + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol + 1 + } + } + if (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType != FTS5_VOCAB_COL || (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol >= nCol { + if (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = int32(1) + } else { + zTerm = _sqlite3Fts5IterTerm(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter, bp+4) + if (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm >= 0 { + if **(**int32)(__ccgo_up(bp + 4)) < (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm { + v2 = **(**int32)(__ccgo_up(bp + 4)) + } else { + v2 = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm + } + nCmp = v2 + bCmp = libc.Xmemcmp(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zTerm, libc.Uint64FromInt32(nCmp)) + if bCmp < 0 || bCmp == 0 && (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm < **(**int32)(__ccgo_up(bp + 4)) { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = int32(1) + return SQLITE_OK + } + } + _sqlite3Fts5BufferSet(tls, bp, pCsr+96, **(**int32)(__ccgo_up(bp + 4)), zTerm) + libc.Xmemset(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt, 0, libc.Uint64FromInt32(nCol)*uint64(8)) + libc.Xmemset(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc, 0, libc.Uint64FromInt32(nCol)*uint64(8)) + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = 0 + for **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail /* Position list */ + **(**Ti64)(__ccgo_up(bp + 8)) = 0 /* 64-bit position read from poslist */ + **(**int32)(__ccgo_up(bp + 16)) = 0 /* Current offset within position list */ + pPos = (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FpData + nPos = (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FnData + switch (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType { + case int32(FTS5_VOCAB_ROW): + /* Do not bother counting the number of instances if the "cnt" + ** column is not being read (according to colUsed). */ + if eDetail == FTS5_DETAIL_FULL && (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FcolUsed&int32(0x04) != 0 { + for **(**Ti64)(__ccgo_up(bp + 8)) < int64(nPos) { + v3 = **(**Ti64)(__ccgo_up(bp + 8)) + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) + 1 + **(**Tu32)(__ccgo_up(bp + 20)) = uint32(**(**Tu8)(__ccgo_up(pPos + uintptr(v3)))) + if **(**Tu32)(__ccgo_up(bp + 20))&uint32(0x80) != 0 { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) - 1 + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) + int64(_sqlite3Fts5GetVarint32(tls, pPos+uintptr(**(**Ti64)(__ccgo_up(bp + 8))), bp+20)) + } + if **(**Tu32)(__ccgo_up(bp + 20)) == uint32(1) { + /* New column in the position list */ + v3 = **(**Ti64)(__ccgo_up(bp + 8)) + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) + 1 + **(**Tu32)(__ccgo_up(bp + 20)) = uint32(**(**Tu8)(__ccgo_up(pPos + uintptr(v3)))) + if **(**Tu32)(__ccgo_up(bp + 20))&uint32(0x80) != 0 { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) - 1 + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) + int64(_sqlite3Fts5GetVarint32(tls, pPos+uintptr(**(**Ti64)(__ccgo_up(bp + 8))), bp+20)) + } + } else { + /* An instance - increment pCsr->aCnt[] */ + **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt)) = **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt)) + 1 + } + } + } + **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc)) = **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc)) + 1 + case FTS5_VOCAB_COL: + if eDetail == FTS5_DETAIL_FULL { + iCol = -int32(1) + for 0 == _sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+16, bp+8) { + ii1 = int32(**(**Ti64)(__ccgo_up(bp + 8)) >> libc.Int32FromInt32(32) & libc.Int64FromInt32(0x7FFFFFFF)) + if iCol != ii1 { + if ii1 >= nCol { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= int64(nCol) { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)< 0 && libc.Xmemcmp(tls, zTerm, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 4)))) != 0 { + break + } + if (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { + break + } + } + } + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof == 0 && (*TFts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL { + for { + if !((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol && **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) == 0) { + break + } + goto _5 + _5: + ; + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol + 1 + } + if (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol == nCol { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<aDlidx[] array to at least nLvl elements in size. +// ** Any new array elements are zeroed before returning. +// */ +func _fts5WriteDlidxGrow(tls *libc.TLS, p uintptr, pWriter uintptr, nLvl int32) (r int32) { + var aDlidx uintptr + var nByte Tsize_t + _, _ = aDlidx, nByte + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && nLvl >= (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx { + aDlidx = Xsqlite3_realloc64(tls, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx, uint64(uint64(32)*libc.Uint64FromInt32(nLvl))) + if aDlidx == uintptr(0) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + nByte = uint64(32) * libc.Uint64FromInt32(nLvl-(*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx) + libc.Xmemset(tls, aDlidx+uintptr((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx)*32, 0, nByte) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx = aDlidx + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx = nLvl + } + } + return (*TFts5Index)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** If pPoly is a polygon, compute its bounding box. Then: +// ** +// ** (1) if aCoord!=0 store the bounding box in aCoord, returning NULL +// ** (2) otherwise, compute a GeoPoly for the bounding box and return the +// ** new GeoPoly +// ** +// ** If pPoly is NULL but aCoord is not NULL, then compute a new GeoPoly from +// ** the bounding box in aCoord and return a pointer to that GeoPoly. +// */ +func _geopolyBBox(tls *libc.TLS, context uintptr, pPoly uintptr, aCoord uintptr, pRc uintptr) (r1 uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var mnX, mnY, mxX, mxY, v3 float32 + var p, pOut uintptr + var r float64 + var _ /* ii at bp+0 */ int32 + _, _, _, _, _, _, _, _ = mnX, mnY, mxX, mxY, p, pOut, r, v3 + pOut = uintptr(0) + if pPoly == uintptr(0) && aCoord != uintptr(0) { + p = uintptr(0) + mnX = *(*TRtreeValue)(unsafe.Pointer(aCoord)) + mxX = *(*TRtreeValue)(unsafe.Pointer(aCoord + 1*4)) + mnY = *(*TRtreeValue)(unsafe.Pointer(aCoord + 2*4)) + mxY = *(*TRtreeValue)(unsafe.Pointer(aCoord + 3*4)) + goto geopolyBboxFill + } else { + p = _geopolyFuncParam(tls, context, pPoly, pRc) + } + if !(p != 0) { + goto _1 + } + v3 = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4)) + mxX = v3 + mnX = v3 + v3 = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) + mxY = v3 + mnY = v3 + **(**int32)(__ccgo_up(bp)) = int32(1) + for { + if !(**(**int32)(__ccgo_up(bp)) < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) { + break + } + r = float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(**(**int32)(__ccgo_up(bp))*int32(2))*4))) + if r < float64(mnX) { + mnX = float32(r) + } else { + if r > float64(mxX) { + mxX = float32(r) + } + } + r = float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(**(**int32)(__ccgo_up(bp))*int32(2)+int32(1))*4))) + if r < float64(mnY) { + mnY = float32(r) + } else { + if r > float64(mxY) { + mxY = float32(r) + } + } + goto _5 + _5: + ; + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + } + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = SQLITE_OK + } + if !(aCoord == uintptr(0)) { + goto _6 + } + goto geopolyBboxFill +geopolyBboxFill: + ; + pOut = Xsqlite3_realloc64(tls, p, uint64(libc.Uint64FromInt64(40)+libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)*libc.Uint64FromInt32(libc.Int32FromInt32(4)-libc.Int32FromInt32(4)))) + if pOut == uintptr(0) { + Xsqlite3_free(tls, p) + if context != 0 { + Xsqlite3_result_error_nomem(tls, context) + } + if pRc != 0 { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + return uintptr(0) + } + (*TGeoPoly)(unsafe.Pointer(pOut)).FnVertex = int32(4) + **(**int32)(__ccgo_up(bp)) = int32(1) + **(**uint8)(__ccgo_up(pOut + 4)) = **(**uint8)(__ccgo_up(bp)) + **(**uint8)(__ccgo_up(pOut + 4 + 1)) = uint8(0) + **(**uint8)(__ccgo_up(pOut + 4 + 2)) = uint8(0) + **(**uint8)(__ccgo_up(pOut + 4 + 3)) = uint8(4) + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4)) = mnX + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) = mnY + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(2))*4)) = mxX + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(1)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) = mnY + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(2))*4)) = mxX + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(2)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) = mxY + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(2))*4)) = mnX + **(**TGeoCoord)(__ccgo_up(pOut + 8 + uintptr(libc.Int32FromInt32(3)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)) = mxY + goto _7 +_6: + ; + Xsqlite3_free(tls, p) + *(*TRtreeValue)(unsafe.Pointer(aCoord)) = mnX + *(*TRtreeValue)(unsafe.Pointer(aCoord + 1*4)) = mxX + *(*TRtreeValue)(unsafe.Pointer(aCoord + 2*4)) = mnY + *(*TRtreeValue)(unsafe.Pointer(aCoord + 3*4)) = mxY +_7: + ; + goto _2 +_1: + ; + if aCoord != 0 { + libc.Xmemset(tls, aCoord, 0, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(4)) + } +_2: + ; + return pOut +} + +// C documentation +// +// /* +// ** GEOPOLY virtual table module xFilter method. +// ** +// ** Query plans: +// ** +// ** 1 rowid lookup +// ** 2 search for objects overlapping the same bounding box +// ** that contains polygon argv[0] +// ** 3 search for objects overlapping the same bounding box +// ** that contains polygon argv[0] +// ** 4 full table scan +// */ +func _geopolyFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iRowid Ti64 + var p, p1, pCsr, pNew, pRtree, v1 uintptr + var _ /* bbox at bp+32 */ [4]TRtreeCoord + var _ /* iCell at bp+12 */ int32 + var _ /* iNode at bp+24 */ Ti64 + var _ /* pLeaf at bp+16 */ uintptr + var _ /* pRoot at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _, _, _, _, _, _ = iRowid, p, p1, pCsr, pNew, pRtree, v1 + pRtree = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab + pCsr = pVtabCursor + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 12)) = 0 + _ = idxStr + _rtreeReference(tls, pRtree) + /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ + _resetCursor(tls, pCsr) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FiStrategy = idxNum + if idxNum == int32(1) { /* Search point for the leaf */ + iRowid = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + **(**Ti64)(__ccgo_up(bp + 24)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = _findLeafNode(tls, pRtree, iRowid, bp+16, bp+24) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 16)) != uintptr(0) { + p = _rtreeSearchPointNew(tls, pCsr, float64(0), uint8(0)) + /* Always returns pCsr->sPoint */ + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp + 16)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).Fid = **(**Ti64)(__ccgo_up(bp + 24)) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = uint8(PARTLY_WITHIN) + **(**int32)(__ccgo_up(bp + 8)) = _nodeRowidIndex(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 16)), iRowid, bp+12) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 12))) + } else { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FatEOF = uint8(1) + } + } else { + /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array + ** with the configured constraints. + */ + **(**int32)(__ccgo_up(bp + 8)) = _nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && idxNum <= int32(3) { + _geopolyBBox(tls, uintptr(0), **(**uintptr)(__ccgo_up(argv)), bp+32, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + goto geopoly_filter_end + } + v1 = Xsqlite3_malloc(tls, libc.Int32FromUint64(libc.Uint64FromInt64(24)*libc.Uint64FromInt32(4))) + p1 = v1 + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = v1 + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = int32(4) + if p1 == uintptr(0) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, libc.Uint64FromInt64(24)*libc.Uint64FromInt32(4)) + libc.Xmemset(tls, pCsr+128, 0, uint64(4)*libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiDepth+libc.Int32FromInt32(1))) + if idxNum == int32(2) { + /* Overlap query */ + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('B') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0 + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 1*4))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('D') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(1) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('B') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(2) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 3*4))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('D') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(3) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 2*4))) + } else { + /* Within query */ + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('D') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0 + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('B') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(1) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 1*4))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('D') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(2) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 2*4))) + p1 += 24 + (*TRtreeConstraint)(unsafe.Pointer(p1)).Fop = int32('B') + (*TRtreeConstraint)(unsafe.Pointer(p1)).FiCoord = int32(3) + *(*TRtreeDValue)(unsafe.Pointer(p1 + 8)) = float64(*(*TRtreeValue)(unsafe.Pointer(bp + 32 + 3*4))) + } + } + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + pNew = _rtreeSearchPointNew(tls, pCsr, float64(0), libc.Uint8FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiDepth+libc.Int32FromInt32(1))) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_NOMEM) + goto geopoly_filter_end + } + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = uint8(0) + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = uint8(PARTLY_WITHIN) + **(**uintptr)(__ccgo_up(pCsr + 88)) = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = _rtreeStepToLeaf(tls, pCsr) + } + } + goto geopoly_filter_end +geopoly_filter_end: + ; + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + _rtreeRelease(tls, pRtree) + return **(**int32)(__ccgo_up(bp + 8)) +} + +// C documentation +// +// /* +// ** Given a function parameter, try to interpret it as a polygon, either +// ** in the binary format or JSON text. Compute a GeoPoly object and +// ** return a pointer to that object. Or if the input is not a well-formed +// ** polygon, put an error message in sqlite3_context and return NULL. +// */ +func _geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, p, zJson, v4 uintptr + var ii, nByte, nVertex, v1 int32 + var v2 bool + var _ /* x at bp+0 */ int32 + _, _, _, _, _, _, _, _, _ = a, ii, nByte, nVertex, p, zJson, v1, v2, v4 + p = uintptr(0) + if v2 = Xsqlite3_value_type(tls, pVal) == int32(SQLITE_BLOB); v2 { + v1 = Xsqlite3_value_bytes(tls, pVal) + nByte = v1 + } + if v2 && v1 >= libc.Int32FromUint64(libc.Uint64FromInt32(4)+libc.Uint64FromInt32(6)*libc.Uint64FromInt64(4)) { + a = Xsqlite3_value_blob(tls, pVal) + if a == uintptr(0) { + if pCtx != 0 { + Xsqlite3_result_error_nomem(tls, pCtx) + } + return uintptr(0) + } + nVertex = libc.Int32FromUint8(**(**uint8)(__ccgo_up(a + 1)))< (*TPager)(unsafe.Pointer(pPager)).FmxPgno { + rc = int32(SQLITE_FULL) + if pgno <= (*TPager)(unsafe.Pointer(pPager)).FdbSize { + _sqlite3PcacheRelease(tls, pPg) + pPg = uintptr(0) + } + goto pager_acquire_err + } + if noContent != 0 { + /* Failure to set the bits in the InJournal bit-vectors is benign. + ** It merely means that we might do some extra work to journal a + ** page that does not need to be journaled. Nevertheless, be sure + ** to test the case where a malloc error occurs while trying to set + ** a bit in a bit vector. + */ + _sqlite3BeginBenignMalloc(tls) + if pgno <= (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize { + _sqlite3BitvecSet(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal, pgno) + } + _addToSavepointBitvecs(tls, pPager, pgno) + _sqlite3EndBenignMalloc(tls) + } + libc.Xmemset(tls, (*TPgHdr)(unsafe.Pointer(pPg)).FpData, 0, libc.Uint64FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize)) + } else { + **(**Tu32)(__ccgo_up(pPager + 248 + 1*4)) = **(**Tu32)(__ccgo_up(pPager + 248 + 1*4)) + 1 + rc = _readDbPage(tls, pPg) + if rc != SQLITE_OK { + goto pager_acquire_err + } + } + } + return SQLITE_OK + goto pager_acquire_err +pager_acquire_err: + ; + if pPg != 0 { + _sqlite3PcacheDrop(tls, pPg) + } + _pagerUnlockIfUnused(tls, pPager) + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return rc +} + +func _groupConcatInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var nVS int32 + var pGCC uintptr + _, _ = nVS, pGCC + _ = argc /* Suppress unused parameter warning */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + return + } + pGCC = Xsqlite3_aggregate_context(tls, context, int32(48)) + /* pGCC is always non-NULL since groupConcatStep() will have always + ** run first to initialize it */ + if pGCC != 0 { /* Number of characters to remove */ + /* Must call sqlite3_value_text() to convert the argument into text prior + ** to invoking sqlite3_value_bytes(), in case the text encoding is UTF16 */ + Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + nVS = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + **(**int32)(__ccgo_up(pGCC + 32)) -= int32(1) + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths != uintptr(0) { + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum > 0 { + nVS = nVS + **(**int32)(__ccgo_up((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths)) + libc.Xmemmove(tls, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths+uintptr(1)*4, libc.Uint64FromInt32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum-libc.Int32FromInt32(1))*uint64(4)) + } + } else { + /* If removing single accumulated string, harmlessly over-do. */ + nVS = nVS + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength + } + if nVS >= libc.Int32FromUint32((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar) { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar = uint32(0) + } else { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar -= libc.Uint32FromInt32(nVS) + libc.Xmemmove(tls, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FzText, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FzText+uintptr(nVS), uint64((*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar)) + } + if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar == uint32(0) { + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc = uint32(0) + Xsqlite3_free(tls, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths) + (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths = uintptr(0) + } + } +} + +// C documentation +// +// /* +// ** Grow the db->aVTrans[] array so that there is room for at least one +// ** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise. +// */ +func _growVTrans(tls *libc.TLS, db uintptr) (r int32) { + var ARRAY_INCR int32 + var aVTrans uintptr + var nBytes Tsqlite3_int64 + _, _, _ = ARRAY_INCR, aVTrans, nBytes + ARRAY_INCR = int32(5) + /* Grow the sqlite3.aVTrans array if required */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnVTrans%ARRAY_INCR == 0 { + nBytes = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt64(int64((*Tsqlite3)(unsafe.Pointer(db)).FnVTrans)+int64(ARRAY_INCR))) + aVTrans = _sqlite3DbRealloc(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans, libc.Uint64FromInt64(nBytes)) + if !(aVTrans != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, aVTrans+uintptr((*Tsqlite3)(unsafe.Pointer(db)).FnVTrans)*8, 0, uint64(8)*libc.Uint64FromInt32(ARRAY_INCR)) + (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans = aVTrans + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Insert a new cell on pPage at cell index "i". pCell points to the +// ** content of the cell. +// ** +// ** If the cell content will fit on the page, then put it there. If it +// ** will not fit, then make a copy of the cell content into pTemp if +// ** pTemp is not null. Regardless of pTemp, allocate a new entry +// ** in pPage->apOvfl[] and make it point to the cell content (either +// ** in pTemp or the original pCell) and also record its index. +// ** Allocating a new entry in pPage->aCell[] implies that +// ** pPage->nOverflow is incremented. +// ** +// ** The insertCellFast() routine below works exactly the same as +// ** insertCell() except that it lacks the pTemp and iChild parameters +// ** which are assumed zero. Other than that, the two routines are the +// ** same. +// ** +// ** Fixes or enhancements to this routine should be reflected in +// ** insertCellFast()! +// */ +func _insertCell(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32, pTemp uintptr, iChild TPgno) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var data, pIns, v2 uintptr + var j, rc int32 + var v1 Tu8 + var _ /* idx at bp+0 */ int32 + var _ /* rc2 at bp+4 */ int32 + _, _, _, _, _, _ = data, j, pIns, rc, v1, v2 + **(**int32)(__ccgo_up(bp)) = 0 /* The point in pPage->aCellIdx[] where no cell inserted */ + if (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow != 0 || sz+int32(2) > (*TMemPage)(unsafe.Pointer(pPage)).FnFree { + if pTemp != 0 { + libc.Xmemcpy(tls, pTemp, pCell, libc.Uint64FromInt32(sz)) + pCell = pTemp + } + _sqlite3Put4byte(tls, pCell, iChild) + v2 = pPage + 12 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + j = libc.Int32FromUint8(v1) + /* Comparison against ArraySize-1 since we hold back one extra slot + ** as a contingency. In other words, never need more than 3 overflow + ** slots but 4 are allocated, just to be safe. */ + **(**uintptr)(__ccgo_up(pPage + 40 + uintptr(j)*8)) = pCell + **(**Tu16)(__ccgo_up(pPage + 28 + uintptr(j)*2)) = libc.Uint16FromInt32(i) + /* When multiple overflows occur, they are always sequential and in + ** sorted order. This invariants arise because multiple overflows can + ** only occur when inserting divider cells into the parent page during + ** balancing, and the dividers are adjacent and sorted. + */ + /* Overflows in sorted order */ + /* Overflows are sequential */ + } else { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if rc != SQLITE_OK { + return rc + } + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + rc = _allocateSpace(tls, pPage, sz, bp) + if rc != 0 { + return rc + } + /* The allocateSpace() routine guarantees the following properties + ** if it returns successfully */ + **(**int32)(__ccgo_up(pPage + 20)) -= libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(2) + sz)) + /* In a corrupt database where an entry in the cell index section of + ** a btree page has a value of 3 or less, the pCell value might point + ** as many as 4 bytes in front of the start of the aData buffer for + ** the source page. Make sure this does not cause problems by not + ** reading the first 4 bytes */ + libc.Xmemcpy(tls, data+uintptr(**(**int32)(__ccgo_up(bp))+int32(4)), pCell+uintptr(4), libc.Uint64FromInt32(sz-int32(4))) + _sqlite3Put4byte(tls, data+uintptr(**(**int32)(__ccgo_up(bp))), iChild) + pIns = (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(i*int32(2)) + libc.Xmemmove(tls, pIns+uintptr(2), pIns, libc.Uint64FromInt32(int32(2)*(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell)-i))) + **(**Tu8)(__ccgo_up(pIns)) = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pIns + 1)) = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))) + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = (*TMemPage)(unsafe.Pointer(pPage)).FnCell + 1 + /* increment the cell count */ + v2 = data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(4)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + if libc.Int32FromUint8(v1) == 0 { + **(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(3)))) = **(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(3)))) + 1 + } + if (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FautoVacuum != 0 { + **(**int32)(__ccgo_up(bp + 4)) = SQLITE_OK + /* The cell may contain a pointer to an overflow page. If so, write + ** the entry for the overflow page into the pointer map. + */ + _ptrmapPutOvflPtr(tls, pPage, pPage, pCell, bp+4) + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + return **(**int32)(__ccgo_up(bp + 4)) + } + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This variant of insertCell() assumes that the pTemp and iChild +// ** parameters are both zero. Use this variant in sqlite3BtreeInsert() +// ** for performance improvement, and also so that this variant is only +// ** called from that one place, and is thus inlined, and thus runs must +// ** faster. +// ** +// ** Fixes or enhancements to this routine should be reflected into +// ** the insertCell() routine. +// */ +func _insertCellFast(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var data, pIns, v2 uintptr + var j, rc int32 + var v1 Tu8 + var _ /* idx at bp+0 */ int32 + var _ /* rc2 at bp+4 */ int32 + _, _, _, _, _, _ = data, j, pIns, rc, v1, v2 + **(**int32)(__ccgo_up(bp)) = 0 /* The point in pPage->aCellIdx[] where no cell inserted */ + if sz+int32(2) > (*TMemPage)(unsafe.Pointer(pPage)).FnFree { + v2 = pPage + 12 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + j = libc.Int32FromUint8(v1) + /* Comparison against ArraySize-1 since we hold back one extra slot + ** as a contingency. In other words, never need more than 3 overflow + ** slots but 4 are allocated, just to be safe. */ + **(**uintptr)(__ccgo_up(pPage + 40 + uintptr(j)*8)) = pCell + **(**Tu16)(__ccgo_up(pPage + 28 + uintptr(j)*2)) = libc.Uint16FromInt32(i) + /* When multiple overflows occur, they are always sequential and in + ** sorted order. This invariants arise because multiple overflows can + ** only occur when inserting divider cells into the parent page during + ** balancing, and the dividers are adjacent and sorted. + */ + /* Overflows in sorted order */ + /* Overflows are sequential */ + } else { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) + if rc != SQLITE_OK { + return rc + } + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + rc = _allocateSpace(tls, pPage, sz, bp) + if rc != 0 { + return rc + } + /* The allocateSpace() routine guarantees the following properties + ** if it returns successfully */ + **(**int32)(__ccgo_up(pPage + 20)) -= libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(2) + sz)) + libc.Xmemcpy(tls, data+uintptr(**(**int32)(__ccgo_up(bp))), pCell, libc.Uint64FromInt32(sz)) + pIns = (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(i*int32(2)) + libc.Xmemmove(tls, pIns+uintptr(2), pIns, libc.Uint64FromInt32(int32(2)*(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell)-i))) + **(**Tu8)(__ccgo_up(pIns)) = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pIns + 1)) = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))) + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = (*TMemPage)(unsafe.Pointer(pPage)).FnCell + 1 + /* increment the cell count */ + v2 = data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(4)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + if libc.Int32FromUint8(v1) == 0 { + **(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(3)))) = **(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(3)))) + 1 + } + if (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FautoVacuum != 0 { + **(**int32)(__ccgo_up(bp + 4)) = SQLITE_OK + /* The cell may contain a pointer to an overflow page. If so, write + ** the entry for the overflow page into the pointer map. + */ + _ptrmapPutOvflPtr(tls, pPage, pPage, pCell, bp+4) + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + return **(**int32)(__ccgo_up(bp + 4)) + } + } + } + return SQLITE_OK +} + +/* +** The following parameters determine how many adjacent pages get involved +** in a balancing operation. NN is the number of neighbors on either side +** of the page that participate in the balancing operation. NB is the +** total number of pages that participate, including the target page and +** NN neighbors on either side. +** +** The minimum value of NN is 1 (of course). Increasing NN above 1 +** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance +** in exchange for a larger degradation in INSERT and UPDATE performance. +** The value of NN appears to give the best results overall. +** +** (Later:) The description above makes it seem as if these values are +** tunable - as if you could change them and recompile and it would all work. +** But that is unlikely. NB has been 3 since the inception of SQLite and +** we have never tested any other value. + */ + +// C documentation +// +// /* Append a node type byte together with the payload size and +// ** possibly also the payload. +// ** +// ** If aPayload is not NULL, then it is a pointer to the payload which +// ** is also appended. If aPayload is NULL, the pParse->aBlob[] array +// ** is resized (if necessary) so that it is big enough to hold the +// ** payload, but the payload is not appended and pParse->nBlob is left +// ** pointing to where the first byte of payload will eventually be. +// */ +func _jsonBlobAppendNode(tls *libc.TLS, pParse uintptr, eType Tu8, szPayload Tu64, aPayload uintptr) { + var a, v1 uintptr + _, _ = a, v1 + if uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)+szPayload+uint64(9) > uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc) { + _jsonBlobExpandAndAppendNode(tls, pParse, eType, szPayload, aPayload) + return + } + a = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob) + if szPayload <= uint64(11) { + **(**Tu8)(__ccgo_up(a)) = uint8(uint64(eType) | szPayload<> libc.Int32FromInt32(8) & uint64(0xff)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(szPayload & uint64(0xff)) + **(**Tu32)(__ccgo_up(pParse + 8)) += uint32(3) + } else { + **(**Tu8)(__ccgo_up(a)) = libc.Uint8FromInt32(libc.Int32FromUint8(eType) | int32(0xe0)) + **(**Tu8)(__ccgo_up(a + 1)) = uint8(szPayload >> libc.Int32FromInt32(24) & uint64(0xff)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(szPayload >> libc.Int32FromInt32(16) & uint64(0xff)) + **(**Tu8)(__ccgo_up(a + 3)) = uint8(szPayload >> libc.Int32FromInt32(8) & uint64(0xff)) + **(**Tu8)(__ccgo_up(a + 4)) = uint8(szPayload & uint64(0xff)) + **(**Tu32)(__ccgo_up(pParse + 8)) += uint32(5) + } + } + } + if aPayload != 0 { + v1 = pParse + 8 + *(*Tu32)(unsafe.Pointer(v1)) = Tu32(uint64(*(*Tu32)(unsafe.Pointer(v1))) + szPayload) + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)-szPayload), aPayload, szPayload) + } +} + +// C documentation +// +// /* Change the payload size for the node at index i to be szPayload. +// */ +func _jsonBlobChangePayloadSize(tls *libc.TLS, pParse uintptr, i Tu32, szPayload Tu32) (r int32) { + var a uintptr + var delta int32 + var nExtra, nNeeded, szType Tu8 + var newSize Tu32 + _, _, _, _, _, _ = a, delta, nExtra, nNeeded, newSize, szType + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return 0 + } + a = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i) + szType = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a))) >> int32(4)) + if libc.Int32FromUint8(szType) <= int32(11) { + nExtra = uint8(0) + } else { + if libc.Int32FromUint8(szType) == int32(12) { + nExtra = uint8(1) + } else { + if libc.Int32FromUint8(szType) == int32(13) { + nExtra = uint8(2) + } else { + if libc.Int32FromUint8(szType) == int32(14) { + nExtra = uint8(4) + } else { + nExtra = uint8(8) + } + } + } + } + if szPayload <= uint32(11) { + nNeeded = uint8(0) + } else { + if szPayload <= uint32(0xff) { + nNeeded = uint8(1) + } else { + if szPayload <= uint32(0xffff) { + nNeeded = uint8(2) + } else { + nNeeded = uint8(4) + } + } + } + delta = libc.Int32FromUint8(nNeeded) - libc.Int32FromUint8(nExtra) + if delta != 0 { + newSize = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + libc.Uint32FromInt32(delta) + if delta > 0 { + if newSize > (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc && _jsonBlobExpand(tls, pParse, newSize) != 0 { + return 0 /* OOM error. Error state recorded in pParse->oom. */ + } + a = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i) + libc.Xmemmove(tls, a+uintptr(int32(1)+delta), a+1, uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-(i+uint32(1)))) + } else { + libc.Xmemmove(tls, a+1, a+uintptr(int32(1)-delta), uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-(i+uint32(1)-libc.Uint32FromInt32(delta)))) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = newSize + } + if libc.Int32FromUint8(nNeeded) == 0 { + **(**Tu8)(__ccgo_up(a)) = uint8(libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a)))&libc.Int32FromInt32(0x0f)) | szPayload<> libc.Int32FromInt32(8) & uint32(0xff)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(szPayload & uint32(0xff)) + } else { + **(**Tu8)(__ccgo_up(a)) = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a)))&int32(0x0f) | int32(0xe0)) + **(**Tu8)(__ccgo_up(a + 1)) = uint8(szPayload >> libc.Int32FromInt32(24) & uint32(0xff)) + **(**Tu8)(__ccgo_up(a + 2)) = uint8(szPayload >> libc.Int32FromInt32(16) & uint32(0xff)) + **(**Tu8)(__ccgo_up(a + 3)) = uint8(szPayload >> libc.Int32FromInt32(8) & uint32(0xff)) + **(**Tu8)(__ccgo_up(a + 4)) = uint8(szPayload & uint32(0xff)) + } + } + } + return delta +} + +// C documentation +// +// /* +// ** Modify the JSONB blob at pParse->aBlob by removing nDel bytes of +// ** content beginning at iDel, and replacing them with nIns bytes of +// ** content given by aIns. +// ** +// ** nDel may be zero, in which case no bytes are removed. But iDel is +// ** still important as new bytes will be insert beginning at iDel. +// ** +// ** aIns may be zero, in which case space is created to hold nIns bytes +// ** beginning at iDel, but that space is uninitialized. +// ** +// ** Set pParse->oom if an OOM occurs. +// */ +func _jsonBlobEdit(tls *libc.TLS, pParse uintptr, iDel Tu32, nDel Tu32, aIns uintptr, nIns Tu32) { + var d Ti64 + var v1 uintptr + _, _ = d, v1 + d = libc.Int64FromUint32(nIns) - libc.Int64FromUint32(nDel) + if d < 0 && d >= int64(-libc.Int32FromInt32(8)) && aIns != uintptr(0) && _jsonBlobOverwrite(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(iDel), aIns, nIns, libc.Uint32FromInt32(int32(-d))) != 0 { + return + } + if d != 0 { + if libc.Int64FromUint32((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)+d > libc.Int64FromUint32((*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc) { + _jsonBlobExpand(tls, pParse, libc.Uint32FromInt64(libc.Int64FromUint32((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)+d)) + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return + } + } + libc.Xmemmove(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(iDel+nIns), (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(iDel+nDel), uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-(iDel+nDel))) + v1 = pParse + 8 + *(*Tu32)(unsafe.Pointer(v1)) = Tu32(int64(*(*Tu32)(unsafe.Pointer(v1))) + d) + v1 = pParse + 52 + *(*int32)(unsafe.Pointer(v1)) = int32(int64(*(*int32)(unsafe.Pointer(v1))) + d) + } + if nIns != 0 && aIns != 0 { + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(iDel), aIns, uint64(nIns)) + } +} + +// C documentation +// +// /* +// ** If the JSONB at aIns[0..nIns-1] can be expanded (by denormalizing the +// ** size field) by d bytes, then write the expansion into aOut[] and +// ** return true. In this way, an overwrite happens without changing the +// ** size of the JSONB, which reduces memcpy() operations and also make it +// ** faster and easier to update the B-Tree entry that contains the JSONB +// ** in the database. +// ** +// ** If the expansion of aIns[] by d bytes cannot be (easily) accomplished +// ** then return false. +// ** +// ** The d parameter is guaranteed to be between 1 and 8. +// ** +// ** This routine is an optimization. A correct answer is obtained if it +// ** always leaves the output unchanged and returns false. +// */ +func _jsonBlobOverwrite(tls *libc.TLS, aOut uintptr, aIns uintptr, nIns Tu32, d Tu32) (r int32) { + var i, szPayload Tu32 + var szHdr Tu8 + _, _, _ = i, szHdr, szPayload /* Size of header before expansion */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aIns)))&int32(0x0f) <= int32(2) { + return 0 + } /* Cannot enlarge NULL, true, false */ + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aIns))) >> libc.Int32FromInt32(4) { + default: /* aIns[] header size 1 */ + if int32(1)<> uint32(8) + } + return int32(1) +} + +// C documentation +// +// /* +// ** Insert a new entry into the cache. If the cache is full, expel +// ** the least recently used entry. Return SQLITE_OK on success or a +// ** result code otherwise. +// ** +// ** Cache entries are stored in age order, oldest first. +// */ +func _jsonCacheInsert(tls *libc.TLS, ctx uintptr, pParse uintptr) (r int32) { + var db, p uintptr + _, _ = db, p + p = Xsqlite3_get_auxdata(tls, ctx, -int32(429938)) + if p == uintptr(0) { + db = Xsqlite3_context_db_handle(tls, ctx) + p = _sqlite3DbMallocZero(tls, db, uint64(48)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TJsonCache)(unsafe.Pointer(p)).Fdb = db + Xsqlite3_set_auxdata(tls, ctx, -int32(429938), p, __ccgo_fp(_jsonCacheDeleteGeneric)) + p = Xsqlite3_get_auxdata(tls, ctx, -int32(429938)) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + } + if (*TJsonCache)(unsafe.Pointer(p)).FnUsed >= int32(JSON_CACHE_SIZE) { + _jsonParseFree(tls, **(**uintptr)(__ccgo_up(p + 16))) + libc.Xmemmove(tls, p+16, p+16+1*8, libc.Uint64FromInt32(libc.Int32FromInt32(JSON_CACHE_SIZE)-libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + (*TJsonCache)(unsafe.Pointer(p)).FnUsed = libc.Int32FromInt32(JSON_CACHE_SIZE) - libc.Int32FromInt32(1) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FeEdit = uint8(0) + (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef = (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef + 1 + (*TJsonParse)(unsafe.Pointer(pParse)).FbReadOnly = uint8(1) + **(**uintptr)(__ccgo_up(p + 16 + uintptr((*TJsonCache)(unsafe.Pointer(p)).FnUsed)*8)) = pParse + (*TJsonCache)(unsafe.Pointer(p)).FnUsed = (*TJsonCache)(unsafe.Pointer(p)).FnUsed + 1 + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Search for a cached translation the json text supplied by pArg. Return +// ** the JsonParse object if found. Return NULL if not found. +// ** +// ** When a match if found, the matching entry is moved to become the +// ** most-recently used entry if it isn't so already. +// ** +// ** The JsonParse object returned still belongs to the Cache and might +// ** be deleted at any moment. If the caller wants the JsonParse to +// ** linger, it needs to increment the nPJRef reference counter. +// */ +func _jsonCacheSearch(tls *libc.TLS, ctx uintptr, pArg uintptr) (r uintptr) { + var i, nJson int32 + var p, tmp, zJson uintptr + _, _, _, _, _ = i, nJson, p, tmp, zJson + if Xsqlite3_value_type(tls, pArg) != int32(SQLITE_TEXT) { + return uintptr(0) + } + zJson = Xsqlite3_value_text(tls, pArg) + if zJson == uintptr(0) { + return uintptr(0) + } + nJson = Xsqlite3_value_bytes(tls, pArg) + p = Xsqlite3_get_auxdata(tls, ctx, -int32(429938)) + if p == uintptr(0) { + return uintptr(0) + } + i = 0 + for { + if !(i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed) { + break + } + if (*TJsonParse)(unsafe.Pointer(**(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)))).FzJson == zJson { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i >= (*TJsonCache)(unsafe.Pointer(p)).FnUsed { + i = 0 + for { + if !(i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed) { + break + } + if (*TJsonParse)(unsafe.Pointer(**(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)))).FnJson != nJson { + goto _2 + } + if libc.Xmemcmp(tls, (*TJsonParse)(unsafe.Pointer(**(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)))).FzJson, zJson, libc.Uint64FromInt32(nJson)) == 0 { + break + } + goto _2 + _2: + ; + i = i + 1 + } + } + if i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed { + if i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed-int32(1) { + /* Make the matching entry the most recently used entry */ + tmp = **(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)) + libc.Xmemmove(tls, p+16+uintptr(i)*8, p+16+uintptr(i+int32(1))*8, libc.Uint64FromInt32((*TJsonCache)(unsafe.Pointer(p)).FnUsed-i-libc.Int32FromInt32(1))*uint64(8)) + **(**uintptr)(__ccgo_up(p + 16 + uintptr((*TJsonCache)(unsafe.Pointer(p)).FnUsed-int32(1))*8)) = tmp + i = (*TJsonCache)(unsafe.Pointer(p)).FnUsed - int32(1) + } + return **(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8)) + } else { + return uintptr(0) + } + return r +} + +/************************************************************************** +** Utility routines for dealing with JsonString objects +**************************************************************************/ + +// C documentation +// +// /* +// ** RFC-7396 MergePatch for two JSONB blobs. +// ** +// ** pTarget is the target. pPatch is the patch. The target is updated +// ** in place. The patch is read-only. +// ** +// ** The original RFC-7396 algorithm is this: +// ** +// ** define MergePatch(Target, Patch): +// ** if Patch is an Object: +// ** if Target is not an Object: +// ** Target = {} # Ignore the contents and set it to an empty Object +// ** for each Name/Value pair in Patch: +// ** if Value is null: +// ** if Name exists in Target: +// ** remove the Name/Value pair from Target +// ** else: +// ** Target[Name] = MergePatch(Target[Name], Value) +// ** return Target +// ** else: +// ** return Patch +// ** +// ** Here is an equivalent algorithm restructured to show the actual +// ** implementation: +// ** +// ** 01 define MergePatch(Target, Patch): +// ** 02 if Patch is not an Object: +// ** 03 return Patch +// ** 04 else: // if Patch is an Object +// ** 05 if Target is not an Object: +// ** 06 Target = {} +// ** 07 for each Name/Value pair in Patch: +// ** 08 if Name exists in Target: +// ** 09 if Value is null: +// ** 10 remove the Name/Value pair from Target +// ** 11 else +// ** 12 Target[name] = MergePatch(Target[Name], Value) +// ** 13 else if Value is not NULL: +// ** 14 if Value is not an Object: +// ** 15 Target[name] = Value +// ** 16 else: +// ** 17 Target[name] = MergePatch('{}',value) +// ** 18 return Target +// ** | +// ** ^---- Line numbers referenced in comments in the implementation +// */ +func _jsonMergePatch(tls *libc.TLS, pTarget uintptr, iTarget Tu32, pPatch uintptr, iPatch Tu32, iDepth Tu32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ePLabel, eTLabel, x Tu8 + var iPCursor, iPEnd, iPLabel, iPValue, iTCursor, iTEnd, iTEndBE, iTLabel, iTStart, iTValue, n, nPLabel, nPValue, nTLabel, nTValue, szNew, szPatch, szTarget Tu32 + var isEqual, rc, rc1, savedDelta, savedDelta1, v1 int32 + var _ /* sz at bp+0 */ Tu32 + var _ /* szPLabel at bp+12 */ Tu32 + var _ /* szPValue at bp+16 */ Tu32 + var _ /* szTLabel at bp+4 */ Tu32 + var _ /* szTValue at bp+8 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ePLabel, eTLabel, iPCursor, iPEnd, iPLabel, iPValue, iTCursor, iTEnd, iTEndBE, iTLabel, iTStart, iTValue, isEqual, n, nPLabel, nPValue, nTLabel, nTValue, rc, rc1, savedDelta, savedDelta1, szNew, szPatch, szTarget, x, v1 + **(**Tu32)(__ccgo_up(bp)) = uint32(0) /* Node type of the target label */ + iTLabel = uint32(0) /* Index of the label */ + nTLabel = uint32(0) /* Header size in bytes for the target label */ + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) /* Size of the target label payload */ + iTValue = uint32(0) /* Index of the target value */ + nTValue = uint32(0) /* Header size of the target value */ + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(0) /* Payload size of the patch value */ + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob + uintptr(iPatch)))) & int32(0x0f)) + if libc.Int32FromUint8(x) != int32(JSONB_OBJECT) { /* Total size of the target, header+payload */ + n = _jsonbPayloadSize(tls, pPatch, iPatch, bp) + szPatch = n + **(**Tu32)(__ccgo_up(bp)) + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, pTarget, iTarget, bp) + szTarget = n + **(**Tu32)(__ccgo_up(bp)) + _jsonBlobEdit(tls, pTarget, iTarget, szTarget, (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPatch), szPatch) + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + v1 = int32(JSON_MERGE_OOM) + } else { + v1 = JSON_MERGE_OK + } + return v1 /* Line 03 */ + } + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTarget)))) & int32(0x0f)) + if libc.Int32FromUint8(x) != int32(JSONB_OBJECT) { /* Algorithm line 05 */ + n = _jsonbPayloadSize(tls, pTarget, iTarget, bp) + _jsonBlobEdit(tls, pTarget, iTarget+n, **(**Tu32)(__ccgo_up(bp)), uintptr(0), uint32(0)) + x = **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTarget))) + **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTarget))) = libc.Uint8FromInt32(libc.Int32FromUint8(x)&int32(0xf0) | int32(JSONB_OBJECT)) + } + n = _jsonbPayloadSize(tls, pPatch, iPatch, bp) + if n == uint32(0) { + return int32(JSON_MERGE_BADPATCH) + } + iPCursor = iPatch + n + iPEnd = iPCursor + **(**Tu32)(__ccgo_up(bp)) + n = _jsonbPayloadSize(tls, pTarget, iTarget, bp) + if n == uint32(0) { + return int32(JSON_MERGE_BADTARGET) + } + iTStart = iTarget + n + iTEndBE = iTStart + **(**Tu32)(__ccgo_up(bp)) + for iPCursor < iPEnd { /* Algorithm line 07 */ + iPLabel = iPCursor + ePLabel = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob + uintptr(iPCursor)))) & int32(0x0f)) + if libc.Int32FromUint8(ePLabel) < int32(JSONB_TEXT) || libc.Int32FromUint8(ePLabel) > int32(JSONB_TEXTRAW) { + return int32(JSON_MERGE_BADPATCH) + } + nPLabel = _jsonbPayloadSize(tls, pPatch, iPCursor, bp+12) + if nPLabel == uint32(0) { + return int32(JSON_MERGE_BADPATCH) + } + iPValue = iPCursor + nPLabel + **(**Tu32)(__ccgo_up(bp + 12)) + if iPValue >= iPEnd { + return int32(JSON_MERGE_BADPATCH) + } + nPValue = _jsonbPayloadSize(tls, pPatch, iPValue, bp+16) + if nPValue == uint32(0) { + return int32(JSON_MERGE_BADPATCH) + } + iPCursor = iPValue + nPValue + **(**Tu32)(__ccgo_up(bp + 16)) + if iPCursor > iPEnd { + return int32(JSON_MERGE_BADPATCH) + } + iTCursor = iTStart + iTEnd = iTEndBE + libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta) + for iTCursor < iTEnd { /* true if the patch and target labels match */ + iTLabel = iTCursor + eTLabel = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTCursor)))) & int32(0x0f)) + if libc.Int32FromUint8(eTLabel) < int32(JSONB_TEXT) || libc.Int32FromUint8(eTLabel) > int32(JSONB_TEXTRAW) { + return int32(JSON_MERGE_BADTARGET) + } + nTLabel = _jsonbPayloadSize(tls, pTarget, iTCursor, bp+4) + if nTLabel == uint32(0) { + return int32(JSON_MERGE_BADTARGET) + } + iTValue = iTLabel + nTLabel + **(**Tu32)(__ccgo_up(bp + 4)) + if iTValue >= iTEnd { + return int32(JSON_MERGE_BADTARGET) + } + nTValue = _jsonbPayloadSize(tls, pTarget, iTValue, bp+8) + if nTValue == uint32(0) { + return int32(JSON_MERGE_BADTARGET) + } + if iTValue+nTValue+**(**Tu32)(__ccgo_up(bp + 8)) > iTEnd { + return int32(JSON_MERGE_BADTARGET) + } + isEqual = _jsonLabelCompare(tls, (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPLabel+nPLabel), **(**Tu32)(__ccgo_up(bp + 12)), libc.BoolInt32(libc.Int32FromUint8(ePLabel) == int32(JSONB_TEXT) || libc.Int32FromUint8(ePLabel) == int32(JSONB_TEXTRAW)), (*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob+uintptr(iTLabel+nTLabel), **(**Tu32)(__ccgo_up(bp + 4)), libc.BoolInt32(libc.Int32FromUint8(eTLabel) == int32(JSONB_TEXT) || libc.Int32FromUint8(eTLabel) == int32(JSONB_TEXTRAW))) + if isEqual != 0 { + break + } + iTCursor = iTValue + nTValue + **(**Tu32)(__ccgo_up(bp + 8)) + } + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob + uintptr(iPValue)))) & int32(0x0f)) + if iTCursor < iTEnd { + /* A match was found. Algorithm line 08 */ + if libc.Int32FromUint8(x) == 0 { + /* Patch value is NULL. Algorithm line 09 */ + _jsonBlobEdit(tls, pTarget, iTLabel, nTLabel+**(**Tu32)(__ccgo_up(bp + 4))+nTValue+**(**Tu32)(__ccgo_up(bp + 8)), uintptr(0), uint32(0)) + /* vvvvvv----- No OOM on a delete-only edit */ + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + return int32(JSON_MERGE_OOM) + } + } else { + savedDelta = (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta + (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta = 0 + if iDepth >= uint32(JSON_MAX_DEPTH) { + return int32(JSON_MERGE_TOODEEP) + } + rc = _jsonMergePatch(tls, pTarget, iTValue, pPatch, iPValue, iDepth+uint32(1)) + if rc != 0 { + return rc + } + **(**int32)(__ccgo_up(pTarget + 52)) += savedDelta + } + } else { + if libc.Int32FromUint8(x) > 0 { /* Algorithm line 13 */ + /* No match and patch value is not NULL */ + szNew = **(**Tu32)(__ccgo_up(bp + 12)) + nPLabel + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob + uintptr(iPValue))))&int32(0x0f) != int32(JSONB_OBJECT) { /* Line 14 */ + _jsonBlobEdit(tls, pTarget, iTEnd, uint32(0), uintptr(0), **(**Tu32)(__ccgo_up(bp + 16))+nPValue+szNew) + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + return int32(JSON_MERGE_OOM) + } + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob+uintptr(iTEnd), (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPLabel), uint64(szNew)) + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob+uintptr(iTEnd+szNew), (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPValue), uint64(**(**Tu32)(__ccgo_up(bp + 16))+nPValue)) + } else { + _jsonBlobEdit(tls, pTarget, iTEnd, uint32(0), uintptr(0), szNew+uint32(1)) + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + return int32(JSON_MERGE_OOM) + } + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob+uintptr(iTEnd), (*TJsonParse)(unsafe.Pointer(pPatch)).FaBlob+uintptr(iPLabel), uint64(szNew)) + **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pTarget)).FaBlob + uintptr(iTEnd+szNew))) = uint8(0x00) + savedDelta1 = (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta + (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta = 0 + if iDepth >= uint32(JSON_MAX_DEPTH) { + return int32(JSON_MERGE_TOODEEP) + } + rc1 = _jsonMergePatch(tls, pTarget, iTEnd+szNew, pPatch, iPValue, iDepth+uint32(1)) + if rc1 != 0 { + return rc1 + } + **(**int32)(__ccgo_up(pTarget + 52)) += savedDelta1 + } + } + } + } + if (*TJsonParse)(unsafe.Pointer(pTarget)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pTarget, iTarget) + } + if (*TJsonParse)(unsafe.Pointer(pTarget)).Foom != 0 { + v1 = int32(JSON_MERGE_OOM) + } else { + v1 = JSON_MERGE_OK + } + return v1 +} + +// C documentation +// +// /* +// ** The input string pStr is a well-formed JSON text string. Convert +// ** this into the JSONB format and make it the return value of the +// ** SQL function. +// */ +func _jsonReturnStringAsBlob(tls *libc.TLS, pStr uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var _ /* px at bp+0 */ TJsonParse + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TJsonParse)(__ccgo_up(bp))).FzJson = (*TJsonString)(unsafe.Pointer(pStr)).FzBuf + (**(**TJsonParse)(__ccgo_up(bp))).FnJson = libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed) + (**(**TJsonParse)(__ccgo_up(bp))).Fdb = Xsqlite3_context_db_handle(tls, (*TJsonString)(unsafe.Pointer(pStr)).FpCtx) + _jsonTranslateTextToBlob(tls, bp, uint32(0)) + if (**(**TJsonParse)(__ccgo_up(bp))).Foom != 0 { + _sqlite3DbFree(tls, (**(**TJsonParse)(__ccgo_up(bp))).Fdb, (**(**TJsonParse)(__ccgo_up(bp))).FaBlob) + Xsqlite3_result_error_nomem(tls, (*TJsonString)(unsafe.Pointer(pStr)).FpCtx) + } else { + Xsqlite3_result_blob(tls, (*TJsonString)(unsafe.Pointer(pStr)).FpCtx, (**(**TJsonParse)(__ccgo_up(bp))).FaBlob, libc.Int32FromUint32((**(**TJsonParse)(__ccgo_up(bp))).FnBlob), __ccgo_fp(_sqlite3RowSetClear)) + } +} + +// C documentation +// +// /* +// ** Load the content from either the sqlite_stat4 +// ** into the relevant Index.aSample[] arrays. +// ** +// ** Arguments zSql1 and zSql2 must point to SQL statements that return +// ** data equivalent to the following: +// ** +// ** zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx +// ** zSql2: SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4 +// ** +// ** where %Q is replaced with the database name before the SQL is executed. +// */ +func _loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, nByte Ti64 + var nCol, nIdxCol, nSample, rc int32 + var pIdx, pIdx1, pPrevIdx, pPtr, pSample, pSpace, zIndex, zIndex1, zSql uintptr + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, nByte, nCol, nIdxCol, nSample, pIdx, pIdx1, pPrevIdx, pPtr, pSample, pSpace, rc, zIndex, zIndex1, zSql /* Result codes from subroutines */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Text of the SQL statement */ + pPrevIdx = uintptr(0) /* A slot in pIdx->aSample[] */ + zSql = _sqlite3MPrintf(tls, db, zSql1, libc.VaList(bp+16, zDb)) + if !(zSql != 0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_prepare(tls, db, zSql, -int32(1), bp, uintptr(0)) + _sqlite3DbFree(tls, db, zSql) + if rc != 0 { + return rc + } + for Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { + nIdxCol = int32(1) /* Available memory as a u8 for easier manipulation */ + zIndex = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + if zIndex == uintptr(0) { + continue + } + nSample = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + pIdx = _findIndexOrPrimaryKey(tls, db, zIndex, zDb) + if pIdx == uintptr(0) { + continue + } + if (*TIndex)(unsafe.Pointer(pIdx)).FaSample != uintptr(0) { + /* The same index appears in sqlite_stat4 under multiple names */ + continue + } + if !((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + nIdxCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + } else { + nIdxCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } + (*TIndex)(unsafe.Pointer(pIdx)).FnSampleCol = nIdxCol + (*TIndex)(unsafe.Pointer(pIdx)).FmxSample = nSample + nByte = libc.Int64FromUint64((libc.Uint64FromInt64(40)*libc.Uint64FromInt32(nSample) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(nIdxCol)*libc.Uint64FromInt32(3)*libc.Uint64FromInt32(nSample))) + nByte = libc.Int64FromUint64(uint64(nByte) + uint64(libc.Uint64FromInt32(nIdxCol)*libc.Uint64FromInt64(8))) /* Space for Index.aAvgEq[] */ + (*TIndex)(unsafe.Pointer(pIdx)).FaSample = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte)) + if (*TIndex)(unsafe.Pointer(pIdx)).FaSample == uintptr(0) { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return int32(SQLITE_NOMEM) + } + pPtr = (*TIndex)(unsafe.Pointer(pIdx)).FaSample + pPtr = pPtr + uintptr((libc.Uint64FromInt32(nSample)*libc.Uint64FromInt64(40)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + pSpace = pPtr + (*TIndex)(unsafe.Pointer(pIdx)).FaAvgEq = pSpace + pSpace = pSpace + uintptr(nIdxCol)*8 + **(**Tu32)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FpTable + 48)) |= uint32(TF_HasStat4) + i = 0 + for { + if !(i < int64(nSample)) { + break + } + (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*40))).FanEq = pSpace + pSpace = pSpace + uintptr(nIdxCol)*8 + (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*40))).FanLt = pSpace + pSpace = pSpace + uintptr(nIdxCol)*8 + (**(**TIndexSample)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*40))).FanDLt = pSpace + pSpace = pSpace + uintptr(nIdxCol)*8 + goto _1 + _1: + ; + i = i + 1 + } + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc != 0 { + return rc + } + zSql = _sqlite3MPrintf(tls, db, zSql2, libc.VaList(bp+16, zDb)) + if !(zSql != 0) { + return int32(SQLITE_NOMEM) + } + rc = Xsqlite3_prepare(tls, db, zSql, -int32(1), bp, uintptr(0)) + _sqlite3DbFree(tls, db, zSql) + if rc != 0 { + return rc + } + for Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) { /* Pointer to the index object */ + nCol = int32(1) /* Number of columns in index */ + zIndex1 = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + if zIndex1 == uintptr(0) { + continue + } + pIdx1 = _findIndexOrPrimaryKey(tls, db, zIndex1, zDb) + if pIdx1 == uintptr(0) { + continue + } + if (*TIndex)(unsafe.Pointer(pIdx1)).FnSample >= (*TIndex)(unsafe.Pointer(pIdx1)).FmxSample { + /* Too many slots used because the same index appears in + ** sqlite_stat4 using multiple names */ + continue + } + /* This next condition is true if data has already been loaded from + ** the sqlite_stat4 table. */ + nCol = (*TIndex)(unsafe.Pointer(pIdx1)).FnSampleCol + if pIdx1 != pPrevIdx { + _initAvgEq(tls, pPrevIdx) + pPrevIdx = pIdx1 + } + pSample = (*TIndex)(unsafe.Pointer(pIdx1)).FaSample + uintptr((*TIndex)(unsafe.Pointer(pIdx1)).FnSample)*40 + _decodeIntArray(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)), nCol, (*TIndexSample)(unsafe.Pointer(pSample)).FanEq, uintptr(0), uintptr(0)) + _decodeIntArray(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(2)), nCol, (*TIndexSample)(unsafe.Pointer(pSample)).FanLt, uintptr(0), uintptr(0)) + _decodeIntArray(tls, Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)), nCol, (*TIndexSample)(unsafe.Pointer(pSample)).FanDLt, uintptr(0), uintptr(0)) + /* Take a copy of the sample. Add 8 extra 0x00 bytes the end of the buffer. + ** This is in case the sample record is corrupted. In that case, the + ** sqlite3VdbeRecordCompare() may read up to two varints past the + ** end of the allocated buffer before it realizes it is dealing with + ** a corrupt record. Or it might try to read a large integer from the + ** buffer. In any case, eight 0x00 bytes prevents this from causing + ** a buffer overread. */ + (*TIndexSample)(unsafe.Pointer(pSample)).Fn = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + (*TIndexSample)(unsafe.Pointer(pSample)).Fp = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt32((*TIndexSample)(unsafe.Pointer(pSample)).Fn+int32(8))) + if (*TIndexSample)(unsafe.Pointer(pSample)).Fp == uintptr(0) { + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + return int32(SQLITE_NOMEM) + } + if (*TIndexSample)(unsafe.Pointer(pSample)).Fn != 0 { + libc.Xmemcpy(tls, (*TIndexSample)(unsafe.Pointer(pSample)).Fp, Xsqlite3_column_blob(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)), libc.Uint64FromInt32((*TIndexSample)(unsafe.Pointer(pSample)).Fn)) + } + (*TIndex)(unsafe.Pointer(pIdx1)).FnSample = (*TIndex)(unsafe.Pointer(pIdx1)).FnSample + 1 + } + rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + _initAvgEq(tls, pPrevIdx) + } + return rc +} + +// C documentation +// +// /* +// ** Read data from an memdb-file. +// */ +func _memdbRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) { + var p uintptr + _ = p + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + _memdbEnter(tls, p) + if iOfst+int64(iAmt) > (*TMemStore)(unsafe.Pointer(p)).Fsz { + libc.Xmemset(tls, zBuf, 0, libc.Uint64FromInt32(iAmt)) + if iOfst < (*TMemStore)(unsafe.Pointer(p)).Fsz { + libc.Xmemcpy(tls, zBuf, (*TMemStore)(unsafe.Pointer(p)).FaData+uintptr(iOfst), libc.Uint64FromInt64((*TMemStore)(unsafe.Pointer(p)).Fsz-iOfst)) + } + _memdbLeave(tls, p) + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(2)< (*TMemStore)(unsafe.Pointer(p)).Fsz { + if v2 = iOfst+int64(iAmt) > (*TMemStore)(unsafe.Pointer(p)).FszAlloc; v2 { + v1 = _memdbEnlarge(tls, p, iOfst+int64(iAmt)) + rc = v1 + } + if v2 && v1 != SQLITE_OK { + _memdbLeave(tls, p) + return rc + } + if iOfst > (*TMemStore)(unsafe.Pointer(p)).Fsz { + libc.Xmemset(tls, (*TMemStore)(unsafe.Pointer(p)).FaData+uintptr((*TMemStore)(unsafe.Pointer(p)).Fsz), 0, libc.Uint64FromInt64(iOfst-(*TMemStore)(unsafe.Pointer(p)).Fsz)) + } + (*TMemStore)(unsafe.Pointer(p)).Fsz = iOfst + int64(iAmt) + } + libc.Xmemcpy(tls, (*TMemStore)(unsafe.Pointer(p)).FaData+uintptr(iOfst), z, libc.Uint64FromInt32(iAmt)) + _memdbLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Read data from the in-memory journal file. This is the implementation +// ** of the sqlite3_vfs.xRead method. +// */ +func _memjrnlRead(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) { + var iChunkOffset, iSpace, nCopy, nRead, v5 int32 + var iOff Tsqlite3_int64 + var p, pChunk, zOut, v2 uintptr + var v3 bool + var v6 int64 + _, _, _, _, _, _, _, _, _, _, _, _ = iChunkOffset, iOff, iSpace, nCopy, nRead, p, pChunk, zOut, v2, v3, v5, v6 + p = pJfd + zOut = zBuf + nRead = iAmt + if int64(iAmt)+iOfst > (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(2)<= 0; v3 { + v2 = (*TFileChunk)(unsafe.Pointer(pChunk)).FpNext + pChunk = v2 + } + if !(v3 && v2 != uintptr(0) && nRead > 0) { + break + } + } + if pChunk != 0 { + v6 = iOfst + int64(iAmt) + } else { + v6 = 0 + } + (*TMemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset = v6 + (*TMemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = pChunk + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Write data to the file. +// */ +func _memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) { + var iChunkOffset, iSpace, nWrite, rc, v1 int32 + var p, pChunk, pNew, zWrite, v2 uintptr + _, _, _, _, _, _, _, _, _, _ = iChunkOffset, iSpace, nWrite, p, pChunk, pNew, rc, zWrite, v1, v2 + p = pJfd + nWrite = iAmt + zWrite = zBuf + /* If the file should be created now, create it and write the new data + ** into the file on disk. */ + if (*TMemJournal)(unsafe.Pointer(p)).FnSpill > 0 && int64(iAmt)+iOfst > int64((*TMemJournal)(unsafe.Pointer(p)).FnSpill) { + rc = _memjrnlCreateFile(tls, p) + if rc == SQLITE_OK { + rc = _sqlite3OsWrite(tls, pJfd, zBuf, iAmt, iOfst) + } + return rc + } else { + /* An in-memory journal file should only ever be appended to. Random + ** access writes are not required. The only exception to this is when + ** the in-memory journal is being used by a connection using the + ** atomic-write optimization. In this case the first 28 bytes of the + ** journal file may be written as part of committing the transaction. */ + if iOfst > 0 && iOfst != (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset { + _memjrnlTruncate(tls, pJfd, iOfst) + } + if iOfst == 0 && (*TMemJournal)(unsafe.Pointer(p)).FpFirst != 0 { + libc.Xmemcpy(tls, (*TMemJournal)(unsafe.Pointer(p)).FpFirst+8, zBuf, libc.Uint64FromInt32(iAmt)) + } else { + for nWrite > 0 { + pChunk = (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FpChunk + iChunkOffset = int32((*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset % int64((*TMemJournal)(unsafe.Pointer(p)).FnChunkSize)) + if nWrite < (*TMemJournal)(unsafe.Pointer(p)).FnChunkSize-iChunkOffset { + v1 = nWrite + } else { + v1 = (*TMemJournal)(unsafe.Pointer(p)).FnChunkSize - iChunkOffset + } + iSpace = v1 + if iChunkOffset == 0 { + /* New chunk is required to extend the file. */ + pNew = Xsqlite3_malloc(tls, libc.Int32FromUint64(libc.Uint64FromInt64(16)+libc.Uint64FromInt32((*TMemJournal)(unsafe.Pointer(p)).FnChunkSize-libc.Int32FromInt32(8)))) + if !(pNew != 0) { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(12)< uint32(0) { + return SQLITE_OK + } + pP1 = (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 + data = (*TMemPage)(unsafe.Pointer(pP1)).FaData + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pP1)).FpDbPage) + if rc != 0 { + return rc + } + libc.Xmemcpy(tls, data, uintptr(unsafe.Pointer(&_zMagicHeader)), uint64(16)) + **(**uint8)(__ccgo_up(data + 16)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FpageSize >> libc.Int32FromInt32(8) & libc.Uint32FromInt32(0xff)) + **(**uint8)(__ccgo_up(data + 17)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FpageSize >> libc.Int32FromInt32(16) & libc.Uint32FromInt32(0xff)) + **(**uint8)(__ccgo_up(data + 18)) = uint8(1) + **(**uint8)(__ccgo_up(data + 19)) = uint8(1) + **(**uint8)(__ccgo_up(data + 20)) = uint8((*TBtShared)(unsafe.Pointer(pBt)).FpageSize - (*TBtShared)(unsafe.Pointer(pBt)).FusableSize) + **(**uint8)(__ccgo_up(data + 21)) = uint8(64) + **(**uint8)(__ccgo_up(data + 22)) = uint8(32) + **(**uint8)(__ccgo_up(data + 23)) = uint8(32) + libc.Xmemset(tls, data+24, 0, libc.Uint64FromInt32(libc.Int32FromInt32(100)-libc.Int32FromInt32(24))) + _zeroPage(tls, pP1, libc.Int32FromInt32(PTF_INTKEY)|libc.Int32FromInt32(PTF_LEAF)|libc.Int32FromInt32(PTF_LEAFDATA)) + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + _sqlite3Put4byte(tls, data+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(4)*libc.Int32FromInt32(4)), uint32((*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum)) + _sqlite3Put4byte(tls, data+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(7)*libc.Int32FromInt32(4)), uint32((*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum)) + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = uint32(1) + **(**uint8)(__ccgo_up(data + 31)) = uint8(1) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Remove the cell with index iCell from node pNode. +// */ +func _nodeDeleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32) { + var nByte int32 + var pDst, pSrc uintptr + _, _, _ = nByte, pDst, pSrc + pDst = (*TRtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(int32(4)+libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*iCell) + pSrc = pDst + uintptr((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) + nByte = (_readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) - iCell - int32(1)) * libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) + libc.Xmemmove(tls, pDst, pSrc, libc.Uint64FromInt32(nByte)) + _writeInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2, _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2)-int32(1)) + (*TRtreeNode)(unsafe.Pointer(pNode)).FisDirty = int32(1) +} + +// C documentation +// +// /* +// ** Allocate and return new r-tree node. Initially, (RtreeNode.iNode==0), +// ** indicating that node has not yet been assigned a node number. It is +// ** assigned a node number when nodeWrite() is called to write the +// ** node contents out to the database. +// */ +func _nodeNew(tls *libc.TLS, pRtree uintptr, pParent uintptr) (r uintptr) { + var pNode uintptr + _ = pNode + pNode = Xsqlite3_malloc64(tls, uint64(uint64(40)+libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize))) + if pNode != 0 { + libc.Xmemset(tls, pNode, 0, uint64(40)+libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize)) + (*TRtreeNode)(unsafe.Pointer(pNode)).FzData = pNode + 1*40 + (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef = int32(1) + (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef = (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef + 1 + (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent + (*TRtreeNode)(unsafe.Pointer(pNode)).FisDirty = int32(1) + _nodeReference(tls, pParent) + } + return pNode +} + +// C documentation +// +// /* +// ** Clear the content of node p (set all bytes to 0x00). +// */ +func _nodeZero(tls *libc.TLS, pRtree uintptr, p uintptr) { + libc.Xmemset(tls, (*TRtreeNode)(unsafe.Pointer(p)).FzData+2, 0, libc.Uint64FromInt32((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize-int32(2))) + (*TRtreeNode)(unsafe.Pointer(p)).FisDirty = int32(1) +} + +// C documentation +// +// /* +// ** Search the free-list on page pPg for space to store a cell nByte bytes in +// ** size. If one can be found, return a pointer to the space and remove it +// ** from the free-list. +// ** +// ** If no suitable space can be found on the free-list, return NULL. +// ** +// ** This function may detect corruption within pPg. If corruption is +// ** detected then *pRc is set to SQLITE_CORRUPT and NULL is returned. +// ** +// ** Slots on the free list that are between 1 and 3 bytes larger than nByte +// ** will be ignored if adding the extra space to the fragmentation count +// ** causes the fragmentation count to exceed 60. +// */ +func _pageFindSlot(tls *libc.TLS, pPg uintptr, nByte int32, pRc uintptr) (r uintptr) { + var aData, pTmp, v2 uintptr + var hdr, iAddr, maxPC, pc, size, x, v1 int32 + _, _, _, _, _, _, _, _, _, _ = aData, hdr, iAddr, maxPC, pTmp, pc, size, x, v1, v2 + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FhdrOffset) /* Offset to page header */ + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData /* Page data */ + iAddr = hdr + int32(1) /* Address of ptr to pc */ + pTmp = aData + uintptr(iAddr) /* Temporary ptr into aData[] */ + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTmp)))<= 0 { + if x < int32(4) { + /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total + ** number of bytes in fragments may not exceed 60. */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(7))))) > int32(57) { + return uintptr(0) + } + /* Remove the slot from the free-list. Update the number of + ** fragmented bytes within the page. */ + libc.Xmemcpy(tls, aData+uintptr(iAddr), aData+uintptr(pc), uint64(2)) + v2 = aData + uintptr(hdr+int32(7)) + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) + libc.Int32FromUint8(libc.Uint8FromInt32(x))) + return aData + uintptr(pc) + } else { + if x+pc > maxPC { + /* This slot extends off the end of the usable part of the page */ + **(**int32)(__ccgo_up(pRc)) = _sqlite3CorruptError(tls, int32(74920)) + return uintptr(0) + } else { + /* The slot remains on the free-list. Reduce its size to account + ** for the portion used by the new allocation. */ + **(**Tu8)(__ccgo_up(aData + uintptr(pc+int32(2)))) = libc.Uint8FromInt32(x >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(pc+int32(2)) + 1)) = libc.Uint8FromInt32(x) + } + } + return aData + uintptr(pc+x) + } + iAddr = pc + pTmp = aData + uintptr(pc) + pc = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTmp)))< maxPC+nByte-int32(4) { + /* The free slot chain extends off the end of the page */ + **(**int32)(__ccgo_up(pRc)) = _sqlite3CorruptError(tls, int32(74942)) + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** The pCArray objects contains pointers to b-tree cells and the cell sizes. +// ** This function attempts to add the cells stored in the array to page pPg. +// ** If it cannot (because the page needs to be defragmented before the cells +// ** will fit), non-zero is returned. Otherwise, if the cells are added +// ** successfully, zero is returned. +// ** +// ** Argument pCellptr points to the first entry in the cell-pointer array +// ** (part of page pPg) to populate. After cell apCell[0] is written to the +// ** page body, a 16-bit offset is written to pCellptr. And so on, for each +// ** cell in the array. It is the responsibility of the caller to ensure +// ** that it is safe to overwrite this part of the cell-pointer array. +// ** +// ** When this function is called, *ppData points to the start of the +// ** content area on page pPg. If the size of the content area is extended, +// ** *ppData is updated to point to the new start of the content area +// ** before returning. +// ** +// ** Finally, argument pBegin points to the byte immediately following the +// ** end of the space required by this page for the cell-pointer area (for +// ** all cells - not just those inserted by the current call). If the content +// ** area must be extended to before this point in order to accommodate all +// ** cells in apCell[], then the cells do not fit and non-zero is returned. +// */ +func _pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, pCellptr uintptr, iFirst int32, nCell int32, pCArray uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aData, pData, pEnd, pSlot, v2 uintptr + var i, iEnd, k, sz int32 + var v3 bool + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = aData, i, iEnd, k, pData, pEnd, pSlot, sz, v2, v3 + i = iFirst /* Loop counter - cell index to insert */ + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData /* Complete page */ + pData = **(**uintptr)(__ccgo_up(ppData)) /* Content area. A subset of aData[] */ + iEnd = iFirst + nCell /* Maximum extent of cell data */ + /* Never called on page 1 */ + if iEnd <= iFirst { + return 0 + } + k = 0 + for { + if !(**(**int32)(__ccgo_up(pCArray + 80 + uintptr(k)*4)) <= i) { + break + } + goto _1 + _1: + ; + k = k + 1 + } + pEnd = **(**uintptr)(__ccgo_up(pCArray + 32 + uintptr(k)*8)) + for int32(1) != 0 { + sz = libc.Int32FromUint16(**(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2))) + if v3 = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + 1))) == 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + 2))) == 0; !v3 { + v2 = _pageFindSlot(tls, pPg, sz, bp) + pSlot = v2 + } + if v3 || v2 == uintptr(0) { + if int64(pData)-int64(pBegin) < int64(sz) { + return int32(1) + } + pData = pData - uintptr(sz) + pSlot = pData + } + /* pSlot and pCArray->apCell[i] will never overlap on a well-formed + ** database. But they might for a corrupt database. Hence use memmove() + ** since memcpy() sends SIGABORT with overlapping buffers on OpenBSD */ + if uint64(**(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8))+uintptr(sz)) > uint64(pEnd) && uint64(**(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8))) < uint64(pEnd) { + _sqlite3CorruptError(tls, int32(80911)) + return int32(1) + } + libc.Xmemmove(tls, pSlot, **(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8)), libc.Uint64FromInt32(sz)) + **(**Tu8)(__ccgo_up(pCellptr)) = libc.Uint8FromInt64((int64(pSlot) - int64(aData)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pCellptr + 1)) = libc.Uint8FromInt64(int64(pSlot) - int64(aData)) + pCellptr = pCellptr + uintptr(2) + i = i + 1 + if i >= iEnd { + break + } + if **(**int32)(__ccgo_up(pCArray + 80 + uintptr(k)*4)) <= i { + k = k + 1 + pEnd = **(**uintptr)(__ccgo_up(pCArray + 32 + uintptr(k)*8)) + } + } + **(**uintptr)(__ccgo_up(ppData)) = pData + return 0 +} + +// C documentation +// +// /* +// ** Check that there are at least nSavepoint savepoints open. If there are +// ** currently less than nSavepoints open, then open one or more savepoints +// ** to make up the difference. If the number of savepoints is already +// ** equal to nSavepoint, then this function is a no-op. +// ** +// ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error +// ** occurs while opening the sub-journal file, then an IO error code is +// ** returned. Otherwise, SQLITE_OK. +// */ +func _pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) (r int32) { + var aNew uintptr + var ii, nCurrent, rc int32 + _, _, _, _ = aNew, ii, nCurrent, rc + rc = SQLITE_OK /* Return code */ + nCurrent = (*TPager)(unsafe.Pointer(pPager)).FnSavepoint /* New Pager.aSavepoint array */ + /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM + ** if the allocation fails. Otherwise, zero the new portion in case a + ** malloc failure occurs while populating it in the for(...) loop below. + */ + aNew = _sqlite3Realloc(tls, (*TPager)(unsafe.Pointer(pPager)).FaSavepoint, uint64(uint64(56)*libc.Uint64FromInt32(nSavepoint))) + if !(aNew != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, aNew+uintptr(nCurrent)*56, 0, libc.Uint64FromInt32(nSavepoint-nCurrent)*uint64(56)) + (*TPager)(unsafe.Pointer(pPager)).FaSavepoint = aNew + /* Populate the PagerSavepoint structures just allocated. */ + ii = nCurrent + for { + if !(ii < nSavepoint) { + break + } + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FnOrig = (*TPager)(unsafe.Pointer(pPager)).FdbSize + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) && (*TPager)(unsafe.Pointer(pPager)).FjournalOff > 0 { + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FiOffset = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + } else { + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FiOffset = libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) + } + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FiSubRec = (*TPager)(unsafe.Pointer(pPager)).FnSubRec + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FpInSavepoint = _sqlite3BitvecCreate(tls, (*TPager)(unsafe.Pointer(pPager)).FdbSize) + (**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FbTruncateOnRelease = int32(1) + if !((**(**TPagerSavepoint)(__ccgo_up(aNew + uintptr(ii)*56))).FpInSavepoint != 0) { + return int32(SQLITE_NOMEM) + } + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + _sqlite3WalSavepoint(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, aNew+uintptr(ii)*56+36) + } + (*TPager)(unsafe.Pointer(pPager)).FnSavepoint = ii + int32(1) + goto _1 + _1: + ; + ii = ii + 1 + } + return rc +} + +// C documentation +// +// /* +// ** Read a single page from either the journal file (if isMainJrnl==1) or +// ** from the sub-journal (if isMainJrnl==0) and playback that page. +// ** The page begins at offset *pOffset into the file. The *pOffset +// ** value is increased to the start of the next page in the journal. +// ** +// ** The main rollback journal uses checksums - the statement journal does +// ** not. +// ** +// ** If the page number of the page record read from the (sub-)journal file +// ** is greater than the current value of Pager.dbSize, then playback is +// ** skipped and SQLITE_OK is returned. +// ** +// ** If pDone is not NULL, then it is a record of pages that have already +// ** been played back. If the page at *pOffset has already been played back +// ** (if the corresponding pDone bit is set) then skip the playback. +// ** Make sure the pDone bit corresponding to the *pOffset page is set +// ** prior to returning. +// ** +// ** If the page record is successfully read from the (sub-)journal file +// ** and played back, then SQLITE_OK is returned. If an IO error occurs +// ** while reading the record from the (sub-)journal file or while writing +// ** to the database file, then the IO error code is returned. If data +// ** is successfully read from the (sub-)journal file but appears to be +// ** corrupted, SQLITE_DONE is returned. Data is considered corrupted in +// ** two circumstances: +// ** +// ** * If the record page-number is illegal (0 or PAGER_SJ_PGNO), or +// ** * If the record is being rolled back from the main journal file +// ** and the checksum field does not match the record content. +// ** +// ** Neither of these two scenarios are possible during a savepoint rollback. +// ** +// ** If this is a savepoint rollback, then memory may have to be dynamically +// ** allocated by this function. If this is the case and an allocation fails, +// ** SQLITE_NOMEM is returned. +// */ +func _pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDone uintptr, isMainJrnl int32, isSavepnt int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aData, jfd, pData, v1 uintptr + var isSynced, rc, v2 int32 + var ofst Ti64 + var v3 bool + var _ /* cksum at bp+12 */ Tu32 + var _ /* pPg at bp+0 */ uintptr + var _ /* pgno at bp+8 */ TPgno + _, _, _, _, _, _, _, _, _ = aData, isSynced, jfd, ofst, pData, rc, v1, v2, v3 /* True if journal page is synced */ + /* isMainJrnl is 0 or 1 */ + /* isSavepnt is 0 or 1 */ + /* pDone always used on sub-journals */ + /* pDone never used on non-savepoint */ + aData = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace + /* Temp storage must have already been allocated */ + /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction + ** or savepoint rollback done at the request of the caller) or this is + ** a hot-journal rollback. If it is a hot-journal rollback, the pager + ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback + ** only reads from the main journal, not the sub-journal. + */ + /* Read the page number and page data from the journal or sub-journal + ** file. Return an error code to the caller if an IO error occurs. + */ + if isMainJrnl != 0 { + v1 = (*TPager)(unsafe.Pointer(pPager)).Fjfd + } else { + v1 = (*TPager)(unsafe.Pointer(pPager)).Fsjfd + } + jfd = v1 + rc = _read32bits(tls, jfd, **(**Ti64)(__ccgo_up(pOffset)), bp+8) + if rc != SQLITE_OK { + return rc + } + rc = _sqlite3OsRead(tls, jfd, aData, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), **(**Ti64)(__ccgo_up(pOffset))+int64(4)) + if rc != SQLITE_OK { + return rc + } + **(**Ti64)(__ccgo_up(pOffset)) += (*TPager)(unsafe.Pointer(pPager)).FpageSize + int64(4) + int64(isMainJrnl*int32(4)) + /* Sanity checking on the page. This is more important that I originally + ** thought. If a power failure occurs while the journal is being written, + ** it could cause invalid data to be written into the journal. We need to + ** detect this invalid data (with high probability) and ignore it. + */ + if **(**TPgno)(__ccgo_up(bp + 8)) == uint32(0) || **(**TPgno)(__ccgo_up(bp + 8)) == (*TPager)(unsafe.Pointer(pPager)).FlckPgno { + return int32(SQLITE_DONE) + } + if **(**TPgno)(__ccgo_up(bp + 8)) > (*TPager)(unsafe.Pointer(pPager)).FdbSize || _sqlite3BitvecTest(tls, pDone, **(**TPgno)(__ccgo_up(bp + 8))) != 0 { + return SQLITE_OK + } + if isMainJrnl != 0 { + rc = _read32bits(tls, jfd, **(**Ti64)(__ccgo_up(pOffset))-int64(4), bp+12) + if rc != 0 { + return rc + } + if !(isSavepnt != 0) && _pager_cksum(tls, pPager, aData) != **(**Tu32)(__ccgo_up(bp + 12)) { + return int32(SQLITE_DONE) + } + } + /* If this page has already been played back before during the current + ** rollback, then don't bother to play it back again. + */ + if v3 = pDone != 0; v3 { + v2 = _sqlite3BitvecSet(tls, pDone, **(**TPgno)(__ccgo_up(bp + 8))) + rc = v2 + } + if v3 && v2 != SQLITE_OK { + return rc + } + /* When playing back page 1, restore the nReserve setting + */ + if **(**TPgno)(__ccgo_up(bp + 8)) == uint32(1) && int32((*TPager)(unsafe.Pointer(pPager)).FnReserve) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + 20))) { + (*TPager)(unsafe.Pointer(pPager)).FnReserve = libc.Int16FromUint8(**(**Tu8)(__ccgo_up(aData + 20))) + } + /* If the pager is in CACHEMOD state, then there must be a copy of this + ** page in the pager cache. In this case just update the pager cache, + ** not the database file. The page is left marked dirty in this case. + ** + ** An exception to the above rule: If the database is in no-sync mode + ** and a page is moved during an incremental vacuum then the page may + ** not be in the pager cache. Later: if a malloc() or IO error occurs + ** during a Movepage() call, then the page may not be in the cache + ** either. So the condition described in the above paragraph is not + ** assert()able. + ** + ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the + ** pager cache if it exists and the main file. The page is then marked + ** not dirty. Since this code is only executed in PAGER_OPEN state for + ** a hot-journal rollback, it is guaranteed that the page-cache is empty + ** if the pager is in OPEN state. + ** + ** Ticket #1171: The statement journal might contain page content that is + ** different from the page content at the start of the transaction. + ** This occurs when a page is changed prior to the start of a statement + ** then changed again within the statement. When rolling back such a + ** statement we must not write to the original database unless we know + ** for certain that original page contents are synced into the main rollback + ** journal. Otherwise, a power loss might leave modified data in the + ** database file without an entry in the rollback journal that can + ** restore the database to its original form. Two conditions must be + ** met before writing to the database files. (1) the database must be + ** locked. (2) we know that the original page content is fully synced + ** in the main journal either because the page is not in cache or else + ** the page is marked as needSync==0. + ** + ** 2008-04-14: When attempting to vacuum a corrupt database file, it + ** is possible to fail a statement on a database that does not yet exist. + ** Do not attempt to write if database file has never been opened. + */ + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + **(**uintptr)(__ccgo_up(bp)) = _sqlite3PagerLookup(tls, pPager, **(**TPgno)(__ccgo_up(bp + 8))) + } + if isMainJrnl != 0 { + isSynced = libc.BoolInt32((*TPager)(unsafe.Pointer(pPager)).FnoSync != 0 || **(**Ti64)(__ccgo_up(pOffset)) <= (*TPager)(unsafe.Pointer(pPager)).FjournalHdr) + } else { + isSynced = libc.BoolInt32(**(**uintptr)(__ccgo_up(bp)) == uintptr(0) || 0 == libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fflags)&int32(PGHDR_NEED_SYNC)) + } + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) && (libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) >= int32(PAGER_WRITER_DBMOD) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) && isSynced != 0 { + ofst = libc.Int64FromUint32(**(**TPgno)(__ccgo_up(bp + 8))-libc.Uint32FromInt32(1)) * (*TPager)(unsafe.Pointer(pPager)).FpageSize + /* Write the data read from the journal back into the database file. + ** This is usually safe even for an encrypted database - as the data + ** was encrypted before it was written to the journal file. The exception + ** is if the data was just read from an in-memory sub-journal. In that + ** case it must be encrypted here before it is copied into the database + ** file. */ + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, aData, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), ofst) + if **(**TPgno)(__ccgo_up(bp + 8)) > (*TPager)(unsafe.Pointer(pPager)).FdbFileSize { + (*TPager)(unsafe.Pointer(pPager)).FdbFileSize = **(**TPgno)(__ccgo_up(bp + 8)) + } + if (*TPager)(unsafe.Pointer(pPager)).FpBackup != 0 { + _sqlite3BackupUpdate(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup, **(**TPgno)(__ccgo_up(bp + 8)), aData) + } + } else { + if !(isMainJrnl != 0) && **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + /* If this is a rollback of a savepoint and data was not written to + ** the database and the page is not in-memory, there is a potential + ** problem. When the page is next fetched by the b-tree layer, it + ** will be read from the database file, which may or may not be + ** current. + ** + ** There are a couple of different ways this can happen. All are quite + ** obscure. When running in synchronous mode, this can only happen + ** if the page is on the free-list at the start of the transaction, then + ** populated, then moved using sqlite3PagerMovepage(). + ** + ** The solution is to add an in-memory page to the cache containing + ** the data just read from the sub-journal. Mark the page as dirty + ** and if the pager requires a journal-sync, then mark the page as + ** requiring a journal-sync before it is written. + */ + v1 = pPager + 25 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SPILLFLAG_ROLLBACK)) + rc = _sqlite3PagerGet(tls, pPager, **(**TPgno)(__ccgo_up(bp + 8)), bp, int32(1)) + v1 = pPager + 25 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(SPILLFLAG_ROLLBACK)) + if rc != SQLITE_OK { + return rc + } + _sqlite3PcacheMakeDirty(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + if **(**uintptr)(__ccgo_up(bp)) != 0 { + pData = (*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpData + libc.Xmemcpy(tls, pData, aData, libc.Uint64FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize)) + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TPager)(unsafe.Pointer(pPager)).FxReiniter})))(tls, **(**uintptr)(__ccgo_up(bp))) + /* It used to be that sqlite3PcacheMakeClean(pPg) was called here. But + ** that call was dangerous and had no detectable benefit since the cache + ** is normally cleaned by sqlite3PcacheCleanAll() after rollback and so + ** has been removed. */ + /* If this was page 1, then restore the value of Pager.dbFileVers. + ** Do this before any decoding. */ + if **(**TPgno)(__ccgo_up(bp + 8)) == uint32(1) { + libc.Xmemcpy(tls, pPager+136, pData+24, uint64(16)) + } + _sqlite3PcacheRelease(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** This function is used to change the actual size of the database +// ** file in the file-system. This only happens when committing a transaction, +// ** or rolling back a transaction (including rolling back a hot-journal). +// ** +// ** If the main database file is not open, or the pager is not in either +// ** DBMOD or OPEN state, this function is a no-op. Otherwise, the size +// ** of the file is changed to nPage pages (nPage*pPager->pageSize bytes). +// ** If the file on disk is currently larger than nPage pages, then use the VFS +// ** xTruncate() method to truncate it. +// ** +// ** Or, it might be the case that the file on disk is smaller than +// ** nPage pages. Some operating system implementations can get confused if +// ** you try to truncate a file to some size that is larger than it +// ** currently is, so detect this case and write a single zero byte to +// ** the end of the new file instead. +// ** +// ** If successful, return SQLITE_OK. If an IO error occurs while modifying +// ** the database file, return the error code to the caller. +// */ +func _pager_truncate(tls *libc.TLS, pPager uintptr, nPage TPgno) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pTmp uintptr + var rc, szPage int32 + var _ /* currentSize at bp+0 */ Ti64 + var _ /* newSize at bp+8 */ Ti64 + _, _, _ = pTmp, rc, szPage + rc = SQLITE_OK + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) && (libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) >= int32(PAGER_WRITER_DBMOD) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) { + szPage = int32((*TPager)(unsafe.Pointer(pPager)).FpageSize) + /* TODO: Is it safe to use Pager.dbFileSize here? */ + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, bp) + **(**Ti64)(__ccgo_up(bp + 8)) = int64(szPage) * libc.Int64FromUint32(nPage) + if rc == SQLITE_OK && **(**Ti64)(__ccgo_up(bp)) != **(**Ti64)(__ccgo_up(bp + 8)) { + if **(**Ti64)(__ccgo_up(bp)) > **(**Ti64)(__ccgo_up(bp + 8)) { + rc = _sqlite3OsTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, **(**Ti64)(__ccgo_up(bp + 8))) + } else { + if **(**Ti64)(__ccgo_up(bp))+int64(szPage) <= **(**Ti64)(__ccgo_up(bp + 8)) { + pTmp = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace + libc.Xmemset(tls, pTmp, 0, libc.Uint64FromInt32(szPage)) + _sqlite3OsFileControlHint(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_SIZE_HINT), bp+8) + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, pTmp, szPage, **(**Ti64)(__ccgo_up(bp + 8))-int64(szPage)) + } + } + if rc == SQLITE_OK { + (*TPager)(unsafe.Pointer(pPager)).FdbFileSize = nPage + } + } + } + return rc +} + +// C documentation +// +// /* +// ** The argument is the first in a linked list of dirty pages connected +// ** by the PgHdr.pDirty pointer. This function writes each one of the +// ** in-memory pages in the list to the database file. The argument may +// ** be NULL, representing an empty list. In this case this function is +// ** a no-op. +// ** +// ** The pager must hold at least a RESERVED lock when this function +// ** is called. Before writing anything to the database file, this lock +// ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained, +// ** SQLITE_BUSY is returned and no data is written to the database file. +// ** +// ** If the pager is a temp-file pager and the actual file-system file +// ** is not yet open, it is created and opened before any data is +// ** written out. +// ** +// ** Once the lock has been upgraded and, if necessary, the file opened, +// ** the pages are written out to the database file in list order. Writing +// ** a page is skipped if it meets either of the following criteria: +// ** +// ** * The page number is greater than Pager.dbSize, or +// ** * The PGHDR_DONT_WRITE flag is set on the page. +// ** +// ** If writing out a page causes the database file to grow, Pager.dbFileSize +// ** is updated accordingly. If page 1 is written out, then the value cached +// ** in Pager.dbFileVers[] is updated to match the new value stored in +// ** the database file. +// ** +// ** If everything is successful, SQLITE_OK is returned. If an IO error +// ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot +// ** be obtained, SQLITE_BUSY is returned. +// */ +func _pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var offset Ti64 + var pData uintptr + var pgno TPgno + var rc int32 + var _ /* szFile at bp+0 */ Tsqlite3_int64 + _, _, _, _ = offset, pData, pgno, rc + rc = SQLITE_OK /* Return code */ + /* This function is only called for rollback pagers in WRITER_DBMOD state. */ + /* If the file is a temp-file has not yet been opened, open it now. It + ** is not possible for rc to be other than SQLITE_OK if this branch + ** is taken, as pager_wait_on_lock() is a no-op for temp-files. + */ + if !((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != libc.UintptrFromInt32(0)) { + rc = _pagerOpentemp(tls, pPager, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int32FromUint32((*TPager)(unsafe.Pointer(pPager)).FvfsFlags)) + } + /* Before the first write, give the VFS a hint of what the final + ** file size will be. + */ + if rc == SQLITE_OK && (*TPager)(unsafe.Pointer(pPager)).FdbHintSize < (*TPager)(unsafe.Pointer(pPager)).FdbSize && ((*TPgHdr)(unsafe.Pointer(pList)).FpDirty != 0 || (*TPgHdr)(unsafe.Pointer(pList)).Fpgno > (*TPager)(unsafe.Pointer(pPager)).FdbHintSize) { + **(**Tsqlite3_int64)(__ccgo_up(bp)) = (*TPager)(unsafe.Pointer(pPager)).FpageSize * libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FdbSize) + _sqlite3OsFileControlHint(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_SIZE_HINT), bp) + (*TPager)(unsafe.Pointer(pPager)).FdbHintSize = (*TPager)(unsafe.Pointer(pPager)).FdbSize + } + for rc == SQLITE_OK && pList != 0 { + pgno = (*TPgHdr)(unsafe.Pointer(pList)).Fpgno + /* If there are dirty pages in the page cache with page numbers greater + ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to + ** make the file smaller (presumably by auto-vacuum code). Do not write + ** any such pages to the file. + ** + ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag + ** set (set by sqlite3PagerDontWrite()). + */ + if pgno <= (*TPager)(unsafe.Pointer(pPager)).FdbSize && 0 == libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pList)).Fflags)&int32(PGHDR_DONT_WRITE) { + offset = libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1)) * (*TPager)(unsafe.Pointer(pPager)).FpageSize /* Data to write */ + if (*TPgHdr)(unsafe.Pointer(pList)).Fpgno == uint32(1) { + _pager_write_changecounter(tls, pList) + } + pData = (*TPgHdr)(unsafe.Pointer(pList)).FpData + /* Write out the page data. */ + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, pData, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), offset) + /* If page 1 was just written, update Pager.dbFileVers to match + ** the value now stored in the database file. If writing this + ** page caused the database file to grow, update dbFileSize. + */ + if pgno == uint32(1) { + libc.Xmemcpy(tls, pPager+136, pData+24, uint64(16)) + } + if pgno > (*TPager)(unsafe.Pointer(pPager)).FdbFileSize { + (*TPager)(unsafe.Pointer(pPager)).FdbFileSize = pgno + } + **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) = **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) + 1 + /* Update any backup objects copying the contents of this pager. */ + _sqlite3BackupUpdate(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup, pgno, (*TPgHdr)(unsafe.Pointer(pList)).FpData) + } else { + } + pList = (*TPgHdr)(unsafe.Pointer(pList)).FpDirty + } + return rc +} + +// C documentation +// +// /* +// ** Locate a pragma in the aPragmaName[] array. +// */ +func _pragmaLocate(tls *libc.TLS, zName uintptr) (r uintptr) { + var lwr, mid, rc, upr int32 + var v1 uintptr + _, _, _, _, _ = lwr, mid, rc, upr, v1 + mid = 0 + lwr = 0 + upr = libc.Int32FromUint64(libc.Uint64FromInt64(1584)/libc.Uint64FromInt64(24)) - libc.Int32FromInt32(1) + for lwr <= upr { + mid = (lwr + upr) / int32(2) + rc = Xsqlite3_stricmp(tls, zName, _aPragmaName[mid].FzName) + if rc == 0 { + break + } + if rc < 0 { + upr = mid - int32(1) + } else { + lwr = mid + int32(1) + } + } + if lwr > upr { + v1 = uintptr(0) + } else { + v1 = uintptr(unsafe.Pointer(&_aPragmaName)) + uintptr(mid)*24 + } + return v1 +} + +// C documentation +// +// /* +// ** The WHERE-clause constant propagation optimization. +// ** +// ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or +// ** CONSTANT=COLUMN that are top-level AND-connected terms that are not +// ** part of a ON clause from a LEFT JOIN, then throughout the query +// ** replace all other occurrences of COLUMN with CONSTANT. +// ** +// ** For example, the query: +// ** +// ** SELECT * FROM t1, t2, t3 WHERE t1.a=39 AND t2.b=t1.a AND t3.c=t2.b +// ** +// ** Is transformed into +// ** +// ** SELECT * FROM t1, t2, t3 WHERE t1.a=39 AND t2.b=39 AND t3.c=39 +// ** +// ** Return true if any transformations where made and false if not. +// ** +// ** Implementation note: Constant propagation is tricky due to affinity +// ** and collating sequence interactions. Consider this example: +// ** +// ** CREATE TABLE t1(a INT,b TEXT); +// ** INSERT INTO t1 VALUES(123,'0123'); +// ** SELECT * FROM t1 WHERE a=123 AND b=a; +// ** SELECT * FROM t1 WHERE a=123 AND b=123; +// ** +// ** The two SELECT statements above should return different answers. b=a +// ** is always true because the comparison uses numeric affinity, but b=123 +// ** is false because it uses text affinity and '0123' is not the same as '123'. +// ** To work around this, the expression tree is not actually changed from +// ** "b=a" to "b=123" but rather the "a" in "b=a" is tagged with EP_FixedCol +// ** and the "123" value is hung off of the pLeft pointer. Code generator +// ** routines know to generate the constant "123" instead of looking up the +// ** column value. Also, to avoid collation problems, this optimization is +// ** only attempted if the "a=123" term uses the default BINARY collation. +// ** +// ** 2021-05-25 forum post 6a06202608: Another troublesome case is... +// ** +// ** CREATE TABLE t1(x); +// ** INSERT INTO t1 VALUES(10.0); +// ** SELECT 1 FROM t1 WHERE x=10 AND x LIKE 10; +// ** +// ** The query should return no rows, because the t1.x value is '10.0' not '10' +// ** and '10.0' is not LIKE '10'. But if we are not careful, the first WHERE +// ** term "x=10" will cause the second WHERE term to become "10 LIKE 10", +// ** resulting in a false positive. To avoid this, constant propagation for +// ** columns with BLOB affinity is only allowed if the constant is used with +// ** operators ==, <=, <, >=, >, or IS in a way that will cause the correct +// ** type conversions to occur. See logic associated with the bHasAffBlob flag +// ** for details. +// */ +func _propagateConstants(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var nChng int32 + var _ /* w at bp+40 */ TWalker + var _ /* x at bp+0 */ TWhereConst + _ = nChng + nChng = 0 + (**(**TWhereConst)(__ccgo_up(bp))).FpParse = pParse + (**(**TWhereConst)(__ccgo_up(bp))).FpOomFault = (*TParse)(unsafe.Pointer(pParse)).Fdb + 103 + for cond := true; cond; cond = (**(**TWhereConst)(__ccgo_up(bp))).FnChng != 0 { + (**(**TWhereConst)(__ccgo_up(bp))).FnConst = 0 + (**(**TWhereConst)(__ccgo_up(bp))).FnChng = 0 + (**(**TWhereConst)(__ccgo_up(bp))).FapExpr = uintptr(0) + (**(**TWhereConst)(__ccgo_up(bp))).FbHasAffBlob = 0 + if (*TSelect)(unsafe.Pointer(p)).FpSrc != uintptr(0) && (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc > 0 && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + /* Do not propagate constants on any ON clause if there is a + ** RIGHT JOIN anywhere in the query */ + (**(**TWhereConst)(__ccgo_up(bp))).FmExcludeOn = libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON) | libc.Int32FromInt32(EP_OuterON)) + } else { + /* Do not propagate constants through the ON clause of a LEFT JOIN */ + (**(**TWhereConst)(__ccgo_up(bp))).FmExcludeOn = uint32(EP_OuterON) + } + _findConstInWhere(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpWhere) + if (**(**TWhereConst)(__ccgo_up(bp))).FnConst != 0 { + libc.Xmemset(tls, bp+40, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp + 40))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp + 40))).FxExprCallback = __ccgo_fp(_propagateConstantExprRewrite) + (**(**TWalker)(__ccgo_up(bp + 40))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + (**(**TWalker)(__ccgo_up(bp + 40))).FxSelectCallback2 = uintptr(0) + (**(**TWalker)(__ccgo_up(bp + 40))).FwalkerDepth = 0 + *(*uintptr)(unsafe.Pointer(bp + 40 + 40)) = bp + _sqlite3WalkExpr(tls, bp+40, (*TSelect)(unsafe.Pointer(p)).FpWhere) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer((**(**TWhereConst)(__ccgo_up(bp))).FpParse)).Fdb, (**(**TWhereConst)(__ccgo_up(bp))).FapExpr) + nChng = nChng + (**(**TWhereConst)(__ccgo_up(bp))).FnChng + } + } + return nChng +} + +// C documentation +// +// /* +// ** Generate code that will push the record in registers regData +// ** through regData+nData-1 onto the sorter. +// */ +func _pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintptr, regData int32, regOrigData int32, nData int32, nPrefixReg int32) { + var addrFirst, addrJmp, bSeq, iCsr, iLimit, iSkip, nBase, nExpr, nKey, nOBSat, op, regBase, regPrevKey, regRecord, v1 int32 + var pKI, pOp, v, v4 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrFirst, addrJmp, bSeq, iCsr, iLimit, iSkip, nBase, nExpr, nKey, nOBSat, op, pKI, pOp, regBase, regPrevKey, regRecord, v, v1, v4 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Stmt under construction */ + bSeq = libc.BoolInt32(libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&int32(SORTFLAG_UseSorter) == 0) + nExpr = (*TExprList)(unsafe.Pointer((*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr /* No. of ORDER BY terms */ + nBase = nExpr + bSeq + nData /* Regs for sorter record */ + regRecord = 0 /* Assembled sorter record */ + nOBSat = (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat /* LIMIT counter */ + iSkip = 0 /* End of the sorter insert loop */ + /* Three cases: + ** (1) The data to be sorted has already been packed into a Record + ** by a prior OP_MakeRecord. In this case nData==1 and regData + ** will be completely unrelated to regOrigData. + ** (2) All output columns are included in the sort record. In that + ** case regData==regOrigData. + ** (3) Some output columns are omitted from the sort record due to + ** the SQLITE_ENABLE_SORTER_REFERENCES optimization, or due to the + ** SQLITE_ECEL_OMITREF optimization, or due to the + ** SortCtx.pDeferredRowLoad optimization. In any of these cases + ** regOrigData is 0 to prevent this routine from trying to copy + ** values that might not yet exist. + */ + if nPrefixReg != 0 { + regBase = regData - nPrefixReg + } else { + regBase = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nBase + } + if (*TSelect)(unsafe.Pointer(pSelect)).FiOffset != 0 { + v1 = (*TSelect)(unsafe.Pointer(pSelect)).FiOffset + int32(1) + } else { + v1 = (*TSelect)(unsafe.Pointer(pSelect)).FiLimit + } + iLimit = v1 + (*TSortCtx)(unsafe.Pointer(pSort)).FlabelDone = _sqlite3VdbeMakeLabel(tls, pParse) + if regOrigData != 0 { + v1 = int32(SQLITE_ECEL_REF) + } else { + v1 = 0 + } + _sqlite3ExprCodeExprList(tls, pParse, (*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy, regBase, regOrigData, libc.Uint8FromInt32(int32(SQLITE_ECEL_DUP)|v1)) + if bSeq != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sequence), (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor, regBase+nExpr) + } + if nPrefixReg == 0 && nData > 0 { + _sqlite3ExprCodeMove(tls, pParse, regData, regBase+nExpr+bSeq, nData) + } + if nOBSat > 0 { /* Original KeyInfo on the sorter table */ + regRecord = _makeSorterRecord(tls, pParse, pSort, pSelect, regBase, nBase) + regPrevKey = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + nKey = nExpr - (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + bSeq + if bSeq != 0 { + addrFirst = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNot), regBase+nExpr) + } else { + addrFirst = _sqlite3VdbeAddOp1(tls, v, int32(OP_SequenceTest), (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Compare), regPrevKey, regBase, (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat) + pOp = _sqlite3VdbeGetOp(tls, v, (*TSortCtx)(unsafe.Pointer(pSort)).FaddrSortIndex) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return + } + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 = nKey + nData + pKI = *(*uintptr)(unsafe.Pointer(pOp + 16)) + libc.Xmemset(tls, (*TKeyInfo)(unsafe.Pointer(pKI)).FaSortFlags, 0, uint64((*TKeyInfo)(unsafe.Pointer(pKI)).FnKeyField)) /* Makes OP_Jump testable */ + _sqlite3VdbeChangeP4(tls, v, -int32(1), pKI, -int32(9)) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = _sqlite3KeyInfoFromExprList(tls, pParse, (*TSortCtx)(unsafe.Pointer(pSort)).FpOrderBy, nOBSat, libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKI)).FnAllField)-libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKI)).FnKeyField)-int32(1)) + pOp = uintptr(0) /* Ensure pOp not used after sqlite3VdbeAddOp3() */ + addrJmp = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addrJmp+int32(1), 0, addrJmp+int32(1)) + (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut = _sqlite3VdbeMakeLabel(tls, pParse) + v4 = pParse + 60 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn = v1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TSortCtx)(unsafe.Pointer(pSort)).FregReturn, (*TSortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResetSorter), (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor) + if iLimit != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNot), iLimit, (*TSortCtx)(unsafe.Pointer(pSort)).FlabelDone) + } + _sqlite3VdbeJumpHere(tls, v, addrFirst) + _sqlite3ExprCodeMove(tls, pParse, regBase, regPrevKey, (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat) + _sqlite3VdbeJumpHere(tls, v, addrJmp) + } + if iLimit != 0 { + /* At this point the values for the new sorter entry are stored + ** in an array of registers. They need to be composed into a record + ** and inserted into the sorter if either (a) there are currently + ** less than LIMIT+OFFSET items or (b) the new record is smaller than + ** the largest record currently in the sorter. If (b) is true and there + ** are already LIMIT+OFFSET items in the sorter, delete the largest + ** entry before inserting the new one. This way there are never more + ** than LIMIT+OFFSET items in the sorter. + ** + ** If the new record does not need to be inserted into the sorter, + ** jump to the next iteration of the loop. If the pSort->labelOBLopt + ** value is not zero, then it is a label of where to jump. Otherwise, + ** just bypass the row insert logic. See the header comment on the + ** sqlite3WhereOrderByLimitOptLabel() function for additional info. + */ + iCsr = (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNotZero), iLimit, _sqlite3VdbeCurrentAddr(tls, v)+int32(4)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Last), iCsr, 0) + iSkip = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxLE), iCsr, 0, regBase+nOBSat, nExpr-nOBSat) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Delete), iCsr) + } + if regRecord == 0 { + regRecord = _makeSorterRecord(tls, pParse, pSort, pSelect, regBase, nBase) + } + if libc.Int32FromUint8((*TSortCtx)(unsafe.Pointer(pSort)).FsortFlags)&int32(SORTFLAG_UseSorter) != 0 { + op = int32(OP_SorterInsert) + } else { + op = int32(OP_IdxInsert) + } + _sqlite3VdbeAddOp4Int(tls, v, op, (*TSortCtx)(unsafe.Pointer(pSort)).FiECursor, regRecord, regBase+nOBSat, nBase-nOBSat) + if iSkip != 0 { + if (*TSortCtx)(unsafe.Pointer(pSort)).FlabelOBLopt != 0 { + v1 = (*TSortCtx)(unsafe.Pointer(pSort)).FlabelOBLopt + } else { + v1 = _sqlite3VdbeCurrentAddr(tls, v) + } + _sqlite3VdbeChangeP2(tls, v, iSkip, v1) + } +} + +// C documentation +// +// /* +// ** Compare two constraint names. +// ** +// ** Summary: *pRes := zQuote != zCmp +// ** +// ** Details: +// ** Compare the (possibly quoted) constraint name zQuote[0..nQuote-1] +// ** against zCmp[]. Write zero into *pRes if they are the same and +// ** non-zero if they differ. Normally return SQLITE_OK, except if there +// ** is an OOM, set the OOM error condition on ctx and return SQLITE_NOMEM. +// */ +func _quotedCompare(tls *libc.TLS, ctx uintptr, t int32, zQuote uintptr, nQuote int32, zCmp uintptr, pRes uintptr) (r int32) { + var zCopy uintptr + _ = zCopy + zCopy = uintptr(0) /* De-quoted, zero-terminated copy of zQuote[] */ + if t == int32(TK_ILLEGAL) { + **(**int32)(__ccgo_up(pRes)) = int32(1) + return SQLITE_OK + } + zCopy = _sqlite3MallocZero(tls, libc.Uint64FromInt32(nQuote+int32(1))) + if zCopy == uintptr(0) { + Xsqlite3_result_error_nomem(tls, ctx) + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, zCopy, zQuote, libc.Uint64FromInt32(nQuote)) + _sqlite3Dequote(tls, zCopy) + **(**int32)(__ccgo_up(pRes)) = Xsqlite3_stricmp(tls, zCopy, zCmp) + Xsqlite3_free(tls, zCopy) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Attempt to allocate and return a pointer to a zeroed block of nByte +// ** bytes. +// ** +// ** If an error (i.e. an OOM condition) occurs, return NULL and leave an +// ** error code in the rbu handle passed as the first argument. Or, if an +// ** error has already occurred when this function is called, return NULL +// ** immediately without attempting the allocation or modifying the stored +// ** error code. +// */ +func _rbuMalloc(tls *libc.TLS, p uintptr, nByte Tsqlite3_int64) (r uintptr) { + var pRet uintptr + _ = pRet + pRet = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pRet == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pRet, 0, libc.Uint64FromInt64(nByte)) + } + } + return pRet +} + +// C documentation +// +// /* +// ** Read data from an rbuVfs-file. +// */ +func _rbuVfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) { + var aBuf, p, pBuf, pFd, pRbu uintptr + var iRoot Tu32 + var rc, v1 int32 + _, _, _, _, _, _, _, _ = aBuf, iRoot, p, pBuf, pFd, pRbu, rc, v1 + p = pFile + pRbu = (*Trbu_file)(unsafe.Pointer(p)).FpRbu + if pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == int32(RBU_STAGE_CAPTURE) { + rc = _rbuCaptureWalRead(tls, (*Trbu_file)(unsafe.Pointer(p)).FpRbu, iOfst, iAmt) + } else { + if pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == int32(RBU_STAGE_OAL) && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_WAL) != 0 && iOfst >= (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz { + rc = SQLITE_OK + libc.Xmemset(tls, zBuf, 0, libc.Uint64FromInt32(iAmt)) + } else { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxRead})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) + /* If this is being called to read the first page of the target + ** database as part of an rbu vacuum operation, synthesize the + ** contents of the first page if it does not yet exist. Otherwise, + ** SQLite will not check for a *-wal file. */ + if pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FzTarget == uintptr(0) && rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)< int32(100) { + libc.Xmemset(tls, aBuf+100, 0, libc.Uint64FromInt32(iAmt-int32(100))) + _rbuPutU16(tls, aBuf+105, libc.Uint16FromInt32(iAmt&int32(0xFFFF))) + **(**Tu8)(__ccgo_up(aBuf + 100)) = uint8(0x0D) + } + } + } + } + if rc == SQLITE_OK && iOfst == 0 && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + /* These look like magic numbers. But they are stable, as they are part + ** of the definition of the SQLite file format, which may not change. */ + pBuf = zBuf + (*Trbu_file)(unsafe.Pointer(p)).FiCookie = _rbuGetU32(tls, pBuf+24) + (*Trbu_file)(unsafe.Pointer(p)).FiWriteVer = **(**Tu8)(__ccgo_up(pBuf + 19)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Obtain a pointer to a mapping of a single 32KiB page of the *-shm file. +// */ +func _rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, isWrite int32, pp uintptr) (r int32) { + var apNew, p, pNew uintptr + var eStage, rc, v1 int32 + var nByte Tsqlite3_int64 + _, _, _, _, _, _, _ = apNew, eStage, nByte, p, pNew, rc, v1 + p = pFile + rc = SQLITE_OK + if (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 { + v1 = (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage + } else { + v1 = 0 + } + eStage = v1 + /* If not in RBU_STAGE_OAL, allow this call to pass through. Or, if this + ** rbu is in the RBU_STAGE_OAL state, use heap memory for *-shm space + ** instead of a file on disk. */ + if eStage == int32(RBU_STAGE_OAL) { + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(iRegion+libc.Int32FromInt32(1)) * uint64(8)) + apNew = Xsqlite3_realloc64(tls, (*Trbu_file)(unsafe.Pointer(p)).FapShm, libc.Uint64FromInt64(nByte)) + /* This is an RBU connection that uses its own heap memory for the + ** pages of the *-shm file. Since no other process can have run + ** recovery, the connection must request *-shm pages in order + ** from start to finish. */ + if apNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, apNew+uintptr((*Trbu_file)(unsafe.Pointer(p)).FnShm)*8, 0, uint64(8)*libc.Uint64FromInt32(libc.Int32FromInt32(1)+iRegion-(*Trbu_file)(unsafe.Pointer(p)).FnShm)) + (*Trbu_file)(unsafe.Pointer(p)).FapShm = apNew + (*Trbu_file)(unsafe.Pointer(p)).FnShm = iRegion + int32(1) + } + if rc == SQLITE_OK { + pNew = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(szRegion)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pNew, 0, libc.Uint64FromInt32(szRegion)) + **(**uintptr)(__ccgo_up((*Trbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*8)) = pNew + } + } + if rc == SQLITE_OK { + **(**uintptr)(__ccgo_up(pp)) = **(**uintptr)(__ccgo_up((*Trbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*8)) + } else { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + } + } else { + rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmMap})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, iRegion, szRegion, isWrite, pp) + } + return rc +} + +// C documentation +// +// /* +// ** Read the content for page pPg out of the database file (or out of +// ** the WAL if that is where the most recent copy if found) into +// ** pPg->pData. A shared lock or greater must be held on the database +// ** file before this function is called. +// ** +// ** If page 1 is read, then the value of Pager.dbFileVers[] is set to +// ** the value read from the database file. +// ** +// ** If an IO error occurs, then the IO error is returned to the caller. +// ** Otherwise, SQLITE_OK is returned. +// */ +func _readDbPage(tls *libc.TLS, pPg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var dbFileVers, pPager uintptr + var iOffset Ti64 + var rc int32 + var _ /* iFrame at bp+0 */ Tu32 + _, _, _, _ = dbFileVers, iOffset, pPager, rc + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager /* Pager object associated with page pPg */ + rc = SQLITE_OK /* Return code */ + **(**Tu32)(__ccgo_up(bp)) = uint32(0) /* Frame of WAL containing pgno */ + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + rc = _sqlite3WalFindFrame(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno, bp) + if rc != 0 { + return rc + } + } + if **(**Tu32)(__ccgo_up(bp)) != 0 { + rc = _sqlite3WalReadFrame(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, **(**Tu32)(__ccgo_up(bp)), int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), (*TPgHdr)(unsafe.Pointer(pPg)).FpData) + } else { + iOffset = libc.Int64FromUint32((*TPgHdr)(unsafe.Pointer(pPg)).Fpgno-libc.Uint32FromInt32(1)) * (*TPager)(unsafe.Pointer(pPager)).FpageSize + rc = _sqlite3OsRead(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, (*TPgHdr)(unsafe.Pointer(pPg)).FpData, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), iOffset) + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)<dbFileVers[] with all 0xff bytes should suffice. + ** + ** For an encrypted database, the situation is more complex: bytes + ** 24..39 of the database are white noise. But the probability of + ** white noise equaling 16 bytes of 0xff is vanishingly small so + ** we should still be ok. + */ + libc.Xmemset(tls, pPager+136, int32(0xff), uint64(16)) + } else { + dbFileVers = (*TPgHdr)(unsafe.Pointer(pPg)).FpData + 24 + libc.Xmemcpy(tls, pPager+136, dbFileVers, uint64(16)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Array apCell[] contains pointers to nCell b-tree page cells. The +// ** szCell[] array contains the size in bytes of each cell. This function +// ** replaces the current contents of page pPg with the contents of the cell +// ** array. +// ** +// ** Some of the cells in apCell[] may currently be stored in pPg. This +// ** function works around problems caused by this by making a copy of any +// ** such cells before overwriting the page data. +// ** +// ** The MemPage.nFree field is invalidated by this function. It is the +// ** responsibility of the caller to set it correctly. +// */ +func _rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg uintptr) (r int32) { + var aData, pCell, pCellptr, pData, pEnd, pSrcEnd, pTmp uintptr + var hdr, i, iEnd, k, usableSize int32 + var j Tu32 + var sz Tu16 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, hdr, i, iEnd, j, k, pCell, pCellptr, pData, pEnd, pSrcEnd, pTmp, sz, usableSize + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FhdrOffset) /* Offset of header on pPg */ + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData /* Pointer to data for pPg */ + usableSize = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize) + pEnd = aData + uintptr(usableSize) + i = iFirst /* Start of cell content area */ + iEnd = i + nCell /* Loop terminator */ + pCellptr = (*TMemPage)(unsafe.Pointer(pPg)).FaCellIdx + pTmp = _sqlite3PagerTempSpace(tls, (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPg)).FpBt)).FpPager) /* Current pCArray->apEnd[k] value */ + j = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)))))< libc.Uint32FromInt32(usableSize) { + j = uint32(0) + } + libc.Xmemcpy(tls, pTmp+uintptr(j), aData+uintptr(j), uint64(libc.Uint32FromInt32(usableSize)-j)) + k = 0 + for { + if !(**(**int32)(__ccgo_up(pCArray + 80 + uintptr(k)*4)) <= i) { + break + } + goto _1 + _1: + ; + k = k + 1 + } + pSrcEnd = **(**uintptr)(__ccgo_up(pCArray + 32 + uintptr(k)*8)) + pData = pEnd + for int32(1) != 0 { + pCell = **(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8)) + sz = **(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2)) + if uint64(pCell) >= uint64(aData+uintptr(j)) && uint64(pCell) < uint64(pEnd) { + if uint64(pCell+uintptr(sz)) > uint64(pEnd) { + return _sqlite3CorruptError(tls, int32(80813)) + } + pCell = pTmp + uintptr(int64(pCell)-int64(aData)) + } else { + if uint64(pCell+uintptr(sz)) > uint64(pSrcEnd) && uint64(pCell) < uint64(pSrcEnd) { + return _sqlite3CorruptError(tls, int32(80818)) + } + } + pData = pData - uintptr(sz) + **(**Tu8)(__ccgo_up(pCellptr)) = libc.Uint8FromInt64((int64(pData) - int64(aData)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(pCellptr + 1)) = libc.Uint8FromInt64(int64(pData) - int64(aData)) + pCellptr = pCellptr + uintptr(2) + if pData < pCellptr { + return _sqlite3CorruptError(tls, int32(80824)) + } + libc.Xmemmove(tls, pData, pCell, uint64(sz)) + i = i + 1 + if i >= iEnd { + break + } + if **(**int32)(__ccgo_up(pCArray + 80 + uintptr(k)*4)) <= i { + k = k + 1 + pSrcEnd = **(**uintptr)(__ccgo_up(pCArray + 32 + uintptr(k)*8)) + } + } + /* The pPg->nFree field is now set incorrectly. The caller will fix it. */ + (*TMemPage)(unsafe.Pointer(pPg)).FnCell = libc.Uint16FromInt32(nCell) + (*TMemPage)(unsafe.Pointer(pPg)).FnOverflow = uint8(0) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(1)))) = libc.Uint8FromInt32(libc.Int32FromInt32(0) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(1)) + 1)) = libc.Uint8FromInt32(libc.Int32FromInt32(0)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(3)))) = libc.Uint8FromInt32(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPg)).FnCell) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(3)) + 1)) = uint8((*TMemPage)(unsafe.Pointer(pPg)).FnCell) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)))) = libc.Uint8FromInt64((int64(pData) - int64(aData)) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(5)) + 1)) = libc.Uint8FromInt64(int64(pData) - int64(aData)) + **(**Tu8)(__ccgo_up(aData + uintptr(hdr+int32(7)))) = uint8(0x00) + return SQLITE_OK +} + +// C documentation +// +// /* Resize the hash table so that it contains "new_size" buckets. +// ** +// ** The hash table might fail to resize if sqlite3_malloc() fails or +// ** if the new size is the same as the prior size. +// ** Return TRUE if the resize occurs and false if not. +// */ +func _rehash(tls *libc.TLS, pH uintptr, new_size uint32) (r int32) { + var elem, new_ht, next_elem uintptr + var v1 uint32 + _, _, _, _ = elem, new_ht, next_elem, v1 /* For looping over existing elements */ + if uint64(new_size)*uint64(16) > uint64(SQLITE_MALLOC_SOFT_LIMIT) { + new_size = uint32(libc.Uint64FromInt32(SQLITE_MALLOC_SOFT_LIMIT) / libc.Uint64FromInt64(16)) + } + if new_size == (*THash)(unsafe.Pointer(pH)).Fhtsize { + return 0 + } + /* The inability to allocates space for a larger hash table is + ** a performance hit but it is not a fatal error. So mark the + ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of + ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero() + ** only zeroes the requested number of bytes whereas this module will + ** use the actual amount of space allocated for the hash table (which + ** may be larger than the requested amount). + */ + _sqlite3BeginBenignMalloc(tls) + new_ht = _sqlite3Malloc(tls, uint64(new_size)*uint64(16)) + _sqlite3EndBenignMalloc(tls) + if new_ht == uintptr(0) { + return 0 + } + Xsqlite3_free(tls, (*THash)(unsafe.Pointer(pH)).Fht) + (*THash)(unsafe.Pointer(pH)).Fht = new_ht + v1 = uint32(libc.Uint64FromInt32(_sqlite3MallocSize(tls, new_ht)) / libc.Uint64FromInt64(16)) + new_size = v1 + (*THash)(unsafe.Pointer(pH)).Fhtsize = v1 + libc.Xmemset(tls, new_ht, 0, uint64(new_size)*uint64(16)) + elem = (*THash)(unsafe.Pointer(pH)).Ffirst + (*THash)(unsafe.Pointer(pH)).Ffirst = libc.UintptrFromInt32(0) + for { + if !(elem != 0) { + break + } + next_elem = (*THashElem)(unsafe.Pointer(elem)).Fnext + _insertElement(tls, pH, new_ht+uintptr((*THashElem)(unsafe.Pointer(elem)).Fh%new_size)*16, elem) + goto _2 + _2: + ; + elem = next_elem + } + return int32(1) +} + +// C documentation +// +// /* SQL function: sqlite_rename_quotefix(DB,SQL) +// ** +// ** Rewrite the DDL statement "SQL" so that any string literals that use +// ** double-quotes use single quotes instead. +// ** +// ** Two arguments must be passed: +// ** +// ** 0: Database name ("main", "temp" etc.). +// ** 1: SQL statement to edit. +// ** +// ** The returned value is the modified SQL statement. For example, given +// ** the database schema: +// ** +// ** CREATE TABLE t1(a, b, c); +// ** +// ** SELECT sqlite_rename_quotefix('main', +// ** 'CREATE VIEW v1 AS SELECT "a", "string" FROM t1' +// ** ); +// ** +// ** returns the string: +// ** +// ** CREATE VIEW v1 AS SELECT "a", 'string' FROM t1 +// ** +// ** If there is a error in the input SQL, then raise an error, except +// ** if PRAGMA writable_schema=ON, then just return the input string +// ** unmodified following an error. +// */ +func _renameQuotefixFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(496) + defer tls.Free(496) + var db, pSelect, zDb, zInput uintptr + var i, rc, v1 int32 + var xAuth Tsqlite3_xauth + var _ /* sCtx at bp+416 */ TRenameCtx + var _ /* sParse at bp+0 */ TParse + var _ /* sWalker at bp+448 */ TWalker + _, _, _, _, _, _, _, _ = db, i, pSelect, rc, xAuth, zDb, zInput, v1 + db = Xsqlite3_context_db_handle(tls, context) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zInput = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + _sqlite3BtreeEnterAll(tls, db) + _ = NotUsed + if zDb != 0 && zInput != 0 { + rc = _renameParseSql(tls, bp, zDb, db, zInput, 0) + if rc == SQLITE_OK { + /* Walker to find tokens that need to be replaced. */ + libc.Xmemset(tls, bp+416, 0, uint64(32)) + libc.Xmemset(tls, bp+448, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp + 448))).FpParse = bp + (**(**TWalker)(__ccgo_up(bp + 448))).FxExprCallback = __ccgo_fp(_renameQuotefixExprCb) + (**(**TWalker)(__ccgo_up(bp + 448))).FxSelectCallback = __ccgo_fp(_renameColumnSelectCb) + *(*uintptr)(unsafe.Pointer(bp + 448 + 40)) = bp + 416 + if (**(**TParse)(__ccgo_up(bp))).FpNewTable != 0 { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FeTabType) == int32(TABTYP_VIEW) { + pSelect = (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).Fu))).FpSelect + **(**Tu32)(__ccgo_up(pSelect + 4)) &= ^libc.Uint32FromInt32(SF_View) + (**(**TParse)(__ccgo_up(bp))).Frc = SQLITE_OK + _sqlite3SelectPrep(tls, bp, pSelect, uintptr(0)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + v1 = int32(SQLITE_NOMEM) + } else { + v1 = (**(**TParse)(__ccgo_up(bp))).Frc + } + rc = v1 + if rc == SQLITE_OK { + _sqlite3WalkSelect(tls, bp+448, pSelect) + } + } else { + _sqlite3WalkExprList(tls, bp+448, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FpCheck) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FnCol)) { + break + } + _sqlite3WalkExpr(tls, bp+448, _sqlite3ColumnExpr(tls, (**(**TParse)(__ccgo_up(bp))).FpNewTable, (*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FaCol+uintptr(i)*16)) + goto _2 + _2: + ; + i = i + 1 + } + } + } else { + if (**(**TParse)(__ccgo_up(bp))).FpNewIndex != 0 { + _sqlite3WalkExprList(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewIndex)).FaColExpr) + _sqlite3WalkExpr(tls, bp+448, (*TIndex)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewIndex)).FpPartIdxWhere) + } else { + rc = _renameResolveTrigger(tls, bp) + if rc == SQLITE_OK { + _renameWalkTrigger(tls, bp+448, (**(**TParse)(__ccgo_up(bp))).FpNewTrigger) + } + } + } + if rc == SQLITE_OK { + rc = _renameEditSql(tls, context, bp+416, zInput, uintptr(0), 0) + } + _renameTokenFree(tls, db, (**(**TRenameCtx)(__ccgo_up(bp + 416))).FpList) + } + if rc != SQLITE_OK { + if _sqlite3WritableSchema(tls, db) != 0 && rc == int32(SQLITE_ERROR) { + Xsqlite3_result_value(tls, context, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + Xsqlite3_result_error_code(tls, context, rc) + } + } + _renameParseCleanup(tls, bp) + } + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + _sqlite3BtreeLeaveAll(tls, db) +} + +// C documentation +// +// /* Function: sqlite_rename_test(DB,SQL,TYPE,NAME,ISTEMP,WHEN,DQS) +// ** +// ** An SQL user function that checks that there are no parse or symbol +// ** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement. +// ** After an ALTER TABLE .. RENAME operation is performed and the schema +// ** reloaded, this function is called on each SQL statement in the schema +// ** to ensure that it is still usable. +// ** +// ** 0: Database name ("main", "temp" etc.). +// ** 1: SQL statement. +// ** 2: Object type ("view", "table", "trigger" or "index"). +// ** 3: Object name. +// ** 4: True if object is from temp schema. +// ** 5: "when" part of error message. +// ** 6: True to disable the DQS quirk when parsing SQL. +// ** +// ** The return value is computed as follows: +// ** +// ** A. If an error is seen and not in PRAGMA writable_schema=ON mode, +// ** then raise the error. +// ** B. Else if a trigger is created and the the table that the trigger is +// ** attached to is in database zDb, then return 1. +// ** C. Otherwise return NULL. +// */ +func _renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(480) + defer tls.Free(480) + var bNoDQS, bTemp, i1, i2, isLegacy, rc int32 + var db, zDb, zInput, zWhen uintptr + var flags Tu64 + var xAuth Tsqlite3_xauth + var _ /* sNC at bp+416 */ TNameContext + var _ /* sParse at bp+0 */ TParse + _, _, _, _, _, _, _, _, _, _, _, _ = bNoDQS, bTemp, db, flags, i1, i2, isLegacy, rc, xAuth, zDb, zInput, zWhen + db = Xsqlite3_context_db_handle(tls, context) + zDb = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zInput = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + bTemp = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + isLegacy = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_LegacyAlter)) + zWhen = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 5*8))) + bNoDQS = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 6*8))) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + _ = NotUsed + if zDb != 0 && zInput != 0 { + flags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + if bNoDQS != 0 { + **(**Tu64)(__ccgo_up(db + 48)) &= libc.Uint64FromInt32(^(libc.Int32FromInt32(SQLITE_DqsDML) | libc.Int32FromInt32(SQLITE_DqsDDL))) + } + rc = _renameParseSql(tls, bp, zDb, db, zInput, bTemp) + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = flags + if rc == SQLITE_OK { + if isLegacy == 0 && (**(**TParse)(__ccgo_up(bp))).FpNewTable != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).FeTabType) == int32(TABTYP_VIEW) { + libc.Xmemset(tls, bp+416, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp + 416))).FpParse = bp + _sqlite3SelectPrep(tls, bp, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTable)).Fu))).FpSelect, bp+416) + if (**(**TParse)(__ccgo_up(bp))).FnErr != 0 { + rc = (**(**TParse)(__ccgo_up(bp))).Frc + } + } else { + if (**(**TParse)(__ccgo_up(bp))).FpNewTrigger != 0 { + if isLegacy == 0 { + rc = _renameResolveTrigger(tls, bp) + } + if rc == SQLITE_OK { + i1 = _sqlite3SchemaToIndex(tls, db, (*TTrigger)(unsafe.Pointer((**(**TParse)(__ccgo_up(bp))).FpNewTrigger)).FpTabSchema) + i2 = _sqlite3FindDbName(tls, db, zDb) + if i1 == i2 { + /* Handle output case B */ + Xsqlite3_result_int(tls, context, int32(1)) + } + } + } + } + } + if rc != SQLITE_OK && zWhen != 0 && !(_sqlite3WritableSchema(tls, db) != 0) { + /* Output case A */ + _renameColumnParseError(tls, context, zWhen, **(**uintptr)(__ccgo_up(argv + 2*8)), **(**uintptr)(__ccgo_up(argv + 3*8)), bp) + } + _renameParseCleanup(tls, bp) + } + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth +} + +// C documentation +// +// /* +// ** The replace() function. Three arguments are all strings: call +// ** them A, B, and C. The result is also a string which is derived +// ** from A by replacing every occurrence of B with C. The match +// ** must be exact. Collating sequences are not used. +// */ +func _replaceFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var cntExpand uint32 + var db, zOld, zOut, zPattern, zRep, zStr uintptr + var i, j, loopLimit, nPattern, nRep, nStr, v2, v3 int32 + var nOut Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cntExpand, db, i, j, loopLimit, nOut, nPattern, nRep, nStr, zOld, zOut, zPattern, zRep, zStr, v2, v3 /* Number zOut expansions */ + db = Xsqlite3_context_db_handle(tls, context) + _ = argc + zStr = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zStr == uintptr(0) { + return + } + nStr = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + /* No encoding change */ + zPattern = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zPattern == uintptr(0) { + return + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPattern))) == 0 { + Xsqlite3_result_text(tls, context, zStr, nStr, uintptr(-libc.Int32FromInt32(1))) + return + } + nPattern = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + /* No encoding change */ + zRep = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + if zRep == uintptr(0) { + return + } + nRep = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + nOut = int64(nStr + int32(1)) + zOut = _contextMalloc(tls, context, nOut) + if zOut == uintptr(0) { + return + } + loopLimit = nStr - nPattern + cntExpand = uint32(0) + v2 = libc.Int32FromInt32(0) + j = v2 + i = v2 + for { + if !(i <= loopLimit) { + break + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zStr + uintptr(i)))) != libc.Int32FromUint8(**(**uint8)(__ccgo_up(zPattern))) || libc.Xmemcmp(tls, zStr+uintptr(i), zPattern, libc.Uint64FromInt32(nPattern)) != 0 { + v3 = j + j = j + 1 + **(**uint8)(__ccgo_up(zOut + uintptr(v3))) = **(**uint8)(__ccgo_up(zStr + uintptr(i))) + } else { + if nRep > nPattern { + nOut = nOut + int64(nRep-nPattern) + if nOut-int64(1) > int64(**(**int32)(__ccgo_up(db + 136))) { + Xsqlite3_result_error_toobig(tls, context) + Xsqlite3_free(tls, zOut) + return + } + cntExpand = cntExpand + 1 + if cntExpand&(cntExpand-uint32(1)) == uint32(0) { + zOld = zOut + zOut = _sqlite3Realloc(tls, zOut, libc.Uint64FromInt64(int64(int32(nOut))+(nOut-int64(nStr)-int64(1)))) + if zOut == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + Xsqlite3_free(tls, zOld) + return + } + } + } + libc.Xmemcpy(tls, zOut+uintptr(j), zRep, libc.Uint64FromInt32(nRep)) + j = j + nRep + i = i + (nPattern - int32(1)) + } + goto _1 + _1: + ; + i = i + 1 + } + libc.Xmemcpy(tls, zOut+uintptr(j), zStr+uintptr(i), libc.Uint64FromInt32(nStr-i)) + j = j + (nStr - i) + **(**uint8)(__ccgo_up(zOut + uintptr(j))) = uint8(0) + Xsqlite3_result_text(tls, context, zOut, j, __ccgo_fp(Xsqlite3_free)) +} + +// C documentation +// +// /* +// ** Resize an Index object to hold N columns total. Return SQLITE_OK +// ** on success and SQLITE_NOMEM on an OOM error. +// */ +func _resizeIndexObject(tls *libc.TLS, pParse uintptr, pIdx uintptr, N int32) (r int32) { + var db, zExtra uintptr + var nByte Tu64 + _, _, _ = db, nByte, zExtra + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) >= N { + return SQLITE_OK + } + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + nByte = uint64(libc.Uint64FromInt64(8)+libc.Uint64FromInt64(2)+libc.Uint64FromInt64(2)+libc.Uint64FromInt32(1)) * libc.Uint64FromInt32(N) + zExtra = _sqlite3DbMallocZero(tls, db, nByte) + if zExtra == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, zExtra, (*TIndex)(unsafe.Pointer(pIdx)).FazColl, uint64(8)*uint64((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) + (*TIndex)(unsafe.Pointer(pIdx)).FazColl = zExtra + zExtra = zExtra + uintptr(uint64(8)*libc.Uint64FromInt32(N)) + libc.Xmemcpy(tls, zExtra, (*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst, uint64(2)*libc.Uint64FromInt32(libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)+libc.Int32FromInt32(1))) + (*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst = zExtra + zExtra = zExtra + uintptr(uint64(2)*libc.Uint64FromInt32(N)) + libc.Xmemcpy(tls, zExtra, (*TIndex)(unsafe.Pointer(pIdx)).FaiColumn, uint64(2)*uint64((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) + (*TIndex)(unsafe.Pointer(pIdx)).FaiColumn = zExtra + zExtra = zExtra + uintptr(uint64(2)*libc.Uint64FromInt32(N)) + libc.Xmemcpy(tls, zExtra, (*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder, uint64((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) + (*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder = zExtra + (*TIndex)(unsafe.Pointer(pIdx)).FnColumn = libc.Uint16FromInt32(N) /* See tag-20250221-1 above for proof of safety */ + libc.SetBitFieldPtr16Uint32(pIdx+100, libc.Uint32FromInt32(1), 4, 0x10) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Turn the pExpr expression into an alias for the iCol-th column of the +// ** result set in pEList. +// ** +// ** If the reference is followed by a COLLATE operator, then make sure +// ** the COLLATE operator is preserved. For example: +// ** +// ** SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase; +// ** +// ** Should be transformed into: +// ** +// ** SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase; +// ** +// ** The nSubquery parameter specifies how many levels of subquery the +// ** alias is removed from the original expression. The usual value is +// ** zero but it might be more if the alias is contained within a subquery +// ** of the original expression. The Expr.op2 field of TK_AGG_FUNCTION +// ** structures must be increased by the nSubquery amount. +// */ +func _resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pExpr uintptr, nSubquery int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var db, pDup, pOrig uintptr + var _ /* temp at bp+0 */ TExpr + _, _, _ = db, pDup, pOrig /* The database connection */ + pOrig = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(iCol)*32))).FpExpr + if (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo != 0 { + return + } + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pDup = _sqlite3ExprDup(tls, db, pOrig, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pDup) + pDup = uintptr(0) + } else { + _incrAggFunctionDepth(tls, pDup, nSubquery) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE) { + pDup = _sqlite3ExprAddCollateString(tls, pParse, pDup, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + } + libc.Xmemcpy(tls, bp, pDup, uint64(72)) + libc.Xmemcpy(tls, pDup, pExpr, uint64(72)) + libc.Xmemcpy(tls, pExpr, bp, uint64(72)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + if *(*uintptr)(unsafe.Pointer(pExpr + 64)) != uintptr(0) { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpOwner = pExpr + } + } + _sqlite3ExprDeferredDelete(tls, pParse, pDup) + } +} + +// C documentation +// +// /* +// ** The xUpdate method for rtree module virtual tables. +// */ +func _rtreeUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bHaveRowid, ii, jj, nn, rc, rc2, steprc int32 + var pRtree, pUp uintptr + var _ /* cell at bp+0 */ TRtreeCell + var _ /* pLeaf at bp+48 */ uintptr + _, _, _, _, _, _, _, _, _ = bHaveRowid, ii, jj, nn, pRtree, pUp, rc, rc2, steprc + pRtree = pVtab + rc = SQLITE_OK /* New cell to insert if nData>1 */ + bHaveRowid = 0 /* Set to 1 after new rowid is determined */ + if (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0 { + /* Unable to write to the btree while another cursor is reading from it, + ** since the write might do a rebalance which would disrupt the read + ** cursor. */ + return libc.Int32FromInt32(SQLITE_LOCKED) | libc.Int32FromInt32(2)<=x1" constraint. + ** + ** In the first case, if the conflict-handling mode is REPLACE, then + ** the conflicting row can be removed before proceeding. In the second + ** case, SQLITE_CONSTRAINT must be returned regardless of the + ** conflict-handling mode specified by the user. + */ + if nData > int32(1) { + nn = nData - int32(4) + if nn > libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) { + nn = libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) + } + /* Populate the cell.aCoord[] array. The first coordinate is aData[3]. + ** + ** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared + ** with "column" that are interpreted as table constraints. + ** Example: CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5)); + ** This problem was discovered after years of use, so we silently ignore + ** these kinds of misdeclared tables to avoid breaking any legacy. + */ + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + ii = 0 + for { + if !(ii < nn) { + break + } + *(*TRtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) = _rtreeValueDown(tls, **(**uintptr)(__ccgo_up(aData + uintptr(ii+int32(3))*8))) + *(*TRtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii+int32(1))*4)) = _rtreeValueUp(tls, **(**uintptr)(__ccgo_up(aData + uintptr(ii+int32(4))*8))) + if *(*TRtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) > *(*TRtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii+int32(1))*4)) { + rc = _rtreeConstraintError(tls, pRtree, ii+int32(1)) + goto constraint + } + goto _1 + _1: + ; + ii = ii + int32(2) + } + } else { + ii = 0 + for { + if !(ii < nn) { + break + } + *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(aData + uintptr(ii+int32(3))*8))) + *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii+int32(1))*4)) = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(aData + uintptr(ii+int32(4))*8))) + if *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) > *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii+int32(1))*4)) { + rc = _rtreeConstraintError(tls, pRtree, ii+int32(1)) + goto constraint + } + goto _2 + _2: + ; + ii = ii + int32(2) + } + } + /* If a rowid value was supplied, check if it is already present in + ** the table. If so, the constraint has failed. */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) != int32(SQLITE_NULL) { + (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(aData + 2*8))) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData))) == int32(SQLITE_NULL) || Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(aData))) != (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid { + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid, int32(1), (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid) + steprc = Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + if int32(SQLITE_ROW) == steprc { + if Xsqlite3_vtab_on_conflict(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb) == int32(SQLITE_REPLACE) { + rc = _rtreeDeleteRowid(tls, pRtree, (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid) + } else { + rc = _rtreeConstraintError(tls, pRtree, 0) + goto constraint + } + } + } + bHaveRowid = int32(1) + } + } + /* If aData[0] is not an SQL NULL value, it is the rowid of a + ** record to delete from the r-tree table. The following block does + ** just that. + */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(aData))) != int32(SQLITE_NULL) { + rc = _rtreeDeleteRowid(tls, pRtree, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(aData)))) + } + /* If the aData[] array contains more than one element, elements + ** (aData[2]..aData[argc-1]) contain a new record to insert into + ** the r-tree structure. + */ + if rc == SQLITE_OK && nData > int32(1) { + /* Insert the new record into the r-tree */ + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) + /* Figure out the rowid of the new row. */ + if bHaveRowid == 0 { + rc = _rtreeNewRowid(tls, pRtree, bp) + } + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = (**(**TRtreeCell)(__ccgo_up(bp))).FiRowid + if rc == SQLITE_OK { + rc = _ChooseLeaf(tls, pRtree, bp, 0, bp+48) + } + if rc == SQLITE_OK { + rc = _rtreeInsertCell(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 48)), bp, 0) + rc2 = _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 48))) + if rc == SQLITE_OK { + rc = rc2 + } + } + if rc == SQLITE_OK && (*TRtree)(unsafe.Pointer(pRtree)).FnAux != 0 { + pUp = (*TRtree)(unsafe.Pointer(pRtree)).FpWriteAux + Xsqlite3_bind_int64(tls, pUp, int32(1), **(**Tsqlite_int64)(__ccgo_up(pRowid))) + jj = 0 + for { + if !(jj < libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux)) { + break + } + Xsqlite3_bind_value(tls, pUp, jj+int32(2), **(**uintptr)(__ccgo_up(aData + uintptr(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)+int32(3)+jj)*8))) + goto _3 + _3: + ; + jj = jj + 1 + } + Xsqlite3_step(tls, pUp) + rc = Xsqlite3_reset(tls, pUp) + } + } + goto constraint +constraint: + ; + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** Copy the contents of object (*pFrom) into (*pTo). +// */ +func _sampleCopy(tls *libc.TLS, p uintptr, pTo uintptr, pFrom uintptr) { + (*TStatSample)(unsafe.Pointer(pTo)).FisPSample = (*TStatSample)(unsafe.Pointer(pFrom)).FisPSample + (*TStatSample)(unsafe.Pointer(pTo)).FiCol = (*TStatSample)(unsafe.Pointer(pFrom)).FiCol + (*TStatSample)(unsafe.Pointer(pTo)).FiHash = (*TStatSample)(unsafe.Pointer(pFrom)).FiHash + libc.Xmemcpy(tls, (*TStatSample)(unsafe.Pointer(pTo)).FanEq, (*TStatSample)(unsafe.Pointer(pFrom)).FanEq, uint64(8)*libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnCol)) + libc.Xmemcpy(tls, (*TStatSample)(unsafe.Pointer(pTo)).FanLt, (*TStatSample)(unsafe.Pointer(pFrom)).FanLt, uint64(8)*libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnCol)) + libc.Xmemcpy(tls, (*TStatSample)(unsafe.Pointer(pTo)).FanDLt, (*TStatSample)(unsafe.Pointer(pFrom)).FanDLt, uint64(8)*libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnCol)) + if (*TStatSample)(unsafe.Pointer(pFrom)).FnRowid != 0 { + _sampleSetRowid(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, pTo, libc.Int32FromUint32((*TStatSample)(unsafe.Pointer(pFrom)).FnRowid), *(*uintptr)(unsafe.Pointer(pFrom + 24))) + } else { + _sampleSetRowidInt64(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, pTo, *(*Ti64)(unsafe.Pointer(pFrom + 24))) + } +} + +// C documentation +// +// /* +// ** Copy the contents of sample *pNew into the p->a[] array. If necessary, +// ** remove the least desirable sample from p->a[] to make room. +// */ +func _sampleInsert(tls *libc.TLS, p uintptr, pNew uintptr, nEqZero int32) { + var anDLt, anEq, anLt, pMin, pOld, pSample, pUpgrade uintptr + var i, iMin int32 + _, _, _, _, _, _, _, _, _ = anDLt, anEq, anLt, i, iMin, pMin, pOld, pSample, pUpgrade + pSample = uintptr(0) + /* StatAccum.nMaxEqZero is set to the maximum number of leading 0 + ** values in the anEq[] array of any sample in StatAccum.a[]. In + ** other words, if nMaxEqZero is n, then it is guaranteed that there + ** are no samples with StatSample.anEq[m]==0 for (m>=n). */ + if nEqZero > (*TStatAccum)(unsafe.Pointer(p)).FnMaxEqZero { + (*TStatAccum)(unsafe.Pointer(p)).FnMaxEqZero = nEqZero + } + if libc.Int32FromUint8((*TStatSample)(unsafe.Pointer(pNew)).FisPSample) == 0 { + pUpgrade = uintptr(0) + /* This sample is being added because the prefix that ends in column + ** iCol occurs many times in the table. However, if we have already + ** added a sample that shares this prefix, there is no need to add + ** this one. Instead, upgrade the priority of the highest priority + ** existing sample that shares this prefix. */ + i = (*TStatAccum)(unsafe.Pointer(p)).FnSample - int32(1) + for { + if !(i >= 0) { + break + } + pOld = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48 + if **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pOld)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pNew)).FiCol)*8)) == uint64(0) { + if (*TStatSample)(unsafe.Pointer(pOld)).FisPSample != 0 { + return + } + if pUpgrade == uintptr(0) || _sampleIsBetter(tls, p, pOld, pUpgrade) != 0 { + pUpgrade = pOld + } + } + goto _1 + _1: + ; + i = i - 1 + } + if pUpgrade != 0 { + (*TStatSample)(unsafe.Pointer(pUpgrade)).FiCol = (*TStatSample)(unsafe.Pointer(pNew)).FiCol + **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pUpgrade)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pUpgrade)).FiCol)*8)) = **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pNew)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pUpgrade)).FiCol)*8)) + goto find_new_min + } + } + /* If necessary, remove sample iMin to make room for the new sample. */ + if (*TStatAccum)(unsafe.Pointer(p)).FnSample >= (*TStatAccum)(unsafe.Pointer(p)).FmxSample { + pMin = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FiMin)*48 + anEq = (*TStatSample)(unsafe.Pointer(pMin)).FanEq + anLt = (*TStatSample)(unsafe.Pointer(pMin)).FanLt + anDLt = (*TStatSample)(unsafe.Pointer(pMin)).FanDLt + _sampleClear(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, pMin) + libc.Xmemmove(tls, pMin, pMin+1*48, uint64(48)*libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnSample-(*TStatAccum)(unsafe.Pointer(p)).FiMin-libc.Int32FromInt32(1))) + pSample = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FnSample-int32(1))*48 + (*TStatSample)(unsafe.Pointer(pSample)).FnRowid = uint32(0) + (*TStatSample)(unsafe.Pointer(pSample)).FanEq = anEq + (*TStatSample)(unsafe.Pointer(pSample)).FanDLt = anDLt + (*TStatSample)(unsafe.Pointer(pSample)).FanLt = anLt + (*TStatAccum)(unsafe.Pointer(p)).FnSample = (*TStatAccum)(unsafe.Pointer(p)).FmxSample - int32(1) + } + /* The "rows less-than" for the rowid column must be greater than that + ** for the last sample in the p->a[] array. Otherwise, the samples would + ** be out of order. */ + /* Insert the new sample */ + pSample = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr((*TStatAccum)(unsafe.Pointer(p)).FnSample)*48 + _sampleCopy(tls, p, pSample, pNew) + (*TStatAccum)(unsafe.Pointer(p)).FnSample = (*TStatAccum)(unsafe.Pointer(p)).FnSample + 1 + /* Zero the first nEqZero entries in the anEq[] array. */ + libc.Xmemset(tls, (*TStatSample)(unsafe.Pointer(pSample)).FanEq, 0, uint64(8)*libc.Uint64FromInt32(nEqZero)) + goto find_new_min +find_new_min: + ; + if (*TStatAccum)(unsafe.Pointer(p)).FnSample >= (*TStatAccum)(unsafe.Pointer(p)).FmxSample { + iMin = -int32(1) + i = 0 + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FmxSample) { + break + } + if (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48))).FisPSample != 0 { + goto _2 + } + if iMin < 0 || _sampleIsBetter(tls, p, (*TStatAccum)(unsafe.Pointer(p)).Fa+uintptr(iMin)*48, (*TStatAccum)(unsafe.Pointer(p)).Fa+uintptr(i)*48) != 0 { + iMin = i + } + goto _2 + _2: + ; + i = i + 1 + } + (*TStatAccum)(unsafe.Pointer(p)).FiMin = iMin + } +} + +// C documentation +// +// /* Initialize the BLOB value of a ROWID +// */ +func _sampleSetRowid(tls *libc.TLS, db uintptr, p uintptr, n int32, pData uintptr) { + if (*TStatSample)(unsafe.Pointer(p)).FnRowid != 0 { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 24))) + } + *(*uintptr)(unsafe.Pointer(p + 24)) = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(n)) + if *(*uintptr)(unsafe.Pointer(p + 24)) != 0 { + (*TStatSample)(unsafe.Pointer(p)).FnRowid = libc.Uint32FromInt32(n) + libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(p + 24)), pData, libc.Uint64FromInt32(n)) + } else { + (*TStatSample)(unsafe.Pointer(p)).FnRowid = uint32(0) + } +} + +// C documentation +// +// /* +// ** The cursor passed as the only argument must point to a valid entry +// ** when this function is called (i.e. have eState==CURSOR_VALID). This +// ** function saves the current cursor key in variables pCur->nKey and +// ** pCur->pKey. SQLITE_OK is returned if successful or an SQLite error +// ** code otherwise. +// ** +// ** If the cursor is open on an intkey table, then the integer key +// ** (the rowid) is stored in pCur->nKey and pCur->pKey is left set to +// ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is +// ** set to point to a malloced buffer pCur->nKey bytes in size containing +// ** the key. +// */ +func _saveCursorKey(tls *libc.TLS, pCur uintptr) (r int32) { + var pKey uintptr + var rc int32 + _, _ = pKey, rc + rc = SQLITE_OK + if (*TBtCursor)(unsafe.Pointer(pCur)).FcurIntKey != 0 { + /* Only the rowid is required for a table btree */ + (*TBtCursor)(unsafe.Pointer(pCur)).FnKey = _sqlite3BtreeIntegerKey(tls, pCur) + } else { + (*TBtCursor)(unsafe.Pointer(pCur)).FnKey = libc.Int64FromUint32(_sqlite3BtreePayloadSize(tls, pCur)) + pKey = _sqlite3Malloc(tls, libc.Uint64FromInt64((*TBtCursor)(unsafe.Pointer(pCur)).FnKey+int64(9)+int64(8))) + if pKey != 0 { + rc = _sqlite3BtreePayload(tls, pCur, uint32(0), libc.Uint32FromInt32(int32((*TBtCursor)(unsafe.Pointer(pCur)).FnKey)), pKey) + if rc == SQLITE_OK { + libc.Xmemset(tls, pKey+uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FnKey), 0, libc.Uint64FromInt32(libc.Int32FromInt32(9)+libc.Int32FromInt32(8))) + (*TBtCursor)(unsafe.Pointer(pCur)).FpKey = pKey + } else { + Xsqlite3_free(tls, pKey) + } + } else { + rc = int32(SQLITE_NOMEM) + } + } + return rc +} + +// C documentation +// +// /* +// ** The xSelect callback for the search of invalid ON clause terms. +// */ +func _selectCheckOnClausesSelect(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pCtx uintptr + var _ /* sCtx at bp+0 */ TCheckOnCtx + _ = pCtx + pCtx = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + if (*TSelect)(unsafe.Pointer(pSelect)).FpSrc == (*TCheckOnCtx)(unsafe.Pointer(pCtx)).FpSrc || (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc == 0 { + return WRC_Continue + } else { + libc.Xmemset(tls, bp, 0, uint64(24)) + (**(**TCheckOnCtx)(__ccgo_up(bp))).FpSrc = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + (**(**TCheckOnCtx)(__ccgo_up(bp))).FpParent = pCtx + *(*uintptr)(unsafe.Pointer(pWalker + 40)) = bp + _sqlite3WalkSelect(tls, pWalker, pSelect) + *(*uintptr)(unsafe.Pointer(pWalker + 40)) = pCtx + **(**Tu32)(__ccgo_up(pSelect + 4)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SF_OnToWhere)) + return int32(WRC_Prune) + } + return r +} + +// C documentation +// +// /* +// ** Callback function used by selectWindowRewriteEList(). If necessary, +// ** this function appends to the output expression-list and updates +// ** expression (*ppExpr) in place. +// */ +func _selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var f, i, i1, iCol, nSrc, v4 int32 + var p, pDup, pParse, pWin uintptr + _, _, _, _, _, _, _, _, _, _ = f, i, i1, iCol, nSrc, p, pDup, pParse, pWin, v4 + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + /* If this function is being called from within a scalar sub-select + ** that used by the SELECT statement being processed, only process + ** TK_COLUMN expressions that refer to it (the outer SELECT). Do + ** not process aggregates or window functions at all, as they belong + ** to the scalar sub-select. */ + if (*TWindowRewrite)(unsafe.Pointer(p)).FpSubSelect != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLUMN) { + return WRC_Continue + } else { + nSrc = (*TSrcList)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSrc)).FnSrc + i = 0 + for { + if !(i < nSrc) { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*(*TSrcItem)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSrc + 8 + uintptr(i)*80))).FiCursor { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i == nSrc { + return WRC_Continue + } + } + } + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + case int32(TK_FUNCTION): + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != libc.Uint32FromInt32(0)) { + break + } else { + pWin = (*TWindowRewrite)(unsafe.Pointer(p)).FpWin + for { + if !(pWin != 0) { + break + } + if *(*uintptr)(unsafe.Pointer(pExpr + 64)) == pWin { + return int32(WRC_Prune) + } + goto _2 + _2: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + } + fallthrough + case int32(TK_IF_NULL_ROW): + fallthrough + case int32(TK_AGG_FUNCTION): + fallthrough + case int32(TK_COLUMN): + iCol = -int32(1) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + if (*TWindowRewrite)(unsafe.Pointer(p)).FpSub != 0 { + i1 = 0 + for { + if !(i1 < (*TExprList)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSub)).FnExpr) { + break + } + if 0 == _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSub + 8 + uintptr(i1)*32))).FpExpr, pExpr, -int32(1)) { + iCol = i1 + break + } + goto _3 + _3: + ; + i1 = i1 + 1 + } + } + if iCol < 0 { + pDup = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) + if pDup != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pDup)).Fop) == int32(TK_AGG_FUNCTION) { + (*TExpr)(unsafe.Pointer(pDup)).Fop = uint8(TK_FUNCTION) + } + (*TWindowRewrite)(unsafe.Pointer(p)).FpSub = _sqlite3ExprListAppend(tls, pParse, (*TWindowRewrite)(unsafe.Pointer(p)).FpSub, pDup) + } + if (*TWindowRewrite)(unsafe.Pointer(p)).FpSub != 0 { + f = libc.Int32FromUint32((*TExpr)(unsafe.Pointer(pExpr)).Fflags & uint32(EP_Collate)) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Static)) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Static)) + libc.Xmemset(tls, pExpr, 0, uint64(72)) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_COLUMN) + if iCol < 0 { + v4 = (*TExprList)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpSub)).FnExpr - int32(1) + } else { + v4 = iCol + } + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(v4) + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TWindow)(unsafe.Pointer((*TWindowRewrite)(unsafe.Pointer(p)).FpWin)).FiEphCsr + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TWindowRewrite)(unsafe.Pointer(p)).FpTab + (*TExpr)(unsafe.Pointer(pExpr)).Fflags = libc.Uint32FromInt32(f) + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return int32(WRC_Abort) + } + default: /* no-op */ + break + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Deserialize the data blob pointed to by buf as serial type serial_type +// ** and store the result in pMem. +// ** +// ** This function is implemented as two separate routines for performance. +// ** The few cases that require local variables are broken out into a separate +// ** routine so that in most cases the overhead of moving the stack pointer +// ** is avoided. +// */ +func _serialGet(tls *libc.TLS, buf uintptr, serial_type Tu32, pMem uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var y Tu32 + var v1 int32 + var _ /* x at bp+0 */ Tu64 + _, _ = y, v1 + **(**Tu64)(__ccgo_up(bp)) = uint64(uint32(**(**uint8)(__ccgo_up(buf)))< 0 && 0 == _sessionBufferGrow(tls, p, int64(nBlob), pRc) { + libc.Xmemcpy(tls, (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf), aBlob, libc.Uint64FromInt32(nBlob)) + **(**int32)(__ccgo_up(p + 8)) += nBlob + } +} + +// C documentation +// +// /* +// ** This function is called when rebasing a local UPDATE change against one +// ** or more remote UPDATE changes. The aRec/nRec buffer contains the current +// ** old.* and new.* records for the change. The rebase buffer (a single +// ** record) is in aChange/nChange. The rebased change is appended to buffer +// ** pBuf. +// ** +// ** Rebasing the UPDATE involves: +// ** +// ** * Removing any changes to fields for which the corresponding field +// ** in the rebase buffer is set to "replaced" (type 0xFF). If this +// ** means the UPDATE change updates no fields, nothing is appended +// ** to the output buffer. +// ** +// ** * For each field modified by the local change for which the +// ** corresponding field in the rebase buffer is not "undefined" (0x00) +// ** or "replaced" (0xFF), the old.* value is replaced by the value +// ** in the rebase buffer. +// */ +func _sessionAppendPartialUpdate(tls *libc.TLS, pBuf uintptr, pIter uintptr, aRec uintptr, nRec int32, aChange uintptr, nChange int32, pRc uintptr) { + var a1, a2, pOut, v1 uintptr + var bData, i, n1, n11, n2, n21 int32 + _, _, _, _, _, _, _, _, _, _ = a1, a2, bData, i, n1, n11, n2, n21, pOut, v1 + _sessionBufferGrow(tls, pBuf, int64(int32(2)+nRec+nChange), pRc) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + bData = 0 + pOut = (*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf) + a1 = aRec + a2 = aChange + v1 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8(SQLITE_UPDATE) + v1 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v1)) = libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect) + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + n1 = _sessionSerialLen(tls, a1) + n2 = _sessionSerialLen(tls, a2) + if **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i))) != 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a2))) == 0 { + if !(**(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i))) != 0) && **(**Tu8)(__ccgo_up(a1)) != 0 { + bData = int32(1) + } + libc.Xmemcpy(tls, pOut, a1, libc.Uint64FromInt32(n1)) + pOut = pOut + uintptr(n1) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a2))) != int32(0xFF) && **(**Tu8)(__ccgo_up(a1)) != 0 { + bData = int32(1) + libc.Xmemcpy(tls, pOut, a2, libc.Uint64FromInt32(n2)) + pOut = pOut + uintptr(n2) + } else { + v1 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8('\000') + } + } + a1 = a1 + uintptr(n1) + a2 = a2 + uintptr(n2) + goto _3 + _3: + ; + i = i + 1 + } + if bData != 0 { + a2 = aChange + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) { + break + } + n11 = _sessionSerialLen(tls, a1) + n21 = _sessionSerialLen(tls, a2) + if **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i))) != 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a2))) != int32(0xFF) { + libc.Xmemcpy(tls, pOut, a1, libc.Uint64FromInt32(n11)) + pOut = pOut + uintptr(n11) + } else { + v1 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8('\000') + } + a1 = a1 + uintptr(n11) + a2 = a2 + uintptr(n21) + goto _5 + _5: + ; + i = i + 1 + } + (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = int32(int64(pOut) - int64((*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf)) + } + } +} + +// C documentation +// +// /* +// ** Buffers a1 and a2 must both contain a sessions module record nCol +// ** fields in size. This function appends an nCol sessions module +// ** record to buffer pBuf that is a copy of a1, except that for +// ** each field that is undefined in a1[], swap in the field from a2[]. +// */ +func _sessionAppendRecordMerge(tls *libc.TLS, pBuf uintptr, nCol int32, a1 uintptr, n1 int32, a2 uintptr, n2 int32, pRc uintptr) { + var i, nn1, nn2 int32 + var pOut uintptr + _, _, _, _ = i, nn1, nn2, pOut + _sessionBufferGrow(tls, pBuf, int64(n1+n2), pRc) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + pOut = (*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf) + i = 0 + for { + if !(i < nCol) { + break + } + nn1 = _sessionSerialLen(tls, a1) + nn2 = _sessionSerialLen(tls, a2) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a1))) == 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a1))) == int32(0xFF) { + libc.Xmemcpy(tls, pOut, a2, libc.Uint64FromInt32(nn2)) + pOut = pOut + uintptr(nn2) + } else { + libc.Xmemcpy(tls, pOut, a1, libc.Uint64FromInt32(nn1)) + pOut = pOut + uintptr(nn1) + } + a1 = a1 + uintptr(nn1) + a2 = a2 + uintptr(nn2) + goto _1 + _1: + ; + i = i + 1 + } + (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = int32(int64(pOut) - int64((*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf)) + } +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append a string to the buffer. All bytes in the string +// ** up to (but not including) the nul-terminator are written to the buffer. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendStr(tls *libc.TLS, p uintptr, zStr uintptr, pRc uintptr) { + var nStr int32 + _ = nStr + nStr = _sqlite3Strlen30(tls, zStr) + if 0 == _sessionBufferGrow(tls, p, int64(nStr+int32(1)), pRc) { + libc.Xmemcpy(tls, (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf), zStr, libc.Uint64FromInt32(nStr)) + **(**int32)(__ccgo_up(p + 8)) += nStr + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf))) = uint8(0x00) + } +} + +// C documentation +// +// /* +// ** +// ** This function appends an update change to the buffer (see the comments +// ** under "CHANGESET FORMAT" at the top of the file). An update change +// ** consists of: +// ** +// ** 1 byte: SQLITE_UPDATE (0x17) +// ** n bytes: old.* record (see RECORD FORMAT) +// ** m bytes: new.* record (see RECORD FORMAT) +// ** +// ** The SessionChange object passed as the third argument contains the +// ** values that were stored in the row when the session began (the old.* +// ** values). The statement handle passed as the second argument points +// ** at the current version of the row (the new.* values). +// ** +// ** If all of the old.* values are equal to their corresponding new.* value +// ** (i.e. nothing has changed), then no data at all is appended to the buffer. +// ** +// ** Otherwise, the old.* record contains all primary key values and the +// ** original values of any fields that have been modified. The new.* record +// ** contains the new values of only those fields that have been modified. +// */ +func _sessionAppendUpdate(tls *libc.TLS, pBuf uintptr, bPatchset int32, pStmt uintptr, p uintptr, abPK uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bChanged, bNoop, eType, i, nAdvance, nHdr, nRewind int32 + var pCsr uintptr + var _ /* buf2 at bp+8 */ TSessionBuffer + var _ /* dVal at bp+32 */ float64 + var _ /* iVal at bp+24 */ Tsqlite3_int64 + var _ /* n at bp+40 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _ = bChanged, bNoop, eType, i, nAdvance, nHdr, nRewind, pCsr + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} /* Buffer to accumulate new.* record in */ + bNoop = int32(1) /* Set to zero if any values are modified */ + nRewind = (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf /* Used to iterate through columns */ + pCsr = (*TSessionChange)(unsafe.Pointer(p)).FaRecord /* Used to iterate through old.* values */ + _sessionAppendByte(tls, pBuf, uint8(SQLITE_UPDATE), bp) + _sessionAppendByte(tls, pBuf, (*TSessionChange)(unsafe.Pointer(p)).FbIndirect, bp) + i = 0 + for { + if !(i < Xsqlite3_column_count(tls, pStmt)) { + break + } + bChanged = 0 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pCsr))) + switch eType { + case int32(SQLITE_NULL): + nAdvance = int32(1) + if Xsqlite3_column_type(tls, pStmt, i) != int32(SQLITE_NULL) { + bChanged = int32(1) + } + case int32(SQLITE_FLOAT): + fallthrough + case int32(SQLITE_INTEGER): + nAdvance = int32(9) + if eType == Xsqlite3_column_type(tls, pStmt, i) { + **(**Tsqlite3_int64)(__ccgo_up(bp + 24)) = _sessionGetI64(tls, pCsr+1) + if eType == int32(SQLITE_INTEGER) { + if **(**Tsqlite3_int64)(__ccgo_up(bp + 24)) == Xsqlite3_column_int64(tls, pStmt, i) { + break + } + } else { + libc.Xmemcpy(tls, bp+32, bp+24, uint64(8)) + if **(**float64)(__ccgo_up(bp + 32)) == Xsqlite3_column_double(tls, pStmt, i) { + break + } + } + } + bChanged = int32(1) + default: + nHdr = int32(1) + _sessionVarintGet(tls, pCsr+1, bp+40) + nAdvance = nHdr + **(**int32)(__ccgo_up(bp + 40)) + if eType == Xsqlite3_column_type(tls, pStmt, i) && **(**int32)(__ccgo_up(bp + 40)) == Xsqlite3_column_bytes(tls, pStmt, i) && (**(**int32)(__ccgo_up(bp + 40)) == 0 || 0 == libc.Xmemcmp(tls, pCsr+uintptr(nHdr), Xsqlite3_column_blob(tls, pStmt, i), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 40))))) { + break + } + bChanged = int32(1) + } + /* If at least one field has been modified, this is not a no-op. */ + if bChanged != 0 { + bNoop = 0 + } + /* Add a field to the old.* record. This is omitted if this module is + ** currently generating a patchset. */ + if bPatchset == 0 { + if bChanged != 0 || **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + _sessionAppendBlob(tls, pBuf, pCsr, nAdvance, bp) + } else { + _sessionAppendByte(tls, pBuf, uint8(0), bp) + } + } + /* Add a field to the new.* record. Or the only record if currently + ** generating a patchset. */ + if bChanged != 0 || bPatchset != 0 && **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + _sessionAppendCol(tls, bp+8, pStmt, i, bp) + } else { + _sessionAppendByte(tls, bp+8, uint8(0), bp) + } + pCsr = pCsr + uintptr(nAdvance) + goto _1 + _1: + ; + i = i + 1 + } + if bNoop != 0 { + (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = nRewind + } else { + _sessionAppendBlob(tls, pBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf, bp) + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This function is called to merge two changes to the same row together as +// ** part of an sqlite3changeset_concat() operation. A new change object is +// ** allocated and a pointer to it stored in *ppNew. +// ** +// ** Because they have been vetted by sqlite3changegroup_add() or similar, +// ** both the aRec[] change and the pExist change are safe to use without +// ** checking for buffer overflows. +// */ +func _sessionChangeMerge(tls *libc.TLS, pTab uintptr, bRebase int32, bPatchset int32, pExist uintptr, op2 int32, bIndirect int32, aRec uintptr, nRec int32, ppNew uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a1, a2, aExist, pIn, pNew, pOut, pOut1, v2 uintptr + var i, i1, n1, n2, nIn, op1, rc int32 + var nByte, nByte1 Tsqlite3_int64 + var _ /* a1 at bp+16 */ uintptr + var _ /* a1 at bp+8 */ uintptr + var _ /* a2 at bp+24 */ uintptr + var _ /* aCsr at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a1, a2, aExist, i, i1, n1, n2, nByte, nByte1, nIn, op1, pIn, pNew, pOut, pOut1, rc, v2 + pNew = uintptr(0) + rc = SQLITE_OK + if !(pExist != 0) { + pNew = Xsqlite3_malloc64(tls, uint64(uint64(32)+libc.Uint64FromInt32(nRec))) + if !(pNew != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pNew, 0, uint64(32)) + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = libc.Uint8FromInt32(op2) + (*TSessionChange)(unsafe.Pointer(pNew)).FbIndirect = libc.Uint8FromInt32(bIndirect) + (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord = pNew + 1*32 + if bIndirect == 0 || bRebase == 0 { + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecord = nRec + libc.Xmemcpy(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord, aRec, libc.Uint64FromInt32(nRec)) + } else { + pIn = aRec + pOut = (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + nIn = _sessionSerialLen(tls, pIn) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pIn))) == 0 { + v2 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8(0) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i)))) == 0 { + v2 = pOut + pOut = pOut + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8(0xFF) + } else { + libc.Xmemcpy(tls, pOut, pIn, libc.Uint64FromInt32(nIn)) + pOut = pOut + uintptr(nIn) + } + } + pIn = pIn + uintptr(nIn) + goto _1 + _1: + ; + i = i + 1 + } + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecord = int32(int64(pOut) - int64((*TSessionChange)(unsafe.Pointer(pNew)).FaRecord)) + } + } else { + if bRebase != 0 { + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pExist)).Fop) == int32(SQLITE_DELETE) && (*TSessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0 { + **(**uintptr)(__ccgo_up(ppNew)) = pExist + } else { + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(nRec+(*TSessionChange)(unsafe.Pointer(pExist)).FnRecord) + uint64(32)) + pNew = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + a1 = (*TSessionChange)(unsafe.Pointer(pExist)).FaRecord + a2 = aRec + libc.Xmemset(tls, pNew, 0, libc.Uint64FromInt64(nByte)) + (*TSessionChange)(unsafe.Pointer(pNew)).FbIndirect = libc.BoolUint8(bIndirect != 0 || (*TSessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0) + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = libc.Uint8FromInt32(op2) + v2 = pNew + 1*32 + (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord = v2 + pOut1 = v2 + i1 = 0 + for { + if !(i1 < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + n1 = _sessionSerialLen(tls, a1) + n2 = _sessionSerialLen(tls, a2) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a1))) == int32(0xFF) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i1)))) == 0 && bIndirect != 0 { + v2 = pOut1 + pOut1 = pOut1 + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8(0xFF) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a2))) == 0 { + libc.Xmemcpy(tls, pOut1, a1, libc.Uint64FromInt32(n1)) + pOut1 = pOut1 + uintptr(n1) + } else { + libc.Xmemcpy(tls, pOut1, a2, libc.Uint64FromInt32(n2)) + pOut1 = pOut1 + uintptr(n2) + } + } + a1 = a1 + uintptr(n1) + a2 = a2 + uintptr(n2) + goto _5 + _5: + ; + i1 = i1 + 1 + } + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecord = int32(int64(pOut1) - int64((*TSessionChange)(unsafe.Pointer(pNew)).FaRecord)) + } + Xsqlite3_free(tls, pExist) + } + } else { + op1 = libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pExist)).Fop) + /* + ** op1=INSERT, op2=INSERT -> Unsupported. Discard op2. + ** op1=INSERT, op2=UPDATE -> INSERT. + ** op1=INSERT, op2=DELETE -> (none) + ** + ** op1=UPDATE, op2=INSERT -> Unsupported. Discard op2. + ** op1=UPDATE, op2=UPDATE -> UPDATE. + ** op1=UPDATE, op2=DELETE -> DELETE. + ** + ** op1=DELETE, op2=INSERT -> UPDATE. + ** op1=DELETE, op2=UPDATE -> Unsupported. Discard op2. + ** op1=DELETE, op2=DELETE -> Unsupported. Discard op2. + */ + if op1 == int32(SQLITE_INSERT) && op2 == int32(SQLITE_INSERT) || op1 == int32(SQLITE_UPDATE) && op2 == int32(SQLITE_INSERT) || op1 == int32(SQLITE_DELETE) && op2 == int32(SQLITE_UPDATE) || op1 == int32(SQLITE_DELETE) && op2 == int32(SQLITE_DELETE) { + pNew = pExist + } else { + if op1 == int32(SQLITE_INSERT) && op2 == int32(SQLITE_DELETE) { + Xsqlite3_free(tls, pExist) + } else { + aExist = (*TSessionChange)(unsafe.Pointer(pExist)).FaRecord + /* Allocate a new SessionChange object. Ensure that the aRecord[] + ** buffer of the new object is large enough to hold any record that + ** may be generated by combining the input records. */ + nByte1 = libc.Int64FromUint64(uint64(32) + libc.Uint64FromInt32((*TSessionChange)(unsafe.Pointer(pExist)).FnRecord) + libc.Uint64FromInt32(nRec)) + pNew = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte1)) + if !(pNew != 0) { + Xsqlite3_free(tls, pExist) + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pNew, 0, uint64(32)) + (*TSessionChange)(unsafe.Pointer(pNew)).FbIndirect = libc.BoolUint8(bIndirect != 0 && (*TSessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0) + v2 = pNew + 1*32 + (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord = v2 + **(**uintptr)(__ccgo_up(bp)) = v2 + if op1 == int32(SQLITE_INSERT) { /* INSERT + UPDATE */ + **(**uintptr)(__ccgo_up(bp + 8)) = aRec + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = uint8(SQLITE_INSERT) + if bPatchset == 0 { + _sessionSkipRecord(tls, bp+8, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) + } + _sessionMergeRecord(tls, bp, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, aExist, **(**uintptr)(__ccgo_up(bp + 8))) + } else { + if op1 == int32(SQLITE_DELETE) { /* DELETE + INSERT */ + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = uint8(SQLITE_UPDATE) + if bPatchset != 0 { + libc.Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp)), aRec, libc.Uint64FromInt32(nRec)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(nRec) + } else { + if 0 == _sessionMergeUpdate(tls, bp, pTab, bPatchset, aExist, uintptr(0), aRec, uintptr(0)) { + Xsqlite3_free(tls, pNew) + pNew = uintptr(0) + } + } + } else { + if op2 == int32(SQLITE_UPDATE) { /* UPDATE + UPDATE */ + **(**uintptr)(__ccgo_up(bp + 16)) = aExist + **(**uintptr)(__ccgo_up(bp + 24)) = aRec + if bPatchset == 0 { + _sessionSkipRecord(tls, bp+16, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) + _sessionSkipRecord(tls, bp+24, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) + } + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = uint8(SQLITE_UPDATE) + if 0 == _sessionMergeUpdate(tls, bp, pTab, bPatchset, aRec, aExist, **(**uintptr)(__ccgo_up(bp + 16)), **(**uintptr)(__ccgo_up(bp + 24))) { + Xsqlite3_free(tls, pNew) + pNew = uintptr(0) + } + } else { /* UPDATE + DELETE */ + (*TSessionChange)(unsafe.Pointer(pNew)).Fop = uint8(SQLITE_DELETE) + if bPatchset != 0 { + libc.Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp)), aRec, libc.Uint64FromInt32(nRec)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(nRec) + } else { + _sessionMergeRecord(tls, bp, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, aRec, aExist) + } + } + } + } + if pNew != 0 { + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecord = int32(int64(**(**uintptr)(__ccgo_up(bp))) - int64((*TSessionChange)(unsafe.Pointer(pNew)).FaRecord)) + } + Xsqlite3_free(tls, pExist) + } + } + } + } + **(**uintptr)(__ccgo_up(ppNew)) = pNew + return rc +} + +// C documentation +// +// /* +// ** Locate or create a SessionTable object that may be used to add the +// ** change currently pointed to by iterator pIter to changegroup pGrp. +// ** If successful, set output variable (*ppTab) to point to the table +// ** object and return SQLITE_OK. Otherwise, if some error occurs, return +// ** an SQLite error code and leave (*ppTab) set to NULL. +// */ +func _sessionChangesetFindTable(tls *libc.TLS, pGrp uintptr, zTab uintptr, pIter uintptr, ppTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nTab, rc int32 + var pTab, ppNew uintptr + var _ /* abPK at bp+0 */ uintptr + var _ /* nCol at bp+8 */ int32 + _, _, _, _ = nTab, pTab, ppNew, rc + rc = SQLITE_OK + pTab = uintptr(0) + nTab = libc.Int32FromUint64(libc.Xstrlen(tls, zTab)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = 0 + **(**uintptr)(__ccgo_up(ppTab)) = uintptr(0) + /* Search the list for an existing table */ + pTab = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList + for { + if !(pTab != 0) { + break + } + if 0 == Xsqlite3_strnicmp(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zTab, nTab+int32(1)) { + break + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + if pIter != 0 { + Xsqlite3changeset_pk(tls, pIter, bp, bp+8) + } else { + if !(pTab != 0) && !((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb != 0) { + return SQLITE_OK + } + } + /* If one was not found above, create a new table now */ + if !(pTab != 0) { + pTab = Xsqlite3_malloc64(tls, uint64(uint64(88)+libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 8)))+libc.Uint64FromInt32(nTab)+uint64(1))) + if !(pTab != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pTab, 0, uint64(88)) + (*TSessionTable)(unsafe.Pointer(pTab)).FnCol = **(**int32)(__ccgo_up(bp + 8)) + (*TSessionTable)(unsafe.Pointer(pTab)).FabPK = pTab + 1*88 + if **(**int32)(__ccgo_up(bp + 8)) > 0 { + libc.Xmemcpy(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK, **(**uintptr)(__ccgo_up(bp)), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 8)))) + } + (*TSessionTable)(unsafe.Pointer(pTab)).FzName = (*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(**(**int32)(__ccgo_up(bp + 8))) + libc.Xmemcpy(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zTab, libc.Uint64FromInt32(nTab+int32(1))) + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb != 0 { + (*TSessionTable)(unsafe.Pointer(pTab)).FnCol = 0 + rc = _sessionInitTable(tls, uintptr(0), pTab, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FzDb) + if rc != 0 || (*TSessionTable)(unsafe.Pointer(pTab)).FnCol == 0 { + Xsqlite3_free(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol) + Xsqlite3_free(tls, pTab) + return rc + } + } + /* The new object must be linked on to the end of the list, not + ** simply added to the start of it. This is to ensure that the + ** tables within the output of sqlite3changegroup_output() are in + ** the right order. */ + ppNew = pGrp + 8 + for { + if !(**(**uintptr)(__ccgo_up(ppNew)) != 0) { + break + } + goto _2 + _2: + ; + ppNew = **(**uintptr)(__ccgo_up(ppNew)) + } + **(**uintptr)(__ccgo_up(ppNew)) = pTab + } + /* Check that the table is compatible. */ + if pIter != 0 && !(_sessionChangesetCheckCompat(tls, pTab, **(**int32)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp))) != 0) { + rc = int32(SQLITE_SCHEMA) + } + **(**uintptr)(__ccgo_up(ppTab)) = pTab + return rc +} + +func _sessionChangesetInvert(tls *libc.TLS, pInput uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr, pnInverted uintptr, ppInverted uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var abPK, apVal, pVal, pVal1, v7 uintptr + var bIndirect, eType2, iCol, nVar, v1 int32 + var eType Tu8 + var _ /* nByte at bp+48 */ int32 + var _ /* nByte at bp+52 */ int32 + var _ /* nCol at bp+24 */ int32 + var _ /* rc at bp+0 */ int32 + var _ /* sOut at bp+8 */ TSessionBuffer + var _ /* sPK at bp+32 */ TSessionBuffer + _, _, _, _, _, _, _, _, _, _, _ = abPK, apVal, bIndirect, eType, eType2, iCol, nVar, pVal, pVal1, v1, v7 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Output buffer */ + **(**int32)(__ccgo_up(bp + 24)) = 0 /* Number of cols in current table */ + abPK = uintptr(0) /* PK array for current table */ + apVal = uintptr(0) /* Space for values for UPDATE inversion */ + **(**TSessionBuffer)(__ccgo_up(bp + 32)) = TSessionBuffer{} /* PK array for current table */ + /* Initialize the output buffer */ + libc.Xmemset(tls, bp+8, 0, uint64(16)) + /* Zero the output variables in case an error occurs. */ + if ppInverted != 0 { + **(**uintptr)(__ccgo_up(ppInverted)) = uintptr(0) + **(**int32)(__ccgo_up(pnInverted)) = 0 + } + for int32(1) != 0 { + /* Test for EOF. */ + v1 = _sessionInputBuffer(tls, pInput, int32(2)) + **(**int32)(__ccgo_up(bp)) = v1 + if v1 != 0 { + goto finished_invert + } + if (*TSessionInput)(unsafe.Pointer(pInput)).FiNext+int32(1) >= (*TSessionInput)(unsafe.Pointer(pInput)).FnData { + if (*TSessionInput)(unsafe.Pointer(pInput)).FiNext != (*TSessionInput)(unsafe.Pointer(pInput)).FnData { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(237677)) + goto finished_invert + } + break + } + eType = **(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext))) + switch libc.Int32FromUint8(eType) { + case int32('T'): + (*TSessionInput)(unsafe.Pointer(pInput)).FiNext = (*TSessionInput)(unsafe.Pointer(pInput)).FiNext + 1 + v1 = _sessionChangesetBufferTblhdr(tls, pInput, bp+48) + **(**int32)(__ccgo_up(bp)) = v1 + if v1 != 0 { + goto finished_invert + } + nVar = _sessionVarintGet(tls, (*TSessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext), bp+24) + (**(**TSessionBuffer)(__ccgo_up(bp + 32))).FnBuf = 0 + _sessionAppendBlob(tls, bp+32, (*TSessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext+nVar), **(**int32)(__ccgo_up(bp + 24)), bp) + _sessionAppendByte(tls, bp+8, eType, bp) + _sessionAppendBlob(tls, bp+8, (*TSessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext), **(**int32)(__ccgo_up(bp + 48)), bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto finished_invert + } + **(**int32)(__ccgo_up(pInput + 8)) += **(**int32)(__ccgo_up(bp + 48)) + Xsqlite3_free(tls, apVal) + apVal = uintptr(0) + abPK = (**(**TSessionBuffer)(__ccgo_up(bp + 32))).FaBuf + case int32(SQLITE_INSERT): + fallthrough + case int32(SQLITE_DELETE): + bIndirect = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext+int32(1))))) + if libc.Int32FromUint8(eType) == int32(SQLITE_DELETE) { + v1 = int32(SQLITE_INSERT) + } else { + v1 = int32(SQLITE_DELETE) + } + eType2 = v1 + **(**int32)(__ccgo_up(pInput + 8)) += int32(2) + **(**int32)(__ccgo_up(bp)) = _sessionChangesetBufferRecord(tls, pInput, **(**int32)(__ccgo_up(bp + 24)), bp+52) + _sessionAppendByte(tls, bp+8, libc.Uint8FromInt32(eType2), bp) + _sessionAppendByte(tls, bp+8, libc.Uint8FromInt32(bIndirect), bp) + _sessionAppendBlob(tls, bp+8, (*TSessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext), **(**int32)(__ccgo_up(bp + 52)), bp) + **(**int32)(__ccgo_up(pInput + 8)) += **(**int32)(__ccgo_up(bp + 52)) + if **(**int32)(__ccgo_up(bp)) != 0 { + goto finished_invert + } + case int32(SQLITE_UPDATE): + if uintptr(0) == apVal { + apVal = Xsqlite3_malloc64(tls, uint64(uint64(8)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 24)))*uint64(2))) + if uintptr(0) == apVal { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + goto finished_invert + } + libc.Xmemset(tls, apVal, 0, uint64(8)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 24)))*uint64(2)) + } + /* Write the header for the new UPDATE change. Same as the original. */ + _sessionAppendByte(tls, bp+8, eType, bp) + _sessionAppendByte(tls, bp+8, **(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pInput)).FiNext+int32(1)))), bp) + /* Read the old.* and new.* records for the update change. */ + **(**int32)(__ccgo_up(pInput + 8)) += int32(2) + **(**int32)(__ccgo_up(bp)) = _sessionReadRecord(tls, pInput, **(**int32)(__ccgo_up(bp + 24)), uintptr(0), apVal, uintptr(0)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionReadRecord(tls, pInput, **(**int32)(__ccgo_up(bp + 24)), uintptr(0), apVal+uintptr(**(**int32)(__ccgo_up(bp + 24)))*8, uintptr(0)) + } + /* Write the new old.* record. Consists of the PK columns from the + ** original old.* record, and the other values from the original + ** new.* record. */ + iCol = 0 + for { + if !(iCol < **(**int32)(__ccgo_up(bp + 24))) { + break + } + if **(**Tu8)(__ccgo_up(abPK + uintptr(iCol))) != 0 { + v1 = 0 + } else { + v1 = **(**int32)(__ccgo_up(bp + 24)) + } + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr(iCol+v1)*8)) + _sessionAppendValue(tls, bp+8, pVal, bp) + goto _4 + _4: + ; + iCol = iCol + 1 + } + /* Write the new new.* record. Consists of a copy of all values + ** from the original old.* record, except for the PK columns, which + ** are set to "undefined". */ + iCol = 0 + for { + if !(iCol < **(**int32)(__ccgo_up(bp + 24))) { + break + } + if **(**Tu8)(__ccgo_up(abPK + uintptr(iCol))) != 0 { + v7 = uintptr(0) + } else { + v7 = **(**uintptr)(__ccgo_up(apVal + uintptr(iCol)*8)) + } + pVal1 = v7 + _sessionAppendValue(tls, bp+8, pVal1, bp) + goto _6 + _6: + ; + iCol = iCol + 1 + } + iCol = 0 + for { + if !(iCol < **(**int32)(__ccgo_up(bp + 24))*int32(2)) { + break + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(iCol)*8))) + goto _8 + _8: + ; + iCol = iCol + 1 + } + libc.Xmemset(tls, apVal, 0, uint64(8)*libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 24)))*uint64(2)) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto finished_invert + } + default: + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(237780)) + goto finished_invert + } + if __ccgo_fp_xOutput != 0 && (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf >= _sessions_strm_chunk_size { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf) + (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf = 0 + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + goto finished_invert + } + } + } + if pnInverted != 0 && ppInverted != 0 { + **(**int32)(__ccgo_up(pnInverted)) = (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf + **(**uintptr)(__ccgo_up(ppInverted)) = (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf + (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf = uintptr(0) + } else { + if (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf > 0 && __ccgo_fp_xOutput != uintptr(0) { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf) + } + } + goto finished_invert +finished_invert: + ; + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + Xsqlite3_free(tls, apVal) + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 32))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Advance the changeset iterator to the next change. The differences between +// ** this function and sessionChangesetNext() are that +// ** +// ** * If pbEmpty is not NULL and the change is a no-op UPDATE (an UPDATE +// ** that modifies no columns), this function sets (*pbEmpty) to 1. +// ** +// ** * If the iterator is configured to skip no-op UPDATEs, +// ** sessionChangesetNext() does that. This function does not. +// */ +func _sessionChangesetNextOne(tls *libc.TLS, p uintptr, paRec uintptr, pnRec uintptr, pbNew uintptr, pbEmpty uintptr) (r int32) { + var abPK, apNew, apOld, v10, v3, v6 uintptr + var i, nVal, v2 int32 + var op Tu8 + _, _, _, _, _, _, _, _, _, _ = abPK, apNew, apOld, i, nVal, op, v10, v2, v3, v6 + /* If the iterator is in the error-state, return immediately. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + /* Free the current contents of p->apValue[], if any. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue != 0 { + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol*int32(2)) { + break + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + libc.Xmemset(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue, 0, uint64(8)*libc.Uint64FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*uint64(2)) + } + /* Make sure the buffer contains at least 2 bytes of input data, or all + ** remaining data if there are less than 2 bytes available. This is + ** sufficient either for the 'T' or 'P' byte that begins a new table, + ** or for the "op" and "bIndirect" single bytes otherwise. */ + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = _sessionInputBuffer(tls, p, int32(2)) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiCurrent = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext + _sessionDiscardData(tls, p) + /* If the iterator is already at the end of the changeset, return DONE. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FnData { + return int32(SQLITE_DONE) + } + v3 = p + 8 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + op = **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(v2))) + for libc.Int32FromUint8(op) == int32('T') || libc.Int32FromUint8(op) == int32('P') { + if pbNew != 0 { + **(**int32)(__ccgo_up(pbNew)) = int32(1) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset = libc.BoolInt32(libc.Int32FromUint8(op) == int32('P')) + if _sessionChangesetReadTblhdr(tls, p) != 0 { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + v2 = _sessionInputBuffer(tls, p, int32(2)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + if v2 != 0 { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiCurrent = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FnData { + return int32(SQLITE_DONE) + } + v3 = p + 8 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + op = **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(v2))) + } + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab == uintptr(0) || (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 && (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 { + /* The first record in the changeset is not a table header. Must be a + ** corrupt changeset. */ + v2 = _sqlite3CorruptError(tls, int32(237357)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + return v2 + } + if libc.Int32FromUint8(op) != int32(SQLITE_UPDATE) && libc.Int32FromUint8(op) != int32(SQLITE_DELETE) && libc.Int32FromUint8(op) != int32(SQLITE_INSERT) || (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FnData { + v2 = _sqlite3CorruptError(tls, int32(237363)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + return v2 + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = libc.Int32FromUint8(op) + v3 = p + 8 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbIndirect = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(v2)))) + if paRec != 0 { /* Number of values to buffer */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 && libc.Int32FromUint8(op) == int32(SQLITE_UPDATE) { + nVal = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol * int32(2) + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 && libc.Int32FromUint8(op) == int32(SQLITE_DELETE) { + nVal = 0 + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 { + nVal = nVal + 1 + } + goto _11 + _11: + ; + i = i + 1 + } + } else { + nVal = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol + } + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = _sessionChangesetBufferRecord(tls, p, nVal, pnRec) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + **(**uintptr)(__ccgo_up(paRec)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext += **(**int32)(__ccgo_up(pnRec)) + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 { + v3 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8 + } else { + v3 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + } + apOld = v3 + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 { + v6 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + } else { + v6 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8 + } + apNew = v6 + /* If this is an UPDATE or DELETE, read the old.* record. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != int32(SQLITE_INSERT) && ((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 || (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_DELETE)) { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 { + v10 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + } else { + v10 = uintptr(0) + } + abPK = v10 + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = _sessionReadRecord(tls, p, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol, abPK, apOld, uintptr(0)) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + } + /* If this is an INSERT or UPDATE, read the new.* record. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != int32(SQLITE_DELETE) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = _sessionReadRecord(tls, p, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol, uintptr(0), apNew, pbEmpty) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + } + } + if ((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 || (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0) && (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_UPDATE) { + /* If this is an UPDATE that is part of a patchset, then all PK and + ** modified fields are present in the new.* record. The old.* record + ** is currently completely empty. This block shifts the PK fields from + ** new.* to old.*, to accommodate the code that reads these arrays. */ + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 { + **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8)) + if **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8)) == uintptr(0) { + v2 = _sqlite3CorruptError(tls, int32(237409)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + return v2 + } + **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8)) = uintptr(0) + } + goto _15 + _15: + ; + i = i + 1 + } + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_INSERT) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = int32(SQLITE_DELETE) + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_DELETE) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = int32(SQLITE_INSERT) + } + } + } + } + /* If this is an UPDATE that is part of a changeset, then check that + ** there are no fields in the old.* record that are not (a) PK fields, + ** or (b) also present in the new.* record. + ** + ** Such records are technically corrupt, but the rebaser was at one + ** point generating them. Under most circumstances this is benign, but + ** can cause spurious SQLITE_RANGE errors when applying the changeset. */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 && (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == int32(SQLITE_UPDATE) { + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i)))) == 0 && **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*8)) == uintptr(0) { + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8))) + **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8)) = uintptr(0) + } + goto _17 + _17: + ; + i = i + 1 + } + } + } + return int32(SQLITE_ROW) +} + +// C documentation +// +// /* +// ** The input pointer currently points to the second byte of a table-header. +// ** Specifically, to the following: +// ** +// ** + number of columns in table (varint) +// ** + array of PK flags (1 byte per column), +// ** + table name (nul terminated). +// ** +// ** This function decodes the table-header and populates the p->nCol, +// ** p->zTab and p->abPK[] variables accordingly. The p->apValue[] array is +// ** also allocated or resized according to the new value of p->nCol. The +// ** input pointer is left pointing to the byte following the table header. +// ** +// ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code +// ** is returned and the final values of the various fields enumerated above +// ** are undefined. +// */ +func _sessionChangesetReadTblhdr(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iPK Tsize_t + var nByte, nVarint, v2 int32 + var v1 uintptr + var _ /* nCopy at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _ = iPK, nByte, nVarint, v1, v2 + **(**int32)(__ccgo_up(bp)) = _sessionChangesetBufferTblhdr(tls, p, bp+4) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + nVarint = _sessionVarintGet(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData+uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext), p+120) + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol > 0 { + **(**int32)(__ccgo_up(bp + 4)) = **(**int32)(__ccgo_up(bp + 4)) - nVarint + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext += nVarint + nByte = libc.Int32FromUint64(libc.Uint64FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*uint64(8)*uint64(2) + libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 4)))) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FnBuf = 0 + _sessionBufferGrow(tls, p+72, int64(nByte), bp) + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3CorruptError(tls, int32(237271)) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + iPK = uint64(8) * libc.Uint64FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) * uint64(2) + libc.Xmemset(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf, 0, iPK) + libc.Xmemcpy(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf+uintptr(iPK), (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData+uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 4)))) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext += **(**int32)(__ccgo_up(bp + 4)) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue == uintptr(0) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK = uintptr(0) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab = uintptr(0) + } else { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol*int32(2))*8 + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK != 0 { + v1 = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) + } else { + v1 = uintptr(0) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab = v1 + } + v2 = **(**int32)(__ccgo_up(bp)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = v2 + return v2 +} + +// C documentation +// +// /* +// ** If the SessionInput object passed as the only argument is a streaming +// ** object and the buffer is full, discard some data to free up space. +// */ +func _sessionDiscardData(tls *libc.TLS, pIn uintptr) { + var nMove int32 + _ = nMove + if (*TSessionInput)(unsafe.Pointer(pIn)).FxInput != 0 && (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent >= _sessions_strm_chunk_size { + nMove = (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf - (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent + if nMove > 0 { + libc.Xmemmove(tls, (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf, (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf+uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent), libc.Uint64FromInt32(nMove)) + } + (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf -= (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent + **(**int32)(__ccgo_up(pIn + 8)) -= (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent + (*TSessionInput)(unsafe.Pointer(pIn)).FiCurrent = 0 + (*TSessionInput)(unsafe.Pointer(pIn)).FnData = (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf + } +} + +// C documentation +// +// /* +// ** If required, grow the hash table used to store changes on table pTab +// ** (part of the session pSession). If a fatal OOM error occurs, set the +// ** session object to failed and return SQLITE_ERROR. Otherwise, return +// ** SQLITE_OK. +// ** +// ** It is possible that a non-fatal OOM error occurs in this function. In +// ** that case the hash-table does not grow, but SQLITE_OK is returned anyway. +// ** Growing the hash table in this case is a performance optimization only, +// ** it is not required for correct operation. +// */ +func _sessionGrowHash(tls *libc.TLS, pSession uintptr, bPatchset int32, pTab uintptr) (r int32) { + var apNew, p, pNext uintptr + var bPkOnly, i, iHash, v1 int32 + var nNew Tsqlite3_int64 + _, _, _, _, _, _, _, _ = apNew, bPkOnly, i, iHash, nNew, p, pNext, v1 + if (*TSessionTable)(unsafe.Pointer(pTab)).FnChange == 0 || (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry >= (*TSessionTable)(unsafe.Pointer(pTab)).FnChange/int32(2) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FnChange != 0 { + v1 = (*TSessionTable)(unsafe.Pointer(pTab)).FnChange + } else { + v1 = int32(128) + } + nNew = int64(2) * int64(v1) + apNew = _sessionMalloc64(tls, pSession, libc.Int64FromUint64(uint64(8)*libc.Uint64FromInt64(nNew))) + if apNew == uintptr(0) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FnChange == 0 { + return int32(SQLITE_ERROR) + } + return SQLITE_OK + } + libc.Xmemset(tls, apNew, 0, uint64(uint64(8)*libc.Uint64FromInt64(nNew))) + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnChange) { + break + } + p = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*8)) + for { + if !(p != 0) { + break + } + bPkOnly = libc.BoolInt32(libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(p)).Fop) == int32(SQLITE_DELETE) && bPatchset != 0) + iHash = libc.Int32FromUint32(_sessionChangeHash(tls, pTab, bPkOnly, (*TSessionChange)(unsafe.Pointer(p)).FaRecord, int32(nNew))) + pNext = (*TSessionChange)(unsafe.Pointer(p)).FpNext + (*TSessionChange)(unsafe.Pointer(p)).FpNext = **(**uintptr)(__ccgo_up(apNew + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up(apNew + uintptr(iHash)*8)) = p + goto _3 + _3: + ; + p = pNext + } + goto _2 + _2: + ; + i = i + 1 + } + _sessionFree(tls, pSession, (*TSessionTable)(unsafe.Pointer(pTab)).FapChange) + (*TSessionTable)(unsafe.Pointer(pTab)).FnChange = int32(nNew) + (*TSessionTable)(unsafe.Pointer(pTab)).FapChange = apNew + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Arguments aLeft and aRight both point to buffers containing change +// ** records with nCol columns. This function "merges" the two records into +// ** a single records which is written to the buffer at *paOut. *paOut is +// ** then set to point to one byte after the last byte written before +// ** returning. +// ** +// ** The merging of records is done as follows: For each column, if the +// ** aRight record contains a value for the column, copy the value from +// ** their. Otherwise, if aLeft contains a value, copy it. If neither +// ** record contains a value for a given column, then neither does the +// ** output record. +// */ +func _sessionMergeRecord(tls *libc.TLS, paOut uintptr, nCol int32, aLeft uintptr, aRight uintptr) { + var a1, a2, aOut uintptr + var iCol, n1, n2 int32 + _, _, _, _, _, _ = a1, a2, aOut, iCol, n1, n2 + a1 = aLeft /* Cursor used to iterate through aLeft */ + a2 = aRight /* Cursor used to iterate through aRight */ + aOut = **(**uintptr)(__ccgo_up(paOut)) /* Used to iterate from 0 to nCol */ + iCol = 0 + for { + if !(iCol < nCol) { + break + } + n1 = _sessionSerialLen(tls, a1) + n2 = _sessionSerialLen(tls, a2) + if **(**Tu8)(__ccgo_up(a2)) != 0 { + libc.Xmemcpy(tls, aOut, a2, libc.Uint64FromInt32(n2)) + aOut = aOut + uintptr(n2) + } else { + libc.Xmemcpy(tls, aOut, a1, libc.Uint64FromInt32(n1)) + aOut = aOut + uintptr(n1) + } + a1 = a1 + uintptr(n1) + a2 = a2 + uintptr(n2) + goto _1 + _1: + ; + iCol = iCol + 1 + } + **(**uintptr)(__ccgo_up(paOut)) = aOut +} + +// C documentation +// +// /* +// ** This function is used by changeset_concat() to merge two UPDATE changes +// ** on the same row. +// */ +func _sessionMergeUpdate(tls *libc.TLS, paOut uintptr, pTab uintptr, bPatchset int32, aOldRecord1 uintptr, aOldRecord2 uintptr, aNewRecord1 uintptr, aNewRecord2 uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aNew, aNew1, aOld, aOld1, aOut, v2 uintptr + var bRequired, i int32 + var _ /* aNew1 at bp+16 */ uintptr + var _ /* aNew2 at bp+24 */ uintptr + var _ /* aOld1 at bp+0 */ uintptr + var _ /* aOld2 at bp+8 */ uintptr + var _ /* nNew at bp+36 */ int32 + var _ /* nNew at bp+44 */ int32 + var _ /* nOld at bp+32 */ int32 + var _ /* nOld at bp+40 */ int32 + _, _, _, _, _, _, _, _ = aNew, aNew1, aOld, aOld1, aOut, bRequired, i, v2 + **(**uintptr)(__ccgo_up(bp)) = aOldRecord1 + **(**uintptr)(__ccgo_up(bp + 8)) = aOldRecord2 + **(**uintptr)(__ccgo_up(bp + 16)) = aNewRecord1 + **(**uintptr)(__ccgo_up(bp + 24)) = aNewRecord2 + aOut = **(**uintptr)(__ccgo_up(paOut)) + if bPatchset == 0 { + bRequired = 0 + /* Write the old.* vector first. */ + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + aOld = _sessionMergeValue(tls, bp, bp+8, bp+32) + aNew = _sessionMergeValue(tls, bp+16, bp+24, bp+36) + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 || **(**int32)(__ccgo_up(bp + 32)) != **(**int32)(__ccgo_up(bp + 36)) || libc.Xmemcmp(tls, aOld, aNew, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 36)))) != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i)))) == 0 { + bRequired = int32(1) + } + libc.Xmemcpy(tls, aOut, aOld, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 32)))) + aOut = aOut + uintptr(**(**int32)(__ccgo_up(bp + 32))) + } else { + v2 = aOut + aOut = aOut + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8('\000') + } + goto _1 + _1: + ; + i = i + 1 + } + if !(bRequired != 0) { + return 0 + } + } + /* Write the new.* vector */ + **(**uintptr)(__ccgo_up(bp)) = aOldRecord1 + **(**uintptr)(__ccgo_up(bp + 8)) = aOldRecord2 + **(**uintptr)(__ccgo_up(bp + 16)) = aNewRecord1 + **(**uintptr)(__ccgo_up(bp + 24)) = aNewRecord2 + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + aOld1 = _sessionMergeValue(tls, bp, bp+8, bp+40) + aNew1 = _sessionMergeValue(tls, bp+16, bp+24, bp+44) + if bPatchset == 0 && (**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 || **(**int32)(__ccgo_up(bp + 40)) == **(**int32)(__ccgo_up(bp + 44)) && 0 == libc.Xmemcmp(tls, aOld1, aNew1, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 44))))) { + v2 = aOut + aOut = aOut + 1 + **(**Tu8)(__ccgo_up(v2)) = uint8('\000') + } else { + libc.Xmemcpy(tls, aOut, aNew1, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 44)))) + aOut = aOut + uintptr(**(**int32)(__ccgo_up(bp + 44))) + } + goto _3 + _3: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up(paOut)) = aOut + return int32(1) +} + +// C documentation +// +// /* +// ** This function is only called from within a pre-update-hook callback. +// ** It determines if the current pre-update-hook change affects the same row +// ** as the change stored in argument pChange. If so, it returns true. Otherwise +// ** if the pre-update-hook does not affect the same row as pChange, it returns +// ** false. +// */ +func _sessionPreupdateEqual(tls *libc.TLS, pSession uintptr, iRowid Ti64, pTab uintptr, pChange uintptr, op int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a, z, v2 uintptr + var eType, iCol, iIdx, rc int32 + var _ /* iVal at bp+8 */ Ti64 + var _ /* n at bp+24 */ int32 + var _ /* pVal at bp+0 */ uintptr + var _ /* rVal at bp+16 */ float64 + _, _, _, _, _, _, _ = a, eType, iCol, iIdx, rc, z, v2 /* Used to iterate through columns */ + a = (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord /* Cursor used to scan change record */ + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a))) != int32(SQLITE_INTEGER) { + return 0 + } + return libc.BoolInt32(_sessionGetI64(tls, a+1) == iRowid) + } + iCol = 0 + for { + if !(iCol < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if !(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(iCol))) != 0) { + a = a + uintptr(_sessionSerialLen(tls, a)) + } else { + v2 = a + a = a + 1 /* Error code from preupdate_new/old */ + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v2))) /* Type of value from change record */ + iIdx = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(iCol)*4)) + /* The following calls to preupdate_new() and preupdate_old() can not + ** fail. This is because they cache their return values, and by the + ** time control flows to here they have already been called once from + ** within sessionPreupdateHash(). The first two asserts below verify + ** this (that the method has already been called). */ + if op == int32(SQLITE_INSERT) { + /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp) + } else { + /* assert( db->pPreUpdate->pUnpacked ); */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp) + } + _ = rc /* Suppress warning about unused variable */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp))) != eType { + return 0 + } + /* A SessionChange object never has a NULL value in a PK column */ + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + **(**Ti64)(__ccgo_up(bp + 8)) = _sessionGetI64(tls, a) + a = a + uintptr(8) + if eType == int32(SQLITE_INTEGER) { + if Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(bp))) != **(**Ti64)(__ccgo_up(bp + 8)) { + return 0 + } + } else { + libc.Xmemcpy(tls, bp+16, bp+8, uint64(8)) + if Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(bp))) != **(**float64)(__ccgo_up(bp + 16)) { + return 0 + } + } + } else { + a = a + uintptr(_sessionVarintGet(tls, a, bp+24)) + if Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(bp))) != **(**int32)(__ccgo_up(bp + 24)) { + return 0 + } + if eType == int32(SQLITE_TEXT) { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + z = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(bp))) + } + if **(**int32)(__ccgo_up(bp + 24)) > 0 && libc.Xmemcmp(tls, a, z, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 24)))) != 0 { + return 0 + } + a = a + uintptr(**(**int32)(__ccgo_up(bp + 24))) + } + } + goto _1 + _1: + ; + iCol = iCol + 1 + } + return int32(1) +} + +// C documentation +// +// /* +// ** This function may only be called from within a pre-update callback. +// ** It calculates a hash based on the primary key values of the old.* or +// ** new.* row currently available and, assuming no error occurs, writes it to +// ** *piHash before returning. If the primary key contains one or more NULL +// ** values, *pbNullPK is set to true before returning. +// ** +// ** If an error occurs, an SQLite error code is returned and the final values +// ** of *piHash asn *pbNullPK are undefined. Otherwise, SQLITE_OK is returned +// ** and the output variables are set as described above. +// */ +func _sessionPreupdateHash(tls *libc.TLS, pSession uintptr, iRowid Ti64, pTab uintptr, bNew int32, piHash uintptr, pbNullPK uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var eType, i, iIdx, n, rc int32 + var h uint32 + var z uintptr + var _ /* iVal at bp+8 */ Ti64 + var _ /* pVal at bp+0 */ uintptr + var _ /* rVal at bp+16 */ float64 + _, _, _, _, _, _, _ = eType, h, i, iIdx, n, rc, z + h = uint32(0) /* Used to iterate through columns */ + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + h = _sessionHashAppendI64(tls, h, iRowid) + } else { + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 { + iIdx = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(i)*4)) + if bNew != 0 { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp) + } else { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp) + } + if rc != SQLITE_OK { + return rc + } + eType = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp))) + h = _sessionHashAppendType(tls, h, eType) + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + if eType == int32(SQLITE_INTEGER) { + **(**Ti64)(__ccgo_up(bp + 8)) = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + **(**float64)(__ccgo_up(bp + 16)) = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(bp))) + libc.Xmemcpy(tls, bp+8, bp+16, uint64(8)) + } + h = _sessionHashAppendI64(tls, h, **(**Ti64)(__ccgo_up(bp + 8))) + } else { + if eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB) { + if eType == int32(SQLITE_TEXT) { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + z = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(bp))) + } + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(bp))) + if !(z != 0) && (eType != int32(SQLITE_BLOB) || n > 0) { + return int32(SQLITE_NOMEM) + } + h = _sessionHashAppendBlob(tls, h, n, z) + } else { + **(**int32)(__ccgo_up(pbNullPK)) = int32(1) + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + **(**int32)(__ccgo_up(piHash)) = libc.Int32FromUint32(h % libc.Uint32FromInt32((*TSessionTable)(unsafe.Pointer(pTab)).FnChange)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Write a double value to the buffer aBuf[]. +// */ +func _sessionPutDouble(tls *libc.TLS, aBuf uintptr, _r float64) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*float64)(unsafe.Pointer(bp)) = _r + var _ /* i at bp+8 */ Tu64 + libc.Xmemcpy(tls, bp+8, bp, uint64(8)) + _sessionPutI64(tls, aBuf, libc.Int64FromUint64(**(**Tu64)(__ccgo_up(bp + 8)))) +} + +// C documentation +// +// /* +// ** Deserialize a single record from a buffer in memory. See "RECORD FORMAT" +// ** for details. +// ** +// ** When this function is called, *paChange points to the start of the record +// ** to deserialize. Assuming no error occurs, *paChange is set to point to +// ** one byte after the end of the same record before this function returns. +// ** If the argument abPK is NULL, then the record contains nCol values. Or, +// ** if abPK is other than NULL, then the record contains only the PK fields +// ** (in other words, it is a patchset DELETE record). +// ** +// ** If successful, each element of the apOut[] array (allocated by the caller) +// ** is set to point to an sqlite3_value object containing the value read +// ** from the corresponding position in the record. If that value is not +// ** included in the record (i.e. because the record is part of an UPDATE change +// ** and the field was not modified), the corresponding element of apOut[] is +// ** set to NULL. +// ** +// ** It is the responsibility of the caller to free all sqlite_value structures +// ** using sqlite3_free(). +// ** +// ** If an error occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned. +// ** The apOut[] array may have been partially populated in this case. +// */ +func _sessionReadRecord(tls *libc.TLS, pIn uintptr, nCol int32, abPK uintptr, apOut uintptr, pbEmpty uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aVal, v3 uintptr + var eType, i, nRem, rc, v2 int32 + var enc Tu8 + var _ /* d at bp+16 */ float64 + var _ /* nByte at bp+0 */ int32 + var _ /* v at bp+8 */ Tsqlite3_int64 + _, _, _, _, _, _, _, _ = aVal, eType, enc, i, nRem, rc, v2, v3 /* Used to iterate through columns */ + rc = SQLITE_OK + if pbEmpty != 0 { + **(**int32)(__ccgo_up(pbEmpty)) = int32(1) + } + i = 0 + for { + if !(i < nCol && rc == SQLITE_OK) { + break + } + eType = 0 /* Type of value (SQLITE_NULL, TEXT etc.) */ + if abPK != 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(abPK + uintptr(i)))) == 0 { + goto _1 + } + rc = _sessionInputBuffer(tls, pIn, int32(9)) + if rc == SQLITE_OK { + if (*TSessionInput)(unsafe.Pointer(pIn)).FiNext >= (*TSessionInput)(unsafe.Pointer(pIn)).FnData { + rc = _sqlite3CorruptError(tls, int32(237090)) + } else { + v3 = pIn + 8 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pIn)).FaData + uintptr(v2)))) + if eType != 0 { + if pbEmpty != 0 { + **(**int32)(__ccgo_up(pbEmpty)) = 0 + } + **(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)) = _sqlite3ValueNew(tls, uintptr(0)) + if !(**(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)) != 0) { + rc = int32(SQLITE_NOMEM) + } + } + } + } + if rc == SQLITE_OK { + aVal = (*TSessionInput)(unsafe.Pointer(pIn)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiNext) + if eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB) { + nRem = (*TSessionInput)(unsafe.Pointer(pIn)).FnData - (*TSessionInput)(unsafe.Pointer(pIn)).FiNext + **(**int32)(__ccgo_up(pIn + 8)) += _sessionVarintGetSafe(tls, aVal, nRem, bp) + rc = _sessionInputBuffer(tls, pIn, **(**int32)(__ccgo_up(bp))) + if rc == SQLITE_OK { + if **(**int32)(__ccgo_up(bp)) < 0 || **(**int32)(__ccgo_up(bp)) > (*TSessionInput)(unsafe.Pointer(pIn)).FnData-(*TSessionInput)(unsafe.Pointer(pIn)).FiNext { + rc = _sqlite3CorruptError(tls, int32(237111)) + } else { + if eType == int32(SQLITE_TEXT) { + v2 = int32(SQLITE_UTF8) + } else { + v2 = 0 + } + enc = libc.Uint8FromInt32(v2) + rc = _sessionValueSetStr(tls, **(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)), (*TSessionInput)(unsafe.Pointer(pIn)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiNext), **(**int32)(__ccgo_up(bp)), enc) + **(**int32)(__ccgo_up(pIn + 8)) += **(**int32)(__ccgo_up(bp)) + } + } + } + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + if (*TSessionInput)(unsafe.Pointer(pIn)).FnData-(*TSessionInput)(unsafe.Pointer(pIn)).FiNext < int32(8) { + rc = _sqlite3CorruptError(tls, int32(237121)) + } else { + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = _sessionGetI64(tls, aVal) + if eType == int32(SQLITE_INTEGER) { + _sqlite3VdbeMemSetInt64(tls, **(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)), **(**Tsqlite3_int64)(__ccgo_up(bp + 8))) + } else { + libc.Xmemcpy(tls, bp+16, bp+8, uint64(8)) + _sqlite3VdbeMemSetDouble(tls, **(**uintptr)(__ccgo_up(apOut + uintptr(i)*8)), **(**float64)(__ccgo_up(bp + 16))) + } + **(**int32)(__ccgo_up(pIn + 8)) += int32(8) + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +// C documentation +// +// /* +// ** pIter is configured to iterate through a changeset. This function rebases +// ** that changeset according to the current configuration of the rebaser +// ** object passed as the first argument. If no error occurs and argument xOutput +// ** is not NULL, then the changeset is returned to the caller by invoking +// ** xOutput zero or more times and SQLITE_OK returned. Or, if xOutput is NULL, +// ** then (*ppOut) is set to point to a buffer containing the rebased changeset +// ** before this function returns. In this case (*pnOut) is set to the size of +// ** the buffer in bytes. It is the responsibility of the caller to eventually +// ** free the (*ppOut) buffer using sqlite3_free(). +// ** +// ** If an error occurs, an SQLite error code is returned. If ppOut and +// ** pnOut are not NULL, then the two output parameters are set to 0 before +// ** returning. +// */ +func _sessionRebase(tls *libc.TLS, p uintptr, pIter uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr, pnOut uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bDone, iHash, v2 int32 + var pChange, pTab, zTab uintptr + var _ /* aRec at bp+8 */ uintptr + var _ /* bNew at bp+20 */ int32 + var _ /* nRec at bp+16 */ int32 + var _ /* pCsr at bp+40 */ uintptr + var _ /* rc at bp+0 */ int32 + var _ /* sOut at bp+24 */ TSessionBuffer + _, _, _, _, _, _ = bDone, iHash, pChange, pTab, zTab, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 16)) = 0 + **(**int32)(__ccgo_up(bp + 20)) = 0 + pTab = uintptr(0) + **(**TSessionBuffer)(__ccgo_up(bp + 24)) = TSessionBuffer{} + for int32(SQLITE_ROW) == _sessionChangesetNext(tls, pIter, bp+8, bp+16, bp+20) { + pChange = uintptr(0) + bDone = 0 + if **(**int32)(__ccgo_up(bp + 20)) != 0 { + zTab = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab + pTab = (*Tsqlite3_rebaser)(unsafe.Pointer(p)).Fgrp.FpList + for { + if !(pTab != 0) { + break + } + if 0 == Xsqlite3_stricmp(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zTab) { + break + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + **(**int32)(__ccgo_up(bp + 20)) = 0 + /* A patchset may not be rebased */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* Append a table header to the output for this new table */ + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 { + v2 = int32('P') + } else { + v2 = int32('T') + } + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32(v2), bp) + _sessionAppendVarint(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, bp) + _sessionAppendBlob(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, bp) + _sessionAppendBlob(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, libc.Int32FromUint64(libc.Xstrlen(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab))+int32(1), bp) + } + if pTab != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + iHash = libc.Int32FromUint32(_sessionChangeHash(tls, pTab, 0, **(**uintptr)(__ccgo_up(bp + 8)), (*TSessionTable)(unsafe.Pointer(pTab)).FnChange)) + pChange = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*8)) + for { + if !(pChange != 0) { + break + } + if _sessionChangeEqual(tls, pTab, 0, **(**uintptr)(__ccgo_up(bp + 8)), 0, (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord) != 0 { + break + } + goto _3 + _3: + ; + pChange = (*TSessionChange)(unsafe.Pointer(pChange)).FpNext + } + } + if pChange != 0 { + switch (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop { + case int32(SQLITE_INSERT): + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).Fop) == int32(SQLITE_INSERT) { + bDone = int32(1) + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).FbIndirect) == 0 { + _sessionAppendByte(tls, bp+24, uint8(SQLITE_UPDATE), bp) + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp) + _sessionAppendBlob(tls, bp+24, (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord, (*TSessionChange)(unsafe.Pointer(pChange)).FnRecord, bp) + _sessionAppendBlob(tls, bp+24, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), bp) + } + } + case int32(SQLITE_UPDATE): + bDone = int32(1) + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).Fop) == int32(SQLITE_DELETE) { + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).FbIndirect) == 0 { + **(**uintptr)(__ccgo_up(bp + 40)) = **(**uintptr)(__ccgo_up(bp + 8)) + _sessionSkipRecord(tls, bp+40, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol) + _sessionAppendByte(tls, bp+24, uint8(SQLITE_INSERT), bp) + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp) + _sessionAppendRecordMerge(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, **(**uintptr)(__ccgo_up(bp + 40)), int32(int64(**(**int32)(__ccgo_up(bp + 16)))-(int64(**(**uintptr)(__ccgo_up(bp + 40)))-int64(**(**uintptr)(__ccgo_up(bp + 8))))), (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord, (*TSessionChange)(unsafe.Pointer(pChange)).FnRecord, bp) + } + } else { + _sessionAppendPartialUpdate(tls, bp+24, pIter, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord, (*TSessionChange)(unsafe.Pointer(pChange)).FnRecord, bp) + } + default: + bDone = int32(1) + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pChange)).Fop) == int32(SQLITE_INSERT) { + _sessionAppendByte(tls, bp+24, uint8(SQLITE_DELETE), bp) + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp) + _sessionAppendRecordMerge(tls, bp+24, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord, (*TSessionChange)(unsafe.Pointer(pChange)).FnRecord, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), bp) + } + break + } + } + if bDone == 0 { + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop), bp) + _sessionAppendByte(tls, bp+24, libc.Uint8FromInt32((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp) + _sessionAppendBlob(tls, bp+24, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), bp) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && __ccgo_fp_xOutput != 0 && (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf > _sessions_strm_chunk_size { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf) + (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf = 0 + } + if **(**int32)(__ccgo_up(bp)) != 0 { + break + } + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf) + libc.Xmemset(tls, bp+24, 0, uint64(16)) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if __ccgo_fp_xOutput != 0 { + if (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf > 0 { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf) + } + } else { + if ppOut != 0 { + **(**uintptr)(__ccgo_up(ppOut)) = (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf + **(**int32)(__ccgo_up(pnOut)) = (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FnBuf + (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf = uintptr(0) + } + } + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 24))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Create an iterator to iterate through the retry buffer pRetry. +// */ +func _sessionRetryIterInit(tls *libc.TLS, pRetry uintptr, bPatchset int32, zTab uintptr, pApply uintptr, ppIter uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nByte Tsize_t + var _ /* pRet at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _ = nByte + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 8)) = _sessionChangesetStart(tls, bp, uintptr(0), uintptr(0), (*TSessionBuffer)(unsafe.Pointer(pRetry)).FnBuf, (*TSessionBuffer)(unsafe.Pointer(pRetry)).FaBuf, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FbInvertConstraints, int32(1)) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + nByte = libc.Uint64FromInt32(int32(2)*(*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol) * uint64(8) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FbPatchset = bPatchset + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzTab = zTab + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnCol = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FabPK = (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK + _sessionBufferGrow(tls, **(**uintptr)(__ccgo_up(bp))+72, libc.Int64FromUint64(nByte), bp+8) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FapValue = (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ftblhdr.FaBuf + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + libc.Xmemset(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FapValue, 0, nByte) + } else { + Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + **(**uintptr)(__ccgo_up(ppIter)) = **(**uintptr)(__ccgo_up(bp)) + return **(**int32)(__ccgo_up(bp + 8)) +} + +// C documentation +// +// /* +// ** Bind the PRIMARY KEY values from the change passed in argument pChange +// ** to the SELECT statement passed as the first argument. The SELECT statement +// ** is as prepared by function sessionSelectStmt(). +// ** +// ** Return SQLITE_OK if all PK values are successfully bound, or an SQLite +// ** error code (e.g. SQLITE_NOMEM) otherwise. +// */ +func _sessionSelectBind(tls *libc.TLS, pSelect uintptr, nCol int32, abPK uintptr, pChange uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a, v2 uintptr + var eType, i, rc int32 + var iVal Ti64 + var _ /* iVal at bp+8 */ Ti64 + var _ /* n at bp+16 */ int32 + var _ /* n at bp+20 */ int32 + var _ /* rVal at bp+0 */ float64 + _, _, _, _, _, _ = a, eType, i, iVal, rc, v2 + rc = SQLITE_OK + a = (*TSessionChange)(unsafe.Pointer(pChange)).FaRecord + i = 0 + for { + if !(i < nCol && rc == SQLITE_OK) { + break + } + v2 = a + a = a + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v2))) + switch eType { + case 0: + fallthrough + case int32(SQLITE_NULL): + case int32(SQLITE_INTEGER): + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + iVal = _sessionGetI64(tls, a) + rc = Xsqlite3_bind_int64(tls, pSelect, i+int32(1), iVal) + } + a = a + uintptr(8) + case int32(SQLITE_FLOAT): + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + **(**Ti64)(__ccgo_up(bp + 8)) = _sessionGetI64(tls, a) + libc.Xmemcpy(tls, bp, bp+8, uint64(8)) + rc = Xsqlite3_bind_double(tls, pSelect, i+int32(1), **(**float64)(__ccgo_up(bp))) + } + a = a + uintptr(8) + case int32(SQLITE_TEXT): + a = a + uintptr(_sessionVarintGet(tls, a, bp+16)) + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + rc = Xsqlite3_bind_text(tls, pSelect, i+int32(1), a, **(**int32)(__ccgo_up(bp + 16)), uintptr(-libc.Int32FromInt32(1))) + } + a = a + uintptr(**(**int32)(__ccgo_up(bp + 16))) + default: + a = a + uintptr(_sessionVarintGet(tls, a, bp+20)) + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + rc = Xsqlite3_bind_blob(tls, pSelect, i+int32(1), a, **(**int32)(__ccgo_up(bp + 20)), uintptr(-libc.Int32FromInt32(1))) + } + a = a + uintptr(**(**int32)(__ccgo_up(bp + 20))) + break + } + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +// C documentation +// +// /* +// ** This function is used to serialize the contents of value pValue (see +// ** comment titled "RECORD FORMAT" above). +// ** +// ** If it is non-NULL, the serialized form of the value is written to +// ** buffer aBuf. *pnWrite is set to the number of bytes written before +// ** returning. Or, if aBuf is NULL, the only thing this function does is +// ** set *pnWrite. +// ** +// ** If no error occurs, SQLITE_OK is returned. Or, if an OOM error occurs +// ** within a call to sqlite3_value_text() (may fail if the db is utf-16)) +// ** SQLITE_NOMEM is returned. +// */ +func _sessionSerializeValue(tls *libc.TLS, aBuf uintptr, pValue uintptr, pnWrite uintptr) (r1 int32) { + var eType, n, nByte, nVarint int32 + var i Tu64 + var r float64 + var z uintptr + _, _, _, _, _, _, _ = eType, i, n, nByte, nVarint, r, z /* Size of serialized value in bytes */ + if pValue != 0 { /* Value type (SQLITE_NULL, TEXT etc.) */ + eType = Xsqlite3_value_type(tls, pValue) + if aBuf != 0 { + **(**Tu8)(__ccgo_up(aBuf)) = libc.Uint8FromInt32(eType) + } + switch eType { + case int32(SQLITE_NULL): + nByte = int32(1) + case int32(SQLITE_INTEGER): + fallthrough + case int32(SQLITE_FLOAT): + if aBuf != 0 { + /* TODO: SQLite does something special to deal with mixed-endian + ** floating point values (e.g. ARM7). This code probably should + ** too. */ + if eType == int32(SQLITE_INTEGER) { + i = libc.Uint64FromInt64(Xsqlite3_value_int64(tls, pValue)) + _sessionPutI64(tls, aBuf+1, libc.Int64FromUint64(i)) + } else { + r = Xsqlite3_value_double(tls, pValue) + _sessionPutDouble(tls, aBuf+1, r) + } + } + nByte = int32(9) + default: + if eType == int32(SQLITE_TEXT) { + z = Xsqlite3_value_text(tls, pValue) + } else { + z = Xsqlite3_value_blob(tls, pValue) + } + n = Xsqlite3_value_bytes(tls, pValue) + if z == uintptr(0) && (eType != int32(SQLITE_BLOB) || n > 0) { + return int32(SQLITE_NOMEM) + } + nVarint = _sessionVarintLen(tls, n) + if aBuf != 0 { + _sessionVarintPut(tls, aBuf+1, n) + if n > 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nVarint+int32(1)), z, libc.Uint64FromInt32(n)) + } + } + nByte = int32(1) + nVarint + n + break + } + } else { + nByte = int32(1) + if aBuf != 0 { + **(**Tu8)(__ccgo_up(aBuf)) = uint8('\000') + } + } + if pnWrite != 0 { + **(**Tsqlite3_int64)(__ccgo_up(pnWrite)) += int64(nByte) + } + return SQLITE_OK +} + +func _sessionUpdateMaxSize(tls *libc.TLS, op int32, pSession uintptr, pTab uintptr, pC uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bChanged, eType, iIdx, ii, ii1, nIncr, nOld int32 + var pCsr, v3 uintptr + var _ /* dVal at bp+32 */ float64 + var _ /* iVal at bp+24 */ Tsqlite3_int64 + var _ /* nByte at bp+40 */ int32 + var _ /* nNew at bp+0 */ Ti64 + var _ /* p at bp+16 */ uintptr + var _ /* p at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _ = bChanged, eType, iIdx, ii, ii1, nIncr, nOld, pCsr, v3 + **(**Ti64)(__ccgo_up(bp)) = int64(2) + if libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(pC)).Fop) == int32(SQLITE_INSERT) { + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(9) + } + if op != int32(SQLITE_DELETE) { + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(ii)*4)), bp+8) + _sessionSerializeValue(tls, uintptr(0), **(**uintptr)(__ccgo_up(bp + 8)), bp) + goto _1 + _1: + ; + ii = ii + 1 + } + } + } else { + if op == int32(SQLITE_DELETE) { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64((*TSessionChange)(unsafe.Pointer(pC)).FnRecord) + if Xsqlite3_preupdate_blobwrite(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb) >= 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64((*TSessionChange)(unsafe.Pointer(pC)).FnRecord) + } + } else { + pCsr = (*TSessionChange)(unsafe.Pointer(pC)).FaRecord + if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(libc.Int32FromInt32(9)+libc.Int32FromInt32(1)) + pCsr = pCsr + uintptr(9) + } + ii1 = (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid + for { + if !(ii1 < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + bChanged = int32(1) + nOld = 0 + iIdx = **(**int32)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx + uintptr(ii1)*4)) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iIdx, bp+16) + if **(**uintptr)(__ccgo_up(bp + 16)) == uintptr(0) { + return int32(SQLITE_NOMEM) + } + v3 = pCsr + pCsr = pCsr + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v3))) + switch eType { + case int32(SQLITE_NULL): + bChanged = libc.BoolInt32(Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 16))) != int32(SQLITE_NULL)) + case int32(SQLITE_FLOAT): + fallthrough + case int32(SQLITE_INTEGER): + if eType == Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 16))) { + **(**Tsqlite3_int64)(__ccgo_up(bp + 24)) = _sessionGetI64(tls, pCsr) + if eType == int32(SQLITE_INTEGER) { + bChanged = libc.BoolInt32(**(**Tsqlite3_int64)(__ccgo_up(bp + 24)) != Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(bp + 16)))) + } else { + libc.Xmemcpy(tls, bp+32, bp+24, uint64(8)) + bChanged = libc.BoolInt32(**(**float64)(__ccgo_up(bp + 32)) != Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(bp + 16)))) + } + } + nOld = int32(8) + pCsr = pCsr + uintptr(8) + default: + nOld = _sessionVarintGet(tls, pCsr, bp+40) + pCsr = pCsr + uintptr(nOld) + nOld = nOld + **(**int32)(__ccgo_up(bp + 40)) + if eType == Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 16))) && **(**int32)(__ccgo_up(bp + 40)) == Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(bp + 16))) && (**(**int32)(__ccgo_up(bp + 40)) == 0 || 0 == libc.Xmemcmp(tls, pCsr, Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(bp + 16))), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp + 40))))) { + bChanged = 0 + } + pCsr = pCsr + uintptr(**(**int32)(__ccgo_up(bp + 40))) + break + } + if bChanged != 0 && **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(ii1))) != 0 { + **(**Ti64)(__ccgo_up(bp)) = int64((*TSessionChange)(unsafe.Pointer(pC)).FnRecord + int32(2)) + break + } + if bChanged != 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(int32(1)+nOld) + _sessionSerializeValue(tls, uintptr(0), **(**uintptr)(__ccgo_up(bp + 16)), bp) + } else { + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(ii1))) != 0 { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(int32(2)+nOld) + } else { + **(**Ti64)(__ccgo_up(bp)) = **(**Ti64)(__ccgo_up(bp)) + int64(2) + } + } + goto _2 + _2: + ; + ii1 = ii1 + 1 + } + } + } + if **(**Ti64)(__ccgo_up(bp)) > int64((*TSessionChange)(unsafe.Pointer(pC)).FnMaxSize) { + nIncr = int32(**(**Ti64)(__ccgo_up(bp)) - int64((*TSessionChange)(unsafe.Pointer(pC)).FnMaxSize)) + (*TSessionChange)(unsafe.Pointer(pC)).FnMaxSize = int32(**(**Ti64)(__ccgo_up(bp))) + **(**Ti64)(__ccgo_up(pSession + 64)) += int64(nIncr) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Session-change object (*pp) contains an old.* record with fewer than +// ** nCol fields. This function updates it with the default values for +// ** the missing fields. +// */ +func _sessionUpdateOneChange(tls *libc.TLS, pSession uintptr, pRc uintptr, pp uintptr, nCol int32, pDflt uintptr) { + var eType, iField, n, n1, n2, nByte, nIncr, v1 int32 + var iVal Ti64 + var pNew, pOld, z, z1, v2 uintptr + var rVal float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = eType, iField, iVal, n, n1, n2, nByte, nIncr, pNew, pOld, rVal, z, z1, v1, v2 + pOld = **(**uintptr)(__ccgo_up(pp)) + for libc.Int32FromUint16((*TSessionChange)(unsafe.Pointer(pOld)).FnRecordField) < nCol { + pNew = uintptr(0) + nByte = 0 + nIncr = 0 + iField = libc.Int32FromUint16((*TSessionChange)(unsafe.Pointer(pOld)).FnRecordField) + eType = Xsqlite3_column_type(tls, pDflt, iField) + switch eType { + case int32(SQLITE_NULL): + nIncr = int32(1) + case int32(SQLITE_INTEGER): + fallthrough + case int32(SQLITE_FLOAT): + nIncr = int32(9) + default: + n = Xsqlite3_column_bytes(tls, pDflt, iField) + nIncr = int32(1) + _sessionVarintLen(tls, n) + n + break + } + nByte = libc.Int32FromUint64(libc.Uint64FromInt32(nIncr) + (uint64(32) + libc.Uint64FromInt32((*TSessionChange)(unsafe.Pointer(pOld)).FnRecord))) + pNew = _sessionMalloc64(tls, pSession, int64(nByte)) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + return + } else { + libc.Xmemcpy(tls, pNew, pOld, uint64(32)) + (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord = pNew + 1*32 + libc.Xmemcpy(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord, (*TSessionChange)(unsafe.Pointer(pOld)).FaRecord, libc.Uint64FromInt32((*TSessionChange)(unsafe.Pointer(pOld)).FnRecord)) + v2 = pNew + 8 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TSessionChange)(unsafe.Pointer(pNew)).FaRecord + uintptr(v1))) = libc.Uint8FromInt32(eType) + switch eType { + case int32(SQLITE_INTEGER): + iVal = Xsqlite3_column_int64(tls, pDflt, iField) + _sessionPutI64(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), iVal) + **(**int32)(__ccgo_up(pNew + 8)) += int32(8) + case int32(SQLITE_FLOAT): + rVal = Xsqlite3_column_double(tls, pDflt, iField) + _sessionPutDouble(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), rVal) + **(**int32)(__ccgo_up(pNew + 8)) += int32(8) + case int32(SQLITE_TEXT): + n1 = Xsqlite3_column_bytes(tls, pDflt, iField) + z = Xsqlite3_column_text(tls, pDflt, iField) + **(**int32)(__ccgo_up(pNew + 8)) += _sessionVarintPut(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), n1) + libc.Xmemcpy(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), z, libc.Uint64FromInt32(n1)) + **(**int32)(__ccgo_up(pNew + 8)) += n1 + case int32(SQLITE_BLOB): + n2 = Xsqlite3_column_bytes(tls, pDflt, iField) + z1 = Xsqlite3_column_blob(tls, pDflt, iField) + **(**int32)(__ccgo_up(pNew + 8)) += _sessionVarintPut(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), n2) + libc.Xmemcpy(tls, (*TSessionChange)(unsafe.Pointer(pNew)).FaRecord+uintptr((*TSessionChange)(unsafe.Pointer(pNew)).FnRecord), z1, libc.Uint64FromInt32(n2)) + **(**int32)(__ccgo_up(pNew + 8)) += n2 + default: + break + } + _sessionFree(tls, pSession, pOld) + v2 = pNew + pOld = v2 + **(**uintptr)(__ccgo_up(pp)) = v2 + (*TSessionChange)(unsafe.Pointer(pNew)).FnRecordField = (*TSessionChange)(unsafe.Pointer(pNew)).FnRecordField + 1 + **(**int32)(__ccgo_up(pNew + 4)) += nIncr + if pSession != 0 { + **(**Ti64)(__ccgo_up(pSession + 64)) += int64(nIncr) + } + } + } +} + +// C documentation +// +// /* +// ** This function sets the value of the sqlite3_value object passed as the +// ** first argument to a copy of the string or blob held in the aData[] +// ** buffer. SQLITE_OK is returned if successful, or SQLITE_NOMEM if an OOM +// ** error occurs. +// */ +func _sessionValueSetStr(tls *libc.TLS, pVal uintptr, aData uintptr, nData int32, enc Tu8) (r int32) { + var aCopy uintptr + _ = aCopy + /* In theory this code could just pass SQLITE_TRANSIENT as the final + ** argument to sqlite3ValueSetStr() and have the copy created + ** automatically. But doing so makes it difficult to detect any OOM + ** error. Hence the code to create the copy externally. */ + aCopy = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64(nData)+int64(1))) + if aCopy == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, aCopy, aData, libc.Uint64FromInt32(nData)) + _sqlite3ValueSetStr(tls, pVal, nData, aCopy, enc, __ccgo_fp(Xsqlite3_free)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Read a varint value from buffer aBuf[], size nBuf bytes, into *piVal. +// ** Return the number of bytes read. +// */ +func _sessionVarintGetSafe(tls *libc.TLS, aBuf uintptr, nBuf int32, piVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aRead uintptr + var v1 int32 + var _ /* aCopy at bp+0 */ [9]Tu8 + _, _ = aRead, v1 + aRead = aBuf + libc.Xmemset(tls, bp, 0, uint64(9)) + if libc.Uint64FromInt32(nBuf) < uint64(9) { + libc.Xmemcpy(tls, bp, aBuf, libc.Uint64FromInt32(nBuf)) + aRead = bp + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aRead))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**int32)(__ccgo_up(piVal)) = libc.Int32FromUint32(uint32(**(**Tu8)(__ccgo_up(aRead)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aRead, piVal)) + } + return libc.Int32FromUint8(libc.Uint8FromInt32(v1)) +} + +/* Load an unaligned and unsigned 32-bit integer */ + +// C documentation +// +// /* +// ** Implementation of the R*-tree variant of SplitNode from Beckman[1990]. +// */ +func _splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32, pLeft uintptr, pRight uintptr, pBboxLeft uintptr, pBboxRight uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var aSpare, aaSorted, pBbox, pCell, pTarget, v7, v8 uintptr + var area, fBestArea, fBestMargin, fBestOverlap, margin, overlap TRtreeDValue + var iBestDim, iBestLeft, iBestSplit, ii, jj, kk, nLeft int32 + var nByte Tsqlite3_int64 + var _ /* left at bp+0 */ TRtreeCell + var _ /* right at bp+48 */ TRtreeCell + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aSpare, aaSorted, area, fBestArea, fBestMargin, fBestOverlap, iBestDim, iBestLeft, iBestSplit, ii, jj, kk, margin, nByte, nLeft, overlap, pBbox, pCell, pTarget, v7, v8 + iBestDim = 0 + iBestSplit = 0 + fBestMargin = float64(0) + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim)+libc.Int32FromInt32(1)) * (uint64(8) + libc.Uint64FromInt32(nCell)*uint64(4))) + aaSorted = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if !(aaSorted != 0) { + return int32(SQLITE_NOMEM) + } + aSpare = aaSorted + uintptr((*TRtree)(unsafe.Pointer(pRtree)).FnDim)*8 + uintptr(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim)*nCell)*4 + libc.Xmemset(tls, aaSorted, 0, libc.Uint64FromInt64(nByte)) + ii = 0 + for { + if !(ii < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim)) { + break + } + **(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) = aaSorted + uintptr((*TRtree)(unsafe.Pointer(pRtree)).FnDim)*8 + uintptr(ii*nCell)*4 + jj = 0 + for { + if !(jj < nCell) { + break + } + **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) + uintptr(jj)*4)) = jj + goto _2 + _2: + ; + jj = jj + 1 + } + _SortByDimension(tls, pRtree, **(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)), nCell, ii, aCell, aSpare) + goto _1 + _1: + ; + ii = ii + 1 + } + ii = 0 + for { + if !(ii < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim)) { + break + } + margin = float64(0) + fBestOverlap = float64(0) + fBestArea = float64(0) + iBestLeft = 0 + nLeft = ((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize - int32(4)) / libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) / int32(3) + for { + if !(nLeft <= nCell-((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize-int32(4))/libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/int32(3)) { + break + } + libc.Xmemcpy(tls, bp, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)))))*48, uint64(48)) + libc.Xmemcpy(tls, bp+48, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) + uintptr(nCell-int32(1))*4)))*48, uint64(48)) + kk = int32(1) + for { + if !(kk < nCell-int32(1)) { + break + } + if kk < nLeft { + _cellUnion(tls, pRtree, bp, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) + uintptr(kk)*4)))*48) + } else { + _cellUnion(tls, pRtree, bp+48, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(ii)*8)) + uintptr(kk)*4)))*48) + } + goto _5 + _5: + ; + kk = kk + 1 + } + margin = margin + _cellMargin(tls, pRtree, bp) + margin = margin + _cellMargin(tls, pRtree, bp+48) + overlap = _cellOverlap(tls, pRtree, bp, bp+48, int32(1)) + area = _cellArea(tls, pRtree, bp) + _cellArea(tls, pRtree, bp+48) + if nLeft == ((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize-int32(4))/libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/int32(3) || overlap < fBestOverlap || overlap == fBestOverlap && area < fBestArea { + iBestLeft = nLeft + fBestOverlap = overlap + fBestArea = area + } + goto _4 + _4: + ; + nLeft = nLeft + 1 + } + if ii == 0 || margin < fBestMargin { + iBestDim = ii + fBestMargin = margin + iBestSplit = iBestLeft + } + goto _3 + _3: + ; + ii = ii + 1 + } + libc.Xmemcpy(tls, pBboxLeft, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(iBestDim)*8)))))*48, uint64(48)) + libc.Xmemcpy(tls, pBboxRight, aCell+uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(iBestDim)*8)) + uintptr(iBestSplit)*4)))*48, uint64(48)) + ii = 0 + for { + if !(ii < nCell) { + break + } + if ii < iBestSplit { + v7 = pLeft + } else { + v7 = pRight + } + pTarget = v7 + if ii < iBestSplit { + v8 = pBboxLeft + } else { + v8 = pBboxRight + } + pBbox = v8 + pCell = aCell + uintptr(**(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(aaSorted + uintptr(iBestDim)*8)) + uintptr(ii)*4)))*48 + _nodeInsertCell(tls, pRtree, pTarget, pCell) + _cellUnion(tls, pRtree, pBbox, pCell) + goto _6 + _6: + ; + ii = ii + 1 + } + Xsqlite3_free(tls, aaSorted) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** pArray is a pointer to an array of objects. Each object in the +// ** array is szEntry bytes in size. This routine uses sqlite3DbRealloc() +// ** to extend the array so that there is space for a new object at the end. +// ** +// ** When this function is called, *pnEntry contains the current size of +// ** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes +// ** in total). +// ** +// ** If the realloc() is successful (i.e. if no OOM condition occurs), the +// ** space allocated for the new object is zeroed, *pnEntry updated to +// ** reflect the new size of the array and a pointer to the new allocation +// ** returned. *pIdx is set to the index of the new array entry in this case. +// ** +// ** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains +// ** unchanged and a copy of pArray returned. +// */ +func _sqlite3ArrayAllocate(tls *libc.TLS, db uintptr, pArray uintptr, szEntry int32, pnEntry uintptr, pIdx uintptr) (r uintptr) { + var n, sz Tsqlite3_int64 + var pNew, z uintptr + var v1 int32 + var v2 int64 + _, _, _, _, _, _ = n, pNew, sz, z, v1, v2 + v1 = **(**int32)(__ccgo_up(pnEntry)) + **(**int32)(__ccgo_up(pIdx)) = v1 + n = int64(v1) + if n&(n-int64(1)) == 0 { + if n == 0 { + v2 = int64(1) + } else { + v2 = int64(2) * n + } + sz = v2 + pNew = _sqlite3DbRealloc(tls, db, pArray, libc.Uint64FromInt64(sz*int64(szEntry))) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(pIdx)) = -int32(1) + return pArray + } + pArray = pNew + } + z = pArray + libc.Xmemset(tls, z+uintptr(n*int64(szEntry)), 0, libc.Uint64FromInt32(szEntry)) + **(**int32)(__ccgo_up(pnEntry)) = **(**int32)(__ccgo_up(pnEntry)) + 1 + return pArray +} + +// C documentation +// +// /* +// ** Clear the i-th bit. +// ** +// ** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage +// ** that BitvecClear can use to rebuilt its hash table. +// */ +func _sqlite3BitvecClear(tls *libc.TLS, p uintptr, i Tu32, pBuf uintptr) { + var aiValues, v1 uintptr + var bin, h Tu32 + var j uint32 + _, _, _, _, _ = aiValues, bin, h, j, v1 + if p == uintptr(0) { + return + } + i = i - 1 + for (*TBitvec)(unsafe.Pointer(p)).FiDivisor != 0 { + bin = i / (*TBitvec)(unsafe.Pointer(p)).FiDivisor + i = i % (*TBitvec)(unsafe.Pointer(p)).FiDivisor + p = **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) + if !(p != 0) { + return + } + } + if uint64((*TBitvec)(unsafe.Pointer(p)).FiSize) <= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) { + v1 = p + 16 + uintptr(i/uint32(BITVEC_SZELEM)) + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromUint8(libc.Uint8FromInt32(libc.Int32FromInt32(1)<<(i&libc.Uint32FromInt32(libc.Int32FromInt32(BITVEC_SZELEM)-libc.Int32FromInt32(1)))))) + } else { + aiValues = pBuf + libc.Xmemcpy(tls, aiValues, p+16, uint64(496)) + libc.Xmemset(tls, p+16, 0, uint64(496)) + (*TBitvec)(unsafe.Pointer(p)).FnSet = uint32(0) + j = uint32(0) + for { + if !(uint64(j) < (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)) { + break + } + if **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4)) != 0 && **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4)) != i+uint32(1) { + h = uint32(uint64((**(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4))-libc.Uint32FromInt32(1))*libc.Uint32FromInt32(1)) % ((libc.Uint64FromInt32(BITVEC_SZ) - libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4)) / libc.Uint64FromInt64(8) * libc.Uint64FromInt64(8) / libc.Uint64FromInt64(4))) + (*TBitvec)(unsafe.Pointer(p)).FnSet = (*TBitvec)(unsafe.Pointer(p)).FnSet + 1 + for **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) != 0 { + h = h + 1 + if uint64(h) >= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4) { + h = uint32(0) + } + } + **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) = **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4)) + } + goto _2 + _2: + ; + j = j + 1 + } + } +} + +// C documentation +// +// /* +// ** Set the i-th bit. Return 0 on success and an error code if +// ** anything goes wrong. +// ** +// ** This routine might cause sub-bitmaps to be allocated. Failing +// ** to get the memory needed to hold the sub-bitmap is the only +// ** that can go wrong with an insert, assuming p and i are valid. +// ** +// ** The calling function must ensure that p is a valid Bitvec object +// ** and that the value for "i" is within range of the Bitvec object. +// ** Otherwise the behavior is undefined. +// */ +func _sqlite3BitvecSet(tls *libc.TLS, p uintptr, i Tu32) (r int32) { + var aiValues, v1 uintptr + var bin, h, v2 Tu32 + var j uint32 + var rc int32 + _, _, _, _, _, _, _ = aiValues, bin, h, j, rc, v1, v2 + if p == uintptr(0) { + return SQLITE_OK + } + i = i - 1 + for uint64((*TBitvec)(unsafe.Pointer(p)).FiSize) > (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) && (*TBitvec)(unsafe.Pointer(p)).FiDivisor != 0 { + bin = i / (*TBitvec)(unsafe.Pointer(p)).FiDivisor + i = i % (*TBitvec)(unsafe.Pointer(p)).FiDivisor + if **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) == uintptr(0) { + **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) = _sqlite3BitvecCreate(tls, (*TBitvec)(unsafe.Pointer(p)).FiDivisor) + if **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) == uintptr(0) { + return int32(SQLITE_NOMEM) + } + } + p = **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) + } + if uint64((*TBitvec)(unsafe.Pointer(p)).FiSize) <= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) { + v1 = p + 16 + uintptr(i/uint32(BITVEC_SZELEM)) + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(1)<<(i&libc.Uint32FromInt32(libc.Int32FromInt32(BITVEC_SZELEM)-libc.Int32FromInt32(1)))) + return SQLITE_OK + } + v2 = i + i = i + 1 + h = uint32(uint64(v2*libc.Uint32FromInt32(1)) % ((libc.Uint64FromInt32(BITVEC_SZ) - libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4)) / libc.Uint64FromInt64(8) * libc.Uint64FromInt64(8) / libc.Uint64FromInt64(4))) + /* if there wasn't a hash collision, and this doesn't */ + /* completely fill the hash, then just add it without */ + /* worrying about sub-dividing and re-hashing. */ + if !(**(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) != 0) { + if uint64((*TBitvec)(unsafe.Pointer(p)).FnSet) < (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)-libc.Uint64FromInt32(1) { + goto bitvec_set_end + } else { + goto bitvec_set_rehash + } + } + /* there was a collision, check to see if it's already */ + /* in hash, if not, try to find a spot for it */ + for cond := true; cond; cond = **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) != 0 { + if **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) == i { + return SQLITE_OK + } + h = h + 1 + if uint64(h) >= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4) { + h = uint32(0) + } + } + /* we didn't find it in the hash. h points to the first */ + /* available free spot. check to see if this is going to */ + /* make our hash too "full". */ + goto bitvec_set_rehash +bitvec_set_rehash: + ; + if uint64((*TBitvec)(unsafe.Pointer(p)).FnSet) >= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)/libc.Uint64FromInt32(2) { + aiValues = _sqlite3DbMallocRaw(tls, uintptr(0), uint64(496)) + if aiValues == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, aiValues, p+16, uint64(496)) + libc.Xmemset(tls, p+16, 0, uint64(496)) + (*TBitvec)(unsafe.Pointer(p)).FiDivisor = (*TBitvec)(unsafe.Pointer(p)).FiSize / uint32((libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(8)) + if (*TBitvec)(unsafe.Pointer(p)).FiSize%uint32((libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(8)) != uint32(0) { + (*TBitvec)(unsafe.Pointer(p)).FiDivisor = (*TBitvec)(unsafe.Pointer(p)).FiDivisor + 1 + } + if uint64((*TBitvec)(unsafe.Pointer(p)).FiDivisor) < (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) { + (*TBitvec)(unsafe.Pointer(p)).FiDivisor = uint32((libc.Uint64FromInt32(BITVEC_SZ) - libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4)) / libc.Uint64FromInt64(8) * libc.Uint64FromInt64(8) / libc.Uint64FromInt64(1) * libc.Uint64FromInt32(BITVEC_SZELEM)) + } + rc = _sqlite3BitvecSet(tls, p, i) + j = uint32(0) + for { + if !(uint64(j) < (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)) { + break + } + if **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4)) != 0 { + rc = rc | _sqlite3BitvecSet(tls, p, **(**Tu32)(__ccgo_up(aiValues + uintptr(j)*4))) + } + goto _3 + _3: + ; + j = j + 1 + } + _sqlite3DbFree(tls, uintptr(0), aiValues) + return rc + } + } + goto bitvec_set_end +bitvec_set_end: + ; + (*TBitvec)(unsafe.Pointer(p)).FnSet = (*TBitvec)(unsafe.Pointer(p)).FnSet + 1 + **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) = i + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Copy the complete content of pBtFrom into pBtTo. A transaction +// ** must be active for both files. +// ** +// ** The size of file pTo may be reduced by this operation. If anything +// ** goes wrong, the transaction on pTo is rolled back. If successful, the +// ** transaction is committed before returning. +// */ +func _sqlite3BtreeCopyFile(tls *libc.TLS, pTo uintptr, pFrom uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var pFd, v1 uintptr + var rc int32 + var _ /* b at bp+0 */ Tsqlite3_backup + var _ /* nByte at bp+72 */ Ti64 + _, _, _ = pFd, rc, v1 + _sqlite3BtreeEnter(tls, pTo) + _sqlite3BtreeEnter(tls, pFrom) + pFd = _sqlite3PagerFile(tls, _sqlite3BtreePager(tls, pTo)) + if (*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods != 0 { + **(**Ti64)(__ccgo_up(bp + 72)) = int64(_sqlite3BtreeGetPageSize(tls, pFrom)) * libc.Int64FromUint32(_sqlite3BtreeLastPage(tls, pFrom)) + rc = _sqlite3OsFileControl(tls, pFd, int32(SQLITE_FCNTL_OVERWRITE), bp+72) + if rc == int32(SQLITE_NOTFOUND) { + rc = SQLITE_OK + } + if rc != 0 { + goto copy_finished + } + } + /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set + ** to 0. This is used by the implementations of sqlite3_backup_step() + ** and sqlite3_backup_finish() to detect that they are being called + ** from this function, not directly by the user. + */ + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**Tsqlite3_backup)(__ccgo_up(bp))).FpSrcDb = (*TBtree)(unsafe.Pointer(pFrom)).Fdb + (**(**Tsqlite3_backup)(__ccgo_up(bp))).FpSrc = pFrom + (**(**Tsqlite3_backup)(__ccgo_up(bp))).FpDest = pTo + (**(**Tsqlite3_backup)(__ccgo_up(bp))).FiNext = uint32(1) + /* 0x7FFFFFFF is the hard limit for the number of pages in a database + ** file. By passing this as the number of pages to copy to + ** sqlite3_backup_step(), we can guarantee that the copy finishes + ** within a single call (unless an error occurs). The assert() statement + ** checks this assumption - (p->rc) should be set to either SQLITE_DONE + ** or an error code. */ + Xsqlite3_backup_step(tls, bp, int32(0x7FFFFFFF)) + rc = Xsqlite3_backup_finish(tls, bp) + if rc == SQLITE_OK { + v1 = (*TBtree)(unsafe.Pointer(pTo)).FpBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + } else { + _sqlite3PagerClearCache(tls, _sqlite3BtreePager(tls, (**(**Tsqlite3_backup)(__ccgo_up(bp))).FpDest)) + } + goto copy_finished +copy_finished: + ; + _sqlite3BtreeLeave(tls, pFrom) + _sqlite3BtreeLeave(tls, pTo) + return rc +} + +/************** End of backup.c **********************************************/ +/************** Begin file vdbemem.c *****************************************/ +/* +** 2004 May 26 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code use to manipulate "Mem" structure. A "Mem" +** stores a single value in the VDBE. Mem is an opaque structure visible +** only within the VDBE. Interface routines refer to a Mem using the +** name sqlite_value + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +/* True if X is a power of two. 0 is considered a power of two here. +** In other words, return true if X has at most one bit set. + */ + +// C documentation +// +// /* +// ** This function is used as part of copying the current row from cursor +// ** pSrc into cursor pDest. If the cursors are open on intkey tables, then +// ** parameter iKey is used as the rowid value when the record is copied +// ** into pDest. Otherwise, the record is copied verbatim. +// ** +// ** This function does not actually write the new value to cursor pDest. +// ** Instead, it creates and populates any required overflow pages and +// ** writes the data for the new cell into the BtShared.pTmpSpace buffer +// ** for the destination database. The size of the cell, in bytes, is left +// ** in BtShared.nPreformatSize. The caller completes the insertion by +// ** calling sqlite3BtreeInsert() with the BTREE_PREFORMAT flag specified. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +// */ +func _sqlite3BtreeTransferRow(tls *libc.TLS, pDest uintptr, pSrc uintptr, iKey Ti64) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aIn, aOut, pBt, pPageOut, pPgnoOut, pSrcPager, v1 uintptr + var nCopy int32 + var nIn, nOut, nRem Tu32 + var ovflIn TPgno + var v2 uint32 + var _ /* pNew at bp+24 */ uintptr + var _ /* pPageIn at bp+8 */ uintptr + var _ /* pgnoNew at bp+16 */ TPgno + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = aIn, aOut, nCopy, nIn, nOut, nRem, ovflIn, pBt, pPageOut, pPgnoOut, pSrcPager, v1, v2 + pBt = (*TBtCursor)(unsafe.Pointer(pDest)).FpBt + aOut = (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace /* Bytes of data still to copy */ + _getCellInfo(tls, pSrc) + if (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload < uint32(0x80) { + v1 = aOut + aOut = aOut + 1 + **(**Tu8)(__ccgo_up(v1)) = uint8((*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload) + } else { + aOut = aOut + uintptr(_sqlite3PutVarint(tls, aOut, uint64((*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload))) + } + if (*TBtCursor)(unsafe.Pointer(pDest)).FpKeyInfo == uintptr(0) { + aOut = aOut + uintptr(_sqlite3PutVarint(tls, aOut, libc.Uint64FromInt64(iKey))) + } + nIn = uint32((*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnLocal) + aIn = (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FpPayload + if aIn+uintptr(nIn) > (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pSrc)).FpPage)).FaDataEnd { + return _sqlite3CorruptError(tls, int32(82878)) + } + nRem = (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload + if nIn == nRem && nIn < uint32((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pDest)).FpPage)).FmaxLocal) { + libc.Xmemcpy(tls, aOut, aIn, uint64(nIn)) + (*TBtShared)(unsafe.Pointer(pBt)).FnPreformatSize = libc.Int32FromUint32(nIn + libc.Uint32FromInt32(int32(int64(aOut)-int64((*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace)))) + return SQLITE_OK + } else { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + pSrcPager = (*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pSrc)).FpBt)).FpPager + pPgnoOut = uintptr(0) + ovflIn = uint32(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pPageOut = uintptr(0) /* Size of output buffer aOut[] */ + nOut = libc.Uint32FromInt32(_btreePayloadToLocal(tls, (*TBtCursor)(unsafe.Pointer(pDest)).FpPage, libc.Int64FromUint32((*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload))) + (*TBtShared)(unsafe.Pointer(pBt)).FnPreformatSize = libc.Int32FromUint32(nOut) + int32(int64(aOut)-int64((*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace)) + if nOut < (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload { + pPgnoOut = aOut + uintptr(nOut) + **(**int32)(__ccgo_up(pBt + 144)) += int32(4) + } + if nRem > nIn { + if aIn+uintptr(nIn)+uintptr(4) > (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pSrc)).FpPage)).FaDataEnd { + return _sqlite3CorruptError(tls, int32(82903)) + } + ovflIn = _sqlite3Get4byte(tls, (*TBtCursor)(unsafe.Pointer(pSrc)).Finfo.FpPayload+uintptr(nIn)) + } + for cond := true; cond; cond = nRem > uint32(0) && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + nRem = nRem - nOut + for cond := true; cond; cond = **(**int32)(__ccgo_up(bp)) == SQLITE_OK && nOut > uint32(0) { + if nIn > uint32(0) { + if nOut < nIn { + v2 = nOut + } else { + v2 = nIn + } + nCopy = libc.Int32FromUint32(v2) + libc.Xmemcpy(tls, aOut, aIn, libc.Uint64FromInt32(nCopy)) + nOut = nOut - libc.Uint32FromInt32(nCopy) + nIn = nIn - libc.Uint32FromInt32(nCopy) + aOut = aOut + uintptr(nCopy) + aIn = aIn + uintptr(nCopy) + } + if nOut > uint32(0) { + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp)) = _sqlite3PagerGet(tls, pSrcPager, ovflIn, bp+8, int32(PAGER_GET_READONLY)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + aIn = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 8))) + ovflIn = _sqlite3Get4byte(tls, aIn) + aIn = aIn + uintptr(4) + nIn = (*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pSrc)).FpBt)).FusableSize - uint32(4) + } + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && nRem > uint32(0) && pPgnoOut != 0 { + **(**TPgno)(__ccgo_up(bp + 16)) = uint32(0) /* Prevent harmless static-analyzer warning */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + **(**int32)(__ccgo_up(bp)) = _allocateBtreePage(tls, pBt, bp+24, bp+16, uint32(0), uint8(0)) + _sqlite3Put4byte(tls, pPgnoOut, **(**TPgno)(__ccgo_up(bp + 16))) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && pPageOut != 0 { + _ptrmapPut(tls, pBt, **(**TPgno)(__ccgo_up(bp + 16)), uint8(PTRMAP_OVERFLOW2), (*TMemPage)(unsafe.Pointer(pPageOut)).Fpgno, bp) + } + _releasePage(tls, pPageOut) + pPageOut = **(**uintptr)(__ccgo_up(bp + 24)) + if pPageOut != 0 { + pPgnoOut = (*TMemPage)(unsafe.Pointer(pPageOut)).FaData + _sqlite3Put4byte(tls, pPgnoOut, uint32(0)) + aOut = pPgnoOut + 4 + if (*TBtShared)(unsafe.Pointer(pBt)).FusableSize-uint32(4) < nRem { + v2 = (*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32(4) + } else { + v2 = nRem + } + nOut = v2 + } + } + } + _releasePage(tls, pPageOut) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return **(**int32)(__ccgo_up(bp)) + } + return r +} + +// C documentation +// +// /* +// ** Set the collating sequence name for a column. +// */ +func _sqlite3ColumnSetColl(tls *libc.TLS, db uintptr, pCol uintptr, zColl uintptr) { + var n, nColl Ti64 + var zNew, v1 uintptr + _, _, _, _ = n, nColl, zNew, v1 + n = int64(_sqlite3Strlen30(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + int32(1)) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { + n = n + int64(_sqlite3Strlen30(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName+uintptr(n))+int32(1)) + } + nColl = int64(_sqlite3Strlen30(tls, zColl) + int32(1)) + zNew = _sqlite3DbRealloc(tls, db, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, libc.Uint64FromInt64(nColl+n)) + if zNew != 0 { + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = zNew + libc.Xmemcpy(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName+uintptr(n), zColl, libc.Uint64FromInt64(nColl)) + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_HASCOLL)) + } +} + +// C documentation +// +// /* +// ** This function is called when +// ** the transaction opened by database db has just finished. Locks held +// ** by database connection db have been released. +// ** +// ** This function loops through each entry in the blocked connections +// ** list and does the following: +// ** +// ** 1) If the sqlite3.pBlockingConnection member of a list entry is +// ** set to db, then set pBlockingConnection=0. +// ** +// ** 2) If the sqlite3.pUnlockConnection member of a list entry is +// ** set to db, then invoke the configured unlock-notify callback and +// ** set pUnlockConnection=0. +// ** +// ** 3) If the two steps above mean that pBlockingConnection==0 and +// ** pUnlockConnection==0, remove the entry from the blocked connections +// ** list. +// */ +func _sqlite3ConnectionUnlocked(tls *libc.TLS, db uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var aArg, aDyn, p, pNew, pp, xUnlockNotify, v2 uintptr + var nArg, v3 int32 + var _ /* aStatic at bp+0 */ [16]uintptr + _, _, _, _, _, _, _, _, _ = aArg, aDyn, nArg, p, pNew, pp, xUnlockNotify, v2, v3 + xUnlockNotify = uintptr(0) /* Unlock-notify cb to invoke */ + nArg = 0 /* Arguments to the unlock callback */ + aDyn = uintptr(0) /* Starter space for aArg[]. No malloc required */ + aArg = bp + _enterMutex(tls) /* Enter STATIC_MAIN mutex */ + /* This loop runs once for each entry in the blocked-connections list. */ + pp = uintptr(unsafe.Pointer(&_sqlite3BlockedList)) + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + p = **(**uintptr)(__ccgo_up(pp)) + /* Step 1. */ + if (*Tsqlite3)(unsafe.Pointer(p)).FpBlockingConnection == db { + (*Tsqlite3)(unsafe.Pointer(p)).FpBlockingConnection = uintptr(0) + } + /* Step 2. */ + if (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection == db { + if (*Tsqlite3)(unsafe.Pointer(p)).FxUnlockNotify != xUnlockNotify && nArg != 0 { + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})))(tls, aArg, nArg) + nArg = 0 + } + _sqlite3BeginBenignMalloc(tls) + if !(aDyn != 0) && nArg == libc.Int32FromUint64(libc.Uint64FromInt64(128)/libc.Uint64FromInt64(8)) || aDyn != 0 && nArg == libc.Int32FromUint64(libc.Uint64FromInt32(_sqlite3MallocSize(tls, aDyn))/libc.Uint64FromInt64(8)) { + /* The aArg[] array needs to grow. */ + pNew = _sqlite3Malloc(tls, uint64(libc.Uint64FromInt32(nArg)*uint64(8)*uint64(2))) + if pNew != 0 { + libc.Xmemcpy(tls, pNew, aArg, libc.Uint64FromInt32(nArg)*uint64(8)) + Xsqlite3_free(tls, aDyn) + v2 = pNew + aArg = v2 + aDyn = v2 + } else { + /* This occurs when the array of context pointers that need to + ** be passed to the unlock-notify callback is larger than the + ** aStatic[] array allocated on the stack and the attempt to + ** allocate a larger array from the heap has failed. + ** + ** This is a difficult situation to handle. Returning an error + ** code to the caller is insufficient, as even if an error code + ** is returned the transaction on connection db will still be + ** closed and the unlock-notify callbacks on blocked connections + ** will go unissued. This might cause the application to wait + ** indefinitely for an unlock-notify callback that will never + ** arrive. + ** + ** Instead, invoke the unlock-notify callback with the context + ** array already accumulated. We can then clear the array and + ** begin accumulating any further context pointers without + ** requiring any dynamic allocation. This is sub-optimal because + ** it means that instead of one callback with a large array of + ** context pointers the application will receive two or more + ** callbacks with smaller arrays of context pointers, which will + ** reduce the applications ability to prioritize multiple + ** connections. But it is the best that can be done under the + ** circumstances. + */ + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})))(tls, aArg, nArg) + nArg = 0 + } + } + _sqlite3EndBenignMalloc(tls) + v3 = nArg + nArg = nArg + 1 + **(**uintptr)(__ccgo_up(aArg + uintptr(v3)*8)) = (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockArg + xUnlockNotify = (*Tsqlite3)(unsafe.Pointer(p)).FxUnlockNotify + (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(p)).FxUnlockNotify = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockArg = uintptr(0) + } + /* Step 3. */ + if (*Tsqlite3)(unsafe.Pointer(p)).FpBlockingConnection == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection == uintptr(0) { + /* Remove connection p from the blocked connections list. */ + **(**uintptr)(__ccgo_up(pp)) = (*Tsqlite3)(unsafe.Pointer(p)).FpNextBlocked + (*Tsqlite3)(unsafe.Pointer(p)).FpNextBlocked = uintptr(0) + } else { + pp = p + 856 + } + goto _1 + _1: + } + if nArg != 0 { + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})))(tls, aArg, nArg) + } + Xsqlite3_free(tls, aDyn) + _leaveMutex(tls) /* Leave STATIC_MAIN mutex */ +} + +// C documentation +// +// /* +// ** Fill the Index.aiRowEst[] array with default information - information +// ** to be used when we have not run the ANALYZE command. +// ** +// ** aiRowEst[0] is supposed to contain the number of elements in the index. +// ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the +// ** number of rows in the table that match any particular value of the +// ** first column of the index. aiRowEst[2] is an estimate of the number +// ** of rows that match any particular combination of the first 2 columns +// ** of the index. And so forth. It must always be the case that +// * +// ** aiRowEst[N]<=aiRowEst[N-1] +// ** aiRowEst[N]>=1 +// ** +// ** Apart from that, we have little to go on besides intuition as to +// ** how aiRowEst[] should be initialized. The numbers generated here +// ** are based on typical values found in actual indices. +// */ +func _sqlite3DefaultRowEst(tls *libc.TLS, pIdx uintptr) { + var a uintptr + var i, nCopy, v1 int32 + var x, v2 TLogEst + _, _, _, _, _, _ = a, i, nCopy, x, v1, v2 + a = (*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst + if libc.Int32FromUint64(libc.Uint64FromInt64(10)/libc.Uint64FromInt64(2)) < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + v1 = libc.Int32FromUint64(libc.Uint64FromInt64(10) / libc.Uint64FromInt64(2)) + } else { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + } + nCopy = v1 + /* Indexes with default row estimates should not have stat1 data */ + /* Set the first entry (number of rows in the index) to the estimated + ** number of rows in the table, or half the number of rows in the table + ** for a partial index. + ** + ** 2020-05-27: If some of the stat data is coming from the sqlite_stat1 + ** table but other parts we are having to guess at, then do not let the + ** estimated number of rows in the table be less than 1000 (LogEst 99). + ** Failure to do this can cause the indexes for which we do not have + ** stat1 data to be ignored by the query planner. + */ + x = (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FnRowLogEst + if int32(x) < int32(99) { + v2 = libc.Int16FromInt32(99) + x = v2 + (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FnRowLogEst = v2 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) { + x = int16(int32(x) - libc.Int32FromInt32(10)) + } + **(**TLogEst)(__ccgo_up(a)) = x + /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is + ** 6 and each subsequent value (if any) is 5. */ + libc.Xmemcpy(tls, a+1*2, uintptr(unsafe.Pointer(&_aVal)), libc.Uint64FromInt32(nCopy)*uint64(2)) + i = nCopy + int32(1) + for { + if !(i <= libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + **(**TLogEst)(__ccgo_up(a + uintptr(i)*2)) = int16(23) + goto _3 + _3: + ; + i = i + 1 + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != OE_None { + **(**TLogEst)(__ccgo_up(a + uintptr((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)*2)) = 0 + } +} + +// C documentation +// +// /* +// ** Return TRUE if expression pExpr is able to return a subtype. +// ** +// ** A TRUE return does not guarantee that a subtype will be returned. +// ** It only indicates that a subtype return is possible. False positives +// ** are acceptable as they only disable an optimization. False negatives, +// ** on the other hand, can lead to incorrect answers. +// */ +func _sqlite3ExprCanReturnSubtype(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprNodeCanReturnSubtype) + _sqlite3WalkExpr(tls, bp, pExpr) + return libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) +} + +// C documentation +// +// /* +// ** Allocate an expression for a 32-bit signed integer literal. +// */ +func _sqlite3ExprInt32(tls *libc.TLS, db uintptr, iVal int32) (r uintptr) { + var pNew uintptr + var v1 int32 + _, _ = pNew, v1 + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(72)) + if pNew != 0 { + libc.Xmemset(tls, pNew, 0, uint64(72)) + (*TExpr)(unsafe.Pointer(pNew)).Fop = uint8(TK_INTEGER) + (*TExpr)(unsafe.Pointer(pNew)).FiAgg = int16(-int32(1)) + if iVal != 0 { + v1 = int32(EP_IsTrue) + } else { + v1 = int32(EP_IsFalse) + } + (*TExpr)(unsafe.Pointer(pNew)).Fflags = libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue) | libc.Int32FromInt32(EP_Leaf) | v1) + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pNew)).Fu)) = iVal + (*TExpr)(unsafe.Pointer(pNew)).FnHeight = int32(1) + } + return pNew +} + +// C documentation +// +// /* +// ** Make arrangements to invoke OP_Null on a range of registers +// ** during initialization. +// */ +func _sqlite3ExprNullRegisterRange(tls *libc.TLS, pParse uintptr, iReg int32, nReg int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var okConstFactor Tu8 + var _ /* t at bp+0 */ TExpr + _ = okConstFactor + okConstFactor = libc.Uint8FromInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x80 >> 7))) + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_NULLS) + *(*int32)(unsafe.Pointer(bp + 64)) = nReg + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 7, 0x80) + _sqlite3ExprCodeRunJustOnce(tls, pParse, bp, iReg) + libc.SetBitFieldPtr16Uint32(pParse+40, uint32(okConstFactor), 7, 0x80) +} + +// C documentation +// +// /* +// ** pExpr is a CHECK constraint on a row that is being UPDATE-ed. The +// ** only columns that are modified by the UPDATE are those for which +// ** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true. +// ** +// ** Return true if CHECK constraint pExpr uses any of the +// ** changing columns (or the rowid if it is changing). In other words, +// ** return true if this CHECK constraint must be validated for +// ** the new row in the UPDATE statement. +// ** +// ** 2018-09-15: pExpr might also be an expression for an index-on-expressions. +// ** The operation of this routine is the same - return true if an only if +// ** the expression uses one or more of columns identified by the second and +// ** third arguments. +// */ +func _sqlite3ExprReferencesUpdatedColumn(tls *libc.TLS, pExpr uintptr, aiChng uintptr, chngRowid int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var v1 uintptr + var _ /* w at bp+0 */ TWalker + _ = v1 + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(0) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_checkConstraintExprNode) + *(*uintptr)(unsafe.Pointer(bp + 40)) = aiChng + _sqlite3WalkExpr(tls, bp, pExpr) + if !(chngRowid != 0) { + v1 = bp + 36 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(CKCNSTRNT_ROWID)) + } + return libc.BoolInt32(libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) != 0) +} + +// C documentation +// +// /* +// ** Return an IEEE754 floating point value that approximates d*pow(10,p). +// ** +// ** The (current) algorithm is adapted from the work of Ross Cox at +// ** https://github.com/rsc/fpfmt +// */ +func _sqlite3Fp10Convert2(tls *libc.TLS, d Tu64, p int32) (r float64) { + bp := tls.Alloc(32) + defer tls.Free(32) + var adj, b, e, lp, s int32 + var hi, pwr10h, sticky, u, x Tu64 + var mid1, mid2 Tu32 + var _ /* lo at bp+8 */ Tu64 + var _ /* m at bp+16 */ Tu64 + var _ /* pwr10l at bp+0 */ Tu32 + var _ /* r at bp+24 */ float64 + _, _, _, _, _, _, _, _, _, _, _, _ = adj, b, e, hi, lp, mid1, mid2, pwr10h, s, sticky, u, x + if p < -int32(348) { + return float64(0) + } + if p > +libc.Int32FromInt32(347) { + return float64(libc.X__builtin_inff(tls)) + } + b = int32(64) - _countLeadingZeros(tls, d) + lp = _pwr10to2(tls, p) + e = int32(53) - b - lp + if e > int32(1074) { + if e >= int32(1130) { + return float64(0) + } + e = int32(1074) + } + s = -(e - (int32(64) - b) + lp + int32(3)) + pwr10h = _powerOfTen(tls, p, bp) + if **(**Tu32)(__ccgo_up(bp)) != uint32(0) { + pwr10h = pwr10h + 1 + **(**Tu32)(__ccgo_up(bp)) = ^**(**Tu32)(__ccgo_up(bp)) + } + x = d << (int32(64) - b) + hi = _sqlite3Multiply128(tls, x, pwr10h, bp+8) + mid1 = uint32(**(**Tu64)(__ccgo_up(bp + 8)) >> int32(32)) + sticky = uint64(1) + if hi&(libc.Uint64FromInt32(1)<> int32(32)) + sticky = libc.BoolUint64(mid1-mid2 > libc.Uint32FromInt32(1)) + hi = hi - libc.BoolUint64(mid1 < mid2) + } + u = hi>>s | sticky + adj = libc.BoolInt32(u >= libc.Uint64FromInt32(1)<>adj | u&uint64(1) + e = e - adj + } + **(**Tu64)(__ccgo_up(bp + 16)) = (u + uint64(1) + u>>libc.Int32FromInt32(2)&uint64(1)) >> int32(2) + if e <= -int32(972) { + return float64(libc.X__builtin_inff(tls)) + } + if **(**Tu64)(__ccgo_up(bp + 16))&(libc.Uint64FromInt32(1)<= (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_RANGE) + } else { + pOrig = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) + pNew = _sqlite3Fts5MallocZero(tls, bp, int64(40)) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase = _sqlite3Fts5MallocZero(tls, bp, int64(8)) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+48)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(8))) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+24)+libc.Uint64FromInt32(libc.Int32FromInt32(2))*libc.Uint64FromInt64(8))) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && pOrig != uintptr(0) { + pColsetOrig = (*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer((*TFts5ExprPhrase)(unsafe.Pointer(pOrig)).FpNode)).FpNear)).FpColset + if pColsetOrig != 0 { + nByte = libc.Int64FromUint64(libc.Uint64FromInt64(8) * libc.Uint64FromInt32(((*TFts5Colset)(unsafe.Pointer(pColsetOrig)).FnCol+libc.Int32FromInt32(2))/libc.Int32FromInt32(2))) + pColset = _sqlite3Fts5MallocZero(tls, bp, nByte) + if pColset != 0 { + libc.Xmemcpy(tls, pColset, pColsetOrig, libc.Uint64FromInt64(nByte)) + } + (*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear)).FpColset = pColset + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if (*TFts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm != 0 { /* Used to iterate through phrase terms */ + (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpConfig = (*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < (*TFts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm) { + break + } + tflags = 0 + p = pOrig + 32 + uintptr(i)*40 + for { + if !(p != 0 && **(**int32)(__ccgo_up(bp)) == SQLITE_OK) { + break + } + **(**int32)(__ccgo_up(bp)) = _fts5ParseTokenize(tls, bp+8, tflags, (*TFts5ExprTerm)(unsafe.Pointer(p)).FpTerm, (*TFts5ExprTerm)(unsafe.Pointer(p)).FnFullTerm, 0, 0) + tflags = int32(FTS5_TOKEN_COLOCATED) + goto _2 + _2: + ; + p = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpSynonym + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*(*TFts5ExprTerm)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase + 32 + uintptr(i)*40))).FbPrefix = (*(*TFts5ExprTerm)(unsafe.Pointer(pOrig + 32 + uintptr(i)*40))).FbPrefix + (*(*TFts5ExprTerm)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase + 32 + uintptr(i)*40))).FbFirst = (*(*TFts5ExprTerm)(unsafe.Pointer(pOrig + 32 + uintptr(i)*40))).FbFirst + } + goto _1 + _1: + ; + i = i + 1 + } + } else { + /* This happens when parsing a token or quoted phrase that contains + ** no token characters at all. (e.g ... MATCH '""'). */ + (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(40))) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase != 0 { + /* All the allocations succeeded. Put the expression object together. */ + (*TFts5Expr)(unsafe.Pointer(pNew)).FpIndex = (*TFts5Expr)(unsafe.Pointer(pExpr)).FpIndex + (*TFts5Expr)(unsafe.Pointer(pNew)).FpConfig = (*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig + (*TFts5Expr)(unsafe.Pointer(pNew)).FnPhrase = int32(1) + **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase)) = (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase + *(*uintptr)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear + 24)) = (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase + (*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear)).FnPhrase = int32(1) + (*TFts5ExprPhrase)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase)).FpNode = (*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot + if (*TFts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm == int32(1) && (*(*TFts5ExprTerm)(unsafe.Pointer(pOrig + 32))).FpSynonym == uintptr(0) && libc.Int32FromUint8((*(*TFts5ExprTerm)(unsafe.Pointer(pOrig + 32))).FbFirst) == 0 { + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = int32(FTS5_TERM) + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = __ccgo_fp(_fts5ExprNodeNext_TERM) + } else { + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = int32(FTS5_STRING) + (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = __ccgo_fp(_fts5ExprNodeNext_STRING) + } + } else { + _sqlite3Fts5ExprFree(tls, pNew) + _fts5ExprPhraseFree(tls, (**(**TTokenCtx)(__ccgo_up(bp + 8))).FpPhrase) + pNew = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppNew)) = pNew + return **(**int32)(__ccgo_up(bp)) +} + +func _sqlite3Fts5ExprNew(tls *libc.TLS, pConfig uintptr, bPhraseToAnd int32, iCol int32, zExpr uintptr, ppNew uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var n, t int32 + var pColset, pEngine, pNew, v1 uintptr + var _ /* sParse at bp+0 */ TFts5Parse + var _ /* token at bp+48 */ TFts5Token + var _ /* z at bp+64 */ uintptr + _, _, _, _, _, _ = n, pColset, pEngine, pNew, t, v1 + **(**uintptr)(__ccgo_up(bp + 64)) = zExpr + **(**uintptr)(__ccgo_up(ppNew)) = uintptr(0) + **(**uintptr)(__ccgo_up(pzErr)) = uintptr(0) + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TFts5Parse)(__ccgo_up(bp))).FbPhraseToAnd = bPhraseToAnd + pEngine = _sqlite3Fts5ParserAlloc(tls, __ccgo_fp(_fts5ParseAlloc)) + if pEngine == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (**(**TFts5Parse)(__ccgo_up(bp))).FpConfig = pConfig + for cond := true; cond; cond = (**(**TFts5Parse)(__ccgo_up(bp))).Frc == SQLITE_OK && t != FTS5_EOF { + t = _fts5ExprGetToken(tls, bp, bp+64, bp+48) + _sqlite3Fts5Parser(tls, pEngine, t, **(**TFts5Token)(__ccgo_up(bp + 48)), bp) + } + _sqlite3Fts5ParserFree(tls, pEngine, __ccgo_fp(_fts5ParseFree)) + /* If the LHS of the MATCH expression was a user column, apply the + ** implicit column-filter. */ + if (**(**TFts5Parse)(__ccgo_up(bp))).Frc == SQLITE_OK && iCol < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol { + n = libc.Int32FromUint64(libc.Uint64FromInt64(8) * libc.Uint64FromInt32((libc.Int32FromInt32(1)+libc.Int32FromInt32(2))/libc.Int32FromInt32(2))) + pColset = _sqlite3Fts5MallocZero(tls, bp+16, int64(n)) + if pColset != 0 { + (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol = int32(1) + *(*int32)(unsafe.Pointer(pColset + 4)) = iCol + _sqlite3Fts5ParseSetColset(tls, bp, (**(**TFts5Parse)(__ccgo_up(bp))).FpExpr, pColset) + } + } + if (**(**TFts5Parse)(__ccgo_up(bp))).Frc == SQLITE_OK { + v1 = Xsqlite3_malloc64(tls, uint64(40)) + pNew = v1 + **(**uintptr)(__ccgo_up(ppNew)) = v1 + if pNew == uintptr(0) { + (**(**TFts5Parse)(__ccgo_up(bp))).Frc = int32(SQLITE_NOMEM) + _sqlite3Fts5ParseNodeFree(tls, (**(**TFts5Parse)(__ccgo_up(bp))).FpExpr) + } else { + (*TFts5Expr)(unsafe.Pointer(pNew)).FpRoot = (**(**TFts5Parse)(__ccgo_up(bp))).FpExpr + (*TFts5Expr)(unsafe.Pointer(pNew)).FpIndex = uintptr(0) + (*TFts5Expr)(unsafe.Pointer(pNew)).FpConfig = pConfig + (*TFts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase = (**(**TFts5Parse)(__ccgo_up(bp))).FapPhrase + (*TFts5Expr)(unsafe.Pointer(pNew)).FnPhrase = (**(**TFts5Parse)(__ccgo_up(bp))).FnPhrase + (*TFts5Expr)(unsafe.Pointer(pNew)).FbDesc = 0 + (**(**TFts5Parse)(__ccgo_up(bp))).FapPhrase = uintptr(0) + } + } else { + _sqlite3Fts5ParseNodeFree(tls, (**(**TFts5Parse)(__ccgo_up(bp))).FpExpr) + } + Xsqlite3_free(tls, (**(**TFts5Parse)(__ccgo_up(bp))).FapPhrase) + if uintptr(0) == **(**uintptr)(__ccgo_up(pzErr)) { + **(**uintptr)(__ccgo_up(pzErr)) = (**(**TFts5Parse)(__ccgo_up(bp))).FzErr + } else { + Xsqlite3_free(tls, (**(**TFts5Parse)(__ccgo_up(bp))).FzErr) + } + return (**(**TFts5Parse)(__ccgo_up(bp))).Frc +} + +// C documentation +// +// /* +// ** Empty (but do not delete) a hash table. +// */ +func _sqlite3Fts5HashClear(tls *libc.TLS, pHash uintptr) { + var i int32 + var pNext, pSlot uintptr + _, _, _ = i, pNext, pSlot + i = 0 + for { + if !(i < (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot) { + break + } + pSlot = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(i)*8)) + for { + if !(pSlot != 0) { + break + } + pNext = (*TFts5HashEntry)(unsafe.Pointer(pSlot)).FpHashNext + Xsqlite3_free(tls, pSlot) + goto _2 + _2: + ; + pSlot = pNext + } + goto _1 + _1: + ; + i = i + 1 + } + libc.Xmemset(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot, 0, libc.Uint64FromInt32((*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot)*uint64(8)) + (*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry = 0 +} + +// C documentation +// +// /* +// ** Allocate a new hash table. +// */ +func _sqlite3Fts5HashNew(tls *libc.TLS, pConfig uintptr, ppNew uintptr, pnByte uintptr) (r int32) { + var nByte Tsqlite3_int64 + var pNew, v1 uintptr + var rc int32 + _, _, _, _ = nByte, pNew, rc, v1 + rc = SQLITE_OK + v1 = Xsqlite3_malloc64(tls, uint64(40)) + pNew = v1 + **(**uintptr)(__ccgo_up(ppNew)) = v1 + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pNew, 0, uint64(40)) + (*TFts5Hash)(unsafe.Pointer(pNew)).FpnByte = pnByte + (*TFts5Hash)(unsafe.Pointer(pNew)).FeDetail = (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail + (*TFts5Hash)(unsafe.Pointer(pNew)).FnSlot = int32(1024) + nByte = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt32((*TFts5Hash)(unsafe.Pointer(pNew)).FnSlot)) + (*TFts5Hash)(unsafe.Pointer(pNew)).FaSlot = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if (*TFts5Hash)(unsafe.Pointer(pNew)).FaSlot == uintptr(0) { + Xsqlite3_free(tls, pNew) + **(**uintptr)(__ccgo_up(ppNew)) = uintptr(0) + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, (*TFts5Hash)(unsafe.Pointer(pNew)).FaSlot, 0, libc.Uint64FromInt64(nByte)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Query the hash table for a doclist associated with term pTerm/nTerm. +// */ +func _sqlite3Fts5HashQuery(tls *libc.TLS, pHash uintptr, nPre int32, pTerm uintptr, nTerm int32, ppOut uintptr, pnDoclist uintptr) (r int32) { + var iHash uint32 + var nHashPre, nList int32 + var p, pFaux, pRet, zKey, v2 uintptr + _, _, _, _, _, _, _, _ = iHash, nHashPre, nList, p, pFaux, pRet, zKey, v2 + iHash = _fts5HashKey(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FnSlot, pTerm, nTerm) + zKey = uintptr(0) + p = **(**uintptr)(__ccgo_up((*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)) + for { + if !(p != 0) { + break + } + zKey = p + 1*48 + if nTerm == (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey && libc.Xmemcmp(tls, zKey, pTerm, libc.Uint64FromInt32(nTerm)) == 0 { + break + } + goto _1 + _1: + ; + p = (*TFts5HashEntry)(unsafe.Pointer(p)).FpHashNext + } + if p != 0 { + nHashPre = libc.Int32FromUint64(uint64(48) + libc.Uint64FromInt32(nTerm)) + nList = (*TFts5HashEntry)(unsafe.Pointer(p)).FnData - nHashPre + v2 = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nPre+nList+int32(10))) + **(**uintptr)(__ccgo_up(ppOut)) = v2 + pRet = v2 + if pRet != 0 { + pFaux = pRet + uintptr(nPre-nHashPre) + libc.Xmemcpy(tls, pRet+uintptr(nPre), p+uintptr(nHashPre), libc.Uint64FromInt32(nList)) + nList = nList + _fts5HashAddPoslistSize(tls, pHash, p, pFaux) + **(**int32)(__ccgo_up(pnDoclist)) = nList + } else { + **(**int32)(__ccgo_up(pnDoclist)) = 0 + return int32(SQLITE_NOMEM) + } + } else { + **(**uintptr)(__ccgo_up(ppOut)) = uintptr(0) + **(**int32)(__ccgo_up(pnDoclist)) = 0 + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Read and decode the "averages" record from the database. +// ** +// ** Parameter anSize must point to an array of size nCol, where nCol is +// ** the number of user defined columns in the FTS table. +// */ +func _sqlite3Fts5IndexGetAverages(tls *libc.TLS, p uintptr, pnRow uintptr, anSize uintptr) (r int32) { + var i, iCol, nCol int32 + var pData uintptr + _, _, _, _ = i, iCol, nCol, pData + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FnCol + **(**Ti64)(__ccgo_up(pnRow)) = 0 + libc.Xmemset(tls, anSize, 0, uint64(8)*libc.Uint64FromInt32(nCol)) + pData = _fts5DataRead(tls, p, int64(FTS5_AVERAGES_ROWID)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5Data)(unsafe.Pointer(pData)).Fnn != 0 { + i = 0 + i = i + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr(i), pnRow)) + iCol = 0 + for { + if !(i < (*TFts5Data)(unsafe.Pointer(pData)).Fnn && iCol < nCol) { + break + } + i = i + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr(i), anSize+uintptr(iCol)*8)) + goto _1 + _1: + ; + iCol = iCol + 1 + } + } + _fts5DataRelease(tls, pData) + return _fts5IndexReturn(tls, p) +} + +// C documentation +// +// /* +// ** Open a new iterator to iterate though all rowid that match the +// ** specified token or token prefix. +// */ +func _sqlite3Fts5IndexQuery(tls *libc.TLS, p uintptr, pToken uintptr, nToken int32, flags int32, pColset uintptr, ppIter uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bDesc, bTokendata, iIdx, iPrefixIdx, nChar, nIdxChar int32 + var pConfig, pSeg, pStruct uintptr + var _ /* buf at bp+8 */ TFts5Buffer + var _ /* pRet at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _ = bDesc, bTokendata, iIdx, iPrefixIdx, nChar, nIdxChar, pConfig, pSeg, pStruct + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**TFts5Buffer)(__ccgo_up(bp + 8)) = TFts5Buffer{} + /* If the QUERY_SCAN flag is set, all other flags must be clear. */ + if _sqlite3Fts5BufferSize(tls, p+60, bp+8, libc.Uint32FromInt32(nToken+int32(1))) == 0 { + iIdx = 0 /* Index to search */ + iPrefixIdx = 0 /* +1 prefix index */ + bTokendata = (*TFts5Config)(unsafe.Pointer(pConfig)).FbTokendata + if nToken > 0 { + libc.Xmemcpy(tls, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp+1, pToken, libc.Uint64FromInt32(nToken)) + } + /* The NOTOKENDATA flag is set when each token in a tokendata=1 table + ** should be treated individually, instead of merging all those with + ** a common prefix into a single entry. This is used, for example, by + ** queries performed as part of an integrity-check, or by the fts5vocab + ** module. */ + if flags&(libc.Int32FromInt32(FTS5INDEX_QUERY_NOTOKENDATA)|libc.Int32FromInt32(FTS5INDEX_QUERY_SCAN)) != 0 { + bTokendata = 0 + } + /* Figure out which index to search and set iIdx accordingly. If this + ** is a prefix query for which there is no prefix index, set iIdx to + ** greater than pConfig->nPrefix to indicate that the query will be + ** satisfied by scanning multiple terms in the main index. + ** + ** If the QUERY_TEST_NOIDX flag was specified, then this must be a + ** prefix-query. Instead of using a prefix-index (if one exists), + ** evaluate the prefix query using the main FTS index. This is used + ** for internal sanity checking by the integrity-check in debug + ** mode only. */ + if flags&int32(FTS5INDEX_QUERY_PREFIX) != 0 { + nChar = _fts5IndexCharlen(tls, pToken, nToken) + iIdx = int32(1) + for { + if !(iIdx <= (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix) { + break + } + nIdxChar = **(**int32)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr(iIdx-int32(1))*4)) + if nIdxChar == nChar { + break + } + if nIdxChar == nChar+int32(1) { + iPrefixIdx = iIdx + } + goto _1 + _1: + ; + iIdx = iIdx + 1 + } + } + if bTokendata != 0 && iIdx == 0 { + **(**Tu8)(__ccgo_up((**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp)) = uint8('0') + **(**uintptr)(__ccgo_up(bp)) = _fts5SetupTokendataIter(tls, p, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp, nToken+int32(1), pColset) + } else { + if iIdx <= (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix { + /* Straight index lookup */ + pStruct = _fts5StructureRead(tls, p) + **(**Tu8)(__ccgo_up((**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp)) = libc.Uint8FromInt32(libc.Int32FromUint8('0') + iIdx) + if pStruct != 0 { + _fts5MultiIterNew(tls, p, pStruct, flags|int32(FTS5INDEX_QUERY_SKIPEMPTY), pColset, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp, nToken+int32(1), -int32(1), 0, bp) + _fts5StructureRelease(tls, pStruct) + } + } else { + /* Scan multiple terms in the main index for a prefix query. */ + bDesc = libc.BoolInt32(flags&int32(FTS5INDEX_QUERY_DESC) != 0) + _fts5SetupPrefixIter(tls, p, bDesc, iPrefixIdx, (**(**TFts5Buffer)(__ccgo_up(bp + 8))).Fp, nToken+int32(1), pColset, bp) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + } else { + _fts5IterSetOutputCb(tls, p+60, **(**uintptr)(__ccgo_up(bp))) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pSeg = **(**uintptr)(__ccgo_up(bp)) + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaFirst + 1*4))).FiFirst)*128 + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 { + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxSetOutputs})))(tls, **(**uintptr)(__ccgo_up(bp)), pSeg) + } + } + } + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + _fts5IterClose(tls, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _fts5IndexCloseReader(tls, p) + } + **(**uintptr)(__ccgo_up(ppIter)) = **(**uintptr)(__ccgo_up(bp)) + _sqlite3Fts5BufferFree(tls, bp+8) + } + return _fts5IndexReturn(tls, p) +} + +func _sqlite3Fts5MallocZero(tls *libc.TLS, pRc uintptr, nByte Tsqlite3_int64) (r uintptr) { + var pRet uintptr + _ = pRet + pRet = uintptr(0) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pRet == uintptr(0) { + if nByte > 0 { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } else { + libc.Xmemset(tls, pRet, 0, libc.Uint64FromInt64(nByte)) + } + } + return pRet +} + +func _sqlite3Fts5ParseImplicitAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) (r uintptr) { + var ap, pPrev, pRet uintptr + _, _, _ = ap, pPrev, pRet + pRet = uintptr(0) + if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc != 0 { + _sqlite3Fts5ParseNodeFree(tls, pLeft) + _sqlite3Fts5ParseNodeFree(tls, pRight) + } else { + if (*TFts5ExprNode)(unsafe.Pointer(pLeft)).FeType == int32(FTS5_AND) { + pPrev = *(*uintptr)(unsafe.Pointer(pLeft + 48 + uintptr((*TFts5ExprNode)(unsafe.Pointer(pLeft)).FnChild-int32(1))*8)) + } else { + pPrev = pLeft + } + if (*TFts5ExprNode)(unsafe.Pointer(pRight)).FeType == FTS5_EOF { + _sqlite3Fts5ParseNodeFree(tls, pRight) + pRet = pLeft + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + } else { + if (*TFts5ExprNode)(unsafe.Pointer(pPrev)).FeType == FTS5_EOF { + if pPrev == pLeft { + pRet = pRight + } else { + *(*uintptr)(unsafe.Pointer(pLeft + 48 + uintptr((*TFts5ExprNode)(unsafe.Pointer(pLeft)).FnChild-int32(1))*8)) = pRight + pRet = pLeft + } + ap = (*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase-int32(1)-(*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase)*8 + libc.Xmemmove(tls, ap, ap+1*8, uint64(8)*libc.Uint64FromInt32((*TFts5ExprNearset)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase)) + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + _sqlite3Fts5ParseNodeFree(tls, pPrev) + } else { + pRet = _sqlite3Fts5ParseNode(tls, pParse, int32(FTS5_AND), pLeft, pRight, uintptr(0)) + } + } + } + return pRet +} + +// C documentation +// +// /* +// ** If argument pNear is NULL, then a new Fts5ExprNearset object is allocated +// ** and populated with pPhrase. Or, if pNear is not NULL, phrase pPhrase is +// ** appended to it and the results returned. +// ** +// ** If an OOM error occurs, both the pNear and pPhrase objects are freed and +// ** NULL returned. +// */ +func _sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhrase uintptr) (r uintptr) { + var SZALLOC, nNew, v1 int32 + var nByte, nByte1 Tsqlite3_int64 + var pLast, pRet, v2 uintptr + _, _, _, _, _, _, _, _ = SZALLOC, nByte, nByte1, nNew, pLast, pRet, v1, v2 + SZALLOC = int32(8) + pRet = uintptr(0) + if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { + if pNear == uintptr(0) { + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+24) + libc.Uint64FromInt32(SZALLOC+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pRet == uintptr(0) { + (*TFts5Parse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pRet, 0, libc.Uint64FromInt64(nByte)) + } + } else { + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase%SZALLOC == 0 { + nNew = (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase + SZALLOC + nByte1 = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+24) + libc.Uint64FromInt32(nNew+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + pRet = Xsqlite3_realloc64(tls, pNear, libc.Uint64FromInt64(nByte1)) + if pRet == uintptr(0) { + (*TFts5Parse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + } + } else { + pRet = pNear + } + } + } + if pRet == uintptr(0) { + _sqlite3Fts5ParseNearsetFree(tls, pNear) + _sqlite3Fts5ParsePhraseFree(tls, pPhrase) + } else { + if (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase > 0 { + pLast = *(*uintptr)(unsafe.Pointer(pRet + 24 + uintptr((*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase-int32(1))*8)) + if (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm == 0 { + _fts5ExprPhraseFree(tls, pPhrase) + (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase = (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase - 1 + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + pPhrase = pLast + } else { + if (*TFts5ExprPhrase)(unsafe.Pointer(pLast)).FnTerm == 0 { + _fts5ExprPhraseFree(tls, pLast) + **(**uintptr)(__ccgo_up((*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase-int32(2))*8)) = pPhrase + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase = (*TFts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase - 1 + } + } + } + v2 = pRet + 16 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + *(*uintptr)(unsafe.Pointer(pRet + 24 + uintptr(v1)*8)) = pPhrase + } + return pRet +} + +// C documentation +// +// /* +// ** This function is called by the parser to process a string token. The +// ** string may or may not be quoted. In any case it is tokenized and a +// ** phrase object consisting of all tokens returned. +// */ +func _sqlite3Fts5ParseTerm(tls *libc.TLS, pParse uintptr, pAppend uintptr, pToken uintptr, bPrefix int32) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var flags, n, rc, v1 int32 + var pConfig uintptr + var v3 bool + var _ /* sCtx at bp+0 */ TTokenCtx + var _ /* z at bp+24 */ uintptr + _, _, _, _, _, _ = flags, n, pConfig, rc, v1, v3 + pConfig = (*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig /* Tokenize return code */ + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + libc.Xmemset(tls, bp, 0, uint64(24)) + (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase = pAppend + (**(**TTokenCtx)(__ccgo_up(bp))).FpConfig = pConfig + rc = _fts5ParseStringFromToken(tls, pToken, bp+24) + if rc == SQLITE_OK { + if bPrefix != 0 { + v1 = int32(FTS5_TOKENIZE_PREFIX) + } else { + v1 = 0 + } + flags = int32(FTS5_TOKENIZE_QUERY) | v1 + _sqlite3Fts5Dequote(tls, **(**uintptr)(__ccgo_up(bp + 24))) + n = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(bp + 24)))) + rc = _sqlite3Fts5Tokenize(tls, pConfig, flags, **(**uintptr)(__ccgo_up(bp + 24)), n, bp, __ccgo_fp(_fts5ParseTokenize)) + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 24))) + if v3 = rc != 0; !v3 { + v1 = (**(**TTokenCtx)(__ccgo_up(bp))).Frc + rc = v1 + } + if v3 || v1 != 0 { + (*TFts5Parse)(unsafe.Pointer(pParse)).Frc = rc + _fts5ExprPhraseFree(tls, (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase) + (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase = uintptr(0) + } else { + if pAppend == uintptr(0) { + if _parseGrowPhraseArray(tls, pParse) != 0 { + _fts5ExprPhraseFree(tls, (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase) + return uintptr(0) + } + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase + 1 + } + if (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase == uintptr(0) { + /* This happens when parsing a token or quoted phrase that contains + ** no token characters at all. (e.g ... MATCH '""'). */ + (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase = _sqlite3Fts5MallocZero(tls, pParse+16, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(40))) + } else { + if (*TFts5ExprPhrase)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase)).FnTerm != 0 { + (*(*TFts5ExprTerm)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase + 32 + uintptr((*TFts5ExprPhrase)(unsafe.Pointer((**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase)).FnTerm-int32(1))*40))).FbPrefix = libc.Uint8FromInt32(bPrefix) + } + } + **(**uintptr)(__ccgo_up((*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase-int32(1))*8)) = (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase + } + return (**(**TTokenCtx)(__ccgo_up(bp))).FpPhrase +} + +func _sqlite3Fts5PoslistReaderInit(tls *libc.TLS, a uintptr, n int32, pIter uintptr) (r int32) { + libc.Xmemset(tls, pIter, 0, uint64(32)) + (*TFts5PoslistReader)(unsafe.Pointer(pIter)).Fa = a + (*TFts5PoslistReader)(unsafe.Pointer(pIter)).Fn = n + _sqlite3Fts5PoslistReaderNext(tls, pIter) + return libc.Int32FromUint8((*TFts5PoslistReader)(unsafe.Pointer(pIter)).FbEof) +} + +// C documentation +// +// /* +// ** Insert new entries into the FTS index and %_docsize table. +// */ +func _sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRowid Ti64) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iCol int32 + var pConfig, pVal uintptr + var _ /* buf at bp+24 */ TFts5Buffer + var _ /* ctx at bp+8 */ TFts5InsertCtx + var _ /* nLoc at bp+56 */ int32 + var _ /* nText at bp+40 */ int32 + var _ /* pLoc at bp+64 */ uintptr + var _ /* pText at bp+48 */ uintptr + var _ /* rc at bp+0 */ int32 + _, _, _ = iCol, pConfig, pVal + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Buffer used to build up %_docsize blob */ + libc.Xmemset(tls, bp+24, 0, uint64(16)) + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FpStorage = p + **(**int32)(__ccgo_up(bp)) = _fts5StorageLoadTotals(tls, p, int32(1)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5IndexBeginWrite(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid) + } + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FszCol = 0 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol)))) == 0 { + **(**int32)(__ccgo_up(bp + 40)) = 0 /* Size of pText in bytes */ + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) /* Pointer to buffer containing text value */ + **(**int32)(__ccgo_up(bp + 56)) = 0 /* Size of pText in bytes */ + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) /* Pointer to buffer containing text value */ + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol+int32(2))*8)) + if (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow != 0 && Xsqlite3_value_nochange(tls, pVal) != 0 { + pVal = Xsqlite3_column_value(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow, (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol+int32(1)) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL && (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 { + iCol = (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol + int32(1) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + **(**uintptr)(__ccgo_up(bp + 64)) = Xsqlite3_column_text(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow, iCol) + **(**int32)(__ccgo_up(bp + 56)) = Xsqlite3_column_bytes(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow, iCol) + } + } else { + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol+int32(2))*8)) + } + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 && _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5DecodeLocaleValue(tls, pVal, bp+48, bp+40, bp+64, bp+56) + } else { + **(**uintptr)(__ccgo_up(bp + 48)) = Xsqlite3_value_text(tls, pVal) + **(**int32)(__ccgo_up(bp + 40)) = Xsqlite3_value_bytes(tls, pVal) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + _sqlite3Fts5SetLocale(tls, pConfig, **(**uintptr)(__ccgo_up(bp + 64)), **(**int32)(__ccgo_up(bp + 56))) + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5Tokenize(tls, pConfig, int32(FTS5_TOKENIZE_DOCUMENT), **(**uintptr)(__ccgo_up(bp + 48)), **(**int32)(__ccgo_up(bp + 40)), bp+8, __ccgo_fp(_fts5StorageInsertCallback)) + _sqlite3Fts5ClearLocale(tls, pConfig) + } + } + _sqlite3Fts5BufferAppendVarint(tls, bp, bp+24, int64((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FszCol)) + **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol)*8)) += int64((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FszCol) + goto _1 + _1: + ; + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol = (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol + 1 + } + (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow = (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow + 1 + /* Write the %_docsize record */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _fts5StorageInsertDocsize(tls, p, iRowid, bp+24) + } + Xsqlite3_free(tls, (**(**TFts5Buffer)(__ccgo_up(bp + 24))).Fp) + return **(**int32)(__ccgo_up(bp)) +} + +func _sqlite3Fts5StorageRebuild(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var iCol, rc2 int32 + var iRowid Ti64 + var pConfig, pVal uintptr + var _ /* buf at bp+0 */ TFts5Buffer + var _ /* ctx at bp+24 */ TFts5InsertCtx + var _ /* nLoc at bp+56 */ int32 + var _ /* nText at bp+44 */ int32 + var _ /* pLoc at bp+64 */ uintptr + var _ /* pScan at bp+16 */ uintptr + var _ /* pText at bp+48 */ uintptr + var _ /* rc at bp+40 */ int32 + _, _, _, _, _ = iCol, iRowid, pConfig, pVal, rc2 + **(**TFts5Buffer)(__ccgo_up(bp)) = TFts5Buffer{} + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + libc.Xmemset(tls, bp+24, 0, uint64(16)) + (**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FpStorage = p + **(**int32)(__ccgo_up(bp + 40)) = _sqlite3Fts5StorageDeleteAll(tls, p) + if **(**int32)(__ccgo_up(bp + 40)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 40)) = _fts5StorageLoadTotals(tls, p, int32(1)) + } + if **(**int32)(__ccgo_up(bp + 40)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 40)) = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_SCAN), bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg) + } + for **(**int32)(__ccgo_up(bp + 40)) == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 16))) { + iRowid = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp + 16)), 0) + _sqlite3Fts5BufferZero(tls, bp) + **(**int32)(__ccgo_up(bp + 40)) = _sqlite3Fts5IndexBeginWrite(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid) + (**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FiCol = 0 + for { + if !(**(**int32)(__ccgo_up(bp + 40)) == SQLITE_OK && (**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FiCol < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + (**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FszCol = 0 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FiCol)))) == 0 { + **(**int32)(__ccgo_up(bp + 44)) = 0 /* Size of pText in bytes */ + **(**uintptr)(__ccgo_up(bp + 48)) = uintptr(0) /* Pointer to buffer containing text value */ + **(**int32)(__ccgo_up(bp + 56)) = 0 /* Size of pLoc in bytes */ + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) /* Pointer to buffer containing text value */ + pVal = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp + 16)), (**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FiCol+int32(1)) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_EXTERNAL) && _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + **(**int32)(__ccgo_up(bp + 40)) = _sqlite3Fts5DecodeLocaleValue(tls, pVal, bp+48, bp+44, bp+64, bp+56) + } else { + **(**uintptr)(__ccgo_up(bp + 48)) = Xsqlite3_value_text(tls, pVal) + **(**int32)(__ccgo_up(bp + 44)) = Xsqlite3_value_bytes(tls, pVal) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 { + iCol = (**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FiCol + int32(1) + (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + **(**uintptr)(__ccgo_up(bp + 64)) = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 16)), iCol) + **(**int32)(__ccgo_up(bp + 56)) = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp + 16)), iCol) + } + } + if **(**int32)(__ccgo_up(bp + 40)) == SQLITE_OK { + _sqlite3Fts5SetLocale(tls, pConfig, **(**uintptr)(__ccgo_up(bp + 64)), **(**int32)(__ccgo_up(bp + 56))) + **(**int32)(__ccgo_up(bp + 40)) = _sqlite3Fts5Tokenize(tls, pConfig, int32(FTS5_TOKENIZE_DOCUMENT), **(**uintptr)(__ccgo_up(bp + 48)), **(**int32)(__ccgo_up(bp + 44)), bp+24, __ccgo_fp(_fts5StorageInsertCallback)) + _sqlite3Fts5ClearLocale(tls, pConfig) + } + } + _sqlite3Fts5BufferAppendVarint(tls, bp+40, bp, int64((**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FszCol)) + **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr((**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FiCol)*8)) += int64((**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FszCol) + goto _1 + _1: + ; + (**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FiCol = (**(**TFts5InsertCtx)(__ccgo_up(bp + 24))).FiCol + 1 + } + (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow = (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow + 1 + if **(**int32)(__ccgo_up(bp + 40)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 40)) = _fts5StorageInsertDocsize(tls, p, iRowid, bp) + } + } + Xsqlite3_free(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp) + rc2 = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp + 16))) + if **(**int32)(__ccgo_up(bp + 40)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 40)) = rc2 + } + /* Write the averages record */ + if **(**int32)(__ccgo_up(bp + 40)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 40)) = _fts5StorageSaveTotals(tls, p) + } + return **(**int32)(__ccgo_up(bp + 40)) +} + +// C documentation +// +// /* +// ** Open a journal file. +// ** +// ** The behaviour of the journal file depends on the value of parameter +// ** nSpill. If nSpill is 0, then the journal file is always create and +// ** accessed using the underlying VFS. If nSpill is less than zero, then +// ** all content is always stored in main-memory. Finally, if nSpill is a +// ** positive value, then the journal file is initially created in-memory +// ** but may be flushed to disk later on. In this case the journal file is +// ** flushed to disk either when it grows larger than nSpill bytes in size, +// ** or when sqlite3JournalCreate() is called. +// */ +func _sqlite3JournalOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pJfd uintptr, flags int32, nSpill int32) (r int32) { + var p uintptr + _ = p + p = pJfd + /* Zero the file-handle object. If nSpill was passed zero, initialize + ** it using the sqlite3OsOpen() function of the underlying VFS. In this + ** case none of the code in this module is executed as a result of calls + ** made on the journal file-handle. */ + libc.Xmemset(tls, p, 0, uint64(80)) + if nSpill == 0 { + return _sqlite3OsOpen(tls, pVfs, zName, pJfd, flags, uintptr(0)) + } + if nSpill > 0 { + (*TMemJournal)(unsafe.Pointer(p)).FnChunkSize = nSpill + } else { + (*TMemJournal)(unsafe.Pointer(p)).FnChunkSize = libc.Int32FromUint64(libc.Uint64FromInt32(libc.Int32FromInt32(8)+libc.Int32FromInt32(MEMJOURNAL_DFLT_FILECHUNKSIZE)) - libc.Uint64FromInt64(16)) + } + (*Tsqlite3_file)(unsafe.Pointer(pJfd)).FpMethods = uintptr(unsafe.Pointer(&_MemJournalMethods)) + (*TMemJournal)(unsafe.Pointer(p)).FnSpill = nSpill + (*TMemJournal)(unsafe.Pointer(p)).Fflags = flags + (*TMemJournal)(unsafe.Pointer(p)).FzJournal = zName + (*TMemJournal)(unsafe.Pointer(p)).FpVfs = pVfs + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Allocate a KeyInfo object sufficient for an index of N key columns and +// ** X extra columns. +// */ +func _sqlite3KeyInfoAlloc(tls *libc.TLS, db uintptr, N int32, X int32) (r uintptr) { + var nExtra int32 + var p uintptr + _, _ = nExtra, p + nExtra = libc.Int32FromUint64(libc.Uint64FromInt32(N+X) * (libc.Uint64FromInt64(8) + libc.Uint64FromInt32(1))) + if N+X > int32(0xffff) { + return _sqlite3OomFault(tls, db) + } + p = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(0))*libc.Uint64FromInt64(8)+libc.Uint64FromInt32(nExtra))) + if p != 0 { + (*TKeyInfo)(unsafe.Pointer(p)).FaSortFlags = p + 32 + uintptr(N+X)*8 + (*TKeyInfo)(unsafe.Pointer(p)).FnKeyField = libc.Uint16FromInt32(N) + (*TKeyInfo)(unsafe.Pointer(p)).FnAllField = libc.Uint16FromInt32(N + X) + (*TKeyInfo)(unsafe.Pointer(p)).Fenc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + (*TKeyInfo)(unsafe.Pointer(p)).Fdb = db + (*TKeyInfo)(unsafe.Pointer(p)).FnRef = uint32(1) + libc.Xmemset(tls, p+32, 0, libc.Uint64FromInt32(nExtra)) + } else { + return _sqlite3OomFault(tls, db) + } + return p +} + +// C documentation +// +// /* +// ** Convert a double into a LogEst +// ** In other words, compute an approximation for 10*log2(x). +// */ +func _sqlite3LogEstFromDouble(tls *libc.TLS, _x float64) (r TLogEst) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*float64)(unsafe.Pointer(bp)) = _x + var e TLogEst + var _ /* a at bp+8 */ Tu64 + _ = e + if **(**float64)(__ccgo_up(bp)) <= libc.Float64FromInt32(1) { + return 0 + } + if **(**float64)(__ccgo_up(bp)) <= libc.Float64FromInt32(2000000000) { + return _sqlite3LogEst(tls, uint64(**(**float64)(__ccgo_up(bp)))) + } + libc.Xmemcpy(tls, bp+8, bp, uint64(8)) + e = libc.Int16FromUint64(**(**Tu64)(__ccgo_up(bp + 8))>>libc.Int32FromInt32(52) - uint64(1022)) + return int16(int32(e) * int32(10)) +} + +func _sqlite3OsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) (r int32) { + if _sqlite3Config.FiPrngSeed != 0 { + libc.Xmemset(tls, zBufOut, 0, libc.Uint64FromInt32(nByte)) + if nByte > libc.Int32FromInt64(4) { + nByte = int32(4) + } + libc.Xmemcpy(tls, zBufOut, uintptr(unsafe.Pointer(&_sqlite3Config))+432, libc.Uint64FromInt32(nByte)) + return SQLITE_OK + } else { + return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxRandomness})))(tls, pVfs, nByte, zBufOut) + } + return r +} + +// C documentation +// +// /* +// ** Allocate an Expr node which joins as many as two subtrees. +// ** +// ** One or both of the subtrees can be NULL. Return a pointer to the new +// ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed, +// ** free the subtrees and return NULL. +// */ +func _sqlite3PExpr(tls *libc.TLS, pParse uintptr, op int32, pLeft uintptr, pRight uintptr) (r uintptr) { + var p uintptr + _ = p + p = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(72)) + if p != 0 { + libc.Xmemset(tls, p, 0, uint64(72)) + (*TExpr)(unsafe.Pointer(p)).Fop = libc.Uint8FromInt32(op & int32(0xff)) + (*TExpr)(unsafe.Pointer(p)).FiAgg = int16(-int32(1)) + _sqlite3ExprAttachSubtrees(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p, pLeft, pRight) + _sqlite3ExprCheckHeight(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FnHeight) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pLeft) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pRight) + } + return p +} + +// C documentation +// +// /* +// ** Read the first N bytes from the beginning of the file into memory +// ** that pDest points to. +// ** +// ** If the pager was opened on a transient file (zFilename==""), or +// ** opened on a file less than N bytes in size, the output buffer is +// ** zeroed and SQLITE_OK returned. The rationale for this is that this +// ** function is used to read database headers, and a new transient or +// ** zero sized database has a header than consists entirely of zeroes. +// ** +// ** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered, +// ** the error code is returned to the caller and the contents of the +// ** output buffer undefined. +// */ +func _sqlite3PagerReadFileheader(tls *libc.TLS, pPager uintptr, N int32, pDest uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + libc.Xmemset(tls, pDest, 0, libc.Uint64FromInt32(N)) + /* This routine is only called by btree immediately after creating + ** the Pager object. There has not been an opportunity to transition + ** to WAL mode yet. + */ + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) { + rc = _sqlite3OsRead(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, pDest, N, 0) + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)< PAGER_OPEN && (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) { + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, bp) + } + if rc == SQLITE_OK { + /* 8 bytes of zeroed overrun space is sufficient so that the b-tree + * cell header parser will never run off the end of the allocation */ + pNew = _sqlite3PageMalloc(tls, libc.Int32FromUint32(pageSize+uint32(8))) + if !(pNew != 0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pNew+uintptr(pageSize), 0, uint64(8)) + } + } + if rc == SQLITE_OK { + _pager_reset(tls, pPager) + rc = _sqlite3PcacheSetPageSize(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, libc.Int32FromUint32(pageSize)) + } + if rc == SQLITE_OK { + _sqlite3PageFree(tls, (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace) + (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace = pNew + (*TPager)(unsafe.Pointer(pPager)).FdbSize = libc.Uint32FromInt64((**(**Ti64)(__ccgo_up(bp)) + libc.Int64FromUint32(pageSize) - libc.Int64FromInt32(1)) / libc.Int64FromUint32(pageSize)) + (*TPager)(unsafe.Pointer(pPager)).FpageSize = libc.Int64FromUint32(pageSize) + (*TPager)(unsafe.Pointer(pPager)).FlckPgno = libc.Uint32FromInt32(_sqlite3PendingByte)/pageSize + uint32(1) + } else { + _sqlite3PageFree(tls, pNew) + } + } + **(**Tu32)(__ccgo_up(pPageSize)) = libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) + if rc == SQLITE_OK { + if nReserve < 0 { + nReserve = int32((*TPager)(unsafe.Pointer(pPager)).FnReserve) + } + (*TPager)(unsafe.Pointer(pPager)).FnReserve = int16(nReserve) + _pagerFixMaplimit(tls, pPager) + } + return rc +} + +// C documentation +// +// /* +// ** Create a new PCache object. Storage space to hold the object +// ** has already been allocated and is passed in as the p pointer. +// ** The caller discovers how much space needs to be allocated by +// ** calling sqlite3PcacheSize(). +// ** +// ** szExtra is some extra space allocated for each page. The first +// ** 8 bytes of the extra space will be zeroed as the page is allocated, +// ** but remaining content will be uninitialized. Though it is opaque +// ** to this module, the extra space really ends up being the MemPage +// ** structure in the pager. +// */ +func _sqlite3PcacheOpen(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32, __ccgo_fp_xStress uintptr, pStress uintptr, p uintptr) (r int32) { + libc.Xmemset(tls, p, 0, uint64(80)) + (*TPCache)(unsafe.Pointer(p)).FszPage = int32(1) + (*TPCache)(unsafe.Pointer(p)).FszExtra = szExtra + /* First 8 bytes will be zeroed */ + (*TPCache)(unsafe.Pointer(p)).FbPurgeable = libc.Uint8FromInt32(bPurgeable) + (*TPCache)(unsafe.Pointer(p)).FeCreate = uint8(2) + (*TPCache)(unsafe.Pointer(p)).FxStress = __ccgo_fp_xStress + (*TPCache)(unsafe.Pointer(p)).FpStress = pStress + (*TPCache)(unsafe.Pointer(p)).FszCache = int32(100) + (*TPCache)(unsafe.Pointer(p)).FszSpill = int32(1) + return _sqlite3PcacheSetPageSize(tls, p, szPage) +} + +// C documentation +// +// /* +// ** Drop every cache entry whose page number is greater than "pgno". The +// ** caller must ensure that there are no outstanding references to any pages +// ** other than page 1 with a page number greater than pgno. +// ** +// ** If there is a reference to page 1 and the pgno parameter passed to this +// ** function is 0, then the data area associated with page 1 is zeroed, but +// ** the page object is not dropped. +// */ +func _sqlite3PcacheTruncate(tls *libc.TLS, pCache uintptr, pgno TPgno) { + var p, pNext, pPage1 uintptr + _, _, _ = p, pNext, pPage1 + if (*TPCache)(unsafe.Pointer(pCache)).FpCache != 0 { + p = (*TPCache)(unsafe.Pointer(pCache)).FpDirty + for { + if !(p != 0) { + break + } + pNext = (*TPgHdr)(unsafe.Pointer(p)).FpDirtyNext + /* This routine never gets call with a positive pgno except right + ** after sqlite3PcacheCleanAll(). So if there are dirty pages, + ** it must be that pgno==0. + */ + if (*TPgHdr)(unsafe.Pointer(p)).Fpgno > pgno { + _sqlite3PcacheMakeClean(tls, p) + } + goto _1 + _1: + ; + p = pNext + } + if pgno == uint32(0) && (*TPCache)(unsafe.Pointer(pCache)).FnRefSum != 0 { + pPage1 = (*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxFetch})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, uint32(1), 0) + if pPage1 != 0 { /* Page 1 is always available in cache, because + ** pCache->nRefSum>0 */ + libc.Xmemset(tls, (*Tsqlite3_pcache_page)(unsafe.Pointer(pPage1)).FpBuf, 0, libc.Uint64FromInt32((*TPCache)(unsafe.Pointer(pCache)).FszPage)) + pgno = uint32(1) + } + } + (*(*func(*libc.TLS, uintptr, uint32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxTruncate})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, pgno+uint32(1)) + } +} + +// C documentation +// +// /* +// ** Check to see if pExpr references any tables in pSrcList. +// ** Possible return values: +// ** +// ** 1 pExpr does references a table in pSrcList. +// ** +// ** 0 pExpr references some table that is not defined in either +// ** pSrcList or in subqueries of pExpr itself. +// ** +// ** -1 pExpr only references no tables at all, or it only +// ** references tables defined in subqueries of pExpr itself. +// ** +// ** As currently used, pExpr is always an aggregate function call. That +// ** fact is exploited for efficiency. +// */ +func _sqlite3ReferencesSrcList(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSrcList uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var _ /* w at bp+0 */ TWalker + var _ /* x at bp+48 */ TRefSrcList + libc.Xmemset(tls, bp, 0, uint64(48)) + libc.Xmemset(tls, bp+48, 0, uint64(32)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprRefToSrcList) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_selectRefEnter) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = __ccgo_fp(_selectRefLeave) + *(*uintptr)(unsafe.Pointer(bp + 40)) = bp + 48 + (**(**TRefSrcList)(__ccgo_up(bp + 48))).Fdb = (*TParse)(unsafe.Pointer(pParse)).Fdb + (**(**TRefSrcList)(__ccgo_up(bp + 48))).FpRef = pSrcList + _sqlite3WalkExprList(tls, bp, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3WalkExprList(tls, bp, *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32))) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3WalkExpr(tls, bp, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpFilter) + } + if (**(**TRefSrcList)(__ccgo_up(bp + 48))).FaiExclude != 0 { + _sqlite3DbNNFreeNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (**(**TRefSrcList)(__ccgo_up(bp + 48))).FaiExclude) + } + if libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode)&int32(0x01) != 0 { + return int32(1) + } else { + if (**(**TWalker)(__ccgo_up(bp))).FeCode != 0 { + return 0 + } else { + return -int32(1) + } + } + return r +} + +// C documentation +// +// /* +// ** Free all resources held by the schema structure. The void* argument points +// ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the +// ** pointer itself, it just cleans up subsidiary resources (i.e. the contents +// ** of the schema hash tables). +// ** +// ** The Schema.cache_size variable is not cleared. +// */ +func _sqlite3SchemaClear(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(912) + defer tls.Free(912) + var pElem, pSchema, pTab, v3 uintptr + var _ /* temp1 at bp+0 */ THash + var _ /* temp2 at bp+24 */ THash + var _ /* xdb at bp+48 */ Tsqlite3 + _, _, _, _ = pElem, pSchema, pTab, v3 + pSchema = p + libc.Xmemset(tls, bp+48, 0, uint64(864)) + **(**THash)(__ccgo_up(bp)) = (*TSchema)(unsafe.Pointer(pSchema)).FtblHash + **(**THash)(__ccgo_up(bp + 24)) = (*TSchema)(unsafe.Pointer(pSchema)).FtrigHash + _sqlite3HashInit(tls, pSchema+56) + _sqlite3HashClear(tls, pSchema+32) + pElem = (*THash)(unsafe.Pointer(bp + 24)).Ffirst + for { + if !(pElem != 0) { + break + } + _sqlite3DeleteTrigger(tls, bp+48, (*THashElem)(unsafe.Pointer(pElem)).Fdata) + goto _1 + _1: + ; + pElem = (*THashElem)(unsafe.Pointer(pElem)).Fnext + } + _sqlite3HashClear(tls, bp+24) + _sqlite3HashInit(tls, pSchema+8) + pElem = (*THash)(unsafe.Pointer(bp)).Ffirst + for { + if !(pElem != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(pElem)).Fdata + _sqlite3DeleteTable(tls, bp+48, pTab) + goto _2 + _2: + ; + pElem = (*THashElem)(unsafe.Pointer(pElem)).Fnext + } + _sqlite3HashClear(tls, bp) + _sqlite3HashClear(tls, pSchema+80) + (*TSchema)(unsafe.Pointer(pSchema)).FpSeqTab = uintptr(0) + if libc.Int32FromUint16((*TSchema)(unsafe.Pointer(pSchema)).FschemaFlags)&int32(DB_SchemaLoaded) != 0 { + (*TSchema)(unsafe.Pointer(pSchema)).FiGeneration = (*TSchema)(unsafe.Pointer(pSchema)).FiGeneration + 1 + } + v3 = pSchema + 114 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(DB_SchemaLoaded) | libc.Int32FromInt32(DB_ResetWanted))) +} + +// C documentation +// +// /* +// ** Check all ON clauses in pSelect to verify that they do not reference +// ** columns to the right. +// */ +func _sqlite3SelectCheckOnClauses(tls *libc.TLS, pParse uintptr, pSelect uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var ii int32 + var pItem uintptr + var _ /* sCtx at bp+48 */ TCheckOnCtx + var _ /* w at bp+0 */ TWalker + _, _ = ii, pItem + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_selectCheckOnClausesExpr) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_selectCheckOnClausesSelect) + *(*uintptr)(unsafe.Pointer(bp + 40)) = bp + 48 + libc.Xmemset(tls, bp+48, 0, uint64(24)) + (**(**TCheckOnCtx)(__ccgo_up(bp + 48))).FpSrc = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + _sqlite3WalkExpr(tls, bp, (*TSelect)(unsafe.Pointer(pSelect)).FpWhere) + **(**Tu32)(__ccgo_up(pSelect + 4)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SF_OnToWhere)) + /* Check for any table-function args that are attached to virtual tables + ** on the RHS of an outer join. They are subject to the same constraints + ** as ON clauses. */ + (**(**TCheckOnCtx)(__ccgo_up(bp + 48))).FbFuncArg = int32(1) + ii = 0 + for { + if !(ii < (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc) { + break + } + pItem = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + 8 + uintptr(ii)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x8>>3) != 0 && libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_OUTER) != 0 { + (**(**TCheckOnCtx)(__ccgo_up(bp + 48))).FiJoin = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + _sqlite3WalkExprList(tls, bp, *(*uintptr)(unsafe.Pointer(pItem + 48))) + } + goto _1 + _1: + ; + ii = ii + 1 + } +} + +// C documentation +// +// /* +// ** Append a new table name to the given SrcList. Create a new SrcList if +// ** need be. A new entry is created in the SrcList even if pTable is NULL. +// ** +// ** A SrcList is returned, or NULL if there is an OOM error or if the +// ** SrcList grows to large. The returned +// ** SrcList might be the same as the SrcList that was input or it might be +// ** a new one. If an OOM error does occurs, then the prior value of pList +// ** that is input to this routine is automatically freed. +// ** +// ** If pDatabase is not null, it means that the table has an optional +// ** database name prefix. Like this: "database.table". The pDatabase +// ** points to the table name and the pTable points to the database name. +// ** The SrcList.a[].zName field is filled with the table name which might +// ** come from pTable (if pDatabase is NULL) or from pDatabase. +// ** SrcList.a[].zDatabase is filled with the database name from pTable, +// ** or with NULL if no database is specified. +// ** +// ** In other words, if call like this: +// ** +// ** sqlite3SrcListAppend(D,A,B,0); +// ** +// ** Then B is a table name and the database name is unspecified. If called +// ** like this: +// ** +// ** sqlite3SrcListAppend(D,A,B,C); +// ** +// ** Then C is the table name and B is the database name. If C is defined +// ** then so is B. In other words, we never have a case where: +// ** +// ** sqlite3SrcListAppend(D,A,0,C); +// ** +// ** Both pTable and pDatabase are assumed to be quoted. They are dequoted +// ** before being added to the SrcList. +// */ +func _sqlite3SrcListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pTable uintptr, pDatabase uintptr) (r uintptr) { + var db, pItem, pNew uintptr + _, _, _ = db, pItem, pNew + /* Cannot have C without B */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pList == uintptr(0) { + pList = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(80))) + if pList == uintptr(0) { + return uintptr(0) + } + (*TSrcList)(unsafe.Pointer(pList)).FnAlloc = uint32(1) + (*TSrcList)(unsafe.Pointer(pList)).FnSrc = int32(1) + libc.Xmemset(tls, pList+8, 0, uint64(80)) + (*(*TSrcItem)(unsafe.Pointer(pList + 8))).FiCursor = -int32(1) + } else { + pNew = _sqlite3SrcListEnlarge(tls, pParse, pList, int32(1), (*TSrcList)(unsafe.Pointer(pList)).FnSrc) + if pNew == uintptr(0) { + _sqlite3SrcListDelete(tls, db, pList) + return uintptr(0) + } else { + pList = pNew + } + } + pItem = pList + 8 + uintptr((*TSrcList)(unsafe.Pointer(pList)).FnSrc-int32(1))*80 + if pDatabase != 0 && (*TToken)(unsafe.Pointer(pDatabase)).Fz == uintptr(0) { + pDatabase = uintptr(0) + } + if pDatabase != 0 { + (*TSrcItem)(unsafe.Pointer(pItem)).FzName = _sqlite3NameFromToken(tls, db, pDatabase) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = _sqlite3NameFromToken(tls, db, pTable) + } else { + (*TSrcItem)(unsafe.Pointer(pItem)).FzName = _sqlite3NameFromToken(tls, db, pTable) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) + } + return pList +} + +// C documentation +// +// /* +// ** Append the contents of SrcList p2 to SrcList p1 and return the resulting +// ** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2 +// ** are deleted by this function. +// */ +func _sqlite3SrcListAppendList(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uintptr) (r uintptr) { + var nOld int32 + var pNew, v1 uintptr + _, _, _ = nOld, pNew, v1 + if p2 != 0 { + nOld = (*TSrcList)(unsafe.Pointer(p1)).FnSrc + pNew = _sqlite3SrcListEnlarge(tls, pParse, p1, (*TSrcList)(unsafe.Pointer(p2)).FnSrc, nOld) + if pNew == uintptr(0) { + _sqlite3SrcListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p2) + } else { + p1 = pNew + libc.Xmemcpy(tls, p1+8+uintptr(nOld)*80, p2+8, libc.Uint64FromInt32((*TSrcList)(unsafe.Pointer(p2)).FnSrc)*uint64(80)) + v1 = p1 + 8 + 24 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JT_LTORJ)&libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(p2 + 8))).Ffg.Fjointype)) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p2) + } + } + return p1 +} + +// C documentation +// +// /* +// ** If cursors, triggers, views and subqueries are all omitted from +// ** the build, then none of the following routines, except for +// ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes +// ** called with a NULL argument. +// */ +func _sqlite3SrcListDup(tls *libc.TLS, db uintptr, p uintptr, flags int32) (r uintptr) { + var i int32 + var pNew, pNewItem, pNewSubq, pOldItem, pTab, v3 uintptr + var v1 Tu32 + _, _, _, _, _, _, _, _ = i, pNew, pNewItem, pNewSubq, pOldItem, pTab, v1, v3 + if p == uintptr(0) { + return uintptr(0) + } + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32((*TSrcList)(unsafe.Pointer(p)).FnSrc)*libc.Uint64FromInt64(80))) + if pNew == uintptr(0) { + return uintptr(0) + } + v1 = libc.Uint32FromInt32((*TSrcList)(unsafe.Pointer(p)).FnSrc) + (*TSrcList)(unsafe.Pointer(pNew)).FnAlloc = v1 + (*TSrcList)(unsafe.Pointer(pNew)).FnSrc = libc.Int32FromUint32(v1) + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(p)).FnSrc) { + break + } + pNewItem = pNew + 8 + uintptr(i)*80 + pOldItem = p + 8 + uintptr(i)*80 + (*TSrcItem)(unsafe.Pointer(pNewItem)).Ffg = (*TSrcItem)(unsafe.Pointer(pOldItem)).Ffg + if int32(*(*uint32)(unsafe.Pointer(pOldItem + 24 + 4))&0x4>>2) != 0 { + pNewSubq = _sqlite3DbMallocRaw(tls, db, uint64(24)) + if pNewSubq == uintptr(0) { + libc.SetBitFieldPtr32Uint32(pNewItem+24+4, libc.Uint32FromInt32(0), 2, 0x4) + } else { + libc.Xmemcpy(tls, pNewSubq, *(*uintptr)(unsafe.Pointer(pOldItem + 72)), uint64(24)) + (*TSubquery)(unsafe.Pointer(pNewSubq)).FpSelect = _sqlite3SelectDup(tls, db, (*TSubquery)(unsafe.Pointer(pNewSubq)).FpSelect, flags) + if (*TSubquery)(unsafe.Pointer(pNewSubq)).FpSelect == uintptr(0) { + _sqlite3DbFree(tls, db, pNewSubq) + pNewSubq = uintptr(0) + libc.SetBitFieldPtr32Uint32(pNewItem+24+4, libc.Uint32FromInt32(0), 2, 0x4) + } + } + *(*uintptr)(unsafe.Pointer(pNewItem + 72)) = pNewSubq + } else { + if int32(*(*uint32)(unsafe.Pointer(pOldItem + 24 + 4))&0x10000>>16) != 0 { + *(*uintptr)(unsafe.Pointer(pNewItem + 72)) = *(*uintptr)(unsafe.Pointer(pOldItem + 72)) + } else { + *(*uintptr)(unsafe.Pointer(pNewItem + 72)) = _sqlite3DbStrDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 72))) + } + } + (*TSrcItem)(unsafe.Pointer(pNewItem)).FzName = _sqlite3DbStrDup(tls, db, (*TSrcItem)(unsafe.Pointer(pOldItem)).FzName) + (*TSrcItem)(unsafe.Pointer(pNewItem)).FzAlias = _sqlite3DbStrDup(tls, db, (*TSrcItem)(unsafe.Pointer(pOldItem)).FzAlias) + (*TSrcItem)(unsafe.Pointer(pNewItem)).FiCursor = (*TSrcItem)(unsafe.Pointer(pOldItem)).FiCursor + if int32(*(*uint32)(unsafe.Pointer(pNewItem + 24 + 4))&0x2>>1) != 0 { + *(*uintptr)(unsafe.Pointer(pNewItem + 48)) = _sqlite3DbStrDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 48))) + } else { + if int32(*(*uint32)(unsafe.Pointer(pNewItem + 24 + 4))&0x8>>3) != 0 { + *(*uintptr)(unsafe.Pointer(pNewItem + 48)) = _sqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 48)), flags) + } else { + *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(pNewItem)).Fu1)) = *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(pOldItem)).Fu1)) + } + } + (*TSrcItem)(unsafe.Pointer(pNewItem)).Fu2 = (*TSrcItem)(unsafe.Pointer(pOldItem)).Fu2 + if int32(*(*uint32)(unsafe.Pointer(pNewItem + 24 + 4))&0x200>>9) != 0 { + (*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNewItem + 56)))).FnUse = (*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNewItem + 56)))).FnUse + 1 + } + v3 = (*TSrcItem)(unsafe.Pointer(pOldItem)).FpSTab + (*TSrcItem)(unsafe.Pointer(pNewItem)).FpSTab = v3 + pTab = v3 + if pTab != 0 { + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + } + if int32(*(*uint32)(unsafe.Pointer(pOldItem + 24 + 4))&0x800>>11) != 0 { + *(*uintptr)(unsafe.Pointer(pNewItem + 64)) = _sqlite3IdListDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 64))) + } else { + *(*uintptr)(unsafe.Pointer(pNewItem + 64)) = _sqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 64)), flags) + } + (*TSrcItem)(unsafe.Pointer(pNewItem)).FcolUsed = (*TSrcItem)(unsafe.Pointer(pOldItem)).FcolUsed + goto _2 + _2: + ; + i = i + 1 + } + return pNew +} + +// C documentation +// +// /* +// ** Enlarge the memory allocation on a StrAccum object so that it is +// ** able to accept at least N more bytes of text. +// ** +// ** Return the number of bytes of text that StrAccum is able to accept +// ** after the attempted enlargement. The value returned might be zero. +// */ +func _sqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N Ti64) (r int32) { + var szNew Ti64 + var zNew, zOld, v1 uintptr + _, _, _, _ = szNew, zNew, zOld, v1 + /* Only called if really needed */ + if (*TStrAccum)(unsafe.Pointer(p)).FaccError != 0 { + return 0 + } + if (*TStrAccum)(unsafe.Pointer(p)).FmxAlloc == uint32(0) { + _sqlite3StrAccumSetError(tls, p, uint8(SQLITE_TOOBIG)) + return libc.Int32FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnAlloc - (*TStrAccum)(unsafe.Pointer(p)).FnChar - uint32(1)) + } else { + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&int32(SQLITE_PRINTF_MALLOCED) != 0 { + v1 = (*TStrAccum)(unsafe.Pointer(p)).FzText + } else { + v1 = uintptr(0) + } + zOld = v1 + szNew = libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar) + N + int64(1) + if szNew+libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar) <= libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FmxAlloc) { + /* Force exponential buffer size growth as long as it does not overflow, + ** to avoid having to call this routine too often */ + szNew = szNew + libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar) + } + if szNew > libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FmxAlloc) { + Xsqlite3_str_reset(tls, p) + _sqlite3StrAccumSetError(tls, p, uint8(SQLITE_TOOBIG)) + return 0 + } else { + (*TStrAccum)(unsafe.Pointer(p)).FnAlloc = libc.Uint32FromInt32(int32(szNew)) + } + if (*TStrAccum)(unsafe.Pointer(p)).Fdb != 0 { + zNew = _sqlite3DbRealloc(tls, (*TStrAccum)(unsafe.Pointer(p)).Fdb, zOld, uint64((*TStrAccum)(unsafe.Pointer(p)).FnAlloc)) + } else { + zNew = _sqlite3Realloc(tls, zOld, uint64((*TStrAccum)(unsafe.Pointer(p)).FnAlloc)) + } + if zNew != 0 { + if !(libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED) != libc.Int32FromInt32(0)) && (*TStrAccum)(unsafe.Pointer(p)).FnChar > uint32(0) { + libc.Xmemcpy(tls, zNew, (*TStrAccum)(unsafe.Pointer(p)).FzText, uint64((*TStrAccum)(unsafe.Pointer(p)).FnChar)) + } + (*TStrAccum)(unsafe.Pointer(p)).FzText = zNew + (*TStrAccum)(unsafe.Pointer(p)).FnAlloc = libc.Uint32FromInt32(_sqlite3DbMallocSize(tls, (*TStrAccum)(unsafe.Pointer(p)).Fdb, zNew)) + v1 = p + 29 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) + } else { + Xsqlite3_str_reset(tls, p) + _sqlite3StrAccumSetError(tls, p, uint8(SQLITE_NOMEM)) + return 0 + } + } + return int32(N) +} + +// C documentation +// +// /* +// ** Prepare a virtual machine for execution for the first time after +// ** creating the virtual machine. This involves things such +// ** as allocating registers and initializing the program counter. +// ** After the VDBE has be prepped, it can be executed by one or more +// ** calls to sqlite3VdbeExec(). +// ** +// ** This function may be called exactly once on each virtual machine. +// ** After this routine is called the VM has been "packaged" and is ready +// ** to run. After this routine is called, further calls to +// ** sqlite3VdbeAddOp() functions are prohibited. This routine disconnects +// ** the Vdbe from the Parse object that helped generate it so that the +// ** the Vdbe becomes an independent entity and the Parse object can be +// ** destroyed. +// ** +// ** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back +// ** to its initial state after it has been run. +// */ +func _sqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, v1 uintptr + var n, nCursor, nMem, nVar int32 + var _ /* nArg at bp+0 */ int32 + var _ /* x at bp+8 */ TReusableSpace + _, _, _, _, _, _ = db, n, nCursor, nMem, nVar, v1 /* Reusable bulk memory */ + (*TVdbe)(unsafe.Pointer(p)).FpVList = (*TParse)(unsafe.Pointer(pParse)).FpVList + (*TParse)(unsafe.Pointer(pParse)).FpVList = uintptr(0) + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + nVar = int32((*TParse)(unsafe.Pointer(pParse)).FnVar) + nMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + nCursor = (*TParse)(unsafe.Pointer(pParse)).FnTab + **(**int32)(__ccgo_up(bp)) = (*TParse)(unsafe.Pointer(pParse)).FnMaxArg + /* Each cursor uses a memory cell. The first cursor (cursor 0) can + ** use aMem[0] which is not otherwise used by the VDBE program. Allocate + ** space at the end of aMem[] for cursors 1 and greater. + ** See also: allocateCursor(). + */ + nMem = nMem + nCursor + if nCursor == 0 && nMem > 0 { + nMem = nMem + 1 + } /* Space for aMem[0] even if not used */ + /* Figure out how much reusable memory is available at the end of the + ** opcode array. This extra memory will be reallocated for other elements + ** of the prepared statement. + */ + n = libc.Int32FromUint64(libc.Uint64FromInt64(24) * libc.Uint64FromInt32((*TVdbe)(unsafe.Pointer(p)).FnOp)) /* Bytes of opcode memory used */ + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FpSpace = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(n) /* Unused opcode memory */ + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnFree = int64(((*TParse)(unsafe.Pointer(pParse)).FszOpAlloc - n) & ^libc.Int32FromInt32(7)) /* Bytes of unused memory */ + _resolveP2Values(tls, p, bp) + libc.SetBitFieldPtr16Uint32(p+200, uint32(libc.BoolUint8((*TParse)(unsafe.Pointer(pParse)).FisMultiWrite != 0 && int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x2>>1)) != 0)), 5, 0x20) + if (*TParse)(unsafe.Pointer(pParse)).Fexplain != 0 { + if nMem < int32(10) { + nMem = int32(10) + } + libc.SetBitFieldPtr16Uint32(p+200, uint32((*TParse)(unsafe.Pointer(pParse)).Fexplain), 2, 0xc) + (*TVdbe)(unsafe.Pointer(p)).FnResColumn = libc.Uint16FromInt32(int32(12) - int32(4)*int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2))) + } + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + /* Memory for registers, parameters, cursor, etc, is allocated in one or two + ** passes. On the first pass, we try to reuse unused memory at the + ** end of the opcode array. If we are unable to satisfy all memory + ** requirements by reusing the opcode array tail, then the second + ** pass will fill in the remainder using a fresh memory allocation. + ** + ** This two-pass approach that reuses as much memory as possible from + ** the leftover memory at the end of the opcode array. This can significantly + ** reduce the amount of memory held by a prepared statement. + */ + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnNeeded = 0 + (*TVdbe)(unsafe.Pointer(p)).FaMem = _allocSpace(tls, bp+8, uintptr(0), libc.Int64FromUint64(libc.Uint64FromInt32(nMem)*uint64(56))) + (*TVdbe)(unsafe.Pointer(p)).FaVar = _allocSpace(tls, bp+8, uintptr(0), libc.Int64FromUint64(libc.Uint64FromInt32(nVar)*uint64(56))) + (*TVdbe)(unsafe.Pointer(p)).FapArg = _allocSpace(tls, bp+8, uintptr(0), libc.Int64FromUint64(libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(8))) + (*TVdbe)(unsafe.Pointer(p)).FapCsr = _allocSpace(tls, bp+8, uintptr(0), libc.Int64FromUint64(libc.Uint64FromInt32(nCursor)*uint64(8))) + if (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnNeeded != 0 { + v1 = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt64((**(**TReusableSpace)(__ccgo_up(bp + 8))).FnNeeded)) + (*TVdbe)(unsafe.Pointer(p)).FpFree = v1 + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FpSpace = v1 + (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnFree = (**(**TReusableSpace)(__ccgo_up(bp + 8))).FnNeeded + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + (*TVdbe)(unsafe.Pointer(p)).FaMem = _allocSpace(tls, bp+8, (*TVdbe)(unsafe.Pointer(p)).FaMem, libc.Int64FromUint64(libc.Uint64FromInt32(nMem)*uint64(56))) + (*TVdbe)(unsafe.Pointer(p)).FaVar = _allocSpace(tls, bp+8, (*TVdbe)(unsafe.Pointer(p)).FaVar, libc.Int64FromUint64(libc.Uint64FromInt32(nVar)*uint64(56))) + (*TVdbe)(unsafe.Pointer(p)).FapArg = _allocSpace(tls, bp+8, (*TVdbe)(unsafe.Pointer(p)).FapArg, libc.Int64FromUint64(libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))*uint64(8))) + (*TVdbe)(unsafe.Pointer(p)).FapCsr = _allocSpace(tls, bp+8, (*TVdbe)(unsafe.Pointer(p)).FapCsr, libc.Int64FromUint64(libc.Uint64FromInt32(nCursor)*uint64(8))) + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnVar = 0 + (*TVdbe)(unsafe.Pointer(p)).FnCursor = 0 + (*TVdbe)(unsafe.Pointer(p)).FnMem = 0 + } else { + (*TVdbe)(unsafe.Pointer(p)).FnCursor = nCursor + (*TVdbe)(unsafe.Pointer(p)).FnVar = int16(nVar) + _initMemArray(tls, (*TVdbe)(unsafe.Pointer(p)).FaVar, nVar, db, uint16(MEM_Null)) + (*TVdbe)(unsafe.Pointer(p)).FnMem = nMem + _initMemArray(tls, (*TVdbe)(unsafe.Pointer(p)).FaMem, nMem, db, uint16(MEM_Undefined)) + libc.Xmemset(tls, (*TVdbe)(unsafe.Pointer(p)).FapCsr, 0, libc.Uint64FromInt32(nCursor)*uint64(8)) + } + _sqlite3VdbeRewind(tls, p) +} + +// C documentation +// +// /* +// ** Make a full copy of pFrom into pTo. Prior contents of pTo are +// ** freed before the copy is made. +// */ +func _sqlite3VdbeMemCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr) (r int32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + rc = SQLITE_OK + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pTo)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _vdbeMemClearExternAndSetNull(tls, pTo) + } + libc.Xmemcpy(tls, pTo, pFrom, uint64(libc.UintptrFromInt32(0)+24)) + v1 = pTo + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Dyn)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pTo)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) != 0 { + if 0 == libc.Int32FromUint16((*TMem)(unsafe.Pointer(pFrom)).Fflags)&int32(MEM_Static) { + v1 = pTo + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Ephem)) + rc = _sqlite3VdbeMemMakeWriteable(tls, pTo) + } + } + return rc +} + +// C documentation +// +// /* +// ** If the given Mem* has a zero-filled tail, turn it into an ordinary +// ** blob stored in dynamically allocated space. +// */ +func _sqlite3VdbeMemExpandBlob(tls *libc.TLS, pMem uintptr) (r int32) { + var nByte int32 + var v1 uintptr + _, _ = nByte, v1 + /* Set nByte to the number of bytes required to store the expanded blob. */ + nByte = (*TMem)(unsafe.Pointer(pMem)).Fn + *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pMem)).Fu)) + if nByte <= 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Blob) == 0 { + return SQLITE_OK + } + nByte = int32(1) + } + if _sqlite3VdbeMemGrow(tls, pMem, nByte, int32(1)) != 0 { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, (*TMem)(unsafe.Pointer(pMem)).Fz+uintptr((*TMem)(unsafe.Pointer(pMem)).Fn), 0, libc.Uint64FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pMem)).Fu)))) + **(**int32)(__ccgo_up(pMem + 16)) += *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pMem)).Fu)) + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Zero) | libc.Int32FromInt32(MEM_Term))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Make sure pMem->z points to a writable allocation of at least n bytes. +// ** +// ** If the bPreserve argument is true, then copy of the content of +// ** pMem->z into the new allocation. pMem must be either a string or +// ** blob if bPreserve is true. If bPreserve is false, any prior content +// ** in pMem->z is discarded. +// */ +func _sqlite3VdbeMemGrow(tls *libc.TLS, pMem uintptr, n int32, bPreserve int32) (r int32) { + var v1 uintptr + _ = v1 + /* If the bPreserve flag is set to true, then the memory cell must already + ** contain a valid string or blob value. */ + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc > 0 && bPreserve != 0 && (*TMem)(unsafe.Pointer(pMem)).Fz == (*TMem)(unsafe.Pointer(pMem)).FzMalloc { + if (*TMem)(unsafe.Pointer(pMem)).Fdb != 0 { + v1 = _sqlite3DbReallocOrFree(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).Fz, libc.Uint64FromInt32(n)) + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = v1 + (*TMem)(unsafe.Pointer(pMem)).Fz = v1 + } else { + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = _sqlite3Realloc(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, libc.Uint64FromInt32(n)) + if (*TMem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) { + Xsqlite3_free(tls, (*TMem)(unsafe.Pointer(pMem)).Fz) + } + (*TMem)(unsafe.Pointer(pMem)).Fz = (*TMem)(unsafe.Pointer(pMem)).FzMalloc + } + bPreserve = 0 + } else { + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc > 0 { + _sqlite3DbFreeNN(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = _sqlite3DbMallocRaw(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, libc.Uint64FromInt32(n)) + } + if (*TMem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) { + _sqlite3VdbeMemSetNull(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fz = uintptr(0) + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = 0 + return int32(SQLITE_NOMEM) + } else { + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } + if bPreserve != 0 && (*TMem)(unsafe.Pointer(pMem)).Fz != 0 { + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pMem)).FzMalloc, (*TMem)(unsafe.Pointer(pMem)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pMem)).Fn)) + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Dyn) != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMem)(unsafe.Pointer(pMem)).FxDel})))(tls, (*TMem)(unsafe.Pointer(pMem)).Fz) + } + (*TMem)(unsafe.Pointer(pMem)).Fz = (*TMem)(unsafe.Pointer(pMem)).FzMalloc + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Ephem) | libc.Int32FromInt32(MEM_Static))) + return SQLITE_OK +} + +func _sqlite3VdbeMemShallowCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, srcType int32) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pTo)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _vdbeClrCopy(tls, pTo, pFrom, srcType) + return + } + libc.Xmemcpy(tls, pTo, pFrom, uint64(libc.UintptrFromInt32(0)+24)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pFrom)).Fflags)&int32(MEM_Static) == 0 { + v1 = pTo + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Ephem))) + v1 = pTo + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | srcType) + } +} + +// C documentation +// +// /* +// ** Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call, +// ** then cursor passed as the second argument should point to the row about +// ** to be update or deleted. If the application calls sqlite3_preupdate_old(), +// ** the required value will be read from the row the cursor points to. +// */ +func _sqlite3VdbePreUpdateHook(tls *libc.TLS, v uintptr, pCsr uintptr, op int32, zDb uintptr, pTab uintptr, iKey1 Ti64, iReg int32, iBlobWrite int32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var db, zTbl uintptr + var i, i1 int32 + var iKey2, v1 Ti64 + var _ /* preupdate at bp+0 */ TPreUpdate + _, _, _, _, _, _ = db, i, i1, iKey2, zTbl, v1 + db = (*TVdbe)(unsafe.Pointer(v)).Fdb + zTbl = (*TTable)(unsafe.Pointer(pTab)).FzName + libc.Xmemset(tls, bp, 0, uint64(200)) + if libc.BoolInt32((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0)) == 0 { + v1 = libc.Int64FromInt32(0) + iKey2 = v1 + iKey1 = v1 + (**(**TPreUpdate)(__ccgo_up(bp))).FpPk = _sqlite3PrimaryKeyIndex(tls, pTab) + } else { + if op == int32(SQLITE_UPDATE) { + iKey2 = *(*Ti64)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(v)).FaMem + uintptr(iReg)*56)) + } else { + iKey2 = iKey1 + } + } + (**(**TPreUpdate)(__ccgo_up(bp))).Fv = v + (**(**TPreUpdate)(__ccgo_up(bp))).FpCsr = pCsr + (**(**TPreUpdate)(__ccgo_up(bp))).Fop = op + (**(**TPreUpdate)(__ccgo_up(bp))).FiNewReg = iReg + (**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo = bp + 168 + (*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).Fdb = db + (*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).Fenc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + (*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).FnKeyField = libc.Uint16FromInt16((*TTable)(unsafe.Pointer(pTab)).FnCol) + (*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).FaSortFlags = uintptr(0) /* Indicate .aColl, .nAllField uninit */ + (**(**TPreUpdate)(__ccgo_up(bp))).FiKey1 = iKey1 + (**(**TPreUpdate)(__ccgo_up(bp))).FiKey2 = iKey2 + (**(**TPreUpdate)(__ccgo_up(bp))).FpTab = pTab + (**(**TPreUpdate)(__ccgo_up(bp))).FiBlobWrite = iBlobWrite + (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate = bp + (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, Tsqlite3_int64, Tsqlite3_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2) + (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate = uintptr(0) + _sqlite3DbFree(tls, db, (**(**TPreUpdate)(__ccgo_up(bp))).FaRecord) + _vdbeFreeUnpacked(tls, db, libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).FnKeyField)+int32(1), (**(**TPreUpdate)(__ccgo_up(bp))).FpUnpacked) + _vdbeFreeUnpacked(tls, db, libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((**(**TPreUpdate)(__ccgo_up(bp))).FpKeyinfo)).FnKeyField)+int32(1), (**(**TPreUpdate)(__ccgo_up(bp))).FpNewUnpacked) + _sqlite3VdbeMemRelease(tls, bp+80) + if (**(**TPreUpdate)(__ccgo_up(bp))).FaNew != 0 { + i = 0 + for { + if !(i < int32((*TVdbeCursor)(unsafe.Pointer(pCsr)).FnField)) { + break + } + _sqlite3VdbeMemRelease(tls, (**(**TPreUpdate)(__ccgo_up(bp))).FaNew+uintptr(i)*56) + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3DbNNFreeNN(tls, db, (**(**TPreUpdate)(__ccgo_up(bp))).FaNew) + } + if (**(**TPreUpdate)(__ccgo_up(bp))).FapDflt != 0 { + i1 = 0 + for { + if !(i1 < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up((**(**TPreUpdate)(__ccgo_up(bp))).FapDflt + uintptr(i1)*8))) + goto _3 + _3: + ; + i1 = i1 + 1 + } + _sqlite3DbFree(tls, db, (**(**TPreUpdate)(__ccgo_up(bp))).FapDflt) + } +} + +/************** End of vdbeaux.c *********************************************/ +/************** Begin file vdbeapi.c *****************************************/ +/* +** 2004 May 26 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code use to implement APIs that are part of the +** VDBE. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ +/* #include "opcodes.h" */ + +// C documentation +// +// /* +// ** Initialize the temporary index cursor just opened as a sorter cursor. +// ** +// ** Usually, the sorter module uses the value of (pCsr->pKeyInfo->nKeyField) +// ** to determine the number of fields that should be compared from the +// ** records being sorted. However, if the value passed as argument nField +// ** is non-zero and the sorter is able to guarantee a stable sort, nField +// ** is used instead. This is used when sorting records for a CREATE INDEX +// ** statement. In this case, keys are always delivered to the sorter in +// ** order of the primary key, which happens to be make up the final part +// ** of the records being sorted. So if the sort is stable, there is never +// ** any reason to compare PK fields and they can be ignored for a small +// ** performance boost. +// ** +// ** The sorter can guarantee a stable sort when running in single-threaded +// ** mode, but not in multi-threaded mode. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +// */ +func _sqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintptr) (r int32) { + var i, nWorker, pgsz, rc, szKeyInfo, v2 int32 + var mxCache, sz Ti64 + var pBt, pKeyInfo, pSorter, pTask, v1 uintptr + var szPma Tu32 + var v4 int64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, mxCache, nWorker, pBt, pKeyInfo, pSorter, pTask, pgsz, rc, sz, szKeyInfo, szPma, v1, v2, v4 /* Size of pSorter in bytes */ + rc = SQLITE_OK + /* Initialize the upper limit on the number of worker threads */ + if _sqlite3TempInMemory(tls, db) != 0 || libc.Int32FromUint8(_sqlite3Config.FbCoreMutex) == 0 { + nWorker = 0 + } else { + nWorker = **(**int32)(__ccgo_up(db + 136 + 11*4)) + } + /* Do not allow the total number of threads (main thread + all workers) + ** to exceed the maximum merge count */ + szKeyInfo = libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0)+32) + uint64((*TKeyInfo)(unsafe.Pointer((*TVdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo)).FnAllField)*libc.Uint64FromInt64(8)) + sz = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+96) + libc.Uint64FromInt32(nWorker+libc.Int32FromInt32(1))*libc.Uint64FromInt64(104)) + pSorter = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(sz+int64(szKeyInfo))) + *(*uintptr)(unsafe.Pointer(pCsr + 48)) = pSorter + if pSorter == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpBt + v1 = pSorter + uintptr(sz) + pKeyInfo = v1 + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpKeyInfo = v1 + libc.Xmemcpy(tls, pKeyInfo, (*TVdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo, libc.Uint64FromInt32(szKeyInfo)) + (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb = uintptr(0) + if nField != 0 && nWorker == 0 { + (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField = libc.Uint16FromInt32(nField) + } + /* It is OK that pKeyInfo reuses the aSortFlags field from pCsr->pKeyInfo, + ** since the pCsr->pKeyInfo->aSortFlags[] array is invariant and lives + ** longer that pSorter. */ + _sqlite3BtreeEnter(tls, pBt) + v2 = _sqlite3BtreeGetPageSize(tls, pBt) + pgsz = v2 + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Fpgsz = v2 + _sqlite3BtreeLeave(tls, pBt) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask = libc.Uint8FromInt32(nWorker + int32(1)) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FiPrev = libc.Uint8FromInt32(nWorker - libc.Int32FromInt32(1)) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads = libc.BoolUint8(libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > libc.Int32FromInt32(1)) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Fdb = db + i = 0 + for { + if !(i < libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) { + break + } + pTask = pSorter + 96 + uintptr(i)*104 + (*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter = pSorter + goto _3 + _3: + ; + i = i + 1 + } + if !(_sqlite3TempInMemory(tls, db) != 0) { /* Cache size in bytes*/ + szPma = _sqlite3Config.FszPma + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize = libc.Int32FromUint32(szPma * libc.Uint32FromInt32(pgsz)) + mxCache = int64((*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).Fcache_size) + if mxCache < 0 { + /* A negative cache-size value C indicates that the cache is abs(C) + ** KiB in size. */ + mxCache = mxCache * int64(-int32(1024)) + } else { + mxCache = mxCache * int64(pgsz) + } + if mxCache < int64(libc.Int32FromInt32(1)< int32(mxCache) { + v2 = (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize + } else { + v2 = int32(mxCache) + } + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize = v2 + /* Avoid large memory allocations if the application has requested + ** SQLITE_CONFIG_SMALL_MALLOC. */ + if libc.Int32FromUint8(_sqlite3Config.FbSmallMalloc) == 0 { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = pgsz + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = _sqlite3Malloc(tls, libc.Uint64FromInt32(pgsz)) + if !((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0) { + rc = int32(SQLITE_NOMEM) + } + } + } + if libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField) < int32(13) && (*(*uintptr)(unsafe.Pointer(pKeyInfo + 32)) == uintptr(0) || *(*uintptr)(unsafe.Pointer(pKeyInfo + 32)) == (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags)))&int32(KEYINFO_ORDER_BIGNULL) == 0 { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = libc.Uint8FromInt32(libc.Int32FromInt32(SORTER_TYPE_INTEGER) | libc.Int32FromInt32(SORTER_TYPE_TEXT)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Copy the current sorter key into the memory cell pOut. +// */ +func _sqlite3VdbeSorterRowkey(tls *libc.TLS, pCsr uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pKey, pSorter uintptr + var _ /* nKey at bp+0 */ int32 + _, _ = pKey, pSorter /* Sorter key to copy into pOut */ + pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 48)) + pKey = _vdbeSorterRowkey(tls, pSorter, bp) + if _sqlite3VdbeMemClearAndResize(tls, pOut, **(**int32)(__ccgo_up(bp))) != 0 { + return int32(SQLITE_NOMEM) + } + (*TMem)(unsafe.Pointer(pOut)).Fn = **(**int32)(__ccgo_up(bp)) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Blob)) + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pOut)).Fz, pKey, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Add a record to the sorter. +// */ +func _sqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aNew, pNew, pSorter, v1 uintptr + var bFlush, iListOff, nMin, rc int32 + var nNew Tsqlite3_int64 + var nPMA, nReq Ti64 + var _ /* t at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = aNew, bFlush, iListOff, nMin, nNew, nPMA, nReq, pNew, pSorter, rc, v1 + rc = SQLITE_OK /* serial type of first record field */ + pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 48)) + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint32(uint32(**(**Tu8)(__ccgo_up((*TMem)(unsafe.Pointer(pVal)).Fz + 1)))) + if **(**int32)(__ccgo_up(bp)) >= int32(0x80) { + _sqlite3GetVarint32(tls, (*TMem)(unsafe.Pointer(pVal)).Fz+1, bp) + } + if **(**int32)(__ccgo_up(bp)) > 0 && **(**int32)(__ccgo_up(bp)) < int32(10) && **(**int32)(__ccgo_up(bp)) != int32(7) { + v1 = pSorter + 92 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & libc.Int32FromInt32(SORTER_TYPE_INTEGER)) + } else { + if **(**int32)(__ccgo_up(bp)) > int32(10) && **(**int32)(__ccgo_up(bp))&int32(0x01) != 0 { + v1 = pSorter + 92 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & libc.Int32FromInt32(SORTER_TYPE_TEXT)) + } else { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = uint8(0) + } + } + /* Figure out whether or not the current contents of memory should be + ** flushed to a PMA before continuing. If so, do so. + ** + ** If using the single large allocation mode (pSorter->aMemory!=0), then + ** flush the contents of memory to a new PMA if (a) at least one value is + ** already in memory and (b) the new value will not fit in memory. + ** + ** Or, if using separate allocations for each record, flush the contents + ** of memory to a PMA if either of the following are true: + ** + ** * The total memory allocated for the in-memory list is greater + ** than (page-size * cache-size), or + ** + ** * The total memory allocated for the in-memory list is greater + ** than (page-size * 10) and sqlite3HeapNearlyFull() returns true. + */ + nReq = libc.Int64FromUint64(libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pVal)).Fn) + uint64(16)) + nPMA = int64((*TMem)(unsafe.Pointer(pVal)).Fn + _sqlite3VarintLen(tls, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pVal)).Fn))) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize != 0 { + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 { + bFlush = libc.BoolInt32((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory != 0 && int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory)+nReq > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize)) + } else { + bFlush = libc.BoolInt32((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize) || (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize) && _sqlite3HeapNearlyFull(tls) != 0) + } + if bFlush != 0 { + rc = _vdbeSorterFlushPMA(tls, pSorter) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA = 0 + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory = 0 + } + } + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA += nPMA + if nPMA > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxKeysize) { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxKeysize = int32(nPMA) + } + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 { + nMin = int32(int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory) + nReq) + if nMin > (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory { + nNew = int64(2) * int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory) + iListOff = -int32(1) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { + iListOff = int32(int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList) - int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)) + } + for nNew < int64(nMin) { + nNew = nNew * int64(2) + } + if nNew > int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize) { + nNew = int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize) + } + if nNew < int64(nMin) { + nNew = int64(nMin) + } + aNew = _sqlite3Realloc(tls, (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory, libc.Uint64FromInt64(nNew)) + if !(aNew != 0) { + return int32(SQLITE_NOMEM) + } + if iListOff >= 0 { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = aNew + uintptr(iListOff) + } + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = aNew + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = int32(nNew) + } + pNew = (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory + uintptr((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory) + v1 = pSorter + 80 + *(*int32)(unsafe.Pointer(v1)) = int32(int64(*(*int32)(unsafe.Pointer(v1))) + (nReq+libc.Int64FromInt32(7))&int64(^libc.Int32FromInt32(7))) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { + *(*int32)(unsafe.Pointer(&(*TSorterRecord)(unsafe.Pointer(pNew)).Fu)) = int32(int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList) - int64((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)) + } + } else { + pNew = _sqlite3Malloc(tls, libc.Uint64FromInt64(nReq)) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + *(*uintptr)(unsafe.Pointer(pNew + 8)) = (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList + } + libc.Xmemcpy(tls, pNew+libc.UintptrFromInt32(1)*16, (*TMem)(unsafe.Pointer(pVal)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pVal)).Fn)) + (*TSorterRecord)(unsafe.Pointer(pNew)).FnVal = (*TMem)(unsafe.Pointer(pVal)).Fn + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = pNew + return rc +} + +// C documentation +// +// /* +// ** Construct and install a Module object for a virtual table. When this +// ** routine is called, it is guaranteed that all appropriate locks are held +// ** and the module is not already part of the connection. +// ** +// ** If there already exists a module with zName, replace it with the new one. +// ** If pModule==0, then delete the module zName if it exists. +// */ +func _sqlite3VtabCreateModule(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, __ccgo_fp_xDestroy uintptr) (r uintptr) { + var nName int32 + var pDel, pMod, zCopy uintptr + _, _, _, _ = nName, pDel, pMod, zCopy + if pModule == uintptr(0) { + zCopy = zName + pMod = uintptr(0) + } else { + nName = _sqlite3Strlen30(tls, zName) + pMod = _sqlite3Malloc(tls, uint64(uint64(48)+libc.Uint64FromInt32(nName)+uint64(1))) + if pMod == uintptr(0) { + _sqlite3OomFault(tls, db) + return uintptr(0) + } + zCopy = pMod + 1*48 + libc.Xmemcpy(tls, zCopy, zName, libc.Uint64FromInt32(nName+int32(1))) + (*TModule)(unsafe.Pointer(pMod)).FzName = zCopy + (*TModule)(unsafe.Pointer(pMod)).FpModule = pModule + (*TModule)(unsafe.Pointer(pMod)).FpAux = pAux + (*TModule)(unsafe.Pointer(pMod)).FxDestroy = __ccgo_fp_xDestroy + (*TModule)(unsafe.Pointer(pMod)).FpEpoTab = uintptr(0) + (*TModule)(unsafe.Pointer(pMod)).FnRefModule = int32(1) + } + pDel = _sqlite3HashInsert(tls, db+576, zCopy, pMod) + if pDel != 0 { + if pDel == pMod { + _sqlite3OomFault(tls, db) + _sqlite3DbFree(tls, db, pDel) + pMod = uintptr(0) + } else { + _sqlite3VtabEponymousTableClear(tls, db, pDel) + _sqlite3VtabModuleUnref(tls, db, pDel) + } + } + return pMod +} + +// C documentation +// +// /* +// ** The first parameter (pDef) is a function implementation. The +// ** second parameter (pExpr) is the first argument to this function. +// ** If pExpr is a column in a virtual table, then let the virtual +// ** table implementation have an opportunity to overload the function. +// ** +// ** This routine is used to allow virtual table implementations to +// ** overload MATCH, LIKE, GLOB, and REGEXP operators. +// ** +// ** Return either the pDef argument (indicating no change) or a +// ** new FuncDef structure that is marked as ephemeral using the +// ** SQLITE_FUNC_EPHEM flag. +// */ +func _sqlite3VtabOverloadFunction(tls *libc.TLS, db uintptr, pDef uintptr, nArg int32, pExpr uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pMod, pNew, pTab, pVtab uintptr + var rc int32 + var _ /* pArg at bp+8 */ uintptr + var _ /* xSFunc at bp+0 */ uintptr + _, _, _, _, _ = pMod, pNew, pTab, pVtab, rc + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + rc = 0 + /* Check to see the left operand is a column in a virtual table */ + if pExpr == uintptr(0) { + return pDef + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLUMN) { + return pDef + } + pTab = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + if pTab == uintptr(0) { + return pDef + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + return pDef + } + pVtab = (*TVTable)(unsafe.Pointer(_sqlite3GetVTable(tls, db, pTab))).FpVtab + pMod = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule + if (*Tsqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction == uintptr(0) { + return pDef + } + /* Call the xFindFunction method on the virtual table implementation + ** to see if the implementation wants to overload this function. + ** + ** Though undocumented, we have historically always invoked xFindFunction + ** with an all lower-case function name. Continue in this tradition to + ** avoid any chance of an incompatibility. + */ + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction})))(tls, pVtab, nArg, (*TFuncDef)(unsafe.Pointer(pDef)).FzName, bp, bp+8) + if rc == 0 { + return pDef + } + /* Create a new ephemeral function definition for the overloaded + ** function */ + pNew = _sqlite3DbMallocZero(tls, db, uint64(uint64(72)+libc.Uint64FromInt32(_sqlite3Strlen30(tls, (*TFuncDef)(unsafe.Pointer(pDef)).FzName))+uint64(1))) + if pNew == uintptr(0) { + return pDef + } + **(**TFuncDef)(__ccgo_up(pNew)) = **(**TFuncDef)(__ccgo_up(pDef)) + (*TFuncDef)(unsafe.Pointer(pNew)).FzName = pNew + 1*72 + libc.Xmemcpy(tls, pNew+1*72, (*TFuncDef)(unsafe.Pointer(pDef)).FzName, libc.Uint64FromInt32(_sqlite3Strlen30(tls, (*TFuncDef)(unsafe.Pointer(pDef)).FzName)+int32(1))) + (*TFuncDef)(unsafe.Pointer(pNew)).FxSFunc = **(**uintptr)(__ccgo_up(bp)) + (*TFuncDef)(unsafe.Pointer(pNew)).FpUserData = **(**uintptr)(__ccgo_up(bp + 8)) + **(**Tu32)(__ccgo_up(pNew + 4)) |= uint32(SQLITE_FUNC_EPHEM) + return pNew +} + +// C documentation +// +// /* +// ** This routine is called to implement sqlite3_wal_checkpoint() and +// ** related interfaces. +// ** +// ** Obtain a CHECKPOINT lock and then backfill as much information as +// ** we can from WAL into the database. +// ** +// ** If parameter xBusy is not NULL, it is a pointer to a busy-handler +// ** callback. In this case this function runs a blocking checkpoint. +// */ +func _sqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, __ccgo_fp_xBusy uintptr, pBusyArg uintptr, sync_flags int32, nBuf int32, zBuf uintptr, pnLog uintptr, pnCkpt uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eMode2, rc, v1 int32 + var xBusy2 uintptr + var _ /* isChanged at bp+0 */ int32 + _, _, _, _ = eMode2, rc, xBusy2, v1 /* Return code */ + **(**int32)(__ccgo_up(bp)) = 0 /* True if a new wal-index header is loaded */ + eMode2 = eMode /* Mode to pass to walCheckpoint() */ + xBusy2 = __ccgo_fp_xBusy /* Busy handler for eMode2 */ + /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked + ** in the SQLITE_CHECKPOINT_PASSIVE mode. */ + if (*TWal)(unsafe.Pointer(pWal)).FreadOnly != 0 { + return int32(SQLITE_READONLY) + } + /* Enable blocking locks, if possible. */ + if xBusy2 != 0 { + } + /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive + ** "checkpoint" lock on the database file. + ** EVIDENCE-OF: R-10421-19736 If any other process is running a + ** checkpoint operation at the same time, the lock cannot be obtained and + ** SQLITE_BUSY is returned. + ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured, + ** it will not be invoked in this case. + */ + if eMode != -int32(1) { + rc = _walLockExclusive(tls, pWal, int32(WAL_CKPT_LOCK), int32(1)) + if rc == SQLITE_OK { + (*TWal)(unsafe.Pointer(pWal)).FckptLock = uint8(1) + /* IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART + ** and TRUNCATE modes also obtain the exclusive "writer" lock on the + ** database file. + ** + ** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained + ** immediately, and a busy-handler is configured, it is invoked and the + ** writer lock retried until either the busy-handler returns 0 or the + ** lock is successfully obtained. + */ + if eMode != SQLITE_CHECKPOINT_PASSIVE { + rc = _walBusyLock(tls, pWal, xBusy2, pBusyArg, WAL_WRITE_LOCK, int32(1)) + if rc == SQLITE_OK { + (*TWal)(unsafe.Pointer(pWal)).FwriteLock = uint8(1) + } else { + if rc == int32(SQLITE_BUSY) { + eMode2 = SQLITE_CHECKPOINT_PASSIVE + xBusy2 = uintptr(0) + rc = SQLITE_OK + } + } + } + } + } else { + rc = SQLITE_OK + } + /* Read the wal-index header. */ + if rc == SQLITE_OK { + /* For a passive checkpoint, do not re-enable blocking locks after + ** reading the wal-index header. A passive checkpoint should not block + ** or invoke the busy handler. The only lock such a checkpoint may + ** attempt to obtain is a lock on a read-slot, and it should give up + ** immediately and do a partial checkpoint if it cannot obtain it. */ + rc = _walIndexReadHdr(tls, pWal, bp) + if eMode2 > SQLITE_CHECKPOINT_PASSIVE { + } + if **(**int32)(__ccgo_up(bp)) != 0 && (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*TWal)(unsafe.Pointer(pWal)).FpDbFd)).FpMethods)).FiVersion >= int32(3) { + _sqlite3OsUnfetch(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, 0, uintptr(0)) + } + } + /* Copy data from the log to the database file. */ + if rc == SQLITE_OK { + _sqlite3FaultSim(tls, int32(660)) + if (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0 && _walPagesize(tls, pWal) != nBuf { + rc = _sqlite3CorruptError(tls, int32(71830)) + } else { + if eMode2 != -int32(1) { + rc = _walCheckpoint(tls, pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf) + } + } + /* If no error occurred, set the output variables. */ + if rc == SQLITE_OK || rc == int32(SQLITE_BUSY) { + if pnLog != 0 { + **(**int32)(__ccgo_up(pnLog)) = libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) + } + if pnCkpt != 0 { + **(**int32)(__ccgo_up(pnCkpt)) = libc.Int32FromUint32((*TWalCkptInfo)(unsafe.Pointer(_walCkptInfo(tls, pWal))).FnBackfill) + } + } + } + if **(**int32)(__ccgo_up(bp)) != 0 { + /* If a new wal-index header was loaded before the checkpoint was + ** performed, then the pager-cache associated with pWal is now + ** out of date. So zero the cached wal-index header to ensure that + ** next time the pager opens a snapshot on this database it knows that + ** the cache needs to be reset. + */ + libc.Xmemset(tls, pWal+72, 0, uint64(48)) + } + /* Release the locks. */ + _sqlite3WalEndWriteTransaction(tls, pWal) + if (*TWal)(unsafe.Pointer(pWal)).FckptLock != 0 { + _walUnlockExclusive(tls, pWal, int32(WAL_CKPT_LOCK), int32(1)) + (*TWal)(unsafe.Pointer(pWal)).FckptLock = uint8(0) + } + if rc == SQLITE_OK && eMode != eMode2 { + v1 = int32(SQLITE_BUSY) + } else { + v1 = rc + } + return v1 +} + +// C documentation +// +// /* +// ** Return ONEPASS_OFF (0) if an UPDATE or DELETE statement is unable to +// ** operate directly on the rowids returned by a WHERE clause. Return +// ** ONEPASS_SINGLE (1) if the statement can operation directly because only +// ** a single row is to be changed. Return ONEPASS_MULTI (2) if the one-pass +// ** optimization can be used on multiple +// ** +// ** If the ONEPASS optimization is used (if this routine returns true) +// ** then also write the indices of open cursors used by ONEPASS +// ** into aiCur[0] and aiCur[1]. iaCur[0] gets the cursor of the data +// ** table and iaCur[1] gets the cursor used by an auxiliary index. +// ** Either value may be -1, indicating that cursor is not used. +// ** Any cursors returned will have been opened for writing. +// ** +// ** aiCur[0] and aiCur[1] both get -1 if the where-clause logic is +// ** unable to use the ONEPASS optimization. +// */ +func _sqlite3WhereOkOnePass(tls *libc.TLS, pWInfo uintptr, aiCur uintptr) (r int32) { + libc.Xmemcpy(tls, aiCur, pWInfo+40, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)) + return libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) +} + +// C documentation +// +// /* +// ** sqlite3WhereBegin() has already been called for the SELECT statement +// ** passed as the second argument when this function is invoked. It generates +// ** code to populate the Window.regResult register for each window function +// ** and invoke the sub-routine at instruction addrGosub once for each row. +// ** sqlite3WhereEnd() is always called before returning. +// ** +// ** This function handles several different types of window frames, which +// ** require slightly different processing. The following pseudo code is +// ** used to implement window frames of the form: +// ** +// ** ROWS BETWEEN PRECEDING AND FOLLOWING +// ** +// ** Other window frame types use variants of the following: +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** +// ** if( first row of partition ){ +// ** // Rewind three cursors, all open on the eph table. +// ** Rewind(csrEnd); +// ** Rewind(csrStart); +// ** Rewind(csrCurrent); +// ** +// ** regEnd = // FOLLOWING expression +// ** regStart = // PRECEDING expression +// ** }else{ +// ** // First time this branch is taken, the eph table contains two +// ** // rows. The first row in the partition, which all three cursors +// ** // currently point to, and the following row. +// ** AGGSTEP +// ** if( (regEnd--)<=0 ){ +// ** RETURN_ROW +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** RETURN ROW +// ** if( csrCurrent is EOF ) break; +// ** if( (regStart--)<=0 ){ +// ** AggInverse(csrStart) +// ** Next(csrStart) +// ** } +// ** } +// ** +// ** The pseudo-code above uses the following shorthand: +// ** +// ** AGGSTEP: invoke the aggregate xStep() function for each window function +// ** with arguments read from the current row of cursor csrEnd, then +// ** step cursor csrEnd forward one row (i.e. sqlite3BtreeNext()). +// ** +// ** RETURN_ROW: return a row to the caller based on the contents of the +// ** current row of csrCurrent and the current state of all +// ** aggregates. Then step cursor csrCurrent forward one row. +// ** +// ** AGGINVERSE: invoke the aggregate xInverse() function for each window +// ** functions with arguments read from the current row of cursor +// ** csrStart. Then step csrStart forward one row. +// ** +// ** There are two other ROWS window frames that are handled significantly +// ** differently from the above - "BETWEEN PRECEDING AND PRECEDING" +// ** and "BETWEEN FOLLOWING AND FOLLOWING". These are special +// ** cases because they change the order in which the three cursors (csrStart, +// ** csrCurrent and csrEnd) iterate through the ephemeral table. Cases that +// ** use UNBOUNDED or CURRENT ROW are much simpler variations on one of these +// ** three. +// ** +// ** ROWS BETWEEN PRECEDING AND PRECEDING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else{ +// ** if( (regEnd--)<=0 ){ +// ** AGGSTEP +// ** } +// ** RETURN_ROW +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** flush: +// ** if( (regEnd--)<=0 ){ +// ** AGGSTEP +// ** } +// ** RETURN_ROW +// ** +// ** +// ** ROWS BETWEEN FOLLOWING AND FOLLOWING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = regEnd - +// ** }else{ +// ** AGGSTEP +// ** if( (regEnd--)<=0 ){ +// ** RETURN_ROW +// ** } +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** if( (regEnd--)<=0 ){ +// ** RETURN_ROW +// ** if( eof ) break; +// ** } +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** if( eof ) break +// ** } +// ** } +// ** while( !eof csrCurrent ){ +// ** RETURN_ROW +// ** } +// ** +// ** For the most part, the patterns above are adapted to support UNBOUNDED by +// ** assuming that it is equivalent to "infinity PRECEDING/FOLLOWING" and +// ** CURRENT ROW by assuming that it is equivalent to "0 PRECEDING/FOLLOWING". +// ** This is optimized of course - branches that will never be taken and +// ** conditions that are always true are omitted from the VM code. The only +// ** exceptional case is: +// ** +// ** ROWS BETWEEN FOLLOWING AND UNBOUNDED FOLLOWING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regStart = +// ** }else{ +// ** AGGSTEP +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** if( (regStart--)<=0 ){ +// ** AGGINVERSE +// ** if( eof ) break +// ** } +// ** RETURN_ROW +// ** } +// ** while( !eof csrCurrent ){ +// ** RETURN_ROW +// ** } +// ** +// ** Also requiring special handling are the cases: +// ** +// ** ROWS BETWEEN PRECEDING AND PRECEDING +// ** ROWS BETWEEN FOLLOWING AND FOLLOWING +// ** +// ** when (expr1 < expr2). This is detected at runtime, not by this function. +// ** To handle this case, the pseudo-code programs depicted above are modified +// ** slightly to be: +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** if( regEnd < regStart ){ +// ** RETURN_ROW +// ** delete eph table contents +// ** continue +// ** } +// ** ... +// ** +// ** The new "continue" statement in the above jumps to the next iteration +// ** of the outer loop - the one started by sqlite3WhereBegin(). +// ** +// ** The various GROUPS cases are implemented using the same patterns as +// ** ROWS. The VM code is modified slightly so that: +// ** +// ** 1. The else branch in the main loop is only taken if the row just +// ** added to the ephemeral table is the start of a new group. In +// ** other words, it becomes: +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else if( new group ){ +// ** ... +// ** } +// ** } +// ** +// ** 2. Instead of processing a single row, each RETURN_ROW, AGGSTEP or +// ** AGGINVERSE step processes the current row of the relevant cursor and +// ** all subsequent rows belonging to the same group. +// ** +// ** RANGE window frames are a little different again. As for GROUPS, the +// ** main loop runs once per group only. And RETURN_ROW, AGGSTEP and AGGINVERSE +// ** deal in groups instead of rows. As for ROWS and GROUPS, there are three +// ** basic cases: +// ** +// ** RANGE BETWEEN PRECEDING AND FOLLOWING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else{ +// ** AGGSTEP +// ** while( (csrCurrent.key + regEnd) < csrEnd.key ){ +// ** RETURN_ROW +// ** while( csrStart.key + regStart) < csrCurrent.key ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** RETURN ROW +// ** if( csrCurrent is EOF ) break; +// ** while( csrStart.key + regStart) < csrCurrent.key ){ +// ** AGGINVERSE +// ** } +// ** } +// ** } +// ** +// ** In the above notation, "csr.key" means the current value of the ORDER BY +// ** expression (there is only ever 1 for a RANGE that uses an FOLLOWING +// ** or PRECEDING AND PRECEDING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else{ +// ** while( (csrEnd.key + regEnd) <= csrCurrent.key ){ +// ** AGGSTEP +// ** } +// ** while( (csrStart.key + regStart) < csrCurrent.key ){ +// ** AGGINVERSE +// ** } +// ** RETURN_ROW +// ** } +// ** } +// ** flush: +// ** while( (csrEnd.key + regEnd) <= csrCurrent.key ){ +// ** AGGSTEP +// ** } +// ** while( (csrStart.key + regStart) < csrCurrent.key ){ +// ** AGGINVERSE +// ** } +// ** RETURN_ROW +// ** +// ** RANGE BETWEEN FOLLOWING AND FOLLOWING +// ** +// ** ... loop started by sqlite3WhereBegin() ... +// ** if( new partition ){ +// ** Gosub flush +// ** } +// ** Insert new row into eph table. +// ** if( first row of partition ){ +// ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) +// ** regEnd = +// ** regStart = +// ** }else{ +// ** AGGSTEP +// ** while( (csrCurrent.key + regEnd) < csrEnd.key ){ +// ** while( (csrCurrent.key + regStart) > csrStart.key ){ +// ** AGGINVERSE +// ** } +// ** RETURN_ROW +// ** } +// ** } +// ** } +// ** flush: +// ** AGGSTEP +// ** while( 1 ){ +// ** while( (csrCurrent.key + regStart) > csrStart.key ){ +// ** AGGINVERSE +// ** if( eof ) break "while( 1 )" loop. +// ** } +// ** RETURN_ROW +// ** } +// ** while( !eof csrCurrent ){ +// ** RETURN_ROW +// ** } +// ** +// ** The text above leaves out many details. Refer to the code and comments +// ** below for a more complete picture. +// */ +func _sqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uintptr, regGosub int32, addrGosub int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addr, addr1, addrBreak, addrBreak1, addrBreak2, addrBreak3, addrEmpty, addrGe, addrGosubFlush, addrInteger, addrNe, addrNext, addrStart, addrStart1, bRPS, bRPS1, csrInput, csrWrite, iInput, lbl, lbl1, lblWhereEnd, nInput, nPart, nPeer, op, regEnd, regFlushPart, regNew, regNewPart, regNewPeer, regPeer, regRecord, regStart, v1 int32 + var pKeyInfo, pMWin, pOrderBy, pPart, v, v2 uintptr + var _ /* s at bp+0 */ TWindowCodeArg + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addr1, addrBreak, addrBreak1, addrBreak2, addrBreak3, addrEmpty, addrGe, addrGosubFlush, addrInteger, addrNe, addrNext, addrStart, addrStart1, bRPS, bRPS1, csrInput, csrWrite, iInput, lbl, lbl1, lblWhereEnd, nInput, nPart, nPeer, op, pKeyInfo, pMWin, pOrderBy, pPart, regEnd, regFlushPart, regNew, regNewPart, regNewPeer, regPeer, regRecord, regStart, v, v1, v2 + pMWin = (*TSelect)(unsafe.Pointer(p)).FpWin + pOrderBy = (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy + v = _sqlite3GetVdbe(tls, pParse) /* Cursor used to write to eph. table */ + csrInput = (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FiCursor /* Cursor of sub-select */ + nInput = int32((*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab)).FnCol) /* Address of OP_Ne */ + addrGosubFlush = 0 /* Address of OP_Gosub to flush: */ + addrInteger = 0 /* regNew array in record form */ + regNewPeer = 0 /* Peer values for new row (part of regNew) */ + regPeer = 0 /* Peer values for current row */ + regFlushPart = 0 /* Label just before sqlite3WhereEnd() code */ + regStart = 0 /* Value of PRECEDING */ + regEnd = 0 /* Value of FOLLOWING */ + lblWhereEnd = _sqlite3VdbeMakeLabel(tls, pParse) + /* Fill in the context object */ + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TWindowCodeArg)(__ccgo_up(bp))).FpParse = pParse + (**(**TWindowCodeArg)(__ccgo_up(bp))).FpMWin = pMWin + (**(**TWindowCodeArg)(__ccgo_up(bp))).FpVdbe = v + (**(**TWindowCodeArg)(__ccgo_up(bp))).FregGosub = regGosub + (**(**TWindowCodeArg)(__ccgo_up(bp))).FaddrGosub = addrGosub + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr = (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr + csrWrite = (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr + int32(1) + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fstart.Fcsr = (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr + int32(2) + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Fcsr = (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr + int32(3) + /* Figure out when rows may be deleted from the ephemeral table. There + ** are four options - they may never be deleted (eDelete==0), they may + ** be deleted as soon as they are no longer part of the window frame + ** (eDelete==WINDOW_AGGINVERSE), they may be deleted as after the row + ** has been returned to the caller (WINDOW_RETURN_ROW), or they may + ** be deleted after they enter the frame (WINDOW_AGGSTEP). */ + switch libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) { + case int32(TK_FOLLOWING): + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_RANGE) && _windowExprGtZero(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpStart) != 0 { + (**(**TWindowCodeArg)(__ccgo_up(bp))).FeDelete = int32(WINDOW_RETURN_ROW) + } + case int32(TK_UNBOUNDED): + if _windowCacheFrame(tls, pMWin) == 0 { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_PRECEDING) { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_RANGE) && _windowExprGtZero(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpEnd) != 0 { + (**(**TWindowCodeArg)(__ccgo_up(bp))).FeDelete = int32(WINDOW_AGGSTEP) + } + } else { + (**(**TWindowCodeArg)(__ccgo_up(bp))).FeDelete = int32(WINDOW_RETURN_ROW) + } + } + default: + (**(**TWindowCodeArg)(__ccgo_up(bp))).FeDelete = int32(WINDOW_AGGINVERSE) + break + } + /* Allocate registers for the array of values from the sub-query, the + ** same values in record form, and the rowid used to insert said record + ** into the ephemeral table. */ + regNew = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nInput + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regRecord = v1 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid = v1 + /* If the window frame contains an " PRECEDING" or " FOLLOWING" + ** clause, allocate registers to store the results of evaluating each + ** . */ + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_PRECEDING) || libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regStart = v1 + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_PRECEDING) || libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_FOLLOWING) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regEnd = v1 + } + /* If this is not a "ROWS BETWEEN ..." frame, then allocate arrays of + ** registers to store copies of the ORDER BY expressions (peer values) + ** for the main loop, and for each cursor (start, current and end). */ + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_ROWS) { + if pOrderBy != 0 { + v1 = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr + } else { + v1 = 0 + } + nPeer = v1 + regNewPeer = regNew + (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + regNewPeer = regNewPeer + (*TExprList)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pMWin)).FpPartition)).FnExpr + } + regPeer = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPeer + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fstart.Freg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPeer + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Freg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPeer + (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Freg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPeer + } + /* Load the column values for the row returned by the sub-select + ** into an array of registers starting at regNew. Assemble them into + ** a record in register regRecord. */ + iInput = 0 + for { + if !(iInput < nInput) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), csrInput, iInput, regNew+iInput) + goto _10 + _10: + ; + iInput = iInput + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regNew, nInput, regRecord) + /* An input row has just been read into an array of registers starting + ** at regNew. If the window has a PARTITION clause, this block generates + ** VM code to check if the input row is the start of a new partition. + ** If so, it does an OP_Gosub to an address to be filled in later. The + ** address of the OP_Gosub is stored in local variable addrGosubFlush. */ + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + pPart = (*TWindow)(unsafe.Pointer(pMWin)).FpPartition + nPart = (*TExprList)(unsafe.Pointer(pPart)).FnExpr + regNewPart = regNew + (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, pPart, 0, 0) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regFlushPart = v1 + addr = _sqlite3VdbeAddOp3(tls, v, int32(OP_Compare), regNewPart, (*TWindow)(unsafe.Pointer(pMWin)).FregPart, nPart) + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addr+int32(2), addr+int32(4), addr+int32(2)) + addrGosubFlush = _sqlite3VdbeAddOp1(tls, v, int32(OP_Gosub), regFlushPart) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regNewPart, (*TWindow)(unsafe.Pointer(pMWin)).FregPart, nPart-int32(1)) + } + /* Insert the new row into the ephemeral table */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), csrWrite, (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), csrWrite, regRecord, (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid) + addrNe = _sqlite3VdbeAddOp3(tls, v, int32(OP_Ne), (*TWindow)(unsafe.Pointer(pMWin)).FregOne, 0, (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid) + /* This block is run for the first row of each partition */ + (**(**TWindowCodeArg)(__ccgo_up(bp))).FregArg = _windowInitAccum(tls, pParse, pMWin) + if regStart != 0 { + _sqlite3ExprCode(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpStart, regStart) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + v1 = int32(3) + } else { + v1 = 0 + } + _windowCheckValue(tls, pParse, regStart, 0+v1) + } + if regEnd != 0 { + _sqlite3ExprCode(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpEnd, regEnd) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + v1 = int32(3) + } else { + v1 = 0 + } + _windowCheckValue(tls, pParse, regEnd, int32(1)+v1) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_RANGE) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) && regStart != 0 { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + v1 = int32(OP_Ge) + } else { + v1 = int32(OP_Le) + } + op = v1 + addrGe = _sqlite3VdbeAddOp3(tls, v, op, regStart, 0, regEnd) + /* NeverNull because bound */ + /* values previously checked */ + _windowAggFinal(tls, bp, 0) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr) + _windowReturnOneRow(tls, bp) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResetSorter), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, lblWhereEnd) + _sqlite3VdbeJumpHere(tls, v, addrGe) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_RANGE) && regEnd != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Subtract), regStart, regEnd, regStart) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) != int32(TK_UNBOUNDED) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fstart.Fcsr) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Fcsr) + if regPeer != 0 && pOrderBy != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regNewPeer, regPeer, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr-int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regPeer, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fstart.Freg, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr-int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regPeer, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Freg, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr-int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regPeer, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Freg, (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr-int32(1)) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, lblWhereEnd) + _sqlite3VdbeJumpHere(tls, v, addrNe) + /* Beginning of the block executed for the second and subsequent rows. */ + if regPeer != 0 { + _windowIfNewPeer(tls, pParse, pOrderBy, regNewPeer, regPeer, lblWhereEnd) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), 0, 0) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) != int32(TK_UNBOUNDED) { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + lbl = _sqlite3VdbeMakeLabel(tls, pParse) + addrNext = _sqlite3VdbeCurrentAddr(tls, v) + _windowCodeRangeTest(tls, bp, int32(OP_Ge), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr, regEnd, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Fcsr, lbl) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrNext) + _sqlite3VdbeResolveLabel(tls, v, lbl) + } else { + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), regEnd, 0) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + } + } + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_PRECEDING) { + bRPS = libc.BoolInt32(libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_PRECEDING) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE)) + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), regEnd, 0) + if bRPS != 0 { + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + } + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + if !(bRPS != 0) { + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + } + } else { + addr1 = 0 + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), 0, 0) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) != int32(TK_UNBOUNDED) { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + lbl1 = 0 + addr1 = _sqlite3VdbeCurrentAddr(tls, v) + if regEnd != 0 { + lbl1 = _sqlite3VdbeMakeLabel(tls, pParse) + _windowCodeRangeTest(tls, bp, int32(OP_Ge), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr, regEnd, (**(**TWindowCodeArg)(__ccgo_up(bp))).Fend.Fcsr, lbl1) + } + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + if regEnd != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addr1) + _sqlite3VdbeResolveLabel(tls, v, lbl1) + } + } else { + if regEnd != 0 { + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfPos), regEnd, 0, int32(1)) + } + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + if regEnd != 0 { + _sqlite3VdbeJumpHere(tls, v, addr1) + } + } + } + } + } + /* End of the main input loop */ + _sqlite3VdbeResolveLabel(tls, v, lblWhereEnd) + _sqlite3WhereEnd(tls, pWInfo) + /* Fall through */ + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + addrInteger = _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regFlushPart) + _sqlite3VdbeJumpHere(tls, v, addrGosubFlush) + } + (**(**TWindowCodeArg)(__ccgo_up(bp))).FregRowid = 0 + addrEmpty = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), csrWrite) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_PRECEDING) { + bRPS1 = libc.BoolInt32(libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_PRECEDING) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE)) + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), regEnd, 0) + if bRPS1 != 0 { + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + } + _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, 0) + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), 0, 0) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + addrStart = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak2 = _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, int32(1)) + addrBreak1 = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, int32(1)) + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) == int32(TK_UNBOUNDED) { + addrStart = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak1 = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), regStart, int32(1)) + addrBreak2 = _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), 0, int32(1)) + } else { + /* assert( regStart>=0 ); + ** regEnd = regEnd - regStart; + ** regStart = 0; */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Subtract), regStart, regEnd, regEnd) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regStart) + addrStart = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak1 = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), regEnd, int32(1)) + addrBreak2 = _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, int32(1)) + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrStart) + _sqlite3VdbeJumpHere(tls, v, addrBreak2) + addrStart = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak3 = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrStart) + _sqlite3VdbeJumpHere(tls, v, addrBreak1) + _sqlite3VdbeJumpHere(tls, v, addrBreak3) + } else { + _windowCodeOp(tls, bp, int32(WINDOW_AGGSTEP), 0, 0) + addrStart1 = _sqlite3VdbeCurrentAddr(tls, v) + addrBreak = _windowCodeOp(tls, bp, int32(WINDOW_RETURN_ROW), 0, int32(1)) + _windowCodeOp(tls, bp, int32(WINDOW_AGGINVERSE), regStart, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrStart1) + _sqlite3VdbeJumpHere(tls, v, addrBreak) + } + } + _sqlite3VdbeJumpHere(tls, v, addrEmpty) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResetSorter), (**(**TWindowCodeArg)(__ccgo_up(bp))).Fcurrent.Fcsr) + if (*TWindow)(unsafe.Pointer(pMWin)).FpPartition != 0 { + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pMWin)).FregEndRowid) + } + _sqlite3VdbeChangeP1(tls, v, addrInteger, _sqlite3VdbeCurrentAddr(tls, v)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Return), regFlushPart) + } +} + +/************** End of window.c **********************************************/ +/************** Begin file parse.c *******************************************/ +/* This file is automatically generated by Lemon from input grammar +** source file "parse.y". + */ +/* +** 2001-09-15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains SQLite's SQL parser. +** +** The canonical source code to this file ("parse.y") is a Lemon grammar +** file that specifies the input grammar and actions to take while parsing. +** That input file is processed by Lemon to generate a C-language +** implementation of a parser for the given grammar. You might be reading +** this comment as part of the translated C-code. Edits should be made +** to the original parse.y sources. + */ + +/* #include "sqliteInt.h" */ + +/* +** Verify that the pParse->isCreate field is set + */ + +/* +** Disable all error recovery processing in the parser push-down +** automaton. + */ + +/* +** Make yytestcase() the same as testcase() + */ + +/* +** Indicate that sqlite3ParserFree() will never be called with a null +** pointer. + */ + +/* +** In the amalgamation, the parse.c file generated by lemon and the +** tokenize.c file are concatenated. In that case, sqlite3RunParser() +** has access to the the size of the yyParser object and so the parser +** engine can be allocated from stack. In that case, only the +** sqlite3ParserInit() and sqlite3ParserFinalize() routines are invoked +** and the sqlite3ParserAlloc() and sqlite3ParserFree() routines can be +** omitted. + */ + +/* +** Alternative datatype for the argument to the malloc() routine passed +** into sqlite3ParserAlloc(). The default is size_t. + */ + +// C documentation +// +// /* Populate the StatPage object with information about the all +// ** cells found on the page currently under analysis. +// */ +func _statDecodePage(tls *libc.TLS, pBt uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aData, aHdr, pCell uintptr + var i, iNext, iOff, isLeaf, j, nHdr, nLocal, nOvfl, nUnused, nUsable, rc, szPage, v1 int32 + var iPrev Tu32 + var v2 uint32 + var _ /* dummy at bp+8 */ Tu64 + var _ /* nPayload at bp+0 */ Tu32 + var _ /* pPg at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aData, aHdr, i, iNext, iOff, iPrev, isLeaf, j, nHdr, nLocal, nOvfl, nUnused, nUsable, pCell, rc, szPage, v1, v2 + aData = (*TStatPage)(unsafe.Pointer(p)).FaPg + if (*TStatPage)(unsafe.Pointer(p)).FiPgno == uint32(1) { + v1 = int32(100) + } else { + v1 = 0 + } + aHdr = aData + uintptr(v1) + (*TStatPage)(unsafe.Pointer(p)).Fflags = **(**Tu8)(__ccgo_up(aHdr)) + if libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x0A) || libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x0D) { + isLeaf = int32(1) + nHdr = int32(8) + } else { + if libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x05) || libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x02) { + isLeaf = 0 + nHdr = int32(12) + } else { + goto statPageIsCorrupt + } + } + if (*TStatPage)(unsafe.Pointer(p)).FiPgno == uint32(1) { + nHdr = nHdr + int32(100) + } + (*TStatPage)(unsafe.Pointer(p)).FnCell = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aHdr + 3)))<= szPage { + goto statPageIsCorrupt + } + nUnused = nUnused + (libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(iOff+int32(2)))))< 0 { + goto statPageIsCorrupt + } + iOff = iNext + } + (*TStatPage)(unsafe.Pointer(p)).FnUnused = nUnused + if isLeaf != 0 { + v2 = uint32(0) + } else { + v2 = _sqlite3Get4byte(tls, aHdr+8) + } + (*TStatPage)(unsafe.Pointer(p)).FiRightChildPg = v2 + if (*TStatPage)(unsafe.Pointer(p)).FnCell != 0 { /* Usable bytes per page */ + _sqlite3BtreeEnter(tls, pBt) + nUsable = szPage - _sqlite3BtreeGetReserveNoMutex(tls, pBt) + _sqlite3BtreeLeave(tls, pBt) + (*TStatPage)(unsafe.Pointer(p)).FaCell = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TStatPage)(unsafe.Pointer(p)).FnCell+libc.Int32FromInt32(1))*uint64(32))) + if (*TStatPage)(unsafe.Pointer(p)).FaCell == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, (*TStatPage)(unsafe.Pointer(p)).FaCell, 0, libc.Uint64FromInt32((*TStatPage)(unsafe.Pointer(p)).FnCell+libc.Int32FromInt32(1))*uint64(32)) + i = 0 + for { + if !(i < (*TStatPage)(unsafe.Pointer(p)).FnCell) { + break + } + pCell = (*TStatPage)(unsafe.Pointer(p)).FaCell + uintptr(i)*32 + iOff = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(nHdr+i*int32(2)))))<= szPage { + goto statPageIsCorrupt + } + if !(isLeaf != 0) { + (*TStatCell)(unsafe.Pointer(pCell)).FiChildPg = _sqlite3Get4byte(tls, aData+uintptr(iOff)) + iOff = iOff + int32(4) + } + if libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x05) { + /* A table interior node. nPayload==0. */ + } else { /* Bytes of payload stored locally */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + uintptr(iOff)))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**Tu8)(__ccgo_up(aData + uintptr(iOff)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aData+uintptr(iOff), bp)) + } + iOff = iOff + libc.Int32FromUint8(libc.Uint8FromInt32(v1)) + if libc.Int32FromUint8((*TStatPage)(unsafe.Pointer(p)).Fflags) == int32(0x0D) { + iOff = iOff + libc.Int32FromUint8(_sqlite3GetVarint(tls, aData+uintptr(iOff), bp+8)) + } + if **(**Tu32)(__ccgo_up(bp)) > libc.Uint32FromInt32((*TStatPage)(unsafe.Pointer(p)).FnMxPayload) { + (*TStatPage)(unsafe.Pointer(p)).FnMxPayload = libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))) + } + nLocal = _getLocalPayload(tls, nUsable, (*TStatPage)(unsafe.Pointer(p)).Fflags, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp)))) + if nLocal < 0 { + goto statPageIsCorrupt + } + (*TStatCell)(unsafe.Pointer(pCell)).FnLocal = nLocal + if **(**Tu32)(__ccgo_up(bp)) > libc.Uint32FromInt32(nLocal) { + nOvfl = libc.Int32FromUint32((**(**Tu32)(__ccgo_up(bp)) - libc.Uint32FromInt32(nLocal) + libc.Uint32FromInt32(nUsable) - uint32(4) - uint32(1)) / libc.Uint32FromInt32(nUsable-libc.Int32FromInt32(4))) + if iOff+nLocal+int32(4) > nUsable || **(**Tu32)(__ccgo_up(bp)) > uint32(0x7fffffff) { + goto statPageIsCorrupt + } + (*TStatCell)(unsafe.Pointer(pCell)).FnLastOvfl = libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp)) - libc.Uint32FromInt32(nLocal) - libc.Uint32FromInt32((nOvfl-int32(1))*(nUsable-int32(4)))) + (*TStatCell)(unsafe.Pointer(pCell)).FnOvfl = nOvfl + (*TStatCell)(unsafe.Pointer(pCell)).FaOvfl = Xsqlite3_malloc64(tls, uint64(uint64(4)*libc.Uint64FromInt32(nOvfl))) + if (*TStatCell)(unsafe.Pointer(pCell)).FaOvfl == uintptr(0) { + return int32(SQLITE_NOMEM) + } + **(**Tu32)(__ccgo_up((*TStatCell)(unsafe.Pointer(pCell)).FaOvfl)) = _sqlite3Get4byte(tls, aData+uintptr(iOff+nLocal)) + j = int32(1) + for { + if !(j < nOvfl) { + break + } + iPrev = **(**Tu32)(__ccgo_up((*TStatCell)(unsafe.Pointer(pCell)).FaOvfl + uintptr(j-int32(1))*4)) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + rc = _sqlite3PagerGet(tls, _sqlite3BtreePager(tls, pBt), iPrev, bp+16, 0) + if rc != SQLITE_OK { + return rc + } + **(**Tu32)(__ccgo_up((*TStatCell)(unsafe.Pointer(pCell)).FaOvfl + uintptr(j)*4)) = _sqlite3Get4byte(tls, _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 16)))) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 16))) + goto _5 + _5: + ; + j = j + 1 + } + } + } + goto _3 + _3: + ; + i = i + 1 + } + } + return SQLITE_OK + goto statPageIsCorrupt +statPageIsCorrupt: + ; + (*TStatPage)(unsafe.Pointer(p)).Fflags = uint8(0) + _statClearCells(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Load a copy of the page data for page iPg into the buffer belonging +// ** to page object pPg. Allocate the buffer if necessary. Return SQLITE_OK +// ** if successful, or an SQLite error code otherwise. +// */ +func _statGetPage(tls *libc.TLS, pBt uintptr, iPg Tu32, pPg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a uintptr + var pgsz, rc int32 + var _ /* pDbPage at bp+0 */ uintptr + _, _, _ = a, pgsz, rc + pgsz = _sqlite3BtreeGetPageSize(tls, pBt) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*TStatPage)(unsafe.Pointer(pPg)).FaPg == uintptr(0) { + (*TStatPage)(unsafe.Pointer(pPg)).FaPg = Xsqlite3_malloc(tls, pgsz+int32(DBSTAT_PAGE_PADDING_BYTES)) + if (*TStatPage)(unsafe.Pointer(pPg)).FaPg == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, (*TStatPage)(unsafe.Pointer(pPg)).FaPg+uintptr(pgsz), 0, uint64(DBSTAT_PAGE_PADDING_BYTES)) + } + rc = _sqlite3PagerGet(tls, _sqlite3BtreePager(tls, pBt), iPg, bp, 0) + if rc == SQLITE_OK { + a = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + libc.Xmemcpy(tls, (*TStatPage)(unsafe.Pointer(pPg)).FaPg, a, libc.Uint64FromInt32(pgsz)) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Sync the journal. In other words, make sure all the pages that have +// ** been written to the journal have actually reached the surface of the +// ** disk and can be restored in the event of a hot-journal rollback. +// ** +// ** If the Pager.noSync flag is set, then this function is a no-op. +// ** Otherwise, the actions required depend on the journal-mode and the +// ** device characteristics of the file-system, as follows: +// ** +// ** * If the journal file is an in-memory journal file, no action need +// ** be taken. +// ** +// ** * Otherwise, if the device does not support the SAFE_APPEND property, +// ** then the nRec field of the most recently written journal header +// ** is updated to contain the number of journal records that have +// ** been written following it. If the pager is operating in full-sync +// ** mode, then the journal file is synced before this field is updated. +// ** +// ** * If the device does not support the SEQUENTIAL property, then +// ** journal file is synced. +// ** +// ** Or, in pseudo-code: +// ** +// ** if( NOT ){ +// ** if( NOT SAFE_APPEND ){ +// ** if( ) xSync(); +// ** +// ** } +// ** if( NOT SEQUENTIAL ) xSync(); +// ** } +// ** +// ** If successful, this routine clears the PGHDR_NEED_SYNC flag of every +// ** page currently held in memory before returning SQLITE_OK. If an IO +// ** error is encountered, then the IO error code is returned to the caller. +// */ +func _syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iDc, rc, v1 int32 + var iNextHdrOffset Ti64 + var _ /* aMagic at bp+0 */ [8]Tu8 + var _ /* zHeader at bp+8 */ [12]Tu8 + _, _, _, _ = iDc, iNextHdrOffset, rc, v1 /* Return code */ + rc = _sqlite3PagerExclusiveLock(tls, pPager) + if rc != SQLITE_OK { + return rc + } + if !((*TPager)(unsafe.Pointer(pPager)).FnoSync != 0) { + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) != int32(PAGER_JOURNALMODE_MEMORY) { + iDc = _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd) + if 0 == iDc&int32(SQLITE_IOCAP_SAFE_APPEND) { + libc.Xmemcpy(tls, bp+8, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8)) + _sqlite3Put4byte(tls, bp+8+uintptr(8), libc.Uint32FromInt32((*TPager)(unsafe.Pointer(pPager)).FnRec)) + iNextHdrOffset = _journalHdrOffset(tls, pPager) + rc = _sqlite3OsRead(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp, int32(8), iNextHdrOffset) + if rc == SQLITE_OK && 0 == libc.Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8)) { + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&_zerobyte)), int32(1), iNextHdrOffset) + } + if rc != SQLITE_OK && rc != libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)< uint32(0x7fffffff) { + return _sqlite3CorruptError(tls, int32(93211)) + } + /* Allocate 5 extra bytes at the end of the buffer. This allows the + ** getVarint32() call below to read slightly past the end of the buffer + ** if the record is corrupt. */ + aRec = _sqlite3MallocZero(tls, uint64(nRec+uint32(5))) + if aRec == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = _sqlite3BtreePayload(tls, pCur, uint32(0), nRec, aRec) + } + if rc == SQLITE_OK { + **(**Tu32)(__ccgo_up(bp + 56)) = uint32(0) /* Size of record header in bytes */ + idxHdr = uint32(0) /* Current index in header */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aRec))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp + 56)) = uint32(**(**Tu8)(__ccgo_up(aRec))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aRec, bp+56)) + } + idxHdr = uint32(libc.Uint8FromInt32(v1)) + if **(**Tu32)(__ccgo_up(bp + 56)) > uint32(98307) { + rc = int32(SQLITE_CORRUPT) + } else { + res = 0 /* Result of this function call */ + idxRec = **(**Tu32)(__ccgo_up(bp + 56)) /* Index of next field in record body */ + ii = 0 /* Iterator variable */ + nCol = libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FnAllField) + ii = 0 + for { + if !(ii < nCol && rc == SQLITE_OK) { + break + } + **(**Tu32)(__ccgo_up(bp + 60)) = uint32(0) + nSerial = 0 + if idxHdr >= **(**Tu32)(__ccgo_up(bp + 56)) { + rc = _sqlite3CorruptError(tls, int32(93242)) + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aRec + uintptr(idxHdr)))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp + 60)) = uint32(**(**Tu8)(__ccgo_up(aRec + uintptr(idxHdr)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aRec+uintptr(idxHdr), bp+60)) + } + idxHdr = idxHdr + uint32(libc.Uint8FromInt32(v1)) + nSerial = libc.Int32FromUint32(_sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 60)))) + if idxRec+libc.Uint32FromInt32(nSerial) > nRec { + rc = _sqlite3CorruptError(tls, int32(93248)) + } else { + _sqlite3VdbeSerialGet(tls, aRec+uintptr(idxRec), **(**Tu32)(__ccgo_up(bp + 60)), bp) + if _vdbeSkipField(tls, mask, ii, (*TUnpackedRecord)(unsafe.Pointer(p)).FaMem+uintptr(ii)*56, bp, bInt) == 0 { + res = _sqlite3MemCompare(tls, bp, (*TUnpackedRecord)(unsafe.Pointer(p)).FaMem+uintptr(ii)*56, *(*uintptr)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + 32 + uintptr(ii)*8))) + if res != 0 { + break + } + } + } + idxRec = idxRec + _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 60))) + goto _2 + _2: + ; + ii = ii + 1 + } + **(**int32)(__ccgo_up(piRes)) = res + } + } + Xsqlite3_free(tls, aRec) + return rc +} + +// C documentation +// +// /* +// ** Read the next nByte bytes of data from the PMA p. +// ** If successful, set *ppOut to point to a buffer containing the data +// ** and return SQLITE_OK. Otherwise, if an error occurs, return an SQLite +// ** error code. +// ** +// ** The buffer returned in *ppOut is only valid until the +// ** next call to this function. +// */ +func _vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aNew uintptr + var iBuf, nAvail, nCopy, nRead, nRem, rc, rc1 int32 + var nNew Tsqlite3_int64 + var v1 int64 + var _ /* aNext at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _ = aNew, iBuf, nAvail, nCopy, nNew, nRead, nRem, rc, rc1, v1 /* Bytes of data available in buffer */ + if (*TPmaReader)(unsafe.Pointer(p)).FaMap != 0 { + **(**uintptr)(__ccgo_up(ppOut)) = (*TPmaReader)(unsafe.Pointer(p)).FaMap + uintptr((*TPmaReader)(unsafe.Pointer(p)).FiReadOff) + **(**Ti64)(__ccgo_up(p)) += int64(nByte) + return SQLITE_OK + } + /* If there is no more data to be read from the buffer, read the next + ** p->nBuffer bytes of data from the file into it. Or, if there are less + ** than p->nBuffer bytes remaining in the PMA, read all remaining data. */ + iBuf = int32((*TPmaReader)(unsafe.Pointer(p)).FiReadOff % int64((*TPmaReader)(unsafe.Pointer(p)).FnBuffer)) + if iBuf == 0 { /* sqlite3OsRead() return code */ + /* Determine how many bytes of data to read. */ + if (*TPmaReader)(unsafe.Pointer(p)).FiEof-(*TPmaReader)(unsafe.Pointer(p)).FiReadOff > int64((*TPmaReader)(unsafe.Pointer(p)).FnBuffer) { + nRead = (*TPmaReader)(unsafe.Pointer(p)).FnBuffer + } else { + nRead = int32((*TPmaReader)(unsafe.Pointer(p)).FiEof - (*TPmaReader)(unsafe.Pointer(p)).FiReadOff) + } + /* Readr data from the file. Return early if an error occurs. */ + rc = _sqlite3OsRead(tls, (*TPmaReader)(unsafe.Pointer(p)).FpFd, (*TPmaReader)(unsafe.Pointer(p)).FaBuffer, nRead, (*TPmaReader)(unsafe.Pointer(p)).FiReadOff) + if rc != SQLITE_OK { + return rc + } + } + nAvail = (*TPmaReader)(unsafe.Pointer(p)).FnBuffer - iBuf + if nByte <= nAvail { + /* The requested data is available in the in-memory buffer. In this + ** case there is no need to make a copy of the data, just return a + ** pointer into the buffer to the caller. */ + **(**uintptr)(__ccgo_up(ppOut)) = (*TPmaReader)(unsafe.Pointer(p)).FaBuffer + uintptr(iBuf) + **(**Ti64)(__ccgo_up(p)) += int64(nByte) + } else { /* Bytes remaining to copy */ + /* Extend the p->aAlloc[] allocation if required. */ + if (*TPmaReader)(unsafe.Pointer(p)).FnAlloc < nByte { + if int64(libc.Int32FromInt32(128)) > int64(2)*int64((*TPmaReader)(unsafe.Pointer(p)).FnAlloc) { + v1 = int64(libc.Int32FromInt32(128)) + } else { + v1 = int64(2) * int64((*TPmaReader)(unsafe.Pointer(p)).FnAlloc) + } + nNew = v1 + for int64(nByte) > nNew { + nNew = nNew * int64(2) + } + aNew = _sqlite3Realloc(tls, (*TPmaReader)(unsafe.Pointer(p)).FaAlloc, libc.Uint64FromInt64(nNew)) + if !(aNew != 0) { + return int32(SQLITE_NOMEM) + } + (*TPmaReader)(unsafe.Pointer(p)).FnAlloc = int32(nNew) + (*TPmaReader)(unsafe.Pointer(p)).FaAlloc = aNew + } + /* Copy as much data as is available in the buffer into the start of + ** p->aAlloc[]. */ + libc.Xmemcpy(tls, (*TPmaReader)(unsafe.Pointer(p)).FaAlloc, (*TPmaReader)(unsafe.Pointer(p)).FaBuffer+uintptr(iBuf), libc.Uint64FromInt32(nAvail)) + **(**Ti64)(__ccgo_up(p)) += int64(nAvail) + nRem = nByte - nAvail + /* The following loop copies up to p->nBuffer bytes per iteration into + ** the p->aAlloc[] buffer. */ + for nRem > 0 { /* Number of bytes to copy */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Pointer to buffer to copy data from */ + nCopy = nRem + if nRem > (*TPmaReader)(unsafe.Pointer(p)).FnBuffer { + nCopy = (*TPmaReader)(unsafe.Pointer(p)).FnBuffer + } + rc1 = _vdbePmaReadBlob(tls, p, nCopy, bp) + if rc1 != SQLITE_OK { + return rc1 + } + libc.Xmemcpy(tls, (*TPmaReader)(unsafe.Pointer(p)).FaAlloc+uintptr(nByte-nRem), **(**uintptr)(__ccgo_up(bp)), libc.Uint64FromInt32(nCopy)) + nRem = nRem - nCopy + } + **(**uintptr)(__ccgo_up(ppOut)) = (*TPmaReader)(unsafe.Pointer(p)).FaAlloc + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Write nData bytes of data to the PMA. Return SQLITE_OK +// ** if successful, or an SQLite error code if an error occurs. +// */ +func _vdbePmaWriteBlob(tls *libc.TLS, p uintptr, pData uintptr, nData int32) { + var nCopy, nRem, v1 int32 + _, _, _ = nCopy, nRem, v1 + nRem = nData + for nRem > 0 && (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr == 0 { + nCopy = nRem + if nCopy > (*TPmaWriter)(unsafe.Pointer(p)).FnBuffer-(*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd { + nCopy = (*TPmaWriter)(unsafe.Pointer(p)).FnBuffer - (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd + } + libc.Xmemcpy(tls, (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd), pData+uintptr(nData-nRem), libc.Uint64FromInt32(nCopy)) + **(**int32)(__ccgo_up(p + 24)) += nCopy + if (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd == (*TPmaWriter)(unsafe.Pointer(p)).FnBuffer { + (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr = _sqlite3OsWrite(tls, (*TPmaWriter)(unsafe.Pointer(p)).FpFd, (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart), (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd-(*TPmaWriter)(unsafe.Pointer(p)).FiBufStart, (*TPmaWriter)(unsafe.Pointer(p)).FiWriteOff+int64((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart)) + **(**Tu64)(__ccgo_up(p + 48)) += libc.Uint64FromInt32((*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd - (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart) + v1 = libc.Int32FromInt32(0) + (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd = v1 + (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart = v1 + **(**Ti64)(__ccgo_up(p + 32)) += int64((*TPmaWriter)(unsafe.Pointer(p)).FnBuffer) + } + nRem = nRem - nCopy + } +} + +// C documentation +// +// /* +// ** Flush any buffered data to disk and clean up the PMA-writer object. +// ** The results of using the PMA-writer after this call are undefined. +// ** Return SQLITE_OK if flushing the buffered data succeeds or is not +// ** required. Otherwise, return an SQLite error code. +// ** +// ** Before returning, set *piEof to the offset immediately following the +// ** last byte written to the file. Also, increment (*pnSpill) by the total +// ** number of bytes written to the file. +// */ +func _vdbePmaWriterFinish(tls *libc.TLS, p uintptr, piEof uintptr, pnSpill uintptr) (r int32) { + var rc int32 + _ = rc + if (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr == 0 && (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer != 0 && (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd > (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart { + (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr = _sqlite3OsWrite(tls, (*TPmaWriter)(unsafe.Pointer(p)).FpFd, (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart), (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd-(*TPmaWriter)(unsafe.Pointer(p)).FiBufStart, (*TPmaWriter)(unsafe.Pointer(p)).FiWriteOff+int64((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart)) + **(**Tu64)(__ccgo_up(p + 48)) += libc.Uint64FromInt32((*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd - (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart) + } + **(**Ti64)(__ccgo_up(piEof)) = (*TPmaWriter)(unsafe.Pointer(p)).FiWriteOff + int64((*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd) + **(**Tu64)(__ccgo_up(pnSpill)) += (*TPmaWriter)(unsafe.Pointer(p)).FnPmaSpill + Xsqlite3_free(tls, (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer) + rc = (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr + libc.Xmemset(tls, p, 0, uint64(56)) + return rc +} + +// C documentation +// +// /* +// ** Initialize a PMA-writer object. +// */ +func _vdbePmaWriterInit(tls *libc.TLS, pFd uintptr, p uintptr, nBuf int32, iStart Ti64) { + var v1 int32 + _ = v1 + libc.Xmemset(tls, p, 0, uint64(56)) + (*TPmaWriter)(unsafe.Pointer(p)).FaBuffer = _sqlite3Malloc(tls, libc.Uint64FromInt32(nBuf)) + if !((*TPmaWriter)(unsafe.Pointer(p)).FaBuffer != 0) { + (*TPmaWriter)(unsafe.Pointer(p)).FeFWErr = int32(SQLITE_NOMEM) + } else { + v1 = int32(iStart % int64(nBuf)) + (*TPmaWriter)(unsafe.Pointer(p)).FiBufStart = v1 + (*TPmaWriter)(unsafe.Pointer(p)).FiBufEnd = v1 + (*TPmaWriter)(unsafe.Pointer(p)).FiWriteOff = iStart - int64((*TPmaWriter)(unsafe.Pointer(p)).FiBufStart) + (*TPmaWriter)(unsafe.Pointer(p)).FnBuffer = nBuf + (*TPmaWriter)(unsafe.Pointer(p)).FpFd = pFd + } +} + +// C documentation +// +// /* +// ** Helper function for vdbeIsMatchingIndexKey(). Return true if column +// ** iCol should be ignored when comparing a record with a record from +// ** an index on disk. The field should be ignored if: +// ** +// ** * the corresponding bit in mask is set, and +// ** * either: +// ** - bIntegrity is false, or +// ** - the two Mem values are both real values that differ by +// ** BTREE_ULPDISTORTION or fewer ULPs. +// */ +func _vdbeSkipField(tls *libc.TLS, mask TBitmask, iCol int32, pMem1 uintptr, pMem2 uintptr, bIntegrity int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* m1 at bp+0 */ Tu64 + var _ /* m2 at bp+8 */ Tu64 + _ = v1 + if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) || mask&(libc.Uint64FromInt32(1)<pList. Return +// ** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if +// ** an error occurs. +// */ +func _vdbeSorterSort(tls *libc.TLS, pTask uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(512) + defer tls.Free(512) + var i, rc int32 + var p, pNext, v3 uintptr + var _ /* aSlot at bp+0 */ [64]uintptr + _, _, _, _, _ = i, p, pNext, rc, v3 + rc = _vdbeSortAllocUnpacked(tls, pTask) + if rc != SQLITE_OK { + return rc + } + p = (*TSorterList)(unsafe.Pointer(pList)).FpList + (*TSortSubtask)(unsafe.Pointer(pTask)).FxCompare = _vdbeSorterGetCompare(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter) + libc.Xmemset(tls, bp, 0, uint64(512)) + for p != 0 { + if (*TSorterList)(unsafe.Pointer(pList)).FaMemory != 0 { + if p == (*TSorterList)(unsafe.Pointer(pList)).FaMemory { + pNext = uintptr(0) + } else { + pNext = (*TSorterList)(unsafe.Pointer(pList)).FaMemory + uintptr(*(*int32)(unsafe.Pointer(&(*TSorterRecord)(unsafe.Pointer(p)).Fu))) + } + } else { + pNext = *(*uintptr)(unsafe.Pointer(p + 8)) + } + *(*uintptr)(unsafe.Pointer(p + 8)) = uintptr(0) + i = 0 + for { + if !((**(**[64]uintptr)(__ccgo_up(bp)))[i] != 0) { + break + } + p = _vdbeSorterMerge(tls, pTask, p, (**(**[64]uintptr)(__ccgo_up(bp)))[i]) + /* ,--Each aSlot[] holds twice as much as the previous. So we cannot use + ** | up all 64 aSlots[] with only a 64-bit address space. + ** v */ + (**(**[64]uintptr)(__ccgo_up(bp)))[i] = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + (**(**[64]uintptr)(__ccgo_up(bp)))[i] = p + p = pNext + } + p = uintptr(0) + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(512)/libc.Uint64FromInt64(8))) { + break + } + if (**(**[64]uintptr)(__ccgo_up(bp)))[i] == uintptr(0) { + goto _2 + } + if p != 0 { + v3 = _vdbeSorterMerge(tls, pTask, p, (**(**[64]uintptr)(__ccgo_up(bp)))[i]) + } else { + v3 = (**(**[64]uintptr)(__ccgo_up(bp)))[i] + } + p = v3 + goto _2 + _2: + ; + i = i + 1 + } + (*TSorterList)(unsafe.Pointer(pList)).FpList = p + return libc.Int32FromUint8((*TUnpackedRecord)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode) +} + +// C documentation +// +// /* +// ** Allocate and populate an UnpackedRecord structure based on the serialized +// ** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure +// ** if successful, or a NULL pointer if an OOM error is encountered. +// */ +func _vdbeUnpackRecord(tls *libc.TLS, pKeyInfo uintptr, nKey int32, pKey uintptr) (r uintptr) { + var pRet uintptr + _ = pRet /* Return value */ + pRet = _sqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo) + if pRet != 0 { + libc.Xmemset(tls, (*TUnpackedRecord)(unsafe.Pointer(pRet)).FaMem, 0, uint64(56)*libc.Uint64FromInt32(libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField)+libc.Int32FromInt32(1))) + _sqlite3VdbeRecordUnpack(tls, nKey, pKey, pRet) + } + return pRet +} + +// C documentation +// +// /* +// ** Open a transaction in a connection where the shared-memory is read-only +// ** and where we cannot verify that there is a separate write-capable connection +// ** on hand to keep the shared-memory up-to-date with the WAL file. +// ** +// ** This can happen, for example, when the shared-memory is implemented by +// ** memory-mapping a *-shm file, where a prior writer has shut down and +// ** left the *-shm file on disk, and now the present connection is trying +// ** to use that database but lacks write permission on the *-shm file. +// ** Other scenarios are also possible, depending on the VFS implementation. +// ** +// ** Precondition: +// ** +// ** The *-wal file has been read and an appropriate wal-index has been +// ** constructed in pWal->apWiData[] using heap memory instead of shared +// ** memory. +// ** +// ** If this function returns SQLITE_OK, then the read transaction has +// ** been successfully opened. In this case output variable (*pChanged) +// ** is set to true before returning if the caller should discard the +// ** contents of the page cache before proceeding. Or, if it returns +// ** WAL_RETRY, then the heap memory wal-index has been discarded and +// ** the caller should retry opening the read transaction from the +// ** beginning (including attempting to map the *-shm file). +// ** +// ** If an error occurs, an SQLite error code is returned. +// */ +func _walBeginShmUnreliable(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var aData, aFrame uintptr + var aSaveCksum [2]Tu32 + var i, rc, szFrame, v1 int32 + var iOffset Ti64 + var _ /* aBuf at bp+8 */ [32]Tu8 + var _ /* nTruncate at bp+52 */ Tu32 + var _ /* pDummy at bp+40 */ uintptr + var _ /* pgno at bp+48 */ Tu32 + var _ /* szWal at bp+0 */ Ti64 + _, _, _, _, _, _, _, _ = aData, aFrame, aSaveCksum, i, iOffset, rc, szFrame, v1 /* Buffer to load WAL header into */ + aFrame = uintptr(0) /* Saved copy of pWal->hdr.aFrameCksum */ + /* Take WAL_READ_LOCK(0). This has the effect of preventing any + ** writers from running a checkpoint, but does not stop them + ** from running recovery. */ + rc = _walLockShared(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(0)) + if rc != SQLITE_OK { + if rc == int32(SQLITE_BUSY) { + rc = -int32(1) + } + goto begin_unreliable_shm_out + } + (*TWal)(unsafe.Pointer(pWal)).FreadLock = 0 + /* Check to see if a separate writer has attached to the shared-memory area, + ** thus making the shared-memory "reliable" again. Do this by invoking + ** the xShmMap() routine of the VFS and looking to see if the return + ** is SQLITE_READONLY instead of SQLITE_READONLY_CANTINIT. + ** + ** If the shared-memory is now "reliable" return WAL_RETRY, which will + ** cause the heap-memory WAL-index to be discarded and the actual + ** shared memory to be used in its place. + ** + ** This step is important because, even though this connection is holding + ** the WAL_READ_LOCK(0) which prevents a checkpoint, a writer might + ** have already checkpointed the WAL file and, while the current + ** is active, wrap the WAL and start overwriting frames that this + ** process wants to use. + ** + ** Once sqlite3OsShmMap() has been called for an sqlite3_file and has + ** returned any SQLITE_READONLY value, it must return only SQLITE_READONLY + ** or SQLITE_READONLY_CANTINIT or some error for all subsequent invocations, + ** even if some external agent does a "chmod" to make the shared-memory + ** writable by us, until sqlite3OsShmUnmap() has been called. + ** This is a requirement on the VFS implementation. + */ + rc = _sqlite3OsShmMap(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, 0, libc.Int32FromUint64(libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4)), 0, bp+40) + /* SQLITE_OK not possible for read-only connection */ + if rc != libc.Int32FromInt32(SQLITE_READONLY)|libc.Int32FromInt32(5)<hdr. + */ + libc.Xmemcpy(tls, pWal+72, _walIndexHdr(tls, pWal), uint64(48)) + /* Make sure some writer hasn't come in and changed the WAL file out + ** from under us, then disconnected, while we were not looking. + */ + rc = _sqlite3OsFileSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp) + if rc != SQLITE_OK { + goto begin_unreliable_shm_out + } + if **(**Ti64)(__ccgo_up(bp)) < int64(WAL_HDRSIZE) { + /* If the wal file is too small to contain a wal-header and the + ** wal-index header has mxFrame==0, then it must be safe to proceed + ** reading the database file only. However, the page cache cannot + ** be trusted, as a read/write connection may have connected, written + ** the db, run a checkpoint, truncated the wal file and disconnected + ** since this client's last read transaction. */ + **(**int32)(__ccgo_up(pChanged)) = int32(1) + if (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == uint32(0) { + v1 = SQLITE_OK + } else { + v1 = -int32(1) + } + rc = v1 + goto begin_unreliable_shm_out + } + /* Check the salt keys at the start of the wal file still match. */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp+8, int32(WAL_HDRSIZE), 0) + if rc != SQLITE_OK { + goto begin_unreliable_shm_out + } + if libc.Xmemcmp(tls, pWal+72+32, bp+8+16, uint64(8)) != 0 { + /* Some writer has wrapped the WAL file while we were not looking. + ** Return WAL_RETRY which will cause the in-memory WAL-index to be + ** rebuilt. */ + rc = -int32(1) + goto begin_unreliable_shm_out + } + /* Allocate a buffer to read frames into */ + szFrame = libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage + uint32(WAL_FRAME_HDRSIZE)) + aFrame = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(szFrame)) + if aFrame == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto begin_unreliable_shm_out + } + aData = aFrame + 24 + /* Check to see if a complete transaction has been appended to the + ** wal file since the heap-memory wal-index was created. If so, the + ** heap-memory wal-index is discarded and WAL_RETRY returned to + ** the caller. */ + aSaveCksum[0] = **(**Tu32)(__ccgo_up(pWal + 72 + 24)) + aSaveCksum[int32(1)] = **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) + iOffset = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32((*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame+libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*libc.Int64FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage+libc.Uint32FromInt32(WAL_FRAME_HDRSIZE)) + for { + if !(iOffset+int64(szFrame) <= **(**Ti64)(__ccgo_up(bp))) { + break + } /* dbsize field from frame header */ + /* Read and decode the next log frame. */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset) + if rc != SQLITE_OK { + break + } + if !(_walDecodeFrame(tls, pWal, bp+48, bp+52, aData, aFrame) != 0) { + break + } + /* If nTruncate is non-zero, then a complete transaction has been + ** appended to this wal file. Set rc to WAL_RETRY and break out of + ** the loop. */ + if **(**Tu32)(__ccgo_up(bp + 52)) != 0 { + rc = -int32(1) + break + } + goto _3 + _3: + ; + iOffset = iOffset + int64(szFrame) + } + **(**Tu32)(__ccgo_up(pWal + 72 + 24)) = aSaveCksum[0] + **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) = aSaveCksum[int32(1)] + goto begin_unreliable_shm_out +begin_unreliable_shm_out: + ; + Xsqlite3_free(tls, aFrame) + if rc != SQLITE_OK { + i = 0 + for { + if !(i < (*TWal)(unsafe.Pointer(pWal)).FnWiData) { + break + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8))) + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8)) = uintptr(0) + goto _4 + _4: + ; + i = i + 1 + } + (*TWal)(unsafe.Pointer(pWal)).FbShmUnreliable = uint8(0) + _sqlite3WalEndReadTransaction(tls, pWal) + **(**int32)(__ccgo_up(pChanged)) = int32(1) + } + return rc +} + +/* +** The final argument passed to walTryBeginRead() is of type (int*). The +** caller should invoke walTryBeginRead as follows: +** +** int cnt = 0; +** do { +** rc = walTryBeginRead(..., &cnt); +** }while( rc==WAL_RETRY ); +** +** The final value of "cnt" is of no use to the caller. It is used by +** the implementation of walTryBeginRead() as follows: +** +** + Each time walTryBeginRead() is called, it is incremented. Once +** it reaches WAL_RETRY_PROTOCOL_LIMIT - indicating that walTryBeginRead() +** has many times been invoked and failed with WAL_RETRY - walTryBeginRead() +** returns SQLITE_PROTOCOL. +** +** + If SQLITE_ENABLE_SETLK_TIMEOUT is defined and walTryBeginRead() failed +** because a blocking lock timed out (SQLITE_BUSY_TIMEOUT from the OS +** layer), the WAL_RETRY_BLOCKED_MASK bit is set in "cnt". In this case +** the next invocation of walTryBeginRead() may omit an expected call to +** sqlite3OsSleep(). There has already been a delay when the previous call +** waited on a lock. + */ + +// C documentation +// +// /* +// ** Remove entries from the hash table that point to WAL slots greater +// ** than pWal->hdr.mxFrame. +// ** +// ** This function is called whenever pWal->hdr.mxFrame is decreased due +// ** to a rollback or savepoint. +// ** +// ** At most only the hash table containing pWal->hdr.mxFrame needs to be +// ** updated. Any later hash tables will be automatically cleared when +// ** pWal->hdr.mxFrame advances to the point where those hash tables are +// ** actually needed. +// */ +func _walCleanupHash(tls *libc.TLS, pWal uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, iLimit, nByte int32 + var _ /* sLoc at bp+0 */ TWalHashLoc + _, _, _ = i, iLimit, nByte /* Hash table location */ + iLimit = 0 /* Used to iterate through aHash[] */ + if (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == uint32(0) { + return + } + /* Obtain pointers to the hash-table and page-number array containing + ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed + ** that the page said hash-table and array reside on is already mapped.(1) + */ + i = _walHashGet(tls, pWal, _walFramePage(tls, (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame), bp) + if i != 0 { + return + } /* Defense-in-depth, in case (1) above is wrong */ + /* Zero all hash-table entries that correspond to frame numbers greater + ** than pWal->hdr.mxFrame. + */ + iLimit = libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero) + i = 0 + for { + if !(i < libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2)) { + break + } + if libc.Int32FromUint16(**(**Tht_slot)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash + uintptr(i)*2))) > iLimit { + **(**Tht_slot)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash + uintptr(i)*2)) = uint16(0) + } + goto _1 + _1: + ; + i = i + 1 + } + /* Zero the entries in the aPgno array that correspond to frames with + ** frame numbers greater than pWal->hdr.mxFrame. + */ + nByte = int32(int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash) - int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno+uintptr(iLimit)*4)) + libc.Xmemset(tls, (**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno+uintptr(iLimit)*4, 0, libc.Uint64FromInt32(nByte)) +} + +// C documentation +// +// /* +// ** Write a set of frames to the log. The caller must hold the write-lock +// ** on the log file (obtained using sqlite3WalBeginWriteTransaction()). +// */ +func _walFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, nTruncate TPgno, isCommit int32, sync_flags int32) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bSync, nDbSize, nExtra, rc, sectorSize, szFrame, v1 int32 + var iFirst, iFrame Tu32 + var iOff, iOffset, sz Ti64 + var p, pData, pLast, pLive, v3 uintptr + var v4 uint32 + var _ /* aCksum at bp+64 */ [2]Tu32 + var _ /* aWalHdr at bp+32 */ [32]Tu8 + var _ /* iWrite at bp+72 */ Tu32 + var _ /* w at bp+0 */ TWalWriter + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bSync, iFirst, iFrame, iOff, iOffset, nDbSize, nExtra, p, pData, pLast, pLive, rc, sectorSize, sz, szFrame, v1, v3, v4 /* Iterator to run through pList with. */ + pLast = uintptr(0) /* Last frame in list */ + nExtra = 0 /* The writer */ + iFirst = uint32(0) /* Pointer to shared header */ + /* If this frame set completes a transaction, then nTruncate>0. If + ** nTruncate==0 then this frame set does not complete the transaction. */ + pLive = _walIndexHdr(tls, pWal) + if libc.Xmemcmp(tls, pWal+72, pLive, uint64(48)) != 0 { + iFirst = (*TWalIndexHdr)(unsafe.Pointer(pLive)).FmxFrame + uint32(1) + } + /* See if it is possible to write these frames into the start of the + ** log file, instead of appending to it at pWal->hdr.mxFrame. + */ + v1 = _walRestartLog(tls, pWal) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + /* If this is the first frame written into the log, write the WAL + ** header to the start of the WAL file. See comments at the top of + ** this source file for a description of the WAL header format. + */ + iFrame = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + if iFrame == uint32(0) { /* Checksum for wal-header */ + _sqlite3Put4byte(tls, bp+32, libc.Uint32FromInt32(libc.Int32FromInt32(WAL_MAGIC)|libc.Int32FromInt32(SQLITE_BIGENDIAN))) + _sqlite3Put4byte(tls, bp+32+4, uint32(WAL_MAX_VERSION)) + _sqlite3Put4byte(tls, bp+32+8, libc.Uint32FromInt32(szPage)) + _sqlite3Put4byte(tls, bp+32+12, (*TWal)(unsafe.Pointer(pWal)).FnCkpt) + if (*TWal)(unsafe.Pointer(pWal)).FnCkpt == uint32(0) { + Xsqlite3_randomness(tls, int32(8), pWal+72+32) + } + libc.Xmemcpy(tls, bp+32+16, pWal+72+32, uint64(8)) + _walChecksumBytes(tls, int32(1), bp+32, libc.Int32FromInt32(WAL_HDRSIZE)-libc.Int32FromInt32(2)*libc.Int32FromInt32(4), uintptr(0), bp+64) + _sqlite3Put4byte(tls, bp+32+24, (**(**[2]Tu32)(__ccgo_up(bp + 64)))[0]) + _sqlite3Put4byte(tls, bp+32+28, (**(**[2]Tu32)(__ccgo_up(bp + 64)))[int32(1)]) + (*TWal)(unsafe.Pointer(pWal)).FszPage = libc.Uint32FromInt32(szPage) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = uint8(SQLITE_BIGENDIAN) + **(**Tu32)(__ccgo_up(pWal + 72 + 24)) = (**(**[2]Tu32)(__ccgo_up(bp + 64)))[0] + **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) = (**(**[2]Tu32)(__ccgo_up(bp + 64)))[int32(1)] + (*TWal)(unsafe.Pointer(pWal)).FtruncateOnCommit = uint8(1) + rc = _sqlite3OsWrite(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp+32, int32(32), 0) + if rc != SQLITE_OK { + return rc + } + /* Sync the header (unless SQLITE_IOCAP_SEQUENTIAL is true or unless + ** all syncing is turned off by PRAGMA synchronous=OFF). Otherwise + ** an out-of-order write following a WAL restart could result in + ** database corruption. See the ticket: + ** + ** https://sqlite.org/src/info/ff5be73dee + */ + if (*TWal)(unsafe.Pointer(pWal)).FsyncHeader != 0 { + rc = _sqlite3OsSync(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, sync_flags>>int32(2)&int32(0x03)) + if rc != 0 { + return rc + } + } + } + if libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage) != szPage { + return _sqlite3CorruptError(tls, int32(71564)) /* TH3 test case: cov1/corrupt155.test */ + } + /* Setup information needed to write frames into the WAL */ + (**(**TWalWriter)(__ccgo_up(bp))).FpWal = pWal + (**(**TWalWriter)(__ccgo_up(bp))).FpFd = (*TWal)(unsafe.Pointer(pWal)).FpWalFd + (**(**TWalWriter)(__ccgo_up(bp))).FiSyncPoint = 0 + (**(**TWalWriter)(__ccgo_up(bp))).FsyncFlags = sync_flags + (**(**TWalWriter)(__ccgo_up(bp))).FszPage = szPage + iOffset = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32(iFrame+libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + szFrame = szPage + int32(WAL_FRAME_HDRSIZE) + /* Write all frames into the log file exactly once */ + p = pList + for { + if !(p != 0) { + break + } /* 0 normally. Positive == commit flag */ + /* Check if this page has already been written into the wal file by + ** the current transaction. If so, overwrite the existing frame and + ** set Wal.writeLock to WAL_WRITELOCK_RECKSUM - indicating that + ** checksums must be recomputed when the transaction is committed. */ + if iFirst != 0 && ((*TPgHdr)(unsafe.Pointer(p)).FpDirty != 0 || isCommit == 0) { + **(**Tu32)(__ccgo_up(bp + 72)) = uint32(0) + _walFindFrame(tls, pWal, (*TPgHdr)(unsafe.Pointer(p)).Fpgno, bp+72) + if **(**Tu32)(__ccgo_up(bp + 72)) >= iFirst { + iOff = int64(WAL_HDRSIZE) + libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp + 72))-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + int64(WAL_FRAME_HDRSIZE) + if (*TWal)(unsafe.Pointer(pWal)).FiReCksum == uint32(0) || **(**Tu32)(__ccgo_up(bp + 72)) < (*TWal)(unsafe.Pointer(pWal)).FiReCksum { + (*TWal)(unsafe.Pointer(pWal)).FiReCksum = **(**Tu32)(__ccgo_up(bp + 72)) + } + pData = (*TPgHdr)(unsafe.Pointer(p)).FpData + rc = _sqlite3OsWrite(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, pData, szPage, iOff) + if rc != 0 { + return rc + } + v3 = p + 52 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^libc.Int32FromInt32(PGHDR_WAL_APPEND)) + goto _2 + } + } + iFrame = iFrame + 1 + if isCommit != 0 && (*TPgHdr)(unsafe.Pointer(p)).FpDirty == uintptr(0) { + v4 = nTruncate + } else { + v4 = uint32(0) + } + nDbSize = libc.Int32FromUint32(v4) + rc = _walWriteOneFrame(tls, bp, p, nDbSize, iOffset) + if rc != 0 { + return rc + } + pLast = p + iOffset = iOffset + int64(szFrame) + v3 = p + 52 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(PGHDR_WAL_APPEND)) + goto _2 + _2: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + } + /* Recalculate checksums within the wal file if required. */ + if isCommit != 0 && (*TWal)(unsafe.Pointer(pWal)).FiReCksum != 0 { + rc = _walRewriteChecksums(tls, pWal, iFrame) + if rc != 0 { + return rc + } + } + /* If this is the end of a transaction, then we might need to pad + ** the transaction and/or sync the WAL file. + ** + ** Padding and syncing only occur if this set of frames complete a + ** transaction and if PRAGMA synchronous=FULL. If synchronous==NORMAL + ** or synchronous==OFF, then no padding or syncing are needed. + ** + ** If SQLITE_IOCAP_POWERSAFE_OVERWRITE is defined, then padding is not + ** needed and only the sync is done. If padding is needed, then the + ** final frame is repeated (with its commit mark) until the next sector + ** boundary is crossed. Only the part of the WAL prior to the last + ** sector boundary is synced; the part of the last frame that extends + ** past the sector boundary is written after the sync. + */ + if isCommit != 0 && sync_flags&int32(0x03) != 0 { + bSync = int32(1) + if (*TWal)(unsafe.Pointer(pWal)).FpadToSectorBoundary != 0 { + sectorSize = _sqlite3SectorSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd) + (**(**TWalWriter)(__ccgo_up(bp))).FiSyncPoint = (iOffset + int64(sectorSize) - int64(1)) / int64(sectorSize) * int64(sectorSize) + bSync = libc.BoolInt32((**(**TWalWriter)(__ccgo_up(bp))).FiSyncPoint == iOffset) + for iOffset < (**(**TWalWriter)(__ccgo_up(bp))).FiSyncPoint { + rc = _walWriteOneFrame(tls, bp, pLast, libc.Int32FromUint32(nTruncate), iOffset) + if rc != 0 { + return rc + } + iOffset = iOffset + int64(szFrame) + nExtra = nExtra + 1 + } + } + if bSync != 0 { + rc = _sqlite3OsSync(tls, (**(**TWalWriter)(__ccgo_up(bp))).FpFd, sync_flags&int32(0x03)) + } + } + /* If this frame set completes the first transaction in the WAL and + ** if PRAGMA journal_size_limit is set, then truncate the WAL to the + ** journal size limit, if possible. + */ + if isCommit != 0 && (*TWal)(unsafe.Pointer(pWal)).FtruncateOnCommit != 0 && (*TWal)(unsafe.Pointer(pWal)).FmxWalSize >= 0 { + sz = (*TWal)(unsafe.Pointer(pWal)).FmxWalSize + if int64(WAL_HDRSIZE)+libc.Int64FromUint32(iFrame+libc.Uint32FromInt32(nExtra)+libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) > (*TWal)(unsafe.Pointer(pWal)).FmxWalSize { + sz = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32(iFrame+libc.Uint32FromInt32(nExtra)+libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + } + _walLimitSize(tls, pWal, sz) + (*TWal)(unsafe.Pointer(pWal)).FtruncateOnCommit = uint8(0) + } + /* Append data to the wal-index. It is not necessary to lock the + ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index + ** guarantees that there are no other writers, and no data that may + ** be in use by existing readers is being overwritten. + */ + iFrame = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + p = pList + for { + if !(p != 0 && rc == SQLITE_OK) { + break + } + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(p)).Fflags)&int32(PGHDR_WAL_APPEND) == 0 { + goto _6 + } + iFrame = iFrame + 1 + rc = _walIndexAppend(tls, pWal, iFrame, (*TPgHdr)(unsafe.Pointer(p)).Fpgno) + goto _6 + _6: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + } + for rc == SQLITE_OK && nExtra > 0 { + iFrame = iFrame + 1 + nExtra = nExtra - 1 + rc = _walIndexAppend(tls, pWal, iFrame, (*TPgHdr)(unsafe.Pointer(pLast)).Fpgno) + } + if rc == SQLITE_OK { + /* Update the private copy of the header. */ + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage = libc.Uint16FromInt32(szPage&libc.Int32FromInt32(0xff00) | szPage>>libc.Int32FromInt32(16)) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = iFrame + if isCommit != 0 { + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FiChange = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FiChange + 1 + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage = nTruncate + } + /* If this is a commit, update the wal-index header too. */ + if isCommit != 0 { + _walIndexWriteHdr(tls, pWal) + (*TWal)(unsafe.Pointer(pWal)).FiCallback = iFrame + } + } + return rc +} + +// C documentation +// +// /* +// ** Set an entry in the wal-index that will map database page number +// ** pPage into WAL frame iFrame. +// */ +func _walIndexAppend(tls *libc.TLS, pWal uintptr, iFrame Tu32, iPage Tu32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iKey, idx, nByte, nCollide, rc, v2 int32 + var _ /* sLoc at bp+0 */ TWalHashLoc + _, _, _, _, _, _ = iKey, idx, nByte, nCollide, rc, v2 /* Wal-index hash table location */ + rc = _walHashGet(tls, pWal, _walFramePage(tls, iFrame), bp) + /* Assuming the wal-index file was successfully mapped, populate the + ** page number array and hash table entry. + */ + if rc == SQLITE_OK { /* Number of hash collisions */ + idx = libc.Int32FromUint32(iFrame - (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero) + /* If this is the first entry to be added to this hash-table, zero the + ** entire hash table and aPgno[] array before proceeding. + */ + if idx == int32(1) { + nByte = int32(int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash+uintptr(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))*2) - int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno)) + libc.Xmemset(tls, (**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno, 0, libc.Uint64FromInt32(nByte)) + } + /* If the entry in aPgno[] is already set, then the previous writer + ** must have exited unexpectedly in the middle of a transaction (after + ** writing one or more dirty pages to the WAL to free up memory). + ** Remove the remnants of that writers uncommitted transaction from + ** the hash-table before writing any new entries. + */ + if **(**Tu32)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno + uintptr(idx-int32(1))*4)) != 0 { + _walCleanupHash(tls, pWal) + } + /* Write the aPgno[] array entry and the hash-table slot. */ + nCollide = idx + iKey = _walHash(tls, iPage) + for { + if !(**(**Tht_slot)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash + uintptr(iKey)*2)) != 0) { + break + } + v2 = nCollide + nCollide = nCollide - 1 + if v2 == 0 { + return _sqlite3CorruptError(tls, int32(68778)) + } + goto _1 + _1: + ; + iKey = _walNextHash(tls, iKey) + } + **(**Tu32)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno + uintptr((idx-int32(1))&(libc.Int32FromInt32(HASHTABLE_NPAGE)-libc.Int32FromInt32(1)))*4)) = iPage + libc.AtomicStoreNUint16((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash+uintptr(iKey)*2, libc.Uint16FromInt32(idx), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + return rc +} + +// C documentation +// +// /* +// ** Obtain a pointer to the iPage'th page of the wal-index. The wal-index +// ** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are +// ** numbered from zero. +// ** +// ** If the wal-index is currently smaller the iPage pages then the size +// ** of the wal-index might be increased, but only if it is safe to do +// ** so. It is safe to enlarge the wal-index if pWal->writeLock is true +// ** or pWal->exclusiveMode==WAL_HEAPMEMORY_MODE. +// ** +// ** Three possible result scenarios: +// ** +// ** (1) rc==SQLITE_OK and *ppPage==Requested-Wal-Index-Page +// ** (2) rc>=SQLITE_ERROR and *ppPage==NULL +// ** (3) rc==SQLITE_OK and *ppPage==NULL // only if iPage==0 +// ** +// ** Scenario (3) can only occur when pWal->writeLock is false and iPage==0 +// */ +func _walIndexPageRealloc(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) (r int32) { + var apNew, v1 uintptr + var nByte Tsqlite3_int64 + var rc int32 + _, _, _, _ = apNew, nByte, rc, v1 + rc = SQLITE_OK + /* Enlarge the pWal->apWiData[] array if required */ + if (*TWal)(unsafe.Pointer(pWal)).FnWiData <= iPage { + nByte = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt64(libc.Int64FromInt32(1)+int64(iPage))) + apNew = _sqlite3Realloc(tls, (*TWal)(unsafe.Pointer(pWal)).FapWiData, libc.Uint64FromInt64(nByte)) + if !(apNew != 0) { + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, apNew+uintptr((*TWal)(unsafe.Pointer(pWal)).FnWiData)*8, 0, uint64(8)*libc.Uint64FromInt32(iPage+libc.Int32FromInt32(1)-(*TWal)(unsafe.Pointer(pWal)).FnWiData)) + (*TWal)(unsafe.Pointer(pWal)).FapWiData = apNew + (*TWal)(unsafe.Pointer(pWal)).FnWiData = iPage + int32(1) + } + /* Request a pointer to the required page from the VFS */ + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) == int32(WAL_HEAPMEMORY_MODE) { + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) = _sqlite3MallocZero(tls, uint64(libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4))) + if !(**(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) != 0) { + rc = int32(SQLITE_NOMEM) + } + } else { + rc = _sqlite3OsShmMap(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, iPage, libc.Int32FromUint64(libc.Uint64FromInt64(2)*libc.Uint64FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2))+libc.Uint64FromInt32(HASHTABLE_NPAGE)*libc.Uint64FromInt64(4)), libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FwriteLock), (*TWal)(unsafe.Pointer(pWal)).FapWiData+uintptr(iPage)*8) + if rc == SQLITE_OK { + if iPage > 0 && _sqlite3FaultSim(tls, int32(600)) != 0 { + rc = int32(SQLITE_NOMEM) + } + } else { + if rc&int32(0xff) == int32(SQLITE_READONLY) { + v1 = pWal + 66 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(WAL_SHM_RDONLY)) + if rc == int32(SQLITE_READONLY) { + rc = SQLITE_OK + } + } + } + } + **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) + return rc +} + +// C documentation +// +// /* +// ** Try to read the wal-index header. Return 0 on success and 1 if +// ** there is a problem. +// ** +// ** The wal-index is in shared memory. Another thread or process might +// ** be writing the header at the same time this procedure is trying to +// ** read it, which might result in inconsistency. A dirty read is detected +// ** by verifying that both copies of the header are the same and also by +// ** a checksum on the header. +// ** +// ** If and only if the read is consistent and the header is different from +// ** pWal->hdr, then pWal->hdr is updated to the content of the new header +// ** and *pChanged is set to 1. +// ** +// ** If the checksum cannot be verified return non-zero. If the header +// ** is read successfully and the checksum verified, return zero. +// */ +func _walIndexTryHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var aHdr uintptr + var _ /* aCksum at bp+0 */ [2]Tu32 + var _ /* h1 at bp+8 */ TWalIndexHdr + var _ /* h2 at bp+56 */ TWalIndexHdr + _ = aHdr /* Header in shared memory */ + /* The first page of the wal-index must be mapped at this point. */ + /* Read the header. This might happen concurrently with a write to the + ** same area of shared memory on a different CPU in a SMP, + ** meaning it is possible that an inconsistent snapshot is read + ** from the file. If this happens, return non-zero. + ** + ** tag-20200519-1: + ** There are two copies of the header at the beginning of the wal-index. + ** When reading, read [0] first then [1]. Writes are in the reverse order. + ** Memory barriers are used to prevent the compiler or the hardware from + ** reordering the reads and writes. TSAN and similar tools can sometimes + ** give false-positive warnings about these accesses because the tools do not + ** account for the double-read and the memory barrier. The use of mutexes + ** here would be problematic as the memory being accessed is potentially + ** shared among multiple processes and not all mutex implementations work + ** reliably in that environment. + */ + aHdr = _walIndexHdr(tls, pWal) + libc.Xmemcpy(tls, bp+8, aHdr, uint64(48)) /* Possible TSAN false-positive */ + _walShmBarrier(tls, pWal) + libc.Xmemcpy(tls, bp+56, aHdr+1*48, uint64(48)) + if libc.Xmemcmp(tls, bp+8, bp+56, uint64(48)) != 0 { + return int32(1) /* Dirty read */ + } + if libc.Int32FromUint8((**(**TWalIndexHdr)(__ccgo_up(bp + 8))).FisInit) == 0 { + return int32(1) /* Malformed header - probably all zeros */ + } + _walChecksumBytes(tls, int32(1), bp+8, libc.Int32FromUint64(libc.Uint64FromInt64(48)-libc.Uint64FromInt64(8)), uintptr(0), bp) + if (**(**[2]Tu32)(__ccgo_up(bp)))[0] != **(**Tu32)(__ccgo_up(bp + 8 + 40)) || (**(**[2]Tu32)(__ccgo_up(bp)))[int32(1)] != **(**Tu32)(__ccgo_up(bp + 8 + 40 + 1*4)) { + return int32(1) /* Checksum does not match */ + } + if libc.Xmemcmp(tls, pWal+72, bp+8, uint64(48)) != 0 { + **(**int32)(__ccgo_up(pChanged)) = int32(1) + libc.Xmemcpy(tls, pWal+72, bp+8, uint64(48)) + (*TWal)(unsafe.Pointer(pWal)).FszPage = libc.Uint32FromInt32(libc.Int32FromUint16((*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage)&int32(0xfe00) + libc.Int32FromUint16((*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage)&int32(0x0001)<hdr into the wal-index. +// ** +// ** The checksum on pWal->hdr is updated before it is written. +// */ +func _walIndexWriteHdr(tls *libc.TLS, pWal uintptr) { + var aHdr uintptr + var nCksum int32 + _, _ = aHdr, nCksum + aHdr = _walIndexHdr(tls, pWal) + nCksum = libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0) + 40)) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FisInit = uint8(1) + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FiVersion = uint32(WALINDEX_MAX_VERSION) + _walChecksumBytes(tls, int32(1), pWal+72, nCksum, uintptr(0), pWal+72+40) + /* Possible TSAN false-positive. See tag-20200519-1 */ + libc.Xmemcpy(tls, aHdr+1*48, pWal+72, uint64(48)) + _walShmBarrier(tls, pWal) + libc.Xmemcpy(tls, aHdr, pWal+72, uint64(48)) +} + +// C documentation +// +// /* +// ** Construct a WalInterator object that can be used to loop over all +// ** pages in the WAL following frame nBackfill in ascending order. Frames +// ** nBackfill or earlier may be included - excluding them is an optimization +// ** only. The caller must hold the checkpoint lock. +// ** +// ** On success, make *pp point to the newly allocated WalInterator object +// ** return SQLITE_OK. Otherwise, return an error code. If this routine +// ** returns an error, the value of *pp is undefined. +// ** +// ** The calling routine should invoke walIteratorFree() to destroy the +// ** WalIterator object when it has finished with it. +// */ +func _walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill Tu32, pp uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aIndex, aTmp, p uintptr + var i, j, nSegment, rc int32 + var iLast Tu32 + var nByte Tsqlite3_int64 + var v1 uint32 + var _ /* nEntry at bp+24 */ int32 + var _ /* sLoc at bp+0 */ TWalHashLoc + _, _, _, _, _, _, _, _, _, _ = aIndex, aTmp, i, iLast, j, nByte, nSegment, p, rc, v1 /* Temp space used by merge-sort */ + rc = SQLITE_OK /* Return Code */ + /* This routine only runs while holding the checkpoint lock. And + ** it only runs if there is actually content in the log (mxFrame>0). + */ + iLast = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + /* Allocate space for the WalIterator object. */ + nSegment = _walFramePage(tls, iLast) + int32(1) + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+8) + libc.Uint64FromInt32(nSegment)*uint64(32) + uint64(iLast)*uint64(2)) + if iLast > uint32(HASHTABLE_NPAGE) { + v1 = uint32(HASHTABLE_NPAGE) + } else { + v1 = iLast + } + p = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)+uint64(2)*uint64(v1)) + if !(p != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, p, 0, libc.Uint64FromInt64(nByte)) + (*TWalIterator)(unsafe.Pointer(p)).FnSegment = nSegment + aTmp = p + uintptr(nByte) + i = _walFramePage(tls, nBackfill+uint32(1)) + for { + if !(rc == SQLITE_OK && i < nSegment) { + break + } + rc = _walHashGet(tls, pWal, i, bp) + if rc == SQLITE_OK { /* Sorted index for this segment */ + if i+int32(1) == nSegment { + **(**int32)(__ccgo_up(bp + 24)) = libc.Int32FromUint32(iLast - (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero) + } else { + **(**int32)(__ccgo_up(bp + 24)) = int32((int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash) - int64((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno)) / 4) + } + aIndex = p + 8 + uintptr((*TWalIterator)(unsafe.Pointer(p)).FnSegment)*32 + uintptr((**(**TWalHashLoc)(__ccgo_up(bp))).FiZero)*2 + (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero = (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero + 1 + j = 0 + for { + if !(j < **(**int32)(__ccgo_up(bp + 24))) { + break + } + **(**Tht_slot)(__ccgo_up(aIndex + uintptr(j)*2)) = libc.Uint16FromInt32(j) + goto _3 + _3: + ; + j = j + 1 + } + _walMergesort(tls, (**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno, aTmp, aIndex, bp+24) + (*(*TWalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FiZero = libc.Int32FromUint32((**(**TWalHashLoc)(__ccgo_up(bp))).FiZero) + (*(*TWalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FnEntry = **(**int32)(__ccgo_up(bp + 24)) + (*(*TWalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FaIndex = aIndex + (*(*TWalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FaPgno = (**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno + } + goto _2 + _2: + ; + i = i + 1 + } + if rc != SQLITE_OK { + _walIteratorFree(tls, p) + p = uintptr(0) + } + **(**uintptr)(__ccgo_up(pp)) = p + return rc +} + +// C documentation +// +// /* +// ** This function merges two sorted lists into a single sorted list. +// ** +// ** aLeft[] and aRight[] are arrays of indices. The sort key is +// ** aContent[aLeft[]] and aContent[aRight[]]. Upon entry, the following +// ** is guaranteed for all J= nRight || **(**Tu32)(__ccgo_up(aContent + uintptr(**(**Tht_slot)(__ccgo_up(aLeft + uintptr(iLeft)*2)))*4)) < **(**Tu32)(__ccgo_up(aContent + uintptr(**(**Tht_slot)(__ccgo_up(aRight + uintptr(iRight)*2)))*4))) { + v1 = iLeft + iLeft = iLeft + 1 + logpage = **(**Tht_slot)(__ccgo_up(aLeft + uintptr(v1)*2)) + } else { + v1 = iRight + iRight = iRight + 1 + logpage = **(**Tht_slot)(__ccgo_up(aRight + uintptr(v1)*2)) + } + dbpage = **(**Tu32)(__ccgo_up(aContent + uintptr(logpage)*4)) + v1 = iOut + iOut = iOut + 1 + **(**Tht_slot)(__ccgo_up(aTmp + uintptr(v1)*2)) = logpage + if iLeft < nLeft && **(**Tu32)(__ccgo_up(aContent + uintptr(**(**Tht_slot)(__ccgo_up(aLeft + uintptr(iLeft)*2)))*4)) == dbpage { + iLeft = iLeft + 1 + } + } + **(**uintptr)(__ccgo_up(paRight)) = aLeft + **(**int32)(__ccgo_up(pnRight)) = iOut + libc.Xmemcpy(tls, aLeft, aTmp, uint64(2)*libc.Uint64FromInt32(iOut)) +} + +// C documentation +// +// /* +// ** Sort the elements in list aList using aContent[] as the sort key. +// ** Remove elements with duplicate keys, preferring to keep the +// ** larger aList[] values. +// ** +// ** The aList[] entries are indices into aContent[]. The values in +// ** aList[] are to be sorted so that for all Ja[] of the new WhereTerm is returned on success. +// ** 0 is returned if the new WhereTerm could not be added due to a memory +// ** allocation error. The memory allocation failure will be recorded in +// ** the db->mallocFailed flag so that higher-level functions can detect it. +// ** +// ** This routine will increase the size of the pWC->a[] array as necessary. +// ** +// ** If the wtFlags argument includes TERM_DYNAMIC, then responsibility +// ** for freeing the expression p is assumed by the WhereClause object pWC. +// ** This is true even if this routine fails to allocate a new WhereTerm. +// ** +// ** WARNING: This routine might reallocate the space used to store +// ** WhereTerms. All pointers to WhereTerms should be invalidated after +// ** calling this routine. Such pointers may be reinitialized by referencing +// ** the pWC->a[] array. +// */ +func _whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags Tu16) (r int32) { + var db, pOld, pTerm, v3 uintptr + var idx, v1, v2 int32 + _, _, _, _, _, _, _ = db, idx, pOld, pTerm, v1, v2, v3 + if (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm >= (*TWhereClause)(unsafe.Pointer(pWC)).FnSlot { + pOld = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + db = (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb + (*TWhereClause)(unsafe.Pointer(pWC)).Fa = _sqlite3WhereMalloc(tls, (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo, uint64(uint64(56)*libc.Uint64FromInt32((*TWhereClause)(unsafe.Pointer(pWC)).FnSlot)*uint64(2))) + if (*TWhereClause)(unsafe.Pointer(pWC)).Fa == uintptr(0) { + if libc.Int32FromUint16(wtFlags)&int32(TERM_DYNAMIC) != 0 { + _sqlite3ExprDelete(tls, db, p) + } + (*TWhereClause)(unsafe.Pointer(pWC)).Fa = pOld + return 0 + } + libc.Xmemcpy(tls, (*TWhereClause)(unsafe.Pointer(pWC)).Fa, pOld, uint64(56)*libc.Uint64FromInt32((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)) + (*TWhereClause)(unsafe.Pointer(pWC)).FnSlot = (*TWhereClause)(unsafe.Pointer(pWC)).FnSlot * int32(2) + } + v3 = pWC + 20 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v1 = v2 + idx = v1 + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(v1)*56 + if libc.Int32FromUint16(wtFlags)&int32(TERM_VIRTUAL) == 0 { + (*TWhereClause)(unsafe.Pointer(pWC)).FnBase = (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm + } + if p != 0 && (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Unlikely)) != uint32(0) { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = int16(int32(_sqlite3LogEst(tls, libc.Uint64FromInt32((*TExpr)(unsafe.Pointer(p)).FiTable))) - int32(270)) + } else { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = int16(1) + } + (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr = _sqlite3ExprSkipCollateAndLikely(tls, p) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags = wtFlags + (*TWhereTerm)(unsafe.Pointer(pTerm)).FpWC = pWC + (*TWhereTerm)(unsafe.Pointer(pTerm)).FiParent = -int32(1) + libc.Xmemset(tls, pTerm+20, 0, libc.Uint64FromInt64(56)-uint64(libc.UintptrFromInt32(0)+20)) + return idx +} + +// C documentation +// +// /* +// ** pIdx is an index that covers all of the low-number columns used by +// ** pWInfo->pSelect (columns from 0 through 62) or an index that has +// ** expressions terms. Hence, we cannot determine whether or not it is +// ** a covering index by using the colUsed bitmasks. We have to do a search +// ** to see if the index is covering. This routine does that search. +// ** +// ** The return value is one of these: +// ** +// ** 0 The index is definitely not a covering index +// ** +// ** WHERE_IDX_ONLY The index is definitely a covering index +// ** +// ** WHERE_EXPRIDX The index is likely a covering index, but it is +// ** difficult to determine precisely because of the +// ** expressions that are indexed. Score it as a +// ** covering index, but still keep the main table open +// ** just in case we need it. +// ** +// ** This routine is an optimization. It is always safe to return zero. +// ** But returning one of the other two values when zero should have been +// ** returned can lead to incorrect bytecode and assertion faults. +// */ +func _whereIsCoveringIndex(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iTabCur int32) (r Tu32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i, rc int32 + var _ /* ck at bp+0 */ TCoveringIndexCheck + var _ /* w at bp+16 */ TWalker + _, _ = i, rc + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect == uintptr(0) { + /* We don't have access to the full query, so we cannot check to see + ** if pIdx is covering. Assume it is not. */ + return uint32(0) + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x800>>11)) == 0 { + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i >= libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) { + /* pIdx does not index any columns greater than 62, but we know from + ** colMask that columns greater than 62 are used, so this is not a + ** covering index */ + return uint32(0) + } + } + (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FpIdx = pIdx + (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FiTabCur = iTabCur + (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FbExpr = uint8(0) + (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FbUnidx = uint8(0) + libc.Xmemset(tls, bp+16, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp + 16))).FxExprCallback = __ccgo_fp(_whereIsCoveringIndexWalkCallback) + (**(**TWalker)(__ccgo_up(bp + 16))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + *(*uintptr)(unsafe.Pointer(bp + 16 + 40)) = bp + _sqlite3WalkSelect(tls, bp+16, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect) + if (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FbUnidx != 0 { + rc = 0 + } else { + if (**(**TCoveringIndexCheck)(__ccgo_up(bp))).FbExpr != 0 { + rc = int32(WHERE_EXPRIDX) + } else { + rc = int32(WHERE_IDX_ONLY) + } + } + return libc.Uint32FromInt32(rc) +} + +// C documentation +// +// /* +// ** Add all WhereLoop objects for a single table of the join where the table +// ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be +// ** a b-tree table, not a virtual table. +// ** +// ** The costs (WhereLoop.rRun) of the b-tree loops added by this function +// ** are calculated as follows: +// ** +// ** For a full scan, assuming the table (or index) contains nRow rows: +// ** +// ** cost = nRow * 3.0 // full-table scan +// ** cost = nRow * K // scan of covering index +// ** cost = nRow * (K+3.0) // scan of non-covering index +// ** +// ** where K is a value between 1.1 and 3.0 set based on the relative +// ** estimated average size of the index and table records. +// ** +// ** For an index scan, where nVisit is the number of index rows visited +// ** by the scan, and nSeek is the number of seek operations required on +// ** the index b-tree: +// ** +// ** cost = nSeek * (log(nRow) + K * nVisit) // covering index +// ** cost = nSeek * (log(nRow) + (K+3.0) * nVisit) // non-covering index +// ** +// ** Normally, nSeek is 1. nSeek values greater than 1 come about if the +// ** WHERE clause includes "x IN (....)" terms used in place of "x=?". Or when +// ** implicit "x IN (SELECT x FROM tbl)" terms are added for skip-scans. +// ** +// ** The estimated values (nRow, nVisit, nSeek) often contain a large amount +// ** of uncertainty. For this reason, scoring is designed to pick plans that +// ** "do the least harm" if the estimates are inaccurate. For example, a +// ** log(nRow) factor is omitted from a non-covering index scan in order to +// ** bias the scoring in favor of using an index, since the worst-case +// ** performance of using an index is far better than the worst-case performance +// ** of a full table scan. +// */ +func _whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq TBitmask) (r int32) { + bp := tls.Alloc(176) + defer tls.Free(176) + var b, iCur, iSortIdx, ii, rc, v5 int32 + var isCov Tu32 + var nLookup, rLogSize, rSize TLogEst + var pFirst, pNew, pProbe, pSrc, pTab, pTabList, pTerm, pTerm1, pWC, pWC2, pWCEnd, pWInfo, v2 uintptr + var _ /* aiColumnPk at bp+164 */ Ti16 + var _ /* aiRowEstPk at bp+160 */ [2]TLogEst + var _ /* m at bp+168 */ TBitmask + var _ /* sPk at bp+0 */ TIndex + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = b, iCur, iSortIdx, ii, isCov, nLookup, pFirst, pNew, pProbe, pSrc, pTab, pTabList, pTerm, pTerm1, pWC, pWC2, pWCEnd, pWInfo, rLogSize, rSize, rc, v2, v5 /* The aiRowLogEst[] value for the sPk index */ + **(**Ti16)(__ccgo_up(bp + 164)) = int16(-int32(1)) /* Template WhereLoop object */ + rc = SQLITE_OK /* Return code */ + iSortIdx = int32(1) /* Table being queried */ + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + pTabList = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + pSrc = pTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pNew)).FiTab)*80 + pTab = (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab + pWC = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x2>>1) != 0 { + /* An INDEXED BY clause specifies a particular index to use */ + pProbe = *(*uintptr)(unsafe.Pointer(pSrc + 56)) + } else { + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pProbe = (*TTable)(unsafe.Pointer(pTab)).FpIndex + } else { /* First of real indices on the table */ + libc.Xmemset(tls, bp, 0, uint64(160)) + (**(**TIndex)(__ccgo_up(bp))).FnKeyCol = uint16(1) + (**(**TIndex)(__ccgo_up(bp))).FnColumn = uint16(1) + (**(**TIndex)(__ccgo_up(bp))).FaiColumn = bp + 164 + (**(**TIndex)(__ccgo_up(bp))).FaiRowLogEst = bp + 160 + (**(**TIndex)(__ccgo_up(bp))).FonError = uint8(OE_Replace) + (**(**TIndex)(__ccgo_up(bp))).FpTable = pTab + (**(**TIndex)(__ccgo_up(bp))).FszIdxRow = int16(3) /* TUNING: Interior rows of IPK table are very small */ + libc.SetBitFieldPtr16Uint32(bp+100, libc.Uint32FromInt32(SQLITE_IDXTYPE_IPK), 0, 0x3) + (**(**[2]TLogEst)(__ccgo_up(bp + 160)))[0] = (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst + (**(**[2]TLogEst)(__ccgo_up(bp + 160)))[int32(1)] = 0 + pFirst = (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FpIndex + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x1>>0) == 0 { + /* The real indices of the table are only considered if the + ** NOT INDEXED qualifier is omitted from the FROM clause */ + (**(**TIndex)(__ccgo_up(bp))).FpNext = pFirst + } + pProbe = bp + } + } + rSize = (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst + /* Automatic indexes */ + if !((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet != 0) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(libc.Int32FromInt32(WHERE_RIGHT_JOIN)|libc.Int32FromInt32(WHERE_OR_SUBCLAUSE)) == 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).Fflags&uint64(SQLITE_AutoIndex) != uint64(0) && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x2>>1) != 0) && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x1>>0) != 0) && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x10>>4) != 0) && !(int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x80>>7) != 0) && libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + pWCEnd = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)*56 + rLogSize = _estLog(tls, rSize) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(rc == SQLITE_OK && pTerm < pWCEnd) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&(*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf != 0 { + goto _1 + } + if _termCanDriveIndex(tls, pTerm, pSrc, uint64(0)) != 0 { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq = uint16(1) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip = uint16(0) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FpIndex = uintptr(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = uint16(1) + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm + /* TUNING: One-time cost for computing the automatic index is + ** estimated to be X*N*log2(N) where N is the number of rows in + ** the table being indexed and where X is 7 (LogEst=28) for normal + ** tables or 0.5 (LogEst=-10) for views and subqueries. The value + ** of X is smaller for views and subqueries so that the query planner + ** will be more aggressive about generating automatic indexes for + ** those objects, since there is no opportunity to add schema + ** indexes on subqueries and views. */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(int32(rLogSize) + int32(rSize)) + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VIEW)) && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Ephemeral) == uint32(0) { + v2 = pNew + 18 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) + libc.Int32FromInt32(28)) + } else { + v2 = pNew + 18 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) - libc.Int32FromInt32(25)) /* Greatly reduced setup cost for auto indexes + ** on ephemeral materializations of views */ + } + if int32((*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup) < 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = 0 + } + /* TUNING: Each index lookup yields 20 rows in the table. This + ** is more than the usual guess of 10 rows, since we have no way + ** of knowing how selective the index will ultimately be. It would + ** not be unreasonable to make this value much larger. */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = int16(43) + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = _sqlite3LogEstAdd(tls, rLogSize, (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut) + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_AUTO_INDEX) + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight + rc = _whereLoopInsert(tls, pBuilder, pNew) + } + goto _1 + _1: + ; + pTerm += 56 + } + } + /* Loop over all indices. If there was an INDEXED BY clause, then only + ** consider index pProbe. */ + for { + if !(rc == SQLITE_OK && pProbe != 0) { + break + } + if (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0) && !(_whereUsablePartialIndex(tls, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor, (*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype, pWC, (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere) != 0) { + /* See ticket [98d973b8f5] */ + goto _4 /* Partial index inappropriate for this query */ + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x100>>8)) != 0 { + goto _4 + } + rSize = **(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst)) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq = uint16(0) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnBtm = uint16(0) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnTop = uint16(0) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnDistinctCol = uint16(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip = uint16(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = uint16(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = uint8(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = 0 + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FpIndex = pProbe + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FpOrderBy = uintptr(0) + b = _indexMightHelpWithOrderBy(tls, pBuilder, pProbe, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor) + /* The ONEPASS_DESIRED flags never occurs together with ORDER BY */ + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_IPK) { + /* Integer primary key index */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_IPK) + /* Full table scan */ + if b != 0 { + v5 = iSortIdx + } else { + v5 = 0 + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = libc.Uint8FromInt32(v5) + /* TUNING: Cost of full table scan is 3.0*N. The 3.0 factor is an + ** extra cost designed to discourage the use of full table scans, + ** since index lookups have better worst-case performance if our + ** stat guesses are wrong. Reduce the 3.0 penalty slightly + ** (to 2.75) if we have valid STAT4 information for the table. + ** At 2.75, a full table scan is preferred over using an index on + ** a column with just two distinct values where each value has about + ** an equal number of appearances. Without STAT4 data, we still want + ** to use an index in that case, since the constraint might be for + ** the scarcer of the two values, and in that case an index lookup is + ** better. + */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = int16(int32(rSize) + int32(16) - int32(2)*libc.BoolInt32((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasStat4) != uint32(0))) + _whereLoopOutputAdjust(tls, pWC, pNew, rSize) + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x4>>2) != 0 { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40>>6) != 0 { + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_COROUTINE) + } + /* Do not set btree.pOrderBy for a recursive CTE. In this case + ** the ORDER BY clause does not determine the overall order that + ** rows are emitted from the CTE in. */ + if (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FpSelect)).FselFlags&uint32(SF_Recursive) == uint32(0) { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FpOrderBy = (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FpSelect)).FpOrderBy + } + } else { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40000>>18) != 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = 0 + } + } + rc = _whereLoopInsert(tls, pBuilder, pNew) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize + if rc != 0 { + break + } + } else { + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x20>>5)) != 0 { + **(**TBitmask)(__ccgo_up(bp + 168)) = uint64(0) + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY) | libc.Int32FromInt32(WHERE_INDEXED)) + } else { + **(**TBitmask)(__ccgo_up(bp + 168)) = (*TSrcItem)(unsafe.Pointer(pSrc)).FcolUsed & (*TIndex)(unsafe.Pointer(pProbe)).FcolNotIdxed + if (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere != 0 { + _wherePartIdxExpr(tls, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse, pProbe, (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere, bp+168, 0, uintptr(0)) + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_INDEXED) + if **(**TBitmask)(__ccgo_up(bp + 168)) == libc.Uint64FromInt32(1)<<(libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1)) || int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x800>>11)) != 0 && !(int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x400>>10)) != 0) && **(**TBitmask)(__ccgo_up(bp + 168)) != uint64(0) { + isCov = _whereIsCoveringIndex(tls, pWInfo, pProbe, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor) + if isCov == uint32(0) { + } else { + **(**TBitmask)(__ccgo_up(bp + 168)) = uint64(0) + **(**Tu32)(__ccgo_up(pNew + 48)) |= isCov + if isCov&uint32(WHERE_IDX_ONLY) != 0 { + } else { + } + } + } else { + if **(**TBitmask)(__ccgo_up(bp + 168)) == uint64(0) && ((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect != uintptr(0) || _sqlite3FaultSim(tls, int32(700)) != 0) { + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY) | libc.Int32FromInt32(WHERE_INDEXED)) + } + } + } + /* Full scan via index */ + if b != 0 || !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) || (*TIndex)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0) || int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x2>>1) != 0 || **(**TBitmask)(__ccgo_up(bp + 168)) == uint64(0) && int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x4>>2)) == 0 && int32((*TIndex)(unsafe.Pointer(pProbe)).FszIdxRow) < int32((*TTable)(unsafe.Pointer(pTab)).FszTabRow) && libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_ONEPASS_DESIRED) == 0 && _sqlite3Config.FbUseCis != 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_CoverIdxScan)) == uint32(0) { + if b != 0 { + v5 = iSortIdx + } else { + v5 = 0 + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = libc.Uint8FromInt32(v5) + /* The cost of visiting the index rows is N*K, where K is + ** between 1.1 and 3.0, depending on the relative sizes of the + ** index and table rows. */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = int16(int32(rSize) + int32(1) + int32(15)*int32((*TIndex)(unsafe.Pointer(pProbe)).FszIdxRow)/int32((*TTable)(unsafe.Pointer(pTab)).FszTabRow)) + if **(**TBitmask)(__ccgo_up(bp + 168)) != uint64(0) { + /* If this is a non-covering index scan, add in the cost of + ** doing table lookups. The cost will be 3x the number of + ** lookups. Take into account WHERE clause terms that can be + ** satisfied using just the index, and that do not require a + ** table lookup. */ + nLookup = int16(int32(rSize) + int32(16)) + iCur = (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor + pWC2 = pWInfo + 104 + ii = 0 + for { + if !(ii < (*TWhereClause)(unsafe.Pointer(pWC2)).FnTerm) { + break + } + pTerm1 = (*TWhereClause)(unsafe.Pointer(pWC2)).Fa + uintptr(ii)*56 + if !(_sqlite3ExprCoveredByIndex(tls, (*TWhereTerm)(unsafe.Pointer(pTerm1)).FpExpr, iCur, pProbe) != 0) { + break + } + /* pTerm can be evaluated using just the index. So reduce + ** the expected number of table lookups accordingly */ + if int32((*TWhereTerm)(unsafe.Pointer(pTerm1)).FtruthProb) <= 0 { + nLookup = int16(int32(nLookup) + int32((*TWhereTerm)(unsafe.Pointer(pTerm1)).FtruthProb)) + } else { + nLookup = nLookup - 1 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm1)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) != 0 { + nLookup = int16(int32(nLookup) - libc.Int32FromInt32(19)) + } + } + goto _7 + _7: + ; + ii = ii + 1 + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = _sqlite3LogEstAdd(tls, (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun, nLookup) + } + _whereLoopOutputAdjust(tls, pWC, pNew, rSize) + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 && (*TIndex)(unsafe.Pointer(pProbe)).FaColExpr != 0 { + /* Do not do an SCAN of a index-on-expression in a RIGHT JOIN + ** because the cursor used to access the index might not be + ** positioned to the correct row during the right-join no-match + ** loop. */ + } else { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40000>>18) != 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = 0 + } + rc = _whereLoopInsert(tls, pBuilder, pNew) + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize + if rc != 0 { + break + } + } + } + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1 = uint8(0) + rc = _whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, 0) + if libc.Int32FromUint8((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1) == int32(SQLITE_BLDF1_INDEXED) { + /* If a non-unique index is used, or if a prefix of the key for + ** unique index is used (making the index functionally non-unique) + ** then the sqlite_stat1 data becomes important for scoring the + ** plan */ + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_MaybeReanalyze) + } + _sqlite3Stat4ProbeFree(tls, (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec) + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = 0 + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = uintptr(0) + goto _4 + _4: + ; + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x2>>1) != 0 { + v2 = uintptr(0) + } else { + v2 = (*TIndex)(unsafe.Pointer(pProbe)).FpNext + } + pProbe = v2 + iSortIdx = iSortIdx + 1 + } + return rc +} + +// C documentation +// +// /* +// ** Add WhereLoop entries to handle OR terms. This works for either +// ** btrees or virtual tables. +// */ +func _whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq TBitmask, mUnusable TBitmask) (r int32) { + bp := tls.Alloc(720) + defer tls.Free(720) + var i, iCur, j, once, rc int32 + var pItem, pNew, pOrTerm, pOrWC, pOrWCEnd, pTerm, pWC, pWCEnd, pWInfo uintptr + var _ /* sCur at bp+600 */ TWhereOrSet + var _ /* sPrev at bp+656 */ TWhereOrSet + var _ /* sSubBuild at bp+488 */ TWhereLoopBuilder + var _ /* sSum at bp+544 */ TWhereOrSet + var _ /* tempWC at bp+0 */ TWhereClause + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iCur, j, once, pItem, pNew, pOrTerm, pOrWC, pOrWCEnd, pTerm, pWC, pWCEnd, pWInfo, rc + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + rc = SQLITE_OK + pWC = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC + pWCEnd = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)*56 + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + libc.Xmemset(tls, bp+544, 0, uint64(56)) + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pNew)).FiTab)*80 + iCur = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + /* The multi-index OR optimization does not work for RIGHT and FULL JOIN */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) != 0 { + return SQLITE_OK + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(pTerm < pWCEnd && rc == SQLITE_OK) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_OR) != 0 && (*TWhereOrInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 32)))).Findexable&(*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf != uint64(0) { + pOrWC = *(*uintptr)(unsafe.Pointer(pTerm + 32)) + pOrWCEnd = (*TWhereClause)(unsafe.Pointer(pOrWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pOrWC)).FnTerm)*56 + once = int32(1) + **(**TWhereLoopBuilder)(__ccgo_up(bp + 488)) = **(**TWhereLoopBuilder)(__ccgo_up(pBuilder)) + (**(**TWhereLoopBuilder)(__ccgo_up(bp + 488))).FpOrSet = bp + 600 + pOrTerm = (*TWhereClause)(unsafe.Pointer(pOrWC)).Fa + for { + if !(pOrTerm < pOrWCEnd) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&int32(WO_AND) != 0 { + (**(**TWhereLoopBuilder)(__ccgo_up(bp + 488))).FpWC = *(*uintptr)(unsafe.Pointer(pOrTerm + 32)) + } else { + if (*TWhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur { + (**(**TWhereClause)(__ccgo_up(bp))).FpWInfo = (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo + (**(**TWhereClause)(__ccgo_up(bp))).FpOuter = pWC + (**(**TWhereClause)(__ccgo_up(bp))).Fop = uint8(TK_AND) + (**(**TWhereClause)(__ccgo_up(bp))).FnTerm = int32(1) + (**(**TWhereClause)(__ccgo_up(bp))).FnBase = int32(1) + (**(**TWhereClause)(__ccgo_up(bp))).Fa = pOrTerm + (**(**TWhereLoopBuilder)(__ccgo_up(bp + 488))).FpWC = bp + } else { + goto _2 + } + } + (**(**TWhereOrSet)(__ccgo_up(bp + 600))).Fn = uint16(0) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FeTabType) == int32(TABTYP_VTAB) { + rc = _whereLoopAddVirtual(tls, bp+488, mPrereq, mUnusable) + } else { + rc = _whereLoopAddBtree(tls, bp+488, mPrereq) + } + if rc == SQLITE_OK { + rc = _whereLoopAddOr(tls, bp+488, mPrereq, mUnusable) + } + if libc.Int32FromUint16((**(**TWhereOrSet)(__ccgo_up(bp + 600))).Fn) == 0 { + (**(**TWhereOrSet)(__ccgo_up(bp + 544))).Fn = uint16(0) + break + } else { + if once != 0 { + _whereOrMove(tls, bp+544, bp+600) + once = 0 + } else { + _whereOrMove(tls, bp+656, bp+544) + (**(**TWhereOrSet)(__ccgo_up(bp + 544))).Fn = uint16(0) + i = 0 + for { + if !(i < libc.Int32FromUint16((**(**TWhereOrSet)(__ccgo_up(bp + 656))).Fn)) { + break + } + j = 0 + for { + if !(j < libc.Int32FromUint16((**(**TWhereOrSet)(__ccgo_up(bp + 600))).Fn)) { + break + } + _whereOrInsert(tls, bp+544, (**(**TWhereOrCost)(__ccgo_up(bp + 656 + 8 + uintptr(i)*16))).Fprereq|(**(**TWhereOrCost)(__ccgo_up(bp + 600 + 8 + uintptr(j)*16))).Fprereq, _sqlite3LogEstAdd(tls, (**(**TWhereOrCost)(__ccgo_up(bp + 656 + 8 + uintptr(i)*16))).FrRun, (**(**TWhereOrCost)(__ccgo_up(bp + 600 + 8 + uintptr(j)*16))).FrRun), _sqlite3LogEstAdd(tls, (**(**TWhereOrCost)(__ccgo_up(bp + 656 + 8 + uintptr(i)*16))).FnOut, (**(**TWhereOrCost)(__ccgo_up(bp + 600 + 8 + uintptr(j)*16))).FnOut)) + goto _4 + _4: + ; + j = j + 1 + } + goto _3 + _3: + ; + i = i + 1 + } + } + } + goto _2 + _2: + ; + pOrTerm += 56 + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = uint16(1) + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_MULTI_OR) + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = 0 + (*TWhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = uint8(0) + libc.Xmemset(tls, pNew+24, 0, uint64(24)) + i = 0 + for { + if !(rc == SQLITE_OK && i < libc.Int32FromUint16((**(**TWhereOrSet)(__ccgo_up(bp + 544))).Fn)) { + break + } + /* TUNING: Currently sSum.a[i].rRun is set to the sum of the costs + ** of all sub-scans required by the OR-scan. However, due to rounding + ** errors, it may be that the cost of the OR-scan is equal to its + ** most expensive sub-scan. Add the smallest possible penalty + ** (equivalent to multiplying the cost by 1.07) to ensure that + ** this does not happen. Otherwise, for WHERE clauses such as the + ** following where there is an index on "y": + ** + ** WHERE likelihood(x=?, 0.99) OR y=? + ** + ** the planner may elect to "OR" together a full-table scan and an + ** index lookup. And other similarly odd results. */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = int16(int32((**(**TWhereOrCost)(__ccgo_up(bp + 544 + 8 + uintptr(i)*16))).FrRun) + int32(1)) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = (**(**TWhereOrCost)(__ccgo_up(bp + 544 + 8 + uintptr(i)*16))).FnOut + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = (**(**TWhereOrCost)(__ccgo_up(bp + 544 + 8 + uintptr(i)*16))).Fprereq + rc = _whereLoopInsert(tls, pBuilder, pNew) + goto _5 + _5: + ; + i = i + 1 + } + } + goto _1 + _1: + ; + pTerm += 56 + } + return rc +} + +// C documentation +// +// /* +// ** Increase the memory allocation for pLoop->aLTerm[] to be at least n. +// */ +func _whereLoopResize(tls *libc.TLS, db uintptr, p uintptr, n int32) (r int32) { + var paNew uintptr + _ = paNew + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(p)).FnLSlot) >= n { + return SQLITE_OK + } + n = (n + int32(7)) & ^libc.Int32FromInt32(7) + paNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(8)*libc.Uint64FromInt32(n))) + if paNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, paNew, (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm, uint64(8)*uint64((*TWhereLoop)(unsafe.Pointer(p)).FnLSlot)) + if (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm != p+80 { + _sqlite3DbFreeNN(tls, db, (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm) + } + (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm = paNew + (*TWhereLoop)(unsafe.Pointer(p)).FnLSlot = libc.Uint16FromInt32(n) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Transfer content from the second pLoop into the first. +// */ +func _whereLoopXfer(tls *libc.TLS, db uintptr, pTo uintptr, pFrom uintptr) (r int32) { + _whereLoopClearUnion(tls, db, pTo) + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pFrom)).FnLTerm) > libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pTo)).FnLSlot) && _whereLoopResize(tls, db, pTo, libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pFrom)).FnLTerm)) != 0 { + libc.Xmemset(tls, pTo, 0, uint64(libc.UintptrFromInt32(0)+56)) + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, pTo, pFrom, uint64(libc.UintptrFromInt32(0)+56)) + libc.Xmemcpy(tls, (*TWhereLoop)(unsafe.Pointer(pTo)).FaLTerm, (*TWhereLoop)(unsafe.Pointer(pFrom)).FaLTerm, uint64((*TWhereLoop)(unsafe.Pointer(pTo)).FnLTerm)*uint64(8)) + if (*TWhereLoop)(unsafe.Pointer(pFrom)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != 0 { + libc.SetBitFieldPtr8Uint32(pFrom+24+4, libc.Uint32FromInt32(0), 0, 0x1) + } else { + if (*TWhereLoop)(unsafe.Pointer(pFrom)).FwsFlags&uint32(WHERE_AUTO_INDEX) != uint32(0) { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pFrom + 24))).FpIndex = uintptr(0) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* Attempt to omit tables from a join that do not affect the result. +// ** For a table to not affect the result, the following must be true: +// ** +// ** 1) The query must not be an aggregate. +// ** 2) The table must be the RHS of a LEFT JOIN. +// ** 3) Either the query must be DISTINCT, or else the ON or USING clause +// ** must contain a constraint that limits the scan of the table to +// ** at most a single row. +// ** 4) The table must not be referenced by any part of the query apart +// ** from its own USING or ON clause. +// ** 5) The table must not have an inner-join ON or USING clause if there is +// ** a RIGHT JOIN anywhere in the query. Otherwise the ON/USING clause +// ** might move from the right side to the left side of the RIGHT JOIN. +// ** Note: Due to (2), this condition can only arise if the table is +// ** the right-most table of a subquery that was flattened into the +// ** main query and that subquery was the right-hand operand of an +// ** inner join that held an ON or USING clause. +// ** 6) The ORDER BY clause has 63 or fewer terms +// ** 7) The omit-noop-join optimization is enabled. +// ** +// ** Items (1), (6), and (7) are checked by the caller. +// ** +// ** For example, given: +// ** +// ** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1); +// ** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2); +// ** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3); +// ** +// ** then table t2 can be omitted from the following: +// ** +// ** SELECT v1, v3 FROM t1 +// ** LEFT JOIN t2 ON (t1.ipk=t2.ipk) +// ** LEFT JOIN t3 ON (t1.ipk=t3.ipk) +// ** +// ** or from: +// ** +// ** SELECT DISTINCT v1, v3 FROM t1 +// ** LEFT JOIN t2 +// ** LEFT JOIN t3 ON (t1.ipk=t3.ipk) +// */ +func _whereOmitNoopJoin(tls *libc.TLS, pWInfo uintptr, notReady TBitmask) (r TBitmask) { + var hasRightJoin, i, nByte int32 + var m1, tabUsed TBitmask + var pEnd, pItem, pLoop, pTerm, v4 uintptr + _, _, _, _, _, _, _, _, _, _ = hasRightJoin, i, m1, nByte, pEnd, pItem, pLoop, pTerm, tabUsed, v4 + /* Preconditions checked by the caller */ + /* These two preconditions checked by the caller combine to guarantee + ** condition (1) of the header comment */ + tabUsed = _sqlite3WhereExprListUsage(tls, pWInfo+592, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet) + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { + tabUsed = tabUsed | _sqlite3WhereExprListUsage(tls, pWInfo+592, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy) + } + hasRightJoin = libc.BoolInt32(libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0) + i = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - int32(1) + for { + if !(i >= int32(1)) { + break + } + pLoop = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(i)*112))).FpWLoop + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pLoop)).FiTab)*80 + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_RIGHT)) != int32(JT_LEFT) { + goto _1 + } + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) == 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_ONEROW) == uint32(0) { + goto _1 + } + if tabUsed&(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) { + goto _1 + } + pEnd = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + uintptr((*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.FnTerm)*56 + pTerm = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + for { + if !(pTerm < pEnd) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) { + if !((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) || *(*int32)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + 52)) != (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor { + break + } + } + if hasRightJoin != 0 && (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) != uint32(0) && *(*int32)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + 52)) == (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor { + break /* restriction (5) */ + } + goto _2 + _2: + ; + pTerm += 56 + } + if pTerm < pEnd { + goto _1 + } + m1 = libc.Uint64FromInt32(1)<>libc.Int32FromInt32(1) & ^m1 + notReady = notReady & ^(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf + pTerm = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + for { + if !(pTerm < pEnd) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) { + v4 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(TERM_CODED)) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = uint64(0) + } + goto _3 + _3: + ; + pTerm += 56 + } + if i != libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-int32(1) { + nByte = libc.Int32FromUint64(libc.Uint64FromInt32(libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-libc.Int32FromInt32(1)-i) * uint64(112)) + libc.Xmemmove(tls, pWInfo+856+uintptr(i)*112, pWInfo+856+uintptr(i+int32(1))*112, libc.Uint64FromInt32(nByte)) + } + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel - 1 + goto _1 + _1: + ; + i = i - 1 + } + return notReady +} + +// C documentation +// +// /* +// ** The journal file must be open when this routine is called. A journal +// ** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the +// ** current location. +// ** +// ** The format for the journal header is as follows: +// ** - 8 bytes: Magic identifying journal format. +// ** - 4 bytes: Number of records in journal, or -1 no-sync mode is on. +// ** - 4 bytes: Random number used for page hash. +// ** - 4 bytes: Initial database page count. +// ** - 4 bytes: Sector size used by the process that wrote this journal. +// ** - 4 bytes: Database page size. +// ** +// ** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space. +// */ +func _writeJournalHdr(tls *libc.TLS, pPager uintptr) (r int32) { + var ii, rc int32 + var nHeader, nWrite Tu32 + var zHeader uintptr + var v2 Ti64 + _, _, _, _, _, _ = ii, nHeader, nWrite, rc, zHeader, v2 + rc = SQLITE_OK /* Return code */ + zHeader = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace /* Temporary space used to build header */ + nHeader = libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) /* Loop counter */ + /* Journal file must be open. */ + if nHeader > (*TPager)(unsafe.Pointer(pPager)).FsectorSize { + nHeader = (*TPager)(unsafe.Pointer(pPager)).FsectorSize + } + /* If there are active savepoints and any of them were created + ** since the most recent journal header was written, update the + ** PagerSavepoint.iHdrOffset fields now. + */ + ii = 0 + for { + if !(ii < (*TPager)(unsafe.Pointer(pPager)).FnSavepoint) { + break + } + if (**(**TPagerSavepoint)(__ccgo_up((*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*56))).FiHdrOffset == 0 { + (**(**TPagerSavepoint)(__ccgo_up((*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*56))).FiHdrOffset = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + } + goto _1 + _1: + ; + ii = ii + 1 + } + v2 = _journalHdrOffset(tls, pPager) + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = v2 + (*TPager)(unsafe.Pointer(pPager)).FjournalHdr = v2 + /* + ** Write the nRec Field - the number of page records that follow this + ** journal header. Normally, zero is written to this value at this time. + ** After the records are added to the journal (and the journal synced, + ** if in full-sync mode), the zero is overwritten with the true number + ** of records (see syncJournal()). + ** + ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When + ** reading the journal this value tells SQLite to assume that the + ** rest of the journal file contains valid page records. This assumption + ** is dangerous, as if a failure occurred whilst writing to the journal + ** file it may contain some garbage data. There are two scenarios + ** where this risk can be ignored: + ** + ** * When the pager is in no-sync mode. Corruption can follow a + ** power failure in this case anyway. + ** + ** * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees + ** that garbage data is never appended to the journal file. + */ + if (*TPager)(unsafe.Pointer(pPager)).FnoSync != 0 || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_MEMORY) || _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd)&int32(SQLITE_IOCAP_SAFE_APPEND) != 0 { + libc.Xmemcpy(tls, zHeader, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8)) + _sqlite3Put4byte(tls, zHeader+uintptr(8), uint32(0xffffffff)) + } else { + libc.Xmemset(tls, zHeader, 0, libc.Uint64FromInt64(8)+libc.Uint64FromInt32(4)) + } + /* The random check-hash initializer */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) != int32(PAGER_JOURNALMODE_MEMORY) { + Xsqlite3_randomness(tls, int32(4), pPager+56) + } + _sqlite3Put4byte(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(4)), (*TPager)(unsafe.Pointer(pPager)).FcksumInit) + /* The initial database size */ + _sqlite3Put4byte(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(8)), (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize) + /* The assumed sector size for this process */ + _sqlite3Put4byte(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(12)), (*TPager)(unsafe.Pointer(pPager)).FsectorSize) + /* The page size */ + _sqlite3Put4byte(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(16)), libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize)) + /* Initializing the tail of the buffer is not necessary. Everything + ** works find if the following memset() is omitted. But initializing + ** the memory prevents valgrind from complaining, so we are willing to + ** take the performance hit. + */ + libc.Xmemset(tls, zHeader+uintptr(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(20)), 0, uint64(nHeader)-(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(20))) + /* In theory, it is only necessary to write the 28 bytes that the + ** journal header consumes to the journal file here. Then increment the + ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next + ** record is written to the following sector (leaving a gap in the file + ** that will be implicitly filled in by the OS). + ** + ** However it has been discovered that on some systems this pattern can + ** be significantly slower than contiguously writing data to the file, + ** even if that means explicitly writing data to the block of + ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what + ** is done. + ** + ** The loop is required here in case the sector-size is larger than the + ** database page size. Since the zHeader buffer is only Pager.pageSize + ** bytes in size, more than one call to sqlite3OsWrite() may be required + ** to populate the entire journal header sector. + */ + nWrite = uint32(0) + for { + if !(rc == SQLITE_OK && nWrite < (*TPager)(unsafe.Pointer(pPager)).FsectorSize) { + break + } + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, zHeader, libc.Int32FromUint32(nHeader), (*TPager)(unsafe.Pointer(pPager)).FjournalOff) + **(**Ti64)(__ccgo_up(pPager + 96)) += libc.Int64FromUint32(nHeader) + goto _3 + _3: + ; + nWrite = nWrite + nHeader + } + return rc +} + +// C documentation +// +// /* +// ** Try to increase the size of the parser stack. Return the number +// ** of errors. Return 0 on success. +// */ +func _yyGrowStack(tls *libc.TLS, p uintptr) (r int32) { + var idx, nLimit, newSize, oldSize int32 + var pNew uintptr + _, _, _, _, _ = idx, nLimit, newSize, oldSize, pNew + oldSize = int32(1) + int32((int64((*TyyParser)(unsafe.Pointer(p)).FyystackEnd)-int64((*TyyParser)(unsafe.Pointer(p)).Fyystack))/24) + nLimit = _parserStackSizeLimit(tls, (*TyyParser)(unsafe.Pointer(p)).FpParse) + newSize = oldSize*int32(2) + int32(100) + if newSize > nLimit { + newSize = nLimit + if newSize <= oldSize { + return int32(1) + } + } + idx = int32((int64((*TyyParser)(unsafe.Pointer(p)).Fyytos) - int64((*TyyParser)(unsafe.Pointer(p)).Fyystack)) / 24) + if (*TyyParser)(unsafe.Pointer(p)).Fyystack == p+32 { + pNew = _parserStackRealloc(tls, uintptr(0), uint64(libc.Uint64FromInt32(newSize)*uint64(24)), (*TyyParser)(unsafe.Pointer(p)).FpParse) + if pNew == uintptr(0) { + return int32(1) + } + libc.Xmemcpy(tls, pNew, (*TyyParser)(unsafe.Pointer(p)).Fyystack, libc.Uint64FromInt32(oldSize)*uint64(24)) + } else { + pNew = _parserStackRealloc(tls, (*TyyParser)(unsafe.Pointer(p)).Fyystack, uint64(libc.Uint64FromInt32(newSize)*uint64(24)), (*TyyParser)(unsafe.Pointer(p)).FpParse) + if pNew == uintptr(0) { + return int32(1) + } + } + (*TyyParser)(unsafe.Pointer(p)).Fyystack = pNew + (*TyyParser)(unsafe.Pointer(p)).Fyytos = (*TyyParser)(unsafe.Pointer(p)).Fyystack + uintptr(idx)*24 + (*TyyParser)(unsafe.Pointer(p)).FyystackEnd = (*TyyParser)(unsafe.Pointer(p)).Fyystack + uintptr(newSize-int32(1))*24 + return 0 +} + +/* Datatype of the argument to the memory allocated passed as the +** second argument to sqlite3ParserAlloc() below. This can be changed by +** putting an appropriate #define in the %include section of the input +** grammar. + */ + +func init() { + p := unsafe.Pointer(&_aVfs) + *(*uintptr)(unsafe.Add(p, 32)) = uintptr(unsafe.Pointer(&_posixIoFinder)) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 200)) = uintptr(unsafe.Pointer(&_nolockIoFinder)) + *(*uintptr)(unsafe.Add(p, 208)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 216)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 232)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 248)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 256)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 264)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 280)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 288)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 304)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 328)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 368)) = uintptr(unsafe.Pointer(&_dotlockIoFinder)) + *(*uintptr)(unsafe.Add(p, 376)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 400)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 408)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 416)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 424)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 432)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 440)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 448)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 464)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 472)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 480)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 488)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 496)) = __ccgo_fp(_unixNextSystemCall) + *(*uintptr)(unsafe.Add(p, 536)) = uintptr(unsafe.Pointer(&_posixIoFinder)) + *(*uintptr)(unsafe.Add(p, 544)) = __ccgo_fp(_unixOpen) + *(*uintptr)(unsafe.Add(p, 552)) = __ccgo_fp(_unixDelete) + *(*uintptr)(unsafe.Add(p, 560)) = __ccgo_fp(_unixAccess) + *(*uintptr)(unsafe.Add(p, 568)) = __ccgo_fp(_unixFullPathname) + *(*uintptr)(unsafe.Add(p, 576)) = __ccgo_fp(_unixDlOpen) + *(*uintptr)(unsafe.Add(p, 584)) = __ccgo_fp(_unixDlError) + *(*uintptr)(unsafe.Add(p, 592)) = __ccgo_fp(_unixDlSym) + *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(_unixDlClose) + *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(_unixRandomness) + *(*uintptr)(unsafe.Add(p, 616)) = __ccgo_fp(_unixSleep) + *(*uintptr)(unsafe.Add(p, 624)) = __ccgo_fp(_unixCurrentTime) + *(*uintptr)(unsafe.Add(p, 632)) = __ccgo_fp(_unixGetLastError) + *(*uintptr)(unsafe.Add(p, 640)) = __ccgo_fp(_unixCurrentTimeInt64) + *(*uintptr)(unsafe.Add(p, 648)) = __ccgo_fp(_unixSetSystemCall) + *(*uintptr)(unsafe.Add(p, 656)) = __ccgo_fp(_unixGetSystemCall) + *(*uintptr)(unsafe.Add(p, 664)) = __ccgo_fp(_unixNextSystemCall) +} diff --git a/internal/engine/lib/sqlite_g_000000000001feab.go b/internal/engine/lib/sqlite_g_000000000001feab.go new file mode 100644 index 0000000..4dc8c76 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001feab.go @@ -0,0 +1,31631 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type Tldiv_t = struct { + Fquot int64 + Frem int64 +} + +type Ttm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + Ftm_gmtoff int64 + Ftm_zone uintptr +} + +type Tu_long = uint64 + +// C documentation +// +// /* +// ** Copy nPage pages from the source b-tree to the destination. +// */ +func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bCloseTrans, destMode, ii, nDestTruncate, nSrcPage, pgszDest, pgszSrc, ratio, rc, v1 int32 + var iEnd, iOff, iSize Ti64 + var iPg, iSrcPg, iSrcPg1 TPgno + var pDestPager, pFile, pSrcPager, zData uintptr + var v2 bool + var v5 int64 + var _ /* nDstPage at bp+8 */ int32 + var _ /* pPg at bp+16 */ uintptr + var _ /* pSrcPg at bp+0 */ uintptr + var _ /* pSrcPg at bp+24 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bCloseTrans, destMode, iEnd, iOff, iPg, iSize, iSrcPg, iSrcPg1, ii, nDestTruncate, nSrcPage, pDestPager, pFile, pSrcPager, pgszDest, pgszSrc, ratio, rc, zData, v1, v2, v5 /* Destination journal mode */ + pgszSrc = 0 /* Source page size */ + pgszDest = 0 /* Destination page size */ + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrcDb)).Fmutex) + _sqlite3BtreeEnter(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc) + if (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex) + } + rc = (*Tsqlite3_backup)(unsafe.Pointer(p)).Frc + if !(_isFatalError(tls, rc) != 0) { + pSrcPager = _sqlite3BtreePager(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc) /* Source pager */ + pDestPager = _sqlite3BtreePager(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest) /* Iterator variable */ + nSrcPage = -int32(1) /* Size of source db in pages */ + bCloseTrans = 0 /* True if src db requires unlocking */ + /* If the source pager is currently in a write-transaction, return + ** SQLITE_BUSY immediately. + */ + if (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 && libc.Int32FromUint8((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FinTransaction) == int32(TRANS_WRITE) { + rc = int32(SQLITE_BUSY) + } else { + rc = SQLITE_OK + } + /* If there is no open read-transaction on the source database, open + ** one now. If a transaction is opened here, then it will be closed + ** before this function exits. + */ + if rc == SQLITE_OK && SQLITE_TXN_NONE == _sqlite3BtreeTxnState(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc) { + rc = _sqlite3BtreeBeginTrans(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc, 0, uintptr(0)) + bCloseTrans = int32(1) + } + /* If the destination database has not yet been locked (i.e. if this + ** is the first call to backup_step() for the current backup operation), + ** try to set its page size to the same as the source database. This + ** is especially important on ZipVFS systems, as in that case it is + ** not possible to create a database file that uses one page size by + ** writing to it with another. */ + if (*Tsqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0 && rc == SQLITE_OK && _setDestPgsz(tls, p) == int32(SQLITE_NOMEM) { + rc = int32(SQLITE_NOMEM) + } + /* Lock the destination database, if it is not locked already. */ + if v2 = SQLITE_OK == rc && (*Tsqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0; v2 { + v1 = _sqlite3BtreeBeginTrans(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest, int32(2), p+16) + rc = v1 + } + if v2 && SQLITE_OK == v1 { + (*Tsqlite3_backup)(unsafe.Pointer(p)).FbDestLocked = int32(1) + } + /* Do not allow backup if the destination database is in WAL mode + ** and the page sizes are different between source and destination */ + pgszSrc = _sqlite3BtreeGetPageSize(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc) + pgszDest = _sqlite3BtreeGetPageSize(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest) + destMode = _sqlite3PagerGetJournalMode(tls, _sqlite3BtreePager(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest)) + if SQLITE_OK == rc && (destMode == int32(PAGER_JOURNALMODE_WAL) || _sqlite3PagerIsMemdb(tls, pDestPager) != 0) && pgszSrc != pgszDest { + rc = int32(SQLITE_READONLY) + } + /* Now that there is a read-lock on the source database, query the + ** source pager for the number of pages in the database. + */ + nSrcPage = libc.Int32FromUint32(_sqlite3BtreeLastPage(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc)) + ii = 0 + for { + if !((nPage < 0 || ii < nPage) && (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext <= libc.Uint32FromInt32(nSrcPage) && !(rc != 0)) { + break + } + iSrcPg = (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext /* Source page number */ + if iSrcPg != libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FpageSize+libc.Uint32FromInt32(1) { /* Source page object */ + rc = _sqlite3PagerGet(tls, pSrcPager, iSrcPg, bp, int32(PAGER_GET_READONLY)) + if rc == SQLITE_OK { + rc = _backupOnePage(tls, p, iSrcPg, _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))), 0) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext = (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext + 1 + goto _3 + _3: + ; + ii = ii + 1 + } + if rc == SQLITE_OK { + (*Tsqlite3_backup)(unsafe.Pointer(p)).FnPagecount = libc.Uint32FromInt32(nSrcPage) + (*Tsqlite3_backup)(unsafe.Pointer(p)).FnRemaining = libc.Uint32FromInt32(nSrcPage+int32(1)) - (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext + if (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext > libc.Uint32FromInt32(nSrcPage) { + rc = int32(SQLITE_DONE) + } else { + if !((*Tsqlite3_backup)(unsafe.Pointer(p)).FisAttached != 0) { + _attachBackupObject(tls, p) + } + } + } + /* Update the schema version field in the destination database. This + ** is to make sure that the schema-version really does change in + ** the case where the source and destination databases have the + ** same schema version. + */ + if rc == int32(SQLITE_DONE) { + if nSrcPage == 0 { + rc = _sqlite3BtreeNewDb(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest) + nSrcPage = int32(1) + } + if rc == SQLITE_OK || rc == int32(SQLITE_DONE) { + rc = _sqlite3BtreeUpdateMeta(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest, int32(1), (*Tsqlite3_backup)(unsafe.Pointer(p)).FiDestSchema+uint32(1)) + } + if rc == SQLITE_OK { + if (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 { + _sqlite3ResetAllSchemasOfConnection(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb) + } + if destMode == int32(PAGER_JOURNALMODE_WAL) { + rc = _sqlite3BtreeSetVersion(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest, int32(2)) + } + } + if rc == SQLITE_OK { + /* Set nDestTruncate to the final number of pages in the destination + ** database. The complication here is that the destination page + ** size may be different to the source page size. + ** + ** If the source page size is smaller than the destination page size, + ** round up. In this case the call to sqlite3OsTruncate() below will + ** fix the size of the file. However it is important to call + ** sqlite3PagerTruncateImage() here so that any pages in the + ** destination file that lie beyond the nDestTruncate page mark are + ** journalled by PagerCommitPhaseOne() before they are destroyed + ** by the file truncation. + */ + if pgszSrc < pgszDest { + ratio = pgszDest / pgszSrc + nDestTruncate = (nSrcPage + ratio - int32(1)) / ratio + if nDestTruncate == libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize+libc.Uint32FromInt32(1)) { + nDestTruncate = nDestTruncate - 1 + } + } else { + nDestTruncate = nSrcPage * (pgszSrc / pgszDest) + } + if pgszSrc < pgszDest { + /* If the source page-size is smaller than the destination page-size, + ** two extra things may need to happen: + ** + ** * The destination may need to be truncated, and + ** + ** * Data stored on the pages immediately following the + ** pending-byte page in the source database may need to be + ** copied into the destination database. + */ + iSize = int64(pgszSrc) * int64(nSrcPage) + pFile = _sqlite3PagerFile(tls, pDestPager) + /* This block ensures that all data required to recreate the original + ** database has been stored in the journal for pDestPager and the + ** journal synced to disk. So at this point we may safely modify + ** the database file in any way, knowing that if a power failure + ** occurs, the original database will be reconstructed from the + ** journal file. */ + _sqlite3PagerPagecount(tls, pDestPager, bp+8) + iPg = libc.Uint32FromInt32(nDestTruncate) + for { + if !(rc == SQLITE_OK && iPg <= libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 8)))) { + break + } + if iPg != libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize+libc.Uint32FromInt32(1) { + rc = _sqlite3PagerGet(tls, pDestPager, iPg, bp+16, 0) + if rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp + 16))) + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 16))) + } + } + goto _4 + _4: + ; + iPg = iPg + 1 + } + if rc == SQLITE_OK { + rc = _sqlite3PagerCommitPhaseOne(tls, pDestPager, uintptr(0), int32(1)) + } + /* Write the extra pages and truncate the database file as required */ + if int64(_sqlite3PendingByte+pgszDest) < iSize { + v5 = int64(_sqlite3PendingByte + pgszDest) + } else { + v5 = iSize + } + iEnd = v5 + iOff = int64(_sqlite3PendingByte + pgszSrc) + for { + if !(rc == SQLITE_OK && iOff < iEnd) { + break + } + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + iSrcPg1 = libc.Uint32FromInt64(iOff/int64(pgszSrc) + libc.Int64FromInt32(1)) + rc = _sqlite3PagerGet(tls, pSrcPager, iSrcPg1, bp+24, 0) + if rc == SQLITE_OK { + zData = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp + 24))) + rc = _sqlite3OsWrite(tls, pFile, zData, pgszSrc, iOff) + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp + 24))) + goto _6 + _6: + ; + iOff = iOff + int64(pgszSrc) + } + if rc == SQLITE_OK { + rc = _backupTruncateFile(tls, pFile, iSize) + } + /* Sync the database file to disk. */ + if rc == SQLITE_OK { + rc = _sqlite3PagerSync(tls, pDestPager, uintptr(0)) + } + } else { + _sqlite3PagerTruncateImage(tls, pDestPager, libc.Uint32FromInt32(nDestTruncate)) + rc = _sqlite3PagerCommitPhaseOne(tls, pDestPager, uintptr(0), 0) + } + /* Finish committing the transaction to the destination database. */ + if v2 = SQLITE_OK == rc; v2 { + v1 = _sqlite3BtreeCommitPhaseTwo(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpDest, 0) + rc = v1 + } + if v2 && SQLITE_OK == v1 { + rc = int32(SQLITE_DONE) + } + } + } + /* If bCloseTrans is true, then this function opened a read transaction + ** on the source database. Close the read transaction here. There is + ** no need to check the return values of the btree methods here, as + ** "committing" a read-only transaction cannot fail. + */ + if bCloseTrans != 0 { + _sqlite3BtreeCommitPhaseOne(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc, uintptr(0)) + _sqlite3BtreeCommitPhaseTwo(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc, 0) + } + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)< libc.Uint64FromInt32(**(**int32)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).Fdb + 136))) { + rc = int32(SQLITE_TOOBIG) + } else { + rc = Xsqlite3_bind_zeroblob(tls, pStmt, i, libc.Int32FromUint64(n)) + } + rc = _sqlite3ApiExit(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Cancel a prior call to sqlite3_auto_extension. Remove xInit from the +// ** set of routines that is invoked for each new database connection, if it +// ** is currently on the list. If xInit is not on the list, then this +// ** routine is a no-op. +// ** +// ** Return 1 if xInit was found on the list and removed. Return 0 if xInit +// ** was not on the list. +// */ +func Xsqlite3_cancel_auto_extension(tls *libc.TLS, __ccgo_fp_xInit uintptr) (r int32) { + var i, n int32 + var mutex uintptr + _, _, _ = i, mutex, n + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + n = 0 + Xsqlite3_mutex_enter(tls, mutex) + i = libc.Int32FromUint32(_sqlite3Autoext.FnExt) - int32(1) + for { + if !(i >= 0) { + break + } + if **(**uintptr)(__ccgo_up(_sqlite3Autoext.FaExt + uintptr(i)*8)) == __ccgo_fp_xInit { + _sqlite3Autoext.FnExt = _sqlite3Autoext.FnExt - 1 + **(**uintptr)(__ccgo_up(_sqlite3Autoext.FaExt + uintptr(i)*8)) = **(**uintptr)(__ccgo_up(_sqlite3Autoext.FaExt + uintptr(_sqlite3Autoext.FnExt)*8)) + n = n + 1 + break + } + goto _1 + _1: + ; + i = i - 1 + } + Xsqlite3_mutex_leave(tls, mutex) + return n +} + +func Xsqlite3_column_value(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) { + var pOut, v1 uintptr + _, _ = pOut, v1 + pOut = _columnMem(tls, pStmt, i) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Static) != 0 { + v1 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Static)) + v1 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Ephem)) + } + _columnMallocFailure(tls, pStmt) + return pOut +} + +// C documentation +// +// /* +// ** Configuration settings for an individual database connection +// */ +func Xsqlite3_db_config(tls *libc.TLS, db uintptr, op int32, va uintptr) (r int32) { + var ap Tva_list + var cnt, nIn, onoff, rc, sz int32 + var i uint32 + var oldFlags Tu64 + var pBuf, pOut, pRes uintptr + _, _, _, _, _, _, _, _, _, _, _ = ap, cnt, i, nIn, oldFlags, onoff, pBuf, pOut, pRes, rc, sz + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + ap = va + switch op { + case int32(SQLITE_DBCONFIG_MAINDBNAME): + /* IMP: R-06824-28531 */ + /* IMP: R-36257-52125 */ + (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName = libc.VaUintptr(&ap) + rc = SQLITE_OK + case int32(SQLITE_DBCONFIG_LOOKASIDE): + pBuf = libc.VaUintptr(&ap) /* IMP: R-26835-10964 */ + sz = libc.VaInt32(&ap) /* IMP: R-47871-25994 */ + cnt = libc.VaInt32(&ap) /* IMP: R-04460-53386 */ + rc = _setupLookaside(tls, db, pBuf, sz, cnt) + case int32(SQLITE_DBCONFIG_FP_DIGITS): + nIn = libc.VaInt32(&ap) + pOut = libc.VaUintptr(&ap) + if nIn > int32(3) && nIn < int32(24) { + (*Tsqlite3)(unsafe.Pointer(db)).FnFpDigit = libc.Uint8FromInt32(nIn) + } + if pOut != 0 { + **(**int32)(__ccgo_up(pOut)) = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FnFpDigit) + } + rc = SQLITE_OK + default: + rc = int32(SQLITE_ERROR) /* IMP: R-42790-23372 */ + i = uint32(0) + for { + if !(i < libc.Uint32FromInt32(libc.Int32FromUint64(libc.Uint64FromInt64(336)/libc.Uint64FromInt64(16)))) { + break + } + if _aFlagOp[i].Fop == op { + onoff = libc.VaInt32(&ap) + pRes = libc.VaUintptr(&ap) + oldFlags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + if onoff > 0 { + **(**Tu64)(__ccgo_up(db + 48)) |= _aFlagOp[i].Fmask + } else { + if onoff == 0 { + **(**Tu64)(__ccgo_up(db + 48)) &= ^_aFlagOp[i].Fmask + } + } + if oldFlags != (*Tsqlite3)(unsafe.Pointer(db)).Fflags { + _sqlite3ExpirePreparedStatements(tls, db, 0) + } + if pRes != 0 { + **(**int32)(__ccgo_up(pRes)) = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&_aFlagOp[i].Fmask != uint64(0)) + } + rc = SQLITE_OK + break + } + goto _1 + _1: + ; + i = i + 1 + } + break + } + _ = ap + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Query status information for a single database connection +// */ +func Xsqlite3_db_status64(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, pHighwtr uintptr, resetFlag int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, i1, i2, nByte, rc int32 + var p, p1, pBt, pPager, pPager1, pPager2, pSchema, pVdbe uintptr + var totalUsed Tsqlite3_int64 + var _ /* H at bp+0 */ int32 + var _ /* nByte at bp+4 */ int32 + var _ /* nByte at bp+8 */ int32 + var _ /* nRet at bp+16 */ Tu64 + var _ /* nRet at bp+24 */ Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, i1, i2, nByte, p, p1, pBt, pPager, pPager1, pPager2, pSchema, pVdbe, rc, totalUsed + rc = SQLITE_OK /* Return code */ + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + switch op { + case SQLITE_DBSTATUS_LOOKASIDE_USED: + **(**int32)(__ccgo_up(bp)) = 0 + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = int64(_sqlite3LookasideUsed(tls, db, bp)) + **(**Tsqlite3_int64)(__ccgo_up(pHighwtr)) = int64(**(**int32)(__ccgo_up(bp))) + if resetFlag != 0 { + p = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree + if p != 0 { + for (*TLookasideSlot)(unsafe.Pointer(p)).FpNext != 0 { + p = (*TLookasideSlot)(unsafe.Pointer(p)).FpNext + } + (*TLookasideSlot)(unsafe.Pointer(p)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpInit + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = uintptr(0) + } + p = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree + if p != 0 { + for (*TLookasideSlot)(unsafe.Pointer(p)).FpNext != 0 { + p = (*TLookasideSlot)(unsafe.Pointer(p)).FpNext + } + (*TLookasideSlot)(unsafe.Pointer(p)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = uintptr(0) + } + } + case int32(SQLITE_DBSTATUS_LOOKASIDE_HIT): + fallthrough + case int32(SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE): + fallthrough + case int32(SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL): + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = 0 + **(**Tsqlite3_int64)(__ccgo_up(pHighwtr)) = libc.Int64FromUint32(**(**Tu32)(__ccgo_up(db + 440 + 16 + uintptr(op-int32(SQLITE_DBSTATUS_LOOKASIDE_HIT))*4))) + if resetFlag != 0 { + **(**Tu32)(__ccgo_up(db + 440 + 16 + uintptr(op-int32(SQLITE_DBSTATUS_LOOKASIDE_HIT))*4)) = uint32(0) + } + break + /* + ** Return an approximation for the amount of memory currently used + ** by all pagers associated with the given database connection. The + ** highwater mark is meaningless and is returned as zero. + */ + fallthrough + case int32(SQLITE_DBSTATUS_CACHE_USED_SHARED): + fallthrough + case int32(SQLITE_DBSTATUS_CACHE_USED): + totalUsed = 0 + _sqlite3BtreeEnterAll(tls, db) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 { + pPager = _sqlite3BtreePager(tls, pBt) + nByte = _sqlite3PagerMemUsed(tls, pPager) + if op == int32(SQLITE_DBSTATUS_CACHE_USED_SHARED) { + nByte = nByte / _sqlite3BtreeConnectionCount(tls, pBt) + } + totalUsed = totalUsed + int64(nByte) + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3BtreeLeaveAll(tls, db) + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = totalUsed + **(**Tsqlite3_int64)(__ccgo_up(pHighwtr)) = 0 + break + /* + ** *pCurrent gets an accurate estimate of the amount of memory used + ** to store the schema for all databases (main, temp, and any ATTACHed + ** databases. *pHighwtr is set to zero. + */ + fallthrough + case int32(SQLITE_DBSTATUS_SCHEMA_USED): /* Used to iterate through schemas */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* Used to accumulate return value */ + _sqlite3BtreeEnterAll(tls, db) + (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed = bp + 4 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart + i1 = 0 + for { + if !(i1 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i1)*32))).FpSchema + if pSchema != uintptr(0) { + **(**int32)(__ccgo_up(bp + 4)) = libc.Int32FromUint32(uint32(**(**int32)(__ccgo_up(bp + 4))) + libc.Uint32FromInt32((*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxRoundup})))(tls, int32(40)))*((*TSchema)(unsafe.Pointer(pSchema)).FtblHash.Fcount+(*TSchema)(unsafe.Pointer(pSchema)).FtrigHash.Fcount+(*TSchema)(unsafe.Pointer(pSchema)).FidxHash.Fcount+(*TSchema)(unsafe.Pointer(pSchema)).FfkeyHash.Fcount)) + **(**int32)(__ccgo_up(bp + 4)) = libc.Int32FromUint64(uint64(**(**int32)(__ccgo_up(bp + 4))) + Xsqlite3_msize(tls, (*TSchema)(unsafe.Pointer(pSchema)).FtblHash.Fht)) + **(**int32)(__ccgo_up(bp + 4)) = libc.Int32FromUint64(uint64(**(**int32)(__ccgo_up(bp + 4))) + Xsqlite3_msize(tls, (*TSchema)(unsafe.Pointer(pSchema)).FtrigHash.Fht)) + **(**int32)(__ccgo_up(bp + 4)) = libc.Int32FromUint64(uint64(**(**int32)(__ccgo_up(bp + 4))) + Xsqlite3_msize(tls, (*TSchema)(unsafe.Pointer(pSchema)).FidxHash.Fht)) + **(**int32)(__ccgo_up(bp + 4)) = libc.Int32FromUint64(uint64(**(**int32)(__ccgo_up(bp + 4))) + Xsqlite3_msize(tls, (*TSchema)(unsafe.Pointer(pSchema)).FfkeyHash.Fht)) + p1 = (*THash)(unsafe.Pointer(pSchema + 56)).Ffirst + for { + if !(p1 != 0) { + break + } + _sqlite3DeleteTrigger(tls, db, (*THashElem)(unsafe.Pointer(p1)).Fdata) + goto _3 + _3: + ; + p1 = (*THashElem)(unsafe.Pointer(p1)).Fnext + } + p1 = (*THash)(unsafe.Pointer(pSchema + 8)).Ffirst + for { + if !(p1 != 0) { + break + } + _sqlite3DeleteTable(tls, db, (*THashElem)(unsafe.Pointer(p1)).Fdata) + goto _4 + _4: + ; + p1 = (*THashElem)(unsafe.Pointer(p1)).Fnext + } + } + goto _2 + _2: + ; + i1 = i1 + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd + _sqlite3BtreeLeaveAll(tls, db) + **(**Tsqlite3_int64)(__ccgo_up(pHighwtr)) = 0 + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = int64(**(**int32)(__ccgo_up(bp + 4))) + break + /* + ** *pCurrent gets an accurate estimate of the amount of memory used + ** to store all prepared statements. + ** *pHighwtr is set to zero. + */ + fallthrough + case int32(SQLITE_DBSTATUS_STMT_USED): /* Used to iterate through VMs */ + **(**int32)(__ccgo_up(bp + 8)) = 0 /* Used to accumulate return value */ + (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed = bp + 8 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart + pVdbe = (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe + for { + if !(pVdbe != 0) { + break + } + _sqlite3VdbeDelete(tls, pVdbe) + goto _5 + _5: + ; + pVdbe = (*TVdbe)(unsafe.Pointer(pVdbe)).FpVNext + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd + (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed = uintptr(0) + **(**Tsqlite3_int64)(__ccgo_up(pHighwtr)) = 0 /* IMP: R-64479-57858 */ + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = int64(**(**int32)(__ccgo_up(bp + 8))) + break + /* + ** Set *pCurrent to the total cache hits or misses encountered by all + ** pagers the database handle is connected to. *pHighwtr is always set + ** to zero. + */ + fallthrough + case int32(SQLITE_DBSTATUS_CACHE_SPILL): + op = libc.Int32FromInt32(SQLITE_DBSTATUS_CACHE_WRITE) + libc.Int32FromInt32(1) + fallthrough + case int32(SQLITE_DBSTATUS_CACHE_HIT): + fallthrough + case int32(SQLITE_DBSTATUS_CACHE_MISS): + fallthrough + case int32(SQLITE_DBSTATUS_CACHE_WRITE): + **(**Tu64)(__ccgo_up(bp + 16)) = uint64(0) + i2 = 0 + for { + if !(i2 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i2)*32))).FpBt != 0 { + pPager1 = _sqlite3BtreePager(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i2)*32))).FpBt) + _sqlite3PagerCacheStat(tls, pPager1, op, resetFlag, bp+16) + } + goto _6 + _6: + ; + i2 = i2 + 1 + } + **(**Tsqlite3_int64)(__ccgo_up(pHighwtr)) = 0 /* IMP: R-42420-56072 */ + /* IMP: R-54100-20147 */ + /* IMP: R-29431-39229 */ + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = libc.Int64FromUint64(**(**Tu64)(__ccgo_up(bp + 16))) + break + /* Set *pCurrent to the number of bytes that the db database connection + ** has spilled to the filesystem in temporary files that could have been + ** stored in memory, had sufficient memory been available. + ** The *pHighwater is always set to zero. + */ + fallthrough + case int32(SQLITE_DBSTATUS_TEMPBUF_SPILL): + **(**Tu64)(__ccgo_up(bp + 24)) = uint64(0) + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt != 0 { + pPager2 = _sqlite3BtreePager(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt) + _sqlite3PagerCacheStat(tls, pPager2, int32(SQLITE_DBSTATUS_CACHE_WRITE), resetFlag, bp+24) + **(**Tu64)(__ccgo_up(bp + 24)) = **(**Tu64)(__ccgo_up(bp + 24)) * libc.Uint64FromInt32(_sqlite3BtreeGetPageSize(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpBt)) + } + **(**Tu64)(__ccgo_up(bp + 24)) = **(**Tu64)(__ccgo_up(bp + 24)) + (*Tsqlite3)(unsafe.Pointer(db)).FnSpill + if resetFlag != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnSpill = uint64(0) + } + **(**Tsqlite3_int64)(__ccgo_up(pHighwtr)) = 0 + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = libc.Int64FromUint64(**(**Tu64)(__ccgo_up(bp + 24))) + break + /* Set *pCurrent to non-zero if there are unresolved deferred foreign + ** key constraints. Set *pCurrent to zero if all foreign key constraints + ** have been satisfied. The *pHighwtr is always set to zero. + */ + fallthrough + case int32(SQLITE_DBSTATUS_DEFERRED_FKS): + **(**Tsqlite3_int64)(__ccgo_up(pHighwtr)) = 0 /* IMP: R-11967-56545 */ + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = libc.BoolInt64((*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons > 0 || (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons > 0) + default: + rc = int32(SQLITE_ERROR) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Enable or disable extension loading. Extension loading is disabled by +// ** default so as not to open security holes in older applications. +// */ +func Xsqlite3_enable_load_extension(tls *libc.TLS, db uintptr, onoff int32) (r int32) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if onoff != 0 { + **(**Tu64)(__ccgo_up(db + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_LoadExtension) | libc.Int32FromInt32(SQLITE_LoadExtFunc)) + } else { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_LoadExtension) | libc.Int32FromInt32(SQLITE_LoadExtFunc)) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is called from within a pre-update callback to retrieve +// ** a field of the row currently being updated or inserted. +// */ +func Xsqlite3_preupdate_new(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintptr) (r int32) { + var iStore, rc, v1 int32 + var p, pData, pMem, pUnpack uintptr + _, _, _, _, _, _, _ = iStore, p, pData, pMem, pUnpack, rc, v1 + rc = SQLITE_OK + iStore = 0 + p = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate + if !(p != 0) || (*TPreUpdate)(unsafe.Pointer(p)).Fop == int32(SQLITE_DELETE) { + rc = _sqlite3MisuseError(tls, int32(95940)) + goto preupdate_new_out + } + if (*TPreUpdate)(unsafe.Pointer(p)).FpPk != 0 && (*TPreUpdate)(unsafe.Pointer(p)).Fop != int32(SQLITE_UPDATE) { + iStore = _sqlite3TableColumnToIndex(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpPk, iIdx) + } else { + if iIdx >= int32((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FnCol) { + return _sqlite3MisuseError(tls, int32(95946)) + } else { + iStore = int32(_sqlite3TableColumnToStorage(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpTab, int16(iIdx))) + } + } + if iStore >= int32((*TVdbeCursor)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField) || iStore < 0 { + rc = int32(SQLITE_RANGE) + goto preupdate_new_out + } + if (*TPreUpdate)(unsafe.Pointer(p)).Fop == int32(SQLITE_INSERT) { + /* For an INSERT, memory cell p->iNewReg contains the serialized record + ** that is being inserted. Deserialize it. */ + pUnpack = (*TPreUpdate)(unsafe.Pointer(p)).FpNewUnpacked + if !(pUnpack != 0) { + pData = (*TVdbe)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).Fv)).FaMem + uintptr((*TPreUpdate)(unsafe.Pointer(p)).FiNewReg)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pData)).Fflags)&int32(MEM_Zero) != 0 { + v1 = _sqlite3VdbeMemExpandBlob(tls, pData) + } else { + v1 = 0 + } + rc = v1 + if rc != SQLITE_OK { + goto preupdate_new_out + } + pUnpack = _vdbeUnpackRecord(tls, (*TPreUpdate)(unsafe.Pointer(p)).FpKeyinfo, (*TMem)(unsafe.Pointer(pData)).Fn, (*TMem)(unsafe.Pointer(pData)).Fz) + if !(pUnpack != 0) { + rc = int32(SQLITE_NOMEM) + goto preupdate_new_out + } + (*TPreUpdate)(unsafe.Pointer(p)).FpNewUnpacked = pUnpack + } + pMem = (*TUnpackedRecord)(unsafe.Pointer(pUnpack)).FaMem + uintptr(iStore)*56 + if iIdx == int32((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FiPKey) { + _sqlite3VdbeMemSetInt64(tls, pMem, (*TPreUpdate)(unsafe.Pointer(p)).FiKey2) + } else { + if iStore >= libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(pUnpack)).FnField) { + pMem = _columnNullValue(tls) + } + } + } else { + /* For an UPDATE, memory cell (p->iNewReg+1+iStore) contains the required + ** value. Make a copy of the cell contents and return a pointer to it. + ** It is not safe to return a pointer to the memory cell itself as the + ** caller may modify the value text encoding. + */ + if !((*TPreUpdate)(unsafe.Pointer(p)).FaNew != 0) { + (*TPreUpdate)(unsafe.Pointer(p)).FaNew = _sqlite3DbMallocZero(tls, db, uint64(uint64(56)*libc.Uint64FromInt16((*TVdbeCursor)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField))) + if !((*TPreUpdate)(unsafe.Pointer(p)).FaNew != 0) { + rc = int32(SQLITE_NOMEM) + goto preupdate_new_out + } + } + pMem = (*TPreUpdate)(unsafe.Pointer(p)).FaNew + uintptr(iStore)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags) == 0 { + if iIdx == int32((*TTable)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpTab)).FiPKey) { + _sqlite3VdbeMemSetInt64(tls, pMem, (*TPreUpdate)(unsafe.Pointer(p)).FiKey2) + } else { + rc = _sqlite3VdbeMemCopy(tls, pMem, (*TVdbe)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).Fv)).FaMem+uintptr((*TPreUpdate)(unsafe.Pointer(p)).FiNewReg+int32(1)+iStore)*56) + if rc != SQLITE_OK { + goto preupdate_new_out + } + } + } + } + **(**uintptr)(__ccgo_up(ppValue)) = pMem + goto preupdate_new_out +preupdate_new_out: + ; + _sqlite3Error(tls, db, rc) + return _sqlite3ApiExit(tls, db, rc) +} + +/************** End of vdbeapi.c *********************************************/ +/************** Begin file vdbetrace.c ***************************************/ +/* +** 2009 November 25 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code used to insert the values of host parameters +** (aka "wildcards") into the SQL text output by sqlite3_trace(). +** +** The Vdbe parse-tree explainer is also found here. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +func Xsqlite3_result_zeroblob64(tls *libc.TLS, pCtx uintptr, n Tu64) (r int32) { + var pOut uintptr + _ = pOut + pOut = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut + if n > libc.Uint64FromInt32(**(**int32)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fdb + 136))) { + Xsqlite3_result_error_toobig(tls, pCtx) + return int32(SQLITE_TOOBIG) + } + _sqlite3VdbeMemSetZeroBlob(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, libc.Int32FromUint64(n)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Obtain a snapshot handle for the snapshot of database zDb currently +// ** being read by handle db. +// */ +func Xsqlite3_snapshot_get(tls *libc.TLS, db uintptr, zDb uintptr, ppSnapshot uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDb, rc int32 + var pBt, pPager uintptr + var _ /* dummy at bp+0 */ Ti64 + _, _, _, _ = iDb, pBt, pPager, rc + rc = int32(SQLITE_ERROR) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 { + iDb = _sqlite3FindDbName(tls, db, zDb) + if iDb == 0 || iDb > int32(1) { + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if int32(SQLITE_TXN_WRITE) != _sqlite3BtreeTxnState(tls, pBt) { + pPager = _sqlite3BtreePager(tls, pBt) + **(**Ti64)(__ccgo_up(bp)) = 0 + _sqlite3PagerSnapshotOpen(tls, pPager, bp) + rc = _sqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) + _sqlite3PagerSnapshotOpen(tls, pPager, uintptr(0)) + if rc == SQLITE_OK { + rc = _sqlite3PagerSnapshotGet(tls, _sqlite3BtreePager(tls, pBt), ppSnapshot) + } + } + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Open a read-transaction on the snapshot identified by pSnapshot. +// */ +func Xsqlite3_snapshot_open(tls *libc.TLS, db uintptr, zDb uintptr, pSnapshot uintptr) (r int32) { + var bUnlock, iDb, rc int32 + var pBt, pPager uintptr + _, _, _, _, _ = bUnlock, iDb, pBt, pPager, rc + rc = int32(SQLITE_ERROR) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 { + iDb = _sqlite3FindDbName(tls, db, zDb) + if iDb == 0 || iDb > int32(1) { + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if _sqlite3BtreeTxnState(tls, pBt) != int32(SQLITE_TXN_WRITE) { + pPager = _sqlite3BtreePager(tls, pBt) + bUnlock = 0 + if _sqlite3BtreeTxnState(tls, pBt) != SQLITE_TXN_NONE { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { + rc = _sqlite3PagerSnapshotCheck(tls, pPager, pSnapshot) + if rc == SQLITE_OK { + bUnlock = int32(1) + rc = _sqlite3BtreeCommit(tls, pBt) + } + } + } else { + rc = SQLITE_OK + } + if rc == SQLITE_OK { + rc = _sqlite3PagerSnapshotOpen(tls, pPager, pSnapshot) + } + if rc == SQLITE_OK { + rc = _sqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) + _sqlite3PagerSnapshotOpen(tls, pPager, uintptr(0)) + } + if bUnlock != 0 { + _sqlite3PagerSnapshotUnlock(tls, pPager) + } + } + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Query status information. +// */ +func Xsqlite3_status64(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uintptr, resetFlag int32) (r int32) { + var pMutex, v1 uintptr + _, _ = pMutex, v1 + if op < 0 || op >= libc.Int32FromUint64(libc.Uint64FromInt64(80)/libc.Uint64FromInt64(8)) { + return _sqlite3MisuseError(tls, int32(25144)) + } + if _statMutex[op] != 0 { + v1 = _sqlite3Pcache1Mutex(tls) + } else { + v1 = _sqlite3MallocMutex(tls) + } + pMutex = v1 + Xsqlite3_mutex_enter(tls, pMutex) + **(**Tsqlite3_int64)(__ccgo_up(pCurrent)) = **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + uintptr(op)*8)) + **(**Tsqlite3_int64)(__ccgo_up(pHighwater)) = **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + 80 + uintptr(op)*8)) + if resetFlag != 0 { + **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + 80 + uintptr(op)*8)) = **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + uintptr(op)*8)) + } + Xsqlite3_mutex_leave(tls, pMutex) + _ = pMutex /* Prevent warning when SQLITE_THREADSAFE=0 */ + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Set the explain mode for a statement. +// */ +func Xsqlite3_stmt_explain(tls *libc.TLS, pStmt uintptr, eMode int32) (r int32) { + var rc int32 + var v uintptr + _, _ = rc, v + v = pStmt + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(v)).Fdb)).Fmutex) + if int32(Tbft(*(*uint16)(unsafe.Pointer(v + 200))&0xc>>2)) == eMode { + rc = SQLITE_OK + } else { + if eMode < 0 || eMode > int32(2) { + rc = int32(SQLITE_ERROR) + } else { + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(v)).FprepFlags)&int32(SQLITE_PREPARE_SAVESQL) == 0 { + rc = int32(SQLITE_ERROR) + } else { + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(v)).FeVdbeState) != int32(VDBE_READY_STATE) { + rc = int32(SQLITE_BUSY) + } else { + if (*TVdbe)(unsafe.Pointer(v)).FnMem >= int32(10) && (eMode != int32(2) || int32(Tbft(*(*uint16)(unsafe.Pointer(v + 200))&0x100>>8)) != 0) { + /* No reprepare necessary */ + libc.SetBitFieldPtr16Uint32(v+200, libc.Uint32FromInt32(eMode), 2, 0xc) + rc = SQLITE_OK + } else { + libc.SetBitFieldPtr16Uint32(v+200, libc.Uint32FromInt32(eMode), 2, 0xc) + rc = _sqlite3Reprepare(tls, v) + libc.SetBitFieldPtr16Uint32(v+200, libc.BoolUint32(eMode == libc.Int32FromInt32(2)), 8, 0x100) + } + } + } + } + } + if int32(Tbft(*(*uint16)(unsafe.Pointer(v + 200))&0xc>>2)) != 0 { + (*TVdbe)(unsafe.Pointer(v)).FnResColumn = libc.Uint16FromInt32(int32(12) - int32(4)*int32(Tbft(*(*uint16)(unsafe.Pointer(v + 200))&0xc>>2))) + } else { + (*TVdbe)(unsafe.Pointer(v)).FnResColumn = (*TVdbe)(unsafe.Pointer(v)).FnResAlloc + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(v)).Fdb)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Return the value of a status counter for a prepared statement +// */ +func Xsqlite3_stmt_status(tls *libc.TLS, pStmt uintptr, op int32, resetFlag int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pVdbe uintptr + var _ /* v at bp+0 */ Tu32 + _, _ = db, pVdbe + pVdbe = pStmt + if op == int32(SQLITE_STMTSTATUS_MEMUSED) { + db = (*TVdbe)(unsafe.Pointer(pVdbe)).Fdb + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed = bp + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart + _sqlite3VdbeDelete(tls, pVdbe) + (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + } else { + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(pVdbe + 212 + uintptr(op)*4)) + if resetFlag != 0 { + **(**Tu32)(__ccgo_up(pVdbe + 212 + uintptr(op)*4)) = uint32(0) + } + } + return libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))) +} + +// C documentation +// +// /* +// ** Reset an StrAccum string. Reclaim all malloced memory. +// */ +func Xsqlite3_str_reset(tls *libc.TLS, p uintptr) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&int32(SQLITE_PRINTF_MALLOCED) != 0 { + _sqlite3DbFree(tls, (*TStrAccum)(unsafe.Pointer(p)).Fdb, (*TStrAccum)(unsafe.Pointer(p)).FzText) + v1 = p + 29 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) + } + (*TStrAccum)(unsafe.Pointer(p)).FnAlloc = uint32(0) + (*TStrAccum)(unsafe.Pointer(p)).FnChar = uint32(0) + (*TStrAccum)(unsafe.Pointer(p)).FzText = uintptr(0) +} + +// C documentation +// +// /* +// ** Interface to the testing logic. +// */ +func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) (r int32) { + var aProg, db, db1, db2, db3, db4, db5, db6, db7, pCtx, pI1, pI2, pN, pR, pU64, pn, ptr, xBenignBegin, xBenignEnd, z uintptr + var ap Tva_list + var b, iDb, opTrace, rc, sz, x, x1, x2, y, v1 int32 + var newVal uint32 + var rIn float64 + var rLogEst TLogEst + var v2 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aProg, ap, b, db, db1, db2, db3, db4, db5, db6, db7, iDb, newVal, opTrace, pCtx, pI1, pI2, pN, pR, pU64, pn, ptr, rIn, rLogEst, rc, sz, x, x1, x2, xBenignBegin, xBenignEnd, y, z, v1, v2 + rc = 0 + ap = va + switch op { + /* + ** Save the current state of the PRNG. + */ + case int32(SQLITE_TESTCTRL_PRNG_SAVE): + _sqlite3PrngSaveState(tls) + break + /* + ** Restore the state of the PRNG to the last state saved using + ** PRNG_SAVE. If PRNG_SAVE has never before been called, then + ** this verb acts like PRNG_RESET. + */ + fallthrough + case int32(SQLITE_TESTCTRL_PRNG_RESTORE): + _sqlite3PrngRestoreState(tls) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SEED, int x, sqlite3 *db); + ** + ** Control the seed for the pseudo-random number generator (PRNG) that + ** is built into SQLite. Cases: + ** + ** x!=0 && db!=0 Seed the PRNG to the current value of the + ** schema cookie in the main database for db, or + ** x if the schema cookie is zero. This case + ** is convenient to use with database fuzzers + ** as it allows the fuzzer some control over the + ** the PRNG seed. + ** + ** x!=0 && db==0 Seed the PRNG to the value of x. + ** + ** x==0 && db==0 Revert to default behavior of using the + ** xRandomness method on the primary VFS. + ** + ** This test-control also resets the PRNG so that the new seed will + ** be used for the next call to sqlite3_randomness(). + */ + fallthrough + case int32(SQLITE_TESTCTRL_PRNG_SEED): + x = libc.VaInt32(&ap) + db = libc.VaUintptr(&ap) + if v2 = db != 0; v2 { + v1 = (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).Fschema_cookie + y = v1 + } + if v2 && v1 != 0 { + x = y + } + _sqlite3Config.FiPrngSeed = libc.Uint32FromInt32(x) + Xsqlite3_randomness(tls, 0, uintptr(0)) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_FK_NO_ACTION, sqlite3 *db, int b); + ** + ** If b is true, then activate the SQLITE_FkNoAction setting. If b is + ** false then clear that setting. If the SQLITE_FkNoAction setting is + ** enabled, all foreign key ON DELETE and ON UPDATE actions behave as if + ** they were NO ACTION, regardless of how they are defined. + ** + ** NB: One must usually run "PRAGMA writable_schema=RESET" after + ** using this test-control, before it will take full effect. failing + ** to reset the schema can result in some unexpected behavior. + */ + fallthrough + case int32(SQLITE_TESTCTRL_FK_NO_ACTION): + db1 = libc.VaUintptr(&ap) + b = libc.VaInt32(&ap) + if b != 0 { + **(**Tu64)(__ccgo_up(db1 + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(0x00008)) << libc.Int32FromInt32(32) + } else { + **(**Tu64)(__ccgo_up(db1 + 48)) &= ^(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008)) << libc.Int32FromInt32(32)) + } + break + /* + ** sqlite3_test_control(BITVEC_TEST, size, program) + ** + ** Run a test against a Bitvec object of size. The program argument + ** is an array of integers that defines the test. Return -1 on a + ** memory allocation error, 0 on success, or non-zero for an error. + ** See the sqlite3BitvecBuiltinTest() for additional information. + */ + fallthrough + case int32(SQLITE_TESTCTRL_BITVEC_TEST): + sz = libc.VaInt32(&ap) + aProg = libc.VaUintptr(&ap) + rc = _sqlite3BitvecBuiltinTest(tls, sz, aProg) + break + /* + ** sqlite3_test_control(FAULT_INSTALL, xCallback) + ** + ** Arrange to invoke xCallback() whenever sqlite3FaultSim() is called, + ** if xCallback is not NULL. + ** + ** As a test of the fault simulator mechanism itself, sqlite3FaultSim(0) + ** is called immediately after installing the new callback and the return + ** value from sqlite3FaultSim(0) becomes the return from + ** sqlite3_test_control(). + */ + fallthrough + case int32(SQLITE_TESTCTRL_FAULT_INSTALL): + _sqlite3Config.FxTestCallback = libc.VaUintptr(&ap) + rc = _sqlite3FaultSim(tls, 0) + break + /* + ** sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd) + ** + ** Register hooks to call to indicate which malloc() failures + ** are benign. + */ + fallthrough + case int32(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS): + xBenignBegin = libc.VaUintptr(&ap) + xBenignEnd = libc.VaUintptr(&ap) + _sqlite3BenignMallocHooks(tls, xBenignBegin, xBenignEnd) + break + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X) + ** + ** Set the PENDING byte to the value in the argument, if X>0. + ** Make no changes if X==0. Return the value of the pending byte + ** as it existing before this routine was called. + ** + ** IMPORTANT: Changing the PENDING byte from 0x40000000 results in + ** an incompatible database file format. Changing the PENDING byte + ** while any database connection is open results in undefined and + ** deleterious behavior. + */ + fallthrough + case int32(SQLITE_TESTCTRL_PENDING_BYTE): + rc = _sqlite3PendingByte + newVal = libc.VaUint32(&ap) + if newVal != 0 { + _sqlite3PendingByte = libc.Int32FromUint32(newVal) + } + break + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X) + ** + ** This action provides a run-time test to see whether or not + ** assert() was enabled at compile-time. If X is true and assert() + ** is enabled, then the return value is true. If X is true and + ** assert() is disabled, then the return value is zero. If X is + ** false and assert() is enabled, then the assertion fires and the + ** process aborts. If X is false and assert() is disabled, then the + ** return value is zero. + */ + fallthrough + case int32(SQLITE_TESTCTRL_ASSERT): + x1 = 0 + rc = x1 + break + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X) + ** + ** This action provides a run-time test to see how the ALWAYS and + ** NEVER macros were defined at compile-time. + ** + ** The return value is ALWAYS(X) if X is true, or 0 if X is false. + ** + ** The recommended test is X==2. If the return value is 2, that means + ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the + ** default setting. If the return value is 1, then ALWAYS() is either + ** hard-coded to true or else it asserts if its argument is false. + ** The first behavior (hard-coded to true) is the case if + ** SQLITE_TESTCTRL_ASSERT shows that assert() is disabled and the second + ** behavior (assert if the argument to ALWAYS() is false) is the case if + ** SQLITE_TESTCTRL_ASSERT shows that assert() is enabled. + ** + ** The run-time test procedure might look something like this: + ** + ** if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){ + ** // ALWAYS() and NEVER() are no-op pass-through macros + ** }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){ + ** // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false. + ** }else{ + ** // ALWAYS(x) is a constant 1. NEVER(x) is a constant 0. + ** } + */ + fallthrough + case int32(SQLITE_TESTCTRL_ALWAYS): + x2 = libc.VaInt32(&ap) + if x2 != 0 { + v1 = x2 + } else { + v1 = 0 + } + rc = v1 + break + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_BYTEORDER); + ** + ** The integer returned reveals the byte-order of the computer on which + ** SQLite is running: + ** + ** 1 big-endian, determined at run-time + ** 10 little-endian, determined at run-time + ** 432101 big-endian, determined at compile-time + ** 123410 little-endian, determined at compile-time + */ + fallthrough + case int32(SQLITE_TESTCTRL_BYTEORDER): + rc = libc.Int32FromInt32(SQLITE_BYTEORDER)*libc.Int32FromInt32(100) + libc.Int32FromInt32(SQLITE_LITTLEENDIAN)*libc.Int32FromInt32(10) + libc.Int32FromInt32(SQLITE_BIGENDIAN) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N) + ** + ** Enable or disable various optimizations for testing purposes. The + ** argument N is a bitmask of optimizations to be disabled. For normal + ** operation N should be 0. The idea is that a test program (like the + ** SQL Logic Test or SLT test module) can run the same SQL multiple times + ** with various optimizations disabled to verify that the same answer + ** is obtained in every case. + */ + fallthrough + case int32(SQLITE_TESTCTRL_OPTIMIZATIONS): + db2 = libc.VaUintptr(&ap) + (*Tsqlite3)(unsafe.Pointer(db2)).FdbOptFlags = libc.VaUint32(&ap) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_GETOPT, sqlite3 *db, int *N) + ** + ** Write the current optimization settings into *N. A zero bit means that + ** the optimization is on, and a 1 bit means that the optimization is off. + */ + fallthrough + case int32(SQLITE_TESTCTRL_GETOPT): + db3 = libc.VaUintptr(&ap) + pN = libc.VaUintptr(&ap) + **(**int32)(__ccgo_up(pN)) = libc.Int32FromUint32((*Tsqlite3)(unsafe.Pointer(db3)).FdbOptFlags) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, onoff, xAlt); + ** + ** If parameter onoff is 1, subsequent calls to localtime() fail. + ** If 2, then invoke xAlt() instead of localtime(). If 0, normal + ** processing. + ** + ** xAlt arguments are void pointers, but they really want to be: + ** + ** int xAlt(const time_t*, struct tm*); + ** + ** xAlt should write results in to struct tm object of its 2nd argument + ** and return zero on success, or return non-zero on failure. + */ + fallthrough + case int32(SQLITE_TESTCTRL_LOCALTIME_FAULT): + _sqlite3Config.FbLocaltimeFault = libc.VaInt32(&ap) + if _sqlite3Config.FbLocaltimeFault == int32(2) { + _sqlite3Config.FxAltLocaltime = libc.VaUintptr(&ap) + } else { + _sqlite3Config.FxAltLocaltime = uintptr(0) + } + break + /* sqlite3_test_control(SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, sqlite3*); + ** + ** Toggle the ability to use internal functions on or off for + ** the database connection given in the argument. + */ + fallthrough + case int32(SQLITE_TESTCTRL_INTERNAL_FUNCTIONS): + db4 = libc.VaUintptr(&ap) + **(**Tu32)(__ccgo_up(db4 + 44)) ^= uint32(DBFLAG_InternalFunc) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, int); + ** + ** Set or clear a flag that indicates that the database file is always well- + ** formed and never corrupt. This flag is clear by default, indicating that + ** database files might have arbitrary corruption. Setting the flag during + ** testing causes certain assert() statements in the code to be activated + ** that demonstrate invariants on well-formed database files. + */ + fallthrough + case int32(SQLITE_TESTCTRL_NEVER_CORRUPT): + _sqlite3Config.FneverCorrupt = libc.VaInt32(&ap) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS, int); + ** + ** Set or clear a flag that causes SQLite to verify that type, name, + ** and tbl_name fields of the sqlite_schema table. This is normally + ** on, but it is sometimes useful to turn it off for testing. + ** + ** 2020-07-22: Disabling EXTRA_SCHEMA_CHECKS also disables the + ** verification of rootpage numbers when parsing the schema. This + ** is useful to make it easier to reach strange internal error states + ** during testing. The EXTRA_SCHEMA_CHECKS setting is always enabled + ** in production. + */ + fallthrough + case int32(SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS): + _sqlite3Config.FbExtraSchemaChecks = libc.Uint8FromInt32(libc.VaInt32(&ap)) + break + /* Set the threshold at which OP_Once counters reset back to zero. + ** By default this is 0x7ffffffe (over 2 billion), but that value is + ** too big to test in a reasonable amount of time, so this control is + ** provided to set a small and easily reachable reset value. + */ + fallthrough + case int32(SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD): + _sqlite3Config.FiOnceResetThreshold = libc.VaInt32(&ap) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE, xCallback, ptr); + ** + ** Set the VDBE coverage callback function to xCallback with context + ** pointer ptr. + */ + fallthrough + case int32(SQLITE_TESTCTRL_VDBE_COVERAGE): + break + /* sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, nMax); */ + fallthrough + case int32(SQLITE_TESTCTRL_SORTER_MMAP): + db5 = libc.VaUintptr(&ap) + (*Tsqlite3)(unsafe.Pointer(db5)).FnMaxSorterMmap = libc.VaInt32(&ap) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_ISINIT); + ** + ** Return SQLITE_OK if SQLite has been initialized and SQLITE_ERROR if + ** not. + */ + fallthrough + case int32(SQLITE_TESTCTRL_ISINIT): + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340) == 0 { + rc = int32(SQLITE_ERROR) + } + break + /* sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, mode, tnum); + ** + ** This test control is used to create imposter tables. "db" is a pointer + ** to the database connection. dbName is the database name (ex: "main" or + ** "temp") which will receive the imposter. "mode" turns imposter mode on + ** or off. mode==0 means imposter mode is off. mode==1 means imposter mode + ** is on. mode==2 means imposter mode is on but results in an imposter + ** table that is read-only unless writable_schema is on. "tnum" is the + ** root page of the b-tree to which the imposter table should connect. + ** + ** Enable imposter mode only when the schema has already been parsed. Then + ** run a single CREATE TABLE statement to construct the imposter table in + ** the parsed schema. Then turn imposter mode back off again. + ** + ** If onOff==0 and tnum>0 then reset the schema for all databases, causing + ** the schema to be reparsed the next time it is needed. This has the + ** effect of erasing all imposter tables. + */ + fallthrough + case int32(SQLITE_TESTCTRL_IMPOSTER): + db6 = libc.VaUintptr(&ap) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db6)).Fmutex) + iDb = _sqlite3FindDbName(tls, db6, libc.VaUintptr(&ap)) + if iDb >= 0 { + (*Tsqlite3)(unsafe.Pointer(db6)).Finit1.FiDb = libc.Uint8FromInt32(iDb) + (*Tsqlite3)(unsafe.Pointer(db6)).Finit1.Fbusy = uint8(libc.AssignBitFieldPtr8Uint32(db6+192+8, libc.Uint32FromInt32(libc.VaInt32(&ap)), 2, 1, 0x6)) + (*Tsqlite3)(unsafe.Pointer(db6)).Finit1.FnewTnum = libc.Uint32FromInt32(libc.VaInt32(&ap)) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db6)).Finit1.Fbusy) == 0 && (*Tsqlite3)(unsafe.Pointer(db6)).Finit1.FnewTnum > uint32(0) { + _sqlite3ResetAllSchemasOfConnection(tls, db6) + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db6)).Fmutex) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_RESULT_INTREAL, sqlite3_context*); + ** + ** This test-control causes the most recent sqlite3_result_int64() value + ** to be interpreted as a MEM_IntReal instead of as an MEM_Int. Normally, + ** MEM_IntReal values only arise during an INSERT operation of integer + ** values into a REAL column, so they can be challenging to test. This + ** test-control enables us to write an intreal() SQL function that can + ** inject an intreal() value at arbitrary places in an SQL statement, + ** for testing purposes. + */ + fallthrough + case int32(SQLITE_TESTCTRL_RESULT_INTREAL): + pCtx = libc.VaUintptr(&ap) + _sqlite3ResultIntReal(tls, pCtx) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_SEEK_COUNT, + ** sqlite3 *db, // Database connection + ** u64 *pnSeek // Write seek count here + ** ); + ** + ** This test-control queries the seek-counter on the "main" database + ** file. The seek-counter is written into *pnSeek and is then reset. + ** The seek-count is only available if compiled with SQLITE_DEBUG. + */ + fallthrough + case int32(SQLITE_TESTCTRL_SEEK_COUNT): + db7 = libc.VaUintptr(&ap) + pn = libc.VaUintptr(&ap) + **(**Tu64)(__ccgo_up(pn)) = uint64(0) + _ = db7 /* Silence harmless unused variable warning */ + break + /* sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, op, ptr) + ** + ** "ptr" is a pointer to a u32. + ** + ** op==0 Store the current sqlite3TreeTrace in *ptr + ** op==1 Set sqlite3TreeTrace to the value *ptr + ** op==2 Store the current sqlite3WhereTrace in *ptr + ** op==3 Set sqlite3WhereTrace to the value *ptr + */ + fallthrough + case int32(SQLITE_TESTCTRL_TRACEFLAGS): + opTrace = libc.VaInt32(&ap) + ptr = libc.VaUintptr(&ap) + switch opTrace { + case 0: + **(**Tu32)(__ccgo_up(ptr)) = _sqlite3TreeTrace + case int32(1): + _sqlite3TreeTrace = **(**Tu32)(__ccgo_up(ptr)) + case int32(2): + **(**Tu32)(__ccgo_up(ptr)) = _sqlite3WhereTrace + case int32(3): + _sqlite3WhereTrace = **(**Tu32)(__ccgo_up(ptr)) + break + } + break + /* sqlite3_test_control(SQLITE_TESTCTRL_LOGEST, + ** double fIn, // Input value + ** int *pLogEst, // sqlite3LogEstFromDouble(fIn) + ** u64 *pInt, // sqlite3LogEstToInt(*pLogEst) + ** int *pLogEst2 // sqlite3LogEst(*pInt) + ** ); + ** + ** Test access for the LogEst conversion routines. + */ + fallthrough + case int32(SQLITE_TESTCTRL_LOGEST): + rIn = libc.VaFloat64(&ap) + rLogEst = _sqlite3LogEstFromDouble(tls, rIn) + pI1 = libc.VaUintptr(&ap) + pU64 = libc.VaUintptr(&ap) + pI2 = libc.VaUintptr(&ap) + **(**int32)(__ccgo_up(pI1)) = int32(rLogEst) + **(**Tu64)(__ccgo_up(pU64)) = _sqlite3LogEstToInt(tls, rLogEst) + **(**int32)(__ccgo_up(pI2)) = int32(_sqlite3LogEst(tls, **(**Tu64)(__ccgo_up(pU64)))) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_ATOF, const char *z, double *p); + ** + ** Test access to the sqlite3AtoF() routine. + */ + fallthrough + case int32(SQLITE_TESTCTRL_ATOF): + z = libc.VaUintptr(&ap) + pR = libc.VaUintptr(&ap) + rc = _sqlite3AtoF(tls, z, pR) + break + /* sqlite3_test_control(SQLITE_TESTCTRL_JSON_SELFCHECK, &onOff); + ** + ** Activate or deactivate validation of JSONB that is generated from + ** text. Off by default, as the validation is slow. Validation is + ** only available if compiled using SQLITE_DEBUG. + ** + ** If onOff is initially 1, then turn it on. If onOff is initially + ** off, turn it off. If onOff is initially -1, then change onOff + ** to be the current setting. + */ + fallthrough + case int32(SQLITE_TESTCTRL_JSON_SELFCHECK): + break + } + _ = ap + return rc +} + +// C documentation +// +// /* +// ** Register a trace function. The pArg from the previously registered trace +// ** is returned. +// ** +// ** A NULL trace function means that no tracing is executes. A non-NULL +// ** trace is a pointer to a function that is invoked at the start of each +// ** SQL statement. +// */ +func Xsqlite3_trace(tls *libc.TLS, db uintptr, __ccgo_fp_xTrace uintptr, pArg uintptr) (r uintptr) { + var pOld uintptr + var v1 int32 + _, _ = pOld, v1 + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pOld = (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg + if __ccgo_fp_xTrace != 0 { + v1 = int32(SQLITE_TRACE_LEGACY) + } else { + v1 = 0 + } + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = libc.Uint8FromInt32(v1) + *(*uintptr)(unsafe.Pointer(db + 248)) = __ccgo_fp_xTrace + (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg = pArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return pOld +} + +// C documentation +// +// /**************************** sqlite3_value_ ******************************* +// ** The following routines extract information from a Mem or sqlite3_value +// ** structure. +// */ +func Xsqlite3_value_blob(tls *libc.TLS, pVal uintptr) (r uintptr) { + var p, v2 uintptr + var v1 int32 + _, _, _ = p, v1, v2 + p = pVal + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_Blob)|libc.Int32FromInt32(MEM_Str)) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&int32(MEM_Zero) != 0 { + v1 = _sqlite3VdbeMemExpandBlob(tls, p) + } else { + v1 = 0 + } + if v1 != SQLITE_OK { + return uintptr(0) + } + v2 = p + 20 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(MEM_Blob)) + if (*TMem)(unsafe.Pointer(p)).Fn != 0 { + v2 = (*TMem)(unsafe.Pointer(p)).Fz + } else { + v2 = uintptr(0) + } + return v2 + } else { + return Xsqlite3_value_text(tls, pVal) + } + return r +} + +func Xsqlite3_value_pointer(tls *libc.TLS, pVal uintptr, zPType uintptr) (r uintptr) { + var p uintptr + _ = p + p = pVal + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Term)|libc.Int32FromInt32(MEM_Subtype)) == libc.Int32FromInt32(MEM_Null)|libc.Int32FromInt32(MEM_Term)|libc.Int32FromInt32(MEM_Subtype) && zPType != uintptr(0) && libc.Int32FromUint8((*TMem)(unsafe.Pointer(p)).FeSubtype) == int32('p') && libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(p)), zPType) == 0 { + return (*TMem)(unsafe.Pointer(p)).Fz + } else { + return uintptr(0) + } + return r +} + +const _LP64 = 1 + +const __LONG_MAX__ = 9223372036854775807 + +const __LONG_WIDTH__ = 64 + +const __LP64__ = 1 + +const __SIZEOF_LONG__ = 8 + +func _addOp4IntSlow(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, p4 int32) (r int32) { + var addr int32 + var pOp uintptr + _, _ = addr, pOp + addr = _sqlite3VdbeAddOp3(tls, p, op, p1, p2, p3) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed) == 0 { + pOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*24 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(3)) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4.Fi = p4 + } + return addr +} + +// C documentation +// +// /* +// ** The pOrderBy->a[].u.x.iOrderByCol values might be incorrect because +// ** columns might have been rearranged in the result set. This routine +// ** fixes them up. +// ** +// ** pEList is the new result set. The pEList->a[].u.x.iOrderByCol values +// ** contain the *old* locations of each expression. This is a temporary +// ** use of u.x.iOrderByCol, not its intended use. The caller must reset +// ** u.x.iOrderByCol back to zero for all entries in pEList before the +// ** caller returns. +// ** +// ** This routine changes pOrderBy->a[].u.x.iOrderByCol values from +// ** pEList->a[N].u.x.iOrderByCol into N+1. (The "+1" is because of the 1-based +// ** indexing used by iOrderByCol.) Or if no match, iOrderByCol is set to zero. +// */ +func _adjustOrderByCol(tls *libc.TLS, pOrderBy uintptr, pEList uintptr) { + var i, j, t int32 + _, _, _ = i, j, t + if pOrderBy == uintptr(0) { + return + } + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + t = libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32 + 24))) + if t == 0 { + goto _1 + } + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if libc.Int32FromUint16(*(*Tu16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 24))) == t { + *(*Tu16)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32 + 24)) = libc.Uint16FromInt32(j + int32(1)) + break + } + goto _2 + _2: + ; + j = j + 1 + } + if j >= (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + *(*Tu16)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32 + 24)) = uint16(0) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** This is a Walker expression node callback. +// ** +// ** For Expr nodes that contain pAggInfo pointers, make sure the AggInfo +// ** object that is referenced does not refer directly to the Expr. If +// ** it does, make a copy. This is done because the pExpr argument is +// ** subject to change. +// ** +// ** The copy is scheduled for deletion using the sqlite3ExprDeferredDelete() +// ** which builds on the sqlite3ParserAddCleanup() mechanism. +// */ +func _agginfoPersistExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var db, pAggInfo, pParse uintptr + var iAgg int32 + _, _, _, _ = db, iAgg, pAggInfo, pParse + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Reduced)) != libc.Uint32FromInt32(0)) && (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo != uintptr(0) { + pAggInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + iAgg = int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_AGG_FUNCTION) { + if iAgg < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn && (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(iAgg)*32))).FpCExpr == pExpr { + pExpr = _sqlite3ExprDup(tls, db, pExpr, 0) + if pExpr != 0 && !(_sqlite3ExprDeferredDelete(tls, pParse, pExpr) != 0) { + (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(iAgg)*32))).FpCExpr = pExpr + } + } + } else { + if iAgg < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc && (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(iAgg)*32))).FpFExpr == pExpr { + pExpr = _sqlite3ExprDup(tls, db, pExpr, 0) + if pExpr != 0 && !(_sqlite3ExprDeferredDelete(tls, pParse, pExpr) != 0) { + (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(iAgg)*32))).FpFExpr = pExpr + } + } + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Walker callback for aggregateConvertIndexedExprRefToColumn(). +// */ +func _aggregateIdxEprRefToColCallback(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var pAggInfo, pCol uintptr + _, _ = pAggInfo, pCol + _ = pWalker + if (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) { + return WRC_Continue + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_COLUMN) { + return WRC_Continue + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_FUNCTION) { + return WRC_Continue + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IF_NULL_ROW) { + return WRC_Continue + } + pAggInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn { + return WRC_Continue + } + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32 + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_AGG_COLUMN) + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TAggInfo_col)(unsafe.Pointer(pCol)).FiTable + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16((*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn) + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Skip) | libc.Int32FromInt32(EP_Collate) | libc.Int32FromInt32(EP_Unlikely)) + return int32(WRC_Prune) +} + +// C documentation +// +// /* +// ** Allocate nByte bytes of space from within the B-Tree page passed +// ** as the first argument. Write into *pIdx the index into pPage->aData[] +// ** of the first byte of allocated space. Return either SQLITE_OK or +// ** an error code (usually SQLITE_CORRUPT). +// ** +// ** The caller guarantees that there is sufficient space to make the +// ** allocation. This routine might need to defragment in order to bring +// ** all the space together, however. This routine will avoid using +// ** the first two bytes past the cell pointer area since presumably this +// ** allocation is being made in order to insert a new cell, so we will +// ** also end up needing a new cell pointer. +// */ +func _allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var data, pSpace, pTmp uintptr + var g2, gap, hdr, top, v1 int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _ = data, g2, gap, hdr, pSpace, pTmp, top, v1 + hdr = libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) /* Local cache of pPage->hdrOffset */ + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData /* First byte of cell content area */ + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* First byte of gap between cell pointers and cell content */ + /* Minimum cell size is 4 */ + gap = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FcellOffset) + int32(2)*libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) + /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size + ** and the reserved space is zero (the usual value for reserved space) + ** then the cell content offset of an empty page wants to be 65536. + ** However, that integer is too large to be stored in a 2-byte unsigned + ** integer, so a value of 0 is used in its place. */ + pTmp = data + uintptr(hdr+int32(5)) + top = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTmp)))< top { + if top == 0 && (*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize == uint32(65536) { + top = int32(65536) + } else { + return _sqlite3CorruptError(tls, int32(74990)) + } + } else { + if top > libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) { + return _sqlite3CorruptError(tls, int32(74993)) + } + } + /* If there is enough space between gap and top for one more cell pointer, + ** and if the freelist is not empty, then search the + ** freelist looking for a slot big enough to satisfy the request. + */ + if (**(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(2)))) != 0 || **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(1)))) != 0) && gap+int32(2) <= top { + pSpace = _pageFindSlot(tls, pPage, nByte, bp) + if pSpace != 0 { + v1 = int32(int64(pSpace) - int64(data)) + g2 = v1 + **(**int32)(__ccgo_up(pIdx)) = v1 + if g2 <= gap { + return _sqlite3CorruptError(tls, int32(75010)) + } else { + return SQLITE_OK + } + } else { + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + } + /* The request could not be fulfilled using a freelist slot. Check + ** to see if defragmentation is necessary. + */ + if gap+int32(2)+nByte > top { + if int32(4) < (*TMemPage)(unsafe.Pointer(pPage)).FnFree-(int32(2)+nByte) { + v1 = int32(4) + } else { + v1 = (*TMemPage)(unsafe.Pointer(pPage)).FnFree - (int32(2) + nByte) + } + **(**int32)(__ccgo_up(bp)) = _defragmentPage(tls, pPage, v1) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + top = (libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(5)))))<> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(data + uintptr(hdr+int32(5)) + 1)) = libc.Uint8FromInt32(top) + **(**int32)(__ccgo_up(pIdx)) = top + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This callback is invoked once for each index when reading the +// ** sqlite_stat1 table. +// ** +// ** argv[0] = name of the table +// ** argv[1] = name of the index (might be NULL) +// ** argv[2] = results of analysis - on integer for each column +// ** +// ** Entries for which argv[1]==NULL simply record the number of rows in +// ** the table. +// */ +func _analysisLoader(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotUsed uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var aiRowEst, pIndex, pInfo, pTable, z uintptr + var nCol int32 + var _ /* fakeIdx at bp+0 */ TIndex + _, _, _, _, _, _ = aiRowEst, nCol, pIndex, pInfo, pTable, z + pInfo = pData + _ = NotUsed + _ = argc + if argv == uintptr(0) || **(**uintptr)(__ccgo_up(argv)) == uintptr(0) || **(**uintptr)(__ccgo_up(argv + 2*8)) == uintptr(0) { + return 0 + } + pTable = _sqlite3FindTable(tls, (*TanalysisInfo)(unsafe.Pointer(pInfo)).Fdb, **(**uintptr)(__ccgo_up(argv)), (*TanalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) + if pTable == uintptr(0) { + return 0 + } + if **(**uintptr)(__ccgo_up(argv + 1*8)) == uintptr(0) { + pIndex = uintptr(0) + } else { + if Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(argv)), **(**uintptr)(__ccgo_up(argv + 1*8))) == 0 { + pIndex = _sqlite3PrimaryKeyIndex(tls, pTable) + } else { + pIndex = _sqlite3FindIndex(tls, (*TanalysisInfo)(unsafe.Pointer(pInfo)).Fdb, **(**uintptr)(__ccgo_up(argv + 1*8)), (*TanalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) + } + } + z = **(**uintptr)(__ccgo_up(argv + 2*8)) + if pIndex != 0 { + aiRowEst = uintptr(0) + nCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol) + int32(1) + /* Index.aiRowEst may already be set here if there are duplicate + ** sqlite_stat1 entries for this index. In that case just clobber + ** the old data with the new instead of allocating a new array. */ + if (*TIndex)(unsafe.Pointer(pIndex)).FaiRowEst == uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).FaiRowEst = _sqlite3MallocZero(tls, uint64(uint64(8)*libc.Uint64FromInt32(nCol))) + if (*TIndex)(unsafe.Pointer(pIndex)).FaiRowEst == uintptr(0) { + _sqlite3OomFault(tls, (*TanalysisInfo)(unsafe.Pointer(pInfo)).Fdb) + } + } + aiRowEst = (*TIndex)(unsafe.Pointer(pIndex)).FaiRowEst + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 2, 0x4) + _decodeIntArray(tls, z, nCol, aiRowEst, (*TIndex)(unsafe.Pointer(pIndex)).FaiRowLogEst, pIndex) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 7, 0x80) + if (*TIndex)(unsafe.Pointer(pIndex)).FpPartIdxWhere == uintptr(0) { + (*TTable)(unsafe.Pointer(pTable)).FnRowLogEst = **(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiRowLogEst)) + **(**Tu32)(__ccgo_up(pTable + 48)) |= uint32(TF_HasStat1) + } + } else { + (**(**TIndex)(__ccgo_up(bp))).FszIdxRow = (*TTable)(unsafe.Pointer(pTable)).FszTabRow + _decodeIntArray(tls, z, int32(1), uintptr(0), pTable+58, bp) + (*TTable)(unsafe.Pointer(pTable)).FszTabRow = (**(**TIndex)(__ccgo_up(bp))).FszIdxRow + **(**Tu32)(__ccgo_up(pTable + 48)) |= uint32(TF_HasStat1) + } + return 0 +} + +// C documentation +// +// /* +// ** Analyze the arguments to aggregate functions. Create new pAggInfo->aCol[] +// ** entries for columns that are arguments to aggregate functions but which +// ** are not otherwise used. +// ** +// ** The aCol[] entries in AggInfo prior to nAccumulator are columns that +// ** are referenced outside of aggregate functions. These might be columns +// ** that are part of the GROUP by clause, for example. Other database engines +// ** would throw an error if there is a column reference that is not in the +// ** GROUP BY clause and that is not part of an aggregate function argument. +// ** But SQLite allows this. +// ** +// ** The aCol[] entries beginning with the aCol[nAccumulator] and following +// ** are column references that are used exclusively as arguments to +// ** aggregate functions. This routine is responsible for computing +// ** (or recomputing) those aCol[] entries. +// */ +func _analyzeAggFuncArgs(tls *libc.TLS, pAggInfo uintptr, pNC uintptr) { + var i int32 + var pExpr uintptr + _, _ = i, pExpr + **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_InAggFunc) + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + pExpr = (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32))).FpFExpr + _sqlite3ExprAnalyzeAggList(tls, pNC, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3ExprAnalyzeAggList(tls, pNC, *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32))) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3ExprAnalyzeAggregates(tls, pNC, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpFilter) + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(pNC + 40)) &= ^libc.Int32FromInt32(NC_InAggFunc) +} + +// C documentation +// +// /* +// ** Locate or create an AutoincInfo structure associated with table pTab +// ** which is in database iDb. Return the register number for the register +// ** that holds the maximum rowid. Return zero if pTab is not an AUTOINCREMENT +// ** table. (Also return zero when doing a VACUUM since we do not want to +// ** update the AUTOINCREMENT counters during a VACUUM.) +// ** +// ** There is at most one AutoincInfo structure per table even if the +// ** same table is autoincremented multiple times due to inserts within +// ** triggers. A new AutoincInfo structure is created if this is the +// ** first use of table pTab. On 2nd and subsequent uses, the original +// ** AutoincInfo structure is used. +// ** +// ** Four consecutive registers are allocated: +// ** +// ** (1) The name of the pTab table. +// ** (2) The maximum ROWID of pTab. +// ** (3) The rowid in sqlite_sequence of pTab +// ** (4) The original value of the max ROWID in pTab, or NULL if none +// ** +// ** The 2nd register is the one that is returned. That is all the +// ** insert routine needs to know about. +// */ +func _autoIncBegin(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr) (r int32) { + var memId, v2 int32 + var pInfo, pSeqTab, pToplevel, v1 uintptr + _, _, _, _, _, _ = memId, pInfo, pSeqTab, pToplevel, v1, v2 + memId = 0 /* Register holding maximum rowid */ + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Autoincrement) != uint32(0) && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_Vacuum) == uint32(0) { + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + pToplevel = v1 + pSeqTab = (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FpSchema)).FpSeqTab + /* Verify that the sqlite_sequence table exists and is an ordinary + ** rowid table with exactly two columns. + ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */ + if pSeqTab == uintptr(0) || !((*TTable)(unsafe.Pointer(pSeqTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) || libc.Int32FromUint8((*TTable)(unsafe.Pointer(pSeqTab)).FeTabType) == int32(TABTYP_VTAB) || int32((*TTable)(unsafe.Pointer(pSeqTab)).FnCol) != int32(2) { + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(2)< nFree { + nVac = nFree + } + if nVac == uint32(0) { + return SQLITE_OK + } + } else { + nVac = nFree + } + nFin = _finalDbSize(tls, pBt, nOrig, nVac) + if nFin > nOrig { + return _sqlite3CorruptError(tls, int32(77394)) + } + if nFin < nOrig { + rc = _saveAllCursors(tls, pBt, uint32(0), uintptr(0)) + } + iFree = nOrig + for { + if !(iFree > nFin && rc == SQLITE_OK) { + break + } + rc = _incrVacuumStep(tls, pBt, nFin, iFree, libc.BoolInt32(nVac == nFree)) + goto _2 + _2: + ; + iFree = iFree - 1 + } + if (rc == int32(SQLITE_DONE) || rc == SQLITE_OK) && nFree > uint32(0) { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) + if nVac == nFree { + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+32, uint32(0)) + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36, uint32(0)) + } + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+28, nFin) + (*TBtShared)(unsafe.Pointer(pBt)).FbDoTruncate = uint8(1) + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = nFin + } + if rc != SQLITE_OK { + _sqlite3PagerRollback(tls, pPager) + } + } + return rc +} + +// C documentation +// +// /* +// ** The page that pCur currently points to has just been modified in +// ** some way. This function figures out if this modification means the +// ** tree needs to be balanced, and if so calls the appropriate balancing +// ** routine. Balancing routines are: +// ** +// ** balance_quick() +// ** balance_deeper() +// ** balance_nonroot() +// */ +func _balance(tls *libc.TLS, pCur uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iIdx, iPage, rc, v1, v2 int32 + var pFree, pPage, pParent, pSpace uintptr + var v3 bool + var _ /* aBalanceQuickSpace at bp+0 */ [13]Tu8 + _, _, _, _, _, _, _, _, _, _ = iIdx, iPage, pFree, pPage, pParent, pSpace, rc, v1, v2, v3 + rc = SQLITE_OK + pFree = uintptr(0) + for cond := true; cond; cond = rc == SQLITE_OK { + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + if (*TMemPage)(unsafe.Pointer(pPage)).FnFree < 0 && _btreeComputeFreeSpace(tls, pPage) != 0 { + break + } + if libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FnOverflow) == 0 && (*TMemPage)(unsafe.Pointer(pPage)).FnFree*int32(3) <= libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBt)).FusableSize)*int32(2) { + /* No rebalance required as long as: + ** (1) There are no overflow cells + ** (2) The amount of free space on the page is less than 2/3rds of + ** the total usable space on the page. */ + break + } else { + v1 = int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) + iPage = v1 + if v1 == 0 { + if v3 = (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow != 0; v3 { + v2 = _anotherValidCursor(tls, pCur) + rc = v2 + } + if v3 && v2 == SQLITE_OK { + /* The root page of the b-tree is overfull. In this case call the + ** balance_deeper() function to create a new child for the root-page + ** and copy the current contents of the root-page to it. The + ** next iteration of the do-loop will balance the child page. + */ + rc = _balance_deeper(tls, pPage, pCur+144+1*8) + if rc == SQLITE_OK { + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = int8(1) + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = uint16(0) + **(**Tu16)(__ccgo_up(pCur + 88)) = uint16(0) + **(**uintptr)(__ccgo_up(pCur + 144)) = pPage + (*TBtCursor)(unsafe.Pointer(pCur)).FpPage = **(**uintptr)(__ccgo_up(pCur + 144 + 1*8)) + } + } else { + break + } + } else { + if _sqlite3PagerPageRefcount(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage) > int32(1) { + /* The page being written is not a root page, and there is currently + ** more than one reference to it. This only happens if the page is one + ** of its own ancestor pages. Corruption. */ + rc = _sqlite3CorruptError(tls, int32(82308)) + } else { + pParent = **(**uintptr)(__ccgo_up(pCur + 144 + uintptr(iPage-int32(1))*8)) + iIdx = libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pCur + 88 + uintptr(iPage-int32(1))*2))) + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pParent)).FpDbPage) + if rc == SQLITE_OK && (*TMemPage)(unsafe.Pointer(pParent)).FnFree < 0 { + rc = _btreeComputeFreeSpace(tls, pParent) + } + if rc == SQLITE_OK { + if (*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf != 0 && libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FnOverflow) == int32(1) && libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pPage + 28))) == libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) && (*TMemPage)(unsafe.Pointer(pParent)).Fpgno != uint32(1) && libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pParent)).FnCell) == iIdx { + /* Call balance_quick() to create a new sibling of pPage on which + ** to store the overflow cell. balance_quick() inserts a new cell + ** into pParent, which may cause pParent overflow. If this + ** happens, the next iteration of the do-loop will balance pParent + ** use either balance_nonroot() or balance_deeper(). Until this + ** happens, the overflow cell is stored in the aBalanceQuickSpace[] + ** buffer. + ** + ** The purpose of the following assert() is to check that only a + ** single call to balance_quick() is made for each call to this + ** function. If this were not verified, a subtle bug involving reuse + ** of the aBalanceQuickSpace[] might sneak in. + */ + rc = _balance_quick(tls, pParent, pPage, bp) + } else { + /* In this case, call balance_nonroot() to redistribute cells + ** between pPage and up to 2 of its sibling pages. This involves + ** modifying the contents of pParent, which may cause pParent to + ** become overfull or underfull. The next iteration of the do-loop + ** will balance the parent page to correct this. + ** + ** If the parent page becomes overfull, the overflow cell or cells + ** are stored in the pSpace buffer allocated immediately below. + ** A subsequent iteration of the do-loop will deal with this by + ** calling balance_nonroot() (balance_deeper() may be called first, + ** but it doesn't deal with overflow cells - just moves them to a + ** different page). Once this subsequent call to balance_nonroot() + ** has completed, it is safe to release the pSpace buffer used by + ** the previous call, as the overflow cell data will have been + ** copied either into the body of a database page or into the new + ** pSpace buffer passed to the latter call to balance_nonroot(). + */ + pSpace = _sqlite3PageMalloc(tls, libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBt)).FpageSize)) + rc = _balance_nonroot(tls, pParent, iIdx, pSpace, libc.BoolInt32(iPage == int32(1)), libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).Fhints)&int32(BTREE_BULKLOAD)) + if pFree != 0 { + /* If pFree is not NULL, it points to the pSpace buffer used + ** by a previous call to balance_nonroot(). Its contents are + ** now stored either on real database pages or within the + ** new pSpace buffer, so it may be safely freed here. */ + _sqlite3PageFree(tls, pFree) + } + /* The pSpace buffer will be freed after the next call to + ** balance_nonroot(), or just before this function returns, whichever + ** comes first. */ + pFree = pSpace + } + } + (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow = uint8(0) + /* The next iteration of the do-loop balances the parent page. */ + _releasePage(tls, pPage) + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = (*TBtCursor)(unsafe.Pointer(pCur)).FiPage - 1 + (*TBtCursor)(unsafe.Pointer(pCur)).FpPage = **(**uintptr)(__ccgo_up(pCur + 144 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*8)) + } + } + } + } + if pFree != 0 { + _sqlite3PageFree(tls, pFree) + } + return rc +} + +// C documentation +// +// /* +// ** This is the default collating function named "BINARY" which is always +// ** available. +// */ +func _binCollFunc(tls *libc.TLS, NotUsed uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) (r int32) { + var n, rc, v1 int32 + _, _, _ = n, rc, v1 + _ = NotUsed + if nKey1 < nKey2 { + v1 = nKey1 + } else { + v1 = nKey2 + } + n = v1 + /* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares + ** strings byte by byte using the memcmp() function from the standard C + ** library. */ + rc = libc.Xmemcmp(tls, pKey1, pKey2, libc.Uint64FromInt32(n)) + if rc == 0 { + rc = nKey1 - nKey2 + } + return rc +} + +// C documentation +// +// /* +// ** Bind a text or BLOB value. +// */ +func _bindText(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData Ti64, __ccgo_fp_xDel uintptr, encoding Tu8) (r int32) { + var p, pVar, v1 uintptr + var rc int32 + _, _, _, _ = p, pVar, rc, v1 + p = pStmt + rc = _vdbeUnbind(tls, p, libc.Uint32FromInt32(i-libc.Int32FromInt32(1))) + if rc == SQLITE_OK { + /* tag-20240917-01 */ + if zData != uintptr(0) { + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr(i-int32(1))*56 + if libc.Int32FromUint8(encoding) == int32(SQLITE_UTF8) { + rc = _sqlite3VdbeMemSetText(tls, pVar, zData, nData, __ccgo_fp_xDel) + } else { + if libc.Int32FromUint8(encoding) == int32(SQLITE_UTF8_ZT) { + /* It is usually consider improper to assert() on an input. + ** However, the following assert() is checking for inputs + ** that are documented to result in undefined behavior. */ + rc = _sqlite3VdbeMemSetText(tls, pVar, zData, nData, __ccgo_fp_xDel) + v1 = pVar + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + } else { + rc = _sqlite3VdbeMemSetStr(tls, pVar, zData, nData, encoding, __ccgo_fp_xDel) + if libc.Int32FromUint8(encoding) == 0 { + (*TMem)(unsafe.Pointer(pVar)).Fenc = (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fenc + } + } + } + if rc == SQLITE_OK && libc.Int32FromUint8(encoding) != 0 { + rc = _sqlite3VdbeChangeEncoding(tls, pVar, libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fenc)) + } + if rc != 0 { + _sqlite3Error(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, rc) + rc = _sqlite3ApiExit(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, rc) + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + } else { + if __ccgo_fp_xDel != libc.UintptrFromInt32(0) && __ccgo_fp_xDel != uintptr(-libc.Int32FromInt32(1)) { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, zData) + } + } + return rc +} + +// C documentation +// +// /* +// ** Attempt to start a new transaction. A write-transaction +// ** is started if the second argument is nonzero, otherwise a read- +// ** transaction. If the second argument is 2 or more and exclusive +// ** transaction is started, meaning that no other process is allowed +// ** to access the database. A preexisting transaction may not be +// ** upgraded to exclusive by calling this routine a second time - the +// ** exclusivity flag only works for a new transaction. +// ** +// ** A write-transaction must be started before attempting any +// ** changes to the database. None of the following routines +// ** will work unless a transaction is started first: +// ** +// ** sqlite3BtreeCreateTable() +// ** sqlite3BtreeCreateIndex() +// ** sqlite3BtreeClearTable() +// ** sqlite3BtreeDropTable() +// ** sqlite3BtreeInsert() +// ** sqlite3BtreeDelete() +// ** sqlite3BtreeUpdateMeta() +// ** +// ** If an initial attempt to acquire the lock fails because of lock contention +// ** and the database was previously unlocked, then invoke the busy handler +// ** if there is one. But if there was previously a read-lock, do not +// ** invoke the busy handler - just return SQLITE_BUSY. SQLITE_BUSY is +// ** returned when there is already a read-lock in order to avoid a deadlock. +// ** +// ** Suppose there are two processes A and B. A has a read lock and B has +// ** a reserved lock. B tries to promote to exclusive but is blocked because +// ** of A's read lock. A tries to promote to reserved but is blocked by B. +// ** One or the other of the two processes must give way or there can be +// ** no progress. By returning SQLITE_BUSY and not invoking the busy callback +// ** when A already has a read lock, we encourage A to give up and let B +// ** proceed. +// */ +func _btreeBeginTrans(tls *libc.TLS, p uintptr, wrflag int32, pSchemaVersion uintptr) (r int32) { + var pBlock, pBt, pIter, pPage1, pPager, v1 uintptr + var rc, v5 int32 + var v6 bool + _, _, _, _, _, _, _, _, _ = pBlock, pBt, pIter, pPage1, pPager, rc, v1, v5, v6 + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + pPager = (*TBtShared)(unsafe.Pointer(pBt)).FpPager + rc = SQLITE_OK + _sqlite3BtreeEnter(tls, p) + /* If the btree is already in a write-transaction, or it + ** is already in a read-transaction and a read-transaction + ** is requested, this is a no-op. + */ + if libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == int32(TRANS_WRITE) || libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == int32(TRANS_READ) && !(wrflag != 0) { + goto trans_begun + } + if (*Tsqlite3)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).Fdb)).Fflags&uint64(SQLITE_ResetDatabase) != 0 && libc.Int32FromUint8(_sqlite3PagerIsreadonly(tls, pPager)) == 0 { + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTS_READ_ONLY)) + } + /* Write transactions are not possible on a read-only database */ + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_READ_ONLY) != 0 && wrflag != 0 { + rc = int32(SQLITE_READONLY) + goto trans_begun + } + pBlock = uintptr(0) + /* If another database handle has already opened a write transaction + ** on this shared-btree structure and a second write transaction is + ** requested, return SQLITE_LOCKED. + */ + if wrflag != 0 && libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FinTransaction) == int32(TRANS_WRITE) || libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_PENDING) != 0 { + pBlock = (*TBtree)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpWriter)).Fdb + } else { + if wrflag > int32(1) { + pIter = (*TBtShared)(unsafe.Pointer(pBt)).FpLock + for { + if !(pIter != 0) { + break + } + if (*TBtLock)(unsafe.Pointer(pIter)).FpBtree != p { + pBlock = (*TBtree)(unsafe.Pointer((*TBtLock)(unsafe.Pointer(pIter)).FpBtree)).Fdb + break + } + goto _2 + _2: + ; + pIter = (*TBtLock)(unsafe.Pointer(pIter)).FpNext + } + } + } + if pBlock != 0 { + _sqlite3ConnectionBlocked(tls, (*TBtree)(unsafe.Pointer(p)).Fdb, pBlock) + rc = libc.Int32FromInt32(SQLITE_LOCKED) | libc.Int32FromInt32(1)<pPage1 is populated or + ** lockBtree() returns something other than SQLITE_OK. lockBtree() + ** may return SQLITE_OK but leave pBt->pPage1 set to 0 if after + ** reading page 1 it discovers that the page-size of the database + ** file is not pBt->pageSize. In this case lockBtree() will update + ** pBt->pageSize to the page-size of the file on disk. + */ + for { + if v6 = (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 == uintptr(0); v6 { + v5 = _lockBtree(tls, pBt) + rc = v5 + } + if !(v6 && SQLITE_OK == v5) { + break + } + } + if rc == SQLITE_OK && wrflag != 0 { + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_READ_ONLY) != 0 { + rc = int32(SQLITE_READONLY) + } else { + rc = _sqlite3PagerBegin(tls, pPager, libc.BoolInt32(wrflag > int32(1)), _sqlite3TempInMemory(tls, (*TBtree)(unsafe.Pointer(p)).Fdb)) + if rc == SQLITE_OK { + rc = _newDatabase(tls, pBt) + } else { + if rc == libc.Int32FromInt32(SQLITE_BUSY)|libc.Int32FromInt32(2)< libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FinTransaction) { + (*TBtShared)(unsafe.Pointer(pBt)).FinTransaction = (*TBtree)(unsafe.Pointer(p)).FinTrans + } + if wrflag != 0 { + pPage1 = (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 + (*TBtShared)(unsafe.Pointer(pBt)).FpWriter = p + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTS_EXCLUSIVE)) + if wrflag > int32(1) { + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_EXCLUSIVE)) + } + /* If the db-size header field is incorrect (as it may be if an old + ** client has been writing the database file), update it now. Doing + ** this sooner rather than later means the database size can safely + ** re-read the database size from page 1 if a savepoint or transaction + ** rollback occurs within the transaction. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FnPage != _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+28) { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FpDbPage) + if rc == SQLITE_OK { + _sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+28, (*TBtShared)(unsafe.Pointer(pBt)).FnPage) + } + } + } + } + goto trans_begun +trans_begun: + ; + if rc == SQLITE_OK { + if pSchemaVersion != 0 { + **(**int32)(__ccgo_up(pSchemaVersion)) = libc.Int32FromUint32(_sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+40)) + } + if wrflag != 0 { + /* This call makes sure that the pager has the correct number of + ** open savepoints. If the second parameter is greater than 0 and + ** the sub-journal is not already open, then it will be opened here. + */ + rc = _sqlite3PagerOpenSavepoint(tls, pPager, (*Tsqlite3)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).Fdb)).FnSavepoint) + } + } + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Create a new BTree table. Write into *piTable the page +// ** number for the root page of the new table. +// ** +// ** The type of type is determined by the flags parameter. Only the +// ** following values of flags are currently in use. Other values for +// ** flags might not work: +// ** +// ** BTREE_INTKEY|BTREE_LEAFDATA Used for SQL tables with rowid keys +// ** BTREE_ZERODATA Used for SQL indices +// */ +func _btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var pBt uintptr + var ptfFlags int32 + var _ /* eType at bp+32 */ Tu8 + var _ /* iPtrPage at bp+36 */ TPgno + var _ /* pPageMove at bp+24 */ uintptr + var _ /* pRoot at bp+0 */ uintptr + var _ /* pgnoMove at bp+16 */ TPgno + var _ /* pgnoRoot at bp+8 */ TPgno + var _ /* rc at bp+12 */ int32 + _, _ = pBt, ptfFlags + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt /* Page-type flags for the root page of new table */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { /* The page to move to. */ + /* Creating a new table may probably require moving an existing database + ** to make room for the new tables root page. In case this page turns + ** out to be an overflow page, delete all overflow page-map caches + ** held by open cursors. + */ + _invalidateAllOverflowCache(tls, pBt) + /* Read the value of meta[3] from the database to determine where the + ** root page of the new table should go. meta[3] is the largest root-page + ** created so far, so the new root-page is (meta[3]+1). + */ + _sqlite3BtreeGetMeta(tls, p, int32(BTREE_LARGEST_ROOT_PAGE), bp+8) + if **(**TPgno)(__ccgo_up(bp + 8)) > _btreePagecount(tls, pBt) { + return _sqlite3CorruptError(tls, int32(83222)) + } + **(**TPgno)(__ccgo_up(bp + 8)) = **(**TPgno)(__ccgo_up(bp + 8)) + 1 + /* The new root-page may not be allocated on a pointer-map page, or the + ** PENDING_BYTE page. + */ + for **(**TPgno)(__ccgo_up(bp + 8)) == _ptrmapPageno(tls, pBt, **(**TPgno)(__ccgo_up(bp + 8))) || **(**TPgno)(__ccgo_up(bp + 8)) == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + **(**TPgno)(__ccgo_up(bp + 8)) = **(**TPgno)(__ccgo_up(bp + 8)) + 1 + } + /* Allocate a page. The page that currently resides at pgnoRoot will + ** be moved to the allocated page (unless the allocated page happens + ** to reside at pgnoRoot). + */ + **(**int32)(__ccgo_up(bp + 12)) = _allocateBtreePage(tls, pBt, bp+24, bp+16, **(**TPgno)(__ccgo_up(bp + 8)), uint8(BTALLOC_EXACT)) + if **(**int32)(__ccgo_up(bp + 12)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 12)) + } + if **(**TPgno)(__ccgo_up(bp + 16)) != **(**TPgno)(__ccgo_up(bp + 8)) { + /* pgnoRoot is the page that will be used for the root-page of + ** the new table (assuming an error did not occur). But we were + ** allocated pgnoMove. If required (i.e. if it was not allocated + ** by extending the file), the current page at position pgnoMove + ** is already journaled. + */ + **(**Tu8)(__ccgo_up(bp + 32)) = uint8(0) + **(**TPgno)(__ccgo_up(bp + 36)) = uint32(0) + /* Save the positions of any open cursors. This is required in + ** case they are holding a reference to an xFetch reference + ** corresponding to page pgnoRoot. */ + **(**int32)(__ccgo_up(bp + 12)) = _saveAllCursors(tls, pBt, uint32(0), uintptr(0)) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 24))) + if **(**int32)(__ccgo_up(bp + 12)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 12)) + } + /* Move the page currently at pgnoRoot to pgnoMove. */ + **(**int32)(__ccgo_up(bp + 12)) = _btreeGetPage(tls, pBt, **(**TPgno)(__ccgo_up(bp + 8)), bp, 0) + if **(**int32)(__ccgo_up(bp + 12)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 12)) + } + **(**int32)(__ccgo_up(bp + 12)) = _ptrmapGet(tls, pBt, **(**TPgno)(__ccgo_up(bp + 8)), bp+32, bp+36) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp + 32))) == int32(PTRMAP_ROOTPAGE) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp + 32))) == int32(PTRMAP_FREEPAGE) { + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3CorruptError(tls, int32(83270)) + } + if **(**int32)(__ccgo_up(bp + 12)) != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + return **(**int32)(__ccgo_up(bp + 12)) + } + **(**int32)(__ccgo_up(bp + 12)) = _relocatePage(tls, pBt, **(**uintptr)(__ccgo_up(bp)), **(**Tu8)(__ccgo_up(bp + 32)), **(**TPgno)(__ccgo_up(bp + 36)), **(**TPgno)(__ccgo_up(bp + 16)), 0) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + /* Obtain the page at pgnoRoot */ + if **(**int32)(__ccgo_up(bp + 12)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 12)) + } + **(**int32)(__ccgo_up(bp + 12)) = _btreeGetPage(tls, pBt, **(**TPgno)(__ccgo_up(bp + 8)), bp, 0) + if **(**int32)(__ccgo_up(bp + 12)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 12)) + } + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if **(**int32)(__ccgo_up(bp + 12)) != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + return **(**int32)(__ccgo_up(bp + 12)) + } + } else { + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp + 24)) + } + /* Update the pointer-map and meta-data with the new root-page number. */ + _ptrmapPut(tls, pBt, **(**TPgno)(__ccgo_up(bp + 8)), uint8(PTRMAP_ROOTPAGE), uint32(0), bp+12) + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + return **(**int32)(__ccgo_up(bp + 12)) + } + /* When the new root page was allocated, page 1 was made writable in + ** order either to increase the database filesize, or to decrement the + ** freelist count. Hence, the sqlite3BtreeUpdateMeta() call cannot fail. + */ + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3BtreeUpdateMeta(tls, p, int32(4), **(**TPgno)(__ccgo_up(bp + 8))) + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + return **(**int32)(__ccgo_up(bp + 12)) + } + } else { + **(**int32)(__ccgo_up(bp + 12)) = _allocateBtreePage(tls, pBt, bp, bp+8, uint32(1), uint8(0)) + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + return **(**int32)(__ccgo_up(bp + 12)) + } + } + if createTabFlags&int32(BTREE_INTKEY) != 0 { + ptfFlags = libc.Int32FromInt32(PTF_INTKEY) | libc.Int32FromInt32(PTF_LEAFDATA) | libc.Int32FromInt32(PTF_LEAF) + } else { + ptfFlags = libc.Int32FromInt32(PTF_ZERODATA) | libc.Int32FromInt32(PTF_LEAF) + } + _zeroPage(tls, **(**uintptr)(__ccgo_up(bp)), ptfFlags) + _sqlite3PagerUnref(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + **(**TPgno)(__ccgo_up(piTable)) = **(**TPgno)(__ccgo_up(bp + 8)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Erase all information in a table and add the root of the table to +// ** the freelist. Except, the root of the principle table (the one on +// ** page 1) is never added to the freelist. +// ** +// ** This routine will fail with SQLITE_LOCKED if there are any open +// ** cursors on the table. +// ** +// ** If AUTOVACUUM is enabled and the page at iTable is not the last +// ** root page in the database file, then the last root page +// ** in the database file is moved into the slot formerly occupied by +// ** iTable and that last slot formerly occupied by the last root page +// ** is added to the freelist instead of iTable. In this say, all +// ** root pages are kept at the beginning of the database file, which +// ** is necessary for AUTOVACUUM to work right. *piMoved is set to the +// ** page number that used to be the last root page in the file before +// ** the move. If no page gets moved, *piMoved is set to 0. +// ** The last root page is recorded in meta[3] and the value of +// ** meta[3] is updated by this procedure. +// */ +func _btreeDropTable(tls *libc.TLS, p uintptr, iTable TPgno, piMoved uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pBt uintptr + var _ /* maxRootPgno at bp+16 */ TPgno + var _ /* pMove at bp+24 */ uintptr + var _ /* pPage at bp+8 */ uintptr + var _ /* rc at bp+0 */ int32 + _ = pBt + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + if iTable > _btreePagecount(tls, pBt) { + return _sqlite3CorruptError(tls, int32(83471)) + } + **(**int32)(__ccgo_up(bp)) = _sqlite3BtreeClearTable(tls, p, libc.Int32FromUint32(iTable), uintptr(0)) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + **(**int32)(__ccgo_up(bp)) = _btreeGetPage(tls, pBt, iTable, bp+8, 0) + if **(**int32)(__ccgo_up(bp)) != 0 { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return **(**int32)(__ccgo_up(bp)) + } + **(**int32)(__ccgo_up(piMoved)) = 0 + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + _sqlite3BtreeGetMeta(tls, p, int32(BTREE_LARGEST_ROOT_PAGE), bp+16) + if iTable == **(**TPgno)(__ccgo_up(bp + 16)) { + /* If the table being dropped is the table with the largest root-page + ** number in the database, put the root page on the free list. + */ + _freePage(tls, **(**uintptr)(__ccgo_up(bp + 8)), bp) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp)) + } + } else { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**int32)(__ccgo_up(bp)) = _btreeGetPage(tls, pBt, **(**TPgno)(__ccgo_up(bp + 16)), bp+24, 0) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp)) + } + **(**int32)(__ccgo_up(bp)) = _relocatePage(tls, pBt, **(**uintptr)(__ccgo_up(bp + 24)), uint8(PTRMAP_ROOTPAGE), uint32(0), iTable, 0) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 24))) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp)) + } + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + **(**int32)(__ccgo_up(bp)) = _btreeGetPage(tls, pBt, **(**TPgno)(__ccgo_up(bp + 16)), bp+24, 0) + _freePage(tls, **(**uintptr)(__ccgo_up(bp + 24)), bp) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 24))) + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp)) + } + **(**int32)(__ccgo_up(piMoved)) = libc.Int32FromUint32(**(**TPgno)(__ccgo_up(bp + 16))) + } + /* Set the new 'max-root-page' value in the database header. This + ** is the old value less one, less one more if that happens to + ** be a root-page number, less one again if that is the + ** PENDING_BYTE_PAGE. + */ + **(**TPgno)(__ccgo_up(bp + 16)) = **(**TPgno)(__ccgo_up(bp + 16)) - 1 + for **(**TPgno)(__ccgo_up(bp + 16)) == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) || _ptrmapPageno(tls, pBt, **(**TPgno)(__ccgo_up(bp + 16))) == **(**TPgno)(__ccgo_up(bp + 16)) { + **(**TPgno)(__ccgo_up(bp + 16)) = **(**TPgno)(__ccgo_up(bp + 16)) - 1 + } + **(**int32)(__ccgo_up(bp)) = _sqlite3BtreeUpdateMeta(tls, p, int32(4), **(**TPgno)(__ccgo_up(bp + 16))) + } else { + _freePage(tls, **(**uintptr)(__ccgo_up(bp + 8)), bp) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Advance the cursor to the next entry in the database. +// ** Return value: +// ** +// ** SQLITE_OK success +// ** SQLITE_DONE cursor is already pointing at the last element +// ** otherwise some kind of error occurred +// ** +// ** The main entry point is sqlite3BtreeNext(). That routine is optimized +// ** for the common case of merely incrementing the cell counter BtCursor.aiIdx +// ** to the next cell on the current page. The (slower) btreeNext() helper +// ** routine is called when it is necessary to move to a different page or +// ** to restore the cursor. +// ** +// ** If bit 0x01 of the F argument in sqlite3BtreeNext(C,F) is 1, then the +// ** cursor corresponds to an SQL index and this routine could have been +// ** skipped if the SQL index had been a unique index. The F argument +// ** is a hint to the implement. SQLite btree implementation does not use +// ** this hint, but COMDB2 does. +// */ +func _btreeNext(tls *libc.TLS, pCur uintptr) (r int32) { + var idx, rc, v1 int32 + var pPage, v3 uintptr + var v2 Tu16 + _, _, _, _, _, _ = idx, pPage, rc, v1, v2, v3 + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) >= int32(CURSOR_REQUIRESEEK) { + v1 = _btreeRestoreCursorPosition(tls, pCur) + } else { + v1 = SQLITE_OK + } + rc = v1 + if rc != SQLITE_OK { + return rc + } + if int32(CURSOR_INVALID) == libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) { + return int32(SQLITE_DONE) + } + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == int32(CURSOR_SKIPNEXT) { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_VALID) + if (*TBtCursor)(unsafe.Pointer(pCur)).FskipNext > 0 { + return SQLITE_OK + } + } + } + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + v3 = pCur + 86 + *(*Tu16)(unsafe.Pointer(v3)) = *(*Tu16)(unsafe.Pointer(v3)) + 1 + v2 = *(*Tu16)(unsafe.Pointer(v3)) + idx = libc.Int32FromUint16(v2) + if _sqlite3FaultSim(tls, int32(412)) != 0 { + (*TMemPage)(unsafe.Pointer(pPage)).FisInit = uint8(0) + } + if !((*TMemPage)(unsafe.Pointer(pPage)).FisInit != 0) { + return _sqlite3CorruptError(tls, int32(79489)) + } + if idx >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + if !((*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0) { + rc = _moveToChild(tls, pCur, _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset)+int32(8)))) + if rc != 0 { + return rc + } + return _moveToLeftmost(tls, pCur) + } + for cond := true; cond; cond = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID) + return int32(SQLITE_DONE) + } + _moveToParent(tls, pCur) + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + } + if (*TMemPage)(unsafe.Pointer(pPage)).FintKey != 0 { + return _sqlite3BtreeNext(tls, pCur, 0) + } else { + return SQLITE_OK + } + } + if (*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { + return SQLITE_OK + } else { + return _moveToLeftmost(tls, pCur) + } + return r +} + +// C documentation +// +// /* +// ** This is common tail processing for btreeParseCellPtr() and +// ** btreeParseCellPtrIndex() for the case when the cell does not fit entirely +// ** on a single B-tree page. Make necessary adjustments to the CellInfo +// ** structure. +// */ +func _btreeParseCellAdjustSizeForOverflow(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) { + var maxLocal, minLocal, surplus int32 + _, _, _ = maxLocal, minLocal, surplus /* Overflow payload available for local storage */ + minLocal = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FminLocal) + maxLocal = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) + surplus = libc.Int32FromUint32(libc.Uint32FromInt32(minLocal) + ((*TCellInfo)(unsafe.Pointer(pInfo)).FnPayload-libc.Uint32FromInt32(minLocal))%((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-uint32(4))) + if surplus <= maxLocal { + (*TCellInfo)(unsafe.Pointer(pInfo)).FnLocal = libc.Uint16FromInt32(surplus) + } else { + (*TCellInfo)(unsafe.Pointer(pInfo)).FnLocal = libc.Uint16FromInt32(minLocal) + } + (*TCellInfo)(unsafe.Pointer(pInfo)).FnSize = libc.Uint16FromInt32(libc.Int32FromUint16(libc.Uint16FromInt64(t__predefined_ptrdiff_t((*TCellInfo)(unsafe.Pointer(pInfo)).FpPayload+uintptr((*TCellInfo)(unsafe.Pointer(pInfo)).FnLocal))-int64(pCell))) + int32(4)) +} + +func _btreeParseCellPtr(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nPayload Tu64 + var pEnd, pIter, v1 uintptr + var x, v2 Tu8 + var _ /* iKey at bp+0 */ Tu64 + _, _, _, _, _, _ = nPayload, pEnd, pIter, x, v1, v2 /* Extracted Key value */ + pIter = pCell + /* The next block of code is equivalent to: + ** + ** pIter += getVarint32(pIter, nPayload); + ** + ** The code is inlined to avoid a function call. + */ + nPayload = uint64(**(**Tu8)(__ccgo_up(pIter))) + if nPayload >= uint64(0x80) { + pEnd = pIter + 8 + nPayload = nPayload & uint64(0x7f) + for cond := true; cond; cond = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pIter))) >= int32(0x80) && pIter < pEnd { + pIter = pIter + 1 + v1 = pIter + nPayload = nPayload<nKey); + ** + ** The code is inlined and the loop is unrolled for performance. + ** This routine is a high-runner. + */ + **(**Tu64)(__ccgo_up(bp)) = uint64(**(**Tu8)(__ccgo_up(pIter))) + if **(**Tu64)(__ccgo_up(bp)) >= uint64(0x80) { + pIter = pIter + 1 + v1 = pIter + v2 = **(**Tu8)(__ccgo_up(v1)) + x = v2 + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))<= int32(0x80) { + pIter = pIter + 1 + v1 = pIter + v2 = **(**Tu8)(__ccgo_up(v1)) + x = v2 + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))<= int32(0x80) { + pIter = pIter + 1 + v1 = pIter + v2 = **(**Tu8)(__ccgo_up(v1)) + x = v2 + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))<= int32(0x80) { + pIter = pIter + 1 + v1 = pIter + v2 = **(**Tu8)(__ccgo_up(v1)) + x = v2 + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))<= int32(0x80) { + pIter = pIter + 1 + v1 = pIter + v2 = **(**Tu8)(__ccgo_up(v1)) + x = v2 + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))<= int32(0x80) { + pIter = pIter + 1 + v1 = pIter + v2 = **(**Tu8)(__ccgo_up(v1)) + x = v2 + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))<= int32(0x80) { + pIter = pIter + 1 + v1 = pIter + v2 = **(**Tu8)(__ccgo_up(v1)) + x = v2 + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))<= int32(0x80) { + pIter = pIter + 1 + v1 = pIter + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))<= uint32(0x80) { + pEnd = pIter + 8 + nPayload = nPayload & uint32(0x7f) + for cond := true; cond; cond = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pIter))) >= int32(0x80) && pIter < pEnd { + pIter = pIter + 1 + v1 = pIter + nPayload = nPayload< table internal nodes +// ** cellSizePtrTableLeaf() => table leaf nodes +// ** cellSizePtr() => index internal nodes +// ** cellSizeIdxLeaf() => index leaf nodes +// */ +func _cellSizePtr(tls *libc.TLS, pPage uintptr, pCell uintptr) (r Tu16) { + var minLocal int32 + var nSize Tu32 + var pEnd, pIter, v1 uintptr + _, _, _, _, _ = minLocal, nSize, pEnd, pIter, v1 + pIter = pCell + uintptr(4) /* Size value to return */ + nSize = uint32(**(**Tu8)(__ccgo_up(pIter))) + if nSize >= uint32(0x80) { + pEnd = pIter + 8 + nSize = nSize & uint32(0x7f) + for cond := true; cond; cond = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pIter))) >= int32(0x80) && pIter < pEnd { + pIter = pIter + 1 + v1 = pIter + nSize = nSize< uint32((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + nSize = libc.Uint32FromInt32(minLocal) + } + nSize = nSize + libc.Uint32FromInt32(int32(4)+libc.Int32FromUint16(libc.Uint16FromInt64(int64(pIter)-int64(pCell)))) + } + return uint16(nSize) +} + +func _cellSizePtrIdxLeaf(tls *libc.TLS, pPage uintptr, pCell uintptr) (r Tu16) { + var minLocal int32 + var nSize Tu32 + var pEnd, pIter, v1 uintptr + _, _, _, _, _ = minLocal, nSize, pEnd, pIter, v1 + pIter = pCell /* Size value to return */ + nSize = uint32(**(**Tu8)(__ccgo_up(pIter))) + if nSize >= uint32(0x80) { + pEnd = pIter + 8 + nSize = nSize & uint32(0x7f) + for cond := true; cond; cond = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pIter))) >= int32(0x80) && pIter < pEnd { + pIter = pIter + 1 + v1 = pIter + nSize = nSize< uint32((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + nSize = libc.Uint32FromInt32(minLocal) + } + nSize = nSize + libc.Uint32FromInt32(int32(4)+libc.Int32FromUint16(libc.Uint16FromInt64(int64(pIter)-int64(pCell)))) + } + return uint16(nSize) +} + +func _cellSizePtrNoPayload(tls *libc.TLS, pPage uintptr, pCell uintptr) (r Tu16) { + var pEnd, pIter, v1 uintptr + _, _, _ = pEnd, pIter, v1 + pIter = pCell + uintptr(4) /* End mark for a varint */ + _ = pPage + pEnd = pIter + uintptr(9) + for { + v1 = pIter + pIter = pIter + 1 + if !(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v1)))&int32(0x80) != 0 && pIter < pEnd) { + break + } + } + return libc.Uint16FromInt64(int64(pIter) - int64(pCell)) +} + +func _cellSizePtrTableLeaf(tls *libc.TLS, pPage uintptr, pCell uintptr) (r Tu16) { + var minLocal int32 + var nSize Tu32 + var pEnd, pIter, v1, v11, v13, v2, v3, v5, v7, v9 uintptr + var v10, v12, v14, v16, v4, v6, v8 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = minLocal, nSize, pEnd, pIter, v1, v10, v11, v12, v13, v14, v16, v2, v3, v4, v5, v6, v7, v8, v9 + pIter = pCell /* Size value to return */ + nSize = uint32(**(**Tu8)(__ccgo_up(pIter))) + if nSize >= uint32(0x80) { + pEnd = pIter + 8 + nSize = nSize & uint32(0x7f) + for cond := true; cond; cond = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pIter))) >= int32(0x80) && pIter < pEnd { + pIter = pIter + 1 + v1 = pIter + nSize = nSize< uint32((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) { + nSize = libc.Uint32FromInt32(minLocal) + } + nSize = nSize + libc.Uint32FromInt32(int32(4)+libc.Int32FromUint16(libc.Uint16FromInt64(int64(pIter)-int64(pCell)))) + } + return uint16(nSize) +} + +// C documentation +// +// /* +// ** The char() function takes zero or more arguments, each of which is +// ** an integer. It constructs a string where each character of the string +// ** is the unicode character for the corresponding integer argument. +// */ +func _charFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var c uint32 + var i int32 + var x Tsqlite3_int64 + var z, zOut, v1 uintptr + _, _, _, _, _, _ = c, i, x, z, zOut, v1 + v1 = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(argc*int32(4)+int32(1))) + z = v1 + zOut = v1 + if z == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + i = 0 + for { + if !(i < argc) { + break + } + x = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if x < 0 || x > int64(0x10ffff) { + x = int64(0xfffd) + } + c = libc.Uint32FromInt64(x & libc.Int64FromInt32(0x1fffff)) + if c < uint32(0x00080) { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c & libc.Uint32FromInt32(0xFF)) + } else { + if c < uint32(0x00800) { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xC0) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } else { + if c < uint32(0x10000) { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xE0) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xF0) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = zOut + zOut = zOut + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } + } + } + goto _2 + _2: + ; + i = i + 1 + } + **(**uint8)(__ccgo_up(zOut)) = uint8(0) + Xsqlite3_result_text64(tls, context, z, libc.Uint64FromInt64(int64(zOut)-int64(z)), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) +} + +// C documentation +// +// /* This is the Walker callback from sqlite3ExprReferencesUpdatedColumn(). +// * Set bit 0x01 of pWalker->eCode if pWalker->eCode to 0 and if this +// ** expression node references any of the +// ** columns that are being modified by an UPDATE statement. +// */ +func _checkConstraintExprNode(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) { + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 { + if **(**int32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pWalker + 40)) + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiColumn)*4)) >= 0 { + v1 = pWalker + 36 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(CKCNSTRNT_COLUMN)) + } + } else { + v1 = pWalker + 36 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(CKCNSTRNT_ROWID)) + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Free the overflow pages associated with the given Cell. +// */ +func _clearCellOverflow(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nOvfl, rc, v1 int32 + var ovflPageSize Tu32 + var ovflPgno TPgno + var pBt, v2 uintptr + var v3 bool + var _ /* iNext at bp+0 */ TPgno + var _ /* pOvfl at bp+8 */ uintptr + _, _, _, _, _, _, _, _ = nOvfl, ovflPageSize, ovflPgno, pBt, rc, v1, v2, v3 + if pCell+uintptr((*TCellInfo)(unsafe.Pointer(pInfo)).FnSize) > (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd { + /* Cell extends past end of page */ + return _sqlite3CorruptError(tls, int32(80130)) + } + ovflPgno = _sqlite3Get4byte(tls, pCell+uintptr((*TCellInfo)(unsafe.Pointer(pInfo)).FnSize)-uintptr(4)) + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt + ovflPageSize = (*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32(4) + nOvfl = libc.Int32FromUint32(((*TCellInfo)(unsafe.Pointer(pInfo)).FnPayload - uint32((*TCellInfo)(unsafe.Pointer(pInfo)).FnLocal) + ovflPageSize - uint32(1)) / ovflPageSize) + for { + v1 = nOvfl + nOvfl = nOvfl - 1 + if !(v1 != 0) { + break + } + **(**TPgno)(__ccgo_up(bp)) = uint32(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if ovflPgno < uint32(2) || ovflPgno > _btreePagecount(tls, pBt) { + /* 0 is not a legal page number and page 1 cannot be an + ** overflow page. Therefore if ovflPgno<2 or past the end of the + ** file the database must be corrupt. */ + return _sqlite3CorruptError(tls, int32(80147)) + } + if nOvfl != 0 { + rc = _getOverflowPage(tls, pBt, ovflPgno, bp+8, bp) + if rc != 0 { + return rc + } + } + if v3 = **(**uintptr)(__ccgo_up(bp + 8)) != 0; !v3 { + v2 = _btreePageLookup(tls, pBt, ovflPgno) + **(**uintptr)(__ccgo_up(bp + 8)) = v2 + } + if (v3 || v2 != uintptr(0)) && _sqlite3PagerPageRefcount(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) != int32(1) { + /* There is no reason any cursor should have an outstanding reference + ** to an overflow page belonging to a cell that is being deleted/updated. + ** So if there exists more than one reference to this page, then it + ** must not really be an overflow page and the database must be corrupt. + ** It is helpful to detect this before calling freePage2(), as + ** freePage2() may zero the page contents if secure-delete mode is + ** enabled. If this 'overflow' page happens to be a page that the + ** caller is iterating through or using in some other way, this + ** can be problematic. + */ + rc = _sqlite3CorruptError(tls, int32(80167)) + } else { + rc = _freePage2(tls, pBt, **(**uintptr)(__ccgo_up(bp + 8)), ovflPgno) + } + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _sqlite3PagerUnref(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDbPage) + } + if rc != 0 { + return rc + } + ovflPgno = **(**TPgno)(__ccgo_up(bp)) + } + return SQLITE_OK +} + +/* Call xParseCell to compute the size of a cell. If the cell contains +** overflow, then invoke cellClearOverflow to clear out that overflow. +** Store the result code (SQLITE_OK or some error code) in rc. +** +** Implemented as macro to force inlining for performance. + */ + +// C documentation +// +// /* +// ** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains +// ** a rowid value just read from cursor iIdxCur, open on index pIdx. This +// ** function generates code to do a deferred seek of cursor iCur to the +// ** rowid stored in register iRowid. +// ** +// ** Normally, this is just: +// ** +// ** OP_DeferredSeek $iCur $iRowid +// ** +// ** Which causes a seek on $iCur to the row with rowid $iRowid. +// ** +// ** However, if the scan currently being coded is a branch of an OR-loop and +// ** the statement currently being coded is a SELECT, then additional information +// ** is added that might allow OP_Column to omit the seek and instead do its +// ** lookup on the index, thus avoiding an expensive seek operation. To +// ** enable this optimization, the P3 of OP_DeferredSeek is set to iIdxCur +// ** and P4 is set to an array of integers containing one entry for each column +// ** in the table. For each table column, if the column is the i'th +// ** column of the index, then the corresponding array entry is set to (i+1). +// ** If the column does not appear in the index at all, the array entry is set +// ** to 0. The OP_Column opcode can check this array to see if the column it +// ** wants is in the index and if it is, it will substitute the index cursor +// ** and column number and continue with those new values, rather than seeking +// ** the table cursor. +// */ +func _codeDeferredSeek(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iCur int32, iIdxCur int32) { + var ai, pParse, pTab, v, v1 uintptr + var i, x1, x2 int32 + var v2 bool + _, _, _, _, _, _, _, _, _ = ai, i, pParse, pTab, v, x1, x2, v1, v2 + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parse context */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Vdbe to generate code within */ + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 0, 0x1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_DeferredSeek), iIdxCur, 0, iCur) + if v2 = libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(libc.Int32FromInt32(WHERE_OR_SUBCLAUSE)|libc.Int32FromInt32(WHERE_RIGHT_JOIN)) != 0; v2 { + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + } + if v2 && (*TParse)(unsafe.Pointer(v1)).FwriteMask == uint32(0) { + pTab = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + ai = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(4)*libc.Uint64FromInt32(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+libc.Int32FromInt32(1)))) + if ai != 0 { + **(**Tu32)(__ccgo_up(ai)) = libc.Uint32FromInt16((*TTable)(unsafe.Pointer(pTab)).FnCol) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)-int32(1)) { + break + } + x1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) + x2 = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(x1))) + if x1 >= 0 { + **(**Tu32)(__ccgo_up(ai + uintptr(x2+int32(1))*4)) = libc.Uint32FromInt32(i + int32(1)) + } + goto _3 + _3: + ; + i = i + 1 + } + _sqlite3VdbeChangeP4(tls, v, -int32(1), ai, -int32(15)) + } + } +} + +// C documentation +// +// /* +// ** Generate code for a single X IN (....) term of the WHERE clause. +// ** +// ** This is a special-case of codeEqualityTerm() that works for IN operators +// ** only. It is broken out into a subroutine because this case is +// ** uncommon and by splitting it off into a subroutine, the common case +// ** runs faster. +// ** +// ** The current value for the constraint is left in register iTarget. +// ** This routine sets up a loop that will iterate over all values of X. +// */ +func _codeINTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintptr, iEq int32, bRev int32, iTarget int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aiMap, db, pIn, pLoop, pX, pXMod, v uintptr + var eType, i, iCol, iMap, iOut, nEq, v3, v5 int32 + var _ /* iTab at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aiMap, db, eType, i, iCol, iMap, iOut, nEq, pIn, pLoop, pX, pXMod, v, v3, v5 + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + eType = int32(IN_INDEX_NOOP) + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + nEq = 0 + aiMap = uintptr(0) + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_VIRTUALTABLE) == uint32(0) && (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex != uintptr(0) && **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex)).FaSortOrder + uintptr(iEq))) != 0 { + bRev = libc.BoolInt32(!(bRev != 0)) + } + i = 0 + for { + if !(i < iEq) { + break + } + if **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)) != 0 && (*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)))).FpExpr == pX { + _disableTerm(tls, pLevel, pTerm) + return + } + goto _1 + _1: + ; + i = i + 1 + } + i = iEq + for { + if !(i < libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm)) { + break + } + if (*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)))).FpExpr == pX { + nEq = nEq + 1 + } + goto _2 + _2: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(bp)) = 0 + if !((*TExpr)(unsafe.Pointer(pX)).Fflags&libc.Uint32FromInt32(EP_xIsSelect) != libc.Uint32FromInt32(0)) || (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32)))).FpEList)).FnExpr == int32(1) { + eType = _sqlite3FindInIndex(tls, pParse, pX, uint32(IN_INDEX_LOOP), uintptr(0), uintptr(0), bp) + } else { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pXMod = _removeUnindexableInClauseTerms(tls, pParse, iEq, pLoop, pX) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + aiMap = _sqlite3DbMallocZero(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(nEq))) + eType = _sqlite3FindInIndex(tls, pParse, pXMod, uint32(IN_INDEX_LOOP), uintptr(0), aiMap, bp) + } + _sqlite3ExprDelete(tls, db, pXMod) + } + if eType == int32(IN_INDEX_INDEX_DESC) { + bRev = libc.BoolInt32(!(bRev != 0)) + } + if bRev != 0 { + v3 = int32(OP_Last) + } else { + v3 = int32(OP_Rewind) + } + _sqlite3VdbeAddOp2(tls, v, v3, **(**int32)(__ccgo_up(bp)), 0) + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_IN_ABLE) + if (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn == 0 { + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt = _sqlite3VdbeMakeLabel(tls, pParse) + } + if iEq > 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IN_SEEKSCAN) == uint32(0) { + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_IN_EARLYOUT) + } + i = (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn + (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn += nEq + (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FaInLoop = _sqlite3WhereRealloc(tls, (*TWhereClause)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpWC)).FpWInfo, (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FaInLoop, uint64(uint64(20)*libc.Uint64FromInt32((*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn))) + pIn = (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FaInLoop + if pIn != 0 { + iMap = 0 /* Index in aiMap[] */ + pIn = pIn + uintptr(i)*20 + i = iEq + for { + if !(i < libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm)) { + break + } + if (*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)))).FpExpr == pX { + iOut = iTarget + i - iEq + if eType == int32(IN_INDEX_ROWID) { + (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), **(**int32)(__ccgo_up(bp)), iOut) + } else { + if aiMap != 0 { + v5 = iMap + iMap = iMap + 1 + v3 = **(**int32)(__ccgo_up(aiMap + uintptr(v5)*4)) + } else { + v3 = 0 + } + iCol = v3 + (*TInLoop)(unsafe.Pointer(pIn)).FaddrInTop = _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp)), iCol, iOut) + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), iOut) + if i == iEq { + (*TInLoop)(unsafe.Pointer(pIn)).FiCur = **(**int32)(__ccgo_up(bp)) + if bRev != 0 { + v3 = int32(OP_Prev) + } else { + v3 = int32(OP_Next) + } + (*TInLoop)(unsafe.Pointer(pIn)).FeEndLoopOp = libc.Uint8FromInt32(v3) + if iEq > 0 { + (*TInLoop)(unsafe.Pointer(pIn)).FiBase = iTarget - i + (*TInLoop)(unsafe.Pointer(pIn)).FnPrefix = i + } else { + (*TInLoop)(unsafe.Pointer(pIn)).FnPrefix = 0 + } + } else { + (*TInLoop)(unsafe.Pointer(pIn)).FeEndLoopOp = uint8(OP_Noop) + } + pIn += 20 + } + goto _4 + _4: + ; + i = i + 1 + } + if iEq > 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IN_SEEKSCAN)|libc.Int32FromInt32(WHERE_VIRTUALTABLE)) == uint32(0) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekHit), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, 0, iEq) + } + } else { + (*(*struct { + FnIn int32 + FaInLoop uintptr + })(unsafe.Pointer(pLevel + 80))).FnIn = 0 + } + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, aiMap) +} + +// C documentation +// +// /* +// ** Code an OP_TableLock instruction for each table locked by the +// ** statement (configured by calls to sqlite3TableLock()). +// */ +func _codeTableLocks(tls *libc.TLS, pParse uintptr) { + var i, p1 int32 + var p, pVdbe uintptr + _, _, _, _ = i, p, p1, pVdbe + pVdbe = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + i = 0 + for { + if !(i < (*TParse)(unsafe.Pointer(pParse)).FnTableLock) { + break + } + p = (*TParse)(unsafe.Pointer(pParse)).FaTableLock + uintptr(i)*24 + p1 = (*TTableLock)(unsafe.Pointer(p)).FiDb + _sqlite3VdbeAddOp4(tls, pVdbe, int32(OP_TableLock), p1, libc.Int32FromUint32((*TTableLock)(unsafe.Pointer(p)).FiTab), libc.Int32FromUint8((*TTableLock)(unsafe.Pointer(p)).FisWriteLock), (*TTableLock)(unsafe.Pointer(p)).FzLockName, -int32(1)) + goto _1 + _1: + ; + i = i + 1 + } +} + +/* +** Return TRUE if the given yDbMask object is empty - if it contains no +** 1 bits. This routine is used by the DbMaskAllZero() and DbMaskNotZero() +** macros when SQLITE_MAX_ATTACHED is greater than 30. + */ + +// C documentation +// +// /* +// ** Return true if any column of pIndex uses the zColl collation +// */ +func _collationMatch(tls *libc.TLS, zColl uintptr, pIndex uintptr) (r int32) { + var i int32 + var z uintptr + _, _ = i, z + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnColumn)) { + break + } + z = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) + if 0 == _sqlite3StrICmp(tls, z, zColl) { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Return true if column iCol of table pTab seem like it might be a +// ** good column to use as part of a query-time index. +// ** +// ** Current algorithm (subject to improvement!): +// ** +// ** 1. If iCol is already the left-most column of some other index, +// ** then return false. +// ** +// ** 2. If iCol is part of an existing index that has an aiRowLogEst of +// ** more than 20, then return false. +// ** +// ** 3. If no disqualifying conditions above are found, return true. +// ** +// ** 2025-01-03: I experimented with a new rule that returns false if the +// ** the datatype of the column is "BOOLEAN". This did not improve +// ** performance on any queries at hand, but it did burn CPU cycles, so the +// ** idea was not committed. +// */ +func _columnIsGoodIndexCandidate(tls *libc.TLS, pTab uintptr, iCol int32) (r int32) { + var j int32 + var pIdx uintptr + _, _ = j, pIdx + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != uintptr(0)) { + break + } + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) == iCol { + if j == 0 { + return 0 + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x80>>7)) != 0 && int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiRowLogEst + uintptr(j+int32(1))*2))) > int32(20) { + return 0 + } + break + } + goto _2 + _2: + ; + j = j + 1 + } + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + return int32(1) +} + +// C documentation +// +// /* +// ** Check to see if column iCol of the given statement is valid. If +// ** it is, return a pointer to the Mem for the value of that column. +// ** If iCol is not valid, return a pointer to a Mem which has a value +// ** of NULL. +// */ +func _columnMem(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) { + var pOut, pVm uintptr + _, _ = pOut, pVm + pVm = pStmt + if pVm == uintptr(0) { + return _columnNullValue(tls) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(pVm)).Fdb)).Fmutex) + if (*TVdbe)(unsafe.Pointer(pVm)).FpResultRow != uintptr(0) && i < libc.Int32FromUint16((*TVdbe)(unsafe.Pointer(pVm)).FnResColumn) && i >= 0 { + pOut = (*TVdbe)(unsafe.Pointer(pVm)).FpResultRow + uintptr(i)*56 + } else { + _sqlite3Error(tls, (*TVdbe)(unsafe.Pointer(pVm)).Fdb, int32(SQLITE_RANGE)) + pOut = _columnNullValue(tls) + } + return pOut +} + +// C documentation +// +// /* +// ** Convert the N-th element of pStmt->pColName[] into a string using +// ** xFunc() then return that string. If N is out of range, return 0. +// ** +// ** There are up to 5 names for each column. useType determines which +// ** name is returned. Here are the names: +// ** +// ** 0 The column name as it should be displayed for output +// ** 1 The datatype name for the column +// ** 2 The name of the database that the column derives from +// ** 3 The name of the table that the column derives from +// ** 4 The name of the table column that the result column derives from +// ** +// ** If the result is not a simple column reference (if it is an expression +// ** or a constant) then useTypes 2, 3, and 4 return NULL. +// */ +func _columnName(tls *libc.TLS, pStmt uintptr, N int32, useUtf16 int32, useType int32) (r uintptr) { + var db, p, ret uintptr + var i, n, v1 int32 + var prior_mallocFailed Tu8 + _, _, _, _, _, _, _ = db, i, n, p, prior_mallocFailed, ret, v1 + if N < 0 { + return uintptr(0) + } + ret = uintptr(0) + p = pStmt + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2)) != 0 { + if useType > 0 { + goto columnName_end + } + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2)) == int32(1) { + v1 = int32(8) + } else { + v1 = int32(4) + } + n = v1 + if N >= n { + goto columnName_end + } + if useUtf16 != 0 { + i = libc.Int32FromUint8(_iExplainColNames16[N+int32(8)*int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2))-int32(8)]) + ret = uintptr(unsafe.Pointer(&_azExplainColNames16data)) + uintptr(i)*2 + } else { + ret = _azExplainColNames8[N+int32(8)*int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2))-int32(8)] + } + goto columnName_end + } + n = libc.Int32FromUint16((*TVdbe)(unsafe.Pointer(p)).FnResColumn) + if N < n { + prior_mallocFailed = (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed + N = N + useType*n + if useUtf16 != 0 { + ret = Xsqlite3_value_text16(tls, (*TVdbe)(unsafe.Pointer(p)).FaColName+uintptr(N)*56) + } else { + ret = Xsqlite3_value_text(tls, (*TVdbe)(unsafe.Pointer(p)).FaColName+uintptr(N)*56) + } + /* A malloc may have failed inside of the _text() call. If this + ** is the case, clear the mallocFailed flag and return NULL. + */ + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) > libc.Int32FromUint8(prior_mallocFailed) { + _sqlite3OomClear(tls, db) + ret = uintptr(0) + } + } + goto columnName_end +columnName_end: + ; + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return ret +} + +// C documentation +// +// /* +// ** Compute the iLimit and iOffset fields of the SELECT based on the +// ** pLimit expressions. pLimit->pLeft and pLimit->pRight hold the expressions +// ** that appear in the original SQL statement after the LIMIT and OFFSET +// ** keywords. Or NULL if those keywords are omitted. iLimit and iOffset +// ** are the integer memory register numbers for counters used to compute +// ** the limit and offset. If there is no limit and/or offset, then +// ** iLimit and iOffset are negative. +// ** +// ** This routine changes the values of iLimit and iOffset only if +// ** a limit or offset is defined by pLimit->pLeft and pLimit->pRight. iLimit +// ** and iOffset should have been preset to appropriate default values (zero) +// ** prior to calling this routine. +// ** +// ** The iOffset register (if it exists) is initialized to the value +// ** of the OFFSET. The iLimit register is initialized to LIMIT. Register +// ** iOffset+1 is initialized to LIMIT+OFFSET. +// ** +// ** Only if pLimit->pLeft!=0 do the limit registers get +// ** redefined. The UNION ALL operator uses this property to force +// ** the reuse of the same limit and offset registers across multiple +// ** SELECT statements. +// */ +func _computeLimitRegisters(tls *libc.TLS, pParse uintptr, p uintptr, iBreak int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iLimit, iOffset, v1, v2 int32 + var pLimit, v, v3 uintptr + var _ /* n at bp+0 */ int32 + _, _, _, _, _, _, _ = iLimit, iOffset, pLimit, v, v1, v2, v3 + v = uintptr(0) + iLimit = 0 + pLimit = (*TSelect)(unsafe.Pointer(p)).FpLimit + if (*TSelect)(unsafe.Pointer(p)).FiLimit != 0 { + return + } + /* + ** "LIMIT -1" always shows all rows. There is some + ** controversy about what the correct behavior should be. + ** The current implementation interprets "LIMIT 0" to mean + ** no rows. + */ + if pLimit != 0 { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v2 = *(*int32)(unsafe.Pointer(v3)) + v1 = v2 + iLimit = v1 + (*TSelect)(unsafe.Pointer(p)).FiLimit = v1 + v = _sqlite3GetVdbe(tls, pParse) + if _sqlite3ExprIsInteger(tls, (*TExpr)(unsafe.Pointer(pLimit)).FpLeft, bp, pParse) != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp)), iLimit) + if **(**int32)(__ccgo_up(bp)) == 0 { + _sqlite3VdbeGoto(tls, v, iBreak) + } else { + if **(**int32)(__ccgo_up(bp)) >= 0 && int32((*TSelect)(unsafe.Pointer(p)).FnSelectRow) > int32(_sqlite3LogEst(tls, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))))) { + (*TSelect)(unsafe.Pointer(p)).FnSelectRow = _sqlite3LogEst(tls, libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp)))) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_FixedLimit) + } + } + } else { + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pLimit)).FpLeft, iLimit) + _sqlite3VdbeAddOp1(tls, v, int32(OP_MustBeInt), iLimit) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfNot), iLimit, iBreak) + } + if (*TExpr)(unsafe.Pointer(pLimit)).FpRight != 0 { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v2 = *(*int32)(unsafe.Pointer(v3)) + v1 = v2 + iOffset = v1 + (*TSelect)(unsafe.Pointer(p)).FiOffset = v1 + (*TParse)(unsafe.Pointer(pParse)).FnMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + 1 /* Allocate an extra register for limit+offset */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pLimit)).FpRight, iOffset) + _sqlite3VdbeAddOp1(tls, v, int32(OP_MustBeInt), iOffset) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OffsetLimit), iLimit, iOffset+int32(1), iOffset) + } + } +} + +// C documentation +// +// /* +// ** Compute the maximum number of paths in the solver algorithm, for +// ** queries that have three or more terms in the FROM clause. Queries with +// ** two or fewer FROM clause terms are handled by the caller. +// ** +// ** Query planning is NP-hard. We must limit the number of paths at +// ** each step of the solver search algorithm to avoid exponential behavior. +// ** +// ** The value returned is a tuning parameter. Currently the value is: +// ** +// ** 18 for star queries +// ** 12 otherwise +// ** +// ** For the purposes of this heuristic, a star-query is defined as a query +// ** with a central "fact" table that is joined against multiple +// ** "dimension" tables, subject to the following constraints: +// ** +// ** (aa) Only a five-way or larger join is considered for this +// ** optimization. If there are fewer than four terms in the FROM +// ** clause, this heuristic does not apply. +// ** +// ** (bb) The join between the fact table and the dimension tables must +// ** be an INNER join. CROSS and OUTER JOINs do not qualify. +// ** +// ** (cc) A table must have 3 or more dimension tables in order to be +// ** considered a fact table. (Was 4 prior to 2026-02-10.) +// ** +// ** (dd) A table that is a self-join cannot be a dimension table. +// ** Dimension tables are joined against fact tables. +// ** +// ** SIDE EFFECT: (and really the whole point of this subroutine) +// ** +// ** If pWInfo describes a star-query, then the cost for SCANs of dimension +// ** WhereLoops is increased to be slightly larger than the cost of a SCAN +// ** in the fact table. Only SCAN costs are increased. SEARCH costs are +// ** unchanged. This heuristic helps keep fact tables in outer loops. Without +// ** this heuristic, paths with fact tables in outer loops tend to get pruned +// ** by the mxChoice limit on the number of paths, resulting in poor query +// ** plans. See the starschema1.test test module for examples of queries +// ** that need this heuristic to find good query plans. +// ** +// ** This heuristic can be completely disabled, so that no query is +// ** considered a star-query, using SQLITE_TESTCTRL_OPTIMIZATION to +// ** disable the SQLITE_StarQuery optimization. In the CLI, the command +// ** to do that is: ".testctrl opt -starquery". +// ** +// ** HISTORICAL NOTES: +// ** +// ** This optimization was first added on 2024-05-09 by check-in 38db9b5c83d. +// ** The original optimization reduced the cost and output size estimate for +// ** fact tables to help them move to outer loops. But months later (as people +// ** started upgrading) performance regression reports started caming in, +// ** including: +// ** +// ** forum post b18ef983e68d06d1 (2024-12-21) +// ** forum post 0025389d0860af82 (2025-01-14) +// ** forum post d87570a145599033 (2025-01-17) +// ** +// ** To address these, the criteria for a star-query was tightened to exclude +// ** cases where the fact and dimensions are separated by an outer join, and +// ** the affect of star-schema detection was changed to increase the rRun cost +// ** on just full table scans of dimension tables, rather than reducing costs +// ** in the all access methods of the fact table. +// */ +func _computeMxChoice(tls *libc.TLS, pWInfo uintptr) (r int32) { + var aFromTabs, pFactTab, pStart, pWLoop uintptr + var iFromIdx, nDep, nLoop, v5 int32 + var m, mSeen, mSelfJoin TBitmask + var mxRun TLogEst + _, _, _, _, _, _, _, _, _, _, _, _ = aFromTabs, iFromIdx, m, mSeen, mSelfJoin, mxRun, nDep, nLoop, pFactTab, pStart, pWLoop, v5 + nLoop = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) /* For looping over WhereLoops */ + if nLoop >= int32(4) && !(int32(uint32(*(*uint8)(unsafe.Pointer(pWInfo + 68))&0x10>>4)) != 0) && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_StarQuery)) == uint32(0) { /* Bitmask for candidate fact-table */ + mSelfJoin = uint64(0) /* Where to start searching for dimension-tables */ + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 4, 0x10) /* Only do this computation once */ + /* Look for fact tables with three or more dimensions where the + ** dimension tables are not separately from the fact tables by an outer + ** or cross join. Adjust cost weights if found. + */ + aFromTabs = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + pStart = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops + iFromIdx = 0 + m = libc.Uint64FromInt32(1) + for { + if !(iFromIdx < nLoop) { + break + } + nDep = 0 /* Maximum SCAN cost of a fact table */ + mSeen = uint64(0) /* The candidate fact table */ + pFactTab = aFromTabs + uintptr(iFromIdx)*80 + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pFactTab)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)) != 0 { + /* If the candidate fact-table is the right table of an outer join + ** restrict the search for dimension-tables to be tables to the right + ** of the fact-table. Constraint (bb) */ + if iFromIdx+int32(3) > nLoop { + break /* ^-- Impossible to reach nDep>=2 - Constraint (cc) */ + } + for pStart != 0 && libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(pStart)).FiTab) <= iFromIdx { + pStart = (*TWhereLoop)(unsafe.Pointer(pStart)).FpNextLoop + } + } + pWLoop = pStart + for { + if !(pWLoop != 0) { + break + } + if libc.Int32FromUint8((**(**TSrcItem)(__ccgo_up(aFromTabs + uintptr((*TWhereLoop)(unsafe.Pointer(pWLoop)).FiTab)*80))).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)) != 0 { + break /* Constraint (bb) */ + } + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).Fprereq&m != uint64(0) && (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf&mSeen == uint64(0) && (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf&mSelfJoin == uint64(0) { + if (**(**TSrcItem)(__ccgo_up(aFromTabs + uintptr((*TWhereLoop)(unsafe.Pointer(pWLoop)).FiTab)*80))).FpSTab == (*TSrcItem)(unsafe.Pointer(pFactTab)).FpSTab { + mSelfJoin = mSelfJoin | m + } else { + nDep = nDep + 1 + mSeen = mSeen | (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf + } + } + goto _2 + _2: + ; + pWLoop = (*TWhereLoop)(unsafe.Pointer(pWLoop)).FpNextLoop + } + if nDep <= int32(2) { + goto _1 /* Constraint (cc) */ + } + /* If we reach this point, it means that pFactTab is a fact table + ** with four or more dimensions connected by inner joins. Proceed + ** to make cost adjustments. */ + libc.SetBitFieldPtr8Uint32(pWInfo+68, libc.Uint32FromInt32(1), 5, 0x20) + /* Compute the maximum cost of any WhereLoop for the + ** fact table plus one epsilon */ + mxRun = int16(-libc.Int32FromInt32(32768)) + pWLoop = pStart + for { + if !(pWLoop != 0) { + break + } + if libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(pWLoop)).FiTab) < iFromIdx { + goto _3 + } + if libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(pWLoop)).FiTab) > iFromIdx { + break + } + if int32((*TWhereLoop)(unsafe.Pointer(pWLoop)).FrRun) > int32(mxRun) { + mxRun = (*TWhereLoop)(unsafe.Pointer(pWLoop)).FrRun + } + goto _3 + _3: + ; + pWLoop = (*TWhereLoop)(unsafe.Pointer(pWLoop)).FpNextLoop + } + if int32(mxRun) < int32(LOGEST_MAX) { + mxRun = mxRun + 1 + } + /* Increase the cost of table scans for dimension tables to be + ** slightly more than the maximum cost of the fact table */ + pWLoop = pStart + for { + if !(pWLoop != 0) { + break + } + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf&mSeen == uint64(0) { + goto _4 + } + if (*TWhereLoop)(unsafe.Pointer(pWLoop)).FnLTerm != 0 { + goto _4 + } + if int32((*TWhereLoop)(unsafe.Pointer(pWLoop)).FrRun) < int32(mxRun) { + (*TWhereLoop)(unsafe.Pointer(pWLoop)).FrRun = mxRun + } + goto _4 + _4: + ; + pWLoop = (*TWhereLoop)(unsafe.Pointer(pWLoop)).FpNextLoop + } + goto _1 + _1: + ; + iFromIdx = iFromIdx + 1 + m = m << uint64(1) + } + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pWInfo + 68))&0x20>>5)) != 0 { + v5 = int32(18) + } else { + v5 = int32(12) + } + return v5 +} + +// C documentation +// +// /* +// ** We know that pSrc is an operand of an outer join. Return true if +// ** pTerm is a constraint that is compatible with that join. +// ** +// ** pTerm must be EP_OuterON if pSrc is the right operand of an +// ** outer join. pTerm can be either EP_OuterON or EP_InnerON if pSrc +// ** is the left operand of a RIGHT join. +// ** +// ** See https://sqlite.org/forum/forumpost/206d99a16dd9212f +// ** for an example of a WHERE clause constraints that may not be used on +// ** the right table of a RIGHT JOIN because the constraint implies a +// ** not-NULL condition on the left table of the RIGHT JOIN. +// */ +func _constraintCompatibleWithOuterJoin(tls *libc.TLS, pTerm uintptr, pSrc uintptr) (r int32) { + /* By caller */ + if !((*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != libc.Uint32FromInt32(0)) || *(*int32)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + 52)) != (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { + return 0 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_RIGHT)) != 0 && (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + return 0 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Allocate nByte bytes of space using sqlite3Malloc(). If the +// ** allocation fails, call sqlite3_result_error_nomem() to notify +// ** the database handle that malloc() has failed and return NULL. +// ** If nByte is larger than the maximum string or blob length, then +// ** raise an SQLITE_TOOBIG exception and return NULL. +// */ +func _contextMalloc(tls *libc.TLS, context uintptr, nByte Ti64) (r uintptr) { + var db, z uintptr + _, _ = db, z + db = Xsqlite3_context_db_handle(tls, context) + if nByte > int64(**(**int32)(__ccgo_up(db + 136))) { + Xsqlite3_result_error_toobig(tls, context) + z = uintptr(0) + } else { + z = _sqlite3Malloc(tls, libc.Uint64FromInt64(nByte)) + if !(z != 0) { + Xsqlite3_result_error_nomem(tls, context) + } + } + return z +} + +// C documentation +// +// /* +// ** This routine runs at the end of parsing a CREATE TABLE statement that +// ** has a WITHOUT ROWID clause. The job of this routine is to convert both +// ** internal schema data structures and the generated VDBE code so that they +// ** are appropriate for a WITHOUT ROWID table instead of a rowid table. +// ** Changes include: +// ** +// ** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL. +// ** (2) Convert P3 parameter of the OP_CreateBtree from BTREE_INTKEY +// ** into BTREE_BLOBKEY. +// ** (3) Bypass the creation of the sqlite_schema table entry +// ** for the PRIMARY KEY as the primary key index is now +// ** identified by the sqlite_schema table entry of the table itself. +// ** (4) Set the Index.tnum of the PRIMARY KEY Index object in the +// ** schema to the rootpage from the main table. +// ** (5) Add all table columns to the PRIMARY KEY Index object +// ** so that the PRIMARY KEY is a covering index. The surplus +// ** columns are part of KeyInfo.nAllField and are not used for +// ** sorting or lookup or uniqueness checks. +// ** (6) Replace the rowid tail on all automatically generated UNIQUE +// ** indices with the PRIMARY KEY columns. +// ** +// ** For virtual tables, only (1) is performed. +// */ +func _convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pIdx, pList, pPk, v, zColl, v12 uintptr + var i, j, n, nExtra, nPk, v3 int32 + var v5 Tu16 + var _ /* ipkToken at bp+0 */ TToken + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, j, n, nExtra, nPk, pIdx, pList, pPk, v, zColl, v12, v3, v5 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables) + */ + if !(int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x6>>1)) != 0) { + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + 8))&0xf>>0)) == OE_None { + libc.SetBitFieldPtr8Uint32((*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16+8, libc.Uint32FromInt32(OE_Abort), 0, 0xf) + } + goto _1 + _1: + ; + i = i + 1 + } + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_HasNotNull) + } + /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY + ** into BTREE_BLOBKEY. + */ + if (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FaddrCrTab != 0 { + _sqlite3VdbeChangeP3(tls, v, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FaddrCrTab, int32(BTREE_BLOBKEY)) + } + /* Locate the PRIMARY KEY index. Or, if this table was originally + ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index. + */ + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) >= 0 { + _sqlite3TokenInit(tls, bp, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TTable)(unsafe.Pointer(pTab)).FiPKey)*16))).FzCnName) + pList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp, 0)) + if pList == uintptr(0) { + **(**Tu32)(__ccgo_up(pTab + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(TF_WithoutRowid)) + return + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8))).FpExpr, pTab+52) + } + (*(*TExprList_item)(unsafe.Pointer(pList + 8))).Ffg.FsortFlags = (*TParse)(unsafe.Pointer(pParse)).FiPkSortOrder + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(-int32(1)) + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FkeyConf), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_PRIMARYKEY)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + **(**Tu32)(__ccgo_up(pTab + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(TF_WithoutRowid)) + return + } + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + /* + ** Remove all redundant columns from the PRIMARY KEY. For example, change + ** "PRIMARY KEY(a,b,a,b,c,b,c,d)" into just "PRIMARY KEY(a,b,c,d)". Later + ** code assumes the PRIMARY KEY contains no repeated columns. + */ + v3 = libc.Int32FromInt32(1) + j = v3 + i = v3 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + if _isDupColumn(tls, pPk, j, pPk, i) != 0 { + (*TIndex)(unsafe.Pointer(pPk)).FnColumn = (*TIndex)(unsafe.Pointer(pPk)).FnColumn - 1 + } else { + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(i)*8)) + **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(j))) = **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(i))) + v3 = j + j = j + 1 + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(v3)*2)) = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)) + } + goto _2 + _2: + ; + i = i + 1 + } + (*TIndex)(unsafe.Pointer(pPk)).FnKeyCol = libc.Uint16FromInt32(j) + } + libc.SetBitFieldPtr16Uint32(pPk+100, libc.Uint32FromInt32(1), 5, 0x20) + if !(int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x6>>1)) != 0) { + libc.SetBitFieldPtr16Uint32(pPk+100, libc.Uint32FromInt32(1), 3, 0x8) + } + v5 = (*TIndex)(unsafe.Pointer(pPk)).FnKeyCol + (*TIndex)(unsafe.Pointer(pPk)).FnColumn = v5 + nPk = libc.Int32FromUint16(v5) + /* Bypass the creation of the PRIMARY KEY btree and the sqlite_schema + ** table entry. This is only required if currently generating VDBE + ** code for a CREATE TABLE (not when parsing one as part of reading + ** a database schema). */ + if v != 0 && (*TIndex)(unsafe.Pointer(pPk)).Ftnum > uint32(0) { + _sqlite3VdbeChangeOpcode(tls, v, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pPk)).Ftnum), uint8(OP_Goto)) + } + /* The root page of the PRIMARY KEY is the table root page */ + (*TIndex)(unsafe.Pointer(pPk)).Ftnum = (*TTable)(unsafe.Pointer(pTab)).Ftnum + /* Update the in-memory representation of all UNIQUE indices by converting + ** the final rowid column into one or more columns of the PRIMARY KEY. + */ + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + goto _6 + } + v3 = libc.Int32FromInt32(0) + n = v3 + i = v3 + for { + if !(i < nPk) { + break + } + if !(_isDupColumn(tls, pIdx, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol), pPk, i) != 0) { + n = n + 1 + } + goto _7 + _7: + ; + i = i + 1 + } + if n == 0 { + /* This index is a superset of the primary key */ + (*TIndex)(unsafe.Pointer(pIdx)).FnColumn = (*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol + goto _6 + } + if _resizeIndexObject(tls, pParse, pIdx, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)+n) != 0 { + return + } + i = 0 + j = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + for { + if !(i < nPk) { + break + } + if !(_isDupColumn(tls, pIdx, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol), pPk, i) != 0) { + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2)) = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)) + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(i)*8)) + if **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(i))) != 0 { + /* See ticket https://sqlite.org/src/info/bba7b69f9849b5bf */ + libc.SetBitFieldPtr16Uint32(pIdx+100, libc.Uint32FromInt32(1), 9, 0x200) + } + j = j + 1 + } + goto _9 + _9: + ; + i = i + 1 + } + goto _6 + _6: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + /* Add all table columns to the PRIMARY KEY index + */ + nExtra = 0 + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if !(_hasColumn(tls, (*TIndex)(unsafe.Pointer(pPk)).FaiColumn, nPk, i) != 0) && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + nExtra = nExtra + 1 + } + goto _10 + _10: + ; + i = i + 1 + } + if _resizeIndexObject(tls, pParse, pPk, nPk+nExtra) != 0 { + return + } + i = 0 + j = nPk + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if !(_hasColumn(tls, (*TIndex)(unsafe.Pointer(pPk)).FaiColumn, j, i) != 0) && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16) + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)) = int16(i) + if zColl != 0 { + v12 = zColl + } else { + v12 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*8)) = v12 + j = j + 1 + } + goto _11 + _11: + ; + i = i + 1 + } + _recomputeColumnsNotIndexed(tls, pPk) +} + +// C documentation +// +// /* +// ** Return true (non-zero) if pCur is current pointing to the last +// ** page of a table. +// */ +func _cursorOnLastPage(tls *libc.TLS, pCur uintptr) (r int32) { + var i int32 + var pPage uintptr + _, _ = i, pPage + i = 0 + for { + if !(i < int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)) { + break + } + pPage = **(**uintptr)(__ccgo_up(pCur + 144 + uintptr(i)*8)) + if libc.Int32FromUint16(**(**Tu16)(__ccgo_up(pCur + 88 + uintptr(i)*2))) < libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + return int32(1) +} + +func _dbpageColumn(tls *libc.TLS, pCursor uintptr, ctx uintptr, i int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pCsr uintptr + var rc int32 + var _ /* pDbPage at bp+0 */ uintptr + _, _, _ = db, pCsr, rc + pCsr = pCursor + rc = SQLITE_OK + switch i { + case 0: /* pgno */ + Xsqlite3_result_int64(tls, ctx, libc.Int64FromUint32((*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno)) + case int32(1): /* data */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno == libc.Uint32FromInt32(_sqlite3PendingByte/(*TDbpageCursor)(unsafe.Pointer(pCsr)).FszPage+libc.Int32FromInt32(1)) { + /* The pending byte page. Assume it is zeroed out. Attempting to + ** request this page from the page is an SQLITE_CORRUPT error. */ + Xsqlite3_result_zeroblob(tls, ctx, (*TDbpageCursor)(unsafe.Pointer(pCsr)).FszPage) + } else { + rc = _sqlite3PagerGet(tls, (*TDbpageCursor)(unsafe.Pointer(pCsr)).FpPager, (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno, bp, 0) + if rc == SQLITE_OK { + Xsqlite3_result_blob(tls, ctx, _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))), (*TDbpageCursor)(unsafe.Pointer(pCsr)).FszPage, uintptr(-libc.Int32FromInt32(1))) + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + } + default: /* schema */ + db = Xsqlite3_context_db_handle(tls, ctx) + Xsqlite3_result_text(tls, ctx, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TDbpageCursor)(unsafe.Pointer(pCsr)).FiDb)*32))).FzDbSName, -int32(1), libc.UintptrFromInt32(0)) + break + } + return rc +} + +// C documentation +// +// /* +// ** idxNum: +// ** +// ** 0 schema=main, full table scan +// ** 1 schema=main, pgno=?1 +// ** 2 schema=?1, full table scan +// ** 3 schema=?1, pgno=?2 +// ** +// ** idxStr is not used +// */ +func _dbpageFilter(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + var db, pBt, pCsr, pTab, zSchema uintptr + var iPg Ti64 + var rc int32 + _, _, _, _, _, _, _ = db, iPg, pBt, pCsr, pTab, rc, zSchema + pCsr = pCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + db = (*TDbpageTable)(unsafe.Pointer(pTab)).Fdb + _ = idxStr + _ = argc + /* Default setting is no rows of result */ + (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno = uint32(1) + (*TDbpageCursor)(unsafe.Pointer(pCsr)).FmxPgno = uint32(0) + if idxNum&int32(2) != 0 { + zSchema = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + (*TDbpageCursor)(unsafe.Pointer(pCsr)).FiDb = _sqlite3FindDbName(tls, db, zSchema) + if (*TDbpageCursor)(unsafe.Pointer(pCsr)).FiDb < 0 { + return SQLITE_OK + } + } else { + (*TDbpageCursor)(unsafe.Pointer(pCsr)).FiDb = 0 + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TDbpageCursor)(unsafe.Pointer(pCsr)).FiDb)*32))).FpBt + if pBt == uintptr(0) { + return SQLITE_OK + } + (*TDbpageCursor)(unsafe.Pointer(pCsr)).FpPager = _sqlite3BtreePager(tls, pBt) + (*TDbpageCursor)(unsafe.Pointer(pCsr)).FszPage = _sqlite3BtreeGetPageSize(tls, pBt) + (*TDbpageCursor)(unsafe.Pointer(pCsr)).FmxPgno = _sqlite3BtreeLastPage(tls, pBt) + if idxNum&int32(1) != 0 { + iPg = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + uintptr(idxNum>>int32(1))*8))) + if iPg < int64(1) || iPg > libc.Int64FromUint32((*TDbpageCursor)(unsafe.Pointer(pCsr)).FmxPgno) { + (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno = uint32(1) + (*TDbpageCursor)(unsafe.Pointer(pCsr)).FmxPgno = uint32(0) + } else { + (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno = libc.Uint32FromInt64(iPg) + (*TDbpageCursor)(unsafe.Pointer(pCsr)).FmxPgno = (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno + } + } else { + } + if (*TDbpageCursor)(unsafe.Pointer(pCsr)).FpPage1 != 0 { + _sqlite3PagerUnrefPageOne(tls, (*TDbpageCursor)(unsafe.Pointer(pCsr)).FpPage1) + } + rc = _sqlite3PagerGet(tls, (*TDbpageCursor)(unsafe.Pointer(pCsr)).FpPager, uint32(1), pCsr+24, 0) + return rc +} + +// C documentation +// +// /* +// ** Remove the memory data structures associated with the given +// ** Table. No changes are made to disk by this routine. +// ** +// ** This routine just deletes the data structure. It does not unlink +// ** the table data structure from the hash table. But it does destroy +// ** memory structures of the indices and foreign keys associated with +// ** the table. +// ** +// ** The db parameter is optional. It is needed if the Table object +// ** contains lookaside memory. (Table objects in the schema do not use +// ** lookaside memory, but some ephemeral Table objects do.) Or the +// ** db parameter can be used with db->pnBytesFreed to measure the memory +// ** used by the Table object. +// */ +func _deleteTable(tls *libc.TLS, db uintptr, pTable uintptr) { + var pIndex, pNext, zName uintptr + _, _, _ = pIndex, pNext, zName + /* Delete all indices associated with this table. */ + pIndex = (*TTable)(unsafe.Pointer(pTable)).FpIndex + for { + if !(pIndex != 0) { + break + } + pNext = (*TIndex)(unsafe.Pointer(pIndex)).FpNext + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) && !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + zName = (*TIndex)(unsafe.Pointer(pIndex)).FzName + _sqlite3HashInsert(tls, (*TIndex)(unsafe.Pointer(pIndex)).FpSchema+32, zName, uintptr(0)) + } + _sqlite3FreeIndex(tls, db, pIndex) + goto _1 + _1: + ; + pIndex = pNext + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_NORM { + _sqlite3FkDelete(tls, db, pTable) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3VtabClear(tls, db, pTable) + } else { + _sqlite3SelectDelete(tls, db, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTable)).Fu))).FpSelect) + } + } + /* Delete the Table structure itself. + */ + _sqlite3DeleteColumnNames(tls, db, pTable) + _sqlite3DbFree(tls, db, (*TTable)(unsafe.Pointer(pTable)).FzName) + _sqlite3DbFree(tls, db, (*TTable)(unsafe.Pointer(pTable)).FzColAff) + _sqlite3ExprListDelete(tls, db, (*TTable)(unsafe.Pointer(pTable)).FpCheck) + _sqlite3DbFree(tls, db, pTable) + /* Verify that no lookaside memory was used by schema tables */ +} + +// C documentation +// +// /* +// ** Disable a term in the WHERE clause. Except, do not disable the term +// ** if it controls a LEFT OUTER JOIN and it did not originate in the ON +// ** or USING clause of that join. +// ** +// ** Consider the term t2.z='ok' in the following queries: +// ** +// ** (1) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok' +// ** (2) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok' +// ** (3) SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok' +// ** +// ** The t2.z='ok' is disabled in the in (2) because it originates +// ** in the ON clause. The term is disabled in (3) because it is not part +// ** of a LEFT OUTER JOIN. In (1), the term is not disabled. +// ** +// ** Disabling a term causes that term to not be tested in the inner loop +// ** of the join. Disabling is an optimization. When terms are satisfied +// ** by indices, we disable them to prevent redundant tests in the inner +// ** loop. We would get the correct results if nothing were ever disabled, +// ** but joins might run a little slower. The trick is to disable as much +// ** as we can without disabling too much. If we disabled in (1), we'd get +// ** the wrong answer. See ticket #813. +// ** +// ** If all the children of a term are disabled, then that term is also +// ** automatically disabled. In this way, terms get disabled if derived +// ** virtual terms are tested first. For example: +// ** +// ** x GLOB 'abc*' AND x>='abc' AND x<'acd' +// ** \___________/ \______/ \_____/ +// ** parent child1 child2 +// ** +// ** Only the parent term was in the original WHERE clause. The child1 +// ** and child2 terms were added by the LIKE optimization. If both of +// ** the virtual child terms are valid, then testing of the parent can be +// ** skipped. +// ** +// ** Usually the parent term is marked as TERM_CODED. But if the parent +// ** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead. +// ** The TERM_LIKECOND marking indicates that the term should be coded inside +// ** a conditional such that is only evaluated on the second pass of a +// ** LIKE-optimization loop, when scanning BLOBs instead of strings. +// */ +func _disableTerm(tls *libc.TLS, pLevel uintptr, pTerm uintptr) { + var nLoop int32 + var v1 uintptr + _, _ = nLoop, v1 + nLoop = 0 + for libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_CODED) == 0 && ((*TWhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0 || (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0)) && (*TWhereLevel)(unsafe.Pointer(pLevel)).FnotReady&(*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll == uint64(0) { + if nLoop != 0 && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_LIKE) != 0 { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_LIKECOND)) + } else { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_CODED)) + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FiParent < 0 { + break + } + pTerm = (*TWhereClause)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpWC)).Fa + uintptr((*TWhereTerm)(unsafe.Pointer(pTerm)).FiParent)*56 + (*TWhereTerm)(unsafe.Pointer(pTerm)).FnChild = (*TWhereTerm)(unsafe.Pointer(pTerm)).FnChild - 1 + if libc.Int32FromUint8((*TWhereTerm)(unsafe.Pointer(pTerm)).FnChild) != 0 { + break + } + nLoop = nLoop + 1 + } +} + +// C documentation +// +// /* +// ** Check to see if a subquery contains result-set columns that are +// ** never used. If it does, change the value of those result-set columns +// ** to NULL so that they do not cause unnecessary work to compute. +// ** +// ** Return the number of column that were changed to NULL. +// */ +func _disableUnusedSubqueryResultColumns(tls *libc.TLS, pItem uintptr) (r int32) { + var colUsed, m TBitmask + var iCol Tu16 + var j, nChng, nCol, v3 int32 + var pList, pSub, pTab, pX, pY uintptr + var v5 uint64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = colUsed, iCol, j, m, nChng, nCol, pList, pSub, pTab, pX, pY, v3, v5 /* Column number */ + nChng = 0 /* Columns that may not be NULLed out */ + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10>>4) != 0 || int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x200>>9) != 0 { + return 0 + } + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + pSub = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + pX = pSub + for { + if !(pX != 0) { + break + } + if (*TSelect)(unsafe.Pointer(pX)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Distinct)|libc.Int32FromInt32(SF_Aggregate)) != uint32(0) { + return 0 + } + if (*TSelect)(unsafe.Pointer(pX)).FpPrior != 0 && libc.Int32FromUint8((*TSelect)(unsafe.Pointer(pX)).Fop) != int32(TK_ALL) { + /* This optimization does not work for compound subqueries that + ** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */ + return 0 + } + if (*TSelect)(unsafe.Pointer(pX)).FpWin != 0 { + /* This optimization does not work for subqueries that use window + ** functions. */ + return 0 + } + goto _1 + _1: + ; + pX = (*TSelect)(unsafe.Pointer(pX)).FpPrior + } + colUsed = (*TSrcItem)(unsafe.Pointer(pItem)).FcolUsed + if (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy != 0 { + pList = (*TSelect)(unsafe.Pointer(pSub)).FpOrderBy + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + iCol = *(*Tu16)(unsafe.Pointer(pList + 8 + uintptr(j)*32 + 24)) + if libc.Int32FromUint16(iCol) > 0 { + iCol = iCol - 1 + if libc.Int32FromUint16(iCol) >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v3 = libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1) + } else { + v3 = libc.Int32FromUint16(iCol) + } + colUsed = colUsed | libc.Uint64FromInt32(1)<= 0 { + v1 = pWalker + 36 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40)))).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiColumn)*16))).FcolFlags)) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Check to see if there are references to columns in table +// ** pWalker->u.pIdxCover->iCur can be satisfied using the index +// ** pWalker->u.pIdxCover->pIdx. +// */ +func _exprIdxCover(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TIdxCover)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40)))).FiCur && _sqlite3TableColumnToIndex(tls, (*TIdxCover)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40)))).FpIdx, int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn)) < 0 { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(1) + return int32(WRC_Abort) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Return non-zero if Expr p can only be true if pNN is not NULL. +// ** +// ** Or if seenNot is true, return non-zero if Expr p can only be +// ** non-NULL if pNN is not NULL +// */ +func _exprImpliesNotNull(tls *libc.TLS, pParse uintptr, p uintptr, pNN uintptr, iTab int32, seenNot int32) (r int32) { + var pList uintptr + _ = pList + if _sqlite3ExprCompare(tls, pParse, p, pNN, iTab) == 0 { + return libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pNN)).Fop) != int32(TK_NULL)) + } + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) { + case int32(TK_IN): + if seenNot != 0 && (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_xIsSelect)) != uint32(0) { + return 0 + } + return _exprImpliesNotNull(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, int32(1)) + case int32(TK_BETWEEN): + pList = *(*uintptr)(unsafe.Pointer(p + 32)) + if seenNot != 0 { + return 0 + } + if _exprImpliesNotNull(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8))).FpExpr, pNN, iTab, int32(1)) != 0 || _exprImpliesNotNull(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr, pNN, iTab, int32(1)) != 0 { + return int32(1) + } + return _exprImpliesNotNull(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, int32(1)) + case int32(TK_EQ): + fallthrough + case int32(TK_NE): + fallthrough + case int32(TK_LT): + fallthrough + case int32(TK_LE): + fallthrough + case int32(TK_GT): + fallthrough + case int32(TK_GE): + fallthrough + case int32(TK_PLUS): + fallthrough + case int32(TK_MINUS): + fallthrough + case int32(TK_BITOR): + fallthrough + case int32(TK_LSHIFT): + fallthrough + case int32(TK_RSHIFT): + fallthrough + case int32(TK_CONCAT): + seenNot = int32(1) + fallthrough + case int32(TK_STAR): + fallthrough + case int32(TK_REM): + fallthrough + case int32(TK_BITAND): + fallthrough + case int32(TK_SLASH): + if _exprImpliesNotNull(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FpRight, pNN, iTab, seenNot) != 0 { + return int32(1) + } + fallthrough + case int32(TK_SPAN): + fallthrough + case int32(TK_COLLATE): + fallthrough + case int32(TK_UPLUS): + fallthrough + case int32(TK_UMINUS): + return _exprImpliesNotNull(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, seenNot) + case int32(TK_TRUTH): + if seenNot != 0 { + return 0 + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop2) != int32(TK_IS) { + return 0 + } + return _exprImpliesNotNull(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, int32(1)) + case int32(TK_BITNOT): + fallthrough + case int32(TK_NOT): + return _exprImpliesNotNull(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, int32(1)) + } + return 0 +} + +func _exprIsConst(tls *libc.TLS, pParse uintptr, p uintptr, initFlag int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + (**(**TWalker)(__ccgo_up(bp))).FeCode = libc.Uint16FromInt32(initFlag) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprNodeIsConstant) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkFail) + _sqlite3WalkExpr(tls, bp, p) + return libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) +} + +// C documentation +// +// /* +// ** pIdx is an index containing expressions. Check it see if any of the +// ** expressions in the index match the pExpr expression. +// */ +func _exprIsCoveredByIndex(tls *libc.TLS, pExpr uintptr, pIdx uintptr, iTabCur int32) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) == -int32(2) && _sqlite3ExprCompare(tls, uintptr(0), pExpr, (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(i)*32))).FpExpr, iTabCur) == 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Append a copy of each expression in expression-list pAppend to +// ** expression list pList. Return a pointer to the result list. +// */ +func _exprListAppendList(tls *libc.TLS, pParse uintptr, pList uintptr, pAppend uintptr, bIntToNull int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pDup, pSub uintptr + var i, nInit, v1 int32 + var _ /* iDummy at bp+0 */ int32 + _, _, _, _, _, _ = db, i, nInit, pDup, pSub, v1 + if pAppend != 0 { + if pList != 0 { + v1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v1 = 0 + } + nInit = v1 + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pAppend)).FnExpr) { + break + } + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pDup = _sqlite3ExprDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pAppend + 8 + uintptr(i)*32))).FpExpr, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pDup) + break + } + if bIntToNull != 0 { + pSub = _sqlite3ExprSkipCollateAndLikely(tls, pDup) + if _sqlite3ExprIsInteger(tls, pSub, bp, uintptr(0)) != 0 { + (*TExpr)(unsafe.Pointer(pSub)).Fop = uint8(TK_NULL) + **(**Tu32)(__ccgo_up(pSub + 4)) &= libc.Uint32FromInt32(^(libc.Int32FromInt32(EP_IntValue) | libc.Int32FromInt32(EP_IsTrue) | libc.Int32FromInt32(EP_IsFalse))) + *(*uintptr)(unsafe.Pointer(pSub + 8)) = uintptr(0) + } + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, pDup) + if pList != 0 { + (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(nInit+i)*32))).Ffg.FsortFlags = (*(*TExprList_item)(unsafe.Pointer(pAppend + 8 + uintptr(i)*32))).Ffg.FsortFlags + } + goto _2 + _2: + ; + i = i + 1 + } + } + return pList +} + +func _exprMightBeIndexed(tls *libc.TLS, pFrom uintptr, aiCurCol uintptr, pExpr uintptr, op int32) (r int32) { + var i int32 + var pIdx uintptr + _, _ = i, pIdx + /* If this expression is a vector to the left or right of a + ** inequality constraint (>, <, >= or <=), perform the processing + ** on the first element of the vector. */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_VECTOR) && (op >= int32(TK_GT) && op <= int32(TK_GE)) { + pExpr = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) { + **(**int32)(__ccgo_up(aiCurCol)) = (*TExpr)(unsafe.Pointer(pExpr)).FiTable + **(**int32)(__ccgo_up(aiCurCol + 1*4)) = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + return int32(1) + } + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pFrom)).FnSrc) { + break + } + pIdx = (*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pFrom + 8 + uintptr(i)*80))).FpSTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if (*TIndex)(unsafe.Pointer(pIdx)).FaColExpr != 0 { + return _exprMightBeIndexed2(tls, pFrom, aiCurCol, pExpr, i) + } + goto _2 + _2: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Expression pExpr is one operand of a comparison operator that might +// ** be useful for indexing. This routine checks to see if pExpr appears +// ** in any index. Return TRUE (1) if pExpr is an indexed term and return +// ** FALSE (0) if not. If TRUE is returned, also set aiCurCol[0] to the cursor +// ** number of the table that is indexed and aiCurCol[1] to the column number +// ** of the column that is indexed, or XN_EXPR (-2) if an expression is being +// ** indexed. +// ** +// ** If pExpr is a TK_COLUMN column reference, then this routine always returns +// ** true even if that particular column is not indexed, because the column +// ** might be added to an automatic index later. +// */ +func _exprMightBeIndexed2(tls *libc.TLS, pFrom uintptr, aiCurCol uintptr, pExpr uintptr, j int32) (r int32) { + var i, iCur, v1 int32 + var pIdx uintptr + _, _, _, _ = i, iCur, pIdx, v1 + for { + iCur = (*(*TSrcItem)(unsafe.Pointer(pFrom + 8 + uintptr(j)*80))).FiCursor + pIdx = (*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pFrom + 8 + uintptr(j)*80))).FpSTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if (*TIndex)(unsafe.Pointer(pIdx)).FaColExpr == uintptr(0) { + goto _3 + } + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) != -int32(2) { + goto _4 + } + if _sqlite3ExprCompareSkip(tls, pExpr, (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(i)*32))).FpExpr, iCur) == 0 && !(_sqlite3ExprIsConstant(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(i)*32))).FpExpr) != 0) { + **(**int32)(__ccgo_up(aiCurCol)) = iCur + **(**int32)(__ccgo_up(aiCurCol + 1*4)) = -int32(2) + return int32(1) + } + goto _4 + _4: + ; + i = i + 1 + } + goto _3 + _3: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + goto _2 + _2: + ; + j = j + 1 + v1 = j + if !(v1 < (*TSrcList)(unsafe.Pointer(pFrom)).FnSrc) { + break + } + } + return 0 +} + +// C documentation +// +// /* +// ** Expression Node callback for sqlite3ExprCanReturnSubtype(). If +// ** pExpr is able to return a subtype, set pWalker->eCode and abort +// ** the search. If pExpr can never return a subtype, prune search. +// ** +// ** The only expressions that can return a subtype are: +// ** +// ** 1. A function +// ** 2. The no-op "+" operator +// ** 3. A CASE...END expression +// ** 4. A CAST() expression +// ** 5. A "expr COLLATE colseq" expression. +// ** +// ** For any other kind of expression, prune the search. +// ** +// ** For case 1, the expression can yield a subtype if the function has +// ** the SQLITE_RESULT_SUBTYPE property. Functions can also return +// ** a subtype (via sqlite3_result_value()) if any of the arguments can +// ** return a subtype. +// ** +// ** In all cases 1 through 5, the expression might also return a subtype +// ** if any operand can return a subtype. +// */ +func _exprNodeCanReturnSubtype(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var db, pDef uintptr + var n, v1 int32 + _, _, _, _ = db, n, pDef, v1 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_CASE) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_UPLUS) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_CAST) { + return WRC_Continue + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_FUNCTION) { + return int32(WRC_Prune) + } + db = (*TParse)(unsafe.Pointer((*TWalker)(unsafe.Pointer(pWalker)).FpParse)).Fdb + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != 0 { + v1 = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + } else { + v1 = 0 + } + n = v1 + pDef = _sqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8)), n, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, uint8(0)) + if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_RESULT_SUBTYPE) != uint32(0) { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(1) + return int32(WRC_Abort) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** These routines are Walker callbacks used to check expressions to +// ** see if they are "constant" for some definition of constant. The +// ** Walker.eCode value determines the type of "constant" we are looking +// ** for. +// ** +// ** These callback routines are used to implement the following: +// ** +// ** sqlite3ExprIsConstant() pWalker->eCode==1 +// ** sqlite3ExprIsConstantNotJoin() pWalker->eCode==2 +// ** sqlite3ExprIsTableConstant() pWalker->eCode==3 +// ** sqlite3ExprIsConstantOrFunction() pWalker->eCode==4 or 5 +// ** +// ** In all cases, the callbacks set Walker.eCode=0 and abort if the expression +// ** is found to not be a constant. +// ** +// ** The sqlite3ExprIsConstantOrFunction() is used for evaluating DEFAULT +// ** expressions in a CREATE TABLE statement. The Walker.eCode value is 5 +// ** when parsing an existing schema out of the sqlite_schema table and 4 +// ** when processing a new CREATE TABLE statement. A bound parameter raises +// ** an error for new statements, but is silently converted +// ** to NULL for existing schemas. This allows sqlite_schema tables that +// ** contain a bound parameter because they were generated by older versions +// ** of SQLite to be parsed by newer versions of SQLite without raising a +// ** malformed schema error. +// */ +func _exprNodeIsConstant(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + /* If pWalker->eCode is 2 then any term of the expression that comes from + ** the ON or USING clauses of an outer join disqualifies the expression + ** from being considered constant. */ + if libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) == int32(2) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) + } + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + /* Consider functions to be constant if all their arguments are constant + ** and either pWalker->eCode==4 or 5 or the function has the + ** SQLITE_FUNC_CONST flag. */ + case int32(TK_FUNCTION): + if (libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) >= int32(4) || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_ConstFunc)) != uint32(0)) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != libc.Uint32FromInt32(0)) { + if libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) == int32(5) { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) + } + return WRC_Continue + } else { + if (*TWalker)(unsafe.Pointer(pWalker)).FpParse != 0 { + return _exprNodeIsConstantFunction(tls, pWalker, pExpr) + } else { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) + } + } + fallthrough + case int32(TK_ID): + /* Convert "true" or "false" in a DEFAULT clause into the + ** appropriate TK_TRUEFALSE operator */ + if _sqlite3ExprIdToTrueFalse(tls, pExpr) != 0 { + return int32(WRC_Prune) + } + fallthrough + case int32(TK_COLUMN): + fallthrough + case int32(TK_AGG_FUNCTION): + fallthrough + case int32(TK_AGG_COLUMN): + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != uint32(0) && libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) != int32(2) { + return WRC_Continue + } + if libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) == int32(3) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == *(*int32)(unsafe.Pointer(&(*TWalker)(unsafe.Pointer(pWalker)).Fu)) { + return WRC_Continue + } + fallthrough + case int32(TK_IF_NULL_ROW): + fallthrough + case int32(TK_REGISTER): + fallthrough + case int32(TK_DOT): + fallthrough + case int32(TK_RAISE): + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) + case int32(TK_VARIABLE): + if libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) == int32(5) { + /* Silently convert bound parameters that appear inside of CREATE + ** statements into a NULL when parsing the CREATE statement text out + ** of the sqlite_schema table */ + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + } else { + if libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) == int32(4) { + /* A bound parameter in a CREATE statement that originates from + ** sqlite3_prepare() causes an error */ + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) + } + } + fallthrough + default: + /* sqlite3SelectWalkFail() disallows */ + /* sqlite3SelectWalkFail() disallows */ + return WRC_Continue + } + return r +} + +// C documentation +// +// /* +// ** pExpr is a TK_FUNCTION node. Try to determine whether or not the +// ** function is a constant function. A function is constant if all of +// ** the following are true: +// ** +// ** (1) It is a scalar function (not an aggregate or window function) +// ** (2) It has either the SQLITE_FUNC_CONSTANT or SQLITE_FUNC_SLOCHNG +// ** property. +// ** (3) All of its arguments are constants +// ** +// ** This routine sets pWalker->eCode to 0 if pExpr is not a constant. +// ** It makes no changes to pWalker->eCode if pExpr is constant. In +// ** every case, it returns WRC_Abort. +// ** +// ** Called as a service subroutine from exprNodeIsConstant(). +// */ +func _exprNodeIsConstantFunction(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var db, pDef, pList, v1 uintptr + var n int32 + var v2 bool + _, _, _, _, _, _ = db, n, pDef, pList, v1, v2 /* The database */ + if v2 = (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)) != uint32(0); !v2 { + v1 = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + pList = v1 + } + if v2 || v1 == uintptr(0) { + n = 0 + } else { + n = (*TExprList)(unsafe.Pointer(pList)).FnExpr + _sqlite3WalkExprList(tls, pWalker, pList) + if libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) == 0 { + return int32(WRC_Abort) + } + } + db = (*TParse)(unsafe.Pointer((*TWalker)(unsafe.Pointer(pWalker)).FpParse)).Fdb + pDef = _sqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8)), n, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, uint8(0)) + if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)|libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG)) == uint32(0) || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) + } + return int32(WRC_Prune) +} + +// C documentation +// +// /* +// ** Callback for estLikePatternLength(). +// ** +// ** If this node is a string literal that is longer pWalker->sz, then set +// ** pWalker->sz to the byte length of that string literal. +// ** +// ** pWalker->eCode indicates how to count characters: +// ** +// ** eCode==0 Count as a GLOB pattern +// ** eCode==1 Count as a LIKE pattern +// */ +func _exprNodePatternLengthEst(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var c, c1, c2, c3, v1 Tu8 + var sz int32 + var z, v2 uintptr + _, _, _, _, _, _, _, _ = c, c1, c2, c3, sz, z, v1, v2 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_STRING) { + sz = 0 /* Pattern size in bytes */ + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) /* Wildcards */ + if (*TWalker)(unsafe.Pointer(pWalker)).FeCode != 0 { + c1 = uint8('%') + c2 = uint8('_') + c3 = uint8(0) + } else { + c1 = uint8('*') + c2 = uint8('?') + c3 = uint8('[') + } + for { + v2 = z + z = z + 1 + v1 = **(**Tu8)(__ccgo_up(v2)) + c = v1 + if !(libc.Int32FromUint8(v1) != 0) { + break + } + if libc.Int32FromUint8(c) == libc.Int32FromUint8(c3) { + if **(**Tu8)(__ccgo_up(z)) != 0 { + z = z + 1 + } + for **(**Tu8)(__ccgo_up(z)) != 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z))) != int32(']') { + z = z + 1 + } + } else { + if libc.Int32FromUint8(c) != libc.Int32FromUint8(c1) && libc.Int32FromUint8(c) != libc.Int32FromUint8(c2) { + sz = sz + 1 + } + } + } + if sz > *(*int32)(unsafe.Pointer(&(*TWalker)(unsafe.Pointer(pWalker)).Fu)) { + *(*int32)(unsafe.Pointer(&(*TWalker)(unsafe.Pointer(pWalker)).Fu)) = sz + } + } + return WRC_Continue +} + +// C documentation +// +// /* This is the Walker EXPR callback for sqlite3ReferencesSrcList(). +// ** +// ** Set the 0x01 bit of pWalker->eCode if there is a reference to any +// ** of the tables shown in RefSrcList.pRef. +// ** +// ** Set the 0x02 bit of pWalker->eCode if there is a reference to a +// ** table is in neither RefSrcList.pRef nor RefSrcList.aiExclude. +// */ +func _exprRefToSrcList(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var i, nSrc, v1 int32 + var p, pSrc, v3 uintptr + _, _, _, _, _, _ = i, nSrc, p, pSrc, v1, v3 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_COLUMN) { + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pSrc = (*TRefSrcList)(unsafe.Pointer(p)).FpRef + if pSrc != 0 { + v1 = (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc + } else { + v1 = 0 + } + nSrc = v1 + i = 0 + for { + if !(i < nSrc) { + break + } + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FiCursor { + v3 = pWalker + 36 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(1)) + return WRC_Continue + } + goto _2 + _2: + ; + i = i + 1 + } + i = 0 + for { + if !(int64(i) < (*TRefSrcList)(unsafe.Pointer(p)).FnExclude && **(**int32)(__ccgo_up((*TRefSrcList)(unsafe.Pointer(p)).FaiExclude + uintptr(i)*4)) != (*TExpr)(unsafe.Pointer(pExpr)).FiTable) { + break + } + goto _4 + _4: + ; + i = i + 1 + } + if int64(i) >= (*TRefSrcList)(unsafe.Pointer(p)).FnExclude { + v3 = pWalker + 36 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(2)) + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Set the Expr.nHeight variable in the structure passed as an +// ** argument. An expression with no children, Expr.pList or +// ** Expr.pSelect member has a height of 1. Any other expression +// ** has a height equal to the maximum height of any other +// ** referenced Expr plus one. +// ** +// ** Also propagate EP_Propagate flags up from Expr.x.pList to Expr.flags, +// ** if appropriate. +// */ +func _exprSetHeight(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 int32 + var _ /* nHeight at bp+0 */ int32 + _ = v1 + if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 { + v1 = (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(p)).FpLeft)).FnHeight + } else { + v1 = 0 + } + **(**int32)(__ccgo_up(bp)) = v1 + if (*TExpr)(unsafe.Pointer(p)).FpRight != 0 && (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(p)).FpRight)).FnHeight > **(**int32)(__ccgo_up(bp)) { + **(**int32)(__ccgo_up(bp)) = (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(p)).FpRight)).FnHeight + } + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _heightOfSelect(tls, *(*uintptr)(unsafe.Pointer(p + 32)), bp) + } else { + if *(*uintptr)(unsafe.Pointer(p + 32)) != 0 { + _heightOfExprList(tls, *(*uintptr)(unsafe.Pointer(p + 32)), bp) + **(**Tu32)(__ccgo_up(p + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)|libc.Int32FromInt32(EP_Subquery)|libc.Int32FromInt32(EP_HasFunc)) & _sqlite3ExprListFlags(tls, *(*uintptr)(unsafe.Pointer(p + 32))) + } + } + (*TExpr)(unsafe.Pointer(p)).FnHeight = **(**int32)(__ccgo_up(bp)) + int32(1) +} + +// C documentation +// +// /* +// ** Return the number of bytes allocated for the expression structure +// ** passed as the first argument. This is always one of EXPR_FULLSIZE, +// ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. +// */ +func _exprStructSize(tls *libc.TLS, p uintptr) (r int32) { + if (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)) != uint32(0) { + return libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0) + 16)) + } + if (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Reduced)) != uint32(0) { + return libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0) + 44)) + } + return int32(72) +} + +// C documentation +// +// /* +// ** Argument pVector points to a vector expression - either a TK_VECTOR +// ** or TK_SELECT that returns more than one column. This function returns +// ** the register number of a register that contains the value of +// ** element iField of the vector. +// ** +// ** If pVector is a TK_SELECT expression, then code for it must have +// ** already been generated using the exprCodeSubselect() routine. In this +// ** case parameter regSelect should be the first in an array of registers +// ** containing the results of the sub-select. +// ** +// ** If pVector is of type TK_VECTOR, then code for the requested field +// ** is generated. In this case (*pRegFree) may be set to the number of +// ** a temporary register to be freed by the caller before returning. +// ** +// ** Before returning, output parameter (*ppExpr) is set to point to the +// ** Expr object corresponding to element iElem of the vector. +// */ +func _exprVectorRegister(tls *libc.TLS, pParse uintptr, pVector uintptr, iField int32, regSelect int32, ppExpr uintptr, pRegFree uintptr) (r int32) { + var op Tu8 + _ = op + op = (*TExpr)(unsafe.Pointer(pVector)).Fop + if libc.Int32FromUint8(op) == int32(TK_REGISTER) { + **(**uintptr)(__ccgo_up(ppExpr)) = _sqlite3VectorFieldSubexpr(tls, pVector, iField) + return (*TExpr)(unsafe.Pointer(pVector)).FiTable + iField + } + if libc.Int32FromUint8(op) == int32(TK_SELECT) { + **(**uintptr)(__ccgo_up(ppExpr)) = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 32)))).FpEList + 8 + uintptr(iField)*32))).FpExpr + return regSelect + iField + } + if libc.Int32FromUint8(op) == int32(TK_VECTOR) { + **(**uintptr)(__ccgo_up(ppExpr)) = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 32)) + 8 + uintptr(iField)*32))).FpExpr + return _sqlite3ExprCodeTemp(tls, pParse, **(**uintptr)(__ccgo_up(ppExpr)), pRegFree) + } + return 0 +} + +// C documentation +// +// /* +// ** Create a new expression term for the column specified by pMatch and +// ** iColumn. Append this new expression term to the FULL JOIN Match set +// ** in *ppList. Create a new *ppList if this is the first term in the +// ** set. +// */ +func _extendFJMatch(tls *libc.TLS, pParse uintptr, ppList uintptr, pMatch uintptr, iColumn Ti16) { + var pNew uintptr + _ = pNew + pNew = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_COLUMN), uintptr(0), 0) + if pNew != 0 { + (*TExpr)(unsafe.Pointer(pNew)).FiTable = (*TSrcItem)(unsafe.Pointer(pMatch)).FiCursor + (*TExpr)(unsafe.Pointer(pNew)).FiColumn = iColumn + *(*uintptr)(unsafe.Pointer(pNew + 64)) = (*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + **(**uintptr)(__ccgo_up(ppList)) = _sqlite3ExprListAppend(tls, pParse, **(**uintptr)(__ccgo_up(ppList)), pNew) + } +} + +// C documentation +// +// /* +// ** Return a pointer to payload information from the entry that the +// ** pCur cursor is pointing to. The pointer is to the beginning of +// ** the key if index btrees (pPage->intKey==0) and is the data for +// ** table btrees (pPage->intKey==1). The number of bytes of available +// ** key/data is written into *pAmt. If *pAmt==0, then the value +// ** returned will not be a valid pointer. +// ** +// ** This routine is an optimization. It is common for the entire key +// ** and data to fit on the local page and for there to be no overflow +// ** pages. When that is so, this routine can be used to access the +// ** key and data without making a copy. If the key and/or data spills +// ** onto overflow pages, then accessPayload() must be used to reassemble +// ** the key/data and copy it into a preallocated buffer. +// ** +// ** The pointer returned by this routine looks directly into the cached +// ** page of the database. The data might change or move the next time +// ** any btree routine is called. +// */ +func _fetchPayload(tls *libc.TLS, pCur uintptr, pAmt uintptr) (r uintptr) { + var amt, v1 int32 + _, _ = amt, v1 + amt = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) + if amt > int32(int64((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FaDataEnd)-int64((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload)) { + /* There is too little space on the page for the expected amount + ** of local content. Database must be corrupt. */ + if 0 > int32(int64((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FaDataEnd)-int64((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload)) { + v1 = 0 + } else { + v1 = int32(int64((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FaDataEnd) - int64((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload)) + } + amt = v1 + } + **(**Tu32)(__ccgo_up(pAmt)) = libc.Uint32FromInt32(amt) + return (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload +} + +// C documentation +// +// /* +// ** Compute a bloom filter hash using pOp->p4.i registers from aMem[] beginning +// ** with pOp->p3. Return the hash. +// */ +func _filterHash(tls *libc.TLS, aMem uintptr, pOp uintptr) (r Tu64) { + var h Tu64 + var i, mx int32 + var p uintptr + _, _, _, _ = h, i, mx, p + h = uint64(0) + i = (*TOp)(unsafe.Pointer(pOp)).Fp3 + mx = i + (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + for { + if !(i < mx) { + break + } + p = aMem + uintptr(i)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + h = h + libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(p))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&int32(MEM_Real) != 0 { + h = h + libc.Uint64FromInt64(_sqlite3VdbeIntValue(tls, p)) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) != 0 { + /* All strings have the same hash and all blobs have the same hash, + ** though, at least, those hashes are different from each other and + ** from NULL. */ + h = h + libc.Uint64FromInt32(int32(4093)+libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob))) + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + return h +} + +// C documentation +// +// /* +// ** This routine is called right after An OP_Filter has been generated and +// ** before the corresponding index search has been performed. This routine +// ** checks to see if there are additional Bloom filters in inner loops that +// ** can be checked prior to doing the index lookup. If there are available +// ** inner-loop Bloom filters, then evaluate those filters now, before the +// ** index lookup. The idea is that a Bloom filter check is way faster than +// ** an index lookup, and the Bloom filter might return false, meaning that +// ** the index lookup can be skipped. +// ** +// ** We know that an inner loop uses a Bloom filter because it has the +// ** WhereLevel.regFilter set. If an inner-loop Bloom filter is checked, +// ** then clear the WhereLevel.regFilter value to prevent the Bloom filter +// ** from being checked a second time when the inner loop is evaluated. +// */ +func _filterPullDown(tls *libc.TLS, pParse uintptr, pWInfo uintptr, iLevel int32, addrNxt int32, notReady TBitmask) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nEq Tu16 + var pLevel, pLoop, pTerm uintptr + var r1, regRowid, saved_addrBrk, v1 int32 + var _ /* zStartAff at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = nEq, pLevel, pLoop, pTerm, r1, regRowid, saved_addrBrk, v1 + for { + iLevel = iLevel + 1 + v1 = iLevel + if !(v1 < libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)) { + break + } + pLevel = pWInfo + 856 + uintptr(iLevel)*112 + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter == 0 { + continue + } + if (*TWhereLoop)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FnSkip != 0 { + continue + } + /* ,--- Because sqlite3ConstructBloomFilter() has will not have set + ** vvvvv--' pLevel->regFilter if this were true. */ + if (*TWhereLoop)(unsafe.Pointer(pLoop)).Fprereq¬Ready != 0 { + continue + } + saved_addrBrk = (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk = addrNxt + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != 0 { + pTerm = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) + regRowid = _sqlite3GetTempReg(tls, pParse) + regRowid = _codeEqualityTerm(tls, pParse, pTerm, pLevel, 0, 0, regRowid) + _sqlite3VdbeAddOp2(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_MustBeInt), regRowid, addrNxt) + _sqlite3VdbeAddOp4Int(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Filter), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, addrNxt, regRowid, int32(1)) + } else { + nEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq + r1 = _codeAllEqualityTerms(tls, pParse, pLevel, 0, 0, bp) + _codeApplyAffinity(tls, pParse, r1, libc.Int32FromUint16(nEq), **(**uintptr)(__ccgo_up(bp))) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, **(**uintptr)(__ccgo_up(bp))) + _sqlite3VdbeAddOp4Int(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Filter), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, addrNxt, r1, libc.Int32FromUint16(nEq)) + } + (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter = 0 + (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk = saved_addrBrk + } +} + +// C documentation +// +// /* +// ** Invoke the OP_AggFinalize opcode for every aggregate function +// ** in the AggInfo structure. +// */ +func _finalizeAggFunctions(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) { + var i, iBaseCol, iTop, j, nArg, nKey, regAgg, regSubtype, v4 int32 + var pF, pList, v uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = i, iBaseCol, iTop, j, nArg, nKey, pF, pList, regAgg, regSubtype, v, v4 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + i = 0 + pF = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + pList = *(*uintptr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 32)) + if (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab >= 0 { /* Loop counter */ + nArg = (*TExprList)(unsafe.Pointer(pList)).FnExpr + regAgg = _sqlite3GetTempRange(tls, pParse, nArg) + if libc.Int32FromUint8((*TAggInfo_func)(unsafe.Pointer(pF)).FbOBPayload) == 0 { + nKey = 0 + } else { + nKey = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pF)).FpFExpr)).FpLeft + 32)))).FnExpr + if !((*TAggInfo_func)(unsafe.Pointer(pF)).FbOBUnique != 0) { + nKey = nKey + 1 + } + } + iTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab) + j = nArg - int32(1) + for { + if !(j >= 0) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab, nKey+j, regAgg+j) + goto _2 + _2: + ; + j = j - 1 + } + if (*TAggInfo_func)(unsafe.Pointer(pF)).FbUseSubtype != 0 { + regSubtype = _sqlite3GetTempReg(tls, pParse) + iBaseCol = nKey + nArg + libc.BoolInt32(libc.Int32FromUint8((*TAggInfo_func)(unsafe.Pointer(pF)).FbOBPayload) == 0 && libc.Int32FromUint8((*TAggInfo_func)(unsafe.Pointer(pF)).FbOBUnique) == 0) + j = nArg - int32(1) + for { + if !(j >= 0) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab, iBaseCol+j, regSubtype) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SetSubtype), regSubtype, regAgg+j) + goto _3 + _3: + ; + j = j - 1 + } + _sqlite3ReleaseTempReg(tls, pParse, regSubtype) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_AggStep), 0, regAgg, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+(*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn+i) + _sqlite3VdbeAppendP4(tls, v, (*TAggInfo_func)(unsafe.Pointer(pF)).FpFunc, -int32(8)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(nArg)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab, iTop+int32(1)) + _sqlite3VdbeJumpHere(tls, v, iTop) + _sqlite3ReleaseTempRange(tls, pParse, regAgg, nArg) + } + if pList != 0 { + v4 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v4 = 0 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_AggFinal), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+(*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn+i, v4) + _sqlite3VdbeAppendP4(tls, v, (*TAggInfo_func)(unsafe.Pointer(pF)).FpFunc, -int32(8)) + goto _1 + _1: + ; + i = i + 1 + pF += 32 + } +} + +// C documentation +// +// /* +// ** Scan all previously generated bytecode looking for an OP_BeginSubrtn +// ** that is compatible with pExpr. If found, add the y.sub values +// ** to pExpr and return true. If not found, return false. +// */ +func _findCompatibleInRhsSubrtn(tls *libc.TLS, pParse uintptr, pExpr uintptr, pNewSig uintptr) (r int32) { + var pEnd, pOp, pSig, v uintptr + _, _, _, _ = pEnd, pOp, pSig, v + if pNewSig == uintptr(0) { + return 0 + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FmSubrtnSig)&(int32(1)<<((*TSubrtnSig)(unsafe.Pointer(pNewSig)).FselId&int32(7))) == 0 { + return 0 + } + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pOp = _sqlite3VdbeGetOp(tls, v, int32(1)) + pEnd = _sqlite3VdbeGetLastOp(tls, v) + for { + if !(pOp < pEnd) { + break + } + if int32((*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type) != -int32(18) { + goto _1 + } + pSig = *(*uintptr)(unsafe.Pointer(pOp + 16)) + if !((*TSubrtnSig)(unsafe.Pointer(pSig)).FbComplete != 0) { + goto _1 + } + if (*TSubrtnSig)(unsafe.Pointer(pNewSig)).FselId != (*TSubrtnSig)(unsafe.Pointer(pSig)).FselId { + goto _1 + } + if libc.Xstrcmp(tls, (*TSubrtnSig)(unsafe.Pointer(pNewSig)).FzAff, (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff) != 0 { + goto _1 + } + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr = (*TSubrtnSig)(unsafe.Pointer(pSig)).FiAddr + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn = (*TSubrtnSig)(unsafe.Pointer(pSig)).FregReturn + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSubrtnSig)(unsafe.Pointer(pSig)).FiTable + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + return int32(1) + goto _1 + _1: + ; + pOp += 24 + } + return 0 +} + +// C documentation +// +// /* +// ** This function searches pList for an entry that matches the iCol-th column +// ** of index pIdx. +// ** +// ** If such an expression is found, its index in pList->a[] is returned. If +// ** no expression is found, -1 is returned. +// */ +func _findIndexCol(tls *libc.TLS, pParse uintptr, pList uintptr, iBase int32, pIdx uintptr, iCol int32) (r int32) { + var i int32 + var p, pColl, zColl uintptr + _, _, _, _ = i, p, pColl, zColl + zColl = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(iCol)*8)) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + p = _sqlite3ExprSkipCollateAndLikely(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr) + if p != uintptr(0) && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_COLUMN) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_AGG_COLUMN)) && int32((*TExpr)(unsafe.Pointer(p)).FiColumn) == int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iCol)*2))) && (*TExpr)(unsafe.Pointer(p)).FiTable == iBase { + pColl = _sqlite3ExprNNCollSeq(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr) + if 0 == _sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pColl)).FzName, zColl) { + return i + } + } + goto _1 + _1: + ; + i = i + 1 + } + return -int32(1) +} + +// C documentation +// +// /* +// ** The second argument points to an FKey object representing a foreign key +// ** for which pTab is the parent table. An UPDATE statement against pTab +// ** is currently being processed. For each column of the table that is +// ** actually updated, the corresponding element in the aChange[] array +// ** is zero or greater (if a column is unmodified the corresponding element +// ** is set to -1). If the rowid column is modified by the UPDATE statement +// ** the bChngRowid argument is non-zero. +// ** +// ** This function returns true if any of the columns that are part of the +// ** parent key for FK constraint *p are modified. +// */ +func _fkParentIsModified(tls *libc.TLS, pTab uintptr, p uintptr, aChange uintptr, bChngRowid int32) (r int32) { + var i, iKey int32 + var pCol, zKey uintptr + _, _, _, _ = i, iKey, pCol, zKey + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(p)).FnCol) { + break + } + zKey = (*(*TsColMap)(unsafe.Pointer(p + 64 + uintptr(i)*16))).FzCol + iKey = 0 + for { + if !(iKey < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if **(**int32)(__ccgo_up(aChange + uintptr(iKey)*4)) >= 0 || iKey == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) && bChngRowid != 0 { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iKey)*16 + if zKey != 0 { + if 0 == _sqlite3StrICmp(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, zKey) { + return int32(1) + } + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + return int32(1) + } + } + } + goto _2 + _2: + ; + iKey = iKey + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Return TRUE (non-zero) if the i-th entry in the pTabList SrcList can +// ** be implemented as a co-routine. The i-th entry is guaranteed to be +// ** a subquery. +// ** +// ** The subquery is implemented as a co-routine if all of the following are +// ** true: +// ** +// ** (1) The subquery will likely be implemented in the outer loop of +// ** the query. This will be the case if any one of the following +// ** conditions hold: +// ** (a) The subquery is the only term in the FROM clause +// ** (b) The subquery is the left-most term and a CROSS JOIN or similar +// ** requires it to be the outer loop +// ** (c) All of the following are true: +// ** (i) The subquery is the left-most subquery in the FROM clause +// ** (ii) There is nothing that would prevent the subquery from +// ** being used as the outer loop if the sqlite3WhereBegin() +// ** routine nominates it to that position. +// ** (iii) The query is not a UPDATE ... FROM +// ** (2) The subquery is not a CTE that should be materialized because +// ** (a) the AS MATERIALIZED keyword is used, or +// ** (b) the CTE is used multiple times and does not have the +// ** NOT MATERIALIZED keyword +// ** (3) The subquery is not part of a left operand for a RIGHT JOIN +// ** (4) The SQLITE_Coroutine optimization disable flag is not set +// ** (5) The subquery is not self-joined +// */ +func _fromClauseTermCanBeCoroutine(tls *libc.TLS, pParse uintptr, pTabList uintptr, i int32, selFlags int32) (r int32) { + var pCteUse, pItem uintptr + _, _ = pCteUse, pItem + pItem = pTabList + 8 + uintptr(i)*80 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x200>>9) != 0 { + pCteUse = *(*uintptr)(unsafe.Pointer(pItem + 56)) + if libc.Int32FromUint8((*TCteUse)(unsafe.Pointer(pCteUse)).FeM10d) == M10d_Yes { + return 0 + } /* (2a) */ + if (*TCteUse)(unsafe.Pointer(pCteUse)).FnUse >= int32(2) && libc.Int32FromUint8((*TCteUse)(unsafe.Pointer(pCteUse)).FeM10d) != int32(M10d_No) { + return 0 + } /* (2b) */ + } + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + return 0 + } /* (3) */ + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Coroutines)) != uint32(0) { + return 0 + } /* (4) */ + if _isSelfJoinView(tls, pTabList, pItem, i+int32(1), (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) != uintptr(0) { + return 0 /* (5) */ + } + if i == 0 { + if (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc == int32(1) { + return int32(1) + } /* (1a) */ + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pTabList + 8 + 1*80))).Ffg.Fjointype)&int32(JT_CROSS) != 0 { + return int32(1) + } /* (1b) */ + if selFlags&int32(SF_UpdateFrom) != 0 { + return 0 + } /* (1c-iii) */ + return int32(1) + } + if selFlags&int32(SF_UpdateFrom) != 0 { + return 0 + } /* (1c-iii) */ + for int32(1) != 0 { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_OUTER)|libc.Int32FromInt32(JT_CROSS)) != 0 { + return 0 + } /* (1c-ii) */ + if i == 0 { + break + } + i = i - 1 + pItem -= 80 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { + return 0 + } /* (1c-i) */ + } + return int32(1) +} + +// C documentation +// +// /* +// ** The xColumnLocale() API. +// */ +func _fts5ApiColumnLocale(tls *libc.TLS, pCtx uintptr, iCol int32, pzLocale uintptr, pnLocale uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pConfig, pCsr uintptr + var rc int32 + var _ /* nDummy at bp+8 */ int32 + var _ /* zDummy at bp+0 */ uintptr + _, _, _ = pConfig, pCsr, rc + rc = SQLITE_OK + pCsr = pCtx + pConfig = (*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig + **(**uintptr)(__ccgo_up(pzLocale)) = uintptr(0) + **(**int32)(__ccgo_up(pnLocale)) = 0 + if iCol < 0 || iCol >= (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol { + rc = int32(SQLITE_RANGE) + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(iCol)))) == 0 && 0 == _fts5IsContentless(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, int32(1)) && (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 { + rc = _fts5SeekCursor(tls, pCsr, 0) + if rc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = 0 + rc = _fts5TextFromStmt(tls, pConfig, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, iCol, bp, bp+8) + if rc == SQLITE_OK { + **(**uintptr)(__ccgo_up(pzLocale)) = (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpLocale + **(**int32)(__ccgo_up(pnLocale)) = (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FnLocale + } + _sqlite3Fts5ClearLocale(tls, pConfig) + } + } + } + return rc +} + +func _fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, i1, i2, rc int32 + var iRowid Ti64 + var pConfig, pCsr, pTab uintptr + var _ /* n at bp+8 */ int32 + var _ /* z at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = i, i1, i2, iRowid, pConfig, pCsr, pTab, rc + pCsr = pCtx + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + rc = SQLITE_OK + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_DOCSIZE) != 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { + iRowid = _fts5CursorRowid(tls, pCsr) + rc = _sqlite3Fts5StorageDocsize(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iRowid, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize) + } else { + if !((*TFts5Config)(unsafe.Pointer(pConfig)).FzContent != 0) || (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_UNINDEXED) { + i = 0 + for { + if !(i < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i)))) == 0 { + **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4)) = -int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + } else { + rc = _fts5SeekCursor(tls, pCsr, 0) + i1 = 0 + for { + if !(rc == SQLITE_OK && i1 < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i1)))) == 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = 0 + **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i1)*4)) = 0 + rc = _fts5TextFromStmt(tls, pConfig, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, i1, bp, bp+8) + if rc == SQLITE_OK { + rc = _sqlite3Fts5Tokenize(tls, pConfig, int32(FTS5_TOKENIZE_AUX), **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize+uintptr(i1)*4, __ccgo_fp(_fts5ColumnSizeCb)) + } + _sqlite3Fts5ClearLocale(tls, pConfig) + } + goto _2 + _2: + ; + i1 = i1 + 1 + } + } + } + **(**int32)(__ccgo_up(pCsr + 80)) &= ^libc.Int32FromInt32(FTS5CSR_REQUIRE_DOCSIZE) + } + if iCol < 0 { + **(**int32)(__ccgo_up(pnToken)) = 0 + i2 = 0 + for { + if !(i2 < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + **(**int32)(__ccgo_up(pnToken)) += **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i2)*4)) + goto _3 + _3: + ; + i2 = i2 + 1 + } + } else { + if iCol < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol { + **(**int32)(__ccgo_up(pnToken)) = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(iCol)*4)) + } else { + **(**int32)(__ccgo_up(pnToken)) = 0 + rc = int32(SQLITE_RANGE) + } + } + return rc +} + +func _fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter uintptr, piCol uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i1, rc, v1 int32 + var pConfig, pCsr, pSorter, v2 uintptr + var _ /* n at bp+0 */ int32 + var _ /* n at bp+4 */ int32 + _, _, _, _, _, _, _ = i1, pConfig, pCsr, pSorter, rc, v1, v2 + rc = SQLITE_OK + pCsr = pCtx + pConfig = (*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_COLUMNS) { + pSorter = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter + if pSorter != 0 { + if iPhrase == 0 { + v1 = 0 + } else { + v1 = *(*int32)(unsafe.Pointer(pSorter + 28 + uintptr(iPhrase-int32(1))*4)) + } + i1 = v1 + **(**int32)(__ccgo_up(bp)) = *(*int32)(unsafe.Pointer(pSorter + 28 + uintptr(iPhrase)*4)) - i1 + (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa = (*TFts5Sorter)(unsafe.Pointer(pSorter)).FaPoslist + uintptr(i1) + } else { + rc = _sqlite3Fts5ExprPhraseCollist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, pIter, bp) + } + if rc == SQLITE_OK { + if (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa != 0 { + v2 = (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(**(**int32)(__ccgo_up(bp))) + } else { + v2 = uintptr(0) + } + (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fb = v2 + **(**int32)(__ccgo_up(piCol)) = 0 + _fts5ApiPhraseNextColumn(tls, pCtx, pIter, piCol) + } + } else { + rc = _fts5CsrPoslist(tls, pCsr, iPhrase, pIter, bp+4) + if rc == SQLITE_OK { + if (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa != 0 { + v2 = (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(**(**int32)(__ccgo_up(bp + 4))) + } else { + v2 = uintptr(0) + } + (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fb = v2 + if **(**int32)(__ccgo_up(bp + 4)) <= 0 { + **(**int32)(__ccgo_up(piCol)) = -int32(1) + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa))) == int32(0x01) { + **(**uintptr)(__ccgo_up(pIter)) += uintptr(int32(1) + _sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa+1, piCol)) + } else { + **(**int32)(__ccgo_up(piCol)) = 0 + } + } + } + } + return rc +} + +func _fts5AppendRowid(tls *libc.TLS, p uintptr, iDelta Tu64, pUnused uintptr, pBuf uintptr) { + _ = pUnused + _sqlite3Fts5BufferAppendVarint(tls, p+60, pBuf, libc.Int64FromUint64(iDelta)) +} + +// C documentation +// +// /* +// ** Compare the contents of the two buffers using memcmp(). If one buffer +// ** is a prefix of the other, it is considered the lesser. +// ** +// ** Return -ve if pLeft is smaller than pRight, 0 if they are equal or +// ** +ve if pRight is smaller than pLeft. In other words: +// ** +// ** res = *pLeft - *pRight +// */ +func _fts5BufferCompare(tls *libc.TLS, pLeft uintptr, pRight uintptr) (r int32) { + var nCmp, res, v1 int32 + _, _, _ = nCmp, res, v1 + if (*TFts5Buffer)(unsafe.Pointer(pLeft)).Fn < (*TFts5Buffer)(unsafe.Pointer(pRight)).Fn { + v1 = (*TFts5Buffer)(unsafe.Pointer(pLeft)).Fn + } else { + v1 = (*TFts5Buffer)(unsafe.Pointer(pRight)).Fn + } + nCmp = v1 + if nCmp <= 0 { + v1 = 0 + } else { + v1 = libc.Xmemcmp(tls, (*TFts5Buffer)(unsafe.Pointer(pLeft)).Fp, (*TFts5Buffer)(unsafe.Pointer(pRight)).Fp, libc.Uint64FromInt32(nCmp)) + } + res = v1 + if res == 0 { + v1 = (*TFts5Buffer)(unsafe.Pointer(pLeft)).Fn - (*TFts5Buffer)(unsafe.Pointer(pRight)).Fn + } else { + v1 = res + } + return v1 +} + +// C documentation +// +// /* +// ** Ensure that the Fts5Cursor.nInstCount and aInst[] variables are populated +// ** correctly for the current view. Return SQLITE_OK if successful, or an +// ** SQLite error code otherwise. +// */ +func _fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aInst, aIter uintptr + var i, iBest, nCol, nInst, nIter, nNewSize, v3 int32 + var nByte Tsqlite3_int64 + var _ /* a at bp+8 */ uintptr + var _ /* n at bp+16 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = aInst, aIter, i, iBest, nByte, nCol, nInst, nIter, nNewSize, v3 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Number of iterators/phrases */ + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FnCol + nIter = _sqlite3Fts5ExprPhraseCount(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter == uintptr(0) { + nByte = libc.Int64FromUint64(uint64(32) * libc.Uint64FromInt32(nIter)) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter = _sqlite3Fts5MallocZero(tls, bp, nByte) + } + aIter = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter + if aIter != 0 { + nInst = 0 + /* Initialize all iterators */ + i = 0 + for { + if !(i < nIter && **(**int32)(__ccgo_up(bp)) == SQLITE_OK) { + break + } + **(**int32)(__ccgo_up(bp)) = _fts5CsrPoslist(tls, pCsr, i, bp+8, bp+16) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + _sqlite3Fts5PoslistReaderInit(tls, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 16)), aIter+uintptr(i)*32) + } + goto _1 + _1: + ; + i = i + 1 + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + for int32(1) != 0 { + iBest = -int32(1) + i = 0 + for { + if !(i < nIter) { + break + } + if libc.Int32FromUint8((**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).FbEof) == 0 && (iBest < 0 || (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(i)*32))).FiPos < (**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(iBest)*32))).FiPos) { + iBest = i + } + goto _2 + _2: + ; + i = i + 1 + } + if iBest < 0 { + break + } + nInst = nInst + 1 + if nInst >= (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstAlloc { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstAlloc != 0 { + v3 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstAlloc * int32(2) + } else { + v3 = int32(32) + } + nNewSize = v3 + aInst = Xsqlite3_realloc64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst, uint64(libc.Uint64FromInt32(nNewSize)*uint64(4)*uint64(3))) + if aInst != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst = aInst + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstAlloc = nNewSize + } else { + nInst = nInst - 1 + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_NOMEM) + break + } + } + aInst = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(int32(3)*(nInst-int32(1)))*4 + **(**int32)(__ccgo_up(aInst)) = iBest + **(**int32)(__ccgo_up(aInst + 1*4)) = int32((**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(iBest)*32))).FiPos >> libc.Int32FromInt32(32) & libc.Int64FromInt32(0x7FFFFFFF)) + **(**int32)(__ccgo_up(aInst + 2*4)) = int32((**(**TFts5PoslistReader)(__ccgo_up(aIter + uintptr(iBest)*32))).FiPos & libc.Int64FromInt32(0x7FFFFFFF)) + if **(**int32)(__ccgo_up(aInst + 1*4)) >= nCol { + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= 0 { + return int32(SQLITE_ERROR) + } + iVal = (**(**TFts5Enum)(__ccgo_up(aEnum + uintptr(i)*16))).FeVal + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(peVal)) = iVal + if iVal < 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = SQLITE_OK + } + return v2 +} + +// C documentation +// +// /* +// ** Advance the iterator passed as the only argument. If the end of the +// ** doclist-index page is reached, return non-zero. +// */ +func _fts5DlidxLvlNext(tls *libc.TLS, pLvl uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iOff int32 + var pData, v2 uintptr + var _ /* iVal at bp+0 */ Tu64 + _, _, _ = iOff, pData, v2 + pData = (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData + if (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff == 0 { + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = int32(1) + **(**int32)(__ccgo_up(pLvl + 8)) += _sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp+1, pLvl+20) + **(**int32)(__ccgo_up(pLvl + 8)) += libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr((*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff), pLvl+24)) + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff = (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff + } else { + iOff = (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff + for { + if !(iOff < (*TFts5Data)(unsafe.Pointer(pData)).Fnn) { + break + } + if **(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pData)).Fp + uintptr(iOff))) != 0 { + break + } + goto _1 + _1: + ; + iOff = iOff + 1 + } + if iOff < (*TFts5Data)(unsafe.Pointer(pData)).Fnn { + **(**int32)(__ccgo_up(pLvl + 20)) += iOff - (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff + int32(1) + iOff = iOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp+uintptr(iOff), bp)) + v2 = pLvl + 24 + *(*Ti64)(unsafe.Pointer(v2)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v2))) + **(**Tu64)(__ccgo_up(bp))) + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = iOff + } else { + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof = int32(1) + } + } + return (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof +} + +// C documentation +// +// /* +// ** Move the iterator passed as the only argument to the previous entry. +// */ +func _fts5DlidxLvlPrev(tls *libc.TLS, pLvl uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, v1 uintptr + var iOff, ii, nZero int32 + var _ /* delta at bp+0 */ Tu64 + _, _, _, _, _ = a, iOff, ii, nZero, v1 + iOff = (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff + if iOff <= (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff { + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof = int32(1) + } else { + a = (*TFts5Data)(unsafe.Pointer((*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)).Fp + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = 0 + _fts5DlidxLvlNext(tls, pLvl) + for int32(1) != 0 { + nZero = 0 + ii = (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff + **(**Tu64)(__ccgo_up(bp)) = uint64(0) + for libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a + uintptr(ii)))) == 0 { + nZero = nZero + 1 + ii = ii + 1 + } + ii = ii + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, a+uintptr(ii), bp)) + if ii >= iOff { + break + } + **(**int32)(__ccgo_up(pLvl + 20)) += nZero + int32(1) + v1 = pLvl + 24 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + **(**Tu64)(__ccgo_up(bp))) + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = ii + } + } + return (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof +} + +func _fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { + var pNear uintptr + _ = pNear + switch (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType { + case int32(FTS5_STRING): + pNear = (*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == int32(1) && (*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24)))).FnTerm == int32(1) && (*(*TFts5ExprTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24)) + 32))).FpSynonym == uintptr(0) && libc.Int32FromUint8((*(*TFts5ExprTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24)) + 32))).FbFirst) == 0 { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType = int32(FTS5_TERM) + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FxNext = __ccgo_fp(_fts5ExprNodeNext_TERM) + } else { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FxNext = __ccgo_fp(_fts5ExprNodeNext_STRING) + } + case int32(FTS5_OR): + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FxNext = __ccgo_fp(_fts5ExprNodeNext_OR) + case int32(FTS5_AND): + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FxNext = __ccgo_fp(_fts5ExprNodeNext_AND) + default: + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FxNext = __ccgo_fp(_fts5ExprNodeNext_NOT) + break + } +} + +// C documentation +// +// /* +// ** Initialize all term iterators in the pNear object. If any term is found +// ** to match no documents at all, return immediately without initializing any +// ** further iterators. +// ** +// ** If an error occurs, return an SQLite error code. Otherwise, return +// ** SQLITE_OK. It is not considered an error if some term matches zero +// ** documents. +// */ +func _fts5ExprNearInitAll(tls *libc.TLS, pExpr uintptr, pNode uintptr) (r int32) { + var bHit, i, j, rc, v4, v5 int32 + var p, pNear, pPhrase, pTerm uintptr + _, _, _, _, _, _, _, _, _, _ = bHit, i, j, p, pNear, pPhrase, pTerm, rc, v4, v5 + pNear = (*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + pPhrase = *(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(i)*8)) + if (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm == 0 { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = int32(1) + return SQLITE_OK + } else { + j = 0 + for { + if !(j < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + pTerm = pPhrase + 32 + uintptr(j)*40 + bHit = 0 + p = pTerm + for { + if !(p != 0) { + break + } + if (*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter != 0 { + _sqlite3Fts5IterClose(tls, (*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter) + (*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter = uintptr(0) + } + if (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FbPrefix != 0 { + v4 = int32(FTS5INDEX_QUERY_PREFIX) + } else { + v4 = 0 + } + if (*TFts5Expr)(unsafe.Pointer(pExpr)).FbDesc != 0 { + v5 = int32(FTS5INDEX_QUERY_DESC) + } else { + v5 = 0 + } + rc = _sqlite3Fts5IndexQuery(tls, (*TFts5Expr)(unsafe.Pointer(pExpr)).FpIndex, (*TFts5ExprTerm)(unsafe.Pointer(p)).FpTerm, (*TFts5ExprTerm)(unsafe.Pointer(p)).FnQueryTerm, v4|v5, (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FpColset, p+24) + if rc != SQLITE_OK { + return rc + } + if 0 == libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) { + bHit = int32(1) + } + goto _3 + _3: + ; + p = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpSynonym + } + if bHit == 0 { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = int32(1) + return SQLITE_OK + } + goto _2 + _2: + ; + j = j + 1 + } + } + goto _1 + _1: + ; + i = i + 1 + } + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 + return SQLITE_OK +} + +func _fts5ExprNearTest(tls *libc.TLS, pRc uintptr, pExpr uintptr, pNode uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var pIter, pIter1, pNear, pPhrase, pPhrase1, pTerm uintptr + var _ /* bMatch at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _ = i, pIter, pIter1, pNear, pPhrase, pPhrase1, pTerm + pNear = (*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(pRc)) + if (*TFts5Config)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail != FTS5_DETAIL_FULL { + pPhrase = *(*uintptr)(unsafe.Pointer(pNear + 24)) + (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = 0 + pTerm = pPhrase + 32 + for { + if !(pTerm != 0) { + break + } + pIter = (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter + if libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer(pIter)).FbEof) == 0 { + if (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid && (*TFts5IndexIter)(unsafe.Pointer(pIter)).FnData > 0 { + (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = int32(1) + } + } + goto _1 + _1: + ; + pTerm = (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym + } + return (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn + } else { + /* Check that each phrase in the nearset matches the current row. + ** Populate the pPhrase->poslist buffers at the same time. If any + ** phrase is not a match, break out of the loop early. */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + pPhrase1 = *(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(i)*8)) + if (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase1)).FnTerm > int32(1) || (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase1 + 32))).FpSynonym != 0 || (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0 || (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase1 + 32))).FbFirst != 0 { + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**int32)(__ccgo_up(bp)) = _fts5ExprPhraseIsMatch(tls, pNode, pPhrase1, bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + break + } + } else { + pIter1 = (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase1 + 32))).FpIter + _sqlite3Fts5BufferSet(tls, bp, pPhrase1+8, (*TFts5IndexIter)(unsafe.Pointer(pIter1)).FnData, (*TFts5IndexIter)(unsafe.Pointer(pIter1)).FpData) + } + goto _2 + _2: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(pRc)) = **(**int32)(__ccgo_up(bp)) + if i == (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase && (i == int32(1) || _fts5ExprNearIsMatch(tls, pRc, pNear) != 0) { + return int32(1) + } + return 0 + } + return r +} + +// C documentation +// +// /* +// ** Advance the first term iterator in the first phrase of pNear. Set output +// ** variable *pbEof to true if it reaches EOF or if an error occurs. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code if an error +// ** occurs. +// */ +func _fts5ExprNodeNext_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom Ti64) (r int32) { + var bEof, rc int32 + var iRowid, ii Ti64 + var p, pIter, pTerm uintptr + _, _, _, _, _, _, _ = bEof, iRowid, ii, p, pIter, pTerm, rc + pTerm = *(*uintptr)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24)) + 32 + rc = SQLITE_OK + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 + if (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { + bEof = int32(1) + /* Find the firstest rowid any synonym points to. */ + iRowid = _fts5ExprSynonymRowid(tls, pTerm, (*TFts5Expr)(unsafe.Pointer(pExpr)).FbDesc, uintptr(0)) + /* Advance each iterator that currently points to iRowid. Or, if iFrom + ** is valid - each iterator that points to a rowid before iFrom. */ + p = pTerm + for { + if !(p != 0) { + break + } + if libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) == 0 { + ii = (*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FiRowid + if ii == iRowid || bFromValid != 0 && ii != iFrom && libc.BoolInt32(ii > iFrom) == (*TFts5Expr)(unsafe.Pointer(pExpr)).FbDesc { + if bFromValid != 0 { + rc = _sqlite3Fts5IterNextFrom(tls, (*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter, iFrom) + } else { + rc = _sqlite3Fts5IterNext(tls, (*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter) + } + if rc != SQLITE_OK { + break + } + if libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) == 0 { + bEof = 0 + } + } else { + bEof = 0 + } + } + goto _1 + _1: + ; + p = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpSynonym + } + /* Set the EOF flag if either all synonym iterators are at EOF or an + ** error has occurred. */ + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = libc.BoolInt32(rc != 0 || bEof != 0) + } else { + pIter = (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter + if bFromValid != 0 { + rc = _sqlite3Fts5IterNextFrom(tls, pIter, iFrom) + } else { + rc = _sqlite3Fts5IterNext(tls, pIter) + } + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = libc.BoolInt32(rc != 0 || (*TFts5IndexIter)(unsafe.Pointer(pIter)).FbEof != 0) + } + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 { + rc = _fts5ExprNodeTest_STRING(tls, pExpr, pNode) + } + return rc +} + +// C documentation +// +// /* +// ** xNext() method for a node of type FTS5_TERM. +// */ +func _fts5ExprNodeNext_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom Ti64) (r int32) { + var pIter uintptr + var rc int32 + _, _ = pIter, rc + pIter = (*(*TFts5ExprTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24)) + 32))).FpIter + if bFromValid != 0 { + rc = _sqlite3Fts5IterNextFrom(tls, pIter, iFrom) + } else { + rc = _sqlite3Fts5IterNext(tls, pIter) + } + if rc == SQLITE_OK && libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer(pIter)).FbEof) == 0 { + rc = _fts5ExprNodeTest_TERM(tls, pExpr, pNode) + } else { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = int32(1) + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 + } + return rc +} + +func _fts5ExprPopulatePoslistsCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) (r int32) { + var i, iCol, iTokOff, nQuery, rc int32 + var iRowid Ti64 + var p, pExpr, pT uintptr + _, _, _, _, _, _, _, _, _ = i, iCol, iRowid, iTokOff, nQuery, p, pExpr, pT, rc + p = pCtx + pExpr = (*TFts5ExprCtx)(unsafe.Pointer(p)).FpExpr + nQuery = nToken + iRowid = (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pExpr)).FpRoot)).FiRowid + _ = iUnused1 + _ = iUnused2 + if nQuery > int32(FTS5_MAX_TOKEN_SIZE) { + nQuery = int32(FTS5_MAX_TOKEN_SIZE) + } + if (*TFts5Config)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FbTokendata != 0 { + nQuery = _fts5QueryTerm(tls, pToken, nQuery) + } + if tflags&int32(FTS5_TOKEN_COLOCATED) == 0 { + (*TFts5ExprCtx)(unsafe.Pointer(p)).FiOff = (*TFts5ExprCtx)(unsafe.Pointer(p)).FiOff + 1 + } + i = 0 + for { + if !(i < (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase) { + break + } + if (**(**TFts5PoslistPopulator)(__ccgo_up((*TFts5ExprCtx)(unsafe.Pointer(p)).FaPopulator + uintptr(i)*16))).FbOk == 0 { + goto _1 + } + pT = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*8)) + 32 + for { + if !(pT != 0) { + break + } + if ((*TFts5ExprTerm)(unsafe.Pointer(pT)).FnQueryTerm == nQuery || (*TFts5ExprTerm)(unsafe.Pointer(pT)).FnQueryTerm < nQuery && (*TFts5ExprTerm)(unsafe.Pointer(pT)).FbPrefix != 0) && libc.Xmemcmp(tls, (*TFts5ExprTerm)(unsafe.Pointer(pT)).FpTerm, pToken, libc.Uint64FromInt32((*TFts5ExprTerm)(unsafe.Pointer(pT)).FnQueryTerm)) == 0 { + rc = _sqlite3Fts5PoslistWriterAppend(tls, **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*8))+8, (*TFts5ExprCtx)(unsafe.Pointer(p)).FaPopulator+uintptr(i)*16, (*TFts5ExprCtx)(unsafe.Pointer(p)).FiOff) + if rc == SQLITE_OK && ((*TFts5Config)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FbTokendata != 0 || (*TFts5ExprTerm)(unsafe.Pointer(pT)).FbPrefix != 0) { + iCol = int32((*TFts5ExprCtx)(unsafe.Pointer(p)).FiOff >> int32(32)) + iTokOff = int32((*TFts5ExprCtx)(unsafe.Pointer(p)).FiOff & int64(0x7FFFFFFF)) + rc = _sqlite3Fts5IndexIterWriteTokendata(tls, (*TFts5ExprTerm)(unsafe.Pointer(pT)).FpIter, pToken, nToken, iRowid, iCol, iTokOff) + } + if rc != 0 { + return rc + } + break + } + goto _2 + _2: + ; + pT = (*TFts5ExprTerm)(unsafe.Pointer(pT)).FpSynonym + } + goto _1 + _1: + ; + i = i + 1 + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Arguments pLeft and pRight point to linked-lists of hash-entry objects, +// ** each sorted in key order. This function merges the two lists into a +// ** single list and returns a pointer to its first element. +// */ +func _fts5HashEntryMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var cmp, nMin, v1 int32 + var p1, p2, ppOut, zKey1, zKey2 uintptr + var _ /* pRet at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = cmp, nMin, p1, p2, ppOut, zKey1, zKey2, v1 + p1 = pLeft + p2 = pRight + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + ppOut = bp + for p1 != 0 || p2 != 0 { + if p1 == uintptr(0) { + **(**uintptr)(__ccgo_up(ppOut)) = p2 + p2 = uintptr(0) + } else { + if p2 == uintptr(0) { + **(**uintptr)(__ccgo_up(ppOut)) = p1 + p1 = uintptr(0) + } else { + zKey1 = p1 + 1*48 + zKey2 = p2 + 1*48 + if (*TFts5HashEntry)(unsafe.Pointer(p1)).FnKey < (*TFts5HashEntry)(unsafe.Pointer(p2)).FnKey { + v1 = (*TFts5HashEntry)(unsafe.Pointer(p1)).FnKey + } else { + v1 = (*TFts5HashEntry)(unsafe.Pointer(p2)).FnKey + } + nMin = v1 + cmp = libc.Xmemcmp(tls, zKey1, zKey2, libc.Uint64FromInt32(nMin)) + if cmp == 0 { + cmp = (*TFts5HashEntry)(unsafe.Pointer(p1)).FnKey - (*TFts5HashEntry)(unsafe.Pointer(p2)).FnKey + } + if cmp > 0 { + /* p2 is smaller */ + **(**uintptr)(__ccgo_up(ppOut)) = p2 + ppOut = p2 + 8 + p2 = (*TFts5HashEntry)(unsafe.Pointer(p2)).FpScanNext + } else { + /* p1 is smaller */ + **(**uintptr)(__ccgo_up(ppOut)) = p1 + ppOut = p1 + 8 + p1 = (*TFts5HashEntry)(unsafe.Pointer(p1)).FpScanNext + } + **(**uintptr)(__ccgo_up(ppOut)) = uintptr(0) + } + } + } + return **(**uintptr)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** If this is not a contentless_delete=1 table, or if the 'deletemerge' +// ** configuration option is set to 0, then this function always returns -1. +// ** Otherwise, it searches the structure object passed as the second argument +// ** for a level suitable for merging due to having a large number of +// ** tombstones in the tombstone hash. If one is found, its index is returned. +// ** Otherwise, if there is no suitable level, -1. +// */ +func _fts5IndexFindDeleteMerge(tls *libc.TLS, p uintptr, pStruct uintptr) (r int32) { + var iRet, iSeg, ii, nBest, nPercent int32 + var nEntry, nTomb Ti64 + var pConfig, pLvl uintptr + _, _, _, _, _, _, _, _, _ = iRet, iSeg, ii, nBest, nEntry, nPercent, nTomb, pConfig, pLvl + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + iRet = -int32(1) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete != 0 && (*TFts5Config)(unsafe.Pointer(pConfig)).FnDeleteMerge > 0 { + nBest = 0 + ii = 0 + for { + if !(ii < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + pLvl = pStruct + 32 + uintptr(ii)*16 + nEntry = 0 + nTomb = 0 + iSeg = 0 + for { + if !(iSeg < (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg) { + break + } + nEntry = libc.Int64FromUint64(uint64(nEntry) + (**(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*56))).FnEntry) + nTomb = libc.Int64FromUint64(uint64(nTomb) + (**(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*56))).FnEntryTombstone) + goto _2 + _2: + ; + iSeg = iSeg + 1 + } + if nEntry > 0 { + nPercent = int32(nTomb * int64(100) / nEntry) + if nPercent >= (*TFts5Config)(unsafe.Pointer(pConfig)).FnDeleteMerge && nPercent > nBest { + iRet = ii + nBest = nPercent + } + } + /* If pLvl is already the input level to an ongoing merge, look no + ** further for a merge candidate. The caller should be allowed to + ** continue merging from pLvl first. */ + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 { + break + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + return iRet +} + +func _fts5IndexOptimizeStruct(tls *libc.TLS, p uintptr, pStruct uintptr) (r uintptr) { + var i, iLvl, iSeg, iSegOut, nMerge, nSeg, nThis, v2 int32 + var nByte Tsqlite3_int64 + var pLvl, pNew uintptr + _, _, _, _, _, _, _, _, _, _, _ = i, iLvl, iSeg, iSegOut, nByte, nMerge, nSeg, nThis, pLvl, pNew, v2 + pNew = uintptr(0) + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32) + libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(16)) + nSeg = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment + /* Figure out if this structure requires optimization. A structure does + ** not require optimization if either: + ** + ** 1. it consists of fewer than two segments, or + ** 2. all segments are on the same level, or + ** 3. all segments except one are currently inputs to a merge operation. + ** + ** In the first case, if there are no tombstone hash pages, return NULL. In + ** the second, increment the ref-count on *pStruct and return a copy of the + ** pointer to it. + */ + if nSeg == 0 { + return uintptr(0) + } + i = 0 + for { + if !(i < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + nThis = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(i)*16))).FnSeg + nMerge = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(i)*16))).FnMerge + if nThis > 0 && (nThis == nSeg || nThis == nSeg-int32(1) && nMerge == nThis) { + if nSeg == int32(1) && nThis == int32(1) && (**(**TFts5StructureSegment)(__ccgo_up((*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(i)*16))).FaSeg))).FnPgTombstone == 0 { + return uintptr(0) + } + _fts5StructureRef(tls, pStruct) + return pStruct + } + goto _1 + _1: + ; + i = i + 1 + } + nByte = libc.Int64FromUint64(uint64(nByte) + libc.Uint64FromInt64(int64((*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel)+libc.Int64FromInt32(1))*libc.Uint64FromInt64(16)) + pNew = _sqlite3Fts5MallocZero(tls, p+60, nByte) + if pNew != 0 { + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(nSeg) * uint64(56)) + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel+int32(1) < int32(FTS5_MAX_LEVEL) { + v2 = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel + int32(1) + } else { + v2 = int32(FTS5_MAX_LEVEL) + } + (*TFts5Structure)(unsafe.Pointer(pNew)).FnLevel = v2 + (*TFts5Structure)(unsafe.Pointer(pNew)).FnRef = int32(1) + (*TFts5Structure)(unsafe.Pointer(pNew)).FnWriteCounter = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnWriteCounter + (*TFts5Structure)(unsafe.Pointer(pNew)).FnOriginCntr = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnOriginCntr + pLvl = pNew + 32 + uintptr((*TFts5Structure)(unsafe.Pointer(pNew)).FnLevel-int32(1))*16 + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = _sqlite3Fts5MallocZero(tls, p+60, nByte) + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg != 0 { + iSegOut = 0 + /* Iterate through all segments, from oldest to newest. Add them to + ** the new Fts5Level object so that pLvl->aSeg[0] is the oldest + ** segment in the data structure. */ + iLvl = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel - int32(1) + for { + if !(iLvl >= 0) { + break + } + iSeg = 0 + for { + if !(iSeg < (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg) { + break + } + **(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSegOut)*56)) = **(**TFts5StructureSegment)(__ccgo_up((*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr(iSeg)*56)) + iSegOut = iSegOut + 1 + goto _4 + _4: + ; + iSeg = iSeg + 1 + } + goto _3 + _3: + ; + iLvl = iLvl - 1 + } + v2 = nSeg + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg = v2 + (*TFts5Structure)(unsafe.Pointer(pNew)).FnSegment = v2 + } else { + Xsqlite3_free(tls, pNew) + pNew = uintptr(0) + } + } + return pNew +} + +// C documentation +// +// /* +// ** Add a tombstone for rowid iRowid to segment pSeg. +// */ +func _fts5IndexTombstoneAdd(tls *libc.TLS, p uintptr, pSeg uintptr, iRowid Tu64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iPg, ii, szKey, v1, v2 int32 + var iTombstoneRowid Ti64 + var pPg uintptr + var _ /* apHash at bp+8 */ uintptr + var _ /* nHash at bp+0 */ int32 + _, _, _, _, _, _, _ = iPg, iTombstoneRowid, ii, pPg, szKey, v1, v2 + pPg = uintptr(0) + iPg = -int32(1) + szKey = 0 + **(**int32)(__ccgo_up(bp)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + (*TFts5Index)(unsafe.Pointer(p)).FnContentlessDelete = (*TFts5Index)(unsafe.Pointer(p)).FnContentlessDelete + 1 + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnPgTombstone > 0 { + iPg = libc.Int32FromUint64(iRowid % libc.Uint64FromInt32((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnPgTombstone)) + pPg = _fts5DataRead(tls, p, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid+libc.Int32FromInt32(1)< uint64(0xFFFFFFFF) { + szKey = int32(8) + } + /* Rebuild the hash table */ + _fts5IndexTombstoneRebuild(tls, p, pSeg, pPg, iPg, szKey, bp, bp+8) + /* If all has succeeded, write the new rowid into one of the new hash + ** table pages, then write them all out to disk. */ + if **(**int32)(__ccgo_up(bp)) != 0 { + ii = 0 + _fts5IndexTombstoneAddToPage(tls, **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + uintptr(iRowid%libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))))*8)), int32(1), **(**int32)(__ccgo_up(bp)), iRowid) + ii = 0 + for { + if !(ii < **(**int32)(__ccgo_up(bp))) { + break + } + iTombstoneRowid = int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid+libc.Int32FromInt32(1)< ((*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz-int32(8))/szKey { + v1 = MINSLOT + } else { + v1 = ((*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz - int32(8)) / szKey + } + nSlotPerPage = v1 + nSlot = 0 /* Number of slots in each output page */ + nOut = 0 + /* Figure out how many output pages (nOut) and how many slots per + ** page (nSlot). There are three possibilities: + ** + ** 1. The hash table does not yet exist. In this case the new hash + ** table will consist of a single page with MINSLOT slots. + ** + ** 2. The hash table exists but is currently a single page. In this + ** case an attempt is made to grow the page to accommodate the new + ** entry. The page is allowed to grow up to nSlotPerPage (see above) + ** slots. + ** + ** 3. The hash table already consists of more than one page, or of + ** a single page already so large that it cannot be grown. In this + ** case the new hash consists of (nPg*2+1) pages of nSlotPerPage + ** slots each, where nPg is the current number of pages in the + ** hash table. + */ + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnPgTombstone == 0 { + /* Case 1. */ + nOut = int32(1) + nSlot = MINSLOT + } else { + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnPgTombstone == int32(1) { + /* Case 2. */ + nElem = libc.Int32FromUint32(_fts5GetU32(tls, (*TFts5Data)(unsafe.Pointer(pData1)).Fp+4)) + nOut = int32(1) + if nElem*int32(4) > MINSLOT { + v1 = nElem * int32(4) + } else { + v1 = MINSLOT + } + nSlot = v1 + if nSlot > nSlotPerPage { + nOut = 0 + } + } + } + if nOut == 0 { + /* Case 3. */ + nOut = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnPgTombstone*int32(2) + int32(1) + nSlot = nSlotPerPage + } + /* Allocate the required array and output pages */ + for int32(1) != 0 { + res = 0 + ii = 0 + szPage = 0 + apOut = uintptr(0) + /* Allocate space for the new hash table */ + apOut = _sqlite3Fts5MallocZero(tls, p+60, libc.Int64FromUint64(uint64(8)*libc.Uint64FromInt32(nOut))) + szPage = int32(8) + nSlot*szKey + ii = 0 + for { + if !(ii < nOut) { + break + } + pNew = _sqlite3Fts5MallocZero(tls, p+60, libc.Int64FromUint64(uint64(16)+libc.Uint64FromInt32(szPage))) + if pNew != 0 { + (*TFts5Data)(unsafe.Pointer(pNew)).Fnn = szPage + (*TFts5Data)(unsafe.Pointer(pNew)).Fp = pNew + 1*16 + **(**uintptr)(__ccgo_up(apOut + uintptr(ii)*8)) = pNew + } + goto _3 + _3: + ; + ii = ii + 1 + } + /* Rebuild the hash table. */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + res = _fts5IndexTombstoneRehash(tls, p, pSeg, pData1, iPg1, szKey, nOut, apOut) + } + if res == 0 { + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + _fts5IndexFreeArray(tls, apOut, nOut) + apOut = uintptr(0) + nOut = 0 + } + **(**int32)(__ccgo_up(pnOut)) = nOut + **(**uintptr)(__ccgo_up(papOut)) = apOut + break + } + /* If control flows to here, it was not possible to rebuild the hash + ** table. Free all buffers and then try again with more pages. */ + _fts5IndexFreeArray(tls, apOut, nOut) + nSlot = nSlotPerPage + nOut = nOut*int32(2) + int32(1) + } +} + +// C documentation +// +// /* +// ** This function attempts to build a new hash containing all the keys +// ** currently in the tombstone hash table for segment pSeg. The new +// ** hash will be stored in the nOut buffers passed in array apOut[]. +// ** All pages of the new hash use key-size szKey (4 or 8). +// ** +// ** Return 0 if the hash is successfully rebuilt into the nOut pages. +// ** Or non-zero if it is not (because one page became overfull). In this +// ** case the caller should retry with a larger nOut parameter. +// ** +// ** Parameter pData1 is page iPg1 of the hash table being rebuilt. +// */ +func _fts5IndexTombstoneRehash(tls *libc.TLS, p uintptr, pSeg uintptr, pData1 uintptr, iPg1 int32, szKey int32, nOut int32, apOut uintptr) (r int32) { + var aSlot, aSlot1, pData, pFree, pPg, v3 uintptr + var iIn, ii, nSlotIn, res, szKeyIn, v4 int32 + var iVal Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = aSlot, aSlot1, iIn, iVal, ii, nSlotIn, pData, pFree, pPg, res, szKeyIn, v3, v4 + res = 0 + /* Initialize the headers of all the output pages */ + ii = 0 + for { + if !(ii < nOut) { + break + } + **(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(apOut + uintptr(ii)*8)))).Fp)) = libc.Uint8FromInt32(szKey) + _fts5PutU32(tls, (*TFts5Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(apOut + uintptr(ii)*8)))).Fp+4, uint32(0)) + goto _1 + _1: + ; + ii = ii + 1 + } + /* Loop through the current pages of the hash table. */ + ii = 0 + for { + if !(res == 0 && ii < (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnPgTombstone) { + break + } + pData = uintptr(0) /* Page ii of the current hash table */ + pFree = uintptr(0) /* Free this at the end of the loop */ + if iPg1 == ii { + pData = pData1 + } else { + v3 = _fts5DataRead(tls, p, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid+libc.Int32FromInt32(1)<= int64((*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf) { + _fts5IndexCorruptRowid(tls, p, iRowid) + } else { + if iTermOff == int64(**(**int32)(__ccgo_up(bp + 32))) { + iOff = iOff + int64(_sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+36)) + if iOff+int64(**(**int32)(__ccgo_up(bp + 36))) > int64((*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf) { + _fts5IndexCorruptRowid(tls, p, iRowid) + } else { + _sqlite3Fts5BufferSet(tls, p+60, bp, **(**int32)(__ccgo_up(bp + 36)), (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff)) + } + } else { + iOff = iOff + int64(_sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+40)) + iOff = iOff + int64(_sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+44)) + if **(**int32)(__ccgo_up(bp + 40)) > (**(**TFts5Buffer)(__ccgo_up(bp))).Fn || iOff+int64(**(**int32)(__ccgo_up(bp + 44))) > int64((*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf) { + _fts5IndexCorruptRowid(tls, p, iRowid) + } else { + (**(**TFts5Buffer)(__ccgo_up(bp))).Fn = **(**int32)(__ccgo_up(bp + 40)) + _sqlite3Fts5BufferAppendBlob(tls, p+60, bp, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 44))), (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff)) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + res = _fts5BufferCompare(tls, bp, bp+16) + if res <= 0 { + _fts5IndexCorruptRowid(tls, p, iRowid) + } + } + } + } + _sqlite3Fts5BufferSet(tls, p+60, bp+16, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp) + } + _sqlite3Fts5BufferFree(tls, bp) + _sqlite3Fts5BufferFree(tls, bp+16) +} + +// C documentation +// +// /* +// ** pToken points to a buffer of size nToken bytes containing a search +// ** term, including the index number at the start, used on a tokendata=1 +// ** table. This function returns true if the term in buffer pBuf matches +// ** token pToken/nToken. +// */ +func _fts5IsTokendataPrefix(tls *libc.TLS, pBuf uintptr, pToken uintptr, nToken int32) (r int32) { + return libc.BoolInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn >= nToken && 0 == libc.Xmemcmp(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp, pToken, libc.Uint64FromInt32(nToken)) && ((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn == nToken || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(nToken)))) == 0x00)) +} + +func _fts5IterSetOutputCb(tls *libc.TLS, pRc uintptr, pIter uintptr) { + var pConfig uintptr + _ = pConfig + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + pConfig = (*TFts5Index)(unsafe.Pointer((*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex)).FpConfig + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + (*TFts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = __ccgo_fp(_fts5IterSetOutputs_None) + } else { + if (*TFts5Iter)(unsafe.Pointer(pIter)).FpColset == uintptr(0) { + (*TFts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = __ccgo_fp(_fts5IterSetOutputs_Nocolset) + } else { + if (*TFts5Colset)(unsafe.Pointer((*TFts5Iter)(unsafe.Pointer(pIter)).FpColset)).FnCol == 0 { + (*TFts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = __ccgo_fp(_fts5IterSetOutputs_ZeroColset) + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_FULL { + (*TFts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = __ccgo_fp(_fts5IterSetOutputs_Full) + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol <= int32(100) { + (*TFts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = __ccgo_fp(_fts5IterSetOutputs_Col100) + _sqlite3Fts5BufferSize(tls, pRc, pIter+40, libc.Uint32FromInt32((*TFts5Config)(unsafe.Pointer(pConfig)).FnCol)) + } else { + (*TFts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = __ccgo_fp(_fts5IterSetOutputs_Col) + } + } + } + } + } + } +} + +// C documentation +// +// /* +// ** The iterator passed as the only argument must be a tokendata=1 iterator +// ** (pIter->pTokenDataIter!=0). This function sets the iterator output +// ** variables (pIter->base.*) according to the contents of the current +// ** row. +// */ +func _fts5IterSetOutputsTokendata(tls *libc.TLS, pIter uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aNew, p, p1, pReader, pT uintptr + var eDetail, iMin, ii, nByte, nHit, nReader, v3 int32 + var iMinPos, iRowid, nNew Ti64 + var _ /* iPrev at bp+0 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aNew, eDetail, iMin, iMinPos, iRowid, ii, nByte, nHit, nNew, nReader, p, p1, pReader, pT, v3 + nHit = 0 + iRowid = int64(-libc.Int32FromInt32(1)) - (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< int32(1) && eDetail != int32(FTS5_DETAIL_NONE) { + nReader = 0 + nByte = 0 + **(**Ti64)(__ccgo_up(bp)) = 0 + /* Allocate array of iterators if they are not already allocated. */ + if (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaPoslistReader == uintptr(0) { + (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaPoslistReader = _sqlite3Fts5MallocZero(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex+60, libc.Int64FromUint64(libc.Uint64FromInt64((*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnIter)*uint64(libc.Uint64FromInt64(32)+libc.Uint64FromInt64(4)))) + if (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaPoslistReader == uintptr(0) { + return + } + (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaPoslistToIter = (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaPoslistReader + uintptr((*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnIter)*32 + } + /* Populate an iterator for each poslist that will be merged */ + ii = 0 + for { + if !(int64(ii) < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnIter) { + break + } + p1 = *(*uintptr)(unsafe.Pointer(pT + 72 + uintptr(ii)*8)) + if iRowid == (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FiRowid { + **(**int32)(__ccgo_up((*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaPoslistToIter + uintptr(nReader)*4)) = ii + v3 = nReader + nReader = nReader + 1 + _sqlite3Fts5PoslistReaderInit(tls, (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FpData, (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FnData, (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaPoslistReader+uintptr(v3)*32) + nByte = nByte + (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FnData + } + goto _2 + _2: + ; + ii = ii + 1 + } + /* Ensure the output buffer is large enough */ + if libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pIter+40)).Fn)+libc.Uint32FromInt32(nByte+nHit*libc.Int32FromInt32(10)) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pIter+40)).FnSpace) { + v3 = 0 + } else { + v3 = _sqlite3Fts5BufferSize(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex+60, pIter+40, libc.Uint32FromInt32(nByte+nHit*int32(10)+(*TFts5Buffer)(unsafe.Pointer(pIter+40)).Fn)) + } + if v3 != 0 { + return + } + /* Ensure the token-mapping is large enough */ + if eDetail == FTS5_DETAIL_FULL && (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMapAlloc < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMap+int64(nByte) { + nNew = ((*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMapAlloc + int64(nByte)) * int64(2) + aNew = Xsqlite3_realloc64(tls, (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaMap, libc.Uint64FromInt64(nNew)*uint64(24)) + if aNew == uintptr(0) { + (*TFts5Index)(unsafe.Pointer((*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex)).Frc = int32(SQLITE_NOMEM) + return + } + (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FaMap = aNew + (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnMapAlloc = nNew + } + (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn = 0 + for int32(1) != 0 { + iMinPos = libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf) || (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos > (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer((*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex)).FpConfig)).FnCol { + _fts5IterSetOutputs_Col(tls, pIter, pSeg) + } else { + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset) + pEnd = a + uintptr((*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos) + iPrev = 0 + aiCol = (*TFts5Iter)(unsafe.Pointer(pIter)).FpColset + 4 + aiColEnd = aiCol + uintptr((*TFts5Colset)(unsafe.Pointer((*TFts5Iter)(unsafe.Pointer(pIter)).FpColset)).FnCol)*4 + aOut = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + iPrevOut = 0 + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiRowid + for a < pEnd { + v1 = a + a = a + 1 + iPrev = iPrev + (libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v1))) - int32(2)) + for **(**int32)(__ccgo_up(aiCol)) < iPrev { + aiCol += 4 + if aiCol == aiColEnd { + goto setoutputs_col_out + } + } + if **(**int32)(__ccgo_up(aiCol)) == iPrev { + v1 = aOut + aOut = aOut + 1 + **(**Tu8)(__ccgo_up(v1)) = libc.Uint8FromInt32(iPrev - iPrevOut + libc.Int32FromInt32(2)) + iPrevOut = iPrev + } + } + goto setoutputs_col_out + setoutputs_col_out: + ; + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = int32(int64(aOut) - int64((*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp)) + } +} + +// C documentation +// +// /* +// ** The iterator object passed as the second argument currently contains +// ** no valid values except for the Fts5SegIter.pLeaf member variable. This +// ** function searches the leaf page for a term matching (pTerm/nTerm). +// ** +// ** If the specified term is found on the page, then the iterator is left +// ** pointing to it. If argument bGe is zero and the term is not found, +// ** the iterator is left pointing at EOF. +// ** +// ** If bGe is non-zero and the specified term is not found, then the +// ** iterator is left pointing to the smallest term in the segment that +// ** is larger than the specified term, even if this term is not on the +// ** current page. +// */ +func _fts5LeafSeek(tls *libc.TLS, p uintptr, bGe int32, pIter uintptr, pTerm uintptr, nTerm int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var a uintptr + var bEndOfPage int32 + var i, iPgidx, n, nCmp, nMatch, v1 Tu32 + var v2 uint32 + var _ /* iOff at bp+0 */ Tu32 + var _ /* iTermOff at bp+12 */ Tu32 + var _ /* nExtra at bp+16 */ int32 + var _ /* nKeep at bp+4 */ Tu32 + var _ /* nNew at bp+8 */ Tu32 + _, _, _, _, _, _, _, _, _ = a, bEndOfPage, i, iPgidx, n, nCmp, nMatch, v1, v2 + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + n = libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn) + nMatch = uint32(0) + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(0) /* Current offset in pgidx */ + bEndOfPage = 0 + iPgidx = libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) + iPgidx = iPgidx + libc.Uint32FromInt32(_sqlite3Fts5GetVarint32(tls, a+uintptr(iPgidx), bp+12)) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp + 12)) + if **(**Tu32)(__ccgo_up(bp)) > n { + _fts5IndexCorruptIter(tls, p, pIter) + return + } + for int32(1) != 0 { + /* Figure out how many new bytes are in this term */ + v1 = **(**Tu32)(__ccgo_up(bp)) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + 1 + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(**(**Tu8)(__ccgo_up(a + uintptr(v1)))) + if **(**Tu32)(__ccgo_up(bp + 8))&uint32(0x80) != 0 { + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) - 1 + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + libc.Uint32FromInt32(_sqlite3Fts5GetVarint32(tls, a+uintptr(**(**Tu32)(__ccgo_up(bp))), bp+8)) + } + if **(**Tu32)(__ccgo_up(bp + 4)) < nMatch { + goto search_failed + } + if **(**Tu32)(__ccgo_up(bp))+**(**Tu32)(__ccgo_up(bp + 8)) > n { + _fts5IndexCorruptIter(tls, p, pIter) + return + } + if **(**Tu32)(__ccgo_up(bp + 4)) == nMatch { + if **(**Tu32)(__ccgo_up(bp + 8)) < libc.Uint32FromInt32(nTerm)-nMatch { + v2 = **(**Tu32)(__ccgo_up(bp + 8)) + } else { + v2 = libc.Uint32FromInt32(nTerm) - nMatch + } + nCmp = v2 + i = uint32(0) + for { + if !(i < nCmp) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a + uintptr(**(**Tu32)(__ccgo_up(bp))+i)))) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTerm + uintptr(nMatch+i)))) { + break + } + goto _3 + _3: + ; + i = i + 1 + } + nMatch = nMatch + i + if libc.Uint32FromInt32(nTerm) == nMatch { + if i == **(**Tu32)(__ccgo_up(bp + 8)) { + goto search_success + } else { + goto search_failed + } + } else { + if i < **(**Tu32)(__ccgo_up(bp + 8)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a + uintptr(**(**Tu32)(__ccgo_up(bp))+i)))) > libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTerm + uintptr(nMatch)))) { + goto search_failed + } + } + } + if iPgidx >= n { + bEndOfPage = int32(1) + break + } + iPgidx = iPgidx + libc.Uint32FromInt32(_sqlite3Fts5GetVarint32(tls, a+uintptr(iPgidx), bp+4)) + **(**Tu32)(__ccgo_up(bp + 12)) = **(**Tu32)(__ccgo_up(bp + 12)) + **(**Tu32)(__ccgo_up(bp + 4)) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp + 12)) + if **(**Tu32)(__ccgo_up(bp)) >= n { + _fts5IndexCorruptIter(tls, p, pIter) + return + } + /* Read the nKeep field of the next term. */ + v1 = **(**Tu32)(__ccgo_up(bp)) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + 1 + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(**(**Tu8)(__ccgo_up(a + uintptr(v1)))) + if **(**Tu32)(__ccgo_up(bp + 4))&uint32(0x80) != 0 { + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) - 1 + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + libc.Uint32FromInt32(_sqlite3Fts5GetVarint32(tls, a+uintptr(**(**Tu32)(__ccgo_up(bp))), bp+4)) + } + } + goto search_failed +search_failed: + ; + if bGe == 0 { + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) + return + } else { + if bEndOfPage != 0 { + for cond := true; cond; cond = int32(1) != 0 { + _fts5SegIterNextPage(tls, p, pIter) + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { + return + } + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + if libc.BoolInt32((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf >= (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn) == 0 { + iPgidx = libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) + iPgidx = iPgidx + libc.Uint32FromInt32(_sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr(iPgidx), bp)) + if **(**Tu32)(__ccgo_up(bp)) < uint32(4) || libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp))) >= int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) { + _fts5IndexCorruptIter(tls, p, pIter) + return + } else { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) + **(**Tu32)(__ccgo_up(bp + 12)) = **(**Tu32)(__ccgo_up(bp)) + n = libc.Uint32FromInt32((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + libc.Uint32FromInt32(_sqlite3Fts5GetVarint32(tls, a+uintptr(**(**Tu32)(__ccgo_up(bp))), bp+8)) + break + } + } + } + } + } + goto search_success +search_success: + ; + if libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp)))+libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp + 8))) > libc.Int64FromUint32(n) || **(**Tu32)(__ccgo_up(bp + 8)) < uint32(1) { + _fts5IndexCorruptIter(tls, p, pIter) + return + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp)) + **(**Tu32)(__ccgo_up(bp + 8))) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset = int32((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno + _sqlite3Fts5BufferSet(tls, p+60, pIter+96, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp + 4))), pTerm) + _sqlite3Fts5BufferAppendBlob(tls, p+60, pIter+96, **(**Tu32)(__ccgo_up(bp + 8)), a+uintptr(**(**Tu32)(__ccgo_up(bp)))) + if iPgidx >= n { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn + int32(1) + } else { + iPgidx = iPgidx + libc.Uint32FromInt32(_sqlite3Fts5GetVarint32(tls, a+uintptr(iPgidx), bp+16)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp + 12)) + libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 16)))) + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = libc.Int32FromUint32(iPgidx) + _fts5SegIterLoadRowid(tls, p, pIter) + _fts5SegIterLoadNPos(tls, p, pIter) +} + +// C documentation +// +// /* +// ** Sub-iterator iChanged of iterator pIter has just been advanced. It still +// ** points to the same term though - just a different rowid. This function +// ** attempts to update the contents of the pIter->aFirst[] accordingly. +// ** If it does so successfully, 0 is returned. Otherwise 1. +// ** +// ** If non-zero is returned, the caller should call fts5MultiIterAdvanced() +// ** on the iterator instead. That function does the same as this one, except +// ** that it deals with more complicated cases as well. +// */ +func _fts5MultiIterAdvanceRowid(tls *libc.TLS, pIter uintptr, iChanged int32, ppFirst uintptr) (r int32) { + var i int32 + var pNew, pOther, pRes uintptr + var v1 int64 + _, _, _, _, _ = i, pNew, pOther, pRes, v1 + pNew = pIter + 104 + uintptr(iChanged)*128 + if (*TFts5SegIter)(unsafe.Pointer(pNew)).FiRowid == (*TFts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid || libc.BoolInt32((*TFts5SegIter)(unsafe.Pointer(pNew)).FiRowid < (*TFts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid) == (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev { + pOther = pIter + 104 + uintptr(iChanged^int32(0x0001))*128 + if (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev != 0 { + v1 = int64(-libc.Int32FromInt32(1)) - (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)< (*TFts5SegIter)(unsafe.Pointer(pNew)).FiRowid) == (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev { + (*TFts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = (*TFts5SegIter)(unsafe.Pointer(pOther)).FiRowid + pNew = pOther + } else { + if libc.BoolInt32((*TFts5SegIter)(unsafe.Pointer(pOther)).FiRowid > (*TFts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid) == (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev { + (*TFts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = (*TFts5SegIter)(unsafe.Pointer(pOther)).FiRowid + } + } + } + } + (*TFts5CResult)(unsafe.Pointer(pRes)).FiFirst = libc.Uint16FromInt64((int64(pNew) - t__predefined_ptrdiff_t(pIter+104)) / 128) + if i == int32(1) { + break + } + pOther = pIter + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(i^int32(0x0001))*4))).FiFirst)*128 + goto _2 + _2: + ; + i = i / int32(2) + } + } + **(**uintptr)(__ccgo_up(ppFirst)) = pNew + return 0 +} + +func _fts5MultiIterAlloc(tls *libc.TLS, p uintptr, nSeg int32) (r uintptr) { + var nSlot Ti64 + var pNew uintptr + _, _ = nSlot, pNew /* Power of two >= nSeg */ + nSlot = int64(2) + for { + if !(nSlot < int64(nSeg)) { + break + } + goto _1 + _1: + ; + nSlot = nSlot * int64(2) + } + pNew = _fts5IdxMalloc(tls, p, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+104)+libc.Uint64FromInt64(nSlot)*uint64(128)+uint64(4)*libc.Uint64FromInt64(nSlot))) + if pNew != 0 { + (*TFts5Iter)(unsafe.Pointer(pNew)).FnSeg = int32(nSlot) + (*TFts5Iter)(unsafe.Pointer(pNew)).FaFirst = pNew + 104 + uintptr(nSlot)*128 + (*TFts5Iter)(unsafe.Pointer(pNew)).FpIndex = p + (*TFts5Iter)(unsafe.Pointer(pNew)).FxSetOutputs = __ccgo_fp(_fts5IterSetOutputs_Noop) + } + return pNew +} + +// C documentation +// +// /* +// ** Do the comparison necessary to populate pIter->aFirst[iOut]. +// ** +// ** If the returned value is non-zero, then it is the index of an entry +// ** in the pIter->aSeg[] array that is (a) not at EOF, and (b) pointing +// ** to a key that is a duplicate of another, higher priority, +// ** segment-iterator in the pSeg->aSeg[] array. +// */ +func _fts5MultiIterDoCompare(tls *libc.TLS, pIter uintptr, iOut int32) (r int32) { + var i1, i2, iRes, res, v1 int32 + var p1, p2, pRes uintptr + _, _, _, _, _, _, _, _ = i1, i2, iRes, p1, p2, pRes, res, v1 /* Right-hand Fts5SegIter */ + pRes = (*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(iOut)*4 + if iOut >= (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg/int32(2) { + i1 = (iOut - (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg/int32(2)) * int32(2) + i2 = i1 + int32(1) + } else { + i1 = libc.Int32FromUint16((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(iOut*int32(2))*4))).FiFirst) + i2 = libc.Int32FromUint16((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(iOut*int32(2)+int32(1))*4))).FiFirst) + } + p1 = pIter + 104 + uintptr(i1)*128 + p2 = pIter + 104 + uintptr(i2)*128 + (*TFts5CResult)(unsafe.Pointer(pRes)).FbTermEq = uint8(0) + if (*TFts5SegIter)(unsafe.Pointer(p1)).FpLeaf == uintptr(0) { /* If p1 is at EOF */ + iRes = i2 + } else { + if (*TFts5SegIter)(unsafe.Pointer(p2)).FpLeaf == uintptr(0) { /* If p2 is at EOF */ + iRes = i1 + } else { + res = _fts5BufferCompare(tls, p1+96, p2+96) + if res == 0 { + (*TFts5CResult)(unsafe.Pointer(pRes)).FbTermEq = uint8(1) + if (*TFts5SegIter)(unsafe.Pointer(p1)).FiRowid == (*TFts5SegIter)(unsafe.Pointer(p2)).FiRowid { + return i2 + } + if libc.BoolInt32((*TFts5SegIter)(unsafe.Pointer(p1)).FiRowid > (*TFts5SegIter)(unsafe.Pointer(p2)).FiRowid) == (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev { + v1 = -int32(1) + } else { + v1 = +libc.Int32FromInt32(1) + } + res = v1 + } + if res < 0 { + iRes = i1 + } else { + iRes = i2 + } + } + } + (*TFts5CResult)(unsafe.Pointer(pRes)).FiFirst = libc.Uint16FromInt32(iRes) + return 0 +} + +// C documentation +// +// /* +// ** All the component segment-iterators of pIter have been set up. This +// ** functions finishes setup for iterator pIter itself. +// */ +func _fts5MultiIterFinishSetup(tls *libc.TLS, p uintptr, pIter uintptr) { + var iEq, iIter, v2 int32 + var pSeg, pSeg1 uintptr + _, _, _, _, _ = iEq, iIter, pSeg, pSeg1, v2 + iIter = (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg - int32(1) + for { + if !(iIter > 0) { + break + } + v2 = _fts5MultiIterDoCompare(tls, pIter, iIter) + iEq = v2 + if v2 != 0 { + pSeg = pIter + 104 + uintptr(iEq)*128 + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5SegIter)(unsafe.Pointer(pSeg)).FxNext})))(tls, p, pSeg, uintptr(0)) + } + _fts5MultiIterAdvanced(tls, p, pIter, iEq, iIter) + } + goto _1 + _1: + ; + iIter = iIter - 1 + } + _fts5MultiIterSetEof(tls, pIter) + if (*TFts5Iter)(unsafe.Pointer(pIter)).FbSkipEmpty != 0 && _fts5MultiIterIsEmpty(tls, p, pIter) != 0 || _fts5MultiIterIsDeleted(tls, pIter) != 0 { + _fts5MultiIterNext(tls, p, pIter, 0, 0) + } else { + if libc.Int32FromUint8((*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof) == 0 { + pSeg1 = pIter + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst)*128 + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs})))(tls, pIter, pSeg1) + } + } +} + +// C documentation +// +// /* +// ** Return true if the iterator passed as the only argument points +// ** to an segment entry for which there is a tombstone. Return false +// ** if there is no tombstone or if the iterator is already at EOF. +// */ +func _fts5MultiIterIsDeleted(tls *libc.TLS, pIter uintptr) (r int32) { + var iFirst, iPg int32 + var pArray, pSeg uintptr + _, _, _, _ = iFirst, iPg, pArray, pSeg + iFirst = libc.Int32FromUint16((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst) + pSeg = pIter + 104 + uintptr(iFirst)*128 + pArray = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpTombArray + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 && pArray != 0 { + /* Figure out which page the rowid might be present on. */ + iPg = libc.Int32FromUint64(libc.Uint64FromInt64((*TFts5SegIter)(unsafe.Pointer(pSeg)).FiRowid) % libc.Uint64FromInt32((*TFts5TombstoneArray)(unsafe.Pointer(pArray)).FnTombstone)) + /* If tombstone hash page iPg has not yet been loaded from the + ** database, load it now. */ + if *(*uintptr)(unsafe.Pointer(pArray + 8 + uintptr(iPg)*8)) == uintptr(0) { + *(*uintptr)(unsafe.Pointer(pArray + 8 + uintptr(iPg)*8)) = _fts5DataRead(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex, int64((*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid+libc.Int32FromInt32(1)< 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pData + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = libc.Int64FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pData)).Fp, pIter+112)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*TFts5Data)(unsafe.Pointer(pData)).Fnn + (**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pNew)).FaFirst + 1*4))).FiFirst = uint16(1) + if bDesc != 0 { + (*TFts5Iter)(unsafe.Pointer(pNew)).FbRev = int32(1) + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_REVERSE) + _fts5SegIterReverseInitPage(tls, p, pIter) + } else { + _fts5SegIterLoadNPos(tls, p, pIter) + } + pData = uintptr(0) + } else { + (*TFts5Iter)(unsafe.Pointer(pNew)).Fbase.FbEof = uint8(1) + } + _fts5SegIterSetNext(tls, p, pIter) + **(**uintptr)(__ccgo_up(ppOut)) = pNew + } + _fts5DataRelease(tls, pData) +} + +// C documentation +// +// /* +// ** Move the iterator to the next entry. +// ** +// ** If an error occurs, an error code is left in Fts5Index.rc. It is not +// ** considered an error if the iterator reaches EOF, or if it is already at +// ** EOF when this function is called. +// */ +func _fts5MultiIterNext(tls *libc.TLS, p uintptr, pIter uintptr, bFrom int32, iFrom Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bUseFrom, iFirst int32 + var _ /* bNewTerm at bp+0 */ int32 + var _ /* pSeg at bp+8 */ uintptr + _, _ = bUseFrom, iFirst + bUseFrom = bFrom + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + iFirst = libc.Int32FromUint16((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst) + **(**int32)(__ccgo_up(bp)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = pIter + 104 + uintptr(iFirst)*128 + if bUseFrom != 0 && (*TFts5SegIter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpDlidx != 0 { + _fts5SegIterNextFrom(tls, p, **(**uintptr)(__ccgo_up(bp + 8)), iFrom) + } else { + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5SegIter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FxNext})))(tls, p, **(**uintptr)(__ccgo_up(bp + 8)), bp) + } + if (*TFts5SegIter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpLeaf == uintptr(0) || **(**int32)(__ccgo_up(bp)) != 0 || _fts5MultiIterAdvanceRowid(tls, pIter, iFirst, bp+8) != 0 { + _fts5MultiIterAdvanced(tls, p, pIter, iFirst, int32(1)) + _fts5MultiIterSetEof(tls, pIter) + **(**uintptr)(__ccgo_up(bp + 8)) = pIter + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst)*128 + if (*TFts5SegIter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpLeaf == uintptr(0) { + return + } + } + if (libc.Int32FromUint8((*TFts5Iter)(unsafe.Pointer(pIter)).FbSkipEmpty) == 0 || (*TFts5SegIter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FnPos != 0) && 0 == _fts5MultiIterIsDeleted(tls, pIter) { + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs})))(tls, pIter, **(**uintptr)(__ccgo_up(bp + 8))) + return + } + bUseFrom = 0 + } +} + +func _fts5MultiIterNext2(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iFirst int32 + var _ /* bNewTerm at bp+8 */ int32 + var _ /* pSeg at bp+0 */ uintptr + _ = iFirst + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**int32)(__ccgo_up(pbNewTerm)) = 0 + for cond := true; cond; cond = (_fts5MultiIterIsEmpty(tls, p, pIter) != 0 || _fts5MultiIterIsDeleted(tls, pIter) != 0) && (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + iFirst = libc.Int32FromUint16((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst) + **(**uintptr)(__ccgo_up(bp)) = pIter + 104 + uintptr(iFirst)*128 + **(**int32)(__ccgo_up(bp + 8)) = 0 + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5SegIter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxNext})))(tls, p, **(**uintptr)(__ccgo_up(bp)), bp+8) + if (*TFts5SegIter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpLeaf == uintptr(0) || **(**int32)(__ccgo_up(bp + 8)) != 0 || _fts5MultiIterAdvanceRowid(tls, pIter, iFirst, bp) != 0 { + _fts5MultiIterAdvanced(tls, p, pIter, iFirst, int32(1)) + _fts5MultiIterSetEof(tls, pIter) + **(**int32)(__ccgo_up(pbNewTerm)) = int32(1) + } + } + } +} + +// C documentation +// +// /* +// ** The second argument passed to this function may be NULL, or it may be +// ** an existing Fts5Colset object. This function returns a pointer to +// ** a new colset object containing the contents of (p) with new value column +// ** number iCol appended. +// ** +// ** If an OOM error occurs, store an error code in pParse and return NULL. +// ** The old colset object (if any) is not freed in this case. +// */ +func _fts5ParseColset(tls *libc.TLS, pParse uintptr, p uintptr, iCol int32) (r uintptr) { + var aiCol, pNew uintptr + var i, j, nCol, v1 int32 + _, _, _, _, _, _ = aiCol, i, j, nCol, pNew, v1 + if p != 0 { + v1 = (*TFts5Colset)(unsafe.Pointer(p)).FnCol + } else { + v1 = 0 + } + nCol = v1 /* New colset object to return */ + pNew = Xsqlite3_realloc64(tls, p, uint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32((nCol+libc.Int32FromInt32(1)+libc.Int32FromInt32(2))/libc.Int32FromInt32(2)))) + if pNew == uintptr(0) { + (*TFts5Parse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + } else { + aiCol = pNew + 4 + i = 0 + for { + if !(i < nCol) { + break + } + if **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) == iCol { + return pNew + } + if **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) > iCol { + break + } + goto _2 + _2: + ; + i = i + 1 + } + j = nCol + for { + if !(j > i) { + break + } + **(**int32)(__ccgo_up(aiCol + uintptr(j)*4)) = **(**int32)(__ccgo_up(aiCol + uintptr(j-int32(1))*4)) + goto _3 + _3: + ; + j = j - 1 + } + **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) = iCol + (*TFts5Colset)(unsafe.Pointer(pNew)).FnCol = nCol + int32(1) + } + return pNew +} + +// C documentation +// +// /* +// ** This function is used when parsing LIKE or GLOB patterns against +// ** trigram indexes that specify either detail=column or detail=none. +// ** It converts a phrase: +// ** +// ** abc + def + ghi +// ** +// ** into an AND tree: +// ** +// ** abc AND def AND ghi +// */ +func _fts5ParsePhraseToAnd(tls *libc.TLS, pParse uintptr, pNear uintptr) (r uintptr) { + var ii, nByte, nTerm, v2 int32 + var p, pPhrase, pRet, pTo, v3 uintptr + _, _, _, _, _, _, _, _, _ = ii, nByte, nTerm, p, pPhrase, pRet, pTo, v2, v3 + nTerm = (*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 24)))).FnTerm + nByte = libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0)+48) + libc.Uint64FromInt32(nTerm+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8)) + pRet = _sqlite3Fts5MallocZero(tls, pParse+16, int64(nByte)) + if pRet != 0 { + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FeType = int32(FTS5_AND) + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FnChild = nTerm + (*TFts5ExprNode)(unsafe.Pointer(pRet)).FiHeight = int32(1) + _fts5ExprAssignXNext(tls, pRet) + (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase = (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase - 1 + ii = 0 + for { + if !(ii < nTerm) { + break + } + pPhrase = _sqlite3Fts5MallocZero(tls, pParse+16, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+32)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(40))) + if pPhrase != 0 { + if _parseGrowPhraseArray(tls, pParse) != 0 { + _fts5ExprPhraseFree(tls, pPhrase) + } else { + p = *(*uintptr)(unsafe.Pointer(pNear + 24)) + 32 + uintptr(ii)*40 + pTo = pPhrase + 32 + v3 = pParse + 20 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + **(**uintptr)(__ccgo_up((*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr(v2)*8)) = pPhrase + (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm = int32(1) + (*TFts5ExprTerm)(unsafe.Pointer(pTo)).FpTerm = _sqlite3Fts5Strndup(tls, pParse+16, (*TFts5ExprTerm)(unsafe.Pointer(p)).FpTerm, (*TFts5ExprTerm)(unsafe.Pointer(p)).FnFullTerm) + (*TFts5ExprTerm)(unsafe.Pointer(pTo)).FnQueryTerm = (*TFts5ExprTerm)(unsafe.Pointer(p)).FnQueryTerm + (*TFts5ExprTerm)(unsafe.Pointer(pTo)).FnFullTerm = (*TFts5ExprTerm)(unsafe.Pointer(p)).FnFullTerm + *(*uintptr)(unsafe.Pointer(pRet + 48 + uintptr(ii)*8)) = _sqlite3Fts5ParseNode(tls, pParse, int32(FTS5_STRING), uintptr(0), uintptr(0), _sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), pPhrase)) + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc != 0 { + _sqlite3Fts5ParseNodeFree(tls, pRet) + pRet = uintptr(0) + } else { + _sqlite3Fts5ParseNearsetFree(tls, pNear) + } + } + return pRet +} + +func _fts5PoslistOffsetsCallback(tls *libc.TLS, pUnused uintptr, pContext uintptr, pChunk uintptr, nChunk int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var pCtx uintptr + var _ /* iVal at bp+0 */ int32 + _, _ = i, pCtx + pCtx = pContext + _ = pUnused + if nChunk > 0 { + i = 0 + for i < nChunk { + i = i + _sqlite3Fts5GetVarint32(tls, pChunk+uintptr(i), bp) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + ((*TPoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FiRead - int32(2)) + (*TPoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FiRead = **(**int32)(__ccgo_up(bp)) + if _fts5IndexColsetTest(tls, (*TPoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FpColset, **(**int32)(__ccgo_up(bp))) != 0 { + **(**int32)(__ccgo_up((*TPoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FpBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer((*TPoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer((*TPoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), libc.Uint64FromInt32(**(**int32)(__ccgo_up(bp))+libc.Int32FromInt32(2)-(*TPoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FiWrite)) + (*TPoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FiWrite = **(**int32)(__ccgo_up(bp)) + } + } + } +} + +// C documentation +// +// /* +// ** Allocate a tombstone hash page array object (pIter->pTombArray) for +// ** the iterator passed as the second argument. If an OOM error occurs, +// ** leave an error in the Fts5Index object. +// */ +func _fts5SegIterAllocTombstone(tls *libc.TLS, p uintptr, pIter uintptr) { + var nByte, nTomb Ti64 + var pNew uintptr + _, _, _ = nByte, nTomb, pNew + nTomb = int64((*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FnPgTombstone) + if nTomb > 0 { + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+8) + libc.Uint64FromInt64(nTomb+libc.Int64FromInt32(1))*libc.Uint64FromInt64(8)) + pNew = _sqlite3Fts5MallocZero(tls, p+60, nByte) + if pNew != 0 { + (*TFts5TombstoneArray)(unsafe.Pointer(pNew)).FnTombstone = int32(nTomb) + (*TFts5TombstoneArray)(unsafe.Pointer(pNew)).FnRef = int32(1) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpTombArray = pNew + } + } +} + +// C documentation +// +// /* +// ** Move the seg-iter so that it points to the first rowid on page iLeafPgno. +// ** It is an error if leaf iLeafPgno does not exist. Unless the db is +// ** a 'secure-delete' db, if it contains no rowids then this is also an error. +// */ +func _fts5SegIterGotoPage(tls *libc.TLS, p uintptr, pIter uintptr, iLeafPgno int32) { + var a uintptr + var iOff, n int32 + _, _, _ = a, iOff, n + if iLeafPgno > (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FpgnoLast { + _fts5IndexCorruptIdx(tls, p) + } else { + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf = uintptr(0) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iLeafPgno - int32(1) + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _fts5SegIterNextPage(tls, p, pIter) + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { + break + } + iOff = libc.Int32FromUint16(_fts5GetU16(tls, (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp)) + if iOff > 0 { + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + n = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + if iOff < int32(4) || iOff >= n { + _fts5IndexCorruptIdx(tls, p) + } else { + iOff = iOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, a+uintptr(iOff), pIter+112)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(iOff) + _fts5SegIterLoadNPos(tls, p, pIter) + } + break + } + } + } +} + +// C documentation +// +// /* +// ** Initialize the object pIter to point to term pTerm/nTerm within the +// ** in-memory hash table. If there is no such term in the hash-table, the +// ** iterator is set to EOF. +// ** +// ** If an error occurs, Fts5Index.rc is set to an appropriate error code. If +// ** an error has already occurred when this function is called, it is a no-op. +// */ +func _fts5SegIterHashInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, flags int32, pIter uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var v1 int32 + var _ /* n at bp+16 */ int32 + var _ /* nList at bp+0 */ int32 + var _ /* pLeaf at bp+24 */ uintptr + var _ /* pList at bp+32 */ uintptr + var _ /* z at bp+8 */ uintptr + _ = v1 + **(**int32)(__ccgo_up(bp)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 16)) = 0 + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + if pTerm == uintptr(0) || flags&int32(FTS5INDEX_QUERY_SCAN) != 0 { + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + (*TFts5Index)(unsafe.Pointer(p)).Frc = _sqlite3Fts5HashScanInit(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash, pTerm, nTerm) + _sqlite3Fts5HashScanEntry(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash, bp+8, bp+16, bp+32, bp) + if **(**uintptr)(__ccgo_up(bp + 32)) != 0 { + **(**uintptr)(__ccgo_up(bp + 24)) = _fts5IdxMalloc(tls, p, int64(16)) + if **(**uintptr)(__ccgo_up(bp + 24)) != 0 { + (*TFts5Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 24)))).Fp = **(**uintptr)(__ccgo_up(bp + 32)) + } + } + /* The call to sqlite3Fts5HashScanInit() causes the hash table to + ** fill the size field of all existing position lists. This means they + ** can no longer be appended to. Since the only scenario in which they + ** can be appended to is if the previous operation on this table was + ** a DELETE, by clearing the Fts5Index.bDelete flag we can avoid this + ** possibility altogether. */ + (*TFts5Index)(unsafe.Pointer(p)).FbDelete = 0 + } else { + (*TFts5Index)(unsafe.Pointer(p)).Frc = _sqlite3Fts5HashQuery(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash, int32(16), pTerm, nTerm, bp+24, bp) + if **(**uintptr)(__ccgo_up(bp + 24)) != 0 { + (*TFts5Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 24)))).Fp = **(**uintptr)(__ccgo_up(bp + 24)) + 1*16 + } + **(**uintptr)(__ccgo_up(bp + 8)) = pTerm + **(**int32)(__ccgo_up(bp + 16)) = nTerm + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_ONETERM) + } + if **(**uintptr)(__ccgo_up(bp + 24)) != 0 { + _sqlite3Fts5BufferSet(tls, p+60, pIter+96, **(**int32)(__ccgo_up(bp + 16)), **(**uintptr)(__ccgo_up(bp + 8))) + v1 = **(**int32)(__ccgo_up(bp)) + (*TFts5Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 24)))).FszLeaf = v1 + (*TFts5Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 24)))).Fnn = v1 + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = **(**uintptr)(__ccgo_up(bp + 24)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = libc.Int64FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 24)))).Fp, pIter+112)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*TFts5Data)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 24)))).Fnn + if flags&int32(FTS5INDEX_QUERY_DESC) != 0 { + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_REVERSE) + _fts5SegIterReverseInitPage(tls, p, pIter) + } else { + _fts5SegIterLoadNPos(tls, p, pIter) + } + } + _fts5SegIterSetNext(tls, p, pIter) +} + +func _fts5SegIterLoadRowid(tls *libc.TLS, p uintptr, pIter uintptr) { + var a uintptr + var iOff Ti64 + _, _ = a, iOff + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp /* Buffer to read data from */ + iOff = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset + for iOff >= int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) { + _fts5SegIterNextPage(tls, p, pIter) + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _fts5IndexCorruptIter(tls, p, pIter) + } + return + } + iOff = int64(4) + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + } + iOff = iOff + libc.Int64FromUint8(_sqlite3Fts5GetVarint(tls, a+uintptr(iOff), pIter+112)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = iOff +} + +// C documentation +// +// /* +// ** Fts5SegIter.iLeafOffset currently points to the first byte of the +// ** "nSuffix" field of a term. Function parameter nKeep contains the value +// ** of the "nPrefix" field (if there was one - it is passed 0 if this is +// ** the first term in the segment). +// ** +// ** This function populates: +// ** +// ** Fts5SegIter.term +// ** Fts5SegIter.rowid +// ** +// ** accordingly and leaves (Fts5SegIter.iLeafOffset) set to the content of +// ** the first position list. The position list belonging to document +// ** (Fts5SegIter.iRowid). +// */ +func _fts5SegIterLoadTerm(tls *libc.TLS, p uintptr, pIter uintptr, nKeep int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a uintptr + var iOff Ti64 + var _ /* nExtra at bp+4 */ int32 + var _ /* nNew at bp+0 */ int32 + _, _ = a, iOff + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp /* Buffer to read data from */ + iOff = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset /* Bytes of new data */ + iOff = iOff + int64(_sqlite3Fts5GetVarint32(tls, a+uintptr(iOff), bp)) + if iOff+int64(**(**int32)(__ccgo_up(bp))) > int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) || nKeep > (*TFts5SegIter)(unsafe.Pointer(pIter)).Fterm.Fn || **(**int32)(__ccgo_up(bp)) == 0 { + _fts5IndexCorruptIter(tls, p, pIter) + return + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).Fterm.Fn = nKeep + _sqlite3Fts5BufferAppendBlob(tls, p+60, pIter+96, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp))), a+uintptr(iOff)) + iOff = iOff + int64(**(**int32)(__ccgo_up(bp))) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset = int32(iOff) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = iOff + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff >= (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn + int32(1) + } else { + **(**int32)(__ccgo_up(pIter + 64)) += _sqlite3Fts5GetVarint32(tls, a+uintptr((*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff), bp+4) + **(**int32)(__ccgo_up(pIter + 68)) += **(**int32)(__ccgo_up(bp + 4)) + } + _fts5SegIterLoadRowid(tls, p, pIter) +} + +// C documentation +// +// /* +// ** Advance iterator pIter to the next entry. +// ** +// ** If an error occurs, Fts5Index.rc is set to an appropriate error code. It +// ** is not considered an error if the iterator reaches EOF. If an error has +// ** already occurred when this function is called, it is a no-op. +// */ +func _fts5SegIterNext(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var a, pLeaf, v1 uintptr + var bNewTerm, n, v2 int32 + var v3 Ti64 + var _ /* iDelta at bp+8 */ Tu64 + var _ /* iOff at bp+0 */ int32 + var _ /* nKeep at bp+4 */ int32 + var _ /* nList at bp+36 */ int32 + var _ /* nSz at bp+40 */ int32 + var _ /* nTerm at bp+32 */ int32 + var _ /* pList at bp+16 */ uintptr + var _ /* zTerm at bp+24 */ uintptr + _, _, _, _, _, _, _ = a, bNewTerm, n, pLeaf, v1, v2, v3 + pLeaf = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf + bNewTerm = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + /* Search for the end of the position list within the current page. */ + a = (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp + n = (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf + **(**int32)(__ccgo_up(bp)) = int32((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset + int64((*TFts5SegIter)(unsafe.Pointer(pIter)).FnPos)) + if **(**int32)(__ccgo_up(bp)) < n { + /* The next entry is on the current page. */ + if **(**int32)(__ccgo_up(bp)) >= (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist { + bNewTerm = int32(1) + if **(**int32)(__ccgo_up(bp)) != _fts5LeafFirstTermOff(tls, pLeaf) { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + _sqlite3Fts5GetVarint32(tls, a+uintptr(**(**int32)(__ccgo_up(bp))), bp+4) + } + } else { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, a+uintptr(**(**int32)(__ccgo_up(bp))), bp+8)) + v1 = pIter + 112 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + **(**Tu64)(__ccgo_up(bp + 8))) + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(**(**int32)(__ccgo_up(bp))) + } else { + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg == uintptr(0) { + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 32)) = 0 + **(**int32)(__ccgo_up(bp + 36)) = 0 + if 0 == (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags&int32(FTS5_SEGITER_ONETERM) { + _sqlite3Fts5HashScanNext(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash) + _sqlite3Fts5HashScanEntry(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash, bp+24, bp+32, bp+16, bp+36) + } + if **(**uintptr)(__ccgo_up(bp + 16)) == uintptr(0) { + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) + } else { + (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp = **(**uintptr)(__ccgo_up(bp + 16)) + (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn = **(**int32)(__ccgo_up(bp + 36)) + (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf = **(**int32)(__ccgo_up(bp + 36)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = **(**int32)(__ccgo_up(bp + 36)) + int32(1) + _sqlite3Fts5BufferSet(tls, p+60, pIter+96, **(**int32)(__ccgo_up(bp + 32)), **(**uintptr)(__ccgo_up(bp + 24))) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = libc.Int64FromUint8(_sqlite3Fts5GetVarint(tls, **(**uintptr)(__ccgo_up(bp + 16)), pIter+112)) + **(**int32)(__ccgo_up(pbNewTerm)) = int32(1) + } + } else { + **(**int32)(__ccgo_up(bp)) = 0 + /* Next entry is not on the current page */ + for **(**int32)(__ccgo_up(bp)) == 0 { + _fts5SegIterNextPage(tls, p, pIter) + pLeaf = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf + if pLeaf == uintptr(0) { + break + } + v2 = libc.Int32FromUint16(_fts5GetU16(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp)) + **(**int32)(__ccgo_up(bp)) = v2 + if v2 != 0 && **(**int32)(__ccgo_up(bp)) < (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(**(**int32)(__ccgo_up(bp))), pIter+112)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(**(**int32)(__ccgo_up(bp))) + if (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn > (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf + _sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr((*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf), pIter+68) + } + } else { + if (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn > (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf + _sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr((*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf), bp) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(**(**int32)(__ccgo_up(bp))) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = **(**int32)(__ccgo_up(bp)) + bNewTerm = int32(1) + } + } + if **(**int32)(__ccgo_up(bp)) > (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + _fts5IndexCorruptIter(tls, p, pIter) + return + } + } + } + } + /* Check if the iterator is now at EOF. If so, return early. */ + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + if bNewTerm != 0 { + if (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags&int32(FTS5_SEGITER_ONETERM) != 0 { + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) + } else { + _fts5SegIterLoadTerm(tls, p, pIter, **(**int32)(__ccgo_up(bp + 4))) + _fts5SegIterLoadNPos(tls, p, pIter) + if pbNewTerm != 0 { + **(**int32)(__ccgo_up(pbNewTerm)) = int32(1) + } + } + } else { + v1 = pIter + 32 + v3 = *(*Ti64)(unsafe.Pointer(v1)) + *(*Ti64)(unsafe.Pointer(v1)) = *(*Ti64)(unsafe.Pointer(v1)) + 1 + **(**int32)(__ccgo_up(bp + 40)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr(v3)))) + if **(**int32)(__ccgo_up(bp + 40))&int32(0x80) != 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset - 1 + **(**Ti64)(__ccgo_up(pIter + 32)) += int64(_sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset), bp+40)) + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FbDel = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 40)) & libc.Int32FromInt32(0x0001)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FnPos = **(**int32)(__ccgo_up(bp + 40)) >> int32(1) + } + } +} + +// C documentation +// +// /* +// ** Advance iterator pIter to the next entry. +// ** +// ** This version of fts5SegIterNext() is only used if detail=none and the +// ** iterator is not a reverse direction iterator. +// */ +func _fts5SegIterNext_None(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var iOff int32 + var v1 uintptr + var _ /* iDelta at bp+0 */ Tu64 + var _ /* nKeep at bp+8 */ int32 + var _ /* nList at bp+36 */ int32 + var _ /* nTerm at bp+32 */ int32 + var _ /* pList at bp+16 */ uintptr + var _ /* zTerm at bp+24 */ uintptr + _, _ = iOff, v1 + iOff = int32((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset) + /* Next entry is on the next page */ + for (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg != 0 && iOff >= (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf { + _fts5SegIterNextPage(tls, p, pIter) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 || (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { + return + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowid = 0 + iOff = int32(4) + } + if iOff < (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist { + iOff = iOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr(iOff), bp)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(iOff) + v1 = pIter + 112 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + **(**Tu64)(__ccgo_up(bp))) + } else { + if (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags&int32(FTS5_SEGITER_ONETERM) == 0 { + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg != 0 { + **(**int32)(__ccgo_up(bp + 8)) = 0 + if iOff != _fts5LeafFirstTermOff(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) { + iOff = iOff + _sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr(iOff), bp+8) + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(iOff) + _fts5SegIterLoadTerm(tls, p, pIter, **(**int32)(__ccgo_up(bp + 8))) + } else { + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 32)) = 0 + _sqlite3Fts5HashScanNext(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash) + _sqlite3Fts5HashScanEntry(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash, bp+24, bp+32, bp+16, bp+36) + if **(**uintptr)(__ccgo_up(bp + 16)) == uintptr(0) { + goto next_none_eof + } + (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp = **(**uintptr)(__ccgo_up(bp + 16)) + (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn = **(**int32)(__ccgo_up(bp + 36)) + (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf = **(**int32)(__ccgo_up(bp + 36)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = **(**int32)(__ccgo_up(bp + 36)) + _sqlite3Fts5BufferSet(tls, p+60, pIter+96, **(**int32)(__ccgo_up(bp + 32)), **(**uintptr)(__ccgo_up(bp + 24))) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = libc.Int64FromUint8(_sqlite3Fts5GetVarint(tls, **(**uintptr)(__ccgo_up(bp + 16)), pIter+112)) + } + if pbNewTerm != 0 { + **(**int32)(__ccgo_up(pbNewTerm)) = int32(1) + } + } else { + goto next_none_eof + } + } + _fts5SegIterLoadNPos(tls, p, pIter) + return + goto next_none_eof +next_none_eof: + ; + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) +} + +// C documentation +// +// /* +// ** Iterator pIter currently points to the first rowid in a doclist. This +// ** function sets the iterator up so that iterates in reverse order through +// ** the doclist. +// */ +func _fts5SegIterReverse(tls *libc.TLS, p uintptr, pIter uintptr) { + var bTermless, iEnd, iOff, iPoslist, iRowid, iSegid, pgno, pgnoLast, v1 int32 + var iAbs Ti64 + var pDlidx, pLast, pLeaf, pNew, pSeg, tmp uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bTermless, iAbs, iEnd, iOff, iPoslist, iRowid, iSegid, pDlidx, pLast, pLeaf, pNew, pSeg, pgno, pgnoLast, tmp, v1 + pDlidx = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpDlidx + pLast = uintptr(0) + pgnoLast = 0 + if pDlidx != 0 && (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FiVersion == int32(FTS5_CURRENT_VERSION) { + iSegid = (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid + pgnoLast = _fts5DlidxIterPgno(tls, pDlidx) + pLast = _fts5LeafRead(tls, p, int64(iSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))<= (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { + pSeg = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg + /* The last rowid in the doclist may not be on the current page. Search + ** forward to find the page containing the last rowid. */ + pgno = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno + int32(1) + for { + if !(!((*TFts5Index)(unsafe.Pointer(p)).Frc != 0) && pgno <= (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast) { + break + } + iAbs = int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B)) + int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)) + int64(libc.Int32FromInt32(0))<= (*TFts5Data)(unsafe.Pointer(pNew)).Fnn) + if iRowid != 0 { + tmp = pNew + pNew = pLast + pLast = tmp + pgnoLast = pgno + } + _fts5DataRelease(tls, pNew) + if bTermless == 0 { + break + } + } + goto _2 + _2: + ; + pgno = pgno + 1 + } + } + } + /* If pLast is NULL at this point, then the last rowid for this doclist + ** lies on the page currently indicated by the iterator. In this case + ** pIter->iLeafOffset is already set to point to the position-list size + ** field associated with the first relevant rowid on the page. + ** + ** Or, if pLast is non-NULL, then it is the page that contains the last + ** rowid. In this case configure the iterator so that it points to the + ** first rowid on this page. + */ + if pLast != 0 { + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pLast + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = pgnoLast + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + iOff = libc.Int32FromUint16(_fts5GetU16(tls, (*TFts5Data)(unsafe.Pointer(pLast)).Fp)) + if iOff > (*TFts5Data)(unsafe.Pointer(pLast)).FszLeaf { + _fts5IndexCorruptIter(tls, p, pIter) + return + } + iOff = iOff + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Data)(unsafe.Pointer(pLast)).Fp+uintptr(iOff), pIter+112)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(iOff) + if (*TFts5Data)(unsafe.Pointer(pLast)).FszLeaf >= (*TFts5Data)(unsafe.Pointer(pLast)).Fnn { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*TFts5Data)(unsafe.Pointer(pLast)).Fnn + int32(1) + } else { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = _fts5LeafFirstTermOff(tls, pLast) + } + } + } + _fts5SegIterReverseInitPage(tls, p, pIter) +} + +// C documentation +// +// /* +// ** This function is only ever called on iterators created by calls to +// ** Fts5IndexQuery() with the FTS5INDEX_QUERY_DESC flag set. +// ** +// ** The iterator is in an unusual state when this function is called: the +// ** Fts5SegIter.iLeafOffset variable is set to the offset of the start of +// ** the position-list size field for the first relevant rowid on the page. +// ** Fts5SegIter.rowid is set, but nPos and bDel are not. +// ** +// ** This function advances the iterator so that it points to the last +// ** relevant rowid on the page and, if necessary, initializes the +// ** aRowidOffset[] and iRowidOffset variables. At this point the iterator +// ** is in its regular state - Fts5SegIter.iLeafOffset points to the first +// ** byte of the position list content associated with said rowid. +// */ +func _fts5SegIterReverseInitPage(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, aNew, v1 uintptr + var eDetail, i, iRowidOffset, n, v2 int32 + var nNew Ti64 + var _ /* bDummy at bp+12 */ int32 + var _ /* iDelta at bp+0 */ Tu64 + var _ /* nPos at bp+8 */ int32 + _, _, _, _, _, _, _, _, _ = a, aNew, eDetail, i, iRowidOffset, n, nNew, v1, v2 + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail + n = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + i = int32((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset) + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + iRowidOffset = 0 + if n > (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist { + n = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist + } + for int32(1) != 0 { + **(**Tu64)(__ccgo_up(bp)) = uint64(0) + if i >= n { + break + } + if eDetail == int32(FTS5_DETAIL_NONE) { + /* todo */ + if i < n && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a + uintptr(i)))) == 0 { + i = i + 1 + if i < n && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a + uintptr(i)))) == 0 { + i = i + 1 + } + } + } else { + i = i + _fts5GetPoslistSize(tls, a+uintptr(i), bp+8, bp+12) + i = i + **(**int32)(__ccgo_up(bp + 8)) + } + if i >= n { + break + } + i = i + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, a+uintptr(i), bp)) + v1 = pIter + 112 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + **(**Tu64)(__ccgo_up(bp))) + /* If necessary, grow the pIter->aRowidOffset[] array. */ + if iRowidOffset >= (*TFts5SegIter)(unsafe.Pointer(pIter)).FnRowidOffset { + nNew = int64((*TFts5SegIter)(unsafe.Pointer(pIter)).FnRowidOffset + int32(8)) + aNew = Xsqlite3_realloc64(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset, libc.Uint64FromInt64(nNew)*uint64(4)) + if aNew == uintptr(0) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + break + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset = aNew + (*TFts5SegIter)(unsafe.Pointer(pIter)).FnRowidOffset = int32(nNew) + } + v2 = iRowidOffset + iRowidOffset = iRowidOffset + 1 + **(**int32)(__ccgo_up((*TFts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset + uintptr(v2)*4)) = int32((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(i) + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset = iRowidOffset + _fts5SegIterLoadNPos(tls, p, pIter) +} + +// C documentation +// +// /* +// ** +// */ +func _fts5SegIterReverseNewPage(tls *libc.TLS, p uintptr, pIter uintptr) { + var a, pNew uintptr + var iRowidOff int32 + _, _, _ = a, iRowidOff, pNew + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno > (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno - 1 + pNew = _fts5DataRead(tls, p, int64((*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))<pLeaf==0, this iterator is at EOF. */ + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno { + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset < (*TFts5Data)(unsafe.Pointer(pNew)).FszLeaf { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pNew + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64((*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset) + } + } else { + iRowidOff = libc.Int32FromUint16(_fts5GetU16(tls, (*TFts5Data)(unsafe.Pointer(pNew)).Fp)) + if iRowidOff != 0 { + if iRowidOff >= (*TFts5Data)(unsafe.Pointer(pNew)).FszLeaf { + _fts5IndexCorruptIter(tls, p, pIter) + } else { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pNew + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(iRowidOff) + } + } + } + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset) + **(**Ti64)(__ccgo_up(pIter + 32)) += libc.Int64FromUint8(_sqlite3Fts5GetVarint(tls, a, pIter+112)) + break + } else { + _fts5DataRelease(tls, pNew) + } + } + } + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn + int32(1) + _fts5SegIterReverseInitPage(tls, p, pIter) + } +} + +// C documentation +// +// /* +// ** Add an entry to the Fts5SFinder.aFirst[] array. Grow the array if +// ** necessary. Return SQLITE_OK if successful, or SQLITE_NOMEM if an +// ** error occurs. +// */ +func _fts5SentenceFinderAdd(tls *libc.TLS, p uintptr, iAdd int32) (r int32) { + var aNew, v3 uintptr + var nNew, v1 int32 + _, _, _, _ = aNew, nNew, v1, v3 + if (*TFts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc == (*TFts5SFinder)(unsafe.Pointer(p)).FnFirst { + if (*TFts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc != 0 { + v1 = (*TFts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc * int32(2) + } else { + v1 = int32(64) + } + nNew = v1 + aNew = Xsqlite3_realloc64(tls, (*TFts5SFinder)(unsafe.Pointer(p)).FaFirst, uint64(libc.Uint64FromInt32(nNew)*uint64(4))) + if aNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TFts5SFinder)(unsafe.Pointer(p)).FaFirst = aNew + (*TFts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc = nNew + } + v3 = p + 8 + v1 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + **(**int32)(__ccgo_up((*TFts5SFinder)(unsafe.Pointer(p)).FaFirst + uintptr(v1)*4)) = iAdd + return SQLITE_OK +} + +// C documentation +// +// /* +// ** If a row with rowid iDel is present in the %_content table, add the +// ** delete-markers to the FTS index necessary to delete it. Do not actually +// ** remove the %_content row at this time though. +// ** +// ** If parameter bSaveRow is true, then Fts5Storage.pSavedRow is left +// ** pointing to a statement (FTS5_STMT_LOOKUP2) that may be used to access +// ** the original values of the row being deleted. This is used by UPDATE +// ** statements. +// */ +func _fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel Ti64, apVal uintptr, bSaveRow int32) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var iCol, rc, rc2 int32 + var pConfig, pFree, pVal, v2 uintptr + var _ /* ctx at bp+8 */ TFts5InsertCtx + var _ /* nLoc at bp+48 */ int32 + var _ /* nText at bp+32 */ int32 + var _ /* pLoc at bp+40 */ uintptr + var _ /* pSeek at bp+0 */ uintptr + var _ /* pText at bp+24 */ uintptr + _, _, _, _, _, _, _ = iCol, pConfig, pFree, pVal, rc, rc2, v2 + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* SELECT to read row iDel from %_data */ + rc = SQLITE_OK + if apVal == uintptr(0) { + if (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow != 0 && bSaveRow != 0 { + **(**uintptr)(__ccgo_up(bp)) = (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow + (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow = uintptr(0) + } else { + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_LOOKUP)+bSaveRow, bp, uintptr(0)) + if rc != SQLITE_OK { + return rc + } + Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iDel) + if Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) != int32(SQLITE_ROW) { + return Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + } + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FpStorage = p + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FiCol = -int32(1) + iCol = int32(1) + for { + if !(rc == SQLITE_OK && iCol <= (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(iCol-int32(1))))) == 0 { + pVal = uintptr(0) + pFree = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 32)) = 0 + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 48)) = 0 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + pVal = Xsqlite3_column_value(tls, **(**uintptr)(__ccgo_up(bp)), iCol) + } else { + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr(iCol-int32(1))*8)) + } + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 && _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + rc = _sqlite3Fts5DecodeLocaleValue(tls, pVal, bp+24, bp+32, bp+40, bp+48) + } else { + if Xsqlite3_value_type(tls, pVal) != int32(SQLITE_TEXT) { + /* Make a copy of the value to work with. This is because the call + ** to sqlite3_value_text() below forces the type of the value to + ** SQLITE_TEXT, and we may need to use it again later. */ + v2 = Xsqlite3_value_dup(tls, pVal) + pVal = v2 + pFree = v2 + if pVal == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp + 24)) = Xsqlite3_value_text(tls, pVal) + **(**int32)(__ccgo_up(bp + 32)) = Xsqlite3_value_bytes(tls, pVal) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 && **(**uintptr)(__ccgo_up(bp)) != 0 { + **(**uintptr)(__ccgo_up(bp + 40)) = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), iCol+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) + **(**int32)(__ccgo_up(bp + 48)) = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), iCol+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) + } + } + } + if rc == SQLITE_OK { + _sqlite3Fts5SetLocale(tls, pConfig, **(**uintptr)(__ccgo_up(bp + 40)), **(**int32)(__ccgo_up(bp + 48))) + (**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FszCol = 0 + rc = _sqlite3Fts5Tokenize(tls, pConfig, int32(FTS5_TOKENIZE_DOCUMENT), **(**uintptr)(__ccgo_up(bp + 24)), **(**int32)(__ccgo_up(bp + 32)), bp+8, __ccgo_fp(_fts5StorageInsertCallback)) + **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(iCol-int32(1))*8)) -= int64((**(**TFts5InsertCtx)(__ccgo_up(bp + 8))).FszCol) + if rc == SQLITE_OK && **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(iCol-int32(1))*8)) < 0 { + rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<pTokenDataIter!=0). This function advances the iterator. If +// ** argument bFrom is false, then the iterator is advanced to the next +// ** entry. Or, if bFrom is true, it is advanced to the first entry with +// ** a rowid of iFrom or greater. +// */ +func _fts5TokendataIterNext(tls *libc.TLS, pIter uintptr, bFrom int32, iFrom Ti64) { + var ii int32 + var p, pIndex, pT uintptr + _, _, _, _ = ii, p, pIndex, pT + pT = (*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter + pIndex = (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex + ii = 0 + for { + if !(int64(ii) < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnIter) { + break + } + p = *(*uintptr)(unsafe.Pointer(pT + 72 + uintptr(ii)*8)) + if libc.Int32FromUint8((*TFts5Iter)(unsafe.Pointer(p)).Fbase.FbEof) == 0 && ((*TFts5Iter)(unsafe.Pointer(p)).Fbase.FiRowid == (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid || bFrom != 0 && (*TFts5Iter)(unsafe.Pointer(p)).Fbase.FiRowid < iFrom) { + _fts5MultiIterNext(tls, pIndex, p, bFrom, iFrom) + for bFrom != 0 && libc.Int32FromUint8((*TFts5Iter)(unsafe.Pointer(p)).Fbase.FbEof) == 0 && (*TFts5Iter)(unsafe.Pointer(p)).Fbase.FiRowid < iFrom && (*TFts5Index)(unsafe.Pointer(pIndex)).Frc == SQLITE_OK { + _fts5MultiIterNext(tls, pIndex, p, 0, 0) + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + if (*TFts5Index)(unsafe.Pointer(pIndex)).Frc == SQLITE_OK { + _fts5IterSetOutputsTokendata(tls, pIter) + } +} + +// C documentation +// +// /* +// ** Return true if, for the purposes of tokenizing with the tokenizer +// ** passed as the first argument, codepoint iCode is considered a token +// ** character (not a separator). +// */ +func _fts5UnicodeIsAlnum(tls *libc.TLS, p uintptr, iCode int32) (r int32) { + return libc.Int32FromUint8(**(**uint8)(__ccgo_up(p + 160 + uintptr(_sqlite3Fts5UnicodeCategory(tls, libc.Uint32FromInt32(iCode)))))) ^ _fts5UnicodeIsException(tls, p, iCode) +} + +// C documentation +// +// /* +// ** Iterate through a range of entries in the FTS index, invoking the xVisit +// ** callback for each of them. +// ** +// ** Parameter pToken points to an nToken buffer containing an FTS index term +// ** (i.e. a document term with the preceding 1 byte index identifier - +// ** FTS5_MAIN_PREFIX or similar). If bPrefix is true, then the call visits +// ** all entries for terms that have pToken/nToken as a prefix. If bPrefix +// ** is false, then only entries with pToken/nToken as the entire key are +// ** visited. +// ** +// ** If the current table is a tokendata=1 table, then if bPrefix is true then +// ** each index term is treated separately. However, if bPrefix is false, then +// ** all index terms corresponding to pToken/nToken are collapsed into a single +// ** term before the callback is invoked. +// ** +// ** The callback invoked for each entry visited is specified by paramter xVisit. +// ** Each time it is invoked, it is passed a pointer to the Fts5Index object, +// ** a copy of the 7th paramter to this function (pCtx) and a pointer to the +// ** iterator that indicates the current entry. If the current entry is the +// ** first with a new term (i.e. different from that of the previous entry, +// ** including the very first term), then the final two parameters are passed +// ** a pointer to the term and its size in bytes, respectively. If the current +// ** entry is not the first associated with its term, these two parameters +// ** are passed 0. +// ** +// ** If parameter pColset is not NULL, then it is used to filter entries before +// ** the callback is invoked. +// */ +func _fts5VisitEntries(tls *libc.TLS, p uintptr, pColset uintptr, pToken uintptr, nToken int32, bPrefix int32, __ccgo_fp_xVisit uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var flags, nNew, v1 int32 + var pNew, pSeg, pStruct uintptr + var _ /* bNewTerm at bp+8 */ int32 + var _ /* p1 at bp+0 */ uintptr + _, _, _, _, _, _ = flags, nNew, pNew, pSeg, pStruct, v1 + if bPrefix != 0 { + v1 = int32(FTS5INDEX_QUERY_SCAN) + } else { + v1 = 0 + } + flags = v1 | int32(FTS5INDEX_QUERY_SKIPEMPTY) | int32(FTS5INDEX_QUERY_NOOUTPUT) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Iterator used to gather data from index */ + **(**int32)(__ccgo_up(bp + 8)) = int32(1) + pStruct = _fts5StructureRead(tls, p) + _fts5MultiIterNew(tls, p, pStruct, flags, pColset, pToken, nToken, -int32(1), 0, bp) + _fts5IterSetOutputCb(tls, p+60, **(**uintptr)(__ccgo_up(bp))) + for { + if !(_fts5MultiIterEof(tls, p, **(**uintptr)(__ccgo_up(bp))) == 0) { + break + } + pSeg = **(**uintptr)(__ccgo_up(bp)) + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaFirst + 1*4))).FiFirst)*128 + nNew = 0 + pNew = uintptr(0) + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Iter)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxSetOutputs})))(tls, **(**uintptr)(__ccgo_up(bp)), pSeg) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + break + } + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + nNew = (*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn + pNew = (*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp + if nNew < nToken || libc.Xmemcmp(tls, pToken, pNew, libc.Uint64FromInt32(nToken)) != 0 { + break + } + } + (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xVisit})))(tls, p, pCtx, **(**uintptr)(__ccgo_up(bp)), pNew, nNew) + goto _2 + _2: + ; + _fts5MultiIterNext2(tls, p, **(**uintptr)(__ccgo_up(bp)), bp+8) + } + _fts5MultiIterFree(tls, **(**uintptr)(__ccgo_up(bp))) + _fts5StructureRelease(tls, pStruct) + return (*TFts5Index)(unsafe.Pointer(p)).Frc +} + +/* Size in bytes of an Fts5TokenDataIter object holding up to N iterators */ + +func _fts5VocabInstanceNewTerm(tls *libc.TLS, pCsr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bCmp, nCmp, v1 int32 + var zTerm uintptr + var _ /* nTerm at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _ = bCmp, nCmp, zTerm, v1 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + if (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = int32(1) + } else { + zTerm = _sqlite3Fts5IterTerm(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter, bp+4) + if (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm >= 0 { + if **(**int32)(__ccgo_up(bp + 4)) < (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm { + v1 = **(**int32)(__ccgo_up(bp + 4)) + } else { + v1 = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm + } + nCmp = v1 + bCmp = libc.Xmemcmp(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zTerm, libc.Uint64FromInt32(nCmp)) + if bCmp < 0 || bCmp == 0 && (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm < **(**int32)(__ccgo_up(bp + 4)) { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = int32(1) + } + } + _sqlite3Fts5BufferSet(tls, bp, pCsr+96, **(**int32)(__ccgo_up(bp + 4)), zTerm) + } + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5WriteAppendPoslistData(tls *libc.TLS, p uintptr, pWriter uintptr, aData uintptr, nData int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, pPage uintptr + var n, nCopy, nReq int32 + var _ /* dummy at bp+0 */ Ti64 + _, _, _, _, _ = a, n, nCopy, nReq, pPage + pPage = pWriter + 8 + a = aData + n = nData + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn+(*TFts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn+n >= (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz { + nReq = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz - (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn - (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn + nCopy = 0 + for nCopy < nReq { + nCopy = nCopy + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, a+uintptr(nCopy), bp)) + } + _sqlite3Fts5BufferAppendBlob(tls, p+60, pPage+8, libc.Uint32FromInt32(nCopy), a) + a = a + uintptr(nCopy) + n = n - nCopy + _fts5WriteFlushLeaf(tls, p, pWriter) + } + if n > 0 { + _sqlite3Fts5BufferAppendBlob(tls, p+60, pPage+8, libc.Uint32FromInt32(n), a) + } +} + +// C documentation +// +// /* +// ** Append a rowid and position-list size field to the writers output. +// */ +func _fts5WriteAppendRowid(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid Ti64) { + var pPage uintptr + _ = pPage + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pPage = pWriter + 8 + if (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn+(*TFts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn >= (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz { + _fts5WriteFlushLeaf(tls, p, pWriter) + } + /* If this is to be the first rowid written to the page, set the + ** rowid-pointer in the page-header. Also append a value to the dlidx + ** buffer, in case a doclist-index is required. */ + if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0 { + _fts5PutU16(tls, (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp, libc.Uint16FromInt32((*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn)) + _fts5WriteDlidxAppend(tls, p, pWriter, iRowid) + } + /* Write the rowid. */ + if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInDoclist != 0 || (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0 { + _sqlite3Fts5BufferAppendVarint(tls, p+60, pPage+8, iRowid) + } else { + _sqlite3Fts5BufferAppendVarint(tls, p+60, pPage+8, libc.Int64FromUint64(libc.Uint64FromInt64(libc.Int64FromUint64(libc.Uint64FromInt64(iRowid)))-libc.Uint64FromInt64((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiPrevRowid))) + } + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiPrevRowid = iRowid + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInDoclist = uint8(0) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage = uint8(0) + } +} + +// C documentation +// +// /* +// ** Append term pTerm/nTerm to the segment being written by the writer passed +// ** as the second argument. +// ** +// ** If an error occurs, set the Fts5Index.rc error code. If an error has +// ** already occurred, this function is a no-op. +// */ +func _fts5WriteAppendTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, pTerm uintptr) { + var n, nMin, nPrefix, v1 int32 + var pPage, pPgidx uintptr + _, _, _, _, _, _ = n, nMin, nPrefix, pPage, pPgidx, v1 /* Bytes of prefix compression for term */ + pPage = pWriter + 8 + pPgidx = pWriter + 8 + 24 + if (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fn < nTerm { + v1 = (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fn + } else { + v1 = nTerm + } + nMin = v1 + /* If the current leaf page is full, flush it to disk. */ + if (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn+(*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn+nTerm+int32(2) >= (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz { + if (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn > int32(4) { + _fts5WriteFlushLeaf(tls, p, pWriter) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return + } + } + if !(libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pPage+8)).Fn)+libc.Uint32FromInt32(nTerm+libc.Int32FromInt32(FTS5_DATA_PADDING)) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pPage+8)).FnSpace)) { + _sqlite3Fts5BufferSize(tls, p+60, pPage+8, libc.Uint32FromInt32(nTerm+int32(FTS5_DATA_PADDING)+(*TFts5Buffer)(unsafe.Pointer(pPage+8)).Fn)) + } + } + /* TODO1: Updating pgidx here. */ + **(**int32)(__ccgo_up(pPgidx + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pPgidx)).Fn), libc.Uint64FromInt32((*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn-(*TFts5PageWriter)(unsafe.Pointer(pPage)).FiPrevPgidx)) + (*TFts5PageWriter)(unsafe.Pointer(pPage)).FiPrevPgidx = (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn + if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage != 0 { + nPrefix = 0 + if (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fpgno != int32(1) { + /* This is the first term on a leaf that is not the leftmost leaf in + ** the segment b-tree. In this case it is necessary to add a term to + ** the b-tree hierarchy that is (a) larger than the largest term + ** already written to the segment and (b) smaller than or equal to + ** this term. In other words, a prefix of (pTerm/nTerm) that is one + ** byte longer than the longest prefix (pTerm/nTerm) shares with the + ** previous term. + ** + ** Usually, the previous term is available in pPage->term. The exception + ** is if this is the first term written in an incremental-merge step. + ** In this case the previous term is not available, so just write a + ** copy of (pTerm/nTerm) into the parent node. This is slightly + ** inefficient, but still correct. */ + n = nTerm + if (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fn != 0 { + n = int32(1) + _fts5PrefixCompress(tls, nMin, (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fp, pTerm) + } + _fts5WriteBtreeTerm(tls, p, pWriter, n, pTerm) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { + return + } + pPage = pWriter + 8 + } + } else { + nPrefix = _fts5PrefixCompress(tls, nMin, (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fp, pTerm) + _sqlite3Fts5BufferAppendVarint(tls, p+60, pPage+8, int64(nPrefix)) + } + /* Append the number of bytes of new data, then the term data itself + ** to the page. */ + _sqlite3Fts5BufferAppendVarint(tls, p+60, pPage+8, int64(nTerm)-int64(nPrefix)) + _sqlite3Fts5BufferAppendBlob(tls, p+60, pPage+8, libc.Uint32FromInt32(nTerm-nPrefix), pTerm+uintptr(nPrefix)) + /* Update the Fts5PageWriter.term field. */ + _sqlite3Fts5BufferSet(tls, p+60, pPage+40, nTerm, pTerm) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage = uint8(0) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage = uint8(0) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInDoclist = uint8(1) + (**(**TFts5DlidxWriter)(__ccgo_up((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx))).Fpgno = (*TFts5PageWriter)(unsafe.Pointer(pPage)).Fpgno +} + +// C documentation +// +// /* +// ** Rowid iRowid has just been appended to the current leaf page. It is the +// ** first on the page. This function appends an appropriate entry to the current +// ** doclist-index. +// */ +func _fts5WriteDlidxAppend(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid Ti64) { + var bDone, i, v2 int32 + var iFirst, iPgno, iVal Ti64 + var pDlidx uintptr + _, _, _, _, _, _, _ = bDone, i, iFirst, iPgno, iVal, pDlidx, v2 + bDone = 0 + i = 0 + for { + if !((*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bDone == 0) { + break + } + pDlidx = (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32 + if (*TFts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn >= (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz { + /* The current doclist-index page is full. Write it to disk and push + ** a copy of iRowid (which will become the first rowid on the next + ** doclist-index leaf page) up into the next level of the b-tree + ** hierarchy. If the node being flushed is currently the root node, + ** also push its first rowid upwards. */ + **(**Tu8)(__ccgo_up((*TFts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp)) = uint8(0x01) /* Not the root node */ + _fts5DataWrite(tls, p, int64((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(1))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(i)<= iLo { + iTest = (iHi + iLo) / int32(2) + if key >= uint32(aDia[iTest]) { + iRes = iTest + iLo = iTest + int32(1) + } else { + iHi = iTest - int32(1) + } + } + if bComplex == 0 && libc.Int32FromUint8(aChar[iRes])&int32(0x80) != 0 { + return c + } + if c > libc.Int32FromUint16(aDia[iRes])>>int32(3)+libc.Int32FromUint16(aDia[iRes])&int32(0x07) { + v1 = c + } else { + v1 = libc.Int32FromUint8(aChar[iRes]) & int32(0x7F) + } + return v1 +} + +// C documentation +// +// /* +// ** Perform a reduce action and the shift that must immediately +// ** follow the reduce. +// ** +// ** The fts5yyLookahead and fts5yyLookaheadToken parameters provide reduce actions +// ** access to the lookahead token (if any). The fts5yyLookahead will be fts5YYNOCODE +// ** if the lookahead token has already been consumed. As this procedure is +// ** only called from one place, optimizing compilers will in-line it, which +// ** means that the extra parameters have no performance impact. +// */ +func _fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, fts5yyLookahead int32, fts5yyLookaheadToken TFts5Token) (r uint8) { + var fts5yyact uint8 + var fts5yygoto, fts5yysize int32 + var fts5yylhsminor Tfts5YYMINORTYPE + var fts5yymsp, pParse uintptr + _, _, _, _, _, _ = fts5yyact, fts5yygoto, fts5yylhsminor, fts5yymsp, fts5yysize, pParse /* Amount to pop the stack */ + pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse + _ = fts5yyLookahead + _ = fts5yyLookaheadToken + fts5yymsp = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos + switch fts5yyruleno { + case uint32(0): + goto _1 + case uint32(1): + goto _2 + case uint32(2): + goto _3 + case uint32(3): + goto _4 + case uint32(4): + goto _5 + case uint32(5): + goto _6 + case uint32(6): + goto _7 + case uint32(7): + goto _8 + case uint32(8): + goto _9 + case uint32(9): + goto _10 + case uint32(10): + goto _11 + case uint32(11): + goto _12 + case uint32(13): + goto _13 + case uint32(12): + goto _14 + case uint32(14): + goto _15 + case uint32(15): + goto _16 + case uint32(16): + goto _17 + case uint32(17): + goto _18 + case uint32(18): + goto _19 + case uint32(19): + goto _20 + case uint32(20): + goto _21 + case uint32(21): + goto _22 + case uint32(22): + goto _23 + case uint32(23): + goto _24 + case uint32(24): + goto _25 + case uint32(25): + goto _26 + case uint32(26): + goto _27 + case uint32(27): + goto _28 + default: + goto _29 + } + goto _30 +_1: + ; /* input ::= expr */ + _sqlite3Fts5ParseFinished(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + goto _30 +_2: + ; /* colset ::= MINUS LCP colsetlist RCP */ + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3Fts5ParseColsetInvert(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _30 +_3: + ; /* colset ::= LCP colsetlist RCP */ + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _30 +_4: + ; /* colset ::= STRING */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseColset(tls, pParse, uintptr(0), fts5yymsp+8) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_5: + ; /* colset ::= MINUS STRING */ + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3Fts5ParseColset(tls, pParse, uintptr(0), fts5yymsp+8) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3Fts5ParseColsetInvert(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _30 +_6: + ; /* colsetlist ::= colsetlist STRING */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseColset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), fts5yymsp+8) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_7: + ; /* colsetlist ::= STRING */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseColset(tls, pParse, uintptr(0), fts5yymsp+8) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_8: + ; /* expr ::= expr AND expr */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseNode(tls, pParse, int32(FTS5_AND), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_9: + ; /* expr ::= expr OR expr */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseNode(tls, pParse, int32(FTS5_OR), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_10: + ; /* expr ::= expr NOT expr */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseNode(tls, pParse, int32(FTS5_NOT), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_11: + ; /* expr ::= colset COLON LP expr RP */ + _sqlite3Fts5ParseSetColset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_12: + ; /* expr ::= LP expr RP */ + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _30 +_14: + ; /* expr ::= exprlist */ +_13: + ; + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_15: + ; /* exprlist ::= exprlist cnearset */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseImplicitAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_16: + ; /* cnearset ::= nearset */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseNode(tls, pParse, int32(FTS5_STRING), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_17: + ; /* cnearset ::= colset COLON nearset */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseNode(tls, pParse, int32(FTS5_STRING), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + _sqlite3Fts5ParseSetColset(tls, pParse, *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_18: + ; /* nearset ::= phrase */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_19: + ; /* nearset ::= CARET phrase */ + _sqlite3Fts5ParseSetCaret(tls, *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + goto _30 +_20: + ; /* nearset ::= STRING LP nearphrases neardist_opt RP */ + _sqlite3Fts5ParseNear(tls, pParse, fts5yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + _sqlite3Fts5ParseSetDistance(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), fts5yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_21: + ; /* nearphrases ::= phrase */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_22: + ; /* nearphrases ::= nearphrases phrase */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseNearset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_23: + ; /* neardist_opt ::= */ + *(*uintptr)(unsafe.Pointer(fts5yymsp + 1*24 + 8)) = uintptr(0) + *(*int32)(unsafe.Pointer(fts5yymsp + 1*24 + 8 + 8)) = 0 + goto _30 +_24: + ; /* neardist_opt ::= COMMA STRING */ + *(*TFts5Token)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFts5Token)(unsafe.Pointer(fts5yymsp + 8)) + goto _30 +_25: + ; /* phrase ::= phrase PLUS STRING star_opt */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), fts5yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*int32)(unsafe.Pointer(fts5yymsp + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_26: + ; /* phrase ::= STRING star_opt */ + *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) = _sqlite3Fts5ParseTerm(tls, pParse, uintptr(0), fts5yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*int32)(unsafe.Pointer(fts5yymsp + 8))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&fts5yylhsminor)) + goto _30 +_27: + ; /* star_opt ::= STAR */ + *(*int32)(unsafe.Pointer(fts5yymsp + 8)) = int32(1) + goto _30 +_28: + ; /* star_opt ::= */ + *(*int32)(unsafe.Pointer(fts5yymsp + 1*24 + 8)) = 0 + goto _30 +_29: + ; + goto _30 + /********** End reduce actions ************************************************/ +_30: + ; + fts5yygoto = libc.Int32FromUint8(_fts5yyRuleInfoLhs[fts5yyruleno]) + fts5yysize = int32(_fts5yyRuleInfoNRhs[fts5yyruleno]) + fts5yyact = _fts5yy_find_reduce_action(tls, (**(**Tfts5yyStackEntry)(__ccgo_up(fts5yymsp + uintptr(fts5yysize)*24))).Fstateno, libc.Uint8FromInt32(fts5yygoto)) + /* There are no SHIFTREDUCE actions on nonterminals because the table + ** generator has simplified them to pure REDUCE actions. */ + /* It is not possible for a REDUCE to be followed by an error */ + fts5yymsp = fts5yymsp + uintptr(fts5yysize+int32(1))*24 + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos = fts5yymsp + (*Tfts5yyStackEntry)(unsafe.Pointer(fts5yymsp)).Fstateno = fts5yyact + (*Tfts5yyStackEntry)(unsafe.Pointer(fts5yymsp)).Fmajor = libc.Uint8FromInt32(fts5yygoto) + return fts5yyact +} + +/* +** The following code executes when the parse fails + */ + +// C documentation +// +// /* +// ** Perform a shift action. +// */ +func _fts5yy_shift(tls *libc.TLS, fts5yypParser uintptr, fts5yyNewState uint8, fts5yyMajor uint8, fts5yyMinor TFts5Token) { + var fts5yytos uintptr + _ = fts5yytos + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos += 24 + fts5yytos = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos + if fts5yytos > (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd { + if int32(1) != 0 { + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos -= 24 + _fts5yyStackOverflow(tls, fts5yypParser) + return + } + fts5yytos = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos + } + if libc.Int32FromUint8(fts5yyNewState) > int32(fts5YY_MAX_SHIFT) { + fts5yyNewState = libc.Uint8FromInt32(int32(fts5yyNewState) + (libc.Int32FromInt32(fts5YY_MIN_REDUCE) - libc.Int32FromInt32(fts5YY_MIN_SHIFTREDUCE))) + } + (*Tfts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fstateno = fts5yyNewState + (*Tfts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fmajor = fts5yyMajor + *(*TFts5Token)(unsafe.Pointer(fts5yytos + 8)) = fts5yyMinor +} + +// C documentation +// +// /* +// ** The gatherSelectWindows() procedure and its helper routine +// ** gatherSelectWindowsCallback() are used to scan all the expressions +// ** an a newly duplicated SELECT statement and gather all of the Window +// ** objects found there, assembling them onto the linked list at Select->pWin. +// */ +func _gatherSelectWindowsCallback(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var pSelect, pWin uintptr + _, _ = pSelect, pWin + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_FUNCTION) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + pSelect = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pWin = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + _sqlite3WindowLink(tls, pSelect, pWin) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** GEOPOLY virtual table module xColumn method. +// */ +func _geopolyColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p, pCsr, pNode, pRtree uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _ = p, pCsr, pNode, pRtree + pRtree = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab + pCsr = cur + p = _rtreeSearchPointFirst(tls, pCsr) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + pNode = _rtreeNodeOfFirstSearchPoint(tls, pCsr, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + if p == uintptr(0) { + return SQLITE_OK + } + if i == 0 && Xsqlite3_vtab_nochange(tls, ctx) != 0 { + return SQLITE_OK + } + if i <= libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux) { + if !((*TRtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid != 0) { + if (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_prepare_v3(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, (*TRtree)(unsafe.Pointer(pRtree)).FzReadAuxSql, -int32(1), uint32(0), pCsr+56, uintptr(0)) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + Xsqlite3_bind_int64(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, int32(1), _nodeGetRowid(tls, pRtree, pNode, libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) + **(**int32)(__ccgo_up(bp)) = Xsqlite3_step(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_ROW) { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = uint8(1) + } else { + Xsqlite3_reset(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_DONE) { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + } + return **(**int32)(__ccgo_up(bp)) + } + } + Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, i+int32(2))) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Make sure the BtCursor* given in the argument has a valid +// ** BtCursor.info structure. If it is not already valid, call +// ** btreeParseCell() to fill it in. +// ** +// ** BtCursor.info is a cache of the information in the current cell. +// ** Using this cache reduces the number of calls to btreeParseCell(). +// */ +func _getCellInfo(tls *libc.TLS, pCur uintptr) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize) == 0 { + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTCF_ValidNKey)) + _btreeParseCell(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage, libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix), pCur+48) + } else { + } +} + +// C documentation +// +// /* +// ** Given the page number of an overflow page in the database (parameter +// ** ovfl), this function finds the page number of the next page in the +// ** linked list of overflow pages. If possible, it uses the auto-vacuum +// ** pointer-map data instead of reading the content of page ovfl to do so. +// ** +// ** If an error occurs an SQLite error code is returned. Otherwise: +// ** +// ** The page number of the next overflow page in the linked list is +// ** written to *pPgnoNext. If page ovfl is the last page in its linked +// ** list, *pPgnoNext is set to zero. +// ** +// ** If ppPage is not NULL, and a reference to the MemPage object corresponding +// ** to page number pOvfl was obtained, then *ppPage is set to point to that +// ** reference. It is the responsibility of the caller to call releasePage() +// ** on *ppPage to free the reference. In no reference was obtained (because +// ** the pointer-map was used to obtain the value for *pPgnoNext), then +// ** *ppPage is set to zero. +// */ +func _getOverflowPage(tls *libc.TLS, pBt uintptr, ovfl TPgno, ppPage uintptr, pPgnoNext uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iGuess, next TPgno + var rc, v1 int32 + var _ /* eType at bp+12 */ Tu8 + var _ /* pPage at bp+0 */ uintptr + var _ /* pgno at bp+8 */ TPgno + _, _, _, _ = iGuess, next, rc, v1 + next = uint32(0) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + /* Try to find the next page in the overflow list using the + ** autovacuum pointer-map pages. Guess that the next page in + ** the overflow list is page number (ovfl+1). If that guess turns + ** out to be wrong, fall back to loading the data of page + ** number ovfl to determine the next page number. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + iGuess = ovfl + uint32(1) + for _ptrmapPageno(tls, pBt, iGuess) == iGuess || iGuess == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + iGuess = iGuess + 1 + } + if iGuess <= _btreePagecount(tls, pBt) { + rc = _ptrmapGet(tls, pBt, iGuess, bp+12, bp+8) + if rc == SQLITE_OK && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp + 12))) == int32(PTRMAP_OVERFLOW2) && **(**TPgno)(__ccgo_up(bp + 8)) == ovfl { + next = iGuess + rc = int32(SQLITE_DONE) + } + } + } + if rc == SQLITE_OK { + if ppPage == uintptr(0) { + v1 = int32(PAGER_GET_READONLY) + } else { + v1 = 0 + } + rc = _btreeGetPage(tls, pBt, ovfl, bp, v1) + if rc == SQLITE_OK { + next = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData) + } + } + **(**TPgno)(__ccgo_up(pPgnoNext)) = next + if ppPage != 0 { + **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up(bp)) + } else { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + } + if rc == int32(SQLITE_DONE) { + v1 = SQLITE_OK + } else { + v1 = rc + } + return v1 +} + +// C documentation +// +// /* +// ** Resize the Vdbe.aOp array so that it is at least nOp elements larger +// ** than its current size. nOp is guaranteed to be less than or equal +// ** to 1024/sizeof(Op). +// ** +// ** If an out-of-memory error occurs while resizing the array, return +// ** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain +// ** unchanged (this is so that any opcodes already allocated can be +// ** correctly deallocated along with the rest of the Vdbe). +// */ +func _growOpArray(tls *libc.TLS, v uintptr, nOp int32) (r int32) { + var nNew Tsqlite3_int64 + var p, pNew uintptr + var v1 int64 + var v2 int32 + _, _, _, _, _ = nNew, p, pNew, v1, v2 + p = (*TVdbe)(unsafe.Pointer(v)).FpParse + if (*TVdbe)(unsafe.Pointer(v)).FnOpAlloc != 0 { + v1 = int64(2) * int64((*TVdbe)(unsafe.Pointer(v)).FnOpAlloc) + } else { + v1 = libc.Int64FromUint64(libc.Uint64FromInt32(1024) / libc.Uint64FromInt64(24)) + } + /* The SQLITE_TEST_REALLOC_STRESS compile-time option is designed to force + ** more frequent reallocs and hence provide more opportunities for + ** simulated OOM faults. SQLITE_TEST_REALLOC_STRESS is generally used + ** during testing only. With SQLITE_TEST_REALLOC_STRESS grow the op array + ** by the minimum* amount required until the size reaches 512. Normal + ** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current + ** size of the op array or add 1KB of space, whichever is smaller. */ + nNew = v1 + _ = nOp + /* Ensure that the size of a VDBE does not grow too large */ + if nNew > int64(**(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(p)).Fdb + 136 + 5*4))) { + _sqlite3OomFault(tls, (*TParse)(unsafe.Pointer(p)).Fdb) + return int32(SQLITE_NOMEM) + } + pNew = _sqlite3DbRealloc(tls, (*TParse)(unsafe.Pointer(p)).Fdb, (*TVdbe)(unsafe.Pointer(v)).FaOp, libc.Uint64FromInt64(nNew)*uint64(24)) + if pNew != 0 { + (*TParse)(unsafe.Pointer(p)).FszOpAlloc = _sqlite3DbMallocSize(tls, (*TParse)(unsafe.Pointer(p)).Fdb, pNew) + (*TVdbe)(unsafe.Pointer(v)).FnOpAlloc = libc.Int32FromUint64(libc.Uint64FromInt32((*TParse)(unsafe.Pointer(p)).FszOpAlloc) / uint64(24)) + (*TVdbe)(unsafe.Pointer(v)).FaOp = pNew + } + if pNew != 0 { + v2 = SQLITE_OK + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 +} + +// C documentation +// +// /* +// ** sqlite3WalkExpr() callback used by havingToWhere(). +// ** +// ** If the node passed to the callback is a TK_AND node, return +// ** WRC_Continue to tell sqlite3WalkExpr() to iterate through child nodes. +// ** +// ** Otherwise, return WRC_Prune. In this case, also check if the +// ** sub-expression matches the criteria for being moved to the WHERE +// ** clause. If so, add it to the WHERE clause and replace the sub-expression +// ** within the HAVING expression with a constant "1". +// */ +func _havingToWhereExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var db, pNew, pS, pWhere uintptr + var t TExpr + _, _, _, _, _ = db, pNew, pS, pWhere, t + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_AND) { + pS = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + /* This routine is called before the HAVING clause of the current + ** SELECT is analyzed for aggregates. So if pExpr->pAggInfo is set + ** here, it indicates that the expression is a correlated reference to a + ** column from an outer aggregate query, or an aggregate function that + ** belongs to an outer query. Do not move the expression to the WHERE + ** clause in this obscure case, as doing so may corrupt the outer Select + ** statements AggInfo structure. */ + if _sqlite3ExprIsConstantOrGroupBy(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, pExpr, (*TSelect)(unsafe.Pointer(pS)).FpGroupBy) != 0 && libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsFalse)) == uint32(EP_IsFalse)) == 0 && (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) { + db = (*TParse)(unsafe.Pointer((*TWalker)(unsafe.Pointer(pWalker)).FpParse)).Fdb + pNew = _sqlite3ExprInt32(tls, db, int32(1)) + if pNew != 0 { + pWhere = (*TSelect)(unsafe.Pointer(pS)).FpWhere + t = **(**TExpr)(__ccgo_up(pNew)) + **(**TExpr)(__ccgo_up(pNew)) = **(**TExpr)(__ccgo_up(pExpr)) + **(**TExpr)(__ccgo_up(pExpr)) = t + pNew = _sqlite3ExprAnd(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, pWhere, pNew) + (*TSelect)(unsafe.Pointer(pS)).FpWhere = pNew + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(1) + } + } + return int32(WRC_Prune) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** This is the Expr node callback for sqlite3ExprImpliesNonNullRow(). +// ** If the expression node requires that the table at pWalker->iCur +// ** have one or more non-NULL column, then set pWalker->eCode to 1 and abort. +// ** +// ** pWalker->mWFlags is non-zero if this inquiry is being undertaking on +// ** behalf of a RIGHT JOIN (or FULL JOIN). That makes a difference when +// ** evaluating terms in the ON clause of an inner join. +// ** +// ** This routine controls an optimization. False positives (setting +// ** pWalker->eCode to 1 when it should not be) are deadly, but false-negatives +// ** (never setting pWalker->eCode) is a harmless missed optimization. +// */ +func _impliesNotNullRow(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var pLeft, pRight uintptr + _, _ = pLeft, pRight + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) { + return int32(WRC_Prune) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) != uint32(0) && (*TWalker)(unsafe.Pointer(pWalker)).FmWFlags != 0 { + /* If iCur is used in an inner-join ON clause to the left of a + ** RIGHT JOIN, that does *not* mean that the table must be non-null. + ** But it is difficult to check for that condition precisely. + ** To keep things simple, any use of iCur from any inner-join is + ** ignored while attempting to simplify a RIGHT JOIN. */ + return int32(WRC_Prune) + } + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + case int32(TK_ISNOT): + fallthrough + case int32(TK_ISNULL): + fallthrough + case int32(TK_NOTNULL): + fallthrough + case int32(TK_IS): + fallthrough + case int32(TK_VECTOR): + fallthrough + case int32(TK_FUNCTION): + fallthrough + case int32(TK_TRUTH): + fallthrough + case int32(TK_CASE): + return int32(WRC_Prune) + case int32(TK_COLUMN): + if *(*int32)(unsafe.Pointer(&(*TWalker)(unsafe.Pointer(pWalker)).Fu)) == (*TExpr)(unsafe.Pointer(pExpr)).FiTable { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(1) + return int32(WRC_Abort) + } + return int32(WRC_Prune) + case int32(TK_OR): + fallthrough + case int32(TK_AND): + /* Both sides of an AND or OR must separately imply non-null-row. + ** Consider these cases: + ** 1. NOT (x AND y) + ** 2. x OR y + ** If only one of x or y is non-null-row, then the overall expression + ** can be true if the other arm is false (case 1) or true (case 2). + */ + _bothImplyNotNullRow(tls, pWalker, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + return int32(WRC_Prune) + case int32(TK_IN): + /* Beware of "x NOT IN ()" and "x NOT IN (SELECT 1 WHERE false)", + ** both of which can be true. But apart from these cases, if + ** the left-hand side of the IN is NULL then the IN itself will be + ** NULL. */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) == uint32(0) && (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr > 0 { + _sqlite3WalkExpr(tls, pWalker, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + } + return int32(WRC_Prune) + case int32(TK_BETWEEN): + /* In "x NOT BETWEEN y AND z" either x must be non-null-row or else + ** both y and z must be non-null row */ + _sqlite3WalkExpr(tls, pWalker, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + _bothImplyNotNullRow(tls, pWalker, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr) + return int32(WRC_Prune) + /* Virtual tables are allowed to use constraints like x=NULL. So + ** a term of the form x=y does not prove that y is not null if x + ** is the column of a virtual table */ + fallthrough + case int32(TK_EQ): + fallthrough + case int32(TK_NE): + fallthrough + case int32(TK_LT): + fallthrough + case int32(TK_LE): + fallthrough + case int32(TK_GT): + fallthrough + case int32(TK_GE): + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + /* The y.pTab=0 assignment in wherecode.c always happens after the + ** impliesNotNullRow() test */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) == int32(TK_COLUMN) && *(*uintptr)(unsafe.Pointer(pLeft + 64)) != uintptr(0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64)))).FeTabType) == int32(TABTYP_VTAB) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) == int32(TK_COLUMN) && *(*uintptr)(unsafe.Pointer(pRight + 64)) != uintptr(0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 64)))).FeTabType) == int32(TABTYP_VTAB) { + return int32(WRC_Prune) + } + fallthrough + default: + return WRC_Continue + } + return r +} + +// C documentation +// +// /* +// ** Walk the expression tree pExpr and increase the aggregate function +// ** depth (the Expr.op2 field) by N on every TK_AGG_FUNCTION node. +// ** This needs to occur when copying a TK_AGG_FUNCTION node from an +// ** outer query into an inner subquery. +// ** +// ** incrAggFunctionDepth(pExpr,n) is the main routine. incrAggDepth(..) +// ** is a helper function - a callback for the tree walker. +// ** +// ** See also the sqlite3WindowExtraAggFuncDepth() routine in window.c +// */ +func _incrAggDepth(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_FUNCTION) { + v1 = pExpr + 2 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) + *(*int32)(unsafe.Pointer(&(*TWalker)(unsafe.Pointer(pWalker)).Fu))) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Perform a single step of an incremental-vacuum. If successful, return +// ** SQLITE_OK. If there is no work to do (and therefore no point in +// ** calling this function again), return SQLITE_DONE. Or, if an error +// ** occurs, return some other error code. +// ** +// ** More specifically, this function attempts to re-organize the database so +// ** that the last page of the file currently in use is no longer in use. +// ** +// ** Parameter nFin is the number of pages that this database would contain +// ** were this function called until it returns SQLITE_DONE. +// ** +// ** If the bCommit parameter is non-zero, this function assumes that the +// ** caller will keep calling incrVacuumStep() until it returns SQLITE_DONE +// ** or an error. bCommit is passed true for an auto-vacuum-on-commit +// ** operation, or false for an incremental vacuum. +// */ +func _incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin TPgno, iLastPg TPgno, bCommit int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var dbSize, iNear, nFreeList TPgno + var eMode Tu8 + var rc int32 + var _ /* eType at bp+0 */ Tu8 + var _ /* iFreePg at bp+24 */ TPgno + var _ /* iFreePg at bp+8 */ TPgno + var _ /* iPtrPage at bp+4 */ TPgno + var _ /* pFreePg at bp+16 */ uintptr + var _ /* pFreePg at bp+40 */ uintptr + var _ /* pLastPg at bp+32 */ uintptr + _, _, _, _, _ = dbSize, eMode, iNear, nFreeList, rc + if !(_ptrmapPageno(tls, pBt, iLastPg) == iLastPg) && iLastPg != libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + nFreeList = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36) + if nFreeList == uint32(0) { + return int32(SQLITE_DONE) + } + rc = _ptrmapGet(tls, pBt, iLastPg, bp, bp+4) + if rc != SQLITE_OK { + return rc + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp))) == int32(PTRMAP_ROOTPAGE) { + return _sqlite3CorruptError(tls, int32(77196)) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp))) == int32(PTRMAP_FREEPAGE) { + if bCommit == 0 { + rc = _allocateBtreePage(tls, pBt, bp+16, bp+8, iLastPg, uint8(BTALLOC_EXACT)) + if rc != SQLITE_OK { + return rc + } + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 16))) + } + } else { + eMode = uint8(BTALLOC_ANY) /* Mode parameter for allocateBtreePage() */ + iNear = uint32(0) /* nearby parameter for allocateBtreePage() */ + rc = _btreeGetPage(tls, pBt, iLastPg, bp+32, 0) + if rc != SQLITE_OK { + return rc + } + /* If bCommit is zero, this loop runs exactly once and page pLastPg + ** is swapped with the first free page pulled off the free list. + ** + ** On the other hand, if bCommit is greater than zero, then keep + ** looping until a free-page located within the first nFin pages + ** of the file is found. + */ + if bCommit == 0 { + eMode = uint8(BTALLOC_LE) + iNear = nFin + } + for cond := true; cond; cond = bCommit != 0 && **(**TPgno)(__ccgo_up(bp + 24)) > nFin { + dbSize = _btreePagecount(tls, pBt) + rc = _allocateBtreePage(tls, pBt, bp+40, bp+24, iNear, eMode) + if rc != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 32))) + return rc + } + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 40))) + if **(**TPgno)(__ccgo_up(bp + 24)) > dbSize { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 32))) + return _sqlite3CorruptError(tls, int32(77248)) + } + } + rc = _relocatePage(tls, pBt, **(**uintptr)(__ccgo_up(bp + 32)), **(**Tu8)(__ccgo_up(bp)), **(**TPgno)(__ccgo_up(bp + 4)), **(**TPgno)(__ccgo_up(bp + 24)), bCommit) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp + 32))) + if rc != SQLITE_OK { + return rc + } + } + } + if bCommit == 0 { + for cond := true; cond; cond = iLastPg == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) || _ptrmapPageno(tls, pBt, iLastPg) == iLastPg { + iLastPg = iLastPg - 1 + } + (*TBtShared)(unsafe.Pointer(pBt)).FbDoTruncate = uint8(1) + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = iLastPg + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return True if it is possible that pIndex might be useful in +// ** implementing the ORDER BY clause in pBuilder. +// ** +// ** Return False if pBuilder does not contain an ORDER BY clause or +// ** if there is no way for pIndex to be useful in implementing that +// ** ORDER BY clause. +// */ +func _indexMightHelpWithOrderBy(tls *libc.TLS, pBuilder uintptr, pIndex uintptr, iCursor int32) (r int32) { + var aColExpr, pExpr, pOB, v1 uintptr + var ii, jj int32 + _, _, _, _, _, _ = aColExpr, ii, jj, pExpr, pOB, v1 + if int32(uint32(*(*uint16)(unsafe.Pointer(pIndex + 100))&0x4>>2)) != 0 { + return 0 + } + v1 = (*TWhereInfo)(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpOrderBy + pOB = v1 + if v1 == uintptr(0) { + return 0 + } + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pOB)).FnExpr) { + break + } + pExpr = _sqlite3ExprSkipCollateAndLikely(tls, (*(*TExprList_item)(unsafe.Pointer(pOB + 8 + uintptr(ii)*32))).FpExpr) + if pExpr == uintptr(0) { + goto _2 + } + if (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_COLUMN)) && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == iCursor { + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) < 0 { + return int32(1) + } + jj = 0 + for { + if !(jj < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol)) { + break + } + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) == int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(jj)*2))) { + return int32(1) + } + goto _3 + _3: + ; + jj = jj + 1 + } + } else { + v1 = (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr + aColExpr = v1 + if v1 != uintptr(0) { + jj = 0 + for { + if !(jj < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(jj)*2))) != -int32(2) { + goto _5 + } + if _sqlite3ExprCompareSkip(tls, pExpr, (*(*TExprList_item)(unsafe.Pointer(aColExpr + 8 + uintptr(jj)*32))).FpExpr, iCursor) == 0 { + return int32(1) + } + goto _5 + _5: + ; + jj = jj + 1 + } + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Populate the pIdx->aAvgEq[] array based on the samples currently +// ** stored in pIdx->aSample[]. +// */ +func _initAvgEq(tls *libc.TLS, pIdx uintptr) { + var aSample, pFinal uintptr + var avgEq, nRow, sumEq TtRowcnt + var i, iCol, nCol, nSample int32 + var nDist100, nSum100 Ti64 + _, _, _, _, _, _, _, _, _, _, _ = aSample, avgEq, i, iCol, nCol, nDist100, nRow, nSample, nSum100, pFinal, sumEq + if pIdx != 0 { + aSample = (*TIndex)(unsafe.Pointer(pIdx)).FaSample + pFinal = aSample + uintptr((*TIndex)(unsafe.Pointer(pIdx)).FnSample-int32(1))*40 + nCol = int32(1) + if (*TIndex)(unsafe.Pointer(pIdx)).FnSampleCol > int32(1) { + /* If this is stat4 data, then calculate aAvgEq[] values for all + ** sample columns except the last. The last is always set to 1, as + ** once the trailing PK fields are considered all index keys are + ** unique. */ + nCol = (*TIndex)(unsafe.Pointer(pIdx)).FnSampleCol - int32(1) + **(**TtRowcnt)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr(nCol)*8)) = uint64(1) + } + iCol = 0 + for { + if !(iCol < nCol) { + break + } + nSample = (*TIndex)(unsafe.Pointer(pIdx)).FnSample /* Used to iterate through samples */ + sumEq = uint64(0) /* Sum of the nEq values */ + avgEq = uint64(0) /* Number of rows in index */ + nSum100 = 0 /* Number of distinct values in index */ + if !((*TIndex)(unsafe.Pointer(pIdx)).FaiRowEst != 0) || iCol >= libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) || **(**TtRowcnt)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr(iCol+int32(1))*8)) == uint64(0) { + nRow = **(**TtRowcnt)(__ccgo_up((*TIndexSample)(unsafe.Pointer(pFinal)).FanLt + uintptr(iCol)*8)) + nDist100 = libc.Int64FromUint64(libc.Uint64FromInt64(libc.Int64FromInt32(100)) * **(**TtRowcnt)(__ccgo_up((*TIndexSample)(unsafe.Pointer(pFinal)).FanDLt + uintptr(iCol)*8))) + nSample = nSample - 1 + } else { + nRow = **(**TtRowcnt)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiRowEst)) + nDist100 = libc.Int64FromUint64(libc.Uint64FromInt64(libc.Int64FromInt32(100)) * **(**TtRowcnt)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiRowEst)) / **(**TtRowcnt)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr(iCol+int32(1))*8))) + } + (*TIndex)(unsafe.Pointer(pIdx)).FnRowEst0 = nRow + /* Set nSum to the number of distinct (iCol+1) field prefixes that + ** occur in the stat4 table for this index. Set sumEq to the sum of + ** the nEq values for column iCol for the same set (adding the value + ** only once where there exist duplicate prefixes). */ + i = 0 + for { + if !(i < nSample) { + break + } + if i == (*TIndex)(unsafe.Pointer(pIdx)).FnSample-int32(1) || **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(i)*40))).FanDLt + uintptr(iCol)*8)) != **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(i+int32(1))*40))).FanDLt + uintptr(iCol)*8)) { + sumEq = sumEq + **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(i)*40))).FanEq + uintptr(iCol)*8)) + nSum100 = nSum100 + int64(100) + } + goto _2 + _2: + ; + i = i + 1 + } + if nDist100 > nSum100 && sumEq < nRow { + avgEq = libc.Uint64FromInt64(libc.Int64FromInt32(100)) * (nRow - sumEq) / libc.Uint64FromInt64(nDist100-nSum100) + } + if avgEq == uint64(0) { + avgEq = uint64(1) + } + **(**TtRowcnt)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr(iCol)*8)) = avgEq + goto _1 + _1: + ; + iCol = iCol + 1 + } + } +} + +// C documentation +// +// /* +// ** Implementation of the instr() function. +// ** +// ** instr(haystack,needle) finds the first occurrence of needle +// ** in haystack and returns the number of previous characters plus 1, +// ** or 0 if needle does not occur within haystack. +// ** +// ** If both haystack and needle are BLOBs, then the result is one more than +// ** the number of bytes in haystack prior to the first occurrence of needle, +// ** or 0 if needle never occurs in haystack. +// */ +func _instrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var N, isText, nHaystack, nNeedle, typeHaystack, typeNeedle int32 + var firstChar uint8 + var pC1, pC2, zHaystack, zNeedle uintptr + _, _, _, _, _, _, _, _, _, _, _ = N, firstChar, isText, nHaystack, nNeedle, pC1, pC2, typeHaystack, typeNeedle, zHaystack, zNeedle + N = int32(1) + pC1 = uintptr(0) + pC2 = uintptr(0) + _ = argc + typeHaystack = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) + typeNeedle = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if typeHaystack == int32(SQLITE_NULL) || typeNeedle == int32(SQLITE_NULL) { + return + } + nHaystack = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + nNeedle = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if nNeedle > 0 { + if typeHaystack == int32(SQLITE_BLOB) && typeNeedle == int32(SQLITE_BLOB) { + zHaystack = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + zNeedle = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + isText = 0 + } else { + if typeHaystack != int32(SQLITE_BLOB) && typeNeedle != int32(SQLITE_BLOB) { + zHaystack = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zNeedle = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + isText = int32(1) + } else { + pC1 = Xsqlite3_value_dup(tls, **(**uintptr)(__ccgo_up(argv))) + zHaystack = Xsqlite3_value_text(tls, pC1) + if zHaystack == uintptr(0) { + goto endInstrOOM + } + nHaystack = Xsqlite3_value_bytes(tls, pC1) + pC2 = Xsqlite3_value_dup(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + zNeedle = Xsqlite3_value_text(tls, pC2) + if zNeedle == uintptr(0) { + goto endInstrOOM + } + nNeedle = Xsqlite3_value_bytes(tls, pC2) + isText = int32(1) + } + } + if zNeedle == uintptr(0) || nHaystack != 0 && zHaystack == uintptr(0) { + goto endInstrOOM + } + firstChar = **(**uint8)(__ccgo_up(zNeedle)) + for nNeedle <= nHaystack && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zHaystack))) != libc.Int32FromUint8(firstChar) || libc.Xmemcmp(tls, zHaystack, zNeedle, libc.Uint64FromInt32(nNeedle)) != 0) { + N = N + 1 + for cond := true; cond; cond = isText != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zHaystack)))&int32(0xc0) == int32(0x80) { + nHaystack = nHaystack - 1 + zHaystack = zHaystack + 1 + } + } + if nNeedle > nHaystack { + N = 0 + } + } + Xsqlite3_result_int(tls, context, N) + goto endInstr +endInstr: + ; + Xsqlite3_value_free(tls, pC1) + Xsqlite3_value_free(tls, pC2) + return + goto endInstrOOM +endInstrOOM: + ; + Xsqlite3_result_error_nomem(tls, context) + goto endInstr +} + +// C documentation +// +// /* +// ** Check to see if the pExpr expression is a form that needs to be passed +// ** to the xBestIndex method of virtual tables. Forms of interest include: +// ** +// ** Expression Virtual Table Operator +// ** ----------------------- --------------------------------- +// ** 1. column MATCH expr SQLITE_INDEX_CONSTRAINT_MATCH +// ** 2. column GLOB expr SQLITE_INDEX_CONSTRAINT_GLOB +// ** 3. column LIKE expr SQLITE_INDEX_CONSTRAINT_LIKE +// ** 4. column REGEXP expr SQLITE_INDEX_CONSTRAINT_REGEXP +// ** 5. column != expr SQLITE_INDEX_CONSTRAINT_NE +// ** 6. expr != column SQLITE_INDEX_CONSTRAINT_NE +// ** 7. column IS NOT expr SQLITE_INDEX_CONSTRAINT_ISNOT +// ** 8. expr IS NOT column SQLITE_INDEX_CONSTRAINT_ISNOT +// ** 9. column IS NOT NULL SQLITE_INDEX_CONSTRAINT_ISNOTNULL +// ** +// ** In every case, "column" must be a column of a virtual table. If there +// ** is a match, set *ppLeft to the "column" expression, set *ppRight to the +// ** "expr" expression (even though in forms (6) and (8) the column is on the +// ** right and the expression is on the left). Also set *peOp2 to the +// ** appropriate virtual table operator. The return value is 1 or 2 if there +// ** is a match. The usual return is 1, but if the RHS is also a column +// ** of virtual table in forms (5) or (7) then return 2. +// ** +// ** If the expression matches none of the patterns above, return 0. +// */ +func _isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uintptr, ppLeft uintptr, ppRight uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, res, v1 int32 + var pCol, pLeft, pList, pMod, pRight, pVtab, t uintptr + var v2 bool + var _ /* pNotUsed at bp+8 */ uintptr + var _ /* xNotUsed at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = i, pCol, pLeft, pList, pMod, pRight, pVtab, res, t, v1, v2 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_FUNCTION) { + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if pList == uintptr(0) || (*TExprList)(unsafe.Pointer(pList)).FnExpr != int32(2) { + return 0 + } + /* Built-in operators MATCH, GLOB, LIKE, and REGEXP attach to a + ** virtual table on their second argument, which is the same as + ** the left-hand side operand in their in-fix form. + ** + ** vtab_column MATCH expression + ** MATCH(expression,vtab_column) + */ + pCol = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr + if v2 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCol)).Fop) == int32(TK_COLUMN) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64)))).FeTabType) == int32(TABTYP_VTAB); v2 { + v1 = _sqlite3ExprIsLikeOperator(tls, pExpr) + i = v1 + } + if v2 && v1 != 0 { + **(**uint8)(__ccgo_up(peOp2)) = libc.Uint8FromInt32(i) + **(**uintptr)(__ccgo_up(ppRight)) = (*(*TExprList_item)(unsafe.Pointer(pList + 8))).FpExpr + **(**uintptr)(__ccgo_up(ppLeft)) = pCol + return int32(1) + } + /* We can also match against the first column of overloaded + ** functions where xFindFunction returns a value of at least + ** SQLITE_INDEX_CONSTRAINT_FUNCTION. + ** + ** OVERLOADED(vtab_column,expression) + ** + ** Historically, xFindFunction expected to see lower-case function + ** names. But for this use case, xFindFunction is expected to deal + ** with function names in an arbitrary case. + */ + pCol = (*(*TExprList_item)(unsafe.Pointer(pList + 8))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCol)).Fop) == int32(TK_COLUMN) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64)))).FeTabType) == int32(TABTYP_VTAB) { + pVtab = (*TVTable)(unsafe.Pointer(_sqlite3GetVTable(tls, db, *(*uintptr)(unsafe.Pointer(pCol + 64))))).FpVtab + pMod = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule + if (*Tsqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction != uintptr(0) { + i = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction})))(tls, pVtab, int32(2), *(*uintptr)(unsafe.Pointer(pExpr + 8)), bp, bp+8) + if i >= int32(SQLITE_INDEX_CONSTRAINT_FUNCTION) { + **(**uint8)(__ccgo_up(peOp2)) = libc.Uint8FromInt32(i) + **(**uintptr)(__ccgo_up(ppRight)) = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr + **(**uintptr)(__ccgo_up(ppLeft)) = pCol + return int32(1) + } + } + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) >= int32(TK_EQ) { + /* Comparison operators are a common case. Save a few comparisons for + ** that common case by terminating early. */ + return 0 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NE) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_ISNOT) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL) { + res = 0 + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) == int32(TK_COLUMN) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64)))).FeTabType) == int32(TABTYP_VTAB) { + res = res + 1 + } + if pRight != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) == int32(TK_COLUMN) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 64)))).FeTabType) == int32(TABTYP_VTAB)) { + res = res + 1 + t = pLeft + pLeft = pRight + pRight = t + } + **(**uintptr)(__ccgo_up(ppLeft)) = pLeft + **(**uintptr)(__ccgo_up(ppRight)) = pRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NE) { + **(**uint8)(__ccgo_up(peOp2)) = uint8(SQLITE_INDEX_CONSTRAINT_NE) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_ISNOT) { + **(**uint8)(__ccgo_up(peOp2)) = uint8(SQLITE_INDEX_CONSTRAINT_ISNOT) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL) { + **(**uint8)(__ccgo_up(peOp2)) = uint8(SQLITE_INDEX_CONSTRAINT_ISNOTNULL) + } + return res + } + } + } + return 0 +} + +// C documentation +// +// /* +// ** pX is the RHS of an IN operator. If pX is a SELECT statement +// ** that can be simplified to a direct table access, then return +// ** a pointer to the SELECT statement. If pX is not a SELECT statement, +// ** or if the SELECT statement needs to be materialized into a transient +// ** table, then return NULL. +// */ +func _isCandidateForInOpt(tls *libc.TLS, pX uintptr) (r uintptr) { + var i int32 + var p, pEList, pRes, pSrc, pTab uintptr + _, _, _, _, _, _ = i, p, pEList, pRes, pSrc, pTab + if !((*TExpr)(unsafe.Pointer(pX)).Fflags&libc.Uint32FromInt32(EP_xIsSelect) != libc.Uint32FromInt32(0)) { + return uintptr(0) + } /* Not a subquery */ + if (*TExpr)(unsafe.Pointer(pX)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) != uint32(0) { + return uintptr(0) + } /* Correlated subq */ + p = *(*uintptr)(unsafe.Pointer(pX + 32)) + if (*TSelect)(unsafe.Pointer(p)).FpPrior != 0 { + return uintptr(0) + } /* Not a compound SELECT */ + if (*TSelect)(unsafe.Pointer(p)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Distinct)|libc.Int32FromInt32(SF_Aggregate)) != 0 { + return uintptr(0) /* No DISTINCT keyword and no aggregate functions */ + } + /* Has no GROUP BY clause */ + if (*TSelect)(unsafe.Pointer(p)).FpLimit != 0 { + return uintptr(0) + } /* Has no LIMIT clause */ + if (*TSelect)(unsafe.Pointer(p)).FpWhere != 0 { + return uintptr(0) + } /* Has no WHERE clause */ + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + if (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc != int32(1) { + return uintptr(0) + } /* Single term in FROM clause */ + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + 24 + 4))&0x4>>2) != 0 { + return uintptr(0) + } /* FROM is not a subquery or view */ + pTab = (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FpSTab + /* FROM clause is not a view */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + return uintptr(0) + } /* FROM clause not a virtual table */ + pEList = (*TSelect)(unsafe.Pointer(p)).FpEList + /* All SELECT results must be columns. */ + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + pRes = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRes)).Fop) != int32(TK_COLUMN) { + return uintptr(0) + } + /* Not a correlated subquery */ + goto _1 + _1: + ; + i = i + 1 + } + return p +} + +// C documentation +// +// /* +// ** Return true if the DISTINCT expression-list passed as the third argument +// ** is redundant. +// ** +// ** A DISTINCT list is redundant if any subset of the columns in the +// ** DISTINCT list are collectively unique and individually non-null. +// */ +func _isDistinctRedundant(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWC uintptr, pDistinct uintptr) (r int32) { + var i, iBase int32 + var p, pIdx, pTab uintptr + _, _, _, _, _ = i, iBase, p, pIdx, pTab + /* If there is more than one table or sub-select in the FROM clause of + ** this query, then it will not be possible to show that the DISTINCT + ** clause is redundant. */ + if (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc != int32(1) { + return 0 + } + iBase = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab + /* If any of the expressions is an IPK column on table iBase, then return + ** true. Note: The (p->iTable==iBase) part of this test may be false if the + ** current SELECT is a correlated sub-query. + */ + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pDistinct)).FnExpr) { + break + } + p = _sqlite3ExprSkipCollateAndLikely(tls, (*(*TExprList_item)(unsafe.Pointer(pDistinct + 8 + uintptr(i)*32))).FpExpr) + if p == uintptr(0) { + goto _1 + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) != int32(TK_COLUMN) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) != int32(TK_AGG_COLUMN) { + goto _1 + } + if (*TExpr)(unsafe.Pointer(p)).FiTable == iBase && int32((*TExpr)(unsafe.Pointer(p)).FiColumn) < 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + /* Loop through all indices on the table, checking each to see if it makes + ** the DISTINCT qualifier redundant. It does so if: + ** + ** 1. The index is itself UNIQUE, and + ** + ** 2. All of the columns in the index are either part of the pDistinct + ** list, or else the WHERE clause contains a term of the form "col=X", + ** where X is a constant value. The collation sequences of the + ** comparison and select-list expressions must match those of the index. + ** + ** 3. All of those index columns for which the WHERE clause does not + ** contain a "col=X" term are subject to a NOT NULL constraint. + */ + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromInt32(OE_None)) { + goto _2 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + goto _2 + } + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + if uintptr(0) == _sqlite3WhereFindTerm(tls, pWC, iBase, i, ^libc.Uint64FromInt32(0), uint32(WO_EQ), pIdx) { + if _findIndexCol(tls, pParse, pDistinct, iBase, pIdx, i) < 0 { + break + } + if _indexColumnNotNull(tls, pIdx, i) == 0 { + break + } + } + goto _3 + _3: + ; + i = i + 1 + } + if i == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + /* This index implies that the DISTINCT qualifier is redundant. */ + return int32(1) + } + goto _2 + _2: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + return 0 +} + +// C documentation +// +// /* +// ** Return true if the parser passed as the first argument is being +// ** used to code a trigger that is really a "SET NULL" action belonging +// ** to trigger pFKey. +// */ +func _isSetNullAction(tls *libc.TLS, pParse uintptr, pFKey uintptr) (r int32) { + var p, pTop, v1 uintptr + _, _, _ = p, pTop, v1 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + pTop = v1 + if (*TParse)(unsafe.Pointer(pTop)).FpTriggerPrg != 0 { + p = (*TTriggerPrg)(unsafe.Pointer((*TParse)(unsafe.Pointer(pTop)).FpTriggerPrg)).FpTrigger + if p == **(**uintptr)(__ccgo_up(pFKey + 48)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pFKey + 45))) == int32(OE_SetNull) || p == **(**uintptr)(__ccgo_up(pFKey + 48 + 1*8)) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pFKey + 45 + 1))) == int32(OE_SetNull) { + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** The select statement passed as the first argument is an aggregate query. +// ** The second argument is the associated aggregate-info object. This +// ** function tests if the SELECT is of the form: +// ** +// ** SELECT count(*) FROM +// ** +// ** where table is a database table, not a sub-select or view. If the query +// ** does match this pattern, then a pointer to the Table object representing +// ** is returned. Otherwise, NULL is returned. +// ** +// ** This routine checks to see if it is safe to use the count optimization. +// ** A correct answer is still obtained (though perhaps more slowly) if +// ** this routine returns NULL when it could have returned a table pointer. +// ** But returning the pointer when NULL should have been returned can +// ** result in incorrect answers and/or crashes. So, when in doubt, return NULL. +// */ +func _isSimpleCount(tls *libc.TLS, p uintptr, pAggInfo uintptr) (r uintptr) { + var pExpr, pTab uintptr + _, _ = pExpr, pTab + if (*TSelect)(unsafe.Pointer(p)).FpWhere != 0 || (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr != int32(1) || (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc != int32(1) || int32(*(*uint32)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8 + 24 + 4))&0x4>>2) != 0 || (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc != int32(1) || (*TSelect)(unsafe.Pointer(p)).FpHaving != 0 { + return uintptr(0) + } + pTab = (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + return uintptr(0) + } + pExpr = (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_AGG_FUNCTION) { + return uintptr(0) + } + if (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo != pAggInfo { + return uintptr(0) + } + if (*TFuncDef)(unsafe.Pointer((**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc))).FpFunc)).FfuncFlags&uint32(SQLITE_FUNC_COUNT) == uint32(0) { + return uintptr(0) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)|libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + return uintptr(0) + } + return pTab +} + +// C documentation +// +// /* +// ** Edit the payload size of the element at iRoot by the amount in +// ** pParse->delta. +// */ +func _jsonAfterEditSizeAdjust(tls *libc.TLS, pParse uintptr, iRoot Tu32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nBlob Tu32 + var _ /* sz at bp+0 */ Tu32 + _ = nBlob + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + nBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc + _jsonbPayloadSize(tls, pParse, iRoot, bp) + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = nBlob + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pParse)).Fdelta) + **(**int32)(__ccgo_up(pParse + 52)) += _jsonBlobChangePayloadSize(tls, pParse, iRoot, **(**Tu32)(__ccgo_up(bp))) +} + +// C documentation +// +// /* Expand pParse->aBlob and append one bytes. +// */ +func _jsonBlobExpandAndAppendOneByte(tls *libc.TLS, pParse uintptr, c Tu8) { + var v1 Tu32 + var v2 uintptr + _, _ = v1, v2 + _jsonBlobExpand(tls, pParse, (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob+uint32(1)) + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).Foom) == 0 { + v2 = pParse + 8 + v1 = *(*Tu32)(unsafe.Pointer(v2)) + *(*Tu32)(unsafe.Pointer(v2)) = *(*Tu32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(v1))) = c + } +} + +// C documentation +// +// /* Advance the cursor to the next element for json_tree() */ +func _jsonEachNext(tls *libc.TLS, cur uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, i1, iVal, n, n1 Tu32 + var levelChange, x Tu8 + var nNew Tu64 + var p, pNew, pParent, pParent1 uintptr + var rc int32 + var _ /* sz at bp+0 */ Tu32 + var _ /* sz at bp+4 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = i, i1, iVal, levelChange, n, n1, nNew, p, pNew, pParent, pParent1, rc, x + p = cur + rc = SQLITE_OK + if (*TJsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { + levelChange = uint8(0) + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + i = libc.Uint32FromInt32(_jsonSkipLabel(tls, p)) + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i)))) & int32(0x0f)) + n = _jsonbPayloadSize(tls, p+192, i, bp) + if libc.Int32FromUint8(x) == int32(JSONB_OBJECT) || libc.Int32FromUint8(x) == int32(JSONB_ARRAY) { + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent >= (*TJsonEachCursor)(unsafe.Pointer(p)).FnParentAlloc { + nNew = uint64((*TJsonEachCursor)(unsafe.Pointer(p)).FnParentAlloc*uint32(2) + uint32(3)) + pNew = _sqlite3DbRealloc(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb, (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent, uint64(24)*nNew) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParentAlloc = uint32(nNew) + (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent = pNew + } + levelChange = uint8(1) + pParent = (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent)*24 + (*TJsonParent)(unsafe.Pointer(pParent)).FiHead = (*TJsonEachCursor)(unsafe.Pointer(p)).Fi + (*TJsonParent)(unsafe.Pointer(pParent)).FiValue = i + (*TJsonParent)(unsafe.Pointer(pParent)).FiEnd = i + n + **(**Tu32)(__ccgo_up(bp)) + (*TJsonParent)(unsafe.Pointer(pParent)).FiKey = int64(-int32(1)) + (*TJsonParent)(unsafe.Pointer(pParent)).FnPath = uint32((*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed) + if (*TJsonEachCursor)(unsafe.Pointer(p)).FeType != 0 && (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent != 0 { + _jsonAppendPathName(tls, p) + if (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FeErr != 0 { + rc = int32(SQLITE_NOMEM) + } + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent + 1 + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i + n + } else { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i + n + **(**Tu32)(__ccgo_up(bp)) + } + for (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent > uint32(0) && (*TJsonEachCursor)(unsafe.Pointer(p)).Fi >= (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiEnd { + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent - 1 + (*TJsonEachCursor)(unsafe.Pointer(p)).Fpath.FnUsed = uint64((**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent)*24))).FnPath) + levelChange = uint8(1) + } + if levelChange != 0 { + if (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent > uint32(0) { + pParent1 = (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24 + iVal = (*TJsonParent)(unsafe.Pointer(pParent1)).FiValue + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(iVal)))) & int32(0x0f)) + } else { + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + } + } + } else { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(0) + i1 = libc.Uint32FromInt32(_jsonSkipLabel(tls, p)) + n1 = _jsonbPayloadSize(tls, p+192, i1, bp+4) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i1 + n1 + **(**Tu32)(__ccgo_up(bp + 4)) + } + if libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeType) == int32(JSONB_ARRAY) && (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent != 0 { + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiKey = (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiKey + 1 + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FiRowid = (*TJsonEachCursor)(unsafe.Pointer(p)).FiRowid + 1 + return rc +} + +// C documentation +// +// /* Append formatted text (not to exceed N bytes) to the JsonString. +// */ +func _jsonPrintf(tls *libc.TLS, N int32, p uintptr, zFormat uintptr, va uintptr) { + var ap Tva_list + _ = ap + if (*TJsonString)(unsafe.Pointer(p)).FnUsed+libc.Uint64FromInt32(N) >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc && _jsonStringGrow(tls, p, libc.Uint32FromInt32(N)) != 0 { + return + } + ap = va + Xsqlite3_vsnprintf(tls, N, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), zFormat, ap) + _ = ap + **(**Tu64)(__ccgo_up(p + 24)) += libc.Uint64FromInt32(libc.Int32FromUint64(libc.Xstrlen(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed)))) +} + +// C documentation +// +// /* +// ** Make the return value of a JSON function either the raw JSONB blob +// ** or make it JSON text, depending on whether the JSON_BLOB flag is +// ** set on the function. +// */ +func _jsonReturnParse(tls *libc.TLS, ctx uintptr, p uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var flgs int32 + var _ /* s at bp+0 */ TJsonString + _ = flgs + if (*TJsonParse)(unsafe.Pointer(p)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, ctx) + return + } + flgs = int32(int64(Xsqlite3_user_data(tls, ctx))) + if flgs&int32(JSON_BLOB) != 0 { + if (*TJsonParse)(unsafe.Pointer(p)).FnBlobAlloc > uint32(0) && !((*TJsonParse)(unsafe.Pointer(p)).FbReadOnly != 0) { + Xsqlite3_result_blob(tls, ctx, (*TJsonParse)(unsafe.Pointer(p)).FaBlob, libc.Int32FromUint32((*TJsonParse)(unsafe.Pointer(p)).FnBlob), __ccgo_fp(_sqlite3RowSetClear)) + (*TJsonParse)(unsafe.Pointer(p)).FnBlobAlloc = uint32(0) + } else { + Xsqlite3_result_blob(tls, ctx, (*TJsonParse)(unsafe.Pointer(p)).FaBlob, libc.Int32FromUint32((*TJsonParse)(unsafe.Pointer(p)).FnBlob), uintptr(-libc.Int32FromInt32(1))) + } + } else { + _jsonStringInit(tls, bp, ctx) + (*TJsonParse)(unsafe.Pointer(p)).Fdelta = 0 + _jsonTranslateBlobToText(tls, p, uint32(0), bp) + _jsonReturnString(tls, bp, p, ctx) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } +} + +/**************************************************************************** +** SQL functions used for testing and debugging +****************************************************************************/ + +/**************************************************************************** +** Scalar SQL function implementations +****************************************************************************/ + +// C documentation +// +// /* +// ** json_set(JSON, PATH, VALUE, ...) +// ** +// ** Set the value at PATH to VALUE. Create the PATH if it does not already +// ** exist. Overwrite existing values that do exist. +// ** If JSON or PATH is malformed, throw an error. +// ** +// ** json_insert(JSON, PATH, VALUE, ...) +// ** +// ** Create PATH and initialize it to VALUE. If PATH already exists, this +// ** routine is a no-op. If JSON or PATH is malformed, throw an error. +// */ +func _jsonSetFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var eInsType, flags int32 + _, _ = eInsType, flags + flags = int32(int64(Xsqlite3_user_data(tls, ctx))) + eInsType = flags & int32(0xC) >> int32(2) + if argc < int32(1) { + return + } + if argc&int32(1) == 0 { + _jsonWrongNumArgs(tls, ctx, _azInsType[eInsType]) + return + } + _jsonInsertIntoBlob(tls, ctx, argc, argv, libc.Int32FromUint8(_aEditType[eInsType])) +} + +// C documentation +// +// /* +// ** If the cursor is currently pointing at the label of a object entry, +// ** then return the index of the value. For all other cases, return the +// ** current pointer position, which is the value. +// */ +func _jsonSkipLabel(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var n Tu32 + var _ /* sz at bp+0 */ Tu32 + _ = n + if libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeType) == int32(JSONB_OBJECT) { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + n = _jsonbPayloadSize(tls, p+192, (*TJsonEachCursor)(unsafe.Pointer(p)).Fi, bp) + return libc.Int32FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).Fi + n + **(**Tu32)(__ccgo_up(bp))) + } else { + return libc.Int32FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).Fi) + } + return r +} + +// C documentation +// +// /* +// ** Implementation of the length() function +// */ +func _lengthFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var c, v1 uint8 + var z, z0 uintptr + _, _, _, _ = c, z, z0, v1 + _ = argc + switch Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_BLOB): + fallthrough + case int32(SQLITE_INTEGER): + fallthrough + case int32(SQLITE_FLOAT): + Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv)))) + case int32(SQLITE_TEXT): + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if z == uintptr(0) { + return + } + z0 = z + for { + v1 = **(**uint8)(__ccgo_up(z)) + c = v1 + if !(libc.Int32FromUint8(v1) != 0) { + break + } + z = z + 1 + if libc.Int32FromUint8(c) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { + z = z + 1 + z0 = z0 + 1 + } + } + } + Xsqlite3_result_int(tls, context, int32(int64(z)-int64(z0))) + default: + Xsqlite3_result_null(tls, context) + break + } +} + +// C documentation +// +// /* +// ** Record the fact that we want to lock a table at run-time. +// ** +// ** The table to be locked has root page iTab and is found in database iDb. +// ** A read or a write lock can be taken depending on isWritelock. +// ** +// ** This routine just records the fact that the lock is desired. The +// ** code to make the lock occur is generated by a later call to +// ** codeTableLocks() which occurs during sqlite3FinishCoding(). +// */ +func _lockTable(tls *libc.TLS, pParse uintptr, iDb int32, iTab TPgno, isWriteLock Tu8, zName uintptr) { + var i, nBytes, v3 int32 + var p, pToplevel, v1 uintptr + _, _, _, _, _, _ = i, nBytes, p, pToplevel, v1, v3 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + pToplevel = v1 + i = 0 + for { + if !(i < (*TParse)(unsafe.Pointer(pToplevel)).FnTableLock) { + break + } + p = (*TParse)(unsafe.Pointer(pToplevel)).FaTableLock + uintptr(i)*24 + if (*TTableLock)(unsafe.Pointer(p)).FiDb == iDb && (*TTableLock)(unsafe.Pointer(p)).FiTab == iTab { + (*TTableLock)(unsafe.Pointer(p)).FisWriteLock = libc.BoolUint8((*TTableLock)(unsafe.Pointer(p)).FisWriteLock != 0 || isWriteLock != 0) + return + } + goto _2 + _2: + ; + i = i + 1 + } + nBytes = libc.Int32FromUint64(uint64(24) * libc.Uint64FromInt32((*TParse)(unsafe.Pointer(pToplevel)).FnTableLock+libc.Int32FromInt32(1))) + (*TParse)(unsafe.Pointer(pToplevel)).FaTableLock = _sqlite3DbReallocOrFree(tls, (*TParse)(unsafe.Pointer(pToplevel)).Fdb, (*TParse)(unsafe.Pointer(pToplevel)).FaTableLock, libc.Uint64FromInt32(nBytes)) + if (*TParse)(unsafe.Pointer(pToplevel)).FaTableLock != 0 { + v1 = pToplevel + 132 + v3 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + p = (*TParse)(unsafe.Pointer(pToplevel)).FaTableLock + uintptr(v3)*24 + (*TTableLock)(unsafe.Pointer(p)).FiDb = iDb + (*TTableLock)(unsafe.Pointer(p)).FiTab = iTab + (*TTableLock)(unsafe.Pointer(p)).FisWriteLock = isWriteLock + (*TTableLock)(unsafe.Pointer(p)).FzLockName = zName + } else { + (*TParse)(unsafe.Pointer(pToplevel)).FnTableLock = 0 + _sqlite3OomFault(tls, (*TParse)(unsafe.Pointer(pToplevel)).Fdb) + } +} + +// C documentation +// +// /* +// ** Move the cursor down to a new child page. The newPgno argument is the +// ** page number of the child page to move to. +// ** +// ** This function returns SQLITE_CORRUPT if the page-header flags field of +// ** the new child page does not match the flags field of the parent (i.e. +// ** if an intkey page appears to be the parent of a non-intkey page, or +// ** vice-versa). +// */ +func _moveToChild(tls *libc.TLS, pCur uintptr, newPgno Tu32) (r int32) { + var rc int32 + var v1 uintptr + var v2 Ti8 + _, _, _ = rc, v1, v2 + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) >= libc.Int32FromInt32(BTCURSOR_MAX_DEPTH)-libc.Int32FromInt32(1) { + return _sqlite3CorruptError(tls, int32(78598)) + } + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + **(**Tu16)(__ccgo_up(pCur + 88 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*2)) = (*TBtCursor)(unsafe.Pointer(pCur)).Fix + **(**uintptr)(__ccgo_up(pCur + 144 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*8)) = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = uint16(0) + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = (*TBtCursor)(unsafe.Pointer(pCur)).FiPage + 1 + rc = _getAndInitPage(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBt, newPgno, pCur+136, libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags)) + if rc == SQLITE_OK && (libc.Int32FromUint16((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell) < int32(1) || libc.Int32FromUint8((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FintKey) != libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurIntKey)) { + _releasePage(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage) + rc = _sqlite3CorruptError(tls, int32(78612)) + } + if rc != 0 { + v1 = pCur + 84 + *(*Ti8)(unsafe.Pointer(v1)) = *(*Ti8)(unsafe.Pointer(v1)) - 1 + v2 = *(*Ti8)(unsafe.Pointer(v1)) + (*TBtCursor)(unsafe.Pointer(pCur)).FpPage = **(**uintptr)(__ccgo_up(pCur + 144 + uintptr(v2)*8)) + } + return rc +} + +// C documentation +// +// /* +// ** Move the cursor to point to the root page of its b-tree structure. +// ** +// ** If the table has a virtual root page, then the cursor is moved to point +// ** to the virtual root page instead of the actual root page. A table has a +// ** virtual root page when the actual root page contains no cells and a +// ** single child page. This can only happen with the table rooted at page 1. +// ** +// ** If the b-tree structure is empty, the cursor state is set to +// ** CURSOR_INVALID and this routine returns SQLITE_EMPTY. Otherwise, +// ** the cursor is set to point to the first cell located on the root +// ** (or virtual root) page and the cursor state is set to CURSOR_VALID. +// ** +// ** If this function returns successfully, it may be assumed that the +// ** page-header flags indicate that the [virtual] root-page is the expected +// ** kind of b-tree page (i.e. if when opening the cursor the caller did not +// ** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D, +// ** indicating a table b-tree, or if the caller did specify a KeyInfo +// ** structure the flags byte is set to 0x02 or 0x0A, indicating an index +// ** b-tree). +// */ +func _moveToRoot(tls *libc.TLS, pCur uintptr) (r int32) { + var pRoot, v2 uintptr + var rc int32 + var subpage TPgno + var v1 Ti8 + _, _, _, _, _ = pRoot, rc, subpage, v1, v2 + rc = SQLITE_OK + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) >= 0 { + if (*TBtCursor)(unsafe.Pointer(pCur)).FiPage != 0 { + _releasePageNotNull(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage) + for { + v2 = pCur + 84 + *(*Ti8)(unsafe.Pointer(v2)) = *(*Ti8)(unsafe.Pointer(v2)) - 1 + v1 = *(*Ti8)(unsafe.Pointer(v2)) + if !(v1 != 0) { + break + } + _releasePageNotNull(tls, **(**uintptr)(__ccgo_up(pCur + 144 + uintptr((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)*8))) + } + v2 = **(**uintptr)(__ccgo_up(pCur + 144)) + (*TBtCursor)(unsafe.Pointer(pCur)).FpPage = v2 + pRoot = v2 + goto skip_init + } + } else { + if (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot == uint32(0) { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID) + return int32(SQLITE_EMPTY) + } else { + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) >= int32(CURSOR_REQUIRESEEK) { + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == int32(CURSOR_FAULT) { + return (*TBtCursor)(unsafe.Pointer(pCur)).FskipNext + } + _sqlite3BtreeClearCursor(tls, pCur) + } + rc = _getAndInitPage(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBt, (*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur+136, libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags)) + if rc != SQLITE_OK { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID) + return rc + } + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = 0 + (*TBtCursor)(unsafe.Pointer(pCur)).FcurIntKey = (*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FintKey + } + } + pRoot = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor + ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is + ** NULL, the caller expects a table b-tree. If this is not the case, + ** return an SQLITE_CORRUPT error. + ** + ** Earlier versions of SQLite assumed that this test could not fail + ** if the root page was already loaded when this function was called (i.e. + ** if pCur->iPage>=0). But this is not so if the database is corrupted + ** in such a way that page pRoot is linked into a second b-tree table + ** (or the freelist). */ + if libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pRoot)).FisInit) == 0 || libc.BoolInt32((*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo == uintptr(0)) != libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pRoot)).FintKey) { + return _sqlite3CorruptError(tls, int32(78747)) + } + goto skip_init +skip_init: + ; + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = uint16(0) + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + v2 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) & ^(libc.Int32FromInt32(BTCF_AtLast) | libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + if libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pRoot)).FnCell) > 0 { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_VALID) + } else { + if !((*TMemPage)(unsafe.Pointer(pRoot)).Fleaf != 0) { + if (*TMemPage)(unsafe.Pointer(pRoot)).Fpgno != uint32(1) { + return _sqlite3CorruptError(tls, int32(78759)) + } + subpage = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pRoot)).FaData+uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pRoot)).FhdrOffset)+int32(8))) + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_VALID) + rc = _moveToChild(tls, pCur, subpage) + } else { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID) + rc = int32(SQLITE_EMPTY) + } + } + return rc +} + +// C documentation +// +// /* +// ** The select statement passed as the second parameter is a compound SELECT +// ** with an ORDER BY clause. This function allocates and returns a KeyInfo +// ** structure suitable for implementing the ORDER BY. +// ** +// ** Space to hold the KeyInfo structure is obtained from malloc. The calling +// ** function is responsible for ensuring that this structure is eventually +// ** freed. +// */ +func _multiSelectByMergeKeyInfo(tls *libc.TLS, pParse uintptr, p uintptr, nExtra int32) (r uintptr) { + var db, pColl, pItem, pOrderBy, pRet, pTerm uintptr + var i, nOrderBy, v1 int32 + _, _, _, _, _, _, _, _, _ = db, i, nOrderBy, pColl, pItem, pOrderBy, pRet, pTerm, v1 + pOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + if pOrderBy != uintptr(0) { + v1 = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr + } else { + v1 = 0 + } + nOrderBy = v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pRet = _sqlite3KeyInfoAlloc(tls, db, nOrderBy+nExtra, int32(1)) + if pRet != 0 { + i = 0 + for { + if !(i < nOrderBy) { + break + } + pItem = pOrderBy + 8 + uintptr(i)*32 + pTerm = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + if (*TExpr)(unsafe.Pointer(pTerm)).Fflags&uint32(EP_Collate) != 0 { + pColl = _sqlite3ExprCollSeq(tls, pParse, pTerm) + } else { + pColl = _multiSelectCollSeq(tls, pParse, p, libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol)-int32(1)) + if pColl == uintptr(0) { + pColl = (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl + } + (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).FpExpr = _sqlite3ExprAddCollateString(tls, pParse, pTerm, (*TCollSeq)(unsafe.Pointer(pColl)).FzName) + } + *(*uintptr)(unsafe.Pointer(pRet + 32 + uintptr(i)*8)) = pColl + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pRet)).FaSortFlags + uintptr(i))) = (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).Ffg.FsortFlags + goto _2 + _2: + ; + i = i + 1 + } + } + return pRet +} + +// C documentation +// +// /* +// ** Add node pNode to the node hash table. +// */ +func _nodeHashInsert(tls *libc.TLS, pRtree uintptr, pNode uintptr) { + var iHash int32 + _ = iHash + iHash = libc.Int32FromUint32(_nodeHash(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode)) + (*TRtreeNode)(unsafe.Pointer(pNode)).FpNext = **(**uintptr)(__ccgo_up(pRtree + 200 + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up(pRtree + 200 + uintptr(iHash)*8)) = pNode +} + +// C documentation +// +// /* +// ** An index on expressions is being used in the inner loop of an +// ** aggregate query with a GROUP BY clause. This routine attempts +// ** to adjust the AggInfo object to take advantage of index and to +// ** perhaps use the index as a covering index. +// ** +// */ +func _optimizeAggregateUseOfIndexedExpr(tls *libc.TLS, pParse uintptr, pSelect uintptr, pAggInfo uintptr, pNC uintptr) { + var j, k, mx int32 + _, _, _ = j, k, mx + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn > uint32(0) { + mx = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSelect)).FpGroupBy)).FnExpr - int32(1) + j = 0 + for { + if !(j < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) { + break + } + k = (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(j)*32))).FiSorterColumn + if k > mx { + mx = k + } + goto _1 + _1: + ; + j = j + 1 + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn = libc.Uint32FromInt32(mx + int32(1)) + } + _analyzeAggFuncArgs(tls, pAggInfo, pNC) + _ = pSelect + _ = pParse +} + +func _out2Prerelease(tls *libc.TLS, p uintptr, pOp uintptr) (r uintptr) { + var pOut uintptr + _ = pOut + pOut = (*TVdbe)(unsafe.Pointer(p)).FaMem + uintptr((*TVdbeOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { /*OPTIMIZATION-IF-FALSE*/ + return _out2PrereleaseWithClear(tls, pOut) + } else { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) + return pOut + } + return r +} + +// C documentation +// +// /* +// ** The pCArray object contains pointers to b-tree cells and their sizes. +// ** +// ** This function adds the space associated with each cell in the array +// ** that is currently stored within the body of pPg to the pPg free-list. +// ** The cell-pointers and other fields of the page are not updated. +// ** +// ** This function returns the total number of cells added to the free-list. +// */ +func _pageFreeArray(tls *libc.TLS, pPg uintptr, iFirst int32, nCell int32, pCArray uintptr) (r int32) { + var aAfter, aOfst [10]int32 + var aData, pCell, pEnd, pStart uintptr + var i, iAfter, iEnd, iOfst, j, nFree, nRet, sz int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aAfter, aData, aOfst, i, iAfter, iEnd, iOfst, j, nFree, nRet, pCell, pEnd, pStart, sz + aData = (*TMemPage)(unsafe.Pointer(pPg)).FaData + pEnd = aData + uintptr((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize) + pStart = aData + uintptr(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FhdrOffset)+int32(8)+libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPg)).FchildPtrSize)) + nRet = 0 + iEnd = iFirst + nCell + nFree = 0 + i = iFirst + for { + if !(i < iEnd) { + break + } + pCell = **(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8)) + if uint64(pCell) >= uint64(pStart) && uint64(pCell) < uint64(pEnd) { + /* No need to use cachedCellSize() here. The sizes of all cells that + ** are to be freed have already been computing while deciding which + ** cells need freeing */ + sz = libc.Int32FromUint16(**(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2))) + iOfst = libc.Int32FromUint16(libc.Uint16FromInt64(int64(pCell) - int64(aData))) + iAfter = iOfst + sz + j = 0 + for { + if !(j < nFree) { + break + } + if aOfst[j] == iAfter { + aOfst[j] = iOfst + break + } else { + if aAfter[j] == iOfst { + aAfter[j] = iAfter + break + } + } + goto _2 + _2: + ; + j = j + 1 + } + if j >= nFree { + if nFree >= libc.Int32FromUint64(libc.Uint64FromInt64(40)/libc.Uint64FromInt64(4)) { + j = 0 + for { + if !(j < nFree) { + break + } + _freeSpace(tls, pPg, aOfst[j], aAfter[j]-aOfst[j]) + goto _3 + _3: + ; + j = j + 1 + } + nFree = 0 + } + aOfst[nFree] = iOfst + aAfter[nFree] = iAfter + if aData+uintptr(iAfter) > pEnd { + return 0 + } + nFree = nFree + 1 + } + nRet = nRet + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + j = 0 + for { + if !(j < nFree) { + break + } + _freeSpace(tls, pPg, aOfst[j], aAfter[j]-aOfst[j]) + goto _4 + _4: + ; + j = j + 1 + } + return nRet +} + +// C documentation +// +// /* +// ** Call sqlite3WalOpen() to open the WAL handle. If the pager is in +// ** exclusive-locking mode when this function is called, take an EXCLUSIVE +// ** lock on the database file and use heap-memory to store the wal-index +// ** in. Otherwise, use the normal shared-memory. +// */ +func _pagerOpenWal(tls *libc.TLS, pPager uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + /* If the pager is already in exclusive-mode, the WAL module will use + ** heap-memory for the wal-index instead of the VFS shared-memory + ** implementation. Take the exclusive lock now, before opening the WAL + ** file, to make sure this is safe. + */ + if (*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 { + rc = _pagerExclusiveLock(tls, pPager) + } + /* Open the connection to the log file. If this operation fails, + ** (e.g. due to malloc() failure), return an error code. + */ + if rc == SQLITE_OK { + rc = _sqlite3WalOpen(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, (*TPager)(unsafe.Pointer(pPager)).Ffd, (*TPager)(unsafe.Pointer(pPager)).FzWal, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode), (*TPager)(unsafe.Pointer(pPager)).FjournalSizeLimit, pPager+296) + } + _pagerFixMaplimit(tls, pPager) + return rc +} + +// C documentation +// +// /* +// ** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback +// ** the entire super-journal file. The case pSavepoint==NULL occurs when +// ** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction +// ** savepoint. +// ** +// ** When pSavepoint is not NULL (meaning a non-transaction savepoint is +// ** being rolled back), then the rollback consists of up to three stages, +// ** performed in the order specified: +// ** +// ** * Pages are played back from the main journal starting at byte +// ** offset PagerSavepoint.iOffset and continuing to +// ** PagerSavepoint.iHdrOffset, or to the end of the main journal +// ** file if PagerSavepoint.iHdrOffset is zero. +// ** +// ** * If PagerSavepoint.iHdrOffset is not zero, then pages are played +// ** back starting from the journal header immediately following +// ** PagerSavepoint.iHdrOffset to the end of the main journal file. +// ** +// ** * Pages are then played back from the sub-journal file, starting +// ** with the PagerSavepoint.iSubRec and continuing to the end of +// ** the journal file. +// ** +// ** Throughout the rollback process, each time a page is rolled back, the +// ** corresponding bit is set in a bitvec structure (variable pDone in the +// ** implementation below). This is used to ensure that a page is only +// ** rolled back the first time it is encountered in either journal. +// ** +// ** If pSavepoint is NULL, then pages are only played back from the main +// ** journal file. There is no need for a bitvec in this case. +// ** +// ** In either case, before playback commences the Pager.dbSize variable +// ** is reset to the value that it held at the start of the savepoint +// ** (or transaction). No page with a page-number greater than this value +// ** is played back. If one is encountered it is simply skipped. +// */ +func _pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iHdrOff, szJ Ti64 + var ii, ii1 Tu32 + var pDone uintptr + var rc int32 + var v1 uint32 + var v2 int64 + var _ /* dummy at bp+4 */ Tu32 + var _ /* nJRec at bp+0 */ Tu32 + var _ /* offset at bp+8 */ Ti64 + _, _, _, _, _, _, _, _ = iHdrOff, ii, ii1, pDone, rc, szJ, v1, v2 /* End of first segment of main-journal records */ + rc = SQLITE_OK /* Return code */ + pDone = uintptr(0) /* Bitvec to ensure pages played back only once */ + /* Allocate a bitvec to use to store the set of pages rolled back */ + if pSavepoint != 0 { + pDone = _sqlite3BitvecCreate(tls, (*TPagerSavepoint)(unsafe.Pointer(pSavepoint)).FnOrig) + if !(pDone != 0) { + return int32(SQLITE_NOMEM) + } + } + /* Set the database size back to the value it was before the savepoint + ** being reverted was opened. + */ + if pSavepoint != 0 { + v1 = (*TPagerSavepoint)(unsafe.Pointer(pSavepoint)).FnOrig + } else { + v1 = (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize + } + (*TPager)(unsafe.Pointer(pPager)).FdbSize = v1 + (*TPager)(unsafe.Pointer(pPager)).FchangeCountDone = (*TPager)(unsafe.Pointer(pPager)).FtempFile + if !(pSavepoint != 0) && (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + return _pagerRollbackWal(tls, pPager) + } + /* Use pPager->journalOff as the effective size of the main rollback + ** journal. The actual file might be larger than this in + ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST. But anything + ** past pPager->journalOff is off-limits to us. + */ + szJ = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + /* Begin by rolling back records from the main journal starting at + ** PagerSavepoint.iOffset and continuing to the next journal header. + ** There might be records in the main journal that have a page number + ** greater than the current database size (pPager->dbSize) but those + ** will be skipped automatically. Pages are added to pDone as they + ** are played back. + */ + if pSavepoint != 0 && !((*TPager)(unsafe.Pointer(pPager)).FpWal != libc.UintptrFromInt32(0)) { + if (*TPagerSavepoint)(unsafe.Pointer(pSavepoint)).FiHdrOffset != 0 { + v2 = (*TPagerSavepoint)(unsafe.Pointer(pSavepoint)).FiHdrOffset + } else { + v2 = szJ + } + iHdrOff = v2 + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = (*TPagerSavepoint)(unsafe.Pointer(pSavepoint)).FiOffset + for rc == SQLITE_OK && (*TPager)(unsafe.Pointer(pPager)).FjournalOff < iHdrOff { + rc = _pager_playback_one_page(tls, pPager, pPager+96, pDone, int32(1), int32(1)) + } + } else { + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + } + /* Continue rolling back records out of the main journal starting at + ** the first journal header seen and continuing until the effective end + ** of the main journal file. Continue to skip out-of-range pages and + ** continue adding pages rolled back to pDone. + */ + for rc == SQLITE_OK && (*TPager)(unsafe.Pointer(pPager)).FjournalOff < szJ { /* Loop counter */ + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + rc = _readJournalHdr(tls, pPager, 0, szJ, bp, bp+4) + /* + ** The "pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff" + ** test is related to ticket #2565. See the discussion in the + ** pager_playback() function for additional information. + */ + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) && (*TPager)(unsafe.Pointer(pPager)).FjournalHdr+libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) == (*TPager)(unsafe.Pointer(pPager)).FjournalOff { + **(**Tu32)(__ccgo_up(bp)) = libc.Uint32FromInt64((szJ - (*TPager)(unsafe.Pointer(pPager)).FjournalOff) / ((*TPager)(unsafe.Pointer(pPager)).FpageSize + libc.Int64FromInt32(8))) + } + ii = uint32(0) + for { + if !(rc == SQLITE_OK && ii < **(**Tu32)(__ccgo_up(bp)) && (*TPager)(unsafe.Pointer(pPager)).FjournalOff < szJ) { + break + } + rc = _pager_playback_one_page(tls, pPager, pPager+96, pDone, int32(1), int32(1)) + goto _3 + _3: + ; + ii = ii + 1 + } + } + /* Finally, rollback pages from the sub-journal. Page that were + ** previously rolled back out of the main journal (and are hence in pDone) + ** will be skipped. Out-of-range pages are also skipped. + */ + if pSavepoint != 0 { /* Loop counter */ + **(**Ti64)(__ccgo_up(bp + 8)) = libc.Int64FromUint32((*TPagerSavepoint)(unsafe.Pointer(pSavepoint)).FiSubRec) * (int64(4) + (*TPager)(unsafe.Pointer(pPager)).FpageSize) + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + rc = _sqlite3WalSavepointUndo(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pSavepoint+36) + } + ii1 = (*TPagerSavepoint)(unsafe.Pointer(pSavepoint)).FiSubRec + for { + if !(rc == SQLITE_OK && ii1 < (*TPager)(unsafe.Pointer(pPager)).FnSubRec) { + break + } + rc = _pager_playback_one_page(tls, pPager, bp+8, pDone, 0, int32(1)) + goto _4 + _4: + ; + ii1 = ii1 + 1 + } + } + _sqlite3BitvecDestroy(tls, pDone) + if rc == SQLITE_OK { + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = szJ + } + return rc +} + +// C documentation +// +// /* +// ** This function is called by the pcache layer when it has reached some +// ** soft memory limit. The first argument is a pointer to a Pager object +// ** (cast as a void*). The pager is always 'purgeable' (not an in-memory +// ** database). The second argument is a reference to a page that is +// ** currently dirty but has no outstanding references. The page +// ** is always associated with the Pager object passed as the first +// ** argument. +// ** +// ** The job of this function is to make pPg clean by writing its contents +// ** out to the database file, if possible. This may involve syncing the +// ** journal file. +// ** +// ** If successful, sqlite3PcacheMakeClean() is called on the page and +// ** SQLITE_OK returned. If an IO error occurs while trying to make the +// ** page clean, the IO error code is returned. If the page cannot be +// ** made clean for some other reason, but no error occurs, then SQLITE_OK +// ** is returned by sqlite3PcacheMakeClean() is not called. +// */ +func _pagerStress(tls *libc.TLS, p uintptr, pPg uintptr) (r int32) { + var pPager uintptr + var rc int32 + _, _ = pPager, rc + pPager = p + rc = SQLITE_OK + /* The doNotSpill NOSYNC bit is set during times when doing a sync of + ** journal (and adding a new header) is not allowed. This occurs + ** during calls to sqlite3PagerWrite() while trying to journal multiple + ** pages belonging to the same sector. + ** + ** The doNotSpill ROLLBACK and OFF bits inhibits all cache spilling + ** regardless of whether or not a sync is required. This is set during + ** a rollback or by user request, respectively. + ** + ** Spilling is also prohibited when in an error state since that could + ** lead to database corruption. In the current implementation it + ** is impossible for sqlite3PcacheFetch() to be called with createFlag==3 + ** while in the error state, hence it is impossible for this routine to + ** be called in the error state. Nevertheless, we include a NEVER() + ** test for the error state as a safeguard against future changes. + */ + if (*TPager)(unsafe.Pointer(pPager)).FerrCode != 0 { + return SQLITE_OK + } + if (*TPager)(unsafe.Pointer(pPager)).FdoNotSpill != 0 && (libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FdoNotSpill)&(libc.Int32FromInt32(SPILLFLAG_ROLLBACK)|libc.Int32FromInt32(SPILLFLAG_OFF)) != 0 || libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pPg)).Fflags)&int32(PGHDR_NEED_SYNC) != 0) { + return SQLITE_OK + } + **(**Tu32)(__ccgo_up(pPager + 248 + 3*4)) = **(**Tu32)(__ccgo_up(pPager + 248 + 3*4)) + 1 + (*TPgHdr)(unsafe.Pointer(pPg)).FpDirty = uintptr(0) + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + /* Write a single frame for this page to the log. */ + rc = _subjournalPageIfRequired(tls, pPg) + if rc == SQLITE_OK { + rc = _pagerWalFrames(tls, pPager, pPg, uint32(0), 0) + } + } else { + /* Sync the journal file if required. */ + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pPg)).Fflags)&int32(PGHDR_NEED_SYNC) != 0 || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_WRITER_CACHEMOD) { + rc = _syncJournal(tls, pPager, int32(1)) + } + /* Write the contents of the page out to the database file. */ + if rc == SQLITE_OK { + rc = _pager_write_pagelist(tls, pPager, pPg) + } + } + /* Mark the page as clean. */ + if rc == SQLITE_OK { + _sqlite3PcacheMakeClean(tls, pPg) + } + return _pager_error(tls, pPager, rc) +} + +// C documentation +// +// /* +// ** This function is a wrapper around sqlite3WalFrames(). As well as logging +// ** the contents of the list of pages headed by pList (connected by pDirty), +// ** this function notifies any active backup processes that the pages have +// ** changed. +// ** +// ** The list of pages passed into this routine is always sorted by page number. +// ** Hence, if page 1 appears anywhere on the list, it will be the first page. +// */ +func _pagerWalFrames(tls *libc.TLS, pPager uintptr, _pList uintptr, nTruncate TPgno, isCommit int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _pList + var nList, rc int32 + var p, ppNext, v2 uintptr + _, _, _, _, _ = nList, p, ppNext, rc, v2 /* For looping over pages */ + if isCommit != 0 { + /* If a WAL transaction is being committed, there is no point in writing + ** any pages with page numbers greater than nTruncate into the WAL file. + ** They will never be read by any client. So remove them from the pDirty + ** list here. */ + ppNext = bp + nList = 0 + p = **(**uintptr)(__ccgo_up(bp)) + for { + v2 = p + **(**uintptr)(__ccgo_up(ppNext)) = v2 + if !(v2 != uintptr(0)) { + break + } + if (*TPgHdr)(unsafe.Pointer(p)).Fpgno <= nTruncate { + ppNext = p + 32 + nList = nList + 1 + } + goto _1 + _1: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + } + } else { + nList = int32(1) + } + **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) += libc.Uint32FromInt32(nList) + if (*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fpgno == uint32(1) { + _pager_write_changecounter(tls, **(**uintptr)(__ccgo_up(bp))) + } + rc = _sqlite3WalFrames(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), **(**uintptr)(__ccgo_up(bp)), nTruncate, isCommit, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FwalSyncFlags)) + if rc == SQLITE_OK && (*TPager)(unsafe.Pointer(pPager)).FpBackup != 0 { + p = **(**uintptr)(__ccgo_up(bp)) + for { + if !(p != 0) { + break + } + _sqlite3BackupUpdate(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup, (*TPgHdr)(unsafe.Pointer(p)).Fpgno, (*TPgHdr)(unsafe.Pointer(p)).FpData) + goto _3 + _3: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + } + } + return rc +} + +// C documentation +// +// /* +// ** This is a variant of sqlite3PagerWrite() that runs when the sector size +// ** is larger than the page size. SQLite makes the (reasonable) assumption that +// ** all bytes of a sector are written together by hardware. Hence, all bytes of +// ** a sector need to be journalled in case of a power loss in the middle of +// ** a write. +// ** +// ** Usually, the sector size is less than or equal to the page size, in which +// ** case pages can be individually written. This routine only runs in the +// ** exceptional case where the page size is smaller than the sector size. +// */ +func _pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var ii, nPage, needSync, rc int32 + var nPageCount, nPagePerSector, pg, pg1 TPgno + var pPage1, pPager, v1 uintptr + var _ /* pPage at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = ii, nPage, nPageCount, nPagePerSector, needSync, pPage1, pPager, pg, pg1, rc, v1 + rc = SQLITE_OK /* First page of the sector pPg is located on. */ + nPage = 0 /* Loop counter */ + needSync = 0 /* True if any page has PGHDR_NEED_SYNC */ + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager /* The pager that owns pPg */ + nPagePerSector = libc.Uint32FromInt64(libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) / (*TPager)(unsafe.Pointer(pPager)).FpageSize) + /* Set the doNotSpill NOSYNC bit to 1. This is because we cannot allow + ** a journal header to be written between the pages journaled by + ** this function. + */ + v1 = pPager + 25 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SPILLFLAG_NOSYNC)) + /* This trick assumes that both the page-size and sector-size are + ** an integer power of 2. It sets variable pg1 to the identifier + ** of the first page of the sector pPg is located on. + */ + pg1 = ((*TPgHdr)(unsafe.Pointer(pPg)).Fpgno-uint32(1)) & ^(nPagePerSector-libc.Uint32FromInt32(1)) + uint32(1) + nPageCount = (*TPager)(unsafe.Pointer(pPager)).FdbSize + if (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno > nPageCount { + nPage = libc.Int32FromUint32((*TPgHdr)(unsafe.Pointer(pPg)).Fpgno - pg1 + uint32(1)) + } else { + if pg1+nPagePerSector-uint32(1) > nPageCount { + nPage = libc.Int32FromUint32(nPageCount + uint32(1) - pg1) + } else { + nPage = libc.Int32FromUint32(nPagePerSector) + } + } + ii = 0 + for { + if !(ii < nPage && rc == SQLITE_OK) { + break + } + pg = pg1 + libc.Uint32FromInt32(ii) + if pg == (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno || !(_sqlite3BitvecTest(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal, pg) != 0) { + if pg != (*TPager)(unsafe.Pointer(pPager)).FlckPgno { + rc = _sqlite3PagerGet(tls, pPager, pg, bp, 0) + if rc == SQLITE_OK { + rc = _pager_write(tls, **(**uintptr)(__ccgo_up(bp))) + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fflags)&int32(PGHDR_NEED_SYNC) != 0 { + needSync = int32(1) + } + _sqlite3PagerUnrefNotNull(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + } else { + v1 = _sqlite3PagerLookup(tls, pPager, pg) + **(**uintptr)(__ccgo_up(bp)) = v1 + if v1 != uintptr(0) { + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fflags)&int32(PGHDR_NEED_SYNC) != 0 { + needSync = int32(1) + } + _sqlite3PagerUnrefNotNull(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages + ** starting at pg1, then it needs to be set for all of them. Because + ** writing to any of these nPage pages may damage the others, the + ** journal file must contain sync()ed copies of all of them + ** before any of them can be written out to the database file. + */ + if rc == SQLITE_OK && needSync != 0 { + ii = 0 + for { + if !(ii < nPage) { + break + } + pPage1 = _sqlite3PagerLookup(tls, pPager, pg1+libc.Uint32FromInt32(ii)) + if pPage1 != 0 { + v1 = pPage1 + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(PGHDR_NEED_SYNC)) + _sqlite3PagerUnrefNotNull(tls, pPage1) + } + goto _4 + _4: + ; + ii = ii + 1 + } + } + v1 = pPager + 25 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(SPILLFLAG_NOSYNC)) + return rc +} + +// C documentation +// +// /* +// ** Mark a single data page as writeable. The page is written into the +// ** main journal or sub-journal as required. If the page is written into +// ** one of the journals, the corresponding bit is set in the +// ** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs +// ** of any open savepoints as appropriate. +// */ +func _pager_write(tls *libc.TLS, pPg uintptr) (r int32) { + var pPager, v1 uintptr + var rc int32 + _, _, _ = pPager, rc, v1 + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager + rc = SQLITE_OK + /* This routine is not called unless a write-transaction has already + ** been started. The journal file may or may not be open at this point. + ** It is never called in the ERROR state. + */ + /* The journal file needs to be opened. Higher level routines have already + ** obtained the necessary locks to begin the write-transaction, but the + ** rollback journal might not yet be open. Open it now if this is the case. + ** + ** This is done before calling sqlite3PcacheMakeDirty() on the page. + ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then + ** an error might occur and the pager would end up in WRITER_LOCKED state + ** with pages marked as dirty in the cache. + */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_WRITER_LOCKED) { + rc = _pager_open_journal(tls, pPager) + if rc != SQLITE_OK { + return rc + } + } + /* Mark the page that is about to be modified as dirty. */ + _sqlite3PcacheMakeDirty(tls, pPg) + /* If a rollback journal is in use, them make sure the page that is about + ** to change is in the rollback journal, or if the page is a new page off + ** then end of the file, make sure it is marked as PGHDR_NEED_SYNC. + */ + if (*TPager)(unsafe.Pointer(pPager)).FpInJournal != uintptr(0) && _sqlite3BitvecTestNotNull(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal, (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno) == 0 { + if (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno <= (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize { + rc = _pagerAddPageToRollbackJournal(tls, pPg) + if rc != SQLITE_OK { + return rc + } + } else { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) != int32(PAGER_WRITER_DBMOD) { + v1 = pPg + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(PGHDR_NEED_SYNC)) + } + } + } + /* The PGHDR_DIRTY bit is set above when the page was added to the dirty-list + ** and before writing the page into the rollback journal. Wait until now, + ** after the page has been successfully journalled, before setting the + ** PGHDR_WRITEABLE bit that indicates that the page can be safely modified. + */ + v1 = pPg + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(PGHDR_WRITEABLE)) + /* If the statement journal is open and the page is not in it, + ** then write the page into the statement journal. + */ + if (*TPager)(unsafe.Pointer(pPager)).FnSavepoint > 0 { + rc = _subjournalPageIfRequired(tls, pPg) + } + /* Update the database size and return. */ + if (*TPager)(unsafe.Pointer(pPager)).FdbSize < (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno { + (*TPager)(unsafe.Pointer(pPager)).FdbSize = (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno + } + return rc +} + +func _parseGrowPhraseArray(tls *libc.TLS, pParse uintptr) (r int32) { + var apNew uintptr + var nByte Tsqlite3_int64 + _, _ = apNew, nByte + if (*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase%int32(8) == 0 { + nByte = libc.Int64FromUint64(uint64(8) * libc.Uint64FromInt32((*TFts5Parse)(unsafe.Pointer(pParse)).FnPhrase+libc.Int32FromInt32(8))) + apNew = Xsqlite3_realloc64(tls, (*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase, libc.Uint64FromInt64(nByte)) + if apNew == uintptr(0) { + (*TFts5Parse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + return int32(SQLITE_NOMEM) + } + (*TFts5Parse)(unsafe.Pointer(pParse)).FapPhrase = apNew + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Malloc function used within this file to allocate space from the buffer +// ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no +// ** such buffer exists or there is no space left in it, this function falls +// ** back to sqlite3Malloc(). +// ** +// ** Multiple threads can run this routine at the same time. Global variables +// ** in pcache1 need to be protected via mutex. +// */ +func _pcache1Alloc(tls *libc.TLS, nByte int32) (r uintptr) { + var p uintptr + var sz int32 + _, _ = p, sz + p = uintptr(0) + if nByte <= _pcache1_g.FszSlot { + Xsqlite3_mutex_enter(tls, _pcache1_g.Fmutex) + p = _pcache1_g.FpFree + if p != 0 { + _pcache1_g.FpFree = (*TPgFreeslot)(unsafe.Pointer(_pcache1_g.FpFree)).FpNext + _pcache1_g.FnFreeSlot = _pcache1_g.FnFreeSlot - 1 + libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&_pcache1_g))+140, libc.BoolInt32(_pcache1_g.FnFreeSlot < _pcache1_g.FnReserve), libc.Int32FromInt32(__ATOMIC_RELAXED)) + _sqlite3StatusHighwater(tls, int32(SQLITE_STATUS_PAGECACHE_SIZE), nByte) + _sqlite3StatusUp(tls, int32(SQLITE_STATUS_PAGECACHE_USED), int32(1)) + } + Xsqlite3_mutex_leave(tls, _pcache1_g.Fmutex) + } + if p == uintptr(0) { + /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get + ** it from sqlite3Malloc instead. + */ + p = _sqlite3Malloc(tls, libc.Uint64FromInt32(nByte)) + if p != 0 { + sz = _sqlite3MallocSize(tls, p) + Xsqlite3_mutex_enter(tls, _pcache1_g.Fmutex) + _sqlite3StatusHighwater(tls, int32(SQLITE_STATUS_PAGECACHE_SIZE), nByte) + _sqlite3StatusUp(tls, int32(SQLITE_STATUS_PAGECACHE_OVERFLOW), sz) + Xsqlite3_mutex_leave(tls, _pcache1_g.Fmutex) + } + } + return p +} + +// C documentation +// +// /* +// ** Allocate a new page object initially associated with cache pCache. +// */ +func _pcache1AllocPage(tls *libc.TLS, pCache uintptr, benignMalloc int32) (r uintptr) { + var p, pPg uintptr + _, _ = p, pPg + p = uintptr(0) + if (*TPCache1)(unsafe.Pointer(pCache)).FpFree != 0 || (*TPCache1)(unsafe.Pointer(pCache)).FnPage == uint32(0) && _pcache1InitBulk(tls, pCache) != 0 { + p = (*TPCache1)(unsafe.Pointer(pCache)).FpFree + (*TPCache1)(unsafe.Pointer(pCache)).FpFree = (*TPgHdr1)(unsafe.Pointer(p)).FpNext + (*TPgHdr1)(unsafe.Pointer(p)).FpNext = uintptr(0) + } else { + /* The group mutex must be released before pcache1Alloc() is called. This + ** is because it might call sqlite3_release_memory(), which assumes that + ** this mutex is not held. */ + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) + if benignMalloc != 0 { + _sqlite3BeginBenignMalloc(tls) + } + pPg = _pcache1Alloc(tls, (*TPCache1)(unsafe.Pointer(pCache)).FszAlloc) + if benignMalloc != 0 { + _sqlite3EndBenignMalloc(tls) + } + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) + if pPg == uintptr(0) { + return uintptr(0) + } + p = pPg + uintptr((*TPCache1)(unsafe.Pointer(pCache)).FszPage) + (*TPgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf = pPg + (*TPgHdr1)(unsafe.Pointer(p)).Fpage.FpExtra = p + uintptr((libc.Uint64FromInt64(56)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + (*TPgHdr1)(unsafe.Pointer(p)).FisBulkLocal = uint16(0) + (*TPgHdr1)(unsafe.Pointer(p)).FisAnchor = uint16(0) + (*TPgHdr1)(unsafe.Pointer(p)).FpLruPrev = uintptr(0) /* Initializing this saves a valgrind error */ + } + **(**uint32)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FpnPurgeable)) = **(**uint32)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FpnPurgeable)) + 1 + return p +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xCachesize method. +// ** +// ** Configure the cache_size limit for a cache. +// */ +func _pcache1Cachesize(tls *libc.TLS, p uintptr, nMax int32) { + var n Tu32 + var pCache, pGroup uintptr + _, _, _ = n, pCache, pGroup + pCache = p + if (*TPCache1)(unsafe.Pointer(pCache)).FbPurgeable != 0 { + pGroup = (*TPCache1)(unsafe.Pointer(pCache)).FpGroup + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + n = libc.Uint32FromInt32(nMax) + if n > uint32(0x7fff0000)-(*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage+(*TPCache1)(unsafe.Pointer(pCache)).FnMax { + n = uint32(0x7fff0000) - (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage + (*TPCache1)(unsafe.Pointer(pCache)).FnMax + } + **(**uint32)(__ccgo_up(pGroup + 8)) += n - (*TPCache1)(unsafe.Pointer(pCache)).FnMax + (*TPGroup)(unsafe.Pointer(pGroup)).FmxPinned = (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage + uint32(10) - (*TPGroup)(unsafe.Pointer(pGroup)).FnMinPage + (*TPCache1)(unsafe.Pointer(pCache)).FnMax = n + (*TPCache1)(unsafe.Pointer(pCache)).Fn90pct = (*TPCache1)(unsafe.Pointer(pCache)).FnMax * uint32(9) / uint32(10) + _pcache1EnforceMaxPage(tls, pCache) + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + } +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xCreate method. +// ** +// ** Allocate a new cache. +// */ +func _pcache1Create(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32) (r uintptr) { + var pCache, pGroup, v1 uintptr + var sz Ti64 + var v2 int32 + _, _, _, _, _ = pCache, pGroup, sz, v1, v2 /* Bytes of memory required to allocate the new cache */ + sz = libc.Int64FromUint64(uint64(88) + uint64(80)*libc.Uint64FromInt32(_pcache1_g.FseparateCache)) + pCache = _sqlite3MallocZero(tls, libc.Uint64FromInt64(sz)) + if pCache != 0 { + if _pcache1_g.FseparateCache != 0 { + pGroup = pCache + 1*88 + (*TPGroup)(unsafe.Pointer(pGroup)).FmxPinned = uint32(10) + } else { + pGroup = uintptr(unsafe.Pointer(&_pcache1_g)) + } + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + if libc.Int32FromUint16((*TPGroup)(unsafe.Pointer(pGroup)).Flru.FisAnchor) == 0 { + (*TPGroup)(unsafe.Pointer(pGroup)).Flru.FisAnchor = uint16(1) + v1 = pGroup + 24 + (*TPGroup)(unsafe.Pointer(pGroup)).Flru.FpLruNext = v1 + (*TPGroup)(unsafe.Pointer(pGroup)).Flru.FpLruPrev = v1 + } + (*TPCache1)(unsafe.Pointer(pCache)).FpGroup = pGroup + (*TPCache1)(unsafe.Pointer(pCache)).FszPage = szPage + (*TPCache1)(unsafe.Pointer(pCache)).FszExtra = szExtra + (*TPCache1)(unsafe.Pointer(pCache)).FszAlloc = libc.Int32FromUint64(libc.Uint64FromInt32(szPage+szExtra) + (libc.Uint64FromInt64(56)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + if bPurgeable != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + (*TPCache1)(unsafe.Pointer(pCache)).FbPurgeable = v2 + _pcache1ResizeHash(tls, pCache) + if bPurgeable != 0 { + (*TPCache1)(unsafe.Pointer(pCache)).FnMin = uint32(10) + **(**uint32)(__ccgo_up(pGroup + 12)) += (*TPCache1)(unsafe.Pointer(pCache)).FnMin + (*TPGroup)(unsafe.Pointer(pGroup)).FmxPinned = (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage + uint32(10) - (*TPGroup)(unsafe.Pointer(pGroup)).FnMinPage + (*TPCache1)(unsafe.Pointer(pCache)).FpnPurgeable = pGroup + 20 + } else { + (*TPCache1)(unsafe.Pointer(pCache)).FpnPurgeable = pCache + 48 + } + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + if (*TPCache1)(unsafe.Pointer(pCache)).FnHash == uint32(0) { + _pcache1Destroy(tls, pCache) + pCache = uintptr(0) + } + } + return pCache +} + +// C documentation +// +// /* +// ** Implement steps 3, 4, and 5 of the pcache1Fetch() algorithm described +// ** in the header of the pcache1Fetch() procedure. +// ** +// ** This steps are broken out into a separate procedure because they are +// ** usually not needed, and by avoiding the stack initialization required +// ** for these steps, the main pcache1Fetch() procedure can run faster. +// */ +func _pcache1FetchStage2(tls *libc.TLS, pCache uintptr, iKey uint32, createFlag int32) (r uintptr) { + var h, nPinned uint32 + var pGroup, pOther, pPage uintptr + _, _, _, _, _ = h, nPinned, pGroup, pOther, pPage + pGroup = (*TPCache1)(unsafe.Pointer(pCache)).FpGroup + pPage = uintptr(0) + /* Step 3: Abort if createFlag is 1 but the cache is nearly full */ + nPinned = (*TPCache1)(unsafe.Pointer(pCache)).FnPage - (*TPCache1)(unsafe.Pointer(pCache)).FnRecyclable + if createFlag == int32(1) && (nPinned >= (*TPGroup)(unsafe.Pointer(pGroup)).FmxPinned || nPinned >= (*TPCache1)(unsafe.Pointer(pCache)).Fn90pct || _pcache1UnderMemoryPressure(tls, pCache) != 0 && (*TPCache1)(unsafe.Pointer(pCache)).FnRecyclable < nPinned) { + return uintptr(0) + } + if (*TPCache1)(unsafe.Pointer(pCache)).FnPage >= (*TPCache1)(unsafe.Pointer(pCache)).FnHash { + _pcache1ResizeHash(tls, pCache) + } + /* Step 4. Try to recycle a page. */ + if (*TPCache1)(unsafe.Pointer(pCache)).FbPurgeable != 0 && !((*TPgHdr1)(unsafe.Pointer((*TPGroup)(unsafe.Pointer(pGroup)).Flru.FpLruPrev)).FisAnchor != 0) && ((*TPCache1)(unsafe.Pointer(pCache)).FnPage+uint32(1) >= (*TPCache1)(unsafe.Pointer(pCache)).FnMax || _pcache1UnderMemoryPressure(tls, pCache) != 0) { + pPage = (*TPGroup)(unsafe.Pointer(pGroup)).Flru.FpLruPrev + _pcache1RemoveFromHash(tls, pPage, 0) + _pcache1PinPage(tls, pPage) + pOther = (*TPgHdr1)(unsafe.Pointer(pPage)).FpCache + if (*TPCache1)(unsafe.Pointer(pOther)).FszAlloc != (*TPCache1)(unsafe.Pointer(pCache)).FszAlloc { + _pcache1FreePage(tls, pPage) + pPage = uintptr(0) + } else { + **(**uint32)(__ccgo_up(pGroup + 20)) -= libc.Uint32FromInt32((*TPCache1)(unsafe.Pointer(pOther)).FbPurgeable - (*TPCache1)(unsafe.Pointer(pCache)).FbPurgeable) + } + } + /* Step 5. If a usable page buffer has still not been found, + ** attempt to allocate a new one. + */ + if !(pPage != 0) { + pPage = _pcache1AllocPage(tls, pCache, libc.BoolInt32(createFlag == int32(1))) + } + if pPage != 0 { + h = iKey % (*TPCache1)(unsafe.Pointer(pCache)).FnHash + (*TPCache1)(unsafe.Pointer(pCache)).FnPage = (*TPCache1)(unsafe.Pointer(pCache)).FnPage + 1 + (*TPgHdr1)(unsafe.Pointer(pPage)).FiKey = iKey + (*TPgHdr1)(unsafe.Pointer(pPage)).FpNext = **(**uintptr)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(h)*8)) + (*TPgHdr1)(unsafe.Pointer(pPage)).FpCache = pCache + (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext = uintptr(0) + /* pPage->pLruPrev = 0; + ** No need to clear pLruPrev since it is not accessed when pLruNext==0 */ + **(**uintptr)(__ccgo_up((*TPgHdr1)(unsafe.Pointer(pPage)).Fpage.FpExtra)) = uintptr(0) + **(**uintptr)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(h)*8)) = pPage + if iKey > (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey { + (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey = iKey + } + } + return pPage +} + +// C documentation +// +// /* +// ** Try to initialize the pCache->pFree and pCache->pBulk fields. Return +// ** true if pCache->pFree ends up containing one or more free pages. +// */ +func _pcache1InitBulk(tls *libc.TLS, pCache uintptr) (r int32) { + var nBulk, v2 int32 + var pX, zBulk, v1 uintptr + var szBulk Ti64 + _, _, _, _, _, _ = nBulk, pX, szBulk, zBulk, v1, v2 + if _pcache1_g.FnInitPage == 0 { + return 0 + } + /* Do not bother with a bulk allocation if the cache size very small */ + if (*TPCache1)(unsafe.Pointer(pCache)).FnMax < uint32(3) { + return 0 + } + _sqlite3BeginBenignMalloc(tls) + if _pcache1_g.FnInitPage > 0 { + szBulk = int64((*TPCache1)(unsafe.Pointer(pCache)).FszAlloc) * int64(_pcache1_g.FnInitPage) + } else { + szBulk = int64(-int32(1024)) * int64(_pcache1_g.FnInitPage) + } + if szBulk > int64((*TPCache1)(unsafe.Pointer(pCache)).FszAlloc)*libc.Int64FromUint32((*TPCache1)(unsafe.Pointer(pCache)).FnMax) { + szBulk = int64((*TPCache1)(unsafe.Pointer(pCache)).FszAlloc) * libc.Int64FromUint32((*TPCache1)(unsafe.Pointer(pCache)).FnMax) + } + v1 = _sqlite3Malloc(tls, libc.Uint64FromInt64(szBulk)) + (*TPCache1)(unsafe.Pointer(pCache)).FpBulk = v1 + zBulk = v1 + _sqlite3EndBenignMalloc(tls) + if zBulk != 0 { + nBulk = _sqlite3MallocSize(tls, zBulk) / (*TPCache1)(unsafe.Pointer(pCache)).FszAlloc + for { + pX = zBulk + uintptr((*TPCache1)(unsafe.Pointer(pCache)).FszPage) + (*TPgHdr1)(unsafe.Pointer(pX)).Fpage.FpBuf = zBulk + (*TPgHdr1)(unsafe.Pointer(pX)).Fpage.FpExtra = pX + uintptr((libc.Uint64FromInt64(56)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + (*TPgHdr1)(unsafe.Pointer(pX)).FisBulkLocal = uint16(1) + (*TPgHdr1)(unsafe.Pointer(pX)).FisAnchor = uint16(0) + (*TPgHdr1)(unsafe.Pointer(pX)).FpNext = (*TPCache1)(unsafe.Pointer(pCache)).FpFree + (*TPgHdr1)(unsafe.Pointer(pX)).FpLruPrev = uintptr(0) /* Initializing this saves a valgrind error */ + (*TPCache1)(unsafe.Pointer(pCache)).FpFree = pX + zBulk = zBulk + uintptr((*TPCache1)(unsafe.Pointer(pCache)).FszAlloc) + goto _3 + _3: + ; + nBulk = nBulk - 1 + v2 = nBulk + if !(v2 != 0) { + break + } + } + } + return libc.BoolInt32((*TPCache1)(unsafe.Pointer(pCache)).FpFree != uintptr(0)) +} + +// C documentation +// +// /* +// ** Make sure the cell sizes at idx, idx+1, ..., idx+N-1 have been +// ** computed. +// */ +func _populateCellCache(tls *libc.TLS, p uintptr, idx int32, N int32) { + var pRef, szCell uintptr + _, _ = pRef, szCell + pRef = (*TCellArray)(unsafe.Pointer(p)).FpRef + szCell = (*TCellArray)(unsafe.Pointer(p)).FszCell + for N > 0 { + if libc.Int32FromUint16(**(**Tu16)(__ccgo_up(szCell + uintptr(idx)*2))) == 0 { + **(**Tu16)(__ccgo_up(szCell + uintptr(idx)*2)) = (*(*func(*libc.TLS, uintptr, uintptr) Tu16)(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pRef)).FxCellSize})))(tls, pRef, **(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(p)).FapCell + uintptr(idx)*8))) + } else { + } + idx = idx + 1 + N = N - 1 + } +} + +// C documentation +// +// /* The xColumn method simply returns the corresponding column from +// ** the PRAGMA. +// */ +func _pragmaVtabColumn(tls *libc.TLS, pVtabCursor uintptr, ctx uintptr, i int32) (r int32) { + var pCsr, pTab uintptr + _, _ = pCsr, pTab + pCsr = pVtabCursor + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab + if i < libc.Int32FromUint8((*TPragmaVtab)(unsafe.Pointer(pTab)).FiHidden) { + Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma, i)) + } else { + Xsqlite3_result_text(tls, ctx, **(**uintptr)(__ccgo_up(pCsr + 24 + uintptr(i-libc.Int32FromUint8((*TPragmaVtab)(unsafe.Pointer(pTab)).FiHidden))*8)), -int32(1), uintptr(-libc.Int32FromInt32(1))) + } + return SQLITE_OK +} + +// C documentation +// +// /* Clear all content from pragma virtual table cursor. */ +func _pragmaVtabCursorClear(tls *libc.TLS, pCsr uintptr) { + var i int32 + _ = i + Xsqlite3_finalize(tls, (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) + (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma = uintptr(0) + (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid = 0 + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(16)/libc.Uint64FromInt64(8))) { + break + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(pCsr + 24 + uintptr(i)*8))) + **(**uintptr)(__ccgo_up(pCsr + 24 + uintptr(i)*8)) = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** fts5VisitEntries() callback used by fts5SetupPrefixIter() +// */ +func _prefixIterSetupCb(tls *libc.TLS, p uintptr, pCtx uintptr, p1 uintptr, pNew uintptr, nNew int32) { + var i, i1, iStore, nMerge int32 + var pSetup uintptr + _, _, _, _, _ = i, i1, iStore, nMerge, pSetup + pSetup = pCtx + nMerge = (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FnMerge + if (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FnData > 0 { + if (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FiRowid <= (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FiLastRowid && (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).Fdoclist.Fn > 0 { + i = 0 + for { + if !((*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).Fdoclist.Fn != 0) { + break + } + i1 = i * nMerge + iStore = i1 + for { + if !(iStore < i1+nMerge) { + break + } + if (**(**TFts5Buffer)(__ccgo_up((*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FaBuf + uintptr(iStore)*16))).Fn == 0 { + _fts5BufferSwap(tls, pSetup+48, (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FaBuf+uintptr(iStore)*16) + _sqlite3Fts5BufferZero(tls, pSetup+48) + break + } + goto _2 + _2: + ; + iStore = iStore + 1 + } + if iStore == i1+nMerge { + (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FxMerge})))(tls, p, pSetup+48, nMerge, (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FaBuf+uintptr(i1)*16) + iStore = i1 + for { + if !(iStore < i1+nMerge) { + break + } + _sqlite3Fts5BufferZero(tls, (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FaBuf+uintptr(iStore)*16) + goto _3 + _3: + ; + iStore = iStore + 1 + } + } + goto _1 + _1: + ; + i = i + 1 + } + (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FiLastRowid = 0 + } + (*(*func(*libc.TLS, uintptr, Tu64, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FxAppend})))(tls, p, libc.Uint64FromInt64((*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FiRowid)-libc.Uint64FromInt64((*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FiLastRowid), p1, pSetup+48) + (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FiLastRowid = (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FiRowid + } + if (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FpTokendata != 0 { + _prefixIterSetupTokendataCb(tls, p, (*TPrefixSetupCtx)(unsafe.Pointer(pSetup)).FpTokendata, p1, pNew, nNew) + } +} + +// C documentation +// +// /* +// ** fts5VisitEntries() callback used by fts5SetupPrefixIterTokendata(). This +// ** callback adds an entry to the Fts5TokenDataIter.aMap[] array for each +// ** position in the current position-list. It doesn't matter that some of +// ** these may be out of order - they will be sorted later. +// */ +func _prefixIterSetupTokendataCb(tls *libc.TLS, p uintptr, pCtx uintptr, p1 uintptr, pNew uintptr, nNew int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pSetup uintptr + var _ /* iPos at bp+8 */ Ti64 + var _ /* iPosOff at bp+0 */ int32 + _ = pSetup + pSetup = pCtx + **(**int32)(__ccgo_up(bp)) = 0 + **(**Ti64)(__ccgo_up(bp + 8)) = 0 + if pNew != 0 { + (*TTokendataSetupCtx)(unsafe.Pointer(pSetup)).FnTermByte = nNew - int32(1) + (*TTokendataSetupCtx)(unsafe.Pointer(pSetup)).FiTermOff = (*TFts5TokenDataIter)(unsafe.Pointer((*TTokendataSetupCtx)(unsafe.Pointer(pSetup)).FpT)).Fterms.Fn + _sqlite3Fts5BufferAppendBlob(tls, p+60, (*TTokendataSetupCtx)(unsafe.Pointer(pSetup)).FpT+24, libc.Uint32FromInt32(nNew-int32(1)), pNew+uintptr(1)) + } + for 0 == _sqlite3Fts5PoslistNext64(tls, (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FpData, (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FnData, bp, bp+8) { + _fts5TokendataIterAppendMap(tls, p, (*TTokendataSetupCtx)(unsafe.Pointer(pSetup)).FpT, (*TTokendataSetupCtx)(unsafe.Pointer(pSetup)).FiTermOff, (*TTokendataSetupCtx)(unsafe.Pointer(pSetup)).FnTermByte, (*TFts5Iter)(unsafe.Pointer(p1)).Fbase.FiRowid, **(**Ti64)(__ccgo_up(bp + 8))) + } +} + +// C documentation +// +// /* +// ** Implementation of the printf() (a.k.a. format()) SQL function. +// */ +func _printfFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, zFormat, v1 uintptr + var n int32 + var v2 bool + var _ /* str at bp+16 */ TStrAccum + var _ /* x at bp+0 */ TPrintfArguments + _, _, _, _, _ = db, n, zFormat, v1, v2 + db = Xsqlite3_context_db_handle(tls, context) + if v2 = argc >= int32(1); v2 { + v1 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zFormat = v1 + } + if v2 && v1 != uintptr(0) { + (**(**TPrintfArguments)(__ccgo_up(bp))).FnArg = argc - int32(1) + (**(**TPrintfArguments)(__ccgo_up(bp))).FnUsed = 0 + (**(**TPrintfArguments)(__ccgo_up(bp))).FapArg = argv + uintptr(1)*8 + _sqlite3StrAccumInit(tls, bp+16, db, uintptr(0), 0, **(**int32)(__ccgo_up(db + 136))) + (**(**TStrAccum)(__ccgo_up(bp + 16))).FprintfFlags = uint8(SQLITE_PRINTF_SQLFUNC) + Xsqlite3_str_appendf(tls, bp+16, zFormat, libc.VaList(bp+56, bp)) + if libc.Int32FromUint8((**(**TStrAccum)(__ccgo_up(bp + 16))).FaccError) == SQLITE_OK { + n = libc.Int32FromUint32((**(**TStrAccum)(__ccgo_up(bp + 16))).FnChar) + Xsqlite3_result_text(tls, context, _sqlite3StrAccumFinish(tls, bp+16), n, __ccgo_fp(_sqlite3RowSetClear)) + } else { + if libc.Int32FromUint8((**(**TStrAccum)(__ccgo_up(bp + 16))).FaccError) == int32(SQLITE_NOMEM) { + Xsqlite3_result_error_nomem(tls, context) + } else { + Xsqlite3_result_error_toobig(tls, context) + } + Xsqlite3_str_reset(tls, bp+16) + } + } +} + +// C documentation +// +// /* +// ** The cell pCell is currently part of page pSrc but will ultimately be part +// ** of pPage. (pSrc and pPage are often the same.) If pCell contains a +// ** pointer to an overflow page, insert an entry into the pointer-map for +// ** the overflow page that will be valid after pCell has been moved to pPage. +// */ +func _ptrmapPutOvflPtr(tls *libc.TLS, pPage uintptr, pSrc uintptr, pCell uintptr, pRC uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ovfl TPgno + var _ /* info at bp+0 */ TCellInfo + _ = ovfl + if **(**int32)(__ccgo_up(pRC)) != 0 { + return + } + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell})))(tls, pPage, pCell, bp) + if uint32((**(**TCellInfo)(__ccgo_up(bp))).FnLocal) < (**(**TCellInfo)(__ccgo_up(bp))).FnPayload { + if uint64(pCell) < uint64((*TMemPage)(unsafe.Pointer(pSrc)).FaDataEnd) && uint64(pCell+uintptr((**(**TCellInfo)(__ccgo_up(bp))).FnLocal)) > uint64((*TMemPage)(unsafe.Pointer(pSrc)).FaDataEnd) { + **(**int32)(__ccgo_up(pRC)) = _sqlite3CorruptError(tls, int32(74732)) + return + } + ovfl = _sqlite3Get4byte(tls, pCell+uintptr(libc.Int32FromUint16((**(**TCellInfo)(__ccgo_up(bp))).FnSize)-int32(4))) + _ptrmapPut(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpBt, ovfl, uint8(PTRMAP_OVERFLOW1), (*TMemPage)(unsafe.Pointer(pPage)).Fpgno, pRC) + } +} + +// C documentation +// +// /* +// ** Make copies of relevant WHERE clause terms of the outer query into +// ** the WHERE clause of subquery. Example: +// ** +// ** SELECT * FROM (SELECT a AS x, c-d AS y FROM t1) WHERE x=5 AND y=10; +// ** +// ** Transformed into: +// ** +// ** SELECT * FROM (SELECT a AS x, c-d AS y FROM t1 WHERE a=5 AND c-d=10) +// ** WHERE x=5 AND y=10; +// ** +// ** The hope is that the terms added to the inner query will make it more +// ** efficient. +// ** +// ** NAME AMBIGUITY +// ** +// ** This optimization is called the "WHERE-clause push-down optimization" +// ** or sometimes the "predicate push-down optimization". +// ** +// ** Do not confuse this optimization with another unrelated optimization +// ** with a similar name: The "MySQL push-down optimization" causes WHERE +// ** clause terms that can be evaluated using only the index and without +// ** reference to the table are run first, so that if they are false, +// ** unnecessary table seeks are avoided. +// ** +// ** RULES +// ** +// ** Do not attempt this optimization if: +// ** +// ** (1) (** This restriction was removed on 2017-09-29. We used to +// ** disallow this optimization for aggregate subqueries, but now +// ** it is allowed by putting the extra terms on the HAVING clause. +// ** The added HAVING clause is pointless if the subquery lacks +// ** a GROUP BY clause. But such a HAVING clause is also harmless +// ** so there does not appear to be any reason to add extra logic +// ** to suppress it. **) +// ** +// ** (2) The inner query is the recursive part of a common table expression. +// ** +// ** (3) The inner query has a LIMIT clause (since the changes to the WHERE +// ** clause would change the meaning of the LIMIT). +// ** +// ** (4) The inner query is the right operand of a LEFT JOIN and the +// ** expression to be pushed down does not come from the ON clause +// ** on that LEFT JOIN. +// ** +// ** (5) The WHERE clause expression originates in the ON or USING clause +// ** of a LEFT JOIN where iCursor is not the right-hand table of that +// ** left join. An example: +// ** +// ** SELECT * +// ** FROM (SELECT 1 AS a1 UNION ALL SELECT 2) AS aa +// ** JOIN (SELECT 1 AS b2 UNION ALL SELECT 2) AS bb ON (a1=b2) +// ** LEFT JOIN (SELECT 8 AS c3 UNION ALL SELECT 9) AS cc ON (b2=2); +// ** +// ** The correct answer is three rows: (1,1,NULL),(2,2,8),(2,2,9). +// ** But if the (b2=2) term were to be pushed down into the bb subquery, +// ** then the (1,1,NULL) row would be suppressed. +// ** +// ** (6) Window functions make things tricky as changes to the WHERE clause +// ** of the inner query could change the window over which window +// ** functions are calculated. Therefore, do not attempt the optimization +// ** if: +// ** +// ** (6a) The inner query uses multiple incompatible window partitions. +// ** +// ** (6b) The inner query is a compound and uses window-functions. +// ** +// ** (6c) The WHERE clause does not consist entirely of constants and +// ** copies of expressions found in the PARTITION BY clause of +// ** all window-functions used by the sub-query. It is safe to +// ** filter out entire partitions, as this does not change the +// ** window over which any window-function is calculated. +// ** +// ** (7) The inner query is a Common Table Expression (CTE) that should +// ** be materialized. (This restriction is implemented in the calling +// ** routine.) +// ** +// ** (8) If the subquery is a compound that uses UNION, INTERSECT, +// ** or EXCEPT, then all of the result set columns for all arms of +// ** the compound must use the BINARY collating sequence. +// ** +// ** (9) All three of the following are true: +// ** +// ** (9a) The WHERE clause expression originates in the ON or USING clause +// ** of a join (either an INNER or an OUTER join), and +// ** +// ** (9b) The subquery is to the right of the ON/USING clause +// ** +// ** (9c) There is a RIGHT JOIN (or FULL JOIN) in between the ON/USING +// ** clause and the subquery. +// ** +// ** Without this restriction, the WHERE-clause push-down optimization +// ** might move the ON/USING filter expression from the left side of a +// ** RIGHT JOIN over to the right side, which leads to incorrect answers. +// ** See also restriction (6) in sqlite3ExprIsSingleTableConstraint(). +// ** +// ** (10) The inner query is not the right-hand table of a RIGHT JOIN. +// ** +// ** (11) The subquery is not a VALUES clause +// ** +// ** (12) The WHERE clause is not "rowid ISNULL" or the equivalent. This +// ** case only comes up if SQLite is compiled using +// ** SQLITE_ALLOW_ROWID_IN_VIEW. +// ** +// ** Return 0 if no changes are made and non-zero if one or more WHERE clause +// ** terms are duplicated into the subquery. +// */ +func _pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uintptr, pSrcList uintptr, iSrc int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var ii, nChng, notUnionAll int32 + var op Tu8 + var pColl, pList, pNew, pSel, pSrc uintptr + var _ /* x at bp+0 */ TSubstContext + _, _, _, _, _, _, _, _, _ = ii, nChng, notUnionAll, op, pColl, pList, pNew, pSel, pSrc /* The subquery FROM term into which WHERE is pushed */ + nChng = 0 + pSrc = pSrcList + 8 + uintptr(iSrc)*80 + if pWhere == uintptr(0) { + return 0 + } + if (*TSelect)(unsafe.Pointer(pSubq)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Recursive)|libc.Int32FromInt32(SF_MultiPart)) != 0 { + return 0 /* restrictions (2) and (11) */ + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 { + return 0 /* restrictions (10) */ + } + if (*TSelect)(unsafe.Pointer(pSubq)).FpPrior != 0 { + notUnionAll = 0 + pSel = pSubq + for { + if !(pSel != 0) { + break + } + op = (*TSelect)(unsafe.Pointer(pSel)).Fop + if libc.Int32FromUint8(op) != int32(TK_ALL) && libc.Int32FromUint8(op) != int32(TK_SELECT) { + notUnionAll = int32(1) + } + if (*TSelect)(unsafe.Pointer(pSel)).FpWin != 0 { + return 0 + } /* restriction (6b) */ + goto _1 + _1: + ; + pSel = (*TSelect)(unsafe.Pointer(pSel)).FpPrior + } + if notUnionAll != 0 { + /* If any of the compound arms are connected using UNION, INTERSECT, + ** or EXCEPT, then we must ensure that none of the columns use a + ** non-BINARY collating sequence. */ + pSel = pSubq + for { + if !(pSel != 0) { + break + } + pList = (*TSelect)(unsafe.Pointer(pSel)).FpEList + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + pColl = _sqlite3ExprCollSeq(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr) + if !(_sqlite3IsBinary(tls, pColl) != 0) { + return 0 /* Restriction (8) */ + } + goto _3 + _3: + ; + ii = ii + 1 + } + goto _2 + _2: + ; + pSel = (*TSelect)(unsafe.Pointer(pSel)).FpPrior + } + } + } else { + if (*TSelect)(unsafe.Pointer(pSubq)).FpWin != 0 && (*TWindow)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSubq)).FpWin)).FpPartition == uintptr(0) { + return 0 + } + } + if (*TSelect)(unsafe.Pointer(pSubq)).FpLimit != uintptr(0) { + return 0 /* restriction (3) */ + } + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pWhere)).Fop) == int32(TK_AND) { + nChng = nChng + _pushDownWhereTerms(tls, pParse, pSubq, (*TExpr)(unsafe.Pointer(pWhere)).FpRight, pSrcList, iSrc) + pWhere = (*TExpr)(unsafe.Pointer(pWhere)).FpLeft + } + if _sqlite3ExprIsSingleTableConstraint(tls, pWhere, pSrcList, iSrc, int32(1)) != 0 { + nChng = nChng + 1 + **(**Tu32)(__ccgo_up(pSubq + 4)) |= uint32(SF_PushDown) + for pSubq != 0 { + pNew = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pWhere, 0) + _unsetJoinExpr(tls, pNew, -int32(1), int32(1)) + (**(**TSubstContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TSubstContext)(__ccgo_up(bp))).FiTable = (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor + (**(**TSubstContext)(__ccgo_up(bp))).FiNewTable = (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor + (**(**TSubstContext)(__ccgo_up(bp))).FisOuterJoin = 0 + (**(**TSubstContext)(__ccgo_up(bp))).FnSelDepth = 0 + (**(**TSubstContext)(__ccgo_up(bp))).FpEList = (*TSelect)(unsafe.Pointer(pSubq)).FpEList + (**(**TSubstContext)(__ccgo_up(bp))).FpCList = _findLeftmostExprlist(tls, pSubq) + pNew = _substExpr(tls, bp, pNew) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pNew)).Fop) == int32(TK_IN) && (*TExpr)(unsafe.Pointer(pNew)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pNew + 32)) + 4)) |= uint32(SF_ClonedRhsIn) + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pWhere + 32)) + 4)) |= uint32(SF_ClonedRhsIn) + } + if (*TSelect)(unsafe.Pointer(pSubq)).FpWin != 0 && 0 == _pushDownWindowCheck(tls, pParse, pSubq, pNew) { + /* Restriction 6c has prevented push-down in this case */ + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pNew) + nChng = nChng - 1 + break + } + if (*TSelect)(unsafe.Pointer(pSubq)).FselFlags&uint32(SF_Aggregate) != 0 { + (*TSelect)(unsafe.Pointer(pSubq)).FpHaving = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(pSubq)).FpHaving, pNew) + } else { + (*TSelect)(unsafe.Pointer(pSubq)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(pSubq)).FpWhere, pNew) + } + pSubq = (*TSelect)(unsafe.Pointer(pSubq)).FpPrior + } + } + return nChng +} + +// C documentation +// +// /* +// ** Query to see if Btree handle p may obtain a lock of type eLock +// ** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return +// ** SQLITE_OK if the lock may be obtained (by calling +// ** setSharedCacheTableLock()), or SQLITE_LOCKED if not. +// */ +func _querySharedCacheTableLock(tls *libc.TLS, p uintptr, iTab TPgno, eLock Tu8) (r int32) { + var pBt, pIter, v2 uintptr + _, _, _ = pBt, pIter, v2 + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + /* If requesting a write-lock, then the Btree must have an open write + ** transaction on this file. And, obviously, for this to be so there + ** must be an open write transaction on the file itself. + */ + /* This routine is a no-op if the shared-cache is not enabled */ + if !((*TBtree)(unsafe.Pointer(p)).Fsharable != 0) { + return SQLITE_OK + } + /* If some other connection is holding an exclusive lock, the + ** requested lock may not be obtained. + */ + if (*TBtShared)(unsafe.Pointer(pBt)).FpWriter != p && libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_EXCLUSIVE) != 0 { + _sqlite3ConnectionBlocked(tls, (*TBtree)(unsafe.Pointer(p)).Fdb, (*TBtree)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpWriter)).Fdb) + return libc.Int32FromInt32(SQLITE_LOCKED) | libc.Int32FromInt32(1)<eLock!=eLock) in the following if(...) + ** statement is a simplification of: + ** + ** (eLock==WRITE_LOCK || pIter->eLock==WRITE_LOCK) + ** + ** since we know that if eLock==WRITE_LOCK, then no other connection + ** may hold a WRITE_LOCK on any table in this file (since there can + ** only be a single writer). + */ + if (*TBtLock)(unsafe.Pointer(pIter)).FpBtree != p && (*TBtLock)(unsafe.Pointer(pIter)).FiTable == iTab && libc.Int32FromUint8((*TBtLock)(unsafe.Pointer(pIter)).FeLock) != libc.Int32FromUint8(eLock) { + _sqlite3ConnectionBlocked(tls, (*TBtree)(unsafe.Pointer(p)).Fdb, (*TBtree)(unsafe.Pointer((*TBtLock)(unsafe.Pointer(pIter)).FpBtree)).Fdb) + if libc.Int32FromUint8(eLock) == int32(WRITE_LOCK) { + v2 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(BTS_PENDING)) + } + return libc.Int32FromInt32(SQLITE_LOCKED) | libc.Int32FromInt32(1)<azTblCol[] and abTblPk[] arrays so that +// ** there is room for at least nCol elements. If an OOM occurs, store an +// ** error code in the RBU handle passed as the first argument. +// */ +func _rbuAllocateIterArrays(tls *libc.TLS, p uintptr, pIter uintptr, nCol int32) { + var azNew uintptr + var nByte Tsqlite3_int64 + _, _ = azNew, nByte + nByte = libc.Int64FromUint64((libc.Uint64FromInt32(2)*libc.Uint64FromInt64(8) + libc.Uint64FromInt64(4) + libc.Uint64FromInt32(3)*libc.Uint64FromInt64(1)) * libc.Uint64FromInt32(nCol)) + azNew = _rbuMalloc(tls, p, nByte) + if azNew != 0 { + (*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol = azNew + (*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType = azNew + uintptr(nCol)*8 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder = (*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(nCol)*8 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk = (*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(nCol)*4 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FabNotNull = (*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(nCol) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FabIndexed = (*TRbuObjIter)(unsafe.Pointer(pIter)).FabNotNull + uintptr(nCol) + } +} + +// C documentation +// +// /* +// ** Called when iAmt bytes are read from offset iOff of the wal file while +// ** the rbu object is in capture mode. Record the frame number of the frame +// ** being read in the aFrame[] array. +// */ +func _rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff Ti64, iAmt int32) (r int32) { + var aNew uintptr + var iFrame, mReq Tu32 + var nNew, v1 int32 + _, _, _, _, _ = aNew, iFrame, mReq, nNew, v1 + mReq = libc.Uint32FromInt32(libc.Int32FromInt32(1)<= 0) { + break + } + v = v<journalOff. See comments above function writeJournalHdr() for +// ** a description of the journal header format. +// ** +// ** If the header is read successfully, *pNRec is set to the number of +// ** page records following this header and *pDbSize is set to the size of the +// ** database before the transaction began, in pages. Also, pPager->cksumInit +// ** is set to the value read from the journal header. SQLITE_OK is returned +// ** in this case. +// ** +// ** If the journal header file appears to be corrupted, SQLITE_DONE is +// ** returned and *pNRec and *PDbSize are undefined. If JOURNAL_HDR_SZ bytes +// ** cannot be read from the journal file an error code is returned. +// */ +func _readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize Ti64, pNRec uintptr, pDbSize uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iHdrOff Ti64 + var rc, v1, v2, v4 int32 + var v3, v5 bool + var _ /* aMagic at bp+0 */ [8]uint8 + var _ /* iPageSize at bp+8 */ Tu32 + var _ /* iSectorSize at bp+12 */ Tu32 + _, _, _, _, _, _, _ = iHdrOff, rc, v1, v2, v3, v4, v5 /* Offset of journal header being read */ + /* Journal file must be open. */ + /* Advance Pager.journalOff to the start of the next sector. If the + ** journal file is too small for there to be a header stored at this + ** point, return SQLITE_DONE. + */ + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = _journalHdrOffset(tls, pPager) + if (*TPager)(unsafe.Pointer(pPager)).FjournalOff+libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) > journalSize { + return int32(SQLITE_DONE) + } + iHdrOff = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + /* Read in the first 8 bytes of the journal header. If they do not match + ** the magic string found at the start of each journal header, return + ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise, + ** proceed. + */ + if isHot != 0 || iHdrOff != (*TPager)(unsafe.Pointer(pPager)).FjournalHdr { + rc = _sqlite3OsRead(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp, int32(8), iHdrOff) + if rc != 0 { + return rc + } + if libc.Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_aJournalMagic)), uint64(8)) != 0 { + return int32(SQLITE_DONE) + } + } + /* Read the first three 32-bit fields of the journal header: The nRec + ** field, the checksum-initializer and the database size at the start + ** of the transaction. Return an error code if anything goes wrong. + */ + v1 = _read32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(8), pNRec) + rc = v1 + if v3 = SQLITE_OK != v1; !v3 { + v2 = _read32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(12), pPager+56) + rc = v2 + } + if v5 = v3 || SQLITE_OK != v2; !v5 { + v4 = _read32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(16), pDbSize) + rc = v4 + } + if v5 || SQLITE_OK != v4 { + return rc + } + if (*TPager)(unsafe.Pointer(pPager)).FjournalOff == 0 { /* Sector-size field of journal header */ + /* Read the page-size and sector-size journal header fields. */ + v1 = _read32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(20), bp+12) + rc = v1 + if v3 = SQLITE_OK != v1; !v3 { + v2 = _read32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(24), bp+8) + rc = v2 + } + if v3 || SQLITE_OK != v2 { + return rc + } + /* Versions of SQLite prior to 3.5.8 set the page-size field of the + ** journal header to zero. In this case, assume that the Pager.pageSize + ** variable is already set to the correct page size. + */ + if **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0) { + **(**Tu32)(__ccgo_up(bp + 8)) = libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) + } + /* Check that the values read from the page-size and sector-size fields + ** are within range. To be 'in range', both values need to be a power + ** of two greater than or equal to 512 or 32, and not greater than their + ** respective compile time maximum limits. + */ + if **(**Tu32)(__ccgo_up(bp + 8)) < uint32(512) || **(**Tu32)(__ccgo_up(bp + 12)) < uint32(32) || **(**Tu32)(__ccgo_up(bp + 8)) > uint32(SQLITE_MAX_PAGE_SIZE) || **(**Tu32)(__ccgo_up(bp + 12)) > uint32(MAX_SECTOR_SIZE) || (**(**Tu32)(__ccgo_up(bp + 8))-uint32(1))&**(**Tu32)(__ccgo_up(bp + 8)) != uint32(0) || (**(**Tu32)(__ccgo_up(bp + 12))-uint32(1))&**(**Tu32)(__ccgo_up(bp + 12)) != uint32(0) { + /* If the either the page-size or sector-size in the journal-header is + ** invalid, then the process that wrote the journal-header must have + ** crashed before the header was synced. In this case stop reading + ** the journal file here. + */ + return int32(SQLITE_DONE) + } + /* Update the page-size to match the value read from the journal. + ** Use a testcase() macro to make sure that malloc failure within + ** PagerSetPagesize() is tested. + */ + rc = _sqlite3PagerSetPagesize(tls, pPager, bp+8, -int32(1)) + /* Update the assumed sector-size to match the value used by + ** the process that created this journal. If this journal was + ** created by a process other than this one, then this routine + ** is being called from within pager_playback(). The local value + ** of Pager.sectorSize is restored at the end of that routine. + */ + (*TPager)(unsafe.Pointer(pPager)).FsectorSize = **(**Tu32)(__ccgo_up(bp + 12)) + } + **(**Ti64)(__ccgo_up(pPager + 96)) += libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) + return rc +} + +// C documentation +// +// /* Recompute the colNotIdxed field of the Index. +// ** +// ** colNotIdxed is a bitmask that has a 0 bit representing each indexed +// ** columns that are within the first 63 columns of the table and a 1 for +// ** all other bits (all columns that are not in the index). The +// ** high-order bit of colNotIdxed is always 1. All unindexed columns +// ** of the table have a 1. +// ** +// ** 2019-10-24: For the purpose of this computation, virtual columns are +// ** not considered to be covered by the index, even if they are in the +// ** index, because we do not trust the logic in whereIndexExprTrans() to be +// ** able to find all instances of a reference to the indexed table column +// ** and convert them into references to the index. Hence we always want +// ** the actual table at hand in order to recompute the virtual column, if +// ** necessary. +// ** +// ** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask +// ** to determine if the index is covering index. +// */ +func _recomputeColumnsNotIndexed(tls *libc.TLS, pIdx uintptr) { + var j, x int32 + var m TBitmask + var pTab uintptr + _, _, _, _ = j, m, pTab, x + m = uint64(0) + pTab = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + j = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) - int32(1) + for { + if !(j >= 0) { + break + } + x = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) + if x >= 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(x)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + if x < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + m = m | libc.Uint64FromInt32(1)<colUsed mask. +// */ +func _recomputeColumnsUsedExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var pItem uintptr + _ = pItem + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLUMN) { + return WRC_Continue + } + pItem = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + if (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor != (*TExpr)(unsafe.Pointer(pExpr)).FiTable { + return WRC_Continue + } + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) < 0 { + return WRC_Continue + } + **(**TBitmask)(__ccgo_up(pItem + 40)) |= _sqlite3ExprColUsed(tls, pExpr) + return WRC_Continue +} + +// C documentation +// +// /* +// ** Release auxiliary memory held in an array of N Mem elements. +// ** +// ** After this routine returns, all Mem elements in the array will still +// ** be valid. Those Mem elements that were not holding auxiliary resources +// ** will be unchanged. Mem elements which had something freed will be +// ** set to MEM_Undefined. +// */ +func _releaseMemArray(tls *libc.TLS, p uintptr, N int32) { + var db, pEnd, v1 uintptr + _, _, _ = db, pEnd, v1 + if p != 0 && N != 0 { + pEnd = p + uintptr(N)*56 + db = (*TMem)(unsafe.Pointer(p)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed != 0 { + for { + if (*TMem)(unsafe.Pointer(p)).FszMalloc != 0 { + _sqlite3DbFree(tls, db, (*TMem)(unsafe.Pointer(p)).FzMalloc) + } + goto _2 + _2: + ; + p += 56 + v1 = p + if !(v1 < pEnd) { + break + } + } + return + } + for { + /* This block is really an inlined version of sqlite3VdbeMemRelease() + ** that takes advantage of the fact that the memory cell value is + ** being set to NULL after releasing any dynamic resources. + ** + ** The justification for duplicating code is that according to + ** callgrind, this causes a certain test case to hit the CPU 4.7 + ** percent less (x86 linux, gcc version 4.1.2, -O6) than if + ** sqlite3MemRelease() were called from here. With -O2, this jumps + ** to 6.6 percent. The test case is inserting 1000 rows into a table + ** with no indexes using a single prepared INSERT statement, bind() + ** and reset(). Inserts are grouped into a transaction. + */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _sqlite3VdbeMemRelease(tls, p) + (*TMem)(unsafe.Pointer(p)).Fflags = uint16(MEM_Undefined) + } else { + if (*TMem)(unsafe.Pointer(p)).FszMalloc != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TMem)(unsafe.Pointer(p)).FzMalloc) + (*TMem)(unsafe.Pointer(p)).FszMalloc = 0 + (*TMem)(unsafe.Pointer(p)).Fflags = uint16(MEM_Undefined) + } + } + goto _4 + _4: + ; + p += 56 + v1 = p + if !(v1 < pEnd) { + break + } + } + } +} + +// C documentation +// +// /* +// ** Move the open database page pDbPage to location iFreePage in the +// ** database. The pDbPage reference remains valid. +// ** +// ** The isCommit flag indicates that there is no need to remember that +// ** the journal needs to be sync()ed before database page pDbPage->pgno +// ** can be written to. The caller has already promised not to write to that +// ** page. +// */ +func _relocatePage(tls *libc.TLS, pBt uintptr, pDbPage uintptr, eType Tu8, iPtrPage TPgno, iFreePage TPgno, isCommit int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDbPage, nextOvfl TPgno + var pPager uintptr + var _ /* pPtrPage at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _, _ = iDbPage, nextOvfl, pPager /* The page that contains a pointer to pDbPage */ + iDbPage = (*TMemPage)(unsafe.Pointer(pDbPage)).Fpgno + pPager = (*TBtShared)(unsafe.Pointer(pBt)).FpPager + if iDbPage < uint32(3) { + return _sqlite3CorruptError(tls, int32(77098)) + } + /* Move page iDbPage from its current location to page number iFreePage */ + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3PagerMovepage(tls, pPager, (*TMemPage)(unsafe.Pointer(pDbPage)).FpDbPage, iFreePage, isCommit) + if **(**int32)(__ccgo_up(bp + 8)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 8)) + } + (*TMemPage)(unsafe.Pointer(pDbPage)).Fpgno = iFreePage + /* If pDbPage was a btree-page, then it may have child pages and/or cells + ** that point to overflow pages. The pointer map entries for all these + ** pages need to be changed. + ** + ** If pDbPage is an overflow page, then the first 4 bytes may store a + ** pointer to a subsequent overflow page. If this is the case, then + ** the pointer map needs to be updated for the subsequent overflow page. + */ + if libc.Int32FromUint8(eType) == int32(PTRMAP_BTREE) || libc.Int32FromUint8(eType) == int32(PTRMAP_ROOTPAGE) { + **(**int32)(__ccgo_up(bp + 8)) = _setChildPtrmaps(tls, pDbPage) + if **(**int32)(__ccgo_up(bp + 8)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 8)) + } + } else { + nextOvfl = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pDbPage)).FaData) + if nextOvfl != uint32(0) { + _ptrmapPut(tls, pBt, nextOvfl, uint8(PTRMAP_OVERFLOW2), iFreePage, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 8)) + } + } + } + /* Fix the database pointer on page iPtrPage that pointed at iDbPage so + ** that it points at iFreePage. Also fix the pointer map entry for + ** iPtrPage. + */ + if libc.Int32FromUint8(eType) != int32(PTRMAP_ROOTPAGE) { + **(**int32)(__ccgo_up(bp + 8)) = _btreeGetPage(tls, pBt, iPtrPage, bp, 0) + if **(**int32)(__ccgo_up(bp + 8)) != SQLITE_OK { + return **(**int32)(__ccgo_up(bp + 8)) + } + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if **(**int32)(__ccgo_up(bp + 8)) != SQLITE_OK { + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + return **(**int32)(__ccgo_up(bp + 8)) + } + **(**int32)(__ccgo_up(bp + 8)) = _modifyPagePointer(tls, **(**uintptr)(__ccgo_up(bp)), iDbPage, iFreePage, eType) + _releasePage(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + _ptrmapPut(tls, pBt, iFreePage, eType, iPtrPage, bp+8) + } + } + return **(**int32)(__ccgo_up(bp + 8)) +} + +// C documentation +// +// /* +// ** pX is an expression of the form: (vector) IN (SELECT ...) +// ** In other words, it is a vector IN operator with a SELECT clause on the +// ** RHS. But not all terms in the vector are indexable and the terms might +// ** not be in the correct order for indexing. +// ** +// ** This routine makes a copy of the input pX expression and then adjusts +// ** the vector on the LHS with corresponding changes to the SELECT so that +// ** the vector contains only index terms and those terms are in the correct +// ** order. The modified IN expression is returned. The caller is responsible +// ** for deleting the returned expression. +// ** +// ** Example: +// ** +// ** CREATE TABLE t1(a,b,c,d,e,f); +// ** CREATE INDEX t1x1 ON t1(e,c); +// ** SELECT * FROM t1 WHERE (a,b,c,d,e) IN (SELECT v,w,x,y,z FROM t2) +// ** \_______________________________________/ +// ** The pX expression +// ** +// ** Since only columns e and c can be used with the index, in that order, +// ** the modified IN expression that is returned will be: +// ** +// ** (e,c) IN (SELECT z,x FROM t2) +// ** +// ** The reduced pX is different from the original (obviously) and thus is +// ** only used for indexing, to improve performance. The original unaltered +// ** IN expression must also be run on each output row for correctness. +// */ +func _removeUnindexableInClauseTerms(tls *libc.TLS, pParse uintptr, iEq int32, pLoop uintptr, pX uintptr) (r uintptr) { + var db, p, pLhs, pNew, pOrigLhs, pOrigRhs, pRhs, pSelect, v4 uintptr + var i, iField, v3 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iField, p, pLhs, pNew, pOrigLhs, pOrigRhs, pRhs, pSelect, v3, v4 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pNew = _sqlite3ExprDup(tls, db, pX, 0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + pSelect = *(*uintptr)(unsafe.Pointer(pNew + 32)) + for { + if !(pSelect != 0) { + break + } /* Original unmodified RHS */ + pOrigLhs = uintptr(0) /* Original unmodified LHS */ + pRhs = uintptr(0) /* New RHS after modifications */ + pLhs = uintptr(0) /* Loop counter */ + pOrigRhs = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + if pSelect == *(*uintptr)(unsafe.Pointer(pNew + 32)) { + pOrigLhs = *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pNew)).FpLeft + 32)) + } + i = iEq + for { + if !(i < libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm)) { + break + } + if (*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)))).FpExpr == pX { + iField = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)) + 32))).FiField - int32(1) + if (*(*TExprList_item)(unsafe.Pointer(pOrigRhs + 8 + uintptr(iField)*32))).FpExpr == uintptr(0) { + goto _2 /* Duplicate PK column */ + } + pRhs = _sqlite3ExprListAppend(tls, pParse, pRhs, (*(*TExprList_item)(unsafe.Pointer(pOrigRhs + 8 + uintptr(iField)*32))).FpExpr) + (*(*TExprList_item)(unsafe.Pointer(pOrigRhs + 8 + uintptr(iField)*32))).FpExpr = uintptr(0) + if pRhs != 0 { + *(*Tu16)(unsafe.Pointer(pRhs + 8 + uintptr((*TExprList)(unsafe.Pointer(pRhs)).FnExpr-int32(1))*32 + 24)) = libc.Uint16FromInt32(iField + int32(1)) + } + if pOrigLhs != 0 { + pLhs = _sqlite3ExprListAppend(tls, pParse, pLhs, (*(*TExprList_item)(unsafe.Pointer(pOrigLhs + 8 + uintptr(iField)*32))).FpExpr) + (*(*TExprList_item)(unsafe.Pointer(pOrigLhs + 8 + uintptr(iField)*32))).FpExpr = uintptr(0) + } + } + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3ExprListDelete(tls, db, pOrigRhs) + if pOrigLhs != 0 { + _sqlite3ExprListDelete(tls, db, pOrigLhs) + *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pNew)).FpLeft + 32)) = pLhs + } + (*TSelect)(unsafe.Pointer(pSelect)).FpEList = pRhs + v4 = pParse + 124 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 + v3 = *(*int32)(unsafe.Pointer(v4)) + (*TSelect)(unsafe.Pointer(pSelect)).FselId = libc.Uint32FromInt32(v3) /* Req'd for SubrtnSig validity */ + if pLhs != 0 && (*TExprList)(unsafe.Pointer(pLhs)).FnExpr == int32(1) { + /* Take care here not to generate a TK_VECTOR containing only a + ** single value. Since the parser never creates such a vector, some + ** of the subroutines do not handle this case. */ + p = (*(*TExprList_item)(unsafe.Pointer(pLhs + 8))).FpExpr + (*(*TExprList_item)(unsafe.Pointer(pLhs + 8))).FpExpr = uintptr(0) + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pNew)).FpLeft) + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = p + } + /* If either the ORDER BY clause or the GROUP BY clause contains + ** references to result-set columns, those references might now be + ** obsolete. So fix them up. + */ + if pRhs != 0 { + _adjustOrderByCol(tls, (*TSelect)(unsafe.Pointer(pSelect)).FpOrderBy, pRhs) + _adjustOrderByCol(tls, (*TSelect)(unsafe.Pointer(pSelect)).FpGroupBy, pRhs) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pRhs)).FnExpr) { + break + } + *(*Tu16)(unsafe.Pointer(pRhs + 8 + uintptr(i)*32 + 24)) = uint16(0) + goto _5 + _5: + ; + i = i + 1 + } + } + goto _1 + _1: + ; + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + } + return pNew +} + +// C documentation +// +// /* +// ** This is a Walker expression callback. +// ** +// ** For every TK_COLUMN node in the expression tree, search to see +// ** if the column being references is the column being renamed by an +// ** ALTER TABLE statement. If it is, then attach its associated +// ** RenameToken object to the list of RenameToken objects being +// ** constructed in RenameCtx object at pWalker->u.pRename. +// */ +func _renameColumnExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var p uintptr + _ = p + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_TRIGGER) && int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) == (*TRenameCtx)(unsafe.Pointer(p)).FiCol && (*TParse)(unsafe.Pointer((*TWalker)(unsafe.Pointer(pWalker)).FpParse)).FpTriggerTab == (*TRenameCtx)(unsafe.Pointer(p)).FpTab { + _renameTokenFind(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) && int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) == (*TRenameCtx)(unsafe.Pointer(p)).FiCol && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) && (*TRenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 64)) { + _renameTokenFind(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr) + } + } + return WRC_Continue +} + +func _renameQuotefixExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_STRING) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_DblQuoted) != 0 { + _renameTokenFind(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, *(*uintptr)(unsafe.Pointer(pWalker + 40)), pExpr) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Set all pEList->a[].fg.eEName fields in the expression-list to val. +// */ +func _renameSetENames(tls *libc.TLS, pEList uintptr, val int32) { + var i int32 + _ = i + if pEList != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + libc.SetBitFieldPtr16Uint32(pEList+8+uintptr(i)*32+16+4, libc.Uint32FromInt32(val&libc.Int32FromInt32(0x3)), 0, 0x3) + goto _1 + _1: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** Walker expression callback used by "RENAME TABLE". +// */ +func _renameTableExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var p uintptr + _ = p + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) && (*TRenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 64)) { + _renameTokenFind(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr+64) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Walker select callback used by "RENAME TABLE". +// */ +func _renameTableSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) { + var i int32 + var p, pItem, pSrc uintptr + _, _, _, _ = i, p, pItem, pSrc + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pSrc = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + if (*TSelect)(unsafe.Pointer(pSelect)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_View)|libc.Int32FromInt32(SF_CopyCte)) != 0 { + return int32(WRC_Prune) + } + if pSrc == uintptr(0) { + return int32(WRC_Abort) + } + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + pItem = pSrc + 8 + uintptr(i)*80 + if (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab == (*TRenameCtx)(unsafe.Pointer(p)).FpTab { + _renameTokenFind(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, p, (*TSrcItem)(unsafe.Pointer(pItem)).FzName) + } + goto _1 + _1: + ; + i = i + 1 + } + _renameWalkWith(tls, pWalker, pSelect) + return WRC_Continue +} + +// C documentation +// +// /* +// ** Walker callback used by sqlite3RenameExprUnmap(). +// */ +func _renameUnmapExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var pParse uintptr + _ = pParse + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr+64) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Walker callback used by sqlite3RenameExprUnmap(). +// */ +func _renameUnmapSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + var i int32 + var pList, pParse, pSrc uintptr + _, _, _, _ = i, pList, pParse, pSrc + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(WRC_Abort) + } + if (*TSelect)(unsafe.Pointer(p)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_View)|libc.Int32FromInt32(SF_CopyCte)) != 0 { + return int32(WRC_Prune) + } + if (*TSelect)(unsafe.Pointer(p)).FpEList != 0 { + pList = (*TSelect)(unsafe.Pointer(p)).FpEList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + if (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FzEName != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pList + 8 + uintptr(i)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FzEName) + } + goto _1 + _1: + ; + i = i + 1 + } + } + if (*TSelect)(unsafe.Pointer(p)).FpSrc != 0 { /* Every Select as a SrcList, even if it is empty */ + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FzName) + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 24 + 4))&0x800>>11) == 0 { + _sqlite3WalkExpr(tls, pWalker, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 64))) + } else { + _unmapColumnIdlistNames(tls, pParse, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 64))) + } + goto _2 + _2: + ; + i = i + 1 + } + } + _renameWalkWith(tls, pWalker, p) + return WRC_Continue +} + +// C documentation +// +// /* +// ** Expression walker callback used by renumberCursors() to update +// ** Expr objects to match newly assigned cursor numbers. +// */ +func _renumberCursorsCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var op int32 + _ = op + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + if op == int32(TK_COLUMN) || op == int32(TK_IF_NULL_ROW) { + _renumberCursorDoMapping(tls, pWalker, pExpr+44) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) { + _renumberCursorDoMapping(tls, pWalker, pExpr+52) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Resolve label "x" to be the address of the next instruction to +// ** be inserted. The parameter "x" must have been obtained from +// ** a prior call to sqlite3VdbeMakeLabel(). +// */ +func _resizeResolveLabel(tls *libc.TLS, p uintptr, v uintptr, j int32) { + var nNewSize int32 + _ = nNewSize + nNewSize = int32(10) - (*TParse)(unsafe.Pointer(p)).FnLabel + (*TParse)(unsafe.Pointer(p)).FaLabel = _sqlite3DbReallocOrFree(tls, (*TParse)(unsafe.Pointer(p)).Fdb, (*TParse)(unsafe.Pointer(p)).FaLabel, uint64(libc.Uint64FromInt32(nNewSize)*uint64(4))) + if (*TParse)(unsafe.Pointer(p)).FaLabel == uintptr(0) { + (*TParse)(unsafe.Pointer(p)).FnLabelAlloc = 0 + } else { + if nNewSize >= int32(100) && nNewSize/int32(100) > (*TParse)(unsafe.Pointer(p)).FnLabelAlloc/int32(100) { + _sqlite3ProgressCheck(tls, p) + } + (*TParse)(unsafe.Pointer(p)).FnLabelAlloc = nNewSize + **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(p)).FaLabel + uintptr(j)*4)) = (*TVdbe)(unsafe.Pointer(v)).FnOp + } +} + +// C documentation +// +// /* +// ** pEList is a list of expressions which are really the result set of the +// ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause. +// ** This routine checks to see if pE is a simple identifier which corresponds +// ** to the AS-name of one of the terms of the expression list. If it is, +// ** this routine return an integer between 1 and N where N is the number of +// ** elements in pEList, corresponding to the matching entry. If there is +// ** no match, or if pE is not a simple identifier, then this routine +// ** return 0. +// ** +// ** pEList has been resolved. pE has not. +// */ +func _resolveAsName(tls *libc.TLS, pParse uintptr, pEList uintptr, pE uintptr) (r int32) { + var i int32 + var zCol uintptr + _, _ = i, zCol /* Loop counter */ + _ = pParse + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE)).Fop) == int32(TK_ID) { + zCol = *(*uintptr)(unsafe.Pointer(pE + 8)) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME && Xsqlite3_stricmp(tls, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName, zCol) == 0 { + return i + int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + } + return 0 +} + +// C documentation +// +// /* +// ** This routine is called after all opcodes have been inserted. It loops +// ** through all the opcodes and fixes up some details. +// ** +// ** (1) For each jump instruction with a negative P2 value (a label) +// ** resolve the P2 value to an actual address. +// ** +// ** (2) Compute the maximum number of arguments used by the xUpdate/xFilter +// ** methods of any virtual table and store that value in *pMaxVtabArgs. +// ** +// ** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately +// ** indicate what the prepared statement actually does. +// ** +// ** (4) (discontinued) +// ** +// ** (5) Reclaim the memory allocated for storing labels. +// ** +// ** This routine will only function correctly if the mkopcodeh.tcl generator +// ** script numbers the opcodes correctly. Changes to this routine must be +// ** coordinated with changes to mkopcodeh.tcl. +// */ +func _resolveP2Values(tls *libc.TLS, p uintptr, pMaxVtabArgs uintptr) { + var aLabel, pOp, pParse uintptr + var n, nMaxVtabArgs int32 + _, _, _, _, _ = aLabel, n, nMaxVtabArgs, pOp, pParse + nMaxVtabArgs = **(**int32)(__ccgo_up(pMaxVtabArgs)) + pParse = (*TVdbe)(unsafe.Pointer(p)).FpParse + aLabel = (*TParse)(unsafe.Pointer(pParse)).FaLabel + /* tag-20230419-1 */ + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 6, 0x40) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 7, 0x80) + pOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr((*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1))*24 + for int32(1) != 0 { + /* Only JUMP opcodes and the short list of special opcodes in the switch + ** below need to be considered. The mkopcodeh.tcl generator script groups + ** all these opcodes together near the front of the opcode list. Skip + ** any opcode that does not need processing by virtual of the fact that + ** it is larger than SQLITE_MX_JUMP_OPCODE, as a performance optimization. + */ + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) <= int32(SQLITE_MX_JUMP_OPCODE) { + /* NOTE: Be sure to update mkopcodeh.tcl when adding or removing + ** cases from this switch! */ + switch libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) { + case int32(OP_Transaction): + if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 { + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 6, 0x40) + } + fallthrough + case int32(OP_AutoCommit): + fallthrough + case OP_Savepoint: + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 7, 0x80) + case int32(OP_Checkpoint): + fallthrough + case int32(OP_Vacuum): + fallthrough + case int32(OP_JournalMode): + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 6, 0x40) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 7, 0x80) + case int32(OP_Init): + goto resolve_p2_values_loop_exit + case int32(OP_VUpdate): + if (*TOp)(unsafe.Pointer(pOp)).Fp2 > nMaxVtabArgs { + nMaxVtabArgs = (*TOp)(unsafe.Pointer(pOp)).Fp2 + } + case int32(OP_VFilter): + /* The instruction immediately prior to VFilter will be an + ** OP_Integer that sets the "argc" value for the VFilter. See + ** the code where OP_VFilter is generated at tag-20250207a. */ + n = (**(**TOp)(__ccgo_up(pOp + uintptr(-libc.Int32FromInt32(1))*24))).Fp1 + if n > nMaxVtabArgs { + nMaxVtabArgs = n + } + /* Fall through into the default case */ + fallthrough + default: + if (*TOp)(unsafe.Pointer(pOp)).Fp2 < 0 { + /* The mkopcodeh.tcl script has so arranged things that the only + ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to + ** have non-negative values for P2. */ + /* True because of tag-20230419-1 */ + (*TOp)(unsafe.Pointer(pOp)).Fp2 = **(**int32)(__ccgo_up(aLabel + uintptr(^(*TOp)(unsafe.Pointer(pOp)).Fp2)*4)) + } + /* OPFLG_JUMP opcodes never have P2==0, though OPFLG_JUMP0 opcodes + ** might */ + /* Jumps never go off the end of the bytecode array */ + break + } + /* The mkopcodeh.tcl script has so arranged things that the only + ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to + ** have non-negative values for P2. */ + } + pOp -= 24 + } + goto resolve_p2_values_loop_exit +resolve_p2_values_loop_exit: + ; + if aLabel != 0 { + _sqlite3DbNNFreeNN(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, (*TParse)(unsafe.Pointer(pParse)).FaLabel) + (*TParse)(unsafe.Pointer(pParse)).FaLabel = uintptr(0) + } + (*TParse)(unsafe.Pointer(pParse)).FnLabel = 0 + **(**int32)(__ccgo_up(pMaxVtabArgs)) = nMaxVtabArgs +} + +// C documentation +// +// /* +// ** Walker callback for windowRemoveExprFromSelect(). +// */ +func _resolveRemoveWindowsCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var pWin uintptr + _ = pWin + _ = pWalker + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + pWin = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + _sqlite3WindowUnlinkFromSelect(tls, pWin) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Set the EP_SubtArg property on every expression inside of +// ** pList. If any subexpression is actually a subquery, then +// ** also set the EP_SubtArg property on the first result-set +// ** column of that subquery. +// */ +func _resolveSetExprSubtypeArg(tls *libc.TLS, pList uintptr) { + var ii, nn, v1 int32 + var pExpr uintptr + _, _, _, _ = ii, nn, pExpr, v1 + if pList != 0 { + v1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v1 = 0 + } + nn = v1 + ii = 0 + for { + if !(ii < nn) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromUint32(EP_SubtArg) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) { + _resolveSetExprSubtypeArg(tls, (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList) + } + goto _2 + _2: + ; + ii = ii + 1 + } +} + +// C documentation +// +// /* +// ** Allocate a new RowSetEntry object that is associated with the +// ** given RowSet. Return a pointer to the new and completely uninitialized +// ** object. +// ** +// ** In an OOM situation, the RowSet.db->mallocFailed flag is set and this +// ** routine returns NULL. +// */ +func _rowSetEntryAlloc(tls *libc.TLS, p uintptr) (r uintptr) { + var pNew, v1, v2 uintptr + _, _, _ = pNew, v1, v2 + if libc.Int32FromUint16((*TRowSet)(unsafe.Pointer(p)).FnFresh) == 0 { + pNew = _sqlite3DbMallocRawNN(tls, (*TRowSet)(unsafe.Pointer(p)).Fdb, uint64(1016)) + if pNew == uintptr(0) { + return uintptr(0) + } + (*TRowSetChunk)(unsafe.Pointer(pNew)).FpNextChunk = (*TRowSet)(unsafe.Pointer(p)).FpChunk + (*TRowSet)(unsafe.Pointer(p)).FpChunk = pNew + (*TRowSet)(unsafe.Pointer(p)).FpFresh = pNew + 8 + (*TRowSet)(unsafe.Pointer(p)).FnFresh = uint16(libc.Uint64FromInt32(libc.Int32FromInt32(ROWSET_ALLOCATION_SIZE)-libc.Int32FromInt32(8)) / libc.Uint64FromInt64(24)) + } + (*TRowSet)(unsafe.Pointer(p)).FnFresh = (*TRowSet)(unsafe.Pointer(p)).FnFresh - 1 + v2 = p + 32 + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) += 24 + return v1 +} + +// C documentation +// +// /* +// ** Rtree virtual table module xColumn method. +// */ +func _rtreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p, pCsr, pNode, pRtree uintptr + var _ /* c at bp+0 */ TRtreeCoord + var _ /* rc at bp+4 */ int32 + _, _, _, _ = p, pCsr, pNode, pRtree + pRtree = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab + pCsr = cur + p = _rtreeSearchPointFirst(tls, pCsr) + **(**int32)(__ccgo_up(bp + 4)) = SQLITE_OK + pNode = _rtreeNodeOfFirstSearchPoint(tls, pCsr, bp+4) + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + return **(**int32)(__ccgo_up(bp + 4)) + } + if p == uintptr(0) { + return SQLITE_OK + } + if libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell) >= _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) { + return int32(SQLITE_ABORT) + } + if i == 0 { + Xsqlite3_result_int64(tls, ctx, _nodeGetRowid(tls, pRtree, pNode, libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) + } else { + if i <= libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) { + _nodeGetCoord(tls, pRtree, pNode, libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell), i-int32(1), bp) + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + Xsqlite3_result_double(tls, ctx, float64(*(*TRtreeValue)(unsafe.Pointer(bp)))) + } else { + Xsqlite3_result_int(tls, ctx, *(*int32)(unsafe.Pointer(bp))) + } + } else { + if !((*TRtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid != 0) { + if (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux == uintptr(0) { + **(**int32)(__ccgo_up(bp + 4)) = Xsqlite3_prepare_v3(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, (*TRtree)(unsafe.Pointer(pRtree)).FzReadAuxSql, -int32(1), uint32(0), pCsr+56, uintptr(0)) + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + return **(**int32)(__ccgo_up(bp + 4)) + } + } + Xsqlite3_bind_int64(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, int32(1), _nodeGetRowid(tls, pRtree, pNode, libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) + **(**int32)(__ccgo_up(bp + 4)) = Xsqlite3_step(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) + if **(**int32)(__ccgo_up(bp + 4)) == int32(SQLITE_ROW) { + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = uint8(1) + } else { + Xsqlite3_reset(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) + if **(**int32)(__ccgo_up(bp + 4)) == int32(SQLITE_DONE) { + **(**int32)(__ccgo_up(bp + 4)) = SQLITE_OK + } + return **(**int32)(__ccgo_up(bp + 4)) + } + } + Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, i-libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)+int32(1))) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Push a new element onto the priority queue +// */ +func _rtreeEnqueue(tls *libc.TLS, pCur uintptr, rScore TRtreeDValue, iLevel Tu8) (r uintptr) { + var i, j, nNew, v1 int32 + var pNew, pParent, v2 uintptr + _, _, _, _, _, _, _ = i, j, nNew, pNew, pParent, v1, v2 + if (*TRtreeCursor)(unsafe.Pointer(pCur)).FnPoint >= (*TRtreeCursor)(unsafe.Pointer(pCur)).FnPointAlloc { + nNew = (*TRtreeCursor)(unsafe.Pointer(pCur)).FnPointAlloc*int32(2) + int32(8) + pNew = Xsqlite3_realloc64(tls, (*TRtreeCursor)(unsafe.Pointer(pCur)).FaPoint, uint64(libc.Uint64FromInt32(nNew)*uint64(24))) + if pNew == uintptr(0) { + return uintptr(0) + } + (*TRtreeCursor)(unsafe.Pointer(pCur)).FaPoint = pNew + (*TRtreeCursor)(unsafe.Pointer(pCur)).FnPointAlloc = nNew + } + v2 = pCur + 36 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + i = v1 + pNew = (*TRtreeCursor)(unsafe.Pointer(pCur)).FaPoint + uintptr(i)*24 + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FrScore = rScore + (*TRtreeSearchPoint)(unsafe.Pointer(pNew)).FiLevel = iLevel + for i > 0 { + j = (i - int32(1)) / int32(2) + pParent = (*TRtreeCursor)(unsafe.Pointer(pCur)).FaPoint + uintptr(j)*24 + if _rtreeSearchPointCompare(tls, pNew, pParent) >= 0 { + break + } + _rtreeSearchPointSwap(tls, pCur, j, i) + i = j + pNew = pParent + } + return pNew +} + +// C documentation +// +// /* +// ** Get the RtreeNode for the search point with the lowest score. +// */ +func _rtreeNodeOfFirstSearchPoint(tls *libc.TLS, pCur uintptr, pRC uintptr) (r uintptr) { + var id Tsqlite3_int64 + var ii int32 + var v1 int64 + _, _, _ = id, ii, v1 + ii = int32(1) - libc.Int32FromUint8((*TRtreeCursor)(unsafe.Pointer(pCur)).FbPoint) + if **(**uintptr)(__ccgo_up(pCur + 88 + uintptr(ii)*8)) == uintptr(0) { + if ii != 0 { + v1 = (**(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(pCur)).FaPoint))).Fid + } else { + v1 = (*TRtreeCursor)(unsafe.Pointer(pCur)).FsPoint.Fid + } + id = v1 + **(**int32)(__ccgo_up(pRC)) = _nodeAcquire(tls, (*TRtreeCursor)(unsafe.Pointer(pCur)).Fbase.FpVtab, id, uintptr(0), pCur+88+uintptr(ii)*8) + } + return **(**uintptr)(__ccgo_up(pCur + 88 + uintptr(ii)*8)) +} + +// C documentation +// +// /* +// ** Allocate a new RtreeSearchPoint and return a pointer to it. Return +// ** NULL if malloc fails. +// */ +func _rtreeSearchPointNew(tls *libc.TLS, pCur uintptr, rScore TRtreeDValue, iLevel Tu8) (r uintptr) { + var ii int32 + var pFirst, pNew uintptr + _, _, _ = ii, pFirst, pNew + pFirst = _rtreeSearchPointFirst(tls, pCur) + **(**Tu32)(__ccgo_up(pCur + 128 + uintptr(iLevel)*4)) = **(**Tu32)(__ccgo_up(pCur + 128 + uintptr(iLevel)*4)) + 1 + if pFirst == uintptr(0) || (*TRtreeSearchPoint)(unsafe.Pointer(pFirst)).FrScore > rScore || (*TRtreeSearchPoint)(unsafe.Pointer(pFirst)).FrScore == rScore && libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(pFirst)).FiLevel) > libc.Int32FromUint8(iLevel) { + if (*TRtreeCursor)(unsafe.Pointer(pCur)).FbPoint != 0 { + pNew = _rtreeEnqueue(tls, pCur, rScore, iLevel) + if pNew == uintptr(0) { + return uintptr(0) + } + ii = int32((int64(pNew)-int64((*TRtreeCursor)(unsafe.Pointer(pCur)).FaPoint))/24) + int32(1) + if ii < int32(RTREE_CACHE_SZ) { + **(**uintptr)(__ccgo_up(pCur + 88 + uintptr(ii)*8)) = **(**uintptr)(__ccgo_up(pCur + 88)) + } else { + _nodeRelease(tls, (*TRtreeCursor)(unsafe.Pointer(pCur)).Fbase.FpVtab, **(**uintptr)(__ccgo_up(pCur + 88))) + } + **(**uintptr)(__ccgo_up(pCur + 88)) = uintptr(0) + **(**TRtreeSearchPoint)(__ccgo_up(pNew)) = (*TRtreeCursor)(unsafe.Pointer(pCur)).FsPoint + } + (*TRtreeCursor)(unsafe.Pointer(pCur)).FsPoint.FrScore = rScore + (*TRtreeCursor)(unsafe.Pointer(pCur)).FsPoint.FiLevel = iLevel + (*TRtreeCursor)(unsafe.Pointer(pCur)).FbPoint = uint8(1) + return pCur + 64 + } else { + return _rtreeEnqueue(tls, pCur, rScore, iLevel) + } + return r +} + +// C documentation +// +// /* Remove the search point with the lowest current score. +// */ +func _rtreeSearchPointPop(tls *libc.TLS, p uintptr) { + var i, j, k, n, v1 int32 + var v2 uintptr + _, _, _, _, _, _ = i, j, k, n, v1, v2 + i = int32(1) - libc.Int32FromUint8((*TRtreeCursor)(unsafe.Pointer(p)).FbPoint) + if **(**uintptr)(__ccgo_up(p + 88 + uintptr(i)*8)) != 0 { + _nodeRelease(tls, (*TRtreeCursor)(unsafe.Pointer(p)).Fbase.FpVtab, **(**uintptr)(__ccgo_up(p + 88 + uintptr(i)*8))) + **(**uintptr)(__ccgo_up(p + 88 + uintptr(i)*8)) = uintptr(0) + } + if (*TRtreeCursor)(unsafe.Pointer(p)).FbPoint != 0 { + **(**Tu32)(__ccgo_up(p + 128 + uintptr((*TRtreeCursor)(unsafe.Pointer(p)).FsPoint.FiLevel)*4)) = **(**Tu32)(__ccgo_up(p + 128 + uintptr((*TRtreeCursor)(unsafe.Pointer(p)).FsPoint.FiLevel)*4)) - 1 + (*TRtreeCursor)(unsafe.Pointer(p)).FbPoint = uint8(0) + } else { + if (*TRtreeCursor)(unsafe.Pointer(p)).FnPoint != 0 { + **(**Tu32)(__ccgo_up(p + 128 + uintptr((**(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(p)).FaPoint))).FiLevel)*4)) = **(**Tu32)(__ccgo_up(p + 128 + uintptr((**(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(p)).FaPoint))).FiLevel)*4)) - 1 + v2 = p + 36 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + n = v1 + **(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(p)).FaPoint)) = **(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(n)*24)) + if n < libc.Int32FromInt32(RTREE_CACHE_SZ)-libc.Int32FromInt32(1) { + **(**uintptr)(__ccgo_up(p + 88 + 1*8)) = **(**uintptr)(__ccgo_up(p + 88 + uintptr(n+int32(1))*8)) + **(**uintptr)(__ccgo_up(p + 88 + uintptr(n+int32(1))*8)) = uintptr(0) + } + i = 0 + for { + v1 = i*libc.Int32FromInt32(2) + libc.Int32FromInt32(1) + j = v1 + if !(v1 < n) { + break + } + k = j + int32(1) + if k < n && _rtreeSearchPointCompare(tls, (*TRtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(k)*24, (*TRtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(j)*24) < 0 { + if _rtreeSearchPointCompare(tls, (*TRtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(k)*24, (*TRtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(i)*24) < 0 { + _rtreeSearchPointSwap(tls, p, i, k) + i = k + } else { + break + } + } else { + if _rtreeSearchPointCompare(tls, (*TRtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(j)*24, (*TRtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(i)*24) < 0 { + _rtreeSearchPointSwap(tls, p, i, j) + i = j + } else { + break + } + } + } + } + } +} + +// C documentation +// +// /* +// ** Check schema cookies in all databases. If any cookie is out +// ** of date set pParse->rc to SQLITE_SCHEMA. If all schema cookies +// ** make no changes to pParse->rc. +// */ +func _schemaIsValid(tls *libc.TLS, pParse uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pBt uintptr + var iDb, openedTransaction, rc int32 + var _ /* cookie at bp+0 */ int32 + _, _, _, _, _ = db, iDb, openedTransaction, pBt, rc + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + iDb = 0 + for { + if !(iDb < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + openedTransaction = 0 /* True if a transaction is opened */ + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt /* Btree database to read cookie from */ + if pBt == uintptr(0) { + goto _1 + } + /* If there is not already a read-only (or read-write) transaction opened + ** on the b-tree database, open one now. If a transaction is opened, it + ** will be closed immediately after reading the meta-value. */ + if _sqlite3BtreeTxnState(tls, pBt) == SQLITE_TXN_NONE { + rc = _sqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) + if rc == int32(SQLITE_NOMEM) || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<offset then read cnt bytes into pBuf. +// ** Return the number of bytes actually read. Update the offset. +// ** +// ** To avoid stomping the errno value on a failed write the lastErrno value +// ** is set before returning. +// */ +func _seekAndWrite(tls *libc.TLS, id uintptr, offset Ti64, pBuf uintptr, cnt int32) (r int32) { + return _seekAndWriteFd(tls, (*TunixFile)(unsafe.Pointer(id)).Fh, offset, pBuf, cnt, id+32) +} + +// C documentation +// +// /* +// ** Walker SELECT callbacks for sqlite3ReferencesSrcList(). +// ** +// ** When entering a new subquery on the pExpr argument, add all FROM clause +// ** entries for that subquery to the exclude list. +// ** +// ** When leaving the subquery, remove those entries from the exclude list. +// */ +func _selectRefEnter(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) { + var i, j Ti64 + var p, pSrc, piNew uintptr + _, _, _, _, _ = i, j, p, pSrc, piNew + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pSrc = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + if (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc == 0 { + return WRC_Continue + } + j = (*TRefSrcList)(unsafe.Pointer(p)).FnExclude + **(**Ti64)(__ccgo_up(p + 16)) += int64((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) + piNew = _sqlite3DbRealloc(tls, (*TRefSrcList)(unsafe.Pointer(p)).Fdb, (*TRefSrcList)(unsafe.Pointer(p)).FaiExclude, libc.Uint64FromInt64((*TRefSrcList)(unsafe.Pointer(p)).FnExclude)*uint64(4)) + if piNew == uintptr(0) { + (*TRefSrcList)(unsafe.Pointer(p)).FnExclude = 0 + return int32(WRC_Abort) + } else { + (*TRefSrcList)(unsafe.Pointer(p)).FaiExclude = piNew + } + i = 0 + for { + if !(i < int64((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc)) { + break + } + **(**int32)(__ccgo_up((*TRefSrcList)(unsafe.Pointer(p)).FaiExclude + uintptr(j)*4)) = (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FiCursor + goto _1 + _1: + ; + i = i + 1 + j = j + 1 + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Append a DELETE change to the buffer passed as the first argument. Use +// ** the changeset format if argument bPatchset is zero, or the patchset +// ** format otherwise. +// */ +func _sessionAppendDelete(tls *libc.TLS, pBuf uintptr, bPatchset int32, p uintptr, nCol int32, abPK uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, pStart, v2 uintptr + var eType, i int32 + var _ /* n at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _ = a, eType, i, pStart, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + _sessionAppendByte(tls, pBuf, uint8(SQLITE_DELETE), bp) + _sessionAppendByte(tls, pBuf, (*TSessionChange)(unsafe.Pointer(p)).FbIndirect, bp) + if bPatchset == 0 { + _sessionAppendBlob(tls, pBuf, (*TSessionChange)(unsafe.Pointer(p)).FaRecord, (*TSessionChange)(unsafe.Pointer(p)).FnRecord, bp) + } else { + a = (*TSessionChange)(unsafe.Pointer(p)).FaRecord + i = 0 + for { + if !(i < nCol) { + break + } + pStart = a + v2 = a + a = a + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v2))) + switch eType { + case 0: + fallthrough + case int32(SQLITE_NULL): + case int32(SQLITE_FLOAT): + fallthrough + case int32(SQLITE_INTEGER): + a = a + uintptr(8) + default: + a = a + uintptr(_sessionVarintGet(tls, a, bp+4)) + a = a + uintptr(**(**int32)(__ccgo_up(bp + 4))) + break + } + if **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 { + _sessionAppendBlob(tls, pBuf, pStart, int32(int64(a)-int64(pStart)), bp) + } + goto _1 + _1: + ; + i = i + 1 + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is set to other than SQLITE_OK when it +// ** is called. Otherwise, append a serialized table header (part of the binary +// ** changeset format) to buffer *pBuf. If an error occurs, set *pRc to an +// ** SQLite error code before returning. +// */ +func _sessionAppendTableHdr(tls *libc.TLS, pBuf uintptr, bPatchset int32, pTab uintptr, pRc uintptr) { + var v1 int32 + _ = v1 + /* Write a table header */ + if bPatchset != 0 { + v1 = int32('P') + } else { + v1 = int32('T') + } + _sessionAppendByte(tls, pBuf, libc.Uint8FromInt32(v1), pRc) + _sessionAppendVarint(tls, pBuf, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, pRc) + _sessionAppendBlob(tls, pBuf, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, pRc) + _sessionAppendBlob(tls, pBuf, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, libc.Int32FromUint64(libc.Xstrlen(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FzName))+int32(1), pRc) +} + +// C documentation +// +// /* +// ** Arguments aLeft and aRight are pointers to change records for table pTab. +// ** This function returns true if the two records apply to the same row (i.e. +// ** have the same values stored in the primary key columns), or false +// ** otherwise. +// */ +func _sessionChangeEqual(tls *libc.TLS, pTab uintptr, bLeftPkOnly int32, aLeft uintptr, bRightPkOnly int32, aRight uintptr) (r int32) { + var a1, a2 uintptr + var iCol, n1, n2 int32 + _, _, _, _, _ = a1, a2, iCol, n1, n2 + a1 = aLeft /* Cursor to iterate through aLeft */ + a2 = aRight /* Used to iterate through table columns */ + iCol = 0 + for { + if !(iCol < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if **(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(iCol))) != 0 { + n1 = _sessionSerialLen(tls, a1) + n2 = _sessionSerialLen(tls, a2) + if n1 != n2 || libc.Xmemcmp(tls, a1, a2, libc.Uint64FromInt32(n1)) != 0 { + return 0 + } + a1 = a1 + uintptr(n1) + a2 = a2 + uintptr(n2) + } else { + if bLeftPkOnly == 0 { + a1 = a1 + uintptr(_sessionSerialLen(tls, a1)) + } + if bRightPkOnly == 0 { + a2 = a2 + uintptr(_sessionSerialLen(tls, a2)) + } + } + goto _1 + _1: + ; + iCol = iCol + 1 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Check if a changeset entry with nCol columns and the PK array passed +// ** as the final argument to this function is compatible with SessionTable +// ** pTab. If so, return 1. Otherwise, if they are incompatible in some way, +// ** return 0. +// */ +func _sessionChangesetCheckCompat(tls *libc.TLS, pTab uintptr, nCol int32, abPK uintptr) (r int32) { + var bPK Tu8 + var ii, v2 int32 + _, _, _ = bPK, ii, v2 + if (*TSessionTable)(unsafe.Pointer(pTab)).FazCol != 0 && nCol < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol { + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + if ii < nCol { + v2 = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(abPK + uintptr(ii)))) + } else { + v2 = 0 + } + bPK = libc.Uint8FromInt32(v2) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(ii)))) != libc.Int32FromUint8(bPK) { + return 0 + } + goto _1 + _1: + ; + ii = ii + 1 + } + return int32(1) + } + return libc.BoolInt32((*TSessionTable)(unsafe.Pointer(pTab)).FnCol == nCol && 0 == libc.Xmemcmp(tls, abPK, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK, libc.Uint64FromInt32(nCol))) +} + +func _sessionChangesetExtendRecord(tls *libc.TLS, pGrp uintptr, pTab uintptr, nCol int32, op int32, aRec uintptr, nRec int32, pOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType, iOff, ii, n int32 + var iVal Tsqlite3_int64 + var rVal float64 + var z, z1 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _ = eType, iOff, iVal, ii, n, rVal, z, z1 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + ii = 0 + (*TSessionBuffer)(unsafe.Pointer(pOut)).FnBuf = 0 + if op == int32(SQLITE_INSERT) || op == int32(SQLITE_DELETE) && (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch == 0 { + /* Append the missing default column values to the record. */ + _sessionAppendBlob(tls, pOut, aRec, nRec, bp) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = _sessionPrepareDfltStmt(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb, pTab, pTab+80) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && int32(SQLITE_ROW) != Xsqlite3_step(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt) { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_errcode(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb) + } + } + ii = nCol + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + eType = Xsqlite3_column_type(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt, ii) + _sessionAppendByte(tls, pOut, libc.Uint8FromInt32(eType), bp) + switch eType { + case int32(SQLITE_FLOAT): + fallthrough + case int32(SQLITE_INTEGER): + if SQLITE_OK == _sessionBufferGrow(tls, pOut, int64(8), bp) { + if eType == int32(SQLITE_INTEGER) { + iVal = Xsqlite3_column_int64(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt, ii) + _sessionPutI64(tls, (*TSessionBuffer)(unsafe.Pointer(pOut)).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(pOut)).FnBuf), iVal) + } else { + rVal = Xsqlite3_column_double(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt, ii) + _sessionPutDouble(tls, (*TSessionBuffer)(unsafe.Pointer(pOut)).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(pOut)).FnBuf), rVal) + } + **(**int32)(__ccgo_up(pOut + 8)) += int32(8) + } + case int32(SQLITE_BLOB): + fallthrough + case int32(SQLITE_TEXT): + n = Xsqlite3_column_bytes(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt, ii) + _sessionAppendVarint(tls, pOut, n, bp) + if eType == int32(SQLITE_TEXT) { + z = Xsqlite3_column_text(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt, ii) + _sessionAppendBlob(tls, pOut, z, n, bp) + } else { + z1 = Xsqlite3_column_blob(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt, ii) + _sessionAppendBlob(tls, pOut, z1, n, bp) + } + default: + break + } + goto _1 + _1: + ; + ii = ii + 1 + } + } else { + if op == int32(SQLITE_UPDATE) { + /* Append missing "undefined" entries to the old.* record. And, if this + ** is an UPDATE, to the new.* record as well. */ + iOff = 0 + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch == 0 { + ii = 0 + for { + if !(ii < nCol) { + break + } + iOff = iOff + _sessionSerialLen(tls, aRec+uintptr(iOff)) + goto _2 + _2: + ; + ii = ii + 1 + } + _sessionAppendBlob(tls, pOut, aRec, iOff, bp) + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol-nCol) { + break + } + _sessionAppendByte(tls, pOut, uint8(0x00), bp) + goto _3 + _3: + ; + ii = ii + 1 + } + } + _sessionAppendBlob(tls, pOut, aRec+uintptr(iOff), nRec-iOff, bp) + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol-nCol) { + break + } + _sessionAppendByte(tls, pOut, uint8(0x00), bp) + goto _4 + _4: + ; + ii = ii + 1 + } + } else { + _sessionAppendBlob(tls, pOut, aRec, nRec, bp) + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Invoke the conflict handler for the change that the changeset iterator +// ** currently points to. +// ** +// ** Argument eType must be either CHANGESET_DATA or CHANGESET_CONFLICT. +// ** If argument pbReplace is NULL, then the type of conflict handler invoked +// ** depends solely on eType, as follows: +// ** +// ** eType value Value passed to xConflict +// ** ------------------------------------------------- +// ** CHANGESET_DATA CHANGESET_NOTFOUND +// ** CHANGESET_CONFLICT CHANGESET_CONSTRAINT +// ** +// ** Or, if pbReplace is not NULL, then an attempt is made to find an existing +// ** record with the same primary key as the record about to be deleted, updated +// ** or inserted. If such a record can be found, it is available to the conflict +// ** handler as the "conflicting" record. In this case the type of conflict +// ** handler invoked is as follows: +// ** +// ** eType value PK Record found? Value passed to xConflict +// ** ---------------------------------------------------------------- +// ** CHANGESET_DATA Yes CHANGESET_DATA +// ** CHANGESET_DATA No CHANGESET_NOTFOUND +// ** CHANGESET_CONFLICT Yes CHANGESET_CONFLICT +// ** CHANGESET_CONFLICT No CHANGESET_CONSTRAINT +// ** +// ** If pbReplace is not NULL, and a record with a matching PK is found, and +// ** the conflict handler function returns SQLITE_CHANGESET_REPLACE, *pbReplace +// ** is set to non-zero before returning SQLITE_OK. +// ** +// ** If the conflict handler returns SQLITE_CHANGESET_ABORT, SQLITE_ABORT is +// ** returned. Or, if the conflict handler returns an invalid value, +// ** SQLITE_MISUSE. If the conflict handler returns SQLITE_CHANGESET_OMIT, +// ** this function returns SQLITE_OK. +// */ +func _sessionConflictHandler(tls *libc.TLS, eType int32, p uintptr, pIter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, pbReplace uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aBlob uintptr + var nBlob, res int32 + var _ /* nCol at bp+4 */ int32 + var _ /* op at bp+8 */ int32 + var _ /* rc at bp+0 */ int32 + var _ /* zDummy at bp+16 */ uintptr + _, _, _ = aBlob, nBlob, res + res = SQLITE_CHANGESET_OMIT + Xsqlite3changeset_op(tls, pIter, bp+16, bp+4, bp+8, uintptr(0)) + /* Bind the new.* PRIMARY KEY values to the SELECT statement. */ + if pbReplace != 0 { + **(**int32)(__ccgo_up(bp)) = _sessionSeekToRow(tls, pIter, p) + } else { + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + } + if **(**int32)(__ccgo_up(bp)) == int32(SQLITE_ROW) { + /* There exists another row with the new.* primary key. */ + if 0 == libc.Int32FromUint8((*TSessionApplyCtx)(unsafe.Pointer(p)).FbIgnoreNoop) || 0 == Xsqlite3_column_int(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpSelect, Xsqlite3_column_count(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpSelect)-int32(1)) { + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict = (*TSessionApplyCtx)(unsafe.Pointer(p)).FpSelect + res = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xConflict})))(tls, pCtx, eType, pIter) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict = uintptr(0) + } + **(**int32)(__ccgo_up(bp)) = Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpSelect) + } else { + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FbDeferConstraints != 0 && eType == int32(SQLITE_CHANGESET_CONFLICT) { + /* Instead of invoking the conflict handler, append the change blob + ** to the SessionApplyCtx.constraints buffer. */ + aBlob = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FaData + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiCurrent) + nBlob = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiNext - (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiCurrent + _sessionAppendBlob(tls, p+88, aBlob, nBlob, bp) + return **(**int32)(__ccgo_up(bp)) + } else { + if libc.Int32FromUint8((*TSessionApplyCtx)(unsafe.Pointer(p)).FbIgnoreNoop) == 0 || **(**int32)(__ccgo_up(bp + 8)) != int32(SQLITE_DELETE) || eType == int32(SQLITE_CHANGESET_CONFLICT) { + /* No other row with the new.* primary key. */ + res = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xConflict})))(tls, pCtx, eType+int32(1), pIter) + if res == int32(SQLITE_CHANGESET_REPLACE) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_MISUSE) + } + } + } + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + switch res { + case int32(SQLITE_CHANGESET_REPLACE): + **(**int32)(__ccgo_up(pbReplace)) = int32(1) + case SQLITE_CHANGESET_OMIT: + case int32(SQLITE_CHANGESET_ABORT): + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ABORT) + default: + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_MISUSE) + break + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionRebaseAdd(tls, p, res, pIter) + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Allocate and return a pointer to a buffer nByte bytes in size. If +// ** pSession is not NULL, increase the sqlite3_session.nMalloc variable +// ** by the number of bytes allocated. +// */ +func _sessionMalloc64(tls *libc.TLS, pSession uintptr, nByte Ti64) (r uintptr) { + var pRet, v1 uintptr + _, _ = pRet, v1 + pRet = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(nByte)) + if pSession != 0 { + v1 = pSession + 56 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + Xsqlite3_msize(tls, pRet)) + } + return pRet +} + +// C documentation +// +// /* +// ** Add a single change to the changegroup pGrp. +// */ +func _sessionOneChangeToHash(tls *libc.TLS, pGrp uintptr, pTab uintptr, op int32, bIndirect int32, nCol int32, aRec uintptr, nRec int32, bRebase int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bPkOnly1, bPkOnly2, iHash, rc int32 + var pBuf, pExist, pp uintptr + var _ /* pChange at bp+0 */ uintptr + _, _, _, _, _, _, _ = bPkOnly1, bPkOnly2, iHash, pBuf, pExist, pp, rc + rc = SQLITE_OK + iHash = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pExist = uintptr(0) + pp = uintptr(0) + if nCol < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol { + pBuf = pGrp + 16 + rc = _sessionChangesetExtendRecord(tls, pGrp, pTab, nCol, op, aRec, nRec, pBuf) + aRec = (*TSessionBuffer)(unsafe.Pointer(pBuf)).FaBuf + nRec = (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf + } + if rc == SQLITE_OK && _sessionGrowHash(tls, uintptr(0), (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch, pTab) != 0 { + rc = int32(SQLITE_NOMEM) + } + if rc == SQLITE_OK { + /* Search for existing entry. If found, remove it from the hash table. + ** Code below may link it back in. */ + iHash = libc.Int32FromUint32(_sessionChangeHash(tls, pTab, libc.BoolInt32((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch != 0 && op == int32(SQLITE_DELETE)), aRec, (*TSessionTable)(unsafe.Pointer(pTab)).FnChange)) + pp = (*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*8 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + bPkOnly1 = 0 + bPkOnly2 = 0 + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch != 0 { + bPkOnly1 = libc.BoolInt32(libc.Int32FromUint8((*TSessionChange)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).Fop) == int32(SQLITE_DELETE)) + bPkOnly2 = libc.BoolInt32(op == int32(SQLITE_DELETE)) + } + if _sessionChangeEqual(tls, pTab, bPkOnly1, (*TSessionChange)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FaRecord, bPkOnly2, aRec) != 0 { + pExist = **(**uintptr)(__ccgo_up(pp)) + **(**uintptr)(__ccgo_up(pp)) = (*TSessionChange)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpNext + (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry = (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry - 1 + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 24 + } + } + if rc == SQLITE_OK { + rc = _sessionChangeMerge(tls, pTab, bRebase, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch, pExist, op, bIndirect, aRec, nRec, bp) + } + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp)) != 0 { + (*TSessionChange)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpNext = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*8)) + **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*8)) = **(**uintptr)(__ccgo_up(bp)) + (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry = (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry + 1 + } + return rc +} + +// C documentation +// +// /* +// ** This function is called from within sqlite3changeset_apply_v2() when +// ** a conflict is encountered and resolved using conflict resolution +// ** mode eType (either SQLITE_CHANGESET_OMIT or SQLITE_CHANGESET_REPLACE).. +// ** It adds a conflict resolution record to the buffer in +// ** SessionApplyCtx.rebase, which will eventually be returned to the caller +// ** of apply_v2() as the "rebase" buffer. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code otherwise. +// */ +func _sessionRebaseAdd(tls *libc.TLS, p uintptr, eType int32, pIter uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eOp, i, v1 int32 + var zTab uintptr + var _ /* pVal at bp+8 */ uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _ = eOp, i, zTab, v1 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FbRebase != 0 { + eOp = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop + if libc.Int32FromUint8((*TSessionApplyCtx)(unsafe.Pointer(p)).FbRebaseStarted) == 0 { + /* Append a table-header to the rebase buffer */ + zTab = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab + _sessionAppendByte(tls, p+104, uint8('T'), bp) + _sessionAppendVarint(tls, p+104, (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol, bp) + _sessionAppendBlob(tls, p+104, (*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK, (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol, bp) + _sessionAppendBlob(tls, p+104, zTab, libc.Int32FromUint64(libc.Xstrlen(tls, zTab))+int32(1), bp) + (*TSessionApplyCtx)(unsafe.Pointer(p)).FbRebaseStarted = uint8(1) + } + if eOp == int32(SQLITE_DELETE) { + v1 = int32(SQLITE_DELETE) + } else { + v1 = int32(SQLITE_INSERT) + } + _sessionAppendByte(tls, p+104, libc.Uint8FromInt32(v1), bp) + _sessionAppendByte(tls, p+104, libc.BoolUint8(eType == libc.Int32FromInt32(SQLITE_CHANGESET_REPLACE)), bp) + i = 0 + for { + if !(i < (*TSessionApplyCtx)(unsafe.Pointer(p)).FnCol) { + break + } + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + if eOp == int32(SQLITE_DELETE) || eOp == int32(SQLITE_UPDATE) && **(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 { + Xsqlite3changeset_old(tls, pIter, i, bp+8) + } else { + Xsqlite3changeset_new(tls, pIter, i, bp+8) + } + _sessionAppendValue(tls, p+104, **(**uintptr)(__ccgo_up(bp + 8)), bp) + goto _2 + _2: + ; + i = i + 1 + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Re-initialize table object pTab. +// */ +func _sessionReinitTable(tls *libc.TLS, pSession uintptr, pTab uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var a, v1 uintptr + var ii, nOldCol int32 + var _ /* abPK at bp+32 */ uintptr + var _ /* aiIdx at bp+24 */ uintptr + var _ /* azCol at bp+8 */ uintptr + var _ /* azDflt at bp+16 */ uintptr + var _ /* bRowid at bp+40 */ int32 + var _ /* nCol at bp+0 */ int32 + var _ /* nTotalCol at bp+4 */ int32 + _, _, _, _ = a, ii, nOldCol, v1 + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 40)) = 0 + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK != 0 { + v1 = bp + 40 + } else { + v1 = uintptr(0) + } + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = _sessionTableInfo(tls, pSession, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, bp, bp+4, uintptr(0), bp+8, bp+16, bp+24, bp+32, v1) + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc == SQLITE_OK { + if (*TSessionTable)(unsafe.Pointer(pTab)).FnCol > **(**int32)(__ccgo_up(bp)) || (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != **(**int32)(__ccgo_up(bp + 40)) { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = int32(SQLITE_SCHEMA) + } else { + nOldCol = (*TSessionTable)(unsafe.Pointer(pTab)).FnCol + ii = 0 + for { + if !(ii < **(**int32)(__ccgo_up(bp))) { + break + } + if ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(ii)))) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)) + uintptr(ii)))) { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = int32(SQLITE_SCHEMA) + } + } else { + if **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)) + uintptr(ii))) != 0 { + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = int32(SQLITE_SCHEMA) + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc == SQLITE_OK { + a = (*TSessionTable)(unsafe.Pointer(pTab)).FazCol + (*TSessionTable)(unsafe.Pointer(pTab)).FazCol = **(**uintptr)(__ccgo_up(bp + 8)) + (*TSessionTable)(unsafe.Pointer(pTab)).FnCol = **(**int32)(__ccgo_up(bp)) + (*TSessionTable)(unsafe.Pointer(pTab)).FnTotalCol = **(**int32)(__ccgo_up(bp + 4)) + (*TSessionTable)(unsafe.Pointer(pTab)).FazDflt = **(**uintptr)(__ccgo_up(bp + 16)) + (*TSessionTable)(unsafe.Pointer(pTab)).FabPK = **(**uintptr)(__ccgo_up(bp + 32)) + (*TSessionTable)(unsafe.Pointer(pTab)).FaiIdx = **(**uintptr)(__ccgo_up(bp + 24)) + **(**uintptr)(__ccgo_up(bp + 8)) = a + } + if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize != 0 { + **(**Ti64)(__ccgo_up(pSession + 64)) += int64(**(**int32)(__ccgo_up(bp)) - nOldCol) + **(**Ti64)(__ccgo_up(pSession + 64)) += int64(_sessionVarintLen(tls, **(**int32)(__ccgo_up(bp)))) + **(**Ti64)(__ccgo_up(pSession + 64)) -= int64(_sessionVarintLen(tls, nOldCol)) + } + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + return (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc +} + +// C documentation +// +// /* +// ** SQL statement pSelect is as generated by the sessionSelectRow() function. +// ** This function binds the primary key values from the change that changeset +// ** iterator pIter points to to the SELECT and attempts to seek to the table +// ** entry. If a row is found, the SELECT statement left pointing at the row +// ** and SQLITE_ROW is returned. Otherwise, if no row is found and no error +// ** has occured, the statement is reset and SQLITE_OK is returned. If an +// ** error occurs, the statement is reset and an SQLite error code is returned. +// ** +// ** If this function returns SQLITE_ROW, the caller must eventually reset() +// ** statement pSelect. If any other value is returned, the statement does +// ** not require a reset(). +// ** +// ** If the iterator currently points to an INSERT record, bind values from the +// ** new.* record to the SELECT statement. Or, if it points to a DELETE or +// ** UPDATE, bind values from the old.* record. +// */ +func _sessionSeekToRow(tls *libc.TLS, pIter uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ii, rc int32 + var pSelect, v1 uintptr + var _ /* nCol at bp+0 */ int32 + var _ /* op at bp+4 */ int32 + var _ /* pVal at bp+16 */ uintptr + var _ /* zDummy at bp+8 */ uintptr + _, _, _, _ = ii, pSelect, rc, v1 + pSelect = (*TSessionApplyCtx)(unsafe.Pointer(p)).FpSelect /* Unused */ + Xsqlite3_clear_bindings(tls, pSelect) + Xsqlite3changeset_op(tls, pIter, bp+8, bp, bp+4, uintptr(0)) + if **(**int32)(__ccgo_up(bp + 4)) == int32(SQLITE_INSERT) { + v1 = __ccgo_fp(Xsqlite3changeset_new) + } else { + v1 = __ccgo_fp(Xsqlite3changeset_old) + } + rc = _sessionBindRow(tls, pIter, v1, **(**int32)(__ccgo_up(bp)), (*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK, pSelect) + if **(**int32)(__ccgo_up(bp + 4)) != int32(SQLITE_DELETE) && (*TSessionApplyCtx)(unsafe.Pointer(p)).FbIgnoreNoop != 0 { + ii = 0 + for { + if !(rc == SQLITE_OK && ii < **(**int32)(__ccgo_up(bp))) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(ii)))) == 0 { + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + Xsqlite3changeset_new(tls, pIter, ii, bp+16) + Xsqlite3_bind_int(tls, pSelect, ii+int32(1)+**(**int32)(__ccgo_up(bp)), libc.BoolInt32(**(**uintptr)(__ccgo_up(bp + 16)) == uintptr(0))) + if **(**uintptr)(__ccgo_up(bp + 16)) != 0 { + rc = _sessionBindValue(tls, pSelect, ii+int32(1), **(**uintptr)(__ccgo_up(bp + 16))) + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + } + if rc == SQLITE_OK { + rc = Xsqlite3_step(tls, pSelect) + if rc != int32(SQLITE_ROW) { + rc = Xsqlite3_reset(tls, pSelect) + } + } + return rc +} + +// C documentation +// +// /* +// ** Table pTab has one or more existing change-records with old.* records +// ** with fewer than pTab->nCol columns. This function updates all such +// ** change-records with the default values for the missing columns. +// */ +func _sessionUpdateChanges(tls *libc.TLS, pSession uintptr, pTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var ii int32 + var pp uintptr + var _ /* pStmt at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _ = ii, pp + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc + **(**int32)(__ccgo_up(bp + 8)) = _sessionPrepareDfltStmt(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, pTab, bp) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + ii = 0 + pp = uintptr(0) + ii = 0 + for { + if !(ii < (*TSessionTable)(unsafe.Pointer(pTab)).FnChange) { + break + } + pp = (*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(ii)*8 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + if libc.Int32FromUint16((*TSessionChange)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FnRecordField) != (*TSessionTable)(unsafe.Pointer(pTab)).FnCol { + _sessionUpdateOneChange(tls, pSession, bp+8, pp, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, **(**uintptr)(__ccgo_up(bp))) + } + goto _2 + _2: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 24 + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + _sessionFinalizeStmt(tls, **(**uintptr)(__ccgo_up(bp)), bp+8) + (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = **(**int32)(__ccgo_up(bp + 8)) + return (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc +} + +// C documentation +// +// /**************************** sqlite3_result_ ******************************* +// ** The following routines are used by user-defined functions to specify +// ** the function result. +// ** +// ** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the +// ** result as a string or blob. Appropriate errors are set if the string/blob +// ** is too big or if an OOM occurs. +// ** +// ** The invokeValueDestructor(P,X) routine invokes destructor function X() +// ** on value P if P is not going to be used and need to be destroyed. +// */ +func _setResultStrOrError(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, enc Tu8, __ccgo_fp_xDel uintptr) { + var pOut, v1 uintptr + var rc int32 + _, _, _ = pOut, rc, v1 + pOut = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8) { + rc = _sqlite3VdbeMemSetText(tls, pOut, z, int64(n), __ccgo_fp_xDel) + } else { + if libc.Int32FromUint8(enc) == int32(SQLITE_UTF8_ZT) { + /* It is usually considered improper to assert() on an input. However, + ** the following assert() is checking for inputs that are documented + ** to result in undefined behavior. */ + rc = _sqlite3VdbeMemSetText(tls, pOut, z, int64(n), __ccgo_fp_xDel) + v1 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + } else { + rc = _sqlite3VdbeMemSetStr(tls, pOut, z, int64(n), enc, __ccgo_fp_xDel) + } + } + if rc != 0 { + if rc == int32(SQLITE_TOOBIG) { + Xsqlite3_result_error_toobig(tls, pCtx) + } else { + /* The only errors possible from sqlite3VdbeMemSetStr are + ** SQLITE_TOOBIG and SQLITE_NOMEM */ + Xsqlite3_result_error_nomem(tls, pCtx) + } + return + } + _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8((*Tsqlite3_context)(unsafe.Pointer(pCtx)).Fenc)) + if _sqlite3VdbeMemTooBig(tls, pOut) != 0 { + Xsqlite3_result_error_toobig(tls, pCtx) + } +} + +// C documentation +// +// /* +// ** Add a lock on the table with root-page iTable to the shared-btree used +// ** by Btree handle p. Parameter eLock must be either READ_LOCK or +// ** WRITE_LOCK. +// ** +// ** This function assumes the following: +// ** +// ** (a) The specified Btree object p is connected to a sharable +// ** database (one with the BtShared.sharable flag set), and +// ** +// ** (b) No other Btree objects hold a lock that conflicts +// ** with the requested lock (i.e. querySharedCacheTableLock() has +// ** already been called and returned SQLITE_OK). +// ** +// ** SQLITE_OK is returned if the lock is added successfully. SQLITE_NOMEM +// ** is returned if a malloc attempt fails. +// */ +func _setSharedCacheTableLock(tls *libc.TLS, p uintptr, iTable TPgno, eLock Tu8) (r int32) { + var pBt, pIter, pLock uintptr + _, _, _ = pBt, pIter, pLock + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + pLock = uintptr(0) + /* A connection with the read-uncommitted flag set will never try to + ** obtain a read-lock using this function. The only read-lock obtained + ** by a connection in read-uncommitted mode is on the sqlite_schema + ** table, and that lock is obtained in BtreeBeginTrans(). */ + /* This function should only be called on a sharable b-tree after it + ** has been determined that no other b-tree holds a conflicting lock. */ + /* First search the list for an existing lock on this table. */ + pIter = (*TBtShared)(unsafe.Pointer(pBt)).FpLock + for { + if !(pIter != 0) { + break + } + if (*TBtLock)(unsafe.Pointer(pIter)).FiTable == iTable && (*TBtLock)(unsafe.Pointer(pIter)).FpBtree == p { + pLock = pIter + break + } + goto _1 + _1: + ; + pIter = (*TBtLock)(unsafe.Pointer(pIter)).FpNext + } + /* If the above search did not find a BtLock struct associating Btree p + ** with table iTable, allocate one and link it into the list. + */ + if !(pLock != 0) { + pLock = _sqlite3MallocZero(tls, uint64(24)) + if !(pLock != 0) { + return int32(SQLITE_NOMEM) + } + (*TBtLock)(unsafe.Pointer(pLock)).FiTable = iTable + (*TBtLock)(unsafe.Pointer(pLock)).FpBtree = p + (*TBtLock)(unsafe.Pointer(pLock)).FpNext = (*TBtShared)(unsafe.Pointer(pBt)).FpLock + (*TBtShared)(unsafe.Pointer(pBt)).FpLock = pLock + } + /* Set the BtLock.eLock variable to the maximum of the current lock + ** and the requested lock. This means if a write-lock was already held + ** and a read-lock requested, we don't incorrectly downgrade the lock. + */ + if libc.Int32FromUint8(eLock) > libc.Int32FromUint8((*TBtLock)(unsafe.Pointer(pLock)).FeLock) { + (*TBtLock)(unsafe.Pointer(pLock)).FeLock = eLock + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Set up the lookaside buffers for a database connection. +// ** Return SQLITE_OK on success. +// ** If lookaside is already active, return SQLITE_BUSY. +// ** +// ** The sz parameter is the number of bytes in each lookaside slot. +// ** The cnt parameter is the number of slots. If pBuf is NULL the +// ** space for the lookaside memory is obtained from sqlite3_malloc() +// ** or similar. If pBuf is not NULL then it is sz*cnt bytes of memory +// ** to use for the lookaside memory. +// */ +func _setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32) (r int32) { + var i, nBig, nSm, v1 int32 + var p, pStart uintptr + var szAlloc Tsqlite3_int64 + _, _, _, _, _, _, _ = i, nBig, nSm, p, pStart, szAlloc, v1 /* Number smaller LOOKASIDE_SMALL-byte slots */ + if _sqlite3LookasideUsed(tls, db, uintptr(0)) > 0 { + return int32(SQLITE_BUSY) + } + /* Free any existing lookaside buffer for this handle before + ** allocating a new one so we don't have to have space for + ** both at the same time. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced != 0 { + Xsqlite3_free(tls, (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) + } + /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger + ** than a pointer and small enough to fit in a u16. + */ + sz = sz & ^libc.Int32FromInt32(7) + if sz <= libc.Int32FromInt64(8) { + sz = 0 + } + if sz > int32(65528) { + sz = int32(65528) + } + /* Count must be at least 1 to be useful, but not so large as to use + ** more than 0x7fff0000 total bytes for lookaside. */ + if cnt < int32(1) { + cnt = 0 + } + if sz > 0 && cnt > int32(0x7fff0000)/sz { + cnt = int32(0x7fff0000) / sz + } + szAlloc = int64(sz) * int64(cnt) + if szAlloc == 0 { + sz = 0 + pStart = uintptr(0) + } else { + if pBuf == uintptr(0) { + _sqlite3BeginBenignMalloc(tls) + pStart = _sqlite3Malloc(tls, libc.Uint64FromInt64(szAlloc)) + _sqlite3EndBenignMalloc(tls) + if pStart != 0 { + szAlloc = int64(_sqlite3MallocSize(tls, pStart)) + } + } else { + pStart = pBuf + } + } + if sz >= libc.Int32FromInt32(LOOKASIDE_SMALL)*libc.Int32FromInt32(3) { + nBig = int32(szAlloc / int64(libc.Int32FromInt32(3)*libc.Int32FromInt32(LOOKASIDE_SMALL)+sz)) + nSm = int32((szAlloc - int64(sz)*int64(nBig)) / int64(LOOKASIDE_SMALL)) + } else { + if sz >= libc.Int32FromInt32(LOOKASIDE_SMALL)*libc.Int32FromInt32(2) { + nBig = int32(szAlloc / int64(libc.Int32FromInt32(LOOKASIDE_SMALL)+sz)) + nSm = int32((szAlloc - int64(sz)*int64(nBig)) / int64(LOOKASIDE_SMALL)) + } else { + if sz > 0 { + nBig = int32(szAlloc / int64(sz)) + nSm = 0 + } else { + v1 = libc.Int32FromInt32(0) + nSm = v1 + nBig = v1 + } + } + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart = pStart + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(sz) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue = libc.Uint16FromInt32(sz) + if pStart != 0 { + p = pStart + i = 0 + for { + if !(i < nBig) { + break + } + (*TLookasideSlot)(unsafe.Pointer(p)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpInit + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = p + p = p + uintptr(sz) + goto _2 + _2: + ; + i = i + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle = p + i = 0 + for { + if !(i < nSm) { + break + } + (*TLookasideSlot)(unsafe.Pointer(p)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = p + p = p + 128 + goto _3 + _3: + ; + i = i + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = p + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = uint32(0) + if pBuf == uintptr(0) { + v1 = int32(1) + } else { + v1 = 0 + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced = libc.Uint8FromInt32(v1) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot = libc.Uint32FromInt32(nBig + nSm) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = uint32(1) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced = uint8(0) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot = uint32(0) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Set the collation function of the most recently parsed table column +// ** to the CollSeq given. +// */ +func _sqlite3AddCollateType(tls *libc.TLS, pParse uintptr, pToken uintptr) { + var db, p, pIdx, zColl, v1 uintptr + var i int32 + _, _, _, _, _, _ = db, i, p, pIdx, zColl, v1 + v1 = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + p = v1 + if v1 == uintptr(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return + } + i = int32((*TTable)(unsafe.Pointer(p)).FnCol) - int32(1) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + zColl = _sqlite3NameFromToken(tls, db, pToken) + if !(zColl != 0) { + return + } + if _sqlite3LocateCollSeq(tls, pParse, zColl) != 0 { + _sqlite3ColumnSetColl(tls, db, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(i)*16, zColl) + /* If the column is declared as " PRIMARY KEY COLLATE ", + ** then an index may have been created on this column before the + ** collation type was added. Correct this if it is the case. + */ + pIdx = (*TTable)(unsafe.Pointer(p)).FpIndex + for { + if !(pIdx != 0) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn))) == i { + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl)) = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(i)*16) + } + goto _2 + _2: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } + _sqlite3DbFree(tls, db, zColl) +} + +// C documentation +// +// /* +// ** This routine is called by the parser while in the middle of +// ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has +// ** been seen on a column. This routine sets the notNull flag on +// ** the column currently under construction. +// */ +func _sqlite3AddNotNull(tls *libc.TLS, pParse uintptr, onError int32) { + var p, pCol, pIdx uintptr + _, _, _ = p, pCol, pIdx + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) || int32((*TTable)(unsafe.Pointer(p)).FnCol) < int32(1) { + return + } + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(p)).FnCol)-int32(1))*16 + libc.SetBitFieldPtr8Uint32(pCol+8, uint32(libc.Uint8FromInt32(onError)), 0, 0xf) + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_HasNotNull) + /* Set the uniqNotNull flag on any UNIQUE or PK indexes already created + ** on this column. */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_UNIQUE) != 0 { + pIdx = (*TTable)(unsafe.Pointer(p)).FpIndex + for { + if !(pIdx != 0) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn))) == int32((*TTable)(unsafe.Pointer(p)).FnCol)-int32(1) { + libc.SetBitFieldPtr16Uint32(pIdx+100, libc.Uint32FromInt32(1), 3, 0x8) + } + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } +} + +// C documentation +// +// /* +// ** Allocate heap space to hold an Index object with nCol columns. +// ** +// ** Increase the allocation size to provide an extra nExtra bytes +// ** of 8-byte aligned space after the Index object and return a +// ** pointer to this extra space in *ppExtra. +// */ +func _sqlite3AllocateIndexObject(tls *libc.TLS, db uintptr, nCol int32, nExtra int32, ppExtra uintptr) (r uintptr) { + var nByte Ti64 + var p, pExtra uintptr + _, _, _ = nByte, p, pExtra /* Bytes of space for Index object + arrays */ + nByte = libc.Int64FromUint64((libc.Uint64FromInt64(160)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7)) + (uint64(8)*libc.Uint64FromInt32(nCol)+uint64(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7)) + (uint64(2)*libc.Uint64FromInt32(nCol+libc.Int32FromInt32(1))+uint64(2)*libc.Uint64FromInt32(nCol)+uint64(1)*libc.Uint64FromInt32(nCol)+uint64(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) /* Index.aSortOrder */ + p = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte+int64(nExtra))) + if p != 0 { + pExtra = p + uintptr((libc.Uint64FromInt64(160)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + (*TIndex)(unsafe.Pointer(p)).FazColl = pExtra + pExtra = pExtra + uintptr((libc.Uint64FromInt64(8)*libc.Uint64FromInt32(nCol)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + (*TIndex)(unsafe.Pointer(p)).FaiRowLogEst = pExtra + pExtra = pExtra + uintptr(uint64(2)*libc.Uint64FromInt32(nCol+libc.Int32FromInt32(1))) + (*TIndex)(unsafe.Pointer(p)).FaiColumn = pExtra + pExtra = pExtra + uintptr(uint64(2)*libc.Uint64FromInt32(nCol)) + (*TIndex)(unsafe.Pointer(p)).FaSortOrder = pExtra + (*TIndex)(unsafe.Pointer(p)).FnColumn = libc.Uint16FromInt32(nCol) + (*TIndex)(unsafe.Pointer(p)).FnKeyCol = libc.Uint16FromInt32(nCol - libc.Int32FromInt32(1)) + **(**uintptr)(__ccgo_up(ppExtra)) = p + uintptr(nByte) + } + return p +} + +// C documentation +// +// /* +// ** Register built-in functions used to help implement ALTER TABLE +// */ +func _sqlite3AlterFunctions(tls *libc.TLS) { + _sqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&_aAlterTableFuncs)), libc.Int32FromUint64(libc.Uint64FromInt64(648)/libc.Uint64FromInt64(72))) +} + +// C documentation +// +// /* +// ** Generate code for the ANALYZE command. The parser calls this routine +// ** when it recognizes an ANALYZE command. +// ** +// ** ANALYZE -- 1 +// ** ANALYZE -- 2 +// ** ANALYZE ?.? -- 3 +// ** +// ** Form 1 causes all indices in all attached databases to be analyzed. +// ** Form 2 analyzes all indices the single database named. +// ** Form 3 analyzes all indices associated with the named table. +// */ +func _sqlite3Analyze(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pIdx, pTab, v, z, zDb, v4 uintptr + var i, iDb, v2 int32 + var v3 bool + var _ /* pTableName at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = db, i, iDb, pIdx, pTab, v, z, zDb, v2, v3, v4 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Read the database schema. If an error occurs, leave an error message + ** and code in pParse and return NULL. */ + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + return + } + if pName1 == uintptr(0) { + /* Form 1: Analyze everything */ + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if i == int32(1) { + goto _1 + } /* Do not analyze the TEMP database */ + _analyzeDatabase(tls, pParse, i) + goto _1 + _1: + ; + i = i + 1 + } + } else { + if v3 = (*TToken)(unsafe.Pointer(pName2)).Fn == uint32(0); v3 { + v2 = _sqlite3FindDb(tls, db, pName1) + iDb = v2 + } + if v3 && v2 >= 0 { + /* Analyze the schema named as the argument */ + _analyzeDatabase(tls, pParse, iDb) + } else { + /* Form 3: Analyze the table or index named as an argument */ + iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp) + if iDb >= 0 { + if (*TToken)(unsafe.Pointer(pName2)).Fn != 0 { + v4 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + v4 = uintptr(0) + } + zDb = v4 + z = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if z != 0 { + v4 = _sqlite3FindIndex(tls, db, z, zDb) + pIdx = v4 + if v4 != uintptr(0) { + _analyzeTable(tls, pParse, (*TIndex)(unsafe.Pointer(pIdx)).FpTable, pIdx) + } else { + v4 = _sqlite3LocateTable(tls, pParse, uint32(0), z, zDb) + pTab = v4 + if v4 != uintptr(0) { + _analyzeTable(tls, pParse, pTab, uintptr(0)) + } + } + _sqlite3DbFree(tls, db, z) + } + } + } + } + if v3 = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec) == 0; v3 { + v4 = _sqlite3GetVdbe(tls, pParse) + v = v4 + } + if v3 && v4 != uintptr(0) { + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + } +} + +// C documentation +// +// /* +// ** This routine generates code that will initialize all of the +// ** register used by the autoincrement tracker. +// */ +func _sqlite3AutoincrementBegin(tls *libc.TLS, pParse uintptr) { + var aOp, db, p, pDb, v uintptr + var memId int32 + _, _, _, _, _, _ = aOp, db, memId, p, pDb, v /* Information about an AUTOINCREMENT */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Register holding max rowid */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* VDBE under construction */ + /* This routine is never called during trigger-generation. It is + ** only called from the top-level */ + /* We failed long ago if this is not so */ + p = (*TParse)(unsafe.Pointer(pParse)).FpAinc + for { + if !(p != 0) { + break + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TAutoincInfo)(unsafe.Pointer(p)).FiDb)*32 + memId = (*TAutoincInfo)(unsafe.Pointer(p)).FregCtr + _sqlite3OpenTable(tls, pParse, 0, (*TAutoincInfo)(unsafe.Pointer(p)).FiDb, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, int32(OP_OpenRead)) + _sqlite3VdbeLoadString(tls, v, memId-int32(1), (*TTable)(unsafe.Pointer((*TAutoincInfo)(unsafe.Pointer(p)).FpTab)).FzName) + aOp = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(48)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_autoInc)), _iLn1) + if aOp == uintptr(0) { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp))).Fp2 = memId + (**(**TVdbeOp)(__ccgo_up(aOp))).Fp3 = memId + int32(2) + (**(**TVdbeOp)(__ccgo_up(aOp + 2*24))).Fp3 = memId + (**(**TVdbeOp)(__ccgo_up(aOp + 3*24))).Fp1 = memId - int32(1) + (**(**TVdbeOp)(__ccgo_up(aOp + 3*24))).Fp3 = memId + (**(**TVdbeOp)(__ccgo_up(aOp + 3*24))).Fp5 = uint16(SQLITE_JUMPIFNULL) + (**(**TVdbeOp)(__ccgo_up(aOp + 4*24))).Fp2 = memId + int32(1) + (**(**TVdbeOp)(__ccgo_up(aOp + 5*24))).Fp3 = memId + (**(**TVdbeOp)(__ccgo_up(aOp + 6*24))).Fp1 = memId + (**(**TVdbeOp)(__ccgo_up(aOp + 7*24))).Fp2 = memId + int32(2) + (**(**TVdbeOp)(__ccgo_up(aOp + 7*24))).Fp1 = memId + (**(**TVdbeOp)(__ccgo_up(aOp + 10*24))).Fp2 = memId + if (*TParse)(unsafe.Pointer(pParse)).FnTab == 0 { + (*TParse)(unsafe.Pointer(pParse)).FnTab = int32(1) + } + goto _1 + _1: + ; + p = (*TAutoincInfo)(unsafe.Pointer(p)).FpNext + } +} + +// C documentation +// +// /* +// ** Check to see if the i-th bit is set. Return true or false. +// ** If p is NULL (if the bitmap has not been created) or if +// ** i is out of range, then return false. +// */ +func _sqlite3BitvecTestNotNull(tls *libc.TLS, p uintptr, i Tu32) (r int32) { + var bin, h, v1 Tu32 + _, _, _ = bin, h, v1 + i = i - 1 + if i >= (*TBitvec)(unsafe.Pointer(p)).FiSize { + return 0 + } + for (*TBitvec)(unsafe.Pointer(p)).FiDivisor != 0 { + bin = i / (*TBitvec)(unsafe.Pointer(p)).FiDivisor + i = i % (*TBitvec)(unsafe.Pointer(p)).FiDivisor + p = **(**uintptr)(__ccgo_up(p + 16 + uintptr(bin)*8)) + if !(p != 0) { + return 0 + } + } + if uint64((*TBitvec)(unsafe.Pointer(p)).FiSize) <= (libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(1)*libc.Uint64FromInt32(BITVEC_SZELEM) { + return libc.BoolInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(p + 16 + uintptr(i/uint32(BITVEC_SZELEM)))))&(int32(1)<<(i&libc.Uint32FromInt32(libc.Int32FromInt32(BITVEC_SZELEM)-libc.Int32FromInt32(1)))) != 0) + } else { + v1 = i + i = i + 1 + h = uint32(uint64(v1*libc.Uint32FromInt32(1)) % ((libc.Uint64FromInt32(BITVEC_SZ) - libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4)) / libc.Uint64FromInt64(8) * libc.Uint64FromInt64(8) / libc.Uint64FromInt64(4))) + for **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) != 0 { + if **(**Tu32)(__ccgo_up(p + 16 + uintptr(h)*4)) == i { + return int32(1) + } + h = uint32(uint64(h+libc.Uint32FromInt32(1)) % ((libc.Uint64FromInt32(BITVEC_SZ) - libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4)) / libc.Uint64FromInt64(8) * libc.Uint64FromInt64(8) / libc.Uint64FromInt64(4))) + } + return 0 + } + return r +} + +// C documentation +// +// /* +// ** Compare two blobs. Return negative, zero, or positive if the first +// ** is less than, equal to, or greater than the second, respectively. +// ** If one blob is a prefix of the other, then the shorter is the lessor. +// */ +func _sqlite3BlobCompare(tls *libc.TLS, pB1 uintptr, pB2 uintptr) (r int32) { + var c, n1, n2, v1 int32 + _, _, _, _ = c, n1, n2, v1 + n1 = (*TMem)(unsafe.Pointer(pB1)).Fn + n2 = (*TMem)(unsafe.Pointer(pB2)).Fn + /* It is possible to have a Blob value that has some non-zero content + ** followed by zero content. But that only comes up for Blobs formed + ** by the OP_MakeRecord opcode, and such Blobs never get passed into + ** sqlite3MemCompare(). */ + if (libc.Int32FromUint16((*TMem)(unsafe.Pointer(pB1)).Fflags)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pB2)).Fflags))&int32(MEM_Zero) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pB1)).Fflags)&libc.Int32FromUint16((*TMem)(unsafe.Pointer(pB2)).Fflags)&int32(MEM_Zero) != 0 { + return *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pB1)).Fu)) - *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pB2)).Fu)) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pB1)).Fflags)&int32(MEM_Zero) != 0 { + if !(_isAllZero(tls, (*TMem)(unsafe.Pointer(pB2)).Fz, (*TMem)(unsafe.Pointer(pB2)).Fn) != 0) { + return -int32(1) + } + return *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pB1)).Fu)) - n2 + } else { + if !(_isAllZero(tls, (*TMem)(unsafe.Pointer(pB1)).Fz, (*TMem)(unsafe.Pointer(pB1)).Fn) != 0) { + return +libc.Int32FromInt32(1) + } + return n1 - *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pB2)).Fu)) + } + } + } + if n1 > n2 { + v1 = n2 + } else { + v1 = n1 + } + c = libc.Xmemcmp(tls, (*TMem)(unsafe.Pointer(pB1)).Fz, (*TMem)(unsafe.Pointer(pB2)).Fz, libc.Uint64FromInt32(v1)) + if c != 0 { + return c + } + return n1 - n2 +} + +/* The following two functions are used only within testcase() to prove +** test coverage. These functions do no exist for production builds. +** We must use separate SQLITE_NOINLINE functions here, since otherwise +** optimizer code movement causes gcov to become very confused. + */ + +// C documentation +// +// /* +// ** Return the size of a BtCursor object in bytes. +// ** +// ** This interfaces is needed so that users of cursors can preallocate +// ** sufficient storage to hold a cursor. The BtCursor object is opaque +// ** to users so they cannot do the sizeof() themselves - they must call +// ** this routine. +// */ +func _sqlite3BtreeCursorSize(tls *libc.TLS) (r int32) { + return libc.Int32FromUint64((libc.Uint64FromInt64(296) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) +} + +func _sqlite3BtreeNext(tls *libc.TLS, pCur uintptr, flags int32) (r int32) { + var pPage, v1 uintptr + var v2 Tu16 + _, _, _ = pPage, v1, v2 + _ = flags /* Used in COMDB2 but not native SQLite */ + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { + return _btreeNext(tls, pCur) + } + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + v1 = pCur + 86 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v2 = *(*Tu16)(unsafe.Pointer(v1)) + if libc.Int32FromUint16(v2) >= libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FnCell) { + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = (*TBtCursor)(unsafe.Pointer(pCur)).Fix - 1 + return _btreeNext(tls, pCur) + } + if (*TMemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { + return SQLITE_OK + } else { + return _moveToLeftmost(tls, pCur) + } + return r +} + +// C documentation +// +// /* +// ** Return the offset into the database file for the start of the +// ** payload to which the cursor is pointing. +// */ +func _sqlite3BtreeOffset(tls *libc.TLS, pCur uintptr) (r Ti64) { + _getCellInfo(tls, pCur) + return libc.Int64FromUint32((*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBt)).FpageSize)*(libc.Int64FromUint32((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).Fpgno)-int64(1)) + (int64((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload) - int64((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FaData)) +} + +// C documentation +// +// /* +// ** Return an estimate for the number of rows in the table that pCur is +// ** pointing to. Return a negative number if no estimate is currently +// ** available. +// */ +func _sqlite3BtreeRowCountEst(tls *libc.TLS, pCur uintptr) (r Ti64) { + var i Tu8 + var n Ti64 + _, _ = i, n + /* Currently this interface is only called by the OP_IfSizeBetween + ** opcode and the OP_Count opcode with P3=1. In either case, + ** the cursor will always be valid unless the btree is empty. */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { + return 0 + } + if libc.Int32FromUint8((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf) == 0 { + return int64(-int32(1)) + } + n = libc.Int64FromUint16((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell) + i = uint8(0) + for { + if !(libc.Int32FromUint8(i) < int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)) { + break + } + n = n * int64(libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pCur + 144 + uintptr(i)*8)))).FnCell)+int32(1)) + goto _1 + _1: + ; + i = i + 1 + } + return n +} + +// C documentation +// +// /* +// ** Change the values for the BTS_SECURE_DELETE and BTS_OVERWRITE flags: +// ** +// ** newFlag==0 Both BTS_SECURE_DELETE and BTS_OVERWRITE are cleared +// ** newFlag==1 BTS_SECURE_DELETE set and BTS_OVERWRITE is cleared +// ** newFlag==2 BTS_SECURE_DELETE cleared and BTS_OVERWRITE is set +// ** newFlag==(-1) No changes +// ** +// ** This routine acts as a query if newFlag is less than zero +// ** +// ** With BTS_OVERWRITE set, deleted content is overwritten by zeros, but +// ** freelist leaf pages are not written back to the database. Thus in-page +// ** deleted content is cleared, but freelist deleted content is not. +// ** +// ** With BTS_SECURE_DELETE, operation is like BTS_OVERWRITE with the addition +// ** that freelist leaf pages are written back into the database, increasing +// ** the amount of disk I/O. +// */ +func _sqlite3BtreeSecureDelete(tls *libc.TLS, p uintptr, newFlag int32) (r int32) { + var b int32 + var v1 uintptr + _, _ = b, v1 + if p == uintptr(0) { + return 0 + } + _sqlite3BtreeEnter(tls, p) + if newFlag >= 0 { + v1 = (*TBtree)(unsafe.Pointer(p)).FpBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTS_FAST_SECURE)) + v1 = (*TBtree)(unsafe.Pointer(p)).FpBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16(libc.Uint16FromInt32(libc.Int32FromInt32(BTS_SECURE_DELETE)*newFlag))) + } + b = libc.Int32FromUint16((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & int32(BTS_FAST_SECURE) / int32(BTS_SECURE_DELETE) + _sqlite3BtreeLeave(tls, p) + return b +} + +// C documentation +// +// /* +// ** Change the default pages size and the number of reserved bytes per page. +// ** Or, if the page size has already been fixed, return SQLITE_READONLY +// ** without changing anything. +// ** +// ** The page size must be a power of 2 between 512 and 65536. If the page +// ** size supplied does not meet this constraint then the page size is not +// ** changed. +// ** +// ** Page sizes are constrained to be a power of two so that the region +// ** of the database file used for locking (beginning at PENDING_BYTE, +// ** the first byte past the 1GB boundary, 0x40000000) needs to occur +// ** at the beginning of a page. +// ** +// ** If parameter nReserve is less than zero, then the number of reserved +// ** bytes per page is left unchanged. +// ** +// ** If the iFix!=0 then the BTS_PAGESIZE_FIXED flag is set so that the page size +// ** and autovacuum mode can no longer be changed. +// */ +func _sqlite3BtreeSetPageSize(tls *libc.TLS, p uintptr, pageSize int32, nReserve int32, iFix int32) (r int32) { + var pBt, v1 uintptr + var rc, x int32 + _, _, _, _ = pBt, rc, x, v1 + rc = SQLITE_OK + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + (*TBtShared)(unsafe.Pointer(pBt)).FnReserveWanted = libc.Uint8FromInt32(nReserve) + x = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FpageSize - (*TBtShared)(unsafe.Pointer(pBt)).FusableSize) + if x == nReserve && (pageSize == 0 || libc.Uint32FromInt32(pageSize) == (*TBtShared)(unsafe.Pointer(pBt)).FpageSize) { + _sqlite3BtreeLeave(tls, p) + return SQLITE_OK + } + if nReserve < x { + nReserve = x + } + if libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_PAGESIZE_FIXED) != 0 { + _sqlite3BtreeLeave(tls, p) + return int32(SQLITE_READONLY) + } + if pageSize >= int32(512) && pageSize <= int32(SQLITE_MAX_PAGE_SIZE) && (pageSize-int32(1))&pageSize == 0 { + if nReserve > int32(32) && pageSize == int32(512) { + pageSize = int32(1024) + } + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = libc.Uint32FromInt32(pageSize) + _freeTempSpace(tls, pBt) + } + rc = _sqlite3PagerSetPagesize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pBt+52, nReserve) + (*TBtShared)(unsafe.Pointer(pBt)).FusableSize = (*TBtShared)(unsafe.Pointer(pBt)).FpageSize - uint32(libc.Uint16FromInt32(nReserve)) + if iFix != 0 { + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + } + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Set both the "read version" (single byte at byte offset 18) and +// ** "write version" (single byte at byte offset 19) fields in the database +// ** header to iVersion. +// */ +func _sqlite3BtreeSetVersion(tls *libc.TLS, pBtree uintptr, iVersion int32) (r int32) { + var aData, pBt, v1 uintptr + var rc int32 + _, _, _, _ = aData, pBt, rc, v1 + pBt = (*TBtree)(unsafe.Pointer(pBtree)).FpBt /* Return code */ + /* If setting the version fields to 1, do not automatically open the + ** WAL connection, even if the version fields are currently set to 2. + */ + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTS_NO_WAL)) + if iVersion == int32(1) { + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTS_NO_WAL)) + } + rc = _sqlite3BtreeBeginTrans(tls, pBtree, 0, uintptr(0)) + if rc == SQLITE_OK { + aData = (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + 18))) != libc.Int32FromUint8(libc.Uint8FromInt32(iVersion)) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aData + 19))) != libc.Int32FromUint8(libc.Uint8FromInt32(iVersion)) { + rc = _sqlite3BtreeBeginTrans(tls, pBtree, int32(2), uintptr(0)) + if rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) + if rc == SQLITE_OK { + **(**Tu8)(__ccgo_up(aData + 18)) = libc.Uint8FromInt32(iVersion) + **(**Tu8)(__ccgo_up(aData + 19)) = libc.Uint8FromInt32(iVersion) + } + } + } + } + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTS_NO_WAL)) + return rc +} + +// C documentation +// +// /* +// ** Generate code that will increment the schema cookie. +// ** +// ** The schema cookie is used to determine when the schema for the +// ** database changes. After each schema change, the cookie value +// ** changes. When a process first reads the schema it records the +// ** cookie. Thereafter, whenever it goes to access the database, +// ** it checks the cookie to make sure the schema has not changed +// ** since it was last read. +// ** +// ** This plan is not completely bullet-proof. It is possible for +// ** the schema to change multiple times and for the cookie to be +// ** set back to prior value. But schema changes are infrequent +// ** and the probability of hitting the same cookie value is only +// ** 1 chance in 2^32. So we're safe enough. +// ** +// ** IMPLEMENTATION-OF: R-34230-56049 SQLite automatically increments +// ** the schema-version whenever the schema changes. +// */ +func _sqlite3ChangeCookie(tls *libc.TLS, pParse uintptr, iDb int32) { + var db, v uintptr + _, _ = db, v + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_SCHEMA_VERSION), libc.Int32FromUint32(libc.Uint32FromInt32(1)+libc.Uint32FromInt32((*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema)).Fschema_cookie))) +} + +// C documentation +// +// /* +// ** Generate code for the trigger program associated with trigger p on +// ** table pTab. The reg, orconf and ignoreJump parameters passed to this +// ** function are the same as those described in the header function for +// ** sqlite3CodeRowTrigger() +// */ +func _sqlite3CodeRowTriggerDirect(tls *libc.TLS, pParse uintptr, p uintptr, pTab uintptr, reg int32, orconf int32, ignoreJump int32) { + var bRecursive, v1 int32 + var pPrg, v, v2 uintptr + _, _, _, _, _ = bRecursive, pPrg, v, v1, v2 + v = _sqlite3GetVdbe(tls, pParse) + pPrg = _getRowTrigger(tls, pParse, p, pTab, orconf) + /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program + ** is a pointer to the sub-vdbe containing the trigger program. */ + if pPrg != 0 { + bRecursive = libc.BoolInt32((*TTrigger)(unsafe.Pointer(p)).FzName != 0 && uint64(0) == (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_RecTriggers)) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Program), reg, ignoreJump, v1, (*TTriggerPrg)(unsafe.Pointer(pPrg)).FpProgram, -int32(4)) + /* Set the P5 operand of the OP_Program instruction to non-zero if + ** recursive invocation of this trigger program is disallowed. Recursive + ** invocation is disallowed if (a) the sub-program is really a trigger, + ** not a foreign key action, and (b) the flag to enable recursive triggers + ** is clear. */ + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(bRecursive)) + } +} + +// C documentation +// +// /* +// ** Return the expression associated with a column. The expression might be +// ** the DEFAULT clause or the AS clause of a generated column. +// ** Return NULL if the column has no associated expression. +// */ +func _sqlite3ColumnExpr(tls *libc.TLS, pTab uintptr, pCol uintptr) (r uintptr) { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) == 0 { + return uintptr(0) + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + return uintptr(0) + } + if (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpDfltList == uintptr(0) { + return uintptr(0) + } + if (*TExprList)(unsafe.Pointer((*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpDfltList)).FnExpr < libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) { + return uintptr(0) + } + return (*(*TExprList_item)(unsafe.Pointer((*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpDfltList + 8 + uintptr(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt)-int32(1))*32))).FpExpr +} + +// C documentation +// +// /* +// ** Return the index of a column in a table. Return -1 if the column +// ** is not contained in the table. +// */ +func _sqlite3ColumnIndex(tls *libc.TLS, pTab uintptr, zCol uintptr) (r int32) { + var aCol uintptr + var h Tu8 + var i, nCol int32 + _, _, _, _ = aCol, h, i, nCol + h = _sqlite3StrIHash(tls, zCol) + aCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + nCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + /* See if the aHx gives us a lucky match */ + i = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pTab + 104 + uintptr(uint64(h)%uint64(16))))) + if libc.Int32FromUint8((**(**TColumn)(__ccgo_up(aCol + uintptr(i)*16))).FhName) == libc.Int32FromUint8(h) && _sqlite3StrICmp(tls, (**(**TColumn)(__ccgo_up(aCol + uintptr(i)*16))).FzCnName, zCol) == 0 { + return i + } + /* No lucky match from the hash table. Do a full search. */ + i = 0 + for int32(1) != 0 { + if libc.Int32FromUint8((**(**TColumn)(__ccgo_up(aCol + uintptr(i)*16))).FhName) == libc.Int32FromUint8(h) && _sqlite3StrICmp(tls, (**(**TColumn)(__ccgo_up(aCol + uintptr(i)*16))).FzCnName, zCol) == 0 { + return i + } + i = i + 1 + if i >= nCol { + break + } + } + return -int32(1) +} + +// C documentation +// +// /* +// ** Set the expression associated with a column. This is usually +// ** the DEFAULT value, but might also be the expression that computes +// ** the value for a generated column. +// */ +func _sqlite3ColumnSetExpr(tls *libc.TLS, pParse uintptr, pTab uintptr, pCol uintptr, pExpr uintptr) { + var pList uintptr + var v1 int32 + _, _ = pList, v1 + pList = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpDfltList + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) == 0 || pList == uintptr(0) || (*TExprList)(unsafe.Pointer(pList)).FnExpr < libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt) { + if pList == uintptr(0) { + v1 = int32(1) + } else { + v1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + int32(1) + } + (*TColumn)(unsafe.Pointer(pCol)).FiDflt = libc.Uint16FromInt32(v1) + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpDfltList = _sqlite3ExprListAppend(tls, pParse, pList, pExpr) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt)-int32(1))*32))).FpExpr) + (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FiDflt)-int32(1))*32))).FpExpr = pExpr + } +} + +// C documentation +// +// /* +// ** Return the declared type of a column. Or return zDflt if the column +// ** has no declared type. +// ** +// ** The column type is an extra string stored after the zero-terminator on +// ** the column name if and only if the COLFLAG_HASTYPE flag is set. +// */ +func _sqlite3ColumnType(tls *libc.TLS, pCol uintptr, zDflt uintptr) (r uintptr) { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { + return (*TColumn)(unsafe.Pointer(pCol)).FzCnName + uintptr(libc.Xstrlen(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + uintptr(1) + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) != 0 { + return _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4))-int32(1)] + } else { + return zDflt + } + } + return r +} + +// C documentation +// +// /* +// ** This routine is called when a commit occurs. +// */ +func _sqlite3CommitInternalChanges(tls *libc.TLS, db uintptr) { + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_SchemaChange)) +} + +func _sqlite3CompileOptions(tls *libc.TLS, pnOpt uintptr) (r uintptr) { + **(**int32)(__ccgo_up(pnOpt)) = libc.Int32FromUint64(libc.Uint64FromInt64(448) / libc.Uint64FromInt64(8)) + return uintptr(unsafe.Pointer(&_sqlite3azCompileOpt)) +} + +/************** End of ctime.c ***********************************************/ +/************** Begin file global.c ******************************************/ +/* +** 2008 June 13 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains definitions of global variables and constants. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** This routine generates code to finish the INSERT or UPDATE operation +// ** that was started by a prior call to sqlite3GenerateConstraintChecks. +// ** A consecutive range of registers starting at regNewData contains the +// ** rowid and the content to be inserted. +// ** +// ** The arguments to this routine should be the same as the first six +// ** arguments to sqlite3GenerateConstraintChecks. +// */ +func _sqlite3CompleteInsertion(tls *libc.TLS, pParse uintptr, pTab uintptr, iDataCur int32, iIdxCur int32, regNewData int32, aRegIdx uintptr, update_flags int32, appendBias int32, useSeekResult int32) { + var i, v2 int32 + var pIdx, v uintptr + var pik_flags Tu8 + _, _, _, _, _ = i, pIdx, pik_flags, v, v2 /* Loop counter */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* This table is not a VIEW */ + i = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + /* All REPLACE indexes are at the end of the list */ + if **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)) == 0 { + goto _1 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)), _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + } + if useSeekResult != 0 { + v2 = int32(OPFLAG_USESEEKRESULT) + } else { + v2 = 0 + } + pik_flags = libc.Uint8FromInt32(v2) + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) && !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pik_flags = libc.Uint8FromInt32(int32(pik_flags) | libc.Int32FromInt32(OPFLAG_NCHANGE)) + pik_flags = libc.Uint8FromInt32(int32(pik_flags) | update_flags&libc.Int32FromInt32(OPFLAG_SAVEPOSITION)) + if update_flags == 0 { + _codeWithoutRowidPreupdate(tls, pParse, pTab, iIdxCur+i, **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4))) + } + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x8>>3)) != 0 { + v2 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + } else { + v2 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iIdxCur+i, **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)), **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4))+int32(1), v2) + _sqlite3VdbeChangeP5(tls, v, uint16(pik_flags)) + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + i = i + 1 + } + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + return + } + if (*TParse)(unsafe.Pointer(pParse)).Fnested != 0 { + pik_flags = uint8(0) + } else { + pik_flags = uint8(OPFLAG_NCHANGE) + if update_flags != 0 { + v2 = update_flags + } else { + v2 = int32(OPFLAG_LASTROWID) + } + pik_flags = libc.Uint8FromInt32(int32(pik_flags) | v2) + } + if appendBias != 0 { + pik_flags = libc.Uint8FromInt32(int32(pik_flags) | libc.Int32FromInt32(OPFLAG_APPEND)) + } + if useSeekResult != 0 { + pik_flags = libc.Uint8FromInt32(int32(pik_flags) | libc.Int32FromInt32(OPFLAG_USESEEKRESULT)) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iDataCur, **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)), regNewData) + if !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { + _sqlite3VdbeAppendP4(tls, v, pTab, -int32(5)) + } + _sqlite3VdbeChangeP5(tls, v, uint16(pik_flags)) +} + +// C documentation +// +// /* +// ** Generate bytecode that will initialize a Bloom filter that is appropriate +// ** for pLevel. +// ** +// ** If there are inner loops within pLevel that have the WHERE_BLOOMFILTER +// ** flag set, initialize a Bloomfilter for them as well. Except don't do +// ** this recursive initialization if the SQLITE_BloomPulldown optimization has +// ** been turned off. +// ** +// ** When the Bloom filter is initialized, the WHERE_BLOOMFILTER flag is cleared +// ** from the loop, but the regFilter value is set to a register that implements +// ** the Bloom filter. When regFilter is positive, the +// ** sqlite3WhereCodeOneLoopStart() will generate code to test the Bloom filter +// ** and skip the subsequence B-Tree seek if the Bloom filter indicates that +// ** no matching rows exist. +// ** +// ** This routine may only be called if it has previously been determined that +// ** the loop would benefit from a Bloom filter, and the WHERE_BLOOMFILTER bit +// ** is set. +// */ +func _sqlite3ConstructBloomFilter(tls *libc.TLS, pWInfo uintptr, iLevel int32, pLevel uintptr, notReady TBitmask) { + var addrCont, addrOnce, addrTop, iCur, iSrc, jj, n, r1, r11, v1 int32 + var pExpr, pIdx, pItem, pLoop, pParse, pTab, pTabItem, pTabList, pTerm, pWCEnd, saved_pIdxEpr, saved_pIdxPartExpr, v, v2 uintptr + var sz Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCont, addrOnce, addrTop, iCur, iSrc, jj, n, pExpr, pIdx, pItem, pLoop, pParse, pTab, pTabItem, pTabList, pTerm, pWCEnd, r1, r11, saved_pIdxEpr, saved_pIdxPartExpr, sz, v, v1, v2 /* Last WHERE clause term */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parsing context */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* VDBE under construction */ + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop /* saved copy of Parse.pIdxPartExpr */ + saved_pIdxEpr = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr + saved_pIdxPartExpr = (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr + (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr = uintptr(0) + (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr = uintptr(0) + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + for cond := true; cond; cond = iLevel < libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) { + _sqlite3WhereExplainBloomFilter(tls, pParse, pWInfo, pLevel) + addrCont = _sqlite3VdbeMakeLabel(tls, pParse) + iCur = (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter = v1 + /* The Bloom filter is a Blob held in a register. Initialize it + ** to zero-filled blob of at least 80K bits, but maybe more if the + ** estimated size of the table is larger. We could actually + ** measure the size of the table at run-time using OP_Count with + ** P3==1 and use that value to initialize the blob. But that makes + ** testing complicated. By basing the blob size on the value in the + ** sqlite_stat1 table, testing is much easier. + */ + pTabList = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + iSrc = libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom) + pItem = pTabList + 8 + uintptr(iSrc)*80 + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + sz = _sqlite3LogEstToInt(tls, (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst) + if sz < uint64(10000) { + sz = uint64(10000) + } else { + if sz > uint64(10000000) { + sz = uint64(10000000) + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Blob), libc.Int32FromUint64(sz), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter) + addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iCur) + pWCEnd = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + uintptr((*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.FnTerm)*56 + pTerm = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + for { + if !(pTerm < pWCEnd) { + break + } + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VIRTUAL) == 0 && _sqlite3ExprIsSingleTableConstraint(tls, pExpr, pTabList, iSrc, 0) != 0 { + _sqlite3ExprIfFalse(tls, pParse, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, int32(SQLITE_JUMPIFNULL)) + } + goto _3 + _3: + ; + pTerm += 56 + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != 0 { + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iCur, r1) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0, r1, int32(1)) + _sqlite3ReleaseTempReg(tls, pParse, r1) + } else { + pIdx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + n = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) + r11 = _sqlite3GetTempRange(tls, pParse, n) + jj = 0 + for { + if !(jj < n) { + break + } + _sqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iCur, jj, r11+jj) + goto _4 + _4: + ; + jj = jj + 1 + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0, r11, n) + _sqlite3ReleaseTempRange(tls, pParse, r11, n) + } + _sqlite3VdbeResolveLabel(tls, v, addrCont) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, addrTop+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addrTop) + **(**Tu32)(__ccgo_up(pLoop + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(WHERE_BLOOMFILTER)) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_BloomPulldown)) != uint32(0) { + break + } + for { + iLevel = iLevel + 1 + v1 = iLevel + if !(v1 < libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)) { + break + } + pLevel = pWInfo + 856 + uintptr(iLevel)*112 + pTabItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0 { + continue + } + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + if pLoop == uintptr(0) { + continue + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).Fprereq¬Ready != 0 { + continue + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_BLOOMFILTER)|libc.Int32FromInt32(WHERE_COLUMN_IN)) == uint32(WHERE_BLOOMFILTER) { + /* This is a candidate for bloom-filter pull-down (early evaluation). + ** The test that WHERE_COLUMN_IN is omitted is important, as we are + ** not able to do early evaluation of bloom filters that make use of + ** the IN operator */ + break + } + } + } + _sqlite3VdbeJumpHere(tls, v, addrOnce) + (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr = saved_pIdxEpr + (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr = saved_pIdxPartExpr +} + +// C documentation +// +// /* +// ** If p2 exists and p1 and p2 have the same number of terms, then change +// ** every term of p1 to have the same sort order as p2 and return true. +// ** +// ** If p2 is NULL or p1 and p2 are different lengths, then make no changes +// ** and return false. +// ** +// ** p1 must be non-NULL. +// */ +func _sqlite3CopySortOrder(tls *libc.TLS, p1 uintptr, p2 uintptr) (r int32) { + var ii int32 + var sortFlags Tu8 + _, _ = ii, sortFlags + if p2 != 0 && (*TExprList)(unsafe.Pointer(p1)).FnExpr == (*TExprList)(unsafe.Pointer(p2)).FnExpr { + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(p1)).FnExpr) { + break + } + sortFlags = libc.Uint8FromInt32(libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(p2 + 8 + uintptr(ii)*32))).Ffg.FsortFlags) & int32(KEYINFO_ORDER_DESC)) + (*(*TExprList_item)(unsafe.Pointer(p1 + 8 + uintptr(ii)*32))).Ffg.FsortFlags = sortFlags + goto _1 + _1: + ; + ii = ii + 1 + } + return int32(1) + } else { + return 0 + } + return r +} + +// C documentation +// +// /* +// ** Allocate and return a pointer to an expression to load the column iCol +// ** from datasource iSrc in SrcList pSrc. +// */ +func _sqlite3CreateColumnExpr(tls *libc.TLS, db uintptr, pSrc uintptr, iSrc int32, iCol int32) (r uintptr) { + var p, pItem, pTab, v1 uintptr + var v2 uint64 + var v3 int32 + _, _, _, _, _, _ = p, pItem, pTab, v1, v2, v3 + p = _sqlite3ExprAlloc(tls, db, int32(TK_COLUMN), uintptr(0), 0) + if p != 0 { + pItem = pSrc + 8 + uintptr(iSrc)*80 + v1 = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + *(*uintptr)(unsafe.Pointer(p + 64)) = v1 + pTab = v1 + (*TExpr)(unsafe.Pointer(p)).FiTable = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + if int32((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FiPKey) == iCol { + (*TExpr)(unsafe.Pointer(p)).FiColumn = int16(-int32(1)) + } else { + (*TExpr)(unsafe.Pointer(p)).FiColumn = int16(iCol) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasGenerated) != uint32(0) && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + if int32((*TTable)(unsafe.Pointer(pTab)).FnCol) >= int32(64) { + v2 = libc.Uint64FromInt32(-libc.Int32FromInt32(1)) + } else { + v2 = libc.Uint64FromInt32(1)<<(*TTable)(unsafe.Pointer(pTab)).FnCol - uint64(1) + } + (*TSrcItem)(unsafe.Pointer(pItem)).FcolUsed = v2 + } else { + if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v3 = libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1) + } else { + v3 = iCol + } + **(**TBitmask)(__ccgo_up(pItem + 40)) |= libc.Uint64FromInt32(1) << v3 + } + } + } + return p +} + +func _sqlite3DbMallocSize(tls *libc.TLS, db uintptr, p uintptr) (r int32) { + if db != 0 { + if uint64(p) < uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd) { + if uint64(p) >= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) { + return int32(LOOKASIDE_SMALL) + } + if uint64(p) >= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) { + return libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + } + } + return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxSize})))(tls, p) +} + +// C documentation +// +// /* +// ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED +// ** clause is seen as part of a foreign key definition. The isDeferred +// ** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE. +// ** The behavior of the most recently created foreign key is adjusted +// ** accordingly. +// */ +func _sqlite3DeferForeignKey(tls *libc.TLS, pParse uintptr, isDeferred int32) { + var pFKey, pTab, v1 uintptr + _, _, _ = pFKey, pTab, v1 + v1 = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + pTab = v1 + if v1 == uintptr(0) { + return + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + return + } + v1 = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey + pFKey = v1 + if v1 == uintptr(0) { + return + } + /* EV: R-30323-21917 */ + (*TFKey)(unsafe.Pointer(pFKey)).FisDeferred = libc.Uint8FromInt32(isDeferred) +} + +// C documentation +// +// /* +// ** Delete memory allocated for the column names of a table or view (the +// ** Table.aCol[] array). +// */ +func _sqlite3DeleteColumnNames(tls *libc.TLS, db uintptr, pTable uintptr) { + var i int32 + var pCol, v1 uintptr + _, _, _ = i, pCol, v1 + v1 = (*TTable)(unsafe.Pointer(pTable)).FaCol + pCol = v1 + if v1 != uintptr(0) { + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTable)).FnCol)) { + break + } + _sqlite3DbFree(tls, db, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + goto _2 + _2: + ; + i = i + 1 + pCol += 16 + } + _sqlite3DbNNFreeNN(tls, db, (*TTable)(unsafe.Pointer(pTable)).FaCol) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_NORM { + _sqlite3ExprListDelete(tls, db, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTable + 64))).FpDfltList) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) { + (*TTable)(unsafe.Pointer(pTable)).FaCol = uintptr(0) + (*TTable)(unsafe.Pointer(pTable)).FnCol = 0 + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_NORM { + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTable + 64))).FpDfltList = uintptr(0) + } + } + } +} + +// C documentation +// +// /* The input list pList is the list of result set terms from a RETURNING +// ** clause. The table that we are returning from is pTab. +// ** +// ** This routine makes a copy of the pList, and at the same time expands +// ** any "*" wildcards to be the complete set of columns from pTab. +// */ +func _sqlite3ExpandReturning(tls *libc.TLS, pParse uintptr, pList uintptr, pTab uintptr) (r uintptr) { + var db, pItem, pItem1, pNew, pNewExpr, pNewExpr1, pOldExpr uintptr + var i, jj int32 + _, _, _, _, _, _, _, _, _ = db, i, jj, pItem, pItem1, pNew, pNewExpr, pNewExpr1, pOldExpr + pNew = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + pOldExpr = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr + if pOldExpr == uintptr(0) { + goto _1 + } + if _isAsteriskTerm(tls, pParse, pOldExpr) != 0 { + jj = 0 + for { + if !(jj < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(jj)*16)).FcolFlags)&int32(COLFLAG_HIDDEN) != 0 { + goto _2 + } + pNewExpr = _sqlite3Expr(tls, db, int32(TK_ID), (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(jj)*16))).FzCnName) + pNew = _sqlite3ExprListAppend(tls, pParse, pNew, pNewExpr) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + pItem = pNew + 8 + uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32 + (*TExprList_item)(unsafe.Pointer(pItem)).FzEName = _sqlite3DbStrDup(tls, db, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(jj)*16))).FzCnName) + libc.SetBitFieldPtr16Uint32(pItem+16+4, libc.Uint32FromInt32(ENAME_NAME), 0, 0x3) + } + goto _2 + _2: + ; + jj = jj + 1 + } + } else { + pNewExpr1 = _sqlite3ExprDup(tls, db, pOldExpr, 0) + pNew = _sqlite3ExprListAppend(tls, pParse, pNew, pNewExpr1) + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) && (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FzEName != uintptr(0) { + pItem1 = pNew + 8 + uintptr((*TExprList)(unsafe.Pointer(pNew)).FnExpr-int32(1))*32 + (*TExprList_item)(unsafe.Pointer(pItem1)).FzEName = _sqlite3DbStrDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FzEName) + libc.SetBitFieldPtr16Uint32(pItem1+16+4, libc.Uint32FromInt32(int32(uint32(*(*uint16)(unsafe.Pointer(pList + 8 + uintptr(i)*32 + 16 + 4))&0x3>>0))), 0, 0x3) + } + } + goto _1 + _1: + ; + i = i + 1 + } + return pNew +} + +// C documentation +// +// /* +// ** Mark every prepared statement associated with a database connection +// ** as expired. +// ** +// ** An expired statement means that recompilation of the statement is +// ** recommend. Statements expire when things happen that make their +// ** programs obsolete. Removing user-defined functions or collating +// ** sequences, or changing an authorization function are the types of +// ** things that make prepared statements obsolete. +// ** +// ** If iCode is 1, then expiration is advisory. The statement should +// ** be reprepared before being restarted, but if it is already running +// ** it is allowed to run to completion. +// ** +// ** Internally, this function just sets the Vdbe.expired flag on all +// ** prepared statements. The flag is set to 1 for an immediate expiration +// ** and set to 2 for an advisory expiration. +// */ +func _sqlite3ExpirePreparedStatements(tls *libc.TLS, db uintptr, iCode int32) { + var p uintptr + _ = p + p = (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe + for { + if !(p != 0) { + break + } + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(iCode+libc.Int32FromInt32(1)), 0, 0x3) + goto _1 + _1: + ; + p = (*TVdbe)(unsafe.Pointer(p)).FpVNext + } +} + +// C documentation +// +// /* +// ** Return FALSE if there is no chance that the expression can be NULL. +// ** +// ** If the expression might be NULL or if the expression is too complex +// ** to tell return TRUE. +// ** +// ** This routine is used as an optimization, to skip OP_IsNull opcodes +// ** when we know that a value cannot be NULL. Hence, a false positive +// ** (returning TRUE when in fact the expression can never be NULL) might +// ** be a small performance hit but is otherwise harmless. On the other +// ** hand, a false negative (returning FALSE when the result could be NULL) +// ** will likely result in an incorrect answer. So when in doubt, return +// ** TRUE. +// */ +func _sqlite3ExprCanBeNull(tls *libc.TLS, p uintptr) (r int32) { + var op Tu8 + _ = op + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UPLUS) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UMINUS) { + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + } + op = (*TExpr)(unsafe.Pointer(p)).Fop + if libc.Int32FromUint8(op) == int32(TK_REGISTER) { + op = (*TExpr)(unsafe.Pointer(p)).Fop2 + } + switch libc.Int32FromUint8(op) { + case int32(TK_INTEGER): + fallthrough + case int32(TK_STRING): + fallthrough + case int32(TK_FLOAT): + fallthrough + case int32(TK_BLOB): + return 0 + case int32(TK_COLUMN): + return libc.BoolInt32((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) != uint32(0) || *(*uintptr)(unsafe.Pointer(p + 64)) == uintptr(0) || int32((*TExpr)(unsafe.Pointer(p)).FiColumn) >= 0 && (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FaCol != uintptr(0) && int32((*TExpr)(unsafe.Pointer(p)).FiColumn) < int32((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FnCol) && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FaCol + uintptr((*TExpr)(unsafe.Pointer(p)).FiColumn)*16 + 8))&0xf>>0)) == 0) + default: + return int32(1) + } + return r +} + +// C documentation +// +// /* +// ** Generate code that pushes the value of every element of the given +// ** expression list into a sequence of registers beginning at target. +// ** +// ** Return the number of elements evaluated. The number returned will +// ** usually be pList->nExpr but might be reduced if SQLITE_ECEL_OMITREF +// ** is defined. +// ** +// ** The SQLITE_ECEL_DUP flag prevents the arguments from being +// ** filled using OP_SCopy. OP_Copy must be used instead. +// ** +// ** The SQLITE_ECEL_FACTOR argument allows constant arguments to be +// ** factored out into initialization code. +// ** +// ** The SQLITE_ECEL_REF flag means that expressions in the list with +// ** ExprList.a[].u.x.iOrderByCol>0 have already been evaluated and stored +// ** in registers at srcReg, and so the value can be copied from there. +// ** If SQLITE_ECEL_OMITREF is also set, then the values with u.x.iOrderByCol>0 +// ** are simply omitted rather than being copied from srcReg. +// */ +func _sqlite3ExprCodeExprList(tls *libc.TLS, pParse uintptr, pList uintptr, target int32, srcReg int32, flags Tu8) (r int32) { + var copyOp Tu8 + var i, inReg, j, n, v1 int32 + var pExpr, pItem, pOp, v, v5 uintptr + var v4 bool + _, _, _, _, _, _, _, _, _, _, _, _ = copyOp, i, inReg, j, n, pExpr, pItem, pOp, v, v1, v4, v5 + if libc.Int32FromUint8(flags)&int32(SQLITE_ECEL_DUP) != 0 { + v1 = int32(OP_Copy) + } else { + v1 = int32(OP_SCopy) + } + copyOp = libc.Uint8FromInt32(v1) + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* Never gets this far otherwise */ + n = (*TExprList)(unsafe.Pointer(pList)).FnExpr + if !(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x80>>7)) != 0) { + flags = libc.Uint8FromInt32(int32(flags) & ^libc.Int32FromInt32(SQLITE_ECEL_FACTOR)) + } + pItem = pList + 8 + i = libc.Int32FromInt32(0) + for { + if !(i < n) { + break + } + pExpr = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + if v4 = libc.Int32FromUint8(flags)&int32(SQLITE_ECEL_REF) != 0; v4 { + v1 = libc.Int32FromUint16((*(*struct { + FiOrderByCol Tu16 + FiAlias Tu16 + })(unsafe.Pointer(pItem + 24))).FiOrderByCol) + j = v1 + } + if v4 && v1 > 0 { + if libc.Int32FromUint8(flags)&int32(SQLITE_ECEL_OMITREF) != 0 { + i = i - 1 + n = n - 1 + } else { + _sqlite3VdbeAddOp2(tls, v, libc.Int32FromUint8(copyOp), j+srcReg-int32(1), target+i) + } + } else { + if libc.Int32FromUint8(flags)&int32(SQLITE_ECEL_FACTOR) != 0 && _sqlite3ExprIsConstantNotJoin(tls, pParse, pExpr) != 0 { + _sqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, target+i) + } else { + inReg = _sqlite3ExprCodeTarget(tls, pParse, pExpr, target+i) + if inReg != target+i { + if v4 = libc.Int32FromUint8(copyOp) == int32(OP_Copy); v4 { + v5 = _sqlite3VdbeGetLastOp(tls, v) + pOp = v5 + } + if v4 && libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(v5)).Fopcode) == int32(OP_Copy) && (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1+(*TVdbeOp)(unsafe.Pointer(pOp)).Fp3+int32(1) == inReg && (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2+(*TVdbeOp)(unsafe.Pointer(pOp)).Fp3+int32(1) == target+i && libc.Int32FromUint16((*TVdbeOp)(unsafe.Pointer(pOp)).Fp5) == 0 { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 = (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 + 1 + } else { + _sqlite3VdbeAddOp2(tls, v, libc.Int32FromUint8(copyOp), inReg, target+i) + } + } + } + } + goto _2 + _2: + ; + i = i + 1 + pItem += 32 + } + return n +} + +// C documentation +// +// /* +// ** Generate code that will evaluate expression pExpr just one time +// ** per prepared statement execution. +// ** +// ** If the expression uses functions (that might throw an exception) then +// ** guard them with an OP_Once opcode to ensure that the code is only executed +// ** once. If no functions are involved, then factor the code out and put it at +// ** the end of the prepared statement in the initialization section. +// ** +// ** If regDest>0 then the result is always stored in that register and the +// ** result is not reusable. If regDest<0 then this routine is free to +// ** store the value wherever it wants. The register where the expression +// ** is stored is returned. When regDest<0, two identical expressions might +// ** code to the same register, if they do not contain function calls and hence +// ** are factored out into the initialization section at the end of the +// ** prepared statement. +// */ +func _sqlite3ExprCodeRunJustOnce(tls *libc.TLS, pParse uintptr, pExpr uintptr, regDest int32) (r int32) { + var addr, i, v2 int32 + var p, pItem, pItem1, v, v3 uintptr + _, _, _, _, _, _, _, _ = addr, i, p, pItem, pItem1, v, v2, v3 + p = (*TParse)(unsafe.Pointer(pParse)).FpConstExpr + if regDest < 0 && p != 0 { + pItem = p + 8 + i = (*TExprList)(unsafe.Pointer(p)).FnExpr + for { + if !(i > 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pItem + 16 + 4))&0x8>>3)) != 0 && _sqlite3ExprCompare(tls, uintptr(0), (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr, pExpr, -int32(1)) == 0 { + return *(*int32)(unsafe.Pointer(pItem + 24)) + } + goto _1 + _1: + ; + pItem += 32 + i = i - 1 + } + } + pExpr = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) + if pExpr != uintptr(0) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)) != uint32(0) { + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + addr = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) + if !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { + if regDest < 0 { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v2 = *(*int32)(unsafe.Pointer(v3)) + regDest = v2 + } + _sqlite3ExprCode(tls, pParse, pExpr, regDest) + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 7, 0x80) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + _sqlite3VdbeJumpHere(tls, v, addr) + } else { + p = _sqlite3ExprListAppend(tls, pParse, p, pExpr) + if p != 0 { + pItem1 = p + 8 + uintptr((*TExprList)(unsafe.Pointer(p)).FnExpr-int32(1))*32 + libc.SetBitFieldPtr16Uint32(pItem1+16+4, libc.BoolUint32(regDest < libc.Int32FromInt32(0)), 3, 0x8) + if regDest < 0 { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v2 = *(*int32)(unsafe.Pointer(v3)) + regDest = v2 + } + *(*int32)(unsafe.Pointer(pItem1 + 24)) = regDest + } + (*TParse)(unsafe.Pointer(pParse)).FpConstExpr = p + } + return regDest +} + +// C documentation +// +// /* +// ** Generate code to evaluate an expression and store the results +// ** into a register. Return the register number where the results +// ** are stored. +// ** +// ** If the register is a temporary register that can be deallocated, +// ** then write its number into *pReg. If the result register is not +// ** a temporary, then set *pReg to zero. +// ** +// ** If pExpr is a constant, then this routine might generate this +// ** code to fill the register in the initialization section of the +// ** VDBE program, in order to factor it out of the evaluation loop. +// */ +func _sqlite3ExprCodeTemp(tls *libc.TLS, pParse uintptr, pExpr uintptr, pReg uintptr) (r int32) { + var r1, r2 int32 + _, _ = r1, r2 + pExpr = _sqlite3ExprSkipCollateAndLikely(tls, pExpr) + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x80>>7)) != 0 && pExpr != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_REGISTER) && _sqlite3ExprIsConstantNotJoin(tls, pParse, pExpr) != 0 { + **(**int32)(__ccgo_up(pReg)) = 0 + r2 = _sqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -int32(1)) + } else { + r1 = _sqlite3GetTempReg(tls, pParse) + r2 = _sqlite3ExprCodeTarget(tls, pParse, pExpr, r1) + if r2 == r1 { + **(**int32)(__ccgo_up(pReg)) = r1 + } else { + _sqlite3ReleaseTempReg(tls, pParse, r1) + **(**int32)(__ccgo_up(pReg)) = 0 + } + } + return r2 +} + +// C documentation +// +// /* +// ** The argument is guaranteed to be a non-NULL Expr node of type TK_COLUMN. +// ** return the appropriate colUsed mask. +// */ +func _sqlite3ExprColUsed(tls *libc.TLS, pExpr uintptr) (r TBitmask) { + var n int32 + var pExTab uintptr + var v1 uint64 + _, _, _ = n, pExTab, v1 + n = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + pExTab = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + if (*TTable)(unsafe.Pointer(pExTab)).FtabFlags&uint32(TF_HasGenerated) != uint32(0) && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pExTab)).FaCol + uintptr(n)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + if int32((*TTable)(unsafe.Pointer(pExTab)).FnCol) >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v1 = libc.Uint64FromInt32(-libc.Int32FromInt32(1)) + } else { + v1 = libc.Uint64FromInt32(1)<<(*TTable)(unsafe.Pointer(pExTab)).FnCol - uint64(1) + } + return v1 + } else { + if n >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + n = libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1) + } + return libc.Uint64FromInt32(1) << n + } + return r +} + +// C documentation +// +// /* +// ** Do a deep comparison of two expression trees. Return 0 if the two +// ** expressions are completely identical. Return 1 if they differ only +// ** by a COLLATE operator at the top level. Return 2 if there are differences +// ** other than the top-level COLLATE operator. +// ** +// ** If any subelement of pB has Expr.iTable==(-1) then it is allowed +// ** to compare equal to an equivalent element in pA with Expr.iTable==iTab. +// ** +// ** The pA side might be using TK_REGISTER. If that is the case and pB is +// ** not using TK_REGISTER but is otherwise equivalent, then still return 0. +// ** +// ** Sometimes this routine will return 2 even if the two expressions +// ** really are equivalent. If we cannot prove that the expressions are +// ** identical, we return 2 just to be safe. So if this routine +// ** returns 2, then you do not really know for certain if the two +// ** expressions are the same. But if you get a 0 or 1 return, then you +// ** can be sure the expressions are the same. In the places where +// ** this routine is used, it does not hurt to get an extra 2 - that +// ** just might result in some slightly slower code. But returning +// ** an incorrect 0 or 1 could lead to a malfunction. +// ** +// ** If pParse is not NULL and SQLITE_EnableQPSG is off then TK_VARIABLE +// ** terms in pA with bindings in pParse->pReprepare can be matched against +// ** literals in pB. The pParse->pVdbe->expmask bitmask is updated for +// ** each variable referenced. +// */ +func _sqlite3ExprCompare(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, iTab int32) (r int32) { + var combinedFlags Tu32 + var v1 int32 + _, _ = combinedFlags, v1 + if pA == uintptr(0) || pB == uintptr(0) { + if pB == pA { + v1 = 0 + } else { + v1 = int32(2) + } + return v1 + } + if pParse != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_VARIABLE) { + return _exprCompareVariable(tls, pParse, pA, pB) + } + combinedFlags = (*TExpr)(unsafe.Pointer(pA)).Fflags | (*TExpr)(unsafe.Pointer(pB)).Fflags + if combinedFlags&uint32(EP_IntValue) != 0 { + if (*TExpr)(unsafe.Pointer(pA)).Fflags&(*TExpr)(unsafe.Pointer(pB)).Fflags&uint32(EP_IntValue) != uint32(0) && *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pA)).Fu)) == *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pB)).Fu)) { + return 0 + } + return int32(2) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) != libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pB)).Fop) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_RAISE) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_COLLATE) && _sqlite3ExprCompare(tls, pParse, (*TExpr)(unsafe.Pointer(pA)).FpLeft, pB, iTab) < int32(2) { + return int32(1) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pB)).Fop) == int32(TK_COLLATE) && _sqlite3ExprCompare(tls, pParse, pA, (*TExpr)(unsafe.Pointer(pB)).FpLeft, iTab) < int32(2) { + return int32(1) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_AGG_COLUMN) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pB)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pB)).FiTable < 0 && (*TExpr)(unsafe.Pointer(pA)).FiTable == iTab { + /* fall through */ + } else { + return int32(2) + } + } + if *(*uintptr)(unsafe.Pointer(pA + 8)) != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_FUNCTION) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_AGG_FUNCTION) { + if _sqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8)), *(*uintptr)(unsafe.Pointer(pB + 8))) != 0 { + return int32(2) + } + if libc.BoolInt32((*TExpr)(unsafe.Pointer(pA)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0)) != libc.BoolInt32((*TExpr)(unsafe.Pointer(pB)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0)) { + return int32(2) + } + if (*TExpr)(unsafe.Pointer(pA)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + if _sqlite3WindowCompare(tls, pParse, *(*uintptr)(unsafe.Pointer(pA + 64)), *(*uintptr)(unsafe.Pointer(pB + 64)), int32(1)) != 0 { + return int32(2) + } + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_NULL) { + return 0 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_COLLATE) { + if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8)), *(*uintptr)(unsafe.Pointer(pB + 8))) != 0 { + return int32(2) + } + } else { + if *(*uintptr)(unsafe.Pointer(pB + 8)) != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) != int32(TK_COLUMN) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) != int32(TK_AGG_COLUMN) && libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8)), *(*uintptr)(unsafe.Pointer(pB + 8))) != 0 { + return int32(2) + } + } + } + } + } + if (*TExpr)(unsafe.Pointer(pA)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)|libc.Int32FromInt32(EP_Commuted)) != (*TExpr)(unsafe.Pointer(pB)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Distinct)|libc.Int32FromInt32(EP_Commuted)) { + return int32(2) + } + if combinedFlags&uint32(EP_TokenOnly) == uint32(0) { + if combinedFlags&uint32(EP_xIsSelect) != 0 { + return int32(2) + } + if combinedFlags&uint32(EP_FixedCol) == uint32(0) && _sqlite3ExprCompare(tls, pParse, (*TExpr)(unsafe.Pointer(pA)).FpLeft, (*TExpr)(unsafe.Pointer(pB)).FpLeft, iTab) != 0 { + return int32(2) + } + if _sqlite3ExprCompare(tls, pParse, (*TExpr)(unsafe.Pointer(pA)).FpRight, (*TExpr)(unsafe.Pointer(pB)).FpRight, iTab) != 0 { + return int32(2) + } + if _sqlite3ExprListCompare(tls, *(*uintptr)(unsafe.Pointer(pA + 32)), *(*uintptr)(unsafe.Pointer(pB + 32)), iTab) != 0 { + return int32(2) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) != int32(TK_STRING) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) != int32(TK_TRUEFALSE) && combinedFlags&uint32(EP_Reduced) == uint32(0) { + if int32((*TExpr)(unsafe.Pointer(pA)).FiColumn) != int32((*TExpr)(unsafe.Pointer(pB)).FiColumn) { + return int32(2) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop2) != libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pB)).Fop2) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) == int32(TK_TRUTH) { + return int32(2) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA)).Fop) != int32(TK_IN) && (*TExpr)(unsafe.Pointer(pA)).FiTable != (*TExpr)(unsafe.Pointer(pB)).FiTable && (*TExpr)(unsafe.Pointer(pA)).FiTable != iTab { + return int32(2) + } + } + } + return 0 +} + +// C documentation +// +// /* +// ** Recursively delete an expression tree. +// */ +func _sqlite3ExprDeleteNN(tls *libc.TLS, db uintptr, p uintptr) { + var pLeft uintptr + _ = pLeft + goto exprDeleteRestart +exprDeleteRestart: + ; + if !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)) { + /* The Expr.x union is never used at the same time as Expr.pRight */ + if (*TExpr)(unsafe.Pointer(p)).FpRight != 0 { + _sqlite3ExprDeleteNN(tls, db, (*TExpr)(unsafe.Pointer(p)).FpRight) + } else { + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _sqlite3SelectDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 32))) + } else { + _sqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 32))) + if (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3WindowDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 64))) + } + } + } + if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) != int32(TK_SELECT_COLUMN) { + pLeft = (*TExpr)(unsafe.Pointer(p)).FpLeft + if !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Static)) != libc.Uint32FromInt32(0)) && !((*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Static)) != libc.Uint32FromInt32(0)) { + /* Avoid unnecessary recursion on unary operators */ + _sqlite3DbNNFreeNN(tls, db, p) + p = pLeft + goto exprDeleteRestart + } else { + _sqlite3ExprDeleteNN(tls, db, pLeft) + } + } + } + if !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Static)) != libc.Uint32FromInt32(0)) { + _sqlite3DbNNFreeNN(tls, db, p) + } +} + +// C documentation +// +// /* +// ** Compute and return a new Expr object which when passed to +// ** sqlite3ExprCode() will generate all necessary code to compute +// ** the iField-th column of the vector expression pVector. +// ** +// ** It is ok for pVector to be a scalar (as long as iField==0). +// ** In that case, this routine works like sqlite3ExprDup(). +// ** +// ** The caller owns the returned Expr object and is responsible for +// ** ensuring that the returned value eventually gets freed. +// ** +// ** The caller retains ownership of pVector. If pVector is a TK_SELECT, +// ** then the returned object will reference pVector and so pVector must remain +// ** valid for the life of the returned object. If pVector is a TK_VECTOR +// ** or a scalar expression, then it can be deleted as soon as this routine +// ** returns. +// ** +// ** A trick to cause a TK_SELECT pVector to be deleted together with +// ** the returned Expr object is to attach the pVector to the pRight field +// ** of the returned TK_SELECT_COLUMN Expr object. +// */ +func _sqlite3ExprForVectorField(tls *libc.TLS, pParse uintptr, pVector uintptr, iField int32, nField int32) (r uintptr) { + var pRet, ppVector uintptr + _, _ = pRet, ppVector + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pVector)).Fop) == int32(TK_SELECT) { + /* The TK_SELECT_COLUMN Expr node: + ** + ** pLeft: pVector containing TK_SELECT. Not deleted. + ** pRight: not used. But recursively deleted. + ** iColumn: Index of a column in pVector + ** iTable: 0 or the number of columns on the LHS of an assignment + ** pLeft->iTable: First in an array of register holding result, or 0 + ** if the result is not yet computed. + ** + ** sqlite3ExprDelete() specifically skips the recursive delete of + ** pLeft on TK_SELECT_COLUMN nodes. But pRight is followed, so pVector + ** can be attached to pRight to cause this node to take ownership of + ** pVector. Typically there will be multiple TK_SELECT_COLUMN nodes + ** with the same pLeft pointer to the pVector, but only one of them + ** will own the pVector. + */ + pRet = _sqlite3PExpr(tls, pParse, int32(TK_SELECT_COLUMN), uintptr(0), uintptr(0)) + if pRet != 0 { + **(**Tu32)(__ccgo_up(pRet + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FullSize)) + (*TExpr)(unsafe.Pointer(pRet)).FiTable = nField + (*TExpr)(unsafe.Pointer(pRet)).FiColumn = int16(iField) + (*TExpr)(unsafe.Pointer(pRet)).FpLeft = pVector + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pVector)).Fop) == int32(TK_VECTOR) { + ppVector = *(*uintptr)(unsafe.Pointer(pVector + 32)) + 8 + uintptr(iField)*32 + pVector = **(**uintptr)(__ccgo_up(ppVector)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + /* This must be a vector UPDATE inside a trigger */ + **(**uintptr)(__ccgo_up(ppVector)) = uintptr(0) + return pVector + } + } + pRet = _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pVector, 0) + } + return pRet +} + +// C documentation +// +// /* +// ** Return true if we can prove the pE2 will always be true if pE1 is +// ** true. Return false if we cannot complete the proof or if pE2 might +// ** be false. Examples: +// ** +// ** pE1: x==5 pE2: x==5 Result: true +// ** pE1: x>0 pE2: x==5 Result: false +// ** pE1: x=21 pE2: x=21 OR y=43 Result: true +// ** pE1: x!=123 pE2: x IS NOT NULL Result: true +// ** pE1: x!=?1 pE2: x IS NOT NULL Result: true +// ** pE1: x IS NULL pE2: x IS NOT NULL Result: false +// ** pE1: x IS ?2 pE2: x IS NOT NULL Result: false +// ** pE1: iif(x,y) pE2: x Result: true +// ** PE1: iif(x,y,0) pE2: x Result: true +// ** +// ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has +// ** Expr.iTable<0 then assume a table number given by iTab. +// ** +// ** If pParse is not NULL, then the values of bound variables in pE1 are +// ** compared against literal values in pE2 and pParse->pVdbe->expmask is +// ** modified to record which bound variables are referenced. If pParse +// ** is NULL, then false will be returned if pE1 contains any bound variables. +// ** +// ** When in doubt, return false. Returning true might give a performance +// ** improvement. Returning false might cause a performance reduction, but +// ** it will always give the correct answer and is hence always safe. +// */ +func _sqlite3ExprImpliesExpr(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uintptr, iTab int32) (r int32) { + if _sqlite3ExprCompare(tls, pParse, pE1, pE2, iTab) == 0 { + return int32(1) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE2)).Fop) == int32(TK_OR) && (_sqlite3ExprImpliesExpr(tls, pParse, pE1, (*TExpr)(unsafe.Pointer(pE2)).FpLeft, iTab) != 0 || _sqlite3ExprImpliesExpr(tls, pParse, pE1, (*TExpr)(unsafe.Pointer(pE2)).FpRight, iTab) != 0) { + return int32(1) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE2)).Fop) == int32(TK_NOTNULL) && _exprImpliesNotNull(tls, pParse, pE1, (*TExpr)(unsafe.Pointer(pE2)).FpLeft, iTab, 0) != 0 { + return int32(1) + } + if _sqlite3ExprIsIIF(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pE1) != 0 { + return _sqlite3ExprImpliesExpr(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pE1 + 32)) + 8))).FpExpr, pE2, iTab) + } + return 0 +} + +// C documentation +// +// /* +// ** Return true (non-zero) if expression p can only be true if at least +// ** one column of table iTab is non-null. In other words, return true +// ** if expression p will always be NULL or false if every column of iTab +// ** is NULL. +// ** +// ** False negatives are acceptable. In other words, it is ok to return +// ** zero even if expression p will never be true of every column of iTab +// ** is NULL. A false negative is merely a missed optimization opportunity. +// ** +// ** False positives are not allowed, however. A false positive may result +// ** in an incorrect answer. +// ** +// ** Terms of p that are marked with EP_OuterON (and hence that come from +// ** the ON or USING clauses of OUTER JOINS) are excluded from the analysis. +// ** +// ** This routine is used to check if a LEFT JOIN can be converted into +// ** an ordinary JOIN. The p argument is the WHERE clause. If the WHERE +// ** clause requires that some column of the right table of the LEFT JOIN +// ** be non-NULL, then the LEFT JOIN can be safely converted into an +// ** ordinary join. +// */ +func _sqlite3ExprImpliesNonNullRow(tls *libc.TLS, p uintptr, iTab int32, isRJ int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + p = _sqlite3ExprSkipCollateAndLikely(tls, p) + if p == uintptr(0) { + return 0 + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_NOTNULL) { + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + } else { + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_AND) { + if _sqlite3ExprImpliesNonNullRow(tls, (*TExpr)(unsafe.Pointer(p)).FpLeft, iTab, isRJ) != 0 { + return int32(1) + } + p = (*TExpr)(unsafe.Pointer(p)).FpRight + } + } + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_impliesNotNullRow) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = uintptr(0) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(0) + (**(**TWalker)(__ccgo_up(bp))).FmWFlags = libc.BoolUint16(isRJ != 0) + *(*int32)(unsafe.Pointer(bp + 40)) = iTab + _sqlite3WalkExpr(tls, bp, p) + return libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) +} + +// C documentation +// +// /* +// ** Walk the expression tree passed as the first argument. Return non-zero +// ** if the expression consists entirely of constants or copies of terms +// ** in pGroupBy that sort with the BINARY collation sequence. +// ** +// ** This routine is used to determine if a term of the HAVING clause can +// ** be promoted into the WHERE clause. In order for such a promotion to work, +// ** the value of the HAVING clause term must be the same for all members of +// ** a "group". The requirement that the GROUP BY term must be BINARY +// ** assumes that no other collating sequence will have a finer-grained +// ** grouping than binary. In other words (A=B COLLATE binary) implies +// ** A=B in every other collating sequence. The requirement that the +// ** GROUP BY be BINARY is stricter than necessary. It would also work +// ** to promote HAVING clauses that use the same alternative collating +// ** sequence as the GROUP BY term, but that is much harder to check, +// ** alternative collating sequences are uncommon, and this is only an +// ** optimization, so we take the easy way out and simply require the +// ** GROUP BY to use the BINARY collating sequence. +// */ +func _sqlite3ExprIsConstantOrGroupBy(tls *libc.TLS, pParse uintptr, p uintptr, pGroupBy uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(1) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprNodeIsConstantOrGroupBy) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 40)) = pGroupBy + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + _sqlite3WalkExpr(tls, bp, p) + return libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) +} + +// C documentation +// +// /* +// ** If the expression p codes a constant integer that is small enough +// ** to fit in a 32-bit integer, return 1 and put the value of the integer +// ** in *pValue. If the expression is not an integer or if it is too big +// ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. +// ** +// ** If the pParse pointer is provided, then allow the expression p to be +// ** a parameter (TK_VARIABLE) that is bound to an integer. +// ** But if pParse is NULL, then p must be a pure integer literal. +// */ +func _sqlite3ExprIsInteger(tls *libc.TLS, p uintptr, pValue uintptr, pParse uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pVal uintptr + var rc int32 + var vv Tsqlite3_int64 + var _ /* v at bp+0 */ int32 + _, _, _ = pVal, rc, vv + rc = 0 + if p == uintptr(0) { + return 0 + } /* Used to only happen following on OOM */ + /* If an expression is an integer literal that fits in a signed 32-bit + ** integer, then the EP_IntValue flag will have already been set */ + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_IntValue) != 0 { + **(**int32)(__ccgo_up(pValue)) = *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(p)).Fu)) + return int32(1) + } + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) { + case int32(TK_UPLUS): + rc = _sqlite3ExprIsInteger(tls, (*TExpr)(unsafe.Pointer(p)).FpLeft, pValue, uintptr(0)) + case int32(TK_UMINUS): + **(**int32)(__ccgo_up(bp)) = 0 + if _sqlite3ExprIsInteger(tls, (*TExpr)(unsafe.Pointer(p)).FpLeft, bp, uintptr(0)) != 0 { + **(**int32)(__ccgo_up(pValue)) = -**(**int32)(__ccgo_up(bp)) + rc = int32(1) + } + case int32(TK_VARIABLE): + if pParse == uintptr(0) { + break + } + if (*TParse)(unsafe.Pointer(pParse)).FpVdbe == uintptr(0) { + break + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_EnableQPSG) != uint64(0) { + break + } + _sqlite3VdbeSetVarmask(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32((*TExpr)(unsafe.Pointer(p)).FiColumn)) + pVal = _sqlite3VdbeGetBoundValue(tls, (*TParse)(unsafe.Pointer(pParse)).FpReprepare, int32((*TExpr)(unsafe.Pointer(p)).FiColumn), uint8(SQLITE_AFF_BLOB)) + if pVal != 0 { + if Xsqlite3_value_type(tls, pVal) == int32(SQLITE_INTEGER) { + vv = Xsqlite3_value_int64(tls, pVal) + if vv == vv&int64(0x7fffffff) { /* non-negative numbers only */ + **(**int32)(__ccgo_up(pValue)) = int32(vv) + rc = int32(1) + } + } + _sqlite3ValueFree(tls, pVal) + } + default: + break + } + return rc +} + +// C documentation +// +// /* +// ** If pExpr is one of "like", "glob", "match", or "regexp", then +// ** return the corresponding SQLITE_INDEX_CONSTRAINT_xxxx value. +// ** If not, return 0. +// ** +// ** pExpr is guaranteed to be a TK_FUNCTION. +// */ +func _sqlite3ExprIsLikeOperator(tls *libc.TLS, pExpr uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(64)/libc.Uint64FromInt64(16))) { + break + } + if _sqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), _aOp[i].FzOp) == 0 { + return libc.Int32FromUint8(_aOp[i].FeOp) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Check pExpr to see if it is an constraint on the single data source +// ** pSrc = &pSrcList->a[iSrc]. In other words, check to see if pExpr +// ** constrains pSrc but does not depend on any other tables or data +// ** sources anywhere else in the query. Return true (non-zero) if pExpr +// ** is a constraint on pSrc only. +// ** +// ** This is an optimization. False negatives will perhaps cause slower +// ** queries, but false positives will yield incorrect answers. So when in +// ** doubt, return 0. +// ** +// ** To be an single-source constraint, the following must be true: +// ** +// ** (1) pExpr cannot refer to any table other than pSrc->iCursor. +// ** +// ** (2a) pExpr cannot use subqueries unless the bAllowSubq parameter is +// ** true and the subquery is non-correlated +// ** +// ** (2b) pExpr cannot use non-deterministic functions. +// ** +// ** (3) pSrc cannot be part of the left operand for a RIGHT JOIN. +// ** (Is there some way to relax this constraint?) +// ** +// ** (4) If pSrc is the right operand of a LEFT JOIN, then... +// ** (4a) pExpr must come from an ON clause.. +// ** (4b) and specifically the ON clause associated with the LEFT JOIN. +// ** +// ** (5) If pSrc is the right operand of a LEFT JOIN or the left +// ** operand of a RIGHT JOIN, then pExpr must be from the WHERE +// ** clause, not an ON clause. +// ** +// ** (6) Either: +// ** +// ** (6a) pExpr does not originate in an ON or USING clause, or +// ** +// ** (6b) The ON or USING clause from which pExpr is derived is +// ** not to the left of a RIGHT JOIN (or FULL JOIN). +// ** +// ** Without this restriction, accepting pExpr as a single-table +// ** constraint might move the the ON/USING filter expression +// ** from the left side of a RIGHT JOIN over to the right side, +// ** which leads to incorrect answers. See also restriction (9) +// ** on push-down. +// */ +func _sqlite3ExprIsSingleTableConstraint(tls *libc.TLS, pExpr uintptr, pSrcList uintptr, iSrc int32, bAllowSubq int32) (r int32) { + var jj int32 + var pSrc uintptr + _, _ = jj, pSrc + pSrc = pSrcList + 8 + uintptr(iSrc)*80 + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + return 0 /* rule (3) */ + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) { + return 0 + } /* rule (4a) */ + if *(*int32)(unsafe.Pointer(pExpr + 52)) != (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor { + return 0 + } /* rule (4b) */ + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) { + return 0 + } /* rule (5) */ + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrcList + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + jj = 0 + for { + if !(jj < iSrc) { + break + } + if *(*int32)(unsafe.Pointer(pExpr + 52)) == (*(*TSrcItem)(unsafe.Pointer(pSrcList + 8 + uintptr(jj)*80))).FiCursor { + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrcList + 8 + uintptr(jj)*80))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 { + return 0 /* restriction (6) */ + } + break + } + goto _1 + _1: + ; + jj = jj + 1 + } + } + /* Rules (1), (2a), and (2b) handled by the following: */ + return _sqlite3ExprIsTableConstant(tls, pExpr, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor, bAllowSubq) +} + +// C documentation +// +// /* +// ** Walk an expression tree. Return non-zero if the expression is constant +// ** for any single row of the table with cursor iCur. In other words, the +// ** expression must not refer to any non-deterministic function nor any +// ** table other than iCur. +// ** +// ** Consider uncorrelated subqueries to be constants if the bAllowSubq +// ** parameter is true. +// */ +func _sqlite3ExprIsTableConstant(tls *libc.TLS, p uintptr, iCur int32, bAllowSubq int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(3) + (**(**TWalker)(__ccgo_up(bp))).FpParse = uintptr(0) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprNodeIsConstant) + if bAllowSubq != 0 { + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_exprSelectWalkTableConstant) + } else { + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkFail) + } + *(*int32)(unsafe.Pointer(bp + 40)) = iCur + _sqlite3WalkExpr(tls, bp, p) + return libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode) +} + +func _sqlite3ExprListAppendGrow(tls *libc.TLS, db uintptr, pList uintptr, pExpr uintptr) (r uintptr) { + var pItem, pNew, v2 uintptr + var v1 int32 + _, _, _, _ = pItem, pNew, v1, v2 + **(**int32)(__ccgo_up(pList + 4)) *= int32(2) + pNew = _sqlite3DbRealloc(tls, db, pList, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32((*TExprList)(unsafe.Pointer(pList)).FnAlloc)*libc.Uint64FromInt64(32))) + if pNew == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3ExprDelete(tls, db, pExpr) + return uintptr(0) + } else { + pList = pNew + } + v2 = pList + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + pItem = pList + 8 + uintptr(v1)*32 + **(**TExprList_item)(__ccgo_up(pItem)) = _zeroItem + (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr = pExpr + return pList +} + +func _sqlite3ExprListAppendNew(tls *libc.TLS, db uintptr, pExpr uintptr) (r uintptr) { + var pItem, pList uintptr + _, _ = pItem, pList + pList = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32(libc.Int32FromInt32(4))*libc.Uint64FromInt64(32))) + if pList == uintptr(0) { + _sqlite3ExprDelete(tls, db, pExpr) + return uintptr(0) + } + (*TExprList)(unsafe.Pointer(pList)).FnAlloc = int32(4) + (*TExprList)(unsafe.Pointer(pList)).FnExpr = int32(1) + pItem = pList + 8 + **(**TExprList_item)(__ccgo_up(pItem)) = _zeroItem + (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr = pExpr + return pList +} + +// C documentation +// +// /* +// ** Compare two ExprList objects. Return 0 if they are identical, 1 +// ** if they are certainly different, or 2 if it is not possible to +// ** determine if they are identical or not. +// ** +// ** If any subelement of pB has Expr.iTable==(-1) then it is allowed +// ** to compare equal to an equivalent element in pA with Expr.iTable==iTab. +// ** +// ** This routine might return non-zero for equivalent ExprLists. The +// ** only consequence will be disabled optimizations. But this routine +// ** must never return 0 if the two ExprList objects are different, or +// ** a malfunction will result. +// ** +// ** Two NULL pointers are considered to be the same. But a NULL pointer +// ** always differs from a non-NULL pointer. +// */ +func _sqlite3ExprListCompare(tls *libc.TLS, pA uintptr, pB uintptr, iTab int32) (r int32) { + var i, res, v2 int32 + var pExprA, pExprB uintptr + _, _, _, _, _ = i, pExprA, pExprB, res, v2 + if pA == uintptr(0) && pB == uintptr(0) { + return 0 + } + if pA == uintptr(0) || pB == uintptr(0) { + return int32(1) + } + if (*TExprList)(unsafe.Pointer(pA)).FnExpr != (*TExprList)(unsafe.Pointer(pB)).FnExpr { + return int32(1) + } + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pA)).FnExpr) { + break + } + pExprA = (*(*TExprList_item)(unsafe.Pointer(pA + 8 + uintptr(i)*32))).FpExpr + pExprB = (*(*TExprList_item)(unsafe.Pointer(pB + 8 + uintptr(i)*32))).FpExpr + if libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pA + 8 + uintptr(i)*32))).Ffg.FsortFlags) != libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pB + 8 + uintptr(i)*32))).Ffg.FsortFlags) { + return int32(1) + } + v2 = _sqlite3ExprCompare(tls, uintptr(0), pExprA, pExprB, iTab) + res = v2 + if v2 != 0 { + return res + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +func _sqlite3ExprListDup(tls *libc.TLS, db uintptr, p uintptr, flags int32) (r uintptr) { + var i int32 + var pItem, pNew, pNewExpr, pOldExpr, pOldItem, pPriorSelectColNew, pPriorSelectColOld, v2 uintptr + var v3 bool + _, _, _, _, _, _, _, _, _, _ = i, pItem, pNew, pNewExpr, pOldExpr, pOldItem, pPriorSelectColNew, pPriorSelectColOld, v2, v3 + pPriorSelectColOld = uintptr(0) + pPriorSelectColNew = uintptr(0) + if p == uintptr(0) { + return uintptr(0) + } + pNew = _sqlite3DbMallocRawNN(tls, db, libc.Uint64FromInt32(_sqlite3DbMallocSize(tls, db, p))) + if pNew == uintptr(0) { + return uintptr(0) + } + (*TExprList)(unsafe.Pointer(pNew)).FnExpr = (*TExprList)(unsafe.Pointer(p)).FnExpr + (*TExprList)(unsafe.Pointer(pNew)).FnAlloc = (*TExprList)(unsafe.Pointer(p)).FnAlloc + pItem = pNew + 8 + pOldItem = p + 8 + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(p)).FnExpr) { + break + } + pOldExpr = (*TExprList_item)(unsafe.Pointer(pOldItem)).FpExpr + (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr = _sqlite3ExprDup(tls, db, pOldExpr, flags) + if v3 = pOldExpr != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pOldExpr)).Fop) == int32(TK_SELECT_COLUMN); v3 { + v2 = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + pNewExpr = v2 + } + if v3 && v2 != uintptr(0) { + if (*TExpr)(unsafe.Pointer(pNewExpr)).FpRight != 0 { + pPriorSelectColOld = (*TExpr)(unsafe.Pointer(pOldExpr)).FpRight + pPriorSelectColNew = (*TExpr)(unsafe.Pointer(pNewExpr)).FpRight + (*TExpr)(unsafe.Pointer(pNewExpr)).FpLeft = (*TExpr)(unsafe.Pointer(pNewExpr)).FpRight + } else { + if (*TExpr)(unsafe.Pointer(pOldExpr)).FpLeft != pPriorSelectColOld { + pPriorSelectColOld = (*TExpr)(unsafe.Pointer(pOldExpr)).FpLeft + pPriorSelectColNew = _sqlite3ExprDup(tls, db, pPriorSelectColOld, flags) + (*TExpr)(unsafe.Pointer(pNewExpr)).FpRight = pPriorSelectColNew + } + (*TExpr)(unsafe.Pointer(pNewExpr)).FpLeft = pPriorSelectColNew + } + } + (*TExprList_item)(unsafe.Pointer(pItem)).FzEName = _sqlite3DbStrDup(tls, db, (*TExprList_item)(unsafe.Pointer(pOldItem)).FzEName) + (*TExprList_item)(unsafe.Pointer(pItem)).Ffg = (*TExprList_item)(unsafe.Pointer(pOldItem)).Ffg + (*TExprList_item)(unsafe.Pointer(pItem)).Fu = (*TExprList_item)(unsafe.Pointer(pOldItem)).Fu + goto _1 + _1: + ; + i = i + 1 + pItem += 32 + pOldItem += 32 + } + return pNew +} + +// C documentation +// +// /* +// ** Set the ExprList.a[].zEName element of the most recently added item +// ** on the expression list. +// ** +// ** pList might be NULL following an OOM error. But pName should never be +// ** NULL. If a memory allocation fails, the pParse->db->mallocFailed flag +// ** is set. +// */ +func _sqlite3ExprListSetName(tls *libc.TLS, pParse uintptr, pList uintptr, pName uintptr, dequote int32) { + var pItem uintptr + _ = pItem + if pList != 0 { + pItem = pList + 8 + uintptr((*TExprList)(unsafe.Pointer(pList)).FnExpr-int32(1))*32 + (*TExprList_item)(unsafe.Pointer(pItem)).FzEName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TToken)(unsafe.Pointer(pName)).Fz, uint64((*TToken)(unsafe.Pointer(pName)).Fn)) + if dequote != 0 { + /* If dequote==0, then pName->z does not point to part of a DDL + ** statement handled by the parser. And so no token need be added + ** to the token-map. */ + _sqlite3Dequote(tls, (*TExprList_item)(unsafe.Pointer(pItem)).FzEName) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, (*TExprList_item)(unsafe.Pointer(pItem)).FzEName, pName) + } + } + } +} + +// C documentation +// +// /* +// ** Set the sort order for the last element on the given ExprList. +// */ +func _sqlite3ExprListSetSortOrder(tls *libc.TLS, p uintptr, iSortOrder int32, eNulls int32) { + var pItem, v1 uintptr + _, _ = pItem, v1 + if p == uintptr(0) { + return + } + pItem = p + 8 + uintptr((*TExprList)(unsafe.Pointer(p)).FnExpr-int32(1))*32 + if iSortOrder == -int32(1) { + iSortOrder = SQLITE_SO_ASC + } + (*TExprList_item)(unsafe.Pointer(pItem)).Ffg.FsortFlags = libc.Uint8FromInt32(iSortOrder) + if eNulls != -int32(1) { + libc.SetBitFieldPtr16Uint32(pItem+16+4, libc.Uint32FromInt32(1), 5, 0x20) + if iSortOrder != eNulls { + v1 = pItem + 16 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(KEYINFO_ORDER_BIGNULL)) + } + } +} + +// C documentation +// +// /* +// ** Set the error offset for an Expr node, if possible. +// */ +func _sqlite3ExprSetErrorOffset(tls *libc.TLS, pExpr uintptr, iOfst int32) { + if pExpr == uintptr(0) { + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)|libc.Int32FromInt32(EP_OuterON)) != uint32(0) { + return + } + *(*int32)(unsafe.Pointer(pExpr + 52)) = iOfst +} + +// C documentation +// +// /* +// ** Skip over any TK_COLLATE operators and/or any unlikely() +// ** or likelihood() or likely() functions at the root of an +// ** expression. +// */ +func _sqlite3ExprSkipCollateAndLikely(tls *libc.TLS, pExpr uintptr) (r uintptr) { + for pExpr != 0 && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Skip)|libc.Int32FromInt32(EP_Unlikely)) != uint32(0) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Unlikely)) != uint32(0) { + pExpr = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE) { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + } else { + break + } + } + } + return pExpr +} + +// C documentation +// +// /* +// ** If the expression passed as the only argument is of type TK_VECTOR +// ** return the number of expressions in the vector. Or, if the expression +// ** is a sub-select, return the number of columns in the sub-select. For +// ** any other type of expression, return 1. +// */ +func _sqlite3ExprVectorSize(tls *libc.TLS, pExpr uintptr) (r int32) { + var op Tu8 + _ = op + op = (*TExpr)(unsafe.Pointer(pExpr)).Fop + if libc.Int32FromUint8(op) == int32(TK_REGISTER) { + op = (*TExpr)(unsafe.Pointer(pExpr)).Fop2 + } + if libc.Int32FromUint8(op) == int32(TK_VECTOR) { + return (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr + } else { + if libc.Int32FromUint8(op) == int32(TK_SELECT) { + return (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList)).FnExpr + } else { + return int32(1) + } + } + return r +} + +// C documentation +// +// /* +// ** Parameter zName points to a UTF-8 encoded string nName bytes long. +// ** Return the CollSeq* pointer for the collation sequence named zName +// ** for the encoding 'enc' from the database 'db'. +// ** +// ** If the entry specified is not found and 'create' is true, then create a +// ** new entry. Otherwise return NULL. +// ** +// ** A separate function sqlite3LocateCollSeq() is a wrapper around +// ** this routine. sqlite3LocateCollSeq() invokes the collation factory +// ** if necessary and generates an error message if the collating sequence +// ** cannot be found. +// ** +// ** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq() +// */ +func _sqlite3FindCollSeq(tls *libc.TLS, db uintptr, enc Tu8, zName uintptr, create int32) (r uintptr) { + var pColl uintptr + _ = pColl + if zName != 0 { + pColl = _findCollSeqEntry(tls, db, zName, create) + if pColl != 0 { + pColl = pColl + uintptr(libc.Int32FromUint8(enc)-int32(1))*40 + } + } else { + pColl = (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl + } + return pColl +} + +// C documentation +// +// /* +// ** This routine is called after a single SQL statement has been +// ** parsed and a VDBE program to execute that statement has been +// ** prepared. This routine puts the finishing touches on the +// ** VDBE program and resets the pParse structure for the next +// ** parse. +// ** +// ** Note that if an error occurred, it might be the case that +// ** no VDBE code was generated. +// */ +func _sqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { + var addrRewind, i, iDb, reg, v2 int32 + var db, pEL, pRet, pReturning, pSchema, v, vtab uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = addrRewind, db, i, iDb, pEL, pRet, pReturning, pSchema, reg, v, vtab, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).Fnested != 0 { + return + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM) + } + return + } + /* Begin by generating some termination code at the end of the + ** vdbe program + */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if v == uintptr(0) { + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_DONE) + return + } + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) + } + } + if v != 0 { + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { + pReturning = (*(*struct { + FpReturning uintptr + })(unsafe.Pointer(&(*TParse)(unsafe.Pointer(pParse)).Fu1))).FpReturning + if (*TReturning)(unsafe.Pointer(pReturning)).FnRetCol != 0 { + _sqlite3VdbeAddOp0(tls, v, int32(OP_FkCheck)) + addrRewind = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur) + reg = (*TReturning)(unsafe.Pointer(pReturning)).FiRetReg + i = 0 + for { + if !(i < (*TReturning)(unsafe.Pointer(pReturning)).FnRetCol) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur, i, reg+i) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), reg, i) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur, addrRewind+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addrRewind) + } + } + _sqlite3VdbeAddOp0(tls, v, int32(OP_Halt)) + /* The cookie mask contains one bit for each database file open. + ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are + ** set for each database that is used. Generate code to start a + ** transaction on each used database and to verify the schema cookie + ** on each used database. + */ + _sqlite3VdbeJumpHere(tls, v, 0) + iDb = 0 + for { + if libc.BoolInt32((*TParse)(unsafe.Pointer(pParse)).FcookieMask&(libc.Uint32FromInt32(1)<>3)) != 0 { + pRet = (*(*struct { + FpReturning uintptr + })(unsafe.Pointer(&(*TParse)(unsafe.Pointer(pParse)).Fu1))).FpReturning + if (*TReturning)(unsafe.Pointer(pRet)).FnRetCol != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TReturning)(unsafe.Pointer(pRet)).FiRetCur, (*TReturning)(unsafe.Pointer(pRet)).FnRetCol) + } + } + /* Finally, jump back to the beginning of the executable code. */ + _sqlite3VdbeGoto(tls, v, int32(1)) + } + /* Get the VDBE program ready for execution + */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + /* A minimum of one cursor is required if autoincrement is used + * See ticket [a696379c1f08866] */ + _sqlite3VdbeMakeReady(tls, v, pParse) + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_DONE) + } else { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) + } +} + +// C documentation +// +// /* +// ** This function is called when inserting, deleting or updating a row of +// ** table pTab to generate VDBE code to perform foreign key constraint +// ** processing for the operation. +// ** +// ** For a DELETE operation, parameter regOld is passed the index of the +// ** first register in an array of (pTab->nCol+1) registers containing the +// ** rowid of the row being deleted, followed by each of the column values +// ** of the row being deleted, from left to right. Parameter regNew is passed +// ** zero in this case. +// ** +// ** For an INSERT operation, regOld is passed zero and regNew is passed the +// ** first register of an array of (pTab->nCol+1) registers containing the new +// ** row data. +// ** +// ** For an UPDATE operation, this function is called twice. Once before +// ** the original record is deleted from the table using the calling convention +// ** described for DELETE. Then again after the original record is deleted +// ** but before the new record is inserted using the INSERT convention. +// */ +func _sqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, regNew int32, aChange uintptr, bChngRowid int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var aiCol, db, pFKey, pItem, pSrc, pTo, v, zCol, zDb, v7 uintptr + var bIgnore, eAction, i, iDb, iFromCol, iJump, iReg, isIgnoreErrors, rcauth, v4 int32 + var _ /* aiCol at bp+32 */ uintptr + var _ /* aiFree at bp+8 */ uintptr + var _ /* iCol at bp+16 */ int32 + var _ /* pIdx at bp+0 */ uintptr + var _ /* pIdx at bp+24 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aiCol, bIgnore, db, eAction, i, iDb, iFromCol, iJump, iReg, isIgnoreErrors, pFKey, pItem, pSrc, pTo, rcauth, v, zCol, zDb, v4, v7 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Name of database containing pTab */ + isIgnoreErrors = int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x1 >> 0)) + /* Exactly one of regOld and regNew should be non-zero. */ + /* If foreign-keys are disabled, this function is a no-op. */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) == uint64(0) { + return + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + return + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Loop through all the foreign key constraints for which pTab is the + ** child table (the table that the foreign key definition is part of). */ + pFKey = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey + for { + if !(pFKey != 0) { + break + } /* Parent table of foreign key pFKey */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Index on key columns in pTo */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + bIgnore = 0 + if aChange != 0 && Xsqlite3_stricmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, (*TFKey)(unsafe.Pointer(pFKey)).FzTo) != 0 && _fkChildIsModified(tls, pTab, pFKey, aChange, bChngRowid) == 0 { + goto _1 + } + /* Find the parent table of this foreign key. Also find a unique index + ** on the parent key columns in the parent table. If either of these + ** schema items cannot be located, set an error in pParse and return + ** early. */ + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x1>>0)) != 0 { + pTo = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFKey)).FzTo, zDb) + } else { + pTo = _sqlite3LocateTable(tls, pParse, uint32(0), (*TFKey)(unsafe.Pointer(pFKey)).FzTo, zDb) + } + if !(pTo != 0) || _sqlite3FkLocateIndex(tls, pParse, pTo, pFKey, bp, bp+8) != 0 { + if !(isIgnoreErrors != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + if pTo == uintptr(0) { + /* If isIgnoreErrors is true, then a table is being dropped. In this + ** case SQLite runs a "DELETE FROM xxx" on the table being dropped + ** before actually dropping it in order to check FK constraints. + ** If the parent table of an FK constraint on the current table is + ** missing, behave as if it is empty. i.e. decrement the relevant + ** FK counter for each row of the current table with non-NULL keys. + */ + v = _sqlite3GetVdbe(tls, pParse) + iJump = _sqlite3VdbeCurrentAddr(tls, v) + (*TFKey)(unsafe.Pointer(pFKey)).FnCol + int32(1) + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + iFromCol = (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FiFrom + iReg = int32(_sqlite3TableColumnToStorage(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, int16(iFromCol))) + regOld + int32(1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), iReg, iJump) + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_FkCounter), libc.Int32FromUint8((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred), -int32(1)) + } + goto _1 + } + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + aiCol = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + **(**int32)(__ccgo_up(bp + 16)) = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom + aiCol = bp + 16 + } + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + if **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + **(**int32)(__ccgo_up(aiCol + uintptr(i)*4)) = -int32(1) + } + /* Request permission to read the parent key columns. If the + ** authorization callback returns SQLITE_IGNORE, behave as if any + ** values read from the parent table are NULL. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FxAuth != 0 { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v4 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaiColumn + uintptr(i)*2))) + } else { + v4 = int32((*TTable)(unsafe.Pointer(pTo)).FiPKey) + } + zCol = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTo)).FaCol + uintptr(v4)*16))).FzCnName + rcauth = _sqlite3AuthReadCol(tls, pParse, (*TTable)(unsafe.Pointer(pTo)).FzName, zCol, iDb) + bIgnore = libc.BoolInt32(rcauth == int32(SQLITE_IGNORE)) + } + goto _3 + _3: + ; + i = i + 1 + } + /* Take a shared-cache advisory read-lock on the parent table. Allocate + ** a cursor to use to search the unique index on the parent key columns + ** in the parent table. */ + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTo)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTo)).FzName) + (*TParse)(unsafe.Pointer(pParse)).FnTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + 1 + if regOld != 0 { + /* A row is being removed from the child table. Search for the parent. + ** If the parent does not exist, removing the child row resolves an + ** outstanding foreign key constraint violation. */ + _fkLookupParent(tls, pParse, iDb, pTo, **(**uintptr)(__ccgo_up(bp)), pFKey, aiCol, regOld, -int32(1), bIgnore) + } + if regNew != 0 && !(_isSetNullAction(tls, pParse, pFKey) != 0) { + /* A row is being added to the child table. If a parent row cannot + ** be found, adding the child row has violated the FK constraint. + ** + ** If this operation is being performed as part of a trigger program + ** that is actually a "SET NULL" action belonging to this very + ** foreign key, then omit this scan altogether. As all child key + ** values are guaranteed to be NULL, it is not possible for adding + ** this row to cause an FK violation. */ + _fkLookupParent(tls, pParse, iDb, pTo, **(**uintptr)(__ccgo_up(bp)), pFKey, aiCol, regNew, +libc.Int32FromInt32(1), bIgnore) + } + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 8))) + goto _1 + _1: + ; + pFKey = (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom + } + /* Loop through all the foreign key constraints that refer to this table. + ** (the "child" constraints) */ + pFKey = _sqlite3FkReferences(tls, pTab) + for { + if !(pFKey != 0) { + break + } + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + if aChange != 0 && _fkParentIsModified(tls, pTab, pFKey, aChange, bChngRowid) == 0 { + goto _5 + } + if !((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred != 0) && !((*Tsqlite3)(unsafe.Pointer(db)).Fflags&libc.Uint64FromInt32(SQLITE_DeferFKs) != 0) && !((*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0) && !((*TParse)(unsafe.Pointer(pParse)).FisMultiWrite != 0) { + /* Inserting a single row into a parent table cannot cause (or fix) + ** an immediate foreign key violation. So do nothing in this case. */ + goto _5 + } + if _sqlite3FkLocateIndex(tls, pParse, pTab, pFKey, bp+24, bp+32) != 0 { + if !(isIgnoreErrors != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + goto _5 + } + /* Create a SrcList structure containing the child table. We need the + ** child table as a SrcList for sqlite3WhereBegin() */ + pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + if pSrc != 0 { + pItem = pSrc + 8 + (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab = (*TFKey)(unsafe.Pointer(pFKey)).FpFrom + (*TSrcItem)(unsafe.Pointer(pItem)).FzName = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName + (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FnTabRef = (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FnTabRef + 1 + v7 = pParse + 56 + v4 = *(*int32)(unsafe.Pointer(v7)) + *(*int32)(unsafe.Pointer(v7)) = *(*int32)(unsafe.Pointer(v7)) + 1 + (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor = v4 + if regNew != 0 { + _fkScanChildren(tls, pParse, pSrc, pTab, **(**uintptr)(__ccgo_up(bp + 24)), pFKey, **(**uintptr)(__ccgo_up(bp + 32)), regNew, -int32(1)) + } + if regOld != 0 { + eAction = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pFKey + 45 + libc.BoolUintptr(aChange != uintptr(0))))) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008))<" is executed before dropping +// ** the table from the database. Triggers are disabled while running this +// ** DELETE, but foreign key actions are not. +// */ +func _sqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uintptr) { + var db, p, v uintptr + var iSkip int32 + _, _, _, _ = db, iSkip, p, v + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM { + iSkip = 0 + v = _sqlite3GetVdbe(tls, pParse) + /* VDBE has already been allocated */ + if _sqlite3FkReferences(tls, pTab) == uintptr(0) { + p = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey + for { + if !(p != 0) { + break + } + if (*TFKey)(unsafe.Pointer(p)).FisDeferred != 0 || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0 { + break + } + goto _1 + _1: + ; + p = (*TFKey)(unsafe.Pointer(p)).FpNextFrom + } + if !(p != 0) { + return + } + iSkip = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_FkIfZero), int32(1), iSkip) + } + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 0, 0x1) + _sqlite3DeleteFrom(tls, pParse, _sqlite3SrcListDup(tls, db, pName, 0), uintptr(0), uintptr(0), uintptr(0)) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 0, 0x1) + /* If the DELETE has generated immediate foreign key constraint + ** violations, halt the VDBE and return an error at this point, before + ** any modifications to the schema are made. This is because statement + ** transactions are not able to rollback schema changes. + ** + ** If the SQLITE_DeferFKs flag is set, then this is not required, as + ** the statement transaction will not be rolled back even if FK + ** constraints are violated. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) == uint64(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_FkIfZero), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3HaltConstraint(tls, pParse, libc.Int32FromInt32(SQLITE_CONSTRAINT)|libc.Int32FromInt32(3)< int32(31) { + v3 = uint32(0xffffffff) + } else { + v3 = libc.Uint32FromInt32(1) << (*(*TsColMap)(unsafe.Pointer(p + 64 + uintptr(i)*16))).FiFrom + } + mask = mask | v3 + goto _2 + _2: + ; + i = i + 1 + } + goto _1 + _1: + ; + p = (*TFKey)(unsafe.Pointer(p)).FpNextFrom + } + p = _sqlite3FkReferences(tls, pTab) + for { + if !(p != 0) { + break + } + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _sqlite3FkLocateIndex(tls, pParse, pTab, p, bp, uintptr(0)) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnKeyCol)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaiColumn + uintptr(i)*2))) > int32(31) { + v3 = uint32(0xffffffff) + } else { + v3 = libc.Uint32FromInt32(1) << **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaiColumn + uintptr(i)*2)) + } + mask = mask | v3 + goto _5 + _5: + ; + i = i + 1 + } + } + goto _4 + _4: + ; + p = (*TFKey)(unsafe.Pointer(p)).FpNextTo + } + } + return mask +} + +// C documentation +// +// /* +// ** This function is called before generating code to update or delete a +// ** row contained in table pTab. If the operation is a DELETE, then +// ** parameter aChange is passed a NULL value. For an UPDATE, aChange points +// ** to an array of size N, where N is the number of columns in table pTab. +// ** If the i'th column is not modified by the UPDATE, then the corresponding +// ** entry in the aChange[] array is set to -1. If the column is modified, +// ** the value is 0 or greater. Parameter chngRowid is set to true if the +// ** UPDATE statement modifies the rowid fields of the table. +// ** +// ** If any foreign key processing will be required, this function returns +// ** non-zero. If there is no foreign key related processing, this function +// ** returns zero. +// ** +// ** For an UPDATE, this function returns 2 if: +// ** +// ** * There are any FKs for which pTab is the child and the parent table +// ** and any FK processing at all is required (even of a different FK), or +// ** +// ** * the UPDATE modifies one or more parent keys for which the action is +// ** not "NO ACTION" (i.e. is CASCADE, SET DEFAULT or SET NULL). +// ** +// ** Or, assuming some other foreign key processing is required, 1. +// */ +func _sqlite3FkRequired(tls *libc.TLS, pParse uintptr, pTab uintptr, aChange uintptr, chngRowid int32) (r int32) { + var bHaveFK, eRet, v3 int32 + var p uintptr + _, _, _, _ = bHaveFK, eRet, p, v3 + eRet = int32(1) /* Value to return if bHaveFK is true */ + bHaveFK = 0 /* If FK processing is required */ + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM { + if !(aChange != 0) { + /* A DELETE operation. Foreign key processing is required if the + ** table in question is either the child or parent table for any + ** foreign key constraint. */ + bHaveFK = libc.BoolInt32(_sqlite3FkReferences(tls, pTab) != 0 || (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey != 0) + } else { + /* Check if any child key columns are being modified. */ + p = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey + for { + if !(p != 0) { + break + } + if _fkChildIsModified(tls, pTab, p, aChange, chngRowid) != 0 { + if 0 == Xsqlite3_stricmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, (*TFKey)(unsafe.Pointer(p)).FzTo) { + eRet = int32(2) + } + bHaveFK = int32(1) + } + goto _1 + _1: + ; + p = (*TFKey)(unsafe.Pointer(p)).FpNextFrom + } + /* Check if any parent key columns are being modified. */ + p = _sqlite3FkReferences(tls, pTab) + for { + if !(p != 0) { + break + } + if _fkParentIsModified(tls, pTab, p, aChange, chngRowid) != 0 { + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008))<n count. +// */ +func _sqlite3Fts5BufferAppendString(tls *libc.TLS, pRc uintptr, pBuf uintptr, zStr uintptr) { + var nStr int32 + _ = nStr + nStr = libc.Int32FromUint64(libc.Xstrlen(tls, zStr)) + _sqlite3Fts5BufferAppendBlob(tls, pRc, pBuf, libc.Uint32FromInt32(nStr+int32(1)), zStr) + (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn = (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn - 1 +} + +// C documentation +// +// /* +// ** Encode value iVal as an SQLite varint and append it to the buffer object +// ** pBuf. If an OOM error occurs, set the error code in p. +// */ +func _sqlite3Fts5BufferAppendVarint(tls *libc.TLS, pRc uintptr, pBuf uintptr, iVal Ti64) { + var v1 int32 + _ = v1 + if libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)+libc.Uint32FromInt32(libc.Int32FromInt32(9)) <= libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) { + v1 = 0 + } else { + v1 = _sqlite3Fts5BufferSize(tls, pRc, pBuf, libc.Uint32FromInt32(int32(9)+(*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + } + if v1 != 0 { + return + } + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), libc.Uint64FromInt64(iVal)) +} + +func _sqlite3Fts5HashScanEntry(tls *libc.TLS, pHash uintptr, pzTerm uintptr, pnTerm uintptr, ppDoclist uintptr, pnDoclist uintptr) { + var nTerm int32 + var p, zKey, v1 uintptr + _, _, _, _ = nTerm, p, zKey, v1 + v1 = (*TFts5Hash)(unsafe.Pointer(pHash)).FpScan + p = v1 + if v1 != 0 { + zKey = p + 1*48 + nTerm = (*TFts5HashEntry)(unsafe.Pointer(p)).FnKey + _fts5HashAddPoslistSize(tls, pHash, p, uintptr(0)) + **(**uintptr)(__ccgo_up(pzTerm)) = zKey + **(**int32)(__ccgo_up(pnTerm)) = nTerm + **(**uintptr)(__ccgo_up(ppDoclist)) = zKey + uintptr(nTerm) + **(**int32)(__ccgo_up(pnDoclist)) = libc.Int32FromUint64(libc.Uint64FromInt32((*TFts5HashEntry)(unsafe.Pointer(p)).FnData) - (uint64(48) + libc.Uint64FromInt32(nTerm))) + } else { + **(**uintptr)(__ccgo_up(pzTerm)) = uintptr(0) + **(**int32)(__ccgo_up(pnTerm)) = 0 + **(**uintptr)(__ccgo_up(ppDoclist)) = uintptr(0) + **(**int32)(__ccgo_up(pnDoclist)) = 0 + } +} + +/* +** 2014 May 31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Low level access to the FTS index stored in the database file. The +** routines in this file file implement all read and write access to the +** %_data table. Other parts of the system access this functionality via +** the interface defined in fts5Int.h. + */ + +/* #include "fts5Int.h" */ + +/* +** Overview: +** +** The %_data table contains all the FTS indexes for an FTS5 virtual table. +** As well as the main term index, there may be up to 31 prefix indexes. +** The format is similar to FTS3/4, except that: +** +** * all segment b-tree leaf data is stored in fixed size page records +** (e.g. 1000 bytes). A single doclist may span multiple pages. Care is +** taken to ensure it is possible to iterate in either direction through +** the entries in a doclist, or to seek to a specific entry within a +** doclist, without loading it into memory. +** +** * large doclists that span many pages have associated "doclist index" +** records that contain a copy of the first rowid on each page spanned by +** the doclist. This is used to speed up seek operations, and merges of +** large doclists with very small doclists. +** +** * extra fields in the "structure record" record the state of ongoing +** incremental merge operations. +** + */ + +/* +** There are two versions of the format used for the structure record: +** +** 1. the legacy format, that may be read by all fts5 versions, and +** +** 2. the V2 format, which is used by contentless_delete=1 databases. +** +** Both begin with a 4-byte "configuration cookie" value. Then, a legacy +** format structure record contains a varint - the number of levels in +** the structure. Whereas a V2 structure record contains the constant +** 4 bytes [0xff 0x00 0x00 0x01]. This is unambiguous as the value of a +** varint has to be at least 16256 to begin with "0xFF". And the default +** maximum number of levels is 64. +** +** See below for more on structure record formats. + */ + +/* +** Details: +** +** The %_data table managed by this module, +** +** CREATE TABLE %_data(id INTEGER PRIMARY KEY, block BLOB); +** +** , contains the following 6 types of records. See the comments surrounding +** the FTS5_*_ROWID macros below for a description of how %_data rowids are +** assigned to each fo them. +** +** 1. Structure Records: +** +** The set of segments that make up an index - the index structure - are +** recorded in a single record within the %_data table. The record consists +** of a single 32-bit configuration cookie value followed by a list of +** SQLite varints. +** +** If the structure record is a V2 record, the configuration cookie is +** followed by the following 4 bytes: [0xFF 0x00 0x00 0x01]. +** +** Next, the record continues with three varints: +** +** + number of levels, +** + total number of segments on all levels, +** + value of write counter. +** +** Then, for each level from 0 to nMax: +** +** + number of input segments in ongoing merge. +** + total number of segments in level. +** + for each segment from oldest to newest: +** + segment id (always > 0) +** + first leaf page number (often 1, always greater than 0) +** + final leaf page number +** +** Then, for V2 structures only: +** +** + lower origin counter value, +** + upper origin counter value, +** + the number of tombstone hash pages. +** +** 2. The Averages Record: +** +** A single record within the %_data table. The data is a list of varints. +** The first value is the number of rows in the index. Then, for each column +** from left to right, the total number of tokens in the column for all +** rows of the table. +** +** 3. Segment leaves: +** +** TERM/DOCLIST FORMAT: +** +** Most of each segment leaf is taken up by term/doclist data. The +** general format of term/doclist, starting with the first term +** on the leaf page, is: +** +** varint : size of first term +** blob: first term data +** doclist: first doclist +** zero-or-more { +** varint: number of bytes in common with previous term +** varint: number of bytes of new term data (nNew) +** blob: nNew bytes of new term data +** doclist: next doclist +** } +** +** doclist format: +** +** varint: first rowid +** poslist: first poslist +** zero-or-more { +** varint: rowid delta (always > 0) +** poslist: next poslist +** } +** +** poslist format: +** +** varint: size of poslist in bytes multiplied by 2, not including +** this field. Plus 1 if this entry carries the "delete" flag. +** collist: collist for column 0 +** zero-or-more { +** 0x01 byte +** varint: column number (I) +** collist: collist for column I +** } +** +** collist format: +** +** varint: first offset + 2 +** zero-or-more { +** varint: offset delta + 2 +** } +** +** PAGE FORMAT +** +** Each leaf page begins with a 4-byte header containing 2 16-bit +** unsigned integer fields in big-endian format. They are: +** +** * The byte offset of the first rowid on the page, if it exists +** and occurs before the first term (otherwise 0). +** +** * The byte offset of the start of the page footer. If the page +** footer is 0 bytes in size, then this field is the same as the +** size of the leaf page in bytes. +** +** The page footer consists of a single varint for each term located +** on the page. Each varint is the byte offset of the current term +** within the page, delta-compressed against the previous value. In +** other words, the first varint in the footer is the byte offset of +** the first term, the second is the byte offset of the second less that +** of the first, and so on. +** +** The term/doclist format described above is accurate if the entire +** term/doclist data fits on a single leaf page. If this is not the case, +** the format is changed in two ways: +** +** + if the first rowid on a page occurs before the first term, it +** is stored as a literal value: +** +** varint: first rowid +** +** + the first term on each page is stored in the same way as the +** very first term of the segment: +** +** varint : size of first term +** blob: first term data +** +** 5. Segment doclist indexes: +** +** Doclist indexes are themselves b-trees, however they usually consist of +** a single leaf record only. The format of each doclist index leaf page +** is: +** +** * Flags byte. Bits are: +** 0x01: Clear if leaf is also the root page, otherwise set. +** +** * Page number of fts index leaf page. As a varint. +** +** * First rowid on page indicated by previous field. As a varint. +** +** * A list of varints, one for each subsequent termless page. A +** positive delta if the termless page contains at least one rowid, +** or an 0x00 byte otherwise. +** +** Internal doclist index nodes are: +** +** * Flags byte. Bits are: +** 0x01: Clear for root page, otherwise set. +** +** * Page number of first child page. As a varint. +** +** * Copy of first rowid on page indicated by previous field. As a varint. +** +** * A list of delta-encoded varints - the first rowid on each subsequent +** child page. +** +** 6. Tombstone Hash Page +** +** These records are only ever present in contentless_delete=1 tables. +** There are zero or more of these associated with each segment. They +** are used to store the tombstone rowids for rows contained in the +** associated segments. +** +** The set of nHashPg tombstone hash pages associated with a single +** segment together form a single hash table containing tombstone rowids. +** To find the page of the hash on which a key might be stored: +** +** iPg = (rowid % nHashPg) +** +** Then, within page iPg, which has nSlot slots: +** +** iSlot = (rowid / nHashPg) % nSlot +** +** Each tombstone hash page begins with an 8 byte header: +** +** 1-byte: Key-size (the size in bytes of each slot). Either 4 or 8. +** 1-byte: rowid-0-tombstone flag. This flag is only valid on the +** first tombstone hash page for each segment (iPg=0). If set, +** the hash table contains rowid 0. If clear, it does not. +** Rowid 0 is handled specially. +** 2-bytes: unused. +** 4-bytes: Big-endian integer containing number of entries on page. +** +** Following this are nSlot 4 or 8 byte slots (depending on the key-size +** in the first byte of the page header). The number of slots may be +** determined based on the size of the page record and the key-size: +** +** nSlot = (nByte - 8) / key-size + */ + +/* +** Rowids for the averages and structure records in the %_data table. + */ + +/* +** Macros determining the rowids used by segment leaves and dlidx leaves +** and nodes. All nodes and leaves are stored in the %_data table with large +** positive rowids. +** +** Each segment has a unique non-zero 16-bit id. +** +** The rowid for each segment leaf is found by passing the segment id and +** the leaf page number to the FTS5_SEGMENT_ROWID macro. Leaves are numbered +** sequentially starting from 1. + */ + +/* +** Each time a blob is read from the %_data table, it is padded with this +** many zero bytes. This makes it easier to decode the various record formats +** without overreading if the records are corrupt. + */ + +// C documentation +// +// /* +// ** Add iRowid to the tombstone list of the segment or segments that contain +// ** rows from origin iOrigin. Return SQLITE_OK if successful, or an SQLite +// ** error code otherwise. +// */ +func _sqlite3Fts5IndexContentlessDelete(tls *libc.TLS, p uintptr, iOrigin Ti64, iRowid Ti64) (r int32) { + var bFound, iLvl, iSeg int32 + var pSeg, pStruct uintptr + _, _, _, _, _ = bFound, iLvl, iSeg, pSeg, pStruct + pStruct = _fts5StructureRead(tls, p) + if pStruct != 0 { + bFound = 0 + iLvl = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel - int32(1) + for { + if !(iLvl >= 0) { + break + } + iSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg - int32(1) + for { + if !(iSeg >= 0) { + break + } + pSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr(iSeg)*56 + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin1 <= libc.Uint64FromInt64(iOrigin) && (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiOrigin2 >= libc.Uint64FromInt64(iOrigin) { + if bFound == 0 { + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnEntryTombstone = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FnEntryTombstone + 1 + bFound = int32(1) + } + _fts5IndexTombstoneAdd(tls, p, pSeg, libc.Uint64FromInt64(iRowid)) + } + goto _2 + _2: + ; + iSeg = iSeg - 1 + } + goto _1 + _1: + ; + iLvl = iLvl - 1 + } + _fts5StructureRelease(tls, pStruct) + } + return _fts5IndexReturn(tls, p) +} + +/************************************************************************* +************************************************************************** +** Below this point is the implementation of the integrity-check +** functionality. + */ + +// C documentation +// +// /* +// ** Set a token-mapping for the iterator passed as the first argument. This +// ** is used in detail=column or detail=none mode when a token is requested +// ** using the xInstToken() API. In this case the caller tokenizers the +// ** current row and configures the token-mapping via multiple calls to this +// ** function. +// */ +func _sqlite3Fts5IndexIterWriteTokendata(tls *libc.TLS, pIndexIter uintptr, pToken uintptr, nToken int32, iRowid Ti64, iCol int32, iOff int32) (r int32) { + var iPos Ti64 + var ii int32 + var p, pIter, pT, pTerm uintptr + _, _, _, _, _, _ = iPos, ii, p, pIter, pT, pTerm + pIter = pIndexIter + pT = (*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter + p = (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex + iPos = int64(iCol)< 0 { + /* This is a prefix term iterator. */ + if pT == uintptr(0) { + pT = _sqlite3Fts5MallocZero(tls, p+60, libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+72)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(104))) + (*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter = pT + } + if pT != 0 { + _fts5TokendataIterAppendMap(tls, p, pT, (*TFts5TokenDataIter)(unsafe.Pointer(pT)).Fterms.Fn, nToken, iRowid, iPos) + _sqlite3Fts5BufferAppendBlob(tls, p+60, pT+24, libc.Uint32FromInt32(nToken), pToken) + } + } else { + ii = 0 + for { + if !(int64(ii) < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnIter) { + break + } + pTerm = *(*uintptr)(unsafe.Pointer(pT + 72 + uintptr(ii)*8)) + 104 + 96 + if nToken == (*TFts5Buffer)(unsafe.Pointer(pTerm)).Fn-int32(1) && libc.Xmemcmp(tls, pToken, (*TFts5Buffer)(unsafe.Pointer(pTerm)).Fp+uintptr(1), libc.Uint64FromInt32(nToken)) == 0 { + break + } + goto _1 + _1: + ; + ii = ii + 1 + } + if int64(ii) < (*TFts5TokenDataIter)(unsafe.Pointer(pT)).FnIter { + _fts5TokendataIterAppendMap(tls, p, pT, ii, 0, iRowid, iPos) + } + } + return _fts5IndexReturn(tls, p) +} + +// C documentation +// +// /* +// ** Return true if the value passed as the only argument is an +// ** fts5_locale() value. +// */ +func _sqlite3Fts5IsLocaleValue(tls *libc.TLS, pConfig uintptr, pVal uintptr) (r int32) { + var nBlob, ret int32 + var pBlob uintptr + _, _, _ = nBlob, pBlob, ret + ret = 0 + if Xsqlite3_value_type(tls, pVal) == int32(SQLITE_BLOB) { + /* Call sqlite3_value_bytes() after sqlite3_value_blob() in this case. + ** If the blob was created using zeroblob(), then sqlite3_value_blob() + ** may call malloc(). If this malloc() fails, then the values returned + ** by both value_blob() and value_bytes() will be 0. If value_bytes() were + ** called first, then the NULL pointer returned by value_blob() might + ** be dereferenced. */ + pBlob = Xsqlite3_value_blob(tls, pVal) + nBlob = Xsqlite3_value_bytes(tls, pVal) + if nBlob > libc.Int32FromInt64(16) && 0 == libc.Xmemcmp(tls, pBlob, (*TFts5Config)(unsafe.Pointer(pConfig)).FpGlobal+96, libc.Uint64FromInt32(libc.Int32FromInt64(16))) { + ret = int32(1) + } + } + return ret +} + +// C documentation +// +// /* +// ** Move to the next matching term/rowid. Used by the fts5vocab module. +// */ +func _sqlite3Fts5IterNextScan(tls *libc.TLS, pIndexIter uintptr) (r int32) { + var p, pIter, pSeg uintptr + _, _, _ = p, pIter, pSeg + pIter = pIndexIter + p = (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex + _fts5MultiIterNext(tls, p, pIter, 0, 0) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pSeg = pIter + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst)*128 + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp))) != int32('0') { + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf = uintptr(0) + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof = uint8(1) + } + } + return _fts5IndexReturn(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex) +} + +// C documentation +// +// /* +// ** Allocate and return an Fts5Colset object specifying the inverse of +// ** the colset passed as the second argument. Free the colset passed +// ** as the second argument before returning. +// */ +func _sqlite3Fts5ParseColsetInvert(tls *libc.TLS, pParse uintptr, p uintptr) (r uintptr) { + var i, iOld, nCol, v2 int32 + var pRet, v3 uintptr + _, _, _, _, _, _ = i, iOld, nCol, pRet, v2, v3 + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FnCol + pRet = _sqlite3Fts5MallocZero(tls, pParse+16, libc.Int64FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32((nCol+libc.Int32FromInt32(1)+libc.Int32FromInt32(2))/libc.Int32FromInt32(2)))) + if pRet != 0 { + iOld = 0 + i = 0 + for { + if !(i < nCol) { + break + } + if iOld >= (*TFts5Colset)(unsafe.Pointer(p)).FnCol || *(*int32)(unsafe.Pointer(p + 4 + uintptr(iOld)*4)) != i { + v3 = pRet + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + *(*int32)(unsafe.Pointer(pRet + 4 + uintptr(v2)*4)) = i + } else { + iOld = iOld + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + } + Xsqlite3_free(tls, p) + return pRet +} + +// C documentation +// +// /* The main parser program. +// ** The first argument is a pointer to a structure obtained from +// ** "sqlite3Fts5ParserAlloc" which describes the current state of the parser. +// ** The second argument is the major token number. The third is +// ** the minor token. The fourth optional argument is whatever the +// ** user wants (and specified in the grammar) and is available for +// ** use by the action routines. +// ** +// ** Inputs: +// **
      +// **
    • A pointer to the parser (an opaque structure.) +// **
    • The major token number. +// **
    • The minor token number. +// **
    • An option argument of a grammar-specified type. +// **
    +// ** +// ** Outputs: +// ** None. +// */ +func _sqlite3Fts5Parser(tls *libc.TLS, fts5yyp uintptr, fts5yymajor int32, fts5yyminor TFts5Token, pParse uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var fts5yyact uint8 + var fts5yypParser uintptr + var fts5yyruleno uint32 + var _ /* fts5yyminorunion at bp+0 */ Tfts5YYMINORTYPE + _, _, _ = fts5yyact, fts5yypParser, fts5yyruleno /* The parser action. */ + fts5yypParser = fts5yyp /* The parser */ + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse + fts5yyact = (*Tfts5yyStackEntry)(unsafe.Pointer((*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos)).Fstateno + for int32(1) != 0 { /* Exit by "break" */ + fts5yyact = _fts5yy_find_shift_action(tls, libc.Uint8FromInt32(fts5yymajor), fts5yyact) + if libc.Int32FromUint8(fts5yyact) >= int32(fts5YY_MIN_REDUCE) { + fts5yyruleno = libc.Uint32FromInt32(libc.Int32FromUint8(fts5yyact) - int32(fts5YY_MIN_REDUCE)) /* Reduce by this rule */ + /* Check that the stack is large enough to grow by a single entry + ** if the RHS of the rule is empty. This ensures that there is room + ** enough on the stack to push the LHS value */ + if int32(_fts5yyRuleInfoNRhs[fts5yyruleno]) == 0 { + if (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos >= (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd { + if int32(1) != 0 { + _fts5yyStackOverflow(tls, fts5yypParser) + break + } + } + } + fts5yyact = _fts5yy_reduce(tls, fts5yypParser, fts5yyruleno, fts5yymajor, fts5yyminor) + } else { + if libc.Int32FromUint8(fts5yyact) <= int32(fts5YY_MAX_SHIFTREDUCE) { + _fts5yy_shift(tls, fts5yypParser, fts5yyact, libc.Uint8FromInt32(fts5yymajor), fts5yyminor) + break + } else { + if libc.Int32FromUint8(fts5yyact) == int32(fts5YY_ACCEPT_ACTION) { + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos -= 24 + _fts5yy_accept(tls, fts5yypParser) + return + } else { + *(*TFts5Token)(unsafe.Pointer(bp)) = fts5yyminor + /* If the fts5YYNOERRORRECOVERY macro is defined, then do not attempt to + ** do any kind of error recovery. Instead, simply invoke the syntax + ** error routine and continue going as if nothing had happened. + ** + ** Applications can set this macro (for example inside %include) if + ** they intend to abandon the parse upon the first syntax error seen. + */ + _fts5yy_syntax_error(tls, fts5yypParser, fts5yymajor, fts5yyminor) + _fts5yy_destructor(tls, fts5yypParser, libc.Uint8FromInt32(fts5yymajor), bp) + break + } + } + } + } + return +} + +// C documentation +// +// /* +// ** Clear all secondary memory allocations from the parser +// */ +func _sqlite3Fts5ParserFinalize(tls *libc.TLS, p uintptr) { + var fts5yytos, pParser uintptr + _, _ = fts5yytos, pParser + pParser = p + /* In-lined version of calling fts5yy_pop_parser_stack() for each + ** element left in the stack */ + fts5yytos = (*Tfts5yyParser)(unsafe.Pointer(pParser)).Ffts5yytos + for fts5yytos > (*Tfts5yyParser)(unsafe.Pointer(pParser)).Ffts5yystack { + if libc.Int32FromUint8((*Tfts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fmajor) >= int32(fts5YY_MIN_DSTRCTR) { + _fts5yy_destructor(tls, pParser, (*Tfts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fmajor, fts5yytos+8) + } + fts5yytos -= 24 + } +} + +// C documentation +// +// /* +// ** Advance the iterator object passed as the only argument. Return true +// ** if the iterator reaches EOF, or false otherwise. +// */ +func _sqlite3Fts5PoslistReaderNext(tls *libc.TLS, pIter uintptr) (r int32) { + if _sqlite3Fts5PoslistNext64(tls, (*TFts5PoslistReader)(unsafe.Pointer(pIter)).Fa, (*TFts5PoslistReader)(unsafe.Pointer(pIter)).Fn, pIter+12, pIter+24) != 0 { + (*TFts5PoslistReader)(unsafe.Pointer(pIter)).FbEof = uint8(1) + } + return libc.Int32FromUint8((*TFts5PoslistReader)(unsafe.Pointer(pIter)).FbEof) +} + +// C documentation +// +// /* +// ** Append position iPos to the position list being accumulated in buffer +// ** pBuf, which must be already be large enough to hold the new data. +// ** The previous position written to this list is *piPrev. *piPrev is set +// ** to iPos before returning. +// */ +func _sqlite3Fts5PoslistSafeAppend(tls *libc.TLS, pBuf uintptr, piPrev uintptr, iPos Ti64) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if iPos >= **(**Ti64)(__ccgo_up(piPrev)) { + if iPos&_colmask != **(**Ti64)(__ccgo_up(piPrev))&_colmask { + v2 = pBuf + 8 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(v1))) = uint8(1) + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), libc.Uint64FromInt64(iPos>>libc.Int32FromInt32(32))) + **(**Ti64)(__ccgo_up(piPrev)) = iPos & _colmask + } + **(**int32)(__ccgo_up(pBuf + 8)) += _sqlite3Fts5PutVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn), libc.Uint64FromInt64(iPos-**(**Ti64)(__ccgo_up(piPrev))+int64(2))) + **(**Ti64)(__ccgo_up(piPrev)) = iPos + } +} + +// C documentation +// +// /* +// ** Close a handle opened by an earlier call to sqlite3Fts5StorageOpen(). +// */ +func _sqlite3Fts5StorageClose(tls *libc.TLS, p uintptr) (r int32) { + var i, rc int32 + _, _ = i, rc + rc = SQLITE_OK + if p != 0 { + /* Finalize all SQL statements */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(96)/libc.Uint64FromInt64(8))) { + break + } + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(p + 48 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, p) + } + return rc +} + +// C documentation +// +// /* +// ** Insert a new row into the FTS content table. +// */ +func _sqlite3Fts5StorageContentInsert(tls *libc.TLS, p uintptr, bReplace int32, apVal uintptr, piRowid uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bUnindexed, i, iLoc, rc int32 + var pConfig, pVal uintptr + var _ /* nLoc at bp+28 */ int32 + var _ /* nText at bp+24 */ int32 + var _ /* pInsert at bp+0 */ uintptr + var _ /* pLoc at bp+16 */ uintptr + var _ /* pText at bp+8 */ uintptr + _, _, _, _, _, _ = bUnindexed, i, iLoc, pConfig, pVal, rc + pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig + rc = SQLITE_OK + /* Insert the new row into the %_content table. */ + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent != int32(FTS5_CONTENT_UNINDEXED) { + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) == int32(SQLITE_INTEGER) { + **(**Ti64)(__ccgo_up(piRowid)) = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + } else { + rc = _fts5StorageNewRowid(tls, p, piRowid) + } + } else { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Counter variable */ + rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_INSERT_CONTENT)+bReplace, bp, uintptr(0)) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + Xsqlite3_clear_bindings(tls, **(**uintptr)(__ccgo_up(bp))) + } + /* Bind the rowid value */ + Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), **(**uintptr)(__ccgo_up(apVal + 1*8))) + /* Loop through values for user-defined columns. i=2 is the leftmost + ** user-defined column. As is column 1 of pSavedRow. */ + i = int32(2) + for { + if !(rc == SQLITE_OK && i <= (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol+int32(1)) { + break + } + bUnindexed = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i-int32(2))))) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL || bUnindexed != 0 { + pVal = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + if Xsqlite3_value_nochange(tls, pVal) != 0 && (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow != 0 { + /* This is an UPDATE statement, and user-defined column (i-2) was not + ** modified. Retrieve the value from Fts5Storage.pSavedRow. */ + pVal = Xsqlite3_column_value(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow, i-int32(1)) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 && bUnindexed == 0 { + Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp)), (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol+i, Xsqlite3_column_value(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow, (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol+i-int32(1))) + } + } else { + if _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 24)) = 0 + **(**int32)(__ccgo_up(bp + 28)) = 0 + rc = _sqlite3Fts5DecodeLocaleValue(tls, pVal, bp+8, bp+24, bp+16, bp+28) + if rc == SQLITE_OK { + Xsqlite3_bind_text(tls, **(**uintptr)(__ccgo_up(bp)), i, **(**uintptr)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 24)), uintptr(-libc.Int32FromInt32(1))) + if bUnindexed == 0 { + iLoc = (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + i + Xsqlite3_bind_text(tls, **(**uintptr)(__ccgo_up(bp)), iLoc, **(**uintptr)(__ccgo_up(bp + 16)), **(**int32)(__ccgo_up(bp + 28)), uintptr(-libc.Int32FromInt32(1))) + } + } + goto _1 + } + } + rc = Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp)), i, pVal) + } + goto _1 + _1: + ; + i = i + 1 + } + if rc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp))) + } + **(**Ti64)(__ccgo_up(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb) + } + return rc +} + +func _sqlite3Fts5TermsetFree(tls *libc.TLS, p uintptr) { + var i Tu32 + var pDel, pEntry uintptr + _, _, _ = i, pDel, pEntry + if p != 0 { + i = uint32(0) + for { + if !(i < libc.Uint32FromInt32(libc.Int32FromUint64(libc.Uint64FromInt64(4096)/libc.Uint64FromInt64(8)))) { + break + } + pEntry = **(**uintptr)(__ccgo_up(p + uintptr(i)*8)) + for pEntry != 0 { + pDel = pEntry + pEntry = (*TFts5TermsetEntry)(unsafe.Pointer(pEntry)).FpNext + Xsqlite3_free(tls, pDel) + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, p) + } +} + +/* +** 2014 Jun 09 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This is an SQLite module implementing full-text search. + */ + +/* #include "fts5Int.h" */ + +/* Maximum allowed page size */ + +// C documentation +// +// /* +// ** Interpret the argument as a unicode codepoint. If the codepoint +// ** is an upper case character that has a lower case equivalent, +// ** return the codepoint corresponding to the lower case version. +// ** Otherwise, return a copy of the argument. +// ** +// ** The results are undefined if the value passed to this function +// ** is less than zero. +// */ +func _sqlite3Fts5UnicodeFold(tls *libc.TLS, c int32, eRemoveDiacritic int32) (r int32) { + var cmp, iHi, iLo, iRes, iTest, ret int32 + var p uintptr + _, _, _, _, _, _, _ = cmp, iHi, iLo, iRes, iTest, p, ret + ret = c + if c < int32(128) { + if c >= int32('A') && c <= int32('Z') { + ret = c + (libc.Int32FromUint8('a') - libc.Int32FromUint8('A')) + } + } else { + if c < int32(65536) { + iHi = libc.Int32FromUint64(libc.Uint64FromInt64(652)/libc.Uint64FromInt64(4) - libc.Uint64FromInt32(1)) + iLo = 0 + iRes = -int32(1) + for iHi >= iLo { + iTest = (iHi + iLo) / int32(2) + cmp = c - libc.Int32FromUint16(_aEntry[iTest].FiCode) + if cmp >= 0 { + iRes = iTest + iLo = iTest + int32(1) + } else { + iHi = iTest - int32(1) + } + } + p = uintptr(unsafe.Pointer(&_aEntry)) + uintptr(iRes)*4 + if c < libc.Int32FromUint16((*struct { + FiCode uint16 + Fflags uint8 + FnRange uint8 + })(unsafe.Pointer(p)).FiCode)+libc.Int32FromUint8((*struct { + FiCode uint16 + Fflags uint8 + FnRange uint8 + })(unsafe.Pointer(p)).FnRange) && 0 == int32(0x01)&libc.Int32FromUint8((*struct { + FiCode uint16 + Fflags uint8 + FnRange uint8 + })(unsafe.Pointer(p)).Fflags)&(libc.Int32FromUint16((*struct { + FiCode uint16 + Fflags uint8 + FnRange uint8 + })(unsafe.Pointer(p)).FiCode)^c) { + ret = (c + libc.Int32FromUint16(_aiOff[libc.Int32FromUint8((*struct { + FiCode uint16 + Fflags uint8 + FnRange uint8 + })(unsafe.Pointer(p)).Fflags)>>int32(1)])) & int32(0x0000FFFF) + } + if eRemoveDiacritic != 0 { + ret = _fts5_remove_diacritic(tls, ret, libc.BoolInt32(eRemoveDiacritic == int32(2))) + } + } else { + if c >= int32(66560) && c < int32(66600) { + ret = c + int32(40) + } + } + } + return ret +} + +// C documentation +// +// /* +// ** Generate code that will assemble an index key and stores it in register +// ** regOut. The key with be for index pIdx which is an index on pTab. +// ** iCur is the index of a cursor open on the pTab table and pointing to +// ** the entry that needs indexing. If pTab is a WITHOUT ROWID table, then +// ** iCur must be the cursor of the PRIMARY KEY index. +// ** +// ** Return a register number which is the first in a block of +// ** registers that holds the elements of the index key. The +// ** block of registers has already been deallocated by the time +// ** this routine returns. +// ** +// ** If *piPartIdxLabel is not NULL, fill it in with a label and jump +// ** to that label if pIdx is a partial index that should be skipped. +// ** The label should be resolved using sqlite3ResolvePartIdxLabel(). +// ** A partial index should be skipped if its WHERE clause evaluates +// ** to false or null. If pIdx is not a partial index, *piPartIdxLabel +// ** will be set to zero which is an empty label that is ignored by +// ** sqlite3ResolvePartIdxLabel(). +// ** +// ** The pPrior and regPrior parameters are used to implement a cache to +// ** avoid unnecessary register loads. If pPrior is not NULL, then it is +// ** a pointer to a different index for which an index key has just been +// ** computed into register regPrior. If the current pIdx index is generating +// ** its key into the same sequence of registers and if pPrior and pIdx share +// ** a column in common, then the register corresponding to that column already +// ** holds the correct value and the loading of that register is skipped. +// ** This optimization is helpful when doing a DELETE or an INTEGRITY_CHECK +// ** on a table with multiple indices, and especially with the ROWID or +// ** PRIMARY KEY columns of the index. +// */ +func _sqlite3GenerateIndexKey(tls *libc.TLS, pParse uintptr, pIdx uintptr, iDataCur int32, regOut int32, prefixOnly int32, piPartIdxLabel uintptr, pPrior uintptr, regPrior int32) (r int32) { + var j, nCol, regBase, v1 int32 + var v uintptr + _, _, _, _, _ = j, nCol, regBase, v, v1 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if piPartIdxLabel != 0 { + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + **(**int32)(__ccgo_up(piPartIdxLabel)) = _sqlite3VdbeMakeLabel(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = iDataCur + int32(1) + _sqlite3ExprIfFalseDup(tls, pParse, (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere, **(**int32)(__ccgo_up(piPartIdxLabel)), int32(SQLITE_JUMPIFNULL)) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 + pPrior = uintptr(0) /* Ticket a9efb42811fa41ee 2019-11-02; + ** pPartIdxWhere may have corrupted regPrior registers */ + } else { + **(**int32)(__ccgo_up(piPartIdxLabel)) = 0 + } + } + if prefixOnly != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x8>>3)) != 0 { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + } else { + v1 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } + nCol = v1 + regBase = _sqlite3GetTempRange(tls, pParse, nCol) + if pPrior != 0 && (regBase != regPrior || (*TIndex)(unsafe.Pointer(pPrior)).FpPartIdxWhere != 0) { + pPrior = uintptr(0) + } + j = 0 + for { + if !(j < nCol) { + break + } + if pPrior != 0 && int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPrior)).FaiColumn + uintptr(j)*2))) == int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) && int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPrior)).FaiColumn + uintptr(j)*2))) != -int32(2) { + /* This column was already computed by the previous index */ + goto _2 + } + _sqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iDataCur, j, regBase+j) + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) >= 0 { + /* If the column affinity is REAL but the number is an integer, then it + ** might be stored in the table as an integer (using a compact + ** representation) then converted to REAL by an OP_RealAffinity opcode. + ** But we are getting ready to store this value back into an index, where + ** it should be converted by to INTEGER again. So omit the + ** OP_RealAffinity opcode if it is present */ + _sqlite3VdbeDeletePriorOpcode(tls, v, uint8(OP_RealAffinity)) + } + goto _2 + _2: + ; + j = j + 1 + } + if regOut != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regBase, nCol, regOut) + } + _sqlite3ReleaseTempRange(tls, pParse, regBase, nCol) + return regBase +} + +// C documentation +// +// /* +// ** This routine generates VDBE code that causes the deletion of all +// ** index entries associated with a single row of a single table, pTab +// ** +// ** Preconditions: +// ** +// ** 1. A read/write cursor "iDataCur" must be open on the canonical storage +// ** btree for the table pTab. (This will be either the table itself +// ** for rowid tables or to the primary key index for WITHOUT ROWID +// ** tables.) +// ** +// ** 2. Read/write cursors for all indices of pTab must be open as +// ** cursor number iIdxCur+i for the i-th index. (The pTab->pIndex +// ** index is the 0-th index.) +// ** +// ** 3. The "iDataCur" cursor must be already be positioned on the row +// ** that is to be deleted. +// */ +func _sqlite3GenerateRowIndexDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, iDataCur int32, iIdxCur int32, aRegIdx uintptr, iIdxNoSeek int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, r1, v3 int32 + var pIdx, pPk, pPrior, v, v1 uintptr + var _ /* iPartIdxLabel at bp+0 */ int32 + _, _, _, _, _, _, _, _ = i, pIdx, pPk, pPrior, r1, v, v1, v3 /* Index loop counter */ + r1 = -int32(1) /* Current index */ + pPrior = uintptr(0) /* PRIMARY KEY index, or NULL for rowid tables */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v1 = uintptr(0) + } else { + v1 = _sqlite3PrimaryKeyIndex(tls, pTab) + } + pPk = v1 + i = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if aRegIdx != uintptr(0) && **(**int32)(__ccgo_up(aRegIdx + uintptr(i)*4)) == 0 { + goto _2 + } + if pIdx == pPk { + goto _2 + } + if iIdxCur+i == iIdxNoSeek { + goto _2 + } + r1 = _sqlite3GenerateIndexKey(tls, pParse, pIdx, iDataCur, 0, int32(1), bp, pPrior, r1) + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x8>>3)) != 0 { + v3 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + } else { + v3 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_IdxDelete), iIdxCur+i, r1, v3) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pIdx, -int32(6)) + _sqlite3ResolvePartIdxLabel(tls, pParse, **(**int32)(__ccgo_up(bp))) + pPrior = pIdx + goto _2 + _2: + ; + i = i + 1 + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } +} + +// C documentation +// +// /* +// ** Allocate a single new register for use to hold some intermediate result. +// */ +func _sqlite3GetTempReg(tls *libc.TLS, pParse uintptr) (r int32) { + var v1 int32 + var v2 uintptr + var v3 Tu8 + _, _, _ = v1, v2, v3 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FnTempReg) == 0 { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + return v1 + } + v2 = pParse + 31 + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) - 1 + v3 = *(*Tu8)(unsafe.Pointer(v2)) + return **(**int32)(__ccgo_up(pParse + 184 + uintptr(v3)*4)) +} + +// C documentation +// +// /* +// ** Get a VDBE for the given parser context. Create a new one if necessary. +// ** If an error occurs, return NULL and leave a message in pParse. +// */ +func _sqlite3GetVdbe(tls *libc.TLS, pParse uintptr) (r uintptr) { + if (*TParse)(unsafe.Pointer(pParse)).FpVdbe != 0 { + return (*TParse)(unsafe.Pointer(pParse)).FpVdbe + } + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FactorOutConst)) == uint32(0) { + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 7, 0x80) + } + return _sqlite3VdbeCreate(tls, pParse) +} + +// C documentation +// +// /* +// ** Return the size of the header added to each page by this module. +// */ +func _sqlite3HeaderSizeBtree(tls *libc.TLS) (r int32) { + return libc.Int32FromUint64((libc.Uint64FromInt64(136) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) +} + +// C documentation +// +// /* +// ** Return the size of the header added by this middleware layer +// ** in the page-cache hierarchy. +// */ +func _sqlite3HeaderSizePcache(tls *libc.TLS) (r int32) { + return libc.Int32FromUint64((libc.Uint64FromInt64(80) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) +} + +// C documentation +// +// /* +// ** Return the size of the header on each page of this PCACHE implementation. +// */ +func _sqlite3HeaderSizePcache1(tls *libc.TLS) (r int32) { + return libc.Int32FromUint64((libc.Uint64FromInt64(56) + libc.Uint64FromInt32(7)) & libc.Uint64FromInt32(^libc.Int32FromInt32(7))) +} + +// C documentation +// +// /* +// ** Append a new element to the given IdList. Create a new IdList if +// ** need be. +// ** +// ** A new IdList is returned, or NULL if malloc() fails. +// */ +func _sqlite3IdListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pToken uintptr) (r uintptr) { + var db, pNew, v2 uintptr + var i, v1 int32 + _, _, _, _, _ = db, i, pNew, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pList == uintptr(0) { + pList = _sqlite3DbMallocZero(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32(libc.Int32FromInt32(1))*libc.Uint64FromInt64(8))) + if pList == uintptr(0) { + return uintptr(0) + } + } else { + pNew = _sqlite3DbRealloc(tls, db, pList, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32((*TIdList)(unsafe.Pointer(pList)).FnId+libc.Int32FromInt32(1))*libc.Uint64FromInt64(8))) + if pNew == uintptr(0) { + _sqlite3IdListDelete(tls, db, pList) + return uintptr(0) + } + pList = pNew + } + v2 = pList + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + i = v1 + (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*8))).FzName = _sqlite3NameFromToken(tls, db, pToken) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*8))).FzName != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*8))).FzName, pToken) + } + return pList +} + +func _sqlite3IdListDup(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) { + var i int32 + var pNew, pNewItem, pOldItem uintptr + _, _, _, _ = i, pNew, pNewItem, pOldItem + if p == uintptr(0) { + return uintptr(0) + } + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt32((*TIdList)(unsafe.Pointer(p)).FnId)*libc.Uint64FromInt64(8))) + if pNew == uintptr(0) { + return uintptr(0) + } + (*TIdList)(unsafe.Pointer(pNew)).FnId = (*TIdList)(unsafe.Pointer(p)).FnId + i = 0 + for { + if !(i < (*TIdList)(unsafe.Pointer(p)).FnId) { + break + } + pNewItem = pNew + 8 + uintptr(i)*8 + pOldItem = p + 8 + uintptr(i)*8 + (*TIdList_item)(unsafe.Pointer(pNewItem)).FzName = _sqlite3DbStrDup(tls, db, (*TIdList_item)(unsafe.Pointer(pOldItem)).FzName) + goto _1 + _1: + ; + i = i + 1 + } + return pNew +} + +// C documentation +// +// /* +// ** Initialize all database files - the main database file, the file +// ** used to store temporary tables, and any additional database files +// ** created using ATTACH statements. Return a success code. If an +// ** error occurs, write an error message into *pzErrMsg. +// ** +// ** After a database is initialized, the DB_SchemaLoaded bit is set +// ** bit is set in the flags field of the Db structure. +// */ +func _sqlite3Init(tls *libc.TLS, db uintptr, pzErrMsg uintptr) (r int32) { + var commit_internal, i, rc int32 + _, _, _ = commit_internal, i, rc + commit_internal = libc.BoolInt32(!((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&libc.Uint32FromInt32(DBFLAG_SchemaChange) != 0)) + (*Tsqlite3)(unsafe.Pointer(db)).Fenc = (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).Fenc + /* Do the main schema first */ + if !(libc.Int32FromUint16((*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).FschemaFlags)&libc.Int32FromInt32(DB_SchemaLoaded) == libc.Int32FromInt32(DB_SchemaLoaded)) { + rc = _sqlite3InitOne(tls, db, 0, pzErrMsg, uint32(0)) + if rc != 0 { + return rc + } + } + /* All other schemas after the main schema. The "temp" schema must be last */ + i = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + for { + if !(i > 0) { + break + } + if !(libc.Int32FromUint16((*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema)).FschemaFlags)&libc.Int32FromInt32(DB_SchemaLoaded) == libc.Int32FromInt32(DB_SchemaLoaded)) { + rc = _sqlite3InitOne(tls, db, i, pzErrMsg, uint32(0)) + if rc != 0 { + return rc + } + } + goto _1 + _1: + ; + i = i - 1 + } + if commit_internal != 0 { + _sqlite3CommitInternalChanges(tls, db) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants +// ** defined in pager.h. This function returns the associated lowercase +// ** journal-mode name. +// */ +func _sqlite3JournalModename(tls *libc.TLS, eMode int32) (r uintptr) { + if eMode == libc.Int32FromUint64(libc.Uint64FromInt64(48)/libc.Uint64FromInt64(8)) { + return uintptr(0) + } + return _azModeName[eMode] +} + +// C documentation +// +// /* +// ** Return a KeyInfo structure that is appropriate for the given Index. +// ** +// ** The caller should invoke sqlite3KeyInfoUnref() on the returned object +// ** when it has finished using it. +// */ +func _sqlite3KeyInfoOfIndex(tls *libc.TLS, pParse uintptr, pIdx uintptr) (r uintptr) { + var i, nCol, nKey int32 + var pKey, zColl, v2 uintptr + _, _, _, _, _, _ = i, nCol, nKey, pKey, zColl, v2 + nCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + nKey = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return uintptr(0) + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x8>>3)) != 0 { + pKey = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, nKey, nCol-nKey) + } else { + pKey = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, nCol, 0) + } + if pKey != 0 { + i = 0 + for { + if !(i < nCol) { + break + } + zColl = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*8)) + if zColl == uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) { + v2 = uintptr(0) + } else { + v2 = _sqlite3LocateCollSeq(tls, pParse, zColl) + } + *(*uintptr)(unsafe.Pointer(pKey + 32 + uintptr(i)*8)) = v2 + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKey)).FaSortFlags + uintptr(i))) = **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i))) + goto _1 + _1: + ; + i = i + 1 + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x100>>8)) == 0 && _sqlite3HashFind(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpSchema+32, (*TIndex)(unsafe.Pointer(pIdx)).FzName) != 0 { + /* Deactivate the index because it contains an unknown collating + ** sequence. The only way to reactive the index is to reload the + ** schema. Adding the missing collating sequence later does not + ** reactive the index. The application had the chance to register + ** the missing index using the collation-needed callback. For + ** simplicity, SQLite will not give the application a second chance. + ** + ** Except, do not do this if the index is not in the schema hash + ** table. In this case the index is currently being constructed + ** by a CREATE INDEX statement, and retrying will not help. */ + libc.SetBitFieldPtr16Uint32(pIdx+100, libc.Uint32FromInt32(1), 8, 0x100) + (*TParse)(unsafe.Pointer(pParse)).Frc = libc.Int32FromInt32(SQLITE_ERROR) | libc.Int32FromInt32(2)<>6)) != 0 || (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy != 0 || _exprListIsConstant(tls, pParse, pRow) == 0 || (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pLeft)).FpSrc)).FnSrc == 0 && _exprListIsNoAffinity(tls, pParse, (*TSelect)(unsafe.Pointer(pLeft)).FpEList) == 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + /* The co-routine method cannot be used. Fall back to UNION ALL. */ + pSelect = uintptr(0) + f = libc.Int32FromInt32(SF_Values) | libc.Int32FromInt32(SF_MultiValue) + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pLeft)).FpSrc)).FnSrc != 0 { + _sqlite3MultiValuesEnd(tls, pParse, pLeft) + f = int32(SF_Values) + } else { + if (*TSelect)(unsafe.Pointer(pLeft)).FpPrior != 0 { + /* In this case set the SF_MultiValue flag only if it was set on pLeft */ + f = libc.Int32FromUint32(libc.Uint32FromInt32(f) & (*TSelect)(unsafe.Pointer(pLeft)).FselFlags) + } + } + pSelect = _sqlite3SelectNew(tls, pParse, pRow, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), libc.Uint32FromInt32(f), uintptr(0)) + **(**Tu32)(__ccgo_up(pLeft + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) + if pSelect != 0 { + (*TSelect)(unsafe.Pointer(pSelect)).Fop = uint8(TK_ALL) + (*TSelect)(unsafe.Pointer(pSelect)).FpPrior = pLeft + pLeft = pSelect + } + } else { + p = uintptr(0) /* SrcItem that reads from co-routine */ + if (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pLeft)).FpSrc)).FnSrc == 0 { + /* Co-routine has not yet been started and the special Select object + ** that accesses the co-routine has not yet been created. This block + ** does both those things. */ + v = _sqlite3GetVdbe(tls, pParse) + pRet = _sqlite3SelectNew(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + /* Ensure the database schema has been read. This is to ensure we have + ** the correct text encoding. */ + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_SchemaKnownOk) == uint32(0) { + _sqlite3ReadSchema(tls, pParse) + } + if pRet != 0 { + (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pRet)).FpSrc)).FnSrc = int32(1) + (*TSelect)(unsafe.Pointer(pRet)).FpPrior = (*TSelect)(unsafe.Pointer(pLeft)).FpPrior + (*TSelect)(unsafe.Pointer(pRet)).Fop = (*TSelect)(unsafe.Pointer(pLeft)).Fop + if (*TSelect)(unsafe.Pointer(pRet)).FpPrior != 0 { + **(**Tu32)(__ccgo_up(pRet + 4)) |= uint32(SF_Values) + } + (*TSelect)(unsafe.Pointer(pLeft)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(pLeft)).Fop = uint8(TK_SELECT) + p = (*TSelect)(unsafe.Pointer(pRet)).FpSrc + 8 + libc.SetBitFieldPtr32Uint32(p+24+4, libc.Uint32FromInt32(1), 6, 0x40) + (*TSrcItem)(unsafe.Pointer(p)).FiCursor = -int32(1) + *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(p)).Fu1)) = uint32(2) + if _sqlite3SrcItemAttachSubquery(tls, pParse, p, pLeft, 0) != 0 { + pSubq = *(*uintptr)(unsafe.Pointer(p + 72)) + (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn = v1 + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn, 0, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) + _sqlite3SelectDestInit(tls, bp, int32(SRT_Coroutine), (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn) + /* Allocate registers for the output of the co-routine. Do so so + ** that there are two unused registers immediately before those + ** used by the co-routine. This allows the code in sqlite3Insert() + ** to use these registers directly, instead of copying the output + ** of the co-routine to a separate array for processing. */ + (**(**TSelectDest)(__ccgo_up(bp))).FiSdst = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(3) + (**(**TSelectDest)(__ccgo_up(bp))).FnSdst = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pLeft)).FpEList)).FnExpr + **(**int32)(__ccgo_up(pParse + 60)) += int32(2) + (**(**TSelectDest)(__ccgo_up(bp))).FnSdst + **(**Tu32)(__ccgo_up(pLeft + 4)) |= uint32(SF_MultiValue) + _sqlite3Select(tls, pParse, pLeft, bp) + (*TSubquery)(unsafe.Pointer(pSubq)).FregResult = (**(**TSelectDest)(__ccgo_up(bp))).FiSdst + } + pLeft = pRet + } + } else { + p = (*TSelect)(unsafe.Pointer(pLeft)).FpSrc + 8 + *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(p)).Fu1)) = *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(p)).Fu1)) + 1 + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + pSubq1 = *(*uintptr)(unsafe.Pointer(p + 72)) + if (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(pSubq1)).FpSelect)).FpEList)).FnExpr != (*TExprList)(unsafe.Pointer(pRow)).FnExpr { + _sqlite3SelectWrongNumTermsError(tls, pParse, (*TSubquery)(unsafe.Pointer(pSubq1)).FpSelect) + } else { + _sqlite3ExprCodeExprList(tls, pParse, pRow, (*TSubquery)(unsafe.Pointer(pSubq1)).FregResult, 0, uint8(0)) + _sqlite3VdbeAddOp1(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Yield), (*TSubquery)(unsafe.Pointer(pSubq1)).FregReturn) + } + } + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pRow) + } + return pLeft +} + +// C documentation +// +// /* +// ** This routine reactivates the memory allocator and clears the +// ** db->mallocFailed flag as necessary. +// ** +// ** The memory allocator is not restarted if there are running +// ** VDBEs. +// */ +func _sqlite3OomClear(tls *libc.TLS, db uintptr) { + var v1 int32 + _ = v1 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec == 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed = uint8(0) + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v1 = 0 + } else { + v1 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v1) + } +} + +// C documentation +// +// /* +// ** Allocate cursors for the pTab table and all its indices and generate +// ** code to open and initialized those cursors. +// ** +// ** The cursor for the object that contains the complete data (normally +// ** the table itself, but the PRIMARY KEY index in the case of a WITHOUT +// ** ROWID table) is returned in *piDataCur. The first index cursor is +// ** returned in *piIdxCur. The number of indices is returned. +// ** +// ** Use iBase as the first cursor (either the *piDataCur for rowid tables +// ** or the first index for WITHOUT ROWID tables) if it is non-negative. +// ** If iBase is negative, then allocate the next available cursor. +// ** +// ** For a rowid table, *piDataCur will be exactly one less than *piIdxCur. +// ** For a WITHOUT ROWID table, *piDataCur will be somewhere in the range +// ** of *piIdxCurs, depending on where the PRIMARY KEY index appears on the +// ** pTab->pIndex list. +// ** +// ** If pTab is a virtual table, then this routine is a no-op and the +// ** *piDataCur and *piIdxCur values are left uninitialized. +// */ +func _sqlite3OpenTableAndIndices(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32, p5 Tu8, iBase int32, aToOpen uintptr, piDataCur uintptr, piIdxCur uintptr) (r int32) { + var i, iDataCur, iDb, iIdxCur, v1 int32 + var pIdx, v uintptr + _, _, _, _, _, _, _ = i, iDataCur, iDb, iIdxCur, pIdx, v, v1 + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + /* This routine is a no-op for virtual tables. Leave the output + ** variables *piDataCur and *piIdxCur set to illegal cursor numbers + ** for improved error detection. */ + v1 = -libc.Int32FromInt32(999) + **(**int32)(__ccgo_up(piIdxCur)) = v1 + **(**int32)(__ccgo_up(piDataCur)) = v1 + return 0 + } + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if iBase < 0 { + iBase = (*TParse)(unsafe.Pointer(pParse)).FnTab + } + v1 = iBase + iBase = iBase + 1 + iDataCur = v1 + **(**int32)(__ccgo_up(piDataCur)) = iDataCur + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) && (aToOpen == uintptr(0) || **(**Tu8)(__ccgo_up(aToOpen)) != 0) { + _sqlite3OpenTable(tls, pParse, iDataCur, iDb, pTab, op) + } else { + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FnoSharedCache) == 0 { + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, libc.BoolUint8(op == int32(OP_OpenWrite)), (*TTable)(unsafe.Pointer(pTab)).FzName) + } + } + **(**int32)(__ccgo_up(piIdxCur)) = iBase + i = 0 + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + v1 = iBase + iBase = iBase + 1 + iIdxCur = v1 + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) && !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + **(**int32)(__ccgo_up(piDataCur)) = iIdxCur + p5 = uint8(0) + } + if aToOpen == uintptr(0) || **(**Tu8)(__ccgo_up(aToOpen + uintptr(i+int32(1)))) != 0 { + _sqlite3VdbeAddOp3(tls, v, op, iIdxCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) + _sqlite3VdbeChangeP5(tls, v, uint16(p5)) + } + goto _3 + _3: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + i = i + 1 + } + if iBase > (*TParse)(unsafe.Pointer(pParse)).FnTab { + (*TParse)(unsafe.Pointer(pParse)).FnTab = iBase + } + return i +} + +// C documentation +// +// /* +// ** Add pSelect to the Expr.x.pSelect field. Or, if pExpr is NULL (due +// ** do a memory allocation failure) then delete the pSelect object. +// */ +func _sqlite3PExprAddSelect(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSelect uintptr) { + if pExpr != 0 { + *(*uintptr)(unsafe.Pointer(pExpr + 32)) = pSelect + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_xIsSelect) | libc.Int32FromInt32(EP_Subquery)) + _sqlite3ExprSetHeightAndFlags(tls, pParse, pExpr) + } else { + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect) + } +} + +// C documentation +// +// /* +// ** A call to this routine tells the pager that it is not necessary to +// ** write the information on page pPg back to the disk, even though +// ** that page might be marked as dirty. This happens, for example, when +// ** the page has been added as a leaf of the freelist and so its +// ** content no longer matters. +// ** +// ** The overlying software layer calls this routine when all of the data +// ** on the given page is unused. The pager marks the page as clean so +// ** that it does not get written to disk. +// ** +// ** Tests show that this optimization can quadruple the speed of large +// ** DELETE operations. +// ** +// ** This optimization cannot be used with a temp-file, as the page may +// ** have been dirty at the start of the transaction. In that case, if +// ** memory pressure forces page pPg out of the cache, the data does need +// ** to be written out to disk so that it may be read back in if the +// ** current transaction is rolled back. +// */ +func _sqlite3PagerDontWrite(tls *libc.TLS, pPg uintptr) { + var pPager, v1 uintptr + _, _ = pPager, v1 + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager + if !((*TPager)(unsafe.Pointer(pPager)).FtempFile != 0) && libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pPg)).Fflags)&int32(PGHDR_DIRTY) != 0 && (*TPager)(unsafe.Pointer(pPager)).FnSavepoint == 0 { + v1 = pPg + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(PGHDR_DONT_WRITE)) + v1 = pPg + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(PGHDR_WRITEABLE)) + } +} + +// C documentation +// +// /* +// ** Return the approximate number of bytes of memory currently +// ** used by the pager and its associated cache. +// */ +func _sqlite3PagerMemUsed(tls *libc.TLS, pPager uintptr) (r int32) { + var perPageSize int32 + _ = perPageSize + perPageSize = int32((*TPager)(unsafe.Pointer(pPager)).FpageSize + libc.Int64FromUint16((*TPager)(unsafe.Pointer(pPager)).FnExtra) + int64(libc.Int32FromUint64(libc.Uint64FromInt64(80)+libc.Uint64FromInt32(5)*libc.Uint64FromInt64(8)))) + return int32(int64(perPageSize*_sqlite3PcachePagecount(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache)+_sqlite3MallocSize(tls, pPager)) + (*TPager)(unsafe.Pointer(pPager)).FpageSize) +} + +// C documentation +// +// /* +// ** Move the page pPg to location pgno in the file. +// ** +// ** There must be no references to the page previously located at +// ** pgno (which we call pPgOld) though that page is allowed to be +// ** in cache. If the page previously located at pgno is not already +// ** in the rollback journal, it is not put there by by this routine. +// ** +// ** References to the page pPg remain valid. Updating any +// ** meta-data associated with pPg (i.e. data stored in the nExtra bytes +// ** allocated along with the page) is the responsibility of the caller. +// ** +// ** A transaction must be active when this routine is called. It used to be +// ** required that a statement transaction was not active, but this restriction +// ** has been removed (CREATE INDEX needs to move a page when a statement +// ** transaction is active). +// ** +// ** If the fourth argument, isCommit, is non-zero, then this page is being +// ** moved as part of a database reorganization just before the transaction +// ** is being committed. In this case, it is guaranteed that the database page +// ** pPg refers to will not be written to again within this transaction. +// ** +// ** This function may return SQLITE_NOMEM or an IO error code if an error +// ** occurs. Otherwise, it returns SQLITE_OK. +// */ +func _sqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno TPgno, isCommit int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var needSyncPgno, origPgno TPgno + var pPgOld, v3 uintptr + var rc, v1 int32 + var v2 bool + var _ /* pPgHdr at bp+0 */ uintptr + _, _, _, _, _, _, _ = needSyncPgno, origPgno, pPgOld, rc, v1, v2, v3 /* The page being overwritten. */ + needSyncPgno = uint32(0) /* The original page number */ + /* In order to be able to rollback, an in-memory database must journal + ** the page we are moving from. + */ + if (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 { + rc = _sqlite3PagerWrite(tls, pPg) + if rc != 0 { + return rc + } + } + /* If the page being moved is dirty and has not been saved by the latest + ** savepoint, then save the current contents of the page into the + ** sub-journal now. This is required to handle the following scenario: + ** + ** BEGIN; + ** + ** SAVEPOINT one; + ** + ** ROLLBACK TO one; + ** + ** If page X were not written to the sub-journal here, it would not + ** be possible to restore its contents when the "ROLLBACK TO one" + ** statement were is processed. + ** + ** subjournalPage() may need to allocate space to store pPg->pgno into + ** one or more savepoint bitvecs. This is the reason this function + ** may return SQLITE_NOMEM. + */ + if v2 = libc.Int32FromUint16((*TDbPage)(unsafe.Pointer(pPg)).Fflags)&int32(PGHDR_DIRTY) != 0; v2 { + v1 = _subjournalPageIfRequired(tls, pPg) + rc = v1 + } + if v2 && SQLITE_OK != v1 { + return rc + } + /* If the journal needs to be sync()ed before page pPg->pgno can + ** be written to, store pPg->pgno in local variable needSyncPgno. + ** + ** If the isCommit flag is set, there is no need to remember that + ** the journal needs to be sync()ed before database page pPg->pgno + ** can be written to. The caller has already promised not to write to it. + */ + if libc.Int32FromUint16((*TDbPage)(unsafe.Pointer(pPg)).Fflags)&int32(PGHDR_NEED_SYNC) != 0 && !(isCommit != 0) { + needSyncPgno = (*TDbPage)(unsafe.Pointer(pPg)).Fpgno + } + /* If the cache contains a page with page-number pgno, remove it + ** from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for + ** page pgno before the 'move' operation, it needs to be retained + ** for the page moved there. + */ + v3 = pPg + 52 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^libc.Int32FromInt32(PGHDR_NEED_SYNC)) + pPgOld = _sqlite3PagerLookup(tls, pPager, pgno) + if pPgOld != 0 { + if (*TPgHdr)(unsafe.Pointer(pPgOld)).FnRef > int64(1) { + _sqlite3PagerUnrefNotNull(tls, pPgOld) + return _sqlite3CorruptError(tls, int32(66838)) + } + v3 = pPg + 52 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pPgOld)).Fflags)&libc.Int32FromInt32(PGHDR_NEED_SYNC)) + if (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 { + /* Do not discard pages from an in-memory database since we might + ** need to rollback later. Just move the page out of the way. */ + _sqlite3PcacheMove(tls, pPgOld, (*TPager)(unsafe.Pointer(pPager)).FdbSize+uint32(1)) + } else { + _sqlite3PcacheDrop(tls, pPgOld) + } + } + origPgno = (*TDbPage)(unsafe.Pointer(pPg)).Fpgno + _sqlite3PcacheMove(tls, pPg, pgno) + _sqlite3PcacheMakeDirty(tls, pPg) + /* For an in-memory database, make sure the original page continues + ** to exist, in case the transaction needs to roll back. Use pPgOld + ** as the original page since it has already been allocated. + */ + if (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 && pPgOld != 0 { + _sqlite3PcacheMove(tls, pPgOld, origPgno) + _sqlite3PagerUnrefNotNull(tls, pPgOld) + } + if needSyncPgno != 0 { + rc = _sqlite3PagerGet(tls, pPager, needSyncPgno, bp, 0) + if rc != SQLITE_OK { + if needSyncPgno <= (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize { + _sqlite3BitvecClear(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal, needSyncPgno, (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace) + } + return rc + } + v3 = **(**uintptr)(__ccgo_up(bp)) + 52 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(PGHDR_NEED_SYNC)) + _sqlite3PcacheMakeDirty(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3PagerUnrefNotNull(tls, **(**uintptr)(__ccgo_up(bp))) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is called to rollback or release (commit) a savepoint. +// ** The savepoint to release or rollback need not be the most recently +// ** created savepoint. +// ** +// ** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE. +// ** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with +// ** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes +// ** that have occurred since the specified savepoint was created. +// ** +// ** The savepoint to rollback or release is identified by parameter +// ** iSavepoint. A value of 0 means to operate on the outermost savepoint +// ** (the first created). A value of (Pager.nSavepoint-1) means operate +// ** on the most recently created savepoint. If iSavepoint is greater than +// ** (Pager.nSavepoint-1), then this function is a no-op. +// ** +// ** If a negative value is passed to this function, then the current +// ** transaction is rolled back. This is different to calling +// ** sqlite3PagerRollback() because this function does not terminate +// ** the transaction or unlock the database, it just restores the +// ** contents of the database to its original state. +// ** +// ** In any case, all savepoints with an index greater than iSavepoint +// ** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE), +// ** then savepoint iSavepoint is also destroyed. +// ** +// ** This function may return SQLITE_NOMEM if a memory allocation fails, +// ** or an IO error code if an IO error occurs while rolling back a +// ** savepoint. If no errors occur, SQLITE_OK is returned. +// */ +func _sqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint int32) (r int32) { + var ii, nNew, rc, v1 int32 + var pRel, pSavepoint, v3 uintptr + var sz Ti64 + _, _, _, _, _, _, _, _ = ii, nNew, pRel, pSavepoint, rc, sz, v1, v3 + rc = (*TPager)(unsafe.Pointer(pPager)).FerrCode + if rc == SQLITE_OK && iSavepoint < (*TPager)(unsafe.Pointer(pPager)).FnSavepoint { /* Number of remaining savepoints after this op. */ + /* Figure out how many savepoints will still be active after this + ** operation. Store this value in nNew. Then free resources associated + ** with any savepoints that are destroyed by this operation. + */ + if op == int32(SAVEPOINT_RELEASE) { + v1 = 0 + } else { + v1 = int32(1) + } + nNew = iSavepoint + v1 + ii = nNew + for { + if !(ii < (*TPager)(unsafe.Pointer(pPager)).FnSavepoint) { + break + } + _sqlite3BitvecDestroy(tls, (**(**TPagerSavepoint)(__ccgo_up((*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*56))).FpInSavepoint) + goto _2 + _2: + ; + ii = ii + 1 + } + (*TPager)(unsafe.Pointer(pPager)).FnSavepoint = nNew + /* Truncate the sub-journal so that it only includes the parts + ** that are still in use. */ + if op == int32(SAVEPOINT_RELEASE) { + pRel = (*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(nNew)*56 + if (*TPagerSavepoint)(unsafe.Pointer(pRel)).FbTruncateOnRelease != 0 && (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fsjfd)).FpMethods != uintptr(0) { + /* Only truncate if it is an in-memory sub-journal. */ + if _sqlite3JournalIsInMemory(tls, (*TPager)(unsafe.Pointer(pPager)).Fsjfd) != 0 { + sz = ((*TPager)(unsafe.Pointer(pPager)).FpageSize + int64(4)) * libc.Int64FromUint32((*TPagerSavepoint)(unsafe.Pointer(pRel)).FiSubRec) + rc = _sqlite3OsTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).Fsjfd, sz) + } + (*TPager)(unsafe.Pointer(pPager)).FnSubRec = (*TPagerSavepoint)(unsafe.Pointer(pRel)).FiSubRec + } + } else { + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) || (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) { + if nNew == 0 { + v3 = uintptr(0) + } else { + v3 = (*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(nNew-int32(1))*56 + } + pSavepoint = v3 + rc = _pagerPlaybackSavepoint(tls, pPager, pSavepoint) + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Adjust settings of the pager to those specified in the pgFlags parameter. +// ** +// ** The "level" in pgFlags & PAGER_SYNCHRONOUS_MASK sets the robustness +// ** of the database to damage due to OS crashes or power failures by +// ** changing the number of syncs()s when writing the journals. +// ** There are four levels: +// ** +// ** OFF sqlite3OsSync() is never called. This is the default +// ** for temporary and transient files. +// ** +// ** NORMAL The journal is synced once before writes begin on the +// ** database. This is normally adequate protection, but +// ** it is theoretically possible, though very unlikely, +// ** that an inopertune power failure could leave the journal +// ** in a state which would cause damage to the database +// ** when it is rolled back. +// ** +// ** FULL The journal is synced twice before writes begin on the +// ** database (with some additional information - the nRec field +// ** of the journal header - being written in between the two +// ** syncs). If we assume that writing a +// ** single disk sector is atomic, then this mode provides +// ** assurance that the journal will not be corrupted to the +// ** point of causing damage to the database during rollback. +// ** +// ** EXTRA This is like FULL except that is also syncs the directory +// ** that contains the rollback journal after the rollback +// ** journal is unlinked. +// ** +// ** The above is for a rollback-journal mode. For WAL mode, OFF continues +// ** to mean that no syncs ever occur. NORMAL means that the WAL is synced +// ** prior to the start of checkpoint and that the database file is synced +// ** at the conclusion of the checkpoint if the entire content of the WAL +// ** was written back into the database. But no sync operations occur for +// ** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL +// ** file is synced following each commit operation, in addition to the +// ** syncs associated with NORMAL. There is no difference between FULL +// ** and EXTRA for WAL mode. +// ** +// ** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL. The +// ** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync +// ** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an +// ** ordinary fsync() call. There is no difference between SQLITE_SYNC_FULL +// ** and SQLITE_SYNC_NORMAL on platforms other than MacOSX. But the +// ** synchronous=FULL versus synchronous=NORMAL setting determines when +// ** the xSync primitive is called and is relevant to all platforms. +// ** +// ** Numeric values associated with these states are OFF==1, NORMAL=2, +// ** and FULL=3. +// */ +func _sqlite3PagerSetFlags(tls *libc.TLS, pPager uintptr, pgFlags uint32) { + var level uint32 + var v1 int32 + var v2 uintptr + _, _, _ = level, v1, v2 + level = pgFlags & uint32(PAGER_SYNCHRONOUS_MASK) + if (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 || level == uint32(PAGER_SYNCHRONOUS_OFF) { + (*TPager)(unsafe.Pointer(pPager)).FnoSync = uint8(1) + (*TPager)(unsafe.Pointer(pPager)).FfullSync = uint8(0) + (*TPager)(unsafe.Pointer(pPager)).FextraSync = uint8(0) + } else { + (*TPager)(unsafe.Pointer(pPager)).FnoSync = uint8(0) + if level >= uint32(PAGER_SYNCHRONOUS_FULL) { + v1 = int32(1) + } else { + v1 = 0 + } + (*TPager)(unsafe.Pointer(pPager)).FfullSync = libc.Uint8FromInt32(v1) + /* Set Pager.extraSync if "PRAGMA synchronous=EXTRA" is requested, or + ** if the file-system supports F2FS style atomic writes. If this flag + ** is set, SQLite syncs the directory to disk immediately after deleting + ** a journal file in "PRAGMA journal_mode=DELETE" mode. */ + if level == uint32(PAGER_SYNCHRONOUS_EXTRA) { + (*TPager)(unsafe.Pointer(pPager)).FextraSync = uint8(1) + } else { + (*TPager)(unsafe.Pointer(pPager)).FextraSync = uint8(0) + } + } + if (*TPager)(unsafe.Pointer(pPager)).FnoSync != 0 { + (*TPager)(unsafe.Pointer(pPager)).FsyncFlags = uint8(0) + } else { + if pgFlags&uint32(PAGER_FULLFSYNC) != 0 { + (*TPager)(unsafe.Pointer(pPager)).FsyncFlags = uint8(SQLITE_SYNC_FULL) + } else { + (*TPager)(unsafe.Pointer(pPager)).FsyncFlags = uint8(SQLITE_SYNC_NORMAL) + } + } + (*TPager)(unsafe.Pointer(pPager)).FwalSyncFlags = libc.Uint8FromInt32(libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FsyncFlags) << libc.Int32FromInt32(2)) + if (*TPager)(unsafe.Pointer(pPager)).FfullSync != 0 { + v2 = pPager + 15 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) | libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FsyncFlags)) + } + if pgFlags&uint32(PAGER_CKPT_FULLFSYNC) != 0 && !((*TPager)(unsafe.Pointer(pPager)).FnoSync != 0) { + v2 = pPager + 15 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(SQLITE_SYNC_FULL)< +// **
  • A pointer to the parser (an opaque structure.) +// **
  • The major token number. +// **
  • The minor token number. +// **
  • An option argument of a grammar-specified type. +// ** +// ** +// ** Outputs: +// ** None. +// */ +func _sqlite3Parser(tls *libc.TLS, yyp uintptr, yymajor int32, yyminor TToken) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pParse, yypParser uintptr + var yyact uint16 + var yyruleno uint32 + var _ /* yyminorunion at bp+0 */ TYYMINORTYPE + _, _, _, _ = pParse, yyact, yypParser, yyruleno /* The parser action. */ + yypParser = yyp /* The parser */ + pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse + yyact = (*TyyStackEntry)(unsafe.Pointer((*TyyParser)(unsafe.Pointer(yypParser)).Fyytos)).Fstateno + for int32(1) != 0 { /* Exit by "break" */ + yyact = _yy_find_shift_action(tls, libc.Uint16FromInt32(yymajor), yyact) + if libc.Int32FromUint16(yyact) >= int32(YY_MIN_REDUCE) { + yyruleno = libc.Uint32FromInt32(libc.Int32FromUint16(yyact) - int32(YY_MIN_REDUCE)) /* Reduce by this rule */ + /* Check that the stack is large enough to grow by a single entry + ** if the RHS of the rule is empty. This ensures that there is room + ** enough on the stack to push the LHS value */ + if int32(_yyRuleInfoNRhs[yyruleno]) == 0 { + if (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos >= (*TyyParser)(unsafe.Pointer(yypParser)).FyystackEnd { + if _yyGrowStack(tls, yypParser) != 0 { + _yyStackOverflow(tls, yypParser) + break + } + } + } + yyact = _yy_reduce(tls, yypParser, yyruleno, yymajor, yyminor, pParse) + } else { + if libc.Int32FromUint16(yyact) <= int32(YY_MAX_SHIFTREDUCE) { + _yy_shift(tls, yypParser, yyact, libc.Uint16FromInt32(yymajor), yyminor) + break + } else { + if libc.Int32FromUint16(yyact) == int32(YY_ACCEPT_ACTION) { + (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos -= 24 + _yy_accept(tls, yypParser) + return + } else { + *(*TToken)(unsafe.Pointer(bp)) = yyminor + /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to + ** do any kind of error recovery. Instead, simply invoke the syntax + ** error routine and continue going as if nothing had happened. + ** + ** Applications can set this macro (for example inside %include) if + ** they intend to abandon the parse upon the first syntax error seen. + */ + _yy_syntax_error(tls, yypParser, yymajor, yyminor) + _yy_destructor(tls, yypParser, libc.Uint16FromInt32(yymajor), bp) + break + } + } + } + } + return +} + +// C documentation +// +// /* +// ** Clear all secondary memory allocations from the parser +// */ +func _sqlite3ParserFinalize(tls *libc.TLS, p uintptr) { + var pParser, yytos uintptr + _, _ = pParser, yytos + pParser = p + /* In-lined version of calling yy_pop_parser_stack() for each + ** element left in the stack */ + yytos = (*TyyParser)(unsafe.Pointer(pParser)).Fyytos + for yytos > (*TyyParser)(unsafe.Pointer(pParser)).Fyystack { + if libc.Int32FromUint16((*TyyStackEntry)(unsafe.Pointer(yytos)).Fmajor) >= int32(YY_MIN_DSTRCTR) { + _yy_destructor(tls, pParser, (*TyyStackEntry)(unsafe.Pointer(yytos)).Fmajor, yytos+8) + } + yytos -= 24 + } + if (*TyyParser)(unsafe.Pointer(pParser)).Fyystack != pParser+32 { + _parserStackFree(tls, (*TyyParser)(unsafe.Pointer(pParser)).Fyystack, (*TyyParser)(unsafe.Pointer(pParser)).FpParse) + } +} + +/* +** Return the peak depth of the stack for a parser. + */ + +/* This array of booleans keeps track of the parser statement +** coverage. The element yycoverage[X][Y] is set when the parser +** is in state X and has a lookahead token Y. In a well-tested +** systems, every element of this matrix should end up being set. + */ + +/* +** Write into out a description of every state/lookahead combination that +** +** (1) has not been used by the parser, and +** (2) is not a syntax error. +** +** Return the number of missed state/lookahead combinations. + */ + +// C documentation +// +// /* +// ** Make sure the page is marked as dirty. If it isn't dirty already, +// ** make it so. +// */ +func _sqlite3PcacheMakeDirty(tls *libc.TLS, p uintptr) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(PGHDR_CLEAN)|libc.Int32FromInt32(PGHDR_DONT_WRITE)) != 0 { /*OPTIMIZATION-IF-FALSE*/ + v1 = p + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(PGHDR_DONT_WRITE)) + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(p)).Fflags)&int32(PGHDR_CLEAN) != 0 { + v1 = p + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) ^ (libc.Int32FromInt32(PGHDR_DIRTY) | libc.Int32FromInt32(PGHDR_CLEAN))) + _pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_ADD)) + } + } +} + +// C documentation +// +// /* +// ** Decrement the reference count on a page. If the page is clean and the +// ** reference count drops to 0, then it is made eligible for recycling. +// */ +func _sqlite3PcacheRelease(tls *libc.TLS, p uintptr) { + var v1 Ti64 + var v2 uintptr + _, _ = v1, v2 + (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum = (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum - 1 + v2 = p + 56 + *(*Ti64)(unsafe.Pointer(v2)) = *(*Ti64)(unsafe.Pointer(v2)) - 1 + v1 = *(*Ti64)(unsafe.Pointer(v2)) + if v1 == 0 { + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(p)).Fflags)&int32(PGHDR_CLEAN) != 0 { + _pcacheUnpin(tls, p) + } else { + _pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_FRONT)) + } + } +} + +// C documentation +// +// /* +// ** Change the page size for PCache object. The caller must ensure that there +// ** are no outstanding page references when this function is called. +// */ +func _sqlite3PcacheSetPageSize(tls *libc.TLS, pCache uintptr, szPage int32) (r int32) { + var pNew uintptr + _ = pNew + if (*TPCache)(unsafe.Pointer(pCache)).FszPage != 0 { + pNew = (*(*func(*libc.TLS, int32, int32, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxCreate})))(tls, szPage, libc.Int32FromUint64(libc.Uint64FromInt32((*TPCache)(unsafe.Pointer(pCache)).FszExtra)+(libc.Uint64FromInt64(80)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))), libc.Int32FromUint8((*TPCache)(unsafe.Pointer(pCache)).FbPurgeable)) + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxCachesize})))(tls, pNew, _numberOfCachePages(tls, pCache)) + if (*TPCache)(unsafe.Pointer(pCache)).FpCache != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxDestroy})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache) + } + (*TPCache)(unsafe.Pointer(pCache)).FpCache = pNew + (*TPCache)(unsafe.Pointer(pCache)).FszPage = szPage + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** If pExpr has a byte offset for the start of a token, record that as +// ** as the error offset. +// */ +func _sqlite3RecordErrorOffsetOfExpr(tls *libc.TLS, db uintptr, pExpr uintptr) { + for pExpr != 0 && ((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) || *(*int32)(unsafe.Pointer(pExpr + 52)) <= 0) { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + } + if pExpr == uintptr(0) { + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) != uint32(0) { + return + } + (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = *(*int32)(unsafe.Pointer(pExpr + 52)) +} + +// C documentation +// +// /* +// ** Generate code that will erase and refill index *pIdx. This is +// ** used to initialize a newly created index or to recompute the +// ** content of an index in response to a REINDEX command. +// ** +// ** if memRootPage is not negative, it means that the index is newly +// ** created. The register specified by memRootPage contains the +// ** root page number of the index. If memRootPage is negative, then +// ** the index already exists and must be cleared before being refilled and +// ** the root page number of the index is taken from pIndex->tnum. +// */ +func _sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPage int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var addr1, addr2, iDb, iIdx, iSorter, iTab, j2, regRecord, v1, v3 int32 + var db, pKey, pTab, v, v2, v4 uintptr + var tnum TPgno + var _ /* iPartIdxLabel at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr1, addr2, db, iDb, iIdx, iSorter, iTab, j2, pKey, pTab, regRecord, tnum, v, v1, v2, v3, v4 + pTab = (*TIndex)(unsafe.Pointer(pIndex)).FpTable + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 /* The table that is indexed */ + iTab = v1 + v4 = pParse + 56 + v3 = *(*int32)(unsafe.Pointer(v4)) + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) + 1 /* Btree cursor used for pTab */ + iIdx = v3 /* Register holding assembled index record */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The database connection */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIndex)).FpSchema) + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_REINDEX), (*TIndex)(unsafe.Pointer(pIndex)).FzName, uintptr(0), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) != 0 { + return + } + /* Require a write-lock on the table to perform this operation */ + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(1), (*TTable)(unsafe.Pointer(pTab)).FzName) + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + return + } + if memRootPage >= 0 { + tnum = libc.Uint32FromInt32(memRootPage) + } else { + tnum = (*TIndex)(unsafe.Pointer(pIndex)).Ftnum + } + pKey = _sqlite3KeyInfoOfIndex(tls, pParse, pIndex) + /* Open the sorter cursor if we are to use one. */ + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + iSorter = v1 + _sqlite3VdbeAddOp4(tls, v, int32(OP_SorterOpen), iSorter, 0, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol), _sqlite3KeyInfoRef(tls, pKey), -int32(9)) + /* Open the table. Loop through all rows of the table, inserting index + ** records into the sorter. */ + _sqlite3OpenTable(tls, pParse, iTab, iDb, pTab, int32(OP_OpenRead)) + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iTab, 0) + regRecord = _sqlite3GetTempReg(tls, pParse) + _sqlite3MultiWrite(tls, pParse) + _sqlite3GenerateIndexKey(tls, pParse, pIndex, iTab, regRecord, 0, bp, uintptr(0), 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterInsert), iSorter, regRecord) + _sqlite3ResolvePartIdxLabel(tls, pParse, **(**int32)(__ccgo_up(bp))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iTab, addr1+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addr1) + if memRootPage < 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Clear), libc.Int32FromUint32(tnum), iDb) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_OpenWrite), iIdx, libc.Int32FromUint32(tnum), iDb, pKey, -int32(9)) + if memRootPage >= 0 { + v1 = int32(OPFLAG_P2ISREG) + } else { + v1 = 0 + } + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(int32(OPFLAG_BULKCSR)|v1)) + addr1 = _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterSort), iSorter, 0) + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) != OE_None { + j2 = _sqlite3VdbeGoto(tls, v, int32(1)) + addr2 = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_SorterCompare), iSorter, j2, regRecord, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol)) + _sqlite3UniqueConstraint(tls, pParse, int32(OE_Abort), pIndex) + _sqlite3VdbeJumpHere(tls, v, j2) + } else { + /* Most CREATE INDEX and REINDEX statements that are not UNIQUE can not + ** abort. The exception is if one of the indexed expressions contains a + ** user function that throws an exception when it is evaluated. But the + ** overhead of adding a statement journal to a CREATE INDEX statement is + ** very small (since most of the pages written do not contain content that + ** needs to be restored if the statement aborts), so we call + ** sqlite3MayAbort() for all CREATE INDEX statements. */ + _sqlite3MayAbort(tls, pParse) + addr2 = _sqlite3VdbeCurrentAddr(tls, v) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_SorterData), iSorter, regRecord, iIdx) + if !(int32(uint32(*(*uint16)(unsafe.Pointer(pIndex + 100))&0x200>>9)) != 0) { + /* This OP_SeekEnd opcode makes index insert for a REINDEX go much + ** faster by avoiding unnecessary seeks. But the optimization does + ** not work for UNIQUE constraint indexes on WITHOUT ROWID tables + ** with DESC primary keys, since those indexes have there keys in + ** a different order from the main table. + ** See ticket: https://sqlite.org/src/info/bba7b69f9849b5bf + */ + _sqlite3VdbeAddOp1(tls, v, int32(OP_SeekEnd), iIdx) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), iIdx, regRecord) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + _sqlite3ReleaseTempReg(tls, pParse, regRecord) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SorterNext), iSorter, addr2) + _sqlite3VdbeJumpHere(tls, v, addr1) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iTab) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iIdx) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iSorter) +} + +// C documentation +// +// /* +// ** All of the FuncDef structures in the aBuiltinFunc[] array above +// ** to the global function hash table. This occurs at start-time (as +// ** a consequence of calling sqlite3_initialize()). +// ** +// ** After this routine runs +// */ +func _sqlite3RegisterBuiltinFunctions(tls *libc.TLS) { + _sqlite3AlterFunctions(tls) + _sqlite3WindowFunctions(tls) + _sqlite3RegisterDateTimeFunctions(tls) + _sqlite3RegisterJsonFunctions(tls) + _sqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&_aBuiltinFunc)), libc.Int32FromUint64(libc.Uint64FromInt64(7632)/libc.Uint64FromInt64(72))) +} + +// C documentation +// +// /* +// ** This function registered all of the above C functions as SQL +// ** functions. This should be the only routine in this file with +// ** external linkage. +// */ +func _sqlite3RegisterDateTimeFunctions(tls *libc.TLS) { + _sqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&_aDateTimeFuncs)), libc.Int32FromUint64(libc.Uint64FromInt64(720)/libc.Uint64FromInt64(72))) +} + +// C documentation +// +// /* +// ** Register JSON functions. +// */ +func _sqlite3RegisterJsonFunctions(tls *libc.TLS) { + _sqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&_aJsonFunc)), libc.Int32FromUint64(libc.Uint64FromInt64(2592)/libc.Uint64FromInt64(72))) +} + +// C documentation +// +// /* +// ** Deallocate a register, making available for reuse for some other +// ** purpose. +// */ +func _sqlite3ReleaseTempReg(tls *libc.TLS, pParse uintptr, iReg int32) { + var v1 Tu8 + var v2 uintptr + _, _ = v1, v2 + if iReg != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FnTempReg) < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4)) { + v2 = pParse + 31 + v1 = *(*Tu8)(unsafe.Pointer(v2)) + *(*Tu8)(unsafe.Pointer(v2)) = *(*Tu8)(unsafe.Pointer(v2)) + 1 + **(**int32)(__ccgo_up(pParse + 184 + uintptr(v1)*4)) = iReg + } + } +} + +// C documentation +// +// /* +// ** Remember that the parser tree element pPtr was created using +// ** the token pToken. +// ** +// ** In other words, construct a new RenameToken object and add it +// ** to the list of RenameToken objects currently being built up +// ** in pParse->pRename. +// ** +// ** The pPtr argument is returned so that this routine can be used +// ** with tail recursion in tokenExpr() routine, for a small performance +// ** improvement. +// */ +func _sqlite3RenameTokenMap(tls *libc.TLS, pParse uintptr, pPtr uintptr, pToken uintptr) (r uintptr) { + var pNew uintptr + _ = pNew + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != int32(PARSE_MODE_UNMAP) { + pNew = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(32)) + if pNew != 0 { + (*TRenameToken)(unsafe.Pointer(pNew)).Fp = pPtr + (*TRenameToken)(unsafe.Pointer(pNew)).Ft = **(**TToken)(__ccgo_up(pToken)) + (*TRenameToken)(unsafe.Pointer(pNew)).FpNext = (*TParse)(unsafe.Pointer(pParse)).FpRename + (*TParse)(unsafe.Pointer(pParse)).FpRename = pNew + } + } + return pPtr +} + +// C documentation +// +// /* +// ** Erase all schema information from all attached databases (including +// ** "main" and "temp") for a single database connection. +// */ +func _sqlite3ResetAllSchemasOfConnection(tls *libc.TLS, db uintptr) { + var i int32 + var pDb, v2 uintptr + _, _, _ = i, pDb, v2 + _sqlite3BtreeEnterAll(tls, db) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpSchema != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock == uint32(0) { + _sqlite3SchemaClear(tls, (*TDb)(unsafe.Pointer(pDb)).FpSchema) + } else { + v2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(DB_ResetWanted)) + } + } + goto _1 + _1: + ; + i = i + 1 + } + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^(libc.Int32FromInt32(DBFLAG_SchemaChange) | libc.Int32FromInt32(DBFLAG_SchemaKnownOk))) + _sqlite3VtabUnlockList(tls, db) + _sqlite3BtreeLeaveAll(tls, db) + if (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock == uint32(0) { + _sqlite3CollapseDatabaseArray(tls, db) + } +} + +// C documentation +// +// /* +// ** Reset the schema for the database at index iDb. Also reset the +// ** TEMP schema. The reset is deferred if db->nSchemaLock is not zero. +// ** Deferred resets may be run by calling with iDb<0. +// */ +func _sqlite3ResetOneSchema(tls *libc.TLS, db uintptr, iDb int32) { + var i int32 + var v1 uintptr + _, _ = i, v1 + if iDb >= 0 { + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(DB_ResetWanted)) + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(DB_ResetWanted)) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_SchemaKnownOk)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock == uint32(0) { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if libc.Int32FromUint16((*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema)).FschemaFlags)&int32(DB_ResetWanted) == int32(DB_ResetWanted) { + _sqlite3SchemaClear(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema) + } + goto _3 + _3: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** Resolve all names for all expression in an expression list. This is +// ** just like sqlite3ResolveExprNames() except that it works for an expression +// ** list rather than a single expression. +// ** +// ** The return value is SQLITE_OK (0) for success or SQLITE_ERROR (1) for a +// ** failure. +// */ +func _sqlite3ResolveExprListNames(tls *libc.TLS, pNC uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, savedHasAgg int32 + var pExpr uintptr + var _ /* w at bp+0 */ TWalker + _, _, _ = i, pExpr, savedHasAgg + savedHasAgg = 0 + if pList == uintptr(0) { + return SQLITE_OK + } + (**(**TWalker)(__ccgo_up(bp))).FpParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_resolveExprStep) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_resolveSelectStep) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 40)) = pNC + savedHasAgg = (*TNameContext)(unsafe.Pointer(pNC)).FncFlags & (libc.Int32FromInt32(NC_HasAgg) | libc.Int32FromInt32(NC_MinMaxAgg) | libc.Int32FromInt32(NC_HasWin) | libc.Int32FromInt32(NC_OrderAgg)) + **(**int32)(__ccgo_up(pNC + 40)) &= ^(libc.Int32FromInt32(NC_HasAgg) | libc.Int32FromInt32(NC_MinMaxAgg) | libc.Int32FromInt32(NC_HasWin) | libc.Int32FromInt32(NC_OrderAgg)) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr + if pExpr == uintptr(0) { + goto _1 + } + **(**int32)(__ccgo_up((**(**TWalker)(__ccgo_up(bp))).FpParse + 308)) += (*TExpr)(unsafe.Pointer(pExpr)).FnHeight + if _sqlite3ExprCheckHeight(tls, (**(**TWalker)(__ccgo_up(bp))).FpParse, (*TParse)(unsafe.Pointer((**(**TWalker)(__ccgo_up(bp))).FpParse)).FnHeight) != 0 { + return int32(SQLITE_ERROR) + } + _sqlite3WalkExprNN(tls, bp, pExpr) + **(**int32)(__ccgo_up((**(**TWalker)(__ccgo_up(bp))).FpParse + 308)) -= (*TExpr)(unsafe.Pointer(pExpr)).FnHeight + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_HasAgg)|libc.Int32FromInt32(NC_MinMaxAgg)|libc.Int32FromInt32(NC_HasWin)|libc.Int32FromInt32(NC_OrderAgg)) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32((*TNameContext)(unsafe.Pointer(pNC)).FncFlags & (libc.Int32FromInt32(NC_HasAgg) | libc.Int32FromInt32(NC_HasWin))) + savedHasAgg = savedHasAgg | (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_HasAgg)|libc.Int32FromInt32(NC_MinMaxAgg)|libc.Int32FromInt32(NC_HasWin)|libc.Int32FromInt32(NC_OrderAgg)) + **(**int32)(__ccgo_up(pNC + 40)) &= ^(libc.Int32FromInt32(NC_HasAgg) | libc.Int32FromInt32(NC_MinMaxAgg) | libc.Int32FromInt32(NC_HasWin) | libc.Int32FromInt32(NC_OrderAgg)) + } + if (*TParse)(unsafe.Pointer((**(**TWalker)(__ccgo_up(bp))).FpParse)).FnErr > 0 { + return int32(SQLITE_ERROR) + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(pNC + 40)) |= savedHasAgg + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This routine walks an expression tree and resolves references to +// ** table columns and result-set columns. At the same time, do error +// ** checking on function usage and set a flag if any aggregate functions +// ** are seen. +// ** +// ** To resolve table columns references we look for nodes (or subtrees) of the +// ** form X.Y.Z or Y.Z or just Z where +// ** +// ** X: The name of a database. Ex: "main" or "temp" or +// ** the symbolic name assigned to an ATTACH-ed database. +// ** +// ** Y: The name of a table in a FROM clause. Or in a trigger +// ** one of the special names "old" or "new". +// ** +// ** Z: The name of a column in table Y. +// ** +// ** The node at the root of the subtree is modified as follows: +// ** +// ** Expr.op Changed to TK_COLUMN +// ** Expr.pTab Points to the Table object for X.Y +// ** Expr.iColumn The column index in X.Y. -1 for the rowid. +// ** Expr.iTable The VDBE cursor number for X.Y +// ** +// ** +// ** To resolve result-set references, look for expression nodes of the +// ** form Z (with no X and Y prefix) where the Z matches the right-hand +// ** size of an AS clause in the result-set of a SELECT. The Z expression +// ** is replaced by a copy of the left-hand side of the result-set expression. +// ** Table-name and function resolution occurs on the substituted expression +// ** tree. For example, in: +// ** +// ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x; +// ** +// ** The "x" term of the order by is replaced by "a+b" to render: +// ** +// ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b; +// ** +// ** Function calls are checked to make sure that the function is +// ** defined and that the correct number of arguments are specified. +// ** If the function is an aggregate function, then the NC_HasAgg flag is +// ** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION. +// ** If an expression contains aggregate functions then the EP_Agg +// ** property on the expression is set. +// ** +// ** An error message is left in pParse if anything is amiss. The number +// ** if errors is returned. +// */ +func _sqlite3ResolveExprNames(tls *libc.TLS, pNC uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var savedHasAgg int32 + var v1 uintptr + var _ /* w at bp+0 */ TWalker + _, _ = savedHasAgg, v1 + if pExpr == uintptr(0) { + return SQLITE_OK + } + savedHasAgg = (*TNameContext)(unsafe.Pointer(pNC)).FncFlags & (libc.Int32FromInt32(NC_HasAgg) | libc.Int32FromInt32(NC_MinMaxAgg) | libc.Int32FromInt32(NC_HasWin) | libc.Int32FromInt32(NC_OrderAgg)) + **(**int32)(__ccgo_up(pNC + 40)) &= ^(libc.Int32FromInt32(NC_HasAgg) | libc.Int32FromInt32(NC_MinMaxAgg) | libc.Int32FromInt32(NC_HasWin) | libc.Int32FromInt32(NC_OrderAgg)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_resolveExprStep) + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_NoSelect) != 0 { + v1 = uintptr(0) + } else { + v1 = __ccgo_fp(_resolveSelectStep) + } + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = v1 + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 40)) = pNC + **(**int32)(__ccgo_up((**(**TWalker)(__ccgo_up(bp))).FpParse + 308)) += (*TExpr)(unsafe.Pointer(pExpr)).FnHeight + if _sqlite3ExprCheckHeight(tls, (**(**TWalker)(__ccgo_up(bp))).FpParse, (*TParse)(unsafe.Pointer((**(**TWalker)(__ccgo_up(bp))).FpParse)).FnHeight) != 0 { + return int32(SQLITE_ERROR) + } + _sqlite3WalkExprNN(tls, bp, pExpr) + **(**int32)(__ccgo_up((**(**TWalker)(__ccgo_up(bp))).FpParse + 308)) -= (*TExpr)(unsafe.Pointer(pExpr)).FnHeight + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32((*TNameContext)(unsafe.Pointer(pNC)).FncFlags & (libc.Int32FromInt32(NC_HasAgg) | libc.Int32FromInt32(NC_HasWin))) + **(**int32)(__ccgo_up(pNC + 40)) |= savedHasAgg + return libc.BoolInt32((*TNameContext)(unsafe.Pointer(pNC)).FnNcErr > 0 || (*TParse)(unsafe.Pointer((**(**TWalker)(__ccgo_up(bp))).FpParse)).FnErr > 0) +} + +// C documentation +// +// /* Force the INT64 value currently stored as the result to be +// ** a MEM_IntReal value. See the SQLITE_TESTCTRL_RESULT_INTREAL +// ** test-control. +// */ +func _sqlite3ResultIntReal(tls *libc.TLS, pCtx uintptr) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags)&int32(MEM_Int) != 0 { + v1 = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Int)) + v1 = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_IntReal)) + } +} + +// C documentation +// +// /* If the Expr node is a subquery or an EXISTS operator or an IN operator that +// ** uses a subquery, and if the subquery is SF_Correlated, then mark the +// ** expression as EP_VarSelect. +// */ +func _sqlite3ReturningSubqueryVarSelect(tls *libc.TLS, NotUsed uintptr, pExpr uintptr) (r int32) { + _ = NotUsed + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselFlags&uint32(SF_Correlated) != uint32(0) { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Rollback all database files. If tripCode is not SQLITE_OK, then +// ** any write cursors are invalidated ("tripped" - as in "tripping a circuit +// ** breaker") and made to return tripCode if there are any further +// ** attempts to use that cursor. Read cursors remain open and valid +// ** but are "saved" in case the table pages are moved around. +// */ +func _sqlite3RollbackAll(tls *libc.TLS, db uintptr, tripCode int32) { + var i, inTrans, schemaChange int32 + var p uintptr + _, _, _, _ = i, inTrans, p, schemaChange + inTrans = 0 + _sqlite3BeginBenignMalloc(tls) + /* Obtain all b-tree mutexes before making any calls to BtreeRollback(). + ** This is important in case the transaction being rolled back has + ** modified the database schema. If the b-tree mutexes are not taken + ** here, then another shared-cache connection might sneak in between + ** the database rollback and schema reset, which can cause false + ** corruption reports in some cases. */ + _sqlite3BtreeEnterAll(tls, db) + schemaChange = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_SchemaChange) != uint32(0) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + p = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if p != 0 { + if _sqlite3BtreeTxnState(tls, p) == int32(SQLITE_TXN_WRITE) { + inTrans = int32(1) + } + _sqlite3BtreeRollback(tls, p, tripCode, libc.BoolInt32(!(schemaChange != 0))) + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3VtabRollback(tls, db) + _sqlite3EndBenignMalloc(tls) + if schemaChange != 0 { + _sqlite3ExpirePreparedStatements(tls, db, 0) + _sqlite3ResetAllSchemasOfConnection(tls, db) + } + _sqlite3BtreeLeaveAll(tls, db) + /* Any deferred constraint violations have now been resolved. */ + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = 0 + **(**Tu64)(__ccgo_up(db + 48)) &= ^(libc.Uint64FromInt32(SQLITE_DeferFKs) | libc.Uint64FromInt32(libc.Int32FromInt32(0x00002))<pEntry, then sort those entries into the forest at +// ** pRowSet->pForest so that they can be tested. +// */ +func _sqlite3RowSetTest(tls *libc.TLS, pRowSet uintptr, iBatch int32, iRowid Tsqlite3_int64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p, pTree, ppPrevTree, v2 uintptr + var _ /* pAux at bp+0 */ uintptr + var _ /* pTail at bp+8 */ uintptr + _, _, _, _ = p, pTree, ppPrevTree, v2 + /* This routine is never called after sqlite3RowSetNext() */ + /* Sort entries into the forest on the first test of a new batch. + ** To save unnecessary work, only do this when the batch number changes. + */ + if iBatch != (*TRowSet)(unsafe.Pointer(pRowSet)).FiBatch { /*OPTIMIZATION-IF-FALSE*/ + p = (*TRowSet)(unsafe.Pointer(pRowSet)).FpEntry + if p != 0 { + ppPrevTree = pRowSet + 40 + if libc.Int32FromUint16((*TRowSet)(unsafe.Pointer(pRowSet)).FrsFlags)&int32(ROWSET_SORTED) == 0 { /*OPTIMIZATION-IF-FALSE*/ + /* Only sort the current set of entries if they need it */ + p = _rowSetEntrySort(tls, p) + } + pTree = (*TRowSet)(unsafe.Pointer(pRowSet)).FpForest + for { + if !(pTree != 0) { + break + } + ppPrevTree = pTree + 8 + if (*TRowSetEntry)(unsafe.Pointer(pTree)).FpLeft == uintptr(0) { + (*TRowSetEntry)(unsafe.Pointer(pTree)).FpLeft = _rowSetListToTree(tls, p) + break + } else { + _rowSetTreeToList(tls, (*TRowSetEntry)(unsafe.Pointer(pTree)).FpLeft, bp, bp+8) + (*TRowSetEntry)(unsafe.Pointer(pTree)).FpLeft = uintptr(0) + p = _rowSetEntryMerge(tls, **(**uintptr)(__ccgo_up(bp)), p) + } + goto _1 + _1: + ; + pTree = (*TRowSetEntry)(unsafe.Pointer(pTree)).FpRight + } + if pTree == uintptr(0) { + v2 = _rowSetEntryAlloc(tls, pRowSet) + pTree = v2 + **(**uintptr)(__ccgo_up(ppPrevTree)) = v2 + if pTree != 0 { + (*TRowSetEntry)(unsafe.Pointer(pTree)).Fv = 0 + (*TRowSetEntry)(unsafe.Pointer(pTree)).FpRight = uintptr(0) + (*TRowSetEntry)(unsafe.Pointer(pTree)).FpLeft = _rowSetListToTree(tls, p) + } + } + (*TRowSet)(unsafe.Pointer(pRowSet)).FpEntry = uintptr(0) + (*TRowSet)(unsafe.Pointer(pRowSet)).FpLast = uintptr(0) + v2 = pRowSet + 50 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(ROWSET_SORTED)) + } + (*TRowSet)(unsafe.Pointer(pRowSet)).FiBatch = iBatch + } + /* Test to see if the iRowid value appears anywhere in the forest. + ** Return 1 if it does and 0 if not. + */ + pTree = (*TRowSet)(unsafe.Pointer(pRowSet)).FpForest + for { + if !(pTree != 0) { + break + } + p = (*TRowSetEntry)(unsafe.Pointer(pTree)).FpLeft + for p != 0 { + if (*TRowSetEntry)(unsafe.Pointer(p)).Fv < iRowid { + p = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight + } else { + if (*TRowSetEntry)(unsafe.Pointer(p)).Fv > iRowid { + p = (*TRowSetEntry)(unsafe.Pointer(p)).FpLeft + } else { + return int32(1) + } + } + } + goto _4 + _4: + ; + pTree = (*TRowSetEntry)(unsafe.Pointer(pTree)).FpRight + } + return 0 +} + +/************** End of rowset.c **********************************************/ +/************** Begin file pager.c *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This is the implementation of the page cache subsystem or "pager". +** +** The pager is used to access a database disk file. It implements +** atomic commit and rollback through the use of a journal file that +** is separate from the database file. The pager also implements file +** locking to prevent two processes from writing the same database +** file simultaneously, or one process from reading the database while +** another is writing. + */ +/* #include "sqliteInt.h" */ +/************** Include wal.h in the middle of pager.c ***********************/ +/************** Begin file wal.h *********************************************/ +/* +** 2010 February 1 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the interface to the write-ahead logging +** system. Refer to the comments below and the header comment attached to +** the implementation of each function in log.c for further details. + */ + +/* #include "sqliteInt.h" */ + +/* Macros for extracting appropriate sync flags for either transaction +** commits (WAL_SYNC_FLAGS(X)) or for checkpoint ops (CKPT_SYNC_FLAGS(X)): + */ + +// C documentation +// +// /* +// ** Find and return the schema associated with a BTree. Create +// ** a new one if necessary. +// */ +func _sqlite3SchemaGet(tls *libc.TLS, db uintptr, pBt uintptr) (r uintptr) { + var p uintptr + _ = p + if pBt != 0 { + p = _sqlite3BtreeSchema(tls, pBt, int32(120), __ccgo_fp(_sqlite3SchemaClear)) + } else { + p = _sqlite3DbMallocZero(tls, uintptr(0), uint64(120)) + } + if !(p != 0) { + _sqlite3OomFault(tls, db) + } else { + if 0 == libc.Int32FromUint8((*TSchema)(unsafe.Pointer(p)).Ffile_format) { + _sqlite3HashInit(tls, p+8) + _sqlite3HashInit(tls, p+32) + _sqlite3HashInit(tls, p+56) + _sqlite3HashInit(tls, p+80) + (*TSchema)(unsafe.Pointer(p)).Fenc = uint8(SQLITE_UTF8) + } + } + return p +} + +/************** End of callback.c ********************************************/ +/************** Begin file delete.c ******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains C code routines that are called by the parser +** in order to generate code for DELETE FROM statements. + */ +/* #include "sqliteInt.h" */ + +func _sqlite3SelectDup(tls *libc.TLS, db uintptr, pDup uintptr, flags int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p, pNew, pNext, pp uintptr + var _ /* pRet at bp+0 */ uintptr + _, _, _, _ = p, pNew, pNext, pp + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pNext = uintptr(0) + pp = bp + p = pDup + for { + if !(p != 0) { + break + } + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(120)) + if pNew == uintptr(0) { + break + } + (*TSelect)(unsafe.Pointer(pNew)).FpEList = _sqlite3ExprListDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpEList, flags) + (*TSelect)(unsafe.Pointer(pNew)).FpSrc = _sqlite3SrcListDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpSrc, flags) + (*TSelect)(unsafe.Pointer(pNew)).FpWhere = _sqlite3ExprDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWhere, flags) + (*TSelect)(unsafe.Pointer(pNew)).FpGroupBy = _sqlite3ExprListDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpGroupBy, flags) + (*TSelect)(unsafe.Pointer(pNew)).FpHaving = _sqlite3ExprDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpHaving, flags) + (*TSelect)(unsafe.Pointer(pNew)).FpOrderBy = _sqlite3ExprListDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, flags) + (*TSelect)(unsafe.Pointer(pNew)).Fop = (*TSelect)(unsafe.Pointer(p)).Fop + (*TSelect)(unsafe.Pointer(pNew)).FpNext = pNext + (*TSelect)(unsafe.Pointer(pNew)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpLimit = _sqlite3ExprDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpLimit, flags) + (*TSelect)(unsafe.Pointer(pNew)).FiLimit = 0 + (*TSelect)(unsafe.Pointer(pNew)).FiOffset = 0 + (*TSelect)(unsafe.Pointer(pNew)).FselFlags = (*TSelect)(unsafe.Pointer(p)).FselFlags + (*TSelect)(unsafe.Pointer(pNew)).FnSelectRow = (*TSelect)(unsafe.Pointer(p)).FnSelectRow + (*TSelect)(unsafe.Pointer(pNew)).FpWith = _sqlite3WithDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWith) + (*TSelect)(unsafe.Pointer(pNew)).FpWin = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpWinDefn = _sqlite3WindowListDup(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWinDefn) + if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + _gatherSelectWindows(tls, pNew) + } + (*TSelect)(unsafe.Pointer(pNew)).FselId = (*TSelect)(unsafe.Pointer(p)).FselId + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + /* Any prior OOM might have left the Select object incomplete. + ** Delete the whole thing rather than allow an incomplete Select + ** to be used by the code generator. */ + (*TSelect)(unsafe.Pointer(pNew)).FpNext = uintptr(0) + _sqlite3SelectDelete(tls, db, pNew) + break + } + **(**uintptr)(__ccgo_up(pp)) = pNew + pp = pNew + 72 + pNext = pNew + goto _1 + _1: + ; + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + } + return **(**uintptr)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Allocate a new Select structure and return a pointer to that +// ** structure. +// */ +func _sqlite3SelectNew(tls *libc.TLS, pParse uintptr, pEList uintptr, pSrc uintptr, pWhere uintptr, pGroupBy uintptr, pHaving uintptr, pOrderBy uintptr, selFlags Tu32, pLimit uintptr) (r uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var pAllocated, pNew, v1 uintptr + var v2 int32 + var _ /* standin at bp+0 */ TSelect + _, _, _, _ = pAllocated, pNew, v1, v2 + v1 = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(120)) + pNew = v1 + pAllocated = v1 + if pNew == uintptr(0) { + pNew = bp + } + if pEList == uintptr(0) { + pEList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_ASTERISK), uintptr(0))) + } + (*TSelect)(unsafe.Pointer(pNew)).FpEList = pEList + (*TSelect)(unsafe.Pointer(pNew)).Fop = uint8(TK_SELECT) + (*TSelect)(unsafe.Pointer(pNew)).FselFlags = selFlags + (*TSelect)(unsafe.Pointer(pNew)).FiLimit = 0 + (*TSelect)(unsafe.Pointer(pNew)).FiOffset = 0 + v1 = pParse + 124 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + (*TSelect)(unsafe.Pointer(pNew)).FselId = libc.Uint32FromInt32(v2) + (*TSelect)(unsafe.Pointer(pNew)).FnSelectRow = 0 + if pSrc == uintptr(0) { + pSrc = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(libc.UintptrFromInt32(0)+8)+libc.Uint64FromInt64(80))) + } + (*TSelect)(unsafe.Pointer(pNew)).FpSrc = pSrc + (*TSelect)(unsafe.Pointer(pNew)).FpWhere = pWhere + (*TSelect)(unsafe.Pointer(pNew)).FpGroupBy = pGroupBy + (*TSelect)(unsafe.Pointer(pNew)).FpHaving = pHaving + (*TSelect)(unsafe.Pointer(pNew)).FpOrderBy = pOrderBy + (*TSelect)(unsafe.Pointer(pNew)).FpPrior = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpNext = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpLimit = pLimit + (*TSelect)(unsafe.Pointer(pNew)).FpWith = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpWin = uintptr(0) + (*TSelect)(unsafe.Pointer(pNew)).FpWinDefn = uintptr(0) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + _clearSelect(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pNew, libc.BoolInt32(pNew != bp)) + pAllocated = uintptr(0) + } else { + } + return pAllocated +} + +// C documentation +// +// /* +// ** Return true if zName is a shadow table name in the current database +// ** connection. +// ** +// ** zName is temporarily modified while this routine is running, but is +// ** restored to its original value prior to this routine returning. +// */ +func _sqlite3ShadowTableName(tls *libc.TLS, db uintptr, zName uintptr) (r int32) { + var pTab, zCopy, zTail, v1 uintptr + _, _, _, _ = pTab, zCopy, zTail, v1 + zTail = libc.Xstrrchr(tls, zName, int32('_')) + if zTail == uintptr(0) { + return 0 + } + zCopy = _sqlite3DbStrNDup(tls, db, zName, libc.Uint64FromInt32(int32(int64(zTail)-int64(zName)))) + if zCopy != 0 { + v1 = _sqlite3FindTable(tls, db, zCopy, uintptr(0)) + } else { + v1 = uintptr(0) + } + pTab = v1 + _sqlite3DbFree(tls, db, zCopy) + if pTab == uintptr(0) { + return 0 + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + return 0 + } + return _sqlite3IsShadowTableOf(tls, db, pTab, zName) +} + +// C documentation +// +// /* +// ** When building up a FROM clause in the parser, the join operator +// ** is initially attached to the left operand. But the code generator +// ** expects the join operator to be on the right operand. This routine +// ** Shifts all join operators from left to right for an entire FROM +// ** clause. +// ** +// ** Example: Suppose the join is like this: +// ** +// ** A natural cross join B +// ** +// ** The operator is "natural cross join". The A and B operands are stored +// ** in p->a[0] and p->a[1], respectively. The parser initially stores the +// ** operator with A. This routine shifts that operator over to B. +// ** +// ** Additional changes: +// ** +// ** * All tables to the left of the right-most RIGHT JOIN are tagged with +// ** JT_LTORJ (mnemonic: Left Table Of Right Join) so that the +// ** code generator can easily tell that the table is part of +// ** the left operand of at least one RIGHT JOIN. +// */ +func _sqlite3SrcListShiftJoinType(tls *libc.TLS, pParse uintptr, p uintptr) { + var allFlags, v3 Tu8 + var i, v1 int32 + var v7 uintptr + _, _, _, _, _ = allFlags, i, v1, v3, v7 + _ = pParse + if p != 0 && (*TSrcList)(unsafe.Pointer(p)).FnSrc > int32(1) { + i = (*TSrcList)(unsafe.Pointer(p)).FnSrc - int32(1) + allFlags = uint8(0) + for { + v3 = (*(*TSrcItem)(unsafe.Pointer(p + 8 + uintptr(i-int32(1))*80))).Ffg.Fjointype + (*(*TSrcItem)(unsafe.Pointer(p + 8 + uintptr(i)*80))).Ffg.Fjointype = v3 + allFlags = libc.Uint8FromInt32(int32(allFlags) | libc.Int32FromUint8(v3)) + goto _2 + _2: + ; + i = i - 1 + v1 = i + if !(v1 > 0) { + break + } + } + (*(*TSrcItem)(unsafe.Pointer(p + 8))).Ffg.Fjointype = uint8(0) + /* All terms to the left of a RIGHT JOIN should be tagged with the + ** JT_LTORJ flags */ + if libc.Int32FromUint8(allFlags)&int32(JT_RIGHT) != 0 { + i = (*TSrcList)(unsafe.Pointer(p)).FnSrc - int32(1) + for { + if !(i > 0 && libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(p + 8 + uintptr(i)*80))).Ffg.Fjointype)&int32(JT_RIGHT) == 0) { + break + } + goto _4 + _4: + ; + i = i - 1 + } + i = i - 1 + for { + v7 = p + 8 + uintptr(i)*80 + 24 + *(*Tu8)(unsafe.Pointer(v7)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v7))) | libc.Int32FromInt32(JT_LTORJ)) + goto _6 + _6: + ; + i = i - 1 + v1 = i + if !(v1 >= 0) { + break + } + } + } + } +} + +// C documentation +// +// /* +// ** Unless it is NULL, the argument must be an UnpackedRecord object returned +// ** by an earlier call to sqlite3Stat4ProbeSetValue(). This call deletes +// ** the object. +// */ +func _sqlite3Stat4ProbeFree(tls *libc.TLS, pRec uintptr) { + var aMem, db uintptr + var i, nCol int32 + _, _, _, _ = aMem, db, i, nCol + if pRec != 0 { + nCol = libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo)).FnAllField) + aMem = (*TUnpackedRecord)(unsafe.Pointer(pRec)).FaMem + db = (**(**TMem)(__ccgo_up(aMem))).Fdb + i = 0 + for { + if !(i < nCol) { + break + } + _sqlite3VdbeMemRelease(tls, aMem+uintptr(i)*56) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3KeyInfoUnref(tls, (*TUnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo) + _sqlite3DbFreeNN(tls, db, pRec) + } +} + +// C documentation +// +// /* +// ** Execute the statement pStmt, either until a row of data is ready, the +// ** statement is completely executed or an error occurs. +// ** +// ** This routine implements the bulk of the logic behind the sqlite_step() +// ** API. The only thing omitted is the automatic recompile if a +// ** schema change has occurred. That detail is handled by the +// ** outer sqlite3_step() wrapper procedure. +// */ +func _sqlite3Step(tls *libc.TLS, p uintptr) (r int32) { + var db uintptr + var rc int32 + _, _ = db, rc + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FeVdbeState) != int32(VDBE_RUN_STATE) { + goto restart_step + restart_step: + ; + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FeVdbeState) == int32(VDBE_READY_STATE) { + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x3>>0)) != 0 { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_SCHEMA) + rc = int32(SQLITE_ERROR) + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FprepFlags)&int32(SQLITE_PREPARE_SAVESQL) != 0 { + /* If this statement was prepared using saved SQL and an + ** error has occurred, then return the error code in p->rc to the + ** caller. Set the error code in the database handle to the same + ** value. + */ + rc = _sqlite3VdbeTransferError(tls, p) + } + goto end_of_step + } + /* If there are no other statements currently running, then + ** reset the interrupt flag. This prevents a call to sqlite3_interrupt + ** from interrupting a statement that has not yet started. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&(libc.Int32FromInt32(SQLITE_TRACE_PROFILE)|libc.Int32FromInt32(SQLITE_TRACE_XPROFILE)) != 0 && !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) && (*TVdbe)(unsafe.Pointer(p)).FzSql != 0 { + _sqlite3OsCurrentTimeInt64(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, p+184) + } else { + } + (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive = (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive + 1 + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x40>>6)) == 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite = (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite + 1 + } + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x80>>7)) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead = (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead + 1 + } + (*TVdbe)(unsafe.Pointer(p)).Fpc = 0 + (*TVdbe)(unsafe.Pointer(p)).FeVdbeState = uint8(VDBE_RUN_STATE) + } else { + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FeVdbeState) == int32(VDBE_HALT_STATE) { + /* We used to require that sqlite3_reset() be called before retrying + ** sqlite3_step() after any error or after SQLITE_DONE. But beginning + ** with version 3.7.0, we changed this so that sqlite3_reset() would + ** be called automatically instead of throwing the SQLITE_MISUSE error. + ** This "automatic-reset" change is not technically an incompatibility, + ** since any application that receives an SQLITE_MISUSE is broken by + ** definition. + ** + ** Nevertheless, some published applications that were originally written + ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE + ** returns, and those were broken by the automatic-reset change. As a + ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the + ** legacy behavior of returning SQLITE_MISUSE for cases where the + ** previous sqlite3_step() returned something other than a SQLITE_LOCKED + ** or SQLITE_BUSY error. + */ + Xsqlite3_reset(tls, p) + goto restart_step + } + } + } + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2)) != 0 { + rc = _sqlite3VdbeList(tls, p) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec = (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec + 1 + rc = _sqlite3VdbeExec(tls, p) + (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec = (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec - 1 + } + if rc == int32(SQLITE_ROW) { + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = int32(SQLITE_ROW) + return int32(SQLITE_ROW) + } else { + /* If the statement completed successfully, invoke the profile callback */ + if (*TVdbe)(unsafe.Pointer(p)).FstartTime > 0 { + _invokeProfileCallback(tls, db, p) + } + (*TVdbe)(unsafe.Pointer(p)).FpResultRow = uintptr(0) + if rc == int32(SQLITE_DONE) && (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0 { + (*TVdbe)(unsafe.Pointer(p)).Frc = _doWalCallbacks(tls, db) + if (*TVdbe)(unsafe.Pointer(p)).Frc != SQLITE_OK { + rc = int32(SQLITE_ERROR) + } + } else { + if rc != int32(SQLITE_DONE) && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FprepFlags)&int32(SQLITE_PREPARE_SAVESQL) != 0 { + /* If this statement was prepared using saved SQL and an + ** error has occurred, then return the error code in p->rc to the + ** caller. Set the error code in the database handle to the same value. + */ + rc = _sqlite3VdbeTransferError(tls, p) + } + } + } + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = rc + if int32(SQLITE_NOMEM) == _sqlite3ApiExit(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, (*TVdbe)(unsafe.Pointer(p)).Frc) { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FprepFlags)&int32(SQLITE_PREPARE_SAVESQL) != 0 { + rc = (*TVdbe)(unsafe.Pointer(p)).Frc + } + } + goto end_of_step +end_of_step: + ; + /* There are only a limited number of result codes allowed from the + ** statements prepared using the legacy sqlite3_prepare() interface */ + return rc & (*Tsqlite3)(unsafe.Pointer(db)).FerrMask +} + +// C documentation +// +// /* Convert a storage column number into a table column number. +// ** +// ** The storage column number (0,1,2,....) is the index of the value +// ** as it appears in the record on disk. The true column number +// ** is the index (0,1,2,...) of the column in the CREATE TABLE statement. +// ** +// ** The storage column number is less than the table column number if +// ** and only there are VIRTUAL columns to the left. +// ** +// ** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro. +// */ +func _sqlite3StorageColumnToTable(tls *libc.TLS, pTab uintptr, iCol Ti16) (r Ti16) { + var i int32 + _ = i + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasVirtual) != 0 { + i = 0 + for { + if !(i <= int32(iCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + iCol = iCol + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + } + return iCol +} + +// C documentation +// +// /* +// ** Compute a string length that is limited to what can be stored in +// ** lower 30 bits of a 32-bit signed integer. +// ** +// ** The value returned will never be negative. Nor will it ever be greater +// ** than the actual length of the string. For very long strings (greater +// ** than 1GiB) the value returned might be less than the true string length. +// */ +func _sqlite3Strlen30(tls *libc.TLS, z uintptr) (r int32) { + if z == uintptr(0) { + return 0 + } + return int32(0x3fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, z)) +} + +// C documentation +// +// /* +// ** Make changes to the evolving bytecode to do affinity transformations +// ** of values that are about to be gathered into a row for table pTab. +// ** +// ** For ordinary (legacy, non-strict) tables: +// ** ----------------------------------------- +// ** +// ** Compute the affinity string for table pTab, if it has not already been +// ** computed. As an optimization, omit trailing SQLITE_AFF_BLOB affinities. +// ** +// ** If the affinity string is empty (because it was all SQLITE_AFF_BLOB entries +// ** which were then optimized out) then this routine becomes a no-op. +// ** +// ** Otherwise if iReg>0 then code an OP_Affinity opcode that will set the +// ** affinities for register iReg and following. Or if iReg==0, +// ** then just set the P4 operand of the previous opcode (which should be +// ** an OP_MakeRecord) to the affinity string. +// ** +// ** A column affinity string has one character per column: +// ** +// ** Character Column affinity +// ** --------- --------------- +// ** 'A' BLOB +// ** 'B' TEXT +// ** 'C' NUMERIC +// ** 'D' INTEGER +// ** 'E' REAL +// ** +// ** For STRICT tables: +// ** ------------------ +// ** +// ** Generate an appropriate OP_TypeCheck opcode that will verify the +// ** datatypes against the column definitions in pTab. If iReg==0, that +// ** means an OP_MakeRecord opcode has already been generated and should be +// ** the last opcode generated. The new OP_TypeCheck needs to be inserted +// ** before the OP_MakeRecord. The new OP_TypeCheck should use the same +// ** register set as the OP_MakeRecord. If iReg>0 then register iReg is +// ** the first of a series of registers that will form the new record. +// ** Apply the type checking to that array of registers. +// */ +func _sqlite3TableAffinity(tls *libc.TLS, v uintptr, pTab uintptr, iReg int32) { + var i, p3 int32 + var pPrev, zColAff uintptr + _, _, _, _ = i, p3, pPrev, zColAff + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Strict) != 0 { + if iReg == 0 { + _sqlite3VdbeAppendP4(tls, v, pTab, -int32(5)) + pPrev = _sqlite3VdbeGetLastOp(tls, v) + (*TVdbeOp)(unsafe.Pointer(pPrev)).Fopcode = uint8(OP_TypeCheck) + p3 = (*TVdbeOp)(unsafe.Pointer(pPrev)).Fp3 + (*TVdbeOp)(unsafe.Pointer(pPrev)).Fp3 = 0 + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (*TVdbeOp)(unsafe.Pointer(pPrev)).Fp1, (*TVdbeOp)(unsafe.Pointer(pPrev)).Fp2, p3) + } else { + /* Insert an isolated OP_Typecheck */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_TypeCheck), iReg, int32((*TTable)(unsafe.Pointer(pTab)).FnNVCol)) + _sqlite3VdbeAppendP4(tls, v, pTab, -int32(5)) + } + return + } + zColAff = (*TTable)(unsafe.Pointer(pTab)).FzColAff + if zColAff == uintptr(0) { + zColAff = _sqlite3TableAffinityStr(tls, uintptr(0), pTab) + if !(zColAff != 0) { + _sqlite3OomFault(tls, _sqlite3VdbeDb(tls, v)) + return + } + (*TTable)(unsafe.Pointer(pTab)).FzColAff = zColAff + } + i = libc.Int32FromUint64(libc.Xstrlen(tls, zColAff) & libc.Uint64FromInt32(0x3fffffff)) + if i != 0 { + if iReg != 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), iReg, i, 0, zColAff, i) + } else { + _sqlite3VdbeChangeP4(tls, v, -int32(1), zColAff, i) + } + } +} + +// C documentation +// +// /* Convert a table column number into a storage column number. +// ** +// ** The storage column number (0,1,2,....) is the index of the value +// ** as it appears in the record on disk. Or, if the input column is +// ** the N-th virtual column (zero-based) then the storage number is +// ** the number of non-virtual columns in the table plus N. +// ** +// ** The true column number is the index (0,1,2,...) of the column in +// ** the CREATE TABLE statement. +// ** +// ** If the input column is a VIRTUAL column, then it should not appear +// ** in storage. But the value sometimes is cached in registers that +// ** follow the range of registers used to construct storage. This +// ** avoids computing the same VIRTUAL column multiple times, and provides +// ** values for use by OP_Param opcodes in triggers. Hence, if the +// ** input column is a VIRTUAL table, put it after all the other columns. +// ** +// ** In the following, N means "normal column", S means STORED, and +// ** V means VIRTUAL. Suppose the CREATE TABLE has columns like this: +// ** +// ** CREATE TABLE ex(N,S,V,N,S,V,N,S,V); +// ** -- 0 1 2 3 4 5 6 7 8 +// ** +// ** Then the mapping from this function is as follows: +// ** +// ** INPUTS: 0 1 2 3 4 5 6 7 8 +// ** OUTPUTS: 0 1 6 2 3 7 4 5 8 +// ** +// ** So, in other words, this routine shifts all the virtual columns to +// ** the end. +// ** +// ** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and +// ** this routine is a no-op macro. If the pTab does not have any virtual +// ** columns, then this routine is no-op that always return iCol. If iCol +// ** is negative (indicating the ROWID column) then this routine return iCol. +// */ +func _sqlite3TableColumnToStorage(tls *libc.TLS, pTab uintptr, iCol Ti16) (r Ti16) { + var i int32 + var n Ti16 + _, _ = i, n + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasVirtual) == uint32(0) || int32(iCol) < 0 { + return iCol + } + i = 0 + n = libc.Int16FromInt32(0) + for { + if !(i < int32(iCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + n = n + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + /* iCol is a virtual column itself */ + return int16(int32((*TTable)(unsafe.Pointer(pTab)).FnNVCol) + i - int32(n)) + } else { + /* iCol is a normal or stored column */ + return n + } + return r +} + +// C documentation +// +// /* +// ** Triggers may access values stored in the old.* or new.* pseudo-table. +// ** This function returns a 32-bit bitmask indicating which columns of the +// ** old.* or new.* tables actually are used by triggers. This information +// ** may be used by the caller, for example, to avoid having to load the entire +// ** old.* record into memory when executing an UPDATE or DELETE command. +// ** +// ** Bit 0 of the returned mask is set if the left-most column of the +// ** table may be accessed using an [old|new].
  • reference. Bit 1 is set if +// ** the second leftmost column value is required, and so on. If there +// ** are more than 32 columns in the table, and at least one of the columns +// ** with an index greater than 32 may be accessed, 0xffffffff is returned. +// ** +// ** It is not possible to determine if the old.rowid or new.rowid column is +// ** accessed by triggers. The caller must always assume that it is. +// ** +// ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned +// ** applies to the old.* table. If 1, the new.* table. +// ** +// ** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE +// ** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only +// ** included in the returned mask if the TRIGGER_BEFORE bit is set in the +// ** tr_tm parameter. Similarly, values accessed by AFTER triggers are only +// ** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm. +// */ +func _sqlite3TriggerColmask(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pChanges uintptr, isNew int32, tr_tm int32, pTab uintptr, orconf int32) (r Tu32) { + var mask Tu32 + var op, v1 int32 + var p, pPrg uintptr + _, _, _, _, _ = mask, op, p, pPrg, v1 + if pChanges != 0 { + v1 = int32(TK_UPDATE) + } else { + v1 = int32(TK_DELETE) + } + op = v1 + mask = uint32(0) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + return uint32(0xffffffff) + } + p = pTrigger + for { + if !(p != 0) { + break + } + if libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == op && tr_tm&libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm) != 0 && _checkColumnOverlap(tls, (*TTrigger)(unsafe.Pointer(p)).FpColumns, pChanges) != 0 { + if (*TTrigger)(unsafe.Pointer(p)).FbReturning != 0 { + mask = uint32(0xffffffff) + } else { + pPrg = _getRowTrigger(tls, pParse, p, pTab, orconf) + if pPrg != 0 { + mask = mask | **(**Tu32)(__ccgo_up(pPrg + 28 + uintptr(isNew)*4)) + } + } + } + goto _2 + _2: + ; + p = (*TTrigger)(unsafe.Pointer(p)).FpNext + } + return mask +} + +// C documentation +// +// /* +// ** Given table pTab, return a list of all the triggers attached to +// ** the table. The list is connected by Trigger.pNext pointers. +// ** +// ** All of the triggers on pTab that are in the same database as pTab +// ** are already attached to pTab->pTrigger. But there might be additional +// ** triggers on pTab in the TEMP schema. This routine prepends all +// ** TEMP triggers on pTab to the beginning of the pTab->pTrigger list +// ** and returns the combined list. +// ** +// ** To state it another way: This routine returns a list of all triggers +// ** that fire off of pTab. The list will include any TEMP triggers on +// ** pTab as well as the triggers lised in pTab->pTrigger. +// */ +func _sqlite3TriggerList(tls *libc.TLS, pParse uintptr, pTab uintptr) (r uintptr) { + var p, pList, pTmpSchema, pTrig uintptr + _, _, _, _ = p, pList, pTmpSchema, pTrig /* Loop variable for TEMP triggers */ + pTmpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + 1*32))).FpSchema + p = (*THash)(unsafe.Pointer(pTmpSchema + 56)).Ffirst + pList = (*TTable)(unsafe.Pointer(pTab)).FpTrigger + for p != 0 { + pTrig = (*THashElem)(unsafe.Pointer(p)).Fdata + if (*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema == (*TTable)(unsafe.Pointer(pTab)).FpSchema && (*TTrigger)(unsafe.Pointer(pTrig)).Ftable != 0 && 0 == _sqlite3StrICmp(tls, (*TTrigger)(unsafe.Pointer(pTrig)).Ftable, (*TTable)(unsafe.Pointer(pTab)).FzName) && ((*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema != pTmpSchema || (*TTrigger)(unsafe.Pointer(pTrig)).FbReturning != 0) { + (*TTrigger)(unsafe.Pointer(pTrig)).FpNext = pList + pList = pTrig + } else { + if libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(pTrig)).Fop) == int32(TK_RETURNING) { + (*TTrigger)(unsafe.Pointer(pTrig)).Ftable = (*TTable)(unsafe.Pointer(pTab)).FzName + (*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + (*TTrigger)(unsafe.Pointer(pTrig)).FpNext = pList + pList = pTrig + } + } + p = (*THashElem)(unsafe.Pointer(p)).Fnext + } + return pList +} + +// C documentation +// +// /* +// ** Add an OP_Function or OP_PureFunc opcode. +// ** +// ** The eCallCtx argument is information (typically taken from Expr.op2) +// ** that describes the calling context of the function. 0 means a general +// ** function call. NC_IsCheck means called by a check constraint, +// ** NC_IdxExpr means called as part of an index expression. NC_PartIdx +// ** means in the WHERE clause of a partial index. NC_GenCol means called +// ** while computing a generated column value. 0 is the usual case. +// */ +func _sqlite3VdbeAddFunctionCall(tls *libc.TLS, pParse uintptr, p1 int32, p2 int32, p3 int32, nArg int32, pFunc uintptr, eCallCtx int32) (r int32) { + var addr, v1 int32 + var pCtx, v uintptr + _, _, _, _ = addr, pCtx, v, v1 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pCtx = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(uint64(libc.UintptrFromInt32(0)+48)+libc.Uint64FromInt32(nArg)*libc.Uint64FromInt64(8))) + if pCtx == uintptr(0) { + _freeEphemeralFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pFunc) + return 0 + } + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut = uintptr(0) + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpFunc = pFunc + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe = uintptr(0) + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = 0 + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).Fargc = libc.Uint16FromInt32(nArg) + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FiOp = _sqlite3VdbeCurrentAddr(tls, v) + if eCallCtx != 0 { + v1 = int32(OP_PureFunc) + } else { + v1 = int32(OP_Function) + } + addr = _sqlite3VdbeAddOp4(tls, v, v1, p1, p2, p3, pCtx, -int32(16)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(eCallCtx&int32(NC_SelfRef))) + _sqlite3MayAbort(tls, pParse) + return addr +} + +func _sqlite3VdbeAddOp3(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32) (r int32) { + var i int32 + var pOp uintptr + _, _ = i, pOp + i = (*TVdbe)(unsafe.Pointer(p)).FnOp + if (*TVdbe)(unsafe.Pointer(p)).FnOpAlloc <= i { + return _growOp3(tls, p, op, p1, p2, p3) + } + (*TVdbe)(unsafe.Pointer(p)).FnOp = (*TVdbe)(unsafe.Pointer(p)).FnOp + 1 + pOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i)*24 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode = libc.Uint8FromInt32(op) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp5 = uint16(0) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = p1 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 = p2 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 = p3 + *(*uintptr)(unsafe.Pointer(pOp + 16)) = uintptr(0) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = P4_NOTUSED + /* Replicate this logic in sqlite3VdbeAddOp4Int() + ** vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ + /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ** Replicate in sqlite3VdbeAddOp4Int() */ + return i +} + +func _sqlite3VdbeAddOp4Int(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, p4 int32) (r int32) { + var i int32 + var pOp uintptr + _, _ = i, pOp + i = (*TVdbe)(unsafe.Pointer(p)).FnOp + if (*TVdbe)(unsafe.Pointer(p)).FnOpAlloc <= i { + return _addOp4IntSlow(tls, p, op, p1, p2, p3, p4) + } + (*TVdbe)(unsafe.Pointer(p)).FnOp = (*TVdbe)(unsafe.Pointer(p)).FnOp + 1 + pOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i)*24 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode = libc.Uint8FromInt32(op) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp5 = uint16(0) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = p1 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 = p2 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 = p3 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4.Fi = p4 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(3)) + /* Replicate this logic in sqlite3VdbeAddOp3() + ** vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ + /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ** Replicate in sqlite3VdbeAddOp3() */ + return i +} + +// C documentation +// +// /* +// ** Add a whole list of operations to the operation stack. Return a +// ** pointer to the first operation inserted. +// ** +// ** Non-zero P2 arguments to jump instructions are automatically adjusted +// ** so that the jump target is relative to the first operation inserted. +// */ +func _sqlite3VdbeAddOpList(tls *libc.TLS, p uintptr, nOp int32, aOp uintptr, iLineno int32) (r uintptr) { + var i int32 + var pFirst, pOut, v1 uintptr + _, _, _, _ = i, pFirst, pOut, v1 + if (*TVdbe)(unsafe.Pointer(p)).FnOp+nOp > (*TVdbe)(unsafe.Pointer(p)).FnOpAlloc && _growOpArray(tls, p, nOp) != 0 { + return uintptr(0) + } + v1 = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr((*TVdbe)(unsafe.Pointer(p)).FnOp)*24 + pOut = v1 + pFirst = v1 + i = 0 + for { + if !(i < nOp) { + break + } + (*TVdbeOp)(unsafe.Pointer(pOut)).Fopcode = (*TVdbeOpList)(unsafe.Pointer(aOp)).Fopcode + (*TVdbeOp)(unsafe.Pointer(pOut)).Fp1 = int32((*TVdbeOpList)(unsafe.Pointer(aOp)).Fp1) + (*TVdbeOp)(unsafe.Pointer(pOut)).Fp2 = int32((*TVdbeOpList)(unsafe.Pointer(aOp)).Fp2) + if libc.Int32FromUint8(_sqlite3OpcodeProperty[(*TVdbeOpList)(unsafe.Pointer(aOp)).Fopcode])&int32(OPFLG_JUMP) != 0 && int32((*TVdbeOpList)(unsafe.Pointer(aOp)).Fp2) > 0 { + **(**int32)(__ccgo_up(pOut + 8)) += (*TVdbe)(unsafe.Pointer(p)).FnOp + } + (*TVdbeOp)(unsafe.Pointer(pOut)).Fp3 = int32((*TVdbeOpList)(unsafe.Pointer(aOp)).Fp3) + (*TVdbeOp)(unsafe.Pointer(pOut)).Fp4type = P4_NOTUSED + *(*uintptr)(unsafe.Pointer(pOut + 16)) = uintptr(0) + (*TVdbeOp)(unsafe.Pointer(pOut)).Fp5 = uint16(0) + _ = iLineno + goto _2 + _2: + ; + i = i + 1 + aOp += 4 + pOut += 24 + } + **(**int32)(__ccgo_up(p + 144)) += nOp + return pFirst +} + +// C documentation +// +// /* +// ** Allocate sufficient space for an UnpackedRecord structure large enough +// ** to hold a decoded index record for pKeyInfo. +// ** +// ** The space is allocated using sqlite3DbMallocRaw(). If an OOM error +// ** occurs, NULL is returned. +// */ +func _sqlite3VdbeAllocUnpackedRecord(tls *libc.TLS, pKeyInfo uintptr) (r uintptr) { + var nByte Tu64 + var p uintptr + _, _ = nByte, p /* Number of bytes required for *p */ + nByte = uint64(libc.Uint64FromInt64(40) + uint64(56)*libc.Uint64FromInt32(libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField)+libc.Int32FromInt32(1))) + p = _sqlite3DbMallocRaw(tls, (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb, nByte) + if !(p != 0) { + return uintptr(0) + } + (*TUnpackedRecord)(unsafe.Pointer(p)).FaMem = p + uintptr(libc.Uint64FromInt64(40)) + (*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo = pKeyInfo + (*TUnpackedRecord)(unsafe.Pointer(p)).FnField = libc.Uint16FromInt32(libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField) + int32(1)) + return p +} + +// C documentation +// +// /* +// ** If parameter iOp is less than zero, then invoke the destructor for +// ** all auxiliary data pointers currently cached by the VM passed as +// ** the first argument. +// ** +// ** Or, if iOp is greater than or equal to zero, then the destructor is +// ** only invoked for those auxiliary data pointers created by the user +// ** function invoked by the OP_Function opcode at instruction iOp of +// ** VM pVdbe, and only then if: +// ** +// ** * the associated function parameter is the 32nd or later (counting +// ** from left to right), or +// ** +// ** * the corresponding bit in argument mask is clear (where the first +// ** function parameter corresponds to bit 0 etc.). +// */ +func _sqlite3VdbeDeleteAuxData(tls *libc.TLS, db uintptr, pp uintptr, iOp int32, mask int32) { + var pAux uintptr + _ = pAux + for **(**uintptr)(__ccgo_up(pp)) != 0 { + pAux = **(**uintptr)(__ccgo_up(pp)) + if iOp < 0 || (*TAuxData)(unsafe.Pointer(pAux)).FiAuxOp == iOp && (*TAuxData)(unsafe.Pointer(pAux)).FiAuxArg >= 0 && ((*TAuxData)(unsafe.Pointer(pAux)).FiAuxArg > int32(31) || !(libc.Uint32FromInt32(mask)&(libc.Uint32FromInt32(1)<<(*TAuxData)(unsafe.Pointer(pAux)).FiAuxArg) != 0)) { + if (*TAuxData)(unsafe.Pointer(pAux)).FxDeleteAux != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TAuxData)(unsafe.Pointer(pAux)).FxDeleteAux})))(tls, (*TAuxData)(unsafe.Pointer(pAux)).FpAux) + } + **(**uintptr)(__ccgo_up(pp)) = (*TAuxData)(unsafe.Pointer(pAux)).FpNextAux + _sqlite3DbFree(tls, db, pAux) + } else { + pp = pAux + 24 + } + } +} + +// C documentation +// +// /* +// ** If the last opcode is "op" and it is not a jump destination, +// ** then remove it. Return true if and only if an opcode was removed. +// */ +func _sqlite3VdbeDeletePriorOpcode(tls *libc.TLS, p uintptr, op Tu8) (r int32) { + if (*TVdbe)(unsafe.Pointer(p)).FnOp > 0 && libc.Int32FromUint8((**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr((*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1))*24))).Fopcode) == libc.Int32FromUint8(op) { + return _sqlite3VdbeChangeToNoop(tls, p, (*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1)) + } else { + return 0 + } + return r +} + +// C documentation +// +// /* +// ** Return a pointer to an sqlite3VdbeRecordCompare() compatible function +// ** suitable for comparing serialized records to the unpacked record passed +// ** as the only argument. +// */ +func _sqlite3VdbeFindCompare(tls *libc.TLS, p uintptr) (r TRecordCompare) { + var flags int32 + _ = flags + /* varintRecordCompareInt() and varintRecordCompareString() both assume + ** that the size-of-header varint that occurs at the start of each record + ** fits in a single byte (i.e. is 127 or less). varintRecordCompareInt() + ** also assumes that it is safe to overread a buffer by at least the + ** maximum possible legal header size plus 8 bytes. Because there is + ** guaranteed to be at least 74 (but not 136) bytes of padding following each + ** buffer passed to varintRecordCompareInt() this makes it convenient to + ** limit the size of the header to 64 bytes in cases where the first field + ** is an integer. + ** + ** The easiest way to enforce this limit is to consider only records with + ** 13 fields or less. If the first field is an integer, the maximum legal + ** header size is (12*5 + 1 + 1) bytes. */ + if libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FnAllField) <= int32(13) { + flags = libc.Int32FromUint16((**(**TMem)(__ccgo_up((*TUnpackedRecord)(unsafe.Pointer(p)).FaMem))).Fflags) + if **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags)) != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags)))&int32(KEYINFO_ORDER_BIGNULL) != 0 { + return __ccgo_fp(_sqlite3VdbeRecordCompare) + } + (*TUnpackedRecord)(unsafe.Pointer(p)).Fr1 = int8(1) + (*TUnpackedRecord)(unsafe.Pointer(p)).Fr2 = int8(-int32(1)) + } else { + (*TUnpackedRecord)(unsafe.Pointer(p)).Fr1 = int8(-int32(1)) + (*TUnpackedRecord)(unsafe.Pointer(p)).Fr2 = int8(1) + } + if flags&int32(MEM_Int) != 0 { + *(*Ti64)(unsafe.Pointer(p + 16)) = *(*Ti64)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FaMem)) + return __ccgo_fp(_vdbeRecordCompareInt) + } + if flags&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Null)|libc.Int32FromInt32(MEM_Blob)) == 0 && *(*uintptr)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + 32)) == uintptr(0) { + *(*uintptr)(unsafe.Pointer(p + 16)) = (**(**TMem)(__ccgo_up((*TUnpackedRecord)(unsafe.Pointer(p)).FaMem))).Fz + (*TUnpackedRecord)(unsafe.Pointer(p)).Fn = (**(**TMem)(__ccgo_up((*TUnpackedRecord)(unsafe.Pointer(p)).FaMem))).Fn + return __ccgo_fp(_vdbeRecordCompareString) + } + } + return __ccgo_fp(_sqlite3VdbeRecordCompare) +} + +// C documentation +// +// /* +// ** This is called when the record in (*p) should be found in the index +// ** opened by cursor pCur, but was not. This may happen as part of a DELETE +// ** operation or an integrity check. +// ** +// ** One reason that an exact match was not found may be the EIIB bug - that +// ** a text-to-float conversion may have caused a real value in record (*p) +// ** to be slightly different from its counterpart on disk. This function +// ** attempts to find the right index record. If it does find the right +// ** record, it leaves *pCur pointing to it and sets (*pRes) to 0 before +// ** returning. Otherwise, (*pRes) is set to non-zero and an SQLite error +// ** code returned. +// ** +// ** The algorithm used to find the correct record is: +// ** +// ** * Scan up to BTREE_FDK_RANGE entries either side of the current entry. +// ** If parameter bIntegrity is false, then all fields that are indexed +// ** expressions or virtual table columns are omitted from the comparison. +// ** If bIntegrity is true, then small differences in real values in +// ** such fields are overlooked, but they are not omitted from the comparison +// ** altogether. +// ** +// ** * If the above fails to find an entry and bIntegrity is false, search +// ** the entire index. +// */ +func _sqlite3VdbeFindIndexKey(tls *libc.TLS, pCur uintptr, pIdx uintptr, p uintptr, pRes uintptr, bIntegrity int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iCol, ii, nStep, rc, v2 int32 + var mask TBitmask + var _ /* res at bp+0 */ int32 + _, _, _, _, _, _ = iCol, ii, mask, nStep, rc, v2 + nStep = 0 + **(**int32)(__ccgo_up(bp)) = int32(1) + rc = SQLITE_OK + ii = 0 + /* Calculate a mask based on the first 64 columns of the index. The mask + ** bit is set if the corresponding index field is either an expression + ** or a virtual column of the table. */ + mask = uint64(0) + ii = 0 + for { + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v2 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } else { + v2 = libc.Int32FromUint64(libc.Uint64FromInt64(8) * libc.Uint64FromInt32(8)) + } + if !(ii < v2) { + break + } + iCol = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2))) + if iCol == -int32(2) || iCol >= 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(iCol)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + mask = mask | libc.Uint64FromInt32(1)<=0), or the entire index if (nStep<0). */ + for _sqlite3BtreeCursorIsValidNN(tls, pCur) != 0 { + ii = 0 + for { + if !(rc == SQLITE_OK && (ii < nStep || nStep < 0)) { + break + } + rc = _vdbeIsMatchingIndexKey(tls, pCur, bIntegrity, mask, p, bp) + if **(**int32)(__ccgo_up(bp)) == 0 || rc != SQLITE_OK { + break + } + rc = _sqlite3BtreeNext(tls, pCur, 0) + goto _4 + _4: + ; + ii = ii + 1 + } + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + if nStep < 0 || rc != SQLITE_OK || **(**int32)(__ccgo_up(bp)) == 0 || bIntegrity != 0 { + break + } + /* The first, non-exhaustive, search failed to find an entry with + ** matching PK fields. So restart for an exhaustive search of the + ** entire index. */ + nStep = -int32(1) + rc = _sqlite3BtreeFirst(tls, pCur, bp) + } + } + **(**int32)(__ccgo_up(pRes)) = **(**int32)(__ccgo_up(bp)) + return rc +} + +// C documentation +// +// /* +// ** Delete a VdbeFrame object and its contents. VdbeFrame objects are +// ** allocated by the OP_Program opcode in sqlite3VdbeExec(). +// */ +func _sqlite3VdbeFrameDelete(tls *libc.TLS, p uintptr) { + var aMem, apCsr uintptr + var i int32 + _, _, _ = aMem, apCsr, i + aMem = p + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + apCsr = aMem + uintptr((*TVdbeFrame)(unsafe.Pointer(p)).FnChildMem)*56 + i = 0 + for { + if !(i < (*TVdbeFrame)(unsafe.Pointer(p)).FnChildCsr) { + break + } + if **(**uintptr)(__ccgo_up(apCsr + uintptr(i)*8)) != 0 { + _sqlite3VdbeFreeCursorNN(tls, (*TVdbeFrame)(unsafe.Pointer(p)).Fv, **(**uintptr)(__ccgo_up(apCsr + uintptr(i)*8))) + } + goto _1 + _1: + ; + i = i + 1 + } + _releaseMemArray(tls, aMem, (*TVdbeFrame)(unsafe.Pointer(p)).FnChildMem) + _sqlite3VdbeDeleteAuxData(tls, (*TVdbe)(unsafe.Pointer((*TVdbeFrame)(unsafe.Pointer(p)).Fv)).Fdb, p+64, -int32(1), 0) + _sqlite3DbFree(tls, (*TVdbe)(unsafe.Pointer((*TVdbeFrame)(unsafe.Pointer(p)).Fv)).Fdb, p) +} + +func _sqlite3VdbeFreeCursorNN(tls *libc.TLS, p uintptr, pCx uintptr) { + var pModule, pVCur uintptr + _, _ = pModule, pVCur + if int32(TBool(*(*uint8)(unsafe.Pointer(pCx + 8))&0x10>>4)) != 0 { + _freeCursorWithCache(tls, p, pCx) + return + } + switch libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pCx)).FeCurType) { + case int32(CURTYPE_SORTER): + _sqlite3VdbeSorterClose(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, pCx) + case CURTYPE_BTREE: + _sqlite3BtreeCloseCursor(tls, *(*uintptr)(unsafe.Pointer(pCx + 48))) + case int32(CURTYPE_VTAB): + pVCur = *(*uintptr)(unsafe.Pointer(pCx + 48)) + pModule = (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVCur)).FpVtab)).FpModule + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVCur)).FpVtab)).FnRef = (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(pVCur)).FpVtab)).FnRef - 1 + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule)).FxClose})))(tls, pVCur) + break + } +} + +// C documentation +// +// /* +// ** Return a pointer to an sqlite3_value structure containing the value bound +// ** parameter iVar of VM v. Except, if the value is an SQL NULL, return +// ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_* +// ** constants) to the value before returning it. +// ** +// ** The returned value must be freed by the caller using sqlite3ValueFree(). +// */ +func _sqlite3VdbeGetBoundValue(tls *libc.TLS, v uintptr, iVar int32, aff Tu8) (r uintptr) { + var pMem, pRet uintptr + _, _ = pMem, pRet + if v != 0 { + pMem = (*TVdbe)(unsafe.Pointer(v)).FaVar + uintptr(iVar-int32(1))*56 + if 0 == libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Null) { + pRet = _sqlite3ValueNew(tls, (*TVdbe)(unsafe.Pointer(v)).Fdb) + if pRet != 0 { + _sqlite3VdbeMemCopy(tls, pRet, pMem) + _sqlite3ValueApplyAffinity(tls, pRet, aff, uint8(SQLITE_UTF8)) + } + return pRet + } + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** This routine is called the when a VDBE tries to halt. If the VDBE +// ** has made changes and is in autocommit mode, then commit those +// ** changes. If a rollback is needed, then do the rollback. +// ** +// ** This routine is the only way to move the sqlite3eOpenState of a VM from +// ** SQLITE_STATE_RUN to SQLITE_STATE_HALT. It is harmless to +// ** call this on a VM that is in the SQLITE_STATE_HALT state. +// ** +// ** Return an error code. If the commit could not complete because of +// ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it +// ** means the close did not happen and needs to be repeated. +// */ +func _sqlite3VdbeHalt(tls *libc.TLS, p uintptr) (r int32) { + var db uintptr + var eStatementOp, isSpecialError, mrc, rc, v1 int32 + _, _, _, _, _, _ = db, eStatementOp, isSpecialError, mrc, rc, v1 /* Used to store transient return codes */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + /* This function contains the logic that determines if a statement or + ** transaction will be committed or rolled back as a result of the + ** execution of this virtual machine. + ** + ** If any of the following errors occur: + ** + ** SQLITE_NOMEM + ** SQLITE_IOERR + ** SQLITE_FULL + ** SQLITE_INTERRUPT + ** + ** Then the internal cache might have been left in an inconsistent + ** state. We need to rollback the statement transaction, if there is + ** one, or the complete transaction if there is no statement transaction. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } + _closeAllCursors(tls, p) + /* No commit or rollback needed if the program never started or if the + ** SQL statement does not read or write a database file. */ + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x80>>7)) != 0 { /* Primary error code from p->rc */ + eStatementOp = 0 /* Set to true if a 'special' error */ + /* Lock all btrees used by the statement */ + _sqlite3VdbeEnter(tls, p) + /* Check for one of the special errors */ + if (*TVdbe)(unsafe.Pointer(p)).Frc != 0 { + mrc = (*TVdbe)(unsafe.Pointer(p)).Frc & int32(0xff) + isSpecialError = libc.BoolInt32(mrc == int32(SQLITE_NOMEM) || mrc == int32(SQLITE_IOERR) || mrc == int32(SQLITE_INTERRUPT) || mrc == int32(SQLITE_FULL)) + } else { + v1 = libc.Int32FromInt32(0) + isSpecialError = v1 + mrc = v1 + } + if isSpecialError != 0 { + /* If the query was read-only and the error code is SQLITE_INTERRUPT, + ** no rollback is necessary. Otherwise, at least a savepoint + ** transaction must be rolled back to restore the database to a + ** consistent state. + ** + ** Even if the statement is read-only, it is important to perform + ** a statement or transaction rollback operation. If the error + ** occurred while writing to the journal, sub-journal or database + ** file as part of an effort to free up cache space (see function + ** pagerStress() in pager.c), the rollback is required to restore + ** the pager to a consistent state. + */ + if !(int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x40>>6)) != 0) || mrc != int32(SQLITE_INTERRUPT) { + if (mrc == int32(SQLITE_NOMEM) || mrc == int32(SQLITE_FULL)) && int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x20>>5)) != 0 { + eStatementOp = int32(SAVEPOINT_ROLLBACK) + } else { + /* We are forced to roll back the active transaction. Before doing + ** so, abort any other statements this handle currently has active. + */ + _sqlite3RollbackAll(tls, db, libc.Int32FromInt32(SQLITE_ABORT)|libc.Int32FromInt32(2)< 0 && (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans == uintptr(0)) && (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite == libc.BoolInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x40>>6)) == 0) { + if (*TVdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK || libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FerrorAction) == int32(OE_Fail) && !(isSpecialError != 0) { + rc = _sqlite3VdbeCheckFkDeferred(tls, p) + if rc != SQLITE_OK { + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x40>>6)) != 0 { + _sqlite3VdbeLeave(tls, p) + return int32(SQLITE_ERROR) + } + rc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(3)<>6)) != 0 { + _sqlite3VdbeLeave(tls, p) + return int32(SQLITE_BUSY) + } else { + if rc != SQLITE_OK { + _sqlite3SystemError(tls, db, rc) + (*TVdbe)(unsafe.Pointer(p)).Frc = rc + _sqlite3RollbackAll(tls, db, SQLITE_OK) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = 0 + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_DeferFKs) + _sqlite3CommitInternalChanges(tls, db) + } + } + } else { + if (*TVdbe)(unsafe.Pointer(p)).Frc == int32(SQLITE_SCHEMA) && (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive > int32(1) { + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + } else { + _sqlite3RollbackAll(tls, db, SQLITE_OK) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + } + } + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement = 0 + } else { + if eStatementOp == 0 { + if (*TVdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK || libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FerrorAction) == int32(OE_Fail) { + eStatementOp = int32(SAVEPOINT_RELEASE) + } else { + if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FerrorAction) == int32(OE_Abort) { + eStatementOp = int32(SAVEPOINT_ROLLBACK) + } else { + _sqlite3RollbackAll(tls, db, libc.Int32FromInt32(SQLITE_ABORT)|libc.Int32FromInt32(2)<>4)) != 0 { + if eStatementOp != int32(SAVEPOINT_ROLLBACK) { + _sqlite3VdbeSetChanges(tls, db, (*TVdbe)(unsafe.Pointer(p)).FnChange) + } else { + _sqlite3VdbeSetChanges(tls, db, 0) + } + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + } + /* Release the locks */ + _sqlite3VdbeLeave(tls, p) + } + /* We have successfully halted and closed the VM. Record this fact. */ + (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive = (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive - 1 + if !(int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x40>>6)) != 0) { + (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite = (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite - 1 + } + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x80>>7)) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead = (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead - 1 + } + (*TVdbe)(unsafe.Pointer(p)).FeVdbeState = uint8(VDBE_HALT_STATE) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } + /* If the auto-commit flag is set to true, then any locks that were held + ** by connection db have now been released. Call sqlite3ConnectionUnlocked() + ** to invoke any required unlock-notify callbacks. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0 { + _sqlite3ConnectionUnlocked(tls, db) + } + if (*TVdbe)(unsafe.Pointer(p)).Frc == int32(SQLITE_BUSY) { + v1 = int32(SQLITE_BUSY) + } else { + v1 = SQLITE_OK + } + return v1 +} + +// C documentation +// +// /* +// ** Compare the key of the index entry that cursor pC is pointing to against +// ** the key string in pUnpacked. Write into *pRes a number +// ** that is negative, zero, or positive if pC is less than, equal to, +// ** or greater than pUnpacked. Return SQLITE_OK on success. +// ** +// ** pUnpacked is either created without a rowid or is truncated so that it +// ** omits the rowid at the end. The rowid at the end of the index entry +// ** is ignored as well. Hence, this routine only compares the prefixes +// ** of the keys prior to the final rowid, not the entire key. +// */ +func _sqlite3VdbeIdxKeyCompare(tls *libc.TLS, db uintptr, pC uintptr, pUnpacked uintptr, res uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var nCellKey Ti64 + var pCur uintptr + var rc int32 + var _ /* m at bp+0 */ TMem + _, _, _ = nCellKey, pCur, rc + nCellKey = 0 + pCur = *(*uintptr)(unsafe.Pointer(pC + 48)) + nCellKey = libc.Int64FromUint32(_sqlite3BtreePayloadSize(tls, pCur)) + /* nCellKey will always be between 0 and 0xffffffff because of the way + ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ + if nCellKey <= 0 || nCellKey > int64(0x7fffffff) { + **(**int32)(__ccgo_up(res)) = 0 + return _sqlite3CorruptError(tls, int32(93039)) + } + _sqlite3VdbeMemInit(tls, bp, db, uint16(0)) + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCur, libc.Uint32FromInt64(nCellKey), bp) + if rc != 0 { + return rc + } + **(**int32)(__ccgo_up(res)) = _sqlite3VdbeRecordCompareWithSkip(tls, (**(**TMem)(__ccgo_up(bp))).Fn, (**(**TMem)(__ccgo_up(bp))).Fz, pUnpacked, 0) + _sqlite3VdbeMemReleaseMalloc(tls, bp) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** pCur points at an index entry created using the OP_MakeRecord opcode. +// ** Read the rowid (the last field in the record) and store it in *rowid. +// ** Return SQLITE_OK if everything works, or an error code otherwise. +// ** +// ** pCur might be pointing to text obtained from a corrupt database file. +// ** So the content cannot be trusted. Do appropriate checks on the content. +// */ +func _sqlite3VdbeIdxRowid(tls *libc.TLS, db uintptr, pCur uintptr, rowid uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var lenRowid Tu32 + var nCellKey Ti64 + var rc int32 + var _ /* m at bp+8 */ TMem + var _ /* szHdr at bp+0 */ Tu32 + var _ /* typeRowid at bp+4 */ Tu32 + var _ /* v at bp+64 */ TMem + _, _, _ = lenRowid, nCellKey, rc + nCellKey = 0 + /* Get the size of the index entry. Only indices entries of less + ** than 2GiB are support - anything large must be database corruption. + ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so + ** this code can safely assume that nCellKey is 32-bits + */ + nCellKey = libc.Int64FromUint32(_sqlite3BtreePayloadSize(tls, pCur)) + /* Read in the complete content of the index entry */ + _sqlite3VdbeMemInit(tls, bp+8, db, uint16(0)) + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCur, libc.Uint32FromInt64(nCellKey), bp+8) + if rc != 0 { + return rc + } + /* The index entry must begin with a header size */ + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**Tu8)(__ccgo_up((**(**TMem)(__ccgo_up(bp + 8))).Fz))) + if **(**Tu32)(__ccgo_up(bp)) >= uint32(0x80) { + _sqlite3GetVarint32(tls, (**(**TMem)(__ccgo_up(bp + 8))).Fz, bp) + } + if **(**Tu32)(__ccgo_up(bp)) < uint32(3) || **(**Tu32)(__ccgo_up(bp)) > libc.Uint32FromInt32((**(**TMem)(__ccgo_up(bp + 8))).Fn) { + goto idx_rowid_corruption + } + /* The last field of the index should be an integer - the ROWID. + ** Verify that the last entry really is an integer. */ + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(**(**Tu8)(__ccgo_up((**(**TMem)(__ccgo_up(bp + 8))).Fz + uintptr(**(**Tu32)(__ccgo_up(bp))-uint32(1))))) + if **(**Tu32)(__ccgo_up(bp + 4)) >= uint32(0x80) { + _sqlite3GetVarint32(tls, (**(**TMem)(__ccgo_up(bp + 8))).Fz+uintptr(**(**Tu32)(__ccgo_up(bp))-uint32(1)), bp+4) + } + if **(**Tu32)(__ccgo_up(bp + 4)) < uint32(1) || **(**Tu32)(__ccgo_up(bp + 4)) > uint32(9) || **(**Tu32)(__ccgo_up(bp + 4)) == uint32(7) { + goto idx_rowid_corruption + } + lenRowid = uint32(_sqlite3SmallTypeSizes[**(**Tu32)(__ccgo_up(bp + 4))]) + if libc.Uint32FromInt32((**(**TMem)(__ccgo_up(bp + 8))).Fn) < **(**Tu32)(__ccgo_up(bp))+lenRowid { + goto idx_rowid_corruption + } + /* Fetch the integer off the end of the index record */ + _sqlite3VdbeSerialGet(tls, (**(**TMem)(__ccgo_up(bp + 8))).Fz+uintptr(libc.Uint32FromInt32((**(**TMem)(__ccgo_up(bp + 8))).Fn)-lenRowid), **(**Tu32)(__ccgo_up(bp + 4)), bp+64) + **(**Ti64)(__ccgo_up(rowid)) = *(*Ti64)(unsafe.Pointer(bp + 64)) + _sqlite3VdbeMemReleaseMalloc(tls, bp+8) + return SQLITE_OK + /* Jump here if database corruption is detected after m has been + ** allocated. Free the m object and return SQLITE_CORRUPT. */ + goto idx_rowid_corruption +idx_rowid_corruption: + ; + _sqlite3VdbeMemReleaseMalloc(tls, bp+8) + return _sqlite3CorruptError(tls, int32(93006)) +} + +// C documentation +// +// /* +// ** Give a listing of the program in the virtual machine. +// ** +// ** The interface is the same as sqlite3VdbeExec(). But instead of +// ** running the code, it invokes the callback once for each instruction. +// ** This feature is used to implement "EXPLAIN". +// ** +// ** When p->explain==1, each instruction is listed. When +// ** p->explain==2, only OP_Explain instructions are listed and these +// ** are shown in a different format. p->explain==2 is used to implement +// ** EXPLAIN QUERY PLAN. +// ** 2018-04-24: In p->explain==2 mode, the OP_Init opcodes of triggers +// ** are also shown, so that the boundaries between the main program and +// ** each trigger are clear. +// ** +// ** When p->explain==1, first the main program is listed, then each of +// ** the trigger subprograms are listed one by one. +// */ +func _sqlite3VdbeList(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bListSubprogs, rc int32 + var db, pMem, pOp, pSub, zP4 uintptr + var _ /* aOp at bp+8 */ uintptr + var _ /* i at bp+0 */ int32 + _, _, _, _, _, _, _ = bListSubprogs, db, pMem, pOp, pSub, rc, zP4 + pSub = uintptr(0) /* Memory cell hold array of subprogs */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb /* Loop counter */ + rc = SQLITE_OK /* Return code */ + pMem = (*TVdbe)(unsafe.Pointer(p)).FaMem + 1*56 /* First Mem of result set */ + bListSubprogs = libc.BoolInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2)) == int32(1) || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_TriggerEQP) != uint64(0)) /* Current opcode */ + /* Even though this opcode does not use dynamic strings for + ** the result, result columns may become dynamic if the user calls + ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. + */ + _releaseMemArray(tls, pMem, int32(8)) + if (*TVdbe)(unsafe.Pointer(p)).Frc == int32(SQLITE_NOMEM) { + /* This happens if a malloc() inside a call to sqlite3_column_text() or + ** sqlite3_column_text16() failed. */ + _sqlite3OomFault(tls, db) + return int32(SQLITE_ERROR) + } + if bListSubprogs != 0 { + /* The first 8 memory cells are used for the result set. So we will + ** commandeer the 9th cell to use as storage for an array of pointers + ** to trigger subprograms. The VDBE is guaranteed to have at least 9 + ** cells. */ + pSub = (*TVdbe)(unsafe.Pointer(p)).FaMem + 9*56 + } else { + pSub = uintptr(0) + } + /* Figure out which opcode is next to display */ + rc = _sqlite3VdbeNextOpcode(tls, p, pSub, libc.BoolInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2)) == int32(2)), p+48, bp, bp+8) + if rc == SQLITE_OK { + pOp = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(**(**int32)(__ccgo_up(bp)))*24 + if libc.AtomicLoadNInt32(db+432, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0 { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_INTERRUPT) + rc = int32(SQLITE_ERROR) + _sqlite3VdbeError(tls, p, _sqlite3ErrStr(tls, (*TVdbe)(unsafe.Pointer(p)).Frc), 0) + } else { + zP4 = _sqlite3VdbeDisplayP4(tls, db, pOp) + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0xc>>2)) == int32(2) { + _sqlite3VdbeMemSetInt64(tls, pMem, int64((*TOp)(unsafe.Pointer(pOp)).Fp1)) + _sqlite3VdbeMemSetInt64(tls, pMem+uintptr(1)*56, int64((*TOp)(unsafe.Pointer(pOp)).Fp2)) + _sqlite3VdbeMemSetInt64(tls, pMem+uintptr(2)*56, int64((*TOp)(unsafe.Pointer(pOp)).Fp3)) + _sqlite3VdbeMemSetStr(tls, pMem+uintptr(3)*56, zP4, int64(-int32(1)), uint8(SQLITE_UTF8), __ccgo_fp(Xsqlite3_free)) + } else { + _sqlite3VdbeMemSetInt64(tls, pMem+uintptr(0)*56, int64(**(**int32)(__ccgo_up(bp)))) + _sqlite3VdbeMemSetStr(tls, pMem+uintptr(1)*56, _sqlite3OpcodeName(tls, libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode)), int64(-int32(1)), uint8(SQLITE_UTF8), libc.UintptrFromInt32(0)) + _sqlite3VdbeMemSetInt64(tls, pMem+uintptr(2)*56, int64((*TOp)(unsafe.Pointer(pOp)).Fp1)) + _sqlite3VdbeMemSetInt64(tls, pMem+uintptr(3)*56, int64((*TOp)(unsafe.Pointer(pOp)).Fp2)) + _sqlite3VdbeMemSetInt64(tls, pMem+uintptr(4)*56, int64((*TOp)(unsafe.Pointer(pOp)).Fp3)) + /* pMem+5 for p4 is done last */ + _sqlite3VdbeMemSetInt64(tls, pMem+uintptr(6)*56, libc.Int64FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)) + _sqlite3VdbeMemSetNull(tls, pMem+uintptr(7)*56) + _sqlite3VdbeMemSetStr(tls, pMem+uintptr(5)*56, zP4, int64(-int32(1)), uint8(SQLITE_UTF8), __ccgo_fp(Xsqlite3_free)) + } + (*TVdbe)(unsafe.Pointer(p)).FpResultRow = pMem + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + rc = int32(SQLITE_ERROR) + } else { + (*TVdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + rc = int32(SQLITE_ROW) + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Cast the datatype of the value in pMem according to the affinity +// ** "aff". Casting is different from applying affinity in that a cast +// ** is forced. In other words, the value is converted into the desired +// ** affinity even if that results in loss of data. This routine is +// ** used (for example) to implement the SQL "cast()" operator. +// */ +func _sqlite3VdbeMemCast(tls *libc.TLS, pMem uintptr, aff Tu8, encoding Tu8) (r int32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Null) != 0 { + return SQLITE_OK + } + switch libc.Int32FromUint8(aff) { + case int32(SQLITE_AFF_BLOB): /* Really a cast to BLOB */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Blob) == 0 { + _sqlite3ValueApplyAffinity(tls, pMem, uint8(SQLITE_AFF_TEXT), encoding) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Str) != 0 { + (*TMem)(unsafe.Pointer(pMem)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Blob)) + } + } else { + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_TypeMask) & ^libc.Int32FromInt32(MEM_Blob))) + } + case int32(SQLITE_AFF_NUMERIC): + _sqlite3VdbeMemNumerify(tls, pMem) + case int32(SQLITE_AFF_INTEGER): + _sqlite3VdbeMemIntegerify(tls, pMem) + case int32(SQLITE_AFF_REAL): + _sqlite3VdbeMemRealify(tls, pMem) + default: + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&libc.Int32FromInt32(MEM_Blob)>>libc.Int32FromInt32(3)) + _sqlite3ValueApplyAffinity(tls, pMem, uint8(SQLITE_AFF_TEXT), encoding) + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal) | libc.Int32FromInt32(MEM_Blob) | libc.Int32FromInt32(MEM_Zero))) + if libc.Int32FromUint8(encoding) != int32(SQLITE_UTF8) { + **(**int32)(__ccgo_up(pMem + 16)) &= ^libc.Int32FromInt32(1) + } + rc = _sqlite3VdbeChangeEncoding(tls, pMem, libc.Int32FromUint8(encoding)) + if rc != 0 { + return rc + } + _sqlite3VdbeMemZeroTerminateIfAble(tls, pMem) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Change pMem so that its MEM_Str or MEM_Blob value is stored in +// ** MEM.zMalloc, where it can be safely written. +// ** +// ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. +// */ +func _sqlite3VdbeMemMakeWriteable(tls *libc.TLS, pMem uintptr) (r int32) { + var rc, v1 int32 + var v2 uintptr + _, _, _ = rc, v1, v2 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Zero) != 0 { + v1 = _sqlite3VdbeMemExpandBlob(tls, pMem) + } else { + v1 = 0 + } + if v1 != 0 { + return int32(SQLITE_NOMEM) + } + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc == 0 || (*TMem)(unsafe.Pointer(pMem)).Fz != (*TMem)(unsafe.Pointer(pMem)).FzMalloc { + rc = _vdbeMemAddTerminator(tls, pMem) + if rc != 0 { + return rc + } + } + } + v2 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) & ^libc.Int32FromInt32(MEM_Ephem)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Convert pMem so that it has type MEM_Real or MEM_Int. +// ** Invalidate any prior representations. +// ** +// ** Every effort is made to force the conversion, even if the input +// ** is a string that does not look completely like a number. Convert +// ** as much of the string as we can and ignore the rest. +// */ +func _sqlite3VdbeMemNumerify(tls *libc.TLS, pMem uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var v1 Tsqlite3_int64 + var v2 bool + var v3 uintptr + var _ /* ix at bp+0 */ Tsqlite3_int64 + _, _, _, _ = rc, v1, v2, v3 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Null)) == 0 { + rc = _sqlite3MemRealValueRC(tls, pMem, pMem) + if v2 = rc&int32(2) == 0 && _sqlite3Atoi64(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, bp, (*TMem)(unsafe.Pointer(pMem)).Fn, (*TMem)(unsafe.Pointer(pMem)).Fenc) < int32(2); !v2 { + v1 = _sqlite3RealToI64(tls, *(*float64)(unsafe.Pointer(pMem))) + **(**Tsqlite3_int64)(__ccgo_up(bp)) = v1 + } + if v2 || _sqlite3RealSameAsInt(tls, *(*float64)(unsafe.Pointer(pMem)), v1) != 0 { + *(*Ti64)(unsafe.Pointer(pMem)) = **(**Tsqlite3_int64)(__ccgo_up(bp)) + (*TMem)(unsafe.Pointer(pMem)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Int)) + } else { + (*TMem)(unsafe.Pointer(pMem)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Real)) + } + } + v3 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Blob) | libc.Int32FromInt32(MEM_Zero))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Add MEM_Str to the set of representations for the given Mem. This +// ** routine is only called if pMem is a number of some kind, not a NULL +// ** or a BLOB. +// ** +// ** Existing representations MEM_Int, MEM_Real, or MEM_IntReal are invalidated +// ** if bForce is true but are retained if bForce is false. +// ** +// ** A MEM_Null value will never be passed to this function. This function is +// ** used for converting values to text for returning to the user (i.e. via +// ** sqlite3_value_text()), or for ensuring that values to be used as btree +// ** keys are strings. In the former case a NULL pointer is returned the +// ** user and the latter is an internal programming error. +// */ +func _sqlite3VdbeMemStringify(tls *libc.TLS, pMem uintptr, enc Tu8, bForce Tu8) (r int32) { + var nByte int32 + var v1 uintptr + _, _ = nByte, v1 + nByte = int32(32) + if _sqlite3VdbeMemClearAndResize(tls, pMem, nByte) != 0 { + (*TMem)(unsafe.Pointer(pMem)).Fenc = uint8(0) + return int32(SQLITE_NOMEM) + } + _vdbeMemRenderNum(tls, nByte, (*TMem)(unsafe.Pointer(pMem)).Fz, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fenc = uint8(SQLITE_UTF8) + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | (libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term))) + if bForce != 0 { + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) + } + _sqlite3VdbeChangeEncoding(tls, pMem, libc.Int32FromUint8(enc)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return true if the Mem object contains a TEXT or BLOB that is +// ** too large - whose size exceeds SQLITE_MAX_LENGTH. +// */ +func _sqlite3VdbeMemTooBig(tls *libc.TLS, p uintptr) (r int32) { + var n int32 + _ = n + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) != 0 { + n = (*TMem)(unsafe.Pointer(p)).Fn + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&int32(MEM_Zero) != 0 { + n = n + *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(p)).Fu)) + } + return libc.BoolInt32(n > **(**int32)(__ccgo_up((*TMem)(unsafe.Pointer(p)).Fdb + 136))) + } + return 0 +} + +// C documentation +// +// /* +// ** This routine transforms the internal text encoding used by pMem to +// ** desiredEnc. It is an error if the string is already of the desired +// ** encoding, or if *pMem does not contain a string value. +// */ +func _sqlite3VdbeMemTranslate(tls *libc.TLS, pMem uintptr, desiredEnc Tu8) (r int32) { + var c uint32 + var c2, c21, rc int32 + var len1 Tsqlite3_int64 + var temp Tu8 + var z, zIn, zOut, zTerm, v1, v2 uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = c, c2, c21, len1, rc, temp, z, zIn, zOut, zTerm, v1, v2 + /* If the translation is between UTF-16 little and big endian, then + ** all that is required is to swap the byte order. This case is handled + ** differently from the others. + */ + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) != int32(SQLITE_UTF8) && libc.Int32FromUint8(desiredEnc) != int32(SQLITE_UTF8) { + rc = _sqlite3VdbeMemMakeWriteable(tls, pMem) + if rc != SQLITE_OK { + return int32(SQLITE_NOMEM) + } + zIn = (*TMem)(unsafe.Pointer(pMem)).Fz + zTerm = zIn + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn & ^libc.Int32FromInt32(1)) + for zIn < zTerm { + temp = **(**uint8)(__ccgo_up(zIn)) + **(**uint8)(__ccgo_up(zIn)) = **(**uint8)(__ccgo_up(zIn + libc.UintptrFromInt32(1))) + zIn = zIn + 1 + v1 = zIn + zIn = zIn + 1 + **(**uint8)(__ccgo_up(v1)) = temp + } + (*TMem)(unsafe.Pointer(pMem)).Fenc = desiredEnc + goto translate_out + } + /* Set len to the maximum number of bytes required in the output buffer. */ + if libc.Int32FromUint8(desiredEnc) == int32(SQLITE_UTF8) { + /* When converting from UTF-16, the maximum growth results from + ** translating a 2-byte character to a 4-byte UTF-8 character. + ** A single byte is required for the output string + ** nul-terminator. + */ + **(**int32)(__ccgo_up(pMem + 16)) &= ^libc.Int32FromInt32(1) + len1 = int64(2)*int64((*TMem)(unsafe.Pointer(pMem)).Fn) + int64(1) + } else { + /* When converting from UTF-8 to UTF-16 the maximum growth is caused + ** when a 1-byte UTF-8 character is translated into a 2-byte UTF-16 + ** character. Two bytes are required in the output buffer for the + ** nul-terminator. + */ + len1 = int64(2)*int64((*TMem)(unsafe.Pointer(pMem)).Fn) + int64(2) + } + /* Set zIn to point at the start of the input buffer and zTerm to point 1 + ** byte past the end. + ** + ** Variable zOut is set to point at the output buffer, space obtained + ** from sqlite3_malloc(). + */ + zIn = (*TMem)(unsafe.Pointer(pMem)).Fz + zTerm = zIn + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn) + zOut = _sqlite3DbMallocRaw(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, libc.Uint64FromInt64(len1)) + if !(zOut != 0) { + return int32(SQLITE_NOMEM) + } + z = zOut + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) == int32(SQLITE_UTF8) { + if libc.Int32FromUint8(desiredEnc) == int32(SQLITE_UTF16LE) { + /* UTF-8 -> UTF-16 Little-endian */ + for zIn < zTerm { + v1 = zIn + zIn = zIn + 1 + c = uint32(**(**uint8)(__ccgo_up(v1))) + if c >= uint32(0xc0) { + c = uint32(_sqlite3Utf8Trans1[c-uint32(0xc0)]) + for zIn < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn)))&int32(0xc0) == int32(0x80) { + v1 = zIn + zIn = zIn + 1 + c = c<> libc.Int32FromInt32(8) & libc.Uint32FromInt32(0x00FF)) + } else { + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c>>libc.Int32FromInt32(10)&libc.Uint32FromInt32(0x003F) + (c-libc.Uint32FromInt32(0x10000))>>libc.Int32FromInt32(10)&libc.Uint32FromInt32(0x00C0)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(libc.Uint32FromInt32(0x00D8) + (c-libc.Uint32FromInt32(0x10000))>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x03)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c & libc.Uint32FromInt32(0x00FF)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(libc.Uint32FromInt32(0x00DC) + c>>libc.Int32FromInt32(8)&libc.Uint32FromInt32(0x03)) + } + } + } else { + /* UTF-8 -> UTF-16 Big-endian */ + for zIn < zTerm { + v1 = zIn + zIn = zIn + 1 + c = uint32(**(**uint8)(__ccgo_up(v1))) + if c >= uint32(0xc0) { + c = uint32(_sqlite3Utf8Trans1[c-uint32(0xc0)]) + for zIn < zTerm && libc.Int32FromUint8(**(**uint8)(__ccgo_up(zIn)))&int32(0xc0) == int32(0x80) { + v1 = zIn + zIn = zIn + 1 + c = c<> libc.Int32FromInt32(8) & libc.Uint32FromInt32(0x00FF)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c & libc.Uint32FromInt32(0x00FF)) + } else { + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(libc.Uint32FromInt32(0x00D8) + (c-libc.Uint32FromInt32(0x10000))>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x03)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c>>libc.Int32FromInt32(10)&libc.Uint32FromInt32(0x003F) + (c-libc.Uint32FromInt32(0x10000))>>libc.Int32FromInt32(10)&libc.Uint32FromInt32(0x00C0)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(libc.Uint32FromInt32(0x00DC) + c>>libc.Int32FromInt32(8)&libc.Uint32FromInt32(0x03)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c & libc.Uint32FromInt32(0x00FF)) + } + } + } + (*TMem)(unsafe.Pointer(pMem)).Fn = int32(int64(z) - int64(zOut)) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + } else { + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) == int32(SQLITE_UTF16LE) { + /* UTF-16 Little-endian -> UTF-8 */ + for zIn < zTerm { + v1 = zIn + zIn = zIn + 1 + c = uint32(**(**uint8)(__ccgo_up(v1))) + v1 = zIn + zIn = zIn + 1 + c = c + libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(v1)))<= uint32(0xd800) && c < uint32(0xe000) { + if zIn < zTerm { + v1 = zIn + zIn = zIn + 1 + c2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v1))) + v2 = zIn + zIn = zIn + 1 + c2 = c2 + libc.Int32FromUint8(**(**uint8)(__ccgo_up(v2)))<>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } else { + if c < uint32(0x10000) { + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xE0) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xF0) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } + } + } + } + } else { + /* UTF-16 Big-endian -> UTF-8 */ + for zIn < zTerm { + v1 = zIn + zIn = zIn + 1 + c = libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(v1))) << int32(8)) + v1 = zIn + zIn = zIn + 1 + c = c + uint32(**(**uint8)(__ccgo_up(v1))) + if c >= uint32(0xd800) && c < uint32(0xe000) { + if zIn < zTerm { + v1 = zIn + zIn = zIn + 1 + c21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v1))) << int32(8) + v2 = zIn + zIn = zIn + 1 + c21 = c21 + libc.Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + c = libc.Uint32FromInt32(c21&libc.Int32FromInt32(0x03FF)) + c&uint32(0x003F)<>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x1F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } else { + if c < uint32(0x10000) { + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xE0) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x0F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } else { + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0xF0) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(18)&libc.Uint32FromInt32(0x07)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(12)&libc.Uint32FromInt32(0x3F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c>>libc.Int32FromInt32(6)&libc.Uint32FromInt32(0x3F)))) + v1 = z + z = z + 1 + **(**uint8)(__ccgo_up(v1)) = libc.Uint8FromInt32(int32(0x80) + libc.Int32FromUint8(uint8(c&libc.Uint32FromInt32(0x3F)))) + } + } + } + } + } + (*TMem)(unsafe.Pointer(pMem)).Fn = int32(int64(z) - int64(zOut)) + } + **(**uint8)(__ccgo_up(z)) = uint8(0) + c = libc.Uint32FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term) | libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_AffMask)|libc.Int32FromInt32(MEM_Subtype))) + _sqlite3VdbeMemRelease(tls, pMem) + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(c) + (*TMem)(unsafe.Pointer(pMem)).Fenc = desiredEnc + (*TMem)(unsafe.Pointer(pMem)).Fz = zOut + (*TMem)(unsafe.Pointer(pMem)).FzMalloc = (*TMem)(unsafe.Pointer(pMem)).Fz + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = _sqlite3DbMallocSize(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).Fz) + goto translate_out +translate_out: + ; + return SQLITE_OK + return r +} + +// C documentation +// +// /* +// ** Locate the next opcode to be displayed in EXPLAIN or EXPLAIN +// ** QUERY PLAN output. +// ** +// ** Return SQLITE_ROW on success. Return SQLITE_DONE if there are no +// ** more opcodes to be displayed. +// */ +func _sqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, piPc uintptr, piAddr uintptr, paOp uintptr) (r int32) { + var aOp, apSub uintptr + var i, iPc, j, j1, nByte, nRow, nSub, rc, v2 int32 + _, _, _, _, _, _, _, _, _, _, _ = aOp, apSub, i, iPc, j, j1, nByte, nRow, nSub, rc, v2 /* Stop when row count reaches this */ + nSub = 0 /* Number of sub-vdbes seen so far */ + apSub = uintptr(0) /* Next instruction address */ + rc = SQLITE_OK /* Result code */ + aOp = uintptr(0) /* Rowid. Copy of value in *piPc */ + /* When the number of output rows reaches nRow, that means the + ** listing has finished and sqlite3_step() should return SQLITE_DONE. + ** nRow is the sum of the number of rows in the main program, plus + ** the sum of the number of rows in all trigger subprograms encountered + ** so far. The nRow value will increase as new trigger subprograms are + ** encountered, but p->pc will eventually catch up to nRow. + */ + nRow = (*TVdbe)(unsafe.Pointer(p)).FnOp + if pSub != uintptr(0) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pSub)).Fflags)&int32(MEM_Blob) != 0 { + /* pSub is initiallly NULL. It is initialized to a BLOB by + ** the P4_SUBPROGRAM processing logic below */ + nSub = libc.Int32FromUint64(libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pSub)).Fn) / uint64(8)) + apSub = (*TMem)(unsafe.Pointer(pSub)).Fz + } + i = 0 + for { + if !(i < nSub) { + break + } + nRow = nRow + (*TSubProgram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(apSub + uintptr(i)*8)))).FnOp + goto _1 + _1: + ; + i = i + 1 + } + } + iPc = **(**int32)(__ccgo_up(piPc)) + for int32(1) != 0 { /* Loop exits via break */ + v2 = iPc + iPc = iPc + 1 + i = v2 + if i >= nRow { + (*TVdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + rc = int32(SQLITE_DONE) + break + } + if i < (*TVdbe)(unsafe.Pointer(p)).FnOp { + /* The rowid is small enough that we are still in the + ** main program. */ + aOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + } else { + i = i - (*TVdbe)(unsafe.Pointer(p)).FnOp + j = 0 + for { + if !(i >= (*TSubProgram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(apSub + uintptr(j)*8)))).FnOp) { + break + } + i = i - (*TSubProgram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(apSub + uintptr(j)*8)))).FnOp + goto _3 + _3: + ; + j = j + 1 + } + aOp = (*TSubProgram)(unsafe.Pointer(**(**uintptr)(__ccgo_up(apSub + uintptr(j)*8)))).FaOp + } + /* When an OP_Program opcode is encounter (the only opcode that has + ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms + ** kept in p->aMem[9].z to hold the new program - assuming this subprogram + ** has not already been seen. + */ + if pSub != uintptr(0) && int32((**(**TOp)(__ccgo_up(aOp + uintptr(i)*24))).Fp4type) == -int32(4) { + nByte = libc.Int32FromUint64(libc.Uint64FromInt32(nSub+libc.Int32FromInt32(1)) * uint64(8)) + j1 = 0 + for { + if !(j1 < nSub) { + break + } + if **(**uintptr)(__ccgo_up(apSub + uintptr(j1)*8)) == *(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*24 + 16)) { + break + } + goto _4 + _4: + ; + j1 = j1 + 1 + } + if j1 == nSub { + (*TVdbe)(unsafe.Pointer(p)).Frc = _sqlite3VdbeMemGrow(tls, pSub, nByte, libc.BoolInt32(nSub != 0)) + if (*TVdbe)(unsafe.Pointer(p)).Frc != SQLITE_OK { + rc = int32(SQLITE_ERROR) + break + } + apSub = (*TMem)(unsafe.Pointer(pSub)).Fz + v2 = nSub + nSub = nSub + 1 + **(**uintptr)(__ccgo_up(apSub + uintptr(v2)*8)) = *(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*24 + 16)) + (*TMem)(unsafe.Pointer(pSub)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pSub)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Blob)) + (*TMem)(unsafe.Pointer(pSub)).Fn = libc.Int32FromUint64(libc.Uint64FromInt32(nSub) * uint64(8)) + nRow = nRow + (*TSubProgram)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*24 + 16)))).FnOp + } + } + if eMode == 0 { + break + } + if libc.Int32FromUint8((**(**TOp)(__ccgo_up(aOp + uintptr(i)*24))).Fopcode) == int32(OP_Explain) { + break + } + if libc.Int32FromUint8((**(**TOp)(__ccgo_up(aOp + uintptr(i)*24))).Fopcode) == int32(OP_Init) && iPc > int32(1) { + break + } + } + **(**int32)(__ccgo_up(piPc)) = iPc + **(**int32)(__ccgo_up(piAddr)) = i + **(**uintptr)(__ccgo_up(paOp)) = aOp + return rc +} + +// C documentation +// +// /* +// ** This function compares the two table rows or index records +// ** specified by {nKey1, pKey1} and pPKey2. It returns a negative, zero +// ** or positive integer if key1 is less than, equal to or +// ** greater than key2. The {nKey1, pKey1} key must be a blob +// ** created by the OP_MakeRecord opcode of the VDBE. The pPKey2 +// ** key must be a parsed key such as obtained from +// ** sqlite3VdbeParseRecord. +// ** +// ** If argument bSkip is non-zero, it is assumed that the caller has already +// ** determined that the first fields of the keys are equal. +// ** +// ** Key1 and Key2 do not have to contain the same number of fields. If all +// ** fields that appear in both keys are equal, then pPKey2->default_rc is +// ** returned. +// ** +// ** If database corruption is discovered, set pPKey2->errCode to +// ** SQLITE_CORRUPT and return 0. If an OOM error is encountered, +// ** pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the +// ** malloc-failed flag set on database handle (pPKey2->pKeyInfo->db). +// */ +func _sqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr, bSkip int32) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var aKey1, pKeyInfo, pRhs, v4 uintptr + var d1, idx1, v1 Tu32 + var i, nCmp, nCmp1, nStr, rc, sortFlags, v2 int32 + var lhs, rhs Ti64 + var v5 bool + var _ /* mem1 at bp+8 */ TMem + var _ /* s1 at bp+64 */ Tu32 + var _ /* serial_type at bp+68 */ Tu32 + var _ /* szHdr1 at bp+0 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aKey1, d1, i, idx1, lhs, nCmp, nCmp1, nStr, pKeyInfo, pRhs, rc, rhs, sortFlags, v1, v2, v4, v5 /* Offset of first type in header */ + rc = 0 /* Return value */ + pRhs = (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem + aKey1 = pKey1 + /* If bSkip is true, then the caller has already determined that the first + ** two elements in the keys are equal. Fix the various stack variables so + ** that this routine begins comparing at the second field. */ + if bSkip != 0 { + **(**Tu32)(__ccgo_up(bp + 64)) = uint32(**(**uint8)(__ccgo_up(aKey1 + 1))) + if **(**Tu32)(__ccgo_up(bp + 64)) < uint32(0x80) { + idx1 = uint32(2) + } else { + idx1 = libc.Uint32FromInt32(int32(1) + libc.Int32FromUint8(_sqlite3GetVarint32(tls, aKey1+1, bp+64))) + } + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**uint8)(__ccgo_up(aKey1))) + d1 = **(**Tu32)(__ccgo_up(bp)) + _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 64))) + i = int32(1) + pRhs += 56 + } else { + v1 = uint32(**(**uint8)(__ccgo_up(aKey1))) + **(**Tu32)(__ccgo_up(bp)) = v1 + if v1 < uint32(0x80) { + idx1 = uint32(1) + } else { + idx1 = uint32(_sqlite3GetVarint32(tls, aKey1, bp)) + } + d1 = **(**Tu32)(__ccgo_up(bp)) + i = 0 + } + if d1 > libc.Uint32FromInt32(nKey1) { + (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = libc.Uint8FromInt32(_sqlite3CorruptError(tls, int32(92522))) + return 0 /* Corruption */ + } + /* Only needed by assert() statements */ + for int32(1) != 0 { + /* RHS is an integer */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRhs)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + **(**Tu32)(__ccgo_up(bp + 68)) = uint32(**(**uint8)(__ccgo_up(aKey1 + uintptr(idx1)))) + if **(**Tu32)(__ccgo_up(bp + 68)) >= uint32(10) { + if **(**Tu32)(__ccgo_up(bp + 68)) == uint32(10) { + v2 = -int32(1) + } else { + v2 = +libc.Int32FromInt32(1) + } + rc = v2 + } else { + if **(**Tu32)(__ccgo_up(bp + 68)) == uint32(0) { + rc = -int32(1) + } else { + if **(**Tu32)(__ccgo_up(bp + 68)) == uint32(7) { + _serialGet7(tls, aKey1+uintptr(d1), bp+8) + rc = -_sqlite3IntFloatCompare(tls, *(*Ti64)(unsafe.Pointer(pRhs)), *(*float64)(unsafe.Pointer(bp + 8))) + } else { + lhs = _vdbeRecordDecodeInt(tls, **(**Tu32)(__ccgo_up(bp + 68)), aKey1+uintptr(d1)) + rhs = *(*Ti64)(unsafe.Pointer(pRhs)) + if lhs < rhs { + rc = -int32(1) + } else { + if lhs > rhs { + rc = +libc.Int32FromInt32(1) + } + } + } + } + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRhs)).Fflags)&int32(MEM_Real) != 0 { + **(**Tu32)(__ccgo_up(bp + 68)) = uint32(**(**uint8)(__ccgo_up(aKey1 + uintptr(idx1)))) + if **(**Tu32)(__ccgo_up(bp + 68)) >= uint32(10) { + /* Serial types 12 or greater are strings and blobs (greater than + ** numbers). Types 10 and 11 are currently "reserved for future + ** use", so it doesn't really matter what the results of comparing + ** them to numeric values are. */ + if **(**Tu32)(__ccgo_up(bp + 68)) == uint32(10) { + v2 = -int32(1) + } else { + v2 = +libc.Int32FromInt32(1) + } + rc = v2 + } else { + if **(**Tu32)(__ccgo_up(bp + 68)) == uint32(0) { + rc = -int32(1) + } else { + if **(**Tu32)(__ccgo_up(bp + 68)) == uint32(7) { + if _serialGet7(tls, aKey1+uintptr(d1), bp+8) != 0 { + rc = -int32(1) /* mem1 is a NaN */ + } else { + if *(*float64)(unsafe.Pointer(bp + 8)) < *(*float64)(unsafe.Pointer(pRhs)) { + rc = -int32(1) + } else { + if *(*float64)(unsafe.Pointer(bp + 8)) > *(*float64)(unsafe.Pointer(pRhs)) { + rc = +libc.Int32FromInt32(1) + } else { + } + } + } + } else { + _sqlite3VdbeSerialGet(tls, aKey1+uintptr(d1), **(**Tu32)(__ccgo_up(bp + 68)), bp+8) + rc = _sqlite3IntFloatCompare(tls, *(*Ti64)(unsafe.Pointer(bp + 8)), *(*float64)(unsafe.Pointer(pRhs))) + } + } + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRhs)).Fflags)&int32(MEM_Str) != 0 { + **(**Tu32)(__ccgo_up(bp + 68)) = uint32(**(**uint8)(__ccgo_up(aKey1 + uintptr(idx1)))) + if **(**Tu32)(__ccgo_up(bp + 68)) >= uint32(0x80) { + _sqlite3GetVarint32(tls, aKey1+uintptr(idx1), bp+68) + } + if **(**Tu32)(__ccgo_up(bp + 68)) < uint32(12) { + rc = -int32(1) + } else { + if !(**(**Tu32)(__ccgo_up(bp + 68))&libc.Uint32FromInt32(0x01) != 0) { + rc = +libc.Int32FromInt32(1) + } else { + (**(**TMem)(__ccgo_up(bp + 8))).Fn = libc.Int32FromUint32((**(**Tu32)(__ccgo_up(bp + 68)) - uint32(12)) / uint32(2)) + if v5 = d1+libc.Uint32FromInt32((**(**TMem)(__ccgo_up(bp + 8))).Fn) > libc.Uint32FromInt32(nKey1); !v5 { + v4 = (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FpKeyInfo + pKeyInfo = v4 + } + if v5 || libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(v4)).FnAllField) <= i { + (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = libc.Uint8FromInt32(_sqlite3CorruptError(tls, int32(92603))) + return 0 /* Corruption */ + } else { + if *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)) != 0 { + (**(**TMem)(__ccgo_up(bp + 8))).Fenc = (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).Fenc + (**(**TMem)(__ccgo_up(bp + 8))).Fdb = (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb + (**(**TMem)(__ccgo_up(bp + 8))).Fflags = uint16(MEM_Str) + (**(**TMem)(__ccgo_up(bp + 8))).Fz = aKey1 + uintptr(d1) + rc = _vdbeCompareMemString(tls, bp+8, pRhs, *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)), pPKey2+31) + } else { + if (**(**TMem)(__ccgo_up(bp + 8))).Fn < (*TMem)(unsafe.Pointer(pRhs)).Fn { + v2 = (**(**TMem)(__ccgo_up(bp + 8))).Fn + } else { + v2 = (*TMem)(unsafe.Pointer(pRhs)).Fn + } + nCmp = v2 + rc = libc.Xmemcmp(tls, aKey1+uintptr(d1), (*TMem)(unsafe.Pointer(pRhs)).Fz, libc.Uint64FromInt32(nCmp)) + if rc == 0 { + rc = (**(**TMem)(__ccgo_up(bp + 8))).Fn - (*TMem)(unsafe.Pointer(pRhs)).Fn + } + } + } + } + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRhs)).Fflags)&int32(MEM_Blob) != 0 { + **(**Tu32)(__ccgo_up(bp + 68)) = uint32(**(**uint8)(__ccgo_up(aKey1 + uintptr(idx1)))) + if **(**Tu32)(__ccgo_up(bp + 68)) >= uint32(0x80) { + _sqlite3GetVarint32(tls, aKey1+uintptr(idx1), bp+68) + } + if **(**Tu32)(__ccgo_up(bp + 68)) < uint32(12) || **(**Tu32)(__ccgo_up(bp + 68))&uint32(0x01) != 0 { + rc = -int32(1) + } else { + nStr = libc.Int32FromUint32((**(**Tu32)(__ccgo_up(bp + 68)) - uint32(12)) / uint32(2)) + if d1+libc.Uint32FromInt32(nStr) > libc.Uint32FromInt32(nKey1) { + (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = libc.Uint8FromInt32(_sqlite3CorruptError(tls, int32(92633))) + return 0 /* Corruption */ + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRhs)).Fflags)&int32(MEM_Zero) != 0 { + if !(_isAllZero(tls, aKey1+uintptr(d1), nStr) != 0) { + rc = int32(1) + } else { + rc = nStr - *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRhs)).Fu)) + } + } else { + if nStr < (*TMem)(unsafe.Pointer(pRhs)).Fn { + v2 = nStr + } else { + v2 = (*TMem)(unsafe.Pointer(pRhs)).Fn + } + nCmp1 = v2 + rc = libc.Xmemcmp(tls, aKey1+uintptr(d1), (*TMem)(unsafe.Pointer(pRhs)).Fz, libc.Uint64FromInt32(nCmp1)) + if rc == 0 { + rc = nStr - (*TMem)(unsafe.Pointer(pRhs)).Fn + } + } + } + } + } else { + **(**Tu32)(__ccgo_up(bp + 68)) = uint32(**(**uint8)(__ccgo_up(aKey1 + uintptr(idx1)))) + if **(**Tu32)(__ccgo_up(bp + 68)) == uint32(0) || **(**Tu32)(__ccgo_up(bp + 68)) == uint32(10) || **(**Tu32)(__ccgo_up(bp + 68)) == uint32(7) && _serialGet7(tls, aKey1+uintptr(d1), bp+8) != 0 { + } else { + rc = int32(1) + } + } + } + } + } + if rc != 0 { + sortFlags = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FpKeyInfo)).FaSortFlags + uintptr(i)))) + if sortFlags != 0 { + if sortFlags&int32(KEYINFO_ORDER_BIGNULL) == 0 || sortFlags&int32(KEYINFO_ORDER_DESC) != libc.BoolInt32(**(**Tu32)(__ccgo_up(bp + 68)) == uint32(0) || libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRhs)).Fflags)&int32(MEM_Null) != 0) { + rc = -rc + } + } + /* See comment below */ + return rc + } + i = i + 1 + if i == libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FnField) { + break + } + pRhs += 56 + d1 = d1 + _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 68))) + if d1 > libc.Uint32FromInt32(nKey1) { + break + } + idx1 = idx1 + libc.Uint32FromInt32(_sqlite3VarintLen(tls, uint64(**(**Tu32)(__ccgo_up(bp + 68))))) + if idx1 >= **(**Tu32)(__ccgo_up(bp)) { + (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = libc.Uint8FromInt32(_sqlite3CorruptError(tls, int32(92684))) + return 0 /* Corrupt index */ + } + } + /* No memory allocation is ever used on mem1. Prove this using + ** the following assert(). If the assert() fails, it indicates a + ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1). */ + /* rc==0 here means that one or both of the keys ran out of fields and + ** all the fields up to that point were equal. Return the default_rc + ** value. */ + (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FeqSeen = uint8(1) + return int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fdefault_rc) +} + +// C documentation +// +// /* +// ** Given the nKey-byte encoding of a record in pKey[], populate the +// ** UnpackedRecord structure indicated by the fourth argument with the +// ** contents of the decoded record. +// */ +func _sqlite3VdbeRecordUnpack(tls *libc.TLS, nKey int32, pKey uintptr, p uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aKey, pKeyInfo, pMem uintptr + var d, idx Tu32 + var u, v3 Tu16 + var v1 int32 + var _ /* serial_type at bp+4 */ Tu32 + var _ /* szHdr at bp+0 */ Tu32 + _, _, _, _, _, _, _, _ = aKey, d, idx, pKeyInfo, pMem, u, v1, v3 + aKey = pKey + pMem = (*TUnpackedRecord)(unsafe.Pointer(p)).FaMem + pKeyInfo = (*TUnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + (*TUnpackedRecord)(unsafe.Pointer(p)).Fdefault_rc = 0 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(aKey))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**uint8)(__ccgo_up(aKey))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aKey, bp)) + } + idx = uint32(libc.Uint8FromInt32(v1)) + d = **(**Tu32)(__ccgo_up(bp)) + u = uint16(0) + for idx < **(**Tu32)(__ccgo_up(bp)) && d <= libc.Uint32FromInt32(nKey) { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(aKey + uintptr(idx)))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(**(**uint8)(__ccgo_up(aKey + uintptr(idx)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aKey+uintptr(idx), bp+4)) + } + idx = idx + uint32(libc.Uint8FromInt32(v1)) + (*TMem)(unsafe.Pointer(pMem)).Fenc = (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).Fenc + (*TMem)(unsafe.Pointer(pMem)).Fdb = (*TKeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb + /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */ + (*TMem)(unsafe.Pointer(pMem)).FszMalloc = 0 + (*TMem)(unsafe.Pointer(pMem)).Fz = uintptr(0) + _sqlite3VdbeSerialGet(tls, aKey+uintptr(d), **(**Tu32)(__ccgo_up(bp + 4)), pMem) + d = d + _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 4))) + u = u + 1 + v3 = u + if libc.Int32FromUint16(v3) >= libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(p)).FnField) { + break + } + pMem += 56 + } + if d > libc.Uint32FromInt32(nKey) && u != 0 { + /* In a corrupt record entry, the last pMem might have been set up using + ** uninitialized memory. Overwrite its value with NULL, to prevent + ** warnings from MSAN. */ + _sqlite3VdbeMemSetNull(tls, pMem-libc.BoolUintptr(libc.Int32FromUint16(u) < libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(p)).FnField))*56) + } + (*TUnpackedRecord)(unsafe.Pointer(p)).FnField = u +} + +// C documentation +// +// /* +// ** Mark the VDBE as one that can be run multiple times. +// */ +func _sqlite3VdbeReusable(tls *libc.TLS, p uintptr) { + var i int32 + _ = i + i = int32(1) + for { + if !(i < (*TVdbe)(unsafe.Pointer(p)).FnOp) { + break + } + if libc.Int32FromUint8((**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i)*24))).Fopcode) == int32(OP_Expire) { + (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + 1*24))).Fopcode = uint8(OP_Noop) + break + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Set the name of the idx'th column to be returned by the SQL statement. +// ** zName must be a pointer to a nul terminated string. +// ** +// ** This call must be made after a call to sqlite3VdbeSetNumCols(). +// ** +// ** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC +// ** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed +// ** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed. +// */ +func _sqlite3VdbeSetColName(tls *libc.TLS, p uintptr, idx int32, var1 int32, zName uintptr, __ccgo_fp_xDel uintptr) (r int32) { + var pColName uintptr + var rc int32 + _, _ = pColName, rc + if (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 { + return int32(SQLITE_NOMEM) + } + pColName = (*TVdbe)(unsafe.Pointer(p)).FaColName + uintptr(idx+var1*libc.Int32FromUint16((*TVdbe)(unsafe.Pointer(p)).FnResAlloc))*56 + rc = _sqlite3VdbeMemSetText(tls, pColName, zName, int64(-int32(1)), __ccgo_fp_xDel) + return rc +} + +// C documentation +// +// /* +// ** Set the number of result columns that will be returned by this SQL +// ** statement. This is now set at compile time, rather than during +// ** execution of the vdbe program so that sqlite3_column_count() can +// ** be called on an SQL statement before sqlite3_step(). +// */ +func _sqlite3VdbeSetNumCols(tls *libc.TLS, p uintptr, nResColumn int32) { + var db uintptr + var n int32 + var v1 Tu16 + _, _, _ = db, n, v1 + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + if (*TVdbe)(unsafe.Pointer(p)).FnResAlloc != 0 { + _releaseMemArray(tls, (*TVdbe)(unsafe.Pointer(p)).FaColName, libc.Int32FromUint16((*TVdbe)(unsafe.Pointer(p)).FnResAlloc)*int32(COLNAME_N)) + _sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(p)).FaColName) + } + n = nResColumn * int32(COLNAME_N) + v1 = libc.Uint16FromInt32(nResColumn) + (*TVdbe)(unsafe.Pointer(p)).FnResAlloc = v1 + (*TVdbe)(unsafe.Pointer(p)).FnResColumn = v1 + (*TVdbe)(unsafe.Pointer(p)).FaColName = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(56)*libc.Uint64FromInt32(n))) + if (*TVdbe)(unsafe.Pointer(p)).FaColName == uintptr(0) { + return + } + _initMemArray(tls, (*TVdbe)(unsafe.Pointer(p)).FaColName, n, db, uint16(MEM_Null)) +} + +// C documentation +// +// /* +// ** Free any cursor components allocated by sqlite3VdbeSorterXXX routines. +// */ +func _sqlite3VdbeSorterClose(tls *libc.TLS, db uintptr, pCsr uintptr) { + var ii int32 + var pSorter uintptr + _, _ = ii, pSorter + pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 48)) + if pSorter != 0 { + ii = 0 + for { + if !(ii < libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) { + break + } + **(**Tu64)(__ccgo_up(db + 816)) += (*(*TSortSubtask)(unsafe.Pointer(pSorter + 96 + uintptr(ii)*104))).FnSpill + goto _1 + _1: + ; + ii = ii + 1 + } + _sqlite3VdbeSorterReset(tls, db, pSorter) + Xsqlite3_free(tls, (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory) + _sqlite3DbFree(tls, db, pSorter) + *(*uintptr)(unsafe.Pointer(pCsr + 48)) = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Compare the key in memory cell pVal with the key that the sorter cursor +// ** passed as the first argument currently points to. For the purposes of +// ** the comparison, ignore the rowid field at the end of each record. +// ** +// ** If the sorter cursor key contains any NULL values, consider it to be +// ** less than pVal. Even if pVal also contains NULL values. +// ** +// ** If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM). +// ** Otherwise, set *pRes to a negative, zero or positive value if the +// ** key in pVal is smaller than, equal to or larger than the current sorter +// ** key. +// ** +// ** This routine forms the core of the OP_SorterCompare opcode, which in +// ** turn is used to verify uniqueness when constructing a UNIQUE INDEX. +// */ +func _sqlite3VdbeSorterCompare(tls *libc.TLS, pCsr uintptr, pVal uintptr, nKeyCol int32, pRes uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var pKey, pKeyInfo, pSorter, r2, v1 uintptr + var _ /* nKey at bp+0 */ int32 + _, _, _, _, _, _ = i, pKey, pKeyInfo, pSorter, r2, v1 /* Sorter key to compare pVal with */ + pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 48)) + r2 = (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpUnpacked + pKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo + if r2 == uintptr(0) { + v1 = _sqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpUnpacked = v1 + r2 = v1 + if r2 == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TUnpackedRecord)(unsafe.Pointer(r2)).FnField = libc.Uint16FromInt32(nKeyCol) + } + pKey = _vdbeSorterRowkey(tls, pSorter, bp) + _sqlite3VdbeRecordUnpack(tls, **(**int32)(__ccgo_up(bp)), pKey, r2) + i = 0 + for { + if !(i < nKeyCol) { + break + } + if libc.Int32FromUint16((**(**TMem)(__ccgo_up((*TUnpackedRecord)(unsafe.Pointer(r2)).FaMem + uintptr(i)*56))).Fflags)&int32(MEM_Null) != 0 { + **(**int32)(__ccgo_up(pRes)) = -int32(1) + return SQLITE_OK + } + goto _2 + _2: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(pRes)) = _sqlite3VdbeRecordCompare(tls, (*TMem)(unsafe.Pointer(pVal)).Fn, (*TMem)(unsafe.Pointer(pVal)).Fz, r2) + return SQLITE_OK +} + +/************** End of vdbesort.c ********************************************/ +/************** Begin file vdbevtab.c ****************************************/ +/* +** 2020-03-23 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file implements virtual-tables for examining the bytecode content +** of a prepared statement. + */ +/* #include "sqliteInt.h" */ + +/************** End of vdbevtab.c ********************************************/ +/************** Begin file memjournal.c **************************************/ +/* +** 2008 October 7 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains code use to implement an in-memory rollback journal. +** The in-memory rollback journal is used to journal transactions for +** ":memory:" databases and when the journal_mode=MEMORY pragma is used. +** +** Update: The in-memory journal is also used to temporarily cache +** smaller journals that are not critical for power-loss recovery. +** For example, statement journals that are not too big will be held +** entirely in memory, thus reducing the number of file I/O calls, and +** more importantly, reducing temporary file creation events. If these +** journals become too large for memory, they are spilled to disk. But +** in the common case, they are usually small and no file I/O needs to +** occur. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** Reset a sorting cursor back to its original empty state. +// */ +func _sqlite3VdbeSorterReset(tls *libc.TLS, db uintptr, pSorter uintptr) { + var i int32 + var pTask uintptr + _, _ = i, pTask + _vdbeSorterJoinAll(tls, pSorter, SQLITE_OK) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpReader != 0 { + _vdbePmaReaderClear(tls, (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpReader) + _sqlite3DbFree(tls, db, (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpReader) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpReader = uintptr(0) + } + _vdbeMergeEngineFree(tls, (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpMerger) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpMerger = uintptr(0) + i = 0 + for { + if !(i < libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) { + break + } + pTask = pSorter + 96 + uintptr(i)*104 + _vdbeSortSubtaskCleanup(tls, db, pTask) + (*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter = pSorter + goto _1 + _1: + ; + i = i + 1 + } + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory == uintptr(0) { + _vdbeSorterRecordFree(tls, uintptr(0), (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList) + } + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = uintptr(0) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA = 0 + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA = uint8(0) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FiMemory = 0 + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FmxKeysize = 0 + _sqlite3DbFree(tls, db, (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpUnpacked) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpUnpacked = uintptr(0) +} + +// C documentation +// +// /* +// ** Once the sorter has been populated by calls to sqlite3VdbeSorterWrite, +// ** this function is called to prepare for iterating through the records +// ** in sorted order. +// */ +func _sqlite3VdbeSorterRewind(tls *libc.TLS, pCsr uintptr, pbEof uintptr) (r int32) { + var pSorter uintptr + var rc int32 + _, _ = pSorter, rc + rc = SQLITE_OK /* Return code */ + pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 48)) + /* If no data has been written to disk, then do not do so now. Instead, + ** sort the VdbeSorter.pRecord list. The vdbe layer will read data directly + ** from the in-memory list. */ + if libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA) == 0 { + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { + **(**int32)(__ccgo_up(pbEof)) = 0 + rc = _vdbeSorterSort(tls, pSorter+96, pSorter+56) + } else { + **(**int32)(__ccgo_up(pbEof)) = int32(1) + } + return rc + } + /* Write the current in-memory list to a PMA. When the VdbeSorterWrite() + ** function flushes the contents of memory to disk, it immediately always + ** creates a new list consisting of a single key immediately afterwards. + ** So the list is never empty at this point. */ + rc = _vdbeSorterFlushPMA(tls, pSorter) + /* Join all threads */ + rc = _vdbeSorterJoinAll(tls, pSorter, rc) + /* Assuming no errors have occurred, set up a merger structure to + ** incrementally read and merge all remaining PMAs. */ + if rc == SQLITE_OK { + rc = _vdbeSorterSetupMerge(tls, pSorter) + **(**int32)(__ccgo_up(pbEof)) = 0 + } + return rc +} + +// C documentation +// +// /* +// ** Return a pointer to a subexpression of pVector that is the i-th +// ** column of the vector (numbered starting with 0). The caller must +// ** ensure that i is within range. +// ** +// ** If pVector is really a scalar (and "scalar" here includes subqueries +// ** that return a single column!) then return pVector unmodified. +// ** +// ** pVector retains ownership of the returned subexpression. +// ** +// ** If the vector is a (SELECT ...) then the expression returned is +// ** just the expression for the i-th term of the result set, and may +// ** not be ready for evaluation because the table cursor has not yet +// ** been positioned. +// */ +func _sqlite3VectorFieldSubexpr(tls *libc.TLS, pVector uintptr, i int32) (r uintptr) { + if _sqlite3ExprIsVector(tls, pVector) != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pVector)).Fop) == int32(TK_SELECT) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pVector)).Fop2) == int32(TK_SELECT) { + return (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 32)))).FpEList + 8 + uintptr(i)*32))).FpExpr + } else { + return (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 32)) + 8 + uintptr(i)*32))).FpExpr + } + } + return pVector +} + +// C documentation +// +// /* +// ** The parser calls this routine for each token after the first token +// ** in an argument to the module name in a CREATE VIRTUAL TABLE statement. +// */ +func _sqlite3VtabArgExtend(tls *libc.TLS, pParse uintptr, p uintptr) { + var pArg uintptr + _ = pArg + pArg = pParse + 376 + if (*TToken)(unsafe.Pointer(pArg)).Fz == uintptr(0) { + (*TToken)(unsafe.Pointer(pArg)).Fz = (*TToken)(unsafe.Pointer(p)).Fz + (*TToken)(unsafe.Pointer(pArg)).Fn = (*TToken)(unsafe.Pointer(p)).Fn + } else { + (*TToken)(unsafe.Pointer(pArg)).Fn = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t((*TToken)(unsafe.Pointer(p)).Fz+uintptr((*TToken)(unsafe.Pointer(p)).Fn)) - int64((*TToken)(unsafe.Pointer(pArg)).Fz))) + } +} + +// C documentation +// +// /* +// ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE +// ** statement. The module name has been parsed, but the optional list +// ** of parameters that follow the module name are still pending. +// */ +func _sqlite3VtabBeginParse(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pModuleName uintptr, ifNotExists int32) { + var db, pTable uintptr + var iDb int32 + _, _, _ = db, iDb, pTable /* Database connection */ + _sqlite3StartTable(tls, pParse, pName1, pName2, 0, 0, int32(1), ifNotExists) + pTable = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if pTable == uintptr(0) { + return + } + (*TTable)(unsafe.Pointer(pTable)).FeTabType = uint8(TABTYP_VTAB) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + _addModuleArgument(tls, pParse, pTable, _sqlite3NameFromToken(tls, db, pModuleName)) + _addModuleArgument(tls, pParse, pTable, uintptr(0)) + _addModuleArgument(tls, pParse, pTable, _sqlite3DbStrDup(tls, db, (*TTable)(unsafe.Pointer(pTable)).FzName)) + (*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fn = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t((*TToken)(unsafe.Pointer(pModuleName)).Fz+uintptr((*TToken)(unsafe.Pointer(pModuleName)).Fn)) - int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz))) + /* Creating a virtual table invokes the authorization callback twice. + ** The first invocation, to obtain permission to INSERT a row into the + ** sqlite_schema table, has already been made by sqlite3StartTable(). + ** The second call, to obtain permission to create the table, is made now. + */ + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FazArg != 0 { + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTable)).FpSchema) + /* The database the table is being created in */ + _sqlite3AuthCheck(tls, pParse, int32(SQLITE_CREATE_VTABLE), (*TTable)(unsafe.Pointer(pTable)).FzName, **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTable + 64))).FazArg)), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName) + } +} + +// C documentation +// +// /* +// ** This function is invoked by the vdbe to call the xDestroy method +// ** of the virtual table named zTab in database iDb. This occurs +// ** when a DROP TABLE is mentioned. +// ** +// ** This call is a no-op if zTab is not a virtual table. +// */ +func _sqlite3VtabCallDestroy(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr) (r int32) { + var p, pTab, xDestroy uintptr + var rc int32 + _, _, _, _ = p, pTab, rc, xDestroy + rc = SQLITE_OK + pTab = _sqlite3FindTable(tls, db, zTab, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + if pTab != uintptr(0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) && (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp != uintptr(0) { + p = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp + for { + if !(p != 0) { + break + } + if (*Tsqlite3_vtab)(unsafe.Pointer((*TVTable)(unsafe.Pointer(p)).FpVtab)).FnRef > 0 { + return int32(SQLITE_LOCKED) + } + goto _1 + _1: + ; + p = (*TVTable)(unsafe.Pointer(p)).FpNext + } + p = _vtabDisconnectAll(tls, db, pTab) + xDestroy = (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer(p)).FpMod)).FpModule)).FxDestroy + if xDestroy == uintptr(0) { + xDestroy = (*Tsqlite3_module)(unsafe.Pointer((*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer(p)).FpMod)).FpModule)).FxDisconnect + } + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xDestroy})))(tls, (*TVTable)(unsafe.Pointer(p)).FpVtab) + /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ + if rc == SQLITE_OK { + (*TVTable)(unsafe.Pointer(p)).FpVtab = uintptr(0) + (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp = uintptr(0) + _sqlite3VtabUnlock(tls, p) + } + _sqlite3DeleteTable(tls, db, pTab) + } + return rc +} + +// C documentation +// +// /* +// ** Invoke the xCommit method of all virtual tables in the +// ** sqlite3.aVTrans array. Then clear the array itself. +// */ +func _sqlite3VtabCommit(tls *libc.TLS, db uintptr) (r int32) { + _callFinaliser(tls, db, libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0)+128))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Make sure virtual table pTab is contained in the pParse->apVirtualLock[] +// ** array so that an OP_VBegin will get generated for it. Add pTab to the +// ** array if it is missing. If pTab is already in the array, this routine +// ** is a no-op. +// */ +func _sqlite3VtabMakeWritable(tls *libc.TLS, pParse uintptr, pTab uintptr) { + var apVtabLock, pToplevel, v1 uintptr + var i, n, v3 int32 + _, _, _, _, _, _ = apVtabLock, i, n, pToplevel, v1, v3 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + pToplevel = v1 + i = 0 + for { + if !(i < (*TParse)(unsafe.Pointer(pToplevel)).FnVtabLock) { + break + } + if pTab == **(**uintptr)(__ccgo_up((*TParse)(unsafe.Pointer(pToplevel)).FapVtabLock + uintptr(i)*8)) { + return + } + goto _2 + _2: + ; + i = i + 1 + } + n = libc.Int32FromUint64(libc.Uint64FromInt32((*TParse)(unsafe.Pointer(pToplevel)).FnVtabLock+libc.Int32FromInt32(1)) * uint64(8)) + apVtabLock = _sqlite3Realloc(tls, (*TParse)(unsafe.Pointer(pToplevel)).FapVtabLock, libc.Uint64FromInt32(n)) + if apVtabLock != 0 { + (*TParse)(unsafe.Pointer(pToplevel)).FapVtabLock = apVtabLock + v1 = pToplevel + 304 + v3 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + **(**uintptr)(__ccgo_up((*TParse)(unsafe.Pointer(pToplevel)).FapVtabLock + uintptr(v3)*8)) = pTab + } else { + _sqlite3OomFault(tls, (*TParse)(unsafe.Pointer(pToplevel)).Fdb) + } +} + +// C documentation +// +// /* +// ** Invoke the xRollback method of all virtual tables in the +// ** sqlite3.aVTrans array. Then clear the array itself. +// */ +func _sqlite3VtabRollback(tls *libc.TLS, db uintptr) (r int32) { + _callFinaliser(tls, db, libc.Int32FromUint64(uint64(libc.UintptrFromInt32(0)+136))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Open a connection to the WAL file zWalName. The database file must +// ** already be opened on connection pDbFd. The buffer that zWalName points +// ** to must remain valid for the lifetime of the returned Wal* handle. +// ** +// ** A SHARED lock should be held on the database file when this function +// ** is called. The purpose of this SHARED lock is to prevent any other +// ** client from unlinking the WAL or wal-index file. If another process +// ** were to do this just after this client opened one of these files, the +// ** system would be badly broken. +// ** +// ** If the log file is successfully opened, SQLITE_OK is returned and +// ** *ppWal is set to point to a new WAL handle. If an error occurs, +// ** an SQLite error code is returned and *ppWal is left unmodified. +// */ +func _sqlite3WalOpen(tls *libc.TLS, pVfs uintptr, pDbFd uintptr, zWalName uintptr, bNoShm int32, mxWalSize Ti64, ppWal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDC, rc, v1 int32 + var pRet uintptr + var _ /* flags at bp+0 */ int32 + _, _, _, _ = iDC, pRet, rc, v1 /* Flags passed to OsOpen() */ + /* Verify the values of various constants. Any changes to the values + ** of these constants would result in an incompatible on-disk format + ** for the -shm file. Any change that causes one of these asserts to + ** fail is a backward compatibility problem, even if the change otherwise + ** works. + ** + ** This table also serves as a helpful cross-reference when trying to + ** interpret hex dumps of the -shm file. + */ + /* In the amalgamation, the os_unix.c and os_win.c source files come before + ** this source file. Verify that the #defines of the locking byte offsets + ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value. + ** For that matter, if the lock offset ever changes from its initial design + ** value of 120, we need to know that so there is an assert() to check it. + */ + /* Allocate an instance of struct Wal to return. */ + **(**uintptr)(__ccgo_up(ppWal)) = uintptr(0) + pRet = _sqlite3MallocZero(tls, uint64(uint64(160)+libc.Uint64FromInt32((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile))) + if !(pRet != 0) { + return int32(SQLITE_NOMEM) + } + (*TWal)(unsafe.Pointer(pRet)).FpVfs = pVfs + (*TWal)(unsafe.Pointer(pRet)).FpWalFd = pRet + 1*160 + (*TWal)(unsafe.Pointer(pRet)).FpDbFd = pDbFd + (*TWal)(unsafe.Pointer(pRet)).FreadLock = int16(-int32(1)) + (*TWal)(unsafe.Pointer(pRet)).FmxWalSize = mxWalSize + (*TWal)(unsafe.Pointer(pRet)).FzWalName = zWalName + (*TWal)(unsafe.Pointer(pRet)).FsyncHeader = uint8(1) + (*TWal)(unsafe.Pointer(pRet)).FpadToSectorBoundary = uint8(1) + if bNoShm != 0 { + v1 = int32(WAL_HEAPMEMORY_MODE) + } else { + v1 = WAL_NORMAL_MODE + } + (*TWal)(unsafe.Pointer(pRet)).FexclusiveMode = libc.Uint8FromInt32(v1) + /* Open file handle on the write-ahead log file. */ + **(**int32)(__ccgo_up(bp)) = libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_WAL) + rc = _sqlite3OsOpen(tls, pVfs, zWalName, (*TWal)(unsafe.Pointer(pRet)).FpWalFd, **(**int32)(__ccgo_up(bp)), bp) + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp))&int32(SQLITE_OPEN_READONLY) != 0 { + (*TWal)(unsafe.Pointer(pRet)).FreadOnly = uint8(WAL_RDONLY) + } + if rc != SQLITE_OK { + _walIndexClose(tls, pRet, 0) + _sqlite3OsClose(tls, (*TWal)(unsafe.Pointer(pRet)).FpWalFd) + Xsqlite3_free(tls, pRet) + } else { + iDC = _sqlite3OsDeviceCharacteristics(tls, pDbFd) + if iDC&int32(SQLITE_IOCAP_SEQUENTIAL) != 0 { + (*TWal)(unsafe.Pointer(pRet)).FsyncHeader = uint8(0) + } + if iDC&int32(SQLITE_IOCAP_POWERSAFE_OVERWRITE) != 0 { + (*TWal)(unsafe.Pointer(pRet)).FpadToSectorBoundary = uint8(0) + } + **(**uintptr)(__ccgo_up(ppWal)) = pRet + } + return rc +} + +// C documentation +// +// /* +// ** Walk an expression tree. Invoke the callback once for each node +// ** of the expression, while descending. (In other words, the callback +// ** is invoked before visiting children.) +// ** +// ** The return value from the callback should be one of the WRC_* +// ** constants to specify how to proceed with the walk. +// ** +// ** WRC_Continue Continue descending down the tree. +// ** +// ** WRC_Prune Do not descend into child nodes, but allow +// ** the walk to continue with sibling nodes. +// ** +// ** WRC_Abort Do no more callbacks. Unwind the stack and +// ** return from the top-level walk call. +// ** +// ** The return value from this routine is WRC_Abort to abandon the tree walk +// ** and WRC_Continue to continue. +// */ +func _sqlite3WalkExprNN(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var rc int32 + _ = rc + for int32(1) != 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TWalker)(unsafe.Pointer(pWalker)).FxExprCallback})))(tls, pWalker, pExpr) + if rc != 0 { + return rc & int32(WRC_Abort) + } + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)) { + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 && _sqlite3WalkExprNN(tls, pWalker, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) != 0 { + return int32(WRC_Abort) + } + if (*TExpr)(unsafe.Pointer(pExpr)).FpRight != 0 { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + continue + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + if _sqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32))) != 0 { + return int32(WRC_Abort) + } + } else { + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != 0 { + if _sqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32))) != 0 { + return int32(WRC_Abort) + } + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + if _walkWindowList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32(1)) != 0 { + return int32(WRC_Abort) + } + } + } + } + } + break + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Possibly add terms corresponding to the LIMIT and OFFSET clauses of the +// ** SELECT statement passed as the second argument. These terms are only +// ** added if: +// ** +// ** 1. The SELECT statement has a LIMIT clause, and +// ** 2. The SELECT statement is not an aggregate or DISTINCT query, and +// ** 3. The SELECT statement has exactly one object in its FROM clause, and +// ** that object is a virtual table, and +// ** 4. There are no terms in the WHERE clause that will not be passed +// ** to the virtual table xBestIndex method. +// ** 5. The ORDER BY clause, if any, will be made available to the xBestIndex +// ** method. +// ** +// ** LIMIT and OFFSET terms are ignored by most of the planner code. They +// ** exist only so that they may be passed to the xBestIndex method of the +// ** single virtual table in the FROM clause of the SELECT. +// */ +func _sqlite3WhereAddLimit(tls *libc.TLS, pWC uintptr, p uintptr) { + var iCsr, ii int32 + var pExpr, pOrderBy, pParent uintptr + _, _, _, _, _ = iCsr, ii, pExpr, pOrderBy, pParent + /* 1 -- checked by caller */ + if (*TSelect)(unsafe.Pointer(p)).FpGroupBy == uintptr(0) && (*TSelect)(unsafe.Pointer(p)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_Distinct)|libc.Int32FromInt32(SF_Aggregate)) == uint32(0) && ((*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc)).FnSrc == int32(1) && libc.Int32FromUint8((*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab)).FeTabType) == int32(TABTYP_VTAB)) { + pOrderBy = (*TSelect)(unsafe.Pointer(p)).FpOrderBy + iCsr = (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FiCursor + /* Check condition (4). Return early if it is not met. */ + ii = 0 + for { + if !(ii < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + if libc.Int32FromUint16((**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(ii)*56))).FwtFlags)&int32(TERM_CODED) != 0 { + /* This term is a vector operation that has been decomposed into + ** other, subsequent terms. It can be ignored. See tag-20220128a */ + goto _1 + } + if (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(ii)*56))).FnChild != 0 { + /* If this term has child terms, then they are also part of the + ** pWC->a[] array. So this term can be ignored, as a LIMIT clause + ** will only be added if each of the child terms passes the + ** (leftCursor==iCsr) test below. */ + goto _1 + } + if (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(ii)*56))).FleftCursor == iCsr && (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(ii)*56))).FprereqRight == uint64(0) { + goto _1 + } + /* If this term has a parent with exactly one child, and the parent will + ** be passed through to xBestIndex, then this term can be ignored. */ + if (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(ii)*56))).FiParent >= 0 { + pParent = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(ii)*56))).FiParent)*56 + if (*TWhereTerm)(unsafe.Pointer(pParent)).FleftCursor == iCsr && (*TWhereTerm)(unsafe.Pointer(pParent)).FprereqRight == uint64(0) && libc.Int32FromUint8((*TWhereTerm)(unsafe.Pointer(pParent)).FnChild) == int32(1) { + goto _1 + } + } + /* This term will not be passed through. Do not add a LIMIT clause. */ + return + goto _1 + _1: + ; + ii = ii + 1 + } + /* Check condition (5). Return early if it is not met. */ + if pOrderBy != 0 { + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(ii)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLUMN) { + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable != iCsr { + return + } + if libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(ii)*32))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_BIGNULL) != 0 { + return + } + goto _2 + _2: + ; + ii = ii + 1 + } + } + /* All conditions are met. Add the terms to the where-clause object. */ + if (*TSelect)(unsafe.Pointer(p)).FiOffset != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Compound) == uint32(0) { + _whereAddLimitExpr(tls, pWC, (*TSelect)(unsafe.Pointer(p)).FiOffset, (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpLimit)).FpRight, iCsr, int32(SQLITE_INDEX_CONSTRAINT_OFFSET)) + } + if (*TSelect)(unsafe.Pointer(p)).FiOffset == 0 || (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Compound) == uint32(0) { + _whereAddLimitExpr(tls, pWC, (*TSelect)(unsafe.Pointer(p)).FiLimit, (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpLimit)).FpLeft, iCsr, int32(SQLITE_INDEX_CONSTRAINT_LIMIT)) + } + } +} + +// C documentation +// +// /* +// ** Deallocate a WhereClause structure. The WhereClause structure +// ** itself is not freed. This routine is the inverse of +// ** sqlite3WhereClauseInit(). +// */ +func _sqlite3WhereClauseClear(tls *libc.TLS, pWC uintptr) { + var a, aLast, db uintptr + _, _, _ = a, aLast, db + db = (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb + if (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm > 0 { + a = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + aLast = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm-int32(1))*56 + for int32(1) != 0 { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(a)).FwtFlags)&int32(TERM_DYNAMIC) != 0 { + _sqlite3ExprDelete(tls, db, (*TWhereTerm)(unsafe.Pointer(a)).FpExpr) + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(a)).FwtFlags)&(libc.Int32FromInt32(TERM_ORINFO)|libc.Int32FromInt32(TERM_ANDINFO)) != 0 { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(a)).FwtFlags)&int32(TERM_ORINFO) != 0 { + _whereOrInfoDelete(tls, db, *(*uintptr)(unsafe.Pointer(a + 32))) + } else { + _whereAndInfoDelete(tls, db, *(*uintptr)(unsafe.Pointer(a + 32))) + } + } + if a == aLast { + break + } + a += 56 + } + } +} + +// C documentation +// +// /* +// ** Initialize a preallocated WhereClause structure. +// */ +func _sqlite3WhereClauseInit(tls *libc.TLS, pWC uintptr, pWInfo uintptr) { + (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo = pWInfo + (*TWhereClause)(unsafe.Pointer(pWC)).FhasOr = uint8(0) + (*TWhereClause)(unsafe.Pointer(pWC)).FpOuter = uintptr(0) + (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm = 0 + (*TWhereClause)(unsafe.Pointer(pWC)).FnBase = 0 + (*TWhereClause)(unsafe.Pointer(pWC)).FnSlot = libc.Int32FromUint64(libc.Uint64FromInt64(448) / libc.Uint64FromInt64(56)) + (*TWhereClause)(unsafe.Pointer(pWC)).Fa = pWC + 40 +} + +// C documentation +// +// /* +// ** These routines walk (recursively) an expression tree and generate +// ** a bitmask indicating which tables are used in that expression +// ** tree. +// ** +// ** sqlite3WhereExprUsage(MaskSet, Expr) -> +// ** +// ** Return a Bitmask of all tables referenced by Expr. Expr can be +// ** be NULL, in which case 0 is returned. +// ** +// ** sqlite3WhereExprUsageNN(MaskSet, Expr) -> +// ** +// ** Same as sqlite3WhereExprUsage() except that Expr must not be +// ** NULL. The "NN" suffix on the name stands for "Not Null". +// ** +// ** sqlite3WhereExprListUsage(MaskSet, ExprList) -> +// ** +// ** Return a Bitmask of all tables referenced by every expression +// ** in the expression list ExprList. ExprList can be NULL, in which +// ** case 0 is returned. +// ** +// ** sqlite3WhereExprUsageFull(MaskSet, ExprList) -> +// ** +// ** Internal use only. Called only by sqlite3WhereExprUsageNN() for +// ** complex expressions that require pushing register values onto +// ** the stack. Many calls to sqlite3WhereExprUsageNN() do not need +// ** the more complex analysis done by this routine. Hence, the +// ** computations done by this routine are broken out into a separate +// ** "no-inline" function to avoid the stack push overhead in the +// ** common case where it is not needed. +// */ +func _sqlite3WhereExprUsageFull(tls *libc.TLS, pMaskSet uintptr, p uintptr) (r TBitmask) { + var mask TBitmask + var v1 uint64 + _, _ = mask, v1 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_IF_NULL_ROW) { + v1 = _sqlite3WhereGetMask(tls, pMaskSet, (*TExpr)(unsafe.Pointer(p)).FiTable) + } else { + v1 = uint64(0) + } + mask = v1 + if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 { + mask = mask | _sqlite3WhereExprUsageNN(tls, pMaskSet, (*TExpr)(unsafe.Pointer(p)).FpLeft) + } + if (*TExpr)(unsafe.Pointer(p)).FpRight != 0 { + mask = mask | _sqlite3WhereExprUsageNN(tls, pMaskSet, (*TExpr)(unsafe.Pointer(p)).FpRight) + } else { + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + if (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) != uint32(0) { + (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = int32(1) + } + mask = mask | _exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(p + 32))) + } else { + if *(*uintptr)(unsafe.Pointer(p + 32)) != 0 { + mask = mask | _sqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(p + 32))) + } + } + } + if (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_FUNCTION) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_AGG_FUNCTION)) && (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_WinFunc) != uint32(0) { + mask = mask | _sqlite3WhereExprListUsage(tls, pMaskSet, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FpPartition) + mask = mask | _sqlite3WhereExprListUsage(tls, pMaskSet, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FpOrderBy) + mask = mask | _sqlite3WhereExprUsage(tls, pMaskSet, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64)))).FpFilter) + } + return mask +} + +// C documentation +// +// /* +// ** Search for a term in the WHERE clause that is of the form "X " +// ** where X is a reference to the iColumn of table iCur or of index pIdx +// ** if pIdx!=0 and is one of the WO_xx operator codes specified by +// ** the op parameter. Return a pointer to the term. Return 0 if not found. +// ** +// ** If pIdx!=0 then it must be one of the indexes of table iCur. +// ** Search for terms matching the iColumn-th column of pIdx +// ** rather than the iColumn-th column of table iCur. +// ** +// ** The term returned might by Y= if there is another constraint in +// ** the WHERE clause that specifies that X=Y. Any such constraints will be +// ** identified by the WO_EQUIV bit in the pTerm->eOperator field. The +// ** aiCur[]/iaColumn[] arrays hold X and all its equivalents. There are 11 +// ** slots in aiCur[]/aiColumn[] so that means we can look for X plus up to 10 +// ** other equivalent values. Hence a search for X will return if X=A1 +// ** and A1=A2 and A2=A3 and ... and A9=A10 and A10=. +// ** +// ** If there are multiple terms in the WHERE clause of the form "X " +// ** then try for the one with no dependencies on - in other words where +// ** is a constant expression of some kind. Only return entries of +// ** the form "X Y" where Y is a column in another table if no terms of +// ** the form "X " exist. If no terms with a constant RHS +// ** exist, try to return a term that does not use WO_EQUIV. +// */ +func _sqlite3WhereFindTerm(tls *libc.TLS, pWC uintptr, iCur int32, iColumn int32, notReady TBitmask, op Tu32, pIdx uintptr) (r uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var p, pResult uintptr + var _ /* scan at bp+0 */ TWhereScan + _, _ = p, pResult + pResult = uintptr(0) + p = _whereScanInit(tls, bp, pWC, iCur, iColumn, op, pIdx) + op = op & libc.Uint32FromInt32(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) + for p != 0 { + if (*TWhereTerm)(unsafe.Pointer(p)).FprereqRight¬Ready == uint64(0) { + if (*TWhereTerm)(unsafe.Pointer(p)).FprereqRight == uint64(0) && uint32((*TWhereTerm)(unsafe.Pointer(p)).FeOperator)&op != uint32(0) { + return p + } + if pResult == uintptr(0) { + pResult = p + } + } + p = _whereScanNext(tls, bp) + } + return pResult +} + +// C documentation +// +// /* +// ** While generating code for the min/max optimization, after handling +// ** the aggregate-step call to min() or max(), check to see if any +// ** additional looping is required. If the output order is such that +// ** we are certain that the correct answer has already been found, then +// ** code an OP_Goto to by pass subsequent processing. +// ** +// ** Any extra OP_Goto that is coded here is an optimization. The +// ** correct answer should be obtained regardless. This OP_Goto just +// ** makes the answer appear faster. +// */ +func _sqlite3WhereMinMaxOptEarlyOut(tls *libc.TLS, v uintptr, pWInfo uintptr) { + var i int32 + var pInner uintptr + _, _ = i, pInner + if !(int32(uint32(*(*uint8)(unsafe.Pointer(pWInfo + 68))&0x4>>2)) != 0) { + return + } + if int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == 0 { + return + } + i = libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - int32(1) + for { + if !(i >= 0) { + break + } + pInner = pWInfo + 856 + uintptr(i)*112 + if (*TWhereLoop)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pInner)).FpWLoop)).FwsFlags&uint32(WHERE_COLUMN_IN) != uint32(0) { + _sqlite3VdbeGoto(tls, v, (*TWhereLevel)(unsafe.Pointer(pInner)).FaddrNxt) + return + } + goto _1 + _1: + ; + i = i - 1 + } + _sqlite3VdbeGoto(tls, v, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak) +} + +// C documentation +// +// /* +// ** In the ORDER BY LIMIT optimization, if the inner-most loop is known +// ** to emit rows in increasing order, and if the last row emitted by the +// ** inner-most loop did not fit within the sorter, then we can skip all +// ** subsequent rows for the current iteration of the inner loop (because they +// ** will not fit in the sorter either) and continue with the second inner +// ** loop - the loop immediately outside the inner-most. +// ** +// ** When a row does not fit in the sorter (because the sorter already +// ** holds LIMIT+OFFSET rows that are smaller), then a jump is made to the +// ** label returned by this function. +// ** +// ** If the ORDER BY LIMIT optimization applies, the jump destination should +// ** be the continuation for the second-inner-most loop. If the ORDER BY +// ** LIMIT optimization does not apply, then the jump destination should +// ** be the continuation for the inner-most loop. +// ** +// ** It is always safe for this routine to return the continuation of the +// ** inner-most loop, in the sense that a correct answer will result. +// ** Returning the continuation the second inner loop is an optimization +// ** that might make the code run a little faster, but should not change +// ** the final answer. +// */ +func _sqlite3WhereOrderByLimitOptLabel(tls *libc.TLS, pWInfo uintptr) (r int32) { + var pInner uintptr + var v1 int32 + _, _ = pInner, v1 + if !(int32(uint32(*(*uint8)(unsafe.Pointer(pWInfo + 68))&0x4>>2)) != 0) { + /* The ORDER BY LIMIT optimization does not apply. Jump to the + ** continuation of the inner-most loop. */ + return (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiContinue + } + pInner = pWInfo + 856 + uintptr(libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-int32(1))*112 + if (*TWhereLevel)(unsafe.Pointer(pInner)).FpRJ != 0 { + v1 = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiContinue + } else { + v1 = (*TWhereLevel)(unsafe.Pointer(pInner)).FaddrNxt + } + return v1 +} + +// C documentation +// +// /* +// ** Register those built-in window functions that are not also aggregates. +// */ +func _sqlite3WindowFunctions(tls *libc.TLS) { + _sqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&_aWindowFuncs)), libc.Int32FromUint64(libc.Uint64FromInt64(1080)/libc.Uint64FromInt64(72))) +} + +// C documentation +// +// /* +// ** Create and return a deep copy of the object passed as the second +// ** argument. If an OOM condition is encountered, NULL is returned +// ** and the db->mallocFailed flag set. +// */ +func _sqlite3WithDup(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) { + var i int32 + var nByte Tsqlite3_int64 + var pRet uintptr + _, _, _ = i, nByte, pRet + pRet = uintptr(0) + if p != 0 { + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+16) + libc.Uint64FromInt32((*TWith)(unsafe.Pointer(p)).FnCte)*libc.Uint64FromInt64(48)) + pRet = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte)) + if pRet != 0 { + (*TWith)(unsafe.Pointer(pRet)).FnCte = (*TWith)(unsafe.Pointer(p)).FnCte + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer(p)).FnCte) { + break + } + (*(*TCte)(unsafe.Pointer(pRet + 16 + uintptr(i)*48))).FpSelect = _sqlite3SelectDup(tls, db, (*(*TCte)(unsafe.Pointer(p + 16 + uintptr(i)*48))).FpSelect, 0) + (*(*TCte)(unsafe.Pointer(pRet + 16 + uintptr(i)*48))).FpCols = _sqlite3ExprListDup(tls, db, (*(*TCte)(unsafe.Pointer(p + 16 + uintptr(i)*48))).FpCols, 0) + (*(*TCte)(unsafe.Pointer(pRet + 16 + uintptr(i)*48))).FzName = _sqlite3DbStrDup(tls, db, (*(*TCte)(unsafe.Pointer(p + 16 + uintptr(i)*48))).FzName) + (*(*TCte)(unsafe.Pointer(pRet + 16 + uintptr(i)*48))).FeM10d = (*(*TCte)(unsafe.Pointer(p + 16 + uintptr(i)*48))).FeM10d + goto _1 + _1: + ; + i = i + 1 + } + } + } + return pRet +} + +// C documentation +// +// /* +// ** This routine implements a busy callback that sleeps and tries +// ** again until a timeout value is reached. The timeout value is +// ** an integer number of milliseconds passed in as the first +// ** argument. +// ** +// ** Return non-zero to retry the lock. Return zero to stop trying +// ** and cause SQLite to return SQLITE_BUSY. +// */ +func _sqliteDefaultBusyCallback(tls *libc.TLS, ptr uintptr, count int32) (r int32) { + var db uintptr + var delay, prior, tmout int32 + _, _, _, _ = db, delay, prior, tmout + db = ptr + tmout = (*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout + if count < libc.Int32FromUint64(libc.Uint64FromInt64(12)/libc.Uint64FromInt64(1)) { + delay = libc.Int32FromUint8(_delays[count]) + prior = libc.Int32FromUint8(_totals[count]) + } else { + delay = libc.Int32FromUint8(_delays[libc.Int32FromUint64(libc.Uint64FromInt64(12)/libc.Uint64FromInt64(1))-libc.Int32FromInt32(1)]) + prior = libc.Int32FromUint8(_totals[libc.Int32FromUint64(libc.Uint64FromInt64(12)/libc.Uint64FromInt64(1))-libc.Int32FromInt32(1)]) + delay*(count-(libc.Int32FromUint64(libc.Uint64FromInt64(12)/libc.Uint64FromInt64(1))-libc.Int32FromInt32(1))) + } + if prior+delay > tmout { + delay = tmout - prior + if delay <= 0 { + return 0 + } + } + _sqlite3OsSleep(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, delay*int32(1000)) + return int32(1) +} + +// C documentation +// +// /* +// ** Clear the column names from every VIEW in database idx. +// */ +func _sqliteViewResetAll(tls *libc.TLS, db uintptr, idx int32) { + var i, pTab, v2 uintptr + _, _, _ = i, pTab, v2 + if !(libc.Int32FromUint16((*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(idx)*32))).FpSchema)).FschemaFlags)&libc.Int32FromInt32(DB_UnresetViews) == libc.Int32FromInt32(DB_UnresetViews)) { + return + } + i = (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(idx)*32))).FpSchema + 8)).Ffirst + for { + if !(i != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(i)).Fdata + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3DeleteColumnNames(tls, db, pTab) + } + goto _1 + _1: + ; + i = (*THashElem)(unsafe.Pointer(i)).Fnext + } + v2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(idx)*32))).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) & ^libc.Int32FromInt32(DB_UnresetViews)) +} + +// C documentation +// +// /* +// ** Attempt to extract a value from pExpr and use it to construct *ppVal. +// ** +// ** If pAlloc is not NULL, then an UnpackedRecord object is created for +// ** pAlloc if one does not exist and the new value is added to the +// ** UnpackedRecord object. +// ** +// ** A value is extracted in the following cases: +// ** +// ** * (pExpr==0). In this case the value is assumed to be an SQL NULL, +// ** +// ** * The expression is a bound variable, and this is a reprepare, or +// ** +// ** * The expression is a literal value. +// ** +// ** On success, *ppVal is made to point to the extracted value. The caller +// ** is responsible for ensuring that the value is eventually freed. +// */ +func _stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity Tu8, pAlloc uintptr, ppVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, v, v1 uintptr + var iBindVar, rc int32 + var _ /* pVal at bp+0 */ uintptr + _, _, _, _, _ = db, iBindVar, rc, v, v1 + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + /* Skip over any TK_COLLATE nodes */ + pExpr = _sqlite3ExprSkipCollate(tls, pExpr) + if !(pExpr != 0) { + **(**uintptr)(__ccgo_up(bp)) = _valueNew(tls, db, pAlloc) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + _sqlite3VdbeMemSetNull(tls, **(**uintptr)(__ccgo_up(bp))) + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_VARIABLE) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_EnableQPSG) == uint64(0) { + iBindVar = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + _sqlite3VdbeSetVarmask(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, iBindVar) + v1 = (*TParse)(unsafe.Pointer(pParse)).FpReprepare + v = v1 + if v1 != uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = _valueNew(tls, db, pAlloc) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + rc = _sqlite3VdbeMemCopy(tls, **(**uintptr)(__ccgo_up(bp)), (*TVdbe)(unsafe.Pointer(v)).FaVar+uintptr(iBindVar-int32(1))*56) + _sqlite3ValueApplyAffinity(tls, **(**uintptr)(__ccgo_up(bp)), affinity, (*Tsqlite3)(unsafe.Pointer(db)).Fenc) + (*Tsqlite3_value)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fdb = (*TParse)(unsafe.Pointer(pParse)).Fdb + } + } + } else { + rc = _valueFromExpr(tls, db, pExpr, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, affinity, bp, pAlloc) + } + } + **(**uintptr)(__ccgo_up(ppVal)) = **(**uintptr)(__ccgo_up(bp)) + return rc +} + +// C documentation +// +// /* +// ** Compute the best query strategy and return the result in idxNum. +// ** +// ** idxNum-Bit Meaning +// ** ---------- ---------------------------------------------- +// ** 0x01 There is a schema=? term in the WHERE clause +// ** 0x02 There is a name=? term in the WHERE clause +// ** 0x04 There is an aggregate=? term in the WHERE clause +// ** 0x08 Output should be ordered by name and path +// */ +func _statBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + var i, iAgg, iName, iSchema, v2 int32 + _, _, _, _, _ = i, iAgg, iName, iSchema, v2 + iSchema = -int32(1) + iName = -int32(1) + iAgg = -int32(1) + _ = tab + /* Look for a valid schema=? constraint. If found, change the idxNum to + ** 1 and request the value of that constraint be sent to xFilter. And + ** lower the cost estimate to encourage the constrained version to be + ** used. + */ + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + if libc.Int32FromUint8((**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12))).Fop) != int32(SQLITE_INDEX_CONSTRAINT_EQ) { + goto _1 + } + if libc.Int32FromUint8((**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12))).Fusable) == 0 { + /* Force DBSTAT table should always be the right-most table in a join */ + return int32(SQLITE_CONSTRAINT) + } + switch (**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12))).FiColumn { + case 0: /* name */ + iName = i + case int32(10): /* schema */ + iSchema = i + case int32(11): /* aggregate */ + iAgg = i + break + } + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + if iSchema >= 0 { + i = i + 1 + v2 = i + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iSchema)*8))).FargvIndex = v2 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iSchema)*8))).Fomit = uint8(1) + **(**int32)(__ccgo_up(pIdxInfo + 40)) |= int32(0x01) + } + if iName >= 0 { + i = i + 1 + v2 = i + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iName)*8))).FargvIndex = v2 + **(**int32)(__ccgo_up(pIdxInfo + 40)) |= int32(0x02) + } + if iAgg >= 0 { + i = i + 1 + v2 = i + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iAgg)*8))).FargvIndex = v2 + **(**int32)(__ccgo_up(pIdxInfo + 40)) |= int32(0x04) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1) + /* Records are always returned in ascending order of (name, path). + ** If this will satisfy the client, set the orderByConsumed flag so that + ** SQLite does not do an external sort. + */ + if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == int32(1) && (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).FiColumn == 0 && libc.Int32FromUint8((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).Fdesc) == 0 || (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == int32(2) && (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).FiColumn == 0 && libc.Int32FromUint8((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).Fdesc) == 0 && (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy + 1*8))).FiColumn == int32(1) && libc.Int32FromUint8((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy + 1*8))).Fdesc) == 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = int32(1) + **(**int32)(__ccgo_up(pIdxInfo + 40)) |= int32(0x08) + } + **(**int32)(__ccgo_up(pIdxInfo + 80)) |= int32(SQLITE_INDEX_SCAN_HEX) + return SQLITE_OK +} + +func _statColumn(tls *libc.TLS, pCursor uintptr, ctx uintptr, i int32) (r int32) { + var db, pCsr uintptr + var iDb int32 + _, _, _ = db, iDb, pCsr + pCsr = pCursor + switch i { + case 0: /* name */ + Xsqlite3_result_text(tls, ctx, (*TStatCursor)(unsafe.Pointer(pCsr)).FzName, -int32(1), uintptr(-libc.Int32FromInt32(1))) + case int32(1): /* path */ + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + Xsqlite3_result_text(tls, ctx, (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath, -int32(1), uintptr(-libc.Int32FromInt32(1))) + } + case int32(2): /* pageno */ + if (*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0 { + Xsqlite3_result_int64(tls, ctx, int64((*TStatCursor)(unsafe.Pointer(pCsr)).FnPage)) + } else { + Xsqlite3_result_int64(tls, ctx, libc.Int64FromUint32((*TStatCursor)(unsafe.Pointer(pCsr)).FiPageno)) + } + case int32(3): /* pagetype */ + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + Xsqlite3_result_text(tls, ctx, (*TStatCursor)(unsafe.Pointer(pCsr)).FzPagetype, -int32(1), libc.UintptrFromInt32(0)) + } + case int32(4): /* ncell */ + Xsqlite3_result_int64(tls, ctx, int64((*TStatCursor)(unsafe.Pointer(pCsr)).FnCell)) + case int32(5): /* payload */ + Xsqlite3_result_int64(tls, ctx, (*TStatCursor)(unsafe.Pointer(pCsr)).FnPayload) + case int32(6): /* unused */ + Xsqlite3_result_int64(tls, ctx, (*TStatCursor)(unsafe.Pointer(pCsr)).FnUnused) + case int32(7): /* mx_payload */ + Xsqlite3_result_int64(tls, ctx, int64((*TStatCursor)(unsafe.Pointer(pCsr)).FnMxPayload)) + case int32(8): /* pgoffset */ + if !((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg != 0) { + Xsqlite3_result_int64(tls, ctx, (*TStatCursor)(unsafe.Pointer(pCsr)).FiOffset) + } + case int32(9): /* pgsize */ + Xsqlite3_result_int64(tls, ctx, (*TStatCursor)(unsafe.Pointer(pCsr)).FszPage) + case int32(10): /* schema */ + db = Xsqlite3_context_db_handle(tls, ctx) + iDb = (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb + Xsqlite3_result_text(tls, ctx, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, -int32(1), libc.UintptrFromInt32(0)) + default: /* aggregate */ + Xsqlite3_result_int(tls, ctx, libc.Int32FromUint8((*TStatCursor)(unsafe.Pointer(pCsr)).FisAgg)) + break + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Implementation of the stat_init(N,K,C,L) SQL function. The four parameters +// ** are: +// ** N: The number of columns in the index including the rowid/pk (note 1) +// ** K: The number of columns in the index excluding the rowid/pk. +// ** C: Estimated number of rows in the index +// ** L: A limit on the number of rows to scan, or 0 for no-limit +// ** +// ** Note 1: In the special case of the covering index that implements a +// ** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the +// ** total number of columns in the table. +// ** +// ** For indexes on ordinary rowid tables, N==K+1. But for indexes on +// ** WITHOUT ROWID tables, N=K+P where P is the number of columns in the +// ** PRIMARY KEY of the table. The covering index that implements the +// ** original WITHOUT ROWID table as N==K as a special case. +// ** +// ** This routine allocates the StatAccum object in heap memory. The return +// ** value is a pointer to the StatAccum object. The datatype of the +// ** return value is BLOB, but it is really just a pointer to the StatAccum +// ** object. +// */ +func _statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var db, p, pSpace uintptr + var i, mxSample, nCol, nColUp, nKeyCol, v1 int32 + var n Ti64 + _, _, _, _, _, _, _, _, _, _ = db, i, mxSample, n, nCol, nColUp, nKeyCol, p, pSpace, v1 /* Bytes of space to allocate */ + db = Xsqlite3_context_db_handle(tls, context) + if (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) { + v1 = int32(SQLITE_STAT4_SAMPLES) + } else { + v1 = 0 + } /* Database connection */ + /* Maximum number of samples. 0 if STAT4 data is not collected */ + mxSample = v1 + /* Decode the three function arguments */ + _ = argc + nCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv))) + nColUp = nCol + nKeyCol = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + /* Allocate the space required for the StatAccum object */ + n = libc.Int64FromUint64(uint64(136) + uint64(8)*libc.Uint64FromInt32(nColUp)) /* StatAccum.anDLt */ + n = libc.Int64FromUint64(uint64(n) + uint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(nColUp))) /* StatAccum.anEq */ + if mxSample != 0 { + n = libc.Int64FromUint64(uint64(n) + uint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(nColUp)+libc.Uint64FromInt64(48)*libc.Uint64FromInt32(nCol+mxSample)+libc.Uint64FromInt64(8)*libc.Uint64FromInt32(3)*libc.Uint64FromInt32(nColUp)*libc.Uint64FromInt32(nCol+mxSample))) + } + p = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(n)) + if p == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + (*TStatAccum)(unsafe.Pointer(p)).Fdb = db + (*TStatAccum)(unsafe.Pointer(p)).FnEst = libc.Uint64FromInt64(Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + (*TStatAccum)(unsafe.Pointer(p)).FnRow = uint64(0) + (*TStatAccum)(unsafe.Pointer(p)).FnLimit = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + (*TStatAccum)(unsafe.Pointer(p)).FnCol = nCol + (*TStatAccum)(unsafe.Pointer(p)).FnKeyCol = nKeyCol + (*TStatAccum)(unsafe.Pointer(p)).FnSkipAhead = uint8(0) + (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt = p + 1*136 + (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq = (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(nColUp)*8 + if (*TStatAccum)(unsafe.Pointer(p)).FnLimit == 0 { + v1 = mxSample + } else { + v1 = 0 + } + (*TStatAccum)(unsafe.Pointer(p)).FmxSample = v1 + if mxSample != 0 { /* Used to iterate through p->aSample[] */ + (*TStatAccum)(unsafe.Pointer(p)).FiGet = -int32(1) + (*TStatAccum)(unsafe.Pointer(p)).FnPSample = (*TStatAccum)(unsafe.Pointer(p)).FnEst/libc.Uint64FromInt32(mxSample/libc.Int32FromInt32(3)+libc.Int32FromInt32(1)) + libc.Uint64FromInt32(1) + (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt = (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(nColUp)*8 + (*TStatAccum)(unsafe.Pointer(p)).FiPrn = uint32(0x689e962d)*libc.Uint32FromInt32(nCol) ^ uint32(0xd0944565)*libc.Uint32FromInt32(Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + /* Set up the StatAccum.a[] and aBest[] arrays */ + (*TStatAccum)(unsafe.Pointer(p)).Fa = (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt + uintptr(nColUp)*8 + (*TStatAccum)(unsafe.Pointer(p)).FaBest = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(mxSample)*48 + pSpace = (*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(mxSample+nCol)*48 + i = 0 + for { + if !(i < mxSample+nCol) { + break + } + (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48))).FanEq = pSpace + pSpace = pSpace + uintptr(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(nColUp)) + (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48))).FanLt = pSpace + pSpace = pSpace + uintptr(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(nColUp)) + (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48))).FanDLt = pSpace + pSpace = pSpace + uintptr(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(nColUp)) + goto _3 + _3: + ; + i = i + 1 + } + i = 0 + for { + if !(i < nCol) { + break + } + (**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).FaBest + uintptr(i)*48))).FiCol = i + goto _4 + _4: + ; + i = i + 1 + } + } + /* Return a pointer to the allocated object to the caller. Note that + ** only the pointer (the 2nd parameter) matters. The size of the object + ** (given by the 3rd parameter) is never used and can be any positive + ** value. */ + Xsqlite3_result_blob(tls, context, p, int32(136), __ccgo_fp(_statAccumDestructor)) +} + +// C documentation +// +// /* +// ** Implementation of the stat_push SQL function: stat_push(P,C,R) +// ** Arguments: +// ** +// ** P Pointer to the StatAccum object created by stat_init() +// ** C Index of left-most column to differ from previous row +// ** R Rowid for the current row. Might be a key record for +// ** WITHOUT ROWID tables. +// ** +// ** The purpose of this routine is to collect statistical data and/or +// ** samples from the index being analyzed into the StatAccum object. +// ** The stat_get() SQL function will be used afterwards to +// ** retrieve the information gathered. +// ** +// ** This SQL function usually returns NULL, but might return an integer +// ** if it wants the byte-code to do special processing. +// ** +// ** The R parameter is only used for STAT4 +// */ +func _statPush(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var i, iChng int32 + var nLt TtRowcnt + var p uintptr + var v4 Tu32 + _, _, _, _, _ = i, iChng, nLt, p, v4 + /* The three function arguments */ + p = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + iChng = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + _ = argc + _ = context + if (*TStatAccum)(unsafe.Pointer(p)).FnRow == uint64(0) { + /* This is the first call to this function. Do initialization. */ + i = 0 + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FnCol) { + break + } + **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8)) = uint64(1) + goto _1 + _1: + ; + i = i + 1 + } + } else { + /* Second and subsequent calls get processed here */ + if (*TStatAccum)(unsafe.Pointer(p)).FmxSample != 0 { + _samplePushPrevious(tls, p, iChng) + } + /* Update anDLt[], anLt[] and anEq[] to reflect the values that apply + ** to the current row of the index. */ + i = 0 + for { + if !(i < iChng) { + break + } + **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8)) = **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8)) + 1 + goto _2 + _2: + ; + i = i + 1 + } + i = iChng + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FnCol) { + break + } + **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(i)*8)) = **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(i)*8)) + 1 + if (*TStatAccum)(unsafe.Pointer(p)).FmxSample != 0 { + **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt + uintptr(i)*8)) += **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8)) + } + **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8)) = uint64(1) + goto _3 + _3: + ; + i = i + 1 + } + } + (*TStatAccum)(unsafe.Pointer(p)).FnRow = (*TStatAccum)(unsafe.Pointer(p)).FnRow + 1 + if (*TStatAccum)(unsafe.Pointer(p)).FmxSample != 0 { + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) == int32(SQLITE_INTEGER) { + _sampleSetRowidInt64(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, p+40, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + } else { + _sampleSetRowid(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, p+40, Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + 2*8))), Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + } + v4 = (*TStatAccum)(unsafe.Pointer(p)).FiPrn*libc.Uint32FromInt32(1103515245) + libc.Uint32FromInt32(12345) + (*TStatAccum)(unsafe.Pointer(p)).FiPrn = v4 + (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FiHash = v4 + nLt = **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt + uintptr((*TStatAccum)(unsafe.Pointer(p)).FnCol-int32(1))*8)) + /* Check if this is to be a periodic sample. If so, add it. */ + if nLt/(*TStatAccum)(unsafe.Pointer(p)).FnPSample != (nLt+uint64(1))/(*TStatAccum)(unsafe.Pointer(p)).FnPSample { + (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FisPSample = uint8(1) + (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FiCol = 0 + _sampleInsert(tls, p, p+40, (*TStatAccum)(unsafe.Pointer(p)).FnCol-int32(1)) + (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FisPSample = uint8(0) + } + /* Update the aBest[] array. */ + i = 0 + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FnCol-int32(1)) { + break + } + (*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FiCol = i + if i >= iChng || _sampleIsBetterPost(tls, p, p+40, (*TStatAccum)(unsafe.Pointer(p)).FaBest+uintptr(i)*48) != 0 { + _sampleCopy(tls, p, (*TStatAccum)(unsafe.Pointer(p)).FaBest+uintptr(i)*48, p+40) + } + goto _5 + _5: + ; + i = i + 1 + } + } else { + if (*TStatAccum)(unsafe.Pointer(p)).FnLimit != 0 && (*TStatAccum)(unsafe.Pointer(p)).FnRow > libc.Uint64FromInt32((*TStatAccum)(unsafe.Pointer(p)).FnLimit)*libc.Uint64FromInt32(libc.Int32FromUint8((*TStatAccum)(unsafe.Pointer(p)).FnSkipAhead)+libc.Int32FromInt32(1)) { + (*TStatAccum)(unsafe.Pointer(p)).FnSkipAhead = (*TStatAccum)(unsafe.Pointer(p)).FnSkipAhead + 1 + Xsqlite3_result_int(tls, context, libc.BoolInt32(**(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt)) > uint64(0))) + } + } +} + +func _statResetCsr(tls *libc.TLS, pCsr uintptr) { + var i int32 + _ = i + /* In some circumstances, specifically if an OOM has occurred, the call + ** to sqlite3_reset() may cause the pager to be reset (emptied). It is + ** important that statClearPage() is called to free any page refs before + ** this happens. dbsqlfuzz 9ed3e4e3816219d3509d711636c38542bf3f40b1. */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(2048)/libc.Uint64FromInt64(64))) { + break + } + _statClearPage(tls, pCsr+24+uintptr(i)*64) + Xsqlite3_free(tls, (**(**TStatPage)(__ccgo_up(pCsr + 24 + uintptr(i)*64))).FaPg) + (**(**TStatPage)(__ccgo_up(pCsr + 24 + uintptr(i)*64))).FaPg = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_reset(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiPage = 0 + Xsqlite3_free(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath) + (*TStatCursor)(unsafe.Pointer(pCsr)).FzPath = uintptr(0) + (*TStatCursor)(unsafe.Pointer(pCsr)).FisEof = uint8(0) +} + +// C documentation +// +// /* +// ** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on +// ** the current value of pCsr->iPageno. +// */ +func _statSizeAndOffset(tls *libc.TLS, pCsr uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var fd, pBt, pPager, pTab uintptr + var _ /* x at bp+0 */ [2]Tsqlite3_int64 + _, _, _, _ = fd, pBt, pPager, pTab + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCsr)).FpVtab + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TStatTable)(unsafe.Pointer(pTab)).Fdb)).FaDb + uintptr((*TStatTable)(unsafe.Pointer(pTab)).FiDb)*32))).FpBt + pPager = _sqlite3BtreePager(tls, pBt) + /* If connected to a ZIPVFS backend, find the page size and + ** offset from ZIPVFS. + */ + fd = _sqlite3PagerFile(tls, pPager) + (**(**[2]Tsqlite3_int64)(__ccgo_up(bp)))[0] = libc.Int64FromUint32((*TStatCursor)(unsafe.Pointer(pCsr)).FiPageno) + if _sqlite3OsFileControl(tls, fd, int32(230440), bp) == SQLITE_OK { + (*TStatCursor)(unsafe.Pointer(pCsr)).FiOffset = (**(**[2]Tsqlite3_int64)(__ccgo_up(bp)))[0] + **(**Ti64)(__ccgo_up(pCsr + 2144)) += (**(**[2]Tsqlite3_int64)(__ccgo_up(bp)))[int32(1)] + } else { + /* Not ZIPVFS: The default page size and offset */ + **(**Ti64)(__ccgo_up(pCsr + 2144)) += int64(_sqlite3BtreeGetPageSize(tls, pBt)) + (*TStatCursor)(unsafe.Pointer(pCsr)).FiOffset = (*TStatCursor)(unsafe.Pointer(pCsr)).FszPage * libc.Int64FromUint32((*TStatCursor)(unsafe.Pointer(pCsr)).FiPageno-libc.Uint32FromInt32(1)) + } +} + +// C documentation +// +// /* +// ** Implementation of the substr() function. +// ** +// ** substr(x,p1,p2) returns p2 characters of x[] beginning with p1. +// ** p1 is 1-indexed. So substr(x,1,1) returns the first character +// ** of x. If x is text, then we actually count UTF-8 characters. +// ** If x is a blob, then we count bytes. +// ** +// ** If p1 is negative, then we begin abs(p1) from the end of x[]. +// ** +// ** If p2 is negative, return the p2 characters preceding p1. +// */ +func _substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var len1, p0type int32 + var p1, p2, v6 Ti64 + var z, z2, v2 uintptr + _, _, _, _, _, _, _, _ = len1, p0type, p1, p2, z, z2, v2, v6 + p0type = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) + p1 = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if p0type == int32(SQLITE_BLOB) { + len1 = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + z = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(argv))) + if z == uintptr(0) { + return + } + } else { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if z == uintptr(0) { + return + } + len1 = 0 + if p1 < 0 { + z2 = z + for { + if !(**(**uint8)(__ccgo_up(z2)) != 0) { + break + } + v2 = z2 + z2 = z2 + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v2))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z2)))&int32(0xc0) == int32(0x80) { + z2 = z2 + 1 + } + } + goto _1 + _1: + ; + len1 = len1 + 1 + } + } + } + if argc == int32(3) { + p2 = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + if p2 == 0 && Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) == int32(SQLITE_NULL) { + return + } + } else { + p2 = int64(**(**int32)(__ccgo_up(Xsqlite3_context_db_handle(tls, context) + 136))) + } + if p1 == 0 { + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) == int32(SQLITE_NULL) { + return + } + } + if p1 < 0 { + p1 = p1 + int64(len1) + if p1 < 0 { + if p2 < 0 { + p2 = 0 + } else { + p2 = p2 + p1 + } + p1 = 0 + } + } else { + if p1 > 0 { + p1 = p1 - 1 + } else { + if p2 > 0 { + p2 = p2 - 1 + } + } + } + if p2 < 0 { + if p2 < -p1 { + p2 = p1 + } else { + p2 = -p2 + } + p1 = p1 - p2 + } + if p0type != int32(SQLITE_BLOB) { + for **(**uint8)(__ccgo_up(z)) != 0 && p1 != 0 { + v2 = z + z = z + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v2))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { + z = z + 1 + } + } + p1 = p1 - 1 + } + z2 = z + for { + if !(**(**uint8)(__ccgo_up(z2)) != 0 && p2 != 0) { + break + } + v2 = z2 + z2 = z2 + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v2))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z2)))&int32(0xc0) == int32(0x80) { + z2 = z2 + 1 + } + } + goto _4 + _4: + ; + p2 = p2 - 1 + } + Xsqlite3_result_text64(tls, context, z, libc.Uint64FromInt64(int64(z2)-int64(z)), uintptr(-libc.Int32FromInt32(1)), uint8(SQLITE_UTF8)) + } else { + if p1 >= int64(len1) { + v6 = libc.Int64FromInt32(0) + p2 = v6 + p1 = v6 + } else { + if p2 > int64(len1)-p1 { + p2 = int64(len1) - p1 + } + } + Xsqlite3_result_blob64(tls, context, z+uintptr(p1), libc.Uint64FromInt64(p2), uintptr(-libc.Int32FromInt32(1))) + } +} + +// C documentation +// +// /* +// ** Search the tables iStart..iEnd (inclusive) in pSrc, looking for a +// ** table that has a column named zCol. The search is left-to-right. +// ** The first match found is returned. +// ** +// ** When found, set *piTab and *piCol to the table index and column index +// ** of the matching column and return TRUE. +// ** +// ** If not found, return FALSE. +// */ +func _tableAndColumnIndex(tls *libc.TLS, pSrc uintptr, iStart int32, iEnd int32, zCol uintptr, piTab uintptr, piCol uintptr, bIgnoreHidden int32) (r int32) { + var i, iCol int32 + _, _ = i, iCol /* Index of column matching zCol */ + /* Both or neither are NULL */ + i = iStart + for { + if !(i <= iEnd) { + break + } + iCol = _sqlite3ColumnIndex(tls, (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FpSTab, zCol) + if iCol >= 0 && (bIgnoreHidden == 0 || libc.BoolInt32(libc.Int32FromUint16((*TColumn)(unsafe.Pointer((*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FpSTab)).FaCol+uintptr(iCol)*16)).FcolFlags)&int32(COLFLAG_HIDDEN) != 0) == 0) { + if piTab != 0 { + _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(i)*80, iCol) + **(**int32)(__ccgo_up(piTab)) = i + **(**int32)(__ccgo_up(piCol)) = iCol + } + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** If the pBase expression originated in the ON or USING clause of +// ** a join, then transfer the appropriate markings over to derived. +// */ +func _transferJoinMarkings(tls *libc.TLS, pDerived uintptr, pBase uintptr) { + if pDerived != 0 && (*TExpr)(unsafe.Pointer(pBase)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + **(**Tu32)(__ccgo_up(pDerived + 4)) |= (*TExpr)(unsafe.Pointer(pBase)).Fflags & libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) + *(*int32)(unsafe.Pointer(pDerived + 52)) = *(*int32)(unsafe.Pointer(pBase + 52)) + } +} + +// C documentation +// +// /* +// ** Convert OP_Column opcodes to OP_Copy in previously generated code. +// ** +// ** This routine runs over generated VDBE code and translates OP_Column +// ** opcodes into OP_Copy when the table is being accessed via co-routine +// ** instead of via table lookup. +// ** +// ** If the iAutoidxCur is not zero, then any OP_Rowid instructions on +// ** cursor iTabCur are transformed into OP_Sequence opcode for the +// ** iAutoidxCur cursor, in order to generate unique rowids for the +// ** automatic index being generated. +// */ +func _translateColumnToCopy(tls *libc.TLS, pParse uintptr, iStart int32, iTabCur int32, iRegister int32, iAutoidxCur int32) { + var iEnd int32 + var pOp, v uintptr + _, _, _ = iEnd, pOp, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pOp = _sqlite3VdbeGetOp(tls, v, iStart) + iEnd = _sqlite3VdbeCurrentAddr(tls, v) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return + } + for { + if !(iStart < iEnd) { + break + } + if (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 != iTabCur { + goto _1 + } + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Column) { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_Copy) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 + iRegister + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 = (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 = 0 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp5 = uint16(2) /* Cause the MEM_Subtype flag to be cleared */ + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Rowid) { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_Sequence) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = iAutoidxCur + } + } + goto _1 + _1: + ; + iStart = iStart + 1 + pOp += 24 + } +} + +/* +** Two routines for printing the content of an sqlite3_index_info +** structure. Used for testing and debugging only. If neither +** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines +** are no-ops. + */ + +// C documentation +// +// /* +// ** Implementation of the TRIM(), LTRIM(), and RTRIM() functions. +// ** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both. +// */ +func _trimFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var aLen, azChar, z, zCharSet, zIn, v1 uintptr + var flags, i, nChar int32 + var len1, len11, nIn uint32 + _, _, _, _, _, _, _, _, _, _, _, _ = aLen, azChar, flags, i, len1, len11, nChar, nIn, z, zCharSet, zIn, v1 /* Loop counter */ + aLen = uintptr(0) /* Length of each character in zCharSet */ + azChar = uintptr(0) /* Number of characters in zCharSet */ + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + return + } + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn == uintptr(0) { + return + } + nIn = libc.Uint32FromInt32(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv)))) + if argc == int32(1) { + nChar = int32(1) + aLen = uintptr(unsafe.Pointer(&_lenOne)) + azChar = uintptr(unsafe.Pointer(&_azOne)) + zCharSet = uintptr(0) + } else { + v1 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + zCharSet = v1 + if v1 == uintptr(0) { + return + } else { + z = zCharSet + nChar = libc.Int32FromInt32(0) + for { + if !(**(**uint8)(__ccgo_up(z)) != 0) { + break + } + v1 = z + z = z + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v1))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { + z = z + 1 + } + } + goto _2 + _2: + ; + nChar = nChar + 1 + } + if nChar > 0 { + azChar = _contextMalloc(tls, context, libc.Int64FromUint64(libc.Uint64FromInt64(int64(nChar))*uint64(libc.Uint64FromInt64(8)+libc.Uint64FromInt64(4)))) + if azChar == uintptr(0) { + return + } + aLen = azChar + uintptr(nChar)*8 + z = zCharSet + nChar = libc.Int32FromInt32(0) + for { + if !(**(**uint8)(__ccgo_up(z)) != 0) { + break + } + **(**uintptr)(__ccgo_up(azChar + uintptr(nChar)*8)) = z + v1 = z + z = z + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v1))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { + z = z + 1 + } + } + **(**uint32)(__ccgo_up(aLen + uintptr(nChar)*4)) = libc.Uint32FromInt64(int64(z) - int64(**(**uintptr)(__ccgo_up(azChar + uintptr(nChar)*8)))) + goto _4 + _4: + ; + nChar = nChar + 1 + } + } + } + } + if nChar > 0 { + flags = int32(int64(Xsqlite3_user_data(tls, context))) + if flags&int32(1) != 0 { + for nIn > uint32(0) { + len1 = uint32(0) + i = 0 + for { + if !(i < nChar) { + break + } + len1 = **(**uint32)(__ccgo_up(aLen + uintptr(i)*4)) + if len1 <= nIn && libc.Xmemcmp(tls, zIn, **(**uintptr)(__ccgo_up(azChar + uintptr(i)*8)), uint64(len1)) == 0 { + break + } + goto _6 + _6: + ; + i = i + 1 + } + if i >= nChar { + break + } + zIn = zIn + uintptr(len1) + nIn = nIn - len1 + } + } + if flags&int32(2) != 0 { + for nIn > uint32(0) { + len11 = uint32(0) + i = 0 + for { + if !(i < nChar) { + break + } + len11 = **(**uint32)(__ccgo_up(aLen + uintptr(i)*4)) + if len11 <= nIn && libc.Xmemcmp(tls, zIn+uintptr(nIn-len11), **(**uintptr)(__ccgo_up(azChar + uintptr(i)*8)), uint64(len11)) == 0 { + break + } + goto _7 + _7: + ; + i = i + 1 + } + if i >= nChar { + break + } + nIn = nIn - len11 + } + } + if zCharSet != 0 { + Xsqlite3_free(tls, azChar) + } + } + Xsqlite3_result_text(tls, context, zIn, libc.Int32FromUint32(nIn), uintptr(-libc.Int32FromInt32(1))) +} + +// C documentation +// +// /* +// ** Return the value of a system call. Return NULL if zName is not a +// ** recognized system call name. NULL is also returned if the system call +// ** is currently undefined. +// */ +func _unixGetSystemCall(tls *libc.TLS, pNotUsed uintptr, zName uintptr) (r Tsqlite3_syscall_ptr) { + var i uint32 + _ = i + _ = pNotUsed + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(696)/libc.Uint64FromInt64(24)) { + break + } + if libc.Xstrcmp(tls, zName, _aSyscall[i].FzName) == 0 { + return _aSyscall[i].FpCurrent + } + goto _1 + _1: + ; + i = i + 1 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** If *pArg is initially negative then this is a query. Set *pArg to +// ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set. +// ** +// ** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags. +// */ +func _unixModeBit(tls *libc.TLS, pFile uintptr, mask uint8, pArg uintptr) { + var v1 uintptr + _ = v1 + if **(**int32)(__ccgo_up(pArg)) < 0 { + **(**int32)(__ccgo_up(pArg)) = libc.BoolInt32(libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFile)).FctrlFlags)&libc.Int32FromUint8(mask) != 0) + } else { + if **(**int32)(__ccgo_up(pArg)) == 0 { + v1 = pFile + 30 + *(*uint16)(unsafe.Pointer(v1)) = uint16(int32(*(*uint16)(unsafe.Pointer(v1))) & ^libc.Int32FromUint8(mask)) + } else { + v1 = pFile + 30 + *(*uint16)(unsafe.Pointer(v1)) = uint16(int32(*(*uint16)(unsafe.Pointer(v1))) | libc.Int32FromUint8(mask)) + } + } +} + +// C documentation +// +// /* +// ** Return the name of the first system call after zName. If zName==NULL +// ** then return the name of the first system call. Return NULL if zName +// ** is the last system call or if zName is not the name of a valid +// ** system call. +// */ +func _unixNextSystemCall(tls *libc.TLS, p uintptr, zName uintptr) (r uintptr) { + var i int32 + _ = i + i = -int32(1) + _ = p + if zName != 0 { + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(696)/libc.Uint64FromInt64(24))-libc.Int32FromInt32(1)) { + break + } + if libc.Xstrcmp(tls, zName, _aSyscall[i].FzName) == 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + } + i = i + 1 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(696)/libc.Uint64FromInt64(24))) { + break + } + if _aSyscall[i].FpCurrent != uintptr(0) { + return _aSyscall[i].FzName + } + goto _2 + _2: + ; + i = i + 1 + } + return uintptr(0) +} + +/* +** Do not accept any file descriptor less than this value, in order to avoid +** opening database file using file descriptors that are commonly used for +** standard input, output, and error. + */ + +// C documentation +// +// /* +// ** This is the xSetSystemCall() method of sqlite3_vfs for all of the +// ** "unix" VFSes. Return SQLITE_OK upon successfully updating the +// ** system call pointer, or SQLITE_NOTFOUND if there is no configurable +// ** system call named zName. +// */ +func _unixSetSystemCall(tls *libc.TLS, pNotUsed uintptr, zName uintptr, __ccgo_fp_pNewFunc Tsqlite3_syscall_ptr) (r int32) { + var i uint32 + var rc int32 + _, _ = i, rc + rc = int32(SQLITE_NOTFOUND) + _ = pNotUsed + if zName == uintptr(0) { + /* If no zName is given, restore all system calls to their default + ** settings and return NULL + */ + rc = SQLITE_OK + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(696)/libc.Uint64FromInt64(24)) { + break + } + if _aSyscall[i].FpDefault != 0 { + _aSyscall[i].FpCurrent = _aSyscall[i].FpDefault + } + goto _1 + _1: + ; + i = i + 1 + } + } else { + /* If zName is specified, operate on only the one system call + ** specified. + */ + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(696)/libc.Uint64FromInt64(24)) { + break + } + if libc.Xstrcmp(tls, zName, _aSyscall[i].FzName) == 0 { + if _aSyscall[i].FpDefault == uintptr(0) { + _aSyscall[i].FpDefault = _aSyscall[i].FpCurrent + } + rc = SQLITE_OK + if __ccgo_fp_pNewFunc == uintptr(0) { + __ccgo_fp_pNewFunc = _aSyscall[i].FpDefault + } + _aSyscall[i].FpCurrent = __ccgo_fp_pNewFunc + break + } + goto _2 + _2: + ; + i = i + 1 + } + } + return rc +} + +// C documentation +// +// /* +// ** Purge the unixShmNodeList list of all entries with unixShmNode.nRef==0. +// ** +// ** This is not a VFS shared-memory method; it is a utility function called +// ** by VFS shared-memory methods. +// */ +func _unixShmPurge(tls *libc.TLS, pFd uintptr) { + var i, nShmPerMap int32 + var p uintptr + _, _, _ = i, nShmPerMap, p + p = (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFd)).FpInode)).FpShmNode + if p != 0 && (*TunixShmNode)(unsafe.Pointer(p)).FnRef == 0 { + nShmPerMap = _unixShmRegionPerMap(tls) + Xsqlite3_mutex_free(tls, (*TunixShmNode)(unsafe.Pointer(p)).FpShmMutex) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TunixShmNode)(unsafe.Pointer(p)).FnRegion)) { + break + } + if (*TunixShmNode)(unsafe.Pointer(p)).FhShm >= 0 { + (*(*func(*libc.TLS, uintptr, Tsize_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(23)].FpCurrent})))(tls, **(**uintptr)(__ccgo_up((*TunixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*8)), libc.Uint64FromInt32((*TunixShmNode)(unsafe.Pointer(p)).FszRegion)) + } else { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up((*TunixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*8))) + } + goto _1 + _1: + ; + i = i + nShmPerMap + } + Xsqlite3_free(tls, (*TunixShmNode)(unsafe.Pointer(p)).FapRegion) + if (*TunixShmNode)(unsafe.Pointer(p)).FhShm >= 0 { + _robust_close(tls, pFd, (*TunixShmNode)(unsafe.Pointer(p)).FhShm, int32(45020)) + (*TunixShmNode)(unsafe.Pointer(p)).FhShm = -int32(1) + } + (*TunixInodeInfo)(unsafe.Pointer((*TunixShmNode)(unsafe.Pointer(p)).FpInode)).FpShmNode = uintptr(0) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Close a connection to shared-memory. Delete the underlying +// ** storage if deleteFlag is true. +// ** +// ** If there is no shared memory associated with the connection then this +// ** routine is a harmless no-op. +// */ +func _unixShmUnmap(tls *libc.TLS, fd uintptr, deleteFlag int32) (r int32) { + var p, pDbFd, pShmNode, pp uintptr + _, _, _, _ = p, pDbFd, pShmNode, pp /* The underlying database file */ + pDbFd = fd + p = (*TunixFile)(unsafe.Pointer(pDbFd)).FpShm + if p == uintptr(0) { + return SQLITE_OK + } + pShmNode = (*TunixShm)(unsafe.Pointer(p)).FpShmNode + /* Remove connection p from the set of connections associated + ** with pShmNode */ + Xsqlite3_mutex_enter(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + pp = pShmNode + 56 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != p) { + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 8 + } + **(**uintptr)(__ccgo_up(pp)) = (*TunixShm)(unsafe.Pointer(p)).FpNext + /* Free the connection p */ + Xsqlite3_free(tls, p) + (*TunixFile)(unsafe.Pointer(pDbFd)).FpShm = uintptr(0) + Xsqlite3_mutex_leave(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) + /* If pShmNode->nRef has reached 0, then close the underlying + ** shared-memory file, too */ + _unixEnterMutex(tls) + (*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRef = (*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRef - 1 + if (*TunixShmNode)(unsafe.Pointer(pShmNode)).FnRef == 0 { + if deleteFlag != 0 && (*TunixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0 { + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(16)].FpCurrent})))(tls, (*TunixShmNode)(unsafe.Pointer(pShmNode)).FzFilename) + } + _unixShmPurge(tls, pDbFd) + } + _unixLeaveMutex(tls) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Sleep for a little while. Return the amount of time slept. +// ** The argument is the number of microseconds we want to sleep. +// ** The return value is the number of microseconds of sleep actually +// ** requested from the underlying operating system, a number which +// ** might be greater than or equal to the argument, but not less +// ** than the argument. +// */ +func _unixSleep(tls *libc.TLS, NotUsed uintptr, microseconds int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* sp at bp+0 */ Ttimespec + (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec = int64(microseconds / int32(1000000)) + (**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec = int64(microseconds % int32(1000000) * int32(1000)) + /* Almost all modern unix systems support nanosleep(). But if you are + ** compiling for one of the rare exceptions, you can use + ** -DHAVE_NANOSLEEP=0 (perhaps in conjunction with -DHAVE_USLEEP if + ** usleep() is available) in order to bypass the use of nanosleep() */ + libc.Xnanosleep(tls, bp, libc.UintptrFromInt32(0)) + _ = NotUsed + return microseconds +} + +/* +** The following variable, if set to a non-zero value, is interpreted as +** the number of seconds since 1970 and is used to set the result of +** sqlite3OsCurrentTime() during testing. + */ + +// C documentation +// +// /* Undo the work of sqlite3SetJoinExpr(). This is used when a LEFT JOIN +// ** is simplified into an ordinary JOIN, and when an ON expression is +// ** "pushed down" into the WHERE clause of a subquery. +// ** +// ** Convert every term that is marked with EP_OuterON and w.iJoin==iTable into +// ** an ordinary term that omits the EP_OuterON mark. Or if iTable<0, then +// ** just clear every EP_OuterON and EP_InnerON mark from the expression tree. +// ** +// ** If nullable is true, that means that Expr p might evaluate to NULL even +// ** if it is a reference to a NOT NULL column. This can happen, for example, +// ** if the table that p references is on the left side of a RIGHT JOIN. +// ** If nullable is true, then take care to not remove the EP_CanBeNull bit. +// ** See forum thread https://sqlite.org/forum/forumpost/b40696f50145d21c +// */ +func _unsetJoinExpr(tls *libc.TLS, p uintptr, iTable int32, nullable int32) { + var i int32 + _ = i + for p != 0 { + if iTable < 0 || (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) && *(*int32)(unsafe.Pointer(p + 52)) == iTable { + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON) | libc.Int32FromInt32(EP_InnerON)) + if iTable >= 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) + } + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(p)).FiTable == iTable && !(nullable != 0) { + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_FUNCTION) { + if *(*uintptr)(unsafe.Pointer(p + 32)) != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)))).FnExpr) { + break + } + _unsetJoinExpr(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)) + 8 + uintptr(i)*32))).FpExpr, iTable, nullable) + goto _1 + _1: + ; + i = i + 1 + } + } + } + _unsetJoinExpr(tls, (*TExpr)(unsafe.Pointer(p)).FpLeft, iTable, nullable) + p = (*TExpr)(unsafe.Pointer(p)).FpRight + } +} + +// C documentation +// +// /* +// ** Generate code that will update the accumulator memory cells for an +// ** aggregate based on the current cursor position. +// ** +// ** If regAcc is non-zero and there are no min() or max() aggregates +// ** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator +// ** registers if register regAcc contains 0. The caller will take care +// ** of setting and clearing regAcc. +// ** +// ** For an ORDER BY aggregate, the actual accumulator memory cell update +// ** is deferred until after all input rows have been received, so that they +// ** can be run in the requested order. In that case, instead of invoking +// ** OP_AggStep to update the accumulator, just add the arguments that would +// ** have been passed into OP_AggStep into the sorting ephemeral table +// ** (along with the appropriate sort key). +// */ +func _updateAccumulator(tls *libc.TLS, pParse uintptr, regAcc int32, pAggInfo uintptr, eDistinctType int32) { + var addrHitTest, addrNext, i, j, jj, kk, nArg, regAgg, regAggSz, regBase, regDistinct, regHit, v2 int32 + var pC, pColl, pF, pFilter, pItem, pList, pOBList, v, v3 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrHitTest, addrNext, i, j, jj, kk, nArg, pC, pColl, pF, pFilter, pItem, pList, pOBList, regAgg, regAggSz, regBase, regDistinct, regHit, v, v2, v3 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + regHit = 0 + addrHitTest = 0 + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = uint8(1) + i = 0 + pF = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + addrNext = 0 + regAggSz = 0 + regDistinct = 0 + pList = *(*uintptr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 32)) + if (*TExpr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pF)).FpFExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + pFilter = (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 64)))).FpFilter + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0 && (*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 && regAcc != 0 { + /* If regAcc==0, there there exists some min() or max() function + ** without a FILTER clause that will ensure the magnet registers + ** are populated. */ + if regHit == 0 { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v2 = *(*int32)(unsafe.Pointer(v3)) + regHit = v2 + } + /* If this is the first row of the group (regAcc contains 0), clear the + ** "magnet" register regHit so that the accumulator registers + ** are populated if the FILTER clause jumps over the the + ** invocation of min() or max() altogether. Or, if this is not + ** the first row (regAcc contains 1), set the magnet register so that + ** the accumulators are not populated unless the min()/max() is invoked + ** and indicates that they should be. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), regAcc, regHit) + } + addrNext = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfFalse(tls, pParse, pFilter, addrNext, int32(SQLITE_JUMPIFNULL)) + } + if (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab >= 0 { /* The ORDER BY clause */ + nArg = (*TExprList)(unsafe.Pointer(pList)).FnExpr + pOBList = *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pF)).FpFExpr)).FpLeft + 32)) + regAggSz = (*TExprList)(unsafe.Pointer(pOBList)).FnExpr + if !((*TAggInfo_func)(unsafe.Pointer(pF)).FbOBUnique != 0) { + regAggSz = regAggSz + 1 /* One register for OP_Sequence */ + } + if (*TAggInfo_func)(unsafe.Pointer(pF)).FbOBPayload != 0 { + regAggSz = regAggSz + nArg + } + if (*TAggInfo_func)(unsafe.Pointer(pF)).FbUseSubtype != 0 { + regAggSz = regAggSz + nArg + } + regAggSz = regAggSz + 1 /* One extra register to hold result of MakeRecord */ + regAgg = _sqlite3GetTempRange(tls, pParse, regAggSz) + regDistinct = regAgg + _sqlite3ExprCodeExprList(tls, pParse, pOBList, regAgg, 0, uint8(SQLITE_ECEL_DUP)) + jj = (*TExprList)(unsafe.Pointer(pOBList)).FnExpr + if !((*TAggInfo_func)(unsafe.Pointer(pF)).FbOBUnique != 0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Sequence), (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab, regAgg+jj) + jj = jj + 1 + } + if (*TAggInfo_func)(unsafe.Pointer(pF)).FbOBPayload != 0 { + regDistinct = regAgg + jj + _sqlite3ExprCodeExprList(tls, pParse, pList, regDistinct, 0, uint8(SQLITE_ECEL_DUP)) + jj = jj + nArg + } + if (*TAggInfo_func)(unsafe.Pointer(pF)).FbUseSubtype != 0 { + if (*TAggInfo_func)(unsafe.Pointer(pF)).FbOBPayload != 0 { + v2 = regDistinct + } else { + v2 = regAgg + } + regBase = v2 + kk = 0 + for { + if !(kk < nArg) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_GetSubtype), regBase+kk, regAgg+jj) + goto _5 + _5: + ; + kk = kk + 1 + jj = jj + 1 + } + } + } else { + if pList != 0 { + nArg = (*TExprList)(unsafe.Pointer(pList)).FnExpr + regAgg = _sqlite3GetTempRange(tls, pParse, nArg) + regDistinct = regAgg + _sqlite3ExprCodeExprList(tls, pParse, pList, regAgg, 0, uint8(SQLITE_ECEL_DUP)) + } else { + nArg = 0 + regAgg = 0 + } + } + if (*TAggInfo_func)(unsafe.Pointer(pF)).FiDistinct >= 0 && pList != 0 { + if addrNext == 0 { + addrNext = _sqlite3VdbeMakeLabel(tls, pParse) + } + (*TAggInfo_func)(unsafe.Pointer(pF)).FiDistinct = _codeDistinct(tls, pParse, eDistinctType, (*TAggInfo_func)(unsafe.Pointer(pF)).FiDistinct, addrNext, pList, regDistinct) + } + if (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab >= 0 { + /* Insert a new record into the ORDER BY table */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regAgg, regAggSz-int32(1), regAgg+regAggSz-int32(1)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), (*TAggInfo_func)(unsafe.Pointer(pF)).FiOBTab, regAgg+regAggSz-int32(1), regAgg, regAggSz-int32(1)) + _sqlite3ReleaseTempRange(tls, pParse, regAgg, regAggSz) + } else { + /* Invoke the AggStep function */ + if (*TFuncDef)(unsafe.Pointer((*TAggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 { + pColl = uintptr(0) + /* pList!=0 if pF->pFunc has NEEDCOLL */ + j = 0 + pItem = pList + 8 + for { + if !(!(pColl != 0) && j < nArg) { + break + } + pColl = _sqlite3ExprCollSeq(tls, pParse, (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr) + goto _6 + _6: + ; + j = j + 1 + pItem += 32 + } + if !(pColl != 0) { + pColl = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FpDfltColl + } + if regHit == 0 && (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0 { + v3 = pParse + 60 + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + v2 = *(*int32)(unsafe.Pointer(v3)) + regHit = v2 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_CollSeq), regHit, 0, 0, pColl, -int32(2)) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_AggStep), 0, regAgg, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+(*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn+i) + _sqlite3VdbeAppendP4(tls, v, (*TAggInfo_func)(unsafe.Pointer(pF)).FpFunc, -int32(8)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(nArg)) + _sqlite3ReleaseTempRange(tls, pParse, regAgg, nArg) + } + if addrNext != 0 { + _sqlite3VdbeResolveLabel(tls, v, addrNext) + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + goto _1 + _1: + ; + i = i + 1 + pF += 32 + } + if regHit == 0 && (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0 { + regHit = regAcc + } + if regHit != 0 { + addrHitTest = _sqlite3VdbeAddOp1(tls, v, int32(OP_If), regHit) + } + i = 0 + pC = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator) { + break + } + _sqlite3ExprCode(tls, pParse, (*TAggInfo_col)(unsafe.Pointer(pC)).FpCExpr, (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+i) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + goto _9 + _9: + ; + i = i + 1 + pC += 32 + } + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = uint8(0) + if addrHitTest != 0 { + _sqlite3VdbeJumpHereOrPopInst(tls, v, addrHitTest) + } +} + +// C documentation +// +// /* +// ** Assuming both the pLimit and pOrderBy parameters are NULL, this function +// ** generates VM code to run the query: +// ** +// ** SELECT , pChanges FROM pTabList WHERE pWhere +// ** +// ** and write the results to the ephemeral table already opened as cursor +// ** iEph. None of pChanges, pTabList or pWhere are modified or consumed by +// ** this function, they must be deleted by the caller. +// ** +// ** Or, if pLimit and pOrderBy are not NULL, and pTab is not a view: +// ** +// ** SELECT , pChanges FROM pTabList +// ** WHERE pWhere +// ** GROUP BY +// ** ORDER BY pOrderBy LIMIT pLimit +// ** +// ** If pTab is a view, the GROUP BY clause is omitted. +// ** +// ** Exactly how results are written to table iEph, and exactly what +// ** the in the query above are is determined by the type +// ** of table pTabList->a[0].pTab. +// ** +// ** If the table is a WITHOUT ROWID table, then argument pPk must be its +// ** PRIMARY KEY. In this case are the primary key columns +// ** of the table, in order. The results of the query are written to ephemeral +// ** table iEph as index keys, using OP_IdxInsert. +// ** +// ** If the table is actually a view, then are all columns of +// ** the view. The results are written to the ephemeral table iEph as records +// ** with automatically assigned integer keys. +// ** +// ** If the table is a virtual or ordinary intkey table, then +// ** is its rowid. For a virtual table, the results are written to iEph as +// ** records with automatically assigned integer keys For intkey tables, the +// ** rowid value in is used as the integer key, and the +// ** remaining fields make up the table record. +// */ +func _updateFromSelect(tls *libc.TLS, pParse uintptr, iEph int32, pPk uintptr, pChanges uintptr, pTabList uintptr, pWhere uintptr, pOrderBy uintptr, pLimit uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var db, pGrp, pLimit2, pList, pNew, pOrderBy2, pSelect, pSrc, pTab, pWhere2 uintptr + var eDest, i, v2 int32 + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _ = db, eDest, i, pGrp, pLimit2, pList, pNew, pOrderBy2, pSelect, pSrc, pTab, pWhere2, v2 + pSelect = uintptr(0) + pList = uintptr(0) + pGrp = uintptr(0) + pLimit2 = uintptr(0) + pOrderBy2 = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab + _ = pOrderBy + _ = pLimit + pSrc = _sqlite3SrcListDup(tls, db, pTabList, 0) + pWhere2 = _sqlite3ExprDup(tls, db, pWhere, 0) + if pSrc != 0 { + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FiCursor = -int32(1) + (*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FpSTab)).FnTabRef = (*TTable)(unsafe.Pointer((*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FpSTab)).FnTabRef - 1 + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FpSTab = uintptr(0) + } + if pPk != 0 { + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + pNew = _exprRowColumn(tls, pParse, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) + pList = _sqlite3ExprListAppend(tls, pParse, pList, pNew) + goto _1 + _1: + ; + i = i + 1 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + v2 = int32(SRT_Table) + } else { + v2 = int32(SRT_Upfrom) + } + eDest = v2 + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, _exprRowColumn(tls, pParse, i)) + goto _3 + _3: + ; + i = i + 1 + } + eDest = int32(SRT_Table) + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + v2 = int32(SRT_Table) + } else { + v2 = int32(SRT_Upfrom) + } + eDest = v2 + pList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3PExpr(tls, pParse, int32(TK_ROW), uintptr(0), uintptr(0))) + } + } + if pChanges != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pChanges)).FnExpr) { + break + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, _sqlite3ExprDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*32))).FpExpr, 0)) + goto _5 + _5: + ; + i = i + 1 + } + } + pSelect = _sqlite3SelectNew(tls, pParse, pList, pSrc, pWhere2, pGrp, uintptr(0), pOrderBy2, libc.Uint32FromInt32(libc.Int32FromInt32(SF_UFSrcCheck)|libc.Int32FromInt32(SF_IncludeHidden)|libc.Int32FromInt32(SF_UpdateFrom)), pLimit2) + if pSelect != 0 { + **(**Tu32)(__ccgo_up(pSelect + 4)) |= uint32(SF_OrderByReqd) + } + _sqlite3SelectDestInit(tls, bp, eDest, iEph) + if pPk != 0 { + v2 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } else { + v2 = -int32(1) + } + (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 = v2 + _sqlite3Select(tls, pParse, pSelect, bp) + _sqlite3SelectDelete(tls, db, pSelect) +} + +// C documentation +// +// /* +// ** Generate code for an UPDATE of a virtual table. +// ** +// ** There are two possible strategies - the default and the special +// ** "onepass" strategy. Onepass is only used if the virtual table +// ** implementation indicates that pWhere may match at most one row. +// ** +// ** The default strategy is to create an ephemeral table that contains +// ** for each row to be changed: +// ** +// ** (A) The original rowid of that row. +// ** (B) The revised rowid for the row. +// ** (C) The content of every column in the row. +// ** +// ** Then loop through the contents of this ephemeral table executing a +// ** VUpdate for each row. When finished, drop the ephemeral table. +// ** +// ** The "onepass" strategy does not use an ephemeral table. Instead, it +// ** stores the same values (A, B and C above) in a register array and +// ** makes a single invocation of VUpdate. +// */ +func _updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, pChanges uintptr, pRowid uintptr, aXRef uintptr, pWhere uintptr, onError int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var addr, eOnePass, ephemTab, i, iCsr, nArg, regArg, regRec, regRowid, v1 int32 + var db, pList, pPk, pPk1, pRow, pRowExpr, pVTab, pWInfo, v, v2 uintptr + var iPk, iPk1 Ti16 + var _ /* aDummy at bp+0 */ [2]int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, db, eOnePass, ephemTab, i, iCsr, iPk, iPk1, nArg, pList, pPk, pPk1, pRow, pRowExpr, pVTab, pWInfo, regArg, regRec, regRowid, v, v1, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* Loop counter */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + pVTab = _sqlite3GetVTable(tls, db, pTab) + pWInfo = uintptr(0) + nArg = int32(2) + int32((*TTable)(unsafe.Pointer(pTab)).FnCol) /* Register for ephemeral table rowid */ + iCsr = (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FiCursor /* Address of OP_OpenEphemeral */ + /* Allocate nArg registers in which to gather the arguments for VUpdate. Then + ** create and open the ephemeral table in which the records created from + ** these arguments will be temporarily stored. */ + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + ephemTab = v1 + addr = _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), ephemTab, nArg) + regArg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nArg + if (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc > int32(1) { + pPk = uintptr(0) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + if pRowid != 0 { + pRow = _sqlite3ExprDup(tls, db, pRowid, 0) + } else { + pRow = _sqlite3PExpr(tls, pParse, int32(TK_ROW), uintptr(0), uintptr(0)) + } + } else { /* PRIMARY KEY column */ + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + iPk = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn)) + if **(**int32)(__ccgo_up(aXRef + uintptr(iPk)*4)) >= 0 { + pRow = _sqlite3ExprDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(**(**int32)(__ccgo_up(aXRef + uintptr(iPk)*4)))*32))).FpExpr, 0) + } else { + pRow = _exprRowColumn(tls, pParse, int32(iPk)) + } + } + pList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), pRow) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if **(**int32)(__ccgo_up(aXRef + uintptr(i)*4)) >= 0 { + pList = _sqlite3ExprListAppend(tls, pParse, pList, _sqlite3ExprDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(**(**int32)(__ccgo_up(aXRef + uintptr(i)*4)))*32))).FpExpr, 0)) + } else { + pRowExpr = _exprRowColumn(tls, pParse, i) + if pRowExpr != 0 { + (*TExpr)(unsafe.Pointer(pRowExpr)).Fop2 = uint8(OPFLAG_NOCHNG) + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, pRowExpr) + } + goto _3 + _3: + ; + i = i + 1 + } + _updateFromSelect(tls, pParse, ephemTab, pPk, pList, pSrc, pWhere, uintptr(0), uintptr(0)) + _sqlite3ExprListDelete(tls, db, pList) + eOnePass = ONEPASS_OFF + } else { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regRec = v1 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regRowid = v1 + /* Start scanning the virtual table */ + pWInfo = _sqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint16(WHERE_ONEPASS_DESIRED), 0) + if pWInfo == uintptr(0) { + return + } + /* Populate the argument registers. */ + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if **(**int32)(__ccgo_up(aXRef + uintptr(i)*4)) >= 0 { + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(**(**int32)(__ccgo_up(aXRef + uintptr(i)*4)))*32))).FpExpr, regArg+int32(2)+i) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_VColumn), iCsr, i, regArg+int32(2)+i) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_NOCHNG)) /* For sqlite3_vtab_nochange() */ + } + goto _8 + _8: + ; + i = i + 1 + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iCsr, regArg) + if pRowid != 0 { + _sqlite3ExprCode(tls, pParse, pRowid, regArg+int32(1)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iCsr, regArg+int32(1)) + } + } else { /* PRIMARY KEY column */ + pPk1 = _sqlite3PrimaryKeyIndex(tls, pTab) + iPk1 = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk1)).FaiColumn)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_VColumn), iCsr, int32(iPk1), regArg) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), regArg+int32(2)+int32(iPk1), regArg+int32(1)) + } + eOnePass = _sqlite3WhereOkOnePass(tls, pWInfo, bp) + /* There is no ONEPASS_MULTI on virtual tables */ + if eOnePass != 0 { + /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded + ** above. */ + _sqlite3VdbeChangeToNoop(tls, v, addr) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iCsr) + } else { + /* Create a record from the argument register contents and insert it into + ** the ephemeral table. */ + _sqlite3MultiWrite(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regArg, nArg, regRec) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), ephemTab, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), ephemTab, regRec, regRowid) + } + } + if eOnePass == ONEPASS_OFF { + /* End the virtual table scan */ + if (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc == int32(1) { + _sqlite3WhereEnd(tls, pWInfo) + } + /* Begin scanning through the ephemeral table. */ + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), ephemTab) + /* Extract arguments from the current row of the ephemeral table and + ** invoke the VUpdate method. */ + i = 0 + for { + if !(i < nArg) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), ephemTab, i, regArg+i) + goto _9 + _9: + ; + i = i + 1 + } + } + _sqlite3VtabMakeWritable(tls, pParse, pTab) + _sqlite3VdbeAddOp4(tls, v, int32(OP_VUpdate), 0, nArg, regArg, pVTab, -int32(12)) + if onError == int32(OE_Default) { + v1 = int32(OE_Abort) + } else { + v1 = onError + } + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(v1)) + _sqlite3MayAbort(tls, pParse) + /* End of the ephemeral table scan. Or, if using the onepass strategy, + ** jump to here if the scan visited zero rows. */ + if eOnePass == ONEPASS_OFF { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), ephemTab, addr+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Close), ephemTab, 0) + } else { + _sqlite3WhereEnd(tls, pWInfo) + } +} + +/************** End of update.c **********************************************/ +/************** Begin file upsert.c ******************************************/ +/* +** 2018-04-12 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code to implement various aspects of UPSERT +** processing and handling of the Upsert object. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** Allocate and return a pointer to a new sqlite3_value object. If +// ** the second argument to this function is NULL, the object is allocated +// ** by calling sqlite3ValueNew(). +// ** +// ** Otherwise, if the second argument is non-zero, then this function is +// ** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not +// ** already been allocated, allocate the UnpackedRecord structure that +// ** that function will return to its caller here. Then return a pointer to +// ** an sqlite3_value within the UnpackedRecord.a[] array. +// */ +func _valueNew(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) { + var i, nCol int32 + var nByte Ti64 + var pIdx, pRec uintptr + _, _, _, _, _ = i, nByte, nCol, pIdx, pRec + if p != 0 { + pRec = **(**uintptr)(__ccgo_up((*TValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec)) + if pRec == uintptr(0) { + pIdx = (*TValueNewStat4Ctx)(unsafe.Pointer(p)).FpIdx /* Counter variable */ + nCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) /* Number of index columns including rowid */ + nByte = libc.Int64FromUint64(uint64(56)*libc.Uint64FromInt32(nCol) + (libc.Uint64FromInt64(40)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + pRec = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte)) + if pRec != 0 { + (*TUnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo = _sqlite3KeyInfoOfIndex(tls, (*TValueNewStat4Ctx)(unsafe.Pointer(p)).FpParse, pIdx) + if (*TUnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo != 0 { + (*TUnpackedRecord)(unsafe.Pointer(pRec)).FaMem = pRec + uintptr((libc.Uint64FromInt64(40)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + i = 0 + for { + if !(i < nCol) { + break + } + (**(**TMem)(__ccgo_up((*TUnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*56))).Fflags = uint16(MEM_Null) + (**(**TMem)(__ccgo_up((*TUnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*56))).Fdb = db + goto _1 + _1: + ; + i = i + 1 + } + } else { + _sqlite3DbFreeNN(tls, db, pRec) + pRec = uintptr(0) + } + } + if pRec == uintptr(0) { + return uintptr(0) + } + **(**uintptr)(__ccgo_up((*TValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec)) = pRec + } + (*TUnpackedRecord)(unsafe.Pointer(pRec)).FnField = libc.Uint16FromInt32((*TValueNewStat4Ctx)(unsafe.Pointer(p)).FiVal + int32(1)) + _sqlite3VdbeMemSetNull(tls, (*TUnpackedRecord)(unsafe.Pointer(pRec)).FaMem+uintptr((*TValueNewStat4Ctx)(unsafe.Pointer(p)).FiVal)*56) + return (*TUnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr((*TValueNewStat4Ctx)(unsafe.Pointer(p)).FiVal)*56 + } + return _sqlite3ValueNew(tls, db) +} + +// C documentation +// +// /* +// ** The pVal argument is known to be a value other than NULL. +// ** Convert it into a string with encoding enc and return a pointer +// ** to a zero-terminated version of that string. +// */ +func _valueToText(tls *libc.TLS, pVal uintptr, enc Tu8) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fflags)&(libc.Int32FromInt32(MEM_Blob)|libc.Int32FromInt32(MEM_Str)) != 0 { + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fflags)&int32(MEM_Zero) != 0 { + v1 = _sqlite3VdbeMemExpandBlob(tls, pVal) + } else { + v1 = 0 + } + if v1 != 0 { + return uintptr(0) + } + v2 = pVal + 20 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(MEM_Str)) + if libc.Int32FromUint8((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fenc) != libc.Int32FromUint8(enc) & ^libc.Int32FromInt32(SQLITE_UTF16_ALIGNED) { + _sqlite3VdbeChangeEncoding(tls, pVal, libc.Int32FromUint8(enc) & ^libc.Int32FromInt32(SQLITE_UTF16_ALIGNED)) + } + if libc.Int32FromUint8(enc)&int32(SQLITE_UTF16_ALIGNED) != 0 && int32(1) == int32(1)&int32(int64((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fz)) { + if _sqlite3VdbeMemMakeWriteable(tls, pVal) != SQLITE_OK { + return uintptr(0) + } + } + _sqlite3VdbeMemNulTerminate(tls, pVal) /* IMP: R-31275-44060 */ + } else { + _sqlite3VdbeMemStringify(tls, pVal, enc, uint8(0)) + } + if libc.Int32FromUint8((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fenc) == libc.Int32FromUint8(enc) & ^libc.Int32FromInt32(SQLITE_UTF16_ALIGNED) { + return (*Tsqlite3_value)(unsafe.Pointer(pVal)).Fz + } else { + return uintptr(0) + } + return r +} + +// C documentation +// +// /* +// ** Change the value of the P4 operand for a specific instruction. +// ** This routine is useful when a large program is loaded from a +// ** static array using sqlite3VdbeAddOpList but we want to make a +// ** few minor changes to the program. +// ** +// ** If n>=0 then the P4 operand is dynamic, meaning that a copy of +// ** the string is made into memory obtained from sqlite3_malloc(). +// ** A value of n==0 means copy bytes of zP4 up to and including the +// ** first null byte. If n>0 then copy n+1 bytes of zP4. +// ** +// ** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points +// ** to a string or structure that is guaranteed to exist for the lifetime of +// ** the Vdbe. In these cases we can just copy the pointer. +// ** +// ** If addr<0 then change P4 on the most recently inserted instruction. +// */ +func _vdbeChangeP4Full(tls *libc.TLS, p uintptr, pOp uintptr, zP4 uintptr, n int32) { + if (*TOp)(unsafe.Pointer(pOp)).Fp4type != 0 { + (*TOp)(unsafe.Pointer(pOp)).Fp4type = 0 + *(*uintptr)(unsafe.Pointer(pOp + 16)) = uintptr(0) + } + if n < 0 { + _sqlite3VdbeChangeP4(tls, p, int32((int64(pOp)-int64((*TVdbe)(unsafe.Pointer(p)).FaOp))/24), zP4, n) + } else { + if n == 0 { + n = _sqlite3Strlen30(tls, zP4) + } + *(*uintptr)(unsafe.Pointer(pOp + 16)) = _sqlite3DbStrNDup(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, zP4, libc.Uint64FromInt32(n)) + (*TOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) + } +} + +// C documentation +// +// /* +// ** Read keys from pIncr->pMerger and populate pIncr->aFile[1]. The format +// ** of the data stored in aFile[1] is the same as that used by regular PMAs, +// ** except that the number-of-bytes varint is omitted from the start. +// */ +func _vdbeIncrPopulate(tls *libc.TLS, pIncr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var iEof, iStart Ti64 + var nKey, rc, rc2 int32 + var pMerger, pOut, pReader, pTask uintptr + var _ /* dummy at bp+56 */ int32 + var _ /* writer at bp+0 */ TPmaWriter + _, _, _, _, _, _, _, _, _ = iEof, iStart, nKey, pMerger, pOut, pReader, pTask, rc, rc2 + rc = SQLITE_OK + iStart = (*TIncrMerger)(unsafe.Pointer(pIncr)).FiStartOff + pOut = pIncr + 40 + 1*16 + pTask = (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask + pMerger = (*TIncrMerger)(unsafe.Pointer(pIncr)).FpMerger + _vdbePmaWriterInit(tls, (*TSorterFile)(unsafe.Pointer(pOut)).FpFd, bp, (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz, iStart) + for rc == SQLITE_OK { + pReader = (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(**(**int32)(__ccgo_up((*TMergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)))*80 + nKey = (*TPmaReader)(unsafe.Pointer(pReader)).FnKey + iEof = (**(**TPmaWriter)(__ccgo_up(bp))).FiWriteOff + int64((**(**TPmaWriter)(__ccgo_up(bp))).FiBufEnd) + /* Check if the output file is full or if the input has been exhausted. + ** In either case exit the loop. */ + if (*TPmaReader)(unsafe.Pointer(pReader)).FpFd == uintptr(0) { + break + } + if iEof+int64(nKey)+int64(_sqlite3VarintLen(tls, libc.Uint64FromInt32(nKey))) > iStart+int64((*TIncrMerger)(unsafe.Pointer(pIncr)).FmxSz) { + break + } + /* Write the next key to the output. */ + _vdbePmaWriteVarint(tls, bp, libc.Uint64FromInt32(nKey)) + _vdbePmaWriteBlob(tls, bp, (*TPmaReader)(unsafe.Pointer(pReader)).FaKey, nKey) + rc = _vdbeMergeEngineStep(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpMerger, bp+56) + } + rc2 = _vdbePmaWriterFinish(tls, bp, pOut+8, pTask+96) + if rc == SQLITE_OK { + rc = rc2 + } + return rc +} + +// C documentation +// +// /* +// ** If the memory cell contains a value that must be freed by +// ** invoking the external callback in Mem.xDel, then this routine +// ** will free that value. It also sets Mem.flags to MEM_Null. +// ** +// ** This is a helper routine for sqlite3VdbeMemSetNull() and +// ** for sqlite3VdbeMemRelease(). Use those other routines as the +// ** entry point for releasing Mem resources. +// */ +func _vdbeMemClearExternAndSetNull(tls *libc.TLS, p uintptr) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&int32(MEM_Agg) != 0 { + _sqlite3VdbeMemFinalize(tls, p, *(*uintptr)(unsafe.Pointer(p))) + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&int32(MEM_Dyn) != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TMem)(unsafe.Pointer(p)).FxDel})))(tls, (*TMem)(unsafe.Pointer(p)).Fz) + } + (*TMem)(unsafe.Pointer(p)).Fflags = uint16(MEM_Null) +} + +// C documentation +// +// /* +// ** Initialize the MergeEngine object passed as the second argument. Once this +// ** function returns, the first key of merged data may be read from the +// ** MergeEngine object in the usual fashion. +// ** +// ** If argument eMode is INCRINIT_ROOT, then it is assumed that any IncrMerge +// ** objects attached to the PmaReader objects that the merger reads from have +// ** already been populated, but that they have not yet populated aFile[0] and +// ** set the PmaReader objects up to read from it. In this case all that is +// ** required is to call vdbePmaReaderNext() on each PmaReader to point it at +// ** its first key. +// ** +// ** Otherwise, if eMode is any value other than INCRINIT_ROOT, then use +// ** vdbePmaReaderIncrMergeInit() to initialize each PmaReader that feeds data +// ** to pMerger. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +// */ +func _vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode int32) (r int32) { + var i, nTree, rc int32 + _, _, _ = i, nTree, rc + rc = SQLITE_OK /* Number of subtrees to merge */ + /* Failure to allocate the merge would have been detected prior to + ** invoking this routine */ + /* eMode is always INCRINIT_NORMAL in single-threaded mode */ + /* Verify that the MergeEngine is assigned to a single thread */ + (*TMergeEngine)(unsafe.Pointer(pMerger)).FpTask = pTask + nTree = (*TMergeEngine)(unsafe.Pointer(pMerger)).FnTree + i = 0 + for { + if !(i < nTree) { + break + } + if libc.Bool(int32(SQLITE_MAX_WORKER_THREADS) > 0) && eMode == int32(INCRINIT_ROOT) { + /* PmaReaders should be normally initialized in order, as if they are + ** reading from the same temp file this makes for more linear file IO. + ** However, in the INCRINIT_ROOT case, if PmaReader aReadr[nTask-1] is + ** in use it will block the vdbePmaReaderNext() call while it uses + ** the main thread to fill its buffer. So calling PmaReaderNext() + ** on this PmaReader before any of the multi-threaded PmaReaders takes + ** better advantage of multi-processor hardware. */ + rc = _vdbePmaReaderNext(tls, (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(nTree-i-int32(1))*80) + } else { + rc = _vdbePmaReaderIncrInit(tls, (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(i)*80, INCRINIT_NORMAL) + } + if rc != SQLITE_OK { + return rc + } + goto _1 + _1: + ; + i = i + 1 + } + i = (*TMergeEngine)(unsafe.Pointer(pMerger)).FnTree - int32(1) + for { + if !(i > 0) { + break + } + _vdbeMergeEngineCompare(tls, pMerger, i) + goto _2 + _2: + ; + i = i - 1 + } + return libc.Int32FromUint8((*TUnpackedRecord)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode) +} + +// C documentation +// +// /* +// ** Allocate a new MergeEngine object capable of handling up to +// ** nReader PmaReader inputs. +// ** +// ** nReader is automatically rounded up to the next power of two. +// ** nReader may not exceed SORTER_MAX_MERGE_COUNT even after rounding up. +// */ +func _vdbeMergeEngineNew(tls *libc.TLS, nReader int32) (r uintptr) { + var N int32 + var nByte Ti64 + var pNew, v1 uintptr + _, _, _, _ = N, nByte, pNew, v1 + N = int32(2) /* Pointer to allocated object to return */ + for N < nReader { + N = N + N + } + nByte = libc.Int64FromUint64(uint64(32) + libc.Uint64FromInt32(N)*(libc.Uint64FromInt64(4)+libc.Uint64FromInt64(80))) + if _sqlite3FaultSim(tls, int32(100)) != 0 { + v1 = uintptr(0) + } else { + v1 = _sqlite3MallocZero(tls, libc.Uint64FromInt64(nByte)) + } + pNew = v1 + if pNew != 0 { + (*TMergeEngine)(unsafe.Pointer(pNew)).FnTree = N + (*TMergeEngine)(unsafe.Pointer(pNew)).FpTask = uintptr(0) + (*TMergeEngine)(unsafe.Pointer(pNew)).FaReadr = pNew + 1*32 + (*TMergeEngine)(unsafe.Pointer(pNew)).FaTree = (*TMergeEngine)(unsafe.Pointer(pNew)).FaReadr + uintptr(N)*80 + } + return pNew +} + +// C documentation +// +// /* +// ** Advance the MergeEngine to its next entry. +// ** Set *pbEof to true there is no next entry because +// ** the MergeEngine has reached the end of all its inputs. +// ** +// ** Return SQLITE_OK if successful or an error code if an error occurs. +// */ +func _vdbeMergeEngineStep(tls *libc.TLS, pMerger uintptr, pbEof uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iPrev, iRes, rc, v2 int32 + var pReadr1, pReadr2, pTask uintptr + var _ /* bCached at bp+0 */ int32 + _, _, _, _, _, _, _, _ = i, iPrev, iRes, pReadr1, pReadr2, pTask, rc, v2 + iPrev = **(**int32)(__ccgo_up((*TMergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)) /* Index of PmaReader to advance */ + pTask = (*TMergeEngine)(unsafe.Pointer(pMerger)).FpTask + /* Advance the current PmaReader */ + rc = _vdbePmaReaderNext(tls, (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(iPrev)*80) + /* Update contents of aTree[] */ + if rc == SQLITE_OK { /* Second PmaReader to compare */ + **(**int32)(__ccgo_up(bp)) = 0 + /* Find the first two PmaReaders to compare. The one that was just + ** advanced (iPrev) and the one next to it in the array. */ + pReadr1 = (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(iPrev&libc.Int32FromInt32(0xFFFE))*80 + pReadr2 = (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(iPrev|libc.Int32FromInt32(0x0001))*80 + i = ((*TMergeEngine)(unsafe.Pointer(pMerger)).FnTree + iPrev) / int32(2) + for { + if !(i > 0) { + break + } + if (*TPmaReader)(unsafe.Pointer(pReadr1)).FpFd == uintptr(0) { + iRes = +libc.Int32FromInt32(1) + } else { + if (*TPmaReader)(unsafe.Pointer(pReadr2)).FpFd == uintptr(0) { + iRes = -int32(1) + } else { + iRes = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSortSubtask)(unsafe.Pointer(pTask)).FxCompare})))(tls, pTask, bp, (*TPmaReader)(unsafe.Pointer(pReadr1)).FaKey, (*TPmaReader)(unsafe.Pointer(pReadr1)).FnKey, (*TPmaReader)(unsafe.Pointer(pReadr2)).FaKey, (*TPmaReader)(unsafe.Pointer(pReadr2)).FnKey) + } + } + /* If pReadr1 contained the smaller value, set aTree[i] to its index. + ** Then set pReadr2 to the next PmaReader to compare to pReadr1. In this + ** case there is no cache of pReadr2 in pTask->pUnpacked, so set + ** pKey2 to point to the record belonging to pReadr2. + ** + ** Alternatively, if pReadr2 contains the smaller of the two values, + ** set aTree[i] to its index and update pReadr1. If vdbeSorterCompare() + ** was actually called above, then pTask->pUnpacked now contains + ** a value equivalent to pReadr2. So set pKey2 to NULL to prevent + ** vdbeSorterCompare() from decoding pReadr2 again. + ** + ** If the two values were equal, then the value from the oldest + ** PMA should be considered smaller. The VdbeSorter.aReadr[] array + ** is sorted from oldest to newest, so pReadr1 contains older values + ** than pReadr2 iff (pReadr1= (*TPmaReader)(unsafe.Pointer(pReadr)).FiEof { + pIncr = (*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr + bEof = int32(1) + if pIncr != 0 { + rc = _vdbeIncrSwap(tls, pIncr) + if rc == SQLITE_OK && (*TIncrMerger)(unsafe.Pointer(pIncr)).FbEof == 0 { + rc = _vdbePmaReaderSeek(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask, pReadr, pIncr+40, (*TIncrMerger)(unsafe.Pointer(pIncr)).FiStartOff) + bEof = 0 + } + } + if bEof != 0 { + /* This is an EOF condition */ + _vdbePmaReaderClear(tls, pReadr) + return rc + } + } + if rc == SQLITE_OK { + rc = _vdbePmaReadVarint(tls, pReadr, bp) + } + if rc == SQLITE_OK { + (*TPmaReader)(unsafe.Pointer(pReadr)).FnKey = libc.Int32FromUint64(**(**Tu64)(__ccgo_up(bp))) + rc = _vdbePmaReadBlob(tls, pReadr, libc.Int32FromUint64(**(**Tu64)(__ccgo_up(bp))), pReadr+40) + } + return rc +} + +// C documentation +// +// /* +// ** Attach PmaReader pReadr to file pFile (if it is not already attached to +// ** that file) and seek it to offset iOff within the file. Return SQLITE_OK +// ** if successful, or an SQLite error code if an error occurs. +// */ +func _vdbePmaReaderSeek(tls *libc.TLS, pTask uintptr, pReadr uintptr, pFile uintptr, iOff Ti64) (r int32) { + var iBuf, nRead, pgsz, rc int32 + _, _, _, _ = iBuf, nRead, pgsz, rc + rc = SQLITE_OK + if _sqlite3FaultSim(tls, int32(201)) != 0 { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(1)< (*TPmaReader)(unsafe.Pointer(pReadr)).FiEof { + nRead = int32((*TPmaReader)(unsafe.Pointer(pReadr)).FiEof - (*TPmaReader)(unsafe.Pointer(pReadr)).FiReadOff) + } + rc = _sqlite3OsRead(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FpFd, (*TPmaReader)(unsafe.Pointer(pReadr)).FaBuffer+uintptr(iBuf), nRead, (*TPmaReader)(unsafe.Pointer(pReadr)).FiReadOff) + } + } + return rc +} + +// C documentation +// +// /* +// ** This function is an optimized version of sqlite3VdbeRecordCompare() +// ** that (a) the first field of pPKey2 is an integer, and (b) the +// ** size-of-header varint at the start of (pKey1/nKey1) fits in a single +// ** byte (i.e. is less than 128). +// ** +// ** To avoid concerns about buffer overreads, this routine is only used +// ** on schemas where the maximum valid header size is 63 bytes or less. +// */ +func _vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aKey uintptr + var lhs, v Ti64 + var res, serial_type int32 + var _ /* x at bp+8 */ Tu64 + var _ /* y at bp+0 */ Tu32 + _, _, _, _, _ = aKey, lhs, res, serial_type, v + aKey = pKey1 + uintptr(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pKey1)))&int32(0x3F)) + serial_type = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pKey1 + 1))) + switch serial_type { + case int32(1): /* 1-byte signed integer */ + lhs = int64(libc.Int8FromUint8(**(**Tu8)(__ccgo_up(aKey)))) + case int32(2): /* 2-byte signed integer */ + lhs = int64(libc.Int32FromInt32(256)*int32(libc.Int8FromUint8(**(**Tu8)(__ccgo_up(aKey)))) | libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aKey + 1)))) + case int32(3): /* 3-byte signed integer */ + lhs = int64(libc.Int32FromInt32(65536)*int32(libc.Int8FromUint8(**(**Tu8)(__ccgo_up(aKey)))) | libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aKey + 1)))< lhs { + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) + } else { + if v < lhs { + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2) + } else { + if libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FnField) > int32(1) { + /* The first fields of the two keys are equal. Compare the trailing + ** fields. */ + res = _sqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, int32(1)) + } else { + /* The first fields of the two keys are equal and there are no trailing + ** fields. Return pPKey2->default_rc in this case. */ + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fdefault_rc) + (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FeqSeen = uint8(1) + } + } + } + return res +} + +// C documentation +// +// /* +// ** This function is an optimized version of sqlite3VdbeRecordCompare() +// ** that (a) the first field of pPKey2 is a string, that (b) the first field +// ** uses the collation sequence BINARY and (c) that the size-of-header varint +// ** at the start of (pKey1/nKey1) fits in a single byte. +// */ +func _vdbeRecordCompareString(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aKey1 uintptr + var nCmp, nStr, res, szHdr, v1 int32 + var _ /* serial_type at bp+0 */ int32 + _, _, _, _, _, _ = aKey1, nCmp, nStr, res, szHdr, v1 + aKey1 = pKey1 + **(**int32)(__ccgo_up(bp)) = int32(libc.Int8FromUint8(**(**Tu8)(__ccgo_up(aKey1 + 1)))) + goto vrcs_restart +vrcs_restart: + ; + if **(**int32)(__ccgo_up(bp)) < int32(12) { + if **(**int32)(__ccgo_up(bp)) < 0 { + _sqlite3GetVarint32(tls, aKey1+1, bp) + if **(**int32)(__ccgo_up(bp)) >= int32(12) { + goto vrcs_restart + } + } + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) /* (pKey1/nKey1) is a number or a null */ + } else { + if !(**(**int32)(__ccgo_up(bp))&libc.Int32FromInt32(0x01) != 0) { + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2) /* (pKey1/nKey1) is a blob */ + } else { + szHdr = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aKey1))) + nStr = (**(**int32)(__ccgo_up(bp)) - int32(12)) / int32(2) + if szHdr+nStr > nKey1 { + (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = libc.Uint8FromInt32(_sqlite3CorruptError(tls, int32(92847))) + return 0 /* Corruption */ + } + if (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fn < nStr { + v1 = (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fn + } else { + v1 = nStr + } + nCmp = v1 + res = libc.Xmemcmp(tls, aKey1+uintptr(szHdr), *(*uintptr)(unsafe.Pointer(pPKey2 + 16)), libc.Uint64FromInt32(nCmp)) + if res > 0 { + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2) + } else { + if res < 0 { + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) + } else { + res = nStr - (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fn + if res == 0 { + if libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FnField) > int32(1) { + res = _sqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, int32(1)) + } else { + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fdefault_rc) + (*TUnpackedRecord)(unsafe.Pointer(pPKey2)).FeqSeen = uint8(1) + } + } else { + if res > 0 { + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2) + } else { + res = int32((*TUnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) + } + } + } + } + } + } + return res +} + +// C documentation +// +// /* +// ** A specially optimized version of vdbeSorterCompare() that assumes that +// ** the first field of each key is a TEXT value and that the collation +// ** sequence to compare them with is BINARY. +// */ +func _vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p1, p2, v1, v2 uintptr + var res, v11 int32 + var _ /* n1 at bp+0 */ int32 + var _ /* n2 at bp+4 */ int32 + _, _, _, _, _, _ = p1, p2, res, v1, v2, v11 + p1 = pKey1 + p2 = pKey2 + v1 = p1 + uintptr(**(**Tu8)(__ccgo_up(p1))) /* Pointer to value 1 */ + v2 = p2 + uintptr(**(**Tu8)(__ccgo_up(p2))) + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint32(uint32(**(**Tu8)(__ccgo_up(p1 + 1)))) + if **(**int32)(__ccgo_up(bp)) >= int32(0x80) { + _sqlite3GetVarint32(tls, p1+1, bp) + } + **(**int32)(__ccgo_up(bp + 4)) = libc.Int32FromUint32(uint32(**(**Tu8)(__ccgo_up(p2 + 1)))) + if **(**int32)(__ccgo_up(bp + 4)) >= int32(0x80) { + _sqlite3GetVarint32(tls, p2+1, bp+4) + } + if **(**int32)(__ccgo_up(bp)) < **(**int32)(__ccgo_up(bp + 4)) { + v11 = **(**int32)(__ccgo_up(bp)) + } else { + v11 = **(**int32)(__ccgo_up(bp + 4)) + } + res = libc.Xmemcmp(tls, v1, v2, libc.Uint64FromInt32((v11-int32(13))/int32(2))) + if res == 0 { + res = **(**int32)(__ccgo_up(bp)) - **(**int32)(__ccgo_up(bp + 4)) + } + if res == 0 { + if libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField) > int32(1) { + res = _vdbeSorterCompareTail(tls, pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2) + } + } else { + if **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags)) != 0 { + res = res * -int32(1) + } + } + return res +} + +// C documentation +// +// /* +// ** Flush the current contents of VdbeSorter.list to a new PMA, possibly +// ** using a background thread. +// */ +func _vdbeSorterFlushPMA(tls *libc.TLS, pSorter uintptr) (r int32) { + var aMem, pCtx, pTask uintptr + var i, iTest, nWorker, rc int32 + _, _, _, _, _, _, _ = aMem, i, iTest, nWorker, pCtx, pTask, rc + rc = SQLITE_OK + pTask = uintptr(0) /* Thread context used to create new PMA */ + nWorker = libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - int32(1) + /* Set the flag to indicate that at least one PMA has been written. + ** Or will be, anyhow. */ + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA = uint8(1) + /* Select a sub-task to sort and flush the current list of in-memory + ** records to disk. If the sorter is running in multi-threaded mode, + ** round-robin between the first (pSorter->nTask-1) tasks. Except, if + ** the background thread from a sub-tasks previous turn is still running, + ** skip it. If the first (pSorter->nTask-1) sub-tasks are all still busy, + ** fall back to using the final sub-task. The first (pSorter->nTask-1) + ** sub-tasks are preferred as they use background threads - the final + ** sub-task uses the main thread. */ + i = 0 + for { + if !(i < nWorker) { + break + } + iTest = (libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FiPrev) + i + int32(1)) % nWorker + pTask = pSorter + 96 + uintptr(iTest)*104 + if (*TSortSubtask)(unsafe.Pointer(pTask)).FbDone != 0 { + rc = _vdbeSorterJoinThread(tls, pTask) + } + if rc != SQLITE_OK || (*TSortSubtask)(unsafe.Pointer(pTask)).FpThread == uintptr(0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if rc == SQLITE_OK { + if i == nWorker { + /* Use the foreground thread for this operation */ + rc = _vdbeSorterListToPMA(tls, pSorter+96+uintptr(nWorker)*104, pSorter+56) + } else { + aMem = (*TSortSubtask)(unsafe.Pointer(pTask)).Flist.FaMemory + pCtx = pTask + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FiPrev = libc.Uint8FromInt64((int64(pTask) - t__predefined_ptrdiff_t(pSorter+96)) / 104) + (*TSortSubtask)(unsafe.Pointer(pTask)).Flist = (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = uintptr(0) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA = 0 + if aMem != 0 { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = aMem + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = _sqlite3MallocSize(tls, aMem) + } else { + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 { + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = _sqlite3Malloc(tls, libc.Uint64FromInt32((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnMemory)) + if !((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0) { + return int32(SQLITE_NOMEM) + } + } + } + rc = _vdbeSorterCreateThread(tls, pTask, __ccgo_fp(_vdbeSorterFlushThread), pCtx) + } + } + return rc +} + +// C documentation +// +// /* +// ** Join all outstanding threads launched by SorterWrite() to create +// ** level-0 PMAs. +// */ +func _vdbeSorterJoinAll(tls *libc.TLS, pSorter uintptr, rcin int32) (r int32) { + var i, rc, rc2 int32 + var pTask uintptr + _, _, _, _ = i, pTask, rc, rc2 + rc = rcin + /* This function is always called by the main user thread. + ** + ** If this function is being called after SorterRewind() has been called, + ** it is possible that thread pSorter->aTask[pSorter->nTask-1].pThread + ** is currently attempt to join one of the other threads. To avoid a race + ** condition where this thread also attempts to join the same object, join + ** thread pSorter->aTask[pSorter->nTask-1].pThread first. */ + i = libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - int32(1) + for { + if !(i >= 0) { + break + } + pTask = pSorter + 96 + uintptr(i)*104 + rc2 = _vdbeSorterJoinThread(tls, pTask) + if rc == SQLITE_OK { + rc = rc2 + } + goto _1 + _1: + ; + i = i - 1 + } + return rc +} + +// C documentation +// +// /* +// ** This function is called as part of a SorterRewind() operation on a sorter +// ** that has already written two or more level-0 PMAs to one or more temp +// ** files. It builds a tree of MergeEngine/IncrMerger/PmaReader objects that +// ** can be used to incrementally merge all PMAs on disk. +// ** +// ** If successful, SQLITE_OK is returned and *ppOut set to point to the +// ** MergeEngine object at the root of the tree before returning. Or, if an +// ** error occurs, an SQLite error code is returned and the final value +// ** of *ppOut is undefined. +// */ +func _vdbeSorterMergeTreeBuild(tls *libc.TLS, pSorter uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, iSeq, iTask, nDepth, nReader, rc, v3 int32 + var pMain, pTask uintptr + var _ /* iReadOff at bp+8 */ Ti64 + var _ /* pMerger at bp+16 */ uintptr + var _ /* pRoot at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _ = i, iSeq, iTask, nDepth, nReader, pMain, pTask, rc, v3 + pMain = uintptr(0) + rc = SQLITE_OK + /* If the sorter uses more than one task, then create the top-level + ** MergeEngine here. This MergeEngine will read data from exactly + ** one PmaReader per sub-task. */ + if libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > int32(1) { + pMain = _vdbeMergeEngineNew(tls, libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) + if pMain == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + iTask = 0 + for { + if !(rc == SQLITE_OK && iTask < libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) { + break + } + pTask = pSorter + 96 + uintptr(iTask)*104 + if libc.Bool(false) || (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Root node of tree for this task */ + nDepth = _vdbeSorterTreeDepth(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA) + **(**Ti64)(__ccgo_up(bp + 8)) = 0 + if (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA <= int32(SORTER_MAX_MERGE_COUNT) { + rc = _vdbeMergeEngineLevel0(tls, pTask, (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA, bp+8, bp) + } else { + iSeq = 0 + **(**uintptr)(__ccgo_up(bp)) = _vdbeMergeEngineNew(tls, int32(SORTER_MAX_MERGE_COUNT)) + if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + i = 0 + for { + if !(i < (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA && rc == SQLITE_OK) { + break + } + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) /* Number of level-0 PMAs to merge */ + if (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA-i < int32(SORTER_MAX_MERGE_COUNT) { + v3 = (*TSortSubtask)(unsafe.Pointer(pTask)).FnPMA - i + } else { + v3 = int32(SORTER_MAX_MERGE_COUNT) + } + nReader = v3 + rc = _vdbeMergeEngineLevel0(tls, pTask, nReader, bp+8, bp+16) + if rc == SQLITE_OK { + v3 = iSeq + iSeq = iSeq + 1 + rc = _vdbeSorterAddToTree(tls, pTask, nDepth, v3, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp + 16))) + } + goto _2 + _2: + ; + i = i + int32(SORTER_MAX_MERGE_COUNT) + } + } + if rc == SQLITE_OK { + if pMain != uintptr(0) { + rc = _vdbeIncrMergerNew(tls, pTask, **(**uintptr)(__ccgo_up(bp)), (*TMergeEngine)(unsafe.Pointer(pMain)).FaReadr+uintptr(iTask)*80+72) + } else { + pMain = **(**uintptr)(__ccgo_up(bp)) + } + } else { + _vdbeMergeEngineFree(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + goto _1 + _1: + ; + iTask = iTask + 1 + } + if rc != SQLITE_OK { + _vdbeMergeEngineFree(tls, pMain) + pMain = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppOut)) = pMain + return rc +} + +// C documentation +// +// /* +// ** This function is called as part of an sqlite3VdbeSorterRewind() operation +// ** on a sorter that has written two or more PMAs to temporary files. It sets +// ** up either VdbeSorter.pMerger (for single threaded sorters) or pReader +// ** (for multi-threaded sorters) so that it can be used to iterate through +// ** all records stored in the sorter. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +// */ +func _vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, p, pIncr, pLast, pReadr, pTask0, v3 uintptr + var i, iTask, rc int32 + var xCompare TSorterCompare + var _ /* pMain at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = db, i, iTask, p, pIncr, pLast, pReadr, pTask0, rc, xCompare, v3 /* Return code */ + pTask0 = pSorter + 96 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + db = (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask0)).FpSorter)).Fdb + xCompare = _vdbeSorterGetCompare(tls, pSorter) + i = 0 + for { + if !(i < libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) { + break + } + (*(*TSortSubtask)(unsafe.Pointer(pSorter + 96 + uintptr(i)*104))).FxCompare = xCompare + goto _1 + _1: + ; + i = i + 1 + } + rc = _vdbeSorterMergeTreeBuild(tls, pSorter, bp) + if rc == SQLITE_OK { + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { + pReadr = uintptr(0) + pLast = pSorter + 96 + uintptr(libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)-int32(1))*104 + rc = _vdbeSortAllocUnpacked(tls, pLast) + if rc == SQLITE_OK { + pReadr = _sqlite3DbMallocZero(tls, db, uint64(80)) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpReader = pReadr + if pReadr == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + } + if rc == SQLITE_OK { + rc = _vdbeIncrMergerNew(tls, pLast, **(**uintptr)(__ccgo_up(bp)), pReadr+72) + if rc == SQLITE_OK { + _vdbeIncrMergerSetThreads(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr) + iTask = 0 + for { + if !(iTask < libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)-int32(1)) { + break + } + v3 = (**(**TPmaReader)(__ccgo_up((*TMergeEngine)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaReadr + uintptr(iTask)*80))).FpIncr + pIncr = v3 + if v3 != 0 { + _vdbeIncrMergerSetThreads(tls, pIncr) + } + goto _2 + _2: + ; + iTask = iTask + 1 + } + iTask = 0 + for { + if !(rc == SQLITE_OK && iTask < libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) { + break + } + /* Check that: + ** + ** a) The incremental merge object is configured to use the + ** right task, and + ** b) If it is using task (nTask-1), it is configured to run + ** in single-threaded mode. This is important, as the + ** root merge (INCRINIT_ROOT) will be using the same task + ** object. + */ + p = (*TMergeEngine)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaReadr + uintptr(iTask)*80 + rc = _vdbePmaReaderIncrInit(tls, p, int32(INCRINIT_TASK)) + goto _4 + _4: + ; + iTask = iTask + 1 + } + } + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + if rc == SQLITE_OK { + rc = _vdbePmaReaderIncrMergeInit(tls, pReadr, int32(INCRINIT_ROOT)) + } + } else { + rc = _vdbeMergeEngineInit(tls, pTask0, **(**uintptr)(__ccgo_up(bp)), INCRINIT_NORMAL) + (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpMerger = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + if rc != SQLITE_OK { + _vdbeMergeEngineFree(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Copy as much content as we can from the WAL back into the database file +// ** in response to an sqlite3_wal_checkpoint() request or the equivalent. +// ** +// ** The amount of information copies from WAL to database might be limited +// ** by active readers. This routine will never overwrite a database page +// ** that a concurrent reader might be using. +// ** +// ** All I/O barrier operations (a.k.a fsyncs) occur in this routine when +// ** SQLite is in WAL-mode in synchronous=NORMAL. That means that if +// ** checkpoints are always run by a background thread or background +// ** process, foreground threads will never block on a lengthy fsync call. +// ** +// ** Fsync is called on the WAL before writing content out of the WAL and +// ** into the database. This ensures that if the new content is persistent +// ** in the WAL and can be recovered following a power-loss or hard reset. +// ** +// ** Fsync is also called on the database file if (and only if) the entire +// ** WAL content is copied into the database file. This second fsync makes +// ** it safe to delete the WAL since the new content will persist in the +// ** database file. +// ** +// ** This routine uses and updates the nBackfill field of the wal-index header. +// ** This is the only routine that will increase the value of nBackfill. +// ** (A WAL reset or recovery will revert nBackfill to zero, but not increase +// ** its value.) +// ** +// ** The caller must be holding sufficient locks to ensure that no other +// ** checkpoint is running (in any other thread or process) at the same +// ** time. +// */ +func _walCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, __ccgo_fp_xBusy uintptr, pBusyArg uintptr, sync_flags int32, zBuf uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bChg, i, rc, szPage, v3 int32 + var iMark, mxPage, mxSafeFrame, nBackfill, y Tu32 + var iOffset, szDb Ti64 + var pInfo, pLive uintptr + var v2 uint32 + var v4 bool + var _ /* iDbpage at bp+8 */ Tu32 + var _ /* iFrame at bp+12 */ Tu32 + var _ /* nReq at bp+16 */ Ti64 + var _ /* nSize at bp+24 */ Ti64 + var _ /* pIter at bp+0 */ uintptr + var _ /* salt1 at bp+32 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bChg, i, iMark, iOffset, mxPage, mxSafeFrame, nBackfill, pInfo, pLive, rc, szDb, szPage, y, v2, v3, v4 + rc = SQLITE_OK /* Database page-size */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Wal iterator context */ + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(0) /* Next database page to write */ + **(**Tu32)(__ccgo_up(bp + 12)) = uint32(0) /* The checkpoint status information */ + szPage = _walPagesize(tls, pWal) + pInfo = _walCkptInfo(tls, pWal) + if (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { + /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked + ** in the SQLITE_CHECKPOINT_PASSIVE mode. */ + /* Compute in mxSafeFrame the index of the last frame of the WAL that is + ** safe to write into the database. Frames beyond mxSafeFrame might + ** overwrite database pages that are in use by active readers and thus + ** cannot be backfilled from the WAL. + */ + mxSafeFrame = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + mxPage = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage + i = int32(1) + for { + if !(i < libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)) { + break + } + y = libc.AtomicLoadNUint32(pInfo+4+uintptr(i)*4, libc.Int32FromInt32(__ATOMIC_RELAXED)) + if mxSafeFrame > y { + rc = _walBusyLock(tls, pWal, __ccgo_fp_xBusy, pBusyArg, int32(3)+i, int32(1)) + if rc == SQLITE_OK { + if i == int32(1) { + v2 = mxSafeFrame + } else { + v2 = uint32(READMARK_NOT_USED) + } + iMark = v2 + libc.AtomicStoreNUint32(pInfo+4+uintptr(i)*4, iMark, libc.Int32FromInt32(__ATOMIC_RELAXED)) + _walUnlockExclusive(tls, pWal, int32(3)+i, int32(1)) + } else { + if rc == int32(SQLITE_BUSY) { + mxSafeFrame = y + __ccgo_fp_xBusy = uintptr(0) + } else { + goto walcheckpoint_out + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + /* Allocate the iterator */ + if (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < mxSafeFrame { + rc = _walIteratorInit(tls, pWal, (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill, bp) + } + if v4 = **(**uintptr)(__ccgo_up(bp)) != 0; v4 { + v3 = _walBusyLock(tls, pWal, __ccgo_fp_xBusy, pBusyArg, libc.Int32FromInt32(3)+libc.Int32FromInt32(0), int32(1)) + rc = v3 + } + if v4 && v3 == SQLITE_OK { + nBackfill = (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill + pLive = _walIndexHdr(tls, pWal) + /* Now that read-lock slot 0 is locked, check that the wal has not been + ** wrapped since the header was read for this checkpoint. If it was, then + ** there was no work to do anyway. In this case the + ** (pInfo->nBackfillhdr.mxFrame) test above only passed because + ** pInfo->nBackfill had already been set to 0 by the writer that wrapped + ** the wal file. It would also be dangerous to proceed, as there may be + ** fewer than pWal->hdr.mxFrame valid frames in the wal file. */ + bChg = libc.Xmemcmp(tls, pLive+32, pWal+72+32, uint64(8)) + if 0 == bChg { + (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = mxSafeFrame + /* Sync the WAL to disk */ + rc = _sqlite3OsSync(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, sync_flags>>int32(2)&int32(0x03)) + /* If the database may grow as a result of this checkpoint, hint + ** about the eventual size of the db file to the VFS layer. + */ + if rc == SQLITE_OK { + **(**Ti64)(__ccgo_up(bp + 16)) = libc.Int64FromUint32(mxPage) * int64(szPage) /* Current size of database file */ + _sqlite3OsFileControl(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, int32(SQLITE_FCNTL_CKPT_START), uintptr(0)) + rc = _sqlite3OsFileSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, bp+24) + if rc == SQLITE_OK && **(**Ti64)(__ccgo_up(bp + 24)) < **(**Ti64)(__ccgo_up(bp + 16)) { + if **(**Ti64)(__ccgo_up(bp + 24))+int64(65536)+libc.Int64FromUint32((*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame)*int64(szPage) < **(**Ti64)(__ccgo_up(bp + 16)) { + /* If the size of the final database is larger than the current + ** database plus the amount of data in the wal file, plus the + ** maximum size of the pending-byte page (65536 bytes), then + ** must be corruption somewhere. */ + rc = _sqlite3CorruptError(tls, int32(69730)) + } else { + _sqlite3OsFileControlHint(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, int32(SQLITE_FCNTL_SIZE_HINT), bp+16) + } + } + } + /* Iterate through the contents of the WAL, copying data to the + ** db file */ + for rc == SQLITE_OK && 0 == _walIteratorNext(tls, **(**uintptr)(__ccgo_up(bp)), bp+8, bp+12) { + if libc.AtomicLoadNInt32(db+432, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + v3 = int32(SQLITE_NOMEM) + } else { + v3 = int32(SQLITE_INTERRUPT) + } + rc = v3 + break + } + if **(**Tu32)(__ccgo_up(bp + 12)) <= nBackfill || **(**Tu32)(__ccgo_up(bp + 12)) > mxSafeFrame || **(**Tu32)(__ccgo_up(bp + 8)) > mxPage { + continue + } + iOffset = int64(WAL_HDRSIZE) + libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp + 12))-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + int64(WAL_FRAME_HDRSIZE) + /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */ + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, zBuf, szPage, iOffset) + if rc != SQLITE_OK { + break + } + iOffset = libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp + 8))-libc.Uint32FromInt32(1)) * int64(szPage) + rc = _sqlite3OsWrite(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, zBuf, szPage, iOffset) + if rc != SQLITE_OK { + break + } + } + _sqlite3OsFileControl(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, int32(SQLITE_FCNTL_CKPT_DONE), uintptr(0)) + /* If work was actually accomplished... */ + if rc == SQLITE_OK { + if mxSafeFrame == (*TWalIndexHdr)(unsafe.Pointer(_walIndexHdr(tls, pWal))).FmxFrame { + szDb = libc.Int64FromUint32((*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage) * int64(szPage) + rc = _sqlite3OsTruncate(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, szDb) + if rc == SQLITE_OK { + rc = _sqlite3OsSync(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, sync_flags>>int32(2)&int32(0x03)) + } + } + if rc == SQLITE_OK { + libc.AtomicStoreNUint32(pInfo, mxSafeFrame, libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + } + } + /* Release the reader lock held while backfilling */ + _walUnlockExclusive(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(0), int32(1)) + } + if rc == int32(SQLITE_BUSY) { + /* Reset the return code so as not to report a checkpoint failure + ** just because there are active readers. */ + rc = SQLITE_OK + } + } + /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the + ** entire wal file has been copied into the database file, then block + ** until all readers have finished using the wal file. This ensures that + ** the next process to write to the database restarts the wal file. + */ + if rc == SQLITE_OK && eMode != SQLITE_CHECKPOINT_PASSIVE { + if (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { + rc = int32(SQLITE_BUSY) + } else { + if eMode >= int32(SQLITE_CHECKPOINT_RESTART) { + Xsqlite3_randomness(tls, int32(4), bp+32) + rc = _walBusyLock(tls, pWal, __ccgo_fp_xBusy, pBusyArg, libc.Int32FromInt32(3)+libc.Int32FromInt32(1), libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)-libc.Int32FromInt32(1)) + if rc == SQLITE_OK { + if eMode == int32(SQLITE_CHECKPOINT_TRUNCATE) { + /* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as + ** SQLITE_CHECKPOINT_RESTART with the addition that it also + ** truncates the log file to zero bytes just prior to a + ** successful return. + ** + ** In theory, it might be safe to do this without updating the + ** wal-index header in shared memory, as all subsequent reader or + ** writer clients should see that the entire log file has been + ** checkpointed and behave accordingly. This seems unsafe though, + ** as it would leave the system in a state where the contents of + ** the wal-index header do not match the contents of the + ** file-system. To avoid this, update the wal-index header to + ** indicate that the log file contains zero valid frames. */ + _walRestartHdr(tls, pWal, **(**Tu32)(__ccgo_up(bp + 32))) + rc = _sqlite3OsTruncate(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, 0) + } + _walUnlockExclusive(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(1), libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)-libc.Int32FromInt32(1)) + } + } + } + } + goto walcheckpoint_out +walcheckpoint_out: + ; + _walIteratorFree(tls, **(**uintptr)(__ccgo_up(bp))) + return rc +} + +// C documentation +// +// /* +// ** Search the wal file for page pgno. If found, set *piRead to the frame that +// ** contains the page. Otherwise, if pgno is not in the wal file, set *piRead +// ** to zero. +// ** +// ** Return SQLITE_OK if successful, or an error code if an error occurs. If an +// ** error does occur, the final value of *piRead is undefined. +// */ +func _walFindFrame(tls *libc.TLS, pWal uintptr, pgno TPgno, piRead uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iFrame, iH, iLast, iRead, v2 Tu32 + var iHash, iKey, iMinHash, nCollide, rc, v3 int32 + var _ /* sLoc at bp+0 */ TWalHashLoc + _, _, _, _, _, _, _, _, _, _, _ = iFrame, iH, iHash, iKey, iLast, iMinHash, iRead, nCollide, rc, v2, v3 + iRead = uint32(0) /* If !=0, WAL frame to return data from */ + iLast = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + /* This routine is only be called from within a read transaction. */ + /* If the "last page" field of the wal-index header snapshot is 0, then + ** no data will be read from the wal under any circumstances. Return early + ** in this case as an optimization. Likewise, if pWal->readLock==0, + ** then the WAL is ignored by the reader so return early, as if the + ** WAL were empty. + */ + if iLast == uint32(0) || int32((*TWal)(unsafe.Pointer(pWal)).FreadLock) == 0 && libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0 { + **(**Tu32)(__ccgo_up(piRead)) = uint32(0) + return SQLITE_OK + } + /* Search the hash table or tables for an entry matching page number + ** pgno. Each iteration of the following for() loop searches one + ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames). + ** + ** This code might run concurrently to the code in walIndexAppend() + ** that adds entries to the wal-index (and possibly to this hash + ** table). This means the value just read from the hash + ** slot (aHash[iKey]) may have been added before or after the + ** current read transaction was opened. Values added after the + ** read transaction was opened may have been written incorrectly - + ** i.e. these slots may contain garbage data. However, we assume + ** that any slots written before the current read transaction was + ** opened remain unmodified. + ** + ** For the reasons above, the if(...) condition featured in the inner + ** loop of the following block is more stringent that would be required + ** if we had exclusive access to the hash-table: + ** + ** (aPgno[iFrame]==pgno): + ** This condition filters out normal hash-table collisions. + ** + ** (iFrame<=iLast): + ** This condition filters out entries that were added to the hash + ** table after the current read-transaction had started. + */ + iMinHash = _walFramePage(tls, (*TWal)(unsafe.Pointer(pWal)).FminFrame) + iHash = _walFramePage(tls, iLast) + for { + if !(iHash >= iMinHash) { + break + } + rc = _walHashGet(tls, pWal, iHash, bp) + if rc != SQLITE_OK { + return rc + } + nCollide = libc.Int32FromInt32(HASHTABLE_NPAGE) * libc.Int32FromInt32(2) + iKey = _walHash(tls, pgno) + for { + v2 = uint32(libc.AtomicLoadNUint16((**(**TWalHashLoc)(__ccgo_up(bp))).FaHash+uintptr(iKey)*2, libc.Int32FromInt32(__ATOMIC_RELAXED))) + iH = v2 + if !(v2 != uint32(0)) { + break + } + iFrame = iH + (**(**TWalHashLoc)(__ccgo_up(bp))).FiZero + if iFrame <= iLast && iFrame >= (*TWal)(unsafe.Pointer(pWal)).FminFrame && **(**Tu32)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp))).FaPgno + uintptr((iH-uint32(1))&libc.Uint32FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)-libc.Int32FromInt32(1)))*4)) == pgno { + iRead = iFrame + } + v3 = nCollide + nCollide = nCollide - 1 + if v3 == 0 { + **(**Tu32)(__ccgo_up(piRead)) = uint32(0) + return _sqlite3CorruptError(tls, int32(71037)) + } + iKey = _walNextHash(tls, iKey) + } + if iRead != 0 { + break + } + goto _1 + _1: + ; + iHash = iHash - 1 + } + **(**Tu32)(__ccgo_up(piRead)) = iRead + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return the number of the wal-index page that contains the hash-table +// ** and page-number array that contain entries corresponding to WAL frame +// ** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages +// ** are numbered starting from 0. +// */ +func _walFramePage(tls *libc.TLS, iFrame Tu32) (r int32) { + var iHash int32 + _ = iHash + iHash = libc.Int32FromUint64((uint64(iFrame+uint32(HASHTABLE_NPAGE)) - (libc.Uint64FromInt32(HASHTABLE_NPAGE) - (libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4)) - uint64(1)) / uint64(HASHTABLE_NPAGE)) + return iHash +} + +// C documentation +// +// /* +// ** Return pointers to the hash table and page number array stored on +// ** page iHash of the wal-index. The wal-index is broken into 32KB pages +// ** numbered starting from 0. +// ** +// ** Set output variable pLoc->aHash to point to the start of the hash table +// ** in the wal-index file. Set pLoc->iZero to one less than the frame +// ** number of the first frame indexed by this hash table. If a +// ** slot in the hash table is set to N, it refers to frame number +// ** (pLoc->iZero+N) in the log. +// ** +// ** Finally, set pLoc->aPgno so that pLoc->aPgno[0] is the page number of the +// ** first frame indexed by the hash table, frame (pLoc->iZero). +// */ +func _walHashGet(tls *libc.TLS, pWal uintptr, iHash int32, pLoc uintptr) (r int32) { + var rc int32 + _ = rc /* Return code */ + rc = _walIndexPage(tls, pWal, iHash, pLoc+8) + if (*TWalHashLoc)(unsafe.Pointer(pLoc)).FaPgno != 0 { + (*TWalHashLoc)(unsafe.Pointer(pLoc)).FaHash = (*TWalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + 4096*4 + if iHash == 0 { + (*TWalHashLoc)(unsafe.Pointer(pLoc)).FaPgno = (*TWalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + uintptr((libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4))*4 + (*TWalHashLoc)(unsafe.Pointer(pLoc)).FiZero = uint32(0) + } else { + (*TWalHashLoc)(unsafe.Pointer(pLoc)).FiZero = uint32(libc.Uint64FromInt32(HASHTABLE_NPAGE) - (libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4) + libc.Uint64FromInt32((iHash-int32(1))*int32(HASHTABLE_NPAGE))) + } + } else { + if rc == SQLITE_OK { + rc = int32(SQLITE_ERROR) + } + } + return rc +} + +// C documentation +// +// /* +// ** Close an open wal-index. +// */ +func _walIndexClose(tls *libc.TLS, pWal uintptr, isDelete int32) { + var i int32 + _ = i + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) == int32(WAL_HEAPMEMORY_MODE) || (*TWal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0 { + i = 0 + for { + if !(i < (*TWal)(unsafe.Pointer(pWal)).FnWiData) { + break + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8))) + **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8)) = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + } + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) != int32(WAL_HEAPMEMORY_MODE) { + _sqlite3OsShmUnmap(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, isDelete) + } +} + +// C documentation +// +// /* +// ** Find the smallest page number out of all pages held in the WAL that +// ** has not been returned by any prior invocation of this method on the +// ** same WalIterator object. Write into *piFrame the frame index where +// ** that page was last written into the WAL. Write into *piPage the page +// ** number. +// ** +// ** Return 0 on success. If there are no pages in the WAL with a page +// ** number larger than *piPage, then return 1. +// */ +func _walIteratorNext(tls *libc.TLS, p uintptr, piPage uintptr, piFrame uintptr) (r int32) { + var i int32 + var iMin, iPg, iRet, v2 Tu32 + var pSegment uintptr + _, _, _, _, _, _ = i, iMin, iPg, iRet, pSegment, v2 /* Result pgno must be greater than iMin */ + iRet = uint32(0xFFFFFFFF) /* For looping through segments */ + iMin = (*TWalIterator)(unsafe.Pointer(p)).FiPrior + i = (*TWalIterator)(unsafe.Pointer(p)).FnSegment - int32(1) + for { + if !(i >= 0) { + break + } + pSegment = p + 8 + uintptr(i)*32 + for (*TWalSegment)(unsafe.Pointer(pSegment)).FiNext < (*TWalSegment)(unsafe.Pointer(pSegment)).FnEntry { + iPg = **(**Tu32)(__ccgo_up((*TWalSegment)(unsafe.Pointer(pSegment)).FaPgno + uintptr(**(**Tht_slot)(__ccgo_up((*TWalSegment)(unsafe.Pointer(pSegment)).FaIndex + uintptr((*TWalSegment)(unsafe.Pointer(pSegment)).FiNext)*2)))*4)) + if iPg > iMin { + if iPg < iRet { + iRet = iPg + **(**Tu32)(__ccgo_up(piFrame)) = libc.Uint32FromInt32((*TWalSegment)(unsafe.Pointer(pSegment)).FiZero + libc.Int32FromUint16(**(**Tht_slot)(__ccgo_up((*TWalSegment)(unsafe.Pointer(pSegment)).FaIndex + uintptr((*TWalSegment)(unsafe.Pointer(pSegment)).FiNext)*2)))) + } + break + } + (*TWalSegment)(unsafe.Pointer(pSegment)).FiNext = (*TWalSegment)(unsafe.Pointer(pSegment)).FiNext + 1 + } + goto _1 + _1: + ; + i = i - 1 + } + v2 = iRet + (*TWalIterator)(unsafe.Pointer(p)).FiPrior = v2 + **(**Tu32)(__ccgo_up(piPage)) = v2 + return libc.BoolInt32(iRet == uint32(0xFFFFFFFF)) +} + +// C documentation +// +// /* +// ** This function is called as part of committing a transaction within which +// ** one or more frames have been overwritten. It updates the checksums for +// ** all frames written to the wal file by the current transaction starting +// ** with the earliest to have been overwritten. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +// */ +func _walRewriteChecksums(tls *libc.TLS, pWal uintptr, iLast Tu32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aBuf uintptr + var iCksumOff, iOff Ti64 + var iPgno, iRead, nDbSize Tu32 + var rc, szPage int32 + var _ /* aFrame at bp+0 */ [24]Tu8 + _, _, _, _, _, _, _, _ = aBuf, iCksumOff, iOff, iPgno, iRead, nDbSize, rc, szPage + szPage = libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage) /* Database page size */ + rc = SQLITE_OK + aBuf = Xsqlite3_malloc(tls, szPage+int32(WAL_FRAME_HDRSIZE)) + if aBuf == uintptr(0) { + return int32(SQLITE_NOMEM) + } + /* Find the checksum values to use as input for the recalculating the + ** first checksum. If the first frame is frame 1 (implying that the current + ** transaction restarted the wal file), these values must be read from the + ** wal-file header. Otherwise, read them from the frame header of the + ** previous frame. */ + if (*TWal)(unsafe.Pointer(pWal)).FiReCksum == uint32(1) { + iCksumOff = int64(24) + } else { + iCksumOff = int64(WAL_HDRSIZE) + libc.Int64FromUint32((*TWal)(unsafe.Pointer(pWal)).FiReCksum-libc.Uint32FromInt32(1)-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + int64(16) + } + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, libc.Int32FromUint64(libc.Uint64FromInt64(4)*libc.Uint64FromInt32(2)), iCksumOff) + **(**Tu32)(__ccgo_up(pWal + 72 + 24)) = _sqlite3Get4byte(tls, aBuf) + **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) = _sqlite3Get4byte(tls, aBuf+uintptr(4)) + iRead = (*TWal)(unsafe.Pointer(pWal)).FiReCksum + (*TWal)(unsafe.Pointer(pWal)).FiReCksum = uint32(0) + for { + if !(rc == SQLITE_OK && iRead <= iLast) { + break + } + iOff = libc.Int64FromInt32(WAL_HDRSIZE) + libc.Int64FromUint32(iRead-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, szPage+int32(WAL_FRAME_HDRSIZE), iOff) + if rc == SQLITE_OK { + iPgno = _sqlite3Get4byte(tls, aBuf) + nDbSize = _sqlite3Get4byte(tls, aBuf+4) + _walEncodeFrame(tls, pWal, iPgno, nDbSize, aBuf+24, bp) + rc = _sqlite3OsWrite(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp, int32(24), iOff) + } + goto _1 + _1: + ; + iRead = iRead + 1 + } + Xsqlite3_free(tls, aBuf) + return rc +} + +// C documentation +// +// /* +// ** This function does the work of sqlite3WalSnapshotRecover(). +// */ +func _walSnapshotRecover(tls *libc.TLS, pWal uintptr, pBuf1 uintptr, pBuf2 uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, pgno Tu32 + var iDbOff, iWalOff Ti64 + var pInfo uintptr + var rc, szPage int32 + var _ /* sLoc at bp+8 */ TWalHashLoc + var _ /* szDb at bp+0 */ Ti64 + _, _, _, _, _, _, _ = i, iDbOff, iWalOff, pInfo, pgno, rc, szPage + szPage = libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage) /* Size of db file in bytes */ + rc = _sqlite3OsFileSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, bp) + if rc == SQLITE_OK { + pInfo = _walCkptInfo(tls, pWal) + i = (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted + i = (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted + for { + if !(i > libc.AtomicLoadNUint32(pInfo, libc.Int32FromInt32(__ATOMIC_RELAXED))) { + break + } /* Offset of wal file entry */ + rc = _walHashGet(tls, pWal, _walFramePage(tls, i), bp+8) + if rc != SQLITE_OK { + break + } + pgno = **(**Tu32)(__ccgo_up((**(**TWalHashLoc)(__ccgo_up(bp + 8))).FaPgno + uintptr(i-(**(**TWalHashLoc)(__ccgo_up(bp + 8))).FiZero-uint32(1))*4)) + iDbOff = libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1)) * int64(szPage) + if iDbOff+int64(szPage) <= **(**Ti64)(__ccgo_up(bp)) { + iWalOff = int64(WAL_HDRSIZE) + libc.Int64FromUint32(i-libc.Uint32FromInt32(1))*int64(szPage+libc.Int32FromInt32(WAL_FRAME_HDRSIZE)) + int64(WAL_FRAME_HDRSIZE) + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, pBuf1, szPage, iWalOff) + if rc == SQLITE_OK { + rc = _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, pBuf2, szPage, iDbOff) + } + if rc != SQLITE_OK || 0 == libc.Xmemcmp(tls, pBuf1, pBuf2, libc.Uint64FromInt32(szPage)) { + break + } + } + (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = i - uint32(1) + goto _1 + _1: + ; + i = i - 1 + } + } + return rc +} + +// C documentation +// +// /* +// ** Attempt to start a read transaction. This might fail due to a race or +// ** other transient condition. When that happens, it returns WAL_RETRY to +// ** indicate to the caller that it is safe to retry immediately. +// ** +// ** On success return SQLITE_OK. On a permanent failure (such an +// ** I/O error or an SQLITE_BUSY because another process is running +// ** recovery) return a positive error code. +// ** +// ** The useWal parameter is true to force the use of the WAL and disable +// ** the case where the WAL is bypassed because it has been completely +// ** checkpointed. If useWal==0 then this routine calls walIndexReadHdr() +// ** to make a copy of the wal-index header into pWal->hdr. If the +// ** wal-index header has changed, *pChanged is set to 1 (as an indication +// ** to the caller that the local page cache is obsolete and needs to be +// ** flushed.) When useWal==1, the wal-index header is assumed to already +// ** be loaded and the pChanged parameter is unused. +// ** +// ** The caller must set the cnt parameter to the number of prior calls to +// ** this routine during the current read attempt that returned WAL_RETRY. +// ** This routine will start taking more aggressive measures to clear the +// ** race conditions after multiple WAL_RETRY returns, and after an excessive +// ** number of errors will ultimately return SQLITE_PROTOCOL. The +// ** SQLITE_PROTOCOL return indicates that some other process has gone rogue +// ** and is not honoring the locking protocol. There is a vanishingly small +// ** chance that SQLITE_PROTOCOL could be returned because of a run of really +// ** bad luck when there is lots of contention for the wal-index, but that +// ** possibility is so small that it can be safely neglected, we believe. +// ** +// ** On success, this routine obtains a read lock on +// ** WAL_READ_LOCK(pWal->readLock). The pWal->readLock integer is +// ** in the range 0 <= pWal->readLock < WAL_NREADER. If pWal->readLock==(-1) +// ** that means the Wal does not hold any read lock. The reader must not +// ** access any database page that is modified by a WAL frame up to and +// ** including frame number aReadMark[pWal->readLock]. The reader will +// ** use WAL frames up to and including pWal->hdr.mxFrame if pWal->readLock>0 +// ** Or if pWal->readLock==0, then the reader will ignore the WAL +// ** completely and get all content directly from the database file. +// ** If the useWal parameter is 1 then the WAL will never be ignored and +// ** this routine will always set pWal->readLock>0 on success. +// ** When the read transaction is completed, the caller must release the +// ** lock on WAL_READ_LOCK(pWal->readLock) and set pWal->readLock to -1. +// ** +// ** This routine uses the nBackfill and aReadMark[] fields of the header +// ** to select a particular WAL_READ_LOCK() that strives to let the +// ** checkpoint process do as much work as possible. This routine might +// ** update values of the aReadMark[] array in the header, but if it does +// ** so it takes care to hold an exclusive lock on the corresponding +// ** WAL_READ_LOCK() while changing values. +// */ +func _walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32, pCnt uintptr) (r int32) { + var cnt, i, mxI, nDelay, rc, v1 int32 + var mxFrame, mxReadMark, thisMark Tu32 + var pInfo uintptr + _, _, _, _, _, _, _, _, _, _ = cnt, i, mxFrame, mxI, mxReadMark, nDelay, pInfo, rc, thisMark, v1 /* Checkpoint information in wal-index */ + rc = SQLITE_OK /* Return code */ + /* Not currently locked */ + /* useWal may only be set for read/write connections */ + /* Take steps to avoid spinning forever if there is a protocol error. + ** + ** Circumstances that cause a RETRY should only last for the briefest + ** instances of time. No I/O or other system calls are done while the + ** locks are held, so the locks should not be held for very long. But + ** if we are unlucky, another process that is holding a lock might get + ** paged out or take a page-fault that is time-consuming to resolve, + ** during the few nanoseconds that it is holding the lock. In that case, + ** it might take longer than normal for the lock to free. + ** + ** After 5 RETRYs, we begin calling sqlite3OsSleep(). The first few + ** calls to sqlite3OsSleep() have a delay of 1 microsecond. Really this + ** is more of a scheduler yield than an actual delay. But on the 10th + ** an subsequent retries, the delays start becoming longer and longer, + ** so that on the 100th (and last) RETRY we delay for 323 milliseconds. + ** The total delay time before giving up is less than 10 seconds. + */ + **(**int32)(__ccgo_up(pCnt)) = **(**int32)(__ccgo_up(pCnt)) + 1 + if **(**int32)(__ccgo_up(pCnt)) > int32(5) { + nDelay = int32(1) /* Pause time in microseconds */ + cnt = **(**int32)(__ccgo_up(pCnt)) & ^libc.Int32FromInt32(WAL_RETRY_BLOCKED_MASK) + if cnt > int32(WAL_RETRY_PROTOCOL_LIMIT) { + return int32(SQLITE_PROTOCOL) + } + if **(**int32)(__ccgo_up(pCnt)) >= int32(10) { + nDelay = (cnt - int32(9)) * (cnt - int32(9)) * int32(39) + } + _sqlite3OsSleep(tls, (*TWal)(unsafe.Pointer(pWal)).FpVfs, nDelay) + **(**int32)(__ccgo_up(pCnt)) &= ^libc.Int32FromInt32(WAL_RETRY_BLOCKED_MASK) + } + if !(useWal != 0) { + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0 { + rc = _walIndexReadHdr(tls, pWal, pChanged) + } + if rc == int32(SQLITE_BUSY) { + /* If there is not a recovery running in another thread or process + ** then convert BUSY errors to WAL_RETRY. If recovery is known to + ** be running, convert BUSY to BUSY_RECOVERY. There is a race here + ** which might cause WAL_RETRY to be returned even if BUSY_RECOVERY + ** would be technically correct. But the race is benign since with + ** WAL_RETRY this routine will be called again and will probably be + ** right on the second iteration. + */ + if **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData)) == uintptr(0) { + /* This branch is taken when the xShmMap() method returns SQLITE_BUSY. + ** We assume this is a transient condition, so return WAL_RETRY. The + ** xShmMap() implementation used by the default unix and win32 VFS + ** modules may return SQLITE_BUSY due to a race condition in the + ** code that determines whether or not the shared-memory region + ** must be zeroed before the requested page is returned. + */ + rc = -int32(1) + } else { + v1 = _walLockShared(tls, pWal, int32(WAL_RECOVER_LOCK)) + rc = v1 + if SQLITE_OK == v1 { + _walUnlockShared(tls, pWal, int32(WAL_RECOVER_LOCK)) + rc = -int32(1) + } else { + if rc == int32(SQLITE_BUSY) { + rc = libc.Int32FromInt32(SQLITE_BUSY) | libc.Int32FromInt32(1)<hdr.mxFrame and lock that entry. + */ + mxReadMark = uint32(0) + mxI = 0 + mxFrame = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + if (*TWal)(unsafe.Pointer(pWal)).FpSnapshot != 0 && (*TWalIndexHdr)(unsafe.Pointer((*TWal)(unsafe.Pointer(pWal)).FpSnapshot)).FmxFrame < mxFrame { + mxFrame = (*TWalIndexHdr)(unsafe.Pointer((*TWal)(unsafe.Pointer(pWal)).FpSnapshot)).FmxFrame + } + i = int32(1) + for { + if !(i < libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)) { + break + } + thisMark = libc.AtomicLoadNUint32(pInfo+4+uintptr(i)*4, libc.Int32FromInt32(__ATOMIC_RELAXED)) + if mxReadMark <= thisMark && thisMark <= mxFrame { + mxReadMark = thisMark + mxI = i + } + goto _2 + _2: + ; + i = i + 1 + } + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FreadOnly)&int32(WAL_SHM_RDONLY) == 0 && (mxReadMark < mxFrame || mxI == 0) { + i = int32(1) + for { + if !(i < libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)) { + break + } + rc = _walLockExclusive(tls, pWal, int32(3)+i, int32(1)) + if rc == SQLITE_OK { + libc.AtomicStoreNUint32(pInfo+4+uintptr(i)*4, mxFrame, libc.Int32FromInt32(__ATOMIC_RELAXED)) + mxReadMark = mxFrame + mxI = i + _walUnlockExclusive(tls, pWal, int32(3)+i, int32(1)) + break + } else { + if rc != int32(SQLITE_BUSY) { + return rc + } + } + goto _3 + _3: + ; + i = i + 1 + } + } + if mxI == 0 { + if rc == int32(SQLITE_BUSY) { + v1 = -int32(1) + } else { + v1 = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(5)<hdr.mxFrame may have been + ** copied into the database by a checkpointer. If either of these things + ** happened, then reading the database with the current value of + ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry + ** instead. + ** + ** Before checking that the live wal-index header has not changed + ** since it was read, set Wal.minFrame to the first frame in the wal + ** file that has not yet been checkpointed. This client will not need + ** to read any frames earlier than minFrame from the wal file - they + ** can be safely read directly from the database file. + ** + ** Because a ShmBarrier() call is made between taking the copy of + ** nBackfill and checking that the wal-header in shared-memory still + ** matches the one cached in pWal->hdr, it is guaranteed that the + ** checkpointer that set nBackfill was not working with a wal-index + ** header newer than that cached in pWal->hdr. If it were, that could + ** cause a problem. The checkpointer could omit to checkpoint + ** a version of page X that lies before pWal->minFrame (call that version + ** A) on the basis that there is a newer version (version B) of the same + ** page later in the wal file. But if version B happens to like past + ** frame pWal->hdr.mxFrame - then the client would incorrectly assume + ** that it can read version A from the database file. However, since + ** we can guarantee that the checkpointer that set nBackfill could not + ** see any pages past pWal->hdr.mxFrame, this problem does not come up. + */ + (*TWal)(unsafe.Pointer(pWal)).FminFrame = libc.Uint32FromInt32(libc.Int32FromUint32(libc.AtomicLoadNUint32(pInfo, libc.Int32FromInt32(__ATOMIC_RELAXED))) + int32(1)) + _walShmBarrier(tls, pWal) + if libc.AtomicLoadNUint32(pInfo+4+uintptr(mxI)*4, libc.Int32FromInt32(__ATOMIC_RELAXED)) != mxReadMark || libc.Xmemcmp(tls, _walIndexHdr(tls, pWal), pWal+72, uint64(48)) != 0 { + _walUnlockShared(tls, pWal, int32(3)+mxI) + return -int32(1) + } else { + (*TWal)(unsafe.Pointer(pWal)).FreadLock = int16(mxI) + } + return rc +} + +// C documentation +// +// /* +// ** Write out a single frame of the WAL +// */ +func _walWriteOneFrame(tls *libc.TLS, p uintptr, pPage uintptr, nTruncate int32, iOffset Tsqlite3_int64) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pData uintptr + var rc int32 + var _ /* aFrame at bp+0 */ [24]Tu8 + _, _ = pData, rc /* Buffer to assemble frame-header in */ + pData = (*TPgHdr)(unsafe.Pointer(pPage)).FpData + _walEncodeFrame(tls, (*TWalWriter)(unsafe.Pointer(p)).FpWal, (*TPgHdr)(unsafe.Pointer(pPage)).Fpgno, libc.Uint32FromInt32(nTruncate), pData, bp) + rc = _walWriteToLog(tls, p, bp, int32(24), iOffset) + if rc != 0 { + return rc + } + /* Write the page data */ + rc = _walWriteToLog(tls, p, pData, (*TWalWriter)(unsafe.Pointer(p)).FszPage, libc.Int64FromUint64(libc.Uint64FromInt64(iOffset)+uint64(24))) + return rc +} + +// C documentation +// +// /* +// ** Add either a LIMIT (if eMatchOp==SQLITE_INDEX_CONSTRAINT_LIMIT) or +// ** OFFSET (if eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET) term to the +// ** where-clause passed as the first argument. The value for the term +// ** is found in register iReg. +// ** +// ** In the common case where the value is a simple integer +// ** (example: "LIMIT 5 OFFSET 10") then the expression codes as a +// ** TK_INTEGER so that it will be available to sqlite3_vtab_rhs_value(). +// ** If not, then it codes as a TK_REGISTER expression. +// */ +func _whereAddLimitExpr(tls *libc.TLS, pWC uintptr, iReg int32, pExpr uintptr, iCsr int32, eMatchOp int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pNew, pParse, pTerm, pVal, pVal1 uintptr + var idx int32 + var _ /* iVal at bp+0 */ int32 + _, _, _, _, _, _, _ = db, idx, pNew, pParse, pTerm, pVal, pVal1 + pParse = (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + **(**int32)(__ccgo_up(bp)) = 0 + if _sqlite3ExprIsInteger(tls, pExpr, bp, pParse) != 0 && **(**int32)(__ccgo_up(bp)) >= 0 { + pVal = _sqlite3ExprInt32(tls, db, **(**int32)(__ccgo_up(bp))) + if pVal == uintptr(0) { + return + } + pNew = _sqlite3PExpr(tls, pParse, int32(TK_MATCH), uintptr(0), pVal) + } else { + pVal1 = _sqlite3ExprAlloc(tls, db, int32(TK_REGISTER), uintptr(0), 0) + if pVal1 == uintptr(0) { + return + } + (*TExpr)(unsafe.Pointer(pVal1)).FiTable = iReg + pNew = _sqlite3PExpr(tls, pParse, int32(TK_MATCH), uintptr(0), pVal1) + } + if pNew != 0 { + idx = _whereClauseInsert(tls, pWC, pNew, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_DYNAMIC)|libc.Int32FromInt32(TERM_VIRTUAL))) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idx)*56 + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = iCsr + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(WO_AUX) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp = libc.Uint8FromInt32(eMatchOp) + } +} + +// C documentation +// +// /* +// ** The pTruth expression is always true because it is the WHERE clause +// ** a partial index that is driving a query loop. Look through all of the +// ** WHERE clause terms on the query, and if any of those terms must be +// ** true because pTruth is true, then mark those WHERE clause terms as +// ** coded. +// */ +func _whereApplyPartialIndexConstraints(tls *libc.TLS, pTruth uintptr, iTabCur int32, pWC uintptr) { + var i int32 + var pExpr, pTerm, v2 uintptr + _, _, _, _ = i, pExpr, pTerm, v2 + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pTruth)).Fop) == int32(TK_AND) { + _whereApplyPartialIndexConstraints(tls, (*TExpr)(unsafe.Pointer(pTruth)).FpLeft, iTabCur, pWC) + pTruth = (*TExpr)(unsafe.Pointer(pTruth)).FpRight + } + i = 0 + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(i < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_CODED) != 0 { + goto _1 + } + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if _sqlite3ExprCompare(tls, uintptr(0), pExpr, pTruth, iTabCur) == 0 { + v2 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(TERM_CODED)) + } + goto _1 + _1: + ; + i = i + 1 + pTerm += 56 + } +} + +// C documentation +// +// /* +// ** Check to see if there are any SEARCH loops that might benefit from +// ** using a Bloom filter. Consider a Bloom filter if: +// ** +// ** (1) The SEARCH happens more than N times where N is the number +// ** of rows in the table that is being considered for the Bloom +// ** filter. +// ** (2) Some searches are expected to find zero rows. (This is determined +// ** by the WHERE_SELFCULL flag on the term.) +// ** (3) Bloom-filter processing is not disabled. (Checked by the +// ** caller.) +// ** (4) The size of the table being searched is known by ANALYZE. +// ** +// ** This block of code merely checks to see if a Bloom filter would be +// ** appropriate, and if so sets the WHERE_BLOOMFILTER flag on the +// ** WhereLoop. The implementation of the Bloom filter comes further +// ** down where the code for each WhereLoop is generated. +// */ +func _whereCheckIfBloomFilterIsUseful(tls *libc.TLS, pWInfo uintptr) { + var i int32 + var nSearch TLogEst + var pItem, pLoop, pTab uintptr + var reqFlags uint32 + _, _, _, _, _, _ = i, nSearch, pItem, pLoop, pTab, reqFlags + nSearch = 0 + i = 0 + for { + if !(i < libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)) { + break + } + pLoop = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(i)*112))).FpWLoop + reqFlags = libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_SELFCULL) | libc.Int32FromInt32(WHERE_COLUMN_EQ)) + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pLoop)).FiTab)*80 + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasStat1) == uint32(0) { + break + } + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_MaybeReanalyze) + if i >= int32(1) && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&reqFlags == reqFlags && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_INDEXED)) != uint32(0) { + if int32(nSearch) > int32((*TTable)(unsafe.Pointer(pTab)).FnRowLogEst) { + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_BLOOMFILTER) + **(**Tu32)(__ccgo_up(pLoop + 48)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(WHERE_IDX_ONLY)) + } + } + nSearch = int16(int32(nSearch) + int32((*TWhereLoop)(unsafe.Pointer(pLoop)).FnOut)) + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Estimate the number of rows that will be returned based on +// ** an IN constraint where the right-hand side of the IN operator +// ** is a list of values. Example: +// ** +// ** WHERE x IN (1,2,3,4) +// ** +// ** Write the estimated row count into *pnRow and return SQLITE_OK. +// ** If unable to make an estimate, leave *pnRow unchanged and return +// ** non-zero. +// ** +// ** This routine can fail if it is unable to load a collating sequence +// ** required for string comparison, or if unable to allocate memory +// ** for a UTF conversion required for comparison. The error is stored +// ** in the pParse structure. +// */ +func _whereInScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pList uintptr, pnRow uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, nRecValid, rc int32 + var nRow0 Ti64 + var nRowEst TtRowcnt + var p uintptr + var _ /* nEst at bp+0 */ TtRowcnt + _, _, _, _, _, _ = i, nRecValid, nRow0, nRowEst, p, rc + p = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + 24))).FpIndex + nRow0 = libc.Int64FromUint64(_sqlite3LogEstToInt(tls, **(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(p)).FaiRowLogEst)))) + nRecValid = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid + rc = SQLITE_OK /* Number of rows for a single term */ + nRowEst = uint64(0) /* Loop counter */ + i = 0 + for { + if !(rc == SQLITE_OK && i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + **(**TtRowcnt)(__ccgo_up(bp)) = libc.Uint64FromInt64(nRow0) + rc = _whereEqualScanEst(tls, pParse, pBuilder, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr, bp) + nRowEst = nRowEst + **(**TtRowcnt)(__ccgo_up(bp)) + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nRecValid + goto _1 + _1: + ; + i = i + 1 + } + if rc == SQLITE_OK { + if nRowEst > libc.Uint64FromInt64(nRow0) { + nRowEst = libc.Uint64FromInt64(nRow0) + } + **(**TtRowcnt)(__ccgo_up(pnRow)) = nRowEst + } + return rc +} + +// C documentation +// +// /* +// ** This routine implements a heuristic designed to improve query planning. +// ** This routine is called in between the first and second call to +// ** wherePathSolver(). Hence the name "Interstage" "Heuristic". +// ** +// ** The first call to wherePathSolver() (hereafter just "solver()") computes +// ** the best path without regard to the order of the outputs. The second call +// ** to the solver() builds upon the first call to try to find an alternative +// ** path that satisfies the ORDER BY clause. +// ** +// ** This routine looks at the results of the first solver() run, and for +// ** every FROM clause term in the resulting query plan that uses an equality +// ** constraint against an index, disable other WhereLoops for that same +// ** FROM clause term that would try to do a full-table scan. This prevents +// ** an index search from being converted into a full-table scan in order to +// ** satisfy an ORDER BY clause, since even though we might get slightly better +// ** performance using the full-scan without sorting if the output size +// ** estimates are very precise, we might also get severe performance +// ** degradation using the full-scan if the output size estimate is too large. +// ** It is better to err on the side of caution. +// ** +// ** Except, if the first solver() call generated a full-table scan in an outer +// ** loop then stop this analysis at the first full-scan, since the second +// ** solver() run might try to swap that full-scan for another in order to +// ** get the output into the correct order. In other words, we allow a +// ** rewrite like this: +// ** +// ** First Solver() Second Solver() +// ** |-- SCAN t1 |-- SCAN t2 +// ** |-- SEARCH t2 `-- SEARCH t1 +// ** `-- SORT USING B-TREE +// ** +// ** The purpose of this routine is to disallow rewrites such as: +// ** +// ** First Solver() Second Solver() +// ** |-- SEARCH t1 |-- SCAN t2 <--- bad! +// ** |-- SEARCH t2 `-- SEARCH t1 +// ** `-- SORT USING B-TREE +// ** +// ** See test cases in test/whereN.test for the real-world query that +// ** originally provoked this heuristic. +// */ +func _whereInterstageHeuristic(tls *libc.TLS, pWInfo uintptr) { + var i int32 + var iTab Tu8 + var p, pLoop uintptr + _, _, _, _ = i, iTab, p, pLoop + i = 0 + for { + if !(i < libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)) { + break + } + p = (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856 + uintptr(i)*112))).FpWLoop + if p == uintptr(0) { + break + } + if (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { + /* Treat a vtab scan as similar to a full-table scan */ + break + } + if (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_EQ)|libc.Int32FromInt32(WHERE_COLUMN_NULL)|libc.Int32FromInt32(WHERE_COLUMN_IN)) != uint32(0) { + iTab = (*TWhereLoop)(unsafe.Pointer(p)).FiTab + pLoop = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops + for { + if !(pLoop != 0) { + break + } + if libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(pLoop)).FiTab) != libc.Int32FromUint8(iTab) { + goto _2 + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_CONSTRAINT)|libc.Int32FromInt32(WHERE_AUTO_INDEX)) != uint32(0) { + /* Auto-index and index-constrained loops allowed to remain */ + goto _2 + } + (*TWhereLoop)(unsafe.Pointer(pLoop)).Fprereq = libc.Uint64FromInt32(-libc.Int32FromInt32(1)) /* Prevent 2nd solver() from using this one */ + goto _2 + _2: + ; + pLoop = (*TWhereLoop)(unsafe.Pointer(pLoop)).FpNextLoop + } + } else { + break + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Information passed in is pWalk->u.pCovIdxCk. Call it pCk. +// ** +// ** If the Expr node references the table with cursor pCk->iTabCur, then +// ** make sure that column is covered by the index pCk->pIdx. We know that +// ** all columns less than 63 (really BMS-1) are covered, so we don't need +// ** to check them. But we do need to check any column at 63 or greater. +// ** +// ** If the index does not cover the column, then set pWalk->eCode to +// ** non-zero and return WRC_Abort to stop the search. +// ** +// ** If this node does not disprove that the index can be a covering index, +// ** then just return WRC_Continue, to continue the search. +// ** +// ** If pCk->pIdx contains indexed expressions and one of those expressions +// ** matches pExpr, then prune the search. +// */ +func _whereIsCoveringIndexWalkCallback(tls *libc.TLS, pWalk uintptr, pExpr uintptr) (r int32) { + var aiColumn, pCk, pIdx uintptr + var i int32 + var nColumn Tu16 + _, _, _, _, _ = aiColumn, i, nColumn, pCk, pIdx /* Info about this search */ + pCk = *(*uintptr)(unsafe.Pointer(pWalk + 40)) + pIdx = (*TCoveringIndexCheck)(unsafe.Pointer(pCk)).FpIdx + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_COLUMN) { + /* if( pExpr->iColumn<(BMS-1) && pIdx->bHasExpr==0 ) return WRC_Continue;*/ + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable != (*TCoveringIndexCheck)(unsafe.Pointer(pCk)).FiTabCur { + return WRC_Continue + } + pIdx = (*TCoveringIndexCheck)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalk + 40)))).FpIdx + aiColumn = (*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + nColumn = (*TIndex)(unsafe.Pointer(pIdx)).FnColumn + i = 0 + for { + if !(i < libc.Int32FromUint16(nColumn)) { + break + } + if int32(**(**Ti16)(__ccgo_up(aiColumn + uintptr(i)*2))) == int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) { + return WRC_Continue + } + goto _1 + _1: + ; + i = i + 1 + } + (*TCoveringIndexCheck)(unsafe.Pointer(pCk)).FbUnidx = uint8(1) + return int32(WRC_Abort) + } else { + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x800>>11)) != 0 && _exprIsCoveredByIndex(tls, pExpr, pIdx, (*TCoveringIndexCheck)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalk + 40)))).FiTabCur) != 0 { + (*TCoveringIndexCheck)(unsafe.Pointer(pCk)).FbExpr = uint8(1) + return int32(WRC_Prune) + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Estimate the location of a particular key among all keys in an +// ** index. Store the results in aStat as follows: +// ** +// ** aStat[0] Est. number of rows less than pRec +// ** aStat[1] Est. number of rows equal to pRec +// ** +// ** Return the index of the sample that is the smallest sample that +// ** is greater than or equal to pRec. Note that this index is not an index +// ** into the aSample[] array - it is an index into a virtual set of samples +// ** based on the contents of aSample[] and the number of fields in record +// ** pRec. +// */ +func _whereKeyStats(tls *libc.TLS, pParse uintptr, pIdx uintptr, pRec uintptr, roundUp int32, aStat uintptr) (r int32) { + var aSample uintptr + var i, iCol, iMin, iSamp, iSample, iTest, n, nField, res, v1 int32 + var iGap, iLower, iUpper TtRowcnt + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aSample, i, iCol, iGap, iLower, iMin, iSamp, iSample, iTest, iUpper, n, nField, res, v1 + aSample = (*TIndex)(unsafe.Pointer(pIdx)).FaSample /* Smallest sample larger than or equal to pRec */ + iMin = 0 /* Number of fields in pRec */ + iLower = uint64(0) /* anLt[] + anEq[] of largest sample pRec is > */ + _ = pParse + /* Do a binary search to find the first sample greater than or equal + ** to pRec. If pRec contains a single field, the set of samples to search + ** is simply the aSample[] array. If the samples in aSample[] contain more + ** than one fields, all fields following the first are ignored. + ** + ** If pRec contains N fields, where N is more than one, then as well as the + ** samples in aSample[] (truncated to N fields), the search also has to + ** consider prefixes of those samples. For example, if the set of samples + ** in aSample is: + ** + ** aSample[0] = (a, 5) + ** aSample[1] = (a, 10) + ** aSample[2] = (b, 5) + ** aSample[3] = (c, 100) + ** aSample[4] = (c, 105) + ** + ** Then the search space should ideally be the samples above and the + ** unique prefixes [a], [b] and [c]. But since that is hard to organize, + ** the code actually searches this set: + ** + ** 0: (a) + ** 1: (a, 5) + ** 2: (a, 10) + ** 3: (a, 10) + ** 4: (b) + ** 5: (b, 5) + ** 6: (c) + ** 7: (c, 100) + ** 8: (c, 105) + ** 9: (c, 105) + ** + ** For each sample in the aSample[] array, N samples are present in the + ** effective sample array. In the above, samples 0 and 1 are based on + ** sample aSample[0]. Samples 2 and 3 on aSample[1] etc. + ** + ** Often, sample i of each block of N effective samples has (i+1) fields. + ** Except, each sample may be extended to ensure that it is greater than or + ** equal to the previous sample in the array. For example, in the above, + ** sample 2 is the first sample of a block of N samples, so at first it + ** appears that it should be 1 field in size. However, that would make it + ** smaller than sample 1, so the binary search would not work. As a result, + ** it is extended to two fields. The duplicates that this creates do not + ** cause any problems. + */ + if !((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + nField = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + } else { + nField = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + } + if libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(pRec)).FnField) < nField { + v1 = libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(pRec)).FnField) + } else { + v1 = nField + } + nField = v1 + iCol = 0 + iSample = (*TIndex)(unsafe.Pointer(pIdx)).FnSample * nField + for cond := true; cond; cond = res != 0 && iMin < iSample { /* Number of fields in test sample */ + iTest = (iMin + iSample) / int32(2) + iSamp = iTest / nField + if iSamp > 0 { + /* The proposed effective sample is a prefix of sample aSample[iSamp]. + ** Specifically, the shortest prefix of at least (1 + iTest%nField) + ** fields that is greater than the previous effective sample. */ + n = iTest%nField + int32(1) + for { + if !(n < nField) { + break + } + if **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(iSamp-int32(1))*40))).FanLt + uintptr(n-int32(1))*8)) != **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(iSamp)*40))).FanLt + uintptr(n-int32(1))*8)) { + break + } + goto _2 + _2: + ; + n = n + 1 + } + } else { + n = iTest + int32(1) + } + (*TUnpackedRecord)(unsafe.Pointer(pRec)).FnField = libc.Uint16FromInt32(n) + res = _sqlite3VdbeRecordCompare(tls, (**(**TIndexSample)(__ccgo_up(aSample + uintptr(iSamp)*40))).Fn, (**(**TIndexSample)(__ccgo_up(aSample + uintptr(iSamp)*40))).Fp, pRec) + if res < 0 { + iLower = **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(iSamp)*40))).FanLt + uintptr(n-int32(1))*8)) + **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(iSamp)*40))).FanEq + uintptr(n-int32(1))*8)) + iMin = iTest + int32(1) + } else { + if res == 0 && n < nField { + iLower = **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(iSamp)*40))).FanLt + uintptr(n-int32(1))*8)) + iMin = iTest + int32(1) + res = -int32(1) + } else { + iSample = iTest + iCol = n - int32(1) + } + } + } + i = iSample / nField + if res == 0 { + /* Record pRec is equal to sample i */ + **(**TtRowcnt)(__ccgo_up(aStat)) = **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(i)*40))).FanLt + uintptr(iCol)*8)) + **(**TtRowcnt)(__ccgo_up(aStat + 1*8)) = **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(i)*40))).FanEq + uintptr(iCol)*8)) + } else { + if i >= (*TIndex)(unsafe.Pointer(pIdx)).FnSample { + iUpper = (*TIndex)(unsafe.Pointer(pIdx)).FnRowEst0 + } else { + iUpper = **(**TtRowcnt)(__ccgo_up((**(**TIndexSample)(__ccgo_up(aSample + uintptr(i)*40))).FanLt + uintptr(iCol)*8)) + } + if iLower >= iUpper { + iGap = uint64(0) + } else { + iGap = iUpper - iLower + } + if roundUp != 0 { + iGap = iGap * uint64(2) / uint64(3) + } else { + iGap = iGap / uint64(3) + } + **(**TtRowcnt)(__ccgo_up(aStat)) = iLower + iGap + **(**TtRowcnt)(__ccgo_up(aStat + 1*8)) = **(**TtRowcnt)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr(nField-int32(1))*8)) + } + /* Restore the pRec->nField value before returning. */ + (*TUnpackedRecord)(unsafe.Pointer(pRec)).FnField = libc.Uint16FromInt32(nField) + return i +} + +// C documentation +// +// /* +// ** We have so far matched pBuilder->pNew->u.btree.nEq terms of the +// ** index pIndex. Try to match one more. +// ** +// ** When this function is called, pBuilder->pNew->nOut contains the +// ** number of rows expected to be visited by filtering using the nEq +// ** terms only. If it is modified, this value is restored before this +// ** function returns. +// ** +// ** If pProbe->idxType==SQLITE_IDXTYPE_IPK, that means pIndex is +// ** a fake index used for the INTEGER PRIMARY KEY. +// */ +func _whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProbe uintptr, nInMul TLogEst) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var M, logK, nIter, nOutUnadjusted, rCostIdx, rLogSize, rSize, saved_nOut, x TLogEst + var bRedundant, i, iCol, nEq, nIn, nRecValid, nVecLen, opMask, rc, v21 int32 + var db, pBtm, pExpr, pExpr1, pNew, pParse, pTerm, pTop, pWInfo, v2 uintptr + var eOp, saved_nBtm, saved_nEq, saved_nLTerm, saved_nSkip, saved_nTop, v4 Tu16 + var saved_prereq TBitmask + var saved_wsFlags Tu32 + var v22 bool + var _ /* nOut at bp+112 */ TtRowcnt + var _ /* scan at bp+0 */ TWhereScan + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = M, bRedundant, db, eOp, i, iCol, logK, nEq, nIn, nIter, nOutUnadjusted, nRecValid, nVecLen, opMask, pBtm, pExpr, pExpr1, pNew, pParse, pTerm, pTop, pWInfo, rCostIdx, rLogSize, rSize, rc, saved_nBtm, saved_nEq, saved_nLTerm, saved_nOut, saved_nSkip, saved_nTop, saved_prereq, saved_wsFlags, x, v2, v21, v22, v4 + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo /* WHERE analyze context */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parsing context */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Original value of pNew->nOut */ + rc = SQLITE_OK /* Logarithm of table size */ + pTop = uintptr(0) + pBtm = uintptr(0) /* Top and bottom range constraints */ + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return (*TParse)(unsafe.Pointer(pParse)).Frc + } + if (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags&uint32(WHERE_BTM_LIMIT) != 0 { + opMask = libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ)) + } else { + opMask = libc.Int32FromInt32(WO_EQ) | libc.Int32FromInt32(WO_IN) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_ISNULL) | libc.Int32FromInt32(WO_IS) + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x4>>2)) != 0 { + opMask = opMask & ^(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))) + } + saved_nEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq + saved_nBtm = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnBtm + saved_nTop = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnTop + saved_nSkip = (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip + saved_nLTerm = (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm + saved_wsFlags = (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags + saved_prereq = (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq + saved_nOut = (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut + pTerm = _whereScanInit(tls, bp, (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor, libc.Int32FromUint16(saved_nEq), libc.Uint32FromInt32(opMask), pProbe) + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = 0 + rSize = **(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst)) + rLogSize = _estLog(tls, rSize) + for { + if !(rc == SQLITE_OK && pTerm != uintptr(0)) { + break + } + eOp = (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator /* nOut before IN() and WHERE adjustments */ + nIn = 0 + nRecValid = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid + if (libc.Int32FromUint16(eOp) == int32(WO_ISNULL) || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VNULL) != 0) && _indexColumnNotNull(tls, pProbe, libc.Int32FromUint16(saved_nEq)) != 0 { + goto _1 /* ignore IS [NOT] NULL constraints on NOT NULL columns */ + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&(*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf != 0 { + goto _1 + } + /* Do not allow the upper bound of a LIKE optimization range constraint + ** to mix with a lower range bound from some other source */ + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_LIKEOPT) != 0 && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ)) { + goto _1 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)|libc.Int32FromInt32(JT_RIGHT)) != 0 && !(_constraintCompatibleWithOuterJoin(tls, pTerm, pSrc) != 0) { + goto _1 + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pProbe)).FonError) != OE_None && libc.Int32FromUint16(saved_nEq) == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pProbe)).FnKeyCol)-int32(1) { + v2 = pBuilder + 44 + *(*uint8)(unsafe.Pointer(v2)) = uint8(int32(*(*uint8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(SQLITE_BLDF1_UNIQUE)) + } else { + v2 = pBuilder + 44 + *(*uint8)(unsafe.Pointer(v2)) = uint8(int32(*(*uint8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(SQLITE_BLDF1_INDEXED)) + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = saved_wsFlags + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq = saved_nEq + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnBtm = saved_nBtm + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnTop = saved_nTop + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = saved_nLTerm + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm) >= libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pNew)).FnLSlot) && _whereLoopResize(tls, db, pNew, libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+int32(1)) != 0 { + break /* OOM while trying to enlarge the pNew->aLTerm array */ + } + v2 = pNew + 52 + v4 = *(*Tu16)(unsafe.Pointer(v2)) + *(*Tu16)(unsafe.Pointer(v2)) = *(*Tu16)(unsafe.Pointer(v2)) + 1 + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(v4)*8)) = pTerm + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = (saved_prereq | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight) & ^(*TWhereLoop)(unsafe.Pointer(pNew)).FmaskSelf + if libc.Int32FromUint16(eOp)&int32(WO_IN) != 0 { + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + bRedundant = 0 + nIn = int32(46) + /* The expression may actually be of the form (x, y) IN (SELECT...). + ** In this case there is a separate term for each of (x) and (y). + ** However, the nIn multiplier should only be applied once, not once + ** for each such term. The following loop checks that pTerm is the + ** first such term in use, and sets nIn back to 0 if it is not. */ + i = 0 + for { + if !(i < libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm)-int32(1)) { + break + } + if **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(i)*8)) != 0 && (*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(i)*8)))).FpExpr == pExpr { + nIn = 0 + if (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(i)*8)) + 32))).FiField == (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField { + /* Detect when two or more columns of an index match the same + ** column of a vector IN operater, and avoid adding the column + ** to the WhereLoop more than once. See tag-20250707-01 + ** in test/rowvalue.test */ + bRedundant = int32(1) + } + } + goto _6 + _6: + ; + i = i + 1 + } + if bRedundant != 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm - 1 + goto _1 + } + } else { + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != 0 && (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr != 0 { + /* "x IN (value, value, ...)" */ + nIn = int32(_sqlite3LogEst(tls, libc.Uint64FromInt32((*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FnExpr))) + } + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x80>>7)) != 0 && int32(rLogSize) >= int32(10) { + /* Let: + ** N = the total number of rows in the table + ** K = the number of entries on the RHS of the IN operator + ** M = the number of rows in the table that match terms to the + ** to the left in the same index. If the IN operator is on + ** the left-most index column, M==N. + ** + ** Given the definitions above, it is better to omit the IN operator + ** from the index lookup and instead do a scan of the M elements, + ** testing each scanned row against the IN operator separately, if: + ** + ** M*log(K) < K*log(N) + ** + ** Our estimates for M, K, and N might be inaccurate, so we build in + ** a safety margin of 2 (LogEst: 10) that favors using the IN operator + ** with the index, as using an index has better worst-case behavior. + ** If we do not have real sqlite_stat1 data, always prefer to use + ** the index. Do not bother with this optimization on very small + ** tables (less than 2 rows) as it is pointless in that case. + */ + M = **(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(saved_nEq)*2)) + logK = _estLog(tls, int16(nIn)) + /* TUNING v----- 10 to bias toward indexed IN */ + x = int16(int32(M) + int32(logK) + int32(10) - (nIn + int32(rLogSize))) + if int32(x) >= 0 { + } else { + if int32(nInMul) < int32(2) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_SeekScan)) == uint32(0) { + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_IN_SEEKSCAN) + } else { + goto _1 + } + } + } + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_COLUMN_IN) + } else { + if libc.Int32FromUint16(eOp)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) != 0 { + iCol = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiColumn + uintptr(saved_nEq)*2))) + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_COLUMN_EQ) + if iCol == -int32(1) || iCol >= 0 && int32(nInMul) == 0 && libc.Int32FromUint16(saved_nEq) == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pProbe)).FnKeyCol)-int32(1) { + if iCol == -int32(1) || int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x8>>3)) != 0 || libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pProbe)).FnKeyCol) == int32(1) && (*TIndex)(unsafe.Pointer(pProbe)).FonError != 0 && libc.Int32FromUint16(eOp)&int32(WO_EQ) != 0 { + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_ONEROW) + } else { + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_UNQ_WANTED) + } + } + if libc.Int32FromUint8((**(**TWhereScan)(__ccgo_up(bp))).FiEquiv) > int32(1) { + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_TRANSCONS) + } + } else { + if libc.Int32FromUint16(eOp)&int32(WO_ISNULL) != 0 { + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_COLUMN_NULL) + } else { + nVecLen = _whereRangeVectorLen(tls, pParse, (*TSrcItem)(unsafe.Pointer(pSrc)).FiCursor, pProbe, libc.Int32FromUint16(saved_nEq), pTerm) + if libc.Int32FromUint16(eOp)&(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) != 0 { + **(**Tu32)(__ccgo_up(pNew + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_RANGE) | libc.Int32FromInt32(WHERE_BTM_LIMIT)) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnBtm = libc.Uint16FromInt32(nVecLen) + pBtm = pTerm + pTop = uintptr(0) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_LIKEOPT) != 0 { + /* Range constraints that come from the LIKE optimization are + ** always used in pairs. */ + pTop = pTerm + 1*56 + if _whereLoopResize(tls, db, pNew, libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+int32(1)) != 0 { + break + } /* OOM */ + v2 = pNew + 52 + v4 = *(*Tu16)(unsafe.Pointer(v2)) + *(*Tu16)(unsafe.Pointer(v2)) = *(*Tu16)(unsafe.Pointer(v2)) + 1 + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(v4)*8)) = pTop + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_TOP_LIMIT) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnTop = uint16(1) + } + } else { + **(**Tu32)(__ccgo_up(pNew + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_RANGE) | libc.Int32FromInt32(WHERE_TOP_LIMIT)) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnTop = libc.Uint16FromInt32(nVecLen) + pTop = pTerm + if (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags&uint32(WHERE_BTM_LIMIT) != uint32(0) { + v2 = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm)-int32(2))*8)) + } else { + v2 = uintptr(0) + } + pBtm = v2 + } + } + } + } + /* At this point pNew->nOut is set to the number of rows expected to + ** be visited by the index scan before considering term pTerm, or the + ** values of nIn and nInMul. In other words, assuming that all + ** "x IN(...)" terms are replaced with "x = ?". This block updates + ** the value of pNew->nOut to account for pTerm (but not nIn/nInMul). */ + if (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags&uint32(WHERE_COLUMN_RANGE) != 0 { + /* Adjust nOut using stat4 data. Or, if there is no stat4 + ** data, using some other estimate. */ + _whereRangeScanEst(tls, pParse, pBuilder, pBtm, pTop, pNew) + } else { + v2 = pNew + 24 + *(*Tu16)(unsafe.Pointer(v2)) = *(*Tu16)(unsafe.Pointer(v2)) + 1 + v4 = *(*Tu16)(unsafe.Pointer(v2)) + nEq = libc.Int32FromUint16(v4) + if int32((*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 && int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiColumn + uintptr(saved_nEq)*2))) >= 0 { + v2 = pNew + 22 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) + int32((*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb)) + v2 = pNew + 22 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) - nIn) + } else { + **(**TtRowcnt)(__ccgo_up(bp + 112)) = uint64(0) + if int32(nInMul) == 0 && (*TIndex)(unsafe.Pointer(pProbe)).FnSample != 0 && libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq) <= (*TIndex)(unsafe.Pointer(pProbe)).FnSampleCol && (libc.Int32FromUint16(eOp)&int32(WO_IN) == 0 || (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&uint32(EP_xIsSelect) == uint32(0)) && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) { + pExpr1 = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if libc.Int32FromUint16(eOp)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_ISNULL)|libc.Int32FromInt32(WO_IS)) != 0 { + rc = _whereEqualScanEst(tls, pParse, pBuilder, (*TExpr)(unsafe.Pointer(pExpr1)).FpRight, bp+112) + } else { + rc = _whereInScanEst(tls, pParse, pBuilder, *(*uintptr)(unsafe.Pointer(pExpr1 + 32)), bp+112) + } + if rc == int32(SQLITE_NOTFOUND) { + rc = SQLITE_OK + } + if rc != SQLITE_OK { + break + } /* Jump out of the pTerm loop */ + if **(**TtRowcnt)(__ccgo_up(bp + 112)) != 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = _sqlite3LogEst(tls, **(**TtRowcnt)(__ccgo_up(bp + 112))) + if nEq == int32(1) && int32((*TWhereLoop)(unsafe.Pointer(pNew)).FnOut)+int32(10) > int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst))) { + v2 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(TERM_HIGHTRUTH)) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_HEURTRUTH) != 0 { + /* If the term has previously been used with an assumption of + ** higher selectivity, then set the flag to rerun the + ** loop computations. */ + v2 = pBuilder + 45 + *(*uint8)(unsafe.Pointer(v2)) = uint8(int32(*(*uint8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(SQLITE_BLDF2_2NDPASS)) + } + } + if int32((*TWhereLoop)(unsafe.Pointer(pNew)).FnOut) > int32(saved_nOut) { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut + } + v2 = pNew + 22 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) - nIn) + } + } + if **(**TtRowcnt)(__ccgo_up(bp + 112)) == uint64(0) { + v2 = pNew + 22 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) + (int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(nEq)*2))) - int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(nEq-int32(1))*2))))) + if libc.Int32FromUint16(eOp)&int32(WO_ISNULL) != 0 { + /* TUNING: If there is no likelihood() value, assume that a + ** "col IS NULL" expression matches twice as many rows + ** as (col=?). */ + v2 = pNew + 22 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) + libc.Int32FromInt32(10)) + } + } + } + } + /* Set rCostIdx to the estimated cost of visiting selected rows in the + ** index. The estimate is the sum of two values: + ** 1. The cost of doing one search-by-key to find the first matching + ** entry + ** 2. Stepping forward in the index pNew->nOut times to find all + ** additional matching entries. + */ + if int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_IPK) { + /* The pProbe->szIdxRow is low for an IPK table since the interior + ** pages are small. Thus szIdxRow gives a good estimate of seek cost. + ** But the leaf pages are full-size, so pProbe->szIdxRow would badly + ** under-estimate the scanning cost. */ + rCostIdx = int16(int32((*TWhereLoop)(unsafe.Pointer(pNew)).FnOut) + int32(16)) + } else { + rCostIdx = int16(int32((*TWhereLoop)(unsafe.Pointer(pNew)).FnOut) + int32(1) + int32(15)*int32((*TIndex)(unsafe.Pointer(pProbe)).FszIdxRow)/int32((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab)).FszTabRow)) + } + rCostIdx = _sqlite3LogEstAdd(tls, rLogSize, rCostIdx) + /* Estimate the cost of running the loop. If all data is coming + ** from the index, then this is just the cost of doing the index + ** lookup and scan. But if some data is coming out of the main table, + ** we also have to add in the cost of doing pNew->nOut searches to + ** locate the row in the main table that corresponds to the index entry. + */ + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = rCostIdx + if (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY)|libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_EXPRIDX)) == uint32(0) { + (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun = _sqlite3LogEstAdd(tls, (*TWhereLoop)(unsafe.Pointer(pNew)).FrRun, int16(int32((*TWhereLoop)(unsafe.Pointer(pNew)).FnOut)+int32(16))) + } + nOutUnadjusted = (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut + v2 = pNew + 20 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) + (int32(nInMul) + nIn)) + v2 = pNew + 22 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) + (int32(nInMul) + nIn)) + _whereLoopOutputAdjust(tls, (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC, pNew, rSize) + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40000>>18) != 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = 0 + } + rc = _whereLoopInsert(tls, pBuilder, pNew) + if (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags&uint32(WHERE_COLUMN_RANGE) != 0 { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut + } else { + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = nOutUnadjusted + } + if (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags&uint32(WHERE_TOP_LIMIT) == uint32(0) && libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq) < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pProbe)).FnColumn) && (libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq) < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pProbe)).FnKeyCol) || int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x3>>0)) != int32(SQLITE_IDXTYPE_PRIMARYKEY)) { + if libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq) > int32(3) { + _sqlite3ProgressCheck(tls, pParse) + } + _whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, int16(int32(nInMul)+nIn)) + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nRecValid + goto _1 + _1: + ; + pTerm = _whereScanNext(tls, bp) + } + (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq = saved_prereq + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq = saved_nEq + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnBtm = saved_nBtm + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnTop = saved_nTop + (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip = saved_nSkip + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = saved_wsFlags + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = saved_nLTerm + /* Consider using a skip-scan if there are no WHERE clause constraints + ** available for the left-most terms of the index, and if the average + ** number of repeats in the left-most terms is at least 18. + ** + ** The magic number 18 is selected on the basis that scanning 17 rows + ** is almost always quicker than an index seek (even though if the index + ** contains fewer than 2^17 rows we assume otherwise in other parts of + ** the code). And, even if it is not, it should not be too much slower. + ** On the other hand, the extra seeks could end up being significantly + ** more expensive. */ + if v22 = libc.Int32FromUint16(saved_nEq) == libc.Int32FromUint16(saved_nSkip) && libc.Int32FromUint16(saved_nEq)+int32(1) < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pProbe)).FnKeyCol) && libc.Int32FromUint16(saved_nEq) == libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm) && int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x40>>6)) == 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pProbe + 100))&0x80>>7)) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_SkipScan)) == uint32(0) && int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(libc.Int32FromUint16(saved_nEq)+int32(1))*2))) >= int32(42) && int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40000>>18) == 0; v22 { + v21 = _whereLoopResize(tls, db, pNew, libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+int32(1)) + rc = v21 + } + if v22 && v21 == SQLITE_OK { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq + 1 + (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip = (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip + 1 + v2 = pNew + 52 + v4 = *(*Tu16)(unsafe.Pointer(v2)) + *(*Tu16)(unsafe.Pointer(v2)) = *(*Tu16)(unsafe.Pointer(v2)) + 1 + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(v4)*8)) = uintptr(0) + **(**Tu32)(__ccgo_up(pNew + 48)) |= uint32(WHERE_SKIPSCAN) + nIter = int16(int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(saved_nEq)*2))) - int32(**(**TLogEst)(__ccgo_up((*TIndex)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(libc.Int32FromUint16(saved_nEq)+int32(1))*2)))) + v2 = pNew + 22 + *(*TLogEst)(unsafe.Pointer(v2)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v2))) - int32(nIter)) + /* TUNING: Because uncertainties in the estimates for skip-scan queries, + ** add a 1.375 fudge factor to make skip-scan slightly less likely. */ + nIter = int16(int32(nIter) + libc.Int32FromInt32(5)) + _whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, int16(int32(nIter)+int32(nInMul))) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pNew + 24))).FnEq = saved_nEq + (*TWhereLoop)(unsafe.Pointer(pNew)).FnSkip = saved_nSkip + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = saved_wsFlags + } + return rc +} + +// C documentation +// +// /* +// ** Add all WhereLoop objects for a table of the join identified by +// ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table. +// ** +// ** If there are no LEFT or CROSS JOIN joins in the query, both mPrereq and +// ** mUnusable are set to 0. Otherwise, mPrereq is a mask of all FROM clause +// ** entries that occur before the virtual table in the FROM clause and are +// ** separated from it by at least one LEFT or CROSS JOIN. Similarly, the +// ** mUnusable mask contains all FROM clause entries that occur after the +// ** virtual table and are separated from it by at least one LEFT or +// ** CROSS JOIN. +// ** +// ** For example, if the query were: +// ** +// ** ... FROM t1, t2 LEFT JOIN t3, t4, vt CROSS JOIN t5, t6; +// ** +// ** then mPrereq corresponds to (t1, t2) and mUnusable to (t5, t6). +// ** +// ** All the tables in mPrereq must be scanned before the current virtual +// ** table. So any terms for which all prerequisites are satisfied by +// ** mPrereq may be specified as "usable" in all calls to xBestIndex. +// ** Conversely, all tables in mUnusable must be scanned after the current +// ** virtual table, so any terms for which the prerequisites overlap with +// ** mUnusable should always be configured as "not-usable" for xBestIndex. +// */ +func _whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq TBitmask, mUnusable TBitmask) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iTerm, nConstraint, rc, seenZero, seenZeroNoIN int32 + var mBest, mBestNoIn, mNext, mPrev, mThis, v1 TBitmask + var p, pNew, pParse, pSrc, pWC, pWInfo uintptr + var v2 bool + var _ /* bIn at bp+0 */ int32 + var _ /* bRetry at bp+8 */ int32 + var _ /* mNoOmit at bp+4 */ Tu16 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iTerm, mBest, mBestNoIn, mNext, mPrev, mThis, nConstraint, p, pNew, pParse, pSrc, pWC, pWInfo, rc, seenZero, seenZeroNoIN, v1, v2 + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 8)) = 0 /* True to retry with LIMIT/OFFSET disabled */ + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + pWC = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC + pNew = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + pSrc = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pNew)).FiTab)*80 + p = _allocateIndexInfo(tls, pWInfo, pWC, mUnusable, pSrc, bp+4) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TWhereLoop)(unsafe.Pointer(pNew)).FrSetup = 0 + (*TWhereLoop)(unsafe.Pointer(pNew)).FwsFlags = uint32(WHERE_VIRTUALTABLE) + (*TWhereLoop)(unsafe.Pointer(pNew)).FnLTerm = uint16(0) + libc.SetBitFieldPtr8Uint32(pNew+24+4, libc.Uint32FromInt32(0), 0, 0x1) + nConstraint = (*Tsqlite3_index_info)(unsafe.Pointer(p)).FnConstraint + if _whereLoopResize(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pNew, nConstraint) != 0 { + _freeIndexInfo(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p) + return int32(SQLITE_NOMEM) + } + /* First call xBestIndex() with all constraints usable. */ + rc = _whereLoopAddVirtualOne(tls, pBuilder, mPrereq, libc.Uint64FromInt32(-libc.Int32FromInt32(1)), uint16(0), p, **(**Tu16)(__ccgo_up(bp + 4)), bp, bp+8) + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + rc = _whereLoopAddVirtualOne(tls, pBuilder, mPrereq, libc.Uint64FromInt32(-libc.Int32FromInt32(1)), uint16(0), p, **(**Tu16)(__ccgo_up(bp + 4)), bp, uintptr(0)) + } + /* If the call to xBestIndex() with all terms enabled produced a plan + ** that does not require any source tables (IOW: a plan with mBest==0) + ** and does not use an IN(...) operator, then there is no point in making + ** any further calls to xBestIndex() since they will all return the same + ** result (if the xBestIndex() implementation is sane). */ + if v2 = rc == SQLITE_OK; v2 { + v1 = (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq + mBest = v1 + } + if v2 && (v1 != uint64(0) || **(**int32)(__ccgo_up(bp)) != 0) { + seenZero = 0 /* True if a plan with no prereqs seen */ + seenZeroNoIN = 0 /* Plan with no prereqs and no IN(...) seen */ + mPrev = uint64(0) + mBestNoIn = uint64(0) + /* If the plan produced by the earlier call uses an IN(...) term, call + ** xBestIndex again, this time with IN(...) terms disabled. */ + if **(**int32)(__ccgo_up(bp)) != 0 { + rc = _whereLoopAddVirtualOne(tls, pBuilder, mPrereq, libc.Uint64FromInt32(-libc.Int32FromInt32(1)), uint16(WO_IN), p, **(**Tu16)(__ccgo_up(bp + 4)), bp, uintptr(0)) + mBestNoIn = (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq + if mBestNoIn == uint64(0) { + seenZero = int32(1) + seenZeroNoIN = int32(1) + } + } + /* Call xBestIndex once for each distinct value of (prereqRight & ~mPrereq) + ** in the set of terms that apply to the current virtual table. */ + for rc == SQLITE_OK { + mNext = libc.Uint64FromInt32(-libc.Int32FromInt32(1)) + i = 0 + for { + if !(i < nConstraint) { + break + } + iTerm = (**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(p)).FaConstraint + uintptr(i)*12))).FiTermOffset + mThis = (*TWhereTerm)(unsafe.Pointer(_termFromWhereClause(tls, pWC, iTerm))).FprereqRight & ^mPrereq + if mThis > mPrev && mThis < mNext { + mNext = mThis + } + goto _3 + _3: + ; + i = i + 1 + } + mPrev = mNext + if mNext == libc.Uint64FromInt32(-libc.Int32FromInt32(1)) { + break + } + if mNext == mBest || mNext == mBestNoIn { + continue + } + rc = _whereLoopAddVirtualOne(tls, pBuilder, mPrereq, mNext|mPrereq, uint16(0), p, **(**Tu16)(__ccgo_up(bp + 4)), bp, uintptr(0)) + if (*TWhereLoop)(unsafe.Pointer(pNew)).Fprereq == mPrereq { + seenZero = int32(1) + if **(**int32)(__ccgo_up(bp)) == 0 { + seenZeroNoIN = int32(1) + } + } + } + /* If the calls to xBestIndex() in the above loop did not find a plan + ** that requires no source tables at all (i.e. one guaranteed to be + ** usable), make a call here with all source tables disabled */ + if rc == SQLITE_OK && seenZero == 0 { + rc = _whereLoopAddVirtualOne(tls, pBuilder, mPrereq, mPrereq, uint16(0), p, **(**Tu16)(__ccgo_up(bp + 4)), bp, uintptr(0)) + if **(**int32)(__ccgo_up(bp)) == 0 { + seenZeroNoIN = int32(1) + } + } + /* If the calls to xBestIndex() have so far failed to find a plan + ** that requires no source tables at all and does not use an IN(...) + ** operator, make a final call to obtain one here. */ + if rc == SQLITE_OK && seenZeroNoIN == 0 { + rc = _whereLoopAddVirtualOne(tls, pBuilder, mPrereq, mPrereq, uint16(WO_IN), p, **(**Tu16)(__ccgo_up(bp + 4)), bp, uintptr(0)) + } + } + _freeIndexInfo(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p) + return rc +} + +// C documentation +// +// /* +// ** Return TRUE if X is a proper subset of Y but is of equal or less cost. +// ** In other words, return true if all constraints of X are also part of Y +// ** and Y has additional constraints that might speed the search that X lacks +// ** but the cost of running X is not more than the cost of running Y. +// ** +// ** In other words, return true if the cost relationship between X and Y +// ** is inverted and needs to be adjusted. +// ** +// ** Case 1: +// ** +// ** (1a) X and Y use the same index. +// ** (1b) X has fewer == terms than Y +// ** (1c) Neither X nor Y use skip-scan +// ** (1d) X does not have a a greater cost than Y +// ** +// ** Case 2: +// ** +// ** (2a) X has the same or lower cost, or returns the same or fewer rows, +// ** than Y. +// ** (2b) X uses fewer WHERE clause terms than Y +// ** (2c) Every WHERE clause term used by X is also used by Y +// ** (2d) X skips at least as many columns as Y +// ** (2e) If X is a covering index, than Y is too +// */ +func _whereLoopCheaperProperSubset(tls *libc.TLS, pX uintptr, pY uintptr) (r int32) { + var i, j int32 + _, _ = i, j + if int32((*TWhereLoop)(unsafe.Pointer(pX)).FrRun) > int32((*TWhereLoop)(unsafe.Pointer(pY)).FrRun) && int32((*TWhereLoop)(unsafe.Pointer(pX)).FnOut) > int32((*TWhereLoop)(unsafe.Pointer(pY)).FnOut) { + return 0 + } /* (1d) and (2a) */ + if libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pX + 24))).FnEq) < libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pY + 24))).FnEq) && (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pX + 24))).FpIndex == (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pY + 24))).FpIndex && libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pX)).FnSkip) == 0 && libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pY)).FnSkip) == 0 { + return int32(1) /* Case 1 is true */ + } + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pX)).FnLTerm)-libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pX)).FnSkip) >= libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pY)).FnLTerm)-libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pY)).FnSkip) { + return 0 /* (2b) */ + } + if libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pY)).FnSkip) > libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pX)).FnSkip) { + return 0 + } /* (2d) */ + i = libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pX)).FnLTerm) - int32(1) + for { + if !(i >= 0) { + break + } + if **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pX)).FaLTerm + uintptr(i)*8)) == uintptr(0) { + goto _1 + } + j = libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pY)).FnLTerm) - int32(1) + for { + if !(j >= 0) { + break + } + if **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pY)).FaLTerm + uintptr(j)*8)) == **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pX)).FaLTerm + uintptr(i)*8)) { + break + } + goto _2 + _2: + ; + j = j - 1 + } + if j < 0 { + return 0 + } /* (2c) */ + goto _1 + _1: + ; + i = i - 1 + } + if (*TWhereLoop)(unsafe.Pointer(pX)).FwsFlags&uint32(WHERE_IDX_ONLY) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(pY)).FwsFlags&uint32(WHERE_IDX_ONLY) == uint32(0) { + return 0 /* (2e) */ + } + return int32(1) /* Case 2 is true */ +} + +// C documentation +// +// /* +// ** Deallocate internal memory used by a WhereLoop object. Leave the +// ** object in an initialized state, as if it had been newly allocated. +// */ +func _whereLoopClear(tls *libc.TLS, db uintptr, p uintptr) { + if (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm != p+80 { + _sqlite3DbFreeNN(tls, db, (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm) + (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm = p + 80 + (*TWhereLoop)(unsafe.Pointer(p)).FnLSlot = libc.Uint16FromInt32(libc.Int32FromUint64(libc.Uint64FromInt64(24) / libc.Uint64FromInt64(8))) + } + _whereLoopClearUnion(tls, db, p) + (*TWhereLoop)(unsafe.Pointer(p)).FnLTerm = uint16(0) + (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags = uint32(0) +} + +// C documentation +// +// /* +// ** Search the list of WhereLoops in *ppPrev looking for one that can be +// ** replaced by pTemplate. +// ** +// ** Return NULL if pTemplate does not belong on the WhereLoop list. +// ** In other words if pTemplate ought to be dropped from further consideration. +// ** +// ** If pX is a WhereLoop that pTemplate can replace, then return the +// ** link that points to pX. +// ** +// ** If pTemplate cannot replace any existing element of the list but needs +// ** to be added to the list as a new entry, then return a pointer to the +// ** tail of the list. +// */ +func _whereLoopFindLesser(tls *libc.TLS, ppPrev uintptr, pTemplate uintptr) (r uintptr) { + var p uintptr + _ = p + p = **(**uintptr)(__ccgo_up(ppPrev)) + for { + if !(p != 0) { + break + } + if libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(p)).FiTab) != libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(pTemplate)).FiTab) || libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(p)).FiSortIdx) != libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(pTemplate)).FiSortIdx) { + /* If either the iTab or iSortIdx values for two WhereLoop are different + ** then those WhereLoops need to be considered separately. Neither is + ** a candidate to replace the other. */ + goto _1 + } + /* In the current implementation, the rSetup value is either zero + ** or the cost of building an automatic index (NlogN) and the NlogN + ** is the same for compatible WhereLoops. */ + /* whereLoopAddBtree() always generates and inserts the automatic index + ** case first. Hence compatible candidate WhereLoops never have a larger + ** rSetup. Call this SETUP-INVARIANT */ + /* Any loop using an application-defined index (or PRIMARY KEY or + ** UNIQUE constraint) with one or more == constraints is better + ** than an automatic index. Unless it is a skip-scan. */ + if (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags&uint32(WHERE_AUTO_INDEX) != uint32(0) && libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pTemplate)).FnSkip) == 0 && (*TWhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags&uint32(WHERE_INDEXED) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags&uint32(WHERE_COLUMN_EQ) != uint32(0) && (*TWhereLoop)(unsafe.Pointer(p)).Fprereq&(*TWhereLoop)(unsafe.Pointer(pTemplate)).Fprereq == (*TWhereLoop)(unsafe.Pointer(pTemplate)).Fprereq { + break + } + /* If existing WhereLoop p is better than pTemplate, pTemplate can be + ** discarded. WhereLoop p is better if: + ** (1) p has no more dependencies than pTemplate, and + ** (2) p has an equal or lower cost than pTemplate + */ + if (*TWhereLoop)(unsafe.Pointer(p)).Fprereq&(*TWhereLoop)(unsafe.Pointer(pTemplate)).Fprereq == (*TWhereLoop)(unsafe.Pointer(p)).Fprereq && int32((*TWhereLoop)(unsafe.Pointer(p)).FrSetup) <= int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FrSetup) && int32((*TWhereLoop)(unsafe.Pointer(p)).FrRun) <= int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun) && int32((*TWhereLoop)(unsafe.Pointer(p)).FnOut) <= int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut) { + return uintptr(0) /* Discard pTemplate */ + } + /* If pTemplate is always better than p, then cause p to be overwritten + ** with pTemplate. pTemplate is better than p if: + ** (1) pTemplate has no more dependencies than p, and + ** (2) pTemplate has an equal or lower cost than p. + */ + if (*TWhereLoop)(unsafe.Pointer(p)).Fprereq&(*TWhereLoop)(unsafe.Pointer(pTemplate)).Fprereq == (*TWhereLoop)(unsafe.Pointer(pTemplate)).Fprereq && int32((*TWhereLoop)(unsafe.Pointer(p)).FrRun) >= int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun) && int32((*TWhereLoop)(unsafe.Pointer(p)).FnOut) >= int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut) { + /* SETUP-INVARIANT above */ + break /* Cause p to be overwritten by pTemplate */ + } + goto _1 + _1: + ; + ppPrev = p + 72 + p = **(**uintptr)(__ccgo_up(ppPrev)) + } + return ppPrev +} + +// C documentation +// +// /* +// ** Convert bulk memory into a valid WhereLoop that can be passed +// ** to whereLoopClear harmlessly. +// */ +func _whereLoopInit(tls *libc.TLS, p uintptr) { + (*TWhereLoop)(unsafe.Pointer(p)).FaLTerm = p + 80 + (*TWhereLoop)(unsafe.Pointer(p)).FnLTerm = uint16(0) + (*TWhereLoop)(unsafe.Pointer(p)).FnLSlot = libc.Uint16FromInt32(libc.Int32FromUint64(libc.Uint64FromInt64(24) / libc.Uint64FromInt64(8))) + (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags = uint32(0) +} + +// C documentation +// +// /* +// ** Loop pLoop is a WHERE_INDEXED level that uses at least one IN(...) +// ** operator. Return true if level pLoop is guaranteed to visit only one +// ** row for each key generated for the index. +// */ +func _whereLoopIsOneRow(tls *libc.TLS, pLoop uintptr) (r int32) { + var ii int32 + _ = ii + if (*TIndex)(unsafe.Pointer((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex)).FonError != 0 && libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) == 0 && libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) == libc.Int32FromUint16((*TIndex)(unsafe.Pointer((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex)).FnKeyCol) { + ii = 0 + for { + if !(ii < libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq)) { + break + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(ii)*8)))).FeOperator)&(libc.Int32FromInt32(WO_IS)|libc.Int32FromInt32(WO_ISNULL)) != 0 { + return 0 + } + goto _1 + _1: + ; + ii = ii + 1 + } + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Adjust the WhereLoop.nOut value downward to account for terms of the +// ** WHERE clause that reference the loop but which are not used by an +// ** index. +// * +// ** For every WHERE clause term that is not used by the index +// ** and which has a truth probability assigned by one of the likelihood(), +// ** likely(), or unlikely() SQL functions, reduce the estimated number +// ** of output rows by the probability specified. +// ** +// ** TUNING: For every WHERE clause term that is not used by the index +// ** and which does not have an assigned truth probability, heuristics +// ** described below are used to try to estimate the truth probability. +// ** TODO --> Perhaps this is something that could be improved by better +// ** table statistics. +// ** +// ** Heuristic 1: Estimate the truth probability as 93.75%. The 93.75% +// ** value corresponds to -1 in LogEst notation, so this means decrement +// ** the WhereLoop.nOut field for every such WHERE clause term. +// ** +// ** Heuristic 2: If there exists one or more WHERE clause terms of the +// ** form "x==EXPR" and EXPR is not a constant 0 or 1, then make sure the +// ** final output row estimate is no greater than 1/4 of the total number +// ** of rows in the table. In other words, assume that x==EXPR will filter +// ** out at least 3 out of 4 rows. If EXPR is -1 or 0 or 1, then maybe the +// ** "x" column is boolean or else -1 or 0 or 1 is a common default value +// ** on the "x" column and so in that case only cap the output row estimate +// ** at 1/2 instead of 1/4. +// ** +// ** Heuristic 3: If there is a LIKE or GLOB (or REGEXP or MATCH) operator +// ** with a large constant pattern, then reduce the size of the search +// ** space according to the length of the pattern, under the theory that +// ** longer patterns are less likely to match. This heuristic was added +// ** to give better output-row count estimates when preparing queries for +// ** the Join-Order Benchmarks. See forum thread 2026-01-30T09:57:54z +// */ +func _whereLoopOutputAdjust(tls *libc.TLS, pWC uintptr, pLoop uintptr, nRow TLogEst) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eOp, i, j, szPattern int32 + var iReduce TLogEst + var notAllowed TBitmask + var pOpExpr, pRHS, pRight, pTerm, pX, v3 uintptr + var _ /* k at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _ = eOp, i, iReduce, j, notAllowed, pOpExpr, pRHS, pRight, pTerm, pX, szPattern, v3 + notAllowed = ^((*TWhereLoop)(unsafe.Pointer(pLoop)).Fprereq | (*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf) + iReduce = 0 /* pLoop->nOut should not exceed nRow-iReduce */ + i = (*TWhereClause)(unsafe.Pointer(pWC)).FnBase + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(i > 0) { + break + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll¬Allowed != uint64(0) { + goto _1 + } + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf == uint64(0) { + goto _1 + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VIRTUAL) != 0 { + goto _1 + } + j = libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) - int32(1) + for { + if !(j >= 0) { + break + } + pX = **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) + if pX == uintptr(0) { + goto _2 + } + if pX == pTerm { + break + } + if (*TWhereTerm)(unsafe.Pointer(pX)).FiParent >= 0 && (*TWhereClause)(unsafe.Pointer(pWC)).Fa+uintptr((*TWhereTerm)(unsafe.Pointer(pX)).FiParent)*56 == pTerm { + break + } + goto _2 + _2: + ; + j = j - 1 + } + if j < 0 { + _sqlite3ProgressCheck(tls, (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse) + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf == (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll { + /* If there are extra terms in the WHERE clause not used by an index + ** that depend only on the table being scanned, and that will tend to + ** cause many rows to be omitted, then mark that table as + ** "self-culling". + ** + ** 2022-03-24: Self-culling only applies if either the extra terms + ** are straight comparison operators that are non-true with NULL + ** operand, or if the loop is not an OUTER JOIN. + */ + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(0x3f) != 0 || libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pLoop)).FiTab)*80))).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) == 0 { + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_SELFCULL) + } + } + if int32((*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 { + /* If a truth probability is specified using the likelihood() hints, + ** then use the probability provided by the application. */ + v3 = pLoop + 22 + *(*TLogEst)(unsafe.Pointer(v3)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v3))) + int32((*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb)) + } else { + /* In the absence of explicit truth probabilities, use heuristics to + ** guess a reasonable truth probability. */ + pOpExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + (*TWhereLoop)(unsafe.Pointer(pLoop)).FnOut = (*TWhereLoop)(unsafe.Pointer(pLoop)).FnOut - 1 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) != 0 && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_HIGHTRUTH) == 0 { + pRight = (*TExpr)(unsafe.Pointer(pOpExpr)).FpRight + **(**int32)(__ccgo_up(bp)) = 0 + if _sqlite3ExprIsInteger(tls, pRight, bp, uintptr(0)) != 0 && **(**int32)(__ccgo_up(bp)) >= -int32(1) && **(**int32)(__ccgo_up(bp)) <= int32(1) { + **(**int32)(__ccgo_up(bp)) = int32(10) + } else { + **(**int32)(__ccgo_up(bp)) = int32(20) + } + if int32(iReduce) < **(**int32)(__ccgo_up(bp)) { + v3 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(TERM_HEURTRUTH)) + iReduce = int16(**(**int32)(__ccgo_up(bp))) + } + } else { + if (*TExpr)(unsafe.Pointer(pOpExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InfixFunc)) != uint32(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pOpExpr)).Fop) == int32(TK_FUNCTION) { + eOp = _sqlite3ExprIsLikeOperator(tls, pOpExpr) + if eOp > 0 { + pRHS = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOpExpr + 32)) + 8))).FpExpr + eOp = libc.BoolInt32(eOp == int32(SQLITE_INDEX_CONSTRAINT_LIKE)) + szPattern = _estLikePatternLength(tls, pRHS, libc.Uint16FromInt32(eOp)) + if szPattern > 0 { + v3 = pLoop + 22 + *(*TLogEst)(unsafe.Pointer(v3)) = TLogEst(int32(*(*TLogEst)(unsafe.Pointer(v3))) - szPattern*libc.Int32FromInt32(2)) + } + } + } + } + } + } + goto _1 + _1: + ; + i = i - 1 + pTerm += 56 + } + if int32((*TWhereLoop)(unsafe.Pointer(pLoop)).FnOut) > int32(nRow)-int32(iReduce) { + (*TWhereLoop)(unsafe.Pointer(pLoop)).FnOut = int16(int32(nRow) - int32(iReduce)) + } +} + +// C documentation +// +// /* +// ** Return the N-th AND-connected subterm of pTerm. Or if pTerm is not +// ** a conjunction, then return just pTerm when N==0. If N is exceeds +// ** the number of available subterms, return NULL. +// */ +func _whereNthSubterm(tls *libc.TLS, pTerm uintptr, N int32) (r uintptr) { + var v1 uintptr + _ = v1 + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != int32(WO_AND) { + if N == 0 { + v1 = pTerm + } else { + v1 = uintptr(0) + } + return v1 + } + if N < (*TWhereAndInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 32)))).Fwc.FnTerm { + return (*TWhereAndInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 32)))).Fwc.Fa + uintptr(N)*56 + } + return uintptr(0) +} + +// C documentation +// +// /* Implementation of the order-by-subquery optimization: +// ** +// ** WhereLoop pLoop, which the iLoop-th term of the nested loop, is really +// ** a subquery or CTE that has an ORDER BY clause. See if any of the terms +// ** in the subquery ORDER BY clause will satisfy pOrderBy from the outer +// ** query. Mark off all satisfied terms (by setting bits in *pOBSat) and +// ** return TRUE if they do. If not, return false. +// ** +// ** Example: +// ** +// ** CREATE TABLE t1(a,b,c, PRIMARY KEY(a,b)); +// ** CREATE TABLE t2(x,y); +// ** WITH t3(p,q) AS MATERIALIZED (SELECT x+y, x-y FROM t2 ORDER BY x+y) +// ** SELECT * FROM t3 JOIN t1 ON a=q ORDER BY p, b; +// ** +// ** The CTE named "t3" comes out in the natural order of "p", so the first +// ** first them of "ORDER BY p,b" is satisfied by a sequential scan of "t3" +// ** and sorting only needs to occur on the second term "b". +// ** +// ** Limitations: +// ** +// ** (1) The optimization is not applied if the outer ORDER BY contains +// ** a COLLATE clause. The optimization might be applied if the +// ** outer ORDER BY uses NULLS FIRST, NULLS LAST, ASC, and/or DESC as +// ** long as the subquery ORDER BY does the same. But if the +// ** outer ORDER BY uses COLLATE, even a redundant COLLATE, the +// ** optimization is bypassed. +// ** +// ** (2) The subquery ORDER BY terms must exactly match subquery result +// ** columns, including any COLLATE annotations. This routine relies +// ** on iOrderByCol to do matching between order by terms and result +// ** columns, and iOrderByCol will not be set if the result column +// ** and ORDER BY collations differ. +// ** +// ** (3) The subquery and outer ORDER BY can be in opposite directions as +// ** long as the subquery is materialized. If the subquery is +// ** implemented as a co-routine, the sort orders must be in the same +// ** direction because there is no way to run a co-routine backwards. +// */ +func _wherePathMatchSubqueryOB(tls *libc.TLS, pWInfo uintptr, pLoop uintptr, iLoop int32, iCur int32, pOrderBy uintptr, pRevMask uintptr, pOBSat uintptr) (r int32) { + var iOB, jSub int32 + var pOBExpr, pSubOB uintptr + var rev, revIdx, sfOB, sfSub Tu8 + _, _, _, _, _, _, _, _ = iOB, jSub, pOBExpr, pSubOB, rev, revIdx, sfOB, sfSub /* Index into pSubOB->a[] */ + rev = uint8(0) /* True if iOB and jSub sort in opposite directions */ + revIdx = uint8(0) /* Complete ORDER BY on the subquery */ + pSubOB = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpOrderBy + iOB = 0 + for { + if !(libc.Uint64FromInt32(1)< 0 { + if libc.Int32FromUint8(rev)^libc.Int32FromUint8(revIdx) != libc.Int32FromUint8(sfOB)&int32(KEYINFO_ORDER_DESC) { + break + } + } else { + rev = libc.Uint8FromInt32(libc.Int32FromUint8(revIdx) ^ libc.Int32FromUint8(sfOB)&int32(KEYINFO_ORDER_DESC)) + if rev != 0 { + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_COROUTINE) != uint32(0) { + /* Cannot run a co-routine in reverse order */ + break + } + **(**TBitmask)(__ccgo_up(pRevMask)) |= libc.Uint64FromInt32(1) << iLoop + } + } + } + **(**TBitmask)(__ccgo_up(pOBSat)) |= libc.Uint64FromInt32(1) << iOB + goto _2 + _2: + ; + jSub = jSub + 1 + iOB = iOB + 1 + } + return libc.BoolInt32(jSub > 0) +} + +// C documentation +// +// /* +// ** Examine a WherePath (with the addition of the extra WhereLoop of the 6th +// ** parameters) to see if it outputs rows in the requested ORDER BY +// ** (or GROUP BY) without requiring a separate sort operation. Return N: +// ** +// ** N>0: N terms of the ORDER BY clause are satisfied +// ** N==0: No terms of the ORDER BY clause are satisfied +// ** N<0: Unknown yet how many terms of ORDER BY might be satisfied. +// ** +// ** Note that processing for WHERE_GROUPBY and WHERE_DISTINCTBY is not as +// ** strict. With GROUP BY and DISTINCT the only requirement is that +// ** equivalent rows appear immediately adjacent to one another. GROUP BY +// ** and DISTINCT do not require rows to appear in any particular order as long +// ** as equivalent rows are grouped together. Thus for GROUP BY and DISTINCT +// ** the pOrderBy terms can be matched in any order. With ORDER BY, the +// ** pOrderBy terms must be matched in strict left-to-right order. +// */ +func _wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, pPath uintptr, wctrlFlags Tu16, nLoop Tu16, pLast uintptr, pRevMask uintptr) (r Ti8) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bOnce, distinctColumns, isMatch, isOrderDistinct, rev, revIdx, revSet, v5 Tu8 + var db, p, pColl, pColl1, pColl2, pIndex, pIxExpr, pLoop, pOBExpr, pParse, pTerm, pX, v4 uintptr + var eOp, eqOpMask, nColumn, nKeyCol, nOrderBy Tu16 + var i, iColumn, iCur, iLoop, j int32 + var m, mTerm, obDone, orderDistinctMask, ready TBitmask + var v11 uint64 + var _ /* obSat at bp+0 */ TBitmask + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bOnce, db, distinctColumns, eOp, eqOpMask, i, iColumn, iCur, iLoop, isMatch, isOrderDistinct, j, m, mTerm, nColumn, nKeyCol, nOrderBy, obDone, orderDistinctMask, p, pColl, pColl1, pColl2, pIndex, pIxExpr, pLoop, pOBExpr, pParse, pTerm, pX, ready, rev, revIdx, revSet, v11, v4, v5 /* A column number within table iCur */ + pLoop = uintptr(0) /* The index associated with pLoop */ + db = (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb /* Database connection */ + **(**TBitmask)(__ccgo_up(bp)) = uint64(0) /* Mask of inner loops */ + /* + ** We say the WhereLoop is "one-row" if it generates no more than one + ** row of output. A WhereLoop is one-row if all of the following are true: + ** (a) All index columns match with WHERE_COLUMN_EQ. + ** (b) The index is unique + ** Any WhereLoop with an WHERE_COLUMN_EQ constraint on the rowid is one-row. + ** Every one-row WhereLoop will have the WHERE_ONEROW bit set in wsFlags. + ** + ** We say the WhereLoop is "order-distinct" if the set of columns from + ** that WhereLoop that are in the ORDER BY clause are different for every + ** row of the WhereLoop. Every one-row WhereLoop is automatically + ** order-distinct. A WhereLoop that has no columns in the ORDER BY clause + ** is not order-distinct. To be order-distinct is not quite the same as being + ** UNIQUE since a UNIQUE column or index can have multiple rows that + ** are NULL and NULL values are equivalent for the purpose of order-distinct. + ** To be order-distinct, the columns must be UNIQUE and NOT NULL. + ** + ** The rowid for a table is always UNIQUE and NOT NULL so whenever the + ** rowid appears in the ORDER BY clause, the corresponding WhereLoop is + ** automatically order-distinct. + */ + if nLoop != 0 && (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OrderByIdxJoin)) != uint32(0) { + return 0 + } + nOrderBy = libc.Uint16FromInt32((*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) + if libc.Int32FromUint16(nOrderBy) > libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + return 0 + } /* Cannot optimize overly large ORDER BYs */ + isOrderDistinct = uint8(1) + obDone = libc.Uint64FromInt32(1)< 0 { + ready = ready | (*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf + } + if iLoop < libc.Int32FromUint16(nLoop) { + pLoop = **(**uintptr)(__ccgo_up((*TWherePath)(unsafe.Pointer(pPath)).FaLoop + uintptr(iLoop)*8)) + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_ORDERBY_LIMIT) != 0 { + goto _1 + } + } else { + pLoop = pLast + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != 0 { + if (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FisOrdered != 0 && (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == pOrderBy { + **(**TBitmask)(__ccgo_up(bp)) = obDone + } else { + /* No further ORDER BY terms may be matched. So this call should + ** return >=0, not -1. Clear isOrderDistinct to ensure it does so. */ + isOrderDistinct = uint8(0) + } + break + } + iCur = (*(*TSrcItem)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLoop)(unsafe.Pointer(pLoop)).FiTab)*80))).FiCursor + /* Mark off any ORDER BY term X that is a column in the table of + ** the current loop for which there is term in the WHERE + ** clause of the form X IS NULL or X=? that reference only outer + ** loops. + */ + i = 0 + for { + if !(i < libc.Int32FromUint16(nOrderBy)) { + break + } + if libc.Uint64FromInt32(1)<= libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) { + goto _2 + } + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)) != 0 && int32((*TExpr)(unsafe.Pointer(pOBExpr)).FiColumn) >= 0 { + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse + pColl1 = _sqlite3ExprNNCollSeq(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).FpExpr) + pColl2 = _sqlite3ExprCompareCollSeq(tls, pParse, (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr) + if pColl2 == uintptr(0) || _sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pColl1)).FzName, (*TCollSeq)(unsafe.Pointer(pColl2)).FzName) != 0 { + goto _2 + } + } + **(**TBitmask)(__ccgo_up(bp)) = **(**TBitmask)(__ccgo_up(bp)) | libc.Uint64FromInt32(1)<>2)) != 0 { + return 0 + } else { + nKeyCol = (*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol + nColumn = (*TIndex)(unsafe.Pointer(pIndex)).FnColumn + /* All relevant terms of the index must also be non-NULL in order + ** for isOrderDistinct to be true. So the isOrderDistinct value + ** computed here might be a false positive. Corrections will be + ** made at tag-20210426-1 below */ + isOrderDistinct = libc.BoolUint8(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) != OE_None && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_SKIPSCAN) == uint32(0)) + } + } + /* Loop through all columns of the index and deal with the ones + ** that are not constrained by == or IN. + */ + v5 = libc.Uint8FromInt32(0) + revSet = v5 + rev = v5 + distinctColumns = uint8(0) + j = 0 + for { + if !(j < libc.Int32FromUint16(nColumn)) { + break + } + bOnce = uint8(1) /* True to run the ORDER BY search loop */ + if j < libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) && j >= libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) { + eOp = (*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)))).FeOperator + /* Skip over == and IS and ISNULL terms. (Also skip IN terms when + ** doing WHERE_ORDERBY_LIMIT processing). Except, IS and ISNULL + ** terms imply that the index is not UNIQUE NOT NULL in which case + ** the loop need to be marked as not order-distinct because it can + ** have repeated NULL rows. + ** + ** If the current term is a column of an ((?,?) IN (SELECT...)) + ** expression for which the SELECT returns more than one column, + ** check that it is the only column used by this loop. Otherwise, + ** if it is one of two or more, none of the columns can be + ** considered to match an ORDER BY term. + */ + if libc.Int32FromUint16(eOp)&libc.Int32FromUint16(eqOpMask) != 0 { + if libc.Int32FromUint16(eOp)&(libc.Int32FromInt32(WO_ISNULL)|libc.Int32FromInt32(WO_IS)) != 0 { + isOrderDistinct = uint8(0) + } + goto _6 + } else { + if libc.Int32FromUint16(eOp)&int32(WO_IN) != 0 { + /* ALWAYS() justification: eOp is an equality operator due to the + ** ju.btree.nEq constraint above. Any equality other + ** than WO_IN is captured by the previous "if". So this one + ** always has to be WO_IN. */ + pX = (*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)))).FpExpr + i = j + int32(1) + for { + if !(i < libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq)) { + break + } + if (*TWhereTerm)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)))).FpExpr == pX { + bOnce = uint8(0) + break + } + goto _7 + _7: + ; + i = i + 1 + } + } + } + } + /* Get the column number in the table (iColumn) and sort order + ** (revIdx) for the j-th column of the index. + */ + if pIndex != 0 { + iColumn = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(j)*2))) + revIdx = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(j)))) & int32(KEYINFO_ORDER_DESC)) + if iColumn == int32((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIndex)).FpTable)).FiPKey) { + iColumn = -int32(1) + } + } else { + iColumn = -int32(1) + revIdx = uint8(0) + } + /* An unconstrained column that might be NULL means that this + ** WhereLoop is not well-ordered. tag-20210426-1 + */ + if isOrderDistinct != 0 { + if iColumn >= 0 && j >= libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIndex)).FpTable)).FaCol + uintptr(iColumn)*16 + 8))&0xf>>0)) == 0 { + isOrderDistinct = uint8(0) + } + if iColumn == -int32(2) { + isOrderDistinct = uint8(0) + } + } + /* Find the ORDER BY term that corresponds to the j-th column + ** of the index and mark that ORDER BY term having been satisfied. + */ + isMatch = uint8(0) + i = 0 + for { + if !(bOnce != 0 && i < libc.Int32FromUint16(nOrderBy)) { + break + } + if libc.Uint64FromInt32(1)<= -int32(1) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pOBExpr)).Fop) != int32(TK_COLUMN) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pOBExpr)).Fop) != int32(TK_AGG_COLUMN) { + goto _8 + } + if (*TExpr)(unsafe.Pointer(pOBExpr)).FiTable != iCur { + goto _8 + } + if int32((*TExpr)(unsafe.Pointer(pOBExpr)).FiColumn) != iColumn { + goto _8 + } + } else { + pIxExpr = (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIndex)).FaColExpr + 8 + uintptr(j)*32))).FpExpr + if _sqlite3ExprCompareSkip(tls, pOBExpr, pIxExpr, iCur) != 0 { + goto _8 + } + } + if iColumn != -int32(1) { + pColl = _sqlite3ExprNNCollSeq(tls, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse, (*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).FpExpr) + if _sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pColl)).FzName, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(j)*8))) != 0 { + goto _8 + } + } + if libc.Int32FromUint16(wctrlFlags)&int32(WHERE_DISTINCTBY) != 0 { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnDistinctCol = libc.Uint16FromInt32(j + int32(1)) + } + isMatch = uint8(1) + break + goto _8 + _8: + ; + i = i + 1 + } + if isMatch != 0 && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_GROUPBY) == 0 { + /* Make sure the sort order is compatible in an ORDER BY clause. + ** Sort order is irrelevant for a GROUP BY clause. */ + if revSet != 0 { + if libc.Int32FromUint8(rev)^libc.Int32FromUint8(revIdx) != libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_DESC) { + isMatch = uint8(0) + } + } else { + rev = libc.Uint8FromInt32(libc.Int32FromUint8(revIdx) ^ libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_DESC)) + if rev != 0 { + **(**TBitmask)(__ccgo_up(pRevMask)) |= libc.Uint64FromInt32(1) << iLoop + } + revSet = uint8(1) + } + } + if isMatch != 0 && libc.Int32FromUint8((*(*TExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*32))).Ffg.FsortFlags)&int32(KEYINFO_ORDER_BIGNULL) != 0 { + if j == libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) { + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_BIGNULL_SORT) + } else { + isMatch = uint8(0) + } + } + if isMatch != 0 { + if iColumn == -int32(1) { + distinctColumns = uint8(1) + } + **(**TBitmask)(__ccgo_up(bp)) = **(**TBitmask)(__ccgo_up(bp)) | libc.Uint64FromInt32(1)< 0) { + break + } + if i < libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v11 = libc.Uint64FromInt32(1)<>9) != 0) || libc.Int32FromUint8((*TCteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 56)))).FeM10d) != M10d_Yes || int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) == 0 || (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect)).FpOrderBy == uintptr(0) { + **(**TBitmask)(__ccgo_up(pWInfo + 96)) |= libc.Uint64FromInt32(1) << ii + } + goto _1 + _1: + ; + ii = ii + 1 + } +} + +// C documentation +// +// /* +// ** Most queries use only a single table (they are not joins) and have +// ** simple == constraints against indexed fields. This routine attempts +// ** to plan those simple cases using much less ceremony than the +// ** general-purpose query planner, and thereby yield faster sqlite3_prepare() +// ** times for the common case. +// ** +// ** Return non-zero on success, if this query can be handled by this +// ** no-frills query planner. Return zero if this query needs the +// ** general-purpose query planner. +// */ +func _whereShortCut(tls *libc.TLS, pBuilder uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var iCur, j, opMask, v2 int32 + var pIdx, pItem, pLoop, pTab, pTerm, pWC, pWInfo uintptr + var _ /* scan at bp+0 */ TWhereScan + _, _, _, _, _, _, _, _, _, _, _ = iCur, j, opMask, pIdx, pItem, pLoop, pTab, pTerm, pWC, pWInfo, v2 + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_OR_SUBCLAUSE) != 0 { + return 0 + } + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + return 0 + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x2>>1) != 0 || int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x1>>0) != 0 { + return 0 + } + iCur = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + pWC = pWInfo + 104 + pLoop = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = uint32(0) + (*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip = uint16(0) + pTerm = _whereScanInit(tls, bp, pWC, iCur, -int32(1), libc.Uint32FromInt32(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_IS)), uintptr(0)) + for pTerm != 0 && (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight != 0 { + pTerm = _whereScanNext(tls, bp) + } + if pTerm != 0 { + (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_EQ) | libc.Int32FromInt32(WHERE_IPK) | libc.Int32FromInt32(WHERE_ONEROW)) + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) = pTerm + (*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm = uint16(1) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq = uint16(1) + /* TUNING: Cost of a rowid lookup is 10 */ + (*TWhereLoop)(unsafe.Pointer(pLoop)).FrRun = int16(33) /* 33==sqlite3LogEst(10) */ + } else { + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromInt32(OE_None)) || (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) || libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) > libc.Int32FromUint64(libc.Uint64FromInt64(24)/libc.Uint64FromInt64(8)) { + goto _1 + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x8>>3)) != 0 { + v2 = libc.Int32FromInt32(WO_EQ) | libc.Int32FromInt32(WO_IS) + } else { + v2 = int32(WO_EQ) + } + opMask = v2 + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + pTerm = _whereScanInit(tls, bp, pWC, iCur, j, libc.Uint32FromInt32(opMask), pIdx) + for pTerm != 0 && (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight != 0 { + pTerm = _whereScanNext(tls, bp) + } + if pTerm == uintptr(0) { + break + } + **(**uintptr)(__ccgo_up((*TWhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) = pTerm + goto _3 + _3: + ; + j = j + 1 + } + if j != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + goto _1 + } + (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_EQ) | libc.Int32FromInt32(WHERE_ONEROW) | libc.Int32FromInt32(WHERE_INDEXED)) + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x20>>5)) != 0 || (*TSrcItem)(unsafe.Pointer(pItem)).FcolUsed&(*TIndex)(unsafe.Pointer(pIdx)).FcolNotIdxed == uint64(0) { + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_IDX_ONLY) + } + (*TWhereLoop)(unsafe.Pointer(pLoop)).FnLTerm = libc.Uint16FromInt32(j) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq = libc.Uint16FromInt32(j) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex = pIdx + /* TUNING: Cost of a unique index lookup is 15 */ + (*TWhereLoop)(unsafe.Pointer(pLoop)).FrRun = int16(39) /* 39==sqlite3LogEst(15) */ + break + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags != 0 { + (*TWhereLoop)(unsafe.Pointer(pLoop)).FnOut = libc.Int16FromInt32(1) + (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856))).FpWLoop = pLoop + (*TWhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf = uint64(1) /* sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); */ + (*(*TWhereLevel)(unsafe.Pointer(pWInfo + 856))).FiTabCur = iCur + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut = int16(1) + if (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = int8((*TExprList)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr) + } + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 { + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = uint8(WHERE_DISTINCT_UNIQUE) + } + if libc.Int32FromUint8((**(**TWhereScan)(__ccgo_up(bp))).FiEquiv) > int32(1) { + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_TRANSCONS) + } + return int32(1) + } + return 0 +} + +// C documentation +// +// /* Check to see if a partial index with pPartIndexWhere can be used +// ** in the current query. Return true if it can be and false if not. +// */ +func _whereUsablePartialIndex(tls *libc.TLS, iTab int32, jointype Tu8, pWC uintptr, pWhere uintptr) (r int32) { + var i int32 + var pExpr, pParse, pTerm uintptr + _, _, _, _ = i, pExpr, pParse, pTerm + if libc.Int32FromUint8(jointype)&int32(JT_LTORJ) != 0 { + return 0 + } + pParse = (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pWhere)).Fop) == int32(TK_AND) { + if !(_whereUsablePartialIndex(tls, iTab, jointype, pWC, (*TExpr)(unsafe.Pointer(pWhere)).FpLeft) != 0) { + return 0 + } + pWhere = (*TExpr)(unsafe.Pointer(pWhere)).FpRight + } + i = 0 + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(i < (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm) { + break + } + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + if (!((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) || *(*int32)(unsafe.Pointer(pExpr + 52)) == iTab) && (libc.Int32FromUint8(jointype)&int32(JT_OUTER) == 0 || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0)) && _sqlite3ExprImpliesExpr(tls, pParse, pExpr, pWhere, iTab) != 0 && !(_sqlite3ExprImpliesExpr(tls, pParse, pExpr, pWhere, -int32(1)) != 0) && libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VNULL) == 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + pTerm += 56 + } + return 0 +} + +// C documentation +// +// /* +// ** Generate VM code to invoke either xStep() (if bInverse is 0) or +// ** xInverse (if bInverse is non-zero) for each window function in the +// ** linked list starting at pMWin. Or, for built-in window functions +// ** that do not use the standard function API, generate the required +// ** inline VM code. +// ** +// ** If argument csr is greater than or equal to 0, then argument reg is +// ** the first register in an array of registers guaranteed to be large +// ** enough to hold the array of arguments for each function. In this case +// ** the arguments are extracted from the current row of csr into the +// ** array of registers before invoking OP_AggStep or OP_AggInverse +// ** +// ** Or, if csr is less than zero, then the array of registers at reg is +// ** already populated with all columns from the current row of the sub-query. +// ** +// ** If argument regPartSize is non-zero, then it is a register containing the +// ** number of rows in the current partition. +// */ +func _windowAggStep(tls *libc.TLS, p uintptr, pMWin uintptr, csr int32, bInverse int32, reg int32) { + var addrIf, addrIsNull, i, iEnd, iOp, nArg, regArg, regTmp, v2 int32 + var pColl, pFunc, pOp, pParse, pWin, v uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrIf, addrIsNull, i, iEnd, iOp, nArg, pColl, pFunc, pOp, pParse, pWin, regArg, regTmp, v, v2 + pParse = (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse + v = _sqlite3GetVdbe(tls, pParse) + pWin = pMWin + for { + if !(pWin != 0) { + break + } + pFunc = (*TWindow)(unsafe.Pointer(pWin)).FpWFunc + if (*TWindow)(unsafe.Pointer(pWin)).FbExprArgs != 0 { + v2 = 0 + } else { + v2 = _windowArgCount(tls, pWin) + } + nArg = v2 + addrIf = 0 + /* All OVER clauses in the same window function aggregate step must + ** be the same. */ + i = 0 + for { + if !(i < nArg) { + break + } + if i != int32(1) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName != uintptr(unsafe.Pointer(&_nth_valueName)) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), csr, (*TWindow)(unsafe.Pointer(pWin)).FiArgCol+i, reg+i) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr, (*TWindow)(unsafe.Pointer(pWin)).FiArgCol+i, reg+i) + } + goto _3 + _3: + ; + i = i + 1 + } + regArg = reg + if (*TWindow)(unsafe.Pointer(pWin)).FpFilter != 0 { + regTmp = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), csr, (*TWindow)(unsafe.Pointer(pWin)).FiArgCol+nArg, regTmp) + addrIf = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNot), regTmp, 0, int32(1)) + _sqlite3ReleaseTempReg(tls, pParse, regTmp) + } + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid == 0 && (*TFuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&uint32(SQLITE_FUNC_MINMAX) != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeStart) != int32(TK_UNBOUNDED) { + addrIsNull = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), regArg) + if bInverse == 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(1), int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), regArg, (*TWindow)(unsafe.Pointer(pWin)).FregApp) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (*TWindow)(unsafe.Pointer(pWin)).FregApp, int32(2), (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(2)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(2)) + } else { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_SeekGE), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, 0, regArg, int32(1)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Delete), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp) + _sqlite3VdbeJumpHere(tls, v, _sqlite3VdbeCurrentAddr(tls, v)-int32(2)) + } + _sqlite3VdbeJumpHere(tls, v, addrIsNull) + } else { + if (*TWindow)(unsafe.Pointer(pWin)).FregApp != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(1)-bInverse, int32(1)) + } else { + if (*TFuncDef)(unsafe.Pointer(pFunc)).FxSFunc != __ccgo_fp(_noopStepFunc) { + if (*TWindow)(unsafe.Pointer(pWin)).FbExprArgs != 0 { + iOp = _sqlite3VdbeCurrentAddr(tls, v) + nArg = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)))).FnExpr + regArg = _sqlite3GetTempRange(tls, pParse, nArg) + _sqlite3ExprCodeExprList(tls, pParse, *(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)), regArg, 0, uint8(0)) + iEnd = _sqlite3VdbeCurrentAddr(tls, v) + for { + if !(iOp < iEnd) { + break + } + pOp = _sqlite3VdbeGetOp(tls, v, iOp) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Column) && (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 == (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = csr + } + goto _4 + _4: + ; + iOp = iOp + 1 + } + } + if (*TFuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 { + pColl = _sqlite3ExprNNCollSeq(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)) + 8))).FpExpr) + _sqlite3VdbeAddOp4(tls, v, int32(OP_CollSeq), 0, 0, 0, pColl, -int32(2)) + } + if bInverse != 0 { + v2 = int32(OP_AggInverse) + } else { + v2 = int32(OP_AggStep) + } + _sqlite3VdbeAddOp3(tls, v, v2, bInverse, regArg, (*TWindow)(unsafe.Pointer(pWin)).FregAccum) + _sqlite3VdbeAppendP4(tls, v, pFunc, -int32(8)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(nArg)) + if (*TWindow)(unsafe.Pointer(pWin)).FbExprArgs != 0 { + _sqlite3ReleaseTempRange(tls, pParse, regArg, nArg) + } + } + } + } + if addrIf != 0 { + _sqlite3VdbeJumpHere(tls, v, addrIf) + } + goto _1 + _1: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } +} + +/* +** Values that may be passed as the second argument to windowCodeOp(). + */ + +// C documentation +// +// /* +// ** Check to see if index pSrc is compatible as a source of data +// ** for index pDest in an insert transfer optimization. The rules +// ** for a compatible index: +// ** +// ** * The index is over the same set of columns +// ** * The same DESC and ASC markings occurs on all columns +// ** * The same onError processing (OE_Abort, OE_Ignore, etc) +// ** * The same collating sequence on each column +// ** * The index has the exact same WHERE clause +// */ +func _xferCompatibleIndex(tls *libc.TLS, pDest uintptr, pSrc uintptr) (r int32) { + var i int32 + _ = i + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pDest)).FnKeyCol) != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pSrc)).FnKeyCol) || libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pDest)).FnColumn) != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pSrc)).FnColumn) { + return 0 /* Different number of columns */ + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pDest)).FonError) != libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pSrc)).FonError) { + return 0 /* Different conflict resolution strategies */ + } + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pSrc)).FnKeyCol)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pSrc)).FaiColumn + uintptr(i)*2))) != int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pDest)).FaiColumn + uintptr(i)*2))) { + return 0 /* Different columns indexed */ + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pSrc)).FaiColumn + uintptr(i)*2))) == -int32(2) { + if _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pSrc)).FaColExpr + 8 + uintptr(i)*32))).FpExpr, (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pDest)).FaColExpr + 8 + uintptr(i)*32))).FpExpr, -int32(1)) != 0 { + return 0 /* Different expressions in the index */ + } + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pSrc)).FaSortOrder + uintptr(i)))) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pDest)).FaSortOrder + uintptr(i)))) { + return 0 /* Different sort orders */ + } + if Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pSrc)).FazColl + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pDest)).FazColl + uintptr(i)*8))) != 0 { + return 0 /* Different collating sequences */ + } + goto _1 + _1: + ; + i = i + 1 + } + if _sqlite3ExprCompare(tls, uintptr(0), (*TIndex)(unsafe.Pointer(pSrc)).FpPartIdxWhere, (*TIndex)(unsafe.Pointer(pDest)).FpPartIdxWhere, -int32(1)) != 0 { + return 0 /* Different WHERE clauses */ + } + /* If no test above fails then the indices must be compatible */ + return int32(1) +} + +// C documentation +// +// /* +// ** Perform a shift action. +// */ +func _yy_shift(tls *libc.TLS, yypParser uintptr, yyNewState uint16, yyMajor uint16, yyMinor TToken) { + var yytos uintptr + _ = yytos + (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos += 24 + yytos = (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos + if yytos > (*TyyParser)(unsafe.Pointer(yypParser)).FyystackEnd { + if _yyGrowStack(tls, yypParser) != 0 { + (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos -= 24 + _yyStackOverflow(tls, yypParser) + return + } + yytos = (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos + } + if libc.Int32FromUint16(yyNewState) > int32(YY_MAX_SHIFT) { + yyNewState = libc.Uint16FromInt32(int32(yyNewState) + (libc.Int32FromInt32(YY_MIN_REDUCE) - libc.Int32FromInt32(YY_MIN_SHIFTREDUCE))) + } + (*TyyStackEntry)(unsafe.Pointer(yytos)).Fstateno = yyNewState + (*TyyStackEntry)(unsafe.Pointer(yytos)).Fmajor = yyMajor + *(*TToken)(unsafe.Pointer(yytos + 8)) = yyMinor +} + +func init() { + p := unsafe.Pointer(&_dotlockIoMethods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_dotlockClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_unixRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_unixWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_unixTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_dotlockLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_dotlockUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_dotlockCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixShmLock) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixShmBarrier) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixShmUnmap) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixFetch) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixUnfetch) +} + +func init() { + p := unsafe.Pointer(&_posixIoMethods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_unixClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_unixRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_unixWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_unixTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_unixLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_unixUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_unixCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_unixShmMap) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixShmLock) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixShmBarrier) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixShmUnmap) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixFetch) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixUnfetch) +} + +func init() { + p := unsafe.Pointer(&_nolockIoMethods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_nolockClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_unixRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_unixWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_unixTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_unixSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_unixFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_nolockLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_nolockUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_nolockCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_unixFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_unixSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_unixShmLock) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_unixShmBarrier) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_unixShmUnmap) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_unixFetch) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_unixUnfetch) +} diff --git a/internal/engine/lib/sqlite_g_000000000001feec.go b/internal/engine/lib/sqlite_g_000000000001feec.go new file mode 100644 index 0000000..266f6d9 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001feec.go @@ -0,0 +1,25 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Ttimeval = struct { + Ftv_sec Ttime_t + Ftv_usec Tsuseconds_t +} + +/* Shared memory instance */ +type TunixInodeInfo = struct { + FfileId TunixFileId + FpLockMutex uintptr + FnShared int32 + FnLock int32 + FeFileLock uint8 + FbProcessLock uint8 + FpUnused uintptr + FnRef int32 + FpShmNode uintptr + FpNext uintptr + FpPrev uintptr +} diff --git a/internal/engine/lib/sqlite_g_000000000001feef.go b/internal/engine/lib/sqlite_g_000000000001feef.go new file mode 100644 index 0000000..0b98711 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001feef.go @@ -0,0 +1,113 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "github.com/hanzoai/sqlite/internal/libc" +) + +type Titimerval = struct { + Fit_interval Ttimeval + Fit_value Ttimeval +} + +/* +** An instance of the following structure serves as the key used +** to locate a particular unixInodeInfo object. + */ +type TunixFileId = struct { + Fdev Tdev_t + Fino Tu64 +} + +var _aFlagOp = [21]struct { + Fop int32 + Fmask Tu64 +}{ + 0: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_FKEY), + Fmask: uint64(SQLITE_ForeignKeys), + }, + 1: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_TRIGGER), + Fmask: uint64(SQLITE_EnableTrigger), + }, + 2: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_VIEW), + Fmask: uint64(SQLITE_EnableView), + }, + 3: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER), + Fmask: uint64(SQLITE_Fts3Tokenizer), + }, + 4: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION), + Fmask: uint64(SQLITE_LoadExtension), + }, + 5: { + Fop: int32(SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE), + Fmask: uint64(SQLITE_NoCkptOnClose), + }, + 6: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_QPSG), + Fmask: uint64(SQLITE_EnableQPSG), + }, + 7: { + Fop: int32(SQLITE_DBCONFIG_TRIGGER_EQP), + Fmask: uint64(SQLITE_TriggerEQP), + }, + 8: { + Fop: int32(SQLITE_DBCONFIG_RESET_DATABASE), + Fmask: uint64(SQLITE_ResetDatabase), + }, + 9: { + Fop: int32(SQLITE_DBCONFIG_DEFENSIVE), + Fmask: uint64(SQLITE_Defensive), + }, + 10: { + Fop: int32(SQLITE_DBCONFIG_WRITABLE_SCHEMA), + Fmask: libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_WriteSchema) | libc.Int32FromInt32(SQLITE_NoSchemaError)), + }, + 11: { + Fop: int32(SQLITE_DBCONFIG_LEGACY_ALTER_TABLE), + Fmask: uint64(SQLITE_LegacyAlter), + }, + 12: { + Fop: int32(SQLITE_DBCONFIG_DQS_DDL), + Fmask: uint64(SQLITE_DqsDDL), + }, + 13: { + Fop: int32(SQLITE_DBCONFIG_DQS_DML), + Fmask: uint64(SQLITE_DqsDML), + }, + 14: { + Fop: int32(SQLITE_DBCONFIG_LEGACY_FILE_FORMAT), + Fmask: uint64(SQLITE_LegacyFileFmt), + }, + 15: { + Fop: int32(SQLITE_DBCONFIG_TRUSTED_SCHEMA), + Fmask: uint64(SQLITE_TrustedSchema), + }, + 16: { + Fop: int32(SQLITE_DBCONFIG_STMT_SCANSTATUS), + Fmask: uint64(SQLITE_StmtScanStatus), + }, + 17: { + Fop: int32(SQLITE_DBCONFIG_REVERSE_SCANORDER), + Fmask: uint64(SQLITE_ReverseOrder), + }, + 18: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE), + Fmask: libc.Uint64FromInt32(libc.Int32FromInt32(0x00010)) << libc.Int32FromInt32(32), + }, + 19: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE), + Fmask: libc.Uint64FromInt32(libc.Int32FromInt32(0x00020)) << libc.Int32FromInt32(32), + }, + 20: { + Fop: int32(SQLITE_DBCONFIG_ENABLE_COMMENTS), + Fmask: libc.Uint64FromInt32(libc.Int32FromInt32(0x00040)) << libc.Int32FromInt32(32), + }, +} diff --git a/internal/engine/lib/sqlite_g_000000000001ffbb.go b/internal/engine/lib/sqlite_g_000000000001ffbb.go new file mode 100644 index 0000000..550b49c --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001ffbb.go @@ -0,0 +1,696 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +func _fts5DoclistIterNext(tls *libc.TLS, pIter uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p uintptr + var _ /* iDelta at bp+0 */ Ti64 + var _ /* nPos at bp+8 */ int32 + _ = p + p = (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist + uintptr((*TFts5DoclistIter)(unsafe.Pointer(pIter)).FnSize) + uintptr((*TFts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist) + if p >= (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaEof { + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = uintptr(0) + } else { + p = p + uintptr(_sqlite3Fts5GetVarint(tls, p, bp)) + **(**Ti64)(__ccgo_up(pIter + 8)) += **(**Ti64)(__ccgo_up(bp)) + /* Read position list size */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(p)))&int32(0x80) != 0 { + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FnSize = _sqlite3Fts5GetVarint32(tls, p, bp+8) + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = **(**int32)(__ccgo_up(bp + 8)) >> int32(1) + } else { + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(p))) >> int32(1) + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FnSize = int32(1) + } + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = p + if (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist+uintptr((*TFts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist) > (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaEof { + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = uintptr(0) + } + } +} + +// C documentation +// +// /* +// ** A total of nLeaf leaf pages of data has just been flushed to a level-0 +// ** segment. This function updates the write-counter accordingly and, if +// ** necessary, performs incremental merge work. +// ** +// ** If an error occurs, set the Fts5Index.rc error code. If an error has +// ** already occurred, this function is a no-op. +// */ +func _fts5IndexAutomerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nLeaf int32) { + var nRem, nWork int32 + var nWrite Tu64 + var pStruct uintptr + _, _, _, _ = nRem, nWork, nWrite, pStruct + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FnAutomerge > 0 && **(**uintptr)(__ccgo_up(ppStruct)) != uintptr(0) { + pStruct = **(**uintptr)(__ccgo_up(ppStruct)) /* Number of leaf pages left to write */ + /* Update the write-counter. While doing so, set nWork. */ + nWrite = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnWriteCounter + nWork = libc.Int32FromUint64((nWrite+libc.Uint64FromInt32(nLeaf))/libc.Uint64FromInt32((*TFts5Index)(unsafe.Pointer(p)).FnWorkUnit) - nWrite/libc.Uint64FromInt32((*TFts5Index)(unsafe.Pointer(p)).FnWorkUnit)) + **(**Tu64)(__ccgo_up(pStruct + 8)) += libc.Uint64FromInt32(nLeaf) + nRem = (*TFts5Index)(unsafe.Pointer(p)).FnWorkUnit * nWork * (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel + _fts5IndexMerge(tls, p, ppStruct, nRem, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FnAutomerge) + } +} + +// C documentation +// +// /* +// ** Check the RTree node or entry given by pCellData and p against the MATCH +// ** constraint pConstraint. +// */ +func _rtreeCallbackConstraint(tls *libc.TLS, pConstraint uintptr, eInt int32, pCellData uintptr, pSearch uintptr, prScore uintptr, peWithin uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var nCoord, rc, v2 int32 + var pInfo uintptr + var v1 Tsqlite3_rtree_dbl + var _ /* aCoord at bp+8 */ [10]Tsqlite3_rtree_dbl + var _ /* c at bp+0 */ TRtreeCoord + var _ /* eWithin at bp+88 */ int32 + _, _, _, _, _ = nCoord, pInfo, rc, v1, v2 + pInfo = (*TRtreeConstraint)(unsafe.Pointer(pConstraint)).FpInfo /* Callback info */ + nCoord = (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FnCoord /* Decoded coordinates */ + if (*TRtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == int32(RTREE_QUERY) && libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(pSearch)).FiLevel) == int32(1) { + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FiRowid = _readInt64(tls, pCellData) + } + pCellData = pCellData + uintptr(8) + if eInt == 0 { + switch nCoord { + case int32(10): + _readCoord(tls, pCellData+uintptr(36), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(9)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData+uintptr(32), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(8)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + fallthrough + case int32(8): + _readCoord(tls, pCellData+uintptr(28), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(7)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData+uintptr(24), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(6)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + fallthrough + case int32(6): + _readCoord(tls, pCellData+uintptr(20), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(5)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData+uintptr(16), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(4)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + fallthrough + case int32(4): + _readCoord(tls, pCellData+uintptr(12), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(3)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData+uintptr(8), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(2)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + fallthrough + default: + _readCoord(tls, pCellData+uintptr(4), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(1)] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData, bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[0] = float64(*(*TRtreeValue)(unsafe.Pointer(bp))) + } + } else { + switch nCoord { + case int32(10): + _readCoord(tls, pCellData+uintptr(36), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(9)] = float64(*(*int32)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData+uintptr(32), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(8)] = float64(*(*int32)(unsafe.Pointer(bp))) + fallthrough + case int32(8): + _readCoord(tls, pCellData+uintptr(28), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(7)] = float64(*(*int32)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData+uintptr(24), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(6)] = float64(*(*int32)(unsafe.Pointer(bp))) + fallthrough + case int32(6): + _readCoord(tls, pCellData+uintptr(20), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(5)] = float64(*(*int32)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData+uintptr(16), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(4)] = float64(*(*int32)(unsafe.Pointer(bp))) + fallthrough + case int32(4): + _readCoord(tls, pCellData+uintptr(12), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(3)] = float64(*(*int32)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData+uintptr(8), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(2)] = float64(*(*int32)(unsafe.Pointer(bp))) + fallthrough + default: + _readCoord(tls, pCellData+uintptr(4), bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[int32(1)] = float64(*(*int32)(unsafe.Pointer(bp))) + _readCoord(tls, pCellData, bp) + (**(**[10]Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)))[0] = float64(*(*int32)(unsafe.Pointer(bp))) + } + } + if (*TRtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == int32(RTREE_MATCH) { + **(**int32)(__ccgo_up(bp + 88)) = 0 + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*TRtreeConstraint)(unsafe.Pointer(pConstraint)).Fu))})))(tls, pInfo, nCoord, bp+8, bp+88) + if **(**int32)(__ccgo_up(bp + 88)) == 0 { + **(**int32)(__ccgo_up(peWithin)) = NOT_WITHIN + } + **(**Tsqlite3_rtree_dbl)(__ccgo_up(prScore)) = float64(0) + } else { + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FaCoord = bp + 8 + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FiLevel = libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(pSearch)).FiLevel) - int32(1) + v1 = (*TRtreeSearchPoint)(unsafe.Pointer(pSearch)).FrScore + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FrParentScore = v1 + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FrScore = v1 + v2 = libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(pSearch)).FeWithin) + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FeParentWithin = v2 + (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FeWithin = v2 + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*TRtreeConstraint)(unsafe.Pointer(pConstraint)).Fu))})))(tls, pInfo) + if (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FeWithin < **(**int32)(__ccgo_up(peWithin)) { + **(**int32)(__ccgo_up(peWithin)) = (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FeWithin + } + if (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FrScore < **(**Tsqlite3_rtree_dbl)(__ccgo_up(prScore)) || **(**Tsqlite3_rtree_dbl)(__ccgo_up(prScore)) < float64(0) { + **(**Tsqlite3_rtree_dbl)(__ccgo_up(prScore)) = (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FrScore + } + } + return rc +} + +// C documentation +// +// /* +// ** Continue the search on cursor pCur until the front of the queue +// ** contains an entry suitable for returning as a result-set row, +// ** or until the RtreeSearchPoint queue is empty, indicating that the +// ** query has completed. +// */ +func _rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eInt, ii, nCell, nConstraint int32 + var p, pCellData, pConstraint, pNode, pRtree, v1 uintptr + var x TRtreeSearchPoint + var _ /* eWithin at bp+0 */ int32 + var _ /* rScore at bp+8 */ Tsqlite3_rtree_dbl + var _ /* rc at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = eInt, ii, nCell, nConstraint, p, pCellData, pConstraint, pNode, pRtree, x, v1 + pRtree = (*TRtreeCursor)(unsafe.Pointer(pCur)).Fbase.FpVtab + **(**int32)(__ccgo_up(bp + 4)) = SQLITE_OK + nConstraint = (*TRtreeCursor)(unsafe.Pointer(pCur)).FnConstraint + eInt = libc.BoolInt32(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == int32(RTREE_COORD_INT32)) + for { + v1 = _rtreeSearchPointFirst(tls, pCur) + p = v1 + if !(v1 != uintptr(0) && libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiLevel) > 0) { + break + } + pNode = _rtreeNodeOfFirstSearchPoint(tls, pCur, bp+4) + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + return **(**int32)(__ccgo_up(bp + 4)) + } + nCell = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) + if nCell > int32(RTREE_MAXCELLS) { + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= int32(RTREE_MATCH) { + **(**int32)(__ccgo_up(bp + 4)) = _rtreeCallbackConstraint(tls, pConstraint, eInt, pCellData, p, bp+8, bp) + if **(**int32)(__ccgo_up(bp + 4)) != 0 { + return **(**int32)(__ccgo_up(bp + 4)) + } + } else { + if libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiLevel) == int32(1) { + _rtreeLeafConstraint(tls, pConstraint, eInt, pCellData, bp) + } else { + _rtreeNonleafConstraint(tls, pConstraint, eInt, pCellData, bp) + } + } + if **(**int32)(__ccgo_up(bp)) == NOT_WITHIN { + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell = (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell + 1 + pCellData = pCellData + uintptr((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) + break + } + goto _2 + _2: + ; + ii = ii + 1 + } + if **(**int32)(__ccgo_up(bp)) == NOT_WITHIN { + continue + } + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell = (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell + 1 + x.FiLevel = libc.Uint8FromInt32(libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiLevel) - int32(1)) + if x.FiLevel != 0 { + x.Fid = _readInt64(tls, pCellData) + ii = 0 + for { + if !(ii < (*TRtreeCursor)(unsafe.Pointer(pCur)).FnPoint) { + break + } + if (**(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(pCur)).FaPoint + uintptr(ii)*24))).Fid == x.Fid { + return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<= nCell { + _rtreeSearchPointPop(tls, pCur) + } + if **(**Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)) < float64(0) { + **(**Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)) = float64(0) + } + p = _rtreeSearchPointNew(tls, pCur, **(**Tsqlite3_rtree_dbl)(__ccgo_up(bp + 8)), x.FiLevel) + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))) + (*TRtreeSearchPoint)(unsafe.Pointer(p)).Fid = x.Fid + (*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell = x.FiCell + break + } + if libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell) >= nCell { + _rtreeSearchPointPop(tls, pCur) + } + } + (*TRtreeCursor)(unsafe.Pointer(pCur)).FatEOF = libc.BoolUint8(p == uintptr(0)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Routines used to compute the sum, average, and total. +// ** +// ** The SUM() function follows the (broken) SQL standard which means +// ** that it returns NULL if it sums over no inputs. TOTAL returns +// ** 0.0 in that case. In addition, TOTAL always returns a float where +// ** SUM might return an integer if it never encounters a floating point +// ** value. TOTAL never fails, but SUM might throw an exception if +// ** it overflows an integer. +// */ +func _sumStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p uintptr + var type1 int32 + var _ /* x at bp+0 */ Ti64 + _, _ = p, type1 + _ = argc + p = Xsqlite3_aggregate_context(tls, context, int32(40)) + type1 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) + if p != 0 && type1 != int32(SQLITE_NULL) { + (*TSumCtx)(unsafe.Pointer(p)).Fcnt = (*TSumCtx)(unsafe.Pointer(p)).Fcnt + 1 + if libc.Int32FromUint8((*TSumCtx)(unsafe.Pointer(p)).Fapprox) == 0 { + if type1 != int32(SQLITE_INTEGER) { + _kahanBabuskaNeumaierInit(tls, p, (*TSumCtx)(unsafe.Pointer(p)).FiSum) + (*TSumCtx)(unsafe.Pointer(p)).Fapprox = uint8(1) + _kahanBabuskaNeumaierStep(tls, p, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))) + } else { + **(**Ti64)(__ccgo_up(bp)) = (*TSumCtx)(unsafe.Pointer(p)).FiSum + if _sqlite3AddInt64(tls, bp, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))) == 0 { + (*TSumCtx)(unsafe.Pointer(p)).FiSum = **(**Ti64)(__ccgo_up(bp)) + } else { + (*TSumCtx)(unsafe.Pointer(p)).Fovrfl = uint8(1) + _kahanBabuskaNeumaierInit(tls, p, (*TSumCtx)(unsafe.Pointer(p)).FiSum) + (*TSumCtx)(unsafe.Pointer(p)).Fapprox = uint8(1) + _kahanBabuskaNeumaierStepInt64(tls, p, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))) + } + } + } else { + if type1 == int32(SQLITE_INTEGER) { + _kahanBabuskaNeumaierStepInt64(tls, p, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))) + } else { + (*TSumCtx)(unsafe.Pointer(p)).Fovrfl = uint8(0) + _kahanBabuskaNeumaierStep(tls, p, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))) + } + } + } +} + +// C documentation +// +// /* +// ** Estimate the number of rows that will be returned based on +// ** an equality constraint x=VALUE and where that VALUE occurs in +// ** the histogram data. This only works when x is the left-most +// ** column of an index and sqlite_stat4 histogram data is available +// ** for that index. When pExpr==NULL that means the constraint is +// ** "x IS NULL" instead of "x=VALUE". +// ** +// ** Write the estimated row count into *pnRow and return SQLITE_OK. +// ** If unable to make an estimate, leave *pnRow unchanged and return +// ** non-zero. +// ** +// ** This routine can fail if it is unable to load a collating sequence +// ** required for string comparison, or if unable to allocate memory +// ** for a UTF conversion required for comparison. The error is stored +// ** in the pParse structure. +// */ +func _whereEqualScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pExpr uintptr, pnRow uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var nEq, rc int32 + var p uintptr + var _ /* a at bp+8 */ [2]TtRowcnt + var _ /* bOk at bp+24 */ int32 + var _ /* pRec at bp+0 */ uintptr + _, _, _ = nEq, p, rc + p = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + 24))).FpIndex + nEq = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + 24))).FnEq) + **(**uintptr)(__ccgo_up(bp)) = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec + /* If values are not available for all fields of the index to the left + ** of this one, no estimate can be made. Return SQLITE_NOTFOUND. */ + if (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid < nEq-int32(1) { + return int32(SQLITE_NOTFOUND) + } + /* This is an optimization only. The call to sqlite3Stat4ProbeSetValue() + ** below would return the same value. */ + if nEq >= libc.Int32FromUint16((*TIndex)(unsafe.Pointer(p)).FnColumn) { + **(**TtRowcnt)(__ccgo_up(pnRow)) = uint64(1) + return SQLITE_OK + } + rc = _sqlite3Stat4ProbeSetValue(tls, pParse, p, bp, pExpr, int32(1), nEq-int32(1), bp+24) + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = **(**uintptr)(__ccgo_up(bp)) + if rc != SQLITE_OK { + return rc + } + if **(**int32)(__ccgo_up(bp + 24)) == 0 { + return int32(SQLITE_NOTFOUND) + } + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nEq + _whereKeyStats(tls, pParse, p, **(**uintptr)(__ccgo_up(bp)), 0, bp+8) + **(**TtRowcnt)(__ccgo_up(pnRow)) = (**(**[2]TtRowcnt)(__ccgo_up(bp + 8)))[int32(1)] + return rc +} + +// C documentation +// +// /* +// ** Try to insert a new prerequisite/cost entry into the WhereOrSet pSet. +// ** +// ** The new entry might overwrite an existing entry, or it might be +// ** appended, or it might be discarded. Do whatever is the right thing +// ** so that pSet keeps the N_OR_COST best entries seen so far. +// */ +func _whereOrInsert(tls *libc.TLS, pSet uintptr, prereq TBitmask, rRun TLogEst, nOut TLogEst) (r int32) { + var i, v2 Tu16 + var p, v3 uintptr + _, _, _, _ = i, p, v2, v3 + i = (*TWhereOrSet)(unsafe.Pointer(pSet)).Fn + p = pSet + 8 + for { + if !(libc.Int32FromUint16(i) > 0) { + break + } + if int32(rRun) <= int32((*TWhereOrCost)(unsafe.Pointer(p)).FrRun) && prereq&(*TWhereOrCost)(unsafe.Pointer(p)).Fprereq == prereq { + goto whereOrInsert_done + } + if int32((*TWhereOrCost)(unsafe.Pointer(p)).FrRun) <= int32(rRun) && (*TWhereOrCost)(unsafe.Pointer(p)).Fprereq&prereq == (*TWhereOrCost)(unsafe.Pointer(p)).Fprereq { + return 0 + } + goto _1 + _1: + ; + i = i - 1 + p += 16 + } + if libc.Int32FromUint16((*TWhereOrSet)(unsafe.Pointer(pSet)).Fn) < int32(N_OR_COST) { + v3 = pSet + v2 = *(*Tu16)(unsafe.Pointer(v3)) + *(*Tu16)(unsafe.Pointer(v3)) = *(*Tu16)(unsafe.Pointer(v3)) + 1 + p = pSet + 8 + uintptr(v2)*16 + (*TWhereOrCost)(unsafe.Pointer(p)).FnOut = nOut + } else { + p = pSet + 8 + i = uint16(1) + for { + if !(libc.Int32FromUint16(i) < libc.Int32FromUint16((*TWhereOrSet)(unsafe.Pointer(pSet)).Fn)) { + break + } + if int32((*TWhereOrCost)(unsafe.Pointer(p)).FrRun) > int32((**(**TWhereOrCost)(__ccgo_up(pSet + 8 + uintptr(i)*16))).FrRun) { + p = pSet + 8 + uintptr(i)*16 + } + goto _4 + _4: + ; + i = i + 1 + } + if int32((*TWhereOrCost)(unsafe.Pointer(p)).FrRun) <= int32(rRun) { + return 0 + } + } + goto whereOrInsert_done +whereOrInsert_done: + ; + (*TWhereOrCost)(unsafe.Pointer(p)).Fprereq = prereq + (*TWhereOrCost)(unsafe.Pointer(p)).FrRun = rRun + if int32((*TWhereOrCost)(unsafe.Pointer(p)).FnOut) > int32(nOut) { + (*TWhereOrCost)(unsafe.Pointer(p)).FnOut = nOut + } + return int32(1) +} + +// C documentation +// +// /* +// ** This function is used to estimate the number of rows that will be visited +// ** by scanning an index for a range of values. The range may have an upper +// ** bound, a lower bound, or both. The WHERE clause terms that set the upper +// ** and lower bounds are represented by pLower and pUpper respectively. For +// ** example, assuming that index p is on t1(a): +// ** +// ** ... FROM t1 WHERE a > ? AND a < ? ... +// ** |_____| |_____| +// ** | | +// ** pLower pUpper +// ** +// ** If either of the upper or lower bound is not present, then NULL is passed in +// ** place of the corresponding WhereTerm. +// ** +// ** The value in (pBuilder->pNew->u.btree.nEq) is the number of the index +// ** column subject to the range constraint. Or, equivalently, the number of +// ** equality constraints optimized by the proposed index scan. For example, +// ** assuming index p is on t1(a, b), and the SQL query is: +// ** +// ** ... FROM t1 WHERE a = ? AND b > ? AND b < ? ... +// ** +// ** then nEq is set to 1 (as the range restricted column, b, is the second +// ** left-most column of the index). Or, if the query is: +// ** +// ** ... FROM t1 WHERE a > ? AND a < ? ... +// ** +// ** then nEq is set to 0. +// ** +// ** When this function is called, *pnOut is set to the sqlite3LogEst() of the +// ** number of rows that the index scan is expected to visit without +// ** considering the range constraints. If nEq is 0, then *pnOut is the number of +// ** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced) +// ** to account for the range constraints pLower and pUpper. +// ** +// ** In the absence of sqlite_stat4 ANALYZE data, or if such data cannot be +// ** used, a single range inequality reduces the search space by a factor of 4. +// ** and a pair of constraints (x>? AND x 0 && nEq < (*TIndex)(unsafe.Pointer(p)).FnSampleCol && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0) { + if nEq == (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid { + **(**uintptr)(__ccgo_up(bp)) = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec + nBtm = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnBtm) + nTop = libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnTop) /* Rows less than the upper bound */ + iLwrIdx = -int32(2) /* aSample[] for the lower bound */ + iUprIdx = -int32(1) /* aSample[] for the upper bound */ + if **(**uintptr)(__ccgo_up(bp)) != 0 { + (*TUnpackedRecord)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnField = libc.Uint16FromInt32((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid) + } + /* Determine iLower and iUpper using ($P) only. */ + if nEq == 0 { + iLower = uint64(0) + iUpper = (*TIndex)(unsafe.Pointer(p)).FnRowEst0 + } else { + /* Note: this call could be optimized away - since the same values must + ** have been requested when testing key $P in whereEqualScanEst(). */ + _whereKeyStats(tls, pParse, p, **(**uintptr)(__ccgo_up(bp)), 0, bp+8) + iLower = (**(**[2]TtRowcnt)(__ccgo_up(bp + 8)))[0] + iUpper = (**(**[2]TtRowcnt)(__ccgo_up(bp + 8)))[0] + (**(**[2]TtRowcnt)(__ccgo_up(bp + 8)))[int32(1)] + } + if **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(p)).FaSortOrder + uintptr(nEq))) != 0 { + /* The roles of pLower and pUpper are swapped for a DESC index */ + t = pLower + pLower = pUpper + pUpper = t + t1 = nBtm + nBtm = nTop + nTop = t1 + } + /* If possible, improve on the iLower estimate using ($P:$L). */ + if pLower != 0 { /* Values extracted from pExpr */ + pExpr = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight + rc = _sqlite3Stat4ProbeSetValue(tls, pParse, p, bp, pExpr, nBtm, nEq, bp+24) + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp + 24)) != 0 { + mask = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))) + if _sqlite3ExprVectorSize(tls, pExpr) > **(**int32)(__ccgo_up(bp + 24)) { + mask = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ))) + } + iLwrIdx = _whereKeyStats(tls, pParse, p, **(**uintptr)(__ccgo_up(bp)), 0, bp+8) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pLower)).FeOperator)&libc.Int32FromUint16(mask) != 0 { + v1 = (**(**[2]TtRowcnt)(__ccgo_up(bp + 8)))[int32(1)] + } else { + v1 = uint64(0) + } + iNew = (**(**[2]TtRowcnt)(__ccgo_up(bp + 8)))[0] + v1 + if iNew > iLower { + iLower = iNew + } + nOut = nOut - 1 + pLower = uintptr(0) + } + } + /* If possible, improve on the iUpper estimate using ($P:$U). */ + if pUpper != 0 { /* Values extracted from pExpr */ + pExpr1 = (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight + rc = _sqlite3Stat4ProbeSetValue(tls, pParse, p, bp, pExpr1, nTop, nEq, bp+28) + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp + 28)) != 0 { + mask1 = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))) + if _sqlite3ExprVectorSize(tls, pExpr1) > **(**int32)(__ccgo_up(bp + 28)) { + mask1 = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ)) | libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ))) + } + iUprIdx = _whereKeyStats(tls, pParse, p, **(**uintptr)(__ccgo_up(bp)), int32(1), bp+8) + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pUpper)).FeOperator)&libc.Int32FromUint16(mask1) != 0 { + v1 = (**(**[2]TtRowcnt)(__ccgo_up(bp + 8)))[int32(1)] + } else { + v1 = uint64(0) + } + iNew1 = (**(**[2]TtRowcnt)(__ccgo_up(bp + 8)))[0] + v1 + if iNew1 < iUpper { + iUpper = iNew1 + } + nOut = nOut - 1 + pUpper = uintptr(0) + } + } + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = **(**uintptr)(__ccgo_up(bp)) + if rc == SQLITE_OK { + if iUpper > iLower { + nNew = _sqlite3LogEst(tls, iUpper-iLower) + /* TUNING: If both iUpper and iLower are derived from the same + ** sample, then assume they are 4x more selective. This brings + ** the estimated selectivity more in line with what it would be + ** if estimated without the use of STAT4 tables. */ + if iLwrIdx == iUprIdx { + nNew = int16(int32(nNew) - libc.Int32FromInt32(20)) + } + } else { + nNew = int16(10) + } + if int32(nNew) < nOut { + nOut = int32(nNew) + } + } + } else { + **(**int32)(__ccgo_up(bp + 32)) = 0 + rc = _whereRangeSkipScanEst(tls, pParse, pLower, pUpper, pLoop, bp+32) + if **(**int32)(__ccgo_up(bp + 32)) != 0 { + return rc + } + } + } + nNew = _whereRangeAdjust(tls, pLower, int16(nOut)) + nNew = _whereRangeAdjust(tls, pUpper, nNew) + /* TUNING: If there is both an upper and lower limit and neither limit + ** has an application-defined likelihood(), assume the range is + ** reduced by an additional 75%. This means that, by default, an open-ended + ** range query (e.g. col > ?) is assumed to match 1/4 of the rows in the + ** index. While a closed range (e.g. col BETWEEN ? AND ?) is estimated to + ** match 1/64 of the index. */ + if pLower != 0 && int32((*TWhereTerm)(unsafe.Pointer(pLower)).FtruthProb) > 0 && pUpper != 0 && int32((*TWhereTerm)(unsafe.Pointer(pUpper)).FtruthProb) > 0 { + nNew = int16(int32(nNew) - libc.Int32FromInt32(20)) + } + nOut = nOut - (libc.BoolInt32(pLower != uintptr(0)) + libc.BoolInt32(pUpper != uintptr(0))) + if int32(nNew) < int32(10) { + nNew = int16(10) + } + if int32(nNew) < nOut { + nOut = int32(nNew) + } + (*TWhereLoop)(unsafe.Pointer(pLoop)).FnOut = int16(nOut) + return rc +} diff --git a/internal/engine/lib/sqlite_g_000000000001ffc0.go b/internal/engine/lib/sqlite_g_000000000001ffc0.go new file mode 100644 index 0000000..2e55f68 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001ffc0.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Tmode_t = uint32 + +type ulong = Tulong diff --git a/internal/engine/lib/sqlite_g_000000000001ffc3.go b/internal/engine/lib/sqlite_g_000000000001ffc3.go new file mode 100644 index 0000000..4149541 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001ffc3.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +type Tid_t = uint32 diff --git a/internal/engine/lib/sqlite_g_000000000001ffcf.go b/internal/engine/lib/sqlite_g_000000000001ffcf.go new file mode 100644 index 0000000..4689473 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001ffcf.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +const WCHAR_MAX = 2147483647 + +const WCHAR_MIN = -2147483648 diff --git a/internal/engine/lib/sqlite_g_000000000001ffdf.go b/internal/engine/lib/sqlite_g_000000000001ffdf.go new file mode 100644 index 0000000..6235fe9 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001ffdf.go @@ -0,0 +1,122 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +func _cellOverlap(tls *libc.TLS, pRtree uintptr, p uintptr, aCell uintptr, nCell int32) (r TRtreeDValue) { + var ii, jj int32 + var o, overlap, x1, x2 TRtreeDValue + var v3, v4, v5, v6, v7 float64 + _, _, _, _, _, _, _, _, _, _, _ = ii, jj, o, overlap, x1, x2, v3, v4, v5, v6, v7 + overlap = float64(0) + ii = 0 + for { + if !(ii < nCell) { + break + } + o = libc.Float64FromInt32(1) + jj = 0 + for { + if !(jj < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)) { + break + } + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v4 = float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + uintptr(jj)*4))) + } else { + v4 = float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(jj)*4))) + } + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v5 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj)*4))) + } else { + v5 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj)*4))) + } + if v4 > v5 { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v6 = float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + uintptr(jj)*4))) + } else { + v6 = float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(jj)*4))) + } + v3 = v6 + } else { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v7 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj)*4))) + } else { + v7 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj)*4))) + } + v3 = v7 + } + x1 = v3 + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v4 = float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + uintptr(jj+int32(1))*4))) + } else { + v4 = float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(jj+int32(1))*4))) + } + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v5 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj+int32(1))*4))) + } else { + v5 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj+int32(1))*4))) + } + if v4 < v5 { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v6 = float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + uintptr(jj+int32(1))*4))) + } else { + v6 = float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(jj+int32(1))*4))) + } + v3 = v6 + } else { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v7 = float64(*(*TRtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj+int32(1))*4))) + } else { + v7 = float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj+int32(1))*4))) + } + v3 = v7 + } + x2 = v3 + if x2 < x1 { + o = libc.Float64FromInt32(0) + break + } else { + o = TRtreeDValue(o * (x2 - x1)) + } + goto _2 + _2: + ; + jj = jj + int32(2) + } + overlap = overlap + o + goto _1 + _1: + ; + ii = ii + 1 + } + return overlap +} + +// C documentation +// +// /* +// ** Expression p should encode a floating point value between 1.0 and 0.0. +// ** Return 134,217,728 (2^27) times this value. Or return -1 if p is not +// ** a floating point value between 1.0 and 0.0. +// */ +func _exprProbability(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* r at bp+0 */ float64 + **(**float64)(__ccgo_up(bp)) = -libc.Float64FromFloat64(1) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) != int32(TK_FLOAT) { + return -int32(1) + } + _sqlite3AtoF(tls, *(*uintptr)(unsafe.Pointer(p + 8)), bp) + if **(**float64)(__ccgo_up(bp)) > float64(1) { + return -int32(1) + } + return int32(float64(**(**float64)(__ccgo_up(bp)) * libc.Float64FromFloat64(1.34217728e+08))) +} diff --git a/internal/engine/lib/sqlite_g_000000000001fffc.go b/internal/engine/lib/sqlite_g_000000000001fffc.go new file mode 100644 index 0000000..0b883b2 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001fffc.go @@ -0,0 +1,316 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const AT_FDCWD = -100 + +const HAVE_FULLFSYNC = 0 + +const INT_FAST16_MAX = 2147483647 + +const INT_FAST16_MIN = -2147483648 + +const RTLD_GLOBAL = 256 + +type Tfsblkcnt_t = uint64 + +type Tfsfilcnt_t = uint64 + +type Tint_fast16_t = int32 + +type Tlocale_t = uintptr + +type Tuint_fast16_t = uint32 + +const UINT_FAST16_MAX = 4294967295 + +// C documentation +// +// /* +// ** If the following global variable points to a string which is the +// ** name of a directory, then that directory will be used to store +// ** temporary files. +// ** +// ** See also the "PRAGMA temp_store_directory" SQL command. +// */ +var Xsqlite3_temp_directory uintptr + +/* +** Make sure we can call this stuff from C++. + */ + +/* +** Facilitate override of interface linkage and calling conventions. +** Be aware that these macros may not be used within this particular +** translation of the amalgamation and its associated header file. +** +** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the +** compiler that the target identifier should have external linkage. +** +** The SQLITE_CDECL macro is used to set the calling convention for +** public functions that accept a variable number of arguments. +** +** The SQLITE_APICALL macro is used to set the calling convention for +** public functions that accept a fixed number of arguments. +** +** The SQLITE_STDCALL macro is no longer used and is now deprecated. +** +** The SQLITE_CALLBACK macro is used to set the calling convention for +** function pointers. +** +** The SQLITE_SYSAPI macro is used to set the calling convention for +** functions provided by the operating system. +** +** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and +** SQLITE_SYSAPI macros are used only when building for environments +** that require non-default calling conventions. + */ + +/* +** These no-op macros are used in front of interfaces to mark those +** interfaces as either deprecated or experimental. New applications +** should not use deprecated interfaces - they are supported for backwards +** compatibility only. Application writers should be aware that +** experimental interfaces are subject to change in point releases. +** +** These macros used to resolve to various kinds of compiler magic that +** would generate warning messages when they were used. But that +** compiler magic ended up generating such a flurry of bug reports +** that we have taken it all out and gone back to using simple +** noop macros. + */ + +/* +** Ensure these symbols were not defined by some previous header file. + */ + +/* +** CAPI3REF: Compile-Time Library Version Numbers +** +** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header +** evaluates to a string literal that is the SQLite version in the +** format "X.Y.Z" where X is the major version number (always 3 for +** SQLite3) and Y is the minor version number and Z is the release number.)^ +** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer +** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same +** numbers used in [SQLITE_VERSION].)^ +** The SQLITE_VERSION_NUMBER for any given release of SQLite will also +** be larger than the release from which it is derived. Either Y will +** be held constant and Z will be incremented or else Y will be incremented +** and Z will be reset to zero. +** +** Since [version 3.6.18] ([dateof:3.6.18]), +** SQLite source code has been stored in the +** Fossil configuration management +** system. ^The SQLITE_SOURCE_ID macro evaluates to +** a string which identifies a particular check-in of SQLite +** within its configuration management system. ^The SQLITE_SOURCE_ID +** string contains the date and time of the check-in (UTC) and a SHA1 +** or SHA3-256 hash of the entire source tree. If the source code has +** been edited in any way since it was last checked in, then the last +** four hexadecimal digits of the hash may be modified. +** +** See also: [sqlite3_libversion()], +** [sqlite3_libversion_number()], [sqlite3_sourceid()], +** [sqlite_version()] and [sqlite_source_id()]. + */ + +// C documentation +// +// /* +// ** Return the ON CONFLICT resolution mode in effect for the virtual +// ** table update operation currently in progress. +// ** +// ** The results of this routine are undefined unless it is called from +// ** within an xUpdate method. +// */ +func Xsqlite3_vtab_on_conflict(tls *libc.TLS, db uintptr) (r int32) { + return libc.Int32FromUint8(_aMap[libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict)-int32(1)]) +} + +const _POSIX_CHOWN_RESTRICTED = 1 + +const _POSIX_JOB_CONTROL = 1 + +const _POSIX_NO_TRUNC = 1 + +const _POSIX_REGEXP = 1 + +const _POSIX_SHELL = 1 + +const __ELF__ = 1 + +const __unix__ = 1 + +// C documentation +// +// /* +// ** Close a file. Make sure the lock has been released before closing. +// */ +func _dotlockClose(tls *libc.TLS, id uintptr) (r int32) { + var pFile uintptr + _ = pFile + pFile = id + _dotlockUnlock(tls, id, NO_LOCK) + Xsqlite3_free(tls, (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext) + return _closeUnixFile(tls, id) +} + +/****************** End of the dot-file lock implementation ******************* +******************************************************************************/ + +/****************************************************************************** +************************** Begin flock Locking ******************************** +** +** Use the flock() system call to do file locking. +** +** flock() locking is like dot-file locking in that the various +** fine-grain locking levels supported by SQLite are collapsed into +** a single exclusive lock. In other words, SHARED, RESERVED, and +** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite +** still works when you do this, but concurrency is reduced since +** only a single process can be reading the database at a time. +** +** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off + */ + +/******************* End of the flock lock implementation ********************* +******************************************************************************/ + +/****************************************************************************** +************************ Begin Named Semaphore Locking ************************ +** +** Named semaphore locking is only supported on VxWorks. +** +** Semaphore locking is like dot-lock and flock in that it really only +** supports EXCLUSIVE locking. Only a single process can read or write +** the database file at a time. This reduces potential concurrency, but +** makes the lock implementation much easier. + */ +/* +** Named semaphore locking is only available on VxWorks. +** +*************** End of the named semaphore lock implementation **************** +******************************************************************************/ + +/****************************************************************************** +*************************** Begin AFP Locking ********************************* +** +** AFP is the Apple Filing Protocol. AFP is a network filesystem found +** on Apple Macintosh computers - both OS9 and OSX. +** +** Third-party implementations of AFP are available. But this code here +** only works on OSX. + */ + +/* +** The code above is the AFP lock implementation. The code is specific +** to MacOSX and does not work on other unix platforms. No alternative +** is available. If you don't compile for a mac, then the "unix-afp" +** VFS is not available. +** +********************* End of the AFP lock implementation ********************** +******************************************************************************/ + +/****************************************************************************** +*************************** Begin NFS Locking ********************************/ + +/* +** The code above is the NFS lock implementation. The code is specific +** to MacOSX and does not work on other unix platforms. No alternative +** is available. +** +********************* End of the NFS lock implementation ********************** +******************************************************************************/ + +/****************************************************************************** +**************** Non-locking sqlite3_file methods ***************************** +** +** The next division contains implementations for all methods of the +** sqlite3_file object other than the locking methods. The locking +** methods were defined in divisions above (one locking method per +** division). Those methods that are common to all locking modes +** are gather together into this division. + */ + +// C documentation +// +// /* +// ** The fsync() system call does not work as advertised on many +// ** unix systems. The following procedure is an attempt to make +// ** it work better. +// ** +// ** The SQLITE_NO_SYNC macro disables all fsync()s. This is useful +// ** for testing when we want to run through the test suite quickly. +// ** You are strongly advised *not* to deploy with SQLITE_NO_SYNC +// ** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash +// ** or power failure will likely corrupt the database file. +// ** +// ** SQLite sets the dataOnly flag if the size of the file is unchanged. +// ** The idea behind dataOnly is that it should only write the file content +// ** to disk, not the inode. We only set dataOnly if the file size is +// ** unchanged since the file size is part of the inode. However, +// ** Ted Ts'o tells us that fdatasync() will also write the inode if the +// ** file size has changed. The only real difference between fdatasync() +// ** and fsync(), Ted tells us, is that fdatasync() will not flush the +// ** inode if the mtime or owner or other inode attributes have changed. +// ** We only care about the file size, not the other file attributes, so +// ** as far as SQLite is concerned, an fdatasync() is always adequate. +// ** So, we always use fdatasync() if it is available, regardless of +// ** the value of the dataOnly flag. +// */ +func _full_fsync(tls *libc.TLS, fd int32, fullSync int32, dataOnly int32) (r int32) { + var rc int32 + _ = rc + /* The following "ifdef/elif/else/" block has the same structure as + ** the one below. It is replicated here solely to avoid cluttering + ** up the real code with the UNUSED_PARAMETER() macros. + */ + _ = fullSync + _ = dataOnly + /* Record the number of times that we do a normal fsync() and + ** FULLSYNC. This is used during testing to verify that this procedure + ** gets called with the correct arguments. + */ + /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a + ** no-op. But go ahead and call fstat() to validate the file + ** descriptor as we need a method to provoke a failure during + ** coverage testing. + */ + rc = libc.Xfsync(tls, fd) + if libc.Bool(OS_VXWORKS != 0) && rc != -int32(1) { + rc = 0 + } + return rc +} + +func init() { + p := unsafe.Pointer(&_dotlockIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_dotlockIoFinderImpl) +} + +/* +** The proxy locking method is a "super-method" in the sense that it +** opens secondary file descriptors for the conch and lock files and +** it uses proxy, dot-file, AFP, and flock() locking methods on those +** secondary files. For this reason, the division that implements +** proxy locking is located much further down in the file. But we need +** to go ahead and define the sqlite3_io_methods and finder function +** for proxy locking here. So we forward declare the I/O methods. + */ + +/* nfs lockd on OSX 10.3+ doesn't clear write locks when a read lock is set */ + +type locale_t = Tlocale_t + +const math_errhandling = 2 + +type timer_t = Ttimer_t diff --git a/internal/engine/lib/sqlite_g_000000000001ffff.go b/internal/engine/lib/sqlite_g_000000000001ffff.go new file mode 100644 index 0000000..d9ef309 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000001ffff.go @@ -0,0 +1,14227 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const BIG_ENDIAN = 4321 + +const BUFSIZ = 1024 + +const DOTLOCK_SUFFIX = ".lock" + +type DbPath = TDbPath + +type Dl_info = TDl_info + +const ENOTBLK = 15 + +const ETXTBSY = 26 + +const FD_CLOEXEC = 1 + +const F_DUPFD = 0 + +const F_GETFD = 1 + +const F_GETFL = 3 + +const F_LOCK = 1 + +const F_OK = 0 + +const F_SETFD = 2 + +const F_SETFL = 4 + +const F_TEST = 3 + +const F_TLOCK = 2 + +const F_ULOCK = 0 + +const F_UNLCK = 2 + +const HAVE_FCHMOD = 1 + +const HAVE_GETHOSTUUID = 0 + +const INTERFACE = 1 + +const ITIMER_PROF = 2 + +const ITIMER_REAL = 0 + +const ITIMER_VIRTUAL = 1 + +const LITTLE_ENDIAN = 1234 + +const L_INCR = 1 + +const L_SET = 0 + +const L_XTND = 2 + +const MADV_DONTNEED = 4 + +const MADV_NORMAL = 0 + +const MADV_RANDOM = 1 + +const MADV_SEQUENTIAL = 2 + +const MADV_WILLNEED = 3 + +const MAP_FAILED = -1 + +const MAP_FILE = 0 + +const MAP_FIXED = 16 + +const MAP_PRIVATE = 2 + +const MAP_SHARED = 1 + +const MATH_ERREXCEPT = 2 + +const MATH_ERRNO = 1 + +const MAX_PATHNAME = 512 + +const MS_ASYNC = 1 + +const O_BINARY = 0 + +const O_RDONLY = 0 + +const O_RDWR = 2 + +const O_WRONLY = 1 + +const PDP_ENDIAN = 3412 + +const POSIX_MADV_DONTNEED = 4 + +const POSIX_MADV_NORMAL = 0 + +const POSIX_MADV_RANDOM = 1 + +const POSIX_MADV_SEQUENTIAL = 2 + +const POSIX_MADV_WILLNEED = 3 + +const PROT_EXEC = 4 + +const PROT_NONE = 0 + +const PROT_READ = 1 + +const PROT_WRITE = 2 + +const RAND_MAX = 2147483647 + +const RTLD_LAZY = 1 + +const RTLD_NEXT = -1 + +const RTLD_NOW = 2 + +const R_OK = 4 + +const SQLITE_DEFAULT_FILE_PERMISSIONS = 420 + +const SQLITE_DEFAULT_PROXYDIR_PERMISSIONS = 493 + +const SQLITE_FSFLAGS_IS_MSDOS = 1 + +const SQLITE_MAX_SYMLINKS = 100 + +const SQLITE_MINIMUM_FILE_DESCRIPTOR = 3 + +const SQLITE_OS_UNIX = 1 + +const S_IEXEC = 64 + +const S_IFBLK = 24576 + +const S_IFCHR = 8192 + +const S_IFDIR = 16384 + +const S_IFIFO = 4096 + +const S_IFLNK = 40960 + +const S_IFMT = 61440 + +const S_IFREG = 32768 + +const S_IFSOCK = 49152 + +const S_IREAD = 256 + +const S_IRGRP = 32 + +const S_IROTH = 4 + +const S_IRUSR = 256 + +const S_IRWXG = 56 + +const S_IRWXO = 7 + +const S_IRWXU = 448 + +const S_ISGID = 1024 + +const S_ISUID = 2048 + +const S_ISVTX = 512 + +const S_IWGRP = 16 + +const S_IWOTH = 2 + +const S_IWRITE = 128 + +const S_IWUSR = 128 + +const S_IXGRP = 8 + +const S_IXOTH = 1 + +const S_IXUSR = 64 + +// C documentation +// +// /* +// ** A pathname under construction +// */ +type TDbPath = struct { + Frc int32 + FnSymlink int32 + FzOut uintptr + FnOut int32 + FnUsed int32 +} + +type TDl_info = struct { + Fdli_fname uintptr + Fdli_fbase uintptr + Fdli_sname uintptr + Fdli_saddr uintptr +} + +const TIME_UTC = 1 + +const TIOCM_CAR = 64 + +const TIOCM_CD = 64 + +const TIOCM_CTS = 32 + +const TIOCM_DSR = 256 + +const TIOCM_DTR = 2 + +const TIOCM_LE = 1 + +const TIOCM_RI = 128 + +const TIOCM_RNG = 128 + +const TIOCM_RTS = 4 + +const TIOCM_SR = 16 + +const TIOCM_ST = 8 + +const TIOCPKT_DATA = 0 + +const TIOCPKT_DOSTOP = 32 + +const TIOCPKT_FLUSHREAD = 1 + +const TIOCPKT_FLUSHWRITE = 2 + +const TIOCPKT_IOCTL = 64 + +const TIOCPKT_NOSTOP = 16 + +const TIOCPKT_START = 8 + +const TIOCPKT_STOP = 4 + +/* An i-node */ +type TUnixUnusedFd = struct { + Ffd int32 + Fflags int32 + FpNext uintptr +} + +type Tblkcnt_t = int64 + +type Tcaddr_t = uintptr + +// C documentation +// +// /* +// ** An abstract type for a pointer to an IO method finder function: +// */ +type Tfinder_type = uintptr + +type Tgid_t = uint32 + +type Tino_t = uint64 + +type Tquad_t = int64 + +type Tu_int16_t = uint16 + +type Tu_int32_t = uint32 + +type Tu_int64_t = uint64 + +type Tu_int8_t = uint8 + +type Tu_quad_t = uint64 + +type Tuid_t = uint32 + +type Tuint = uint32 + +// C documentation +// +// /* Forward references */ +type TunixShm = struct { + FpShmNode uintptr + FpNext uintptr + FhasMutex Tu8 + Fid Tu8 + FsharedMask Tu16 + FexclMask Tu16 +} + +/* Connection shared memory */ +type TunixShmNode = struct { + FpInode uintptr + FpShmMutex uintptr + FzFilename uintptr + FhShm int32 + FszRegion int32 + FnRegion Tu16 + FisReadonly Tu8 + FisUnlocked Tu8 + FapRegion uintptr + FnRef int32 + FpFirst uintptr + FaLock [8]int32 +} + +// C documentation +// +// /* +// ** Many system calls are accessed through pointer-to-functions so that +// ** they may be overridden at runtime to facilitate fault injection during +// ** testing and sandboxing. The following array holds the names and pointers +// ** to all overrideable system calls. +// */ +type Tunix_syscall = struct { + FzName uintptr + FpCurrent Tsqlite3_syscall_ptr + FpDefault Tsqlite3_syscall_ptr +} + +type Tushort = uint16 + +/****************************************************************************** +****************** Begin Unique File ID Utility Used By VxWorks *************** +** +** On most versions of unix, we can get a unique ID for a file by concatenating +** the device number and the inode number. But this does not work on VxWorks. +** On VxWorks, a unique file id must be based on the canonical filename. +** +** A pointer to an instance of the following structure can be used as a +** unique file ID in VxWorks. Each instance of this structure contains +** a copy of the canonical filename. There is also a reference count. +** The structure is reclaimed when the number of pointers to it drops to +** zero. +** +** There are never very many files open at one time and lookups are not +** a performance-critical path, so it is sufficient to put these +** structures on a linked list. + */ +type TvxworksFileId = struct { + FpNext uintptr + FnRef int32 + FnName int32 + FzCanonicalName uintptr +} + +type Twinsize = struct { + Fws_row uint16 + Fws_col uint16 + Fws_xpixel uint16 + Fws_ypixel uint16 +} + +const UNIXFILE_DELETE = 32 + +const UNIXFILE_DIRSYNC = 8 + +const UNIXFILE_EXCL = 1 + +const UNIXFILE_NOLOCK = 128 + +const UNIXFILE_PERSIST_WAL = 4 + +const UNIXFILE_PSOW = 16 + +const UNIXFILE_RDONLY = 2 + +const UNIXFILE_URI = 64 + +const UNIX_SHM_BASE = 120 + +const UNIX_SHM_DMS = 128 + +type UnixUnusedFd = TUnixUnusedFd + +const W_OK = 2 + +const X_OK = 1 + +// C documentation +// +// /* +// ** Allocate or return the aggregate context for a user function. A new +// ** context is allocated on the first call. Subsequent calls return the +// ** same context that was returned on prior calls. +// */ +func Xsqlite3_aggregate_context(tls *libc.TLS, p uintptr, nByte int32) (r uintptr) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpMem)).Fflags)&int32(MEM_Agg) == 0 { + return _createAggContext(tls, p, nByte) + } else { + return (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpMem)).Fz + } + return r +} + +// C documentation +// +// /* +// ** Return the total number of pages in the source database as of the most +// ** recent call to sqlite3_backup_step(). +// */ +func Xsqlite3_backup_pagecount(tls *libc.TLS, p uintptr) (r int32) { + return libc.Int32FromUint32((*Tsqlite3_backup)(unsafe.Pointer(p)).FnPagecount) +} + +// C documentation +// +// /* +// ** Return the number of pages still to be backed up as of the most recent +// ** call to sqlite3_backup_step(). +// */ +func Xsqlite3_backup_remaining(tls *libc.TLS, p uintptr) (r int32) { + return libc.Int32FromUint32((*Tsqlite3_backup)(unsafe.Pointer(p)).FnRemaining) +} + +func Xsqlite3_bind_blob64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData Tsqlite3_uint64, __ccgo_fp_xDel uintptr) (r int32) { + return _bindText(tls, pStmt, i, zData, libc.Int64FromUint64(nData), __ccgo_fp_xDel, uint8(0)) +} + +func Xsqlite3_bind_null(tls *libc.TLS, pStmt uintptr, i int32) (r int32) { + var p uintptr + var rc int32 + _, _ = p, rc + p = pStmt + rc = _vdbeUnbind(tls, p, libc.Uint32FromInt32(i-libc.Int32FromInt32(1))) + if rc == SQLITE_OK { + /* tag-20240917-01 */ + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) + } + return rc +} + +func Xsqlite3_bind_value(tls *libc.TLS, pStmt uintptr, i int32, pValue uintptr) (r int32) { + var rc int32 + var v1 float64 + _, _ = rc, v1 + switch Xsqlite3_value_type(tls, pValue) { + case int32(SQLITE_INTEGER): + rc = Xsqlite3_bind_int64(tls, pStmt, i, *(*Ti64)(unsafe.Pointer(pValue))) + case int32(SQLITE_FLOAT): + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pValue)).Fflags)&int32(MEM_Real) != 0 { + v1 = *(*float64)(unsafe.Pointer(pValue)) + } else { + v1 = float64(*(*Ti64)(unsafe.Pointer(pValue))) + } + rc = Xsqlite3_bind_double(tls, pStmt, i, v1) + case int32(SQLITE_BLOB): + if libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pValue)).Fflags)&int32(MEM_Zero) != 0 { + rc = Xsqlite3_bind_zeroblob(tls, pStmt, i, *(*int32)(unsafe.Pointer(&(*Tsqlite3_value)(unsafe.Pointer(pValue)).Fu))) + } else { + rc = Xsqlite3_bind_blob(tls, pStmt, i, (*Tsqlite3_value)(unsafe.Pointer(pValue)).Fz, (*Tsqlite3_value)(unsafe.Pointer(pValue)).Fn, uintptr(-libc.Int32FromInt32(1))) + } + case int32(SQLITE_TEXT): + rc = _bindText(tls, pStmt, i, (*Tsqlite3_value)(unsafe.Pointer(pValue)).Fz, int64((*Tsqlite3_value)(unsafe.Pointer(pValue)).Fn), uintptr(-libc.Int32FromInt32(1)), (*Tsqlite3_value)(unsafe.Pointer(pValue)).Fenc) + default: + rc = Xsqlite3_bind_null(tls, pStmt, i) + break + } + return rc +} + +// C documentation +// +// /* +// ** Return the number of columns in the result set for the statement pStmt. +// */ +func Xsqlite3_column_count(tls *libc.TLS, pStmt uintptr) (r int32) { + var pVm uintptr + _ = pVm + pVm = pStmt + if pVm == uintptr(0) { + return 0 + } + return libc.Int32FromUint16((*TVdbe)(unsafe.Pointer(pVm)).FnResColumn) +} + +// C documentation +// +// /* +// ** Register a new collation sequence with the database handle db. +// */ +func Xsqlite3_create_collation_v2(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, __ccgo_fp_xCompare uintptr, __ccgo_fp_xDel uintptr) (r int32) { + var rc int32 + _ = rc + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + rc = _createCollation(tls, db, zName, libc.Uint8FromInt32(enc), pCtx, __ccgo_fp_xCompare, __ccgo_fp_xDel) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Return the number of values available from the current row of the +// ** currently executing statement pStmt. +// */ +func Xsqlite3_data_count(tls *libc.TLS, pStmt uintptr) (r int32) { + var pVm uintptr + _ = pVm + pVm = pStmt + if pVm == uintptr(0) || (*TVdbe)(unsafe.Pointer(pVm)).FpResultRow == uintptr(0) { + return 0 + } + return libc.Int32FromUint16((*TVdbe)(unsafe.Pointer(pVm)).FnResColumn) +} + +// C documentation +// +// /* +// ** Enable or disable the extended result codes. +// */ +func Xsqlite3_extended_result_codes(tls *libc.TLS, db uintptr, onoff int32) (r int32) { + var v1 uint32 + _ = v1 + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if onoff != 0 { + v1 = uint32(0xffffffff) + } else { + v1 = uint32(0xff) + } + (*Tsqlite3)(unsafe.Pointer(db)).FerrMask = libc.Int32FromUint32(v1) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Test to see whether or not the database connection is in autocommit +// ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on +// ** by default. Autocommit is disabled by a BEGIN statement and reenabled +// ** by the next COMMIT or ROLLBACK. +// */ +func Xsqlite3_get_autocommit(tls *libc.TLS, db uintptr) (r int32) { + return libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) +} + +func Xsqlite3_keyword_name(tls *libc.TLS, i int32, pzName uintptr, pnName uintptr) (r int32) { + if i < 0 || i >= int32(SQLITE_N_KEYWORD) { + return int32(SQLITE_ERROR) + } + i = i + 1 + **(**uintptr)(__ccgo_up(pzName)) = uintptr(unsafe.Pointer(&_zKWText)) + uintptr(_aKWOffset[i]) + **(**int32)(__ccgo_up(pnName)) = libc.Int32FromUint8(_aKWLen[i]) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This version of the memory allocation is for use by the application. +// ** First make sure the memory subsystem is initialized, then do the +// ** allocation. +// */ +func Xsqlite3_malloc(tls *libc.TLS, n int32) (r uintptr) { + var v1 uintptr + _ = v1 + if Xsqlite3_initialize(tls) != 0 { + return uintptr(0) + } + if n <= 0 { + v1 = uintptr(0) + } else { + v1 = _sqlite3Malloc(tls, libc.Uint64FromInt32(n)) + } + return v1 +} + +func Xsqlite3_msize(tls *libc.TLS, p uintptr) (r Tsqlite3_uint64) { + var v1 int32 + _ = v1 + if p != 0 { + v1 = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxSize})))(tls, p) + } else { + v1 = 0 + } + return libc.Uint64FromInt32(v1) +} + +// C documentation +// +// /* +// ** Open a new database handle. +// */ +func Xsqlite3_open(tls *libc.TLS, zFilename uintptr, ppDb uintptr) (r int32) { + return _openDatabase(tls, zFilename, ppDb, libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OPEN_READWRITE)|libc.Int32FromInt32(SQLITE_OPEN_CREATE)), uintptr(0)) +} + +func Xsqlite3_open_v2(tls *libc.TLS, filename uintptr, ppDb uintptr, flags int32, zVfs uintptr) (r int32) { + return _openDatabase(tls, filename, ppDb, libc.Uint32FromInt32(flags), zVfs) +} + +// C documentation +// +// /* +// ** Shutdown the operating system interface. +// ** +// ** Some operating systems might need to do some cleanup in this routine, +// ** to release dynamically allocated objects. But not on unix. +// ** This routine is a no-op for unix. +// */ +func Xsqlite3_os_end(tls *libc.TLS) (r int32) { + _unixBigLock = uintptr(0) + return SQLITE_OK +} + +/************** End of os_unix.c *********************************************/ +/************** Begin file os_win.c ******************************************/ +/* +** 2004 May 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains code that is specific to Windows. + */ +/* #include "sqliteInt.h" */ + +/************** End of os_win.c **********************************************/ +/************** Begin file memdb.c *******************************************/ +/* +** 2016-09-07 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file implements an in-memory VFS. A database is held as a contiguous +** block of memory. +** +** This file also implements interface sqlite3_serialize() and +** sqlite3_deserialize(). + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** This function is called from within a pre-update callback to retrieve +// ** the number of columns in the row being updated, deleted or inserted. +// */ +func Xsqlite3_preupdate_count(tls *libc.TLS, db uintptr) (r int32) { + var p uintptr + var v1 int32 + _, _ = p, v1 + p = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate + if p != 0 { + v1 = libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).FpKeyinfo)).FnKeyField) + } else { + v1 = 0 + } + return v1 +} + +// C documentation +// +// /* +// ** This routine sets the progress callback for an Sqlite database to the +// ** given callback function with the given argument. The progress callback will +// ** be invoked every nOps opcodes. +// */ +func Xsqlite3_progress_handler(tls *libc.TLS, db uintptr, nOps int32, __ccgo_fp_xProgress uintptr, pArg uintptr) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if nOps > 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FxProgress = __ccgo_fp_xProgress + (*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps = libc.Uint32FromInt32(nOps) + (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg = pArg + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FxProgress = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps = uint32(0) + (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg = uintptr(0) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) +} + +// C documentation +// +// /* +// ** The public interface to sqlite3Realloc. Make sure that the memory +// ** subsystem is initialized prior to invoking sqliteRealloc. +// */ +func Xsqlite3_realloc(tls *libc.TLS, pOld uintptr, n int32) (r uintptr) { + if Xsqlite3_initialize(tls) != 0 { + return uintptr(0) + } + if n < 0 { + n = 0 + } /* IMP: R-26507-47431 */ + return _sqlite3Realloc(tls, pOld, libc.Uint64FromInt32(n)) +} + +func Xsqlite3_result_blob64(tls *libc.TLS, pCtx uintptr, z uintptr, n Tsqlite3_uint64, __ccgo_fp_xDel uintptr) { + if n > uint64(0x7fffffff) { + _invokeValueDestructor(tls, z, __ccgo_fp_xDel, pCtx) + } else { + _setResultStrOrError(tls, pCtx, z, libc.Int32FromUint64(n), uint8(0), __ccgo_fp_xDel) + } +} + +func Xsqlite3_result_error_code(tls *libc.TLS, pCtx uintptr, errCode int32) { + var v1 int32 + _ = v1 + if errCode != 0 { + v1 = errCode + } else { + v1 = -int32(1) + } + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags)&int32(MEM_Null) != 0 { + _setResultStrOrError(tls, pCtx, _sqlite3ErrStr(tls, errCode), -int32(1), uint8(SQLITE_UTF8), libc.UintptrFromInt32(0)) + } +} + +func Xsqlite3_result_text16be(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, __ccgo_fp_xDel uintptr) { + _setResultStrOrError(tls, pCtx, z, libc.Int32FromUint64(libc.Uint64FromInt32(n) & ^libc.Uint64FromInt32(1)), uint8(SQLITE_UTF16BE), __ccgo_fp_xDel) +} + +func Xsqlite3_result_text16le(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, __ccgo_fp_xDel uintptr) { + _setResultStrOrError(tls, pCtx, z, libc.Int32FromUint64(libc.Uint64FromInt32(n) & ^libc.Uint64FromInt32(1)), uint8(SQLITE_UTF16LE), __ccgo_fp_xDel) +} + +func Xsqlite3_result_value(tls *libc.TLS, pCtx uintptr, pValue uintptr) { + var pOut uintptr + _ = pOut + pOut = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut + _sqlite3VdbeMemCopy(tls, pOut, pValue) + _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8((*Tsqlite3_context)(unsafe.Pointer(pCtx)).Fenc)) + if _sqlite3VdbeMemTooBig(tls, pOut) != 0 { + Xsqlite3_result_error_toobig(tls, pCtx) + } +} + +func Xsqlite3_result_zeroblob(tls *libc.TLS, pCtx uintptr, n int32) { + var v1 int32 + _ = v1 + if n > 0 { + v1 = n + } else { + v1 = 0 + } + Xsqlite3_result_zeroblob64(tls, pCtx, libc.Uint64FromInt32(v1)) +} + +// C documentation +// +// /* +// ** Return true if the prepared statement is in need of being reset. +// */ +func Xsqlite3_stmt_busy(tls *libc.TLS, pStmt uintptr) (r int32) { + var v uintptr + _ = v + v = pStmt + return libc.BoolInt32(v != uintptr(0) && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(v)).FeVdbeState) == int32(VDBE_RUN_STATE)) +} + +// C documentation +// +// /* Return any error code associated with p */ +func Xsqlite3_str_errcode(tls *libc.TLS, p uintptr) (r int32) { + var v1 int32 + _ = v1 + if p != 0 { + v1 = libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(p)).FaccError) + } else { + v1 = int32(SQLITE_NOMEM) + } + return v1 +} + +// C documentation +// +// /* Return the current length of p in bytes */ +func Xsqlite3_str_length(tls *libc.TLS, p uintptr) (r int32) { + var v1 uint32 + _ = v1 + if p != 0 { + v1 = (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar + } else { + v1 = uint32(0) + } + return libc.Int32FromUint32(v1) +} + +func Xsqlite3_strnicmp(tls *libc.TLS, zLeft uintptr, zRight uintptr, N int32) (r int32) { + var a, b uintptr + var v1 int32 + _, _, _ = a, b, v1 + if zLeft == uintptr(0) { + if zRight != 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 + } else { + if zRight == uintptr(0) { + return int32(1) + } + } + a = zLeft + b = zRight + for { + v1 = N + N = N - 1 + if !(v1 > 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(a))) != 0 && libc.Int32FromUint8(_sqlite3UpperToLower[**(**uint8)(__ccgo_up(a))]) == libc.Int32FromUint8(_sqlite3UpperToLower[**(**uint8)(__ccgo_up(b))])) { + break + } + a = a + 1 + b = b + 1 + } + if N < 0 { + v1 = 0 + } else { + v1 = libc.Int32FromUint8(_sqlite3UpperToLower[**(**uint8)(__ccgo_up(a))]) - libc.Int32FromUint8(_sqlite3UpperToLower[**(**uint8)(__ccgo_up(b))]) + } + return v1 +} + +// C documentation +// +// /* +// ** Return a boolean value for a query parameter. +// */ +func Xsqlite3_uri_boolean(tls *libc.TLS, zFilename uintptr, zParam uintptr, bDflt int32) (r int32) { + var z uintptr + var v1 int32 + _, _ = z, v1 + z = Xsqlite3_uri_parameter(tls, zFilename, zParam) + bDflt = libc.BoolInt32(bDflt != 0) + if z != 0 { + v1 = libc.Int32FromUint8(_sqlite3GetBoolean(tls, z, libc.Uint8FromInt32(bDflt))) + } else { + v1 = bDflt + } + return v1 +} + +func Xsqlite3_value_encoding(tls *libc.TLS, pVal uintptr) (r int32) { + return libc.Int32FromUint8((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fenc) +} + +// C documentation +// +// /* Return true if a parameter value originated from an sqlite3_bind() */ +func Xsqlite3_value_frombind(tls *libc.TLS, pVal uintptr) (r int32) { + return libc.BoolInt32(libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fflags)&int32(MEM_FromBind) != 0) +} + +// C documentation +// +// /* Return true if a parameter to xUpdate represents an unchanged column */ +func Xsqlite3_value_nochange(tls *libc.TLS, pVal uintptr) (r int32) { + return libc.BoolInt32(libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fflags)&(libc.Int32FromInt32(MEM_Null)|libc.Int32FromInt32(MEM_Zero)) == libc.Int32FromInt32(MEM_Null)|libc.Int32FromInt32(MEM_Zero)) +} + +func Xsqlite3_value_subtype(tls *libc.TLS, pVal uintptr) (r uint32) { + var pMem uintptr + var v1 int32 + _, _ = pMem, v1 + pMem = pVal + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Subtype) != 0 { + v1 = libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).FeSubtype) + } else { + v1 = 0 + } + return libc.Uint32FromInt32(v1) +} + +// C documentation +// +// /* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five +// ** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating +// ** point number string BLOB NULL +// */ +func Xsqlite3_value_type(tls *libc.TLS, pVal uintptr) (r int32) { + return libc.Int32FromUint8(_aType[libc.Int32FromUint16((*Tsqlite3_value)(unsafe.Pointer(pVal)).Fflags)&int32(MEM_AffMask)]) +} + +// C documentation +// +// /* +// ** Call from within the xCreate() or xConnect() methods to provide +// ** the SQLite core with additional information about the behavior +// ** of the virtual table being implemented. +// */ +func Xsqlite3_vtab_config(tls *libc.TLS, db uintptr, op int32, va uintptr) (r int32) { + var ap Tva_list + var p uintptr + var rc int32 + _, _, _ = ap, p, rc + rc = SQLITE_OK + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + p = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + if !(p != 0) { + rc = _sqlite3MisuseError(tls, int32(163073)) + } else { + ap = va + switch op { + case int32(SQLITE_VTAB_CONSTRAINT_SUPPORT): + (*TVTable)(unsafe.Pointer((*TVtabCtx)(unsafe.Pointer(p)).FpVTable)).FbConstraint = libc.Uint8FromInt32(libc.VaInt32(&ap)) + case int32(SQLITE_VTAB_INNOCUOUS): + (*TVTable)(unsafe.Pointer((*TVtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = uint8(SQLITE_VTABRISK_Low) + case int32(SQLITE_VTAB_DIRECTONLY): + (*TVTable)(unsafe.Pointer((*TVtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = uint8(SQLITE_VTABRISK_High) + case int32(SQLITE_VTAB_USES_ALL_SCHEMAS): + (*TVTable)(unsafe.Pointer((*TVtabCtx)(unsafe.Pointer(p)).FpVTable)).FbAllSchemas = uint8(1) + default: + rc = _sqlite3MisuseError(tls, int32(163095)) + break + } + _ = ap + } + if rc != SQLITE_OK { + _sqlite3Error(tls, db, rc) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +/************** End of vtab.c ************************************************/ +/************** Begin file wherecode.c ***************************************/ +/* +** 2015-06-06 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This module contains C code that generates VDBE code used to process +** the WHERE clause of SQL statements. +** +** This file was split off from where.c on 2015-06-06 in order to reduce the +** size of where.c and make it easier to edit. This file contains the routines +** that actually generate the bulk of the WHERE loop code. The original where.c +** file retains the code that does query planning and analysis. + */ +/* #include "sqliteInt.h" */ +/************** Include whereInt.h in the middle of wherecode.c **************/ +/************** Begin file whereInt.h ****************************************/ +/* +** 2013-11-12 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains structure and macro definitions for the query +** planner logic in "where.c". These definitions are broken out into +** a separate source file for easier editing. + */ + +const _IOLBF = 1 + +const _IONBF = 2 + +const __SIZEOF_WCHAR_T__ = 4 + +const __SIZEOF_WINT_T__ = 4 + +const __WCHAR_WIDTH__ = 32 + +const __WINT_WIDTH__ = 32 + +const __restrict_arr = 0 + +/* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in + ** length. + ** EVIDENCE-OF: R-28401-00140 Value is a string in the text encoding and + ** (N-13)/2 bytes in length. */ +var _aFlag = [2]Tu16{ + 0: libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Blob) | libc.Int32FromInt32(MEM_Ephem)), + 1: libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Ephem)), +} + +/* If the column value is a string, we need a persistent value, not + ** a MEM_Ephem value. This branch is a fast short-cut that is equivalent + ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize(). + */ +var _aFlag1 = [2]Tu16{ + 0: uint16(MEM_Blob), + 1: libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Term)), +} + +var _aKeyword = [7]struct { + Fi Tu8 + FnChar Tu8 + Fcode Tu8 +}{ + 0: { + FnChar: uint8(7), + Fcode: uint8(JT_NATURAL), + }, + 1: { + Fi: uint8(6), + FnChar: uint8(4), + Fcode: libc.Uint8FromInt32(libc.Int32FromInt32(JT_LEFT) | libc.Int32FromInt32(JT_OUTER)), + }, + 2: { + Fi: uint8(10), + FnChar: uint8(5), + Fcode: uint8(JT_OUTER), + }, + 3: { + Fi: uint8(14), + FnChar: uint8(5), + Fcode: libc.Uint8FromInt32(libc.Int32FromInt32(JT_RIGHT) | libc.Int32FromInt32(JT_OUTER)), + }, + 4: { + Fi: uint8(19), + FnChar: uint8(4), + Fcode: libc.Uint8FromInt32(libc.Int32FromInt32(JT_LEFT) | libc.Int32FromInt32(JT_RIGHT) | libc.Int32FromInt32(JT_OUTER)), + }, + 5: { + Fi: uint8(23), + FnChar: uint8(5), + Fcode: uint8(JT_INNER), + }, + 6: { + Fi: uint8(28), + FnChar: uint8(5), + Fcode: libc.Uint8FromInt32(libc.Int32FromInt32(JT_INNER) | libc.Int32FromInt32(JT_CROSS)), + }, +} + +var _aWindowFuncs = [15]TFuncDef{ + 0: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_row_numberName)), + }, + 1: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_dense_rankName)), + }, + 2: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_rankName)), + }, + 3: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_percent_rankName)), + }, + 4: { + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_cume_distName)), + }, + 5: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_ntileName)), + }, + 6: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_last_valueName)), + }, + 7: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_nth_valueName)), + }, + 8: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_first_valueName)), + }, + 9: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_leadName)), + }, + 10: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_leadName)), + }, + 11: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_leadName)), + }, + 12: { + FnArg: int16(1), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_lagName)), + }, + 13: { + FnArg: int16(2), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_lagName)), + }, + 14: { + FnArg: int16(3), + FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_WINDOW) | libc.Int32FromInt32(0)), + FzName: uintptr(unsafe.Pointer(&_lagName)), + }, +} + +// C documentation +// +// /* +// ** This variant of sqlite3BtreePayload() works even if the cursor has not +// ** in the CURSOR_VALID state. It is only used by the sqlite3_blob_read() +// ** interface. +// */ +func _accessPayloadChecked(tls *libc.TLS, pCur uintptr, offset Tu32, amt Tu32, pBuf uintptr) (r int32) { + var rc, v1 int32 + _, _ = rc, v1 + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == int32(CURSOR_INVALID) { + return int32(SQLITE_ABORT) + } + rc = _btreeRestoreCursorPosition(tls, pCur) + if rc != 0 { + v1 = rc + } else { + v1 = _accessPayload(tls, pCur, offset, amt, pBuf, 0) + } + return v1 +} + +// C documentation +// +// /* +// ** This routine takes the module argument that has been accumulating +// ** in pParse->zArg[] and appends it to the list of arguments on the +// ** virtual table currently under construction in pParse->pTable. +// */ +func _addArgumentToVtab(tls *libc.TLS, pParse uintptr) { + var db, z uintptr + var n int32 + _, _, _ = db, n, z + if (*TParse)(unsafe.Pointer(pParse)).FsArg.Fz != 0 && (*TParse)(unsafe.Pointer(pParse)).FpNewTable != 0 { + z = (*TParse)(unsafe.Pointer(pParse)).FsArg.Fz + n = libc.Int32FromUint32((*TParse)(unsafe.Pointer(pParse)).FsArg.Fn) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + _addModuleArgument(tls, pParse, (*TParse)(unsafe.Pointer(pParse)).FpNewTable, _sqlite3DbStrNDup(tls, db, z, libc.Uint64FromInt32(n))) + } +} + +// C documentation +// +// /* +// ** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid +// ** on the same B-tree as pCur. +// ** +// ** This can occur if a database is corrupt with two or more SQL tables +// ** pointing to the same b-tree. If an insert occurs on one SQL table +// ** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL +// ** table linked to the same b-tree. If the secondary insert causes a +// ** rebalance, that can change content out from under the cursor on the +// ** first SQL table, violating invariants on the first insert. +// */ +func _anotherValidCursor(tls *libc.TLS, pCur uintptr) (r int32) { + var pOther uintptr + _ = pOther + pOther = (*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBt)).FpCursor + for { + if !(pOther != 0) { + break + } + if pOther != pCur && libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pOther)).FeState) == CURSOR_VALID && (*TBtCursor)(unsafe.Pointer(pOther)).FpPage == (*TBtCursor)(unsafe.Pointer(pCur)).FpPage { + return _sqlite3CorruptError(tls, int32(82248)) + } + goto _1 + _1: + ; + pOther = (*TBtCursor)(unsafe.Pointer(pOther)).FpNext + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Perform a read or write operation on a blob +// */ +func _blobReadWrite(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int32, __ccgo_fp_xCall uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, p, v uintptr + var iKey Tsqlite3_int64 + var rc int32 + var _ /* bDiff at bp+0 */ int32 + _, _, _, _, _ = db, iKey, p, rc, v + rc = SQLITE_OK + p = pBlob + if p == uintptr(0) { + return _sqlite3MisuseError(tls, int32(106254)) + } + db = (*TIncrblob)(unsafe.Pointer(p)).Fdb + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + v = (*TIncrblob)(unsafe.Pointer(p)).FpStmt + if n < 0 || iOffset < 0 || int64(iOffset)+int64(n) > int64((*TIncrblob)(unsafe.Pointer(p)).FnByte) { + /* Request is out of range. Return a transient error. */ + rc = int32(SQLITE_ERROR) + } else { + if v == uintptr(0) { + /* If there is no statement handle, then the blob-handle has + ** already been invalidated. Return SQLITE_ABORT in this case. + */ + rc = int32(SQLITE_ABORT) + } else { + /* Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is + ** returned, clean-up the statement handle. + */ + _sqlite3BtreeEnterCursor(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr) + if __ccgo_fp_xCall == __ccgo_fp(_sqlite3BtreePutData) && (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 { + /* If a pre-update hook is registered and this is a write cursor, + ** invoke it here. + ** + ** TODO: The preupdate-hook is passed SQLITE_DELETE, even though this + ** operation should really be an SQLITE_UPDATE. This is probably + ** incorrect, but is convenient because at this point the new.* values + ** are not easily obtainable. And for the sessions module, an + ** SQLITE_UPDATE where the PK columns do not change is handled in the + ** same way as an SQLITE_DELETE (the SQLITE_DELETE code is actually + ** slightly more efficient). Since you cannot write to a PK column + ** using the incremental-blob API, this works. For the sessions module + ** anyhow. + */ + if _sqlite3BtreeCursorIsValidNN(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr) == 0 { + /* If the cursor is not currently valid, try to reseek it. This + ** always either fails or finds the correct row - the cursor will + ** have been marked permanently CURSOR_INVALID if the open row has + ** been deleted. */ + **(**int32)(__ccgo_up(bp)) = 0 + rc = _sqlite3BtreeCursorRestore(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr, bp) + } + if _sqlite3BtreeCursorIsValidNN(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr) != 0 { + iKey = _sqlite3BtreeIntegerKey(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr) + _sqlite3VdbePreUpdateHook(tls, v, **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(v)).FapCsr)), int32(SQLITE_DELETE), (*TIncrblob)(unsafe.Pointer(p)).FzDb, (*TIncrblob)(unsafe.Pointer(p)).FpTab, iKey, -int32(1), libc.Int32FromUint16((*TIncrblob)(unsafe.Pointer(p)).FiCol)) + } + } + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, Tu32, Tu32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xCall})))(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr, libc.Uint32FromInt32(iOffset+(*TIncrblob)(unsafe.Pointer(p)).FiOffset), libc.Uint32FromInt32(n), z) + } + _sqlite3BtreeLeaveCursor(tls, (*TIncrblob)(unsafe.Pointer(p)).FpCsr) + if rc == int32(SQLITE_ABORT) { + _sqlite3VdbeFinalize(tls, v) + (*TIncrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) + } else { + (*TVdbe)(unsafe.Pointer(v)).Frc = rc + } + } + } + _sqlite3Error(tls, db, rc) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* This is a helper function to impliesNotNullRow(). In this routine, +// ** set pWalker->eCode to one only if *both* of the input expressions +// ** separately have the implies-not-null-row property. +// */ +func _bothImplyNotNullRow(tls *libc.TLS, pWalker uintptr, pE1 uintptr, pE2 uintptr) { + if libc.Int32FromUint16((*TWalker)(unsafe.Pointer(pWalker)).FeCode) == 0 { + _sqlite3WalkExpr(tls, pWalker, pE1) + if (*TWalker)(unsafe.Pointer(pWalker)).FeCode != 0 { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + _sqlite3WalkExpr(tls, pWalker, pE2) + } + } +} + +// C documentation +// +// /* +// ** Compute the amount of freespace on the page. In other words, fill +// ** in the pPage->nFree field. +// */ +func _btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) (r int32) { + var data uintptr + var hdr Tu8 + var iCellFirst, iCellLast, nFree, pc, top, usableSize int32 + var next, size Tu32 + _, _, _, _, _, _, _, _, _, _ = data, hdr, iCellFirst, iCellLast, nFree, next, pc, size, top, usableSize /* Last possible cell or freeblock offset */ + usableSize = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) + hdr = (*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates + ** the start of the cell content area. A zero value for this integer is + ** interpreted as 65536. */ + top = (libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(libc.Int32FromUint8(hdr)+int32(5)))))< 0 { + if pc < top { + /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will + ** always be at least one cell before the first freeblock. + */ + return _sqlite3CorruptError(tls, int32(75273)) + } + for int32(1) != 0 { + if pc > iCellLast { + /* Freeblock off the end of the page */ + return _sqlite3CorruptError(tls, int32(75278)) + } + next = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + uintptr(pc))))< uint32(0) { + /* Freeblock not in ascending order */ + return _sqlite3CorruptError(tls, int32(75288)) + } + if libc.Uint32FromInt32(pc)+size > libc.Uint32FromInt32(usableSize) { + /* Last freeblock extends past page end */ + return _sqlite3CorruptError(tls, int32(75292)) + } + } + /* At this point, nFree contains the sum of the offset to the start + ** of the cell-content area plus the number of free bytes within + ** the cell-content area. If this is greater than the usable-size + ** of the page, then the page must be corrupted. This check also + ** serves to verify that the offset to the start of the cell-content + ** area, according to the page header, lies within the page. + */ + if nFree > usableSize || nFree < iCellFirst { + return _sqlite3CorruptError(tls, int32(75304)) + } + (*TMemPage)(unsafe.Pointer(pPage)).FnFree = libc.Int32FromUint16(libc.Uint16FromInt32(nFree - iCellFirst)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback() +// ** at the conclusion of a transaction. +// */ +func _btreeEndTransaction(tls *libc.TLS, p uintptr) { + var db, pBt uintptr + _, _ = db, pBt + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + db = (*TBtree)(unsafe.Pointer(p)).Fdb + (*TBtShared)(unsafe.Pointer(pBt)).FbDoTruncate = uint8(0) + if libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) > TRANS_NONE && (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1) { + /* If there are other active statements that belong to this database + ** handle, downgrade to a read-only transaction. The other statements + ** may still be reading from the database. */ + _downgradeAllSharedCacheTableLocks(tls, p) + (*TBtree)(unsafe.Pointer(p)).FinTrans = uint8(TRANS_READ) + } else { + /* If the handle had any kind of transaction open, decrement the + ** transaction count of the shared btree. If the transaction count + ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused() + ** call below will unlock the pager. */ + if libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) != TRANS_NONE { + _clearAllSharedCacheTableLocks(tls, p) + (*TBtShared)(unsafe.Pointer(pBt)).FnTransaction = (*TBtShared)(unsafe.Pointer(pBt)).FnTransaction - 1 + if 0 == (*TBtShared)(unsafe.Pointer(pBt)).FnTransaction { + (*TBtShared)(unsafe.Pointer(pBt)).FinTransaction = uint8(TRANS_NONE) + } + } + /* Set the current transaction state to TRANS_NONE and unlock the + ** pager if this call closed the only read or write transaction. */ + (*TBtree)(unsafe.Pointer(p)).FinTrans = uint8(TRANS_NONE) + _unlockBtreeIfUnused(tls, pBt) + } +} + +// C documentation +// +// /* +// ** Initialize the auxiliary information for a disk block. +// ** +// ** Return SQLITE_OK on success. If we see that the page does +// ** not contain a well-formed database page, then return +// ** SQLITE_CORRUPT. Note that a return of SQLITE_OK does not +// ** guarantee that the page is well-formed. It only shows that +// ** we failed to detect any corruption. +// */ +func _btreeInitPage(tls *libc.TLS, pPage uintptr) (r int32) { + var data, pBt uintptr + _, _ = data, pBt /* The main btree structure */ + pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt + data = (*TMemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) + /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating + ** the b-tree page type. */ + if _decodeFlags(tls, pPage, libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data)))) != 0 { + return _sqlite3CorruptError(tls, int32(75372)) + } + (*TMemPage)(unsafe.Pointer(pPage)).FmaskPage = uint16((*TBtShared)(unsafe.Pointer(pBt)).FpageSize - libc.Uint32FromInt32(1)) + (*TMemPage)(unsafe.Pointer(pPage)).FnOverflow = uint8(0) + (*TMemPage)(unsafe.Pointer(pPage)).FcellOffset = libc.Uint16FromInt32(libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset) + libc.Int32FromInt32(8) + libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) + (*TMemPage)(unsafe.Pointer(pPage)).FaCellIdx = data + uintptr((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + uintptr(8) + (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd = (*TMemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*TBtShared)(unsafe.Pointer(pBt)).FpageSize) + (*TMemPage)(unsafe.Pointer(pPage)).FaDataOfst = (*TMemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the + ** number of cells on the page. */ + (*TMemPage)(unsafe.Pointer(pPage)).FnCell = libc.Uint16FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(data + 3)))< ((*TBtShared)(unsafe.Pointer(pBt)).FpageSize-uint32(8))/uint32(6) { + /* To many cells for a single page. The page must be corrupt */ + return _sqlite3CorruptError(tls, int32(75386)) + } + /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only + ** possible for a root page of a table that contains no rows) then the + ** offset to the cell content area will equal the page size minus the + ** bytes of reserved space. */ + (*TMemPage)(unsafe.Pointer(pPage)).FnFree = -int32(1) /* Indicate that this value is yet uncomputed */ + (*TMemPage)(unsafe.Pointer(pPage)).FisInit = uint8(1) + if (*Tsqlite3)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags&uint64(SQLITE_CellSizeCk) != 0 { + return _btreeCellSizeCheck(tls, pPage) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** In this version of BtreeMoveto, pKey is a packed index record +// ** such as is generated by the OP_MakeRecord opcode. Unpack the +// ** record and then call sqlite3BtreeIndexMoveto() to do the work. +// */ +func _btreeMoveto(tls *libc.TLS, pCur uintptr, pKey uintptr, nKey Ti64, bias int32, pRes uintptr) (r int32) { + var pIdxKey, pKeyInfo uintptr + var rc int32 + _, _, _ = pIdxKey, pKeyInfo, rc /* Unpacked index key */ + if pKey != 0 { + pKeyInfo = (*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo + pIdxKey = _sqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo) + if pIdxKey == uintptr(0) { + return int32(SQLITE_NOMEM) + } + _sqlite3VdbeRecordUnpack(tls, int32(nKey), pKey, pIdxKey) + if libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FnField) == 0 || libc.Int32FromUint16((*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).FnField) > libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField) { + rc = _sqlite3CorruptError(tls, int32(74018)) + } else { + rc = _sqlite3BtreeIndexMoveto(tls, pCur, pIdxKey, pRes) + } + _sqlite3DbFree(tls, (*TKeyInfo)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo)).Fdb, pIdxKey) + } else { + pIdxKey = uintptr(0) + rc = _sqlite3BtreeTableMoveto(tls, pCur, nKey, bias, pRes) + } + return rc +} + +// C documentation +// +// /* +// ** Overwrite the cell that cursor pCur is pointing to with fresh content +// ** contained in pX. +// */ +func _btreeOverwriteCell(tls *libc.TLS, pCur uintptr, pX uintptr) (r int32) { + var nTotal int32 + var pPage uintptr + _, _ = nTotal, pPage + nTotal = (*TBtreePayload)(unsafe.Pointer(pX)).FnData + (*TBtreePayload)(unsafe.Pointer(pX)).FnZero /* Total bytes of to write */ + pPage = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage /* Page being written */ + if (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload+uintptr((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) > (*TMemPage)(unsafe.Pointer(pPage)).FaDataEnd || (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload < (*TMemPage)(unsafe.Pointer(pPage)).FaData+uintptr((*TMemPage)(unsafe.Pointer(pPage)).FcellOffset) { + return _sqlite3CorruptError(tls, int32(82500)) + } + if libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) == nTotal { + /* The entire cell is local */ + return _btreeOverwriteContent(tls, pPage, (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload, pX, 0, libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) + } else { + /* The cell contains overflow content */ + return _btreeOverwriteOverflowCell(tls, pCur, pX) + } + return r +} + +// C documentation +// +// /* +// ** Overwrite the cell that cursor pCur is pointing to with fresh content +// ** contained in pX. In this variant, pCur is pointing to an overflow +// ** cell. +// */ +func _btreeOverwriteOverflowCell(tls *libc.TLS, pCur uintptr, pX uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iOffset, nTotal, rc int32 + var ovflPageSize Tu32 + var ovflPgno TPgno + var pBt uintptr + var _ /* pPage at bp+0 */ uintptr + _, _, _, _, _, _ = iOffset, nTotal, ovflPageSize, ovflPgno, pBt, rc /* Next byte of pX->pData to write */ + nTotal = (*TBtreePayload)(unsafe.Pointer(pX)).FnData + (*TBtreePayload)(unsafe.Pointer(pX)).FnZero /* Return code */ + **(**uintptr)(__ccgo_up(bp)) = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage /* Size to write on overflow page */ + /* pCur is an overflow cell */ + /* Overwrite the local portion first */ + rc = _btreeOverwriteContent(tls, **(**uintptr)(__ccgo_up(bp)), (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload, pX, 0, libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) + if rc != 0 { + return rc + } + /* Now overwrite the overflow pages */ + iOffset = libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) + ovflPgno = _sqlite3Get4byte(tls, (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload+uintptr(iOffset)) + pBt = (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpBt + ovflPageSize = (*TBtShared)(unsafe.Pointer(pBt)).FusableSize - uint32(4) + for cond := true; cond; cond = iOffset < nTotal { + rc = _btreeGetPage(tls, pBt, ovflPgno, bp, 0) + if rc != 0 { + return rc + } + if _sqlite3PagerPageRefcount(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) != int32(1) || (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FisInit != 0 { + rc = _sqlite3CorruptError(tls, int32(82472)) + } else { + if libc.Uint32FromInt32(iOffset)+ovflPageSize < libc.Uint32FromInt32(nTotal) { + ovflPgno = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData) + } else { + ovflPageSize = libc.Uint32FromInt32(nTotal - iOffset) + } + rc = _btreeOverwriteContent(tls, **(**uintptr)(__ccgo_up(bp)), (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaData+uintptr(4), pX, iOffset, libc.Int32FromUint32(ovflPageSize)) + } + _sqlite3PagerUnref(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpDbPage) + if rc != 0 { + return rc + } + iOffset = libc.Int32FromUint32(uint32(iOffset) + ovflPageSize) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Convert a DbPage obtained from the pager into a MemPage used by +// ** the btree layer. +// */ +func _btreePageFromDbPage(tls *libc.TLS, pDbPage uintptr, pgno TPgno, pBt uintptr) (r uintptr) { + var pPage uintptr + var v1 int32 + _, _ = pPage, v1 + pPage = _sqlite3PagerGetExtra(tls, pDbPage) + if pgno != (*TMemPage)(unsafe.Pointer(pPage)).Fpgno { + (*TMemPage)(unsafe.Pointer(pPage)).FaData = _sqlite3PagerGetData(tls, pDbPage) + (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage = pDbPage + (*TMemPage)(unsafe.Pointer(pPage)).FpBt = pBt + (*TMemPage)(unsafe.Pointer(pPage)).Fpgno = pgno + if pgno == uint32(1) { + v1 = int32(100) + } else { + v1 = 0 + } + (*TMemPage)(unsafe.Pointer(pPage)).FhdrOffset = libc.Uint8FromInt32(v1) + } + return pPage +} + +// C documentation +// +// /* +// ** The following routines are implementations of the MemPage.xParseCell() +// ** method. +// ** +// ** Parse a cell content block and fill in the CellInfo structure. +// ** +// ** btreeParseCellPtr() => table btree leaf nodes +// ** btreeParseCellNoPayload() => table btree internal nodes +// ** btreeParseCellPtrIndex() => index btree nodes +// ** +// ** There is also a wrapper function btreeParseCell() that works for +// ** all MemPage types and that references the cell by index rather than +// ** by pointer. +// */ +func _btreeParseCellPtrNoPayload(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) { + _ = pPage + (*TCellInfo)(unsafe.Pointer(pInfo)).FnSize = libc.Uint16FromInt32(int32(4) + libc.Int32FromUint8(_sqlite3GetVarint(tls, pCell+4, pInfo))) + (*TCellInfo)(unsafe.Pointer(pInfo)).FnPayload = uint32(0) + (*TCellInfo)(unsafe.Pointer(pInfo)).FnLocal = uint16(0) + (*TCellInfo)(unsafe.Pointer(pInfo)).FpPayload = uintptr(0) + return +} + +// C documentation +// +// /* +// ** Given a record with nPayload bytes of payload stored within btree +// ** page pPage, return the number of bytes of payload stored locally. +// */ +func _btreePayloadToLocal(tls *libc.TLS, pPage uintptr, nPayload Ti64) (r int32) { + var maxLocal, minLocal, surplus, v1 int32 + _, _, _, _ = maxLocal, minLocal, surplus, v1 /* Maximum amount of payload held locally */ + maxLocal = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal) + if nPayload <= int64(maxLocal) { + return int32(nPayload) + } else { /* Overflow payload available for local storage */ + minLocal = libc.Int32FromUint16((*TMemPage)(unsafe.Pointer(pPage)).FminLocal) + surplus = int32(int64(minLocal) + (nPayload-int64(minLocal))%libc.Int64FromUint32((*TBtShared)(unsafe.Pointer((*TMemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-libc.Uint32FromInt32(4))) + if surplus <= maxLocal { + v1 = surplus + } else { + v1 = minLocal + } + return v1 + } + return r +} + +// C documentation +// +// /* +// ** Restore the cursor to the position it was in (or as close to as possible) +// ** when saveCursorPosition() was called. Note that this call deletes the +// ** saved position info stored by saveCursorPosition(), so there can be +// ** at most one effective restoreCursorPosition() call after each +// ** saveCursorPosition(). +// */ +func _btreeRestoreCursorPosition(tls *libc.TLS, pCur uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* skipNext at bp+0 */ int32 + _ = rc + **(**int32)(__ccgo_up(bp)) = 0 + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == int32(CURSOR_FAULT) { + return (*TBtCursor)(unsafe.Pointer(pCur)).FskipNext + } + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID) + if _sqlite3FaultSim(tls, int32(410)) != 0 { + rc = int32(SQLITE_IOERR) + } else { + rc = _btreeMoveto(tls, pCur, (*TBtCursor)(unsafe.Pointer(pCur)).FpKey, (*TBtCursor)(unsafe.Pointer(pCur)).FnKey, 0, bp) + } + if rc == SQLITE_OK { + Xsqlite3_free(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpKey) + (*TBtCursor)(unsafe.Pointer(pCur)).FpKey = uintptr(0) + if **(**int32)(__ccgo_up(bp)) != 0 { + (*TBtCursor)(unsafe.Pointer(pCur)).FskipNext = **(**int32)(__ccgo_up(bp)) + } + if (*TBtCursor)(unsafe.Pointer(pCur)).FskipNext != 0 && libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID { + (*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_SKIPNEXT) + } + } + return rc +} + +// C documentation +// +// /* +// ** Set the pBt->nPage field correctly, according to the current +// ** state of the database. Assume pBt->pPage1 is valid. +// */ +func _btreeSetNPage(tls *libc.TLS, pBt uintptr, pPage1 uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* nPage at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint32(_sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer(pPage1)).FaData+28)) + if **(**int32)(__ccgo_up(bp)) == 0 { + _sqlite3PagerPagecount(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, bp) + } + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp))) +} + +// C documentation +// +// /* +// ** Implementation of the octet_length() function +// */ +func _bytelengthFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var m Ti64 + var v1 int32 + _, _ = m, v1 + _ = argc + switch Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_BLOB): + Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv)))) + case int32(SQLITE_INTEGER): + fallthrough + case int32(SQLITE_FLOAT): + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(Xsqlite3_context_db_handle(tls, context))).Fenc) <= int32(SQLITE_UTF8) { + v1 = int32(1) + } else { + v1 = int32(2) + } + m = int64(v1) + Xsqlite3_result_int64(tls, context, int64(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))))*m) + case int32(SQLITE_TEXT): + if Xsqlite3_value_encoding(tls, **(**uintptr)(__ccgo_up(argv))) <= int32(SQLITE_UTF8) { + Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv)))) + } else { + Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes16(tls, **(**uintptr)(__ccgo_up(argv)))) + } + default: + Xsqlite3_result_null(tls, context) + break + } +} + +// C documentation +// +// /* +// ** Return the N-dimensional volume of the cell stored in *p. +// */ +func _cellArea(tls *libc.TLS, pRtree uintptr, p uintptr) (r TRtreeDValue) { + var area TRtreeDValue + _ = area + area = libc.Float64FromInt32(1) + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + switch libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim) { + case int32(5): + area = float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + 9*4)) - *(*TRtreeValue)(unsafe.Pointer(p + 8 + 8*4))) + fallthrough + case int32(4): + area = area * float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + 7*4))-*(*TRtreeValue)(unsafe.Pointer(p + 8 + 6*4))) + fallthrough + case int32(3): + area = area * float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + 5*4))-*(*TRtreeValue)(unsafe.Pointer(p + 8 + 4*4))) + fallthrough + case int32(2): + area = area * float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + 3*4))-*(*TRtreeValue)(unsafe.Pointer(p + 8 + 2*4))) + fallthrough + default: + area = area * float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + 1*4))-*(*TRtreeValue)(unsafe.Pointer(p + 8))) + } + } else { + switch libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim) { + case int32(5): + area = float64(int64(*(*int32)(unsafe.Pointer(p + 8 + 9*4))) - int64(*(*int32)(unsafe.Pointer(p + 8 + 8*4)))) + fallthrough + case int32(4): + area = area * float64(int64(*(*int32)(unsafe.Pointer(p + 8 + 7*4)))-int64(*(*int32)(unsafe.Pointer(p + 8 + 6*4)))) + fallthrough + case int32(3): + area = area * float64(int64(*(*int32)(unsafe.Pointer(p + 8 + 5*4)))-int64(*(*int32)(unsafe.Pointer(p + 8 + 4*4)))) + fallthrough + case int32(2): + area = area * float64(int64(*(*int32)(unsafe.Pointer(p + 8 + 3*4)))-int64(*(*int32)(unsafe.Pointer(p + 8 + 2*4)))) + fallthrough + default: + area = area * float64(int64(*(*int32)(unsafe.Pointer(p + 8 + 1*4)))-int64(*(*int32)(unsafe.Pointer(p + 8)))) + } + } + return area +} + +// C documentation +// +// /* +// ** Return true if the area covered by p2 is a subset of the area covered +// ** by p1. False otherwise. +// */ +func _cellContains(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) (r int32) { + var a1, a11, a2, a21 uintptr + var ii int32 + _, _, _, _, _ = a1, a11, a2, a21, ii + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == int32(RTREE_COORD_INT32) { + ii = 0 + for { + if !(ii < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)) { + break + } + a1 = p1 + 8 + uintptr(ii)*4 + a2 = p2 + 8 + uintptr(ii)*4 + if *(*int32)(unsafe.Pointer(a2)) < *(*int32)(unsafe.Pointer(a1)) || *(*int32)(unsafe.Pointer(a2 + 1*4)) > *(*int32)(unsafe.Pointer(a1 + 1*4)) { + return 0 + } + goto _1 + _1: + ; + ii = ii + int32(2) + } + } else { + ii = 0 + for { + if !(ii < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)) { + break + } + a11 = p1 + 8 + uintptr(ii)*4 + a21 = p2 + 8 + uintptr(ii)*4 + if *(*TRtreeValue)(unsafe.Pointer(a21)) < *(*TRtreeValue)(unsafe.Pointer(a11)) || *(*TRtreeValue)(unsafe.Pointer(a21 + 1*4)) > *(*TRtreeValue)(unsafe.Pointer(a11 + 1*4)) { + return 0 + } + goto _2 + _2: + ; + ii = ii + int32(2) + } + } + return int32(1) +} + +// C documentation +// +// /* +// ** Return the margin length of cell p. The margin length is the sum +// ** of the objects size in each dimension. +// */ +func _cellMargin(tls *libc.TLS, pRtree uintptr, p uintptr) (r TRtreeDValue) { + var ii int32 + var margin TRtreeDValue + var v1, v2 float64 + _, _, _, _ = ii, margin, v1, v2 + margin = libc.Float64FromInt32(0) + ii = libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) - int32(2) + for cond := true; cond; cond = ii >= 0 { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v1 = float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + uintptr(ii+int32(1))*4))) + } else { + v1 = float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(ii+int32(1))*4))) + } + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + v2 = float64(*(*TRtreeValue)(unsafe.Pointer(p + 8 + uintptr(ii)*4))) + } else { + v2 = float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(ii)*4))) + } + margin = margin + (v1 - v2) + ii = ii - int32(2) + } + return margin +} + +// C documentation +// +// /* +// ** Store the union of cells p1 and p2 in p1. +// */ +func _cellUnion(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) { + var ii, v3 int32 + var v1 TRtreeValue + _, _, _ = ii, v1, v3 + ii = 0 + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { + for cond := true; cond; cond = ii < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) { + if *(*TRtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) < *(*TRtreeValue)(unsafe.Pointer(p2 + 8 + uintptr(ii)*4)) { + v1 = *(*TRtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) + } else { + v1 = *(*TRtreeValue)(unsafe.Pointer(p2 + 8 + uintptr(ii)*4)) + } + *(*TRtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) = v1 + if *(*TRtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii+int32(1))*4)) > *(*TRtreeValue)(unsafe.Pointer(p2 + 8 + uintptr(ii+int32(1))*4)) { + v1 = *(*TRtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii+int32(1))*4)) + } else { + v1 = *(*TRtreeValue)(unsafe.Pointer(p2 + 8 + uintptr(ii+int32(1))*4)) + } + *(*TRtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii+int32(1))*4)) = v1 + ii = ii + int32(2) + } + } else { + for cond := true; cond; cond = ii < libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) { + if *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) < *(*int32)(unsafe.Pointer(p2 + 8 + uintptr(ii)*4)) { + v3 = *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) + } else { + v3 = *(*int32)(unsafe.Pointer(p2 + 8 + uintptr(ii)*4)) + } + *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) = v3 + if *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii+int32(1))*4)) > *(*int32)(unsafe.Pointer(p2 + 8 + uintptr(ii+int32(1))*4)) { + v3 = *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii+int32(1))*4)) + } else { + v3 = *(*int32)(unsafe.Pointer(p2 + 8 + uintptr(ii+int32(1))*4)) + } + *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii+int32(1))*4)) = v3 + ii = ii + int32(2) + } + } +} + +// C documentation +// +// /* +// ** If the TEMP database is open, close it and mark the database schema +// ** as needing reloading. This must be done when using the SQLITE_TEMP_STORE +// ** or DEFAULT_TEMP_STORE pragmas. +// */ +func _changeTempStorage(tls *libc.TLS, pParse uintptr, zStorageType uintptr) (r int32) { + var db uintptr + var ts int32 + _, _ = db, ts + ts = _getTempStore(tls, zStorageType) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) == ts { + return SQLITE_OK + } + if _invalidateTempStorage(tls, pParse) != SQLITE_OK { + return int32(SQLITE_ERROR) + } + (*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store = libc.Uint8FromInt32(ts) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Close all file descriptors accumulated in the unixInodeInfo->pUnused list. +// */ +func _closePendingFds(tls *libc.TLS, pFile uintptr) { + var p, pInode, pNext uintptr + _, _, _ = p, pInode, pNext + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + p = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpUnused + for { + if !(p != 0) { + break + } + pNext = (*TUnixUnusedFd)(unsafe.Pointer(p)).FpNext + _robust_close(tls, pFile, (*TUnixUnusedFd)(unsafe.Pointer(p)).Ffd, int32(41665)) + Xsqlite3_free(tls, p) + goto _1 + _1: + ; + p = pNext + } + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpUnused = uintptr(0) +} + +// C documentation +// +// /* +// ** Generate code for a comparison operator. +// */ +func _codeCompare(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr, opcode int32, in1 int32, in2 int32, dest int32, jumpIfNull int32, isCommuted int32) (r int32) { + var addr, p5 int32 + var p4 uintptr + _, _, _ = addr, p4, p5 + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return 0 + } + if isCommuted != 0 { + p4 = _sqlite3BinaryCompareCollSeq(tls, pParse, pRight, pLeft) + } else { + p4 = _sqlite3BinaryCompareCollSeq(tls, pParse, pLeft, pRight) + } + p5 = libc.Int32FromUint8(_binaryCompareP5(tls, pLeft, pRight, jumpIfNull)) + addr = _sqlite3VdbeAddOp4(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, opcode, in2, dest, in1, p4, -int32(2)) + _sqlite3VdbeChangeP5(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, libc.Uint16FromInt32(p5)) + return addr +} + +// C documentation +// +// /* +// ** Generate code for a single equality term of the WHERE clause. An equality +// ** term can be either X=expr or X IN (...). pTerm is the term to be +// ** coded. +// ** +// ** The current value for the constraint is left in a register, the index +// ** of which is returned. An attempt is made store the result in iTarget but +// ** this is only guaranteed for TK_ISNULL and TK_IN constraints. If the +// ** constraint is a TK_EQ or TK_IS, then the current value might be left in +// ** some other register and it is the caller's responsibility to compensate. +// ** +// ** For a constraint of the form X=expr, the expression is evaluated in +// ** straight-line code. For constraints of the form X IN (...) +// ** this routine sets up a loop that will iterate over all values of X. +// */ +func _codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintptr, iEq int32, bRev int32, iTarget int32) (r int32) { + var iReg int32 + var pX uintptr + _, _ = iReg, pX + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr /* Register holding results */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop) == int32(TK_EQ) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop) == int32(TK_IS) { + iReg = _sqlite3ExprCodeTarget(tls, pParse, (*TExpr)(unsafe.Pointer(pX)).FpRight, iTarget) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop) == int32(TK_ISNULL) { + iReg = iTarget + _sqlite3VdbeAddOp2(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Null), 0, iReg) + } else { + iReg = iTarget + _codeINTerm(tls, pParse, pTerm, pLevel, iEq, bRev, iTarget) + } + } + /* As an optimization, try to disable the WHERE clause term that is + ** driving the index as it will always be true. The correct answer is + ** obtained regardless, but we might get the answer with fewer CPU cycles + ** by omitting the term. + ** + ** But do not disable the term unless we are certain that the term is + ** not a transitive constraint. For an example of where that does not + ** work, see https://sqlite.org/forum/forumpost/eb8613976a (2021-05-04) + */ + if (*TWhereLoop)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags&uint32(WHERE_TRANSCONS) == uint32(0) || libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(WO_EQUIV) == 0 { + _disableTerm(tls, pLevel, pTerm) + } + return iReg +} + +// C documentation +// +// /* +// ** pMem currently only holds a string type (or maybe a BLOB that we can +// ** interpret as a string if we want to). Compute its corresponding +// ** numeric type, if has one. Set the pMem->u.r and pMem->u.i fields +// ** accordingly. +// */ +func _computeNumericType(tls *libc.TLS, pMem uintptr) (r Tu16) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc, v1 int32 + var _ /* ix at bp+0 */ Tsqlite3_int64 + _, _ = rc, v1 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Zero) != 0 { + v1 = _sqlite3VdbeMemExpandBlob(tls, pMem) + } else { + v1 = 0 + } + if v1 != 0 { + *(*Ti64)(unsafe.Pointer(pMem)) = 0 + return uint16(MEM_Int) + } + rc = _sqlite3MemRealValueRC(tls, pMem, pMem) + if rc <= 0 { + if rc&int32(2) == 0 && _sqlite3Atoi64(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, bp, (*TMem)(unsafe.Pointer(pMem)).Fn, (*TMem)(unsafe.Pointer(pMem)).Fenc) <= int32(1) { + *(*Ti64)(unsafe.Pointer(pMem)) = **(**Tsqlite3_int64)(__ccgo_up(bp)) + return uint16(MEM_Int) + } else { + return uint16(MEM_Real) + } + } else { + if rc&int32(2) == 0 && _sqlite3Atoi64(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, bp, (*TMem)(unsafe.Pointer(pMem)).Fn, (*TMem)(unsafe.Pointer(pMem)).Fenc) == 0 { + *(*Ti64)(unsafe.Pointer(pMem)) = **(**Tsqlite3_int64)(__ccgo_up(bp)) + return uint16(MEM_Int) + } + } + return uint16(MEM_Real) +} + +// C documentation +// +// /* +// ** idxNum: +// ** +// ** 0 schema=main, full table scan +// ** 1 schema=main, pgno=?1 +// ** 2 schema=?1, full table scan +// ** 3 schema=?1, pgno=?2 +// */ +func _dbpageBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + var i, iPlan, v3 int32 + var p, p1 uintptr + _, _, _, _, _ = i, iPlan, p, p1, v3 + iPlan = 0 + _ = tab + /* If there is a schema= constraint, it must be honored. Report a + ** ridiculously large estimated cost if the schema= constraint is + ** unavailable + */ + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12 + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn != int32(DBPAGE_COLUMN_SCHEMA) { + goto _1 + } + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) != int32(SQLITE_INDEX_CONSTRAINT_EQ) { + goto _1 + } + if !((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) { + /* No solution. */ + return int32(SQLITE_CONSTRAINT) + } + iPlan = int32(2) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + break + goto _1 + _1: + ; + i = i + 1 + } + /* If we reach this point, it means that either there is no schema= + ** constraint (in which case we use the "main" schema) or else the + ** schema constraint was accepted. Lower the estimated cost accordingly + */ + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1e+06) + /* Check for constraints against pgno */ + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + p1 = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12 + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).Fusable != 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).FiColumn <= 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = int32(SQLITE_INDEX_SCAN_UNIQUE) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1) + if iPlan != 0 { + v3 = int32(2) + } else { + v3 = int32(1) + } + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v3 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + iPlan = iPlan | int32(1) + break + } + goto _2 + _2: + ; + i = i + 1 + } + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan + if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy >= int32(1) && (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).FiColumn <= 0 && libc.Int32FromUint8((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).Fdesc) == 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = int32(1) + } + return SQLITE_OK +} + +func _dbpageRowid(tls *libc.TLS, pCursor uintptr, pRowid uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCursor + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = libc.Int64FromUint32((*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Delete the cell at index iCell of node pNode. After removing the +// ** cell, adjust the r-tree data structure if required. +// */ +func _deleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32, iHeight int32) (r int32) { + var pParent uintptr + var rc, v1 int32 + _, _, _ = pParent, rc, v1 + v1 = _fixLeafParent(tls, pRtree, pNode) + rc = v1 + if SQLITE_OK != v1 { + return rc + } + /* Remove the cell from the node. This call just moves bytes around + ** the in-memory node image, so it cannot fail. + */ + _nodeDeleteCell(tls, pRtree, pNode, iCell) + /* If the node is not the tree root and now has less than the minimum + ** number of cells, remove it from the tree. Otherwise, update the + ** cell in the parent node so that it tightly contains the updated + ** node. + */ + pParent = (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent + if pParent != 0 { + if _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) < ((*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize-int32(4))/libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/int32(3) { + rc = _removeNode(tls, pRtree, pNode, iHeight) + } else { + rc = _fixBoundingBox(tls, pRtree, pNode) + } + } + return rc +} + +// C documentation +// +// /* +// ** Write VDBE code to erase table pTab and all associated indices on disk. +// ** Code to update the sqlite_schema tables and internal schema definitions +// ** in case a root-page belonging to another table is moved by the btree layer +// ** is also added (this can happen with an auto-vacuum database). +// */ +func _destroyTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { + var iDb int32 + var iDestroyed, iIdx, iLargest, iTab TPgno + var pIdx uintptr + _, _, _, _, _, _ = iDb, iDestroyed, iIdx, iLargest, iTab, pIdx + /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM + ** is not defined), then it is important to call OP_Destroy on the + ** table and index root-pages in order, starting with the numerically + ** largest root-page number. This guarantees that none of the root-pages + ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the + ** following were coded: + ** + ** OP_Destroy 4 0 + ** ... + ** OP_Destroy 5 0 + ** + ** and root page 5 happened to be the largest root-page number in the + ** database, then root page 5 would be moved to page 4 by the + ** "OP_Destroy 4 0" opcode. The subsequent "OP_Destroy 5 0" would hit + ** a free-list page. + */ + iTab = (*TTable)(unsafe.Pointer(pTab)).Ftnum + iDestroyed = uint32(0) + for int32(1) != 0 { + iLargest = uint32(0) + if iDestroyed == uint32(0) || iTab < iDestroyed { + iLargest = iTab + } + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + iIdx = (*TIndex)(unsafe.Pointer(pIdx)).Ftnum + if (iDestroyed == uint32(0) || iIdx < iDestroyed) && iIdx > iLargest { + iLargest = iIdx + } + goto _1 + _1: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if iLargest == uint32(0) { + return + } else { + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + _destroyRootPage(tls, pParse, libc.Int32FromUint32(iLargest), iDb) + iDestroyed = iLargest + } + } +} + +// C documentation +// +// /* +// ** This routine checks if there is a RESERVED lock held on the specified +// ** file by this or any other process. If the caller holds a SHARED +// ** or greater lock when it is called, then it is assumed that no other +// ** client may hold RESERVED. Or, if the caller holds no lock, then it +// ** is assumed another client holds RESERVED if the lock-file exists. +// */ +func _dotlockCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) (r int32) { + var pFile uintptr + _ = pFile + pFile = id + if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) >= int32(SHARED_LOCK) { + **(**int32)(__ccgo_up(pResOut)) = 0 + } else { + **(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext, 0) == 0) + } + return SQLITE_OK +} + +var _dotlockIoFinder = uintptr(0) + +func _dotlockIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) (r uintptr) { + _ = z + _ = p + return uintptr(unsafe.Pointer(&_dotlockIoMethods)) +} + +var _dotlockIoMethods = Tsqlite3_io_methods{ + FiVersion: int32(1), +} + +// C documentation +// +// /* +// ** Estimate the logarithm of the input value to base 2. +// */ +func _estLog(tls *libc.TLS, N TLogEst) (r TLogEst) { + var v1 int32 + _ = v1 + if int32(N) <= int32(10) { + v1 = 0 + } else { + v1 = int32(_sqlite3LogEst(tls, libc.Uint64FromInt16(N))) - int32(33) + } + return int16(v1) +} + +// C documentation +// +// /* +// ** If expression pExpr is of type TK_SELECT, generate code to evaluate +// ** it. Return the register in which the result is stored (or, if the +// ** sub-select returns more than one column, the first in an array +// ** of registers in which the result is stored). +// ** +// ** If pExpr is not a TK_SELECT expression, return 0. +// */ +func _exprCodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) { + var reg int32 + _ = reg + reg = 0 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) { + reg = _sqlite3CodeSubselect(tls, pParse, pExpr) + } + return reg +} + +// C documentation +// +// /* +// ** Generate code that evaluates an AND or OR operator leaving a +// ** boolean result in a register. pExpr is the AND/OR expression. +// ** Store the result in the "target" register. Use short-circuit +// ** evaluation to avoid computing both operands, if possible. +// ** +// ** The code generated might require the use of a temporary register. +// ** If it does, then write the number of that temporary register +// ** into *pTmpReg. If not, leave *pTmpReg unchanged. +// */ +func _exprCodeTargetAndOr(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32, pTmpReg uintptr) (r int32) { + var addrSkip, op, r1, r2, regSS, skipOp, v1 int32 + var pAlt, v uintptr + _, _, _, _, _, _, _, _, _ = addrSkip, op, pAlt, r1, r2, regSS, skipOp, v, v1 /* Branch instruction that skips one of the operands */ + regSS = 0 /* statement being coded */ + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + pAlt = _sqlite3ExprSimplifiedAndOr(tls, pExpr) + if pAlt != pExpr { + r1 = _sqlite3ExprCodeTarget(tls, pParse, pAlt, target) + _sqlite3VdbeAddOp3(tls, v, int32(OP_And), r1, r1, target) + return target + } + if op == int32(TK_AND) { + v1 = int32(OP_IfNot) + } else { + v1 = int32(OP_If) + } + skipOp = v1 + if _exprEvalRhsFirst(tls, pExpr) != 0 { + /* Compute the right operand first. Skip the computation of the left + ** operand if the right operand fully determines the result */ + v1 = _sqlite3ExprCodeTarget(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, target) + regSS = v1 + r2 = v1 + addrSkip = _sqlite3VdbeAddOp1(tls, v, skipOp, r2) + r1 = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, pTmpReg) + } else { + /* Compute the left operand first */ + r1 = _sqlite3ExprCodeTarget(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + if (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + /* Skip over the computation of the right operand if the right + ** operand is a subquery and the left operand completely determines + ** the result */ + regSS = r1 + addrSkip = _sqlite3VdbeAddOp1(tls, v, skipOp, r1) + } else { + v1 = libc.Int32FromInt32(0) + regSS = v1 + addrSkip = v1 + } + r2 = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, pTmpReg) + } + _sqlite3VdbeAddOp3(tls, v, op, r2, r1, target) + if addrSkip != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addrSkip) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Or), regSS, regSS, target) + } + return target +} + +// C documentation +// +// /* +// ** Commute a comparison operator. Expressions of the form "X op Y" +// ** are converted into "Y op X". +// */ +func _exprCommute(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r Tu16) { + var t uintptr + _ = t + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == int32(TK_VECTOR) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpRight)).Fop) == int32(TK_VECTOR) || _sqlite3BinaryCompareCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) != _sqlite3BinaryCompareCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) { + **(**Tu32)(__ccgo_up(pExpr + 4)) ^= uint32(EP_Commuted) + } + t = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = t + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) >= int32(TK_GT) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = libc.Uint8FromInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) - int32(TK_GT) ^ int32(2) + int32(TK_GT)) + } + return uint16(0) +} + +// C documentation +// +// /* +// ** Expression pVar is guaranteed to be an SQL variable. pExpr may be any +// ** type of expression. +// ** +// ** If pExpr is a simple SQL value - an integer, real, string, blob +// ** or NULL value - then the VDBE currently being prepared is configured +// ** to re-prepare each time a new value is bound to variable pVar. +// ** +// ** Additionally, if pExpr is a simple SQL value and the value is the +// ** same as that currently bound to variable pVar, non-zero is returned. +// ** Otherwise, if the values are not the same or if pExpr is not a simple +// ** SQL value, zero is returned. +// ** +// ** If the SQLITE_EnableQPSG flag is set on the database connection, then +// ** this routine always returns false. +// */ +func _exprCompareVariable(tls *libc.TLS, pParse uintptr, pVar uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iVar, res, v1 int32 + var pL uintptr + var _ /* pR at bp+0 */ uintptr + _, _, _, _ = iVar, pL, res, v1 + res = int32(2) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_VARIABLE) && int32((*TExpr)(unsafe.Pointer(pVar)).FiColumn) == int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) { + return 0 + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_EnableQPSG) != uint64(0) { + return int32(2) + } + _sqlite3ValueFromExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, uint8(SQLITE_UTF8), uint8(SQLITE_AFF_BLOB), bp) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + iVar = int32((*TExpr)(unsafe.Pointer(pVar)).FiColumn) + _sqlite3VdbeSetVarmask(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, iVar) + pL = _sqlite3VdbeGetBoundValue(tls, (*TParse)(unsafe.Pointer(pParse)).FpReprepare, iVar, uint8(SQLITE_AFF_BLOB)) + if pL != 0 { + if Xsqlite3_value_type(tls, pL) == int32(SQLITE_TEXT) { + Xsqlite3_value_text(tls, pL) /* Make sure the encoding is UTF-8 */ + } + if _sqlite3MemCompare(tls, pL, **(**uintptr)(__ccgo_up(bp)), uintptr(0)) != 0 { + v1 = int32(2) + } else { + v1 = 0 + } + res = v1 + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp))) + _sqlite3ValueFree(tls, pL) + } + return res +} + +// C documentation +// +// /* +// ** Compute the two operands of a binary operator. +// ** +// ** If either operand contains a subquery, then the code strives to +// ** compute the operand containing the subquery second. If the other +// ** operand evalutes to NULL, then a jump is made. The address of the +// ** IsNull operand that does this jump is returned. The caller can use +// ** this to optimize the computation so as to avoid doing the potentially +// ** expensive subquery. +// ** +// ** If no optimization opportunities exist, return 0. +// */ +func _exprComputeOperands(tls *libc.TLS, pParse uintptr, pExpr uintptr, pR1 uintptr, pR2 uintptr, pFree1 uintptr, pFree2 uintptr) (r int32) { + var addrIsNull, r1, r2 int32 + var v uintptr + _, _, _, _ = addrIsNull, r1, r2, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* + ** If the left operand contains a (possibly expensive) subquery and the + ** right operand does not and the right operation might be NULL, + ** then compute the right operand first and do an IsNull jump if the + ** right operand evalutes to NULL. + */ + if _exprEvalRhsFirst(tls, pExpr) != 0 && _sqlite3ExprCanBeNull(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) != 0 { + r2 = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, pFree2) + addrIsNull = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), r2) + } else { + r2 = 0 /* Silence a false-positive uninit-var warning in MSVC */ + addrIsNull = 0 + } + r1 = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, pFree1) + if addrIsNull == 0 { + /* + ** If the right operand contains a subquery and the left operand does not + ** and the left operand might be NULL, then do an IsNull check + ** check on the left operand before computing the right operand. + */ + if (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) && _sqlite3ExprCanBeNull(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) != 0 { + addrIsNull = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), r1) + } + r2 = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, pFree2) + } + **(**int32)(__ccgo_up(pR1)) = r1 + **(**int32)(__ccgo_up(pR2)) = r2 + return addrIsNull +} + +// C documentation +// +// /* +// ** Return true if it might be advantageous to compute the right operand +// ** of expression pExpr first, before the left operand. +// ** +// ** Normally the left operand is computed before the right operand. But if +// ** the left operand contains a subquery and the right does not, then it +// ** might be more efficient to compute the right operand first. +// */ +func _exprEvalRhsFirst(tls *libc.TLS, pExpr uintptr) (r int32) { + if (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) && !((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != libc.Uint32FromInt32(0)) { + return int32(1) + } else { + return 0 + } + return r +} + +// C documentation +// +// /* +// ** Helper function for exprIsDeterministic(). +// */ +func _exprNodeIsDeterministic(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_FUNCTION) && libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_ConstFunc)) != uint32(0)) == 0 { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** The database opened by the first argument is an auto-vacuum database +// ** nOrig pages in size containing nFree free pages. Return the expected +// ** size of the database in pages following an auto-vacuum operation. +// */ +func _finalDbSize(tls *libc.TLS, pBt uintptr, nOrig TPgno, nFree TPgno) (r TPgno) { + var nEntry int32 + var nFin, nPtrmap TPgno + _, _, _ = nEntry, nFin, nPtrmap /* Return value */ + nEntry = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FusableSize / uint32(5)) + nPtrmap = (nFree - nOrig + _ptrmapPageno(tls, pBt, nOrig) + libc.Uint32FromInt32(nEntry)) / libc.Uint32FromInt32(nEntry) + nFin = nOrig - nFree - nPtrmap + if nOrig > libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) && nFin < libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + nFin = nFin - 1 + } + for _ptrmapPageno(tls, pBt, nFin) == nFin || nFin == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + nFin = nFin - 1 + } + return nFin +} + +// C documentation +// +// /* +// ** Find all terms of COLUMN=VALUE or VALUE=COLUMN in pExpr where VALUE +// ** is a constant expression and where the term must be true because it +// ** is part of the AND-connected terms of the expression. For each term +// ** found, add it to the pConst structure. +// */ +func _findConstInWhere(tls *libc.TLS, pConst uintptr, pExpr uintptr) { + var pLeft, pRight uintptr + _, _ = pLeft, pRight + if pExpr == uintptr(0) { + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&(*TWhereConst)(unsafe.Pointer(pConst)).FmExcludeOn != uint32(0) { + return + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AND) { + _findConstInWhere(tls, pConst, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + _findConstInWhere(tls, pConst, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + return + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_EQ) { + return + } + pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) == int32(TK_COLUMN) && _sqlite3ExprIsConstant(tls, (*TWhereConst)(unsafe.Pointer(pConst)).FpParse, pLeft) != 0 { + _constInsert(tls, pConst, pRight, pLeft, pExpr) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft)).Fop) == int32(TK_COLUMN) && _sqlite3ExprIsConstant(tls, (*TWhereConst)(unsafe.Pointer(pConst)).FpParse, pRight) != 0 { + _constInsert(tls, pConst, pLeft, pRight, pExpr) + } +} + +// C documentation +// +// /* +// ** This routine runs after codeDistinct(). It makes necessary +// ** adjustments to the OP_OpenEphemeral opcode that the codeDistinct() +// ** routine made use of. This processing must be done separately since +// ** sometimes codeDistinct is called before the OP_OpenEphemeral is actually +// ** laid down. +// ** +// ** WHERE_DISTINCT_NOOP: +// ** WHERE_DISTINCT_UNORDERED: +// ** +// ** No adjustments necessary. This function is a no-op. +// ** +// ** WHERE_DISTINCT_UNIQUE: +// ** +// ** The ephemeral table is not needed. So change the +// ** OP_OpenEphemeral opcode into an OP_Noop. +// ** +// ** WHERE_DISTINCT_ORDERED: +// ** +// ** The ephemeral table is not needed. But we do need register +// ** iVal to be initialized to NULL. So change the OP_OpenEphemeral +// ** into an OP_Null on the iVal register. +// */ +func _fixDistinctOpenEph(tls *libc.TLS, pParse uintptr, eTnctType int32, iVal int32, iOpenEphAddr int32) { + var pOp, v uintptr + _, _ = pOp, v + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && (eTnctType == int32(WHERE_DISTINCT_UNIQUE) || eTnctType == int32(WHERE_DISTINCT_ORDERED)) { + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + _sqlite3VdbeChangeToNoop(tls, v, iOpenEphAddr) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, v, iOpenEphAddr+int32(1)))).Fopcode) == int32(OP_Explain) { + _sqlite3VdbeChangeToNoop(tls, v, iOpenEphAddr+int32(1)) + } + if eTnctType == int32(WHERE_DISTINCT_ORDERED) { + /* Change the OP_OpenEphemeral to an OP_Null that sets the MEM_Cleared + ** bit on the first register of the previous value. This will cause the + ** OP_Ne added in codeDistinct() to always fail on the first iteration of + ** the loop even if the first row is all NULLs. */ + pOp = _sqlite3VdbeGetOp(tls, v, iOpenEphAddr) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_Null) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp1 = int32(1) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2 = iVal + } + } +} + +// C documentation +// +// /* +// ** This function is called when a row is inserted into or deleted from the +// ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed +// ** on the child table of pFKey, this function is invoked twice for each row +// ** affected - once to "delete" the old row, and then again to "insert" the +// ** new row. +// ** +// ** Each time it is called, this function generates VDBE code to locate the +// ** row in the parent table that corresponds to the row being inserted into +// ** or deleted from the child table. If the parent row can be found, no +// ** special action is taken. Otherwise, if the parent row can *not* be +// ** found in the parent table: +// ** +// ** Operation | FK type | Action taken +// ** -------------------------------------------------------------------------- +// ** INSERT immediate Increment the "immediate constraint counter". +// ** +// ** DELETE immediate Decrement the "immediate constraint counter". +// ** +// ** INSERT deferred Increment the "deferred constraint counter". +// ** +// ** DELETE deferred Decrement the "deferred constraint counter". +// ** +// ** These operations are identified in the comment at the top of this file +// ** (fkey.c) as "I.1" and "D.1". +// */ +func _fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx uintptr, pFKey uintptr, aiCol uintptr, regData int32, nIncr int32, isIgnore int32) { + var i, iChild, iCur, iJump, iMustBeInt, iOk, iParent, iReg, nCol, regTemp, regTemp1 int32 + var v uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = i, iChild, iCur, iJump, iMustBeInt, iOk, iParent, iReg, nCol, regTemp, regTemp1, v /* Iterator variable */ + v = _sqlite3GetVdbe(tls, pParse) /* Vdbe to add code to */ + iCur = (*TParse)(unsafe.Pointer(pParse)).FnTab - int32(1) /* Cursor number to use */ + iOk = _sqlite3VdbeMakeLabel(tls, pParse) /* jump here if parent key found */ + /* If nIncr is less than zero, then check at runtime if there are any + ** outstanding constraints to resolve. If there are not, there is no need + ** to check if deleting this row resolves any outstanding violations. + ** + ** Check if any of the key columns in the child table row are NULL. If + ** any are, then the constraint is considered satisfied. No need to + ** search for a matching row in the parent table. */ + if nIncr < 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_FkIfZero), libc.Int32FromUint8((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred), iOk) + } + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + iReg = int32(_sqlite3TableColumnToStorage(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, int16(**(**int32)(__ccgo_up(aiCol + uintptr(i)*4))))) + regData + int32(1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), iReg, iOk) + goto _1 + _1: + ; + i = i + 1 + } + if isIgnore == 0 { + if pIdx == uintptr(0) { /* Address of MustBeInt instruction */ + regTemp = _sqlite3GetTempReg(tls, pParse) + /* Invoke MustBeInt to coerce the child key value to an integer (i.e. + ** apply the affinity of the parent key). If this fails, then there + ** is no matching parent key. Before using MustBeInt, make a copy of + ** the value. Otherwise, the value inserted into the child key column + ** will have INTEGER affinity applied to it, which may not be correct. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), int32(_sqlite3TableColumnToStorage(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, int16(**(**int32)(__ccgo_up(aiCol)))))+int32(1)+regData, regTemp) + iMustBeInt = _sqlite3VdbeAddOp2(tls, v, int32(OP_MustBeInt), regTemp, 0) + /* If the parent table is the same as the child table, and we are about + ** to increment the constraint-counter (i.e. this is an INSERT operation), + ** then check if the row being inserted matches itself. If so, do not + ** increment the constraint-counter. */ + if pTab == (*TFKey)(unsafe.Pointer(pFKey)).FpFrom && nIncr == int32(1) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), regData, iOk, regTemp) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL)) + } + _sqlite3OpenTable(tls, pParse, iCur, iDb, pTab, int32(OP_OpenRead)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_NotExists), iCur, 0, regTemp) + _sqlite3VdbeGoto(tls, v, iOk) + _sqlite3VdbeJumpHere(tls, v, _sqlite3VdbeCurrentAddr(tls, v)-int32(2)) + _sqlite3VdbeJumpHere(tls, v, iMustBeInt) + _sqlite3ReleaseTempReg(tls, pParse, regTemp) + } else { + nCol = (*TFKey)(unsafe.Pointer(pFKey)).FnCol + regTemp1 = _sqlite3GetTempRange(tls, pParse, nCol) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), iCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) + i = 0 + for { + if !(i < nCol) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), int32(_sqlite3TableColumnToStorage(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, int16(**(**int32)(__ccgo_up(aiCol + uintptr(i)*4)))))+int32(1)+regData, regTemp1+i) + goto _2 + _2: + ; + i = i + 1 + } + /* If the parent table is the same as the child table, and we are about + ** to increment the constraint-counter (i.e. this is an INSERT operation), + ** then check if the row being inserted matches itself. If so, do not + ** increment the constraint-counter. + ** + ** If any of the parent-key values are NULL, then the row cannot match + ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any + ** of the parent-key values are NULL (at this point it is known that + ** none of the child key values are). + */ + if pTab == (*TFKey)(unsafe.Pointer(pFKey)).FpFrom && nIncr == int32(1) { + iJump = _sqlite3VdbeCurrentAddr(tls, v) + nCol + int32(1) + i = 0 + for { + if !(i < nCol) { + break + } + iChild = int32(_sqlite3TableColumnToStorage(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, int16(**(**int32)(__ccgo_up(aiCol + uintptr(i)*4))))) + int32(1) + regData + iParent = int32(1) + regData + iParent = iParent + int32(_sqlite3TableColumnToStorage(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpTable, **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)))) + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + /* The parent key is a composite key that includes the IPK column */ + iParent = regData + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ne), iChild, iJump, iParent) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_JUMPIFNULL)) + goto _3 + _3: + ; + i = i + 1 + } + _sqlite3VdbeGoto(tls, v, iOk) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), regTemp1, nCol, 0, _sqlite3IndexAffinityStr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pIdx), nCol) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iCur, iOk, regTemp1, nCol) + _sqlite3ReleaseTempRange(tls, pParse, regTemp1, nCol) + } + } + if !((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred != 0) && !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&libc.Uint64FromInt32(SQLITE_DeferFKs) != 0) && !((*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0) && !((*TParse)(unsafe.Pointer(pParse)).FisMultiWrite != 0) { + /* Special case: If this is an INSERT statement that will insert exactly + ** one row into the table, raise a constraint immediately instead of + ** incrementing a counter. This is necessary as the VM code is being + ** generated for will not open a statement transaction. */ + _sqlite3HaltConstraint(tls, pParse, libc.Int32FromInt32(SQLITE_CONSTRAINT)|libc.Int32FromInt32(3)< 0 && libc.Int32FromUint8((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred) == 0 { + _sqlite3MayAbort(tls, pParse) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_FkCounter), libc.Int32FromUint8((*TFKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) + } + _sqlite3VdbeResolveLabel(tls, v, iOk) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iCur) +} + +func _fts5ApiPhraseNextColumn(tls *libc.TLS, pCtx uintptr, pIter uintptr, piCol uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pConfig, pCsr uintptr + var _ /* dummy at bp+4 */ int32 + var _ /* iIncr at bp+0 */ int32 + _, _ = pConfig, pCsr + pCsr = pCtx + pConfig = (*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == int32(FTS5_DETAIL_COLUMNS) { + if (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fb { + **(**int32)(__ccgo_up(piCol)) = -int32(1) + } else { + **(**uintptr)(__ccgo_up(pIter)) += uintptr(_sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp)) + **(**int32)(__ccgo_up(piCol)) += **(**int32)(__ccgo_up(bp)) - int32(2) + } + } else { + for int32(1) != 0 { + if (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fb { + **(**int32)(__ccgo_up(piCol)) = -int32(1) + return + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa))) == int32(0x01) { + break + } + **(**uintptr)(__ccgo_up(pIter)) += uintptr(_sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp+4)) + } + **(**uintptr)(__ccgo_up(pIter)) += uintptr(int32(1) + _sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa+1, piCol)) + } +} + +func _fts5DlidxExtractFirstRowid(tls *libc.TLS, pBuf uintptr) (r Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iOff int32 + var _ /* iRowid at bp+0 */ Ti64 + _ = iOff + iOff = int32(1) + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+1, bp)) + _sqlite3Fts5GetVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr(iOff), bp) + return **(**Ti64)(__ccgo_up(bp)) +} + +func _fts5ExprSynonymAdvanceto(tls *libc.TLS, pTerm uintptr, bDesc int32, piLast uintptr, pRc uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iLast, iRowid Ti64 + var p uintptr + var rc int32 + var _ /* bEof at bp+0 */ int32 + _, _, _, _ = iLast, iRowid, p, rc + rc = SQLITE_OK + iLast = **(**Ti64)(__ccgo_up(piLast)) + **(**int32)(__ccgo_up(bp)) = 0 + p = pTerm + for { + if !(rc == SQLITE_OK && p != 0) { + break + } + if libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) == 0 { + iRowid = (*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FiRowid + if bDesc == 0 && iLast > iRowid || bDesc != 0 && iLast < iRowid { + rc = _sqlite3Fts5IterNextFrom(tls, (*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter, iLast) + } + } + goto _1 + _1: + ; + p = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpSynonym + } + if rc != SQLITE_OK { + **(**int32)(__ccgo_up(pRc)) = rc + **(**int32)(__ccgo_up(bp)) = int32(1) + } else { + **(**Ti64)(__ccgo_up(piLast)) = _fts5ExprSynonymRowid(tls, pTerm, bDesc, bp) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Argument pTerm must be a synonym iterator. Return the current rowid +// ** that it points to. +// */ +func _fts5ExprSynonymRowid(tls *libc.TLS, pTerm uintptr, bDesc int32, pbEof uintptr) (r Ti64) { + var bRetValid int32 + var iRet, iRowid Ti64 + var p uintptr + _, _, _, _ = bRetValid, iRet, iRowid, p + iRet = 0 + bRetValid = 0 + p = pTerm + for { + if !(p != 0) { + break + } + if 0 == libc.Int32FromUint8((*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) { + iRowid = (*TFts5IndexIter)(unsafe.Pointer((*TFts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FiRowid + if bRetValid == 0 || bDesc != libc.BoolInt32(iRowid < iRet) { + iRet = iRowid + bRetValid = int32(1) + } + } + goto _1 + _1: + ; + p = (*TFts5ExprTerm)(unsafe.Pointer(p)).FpSynonym + } + if pbEof != 0 && bRetValid == 0 { + **(**int32)(__ccgo_up(pbEof)) = int32(1) + } + return iRet +} + +// C documentation +// +// /* +// ** Argument p points to a buffer containing a varint to be interpreted as a +// ** position list size field. Read the varint and return the number of bytes +// ** read. Before returning, set *pnSz to the number of bytes in the position +// ** list, and *pbDel to true if the delete flag is set, or false otherwise. +// */ +func _fts5GetPoslistSize(tls *libc.TLS, p uintptr, pnSz uintptr, pbDel uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var n, v1 int32 + var _ /* nSz at bp+0 */ int32 + _, _ = n, v1 + n = 0 + v1 = n + n = n + 1 + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(p + uintptr(v1)))) + if **(**int32)(__ccgo_up(bp))&int32(0x80) != 0 { + n = n - 1 + n = n + _sqlite3Fts5GetVarint32(tls, p+uintptr(n), bp) + } + **(**int32)(__ccgo_up(pnSz)) = **(**int32)(__ccgo_up(bp)) / int32(2) + **(**int32)(__ccgo_up(pbDel)) = **(**int32)(__ccgo_up(bp)) & int32(0x0001) + return n +} + +func _fts5GetU16(tls *libc.TLS, aIn uintptr) (r Tu16) { + return libc.Uint16FromInt32(libc.Int32FromUint16(uint16(**(**Tu8)(__ccgo_up(aIn))))<= 0) { + break + } + h = h<= 0) { + break + } + h = h<= (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn) || i >= iNoRowid && 0 != libc.Int32FromUint16(_fts5GetU16(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp)) { + _fts5IndexCorruptRowid(tls, p, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))< int32(16) { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pPg)).Fp))) == int32(4) { + v3 = int32(4) + } else { + v3 = int32(8) + } + v2 = ((*TFts5Data)(unsafe.Pointer(pPg)).Fnn - int32(8)) / v3 + } else { + v2 = int32(1) + } + nSlot = v2 + nElem = libc.Int32FromUint32(_fts5GetU32(tls, (*TFts5Data)(unsafe.Pointer(pPg)).Fp+4)) + iSlot = libc.Int32FromUint64(iRowid / libc.Uint64FromInt32(nPg) % libc.Uint64FromInt32(nSlot)) + nCollide = nSlot + if szKey == int32(4) && iRowid > uint64(0xFFFFFFFF) { + return int32(2) + } + if iRowid == uint64(0) { + **(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pPg)).Fp + 1)) = uint8(0x01) + return 0 + } + if bForce == 0 && nElem >= nSlot/int32(2) { + return int32(1) + } + _fts5PutU32(tls, (*TFts5Data)(unsafe.Pointer(pPg)).Fp+4, libc.Uint32FromInt32(nElem+int32(1))) + if szKey == int32(4) { + aSlot = (*TFts5Data)(unsafe.Pointer(pPg)).Fp + 8 + for **(**Tu32)(__ccgo_up(aSlot + uintptr(iSlot)*4)) != 0 { + iSlot = (iSlot + int32(1)) % nSlot + v1 = nCollide + nCollide = nCollide - 1 + if v1 == 0 { + return 0 + } + } + _fts5PutU32(tls, aSlot+uintptr(iSlot)*4, uint32(iRowid)) + } else { + aSlot1 = (*TFts5Data)(unsafe.Pointer(pPg)).Fp + 8 + for **(**Tu64)(__ccgo_up(aSlot1 + uintptr(iSlot)*8)) != 0 { + iSlot = (iSlot + int32(1)) % nSlot + v1 = nCollide + nCollide = nCollide - 1 + if v1 == 0 { + return 0 + } + } + _fts5PutU64(tls, aSlot1+uintptr(iSlot)*8, iRowid) + } + return 0 +} + +// C documentation +// +// /* +// ** Query a single tombstone hash table for rowid iRowid. Return true if +// ** it is found or false otherwise. The tombstone hash table is one of +// ** nHashTable tables. +// */ +func _fts5IndexTombstoneQuery(tls *libc.TLS, pHash uintptr, nHashTable int32, iRowid Tu64) (r int32) { + var aSlot, aSlot1 uintptr + var iSlot, nCollide, nSlot, szKey, v1, v2, v3 int32 + _, _, _, _, _, _, _, _, _ = aSlot, aSlot1, iSlot, nCollide, nSlot, szKey, v1, v2, v3 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pHash)).Fp))) == int32(4) { + v1 = int32(4) + } else { + v1 = int32(8) + } + szKey = v1 + if (*TFts5Data)(unsafe.Pointer(pHash)).Fnn > int32(16) { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pHash)).Fp))) == int32(4) { + v3 = int32(4) + } else { + v3 = int32(8) + } + v2 = ((*TFts5Data)(unsafe.Pointer(pHash)).Fnn - int32(8)) / v3 + } else { + v2 = int32(1) + } + nSlot = v2 + iSlot = libc.Int32FromUint64(iRowid / libc.Uint64FromInt32(nHashTable) % libc.Uint64FromInt32(nSlot)) + nCollide = nSlot + if iRowid == uint64(0) { + return libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer(pHash)).Fp + 1))) + } else { + if szKey == int32(4) { + aSlot = (*TFts5Data)(unsafe.Pointer(pHash)).Fp + 8 + for **(**Tu32)(__ccgo_up(aSlot + uintptr(iSlot)*4)) != 0 { + if uint64(_fts5GetU32(tls, aSlot+uintptr(iSlot)*4)) == iRowid { + return int32(1) + } + v1 = nCollide + nCollide = nCollide - 1 + if v1 == 0 { + break + } + iSlot = (iSlot + int32(1)) % nSlot + } + } else { + aSlot1 = (*TFts5Data)(unsafe.Pointer(pHash)).Fp + 8 + for **(**Tu64)(__ccgo_up(aSlot1 + uintptr(iSlot)*8)) != 0 { + if _fts5GetU64(tls, aSlot1+uintptr(iSlot)*8) == iRowid { + return int32(1) + } + v1 = nCollide + nCollide = nCollide - 1 + if v1 == 0 { + break + } + iSlot = (iSlot + int32(1)) % nSlot + } + } + } + return 0 +} + +func _fts5NextRowid(tls *libc.TLS, pBuf uintptr, piOff uintptr, piRowid uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i int32 + var v1 uintptr + var _ /* iVal at bp+0 */ Tu64 + _, _ = i, v1 + i = **(**int32)(__ccgo_up(piOff)) + if i >= (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn { + **(**int32)(__ccgo_up(piOff)) = -int32(1) + } else { + **(**int32)(__ccgo_up(piOff)) = i + libc.Int32FromUint8(_sqlite3Fts5GetVarint(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr(i), bp)) + v1 = piRowid + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + **(**Tu64)(__ccgo_up(bp))) + } +} + +func _fts5ParseAlloc(tls *libc.TLS, t Tu64) (r uintptr) { + return Xsqlite3_malloc64(tls, libc.Uint64FromInt64(libc.Int64FromUint64(t))) +} + +// C documentation +// +// /* +// ** Return the size of the prefix, in bytes, that buffer +// ** (pNew/) shares with buffer (pOld/nOld). +// ** +// ** Buffer (pNew/) is guaranteed to be greater +// ** than buffer (pOld/nOld). +// */ +func _fts5PrefixCompress(tls *libc.TLS, nOld int32, pOld uintptr, pNew uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < nOld) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pOld + uintptr(i)))) != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pNew + uintptr(i)))) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + return i +} + +func _fts5PutU16(tls *libc.TLS, aOut uintptr, iVal Tu16) { + **(**Tu8)(__ccgo_up(aOut)) = libc.Uint8FromInt32(libc.Int32FromUint16(iVal) >> libc.Int32FromInt32(8)) + **(**Tu8)(__ccgo_up(aOut + 1)) = libc.Uint8FromInt32(libc.Int32FromUint16(iVal) & libc.Int32FromInt32(0xFF)) +} + +// C documentation +// +// /* +// ** Fts5SegIter.iLeafOffset currently points to the first byte of a +// ** position-list size field. Read the value of the field and store it +// ** in the following variables: +// ** +// ** Fts5SegIter.nPos +// ** Fts5SegIter.bDel +// ** +// ** Leave Fts5SegIter.iLeafOffset pointing to the first byte of the +// ** position list content (if any). +// */ +func _fts5SegIterLoadNPos(tls *libc.TLS, p uintptr, pIter uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iEod, iOff, v1 int32 + var _ /* nSz at bp+0 */ int32 + _, _, _ = iEod, iOff, v1 + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + iOff = int32((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset) /* Offset to read at */ + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == int32(FTS5_DETAIL_NONE) { + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist < (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf { + v1 = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist + } else { + v1 = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + } + iEod = v1 + (*TFts5SegIter)(unsafe.Pointer(pIter)).FbDel = uint8(0) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FnPos = int32(1) + if iOff < iEod && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr(iOff)))) == 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FbDel = uint8(1) + iOff = iOff + 1 + if iOff < iEod && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr(iOff)))) == 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FnPos = int32(1) + iOff = iOff + 1 + } else { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FnPos = 0 + } + } + } else { + v1 = iOff + iOff = iOff + 1 + **(**int32)(__ccgo_up(bp)) = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr(v1)))) + if **(**int32)(__ccgo_up(bp))&int32(0x80) != 0 { + iOff = iOff - 1 + iOff = iOff + _sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr(iOff), bp) + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FbDel = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp)) & libc.Int32FromInt32(0x0001)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FnPos = **(**int32)(__ccgo_up(bp)) >> int32(1) + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(iOff) + } +} + +func _fts5UsePatternMatch(tls *libc.TLS, pConfig uintptr, p uintptr) (r int32) { + if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FePattern == int32(FTS5_PATTERN_GLOB) && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(FTS5_PATTERN_GLOB) { + return int32(1) + } + if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FePattern == int32(FTS5_PATTERN_LIKE) && (libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(FTS5_PATTERN_LIKE) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(FTS5_PATTERN_GLOB)) { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Implementation of the xBestIndex method. +// ** +// ** Only constraints of the form: +// ** +// ** term <= ? +// ** term == ? +// ** term >= ? +// ** +// ** are interpreted. Less-than and less-than-or-equal are treated +// ** identically, as are greater-than and greater-than-or-equal. +// */ +func _fts5VocabBestIndexMethod(tls *libc.TLS, pUnused uintptr, pInfo uintptr) (r int32) { + var i, iTermEq, iTermGe, iTermLe, idxNum, nArg, v2 int32 + var p uintptr + _, _, _, _, _, _, _, _ = i, iTermEq, iTermGe, iTermLe, idxNum, nArg, p, v2 + iTermEq = -int32(1) + iTermGe = -int32(1) + iTermLe = -int32(1) + idxNum = libc.Int32FromUint64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FcolUsed) + nArg = 0 + _ = pUnused + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12 + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0 { + goto _1 + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0 { /* term column */ + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) { + iTermEq = i + } + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_LE) { + iTermLe = i + } + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_LT) { + iTermLe = i + } + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_GE) { + iTermGe = i + } + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_GT) { + iTermGe = i + } + } + goto _1 + _1: + ; + i = i + 1 + } + if iTermEq >= 0 { + idxNum = idxNum | int32(FTS5_VOCAB_TERM_EQ) + nArg = nArg + 1 + v2 = nArg + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermEq)*8))).FargvIndex = v2 + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = libc.Float64FromInt32(100) + } else { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = libc.Float64FromInt32(1000000) + if iTermGe >= 0 { + idxNum = idxNum | int32(FTS5_VOCAB_TERM_GE) + nArg = nArg + 1 + v2 = nArg + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermGe)*8))).FargvIndex = v2 + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / libc.Float64FromInt32(2) + } + if iTermLe >= 0 { + idxNum = idxNum | int32(FTS5_VOCAB_TERM_LE) + nArg = nArg + 1 + v2 = nArg + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermLe)*8))).FargvIndex = v2 + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / libc.Float64FromInt32(2) + } + } + /* This virtual table always delivers results in ascending order of + ** the "term" column (column 0). So if the user has requested this + ** specifically - "ORDER BY term" or "ORDER BY term ASC" - set the + ** sqlite3_index_info.orderByConsumed flag to tell the core the results + ** are already in sorted order. */ + if (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == int32(1) && (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).FiColumn == 0 && libc.Int32FromUint8((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).Fdesc) == 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = int32(1) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxNum + return SQLITE_OK +} + +// C documentation +// +// /* The following function deletes the "minor type" or semantic value +// ** associated with a symbol. The symbol can be either a terminal +// ** or nonterminal. "fts5yymajor" is the symbol code, and "fts5yypminor" is +// ** a pointer to the value to be deleted. The code used to do the +// ** deletions is derived from the %destructor and/or %token_destructor +// ** directives of the input grammar. +// */ +func _fts5yy_destructor(tls *libc.TLS, fts5yypParser uintptr, fts5yymajor uint8, fts5yypminor uintptr) { + var pParse uintptr + _ = pParse + pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse + switch libc.Int32FromUint8(fts5yymajor) { + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are *not* used + ** inside the C code. + */ + /********* Begin destructor definitions ***************************************/ + case int32(16): /* input */ + _ = pParse + case int32(17): /* expr */ + fallthrough + case int32(18): /* cnearset */ + fallthrough + case int32(19): /* exprlist */ + _sqlite3Fts5ParseNodeFree(tls, *(*uintptr)(unsafe.Pointer(fts5yypminor))) + case int32(20): /* colset */ + fallthrough + case int32(21): /* colsetlist */ + Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(fts5yypminor))) + case int32(22): /* nearset */ + fallthrough + case int32(23): /* nearphrases */ + _sqlite3Fts5ParseNearsetFree(tls, *(*uintptr)(unsafe.Pointer(fts5yypminor))) + case int32(24): /* phrase */ + _sqlite3Fts5ParsePhraseFree(tls, *(*uintptr)(unsafe.Pointer(fts5yypminor))) + break + /********* End destructor definitions *****************************************/ + fallthrough + default: + break /* If no destructor action specified: do nothing */ + } +} + +// C documentation +// +// /* +// ** Find the appropriate action for a parser given the non-terminal +// ** look-ahead token iLookAhead. +// */ +func _fts5yy_find_reduce_action(tls *libc.TLS, stateno uint8, iLookAhead uint8) (r uint8) { + var i int32 + _ = i + i = int32(_fts5yy_reduce_ofst[stateno]) + i = i + libc.Int32FromUint8(iLookAhead) + return _fts5yy_action[i] +} + +// C documentation +// +// /* +// ** Find the appropriate action for a parser given the terminal +// ** look-ahead token iLookAhead. +// */ +func _fts5yy_find_shift_action(tls *libc.TLS, iLookAhead uint8, stateno uint8) (r uint8) { + var i int32 + _ = i + if libc.Int32FromUint8(stateno) > int32(fts5YY_MAX_SHIFT) { + return stateno + } + for cond := true; cond; cond = int32(1) != 0 { + i = libc.Int32FromUint8(_fts5yy_shift_ofst[stateno]) + i = i + libc.Int32FromUint8(iLookAhead) + if libc.Int32FromUint8(_fts5yy_lookahead[i]) != libc.Int32FromUint8(iLookAhead) { + return _fts5yy_default[stateno] + } else { + return _fts5yy_action[i] + } + } + return r +} + +// C documentation +// +// /* +// ** Insert all segments and events for polygon pPoly. +// */ +func _geopolyAddSegments(tls *libc.TLS, p uintptr, pPoly uintptr, side uint8) { + var i uint32 + var x uintptr + _, _ = i, x + i = uint32(0) + for { + if !(i < libc.Uint32FromInt32((*TGeoPoly)(unsafe.Pointer(pPoly)).FnVertex)-uint32(1)) { + break + } + x = pPoly + 8 + uintptr(i*uint32(2))*4 + _geopolyAddOneSegment(tls, p, **(**TGeoCoord)(__ccgo_up(x)), **(**TGeoCoord)(__ccgo_up(x + 1*4)), **(**TGeoCoord)(__ccgo_up(x + 2*4)), **(**TGeoCoord)(__ccgo_up(x + 3*4)), side, i) + goto _1 + _1: + ; + i = i + 1 + } + x = pPoly + 8 + uintptr(i*uint32(2))*4 + _geopolyAddOneSegment(tls, p, **(**TGeoCoord)(__ccgo_up(x)), **(**TGeoCoord)(__ccgo_up(x + 1*4)), **(**TGeoCoord)(__ccgo_up(pPoly + 8)), **(**TGeoCoord)(__ccgo_up(pPoly + 8 + 1*4)), side, i) +} + +// C documentation +// +// /* +// ** Get a page from the pager and initialize it. +// */ +func _getAndInitPage(tls *libc.TLS, pBt uintptr, pgno TPgno, ppPage uintptr, bReadOnly int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pPage uintptr + var rc int32 + var _ /* pDbPage at bp+0 */ uintptr + _, _ = pPage, rc + if pgno > _btreePagecount(tls, pBt) { + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return _sqlite3CorruptError(tls, int32(75529)) + } + rc = _sqlite3PagerGet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pgno, bp, bReadOnly) + if rc != 0 { + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return rc + } + pPage = _sqlite3PagerGetExtra(tls, **(**uintptr)(__ccgo_up(bp))) + if libc.Int32FromUint8((*TMemPage)(unsafe.Pointer(pPage)).FisInit) == 0 { + _btreePageFromDbPage(tls, **(**uintptr)(__ccgo_up(bp)), pgno, pBt) + rc = _btreeInitPage(tls, pPage) + if rc != SQLITE_OK { + _releasePage(tls, pPage) + **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) + return rc + } + } + **(**uintptr)(__ccgo_up(ppPage)) = pPage + return SQLITE_OK +} + +// C documentation +// +// /* +// ** For a single cell on a btree page, compute the number of bytes of +// ** content (payload) stored on that page. That is to say, compute the +// ** number of bytes of content not found on overflow pages. +// */ +func _getLocalPayload(tls *libc.TLS, nUsable int32, flags Tu8, nTotal int32) (r int32) { + var nLocal, nMaxLocal, nMinLocal int32 + _, _, _ = nLocal, nMaxLocal, nMinLocal + if libc.Int32FromUint8(flags) == int32(0x0D) { /* Table leaf node */ + nMinLocal = (nUsable-int32(12))*int32(32)/int32(255) - int32(23) + nMaxLocal = nUsable - int32(35) + } else { /* Index interior and leaf nodes */ + nMinLocal = (nUsable-int32(12))*int32(32)/int32(255) - int32(23) + nMaxLocal = (nUsable-int32(12))*int32(64)/int32(255) - int32(23) + } + nLocal = nMinLocal + (nTotal-nMinLocal)%(nUsable-int32(4)) + if nLocal > nMaxLocal { + nLocal = nMinLocal + } + return nLocal +} + +// C documentation +// +// /* +// ** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that +// ** corresponds to page iPg is already set. +// */ +func _getPageReferenced(tls *libc.TLS, pCheck uintptr, iPg TPgno) (r int32) { + return libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIntegrityCk)(unsafe.Pointer(pCheck)).FaPgRef + uintptr(iPg/uint32(8))))) & (int32(1) << (iPg & uint32(0x07))) +} + +// C documentation +// +// /* +// ** This function is called after transitioning from PAGER_UNLOCK to +// ** PAGER_SHARED state. It tests if there is a hot journal present in +// ** the file-system for the given pager. A hot journal is one that +// ** needs to be played back. According to this function, a hot-journal +// ** file exists if the following criteria are met: +// ** +// ** * The journal file exists in the file system, and +// ** * No process holds a RESERVED or greater lock on the database file, and +// ** * The database file itself is greater than 0 bytes in size, and +// ** * The first byte of the journal file exists and is not 0x00. +// ** +// ** If the current size of the database file is 0 but a journal file +// ** exists, that is probably an old journal left over from a prior +// ** database with the same name. In this case the journal file is +// ** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK +// ** is returned. +// ** +// ** This routine does not check if there is a super-journal filename +// ** at the end of the file. If there is, and that super-journal file +// ** does not exist, then the journal file is not really hot. In this +// ** case this routine will return a false-positive. The pager_playback() +// ** routine will discover that the journal file is not really hot and +// ** will not roll it back. +// ** +// ** If a hot-journal file is found to exist, *pExists is set to 1 and +// ** SQLITE_OK returned. If no hot-journal file is present, *pExists is +// ** set to 0 and SQLITE_OK returned. If an IO error occurs while trying +// ** to determine whether or not a hot-journal file exists, the IO error +// ** code is returned and the value of *pExists is undefined. +// */ +func _hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var jrnlOpen, rc int32 + var pVfs uintptr + var _ /* exists at bp+0 */ int32 + var _ /* f at bp+12 */ int32 + var _ /* first at bp+16 */ Tu8 + var _ /* locked at bp+4 */ int32 + var _ /* nPage at bp+8 */ TPgno + _, _, _ = jrnlOpen, pVfs, rc + pVfs = (*TPager)(unsafe.Pointer(pPager)).FpVfs + rc = SQLITE_OK /* Return code */ + **(**int32)(__ccgo_up(bp)) = int32(1) /* True if a journal file is present */ + jrnlOpen = libc.BoolInt32(!!((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != libc.UintptrFromInt32(0))) + **(**int32)(__ccgo_up(pExists)) = 0 + if !(jrnlOpen != 0) { + rc = _sqlite3OsAccess(tls, pVfs, (*TPager)(unsafe.Pointer(pPager)).FzJournal, SQLITE_ACCESS_EXISTS, bp) + } + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp)) != 0 { + **(**int32)(__ccgo_up(bp + 4)) = 0 /* True if some process holds a RESERVED lock */ + /* Race condition here: Another process might have been holding the + ** the RESERVED lock and have a journal open at the sqlite3OsAccess() + ** call above, but then delete the journal and drop the lock before + ** we get to the following sqlite3OsCheckReservedLock() call. If that + ** is the case, this routine might think there is a hot journal when + ** in fact there is none. This results in a false-positive which will + ** be dealt with by the playback routine. Ticket #3883. + */ + rc = _sqlite3OsCheckReservedLock(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, bp+4) + if rc == SQLITE_OK && !(**(**int32)(__ccgo_up(bp + 4)) != 0) { /* Number of pages in database file */ + rc = _pagerPagecount(tls, pPager, bp+8) + if rc == SQLITE_OK { + /* If the database is zero pages in size, that means that either (1) the + ** journal is a remnant from a prior database with the same name where + ** the database file but not the journal was deleted, or (2) the initial + ** transaction that populates a new database is being rolled back. + ** In either case, the journal file can be deleted. However, take care + ** not to delete the journal file if it is already open due to + ** journal_mode=PERSIST. + */ + if **(**TPgno)(__ccgo_up(bp + 8)) == uint32(0) && !(jrnlOpen != 0) { + _sqlite3BeginBenignMalloc(tls) + if _pagerLockDb(tls, pPager, int32(RESERVED_LOCK)) == SQLITE_OK { + _sqlite3OsDelete(tls, pVfs, (*TPager)(unsafe.Pointer(pPager)).FzJournal, 0) + if !((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) { + _pagerUnlockDb(tls, pPager, int32(SHARED_LOCK)) + } + } + _sqlite3EndBenignMalloc(tls) + } else { + /* The journal file exists and no other connection has a reserved + ** or greater lock on the database file. Now check that there is + ** at least one non-zero bytes at the start of the journal file. + ** If there is, then we consider this journal to be hot. If not, + ** it can be ignored. + */ + if !(jrnlOpen != 0) { + **(**int32)(__ccgo_up(bp + 12)) = libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_MAIN_JOURNAL) + rc = _sqlite3OsOpen(tls, pVfs, (*TPager)(unsafe.Pointer(pPager)).FzJournal, (*TPager)(unsafe.Pointer(pPager)).Fjfd, **(**int32)(__ccgo_up(bp + 12)), bp+12) + } + if rc == SQLITE_OK { + **(**Tu8)(__ccgo_up(bp + 16)) = uint8(0) + rc = _sqlite3OsRead(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp+16, int32(1), 0) + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)<= int32(SQLITE_INDEX_CONSTRAINT_LIMIT) && libc.Int32FromUint8((*TWhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp) <= int32(SQLITE_INDEX_CONSTRAINT_OFFSET)) +} + +// C documentation +// +// /* +// ** Return the offset of the sector boundary at or immediately +// ** following the value in pPager->journalOff, assuming a sector +// ** size of pPager->sectorSize bytes. +// ** +// ** i.e for a sector size of 512: +// ** +// ** Pager.journalOff Return value +// ** --------------------------------------- +// ** 0 0 +// ** 512 512 +// ** 100 512 +// ** 2000 2048 +// ** +// */ +func _journalHdrOffset(tls *libc.TLS, pPager uintptr) (r Ti64) { + var c, offset Ti64 + _, _ = c, offset + offset = 0 + c = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + if c != 0 { + offset = ((c-int64(1))/libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) + int64(1)) * libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) + } + return offset +} + +// C documentation +// +// /* +// ** If pArg is a blob that seems like a JSONB blob, then initialize +// ** p to point to that JSONB and return TRUE. If pArg does not seem like +// ** a JSONB blob, then return FALSE. +// ** +// ** For small BLOBs (having no more than 7 bytes of payload) a full +// ** validity check is done. So for small BLOBs this routine only returns +// ** true if the value is guaranteed to be a valid JSONB. For larger BLOBs +// ** (8 byte or more of payload) only the size of the outermost element is +// ** checked to verify that the BLOB is superficially valid JSONB. +// ** +// ** A full JSONB validation is done on smaller BLOBs because those BLOBs might +// ** also be text JSON that has been incorrectly cast into a BLOB. +// ** (See tag-20240123-a and https://sqlite.org/forum/forumpost/012136abd5) +// ** If the BLOB is 9 bytes are larger, then it is not possible for the +// ** superficial size check done here to pass if the input is really text +// ** JSON so we do not need to look deeper in that case. +// ** +// ** Why we only need to do full JSONB validation for smaller BLOBs: +// ** +// ** The first byte of valid JSON text must be one of: '{', '[', '"', ' ', '\n', +// ** '\r', '\t', '-', or a digit '0' through '9'. Of these, only a subset +// ** can also be the first byte of JSONB: '{', '[', and digits '3' +// ** through '9'. In every one of those cases, the payload size is 7 bytes +// ** or less. So if we do full JSONB validation for every BLOB where the +// ** payload is less than 7 bytes, we will never get a false positive for +// ** JSONB on an input that is really text JSON. +// */ +func _jsonArgIsJsonb(tls *libc.TLS, pArg uintptr, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, v1 Tu8 + var n, v3 Tu32 + var v2, v4 bool + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _ = c, n, v1, v2, v3, v4 + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + if Xsqlite3_value_type(tls, pArg) != int32(SQLITE_BLOB) { + return 0 + } + (*TJsonParse)(unsafe.Pointer(p)).FaBlob = Xsqlite3_value_blob(tls, pArg) + (*TJsonParse)(unsafe.Pointer(p)).FnBlob = libc.Uint32FromInt32(Xsqlite3_value_bytes(tls, pArg)) + if v2 = (*TJsonParse)(unsafe.Pointer(p)).FnBlob > uint32(0) && (*TJsonParse)(unsafe.Pointer(p)).FaBlob != uintptr(0); v2 { + v1 = **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob)) + c = v1 + } + if v4 = v2 && libc.Int32FromUint8(v1)&int32(0x0f) <= int32(JSONB_OBJECT); v4 { + v3 = _jsonbPayloadSize(tls, p, uint32(0), bp) + n = v3 + } + if v4 && v3 > uint32(0) && **(**Tu32)(__ccgo_up(bp))+n == (*TJsonParse)(unsafe.Pointer(p)).FnBlob && (libc.Int32FromUint8(c)&int32(0x0f) > int32(JSONB_FALSE) || **(**Tu32)(__ccgo_up(bp)) == uint32(0)) && (**(**Tu32)(__ccgo_up(bp)) > uint32(7) || libc.Int32FromUint8(c) != int32(0x7b) && libc.Int32FromUint8(c) != int32(0x5b) && !(libc.Int32FromUint8(_sqlite3CtypeMap[c])&libc.Int32FromInt32(0x04) != 0) || _jsonbValidityCheck(tls, p, uint32(0), (*TJsonParse)(unsafe.Pointer(p)).FnBlob, uint32(1)) == uint32(0)) { + return int32(1) + } + (*TJsonParse)(unsafe.Pointer(p)).FaBlob = uintptr(0) + (*TJsonParse)(unsafe.Pointer(p)).FnBlob = uint32(0) + return 0 +} + +// C documentation +// +// /* The query strategy is to look for an equality constraint on the json +// ** column. Without such a constraint, the table cannot operate. idxNum is +// ** 1 if the constraint is found, 3 if the constraint and zRoot are found, +// ** and 0 otherwise. +// */ +func _jsonEachBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + var aIdx [2]int32 + var i, iCol, iMask, idxMask, unusableMask, v1 int32 + var pConstraint uintptr + _, _, _, _, _, _, _, _ = aIdx, i, iCol, iMask, idxMask, pConstraint, unusableMask, v1 /* Index of constraints for JSON and ROOT */ + unusableMask = 0 /* Mask of unusable JSON and ROOT constraints */ + idxMask = 0 + /* This implementation assumes that JSON and ROOT are the last two + ** columns in the table */ + _ = tab + v1 = -libc.Int32FromInt32(1) + aIdx[int32(1)] = v1 + aIdx[0] = v1 + pConstraint = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < int32(JEACH_JSON) { + goto _2 + } + iCol = (*Tsqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - int32(JEACH_JSON) + iMask = int32(1) << iCol + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { + unusableMask = unusableMask | iMask + } else { + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) { + aIdx[iCol] = i + idxMask = idxMask | iMask + } + } + goto _2 + _2: + ; + i = i + 1 + pConstraint += 12 + } + if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy > 0 && (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).FiColumn < 0 && libc.Int32FromUint8((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy))).Fdesc) == 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = int32(1) + } + if unusableMask & ^idxMask != 0 { + /* If there are any unusable constraints on JSON or ROOT, then reject + ** this entire plan */ + return int32(SQLITE_CONSTRAINT) + } + if aIdx[0] < 0 { + /* No JSON input. Leave estimatedCost at the huge value that it was + ** initialized to to discourage the query planner from selecting this + ** plan. */ + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 + } else { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1) + i = aIdx[0] + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + if aIdx[int32(1)] < 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(1) /* Only JSON supplied. Plan 1 */ + } else { + i = aIdx[int32(1)] + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = int32(2) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(3) /* Both JSON and ROOT are supplied. Plan 3 */ + } + } + return SQLITE_OK +} + +// C documentation +// +// /* Return the current rowid value */ +func _jsonEachRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) (r int32) { + var p uintptr + _ = p + p = cur + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = libc.Int64FromUint32((*TJsonEachCursor)(unsafe.Pointer(p)).FiRowid) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Translate a single byte of Hex into an integer. +// ** This routine only gives a correct answer if h really is a valid hexadecimal +// ** character: 0..9a..fA..F. But unlike sqlite3HexToInt(), it does not +// ** assert() if the digit is not hex. +// */ +func _jsonHexToInt(tls *libc.TLS, h int32) (r Tu8) { + h = h + int32(9)*(int32(1)&(h>>int32(6))) + return libc.Uint8FromInt32(h & libc.Int32FromInt32(0xf)) +} + +// C documentation +// +// /* Remove a single character from the end of the string +// */ +func _jsonStringTrimOneChar(tls *libc.TLS, p uintptr) { + if libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(p)).FeErr) == 0 { + (*TJsonString)(unsafe.Pointer(p)).FnUsed = (*TJsonString)(unsafe.Pointer(p)).FnUsed - 1 + } +} + +// C documentation +// +// /* The byte at index i is a node type-code. This routine +// ** determines the payload size for that node and writes that +// ** payload size in to *pSz. It returns the offset from i to the +// ** beginning of the payload. Return 0 on error. +// */ +func _jsonbPayloadSize(tls *libc.TLS, pParse uintptr, i Tu32, pSz uintptr) (r Tu32) { + var n, sz Tu32 + var x, v1 Tu8 + _, _, _, _ = n, sz, x, v1 + if i >= (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob { + **(**Tu32)(__ccgo_up(pSz)) = uint32(0) + return uint32(0) + } else { + v1 = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) >> libc.Int32FromInt32(4)) + x = v1 + if libc.Int32FromUint8(v1) <= int32(11) { + sz = uint32(x) + n = uint32(1) + } else { + if libc.Int32FromUint8(x) == int32(12) { + if i+uint32(1) >= (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob { + **(**Tu32)(__ccgo_up(pSz)) = uint32(0) + return uint32(0) + } + sz = uint32(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+uint32(1))))) + n = uint32(2) + } else { + if libc.Int32FromUint8(x) == int32(13) { + if i+uint32(2) >= (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob { + **(**Tu32)(__ccgo_up(pSz)) = uint32(0) + return uint32(0) + } + sz = libc.Uint32FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+uint32(1)))))<= (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob { + **(**Tu32)(__ccgo_up(pSz)) = uint32(0) + return uint32(0) + } + sz = uint32(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+uint32(1)))))<= (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+uint32(1))))) != 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+uint32(2))))) != 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+uint32(3))))) != 0 || libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+uint32(4))))) != 0 { + **(**Tu32)(__ccgo_up(pSz)) = uint32(0) + return uint32(0) + } + sz = uint32(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+uint32(5)))))< libc.Int64FromUint32((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob) && libc.Int64FromUint32(i)+libc.Int64FromUint32(sz)+libc.Int64FromUint32(n) > libc.Int64FromUint32((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pParse)).Fdelta)) { + **(**Tu32)(__ccgo_up(pSz)) = uint32(0) + return uint32(0) + } + **(**Tu32)(__ccgo_up(pSz)) = sz + return n +} + +func _lookasideMallocSize(tls *libc.TLS, db uintptr, p uintptr) (r int32) { + var v1 int32 + _ = v1 + if p < (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle { + v1 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } else { + v1 = int32(LOOKASIDE_SMALL) + } + return v1 +} + +// C documentation +// +// /* +// ** Try to enlarge the memory allocation to hold at least sz bytes +// */ +func _memdbEnlarge(tls *libc.TLS, p uintptr, newSz Tsqlite3_int64) (r int32) { + var pNew uintptr + _ = pNew + if (*TMemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_RESIZEABLE) == uint32(0) || (*TMemStore)(unsafe.Pointer(p)).FnMmap > 0 { + return int32(SQLITE_FULL) + } + if newSz > (*TMemStore)(unsafe.Pointer(p)).FszMax { + return int32(SQLITE_FULL) + } + newSz = newSz * int64(2) + if newSz > (*TMemStore)(unsafe.Pointer(p)).FszMax { + newSz = (*TMemStore)(unsafe.Pointer(p)).FszMax + } + pNew = _sqlite3Realloc(tls, (*TMemStore)(unsafe.Pointer(p)).FaData, libc.Uint64FromInt64(newSz)) + if pNew == uintptr(0) { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(12)<flags. +// ** But it does set pMem->u.r and pMem->u.i appropriately. +// */ +func _numericType(tls *libc.TLS, pMem uintptr) (r Tu16) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Null)) != 0 { + return libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags) & (libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal) | libc.Int32FromInt32(MEM_Null))) + } + return _computeNumericType(tls, pMem) + return uint16(0) +} + +// C documentation +// +// /* +// ** Ensure that the sub-journal file is open. If it is already open, this +// ** function is a no-op. +// ** +// ** SQLITE_OK is returned if everything goes according to plan. An +// ** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() +// ** fails. +// */ +func _openSubJournal(tls *libc.TLS, pPager uintptr) (r int32) { + var flags, nStmtSpill, rc int32 + _, _, _ = flags, nStmtSpill, rc + rc = SQLITE_OK + if !((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fsjfd)).FpMethods != libc.UintptrFromInt32(0)) { + flags = libc.Int32FromInt32(SQLITE_OPEN_SUBJOURNAL) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) + nStmtSpill = _sqlite3Config.FnStmtSpill + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_MEMORY) || (*TPager)(unsafe.Pointer(pPager)).FsubjInMemory != 0 { + nStmtSpill = -int32(1) + } + rc = _sqlite3JournalOpen(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), (*TPager)(unsafe.Pointer(pPager)).Fsjfd, flags, nStmtSpill) + } + return rc +} + +// C documentation +// +// /* +// ** Translate from TK_xx operator to WO_xx bitmask. +// */ +func _operatorMask(tls *libc.TLS, op int32) (r Tu16) { + var c Tu16 + _ = c + if op >= int32(TK_EQ) { + c = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ) << (op - libc.Int32FromInt32(TK_EQ))) + } else { + if op == int32(TK_IN) { + c = uint16(WO_IN) + } else { + if op == int32(TK_ISNULL) { + c = uint16(WO_ISNULL) + } else { + c = uint16(WO_IS) + } + } + } + return c +} + +// C documentation +// +// /* +// ** The following routine implements the rough equivalent of localtime_r() +// ** using whatever operating-system specific localtime facility that +// ** is available. This routine returns 0 on success and +// ** non-zero on any kind of error. +// ** +// ** If the sqlite3GlobalConfig.bLocaltimeFault variable is non-zero then this +// ** routine will always fail. If bLocaltimeFault is nonzero and +// ** sqlite3GlobalConfig.xAltLocaltime is not NULL, then xAltLocaltime() is +// ** invoked in place of the OS-defined localtime() function. +// ** +// ** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C +// ** library function localtime_r() is used to assist in the calculation of +// ** local time. +// */ +func _osLocaltime(tls *libc.TLS, t uintptr, pTm uintptr) (r int32) { + var mutex, pX uintptr + var rc int32 + _, _, _ = mutex, pX, rc + mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + Xsqlite3_mutex_enter(tls, mutex) + pX = libc.Xlocaltime(tls, t) + if _sqlite3Config.FbLocaltimeFault != 0 { + if _sqlite3Config.FxAltLocaltime != uintptr(0) && 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.FxAltLocaltime})))(tls, t, pTm) { + pX = pTm + } else { + pX = uintptr(0) + } + } + if pX != 0 { + **(**Ttm)(__ccgo_up(pTm)) = **(**Ttm)(__ccgo_up(pX)) + } + Xsqlite3_mutex_leave(tls, mutex) + rc = libc.BoolInt32(pX == uintptr(0)) + return rc +} + +// C documentation +// +// /* +// ** Attempt to take an exclusive lock on the database file. If a PENDING lock +// ** is obtained instead, immediately release it. +// */ +func _pagerExclusiveLock(tls *libc.TLS, pPager uintptr) (r int32) { + var eOrigLock Tu8 + var rc int32 + _, _ = eOrigLock, rc /* Original lock */ + eOrigLock = (*TPager)(unsafe.Pointer(pPager)).FeLock + rc = _pagerLockDb(tls, pPager, int32(EXCLUSIVE_LOCK)) + if rc != SQLITE_OK { + /* If the attempt to grab the exclusive lock failed, release the + ** pending lock that may have been obtained instead. */ + _pagerUnlockDb(tls, pPager, libc.Int32FromUint8(eOrigLock)) + } + return rc +} + +// C documentation +// +// /* +// ** The write transaction open on pPager is being committed (bCommit==1) +// ** or rolled back (bCommit==0). +// ** +// ** Return TRUE if and only if all dirty pages should be flushed to disk. +// ** +// ** Rules: +// ** +// ** * For non-TEMP databases, always sync to disk. This is necessary +// ** for transactions to be durable. +// ** +// ** * Sync TEMP database only on a COMMIT (not a ROLLBACK) when the backing +// ** file has been created already (via a spill on pagerStress()) and +// ** when the number of dirty pages in memory exceeds 25% of the total +// ** cache size. +// */ +func _pagerFlushOnCommit(tls *libc.TLS, pPager uintptr, bCommit int32) (r int32) { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FtempFile) == 0 { + return int32(1) + } + if !(bCommit != 0) { + return 0 + } + if !((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != libc.UintptrFromInt32(0)) { + return 0 + } + return libc.BoolInt32(_sqlite3PCachePercentDirty(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) >= int32(25)) +} + +// C documentation +// +// /* +// ** Lock the database file to level eLock, which must be either SHARED_LOCK, +// ** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the +// ** Pager.eLock variable to the new locking state. +// ** +// ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is +// ** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. +// ** See the comment above the #define of UNKNOWN_LOCK for an explanation +// ** of this. +// */ +func _pagerLockDb(tls *libc.TLS, pPager uintptr, eLock int32) (r int32) { + var rc, v1 int32 + _, _ = rc, v1 + rc = SQLITE_OK + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) < eLock || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) == libc.Int32FromInt32(EXCLUSIVE_LOCK)+libc.Int32FromInt32(1) { + if (*TPager)(unsafe.Pointer(pPager)).FnoLock != 0 { + v1 = SQLITE_OK + } else { + v1 = _sqlite3OsLock(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, eLock) + } + rc = v1 + if rc == SQLITE_OK && (libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) != libc.Int32FromInt32(EXCLUSIVE_LOCK)+libc.Int32FromInt32(1) || eLock == int32(EXCLUSIVE_LOCK)) { + (*TPager)(unsafe.Pointer(pPager)).FeLock = libc.Uint8FromInt32(eLock) + } + } + return rc +} + +// C documentation +// +// /* +// ** Check if the *-wal file that corresponds to the database opened by pPager +// ** exists if the database is not empty, or verify that the *-wal file does +// ** not exist (by deleting it) if the database file is empty. +// ** +// ** If the database is not empty and the *-wal file exists, open the pager +// ** in WAL mode. If the database is empty or if no *-wal file exists and +// ** if no error occurs, make sure Pager.journalMode is not set to +// ** PAGER_JOURNALMODE_WAL. +// ** +// ** Return SQLITE_OK or an error code. +// ** +// ** The caller must hold a SHARED lock on the database file to call this +// ** function. Because an EXCLUSIVE lock on the db file is required to delete +// ** a WAL on a none-empty database, this ensures there is no race condition +// ** between the xAccess() below and an xDelete() being executed by some +// ** other connection. +// */ +func _pagerOpenWalIfPresent(tls *libc.TLS, pPager uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* isWal at bp+0 */ int32 + var _ /* nPage at bp+4 */ TPgno + _ = rc + rc = SQLITE_OK + if !((*TPager)(unsafe.Pointer(pPager)).FtempFile != 0) { /* True if WAL file exists */ + rc = _sqlite3OsAccess(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, (*TPager)(unsafe.Pointer(pPager)).FzWal, SQLITE_ACCESS_EXISTS, bp) + if rc == SQLITE_OK { + if **(**int32)(__ccgo_up(bp)) != 0 { /* Size of the database file */ + rc = _pagerPagecount(tls, pPager, bp+4) + if rc != 0 { + return rc + } + if **(**TPgno)(__ccgo_up(bp + 4)) == uint32(0) { + rc = _sqlite3OsDelete(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, (*TPager)(unsafe.Pointer(pPager)).FzWal, 0) + } else { + rc = _sqlite3PagerOpenWal(tls, pPager, uintptr(0)) + } + } else { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_WAL) { + (*TPager)(unsafe.Pointer(pPager)).FjournalMode = uint8(PAGER_JOURNALMODE_DELETE) + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** This function is called as part of the transition from PAGER_OPEN +// ** to PAGER_READER state to determine the size of the database file +// ** in pages (assuming the page size currently stored in Pager.pageSize). +// ** +// ** If no error occurs, SQLITE_OK is returned and the size of the database +// ** in pages is stored in *pnPage. Otherwise, an error code (perhaps +// ** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified. +// */ +func _pagerPagecount(tls *libc.TLS, pPager uintptr, pnPage uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nPage TPgno + var rc int32 + var _ /* n at bp+0 */ Ti64 + _, _ = nPage, rc /* Value to return via *pnPage */ + /* Query the WAL sub-system for the database size. The WalDbsize() + ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or + ** if the database size is not available. The database size is not + ** available from the WAL sub-system if the log file is empty or + ** contains no valid committed transactions. + */ + nPage = _sqlite3WalDbsize(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) + /* If the number of pages in the database is not available from the + ** WAL sub-system, determine the page count based on the size of + ** the database file. If the size of the database file is not an + ** integer multiple of the page-size, round up the result. + */ + if nPage == uint32(0) && (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) { + **(**Ti64)(__ccgo_up(bp)) = 0 /* Size of db file in bytes */ + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, bp) + if rc != SQLITE_OK { + return rc + } + nPage = libc.Uint32FromInt64((**(**Ti64)(__ccgo_up(bp)) + (*TPager)(unsafe.Pointer(pPager)).FpageSize - libc.Int64FromInt32(1)) / (*TPager)(unsafe.Pointer(pPager)).FpageSize) + } + /* If the current number of pages in the file is greater than the + ** configured maximum pager number, increase the allowed limit so + ** that the file can be read. + */ + if nPage > (*TPager)(unsafe.Pointer(pPager)).FmxPgno { + (*TPager)(unsafe.Pointer(pPager)).FmxPgno = nPage + } + **(**TPgno)(__ccgo_up(pnPage)) = nPage + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Release a reference to page pPg. pPg must have been returned by an +// ** earlier call to pagerAcquireMapPage(). +// */ +func _pagerReleaseMapPage(tls *libc.TLS, pPg uintptr) { + var pPager uintptr + _ = pPager + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager + (*TPager)(unsafe.Pointer(pPager)).FnMmapOut = (*TPager)(unsafe.Pointer(pPager)).FnMmapOut - 1 + (*TPgHdr)(unsafe.Pointer(pPg)).FpDirty = (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist + (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist = pPg + _sqlite3OsUnfetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int64FromUint32((*TPgHdr)(unsafe.Pointer(pPg)).Fpgno-libc.Uint32FromInt32(1))*(*TPager)(unsafe.Pointer(pPager)).FpageSize, (*TPgHdr)(unsafe.Pointer(pPg)).FpData) +} + +// C documentation +// +// /* +// ** Execute a rollback if a transaction is active and unlock the +// ** database file. +// ** +// ** If the pager has already entered the ERROR state, do not attempt +// ** the rollback at this time. Instead, pager_unlock() is called. The +// ** call to pager_unlock() will discard all in-memory pages, unlock +// ** the database file and move the pager back to OPEN state. If this +// ** means that there is a hot-journal left in the file-system, the next +// ** connection to obtain a shared lock on the pager (which may be this one) +// ** will roll it back. +// ** +// ** If the pager has not already entered the ERROR state, but an IO or +// ** malloc error occurs during a rollback, then this will itself cause +// ** the pager to enter the ERROR state. Which will be cleared by the +// ** call to pager_unlock(), as described above. +// */ +func _pagerUnlockAndRollback(tls *libc.TLS, pPager uintptr) { + var eLock Tu8 + var errCode int32 + _, _ = eLock, errCode + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) != int32(PAGER_ERROR) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) != PAGER_OPEN { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) >= int32(PAGER_WRITER_LOCKED) { + _sqlite3BeginBenignMalloc(tls) + _sqlite3PagerRollback(tls, pPager) + _sqlite3EndBenignMalloc(tls) + } else { + if !((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) { + _pager_end_transaction(tls, pPager, 0, 0) + } + } + } else { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_ERROR) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_MEMORY) && (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) { + /* Special case for a ROLLBACK due to I/O error with an in-memory + ** journal: We have to rollback immediately, before the journal is + ** closed, because once it is closed, all content is forgotten. */ + errCode = (*TPager)(unsafe.Pointer(pPager)).FerrCode + eLock = (*TPager)(unsafe.Pointer(pPager)).FeLock + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_OPEN) + (*TPager)(unsafe.Pointer(pPager)).FerrCode = SQLITE_OK + (*TPager)(unsafe.Pointer(pPager)).FeLock = uint8(EXCLUSIVE_LOCK) + _pager_playback(tls, pPager, int32(1)) + (*TPager)(unsafe.Pointer(pPager)).FerrCode = errCode + (*TPager)(unsafe.Pointer(pPager)).FeLock = eLock + } + } + _pager_unlock(tls, pPager) +} + +// C documentation +// +// /* +// ** Unlock the database file to level eLock, which must be either NO_LOCK +// ** or SHARED_LOCK. Regardless of whether or not the call to xUnlock() +// ** succeeds, set the Pager.eLock variable to match the (attempted) new lock. +// ** +// ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is +// ** called, do not modify it. See the comment above the #define of +// ** UNKNOWN_LOCK for an explanation of this. +// */ +func _pagerUnlockDb(tls *libc.TLS, pPager uintptr, eLock int32) (r int32) { + var rc, v1 int32 + _, _ = rc, v1 + rc = SQLITE_OK + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) { + if (*TPager)(unsafe.Pointer(pPager)).FnoLock != 0 { + v1 = SQLITE_OK + } else { + v1 = _sqlite3OsUnlock(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, eLock) + } + rc = v1 + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) != libc.Int32FromInt32(EXCLUSIVE_LOCK)+libc.Int32FromInt32(1) { + (*TPager)(unsafe.Pointer(pPager)).FeLock = libc.Uint8FromInt32(eLock) + } + } + (*TPager)(unsafe.Pointer(pPager)).FchangeCountDone = (*TPager)(unsafe.Pointer(pPager)).FtempFile /* ticket fb3b3024ea238d5c */ + return rc +} + +// C documentation +// +// /* +// ** This routine ends a transaction. A transaction is usually ended by +// ** either a COMMIT or a ROLLBACK operation. This routine may be called +// ** after rollback of a hot-journal, or if an error occurs while opening +// ** the journal file or writing the very first journal-header of a +// ** database transaction. +// ** +// ** This routine is never called in PAGER_ERROR state. If it is called +// ** in PAGER_NONE or PAGER_SHARED state and the lock held is less +// ** exclusive than a RESERVED lock, it is a no-op. +// ** +// ** Otherwise, any active savepoints are released. +// ** +// ** If the journal file is open, then it is "finalized". Once a journal +// ** file has been finalized it is not possible to use it to roll back a +// ** transaction. Nor will it be considered to be a hot-journal by this +// ** or any other database connection. Exactly how a journal is finalized +// ** depends on whether or not the pager is running in exclusive mode and +// ** the current journal-mode (Pager.journalMode value), as follows: +// ** +// ** journalMode==MEMORY +// ** Journal file descriptor is simply closed. This destroys an +// ** in-memory journal. +// ** +// ** journalMode==TRUNCATE +// ** Journal file is truncated to zero bytes in size. +// ** +// ** journalMode==PERSIST +// ** The first 28 bytes of the journal file are zeroed. This invalidates +// ** the first journal header in the file, and hence the entire journal +// ** file. An invalid journal file cannot be rolled back. +// ** +// ** journalMode==DELETE +// ** The journal file is closed and deleted using sqlite3OsDelete(). +// ** +// ** If the pager is running in exclusive mode, this method of finalizing +// ** the journal file is never used. Instead, if the journalMode is +// ** DELETE and the pager is in exclusive mode, the method described under +// ** journalMode==PERSIST is used instead. +// ** +// ** After the journal is finalized, the pager moves to PAGER_READER state. +// ** If running in non-exclusive rollback mode, the lock on the file is +// ** downgraded to a SHARED_LOCK. +// ** +// ** SQLITE_OK is returned if no error occurs. If an error occurs during +// ** any of the IO operations to finalize the journal file or unlock the +// ** database then the IO error code is returned to the user. If the +// ** operation to finalize the journal file fails, then the code still +// ** tries to unlock the database file if not in exclusive mode. If the +// ** unlock operation fails as well, then the first error code related +// ** to the first error encountered (the journal finalization one) is +// ** returned. +// */ +func _pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommit int32) (r int32) { + var bDelete, rc, rc2, v1 int32 + _, _, _, _ = bDelete, rc, rc2, v1 + rc = SQLITE_OK /* Error code from journal finalization operation */ + rc2 = SQLITE_OK /* Error code from db file unlock operation */ + /* Do nothing if the pager does not have an open write transaction + ** or at least a RESERVED lock. This function may be called when there + ** is no write-transaction active but a RESERVED or greater lock is + ** held under two circumstances: + ** + ** 1. After a successful hot-journal rollback, it is called with + ** eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK. + ** + ** 2. If a connection with locking_mode=exclusive holding an EXCLUSIVE + ** lock switches back to locking_mode=normal and then executes a + ** read-transaction, this function is called with eState==PAGER_READER + ** and eLock==EXCLUSIVE_LOCK when the read-transaction is closed. + */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) < int32(PAGER_WRITER_LOCKED) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) < int32(RESERVED_LOCK) { + return SQLITE_OK + } + _releaseAllSavepoints(tls, pPager) + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) { + /* Finalize the journal file. */ + if _sqlite3JournalIsInMemory(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) != 0 { + /* assert( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ); */ + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) + } else { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_TRUNCATE) { + if (*TPager)(unsafe.Pointer(pPager)).FjournalOff == 0 { + rc = SQLITE_OK + } else { + rc = _sqlite3OsTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, 0) + if rc == SQLITE_OK && (*TPager)(unsafe.Pointer(pPager)).FfullSync != 0 { + /* Make sure the new file size is written into the inode right away. + ** Otherwise the journal might resurrect following a power loss and + ** cause the last transaction to roll back. See + ** https://bugzilla.mozilla.org/show_bug.cgi?id=1072773 + */ + rc = _sqlite3OsSync(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FsyncFlags)) + } + } + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + } else { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_PERSIST) || (*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) < int32(PAGER_JOURNALMODE_WAL) { + rc = _zeroJournalHdr(tls, pPager, libc.BoolInt32(hasSuper != 0 || (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0)) + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + } else { + /* This branch may be executed with Pager.journalMode==MEMORY if + ** a hot-journal was just rolled back. In this case the journal + ** file should be closed and deleted. If this connection writes to + ** the database file, it will do so using an in-memory journal. + */ + bDelete = libc.BoolInt32(!((*TPager)(unsafe.Pointer(pPager)).FtempFile != 0)) + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) + if bDelete != 0 { + rc = _sqlite3OsDelete(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, (*TPager)(unsafe.Pointer(pPager)).FzJournal, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FextraSync)) + } + } + } + } + } + _sqlite3BitvecDestroy(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal) + (*TPager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0) + (*TPager)(unsafe.Pointer(pPager)).FnRec = 0 + if rc == SQLITE_OK { + if (*TPager)(unsafe.Pointer(pPager)).FmemDb != 0 || _pagerFlushOnCommit(tls, pPager, bCommit) != 0 { + _sqlite3PcacheCleanAll(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + } else { + _sqlite3PcacheClearWritable(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + } + _sqlite3PcacheTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, (*TPager)(unsafe.Pointer(pPager)).FdbSize) + } + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + /* Drop the WAL write-lock, if any. Also, if the connection was in + ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE + ** lock held on the database file. + */ + rc2 = _sqlite3WalEndWriteTransaction(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) + } else { + if rc == SQLITE_OK && bCommit != 0 && (*TPager)(unsafe.Pointer(pPager)).FdbFileSize > (*TPager)(unsafe.Pointer(pPager)).FdbSize { + /* This branch is taken when committing a transaction in rollback-journal + ** mode if the database file on disk is larger than the database image. + ** At this point the journal has been finalized and the transaction + ** successfully committed, but the EXCLUSIVE lock is still held on the + ** file. So it is safe to truncate the database file to its minimum + ** required size. */ + rc = _pager_truncate(tls, pPager, (*TPager)(unsafe.Pointer(pPager)).FdbSize) + } + } + if rc == SQLITE_OK && bCommit != 0 { + rc = _sqlite3OsFileControl(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_COMMIT_PHASETWO), uintptr(0)) + if rc == int32(SQLITE_NOTFOUND) { + rc = SQLITE_OK + } + } + if !((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) && (!((*TPager)(unsafe.Pointer(pPager)).FpWal != libc.UintptrFromInt32(0)) || _sqlite3WalExclusiveMode(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, 0) != 0) { + rc2 = _pagerUnlockDb(tls, pPager, int32(SHARED_LOCK)) + } + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_READER) + (*TPager)(unsafe.Pointer(pPager)).FsetSuper = uint8(0) + if rc == SQLITE_OK { + v1 = rc2 + } else { + v1 = rc + } + return v1 +} + +// C documentation +// +// /* +// ** This function is called at the start of every write transaction. +// ** There must already be a RESERVED or EXCLUSIVE lock on the database +// ** file when this routine is called. +// ** +// ** Open the journal file for pager pPager and write a journal header +// ** to the start of it. If there are active savepoints, open the sub-journal +// ** as well. This function is only used when the journal file is being +// ** opened to write a rollback log for a transaction. It is not used +// ** when opening a hot journal file to roll it back. +// ** +// ** If the journal file is already open (as it may be in exclusive mode), +// ** then this function just writes a journal header to the start of the +// ** already open file. +// ** +// ** Whether or not the journal file is opened by this function, the +// ** Pager.pInJournal bitvec structure is allocated. +// ** +// ** Return SQLITE_OK if everything is successful. Otherwise, return +// ** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or +// ** an IO error code if opening or writing the journal file fails. +// */ +func _pager_open_journal(tls *libc.TLS, pPager uintptr) (r int32) { + var flags, nSpill, rc int32 + var pVfs uintptr + _, _, _, _ = flags, nSpill, pVfs, rc + rc = SQLITE_OK /* Return code */ + pVfs = (*TPager)(unsafe.Pointer(pPager)).FpVfs /* Local cache of vfs pointer */ + /* If already in the error state, this function is a no-op. But on + ** the other hand, this routine is never called if we are already in + ** an error state. */ + if (*TPager)(unsafe.Pointer(pPager)).FerrCode != 0 { + return (*TPager)(unsafe.Pointer(pPager)).FerrCode + } + if !((*TPager)(unsafe.Pointer(pPager)).FpWal != libc.UintptrFromInt32(0)) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) != int32(PAGER_JOURNALMODE_OFF) { + (*TPager)(unsafe.Pointer(pPager)).FpInJournal = _sqlite3BitvecCreate(tls, (*TPager)(unsafe.Pointer(pPager)).FdbSize) + if (*TPager)(unsafe.Pointer(pPager)).FpInJournal == uintptr(0) { + return int32(SQLITE_NOMEM) + } + /* Open the journal file if it is not already open. */ + if !((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != libc.UintptrFromInt32(0)) { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_MEMORY) { + _sqlite3MemJournalOpen(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) + } else { + flags = libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) + if (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 { + flags = flags | (libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) | libc.Int32FromInt32(SQLITE_OPEN_TEMP_JOURNAL)) + flags = flags | int32(SQLITE_OPEN_EXCLUSIVE) + nSpill = _sqlite3Config.FnStmtSpill + } else { + flags = flags | int32(SQLITE_OPEN_MAIN_JOURNAL) + nSpill = _jrnlBufferSize(tls, pPager) + } + /* Verify that the database still has the same name as it did when + ** it was originally opened. */ + rc = _databaseIsUnmoved(tls, pPager) + if rc == SQLITE_OK { + rc = _sqlite3JournalOpen(tls, pVfs, (*TPager)(unsafe.Pointer(pPager)).FzJournal, (*TPager)(unsafe.Pointer(pPager)).Fjfd, flags, nSpill) + } + } + } + /* Write the first journal header to the journal file and open + ** the sub-journal if necessary. + */ + if rc == SQLITE_OK { + /* TODO: Check if all of these are really required. */ + (*TPager)(unsafe.Pointer(pPager)).FnRec = 0 + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + (*TPager)(unsafe.Pointer(pPager)).FsetSuper = uint8(0) + (*TPager)(unsafe.Pointer(pPager)).FjournalHdr = 0 + rc = _writeJournalHdr(tls, pPager) + } + } + if rc != SQLITE_OK { + _sqlite3BitvecDestroy(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal) + (*TPager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0) + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + } else { + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_WRITER_CACHEMOD) + } + return rc +} + +// C documentation +// +// /* Memory allocator for parser stack resizing. This is a thin wrapper around +// ** sqlite3_realloc() that includes a call to sqlite3FaultSim() to facilitate +// ** testing. +// */ +func _parserStackRealloc(tls *libc.TLS, pOld uintptr, newSize Tsqlite3_uint64, pParse uintptr) (r uintptr) { + var p, v1 uintptr + _, _ = p, v1 + if _sqlite3FaultSim(tls, int32(700)) != 0 { + v1 = uintptr(0) + } else { + v1 = Xsqlite3_realloc(tls, pOld, libc.Int32FromUint64(newSize)) + } + p = v1 + if p == uintptr(0) { + _sqlite3OomFault(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb) + } + return p +} + +// C documentation +// +// /* +// ** If there are currently more than nMaxPage pages allocated, try +// ** to recycle pages to reduce the number allocated to nMaxPage. +// */ +func _pcache1EnforceMaxPage(tls *libc.TLS, pCache uintptr) { + var p, pGroup, v1 uintptr + var v2 bool + _, _, _, _ = p, pGroup, v1, v2 + pGroup = (*TPCache1)(unsafe.Pointer(pCache)).FpGroup + for { + if v2 = (*TPGroup)(unsafe.Pointer(pGroup)).FnPurgeable > (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage; v2 { + v1 = (*TPGroup)(unsafe.Pointer(pGroup)).Flru.FpLruPrev + p = v1 + } + if !(v2 && libc.Int32FromUint16((*TPgHdr1)(unsafe.Pointer(v1)).FisAnchor) == 0) { + break + } + _pcache1PinPage(tls, p) + _pcache1RemoveFromHash(tls, p, int32(1)) + } + if (*TPCache1)(unsafe.Pointer(pCache)).FnPage == uint32(0) && (*TPCache1)(unsafe.Pointer(pCache)).FpBulk != 0 { + Xsqlite3_free(tls, (*TPCache1)(unsafe.Pointer(pCache)).FpBulk) + v1 = libc.UintptrFromInt32(0) + (*TPCache1)(unsafe.Pointer(pCache)).FpFree = v1 + (*TPCache1)(unsafe.Pointer(pCache)).FpBulk = v1 + } +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xPagecount method. +// */ +func _pcache1Pagecount(tls *libc.TLS, p uintptr) (r int32) { + var n int32 + var pCache uintptr + _, _ = n, pCache + pCache = p + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) + n = libc.Int32FromUint32((*TPCache1)(unsafe.Pointer(pCache)).FnPage) + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) + return n +} + +// C documentation +// +// /* +// ** Manage pPage's participation on the dirty list. Bits of the addRemove +// ** argument determines what operation to do. The 0x01 bit means first +// ** remove pPage from the dirty list. The 0x02 means add pPage back to +// ** the dirty list. Doing both moves pPage to the front of the dirty list. +// */ +func _pcacheManageDirtyList(tls *libc.TLS, pPage uintptr, addRemove Tu8) { + var p uintptr + _ = p + p = (*TPgHdr)(unsafe.Pointer(pPage)).FpCache + if libc.Int32FromUint8(addRemove)&int32(PCACHE_DIRTYLIST_REMOVE) != 0 { + /* Update the PCache1.pSynced variable if necessary. */ + if (*TPCache)(unsafe.Pointer(p)).FpSynced == pPage { + (*TPCache)(unsafe.Pointer(p)).FpSynced = (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev + } + if (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyNext != 0 { + (*TPgHdr)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyNext)).FpDirtyPrev = (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev + } else { + (*TPCache)(unsafe.Pointer(p)).FpDirtyTail = (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev + } + if (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev != 0 { + (*TPgHdr)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev)).FpDirtyNext = (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyNext + } else { + /* If there are now no dirty pages in the cache, set eCreate to 2. + ** This is an optimization that allows sqlite3PcacheFetch() to skip + ** searching for a dirty page to eject from the cache when it might + ** otherwise have to. */ + (*TPCache)(unsafe.Pointer(p)).FpDirty = (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyNext + if (*TPCache)(unsafe.Pointer(p)).FpDirty == uintptr(0) { /*OPTIMIZATION-IF-TRUE*/ + (*TPCache)(unsafe.Pointer(p)).FeCreate = uint8(2) + } + } + } + if libc.Int32FromUint8(addRemove)&int32(PCACHE_DIRTYLIST_ADD) != 0 { + (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev = uintptr(0) + (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyNext = (*TPCache)(unsafe.Pointer(p)).FpDirty + if (*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyNext != 0 { + (*TPgHdr)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(pPage)).FpDirtyNext)).FpDirtyPrev = pPage + } else { + (*TPCache)(unsafe.Pointer(p)).FpDirtyTail = pPage + if (*TPCache)(unsafe.Pointer(p)).FbPurgeable != 0 { + (*TPCache)(unsafe.Pointer(p)).FeCreate = uint8(1) + } + } + (*TPCache)(unsafe.Pointer(p)).FpDirty = pPage + /* If pSynced is NULL and this page has a clear NEED_SYNC flag, set + ** pSynced to point to it. Checking the NEED_SYNC flag is an + ** optimization, as if pSynced points to a page with the NEED_SYNC + ** flag set sqlite3PcacheFetchStress() searches through all newer + ** entries of the dirty-list for a page with NEED_SYNC clear anyway. */ + if !((*TPCache)(unsafe.Pointer(p)).FpSynced != 0) && 0 == libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pPage)).Fflags)&int32(PGHDR_NEED_SYNC) { + (*TPCache)(unsafe.Pointer(p)).FpSynced = pPage + } + } +} + +var _pgsz = int32(4096) + +/* +** Check that the pShmNode->aLock[] array comports with the locking bitmasks +** held by each client. Return true if it does, or false otherwise. This +** is to be used in an assert(). e.g. +** +** assert( assertLockingArrayOk(pShmNode) ); + */ + +var _posixIoFinder = uintptr(0) + +func _posixIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) (r uintptr) { + _ = z + _ = p + return uintptr(unsafe.Pointer(&_posixIoMethods)) +} + +// C documentation +// +// /* +// ** Here are all of the sqlite3_io_methods objects for each of the +// ** locking strategies. Functions that return pointers to these methods +// ** are also created. +// */ +var _posixIoMethods = Tsqlite3_io_methods{ + FiVersion: int32(3), +} + +// C documentation +// +// /* +// ** Different Unix systems declare open() in different ways. Same use +// ** open(const char*,int,mode_t). Others use open(const char*,int,...). +// ** The difference is important when using a pointer to the function. +// ** +// ** The safest way to deal with the problem is to always use this wrapper +// ** which always has the same well-defined interface. +// */ +func _posixOpen(tls *libc.TLS, zFile uintptr, flags int32, mode int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + return libc.Xopen(tls, zFile, flags, libc.VaList(bp+8, mode)) +} + +// C documentation +// +// /* Figure out the best index to use to search a pragma virtual table. +// ** +// ** There are not really any index choices. But we want to encourage the +// ** query planner to give == constraints on as many hidden parameters as +// ** possible, and especially on the first hidden parameter. So return a +// ** high cost if hidden parameters are unconstrained. +// */ +func _pragmaVtabBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) { + var i, j int32 + var pConstraint, pTab uintptr + var seen [2]int32 + _, _, _, _, _ = i, j, pConstraint, pTab, seen + pTab = tab + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = libc.Float64FromInt32(1) + if libc.Int32FromUint8((*TPragmaVtab)(unsafe.Pointer(pTab)).FnHidden) == 0 { + return SQLITE_OK + } + pConstraint = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + seen[0] = 0 + seen[int32(1)] = 0 + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + if (*Tsqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < libc.Int32FromUint8((*TPragmaVtab)(unsafe.Pointer(pTab)).FiHidden) { + goto _1 + } + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != int32(SQLITE_INDEX_CONSTRAINT_EQ) { + goto _1 + } + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { + return int32(SQLITE_CONSTRAINT) + } + j = (*Tsqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - libc.Int32FromUint8((*TPragmaVtab)(unsafe.Pointer(pTab)).FiHidden) + seen[j] = i + int32(1) + goto _1 + _1: + ; + i = i + 1 + pConstraint += 12 + } + if seen[0] == 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = libc.Float64FromInt32(2147483647) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(2147483647) + return SQLITE_OK + } + j = seen[0] - int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8))).FargvIndex = int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8))).Fomit = uint8(1) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = libc.Float64FromInt32(20) + (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(20) + if seen[int32(1)] != 0 { + j = seen[int32(1)] - int32(1) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8))).FargvIndex = int32(2) + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8))).Fomit = uint8(1) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Allocate memory for a temporary buffer needed for printf rendering. +// ** +// ** If the requested size of the temp buffer is larger than the size +// ** of the output buffer in pAccum, then cause an SQLITE_TOOBIG error. +// ** Do the size check before the memory allocation to prevent rogue +// ** SQL from requesting large allocations using the precision or width +// ** field of the printf() function. +// */ +func _printfTempBuf(tls *libc.TLS, pAccum uintptr, n Tsqlite3_int64) (r uintptr) { + var z uintptr + _ = z + if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError != 0 { + return uintptr(0) + } + if n > libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc) && n > libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc) { + _sqlite3StrAccumSetError(tls, pAccum, uint8(SQLITE_TOOBIG)) + return uintptr(0) + } + z = Xsqlite3_malloc(tls, int32(n)) + if z == uintptr(0) { + _sqlite3StrAccumSetError(tls, pAccum, uint8(SQLITE_NOMEM)) + } + return z +} + +/* +** On machines with a small stack size, you can redefine the +** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired. + */ + +/* +** Hard limit on the precision of floating-point conversions. + */ + +// C documentation +// +// /* +// ** Read an entry from the pointer map. +// ** +// ** This routine retrieves the pointer map entry for page 'key', writing +// ** the type and parent page number to *pEType and *pPgno respectively. +// ** An error code is returned if something goes wrong, otherwise SQLITE_OK. +// */ +func _ptrmapGet(tls *libc.TLS, pBt uintptr, key TPgno, pEType uintptr, pPgno uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iPtrmap, offset, rc int32 + var pPtrmap uintptr + var _ /* pDbPage at bp+0 */ uintptr + _, _, _, _ = iPtrmap, offset, pPtrmap, rc + iPtrmap = libc.Int32FromUint32(_ptrmapPageno(tls, pBt, key)) + rc = _sqlite3PagerGet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, libc.Uint32FromInt32(iPtrmap), bp, 0) + if rc != 0 { + return rc + } + pPtrmap = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp))) + offset = libc.Int32FromUint32(libc.Uint32FromInt32(5) * (key - libc.Uint32FromInt32(iPtrmap) - libc.Uint32FromInt32(1))) + if offset < 0 { + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + return _sqlite3CorruptError(tls, int32(74279)) + } + **(**Tu8)(__ccgo_up(pEType)) = **(**Tu8)(__ccgo_up(pPtrmap + uintptr(offset))) + if pPgno != 0 { + **(**TPgno)(__ccgo_up(pPgno)) = _sqlite3Get4byte(tls, pPtrmap+uintptr(offset+int32(1))) + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pEType))) < int32(1) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pEType))) > int32(5) { + return _sqlite3CorruptError(tls, int32(74287)) + } + return SQLITE_OK +} + +/* +** Given a btree page and a cell index (0 means the first cell on +** the page, 1 means the second cell, and so forth) return a pointer +** to the cell content. +** +** findCellPastPtr() does the same except it skips past the initial +** 4-byte child pointer found on interior pages, if there is one. +** +** This routine works only for pages that do not contain overflow cells. + */ + +// C documentation +// +// /* +// ** Given a page number of a regular database page, return the page +// ** number for the pointer-map page that contains the entry for the +// ** input page number. +// ** +// ** Return 0 (not a valid page) for pgno==1 since there is +// ** no pointer map associated with page 1. The integrity_check logic +// ** requires that ptrmapPageno(*,1)!=1. +// */ +func _ptrmapPageno(tls *libc.TLS, pBt uintptr, pgno TPgno) (r TPgno) { + var iPtrMap, ret TPgno + var nPagesPerMapPage int32 + _, _, _ = iPtrMap, nPagesPerMapPage, ret + if pgno < uint32(2) { + return uint32(0) + } + nPagesPerMapPage = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FusableSize/uint32(5) + uint32(1)) + iPtrMap = (pgno - uint32(2)) / libc.Uint32FromInt32(nPagesPerMapPage) + ret = iPtrMap*libc.Uint32FromInt32(nPagesPerMapPage) + uint32(2) + if ret == libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize+libc.Uint32FromInt32(1) { + ret = ret + 1 + } + return ret +} + +// C documentation +// +// /* +// ** Called when a page of data is written to offset iOff of the database +// ** file while the rbu handle is in capture mode. Record the page number +// ** of the page being written in the aFrame[] array. +// */ +func _rbuCaptureDbWrite(tls *libc.TLS, pRbu uintptr, iOff Ti64) (r int32) { + (**(**TRbuFrame)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr((*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame-int32(1))*8))).FiDbPage = libc.Uint32FromInt64(iOff/int64((*Tsqlite3rbu)(unsafe.Pointer(pRbu)).Fpgsz)) + uint32(1) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This is called as part of an incremental checkpoint operation. Copy +// ** a single frame of data from the wal file into the database file, as +// ** indicated by the RbuFrame object. +// */ +func _rbuCheckpointFrame(tls *libc.TLS, p uintptr, pFrame uintptr) { + var iOff Ti64 + var pDb, pWal uintptr + _, _, _ = iOff, pDb, pWal + pWal = (*Trbu_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd)).FpReal + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + iOff = libc.Int64FromUint32((*TRbuFrame)(unsafe.Pointer(pFrame)).FiWalFrame-libc.Uint32FromInt32(1))*int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz+libc.Int32FromInt32(24)) + int64(32) + int64(24) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pWal)).FpMethods)).FxRead})))(tls, pWal, (*Tsqlite3rbu)(unsafe.Pointer(p)).FaBuf, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz, iOff) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + return + } + iOff = libc.Int64FromUint32((*TRbuFrame)(unsafe.Pointer(pFrame)).FiDbPage-libc.Uint32FromInt32(1)) * int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxWrite})))(tls, pDb, (*Tsqlite3rbu)(unsafe.Pointer(p)).FaBuf, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz, iOff) +} + +/* +** This value is copied from the definition of ZIPVFS_CTRL_FILE_POINTER +** in zipvfs.h. + */ + +func _rbuPutU16(tls *libc.TLS, aBuf uintptr, iVal Tu16) { + **(**Tu8)(__ccgo_up(aBuf)) = libc.Uint8FromInt32(libc.Int32FromUint16(iVal) >> int32(8) & int32(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 1)) = libc.Uint8FromInt32(libc.Int32FromUint16(iVal) >> 0 & int32(0xFF)) +} + +// C documentation +// +// /* +// ** Return the current wal-index header checksum for the target database +// ** as a 64-bit integer. +// ** +// ** The checksum is store in the first page of xShmMap memory as an 8-byte +// ** blob starting at byte offset 40. +// */ +func _rbuShmChecksum(tls *libc.TLS, p uintptr) (r Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iRet Ti64 + var pDb uintptr + var _ /* ptr at bp+0 */ uintptr + _, _ = iRet, pDb + iRet = 0 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxShmMap})))(tls, pDb, 0, libc.Int32FromInt32(32)*libc.Int32FromInt32(1024), 0, bp) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + iRet = libc.Int64FromUint64(uint64(libc.AtomicLoadPUint32(**(**uintptr)(__ccgo_up(bp))+libc.UintptrFromInt32(10)*4))< SELECT ..." can +// ** run without using a temporary table for the results of the SELECT. +// */ +func _readsTable(tls *libc.TLS, p uintptr, iDb int32, pTab uintptr) (r int32) { + var i, iEnd int32 + var pIndex, pOp, pVTab, v, v1 uintptr + var tnum TPgno + _, _, _, _, _, _, _, _ = i, iEnd, pIndex, pOp, pVTab, tnum, v, v1 + v = _sqlite3GetVdbe(tls, p) + iEnd = _sqlite3VdbeCurrentAddr(tls, v) + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + v1 = _sqlite3GetVTable(tls, (*TParse)(unsafe.Pointer(p)).Fdb, pTab) + } else { + v1 = uintptr(0) + } + pVTab = v1 + i = int32(1) + for { + if !(i < iEnd) { + break + } + pOp = _sqlite3VdbeGetOp(tls, v, i) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_OpenRead) && (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 == iDb { + tnum = libc.Uint32FromInt32((*TVdbeOp)(unsafe.Pointer(pOp)).Fp2) + if tnum == (*TTable)(unsafe.Pointer(pTab)).Ftnum { + return int32(1) + } + pIndex = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIndex != 0) { + break + } + if tnum == (*TIndex)(unsafe.Pointer(pIndex)).Ftnum { + return int32(1) + } + goto _3 + _3: + ; + pIndex = (*TIndex)(unsafe.Pointer(pIndex)).FpNext + } + } + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_VOpen) && *(*uintptr)(unsafe.Pointer(pOp + 16)) == pVTab { + return int32(1) + } + goto _2 + _2: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Release a unixInodeInfo structure previously allocated by findInodeInfo(). +// ** +// ** The global mutex must be held when this routine is called, but the mutex +// ** on the inode being deleted must NOT be held. +// */ +func _releaseInodeInfo(tls *libc.TLS, pFile uintptr) { + var pInode uintptr + _ = pInode + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + if pInode != 0 { + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnRef = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnRef - 1 + if (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnRef == 0 { + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + _closePendingFds(tls, pFile) + Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + if (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpPrev != 0 { + (*TunixInodeInfo)(unsafe.Pointer((*TunixInodeInfo)(unsafe.Pointer(pInode)).FpPrev)).FpNext = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpNext + } else { + _inodeList = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpNext + } + if (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpNext != 0 { + (*TunixInodeInfo)(unsafe.Pointer((*TunixInodeInfo)(unsafe.Pointer(pInode)).FpNext)).FpPrev = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpPrev + } + Xsqlite3_mutex_free(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + Xsqlite3_free(tls, pInode) + } + } +} + +// C documentation +// +// /* +// ** This is a Walker select callback. It does nothing. It is only required +// ** because without a dummy callback, sqlite3WalkExpr() and similar do not +// ** descend into sub-select statements. +// */ +func _renameColumnSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + if (*TSelect)(unsafe.Pointer(p)).FselFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SF_View)|libc.Int32FromInt32(SF_CopyCte)) != 0 { + return int32(WRC_Prune) + } + _renameWalkWith(tls, pWalker, p) + return WRC_Continue +} + +// C documentation +// +// /* +// ** Resolve an expression that was part of an ATTACH or DETACH statement. This +// ** is slightly different from resolving a normal SQL expression, because simple +// ** identifiers are treated as strings, not possible column names or aliases. +// ** +// ** i.e. if the parser sees: +// ** +// ** ATTACH DATABASE abc AS def +// ** +// ** it treats the two expressions as literal strings 'abc' and 'def' instead of +// ** looking for columns of the same name. +// ** +// ** This only applies to the root node of pExpr, so the statement: +// ** +// ** ATTACH DATABASE abc||def AS 'db2' +// ** +// ** will fail because neither abc or def can be resolved. +// */ +func _resolveAttachExpr(tls *libc.TLS, pName uintptr, pExpr uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if pExpr != 0 { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_ID) { + rc = _sqlite3ResolveExprNames(tls, pName, pExpr) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_STRING) + } + } + return rc +} + +// C documentation +// +// /* +// ** Rtree virtual table module xClose method. +// */ +func _rtreeClose(tls *libc.TLS, cur uintptr) (r int32) { + var pCsr, pRtree uintptr + _, _ = pCsr, pRtree + pRtree = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab + pCsr = cur + _resetCursor(tls, pCsr) + Xsqlite3_finalize(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) + Xsqlite3_free(tls, pCsr) + (*TRtree)(unsafe.Pointer(pRtree)).FnCursor = (*TRtree)(unsafe.Pointer(pRtree)).FnCursor - 1 + if (*TRtree)(unsafe.Pointer(pRtree)).FnCursor == uint32(0) && libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans) == 0 { + _nodeBlobReset(tls, pRtree) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Rtree virtual table module xEof method. +// ** +// ** Return non-zero if the cursor does not currently point to a valid +// ** record (i.e if the scan has finished), or zero otherwise. +// */ +func _rtreeEof(tls *libc.TLS, cur uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = cur + return libc.Int32FromUint8((*TRtreeCursor)(unsafe.Pointer(pCsr)).FatEOF) +} + +/* +** Convert raw bits from the on-disk RTree record into a coordinate value. +** The on-disk format is big-endian and needs to be converted for little- +** endian platforms. The on-disk record stores integer coordinates if +** eInt is true and it stores 32-bit floating point records if eInt is +** false. a[] is the four bytes of the on-disk record to be decoded. +** Store the results in "r". +** +** There are five versions of this macro. The last one is generic. The +** other four are various architectures-specific optimizations. + */ + +// C documentation +// +// /* +// ** Rtree virtual table module xRowid method. +// */ +func _rtreeRowid(tls *libc.TLS, pVtabCursor uintptr, pRowid uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var p, pCsr, pNode uintptr + var _ /* rc at bp+0 */ int32 + _, _, _ = p, pCsr, pNode + pCsr = pVtabCursor + p = _rtreeSearchPointFirst(tls, pCsr) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + pNode = _rtreeNodeOfFirstSearchPoint(tls, pCsr, bp) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && p != 0 { + if libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell) >= _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ABORT) + } else { + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = _nodeGetRowid(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, pNode, libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(p)).FiCell)) + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Compare two search points. Return negative, zero, or positive if the first +// ** is less than, equal to, or greater than the second. +// ** +// ** The rScore is the primary key. Smaller rScore values come first. +// ** If the rScore is a tie, then use iLevel as the tie breaker with smaller +// ** iLevel values coming first. In this way, if rScore is the same for all +// ** SearchPoints, then iLevel becomes the deciding factor and the result +// ** is a depth-first search, which is the desired default behavior. +// */ +func _rtreeSearchPointCompare(tls *libc.TLS, pA uintptr, pB uintptr) (r int32) { + if (*TRtreeSearchPoint)(unsafe.Pointer(pA)).FrScore < (*TRtreeSearchPoint)(unsafe.Pointer(pB)).FrScore { + return -int32(1) + } + if (*TRtreeSearchPoint)(unsafe.Pointer(pA)).FrScore > (*TRtreeSearchPoint)(unsafe.Pointer(pB)).FrScore { + return +libc.Int32FromInt32(1) + } + if libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(pA)).FiLevel) < libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(pB)).FiLevel) { + return -int32(1) + } + if libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(pA)).FiLevel) > libc.Int32FromUint8((*TRtreeSearchPoint)(unsafe.Pointer(pB)).FiLevel) { + return +libc.Int32FromInt32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** This is the collating function named "RTRIM" which is always +// ** available. Ignore trailing spaces. +// */ +func _rtrimCollFunc(tls *libc.TLS, pUser uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) (r int32) { + var pK1, pK2 uintptr + _, _ = pK1, pK2 + pK1 = pKey1 + pK2 = pKey2 + for nKey1 != 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pK1 + uintptr(nKey1-int32(1))))) == int32(' ') { + nKey1 = nKey1 - 1 + } + for nKey2 != 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pK2 + uintptr(nKey2-int32(1))))) == int32(' ') { + nKey2 = nKey2 - 1 + } + return _binCollFunc(tls, pUser, nKey1, pKey1, nKey2, pKey2) +} + +// C documentation +// +// /* +// ** Save the current cursor position in the variables BtCursor.nKey +// ** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK. +// ** +// ** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID) +// ** prior to calling this routine. +// */ +func _saveCursorPosition(tls *libc.TLS, pCur uintptr) (r int32) { + var rc int32 + var v1 uintptr + _, _ = rc, v1 + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_Pinned) != 0 { + return libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(11)< int64((*TSessionBuffer)(unsafe.Pointer(p)).FnAlloc) { + if (*TSessionBuffer)(unsafe.Pointer(p)).FnAlloc != 0 { + v1 = (*TSessionBuffer)(unsafe.Pointer(p)).FnAlloc + } else { + v1 = int32(128) + } + nNew = int64(v1) + for cond := true; cond; cond = nNew < nReq { + nNew = nNew * int64(2) + } + /* The value of SESSION_MAX_BUFFER_SZ is copied from the implementation + ** of sqlite3_realloc64(). Allocations greater than this size in bytes + ** always fail. It is used here to ensure that this routine can always + ** allocate up to this limit - instead of up to the largest power of + ** two smaller than the limit. */ + if nNew > int64(libc.Int32FromInt32(0x7FFFFF00)-libc.Int32FromInt32(1)) { + nNew = int64(libc.Int32FromInt32(0x7FFFFF00) - libc.Int32FromInt32(1)) + if nNew < nReq { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + return int32(1) + } + } + aNew = Xsqlite3_realloc64(tls, (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf, libc.Uint64FromInt64(nNew)) + if uintptr(0) == aNew { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } else { + (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf = aNew + (*TSessionBuffer)(unsafe.Pointer(p)).FnAlloc = int32(nNew) + } + } + return libc.BoolInt32(**(**int32)(__ccgo_up(pRc)) != SQLITE_OK) +} + +// C documentation +// +// /* +// ** Based on the primary key values stored in change aRecord, calculate a +// ** hash key. Assume the has table has nBucket buckets. The hash keys +// ** calculated by this function are compatible with those calculated by +// ** sessionPreupdateHash(). +// ** +// ** The bPkOnly argument is non-zero if the record at aRecord[] is from +// ** a patchset DELETE. In this case the non-PK fields are omitted entirely. +// */ +func _sessionChangeHash(tls *libc.TLS, pTab uintptr, bPkOnly int32, aRecord uintptr, nBucket int32) (r uint32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, v2 uintptr + var eType, i, isPK int32 + var h uint32 + var _ /* n at bp+0 */ int32 + _, _, _, _, _, _ = a, eType, h, i, isPK, v2 + h = uint32(0) /* Used to iterate through columns */ + a = aRecord /* Used to iterate through change record */ + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnCol) { + break + } + isPK = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i)))) + if bPkOnly != 0 && isPK == 0 { + goto _1 + } + if isPK != 0 { + v2 = a + a = a + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v2))) + h = _sessionHashAppendType(tls, h, eType) + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + h = _sessionHashAppendI64(tls, h, _sessionGetI64(tls, a)) + a = a + uintptr(8) + } else { + if eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB) { + a = a + uintptr(_sessionVarintGet(tls, a, bp)) + h = _sessionHashAppendBlob(tls, h, **(**int32)(__ccgo_up(bp)), a) + a = a + uintptr(**(**int32)(__ccgo_up(bp))) + } + } + /* It should not be possible for eType to be SQLITE_NULL or 0x00 here, + ** as the session module does not record changes for rows with NULL + ** values stored in primary key columns. But a corrupt changesets + ** may contain such a value. */ + } else { + a = a + uintptr(_sessionSerialLen(tls, a)) + } + goto _1 + _1: + ; + i = i + 1 + } + return h % libc.Uint32FromInt32(nBucket) +} + +// C documentation +// +// /* +// ** The input pointer currently points to the first byte of the first field +// ** of a record consisting of nCol columns. This function ensures the entire +// ** record is buffered. It does not move the input pointer. +// ** +// ** If successful, SQLITE_OK is returned and *pnByte is set to the size of +// ** the record in bytes. Otherwise, an SQLite error code is returned. The +// ** final value of *pnByte is undefined in this case. +// */ +func _sessionChangesetBufferRecord(tls *libc.TLS, pIn uintptr, nCol int32, pnByte uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var eType, i, nRem, rc int32 + var nByte, v2 Ti64 + var _ /* n at bp+0 */ int32 + _, _, _, _, _, _ = eType, i, nByte, nRem, rc, v2 + rc = SQLITE_OK + nByte = 0 + i = 0 + for { + if !(rc == SQLITE_OK && i < nCol) { + break + } + rc = _sessionInputBuffer(tls, pIn, int32(nByte+int64(10))) + if rc == SQLITE_OK { + v2 = nByte + nByte = nByte + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pIn)).FaData + uintptr(int64((*TSessionInput)(unsafe.Pointer(pIn)).FiNext)+v2)))) + if eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB) { + nRem = int32(int64((*TSessionInput)(unsafe.Pointer(pIn)).FnData) - (int64((*TSessionInput)(unsafe.Pointer(pIn)).FiNext) + nByte)) + nByte = nByte + int64(_sessionVarintGetSafe(tls, (*TSessionInput)(unsafe.Pointer(pIn)).FaData+uintptr(int64((*TSessionInput)(unsafe.Pointer(pIn)).FiNext)+nByte), nRem, bp)) + nByte = nByte + int64(**(**int32)(__ccgo_up(bp))) + rc = _sessionInputBuffer(tls, pIn, int32(nByte)) + } else { + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + nByte = nByte + int64(8) + } else { + if eType != 0 && eType != int32(SQLITE_NULL) { + rc = _sqlite3CorruptError(tls, int32(237226)) + } + } + } + } + if rc == SQLITE_OK && int64((*TSessionInput)(unsafe.Pointer(pIn)).FiNext)+nByte > int64((*TSessionInput)(unsafe.Pointer(pIn)).FnData) { + rc = _sqlite3CorruptError(tls, int32(237230)) + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(pnByte)) = int32(nByte) + return rc +} + +// C documentation +// +// /* +// ** Read a 64-bit big-endian integer value from buffer aRec[]. Return +// ** the value read. +// */ +func _sessionGetI64(tls *libc.TLS, aRec uintptr) (r Tsqlite3_int64) { + var x Tu64 + var y Tu32 + _, _ = x, y + x = uint64(uint32(**(**Tu8)(__ccgo_up(aRec)))<>libc.Int32FromInt32(32)&libc.Int64FromUint32(0xFFFFFFFF)) +} + +// C documentation +// +// /* +// ** Append the hash of the data type passed as the second argument to the +// ** hash-key value passed as the first. Return the new hash-key value. +// */ +func _sessionHashAppendType(tls *libc.TLS, h uint32, eType int32) (r uint32) { + return h<> libc.Int32FromInt32(56) & int64(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 1)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(48) & int64(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 2)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(40) & int64(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 3)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(32) & int64(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 4)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(24) & int64(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 5)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(16) & int64(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 6)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(8) & int64(0xFF)) + **(**Tu8)(__ccgo_up(aBuf + 7)) = libc.Uint8FromInt64(i >> libc.Int32FromInt32(0) & int64(0xFF)) +} + +// C documentation +// +// /* +// ** The buffer that the argument points to contains a serialized SQL value. +// ** Return the number of bytes of space occupied by the value (including +// ** the type byte). +// */ +func _sessionSerialLen(tls *libc.TLS, a uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var _ /* n at bp+0 */ int32 + _ = e + e = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a))) + if e == int32(SQLITE_INTEGER) || e == int32(SQLITE_FLOAT) { + return int32(9) + } + if e == int32(SQLITE_TEXT) || e == int32(SQLITE_BLOB) { + return _sessionVarintGet(tls, a+1, bp) + int32(1) + **(**int32)(__ccgo_up(bp)) + } + return int32(1) +} + +// C documentation +// +// /* +// ** When this function is called, *ppRec points to the start of a record +// ** that contains nCol values. This function advances the pointer *ppRec +// ** until it points to the byte immediately following that record. +// */ +func _sessionSkipRecord(tls *libc.TLS, ppRec uintptr, nCol int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aRec, v2 uintptr + var eType, i int32 + var _ /* nByte at bp+0 */ int32 + _, _, _, _ = aRec, eType, i, v2 + aRec = **(**uintptr)(__ccgo_up(ppRec)) + i = 0 + for { + if !(i < nCol) { + break + } + v2 = aRec + aRec = aRec + 1 + eType = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v2))) + if eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB) { + aRec = aRec + uintptr(_sessionVarintGet(tls, aRec, bp)) + aRec = aRec + uintptr(**(**int32)(__ccgo_up(bp))) + } else { + if eType == int32(SQLITE_INTEGER) || eType == int32(SQLITE_FLOAT) { + aRec = aRec + uintptr(8) + } + } + goto _1 + _1: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up(ppRec)) = aRec +} + +// C documentation +// +// /* +// ** Read a varint value from aBuf[] into *piVal. Return the number of +// ** bytes read. +// */ +func _sessionVarintGet(tls *libc.TLS, aBuf uintptr, piVal uintptr) (r int32) { + var v1 int32 + _ = v1 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aBuf))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**int32)(__ccgo_up(piVal)) = libc.Int32FromUint32(uint32(**(**Tu8)(__ccgo_up(aBuf)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, aBuf, piVal)) + } + return libc.Int32FromUint8(libc.Uint8FromInt32(v1)) +} + +// C documentation +// +// /* +// ** Return the number of bytes required to store value iVal as a varint. +// */ +func _sessionVarintLen(tls *libc.TLS, iVal int32) (r int32) { + return _sqlite3VarintLen(tls, libc.Uint64FromInt32(iVal)) +} + +// C documentation +// +// /* +// ** Write a varint with value iVal into the buffer at aBuf. Return the +// ** number of bytes written. +// */ +func _sessionVarintPut(tls *libc.TLS, aBuf uintptr, iVal int32) (r int32) { + var v1 int32 + _ = v1 + if libc.Uint32FromInt32(iVal) < libc.Uint32FromInt32(0x80) { + **(**Tu8)(__ccgo_up(aBuf)) = libc.Uint8FromInt32(iVal) + v1 = libc.Int32FromInt32(1) + } else { + v1 = _sqlite3PutVarint(tls, aBuf, libc.Uint64FromInt32(iVal)) + } + return libc.Int32FromUint8(libc.Uint8FromInt32(v1)) +} + +// C documentation +// +// /* +// ** If the last opcode is a OP_Copy, then set the do-not-merge flag (p5) +// ** so that a subsequent copy will not be merged into this one. +// */ +func _setDoNotMergeFlagOnCopy(tls *libc.TLS, v uintptr) { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetLastOp(tls, v))).Fopcode) == int32(OP_Copy) { + _sqlite3VdbeChangeP5(tls, v, uint16(1)) /* Tag trailing OP_Copy as not mergeable */ + } +} + +// C documentation +// +// /* +// ** Add the file descriptor used by file handle pFile to the corresponding +// ** pUnused list. +// */ +func _setPendingFd(tls *libc.TLS, pFile uintptr) { + var p, pInode uintptr + _, _ = p, pInode + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + p = (*TunixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused + (*TUnixUnusedFd)(unsafe.Pointer(p)).FpNext = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpUnused + (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpUnused = p + (*TunixFile)(unsafe.Pointer(pFile)).Fh = -int32(1) + (*TunixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused = uintptr(0) +} + +// C documentation +// +// /* +// ** Set result column names for a pragma. +// */ +func _setPragmaResultColumnNames(tls *libc.TLS, v uintptr, pPragma uintptr) { + var i, j, v1 int32 + var n Tu8 + _, _, _, _ = i, j, n, v1 + n = (*TPragmaName)(unsafe.Pointer(pPragma)).FnPragCName + if libc.Int32FromUint8(n) == 0 { + v1 = int32(1) + } else { + v1 = libc.Int32FromUint8(n) + } + _sqlite3VdbeSetNumCols(tls, v, v1) + if libc.Int32FromUint8(n) == 0 { + _sqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, (*TPragmaName)(unsafe.Pointer(pPragma)).FzName, libc.UintptrFromInt32(0)) + } else { + i = 0 + j = libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FiPragCName) + for { + if !(i < libc.Int32FromUint8(n)) { + break + } + _sqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, _pragCName[j], libc.UintptrFromInt32(0)) + goto _2 + _2: + ; + i = i + 1 + j = j + 1 + } + } +} + +// C documentation +// +// /* +// ** Set the value of the Pager.sectorSize variable for the given +// ** pager based on the value returned by the xSectorSize method +// ** of the open database file. The sector size will be used +// ** to determine the size and alignment of journal header and +// ** super-journal pointers within created journal files. +// ** +// ** For temporary files the effective sector size is always 512 bytes. +// ** +// ** Otherwise, for non-temporary files, the effective sector size is +// ** the value returned by the xSectorSize() method rounded up to 32 if +// ** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it +// ** is greater than MAX_SECTOR_SIZE. +// ** +// ** If the file has the SQLITE_IOCAP_POWERSAFE_OVERWRITE property, then set +// ** the effective sector size to its minimum value (512). The purpose of +// ** pPager->sectorSize is to define the "blast radius" of bytes that +// ** might change if a crash occurs while writing to a single byte in +// ** that range. But with POWERSAFE_OVERWRITE, the blast radius is zero +// ** (that is what POWERSAFE_OVERWRITE means), so we minimize the sector +// ** size. For backwards compatibility of the rollback journal file format, +// ** we cannot reduce the effective sector size below 512. +// */ +func _setSectorSize(tls *libc.TLS, pPager uintptr) { + if (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 || _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd)&int32(SQLITE_IOCAP_POWERSAFE_OVERWRITE) != 0 { + /* Sector size doesn't matter for temporary files. Also, the file + ** may not have been opened yet, in which case the OsSectorSize() + ** call will segfault. */ + (*TPager)(unsafe.Pointer(pPager)).FsectorSize = uint32(512) + } else { + (*TPager)(unsafe.Pointer(pPager)).FsectorSize = libc.Uint32FromInt32(_sqlite3SectorSize(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd)) + } +} + +// C documentation +// +// /* +// ** The string z[] is an text representation of a real number. +// ** Convert this string to a double and write it into *pResult. +// ** +// ** z[] must be UTF-8 and zero-terminated. +// ** +// ** Return positive if the result is a valid real number (or integer) and +// ** zero or negative if the string is empty or contains extraneous text. +// ** Lower bits of the return value contain addition information about the +// ** parse: +// ** +// ** bit 0 => Set if any prefix of the input is valid. Clear if +// ** there is no prefix of the input that can be seen as +// ** a valid floating point number. +// ** bit 1 => Set if the input contains a decimal point or eNNN +// ** clause. Zero if the input is an integer. +// ** bit 2 => The input is exactly 0.0, not an underflow from +// ** some value near zero. +// ** bit 3 => Set if there are more than about 19 significant +// ** digits in the input. +// ** +// ** If the input contains a syntax error but begins with text that might +// ** be a valid number of some kind, then the result is negative. The +// ** result is only zero if no prefix of the input could be interpreted as +// ** a number. +// ** +// ** Leading and trailing whitespace is ignored. Valid numbers are in +// ** one of the formats below: +// ** +// ** [+-]digits[E[+-]digits] +// ** [+-]digits.[digits][E[+-]digits] +// ** [+-].digits[E[+-]digits] +// ** +// ** Algorithm sketch: Compute an unsigned 64-bit integer s and a base-10 +// ** exponent d such that the value encoding by the input is s*pow(10,d). +// ** Then invoke sqlite3Fp10Convert2() to calculated the closest possible +// ** IEEE754 double. The sign is added back afterwards, if the input string +// ** starts with a "-". The use of an unsigned 64-bit s mantissa means that +// ** only about the first 19 significant digits of the input can contribute +// ** to the result. This can result in suboptimal rounding decisions when +// ** correct rounding requires more than 19 input digits. For example, +// ** this routine renders "3500000000000000.2500001" as +// ** 3500000000000000.0 instead of 3500000000000000.5 because the decision +// ** to round up instead of using banker's rounding to round down is determined +// ** by the 23rd significant digit, which this routine ignores. It is not +// ** possible to do better without some kind of BigNum. +// */ +func _sqlite3AtoF(tls *libc.TLS, zIn uintptr, pResult uintptr) (r int32) { + var d, esign, exp, mState, neg int32 + var s Tu64 + var v, v3, v4 uint32 + var z, v7 uintptr + _, _, _, _, _, _, _, _, _, _, _ = d, esign, exp, mState, neg, s, v, z, v3, v4, v7 + z = zIn + neg = 0 /* True for a negative value */ + s = uint64(0) /* mantissa */ + d = 0 /* Value is s * pow(10,d) */ + mState = 0 /* Value of a single digit */ + goto start_of_text +start_of_text: + ; + v3 = uint32(**(**uint8)(__ccgo_up(z))) - libc.Uint32FromUint8('0') + v = v3 + if !(v3 < uint32(10)) { + goto _1 + } + goto parse_integer_part +parse_integer_part: + ; + mState = int32(1) + s = uint64(v) + z = z + 1 + for { + v3 = uint32(**(**uint8)(__ccgo_up(z))) - libc.Uint32FromUint8('0') + v = v3 + if !(v3 < uint32(10)) { + break + } + s = s*uint64(10) + uint64(v) + z = z + 1 + if s >= (libc.Uint64FromUint32(0xffffffff)|libc.Uint64FromUint32(0xffffffff)< 0 { + goto bitvec_end + } + /* NULL pBitvec tests */ + _sqlite3BitvecSet(tls, uintptr(0), uint32(1)) + _sqlite3BitvecClear(tls, uintptr(0), uint32(1), pTmpSpace) + /* Run the program */ + v1 = libc.Int32FromInt32(0) + **(**int32)(__ccgo_up(bp)) = v1 + pc = v1 + for { + v1 = **(**int32)(__ccgo_up(aOp + uintptr(pc)*4)) + op = v1 + if !(v1 != 0) { + break + } + if op >= int32(6) { + pc = pc + 1 + continue + } + switch op { + case int32(1): + fallthrough + case int32(2): + fallthrough + case int32(5): + nx = int32(4) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(aOp + uintptr(pc+int32(2))*4)) - int32(1) + **(**int32)(__ccgo_up(aOp + uintptr(pc+int32(2))*4)) += **(**int32)(__ccgo_up(aOp + uintptr(pc+int32(3))*4)) + case int32(3): + fallthrough + case int32(4): + fallthrough + default: + nx = int32(2) + Xsqlite3_randomness(tls, int32(4), bp) + break + } + v4 = aOp + uintptr(pc+int32(1))*4 + *(*int32)(unsafe.Pointer(v4)) = *(*int32)(unsafe.Pointer(v4)) - 1 + v1 = *(*int32)(unsafe.Pointer(v4)) + if v1 > 0 { + nx = 0 + } + pc = pc + nx + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) & int32(0x7fffffff) % sz + if op&int32(1) != 0 { + if pV != 0 { + v4 = pV + uintptr((**(**int32)(__ccgo_up(bp))+int32(1))>>int32(3)) + *(*uint8)(unsafe.Pointer(v4)) = uint8(int32(*(*uint8)(unsafe.Pointer(v4))) | libc.Int32FromInt32(1)<<((**(**int32)(__ccgo_up(bp))+libc.Int32FromInt32(1))&libc.Int32FromInt32(7))) + } + if op != int32(5) { + if _sqlite3BitvecSet(tls, pBitvec, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp))+int32(1))) != 0 { + goto bitvec_end + } + } + } else { + if pV != 0 { + v4 = pV + uintptr((**(**int32)(__ccgo_up(bp))+int32(1))>>int32(3)) + *(*uint8)(unsafe.Pointer(v4)) = uint8(int32(*(*uint8)(unsafe.Pointer(v4))) & ^libc.Int32FromUint8(libc.Uint8FromInt32(libc.Int32FromInt32(1)<<((**(**int32)(__ccgo_up(bp))+libc.Int32FromInt32(1))&libc.Int32FromInt32(7))))) + } + _sqlite3BitvecClear(tls, pBitvec, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp))+int32(1)), pTmpSpace) + } + } + /* Test to make sure the linear array exactly matches the + ** Bitvec object. Start with the assumption that they do + ** match (rc==0). Change rc to non-zero if a discrepancy + ** is found. + */ + if pV != 0 { + rc = libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3BitvecTest(tls, uintptr(0), uint32(0))+_sqlite3BitvecTest(tls, pBitvec, libc.Uint32FromInt32(sz+int32(1)))+_sqlite3BitvecTest(tls, pBitvec, uint32(0))) + (_sqlite3BitvecSize(tls, pBitvec) - libc.Uint32FromInt32(sz))) + **(**int32)(__ccgo_up(bp)) = int32(1) + for { + if !(**(**int32)(__ccgo_up(bp)) <= sz) { + break + } + if libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(pV + uintptr(**(**int32)(__ccgo_up(bp))>>int32(3)))))&(int32(1)<<(**(**int32)(__ccgo_up(bp))&int32(7))) != 0) != _sqlite3BitvecTest(tls, pBitvec, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp)))) { + rc = **(**int32)(__ccgo_up(bp)) + break + } + goto _7 + _7: + ; + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + } + } else { + rc = 0 + } + /* Free allocated structure */ + goto bitvec_end +bitvec_end: + ; + Xsqlite3_free(tls, pTmpSpace) + Xsqlite3_free(tls, pV) + _sqlite3BitvecDestroy(tls, pBitvec) + return rc +} + +/********************************** Test and Debug Logic **********************/ +/* +** Debug tracing macros. Enable by by changing the "0" to "1" and +** recompiling. +** +** When sqlite3PcacheTrace is 1, single line trace messages are issued. +** When sqlite3PcacheTrace is 2, a dump of the pcache showing all cache entries +** is displayed for many operations, resulting in a lot of output. + */ + +/* +** Return 1 if pPg is on the dirty list for pCache. Return 0 if not. +** This routine runs inside of assert() statements only. + */ + +/* +** Check invariants on a PgHdr entry. Return true if everything is OK. +** Return false if any invariant is violated. +** +** This routine is for use inside of assert() statements only. For +** example: +** +** assert( sqlite3PcachePageSanity(pPg) ); + */ + +/********************************** Linked List Management ********************/ + +/* Allowed values for second argument to pcacheManageDirtyList() */ + +func _sqlite3BtreeBeginTrans(tls *libc.TLS, p uintptr, wrflag int32, pSchemaVersion uintptr) (r int32) { + var pBt uintptr + _ = pBt + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 || libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == TRANS_NONE || libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == int32(TRANS_READ) && wrflag != 0 { + return _btreeBeginTrans(tls, p, wrflag, pSchemaVersion) + } + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + if pSchemaVersion != 0 { + **(**int32)(__ccgo_up(pSchemaVersion)) = libc.Int32FromUint32(_sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+40)) + } + if wrflag != 0 { + /* This call makes sure that the pager has the correct number of + ** open savepoints. If the second parameter is greater than 0 and + ** the sub-journal is not already open, then it will be opened here. + */ + return _sqlite3PagerOpenSavepoint(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, (*Tsqlite3)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).Fdb)).FnSavepoint) + } else { + return SQLITE_OK + } + return r +} + +// C documentation +// +// /* +// ** Run a checkpoint on the Btree passed as the first argument. +// ** +// ** Return SQLITE_LOCKED if this or any other connection has an open +// ** transaction on the shared-cache the argument Btree is connected to. +// ** +// ** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART. +// */ +func _sqlite3BtreeCheckpoint(tls *libc.TLS, p uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) (r int32) { + var pBt uintptr + var rc int32 + _, _ = pBt, rc + rc = SQLITE_OK + if p != 0 { + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + if libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FinTransaction) != TRANS_NONE { + rc = int32(SQLITE_LOCKED) + } else { + rc = _sqlite3PagerCheckpoint(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, (*TBtree)(unsafe.Pointer(p)).Fdb, eMode, pnLog, pnCkpt) + } + _sqlite3BtreeLeave(tls, p) + } + return rc +} + +// C documentation +// +// /* +// ** If no transaction is active and the database is not a temp-db, clear +// ** the in-memory pager cache. +// */ +func _sqlite3BtreeClearCache(tls *libc.TLS, p uintptr) { + var pBt uintptr + _ = pBt + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + if libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE { + _sqlite3PagerClearCache(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + } +} + +// C documentation +// +// /* +// ** Delete all information from a single table in the database. iTable is +// ** the page number of the root of the table. After this routine returns, +// ** the root page is empty, but still exists. +// ** +// ** This routine will fail with SQLITE_LOCKED if there are any open +// ** read cursors on the table. Open write cursors are moved to the +// ** root of the table. +// ** +// ** If pnChange is not NULL, then the integer value pointed to by pnChange +// ** is incremented by the number of entries in the table. +// */ +func _sqlite3BtreeClearTable(tls *libc.TLS, p uintptr, iTable int32, pnChange uintptr) (r int32) { + var pBt uintptr + var rc int32 + _, _ = pBt, rc + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + rc = _saveAllCursors(tls, pBt, libc.Uint32FromInt32(iTable), uintptr(0)) + if SQLITE_OK == rc { + /* Invalidate all incrblob cursors open on table iTable (assuming iTable + ** is the root of a table b-tree - if it is not, the following call is + ** a no-op). */ + if (*TBtree)(unsafe.Pointer(p)).FhasIncrblobCur != 0 { + _invalidateIncrblobCursors(tls, p, libc.Uint32FromInt32(iTable), 0, int32(1)) + } + rc = _clearDatabasePage(tls, pBt, libc.Uint32FromInt32(iTable), 0, pnChange) + } + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Delete all information from the single table that pCur is open on. +// ** +// ** This routine only work for pCur on an ephemeral table. +// */ +func _sqlite3BtreeClearTableOfCursor(tls *libc.TLS, pCur uintptr) (r int32) { + return _sqlite3BtreeClearTable(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree, libc.Int32FromUint32((*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot), uintptr(0)) +} + +// C documentation +// +// /* +// ** Close a cursor. The read lock on the database file is released +// ** when the last cursor is closed. +// */ +func _sqlite3BtreeCloseCursor(tls *libc.TLS, pCur uintptr) (r int32) { + var pBt, pBtree, pPrev uintptr + _, _, _ = pBt, pBtree, pPrev + pBtree = (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree + if pBtree != 0 { + pBt = (*TBtCursor)(unsafe.Pointer(pCur)).FpBt + _sqlite3BtreeEnter(tls, pBtree) + if (*TBtShared)(unsafe.Pointer(pBt)).FpCursor == pCur { + (*TBtShared)(unsafe.Pointer(pBt)).FpCursor = (*TBtCursor)(unsafe.Pointer(pCur)).FpNext + } else { + pPrev = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor + for cond := true; cond; cond = pPrev != 0 { + if (*TBtCursor)(unsafe.Pointer(pPrev)).FpNext == pCur { + (*TBtCursor)(unsafe.Pointer(pPrev)).FpNext = (*TBtCursor)(unsafe.Pointer(pCur)).FpNext + break + } + pPrev = (*TBtCursor)(unsafe.Pointer(pPrev)).FpNext + } + } + _btreeReleaseAllCursorPages(tls, pCur) + _unlockBtreeIfUnused(tls, pBt) + Xsqlite3_free(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FaOverflow) + Xsqlite3_free(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpKey) + if libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FopenFlags)&int32(BTREE_SINGLE) != 0 && (*TBtShared)(unsafe.Pointer(pBt)).FpCursor == uintptr(0) { + /* Since the BtShared is not sharable, there is no need to + ** worry about the missing sqlite3BtreeLeave() call here. */ + _sqlite3BtreeClose(tls, pBtree) + } else { + _sqlite3BtreeLeave(tls, pBtree) + } + (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree = uintptr(0) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This routine does the first phase of a two-phase commit. This routine +// ** causes a rollback journal to be created (if it does not already exist) +// ** and populated with enough information so that if a power loss occurs +// ** the database can be restored to its original state by playing back +// ** the journal. Then the contents of the journal are flushed out to +// ** the disk. After the journal is safely on oxide, the changes to the +// ** database are written into the database file and flushed to oxide. +// ** At the end of this call, the rollback journal still exists on the +// ** disk and we are still holding all locks, so the transaction has not +// ** committed. See sqlite3BtreeCommitPhaseTwo() for the second phase of the +// ** commit process. +// ** +// ** This call is a no-op if no write-transaction is currently active on pBt. +// ** +// ** Otherwise, sync the database file for the btree pBt. zSuperJrnl points to +// ** the name of a super-journal file that should be written into the +// ** individual journal file, or is NULL, indicating no super-journal file +// ** (single database transaction). +// ** +// ** When this is called, the super-journal should already have been +// ** created, populated with this journal pointer and synced to disk. +// ** +// ** Once this is routine has returned, the only thing required to commit +// ** the write-transaction for this database file is to delete the journal. +// */ +func _sqlite3BtreeCommitPhaseOne(tls *libc.TLS, p uintptr, zSuperJrnl uintptr) (r int32) { + var pBt uintptr + var rc int32 + _, _ = pBt, rc + rc = SQLITE_OK + if libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == int32(TRANS_WRITE) { + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + rc = _autoVacuumCommit(tls, p) + if rc != SQLITE_OK { + _sqlite3BtreeLeave(tls, p) + return rc + } + } + if (*TBtShared)(unsafe.Pointer(pBt)).FbDoTruncate != 0 { + _sqlite3PagerTruncateImage(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, (*TBtShared)(unsafe.Pointer(pBt)).FnPage) + } + rc = _sqlite3PagerCommitPhaseOne(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, zSuperJrnl, 0) + _sqlite3BtreeLeave(tls, p) + } + return rc +} + +// C documentation +// +// /* +// ** Commit the transaction currently in progress. +// ** +// ** This routine implements the second phase of a 2-phase commit. The +// ** sqlite3BtreeCommitPhaseOne() routine does the first phase and should +// ** be invoked prior to calling this routine. The sqlite3BtreeCommitPhaseOne() +// ** routine did all the work of writing information out to disk and flushing the +// ** contents so that they are written onto the disk platter. All this +// ** routine has to do is delete or truncate or zero the header in the +// ** the rollback journal (which causes the transaction to commit) and +// ** drop locks. +// ** +// ** Normally, if an error occurs while the pager layer is attempting to +// ** finalize the underlying journal file, this function returns an error and +// ** the upper layer will attempt a rollback. However, if the second argument +// ** is non-zero then this b-tree transaction is part of a multi-file +// ** transaction. In this case, the transaction has already been committed +// ** (by deleting a super-journal file) and the caller will ignore this +// ** functions return code. So, even if an error occurs in the pager layer, +// ** reset the b-tree objects internal state to indicate that the write +// ** transaction has been closed. This is quite safe, as the pager will have +// ** transitioned to the error state. +// ** +// ** This will release the write lock on the database file. If there +// ** are no active cursors, it also releases the read lock. +// */ +func _sqlite3BtreeCommitPhaseTwo(tls *libc.TLS, p uintptr, bCleanup int32) (r int32) { + var pBt uintptr + var rc int32 + _, _ = pBt, rc + if libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == TRANS_NONE { + return SQLITE_OK + } + _sqlite3BtreeEnter(tls, p) + /* If the handle has a write-transaction open, commit the shared-btrees + ** transaction and set the shared state to TRANS_READ. + */ + if libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == int32(TRANS_WRITE) { + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + rc = _sqlite3PagerCommitPhaseTwo(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + if rc != SQLITE_OK && bCleanup == 0 { + _sqlite3BtreeLeave(tls, p) + return rc + } + (*TBtree)(unsafe.Pointer(p)).FiBDataVersion = (*TBtree)(unsafe.Pointer(p)).FiBDataVersion - 1 /* Compensate for pPager->iDataVersion++; */ + (*TBtShared)(unsafe.Pointer(pBt)).FinTransaction = uint8(TRANS_READ) + _btreeClearHasContent(tls, pBt) + } + _btreeEndTransaction(tls, p) + _sqlite3BtreeLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Determine whether or not a cursor has moved from the position where +// ** it was last placed, or has been invalidated for any other reason. +// ** Cursors can move when the row they are pointing at is deleted out +// ** from under them, for example. Cursor might also move if a btree +// ** is rebalanced. +// ** +// ** Calling this routine with a NULL cursor pointer returns false. +// ** +// ** Use the separate sqlite3BtreeCursorRestore() routine to restore a cursor +// ** back to where it ought to be if this routine returns true. +// */ +func _sqlite3BtreeCursorHasMoved(tls *libc.TLS, pCur uintptr) (r int32) { + return libc.BoolInt32(CURSOR_VALID != libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pCur)))) +} + +func _sqlite3BtreeCursorIsValidNN(tls *libc.TLS, pCur uintptr) (r int32) { + return libc.BoolInt32(libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID) +} + +// C documentation +// +// /* +// ** This routine restores a cursor back to its original position after it +// ** has been moved by some outside activity (such as a btree rebalance or +// ** a row having been deleted out from under the cursor). +// ** +// ** On success, the *pDifferentRow parameter is false if the cursor is left +// ** pointing at exactly the same row. *pDifferntRow is the row the cursor +// ** was pointing to has been deleted, forcing the cursor to point to some +// ** nearby row. +// ** +// ** This routine should only be called for a cursor that just returned +// ** TRUE from sqlite3BtreeCursorHasMoved(). +// */ +func _sqlite3BtreeCursorRestore(tls *libc.TLS, pCur uintptr, pDifferentRow uintptr) (r int32) { + var rc, v1 int32 + _, _ = rc, v1 + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) >= int32(CURSOR_REQUIRESEEK) { + v1 = _btreeRestoreCursorPosition(tls, pCur) + } else { + v1 = SQLITE_OK + } + rc = v1 + if rc != 0 { + **(**int32)(__ccgo_up(pDifferentRow)) = int32(1) + return rc + } + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { + **(**int32)(__ccgo_up(pDifferentRow)) = int32(1) + } else { + **(**int32)(__ccgo_up(pDifferentRow)) = 0 + } + return SQLITE_OK +} + +func _sqlite3BtreeDropTable(tls *libc.TLS, p uintptr, iTable int32, piMoved uintptr) (r int32) { + var rc int32 + _ = rc + _sqlite3BtreeEnter(tls, p) + rc = _btreeDropTable(tls, p, libc.Uint32FromInt32(iTable), piMoved) + _sqlite3BtreeLeave(tls, p) + return rc +} + +func _sqlite3BtreeEnterAll(tls *libc.TLS, db uintptr) { + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FnoSharedCache) == 0 { + _btreeEnterAll(tls, db) + } +} + +// C documentation +// +// /* +// ** Return TRUE if the cursor is not pointing at an entry of the table. +// ** +// ** TRUE will be returned after a call to sqlite3BtreeNext() moves +// ** past the last entry in the table or sqlite3BtreePrev() moves past +// ** the first entry. TRUE is also returned if the table is empty. +// */ +func _sqlite3BtreeEof(tls *libc.TLS, pCur uintptr) (r int32) { + /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries + ** have been deleted? This API will need to change to return an error code + ** as well as the boolean result value. + */ + return libc.BoolInt32(CURSOR_VALID != libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState)) +} + +// C documentation +// +// /* +// ** Return the currently defined page size +// */ +func _sqlite3BtreeGetPageSize(tls *libc.TLS, p uintptr) (r int32) { + return libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpageSize) +} + +// C documentation +// +// /* +// ** Return the number of bytes of space at the end of every page that +// ** are intentionally left unused. This is the "reserved" space that is +// ** sometimes used by extensions. +// ** +// ** The value returned is the larger of the current reserve size and +// ** the latest reserve size requested by SQLITE_FILECTRL_RESERVE_BYTES. +// ** The amount of reserve can only grow - never shrink. +// */ +func _sqlite3BtreeGetRequestedReserve(tls *libc.TLS, p uintptr) (r int32) { + var n1, n2, v1 int32 + _, _, _ = n1, n2, v1 + _sqlite3BtreeEnter(tls, p) + n1 = libc.Int32FromUint8((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FnReserveWanted) + n2 = _sqlite3BtreeGetReserveNoMutex(tls, p) + _sqlite3BtreeLeave(tls, p) + if n1 > n2 { + v1 = n1 + } else { + v1 = n2 + } + return v1 +} + +// C documentation +// +// /* +// ** This function is similar to sqlite3BtreeGetReserve(), except that it +// ** may only be called if it is guaranteed that the b-tree mutex is already +// ** held. +// ** +// ** This is useful in one special case in the backup API code where it is +// ** known that the shared b-tree mutex is held, but the mutex on the +// ** database handle that owns *p is not. In this case if sqlite3BtreeEnter() +// ** were to be called, it might collide with some other operation on the +// ** database handle that owns *p, causing undefined behavior. +// */ +func _sqlite3BtreeGetReserveNoMutex(tls *libc.TLS, p uintptr) (r int32) { + var n int32 + _ = n + n = libc.Int32FromUint32((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpageSize - (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FusableSize) + return n +} + +// C documentation +// +// /* Set *pRes to 1 (true) if the BTree pointed to by cursor pCur contains zero +// ** rows of content. Set *pRes to 0 (false) if the table contains content. +// ** Return SQLITE_OK on success or some error code (ex: SQLITE_NOMEM) if +// ** something goes wrong. +// */ +func _sqlite3BtreeIsEmpty(tls *libc.TLS, pCur uintptr, pRes uintptr) (r int32) { + var rc int32 + _ = rc + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID { + **(**int32)(__ccgo_up(pRes)) = 0 + return SQLITE_OK + } + rc = _moveToRoot(tls, pCur) + if rc == int32(SQLITE_EMPTY) { + **(**int32)(__ccgo_up(pRes)) = int32(1) + rc = SQLITE_OK + } else { + **(**int32)(__ccgo_up(pRes)) = 0 + } + return rc +} + +// C documentation +// +// /* +// ** Return true if the given Btree is read-only. +// */ +func _sqlite3BtreeIsReadonly(tls *libc.TLS, p uintptr) (r int32) { + return libc.BoolInt32(libc.Int32FromUint16((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FbtsFlags)&int32(BTS_READ_ONLY) != 0) +} + +func _sqlite3BtreeLast(tls *libc.TLS, pCur uintptr, pRes uintptr) (r int32) { + /* If the cursor already points to the last entry, this is a no-op. */ + if CURSOR_VALID == libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) && libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags)&int32(BTCF_AtLast) != 0 { + **(**int32)(__ccgo_up(pRes)) = 0 + return SQLITE_OK + } + return _btreeLast(tls, pCur, pRes) +} + +func _sqlite3BtreeLeaveAll(tls *libc.TLS, db uintptr) { + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FnoSharedCache) == 0 { + _btreeLeaveAll(tls, db) + } +} + +// C documentation +// +// /* +// ** Obtain a lock on the table whose root page is iTab. The +// ** lock is a write lock if isWritelock is true or a read lock +// ** if it is false. +// */ +func _sqlite3BtreeLockTable(tls *libc.TLS, p uintptr, iTab int32, isWriteLock Tu8) (r int32) { + var lockType Tu8 + var rc int32 + _, _ = lockType, rc + rc = SQLITE_OK + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + lockType = libc.Uint8FromInt32(int32(READ_LOCK) + libc.Int32FromUint8(isWriteLock)) + _sqlite3BtreeEnter(tls, p) + rc = _querySharedCacheTableLock(tls, p, libc.Uint32FromInt32(iTab), lockType) + if rc == SQLITE_OK { + rc = _setSharedCacheTableLock(tls, p, libc.Uint32FromInt32(iTab), lockType) + } + _sqlite3BtreeLeave(tls, p) + } + return rc +} + +// C documentation +// +// /* +// ** Return an upper bound on the size of any record for the table +// ** that the cursor is pointing into. +// ** +// ** This is an optimization. Everything will still work if this +// ** routine always returns 2147483647 (which is the largest record +// ** that SQLite can handle) or more. But returning a smaller value might +// ** prevent large memory allocations when trying to interpret a +// ** corrupt database. +// ** +// ** The current implementation merely returns the size of the underlying +// ** database file. +// */ +func _sqlite3BtreeMaxRecordSize(tls *libc.TLS, pCur uintptr) (r Tsqlite3_int64) { + return libc.Int64FromUint32((*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBt)).FpageSize) * libc.Int64FromUint32((*TBtShared)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBt)).FnPage) +} + +func _sqlite3BtreePayloadChecked(tls *libc.TLS, pCur uintptr, offset Tu32, amt Tu32, pBuf uintptr) (r int32) { + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID { + return _accessPayload(tls, pCur, offset, amt, pBuf, 0) + } else { + return _accessPayloadChecked(tls, pCur, offset, amt, pBuf) + } + return r +} + +func _sqlite3BtreePrevious(tls *libc.TLS, pCur uintptr, flags int32) (r int32) { + var v1 uintptr + _ = v1 + _ = flags /* Used in COMDB2 but not native SQLite */ + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTCF_AtLast) | libc.Int32FromInt32(BTCF_ValidOvfl) | libc.Int32FromInt32(BTCF_ValidNKey))) + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID || libc.Int32FromUint16((*TBtCursor)(unsafe.Pointer(pCur)).Fix) == 0 || libc.Int32FromUint8((*TMemPage)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf) == 0 { + return _btreePrevious(tls, pCur) + } + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = (*TBtCursor)(unsafe.Pointer(pCur)).Fix - 1 + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Argument pCsr must be a cursor opened for writing on an +// ** INTKEY table currently pointing at a valid table entry. +// ** This function modifies the data stored as part of that entry. +// ** +// ** Only the data content may only be modified, it is not possible to +// ** change the length of the data stored. If this function is called with +// ** parameters that attempt to write past the end of the existing data, +// ** no modifications are made and SQLITE_CORRUPT is returned. +// */ +func _sqlite3BtreePutData(tls *libc.TLS, pCsr uintptr, offset Tu32, amt Tu32, z uintptr) (r int32) { + var rc, v1 int32 + _, _ = rc, v1 + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCsr)).FeState) >= int32(CURSOR_REQUIRESEEK) { + v1 = _btreeRestoreCursorPosition(tls, pCsr) + } else { + v1 = SQLITE_OK + } + rc = v1 + if rc != SQLITE_OK { + return rc + } + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCsr)).FeState) != CURSOR_VALID { + return int32(SQLITE_ABORT) + } + /* Save the positions of all other cursors open on this table. This is + ** required in case any of them are holding references to an xFetch + ** version of the b-tree page modified by the accessPayload call below. + ** + ** Note that pCsr must be open on a INTKEY table and saveCursorPosition() + ** and hence saveAllCursors() cannot fail on a BTREE_INTKEY table, hence + ** saveAllCursors can only return SQLITE_OK. + */ + _saveAllCursors(tls, (*TBtCursor)(unsafe.Pointer(pCsr)).FpBt, (*TBtCursor)(unsafe.Pointer(pCsr)).FpgnoRoot, pCsr) + /* Check some assumptions: + ** (a) the cursor is open for writing, + ** (b) there is a read/write transaction open, + ** (c) the connection holds a write-lock on the table (if required), + ** (d) there are no conflicting read-locks, and + ** (e) the cursor points at a valid row of an intKey table. + */ + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(pCsr)).FcurFlags)&int32(BTCF_WriteFlag) == 0 { + return int32(SQLITE_READONLY) + } + return _accessPayload(tls, pCsr, offset, amt, z, int32(1)) +} + +// C documentation +// +// /* +// ** Rollback the transaction in progress. +// ** +// ** If tripCode is not SQLITE_OK then cursors will be invalidated (tripped). +// ** Only write cursors are tripped if writeOnly is true but all cursors are +// ** tripped if writeOnly is false. Any attempt to use +// ** a tripped cursor will result in an error. +// ** +// ** This will release the write lock on the database file. If there +// ** are no active cursors, it also releases the read lock. +// */ +func _sqlite3BtreeRollback(tls *libc.TLS, p uintptr, tripCode int32, writeOnly int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pBt uintptr + var rc, rc2, rc21, v1 int32 + var _ /* pPage1 at bp+0 */ uintptr + _, _, _, _, _ = pBt, rc, rc2, rc21, v1 + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + if tripCode == SQLITE_OK { + v1 = _saveAllCursors(tls, pBt, uint32(0), uintptr(0)) + tripCode = v1 + rc = v1 + if rc != 0 { + writeOnly = 0 + } + } else { + rc = SQLITE_OK + } + if tripCode != 0 { + rc2 = _sqlite3BtreeTripAllCursors(tls, p, tripCode, writeOnly) + if rc2 != SQLITE_OK { + rc = rc2 + } + } + if libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == int32(TRANS_WRITE) { + rc21 = _sqlite3PagerRollback(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + if rc21 != SQLITE_OK { + rc = rc21 + } + /* The rollback may have destroyed the pPage1->aData value. So + ** call btreeGetPage() on page 1 again to make + ** sure pPage1->aData is set correctly. */ + if _btreeGetPage(tls, pBt, uint32(1), bp, 0) == SQLITE_OK { + _btreeSetNPage(tls, pBt, **(**uintptr)(__ccgo_up(bp))) + _releasePageOne(tls, **(**uintptr)(__ccgo_up(bp))) + } + (*TBtShared)(unsafe.Pointer(pBt)).FinTransaction = uint8(TRANS_READ) + _btreeClearHasContent(tls, pBt) + } + _btreeEndTransaction(tls, p) + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** The second argument to this function, op, is always SAVEPOINT_ROLLBACK +// ** or SAVEPOINT_RELEASE. This function either releases or rolls back the +// ** savepoint identified by parameter iSavepoint, depending on the value +// ** of op. +// ** +// ** Normally, iSavepoint is greater than or equal to zero. However, if op is +// ** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the +// ** contents of the entire transaction are rolled back. This is different +// ** from a normal transaction rollback, as no locks are released and the +// ** transaction remains open. +// */ +func _sqlite3BtreeSavepoint(tls *libc.TLS, p uintptr, op int32, iSavepoint int32) (r int32) { + var pBt uintptr + var rc int32 + _, _ = pBt, rc + rc = SQLITE_OK + if p != 0 && libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) == int32(TRANS_WRITE) { + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + if op == int32(SAVEPOINT_ROLLBACK) { + rc = _saveAllCursors(tls, pBt, uint32(0), uintptr(0)) + } + if rc == SQLITE_OK { + rc = _sqlite3PagerSavepoint(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, op, iSavepoint) + } + if rc == SQLITE_OK { + if iSavepoint < 0 && libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_INITIALLY_EMPTY) != 0 { + (*TBtShared)(unsafe.Pointer(pBt)).FnPage = uint32(0) + } + rc = _newDatabase(tls, pBt) + _btreeSetNPage(tls, pBt, (*TBtShared)(unsafe.Pointer(pBt)).FpPage1) + /* pBt->nPage might be zero if the database was corrupt when + ** the transaction was started. Otherwise, it must be at least 1. */ + } + _sqlite3BtreeLeave(tls, p) + } + return rc +} + +// C documentation +// +// /* +// ** This function returns a pointer to a blob of memory associated with +// ** a single shared-btree. The memory is used by client code for its own +// ** purposes (for example, to store a high-level schema associated with +// ** the shared-btree). The btree layer manages reference counting issues. +// ** +// ** The first time this is called on a shared-btree, nBytes bytes of memory +// ** are allocated, zeroed, and returned to the caller. For each subsequent +// ** call the nBytes parameter is ignored and a pointer to the same blob +// ** of memory returned. +// ** +// ** If the nBytes parameter is 0 and the blob of memory has not yet been +// ** allocated, a null pointer is returned. If the blob has already been +// ** allocated, it is returned as normal. +// ** +// ** Just before the shared-btree is closed, the function passed as the +// ** xFree argument when the memory allocation was made is invoked on the +// ** blob of allocated memory. The xFree function should not call sqlite3_free() +// ** on the memory, the btree layer does that. +// */ +func _sqlite3BtreeSchema(tls *libc.TLS, p uintptr, nBytes int32, __ccgo_fp_xFree uintptr) (r uintptr) { + var pBt uintptr + _ = pBt + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + if !((*TBtShared)(unsafe.Pointer(pBt)).FpSchema != 0) && nBytes != 0 { + (*TBtShared)(unsafe.Pointer(pBt)).FpSchema = _sqlite3DbMallocZero(tls, uintptr(0), libc.Uint64FromInt32(nBytes)) + (*TBtShared)(unsafe.Pointer(pBt)).FxFreeSchema = __ccgo_fp_xFree + } + _sqlite3BtreeLeave(tls, p) + return (*TBtShared)(unsafe.Pointer(pBt)).FpSchema +} + +// C documentation +// +// /* +// ** Change the 'auto-vacuum' property of the database. If the 'autoVacuum' +// ** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it +// ** is disabled. The default value for the auto-vacuum property is +// ** determined by the SQLITE_DEFAULT_AUTOVACUUM macro. +// */ +func _sqlite3BtreeSetAutoVacuum(tls *libc.TLS, p uintptr, autoVacuum int32) (r int32) { + var av Tu8 + var pBt uintptr + var rc, v1 int32 + var v2 bool + _, _, _, _, _ = av, pBt, rc, v1, v2 + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + rc = SQLITE_OK + av = libc.Uint8FromInt32(autoVacuum) + _sqlite3BtreeEnter(tls, p) + if v2 = libc.Int32FromUint16((*TBtShared)(unsafe.Pointer(pBt)).FbtsFlags)&int32(BTS_PAGESIZE_FIXED) != 0; v2 { + if av != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + } + if v2 && v1 != libc.Int32FromUint8((*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum) { + rc = int32(SQLITE_READONLY) + } else { + if av != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(v1) + if libc.Int32FromUint8(av) == int32(2) { + v1 = int32(1) + } else { + v1 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(v1) + } + _sqlite3BtreeLeave(tls, p) + return rc +} + +// C documentation +// +// /* +// ** Return true if the Btree passed as the only argument is sharable. +// */ +func _sqlite3BtreeSharable(tls *libc.TLS, p uintptr) (r int32) { + return libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).Fsharable) +} + +// C documentation +// +// /* +// ** This routine sets the state to CURSOR_FAULT and the error +// ** code to errCode for every cursor on any BtShared that pBtree +// ** references. Or if the writeOnly flag is set to 1, then only +// ** trip write cursors and leave read cursors unchanged. +// ** +// ** Every cursor is a candidate to be tripped, including cursors +// ** that belong to other database connections that happen to be +// ** sharing the cache with pBtree. +// ** +// ** This routine gets called when a rollback occurs. If the writeOnly +// ** flag is true, then only write-cursors need be tripped - read-only +// ** cursors save their current positions so that they may continue +// ** following the rollback. Or, if writeOnly is false, all cursors are +// ** tripped. In general, writeOnly is false if the transaction being +// ** rolled back modified the database schema. In this case b-tree root +// ** pages may be moved or deleted from the database altogether, making +// ** it unsafe for read cursors to continue. +// ** +// ** If the writeOnly flag is true and an error is encountered while +// ** saving the current position of a read-only cursor, all cursors, +// ** including all read-cursors are tripped. +// ** +// ** SQLITE_OK is returned if successful, or if an error occurs while +// ** saving a cursor position, an SQLite error code. +// */ +func _sqlite3BtreeTripAllCursors(tls *libc.TLS, pBtree uintptr, errCode int32, writeOnly int32) (r int32) { + var p uintptr + var rc int32 + _, _ = p, rc + rc = SQLITE_OK + if pBtree != 0 { + _sqlite3BtreeEnter(tls, pBtree) + p = (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(pBtree)).FpBt)).FpCursor + for { + if !(p != 0) { + break + } + if writeOnly != 0 && libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(p)).FcurFlags)&int32(BTCF_WriteFlag) == 0 { + if libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_VALID || libc.Int32FromUint8((*TBtCursor)(unsafe.Pointer(p)).FeState) == int32(CURSOR_SKIPNEXT) { + rc = _saveCursorPosition(tls, p) + if rc != SQLITE_OK { + _sqlite3BtreeTripAllCursors(tls, pBtree, rc, 0) + break + } + } + } else { + _sqlite3BtreeClearCursor(tls, p) + (*TBtCursor)(unsafe.Pointer(p)).FeState = uint8(CURSOR_FAULT) + (*TBtCursor)(unsafe.Pointer(p)).FskipNext = errCode + } + _btreeReleaseAllCursorPages(tls, p) + goto _1 + _1: + ; + p = (*TBtCursor)(unsafe.Pointer(p)).FpNext + } + _sqlite3BtreeLeave(tls, pBtree) + } + return rc +} + +// C documentation +// +// /* +// ** Return one of SQLITE_TXN_NONE, SQLITE_TXN_READ, or SQLITE_TXN_WRITE +// ** to describe the current transaction state of Btree p. +// */ +func _sqlite3BtreeTxnState(tls *libc.TLS, p uintptr) (r int32) { + var v1 int32 + _ = v1 + if p != 0 { + v1 = libc.Int32FromUint8((*TBtree)(unsafe.Pointer(p)).FinTrans) + } else { + v1 = 0 + } + return v1 +} + +// C documentation +// +// /* +// ** This is called to code the required FOR EACH ROW triggers for an operation +// ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE) +// ** is given by the op parameter. The tr_tm parameter determines whether the +// ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then +// ** parameter pChanges is passed the list of columns being modified. +// ** +// ** If there are no triggers that fire at the specified time for the specified +// ** operation on pTab, this function is a no-op. +// ** +// ** The reg argument is the address of the first in an array of registers +// ** that contain the values substituted for the new.* and old.* references +// ** in the trigger program. If N is the number of columns in table pTab +// ** (a copy of pTab->nCol), then registers are populated as follows: +// ** +// ** Register Contains +// ** ------------------------------------------------------ +// ** reg+0 OLD.rowid +// ** reg+1 OLD.* value of left-most column of pTab +// ** ... ... +// ** reg+N OLD.* value of right-most column of pTab +// ** reg+N+1 NEW.rowid +// ** reg+N+2 NEW.* value of left-most column of pTab +// ** ... ... +// ** reg+N+N+1 NEW.* value of right-most column of pTab +// ** +// ** For ON DELETE triggers, the registers containing the NEW.* values will +// ** never be accessed by the trigger program, so they are not allocated or +// ** populated by the caller (there is no data to populate them with anyway). +// ** Similarly, for ON INSERT triggers the values stored in the OLD.* registers +// ** are never accessed, and so are not allocated by the caller. So, for an +// ** ON INSERT trigger, the value passed to this function as parameter reg +// ** is not a readable register, although registers (reg+N) through +// ** (reg+N+N+1) are. +// ** +// ** Parameter orconf is the default conflict resolution algorithm for the +// ** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump +// ** is the instruction that control should jump to if a trigger program +// ** raises an IGNORE exception. +// */ +func _sqlite3CodeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, op int32, pChanges uintptr, tr_tm int32, pTab uintptr, reg int32, orconf int32, ignoreJump int32) { + var p uintptr + _ = p /* Used to iterate through pTrigger list */ + p = pTrigger + for { + if !(p != 0) { + break + } + /* Sanity checking: The schema for the trigger and for the table are + ** always defined. The trigger must be in the same schema as the table + ** or else it must be a TEMP trigger. */ + /* Determine whether we should code this trigger. One of two choices: + ** 1. The trigger is an exact match to the current DML statement + ** 2. This is a RETURNING trigger for INSERT but we are currently + ** doing the UPDATE part of an UPSERT. + */ + if (libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == op || (*TTrigger)(unsafe.Pointer(p)).FbReturning != 0 && libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == int32(TK_INSERT) && op == int32(TK_UPDATE)) && libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm) == tr_tm && _checkColumnOverlap(tls, (*TTrigger)(unsafe.Pointer(p)).FpColumns, pChanges) != 0 { + if !((*TTrigger)(unsafe.Pointer(p)).FbReturning != 0) { + _sqlite3CodeRowTriggerDirect(tls, pParse, p, pTab, reg, orconf, ignoreJump) + } else { + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) { + _codeReturningTrigger(tls, pParse, p, pTab, reg) + } + } + } + goto _1 + _1: + ; + p = (*TTrigger)(unsafe.Pointer(p)).FpNext + } +} + +// C documentation +// +// /* +// ** Allocate a new expression node from a zero-terminated token that has +// ** already been dequoted. +// */ +func _sqlite3Expr(tls *libc.TLS, db uintptr, op int32, zToken uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* x at bp+0 */ TToken + (**(**TToken)(__ccgo_up(bp))).Fz = zToken + (**(**TToken)(__ccgo_up(bp))).Fn = libc.Uint32FromInt32(_sqlite3Strlen30(tls, zToken)) + return _sqlite3ExprAlloc(tls, db, op, bp, 0) +} + +// C documentation +// +// /* +// ** Set the collating sequence for expression pExpr to be the collating +// ** sequence named by pToken. Return a pointer to a new Expr node that +// ** implements the COLLATE operator. +// ** +// ** If a memory allocation error occurs, that fact is recorded in pParse->db +// ** and the pExpr parameter is returned unchanged. +// */ +func _sqlite3ExprAddCollateToken(tls *libc.TLS, pParse uintptr, pExpr uintptr, pCollName uintptr, dequote int32) (r uintptr) { + var pNew uintptr + _ = pNew + if (*TToken)(unsafe.Pointer(pCollName)).Fn > uint32(0) { + pNew = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_COLLATE), pCollName, dequote) + if pNew != 0 { + (*TExpr)(unsafe.Pointer(pNew)).FpLeft = pExpr + **(**Tu32)(__ccgo_up(pNew + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate) | libc.Int32FromInt32(EP_Skip)) + pExpr = pNew + } + } + return pExpr +} + +// C documentation +// +// /* +// ** Join two expressions using an AND operator. If either expression is +// ** NULL, then just return the other expression. +// ** +// ** If one side or the other of the AND is known to be false, and neither side +// ** is part of an ON clause, then instead of returning an AND expression, +// ** just return a constant expression with a value of false. +// */ +func _sqlite3ExprAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) (r uintptr) { + var db uintptr + var f Tu32 + _, _ = db, f + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pLeft == uintptr(0) { + return pRight + } else { + if pRight == uintptr(0) { + return pLeft + } else { + f = (*TExpr)(unsafe.Pointer(pLeft)).Fflags | (*TExpr)(unsafe.Pointer(pRight)).Fflags + if f&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)|libc.Int32FromInt32(EP_IsFalse)|libc.Int32FromInt32(EP_HasFunc)) == uint32(EP_IsFalse) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + _sqlite3ExprDeferredDelete(tls, pParse, pLeft) + _sqlite3ExprDeferredDelete(tls, pParse, pRight) + return _sqlite3ExprInt32(tls, db, 0) + } else { + return _sqlite3PExpr(tls, pParse, int32(TK_AND), pLeft, pRight) + } + } + } + return r +} + +// C documentation +// +// /* +// ** Attach subtrees pLeft and pRight to the Expr node pRoot. +// ** +// ** If pRoot==NULL that means that a memory allocation error has occurred. +// ** In that case, delete the subtrees pLeft and pRight. +// */ +func _sqlite3ExprAttachSubtrees(tls *libc.TLS, db uintptr, pRoot uintptr, pLeft uintptr, pRight uintptr) { + if pRoot == uintptr(0) { + _sqlite3ExprDelete(tls, db, pLeft) + _sqlite3ExprDelete(tls, db, pRight) + } else { + if pRight != 0 { + (*TExpr)(unsafe.Pointer(pRoot)).FpRight = pRight + **(**Tu32)(__ccgo_up(pRoot + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)|libc.Int32FromInt32(EP_Subquery)|libc.Int32FromInt32(EP_HasFunc)) & (*TExpr)(unsafe.Pointer(pRight)).Fflags + (*TExpr)(unsafe.Pointer(pRoot)).FnHeight = (*TExpr)(unsafe.Pointer(pRight)).FnHeight + int32(1) + } else { + (*TExpr)(unsafe.Pointer(pRoot)).FnHeight = int32(1) + } + if pLeft != 0 { + (*TExpr)(unsafe.Pointer(pRoot)).FpLeft = pLeft + **(**Tu32)(__ccgo_up(pRoot + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)|libc.Int32FromInt32(EP_Subquery)|libc.Int32FromInt32(EP_HasFunc)) & (*TExpr)(unsafe.Pointer(pLeft)).Fflags + if (*TExpr)(unsafe.Pointer(pLeft)).FnHeight >= (*TExpr)(unsafe.Pointer(pRoot)).FnHeight { + (*TExpr)(unsafe.Pointer(pRoot)).FnHeight = (*TExpr)(unsafe.Pointer(pLeft)).FnHeight + int32(1) + } + } + } +} + +// C documentation +// +// /* +// ** Generate code that will evaluate expression pExpr and store the +// ** results in register target. The results are guaranteed to appear +// ** in register target. +// */ +func _sqlite3ExprCode(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) { + var inReg int32 + var op Tu8 + var pX uintptr + _, _, _ = inReg, op, pX + if (*TParse)(unsafe.Pointer(pParse)).FpVdbe == uintptr(0) { + return + } + inReg = _sqlite3ExprCodeTarget(tls, pParse, pExpr, target) + if inReg != target { + pX = _sqlite3ExprSkipCollateAndLikely(tls, pExpr) + if pX != 0 && ((*TExpr)(unsafe.Pointer(pX)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pX)).Fop) == int32(TK_REGISTER)) { + op = uint8(OP_Copy) + } else { + op = uint8(OP_SCopy) + } + _sqlite3VdbeAddOp2(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, libc.Int32FromUint8(op), inReg, target) + } +} + +// C documentation +// +// /* +// ** Generate code that will extract the iColumn-th column from +// ** table pTab and store the column value in register iReg. +// ** +// ** There must be an open cursor to pTab in iTable when this routine +// ** is called. If iColumn<0 then code is generated that extracts the rowid. +// */ +func _sqlite3ExprCodeGetColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, iColumn int32, iTable int32, iReg int32, p5 Tu8) (r int32) { + var pOp uintptr + _ = pOp + _sqlite3ExprCodeGetColumnOfTable(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iTable, iColumn, iReg) + if p5 != 0 { + pOp = _sqlite3VdbeGetLastOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Column) { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp5 = uint16(p5) + } + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_VColumn) { + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp5 = libc.Uint16FromInt32(libc.Int32FromUint8(p5) & libc.Int32FromInt32(OPFLAG_NOCHNG)) + } + } + return iReg +} + +// C documentation +// +// /* Expression p is a comparison operator. Return a collation sequence +// ** appropriate for the comparison operator. +// ** +// ** This is normally just a wrapper around sqlite3BinaryCompareCollSeq(). +// ** However, if the OP_Commuted flag is set, then the order of the operands +// ** is reversed in the sqlite3BinaryCompareCollSeq() call so that the +// ** correct collating sequence is found. +// */ +func _sqlite3ExprCompareCollSeq(tls *libc.TLS, pParse uintptr, p uintptr) (r uintptr) { + if (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0) { + return _sqlite3BinaryCompareCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FpRight, (*TExpr)(unsafe.Pointer(p)).FpLeft) + } else { + return _sqlite3BinaryCompareCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FpLeft, (*TExpr)(unsafe.Pointer(p)).FpRight) + } + return r +} + +// C documentation +// +// /* +// ** If the input expression is an ID with the name "true" or "false" +// ** then convert it into an TK_TRUEFALSE term. Return non-zero if +// ** the conversion happened, and zero if the expression is unaltered. +// */ +func _sqlite3ExprIdToTrueFalse(tls *libc.TLS, pExpr uintptr) (r int32) { + var v, v1 Tu32 + var v2 bool + _, _, _ = v, v1, v2 + if v2 = !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Quoted)|libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)); v2 { + v1 = _sqlite3IsTrueOrFalse(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + v = v1 + } + if v2 && v1 != uint32(0) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_TRUEFALSE) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= v + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** Generate code for a boolean expression such that a jump is made +// ** to the label "dest" if the expression is false but execution +// ** continues straight thru if the expression is true. +// ** +// ** If the expression evaluates to NULL (neither true nor false) then +// ** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull +// ** is 0. +// */ +func _sqlite3ExprIfFalse(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, jumpIfNull int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var addrIsNull, d2, destIfNull, isNot, isTrue, op, v19 int32 + var pAlt, pFirst, pSecond, v uintptr + var _ /* r1 at bp+8 */ int32 + var _ /* r2 at bp+12 */ int32 + var _ /* regFree1 at bp+0 */ int32 + var _ /* regFree2 at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = addrIsNull, d2, destIfNull, isNot, isTrue, op, pAlt, pFirst, pSecond, v, v19 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + op = 0 + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + if v == uintptr(0) { + return + } /* Existence of VDBE checked by caller */ + if pExpr == uintptr(0) { + return + } + /* The value of pExpr->op and op are related as follows: + ** + ** pExpr->op op + ** --------- ---------- + ** TK_ISNULL OP_NotNull + ** TK_NOTNULL OP_IsNull + ** TK_NE OP_Eq + ** TK_EQ OP_Ne + ** TK_GT OP_Le + ** TK_LE OP_Gt + ** TK_GE OP_Lt + ** TK_LT OP_Ge + ** + ** For other values of pExpr->op, op is undefined and unused. + ** The value of TK_ and OP_ constants are arranged such that we + ** can compute the mapping above using the following expression. + ** Assert()s verify that the computation is correct. + */ + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + libc.Int32FromInt32(TK_ISNULL)&libc.Int32FromInt32(1) ^ int32(1) - libc.Int32FromInt32(TK_ISNULL)&libc.Int32FromInt32(1) + /* Verify correct alignment of TK_ and OP_ constants + */ + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + case int32(TK_OR): + goto _1 + case int32(TK_AND): + goto _2 + case int32(TK_NOT): + goto _3 + case int32(TK_TRUTH): + goto _4 + case int32(TK_ISNOT): + goto _5 + case int32(TK_IS): + goto _6 + case int32(TK_EQ): + goto _7 + case int32(TK_NE): + goto _8 + case int32(TK_GE): + goto _9 + case int32(TK_GT): + goto _10 + case int32(TK_LE): + goto _11 + case int32(TK_LT): + goto _12 + case int32(TK_NOTNULL): + goto _13 + case int32(TK_ISNULL): + goto _14 + case int32(TK_BETWEEN): + goto _15 + case int32(TK_IN): + goto _16 + default: + goto _17 + } + goto _18 +_2: + ; +_1: + ; + pAlt = _sqlite3ExprSimplifiedAndOr(tls, pExpr) + if pAlt != pExpr { + _sqlite3ExprIfFalse(tls, pParse, pAlt, dest, jumpIfNull) + } else { + if _exprEvalRhsFirst(tls, pExpr) != 0 { + pFirst = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + pSecond = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + } else { + pFirst = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pSecond = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AND) { + _sqlite3ExprIfFalse(tls, pParse, pFirst, dest, jumpIfNull) + _sqlite3ExprIfFalse(tls, pParse, pSecond, dest, jumpIfNull) + } else { + d2 = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfTrue(tls, pParse, pFirst, d2, jumpIfNull^int32(SQLITE_JUMPIFNULL)) + _sqlite3ExprIfFalse(tls, pParse, pSecond, dest, jumpIfNull) + _sqlite3VdbeResolveLabel(tls, v, d2) + } + } + goto _18 +_3: + ; + _sqlite3ExprIfTrue(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, dest, jumpIfNull) + goto _18 +_4: + ; /* IS TRUE or IS NOT TRUE */ + isNot = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) == int32(TK_ISNOT)) + isTrue = _sqlite3ExprTruthValue(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if isTrue^isNot != 0 { + /* IS TRUE and IS NOT FALSE */ + if isNot != 0 { + v19 = 0 + } else { + v19 = int32(SQLITE_JUMPIFNULL) + } + _sqlite3ExprIfFalse(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, dest, v19) + } else { + /* IS FALSE and IS NOT TRUE */ + if isNot != 0 { + v19 = 0 + } else { + v19 = int32(SQLITE_JUMPIFNULL) + } + _sqlite3ExprIfTrue(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, dest, v19) + } + goto _18 +_6: + ; +_5: + ; + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IS) { + v19 = int32(TK_NE) + } else { + v19 = int32(TK_EQ) + } + op = v19 + jumpIfNull = int32(SQLITE_NULLEQ) +_12: + ; +_11: + ; +_10: + ; +_9: + ; +_8: + ; +_7: + ; + if _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) != 0 { + goto default_expr + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) && jumpIfNull != int32(SQLITE_NULLEQ) { + addrIsNull = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) + addrIsNull = 0 + } + _codeCompare(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, op, **(**int32)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 12)), dest, jumpIfNull, libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0))) + if addrIsNull != 0 { + if jumpIfNull != 0 { + _sqlite3VdbeChangeP2(tls, v, addrIsNull, dest) + } else { + _sqlite3VdbeJumpHere(tls, v, addrIsNull) + } + } + goto _18 +_14: + ; +_13: + ; + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + _sqlite3VdbeTypeofColumn(tls, v, **(**int32)(__ccgo_up(bp + 8))) + } + _sqlite3VdbeAddOp2(tls, v, op, **(**int32)(__ccgo_up(bp + 8)), dest) + goto _18 +_15: + ; + _exprCodeBetween(tls, pParse, pExpr, dest, __ccgo_fp(_sqlite3ExprIfFalse), jumpIfNull) + goto _18 +_16: + ; + if jumpIfNull != 0 { + _sqlite3ExprCodeIN(tls, pParse, pExpr, dest, dest) + } else { + destIfNull = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprCodeIN(tls, pParse, pExpr, dest, destIfNull) + _sqlite3VdbeResolveLabel(tls, v, destIfNull) + } + goto _18 +_17: + ; + goto default_expr +default_expr: + ; + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsFalse)) == uint32(EP_IsFalse) { + _sqlite3VdbeGoto(tls, v, dest) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsTrue)) == uint32(EP_IsTrue) { + /* no-op */ + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, pExpr, bp) + _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNot), **(**int32)(__ccgo_up(bp + 8)), dest, libc.BoolInt32(jumpIfNull != 0)) + } + } + goto _18 +_18: + ; + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp))) + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp + 4))) +} + +// C documentation +// +// /* +// ** Like sqlite3ExprIfFalse() except that a copy is made of pExpr before +// ** code generation, and that copy is deleted after code generation. This +// ** ensures that the original pExpr is unchanged. +// */ +func _sqlite3ExprIfFalseDup(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, jumpIfNull int32) { + var db, pCopy uintptr + _, _ = db, pCopy + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pCopy = _sqlite3ExprDup(tls, db, pExpr, 0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + _sqlite3ExprIfFalse(tls, pParse, pCopy, dest, jumpIfNull) + } + _sqlite3ExprDelete(tls, db, pCopy) +} + +// C documentation +// +// /* +// ** Generate code for a boolean expression such that a jump is made +// ** to the label "dest" if the expression is true but execution +// ** continues straight thru if the expression is false. +// ** +// ** If the expression evaluates to NULL (neither true nor false), then +// ** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL. +// ** +// ** This code depends on the fact that certain token values (ex: TK_EQ) +// ** are the same as opcode values (ex: OP_Eq) that implement the corresponding +// ** operation. Special comments in vdbe.c and the mkopcodeh.awk script in +// ** the make process cause these values to align. Assert()s in the code +// ** below verify that the numbers are aligned correctly. +// */ +func _sqlite3ExprIfTrue(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, jumpIfNull int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var addrIsNull, d2, destIfFalse, destIfNull, isNot, isTrue, op, v19 int32 + var pAlt, pFirst, pSecond, v uintptr + var _ /* r1 at bp+8 */ int32 + var _ /* r2 at bp+12 */ int32 + var _ /* regFree1 at bp+0 */ int32 + var _ /* regFree2 at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _ = addrIsNull, d2, destIfFalse, destIfNull, isNot, isTrue, op, pAlt, pFirst, pSecond, v, v19 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + op = 0 + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + if v == uintptr(0) { + return + } /* Existence of VDBE checked by caller */ + if pExpr == uintptr(0) { + return + } /* No way this can happen */ + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + switch op { + case int32(TK_OR): + goto _1 + case int32(TK_AND): + goto _2 + case int32(TK_NOT): + goto _3 + case int32(TK_TRUTH): + goto _4 + case int32(TK_ISNOT): + goto _5 + case int32(TK_IS): + goto _6 + case int32(TK_EQ): + goto _7 + case int32(TK_NE): + goto _8 + case int32(TK_GE): + goto _9 + case int32(TK_GT): + goto _10 + case int32(TK_LE): + goto _11 + case int32(TK_LT): + goto _12 + case int32(TK_NOTNULL): + goto _13 + case int32(TK_ISNULL): + goto _14 + case int32(TK_BETWEEN): + goto _15 + case int32(TK_IN): + goto _16 + default: + goto _17 + } + goto _18 +_2: + ; +_1: + ; + pAlt = _sqlite3ExprSimplifiedAndOr(tls, pExpr) + if pAlt != pExpr { + _sqlite3ExprIfTrue(tls, pParse, pAlt, dest, jumpIfNull) + } else { + if _exprEvalRhsFirst(tls, pExpr) != 0 { + pFirst = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + pSecond = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + } else { + pFirst = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pSecond = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + } + if op == int32(TK_AND) { + d2 = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfFalse(tls, pParse, pFirst, d2, jumpIfNull^int32(SQLITE_JUMPIFNULL)) + _sqlite3ExprIfTrue(tls, pParse, pSecond, dest, jumpIfNull) + _sqlite3VdbeResolveLabel(tls, v, d2) + } else { + _sqlite3ExprIfTrue(tls, pParse, pFirst, dest, jumpIfNull) + _sqlite3ExprIfTrue(tls, pParse, pSecond, dest, jumpIfNull) + } + } + goto _18 +_3: + ; + _sqlite3ExprIfFalse(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, dest, jumpIfNull) + goto _18 +_4: + ; /* IS TRUE or IS NOT TRUE */ + isNot = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) == int32(TK_ISNOT)) + isTrue = _sqlite3ExprTruthValue(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if isTrue^isNot != 0 { + if isNot != 0 { + v19 = int32(SQLITE_JUMPIFNULL) + } else { + v19 = 0 + } + _sqlite3ExprIfTrue(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, dest, v19) + } else { + if isNot != 0 { + v19 = int32(SQLITE_JUMPIFNULL) + } else { + v19 = 0 + } + _sqlite3ExprIfFalse(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, dest, v19) + } + goto _18 +_6: + ; +_5: + ; + if op == int32(TK_IS) { + v19 = int32(TK_EQ) + } else { + v19 = int32(TK_NE) + } + op = v19 + jumpIfNull = int32(SQLITE_NULLEQ) +_12: + ; +_11: + ; +_10: + ; +_9: + ; +_8: + ; +_7: + ; + if _sqlite3ExprIsVector(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) != 0 { + goto default_expr + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) && jumpIfNull != int32(SQLITE_NULLEQ) { + addrIsNull = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) + addrIsNull = 0 + } + _codeCompare(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, op, **(**int32)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 12)), dest, jumpIfNull, libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0))) + if addrIsNull != 0 { + if jumpIfNull != 0 { + _sqlite3VdbeChangeP2(tls, v, addrIsNull, dest) + } else { + _sqlite3VdbeJumpHere(tls, v, addrIsNull) + } + } + goto _18 +_14: + ; +_13: + ; + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + if **(**int32)(__ccgo_up(bp)) != 0 { + _sqlite3VdbeTypeofColumn(tls, v, **(**int32)(__ccgo_up(bp + 8))) + } + _sqlite3VdbeAddOp2(tls, v, op, **(**int32)(__ccgo_up(bp + 8)), dest) + goto _18 +_15: + ; + _exprCodeBetween(tls, pParse, pExpr, dest, __ccgo_fp(_sqlite3ExprIfTrue), jumpIfNull) + goto _18 +_16: + ; + destIfFalse = _sqlite3VdbeMakeLabel(tls, pParse) + if jumpIfNull != 0 { + v19 = dest + } else { + v19 = destIfFalse + } + destIfNull = v19 + _sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull) + _sqlite3VdbeGoto(tls, v, dest) + _sqlite3VdbeResolveLabel(tls, v, destIfFalse) + goto _18 +_17: + ; + goto default_expr +default_expr: + ; + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsTrue)) == uint32(EP_IsTrue) { + _sqlite3VdbeGoto(tls, v, dest) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsFalse)) == uint32(EP_IsFalse) { + /* No-op */ + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, pExpr, bp) + _sqlite3VdbeAddOp3(tls, v, int32(OP_If), **(**int32)(__ccgo_up(bp + 8)), dest, libc.BoolInt32(jumpIfNull != 0)) + } + } + goto _18 +_18: + ; + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp))) + _sqlite3ReleaseTempReg(tls, pParse, **(**int32)(__ccgo_up(bp + 4))) +} + +// C documentation +// +// /* +// ** Walk an expression tree for the DEFAULT field of a column definition +// ** in a CREATE TABLE statement. Return non-zero if the expression is +// ** acceptable for use as a DEFAULT. That is to say, return non-zero if +// ** the expression is constant or a function call with constant arguments. +// ** Return and 0 if there are any variables. +// ** +// ** isInit is true when parsing from sqlite_schema. isInit is false when +// ** processing a new CREATE TABLE statement. When isInit is true, parameters +// ** (such as ? or $abc) in the expression are converted into NULL. When +// ** isInit is false, parameters raise an error. Parameters should not be +// ** allowed in a CREATE TABLE statement, but some legacy versions of SQLite +// ** allowed it, so we need to support it when reading sqlite_schema for +// ** backwards compatibility. +// ** +// ** If isInit is true, set EP_FromDDL on every TK_FUNCTION node. +// ** +// ** For the purposes of this function, a double-quoted string (ex: "abc") +// ** is considered a variable but a single-quoted string (ex: 'abc') is +// ** a constant. +// */ +func _sqlite3ExprIsConstantOrFunction(tls *libc.TLS, p uintptr, isInit Tu8) (r int32) { + return _exprIsConst(tls, uintptr(0), p, int32(4)+libc.Int32FromUint8(isInit)) +} + +// C documentation +// +// /* +// ** Return true if the boolean value of the expression is always either +// ** FALSE or NULL. +// */ +func _sqlite3ExprIsNotTrue(tls *libc.TLS, pExpr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* v at bp+0 */ int32 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NULL) { + return int32(1) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_TRUEFALSE) && _sqlite3ExprTruthValue(tls, pExpr) == 0 { + return int32(1) + } + **(**int32)(__ccgo_up(bp)) = int32(1) + if _sqlite3ExprIsInteger(tls, pExpr, bp, uintptr(0)) != 0 && **(**int32)(__ccgo_up(bp)) == 0 { + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** If pExpr is an AND or OR expression, try to simplify it by eliminating +// ** terms that are always true or false. Return the simplified expression. +// ** Or return the original expression if no simplification is possible. +// ** +// ** Examples: +// ** +// ** (x<10) AND true => (x<10) +// ** (x<10) AND false => false +// ** (x<10) AND (y=22 OR false) => (x<10) AND (y=22) +// ** (x<10) AND (y=22 OR true) => (x<10) +// ** (y=22) OR true => true +// */ +func _sqlite3ExprSimplifiedAndOr(tls *libc.TLS, pExpr uintptr) (r uintptr) { + var pLeft, pRight, v1 uintptr + _, _, _ = pLeft, pRight, v1 + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AND) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_OR) { + pRight = _sqlite3ExprSimplifiedAndOr(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + pLeft = _sqlite3ExprSimplifiedAndOr(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if (*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsTrue)) == uint32(EP_IsTrue) || (*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsFalse)) == uint32(EP_IsFalse) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AND) { + v1 = pRight + } else { + v1 = pLeft + } + pExpr = v1 + } else { + if (*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsTrue)) == uint32(EP_IsTrue) || (*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_IsFalse)) == uint32(EP_IsFalse) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AND) { + v1 = pLeft + } else { + v1 = pRight + } + pExpr = v1 + } + } + } + return pExpr +} + +// C documentation +// +// /* +// ** Skip over any TK_COLLATE operators. +// */ +func _sqlite3ExprSkipCollate(tls *libc.TLS, pExpr uintptr) (r uintptr) { + for pExpr != 0 && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Skip)) != uint32(0) { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + } + return pExpr +} + +// C documentation +// +// /* +// ** Convert a scalar expression node to a TK_REGISTER referencing +// ** register iReg. The caller must ensure that iReg already contains +// ** the correct value for the expression. +// */ +func _sqlite3ExprToRegister(tls *libc.TLS, pExpr uintptr, iReg int32) { + var p uintptr + _ = p + p = _sqlite3ExprSkipCollateAndLikely(tls, pExpr) + if p == uintptr(0) { + return + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_REGISTER) { + } else { + (*TExpr)(unsafe.Pointer(p)).Fop2 = (*TExpr)(unsafe.Pointer(p)).Fop + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_REGISTER) + (*TExpr)(unsafe.Pointer(p)).FiTable = iReg + **(**Tu32)(__ccgo_up(p + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Skip)) + } +} + +// C documentation +// +// /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the +// ** expression. +// */ +func _sqlite3ExprUnmapAndDelete(tls *libc.TLS, pParse uintptr, p uintptr) { + if p != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameExprUnmap(tls, pParse, p) + } + _sqlite3ExprDeleteNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, p) + } +} + +// C documentation +// +// /* +// ** Given m and e, which represent a quantity r == m*pow(2,e), +// ** return values *pD and *pP such that r == (*pD)*pow(10,*pP), +// ** approximately. *pD should contain at least n significant digits. +// ** +// ** The input m is required to have its highest bit set. In other words, +// ** m should be left-shifted, and e decremented, to maximize the value of m. +// */ +func _sqlite3Fp2Convert10(tls *libc.TLS, m Tu64, e int32, n int32, pD uintptr, pP uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var h Tu64 + var p int32 + var _ /* d1 at bp+0 */ Tu64 + var _ /* d2 at bp+8 */ Tu32 + _, _ = h, p + p = n - int32(1) - _pwr2to10(tls, e+int32(63)) + h = _sqlite3Multiply128(tls, m, _powerOfTen(tls, p, bp+8), bp) + if n == int32(18) { + h = h >> libc.Uint64FromInt32(-(e + _pwr10to2(tls, p) + libc.Int32FromInt32(2))) + **(**Tu64)(__ccgo_up(pD)) = (h + h<> int32(1) + } else { + **(**Tu64)(__ccgo_up(pD)) = h >> -(e + _pwr10to2(tls, p) + int32(1)) + } + **(**int32)(__ccgo_up(pP)) = -p +} + +// C documentation +// +// /* +// ** Set the buffer to contain nData/pData. If an OOM error occurs, leave an +// ** the error code in p. If an error has already occurred when this function +// ** is called, it is a no-op. +// */ +func _sqlite3Fts5BufferSet(tls *libc.TLS, pRc uintptr, pBuf uintptr, nData int32, pData uintptr) { + (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn = 0 + _sqlite3Fts5BufferAppendBlob(tls, pRc, pBuf, libc.Uint32FromInt32(nData), pData) +} + +func _sqlite3Fts5BufferSize(tls *libc.TLS, pRc uintptr, pBuf uintptr, nByte Tu32) (r int32) { + var nNew Tu64 + var pNew uintptr + var v1 int32 + _, _, _ = nNew, pNew, v1 + if libc.Uint32FromInt32((*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) < nByte { + if (*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace != 0 { + v1 = (*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace + } else { + v1 = int32(64) + } + nNew = libc.Uint64FromInt32(v1) + for nNew < uint64(nByte) { + nNew = nNew * uint64(2) + } + pNew = Xsqlite3_realloc64(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp, nNew) + if pNew == uintptr(0) { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + return int32(1) + } else { + (*TFts5Buffer)(unsafe.Pointer(pBuf)).FnSpace = libc.Int32FromUint64(nNew) + (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp = pNew + } + } + return 0 +} + +func _sqlite3Fts5Get32(tls *libc.TLS, aBuf uintptr) (r int32) { + return libc.Int32FromUint32(uint32(**(**Tu8)(__ccgo_up(aBuf)))<)); +** +** One row for each term instance in the database. + */ + +/* #include "fts5Int.h" */ + +// C documentation +// +// /* +// ** Retrieve the origin value that will be used for the segment currently +// ** being accumulated in the in-memory hash table when it is flushed to +// ** disk. If successful, SQLITE_OK is returned and (*piOrigin) set to +// ** the queried value. Or, if an error occurs, an error code is returned +// ** and the final value of (*piOrigin) is undefined. +// */ +func _sqlite3Fts5IndexGetOrigin(tls *libc.TLS, p uintptr, piOrigin uintptr) (r int32) { + var pStruct uintptr + _ = pStruct + pStruct = _fts5StructureRead(tls, p) + if pStruct != 0 { + **(**Ti64)(__ccgo_up(piOrigin)) = libc.Int64FromUint64((*TFts5Structure)(unsafe.Pointer(pStruct)).FnOriginCntr) + _fts5StructureRelease(tls, pStruct) + } + return _fts5IndexReturn(tls, p) +} + +func _sqlite3Fts5PoslistNext64(tls *libc.TLS, a uintptr, n int32, pi uintptr, piOff uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, v1 int32 + var iOff Ti64 + var _ /* iVal at bp+0 */ Tu32 + _, _, _ = i, iOff, v1 + i = **(**int32)(__ccgo_up(pi)) + if i >= n { + /* EOF */ + **(**Ti64)(__ccgo_up(piOff)) = int64(-int32(1)) + return int32(1) + } else { + iOff = **(**Ti64)(__ccgo_up(piOff)) + v1 = i + i = i + 1 + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**Tu8)(__ccgo_up(a + uintptr(v1)))) + if **(**Tu32)(__ccgo_up(bp))&uint32(0x80) != 0 { + i = i - 1 + i = i + _sqlite3Fts5GetVarint32(tls, a+uintptr(i), bp) + } + if **(**Tu32)(__ccgo_up(bp)) <= uint32(1) { + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + **(**int32)(__ccgo_up(pi)) = i + return 0 + } + v1 = i + i = i + 1 + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**Tu8)(__ccgo_up(a + uintptr(v1)))) + if **(**Tu32)(__ccgo_up(bp))&uint32(0x80) != 0 { + i = i - 1 + i = i + _sqlite3Fts5GetVarint32(tls, a+uintptr(i), bp) + } + iOff = libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp))) << int32(32) + v1 = i + i = i + 1 + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**Tu8)(__ccgo_up(a + uintptr(v1)))) + if **(**Tu32)(__ccgo_up(bp))&uint32(0x80) != 0 { + i = i - 1 + i = i + _sqlite3Fts5GetVarint32(tls, a+uintptr(i), bp) + } + if **(**Tu32)(__ccgo_up(bp)) < uint32(2) { + /* This is a corrupt record. So stop parsing it here. */ + **(**Ti64)(__ccgo_up(piOff)) = int64(-int32(1)) + return int32(1) + } + **(**Ti64)(__ccgo_up(piOff)) = iOff + libc.Int64FromUint32((**(**Tu32)(__ccgo_up(bp))-libc.Uint32FromInt32(2))&libc.Uint32FromInt32(0x7FFFFFFF)) + } else { + **(**Ti64)(__ccgo_up(piOff)) = iOff&(libc.Int64FromInt32(0x7FFFFFFF)<> int32(24) & int32(0x00FF)) + **(**Tu8)(__ccgo_up(aBuf + 1)) = libc.Uint8FromInt32(iVal >> int32(16) & int32(0x00FF)) + **(**Tu8)(__ccgo_up(aBuf + 2)) = libc.Uint8FromInt32(iVal >> int32(8) & int32(0x00FF)) + **(**Tu8)(__ccgo_up(aBuf + 3)) = libc.Uint8FromInt32(iVal >> 0 & int32(0x00FF)) +} + +func _sqlite3Fts5UnicodeAscii(tls *libc.TLS, aArray uintptr, aAscii uintptr) { + var bToken, i, iTbl, n int32 + _, _, _, _ = bToken, i, iTbl, n + i = 0 + iTbl = 0 + for i < int32(128) { + bToken = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aArray + uintptr(libc.Int32FromUint16(_aFts5UnicodeData[iTbl])&int32(0x1F))))) + n = libc.Int32FromUint16(_aFts5UnicodeData[iTbl])>>int32(5) + i + for { + if !(i < int32(128) && i < n) { + break + } + **(**Tu8)(__ccgo_up(aAscii + uintptr(i))) = libc.Uint8FromInt32(bToken) + goto _1 + _1: + ; + i = i + 1 + } + iTbl = iTbl + 1 + } + **(**Tu8)(__ccgo_up(aAscii)) = uint8(0) /* 0x00 is never a token character */ +} + +/* +** 2015 May 30 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** Routines for varint serialization and deserialization. + */ + +/* #include "fts5Int.h" */ + +func _sqlite3Fts5UnicodeCategory(tls *libc.TLS, iCode Tu32) (r int32) { + var iHi, iLo, iRes, iTest, ret, v1 int32 + var iKey Tu16 + _, _, _, _, _, _, _ = iHi, iKey, iLo, iRes, iTest, ret, v1 + iRes = -int32(1) + if iCode >= libc.Uint32FromInt32(libc.Int32FromInt32(1)<>int32(16)]) + iHi = libc.Int32FromUint16(_aFts5UnicodeBlock[uint32(1)+iCode>>libc.Int32FromInt32(16)]) + iKey = uint16(iCode & libc.Uint32FromInt32(0xFFFF)) + for iHi > iLo { + iTest = (iHi + iLo) / int32(2) + if libc.Int32FromUint16(iKey) >= libc.Int32FromUint16(_aFts5UnicodeMap[iTest]) { + iRes = iTest + iLo = iTest + int32(1) + } else { + iHi = iTest + } + } + if iRes < 0 { + return 0 + } + if libc.Int32FromUint16(iKey) >= libc.Int32FromUint16(_aFts5UnicodeMap[iRes])+libc.Int32FromUint16(_aFts5UnicodeData[iRes])>>int32(5) { + return 0 + } + ret = libc.Int32FromUint16(_aFts5UnicodeData[iRes]) & int32(0x1F) + if ret != int32(30) { + return ret + } + if (libc.Int32FromUint16(iKey)-libc.Int32FromUint16(_aFts5UnicodeMap[iRes]))&int32(0x01) != 0 { + v1 = int32(5) + } else { + v1 = int32(9) + } + return v1 +} + +// C documentation +// +// /* +// ** Return true if the argument interpreted as a unicode codepoint +// ** is a diacritical modifier character. +// */ +func _sqlite3Fts5UnicodeIsdiacritic(tls *libc.TLS, c int32) (r int32) { + var mask0, mask1, v1 uint32 + _, _, _ = mask0, mask1, v1 + mask0 = uint32(0x08029FDF) + mask1 = uint32(0x000361F8) + if c < int32(768) || c > int32(817) { + return 0 + } + if c < libc.Int32FromInt32(768)+libc.Int32FromInt32(32) { + v1 = mask0 & (libc.Uint32FromInt32(1) << (c - int32(768))) + } else { + v1 = mask1 & (libc.Uint32FromInt32(1) << (c - int32(768) - int32(32))) + } + return libc.Int32FromUint32(v1) +} + +// C documentation +// +// /* +// ** Interpret the given string as a boolean value. +// */ +func _sqlite3GetBoolean(tls *libc.TLS, z uintptr, dflt Tu8) (r Tu8) { + return libc.BoolUint8(libc.Int32FromUint8(_getSafetyLevel(tls, z, int32(1), dflt)) != 0) +} + +/* The sqlite3GetBoolean() function is used by other modules but the +** remainder of this file is specific to PRAGMA processing. So omit +** the rest of the file if PRAGMAs are omitted from the build. + */ + +// C documentation +// +// /* +// ** Return the length (in bytes) of the token that begins at z[0]. +// ** Store the token type in *tokenType before returning. +// */ +func _sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) (r Ti64) { + var c, delim, v3 int32 + var i, n Ti64 + var v6 bool + _, _, _, _, _, _ = c, delim, i, n, v3, v6 + switch libc.Int32FromUint8(_aiClass[**(**uint8)(__ccgo_up(z))]) { /* Switch on the character-class of the first byte + ** of the token. See the comment on the CC_ defines + ** above. */ + case int32(CC_SPACE): + i = int64(1) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x01) != 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(tokenType)) = int32(TK_SPACE) + return i + case int32(CC_MINUS): + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('-') { + i = int64(2) + for { + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) + c = v3 + if !(v3 != 0 && c != int32('\n')) { + break + } + goto _2 + _2: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(tokenType)) = int32(TK_COMMENT) + return i + } else { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('>') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_PTR) + return int64(int32(2) + libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 2))) == int32('>'))) + } + } + **(**int32)(__ccgo_up(tokenType)) = int32(TK_MINUS) + return int64(1) + case int32(CC_LP): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_LP) + return int64(1) + case int32(CC_RP): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_RP) + return int64(1) + case int32(CC_SEMI): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_SEMI) + return int64(1) + case int32(CC_PLUS): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_PLUS) + return int64(1) + case int32(CC_STAR): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_STAR) + return int64(1) + case int32(CC_SLASH): + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) != int32('*') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 2))) == 0 { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_SLASH) + return int64(1) + } + i = int64(3) + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 2))) + for { + if v6 = c != int32('*') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) != int32('/'); v6 { + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) + c = v3 + } + if !(v6 && v3 != 0) { + break + } + goto _4 + _4: + ; + i = i + 1 + } + if c != 0 { + i = i + 1 + } + **(**int32)(__ccgo_up(tokenType)) = int32(TK_COMMENT) + return i + case int32(CC_PERCENT): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_REM) + return int64(1) + case int32(CC_EQ): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_EQ) + return int64(int32(1) + libc.BoolInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('='))) + case int32(CC_LT): + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) + c = v3 + if v3 == int32('=') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_LE) + return int64(2) + } else { + if c == int32('>') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_NE) + return int64(2) + } else { + if c == int32('<') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_LSHIFT) + return int64(2) + } else { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_LT) + return int64(1) + } + } + } + fallthrough + case int32(CC_GT): + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) + c = v3 + if v3 == int32('=') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_GE) + return int64(2) + } else { + if c == int32('>') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_RSHIFT) + return int64(2) + } else { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_GT) + return int64(1) + } + } + fallthrough + case int32(CC_BANG): + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) != int32('=') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ILLEGAL) + return int64(1) + } else { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_NE) + return int64(2) + } + fallthrough + case int32(CC_PIPE): + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) != int32('|') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_BITOR) + return int64(1) + } else { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_CONCAT) + return int64(2) + } + fallthrough + case int32(CC_COMMA): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_COMMA) + return int64(1) + case int32(CC_AND): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_BITAND) + return int64(1) + case int32(CC_TILDA): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_BITNOT) + return int64(1) + case int32(CC_QUOTE): + delim = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) + i = int64(1) + for { + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) + c = v3 + if !(v3 != 0) { + break + } + if c == delim { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+int64(1))))) == delim { + i = i + 1 + } else { + break + } + } + goto _9 + _9: + ; + i = i + 1 + } + if c == int32('\'') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_STRING) + return i + int64(1) + } else { + if c != 0 { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ID) + return i + int64(1) + } else { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ILLEGAL) + return i + } + } + fallthrough + case int32(CC_DOT): + if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + 1))])&libc.Int32FromInt32(0x04) != 0) { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_DOT) + return int64(1) + } + /* If the next character is a digit, this is a floating point + ** number that begins with ".". Fall thru into the next case */ + fallthrough + case int32(CC_DIGIT): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_INTEGER) + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32('0') && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('x') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('X')) && libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + 2))])&int32(0x08) != 0 { + i = int64(3) + for { + if !(int32(1) != 0) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x08) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('_') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_QNUMBER) + } else { + break + } + } + goto _11 + _11: + ; + i = i + 1 + } + } else { + i = 0 + for { + if !(int32(1) != 0) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x04) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('_') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_QNUMBER) + } else { + break + } + } + goto _12 + _12: + ; + i = i + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('.') { + if **(**int32)(__ccgo_up(tokenType)) == int32(TK_INTEGER) { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_FLOAT) + } + i = i + 1 + for { + if !(int32(1) != 0) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x04) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('_') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_QNUMBER) + } else { + break + } + } + goto _13 + _13: + ; + i = i + 1 + } + } + if (libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('e') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('E')) && (libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i+int64(1))))])&int32(0x04) != 0 || (libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+int64(1))))) == int32('+') || libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+int64(1))))) == int32('-')) && libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i+int64(2))))])&int32(0x04) != 0) { + if **(**int32)(__ccgo_up(tokenType)) == int32(TK_INTEGER) { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_FLOAT) + } + i = i + int64(2) + for { + if !(int32(1) != 0) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x04) == 0 { + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) == int32('_') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_QNUMBER) + } else { + break + } + } + goto _14 + _14: + ; + i = i + 1 + } + } + } + for libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x46) != 0 { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ILLEGAL) + i = i + 1 + } + return i + case int32(CC_QUOTE2): + i = int64(1) + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) + for { + if v6 = c != int32(']'); v6 { + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) + c = v3 + } + if !(v6 && v3 != 0) { + break + } + goto _15 + _15: + ; + i = i + 1 + } + if c == int32(']') { + v3 = int32(TK_ID) + } else { + v3 = int32(TK_ILLEGAL) + } + **(**int32)(__ccgo_up(tokenType)) = v3 + return i + case int32(CC_VARNUM): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_VARIABLE) + i = int64(1) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x04) != 0) { + break + } + goto _19 + _19: + ; + i = i + 1 + } + return i + case int32(CC_DOLLAR): + fallthrough + case int32(CC_VARALPHA): + n = 0 + **(**int32)(__ccgo_up(tokenType)) = int32(TK_VARIABLE) + i = int64(1) + for { + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) + c = v3 + if !(v3 != 0) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt32(c)])&int32(0x46) != 0 { + n = n + 1 + } else { + if c == int32('(') && n > 0 { + for { + i = i + 1 + goto _23 + _23: + ; + v3 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) + c = v3 + if !(v3 != 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt32(c)])&libc.Int32FromInt32(0x01) != 0) && c != int32(')')) { + break + } + } + if c == int32(')') { + i = i + 1 + } else { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ILLEGAL) + } + break + } else { + if c == int32(':') && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i+int64(1))))) == int32(':') { + i = i + 1 + } else { + break + } + } + } + goto _20 + _20: + ; + i = i + 1 + } + if n == 0 { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ILLEGAL) + } + return i + case int32(CC_KYWD0): + if libc.Int32FromUint8(_aiClass[**(**uint8)(__ccgo_up(z + 1))]) > int32(CC_KYWD) { + i = int64(1) + break + } + i = int64(2) + for { + if !(libc.Int32FromUint8(_aiClass[**(**uint8)(__ccgo_up(z + uintptr(i)))]) <= int32(CC_KYWD)) { + break + } + goto _24 + _24: + ; + i = i + 1 + } + if libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x46) != 0 { + /* This token started out using characters that can appear in keywords, + ** but z[i] is a character not allowed within keywords, so this must + ** be an identifier instead */ + i = i + 1 + break + } + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ID) + return _keywordCode(tls, z, i, tokenType) + case CC_X: + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32('\'') { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_BLOB) + i = int64(2) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x08) != 0) { + break + } + goto _25 + _25: + ; + i = i + 1 + } + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) != int32('\'') || i%int64(2) != 0 { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ILLEGAL) + for **(**uint8)(__ccgo_up(z + uintptr(i))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(i)))) != int32('\'') { + i = i + 1 + } + } + if **(**uint8)(__ccgo_up(z + uintptr(i))) != 0 { + i = i + 1 + } + return i + } + /* If it is not a BLOB literal, then it must be an ID, since no + ** SQL keywords start with the letter 'x'. Fall through */ + fallthrough + case int32(CC_KYWD): + fallthrough + case int32(CC_ID): + i = int64(1) + case int32(CC_BOM): + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 1))) == int32(0xbb) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 2))) == int32(0xbf) { + **(**int32)(__ccgo_up(tokenType)) = int32(TK_SPACE) + return int64(3) + } + i = int64(1) + case int32(CC_NUL): + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ILLEGAL) + return 0 + default: + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ILLEGAL) + return int64(1) + } + for libc.Int32FromUint8(_sqlite3CtypeMap[**(**uint8)(__ccgo_up(z + uintptr(i)))])&int32(0x46) != 0 { + i = i + 1 + } + **(**int32)(__ccgo_up(tokenType)) = int32(TK_ID) + return i +} + +// C documentation +// +// /* +// ** Read a 64-bit variable-length integer from memory starting at p[0]. +// ** Return the number of bytes read. The value is stored in *v. +// */ +func _sqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) (r Tu8) { + var a, b, s Tu32 + _, _, _ = a, b, s + if int32(**(**int8)(__ccgo_up(p))) >= 0 { + **(**Tu64)(__ccgo_up(v)) = uint64(**(**uint8)(__ccgo_up(p))) + return uint8(1) + } + if int32(**(**int8)(__ccgo_up(p + 1))) >= 0 { + **(**Tu64)(__ccgo_up(v)) = uint64(libc.Uint32FromInt32(libc.Int32FromUint8(**(**uint8)(__ccgo_up(p)))&libc.Int32FromInt32(0x7f))<> int32(18) + **(**Tu64)(__ccgo_up(v)) = uint64(s)<> int32(18) + **(**Tu64)(__ccgo_up(v)) = uint64(s)<> int32(11) + **(**Tu64)(__ccgo_up(v)) = uint64(s)<> int32(4) + **(**Tu64)(__ccgo_up(v)) = uint64(s)<> int32(3) + s = s | b + **(**Tu64)(__ccgo_up(v)) = uint64(s)<>int32(6))) + return libc.Uint8FromInt32(h & libc.Int32FromInt32(0xf)) +} + +// C documentation +// +// /* Make the IdChar function accessible from ctime.c and alter.c */ +func _sqlite3IsIdChar(tls *libc.TLS, c Tu8) (r int32) { + return libc.BoolInt32(libc.Int32FromUint8(_sqlite3CtypeMap[c])&int32(0x46) != 0) +} + +// C documentation +// +// /* +// ** This function returns the collation sequence for database native text +// ** encoding identified by the string zName. +// ** +// ** If the requested collation sequence is not available, or not available +// ** in the database native encoding, the collation factory is invoked to +// ** request it. If the collation factory does not supply such a sequence, +// ** and the sequence is available in another text encoding, then that is +// ** returned instead. +// ** +// ** If no versions of the requested collations sequence are available, or +// ** another error occurs, NULL is returned and an error message written into +// ** pParse. +// ** +// ** This routine is a wrapper around sqlite3FindCollSeq(). This routine +// ** invokes the collation factory if the named collation cannot be found +// ** and generates an error message. +// ** +// ** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq() +// */ +func _sqlite3LocateCollSeq(tls *libc.TLS, pParse uintptr, zName uintptr) (r uintptr) { + var db, pColl uintptr + var enc, initbusy Tu8 + _, _, _, _ = db, enc, initbusy, pColl + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + enc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + initbusy = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy + pColl = _sqlite3FindCollSeq(tls, db, enc, zName, libc.Int32FromUint8(initbusy)) + if !(initbusy != 0) && (!(pColl != 0) || !((*TCollSeq)(unsafe.Pointer(pColl)).FxCmp != 0)) { + pColl = _sqlite3GetCollSeq(tls, pParse, enc, pColl, zName) + } + return pColl +} + +// C documentation +// +// /* +// ** Find (an approximate) sum of two LogEst values. This computation is +// ** not a simple "+" operator because LogEst is stored as a logarithmic +// ** value. +// ** +// */ +func _sqlite3LogEstAdd(tls *libc.TLS, a TLogEst, b TLogEst) (r TLogEst) { + if int32(a) >= int32(b) { + if int32(a) > int32(b)+int32(49) { + return a + } + if int32(a) > int32(b)+int32(31) { + return int16(int32(a) + int32(1)) + } + return int16(int32(a) + libc.Int32FromUint8(_x[int32(a)-int32(b)])) + } else { + if int32(b) > int32(a)+int32(49) { + return b + } + if int32(b) > int32(a)+int32(31) { + return int16(int32(b) + int32(1)) + } + return int16(int32(b) + libc.Int32FromUint8(_x[int32(b)-int32(a)])) + } + return r +} + +// C documentation +// +// /* +// ** Convert a LogEst into an integer. +// */ +func _sqlite3LogEstToInt(tls *libc.TLS, x TLogEst) (r Tu64) { + var n Tu64 + var v1 uint64 + _, _ = n, v1 + n = libc.Uint64FromInt32(int32(x) % int32(10)) + x = int16(int32(x) / libc.Int32FromInt32(10)) + if n >= uint64(5) { + n = n - uint64(2) + } else { + if n >= uint64(1) { + n = n - uint64(1) + } + } + if int32(x) > int32(60) { + return libc.Uint64FromInt64(libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)<= int32(3) { + v1 = (n + uint64(8)) << (int32(x) - int32(3)) + } else { + v1 = (n + uint64(8)) >> (int32(3) - int32(x)) + } + return v1 +} + +// C documentation +// +// /* +// ** Count the number of slots of lookaside memory that are outstanding +// */ +func _sqlite3LookasideUsed(tls *libc.TLS, db uintptr, pHighwater uintptr) (r int32) { + var nFree, nInit Tu32 + _, _ = nFree, nInit + nInit = _countLookasideSlots(tls, (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpInit) + nFree = _countLookasideSlots(tls, (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree) + nInit = nInit + _countLookasideSlots(tls, (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit) + nFree = nFree + _countLookasideSlots(tls, (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree) + if pHighwater != 0 { + **(**int32)(__ccgo_up(pHighwater)) = libc.Int32FromUint32((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot - nInit) + } + return libc.Int32FromUint32((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot - (nInit + nFree)) +} + +// C documentation +// +// /* +// ** Allocate memory. This routine is like sqlite3_malloc() except that it +// ** assumes the memory subsystem has already been initialized. +// */ +func _sqlite3Malloc(tls *libc.TLS, n Tu64) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* p at bp+0 */ uintptr + if n == uint64(0) || n > uint64(SQLITE_MAX_ALLOCATION_SIZE) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if _sqlite3Config.FbMemstat != 0 { + Xsqlite3_mutex_enter(tls, _mem0.Fmutex) + _mallocWithAlarm(tls, libc.Int32FromUint64(n), bp) + Xsqlite3_mutex_leave(tls, _mem0.Fmutex) + } else { + **(**uintptr)(__ccgo_up(bp)) = (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxMalloc})))(tls, libc.Int32FromUint64(n)) + } + } + /* IMP: R-11148-40995 */ + return **(**uintptr)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Compare the values contained by the two memory cells, returning +// ** negative, zero or positive if pMem1 is less than, equal to, or greater +// ** than pMem2. Sorting order is NULL's first, followed by numbers (integers +// ** and reals) sorted numerically, followed by text ordered by the collating +// ** sequence pColl and finally blob's ordered by memcmp(). +// ** +// ** Two NULL values are considered equal by this function. +// */ +func _sqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintptr) (r int32) { + var combined_flags, f1, f2 int32 + _, _, _ = combined_flags, f1, f2 + f1 = libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem1)).Fflags) + f2 = libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem2)).Fflags) + combined_flags = f1 | f2 + /* If one value is NULL, it is less than the other. If both values + ** are NULL, return 0. + */ + if combined_flags&int32(MEM_Null) != 0 { + return f2&int32(MEM_Null) - f1&int32(MEM_Null) + } + /* At least one of the two values is a number + */ + if combined_flags&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + if f1&f2&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + if *(*Ti64)(unsafe.Pointer(pMem1)) < *(*Ti64)(unsafe.Pointer(pMem2)) { + return -int32(1) + } + if *(*Ti64)(unsafe.Pointer(pMem1)) > *(*Ti64)(unsafe.Pointer(pMem2)) { + return +libc.Int32FromInt32(1) + } + return 0 + } + if f1&f2&int32(MEM_Real) != 0 { + if *(*float64)(unsafe.Pointer(pMem1)) < *(*float64)(unsafe.Pointer(pMem2)) { + return -int32(1) + } + if *(*float64)(unsafe.Pointer(pMem1)) > *(*float64)(unsafe.Pointer(pMem2)) { + return +libc.Int32FromInt32(1) + } + return 0 + } + if f1&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + if f2&int32(MEM_Real) != 0 { + return _sqlite3IntFloatCompare(tls, *(*Ti64)(unsafe.Pointer(pMem1)), *(*float64)(unsafe.Pointer(pMem2))) + } else { + if f2&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + if *(*Ti64)(unsafe.Pointer(pMem1)) < *(*Ti64)(unsafe.Pointer(pMem2)) { + return -int32(1) + } + if *(*Ti64)(unsafe.Pointer(pMem1)) > *(*Ti64)(unsafe.Pointer(pMem2)) { + return +libc.Int32FromInt32(1) + } + return 0 + } else { + return -int32(1) + } + } + } + if f1&int32(MEM_Real) != 0 { + if f2&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + return -_sqlite3IntFloatCompare(tls, *(*Ti64)(unsafe.Pointer(pMem2)), *(*float64)(unsafe.Pointer(pMem1))) + } else { + return -int32(1) + } + } + return +libc.Int32FromInt32(1) + } + /* If one value is a string and the other is a blob, the string is less. + ** If both are strings, compare using the collating functions. + */ + if combined_flags&int32(MEM_Str) != 0 { + if f1&int32(MEM_Str) == 0 { + return int32(1) + } + if f2&int32(MEM_Str) == 0 { + return -int32(1) + } + /* The collation sequence must be defined at this point, even if + ** the user deletes the collation sequence after the vdbe program is + ** compiled (this was not always the case). + */ + if pColl != 0 { + return _vdbeCompareMemString(tls, pMem1, pMem2, pColl, uintptr(0)) + } + /* If a NULL pointer was passed as the collate function, fall through + ** to the blob case and use memcmp(). */ + } + /* Both values must be blobs. Compare using memcmp(). */ + return _sqlite3BlobCompare(tls, pMem1, pMem2) +} + +// C documentation +// +// /* +// ** Invoke sqlite3AtoF() on the text value of pMem. Write the +// ** translation of the text input into *pValue. +// ** +// ** The caller must ensure that pMem->db!=0 and that pMem is in +// ** mode MEM_Str or MEM_Blob. +// ** +// ** Result code invariants: +// ** +// ** rc==0 => ERROR: Input string not well-formed, or OOM +// ** rc<0 => Some prefix of the input is well-formed +// ** rc>0 => All of the input is well-formed +// ** (rc&2)==0 => The number is expressed as an integer, with no +// ** decimal point or eNNN suffix. +// */ +func _sqlite3MemRealValueRC(tls *libc.TLS, pMem uintptr, pValue uintptr) (r int32) { + if (*TMem)(unsafe.Pointer(pMem)).Fz == uintptr(0) { + **(**float64)(__ccgo_up(pValue)) = float64(0) + return 0 + } else { + if libc.Int32FromUint8((*TMem)(unsafe.Pointer(pMem)).Fenc) == int32(SQLITE_UTF8) && (libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_Term) != 0 || _sqlite3VdbeMemZeroTerminateIfAble(tls, pMem) != 0) { + return _sqlite3AtoF(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, pValue) + } else { + if (*TMem)(unsafe.Pointer(pMem)).Fn == 0 { + **(**float64)(__ccgo_up(pValue)) = float64(0) + return 0 + } else { + return _sqlite3MemRealValueRCSlowPath(tls, pMem, pValue) + } + } + } + return r +} + +// C documentation +// +// /* +// ** Generate code that will +// ** +// ** (1) acquire a lock for table pTab then +// ** (2) open pTab as cursor iCur. +// ** +// ** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index +// ** for that table that is actually opened. +// */ +func _sqlite3OpenTable(tls *libc.TLS, pParse uintptr, iCur int32, iDb int32, pTab uintptr, opcode int32) { + var pPk, v uintptr + var v1 int32 + _, _, _ = pPk, v, v1 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FnoSharedCache != 0) { + if opcode == int32(OP_OpenWrite) { + v1 = int32(1) + } else { + v1 = 0 + } + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, libc.Uint8FromInt32(v1), (*TTable)(unsafe.Pointer(pTab)).FzName) + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp4Int(tls, v, opcode, iCur, libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab)).Ftnum), iDb, int32((*TTable)(unsafe.Pointer(pTab)).FnNVCol)) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + _sqlite3VdbeAddOp3(tls, v, opcode, iCur, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pPk)).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) + } +} + +func _sqlite3OsOpenMalloc(tls *libc.TLS, pVfs uintptr, zFile uintptr, ppFile uintptr, flags int32, pOutFlags uintptr) (r int32) { + var pFile uintptr + var rc int32 + _, _ = pFile, rc + pFile = _sqlite3MallocZero(tls, libc.Uint64FromInt32((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) + if pFile != 0 { + rc = _sqlite3OsOpen(tls, pVfs, zFile, pFile, flags, pOutFlags) + if rc != SQLITE_OK { + Xsqlite3_free(tls, pFile) + **(**uintptr)(__ccgo_up(ppFile)) = uintptr(0) + } else { + **(**uintptr)(__ccgo_up(ppFile)) = pFile + } + } else { + **(**uintptr)(__ccgo_up(ppFile)) = uintptr(0) + rc = int32(SQLITE_NOMEM) + } + return rc +} + +// C documentation +// +// /* Create a TK_IS or TK_ISNOT operator, perhaps optimized to +// ** TK_ISNULL or TK_NOTNULL or TK_TRUEFALSE. */ +func _sqlite3PExprIs(tls *libc.TLS, pParse uintptr, op int32, pLeft uintptr, pRight uintptr) (r uintptr) { + var v1 int32 + _ = v1 + if pRight != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) == int32(TK_NULL) { + _sqlite3ExprDeferredDelete(tls, pParse, pRight) + if op == int32(TK_IS) { + v1 = int32(TK_ISNULL) + } else { + v1 = int32(TK_NOTNULL) + } + return _sqlite3PExprIsNull(tls, pParse, v1, pLeft) + } + return _sqlite3PExpr(tls, pParse, op, pLeft, pRight) +} + +// C documentation +// +// /* Create a TK_ISNULL or TK_NOTNULL expression, perhaps optimized to +// ** to TK_TRUEFALSE, if possible */ +func _sqlite3PExprIsNull(tls *libc.TLS, pParse uintptr, op int32, pLeft uintptr) (r uintptr) { + var p uintptr + _ = p + p = pLeft + for libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UPLUS) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_UMINUS) { + p = (*TExpr)(unsafe.Pointer(p)).FpLeft + } + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) { + case int32(TK_INTEGER): + fallthrough + case int32(TK_STRING): + fallthrough + case int32(TK_FLOAT): + fallthrough + case int32(TK_BLOB): + _sqlite3ExprDeferredDelete(tls, pParse, pLeft) + return _sqlite3ExprInt32(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, libc.BoolInt32(op == int32(TK_NOTNULL))) + default: + break + } + return _sqlite3PExpr(tls, pParse, op, pLeft, uintptr(0)) +} + +// C documentation +// +// /* +// ** Begin a write-transaction on the specified pager object. If a +// ** write-transaction has already been opened, this function is a no-op. +// ** +// ** If the exFlag argument is false, then acquire at least a RESERVED +// ** lock on the database file. If exFlag is true, then acquire at least +// ** an EXCLUSIVE lock. If such a lock is already held, no locking +// ** functions need be called. +// ** +// ** If the subjInMemory argument is non-zero, then any sub-journal opened +// ** within this transaction will be opened as an in-memory file. This +// ** has no effect if the sub-journal is already opened (as it may be when +// ** running in exclusive mode) or if the transaction does not require a +// ** sub-journal. If the subjInMemory argument is zero, then any required +// ** sub-journal is implemented in-memory if pPager is an in-memory database, +// ** or using a temporary file otherwise. +// */ +func _sqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemory int32) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if (*TPager)(unsafe.Pointer(pPager)).FerrCode != 0 { + return (*TPager)(unsafe.Pointer(pPager)).FerrCode + } + (*TPager)(unsafe.Pointer(pPager)).FsubjInMemory = libc.Uint8FromInt32(subjInMemory) + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_READER) { + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + /* If the pager is configured to use locking_mode=exclusive, and an + ** exclusive lock on the database is not already held, obtain it now. + */ + if (*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 && _sqlite3WalExclusiveMode(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, -int32(1)) != 0 { + rc = _pagerLockDb(tls, pPager, int32(EXCLUSIVE_LOCK)) + if rc != SQLITE_OK { + return rc + } + _sqlite3WalExclusiveMode(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, int32(1)) + } + /* Grab the write lock on the log file. If successful, upgrade to + ** PAGER_RESERVED state. Otherwise, return an error code to the caller. + ** The busy-handler is not invoked if another connection already + ** holds the write-lock. If possible, the upper layer will call it. + */ + rc = _sqlite3WalBeginWriteTransaction(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) + } else { + /* Obtain a RESERVED lock on the database file. If the exFlag parameter + ** is true, then immediately upgrade this to an EXCLUSIVE lock. The + ** busy-handler callback can be used when upgrading to the EXCLUSIVE + ** lock, but not when obtaining the RESERVED lock. + */ + rc = _pagerLockDb(tls, pPager, int32(RESERVED_LOCK)) + if rc == SQLITE_OK && exFlag != 0 { + rc = _pager_wait_on_lock(tls, pPager, int32(EXCLUSIVE_LOCK)) + } + } + if rc == SQLITE_OK { + /* Change to WRITER_LOCKED state. + ** + ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD + ** when it has an open transaction, but never to DBMOD or FINISHED. + ** This is because in those states the code to roll back savepoint + ** transactions may copy data from the sub-journal into the database + ** file as well as into the page cache. Which would be incorrect in + ** WAL mode. + */ + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_WRITER_LOCKED) + (*TPager)(unsafe.Pointer(pPager)).FdbHintSize = (*TPager)(unsafe.Pointer(pPager)).FdbSize + (*TPager)(unsafe.Pointer(pPager)).FdbFileSize = (*TPager)(unsafe.Pointer(pPager)).FdbSize + (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize = (*TPager)(unsafe.Pointer(pPager)).FdbSize + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + } + } + return rc +} + +// C documentation +// +// /* +// ** Unless this is an in-memory or temporary database, clear the pager cache. +// */ +func _sqlite3PagerClearCache(tls *libc.TLS, pPager uintptr) { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FtempFile) == 0 { + _pager_reset(tls, pPager) + } +} + +// C documentation +// +// /* +// ** Shutdown the page cache. Free all memory and close all files. +// ** +// ** If a transaction was in progress when this routine is called, that +// ** transaction is rolled back. All outstanding pages are invalidated +// ** and their memory is freed. Any attempt to use a page associated +// ** with this page cache after this function returns will likely +// ** result in a coredump. +// ** +// ** This function always succeeds. If a transaction is active an attempt +// ** is made to roll it back. If an error occurs during the rollback +// ** a hot journal may be left in the filesystem but no error is returned +// ** to the caller. +// */ +func _sqlite3PagerClose(tls *libc.TLS, pPager uintptr, db uintptr) (r int32) { + var a, pTmp uintptr + _, _ = a, pTmp + pTmp = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace + _sqlite3BeginBenignMalloc(tls) + _pagerFreeMapHdrs(tls, pPager) + /* pPager->errCode = 0; */ + (*TPager)(unsafe.Pointer(pPager)).FexclusiveMode = uint8(0) + a = uintptr(0) + if db != 0 && uint64(0) == (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NoCkptOnClose) && SQLITE_OK == _databaseIsUnmoved(tls, pPager) { + a = pTmp + } + _sqlite3WalClose(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, db, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FwalSyncFlags), int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), a) + (*TPager)(unsafe.Pointer(pPager)).FpWal = uintptr(0) + _pager_reset(tls, pPager) + if (*TPager)(unsafe.Pointer(pPager)).FmemDb != 0 { + _pager_unlock(tls, pPager) + } else { + /* If it is open, sync the journal file before calling UnlockAndRollback. + ** If this is not done, then an unsynced portion of the open journal + ** file may be played back into the database. If a power failure occurs + ** while this is happening, the database could become corrupt. + ** + ** If an error occurs while trying to sync the journal, shift the pager + ** into the ERROR state. This causes UnlockAndRollback to unlock the + ** database and close the journal file without attempting to roll it + ** back or finalize it. The next database user will have to do hot-journal + ** rollback before accessing the database file. + */ + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) { + _pager_error(tls, pPager, _pagerSyncHotJournal(tls, pPager)) + } + _pagerUnlockAndRollback(tls, pPager) + } + _sqlite3EndBenignMalloc(tls) + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd) + _sqlite3PageFree(tls, pTmp) + _sqlite3PcacheClose(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + Xsqlite3_free(tls, pPager) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is called to close the connection to the log file prior +// ** to switching from WAL to rollback mode. +// ** +// ** Before closing the log file, this function attempts to take an +// ** EXCLUSIVE lock on the database file. If this cannot be obtained, an +// ** error (SQLITE_BUSY) is returned and the log connection is not closed. +// ** If successful, the EXCLUSIVE lock is not released before returning. +// */ +func _sqlite3PagerCloseWal(tls *libc.TLS, pPager uintptr, db uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* logexists at bp+0 */ int32 + _ = rc + rc = SQLITE_OK + /* If the log file is not already open, but does exist in the file-system, + ** it may need to be checkpointed before the connection can switch to + ** rollback mode. Open it now so this can happen. + */ + if !((*TPager)(unsafe.Pointer(pPager)).FpWal != 0) { + **(**int32)(__ccgo_up(bp)) = 0 + rc = _pagerLockDb(tls, pPager, int32(SHARED_LOCK)) + if rc == SQLITE_OK { + rc = _sqlite3OsAccess(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, (*TPager)(unsafe.Pointer(pPager)).FzWal, SQLITE_ACCESS_EXISTS, bp) + } + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp)) != 0 { + rc = _pagerOpenWal(tls, pPager) + } + } + /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on + ** the database file, the log and log-summary files will be deleted. + */ + if rc == SQLITE_OK && (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 { + rc = _pagerExclusiveLock(tls, pPager) + if rc == SQLITE_OK { + rc = _sqlite3WalClose(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, db, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FwalSyncFlags), int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace) + (*TPager)(unsafe.Pointer(pPager)).FpWal = uintptr(0) + _pagerFixMaplimit(tls, pPager) + if rc != 0 && !((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) { + _pagerUnlockDb(tls, pPager, int32(SHARED_LOCK)) + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Sync the database file for the pager pPager. zSuper points to the name +// ** of a super-journal file that should be written into the individual +// ** journal file. zSuper may be NULL, which is interpreted as no +// ** super-journal (a single database transaction). +// ** +// ** This routine ensures that: +// ** +// ** * The database file change-counter is updated, +// ** * the journal is synced (unless the atomic-write optimization is used), +// ** * all dirty pages are written to the database file, +// ** * the database file is truncated (if required), and +// ** * the database file synced. +// ** +// ** The only thing that remains to commit the transaction is to finalize +// ** (delete, truncate or zero the first part of) the journal file (or +// ** delete the super-journal file if specified). +// ** +// ** Note that if zSuper==NULL, this does not overwrite a previous value +// ** passed to an sqlite3PagerCommitPhaseOne() call. +// ** +// ** If the final parameter - noSync - is true, then the database file itself +// ** is not synced. The caller must call sqlite3PagerSync() directly to +// ** sync the database file before calling CommitPhaseTwo() to delete the +// ** journal file in this case. +// */ +func _sqlite3PagerCommitPhaseOne(tls *libc.TLS, pPager uintptr, zSuper uintptr, noSync int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var nNew TPgno + var pList uintptr + var rc int32 + var _ /* pPageOne at bp+0 */ uintptr + _, _, _ = nNew, pList, rc + rc = SQLITE_OK /* Return code */ + /* If a prior error occurred, report that error again. */ + if (*TPager)(unsafe.Pointer(pPager)).FerrCode != 0 { + return (*TPager)(unsafe.Pointer(pPager)).FerrCode + } + /* Provide the ability to easily simulate an I/O error during testing */ + if _sqlite3FaultSim(tls, int32(400)) != 0 { + return int32(SQLITE_IOERR) + } + /* If no database changes have been made, return early. */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) < int32(PAGER_WRITER_CACHEMOD) { + return SQLITE_OK + } + if 0 == _pagerFlushOnCommit(tls, pPager, int32(1)) { + /* If this is an in-memory db, or no pages have been written to, or this + ** function has already been called, it is mostly a no-op. However, any + ** backup in progress needs to be restarted. */ + _sqlite3BackupRestart(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup) + } else { + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pList = _sqlite3PcacheDirtyList(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + if pList == uintptr(0) { + /* Must have at least one page for the WAL commit flag. + ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */ + rc = _sqlite3PagerGet(tls, pPager, uint32(1), bp, 0) + pList = **(**uintptr)(__ccgo_up(bp)) + (*TPgHdr)(unsafe.Pointer(pList)).FpDirty = uintptr(0) + } + if pList != 0 { + rc = _pagerWalFrames(tls, pPager, pList, (*TPager)(unsafe.Pointer(pPager)).FdbSize, int32(1)) + } + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + _sqlite3PcacheCleanAll(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + } + } else { + /* The bBatch boolean is true if the batch-atomic-write commit method + ** should be used. No rollback journal is created if batch-atomic-write + ** is enabled. + */ + rc = _pager_incr_changecounter(tls, pPager, 0) + if rc != SQLITE_OK { + goto commit_phase_one_exit + } + /* Write the super-journal name into the journal file. If a + ** super-journal file name has already been written to the journal file, + ** or if zSuper is NULL (no super-journal), then this call is a no-op. + */ + rc = _writeSuperJournal(tls, pPager, zSuper) + if rc != SQLITE_OK { + goto commit_phase_one_exit + } + /* Sync the journal file and write all dirty pages to the database. + ** If the atomic-update optimization is being used, this sync will not + ** create the journal file or perform any real IO. + ** + ** Because the change-counter page was just modified, unless the + ** atomic-update optimization is used it is almost certain that the + ** journal requires a sync here. However, in locking_mode=exclusive + ** on a system under memory pressure it is just possible that this is + ** not the case. In this case it is likely enough that the redundant + ** xSync() call will be changed to a no-op by the OS anyhow. + */ + rc = _syncJournal(tls, pPager, 0) + if rc != SQLITE_OK { + goto commit_phase_one_exit + } + pList = _sqlite3PcacheDirtyList(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + if true { + rc = _pager_write_pagelist(tls, pPager, pList) + } + if rc != SQLITE_OK { + goto commit_phase_one_exit + } + _sqlite3PcacheCleanAll(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) + /* If the file on disk is smaller than the database image, use + ** pager_truncate to grow the file here. This can happen if the database + ** image was extended as part of the current transaction and then the + ** last page in the db image moved to the free-list. In this case the + ** last page is never written out to disk, leaving the database file + ** undersized. Fix this now if it is the case. */ + if (*TPager)(unsafe.Pointer(pPager)).FdbSize > (*TPager)(unsafe.Pointer(pPager)).FdbFileSize { + nNew = (*TPager)(unsafe.Pointer(pPager)).FdbSize - libc.BoolUint32((*TPager)(unsafe.Pointer(pPager)).FdbSize == (*TPager)(unsafe.Pointer(pPager)).FlckPgno) + rc = _pager_truncate(tls, pPager, nNew) + if rc != SQLITE_OK { + goto commit_phase_one_exit + } + } + /* Finally, sync the database file. */ + if !(noSync != 0) { + rc = _sqlite3PagerSync(tls, pPager, zSuper) + } + } + } + goto commit_phase_one_exit +commit_phase_one_exit: + ; + if rc == SQLITE_OK && !((*TPager)(unsafe.Pointer(pPager)).FpWal != libc.UintptrFromInt32(0)) { + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_WRITER_FINISHED) + } + return rc +} + +// C documentation +// +// /* +// ** When this function is called, the database file has been completely +// ** updated to reflect the changes made by the current transaction and +// ** synced to disk. The journal file still exists in the file-system +// ** though, and if a failure occurs at this point it will eventually +// ** be used as a hot-journal and the current transaction rolled back. +// ** +// ** This function finalizes the journal file, either by deleting, +// ** truncating or partially zeroing it, so that it cannot be used +// ** for hot-journal rollback. Once this is done the transaction is +// ** irrevocably committed. +// ** +// ** If an error occurs, an IO error code is returned and the pager +// ** moves into the error state. Otherwise, SQLITE_OK is returned. +// */ +func _sqlite3PagerCommitPhaseTwo(tls *libc.TLS, pPager uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK /* Return code */ + /* This routine should not be called if a prior error has occurred. + ** But if (due to a coding error elsewhere in the system) it does get + ** called, just return the same error code without doing anything. */ + if (*TPager)(unsafe.Pointer(pPager)).FerrCode != 0 { + return (*TPager)(unsafe.Pointer(pPager)).FerrCode + } + (*TPager)(unsafe.Pointer(pPager)).FiDataVersion = (*TPager)(unsafe.Pointer(pPager)).FiDataVersion + 1 + /* An optimization. If the database was not actually modified during + ** this transaction, the pager is running in exclusive-mode and is + ** using persistent journals, then this function is a no-op. + ** + ** The start of the journal file currently contains a single journal + ** header with the nRec field set to 0. If such a journal is used as + ** a hot-journal during hot-journal rollback, 0 changes will be made + ** to the database file. So there is no need to zero the journal + ** header. Since the pager is in exclusive mode, there is no need + ** to drop any locks either. + */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_WRITER_LOCKED) && (*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_PERSIST) { + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_READER) + return SQLITE_OK + } + rc = _pager_end_transaction(tls, pPager, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FsetSuper), int32(1)) + return _pager_error(tls, pPager, rc) +} + +// C documentation +// +// /* +// ** Return the current journal mode. +// */ +func _sqlite3PagerGetJournalMode(tls *libc.TLS, pPager uintptr) (r int32) { + return libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) +} + +// C documentation +// +// /* +// ** Get/set the locking-mode for this pager. Parameter eMode must be one +// ** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or +// ** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then +// ** the locking-mode is set to the value specified. +// ** +// ** The returned value is either PAGER_LOCKINGMODE_NORMAL or +// ** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated) +// ** locking-mode. +// */ +func _sqlite3PagerLockingMode(tls *libc.TLS, pPager uintptr, eMode int32) (r int32) { + if eMode >= 0 && !((*TPager)(unsafe.Pointer(pPager)).FtempFile != 0) && !(_sqlite3WalHeapMemory(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) != 0) { + (*TPager)(unsafe.Pointer(pPager)).FexclusiveMode = libc.Uint8FromInt32(eMode) + } + return libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode) +} + +// C documentation +// +// /* +// ** Return TRUE if the pager is in a state where it is OK to change the +// ** journalmode. Journalmode changes can only happen when the database +// ** is unmodified. +// */ +func _sqlite3PagerOkToChangeJournalMode(tls *libc.TLS, pPager uintptr) (r int32) { + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) >= int32(PAGER_WRITER_CACHEMOD) { + return 0 + } + if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) && (*TPager)(unsafe.Pointer(pPager)).FjournalOff > 0 { + return 0 + } + return int32(1) +} + +// C documentation +// +// /* +// ** This function may only be called when a read-transaction is open on +// ** the pager. It returns the total number of pages in the database. +// ** +// ** However, if the file is between 1 and bytes in size, then +// ** this is considered a 1 page file. +// */ +func _sqlite3PagerPagecount(tls *libc.TLS, pPager uintptr, pnPage uintptr) { + **(**int32)(__ccgo_up(pnPage)) = libc.Int32FromUint32((*TPager)(unsafe.Pointer(pPager)).FdbSize) +} + +// C documentation +// +// /* +// ** If a write transaction is open, then all changes made within the +// ** transaction are reverted and the current write-transaction is closed. +// ** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR +// ** state if an error occurs. +// ** +// ** If the pager is already in PAGER_ERROR state when this function is called, +// ** it returns Pager.errCode immediately. No work is performed in this case. +// ** +// ** Otherwise, in rollback mode, this function performs two functions: +// ** +// ** 1) It rolls back the journal file, restoring all database file and +// ** in-memory cache pages to the state they were in when the transaction +// ** was opened, and +// ** +// ** 2) It finalizes the journal file, so that it is not used for hot +// ** rollback at any point in the future. +// ** +// ** Finalization of the journal file (task 2) is only performed if the +// ** rollback is successful. +// ** +// ** In WAL mode, all cache-entries containing data modified within the +// ** current transaction are either expelled from the cache or reverted to +// ** their pre-transaction state by re-reading data from the database or +// ** WAL files. The WAL transaction is then closed. +// */ +func _sqlite3PagerRollback(tls *libc.TLS, pPager uintptr) (r int32) { + var eState, rc, rc2 int32 + _, _, _ = eState, rc, rc2 + rc = SQLITE_OK /* Return code */ + /* PagerRollback() is a no-op if called in READER or OPEN state. If + ** the pager is already in the ERROR state, the rollback is not + ** attempted here. Instead, the error code is returned to the caller. + */ + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_ERROR) { + return (*TPager)(unsafe.Pointer(pPager)).FerrCode + } + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) <= int32(PAGER_READER) { + return SQLITE_OK + } + if (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { + rc = _sqlite3PagerSavepoint(tls, pPager, int32(SAVEPOINT_ROLLBACK), -int32(1)) + rc2 = _pager_end_transaction(tls, pPager, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FsetSuper), 0) + if rc == SQLITE_OK { + rc = rc2 + } + } else { + if !((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != libc.UintptrFromInt32(0)) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_WRITER_LOCKED) { + eState = libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) + rc = _pager_end_transaction(tls, pPager, 0, 0) + if !((*TPager)(unsafe.Pointer(pPager)).FmemDb != 0) && eState > int32(PAGER_WRITER_LOCKED) { + /* This can happen using journal_mode=off. Move the pager to the error + ** state to indicate that the contents of the cache may not be trusted. + ** Any active readers will get SQLITE_ABORT. + */ + (*TPager)(unsafe.Pointer(pPager)).FerrCode = int32(SQLITE_ABORT) + (*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_ERROR) + _setGetterMethod(tls, pPager) + return rc + } + } else { + rc = _pager_playback(tls, pPager, 0) + } + } + /* If an error occurs during a ROLLBACK, we can no longer trust the pager + ** cache. So call pager_error() on the way out to make any error persistent. + */ + return _pager_error(tls, pPager, rc) +} + +// C documentation +// +// /* +// ** Set the journal-mode for this pager. Parameter eMode must be one of: +// ** +// ** PAGER_JOURNALMODE_DELETE +// ** PAGER_JOURNALMODE_TRUNCATE +// ** PAGER_JOURNALMODE_PERSIST +// ** PAGER_JOURNALMODE_OFF +// ** PAGER_JOURNALMODE_MEMORY +// ** PAGER_JOURNALMODE_WAL +// ** +// ** The journalmode is set to the value specified if the change is allowed. +// ** The change may be disallowed for the following reasons: +// ** +// ** * An in-memory database can only have its journal_mode set to _OFF +// ** or _MEMORY. +// ** +// ** * Temporary databases cannot have _WAL journalmode. +// ** +// ** The returned indicate the current (possibly updated) journal-mode. +// */ +func _sqlite3PagerSetJournalMode(tls *libc.TLS, pPager uintptr, eMode int32) (r int32) { + var eOld Tu8 + var rc, state int32 + _, _, _ = eOld, rc, state + eOld = (*TPager)(unsafe.Pointer(pPager)).FjournalMode /* Prior journalmode */ + /* The eMode parameter is always valid */ + /* This routine is only called from the OP_JournalMode opcode, and + ** the logic there will never allow a temporary file to be changed + ** to WAL mode. + */ + /* Do allow the journalmode of an in-memory database to be set to + ** anything other than MEMORY or OFF + */ + if (*TPager)(unsafe.Pointer(pPager)).FmemDb != 0 { + if eMode != int32(PAGER_JOURNALMODE_MEMORY) && eMode != int32(PAGER_JOURNALMODE_OFF) { + eMode = libc.Int32FromUint8(eOld) + } + } + if eMode != libc.Int32FromUint8(eOld) { + /* Change the journal mode. */ + (*TPager)(unsafe.Pointer(pPager)).FjournalMode = libc.Uint8FromInt32(eMode) + /* When transitioning from TRUNCATE or PERSIST to any other journal + ** mode except WAL, unless the pager is in locking_mode=exclusive mode, + ** delete the journal file. + */ + if !((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) && libc.Int32FromUint8(eOld)&int32(5) == int32(1) && eMode&int32(1) == 0 { + /* In this case we would like to delete the journal file. If it is + ** not possible, then that is not a problem. Deleting the journal file + ** here is an optimization only. + ** + ** Before deleting the journal file, obtain a RESERVED lock on the + ** database file. This ensures that the journal file is not deleted + ** while it is in use by some other client. + */ + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) >= int32(RESERVED_LOCK) { + _sqlite3OsDelete(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, (*TPager)(unsafe.Pointer(pPager)).FzJournal, 0) + } else { + rc = SQLITE_OK + state = libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) + if state == PAGER_OPEN { + rc = _sqlite3PagerSharedLock(tls, pPager) + } + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_READER) { + rc = _pagerLockDb(tls, pPager, int32(RESERVED_LOCK)) + } + if rc == SQLITE_OK { + _sqlite3OsDelete(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, (*TPager)(unsafe.Pointer(pPager)).FzJournal, 0) + } + if rc == SQLITE_OK && state == int32(PAGER_READER) { + _pagerUnlockDb(tls, pPager, int32(SHARED_LOCK)) + } else { + if state == PAGER_OPEN { + _pager_unlock(tls, pPager) + } + } + } + } else { + if eMode == int32(PAGER_JOURNALMODE_OFF) || eMode == int32(PAGER_JOURNALMODE_MEMORY) { + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd) + } + } + } + /* Return the new journal mode */ + return libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) +} + +// C documentation +// +// /* +// ** Sync the database file to disk. This is a no-op for in-memory databases +// ** or pages with the Pager.noSync flag set. +// ** +// ** If successful, or if called on a pager for which it is a no-op, this +// ** function returns SQLITE_OK. Otherwise, an IO error code is returned. +// */ +func _sqlite3PagerSync(tls *libc.TLS, pPager uintptr, zSuper uintptr) (r int32) { + var pArg uintptr + var rc int32 + _, _ = pArg, rc + rc = SQLITE_OK + pArg = zSuper + rc = _sqlite3OsFileControl(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_SYNC), pArg) + if rc == int32(SQLITE_NOTFOUND) { + rc = SQLITE_OK + } + if rc == SQLITE_OK && !((*TPager)(unsafe.Pointer(pPager)).FnoSync != 0) { + rc = _sqlite3OsSync(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FsyncFlags)) + } + return rc +} + +// C documentation +// +// /* +// ** Release a page reference. +// ** +// ** The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be used +// ** if we know that the page being released is not the last reference to page1. +// ** The btree layer always holds page1 open until the end, so these first +// ** two routines can be used to release any page other than BtShared.pPage1. +// ** The assert() at tag-20230419-2 proves that this constraint is always +// ** honored. +// ** +// ** Use sqlite3PagerUnrefPageOne() to release page1. This latter routine +// ** checks the total number of outstanding pages and if the number of +// ** pages reaches zero it drops the database lock. +// */ +func _sqlite3PagerUnrefNotNull(tls *libc.TLS, pPg uintptr) { + if libc.Int32FromUint16((*TDbPage)(unsafe.Pointer(pPg)).Fflags)&int32(PGHDR_MMAP) != 0 { + /* Page1 is never memory mapped */ + _pagerReleaseMapPage(tls, pPg) + } else { + _sqlite3PcacheRelease(tls, pPg) + } + /* Do not use this routine to release the last reference to page1 */ + /* tag-20230419-2 */ +} + +// C documentation +// +// /* +// ** Mark a data page as writeable. This routine must be called before +// ** making changes to a page. The caller must check the return value +// ** of this function and be careful not to change any page data unless +// ** this routine returns SQLITE_OK. +// ** +// ** The difference between this function and pager_write() is that this +// ** function also deals with the special case where 2 or more pages +// ** fit on a single disk sector. In this case all co-resident pages +// ** must have been written to the journal file before returning. +// ** +// ** If an error occurs, SQLITE_NOMEM or an IO error code is returned +// ** as appropriate. Otherwise, SQLITE_OK. +// */ +func _sqlite3PagerWrite(tls *libc.TLS, pPg uintptr) (r int32) { + var pPager uintptr + _ = pPager + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pPg)).Fflags)&int32(PGHDR_WRITEABLE) != 0 && (*TPager)(unsafe.Pointer(pPager)).FdbSize >= (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno { + if (*TPager)(unsafe.Pointer(pPager)).FnSavepoint != 0 { + return _subjournalPageIfRequired(tls, pPg) + } + return SQLITE_OK + } else { + if (*TPager)(unsafe.Pointer(pPager)).FerrCode != 0 { + return (*TPager)(unsafe.Pointer(pPager)).FerrCode + } else { + if (*TPager)(unsafe.Pointer(pPager)).FsectorSize > libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) { + return _pagerWriteLargeSector(tls, pPg) + } else { + return _pager_write(tls, pPg) + } + } + } + return r +} + +/* +** Return TRUE if the page given in the argument was previously passed +** to sqlite3PagerWrite(). In other words, return TRUE if it is ok +** to change the content of the page. + */ + +// C documentation +// +// /* +// ** Free all memory allocations in the pParse object +// */ +func _sqlite3ParseObjectReset(tls *libc.TLS, pParse uintptr) { + var db, pCleanup uintptr + var v1 int32 + _, _, _ = db, pCleanup, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FaTableLock != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TParse)(unsafe.Pointer(pParse)).FaTableLock) + } + for (*TParse)(unsafe.Pointer(pParse)).FpCleanup != 0 { + pCleanup = (*TParse)(unsafe.Pointer(pParse)).FpCleanup + (*TParse)(unsafe.Pointer(pParse)).FpCleanup = (*TParseCleanup)(unsafe.Pointer(pCleanup)).FpNext + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TParseCleanup)(unsafe.Pointer(pCleanup)).FxCleanup})))(tls, db, (*TParseCleanup)(unsafe.Pointer(pCleanup)).FpPtr) + _sqlite3DbNNFreeNN(tls, db, pCleanup) + } + if (*TParse)(unsafe.Pointer(pParse)).FaLabel != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TParse)(unsafe.Pointer(pParse)).FaLabel) + } + if (*TParse)(unsafe.Pointer(pParse)).FpConstExpr != 0 { + _sqlite3ExprListDelete(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpConstExpr) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable -= uint32((*TParse)(unsafe.Pointer(pParse)).FdisableLookaside) + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v1 = 0 + } else { + v1 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v1) + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = (*TParse)(unsafe.Pointer(pParse)).FpOuterParse +} + +// C documentation +// +// /* +// ** Return the fallback token corresponding to canonical token iToken, or +// ** 0 if iToken has no fallback. +// */ +func _sqlite3ParserFallback(tls *libc.TLS, iToken int32) (r int32) { + return libc.Int32FromUint16(_yyFallback[iToken]) +} + +/************** End of parse.c ***********************************************/ +/************** Begin file tokenize.c ****************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** An tokenizer for SQL +** +** This file contains C code that splits an SQL input string up into +** individual tokens and sends those tokens one-by-one over to the +** parser for analysis. + */ +/* #include "sqliteInt.h" */ +/* #include */ + +/* Character classes for tokenizing +** +** In the sqlite3GetToken() function, a switch() on aiClass[c] is implemented +** using a lookup table, whereas a switch() directly on c uses a binary search. +** The lookup table is much faster. To maximize speed, and to ensure that +** a lookup table is used, all of the classes need to be small integers and +** all of them need to be used within the switch. + */ + +// C documentation +// +// /* +// ** Drop a page from the cache. There must be exactly one reference to the +// ** page. This function deletes that reference, so after it returns the +// ** page pointed to by p is invalid. +// */ +func _sqlite3PcacheDrop(tls *libc.TLS, p uintptr) { + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(p)).Fflags)&int32(PGHDR_DIRTY) != 0 { + _pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_REMOVE)) + } + (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum = (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum - 1 + (*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxUnpin})))(tls, (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FpCache, (*TPgHdr)(unsafe.Pointer(p)).FpPage, int32(1)) +} + +// C documentation +// +// /* +// ** Try to obtain a page from the cache. +// ** +// ** This routine returns a pointer to an sqlite3_pcache_page object if +// ** such an object is already in cache, or if a new one is created. +// ** This routine returns a NULL pointer if the object was not in cache +// ** and could not be created. +// ** +// ** The createFlags should be 0 to check for existing pages and should +// ** be 3 (not 1, but 3) to try to create a new page. +// ** +// ** If the createFlag is 0, then NULL is always returned if the page +// ** is not already in the cache. If createFlag is 1, then a new page +// ** is created only if that can be done without spilling dirty pages +// ** and without exceeding the cache size limit. +// ** +// ** The caller needs to invoke sqlite3PcacheFetchFinish() to properly +// ** initialize the sqlite3_pcache_page object and convert it into a +// ** PgHdr object. The sqlite3PcacheFetch() and sqlite3PcacheFetchFinish() +// ** routines are split this way for performance reasons. When separated +// ** they can both (usually) operate without having to push values to +// ** the stack on entry and pop them back off on exit, which saves a +// ** lot of pushing and popping. +// */ +func _sqlite3PcacheFetch(tls *libc.TLS, pCache uintptr, pgno TPgno, createFlag int32) (r uintptr) { + var eCreate int32 + var pRes uintptr + _, _ = eCreate, pRes + /* eCreate defines what to do if the page does not exist. + ** 0 Do not allocate a new page. (createFlag==0) + ** 1 Allocate a new page if doing so is inexpensive. + ** (createFlag==1 AND bPurgeable AND pDirty) + ** 2 Allocate a new page even it doing so is difficult. + ** (createFlag==1 AND !(bPurgeable AND pDirty) + */ + eCreate = createFlag & libc.Int32FromUint8((*TPCache)(unsafe.Pointer(pCache)).FeCreate) + pRes = (*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxFetch})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, pgno, eCreate) + return pRes +} + +// C documentation +// +// /* +// ** If the sqlite3PcacheFetch() routine is unable to allocate a new +// ** page because no clean pages are available for reuse and the cache +// ** size limit has been reached, then this routine can be invoked to +// ** try harder to allocate a page. This routine might invoke the stress +// ** callback to spill dirty pages to the journal. It will then try to +// ** allocate the new page and will only fail to allocate a new page on +// ** an OOM error. +// ** +// ** This routine should be invoked only after sqlite3PcacheFetch() fails. +// */ +func _sqlite3PcacheFetchStress(tls *libc.TLS, pCache uintptr, pgno TPgno, ppPage uintptr) (r int32) { + var pPg uintptr + var rc, v3 int32 + _, _, _ = pPg, rc, v3 + if libc.Int32FromUint8((*TPCache)(unsafe.Pointer(pCache)).FeCreate) == int32(2) { + return 0 + } + if _sqlite3PcachePagecount(tls, pCache) > (*TPCache)(unsafe.Pointer(pCache)).FszSpill { + /* Find a dirty page to write-out and recycle. First try to find a + ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC + ** cleared), but if that is not possible settle for any other + ** unreferenced dirty page. + ** + ** If the LRU page in the dirty list that has a clear PGHDR_NEED_SYNC + ** flag is currently referenced, then the following may leave pSynced + ** set incorrectly (pointing to other than the LRU page with NEED_SYNC + ** cleared). This is Ok, as pSynced is just an optimization. */ + pPg = (*TPCache)(unsafe.Pointer(pCache)).FpSynced + for { + if !(pPg != 0 && ((*TPgHdr)(unsafe.Pointer(pPg)).FnRef != 0 || libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(pPg)).Fflags)&int32(PGHDR_NEED_SYNC) != 0)) { + break + } + goto _1 + _1: + ; + pPg = (*TPgHdr)(unsafe.Pointer(pPg)).FpDirtyPrev + } + (*TPCache)(unsafe.Pointer(pCache)).FpSynced = pPg + if !(pPg != 0) { + pPg = (*TPCache)(unsafe.Pointer(pCache)).FpDirtyTail + for { + if !(pPg != 0 && (*TPgHdr)(unsafe.Pointer(pPg)).FnRef != 0) { + break + } + goto _2 + _2: + ; + pPg = (*TPgHdr)(unsafe.Pointer(pPg)).FpDirtyPrev + } + } + if pPg != 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPCache)(unsafe.Pointer(pCache)).FxStress})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpStress, pPg) + if rc != SQLITE_OK && rc != int32(SQLITE_BUSY) { + return rc + } + } + } + **(**uintptr)(__ccgo_up(ppPage)) = (*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxFetch})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, pgno, int32(2)) + if **(**uintptr)(__ccgo_up(ppPage)) == uintptr(0) { + v3 = int32(SQLITE_NOMEM) + } else { + v3 = SQLITE_OK + } + return v3 +} + +// C documentation +// +// /* +// ** Change the page number of page p to newPgno. +// */ +func _sqlite3PcacheMove(tls *libc.TLS, p uintptr, newPgno TPgno) { + var pCache, pOther, pXPage uintptr + _, _, _ = pCache, pOther, pXPage + pCache = (*TPgHdr)(unsafe.Pointer(p)).FpCache + pOther = (*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxFetch})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, newPgno, 0) + if pOther != 0 { + pXPage = (*Tsqlite3_pcache_page)(unsafe.Pointer(pOther)).FpExtra + (*TPgHdr)(unsafe.Pointer(pXPage)).FnRef = (*TPgHdr)(unsafe.Pointer(pXPage)).FnRef + 1 + (*TPCache)(unsafe.Pointer(pCache)).FnRefSum = (*TPCache)(unsafe.Pointer(pCache)).FnRefSum + 1 + _sqlite3PcacheDrop(tls, pXPage) + } + (*(*func(*libc.TLS, uintptr, uintptr, uint32, uint32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxRekey})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, (*TPgHdr)(unsafe.Pointer(p)).FpPage, (*TPgHdr)(unsafe.Pointer(p)).Fpgno, newPgno) + (*TPgHdr)(unsafe.Pointer(p)).Fpgno = newPgno + if libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(p)).Fflags)&int32(PGHDR_DIRTY) != 0 && libc.Int32FromUint16((*TPgHdr)(unsafe.Pointer(p)).Fflags)&int32(PGHDR_NEED_SYNC) != 0 { + _pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_FRONT)) + } +} + +// C documentation +// +// /* +// ** This function is called to free superfluous dynamically allocated memory +// ** held by the pager system. Memory in use by any SQLite pager allocated +// ** by the current thread may be sqlite3_free()ed. +// ** +// ** nReq is the number of bytes of memory required. Once this much has +// ** been released, the function returns. The return value is the total number +// ** of bytes of memory released. +// */ +func _sqlite3PcacheReleaseMemory(tls *libc.TLS, nReq int32) (r int32) { + var nFree int32 + var p, v1 uintptr + var v2 bool + _, _, _, _ = nFree, p, v1, v2 + nFree = 0 + if _sqlite3Config.FpPage == uintptr(0) { + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer(uintptr(unsafe.Pointer(&_pcache1_g)))).Fmutex) + for { + if v2 = nReq < 0 || nFree < nReq; v2 { + v1 = _pcache1_g.Fgrp.Flru.FpLruPrev + p = v1 + } + if !(v2 && v1 != uintptr(0) && libc.Int32FromUint16((*TPgHdr1)(unsafe.Pointer(p)).FisAnchor) == 0) { + break + } + nFree = nFree + _pcache1MemSize(tls, (*TPgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf) + _pcache1PinPage(tls, p) + _pcache1RemoveFromHash(tls, p, int32(1)) + } + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer(uintptr(unsafe.Pointer(&_pcache1_g)))).Fmutex) + } + return nFree +} + +/************** End of pcache1.c *********************************************/ +/************** Begin file rowset.c ******************************************/ +/* +** 2008 December 3 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This module implements an object we call a "RowSet". +** +** The RowSet object is a collection of rowids. Rowids +** are inserted into the RowSet in an arbitrary order. Inserts +** can be intermixed with tests to see if a given rowid has been +** previously inserted into the RowSet. +** +** After all inserts are finished, it is possible to extract the +** elements of the RowSet in sorted order. Once this extraction +** process has started, no new elements may be inserted. +** +** Hence, the primitive operations for a RowSet are: +** +** CREATE +** INSERT +** TEST +** SMALLEST +** DESTROY +** +** The CREATE and DESTROY primitives are the constructor and destructor, +** obviously. The INSERT primitive adds a new element to the RowSet. +** TEST checks to see if an element is already in the RowSet. SMALLEST +** extracts the least value from the RowSet. +** +** The INSERT primitive might allocate additional memory. Memory is +** allocated in chunks so most INSERTs do no allocation. There is an +** upper bound on the size of allocated memory. No memory is freed +** until DESTROY. +** +** The TEST primitive includes a "batch" number. The TEST primitive +** will only see elements that were inserted before the last change +** in the batch number. In other words, if an INSERT occurs between +** two TESTs where the TESTs have the same batch number, then the +** value added by the INSERT will not be visible to the second TEST. +** The initial batch number is zero, so if the very first TEST contains +** a non-zero batch number, it will see all prior INSERTs. +** +** No INSERTs may occurs after a SMALLEST. An assertion will fail if +** that is attempted. +** +** The cost of an INSERT is roughly constant. (Sometimes new memory +** has to be allocated on an INSERT.) The cost of a TEST with a new +** batch number is O(NlogN) where N is the number of elements in the RowSet. +** The cost of a TEST using the same batch number is O(logN). The cost +** of the first SMALLEST is O(NlogN). Second and subsequent SMALLEST +** primitives are constant time. The cost of DESTROY is O(N). +** +** TEST and SMALLEST may not be used by the same RowSet. This used to +** be possible, but the feature was not used, so it was removed in order +** to simplify the code. + */ +/* #include "sqliteInt.h" */ + +/* +** Target size for allocation chunks. + */ + +/* +** The number of rowset entries per allocation chunk. + */ + +// C documentation +// +// /* +// ** Check to see if zTabName is really the name of a pragma. If it is, +// ** then register an eponymous virtual table for that pragma and return +// ** a pointer to the Module object for the new virtual table. +// */ +func _sqlite3PragmaVtabRegister(tls *libc.TLS, db uintptr, zName uintptr) (r uintptr) { + var pName uintptr + _ = pName + pName = _pragmaLocate(tls, zName+uintptr(7)) + if pName == uintptr(0) { + return uintptr(0) + } + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pName)).FmPragFlg)&(libc.Int32FromInt32(PragFlg_Result0)|libc.Int32FromInt32(PragFlg_Result1)) == 0 { + return uintptr(0) + } + return _sqlite3VtabCreateModule(tls, db, zName, uintptr(unsafe.Pointer(&_pragmaVtabModule)), pName, uintptr(0)) +} + +/************** End of pragma.c **********************************************/ +/************** Begin file prepare.c *****************************************/ +/* +** 2005 May 25 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the implementation of the sqlite3_prepare() +** interface, and routines that contribute to loading the database schema +** from disk. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** Change the size of an existing memory allocation +// */ +func _sqlite3Realloc(tls *libc.TLS, pOld uintptr, nBytes Tu64) (r uintptr) { + var nDiff, nNew, nOld int32 + var nUsed, v1 Tsqlite3_int64 + var pNew uintptr + var v2 bool + _, _, _, _, _, _, _ = nDiff, nNew, nOld, nUsed, pNew, v1, v2 + if pOld == uintptr(0) { + return _sqlite3Malloc(tls, nBytes) /* IMP: R-04300-56712 */ + } + if nBytes == uint64(0) { + Xsqlite3_free(tls, pOld) /* IMP: R-26507-47431 */ + return uintptr(0) + } + if nBytes > uint64(SQLITE_MAX_ALLOCATION_SIZE) { + return uintptr(0) + } + nOld = _sqlite3MallocSize(tls, pOld) + /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second + ** argument to xRealloc is always a value returned by a prior call to + ** xRoundup. */ + nNew = (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxRoundup})))(tls, libc.Int32FromUint64(nBytes)) + if nOld == nNew { + pNew = pOld + } else { + if _sqlite3Config.FbMemstat != 0 { + Xsqlite3_mutex_enter(tls, _mem0.Fmutex) + _sqlite3StatusHighwater(tls, int32(SQLITE_STATUS_MALLOC_SIZE), libc.Int32FromUint64(nBytes)) + nDiff = nNew - nOld + if v2 = nDiff > 0; v2 { + v1 = _sqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) + nUsed = v1 + } + if v2 && v1 >= _mem0.FalarmThreshold-int64(nDiff) { + _sqlite3MallocAlarm(tls, nDiff) + if _mem0.FhardLimit > 0 && nUsed >= _mem0.FhardLimit-int64(nDiff) { + Xsqlite3_mutex_leave(tls, _mem0.Fmutex) + return uintptr(0) + } + } + pNew = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxRealloc})))(tls, pOld, nNew) + if pNew == uintptr(0) && _mem0.FalarmThreshold > 0 { + _sqlite3MallocAlarm(tls, libc.Int32FromUint64(nBytes)) + pNew = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxRealloc})))(tls, pOld, nNew) + } + if pNew != 0 { + nNew = _sqlite3MallocSize(tls, pNew) + _sqlite3StatusUp(tls, SQLITE_STATUS_MEMORY_USED, nNew-nOld) + } + Xsqlite3_mutex_leave(tls, _mem0.Fmutex) + } else { + pNew = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxRealloc})))(tls, pOld, nNew) + } + } + /* IMP: R-11148-40995 */ + return pNew +} + +// C documentation +// +// /* +// ** Initialize a SelectDest structure. +// */ +func _sqlite3SelectDestInit(tls *libc.TLS, pDest uintptr, eDest int32, iParm int32) { + (*TSelectDest)(unsafe.Pointer(pDest)).FeDest = libc.Uint8FromInt32(eDest) + (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm = iParm + (*TSelectDest)(unsafe.Pointer(pDest)).FiSDParm2 = 0 + (*TSelectDest)(unsafe.Pointer(pDest)).FzAffSdst = uintptr(0) + (*TSelectDest)(unsafe.Pointer(pDest)).FiSdst = 0 + (*TSelectDest)(unsafe.Pointer(pDest)).FnSdst = 0 +} + +// C documentation +// +// /* +// ** Extract the iCol-th column from the nRec-byte record in pRec. Write +// ** the column value into *ppVal. If *ppVal is initially NULL then a new +// ** sqlite3_value object is allocated. +// ** +// ** If *ppVal is initially NULL then the caller is responsible for +// ** ensuring that the value written into *ppVal is eventually freed. +// ** +// ** If the buffer does not contain a well-formed record, this routine may +// ** read several bytes past the end of the buffer. Callers must therefore +// ** ensure that any buffer which may contain a corrupt record is padded +// ** with at least 8 bytes of addressable memory. +// */ +func _sqlite3Stat4Column(tls *libc.TLS, db uintptr, pRec uintptr, nRec int32, iCol int32, ppVal uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, pMem, v4 uintptr + var i, v1 int32 + var iField Ti64 + var iHdr, szField Tu32 + var _ /* nHdr at bp+4 */ Tu32 + var _ /* t at bp+0 */ Tu32 + _, _, _, _, _, _, _, _ = a, i, iField, iHdr, pMem, szField, v1, v4 + **(**Tu32)(__ccgo_up(bp)) = uint32(0) /* Next unread data byte */ + szField = uint32(0) /* Column index */ + a = pRec /* Typecast byte array */ + pMem = **(**uintptr)(__ccgo_up(ppVal)) /* Write result into this Mem object */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp + 4)) = uint32(**(**Tu8)(__ccgo_up(a))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, a, bp+4)) + } + iHdr = uint32(libc.Uint8FromInt32(v1)) + if **(**Tu32)(__ccgo_up(bp + 4)) > libc.Uint32FromInt32(nRec) || iHdr >= **(**Tu32)(__ccgo_up(bp + 4)) { + return _sqlite3CorruptError(tls, int32(87657)) + } + iField = libc.Int64FromUint32(**(**Tu32)(__ccgo_up(bp + 4))) + i = 0 + for { + if !(i <= iCol) { + break + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(a + uintptr(iHdr)))) < libc.Int32FromUint8(libc.Uint8FromInt32(0x80)) { + **(**Tu32)(__ccgo_up(bp)) = uint32(**(**Tu8)(__ccgo_up(a + uintptr(iHdr)))) + v1 = libc.Int32FromInt32(1) + } else { + v1 = libc.Int32FromUint8(_sqlite3GetVarint32(tls, a+uintptr(iHdr), bp)) + } + iHdr = iHdr + uint32(libc.Uint8FromInt32(v1)) + if iHdr > **(**Tu32)(__ccgo_up(bp + 4)) { + return _sqlite3CorruptError(tls, int32(87663)) + } + szField = _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp))) + iField = iField + libc.Int64FromUint32(szField) + goto _2 + _2: + ; + i = i + 1 + } + if iField > int64(nRec) { + return _sqlite3CorruptError(tls, int32(87669)) + } + if pMem == uintptr(0) { + v4 = _sqlite3ValueNew(tls, db) + **(**uintptr)(__ccgo_up(ppVal)) = v4 + pMem = v4 + if pMem == uintptr(0) { + return int32(SQLITE_NOMEM) + } + } + _sqlite3VdbeSerialGet(tls, a+uintptr(iField-libc.Int64FromUint32(szField)), **(**Tu32)(__ccgo_up(bp)), pMem) + (*TMem)(unsafe.Pointer(pMem)).Fenc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + return SQLITE_OK +} + +func _sqlite3StrAccumEnlargeIfNeeded(tls *libc.TLS, p uintptr, N Ti64) (r int32) { + if N+libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar) >= libc.Int64FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnAlloc) { + _sqlite3StrAccumEnlarge(tls, p, N) + } + return libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FaccError) +} + +// C documentation +// +// /* +// ** Initialize a string accumulator. +// ** +// ** p: The accumulator to be initialized. +// ** db: Pointer to a database connection. May be NULL. Lookaside +// ** memory is used if not NULL. db->mallocFailed is set appropriately +// ** when not NULL. +// ** zBase: An initial buffer. May be NULL in which case the initial buffer +// ** is malloced. +// ** n: Size of zBase in bytes. If total space requirements never exceed +// ** n then no memory allocations ever occur. +// ** mx: Maximum number of bytes to accumulate. If mx==0 then no memory +// ** allocations will ever occur. +// */ +func _sqlite3StrAccumInit(tls *libc.TLS, p uintptr, db uintptr, zBase uintptr, n int32, mx int32) { + (*TStrAccum)(unsafe.Pointer(p)).FzText = zBase + (*TStrAccum)(unsafe.Pointer(p)).Fdb = db + (*TStrAccum)(unsafe.Pointer(p)).FnAlloc = libc.Uint32FromInt32(n) + (*TStrAccum)(unsafe.Pointer(p)).FmxAlloc = libc.Uint32FromInt32(mx) + (*TStrAccum)(unsafe.Pointer(p)).FnChar = uint32(0) + (*TStrAccum)(unsafe.Pointer(p)).FaccError = uint8(0) + (*TStrAccum)(unsafe.Pointer(p)).FprintfFlags = uint8(0) +} + +// C documentation +// +// /* +// ** Set the StrAccum object to an error mode. +// */ +func _sqlite3StrAccumSetError(tls *libc.TLS, p uintptr, eError Tu8) { + (*TStrAccum)(unsafe.Pointer(p)).FaccError = eError + if (*TStrAccum)(unsafe.Pointer(p)).FmxAlloc != 0 { + Xsqlite3_str_reset(tls, p) + } + if libc.Int32FromUint8(eError) == int32(SQLITE_TOOBIG) { + _sqlite3ErrorToParser(tls, (*TStrAccum)(unsafe.Pointer(p)).Fdb, libc.Int32FromUint8(eError)) + } +} + +func _sqlite3StrICmp(tls *libc.TLS, zLeft uintptr, zRight uintptr) (r int32) { + var a, b uintptr + var c, x int32 + _, _, _, _ = a, b, c, x + a = zLeft + b = zRight + for { + c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(a))) + x = libc.Int32FromUint8(**(**uint8)(__ccgo_up(b))) + if c == x { + if c == 0 { + break + } + } else { + c = libc.Int32FromUint8(_sqlite3UpperToLower[c]) - libc.Int32FromUint8(_sqlite3UpperToLower[x]) + if c != 0 { + break + } + } + a = a + 1 + b = b + 1 + goto _1 + _1: + } + return c +} + +// C documentation +// +// /* +// ** Backwards Compatibility Hack: +// ** +// ** Historical versions of SQLite accepted strings as column names in +// ** indexes and PRIMARY KEY constraints and in UNIQUE constraints. Example: +// ** +// ** CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim) +// ** CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC); +// ** +// ** This is goofy. But to preserve backwards compatibility we continue to +// ** accept it. This routine does the necessary conversion. It converts +// ** the expression given in its argument from a TK_STRING into a TK_ID +// ** if the expression is just a TK_STRING with an optional COLLATE clause. +// ** If the expression is anything other than TK_STRING, the expression is +// ** unchanged. +// */ +func _sqlite3StringToId(tls *libc.TLS, p uintptr) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_STRING) { + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_ID) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_COLLATE) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(p)).FpLeft)).Fop) == int32(TK_STRING) { + (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(p)).FpLeft)).Fop = uint8(TK_ID) + } + } +} + +// C documentation +// +// /* +// ** Convert an table column number into a index column number. That is, +// ** for the column iCol in the table (as defined by the CREATE TABLE statement) +// ** find the (first) offset of that column in index pIdx. Or return -1 +// ** if column iCol is not used in index pIdx. +// */ +func _sqlite3TableColumnToIndex(tls *libc.TLS, pIdx uintptr, iCol int32) (r int32) { + var i int32 + var iCol16 Ti16 + _, _ = i, iCol16 + iCol16 = int16(iCol) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn)) { + break + } + if int32(iCol16) == int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) { + return i + } + goto _1 + _1: + ; + i = i + 1 + } + return -int32(1) +} + +// C documentation +// +// /* +// ** This function returns true if main-memory should be used instead of +// ** a temporary file for transient pager files and statement journals. +// ** The value returned depends on the value of db->temp_store (runtime +// ** parameter) and the compile time value of SQLITE_TEMP_STORE. The +// ** following table describes the relationship between these two values +// ** and this functions return value. +// ** +// ** SQLITE_TEMP_STORE db->temp_store Location of temporary database +// ** ----------------- -------------- ------------------------------ +// ** 0 any file (return 0) +// ** 1 1 file (return 0) +// ** 1 2 memory (return 1) +// ** 1 0 file (return 0) +// ** 2 1 file (return 0) +// ** 2 2 memory (return 1) +// ** 2 0 memory (return 1) +// ** 3 any memory (return 1) +// */ +func _sqlite3TempInMemory(tls *libc.TLS, db uintptr) (r int32) { + return libc.BoolInt32(libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) == int32(2)) +} + +// C documentation +// +// /* +// ** Generate a Token object from a string +// */ +func _sqlite3TokenInit(tls *libc.TLS, p uintptr, z uintptr) { + (*TToken)(unsafe.Pointer(p)).Fz = z + (*TToken)(unsafe.Pointer(p)).Fn = libc.Uint32FromInt32(_sqlite3Strlen30(tls, z)) +} + +/* Convenient short-hand */ + +// C documentation +// +// /* +// ** Construct a trigger step that implements a DELETE statement and return +// ** a pointer to that trigger step. The parser calls this routine when it +// ** sees a DELETE statement inside the body of a CREATE TRIGGER. +// */ +func _sqlite3TriggerDeleteStep(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWhere uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var db, pTriggerStep uintptr + _, _ = db, pTriggerStep + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTriggerStep = _triggerStepAllocate(tls, pParse, uint8(TK_DELETE), pTabList, zStart, zEnd) + if pTriggerStep != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = pWhere + pWhere = uintptr(0) + } else { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = _sqlite3ExprDup(tls, db, pWhere, int32(EXPRDUP_REDUCE)) + } + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = uint8(OE_Default) + } + _sqlite3ExprDelete(tls, db, pWhere) + return pTriggerStep +} + +// C documentation +// +// /* +// ** Build a trigger step out of an INSERT statement. Return a pointer +// ** to the new trigger step. +// ** +// ** The parser calls this routine when it sees an INSERT inside the +// ** body of a trigger. +// */ +func _sqlite3TriggerInsertStep(tls *libc.TLS, pParse uintptr, pTabList uintptr, pColumn uintptr, pSelect uintptr, orconf Tu8, pUpsert uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var db, pTriggerStep uintptr + _, _ = db, pTriggerStep + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTriggerStep = _triggerStepAllocate(tls, pParse, uint8(TK_INSERT), pTabList, zStart, zEnd) + if pTriggerStep != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = pSelect + pSelect = uintptr(0) + } else { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = _sqlite3SelectDup(tls, db, pSelect, int32(EXPRDUP_REDUCE)) + } + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpIdList = pColumn + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpUpsert = pUpsert + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = orconf + if pUpsert != 0 { + _sqlite3HasExplicitNulls(tls, pParse, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) + } + } else { + _sqlite3IdListDelete(tls, db, pColumn) + _sqlite3UpsertDelete(tls, db, pUpsert) + } + _sqlite3SelectDelete(tls, db, pSelect) + return pTriggerStep +} + +// C documentation +// +// /* +// ** Construct a trigger step that implements an UPDATE statement and return +// ** a pointer to that trigger step. The parser calls this routine when it +// ** sees an UPDATE statement inside the body of a CREATE TRIGGER. +// */ +func _sqlite3TriggerUpdateStep(tls *libc.TLS, pParse uintptr, pTabList uintptr, pFrom uintptr, pEList uintptr, pWhere uintptr, orconf Tu8, zStart uintptr, zEnd uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pFromDup, pSub, pTriggerStep uintptr + var _ /* as at bp+0 */ TToken + _, _, _, _ = db, pFromDup, pSub, pTriggerStep + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTriggerStep = _triggerStepAllocate(tls, pParse, uint8(TK_UPDATE), pTabList, zStart, zEnd) + if pTriggerStep != 0 { + pFromDup = uintptr(0) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = pEList + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = pWhere + pFromDup = pFrom + pEList = uintptr(0) + pWhere = uintptr(0) + pFrom = uintptr(0) + } else { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = _sqlite3ExprListDup(tls, db, pEList, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = _sqlite3ExprDup(tls, db, pWhere, int32(EXPRDUP_REDUCE)) + pFromDup = _sqlite3SrcListDup(tls, db, pFrom, int32(EXPRDUP_REDUCE)) + } + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = orconf + if pFromDup != 0 && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + **(**TToken)(__ccgo_up(bp)) = TToken{} + pSub = _sqlite3SelectNew(tls, pParse, uintptr(0), pFromDup, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) + pFromDup = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp, pSub, uintptr(0)) + } + if pFromDup != 0 && (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc != 0 { + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc = _sqlite3SrcListAppendList(tls, pParse, (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSrc, pFromDup) + } else { + _sqlite3SrcListDelete(tls, db, pFromDup) + } + } + _sqlite3ExprListDelete(tls, db, pEList) + _sqlite3ExprDelete(tls, db, pWhere) + _sqlite3SrcListDelete(tls, db, pFrom) + return pTriggerStep +} + +// C documentation +// +// /* +// ** pZ is a UTF-8 encoded unicode string. If nByte is less than zero, +// ** return the number of unicode characters in pZ up to (but not including) +// ** the first 0x00 byte. If nByte is not less than zero, return the +// ** number of unicode characters in the first nByte of pZ (or up to +// ** the first 0x00, whichever comes first). +// */ +func _sqlite3Utf8CharLen(tls *libc.TLS, zIn uintptr, nByte int32) (r1 int32) { + var r int32 + var z, zTerm, v1 uintptr + _, _, _, _ = r, z, zTerm, v1 + r = 0 + z = zIn + if nByte >= 0 { + zTerm = z + uintptr(nByte) + } else { + zTerm = uintptr(-libc.Int32FromInt32(1)) + } + for libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z))) != 0 && z < zTerm { + v1 = z + z = z + 1 + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v1))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { + z = z + 1 + } + } + r = r + 1 + } + return r +} + +/* This test function is not currently used by the automated test-suite. +** Hence it is only available in debug builds. + */ + +// C documentation +// +// /* +// ** Translate a single UTF-8 character. Return the unicode value. +// ** +// ** During translation, assume that the byte that zTerm points +// ** is a 0x00. +// ** +// ** Write a pointer to the next unread byte back into *pzNext. +// ** +// ** Notes On Invalid UTF-8: +// ** +// ** * This routine never allows a 7-bit character (0x00 through 0x7f) to +// ** be encoded as a multi-byte character. Any multi-byte character that +// ** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. +// ** +// ** * This routine never allows a UTF16 surrogate value to be encoded. +// ** If a multi-byte character attempts to encode a value between +// ** 0xd800 and 0xe000 then it is rendered as 0xfffd. +// ** +// ** * Bytes in the range of 0x80 through 0xbf which occur as the first +// ** byte of a character are interpreted as single-byte characters +// ** and rendered as themselves even though they are technically +// ** invalid characters. +// ** +// ** * This routine accepts over-length UTF8 encodings +// ** for unicode values 0x80 and greater. It does not change over-length +// ** encodings to 0xfffd as some systems recommend. +// */ +func _sqlite3Utf8Read(tls *libc.TLS, pz uintptr) (r Tu32) { + var c uint32 + var v1, v2 uintptr + _, _, _ = c, v1, v2 + /* Same as READ_UTF8() above but without the zTerm parameter. + ** For this routine, we assume the UTF8 string is always zero-terminated. + */ + v2 = pz + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1 + c = uint32(**(**uint8)(__ccgo_up(v1))) + if c >= uint32(0xc0) { + c = uint32(_sqlite3Utf8Trans1[c-uint32(0xc0)]) + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(pz)))))&int32(0xc0) == int32(0x80) { + v2 = pz + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1 + c = c<= uint32(0xc0) { + c = uint32(_sqlite3Utf8Trans1[c-uint32(0xc0)]) + if n > int32(4) { + n = int32(4) + } + for i < n && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(i))))&int32(0xc0) == int32(0x80) { + c = c<= int32(VDBE_READY_STATE) { + rc = _sqlite3VdbeReset(tls, p) + } + _sqlite3VdbeDelete(tls, p) + return rc +} + +func _sqlite3VdbeIntValue(tls *libc.TLS, pMem uintptr) (r Ti64) { + var flags int32 + _ = flags + flags = libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags) + if flags&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + return *(*Ti64)(unsafe.Pointer(pMem)) + } else { + if flags&int32(MEM_Real) != 0 { + return _sqlite3RealToI64(tls, *(*float64)(unsafe.Pointer(pMem))) + } else { + if flags&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) != 0 && (*TMem)(unsafe.Pointer(pMem)).Fz != uintptr(0) { + return _memIntValue(tls, pMem) + } else { + return 0 + } + } + } + return r +} + +// C documentation +// +// /* +// ** The MEM structure is already a MEM_Real or MEM_IntReal. Try to +// ** make it a MEM_Int if we can. +// */ +func _sqlite3VdbeIntegerAffinity(tls *libc.TLS, pMem uintptr) { + var ix Ti64 + _ = ix + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags)&int32(MEM_IntReal) != 0 { + (*TMem)(unsafe.Pointer(pMem)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pMem)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Int)) + } else { + ix = _sqlite3RealToI64(tls, *(*float64)(unsafe.Pointer(pMem))) + /* Only mark the value as an integer if + ** + ** (1) the round-trip conversion real->int->real is a no-op, and + ** (2) The integer is neither the largest nor the smallest + ** possible integer (ticket #3922) + ** + ** The second and third terms in the following conditional enforces + ** the second condition under the assumption that addition overflow causes + ** values to wrap around. + */ + if *(*float64)(unsafe.Pointer(pMem)) == float64(ix) && ix > int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 || (*TVdbe)(unsafe.Pointer(p)).FzErrMsg != 0 { + _sqlite3VdbeTransferError(tls, p) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = (*TVdbe)(unsafe.Pointer(p)).Frc + } + } + /* Reset register contents and reclaim error message memory. + */ + if (*TVdbe)(unsafe.Pointer(p)).FzErrMsg != 0 { + _sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg) + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = uintptr(0) + } + (*TVdbe)(unsafe.Pointer(p)).FpResultRow = uintptr(0) + /* Save profiling information from this VDBE run. + */ + return (*TVdbe)(unsafe.Pointer(p)).Frc & (*Tsqlite3)(unsafe.Pointer(db)).FerrMask +} + +func _sqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type Tu32, pMem uintptr) { + switch serial_type { + case uint32(10): /* Internal use only: NULL with virtual table + ** UPDATE no-change flag set */ + (*TMem)(unsafe.Pointer(pMem)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Null) | libc.Int32FromInt32(MEM_Zero)) + (*TMem)(unsafe.Pointer(pMem)).Fn = 0 + *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pMem)).Fu)) = 0 + return + case uint32(11): /* Reserved for future use */ + fallthrough + case uint32(0): /* Null */ + /* EVIDENCE-OF: R-24078-09375 Value is a NULL. */ + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Null) + return + case uint32(1): + /* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement + ** integer. */ + *(*Ti64)(unsafe.Pointer(pMem)) = int64(libc.Int8FromUint8(**(**uint8)(__ccgo_up(buf)))) + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Int) + return + case uint32(2): /* 2-byte signed integer */ + /* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit + ** twos-complement integer. */ + *(*Ti64)(unsafe.Pointer(pMem)) = int64(libc.Int32FromInt32(256)*int32(libc.Int8FromUint8(**(**uint8)(__ccgo_up(buf)))) | libc.Int32FromUint8(**(**uint8)(__ccgo_up(buf + 1)))) + (*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Int) + return + case uint32(3): /* 3-byte signed integer */ + /* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit + ** twos-complement integer. */ + *(*Ti64)(unsafe.Pointer(pMem)) = int64(libc.Int32FromInt32(65536)*int32(libc.Int8FromUint8(**(**uint8)(__ccgo_up(buf)))) | libc.Int32FromUint8(**(**uint8)(__ccgo_up(buf + 1)))< 0 { + return 0 + } + return _viewGetColumnNames(tls, pParse, pTable) +} + +// C documentation +// +// /* Return the value to pass to a sqlite3_wal_hook callback, the +// ** number of frames in the WAL at the point of the last commit since +// ** sqlite3WalCallback() was called. If no commits have occurred since +// ** the last call, then return 0. +// */ +func _sqlite3WalCallback(tls *libc.TLS, pWal uintptr) (r int32) { + var ret Tu32 + _ = ret + ret = uint32(0) + if pWal != 0 { + ret = (*TWal)(unsafe.Pointer(pWal)).FiCallback + (*TWal)(unsafe.Pointer(pWal)).FiCallback = uint32(0) + } + return libc.Int32FromUint32(ret) +} + +// C documentation +// +// /* +// ** Close a connection to a log file. +// */ +func _sqlite3WalClose(tls *libc.TLS, pWal uintptr, db uintptr, sync_flags int32, nBuf int32, zBuf uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var isDelete, rc, v1 int32 + var v2 bool + var _ /* bPersist at bp+0 */ int32 + _, _, _, _ = isDelete, rc, v1, v2 + rc = SQLITE_OK + if pWal != 0 { + isDelete = 0 /* True to unlink wal and wal-index files */ + /* If an EXCLUSIVE lock can be obtained on the database file (using the + ** ordinary, rollback-mode locking methods, this guarantees that the + ** connection associated with this log file is the only connection to + ** the database. In this case checkpoint the database and unlink both + ** the wal and wal-index files. + ** + ** The EXCLUSIVE lock is not released before returning. + */ + if v2 = zBuf != uintptr(0); v2 { + v1 = _sqlite3OsLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, int32(SQLITE_LOCK_EXCLUSIVE)) + rc = v1 + } + if v2 && SQLITE_OK == v1 { + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE { + (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode = uint8(WAL_EXCLUSIVE_MODE) + } + rc = _sqlite3WalCheckpoint(tls, pWal, db, SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0), sync_flags, nBuf, zBuf, uintptr(0), uintptr(0)) + if rc == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = -int32(1) + _sqlite3OsFileControlHint(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, int32(SQLITE_FCNTL_PERSIST_WAL), bp) + if **(**int32)(__ccgo_up(bp)) != int32(1) { + /* Try to delete the WAL file if the checkpoint completed and + ** fsynced (rc==SQLITE_OK) and if we are not in persistent-wal + ** mode (!bPersist) */ + isDelete = int32(1) + } else { + if (*TWal)(unsafe.Pointer(pWal)).FmxWalSize >= 0 { + /* Try to truncate the WAL file to zero bytes if the checkpoint + ** completed and fsynced (rc==SQLITE_OK) and we are in persistent + ** WAL mode (bPersist) and if the PRAGMA journal_size_limit is a + ** non-negative value (pWal->mxWalSize>=0). Note that we truncate + ** to zero bytes as truncating to the journal_size_limit might + ** leave a corrupt WAL file on disk. */ + _walLimitSize(tls, pWal, 0) + } + } + } + } + _walIndexClose(tls, pWal, isDelete) + _sqlite3OsClose(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd) + if isDelete != 0 { + _sqlite3BeginBenignMalloc(tls) + _sqlite3OsDelete(tls, (*TWal)(unsafe.Pointer(pWal)).FpVfs, (*TWal)(unsafe.Pointer(pWal)).FzWalName, 0) + _sqlite3EndBenignMalloc(tls) + } + Xsqlite3_free(tls, (*TWal)(unsafe.Pointer(pWal)).FapWiData) + Xsqlite3_free(tls, pWal) + } + return rc +} + +// C documentation +// +// /* +// ** This function is called to change the WAL subsystem into or out +// ** of locking_mode=EXCLUSIVE. +// ** +// ** If op is zero, then attempt to change from locking_mode=EXCLUSIVE +// ** into locking_mode=NORMAL. This means that we must acquire a lock +// ** on the pWal->readLock byte. If the WAL is already in locking_mode=NORMAL +// ** or if the acquisition of the lock fails, then return 0. If the +// ** transition out of exclusive-mode is successful, return 1. This +// ** operation must occur while the pager is still holding the exclusive +// ** lock on the main database file. +// ** +// ** If op is one, then change from locking_mode=NORMAL into +// ** locking_mode=EXCLUSIVE. This means that the pWal->readLock must +// ** be released. Return 1 if the transition is made and 0 if the +// ** WAL is already in exclusive-locking mode - meaning that this +// ** routine is a no-op. The pager must already hold the exclusive lock +// ** on the main database file before invoking this operation. +// ** +// ** If op is negative, then do a dry-run of the op==1 case but do +// ** not actually change anything. The pager uses this to see if it +// ** should acquire the database exclusive lock prior to invoking +// ** the op==1 case. +// */ +func _sqlite3WalExclusiveMode(tls *libc.TLS, pWal uintptr, op int32) (r int32) { + var rc int32 + _ = rc + /* pWal->readLock is usually set, but might be -1 if there was a + ** prior error while attempting to acquire are read-lock. This cannot + ** happen if the connection is actually in exclusive mode (as no xShmLock + ** locks are taken in this case). Nor should the pager attempt to + ** upgrade to exclusive-mode following such an error. + */ + if op == 0 { + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_NORMAL_MODE { + (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode = uint8(WAL_NORMAL_MODE) + if _walLockShared(tls, pWal, int32(3)+int32((*TWal)(unsafe.Pointer(pWal)).FreadLock)) != SQLITE_OK { + (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode = uint8(WAL_EXCLUSIVE_MODE) + } + rc = libc.BoolInt32(libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE) + } else { + /* Already in locking_mode=NORMAL */ + rc = 0 + } + } else { + if op > 0 { + _walUnlockShared(tls, pWal, int32(3)+int32((*TWal)(unsafe.Pointer(pWal)).FreadLock)) + (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode = uint8(WAL_EXCLUSIVE_MODE) + rc = int32(1) + } else { + rc = libc.BoolInt32(libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE) + } + } + return rc +} + +// C documentation +// +// /* +// ** Return true if the argument is non-NULL and the WAL module is using +// ** heap-memory for the wal-index. Otherwise, if the argument is NULL or the +// ** WAL module is using shared-memory, return false. +// */ +func _sqlite3WalHeapMemory(tls *libc.TLS, pWal uintptr) (r int32) { + return libc.BoolInt32(pWal != 0 && libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FexclusiveMode) == int32(WAL_HEAPMEMORY_MODE)) +} + +// C documentation +// +// /* +// ** Read the contents of frame iRead from the wal file into buffer pOut +// ** (which is nOut bytes in size). Return SQLITE_OK if successful, or an +// ** error code otherwise. +// */ +func _sqlite3WalReadFrame(tls *libc.TLS, pWal uintptr, iRead Tu32, nOut int32, pOut uintptr) (r int32) { + var iOffset Ti64 + var sz, v1 int32 + _, _, _ = iOffset, sz, v1 + sz = libc.Int32FromUint16((*TWal)(unsafe.Pointer(pWal)).Fhdr.FszPage) + sz = sz&int32(0xfe00) + sz&int32(0x0001)< sz { + v1 = sz + } else { + v1 = nOut + } + return _sqlite3OsRead(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, pOut, v1, iOffset) +} + +// C documentation +// +// /* +// ** Attempt to reduce the value of the WalCkptInfo.nBackfillAttempted +// ** variable so that older snapshots can be accessed. To do this, loop +// ** through all wal frames from nBackfillAttempted to (nBackfill+1), +// ** comparing their content to the corresponding page with the database +// ** file, if any. Set nBackfillAttempted to the frame number of the +// ** first frame for which the wal file content matches the db file. +// ** +// ** This is only really safe if the file-system is such that any page +// ** writes made by earlier checkpointers were atomic operations, which +// ** is not always true. It is also possible that nBackfillAttempted +// ** may be left set to a value larger than expected, if a wal frame +// ** contains content that duplicate of an earlier version of the same +// ** page. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code if an +// ** error occurs. It is not an error if nBackfillAttempted cannot be +// ** decreased at all. +// */ +func _sqlite3WalSnapshotRecover(tls *libc.TLS, pWal uintptr) (r int32) { + var pBuf1, pBuf2 uintptr + var rc int32 + _, _, _ = pBuf1, pBuf2, rc + rc = _walLockExclusive(tls, pWal, int32(WAL_CKPT_LOCK), int32(1)) + if rc == SQLITE_OK { + pBuf1 = Xsqlite3_malloc(tls, libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage)) + pBuf2 = Xsqlite3_malloc(tls, libc.Int32FromUint32((*TWal)(unsafe.Pointer(pWal)).FszPage)) + if pBuf1 == uintptr(0) || pBuf2 == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + (*TWal)(unsafe.Pointer(pWal)).FckptLock = uint8(1) + rc = _walSnapshotRecover(tls, pWal, pBuf1, pBuf2) + (*TWal)(unsafe.Pointer(pWal)).FckptLock = uint8(0) + } + Xsqlite3_free(tls, pBuf1) + Xsqlite3_free(tls, pBuf2) + _walUnlockExclusive(tls, pWal, int32(WAL_CKPT_LOCK), int32(1)) + } + return rc +} + +// C documentation +// +// /* +// ** Walk all expressions associated with SELECT statement p. Do +// ** not invoke the SELECT callback on p, but do (of course) invoke +// ** any expr callbacks and SELECT callbacks that come from subqueries. +// ** Return WRC_Abort or WRC_Continue. +// */ +func _sqlite3WalkSelectExpr(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + var pParse, v1 uintptr + var rc int32 + var v2 bool + _, _, _, _ = pParse, rc, v1, v2 + if _sqlite3WalkExprList(tls, pWalker, (*TSelect)(unsafe.Pointer(p)).FpEList) != 0 { + return int32(WRC_Abort) + } + if _sqlite3WalkExpr(tls, pWalker, (*TSelect)(unsafe.Pointer(p)).FpWhere) != 0 { + return int32(WRC_Abort) + } + if _sqlite3WalkExprList(tls, pWalker, (*TSelect)(unsafe.Pointer(p)).FpGroupBy) != 0 { + return int32(WRC_Abort) + } + if _sqlite3WalkExpr(tls, pWalker, (*TSelect)(unsafe.Pointer(p)).FpHaving) != 0 { + return int32(WRC_Abort) + } + if _sqlite3WalkExprList(tls, pWalker, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) != 0 { + return int32(WRC_Abort) + } + if _sqlite3WalkExpr(tls, pWalker, (*TSelect)(unsafe.Pointer(p)).FpLimit) != 0 { + return int32(WRC_Abort) + } + if (*TSelect)(unsafe.Pointer(p)).FpWinDefn != 0 { + if v2 = (*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback2 == __ccgo_fp(_sqlite3WalkWinDefnDummyCallback); !v2 { + v1 = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + pParse = v1 + } + if v2 || v1 != uintptr(0) && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) || (*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback2 == __ccgo_fp(_sqlite3SelectPopWith) { + /* The following may return WRC_Abort if there are unresolvable + ** symbols (e.g. a table that does not exist) in a window definition. */ + rc = _walkWindowList(tls, pWalker, (*TSelect)(unsafe.Pointer(p)).FpWinDefn, 0) + return rc + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN +// ** command, or if stmt_scanstatus_v2() stats are enabled, or if SQLITE_DEBUG +// ** was defined at compile-time. If it is not a no-op, a single OP_Explain +// ** opcode is added to the output to describe the table scan strategy in pLevel. +// ** +// ** If an OP_Explain opcode is added to the VM, its address is returned. +// ** Otherwise, if no OP_Explain is coded, zero is returned. +// */ +func _sqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr, pLevel uintptr, wctrlFlags Tu16) (r int32) { + var addr, ret int32 + var v, v1 uintptr + _, _, _, _ = addr, ret, v, v1 + ret = 0 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(v1)).Fexplain) == int32(2) || libc.Bool(0 != 0) { + if (*TWhereLoop)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags&uint32(WHERE_MULTI_OR) == uint32(0) && libc.Int32FromUint16(wctrlFlags)&int32(WHERE_OR_SUBCLAUSE) == 0 { + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + addr = _sqlite3VdbeCurrentAddr(tls, v) + ret = _sqlite3VdbeAddOp3(tls, v, int32(OP_Explain), addr, (*TParse)(unsafe.Pointer(pParse)).FaddrExplain, int32((*TWhereLoop)(unsafe.Pointer((*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FrRun)) + _sqlite3WhereAddExplainText(tls, pParse, addr, pTabList, pLevel, wctrlFlags) + } + } + return ret +} + +func _sqlite3WhereExprUsageNN(tls *libc.TLS, pMaskSet uintptr, p uintptr) (r TBitmask) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_COLUMN) && !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != libc.Uint32FromInt32(0)) { + return _sqlite3WhereGetMask(tls, pMaskSet, (*TExpr)(unsafe.Pointer(p)).FiTable) + } else { + if (*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) != uint32(0) { + return uint64(0) + } + } + return _sqlite3WhereExprUsageFull(tls, pMaskSet, p) +} + +// C documentation +// +// /* +// ** Return one of the WHERE_DISTINCT_xxxxx values to indicate how this +// ** WHERE clause returns outputs for DISTINCT processing. +// */ +func _sqlite3WhereIsDistinct(tls *libc.TLS, pWInfo uintptr) (r int32) { + return libc.Int32FromUint8((*TWhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) +} + +// C documentation +// +// /* +// ** This routine identifies subexpressions in the WHERE clause where +// ** each subexpression is separated by the AND operator or some other +// ** operator specified in the op parameter. The WhereClause structure +// ** is filled with pointers to subexpressions. For example: +// ** +// ** WHERE a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22) +// ** \________/ \_______________/ \________________/ +// ** slot[0] slot[1] slot[2] +// ** +// ** The original WHERE clause in pExpr is unaltered. All this routine +// ** does is make slot[] entries point to substructure within pExpr. +// ** +// ** In the previous sentence and in the diagram, "slot[]" refers to +// ** the WhereClause.a[] array. The slot[] array grows as needed to contain +// ** all terms of the WHERE clause. +// */ +func _sqlite3WhereSplit(tls *libc.TLS, pWC uintptr, pExpr uintptr, op Tu8) { + var pE2 uintptr + _ = pE2 + pE2 = _sqlite3ExprSkipCollateAndLikely(tls, pExpr) + (*TWhereClause)(unsafe.Pointer(pWC)).Fop = op + if pE2 == uintptr(0) { + return + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pE2)).Fop) != libc.Int32FromUint8(op) { + _whereClauseInsert(tls, pWC, pExpr, uint16(0)) + } else { + _sqlite3WhereSplit(tls, pWC, (*TExpr)(unsafe.Pointer(pE2)).FpLeft, op) + _sqlite3WhereSplit(tls, pWC, (*TExpr)(unsafe.Pointer(pE2)).FpRight, op) + } +} + +// C documentation +// +// /* +// ** Return 0 if the two window objects are identical, 1 if they are +// ** different, or 2 if it cannot be determined if the objects are identical +// ** or not. Identical window objects can be processed in a single scan. +// */ +func _sqlite3WindowCompare(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uintptr, bFilter int32) (r int32) { + var res, v1 int32 + _, _ = res, v1 + if p1 == uintptr(0) || p2 == uintptr(0) { + return int32(1) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(p1)).FeFrmType) != libc.Int32FromUint8((*TWindow)(unsafe.Pointer(p2)).FeFrmType) { + return int32(1) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(p1)).FeStart) != libc.Int32FromUint8((*TWindow)(unsafe.Pointer(p2)).FeStart) { + return int32(1) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(p1)).FeEnd) != libc.Int32FromUint8((*TWindow)(unsafe.Pointer(p2)).FeEnd) { + return int32(1) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(p1)).FeExclude) != libc.Int32FromUint8((*TWindow)(unsafe.Pointer(p2)).FeExclude) { + return int32(1) + } + if _sqlite3ExprCompare(tls, pParse, (*TWindow)(unsafe.Pointer(p1)).FpStart, (*TWindow)(unsafe.Pointer(p2)).FpStart, -int32(1)) != 0 { + return int32(1) + } + if _sqlite3ExprCompare(tls, pParse, (*TWindow)(unsafe.Pointer(p1)).FpEnd, (*TWindow)(unsafe.Pointer(p2)).FpEnd, -int32(1)) != 0 { + return int32(1) + } + v1 = _sqlite3ExprListCompare(tls, (*TWindow)(unsafe.Pointer(p1)).FpPartition, (*TWindow)(unsafe.Pointer(p2)).FpPartition, -int32(1)) + res = v1 + if v1 != 0 { + return res + } + v1 = _sqlite3ExprListCompare(tls, (*TWindow)(unsafe.Pointer(p1)).FpOrderBy, (*TWindow)(unsafe.Pointer(p2)).FpOrderBy, -int32(1)) + res = v1 + if v1 != 0 { + return res + } + if bFilter != 0 { + v1 = _sqlite3ExprCompare(tls, pParse, (*TWindow)(unsafe.Pointer(p1)).FpFilter, (*TWindow)(unsafe.Pointer(p2)).FpFilter, -int32(1)) + res = v1 + if v1 != 0 { + return res + } + } + return 0 +} + +// C documentation +// +// /* +// ** When rewriting a query, if the new subquery in the FROM clause +// ** contains TK_AGG_FUNCTION nodes that refer to an outer query, +// ** then we have to increase the Expr->op2 values of those nodes +// ** due to the extra subquery layer that was added. +// ** +// ** See also the incrAggDepth() routine in resolve.c +// */ +func _sqlite3WindowExtraAggFuncDepth(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_FUNCTION) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) >= (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop2 + 1 + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** The argument expression is an PRECEDING or FOLLOWING offset. The +// ** value should be a non-negative integer. If the value is not a +// ** constant, change it to NULL. The fact that it is then a non-negative +// ** integer will be caught later. But it is important not to leave +// ** variable values in the expression tree. +// */ +func _sqlite3WindowOffsetExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r uintptr) { + if 0 == _sqlite3ExprIsConstant(tls, uintptr(0), pExpr) { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameExprUnmap(tls, pParse, pExpr) + } + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + pExpr = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_NULL), uintptr(0), 0) + } + return pExpr +} + +// C documentation +// +// /* +// ** True if PRAGMA writable_schema is ON +// */ +func _sqlite3WritableSchema(tls *libc.TLS, db uintptr) (r int32) { + return libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_WriteSchema)|libc.Int32FromInt32(SQLITE_Defensive)) == uint64(SQLITE_WriteSchema)) +} + +// C documentation +// +// /* +// ** This routine translates a standard POSIX errno code into something +// ** useful to the clients of the sqlite3 functions. Specifically, it is +// ** intended to translate a variety of "try again" errors into SQLITE_BUSY +// ** and a variety of "please close the file descriptor NOW" errors into +// ** SQLITE_IOERR +// ** +// ** Errors during initialization of locks, or file system support for locks, +// ** should handle ENOLCK, ENOTSUP, EOPNOTSUPP separately. +// */ +func _sqliteErrorFromPosixError(tls *libc.TLS, posixError int32, sqliteIOErr int32) (r int32) { + switch posixError { + case int32(EACCES): + fallthrough + case int32(EAGAIN): + fallthrough + case int32(ETIMEDOUT): + fallthrough + case int32(EBUSY): + fallthrough + case int32(EINTR): + fallthrough + case int32(ENOLCK): + /* random NFS retry error, unless during file system support + * introspection, in which it actually means what it says */ + return int32(SQLITE_BUSY) + case int32(EPERM): + return int32(SQLITE_PERM) + default: + return sqliteIOErr + } + return r +} + +func _statEof(tls *libc.TLS, pCursor uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCursor + return libc.Int32FromUint8((*TStatCursor)(unsafe.Pointer(pCsr)).FisEof) +} + +func _statRowid(tls *libc.TLS, pCursor uintptr, pRowid uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCursor + **(**Tsqlite_int64)(__ccgo_up(pRowid)) = libc.Int64FromUint32((*TStatCursor)(unsafe.Pointer(pCsr)).FiPageno) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Set the pFile->lastErrno. Do this in a subroutine as that provides +// ** a convenient place to set a breakpoint. +// */ +func _storeLastErrno(tls *libc.TLS, pFile uintptr, error1 int32) { + (*TunixFile)(unsafe.Pointer(pFile)).FlastErrno = error1 +} + +// C documentation +// +// /* +// ** Buffer zStr contains nStr bytes of utf-8 encoded text. Return 1 if zStr +// ** contains character ch, or 0 if it does not. +// */ +func _strContainsChar(tls *libc.TLS, zStr uintptr, nStr int32, ch Tu32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var tst Tu32 + var zEnd, v2 uintptr + var v1 uint32 + var _ /* z at bp+0 */ uintptr + _, _, _, _ = tst, zEnd, v1, v2 + zEnd = zStr + uintptr(nStr) + **(**uintptr)(__ccgo_up(bp)) = zStr + for **(**uintptr)(__ccgo_up(bp)) < zEnd { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) < int32(0x80) { + v2 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + v1 = uint32(**(**Tu8)(__ccgo_up(v2))) + } else { + v1 = _sqlite3Utf8Read(tls, bp) + } + tst = v1 + if tst == ch { + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** Append a record of the current state of page pPg to the sub-journal. +// ** +// ** If successful, set the bit corresponding to pPg->pgno in the bitvecs +// ** for all open savepoints before returning. +// ** +// ** This function returns SQLITE_OK if everything is successful, an IO +// ** error code if the attempt to write to the sub-journal fails, or +// ** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint +// ** bitvec. +// */ +func _subjournalPage(tls *libc.TLS, pPg uintptr) (r int32) { + var offset Ti64 + var pData, pData2, pPager uintptr + var rc int32 + _, _, _, _, _ = offset, pData, pData2, pPager, rc + rc = SQLITE_OK + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager + if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) != int32(PAGER_JOURNALMODE_OFF) { + /* Open the sub-journal, if it has not already been opened */ + rc = _openSubJournal(tls, pPager) + /* If the sub-journal was opened successfully (or was already open), + ** write the journal record into the file. */ + if rc == SQLITE_OK { + pData = (*TPgHdr)(unsafe.Pointer(pPg)).FpData + offset = libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FnSubRec) * (int64(4) + (*TPager)(unsafe.Pointer(pPager)).FpageSize) + pData2 = pData + rc = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fsjfd, offset, (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno) + if rc == SQLITE_OK { + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fsjfd, pData2, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), offset+int64(4)) + } + } + } + if rc == SQLITE_OK { + (*TPager)(unsafe.Pointer(pPager)).FnSubRec = (*TPager)(unsafe.Pointer(pPager)).FnSubRec + 1 + rc = _addToSavepointBitvecs(tls, pPager, (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno) + } + return rc +} + +// C documentation +// +// /* subtype(X) +// ** +// ** Return the subtype of X +// */ +func _subtypeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + _ = argc + Xsqlite3_result_int(tls, context, libc.Int32FromUint32(Xsqlite3_value_subtype(tls, **(**uintptr)(__ccgo_up(argv))))) +} + +func _tabIsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr) (r int32) { + var db uintptr + _ = db + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + return _vtabIsReadOnly(tls, pParse, pTab) + } + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(libc.Int32FromInt32(TF_Readonly)|libc.Int32FromInt32(TF_Shadow)) == uint32(0) { + return 0 + } + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Readonly) != uint32(0) { + return libc.BoolInt32(_sqlite3WritableSchema(tls, db) == 0 && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0) + } + return _sqlite3ReadOnlyShadowTables(tls, db) +} + +// C documentation +// +// /* +// ** The unicode() function. Return the integer unicode code-point value +// ** for the first character of the input string. +// */ +func _unicodeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* z at bp+0 */ uintptr + **(**uintptr)(__ccgo_up(bp)) = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + _ = argc + if **(**uintptr)(__ccgo_up(bp)) != 0 && **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0 { + Xsqlite3_result_int(tls, context, libc.Int32FromUint32(_sqlite3Utf8Read(tls, bp))) + } +} + +// C documentation +// +// /* +// ** Helper functions to obtain and relinquish the global mutex. The +// ** global mutex is used to protect the unixInodeInfo objects used by +// ** this file, all of which may be shared by multiple threads. +// ** +// ** Function unixMutexHeld() is used to assert() that the global mutex +// ** is held when required. This function is only used as part of assert() +// ** statements. e.g. +// ** +// ** unixEnterMutex() +// ** assert( unixMutexHeld() ); +// ** unixEnterLeave() +// ** +// ** To prevent deadlock, the global unixBigLock must must be acquired +// ** before the unixInodeInfo.pLockMutex mutex, if both are held. It is +// ** OK to get the pLockMutex without holding unixBigLock first, but if +// ** that happens, the unixBigLock mutex must not be acquired until after +// ** pLockMutex is released. +// ** +// ** OK: enter(unixBigLock), enter(pLockInfo) +// ** OK: enter(unixBigLock) +// ** OK: enter(pLockInfo) +// ** ERROR: enter(pLockInfo), enter(unixBigLock) +// */ +var _unixBigLock = uintptr(0) + +// C documentation +// +// /* +// ** Close a file. +// */ +func _unixClose(tls *libc.TLS, id uintptr) (r int32) { + var pFile, pInode uintptr + var rc int32 + _, _, _ = pFile, pInode, rc + rc = SQLITE_OK + pFile = id + pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode + _verifyDbFile(tls, pFile) + _unixUnlock(tls, id, NO_LOCK) + _unixEnterMutex(tls) + /* unixFile.pInode is always valid here. Otherwise, a different close + ** routine (e.g. nolockClose()) would be called instead. + */ + Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + if (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock != 0 { + /* If there are outstanding locks, do not actually close the file just + ** yet because that would clear those locks. Instead, add the file + ** descriptor to pInode->pUnused list. It will be automatically closed + ** when the last lock is cleared. + */ + _setPendingFd(tls, pFile) + } + Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) + _releaseInodeInfo(tls, pFile) + rc = _closeUnixFile(tls, id) + _unixLeaveMutex(tls) + return rc +} + +/************** End of the posix advisory lock implementation ***************** +******************************************************************************/ + +/****************************************************************************** +****************************** No-op Locking ********************************** +** +** Of the various locking implementations available, this is by far the +** simplest: locking is ignored. No attempt is made to lock the database +** file for reading or writing. +** +** This locking mode is appropriate for use on read-only databases +** (ex: databases that are burned into CD-ROM, for example.) It can +** also be used if the application employs some external mechanism to +** prevent simultaneous access of the same database by two or more +** database connections. But there is a serious risk of database +** corruption if this locking mode is used in situations where multiple +** database connections are accessing the same database file at the same +** time and one or more of those connections are writing. + */ + +// C documentation +// +// /* +// ** Find the current time (in Universal Coordinated Time). Write the +// ** current time and date as a Julian Day number into *prNow and +// ** return 0. Return 1 if the time and date cannot be found. +// */ +func _unixCurrentTime(tls *libc.TLS, NotUsed uintptr, prNow uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* i at bp+0 */ Tsqlite3_int64 + _ = rc + **(**Tsqlite3_int64)(__ccgo_up(bp)) = 0 + _ = NotUsed + rc = _unixCurrentTimeInt64(tls, uintptr(0), bp) + **(**float64)(__ccgo_up(prNow)) = float64(**(**Tsqlite3_int64)(__ccgo_up(bp))) / float64(8.64e+07) + return rc +} + +// C documentation +// +// /* +// ** Return the device characteristics for the file. +// ** +// ** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default. +// ** However, that choice is controversial since technically the underlying +// ** file system does not always provide powersafe overwrites. (In other +// ** words, after a power-loss event, parts of the file that were never +// ** written might end up being altered.) However, non-PSOW behavior is very, +// ** very rare. And asserting PSOW makes a large reduction in the amount +// ** of required I/O for journaling, since a lot of padding is eliminated. +// ** Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control +// ** available to turn it off and URI query parameter available to turn it off. +// */ +func _unixDeviceCharacteristics(tls *libc.TLS, id uintptr) (r int32) { + var pFd uintptr + _ = pFd + pFd = id + _setDeviceCharacteristics(tls, pFd) + return (*TunixFile)(unsafe.Pointer(pFd)).FdeviceCharacteristics +} + +func _unixDlClose(tls *libc.TLS, NotUsed uintptr, pHandle uintptr) { + _ = NotUsed + libc.Xdlclose(tls, pHandle) +} + +func _unixDlOpen(tls *libc.TLS, NotUsed uintptr, zFilename uintptr) (r uintptr) { + _ = NotUsed + return libc.Xdlopen(tls, zFilename, libc.Int32FromInt32(RTLD_NOW)|libc.Int32FromInt32(RTLD_GLOBAL)) +} + +func _unixDlSym(tls *libc.TLS, NotUsed uintptr, p uintptr, zSym uintptr) (r uintptr) { + var x uintptr + _ = x + _ = NotUsed + x = __ccgo_fp(libc.Xdlsym) + return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{x})))(tls, p, zSym) +} + +func _unixEnterMutex(tls *libc.TLS) { + /* Not a recursive mutex */ + Xsqlite3_mutex_enter(tls, _unixBigLock) +} + +var _unixEpoch = libc.Int64FromInt32(24405875) * libc.Int64FromInt32(8640000) + +func _unixLeaveMutex(tls *libc.TLS) { + Xsqlite3_mutex_leave(tls, _unixBigLock) +} + +// C documentation +// +// /* +// ** Return the sector size in bytes of the underlying block device for +// ** the specified file. This is almost always 512 bytes, but may be +// ** larger for some devices. +// ** +// ** SQLite code assumes this function cannot fail. It also assumes that +// ** if two files are created in the same file-system directory (i.e. +// ** a database and its journal file) that the sector size will be the +// ** same for both. +// */ +func _unixSectorSize(tls *libc.TLS, id uintptr) (r int32) { + var pFd uintptr + _ = pFd + pFd = id + _setDeviceCharacteristics(tls, pFd) + return (*TunixFile)(unsafe.Pointer(pFd)).FsectorSize +} + +// C documentation +// +// /* +// ** Return the minimum number of 32KB shm regions that should be mapped at +// ** a time, assuming that each mapping must be an integer multiple of the +// ** current system page-size. +// ** +// ** Usually, this is 1. The exception seems to be systems that are configured +// ** to use 64KB pages - in this case each mapping must cover at least two +// ** shm regions. +// */ +func _unixShmRegionPerMap(tls *libc.TLS) (r int32) { + var pgsz, shmsz int32 + _, _ = pgsz, shmsz + shmsz = libc.Int32FromInt32(32) * libc.Int32FromInt32(1024) /* SHM region size */ + pgsz = (*(*func(*libc.TLS) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(25)].FpCurrent})))(tls) /* System page size */ + /* Page size must be a power of 2 */ + if pgsz < shmsz { + return int32(1) + } + return pgsz / shmsz +} + +// C documentation +// +// /* +// ** Lower the locking level on file descriptor pFile to eFileLock. eFileLock +// ** must be either NO_LOCK or SHARED_LOCK. +// ** +// ** If the locking level of the file descriptor is already at or below +// ** the requested locking level, this routine is a no-op. +// */ +func _unixUnlock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) { + return _posixUnlock(tls, id, eFileLock, 0) +} + +// C documentation +// +// /* +// ** Write data from a buffer into a file. Return SQLITE_OK on success +// ** or some other error code on failure. +// */ +func _unixWrite(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Tsqlite3_int64) (r int32) { + var pFile uintptr + var wrote, v1 int32 + _, _, _ = pFile, wrote, v1 + pFile = id + wrote = 0 + /* If this is a database file (not a journal, super-journal or temp + ** file), the bytes in the locking range should never be read or written. */ + for { + v1 = _seekAndWrite(tls, pFile, offset, pBuf, amt) + wrote = v1 + if !(v1 < amt && wrote > 0) { + break + } + amt = amt - wrote + offset = offset + int64(wrote) + pBuf = pBuf + uintptr(wrote) + } + if amt > wrote { + if wrote < 0 && (*TunixFile)(unsafe.Pointer(pFile)).FlastErrno != int32(ENOSPC) { + /* lastErrno set by seekAndWrite */ + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(3)<xDel and memory in p->zMalloc. +// ** +// ** This is a helper routine invoked by sqlite3VdbeMemRelease() in +// ** the unusual case where there really is memory in p that needs +// ** to be freed. +// */ +func _vdbeMemClear(tls *libc.TLS, p uintptr) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(p)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _vdbeMemClearExternAndSetNull(tls, p) + } + if (*TMem)(unsafe.Pointer(p)).FszMalloc != 0 { + _sqlite3DbFreeNN(tls, (*TMem)(unsafe.Pointer(p)).Fdb, (*TMem)(unsafe.Pointer(p)).FzMalloc) + (*TMem)(unsafe.Pointer(p)).FszMalloc = 0 + } + (*TMem)(unsafe.Pointer(p)).Fz = uintptr(0) +} + +// C documentation +// +// /* +// ** Read a varint from the stream of data accessed by p. Set *pnOut to +// ** the value read. +// */ +func _vdbePmaReadVarint(tls *libc.TLS, p uintptr, pnOut uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, iBuf, rc, v1 int32 + var _ /* a at bp+16 */ uintptr + var _ /* aVarint at bp+0 */ [16]Tu8 + _, _, _, _ = i, iBuf, rc, v1 + if (*TPmaReader)(unsafe.Pointer(p)).FaMap != 0 { + **(**Ti64)(__ccgo_up(p)) += libc.Int64FromUint8(_sqlite3GetVarint(tls, (*TPmaReader)(unsafe.Pointer(p)).FaMap+uintptr((*TPmaReader)(unsafe.Pointer(p)).FiReadOff), pnOut)) + } else { + iBuf = int32((*TPmaReader)(unsafe.Pointer(p)).FiReadOff % int64((*TPmaReader)(unsafe.Pointer(p)).FnBuffer)) + if iBuf != 0 && (*TPmaReader)(unsafe.Pointer(p)).FnBuffer-iBuf >= int32(9) { + **(**Ti64)(__ccgo_up(p)) += libc.Int64FromUint8(_sqlite3GetVarint(tls, (*TPmaReader)(unsafe.Pointer(p)).FaBuffer+uintptr(iBuf), pnOut)) + } else { + i = 0 + for cond := true; cond; cond = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 16)))))&int32(0x80) != 0 { + rc = _vdbePmaReadBlob(tls, p, int32(1), bp+16) + if rc != 0 { + return rc + } + v1 = i + i = i + 1 + (**(**[16]Tu8)(__ccgo_up(bp)))[v1&int32(0xf)] = **(**Tu8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 16)))) + } + _sqlite3GetVarint(tls, bp, pnOut) + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Initialize PmaReader pReadr to scan through the PMA stored in file pFile +// ** starting at offset iStart and ending at offset iEof-1. This function +// ** leaves the PmaReader pointing to the first key in the PMA (or EOF if the +// ** PMA is empty). +// ** +// ** If the pnByte parameter is NULL, then it is assumed that the file +// ** contains a single PMA, and that that PMA omits the initial length varint. +// */ +func _vdbePmaReaderInit(tls *libc.TLS, pTask uintptr, pFile uintptr, iStart Ti64, pReadr uintptr, pnByte uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var v1 uintptr + var _ /* nByte at bp+0 */ Tu64 + _, _ = rc, v1 + rc = _vdbePmaReaderSeek(tls, pTask, pReadr, pFile, iStart) + if rc == SQLITE_OK { + **(**Tu64)(__ccgo_up(bp)) = uint64(0) /* Size of PMA in bytes */ + rc = _vdbePmaReadVarint(tls, pReadr, bp) + (*TPmaReader)(unsafe.Pointer(pReadr)).FiEof = libc.Int64FromUint64(libc.Uint64FromInt64((*TPmaReader)(unsafe.Pointer(pReadr)).FiReadOff) + **(**Tu64)(__ccgo_up(bp))) + v1 = pnByte + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) + **(**Tu64)(__ccgo_up(bp))) + } + if rc == SQLITE_OK { + rc = _vdbePmaReaderNext(tls, pReadr) + } + return rc +} + +// C documentation +// +// /* +// ** The first argument passed to this function is a serial-type that +// ** corresponds to an integer - all values between 1 and 9 inclusive +// ** except 7. The second points to a buffer containing an integer value +// ** serialized according to serial_type. This function deserializes +// ** and returns the value. +// */ +func _vdbeRecordDecodeInt(tls *libc.TLS, serial_type Tu32, aKey uintptr) (r Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* x at bp+8 */ Tu64 + var _ /* y at bp+0 */ Tu32 + switch serial_type { + case uint32(0): + fallthrough + case uint32(1): + return int64(libc.Int8FromUint8(**(**Tu8)(__ccgo_up(aKey)))) + case uint32(2): + return int64(libc.Int32FromInt32(256)*int32(libc.Int8FromUint8(**(**Tu8)(__ccgo_up(aKey)))) | libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aKey + 1)))) + case uint32(3): + return int64(libc.Int32FromInt32(65536)*int32(libc.Int8FromUint8(**(**Tu8)(__ccgo_up(aKey)))) | libc.Int32FromUint8(**(**Tu8)(__ccgo_up(aKey + 1)))< int32(7) && s2 > int32(7) { + res = s1 - s2 + } else { + if s2 > int32(7) { + res = +libc.Int32FromInt32(1) + } else { + if s1 > int32(7) { + res = -int32(1) + } else { + res = s1 - s2 + } + } + if res > 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v1)))&int32(0x80) != 0 { + res = -int32(1) + } + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(v2)))&int32(0x80) != 0 { + res = +libc.Int32FromInt32(1) + } + } + } + } + if res == 0 { + if libc.Int32FromUint16((*TKeyInfo)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField) > int32(1) { + res = _vdbeSorterCompareTail(tls, pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2) + } + } else { + if **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags)) != 0 { + res = res * -int32(1) + } + } + return res +} + +// C documentation +// +// /* +// ** Return the SorterCompare function to compare values collected by the +// ** sorter object passed as the only argument. +// */ +func _vdbeSorterGetCompare(tls *libc.TLS, p uintptr) (r TSorterCompare) { + if libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(p)).FtypeMask) == int32(SORTER_TYPE_INTEGER) { + return __ccgo_fp(_vdbeSorterCompareInt) + } else { + if libc.Int32FromUint8((*TVdbeSorter)(unsafe.Pointer(p)).FtypeMask) == int32(SORTER_TYPE_TEXT) { + return __ccgo_fp(_vdbeSorterCompareText) + } + } + return __ccgo_fp(_vdbeSorterCompare) +} + +// C documentation +// +// /* +// ** Compute a hash on a page number. The resulting hash value must land +// ** between 0 and (HASHTABLE_NSLOT-1). The walNextHash() function advances +// ** the hash to the next value in the event of a collision. +// */ +func _walHash(tls *libc.TLS, iPage Tu32) (r int32) { + return libc.Int32FromUint32(iPage * uint32(HASHTABLE_HASH_1) & libc.Uint32FromInt32(libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2)-libc.Int32FromInt32(1))) +} + +// C documentation +// +// /* +// ** Read the wal-index header from the wal-index and into pWal->hdr. +// ** If the wal-header appears to be corrupt, try to reconstruct the +// ** wal-index from the WAL before returning. +// ** +// ** Set *pChanged to 1 if the wal-index header value in pWal->hdr is +// ** changed by this operation. If pWal->hdr is unchanged, set *pChanged +// ** to 0. +// ** +// ** If the wal-index header is successfully read, return SQLITE_OK. +// ** Otherwise an SQLite error code. +// */ +func _walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bWriteLock, badHdr, rc, v1 int32 + var v4 bool + var _ /* page0 at bp+0 */ uintptr + _, _, _, _, _ = bWriteLock, badHdr, rc, v1, v4 /* Chunk of wal-index containing header */ + /* Ensure that page 0 of the wal-index (the page that contains the + ** wal-index header) is mapped. Return early if an error occurs here. + */ + rc = _walIndexPage(tls, pWal, 0, bp) + if rc != SQLITE_OK { + /* READONLY changed to OK in walIndexPage */ + if rc == libc.Int32FromInt32(SQLITE_READONLY)|libc.Int32FromInt32(5)<writeLock + ** is zero, which prevents the SHM from growing */ + } + /* If the first page of the wal-index has been mapped, try to read the + ** wal-index header immediately, without holding any lock. This usually + ** works, but may fail if the wal-index header is corrupt or currently + ** being modified by another thread or process. + */ + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v1 = _walIndexTryHdr(tls, pWal, pChanged) + } else { + v1 = int32(1) + } + badHdr = v1 + /* If the first attempt failed, it might have been due to a race + ** with a writer. So get a WRITE lock and try again. + */ + if badHdr != 0 { + if libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0 && libc.Int32FromUint8((*TWal)(unsafe.Pointer(pWal)).FreadOnly)&int32(WAL_SHM_RDONLY) != 0 { + v1 = _walLockShared(tls, pWal, WAL_WRITE_LOCK) + rc = v1 + if SQLITE_OK == v1 { + _walUnlockShared(tls, pWal, WAL_WRITE_LOCK) + rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(1)< x<=y +// ** x=y OR x=y --> x=y +// ** x<=y OR x x<=y +// ** +// ** The following is NOT generated: +// ** +// ** xy --> x!=y +// */ +func _whereCombineDisjuncts(tls *libc.TLS, pSrc uintptr, pWC uintptr, pOne uintptr, pTwo uintptr) { + var db, pA, pB, pNew uintptr + var eOp Tu16 + var idxNew, op int32 + _, _, _, _, _, _, _ = db, eOp, idxNew, op, pA, pB, pNew + eOp = libc.Uint16FromInt32(libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOne)).FeOperator) | libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTwo)).FeOperator)) /* Expressions associated with pOne and pTwo */ + if (libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOne)).FwtFlags)|libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTwo)).FwtFlags))&int32(TERM_VNULL) != 0 { + return + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pOne)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) == 0 { + return + } + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTwo)).FeOperator)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) == 0 { + return + } + if libc.Int32FromUint16(eOp)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))) != libc.Int32FromUint16(eOp) && libc.Int32FromUint16(eOp)&(libc.Int32FromInt32(WO_EQ)|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_GE)-libc.Int32FromInt32(TK_EQ))) != libc.Int32FromUint16(eOp) { + return + } + pA = (*TWhereTerm)(unsafe.Pointer(pOne)).FpExpr + pB = (*TWhereTerm)(unsafe.Pointer(pTwo)).FpExpr + if _sqlite3ExprCompare(tls, uintptr(0), (*TExpr)(unsafe.Pointer(pA)).FpLeft, (*TExpr)(unsafe.Pointer(pB)).FpLeft, -int32(1)) != 0 { + return + } + if _sqlite3ExprCompare(tls, uintptr(0), (*TExpr)(unsafe.Pointer(pA)).FpRight, (*TExpr)(unsafe.Pointer(pB)).FpRight, -int32(1)) != 0 { + return + } + if libc.BoolInt32((*TExpr)(unsafe.Pointer(pA)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0)) != libc.BoolInt32((*TExpr)(unsafe.Pointer(pB)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0)) { + return + } + /* If we reach this point, it means the two subterms can be combined */ + if libc.Int32FromUint16(eOp)&(libc.Int32FromUint16(eOp)-int32(1)) != 0 { + if libc.Int32FromUint16(eOp)&(libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LT)-libc.Int32FromInt32(TK_EQ))|libc.Int32FromInt32(WO_EQ)<<(libc.Int32FromInt32(TK_LE)-libc.Int32FromInt32(TK_EQ))) != 0 { + eOp = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ) << (libc.Int32FromInt32(TK_LE) - libc.Int32FromInt32(TK_EQ))) + } else { + eOp = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ) << (libc.Int32FromInt32(TK_GE) - libc.Int32FromInt32(TK_EQ))) + } + } + db = (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb + pNew = _sqlite3ExprDup(tls, db, pA, 0) + if pNew == uintptr(0) { + return + } + op = int32(TK_EQ) + for { + if !(libc.Int32FromUint16(eOp) != int32(WO_EQ)<<(op-int32(TK_EQ))) { + break + } + goto _1 + _1: + ; + op = op + 1 + } + (*TExpr)(unsafe.Pointer(pNew)).Fop = libc.Uint8FromInt32(op) + idxNew = _whereClauseInsert(tls, pWC, pNew, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + _exprAnalyze(tls, pSrc, pWC, idxNew) +} + +// C documentation +// +// /* +// ** Try to adjust the cost and number of output rows of WhereLoop pTemplate +// ** upwards or downwards so that: +// ** +// ** (1) pTemplate costs less than any other WhereLoops that are a proper +// ** subset of pTemplate +// ** +// ** (2) pTemplate costs more than any other WhereLoops for which pTemplate +// ** is a proper subset. +// ** +// ** To say "WhereLoop X is a proper subset of Y" means that X uses fewer +// ** WHERE clause terms than Y and that every WHERE clause term used by X is +// ** also used by Y. +// */ +func _whereLoopAdjustCost(tls *libc.TLS, p uintptr, pTemplate uintptr) { + var v2 int32 + _ = v2 + if (*TWhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags&uint32(WHERE_INDEXED) == uint32(0) { + return + } + for { + if !(p != 0) { + break + } + if libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(p)).FiTab) != libc.Int32FromUint8((*TWhereLoop)(unsafe.Pointer(pTemplate)).FiTab) { + goto _1 + } + if (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags&uint32(WHERE_INDEXED) == uint32(0) { + goto _1 + } + if _whereLoopCheaperProperSubset(tls, p, pTemplate) != 0 { + /* Adjust pTemplate cost downward so that it is cheaper than its + ** subset p. */ + if int32((*TWhereLoop)(unsafe.Pointer(p)).FrRun) < int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun) { + v2 = int32((*TWhereLoop)(unsafe.Pointer(p)).FrRun) + } else { + v2 = int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun) + } + (*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun = int16(v2) + if int32((*TWhereLoop)(unsafe.Pointer(p)).FnOut)-int32(1) < int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut) { + v2 = int32((*TWhereLoop)(unsafe.Pointer(p)).FnOut) - int32(1) + } else { + v2 = int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut) + } + (*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut = int16(v2) + } else { + if _whereLoopCheaperProperSubset(tls, pTemplate, p) != 0 { + /* Adjust pTemplate cost upward so that it is costlier than p since + ** pTemplate is a proper subset of p */ + if int32((*TWhereLoop)(unsafe.Pointer(p)).FrRun) > int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun) { + v2 = int32((*TWhereLoop)(unsafe.Pointer(p)).FrRun) + } else { + v2 = int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun) + } + (*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun = int16(v2) + if int32((*TWhereLoop)(unsafe.Pointer(p)).FnOut)+int32(1) > int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut) { + v2 = int32((*TWhereLoop)(unsafe.Pointer(p)).FnOut) + int32(1) + } else { + v2 = int32((*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut) + } + (*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut = int16(v2) + } + } + goto _1 + _1: + ; + p = (*TWhereLoop)(unsafe.Pointer(p)).FpNextLoop + } +} + +// C documentation +// +// /* +// ** Clear the WhereLoop.u union. Leave WhereLoop.pLTerm intact. +// */ +func _whereLoopClearUnion(tls *libc.TLS, db uintptr, p uintptr) { + if (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_VIRTUALTABLE)|libc.Int32FromInt32(WHERE_AUTO_INDEX)) != 0 { + if (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags&uint32(WHERE_VIRTUALTABLE) != uint32(0) && int32(Tu32(*(*uint8)(unsafe.Pointer(p + 24 + 4))&0x1>>0)) != 0 { + Xsqlite3_free(tls, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(p + 24))).FidxStr) + libc.SetBitFieldPtr8Uint32(p+24+4, libc.Uint32FromInt32(0), 0, 0x1) + (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(p + 24))).FidxStr = uintptr(0) + } else { + if (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags&uint32(WHERE_AUTO_INDEX) != uint32(0) && (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(p + 24))).FpIndex != uintptr(0) { + _sqlite3DbFree(tls, db, (*TIndex)(unsafe.Pointer((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(p + 24))).FpIndex)).FzColAff) + _sqlite3DbFreeNN(tls, db, (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(p + 24))).FpIndex) + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(p + 24))).FpIndex = uintptr(0) + } + } + } +} + +// C documentation +// +// /* +// ** If it is not NULL, pTerm is a term that provides an upper or lower +// ** bound on a range scan. Without considering pTerm, it is estimated +// ** that the scan will visit nNew rows. This function returns the number +// ** estimated to be visited after taking pTerm into account. +// ** +// ** If the user explicitly specified a likelihood() value for this term, +// ** then the return value is the likelihood multiplied by the number of +// ** input rows. Otherwise, this function assumes that an "IS NOT NULL" term +// ** has a likelihood of 0.50, and any other term a likelihood of 0.25. +// */ +func _whereRangeAdjust(tls *libc.TLS, pTerm uintptr, nNew TLogEst) (r TLogEst) { + var nRet TLogEst + _ = nRet + nRet = nNew + if pTerm != 0 { + if int32((*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 { + nRet = int16(int32(nRet) + int32((*TWhereTerm)(unsafe.Pointer(pTerm)).FtruthProb)) + } else { + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VNULL) == 0 { + nRet = int16(int32(nRet) - libc.Int32FromInt32(20)) + } + } + } + return nRet +} + +// C documentation +// +// /* +// ** If the right-hand branch of the expression is a TK_COLUMN, then return +// ** a pointer to the right-hand branch. Otherwise, return NULL. +// */ +func _whereRightSubexprIsColumn(tls *libc.TLS, p uintptr) (r uintptr) { + p = _sqlite3ExprSkipCollateAndLikely(tls, (*TExpr)(unsafe.Pointer(p)).FpRight) + if p != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_COLUMN) && !((*TExpr)(unsafe.Pointer(p)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != libc.Uint32FromInt32(0)) { + return p + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Return the cost of sorting nRow rows, assuming that the keys have +// ** nOrderby columns and that the first nSorted columns are already in +// ** order. +// */ +func _whereSortingCost(tls *libc.TLS, pWInfo uintptr, nRow TLogEst, nOrderBy int32, nSorted int32) (r TLogEst) { + var nCol, rSortCost TLogEst + _, _ = nCol, rSortCost + /* TUNING: sorting cost proportional to the number of output columns: */ + nCol = _sqlite3LogEst(tls, libc.Uint64FromInt32(((*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FpEList)).FnExpr+int32(59))/int32(30))) + rSortCost = int16(int32(nRow) + int32(nCol)) + if nSorted > 0 { + /* Scale the result by (Y/X) */ + rSortCost = int16(int32(rSortCost) + (int32(_sqlite3LogEst(tls, libc.Uint64FromInt32((nOrderBy-nSorted)*int32(100)/nOrderBy))) - libc.Int32FromInt32(66))) + } + /* Multiple by log(M) where M is the number of output rows. + ** Use the LIMIT for M if it is smaller. Or if this sort is for + ** a DISTINCT operator, M will be the number of distinct output + ** rows, so fudge it downwards a bit. + */ + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_USE_LIMIT) != 0 { + rSortCost = int16(int32(rSortCost) + libc.Int32FromInt32(10)) /* TUNING: Extra 2.0x if using LIMIT */ + if nSorted != 0 { + rSortCost = int16(int32(rSortCost) + libc.Int32FromInt32(6)) /* TUNING: Extra 1.5x if also using partial sort */ + } + if int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FiLimit) < int32(nRow) { + nRow = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiLimit + } + } else { + if libc.Int32FromUint16((*TWhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&int32(WHERE_WANT_DISTINCT) != 0 { + /* TUNING: In the sort for a DISTINCT operator, assume that the DISTINCT + ** reduces the number of output rows by a factor of 2 */ + if int32(nRow) > int32(10) { + nRow = int16(int32(nRow) - libc.Int32FromInt32(10)) + } + } + } + rSortCost = int16(int32(rSortCost) + int32(_estLog(tls, nRow))) + return rSortCost +} + +// C documentation +// +// /* +// ** Generate VM code to invoke either xValue() (bFin==0) or xFinalize() +// ** (bFin==1) for each window function in the linked list starting at +// ** pMWin. Or, for built-in window-functions that do not use the standard +// ** API, generate the equivalent VM code. +// */ +func _windowAggFinal(tls *libc.TLS, p uintptr, bFin int32) { + var nArg int32 + var pMWin, pParse, pWin, v uintptr + _, _, _, _, _ = nArg, pMWin, pParse, pWin, v + pParse = (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse + pMWin = (*TWindowCodeArg)(unsafe.Pointer(p)).FpMWin + v = _sqlite3GetVdbe(tls, pParse) + pWin = pMWin + for { + if !(pWin != 0) { + break + } + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid == 0 && (*TFuncDef)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpWFunc)).FfuncFlags&uint32(SQLITE_FUNC_MINMAX) != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pWin)).FeStart) != int32(TK_UNBOUNDED) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregResult) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Last), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp, 0, (*TWindow)(unsafe.Pointer(pWin)).FregResult) + _sqlite3VdbeJumpHere(tls, v, _sqlite3VdbeCurrentAddr(tls, v)-int32(2)) + } else { + if (*TWindow)(unsafe.Pointer(pWin)).FregApp != 0 { + } else { + nArg = _windowArgCount(tls, pWin) + if bFin != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AggFinal), (*TWindow)(unsafe.Pointer(pWin)).FregAccum, nArg) + _sqlite3VdbeAppendP4(tls, v, (*TWindow)(unsafe.Pointer(pWin)).FpWFunc, -int32(8)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Copy), (*TWindow)(unsafe.Pointer(pWin)).FregAccum, (*TWindow)(unsafe.Pointer(pWin)).FregResult) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregAccum) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_AggValue), (*TWindow)(unsafe.Pointer(pWin)).FregAccum, nArg, (*TWindow)(unsafe.Pointer(pWin)).FregResult) + _sqlite3VdbeAppendP4(tls, v, (*TWindow)(unsafe.Pointer(pWin)).FpWFunc, -int32(8)) + } + } + } + goto _1 + _1: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } +} + +// C documentation +// +// /* +// ** Helper function for sqlite3WindowCodeStep(). Each call to this function +// ** generates VM code for a single RETURN_ROW, AGGSTEP or AGGINVERSE +// ** operation. Refer to the header comment for sqlite3WindowCodeStep() for +// ** details. +// */ +func _windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOnEof int32) (r int32) { + var addrContinue, addrNextRange, bPeer, csr, lblDone, nReg, reg, regRowid1, regRowid2, regTmp, ret, v1, v2 int32 + var pMWin, pParse, v uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrContinue, addrNextRange, bPeer, csr, lblDone, nReg, pMWin, pParse, reg, regRowid1, regRowid2, regTmp, ret, v, v1, v2 + pParse = (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse + pMWin = (*TWindowCodeArg)(unsafe.Pointer(p)).FpMWin + ret = 0 + v = (*TWindowCodeArg)(unsafe.Pointer(p)).FpVdbe + addrContinue = 0 + bPeer = libc.BoolInt32(libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) != int32(TK_ROWS)) + lblDone = _sqlite3VdbeMakeLabel(tls, pParse) + addrNextRange = 0 + /* Special case - WINDOW_AGGINVERSE is always a no-op if the frame + ** starts with UNBOUNDED PRECEDING. */ + if op == int32(WINDOW_AGGINVERSE) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_UNBOUNDED) { + return 0 + } + if regCountdown > 0 { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + addrNextRange = _sqlite3VdbeCurrentAddr(tls, v) + if op == int32(WINDOW_AGGINVERSE) { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == int32(TK_FOLLOWING) { + _windowCodeRangeTest(tls, p, int32(OP_Le), (*TWindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, regCountdown, (*TWindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, lblDone) + } else { + _windowCodeRangeTest(tls, p, int32(OP_Ge), (*TWindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regCountdown, (*TWindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) + } + } else { + _windowCodeRangeTest(tls, p, int32(OP_Gt), (*TWindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regCountdown, (*TWindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) + } + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_IfPos), regCountdown, lblDone, int32(1)) + } + } + if op == int32(WINDOW_RETURN_ROW) && (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid == 0 { + _windowAggFinal(tls, p, 0) + } + addrContinue = _sqlite3VdbeCurrentAddr(tls, v) + /* If this is a (RANGE BETWEEN a FOLLOWING AND b FOLLOWING) or + ** (RANGE BETWEEN b PRECEDING AND a PRECEDING) frame, ensure the + ** start cursor does not advance past the end cursor within the + ** temporary table. It otherwise might, if (a>b). Also ensure that, + ** if the input cursor is still finding new rows, that the end + ** cursor does not go past it to EOF. */ + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeStart) == libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeEnd) && regCountdown != 0 && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeFrmType) == int32(TK_RANGE) { + regRowid1 = _sqlite3GetTempReg(tls, pParse) + regRowid2 = _sqlite3GetTempReg(tls, pParse) + if op == int32(WINDOW_AGGINVERSE) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), (*TWindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regRowid1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), (*TWindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regRowid2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ge), regRowid2, lblDone, regRowid1) + } else { + if (*TWindowCodeArg)(unsafe.Pointer(p)).FregRowid != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), (*TWindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regRowid1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ge), (*TWindowCodeArg)(unsafe.Pointer(p)).FregRowid, lblDone, regRowid1) + } + } + _sqlite3ReleaseTempReg(tls, pParse, regRowid1) + _sqlite3ReleaseTempReg(tls, pParse, regRowid2) + } + switch op { + case int32(WINDOW_RETURN_ROW): + csr = (*TWindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr + reg = (*TWindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Freg + _windowReturnOneRow(tls, p) + case int32(WINDOW_AGGINVERSE): + csr = (*TWindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr + reg = (*TWindowCodeArg)(unsafe.Pointer(p)).Fstart.Freg + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid, int32(1)) + } else { + _windowAggStep(tls, p, pMWin, csr, int32(1), (*TWindowCodeArg)(unsafe.Pointer(p)).FregArg) + } + default: + csr = (*TWindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr + reg = (*TWindowCodeArg)(unsafe.Pointer(p)).Fend.Freg + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), (*TWindow)(unsafe.Pointer(pMWin)).FregEndRowid, int32(1)) + } else { + _windowAggStep(tls, p, pMWin, csr, 0, (*TWindowCodeArg)(unsafe.Pointer(p)).FregArg) + } + break + } + if op == (*TWindowCodeArg)(unsafe.Pointer(p)).FeDelete { + _sqlite3VdbeAddOp1(tls, v, int32(OP_Delete), csr) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION)) + } + if jumpOnEof != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), csr, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + ret = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), csr, _sqlite3VdbeCurrentAddr(tls, v)+int32(1)+bPeer) + if bPeer != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, lblDone) + } + } + if bPeer != 0 { + if (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy != 0 { + v1 = (*TExprList)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy)).FnExpr + } else { + v1 = 0 + } + nReg = v1 + if nReg != 0 { + v2 = _sqlite3GetTempRange(tls, pParse, nReg) + } else { + v2 = 0 + } + regTmp = v2 + _windowReadPeerValues(tls, p, csr, regTmp) + _windowIfNewPeer(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy, regTmp, reg, addrContinue) + _sqlite3ReleaseTempRange(tls, pParse, regTmp, nReg) + } + if addrNextRange != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addrNextRange) + } + _sqlite3VdbeResolveLabel(tls, v, lblDone) + return ret +} + +// C documentation +// +// /* +// ** Generate code to calculate the current values of all window functions in the +// ** p->pMWin list by doing a full scan of the current window frame. Store the +// ** results in the Window.regResult registers, ready to return the upper +// ** layer. +// */ +func _windowFullScan(tls *libc.TLS, p uintptr) { + var addr, addrEq, addrNext, csr, lblBrk, lblNext, nPeer, regCPeer, regCRowid, regPeer, regRowid, v1 int32 + var pKeyInfo, pMWin, pParse, pWin, v uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrEq, addrNext, csr, lblBrk, lblNext, nPeer, pKeyInfo, pMWin, pParse, pWin, regCPeer, regCRowid, regPeer, regRowid, v, v1 + pParse = (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse + pMWin = (*TWindowCodeArg)(unsafe.Pointer(p)).FpMWin + v = (*TWindowCodeArg)(unsafe.Pointer(p)).FpVdbe + regCRowid = 0 /* Current rowid value */ + regCPeer = 0 /* Current peer values */ + regRowid = 0 /* AggStep rowid value */ + regPeer = 0 + csr = (*TWindow)(unsafe.Pointer(pMWin)).FcsrApp + if (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy != 0 { + v1 = (*TExprList)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy)).FnExpr + } else { + v1 = 0 + } + nPeer = v1 + lblNext = _sqlite3VdbeMakeLabel(tls, pParse) + lblBrk = _sqlite3VdbeMakeLabel(tls, pParse) + regCRowid = _sqlite3GetTempReg(tls, pParse) + regRowid = _sqlite3GetTempReg(tls, pParse) + if nPeer != 0 { + regCPeer = _sqlite3GetTempRange(tls, pParse, nPeer) + regPeer = _sqlite3GetTempRange(tls, pParse, nPeer) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr, regCRowid) + _windowReadPeerValues(tls, p, (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr, regCPeer) + pWin = pMWin + for { + if !(pWin != 0) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregAccum) + goto _2 + _2: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekGE), csr, lblBrk, (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid) + addrNext = _sqlite3VdbeCurrentAddr(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), csr, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Gt), (*TWindow)(unsafe.Pointer(pMWin)).FregEndRowid, lblBrk, regRowid) + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeExclude) == int32(TK_CURRENT) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), regCRowid, lblNext, regRowid) + } else { + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeExclude) != int32(TK_NO) { + addrEq = 0 + pKeyInfo = uintptr(0) + if (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy != 0 { + pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy, 0, 0) + } + if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pMWin)).FeExclude) == int32(TK_TIES) { + addrEq = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), regCRowid, 0, regRowid) + } + if pKeyInfo != 0 { + _windowReadPeerValues(tls, p, csr, regPeer) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Compare), regPeer, regCPeer, nPeer) + _sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9)) + addr = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), addr, lblNext, addr) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, lblNext) + } + if addrEq != 0 { + _sqlite3VdbeJumpHere(tls, v, addrEq) + } + } + } + _windowAggStep(tls, p, pMWin, csr, 0, (*TWindowCodeArg)(unsafe.Pointer(p)).FregArg) + _sqlite3VdbeResolveLabel(tls, v, lblNext) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), csr, addrNext) + _sqlite3VdbeJumpHere(tls, v, addrNext-int32(1)) + _sqlite3VdbeJumpHere(tls, v, addrNext+int32(1)) + _sqlite3ReleaseTempReg(tls, pParse, regRowid) + _sqlite3ReleaseTempReg(tls, pParse, regCRowid) + if nPeer != 0 { + _sqlite3ReleaseTempRange(tls, pParse, regPeer, nPeer) + _sqlite3ReleaseTempRange(tls, pParse, regCPeer, nPeer) + } + _windowAggFinal(tls, p, int32(1)) +} + +// C documentation +// +// /* +// ** Functions to serialize a 16 bit integer, 32 bit real number and +// ** 64 bit integer. The value returned is the number of bytes written +// ** to the argument buffer (always 2, 4 and 8 respectively). +// */ +func _writeInt16(tls *libc.TLS, p uintptr, i int32) { + **(**Tu8)(__ccgo_up(p)) = libc.Uint8FromInt32(i >> int32(8) & int32(0xFF)) + **(**Tu8)(__ccgo_up(p + 1)) = libc.Uint8FromInt32(i >> 0 & int32(0xFF)) +} + +// C documentation +// +// /* The following function deletes the "minor type" or semantic value +// ** associated with a symbol. The symbol can be either a terminal +// ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is +// ** a pointer to the value to be deleted. The code used to do the +// ** deletions is derived from the %destructor and/or %token_destructor +// ** directives of the input grammar. +// */ +func _yy_destructor(tls *libc.TLS, yypParser uintptr, yymajor uint16, yypminor uintptr) { + var pParse uintptr + _ = pParse + pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse + switch libc.Int32FromUint16(yymajor) { + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are *not* used + ** inside the C code. + */ + /********* Begin destructor definitions ***************************************/ + case int32(206): /* select */ + fallthrough + case int32(241): /* selectnowith */ + fallthrough + case int32(242): /* oneselect */ + fallthrough + case int32(254): /* values */ + fallthrough + case int32(256): /* mvalues */ + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(218): /* term */ + fallthrough + case int32(219): /* expr */ + fallthrough + case int32(248): /* where_opt */ + fallthrough + case int32(250): /* having_opt */ + fallthrough + case int32(270): /* where_opt_ret */ + fallthrough + case int32(281): /* case_operand */ + fallthrough + case int32(283): /* case_else */ + fallthrough + case int32(286): /* vinto */ + fallthrough + case int32(293): /* when_clause */ + fallthrough + case int32(297): /* key_opt */ + fallthrough + case int32(314): /* filter_clause */ + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(223): /* eidlist_opt */ + fallthrough + case int32(233): /* sortlist */ + fallthrough + case int32(234): /* eidlist */ + fallthrough + case int32(246): /* selcollist */ + fallthrough + case int32(249): /* groupby_opt */ + fallthrough + case int32(251): /* orderby_opt */ + fallthrough + case int32(255): /* nexprlist */ + fallthrough + case int32(257): /* sclp */ + fallthrough + case int32(264): /* exprlist */ + fallthrough + case int32(271): /* setlist */ + fallthrough + case int32(280): /* paren_exprlist */ + fallthrough + case int32(282): /* case_exprlist */ + fallthrough + case int32(313): /* part_opt */ + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(240): /* fullname */ + fallthrough + case int32(247): /* from */ + fallthrough + case int32(259): /* seltablist */ + fallthrough + case int32(260): /* stl_prefix */ + fallthrough + case int32(265): /* xfullname */ + _sqlite3SrcListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(243): /* wqlist */ + _sqlite3WithDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(253): /* window_clause */ + fallthrough + case int32(309): /* windowdefn_list */ + _sqlite3WindowListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(266): /* idlist */ + fallthrough + case int32(273): /* idlist_opt */ + _sqlite3IdListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(276): /* filter_over */ + fallthrough + case int32(310): /* windowdefn */ + fallthrough + case int32(311): /* window */ + fallthrough + case int32(312): /* frame_opt */ + fallthrough + case int32(315): /* over_clause */ + _sqlite3WindowDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(289): /* trigger_cmd_list */ + fallthrough + case int32(294): /* trigger_cmd */ + _sqlite3DeleteTriggerStep(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor))) + case int32(291): /* trigger_event */ + _sqlite3IdListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*(*TTrigEvent)(unsafe.Pointer(yypminor))).Fb) + case int32(317): /* frame_bound */ + fallthrough + case int32(318): /* frame_bound_s */ + fallthrough + case int32(319): /* frame_bound_e */ + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*(*TFrameBound)(unsafe.Pointer(yypminor))).FpExpr) + break + /********* End destructor definitions *****************************************/ + fallthrough + default: + break /* If no destructor action specified: do nothing */ + } +} + +// C documentation +// +// /* +// ** Find the appropriate action for a parser given the non-terminal +// ** look-ahead token iLookAhead. +// */ +func _yy_find_reduce_action(tls *libc.TLS, stateno uint16, iLookAhead uint16) (r uint16) { + var i int32 + _ = i + i = int32(_yy_reduce_ofst[stateno]) + i = i + libc.Int32FromUint16(iLookAhead) + return _yy_action[i] +} + +// C documentation +// +// /* +// ** Find the appropriate action for a parser given the terminal +// ** look-ahead token iLookAhead. +// */ +func _yy_find_shift_action(tls *libc.TLS, iLookAhead uint16, stateno uint16) (r uint16) { + var i, j int32 + var iFallback uint16 + _, _, _ = i, iFallback, j + if libc.Int32FromUint16(stateno) > int32(YY_MAX_SHIFT) { + return stateno + } + for cond := true; cond; cond = int32(1) != 0 { + i = libc.Int32FromUint16(_yy_shift_ofst[stateno]) + i = i + libc.Int32FromUint16(iLookAhead) + if libc.Int32FromUint16(_yy_lookahead[i]) != libc.Int32FromUint16(iLookAhead) { /* Fallback token */ + iFallback = _yyFallback[iLookAhead] + if libc.Int32FromUint16(iFallback) != 0 { + /* Fallback loop must terminate */ + iLookAhead = iFallback + continue + } + j = i - libc.Int32FromUint16(iLookAhead) + int32(YYWILDCARD) + if libc.Int32FromUint16(_yy_lookahead[j]) == int32(YYWILDCARD) && libc.Int32FromUint16(iLookAhead) > 0 { + return _yy_action[j] + } + return _yy_default[stateno] + } else { + return _yy_action[i] + } + } + return r +} + +// C documentation +// +// /* +// ** The journal file must be open when this function is called. +// ** +// ** This function is a no-op if the journal file has not been written to +// ** within the current transaction (i.e. if Pager.journalOff==0). +// ** +// ** If doTruncate is non-zero or the Pager.journalSizeLimit variable is +// ** set to 0, then truncate the journal file to zero bytes in size. Otherwise, +// ** zero the 28-byte header at the start of the journal file. In either case, +// ** if the pager is not in no-sync mode, sync the journal file immediately +// ** after writing or truncating it. +// ** +// ** If Pager.journalSizeLimit is set to a positive, non-zero value, and +// ** following the truncation or zeroing described above the size of the +// ** journal file in bytes is larger than this value, then truncate the +// ** journal file to Pager.journalSizeLimit bytes. The journal file does +// ** not need to be synced following this operation. +// ** +// ** If an IO error occurs, abandon processing and return the IO error code. +// ** Otherwise, return SQLITE_OK. +// */ +func _zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iLimit Ti64 + var rc int32 + var _ /* sz at bp+0 */ Ti64 + _, _ = iLimit, rc + rc = SQLITE_OK /* Return code */ + if (*TPager)(unsafe.Pointer(pPager)).FjournalOff != 0 { + iLimit = (*TPager)(unsafe.Pointer(pPager)).FjournalSizeLimit /* Local cache of jsl */ + if doTruncate != 0 || iLimit == 0 { + rc = _sqlite3OsTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, 0) + } else { + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&_zeroHdr)), int32(28), 0) + } + if rc == SQLITE_OK && !((*TPager)(unsafe.Pointer(pPager)).FnoSync != 0) { + rc = _sqlite3OsSync(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, int32(SQLITE_SYNC_DATAONLY)|libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FsyncFlags)) + } + /* At this point the transaction is committed but the write lock + ** is still held on the file. If there is a size limit configured for + ** the persistent journal and the journal file currently consumes more + ** space than that limit allows for, truncate it now. There is no need + ** to sync the file following this operation. + */ + if rc == SQLITE_OK && iLimit > 0 { + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp) + if rc == SQLITE_OK && **(**Ti64)(__ccgo_up(bp)) > iLimit { + rc = _sqlite3OsTruncate(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iLimit) + } + } + } + return rc +} + +// C documentation +// +// /* +// ** The zeroblob(N) function returns a zero-filled blob of size N bytes. +// */ +func _zeroblobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var n Ti64 + var rc int32 + _, _ = n, rc + _ = argc + n = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + if n < 0 { + n = 0 + } + rc = Xsqlite3_result_zeroblob64(tls, context, libc.Uint64FromInt64(n)) /* IMP: R-00293-64994 */ + if rc != 0 { + Xsqlite3_result_error_code(tls, context, rc) + } +} + +type blkcnt_t = Tblkcnt_t + +type blksize_t = Tblksize_t + +type clockid_t = Tclockid_t + +type double_t = Tdouble_t + +const fdatasync = 0 + +type finder_type = Tfinder_type + +/**************************************************************************** +**************************** sqlite3_vfs methods **************************** +** +** This division contains the implementation of methods on the +** sqlite3_vfs object. + */ + +type flock = Tflock + +type id_t = Tid_t + +func init() { + p := unsafe.Pointer(&_nolockIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_nolockIoFinderImpl) +} + +func init() { + p := unsafe.Pointer(&_posixIoFinder) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_posixIoFinderImpl) +} + +type itimerval = Titimerval + +type key_t = Tkey_t + +type nlink_t = Tnlink_t + +type quad_t = Tquad_t + +type sigset_t = Tsigset_t + +type stat = Tstat + +const static_assert = 0 + +type suseconds_t = Tsuseconds_t + +const threadid = 0 + +type u_int16_t = Tu_int16_t + +type u_int32_t = Tu_int32_t + +type u_int64_t = Tu_int64_t + +type u_int8_t = Tu_int8_t + +type u_quad_t = Tu_quad_t + +type uint = Tuint + +type unixFile = TunixFile + +type unixFileId = TunixFileId + +type unixInodeInfo = TunixInodeInfo + +type unixShm = TunixShm + +type unixShmNode = TunixShmNode + +type unix_syscall = Tunix_syscall + +type ushort = Tushort + +type vxworksFileId = TvxworksFileId + +/*************** End of Unique File ID Utility Used By VxWorks **************** +******************************************************************************/ + +/****************************************************************************** +*************************** Posix Advisory Locking **************************** +** +** POSIX advisory locks are broken by design. ANSI STD 1003.1 (1996) +** section 6.5.2.2 lines 483 through 490 specify that when a process +** sets or clears a lock, that operation overrides any prior locks set +** by the same process. It does not explicitly say so, but this implies +** that it overrides locks set by the same process using a different +** file descriptor. Consider this test case: +** +** int fd1 = open("./file1", O_RDWR|O_CREAT, 0644); +** int fd2 = open("./file2", O_RDWR|O_CREAT, 0644); +** +** Suppose ./file1 and ./file2 are really the same file (because +** one is a hard or symbolic link to the other) then if you set +** an exclusive lock on fd1, then try to get an exclusive lock +** on fd2, it works. I would have expected the second lock to +** fail since there was already a lock on the file due to fd1. +** But not so. Since both locks came from the same process, the +** second overrides the first, even though they were on different +** file descriptors opened on different file names. +** +** This means that we cannot use POSIX locks to synchronize file access +** among competing threads of the same process. POSIX locks will work fine +** to synchronize access for threads in separate processes, but not +** threads within the same process. +** +** To work around the problem, SQLite has to manage file locks internally +** on its own. Whenever a new database is opened, we have to find the +** specific inode of the database file (the inode is determined by the +** st_dev and st_ino fields of the stat structure that fstat() fills in) +** and check for locks already existing on that inode. When locks are +** created or removed, we have to look at our own internal record of the +** locks to see if another thread has previously set a lock on that same +** inode. +** +** (Aside: The use of inode numbers as unique IDs does not work on VxWorks. +** For VxWorks, we have to use the alternative unique ID system based on +** canonical filename and implemented in the previous division.) +** +** The sqlite3_file structure for POSIX is no longer just an integer file +** descriptor. It is now a structure that holds the integer file +** descriptor and a pointer to a structure that describes the internal +** locks on the corresponding inode. There is one locking structure +** per inode, so if the same inode is opened twice, both unixFile structures +** point to the same locking structure. The locking structure keeps +** a reference count (so we will know when to delete it) and a "cnt" +** field that tells us its internal lock status. cnt==0 means the +** file is unlocked. cnt==-1 means the file has an exclusive lock. +** cnt>0 means there are cnt shared locks on the file. +** +** Any attempt to lock or unlock a file first checks the locking +** structure. The fcntl() system call is only invoked to set a +** POSIX lock if the internal lock structure transitions between +** a locked and an unlocked state. +** +** But wait: there are yet more problems with POSIX advisory locks. +** +** If you close a file descriptor that points to a file that has locks, +** all locks on that file that are owned by the current process are +** released. To work around this problem, each unixInodeInfo object +** maintains a count of the number of pending locks on the inode. +** When an attempt is made to close an unixFile, if there are +** other unixFile open on the same inode that are holding locks, the call +** to close() the file descriptor is deferred until all of the locks clear. +** The unixInodeInfo structure keeps a list of file descriptors that need to +** be closed and that list is walked (and cleared) when the last lock +** clears. +** +** Yet another problem: LinuxThreads do not play well with posix locks. +** +** Many older versions of linux use the LinuxThreads library which is +** not posix compliant. Under LinuxThreads, a lock created by thread +** A cannot be modified or overridden by a different thread B. +** Only thread A can modify the lock. Locking behavior is correct +** if the application uses the newer Native Posix Thread Library (NPTL) +** on linux - with NPTL a lock created by thread A can override locks +** in thread B. But there is no way to know at compile-time which +** threading library is being used. So there is no way to know at +** compile-time whether or not thread A can override locks on thread B. +** One has to do a run-time check to discover the behavior of the +** current process. +** +** SQLite used to support LinuxThreads. But support for LinuxThreads +** was dropped beginning with version 3.7.0. SQLite will still work with +** LinuxThreads provided that (1) there is no more than one connection +** per database file in the same process and (2) database connections +** do not move across threads. + */ + +type winsize = Twinsize diff --git a/internal/engine/lib/sqlite_g_000000000002002b.go b/internal/engine/lib/sqlite_g_000000000002002b.go new file mode 100644 index 0000000..7eee801 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000002002b.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) || (windows && (amd64 || arm64)) + +package sqlite3 + +type Trsize_t = uint64 diff --git a/internal/engine/lib/sqlite_g_0000000000023eab.go b/internal/engine/lib/sqlite_g_0000000000023eab.go new file mode 100644 index 0000000..4d32649 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000023eab.go @@ -0,0 +1,40 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (windows && (amd64 || arm64)) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** The first argument is a file-handle open on a temporary file. The file +// ** is guaranteed to be nByte bytes or smaller in size. This function +// ** attempts to extend the file to nByte bytes in size and to ensure that +// ** the VFS has memory mapped it. +// ** +// ** Whether or not the file does end up memory mapped of course depends on +// ** the specific VFS implementation. +// */ +func _vdbeSorterExtendFile(tls *libc.TLS, db uintptr, pFd uintptr, _nByte Ti64) { + bp := tls.Alloc(32) + defer tls.Free(32) + *(*Ti64)(unsafe.Pointer(bp)) = _nByte + var _ /* chunksize at bp+16 */ int32 + var _ /* p at bp+8 */ uintptr + if **(**Ti64)(__ccgo_up(bp)) <= int64((*Tsqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap) && (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= int32(3) { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 16)) = libc.Int32FromInt32(4) * libc.Int32FromInt32(1024) + _sqlite3OsFileControlHint(tls, pFd, int32(SQLITE_FCNTL_CHUNK_SIZE), bp+16) + _sqlite3OsFileControlHint(tls, pFd, int32(SQLITE_FCNTL_SIZE_HINT), bp) + _sqlite3OsFetch(tls, pFd, 0, int32(**(**Ti64)(__ccgo_up(bp))), bp+8) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _sqlite3OsUnfetch(tls, pFd, 0, **(**uintptr)(__ccgo_up(bp + 8))) + } + } +} diff --git a/internal/engine/lib/sqlite_g_0000000000024080.go b/internal/engine/lib/sqlite_g_0000000000024080.go new file mode 100644 index 0000000..ead6c38 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000024080.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && amd64) || (netbsd && amd64) || (windows && (amd64 || arm64)) + +package sqlite3 + +const __SIZEOF_FLOAT80__ = 16 diff --git a/internal/engine/lib/sqlite_g_000000000002c088.go b/internal/engine/lib/sqlite_g_000000000002c088.go new file mode 100644 index 0000000..5c4a260 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000002c088.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (linux && amd64) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) + +package sqlite3 + +const __k8 = 1 + +const __k8__ = 1 diff --git a/internal/engine/lib/sqlite_g_000000000002c089.go b/internal/engine/lib/sqlite_g_000000000002c089.go new file mode 100644 index 0000000..3015062 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000002c089.go @@ -0,0 +1,15 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && amd64) || (linux && amd64) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) + +package sqlite3 + +const __FXSR__ = 1 + +const __amd64 = 1 + +const __amd64__ = 1 + +const __x86_64 = 1 + +const __x86_64__ = 1 diff --git a/internal/engine/lib/sqlite_g_000000000002c488.go b/internal/engine/lib/sqlite_g_000000000002c488.go new file mode 100644 index 0000000..190603d --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000002c488.go @@ -0,0 +1,307 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (linux && amd64) || (linux && loong64) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Generate code for the RETURNING trigger. Unlike other triggers +// ** that invoke a subprogram in the bytecode, the code for RETURNING +// ** is generated in-line. +// */ +func _codeReturningTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintptr, regIn int32) { + bp := tls.Alloc(272) + defer tls.Free(272) + var db, pCol, pFrom, pNew, pReturning, v, v2 uintptr + var i, nCol, reg, v1 int32 + var _ /* sNC at bp+208 */ TNameContext + var _ /* sSelect at bp+0 */ TSelect + var _ /* uSrc at bp+120 */ struct { + FfromSpace [0][88]Tu8 + FsSrc TSrcList + F__ccgo_pad2 [80]byte + } + _, _, _, _, _, _, _, _, _, _, _ = db, i, nCol, pCol, pFrom, pNew, pReturning, reg, v, v1, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if !(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0) { + /* This RETURNING trigger must be for a different statement as + ** this statement lacks a RETURNING clause. */ + return + } + pReturning = (*(*struct { + FpReturning uintptr + })(unsafe.Pointer(&(*TParse)(unsafe.Pointer(pParse)).Fu1))).FpReturning + if pTrigger != pReturning+16 { + /* This RETURNING trigger is for a different statement */ + return + } + libc.Xmemset(tls, bp, 0, uint64(120)) + libc.Xmemset(tls, bp+120, 0, uint64(88)) + pFrom = bp + 120 + (**(**TSelect)(__ccgo_up(bp))).FpEList = _sqlite3ExprListDup(tls, db, (*TReturning)(unsafe.Pointer(pReturning)).FpReturnEL, 0) + (**(**TSelect)(__ccgo_up(bp))).FpSrc = pFrom + (*TSrcList)(unsafe.Pointer(pFrom)).FnSrc = int32(1) + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FpSTab = pTab + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FzName = (*TTable)(unsafe.Pointer(pTab)).FzName /* tag-20240424-1 */ + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FiCursor = -int32(1) + _sqlite3SelectPrep(tls, pParse, bp, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + _sqlite3GenerateColumnNames(tls, pParse, bp) + } + _sqlite3ExprListDelete(tls, db, (**(**TSelect)(__ccgo_up(bp))).FpEList) + pNew = _sqlite3ExpandReturning(tls, pParse, (*TReturning)(unsafe.Pointer(pReturning)).FpReturnEL, pTab) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + libc.Xmemset(tls, bp+208, 0, uint64(56)) + if (*TReturning)(unsafe.Pointer(pReturning)).FnRetCol == 0 { + (*TReturning)(unsafe.Pointer(pReturning)).FnRetCol = (*TExprList)(unsafe.Pointer(pNew)).FnExpr + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur = v1 + } + (**(**TNameContext)(__ccgo_up(bp + 208))).FpParse = pParse + *(*int32)(unsafe.Pointer(bp + 208 + 16)) = regIn + (**(**TNameContext)(__ccgo_up(bp + 208))).FncFlags = int32(NC_UBaseReg) + (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = (*TTrigger)(unsafe.Pointer(pTrigger)).Fop + (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = pTab + if _sqlite3ResolveExprListNames(tls, bp+208, pNew) == SQLITE_OK && !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + nCol = (*TExprList)(unsafe.Pointer(pNew)).FnExpr + reg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + _sqlite3ProcessReturningSubqueries(tls, pNew, pTab) + **(**int32)(__ccgo_up(pParse + 60)) += nCol + int32(2) + (*TReturning)(unsafe.Pointer(pReturning)).FiRetReg = reg + i = 0 + for { + if !(i < nCol) { + break + } + pCol = (*(*TExprList_item)(unsafe.Pointer(pNew + 8 + uintptr(i)*32))).FpExpr + /* Due to !db->mallocFailed ~9 lines above */ + _sqlite3ExprCodeFactorable(tls, pParse, pCol, reg+i) + if int32(_sqlite3ExprAffinity(tls, pCol)) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), reg+i) + } + goto _3 + _3: + ; + i = i + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), reg, i, reg+i) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur, reg+i+int32(1)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), (*TReturning)(unsafe.Pointer(pReturning)).FiRetCur, reg+i, reg+i+int32(1)) + } + } + _sqlite3ExprListDelete(tls, db, pNew) + (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = uint8(0) + (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = uintptr(0) +} + +// C documentation +// +// /* +// ** Process time function arguments. argv[0] is a date-time stamp. +// ** argv[1] and following are modifiers. Parse them all and write +// ** the resulting time into the DateTime structure p. Return 0 +// ** on success and 1 if there are any errors. +// ** +// ** If there are zero parameters (if even argv[0] is undefined) +// ** then assume a default value of "now" for argv[0]. +// */ +func _isDate(tls *libc.TLS, context uintptr, argc int32, argv uintptr, p uintptr) (r int32) { + var eType, i, n, v1 int32 + var z uintptr + _, _, _, _, _ = eType, i, n, z, v1 + libc.Xmemset(tls, p, 0, uint64(48)) + if argc == 0 { + if !(_sqlite3NotPureFunc(tls, context) != 0) { + return int32(1) + } + return _setDateTimeToCurrent(tls, context, p) + } + v1 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) + eType = v1 + if v1 == int32(SQLITE_FLOAT) || eType == int32(SQLITE_INTEGER) { + _setRawDateNumber(tls, p, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))) + } else { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if !(z != 0) || _parseDateOrTime(tls, context, z, p) != 0 { + return int32(1) + } + } + i = int32(1) + for { + if !(i < argc) { + break + } + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + n = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if z == uintptr(0) || _parseModifier(tls, context, z, n, p, i) != 0 { + return int32(1) + } + goto _2 + _2: + ; + i = i + 1 + } + _computeJD(tls, p) + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x2>>1)) != 0 || !(_validJulianDay(tls, (*TDateTime)(unsafe.Pointer(p)).FiJD) != 0) { + return int32(1) + } + if argc == int32(1) && (*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0 && (*TDateTime)(unsafe.Pointer(p)).FD > int32(28) { + /* Make sure a YYYY-MM-DD is normalized. + ** Example: 2023-02-31 -> 2023-03-03 */ + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = 0 + } + return 0 +} + +/* +** The following routines implement the various date and time functions +** of SQLite. + */ + +// C documentation +// +// /* +// ** This method works for both json_group_array() and json_group_object(). +// ** It works by removing the first element of the group by searching forward +// ** to the first comma (",") that is not within a string and deleting all +// ** text through that comma. +// */ +func _jsonGroupInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var c, v2 int8 + var i uint32 + var inStr, nNest int32 + var pStr, z uintptr + var v3 bool + _, _, _, _, _, _, _, _ = c, i, inStr, nNest, pStr, z, v2, v3 + inStr = 0 + nNest = 0 + _ = argc + _ = argv + pStr = Xsqlite3_aggregate_context(tls, ctx, 0) + /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will + ** always have been called to initialize it */ + if !(pStr != 0) { + return + } + z = (*TJsonString)(unsafe.Pointer(pStr)).FzBuf + i = uint32(1) + for { + if v3 = uint64(i) < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed; v3 { + v2 = **(**int8)(__ccgo_up(z + uintptr(i))) + c = v2 + } + if !(v3 && (int32(v2) != int32(',') || inStr != 0 || nNest != 0)) { + break + } + if int32(c) == int32('"') { + inStr = libc.BoolInt32(!(inStr != 0)) + } else { + if int32(c) == int32('\\') { + i = i + 1 + } else { + if !(inStr != 0) { + if int32(c) == int32('{') || int32(c) == int32('[') { + nNest = nNest + 1 + } + if int32(c) == int32('}') || int32(c) == int32(']') { + nNest = nNest - 1 + } + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + if uint64(i) < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed { + **(**Tu64)(__ccgo_up(pStr + 24)) -= uint64(i) + libc.Xmemmove(tls, z+1, z+uintptr(i+uint32(1)), (*TJsonString)(unsafe.Pointer(pStr)).FnUsed-uint64(1)) + **(**int8)(__ccgo_up(z + uintptr((*TJsonString)(unsafe.Pointer(pStr)).FnUsed))) = 0 + } else { + (*TJsonString)(unsafe.Pointer(pStr)).FnUsed = uint64(1) + } +} + +func _sqlite3DbStrNDup(tls *libc.TLS, db uintptr, z uintptr, n Tu64) (r uintptr) { + var zNew, v1 uintptr + _, _ = zNew, v1 + if z != 0 { + v1 = _sqlite3DbMallocRawNN(tls, db, n+uint64(1)) + } else { + v1 = uintptr(0) + } + zNew = v1 + if zNew != 0 { + libc.Xmemcpy(tls, zNew, z, n) + **(**int8)(__ccgo_up(zNew + uintptr(n))) = 0 + } + return zNew +} + +// C documentation +// +// /* +// ** Run the parser and code generator recursively in order to generate +// ** code for the SQL statement given onto the end of the pParse context +// ** currently under construction. Notes: +// ** +// ** * The final OP_Halt is not appended and other initialization +// ** and finalization steps are omitted because those are handling by the +// ** outermost parser. +// ** +// ** * Built-in SQL functions always take precedence over application-defined +// ** SQL functions. In other words, it is not possible to override a +// ** built-in function. +// */ +func _sqlite3NestedParse(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var ap Tva_list + var db, zSql uintptr + var savedDbFlags Tu32 + var _ /* saveBuf at bp+0 */ [136]int8 + _, _, _, _ = ap, db, savedDbFlags, zSql + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + savedDbFlags = (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + if (*TParse)(unsafe.Pointer(pParse)).FeParseMode != 0 { + return + } + /* Nesting should only be of limited depth */ + ap = va + zSql = _sqlite3VMPrintf(tls, db, zFormat, ap) + _ = ap + if zSql == uintptr(0) { + /* This can result either from an OOM or because the formatted string + ** exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set + ** an error */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_TOOBIG) + } + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + return + } + (*TParse)(unsafe.Pointer(pParse)).Fnested = (*TParse)(unsafe.Pointer(pParse)).Fnested + 1 + libc.Xmemcpy(tls, bp, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + libc.Xmemset(tls, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), 0, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_PreferBuiltin) + _sqlite3RunParser(tls, pParse, zSql) + (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags = savedDbFlags + _sqlite3DbFree(tls, db, zSql) + libc.Xmemcpy(tls, pParse+uintptr(uint64(libc.UintptrFromInt32(0)+280)), bp, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + (*TParse)(unsafe.Pointer(pParse)).Fnested = (*TParse)(unsafe.Pointer(pParse)).Fnested - 1 +} diff --git a/internal/engine/lib/sqlite_g_000000000002c48b.go b/internal/engine/lib/sqlite_g_000000000002c48b.go new file mode 100644 index 0000000..e181312 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000002c48b.go @@ -0,0 +1,835 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (linux && amd64) || (linux && loong64) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type TColumn = struct { + FzCnName uintptr + F__ccgo8 uint8 + Faffinity int8 + FszEst Tu8 + FhName Tu8 + FiDflt Tu16 + FcolFlags Tu16 +} + +type TExpr = struct { + Fop Tu8 + FaffExpr int8 + Fop2 Tu8 + Fflags Tu32 + Fu struct { + FiValue [0]int32 + FzToken uintptr + } + FpLeft uintptr + FpRight uintptr + Fx struct { + FpSelect [0]uintptr + FpList uintptr + } + FnHeight int32 + FiTable int32 + FiColumn TynVar + FiAgg Ti16 + Fw struct { + FiOfst [0]int32 + FiJoin int32 + } + FpAggInfo uintptr + Fy struct { + FpWin [0]uintptr + FnReg [0]int32 + Fsub [0]struct { + FiAddr int32 + FregReturn int32 + } + FpTab uintptr + } +} + +// C documentation +// +// /* +// ** Return the sqlite3_file for the main database given the name +// ** of the corresponding WAL or Journal name as passed into +// ** xOpen. +// */ +func Xsqlite3_database_file_object(tls *libc.TLS, zName uintptr) (r uintptr) { + var p, pPager uintptr + _, _ = p, pPager + for int32(**(**int8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(1))))) != 0 || int32(**(**int8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(2))))) != 0 || int32(**(**int8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(3))))) != 0 || int32(**(**int8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(4))))) != 0 { + zName = zName - 1 + } + p = zName - uintptr(4) - uintptr(8) + pPager = **(**uintptr)(__ccgo_up(p)) + return (*TPager)(unsafe.Pointer(pPager)).Ffd +} + +// C documentation +// +// /* +// ** Print into memory obtained from sqlite3_malloc(). Omit the internal +// ** %-conversion extensions. +// */ +func Xsqlite3_vmprintf(tls *libc.TLS, zFormat uintptr, ap Tva_list) (r uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var z uintptr + var _ /* acc at bp+72 */ TStrAccum + var _ /* zBase at bp+0 */ [70]int8 + _ = z + if Xsqlite3_initialize(tls) != 0 { + return uintptr(0) + } + _sqlite3StrAccumInit(tls, bp+72, uintptr(0), bp, int32(70), int32(SQLITE_MAX_LENGTH)) + Xsqlite3_str_vappendf(tls, bp+72, zFormat, ap) + z = _sqlite3StrAccumFinish(tls, bp+72) + return z +} + +// C documentation +// +// /* +// ** pExpr is a comparison operator. Return the type affinity that should +// ** be applied to both operands prior to doing the comparison. +// */ +func _comparisonAffinity(tls *libc.TLS, pExpr uintptr) (r int8) { + var aff int8 + _ = aff + aff = _sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if (*TExpr)(unsafe.Pointer(pExpr)).FpRight != 0 { + aff = _sqlite3CompareAffinity(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, aff) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + aff = _sqlite3CompareAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList + 8))).FpExpr, aff) + } else { + if int32(aff) == 0 { + aff = int8(SQLITE_AFF_BLOB) + } + } + } + return aff +} + +// C documentation +// +// /* +// ** Return true if any of the result-set columns in the compound query +// ** have incompatible affinities on one or more arms of the compound. +// */ +func _compoundHasDifferentAffinities(tls *libc.TLS, p uintptr) (r int32) { + var aff int8 + var ii int32 + var pList, pSub1 uintptr + _, _, _, _ = aff, ii, pList, pSub1 + pList = (*TSelect)(unsafe.Pointer(p)).FpEList + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + aff = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ii)*32))).FpExpr) + pSub1 = (*TSelect)(unsafe.Pointer(p)).FpPrior + for { + if !(pSub1 != 0) { + break + } + if int32(_sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSub1)).FpEList + 8 + uintptr(ii)*32))).FpExpr)) != int32(aff) { + return int32(1) + } + goto _2 + _2: + ; + pSub1 = (*TSelect)(unsafe.Pointer(pSub1)).FpPrior + } + goto _1 + _1: + ; + ii = ii + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Return true if all expressions in the expression-list passed as the +// ** only argument are both constant and have no affinity. +// */ +func _exprListIsNoAffinity(tls *libc.TLS, pParse uintptr, pRow uintptr) (r int32) { + var ii int32 + var pExpr uintptr + _, _ = ii, pExpr + if _exprListIsConstant(tls, pParse, pRow) == 0 { + return 0 + } + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pRow)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pRow + 8 + uintptr(ii)*32))).FpExpr + if 0 != int32(_sqlite3ExprAffinity(tls, pExpr)) { + return 0 + } + goto _1 + _1: + ; + ii = ii + 1 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Return an Expr object that refers to a memory register corresponding +// ** to column iCol of table pTab. +// ** +// ** regBase is the first of an array of register that contains the data +// ** for pTab. regBase itself holds the rowid. regBase+1 holds the first +// ** column. regBase+2 holds the second column, and so forth. +// */ +func _exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int32, iCol Ti16) (r uintptr) { + var db, pCol, pExpr, zColl uintptr + _, _, _, _ = db, pCol, pExpr, zColl + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pExpr = _sqlite3Expr(tls, db, int32(TK_REGISTER), uintptr(0)) + if pExpr != 0 { + if int32(iCol) >= 0 && int32(iCol) != int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = regBase + int32(_sqlite3TableColumnToStorage(tls, pTab, iCol)) + int32(1) + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = (*TColumn)(unsafe.Pointer(pCol)).Faffinity + zColl = _sqlite3ColumnColl(tls, pCol) + if zColl == uintptr(0) { + zColl = (*TCollSeq)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl)).FzName + } + pExpr = _sqlite3ExprAddCollateString(tls, pParse, pExpr, zColl) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = regBase + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_INTEGER) + } + } + return pExpr +} + +func _jsonAppendChar(tls *libc.TLS, p uintptr, c int8) { + var v1 Tu64 + var v2 uintptr + _, _ = v1, v2 + if (*TJsonString)(unsafe.Pointer(p)).FnUsed >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc { + _jsonAppendCharExpand(tls, p, c) + } else { + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = c + } +} + +// C documentation +// +// /* Append a single character +// */ +func _jsonAppendCharExpand(tls *libc.TLS, p uintptr, c int8) { + var v1 Tu64 + var v2 uintptr + _, _ = v1, v2 + if _jsonStringGrow(tls, p, uint32(1)) != 0 { + return + } + v2 = p + 24 + v1 = *(*Tu64)(unsafe.Pointer(v2)) + *(*Tu64)(unsafe.Pointer(v2)) = *(*Tu64)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr(v1))) = c +} + +// C documentation +// +// /* +// ** Implementation of the json_array(VALUE,...) function. Return a JSON +// ** array that contains all values given in arguments. Or if any argument +// ** is a BLOB, throw an error. +// */ +func _jsonArrayFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var i int32 + var _ /* jx at bp+0 */ TJsonString + _ = i + _jsonStringInit(tls, bp, ctx) + _jsonAppendChar(tls, bp, int8('[')) + i = 0 + for { + if !(i < argc) { + break + } + _jsonAppendSeparator(tls, bp) + _jsonAppendSqlValue(tls, bp, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + _jsonAppendChar(tls, bp, int8(']')) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /**************************************************************************** +// ** Aggregate SQL function implementations +// ****************************************************************************/ +// /* +// ** json_group_array(VALUE) +// ** +// ** Return a JSON array composed of all values in the aggregate. +// */ +func _jsonArrayStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var pStr uintptr + _ = pStr + _ = argc + pStr = Xsqlite3_aggregate_context(tls, ctx, int32(136)) + if pStr != 0 { + if (*TJsonString)(unsafe.Pointer(pStr)).FzBuf == uintptr(0) { + _jsonStringInit(tls, pStr, ctx) + _jsonAppendChar(tls, pStr, int8('[')) + } else { + if (*TJsonString)(unsafe.Pointer(pStr)).FnUsed > uint64(1) { + _jsonAppendChar(tls, pStr, int8(',')) + } + } + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + _jsonAppendSqlValue(tls, pStr, **(**uintptr)(__ccgo_up(argv))) + } +} + +// C documentation +// +// /* +// ** This function does the work for an sqlite3rbu_step() call. +// ** +// ** The object-iterator (p->objiter) currently points to a valid object, +// ** and the input cursor (p->objiter.pSelect) currently points to a valid +// ** input row. Perform whatever processing is required and return. +// ** +// ** If no error occurs, SQLITE_OK is returned. Otherwise, an error code +// ** and message is left in the RBU handle and a copy of the error code +// ** returned. +// */ +func _rbuStep(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c int8 + var eType, i int32 + var pIter, pVal uintptr + var _ /* pUpdate at bp+8 */ uintptr + var _ /* zMask at bp+0 */ uintptr + _, _, _, _, _ = c, eType, i, pIter, pVal + pIter = p + 88 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + eType = _rbuStepType(tls, p, bp) + if eType != 0 { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) && (eType == int32(RBU_IDX_DELETE) || eType == int32(RBU_IDX_INSERT)) { + _rbuBadControlError(tls, p) + } else { + if eType == int32(RBU_REPLACE) { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { + **(**Ti64)(__ccgo_up(p + 312)) += int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex) + _rbuStepOneOp(tls, p, int32(RBU_DELETE)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _rbuStepOneOp(tls, p, int32(RBU_INSERT)) + } + } else { + if eType != int32(RBU_UPDATE) { + _rbuStepOneOp(tls, p, eType) + } else { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**Ti64)(__ccgo_up(p + 312)) -= int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex) + _rbuGetUpdateStmt(tls, p, pIter, **(**uintptr)(__ccgo_up(bp)), bp+8) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + i = 0 + for { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol) { + break + } + c = **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(**(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4))))) + pVal = Xsqlite3_column_value(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) + if **(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 || int32(c) != int32('.') { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), i+int32(1), pVal) + } + goto _1 + _1: + ; + i = i + 1 + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && ((*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_VTAB) || (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_NONE)) { + /* Bind the rbu_rowid value to column _rowid_ */ + pVal = Xsqlite3_column_value(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect, (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol+int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp + 8)), (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol+int32(1), pVal) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _resetAndCollectError(tls, **(**uintptr)(__ccgo_up(bp + 8)), p+64) + } + } + } + } + } + } + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** This is the routine that actually formats the sqlite3_log() message. +// ** We house it in a separate routine from sqlite3_log() to avoid using +// ** stack space on small-stack systems when logging is disabled. +// ** +// ** sqlite3_log() must render into a static buffer. It cannot dynamically +// ** allocate memory because it might be called while the memory allocator +// ** mutex is held. +// ** +// ** sqlite3_str_vappendf() might ask for *temporary* memory allocations for +// ** certain format characters (%q) or for very large precisions or widths. +// ** Care must be taken that any sqlite3_log() calls that occur while the +// ** memory mutex is held do not use these mechanisms. +// */ +func _renderLogMsg(tls *libc.TLS, iErrCode int32, zFormat uintptr, ap Tva_list) { + bp := tls.Alloc(736) + defer tls.Free(736) + var _ /* acc at bp+0 */ TStrAccum + var _ /* zMsg at bp+32 */ [700]int8 /* Complete log message */ + _sqlite3StrAccumInit(tls, bp, uintptr(0), bp+32, int32(700), 0) + Xsqlite3_str_vappendf(tls, bp, zFormat, ap) + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.FxLog})))(tls, _sqlite3Config.FpLogArg, iErrCode, _sqlite3StrAccumFinish(tls, bp)) +} + +// C documentation +// +// /* +// ** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo() +// ** interface. +// ** +// ** For each FROM-clause subquery, add Column.zType, Column.zColl, and +// ** Column.affinity information to the Table structure that represents +// ** the result set of that subquery. +// ** +// ** The Table structure that represents the result set was constructed +// ** by selectExpander() but the type and collation and affinity information +// ** was omitted at that point because identifiers had not yet been resolved. +// ** This routine is called after identifier resolution. +// */ +func _selectAddSubqueryTypeInfo(tls *libc.TLS, pWalker uintptr, p uintptr) { + var i int32 + var pFrom, pParse, pSel, pTab, pTabList uintptr + _, _, _, _, _, _ = i, pFrom, pParse, pSel, pTab, pTabList + if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_HasTypeInfo) != 0 { + return + } + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_HasTypeInfo) + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + pTabList = (*TSelect)(unsafe.Pointer(p)).FpSrc + i = 0 + pFrom = pTabList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pTabList)).FnSrc) { + break + } + pTab = (*TSrcItem)(unsafe.Pointer(pFrom)).FpSTab + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Ephemeral) != uint32(0) && int32(*(*uint32)(unsafe.Pointer(pFrom + 24 + 4))&0x4>>2) != 0 { + /* A sub-query in the FROM clause of a SELECT */ + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pFrom + 72)))).FpSelect + _sqlite3SubqueryColumnTypes(tls, pParse, pTab, pSel, int8(SQLITE_AFF_NONE)) + } + goto _1 + _1: + ; + i = i + 1 + pFrom += 80 + } +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append the string zStr enclosed in quotes (") and +// ** with any embedded quote characters escaped to the buffer. No +// ** nul-terminator byte is written. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendIdent(tls *libc.TLS, p uintptr, zStr uintptr, pRc uintptr) { + var nStr int32 + var zIn, zOut, v1, v2 uintptr + _, _, _, _, _ = nStr, zIn, zOut, v1, v2 + nStr = _sqlite3Strlen30(tls, zStr)*int32(2) + int32(2) + int32(2) + if 0 == _sessionBufferGrow(tls, p, int64(nStr), pRc) { + zOut = (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf) + zIn = zStr + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8('"') + if zIn != uintptr(0) { + for **(**int8)(__ccgo_up(zIn)) != 0 { + if int32(**(**int8)(__ccgo_up(zIn))) == int32('"') { + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8('"') + } + v1 = zOut + zOut = zOut + 1 + v2 = zIn + zIn = zIn + 1 + **(**int8)(__ccgo_up(v1)) = **(**int8)(__ccgo_up(v2)) + } + } + v1 = zOut + zOut = zOut + 1 + **(**int8)(__ccgo_up(v1)) = int8('"') + (*TSessionBuffer)(unsafe.Pointer(p)).FnBuf = int32(int64(zOut) - int64((*TSessionBuffer)(unsafe.Pointer(p)).FaBuf)) + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf))) = uint8(0x00) + } +} + +// C documentation +// +// /* +// ** Insert a new FuncDef into a FuncDefHash hash table. +// */ +func _sqlite3InsertBuiltinFuncs(tls *libc.TLS, aDef uintptr, nDef int32) { + var h, i, nName int32 + var pOther, zName uintptr + _, _, _, _, _ = h, i, nName, pOther, zName + i = 0 + for { + if !(i < nDef) { + break + } + zName = (**(**TFuncDef)(__ccgo_up(aDef + uintptr(i)*72))).FzName + nName = _sqlite3Strlen30(tls, zName) + h = (int32(**(**int8)(__ccgo_up(zName))) + nName) % int32(SQLITE_FUNC_HASH_SZ) + pOther = _sqlite3FunctionSearch(tls, h, zName) + if pOther != 0 { + (**(**TFuncDef)(__ccgo_up(aDef + uintptr(i)*72))).FpNext = (*TFuncDef)(unsafe.Pointer(pOther)).FpNext + (*TFuncDef)(unsafe.Pointer(pOther)).FpNext = aDef + uintptr(i)*72 + } else { + (**(**TFuncDef)(__ccgo_up(aDef + uintptr(i)*72))).FpNext = uintptr(0) + *(*uintptr)(unsafe.Pointer(aDef + uintptr(i)*72 + 64)) = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(h)*8)) + **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(h)*8)) = aDef + uintptr(i)*72 + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Subqueries store the original database, table and column names for their +// ** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN", +// ** and mark the expression-list item by setting ExprList.a[].fg.eEName +// ** to ENAME_TAB. +// ** +// ** Check to see if the zSpan/eEName of the expression-list item passed to this +// ** routine matches the zDb, zTab, and zCol. If any of zDb, zTab, and zCol are +// ** NULL then those fields will match anything. Return true if there is a match, +// ** or false otherwise. +// ** +// ** SF_NestedFrom subqueries also store an entry for the implicit rowid (or +// ** _rowid_, or oid) column by setting ExprList.a[].fg.eEName to ENAME_ROWID, +// ** and setting zSpan to "DATABASE.TABLE.". This type of pItem +// ** argument matches if zCol is a rowid alias. If it is not NULL, (*pbRowid) +// ** is set to 1 if there is this kind of match. +// */ +func _sqlite3MatchEName(tls *libc.TLS, pItem uintptr, zCol uintptr, zTab uintptr, zDb uintptr, pbRowid uintptr) (r int32) { + var eEName, n int32 + var zSpan uintptr + _, _, _ = eEName, n, zSpan + eEName = int32(uint32(*(*uint16)(unsafe.Pointer(pItem + 16 + 4)) & 0x3 >> 0)) + if eEName != int32(ENAME_TAB) && (eEName != int32(ENAME_ROWID) || pbRowid == uintptr(0)) { + return 0 + } + zSpan = (*TExprList_item)(unsafe.Pointer(pItem)).FzEName + n = 0 + for { + if !(**(**int8)(__ccgo_up(zSpan + uintptr(n))) != 0 && int32(**(**int8)(__ccgo_up(zSpan + uintptr(n)))) != int32('.')) { + break + } + goto _1 + _1: + ; + n = n + 1 + } + if zDb != 0 && (Xsqlite3_strnicmp(tls, zSpan, zDb, n) != 0 || int32(**(**int8)(__ccgo_up(zDb + uintptr(n)))) != 0) { + return 0 + } + zSpan = zSpan + uintptr(n+int32(1)) + n = 0 + for { + if !(**(**int8)(__ccgo_up(zSpan + uintptr(n))) != 0 && int32(**(**int8)(__ccgo_up(zSpan + uintptr(n)))) != int32('.')) { + break + } + goto _2 + _2: + ; + n = n + 1 + } + if zTab != 0 && (Xsqlite3_strnicmp(tls, zSpan, zTab, n) != 0 || int32(**(**int8)(__ccgo_up(zTab + uintptr(n)))) != 0) { + return 0 + } + zSpan = zSpan + uintptr(n+int32(1)) + if zCol != 0 { + if eEName == int32(ENAME_TAB) && _sqlite3StrICmp(tls, zSpan, zCol) != 0 { + return 0 + } + if eEName == int32(ENAME_ROWID) && _sqlite3IsRowid(tls, zCol) == 0 { + return 0 + } + } + if eEName == int32(ENAME_ROWID) { + **(**int32)(__ccgo_up(pbRowid)) = int32(1) + } + return int32(1) +} + +// C documentation +// +// /* +// ** Compile the UTF-16 encoded SQL statement zSql into a statement handle. +// */ +func _sqlite3Prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags Tu32, ppStmt uintptr, pzTail uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var chars_parsed, rc, sz, sz1 int32 + var z, z1, zSql8 uintptr + var _ /* zTail8 at bp+0 */ uintptr + _, _, _, _, _, _, _ = chars_parsed, rc, sz, sz1, z, z1, zSql8 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0) + if !(_sqlite3SafetyCheckOk(tls, db) != 0) || zSql == uintptr(0) { + return _sqlite3MisuseError(tls, int32(148771)) + } + /* Make sure nBytes is non-negative and correct. It should be the + ** number of bytes until the end of the input buffer or until the first + ** U+0000 character. If the input nBytes is odd, convert it into + ** an even number. If the input nBytes is negative, then the input + ** must be terminated by at least one U+0000 character */ + if nBytes >= 0 { + z = zSql + sz = 0 + for { + if !(sz < nBytes && (int32(**(**int8)(__ccgo_up(z + uintptr(sz)))) != 0 || int32(**(**int8)(__ccgo_up(z + uintptr(sz+int32(1))))) != 0)) { + break + } + goto _1 + _1: + ; + sz = sz + int32(2) + } + nBytes = sz + } else { + z1 = zSql + sz1 = 0 + for { + if !(int32(**(**int8)(__ccgo_up(z1 + uintptr(sz1)))) != 0 || int32(**(**int8)(__ccgo_up(z1 + uintptr(sz1+int32(1))))) != 0) { + break + } + goto _2 + _2: + ; + sz1 = sz1 + int32(2) + } + nBytes = sz1 + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + zSql8 = _sqlite3Utf16to8(tls, db, zSql, nBytes, uint8(SQLITE_UTF16LE)) + if zSql8 != 0 { + rc = _sqlite3LockAndPrepare(tls, db, zSql8, -int32(1), prepFlags, uintptr(0), ppStmt, bp) + } + if **(**uintptr)(__ccgo_up(bp)) != 0 && pzTail != 0 { + /* If sqlite3_prepare returns a tail pointer, we calculate the + ** equivalent pointer into the UTF-16 string by counting the unicode + ** characters between zSql8 and zTail8, and then returning a pointer + ** the same number of characters into the UTF-16 string. + */ + chars_parsed = _sqlite3Utf8CharLen(tls, zSql8, int32(int64(**(**uintptr)(__ccgo_up(bp)))-int64(zSql8))) + **(**uintptr)(__ccgo_up(pzTail)) = zSql + uintptr(_sqlite3Utf16ByteLen(tls, zSql, nBytes, chars_parsed)) + } + _sqlite3DbFree(tls, db, zSql8) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Given a SELECT statement, generate a Table structure that describes +// ** the result set of that SELECT. +// */ +func _sqlite3ResultSetOfSelect(tls *libc.TLS, pParse uintptr, pSelect uintptr, aff int8) (r uintptr) { + var db, pTab uintptr + var savedFlags Tu64 + _, _, _ = db, pTab, savedFlags + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + savedFlags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_FullColNames) + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_ShortColNames) + _sqlite3SelectPrep(tls, pParse, pSelect, uintptr(0)) + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = savedFlags + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return uintptr(0) + } + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + pTab = _sqlite3DbMallocZero(tls, db, uint64(120)) + if pTab == uintptr(0) { + return uintptr(0) + } + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = uint32(1) + (*TTable)(unsafe.Pointer(pTab)).FzName = uintptr(0) + (*TTable)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) + _sqlite3ColumnsFromExprList(tls, pParse, (*TSelect)(unsafe.Pointer(pSelect)).FpEList, pTab+54, pTab+8) + _sqlite3SubqueryColumnTypes(tls, pParse, pTab, pSelect, aff) + (*TTable)(unsafe.Pointer(pTab)).FiPKey = int16(-int32(1)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3DeleteTable(tls, db, pTab) + return uintptr(0) + } + return pTab +} + +// C documentation +// +// /* +// ** Return the affinity character for a single column of a table. +// */ +func _sqlite3TableColumnAffinity(tls *libc.TLS, pTab uintptr, iCol int32) (r int8) { + if iCol < 0 || iCol >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + return int8(SQLITE_AFF_INTEGER) + } + return (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).Faffinity +} + +func _unicodeSetCategories(tls *libc.TLS, p uintptr, zCat uintptr) (r int32) { + var z uintptr + _ = z + z = zCat + for **(**int8)(__ccgo_up(z)) != 0 { + for int32(**(**int8)(__ccgo_up(z))) == int32(' ') || int32(**(**int8)(__ccgo_up(z))) == int32('\t') { + z = z + 1 + } + if **(**int8)(__ccgo_up(z)) != 0 && _sqlite3Fts5UnicodeCatParse(tls, z, p+160) != 0 { + return int32(SQLITE_ERROR) + } + for int32(**(**int8)(__ccgo_up(z))) != int32(' ') && int32(**(**int8)(__ccgo_up(z))) != int32('\t') && int32(**(**int8)(__ccgo_up(z))) != int32('\000') { + z = z + 1 + } + } + _sqlite3Fts5UnicodeAscii(tls, p+160, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** It is already known that pMem contains an unterminated string. +// ** Add the zero terminator. +// ** +// ** Three bytes of zero are added. In this way, there is guaranteed +// ** to be a double-zero byte at an even byte boundary in order to +// ** terminate a UTF16 string, even if the initial size of the buffer +// ** is an odd number of bytes. +// */ +func _vdbeMemAddTerminator(tls *libc.TLS, pMem uintptr) (r int32) { + var v1 uintptr + _ = v1 + if _sqlite3VdbeMemGrow(tls, pMem, (*TMem)(unsafe.Pointer(pMem)).Fn+int32(3), int32(1)) != 0 { + return int32(SQLITE_NOMEM) + } + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn))) = 0 + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn+int32(1)))) = 0 + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pMem)).Fz + uintptr((*TMem)(unsafe.Pointer(pMem)).Fn+int32(2)))) = 0 + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Term)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Initialize a WHERE clause scanner object. Return a pointer to the +// ** first match. Return NULL if there are no matches. +// ** +// ** The scanner will be searching the WHERE clause pWC. It will look +// ** for terms of the form "X " where X is column iColumn of table +// ** iCur. Or if pIdx!=0 then X is column iColumn of index pIdx. pIdx +// ** must be one of the indexes of table iCur. +// ** +// ** The must be one of the operators described by opMask. +// ** +// ** If the search is for X and the WHERE clause contains terms of the +// ** form X=Y then this routine might also return terms of the form +// ** "Y ". The number of levels of transitivity is limited, +// ** but is enough to handle most commonly occurring SQL statements. +// ** +// ** If X is not the INTEGER PRIMARY KEY then X must be compatible with +// ** index pIdx. +// */ +func _whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColumn int32, opMask Tu32, pIdx uintptr) (r uintptr) { + var j int32 + _ = j + (*TWhereScan)(unsafe.Pointer(pScan)).FpOrigWC = pWC + (*TWhereScan)(unsafe.Pointer(pScan)).FpWC = pWC + (*TWhereScan)(unsafe.Pointer(pScan)).FpIdxExpr = uintptr(0) + (*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff = 0 + (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName = uintptr(0) + (*TWhereScan)(unsafe.Pointer(pScan)).FopMask = opMask + (*TWhereScan)(unsafe.Pointer(pScan)).Fk = 0 + **(**int32)(__ccgo_up(pScan + 44)) = iCur + (*TWhereScan)(unsafe.Pointer(pScan)).FnEquiv = uint8(1) + (*TWhereScan)(unsafe.Pointer(pScan)).FiEquiv = uint8(1) + if pIdx != 0 { + j = iColumn + iColumn = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) + if iColumn == int32((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FiPKey) { + iColumn = -int32(1) + } else { + if iColumn >= 0 { + (*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(iColumn)*16))).Faffinity + (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8)) + } else { + if iColumn == -int32(2) { + (*TWhereScan)(unsafe.Pointer(pScan)).FpIdxExpr = (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(j)*32))).FpExpr + (*TWhereScan)(unsafe.Pointer(pScan)).FzCollName = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8)) + **(**Ti16)(__ccgo_up(pScan + 88)) = int16(-libc.Int32FromInt32(2)) + return _whereScanInitIndexExpr(tls, pScan) + } + } + } + } else { + if iColumn == -int32(2) { + return uintptr(0) + } + } + **(**Ti16)(__ccgo_up(pScan + 88)) = int16(iColumn) + return _whereScanNext(tls, pScan) +} diff --git a/internal/engine/lib/sqlite_g_000000000002c4cf.go b/internal/engine/lib/sqlite_g_000000000002c4cf.go new file mode 100644 index 0000000..8637623 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000002c4cf.go @@ -0,0 +1,141 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (linux && 386) || (linux && amd64) || (linux && loong64) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) + +package sqlite3 + +// C documentation +// +// /* +// ** A structure for holding a single date and time. +// */ +type TDateTime = struct { + FiJD Tsqlite3_int64 + FY int32 + FM int32 + FD int32 + Fh int32 + Fm int32 + Ftz int32 + Fs float64 + FvalidJD int8 + FvalidYMD int8 + FvalidHMS int8 + FnFloor int8 + F__ccgo44 uint8 +} + +type TJsonString = struct { + FpCtx uintptr + FzBuf uintptr + FnAlloc Tu64 + FnUsed Tu64 + FbStatic Tu8 + FeErr Tu8 + FzSpace [100]int8 +} + +// C documentation +// +// /* +// ** Each open file is managed by a separate instance of the "Pager" structure. +// */ +type TPager = struct { + FpVfs uintptr + FexclusiveMode Tu8 + FjournalMode Tu8 + FuseJournal Tu8 + FnoSync Tu8 + FfullSync Tu8 + FextraSync Tu8 + FsyncFlags Tu8 + FwalSyncFlags Tu8 + FtempFile Tu8 + FnoLock Tu8 + FreadOnly Tu8 + FmemDb Tu8 + FmemVfs Tu8 + FeState Tu8 + FeLock Tu8 + FchangeCountDone Tu8 + FsetSuper Tu8 + FdoNotSpill Tu8 + FsubjInMemory Tu8 + FbUseFetch Tu8 + FhasHeldSharedLock Tu8 + FdbSize TPgno + FdbOrigSize TPgno + FdbFileSize TPgno + FdbHintSize TPgno + FerrCode int32 + FnRec int32 + FcksumInit Tu32 + FnSubRec Tu32 + FpInJournal uintptr + Ffd uintptr + Fjfd uintptr + Fsjfd uintptr + FjournalOff Ti64 + FjournalHdr Ti64 + FpBackup uintptr + FaSavepoint uintptr + FnSavepoint int32 + FiDataVersion Tu32 + FdbFileVers [16]int8 + FnMmapOut int32 + FszMmap Tsqlite3_int64 + FpMmapFreelist uintptr + FnExtra Tu16 + FnReserve Ti16 + FvfsFlags Tu32 + FsectorSize Tu32 + FmxPgno TPgno + FlckPgno TPgno + FpageSize Ti64 + FjournalSizeLimit Ti64 + FzFilename uintptr + FzJournal uintptr + FxBusyHandler uintptr + FpBusyHandlerArg uintptr + FaStat [4]Tu32 + FxReiniter uintptr + FxGet uintptr + FpTmpSpace uintptr + FpPCache uintptr + FpWal uintptr + FzWal uintptr +} + +type Tsqlite3rbu = struct { + FeStage int32 + FdbMain uintptr + FdbRbu uintptr + FzTarget uintptr + FzRbu uintptr + FzState uintptr + FzStateDb [5]int8 + Frc int32 + FzErrmsg uintptr + FnStep int32 + FnProgress Tsqlite3_int64 + Fobjiter TRbuObjIter + FzVfsName uintptr + FpTargetFd uintptr + FnPagePerSector int32 + FiOalSz Ti64 + FnPhaseOneStep Ti64 + FpRenameArg uintptr + FxRename uintptr + FiMaxFrame Tu32 + FmLock Tu32 + FnFrame int32 + FnFrameAlloc int32 + FaFrame uintptr + Fpgsz int32 + FaBuf uintptr + FiWalCksum Ti64 + FszTemp Ti64 + FszTempLimit Ti64 + FnRbu int32 + FpRbuFd uintptr +} diff --git a/internal/engine/lib/sqlite_g_000000000003c02b.go b/internal/engine/lib/sqlite_g_000000000003c02b.go new file mode 100644 index 0000000..a3c80f0 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000003c02b.go @@ -0,0 +1,39 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +func _sqlite3MutexInit(tls *libc.TLS) (r int32) { + mu.Lock() + defer mu.Unlock() + var pFrom, pTo uintptr + var rc int32 + _, _, _ = pFrom, pTo, rc + rc = SQLITE_OK + if !(_sqlite3Config.Fmutex.FxMutexAlloc != 0) { + pTo = uintptr(unsafe.Pointer(&_sqlite3Config)) + 96 + if _sqlite3Config.FbCoreMutex != 0 { + pFrom = _sqlite3DefaultMutex(tls) + } else { + pFrom = _sqlite3NoopMutex(tls) + } + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexInit = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexInit + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexEnd = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexEnd + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexFree = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexFree + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexEnter = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexEnter + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexTry = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexTry + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexLeave = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexLeave + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexHeld = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexHeld + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexNotheld = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexNotheld + (*Tsqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexAlloc = (*Tsqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexAlloc + } + rc = (*(*func(*libc.TLS) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexInit})))(tls) + return rc +} diff --git a/internal/engine/lib/sqlite_g_000000000003dea8.go b/internal/engine/lib/sqlite_g_000000000003dea8.go new file mode 100644 index 0000000..60233f8 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000003dea8.go @@ -0,0 +1,152 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Check the leaf RTree cell given by pCellData against constraint p. +// ** If this constraint is not satisfied, set *peWithin to NOT_WITHIN. +// ** If the constraint is satisfied, leave *peWithin unchanged. +// ** +// ** The constraint is of the form: xN op $val +// ** +// ** The op is given by p->op. The xN is p->iCoord-th coordinate in +// ** pCellData. $val is given by p->u.rValue. +// */ +func _rtreeLeafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr, peWithin uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var xN TRtreeDValue + var v1 Tsqlite3_rtree_dbl + var _ /* c at bp+0 */ TRtreeCoord + _, _ = xN, v1 /* Coordinate value converted to a double */ + pCellData = pCellData + uintptr(int32(8)+(*TRtreeConstraint)(unsafe.Pointer(p)).FiCoord*int32(4)) + /* Coordinate decoded */ + libc.Xmemcpy(tls, bp, pCellData, uint64(4)) + *(*Tu32)(unsafe.Pointer(bp)) = *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp))&uint32(0xff)<= *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { + return + } + case int32(RTREE_GT): + if xN > *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { + return + } + default: + if xN == *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { + return + } + break + } + **(**int32)(__ccgo_up(peWithin)) = NOT_WITHIN +} + +// C documentation +// +// /* +// ** Check the internal RTree node given by pCellData against constraint p. +// ** If this constraint cannot be satisfied by any child within the node, +// ** set *peWithin to NOT_WITHIN. +// */ +func _rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr, peWithin uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var val, v1 Tsqlite3_rtree_dbl + var _ /* c at bp+0 */ TRtreeCoord + var _ /* c at bp+12 */ TRtreeCoord + var _ /* c at bp+4 */ TRtreeCoord + var _ /* c at bp+8 */ TRtreeCoord + _, _ = val, v1 /* Coordinate value convert to a double */ + /* p->iCoord might point to either a lower or upper bound coordinate + ** in a coordinate pair. But make pCellData point to the lower bound. + */ + pCellData = pCellData + uintptr(int32(8)+int32(4)*((*TRtreeConstraint)(unsafe.Pointer(p)).FiCoord&int32(0xfe))) + switch (*TRtreeConstraint)(unsafe.Pointer(p)).Fop { + case int32(RTREE_TRUE): + return /* Always satisfied */ + case int32(RTREE_FALSE): + case int32(RTREE_EQ): + /* Coordinate decoded */ libc.Xmemcpy(tls, bp, pCellData, uint64(4)) + *(*Tu32)(unsafe.Pointer(bp)) = *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp))&uint32(0xff)<= val { + pCellData = pCellData + uintptr(4) + /* Coordinate decoded */ libc.Xmemcpy(tls, bp+4, pCellData, uint64(4)) + *(*Tu32)(unsafe.Pointer(bp + 4)) = *(*Tu32)(unsafe.Pointer(bp + 4))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 4))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 4))&uint32(0xff)<>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 8))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 8))&uint32(0xff)<= val { + return + } + default: + pCellData = pCellData + uintptr(4) + /* Coordinate decoded */ libc.Xmemcpy(tls, bp+12, pCellData, uint64(4)) + *(*Tu32)(unsafe.Pointer(bp + 12)) = *(*Tu32)(unsafe.Pointer(bp + 12))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 12))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 12))&uint32(0xff)< x1 { + t = x0 + x0 = x1 + x1 = t + t = y0 + y0 = y1 + y1 = t + } + pSeg = (*TGeoOverlap)(unsafe.Pointer(p)).FaSegment + uintptr((*TGeoOverlap)(unsafe.Pointer(p)).FnSegment)*48 + (*TGeoOverlap)(unsafe.Pointer(p)).FnSegment = (*TGeoOverlap)(unsafe.Pointer(p)).FnSegment + 1 + (*TGeoSegment)(unsafe.Pointer(pSeg)).FC = float64((y1 - y0) / (x1 - x0)) + (*TGeoSegment)(unsafe.Pointer(pSeg)).FB = float64(y1) - float64(float64(x1)*(*TGeoSegment)(unsafe.Pointer(pSeg)).FC) + (*TGeoSegment)(unsafe.Pointer(pSeg)).Fy0 = y0 + (*TGeoSegment)(unsafe.Pointer(pSeg)).Fside = side + (*TGeoSegment)(unsafe.Pointer(pSeg)).Fidx = idx + pEvent = (*TGeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr((*TGeoOverlap)(unsafe.Pointer(p)).FnEvent)*32 + (*TGeoOverlap)(unsafe.Pointer(p)).FnEvent = (*TGeoOverlap)(unsafe.Pointer(p)).FnEvent + 1 + (*TGeoEvent)(unsafe.Pointer(pEvent)).Fx = float64(x0) + (*TGeoEvent)(unsafe.Pointer(pEvent)).FeType = 0 + (*TGeoEvent)(unsafe.Pointer(pEvent)).FpSeg = pSeg + pEvent = (*TGeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr((*TGeoOverlap)(unsafe.Pointer(p)).FnEvent)*32 + (*TGeoOverlap)(unsafe.Pointer(p)).FnEvent = (*TGeoOverlap)(unsafe.Pointer(p)).FnEvent + 1 + (*TGeoEvent)(unsafe.Pointer(pEvent)).Fx = float64(x1) + (*TGeoEvent)(unsafe.Pointer(pEvent)).FeType = int32(1) + (*TGeoEvent)(unsafe.Pointer(pEvent)).FpSeg = pSeg +} + +// C documentation +// +// /* +// ** SQL Function: geopoly_xform(poly, A, B, C, D, E, F) +// ** +// ** Transform and/or translate a polygon as follows: +// ** +// ** x1 = A*x0 + B*y0 + E +// ** y1 = C*x0 + D*y0 + F +// ** +// ** For a translation: +// ** +// ** geopoly_xform(poly, 1, 0, 0, 1, x-offset, y-offset) +// ** +// ** Rotate by R around the point (0,0): +// ** +// ** geopoly_xform(poly, cos(R), sin(R), -sin(R), cos(R), 0, 0) +// */ +func _geopolyXformFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var A, B, C, D, E, F float64 + var ii int32 + var p uintptr + var x0, x1, y0, y1 TGeoCoord + _, _, _, _, _, _, _, _, _, _, _, _ = A, B, C, D, E, F, ii, p, x0, x1, y0, y1 + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + A = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + B = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + C = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 3*8))) + D = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 4*8))) + E = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 5*8))) + F = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 6*8))) + _ = argc + if p != 0 { + ii = 0 + for { + if !(ii < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) { + break + } + x0 = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4)) + y0 = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4)) + x1 = float32(float64(A*float64(x0)) + float64(B*float64(y0)) + E) + y1 = float32(float64(C*float64(x0)) + float64(D*float64(y0)) + F) + **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4)) = x1 + **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4)) = y1 + goto _1 + _1: + ; + ii = ii + 1 + } + Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1))) + Xsqlite3_free(tls, p) + } +} diff --git a/internal/engine/lib/sqlite_g_000000000003fea8.go b/internal/engine/lib/sqlite_g_000000000003fea8.go new file mode 100644 index 0000000..bbe489f --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000003fea8.go @@ -0,0 +1,2841 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Allocate a new, empty, sqlite3_changegroup. +// */ +func Xsqlite3changegroup_new(tls *libc.TLS, pp uintptr) (r int32) { + var p uintptr + var rc int32 + _, _ = p, rc + rc = SQLITE_OK /* New object */ + p = Xsqlite3_malloc(tls, int32(96)) + if p == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, p, 0, uint64(96)) + } + **(**uintptr)(__ccgo_up(pp)) = p + return rc +} + +// C documentation +// +// /* +// ** Invert a changeset object. +// */ +func Xsqlite3changeset_invert(tls *libc.TLS, nChangeset int32, pChangeset uintptr, pnInverted uintptr, ppInverted uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var _ /* sInput at bp+0 */ TSessionInput + /* Set up the input stream */ + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TSessionInput)(__ccgo_up(bp))).FnData = nChangeset + (**(**TSessionInput)(__ccgo_up(bp))).FaData = pChangeset + return _sessionChangesetInvert(tls, bp, uintptr(0), uintptr(0), pnInverted, ppInverted) +} + +// C documentation +// +// /* +// ** Streaming version of sqlite3changeset_invert(). +// */ +func Xsqlite3changeset_invert_strm(tls *libc.TLS, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var rc int32 + var _ /* sInput at bp+0 */ TSessionInput + _ = rc + /* Set up the input stream */ + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TSessionInput)(__ccgo_up(bp))).FxInput = __ccgo_fp_xInput + (**(**TSessionInput)(__ccgo_up(bp))).FpIn = pIn + rc = _sessionChangesetInvert(tls, bp, __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0)) + Xsqlite3_free(tls, (**(**TSessionInput)(__ccgo_up(bp))).Fbuf.FaBuf) + return rc +} + +// C documentation +// +// /* +// ** Create a new rebaser object. +// */ +func Xsqlite3rebaser_create(tls *libc.TLS, ppNew uintptr) (r int32) { + var pNew uintptr + var rc int32 + _, _ = pNew, rc + rc = SQLITE_OK + pNew = Xsqlite3_malloc(tls, int32(96)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pNew, 0, uint64(96)) + } + **(**uintptr)(__ccgo_up(ppNew)) = pNew + return rc +} + +// C documentation +// +// /* +// ** Convert every pAggInfo->aFunc[].pExpr such that any node within +// ** those expressions that has pAppInfo set is changed into a TK_AGG_COLUMN +// ** opcode. +// */ +func _aggregateConvertIndexedExprRefToColumn(tls *libc.TLS, pAggInfo uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i int32 + var _ /* w at bp+0 */ TWalker + _ = i + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_aggregateIdxEprRefToColCallback) + i = 0 + for { + if !(i < (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { + break + } + _sqlite3WalkExpr(tls, bp, (**(**TAggInfo_func)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*32))).FpFExpr) + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Append text z[] to the end of p[]. Return a pointer to the first +// ** character after then zero terminator on the new text in p[]. +// */ +func _appendText(tls *libc.TLS, p uintptr, z uintptr) (r uintptr) { + var n Tsize_t + _ = n + n = libc.Xstrlen(tls, z) + libc.Xmemcpy(tls, p, z, n+uint64(1)) + return p + uintptr(n) + uintptr(1) +} + +// C documentation +// +// /* The RFC-7539 ChaCha20 block function +// */ +func _chacha_block(tls *libc.TLS, out uintptr, in uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i int32 + var _ /* x at bp+0 */ [16]Tu32 + _ = i + libc.Xmemcpy(tls, bp, in, uint64(64)) + i = 0 + for { + if !(i < int32(10)) { + break + } + **(**Tu32)(__ccgo_up(bp)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] + **(**Tu32)(__ccgo_up(bp + 12*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[0] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 8*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] + **(**Tu32)(__ccgo_up(bp + 4*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(8)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] + **(**Tu32)(__ccgo_up(bp + 12*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[0] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 8*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] + **(**Tu32)(__ccgo_up(bp + 4*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(8)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 1*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] + **(**Tu32)(__ccgo_up(bp + 13*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(1)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 9*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] + **(**Tu32)(__ccgo_up(bp + 5*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(9)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 1*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] + **(**Tu32)(__ccgo_up(bp + 13*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(1)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 9*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] + **(**Tu32)(__ccgo_up(bp + 5*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(9)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 2*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] + **(**Tu32)(__ccgo_up(bp + 14*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(2)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 10*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] + **(**Tu32)(__ccgo_up(bp + 6*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(10)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 2*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] + **(**Tu32)(__ccgo_up(bp + 14*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(2)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 10*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] + **(**Tu32)(__ccgo_up(bp + 6*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(10)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 3*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] + **(**Tu32)(__ccgo_up(bp + 15*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(3)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 11*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] + **(**Tu32)(__ccgo_up(bp + 7*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(11)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 3*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] + **(**Tu32)(__ccgo_up(bp + 15*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(3)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 11*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] + **(**Tu32)(__ccgo_up(bp + 7*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(11)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] + **(**Tu32)(__ccgo_up(bp + 15*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[0] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 10*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] + **(**Tu32)(__ccgo_up(bp + 5*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(10)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] + **(**Tu32)(__ccgo_up(bp + 15*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[0] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 10*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(15)] + **(**Tu32)(__ccgo_up(bp + 5*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(10)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(5)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 1*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] + **(**Tu32)(__ccgo_up(bp + 12*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(1)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 11*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] + **(**Tu32)(__ccgo_up(bp + 6*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(11)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 1*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] + **(**Tu32)(__ccgo_up(bp + 12*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(1)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 11*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(12)] + **(**Tu32)(__ccgo_up(bp + 6*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(11)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(6)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 2*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] + **(**Tu32)(__ccgo_up(bp + 13*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(2)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 8*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] + **(**Tu32)(__ccgo_up(bp + 7*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(8)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 2*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] + **(**Tu32)(__ccgo_up(bp + 13*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(2)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 8*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(13)] + **(**Tu32)(__ccgo_up(bp + 7*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(8)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(7)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + **(**Tu32)(__ccgo_up(bp + 3*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] + **(**Tu32)(__ccgo_up(bp + 14*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(3)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(16)) + **(**Tu32)(__ccgo_up(bp + 9*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] + **(**Tu32)(__ccgo_up(bp + 4*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(9)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(12)) + **(**Tu32)(__ccgo_up(bp + 3*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] + **(**Tu32)(__ccgo_up(bp + 14*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(3)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(8)) + **(**Tu32)(__ccgo_up(bp + 9*4)) += (**(**[16]Tu32)(__ccgo_up(bp)))[int32(14)] + **(**Tu32)(__ccgo_up(bp + 4*4)) ^= (**(**[16]Tu32)(__ccgo_up(bp)))[int32(9)] + (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)] = (**(**[16]Tu32)(__ccgo_up(bp)))[int32(4)]<>(libc.Int32FromInt32(32)-libc.Int32FromInt32(7)) + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < int32(16)) { + break + } + **(**Tu32)(__ccgo_up(out + uintptr(i)*4)) = (**(**[16]Tu32)(__ccgo_up(bp)))[i] + **(**Tu32)(__ccgo_up(in + uintptr(i)*4)) + goto _2 + _2: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Put the DateTime object into its error state. +// */ +func _datetimeError(tls *libc.TLS, p uintptr) { + libc.Xmemset(tls, p, 0, uint64(48)) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 1, 0x2) +} + +// C documentation +// +// /* +// ** Open a new dbpagevfs cursor. +// */ +func _dbpageOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = Xsqlite3_malloc64(tls, uint64(40)) + if pCsr == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pCsr, 0, uint64(40)) + (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab + (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno = uint32(0) + } + **(**uintptr)(__ccgo_up(ppCursor)) = pCsr + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Disable lookaside memory allocation for objects that might be +// ** shared across database connections. +// */ +func _disableLookaside(tls *libc.TLS, pParse uintptr) { + var db uintptr + _ = db + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + (*TParse)(unsafe.Pointer(pParse)).FdisableLookaside = (*TParse)(unsafe.Pointer(pParse)).FdisableLookaside + 1 + libc.Xmemset(tls, pParse+248, 0, uint64(32)) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) +} + +// C documentation +// +// /* +// ** Allocate a new segment-id for the structure pStruct. The new segment +// ** id must be between 1 and 65335 inclusive, and must not be used by +// ** any currently existing segment. If a free segment id cannot be found, +// ** SQLITE_FULL is returned. +// ** +// ** If an error has already occurred, this function is a no-op. 0 is +// ** returned in this case. +// */ +func _fts5AllocateSegid(tls *libc.TLS, p uintptr, pStruct uintptr) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var i, iId, iLvl, iSeg, iSegid int32 + var mask Tu32 + var _ /* aUsed at bp+0 */ [63]Tu32 + _, _, _, _, _, _ = i, iId, iLvl, iSeg, iSegid, mask + iSegid = 0 + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment >= int32(FTS5_MAX_SEGMENT) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = int32(SQLITE_FULL) + } else { + libc.Xmemset(tls, bp, 0, uint64(252)) + iLvl = 0 + for { + if !(iLvl < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + iSeg = 0 + for { + if !(iSeg < (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg) { + break + } + iId = (**(**TFts5StructureSegment)(__ccgo_up((*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr(iSeg)*56))).FiSegid + if iId <= int32(FTS5_MAX_SEGMENT) && iId > 0 { + **(**Tu32)(__ccgo_up(bp + uintptr((iId-int32(1))/int32(32))*4)) |= libc.Uint32FromInt32(1) << ((iId - int32(1)) % int32(32)) + } + goto _2 + _2: + ; + iSeg = iSeg + 1 + } + goto _1 + _1: + ; + iLvl = iLvl + 1 + } + i = 0 + for { + if !((**(**[63]Tu32)(__ccgo_up(bp)))[i] == uint32(0xFFFFFFFF)) { + break + } + goto _3 + _3: + ; + i = i + 1 + } + mask = (**(**[63]Tu32)(__ccgo_up(bp)))[i] + iSegid = 0 + for { + if !(mask&(libc.Uint32FromInt32(1)<= 0) { + break + } + pLvl = pIter + 8 + uintptr(i)*32 + for _fts5DlidxLvlNext(tls, pLvl) == 0 { + } + (*TFts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof = 0 + if i > 0 { + pChild = pLvl + uintptr(-libc.Int32FromInt32(1))*32 + _fts5DataRelease(tls, (*TFts5DlidxLvl)(unsafe.Pointer(pChild)).FpData) + libc.Xmemset(tls, pChild, 0, uint64(32)) + (*TFts5DlidxLvl)(unsafe.Pointer(pChild)).FpData = _fts5DataRead(tls, p, int64((*TFts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(1))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(i-libc.Int32FromInt32(1))< 0 { + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + (*TFts5DoclistIter)(unsafe.Pointer(pIter)).FaEof = (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn) + _fts5DoclistIterNext(tls, pIter) + } +} + +// C documentation +// +// /* +// ** Find a tokenizer. This is the implementation of the +// ** fts5_api.xFindTokenizer() method. +// */ +func _fts5FindTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, ppUserData uintptr, pTokenizer uintptr) (r int32) { + var pMod uintptr + var rc int32 + _, _ = pMod, rc + rc = SQLITE_OK + pMod = _fts5LocateTokenizer(tls, pApi, zName) + if pMod != 0 { + if (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FbV2Native == 0 { + **(**uintptr)(__ccgo_up(ppUserData)) = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData + } else { + **(**uintptr)(__ccgo_up(ppUserData)) = pMod + } + **(**Tfts5_tokenizer)(__ccgo_up(pTokenizer)) = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx1 + } else { + libc.Xmemset(tls, pTokenizer, 0, uint64(24)) + **(**uintptr)(__ccgo_up(ppUserData)) = uintptr(0) + rc = int32(SQLITE_ERROR) + } + return rc +} + +func _fts5LookaheadReaderInit(tls *libc.TLS, a uintptr, n int32, p uintptr) (r int32) { + libc.Xmemset(tls, p, 0, uint64(32)) + (*TFts5LookaheadReader)(unsafe.Pointer(p)).Fa = a + (*TFts5LookaheadReader)(unsafe.Pointer(p)).Fn = n + _fts5LookaheadReaderNext(tls, p) + return _fts5LookaheadReaderNext(tls, p) +} + +// C documentation +// +// /* +// ** Zero the iterator passed as the only argument. +// */ +func _fts5SegIterClear(tls *libc.TLS, pIter uintptr) { + _sqlite3Fts5BufferFree(tls, pIter+96) + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf) + _fts5TombstoneArrayDelete(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpTombArray) + _fts5DlidxIterFree(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpDlidx) + Xsqlite3_free(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset) + libc.Xmemset(tls, pIter, 0, uint64(128)) +} + +// C documentation +// +// /* +// ** Initialize the iterator object pIter to iterate through the entries in +// ** segment pSeg. The iterator is left pointing to the first entry when +// ** this function returns. +// ** +// ** If an error occurs, Fts5Index.rc is set to an appropriate error code. If +// ** an error has already occurred when this function is called, it is a no-op. +// */ +func _fts5SegIterInit(tls *libc.TLS, p uintptr, pSeg uintptr, pIter uintptr) { + if (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst == 0 { + /* This happens if the segment is being used as an input to an incremental + ** merge and all data has already been "trimmed". See function + ** fts5TrimSegments() for details. In this case leave the iterator empty. + ** The caller will see the (pIter->pLeaf==0) and assume the iterator is + ** at EOF already. */ + return + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + libc.Xmemset(tls, pIter, 0, uint64(128)) + _fts5SegIterSetNext(tls, p, pIter) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst - int32(1) + for cond := true; cond; cond = (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 && (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn == int32(4) { + _fts5SegIterNextPage(tls, p, pIter) + } + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(4) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + int32(1) + _fts5SegIterLoadTerm(tls, p, pIter, 0) + _fts5SegIterLoadNPos(tls, p, pIter) + _fts5SegIterAllocTombstone(tls, p, pIter) + } +} + +// C documentation +// +// /* +// ** This is similar to fts5SegIterSeekInit(), except that it initializes +// ** the segment iterator to point to the first term following the page +// ** with pToken/nToken on it. +// */ +func _fts5SegIterNextInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, pSeg uintptr, pIter uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, pSel uintptr + var bDlidx, iPg int32 + var val Ti64 + var _ /* iTermOff at bp+0 */ int32 + _, _, _, _, _ = a, bDlidx, iPg, pSel, val + iPg = -int32(1) /* Page of segment to open */ + bDlidx = 0 + pSel = uintptr(0) /* SELECT to find iPg */ + pSel = _fts5IdxNextStmt(tls, p) + if pSel != 0 { + Xsqlite3_bind_int(tls, pSel, int32(1), (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid) + Xsqlite3_bind_blob(tls, pSel, int32(2), pTerm, nTerm, libc.UintptrFromInt32(0)) + if Xsqlite3_step(tls, pSel) == int32(SQLITE_ROW) { + val = Xsqlite3_column_int64(tls, pSel, 0) + iPg = int32(val >> libc.Int32FromInt32(1)) + bDlidx = int32(val & libc.Int64FromInt32(0x0001)) + } + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, pSel) + Xsqlite3_bind_null(tls, pSel, int32(2)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + } + libc.Xmemset(tls, pIter, 0, uint64(128)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_ONETERM) + if iPg >= 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iPg - int32(1) + _fts5SegIterNextPage(tls, p, pIter) + _fts5SegIterSetNext(tls, p, pIter) + } + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + **(**int32)(__ccgo_up(bp)) = 0 + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + **(**int32)(__ccgo_up(pIter + 64)) += _sqlite3Fts5GetVarint32(tls, a+uintptr((*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff), bp) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(**(**int32)(__ccgo_up(bp))) + _fts5SegIterLoadTerm(tls, p, pIter, 0) + _fts5SegIterLoadNPos(tls, p, pIter) + if bDlidx != 0 { + _fts5SegIterLoadDlidx(tls, p, pIter) + } + } +} + +// C documentation +// +// /* +// ** Initialize the object pIter to point to term pTerm/nTerm within segment +// ** pSeg. If there is no such term in the index, the iterator is set to EOF. +// ** +// ** If an error occurs, Fts5Index.rc is set to an appropriate error code. If +// ** an error has already occurred when this function is called, it is a no-op. +// */ +func _fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, flags int32, pSeg uintptr, pIter uintptr) { + var bDlidx, bGe, iPg int32 + var pIdxSelect uintptr + var val Ti64 + _, _, _, _, _ = bDlidx, bGe, iPg, pIdxSelect, val + iPg = int32(1) + bGe = flags & int32(FTS5INDEX_QUERY_SCAN) + bDlidx = 0 /* True if there is a doclist-index */ + pIdxSelect = uintptr(0) + libc.Xmemset(tls, pIter, 0, uint64(128)) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg + /* This block sets stack variable iPg to the leaf page number that may + ** contain term (pTerm/nTerm), if it is present in the segment. */ + pIdxSelect = _fts5IdxSelectStmt(tls, p) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + Xsqlite3_bind_int(tls, pIdxSelect, int32(1), (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid) + Xsqlite3_bind_blob(tls, pIdxSelect, int32(2), pTerm, nTerm, libc.UintptrFromInt32(0)) + if int32(SQLITE_ROW) == Xsqlite3_step(tls, pIdxSelect) { + val = int64(Xsqlite3_column_int(tls, pIdxSelect, 0)) + iPg = int32(val >> libc.Int32FromInt32(1)) + bDlidx = int32(val & libc.Int64FromInt32(0x0001)) + } + (*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, pIdxSelect) + Xsqlite3_bind_null(tls, pIdxSelect, int32(2)) + if iPg < (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { + iPg = (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst + bDlidx = 0 + } + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iPg - int32(1) + _fts5SegIterNextPage(tls, p, pIter) + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + _fts5LeafSeek(tls, p, bGe, pIter, pTerm, nTerm) + } + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (bGe == 0 || flags&int32(FTS5INDEX_QUERY_SCANONETERM) != 0) { + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_ONETERM) + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { + if flags&int32(FTS5INDEX_QUERY_DESC) != 0 { + **(**int32)(__ccgo_up(pIter + 8)) |= int32(FTS5_SEGITER_REVERSE) + } + if bDlidx != 0 { + _fts5SegIterLoadDlidx(tls, p, pIter) + } + if flags&int32(FTS5INDEX_QUERY_DESC) != 0 { + _fts5SegIterReverse(tls, p, pIter) + } + } + } + _fts5SegIterSetNext(tls, p, pIter) + if 0 == flags&int32(FTS5INDEX_QUERY_SCANONETERM) { + _fts5SegIterAllocTombstone(tls, p, pIter) + } + /* Either: + ** + ** 1) an error has occurred, or + ** 2) the iterator points to EOF, or + ** 3) the iterator points to an entry with term (pTerm/nTerm), or + ** 4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points + ** to an entry with a term greater than or equal to (pTerm/nTerm). + */ +} + +// C documentation +// +// /* +// ** Store the current contents of the p->nTotalRow and p->aTotalSize[] +// ** variables in the "averages" record on disk. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code if an error +// ** occurs. +// */ +func _fts5StorageSaveTotals(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, nCol int32 + var _ /* buf at bp+0 */ TFts5Buffer + var _ /* rc at bp+16 */ int32 + _, _ = i, nCol + nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol + **(**int32)(__ccgo_up(bp + 16)) = SQLITE_OK + libc.Xmemset(tls, bp, 0, uint64(16)) + _sqlite3Fts5BufferAppendVarint(tls, bp+16, bp, (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow) + i = 0 + for { + if !(i < nCol) { + break + } + _sqlite3Fts5BufferAppendVarint(tls, bp+16, bp, **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 16)) = _sqlite3Fts5IndexSetAverages(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp, (**(**TFts5Buffer)(__ccgo_up(bp))).Fn) + } + Xsqlite3_free(tls, (**(**TFts5Buffer)(__ccgo_up(bp))).Fp) + return **(**int32)(__ccgo_up(bp + 16)) +} + +// C documentation +// +// /* +// ** Return a copy of index structure pStruct. Except, promote as many +// ** segments as possible to level iPromote. If an OOM occurs, NULL is +// ** returned. +// */ +func _fts5StructurePromoteTo(tls *libc.TLS, p uintptr, iPromote int32, szPromote int32, pStruct uintptr) { + var il, is, sz int32 + var pLvl, pOut uintptr + _, _, _, _, _ = il, is, pLvl, pOut, sz + pOut = pStruct + 32 + uintptr(iPromote)*16 + if (*TFts5StructureLevel)(unsafe.Pointer(pOut)).FnMerge == 0 { + il = iPromote + int32(1) + for { + if !(il < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + pLvl = pStruct + 32 + uintptr(il)*16 + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 { + return + } + is = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - int32(1) + for { + if !(is >= 0) { + break + } + sz = _fts5SegmentSize(tls, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(is)*56) + if sz > szPromote { + return + } + _fts5StructureExtendLevel(tls, p+60, pStruct, iPromote, int32(1), int32(1)) + if (*TFts5Index)(unsafe.Pointer(p)).Frc != 0 { + return + } + libc.Xmemcpy(tls, (*TFts5StructureLevel)(unsafe.Pointer(pOut)).FaSeg, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(is)*56, uint64(56)) + (*TFts5StructureLevel)(unsafe.Pointer(pOut)).FnSeg = (*TFts5StructureLevel)(unsafe.Pointer(pOut)).FnSeg + 1 + (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - 1 + goto _2 + _2: + ; + is = is - 1 + } + goto _1 + _1: + ; + il = il + 1 + } + } +} + +// C documentation +// +// /* +// ** The two input arrays - a1[] and a2[] - are in sorted order. This function +// ** merges the two arrays together and writes the result to output array +// ** aOut[]. aOut[] is guaranteed to be large enough to hold the result. +// ** +// ** Duplicate entries are copied into the output. So the size of the output +// ** array is always (n1+n2) entries. +// */ +func _fts5TokendataMerge(tls *libc.TLS, a1 uintptr, n1 int32, a2 uintptr, n2 int32, aOut uintptr) { + var i1, i2 int32 + var pOut uintptr + _, _, _ = i1, i2, pOut + i1 = 0 + i2 = 0 + for i1 < n1 || i2 < n2 { + pOut = aOut + uintptr(i1+i2)*24 + if i2 >= n2 || i1 < n1 && ((**(**TFts5TokenDataMap)(__ccgo_up(a1 + uintptr(i1)*24))).FiRowid < (**(**TFts5TokenDataMap)(__ccgo_up(a2 + uintptr(i2)*24))).FiRowid || (**(**TFts5TokenDataMap)(__ccgo_up(a1 + uintptr(i1)*24))).FiRowid == (**(**TFts5TokenDataMap)(__ccgo_up(a2 + uintptr(i2)*24))).FiRowid && (**(**TFts5TokenDataMap)(__ccgo_up(a1 + uintptr(i1)*24))).FiPos <= (**(**TFts5TokenDataMap)(__ccgo_up(a2 + uintptr(i2)*24))).FiPos) { + libc.Xmemcpy(tls, pOut, a1+uintptr(i1)*24, uint64(24)) + i1 = i1 + 1 + } else { + libc.Xmemcpy(tls, pOut, a2+uintptr(i2)*24, uint64(24)) + i2 = i2 + 1 + } + } +} + +// C documentation +// +// /* +// ** Implementation of the geopoly_group_bbox(X) aggregate SQL function. +// */ +func _geopolyBBoxStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pBBox uintptr + var _ /* a at bp+0 */ [4]TRtreeCoord + var _ /* rc at bp+16 */ int32 + _ = pBBox + **(**int32)(__ccgo_up(bp + 16)) = SQLITE_OK + _ = argc + _geopolyBBox(tls, context, **(**uintptr)(__ccgo_up(argv)), bp, bp+16) + if **(**int32)(__ccgo_up(bp + 16)) == SQLITE_OK { + pBBox = Xsqlite3_aggregate_context(tls, context, int32(20)) + if pBBox == uintptr(0) { + return + } + if libc.AtomicLoadPInt32(pBBox) == 0 { + libc.AtomicStorePInt32(pBBox, int32(1)) + libc.Xmemcpy(tls, pBBox+4, bp, libc.Uint64FromInt64(4)*libc.Uint64FromInt32(4)) + } else { + if *(*TRtreeValue)(unsafe.Pointer(bp)) < *(*TRtreeValue)(unsafe.Pointer(pBBox + 4)) { + **(**TRtreeCoord)(__ccgo_up(pBBox + 4)) = (**(**[4]TRtreeCoord)(__ccgo_up(bp)))[0] + } + if *(*TRtreeValue)(unsafe.Pointer(bp + 1*4)) > *(*TRtreeValue)(unsafe.Pointer(pBBox + 4 + 1*4)) { + **(**TRtreeCoord)(__ccgo_up(pBBox + 4 + 1*4)) = (**(**[4]TRtreeCoord)(__ccgo_up(bp)))[int32(1)] + } + if *(*TRtreeValue)(unsafe.Pointer(bp + 2*4)) < *(*TRtreeValue)(unsafe.Pointer(pBBox + 4 + 2*4)) { + **(**TRtreeCoord)(__ccgo_up(pBBox + 4 + 2*4)) = (**(**[4]TRtreeCoord)(__ccgo_up(bp)))[int32(2)] + } + if *(*TRtreeValue)(unsafe.Pointer(bp + 3*4)) > *(*TRtreeValue)(unsafe.Pointer(pBBox + 4 + 3*4)) { + **(**TRtreeCoord)(__ccgo_up(pBBox + 4 + 3*4)) = (**(**[4]TRtreeCoord)(__ccgo_up(bp)))[int32(3)] + } + } + } +} + +// C documentation +// +// /* +// ** Transfer eligible terms from the HAVING clause of a query, which is +// ** processed after grouping, to the WHERE clause, which is processed before +// ** grouping. For example, the query: +// ** +// ** SELECT * FROM WHERE a=? GROUP BY b HAVING b=? AND c=? +// ** +// ** can be rewritten as: +// ** +// ** SELECT * FROM WHERE a=? AND b=? GROUP BY b HAVING c=? +// ** +// ** A term of the HAVING expression is eligible for transfer if it consists +// ** entirely of constants and expressions that are also GROUP BY terms that +// ** use the "BINARY" collation sequence. +// */ +func _havingToWhere(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* sWalker at bp+0 */ TWalker + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_havingToWhereExprCb) + *(*uintptr)(unsafe.Pointer(bp + 40)) = p + _sqlite3WalkExpr(tls, bp, (*TSelect)(unsafe.Pointer(p)).FpHaving) +} + +func _incrAggFunctionDepth(tls *libc.TLS, pExpr uintptr, N int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + if N > 0 { + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_incrAggDepth) + *(*int32)(unsafe.Pointer(bp + 40)) = N + _sqlite3WalkExpr(tls, bp, pExpr) + } +} + +func _jsonAppendRaw(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + if N == uint32(0) { + return + } + if uint64(N)+(*TJsonString)(unsafe.Pointer(p)).FnUsed >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc { + _jsonStringExpandAndAppend(tls, p, zIn, N) + } else { + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), zIn, uint64(N)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(N) + } +} + +func _jsonAppendRawNZ(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + if uint64(N)+(*TJsonString)(unsafe.Pointer(p)).FnUsed >= (*TJsonString)(unsafe.Pointer(p)).FnAlloc { + _jsonStringExpandAndAppend(tls, p, zIn, N) + } else { + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), zIn, uint64(N)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(N) + } +} + +// C documentation +// +// /* +// ** If pParse->aBlob is not previously editable (because it is taken +// ** from sqlite3_value_blob(), as indicated by the fact that +// ** pParse->nBlobAlloc==0 and pParse->nBlob>0) then make it editable +// ** by making a copy into space obtained from malloc. +// ** +// ** Return true on success. Return false on OOM. +// */ +func _jsonBlobMakeEditable(tls *libc.TLS, pParse uintptr, nExtra Tu32) (r int32) { + var aOld uintptr + var nSize Tu32 + _, _ = aOld, nSize + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return 0 + } + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc > uint32(0) { + return int32(1) + } + aOld = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + nSize = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + nExtra + (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = uintptr(0) + if _jsonBlobExpand(tls, pParse, nSize) != 0 { + return 0 + } + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob, aOld, uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)) + return int32(1) +} + +// C documentation +// +// /* +// ** Convert a JSON BLOB into text and make that text the return value +// ** of an SQL function. +// */ +func _jsonReturnTextJsonFromBlob(tls *libc.TLS, ctx uintptr, aBlob uintptr, nBlob Tu32) { + bp := tls.Alloc(208) + defer tls.Free(208) + var _ /* s at bp+72 */ TJsonString + var _ /* x at bp+0 */ TJsonParse + if aBlob == uintptr(0) { + return + } + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TJsonParse)(__ccgo_up(bp))).FaBlob = aBlob + (**(**TJsonParse)(__ccgo_up(bp))).FnBlob = nBlob + _jsonStringInit(tls, bp+72, ctx) + _jsonTranslateBlobToText(tls, bp, uint32(0), bp+72) + _jsonReturnString(tls, bp+72, uintptr(0), uintptr(0)) +} + +// C documentation +// +// /* Append N bytes from zIn onto the end of the JsonString string. +// */ +func _jsonStringExpandAndAppend(tls *libc.TLS, p uintptr, zIn uintptr, N Tu32) { + if _jsonStringGrow(tls, p, N) != 0 { + return + } + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed), zIn, uint64(N)) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(N) +} + +// C documentation +// +// /* Enlarge pJson->zBuf so that it can hold at least N more bytes. +// ** Return zero on success. Return non-zero on an OOM error +// */ +func _jsonStringGrow(tls *libc.TLS, p uintptr, N Tu32) (r int32) { + var nTotal Tu64 + var zNew, v2 uintptr + var v1 uint64 + _, _, _, _ = nTotal, zNew, v1, v2 + if uint64(N) < (*TJsonString)(unsafe.Pointer(p)).FnAlloc { + v1 = (*TJsonString)(unsafe.Pointer(p)).FnAlloc * uint64(2) + } else { + v1 = (*TJsonString)(unsafe.Pointer(p)).FnAlloc + uint64(N) + uint64(10) + } + nTotal = v1 + if (*TJsonString)(unsafe.Pointer(p)).FbStatic != 0 { + if (*TJsonString)(unsafe.Pointer(p)).FeErr != 0 { + return int32(1) + } + zNew = _sqlite3RCStrNew(tls, nTotal) + if zNew == uintptr(0) { + _jsonStringOom(tls, p) + return int32(SQLITE_NOMEM) + } + libc.Xmemcpy(tls, zNew, (*TJsonString)(unsafe.Pointer(p)).FzBuf, (*TJsonString)(unsafe.Pointer(p)).FnUsed) + (*TJsonString)(unsafe.Pointer(p)).FzBuf = zNew + (*TJsonString)(unsafe.Pointer(p)).FbStatic = uint8(0) + } else { + (*TJsonString)(unsafe.Pointer(p)).FzBuf = _sqlite3RCStrResize(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf, nTotal) + if (*TJsonString)(unsafe.Pointer(p)).FzBuf == uintptr(0) { + v2 = p + 33 + *(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(JSTRING_OOM)) + _jsonStringZero(tls, p) + return int32(SQLITE_NOMEM) + } + } + (*TJsonString)(unsafe.Pointer(p)).FnAlloc = nTotal + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Flush the contents of memory to a real file on disk. +// */ +func _memjrnlCreateFile(tls *libc.TLS, p uintptr) (r int32) { + var copy1 TMemJournal + var iOff Ti64 + var nChunk, rc int32 + var pIter, pReal uintptr + _, _, _, _, _, _ = copy1, iOff, nChunk, pIter, pReal, rc + pReal = p + copy1 = **(**TMemJournal)(__ccgo_up(p)) + libc.Xmemset(tls, p, 0, uint64(80)) + rc = _sqlite3OsOpen(tls, copy1.FpVfs, copy1.FzJournal, pReal, copy1.Fflags, uintptr(0)) + if rc == SQLITE_OK { + nChunk = copy1.FnChunkSize + iOff = 0 + pIter = copy1.FpFirst + for { + if !(pIter != 0) { + break + } + if iOff+int64(nChunk) > copy1.Fendpoint.FiOffset { + nChunk = int32(copy1.Fendpoint.FiOffset - iOff) + } + rc = _sqlite3OsWrite(tls, pReal, pIter+8, nChunk, iOff) + if rc != 0 { + break + } + iOff = iOff + int64(nChunk) + goto _1 + _1: + ; + pIter = (*TFileChunk)(unsafe.Pointer(pIter)).FpNext + } + if rc == SQLITE_OK { + /* No error has occurred. Free the in-memory buffers. */ + _memjrnlFreeChunks(tls, copy1.FpFirst) + } + } + if rc != SQLITE_OK { + /* If an error occurred while creating or writing to the file, restore + ** the original before returning. This way, SQLite uses the in-memory + ** journal data to roll back changes made to the internal page-cache + ** before this function was called. */ + _sqlite3OsClose(tls, pReal) + **(**TMemJournal)(__ccgo_up(p)) = copy1 + } + return rc +} + +// C documentation +// +// /* +// ** This routine is called to increment the value of the database file +// ** change-counter, stored as a 4-byte big-endian integer starting at +// ** byte offset 24 of the pager file. The secondary change counter at +// ** 92 is also updated, as is the SQLite version number at offset 96. +// ** +// ** But this only happens if the pPager->changeCountDone flag is false. +// ** To avoid excess churning of page 1, the update only happens once. +// ** See also the pager_write_changecounter() routine that does an +// ** unconditional update of the change counters. +// ** +// ** If the isDirectMode flag is zero, then this is done by calling +// ** sqlite3PagerWrite() on page 1, then modifying the contents of the +// ** page data. In this case the file will be updated when the current +// ** transaction is committed. +// ** +// ** The isDirectMode flag may only be non-zero if the library was compiled +// ** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case, +// ** if isDirect is non-zero, then the database file is updated directly +// ** by writing an updated version of page 1 using a call to the +// ** sqlite3OsWrite() function. +// */ +func _pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pCopy, zBuf uintptr + var rc int32 + var _ /* pPgHdr at bp+0 */ uintptr + _, _, _ = pCopy, rc, zBuf + rc = SQLITE_OK + /* Declare and initialize constant integer 'isDirect'. If the + ** atomic-write optimization is enabled in this build, then isDirect + ** is initialized to the value passed as the isDirectMode parameter + ** to this function. Otherwise, it is always set to zero. + ** + ** The idea is that if the atomic-write optimization is not + ** enabled at compile time, the compiler can omit the tests of + ** 'isDirect' below, as well as the block enclosed in the + ** "if( isDirect )" condition. + */ + _ = isDirectMode + if !((*TPager)(unsafe.Pointer(pPager)).FchangeCountDone != 0) && (*TPager)(unsafe.Pointer(pPager)).FdbSize > uint32(0) { /* Reference to page 1 */ + /* Open page 1 of the file for writing. */ + rc = _sqlite3PagerGet(tls, pPager, uint32(1), bp, 0) + /* If page one was fetched successfully, and this function is not + ** operating in direct-mode, make page 1 writable. When not in + ** direct mode, page 1 is always held in cache and hence the PagerGet() + ** above is always successful - hence the ALWAYS on rc==SQLITE_OK. + */ + if libc.Bool(!(libc.Int32FromInt32(DIRECT_MODE) != 0)) && rc == SQLITE_OK { + rc = _sqlite3PagerWrite(tls, **(**uintptr)(__ccgo_up(bp))) + } + if rc == SQLITE_OK { + /* Actually do the update of the change counter */ + _pager_write_changecounter(tls, **(**uintptr)(__ccgo_up(bp))) + /* If running in direct mode, write the contents of page 1 to the file. */ + if DIRECT_MODE != 0 { + zBuf = (*TPgHdr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpData + if rc == SQLITE_OK { + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, zBuf, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), 0) + **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) = **(**Tu32)(__ccgo_up(pPager + 248 + 2*4)) + 1 + } + if rc == SQLITE_OK { + /* Update the pager's copy of the change-counter. Otherwise, the + ** next time a read transaction is opened the cache will be + ** flushed (as the change-counter values will not match). */ + pCopy = zBuf + 24 + libc.Xmemcpy(tls, pPager+136, pCopy, uint64(16)) + (*TPager)(unsafe.Pointer(pPager)).FchangeCountDone = uint8(1) + } + } else { + (*TPager)(unsafe.Pointer(pPager)).FchangeCountDone = uint8(1) + } + } + /* Release the page reference. */ + _sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xInit method. +// */ +func _pcache1Init(tls *libc.TLS, NotUsed uintptr) (r int32) { + _ = NotUsed + libc.Xmemset(tls, uintptr(unsafe.Pointer(&_pcache1_g)), 0, uint64(144)) + /* + ** The pcache1.separateCache variable is true if each PCache has its own + ** private PGroup (mode-1). pcache1.separateCache is false if the single + ** PGroup in pcache1.grp is used for all page caches (mode-2). + ** + ** * Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT + ** + ** * Use a unified cache in single-threaded applications that have + ** configured a start-time buffer for use as page-cache memory using + ** sqlite3_config(SQLITE_CONFIG_PAGECACHE, pBuf, sz, N) with non-NULL + ** pBuf argument. + ** + ** * Otherwise use separate caches (mode-1) + */ + _pcache1_g.FseparateCache = 0 + if _sqlite3Config.FbCoreMutex != 0 { + _pcache1_g.Fgrp.Fmutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_LRU)) + _pcache1_g.Fmutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_PMEM)) + } + if _pcache1_g.FseparateCache != 0 && _sqlite3Config.FnPage != 0 && _sqlite3Config.FpPage == uintptr(0) { + _pcache1_g.FnInitPage = _sqlite3Config.FnPage + } else { + _pcache1_g.FnInitPage = 0 + } + _pcache1_g.Fgrp.FmxPinned = uint32(10) + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_pcache1_g))+80, int32(1)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xShutdown method. +// ** Note that the static mutex allocated in xInit does +// ** not need to be freed. +// */ +func _pcache1Shutdown(tls *libc.TLS, NotUsed uintptr) { + _ = NotUsed + libc.Xmemset(tls, uintptr(unsafe.Pointer(&_pcache1_g)), 0, uint64(144)) +} + +// C documentation +// +// /* +// ** This is a helper routine for sqlite3PcacheFetchFinish() +// ** +// ** In the uncommon case where the page being fetched has not been +// ** initialized, this routine is invoked to do the initialization. +// ** This routine is broken out into a separate function since it +// ** requires extra stack manipulation that can be avoided in the common +// ** case. +// */ +func _pcacheFetchFinishWithInit(tls *libc.TLS, pCache uintptr, pgno TPgno, pPage uintptr) (r uintptr) { + var pPgHdr uintptr + _ = pPgHdr + pPgHdr = (*Tsqlite3_pcache_page)(unsafe.Pointer(pPage)).FpExtra + libc.Xmemset(tls, pPgHdr+32, 0, libc.Uint64FromInt64(80)-uint64(libc.UintptrFromInt32(0)+32)) + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpPage = pPage + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpData = (*Tsqlite3_pcache_page)(unsafe.Pointer(pPage)).FpBuf + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpExtra = pPgHdr + 1*80 + libc.Xmemset(tls, (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpExtra, 0, uint64(8)) + (*TPgHdr)(unsafe.Pointer(pPgHdr)).FpCache = pCache + (*TPgHdr)(unsafe.Pointer(pPgHdr)).Fpgno = pgno + (*TPgHdr)(unsafe.Pointer(pPgHdr)).Fflags = uint16(PGHDR_CLEAN) + return _sqlite3PcacheFetchFinish(tls, pCache, pgno, pPage) +} + +// C documentation +// +// /* +// ** Sort the list of pages in ascending order by pgno. Pages are +// ** connected by pDirty pointers. The pDirtyPrev pointers are +// ** corrupted by this sort. +// ** +// ** Since there cannot be more than 2^31 distinct pages in a database, +// ** there cannot be more than 31 buckets required by the merge sorter. +// ** One extra bucket is added to catch overflow in case something +// ** ever changes to make the previous sentence incorrect. +// */ +func _pcacheSortDirtyList(tls *libc.TLS, pIn uintptr) (r uintptr) { + bp := tls.Alloc(256) + defer tls.Free(256) + var i int32 + var p, v3 uintptr + var _ /* a at bp+0 */ [32]uintptr + _, _, _ = i, p, v3 + libc.Xmemset(tls, bp, 0, uint64(256)) + for pIn != 0 { + p = pIn + pIn = (*TPgHdr)(unsafe.Pointer(p)).FpDirty + (*TPgHdr)(unsafe.Pointer(p)).FpDirty = uintptr(0) + i = 0 + for { + if !(i < libc.Int32FromInt32(N_SORT_BUCKET)-libc.Int32FromInt32(1)) { + break + } + if (**(**[32]uintptr)(__ccgo_up(bp)))[i] == uintptr(0) { + (**(**[32]uintptr)(__ccgo_up(bp)))[i] = p + break + } else { + p = _pcacheMergeDirtyList(tls, (**(**[32]uintptr)(__ccgo_up(bp)))[i], p) + (**(**[32]uintptr)(__ccgo_up(bp)))[i] = uintptr(0) + } + goto _1 + _1: + ; + i = i + 1 + } + if i == libc.Int32FromInt32(N_SORT_BUCKET)-libc.Int32FromInt32(1) { + /* To get here, there need to be 2^(N_SORT_BUCKET) elements in + ** the input list. But that is impossible. + */ + (**(**[32]uintptr)(__ccgo_up(bp)))[i] = _pcacheMergeDirtyList(tls, (**(**[32]uintptr)(__ccgo_up(bp)))[i], p) + } + } + p = (**(**[32]uintptr)(__ccgo_up(bp)))[0] + i = int32(1) + for { + if !(i < int32(N_SORT_BUCKET)) { + break + } + if (**(**[32]uintptr)(__ccgo_up(bp)))[i] == uintptr(0) { + goto _2 + } + if p != 0 { + v3 = _pcacheMergeDirtyList(tls, p, (**(**[32]uintptr)(__ccgo_up(bp)))[i]) + } else { + v3 = (**(**[32]uintptr)(__ccgo_up(bp)))[i] + } + p = v3 + goto _2 + _2: + ; + i = i + 1 + } + return p +} + +// C documentation +// +// /* Create a new cursor for the pragma virtual table */ +func _pragmaVtabOpen(tls *libc.TLS, pVtab uintptr, ppCursor uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = Xsqlite3_malloc(tls, int32(40)) + if pCsr == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pCsr, 0, uint64(40)) + (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVtab + **(**uintptr)(__ccgo_up(ppCursor)) = pCsr + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Allocate and return an RBU handle with all fields zeroed except for the +// ** error code, which is set to SQLITE_MISUSE. +// */ +func _rbuMisuseError(tls *libc.TLS) (r uintptr) { + var pRet uintptr + _ = pRet + pRet = Xsqlite3_malloc64(tls, uint64(416)) + if pRet != 0 { + libc.Xmemset(tls, pRet, 0, uint64(416)) + (*Tsqlite3rbu)(unsafe.Pointer(pRet)).Frc = int32(SQLITE_MISUSE) + } + return pRet +} + +// C documentation +// +// /* +// ** Clean up any resources allocated as part of the iterator object passed +// ** as the only argument. +// */ +func _rbuObjIterFinalize(tls *libc.TLS, pIter uintptr) { + _rbuObjIterClearStatements(tls, pIter) + Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTblIter) + Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter) + _rbuObjIterFreeCols(tls, pIter) + libc.Xmemset(tls, pIter, 0, uint64(192)) +} + +// C documentation +// +// /* +// ** The first argument must be a nul-terminated string. This function +// ** returns a copy of the string in memory obtained from sqlite3_malloc(). +// ** It is the responsibility of the caller to eventually free this memory +// ** using sqlite3_free(). +// ** +// ** If an OOM condition is encountered when attempting to allocate memory, +// ** output variable (*pRc) is set to SQLITE_NOMEM before returning. Otherwise, +// ** if the allocation succeeds, (*pRc) is left unchanged. +// */ +func _rbuStrndup(tls *libc.TLS, zStr uintptr, pRc uintptr) (r uintptr) { + var nCopy Tsize_t + var zRet uintptr + _, _ = nCopy, zRet + zRet = uintptr(0) + if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK { + if zStr != 0 { + nCopy = libc.Xstrlen(tls, zStr) + uint64(1) + zRet = Xsqlite3_malloc64(tls, nCopy) + if zRet != 0 { + libc.Xmemcpy(tls, zRet, zStr, nCopy) + } else { + **(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM) + } + } + } + return zRet +} + +func _recomputeColumnsUsed(tls *libc.TLS, pSelect uintptr, pSrcItem uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + if (*TSrcItem)(unsafe.Pointer(pSrcItem)).FpSTab == uintptr(0) { + return + } + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_recomputeColumnsUsedExpr) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + *(*uintptr)(unsafe.Pointer(bp + 40)) = pSrcItem + (*TSrcItem)(unsafe.Pointer(pSrcItem)).FcolUsed = uint64(0) + _sqlite3WalkSelect(tls, bp, pSelect) +} + +// C documentation +// +// /* +// ** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming +// ** it was read from the schema of database zDb. Return SQLITE_OK if +// ** successful. Otherwise, return an SQLite error code and leave an error +// ** message in the Parse object. +// */ +func _renameResolveTrigger(tls *libc.TLS, pParse uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, p, pNew, pSel, pSrc, pStep, pUpsert, pUpsertSet uintptr + var i, rc, v2 int32 + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _ = db, i, p, pNew, pSel, pSrc, pStep, pUpsert, pUpsertSet, rc, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger + rc = SQLITE_OK + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = _sqlite3FindTable(tls, db, (*TTrigger)(unsafe.Pointer(pNew)).Ftable, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(_sqlite3SchemaToIndex(tls, db, (*TTrigger)(unsafe.Pointer(pNew)).FpTabSchema))*32))).FzDbSName) + (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = (*TTrigger)(unsafe.Pointer(pNew)).Fop + /* ALWAYS() because if the table of the trigger does not exist, the + ** error would have been hit before this point */ + if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { + rc = libc.BoolInt32(_sqlite3ViewGetColumnNames(tls, pParse, (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab) != 0) + } + /* Resolve symbols in WHEN clause */ + if rc == SQLITE_OK && (*TTrigger)(unsafe.Pointer(pNew)).FpWhen != 0 { + rc = _sqlite3ResolveExprNames(tls, bp, (*TTrigger)(unsafe.Pointer(pNew)).FpWhen) + } + pStep = (*TTrigger)(unsafe.Pointer(pNew)).Fstep_list + for { + if !(rc == SQLITE_OK && pStep != 0) { + break + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect != 0 { + _sqlite3SelectPrep(tls, pParse, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect, bp) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + rc = (*TParse)(unsafe.Pointer(pParse)).Frc + } + } + if rc == SQLITE_OK && (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + pSrc = _sqlite3SrcListDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc, 0) + if pSrc != 0 { + pSel = _sqlite3SelectNew(tls, pParse, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + if pSel == uintptr(0) { + (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList = uintptr(0) + pSrc = uintptr(0) + rc = int32(SQLITE_NOMEM) + } else { + /* pStep->pExprList contains an expression-list used for an UPDATE + ** statement. So the a[].zEName values are the RHS of the + ** "= " clauses of the UPDATE statement. So, before + ** running SelectPrep(), change all the eEName values in + ** pStep->pExprList to ENAME_SPAN (from their current value of + ** ENAME_NAME). This is to prevent any ids in ON() clauses that are + ** part of pSrc from being incorrectly resolved against the + ** a[].zEName values as if they were column aliases. */ + _renameSetENames(tls, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, int32(ENAME_SPAN)) + _sqlite3SelectPrep(tls, pParse, pSel, uintptr(0)) + _renameSetENames(tls, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, ENAME_NAME) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = SQLITE_OK + } + rc = v2 + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList != 0 { + (*TSelect)(unsafe.Pointer(pSel)).FpEList = uintptr(0) + } + (*TSelect)(unsafe.Pointer(pSel)).FpSrc = uintptr(0) + _sqlite3SelectDelete(tls, db, pSel) + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc)).FnSrc && rc == SQLITE_OK) { + break + } + p = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 + uintptr(i)*80 + if int32(*(*uint32)(unsafe.Pointer(p + 24 + 4))&0x4>>2) != 0 { + _sqlite3SelectPrep(tls, pParse, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 72)))).FpSelect, uintptr(0)) + } + goto _3 + _3: + ; + i = i + 1 + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pSrc + if rc == SQLITE_OK && (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere != 0 { + rc = _sqlite3ResolveExprNames(tls, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere) + } + if rc == SQLITE_OK { + rc = _sqlite3ResolveExprListNames(tls, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList) + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0 && rc == SQLITE_OK { + pUpsert = (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert + (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc = pSrc + *(*uintptr)(unsafe.Pointer(bp + 16)) = pUpsert + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = int32(NC_UUpsert) + rc = _sqlite3ResolveExprListNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) + if rc == SQLITE_OK { + pUpsertSet = (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSet + rc = _sqlite3ResolveExprListNames(tls, bp, pUpsertSet) + } + if rc == SQLITE_OK { + rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere) + } + if rc == SQLITE_OK { + rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) + } + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = 0 + } + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = uintptr(0) + _sqlite3SrcListDelete(tls, db, pSrc) + } else { + rc = int32(SQLITE_NOMEM) + } + } + goto _1 + _1: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + return rc +} + +// C documentation +// +// /* +// ** Iterate through the Select objects that are part of WITH clauses attached +// ** to select statement pSelect. +// */ +func _renameWalkWith(tls *libc.TLS, pWalker uintptr, pSelect uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i int32 + var p, pCopy, pParse, pWith uintptr + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _ = i, p, pCopy, pParse, pWith + pWith = (*TSelect)(unsafe.Pointer(pSelect)).FpWith + if pWith != 0 { + pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse + pCopy = uintptr(0) + if (*TSelect)(unsafe.Pointer((*(*TCte)(unsafe.Pointer(pWith + 16))).FpSelect)).FselFlags&uint32(SF_Expanded) == uint32(0) { + /* Push a copy of the With object onto the with-stack. We use a copy + ** here as the original will be expanded and resolved (flags SF_Expanded + ** and SF_Resolved) below. And the parser code that uses the with-stack + ** fails if the Select objects on it have already been expanded and + ** resolved. */ + pCopy = _sqlite3WithDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pWith) + pCopy = _sqlite3WithPush(tls, pParse, pCopy, uint8(1)) + } + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer(pWith)).FnCte) { + break + } + p = (*(*TCte)(unsafe.Pointer(pWith + 16 + uintptr(i)*48))).FpSelect + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + if pCopy != 0 { + _sqlite3SelectPrep(tls, (**(**TNameContext)(__ccgo_up(bp))).FpParse, p, bp) + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((**(**TNameContext)(__ccgo_up(bp))).FpParse)).Fdb)).FmallocFailed != 0 { + return + } + _sqlite3WalkSelect(tls, pWalker, p) + _sqlite3RenameExprlistUnmap(tls, pParse, (*(*TCte)(unsafe.Pointer(pWith + 16 + uintptr(i)*48))).FpCols) + goto _1 + _1: + ; + i = i + 1 + } + if pCopy != 0 && (*TParse)(unsafe.Pointer(pParse)).FpWith == pCopy { + (*TParse)(unsafe.Pointer(pParse)).FpWith = (*TWith)(unsafe.Pointer(pCopy)).FpOuter + } + } +} + +// C documentation +// +// /* +// ** Assign a new cursor number to each cursor in the FROM clause (Select.pSrc) +// ** of the SELECT statement passed as the second argument, and to each +// ** cursor in the FROM clause of any FROM clause sub-selects, recursively. +// ** Except, do not assign a new cursor number to the iExcept'th element in +// ** the FROM clause of (*p). Update all expressions and other references +// ** to refer to the new cursor numbers. +// ** +// ** Argument aCsrMap is an array that may be used for temporary working +// ** space. Two guarantees are made by the caller: +// ** +// ** * the array is larger than the largest cursor number used within the +// ** select statement passed as an argument, and +// ** +// ** * the array entries for all cursor numbers that do *not* appear in +// ** FROM clauses of the select statement as described above are +// ** initialized to zero. +// */ +func _renumberCursors(tls *libc.TLS, pParse uintptr, p uintptr, iExcept int32, aCsrMap uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + _srclistRenumberCursors(tls, pParse, aCsrMap, (*TSelect)(unsafe.Pointer(p)).FpSrc, iExcept) + libc.Xmemset(tls, bp, 0, uint64(48)) + *(*uintptr)(unsafe.Pointer(bp + 40)) = aCsrMap + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_renumberCursorsCb) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + _sqlite3WalkSelect(tls, bp, p) +} + +// C documentation +// +// /* +// ** Reset a cursor back to its initial state. +// */ +func _resetCursor(tls *libc.TLS, pCsr uintptr) { + var i, ii int32 + var pInfo, pRtree, pStmt uintptr + _, _, _, _, _ = i, ii, pInfo, pRtree, pStmt + pRtree = (*TRtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + if (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint != 0 { /* Used to iterate through constraint array */ + i = 0 + for { + if !(i < (*TRtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint) { + break + } + pInfo = (**(**TRtreeConstraint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint + uintptr(i)*24))).FpInfo + if pInfo != 0 { + if (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FxDelUser != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FxDelUser})))(tls, (*Tsqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FpUser) + } + Xsqlite3_free(tls, pInfo) + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = uintptr(0) + } + ii = 0 + for { + if !(ii < int32(RTREE_CACHE_SZ)) { + break + } + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(pCsr + 88 + uintptr(ii)*8))) + goto _2 + _2: + ; + ii = ii + 1 + } + Xsqlite3_free(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FaPoint) + pStmt = (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux + libc.Xmemset(tls, pCsr, 0, uint64(296)) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pRtree + (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux = pStmt + /* The following will only fail if the previous sqlite3_step() call failed, + ** in which case the error has already been caught. This statement never + ** encounters an error within an sqlite3_column_xxx() function, as it + ** calls sqlite3_column_value(), which does not use malloc(). So it is safe + ** to ignore the error code here. */ + Xsqlite3_reset(tls, pStmt) +} + +// C documentation +// +// /* +// ** pE is a pointer to an expression which is a single term in the +// ** ORDER BY of a compound SELECT. The expression has not been +// ** name resolved. +// ** +// ** At the point this routine is called, we already know that the +// ** ORDER BY term is not an integer index into the result set. That +// ** case is handled by the calling routine. +// ** +// ** Attempt to match pE against result set columns in the left-most +// ** SELECT statement. Return the index i of the matching column, +// ** as an indication to the caller that it should sort by the i-th column. +// ** The left-most column is 1. In other words, the value returned is the +// ** same integer value that would be used in the SQL statement to indicate +// ** the column. +// ** +// ** If there is no match, return 0. Return -1 if an error occurs. +// */ +func _resolveOrderByTermToExprList(tls *libc.TLS, pParse uintptr, pSelect uintptr, pE uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pEList uintptr + var i, rc int32 + var savedSuppErr Tu8 + var _ /* nc at bp+0 */ TNameContext + _, _, _, _, _ = db, i, pEList, rc, savedSuppErr /* Saved value of db->suppressErr */ + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + /* Resolve all names in the ORDER BY term expression + */ + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + *(*uintptr)(unsafe.Pointer(bp + 16)) = pEList + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_UEList) | libc.Int32FromInt32(NC_NoSelect) + (**(**TNameContext)(__ccgo_up(bp))).FnNcErr = 0 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + savedSuppErr = (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr + (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr = uint8(1) + rc = _sqlite3ResolveExprNames(tls, bp, pE) + (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr = savedSuppErr + if rc != 0 { + return 0 + } + /* Try to match the ORDER BY expression against an expression + ** in the result set. Return an 1-based index of the matching + ** result-set entry. + */ + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr, pE, -int32(1)) < int32(2) { + return i + int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + /* If no match, return 0. */ + return 0 +} + +// C documentation +// +// /* +// ** Sort all elements on the list of RowSetEntry objects into order of +// ** increasing v. +// */ +func _rowSetEntrySort(tls *libc.TLS, pIn uintptr) (r uintptr) { + bp := tls.Alloc(320) + defer tls.Free(320) + var i uint32 + var pNext, v3 uintptr + var _ /* aBucket at bp+0 */ [40]uintptr + _, _, _ = i, pNext, v3 + libc.Xmemset(tls, bp, 0, uint64(320)) + for pIn != 0 { + pNext = (*TRowSetEntry)(unsafe.Pointer(pIn)).FpRight + (*TRowSetEntry)(unsafe.Pointer(pIn)).FpRight = uintptr(0) + i = uint32(0) + for { + if !((**(**[40]uintptr)(__ccgo_up(bp)))[i] != 0) { + break + } + pIn = _rowSetEntryMerge(tls, (**(**[40]uintptr)(__ccgo_up(bp)))[i], pIn) + (**(**[40]uintptr)(__ccgo_up(bp)))[i] = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + (**(**[40]uintptr)(__ccgo_up(bp)))[i] = pIn + pIn = pNext + } + pIn = (**(**[40]uintptr)(__ccgo_up(bp)))[0] + i = uint32(1) + for { + if !(uint64(i) < libc.Uint64FromInt64(320)/libc.Uint64FromInt64(8)) { + break + } + if (**(**[40]uintptr)(__ccgo_up(bp)))[i] == uintptr(0) { + goto _2 + } + if pIn != 0 { + v3 = _rowSetEntryMerge(tls, pIn, (**(**[40]uintptr)(__ccgo_up(bp)))[i]) + } else { + v3 = (**(**[40]uintptr)(__ccgo_up(bp)))[i] + } + pIn = v3 + goto _2 + _2: + ; + i = i + 1 + } + return pIn +} + +// C documentation +// +// /* +// ** Rtree virtual table module xOpen method. +// */ +func _rtreeOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) (r int32) { + var pCsr, pRtree uintptr + var rc int32 + _, _, _ = pCsr, pRtree, rc + rc = int32(SQLITE_NOMEM) + pRtree = pVTab + pCsr = Xsqlite3_malloc64(tls, uint64(296)) + if pCsr != 0 { + libc.Xmemset(tls, pCsr, 0, uint64(296)) + (*TRtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab + rc = SQLITE_OK + (*TRtree)(unsafe.Pointer(pRtree)).FnCursor = (*TRtree)(unsafe.Pointer(pRtree)).FnCursor + 1 + } + **(**uintptr)(__ccgo_up(ppCursor)) = pCsr + return rc +} + +// C documentation +// +// /* +// ** Iterate through each expression in expression-list pEList. For each: +// ** +// ** * TK_COLUMN, +// ** * aggregate function, or +// ** * window function with a Window object that is not a member of the +// ** Window list passed as the second argument (pWin). +// ** +// ** Append the node to output expression-list (*ppSub). And replace it +// ** with a TK_COLUMN that reads the (N-1)th element of table +// ** pWin->iEphCsr, where N is the number of elements in (*ppSub) after +// ** appending the new one. +// */ +func _selectWindowRewriteEList(tls *libc.TLS, pParse uintptr, pWin uintptr, pSrc uintptr, pEList uintptr, pTab uintptr, ppSub uintptr) { + bp := tls.Alloc(96) + defer tls.Free(96) + var _ /* sRewrite at bp+48 */ TWindowRewrite + var _ /* sWalker at bp+0 */ TWalker + libc.Xmemset(tls, bp, 0, uint64(48)) + libc.Xmemset(tls, bp+48, 0, uint64(40)) + (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpSub = **(**uintptr)(__ccgo_up(ppSub)) + (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpWin = pWin + (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpSrc = pSrc + (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpTab = pTab + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_selectWindowRewriteExprCb) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_selectWindowRewriteSelectCb) + *(*uintptr)(unsafe.Pointer(bp + 40)) = bp + 48 + _sqlite3WalkExprList(tls, bp, pEList) + **(**uintptr)(__ccgo_up(ppSub)) = (**(**TWindowRewrite)(__ccgo_up(bp + 48))).FpSub +} + +// C documentation +// +// /* +// ** Do the work for either sqlite3changeset_start() or start_strm(). +// */ +func _sessionChangesetStart(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, nChangeset int32, pChangeset uintptr, bInvert int32, bSkipEmpty int32) (r int32) { + var nByte, v1 int32 + var pRet uintptr + _, _, _ = nByte, pRet, v1 /* Number of bytes to allocate for iterator */ + /* Zero the output variable in case an error occurs. */ + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + /* Allocate and initialize the iterator structure. */ + nByte = int32(152) + pRet = Xsqlite3_malloc(tls, nByte) + if !(pRet != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pRet, 0, uint64(152)) + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FaData = pChangeset + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FnData = nChangeset + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FxInput = __ccgo_fp_xInput + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FpIn = pIn + if __ccgo_fp_xInput != 0 { + v1 = 0 + } else { + v1 = int32(1) + } + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FbEof = v1 + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).FbInvert = bInvert + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pRet)).FbSkipEmpty = bSkipEmpty + /* Populate the output variable and return success. */ + **(**uintptr)(__ccgo_up(pp)) = pRet + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Initialize a Walker object so that will persist AggInfo entries referenced +// ** by the tree that is walked. +// */ +func _sqlite3AggInfoPersistWalkerInit(tls *libc.TLS, pWalker uintptr, pParse uintptr) { + libc.Xmemset(tls, pWalker, 0, uint64(48)) + (*TWalker)(unsafe.Pointer(pWalker)).FpParse = pParse + (*TWalker)(unsafe.Pointer(pWalker)).FxExprCallback = __ccgo_fp(_agginfoPersistExprCb) + (*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) +} + +// C documentation +// +// /* +// ** Initialize memory that will be converted into a BtCursor object. +// ** +// ** The simple approach here would be to memset() the entire object +// ** to zero. But it turns out that the apPage[] and aiIdx[] arrays +// ** do not need to be zeroed and they are large, so we can save a lot +// ** of run-time by skipping the initialization of those elements. +// */ +func _sqlite3BtreeCursorZero(tls *libc.TLS, p uintptr) { + libc.Xmemset(tls, p, 0, uint64(libc.UintptrFromInt32(0)+32)) +} + +// C documentation +// +// /* +// ** Look through the list of open database files in db->aDb[] and if +// ** any have been closed, remove them from the list. Reallocate the +// ** db->aDb[] structure to a smaller size, if possible. +// ** +// ** Entry 0 (the "main" database) and entry 1 (the "temp" database) +// ** are never candidates for being collapsed. +// */ +func _sqlite3CollapseDatabaseArray(tls *libc.TLS, db uintptr) { + var i, j, v2 int32 + var pDb uintptr + _, _, _, _ = i, j, pDb, v2 + v2 = libc.Int32FromInt32(2) + j = v2 + i = v2 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpBt == uintptr(0) { + _sqlite3DbFree(tls, db, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) + (*TDb)(unsafe.Pointer(pDb)).FzDbSName = uintptr(0) + goto _1 + } + if j < i { + **(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*32)) = **(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)) + } + j = j + 1 + goto _1 + _1: + ; + i = i + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FnDb = j + if (*Tsqlite3)(unsafe.Pointer(db)).FnDb <= int32(2) && (*Tsqlite3)(unsafe.Pointer(db)).FaDb != db+696 { + libc.Xmemcpy(tls, db+696, (*Tsqlite3)(unsafe.Pointer(db)).FaDb, libc.Uint64FromInt32(2)*libc.Uint64FromInt64(32)) + _sqlite3DbFree(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaDb) + (*Tsqlite3)(unsafe.Pointer(db)).FaDb = db + 696 + } +} + +// C documentation +// +// /* +// ** Allocate and zero memory. If the allocation fails, make +// ** the mallocFailed flag in the connection pointer. +// */ +func _sqlite3DbMallocZero(tls *libc.TLS, db uintptr, n Tu64) (r uintptr) { + var p uintptr + _ = p + p = _sqlite3DbMallocRaw(tls, db, n) + if p != 0 { + libc.Xmemset(tls, p, 0, n) + } + return p +} + +// C documentation +// +// /* +// ** Make a copy of a string in memory obtained from sqliteMalloc(). These +// ** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This +// ** is because when memory debugging is turned on, these two functions are +// ** called via macros that record the current file and line number in the +// ** ThreadData structure. +// */ +func _sqlite3DbStrDup(tls *libc.TLS, db uintptr, z uintptr) (r uintptr) { + var n Tsize_t + var zNew uintptr + _, _ = n, zNew + if z == uintptr(0) { + return uintptr(0) + } + n = libc.Xstrlen(tls, z) + uint64(1) + zNew = _sqlite3DbMallocRaw(tls, db, n) + if zNew != 0 { + libc.Xmemcpy(tls, zNew, z, n) + } + return zNew +} + +// C documentation +// +// /* +// ** Determine if an index pIdx on table with cursor iCur contains will +// ** the expression pExpr. Return true if the index does cover the +// ** expression and false if the pExpr expression references table columns +// ** that are not found in the index pIdx. +// ** +// ** An index covering an expression means that the expression can be +// ** evaluated using only the index and without having to lookup the +// ** corresponding table entry. +// */ +func _sqlite3ExprCoveredByIndex(tls *libc.TLS, pExpr uintptr, iCur int32, pIdx uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var _ /* w at bp+0 */ TWalker + var _ /* xcov at bp+48 */ TIdxCover + libc.Xmemset(tls, bp, 0, uint64(48)) + (**(**TIdxCover)(__ccgo_up(bp + 48))).FiCur = iCur + (**(**TIdxCover)(__ccgo_up(bp + 48))).FpIdx = pIdx + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprIdxCover) + *(*uintptr)(unsafe.Pointer(bp + 40)) = bp + 48 + _sqlite3WalkExpr(tls, bp, pExpr) + return libc.BoolInt32(!((**(**TWalker)(__ccgo_up(bp))).FeCode != 0)) +} + +// C documentation +// +// /* +// ** The following set of routines walk through the parse tree and assign +// ** a specific database to all table references where the database name +// ** was left unspecified in the original SQL statement. The pFix structure +// ** must have been initialized by a prior call to sqlite3FixInit(). +// ** +// ** These routines are used to make sure that an index, trigger, or +// ** view in one database does not refer to objects in a different database. +// ** (Exception: indices, triggers, and views in the TEMP database are +// ** allowed to refer to anything.) If a reference is explicitly made +// ** to an object in a different database, an error message is added to +// ** pParse->zErrMsg and these routines return non-zero. If everything +// ** checks out, these routines return 0. +// */ +func _sqlite3FixSrcList(tls *libc.TLS, pFix uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var res int32 + var _ /* s at bp+0 */ TSelect + _ = res + res = 0 + if pList != 0 { + libc.Xmemset(tls, bp, 0, uint64(120)) + (**(**TSelect)(__ccgo_up(bp))).FpSrc = pList + res = _sqlite3WalkSelect(tls, pFix+8, bp) + } + return res +} + +// C documentation +// +// /* +// ** Free any buffer allocated by pBuf. Zero the structure before returning. +// */ +func _sqlite3Fts5BufferFree(tls *libc.TLS, pBuf uintptr) { + Xsqlite3_free(tls, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp) + libc.Xmemset(tls, pBuf, 0, uint64(16)) +} + +// C documentation +// +// /* +// ** Return true if the floating point value is Not a Number (NaN). +// ** +// ** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN. +// ** Otherwise, we have our own implementation that works on most systems. +// */ +func _sqlite3IsNaN(tls *libc.TLS, _x float64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*float64)(unsafe.Pointer(bp)) = _x + var rc int32 + var _ /* y at bp+8 */ Tu64 + _ = rc + libc.Xmemcpy(tls, bp+8, bp, uint64(8)) + rc = libc.BoolInt32(**(**Tu64)(__ccgo_up(bp + 8))&(libc.Uint64FromInt32(0x7ff)<>0)) == ENAME_NAME { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName) + } + goto _1 + _1: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** Resolve names in expressions that can only reference a single table +// ** or which cannot reference any tables at all. Examples: +// ** +// ** "type" flag +// ** ------------ +// ** (1) CHECK constraints NC_IsCheck +// ** (2) WHERE clauses on partial indices NC_PartIdx +// ** (3) Expressions in indexes on expressions NC_IdxExpr +// ** (4) Expression arguments to VACUUM INTO. 0 +// ** (5) GENERATED ALWAYS as expressions NC_GenCol +// ** +// ** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN +// ** nodes of the expression is set to -1 and the Expr.iColumn value is +// ** set to the column number. In case (4), TK_COLUMN nodes cause an error. +// ** +// ** Any errors cause an error message to be set in pParse. +// */ +func _sqlite3ResolveSelfReference(tls *libc.TLS, pParse uintptr, pTab uintptr, type1 int32, pExpr uintptr, pList uintptr) (r int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var pSrc uintptr + var rc, v1 int32 + var _ /* sNC at bp+0 */ TNameContext + var _ /* uSrc at bp+56 */ struct { + FsrcSpace [0][88]Tu8 + FsSrc TSrcList + F__ccgo_pad2 [80]byte + } + _, _, _ = pSrc, rc, v1 + libc.Xmemset(tls, bp, 0, uint64(56)) + libc.Xmemset(tls, bp+56, 0, uint64(88)) + pSrc = bp + 56 + if pTab != 0 { + (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc = int32(1) + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FzName = (*TTable)(unsafe.Pointer(pTab)).FzName + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FpSTab = pTab + (*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).FiCursor = -int32(1) + if (*TTable)(unsafe.Pointer(pTab)).FpSchema != (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + 1*32))).FpSchema { + /* Cause EP_FromDDL to be set on TK_FUNCTION nodes of non-TEMP + ** schema elements */ + type1 = type1 | int32(NC_FromDDL) + } + } + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pSrc + (**(**TNameContext)(__ccgo_up(bp))).FncFlags = type1 | int32(NC_IsDDL) + v1 = _sqlite3ResolveExprNames(tls, bp, pExpr) + rc = v1 + if v1 != SQLITE_OK { + return rc + } + if pList != 0 { + rc = _sqlite3ResolveExprListNames(tls, bp, pList) + } + return rc +} + +// C documentation +// +// /* +// ** Attach a Subquery object to pItem->uv.pSubq. Set the +// ** pSelect value but leave all the other values initialized +// ** to zero. +// ** +// ** A copy of the Select object is made if dupSelect is true, and the +// ** SrcItem takes responsibility for deleting the copy. If dupSelect is +// ** false, ownership of the Select passes to the SrcItem. Either way, +// ** the SrcItem will take responsibility for deleting the Select. +// ** +// ** When dupSelect is zero, that means the Select might get deleted right +// ** away if there is an OOM error. Beware. +// ** +// ** Return non-zero on success. Return zero on an OOM error. +// */ +func _sqlite3SrcItemAttachSubquery(tls *libc.TLS, pParse uintptr, pItem uintptr, pSelect uintptr, dupSelect int32) (r int32) { + var p, v1 uintptr + _, _ = p, v1 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) != 0 { + *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(0), 16, 0x10000) + } else { + if *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(pItem + 72))) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) + } + } + if dupSelect != 0 { + pSelect = _sqlite3SelectDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect, 0) + if pSelect == uintptr(0) { + return 0 + } + } + v1 = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(24)) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = v1 + p = v1 + if p == uintptr(0) { + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect) + return 0 + } + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 2, 0x4) + (*TSubquery)(unsafe.Pointer(p)).FpSelect = pSelect + libc.Xmemset(tls, p+uintptr(8), 0, libc.Uint64FromInt64(24)-libc.Uint64FromInt64(8)) + return int32(1) +} + +// C documentation +// +// /* +// ** Convert a UTF-16 string in the native encoding into a UTF-8 string. +// ** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must +// ** be freed by the calling function. +// ** +// ** NULL is returned if there is an allocation error. +// */ +func _sqlite3Utf16to8(tls *libc.TLS, db uintptr, z uintptr, nByte int32, enc Tu8) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var _ /* m at bp+0 */ TMem + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TMem)(__ccgo_up(bp))).Fdb = db + _sqlite3VdbeMemSetStr(tls, bp, z, int64(nByte), enc, libc.UintptrFromInt32(0)) + _sqlite3VdbeChangeEncoding(tls, bp, int32(SQLITE_UTF8)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3VdbeMemRelease(tls, bp) + (**(**TMem)(__ccgo_up(bp))).Fz = uintptr(0) + } + return (**(**TMem)(__ccgo_up(bp))).Fz +} + +// C documentation +// +// /* +// ** Add an opcode that includes the p4 value with a P4_INT64 or +// ** P4_REAL type. +// */ +func _sqlite3VdbeAddOp4Dup8(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, zP4 uintptr, p4type int32) (r int32) { + var p4copy uintptr + _ = p4copy + p4copy = _sqlite3DbMallocRawNN(tls, _sqlite3VdbeDb(tls, p), uint64(8)) + if p4copy != 0 { + libc.Xmemcpy(tls, p4copy, zP4, uint64(8)) + } + return _sqlite3VdbeAddOp4(tls, p, op, p1, p2, p3, p4copy, p4type) +} + +// C documentation +// +// /* +// ** Create a new virtual database engine. +// */ +func _sqlite3VdbeCreate(tls *libc.TLS, pParse uintptr) (r uintptr) { + var db, p uintptr + _, _ = db, p + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + p = _sqlite3DbMallocRawNN(tls, db, uint64(304)) + if p == uintptr(0) { + return uintptr(0) + } + libc.Xmemset(tls, p+136, 0, libc.Uint64FromInt64(304)-uint64(libc.UintptrFromInt32(0)+136)) + (*TVdbe)(unsafe.Pointer(p)).Fdb = db + if (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe != 0 { + (*TVdbe)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpVdbe)).FppVPrev = p + 16 + } + (*TVdbe)(unsafe.Pointer(p)).FpVNext = (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe + (*TVdbe)(unsafe.Pointer(p)).FppVPrev = db + 8 + (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe = p + (*TVdbe)(unsafe.Pointer(p)).FpParse = pParse + (*TParse)(unsafe.Pointer(pParse)).FpVdbe = p + _sqlite3VdbeAddOp2(tls, p, int32(OP_Init), 0, int32(1)) + return p +} + +// C documentation +// +// /* +// ** Memory cell pAccum contains the context of an aggregate function. +// ** This routine calls the xValue method for that function and stores +// ** the results in memory cell pMem. +// ** +// ** SQLITE_ERROR is returned if xValue() reports an error. SQLITE_OK +// ** otherwise. +// */ +func _sqlite3VdbeMemAggValue(tls *libc.TLS, pAccum uintptr, pOut uintptr, pFunc uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* ctx at bp+0 */ Tsqlite3_context + libc.Xmemset(tls, bp, 0, uint64(48)) + _sqlite3VdbeMemSetNull(tls, pOut) + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpOut = pOut + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpMem = pAccum + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpFunc = pFunc + (**(**Tsqlite3_context)(__ccgo_up(bp))).Fenc = (*Tsqlite3)(unsafe.Pointer((*TMem)(unsafe.Pointer(pAccum)).Fdb)).Fenc + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer(pFunc)).FxValue})))(tls, bp) + return (**(**Tsqlite3_context)(__ccgo_up(bp))).FisError +} + +// C documentation +// +// /* +// ** Memory cell pMem contains the context of an aggregate function. +// ** This routine calls the finalize method for that function. The +// ** result of the aggregate is stored back into pMem. +// ** +// ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK +// ** otherwise. +// */ +func _sqlite3VdbeMemFinalize(tls *libc.TLS, pMem uintptr, pFunc uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var _ /* ctx at bp+0 */ Tsqlite3_context + var _ /* t at bp+48 */ TMem + libc.Xmemset(tls, bp, 0, uint64(48)) + libc.Xmemset(tls, bp+48, 0, uint64(56)) + (**(**TMem)(__ccgo_up(bp + 48))).Fflags = uint16(MEM_Null) + (**(**TMem)(__ccgo_up(bp + 48))).Fdb = (*TMem)(unsafe.Pointer(pMem)).Fdb + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpOut = bp + 48 + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpMem = pMem + (**(**Tsqlite3_context)(__ccgo_up(bp))).FpFunc = pFunc + (**(**Tsqlite3_context)(__ccgo_up(bp))).Fenc = (*Tsqlite3)(unsafe.Pointer((**(**TMem)(__ccgo_up(bp + 48))).Fdb)).Fenc + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer(pFunc)).FxFinalize})))(tls, bp) /* IMP: R-24505-23230 */ + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc > 0 { + _sqlite3DbFreeNN(tls, (*TMem)(unsafe.Pointer(pMem)).Fdb, (*TMem)(unsafe.Pointer(pMem)).FzMalloc) + } + libc.Xmemcpy(tls, pMem, bp+48, uint64(56)) + return (**(**Tsqlite3_context)(__ccgo_up(bp))).FisError +} + +// C documentation +// +// /* +// ** Transfer the contents of pFrom to pTo. Any existing value in pTo is +// ** freed. If pFrom contains ephemeral data, a copy is made. +// ** +// ** pFrom contains an SQL NULL when this routine returns. +// */ +func _sqlite3VdbeMemMove(tls *libc.TLS, pTo uintptr, pFrom uintptr) { + _sqlite3VdbeMemRelease(tls, pTo) + libc.Xmemcpy(tls, pTo, pFrom, uint64(56)) + (*TMem)(unsafe.Pointer(pFrom)).Fflags = uint16(MEM_Null) + (*TMem)(unsafe.Pointer(pFrom)).FszMalloc = 0 +} + +// C documentation +// +// /* +// ** Swap byte-code between two VDBE structures. +// ** +// ** This happens after pB was previously run and returned +// ** SQLITE_SCHEMA. The statement was then reprepared in pA. +// ** This routine transfers the new bytecode in pA over to pB +// ** so that pB can be run again. The old pB byte code is +// ** moved back to pA so that it will be cleaned up when pA is +// ** finalized. +// */ +func _sqlite3VdbeSwap(tls *libc.TLS, pA uintptr, pB uintptr) { + var pTmp, ppTmp, zTmp uintptr + var tmp TVdbe + _, _, _, _ = pTmp, ppTmp, tmp, zTmp + tmp = **(**TVdbe)(__ccgo_up(pA)) + **(**TVdbe)(__ccgo_up(pA)) = **(**TVdbe)(__ccgo_up(pB)) + **(**TVdbe)(__ccgo_up(pB)) = tmp + pTmp = (*TVdbe)(unsafe.Pointer(pA)).FpVNext + (*TVdbe)(unsafe.Pointer(pA)).FpVNext = (*TVdbe)(unsafe.Pointer(pB)).FpVNext + (*TVdbe)(unsafe.Pointer(pB)).FpVNext = pTmp + ppTmp = (*TVdbe)(unsafe.Pointer(pA)).FppVPrev + (*TVdbe)(unsafe.Pointer(pA)).FppVPrev = (*TVdbe)(unsafe.Pointer(pB)).FppVPrev + (*TVdbe)(unsafe.Pointer(pB)).FppVPrev = ppTmp + zTmp = (*TVdbe)(unsafe.Pointer(pA)).FzSql + (*TVdbe)(unsafe.Pointer(pA)).FzSql = (*TVdbe)(unsafe.Pointer(pB)).FzSql + (*TVdbe)(unsafe.Pointer(pB)).FzSql = zTmp + (*TVdbe)(unsafe.Pointer(pB)).Fexpmask = (*TVdbe)(unsafe.Pointer(pA)).Fexpmask + (*TVdbe)(unsafe.Pointer(pB)).FprepFlags = (*TVdbe)(unsafe.Pointer(pA)).FprepFlags + libc.Xmemcpy(tls, pB+212, pA+212, uint64(36)) + **(**Tu32)(__ccgo_up(pB + 212 + 5*4)) = **(**Tu32)(__ccgo_up(pB + 212 + 5*4)) + 1 +} + +// C documentation +// +// /* Create a snapshot object. The content of a snapshot is opaque to +// ** every other subsystem, so the WAL module can put whatever it needs +// ** in the object. +// */ +func _sqlite3WalSnapshotGet(tls *libc.TLS, pWal uintptr, ppSnapshot uintptr) (r int32) { + var pRet uintptr + var rc int32 + _, _ = pRet, rc + rc = SQLITE_OK + if libc.Xmemcmp(tls, pWal+72+24, uintptr(unsafe.Pointer(&_aZero)), uint64(16)) == 0 { + **(**uintptr)(__ccgo_up(ppSnapshot)) = uintptr(0) + return int32(SQLITE_ERROR) + } + pRet = Xsqlite3_malloc(tls, int32(48)) + if pRet == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemcpy(tls, pRet, pWal+72, uint64(48)) + **(**uintptr)(__ccgo_up(ppSnapshot)) = pRet + } + return rc +} + +// C documentation +// +// /* +// ** If any data has been written (but not committed) to the log file, this +// ** function moves the write-pointer back to the start of the transaction. +// ** +// ** Additionally, the callback function is invoked for each frame written +// ** to the WAL since the start of the transaction. If the callback returns +// ** other than SQLITE_OK, it is not invoked again and the error code is +// ** returned to the caller. +// ** +// ** Otherwise, if the callback function does not return an error, this +// ** function returns SQLITE_OK. +// */ +func _sqlite3WalUndo(tls *libc.TLS, pWal uintptr, __ccgo_fp_xUndo uintptr, pUndoCtx uintptr) (r int32) { + var iFrame, iMax TPgno + var rc int32 + _, _, _ = iFrame, iMax, rc + rc = SQLITE_OK + if (*TWal)(unsafe.Pointer(pWal)).FwriteLock != 0 { + iMax = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + /* Restore the clients cache of the wal-index header to the state it + ** was in before the client began writing to the database. + */ + libc.Xmemcpy(tls, pWal+72, _walIndexHdr(tls, pWal), uint64(48)) + iFrame = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + uint32(1) + for { + if !(rc == SQLITE_OK && iFrame <= iMax) { + break + } + /* This call cannot fail. Unless the page for which the page number + ** is passed as the second argument is (a) in the cache and + ** (b) has an outstanding reference, then xUndo is either a no-op + ** (if (a) is false) or simply expels the page from the cache (if (b) + ** is false). + ** + ** If the upper layer is doing a rollback, it is guaranteed that there + ** are no outstanding references to any page other than page 1. And + ** page 1 is never written to the log until the transaction is + ** committed. As a result, the call to xUndo may not fail. + */ + rc = (*(*func(*libc.TLS, uintptr, TPgno) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xUndo})))(tls, pUndoCtx, _walFramePgno(tls, pWal, iFrame)) + goto _1 + _1: + ; + iFrame = iFrame + 1 + } + if iMax != (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { + _walCleanupHash(tls, pWal) + } + (*TWal)(unsafe.Pointer(pWal)).FiReCksum = uint32(0) + } + return rc +} + +func _sqlite3WhereRealloc(tls *libc.TLS, pWInfo uintptr, pOld uintptr, nByte Tu64) (r uintptr) { + var pNew, pOldBlk uintptr + _, _ = pNew, pOldBlk + pNew = _sqlite3WhereMalloc(tls, pWInfo, nByte) + if pNew != 0 && pOld != 0 { + pOldBlk = pOld + pOldBlk -= 16 + libc.Xmemcpy(tls, pNew, pOld, (*TWhereMemBlock)(unsafe.Pointer(pOldBlk)).Fsz) + } + return pNew +} + +func _statClearPage(tls *libc.TLS, p uintptr) { + var aPg uintptr + _ = aPg + aPg = (*TStatPage)(unsafe.Pointer(p)).FaPg + _statClearCells(tls, p) + Xsqlite3_free(tls, (*TStatPage)(unsafe.Pointer(p)).FzPath) + libc.Xmemset(tls, p, 0, uint64(64)) + (*TStatPage)(unsafe.Pointer(p)).FaPg = aPg +} + +// C documentation +// +// /* +// ** Open a new DBSTAT cursor. +// */ +func _statOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) (r int32) { + var pCsr, pTab uintptr + _, _ = pCsr, pTab + pTab = pVTab + pCsr = Xsqlite3_malloc64(tls, uint64(2152)) + if pCsr == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pCsr, 0, uint64(2152)) + (*TStatCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab + (*TStatCursor)(unsafe.Pointer(pCsr)).FiDb = (*TStatTable)(unsafe.Pointer(pTab)).FiDb + } + **(**uintptr)(__ccgo_up(ppCursor)) = pCsr + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Finish off a string by making sure it is zero-terminated. +// ** Return a pointer to the resulting string. Return a NULL +// ** pointer if any kind of error was encountered. +// */ +func _strAccumFinishRealloc(tls *libc.TLS, p uintptr) (r uintptr) { + var zText, v1 uintptr + _, _ = zText, v1 + zText = _sqlite3DbMallocRaw(tls, (*TStrAccum)(unsafe.Pointer(p)).Fdb, uint64(1)+uint64((*TStrAccum)(unsafe.Pointer(p)).FnChar)) + if zText != 0 { + libc.Xmemcpy(tls, zText, (*TStrAccum)(unsafe.Pointer(p)).FzText, uint64((*TStrAccum)(unsafe.Pointer(p)).FnChar+uint32(1))) + v1 = p + 29 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) + } else { + _sqlite3StrAccumSetError(tls, p, uint8(SQLITE_NOMEM)) + } + (*TStrAccum)(unsafe.Pointer(p)).FzText = zText + return zText +} + +// C documentation +// +// /* +// ** This routine is called if the collation factory fails to deliver a +// ** collation function in the best encoding but there may be other versions +// ** of this collation function (for other text encodings) available. Use one +// ** of these instead if they exist. Avoid a UTF-8 <-> UTF-16 conversion if +// ** possible. +// */ +func _synthCollSeq(tls *libc.TLS, db uintptr, pColl uintptr) (r int32) { + var i int32 + var pColl2, z uintptr + _, _, _ = i, pColl2, z + z = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + i = 0 + for { + if !(i < int32(3)) { + break + } + pColl2 = _sqlite3FindCollSeq(tls, db, _aEnc[i], z, 0) + if (*TCollSeq)(unsafe.Pointer(pColl2)).FxCmp != uintptr(0) { + libc.Xmemcpy(tls, pColl, pColl2, uint64(40)) + (*TCollSeq)(unsafe.Pointer(pColl)).FxDel = uintptr(0) /* Do not copy the destructor */ + return SQLITE_OK + } + goto _1 + _1: + ; + i = i + 1 + } + return int32(SQLITE_ERROR) +} + +// C documentation +// +// /* +// ** Free all memory belonging to the PmaReader object passed as the +// ** argument. All structure fields are set to zero before returning. +// */ +func _vdbePmaReaderClear(tls *libc.TLS, pReadr uintptr) { + Xsqlite3_free(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FaAlloc) + Xsqlite3_free(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FaBuffer) + if (*TPmaReader)(unsafe.Pointer(pReadr)).FaMap != 0 { + _sqlite3OsUnfetch(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FpFd, 0, (*TPmaReader)(unsafe.Pointer(pReadr)).FaMap) + } + _vdbeIncrFree(tls, (*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr) + libc.Xmemset(tls, pReadr, 0, uint64(80)) +} + +// C documentation +// +// /* +// ** Free all resources owned by the object indicated by argument pTask. All +// ** fields of *pTask are zeroed before returning. +// */ +func _vdbeSortSubtaskCleanup(tls *libc.TLS, db uintptr, pTask uintptr) { + _sqlite3DbFree(tls, db, (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked) + /* pTask->list.aMemory can only be non-zero if it was handed memory + ** from the main thread. That only occurs SQLITE_MAX_WORKER_THREADS>0 */ + if (*TSortSubtask)(unsafe.Pointer(pTask)).Flist.FaMemory != 0 { + Xsqlite3_free(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).Flist.FaMemory) + } else { + _vdbeSorterRecordFree(tls, uintptr(0), (*TSortSubtask)(unsafe.Pointer(pTask)).Flist.FpList) + } + if (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd != 0 { + _sqlite3OsCloseFree(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd) + } + if (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd != 0 { + _sqlite3OsCloseFree(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd) + } + libc.Xmemset(tls, pTask, 0, uint64(104)) +} + +// C documentation +// +// /* +// ** This function does the work of sqlite3WalBeginReadTransaction() (see +// ** below). That function simply calls this one inside an SEH_TRY{...} block. +// */ +func _walBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bChanged, ckptLock, rc int32 + var pInfo, pSnapshot uintptr + var _ /* cnt at bp+0 */ int32 + _, _, _, _, _ = bChanged, ckptLock, pInfo, pSnapshot, rc /* Return code */ + **(**int32)(__ccgo_up(bp)) = 0 /* Number of TryBeginRead attempts */ + ckptLock = 0 + bChanged = 0 + pSnapshot = (*TWal)(unsafe.Pointer(pWal)).FpSnapshot + if pSnapshot != 0 { + if libc.Xmemcmp(tls, pSnapshot, pWal+72, uint64(48)) != 0 { + bChanged = int32(1) + } + /* It is possible that there is a checkpointer thread running + ** concurrent with this code. If this is the case, it may be that the + ** checkpointer has already determined that it will checkpoint + ** snapshot X, where X is later in the wal file than pSnapshot, but + ** has not yet set the pInfo->nBackfillAttempted variable to indicate + ** its intent. To avoid the race condition this leads to, ensure that + ** there is no checkpointer process by taking a shared CKPT lock + ** before checking pInfo->nBackfillAttempted. */ + rc = _walLockShared(tls, pWal, int32(WAL_CKPT_LOCK)) + if rc != SQLITE_OK { + return rc + } + ckptLock = int32(1) + } + for cond := true; cond; cond = rc == -int32(1) { + rc = _walTryBeginRead(tls, pWal, pChanged, 0, bp) + } + if rc == SQLITE_OK { + if pSnapshot != 0 && libc.Xmemcmp(tls, pSnapshot, pWal+72, uint64(48)) != 0 { + /* At this point the client has a lock on an aReadMark[] slot holding + ** a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr + ** is populated with the wal-index header corresponding to the head + ** of the wal file. Verify that pSnapshot is still valid before + ** continuing. Reasons why pSnapshot might no longer be valid: + ** + ** (1) The WAL file has been reset since the snapshot was taken. + ** In this case, the salt will have changed. + ** + ** (2) A checkpoint as been attempted that wrote frames past + ** pSnapshot->mxFrame into the database file. Note that the + ** checkpoint need not have completed for this to cause problems. + */ + pInfo = _walCkptInfo(tls, pWal) + /* Check that the wal file has not been wrapped. Assuming that it has + ** not, also check that no checkpointer has attempted to checkpoint any + ** frames beyond pSnapshot->mxFrame. If either of these conditions are + ** true, return SQLITE_ERROR_SNAPSHOT. Otherwise, overwrite pWal->hdr + ** with *pSnapshot and set *pChanged as appropriate for opening the + ** snapshot. */ + if !(libc.Xmemcmp(tls, pSnapshot+32, pWal+72+32, uint64(8)) != 0) && (*TWalIndexHdr)(unsafe.Pointer(pSnapshot)).FmxFrame >= (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted { + libc.Xmemcpy(tls, pWal+72, pSnapshot, uint64(48)) + **(**int32)(__ccgo_up(pChanged)) = bChanged + } else { + rc = libc.Int32FromInt32(SQLITE_ERROR) | libc.Int32FromInt32(3)<= 0 && N < **(**int32)(__ccgo_up(bp)) { + return **(**uintptr)(__ccgo_up(azCompileOpt + uintptr(N)*8)) + } + return uintptr(0) +} + +/************** End of main.c ************************************************/ +/************** Begin file notify.c ******************************************/ +/* +** 2009 March 3 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains the implementation of the sqlite3_unlock_notify() +** API method and its associated functionality. + */ +/* #include "sqliteInt.h" */ +/* #include "btreeInt.h" */ + +/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ + +/* +** Public interfaces: +** +** sqlite3ConnectionBlocked() +** sqlite3ConnectionUnlocked() +** sqlite3ConnectionClosed() +** sqlite3_unlock_notify() + */ + +// C documentation +// +// /* +// ** Flush any dirty pages in the pager-cache for any attached database +// ** to disk. +// */ +func Xsqlite3_db_cacheflush(tls *libc.TLS, db uintptr) (r int32) { + var bSeenBusy, i, rc, v2 int32 + var pBt, pPager uintptr + _, _, _, _, _, _ = bSeenBusy, i, pBt, pPager, rc, v2 + rc = SQLITE_OK + bSeenBusy = 0 + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3BtreeEnterAll(tls, db) + i = 0 + for { + if !(rc == SQLITE_OK && i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 && _sqlite3BtreeTxnState(tls, pBt) == int32(SQLITE_TXN_WRITE) { + pPager = _sqlite3BtreePager(tls, pBt) + rc = _sqlite3PagerFlush(tls, pPager) + if rc == int32(SQLITE_BUSY) { + bSeenBusy = int32(1) + rc = SQLITE_OK + } + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3BtreeLeaveAll(tls, db) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if rc == SQLITE_OK && bSeenBusy != 0 { + v2 = int32(SQLITE_BUSY) + } else { + v2 = rc + } + return v2 +} + +// C documentation +// +// /* +// ** Return the name of the N-th database schema. Return NULL if N is out +// ** of range. +// */ +func Xsqlite3_db_name(tls *libc.TLS, db uintptr, N int32) (r uintptr) { + if N < 0 || N >= (*Tsqlite3)(unsafe.Pointer(db)).FnDb { + return uintptr(0) + } else { + return (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(N)*32))).FzDbSName + } + return r +} + +// C documentation +// +// /* +// ** Free up as much memory as we can from the given database +// ** connection. +// */ +func Xsqlite3_db_release_memory(tls *libc.TLS, db uintptr) (r int32) { + var i int32 + var pBt, pPager uintptr + _, _, _ = i, pBt, pPager + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3BtreeEnterAll(tls, db) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 { + pPager = _sqlite3BtreePager(tls, pBt) + _sqlite3PagerShrink(tls, pPager) + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3BtreeLeaveAll(tls, db) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** External API to drop all virtual-table modules, except those named +// ** on the azNames list. +// */ +func Xsqlite3_drop_modules(tls *libc.TLS, db uintptr, azNames uintptr) (r int32) { + var ii int32 + var pMod, pNext, pThis uintptr + _, _, _, _ = ii, pMod, pNext, pThis + pThis = (*THash)(unsafe.Pointer(db + 576)).Ffirst + for { + if !(pThis != 0) { + break + } + pMod = (*THashElem)(unsafe.Pointer(pThis)).Fdata + pNext = (*THashElem)(unsafe.Pointer(pThis)).Fnext + if azNames != 0 { + ii = 0 + for { + if !(**(**uintptr)(__ccgo_up(azNames + uintptr(ii)*8)) != uintptr(0) && libc.Xstrcmp(tls, **(**uintptr)(__ccgo_up(azNames + uintptr(ii)*8)), (*TModule)(unsafe.Pointer(pMod)).FzName) != 0) { + break + } + goto _2 + _2: + ; + ii = ii + 1 + } + if **(**uintptr)(__ccgo_up(azNames + uintptr(ii)*8)) != uintptr(0) { + goto _1 + } + } + _createModule(tls, db, (*TModule)(unsafe.Pointer(pMod)).FzName, uintptr(0), uintptr(0), uintptr(0)) + goto _1 + _1: + ; + pThis = pNext + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Return TRUE (non-zero) of the statement supplied as an argument needs +// ** to be recompiled. A statement needs to be recompiled whenever the +// ** execution environment changes in a way that would alter the program +// ** that sqlite3_prepare() generates. For example, if new functions or +// ** collating sequences are registered or if an authorizer function is +// ** added or changed. +// */ +func Xsqlite3_expired(tls *libc.TLS, pStmt uintptr) (r int32) { + var p uintptr + _ = p + p = pStmt + return libc.BoolInt32(p == uintptr(0) || int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x3>>0)) != 0) +} + +// C documentation +// +// /* +// ** This routine frees the space the sqlite3_get_table() malloced. +// */ +func Xsqlite3_free_table(tls *libc.TLS, azResult uintptr) { + var i, n int32 + _, _ = i, n + if azResult != 0 { + azResult -= 8 + n = int32(int64(**(**uintptr)(__ccgo_up(azResult)))) + i = int32(1) + for { + if !(i < n) { + break + } + if **(**uintptr)(__ccgo_up(azResult + uintptr(i)*8)) != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(azResult + uintptr(i)*8))) + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, azResult) + } +} + +/************** End of table.c ***********************************************/ +/************** Begin file trigger.c *****************************************/ +/* +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the implementation for TRIGGERs + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** Find existing client data. +// */ +func Xsqlite3_get_clientdata(tls *libc.TLS, db uintptr, zName uintptr) (r uintptr) { + var p, pResult uintptr + _, _ = p, pResult + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + p = (*Tsqlite3)(unsafe.Pointer(db)).FpDbData + for { + if !(p != 0) { + break + } + if libc.Xstrcmp(tls, p+24, zName) == 0 { + pResult = (*TDbClientData)(unsafe.Pointer(p)).FpData + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return pResult + } + goto _1 + _1: + ; + p = (*TDbClientData)(unsafe.Pointer(p)).FpNext + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Cause any pending operation to stop at its earliest opportunity. +// */ +func Xsqlite3_interrupt(tls *libc.TLS, db uintptr) { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(1), libc.Int32FromInt32(__ATOMIC_RELAXED)) +} + +// C documentation +// +// /* +// ** Return true or false depending on whether or not an interrupt is +// ** pending on connection db. +// */ +func Xsqlite3_is_interrupted(tls *libc.TLS, db uintptr) (r int32) { + return libc.BoolInt32(libc.AtomicLoadNInt32(db+432, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0) +} + +// C documentation +// +// /* +// ** Change the value of a limit. Report the old value. +// ** If an invalid limit index is supplied, report -1. +// ** Make no changes but still report the old value if the +// ** new limit is negative. +// ** +// ** A new lower limit does not shrink existing constructs. +// ** It merely prevents new constructs that exceed the limit +// ** from forming. +// */ +func Xsqlite3_limit(tls *libc.TLS, db uintptr, limitId int32, newLimit int32) (r int32) { + var oldLimit int32 + _ = oldLimit + /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME + ** there is a hard upper bound set at compile-time by a C preprocessor + ** macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to + ** "_MAX_".) + */ + if limitId < 0 || limitId >= libc.Int32FromInt32(SQLITE_LIMIT_PARSER_DEPTH)+libc.Int32FromInt32(1) { + return -int32(1) + } + oldLimit = **(**int32)(__ccgo_up(db + 136 + uintptr(limitId)*4)) + if newLimit >= 0 { /* IMP: R-52476-28732 */ + if newLimit > _aHardLimit[limitId] { + newLimit = _aHardLimit[limitId] /* IMP: R-51463-25634 */ + } else { + if newLimit < int32(SQLITE_MIN_LENGTH) && limitId == SQLITE_LIMIT_LENGTH { + newLimit = int32(SQLITE_MIN_LENGTH) + } + } + **(**int32)(__ccgo_up(db + 136 + uintptr(limitId)*4)) = newLimit + } + return oldLimit /* IMP: R-53341-35419 */ +} + +// C documentation +// +// /* +// ** Register a profile function. The pArg from the previously registered +// ** profile function is returned. +// ** +// ** A NULL profile function means that no profiling is executes. A non-NULL +// ** profile is a pointer to a function that is invoked at the conclusion of +// ** each SQL statement that is run. +// */ +func Xsqlite3_profile(tls *libc.TLS, db uintptr, __ccgo_fp_xProfile uintptr, pArg uintptr) (r uintptr) { + var pOld, v1 uintptr + _, _ = pOld, v1 + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + pOld = (*Tsqlite3)(unsafe.Pointer(db)).FpProfileArg + (*Tsqlite3)(unsafe.Pointer(db)).FxProfile = __ccgo_fp_xProfile + (*Tsqlite3)(unsafe.Pointer(db)).FpProfileArg = pArg + v1 = db + 110 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & libc.Int32FromInt32(SQLITE_TRACE_NONLEGACY_MASK)) + if (*Tsqlite3)(unsafe.Pointer(db)).FxProfile != 0 { + v1 = db + 110 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(SQLITE_TRACE_XPROFILE)) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return pOld +} + +func Xsqlite3_result_subtype(tls *libc.TLS, pCtx uintptr, eSubtype uint32) { + var pOut, v1 uintptr + _, _ = pOut, v1 + pOut = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut + (*TMem)(unsafe.Pointer(pOut)).FeSubtype = uint8(eSubtype & uint32(0xff)) + v1 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Subtype)) +} + +// C documentation +// +// /* +// ** Register a new geometry function for use with the r-tree MATCH operator. +// */ +func Xsqlite3_rtree_geometry_callback(tls *libc.TLS, db uintptr, zGeom uintptr, __ccgo_fp_xGeom uintptr, pContext uintptr) (r int32) { + var pGeomCtx uintptr + _ = pGeomCtx /* Context object for new user-function */ + /* Allocate and populate the context object. */ + pGeomCtx = Xsqlite3_malloc(tls, int32(32)) + if !(pGeomCtx != 0) { + return int32(SQLITE_NOMEM) + } + (*TRtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxGeom = __ccgo_fp_xGeom + (*TRtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxQueryFunc = uintptr(0) + (*TRtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxDestructor = uintptr(0) + (*TRtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FpContext = pContext + return Xsqlite3_create_function_v2(tls, db, zGeom, -int32(1), int32(SQLITE_ANY), pGeomCtx, __ccgo_fp(_geomCallback), uintptr(0), uintptr(0), __ccgo_fp(_rtreeFreeCallback)) +} + +// C documentation +// +// /* +// ** Register a new 2nd-generation geometry function for use with the +// ** r-tree MATCH operator. +// */ +func Xsqlite3_rtree_query_callback(tls *libc.TLS, db uintptr, zQueryFunc uintptr, __ccgo_fp_xQueryFunc uintptr, pContext uintptr, __ccgo_fp_xDestructor uintptr) (r int32) { + var pGeomCtx uintptr + _ = pGeomCtx /* Context object for new user-function */ + /* Allocate and populate the context object. */ + pGeomCtx = Xsqlite3_malloc(tls, int32(32)) + if !(pGeomCtx != 0) { + if __ccgo_fp_xDestructor != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDestructor})))(tls, pContext) + } + return int32(SQLITE_NOMEM) + } + (*TRtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxGeom = uintptr(0) + (*TRtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxQueryFunc = __ccgo_fp_xQueryFunc + (*TRtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxDestructor = __ccgo_fp_xDestructor + (*TRtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FpContext = pContext + return Xsqlite3_create_function_v2(tls, db, zQueryFunc, -int32(1), int32(SQLITE_ANY), pGeomCtx, __ccgo_fp(_geomCallback), uintptr(0), uintptr(0), __ccgo_fp(_rtreeFreeCallback)) +} + +/************** End of rtree.c ***********************************************/ +/************** Begin file icu.c *********************************************/ +/* +** 2007 May 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** $Id: icu.c,v 1.7 2007/12/13 21:54:11 drh Exp $ +** +** This file implements an integration between the ICU library +** ("International Components for Unicode", an open-source library +** for handling unicode data) and SQLite. The integration uses +** ICU to provide the following to SQLite: +** +** * An implementation of the SQL regexp() function (and hence REGEXP +** operator) using the ICU uregex_XX() APIs. +** +** * Implementations of the SQL scalar upper() and lower() functions +** for case mapping. +** +** * Integration of ICU and SQLite collation sequences. +** +** * An implementation of the LIKE operator that uses ICU to +** provide case-independent matching. + */ + +/************** End of icu.c *************************************************/ +/************** Begin file fts3_icu.c ****************************************/ +/* +** 2007 June 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file implements a tokenizer for fts3 based on the ICU library. + */ +/* #include "fts3Int.h" */ + +/************** End of fts3_icu.c ********************************************/ +/************** Begin file sqlite3rbu.c **************************************/ +/* +** 2014 August 30 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** +** OVERVIEW +** +** The RBU extension requires that the RBU update be packaged as an +** SQLite database. The tables it expects to find are described in +** sqlite3rbu.h. Essentially, for each table xyz in the target database +** that the user wishes to write to, a corresponding data_xyz table is +** created in the RBU database and populated with one row for each row to +** update, insert or delete from the target table. +** +** The update proceeds in three stages: +** +** 1) The database is updated. The modified database pages are written +** to a *-oal file. A *-oal file is just like a *-wal file, except +** that it is named "-oal" instead of "-wal". +** Because regular SQLite clients do not look for file named +** "-oal", they go on using the original database in +** rollback mode while the *-oal file is being generated. +** +** During this stage RBU does not update the database by writing +** directly to the target tables. Instead it creates "imposter" +** tables using the SQLITE_TESTCTRL_IMPOSTER interface that it uses +** to update each b-tree individually. All updates required by each +** b-tree are completed before moving on to the next, and all +** updates are done in sorted key order. +** +** 2) The "-oal" file is moved to the equivalent "-wal" +** location using a call to rename(2). Before doing this the RBU +** module takes an EXCLUSIVE lock on the database file, ensuring +** that there are no other active readers. +** +** Once the EXCLUSIVE lock is released, any other database readers +** detect the new *-wal file and read the database in wal mode. At +** this point they see the new version of the database - including +** the updates made as part of the RBU update. +** +** 3) The new *-wal file is checkpointed. This proceeds in the same way +** as a regular database checkpoint, except that a single frame is +** checkpointed each time sqlite3rbu_step() is called. If the RBU +** handle is closed before the entire *-wal file is checkpointed, +** the checkpoint progress is saved in the RBU database and the +** checkpoint can be resumed by another RBU client at some point in +** the future. +** +** POTENTIAL PROBLEMS +** +** The rename() call might not be portable. And RBU is not currently +** syncing the directory after renaming the file. +** +** When state is saved, any commit to the *-oal file and the commit to +** the RBU update database are not atomic. So if the power fails at the +** wrong moment they might get out of sync. As the main database will be +** committed before the RBU update database this will likely either just +** pass unnoticed, or result in SQLITE_CONSTRAINT errors (due to UNIQUE +** constraint violations). +** +** If some client does modify the target database mid RBU update, or some +** other error occurs, the RBU extension will keep throwing errors. It's +** not really clear how to get out of this state. The system could just +** by delete the RBU update database and *-oal file and have the device +** download the update again and start over. +** +** At present, for an UPDATE, both the new.* and old.* records are +** collected in the rbu_xyz table. And for both UPDATEs and DELETEs all +** fields are collected. This means we're probably writing a lot more +** data to disk when saving the state of an ongoing update to the RBU +** update database than is strictly necessary. +** + */ + +/* #include */ +/* #include */ +/* #include */ + +/* #include "sqlite3.h" */ + +/************** Include sqlite3rbu.h in the middle of sqlite3rbu.c ***********/ +/************** Begin file sqlite3rbu.h **************************************/ +/* +** 2014 August 30 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains the public interface for the RBU extension. + */ + +/* +** SUMMARY +** +** Writing a transaction containing a large number of operations on +** b-tree indexes that are collectively larger than the available cache +** memory can be very inefficient. +** +** The problem is that in order to update a b-tree, the leaf page (at least) +** containing the entry being inserted or deleted must be modified. If the +** working set of leaves is larger than the available cache memory, then a +** single leaf that is modified more than once as part of the transaction +** may be loaded from or written to the persistent media multiple times. +** Additionally, because the index updates are likely to be applied in +** random order, access to pages within the database is also likely to be in +** random order, which is itself quite inefficient. +** +** One way to improve the situation is to sort the operations on each index +** by index key before applying them to the b-tree. This leads to an IO +** pattern that resembles a single linear scan through the index b-tree, +** and all but guarantees each modified leaf page is loaded and stored +** exactly once. SQLite uses this trick to improve the performance of +** CREATE INDEX commands. This extension allows it to be used to improve +** the performance of large transactions on existing databases. +** +** Additionally, this extension allows the work involved in writing the +** large transaction to be broken down into sub-transactions performed +** sequentially by separate processes. This is useful if the system cannot +** guarantee that a single update process will run for long enough to apply +** the entire update, for example because the update is being applied on a +** mobile device that is frequently rebooted. Even after the writer process +** has committed one or more sub-transactions, other database clients continue +** to read from the original database snapshot. In other words, partially +** applied transactions are not visible to other clients. +** +** "RBU" stands for "Resumable Bulk Update". As in a large database update +** transmitted via a wireless network to a mobile device. A transaction +** applied using this extension is hence referred to as an "RBU update". +** +** +** LIMITATIONS +** +** An "RBU update" transaction is subject to the following limitations: +** +** * The transaction must consist of INSERT, UPDATE and DELETE operations +** only. +** +** * INSERT statements may not use any default values. +** +** * UPDATE and DELETE statements must identify their target rows by +** non-NULL PRIMARY KEY values. Rows with NULL values stored in PRIMARY +** KEY fields may not be updated or deleted. If the table being written +** has no PRIMARY KEY, affected rows must be identified by rowid. +** +** * UPDATE statements may not modify PRIMARY KEY columns. +** +** * No triggers will be fired. +** +** * No foreign key violations are detected or reported. +** +** * CHECK constraints are not enforced. +** +** * No constraint handling mode except for "OR ROLLBACK" is supported. +** +** +** PREPARATION +** +** An "RBU update" is stored as a separate SQLite database. A database +** containing an RBU update is an "RBU database". For each table in the +** target database to be updated, the RBU database should contain a table +** named "data_" containing the same set of columns as the +** target table, and one more - "rbu_control". The data_% table should +** have no PRIMARY KEY or UNIQUE constraints, but each column should have +** the same type as the corresponding column in the target database. +** The "rbu_control" column should have no type at all. For example, if +** the target database contains: +** +** CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c UNIQUE); +** +** Then the RBU database should contain: +** +** CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control); +** +** The order of the columns in the data_% table does not matter. +** +** Instead of a regular table, the RBU database may also contain virtual +** tables or views named using the data_ naming scheme. +** +** Instead of the plain data_ naming scheme, RBU database tables +** may also be named data_, where is any sequence +** of zero or more numeric characters (0-9). This can be significant because +** tables within the RBU database are always processed in order sorted by +** name. By judicious selection of the portion of the names +** of the RBU tables the user can therefore control the order in which they +** are processed. This can be useful, for example, to ensure that "external +** content" FTS4 tables are updated before their underlying content tables. +** +** If the target database table is a virtual table or a table that has no +** PRIMARY KEY declaration, the data_% table must also contain a column +** named "rbu_rowid". This column is mapped to the table's implicit primary +** key column - "rowid". Virtual tables for which the "rowid" column does +** not function like a primary key value cannot be updated using RBU. For +** example, if the target db contains either of the following: +** +** CREATE VIRTUAL TABLE x1 USING fts3(a, b); +** CREATE TABLE x1(a, b) +** +** then the RBU database should contain: +** +** CREATE TABLE data_x1(a, b, rbu_rowid, rbu_control); +** +** All non-hidden columns (i.e. all columns matched by "SELECT *") of the +** target table must be present in the input table. For virtual tables, +** hidden columns are optional - they are updated by RBU if present in +** the input table, or not otherwise. For example, to write to an fts4 +** table with a hidden languageid column such as: +** +** CREATE VIRTUAL TABLE ft1 USING fts4(a, b, languageid='langid'); +** +** Either of the following input table schemas may be used: +** +** CREATE TABLE data_ft1(a, b, langid, rbu_rowid, rbu_control); +** CREATE TABLE data_ft1(a, b, rbu_rowid, rbu_control); +** +** For each row to INSERT into the target database as part of the RBU +** update, the corresponding data_% table should contain a single record +** with the "rbu_control" column set to contain integer value 0. The +** other columns should be set to the values that make up the new record +** to insert. +** +** If the target database table has an INTEGER PRIMARY KEY, it is not +** possible to insert a NULL value into the IPK column. Attempting to +** do so results in an SQLITE_MISMATCH error. +** +** For each row to DELETE from the target database as part of the RBU +** update, the corresponding data_% table should contain a single record +** with the "rbu_control" column set to contain integer value 1. The +** real primary key values of the row to delete should be stored in the +** corresponding columns of the data_% table. The values stored in the +** other columns are not used. +** +** For each row to UPDATE from the target database as part of the RBU +** update, the corresponding data_% table should contain a single record +** with the "rbu_control" column set to contain a value of type text. +** The real primary key values identifying the row to update should be +** stored in the corresponding columns of the data_% table row, as should +** the new values of all columns being update. The text value in the +** "rbu_control" column must contain the same number of characters as +** there are columns in the target database table, and must consist entirely +** of 'x' and '.' characters (or in some special cases 'd' - see below). For +** each column that is being updated, the corresponding character is set to +** 'x'. For those that remain as they are, the corresponding character of the +** rbu_control value should be set to '.'. For example, given the tables +** above, the update statement: +** +** UPDATE t1 SET c = 'usa' WHERE a = 4; +** +** is represented by the data_t1 row created by: +** +** INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..x'); +** +** Instead of an 'x' character, characters of the rbu_control value specified +** for UPDATEs may also be set to 'd'. In this case, instead of updating the +** target table with the value stored in the corresponding data_% column, the +** user-defined SQL function "rbu_delta()" is invoked and the result stored in +** the target table column. rbu_delta() is invoked with two arguments - the +** original value currently stored in the target table column and the +** value specified in the data_xxx table. +** +** For example, this row: +** +** INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..d'); +** +** is similar to an UPDATE statement such as: +** +** UPDATE t1 SET c = rbu_delta(c, 'usa') WHERE a = 4; +** +** Finally, if an 'f' character appears in place of a 'd' or 's' in an +** ota_control string, the contents of the data_xxx table column is assumed +** to be a "fossil delta" - a patch to be applied to a blob value in the +** format used by the fossil source-code management system. In this case +** the existing value within the target database table must be of type BLOB. +** It is replaced by the result of applying the specified fossil delta to +** itself. +** +** If the target database table is a virtual table or a table with no PRIMARY +** KEY, the rbu_control value should not include a character corresponding +** to the rbu_rowid value. For example, this: +** +** INSERT INTO data_ft1(a, b, rbu_rowid, rbu_control) +** VALUES(NULL, 'usa', 12, '.x'); +** +** causes a result similar to: +** +** UPDATE ft1 SET b = 'usa' WHERE rowid = 12; +** +** The data_xxx tables themselves should have no PRIMARY KEY declarations. +** However, RBU is more efficient if reading the rows in from each data_xxx +** table in "rowid" order is roughly the same as reading them sorted by +** the PRIMARY KEY of the corresponding target database table. In other +** words, rows should be sorted using the destination table PRIMARY KEY +** fields before they are inserted into the data_xxx tables. +** +** USAGE +** +** The API declared below allows an application to apply an RBU update +** stored on disk to an existing target database. Essentially, the +** application: +** +** 1) Opens an RBU handle using the sqlite3rbu_open() function. +** +** 2) Registers any required virtual table modules with the database +** handle returned by sqlite3rbu_db(). Also, if required, register +** the rbu_delta() implementation. +** +** 3) Calls the sqlite3rbu_step() function one or more times on +** the new handle. Each call to sqlite3rbu_step() performs a single +** b-tree operation, so thousands of calls may be required to apply +** a complete update. +** +** 4) Calls sqlite3rbu_close() to close the RBU update handle. If +** sqlite3rbu_step() has been called enough times to completely +** apply the update to the target database, then the RBU database +** is marked as fully applied. Otherwise, the state of the RBU +** update application is saved in the RBU database for later +** resumption. +** +** See comments below for more detail on APIs. +** +** If an update is only partially applied to the target database by the +** time sqlite3rbu_close() is called, various state information is saved +** within the RBU database. This allows subsequent processes to automatically +** resume the RBU update from where it left off. +** +** To remove all RBU extension state information, returning an RBU database +** to its original contents, it is sufficient to drop all tables that begin +** with the prefix "rbu_" +** +** DATABASE LOCKING +** +** An RBU update may not be applied to a database in WAL mode. Attempting +** to do so is an error (SQLITE_ERROR). +** +** While an RBU handle is open, a SHARED lock may be held on the target +** database file. This means it is possible for other clients to read the +** database, but not to write it. +** +** If an RBU update is started and then suspended before it is completed, +** then an external client writes to the database, then attempting to resume +** the suspended RBU update is also an error (SQLITE_BUSY). + */ + +/* #include "sqlite3.h" ** Required for error code definitions ** */ + +// C documentation +// +// /* +// ** Set the auxiliary data pointer and delete function, for the iArg'th +// ** argument to the user-function defined by pCtx. Any previous value is +// ** deleted by calling the delete function specified when it was set. +// ** +// ** The left-most argument is 0. +// ** +// ** Undocumented behavior: If iArg is negative then make the data available +// ** to all functions within the current prepared statement using iArg as an +// ** access code. +// */ +func Xsqlite3_set_auxdata(tls *libc.TLS, pCtx uintptr, iArg int32, pAux uintptr, __ccgo_fp_xDelete uintptr) { + var pAuxData, pVdbe uintptr + _, _ = pAuxData, pVdbe + pVdbe = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe + if pVdbe == uintptr(0) { + goto failed + } + pAuxData = (*TVdbe)(unsafe.Pointer(pVdbe)).FpAuxData + for { + if !(pAuxData != 0) { + break + } + if (*TAuxData)(unsafe.Pointer(pAuxData)).FiAuxArg == iArg && ((*TAuxData)(unsafe.Pointer(pAuxData)).FiAuxOp == (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FiOp || iArg < 0) { + break + } + goto _1 + _1: + ; + pAuxData = (*TAuxData)(unsafe.Pointer(pAuxData)).FpNextAux + } + if pAuxData == uintptr(0) { + pAuxData = _sqlite3DbMallocZero(tls, (*TVdbe)(unsafe.Pointer(pVdbe)).Fdb, uint64(32)) + if !(pAuxData != 0) { + goto failed + } + (*TAuxData)(unsafe.Pointer(pAuxData)).FiAuxOp = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FiOp + (*TAuxData)(unsafe.Pointer(pAuxData)).FiAuxArg = iArg + (*TAuxData)(unsafe.Pointer(pAuxData)).FpNextAux = (*TVdbe)(unsafe.Pointer(pVdbe)).FpAuxData + (*TVdbe)(unsafe.Pointer(pVdbe)).FpAuxData = pAuxData + if (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError == 0 { + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = -int32(1) + } + } else { + if (*TAuxData)(unsafe.Pointer(pAuxData)).FxDeleteAux != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TAuxData)(unsafe.Pointer(pAuxData)).FxDeleteAux})))(tls, (*TAuxData)(unsafe.Pointer(pAuxData)).FpAux) + } + } + (*TAuxData)(unsafe.Pointer(pAuxData)).FpAux = pAux + (*TAuxData)(unsafe.Pointer(pAuxData)).FxDeleteAux = __ccgo_fp_xDelete + return + goto failed +failed: + ; + if __ccgo_fp_xDelete != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDelete})))(tls, pAux) + } +} + +// C documentation +// +// /* +// ** Undo the effects of sqlite3_initialize(). Must not be called while +// ** there are outstanding database connections or memory allocations or +// ** while any part of SQLite is otherwise in use in any thread. This +// ** routine is not threadsafe. But it is safe to invoke this routine +// ** on when SQLite is already shut down. If SQLite is already shut down +// ** when this routine is invoked, then this routine is a harmless no-op. +// */ +func Xsqlite3_shutdown(tls *libc.TLS) (r int32) { + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340) != 0 { + Xsqlite3_os_end(tls) + Xsqlite3_reset_auto_extension(tls) + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340, 0) + } + if _sqlite3Config.FisPCacheInit != 0 { + _sqlite3PcacheShutdown(tls) + _sqlite3Config.FisPCacheInit = 0 + } + if _sqlite3Config.FisMallocInit != 0 { + _sqlite3MallocEnd(tls) + _sqlite3Config.FisMallocInit = 0 + /* The heap subsystem has now been shutdown and these values are supposed + ** to be NULL or point to memory that was obtained from sqlite3_malloc(), + ** which would rely on that heap subsystem; therefore, make sure these + ** values cannot refer to heap memory that was just invalidated when the + ** heap subsystem was shutdown. This is only done if the current call to + ** this function resulted in the heap subsystem actually being shutdown. + */ + Xsqlite3_data_directory = uintptr(0) + Xsqlite3_temp_directory = uintptr(0) + } + if _sqlite3Config.FisMutexInit != 0 { + _sqlite3MutexEnd(tls) + _sqlite3Config.FisMutexInit = 0 + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Recover as many snapshots as possible from the wal file associated with +// ** schema zDb of database db. +// */ +func Xsqlite3_snapshot_recover(tls *libc.TLS, db uintptr, zDb uintptr) (r int32) { + var iDb, rc int32 + var pBt uintptr + _, _, _ = iDb, pBt, rc + rc = int32(SQLITE_ERROR) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + iDb = _sqlite3FindDbName(tls, db, zDb) + if iDb == 0 || iDb > int32(1) { + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if SQLITE_TXN_NONE == _sqlite3BtreeTxnState(tls, pBt) { + rc = _sqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) + if rc == SQLITE_OK { + rc = _sqlite3PagerSnapshotRecover(tls, _sqlite3BtreePager(tls, pBt)) + _sqlite3BtreeCommit(tls, pBt) + } + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Return 1 if the statement is an EXPLAIN and return 2 if the +// ** statement is an EXPLAIN QUERY PLAN +// */ +func Xsqlite3_stmt_isexplain(tls *libc.TLS, pStmt uintptr) (r int32) { + var v1 int32 + _ = v1 + if pStmt != 0 { + v1 = int32(Tbft(*(*uint16)(unsafe.Pointer(pStmt + 200)) & 0xc >> 2)) + } else { + v1 = 0 + } + return v1 +} + +// C documentation +// +// /* +// ** Return true if the prepared statement is guaranteed to not modify the +// ** database. +// */ +func Xsqlite3_stmt_readonly(tls *libc.TLS, pStmt uintptr) (r int32) { + var v1 int32 + _ = v1 + if pStmt != 0 { + v1 = int32(Tbft(*(*uint16)(unsafe.Pointer(pStmt + 200)) & 0x40 >> 6)) + } else { + v1 = int32(1) + } + return v1 +} + +// C documentation +// +// /* Allocate and initialize a new dynamic string object */ +func Xsqlite3_str_new(tls *libc.TLS, db uintptr) (r uintptr) { + var p uintptr + var v1 int32 + _, _ = p, v1 + p = Xsqlite3_malloc64(tls, uint64(32)) + if p != 0 { + if db != 0 { + v1 = **(**int32)(__ccgo_up(db + 136)) + } else { + v1 = int32(SQLITE_MAX_LENGTH) + } + _sqlite3StrAccumInit(tls, p, uintptr(0), uintptr(0), 0, v1) + } else { + p = uintptr(unsafe.Pointer(&_sqlite3OomStr)) + } + return p +} + +// C documentation +// +// /* Register a trace callback using the version-2 interface. +// */ +func Xsqlite3_trace_v2(tls *libc.TLS, db uintptr, mTrace uint32, __ccgo_fp_xTrace uintptr, pArg uintptr) (r int32) { + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if mTrace == uint32(0) { + __ccgo_fp_xTrace = uintptr(0) + } + if __ccgo_fp_xTrace == uintptr(0) { + mTrace = uint32(0) + } + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = uint8(mTrace) + *(*uintptr)(unsafe.Pointer(db + 248)) = __ccgo_fp_xTrace + (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg = pArg + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Deprecated external interface. Internal/core SQLite code +// ** should call sqlite3TransferBindings. +// ** +// ** It is misuse to call this routine with statements from different +// ** database connections. But as this is a deprecated interface, we +// ** will not bother to check for that condition. +// ** +// ** If the two statements contain a different number of bindings, then +// ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise +// ** SQLITE_OK is returned. +// */ +func Xsqlite3_transfer_bindings(tls *libc.TLS, pFromStmt uintptr, pToStmt uintptr) (r int32) { + var pFrom, pTo uintptr + _, _ = pFrom, pTo + pFrom = pFromStmt + pTo = pToStmt + if int32((*TVdbe)(unsafe.Pointer(pFrom)).FnVar) != int32((*TVdbe)(unsafe.Pointer(pTo)).FnVar) { + return int32(SQLITE_ERROR) + } + if (*TVdbe)(unsafe.Pointer(pTo)).Fexpmask != 0 { + libc.SetBitFieldPtr16Uint32(pTo+200, libc.Uint32FromInt32(1), 0, 0x3) + } + if (*TVdbe)(unsafe.Pointer(pFrom)).Fexpmask != 0 { + libc.SetBitFieldPtr16Uint32(pFrom+200, libc.Uint32FromInt32(1), 0, 0x3) + } + return _sqlite3TransferBindings(tls, pFromStmt, pToStmt) +} + +// C documentation +// +// /* +// ** Return the transaction state for a single databse, or the maximum +// ** transaction state over all attached databases if zSchema is null. +// */ +func Xsqlite3_txn_state(tls *libc.TLS, db uintptr, zSchema uintptr) (r int32) { + var iDb, iTxn, nDb, x, v1 int32 + var pBt uintptr + _, _, _, _, _, _ = iDb, iTxn, nDb, pBt, x, v1 + iTxn = -int32(1) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if zSchema != 0 { + v1 = _sqlite3FindDbName(tls, db, zSchema) + iDb = v1 + nDb = v1 + if iDb < 0 { + nDb = nDb - 1 + } + } else { + iDb = 0 + nDb = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + } + for { + if !(iDb <= nDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if pBt != uintptr(0) { + v1 = _sqlite3BtreeTxnState(tls, pBt) + } else { + v1 = SQLITE_TXN_NONE + } + x = v1 + if x > iTxn { + iTxn = x + } + goto _2 + _2: + ; + iDb = iDb + 1 + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return iTxn +} + +// C documentation +// +// /* +// ** Return the collating sequence for a constraint passed into xBestIndex. +// ** +// ** pIdxInfo must be an sqlite3_index_info structure passed into xBestIndex. +// ** This routine depends on there being a HiddenIndexInfo structure immediately +// ** following the sqlite3_index_info structure. +// ** +// ** Return a pointer to the collation name: +// ** +// ** 1. If there is an explicit COLLATE operator on the constraint, return it. +// ** +// ** 2. Else, if the column has an alternative collation, return that. +// ** +// ** 3. Otherwise, return "BINARY". +// */ +func Xsqlite3_vtab_collation(tls *libc.TLS, pIdxInfo uintptr, iCons int32) (r uintptr) { + var iTerm int32 + var pC, pHidden, pX, zRet, v1 uintptr + _, _, _, _, _, _ = iTerm, pC, pHidden, pX, zRet, v1 + pHidden = pIdxInfo + 1*96 + zRet = uintptr(0) + if iCons >= 0 && iCons < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint { + pC = uintptr(0) + iTerm = (**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(iCons)*12))).FiTermOffset + pX = (*TWhereTerm)(unsafe.Pointer(_termFromWhereClause(tls, (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FpWC, iTerm))).FpExpr + if (*TExpr)(unsafe.Pointer(pX)).FpLeft != 0 { + pC = _sqlite3ExprCompareCollSeq(tls, (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FpParse, pX) + } + if pC != 0 { + v1 = (*TCollSeq)(unsafe.Pointer(pC)).FzName + } else { + v1 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + zRet = v1 + } + return zRet +} + +// C documentation +// +// /* +// ** Return true if ORDER BY clause may be handled as DISTINCT. +// */ +func Xsqlite3_vtab_distinct(tls *libc.TLS, pIdxInfo uintptr) (r int32) { + var pHidden uintptr + _ = pHidden + pHidden = pIdxInfo + 1*96 + return (*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FeDistinct +} + +// C documentation +// +// /* +// ** Return true if constraint iCons is really an IN(...) constraint, or +// ** false otherwise. If iCons is an IN(...) constraint, set (if bHandle!=0) +// ** or clear (if bHandle==0) the flag to handle it using an iterator. +// */ +func Xsqlite3_vtab_in(tls *libc.TLS, pIdxInfo uintptr, iCons int32, bHandle int32) (r int32) { + var m Tu32 + var pHidden uintptr + var v1 uint32 + _, _, _ = m, pHidden, v1 + pHidden = pIdxInfo + 1*96 + if iCons <= int32(31) { + v1 = libc.Uint32FromInt32(1) << iCons + } else { + v1 = uint32(0) + } + m = v1 + if m&(*THiddenIndexInfo)(unsafe.Pointer(pHidden)).FmIn != 0 { + if bHandle == 0 { + **(**Tu32)(__ccgo_up(pHidden + 24)) &= ^m + } else { + if bHandle > 0 { + **(**Tu32)(__ccgo_up(pHidden + 24)) |= m + } + } + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** This interface is callable from within the xBestIndex callback only. +// ** +// ** If possible, set (*ppVal) to point to an object containing the value +// ** on the right-hand-side of constraint iCons. +// */ +func Xsqlite3_vtab_rhs_value(tls *libc.TLS, pIdxInfo uintptr, iCons int32, ppVal uintptr) (r int32) { + var pH, pTerm, pVal uintptr + var rc int32 + _, _, _, _ = pH, pTerm, pVal, rc + pH = pIdxInfo + 1*96 + pVal = uintptr(0) + rc = SQLITE_OK + if iCons < 0 || iCons >= (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint { + rc = _sqlite3MisuseError(tls, int32(173284)) /* EV: R-30545-25046 */ + } else { + if *(*uintptr)(unsafe.Pointer(pH + 32 + uintptr(iCons)*8)) == uintptr(0) { + pTerm = _termFromWhereClause(tls, (*THiddenIndexInfo)(unsafe.Pointer(pH)).FpWC, (**(**Tsqlite3_index_constraint)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(iCons)*12))).FiTermOffset) + rc = _sqlite3ValueFromExpr(tls, (*TParse)(unsafe.Pointer((*THiddenIndexInfo)(unsafe.Pointer(pH)).FpParse)).Fdb, (*TExpr)(unsafe.Pointer((*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight, (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer((*THiddenIndexInfo)(unsafe.Pointer(pH)).FpParse)).Fdb)).Fenc, uint8(SQLITE_AFF_BLOB), pH+32+uintptr(iCons)*8) + } + pVal = *(*uintptr)(unsafe.Pointer(pH + 32 + uintptr(iCons)*8)) + } + **(**uintptr)(__ccgo_up(ppVal)) = pVal + if rc == SQLITE_OK && pVal == uintptr(0) { /* IMP: R-19933-32160 */ + rc = int32(SQLITE_NOTFOUND) /* IMP: R-36424-56542 */ + } + return rc +} + +// C documentation +// +// /* +// ** Configure an sqlite3_wal_hook() callback to automatically checkpoint +// ** a database after committing a transaction if there are nFrame or +// ** more frames in the log file. Passing zero or a negative value as the +// ** nFrame parameter disables automatic checkpoints entirely. +// ** +// ** The callback registered by this function replaces any existing callback +// ** registered using sqlite3_wal_hook(). Likewise, registering a callback +// ** using sqlite3_wal_hook() disables the automatic checkpoint mechanism +// ** configured by this function. +// */ +func Xsqlite3_wal_autocheckpoint(tls *libc.TLS, db uintptr, nFrame int32) (r int32) { + if nFrame > 0 { + Xsqlite3_wal_hook(tls, db, __ccgo_fp(_sqlite3WalDefaultHook), uintptr(int64(nFrame))) + } else { + Xsqlite3_wal_hook(tls, db, uintptr(0), uintptr(0)) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Delete a changegroup object. +// */ +func Xsqlite3changegroup_delete(tls *libc.TLS, pGrp uintptr) { + var ii int32 + _ = ii + if pGrp != 0 { + ii = 0 + for { + if !(ii < (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FnBufAlloc) { + break + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf + uintptr(ii)*16))).FaBuf) + goto _1 + _1: + ; + ii = ii + 1 + } + Xsqlite3_free(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.Frecord.FaBuf) + Xsqlite3_free(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf) + Xsqlite3_free(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FzDb) + _sessionDeleteTable(tls, uintptr(0), (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList) + Xsqlite3_free(tls, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Frec.FaBuf) + Xsqlite3_free(tls, pGrp) + } +} + +// C documentation +// +// /* +// ** Finalize an iterator allocated with sqlite3changeset_start(). +// ** +// ** This function may not be called on iterators passed to a conflict handler +// ** callback by changeset_apply(). +// */ +func Xsqlite3changeset_finalize(tls *libc.TLS, p uintptr) (r int32) { + var i, rc int32 + _, _ = i, rc + rc = SQLITE_OK + if p != 0 { /* Used to iterate through p->apValue[] */ + rc = (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Frc + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue != 0 { + i = 0 + for { + if !(i < (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol*int32(2)) { + break + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + } + Xsqlite3_free(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf) + Xsqlite3_free(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.Fbuf.FaBuf) + Xsqlite3_free(tls, p) + } + return rc +} + +// C documentation +// +// /* +// ** This function may only be called while the iterator is pointing to an +// ** SQLITE_UPDATE or SQLITE_INSERT change (see sqlite3changeset_op()). +// ** Otherwise, SQLITE_MISUSE is returned. +// ** +// ** It sets *ppValue to point to an sqlite3_value structure containing the +// ** iVal'th value in the new.* record. Or, if that particular value is not +// ** included in the record (because the change is an UPDATE and the field +// ** was not modified), set *ppValue to NULL. +// ** +// ** If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is +// ** not modified. Otherwise, SQLITE_OK. +// */ +func Xsqlite3changeset_new(tls *libc.TLS, pIter uintptr, iVal int32, ppValue uintptr) (r int32) { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop != int32(SQLITE_UPDATE) && (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop != int32(SQLITE_INSERT) { + return int32(SQLITE_MISUSE) + } + if iVal < 0 || iVal >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol { + return int32(SQLITE_RANGE) + } + **(**uintptr)(__ccgo_up(ppValue)) = **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+iVal)*8)) + return SQLITE_OK +} + +/* +** The following two macros are used internally. They are similar to the +** sqlite3changeset_new() and sqlite3changeset_old() functions, except that +** they omit all error checking and return a pointer to the requested value. + */ + +// C documentation +// +// /* +// ** This function may only be called while the iterator is pointing to an +// ** SQLITE_UPDATE or SQLITE_DELETE change (see sqlite3changeset_op()). +// ** Otherwise, SQLITE_MISUSE is returned. +// ** +// ** It sets *ppValue to point to an sqlite3_value structure containing the +// ** iVal'th value in the old.* record. Or, if that particular value is not +// ** included in the record (because the change is an UPDATE and the field +// ** was not modified and is not a PK column), set *ppValue to NULL. +// ** +// ** If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is +// ** not modified. Otherwise, SQLITE_OK. +// */ +func Xsqlite3changeset_old(tls *libc.TLS, pIter uintptr, iVal int32, ppValue uintptr) (r int32) { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop != int32(SQLITE_UPDATE) && (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop != int32(SQLITE_DELETE) { + return int32(SQLITE_MISUSE) + } + if iVal < 0 || iVal >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol { + return int32(SQLITE_RANGE) + } + **(**uintptr)(__ccgo_up(ppValue)) = **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr(iVal)*8)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Delete a session object previously allocated using sqlite3session_create(). +// */ +func Xsqlite3session_delete(tls *libc.TLS, pSession uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pp uintptr + var _ /* pHead at bp+0 */ uintptr + _, _ = db, pp + db = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb + /* Unlink the session from the linked list of sessions attached to the + ** database handle. Hold the db mutex while doing so. */ + Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db)) + **(**uintptr)(__ccgo_up(bp)) = Xsqlite3_preupdate_hook(tls, db, uintptr(0), uintptr(0)) + pp = bp + for { + if !(**(**uintptr)(__ccgo_up(pp)) != uintptr(0)) { + break + } + if **(**uintptr)(__ccgo_up(pp)) == pSession { + **(**uintptr)(__ccgo_up(pp)) = (*Tsqlite3_session)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpNext + if **(**uintptr)(__ccgo_up(bp)) != 0 { + Xsqlite3_preupdate_hook(tls, db, __ccgo_fp(_xPreUpdate), **(**uintptr)(__ccgo_up(bp))) + } + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 80 + } + Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db)) + _sqlite3ValueFree(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpZeroBlob) + /* Delete all attached table objects. And the contents of their + ** associated hash-tables. */ + _sessionDeleteTable(tls, pSession, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable) + /* Free the session object. */ + Xsqlite3_free(tls, pSession) +} + +// C documentation +// +// /* +// ** This function implements the ChooseLeaf algorithm from Gutman[84]. +// ** ChooseSubTree in r*tree terminology. +// */ +func _ChooseLeaf(tls *libc.TLS, pRtree uintptr, pCell uintptr, iHeight int32, ppLeaf uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var area, area1, fMinArea, fMinGrowth, growth TRtreeDValue + var bFound, iCell, ii, nCell, rc int32 + var iBest Tsqlite3_int64 + var _ /* cell at bp+16 */ TRtreeCell + var _ /* cell at bp+64 */ TRtreeCell + var _ /* pChild at bp+8 */ uintptr + var _ /* pNode at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _ = area, area1, bFound, fMinArea, fMinGrowth, growth, iBest, iCell, ii, nCell, rc + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp) + ii = 0 + for { + if !(rc == SQLITE_OK && ii < (*TRtree)(unsafe.Pointer(pRtree)).FiDepth-iHeight) { + break + } + iBest = 0 + bFound = 0 + fMinGrowth = float64(0) + fMinArea = float64(0) + nCell = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzData+2) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + /* First check to see if there is are any cells in pNode that completely + ** contains pCell. If two or more cells in pNode completely contain pCell + ** then pick the smallest. + */ + iCell = 0 + for { + if !(iCell < nCell) { + break + } + _nodeGetCell(tls, pRtree, **(**uintptr)(__ccgo_up(bp)), iCell, bp+16) + if _cellContains(tls, pRtree, bp+16, pCell) != 0 { + area = _cellArea(tls, pRtree, bp+16) + if bFound == 0 || area < fMinArea { + iBest = (**(**TRtreeCell)(__ccgo_up(bp + 16))).FiRowid + fMinArea = area + bFound = int32(1) + } + } + goto _2 + _2: + ; + iCell = iCell + 1 + } + if !(bFound != 0) { + /* No cells of pNode will completely contain pCell. So pick the + ** cell of pNode that grows by the least amount when pCell is added. + ** Break ties by selecting the smaller cell. + */ + iCell = 0 + for { + if !(iCell < nCell) { + break + } + _nodeGetCell(tls, pRtree, **(**uintptr)(__ccgo_up(bp)), iCell, bp+64) + area1 = _cellArea(tls, pRtree, bp+64) + _cellUnion(tls, pRtree, bp+64, pCell) + growth = _cellArea(tls, pRtree, bp+64) - area1 + if iCell == 0 || growth < fMinGrowth || growth == fMinGrowth && area1 < fMinArea { + fMinGrowth = growth + fMinArea = area1 + iBest = (**(**TRtreeCell)(__ccgo_up(bp + 64))).FiRowid + } + goto _3 + _3: + ; + iCell = iCell + 1 + } + } + rc = _nodeAcquire(tls, pRtree, iBest, **(**uintptr)(__ccgo_up(bp)), bp+8) + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp + 8)) + goto _1 + _1: + ; + ii = ii + 1 + } + **(**uintptr)(__ccgo_up(ppLeaf)) = **(**uintptr)(__ccgo_up(bp)) + return rc +} + +const __INTPTR_MAX__ = 9223372036854775807 + +const __INTPTR_WIDTH__ = 64 + +const __PTRDIFF_MAX__ = 9223372036854775807 + +const __PTRDIFF_WIDTH__ = 64 + +const __SIZEOF_INT128__ = 16 + +const __SIZEOF_POINTER__ = 8 + +const __SIZEOF_PTRDIFF_T__ = 8 + +const __SIZEOF_SIZE_T__ = 8 + +const __SIZE_MAX__ = 18446744073709551615 + +const __SIZE_WIDTH__ = 64 + +const __UINTPTR_MAX__ = 18446744073709551615 + +// C documentation +// +// /* +// ** Add a new element to the pAggInfo->aCol[] array. Return the index of +// ** the new element. Return a negative number if malloc fails. +// */ +func _addAggInfoColumn(tls *libc.TLS, db uintptr, pInfo uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* i at bp+0 */ int32 + (*TAggInfo)(unsafe.Pointer(pInfo)).FaCol = _sqlite3ArrayAllocate(tls, db, (*TAggInfo)(unsafe.Pointer(pInfo)).FaCol, int32(32), pInfo+40, bp) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Add a new element to the pAggInfo->aFunc[] array. Return the index of +// ** the new element. Return a negative number if malloc fails. +// */ +func _addAggInfoFunc(tls *libc.TLS, db uintptr, pInfo uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* i at bp+0 */ int32 + (*TAggInfo)(unsafe.Pointer(pInfo)).FaFunc = _sqlite3ArrayAllocate(tls, db, (*TAggInfo)(unsafe.Pointer(pInfo)).FaFunc, int32(32), pInfo+56, bp) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Add connection db to the blocked connections list. It is assumed +// ** that it is not already a part of the list. +// */ +func _addToBlockedList(tls *libc.TLS, db uintptr) { + var pp uintptr + _ = pp + pp = uintptr(unsafe.Pointer(&_sqlite3BlockedList)) + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0 && (*Tsqlite3)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FxUnlockNotify != (*Tsqlite3)(unsafe.Pointer(db)).FxUnlockNotify) { + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 856 + } + (*Tsqlite3)(unsafe.Pointer(db)).FpNextBlocked = **(**uintptr)(__ccgo_up(pp)) + **(**uintptr)(__ccgo_up(pp)) = db +} + +// C documentation +// +// /* +// ** Set the bit number pgno in the PagerSavepoint.pInSavepoint +// ** bitvecs of all open savepoints. Return SQLITE_OK if successful +// ** or SQLITE_NOMEM if a malloc failure occurs. +// */ +func _addToSavepointBitvecs(tls *libc.TLS, pPager uintptr, pgno TPgno) (r int32) { + var ii, rc int32 + var p uintptr + _, _, _ = ii, p, rc /* Loop counter */ + rc = SQLITE_OK /* Result code */ + ii = 0 + for { + if !(ii < (*TPager)(unsafe.Pointer(pPager)).FnSavepoint) { + break + } + p = (*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*56 + if pgno <= (*TPagerSavepoint)(unsafe.Pointer(p)).FnOrig { + rc = rc | _sqlite3BitvecSet(tls, (*TPagerSavepoint)(unsafe.Pointer(p)).FpInSavepoint, pgno) + } + goto _1 + _1: + ; + ii = ii + 1 + } + return rc +} + +// C documentation +// +// /* +// ** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should +// ** have already been reserved using growVTrans(). +// */ +func _addToVTrans(tls *libc.TLS, db uintptr, pVTab uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + /* Add pVtab to the end of sqlite3.aVTrans */ + v2 = db + 572 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(v1)*8)) = pVTab + _sqlite3VtabLock(tls, pVTab) +} + +// C documentation +// +// /* Try to allocate nByte bytes of 8-byte aligned bulk memory for pBuf +// ** from the ReusableSpace object. Return a pointer to the allocated +// ** memory on success. If insufficient memory is available in the +// ** ReusableSpace object, increase the ReusableSpace.nNeeded +// ** value by the amount needed and return NULL. +// ** +// ** If pBuf is not initially NULL, that means that the memory has already +// ** been allocated by a prior call to this routine, so just return a copy +// ** of pBuf and leave ReusableSpace unchanged. +// ** +// ** This allocator is employed to repurpose unused slots at the end of the +// ** opcode array of prepared state for other memory needs of the prepared +// ** statement. +// */ +func _allocSpace(tls *libc.TLS, p uintptr, pBuf uintptr, nByte Tsqlite3_int64) (r uintptr) { + if pBuf == uintptr(0) { + nByte = nByte + if nByte <= (*TReusableSpace)(unsafe.Pointer(p)).FnFree { + **(**Tsqlite3_int64)(__ccgo_up(p + 8)) -= nByte + pBuf = (*TReusableSpace)(unsafe.Pointer(p)).FpSpace + uintptr((*TReusableSpace)(unsafe.Pointer(p)).FnFree) + } else { + **(**Tsqlite3_int64)(__ccgo_up(p + 16)) += nByte + } + } + return pBuf +} + +// C documentation +// +// /* +// ** Find the table named by the first entry in source list pSrc. If successful, +// ** return a pointer to the Table structure and set output variable (*pzDb) +// ** to point to the name of the database containin the table (i.e. "main", +// ** "temp" or the name of an attached database). +// ** +// ** If the table cannot be located, return NULL. The value of the two output +// ** parameters is undefined in this case. +// */ +func _alterFindTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, piDb uintptr, pzDb uintptr, bAuth int32) (r uintptr) { + var db, pTab uintptr + var iDb int32 + _, _, _ = db, iDb, pTab + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTab = uintptr(0) + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if pTab != 0 { + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + **(**uintptr)(__ccgo_up(pzDb)) = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + **(**int32)(__ccgo_up(piDb)) = iDb + if SQLITE_OK != _isRealTable(tls, pParse, pTab, int32(2)) || SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + pTab = uintptr(0) + } + } + if pTab != 0 && bAuth != 0 { + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), **(**uintptr)(__ccgo_up(pzDb)), (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + pTab = uintptr(0) + } + } + _sqlite3SrcListDelete(tls, db, pSrc) + return pTab +} + +// C documentation +// +// /* +// ** Generate code that will do an analysis of an entire database +// */ +func _analyzeDatabase(tls *libc.TLS, pParse uintptr, iDb int32) { + var db, k, pSchema, pTab uintptr + var iMem, iStatCur, iTab int32 + _, _, _, _, _, _, _ = db, iMem, iStatCur, iTab, k, pSchema, pTab + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + iStatCur = (*TParse)(unsafe.Pointer(pParse)).FnTab + **(**int32)(__ccgo_up(pParse + 56)) += int32(3) + _openStatTable(tls, pParse, iDb, iStatCur, uintptr(0), uintptr(0)) + iMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + iTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + k = (*THash)(unsafe.Pointer(pSchema + 8)).Ffirst + for { + if !(k != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(k)).Fdata + _analyzeOneTable(tls, pParse, pTab, uintptr(0), iStatCur, iMem, iTab) + iMem = _sqlite3FirstAvailableRegister(tls, pParse, iMem) + goto _1 + _1: + ; + k = (*THashElem)(unsafe.Pointer(k)).Fnext + } + _loadAnalysis(tls, pParse, iDb) +} + +// C documentation +// +// /* +// ** Try to convert a value into a numeric representation if we can +// ** do so without loss of information. In other words, if the string +// ** looks like a number, convert it into a number. If it does not +// ** look like a number, leave it alone. +// ** +// ** If the bTryForInt flag is true, then extra effort is made to give +// ** an integer representation. Strings that look like floating point +// ** values but which have no fractional component (example: '48.00') +// ** will have a MEM_Int representation when bTryForInt is true. +// ** +// ** If bTryForInt is false, then if the input string contains a decimal +// ** point or exponential notation, the result is only MEM_Real, even +// ** if there is an exact integer representation of the quantity. +// */ +func _applyNumericAffinity(tls *libc.TLS, pRec uintptr, bTryForInt int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var v1 uintptr + var _ /* rValue at bp+0 */ float64 + _, _ = rc, v1 + rc = _sqlite3MemRealValueRC(tls, pRec, bp) + if rc <= 0 { + return + } + if rc&int32(2) == 0 && _alsoAnInt(tls, pRec, **(**float64)(__ccgo_up(bp)), pRec) != 0 { + v1 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Int)) + } else { + *(*float64)(unsafe.Pointer(pRec)) = **(**float64)(__ccgo_up(bp)) + v1 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(MEM_Real)) + if bTryForInt != 0 { + _sqlite3VdbeIntegerAffinity(tls, pRec) + } + } + /* TEXT->NUMERIC is many->one. Hence, it is important to invalidate the + ** string representation after computing a numeric equivalent, because the + ** string representation might not be the canonical representation for the + ** numeric value. Ticket [343634942dd54ab57b7024] 2018-01-31. */ + v1 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(MEM_Str)) +} + +// C documentation +// +// /* +// ** Allocate a block of registers so that there is one register for each +// ** pAggInfo->aCol[] and pAggInfo->aFunc[] entry in pAggInfo. The first +// ** register in this block is stored in pAggInfo->iFirstReg. +// ** +// ** This routine may only be called once for each AggInfo object. Prior +// ** to calling this routine: +// ** +// ** * The aCol[] and aFunc[] arrays may be modified +// ** * The AggInfoColumnReg() and AggInfoFuncReg() macros may not be used +// ** +// ** After calling this routine: +// ** +// ** * The aCol[] and aFunc[] arrays are fixed +// ** * The AggInfoColumnReg() and AggInfoFuncReg() macros may be used +// ** +// */ +func _assignAggregateRegisters(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) { + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnFunc +} + +// C documentation +// +// /* +// ** Enter the mutex on every Btree associated with a database +// ** connection. This is needed (for example) prior to parsing +// ** a statement since we will be comparing table and column names +// ** against all schemas and we do not want those schemas being +// ** reset out from under us. +// ** +// ** There is a corresponding leave-all procedures. +// ** +// ** Enter the mutexes in ascending order by BtShared pointer address +// ** to avoid the possibility of deadlock when two threads with +// ** two or more btrees in common both try to lock all their btrees +// ** at the same instant. +// */ +func _btreeEnterAll(tls *libc.TLS, db uintptr) { + var i int32 + var p uintptr + var skipOk Tu8 + _, _, _ = i, p, skipOk + skipOk = uint8(1) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + p = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if p != 0 && (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + _sqlite3BtreeEnter(tls, p) + skipOk = uint8(0) + } + goto _1 + _1: + ; + i = i + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FnoSharedCache = skipOk +} + +// C documentation +// +// /* +// ** Invoke the busy handler for a btree. +// */ +func _btreeInvokeBusyHandler(tls *libc.TLS, pArg uintptr) (r int32) { + var pBt uintptr + _ = pBt + pBt = pArg + return _sqlite3InvokeBusyHandler(tls, (*TBtShared)(unsafe.Pointer(pBt)).Fdb+672) +} + +func _btreeLeaveAll(tls *libc.TLS, db uintptr) { + var i int32 + var p uintptr + _, _ = i, p + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + p = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if p != 0 { + _sqlite3BtreeLeave(tls, p) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Release all of the apPage[] pages for a cursor. +// */ +func _btreeReleaseAllCursorPages(tls *libc.TLS, pCur uintptr) { + var i int32 + _ = i + if int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage) >= 0 { + i = 0 + for { + if !(i < int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)) { + break + } + _releasePageNotNull(tls, **(**uintptr)(__ccgo_up(pCur + 144 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + _releasePageNotNull(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpPage) + (*TBtCursor)(unsafe.Pointer(pCur)).FiPage = int8(-int32(1)) + } +} + +// C documentation +// +// /* +// ** This function invokes either the xRollback or xCommit method +// ** of each of the virtual tables in the sqlite3.aVTrans array. The method +// ** called is identified by the second argument, "offset", which is +// ** the offset of the method to call in the sqlite3_module structure. +// ** +// ** The array is cleared after invoking the callbacks. +// */ +func _callFinaliser(tls *libc.TLS, db uintptr, offset int32) { + var aVTrans, p, pVTab, x uintptr + var i int32 + _, _, _, _, _ = aVTrans, i, p, pVTab, x + if (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans != 0 { + aVTrans = (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans + (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans = uintptr(0) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnVTrans) { + break + } + pVTab = **(**uintptr)(__ccgo_up(aVTrans + uintptr(i)*8)) + p = (*TVTable)(unsafe.Pointer(pVTab)).FpVtab + if p != 0 { + x = **(**uintptr)(__ccgo_up((*Tsqlite3_vtab)(unsafe.Pointer(p)).FpModule + uintptr(offset))) + if x != 0 { + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{x})))(tls, p) + } + } + (*TVTable)(unsafe.Pointer(pVTab)).FiSavepoint = 0 + _sqlite3VtabUnlock(tls, pVTab) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbFree(tls, db, aVTrans) + (*Tsqlite3)(unsafe.Pointer(db)).FnVTrans = 0 + } +} + +// C documentation +// +// /* +// ** This function does processing common to the _change_int64(), _change_text() +// ** and other similar APIs. +// */ +func _checkChangeParams(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, nReq Tsqlite3_int64, ppBuf uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pBuf uintptr + var _ /* rc at bp+0 */ int32 + _ = pBuf + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab == uintptr(0) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_MISUSE) + } else { + if iCol < 0 || iCol >= (*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_RANGE) + } else { + if bNew != 0 && (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_DELETE) || !(bNew != 0) && (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_INSERT) { + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + pBuf = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FaBuf + uintptr(iCol)*16 + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FeOp == int32(SQLITE_UPDATE) && bNew != 0 { + pBuf = pBuf + uintptr((*TSessionTable)(unsafe.Pointer((*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fcd.FpTab)).FnCol)*16 + } + (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = 0 + _sessionBufferGrow(tls, pBuf, nReq, bp) + (*TSessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = int32(nReq) + **(**uintptr)(__ccgo_up(ppBuf)) = pBuf + } + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** pEList is the SET clause of an UPDATE statement. Each entry +// ** in pEList is of the format =. If any of the entries +// ** in pEList have an which matches an identifier in pIdList, +// ** then return TRUE. If pIdList==NULL, then it is considered a +// ** wildcard that matches anything. Likewise if pEList==NULL then +// ** it matches anything so always return true. Return false only +// ** if there is no match. +// */ +func _checkColumnOverlap(tls *libc.TLS, pIdList uintptr, pEList uintptr) (r int32) { + var e int32 + _ = e + if pIdList == uintptr(0) || pEList == uintptr(0) { + return int32(1) + } + e = 0 + for { + if !(e < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if _sqlite3IdListIndex(tls, pIdList, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(e)*32))).FzEName) >= 0 { + return int32(1) + } + goto _1 + _1: + ; + e = e + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Invoke the progress handler, if appropriate. Also check for an +// ** interrupt. +// */ +func _checkProgress(tls *libc.TLS, pCheck uintptr) { + var db uintptr + _ = db + db = (*TIntegrityCk)(unsafe.Pointer(pCheck)).Fdb + if libc.AtomicLoadNInt32(db+432, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0 { + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_INTERRUPT) + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr + 1 + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = 0 + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != 0 { + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnStep = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnStep + 1 + if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnStep%(*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps == uint32(0) && (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { + (*TIntegrityCk)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_INTERRUPT) + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr + 1 + (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = 0 + } + } +} + +// C documentation +// +// /* +// ** Release all the table locks (locks obtained via calls to +// ** the setSharedCacheTableLock() procedure) held by Btree object p. +// ** +// ** This function assumes that Btree p has an open read or write +// ** transaction. If it does not, then the BTS_PENDING flag +// ** may be incorrectly cleared. +// */ +func _clearAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) { + var pBt, pLock, ppIter, v1 uintptr + _, _, _, _ = pBt, pLock, ppIter, v1 + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + ppIter = pBt + 120 + for **(**uintptr)(__ccgo_up(ppIter)) != 0 { + pLock = **(**uintptr)(__ccgo_up(ppIter)) + if (*TBtLock)(unsafe.Pointer(pLock)).FpBtree == p { + **(**uintptr)(__ccgo_up(ppIter)) = (*TBtLock)(unsafe.Pointer(pLock)).FpNext + if (*TBtLock)(unsafe.Pointer(pLock)).FiTable != uint32(1) { + Xsqlite3_free(tls, pLock) + } + } else { + ppIter = pLock + 16 + } + } + if (*TBtShared)(unsafe.Pointer(pBt)).FpWriter == p { + (*TBtShared)(unsafe.Pointer(pBt)).FpWriter = uintptr(0) + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTS_EXCLUSIVE) | libc.Int32FromInt32(BTS_PENDING))) + } else { + if (*TBtShared)(unsafe.Pointer(pBt)).FnTransaction == int32(2) { + /* This function is called when Btree p is concluding its + ** transaction. If there currently exists a writer, and p is not + ** that writer, then the number of locks held by connections other + ** than the writer must be about to drop to zero. In this case + ** set the BTS_PENDING flag to 0. + ** + ** If there is not currently a writer, then BTS_PENDING must + ** be zero already. So this next line is harmless in that case. + */ + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTS_PENDING)) + } + } +} + +// C documentation +// +// /* +// ** Close all cursors. +// ** +// ** Also release any dynamic memory held by the VM in the Vdbe.aMem memory +// ** cell array. This is necessary as the memory cell array may contain +// ** pointers to VdbeFrame objects, which may in turn contain pointers to +// ** open cursors. +// */ +func _closeAllCursors(tls *libc.TLS, p uintptr) { + var pDel, pFrame uintptr + _, _ = pDel, pFrame + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + pFrame = (*TVdbe)(unsafe.Pointer(p)).FpFrame + for { + if !((*TVdbeFrame)(unsafe.Pointer(pFrame)).FpParent != 0) { + break + } + goto _1 + _1: + ; + pFrame = (*TVdbeFrame)(unsafe.Pointer(pFrame)).FpParent + } + _sqlite3VdbeFrameRestore(tls, pFrame) + (*TVdbe)(unsafe.Pointer(p)).FpFrame = uintptr(0) + (*TVdbe)(unsafe.Pointer(p)).FnFrame = 0 + } + _closeCursorsInFrame(tls, p) + _releaseMemArray(tls, (*TVdbe)(unsafe.Pointer(p)).FaMem, (*TVdbe)(unsafe.Pointer(p)).FnMem) + for (*TVdbe)(unsafe.Pointer(p)).FpDelFrame != 0 { + pDel = (*TVdbe)(unsafe.Pointer(p)).FpDelFrame + (*TVdbe)(unsafe.Pointer(p)).FpDelFrame = (*TVdbeFrame)(unsafe.Pointer(pDel)).FpParent + _sqlite3VdbeFrameDelete(tls, pDel) + } + /* Delete any auxdata allocations made by the VM */ + if (*TVdbe)(unsafe.Pointer(p)).FpAuxData != 0 { + _sqlite3VdbeDeleteAuxData(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, p+296, -int32(1), 0) + } +} + +// C documentation +// +// /* +// ** Close all cursors in the current frame. +// */ +func _closeCursorsInFrame(tls *libc.TLS, p uintptr) { + var i int32 + var pC uintptr + _, _ = i, pC + i = 0 + for { + if !(i < (*TVdbe)(unsafe.Pointer(p)).FnCursor) { + break + } + pC = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(i)*8)) + if pC != 0 { + _sqlite3VdbeFreeCursorNN(tls, p, pC) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr(i)*8)) = uintptr(0) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Add code that will check to make sure the array of registers starting at +// ** iMem form a distinct entry. This is used by both "SELECT DISTINCT ..." and +// ** distinct aggregates ("SELECT count(DISTINCT ) ..."). Three strategies +// ** are available. Which is used depends on the value of parameter eTnctType, +// ** as follows: +// ** +// ** WHERE_DISTINCT_UNORDERED/WHERE_DISTINCT_NOOP: +// ** Build an ephemeral table that contains all entries seen before and +// ** skip entries which have been seen before. +// ** +// ** Parameter iTab is the cursor number of an ephemeral table that must +// ** be opened before the VM code generated by this routine is executed. +// ** The ephemeral cursor table is queried for a record identical to the +// ** record formed by the current array of registers. If one is found, +// ** jump to VM address addrRepeat. Otherwise, insert a new record into +// ** the ephemeral cursor and proceed. +// ** +// ** The returned value in this case is a copy of parameter iTab. +// ** +// ** WHERE_DISTINCT_ORDERED: +// ** In this case rows are being delivered sorted order. The ephemeral +// ** table is not required. Instead, the current set of values +// ** is compared against previous row. If they match, the new row +// ** is not distinct and control jumps to VM address addrRepeat. Otherwise, +// ** the VM program proceeds with processing the new row. +// ** +// ** The returned value in this case is the register number of the first +// ** in an array of registers used to store the previous result row so that +// ** it can be compared to the next. The caller must ensure that this +// ** register is initialized to NULL. (The fixDistinctOpenEph() routine +// ** will take care of this initialization.) +// ** +// ** WHERE_DISTINCT_UNIQUE: +// ** In this case it has already been determined that the rows are distinct. +// ** No special action is required. The return value is zero. +// ** +// ** Parameter pEList is the list of expressions used to generated the +// ** contents of each row. It is used by this routine to determine (a) +// ** how many elements there are in the array of registers and (b) the +// ** collation sequences that should be used for the comparisons if +// ** eTnctType is WHERE_DISTINCT_ORDERED. +// */ +func _codeDistinct(tls *libc.TLS, pParse uintptr, eTnctType int32, iTab int32, addrRepeat int32, pEList uintptr, regElem int32) (r int32) { + var i, iJump, iRet, nResultCol, r1, regPrev, v1 int32 + var pColl, v uintptr + _, _, _, _, _, _, _, _, _ = i, iJump, iRet, nResultCol, pColl, r1, regPrev, v, v1 + iRet = 0 + nResultCol = (*TExprList)(unsafe.Pointer(pEList)).FnExpr + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + switch eTnctType { + case int32(WHERE_DISTINCT_ORDERED): /* Previous row content */ + /* Allocate space for the previous row */ + v1 = (*TParse)(unsafe.Pointer(pParse)).FnMem + libc.Int32FromInt32(1) + regPrev = v1 + iRet = v1 + **(**int32)(__ccgo_up(pParse + 60)) += nResultCol + iJump = _sqlite3VdbeCurrentAddr(tls, v) + nResultCol + i = 0 + for { + if !(i < nResultCol) { + break + } + pColl = _sqlite3ExprCollSeq(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr) + if i < nResultCol-int32(1) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ne), regElem+i, iJump, regPrev+i) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), regElem+i, addrRepeat, regPrev+i) + } + _sqlite3VdbeChangeP4(tls, v, -int32(1), pColl, -int32(2)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NULLEQ)) + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regElem, regPrev, nResultCol-int32(1)) + case int32(WHERE_DISTINCT_UNIQUE): + /* nothing to do */ + default: + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iTab, addrRepeat, regElem, nResultCol) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regElem, nResultCol, r1) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iTab, r1, regElem, nResultCol) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + _sqlite3ReleaseTempReg(tls, pParse, r1) + iRet = iTab + break + } + return iRet +} + +// C documentation +// +// /* +// ** If the expression passed as the second argument is a vector, generate +// ** code to write the first nReg elements of the vector into an array +// ** of registers starting with iReg. +// ** +// ** If the expression is not a vector, then nReg must be passed 1. In +// ** this case, generate code to evaluate the expression and leave the +// ** result in register iReg. +// */ +func _codeExprOrVector(tls *libc.TLS, pParse uintptr, p uintptr, iReg int32, nReg int32) { + var i, iSelect int32 + var pList, v uintptr + _, _, _, _ = i, iSelect, pList, v + if p != 0 && _sqlite3ExprIsVector(tls, p) != 0 { + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + iSelect = _sqlite3CodeSubselect(tls, pParse, p) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), iSelect, iReg, nReg-int32(1)) + } else { + pList = *(*uintptr)(unsafe.Pointer(p + 32)) + i = 0 + for { + if !(i < nReg) { + break + } + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr, iReg+i) + goto _1 + _1: + ; + i = i + 1 + } + } + } else { + _sqlite3ExprCode(tls, pParse, p, iReg) + } +} + +// C documentation +// +// /* +// ** Return the size of the Nth element of the cell array +// */ +func _computeCellSize(tls *libc.TLS, p uintptr, N int32) (r Tu16) { + **(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2)) = (*(*func(*libc.TLS, uintptr, uintptr) Tu16)(unsafe.Pointer(&struct{ uintptr }{(*TMemPage)(unsafe.Pointer((*TCellArray)(unsafe.Pointer(p)).FpRef)).FxCellSize})))(tls, (*TCellArray)(unsafe.Pointer(p)).FpRef, **(**uintptr)(__ccgo_up((*TCellArray)(unsafe.Pointer(p)).FapCell + uintptr(N)*8))) + return **(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2)) +} + +// C documentation +// +// /* +// ** The CONCAT_WS(separator, ...) function. +// ** +// ** Generate a string that is the concatenation of 2nd through the Nth +// ** argument. Use the first argument (which must be non-NULL) as the +// ** separator. +// */ +func _concatwsFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var nSep int32 + var zSep uintptr + _, _ = nSep, zSep + nSep = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + zSep = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zSep == uintptr(0) { + return + } + _concatFuncCore(tls, context, argc-int32(1), argv+uintptr(1)*8, nSep, zSep) +} + +// C documentation +// +// /* +// ** Return TRUE if database connection db has unfinalized prepared +// ** statements or unfinished sqlite3_backup objects. +// */ +func _connectionIsBusy(tls *libc.TLS, db uintptr) (r int32) { + var j int32 + var pBt uintptr + _, _ = j, pBt + if (*Tsqlite3)(unsafe.Pointer(db)).FpVdbe != 0 { + return int32(1) + } + j = 0 + for { + if !(j < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*32))).FpBt + if pBt != 0 && _sqlite3BtreeIsInBackup(tls, pBt) != 0 { + return int32(1) + } + goto _1 + _1: + ; + j = j + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Worker function used by utf-8 APIs that create new functions: +// ** +// ** sqlite3_create_function() +// ** sqlite3_create_function_v2() +// ** sqlite3_create_window_function() +// */ +func _createFunctionApi(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, __ccgo_fp_xSFunc uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr, __ccgo_fp_xValue uintptr, __ccgo_fp_xInverse uintptr, __ccgo_fp_xDestroy uintptr) (r int32) { + var pArg uintptr + var rc int32 + _, _ = pArg, rc + rc = int32(SQLITE_ERROR) + pArg = uintptr(0) + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if __ccgo_fp_xDestroy != 0 { + pArg = _sqlite3Malloc(tls, uint64(24)) + if !(pArg != 0) { + _sqlite3OomFault(tls, db) + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDestroy})))(tls, p) + goto out + } + (*TFuncDestructor)(unsafe.Pointer(pArg)).FnRef = 0 + (*TFuncDestructor)(unsafe.Pointer(pArg)).FxDestroy = __ccgo_fp_xDestroy + (*TFuncDestructor)(unsafe.Pointer(pArg)).FpUserData = p + } + rc = _sqlite3CreateFunc(tls, db, zFunc, nArg, enc, p, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, __ccgo_fp_xValue, __ccgo_fp_xInverse, pArg) + if pArg != 0 && (*TFuncDestructor)(unsafe.Pointer(pArg)).FnRef == 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDestroy})))(tls, p) + Xsqlite3_free(tls, pArg) + } + goto out +out: + ; + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Open write transactions. Since we do not know in advance which database +// ** files will be written by the sqlite_dbpage virtual table, start a write +// ** transaction on them all. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code otherwise. +// */ +func _dbpageBeginTrans(tls *libc.TLS, pTab uintptr) (r int32) { + var db, pBt uintptr + var i, rc int32 + _, _, _, _ = db, i, pBt, rc + db = (*TDbpageTable)(unsafe.Pointer(pTab)).Fdb + rc = SQLITE_OK + i = 0 + for { + if !(rc == SQLITE_OK && i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 { + rc = _sqlite3BtreeBeginTrans(tls, pBt, int32(1), uintptr(0)) + } + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +// C documentation +// +// /* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT +// */ +func _dbpageSync(tls *libc.TLS, pVtab uintptr) (r int32) { + var pBt, pPager, pTab uintptr + _, _, _ = pBt, pPager, pTab + pTab = pVtab + if (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc > uint32(0) { + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TDbpageTable)(unsafe.Pointer(pTab)).Fdb)).FaDb + uintptr((*TDbpageTable)(unsafe.Pointer(pTab)).FiDbTrunc)*32))).FpBt + pPager = _sqlite3BtreePager(tls, pBt) + _sqlite3BtreeEnter(tls, pBt) + if (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc < _sqlite3BtreeLastPage(tls, pBt) { + _sqlite3PagerTruncateImage(tls, pPager, (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc) + } + _sqlite3BtreeLeave(tls, pBt) + } + (*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is called after a transaction has been committed. It +// ** invokes callbacks registered with sqlite3_wal_hook() as required. +// */ +func _doWalCallbacks(tls *libc.TLS, db uintptr) (r int32) { + var i, nEntry, rc int32 + var pBt uintptr + _, _, _, _ = i, nEntry, pBt, rc + rc = SQLITE_OK + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 { + _sqlite3BtreeEnter(tls, pBt) + nEntry = _sqlite3PagerWalCallback(tls, _sqlite3BtreePager(tls, pBt)) + _sqlite3BtreeLeave(tls, pBt) + if nEntry > 0 && (*Tsqlite3)(unsafe.Pointer(db)).FxWalCallback != 0 && rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxWalCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpWalArg, db, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName, nEntry) + } + } + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +// C documentation +// +// /* +// ** This function changes all write-locks held by Btree p into read-locks. +// */ +func _downgradeAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) { + var pBt, pLock, v1 uintptr + _, _, _ = pBt, pLock, v1 + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + if (*TBtShared)(unsafe.Pointer(pBt)).FpWriter == p { + (*TBtShared)(unsafe.Pointer(pBt)).FpWriter = uintptr(0) + v1 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTS_EXCLUSIVE) | libc.Int32FromInt32(BTS_PENDING))) + pLock = (*TBtShared)(unsafe.Pointer(pBt)).FpLock + for { + if !(pLock != 0) { + break + } + (*TBtLock)(unsafe.Pointer(pLock)).FeLock = uint8(READ_LOCK) + goto _2 + _2: + ; + pLock = (*TBtLock)(unsafe.Pointer(pLock)).FpNext + } + } +} + +/* Forward reference */ + +/* +***** This routine is used inside of assert() only **** +** +** Verify that the cursor holds the mutex on its BtShared + */ + +/* +** Invalidate the overflow cache of the cursor passed as the first argument. +** on the shared btree structure pBt. + */ + +// C documentation +// +// /* +// ** Return the length of the longest string literal in the given +// ** expression. +// ** +// ** eCode indicates how to count characters: +// ** +// ** eCode==0 Count as a GLOB pattern +// ** eCode==1 Count as a LIKE pattern +// */ +func _estLikePatternLength(tls *libc.TLS, p uintptr, eCode Tu16) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + *(*int32)(unsafe.Pointer(bp + 40)) = 0 + (**(**TWalker)(__ccgo_up(bp))).FeCode = eCode + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprNodePatternLengthEst) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkFail) + _sqlite3WalkExpr(tls, bp, p) + return *(*int32)(unsafe.Pointer(bp + 40)) +} + +// C documentation +// +// /* +// ** Estimate the total row width for a table. +// */ +func _estimateTableWidth(tls *libc.TLS, pTab uintptr) { + var i int32 + var pTabCol uintptr + var wTable uint32 + _, _, _ = i, pTabCol, wTable + wTable = uint32(0) + i = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + pTabCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + for { + if !(i > 0) { + break + } + wTable = wTable + uint32((*TColumn)(unsafe.Pointer(pTabCol)).FszEst) + goto _1 + _1: + ; + i = i - 1 + pTabCol += 16 + } + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) < 0 { + wTable = wTable + 1 + } + (*TTable)(unsafe.Pointer(pTab)).FszTabRow = _sqlite3LogEst(tls, uint64(wTable*uint32(4))) +} + +// C documentation +// +// /* +// ** Delete an entire expression list. +// */ +func _exprListDeleteNN(tls *libc.TLS, db uintptr, pList uintptr) { + var i, v1 int32 + var pItem uintptr + _, _, _ = i, pItem, v1 + i = (*TExprList)(unsafe.Pointer(pList)).FnExpr + pItem = pList + 8 + for { + _sqlite3ExprDelete(tls, db, (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr) + if (*TExprList_item)(unsafe.Pointer(pItem)).FzEName != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TExprList_item)(unsafe.Pointer(pItem)).FzEName) + } + pItem += 32 + goto _2 + _2: + ; + i = i - 1 + v1 = i + if !(v1 > 0) { + break + } + } + _sqlite3DbNNFreeNN(tls, db, pList) +} + +// C documentation +// +// /* +// ** Return true if all expressions in the expression-list passed as the +// ** only argument are constant. +// */ +func _exprListIsConstant(tls *libc.TLS, pParse uintptr, pRow uintptr) (r int32) { + var ii int32 + _ = ii + ii = 0 + for { + if !(ii < (*TExprList)(unsafe.Pointer(pRow)).FnExpr) { + break + } + if 0 == _sqlite3ExprIsConstant(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pRow + 8 + uintptr(ii)*32))).FpExpr) { + return 0 + } + goto _1 + _1: + ; + ii = ii + 1 + } + return int32(1) +} + +// C documentation +// +// /* +// ** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy(). +// */ +func _exprNodeIsConstantOrGroupBy(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + var i int32 + var p, pColl, pGroupBy uintptr + _, _, _, _ = i, p, pColl, pGroupBy + pGroupBy = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + /* Check if pExpr is identical to any GROUP BY term. If so, consider + ** it constant. */ + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { + break + } + p = (*(*TExprList_item)(unsafe.Pointer(pGroupBy + 8 + uintptr(i)*32))).FpExpr + if _sqlite3ExprCompare(tls, uintptr(0), pExpr, p, -int32(1)) < int32(2) { + pColl = _sqlite3ExprNNCollSeq(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, p) + if _sqlite3IsBinary(tls, pColl) != 0 { + return int32(WRC_Prune) + } + } + goto _1 + _1: + ; + i = i + 1 + } + /* Check if pExpr is a sub-select. If so, consider it variable. */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0) + return int32(WRC_Abort) + } + return _exprNodeIsConstant(tls, pWalker, pExpr) +} + +// C documentation +// +// /* +// ** Expression pExpr is guaranteed to be a TK_COLUMN or equivalent. This +// ** function checks the Parse.pIdxPartExpr list to see if this column +// ** can be replaced with a constant value. If so, it generates code to +// ** put the constant value in a register (ideally, but not necessarily, +// ** register iTarget) and returns the register number. +// ** +// ** Or, if the TK_COLUMN cannot be replaced by a constant, zero is +// ** returned. +// */ +func _exprPartidxExprLookup(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTarget int32) (r int32) { + var addr, ret int32 + var p, v uintptr + _, _, _, _ = addr, p, ret, v + p = (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr + for { + if !(p != 0) { + break + } + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) == (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCol && (*TExpr)(unsafe.Pointer(pExpr)).FiTable == (*TIndexedExpr)(unsafe.Pointer(p)).FiDataCur { + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + addr = 0 + if (*TIndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow != 0 { + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IfNullRow), (*TIndexedExpr)(unsafe.Pointer(p)).FiIdxCur) + } + ret = _sqlite3ExprCodeTarget(tls, pParse, (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr, iTarget) + _sqlite3VdbeAddOp4(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Affinity), ret, int32(1), 0, p+21, int32(1)) + if addr != 0 { + _sqlite3VdbeJumpHere(tls, v, addr) + _sqlite3VdbeChangeP3(tls, v, addr, ret) + } + return ret + } + goto _1 + _1: + ; + p = (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext + } + return 0 +} + +// C documentation +// +// /* +// ** Recursively walk the expressions of a SELECT statement and generate +// ** a bitmask indicating which tables are used in that expression +// ** tree. +// */ +func _exprSelectUsage(tls *libc.TLS, pMaskSet uintptr, pS uintptr) (r TBitmask) { + var i int32 + var mask TBitmask + var pSrc uintptr + _, _, _ = i, mask, pSrc + mask = uint64(0) + for pS != 0 { + pSrc = (*TSelect)(unsafe.Pointer(pS)).FpSrc + mask = mask | _sqlite3WhereExprListUsage(tls, pMaskSet, (*TSelect)(unsafe.Pointer(pS)).FpEList) + mask = mask | _sqlite3WhereExprListUsage(tls, pMaskSet, (*TSelect)(unsafe.Pointer(pS)).FpGroupBy) + mask = mask | _sqlite3WhereExprListUsage(tls, pMaskSet, (*TSelect)(unsafe.Pointer(pS)).FpOrderBy) + mask = mask | _sqlite3WhereExprUsage(tls, pMaskSet, (*TSelect)(unsafe.Pointer(pS)).FpWhere) + mask = mask | _sqlite3WhereExprUsage(tls, pMaskSet, (*TSelect)(unsafe.Pointer(pS)).FpHaving) + if pSrc != uintptr(0) { + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 24 + 4))&0x4>>2) != 0 { + mask = mask | _exprSelectUsage(tls, pMaskSet, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 72)))).FpSelect) + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 24 + 4))&0x800>>11) == 0 { + mask = mask | _sqlite3WhereExprUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 64))) + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 24 + 4))&0x8>>3) != 0 { + mask = mask | _sqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 48))) + } + goto _1 + _1: + ; + i = i + 1 + } + } + pS = (*TSelect)(unsafe.Pointer(pS)).FpPrior + } + return mask +} + +// C documentation +// +// /* +// ** Return an Expr object that refers to column iCol of table pTab which +// ** has cursor iCur. +// */ +func _exprTableColumn(tls *libc.TLS, db uintptr, pTab uintptr, iCursor int32, iCol Ti16) (r uintptr) { + var pExpr uintptr + _ = pExpr + pExpr = _sqlite3Expr(tls, db, int32(TK_COLUMN), uintptr(0)) + if pExpr != 0 { + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = iCursor + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = iCol + } + return pExpr +} + +// C documentation +// +// /* +// ** The implementation of SQL function sqlite_fail(MSG). This takes a single +// ** argument, and returns it as an error message with the error code set to +// ** SQLITE_CONSTRAINT. +// */ +func _failConstraintFunc(tls *libc.TLS, ctx uintptr, NotUsed int32, argv uintptr) { + var err int32 + var zText uintptr + _, _ = err, zText + zText = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + err = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + _ = NotUsed + Xsqlite3_result_error(tls, ctx, zText, -int32(1)) + Xsqlite3_result_error_code(tls, ctx, err) +} + +// C documentation +// +// /* +// ** Implementation of internal SQL function: +// ** +// ** sqlite_find_constraint(SQL, CONSTRAINT-NAME) +// ** +// ** This function returns true if the SQL passed as the first argument is a +// ** CREATE TABLE that contains a constraint with the name CONSTRAINT-NAME, +// ** or false otherwise. +// */ +func _findConstraintFunc(tls *libc.TLS, ctx uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iOff, nTok int32 + var zCons, zSql uintptr + var _ /* cmp at bp+4 */ int32 + var _ /* t at bp+0 */ int32 + _, _, _, _ = iOff, nTok, zCons, zSql + zSql = uintptr(0) + zCons = uintptr(0) + iOff = 0 + **(**int32)(__ccgo_up(bp)) = 0 + _ = NotUsed + zSql = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + zCons = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zSql == uintptr(0) || zCons == uintptr(0) { + return + } + for **(**int32)(__ccgo_up(bp)) != int32(TK_LP) && **(**int32)(__ccgo_up(bp)) != int32(TK_ILLEGAL) { + iOff = int32(int64(iOff) + _sqlite3GetToken(tls, zSql+uintptr(iOff), bp)) + } + for int32(1) != 0 { + iOff = iOff + _getConstraintToken(tls, zSql+uintptr(iOff), bp) + if **(**int32)(__ccgo_up(bp)) == int32(TK_CONSTRAINT) { + nTok = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + iOff = iOff + _getWhitespace(tls, zSql+uintptr(iOff)) + nTok = _getConstraintToken(tls, zSql+uintptr(iOff), bp) + if _quotedCompare(tls, ctx, **(**int32)(__ccgo_up(bp)), zSql+uintptr(iOff), nTok, zCons, bp+4) != 0 { + return + } + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + Xsqlite3_result_int(tls, ctx, int32(1)) + return + } + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) { + break + } + } + } + Xsqlite3_result_int(tls, ctx, 0) +} + +// C documentation +// +// /* This function (for internal use only) locates an element in an +// ** hash table that matches the given key. If no element is found, +// ** a pointer to a static null element with HashElem.data==0 is returned. +// ** If pH is not NULL, then the hash for this key is written to *pH. +// */ +func _findElementWithHash(tls *libc.TLS, pH uintptr, pKey uintptr, pHash uintptr) (r uintptr) { + var count, h uint32 + var elem, pEntry uintptr + _, _, _, _ = count, elem, h, pEntry /* The computed hash */ + h = _strHash(tls, pKey) + if (*THash)(unsafe.Pointer(pH)).Fht != 0 { + pEntry = (*THash)(unsafe.Pointer(pH)).Fht + uintptr(h%(*THash)(unsafe.Pointer(pH)).Fhtsize)*16 + elem = (*T_ht)(unsafe.Pointer(pEntry)).Fchain + count = (*T_ht)(unsafe.Pointer(pEntry)).Fcount + } else { + elem = (*THash)(unsafe.Pointer(pH)).Ffirst + count = (*THash)(unsafe.Pointer(pH)).Fcount + } + if pHash != 0 { + **(**uint32)(__ccgo_up(pHash)) = h + } + for count != 0 { + if h == (*THashElem)(unsafe.Pointer(elem)).Fh && _sqlite3StrICmp(tls, (*THashElem)(unsafe.Pointer(elem)).FpKey, pKey) == 0 { + return elem + } + elem = (*THashElem)(unsafe.Pointer(elem)).Fnext + count = count - 1 + } + return uintptr(unsafe.Pointer(&_nullElement)) +} + +// C documentation +// +// /* +// ** The second argument points to an FKey object representing a foreign key +// ** for which pTab is the child table. An UPDATE statement against pTab +// ** is currently being processed. For each column of the table that is +// ** actually updated, the corresponding element in the aChange[] array +// ** is zero or greater (if a column is unmodified the corresponding element +// ** is set to -1). If the rowid column is modified by the UPDATE statement +// ** the bChngRowid argument is non-zero. +// ** +// ** This function returns true if any of the columns that are part of the +// ** child key for FK constraint *p are modified. +// */ +func _fkChildIsModified(tls *libc.TLS, pTab uintptr, p uintptr, aChange uintptr, bChngRowid int32) (r int32) { + var i, iChildKey int32 + _, _ = i, iChildKey + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(p)).FnCol) { + break + } + iChildKey = (*(*TsColMap)(unsafe.Pointer(p + 64 + uintptr(i)*16))).FiFrom + if **(**int32)(__ccgo_up(aChange + uintptr(iChildKey)*4)) >= 0 { + return int32(1) + } + if iChildKey == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) && bChngRowid != 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Free an sqlite3_index_info structure allocated by allocateIndexInfo() +// ** and possibly modified by xBestIndex methods. +// */ +func _freeIndexInfo(tls *libc.TLS, db uintptr, pIdxInfo uintptr) { + var i int32 + var pHidden uintptr + _, _ = i, pHidden + pHidden = pIdxInfo + 1*96 + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { + break + } + _sqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(pHidden + 32 + uintptr(i)*8))) /* IMP: R-14553-25174 */ + *(*uintptr)(unsafe.Pointer(pHidden + 32 + uintptr(i)*8)) = uintptr(0) + goto _1 + _1: + ; + i = i + 1 + } + _freeIdxStr(tls, pIdxInfo) + _sqlite3DbFree(tls, db, pIdxInfo) +} + +// C documentation +// +// /* +// ** Free the pBt->pTmpSpace allocation +// */ +func _freeTempSpace(tls *libc.TLS, pBt uintptr) { + if (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace != 0 { + **(**uintptr)(__ccgo_up(pBt + 136)) -= uintptr(4) + _sqlite3PageFree(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace) + (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Implementation of API function xQueryPhrase(). +// */ +func _fts5ApiQueryPhrase(tls *libc.TLS, pCtx uintptr, iPhrase int32, pUserData uintptr, __ccgo_fp_xCallback uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pCsr, pTab uintptr + var rc int32 + var _ /* pNew at bp+0 */ uintptr + _, _, _ = pCsr, pTab, rc + pCsr = pCtx + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _fts5OpenMethod(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, bp) + if rc == SQLITE_OK { + (*TFts5Cursor)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FePlan = int32(FTS5_PLAN_MATCH) + (*TFts5Cursor)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FiFirstRowid = int64(-libc.Int32FromInt32(1)) - (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)<= _sqlite3Fts5ExprPhraseCount(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) { + rc = int32(SQLITE_RANGE) + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail != FTS5_DETAIL_FULL && _fts5IsContentless(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, int32(1)) != 0 { + **(**uintptr)(__ccgo_up(pa)) = uintptr(0) + **(**int32)(__ccgo_up(pn)) = 0 + return SQLITE_OK + } else { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_POSLIST) != 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail != FTS5_DETAIL_FULL { + aPopulator = _sqlite3Fts5ExprClearPoslists(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, bLive) + if aPopulator == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + if rc == SQLITE_OK { + rc = _fts5SeekCursor(tls, pCsr, 0) + } + i = 0 + for { + if !(i < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol && rc == SQLITE_OK) { + break + } + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = 0 + rc = _fts5TextFromStmt(tls, pConfig, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, i, bp, bp+8) + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprPopulatePoslists(tls, pConfig, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, aPopulator, i, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8))) + } + _sqlite3Fts5ClearLocale(tls, pConfig) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, aPopulator) + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 { + _sqlite3Fts5ExprCheckPoslists(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*TFts5Sorter)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter)).FiRowid) + } + } + **(**int32)(__ccgo_up(pCsr + 80)) &= ^libc.Int32FromInt32(FTS5CSR_REQUIRE_POSLIST) + } + } + } + if rc == SQLITE_OK { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 && (*TFts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_FULL { + pSorter = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter + if iPhrase == 0 { + v2 = 0 + } else { + v2 = *(*int32)(unsafe.Pointer(pSorter + 28 + uintptr(iPhrase-int32(1))*4)) + } + i1 = v2 + **(**int32)(__ccgo_up(pn)) = *(*int32)(unsafe.Pointer(pSorter + 28 + uintptr(iPhrase)*4)) - i1 + **(**uintptr)(__ccgo_up(pa)) = (*TFts5Sorter)(unsafe.Pointer(pSorter)).FaPoslist + uintptr(i1) + } else { + **(**int32)(__ccgo_up(pn)) = _sqlite3Fts5ExprPoslist(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, pa) + } + } else { + **(**uintptr)(__ccgo_up(pa)) = uintptr(0) + **(**int32)(__ccgo_up(pn)) = 0 + } + return rc +} + +func _fts5CursorFirst(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int32) (r int32) { + var pExpr uintptr + var rc int32 + _, _ = pExpr, rc + pExpr = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr + rc = _sqlite3Fts5ExprFirst(tls, pExpr, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid, bDesc) + if _sqlite3Fts5ExprEof(tls, pExpr) != 0 { + **(**int32)(__ccgo_up(pCsr + 80)) |= int32(FTS5CSR_EOF) + } + _fts5CsrNewrow(tls, pCsr) + return rc +} + +// C documentation +// +// /* +// ** If the REQUIRE_RESEEK flag is set on the cursor passed as the first +// ** argument, close and reopen all Fts5IndexIter iterators that the cursor +// ** is using. Then attempt to move the cursor to a rowid equal to or laster +// ** (in the cursors sort order - ASC or DESC) than the current rowid. +// ** +// ** If the new rowid is not equal to the old, set output parameter *pbSkip +// ** to 1 before returning. Otherwise, leave it unchanged. +// ** +// ** Return SQLITE_OK if successful or if no reseek was required, or an +// ** error code if an error occurred. +// */ +func _fts5CursorReseek(tls *libc.TLS, pCsr uintptr, pbSkip uintptr) (r int32) { + var bDesc, rc int32 + var iRowid Ti64 + var pTab uintptr + _, _, _, _ = bDesc, iRowid, pTab, rc + rc = SQLITE_OK + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_RESEEK) != 0 { + pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab + bDesc = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FbDesc + iRowid = _sqlite3Fts5ExprRowid(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) + rc = _sqlite3Fts5ExprFirst(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, iRowid, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid, bDesc) + if rc == SQLITE_OK && iRowid != _sqlite3Fts5ExprRowid(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) { + **(**int32)(__ccgo_up(pbSkip)) = int32(1) + } + **(**int32)(__ccgo_up(pCsr + 80)) &= ^libc.Int32FromInt32(FTS5CSR_REQUIRE_RESEEK) + _fts5CsrNewrow(tls, pCsr) + if _sqlite3Fts5ExprEof(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) != 0 { + **(**int32)(__ccgo_up(pCsr + 80)) |= int32(FTS5CSR_EOF) + **(**int32)(__ccgo_up(pbSkip)) = int32(1) + } + } + return rc +} + +func _fts5ExprCheckPoslists(tls *libc.TLS, pNode uintptr, iRowid Ti64) (r int32) { + var bRet, i, i1 int32 + _, _, _ = bRet, i, i1 + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = iRowid + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 + switch (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType { + case 0: + fallthrough + case int32(FTS5_TERM): + fallthrough + case int32(FTS5_STRING): + return libc.BoolInt32((*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24)))).Fposlist.Fn > 0) + case int32(FTS5_AND): + i = 0 + for { + if !(i < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild) { + break + } + if _fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i)*8)), iRowid) == 0 { + _fts5ExprClearPoslists(tls, pNode) + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + case int32(FTS5_OR): + bRet = 0 + i1 = 0 + for { + if !(i1 < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild) { + break + } + if _fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i1)*8)), iRowid) != 0 { + bRet = int32(1) + } + goto _2 + _2: + ; + i1 = i1 + 1 + } + return bRet + default: + if 0 == _fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 48)), iRowid) || 0 != _fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 48 + 1*8)), iRowid) { + _fts5ExprClearPoslists(tls, pNode) + return 0 + } + break + } + return int32(1) +} + +func _fts5ExprClearPoslists(tls *libc.TLS, pNode uintptr) { + var i int32 + _ = i + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType == int32(FTS5_TERM) || (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType == int32(FTS5_STRING) { + (*TFts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24)))).Fposlist.Fn = 0 + } else { + i = 0 + for { + if !(i < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild) { + break + } + _fts5ExprClearPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** Set node pNode, which is part of expression pExpr, to point to the first +// ** match. If there are no matches, set the Node.bEof flag to indicate EOF. +// ** +// ** Return an SQLite error code if an error occurs, or SQLITE_OK otherwise. +// ** It is not an error if there are no matches. +// */ +func _fts5ExprNodeFirst(tls *libc.TLS, pExpr uintptr, pNode uintptr) (r int32) { + var i, nEof, rc int32 + var pChild uintptr + _, _, _, _ = i, nEof, pChild, rc + rc = SQLITE_OK + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType == int32(FTS5_TERM) || (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType == int32(FTS5_STRING) { + /* Initialize all term iterators in the NEAR object. */ + rc = _fts5ExprNearInitAll(tls, pExpr, pNode) + } else { + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FxNext == uintptr(0) { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = int32(1) + } else { + nEof = 0 + i = 0 + for { + if !(i < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild && rc == SQLITE_OK) { + break + } + pChild = *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i)*8)) + rc = _fts5ExprNodeFirst(tls, pExpr, *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i)*8))) + nEof = nEof + (*TFts5ExprNode)(unsafe.Pointer(pChild)).FbEof + goto _1 + _1: + ; + i = i + 1 + } + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*TFts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 48)))).FiRowid + switch (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType { + case int32(FTS5_AND): + if nEof > 0 { + _fts5ExprSetEof(tls, pNode) + } + case int32(FTS5_OR): + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild == nEof { + _fts5ExprSetEof(tls, pNode) + } + default: + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*TFts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 48)))).FbEof + break + } + } + } + if rc == SQLITE_OK { + rc = _fts5ExprNodeTest(tls, pExpr, pNode) + } + return rc +} + +func _fts5ExprNodeNext_AND(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom Ti64) (r int32) { + var rc int32 + _ = rc + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 48)))).FxNext})))(tls, pExpr, *(*uintptr)(unsafe.Pointer(pNode + 48)), bFromValid, iFrom) + if rc == SQLITE_OK { + rc = _fts5ExprNodeTest_AND(tls, pExpr, pNode) + } else { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 + } + return rc +} + +func _fts5ExprNodeNext_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom Ti64) (r int32) { + var rc int32 + _ = rc + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 48)))).FxNext})))(tls, pExpr, *(*uintptr)(unsafe.Pointer(pNode + 48)), bFromValid, iFrom) + if rc == SQLITE_OK { + rc = _fts5ExprNodeTest_NOT(tls, pExpr, pNode) + } + if rc != SQLITE_OK { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 + } + return rc +} + +func _fts5ExprNodeNext_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom Ti64) (r int32) { + var i, rc int32 + var iLast Ti64 + var p1 uintptr + _, _, _, _ = i, iLast, p1, rc + iLast = (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid + i = 0 + for { + if !(i < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild) { + break + } + p1 = *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i)*8)) + if (*TFts5ExprNode)(unsafe.Pointer(p1)).FbEof == 0 { + if (*TFts5ExprNode)(unsafe.Pointer(p1)).FiRowid == iLast || bFromValid != 0 && _fts5RowidCmp(tls, pExpr, (*TFts5ExprNode)(unsafe.Pointer(p1)).FiRowid, iFrom) < 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(p1)).FxNext})))(tls, pExpr, p1, bFromValid, iFrom) + if rc != SQLITE_OK { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 + return rc + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + _fts5ExprNodeTest_OR(tls, pExpr, pNode) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Argument pNode is an FTS5_AND node. +// */ +func _fts5ExprNodeTest_AND(tls *libc.TLS, pExpr uintptr, pAnd uintptr) (r int32) { + var bMatch, cmp, iChild, rc int32 + var iLast Ti64 + var pChild uintptr + _, _, _, _, _, _ = bMatch, cmp, iChild, iLast, pChild, rc + iLast = (*TFts5ExprNode)(unsafe.Pointer(pAnd)).FiRowid + rc = SQLITE_OK + for cond := true; cond; cond = bMatch == 0 { + (*TFts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch = 0 + bMatch = int32(1) + iChild = 0 + for { + if !(iChild < (*TFts5ExprNode)(unsafe.Pointer(pAnd)).FnChild) { + break + } + pChild = *(*uintptr)(unsafe.Pointer(pAnd + 48 + uintptr(iChild)*8)) + cmp = _fts5RowidCmp(tls, pExpr, iLast, (*TFts5ExprNode)(unsafe.Pointer(pChild)).FiRowid) + if cmp > 0 { + /* Advance pChild until it points to iLast or laster */ + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(pChild)).FxNext})))(tls, pExpr, pChild, int32(1), iLast) + if rc != SQLITE_OK { + (*TFts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch = 0 + return rc + } + } + /* If the child node is now at EOF, so is the parent AND node. Otherwise, + ** the child node is guaranteed to have advanced at least as far as + ** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the + ** new lastest rowid seen so far. */ + if (*TFts5ExprNode)(unsafe.Pointer(pChild)).FbEof != 0 { + _fts5ExprSetEof(tls, pAnd) + bMatch = int32(1) + break + } else { + if iLast != (*TFts5ExprNode)(unsafe.Pointer(pChild)).FiRowid { + bMatch = 0 + iLast = (*TFts5ExprNode)(unsafe.Pointer(pChild)).FiRowid + } + } + if (*TFts5ExprNode)(unsafe.Pointer(pChild)).FbNomatch != 0 { + (*TFts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch = int32(1) + } + goto _1 + _1: + ; + iChild = iChild + 1 + } + } + if (*TFts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch != 0 && pAnd != (*TFts5Expr)(unsafe.Pointer(pExpr)).FpRoot { + _fts5ExprNodeZeroPoslist(tls, pAnd) + } + (*TFts5ExprNode)(unsafe.Pointer(pAnd)).FiRowid = iLast + return SQLITE_OK +} + +func _fts5ExprNodeTest_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr) (r int32) { + var cmp, rc int32 + var p1, p2 uintptr + _, _, _, _ = cmp, p1, p2, rc + rc = SQLITE_OK + p1 = *(*uintptr)(unsafe.Pointer(pNode + 48)) + p2 = *(*uintptr)(unsafe.Pointer(pNode + 48 + 1*8)) + for rc == SQLITE_OK && (*TFts5ExprNode)(unsafe.Pointer(p1)).FbEof == 0 { + cmp = _fts5NodeCompare(tls, pExpr, p1, p2) + if cmp > 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(p2)).FxNext})))(tls, pExpr, p2, int32(1), (*TFts5ExprNode)(unsafe.Pointer(p1)).FiRowid) + cmp = _fts5NodeCompare(tls, pExpr, p1, p2) + } + if cmp != 0 || (*TFts5ExprNode)(unsafe.Pointer(p2)).FbNomatch != 0 { + break + } + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(p1)).FxNext})))(tls, pExpr, p1, 0, int64(libc.Int32FromInt32(0))) + } + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*TFts5ExprNode)(unsafe.Pointer(p1)).FbEof + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (*TFts5ExprNode)(unsafe.Pointer(p1)).FbNomatch + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*TFts5ExprNode)(unsafe.Pointer(p1)).FiRowid + if (*TFts5ExprNode)(unsafe.Pointer(p1)).FbEof != 0 { + _fts5ExprNodeZeroPoslist(tls, p2) + } + return rc +} + +func _fts5ExprNodeTest_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr) { + var cmp, i int32 + var pChild, pNext uintptr + _, _, _, _ = cmp, i, pChild, pNext + pNext = *(*uintptr)(unsafe.Pointer(pNode + 48)) + i = int32(1) + for { + if !(i < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild) { + break + } + pChild = *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i)*8)) + cmp = _fts5NodeCompare(tls, pExpr, pNext, pChild) + if cmp > 0 || cmp == 0 && (*TFts5ExprNode)(unsafe.Pointer(pChild)).FbNomatch == 0 { + pNext = pChild + } + goto _1 + _1: + ; + i = i + 1 + } + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*TFts5ExprNode)(unsafe.Pointer(pNext)).FiRowid + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*TFts5ExprNode)(unsafe.Pointer(pNext)).FbEof + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (*TFts5ExprNode)(unsafe.Pointer(pNext)).FbNomatch +} + +// C documentation +// +// /* +// ** All individual term iterators in pNear are guaranteed to be valid when +// ** this function is called. This function checks if all term iterators +// ** point to the same rowid, and if not, advances them until they do. +// ** If an EOF is reached before this happens, *pbEof is set to true before +// ** returning. +// ** +// ** SQLITE_OK is returned if an error occurs, or an SQLite error code +// ** otherwise. It is not considered an error code if an iterator reaches +// ** EOF. +// */ +func _fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bDesc, bMatch, i, j int32 + var iRowid Ti64 + var pIter, pLeft, pNear, pPhrase, pTerm uintptr + var _ /* iLast at bp+8 */ Ti64 + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = bDesc, bMatch, i, iRowid, j, pIter, pLeft, pNear, pPhrase, pTerm + pNear = (*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + pLeft = *(*uintptr)(unsafe.Pointer(pNear + 24)) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* True if all terms are at the same rowid */ + bDesc = (*TFts5Expr)(unsafe.Pointer(pExpr)).FbDesc + /* Check that this node should not be FTS5_TERM */ + /* Initialize iLast, the "lastest" rowid any iterator points to. If the + ** iterator skips through rowids in the default ascending order, this means + ** the maximum rowid. Or, if the iterator is "ORDER BY rowid DESC", then it + ** means the minimum rowid. */ + if (*(*TFts5ExprTerm)(unsafe.Pointer(pLeft + 32))).FpSynonym != 0 { + **(**Ti64)(__ccgo_up(bp + 8)) = _fts5ExprSynonymRowid(tls, pLeft+32, bDesc, uintptr(0)) + } else { + **(**Ti64)(__ccgo_up(bp + 8)) = (*TFts5IndexIter)(unsafe.Pointer((*(*TFts5ExprTerm)(unsafe.Pointer(pLeft + 32))).FpIter)).FiRowid + } + for cond := true; cond; cond = bMatch == 0 { + bMatch = int32(1) + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + pPhrase = *(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(i)*8)) + j = 0 + for { + if !(j < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + pTerm = pPhrase + 32 + uintptr(j)*40 + if (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { + iRowid = _fts5ExprSynonymRowid(tls, pTerm, bDesc, uintptr(0)) + if iRowid == **(**Ti64)(__ccgo_up(bp + 8)) { + goto _2 + } + bMatch = 0 + if _fts5ExprSynonymAdvanceto(tls, pTerm, bDesc, bp+8, bp) != 0 { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = int32(1) + return **(**int32)(__ccgo_up(bp)) + } + } else { + pIter = (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32 + uintptr(j)*40))).FpIter + if (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == **(**Ti64)(__ccgo_up(bp + 8)) { + goto _2 + } + bMatch = 0 + if _fts5ExprAdvanceto(tls, pIter, bDesc, bp+8, bp, pNode+4) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + goto _2 + _2: + ; + j = j + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + } + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = **(**Ti64)(__ccgo_up(bp + 8)) + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = libc.BoolInt32(0 == _fts5ExprNearTest(tls, bp, pExpr, pNode) && **(**int32)(__ccgo_up(bp)) == SQLITE_OK) + return **(**int32)(__ccgo_up(bp)) +} + +func _fts5ExprNodeTest_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr) (r int32) { + var pIter, pPhrase uintptr + _, _ = pIter, pPhrase + /* As this "NEAR" object is actually a single phrase that consists + ** of a single term only, grab pointers into the poslist managed by the + ** fts5_index.c iterator object. This is much faster than synthesizing + ** a new poslist the way we have to for more complicated phrase or NEAR + ** expressions. */ + pPhrase = *(*uintptr)(unsafe.Pointer((*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24)) + pIter = (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32))).FpIter + (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = (*TFts5IndexIter)(unsafe.Pointer(pIter)).FnData + if (*TFts5Config)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail == FTS5_DETAIL_FULL { + (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fp = (*TFts5IndexIter)(unsafe.Pointer(pIter)).FpData + } + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = libc.BoolInt32((*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn == 0) + return SQLITE_OK +} + +func _fts5ExprNodeZeroPoslist(tls *libc.TLS, pNode uintptr) { + var i, i1 int32 + var pNear, pPhrase uintptr + _, _, _, _ = i, i1, pNear, pPhrase + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType == int32(FTS5_STRING) || (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType == int32(FTS5_TERM) { + pNear = (*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + pPhrase = *(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(i)*8)) + (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = 0 + goto _1 + _1: + ; + i = i + 1 + } + } else { + i1 = 0 + for { + if !(i1 < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild) { + break + } + _fts5ExprNodeZeroPoslist(tls, *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i1)*8))) + goto _2 + _2: + ; + i1 = i1 + 1 + } + } +} + +// C documentation +// +// /* +// ** Free the phrase object passed as the only argument. +// */ +func _fts5ExprPhraseFree(tls *libc.TLS, pPhrase uintptr) { + var i int32 + var pNext, pSyn, pTerm uintptr + _, _, _, _ = i, pNext, pSyn, pTerm + if pPhrase != 0 { + i = 0 + for { + if !(i < (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) { + break + } + pTerm = pPhrase + 32 + uintptr(i)*40 + Xsqlite3_free(tls, (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpTerm) + _sqlite3Fts5IterClose(tls, (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter) + pSyn = (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym + for { + if !(pSyn != 0) { + break + } + pNext = (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpSynonym + _sqlite3Fts5IterClose(tls, (*TFts5ExprTerm)(unsafe.Pointer(pSyn)).FpIter) + _sqlite3Fts5BufferFree(tls, pSyn+1*40) + Xsqlite3_free(tls, pSyn) + goto _2 + _2: + ; + pSyn = pNext + } + goto _1 + _1: + ; + i = i + 1 + } + if (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.FnSpace > 0 { + _sqlite3Fts5BufferFree(tls, pPhrase+8) + } + Xsqlite3_free(tls, pPhrase) + } +} + +func _fts5ExprSetEof(tls *libc.TLS, pNode uintptr) { + var i int32 + _ = i + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof = int32(1) + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 + i = 0 + for { + if !(i < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild) { + break + } + _fts5ExprSetEof(tls, *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Find a tokenizer. This is the implementation of the +// ** fts5_api.xFindTokenizer_v2() method. +// */ +func _fts5FindTokenizer_v2(tls *libc.TLS, pApi uintptr, zName uintptr, ppUserData uintptr, ppTokenizer uintptr) (r int32) { + var pMod uintptr + var rc int32 + _, _ = pMod, rc + rc = SQLITE_OK + pMod = _fts5LocateTokenizer(tls, pApi, zName) + if pMod != 0 { + if (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FbV2Native != 0 { + **(**uintptr)(__ccgo_up(ppUserData)) = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData + } else { + **(**uintptr)(__ccgo_up(ppUserData)) = pMod + } + **(**uintptr)(__ccgo_up(ppTokenizer)) = pMod + 48 + } else { + **(**uintptr)(__ccgo_up(ppTokenizer)) = uintptr(0) + **(**uintptr)(__ccgo_up(ppUserData)) = uintptr(0) + rc = int32(SQLITE_ERROR) + } + return rc +} + +// C documentation +// +// /* +// ** Tokenizer callback used by implementation of highlight() function. +// */ +func _fts5HighlightCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iStartOff int32, iEndOff int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iPos, v1 int32 + var p, v2 uintptr + var _ /* rc at bp+0 */ int32 + _, _, _, _ = iPos, p, v1, v2 + p = pContext + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + _ = pToken + _ = nToken + if tflags&int32(FTS5_TOKEN_COLOCATED) != 0 { + return SQLITE_OK + } + v2 = p + 80 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + iPos = v1 + if (*THighlightContext)(unsafe.Pointer(p)).FiRangeEnd >= 0 { + if iPos < (*THighlightContext)(unsafe.Pointer(p)).FiRangeStart || iPos > (*THighlightContext)(unsafe.Pointer(p)).FiRangeEnd { + return SQLITE_OK + } + if (*THighlightContext)(unsafe.Pointer(p)).FiRangeStart != 0 && iPos == (*THighlightContext)(unsafe.Pointer(p)).FiRangeStart { + (*THighlightContext)(unsafe.Pointer(p)).FiOff = iStartOff + } + } + /* If the parenthesis is open, and this token is not part of the current + ** phrase, and the starting byte offset of this token is past the point + ** that has currently been copied into the output buffer, close the + ** parenthesis. */ + if (*THighlightContext)(unsafe.Pointer(p)).FbOpen != 0 && (iPos <= (*THighlightContext)(unsafe.Pointer(p)).Fiter.FiStart || (*THighlightContext)(unsafe.Pointer(p)).Fiter.FiStart < 0) && iStartOff > (*THighlightContext)(unsafe.Pointer(p)).FiOff { + _fts5HighlightAppend(tls, bp, p, (*THighlightContext)(unsafe.Pointer(p)).FzClose, -int32(1)) + (*THighlightContext)(unsafe.Pointer(p)).FbOpen = 0 + } + /* If this is the start of a new phrase, and the highlight is not open: + ** + ** * copy text from the input up to the start of the phrase, and + ** * open the highlight. + */ + if iPos == (*THighlightContext)(unsafe.Pointer(p)).Fiter.FiStart && (*THighlightContext)(unsafe.Pointer(p)).FbOpen == 0 { + _fts5HighlightAppend(tls, bp, p, (*THighlightContext)(unsafe.Pointer(p)).FzIn+uintptr((*THighlightContext)(unsafe.Pointer(p)).FiOff), iStartOff-(*THighlightContext)(unsafe.Pointer(p)).FiOff) + _fts5HighlightAppend(tls, bp, p, (*THighlightContext)(unsafe.Pointer(p)).FzOpen, -int32(1)) + (*THighlightContext)(unsafe.Pointer(p)).FiOff = iStartOff + (*THighlightContext)(unsafe.Pointer(p)).FbOpen = int32(1) + } + if iPos == (*THighlightContext)(unsafe.Pointer(p)).Fiter.FiEnd { + if (*THighlightContext)(unsafe.Pointer(p)).FbOpen == 0 { + _fts5HighlightAppend(tls, bp, p, (*THighlightContext)(unsafe.Pointer(p)).FzOpen, -int32(1)) + (*THighlightContext)(unsafe.Pointer(p)).FbOpen = int32(1) + } + _fts5HighlightAppend(tls, bp, p, (*THighlightContext)(unsafe.Pointer(p)).FzIn+uintptr((*THighlightContext)(unsafe.Pointer(p)).FiOff), iEndOff-(*THighlightContext)(unsafe.Pointer(p)).FiOff) + (*THighlightContext)(unsafe.Pointer(p)).FiOff = iEndOff + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _fts5CInstIterNext(tls, p+40) + } + } + if iPos == (*THighlightContext)(unsafe.Pointer(p)).FiRangeEnd { + if (*THighlightContext)(unsafe.Pointer(p)).FbOpen != 0 { + if (*THighlightContext)(unsafe.Pointer(p)).Fiter.FiStart >= 0 && iPos >= (*THighlightContext)(unsafe.Pointer(p)).Fiter.FiStart { + _fts5HighlightAppend(tls, bp, p, (*THighlightContext)(unsafe.Pointer(p)).FzIn+uintptr((*THighlightContext)(unsafe.Pointer(p)).FiOff), iEndOff-(*THighlightContext)(unsafe.Pointer(p)).FiOff) + (*THighlightContext)(unsafe.Pointer(p)).FiOff = iEndOff + } + _fts5HighlightAppend(tls, bp, p, (*THighlightContext)(unsafe.Pointer(p)).FzClose, -int32(1)) + (*THighlightContext)(unsafe.Pointer(p)).FbOpen = 0 + } + _fts5HighlightAppend(tls, bp, p, (*THighlightContext)(unsafe.Pointer(p)).FzIn+uintptr((*THighlightContext)(unsafe.Pointer(p)).FiOff), iEndOff-(*THighlightContext)(unsafe.Pointer(p)).FiOff) + (*THighlightContext)(unsafe.Pointer(p)).FiOff = iEndOff + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Allocate and return a buffer at least nByte bytes in size. +// ** +// ** If an OOM error is encountered, return NULL and set the error code in +// ** the Fts5Index handle passed as the first argument. +// */ +func _fts5IdxMalloc(tls *libc.TLS, p uintptr, nByte Tsqlite3_int64) (r uintptr) { + return _sqlite3Fts5MallocZero(tls, p+60, nByte) +} + +/* +** Compare the contents of the pLeft buffer with the pRight/nRight blob. +** +** Return -ve if pLeft is smaller than pRight, 0 if they are equal or +** +ve if pRight is smaller than pLeft. In other words: +** +** res = *pLeft - *pRight + */ + +func _fts5IndexCrisismerge(tls *libc.TLS, p uintptr, ppStruct uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iLvl, nCrisis int32 + var _ /* pStruct at bp+0 */ uintptr + _, _ = iLvl, nCrisis + nCrisis = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FnCrisisMerge + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(ppStruct)) + if **(**uintptr)(__ccgo_up(bp)) != 0 && (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnLevel > 0 { + iLvl = 0 + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*(*TFts5StructureLevel)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 32 + uintptr(iLvl)*16))).FnSeg >= nCrisis { + _fts5IndexMergeLevel(tls, p, bp, iLvl, uintptr(0)) + _fts5StructurePromote(tls, p, iLvl+int32(1), **(**uintptr)(__ccgo_up(bp))) + iLvl = iLvl + 1 + } + **(**uintptr)(__ccgo_up(ppStruct)) = **(**uintptr)(__ccgo_up(bp)) + } +} + +// C documentation +// +// /* +// ** Array ap[] contains n elements. Release each of these elements using +// ** fts5DataRelease(). Then free the array itself using sqlite3_free(). +// */ +func _fts5IndexFreeArray(tls *libc.TLS, ap uintptr, n int32) { + var ii int32 + _ = ii + if ap != 0 { + ii = 0 + for { + if !(ii < n) { + break + } + _fts5DataRelease(tls, **(**uintptr)(__ccgo_up(ap + uintptr(ii)*8))) + goto _1 + _1: + ; + ii = ii + 1 + } + Xsqlite3_free(tls, ap) + } +} + +// C documentation +// +// /* +// ** Do up to nPg pages of automerge work on the index. +// ** +// ** Return true if any changes were actually made, or false otherwise. +// */ +func _fts5IndexMerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nPg int32, nMin int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bRet, iBestLvl, iLvl, nBest int32 + var pLvl uintptr + var _ /* nRem at bp+0 */ int32 + var _ /* pStruct at bp+8 */ uintptr + _, _, _, _, _ = bRet, iBestLvl, iLvl, nBest, pLvl + **(**int32)(__ccgo_up(bp)) = nPg + bRet = 0 + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(ppStruct)) + for **(**int32)(__ccgo_up(bp)) > 0 && (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { /* To iterate through levels */ + iBestLvl = 0 /* Level offering the most input segments */ + nBest = 0 /* Number of input segments on best level */ + /* Set iBestLvl to the level to read input segments from. Or to -1 if + ** there is no level suitable to merge segments from. */ + iLvl = 0 + for { + if !(iLvl < (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FnLevel) { + break + } + pLvl = **(**uintptr)(__ccgo_up(bp + 8)) + 32 + uintptr(iLvl)*16 + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 { + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge > nBest { + iBestLvl = iLvl + nBest = nMin + } + break + } + if (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg > nBest { + nBest = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg + iBestLvl = iLvl + } + goto _1 + _1: + ; + iLvl = iLvl + 1 + } + if nBest < nMin { + iBestLvl = _fts5IndexFindDeleteMerge(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + } + if iBestLvl < 0 { + break + } + bRet = int32(1) + _fts5IndexMergeLevel(tls, p, bp+8, iBestLvl, bp) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*(*TFts5StructureLevel)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)) + 32 + uintptr(iBestLvl)*16))).FnMerge == 0 { + _fts5StructurePromote(tls, p, iBestLvl+int32(1), **(**uintptr)(__ccgo_up(bp + 8))) + } + if nMin == int32(1) { + nMin = int32(2) + } + } + **(**uintptr)(__ccgo_up(ppStruct)) = **(**uintptr)(__ccgo_up(bp + 8)) + return bRet +} + +// C documentation +// +// /* +// ** This function is the implementation of both the xConnect and xCreate +// ** methods of the FTS3 virtual table. +// ** +// ** The argv[] array contains the following: +// ** +// ** argv[0] -> module name ("fts5") +// ** argv[1] -> database name +// ** argv[2] -> table name +// ** argv[...] -> "column name" and other module argument fields. +// */ +func _fts5InitVtab(tls *libc.TLS, bCreate int32, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVTab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var azConfig, pGlobal, pTab uintptr + var _ /* pConfig at bp+8 */ uintptr + var _ /* rc at bp+0 */ int32 + _, _, _ = azConfig, pGlobal, pTab + pGlobal = pAux + azConfig = argv + **(**int32)(__ccgo_up(bp)) = SQLITE_OK /* Return code */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* Results of parsing argc/argv */ + pTab = uintptr(0) /* New virtual table object */ + /* Allocate the new vtab object and parse the configuration */ + pTab = _sqlite3Fts5MallocZero(tls, bp, int64(72)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ConfigParse(tls, pGlobal, db, argc, azConfig, bp+8, pzErr) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5Config)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpzErrmsg = pzErr + (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig = **(**uintptr)(__ccgo_up(bp + 8)) + (*TFts5FullTable)(unsafe.Pointer(pTab)).FpGlobal = pGlobal + if bCreate != 0 || _sqlite3Fts5TokenizerPreload(tls, **(**uintptr)(__ccgo_up(bp + 8))+128) != 0 { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5LoadTokenizer(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + } + /* Open the index sub-system */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5IndexOpen(tls, **(**uintptr)(__ccgo_up(bp + 8)), bCreate, pTab+32, pzErr) + } + /* Open the storage sub-system */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageOpen(tls, **(**uintptr)(__ccgo_up(bp + 8)), (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, bCreate, pTab+40, pzErr) + } + /* Call sqlite3_declare_vtab() */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ConfigDeclareVtab(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + /* Load the initial configuration */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sqlite3Fts5ConfigLoad(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig, (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FiCookie-int32(1)) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FeContent == FTS5_CONTENT_NORMAL { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_CONSTRAINT_SUPPORT), libc.VaList(bp+24, libc.Int32FromInt32(1))) + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + } + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + (*TFts5Config)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).FpzErrmsg = uintptr(0) + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + _fts5FreeVtab(tls, pTab) + pTab = uintptr(0) + } else { + if bCreate != 0 { + } + } + **(**uintptr)(__ccgo_up(ppVTab)) = pTab + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** xSetOutputs callback used by detail=col when there is a column filter +// ** and there are 100 or more columns. Also called as a fallback from +// ** fts5IterSetOutputs_Col100 if the column-list spans more than one page. +// */ +func _fts5IterSetOutputs_Col(tls *libc.TLS, pIter uintptr, pSeg uintptr) { + _sqlite3Fts5BufferZero(tls, pIter+40) + _fts5SegiterPoslist(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex, pSeg, (*TFts5Iter)(unsafe.Pointer(pIter)).FpColset, pIter+40) + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiRowid + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn +} + +// C documentation +// +// /* +// ** xSetOutputs callback used by detail=full when there is a column filter. +// */ +func _fts5IterSetOutputs_Full(tls *libc.TLS, pIter uintptr, pSeg uintptr) { + var a, pColset, pRc uintptr + _, _, _ = a, pColset, pRc + pColset = (*TFts5Iter)(unsafe.Pointer(pIter)).FpColset + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiRowid + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset+int64((*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos) <= int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf) { + /* All data is stored on the current page. Populate the output + ** variables to point into the body of the page object. */ + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset) + pRc = (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex + 60 + _sqlite3Fts5BufferZero(tls, pIter+40) + _fts5IndexExtractColset(tls, pRc, pColset, a, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos, pIter) + } else { + /* The data is distributed over two or more pages. Copy it into the + ** Fts5Iter.poslist buffer and then set the output pointer to point + ** to this buffer. */ + _sqlite3Fts5BufferZero(tls, pIter+40) + _fts5SegiterPoslist(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex, pSeg, pColset, pIter+40) + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn + } +} + +// C documentation +// +// /* +// ** xSetOutputs callback used by detail=full and detail=col tables when no +// ** column filters are specified. +// */ +func _fts5IterSetOutputs_Nocolset(tls *libc.TLS, pIter uintptr, pSeg uintptr) { + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiRowid + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos + if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset+int64((*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos) <= int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf) { + /* All data is stored on the current page. Populate the output + ** variables to point into the body of the page object. */ + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset) + } else { + /* The data is distributed over two or more pages. Copy it into the + ** Fts5Iter.poslist buffer and then set the output pointer to point + ** to this buffer. */ + _sqlite3Fts5BufferZero(tls, pIter+40) + _fts5SegiterPoslist(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex, pSeg, uintptr(0), pIter+40) + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*TFts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp + } +} + +func _fts5LookaheadReaderNext(tls *libc.TLS, p uintptr) (r int32) { + (*TFts5LookaheadReader)(unsafe.Pointer(p)).FiPos = (*TFts5LookaheadReader)(unsafe.Pointer(p)).FiLookahead + if _sqlite3Fts5PoslistNext64(tls, (*TFts5LookaheadReader)(unsafe.Pointer(p)).Fa, (*TFts5LookaheadReader)(unsafe.Pointer(p)).Fn, p+12, p+24) != 0 { + (*TFts5LookaheadReader)(unsafe.Pointer(p)).FiLookahead = libc.Int64FromInt32(1) << libc.Int32FromInt32(62) + } + return libc.BoolInt32((*TFts5LookaheadReader)(unsafe.Pointer(p)).FiPos == libc.Int64FromInt32(1)<= iMinset && (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { + break + } + v2 = _fts5MultiIterDoCompare(tls, pIter, i) + iEq = v2 + if v2 != 0 { + pSeg = pIter + 104 + uintptr(iEq)*128 + (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5SegIter)(unsafe.Pointer(pSeg)).FxNext})))(tls, p, pSeg, uintptr(0)) + i = (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg + iEq + } + goto _1 + _1: + ; + i = i / int32(2) + } +} + +// C documentation +// +// /* +// ** Free the iterator object passed as the second argument. +// */ +func _fts5MultiIterFree(tls *libc.TLS, pIter uintptr) { + var i int32 + _ = i + if pIter != 0 { + i = 0 + for { + if !(i < (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg) { + break + } + _fts5SegIterClear(tls, pIter+104+uintptr(i)*128) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3Fts5BufferFree(tls, pIter+40) + Xsqlite3_free(tls, pIter) + } +} + +// C documentation +// +// /* +// ** Return true if the iterator passed as the second argument currently +// ** points to a delete marker. A delete marker is an entry with a 0 byte +// ** position-list. +// */ +func _fts5MultiIterIsEmpty(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) { + var pSeg uintptr + _ = pSeg + pSeg = pIter + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst)*128 + return libc.BoolInt32((*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 && (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos == 0) +} + +// C documentation +// +// /* +// ** Allocate a new Fts5Iter object. +// ** +// ** The new object will be used to iterate through data in structure pStruct. +// ** If iLevel is -ve, then all data in all segments is merged. Or, if iLevel +// ** is zero or greater, data from the first nSegment segments on level iLevel +// ** is merged. +// ** +// ** The iterator initially points to the first term/rowid entry in the +// ** iterated data. +// */ +func _fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pColset uintptr, pTerm uintptr, nTerm int32, iLevel int32, nSegment int32, ppOut uintptr) { + var iIter, iSeg, nSeg, v1 int32 + var pEnd, pIter, pIter1, pLvl, pNew, pSeg, v2 uintptr + _, _, _, _, _, _, _, _, _, _, _ = iIter, iSeg, nSeg, pEnd, pIter, pIter1, pLvl, pNew, pSeg, v1, v2 + nSeg = 0 /* Number of segment-iters in use */ + iIter = 0 + /* Allocate space for the new multi-seg-iterator. */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if iLevel < 0 { + nSeg = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnSegment + nSeg = nSeg + libc.BoolInt32((*TFts5Index)(unsafe.Pointer(p)).FpHash != 0 && 0 == flags&int32(FTS5INDEX_QUERY_SKIPHASH)) + } else { + if (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLevel)*16))).FnSeg < nSegment { + v1 = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLevel)*16))).FnSeg + } else { + v1 = nSegment + } + nSeg = v1 + } + } + v2 = _fts5MultiIterAlloc(tls, p, nSeg) + pNew = v2 + **(**uintptr)(__ccgo_up(ppOut)) = v2 + if pNew == uintptr(0) { + goto fts5MultiIterNew_post_check + } + (*TFts5Iter)(unsafe.Pointer(pNew)).FbRev = libc.BoolInt32(0 != flags&int32(FTS5INDEX_QUERY_DESC)) + (*TFts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty = libc.BoolUint8(libc.Int32FromInt32(0) != flags&libc.Int32FromInt32(FTS5INDEX_QUERY_SKIPEMPTY)) + (*TFts5Iter)(unsafe.Pointer(pNew)).FpColset = pColset + if flags&int32(FTS5INDEX_QUERY_NOOUTPUT) == 0 { + _fts5IterSetOutputCb(tls, p+60, pNew) + } + /* Initialize each of the component segment iterators. */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if iLevel < 0 { + pEnd = pStruct + 32 + uintptr((*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel)*16 + if (*TFts5Index)(unsafe.Pointer(p)).FpHash != 0 && 0 == flags&int32(FTS5INDEX_QUERY_SKIPHASH) { + v1 = iIter + iIter = iIter + 1 + /* Add a segment iterator for the current contents of the hash table. */ + pIter = pNew + 104 + uintptr(v1)*128 + _fts5SegIterHashInit(tls, p, pTerm, nTerm, flags, pIter) + } + pLvl = pStruct + 32 + for { + if !(pLvl < pEnd) { + break + } + iSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - int32(1) + for { + if !(iSeg >= 0) { + break + } + pSeg = (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*56 + v1 = iIter + iIter = iIter + 1 + pIter1 = pNew + 104 + uintptr(v1)*128 + if pTerm == uintptr(0) { + _fts5SegIterInit(tls, p, pSeg, pIter1) + } else { + _fts5SegIterSeekInit(tls, p, pTerm, nTerm, flags, pSeg, pIter1) + } + goto _5 + _5: + ; + iSeg = iSeg - 1 + } + goto _4 + _4: + ; + pLvl += 16 + } + } else { + pLvl = pStruct + 32 + uintptr(iLevel)*16 + iSeg = nSeg - int32(1) + for { + if !(iSeg >= 0) { + break + } + v1 = iIter + iIter = iIter + 1 + _fts5SegIterInit(tls, p, (*TFts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(iSeg)*56, pNew+104+uintptr(v1)*128) + goto _7 + _7: + ; + iSeg = iSeg - 1 + } + } + } + /* If the above was successful, each component iterator now points + ** to the first entry in its segment. In this case initialize the + ** aFirst[] array. Or, if an error has occurred, free the iterator + ** object and set the output variable to NULL. */ + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _fts5MultiIterFinishSetup(tls, p, pNew) + } else { + _fts5MultiIterFree(tls, pNew) + **(**uintptr)(__ccgo_up(ppOut)) = uintptr(0) + } + goto fts5MultiIterNew_post_check +fts5MultiIterNew_post_check: + ; + return +} + +// C documentation +// +// /* +// ** Return the rowid of the entry that the iterator currently points +// ** to. If the iterator points to EOF when this function is called the +// ** results are undefined. +// */ +func _fts5MultiIterRowid(tls *libc.TLS, pIter uintptr) (r Ti64) { + return (*(*TFts5SegIter)(unsafe.Pointer(pIter + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst)*128))).FiRowid +} + +// C documentation +// +// /* +// ** Set the pIter->bEof variable based on the state of the sub-iterators. +// */ +func _fts5MultiIterSetEof(tls *libc.TLS, pIter uintptr) { + var pSeg uintptr + _ = pSeg + pSeg = pIter + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst)*128 + (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof = libc.BoolUint8((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf == uintptr(0)) + (*TFts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiRowid +} + +/* +** The argument to this macro must be an Fts5Data structure containing a +** tombstone hash page. This macro returns the key-size of the hash-page. + */ + +// C documentation +// +// /* +// ** Return a pointer to a buffer containing the term associated with the +// ** entry that the iterator currently points to. +// */ +func _fts5MultiIterTerm(tls *libc.TLS, pIter uintptr, pn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIter + 104 + uintptr((**(**TFts5CResult)(__ccgo_up((*TFts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4))).FiFirst)*128 + **(**int32)(__ccgo_up(pn)) = (*TFts5SegIter)(unsafe.Pointer(p)).Fterm.Fn + return (*TFts5SegIter)(unsafe.Pointer(p)).Fterm.Fp +} + +// C documentation +// +// /* +// ** Recursively apply colset pColset to expression node pNode and all of +// ** its decendents. If (*ppFree) is not NULL, it contains a spare copy +// ** of pColset. This function may use the spare copy and set (*ppFree) to +// ** zero, or it may create copies of pColset using fts5CloneColset(). +// */ +func _fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pNode uintptr, pColset uintptr, ppFree uintptr) { + var i int32 + var pNear uintptr + _, _ = i, pNear + if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType == int32(FTS5_STRING) || (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType == int32(FTS5_TERM) { + pNear = (*TFts5ExprNode)(unsafe.Pointer(pNode)).FpNear + if (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0 { + _fts5MergeColset(tls, (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FpColset, pColset) + if (*TFts5Colset)(unsafe.Pointer((*TFts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)).FnCol == 0 { + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType = FTS5_EOF + (*TFts5ExprNode)(unsafe.Pointer(pNode)).FxNext = uintptr(0) + } + } else { + if **(**uintptr)(__ccgo_up(ppFree)) != 0 { + (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FpColset = pColset + **(**uintptr)(__ccgo_up(ppFree)) = uintptr(0) + } else { + (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FpColset = _fts5CloneColset(tls, pParse+16, pColset) + } + } + } else { + i = 0 + for { + if !(i < (*TFts5ExprNode)(unsafe.Pointer(pNode)).FnChild) { + break + } + _fts5ParseSetColset(tls, pParse, *(*uintptr)(unsafe.Pointer(pNode + 48 + uintptr(i)*8)), pColset, ppFree) + goto _1 + _1: + ; + i = i + 1 + } + } + } +} + +// C documentation +// +// /* +// ** Tokenize using the porter tokenizer. +// */ +func _fts5PorterTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, flags int32, pText uintptr, nText int32, pLoc uintptr, nLoc int32, __ccgo_fp_xToken uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var p uintptr + var _ /* sCtx at bp+0 */ TPorterContext + _ = p + p = pTokenizer + (**(**TPorterContext)(__ccgo_up(bp))).FxToken = __ccgo_fp_xToken + (**(**TPorterContext)(__ccgo_up(bp))).FpCtx = pCtx + (**(**TPorterContext)(__ccgo_up(bp))).FaBuf = p + 40 + return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPorterTokenizer)(unsafe.Pointer(p)).Ftokenizer_v2.FxTokenize})))(tls, (*TPorterTokenizer)(unsafe.Pointer(p)).FpTokenizer, bp, flags, pText, nText, pLoc, nLoc, __ccgo_fp(_fts5PorterCb)) +} + +func _fts5PrefixMergerInsertByPosition(tls *libc.TLS, ppHead uintptr, p uintptr) { + var pp uintptr + _ = pp + if (*TPrefixMerger)(unsafe.Pointer(p)).FiPos >= 0 { + pp = ppHead + for **(**uintptr)(__ccgo_up(pp)) != 0 && (*TPrefixMerger)(unsafe.Pointer(p)).FiPos > (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FiPos { + pp = **(**uintptr)(__ccgo_up(pp)) + 56 + } + (*TPrefixMerger)(unsafe.Pointer(p)).FpNext = **(**uintptr)(__ccgo_up(pp)) + **(**uintptr)(__ccgo_up(pp)) = p + } +} + +func _fts5PrefixMergerInsertByRowid(tls *libc.TLS, ppHead uintptr, p uintptr) { + var pp uintptr + _ = pp + if (*TPrefixMerger)(unsafe.Pointer(p)).Fiter.FaPoslist != 0 { + pp = ppHead + for **(**uintptr)(__ccgo_up(pp)) != 0 && (*TPrefixMerger)(unsafe.Pointer(p)).Fiter.FiRowid > (*TPrefixMerger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).Fiter.FiRowid { + pp = **(**uintptr)(__ccgo_up(pp)) + 56 + } + (*TPrefixMerger)(unsafe.Pointer(p)).FpNext = **(**uintptr)(__ccgo_up(pp)) + **(**uintptr)(__ccgo_up(pp)) = p + } +} + +// C documentation +// +// /* +// ** Load the next leaf page into the segment iterator. +// */ +func _fts5SegIterNextPage(tls *libc.TLS, p uintptr, pIter uintptr) { + var pLeaf, pSeg uintptr + _, _ = pLeaf, pSeg + pSeg = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg + _fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno + 1 + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf != 0 { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf = uintptr(0) + } else { + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno <= (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = _fts5LeafRead(tls, p, int64((*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))<= (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn { + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*TFts5Data)(unsafe.Pointer(pLeaf)).Fnn + int32(1) + } else { + **(**int32)(__ccgo_up(pIter + 64)) += _sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr((*TFts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff), pIter+68) + } + } +} + +// C documentation +// +// /* +// ** Advance iterator pIter to the next entry. +// ** +// ** This version of fts5SegIterNext() is only used by reverse iterators. +// */ +func _fts5SegIterNext_Reverse(tls *libc.TLS, p uintptr, pIter uintptr, pbUnused uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, v1 uintptr + var iOff int32 + var _ /* iDelta at bp+0 */ Tu64 + _, _, _ = a, iOff, v1 + _ = pbUnused + if (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset > 0 { + a = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset - 1 + (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(**(**int32)(__ccgo_up((*TFts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset + uintptr((*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset)*4))) + _fts5SegIterLoadNPos(tls, p, pIter) + iOff = int32((*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset) + if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail != int32(FTS5_DETAIL_NONE) { + iOff = iOff + (*TFts5SegIter)(unsafe.Pointer(pIter)).FnPos + } + _sqlite3Fts5GetVarint(tls, a+uintptr(iOff), bp) + v1 = pIter + 112 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) - **(**Tu64)(__ccgo_up(bp))) + } else { + _fts5SegIterReverseNewPage(tls, p, pIter) + } +} + +// C documentation +// +// /* +// ** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this +// ** extension is currently being used by a version of SQLite too old to +// ** support index-info flags. In that case this function is a no-op. +// */ +func _fts5SetUniqueFlag(tls *libc.TLS, pIdxInfo uintptr) { + **(**int32)(__ccgo_up(pIdxInfo + 80)) |= int32(SQLITE_INDEX_SCAN_UNIQUE) +} + +// C documentation +// +// /* +// ** Return true if zName is the extension on one of the shadow tables used +// ** by this module. +// */ +func _fts5ShadowName(tls *libc.TLS, zName uintptr) (r int32) { + var i uint32 + _ = i + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(40)/libc.Uint64FromInt64(8)) { + break + } + if Xsqlite3_stricmp(tls, zName, _azName2[i]) == 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +func _fts5SorterNext(tls *libc.TLS, pCsr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var a, aBlob, pSorter, v1 uintptr + var i, iOff, nBlob, rc int32 + var _ /* iVal at bp+0 */ int32 + _, _, _, _, _, _, _, _ = a, aBlob, i, iOff, nBlob, pSorter, rc, v1 + pSorter = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter + rc = Xsqlite3_step(tls, (*TFts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(pCsr + 80)) |= libc.Int32FromInt32(FTS5CSR_EOF) | libc.Int32FromInt32(FTS5CSR_REQUIRE_CONTENT) + } else { + if rc == int32(SQLITE_ROW) { + iOff = 0 + rc = SQLITE_OK + (*TFts5Sorter)(unsafe.Pointer(pSorter)).FiRowid = Xsqlite3_column_int64(tls, (*TFts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, 0) + nBlob = Xsqlite3_column_bytes(tls, (*TFts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, int32(1)) + v1 = Xsqlite3_column_blob(tls, (*TFts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, int32(1)) + a = v1 + aBlob = v1 + /* nBlob==0 in detail=none mode. */ + if nBlob > 0 { + i = 0 + for { + if !(i < (*TFts5Sorter)(unsafe.Pointer(pSorter)).FnIdx-int32(1)) { + break + } + a = a + uintptr(_sqlite3Fts5GetVarint32(tls, a, bp)) + iOff = iOff + **(**int32)(__ccgo_up(bp)) + *(*int32)(unsafe.Pointer(pSorter + 28 + uintptr(i)*4)) = iOff + goto _2 + _2: + ; + i = i + 1 + } + *(*int32)(unsafe.Pointer(pSorter + 28 + uintptr(i)*4)) = int32(t__predefined_ptrdiff_t(aBlob+uintptr(nBlob)) - int64(a)) + (*TFts5Sorter)(unsafe.Pointer(pSorter)).FaPoslist = a + } + _fts5CsrNewrow(tls, pCsr) + } + } + return rc +} + +func _fts5SpecialDelete(tls *libc.TLS, pTab uintptr, apVal uintptr) (r int32) { + var eType1, rc int32 + var iDel Tsqlite3_int64 + _, _, _ = eType1, iDel, rc + rc = SQLITE_OK + eType1 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + if eType1 == int32(SQLITE_INTEGER) { + iDel = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apVal + 1*8))) + rc = _sqlite3Fts5StorageDelete(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, apVal+2*8, 0) + } + return rc +} + +// C documentation +// +// /* +// ** Load the contents of the "averages" record from disk into the +// ** p->nTotalRow and p->aTotalSize[] variables. If successful, and if +// ** argument bCache is true, set the p->bTotalsValid flag to indicate +// ** that the contents of aTotalSize[] and nTotalRow are valid until +// ** further notice. +// ** +// ** Return SQLITE_OK if successful, or an SQLite error code if an error +// ** occurs. +// */ +func _fts5StorageLoadTotals(tls *libc.TLS, p uintptr, bCache int32) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if (*TFts5Storage)(unsafe.Pointer(p)).FbTotalsValid == 0 { + rc = _sqlite3Fts5IndexGetAverages(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, p+24, (*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize) + (*TFts5Storage)(unsafe.Pointer(p)).FbTotalsValid = bCache + } + return rc +} + +// C documentation +// +// /* +// ** A new segment has just been written to level iLvl of index structure +// ** pStruct. This function determines if any segments should be promoted +// ** as a result. Segments are promoted in two scenarios: +// ** +// ** a) If the segment just written is smaller than one or more segments +// ** within the previous populated level, it is promoted to the previous +// ** populated level. +// ** +// ** b) If the segment just written is larger than the newest segment on +// ** the next populated level, then that segment, and any other adjacent +// ** segments that are also smaller than the one just written, are +// ** promoted. +// ** +// ** If one or more segments are promoted, the structure object is updated +// ** to reflect this. +// */ +func _fts5StructurePromote(tls *libc.TLS, p uintptr, iLvl int32, pStruct uintptr) { + var i, iPromote, iTst, nSeg, sz, szMax, szPromote, szSeg int32 + var pSeg, pTst uintptr + _, _, _, _, _, _, _, _, _, _ = i, iPromote, iTst, nSeg, pSeg, pTst, sz, szMax, szPromote, szSeg + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + iPromote = -int32(1) + szPromote = 0 /* Size of segment just written */ + nSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg + if nSeg == 0 { + return + } + pSeg = (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FaSeg + uintptr((*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iLvl)*16))).FnSeg-int32(1))*56 + szSeg = int32(1) + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast - (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst + /* Check for condition (a) */ + iTst = iLvl - int32(1) + for { + if !(iTst >= 0 && (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(iTst)*16))).FnSeg == 0) { + break + } + goto _1 + _1: + ; + iTst = iTst - 1 + } + if iTst >= 0 { + szMax = 0 + pTst = pStruct + 32 + uintptr(iTst)*16 + i = 0 + for { + if !(i < (*TFts5StructureLevel)(unsafe.Pointer(pTst)).FnSeg) { + break + } + sz = (**(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pTst)).FaSeg + uintptr(i)*56))).FpgnoLast - (**(**TFts5StructureSegment)(__ccgo_up((*TFts5StructureLevel)(unsafe.Pointer(pTst)).FaSeg + uintptr(i)*56))).FpgnoFirst + int32(1) + if sz > szMax { + szMax = sz + } + goto _2 + _2: + ; + i = i + 1 + } + if szMax >= szSeg { + /* Condition (a) is true. Promote the newest segment on level + ** iLvl to level iTst. */ + iPromote = iTst + szPromote = szMax + } + } + /* If condition (a) is not met, assume (b) is true. StructurePromoteTo() + ** is a no-op if it is not. */ + if iPromote < 0 { + iPromote = iLvl + szPromote = szSeg + } + _fts5StructurePromoteTo(tls, p, iPromote, szPromote, pStruct) + } +} + +// C documentation +// +// /* +// ** Release a reference to an Fts5Structure object returned by an earlier +// ** call to fts5StructureRead() or fts5StructureDecode(). +// */ +func _fts5StructureRelease(tls *libc.TLS, pStruct uintptr) { + var i, v1 int32 + var v2 uintptr + var v3 bool + _, _, _, _ = i, v1, v2, v3 + if v3 = pStruct != 0; v3 { + v2 = pStruct + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + } + if v3 && 0 >= v1 { + i = 0 + for { + if !(i < (*TFts5Structure)(unsafe.Pointer(pStruct)).FnLevel) { + break + } + Xsqlite3_free(tls, (*(*TFts5StructureLevel)(unsafe.Pointer(pStruct + 32 + uintptr(i)*16))).FaSeg) + goto _4 + _4: + ; + i = i + 1 + } + Xsqlite3_free(tls, pStruct) + } +} + +// C documentation +// +// /* +// ** Implementation of xSync() method. +// */ +func _fts5SyncMethod(tls *libc.TLS, pVtab uintptr) (r int32) { + var pTab uintptr + var rc int32 + _, _ = pTab, rc + pTab = pVtab + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = pTab + 16 + rc = _sqlite3Fts5FlushToDisk(tls, pTab) + (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = uintptr(0) + return rc +} + +// C documentation +// +// /* +// ** Argument pStmt is an SQL statement of the type used by Fts5Cursor. This +// ** function extracts the text value of column iCol of the current row. +// ** Additionally, if there is an associated locale, it invokes +// ** sqlite3Fts5SetLocale() to configure the tokenizer. In all cases the caller +// ** should invoke sqlite3Fts5ClearLocale() to clear the locale at some point +// ** after this function returns. +// ** +// ** If successful, (*ppText) is set to point to a buffer containing the text +// ** value as utf-8 and SQLITE_OK returned. (*pnText) is set to the size of that +// ** buffer in bytes. It is not guaranteed to be nul-terminated. If an error +// ** occurs, an SQLite error code is returned. The final values of the two +// ** output parameters are undefined in this case. +// */ +func _fts5TextFromStmt(tls *libc.TLS, pConfig uintptr, pStmt uintptr, iCol int32, ppText uintptr, pnText uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pVal uintptr + var rc int32 + var _ /* nLoc at bp+8 */ int32 + var _ /* pLoc at bp+0 */ uintptr + _, _ = pVal, rc + pVal = Xsqlite3_column_value(tls, pStmt, iCol+int32(1)) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = 0 + rc = SQLITE_OK + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_EXTERNAL) && _sqlite3Fts5IsLocaleValue(tls, pConfig, pVal) != 0 { + rc = _sqlite3Fts5DecodeLocaleValue(tls, pVal, ppText, pnText, bp, bp+8) + } else { + **(**uintptr)(__ccgo_up(ppText)) = Xsqlite3_value_text(tls, pVal) + **(**int32)(__ccgo_up(pnText)) = Xsqlite3_value_bytes(tls, pVal) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale != 0 && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { + **(**uintptr)(__ccgo_up(bp)) = Xsqlite3_column_text(tls, pStmt, iCol+int32(1)+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) + **(**int32)(__ccgo_up(bp + 8)) = Xsqlite3_column_bytes(tls, pStmt, iCol+int32(1)+(*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) + } + } + _sqlite3Fts5SetLocale(tls, pConfig, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8))) + return rc +} + +// C documentation +// +// /* +// ** Delete an Fts5TokenDataIter structure and its contents. +// */ +func _fts5TokendataIterDelete(tls *libc.TLS, pSet uintptr) { + var ii int32 + _ = ii + if pSet != 0 { + ii = 0 + for { + if !(int64(ii) < (*TFts5TokenDataIter)(unsafe.Pointer(pSet)).FnIter) { + break + } + _fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(pSet + 72 + uintptr(ii)*8))) + goto _1 + _1: + ; + ii = ii + 1 + } + _sqlite3Fts5BufferFree(tls, pSet+24) + Xsqlite3_free(tls, (*TFts5TokenDataIter)(unsafe.Pointer(pSet)).FaPoslistReader) + Xsqlite3_free(tls, (*TFts5TokenDataIter)(unsafe.Pointer(pSet)).FaMap) + Xsqlite3_free(tls, pSet) + } +} + +// C documentation +// +// /* +// ** If the segment-iterator passed as the first argument is at EOF, then +// ** set pIter->term to a copy of buffer pTerm. +// */ +func _fts5TokendataSetTermIfEof(tls *libc.TLS, pIter uintptr, pTerm uintptr) { + if pIter != 0 && (*(*TFts5SegIter)(unsafe.Pointer(pIter + 104))).FpLeaf == uintptr(0) { + _sqlite3Fts5BufferSet(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex+60, pIter+104+96, (*TFts5Buffer)(unsafe.Pointer(pTerm)).Fn, (*TFts5Buffer)(unsafe.Pointer(pTerm)).Fp) + } +} + +// C documentation +// +// /* +// ** Decrement the ref-count of the object passed as the only argument. If it +// ** reaches 0, free it and its contents. +// */ +func _fts5TombstoneArrayDelete(tls *libc.TLS, p uintptr) { + var ii int32 + _ = ii + if p != 0 { + (*TFts5TombstoneArray)(unsafe.Pointer(p)).FnRef = (*TFts5TombstoneArray)(unsafe.Pointer(p)).FnRef - 1 + if (*TFts5TombstoneArray)(unsafe.Pointer(p)).FnRef <= 0 { + ii = 0 + for { + if !(ii < (*TFts5TombstoneArray)(unsafe.Pointer(p)).FnTombstone) { + break + } + _fts5DataRelease(tls, *(*uintptr)(unsafe.Pointer(p + 8 + uintptr(ii)*8))) + goto _1 + _1: + ; + ii = ii + 1 + } + Xsqlite3_free(tls, p) + } + } +} + +// C documentation +// +// /* +// ** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors +// ** open on table pTab. +// */ +func _fts5TripCursors(tls *libc.TLS, pTab uintptr) { + var pCsr uintptr + _ = pCsr + pCsr = (*TFts5Global)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr + for { + if !(pCsr != 0) { + break + } + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan == int32(FTS5_PLAN_MATCH) && (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab { + **(**int32)(__ccgo_up(pCsr + 80)) |= int32(FTS5CSR_REQUIRE_RESEEK) + } + goto _1 + _1: + ; + pCsr = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpNext + } +} + +// C documentation +// +// /* +// ** Close the cursor. For additional information see the documentation +// ** on the xClose method of the virtual table interface. +// */ +func _fts5VocabCloseMethod(tls *libc.TLS, pCursor uintptr) (r int32) { + var pCsr uintptr + _ = pCsr + pCsr = pCursor + _fts5VocabResetCursor(tls, pCsr) + _sqlite3Fts5BufferFree(tls, pCsr+96) + Xsqlite3_finalize(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpStmt) + Xsqlite3_free(tls, pCsr) + return SQLITE_OK +} + +func _fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int32) (r int32) { + var eDetail, eType, ii, ii1 int32 + var iVal Ti64 + var pCsr, z, z1 uintptr + _, _, _, _, _, _, _, _ = eDetail, eType, iVal, ii, ii1, pCsr, z, z1 + pCsr = pCursor + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail + eType = (*TFts5VocabTable)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FeType + iVal = 0 + if iCol == 0 { + Xsqlite3_result_text(tls, pCtx, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fn, uintptr(-libc.Int32FromInt32(1))) + } else { + if eType == FTS5_VOCAB_COL { + if iCol == int32(1) { + if eDetail != int32(FTS5_DETAIL_NONE) { + z = **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FazCol + uintptr((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) + Xsqlite3_result_text(tls, pCtx, z, -int32(1), libc.UintptrFromInt32(0)) + } + } else { + if iCol == int32(2) { + iVal = **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) + } else { + iVal = **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) + } + } + } else { + if eType == int32(FTS5_VOCAB_ROW) { + if iCol == int32(1) { + iVal = **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc)) + } else { + iVal = **(**Ti64)(__ccgo_up((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt)) + } + } else { + switch iCol { + case int32(1): + Xsqlite3_result_int64(tls, pCtx, (*TFts5IndexIter)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FiRowid) + case int32(2): + ii = -int32(1) + if eDetail == FTS5_DETAIL_FULL { + ii = int32((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos >> libc.Int32FromInt32(32) & libc.Int64FromInt32(0x7FFFFFFF)) + } else { + if eDetail == int32(FTS5_DETAIL_COLUMNS) { + ii = int32((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos) + } + } + if ii >= 0 && ii < (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol { + z1 = **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FazCol + uintptr(ii)*8)) + Xsqlite3_result_text(tls, pCtx, z1, -int32(1), libc.UintptrFromInt32(0)) + } + default: + if eDetail == FTS5_DETAIL_FULL { + ii1 = int32((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos & libc.Int64FromInt32(0x7FFFFFFF)) + Xsqlite3_result_int(tls, pCtx, ii1) + } + break + } + } + } + } + if iVal > 0 { + Xsqlite3_result_int64(tls, pCtx, iVal) + } + return SQLITE_OK +} + +func _fts5VocabInstanceNext(tls *libc.TLS, pCsr uintptr) (r int32) { + var eDetail, rc int32 + var pIter, po, pp uintptr + _, _, _, _, _ = eDetail, pIter, po, pp, rc + eDetail = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail + rc = SQLITE_OK + pIter = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter + pp = pCsr + 112 + po = pCsr + 120 + for eDetail == int32(FTS5_DETAIL_NONE) || _sqlite3Fts5PoslistNext64(tls, (*TFts5IndexIter)(unsafe.Pointer(pIter)).FpData, (*TFts5IndexIter)(unsafe.Pointer(pIter)).FnData, po, pp) != 0 { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos = 0 + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstOff = 0 + rc = _sqlite3Fts5IterNextScan(tls, (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter) + if rc == SQLITE_OK { + rc = _fts5VocabInstanceNewTerm(tls, pCsr) + if (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0 || eDetail == int32(FTS5_DETAIL_NONE) { + break + } + } + if rc != 0 { + (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = int32(1) + break + } + } + return rc +} + +// C documentation +// +// /* +// ** Create a wrapper tokenizer. The context argument pCtx points to the +// ** Fts5TokenizerModule object. +// */ +func _fts5VtoVCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pMod, pNew uintptr + var _ /* rc at bp+0 */ int32 + _, _ = pMod, pNew + pMod = pCtx + pNew = uintptr(0) + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + pNew = _sqlite3Fts5MallocZero(tls, bp, int64(72)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + (*TFts5VtoVTokenizer)(unsafe.Pointer(pNew)).Fx1 = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx1 + (*TFts5VtoVTokenizer)(unsafe.Pointer(pNew)).Fx2 = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx2 + (*TFts5VtoVTokenizer)(unsafe.Pointer(pNew)).FbV2Native = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FbV2Native + if (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FbV2Native != 0 { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx2.FxCreate})))(tls, (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData, azArg, nArg, pNew+64) + } else { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5TokenizerModule)(unsafe.Pointer(pMod)).Fx1.FxCreate})))(tls, (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData, azArg, nArg, pNew+64) + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + Xsqlite3_free(tls, pNew) + pNew = uintptr(0) + } + } + **(**uintptr)(__ccgo_up(ppOut)) = pNew + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This function is called when flushing a leaf page that contains no +// ** terms at all to disk. +// */ +func _fts5WriteBtreeNoTerm(tls *libc.TLS, p uintptr, pWriter uintptr) { + var pDlidx uintptr + _ = pDlidx + /* If there were no rowids on the leaf page either and the doclist-index + ** has already been started, append an 0x00 byte to it. */ + if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0 && (**(**TFts5DlidxWriter)(__ccgo_up((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx))).Fbuf.Fn > 0 { + pDlidx = (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + _sqlite3Fts5BufferAppendVarint(tls, p+60, pDlidx+16, 0) + } + /* Increment the "number of sequential leaves without a term" counter. */ + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty = (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty + 1 +} + +// C documentation +// +// /* +// ** This is called once for each leaf page except the first that contains +// ** at least one term. Argument (nTerm/pTerm) is the split-key - a term that +// ** is larger than all terms written to earlier leaves, and equal to or +// ** smaller than the first term on the new leaf. +// ** +// ** If an error occurs, an error code is left in Fts5Index.rc. If an error +// ** has already occurred when this function is called, it is a no-op. +// */ +func _fts5WriteBtreeTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, pTerm uintptr) { + _fts5WriteFlushBtree(tls, p, pWriter) + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + _sqlite3Fts5BufferSet(tls, p+60, pWriter+96, nTerm, pTerm) + (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fpgno + } +} + +// C documentation +// +// /* +// ** Flush any data cached by the writer object to the database. Free any +// ** allocations associated with the writer. +// */ +func _fts5WriteFinish(tls *libc.TLS, p uintptr, pWriter uintptr, pnLeaf uintptr) { + var i int32 + var pLeaf uintptr + _, _ = i, pLeaf + pLeaf = pWriter + 8 + if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*TFts5PageWriter)(unsafe.Pointer(pLeaf)).Fbuf.Fn > int32(4) { + _fts5WriteFlushLeaf(tls, p, pWriter) + } + **(**int32)(__ccgo_up(pnLeaf)) = (*TFts5PageWriter)(unsafe.Pointer(pLeaf)).Fpgno - int32(1) + if (*TFts5PageWriter)(unsafe.Pointer(pLeaf)).Fpgno > int32(1) { + _fts5WriteFlushBtree(tls, p, pWriter) + } + } + _sqlite3Fts5BufferFree(tls, pLeaf+40) + _sqlite3Fts5BufferFree(tls, pLeaf+8) + _sqlite3Fts5BufferFree(tls, pLeaf+24) + _sqlite3Fts5BufferFree(tls, pWriter+96) + i = 0 + for { + if !(i < (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx) { + break + } + _sqlite3Fts5BufferFree(tls, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx+uintptr(i)*32+16) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx) +} + +// C documentation +// +// /* +// ** Pop the parser's stack once. +// ** +// ** If there is a destructor routine associated with the token which +// ** is popped from the stack, then call it. +// */ +func _fts5yy_pop_parser_stack(tls *libc.TLS, pParser uintptr) { + var fts5yytos, v1, v2 uintptr + _, _, _ = fts5yytos, v1, v2 + v2 = pParser + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) -= 24 + fts5yytos = v1 + _fts5yy_destructor(tls, pParser, (*Tfts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fmajor, fts5yytos+8) +} + +// C documentation +// +// /* +// ** Invoke the destructor function associated with FuncDef p, if any. Except, +// ** if this is not the last copy of the function, do not invoke it. Multiple +// ** copies of a single function are created when create_function() is called +// ** with SQLITE_ANY as the encoding. +// */ +func _functionDestroy(tls *libc.TLS, db uintptr, p uintptr) { + var pDestructor uintptr + _ = pDestructor + pDestructor = *(*uintptr)(unsafe.Pointer(p + 64)) + if pDestructor != 0 { + (*TFuncDestructor)(unsafe.Pointer(pDestructor)).FnRef = (*TFuncDestructor)(unsafe.Pointer(pDestructor)).FnRef - 1 + if (*TFuncDestructor)(unsafe.Pointer(pDestructor)).FnRef == 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDestructor)(unsafe.Pointer(pDestructor)).FxDestroy})))(tls, (*TFuncDestructor)(unsafe.Pointer(pDestructor)).FpUserData) + _sqlite3DbFree(tls, db, pDestructor) + } + } +} + +func _gatherSelectWindows(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_gatherSelectWindowsCallback) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_gatherSelectWindowsSelectCallback) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + (**(**TWalker)(__ccgo_up(bp))).FpParse = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 40)) = p + _sqlite3WalkSelect(tls, bp, p) +} + +func _gatherSelectWindowsSelectCallback(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + var v1 int32 + _ = v1 + if p == *(*uintptr)(unsafe.Pointer(pWalker + 40)) { + v1 = WRC_Continue + } else { + v1 = int32(WRC_Prune) + } + return v1 +} + +// C documentation +// +// /* +// ** Generate code that will tell the VDBE the declaration types of columns +// ** in the result set. +// */ +func _generateColumnTypes(tls *libc.TLS, pParse uintptr, pTabList uintptr, pEList uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var i int32 + var p, v, zType uintptr + var _ /* sNC at bp+0 */ TNameContext + var _ /* zOrigCol at bp+72 */ uintptr + var _ /* zOrigDb at bp+56 */ uintptr + var _ /* zOrigTab at bp+64 */ uintptr + _, _, _, _ = i, p, v, zType + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pTabList + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpNext = uintptr(0) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + p = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr + **(**uintptr)(__ccgo_up(bp + 56)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 72)) = uintptr(0) + zType = _columnTypeImpl(tls, bp, p, bp+56, bp+64, bp+72) + /* The vdbe must make its own copy of the column-type and other + ** column specific strings, in case the schema is reset before this + ** virtual machine is deleted. + */ + _sqlite3VdbeSetColName(tls, v, i, int32(COLNAME_DATABASE), **(**uintptr)(__ccgo_up(bp + 56)), uintptr(-libc.Int32FromInt32(1))) + _sqlite3VdbeSetColName(tls, v, i, int32(COLNAME_TABLE), **(**uintptr)(__ccgo_up(bp + 64)), uintptr(-libc.Int32FromInt32(1))) + _sqlite3VdbeSetColName(tls, v, i, int32(COLNAME_COLUMN), **(**uintptr)(__ccgo_up(bp + 72)), uintptr(-libc.Int32FromInt32(1))) + _sqlite3VdbeSetColName(tls, v, i, int32(COLNAME_DECLTYPE), zType, uintptr(-libc.Int32FromInt32(1))) + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** SQL function: geopoly_contains_point(P,X,Y) +// ** +// ** Return +2 if point X,Y is within polygon P. +// ** Return +1 if point X,Y is on the polygon boundary. +// ** Return 0 if point X,Y is outside the polygon +// */ +func _geopolyContainsPointFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var cnt, ii, v int32 + var p1 uintptr + var x0, y0 float64 + _, _, _, _, _, _ = cnt, ii, p1, v, x0, y0 + p1 = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + x0 = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + y0 = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 2*8))) + v = 0 + cnt = 0 + _ = argc + if p1 == uintptr(0) { + return + } + ii = 0 + for { + if !(ii < (*TGeoPoly)(unsafe.Pointer(p1)).FnVertex-int32(1)) { + break + } + v = _pointBeneathLine(tls, x0, y0, float64(**(**TGeoCoord)(__ccgo_up(p1 + 8 + uintptr(ii*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p1 + 8 + uintptr(ii*int32(2)+int32(1))*4))), float64(**(**TGeoCoord)(__ccgo_up(p1 + 8 + uintptr((ii+int32(1))*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p1 + 8 + uintptr((ii+int32(1))*int32(2)+int32(1))*4)))) + if v == int32(2) { + break + } + cnt = cnt + v + goto _1 + _1: + ; + ii = ii + 1 + } + if v != int32(2) { + v = _pointBeneathLine(tls, x0, y0, float64(**(**TGeoCoord)(__ccgo_up(p1 + 8 + uintptr(ii*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p1 + 8 + uintptr(ii*int32(2)+int32(1))*4))), float64(**(**TGeoCoord)(__ccgo_up(p1 + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p1 + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)))) + } + if v == int32(2) { + Xsqlite3_result_int(tls, context, int32(1)) + } else { + if (v+cnt)&int32(1) == 0 { + Xsqlite3_result_int(tls, context, 0) + } else { + Xsqlite3_result_int(tls, context, int32(2)) + } + } + Xsqlite3_free(tls, p1) +} + +// C documentation +// +// /* +// ** SQL function: geopoly_overlap(P1,P2) +// ** +// ** Determine whether or not P1 and P2 overlap. Return value: +// ** +// ** 0 The two polygons are disjoint +// ** 1 They overlap +// ** 2 P1 is completely contained within P2 +// ** 3 P2 is completely contained within P1 +// ** 4 P1 and P2 are the same polygon +// ** NULL Either P1 or P2 or both are not valid polygons +// */ +func _geopolyOverlapFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var p1, p2 uintptr + var x int32 + _, _, _ = p1, p2, x + p1 = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + p2 = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv + 1*8)), uintptr(0)) + _ = argc + if p1 != 0 && p2 != 0 { + x = _geopolyOverlap(tls, p1, p2) + if x < 0 { + Xsqlite3_result_error_nomem(tls, context) + } else { + Xsqlite3_result_int(tls, context, x) + } + } + Xsqlite3_free(tls, p1) + Xsqlite3_free(tls, p2) +} + +// C documentation +// +// /* +// ** Sort an array of nEvent event objects into a list. +// */ +func _geopolySortEventsByX(tls *libc.TLS, aEvent uintptr, nEvent int32) (r uintptr) { + var a [50]uintptr + var i, j, mx int32 + var p uintptr + _, _, _, _, _ = a, i, j, mx, p + mx = 0 + i = 0 + for { + if !(i < nEvent) { + break + } + p = aEvent + uintptr(i)*32 + (*TGeoEvent)(unsafe.Pointer(p)).FpNext = uintptr(0) + j = 0 + for { + if !(j < mx && a[j] != 0) { + break + } + p = _geopolyEventMerge(tls, a[j], p) + a[j] = uintptr(0) + goto _2 + _2: + ; + j = j + 1 + } + a[j] = p + if j >= mx { + mx = j + int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + p = uintptr(0) + i = 0 + for { + if !(i < mx) { + break + } + p = _geopolyEventMerge(tls, a[i], p) + goto _3 + _3: + ; + i = i + 1 + } + return p +} + +// C documentation +// +// /* +// ** SQL function: geopoly_within(P1,P2) +// ** +// ** Return +2 if P1 and P2 are the same polygon +// ** Return +1 if P2 is contained within P1 +// ** Return 0 if any part of P2 is on the outside of P1 +// ** +// */ +func _geopolyWithinFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var p1, p2 uintptr + var x, v1, v2 int32 + _, _, _, _, _ = p1, p2, x, v1, v2 + p1 = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + p2 = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv + 1*8)), uintptr(0)) + _ = argc + if p1 != 0 && p2 != 0 { + x = _geopolyOverlap(tls, p1, p2) + if x < 0 { + Xsqlite3_result_error_nomem(tls, context) + } else { + if x == int32(2) { + v1 = int32(1) + } else { + if x == int32(4) { + v2 = int32(2) + } else { + v2 = 0 + } + v1 = v2 + } + Xsqlite3_result_int(tls, context, v1) + } + } + Xsqlite3_free(tls, p1) + Xsqlite3_free(tls, p2) +} + +func _getDoubleArg(tls *libc.TLS, p uintptr) (r float64) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if (*TPrintfArguments)(unsafe.Pointer(p)).FnArg <= (*TPrintfArguments)(unsafe.Pointer(p)).FnUsed { + return float64(0) + } + v2 = p + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + return Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up((*TPrintfArguments)(unsafe.Pointer(p)).FapArg + uintptr(v1)*8))) +} + +// C documentation +// +// /* +// ** Extra argument values from a PrintfArguments object +// */ +func _getIntArg(tls *libc.TLS, p uintptr) (r Tsqlite3_int64) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if (*TPrintfArguments)(unsafe.Pointer(p)).FnArg <= (*TPrintfArguments)(unsafe.Pointer(p)).FnUsed { + return 0 + } + v2 = p + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + return Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up((*TPrintfArguments)(unsafe.Pointer(p)).FapArg + uintptr(v1)*8))) +} + +func _getTextArg(tls *libc.TLS, p uintptr) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if (*TPrintfArguments)(unsafe.Pointer(p)).FnArg <= (*TPrintfArguments)(unsafe.Pointer(p)).FnUsed { + return uintptr(0) + } + v2 = p + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + return Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up((*TPrintfArguments)(unsafe.Pointer(p)).FapArg + uintptr(v1)*8))) +} + +func _heightOfExprList(tls *libc.TLS, p uintptr, pnHeight uintptr) { + var i int32 + _ = i + if p != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(p)).FnExpr) { + break + } + _heightOfExpr(tls, (*(*TExprList_item)(unsafe.Pointer(p + 8 + uintptr(i)*32))).FpExpr, pnHeight) + goto _1 + _1: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** Check the N SrcItem objects to the right of pBase. (N might be zero!) +// ** If any of those SrcItem objects have a USING clause containing zName +// ** then return true. +// ** +// ** If N is zero, or none of the N SrcItem objects to the right of pBase +// ** contains a USING clause, or if none of the USING clauses contain zName, +// ** then return false. +// */ +func _inAnyUsingClause(tls *libc.TLS, zName uintptr, pBase uintptr, N int32) (r int32) { + for N > 0 { + N = N - 1 + pBase += 80 + if int32(*(*uint32)(unsafe.Pointer(pBase + 24 + 4))&0x800>>11) == 0 { + continue + } + if *(*uintptr)(unsafe.Pointer(pBase + 64)) == uintptr(0) { + continue + } + if _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pBase + 64)), zName) >= 0 { + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** Check to see if column iCol of index pIdx references any of the +// ** columns defined by aXRef and chngRowid. Return true if it does +// ** and false if not. This is an optimization. False-positives are a +// ** performance degradation, but false-negatives can result in a corrupt +// ** index and incorrect answers. +// ** +// ** aXRef[j] will be non-negative if column j of the original table is +// ** being updated. chngRowid will be true if the rowid of the table is +// ** being updated. +// */ +func _indexColumnIsBeingUpdated(tls *libc.TLS, pIdx uintptr, iCol int32, aXRef uintptr, chngRowid int32) (r int32) { + var iIdxCol Ti16 + _ = iIdxCol + iIdxCol = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iCol)*2)) + /* Cannot index rowid */ + if int32(iIdxCol) >= 0 { + return libc.BoolInt32(**(**int32)(__ccgo_up(aXRef + uintptr(iIdxCol)*4)) >= 0) + } + return _sqlite3ExprReferencesUpdatedColumn(tls, (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(iCol)*32))).FpExpr, aXRef, chngRowid) +} + +// C documentation +// +// /* +// ** Return TRUE if the iCol-th column of index pIdx is NOT NULL +// */ +func _indexColumnNotNull(tls *libc.TLS, pIdx uintptr, iCol int32) (r int32) { + var j int32 + _ = j + j = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iCol)*2))) + if j >= 0 { + return int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(j)*16 + 8)) & 0xf >> 0)) + } else { + if j == -int32(1) { + return int32(1) + } else { + return 0 /* Assume an indexed expression can always yield a NULL */ + } + } + return r +} + +// C documentation +// +// /* Return the next index from the list. Return NULL when out of indexes */ +func _indexIteratorNext(tls *libc.TLS, pIter uintptr, pIx uintptr) (r uintptr) { + var i, v1 int32 + var v2 uintptr + _, _, _ = i, v1, v2 + if (*TIndexIterator)(unsafe.Pointer(pIter)).FeType != 0 { + v2 = pIter + 4 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + i = v1 + if i >= (*(*struct { + FnIdx int32 + FaIdx uintptr + })(unsafe.Pointer(pIter + 8))).FnIdx { + **(**int32)(__ccgo_up(pIx)) = i + return uintptr(0) + } + **(**int32)(__ccgo_up(pIx)) = (**(**TIndexListTerm)(__ccgo_up((*(*struct { + FnIdx int32 + FaIdx uintptr + })(unsafe.Pointer(pIter + 8))).FaIdx + uintptr(i)*16))).Fix + return (**(**TIndexListTerm)(__ccgo_up((*(*struct { + FnIdx int32 + FaIdx uintptr + })(unsafe.Pointer(pIter + 8))).FaIdx + uintptr(i)*16))).Fp + } else { + **(**int32)(__ccgo_up(pIx)) = **(**int32)(__ccgo_up(pIx)) + 1 + (*TIndexIterator)(unsafe.Pointer(pIter)).Fu.Flx.FpIdx = (*TIndex)(unsafe.Pointer((*TIndexIterator)(unsafe.Pointer(pIter)).Fu.Flx.FpIdx)).FpNext + return (*TIndexIterator)(unsafe.Pointer(pIter)).Fu.Flx.FpIdx + } + return r +} + +// C documentation +// +// /* +// ** Initialize an array of N Mem element. +// ** +// ** This is a high-runner, so only those fields that really do need to +// ** be initialized are set. The Mem structure is organized so that +// ** the fields that get initialized are nearby and hopefully on the same +// ** cache line. +// ** +// ** Mem.flags = flags +// ** Mem.db = db +// ** Mem.szMalloc = 0 +// ** +// ** All other fields of Mem can safely remain uninitialized for now. They +// ** will be initialized before use. +// */ +func _initMemArray(tls *libc.TLS, p uintptr, N int32, db uintptr, flags Tu16) { + var v1 int32 + _ = v1 + if N > 0 { + for { + (*TMem)(unsafe.Pointer(p)).Fflags = flags + (*TMem)(unsafe.Pointer(p)).Fdb = db + (*TMem)(unsafe.Pointer(p)).FszMalloc = 0 + p += 56 + goto _2 + _2: + ; + N = N - 1 + v1 = N + if !(v1 > 0) { + break + } + } + } +} + +// C documentation +// +// /* +// ** Return true if any of the first nKey entries of index pIdx exactly +// ** match the iCol-th entry of pPk. pPk is always a WITHOUT ROWID +// ** PRIMARY KEY index. pIdx is an index on the same table. pIdx may +// ** or may not be the same index as pPk. +// ** +// ** The first nKey entries of pIdx are guaranteed to be ordinary columns, +// ** not a rowid or expression. +// ** +// ** This routine differs from hasColumn() in that both the column and the +// ** collating sequence must match for this routine, but for hasColumn() only +// ** the column name must match. +// */ +func _isDupColumn(tls *libc.TLS, pIdx uintptr, nKey int32, pPk uintptr, iCol int32) (r int32) { + var i, j int32 + _, _ = i, j + j = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(iCol)*2))) + i = 0 + for { + if !(i < nKey) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) == j && _sqlite3StrICmp(tls, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(iCol)*8))) == 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** TRUE if p is a lookaside memory allocation from db +// */ +func _isLookaside(tls *libc.TLS, db uintptr, p uintptr) (r int32) { + return libc.BoolInt32(uint64(p) >= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) && uint64(p) < uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd)) +} + +// C documentation +// +// /* +// ** Check to see if the pThis entry of pTabList is a self-join of another view. +// ** Search FROM-clause entries in the range of iFirst..iEnd, including iFirst +// ** but stopping before iEnd. +// ** +// ** If pThis is a self-join, then return the SrcItem for the first other +// ** instance of that view found. If pThis is not a self-join then return 0. +// */ +func _isSelfJoinView(tls *libc.TLS, pTabList uintptr, pThis uintptr, iFirst int32, iEnd int32) (r uintptr) { + var pItem, pS1, pSel uintptr + var v1 int32 + _, _, _, _ = pItem, pS1, pSel, v1 + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pThis + 72)))).FpSelect + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_PushDown) != 0 { + return uintptr(0) + } + for iFirst < iEnd { + v1 = iFirst + iFirst = iFirst + 1 + pItem = pTabList + 8 + uintptr(v1)*80 + if !(int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0) { + continue + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x40>>6) != 0 { + continue + } + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName == uintptr(0) { + continue + } + if (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FpSchema != (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pThis)).FpSTab)).FpSchema { + continue + } + if Xsqlite3_stricmp(tls, (*TSrcItem)(unsafe.Pointer(pItem)).FzName, (*TSrcItem)(unsafe.Pointer(pThis)).FzName) != 0 { + continue + } + pS1 = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + if (*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FpSchema == uintptr(0) && (*TSelect)(unsafe.Pointer(pSel)).FselId != (*TSelect)(unsafe.Pointer(pS1)).FselId { + /* The query flattener left two different CTE tables with identical + ** names in the same FROM clause. */ + continue + } + if (*TSelect)(unsafe.Pointer(pS1)).FselFlags&uint32(SF_PushDown) != 0 { + /* The view was modified by some other optimization such as + ** pushDownWhereTerms() */ + continue + } + return pItem + } + return uintptr(0) +} + +// C documentation +// +// /* Append a single character. +// */ +func _jsonBlobAppendOneByte(tls *libc.TLS, pParse uintptr, c Tu8) { + var v1 Tu32 + var v2 uintptr + _, _ = v1, v2 + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob >= (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc { + _jsonBlobExpandAndAppendOneByte(tls, pParse, c) + } else { + v2 = pParse + 8 + v1 = *(*Tu32)(unsafe.Pointer(v2)) + *(*Tu32)(unsafe.Pointer(v2)) = *(*Tu32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(v1))) = c + } +} + +// C documentation +// +// /* +// ** Free a JsonCache object. +// */ +func _jsonCacheDelete(tls *libc.TLS, p uintptr) { + var i int32 + _ = i + i = 0 + for { + if !(i < (*TJsonCache)(unsafe.Pointer(p)).FnUsed) { + break + } + _jsonParseFree(tls, **(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbFree(tls, (*TJsonCache)(unsafe.Pointer(p)).Fdb, p) +} + +// C documentation +// +// /* Reset a JsonEachCursor back to its original state. Free any memory +// ** held. */ +func _jsonEachCursorReset(tls *libc.TLS, p uintptr) { + _jsonParseReset(tls, p+192) + _jsonStringReset(tls, p+56) + _sqlite3DbFree(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb, (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiRowid = uint32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = uint32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent = uintptr(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = uint32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParentAlloc = uint32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = uint32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) +} + +// C documentation +// +// /* constructor for a JsonEachCursor object for json_each()/json_tree(). */ +func _jsonEachOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) (r int32) { + var pCur, pVtab uintptr + _, _ = pCur, pVtab + pVtab = p + _ = p + pCur = _sqlite3DbMallocZero(tls, (*TJsonEachConnection)(unsafe.Pointer(pVtab)).Fdb, uint64(264)) + if pCur == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TJsonEachCursor)(unsafe.Pointer(pCur)).Fdb = (*TJsonEachConnection)(unsafe.Pointer(pVtab)).Fdb + (*TJsonEachCursor)(unsafe.Pointer(pCur)).FeMode = (*TJsonEachConnection)(unsafe.Pointer(pVtab)).FeMode + (*TJsonEachCursor)(unsafe.Pointer(pCur)).FbRecursive = (*TJsonEachConnection)(unsafe.Pointer(pVtab)).FbRecursive + _jsonStringZero(tls, pCur+56) + **(**uintptr)(__ccgo_up(ppCursor)) = pCur + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Compare two object labels. Return 1 if they are equal and +// ** 0 if they differ. Return -1 if an OOM occurs. +// */ +func _jsonLabelCompare(tls *libc.TLS, zLeft uintptr, nLeft Tu32, rawLeft int32, zRight uintptr, nRight Tu32, rawRight int32) (r int32) { + if rawLeft != 0 && rawRight != 0 { + /* Simpliest case: Neither label contains escapes. A simple + ** memcmp() is sufficient. */ + if nLeft != nRight { + return 0 + } + return libc.BoolInt32(libc.Xmemcmp(tls, zLeft, zRight, uint64(nLeft)) == 0) + } else { + return _jsonLabelCompareEscaped(tls, zLeft, nLeft, rawLeft, zRight, nRight, rawRight) + } + return r +} + +// C documentation +// +// /* +// ** Implementation of the json_quote(VALUE) function. Return a JSON value +// ** corresponding to the SQL value input. Mostly this means putting +// ** double-quotes around strings and returning the unquoted string "null" +// ** when given a NULL input. +// */ +func _jsonQuoteFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var _ /* jx at bp+0 */ TJsonString + _ = argc + _jsonStringInit(tls, bp, ctx) + _jsonAppendSqlValue(tls, bp, **(**uintptr)(__ccgo_up(argv))) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /* Report an out-of-memory (OOM) condition +// */ +func _jsonStringOom(tls *libc.TLS, p uintptr) { + var v1 uintptr + _ = v1 + v1 = p + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_OOM)) + if (*TJsonString)(unsafe.Pointer(p)).FpCtx != 0 { + Xsqlite3_result_error_nomem(tls, (*TJsonString)(unsafe.Pointer(p)).FpCtx) + } + _jsonStringReset(tls, p) +} + +// C documentation +// +// /* Turn uninitialized bulk memory into a valid JsonString object +// ** holding a zero-length string. +// */ +func _jsonStringZero(tls *libc.TLS, p uintptr) { + (*TJsonString)(unsafe.Pointer(p)).FzBuf = p + 34 + (*TJsonString)(unsafe.Pointer(p)).FnAlloc = uint64(100) + (*TJsonString)(unsafe.Pointer(p)).FnUsed = uint64(0) + (*TJsonString)(unsafe.Pointer(p)).FbStatic = uint8(1) +} + +func _last_valueFinalizeFunc(tls *libc.TLS, pCtx uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, pCtx, int32(16)) + if p != 0 && (*TLastValueCtx)(unsafe.Pointer(p)).FpVal != 0 { + Xsqlite3_result_value(tls, pCtx, (*TLastValueCtx)(unsafe.Pointer(p)).FpVal) + Xsqlite3_value_free(tls, (*TLastValueCtx)(unsafe.Pointer(p)).FpVal) + (*TLastValueCtx)(unsafe.Pointer(p)).FpVal = uintptr(0) + } +} + +func _last_valueInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + _ = nArg + _ = apArg + p = Xsqlite3_aggregate_context(tls, pCtx, int32(16)) + if p != 0 { + (*TLastValueCtx)(unsafe.Pointer(p)).FnVal = (*TLastValueCtx)(unsafe.Pointer(p)).FnVal - 1 + if (*TLastValueCtx)(unsafe.Pointer(p)).FnVal == 0 { + Xsqlite3_value_free(tls, (*TLastValueCtx)(unsafe.Pointer(p)).FpVal) + (*TLastValueCtx)(unsafe.Pointer(p)).FpVal = uintptr(0) + } + } +} + +// C documentation +// +// /* +// ** Implementation of last_value(). +// */ +func _last_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + _ = nArg + p = Xsqlite3_aggregate_context(tls, pCtx, int32(16)) + if p != 0 { + Xsqlite3_value_free(tls, (*TLastValueCtx)(unsafe.Pointer(p)).FpVal) + (*TLastValueCtx)(unsafe.Pointer(p)).FpVal = Xsqlite3_value_dup(tls, **(**uintptr)(__ccgo_up(apArg))) + if (*TLastValueCtx)(unsafe.Pointer(p)).FpVal == uintptr(0) { + Xsqlite3_result_error_nomem(tls, pCtx) + } else { + (*TLastValueCtx)(unsafe.Pointer(p)).FnVal = (*TLastValueCtx)(unsafe.Pointer(p)).FnVal + 1 + } + } +} + +// C documentation +// +// /* +// ** Implementation of SQL functions: +// ** +// ** ln(X) - natural logarithm +// ** log(X) - log X base 10 +// ** log10(X) - log X base 10 +// ** log(B,X) - log X base B +// */ +func _logFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var ans, b, x float64 + _, _, _ = ans, b, x + switch Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_INTEGER): + fallthrough + case int32(SQLITE_FLOAT): + x = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv))) + if x <= float64(0) { + return + } + default: + return + } + if argc == int32(2) { + switch Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) { + case int32(SQLITE_INTEGER): + fallthrough + case int32(SQLITE_FLOAT): + b = libc.Xlog(tls, x) + if b <= float64(0) { + return + } + x = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if x <= float64(0) { + return + } + default: + return + } + ans = libc.Xlog(tls, x) / b + } else { + switch int32(int64(Xsqlite3_user_data(tls, context))) { + case int32(1): + ans = libc.Xlog10(tls, x) + case int32(2): + ans = libc.X__builtin_log2(tls, x) + default: + ans = libc.Xlog(tls, x) + break + } + } + Xsqlite3_result_double(tls, context, ans) +} + +// C documentation +// +// /* +// ** Code the OP_MakeRecord instruction that generates the entry to be +// ** added into the sorter. +// ** +// ** Return the register in which the result is stored. +// */ +func _makeSorterRecord(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintptr, regBase int32, nBase int32) (r int32) { + var nOBSat, regOut, v1 int32 + var v, v2 uintptr + _, _, _, _, _ = nOBSat, regOut, v, v1, v2 + nOBSat = (*TSortCtx)(unsafe.Pointer(pSort)).FnOBSat + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regOut = v1 + if (*TSortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad != 0 { + _innerLoopLoadRow(tls, pParse, pSelect, (*TSortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), regBase+nOBSat, nBase-nOBSat, regOut) + return regOut +} + +// C documentation +// +// /* +// ** Mark term iChild as being a child of term iParent +// */ +func _markTermAsChild(tls *libc.TLS, pWC uintptr, iChild int32, iParent int32) { + (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iChild)*56))).FiParent = iParent + (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iChild)*56))).FtruthProb = (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iParent)*56))).FtruthProb + (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iParent)*56))).FnChild = (**(**TWhereTerm)(__ccgo_up((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iParent)*56))).FnChild + 1 +} + +// C documentation +// +// /* +// ** Implementation of 2-argument SQL math functions: +// ** +// ** power(X,Y) - Compute X to the Y-th power +// */ +func _math2Func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var ans, v0, v1 float64 + var type0, type1 int32 + var x uintptr + _, _, _, _, _, _ = ans, type0, type1, v0, v1, x + type0 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) + if type0 != int32(SQLITE_INTEGER) && type0 != int32(SQLITE_FLOAT) { + return + } + type1 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if type1 != int32(SQLITE_INTEGER) && type1 != int32(SQLITE_FLOAT) { + return + } + v0 = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv))) + v1 = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + x = Xsqlite3_user_data(tls, context) + ans = (*(*func(*libc.TLS, float64, float64) float64)(unsafe.Pointer(&struct{ uintptr }{x})))(tls, v0, v1) + Xsqlite3_result_double(tls, context, ans) +} + +// C documentation +// +// /* +// ** Close an memdb-file. +// ** Free the underlying MemStore object when its refcount drops to zero +// ** or less. +// */ +func _memdbClose(tls *libc.TLS, pFile uintptr) (r int32) { + var i, v2 int32 + var p, pVfsMutex, v3 uintptr + _, _, _, _, _ = i, p, pVfsMutex, v2, v3 + p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore + if (*TMemStore)(unsafe.Pointer(p)).FzFName != 0 { + pVfsMutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1)) + Xsqlite3_mutex_enter(tls, pVfsMutex) + i = 0 + for { + if !(i < _memdb_g.FnMemStore) { + break + } + if **(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(i)*8)) == p { + _memdbEnter(tls, p) + if (*TMemStore)(unsafe.Pointer(p)).FnRef == int32(1) { + v3 = uintptr(unsafe.Pointer(&_memdb_g)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) - 1 + v2 = *(*int32)(unsafe.Pointer(v3)) + **(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(i)*8)) = **(**uintptr)(__ccgo_up(_memdb_g.FapMemStore + uintptr(v2)*8)) + if _memdb_g.FnMemStore == 0 { + Xsqlite3_free(tls, _memdb_g.FapMemStore) + _memdb_g.FapMemStore = uintptr(0) + } + } + break + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_mutex_leave(tls, pVfsMutex) + } else { + _memdbEnter(tls, p) + } + (*TMemStore)(unsafe.Pointer(p)).FnRef = (*TMemStore)(unsafe.Pointer(p)).FnRef - 1 + if (*TMemStore)(unsafe.Pointer(p)).FnRef <= 0 { + if (*TMemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_FREEONCLOSE) != 0 { + Xsqlite3_free(tls, (*TMemStore)(unsafe.Pointer(p)).FaData) + } + _memdbLeave(tls, p) + Xsqlite3_mutex_free(tls, (*TMemStore)(unsafe.Pointer(p)).FpMutex) + Xsqlite3_free(tls, p) + } else { + _memdbLeave(tls, p) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Implementation of the non-aggregate min() and max() functions +// */ +func _minmaxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + var i, iBest, mask, v1 int32 + var pColl uintptr + _, _, _, _, _ = i, iBest, mask, pColl, v1 + if Xsqlite3_user_data(tls, context) == uintptr(0) { + v1 = 0 + } else { + v1 = -int32(1) + } + mask = v1 + pColl = _sqlite3GetFuncCollSeq(tls, context) + iBest = 0 + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) == int32(SQLITE_NULL) { + return + } + i = int32(1) + for { + if !(i < argc) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) == int32(SQLITE_NULL) { + return + } + if _sqlite3MemCompare(tls, **(**uintptr)(__ccgo_up(argv + uintptr(iBest)*8)), **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)), pColl)^mask >= 0 { + iBest = i + } + goto _2 + _2: + ; + i = i + 1 + } + Xsqlite3_result_value(tls, context, **(**uintptr)(__ccgo_up(argv + uintptr(iBest)*8))) +} + +// C documentation +// +// /* +// ** Routines to implement min() and max() aggregate functions. +// */ +func _minmaxStep(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + var cmp, max int32 + var pArg, pBest, pColl uintptr + _, _, _, _, _ = cmp, max, pArg, pBest, pColl + pArg = **(**uintptr)(__ccgo_up(argv)) + _ = NotUsed + pBest = Xsqlite3_aggregate_context(tls, context, int32(56)) + if !(pBest != 0) { + return + } + if Xsqlite3_value_type(tls, pArg) == int32(SQLITE_NULL) { + if (*TMem)(unsafe.Pointer(pBest)).Fflags != 0 { + _sqlite3SkipAccumulatorLoad(tls, context) + } + } else { + if (*TMem)(unsafe.Pointer(pBest)).Fflags != 0 { + pColl = _sqlite3GetFuncCollSeq(tls, context) + /* This step function is used for both the min() and max() aggregates, + ** the only difference between the two being that the sense of the + ** comparison is inverted. For the max() aggregate, the + ** sqlite3_user_data() function returns (void *)-1. For min() it + ** returns (void *)db, where db is the sqlite3* database pointer. + ** Therefore the next statement sets variable 'max' to 1 for the max() + ** aggregate, or 0 for min(). + */ + max = libc.BoolInt32(Xsqlite3_user_data(tls, context) != uintptr(0)) + cmp = _sqlite3MemCompare(tls, pBest, pArg, pColl) + if max != 0 && cmp < 0 || !(max != 0) && cmp > 0 { + _sqlite3VdbeMemCopy(tls, pBest, pArg) + } else { + _sqlite3SkipAccumulatorLoad(tls, context) + } + } else { + (*TMem)(unsafe.Pointer(pBest)).Fdb = Xsqlite3_context_db_handle(tls, context) + _sqlite3VdbeMemCopy(tls, pBest, pArg) + } + } +} + +// C documentation +// +// /* +// ** Move the cursor up to the parent page. +// ** +// ** pCur->idx is set to the cell index that contains the pointer +// ** to the page we are coming from. If we are coming from the +// ** right-most child page then pCur->idx is set to one more than +// ** the largest cell index. +// */ +func _moveToParent(tls *libc.TLS, pCur uintptr) { + var pLeaf, v1 uintptr + var v2 Ti8 + _, _, _ = pLeaf, v1, v2 + (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = uint16(0) + v1 = pCur + 1 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(BTCF_ValidNKey) | libc.Int32FromInt32(BTCF_ValidOvfl))) + (*TBtCursor)(unsafe.Pointer(pCur)).Fix = **(**Tu16)(__ccgo_up(pCur + 88 + uintptr(int32((*TBtCursor)(unsafe.Pointer(pCur)).FiPage)-int32(1))*2)) + pLeaf = (*TBtCursor)(unsafe.Pointer(pCur)).FpPage + v1 = pCur + 84 + *(*Ti8)(unsafe.Pointer(v1)) = *(*Ti8)(unsafe.Pointer(v1)) - 1 + v2 = *(*Ti8)(unsafe.Pointer(v1)) + (*TBtCursor)(unsafe.Pointer(pCur)).FpPage = **(**uintptr)(__ccgo_up(pCur + 144 + uintptr(v2)*8)) + _releasePageNotNull(tls, pLeaf) +} + +// C documentation +// +// /* +// ** Return the appropriate collating sequence for the iCol-th column of +// ** the result set for the compound-select statement "p". Return NULL if +// ** the column has no default collating sequence. +// ** +// ** The collating sequence for the compound select is taken from the +// ** left-most term of the select that has a collating sequence. +// */ +func _multiSelectCollSeq(tls *libc.TLS, pParse uintptr, p uintptr, iCol int32) (r uintptr) { + var pRet uintptr + _ = pRet + if (*TSelect)(unsafe.Pointer(p)).FpPrior != 0 { + pRet = _multiSelectCollSeq(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpPrior, iCol) + } else { + pRet = uintptr(0) + } + /* iCol must be less than p->pEList->nExpr. Otherwise an error would + ** have been thrown during name resolution and we would not have gotten + ** this far */ + if pRet == uintptr(0) && iCol < (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList)).FnExpr { + pRet = _sqlite3ExprCollSeq(tls, pParse, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpEList + 8 + uintptr(iCol)*32))).FpExpr) + } + return pRet +} + +// C documentation +// +// /* +// ** Remove node pNode from the node hash table. +// */ +func _nodeHashDelete(tls *libc.TLS, pRtree uintptr, pNode uintptr) { + var pp uintptr + _ = pp + if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode != 0 { + pp = pRtree + 200 + uintptr(_nodeHash(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode))*8 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != pNode) { + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 32 + } + **(**uintptr)(__ccgo_up(pp)) = (*TRtreeNode)(unsafe.Pointer(pNode)).FpNext + (*TRtreeNode)(unsafe.Pointer(pNode)).FpNext = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Search the node hash table for node iNode. If found, return a pointer +// ** to it. Otherwise, return 0. +// */ +func _nodeHashLookup(tls *libc.TLS, pRtree uintptr, iNode Ti64) (r uintptr) { + var p uintptr + _ = p + p = **(**uintptr)(__ccgo_up(pRtree + 200 + uintptr(_nodeHash(tls, iNode))*8)) + for { + if !(p != 0 && (*TRtreeNode)(unsafe.Pointer(p)).FiNode != iNode) { + break + } + goto _1 + _1: + ; + p = (*TRtreeNode)(unsafe.Pointer(p)).FpNext + } + return p +} + +// C documentation +// +// /* +// ** Implementation of the NULLIF(x,y) function. The result is the first +// ** argument if the arguments are different. The result is NULL if the +// ** arguments are equal to each other. +// */ +func _nullifFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + var pColl uintptr + _ = pColl + pColl = _sqlite3GetFuncCollSeq(tls, context) + _ = NotUsed + if _sqlite3MemCompare(tls, **(**uintptr)(__ccgo_up(argv)), **(**uintptr)(__ccgo_up(argv + 1*8)), pColl) != 0 { + Xsqlite3_result_value(tls, context, **(**uintptr)(__ccgo_up(argv))) + } +} + +// C documentation +// +// /* +// ** Write page pPg onto the end of the rollback journal. +// */ +func _pagerAddPageToRollbackJournal(tls *libc.TLS, pPg uintptr) (r int32) { + var cksum Tu32 + var iOff Ti64 + var pData2, pPager, v1 uintptr + var rc int32 + _, _, _, _, _, _ = cksum, iOff, pData2, pPager, rc, v1 + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager + iOff = (*TPager)(unsafe.Pointer(pPager)).FjournalOff + /* We should never write to the journal file the page that + ** contains the database locks. The following assert verifies + ** that we do not. */ + pData2 = (*TPgHdr)(unsafe.Pointer(pPg)).FpData + cksum = _pager_cksum(tls, pPager, pData2) + /* Even if an IO or diskfull error occurs while journalling the + ** page in the block above, set the need-sync flag for the page. + ** Otherwise, when the transaction is rolled back, the logic in + ** playback_one_page() will think that the page needs to be restored + ** in the database file. And if an IO error occurs while doing so, + ** then corruption may follow. + */ + v1 = pPg + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(PGHDR_NEED_SYNC)) + rc = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iOff, (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno) + if rc != SQLITE_OK { + return rc + } + rc = _sqlite3OsWrite(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, pData2, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), iOff+int64(4)) + if rc != SQLITE_OK { + return rc + } + rc = _write32bits(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, iOff+(*TPager)(unsafe.Pointer(pPager)).FpageSize+int64(4), cksum) + if rc != SQLITE_OK { + return rc + } + **(**Ti64)(__ccgo_up(pPager + 96)) += int64(8) + (*TPager)(unsafe.Pointer(pPager)).FpageSize + (*TPager)(unsafe.Pointer(pPager)).FnRec = (*TPager)(unsafe.Pointer(pPager)).FnRec + 1 + rc = _sqlite3BitvecSet(tls, (*TPager)(unsafe.Pointer(pPager)).FpInJournal, (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno) + rc = rc | _addToSavepointBitvecs(tls, pPager, (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno) + return rc +} + +// C documentation +// +// /* +// ** This function is called before attempting a hot-journal rollback. It +// ** syncs the journal file to disk, then sets pPager->journalHdr to the +// ** size of the journal file so that the pager_playback() routine knows +// ** that the entire journal file has been synced. +// ** +// ** Syncing a hot-journal to disk before attempting to roll it back ensures +// ** that if a power-failure occurs during the rollback, the process that +// ** attempts rollback following system recovery sees the same journal +// ** content as this process. +// ** +// ** If everything goes as planned, SQLITE_OK is returned. Otherwise, +// ** an SQLite error code. +// */ +func _pagerSyncHotJournal(tls *libc.TLS, pPager uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if !((*TPager)(unsafe.Pointer(pPager)).FnoSync != 0) { + rc = _sqlite3OsSync(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, int32(SQLITE_SYNC_NORMAL)) + } + if rc == SQLITE_OK { + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, pPager+104) + } + return rc +} + +// C documentation +// +// /* +// ** Update the value of the change-counter at offsets 24 and 92 in +// ** the header and the sqlite version number at offset 96. +// ** +// ** This is an unconditional update. See also the pager_incr_changecounter() +// ** routine which only updates the change-counter if the update is actually +// ** needed, as determined by the pPager->changeCountDone state variable. +// */ +func _pager_write_changecounter(tls *libc.TLS, pPg uintptr) { + var change_counter Tu32 + _ = change_counter + if pPg == uintptr(0) { + return + } + /* Increment the value just read and write it back to byte 24. */ + change_counter = _sqlite3Get4byte(tls, (*TPgHdr)(unsafe.Pointer(pPg)).FpPager+136) + uint32(1) + _sqlite3Put4byte(tls, (*TPgHdr)(unsafe.Pointer(pPg)).FpData+uintptr(24), change_counter) + /* Also store the SQLite version number in bytes 96..99 and in + ** bytes 92..95 store the change counter for which the version number + ** is valid. */ + _sqlite3Put4byte(tls, (*TPgHdr)(unsafe.Pointer(pPg)).FpData+uintptr(92), change_counter) + _sqlite3Put4byte(tls, (*TPgHdr)(unsafe.Pointer(pPg)).FpData+uintptr(96), uint32(SQLITE_VERSION_NUMBER)) +} + +// C documentation +// +// /* Return an integer that is the maximum allowed stack size */ +func _parserStackSizeLimit(tls *libc.TLS, pParse uintptr) (r int32) { + return **(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(pParse)).Fdb + 136 + 12*4)) +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xDestroy method. +// ** +// ** Destroy a cache allocated using pcache1Create(). +// */ +func _pcache1Destroy(tls *libc.TLS, p uintptr) { + var pCache, pGroup uintptr + _, _ = pCache, pGroup + pCache = p + pGroup = (*TPCache1)(unsafe.Pointer(pCache)).FpGroup + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + if (*TPCache1)(unsafe.Pointer(pCache)).FnPage != 0 { + _pcache1TruncateUnsafe(tls, pCache, uint32(0)) + } + **(**uint32)(__ccgo_up(pGroup + 8)) -= (*TPCache1)(unsafe.Pointer(pCache)).FnMax + **(**uint32)(__ccgo_up(pGroup + 12)) -= (*TPCache1)(unsafe.Pointer(pCache)).FnMin + (*TPGroup)(unsafe.Pointer(pGroup)).FmxPinned = (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage + uint32(10) - (*TPGroup)(unsafe.Pointer(pGroup)).FnMinPage + _pcache1EnforceMaxPage(tls, pCache) + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + Xsqlite3_free(tls, (*TPCache1)(unsafe.Pointer(pCache)).FpBulk) + Xsqlite3_free(tls, (*TPCache1)(unsafe.Pointer(pCache)).FapHash) + Xsqlite3_free(tls, pCache) +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xFetch method. +// ** +// ** Fetch a page by key value. +// ** +// ** Whether or not a new page may be allocated by this function depends on +// ** the value of the createFlag argument. 0 means do not allocate a new +// ** page. 1 means allocate a new page if space is easily available. 2 +// ** means to try really hard to allocate a new page. +// ** +// ** For a non-purgeable cache (a cache used as the storage for an in-memory +// ** database) there is really no difference between createFlag 1 and 2. So +// ** the calling function (pcache.c) will never have a createFlag of 1 on +// ** a non-purgeable cache. +// ** +// ** There are three different approaches to obtaining space for a page, +// ** depending on the value of parameter createFlag (which may be 0, 1 or 2). +// ** +// ** 1. Regardless of the value of createFlag, the cache is searched for a +// ** copy of the requested page. If one is found, it is returned. +// ** +// ** 2. If createFlag==0 and the page is not already in the cache, NULL is +// ** returned. +// ** +// ** 3. If createFlag is 1, and the page is not already in the cache, then +// ** return NULL (do not allocate a new page) if any of the following +// ** conditions are true: +// ** +// ** (a) the number of pages pinned by the cache is greater than +// ** PCache1.nMax, or +// ** +// ** (b) the number of pages pinned by the cache is greater than +// ** the sum of nMax for all purgeable caches, less the sum of +// ** nMin for all other purgeable caches, or +// ** +// ** 4. If none of the first three conditions apply and the cache is marked +// ** as purgeable, and if one of the following is true: +// ** +// ** (a) The number of pages allocated for the cache is already +// ** PCache1.nMax, or +// ** +// ** (b) The number of pages allocated for all purgeable caches is +// ** already equal to or greater than the sum of nMax for all +// ** purgeable caches, +// ** +// ** (c) The system is under memory pressure and wants to avoid +// ** unnecessary pages cache entry allocations +// ** +// ** then attempt to recycle a page from the LRU list. If it is the right +// ** size, return the recycled buffer. Otherwise, free the buffer and +// ** proceed to step 5. +// ** +// ** 5. Otherwise, allocate and return a new page buffer. +// ** +// ** There are two versions of this routine. pcache1FetchWithMutex() is +// ** the general case. pcache1FetchNoMutex() is a faster implementation for +// ** the common case where pGroup->mutex is NULL. The pcache1Fetch() wrapper +// ** invokes the appropriate routine. +// */ +func _pcache1FetchNoMutex(tls *libc.TLS, p uintptr, iKey uint32, createFlag int32) (r uintptr) { + var pCache, pPage uintptr + _, _ = pCache, pPage + pCache = p + pPage = uintptr(0) + /* Step 1: Search the hash table for an existing entry. */ + pPage = **(**uintptr)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(iKey%(*TPCache1)(unsafe.Pointer(pCache)).FnHash)*8)) + for pPage != 0 && (*TPgHdr1)(unsafe.Pointer(pPage)).FiKey != iKey { + pPage = (*TPgHdr1)(unsafe.Pointer(pPage)).FpNext + } + /* Step 2: If the page was found in the hash table, then return it. + ** If the page was not in the hash table and createFlag is 0, abort. + ** Otherwise (page not in hash and createFlag!=0) continue with + ** subsequent steps to try to create the page. */ + if pPage != 0 { + if (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext != uintptr(0) { + return _pcache1PinPage(tls, pPage) + } else { + return pPage + } + } else { + if createFlag != 0 { + /* Steps 3, 4, and 5 implemented by this subroutine */ + return _pcache1FetchStage2(tls, pCache, iKey, createFlag) + } else { + return uintptr(0) + } + } + return r +} + +// C documentation +// +// /* +// ** Free an allocated buffer obtained from pcache1Alloc(). +// */ +func _pcache1Free(tls *libc.TLS, p uintptr) { + var nFreed int32 + var pSlot uintptr + _, _ = nFreed, pSlot + if p == uintptr(0) { + return + } + if uint64(p) >= uint64(_pcache1_g.FpStart) && uint64(p) < uint64(_pcache1_g.FpEnd) { + Xsqlite3_mutex_enter(tls, _pcache1_g.Fmutex) + _sqlite3StatusDown(tls, int32(SQLITE_STATUS_PAGECACHE_USED), int32(1)) + pSlot = p + (*TPgFreeslot)(unsafe.Pointer(pSlot)).FpNext = _pcache1_g.FpFree + _pcache1_g.FpFree = pSlot + _pcache1_g.FnFreeSlot = _pcache1_g.FnFreeSlot + 1 + libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&_pcache1_g))+140, libc.BoolInt32(_pcache1_g.FnFreeSlot < _pcache1_g.FnReserve), libc.Int32FromInt32(__ATOMIC_RELAXED)) + Xsqlite3_mutex_leave(tls, _pcache1_g.Fmutex) + } else { + nFreed = 0 + nFreed = _sqlite3MallocSize(tls, p) + Xsqlite3_mutex_enter(tls, _pcache1_g.Fmutex) + _sqlite3StatusDown(tls, int32(SQLITE_STATUS_PAGECACHE_OVERFLOW), nFreed) + Xsqlite3_mutex_leave(tls, _pcache1_g.Fmutex) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xRekey method. +// */ +func _pcache1Rekey(tls *libc.TLS, p uintptr, pPg uintptr, iOld uint32, iNew uint32) { + var hNew, hOld uint32 + var pCache, pPage, pp uintptr + _, _, _, _, _ = hNew, hOld, pCache, pPage, pp + pCache = p + pPage = pPg + /* The page number really is changing */ + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) + /* pPg really is iOld */ + hOld = iOld % (*TPCache1)(unsafe.Pointer(pCache)).FnHash + pp = (*TPCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(hOld)*8 + for **(**uintptr)(__ccgo_up(pp)) != pPage { + pp = **(**uintptr)(__ccgo_up(pp)) + 24 + } + **(**uintptr)(__ccgo_up(pp)) = (*TPgHdr1)(unsafe.Pointer(pPage)).FpNext + /* iNew not in cache */ + hNew = iNew % (*TPCache1)(unsafe.Pointer(pCache)).FnHash + (*TPgHdr1)(unsafe.Pointer(pPage)).FiKey = iNew + (*TPgHdr1)(unsafe.Pointer(pPage)).FpNext = **(**uintptr)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(hNew)*8)) + **(**uintptr)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(hNew)*8)) = pPage + if iNew > (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey { + (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey = iNew + } + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) +} + +// C documentation +// +// /* +// ** Remove the page supplied as an argument from the hash table +// ** (PCache1.apHash structure) that it is currently stored in. +// ** Also free the page if freePage is true. +// ** +// ** The PGroup mutex must be held when this function is called. +// */ +func _pcache1RemoveFromHash(tls *libc.TLS, pPage uintptr, freeFlag int32) { + var h uint32 + var pCache, pp uintptr + _, _, _ = h, pCache, pp + pCache = (*TPgHdr1)(unsafe.Pointer(pPage)).FpCache + h = (*TPgHdr1)(unsafe.Pointer(pPage)).FiKey % (*TPCache1)(unsafe.Pointer(pCache)).FnHash + pp = (*TPCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(h)*8 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != pPage) { + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 24 + } + **(**uintptr)(__ccgo_up(pp)) = (*TPgHdr1)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpNext + (*TPCache1)(unsafe.Pointer(pCache)).FnPage = (*TPCache1)(unsafe.Pointer(pCache)).FnPage - 1 + if freeFlag != 0 { + _pcache1FreePage(tls, pPage) + } +} + +// C documentation +// +// /* +// ** This function is used to resize the hash table used by the cache passed +// ** as the first argument. +// ** +// ** The PCache mutex must be held when this function is called. +// */ +func _pcache1ResizeHash(tls *libc.TLS, p uintptr) { + var apNew, pNext, pPage, v2 uintptr + var h uint32 + var i Tu32 + var nNew Tu64 + _, _, _, _, _, _, _ = apNew, h, i, nNew, pNext, pPage, v2 + nNew = uint64(2) * uint64((*TPCache1)(unsafe.Pointer(p)).FnHash) + if nNew < uint64(256) { + nNew = uint64(256) + } + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(p)).FpGroup)).Fmutex) + if (*TPCache1)(unsafe.Pointer(p)).FnHash != 0 { + _sqlite3BeginBenignMalloc(tls) + } + apNew = _sqlite3MallocZero(tls, uint64(8)*nNew) + if (*TPCache1)(unsafe.Pointer(p)).FnHash != 0 { + _sqlite3EndBenignMalloc(tls) + } + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(p)).FpGroup)).Fmutex) + if apNew != 0 { + i = uint32(0) + for { + if !(i < (*TPCache1)(unsafe.Pointer(p)).FnHash) { + break + } + pNext = **(**uintptr)(__ccgo_up((*TPCache1)(unsafe.Pointer(p)).FapHash + uintptr(i)*8)) + for { + v2 = pNext + pPage = v2 + if !(v2 != uintptr(0)) { + break + } + h = uint32(uint64((*TPgHdr1)(unsafe.Pointer(pPage)).FiKey) % nNew) + pNext = (*TPgHdr1)(unsafe.Pointer(pPage)).FpNext + (*TPgHdr1)(unsafe.Pointer(pPage)).FpNext = **(**uintptr)(__ccgo_up(apNew + uintptr(h)*8)) + **(**uintptr)(__ccgo_up(apNew + uintptr(h)*8)) = pPage + } + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*TPCache1)(unsafe.Pointer(p)).FapHash) + (*TPCache1)(unsafe.Pointer(p)).FapHash = apNew + (*TPCache1)(unsafe.Pointer(p)).FnHash = uint32(nNew) + } +} + +// C documentation +// +// /* +// ** Discard all pages from cache pCache with a page number (key value) +// ** greater than or equal to iLimit. Any pinned pages that meet this +// ** criteria are unpinned before they are discarded. +// ** +// ** The PCache mutex must be held when this function is called. +// */ +func _pcache1TruncateUnsafe(tls *libc.TLS, pCache uintptr, iLimit uint32) { + var h, iStop uint32 + var pPage, pp, v2 uintptr + _, _, _, _, _ = h, iStop, pPage, pp, v2 + if (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey-iLimit < (*TPCache1)(unsafe.Pointer(pCache)).FnHash { + /* If we are just shaving the last few pages off the end of the + ** cache, then there is no point in scanning the entire hash table. + ** Only scan those hash slots that might contain pages that need to + ** be removed. */ + h = iLimit % (*TPCache1)(unsafe.Pointer(pCache)).FnHash + iStop = (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey % (*TPCache1)(unsafe.Pointer(pCache)).FnHash + /* Disable the pCache->nPage validity check */ + } else { + /* This is the general case where many pages are being removed. + ** It is necessary to scan the entire hash table */ + h = (*TPCache1)(unsafe.Pointer(pCache)).FnHash / uint32(2) + iStop = h - uint32(1) + } + for { + pp = (*TPCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(h)*8 + for { + v2 = **(**uintptr)(__ccgo_up(pp)) + pPage = v2 + if !(v2 != uintptr(0)) { + break + } + if (*TPgHdr1)(unsafe.Pointer(pPage)).FiKey >= iLimit { + (*TPCache1)(unsafe.Pointer(pCache)).FnPage = (*TPCache1)(unsafe.Pointer(pCache)).FnPage - 1 + **(**uintptr)(__ccgo_up(pp)) = (*TPgHdr1)(unsafe.Pointer(pPage)).FpNext + if (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext != uintptr(0) { + _pcache1PinPage(tls, pPage) + } + _pcache1FreePage(tls, pPage) + } else { + pp = pPage + 24 + } + } + if h == iStop { + break + } + h = (h + uint32(1)) % (*TPCache1)(unsafe.Pointer(pCache)).FnHash + goto _1 + _1: + } +} + +/******************************************************************************/ +/******** sqlite3_pcache Methods **********************************************/ + +// C documentation +// +// /* +// ** Return true if it desirable to avoid allocating a new page cache +// ** entry. +// ** +// ** If memory was allocated specifically to the page cache using +// ** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then +// ** it is desirable to avoid allocating a new page cache entry because +// ** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient +// ** for all page cache needs and we should not need to spill the +// ** allocation onto the heap. +// ** +// ** Or, the heap is used for all page cache memory but the heap is +// ** under memory pressure, then again it is desirable to avoid +// ** allocating a new page cache entry in order to avoid stressing +// ** the heap even further. +// */ +func _pcache1UnderMemoryPressure(tls *libc.TLS, pCache uintptr) (r int32) { + if _pcache1_g.FnSlot != 0 && (*TPCache1)(unsafe.Pointer(pCache)).FszPage+(*TPCache1)(unsafe.Pointer(pCache)).FszExtra <= _pcache1_g.FszSlot { + return libc.AtomicLoadNInt32(uintptr(unsafe.Pointer(&_pcache1_g))+140, libc.Int32FromInt32(__ATOMIC_RELAXED)) + } else { + return _sqlite3HeapNearlyFull(tls) + } + return r +} + +/******************************************************************************/ +/******** General Implementation Functions ************************************/ + +// C documentation +// +// /* +// ** Implementation of the sqlite3_pcache.xUnpin method. +// ** +// ** Mark a page as unpinned (eligible for asynchronous recycling). +// */ +func _pcache1Unpin(tls *libc.TLS, p uintptr, pPg uintptr, reuseUnlikely int32) { + var pCache, pGroup, pPage, ppFirst, v1 uintptr + _, _, _, _, _ = pCache, pGroup, pPage, ppFirst, v1 + pCache = p + pPage = pPg + pGroup = (*TPCache1)(unsafe.Pointer(pCache)).FpGroup + Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex) + /* It is an error to call this function if the page is already + ** part of the PGroup LRU list. + */ + if reuseUnlikely != 0 || (*TPGroup)(unsafe.Pointer(pGroup)).FnPurgeable > (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage { + _pcache1RemoveFromHash(tls, pPage, int32(1)) + } else { + /* Add the page to the PGroup LRU list. */ + ppFirst = pGroup + 24 + 40 + (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruPrev = pGroup + 24 + v1 = **(**uintptr)(__ccgo_up(ppFirst)) + (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext = v1 + (*TPgHdr1)(unsafe.Pointer(v1)).FpLruPrev = pPage + **(**uintptr)(__ccgo_up(ppFirst)) = pPage + (*TPCache1)(unsafe.Pointer(pCache)).FnRecyclable = (*TPCache1)(unsafe.Pointer(pCache)).FnRecyclable + 1 + } + Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex) +} + +// C documentation +// +// /* +// ** Merge two lists of pages connected by pDirty and in pgno order. +// ** Do not bother fixing the pDirtyPrev pointers. +// */ +func _pcacheMergeDirtyList(tls *libc.TLS, pA uintptr, pB uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var pTail uintptr + var _ /* result at bp+0 */ TPgHdr + _ = pTail + pTail = bp + for { + if (*TPgHdr)(unsafe.Pointer(pA)).Fpgno < (*TPgHdr)(unsafe.Pointer(pB)).Fpgno { + (*TPgHdr)(unsafe.Pointer(pTail)).FpDirty = pA + pTail = pA + pA = (*TPgHdr)(unsafe.Pointer(pA)).FpDirty + if pA == uintptr(0) { + (*TPgHdr)(unsafe.Pointer(pTail)).FpDirty = pB + break + } + } else { + (*TPgHdr)(unsafe.Pointer(pTail)).FpDirty = pB + pTail = pB + pB = (*TPgHdr)(unsafe.Pointer(pB)).FpDirty + if pB == uintptr(0) { + (*TPgHdr)(unsafe.Pointer(pTail)).FpDirty = pA + break + } + } + goto _1 + _1: + } + return (**(**TPgHdr)(__ccgo_up(bp))).FpDirty +} + +// C documentation +// +// /* +// ** Argument zFmt is a sqlite3_mprintf() style format string. The trailing +// ** arguments are the usual subsitution values. This function performs +// ** the printf() style substitutions and executes the result as an SQL +// ** statement on the RBU handles database. +// ** +// ** If an error occurs, an error code and error message is stored in the +// ** RBU handle. If an error has already occurred when this function is +// ** called, it is a no-op. +// */ +func _rbuMPrintfExec(tls *libc.TLS, p uintptr, db uintptr, zFmt uintptr, va uintptr) (r int32) { + var ap Tva_list + var zSql uintptr + _, _ = ap, zSql + ap = va + zSql = Xsqlite3_vmprintf(tls, zFmt, ap) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if zSql == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), p+64) + } + } + Xsqlite3_free(tls, zSql) + _ = ap + return (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc +} + +// C documentation +// +// /* +// ** Remove an item from the main-db lists. +// */ +func _rbuMainlistRemove(tls *libc.TLS, p uintptr) { + var pp uintptr + _ = pp + Xsqlite3_mutex_enter(tls, (*Trbu_vfs)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs)).Fmutex) + pp = (*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs + 192 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0 && **(**uintptr)(__ccgo_up(pp)) != p) { + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 88 + } + if **(**uintptr)(__ccgo_up(pp)) != 0 { + **(**uintptr)(__ccgo_up(pp)) = (*Trbu_file)(unsafe.Pointer(p)).FpMainNext + } + (*Trbu_file)(unsafe.Pointer(p)).FpMainNext = uintptr(0) + pp = (*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs + 200 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0 && **(**uintptr)(__ccgo_up(pp)) != p) { + break + } + goto _2 + _2: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 96 + } + if **(**uintptr)(__ccgo_up(pp)) != 0 { + **(**uintptr)(__ccgo_up(pp)) = (*Trbu_file)(unsafe.Pointer(p)).FpMainRbuNext + } + (*Trbu_file)(unsafe.Pointer(p)).FpMainRbuNext = uintptr(0) + Xsqlite3_mutex_leave(tls, (*Trbu_vfs)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs)).Fmutex) +} + +// C documentation +// +// /* +// ** Free the RbuObjIter.azTblCol[] and RbuObjIter.abTblPk[] arrays allocated +// ** by an earlier call to rbuObjIterCacheTableInfo(). +// */ +func _rbuObjIterFreeCols(tls *libc.TLS, pIter uintptr) { + var i int32 + _ = i + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblType = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FabNotNull = uintptr(0) + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol = 0 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType = 0 /* Invalid value */ +} + +func _rbuTmpInsertFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { + var i, rc int32 + var p uintptr + _, _, _ = i, p, rc + p = Xsqlite3_user_data(tls, pCtx) + rc = SQLITE_OK + if Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(apVal))) != 0 { + **(**Ti64)(__ccgo_up(p + 312)) += int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex) + } + i = 0 + for { + if !(rc == SQLITE_OK && i < nVal) { + break + } + rc = Xsqlite3_bind_value(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert, i+int32(1), **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + if rc == SQLITE_OK { + Xsqlite3_step(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert) + rc = Xsqlite3_reset(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert) + } + if rc != SQLITE_OK { + Xsqlite3_result_error_code(tls, pCtx, rc) + } +} + +// C documentation +// +// /* +// */ +func _rbuUpdateTempSize(tls *libc.TLS, pFd uintptr, nNew Tsqlite3_int64) (r int32) { + var nDiff Ti64 + var pRbu uintptr + _, _ = nDiff, pRbu + pRbu = (*Trbu_file)(unsafe.Pointer(pFd)).FpRbu + nDiff = nNew - (*Trbu_file)(unsafe.Pointer(pFd)).Fsz + **(**Ti64)(__ccgo_up(pRbu + 384)) += nDiff + (*Trbu_file)(unsafe.Pointer(pFd)).Fsz = nNew + if (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTemp > (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit { + return int32(SQLITE_FULL) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Close an rbu file. +// */ +func _rbuVfsClose(tls *libc.TLS, pFile uintptr) (r int32) { + var i, rc int32 + var p, pMeth uintptr + _, _, _, _ = i, p, pMeth, rc + p = pFile + /* Free the contents of the apShm[] array. And the array itself. */ + i = 0 + for { + if !(i < (*Trbu_file)(unsafe.Pointer(p)).FnShm) { + break + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up((*Trbu_file)(unsafe.Pointer(p)).FapShm + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*Trbu_file)(unsafe.Pointer(p)).FapShm) + (*Trbu_file)(unsafe.Pointer(p)).FapShm = uintptr(0) + Xsqlite3_free(tls, (*Trbu_file)(unsafe.Pointer(p)).FzDel) + if (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + pMeth = (*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + _rbuMainlistRemove(tls, p) + _rbuUnlockShm(tls, p) + if (*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FiVersion > int32(1) && (*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FxShmUnmap != 0 { + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FxShmUnmap})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, 0) + } + } else { + if (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_DELETEONCLOSE) != 0 && (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 { + _rbuUpdateTempSize(tls, p, 0) + } + } + /* Close the underlying file handle */ + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxClose})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal) + return rc +} + +// C documentation +// +// /* +// ** Free all structures in the Pager.aSavepoint[] array and set both +// ** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal +// ** if it is open and the pager is not in exclusive mode. +// */ +func _releaseAllSavepoints(tls *libc.TLS, pPager uintptr) { + var ii int32 + _ = ii /* Iterator for looping through Pager.aSavepoint */ + ii = 0 + for { + if !(ii < (*TPager)(unsafe.Pointer(pPager)).FnSavepoint) { + break + } + _sqlite3BitvecDestroy(tls, (**(**TPagerSavepoint)(__ccgo_up((*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*56))).FpInSavepoint) + goto _1 + _1: + ; + ii = ii + 1 + } + if !((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) || _sqlite3JournalIsInMemory(tls, (*TPager)(unsafe.Pointer(pPager)).Fsjfd) != 0 { + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fsjfd) + } + Xsqlite3_free(tls, (*TPager)(unsafe.Pointer(pPager)).FaSavepoint) + (*TPager)(unsafe.Pointer(pPager)).FaSavepoint = uintptr(0) + (*TPager)(unsafe.Pointer(pPager)).FnSavepoint = 0 + (*TPager)(unsafe.Pointer(pPager)).FnSubRec = uint32(0) +} + +// C documentation +// +// /* Remove a single entry from the hash table given a pointer to that +// ** element and a hash on the element's key. +// */ +func _removeElement(tls *libc.TLS, pH uintptr, elem uintptr) { + var pEntry uintptr + _ = pEntry + if (*THashElem)(unsafe.Pointer(elem)).Fprev != 0 { + (*THashElem)(unsafe.Pointer((*THashElem)(unsafe.Pointer(elem)).Fprev)).Fnext = (*THashElem)(unsafe.Pointer(elem)).Fnext + } else { + (*THash)(unsafe.Pointer(pH)).Ffirst = (*THashElem)(unsafe.Pointer(elem)).Fnext + } + if (*THashElem)(unsafe.Pointer(elem)).Fnext != 0 { + (*THashElem)(unsafe.Pointer((*THashElem)(unsafe.Pointer(elem)).Fnext)).Fprev = (*THashElem)(unsafe.Pointer(elem)).Fprev + } + if (*THash)(unsafe.Pointer(pH)).Fht != 0 { + pEntry = (*THash)(unsafe.Pointer(pH)).Fht + uintptr((*THashElem)(unsafe.Pointer(elem)).Fh%(*THash)(unsafe.Pointer(pH)).Fhtsize)*16 + if (*T_ht)(unsafe.Pointer(pEntry)).Fchain == elem { + (*T_ht)(unsafe.Pointer(pEntry)).Fchain = (*THashElem)(unsafe.Pointer(elem)).Fnext + } + (*T_ht)(unsafe.Pointer(pEntry)).Fcount = (*T_ht)(unsafe.Pointer(pEntry)).Fcount - 1 + } + Xsqlite3_free(tls, elem) + (*THash)(unsafe.Pointer(pH)).Fcount = (*THash)(unsafe.Pointer(pH)).Fcount - 1 + if (*THash)(unsafe.Pointer(pH)).Fcount == uint32(0) { + _sqlite3HashClear(tls, pH) + } +} + +// C documentation +// +// /* +// ** Remove connection db from the blocked connections list. If connection +// ** db is not currently a part of the list, this function is a no-op. +// */ +func _removeFromBlockedList(tls *libc.TLS, db uintptr) { + var pp uintptr + _ = pp + pp = uintptr(unsafe.Pointer(&_sqlite3BlockedList)) + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + if **(**uintptr)(__ccgo_up(pp)) == db { + **(**uintptr)(__ccgo_up(pp)) = (*Tsqlite3)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpNextBlocked + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 856 + } +} + +// C documentation +// +// /* +// ** For each name in the the expression-list pEList (i.e. each +// ** pEList->a[i].zName) that matches the string in zOld, extract the +// ** corresponding rename-token from Parse object pParse and add it +// ** to the RenameCtx pCtx. +// */ +func _renameColumnElistNames(tls *libc.TLS, pParse uintptr, pCtx uintptr, pEList uintptr, zOld uintptr) { + var i int32 + var zName uintptr + _, _ = i, zName + if pEList != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + zName = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME && zName != uintptr(0) && 0 == Xsqlite3_stricmp(tls, zName, zOld) { + _renameTokenFind(tls, pParse, pCtx, zName) + } + goto _1 + _1: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** For each name in the the id-list pIdList (i.e. each pIdList->a[i].zName) +// ** that matches the string in zOld, extract the corresponding rename-token +// ** from Parse object pParse and add it to the RenameCtx pCtx. +// */ +func _renameColumnIdlistNames(tls *libc.TLS, pParse uintptr, pCtx uintptr, pIdList uintptr, zOld uintptr) { + var i int32 + var zName uintptr + _, _ = i, zName + if pIdList != 0 { + i = 0 + for { + if !(i < (*TIdList)(unsafe.Pointer(pIdList)).FnId) { + break + } + zName = (*(*TIdList_item)(unsafe.Pointer(pIdList + 8 + uintptr(i)*8))).FzName + if 0 == Xsqlite3_stricmp(tls, zName, zOld) { + _renameTokenFind(tls, pParse, pCtx, zName) + } + goto _1 + _1: + ; + i = i + 1 + } + } +} + +// C documentation +// +// /* +// ** The RenameCtx contains a list of tokens that reference a column that +// ** is being renamed by an ALTER TABLE statement. Return the "last" +// ** RenameToken in the RenameCtx and remove that RenameToken from the +// ** RenameContext. "Last" means the last RenameToken encountered when +// ** the input SQL is parsed from left to right. Repeated calls to this routine +// ** return all column name tokens in the order that they are encountered +// ** in the SQL statement. +// */ +func _renameColumnTokenNext(tls *libc.TLS, pCtx uintptr) (r uintptr) { + var pBest, pToken, pp uintptr + _, _, _ = pBest, pToken, pp + pBest = (*TRenameCtx)(unsafe.Pointer(pCtx)).FpList + pToken = (*TRenameToken)(unsafe.Pointer(pBest)).FpNext + for { + if !(pToken != 0) { + break + } + if (*TRenameToken)(unsafe.Pointer(pToken)).Ft.Fz > (*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz { + pBest = pToken + } + goto _1 + _1: + ; + pToken = (*TRenameToken)(unsafe.Pointer(pToken)).FpNext + } + pp = pCtx + for { + if !(**(**uintptr)(__ccgo_up(pp)) != pBest) { + break + } + goto _2 + _2: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 24 + } + **(**uintptr)(__ccgo_up(pp)) = (*TRenameToken)(unsafe.Pointer(pBest)).FpNext + return pBest +} + +// C documentation +// +// /* +// ** Search the Parse object passed as the first argument for a RenameToken +// ** object associated with parse tree element pPtr. If found, return a pointer +// ** to it. Otherwise, return NULL. +// ** +// ** If the second argument passed to this function is not NULL and a matching +// ** RenameToken object is found, remove it from the Parse object and add it to +// ** the list maintained by the RenameCtx object. +// */ +func _renameTokenFind(tls *libc.TLS, pParse uintptr, pCtx uintptr, pPtr uintptr) (r uintptr) { + var pToken, pp uintptr + _, _ = pToken, pp + if pPtr == uintptr(0) { + return uintptr(0) + } + pp = pParse + 408 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + if (*TRenameToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).Fp == pPtr { + pToken = **(**uintptr)(__ccgo_up(pp)) + if pCtx != 0 { + **(**uintptr)(__ccgo_up(pp)) = (*TRenameToken)(unsafe.Pointer(pToken)).FpNext + (*TRenameToken)(unsafe.Pointer(pToken)).FpNext = (*TRenameCtx)(unsafe.Pointer(pCtx)).FpList + (*TRenameCtx)(unsafe.Pointer(pCtx)).FpList = pToken + (*TRenameCtx)(unsafe.Pointer(pCtx)).FnList = (*TRenameCtx)(unsafe.Pointer(pCtx)).FnList + 1 + } + return pToken + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 24 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Invoke sqlite3WalkExpr() or sqlite3WalkSelect() on all Select or Expr +// ** objects that are part of the trigger passed as the second argument. +// */ +func _renameWalkTrigger(tls *libc.TLS, pWalker uintptr, pTrigger uintptr) { + var i int32 + var pSrc, pStep, pUpsert uintptr + _, _, _, _ = i, pSrc, pStep, pUpsert + /* Find tokens to edit in WHEN clause */ + _sqlite3WalkExpr(tls, pWalker, (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen) + /* Find tokens to edit in trigger steps */ + pStep = (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list + for { + if !(pStep != 0) { + break + } + _sqlite3WalkSelect(tls, pWalker, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect) + _sqlite3WalkExpr(tls, pWalker, (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere) + _sqlite3WalkExprList(tls, pWalker, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList) + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0 { + pUpsert = (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert + _sqlite3WalkExprList(tls, pWalker, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) + _sqlite3WalkExprList(tls, pWalker, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSet) + _sqlite3WalkExpr(tls, pWalker, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere) + _sqlite3WalkExpr(tls, pWalker, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) + } + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + pSrc = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 24 + 4))&0x4>>2) != 0 { + _sqlite3WalkSelect(tls, pWalker, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80 + 72)))).FpSelect) + } + goto _2 + _2: + ; + i = i + 1 + } + } + goto _1 + _1: + ; + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } +} + +// C documentation +// +// /* +// ** *piCursor is a cursor number. Change it if it needs to be mapped. +// */ +func _renumberCursorDoMapping(tls *libc.TLS, pWalker uintptr, piCursor uintptr) { + var aCsrMap uintptr + var iCsr int32 + _, _ = aCsrMap, iCsr + aCsrMap = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + iCsr = **(**int32)(__ccgo_up(piCursor)) + if iCsr < **(**int32)(__ccgo_up(aCsrMap)) && **(**int32)(__ccgo_up(aCsrMap + uintptr(iCsr+int32(1))*4)) > 0 { + **(**int32)(__ccgo_up(piCursor)) = **(**int32)(__ccgo_up(aCsrMap + uintptr(iCsr+int32(1))*4)) + } +} + +// C documentation +// +// /* +// ** Merge two lists of RowSetEntry objects. Remove duplicates. +// ** +// ** The input lists are connected via pRight pointers and are +// ** assumed to each already be in sorted order. +// */ +func _rowSetEntryMerge(tls *libc.TLS, pA uintptr, pB uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var pTail, v2 uintptr + var _ /* head at bp+0 */ TRowSetEntry + _, _ = pTail, v2 + pTail = bp + for { + if (*TRowSetEntry)(unsafe.Pointer(pA)).Fv <= (*TRowSetEntry)(unsafe.Pointer(pB)).Fv { + if (*TRowSetEntry)(unsafe.Pointer(pA)).Fv < (*TRowSetEntry)(unsafe.Pointer(pB)).Fv { + v2 = pA + (*TRowSetEntry)(unsafe.Pointer(pTail)).FpRight = v2 + pTail = v2 + } + pA = (*TRowSetEntry)(unsafe.Pointer(pA)).FpRight + if pA == uintptr(0) { + (*TRowSetEntry)(unsafe.Pointer(pTail)).FpRight = pB + break + } + } else { + v2 = pB + (*TRowSetEntry)(unsafe.Pointer(pTail)).FpRight = v2 + pTail = v2 + pB = (*TRowSetEntry)(unsafe.Pointer(pB)).FpRight + if pB == uintptr(0) { + (*TRowSetEntry)(unsafe.Pointer(pTail)).FpRight = pA + break + } + } + goto _1 + _1: + } + return (**(**TRowSetEntry)(__ccgo_up(bp))).FpRight +} + +// C documentation +// +// /* +// ** Remove the entry with rowid=iDelete from the r-tree structure. +// */ +func _rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Tsqlite3_int64) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var iChild Ti64 + var rc, rc2, rc21 int32 + var _ /* iCell at bp+8 */ int32 + var _ /* pChild at bp+24 */ uintptr + var _ /* pLeaf at bp+0 */ uintptr + var _ /* pRoot at bp+16 */ uintptr + _, _, _, _ = iChild, rc, rc2, rc21 /* Return code */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Index of iDelete cell in pLeaf */ + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) /* Root node of rtree structure */ + /* Obtain a reference to the root node to initialize Rtree.iDepth */ + rc = _nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp+16) + /* Obtain a reference to the leaf node that contains the entry + ** about to be deleted. + */ + if rc == SQLITE_OK { + rc = _findLeafNode(tls, pRtree, iDelete, bp, uintptr(0)) + } + /* Delete the cell in question from the leaf node. */ + if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp)) != 0 { + rc = _nodeRowidIndex(tls, pRtree, **(**uintptr)(__ccgo_up(bp)), iDelete, bp+8) + if rc == SQLITE_OK { + rc = _deleteCell(tls, pRtree, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), 0) + } + rc2 = _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + rc = rc2 + } + } + /* Delete the corresponding entry in the _rowid table. */ + if rc == SQLITE_OK { + Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteRowid, int32(1), iDelete) + Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteRowid) + rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteRowid) + } + /* Check if the root node now has exactly one child. If so, remove + ** it, schedule the contents of the child for reinsertion and + ** reduce the tree height by one. + ** + ** This is equivalent to copying the contents of the child into + ** the root node (the operation that Gutman's paper says to perform + ** in this scenario). + */ + if rc == SQLITE_OK && (*TRtree)(unsafe.Pointer(pRtree)).FiDepth > 0 && _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FzData+2) == int32(1) { + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + iChild = _nodeGetRowid(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 16)), 0) + rc = _nodeAcquire(tls, pRtree, iChild, **(**uintptr)(__ccgo_up(bp + 16)), bp+24) /* tag-20210916a */ + if rc == SQLITE_OK { + rc = _removeNode(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 24)), (*TRtree)(unsafe.Pointer(pRtree)).FiDepth-int32(1)) + } + rc21 = _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 24))) + if rc == SQLITE_OK { + rc = rc21 + } + if rc == SQLITE_OK { + (*TRtree)(unsafe.Pointer(pRtree)).FiDepth = (*TRtree)(unsafe.Pointer(pRtree)).FiDepth - 1 + _writeInt16(tls, (*TRtreeNode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FzData, (*TRtree)(unsafe.Pointer(pRtree)).FiDepth) + (*TRtreeNode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 16)))).FisDirty = int32(1) + } + } + /* Re-insert the contents of any underfull nodes removed from the tree. */ + **(**uintptr)(__ccgo_up(bp)) = (*TRtree)(unsafe.Pointer(pRtree)).FpDeleted + for { + if !(**(**uintptr)(__ccgo_up(bp)) != 0) { + break + } + if rc == SQLITE_OK { + rc = _reinsertNodeContent(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + } + (*TRtree)(unsafe.Pointer(pRtree)).FpDeleted = (*TRtreeNode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpNext + (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef = (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef - 1 + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(bp)) = (*TRtree)(unsafe.Pointer(pRtree)).FpDeleted + } + /* Release the reference to the root node. */ + if rc == SQLITE_OK { + rc = _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 16))) + } else { + _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp + 16))) + } + return rc +} + +/* +** Rounding constants for float->double conversion. + */ + +// C documentation +// +// /* +// ** This routine frees the BLOB that is returned by geomCallback(). +// */ +func _rtreeMatchArgFree(tls *libc.TLS, pArg uintptr) { + var i int32 + var p uintptr + _, _ = i, p + p = pArg + i = 0 + for { + if !(i < (*TRtreeMatchArg)(unsafe.Pointer(p)).FnParam) { + break + } + Xsqlite3_value_free(tls, **(**uintptr)(__ccgo_up((*TRtreeMatchArg)(unsafe.Pointer(p)).FapSqlParam + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, p) +} + +// C documentation +// +// /* +// ** Decrement the r-tree reference count. When the reference count reaches +// ** zero the structure is deleted. +// */ +func _rtreeRelease(tls *libc.TLS, pRtree uintptr) { + var i int32 + var pNext uintptr + _, _ = i, pNext + (*TRtree)(unsafe.Pointer(pRtree)).FnBusy = (*TRtree)(unsafe.Pointer(pRtree)).FnBusy - 1 + if (*TRtree)(unsafe.Pointer(pRtree)).FnBusy == uint32(0) { + (*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = uint8(0) + _nodeBlobReset(tls, pRtree) + if (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0 { + i = 0 + for { + if !(i < int32(HASHSIZE)) { + break + } + for **(**uintptr)(__ccgo_up(pRtree + 200 + uintptr(i)*8)) != 0 { + pNext = (*TRtreeNode)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pRtree + 200 + uintptr(i)*8)))).FpNext + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(pRtree + 200 + uintptr(i)*8))) + **(**uintptr)(__ccgo_up(pRtree + 200 + uintptr(i)*8)) = pNext + } + goto _1 + _1: + ; + i = i + 1 + } + } + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteNode) + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteNode) + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid) + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteRowid) + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent) + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent) + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteParent) + Xsqlite3_finalize(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteAux) + Xsqlite3_free(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzReadAuxSql) + Xsqlite3_free(tls, pRtree) + } +} + +// C documentation +// +// /* +// ** Return the search point with the lowest current score. +// */ +func _rtreeSearchPointFirst(tls *libc.TLS, pCur uintptr) (r uintptr) { + var v1, v2 uintptr + _, _ = v1, v2 + if (*TRtreeCursor)(unsafe.Pointer(pCur)).FbPoint != 0 { + v1 = pCur + 64 + } else { + if (*TRtreeCursor)(unsafe.Pointer(pCur)).FnPoint != 0 { + v2 = (*TRtreeCursor)(unsafe.Pointer(pCur)).FaPoint + } else { + v2 = uintptr(0) + } + v1 = v2 + } + return v1 +} + +// C documentation +// +// /* +// ** Interchange two search points in a cursor. +// */ +func _rtreeSearchPointSwap(tls *libc.TLS, p uintptr, i int32, j int32) { + var pTemp uintptr + var t TRtreeSearchPoint + _, _ = pTemp, t + t = **(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(i)*24)) + **(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(i)*24)) = **(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(j)*24)) + **(**TRtreeSearchPoint)(__ccgo_up((*TRtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(j)*24)) = t + i = i + 1 + j = j + 1 + if i < int32(RTREE_CACHE_SZ) { + if j >= int32(RTREE_CACHE_SZ) { + _nodeRelease(tls, (*TRtreeCursor)(unsafe.Pointer(p)).Fbase.FpVtab, **(**uintptr)(__ccgo_up(p + 88 + uintptr(i)*8))) + **(**uintptr)(__ccgo_up(p + 88 + uintptr(i)*8)) = uintptr(0) + } else { + pTemp = **(**uintptr)(__ccgo_up(p + 88 + uintptr(i)*8)) + **(**uintptr)(__ccgo_up(p + 88 + uintptr(i)*8)) = **(**uintptr)(__ccgo_up(p + 88 + uintptr(j)*8)) + **(**uintptr)(__ccgo_up(p + 88 + uintptr(j)*8)) = pTemp + } + } +} + +// C documentation +// +// /* +// ** Return true if zName is the extension on one of the shadow tables used +// ** by this module. +// */ +func _rtreeShadowName(tls *libc.TLS, zName uintptr) (r int32) { + var i uint32 + _ = i + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(24)/libc.Uint64FromInt64(8)) { + break + } + if Xsqlite3_stricmp(tls, zName, _azName1[i]) == 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** If any term of pSrc, or any SF_NestedFrom sub-query, is not the same +// ** as pSrcItem but has the same alias as p0, then return true. +// ** Otherwise return false. +// */ +func _sameSrcAlias(tls *libc.TLS, p0 uintptr, pSrc uintptr) (r int32) { + var i int32 + var p1 uintptr + _, _ = i, p1 + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + p1 = pSrc + 8 + uintptr(i)*80 + if p1 == p0 { + goto _1 + } + if (*TSrcItem)(unsafe.Pointer(p0)).FpSTab == (*TSrcItem)(unsafe.Pointer(p1)).FpSTab && 0 == Xsqlite3_stricmp(tls, (*TSrcItem)(unsafe.Pointer(p0)).FzAlias, (*TSrcItem)(unsafe.Pointer(p1)).FzAlias) { + return int32(1) + } + if int32(*(*uint32)(unsafe.Pointer(p1 + 24 + 4))&0x4>>2) != 0 && (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p1 + 72)))).FpSelect)).FselFlags&uint32(SF_NestedFrom) != uint32(0) && _sameSrcAlias(tls, p0, (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p1 + 72)))).FpSelect)).FpSrc) != 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* Reclaim memory used by a StatSample +// */ +func _sampleClear(tls *libc.TLS, db uintptr, p uintptr) { + if (*TStatSample)(unsafe.Pointer(p)).FnRowid != 0 { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 24))) + (*TStatSample)(unsafe.Pointer(p)).FnRowid = uint32(0) + } +} + +// C documentation +// +// /* +// ** Field iChng of the index being scanned has changed. So at this point +// ** p->current contains a sample that reflects the previous row of the +// ** index. The value of anEq[iChng] and subsequent anEq[] elements are +// ** correct at this point. +// */ +func _samplePushPrevious(tls *libc.TLS, p uintptr, iChng int32) { + var i, j, j1 int32 + var pBest uintptr + _, _, _, _ = i, j, j1, pBest + /* Check if any samples from the aBest[] array should be pushed + ** into IndexSample.a[] at this point. */ + i = (*TStatAccum)(unsafe.Pointer(p)).FnCol - int32(2) + for { + if !(i >= iChng) { + break + } + pBest = (*TStatAccum)(unsafe.Pointer(p)).FaBest + uintptr(i)*48 + **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pBest)).FanEq + uintptr(i)*8)) = **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8)) + if (*TStatAccum)(unsafe.Pointer(p)).FnSample < (*TStatAccum)(unsafe.Pointer(p)).FmxSample || _sampleIsBetter(tls, p, pBest, (*TStatAccum)(unsafe.Pointer(p)).Fa+uintptr((*TStatAccum)(unsafe.Pointer(p)).FiMin)*48) != 0 { + _sampleInsert(tls, p, pBest, i) + } + goto _1 + _1: + ; + i = i - 1 + } + /* Check that no sample contains an anEq[] entry with an index of + ** p->nMaxEqZero or greater set to zero. */ + i = (*TStatAccum)(unsafe.Pointer(p)).FnSample - int32(1) + for { + if !(i >= 0) { + break + } + j = (*TStatAccum)(unsafe.Pointer(p)).FnMaxEqZero + for { + if !(j < (*TStatAccum)(unsafe.Pointer(p)).FnCol) { + break + } + goto _3 + _3: + ; + j = j + 1 + } + goto _2 + _2: + ; + i = i - 1 + } + /* Update the anEq[] fields of any samples already collected. */ + if iChng < (*TStatAccum)(unsafe.Pointer(p)).FnMaxEqZero { + i = (*TStatAccum)(unsafe.Pointer(p)).FnSample - int32(1) + for { + if !(i >= 0) { + break + } + j1 = iChng + for { + if !(j1 < (*TStatAccum)(unsafe.Pointer(p)).FnCol) { + break + } + if **(**TtRowcnt)(__ccgo_up((**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48))).FanEq + uintptr(j1)*8)) == uint64(0) { + **(**TtRowcnt)(__ccgo_up((**(**TStatSample)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*48))).FanEq + uintptr(j1)*8)) = **(**TtRowcnt)(__ccgo_up((*TStatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(j1)*8)) + } + goto _5 + _5: + ; + j1 = j1 + 1 + } + goto _4 + _4: + ; + i = i - 1 + } + (*TStatAccum)(unsafe.Pointer(p)).FnMaxEqZero = iChng + } +} + +// C documentation +// +// /* Initialize the INTEGER value of a ROWID. +// */ +func _sampleSetRowidInt64(tls *libc.TLS, db uintptr, p uintptr, iRowid Ti64) { + if (*TStatSample)(unsafe.Pointer(p)).FnRowid != 0 { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 24))) + } + (*TStatSample)(unsafe.Pointer(p)).FnRowid = uint32(0) + *(*Ti64)(unsafe.Pointer(p + 24)) = iRowid +} + +// C documentation +// +// /* +// ** Argument pWith (which may be NULL) points to a linked list of nested +// ** WITH contexts, from inner to outermost. If the table identified by +// ** FROM clause element pItem is really a common-table-expression (CTE) +// ** then return a pointer to the CTE definition for that table. Otherwise +// ** return NULL. +// ** +// ** If a non-NULL value is returned, set *ppContext to point to the With +// ** object that the returned CTE belongs to. +// */ +func _searchWith(tls *libc.TLS, pWith uintptr, pItem uintptr, ppContext uintptr) (r uintptr) { + var i int32 + var p, zName uintptr + _, _, _ = i, p, zName + zName = (*TSrcItem)(unsafe.Pointer(pItem)).FzName + p = pWith + for { + if !(p != 0) { + break + } + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer(p)).FnCte) { + break + } + if _sqlite3StrICmp(tls, zName, (*(*TCte)(unsafe.Pointer(p + 16 + uintptr(i)*48))).FzName) == 0 { + **(**uintptr)(__ccgo_up(ppContext)) = p + return p + 16 + uintptr(i)*48 + } + goto _2 + _2: + ; + i = i + 1 + } + if (*TWith)(unsafe.Pointer(p)).FbView != 0 { + break + } + goto _1 + _1: + ; + p = (*TWith)(unsafe.Pointer(p)).FpOuter + } + return uintptr(0) +} + +func _selectRefLeave(tls *libc.TLS, pWalker uintptr, pSelect uintptr) { + var p, pSrc uintptr + _, _ = p, pSrc + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pSrc = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + if (*TRefSrcList)(unsafe.Pointer(p)).FnExclude != 0 { + **(**Ti64)(__ccgo_up(p + 16)) -= int64((*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) + } +} + +func _selectWindowRewriteSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) { + var p, pSave uintptr + _, _ = p, pSave + p = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pSave = (*TWindowRewrite)(unsafe.Pointer(p)).FpSubSelect + if pSave == pSelect { + return WRC_Continue + } else { + (*TWindowRewrite)(unsafe.Pointer(p)).FpSubSelect = pSelect + _sqlite3WalkSelect(tls, pWalker, pSelect) + (*TWindowRewrite)(unsafe.Pointer(p)).FpSubSelect = pSave + } + return int32(WRC_Prune) +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append a single byte to the buffer. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendByte(tls *libc.TLS, p uintptr, v Tu8, pRc uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if 0 == _sessionBufferGrow(tls, p, int64(1), pRc) { + v2 = p + 8 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr(v1))) = v + } +} + +// C documentation +// +// /* +// ** Append the value passed as the second argument to the buffer passed +// ** as the first. +// ** +// ** This function is a no-op if *pRc is non-zero when it is called. +// ** Otherwise, if an error occurs, *pRc is set to an SQLite error code +// ** before returning. +// */ +func _sessionAppendValue(tls *libc.TLS, p uintptr, pVal uintptr, pRc uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uintptr + var _ /* nByte at bp+8 */ Tsqlite3_int64 + var _ /* rc at bp+0 */ int32 + _ = v1 + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(pRc)) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0 + **(**int32)(__ccgo_up(bp)) = _sessionSerializeValue(tls, uintptr(0), pVal, bp+8) + _sessionBufferGrow(tls, p, **(**Tsqlite3_int64)(__ccgo_up(bp + 8)), bp) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _sessionSerializeValue(tls, (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf), pVal, uintptr(0)) + v1 = p + 8 + *(*int32)(unsafe.Pointer(v1)) = int32(int64(*(*int32)(unsafe.Pointer(v1))) + **(**Tsqlite3_int64)(__ccgo_up(bp + 8))) + } else { + **(**int32)(__ccgo_up(pRc)) = **(**int32)(__ccgo_up(bp)) + } + } +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append a single varint to the buffer. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendVarint(tls *libc.TLS, p uintptr, v int32, pRc uintptr) { + if 0 == _sessionBufferGrow(tls, p, int64(9), pRc) { + **(**int32)(__ccgo_up(p + 8)) += _sessionVarintPut(tls, (*TSessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*TSessionBuffer)(unsafe.Pointer(p)).FnBuf), v) + } +} + +// C documentation +// +// /* +// ** Attempt to apply the change that the iterator passed as the first argument +// ** currently points to to the database. If a conflict is encountered, invoke +// ** the conflict handler callback. +// ** +// ** If argument pbRetry is NULL, then ignore any CHANGESET_DATA conflict. If +// ** one is encountered, update or delete the row with the matching primary key +// ** instead. Or, if pbRetry is not NULL and a CHANGESET_DATA conflict occurs, +// ** invoke the conflict handler. If it returns CHANGESET_REPLACE, set *pbRetry +// ** to true before returning. In this case the caller will invoke this function +// ** again, this time with pbRetry set to NULL. +// ** +// ** If argument pbReplace is NULL and a CHANGESET_CONFLICT conflict is +// ** encountered invoke the conflict handler with CHANGESET_CONSTRAINT instead. +// ** Or, if pbReplace is not NULL, invoke it with CHANGESET_CONFLICT. If such +// ** an invocation returns SQLITE_CHANGESET_REPLACE, set *pbReplace to true +// ** before retrying. In this case the caller attempts to remove the conflicting +// ** row before invoking this function again, this time with pbReplace set +// ** to NULL. +// ** +// ** If any conflict handler returns SQLITE_CHANGESET_ABORT, this function +// ** returns SQLITE_ABORT. Otherwise, if no error occurs, SQLITE_OK is +// ** returned. +// */ +func _sessionApplyOneOp(tls *libc.TLS, pIter uintptr, p uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, pbReplace uintptr, pbRetry uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var abPK, pNew, pOld, v1 uintptr + var bPatchset, i, rc int32 + var _ /* nCol at bp+12 */ int32 + var _ /* op at bp+8 */ int32 + var _ /* pUp at bp+16 */ uintptr + var _ /* zDummy at bp+0 */ uintptr + _, _, _, _, _, _, _ = abPK, bPatchset, i, pNew, pOld, rc, v1 + rc = SQLITE_OK + Xsqlite3changeset_op(tls, pIter, bp, bp+12, bp+8, uintptr(0)) + if **(**int32)(__ccgo_up(bp + 8)) == int32(SQLITE_DELETE) { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 { + v1 = (*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + } else { + v1 = uintptr(0) + } + /* Bind values to the DELETE statement. If conflict handling is required, + ** bind values for all columns and set bound variable (nCol+1) to true. + ** Or, if conflict handling is not required, bind just the PK column + ** values and, if it exists, set (nCol+1) to false. Conflict handling + ** is not required if: + ** + ** * this is a patchset, or + ** * (pbRetry==0), or + ** * all columns of the table are PK columns (in this case there is + ** no (nCol+1) variable to bind to). + */ + abPK = v1 + rc = _sessionBindRow(tls, pIter, __ccgo_fp(Xsqlite3changeset_old), **(**int32)(__ccgo_up(bp + 12)), abPK, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpDelete) + if rc == SQLITE_OK && Xsqlite3_bind_parameter_count(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpDelete) > **(**int32)(__ccgo_up(bp + 12)) { + rc = Xsqlite3_bind_int(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpDelete, **(**int32)(__ccgo_up(bp + 12))+int32(1), libc.BoolInt32(pbRetry == uintptr(0) || abPK != 0)) + } + if rc != SQLITE_OK { + return rc + } + Xsqlite3_step(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpDelete) + rc = Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpDelete) + if rc == SQLITE_OK && Xsqlite3_changes(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).Fdb) == 0 { + rc = _sessionConflictHandler(tls, int32(SQLITE_CHANGESET_DATA), p, pIter, __ccgo_fp_xConflict, pCtx, pbRetry) + } else { + if rc&int32(0xff) == int32(SQLITE_CONSTRAINT) { + rc = _sessionConflictHandler(tls, int32(SQLITE_CHANGESET_CONFLICT), p, pIter, __ccgo_fp_xConflict, pCtx, uintptr(0)) + } + } + } else { + if **(**int32)(__ccgo_up(bp + 8)) == int32(SQLITE_UPDATE) { + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + bPatchset = libc.BoolInt32(pbRetry == uintptr(0) || (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0) + rc = _sessionUpdateFind(tls, pIter, p, bPatchset, bp+16) + /* Bind values to the UPDATE statement. */ + i = 0 + for { + if !(rc == SQLITE_OK && i < **(**int32)(__ccgo_up(bp + 12))) { + break + } + pOld = **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr(i)*8)) + pNew = **(**uintptr)(__ccgo_up((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+i)*8)) + if pOld != 0 && (**(**Tu8)(__ccgo_up((*TSessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 || bPatchset == 0) { + rc = _sessionBindValue(tls, **(**uintptr)(__ccgo_up(bp + 16)), i*int32(2)+int32(2), pOld) + } + if rc == SQLITE_OK && pNew != 0 { + rc = _sessionBindValue(tls, **(**uintptr)(__ccgo_up(bp + 16)), i*int32(2)+int32(1), pNew) + } + goto _2 + _2: + ; + i = i + 1 + } + if rc != SQLITE_OK { + return rc + } + /* Attempt the UPDATE. In the case of a NOTFOUND or DATA conflict, + ** the result will be SQLITE_OK with 0 rows modified. */ + Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 16))) + rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp + 16))) + if rc == SQLITE_OK && Xsqlite3_changes(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).Fdb) == 0 { + /* A NOTFOUND or DATA error. Search the table to see if it contains + ** a row with a matching primary key. If so, this is a DATA conflict. + ** Otherwise, if there is no primary key match, it is a NOTFOUND. */ + rc = _sessionConflictHandler(tls, int32(SQLITE_CHANGESET_DATA), p, pIter, __ccgo_fp_xConflict, pCtx, pbRetry) + } else { + if rc&int32(0xff) == int32(SQLITE_CONSTRAINT) { + /* This is always a CONSTRAINT conflict. */ + rc = _sessionConflictHandler(tls, int32(SQLITE_CHANGESET_CONFLICT), p, pIter, __ccgo_fp_xConflict, pCtx, uintptr(0)) + } + } + } else { + if (*TSessionApplyCtx)(unsafe.Pointer(p)).FbStat1 != 0 { + /* Check if there is a conflicting row. For sqlite_stat1, this needs + ** to be done using a SELECT, as there is no PRIMARY KEY in the + ** database schema to throw an exception if a duplicate is inserted. */ + rc = _sessionSeekToRow(tls, pIter, p) + if rc == int32(SQLITE_ROW) { + rc = int32(SQLITE_CONSTRAINT) + Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpSelect) + } + } + if rc == SQLITE_OK { + rc = _sessionBindRow(tls, pIter, __ccgo_fp(Xsqlite3changeset_new), **(**int32)(__ccgo_up(bp + 12)), uintptr(0), (*TSessionApplyCtx)(unsafe.Pointer(p)).FpInsert) + if rc != SQLITE_OK { + return rc + } + Xsqlite3_step(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpInsert) + rc = Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FpInsert) + } + if rc&int32(0xff) == int32(SQLITE_CONSTRAINT) { + rc = _sessionConflictHandler(tls, int32(SQLITE_CHANGESET_CONFLICT), p, pIter, __ccgo_fp_xConflict, pCtx, pbReplace) + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Serialize a changeset (or patchset) based on all changesets (or patchsets) +// ** added to the changegroup object passed as the first argument. +// ** +// ** If xOutput is not NULL, then the changeset/patchset is returned to the +// ** user via one or more calls to xOutput, as with the other streaming +// ** interfaces. +// ** +// ** Or, if xOutput is NULL, then (*ppOut) is populated with a pointer to a +// ** buffer containing the output changeset before this function returns. In +// ** this case (*pnOut) is set to the size of the output buffer in bytes. It +// ** is the responsibility of the caller to free the output buffer using +// ** sqlite3_free() when it is no longer required. +// ** +// ** If successful, SQLITE_OK is returned. Or, if an error occurs, an SQLite +// ** error code. If an error occurs and xOutput is NULL, (*ppOut) and (*pnOut) +// ** are both set to 0 before returning. +// */ +func _sessionChangegroupOutput(tls *libc.TLS, pGrp uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr, pnOut uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var p, pTab uintptr + var _ /* buf at bp+8 */ TSessionBuffer + var _ /* rc at bp+0 */ int32 + _, _, _ = i, p, pTab + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**TSessionBuffer)(__ccgo_up(bp + 8)) = TSessionBuffer{} + /* Create the serialized output changeset based on the contents of the + ** hash tables attached to the SessionTable objects in list p->pList. + */ + pTab = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && pTab != 0) { + break + } + if (*TSessionTable)(unsafe.Pointer(pTab)).FnEntry == 0 { + goto _1 + } + _sessionAppendTableHdr(tls, bp+8, (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch, pTab, bp) + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnChange) { + break + } + p = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*8)) + for { + if !(p != 0) { + break + } + _sessionAppendByte(tls, bp+8, (*TSessionChange)(unsafe.Pointer(p)).Fop, bp) + _sessionAppendByte(tls, bp+8, (*TSessionChange)(unsafe.Pointer(p)).FbIndirect, bp) + _sessionAppendBlob(tls, bp+8, (*TSessionChange)(unsafe.Pointer(p)).FaRecord, (*TSessionChange)(unsafe.Pointer(p)).FnRecord, bp) + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && __ccgo_fp_xOutput != 0 && (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf >= _sessions_strm_chunk_size { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf) + (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf = 0 + } + goto _3 + _3: + ; + p = (*TSessionChange)(unsafe.Pointer(p)).FpNext + } + goto _2 + _2: + ; + i = i + 1 + } + goto _1 + _1: + ; + pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if __ccgo_fp_xOutput != 0 { + if (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf > 0 { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xOutput})))(tls, pOut, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf) + } + } else { + if ppOut != 0 { + **(**uintptr)(__ccgo_up(ppOut)) = (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf + if pnOut != 0 { + **(**int32)(__ccgo_up(pnOut)) = (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FnBuf + } + (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf = uintptr(0) + } + } + } + Xsqlite3_free(tls, (**(**TSessionBuffer)(__ccgo_up(bp + 8))).FaBuf) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Add all changes in the changeset traversed by the iterator passed as +// ** the first argument to the changegroup hash tables. +// */ +func _sessionChangesetToHash(tls *libc.TLS, pIter uintptr, pGrp uintptr, bRebase int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* aRec at bp+0 */ uintptr + var _ /* nRec at bp+8 */ int32 + _ = rc + rc = SQLITE_OK + (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FbNoDiscard = int32(1) + for int32(SQLITE_ROW) == _sessionChangesetNext(tls, pIter, bp, bp+8, uintptr(0)) { + rc = _sessionOneChangeIterToHash(tls, pGrp, pIter, bRebase) + if rc != SQLITE_OK { + break + } + } + if rc == SQLITE_OK { + rc = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Frc + } + return rc +} + +// C documentation +// +// /* +// ** Free the list of table objects passed as the first argument. The contents +// ** of the changed-rows hash tables are also deleted. +// */ +func _sessionDeleteTable(tls *libc.TLS, pSession uintptr, pList uintptr) { + var i int32 + var p, pNext, pNextChange, pTab uintptr + _, _, _, _, _ = i, p, pNext, pNextChange, pTab + pTab = pList + for { + if !(pTab != 0) { + break + } + pNext = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext + i = 0 + for { + if !(i < (*TSessionTable)(unsafe.Pointer(pTab)).FnChange) { + break + } + p = **(**uintptr)(__ccgo_up((*TSessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*8)) + for { + if !(p != 0) { + break + } + pNextChange = (*TSessionChange)(unsafe.Pointer(p)).FpNext + _sessionFree(tls, pSession, p) + goto _3 + _3: + ; + p = pNextChange + } + goto _2 + _2: + ; + i = i + 1 + } + Xsqlite3_finalize(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FpDfltStmt) + _sessionFree(tls, pSession, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol) /* cast works around VC++ bug */ + _sessionFree(tls, pSession, (*TSessionTable)(unsafe.Pointer(pTab)).FapChange) + _sessionFree(tls, pSession, pTab) + goto _1 + _1: + ; + pTab = pNext + } +} + +// C documentation +// +// /* +// ** Free buffer pFree, which must have been allocated by an earlier +// ** call to sessionMalloc64(). If pSession is not NULL, decrease the +// ** sqlite3_session.nMalloc counter by the number of bytes freed. +// */ +func _sessionFree(tls *libc.TLS, pSession uintptr, pFree uintptr) { + var v1 uintptr + _ = v1 + if pSession != 0 { + v1 = pSession + 56 + *(*Ti64)(unsafe.Pointer(v1)) = Ti64(uint64(*(*Ti64)(unsafe.Pointer(v1))) - Xsqlite3_msize(tls, pFree)) + } + Xsqlite3_free(tls, pFree) +} + +/* +** This macro is used to calculate hash key values for data structures. In +** order to use this macro, the entire data structure must be represented +** as a series of unsigned integers. In order to calculate a hash-key value +** for a data structure represented as three such integers, the macro may +** then be used as follows: +** +** int hash_key_value; +** hash_key_value = HASH_APPEND(0, ); +** hash_key_value = HASH_APPEND(hash_key_value, ); +** hash_key_value = HASH_APPEND(hash_key_value, ); +** +** In practice, the data structures this macro is used for are the primary +** key values of modified rows. + */ + +// C documentation +// +// /* +// ** Ensure that there are at least nByte bytes available in the buffer. Or, +// ** if there are not nByte bytes remaining in the input, that all available +// ** data is in the buffer. +// ** +// ** Return an SQLite error code if an error occurs, or SQLITE_OK otherwise. +// */ +func _sessionInputBuffer(tls *libc.TLS, pIn uintptr, nByte int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* nNew at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + if (*TSessionInput)(unsafe.Pointer(pIn)).FxInput != 0 { + for !((*TSessionInput)(unsafe.Pointer(pIn)).FbEof != 0) && (*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nByte >= (*TSessionInput)(unsafe.Pointer(pIn)).FnData && **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 4)) = _sessions_strm_chunk_size + if (*TSessionInput)(unsafe.Pointer(pIn)).FbNoDiscard == 0 { + _sessionDiscardData(tls, pIn) + } + if SQLITE_OK == _sessionBufferGrow(tls, pIn+32, int64(**(**int32)(__ccgo_up(bp + 4))), bp) { + **(**int32)(__ccgo_up(bp)) = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSessionInput)(unsafe.Pointer(pIn)).FxInput})))(tls, (*TSessionInput)(unsafe.Pointer(pIn)).FpIn, (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf+uintptr((*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf), bp+4) + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + (*TSessionInput)(unsafe.Pointer(pIn)).FbEof = int32(1) + } else { + (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf += **(**int32)(__ccgo_up(bp + 4)) + } + } + (*TSessionInput)(unsafe.Pointer(pIn)).FaData = (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf + (*TSessionInput)(unsafe.Pointer(pIn)).FnData = (*TSessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf + } + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Add the change currently indicated by iterator pIter to the hash table +// ** belonging to changegroup pGrp. +// */ +func _sessionOneChangeIterToHash(tls *libc.TLS, pGrp uintptr, pIter uintptr, bRebase int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aRec uintptr + var nRec, rc int32 + var _ /* bIndirect at bp+16 */ int32 + var _ /* nCol at bp+8 */ int32 + var _ /* op at bp+12 */ int32 + var _ /* pTab at bp+24 */ uintptr + var _ /* zTab at bp+0 */ uintptr + _, _, _ = aRec, nRec, rc + aRec = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FaData + uintptr((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiCurrent+int32(2)) + nRec = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiNext - (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiCurrent - int32(2) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = 0 + **(**int32)(__ccgo_up(bp + 12)) = 0 + **(**int32)(__ccgo_up(bp + 16)) = 0 + rc = SQLITE_OK + **(**uintptr)(__ccgo_up(bp + 24)) = uintptr(0) + /* Ensure that only changesets, or only patchsets, but not a mixture + ** of both, are being combined. It is an error to try to combine a + ** changeset and a patchset. */ + if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList == uintptr(0) { + (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset + } else { + if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch { + rc = int32(SQLITE_ERROR) + } + } + if rc == SQLITE_OK { + Xsqlite3changeset_op(tls, pIter, bp, bp+8, bp+12, bp+16) + rc = _sessionChangesetFindTable(tls, pGrp, **(**uintptr)(__ccgo_up(bp)), pIter, bp+24) + } + if rc == SQLITE_OK { + rc = _sessionOneChangeToHash(tls, pGrp, **(**uintptr)(__ccgo_up(bp + 24)), **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 16)), **(**int32)(__ccgo_up(bp + 8)), aRec, nRec, bRebase) + } + if rc == SQLITE_OK { + rc = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Frc + } + return rc +} + +// C documentation +// +// /* +// ** Set the safety_level and pager flags for pager iDb. Or if iDb<0 +// ** set these values for all pagers. +// */ +func _setAllPagerFlags(tls *libc.TLS, db uintptr) { + var n, v1 int32 + var pDb uintptr + _, _, _ = n, pDb, v1 + if (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0 { + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + n = (*Tsqlite3)(unsafe.Pointer(db)).FnDb + for { + v1 = n + n = n - 1 + if !(v1 > 0) { + break + } + if (*TDb)(unsafe.Pointer(pDb)).FpBt != 0 { + _sqlite3BtreeSetPagerFlags(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, uint32(uint64((*TDb)(unsafe.Pointer(pDb)).Fsafety_level)|(*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(PAGER_FLAGS_MASK))) + } + pDb += 32 + } + } +} + +// C documentation +// +// /* +// ** Generate VDBE code that prepares for doing an operation that +// ** might change the database. +// ** +// ** This routine starts a new transaction if we are not already within +// ** a transaction. If we are already within a transaction, then a checkpoint +// ** is set if the setStatement parameter is true. A checkpoint should +// ** be set for operations that might fail (due to a constraint) part of +// ** the way through and which will need to undo some writes without having to +// ** rollback the whole transaction. For operations where all constraints +// ** can be checked before any changes are made to the database, it is never +// ** necessary to undo a write and the checkpoint should not be set. +// */ +func _sqlite3BeginWriteOperation(tls *libc.TLS, pParse uintptr, setStatement int32, iDb int32) { + var pToplevel, v1 uintptr + _, _ = pToplevel, v1 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + pToplevel = v1 + _sqlite3CodeVerifySchemaAtToplevel(tls, pToplevel, iDb) + **(**TyDbMask)(__ccgo_up(pToplevel + 112)) |= libc.Uint32FromInt32(1) << iDb + v1 = pToplevel + 32 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | setStatement) +} + +// C documentation +// +// /* +// ** Destroy a bitmap object. Reclaim all memory used. +// */ +func _sqlite3BitvecDestroy(tls *libc.TLS, p uintptr) { + var i uint32 + _ = i + if p == uintptr(0) { + return + } + if (*TBitvec)(unsafe.Pointer(p)).FiDivisor != 0 { + i = uint32(0) + for { + if !(i < uint32((libc.Uint64FromInt32(BITVEC_SZ)-libc.Uint64FromInt32(3)*libc.Uint64FromInt64(4))/libc.Uint64FromInt64(8)*libc.Uint64FromInt64(8)/libc.Uint64FromInt64(8))) { + break + } + _sqlite3BitvecDestroy(tls, **(**uintptr)(__ccgo_up(p + 16 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + } + Xsqlite3_free(tls, p) +} + +// C documentation +// +// /* +// ** Run a checkpoint on database iDb. This is a no-op if database iDb is +// ** not currently open in WAL mode. +// ** +// ** If a transaction is open on the database being checkpointed, this +// ** function returns SQLITE_LOCKED and a checkpoint is not attempted. If +// ** an error occurs while running the checkpoint, an SQLite error code is +// ** returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK. +// ** +// ** The mutex on database handle db should be held by the caller. The mutex +// ** associated with the specific b-tree being checkpointed is taken by +// ** this function while the checkpoint is running. +// ** +// ** If iDb is passed SQLITE_MAX_DB then all attached databases are +// ** checkpointed. If an error is encountered it is returned immediately - +// ** no attempt is made to checkpoint any remaining databases. +// ** +// ** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL, RESTART +// ** or TRUNCATE. +// */ +func _sqlite3Checkpoint(tls *libc.TLS, db uintptr, iDb int32, eMode int32, pnLog uintptr, pnCkpt uintptr) (r int32) { + var bBusy, i, rc, v2 int32 + _, _, _, _ = bBusy, i, rc, v2 + rc = SQLITE_OK /* Used to iterate through attached dbs */ + bBusy = 0 /* True if SQLITE_BUSY has been encountered */ + /* See forum post a006d86f72 */ + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb && rc == SQLITE_OK) { + break + } + if i == iDb || iDb == libc.Int32FromInt32(SQLITE_MAX_ATTACHED)+libc.Int32FromInt32(2) { + rc = _sqlite3BtreeCheckpoint(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt, eMode, pnLog, pnCkpt) + pnLog = uintptr(0) + pnCkpt = uintptr(0) + if rc == int32(SQLITE_BUSY) { + bBusy = int32(1) + rc = SQLITE_OK + } + } + goto _1 + _1: + ; + i = i + 1 + } + if rc == SQLITE_OK && bBusy != 0 { + v2 = int32(SQLITE_BUSY) + } else { + v2 = rc + } + return v2 +} + +// C documentation +// +// /* +// ** Call this routine when the database connection is closing in order +// ** to clean up loaded extensions +// */ +func _sqlite3CloseExtensions(tls *libc.TLS, db uintptr) { + var i int32 + _ = i + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnExtension) { + break + } + _sqlite3OsDlClose(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaExtension + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbFree(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaExtension) +} + +// C documentation +// +// /* +// ** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each +// ** attached database. Otherwise, invoke it for the database named zDb only. +// */ +func _sqlite3CodeVerifyNamedSchema(tls *libc.TLS, pParse uintptr, zDb uintptr) { + var db, pDb uintptr + var i int32 + _, _, _ = db, i, pDb + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpBt != 0 && (!(zDb != 0) || 0 == _sqlite3StrICmp(tls, zDb, (*TDb)(unsafe.Pointer(pDb)).FzDbSName)) { + _sqlite3CodeVerifySchema(tls, pParse, i) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Record the fact that the schema cookie will need to be verified +// ** for database iDb. The code to actually verify the schema cookie +// ** will occur at the end of the top-level VDBE and will be generated +// ** later, by sqlite3FinishCoding(). +// */ +func _sqlite3CodeVerifySchemaAtToplevel(tls *libc.TLS, pToplevel uintptr, iDb int32) { + if libc.BoolInt32((*TParse)(unsafe.Pointer(pToplevel)).FcookieMask&(libc.Uint32FromInt32(1)<= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) { + pBuf = p + (*TLookasideSlot)(unsafe.Pointer(pBuf)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = pBuf + return + } + if uint64(p) >= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) { + pBuf1 = p + (*TLookasideSlot)(unsafe.Pointer(pBuf1)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = pBuf1 + return + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed != 0 { + _measureAllocationSize(tls, db, p) + return + } + } + Xsqlite3_free(tls, p) +} + +func _sqlite3DbMallocRawNN(tls *libc.TLS, db uintptr, n Tu64) (r uintptr) { + var pBuf, v1 uintptr + _, _ = pBuf, v1 + if n > uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz) { + if !((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0) { + **(**Tu32)(__ccgo_up(db + 440 + 16 + 1*4)) = **(**Tu32)(__ccgo_up(db + 440 + 16 + 1*4)) + 1 + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return uintptr(0) + } + } + return _dbMallocRawFinish(tls, db, n) + } + if n <= uint64(LOOKASIDE_SMALL) { + v1 = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree + pBuf = v1 + if v1 != uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = (*TLookasideSlot)(unsafe.Pointer(pBuf)).FpNext + **(**Tu32)(__ccgo_up(db + 440 + 16)) = **(**Tu32)(__ccgo_up(db + 440 + 16)) + 1 + return pBuf + } else { + v1 = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit + pBuf = v1 + if v1 != uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = (*TLookasideSlot)(unsafe.Pointer(pBuf)).FpNext + **(**Tu32)(__ccgo_up(db + 440 + 16)) = **(**Tu32)(__ccgo_up(db + 440 + 16)) + 1 + return pBuf + } + } + } + v1 = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree + pBuf = v1 + if v1 != uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = (*TLookasideSlot)(unsafe.Pointer(pBuf)).FpNext + **(**Tu32)(__ccgo_up(db + 440 + 16)) = **(**Tu32)(__ccgo_up(db + 440 + 16)) + 1 + return pBuf + } else { + v1 = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpInit + pBuf = v1 + if v1 != uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = (*TLookasideSlot)(unsafe.Pointer(pBuf)).FpNext + **(**Tu32)(__ccgo_up(db + 440 + 16)) = **(**Tu32)(__ccgo_up(db + 440 + 16)) + 1 + return pBuf + } else { + **(**Tu32)(__ccgo_up(db + 440 + 16 + 2*4)) = **(**Tu32)(__ccgo_up(db + 440 + 16 + 2*4)) + 1 + } + } + return _dbMallocRawFinish(tls, db, n) +} + +func _sqlite3DbNNFreeNN(tls *libc.TLS, db uintptr, p uintptr) { + var pBuf, pBuf1 uintptr + _, _ = pBuf, pBuf1 + if uint64(p) < uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd) { + if uint64(p) >= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) { + pBuf = p + (*TLookasideSlot)(unsafe.Pointer(pBuf)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = pBuf + return + } + if uint64(p) >= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) { + pBuf1 = p + (*TLookasideSlot)(unsafe.Pointer(pBuf1)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = pBuf1 + return + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed != 0 { + _measureAllocationSize(tls, db, p) + return + } + Xsqlite3_free(tls, p) +} + +// C documentation +// +// /* +// ** Return the Btree pointer identified by zDbName. Return NULL if not found. +// */ +func _sqlite3DbNameToBtree(tls *libc.TLS, db uintptr, zDbName uintptr) (r uintptr) { + var iDb, v1 int32 + var v2 uintptr + _, _, _ = iDb, v1, v2 + if zDbName != 0 { + v1 = _sqlite3FindDbName(tls, db, zDbName) + } else { + v1 = 0 + } + iDb = v1 + if iDb < 0 { + v2 = uintptr(0) + } else { + v2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + } + return v2 +} + +// C documentation +// +// /* +// ** Resize the block of memory pointed to by p to n bytes. If the +// ** resize fails, set the mallocFailed flag in the connection object. +// */ +func _sqlite3DbRealloc(tls *libc.TLS, db uintptr, p uintptr, n Tu64) (r uintptr) { + if p == uintptr(0) { + return _sqlite3DbMallocRawNN(tls, db, n) + } + if uint64(p) < uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd) { + if uint64(p) >= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) { + if n <= uint64(LOOKASIDE_SMALL) { + return p + } + } else { + if uint64(p) >= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) { + if n <= uint64((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) { + return p + } + } + } + } + return _dbReallocFinish(tls, db, p, n) +} + +// C documentation +// +// /* +// ** If the Index.aSample variable is not NULL, delete the aSample[] array +// ** and its contents. +// */ +func _sqlite3DeleteIndexSamples(tls *libc.TLS, db uintptr, pIdx uintptr) { + var j int32 + var p uintptr + _, _ = j, p + if (*TIndex)(unsafe.Pointer(pIdx)).FaSample != 0 { + j = 0 + for { + if !(j < (*TIndex)(unsafe.Pointer(pIdx)).FnSample) { + break + } + p = (*TIndex)(unsafe.Pointer(pIdx)).FaSample + uintptr(j)*40 + _sqlite3DbFree(tls, db, (*TIndexSample)(unsafe.Pointer(p)).Fp) + goto _1 + _1: + ; + j = j + 1 + } + _sqlite3DbFree(tls, db, (*TIndex)(unsafe.Pointer(pIdx)).FaSample) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) { + (*TIndex)(unsafe.Pointer(pIdx)).FnSample = 0 + (*TIndex)(unsafe.Pointer(pIdx)).FaSample = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Clean up the data structures associated with the RETURNING clause. +// */ +func _sqlite3DeleteReturning(tls *libc.TLS, db uintptr, pArg uintptr) { + var pHash, pRet uintptr + _, _ = pHash, pRet + pRet = pArg + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 56 + _sqlite3HashInsert(tls, pHash, pRet+188, uintptr(0)) + _sqlite3ExprListDelete(tls, db, (*TReturning)(unsafe.Pointer(pRet)).FpReturnEL) + _sqlite3DbFree(tls, db, pRet) +} + +func _sqlite3DeleteTable(tls *libc.TLS, db uintptr, pTable uintptr) { + var v1 Tu32 + var v2 uintptr + var v3 bool + _, _, _ = v1, v2, v3 + /* Do not delete the table until the reference count reaches zero. */ + if !(pTable != 0) { + return + } + if v3 = (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0); v3 { + v2 = pTable + 44 + *(*Tu32)(unsafe.Pointer(v2)) = *(*Tu32)(unsafe.Pointer(v2)) - 1 + v1 = *(*Tu32)(unsafe.Pointer(v2)) + } + if v3 && v1 > uint32(0) { + return + } + _deleteTable(tls, db, pTable) +} + +// C documentation +// +// /* +// ** Call sqlite3ExprAnalyzeAggregates() for every expression in an +// ** expression list. Return the number of errors. +// ** +// ** If an error is found, the analysis is cut short. +// */ +func _sqlite3ExprAnalyzeAggList(tls *libc.TLS, pNC uintptr, pList uintptr) { + var i int32 + var pItem uintptr + _, _ = i, pItem + if pList != 0 { + pItem = pList + 8 + i = libc.Int32FromInt32(0) + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + _sqlite3ExprAnalyzeAggregates(tls, pNC, (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr) + goto _1 + _1: + ; + i = i + 1 + pItem += 32 + } + } +} + +// C documentation +// +// /* +// ** Analyze the pExpr expression looking for aggregate functions and +// ** for variables that need to be added to AggInfo object that pNC->pAggInfo +// ** points to. Additional entries are made on the AggInfo object as +// ** necessary. +// ** +// ** This routine should only be called after the expression has been +// ** analyzed by sqlite3ResolveExprNames(). +// */ +func _sqlite3ExprAnalyzeAggregates(tls *libc.TLS, pNC uintptr, pExpr uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_analyzeAggregate) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3WalkerDepthIncrease) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = __ccgo_fp(_sqlite3WalkerDepthDecrease) + (**(**TWalker)(__ccgo_up(bp))).FwalkerDepth = 0 + *(*uintptr)(unsafe.Pointer(bp + 40)) = pNC + (**(**TWalker)(__ccgo_up(bp))).FpParse = uintptr(0) + _sqlite3WalkExpr(tls, bp, pExpr) +} + +// C documentation +// +// /* +// ** Expr pIn is an IN(...) expression. This function checks that the +// ** sub-select on the RHS of the IN() operator has the same number of +// ** columns as the vector on the LHS. Or, if the RHS of the IN() is not +// ** a sub-query, that the LHS is a vector of size 1. +// */ +func _sqlite3ExprCheckIN(tls *libc.TLS, pParse uintptr, pIn uintptr) (r int32) { + var nVector int32 + _ = nVector + nVector = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pIn)).FpLeft) + if (*TExpr)(unsafe.Pointer(pIn)).Fflags&uint32(EP_xIsSelect) != uint32(0) && !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { + if nVector != (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIn + 32)))).FpEList)).FnExpr { + _sqlite3SubselectError(tls, pParse, (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIn + 32)))).FpEList)).FnExpr, nVector) + return int32(1) + } + } else { + if nVector != int32(1) { + _sqlite3VectorErrorMsg(tls, pParse, (*TExpr)(unsafe.Pointer(pIn)).FpLeft) + return int32(1) + } + } + return 0 +} + +// C documentation +// +// /* +// ** Generate code that will evaluate expression pExpr and store the +// ** results in register target. The results are guaranteed to appear +// ** in register target. If the expression is constant, then this routine +// ** might choose to code the expression at initialization time. +// */ +func _sqlite3ExprCodeFactorable(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) { + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x80>>7)) != 0 && _sqlite3ExprIsConstantNotJoin(tls, pParse, pExpr) != 0 { + _sqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, target) + } else { + _sqlite3ExprCodeCopy(tls, pParse, pExpr, target) + } +} + +// C documentation +// +// /* Generate code that will load into register regOut a value that is +// ** appropriate for the iIdxCol-th column of index pIdx. +// */ +func _sqlite3ExprCodeLoadIndexColumn(tls *libc.TLS, pParse uintptr, pIdx uintptr, iTabCur int32, iIdxCol int32, regOut int32) { + var iTabCol Ti16 + _ = iTabCol + iTabCol = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iIdxCol)*2)) + if int32(iTabCol) == -int32(2) { + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = iTabCur + int32(1) + _sqlite3ExprCodeCopy(tls, pParse, (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(iIdxCol)*32))).FpExpr, regOut) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 + } else { + _sqlite3ExprCodeGetColumnOfTable(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, (*TIndex)(unsafe.Pointer(pIdx)).FpTable, iTabCur, int32(iTabCol), regOut) + } +} + +func _sqlite3ExprListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pExpr uintptr) (r uintptr) { + var pItem, v2 uintptr + var v1 int32 + _, _, _ = pItem, v1, v2 + if pList == uintptr(0) { + return _sqlite3ExprListAppendNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + } + if (*TExprList)(unsafe.Pointer(pList)).FnAlloc < (*TExprList)(unsafe.Pointer(pList)).FnExpr+int32(1) { + return _sqlite3ExprListAppendGrow(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList, pExpr) + } + v2 = pList + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + pItem = pList + 8 + uintptr(v1)*32 + **(**TExprList_item)(__ccgo_up(pItem)) = _zeroItem + (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr = pExpr + return pList +} + +// C documentation +// +// /* +// ** Return the bitwise-OR of all Expr.flags fields in the given +// ** ExprList. +// */ +func _sqlite3ExprListFlags(tls *libc.TLS, pList uintptr) (r Tu32) { + var i int32 + var m Tu32 + var pExpr uintptr + _, _, _ = i, m, pExpr + m = uint32(0) + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr + m = m | (*TExpr)(unsafe.Pointer(pExpr)).Fflags + goto _1 + _1: + ; + i = i + 1 + } + return m +} + +// C documentation +// +// /* +// ** Set the ExprList.a[].zSpan element of the most recently added item +// ** on the expression list. +// ** +// ** pList might be NULL following an OOM error. But pSpan should never be +// ** NULL. If a memory allocation fails, the pParse->db->mallocFailed flag +// ** is set. +// */ +func _sqlite3ExprListSetSpan(tls *libc.TLS, pParse uintptr, pList uintptr, zStart uintptr, zEnd uintptr) { + var db, pItem uintptr + _, _ = db, pItem + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pList != 0 { + pItem = pList + 8 + uintptr((*TExprList)(unsafe.Pointer(pList)).FnExpr-int32(1))*32 + if (*TExprList_item)(unsafe.Pointer(pItem)).FzEName == uintptr(0) { + (*TExprList_item)(unsafe.Pointer(pItem)).FzEName = _sqlite3DbSpanDup(tls, db, zStart, zEnd) + libc.SetBitFieldPtr16Uint32(pItem+16+4, libc.Uint32FromInt32(ENAME_SPAN), 0, 0x3) + } + } +} + +// C documentation +// +// /* +// ** Locate the in-memory structure that describes +// ** a particular index given the name of that index +// ** and the name of the database that contains the index. +// ** Return NULL if not found. +// ** +// ** If zDatabase is 0, all databases are searched for the +// ** table and the first matching index is returned. (No checking +// ** for duplicate index names is done.) The search order is +// ** TEMP first, then MAIN, then any auxiliary databases added +// ** using the ATTACH command. +// */ +func _sqlite3FindIndex(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr) (r uintptr) { + var i, j, v2 int32 + var p, pSchema uintptr + _, _, _, _, _ = i, j, p, pSchema, v2 + p = uintptr(0) + /* All mutexes are required for schema access. Make sure we hold them. */ + i = OMIT_TEMPDB + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if i < int32(2) { + v2 = i ^ int32(1) + } else { + v2 = i + } + j = v2 /* Search TEMP before MAIN */ + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*32))).FpSchema + if zDb != 0 && _sqlite3DbIsNamed(tls, db, j, zDb) == 0 { + goto _1 + } + p = _sqlite3HashFind(tls, pSchema+32, zName) + if p != 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + return p +} + +// C documentation +// +// /* +// ** Return the latest reusable register in the set of all registers. +// ** The value returned is no less than iMin. If any register iMin or +// ** greater is in permanent use, then return one more than that last +// ** permanent register. +// */ +func _sqlite3FirstAvailableRegister(tls *libc.TLS, pParse uintptr, iMin int32) (r int32) { + var i int32 + var pList uintptr + _, _ = i, pList + pList = (*TParse)(unsafe.Pointer(pParse)).FpConstExpr + if pList != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + if *(*int32)(unsafe.Pointer(pList + 8 + uintptr(i)*32 + 24)) >= iMin { + iMin = *(*int32)(unsafe.Pointer(pList + 8 + uintptr(i)*32 + 24)) + int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + } + (*TParse)(unsafe.Pointer(pParse)).FnTempReg = uint8(0) + (*TParse)(unsafe.Pointer(pParse)).FnRangeReg = 0 + return iMin +} + +/* +** Validate that no temporary register falls within the range of +** iFirst..iLast, inclusive. This routine is only call from within assert() +** statements. + */ + +/************** End of expr.c ************************************************/ +/************** Begin file alter.c *******************************************/ +/* +** 2005 February 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains C code routines that used to generate VDBE code +** that implements the ALTER TABLE command. + */ +/* #include "sqliteInt.h" */ + +/* +** The code in this file only exists if we are not omitting the +** ALTER TABLE logic from the build. + */ + +func _sqlite3FixExpr(tls *libc.TLS, pFix uintptr, pExpr uintptr) (r int32) { + return _sqlite3WalkExpr(tls, pFix+8, pExpr) +} + +// C documentation +// +// /* +// ** Initialize a DbFixer structure. This routine must be called prior +// ** to passing the structure to one of the sqliteFixAAAA() routines below. +// */ +func _sqlite3FixInit(tls *libc.TLS, pFix uintptr, pParse uintptr, iDb int32, zType uintptr, pName uintptr) { + var db uintptr + _ = db + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + (*TDbFixer)(unsafe.Pointer(pFix)).FpParse = pParse + (*TDbFixer)(unsafe.Pointer(pFix)).FzDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + (*TDbFixer)(unsafe.Pointer(pFix)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*TDbFixer)(unsafe.Pointer(pFix)).FzType = zType + (*TDbFixer)(unsafe.Pointer(pFix)).FpName = pName + (*TDbFixer)(unsafe.Pointer(pFix)).FbTemp = libc.BoolUint8(iDb == libc.Int32FromInt32(1)) + (*TDbFixer)(unsafe.Pointer(pFix)).Fw.FpParse = pParse + (*TDbFixer)(unsafe.Pointer(pFix)).Fw.FxExprCallback = __ccgo_fp(_fixExprCb) + (*TDbFixer)(unsafe.Pointer(pFix)).Fw.FxSelectCallback = __ccgo_fp(_fixSelectCb) + (*TDbFixer)(unsafe.Pointer(pFix)).Fw.FxSelectCallback2 = __ccgo_fp(_sqlite3WalkWinDefnDummyCallback) + (*TDbFixer)(unsafe.Pointer(pFix)).Fw.FwalkerDepth = 0 + (*TDbFixer)(unsafe.Pointer(pFix)).Fw.FeCode = uint16(0) + *(*uintptr)(unsafe.Pointer(pFix + 8 + 40)) = pFix +} + +func _sqlite3FixSelect(tls *libc.TLS, pFix uintptr, pSelect uintptr) (r int32) { + return _sqlite3WalkSelect(tls, pFix+8, pSelect) +} + +func _sqlite3FixTriggerStep(tls *libc.TLS, pFix uintptr, pStep uintptr) (r int32) { + var pUp uintptr + _ = pUp + for pStep != 0 { + if _sqlite3WalkSelect(tls, pFix+8, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect) != 0 || _sqlite3WalkExpr(tls, pFix+8, (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere) != 0 || _sqlite3WalkExprList(tls, pFix+8, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList) != 0 || _sqlite3FixSrcList(tls, pFix, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc) != 0 { + return int32(1) + } + pUp = (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert + for { + if !(pUp != 0) { + break + } + if _sqlite3WalkExprList(tls, pFix+8, (*TUpsert)(unsafe.Pointer(pUp)).FpUpsertTarget) != 0 || _sqlite3WalkExpr(tls, pFix+8, (*TUpsert)(unsafe.Pointer(pUp)).FpUpsertTargetWhere) != 0 || _sqlite3WalkExprList(tls, pFix+8, (*TUpsert)(unsafe.Pointer(pUp)).FpUpsertSet) != 0 || _sqlite3WalkExpr(tls, pFix+8, (*TUpsert)(unsafe.Pointer(pUp)).FpUpsertWhere) != 0 { + return int32(1) + } + goto _1 + _1: + ; + pUp = (*TUpsert)(unsafe.Pointer(pUp)).FpNextUpsert + } + pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext + } + return 0 +} + +// C documentation +// +// /* +// ** Free all memory associated with foreign key definitions attached to +// ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash +// ** hash table. +// */ +func _sqlite3FkDelete(tls *libc.TLS, db uintptr, pTab uintptr) { + var pFKey, pNext, z, v2 uintptr + _, _, _, _ = pFKey, pNext, z, v2 /* Copy of pFKey->pNextFrom */ + pFKey = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab + 64))).FpFKey + for { + if !(pFKey != 0) { + break + } + /* Remove the FK from the fkeyHash hash table. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) { + if (*TFKey)(unsafe.Pointer(pFKey)).FpPrevTo != 0 { + (*TFKey)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpPrevTo)).FpNextTo = (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo + } else { + if (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo != 0 { + v2 = (*TFKey)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpNextTo)).FzTo + } else { + v2 = (*TFKey)(unsafe.Pointer(pFKey)).FzTo + } + z = v2 + _sqlite3HashInsert(tls, (*TTable)(unsafe.Pointer(pTab)).FpSchema+80, z, (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo) + } + if (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo != 0 { + (*TFKey)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpNextTo)).FpPrevTo = (*TFKey)(unsafe.Pointer(pFKey)).FpPrevTo + } + } + /* EV: R-30323-21917 Each foreign key constraint in SQLite is + ** classified as either immediate or deferred. + */ + /* Delete any triggers created to implement actions for this FK. */ + _fkTriggerDelete(tls, db, **(**uintptr)(__ccgo_up(pFKey + 48))) + _fkTriggerDelete(tls, db, **(**uintptr)(__ccgo_up(pFKey + 48 + 1*8))) + pNext = (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom + _sqlite3DbFree(tls, db, pFKey) + goto _1 + _1: + ; + pFKey = pNext + } +} + +/************** End of fkey.c ************************************************/ +/************** Begin file insert.c ******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains C code routines that are called by the parser +** to handle INSERT statements in SQLite. + */ +/* #include "sqliteInt.h" */ + +// C documentation +// +// /* +// ** This function returns a linked list of FKey objects (connected by +// ** FKey.pNextTo) holding all children of table pTab. For example, +// ** given the following schema: +// ** +// ** CREATE TABLE t1(a PRIMARY KEY); +// ** CREATE TABLE t2(b REFERENCES t1(a); +// ** +// ** Calling this function with table "t1" as an argument returns a pointer +// ** to the FKey structure representing the foreign key constraint on table +// ** "t2". Calling this function with "t2" as the argument would return a +// ** NULL pointer (as there are no FK constraints for which t2 is the parent +// ** table). +// */ +func _sqlite3FkReferences(tls *libc.TLS, pTab uintptr) (r uintptr) { + return _sqlite3HashFind(tls, (*TTable)(unsafe.Pointer(pTab)).FpSchema+80, (*TTable)(unsafe.Pointer(pTab)).FzName) +} + +// C documentation +// +// /* +// ** Insert a single OP_JournalMode query opcode in order to force the +// ** prepared statement to return false for sqlite3_stmt_readonly(). This +// ** is used by CREATE TABLE IF NOT EXISTS and similar if the table already +// ** exists, so that the prepared statement for CREATE TABLE IF NOT EXISTS +// ** will return false for sqlite3_stmt_readonly() even if that statement +// ** is a read-only no-op. +// */ +func _sqlite3ForceNotReadOnly(tls *libc.TLS, pParse uintptr) { + var iReg, v1 int32 + var v, v2 uintptr + _, _, _, _ = iReg, v, v1, v2 + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + iReg = v1 + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_JournalMode), 0, iReg, -int32(1)) + _sqlite3VdbeUsesBtree(tls, v, 0) + } +} + +// C documentation +// +// /* +// ** Reclaim the memory used by an index +// */ +func _sqlite3FreeIndex(tls *libc.TLS, db uintptr, p uintptr) { + _sqlite3DeleteIndexSamples(tls, db, p) + _sqlite3ExprDelete(tls, db, (*TIndex)(unsafe.Pointer(p)).FpPartIdxWhere) + _sqlite3ExprListDelete(tls, db, (*TIndex)(unsafe.Pointer(p)).FaColExpr) + _sqlite3DbFree(tls, db, (*TIndex)(unsafe.Pointer(p)).FzColAff) + if int32(uint32(*(*uint16)(unsafe.Pointer(p + 100))&0x10>>4)) != 0 { + _sqlite3DbFree(tls, db, (*TIndex)(unsafe.Pointer(p)).FazColl) + } + Xsqlite3_free(tls, (*TIndex)(unsafe.Pointer(p)).FaiRowEst) + _sqlite3DbFree(tls, db, p) +} + +// C documentation +// +// /* +// ** Free the configuration object passed as the only argument. +// */ +func _sqlite3Fts5ConfigFree(tls *libc.TLS, pConfig uintptr) { + var i int32 + _ = i + if pConfig != 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpTok != 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi1 != 0 { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tfts5_tokenizer)(unsafe.Pointer((*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi1)).FxDelete})))(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpTok) + } else { + (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tfts5_tokenizer_v2)(unsafe.Pointer((*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi2)).FxDelete})))(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpTok) + } + } + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FazArg) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName) + i = 0 + for { + if !(i < (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol) { + break + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FazCol) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzRank) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzRankArgs) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzContent) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzContentRowid) + Xsqlite3_free(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).FzContentExprlist) + Xsqlite3_free(tls, pConfig) + } +} + +// C documentation +// +// /* +// ** Clear the token mappings for all Fts5IndexIter objects managed by +// ** the expression passed as the only argument. +// */ +func _sqlite3Fts5ExprClearTokens(tls *libc.TLS, pExpr uintptr) { + var ii int32 + var pT uintptr + _, _ = ii, pT + ii = 0 + for { + if !(ii < (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase) { + break + } + pT = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(ii)*8)) + 32 + for { + if !(pT != 0) { + break + } + _sqlite3Fts5IndexIterClearTokendata(tls, (*TFts5ExprTerm)(unsafe.Pointer(pT)).FpIter) + goto _2 + _2: + ; + pT = (*TFts5ExprTerm)(unsafe.Pointer(pT)).FpSynonym + } + goto _1 + _1: + ; + ii = ii + 1 + } +} + +/* +** 2014 August 11 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** + */ + +/* #include "fts5Int.h" */ + +// C documentation +// +// /* +// ** Does the work of the fts5_api.xInstToken() API method. +// */ +func _sqlite3Fts5ExprInstToken(tls *libc.TLS, pExpr uintptr, iRowid Ti64, iPhrase int32, iCol int32, iOff int32, iToken int32, ppOut uintptr, pnOut uintptr) (r int32) { + var pPhrase, pTerm uintptr + var rc int32 + _, _, _ = pPhrase, pTerm, rc + pPhrase = uintptr(0) + pTerm = uintptr(0) + rc = SQLITE_OK + if iPhrase < 0 || iPhrase >= (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase { + return int32(SQLITE_RANGE) + } + pPhrase = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) + if iToken < 0 || iToken >= (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm { + return int32(SQLITE_RANGE) + } + pTerm = pPhrase + 32 + uintptr(iToken)*40 + if (*TFts5Config)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FbTokendata != 0 || (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FbPrefix != 0 { + rc = _sqlite3Fts5IterToken(tls, (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter, (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpTerm, (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FnQueryTerm, iRowid, iCol, iOff+iToken, ppOut, pnOut) + } else { + **(**uintptr)(__ccgo_up(ppOut)) = (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpTerm + **(**int32)(__ccgo_up(pnOut)) = (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FnFullTerm + } + return rc +} + +// C documentation +// +// /* +// ** This function is only called for detail=columns tables. +// */ +func _sqlite3Fts5ExprPhraseCollist(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppCollist uintptr, pnCollist uintptr) (r int32) { + var pBuf, pNode, pPhrase, pTerm uintptr + var rc int32 + _, _, _, _, _ = pBuf, pNode, pPhrase, pTerm, rc + pPhrase = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) + pNode = (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FpNode + rc = SQLITE_OK + if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 && (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid == (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(pExpr)).FpRoot)).FiRowid && (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn > 0 { + pTerm = pPhrase + 32 + if (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { + pBuf = (*TFts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym + 1*40 + rc = _fts5ExprSynonymList(tls, pTerm, (*TFts5ExprNode)(unsafe.Pointer(pNode)).FiRowid, pBuf, ppCollist, pnCollist) + } else { + **(**uintptr)(__ccgo_up(ppCollist)) = (*TFts5IndexIter)(unsafe.Pointer((*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32))).FpIter)).FpData + **(**int32)(__ccgo_up(pnCollist)) = (*TFts5IndexIter)(unsafe.Pointer((*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32))).FpIter)).FnData + } + } else { + **(**uintptr)(__ccgo_up(ppCollist)) = uintptr(0) + **(**int32)(__ccgo_up(pnCollist)) = 0 + } + return rc +} + +// C documentation +// +// /* +// ** Return the number of terms in the iPhrase'th phrase in pExpr. +// */ +func _sqlite3Fts5ExprPhraseSize(tls *libc.TLS, pExpr uintptr, iPhrase int32) (r int32) { + if iPhrase < 0 || iPhrase >= (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase { + return 0 + } + return (*TFts5ExprPhrase)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)))).FnTerm +} + +func _sqlite3Fts5ExprPopulatePoslists(tls *libc.TLS, pConfig uintptr, pExpr uintptr, aPopulator uintptr, iCol int32, z uintptr, n int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var pColset, pNode uintptr + var _ /* sCtx at bp+0 */ TFts5ExprCtx + _, _, _ = i, pColset, pNode + (**(**TFts5ExprCtx)(__ccgo_up(bp))).FpExpr = pExpr + (**(**TFts5ExprCtx)(__ccgo_up(bp))).FaPopulator = aPopulator + (**(**TFts5ExprCtx)(__ccgo_up(bp))).FiOff = int64(iCol)<= (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase { + return int32(SQLITE_RANGE) + } + pPhrase = **(**uintptr)(__ccgo_up((*TFts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) + if iToken < 0 || iToken >= (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm { + return int32(SQLITE_RANGE) + } + **(**uintptr)(__ccgo_up(ppOut)) = (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32 + uintptr(iToken)*40))).FpTerm + **(**int32)(__ccgo_up(pnOut)) = (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32 + uintptr(iToken)*40))).FnFullTerm + return SQLITE_OK +} + +func _sqlite3Fts5HashScanInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32) (r int32) { + return _fts5HashEntrySort(tls, p, pTerm, nTerm, p+24) +} + +// C documentation +// +// /* +// ** Indicate that all subsequent calls to sqlite3Fts5IndexWrite() pertain +// ** to the document with rowid iRowid. +// */ +func _sqlite3Fts5IndexBeginWrite(tls *libc.TLS, p uintptr, bDelete int32, iRowid Ti64) (r int32) { + /* Allocate the hash table if it has not already been allocated */ + if (*TFts5Index)(unsafe.Pointer(p)).FpHash == uintptr(0) { + (*TFts5Index)(unsafe.Pointer(p)).Frc = _sqlite3Fts5HashNew(tls, (*TFts5Index)(unsafe.Pointer(p)).FpConfig, p+24, p+32) + } + /* Flush the hash table to disk if required */ + if iRowid < (*TFts5Index)(unsafe.Pointer(p)).FiWriteRowid || iRowid == (*TFts5Index)(unsafe.Pointer(p)).FiWriteRowid && (*TFts5Index)(unsafe.Pointer(p)).FbDelete == 0 || (*TFts5Index)(unsafe.Pointer(p)).FnPendingData > (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FnHashSize { + _fts5IndexFlush(tls, p) + } + (*TFts5Index)(unsafe.Pointer(p)).FiWriteRowid = iRowid + (*TFts5Index)(unsafe.Pointer(p)).FbDelete = bDelete + if bDelete == 0 { + (*TFts5Index)(unsafe.Pointer(p)).FnPendingRow = (*TFts5Index)(unsafe.Pointer(p)).FnPendingRow + 1 + } + return _fts5IndexReturn(tls, p) +} + +func _sqlite3Fts5IndexOptimize(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iLvl int32 + var pStruct uintptr + var _ /* nRem at bp+8 */ int32 + var _ /* pNew at bp+0 */ uintptr + _, _ = iLvl, pStruct + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _fts5IndexFlush(tls, p) + pStruct = _fts5StructureRead(tls, p) + _fts5StructureInvalidate(tls, p) + if pStruct != 0 { + **(**uintptr)(__ccgo_up(bp)) = _fts5IndexOptimizeStruct(tls, p, pStruct) + } + _fts5StructureRelease(tls, pStruct) + if **(**uintptr)(__ccgo_up(bp)) != 0 { + iLvl = 0 + for { + if !((*(*TFts5StructureLevel)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 32 + uintptr(iLvl)*16))).FnSeg == 0) { + break + } + goto _1 + _1: + ; + iLvl = iLvl + 1 + } + for (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*(*TFts5StructureLevel)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 32 + uintptr(iLvl)*16))).FnSeg > 0 { + **(**int32)(__ccgo_up(bp + 8)) = int32(FTS5_OPT_WORK_UNIT) + _fts5IndexMergeLevel(tls, p, bp, iLvl, bp+8) + } + _fts5StructureWrite(tls, p, **(**uintptr)(__ccgo_up(bp))) + _fts5StructureRelease(tls, **(**uintptr)(__ccgo_up(bp))) + } + return _fts5IndexReturn(tls, p) +} + +// C documentation +// +// /* +// ** This is used by xInstToken() to access the token at offset iOff, column +// ** iCol of row iRowid. The token is returned via output variables *ppOut +// ** and *pnOut. The iterator passed as the first argument must be a tokendata=1 +// ** iterator (pIter->pTokenDataIter!=0). +// ** +// ** pToken/nToken: +// */ +func _sqlite3Fts5IterToken(tls *libc.TLS, pIndexIter uintptr, pToken uintptr, nToken int32, iRowid Ti64, iCol int32, iOff int32, ppOut uintptr, pnOut uintptr) (r int32) { + var aMap, p, pIter, pMap, pT uintptr + var i1, i2, iTest, rc int32 + var iPos Ti64 + _, _, _, _, _, _, _, _, _, _ = aMap, i1, i2, iPos, iTest, p, pIter, pMap, pT, rc + pIter = pIndexIter + pT = (*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter + iPos = int64(iCol)< i1 { + iTest = (i1 + i2) / int32(2) + if (**(**TFts5TokenDataMap)(__ccgo_up(aMap + uintptr(iTest)*24))).FiRowid < iRowid { + i1 = iTest + int32(1) + } else { + if (**(**TFts5TokenDataMap)(__ccgo_up(aMap + uintptr(iTest)*24))).FiRowid > iRowid { + i2 = iTest + } else { + if (**(**TFts5TokenDataMap)(__ccgo_up(aMap + uintptr(iTest)*24))).FiPos < iPos { + if (**(**TFts5TokenDataMap)(__ccgo_up(aMap + uintptr(iTest)*24))).FiPos < 0 { + break + } + i1 = iTest + int32(1) + } else { + if (**(**TFts5TokenDataMap)(__ccgo_up(aMap + uintptr(iTest)*24))).FiPos > iPos { + i2 = iTest + } else { + break + } + } + } + } + } + if i2 > i1 { + if (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg == 0 { + pMap = *(*uintptr)(unsafe.Pointer(pT + 72 + uintptr((**(**TFts5TokenDataMap)(__ccgo_up(aMap + uintptr(iTest)*24))).FiIter)*8)) + **(**uintptr)(__ccgo_up(ppOut)) = (*(*TFts5SegIter)(unsafe.Pointer(pMap + 104))).Fterm.Fp + uintptr(1) + **(**int32)(__ccgo_up(pnOut)) = (*(*TFts5SegIter)(unsafe.Pointer(pMap + 104))).Fterm.Fn - int32(1) + } else { + p = aMap + uintptr(iTest)*24 + **(**uintptr)(__ccgo_up(ppOut)) = (*TFts5TokenDataIter)(unsafe.Pointer(pT)).Fterms.Fp + uintptr((*TFts5TokenDataMap)(unsafe.Pointer(p)).FiIter) + **(**int32)(__ccgo_up(pnOut)) = (**(**TFts5TokenDataMap)(__ccgo_up(aMap + uintptr(iTest)*24))).FnByte + } + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Free the phrase object passed as the second argument. +// */ +func _sqlite3Fts5ParseNearsetFree(tls *libc.TLS, pNear uintptr) { + var i int32 + _ = i + if pNear != 0 { + i = 0 + for { + if !(i < (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { + break + } + _fts5ExprPhraseFree(tls, *(*uintptr)(unsafe.Pointer(pNear + 24 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*TFts5ExprNearset)(unsafe.Pointer(pNear)).FpColset) + Xsqlite3_free(tls, pNear) + } +} + +// C documentation +// +// /* +// ** Free the expression node object passed as the only argument. +// */ +func _sqlite3Fts5ParseNodeFree(tls *libc.TLS, p uintptr) { + var i int32 + _ = i + if p != 0 { + i = 0 + for { + if !(i < (*TFts5ExprNode)(unsafe.Pointer(p)).FnChild) { + break + } + _sqlite3Fts5ParseNodeFree(tls, *(*uintptr)(unsafe.Pointer(p + 48 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3Fts5ParseNearsetFree(tls, (*TFts5ExprNode)(unsafe.Pointer(p)).FpNear) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* +// ** Set the "bFirst" flag on the first token of the phrase passed as the +// ** only argument. +// */ +func _sqlite3Fts5ParseSetCaret(tls *libc.TLS, pPhrase uintptr) { + if pPhrase != 0 && (*TFts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm != 0 { + (*(*TFts5ExprTerm)(unsafe.Pointer(pPhrase + 32))).FbFirst = uint8(1) + } +} + +// C documentation +// +// /* +// ** This function allocates a new parser. +// ** The only argument is a pointer to a function which works like +// ** malloc. +// ** +// ** Inputs: +// ** A pointer to the function used to allocate memory. +// ** +// ** Outputs: +// ** A pointer to a parser. This pointer is used in subsequent calls +// ** to sqlite3Fts5Parser and sqlite3Fts5ParserFree. +// */ +func _sqlite3Fts5ParserAlloc(tls *libc.TLS, __ccgo_fp_mallocProc uintptr) (r uintptr) { + var fts5yypParser uintptr + _ = fts5yypParser + fts5yypParser = (*(*func(*libc.TLS, Tu64) uintptr)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_mallocProc})))(tls, libc.Uint64FromInt64(2432)) + if fts5yypParser != 0 { + _sqlite3Fts5ParserInit(tls, fts5yypParser) + } + return fts5yypParser +} + +// C documentation +// +// /* Initialize a new parser that has already been allocated. +// */ +func _sqlite3Fts5ParserInit(tls *libc.TLS, fts5yypRawParser uintptr) { + var fts5yypParser uintptr + _ = fts5yypParser + fts5yypParser = fts5yypRawParser + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystack = fts5yypParser + 32 + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystack + uintptr(libc.Int32FromInt32(fts5YYSTACKDEPTH)-libc.Int32FromInt32(1))*24 + (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystack + (**(**Tfts5yyStackEntry)(__ccgo_up((*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystack))).Fstateno = uint8(0) + (**(**Tfts5yyStackEntry)(__ccgo_up((*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystack))).Fmajor = uint8(0) +} + +// C documentation +// +// /* +// ** Arrange for subsequent calls to sqlite3Fts5Tokenize() to use the locale +// ** specified by pLocale/nLocale. The buffer indicated by pLocale must remain +// ** valid until after the final call to sqlite3Fts5Tokenize() that will use +// ** the locale. +// */ +func _sqlite3Fts5SetLocale(tls *libc.TLS, pConfig uintptr, zLocale uintptr, nLocale int32) { + var pT uintptr + _ = pT + pT = pConfig + 128 + (*TFts5TokenizerConfig)(unsafe.Pointer(pT)).FpLocale = zLocale + (*TFts5TokenizerConfig)(unsafe.Pointer(pT)).FnLocale = nLocale +} + +// C documentation +// +// /* +// ** Obtain an SQLite statement handle that may be used to read data from the +// ** %_content table. +// */ +func _sqlite3Fts5StorageStmt(tls *libc.TLS, p uintptr, eStmt int32, pp uintptr, pzErrMsg uintptr) (r int32) { + var rc int32 + _ = rc + rc = _fts5StorageGetStmt(tls, p, eStmt, pp, pzErrMsg) + if rc == SQLITE_OK { + **(**uintptr)(__ccgo_up(p + 48 + uintptr(eStmt)*8)) = uintptr(0) + } + return rc +} + +// C documentation +// +// /* +// ** Release an SQLite statement handle obtained via an earlier call to +// ** sqlite3Fts5StorageStmt(). The eStmt parameter passed to this function +// ** must match that passed to the sqlite3Fts5StorageStmt() call. +// */ +func _sqlite3Fts5StorageStmtRelease(tls *libc.TLS, p uintptr, eStmt int32, pStmt uintptr) { + if **(**uintptr)(__ccgo_up(p + 48 + uintptr(eStmt)*8)) == uintptr(0) { + Xsqlite3_reset(tls, pStmt) + **(**uintptr)(__ccgo_up(p + 48 + uintptr(eStmt)*8)) = pStmt + } else { + Xsqlite3_finalize(tls, pStmt) + } +} + +func _sqlite3Fts5TermsetNew(tls *libc.TLS, pp uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* rc at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**uintptr)(__ccgo_up(pp)) = _sqlite3Fts5MallocZero(tls, bp, int64(4096)) + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Search a FuncDefHash for a function with the given name. Return +// ** a pointer to the matching FuncDef if found, or 0 if there is no match. +// */ +func _sqlite3FunctionSearch(tls *libc.TLS, h int32, zFunc uintptr) (r uintptr) { + var p uintptr + _ = p + p = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(h)*8)) + for { + if !(p != 0) { + break + } + if _sqlite3StrICmp(tls, (*TFuncDef)(unsafe.Pointer(p)).FzName, zFunc) == 0 { + return p + } + goto _1 + _1: + ; + p = *(*uintptr)(unsafe.Pointer(p + 64)) + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Return the collating function associated with a function. +// */ +func _sqlite3GetFuncCollSeq(tls *libc.TLS, context uintptr) (r uintptr) { + var pOp uintptr + _ = pOp + pOp = (*TVdbe)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(context)).FpVdbe)).FaOp + uintptr((*Tsqlite3_context)(unsafe.Pointer(context)).FiOp-int32(1))*24 + return *(*uintptr)(unsafe.Pointer(pOp + 16)) +} + +// C documentation +// +// /* +// ** Allocate or deallocate a block of nReg consecutive registers. +// */ +func _sqlite3GetTempRange(tls *libc.TLS, pParse uintptr, nReg int32) (r int32) { + var i, n int32 + _, _ = i, n + if nReg == int32(1) { + return _sqlite3GetTempReg(tls, pParse) + } + i = (*TParse)(unsafe.Pointer(pParse)).FiRangeReg + n = (*TParse)(unsafe.Pointer(pParse)).FnRangeReg + if nReg <= n { + **(**int32)(__ccgo_up(pParse + 48)) += nReg + **(**int32)(__ccgo_up(pParse + 44)) -= nReg + } else { + i = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nReg + } + return i +} + +// C documentation +// +// /* +// ** pTab is a pointer to a Table structure representing a virtual-table. +// ** Return a pointer to the VTable object used by connection db to access +// ** this virtual-table, if one has been created, or NULL otherwise. +// */ +func _sqlite3GetVTable(tls *libc.TLS, db uintptr, pTab uintptr) (r uintptr) { + var pVtab uintptr + _ = pVtab + pVtab = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp + for { + if !(pVtab != 0 && (*TVTable)(unsafe.Pointer(pVtab)).Fdb != db) { + break + } + goto _1 + _1: + ; + pVtab = (*TVTable)(unsafe.Pointer(pVtab)).FpNext + } + return pVtab +} + +// C documentation +// +// /* Insert an element into the hash table pH. The key is pKey +// ** and the data is "data". +// ** +// ** If no element exists with a matching key, then a new +// ** element is created and NULL is returned. +// ** +// ** If another element already exists with the same key, then the +// ** new data replaces the old data and the old data is returned. +// ** The key is not copied in this instance. If a malloc fails, then +// ** the new data is returned and the hash table is unchanged. +// ** +// ** If the "data" parameter to this function is NULL, then the +// ** element corresponding to "key" is removed from the hash table. +// */ +func _sqlite3HashInsert(tls *libc.TLS, pH uintptr, pKey uintptr, data uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var elem, new_elem, old_data, v1 uintptr + var _ /* h at bp+0 */ uint32 + _, _, _, _ = elem, new_elem, old_data, v1 /* New element added to the pH */ + elem = _findElementWithHash(tls, pH, pKey, bp) + if (*THashElem)(unsafe.Pointer(elem)).Fdata != 0 { + old_data = (*THashElem)(unsafe.Pointer(elem)).Fdata + if data == uintptr(0) { + _removeElement(tls, pH, elem) + } else { + (*THashElem)(unsafe.Pointer(elem)).Fdata = data + (*THashElem)(unsafe.Pointer(elem)).FpKey = pKey + } + return old_data + } + if data == uintptr(0) { + return uintptr(0) + } + new_elem = _sqlite3Malloc(tls, uint64(40)) + if new_elem == uintptr(0) { + return data + } + (*THashElem)(unsafe.Pointer(new_elem)).FpKey = pKey + (*THashElem)(unsafe.Pointer(new_elem)).Fh = **(**uint32)(__ccgo_up(bp)) + (*THashElem)(unsafe.Pointer(new_elem)).Fdata = data + (*THash)(unsafe.Pointer(pH)).Fcount = (*THash)(unsafe.Pointer(pH)).Fcount + 1 + if (*THash)(unsafe.Pointer(pH)).Fcount >= uint32(5) && (*THash)(unsafe.Pointer(pH)).Fcount > uint32(2)*(*THash)(unsafe.Pointer(pH)).Fhtsize { + _rehash(tls, pH, (*THash)(unsafe.Pointer(pH)).Fcount*uint32(3)) + } + if (*THash)(unsafe.Pointer(pH)).Fht != 0 { + v1 = (*THash)(unsafe.Pointer(pH)).Fht + uintptr((*THashElem)(unsafe.Pointer(new_elem)).Fh%(*THash)(unsafe.Pointer(pH)).Fhtsize)*16 + } else { + v1 = uintptr(0) + } + _insertElement(tls, pH, v1, new_elem) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Delete an IdList. +// */ +func _sqlite3IdListDelete(tls *libc.TLS, db uintptr, pList uintptr) { + var i int32 + _ = i + if pList == uintptr(0) { + return + } + i = 0 + for { + if !(i < (*TIdList)(unsafe.Pointer(pList)).FnId) { + break + } + _sqlite3DbFree(tls, db, (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*8))).FzName) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbNNFreeNN(tls, db, pList) +} + +// C documentation +// +// /* +// ** Return the index in pList of the identifier named zId. Return -1 +// ** if not found. +// */ +func _sqlite3IdListIndex(tls *libc.TLS, pList uintptr, zName uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < (*TIdList)(unsafe.Pointer(pList)).FnId) { + break + } + if _sqlite3StrICmp(tls, (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*8))).FzName, zName) == 0 { + return i + } + goto _1 + _1: + ; + i = i + 1 + } + return -int32(1) +} + +/* +** Maximum size of a SrcList object. +** The SrcList object is used to represent the FROM clause of a +** SELECT statement, and the query planner cannot deal with more +** than 64 tables in a join. So any value larger than 64 here +** is sufficient for most uses. Smaller values, like say 10, are +** appropriate for small and memory-limited applications. + */ + +// C documentation +// +// /* +// ** Return the number of bytes required to store a JournalFile that uses vfs +// ** pVfs to create the underlying on-disk files. +// */ +func _sqlite3JournalSize(tls *libc.TLS, pVfs uintptr) (r int32) { + var v1 int32 + _ = v1 + if (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile > libc.Int32FromInt64(80) { + v1 = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile + } else { + v1 = libc.Int32FromInt64(80) + } + return v1 +} + +/************** End of memjournal.c ******************************************/ +/************** Begin file walker.c ******************************************/ +/* +** 2008 August 16 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains routines used for walking the parser tree for +** an SQL statement. + */ +/* #include "sqliteInt.h" */ +/* #include */ +/* #include */ + +// C documentation +// +// /* +// ** Register the JSON table-valued function named zName and return a +// ** pointer to its Module object. Return NULL if something goes wrong. +// */ +func _sqlite3JsonVtabRegister(tls *libc.TLS, db uintptr, zName uintptr) (r uintptr) { + var i uint32 + _ = i + i = uint32(0) + for { + if !(uint64(i) < libc.Uint64FromInt64(32)/libc.Uint64FromInt64(8)) { + break + } + if _sqlite3StrICmp(tls, _azModule[i], zName) == 0 { + return _sqlite3VtabCreateModule(tls, db, _azModule[i], uintptr(unsafe.Pointer(&_jsonEachModule)), uintptr(0), uintptr(0)) + } + goto _1 + _1: + ; + i = i + 1 + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Given an expression list, generate a KeyInfo structure that records +// ** the collating sequence for each expression in that expression list. +// ** +// ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting +// ** KeyInfo structure is appropriate for initializing a virtual index to +// ** implement that clause. If the ExprList is the result set of a SELECT +// ** then the KeyInfo structure is appropriate for initializing a virtual +// ** index to implement a DISTINCT test. +// ** +// ** Space to hold the KeyInfo structure is obtained from malloc. The calling +// ** function is responsible for seeing that this structure is eventually +// ** freed. +// */ +func _sqlite3KeyInfoFromExprList(tls *libc.TLS, pParse uintptr, pList uintptr, iStart int32, nExtra int32) (r uintptr) { + var db, pInfo, pItem uintptr + var i, nExpr int32 + _, _, _, _, _ = db, i, nExpr, pInfo, pItem + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + nExpr = (*TExprList)(unsafe.Pointer(pList)).FnExpr + pInfo = _sqlite3KeyInfoAlloc(tls, db, nExpr-iStart, nExtra+int32(1)) + if pInfo != 0 { + i = iStart + pItem = pList + 8 + uintptr(iStart)*32 + for { + if !(i < nExpr) { + break + } + *(*uintptr)(unsafe.Pointer(pInfo + 32 + uintptr(i-iStart)*8)) = _sqlite3ExprNNCollSeq(tls, pParse, (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr) + **(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pInfo)).FaSortFlags + uintptr(i-iStart))) = (*TExprList_item)(unsafe.Pointer(pItem)).Ffg.FsortFlags + goto _1 + _1: + ; + i = i + 1 + pItem += 32 + } + } + return pInfo +} + +// C documentation +// +// /* +// ** Locate the table identified by *p. +// ** +// ** This is a wrapper around sqlite3LocateTable(). The difference between +// ** sqlite3LocateTable() and this function is that this function restricts +// ** the search to schema (p->pSchema) if it is not NULL. p->pSchema may be +// ** non-NULL if it is part of a view or trigger program definition. See +// ** sqlite3FixSrcList() for details. +// */ +func _sqlite3LocateTableItem(tls *libc.TLS, pParse uintptr, flags Tu32, p uintptr) (r uintptr) { + var iDb int32 + var zDb uintptr + _, _ = iDb, zDb + if int32(*(*uint32)(unsafe.Pointer(p + 24 + 4))&0x10000>>16) != 0 { + iDb = _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(p + 72))) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + zDb = *(*uintptr)(unsafe.Pointer(p + 72)) + } + return _sqlite3LocateTable(tls, pParse, flags, (*TSrcItem)(unsafe.Pointer(p)).FzName, zDb) +} + +// C documentation +// +// /* +// ** Evaluate a view and store its result in an ephemeral table. The +// ** pWhere argument is an optional WHERE clause that restricts the +// ** set of rows in the view that are to be added to the ephemeral table. +// */ +func _sqlite3MaterializeView(tls *libc.TLS, pParse uintptr, pView uintptr, pWhere uintptr, pOrderBy uintptr, pLimit uintptr, iCur int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var db, pFrom, pSel uintptr + var iDb int32 + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _ = db, iDb, pFrom, pSel + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pView)).FpSchema) + pWhere = _sqlite3ExprDup(tls, db, pWhere, 0) + pFrom = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + if pFrom != 0 { + (*(*TSrcItem)(unsafe.Pointer(pFrom + 8))).FzName = _sqlite3DbStrDup(tls, db, (*TTable)(unsafe.Pointer(pView)).FzName) + *(*uintptr)(unsafe.Pointer(pFrom + 8 + 72)) = _sqlite3DbStrDup(tls, db, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + } + pSel = _sqlite3SelectNew(tls, pParse, uintptr(0), pFrom, pWhere, uintptr(0), uintptr(0), pOrderBy, uint32(SF_IncludeHidden), pLimit) + _sqlite3SelectDestInit(tls, bp, int32(SRT_EphemTab), iCur) + _sqlite3Select(tls, pParse, pSel, bp) + _sqlite3SelectDelete(tls, db, pSel) +} + +/* && !defined(SQLITE_OMIT_SUBQUERY) */ + +// C documentation +// +// /* +// ** The code generator calls this routine if is discovers that it is +// ** possible to abort a statement prior to completion. In order to +// ** perform this abort without corrupting the database, we need to make +// ** sure that the statement is protected by a statement transaction. +// ** +// ** Technically, we only need to set the mayAbort flag if the +// ** isMultiWrite flag was previously set. There is a time dependency +// ** such that the abort must occur after the multiwrite. This makes +// ** some statements involving the REPLACE conflict resolution algorithm +// ** go a little faster. But taking advantage of this time dependency +// ** makes it more difficult to prove that the code is correct (in +// ** particular, it prevents us from writing an effective +// ** implementation of sqlite3AssertMayAbort()) and so we have chosen +// ** to take the safe route and skip the optimization. +// */ +func _sqlite3MayAbort(tls *libc.TLS, pParse uintptr) { + var pToplevel, v1 uintptr + _, _ = pToplevel, v1 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + pToplevel = v1 + libc.SetBitFieldPtr16Uint32(pToplevel+40, libc.Uint32FromInt32(1), 1, 0x2) +} + +// C documentation +// +// /* +// ** Set the iIdx'th entry of array aMem[] to contain integer value val. +// */ +func _sqlite3MemSetArrayInt64(tls *libc.TLS, aMem uintptr, iIdx int32, val Ti64) { + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr(iIdx)*56, val) +} + +// C documentation +// +// /* +// ** If argument pVal is a Select object returned by an sqlite3MultiValues() +// ** that was able to use the co-routine optimization, finish coding the +// ** co-routine. +// */ +func _sqlite3MultiValuesEnd(tls *libc.TLS, pParse uintptr, pVal uintptr) { + var pItem uintptr + _ = pItem + if pVal != 0 && (*TSrcList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pVal)).FpSrc)).FnSrc > 0 { + pItem = (*TSelect)(unsafe.Pointer(pVal)).FpSrc + 8 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { + _sqlite3VdbeEndCoroutine(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FregReturn) + _sqlite3VdbeJumpHere(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FaddrFillSub-int32(1)) + } + } +} + +// C documentation +// +// /* +// ** This function is called during initialization if a static buffer is +// ** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE +// ** verb to sqlite3_config(). Parameter pBuf points to an allocation large +// ** enough to contain 'n' buffers of 'sz' bytes each. +// ** +// ** This routine is called from sqlite3_initialize() and so it is guaranteed +// ** to be serialized already. There is no need for further mutexing. +// */ +func _sqlite3PCacheBufferSetup(tls *libc.TLS, pBuf uintptr, sz int32, n int32) { + var p uintptr + var v1 int32 + _, _ = p, v1 + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_pcache1_g))+80) != 0 { + if pBuf == uintptr(0) { + v1 = libc.Int32FromInt32(0) + n = v1 + sz = v1 + } + if n == 0 { + sz = 0 + } + sz = sz & ^libc.Int32FromInt32(7) + _pcache1_g.FszSlot = sz + v1 = n + _pcache1_g.FnFreeSlot = v1 + _pcache1_g.FnSlot = v1 + if n > int32(90) { + v1 = int32(10) + } else { + v1 = n/int32(10) + int32(1) + } + _pcache1_g.FnReserve = v1 + _pcache1_g.FpStart = pBuf + _pcache1_g.FpFree = uintptr(0) + libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&_pcache1_g))+140, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + p = pBuf + (*TPgFreeslot)(unsafe.Pointer(p)).FpNext = _pcache1_g.FpFree + _pcache1_g.FpFree = p + pBuf = pBuf + uintptr(sz) + } + _pcache1_g.FpEnd = pBuf + } +} + +// C documentation +// +// /* +// ** Return a pointer to the pPager->pBackup variable. The backup module +// ** in backup.c maintains the content of this variable. This module +// ** uses it opaquely as an argument to sqlite3BackupRestart() and +// ** sqlite3BackupUpdate() only. +// */ +func _sqlite3PagerBackupPtr(tls *libc.TLS, pPager uintptr) (r uintptr) { + return pPager + 112 +} + +// C documentation +// +// /* +// ** Parameter eStat must be one of SQLITE_DBSTATUS_CACHE_HIT, _MISS, _WRITE, +// ** or _WRITE+1. The SQLITE_DBSTATUS_CACHE_WRITE+1 case is a translation +// ** of SQLITE_DBSTATUS_CACHE_SPILL. The _SPILL case is not contiguous because +// ** it was added later. +// ** +// ** Before returning, *pnVal is incremented by the +// ** current cache hit or miss count, according to the value of eStat. If the +// ** reset parameter is non-zero, the cache hit or miss count is zeroed before +// ** returning. +// */ +func _sqlite3PagerCacheStat(tls *libc.TLS, pPager uintptr, eStat int32, reset int32, pnVal uintptr) { + eStat = eStat - int32(SQLITE_DBSTATUS_CACHE_HIT) + **(**Tu64)(__ccgo_up(pnVal)) += uint64(**(**Tu32)(__ccgo_up(pPager + 248 + uintptr(eStat)*4))) + if reset != 0 { + **(**Tu32)(__ccgo_up(pPager + 248 + uintptr(eStat)*4)) = uint32(0) + } +} + +// C documentation +// +// /* +// ** Set the busy handler function. +// ** +// ** The pager invokes the busy-handler if sqlite3OsLock() returns +// ** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock, +// ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE +// ** lock. It does *not* invoke the busy handler when upgrading from +// ** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE +// ** (which occurs during hot-journal rollback). Summary: +// ** +// ** Transition | Invokes xBusyHandler +// ** -------------------------------------------------------- +// ** NO_LOCK -> SHARED_LOCK | Yes +// ** SHARED_LOCK -> RESERVED_LOCK | No +// ** SHARED_LOCK -> EXCLUSIVE_LOCK | No +// ** RESERVED_LOCK -> EXCLUSIVE_LOCK | Yes +// ** +// ** If the busy-handler callback returns non-zero, the lock is +// ** retried. If it returns zero, then the SQLITE_BUSY error is +// ** returned to the caller of the pager API function. +// */ +func _sqlite3PagerSetBusyHandler(tls *libc.TLS, pPager uintptr, __ccgo_fp_xBusyHandler uintptr, pBusyHandlerArg uintptr) { + var ap uintptr + _ = ap + (*TPager)(unsafe.Pointer(pPager)).FxBusyHandler = __ccgo_fp_xBusyHandler + (*TPager)(unsafe.Pointer(pPager)).FpBusyHandlerArg = pBusyHandlerArg + ap = pPager + 232 + _sqlite3OsFileControlHint(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_BUSYHANDLER), ap) +} + +// C documentation +// +// /* +// ** Add a new cleanup operation to a Parser. The cleanup should happen when +// ** the parser object is destroyed. But, beware: the cleanup might happen +// ** immediately. +// ** +// ** Use this mechanism for uncommon cleanups. There is a higher setup +// ** cost for this mechanism (an extra malloc), so it should not be used +// ** for common cleanups that happen on most calls. But for less +// ** common cleanups, we save a single NULL-pointer comparison in +// ** sqlite3ParseObjectReset(), which reduces the total CPU cycle count. +// ** +// ** If a memory allocation error occurs, then the cleanup happens immediately. +// ** When either SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the +// ** pParse->earlyCleanup flag is set in that case. Calling code show verify +// ** that test cases exist for which this happens, to guard against possible +// ** use-after-free errors following an OOM. The preferred way to do this is +// ** to immediately follow the call to this routine with: +// ** +// ** testcase( pParse->earlyCleanup ); +// ** +// ** This routine returns a copy of its pPtr input (the third parameter) +// ** except if an early cleanup occurs, in which case it returns NULL. So +// ** another way to check for early cleanup is to check the return value. +// ** Or, stop using the pPtr parameter with this call and use only its +// ** return value thereafter. Something like this: +// ** +// ** pObj = sqlite3ParserAddCleanup(pParse, destructor, pObj); +// */ +func _sqlite3ParserAddCleanup(tls *libc.TLS, pParse uintptr, __ccgo_fp_xCleanup uintptr, pPtr uintptr) (r uintptr) { + var pCleanup uintptr + _ = pCleanup + if _sqlite3FaultSim(tls, int32(300)) != 0 { + pCleanup = uintptr(0) + _sqlite3OomFault(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb) + } else { + pCleanup = _sqlite3DbMallocRaw(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(24)) + } + if pCleanup != 0 { + (*TParseCleanup)(unsafe.Pointer(pCleanup)).FpNext = (*TParse)(unsafe.Pointer(pParse)).FpCleanup + (*TParse)(unsafe.Pointer(pParse)).FpCleanup = pCleanup + (*TParseCleanup)(unsafe.Pointer(pCleanup)).FpPtr = pPtr + (*TParseCleanup)(unsafe.Pointer(pCleanup)).FxCleanup = __ccgo_fp_xCleanup + } else { + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xCleanup})))(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPtr) + pPtr = uintptr(0) + } + return pPtr +} + +// C documentation +// +// /* Initialize a new parser that has already been allocated. +// */ +func _sqlite3ParserInit(tls *libc.TLS, yypRawParser uintptr, pParse uintptr) { + var yypParser uintptr + _ = yypParser + yypParser = yypRawParser + (*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse + (*TyyParser)(unsafe.Pointer(yypParser)).Fyystack = yypParser + 32 + (*TyyParser)(unsafe.Pointer(yypParser)).FyystackEnd = (*TyyParser)(unsafe.Pointer(yypParser)).Fyystack + uintptr(libc.Int32FromInt32(YYSTACKDEPTH)-libc.Int32FromInt32(1))*24 + (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos = (*TyyParser)(unsafe.Pointer(yypParser)).Fyystack + (**(**TyyStackEntry)(__ccgo_up((*TyyParser)(unsafe.Pointer(yypParser)).Fyystack))).Fstateno = uint16(0) + (**(**TyyStackEntry)(__ccgo_up((*TyyParser)(unsafe.Pointer(yypParser)).Fyystack))).Fmajor = uint16(0) +} + +// C documentation +// +// /* +// ** Clear the PGHDR_NEED_SYNC flag from all dirty pages. +// */ +func _sqlite3PcacheClearSyncFlags(tls *libc.TLS, pCache uintptr) { + var p, v2 uintptr + _, _ = p, v2 + p = (*TPCache)(unsafe.Pointer(pCache)).FpDirty + for { + if !(p != 0) { + break + } + v2 = p + 52 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) & ^libc.Int32FromInt32(PGHDR_NEED_SYNC)) + goto _1 + _1: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirtyNext + } + (*TPCache)(unsafe.Pointer(pCache)).FpSynced = (*TPCache)(unsafe.Pointer(pCache)).FpDirtyTail +} + +// C documentation +// +// /* +// ** Clear the PGHDR_NEED_SYNC and PGHDR_WRITEABLE flag from all dirty pages. +// */ +func _sqlite3PcacheClearWritable(tls *libc.TLS, pCache uintptr) { + var p, v2 uintptr + _, _ = p, v2 + p = (*TPCache)(unsafe.Pointer(pCache)).FpDirty + for { + if !(p != 0) { + break + } + v2 = p + 52 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) & ^(libc.Int32FromInt32(PGHDR_NEED_SYNC) | libc.Int32FromInt32(PGHDR_WRITEABLE))) + goto _1 + _1: + ; + p = (*TPgHdr)(unsafe.Pointer(p)).FpDirtyNext + } + (*TPCache)(unsafe.Pointer(pCache)).FpSynced = (*TPCache)(unsafe.Pointer(pCache)).FpDirtyTail +} + +// C documentation +// +// /* +// ** Make sure the page is marked as clean. If it isn't clean already, +// ** make it so. +// */ +func _sqlite3PcacheMakeClean(tls *libc.TLS, p uintptr) { + var v1 uintptr + _ = v1 + _pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_REMOVE)) + v1 = p + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^(libc.Int32FromInt32(PGHDR_DIRTY) | libc.Int32FromInt32(PGHDR_NEED_SYNC) | libc.Int32FromInt32(PGHDR_WRITEABLE))) + v1 = p + 52 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(PGHDR_CLEAN)) + if (*TPgHdr)(unsafe.Pointer(p)).FnRef == 0 { + _pcacheUnpin(tls, p) + } +} + +// C documentation +// +// /* +// ** Return the size in bytes of a PCache object. +// */ +func _sqlite3PcacheSize(tls *libc.TLS) (r int32) { + return int32(80) +} + +// C documentation +// +// /* +// ** Return the PRIMARY KEY index of a table +// */ +func _sqlite3PrimaryKeyIndex(tls *libc.TLS, pTab uintptr) (r uintptr) { + var p uintptr + _ = p + p = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(p != 0 && !(int32(uint32(*(*uint16)(unsafe.Pointer(p + 100))&0x3>>0)) == libc.Int32FromInt32(SQLITE_IDXTYPE_PRIMARYKEY))) { + break + } + goto _1 + _1: + ; + p = (*TIndex)(unsafe.Pointer(p)).FpNext + } + return p +} + +// C documentation +// +// /* +// ** Check for interrupts and invoke progress callback. +// */ +func _sqlite3ProgressCheck(tls *libc.TLS, p uintptr) { + var db, v2 uintptr + var v1 Tu32 + _, _, _ = db, v1, v2 + db = (*TParse)(unsafe.Pointer(p)).Fdb + if libc.AtomicLoadNInt32(db+432, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0 { + (*TParse)(unsafe.Pointer(p)).FnErr = (*TParse)(unsafe.Pointer(p)).FnErr + 1 + (*TParse)(unsafe.Pointer(p)).Frc = int32(SQLITE_INTERRUPT) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != 0 { + if (*TParse)(unsafe.Pointer(p)).Frc == int32(SQLITE_INTERRUPT) { + (*TParse)(unsafe.Pointer(p)).FnProgressSteps = uint32(0) + } else { + v2 = p + 128 + *(*Tu32)(unsafe.Pointer(v2)) = *(*Tu32)(unsafe.Pointer(v2)) + 1 + v1 = *(*Tu32)(unsafe.Pointer(v2)) + if v1 >= (*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps { + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { + (*TParse)(unsafe.Pointer(p)).FnErr = (*TParse)(unsafe.Pointer(p)).FnErr + 1 + (*TParse)(unsafe.Pointer(p)).Frc = int32(SQLITE_INTERRUPT) + } + (*TParse)(unsafe.Pointer(p)).FnProgressSteps = uint32(0) + } + } + } +} + +// C documentation +// +// /* +// ** This routine is a no-op if the database schema is already initialized. +// ** Otherwise, the schema is loaded. An error code is returned. +// */ +func _sqlite3ReadSchema(tls *libc.TLS, pParse uintptr) (r int32) { + var db uintptr + var rc int32 + _, _ = db, rc + rc = SQLITE_OK + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + rc = _sqlite3Init(tls, db, pParse+8) + if rc != SQLITE_OK { + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnoSharedCache != 0 { + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaKnownOk) + } + } + } + return rc +} + +// C documentation +// +// /* Compare a floating point value to an integer. Return true if the two +// ** values are the same within the precision of the floating point value. +// ** +// ** This function assumes that i was obtained by assignment from r1. +// ** +// ** For some versions of GCC on 32-bit machines, if you do the more obvious +// ** comparison of "r1==(double)i" you sometimes get an answer of false even +// ** though the r1 and (double)i values are bit-for-bit the same. +// */ +func _sqlite3RealSameAsInt(tls *libc.TLS, _r1 float64, i Tsqlite3_int64) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*float64)(unsafe.Pointer(bp)) = _r1 + var _ /* r2 at bp+8 */ float64 + **(**float64)(__ccgo_up(bp + 8)) = float64(i) + return libc.BoolInt32(**(**float64)(__ccgo_up(bp)) == float64(0) || libc.Xmemcmp(tls, bp, bp+8, uint64(8)) == 0 && i >= -int64(2251799813685248) && i < int64(2251799813685248)) +} + +// C documentation +// +// /* +// ** The z string points to the first character of a token that is +// ** associated with an error. If db does not already have an error +// ** byte offset recorded, try to compute the error byte offset for +// ** z and set the error byte offset in db. +// */ +func _sqlite3RecordErrorByteOffset(tls *libc.TLS, db uintptr, z uintptr) { + var pParse, zEnd, zText uintptr + _, _, _ = pParse, zEnd, zText + if db == uintptr(0) { + return + } + if (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset != -int32(2) { + return + } + pParse = (*Tsqlite3)(unsafe.Pointer(db)).FpParse + if pParse == uintptr(0) { + return + } + zText = (*TParse)(unsafe.Pointer(pParse)).FzTail + if zText == uintptr(0) { + return + } + zEnd = zText + uintptr(libc.Xstrlen(tls, zText)) + if uint64(z) >= uint64(zText) && uint64(z) < uint64(zEnd) { + (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = int32(int64(z) - int64(zText)) + } +} + +// C documentation +// +// /* +// ** Resolve all names in all expressions of a SELECT and in all +// ** descendants of the SELECT, including compounds off of p->pPrior, +// ** subqueries in expressions, and subqueries used as FROM clause +// ** terms. +// ** +// ** See sqlite3ResolveExprNames() for a description of the kinds of +// ** transformations that occur. +// ** +// ** All SELECT statements should have been expanded using +// ** sqlite3SelectExpand() prior to invoking this routine. +// */ +func _sqlite3ResolveSelectNames(tls *libc.TLS, pParse uintptr, p uintptr, pOuterNC uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_resolveExprStep) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_resolveSelectStep) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + *(*uintptr)(unsafe.Pointer(bp + 40)) = pOuterNC + _sqlite3WalkSelect(tls, bp, p) +} + +// C documentation +// +// /* +// ** If the SELECT references the table pWalker->u.pTab, then do two things: +// ** +// ** (1) Mark the SELECT as as SF_Correlated. +// ** (2) Set pWalker->eCode to non-zero so that the caller will know +// ** that (1) has happened. +// */ +func _sqlite3ReturningSubqueryCorrelated(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) { + var i int32 + var pSrc uintptr + _, _ = i, pSrc + pSrc = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + if (*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*80))).FpSTab == *(*uintptr)(unsafe.Pointer(pWalker + 40)) { + **(**Tu32)(__ccgo_up(pSelect + 4)) |= uint32(SF_Correlated) + (*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(1) + break + } + goto _1 + _1: + ; + i = i + 1 + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** This function is called by the VDBE to adjust the internal schema +// ** used by SQLite when the btree layer moves a table root page. The +// ** root-page of a table or index in database iDb has changed from iFrom +// ** to iTo. +// ** +// ** Ticket #1728: The symbol table might still contain information +// ** on tables and/or indices that are the process of being deleted. +// ** If you are unlucky, one of those deleted indices or tables might +// ** have the same rootpage number as the real table or index that is +// ** being moved. So we cannot stop searching after the first match +// ** because the first match might be for one of the deleted indices +// ** or tables and not the table/index that is actually being moved. +// ** We must continue looping until all tables and indices with +// ** rootpage==iFrom have been converted to have a rootpage of iTo +// ** in order to be certain that we got the right one. +// */ +func _sqlite3RootPageMoved(tls *libc.TLS, db uintptr, iDb int32, iFrom TPgno, iTo TPgno) { + var pDb, pElem, pHash, pIdx, pTab uintptr + _, _, _, _, _ = pDb, pElem, pHash, pIdx, pTab + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + pHash = (*TDb)(unsafe.Pointer(pDb)).FpSchema + 8 + pElem = (*THash)(unsafe.Pointer(pHash)).Ffirst + for { + if !(pElem != 0) { + break + } + pTab = (*THashElem)(unsafe.Pointer(pElem)).Fdata + if (*TTable)(unsafe.Pointer(pTab)).Ftnum == iFrom { + (*TTable)(unsafe.Pointer(pTab)).Ftnum = iTo + } + goto _1 + _1: + ; + pElem = (*THashElem)(unsafe.Pointer(pElem)).Fnext + } + pHash = (*TDb)(unsafe.Pointer(pDb)).FpSchema + 32 + pElem = (*THash)(unsafe.Pointer(pHash)).Ffirst + for { + if !(pElem != 0) { + break + } + pIdx = (*THashElem)(unsafe.Pointer(pElem)).Fdata + if (*TIndex)(unsafe.Pointer(pIdx)).Ftnum == iFrom { + (*TIndex)(unsafe.Pointer(pIdx)).Ftnum = iTo + } + goto _2 + _2: + ; + pElem = (*THashElem)(unsafe.Pointer(pElem)).Fnext + } +} + +// C documentation +// +// /* +// ** Insert a new value into a RowSet. +// ** +// ** The mallocFailed flag of the database connection is set if a +// ** memory allocation fails. +// */ +func _sqlite3RowSetInsert(tls *libc.TLS, p uintptr, rowid Ti64) { + var pEntry, pLast, v1 uintptr + _, _, _ = pEntry, pLast, v1 /* The last prior entry */ + /* This routine is never called after sqlite3RowSetNext() */ + pEntry = _rowSetEntryAlloc(tls, p) + if pEntry == uintptr(0) { + return + } + (*TRowSetEntry)(unsafe.Pointer(pEntry)).Fv = rowid + (*TRowSetEntry)(unsafe.Pointer(pEntry)).FpRight = uintptr(0) + pLast = (*TRowSet)(unsafe.Pointer(p)).FpLast + if pLast != 0 { + if rowid <= (*TRowSetEntry)(unsafe.Pointer(pLast)).Fv { /*OPTIMIZATION-IF-FALSE*/ + /* Avoid unnecessary sorts by preserving the ROWSET_SORTED flags + ** where possible */ + v1 = p + 50 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(ROWSET_SORTED)) + } + (*TRowSetEntry)(unsafe.Pointer(pLast)).FpRight = pEntry + } else { + (*TRowSet)(unsafe.Pointer(p)).FpEntry = pEntry + } + (*TRowSet)(unsafe.Pointer(p)).FpLast = pEntry +} + +// C documentation +// +// /* +// ** Convert a schema pointer into the iDb index that indicates +// ** which database file in db->aDb[] the schema refers to. +// ** +// ** If the same database is attached more than once, the first +// ** attached database is returned. +// */ +func _sqlite3SchemaToIndex(tls *libc.TLS, db uintptr, pSchema uintptr) (r int32) { + var i int32 + _ = i + i = -int32(32768) + /* If pSchema is NULL, then return -32768. This happens when code in + ** expr.c is trying to resolve a reference to a transient table (i.e. one + ** created by a sub-select). In this case the return value of this + ** function should never be used. + ** + ** We return -32768 instead of the more usual -1 simply because using + ** -32768 as the incorrect index into db->aDb[] is much + ** more likely to cause a segfault than -1 (of course there are assert() + ** statements too, but it never hurts to play the odds) and + ** -32768 will still fit into a 16-bit signed integer. + */ + if pSchema != 0 { + i = 0 + for { + if !(int32(1) != 0) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema == pSchema { + break + } + goto _1 + _1: + ; + i = i + 1 + } + } + return i +} + +// C documentation +// +// /* +// ** This routine adds datatype and collating sequence information to +// ** the Table structures of all FROM-clause subqueries in a +// ** SELECT statement. +// ** +// ** Use this routine after name resolution. +// */ +func _sqlite3SelectAddTypeInfo(tls *libc.TLS, pParse uintptr, pSelect uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_sqlite3SelectWalkNoop) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = __ccgo_fp(_selectAddSubqueryTypeInfo) + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_sqlite3ExprWalkNoop) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + _sqlite3WalkSelect(tls, bp, pSelect) +} + +// C documentation +// +// /* +// ** This routine "expands" a SELECT statement and all of its subqueries. +// ** For additional information on what it means to "expand" a SELECT +// ** statement, see the comment on the selectExpand worker callback above. +// ** +// ** Expanding a SELECT statement is the first step in processing a +// ** SELECT statement. The SELECT statement must be expanded before +// ** name resolution is performed. +// ** +// ** If anything goes wrong, an error message is written into pParse. +// ** The calling function can detect the problem by looking at pParse->nErr +// ** and/or pParse->db->mallocFailed. +// */ +func _sqlite3SelectExpand(tls *libc.TLS, pParse uintptr, pSelect uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* w at bp+0 */ TWalker + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_sqlite3ExprWalkNoop) + (**(**TWalker)(__ccgo_up(bp))).FpParse = pParse + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x4>>2)) != 0 { + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_convertCompoundSelectToSubquery) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + _sqlite3WalkSelect(tls, bp, pSelect) + } + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = __ccgo_fp(_selectExpander) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = __ccgo_fp(_sqlite3SelectPopWith) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(0) + _sqlite3WalkSelect(tls, bp, pSelect) +} + +// C documentation +// +// /* +// ** Set the EP_OuterON property on all terms of the given expression. +// ** And set the Expr.w.iJoin to iTable for every term in the +// ** expression. +// ** +// ** The EP_OuterON property is used on terms of an expression to tell +// ** the OUTER JOIN processing logic that this term is part of the +// ** join restriction specified in the ON or USING clause and not a part +// ** of the more general WHERE clause. These terms are moved over to the +// ** WHERE clause during join processing but we need to remember that they +// ** originated in the ON or USING clause. +// ** +// ** The Expr.w.iJoin tells the WHERE clause processing that the +// ** expression depends on table w.iJoin even if that table is not +// ** explicitly mentioned in the expression. That information is needed +// ** for cases like this: +// ** +// ** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5 +// ** +// ** The where clause needs to defer the handling of the t1.x=5 +// ** term until after the t2 loop of the join. In that way, a +// ** NULL t2 row will be inserted whenever t1.x!=5. If we do not +// ** defer the handling of t1.x=5, it will be processed immediately +// ** after the t1 loop and rows with t1.x!=5 will never appear in +// ** the output, which is incorrect. +// */ +func _sqlite3SetJoinExpr(tls *libc.TLS, p uintptr, iTable int32, joinFlag Tu32) { + var i int32 + _ = i + for p != 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= joinFlag + *(*int32)(unsafe.Pointer(p + 52)) = iTable + if (*TExpr)(unsafe.Pointer(p)).Fflags&uint32(EP_xIsSelect) == uint32(0) { + if *(*uintptr)(unsafe.Pointer(p + 32)) != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)))).FnExpr) { + break + } + _sqlite3SetJoinExpr(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32)) + 8 + uintptr(i)*32))).FpExpr, iTable, joinFlag) + goto _1 + _1: + ; + i = i + 1 + } + } + } + _sqlite3SetJoinExpr(tls, (*TExpr)(unsafe.Pointer(p)).FpLeft, iTable, joinFlag) + p = (*TExpr)(unsafe.Pointer(p)).FpRight + } +} + +// C documentation +// +// /* +// ** Mark a subquery result column as having been used. +// */ +func _sqlite3SrcItemColumnUsed(tls *libc.TLS, pItem uintptr, iCol int32) { + var pResults uintptr + _ = pResults + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { + pResults = (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect)).FpEList + libc.SetBitFieldPtr16Uint32(pResults+8+uintptr(iCol)*32+16+4, libc.Uint32FromInt32(1), 6, 0x40) + } +} + +// C documentation +// +// /* +// ** Assign VdbeCursor index numbers to all tables in a SrcList +// */ +func _sqlite3SrcListAssignCursors(tls *libc.TLS, pParse uintptr, pList uintptr) { + var i, v2 int32 + var pItem, v3 uintptr + _, _, _, _ = i, pItem, v2, v3 + if pList != 0 { + i = 0 + pItem = pList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pList)).FnSrc) { + break + } + if (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor >= 0 { + goto _1 + } + v3 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor = v2 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { + _sqlite3SrcListAssignCursors(tls, pParse, (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect)).FpSrc) + } + goto _1 + _1: + ; + i = i + 1 + pItem += 80 + } + } +} + +// C documentation +// +// /* +// ** Delete an entire SrcList including all its substructure. +// */ +func _sqlite3SrcListDelete(tls *libc.TLS, db uintptr, pList uintptr) { + var i int32 + var pItem uintptr + _, _ = i, pItem + if pList == uintptr(0) { + return + } + pItem = pList + 8 + i = libc.Int32FromInt32(0) + for { + if !(i < (*TSrcList)(unsafe.Pointer(pList)).FnSrc) { + break + } + /* Check invariants on SrcItem */ + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TSrcItem)(unsafe.Pointer(pItem)).FzName) + } + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { + _sqlite3SubqueryDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 72))) + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) == 0 && *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { + _sqlite3DbNNFreeNN(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 72))) + } + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x2>>1) != 0 { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 48))) + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x8>>3) != 0 { + _sqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 48))) + } + _sqlite3DeleteTable(tls, db, (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab) + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) != 0 { + _sqlite3IdListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 64))) + } else { + if *(*uintptr)(unsafe.Pointer(pItem + 64)) != 0 { + _sqlite3ExprDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 64))) + } + } + goto _1 + _1: + ; + i = i + 1 + pItem += 80 + } + _sqlite3DbNNFreeNN(tls, db, pList) +} + +// C documentation +// +// /* +// ** Add the list of function arguments to the SrcList entry for a +// ** table-valued-function. +// */ +func _sqlite3SrcListFuncArgs(tls *libc.TLS, pParse uintptr, p uintptr, pList uintptr) { + var pItem uintptr + _ = pItem + if p != 0 { + pItem = p + 8 + uintptr((*TSrcList)(unsafe.Pointer(p)).FnSrc-int32(1))*80 + *(*uintptr)(unsafe.Pointer(pItem + 48)) = pList + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 3, 0x8) + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList) + } +} + +// C documentation +// +// /* +// ** Add an INDEXED BY or NOT INDEXED clause to the most recently added +// ** element of the source-list passed as the second argument. +// */ +func _sqlite3SrcListIndexedBy(tls *libc.TLS, pParse uintptr, p uintptr, pIndexedBy uintptr) { + var pItem uintptr + _ = pItem + if p != 0 && (*TToken)(unsafe.Pointer(pIndexedBy)).Fn > uint32(0) { + pItem = p + 8 + uintptr((*TSrcList)(unsafe.Pointer(p)).FnSrc-int32(1))*80 + if (*TToken)(unsafe.Pointer(pIndexedBy)).Fn == uint32(1) && !((*TToken)(unsafe.Pointer(pIndexedBy)).Fz != 0) { + /* A "NOT INDEXED" clause was supplied. See parse.y + ** construct "indexed_opt" for details. */ + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 0, 0x1) + } else { + *(*uintptr)(unsafe.Pointer(pItem + 48)) = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pIndexedBy) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 1, 0x2) + /* No collision on union u2 */ + } + } +} + +// C documentation +// +// /* +// ** While a SrcList can in general represent multiple tables and subqueries +// ** (as in the FROM clause of a SELECT statement) in this case it contains +// ** the name of a single table, as one might find in an INSERT, DELETE, +// ** or UPDATE statement. Look up that table in the symbol table and +// ** return a pointer. Set an error message and return NULL if the table +// ** name is not found or if any other error occurs. +// ** +// ** The following fields are initialized appropriate in pSrc: +// ** +// ** pSrc->a[0].spTab Pointer to the Table object +// ** pSrc->a[0].u2.pIBIndex Pointer to the INDEXED BY index, if there is one +// ** +// */ +func _sqlite3SrcListLookup(tls *libc.TLS, pParse uintptr, pSrc uintptr) (r uintptr) { + var pItem, pTab uintptr + _, _ = pItem, pTab + pItem = pSrc + 8 + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pItem) + if (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab != 0 { + _sqlite3DeleteTable(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab) + } + (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab = pTab + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 10, 0x400) + if pTab != 0 { + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x2>>1) != 0 && _sqlite3IndexedByLookup(tls, pParse, pItem) != 0 { + pTab = uintptr(0) + } + } + return pTab +} + +func _sqlite3StatusDown(tls *libc.TLS, op int32, N int32) { + **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + uintptr(op)*8)) -= int64(N) +} + +// C documentation +// +// /* +// ** Adjust the highwater mark if necessary. +// ** The caller must hold the appropriate mutex. +// */ +func _sqlite3StatusHighwater(tls *libc.TLS, op int32, X int32) { + var newValue Tsqlite3StatValueType + _ = newValue + newValue = int64(X) + if newValue > **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + 80 + uintptr(op)*8)) { + **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + 80 + uintptr(op)*8)) = newValue + } +} + +// C documentation +// +// /* +// ** Add N to the value of a status record. The caller must hold the +// ** appropriate mutex. (Locking is checked by assert()). +// ** +// ** The StatusUp() routine can accept positive or negative values for N. +// ** The value of N is added to the current status value and the high-water +// ** mark is adjusted if necessary. +// ** +// ** The StatusDown() routine lowers the current value by N. The highwater +// ** mark is unchanged. N must be non-negative for StatusDown(). +// */ +func _sqlite3StatusUp(tls *libc.TLS, op int32, N int32) { + **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + uintptr(op)*8)) += int64(N) + if **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + uintptr(op)*8)) > **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + 80 + uintptr(op)*8)) { + **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + 80 + uintptr(op)*8)) = **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + uintptr(op)*8)) + } +} + +// C documentation +// +// /* +// ** Return the current value of a status parameter. The caller must +// ** be holding the appropriate mutex. +// */ +func _sqlite3StatusValue(tls *libc.TLS, op int32) (r Tsqlite3_int64) { + return **(**Tsqlite3StatValueType)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3Stat)) + uintptr(op)*8)) +} + +// C documentation +// +// /* +// ** Return the current time for a statement. If the current time +// ** is requested more than once within the same run of a single prepared +// ** statement, the exact same time is returned for each invocation regardless +// ** of the amount of time that elapses between invocations. In other words, +// ** the time returned is always the time of the first call. +// */ +func _sqlite3StmtCurrentTime(tls *libc.TLS, p uintptr) (r Tsqlite3_int64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var piTime, v1 uintptr + var rc int32 + var _ /* iTime at bp+0 */ Tsqlite3_int64 + _, _, _ = piTime, rc, v1 + **(**Tsqlite3_int64)(__ccgo_up(bp)) = 0 + if (*Tsqlite3_context)(unsafe.Pointer(p)).FpVdbe != uintptr(0) { + v1 = (*Tsqlite3_context)(unsafe.Pointer(p)).FpVdbe + 72 + } else { + v1 = bp + } + piTime = v1 + if **(**Tsqlite3_int64)(__ccgo_up(piTime)) == 0 { + rc = _sqlite3OsCurrentTimeInt64(tls, (*Tsqlite3)(unsafe.Pointer((*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpOut)).Fdb)).FpVfs, piTime) + if rc != 0 { + **(**Tsqlite3_int64)(__ccgo_up(piTime)) = 0 + } + } + return **(**Tsqlite3_int64)(__ccgo_up(piTime)) +} + +// C documentation +// +// /* +// ** Remove a Subquery from a SrcItem. Return the associated Select object. +// ** The returned Select becomes the responsibility of the caller. +// */ +func _sqlite3SubqueryDetach(tls *libc.TLS, db uintptr, pItem uintptr) (r uintptr) { + var pSel uintptr + _ = pSel + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 72))) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(0), 2, 0x4) + return pSel +} + +func _sqlite3TableLock(tls *libc.TLS, pParse uintptr, iDb int32, iTab TPgno, isWriteLock Tu8, zName uintptr) { + if iDb == int32(1) { + return + } + if !(_sqlite3BtreeSharable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FpBt) != 0) { + return + } + _lockTable(tls, pParse, iDb, iTab, isWriteLock, zName) +} + +// C documentation +// +// /* +// ** Transfer all bindings from the first statement over to the second. +// */ +func _sqlite3TransferBindings(tls *libc.TLS, pFromStmt uintptr, pToStmt uintptr) (r int32) { + var i int32 + var pFrom, pTo uintptr + _, _, _ = i, pFrom, pTo + pFrom = pFromStmt + pTo = pToStmt + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(pTo)).Fdb)).Fmutex) + i = 0 + for { + if !(i < int32((*TVdbe)(unsafe.Pointer(pFrom)).FnVar)) { + break + } + _sqlite3VdbeMemMove(tls, (*TVdbe)(unsafe.Pointer(pTo)).FaVar+uintptr(i)*56, (*TVdbe)(unsafe.Pointer(pFrom)).FaVar+uintptr(i)*56) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(pTo)).Fdb)).Fmutex) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Turn a SELECT statement (that the pSelect parameter points to) into +// ** a trigger step. Return a pointer to a TriggerStep structure. +// ** +// ** The parser calls this routine when it finds a SELECT statement in +// ** body of a TRIGGER. +// */ +func _sqlite3TriggerSelectStep(tls *libc.TLS, db uintptr, pSelect uintptr, zStart uintptr, zEnd uintptr) (r uintptr) { + var pTriggerStep uintptr + _ = pTriggerStep + pTriggerStep = _sqlite3DbMallocZero(tls, db, uint64(88)) + if pTriggerStep == uintptr(0) { + _sqlite3SelectDelete(tls, db, pSelect) + return uintptr(0) + } + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = uint8(TK_SELECT) + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = pSelect + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = uint8(OE_Default) + (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = _triggerSpanDup(tls, db, zStart, zEnd) + return pTriggerStep +} + +func _sqlite3TriggersExist(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32, pChanges uintptr, pMask uintptr) (r uintptr) { + if (*TTable)(unsafe.Pointer(pTab)).FpTrigger == uintptr(0) && !(_tempTriggersExist(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb) != 0) || int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x1>>0)) != 0 { + if pMask != 0 { + **(**int32)(__ccgo_up(pMask)) = 0 + } + return uintptr(0) + } + return _triggersReallyExist(tls, pParse, pTab, op, pChanges, pMask) +} + +// C documentation +// +// /* +// ** For the index called zIdxName which is found in the database iDb, +// ** unlike that index from its Table then remove the index from +// ** the index hash table and free all memory structures associated +// ** with the index. +// */ +func _sqlite3UnlinkAndDeleteIndex(tls *libc.TLS, db uintptr, iDb int32, zIdxName uintptr) { + var p, pHash, pIndex uintptr + _, _, _ = p, pHash, pIndex + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 32 + pIndex = _sqlite3HashInsert(tls, pHash, zIdxName, uintptr(0)) + if pIndex != 0 { + if (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIndex)).FpTable)).FpIndex == pIndex { + (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIndex)).FpTable)).FpIndex = (*TIndex)(unsafe.Pointer(pIndex)).FpNext + } else { + /* Justification of ALWAYS(); The index must be on the list of + ** indices. */ + p = (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIndex)).FpTable)).FpIndex + for p != 0 && (*TIndex)(unsafe.Pointer(p)).FpNext != pIndex { + p = (*TIndex)(unsafe.Pointer(p)).FpNext + } + if p != 0 && (*TIndex)(unsafe.Pointer(p)).FpNext == pIndex { + (*TIndex)(unsafe.Pointer(p)).FpNext = (*TIndex)(unsafe.Pointer(pIndex)).FpNext + } + } + _sqlite3FreeIndex(tls, db, pIndex) + } + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) +} + +// C documentation +// +// /* +// ** Unlink the given table from the hash tables and the delete the +// ** table structure with all its indices and foreign keys. +// */ +func _sqlite3UnlinkAndDeleteTable(tls *libc.TLS, db uintptr, iDb int32, zTabName uintptr) { + var p, pDb uintptr + _, _ = p, pDb + /* Zero-length table names are allowed */ + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + p = _sqlite3HashInsert(tls, (*TDb)(unsafe.Pointer(pDb)).FpSchema+8, zTabName, uintptr(0)) + _sqlite3DeleteTable(tls, db, p) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) +} + +// C documentation +// +// /* +// ** Remove a trigger from the hash tables of the sqlite* pointer. +// */ +func _sqlite3UnlinkAndDeleteTrigger(tls *libc.TLS, db uintptr, iDb int32, zName uintptr) { + var pHash, pTab, pTrigger, pp uintptr + _, _, _, _ = pHash, pTab, pTrigger, pp + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 56 + pTrigger = _sqlite3HashInsert(tls, pHash, zName, uintptr(0)) + if pTrigger != 0 { + if (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema == (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema { + pTab = _tableOfTrigger(tls, pTrigger) + if pTab != 0 { + pp = pTab + 88 + for { + if !(**(**uintptr)(__ccgo_up(pp)) != 0) { + break + } + if **(**uintptr)(__ccgo_up(pp)) == pTrigger { + **(**uintptr)(__ccgo_up(pp)) = (*TTrigger)(unsafe.Pointer(**(**uintptr)(__ccgo_up(pp)))).FpNext + break + } + goto _1 + _1: + ; + pp = **(**uintptr)(__ccgo_up(pp)) + 64 + } + } + } + _sqlite3DeleteTrigger(tls, db, pTrigger) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + } +} + +// C documentation +// +// /* +// ** Create a new Upsert object. +// */ +func _sqlite3UpsertNew(tls *libc.TLS, db uintptr, pTarget uintptr, pTargetWhere uintptr, pSet uintptr, pWhere uintptr, pNext uintptr) (r uintptr) { + var pNew uintptr + _ = pNew + pNew = _sqlite3DbMallocZero(tls, db, uint64(88)) + if pNew == uintptr(0) { + _sqlite3ExprListDelete(tls, db, pTarget) + _sqlite3ExprDelete(tls, db, pTargetWhere) + _sqlite3ExprListDelete(tls, db, pSet) + _sqlite3ExprDelete(tls, db, pWhere) + _sqlite3UpsertDelete(tls, db, pNext) + return uintptr(0) + } else { + (*TUpsert)(unsafe.Pointer(pNew)).FpUpsertTarget = pTarget + (*TUpsert)(unsafe.Pointer(pNew)).FpUpsertTargetWhere = pTargetWhere + (*TUpsert)(unsafe.Pointer(pNew)).FpUpsertSet = pSet + (*TUpsert)(unsafe.Pointer(pNew)).FpUpsertWhere = pWhere + (*TUpsert)(unsafe.Pointer(pNew)).FisDoUpdate = libc.BoolUint8(pSet != uintptr(0)) + (*TUpsert)(unsafe.Pointer(pNew)).FpNextUpsert = pNext + } + return pNew +} + +// C documentation +// +// /* +// ** The VACUUM command is used to clean up the database, +// ** collapse free space, etc. It is modelled after the VACUUM command +// ** in PostgreSQL. The VACUUM command works as follows: +// ** +// ** (1) Create a new transient database file +// ** (2) Copy all content from the database being vacuumed into +// ** the new transient database file +// ** (3) Copy content from the transient database back into the +// ** original database. +// ** +// ** The transient database requires temporary disk space approximately +// ** equal to the size of the original database. The copy operation of +// ** step (3) requires additional temporary disk space approximately equal +// ** to the size of the original database for the rollback journal. +// ** Hence, temporary disk space that is approximately 2x the size of the +// ** original database is required. Every page of the database is written +// ** approximately 3 times: Once for step (2) and twice for step (3). +// ** Two writes per page are required in step (3) because the original +// ** database content must be written into the rollback journal prior to +// ** overwriting the database with the vacuumed content. +// ** +// ** Only 1x temporary space and only 1x writes would be required if +// ** the copy of step (3) were replaced by deleting the original database +// ** and renaming the transient database as the original. But that will +// ** not work if other processes are attached to the original database. +// ** And a power loss in between deleting the original and renaming the +// ** transient would cause the database file to appear to be deleted +// ** following reboot. +// */ +func _sqlite3Vacuum(tls *libc.TLS, pParse uintptr, _pNm uintptr, pInto uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _pNm + var iDb, iIntoReg, v1 int32 + var v, v2 uintptr + _, _, _, _, _ = iDb, iIntoReg, v, v1, v2 + v = _sqlite3GetVdbe(tls, pParse) + iDb = 0 + if v == uintptr(0) { + goto build_vacuum_end + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto build_vacuum_end + } + if **(**uintptr)(__ccgo_up(bp)) != 0 { + /* Default behavior: Report an error if the argument to VACUUM is + ** not recognized */ + iDb = _sqlite3TwoPartName(tls, pParse, **(**uintptr)(__ccgo_up(bp)), **(**uintptr)(__ccgo_up(bp)), bp) + if iDb < 0 { + goto build_vacuum_end + } + } + if iDb != int32(1) { + iIntoReg = 0 + if pInto != 0 && _sqlite3ResolveSelfReference(tls, pParse, uintptr(0), 0, pInto, uintptr(0)) == 0 { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + iIntoReg = v1 + _sqlite3ExprCode(tls, pParse, pInto, iIntoReg) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Vacuum), iDb, iIntoReg) + _sqlite3VdbeUsesBtree(tls, v, iDb) + } + goto build_vacuum_end +build_vacuum_end: + ; + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pInto) + return +} + +// C documentation +// +// /* +// ** Create a new sqlite3_value object. +// */ +func _sqlite3ValueNew(tls *libc.TLS, db uintptr) (r uintptr) { + var p uintptr + _ = p + p = _sqlite3DbMallocZero(tls, db, uint64(56)) + if p != 0 { + (*TMem)(unsafe.Pointer(p)).Fflags = uint16(MEM_Null) + (*TMem)(unsafe.Pointer(p)).Fdb = db + } + return p +} + +// C documentation +// +// /* +// ** Change the P4 operand of the most recently coded instruction +// ** to the value defined by the arguments. This is a high-speed +// ** version of sqlite3VdbeChangeP4(). +// ** +// ** The P4 operand must not have been previously defined. And the new +// ** P4 must not be P4_INT32. Use sqlite3VdbeChangeP4() in either of +// ** those cases. +// */ +func _sqlite3VdbeAppendP4(tls *libc.TLS, p uintptr, pP4 uintptr, n int32) { + var pOp uintptr + _ = pOp + if (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 { + _freeP4(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, n, pP4) + } else { + pOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr((*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1))*24 + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(n) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = pP4 + } +} + +func _sqlite3VdbeChangeP4(tls *libc.TLS, p uintptr, addr int32, _zP4 uintptr, n int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _zP4 + var db, pOp uintptr + _, _ = db, pOp + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + if n != -int32(12) { + _freeP4(tls, db, n, **(**uintptr)(__ccgo_up(bp))) + } + return + } + if addr < 0 { + addr = (*TVdbe)(unsafe.Pointer(p)).FnOp - int32(1) + } + pOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*24 + if n >= 0 || (*TOp)(unsafe.Pointer(pOp)).Fp4type != 0 { + _vdbeChangeP4Full(tls, p, pOp, **(**uintptr)(__ccgo_up(bp)), n) + return + } + if n == -int32(3) { + /* Note: this cast is safe, because the origin data point was an int + ** that was cast to a (const char *). */ + (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi = int32(int64(**(**uintptr)(__ccgo_up(bp)))) + (*TOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(3)) + } else { + if **(**uintptr)(__ccgo_up(bp)) != uintptr(0) { + *(*uintptr)(unsafe.Pointer(pOp + 16)) = **(**uintptr)(__ccgo_up(bp)) + (*TOp)(unsafe.Pointer(pOp)).Fp4type = int8(n) + if n == -int32(12) { + _sqlite3VtabLock(tls, **(**uintptr)(__ccgo_up(bp))) + } + } + } +} + +func _sqlite3VdbeChangeP5(tls *libc.TLS, p uintptr, p5 Tu16) { + if (*TVdbe)(unsafe.Pointer(p)).FnOp > 0 { + (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr((*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1))*24))).Fp5 = p5 + } +} + +// C documentation +// +// /* +// ** Change the opcode at addr into OP_Noop +// */ +func _sqlite3VdbeChangeToNoop(tls *libc.TLS, p uintptr, addr int32) (r int32) { + var pOp uintptr + _ = pOp + if (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 { + return 0 + } + pOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*24 + _freeP4(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, int32((*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type), *(*uintptr)(unsafe.Pointer(pOp + 16))) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = P4_NOTUSED + *(*uintptr)(unsafe.Pointer(pOp + 16)) = uintptr(0) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_Noop) + return int32(1) +} + +// C documentation +// +// /* +// ** Set a flag in the vdbe to update the change counter when it is finalised +// ** or reset. +// */ +func _sqlite3VdbeCountChanges(tls *libc.TLS, v uintptr) { + libc.SetBitFieldPtr16Uint32(v+200, libc.Uint32FromInt32(1), 4, 0x10) +} + +// C documentation +// +// /* +// ** Check to ensure that the cursor is valid. Restore the cursor +// ** if need be. Return any I/O error from the restore operation. +// */ +func _sqlite3VdbeCursorRestore(tls *libc.TLS, p uintptr) (r int32) { + if _sqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(p + 48))) != 0 { + return _sqlite3VdbeHandleMovedCursor(tls, p) + } + return SQLITE_OK +} + +/* +** The following functions: +** +** sqlite3VdbeSerialType() +** sqlite3VdbeSerialTypeLen() +** sqlite3VdbeSerialLen() +** sqlite3VdbeSerialPut() <--- in-lined into OP_MakeRecord as of 2022-04-02 +** sqlite3VdbeSerialGet() +** +** encapsulate the code that serializes values for storage in SQLite +** data and index records. Each serialized value consists of a +** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned +** integer, stored as a varint. +** +** In an SQLite index record, the serial type is stored directly before +** the blob of data that it corresponds to. In a table record, all serial +** types are stored at the start of the record, and the blobs of data at +** the end. Hence these functions allow the caller to handle the +** serial-type and data blob separately. +** +** The following table describes the various storage classes for data: +** +** serial type bytes of data type +** -------------- --------------- --------------- +** 0 0 NULL +** 1 1 signed integer +** 2 2 signed integer +** 3 3 signed integer +** 4 4 signed integer +** 5 6 signed integer +** 6 8 signed integer +** 7 8 IEEE float +** 8 0 Integer constant 0 +** 9 0 Integer constant 1 +** 10,11 reserved for expansion +** N>=12 and even (N-12)/2 BLOB +** N>=13 and odd (N-13)/2 text +** +** The 8 and 9 types were added in 3.3.0, file format 4. Prior versions +** of SQLite will not understand those serial types. + */ + +// C documentation +// +// /* +// ** If SQLite is compiled to support shared-cache mode and to be threadsafe, +// ** this routine obtains the mutex associated with each BtShared structure +// ** that may be accessed by the VM passed as an argument. In doing so it also +// ** sets the BtShared.db member of each of the BtShared structures, ensuring +// ** that the correct busy-handler callback is invoked if required. +// ** +// ** If SQLite is not threadsafe but does support shared-cache mode, then +// ** sqlite3BtreeEnter() is invoked to set the BtShared.db variables +// ** of all of BtShared structures accessible via the database handle +// ** associated with the VM. +// ** +// ** If SQLite is not threadsafe and does not support shared-cache mode, this +// ** function is a no-op. +// ** +// ** The p->btreeMask field is a bitmask of all btrees that the prepared +// ** statement p will ever use. Let N be the number of bits in p->btreeMask +// ** corresponding to btrees that use shared cache. Then the runtime of +// ** this routine is N*N. But as N is rarely more than 1, this should not +// ** be a problem. +// */ +func _sqlite3VdbeEnter(tls *libc.TLS, p uintptr) { + var aDb, db uintptr + var i, nDb int32 + _, _, _, _ = aDb, db, i, nDb + if (*TVdbe)(unsafe.Pointer(p)).FlockMask == uint32(0) { + return + } /* The common case */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + aDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + nDb = (*Tsqlite3)(unsafe.Pointer(db)).FnDb + i = 0 + for { + if !(i < nDb) { + break + } + if i != int32(1) && (*TVdbe)(unsafe.Pointer(p)).FlockMask&(libc.Uint32FromInt32(1)<zMalloc allocation to be at least szNew bytes. +// ** If pMem->zMalloc already meets or exceeds the requested size, this +// ** routine is a no-op. +// ** +// ** Any prior string or blob content in the pMem object may be discarded. +// ** The pMem->xDel destructor is called, if it exists. Though MEM_Str +// ** and MEM_Blob values may be discarded, MEM_Int, MEM_Real, MEM_IntReal, +// ** and MEM_Null values are preserved. +// ** +// ** Return SQLITE_OK on success or an error code (probably SQLITE_NOMEM) +// ** if unable to complete the resizing. +// */ +func _sqlite3VdbeMemClearAndResize(tls *libc.TLS, pMem uintptr, szNew int32) (r int32) { + var v1 uintptr + _ = v1 + if (*TMem)(unsafe.Pointer(pMem)).FszMalloc < szNew { + return _sqlite3VdbeMemGrow(tls, pMem, szNew, 0) + } + (*TMem)(unsafe.Pointer(pMem)).Fz = (*TMem)(unsafe.Pointer(pMem)).FzMalloc + v1 = pMem + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) & (libc.Int32FromInt32(MEM_Null) | libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This routine sets the value to be returned by subsequent calls to +// ** sqlite3_changes() on the database handle 'db'. +// */ +func _sqlite3VdbeSetChanges(tls *libc.TLS, db uintptr, nChange Ti64) { + (*Tsqlite3)(unsafe.Pointer(db)).FnChange = nChange + **(**Ti64)(__ccgo_up(db + 128)) += nChange +} + +// C documentation +// +// /* +// ** Configure SQL variable iVar so that binding a new value to it signals +// ** to sqlite3_reoptimize() that re-preparing the statement may result +// ** in a better query plan. +// */ +func _sqlite3VdbeSetVarmask(tls *libc.TLS, v uintptr, iVar int32) { + if iVar >= int32(32) { + **(**Tu32)(__ccgo_up(v + 284)) |= uint32(0x80000000) + } else { + **(**Tu32)(__ccgo_up(v + 284)) |= libc.Uint32FromInt32(1) << (iVar - libc.Int32FromInt32(1)) + } +} + +// C documentation +// +// /* +// ** Advance to the next element in the sorter. Return value: +// ** +// ** SQLITE_OK success +// ** SQLITE_DONE end of data +// ** otherwise some kind of error. +// */ +func _sqlite3VdbeSorterNext(tls *libc.TLS, db uintptr, pCsr uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pFree, pSorter uintptr + var rc, v1 int32 + var _ /* res at bp+0 */ int32 + _, _, _, _ = pFree, pSorter, rc, v1 /* Return code */ + pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 48)) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA != 0 { + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { + rc = _vdbePmaReaderNext(tls, (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpReader) + if rc == SQLITE_OK && (*TPmaReader)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer(pSorter)).FpReader)).FpFd == uintptr(0) { + rc = int32(SQLITE_DONE) + } + } else { + /*if( !pSorter->bUseThreads )*/ + **(**int32)(__ccgo_up(bp)) = 0 + rc = _vdbeMergeEngineStep(tls, (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpMerger, bp) + if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp)) != 0 { + rc = int32(SQLITE_DONE) + } + } + } else { + pFree = (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList + (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = *(*uintptr)(unsafe.Pointer(pFree + 8)) + *(*uintptr)(unsafe.Pointer(pFree + 8)) = uintptr(0) + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory == uintptr(0) { + _vdbeSorterRecordFree(tls, db, pFree) + } + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { + v1 = SQLITE_OK + } else { + v1 = int32(SQLITE_DONE) + } + rc = v1 + } + return rc +} + +// C documentation +// +// /* +// ** Declare to the Vdbe that the BTree object at db->aDb[i] is used. +// ** +// ** The prepared statements need to know in advance the complete set of +// ** attached databases that will be use. A mask of these databases +// ** is maintained in p->btreeMask. The p->lockMask value is the subset of +// ** p->btreeMask of databases that will require a lock. +// */ +func _sqlite3VdbeUsesBtree(tls *libc.TLS, p uintptr, i int32) { + **(**TyDbMask)(__ccgo_up(p + 204)) |= libc.Uint32FromInt32(1) << i + if i != int32(1) && _sqlite3BtreeSharable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FaDb + uintptr(i)*32))).FpBt) != 0 { + **(**TyDbMask)(__ccgo_up(p + 208)) |= libc.Uint32FromInt32(1) << i + } +} + +// C documentation +// +// /* +// ** If the virtual table pVtab supports the transaction interface +// ** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is +// ** not currently open, invoke the xBegin method now. +// ** +// ** If the xBegin call is successful, place the sqlite3_vtab pointer +// ** in the sqlite3.aVTrans array. +// */ +func _sqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) (r int32) { + var i, iSvpt, rc int32 + var pModule uintptr + _, _, _, _ = i, iSvpt, pModule, rc + rc = SQLITE_OK + /* Special case: If db->aVTrans is NULL and db->nVTrans is greater + ** than zero, then this function is being called from within a + ** virtual module xSync() callback. It is illegal to write to + ** virtual module tables in this case, so return SQLITE_LOCKED. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnVTrans > 0 && (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans == uintptr(0) { + return int32(SQLITE_LOCKED) + } + if !(pVTab != 0) { + return SQLITE_OK + } + pModule = (*Tsqlite3_vtab)(unsafe.Pointer((*TVTable)(unsafe.Pointer(pVTab)).FpVtab)).FpModule + if (*Tsqlite3_module)(unsafe.Pointer(pModule)).FxBegin != 0 { + /* If pVtab is already in the aVTrans array, return early */ + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnVTrans) { + break + } + if **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(i)*8)) == pVTab { + return SQLITE_OK + } + goto _1 + _1: + ; + i = i + 1 + } + /* Invoke the xBegin method. If successful, add the vtab to the + ** sqlite3.aVTrans[] array. */ + rc = _growVTrans(tls, db) + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule)).FxBegin})))(tls, (*TVTable)(unsafe.Pointer(pVTab)).FpVtab) + if rc == SQLITE_OK { + iSvpt = (*Tsqlite3)(unsafe.Pointer(db)).FnStatement + (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + _addToVTrans(tls, db, pVTab) + if iSvpt != 0 && (*Tsqlite3_module)(unsafe.Pointer(pModule)).FxSavepoint != 0 { + (*TVTable)(unsafe.Pointer(pVTab)).FiSavepoint = iSvpt + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule)).FxSavepoint})))(tls, (*TVTable)(unsafe.Pointer(pVTab)).FpVtab, iSvpt-int32(1)) + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** Clear any and all virtual-table information from the Table record. +// ** This routine is called, for example, just before deleting the Table +// ** record. +// ** +// ** Since it is a virtual-table, the Table structure contains a pointer +// ** to the head of a linked list of VTable structures. Each VTable +// ** structure is associated with a single sqlite3* user of the schema. +// ** The reference count of the VTable structure associated with database +// ** connection db is decremented immediately (which may lead to the +// ** structure being xDisconnected and free). Any other VTable structures +// ** in the list are moved to the sqlite3.pDisconnect list of the associated +// ** database connection. +// */ +func _sqlite3VtabClear(tls *libc.TLS, db uintptr, p uintptr) { + var i int32 + _ = i + if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) { + _vtabDisconnectAll(tls, uintptr(0), p) + } + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(p + 64))).FazArg != 0 { + i = 0 + for { + if !(i < (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(p + 64))).FnArg) { + break + } + if i != int32(1) { + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(p + 64))).FazArg + uintptr(i)*8))) + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbFree(tls, db, (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(p + 64))).FazArg) + } +} + +// C documentation +// +// /* +// ** Table *p is a virtual table. This function removes the VTable object +// ** for table *p associated with database connection db from the linked +// ** list in p->pVTab. It also decrements the VTable ref count. This is +// ** used when closing database connection db to free all of its VTable +// ** objects without disturbing the rest of the Schema object (which may +// ** be being used by other shared-cache connections). +// */ +func _sqlite3VtabDisconnect(tls *libc.TLS, db uintptr, p uintptr) { + var pVTab, ppVTab uintptr + _, _ = pVTab, ppVTab + ppVTab = p + 64 + 16 + for { + if !(**(**uintptr)(__ccgo_up(ppVTab)) != 0) { + break + } + if (*TVTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppVTab)))).Fdb == db { + pVTab = **(**uintptr)(__ccgo_up(ppVTab)) + **(**uintptr)(__ccgo_up(ppVTab)) = (*TVTable)(unsafe.Pointer(pVTab)).FpNext + _sqlite3VtabUnlock(tls, pVTab) + break + } + goto _1 + _1: + ; + ppVTab = **(**uintptr)(__ccgo_up(ppVTab)) + 40 + } +} + +// C documentation +// +// /* +// ** Erase the eponymous virtual table instance associated with +// ** virtual table module pMod, if it exists. +// */ +func _sqlite3VtabEponymousTableClear(tls *libc.TLS, db uintptr, pMod uintptr) { + var pTab uintptr + _ = pTab + pTab = (*TModule)(unsafe.Pointer(pMod)).FpEpoTab + if pTab != uintptr(0) { + /* Mark the table as Ephemeral prior to deleting it, so that the + ** sqlite3DeleteTable() routine will know that it is not stored in + ** the schema. */ + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_Ephemeral) + _sqlite3DeleteTable(tls, db, pTab) + (*TModule)(unsafe.Pointer(pMod)).FpEpoTab = uintptr(0) + } +} + +// C documentation +// +// /* +// ** Invoke either the xSavepoint, xRollbackTo or xRelease method of all +// ** virtual tables that currently have an open transaction. Pass iSavepoint +// ** as the second argument to the virtual table method invoked. +// ** +// ** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is +// ** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is +// ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with +// ** an open transaction is invoked. +// ** +// ** If any virtual table method returns an error code other than SQLITE_OK, +// ** processing is abandoned and the error returned to the caller of this +// ** function immediately. If all calls to virtual table methods are successful, +// ** SQLITE_OK is returned. +// */ +func _sqlite3VtabSavepoint(tls *libc.TLS, db uintptr, op int32, iSavepoint int32) (r int32) { + var i, rc int32 + var pMod, pVTab, xMethod uintptr + var savedFlags Tu64 + _, _, _, _, _, _ = i, pMod, pVTab, rc, savedFlags, xMethod + rc = SQLITE_OK + if (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans != 0 { + i = 0 + for { + if !(rc == SQLITE_OK && i < (*Tsqlite3)(unsafe.Pointer(db)).FnVTrans) { + break + } + pVTab = **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(i)*8)) + pMod = (*TModule)(unsafe.Pointer((*TVTable)(unsafe.Pointer(pVTab)).FpMod)).FpModule + if (*TVTable)(unsafe.Pointer(pVTab)).FpVtab != 0 && (*Tsqlite3_module)(unsafe.Pointer(pMod)).FiVersion >= int32(2) { + _sqlite3VtabLock(tls, pVTab) + switch op { + case SAVEPOINT_BEGIN: + xMethod = (*Tsqlite3_module)(unsafe.Pointer(pMod)).FxSavepoint + (*TVTable)(unsafe.Pointer(pVTab)).FiSavepoint = iSavepoint + int32(1) + case int32(SAVEPOINT_ROLLBACK): + xMethod = (*Tsqlite3_module)(unsafe.Pointer(pMod)).FxRollbackTo + default: + xMethod = (*Tsqlite3_module)(unsafe.Pointer(pMod)).FxRelease + break + } + if xMethod != 0 && (*TVTable)(unsafe.Pointer(pVTab)).FiSavepoint > iSavepoint { + savedFlags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_Defensive) + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_Defensive) + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{xMethod})))(tls, (*TVTable)(unsafe.Pointer(pVTab)).FpVtab, iSavepoint) + **(**Tu64)(__ccgo_up(db + 48)) |= savedFlags + } + _sqlite3VtabUnlock(tls, pVTab) + } + goto _1 + _1: + ; + i = i + 1 + } + } + return rc +} + +// C documentation +// +// /* +// ** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans +// ** array. Return the error code for the first error that occurs, or +// ** SQLITE_OK if all xSync operations are successful. +// ** +// ** If an error message is available, leave it in p->zErrMsg. +// */ +func _sqlite3VtabSync(tls *libc.TLS, db uintptr, p uintptr) (r int32) { + var aVTrans, pVtab, x, v2 uintptr + var i, rc int32 + var v3 bool + _, _, _, _, _, _, _ = aVTrans, i, pVtab, rc, x, v2, v3 + rc = SQLITE_OK + aVTrans = (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans + (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans = uintptr(0) + i = 0 + for { + if !(rc == SQLITE_OK && i < (*Tsqlite3)(unsafe.Pointer(db)).FnVTrans) { + break + } + pVtab = (*TVTable)(unsafe.Pointer(**(**uintptr)(__ccgo_up(aVTrans + uintptr(i)*8)))).FpVtab + if v3 = pVtab != 0; v3 { + v2 = (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule)).FxSync + x = v2 + } + if v3 && v2 != uintptr(0) { + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{x})))(tls, pVtab) + _sqlite3VtabImportErrmsg(tls, p, pVtab) + } + goto _1 + _1: + ; + i = i + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans = aVTrans + return rc +} + +// C documentation +// +// /* +// ** This function starts a write transaction on the WAL. +// ** +// ** A read transaction must have already been started by a prior call +// ** to sqlite3WalBeginReadTransaction(). +// ** +// ** If another thread or process has written into the database since +// ** the read transaction was started, then it is not possible for this +// ** thread to write as doing so would cause a fork. So this routine +// ** returns SQLITE_BUSY in that case and no write transaction is started. +// ** +// ** There can only be a single writer active at a time. +// */ +func _sqlite3WalBeginWriteTransaction(tls *libc.TLS, pWal uintptr) (r int32) { + var rc int32 + _ = rc + /* Cannot start a write transaction without first holding a read + ** transaction. */ + if (*TWal)(unsafe.Pointer(pWal)).FreadOnly != 0 { + return int32(SQLITE_READONLY) + } + /* Only one writer allowed at a time. Get the write lock. Return + ** SQLITE_BUSY if unable. + */ + rc = _walLockExclusive(tls, pWal, WAL_WRITE_LOCK, int32(1)) + if rc != 0 { + return rc + } + (*TWal)(unsafe.Pointer(pWal)).FwriteLock = uint8(1) + /* If another connection has written to the database file since the + ** time the read transaction on this connection was started, then + ** the write is disallowed. + */ + if libc.Xmemcmp(tls, pWal+72, _walIndexHdr(tls, pWal), uint64(48)) != 0 { + rc = libc.Int32FromInt32(SQLITE_BUSY) | libc.Int32FromInt32(2)<= int32(int64(pClientData)) { + _sqlite3BeginBenignMalloc(tls) + Xsqlite3_wal_checkpoint(tls, db, zDb) + _sqlite3EndBenignMalloc(tls) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32 +// ** values. This function populates the array with values required to +// ** "rollback" the write position of the WAL handle back to the current +// ** point in the event of a savepoint rollback (via WalSavepointUndo()). +// */ +func _sqlite3WalSavepoint(tls *libc.TLS, pWal uintptr, aWalData uintptr) { + **(**Tu32)(__ccgo_up(aWalData)) = (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + **(**Tu32)(__ccgo_up(aWalData + 1*4)) = **(**Tu32)(__ccgo_up(pWal + 72 + 24)) + **(**Tu32)(__ccgo_up(aWalData + 2*4)) = **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) + **(**Tu32)(__ccgo_up(aWalData + 3*4)) = (*TWal)(unsafe.Pointer(pWal)).FnCkpt +} + +// C documentation +// +// /* +// ** Move the write position of the WAL back to the point identified by +// ** the values in the aWalData[] array. aWalData must point to an array +// ** of WAL_SAVEPOINT_NDATA u32 values that has been previously populated +// ** by a call to WalSavepoint(). +// */ +func _sqlite3WalSavepointUndo(tls *libc.TLS, pWal uintptr, aWalData uintptr) (r int32) { + var rc int32 + _ = rc + rc = SQLITE_OK + if **(**Tu32)(__ccgo_up(aWalData + 3*4)) != (*TWal)(unsafe.Pointer(pWal)).FnCkpt { + /* This savepoint was opened immediately after the write-transaction + ** was started. Right after that, the writer decided to wrap around + ** to the start of the log. Update the savepoint values to match. + */ + **(**Tu32)(__ccgo_up(aWalData)) = uint32(0) + **(**Tu32)(__ccgo_up(aWalData + 3*4)) = (*TWal)(unsafe.Pointer(pWal)).FnCkpt + } + if **(**Tu32)(__ccgo_up(aWalData)) < (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { + (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = **(**Tu32)(__ccgo_up(aWalData)) + **(**Tu32)(__ccgo_up(pWal + 72 + 24)) = **(**Tu32)(__ccgo_up(aWalData + 1*4)) + **(**Tu32)(__ccgo_up(pWal + 72 + 24 + 1*4)) = **(**Tu32)(__ccgo_up(aWalData + 2*4)) + _walCleanupHash(tls, pWal) + if (*TWal)(unsafe.Pointer(pWal)).FiReCksum > (*TWal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { + (*TWal)(unsafe.Pointer(pWal)).FiReCksum = uint32(0) + } + } + return rc +} + +// C documentation +// +// /* +// ** The caller currently has a read transaction open on the database. +// ** This function takes a SHARED lock on the CHECKPOINTER slot and then +// ** checks if the snapshot passed as the second argument is still +// ** available. If so, SQLITE_OK is returned. +// ** +// ** If the snapshot is not available, SQLITE_ERROR is returned. Or, if +// ** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error +// ** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER +// ** lock is released before returning. +// */ +func _sqlite3WalSnapshotCheck(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) (r int32) { + var pNew uintptr + var rc int32 + _, _ = pNew, rc + rc = _walLockShared(tls, pWal, int32(WAL_CKPT_LOCK)) + if rc == SQLITE_OK { + pNew = pSnapshot + if libc.Xmemcmp(tls, pNew+32, pWal+72+32, uint64(8)) != 0 || (*TWalIndexHdr)(unsafe.Pointer(pNew)).FmxFrame < (*TWalCkptInfo)(unsafe.Pointer(_walCkptInfo(tls, pWal))).FnBackfillAttempted { + rc = libc.Int32FromInt32(SQLITE_ERROR) | libc.Int32FromInt32(3)< 0) { + break + } + if _sqlite3WalkExpr(tls, pWalker, (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr) != 0 { + return int32(WRC_Abort) + } + goto _1 + _1: + ; + i = i - 1 + pItem += 32 + } + } + return WRC_Continue +} + +// C documentation +// +// /* +// ** Walk the parse trees associated with all subqueries in the +// ** FROM clause of SELECT statement p. Do not invoke the select +// ** callback on p, but do invoke it on each FROM clause subquery +// ** and on any subqueries further down in the tree. Return +// ** WRC_Abort or WRC_Continue; +// */ +func _sqlite3WalkSelectFrom(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) { + var i int32 + var pItem, pSrc uintptr + _, _, _ = i, pItem, pSrc + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + if pSrc != 0 { + i = (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc + pItem = pSrc + 8 + for { + if !(i > 0) { + break + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 && _sqlite3WalkSelect(tls, pWalker, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect) != 0 { + return int32(WRC_Abort) + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x8>>3) != 0 && _sqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pItem + 48))) != 0 { + return int32(WRC_Abort) + } + goto _1 + _1: + ; + i = i - 1 + pItem += 80 + } + } + return WRC_Continue +} + +func _sqlite3WhereExprListUsage(tls *libc.TLS, pMaskSet uintptr, pList uintptr) (r TBitmask) { + var i int32 + var mask TBitmask + _, _ = i, mask + mask = uint64(0) + if pList != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + mask = mask | _sqlite3WhereExprUsage(tls, pMaskSet, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr) + goto _1 + _1: + ; + i = i + 1 + } + } + return mask +} + +// C documentation +// +// /* +// ** If the WHERE_GROUPBY flag is set in the mask passed to sqlite3WhereBegin(), +// ** the planner assumes that the specified pOrderBy list is actually a GROUP +// ** BY clause - and so any order that groups rows as required satisfies the +// ** request. +// ** +// ** Normally, in this case it is not possible for the caller to determine +// ** whether or not the rows are really being delivered in sorted order, or +// ** just in some other order that provides the required grouping. However, +// ** if the WHERE_SORTBYGROUP flag is also passed to sqlite3WhereBegin(), then +// ** this function may be called on the returned WhereInfo object. It returns +// ** true if the rows really will be sorted in the specified order, or false +// ** otherwise. +// ** +// ** For example, assuming: +// ** +// ** CREATE INDEX i1 ON t1(x, Y); +// ** +// ** then +// ** +// ** SELECT * FROM t1 GROUP BY x,y ORDER BY x,y; -- IsSorted()==1 +// ** SELECT * FROM t1 GROUP BY y,x ORDER BY y,x; -- IsSorted()==0 +// */ +func _sqlite3WhereIsSorted(tls *libc.TLS, pWInfo uintptr) (r int32) { + return int32(uint32(*(*uint8)(unsafe.Pointer(pWInfo + 68)) & 0x8 >> 3)) +} + +// C documentation +// +// /* +// ** Return TRUE if the WHERE loop uses the OP_DeferredSeek opcode to move +// ** the data cursor to the row selected by the index cursor. +// */ +func _sqlite3WhereUsesDeferredSeek(tls *libc.TLS, pWInfo uintptr) (r int32) { + return int32(uint32(*(*uint8)(unsafe.Pointer(pWInfo + 68)) & 0x1 >> 0)) +} + +// C documentation +// +// /* +// ** Allocate and return a duplicate of the Window object indicated by the +// ** third argument. Set the Window.pOwner field of the new object to +// ** pOwner. +// */ +func _sqlite3WindowDup(tls *libc.TLS, db uintptr, pOwner uintptr, p uintptr) (r uintptr) { + var pNew uintptr + _ = pNew + pNew = uintptr(0) + if p != 0 { + pNew = _sqlite3DbMallocZero(tls, db, uint64(144)) + if pNew != 0 { + (*TWindow)(unsafe.Pointer(pNew)).FzName = _sqlite3DbStrDup(tls, db, (*TWindow)(unsafe.Pointer(p)).FzName) + (*TWindow)(unsafe.Pointer(pNew)).FzBase = _sqlite3DbStrDup(tls, db, (*TWindow)(unsafe.Pointer(p)).FzBase) + (*TWindow)(unsafe.Pointer(pNew)).FpFilter = _sqlite3ExprDup(tls, db, (*TWindow)(unsafe.Pointer(p)).FpFilter, 0) + (*TWindow)(unsafe.Pointer(pNew)).FpWFunc = (*TWindow)(unsafe.Pointer(p)).FpWFunc + (*TWindow)(unsafe.Pointer(pNew)).FpPartition = _sqlite3ExprListDup(tls, db, (*TWindow)(unsafe.Pointer(p)).FpPartition, 0) + (*TWindow)(unsafe.Pointer(pNew)).FpOrderBy = _sqlite3ExprListDup(tls, db, (*TWindow)(unsafe.Pointer(p)).FpOrderBy, 0) + (*TWindow)(unsafe.Pointer(pNew)).FeFrmType = (*TWindow)(unsafe.Pointer(p)).FeFrmType + (*TWindow)(unsafe.Pointer(pNew)).FeEnd = (*TWindow)(unsafe.Pointer(p)).FeEnd + (*TWindow)(unsafe.Pointer(pNew)).FeStart = (*TWindow)(unsafe.Pointer(p)).FeStart + (*TWindow)(unsafe.Pointer(pNew)).FeExclude = (*TWindow)(unsafe.Pointer(p)).FeExclude + (*TWindow)(unsafe.Pointer(pNew)).FregResult = (*TWindow)(unsafe.Pointer(p)).FregResult + (*TWindow)(unsafe.Pointer(pNew)).FregAccum = (*TWindow)(unsafe.Pointer(p)).FregAccum + (*TWindow)(unsafe.Pointer(pNew)).FiArgCol = (*TWindow)(unsafe.Pointer(p)).FiArgCol + (*TWindow)(unsafe.Pointer(pNew)).FiEphCsr = (*TWindow)(unsafe.Pointer(p)).FiEphCsr + (*TWindow)(unsafe.Pointer(pNew)).FbExprArgs = (*TWindow)(unsafe.Pointer(p)).FbExprArgs + (*TWindow)(unsafe.Pointer(pNew)).FpStart = _sqlite3ExprDup(tls, db, (*TWindow)(unsafe.Pointer(p)).FpStart, 0) + (*TWindow)(unsafe.Pointer(pNew)).FpEnd = _sqlite3ExprDup(tls, db, (*TWindow)(unsafe.Pointer(p)).FpEnd, 0) + (*TWindow)(unsafe.Pointer(pNew)).FpOwner = pOwner + (*TWindow)(unsafe.Pointer(pNew)).FbImplicitFrame = (*TWindow)(unsafe.Pointer(p)).FbImplicitFrame + } + } + return pNew +} + +// C documentation +// +// /* +// ** Possibly link window pWin into the list at pSel->pWin (window functions +// ** to be processed as part of SELECT statement pSel). The window is linked +// ** in if either (a) there are no other windows already linked to this +// ** SELECT, or (b) the windows already linked use a compatible window frame. +// */ +func _sqlite3WindowLink(tls *libc.TLS, pSel uintptr, pWin uintptr) { + if pSel != 0 { + if uintptr(0) == (*TSelect)(unsafe.Pointer(pSel)).FpWin || 0 == _sqlite3WindowCompare(tls, uintptr(0), (*TSelect)(unsafe.Pointer(pSel)).FpWin, pWin, 0) { + (*TWindow)(unsafe.Pointer(pWin)).FpNextWin = (*TSelect)(unsafe.Pointer(pSel)).FpWin + if (*TSelect)(unsafe.Pointer(pSel)).FpWin != 0 { + (*TWindow)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpWin)).FppThis = pWin + 64 + } + (*TSelect)(unsafe.Pointer(pSel)).FpWin = pWin + (*TWindow)(unsafe.Pointer(pWin)).FppThis = pSel + 104 + } else { + if _sqlite3ExprListCompare(tls, (*TWindow)(unsafe.Pointer(pWin)).FpPartition, (*TWindow)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpWin)).FpPartition, -int32(1)) != 0 { + **(**Tu32)(__ccgo_up(pSel + 4)) |= uint32(SF_MultiPart) + } + } + } +} + +// C documentation +// +// /* +// ** Return a copy of the linked list of Window objects passed as the +// ** second argument. +// */ +func _sqlite3WindowListDup(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pWin, pp uintptr + var _ /* pRet at bp+0 */ uintptr + _, _ = pWin, pp + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pp = bp + pWin = p + for { + if !(pWin != 0) { + break + } + **(**uintptr)(__ccgo_up(pp)) = _sqlite3WindowDup(tls, db, uintptr(0), pWin) + if **(**uintptr)(__ccgo_up(pp)) == uintptr(0) { + break + } + pp = **(**uintptr)(__ccgo_up(pp)) + 64 + goto _1 + _1: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + return **(**uintptr)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Free the contents of the With object passed as the second argument. +// */ +func _sqlite3WithDelete(tls *libc.TLS, db uintptr, pWith uintptr) { + var i int32 + _ = i + if pWith != 0 { + i = 0 + for { + if !(i < (*TWith)(unsafe.Pointer(pWith)).FnCte) { + break + } + _cteClear(tls, db, pWith+16+uintptr(i)*48) + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbFree(tls, db, pWith) + } +} + +// C documentation +// +// /* +// ** Assign new cursor numbers to each of the items in pSrc. For each +// ** new cursor number assigned, set an entry in the aCsrMap[] array +// ** to map the old cursor number to the new: +// ** +// ** aCsrMap[iOld+1] = iNew; +// ** +// ** The array is guaranteed by the caller to be large enough for all +// ** existing cursor numbers in pSrc. aCsrMap[0] is the array size. +// ** +// ** If pSrc contains any sub-selects, call this routine recursively +// ** on the FROM clause of each such sub-select, with iExcept set to -1. +// */ +func _srclistRenumberCursors(tls *libc.TLS, pParse uintptr, aCsrMap uintptr, pSrc uintptr, iExcept int32) { + var i, v2 int32 + var p, pItem, v3 uintptr + _, _, _, _, _ = i, p, pItem, v2, v3 + i = 0 + pItem = pSrc + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc) { + break + } + if i != iExcept { + if !(int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x80>>7) != 0) || **(**int32)(__ccgo_up(aCsrMap + uintptr((*TSrcItem)(unsafe.Pointer(pItem)).FiCursor+int32(1))*4)) == 0 { + v3 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v3)) + *(*int32)(unsafe.Pointer(v3)) = *(*int32)(unsafe.Pointer(v3)) + 1 + **(**int32)(__ccgo_up(aCsrMap + uintptr((*TSrcItem)(unsafe.Pointer(pItem)).FiCursor+int32(1))*4)) = v2 + } + (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor = **(**int32)(__ccgo_up(aCsrMap + uintptr((*TSrcItem)(unsafe.Pointer(pItem)).FiCursor+int32(1))*4)) + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { + p = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + for { + if !(p != 0) { + break + } + _srclistRenumberCursors(tls, pParse, aCsrMap, (*TSelect)(unsafe.Pointer(p)).FpSrc, -int32(1)) + goto _4 + _4: + ; + p = (*TSelect)(unsafe.Pointer(p)).FpPrior + } + } + } + goto _1 + _1: + ; + i = i + 1 + pItem += 80 + } +} + +// C documentation +// +// /* +// ** Reclaim all memory of a StatAccum structure. +// */ +func _statAccumDestructor(tls *libc.TLS, pOld uintptr) { + var i int32 + var p uintptr + _, _ = i, p + p = pOld + if (*TStatAccum)(unsafe.Pointer(p)).FmxSample != 0 { + i = 0 + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FnCol) { + break + } + _sampleClear(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, (*TStatAccum)(unsafe.Pointer(p)).FaBest+uintptr(i)*48) + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < (*TStatAccum)(unsafe.Pointer(p)).FmxSample) { + break + } + _sampleClear(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, (*TStatAccum)(unsafe.Pointer(p)).Fa+uintptr(i)*48) + goto _2 + _2: + ; + i = i + 1 + } + _sampleClear(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, p+40) + } + _sqlite3DbFree(tls, (*TStatAccum)(unsafe.Pointer(p)).Fdb, p) +} + +func _statClearCells(tls *libc.TLS, p uintptr) { + var i int32 + _ = i + if (*TStatPage)(unsafe.Pointer(p)).FaCell != 0 { + i = 0 + for { + if !(i < (*TStatPage)(unsafe.Pointer(p)).FnCell) { + break + } + Xsqlite3_free(tls, (**(**TStatCell)(__ccgo_up((*TStatPage)(unsafe.Pointer(p)).FaCell + uintptr(i)*32))).FaOvfl) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, (*TStatPage)(unsafe.Pointer(p)).FaCell) + } + (*TStatPage)(unsafe.Pointer(p)).FnCell = 0 + (*TStatPage)(unsafe.Pointer(p)).FaCell = uintptr(0) +} + +// C documentation +// +// /* +// ** Return true if it is necessary to write page *pPg into the sub-journal. +// ** A page needs to be written into the sub-journal if there exists one +// ** or more open savepoints for which: +// ** +// ** * The page-number is less than or equal to PagerSavepoint.nOrig, and +// ** * The bit corresponding to the page-number is not set in +// ** PagerSavepoint.pInSavepoint. +// */ +func _subjRequiresPage(tls *libc.TLS, pPg uintptr) (r int32) { + var i int32 + var p, pPager uintptr + var pgno TPgno + _, _, _, _ = i, p, pPager, pgno + pPager = (*TPgHdr)(unsafe.Pointer(pPg)).FpPager + pgno = (*TPgHdr)(unsafe.Pointer(pPg)).Fpgno + i = 0 + for { + if !(i < (*TPager)(unsafe.Pointer(pPager)).FnSavepoint) { + break + } + p = (*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(i)*56 + if (*TPagerSavepoint)(unsafe.Pointer(p)).FnOrig >= pgno && 0 == _sqlite3BitvecTestNotNull(tls, (*TPagerSavepoint)(unsafe.Pointer(p)).FpInSavepoint, pgno) { + i = i + int32(1) + for { + if !(i < (*TPager)(unsafe.Pointer(pPager)).FnSavepoint) { + break + } + (**(**TPagerSavepoint)(__ccgo_up((*TPager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(i)*56))).FbTruncateOnRelease = 0 + goto _2 + _2: + ; + i = i + 1 + } + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +func _substExprList(tls *libc.TLS, pSubst uintptr, pList uintptr) { + var i int32 + _ = i + if pList == uintptr(0) { + return + } + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr = _substExpr(tls, pSubst, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr) + goto _1 + _1: + ; + i = i + 1 + } +} + +func _substSelect(tls *libc.TLS, pSubst uintptr, p uintptr, doPrior int32) { + var i int32 + var pItem, pSrc, v1 uintptr + var v2 bool + _, _, _, _, _ = i, pItem, pSrc, v1, v2 + if !(p != 0) { + return + } + (*TSubstContext)(unsafe.Pointer(pSubst)).FnSelDepth = (*TSubstContext)(unsafe.Pointer(pSubst)).FnSelDepth + 1 + for { + _substExprList(tls, pSubst, (*TSelect)(unsafe.Pointer(p)).FpEList) + _substExprList(tls, pSubst, (*TSelect)(unsafe.Pointer(p)).FpGroupBy) + _substExprList(tls, pSubst, (*TSelect)(unsafe.Pointer(p)).FpOrderBy) + (*TSelect)(unsafe.Pointer(p)).FpHaving = _substExpr(tls, pSubst, (*TSelect)(unsafe.Pointer(p)).FpHaving) + (*TSelect)(unsafe.Pointer(p)).FpWhere = _substExpr(tls, pSubst, (*TSelect)(unsafe.Pointer(p)).FpWhere) + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + i = (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc + pItem = pSrc + 8 + for { + if !(i > 0) { + break + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { + _substSelect(tls, pSubst, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect, int32(1)) + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x8>>3) != 0 { + _substExprList(tls, pSubst, *(*uintptr)(unsafe.Pointer(pItem + 48))) + } + goto _4 + _4: + ; + i = i - 1 + pItem += 80 + } + goto _3 + _3: + ; + if v2 = doPrior != 0; v2 { + v1 = (*TSelect)(unsafe.Pointer(p)).FpPrior + p = v1 + } + if !(v2 && v1 != uintptr(0)) { + break + } + } + (*TSubstContext)(unsafe.Pointer(pSubst)).FnSelDepth = (*TSubstContext)(unsafe.Pointer(pSubst)).FnSelDepth - 1 +} + +// C documentation +// +// /* +// ** Return true if any TEMP triggers exist +// */ +func _tempTriggersExist(tls *libc.TLS, db uintptr) (r int32) { + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema == uintptr(0) { + return 0 + } + if (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema+56)).Ffirst == uintptr(0) { + return 0 + } + return int32(1) +} + +// C documentation +// +// /* +// ** Return term iTerm of the WhereClause passed as the first argument. Terms +// ** are numbered from 0 upwards, starting with the terms in pWC->a[], then +// ** those in pWC->pOuter->a[] (if any), and so on. +// */ +func _termFromWhereClause(tls *libc.TLS, pWC uintptr, iTerm int32) (r uintptr) { + var p uintptr + _ = p + p = pWC + for { + if !(p != 0) { + break + } + if iTerm < (*TWhereClause)(unsafe.Pointer(p)).FnTerm { + return (*TWhereClause)(unsafe.Pointer(p)).Fa + uintptr(iTerm)*56 + } + iTerm = iTerm - (*TWhereClause)(unsafe.Pointer(p)).FnTerm + goto _1 + _1: + ; + p = (*TWhereClause)(unsafe.Pointer(p)).FpOuter + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Unmap all tokens in the IdList object passed as the second argument. +// */ +func _unmapColumnIdlistNames(tls *libc.TLS, pParse uintptr, pIdList uintptr) { + var ii int32 + _ = ii + ii = 0 + for { + if !(ii < (*TIdList)(unsafe.Pointer(pIdList)).FnId) { + break + } + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*(*TIdList_item)(unsafe.Pointer(pIdList + 8 + uintptr(ii)*8))).FzName) + goto _1 + _1: + ; + ii = ii + 1 + } +} + +// C documentation +// +// /* +// ** If the Vdbe passed as the first argument opened a statement-transaction, +// ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or +// ** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement +// ** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the +// ** statement transaction is committed. +// ** +// ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. +// ** Otherwise SQLITE_OK. +// */ +func _vdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) (r int32) { + var db, pBt uintptr + var i, iSavepoint, rc, rc2 int32 + _, _, _, _, _, _ = db, i, iSavepoint, pBt, rc, rc2 + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + rc = SQLITE_OK + iSavepoint = (*TVdbe)(unsafe.Pointer(p)).FiStatement - int32(1) + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + rc2 = SQLITE_OK + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 { + if eOp == int32(SAVEPOINT_ROLLBACK) { + rc2 = _sqlite3BtreeSavepoint(tls, pBt, int32(SAVEPOINT_ROLLBACK), iSavepoint) + } + if rc2 == SQLITE_OK { + rc2 = _sqlite3BtreeSavepoint(tls, pBt, int32(SAVEPOINT_RELEASE), iSavepoint) + } + if rc == SQLITE_OK { + rc = rc2 + } + } + goto _1 + _1: + ; + i = i + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnStatement - 1 + (*TVdbe)(unsafe.Pointer(p)).FiStatement = 0 + if rc == SQLITE_OK { + if eOp == int32(SAVEPOINT_ROLLBACK) { + rc = _sqlite3VtabSavepoint(tls, db, int32(SAVEPOINT_ROLLBACK), iSavepoint) + } + if rc == SQLITE_OK { + rc = _sqlite3VtabSavepoint(tls, db, int32(SAVEPOINT_RELEASE), iSavepoint) + } + } + /* If the statement transaction is being rolled back, also restore the + ** database handles deferred constraint counter to the value it had when + ** the statement transaction was opened. */ + if eOp == int32(SAVEPOINT_ROLLBACK) { + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons = (*TVdbe)(unsafe.Pointer(p)).FnStmtDefCons + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = (*TVdbe)(unsafe.Pointer(p)).FnStmtDefImmCons + } + return rc +} + +// C documentation +// +// /* +// ** Both *pMem1 and *pMem2 contain string values. Compare the two values +// ** using the collation sequence pColl. As usual, return a negative , zero +// ** or positive value if *pMem1 is less than, equal to or greater than +// ** *pMem2, respectively. Similar in spirit to "rc = (*pMem1) - (*pMem2);". +// */ +func _vdbeCompareMemStringWithEncodingChange(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintptr, prcErr uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var rc int32 + var v1, v2 uintptr + var _ /* c1 at bp+0 */ TMem + var _ /* c2 at bp+56 */ TMem + _, _, _ = rc, v1, v2 + _sqlite3VdbeMemInit(tls, bp, (*TMem)(unsafe.Pointer(pMem1)).Fdb, uint16(MEM_Null)) + _sqlite3VdbeMemInit(tls, bp+56, (*TMem)(unsafe.Pointer(pMem1)).Fdb, uint16(MEM_Null)) + _sqlite3VdbeMemShallowCopy(tls, bp, pMem1, int32(MEM_Ephem)) + _sqlite3VdbeMemShallowCopy(tls, bp+56, pMem2, int32(MEM_Ephem)) + v1 = _sqlite3ValueText(tls, bp, (*TCollSeq)(unsafe.Pointer(pColl)).Fenc) + v2 = _sqlite3ValueText(tls, bp+56, (*TCollSeq)(unsafe.Pointer(pColl)).Fenc) + if v1 == uintptr(0) || v2 == uintptr(0) { + if prcErr != 0 { + **(**Tu8)(__ccgo_up(prcErr)) = uint8(SQLITE_NOMEM) + } + rc = 0 + } else { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TCollSeq)(unsafe.Pointer(pColl)).FxCmp})))(tls, (*TCollSeq)(unsafe.Pointer(pColl)).FpUser, (**(**TMem)(__ccgo_up(bp))).Fn, v1, (**(**TMem)(__ccgo_up(bp + 56))).Fn, v2) + } + _sqlite3VdbeMemReleaseMalloc(tls, bp) + _sqlite3VdbeMemReleaseMalloc(tls, bp+56) + return rc +} + +// C documentation +// +// /* +// ** Free the space allocated for aOp and any p4 values allocated for the +// ** opcodes contained within. If aOp is not NULL it is assumed to contain +// ** nOp entries. +// */ +func _vdbeFreeOpArray(tls *libc.TLS, db uintptr, aOp uintptr, nOp int32) { + var pOp uintptr + _ = pOp + if aOp != 0 { + pOp = aOp + uintptr(nOp-int32(1))*24 + for int32(1) != 0 { /* Exit via break */ + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) <= -int32(7) { + _freeP4(tls, db, int32((*TOp)(unsafe.Pointer(pOp)).Fp4type), *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + if pOp == aOp { + break + } + pOp -= 24 + } + _sqlite3DbNNFreeNN(tls, db, aOp) + } +} + +// C documentation +// +// /* +// ** If the second argument is not NULL, release any allocations associated +// ** with the memory cells in the p->aMem[] array. Also free the UnpackedRecord +// ** structure itself, using sqlite3DbFree(). +// ** +// ** This function is used to free UnpackedRecord structures allocated by +// ** the vdbeUnpackRecord() function found in vdbeapi.c. +// */ +func _vdbeFreeUnpacked(tls *libc.TLS, db uintptr, nField int32, p uintptr) { + var i int32 + var pMem uintptr + _, _ = i, pMem + if p != 0 { + i = 0 + for { + if !(i < nField) { + break + } + pMem = (*TUnpackedRecord)(unsafe.Pointer(p)).FaMem + uintptr(i)*56 + if (*TMem)(unsafe.Pointer(pMem)).FzMalloc != 0 { + _sqlite3VdbeMemReleaseMalloc(tls, pMem) + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbNNFreeNN(tls, db, p) + } +} + +// C documentation +// +// /* +// ** Free all resources associated with the IncrMerger object indicated by +// ** the first argument. +// */ +func _vdbeIncrFree(tls *libc.TLS, pIncr uintptr) { + if pIncr != 0 { + if (*TIncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { + _vdbeSorterJoinThread(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask) + if (**(**TSorterFile)(__ccgo_up(pIncr + 40))).FpFd != 0 { + _sqlite3OsCloseFree(tls, (**(**TSorterFile)(__ccgo_up(pIncr + 40))).FpFd) + } + if (**(**TSorterFile)(__ccgo_up(pIncr + 40 + 1*16))).FpFd != 0 { + _sqlite3OsCloseFree(tls, (**(**TSorterFile)(__ccgo_up(pIncr + 40 + 1*16))).FpFd) + } + } + _vdbeMergeEngineFree(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpMerger) + Xsqlite3_free(tls, pIncr) + } +} + +// C documentation +// +// /* +// ** Allocate and return a new IncrMerger object to read data from pMerger. +// ** +// ** If an OOM condition is encountered, return NULL. In this case free the +// ** pMerger argument before returning. +// */ +func _vdbeIncrMergerNew(tls *libc.TLS, pTask uintptr, pMerger uintptr, ppOut uintptr) (r int32) { + var pIncr, v1, v2 uintptr + var rc, v3 int32 + _, _, _, _, _ = pIncr, rc, v1, v2, v3 + rc = SQLITE_OK + if _sqlite3FaultSim(tls, int32(100)) != 0 { + v2 = uintptr(0) + } else { + v2 = _sqlite3MallocZero(tls, uint64(72)) + } + v1 = v2 + **(**uintptr)(__ccgo_up(ppOut)) = v1 + pIncr = v1 + if pIncr != 0 { + (*TIncrMerger)(unsafe.Pointer(pIncr)).FpMerger = pMerger + (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask = pTask + if (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FmxKeysize+int32(9) > (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FmxPmaSize/int32(2) { + v3 = (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FmxKeysize + int32(9) + } else { + v3 = (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FmxPmaSize / int32(2) + } + (*TIncrMerger)(unsafe.Pointer(pIncr)).FmxSz = v3 + (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof += int64((*TIncrMerger)(unsafe.Pointer(pIncr)).FmxSz) + } else { + _vdbeMergeEngineFree(tls, pMerger) + rc = int32(SQLITE_NOMEM) + } + return rc +} + +// C documentation +// +// /* +// ** The main routine for background threads that populate aFile[1] of +// ** multi-threaded IncrMerger objects. +// */ +func _vdbeIncrPopulateThread(tls *libc.TLS, pCtx uintptr) (r uintptr) { + var pIncr, pRet uintptr + _, _ = pIncr, pRet + pIncr = pCtx + pRet = uintptr(int64(_vdbeIncrPopulate(tls, pIncr))) + (*TSortSubtask)(unsafe.Pointer((*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask)).FbDone = int32(1) + return pRet +} + +// C documentation +// +// /* +// ** This function is called when the PmaReader corresponding to pIncr has +// ** finished reading the contents of aFile[0]. Its purpose is to "refill" +// ** aFile[0] such that the PmaReader should start rereading it from the +// ** beginning. +// ** +// ** For single-threaded objects, this is accomplished by literally reading +// ** keys from pIncr->pMerger and repopulating aFile[0]. +// ** +// ** For multi-threaded objects, all that is required is to wait until the +// ** background thread is finished (if it is not already) and then swap +// ** aFile[0] and aFile[1] in place. If the contents of pMerger have not +// ** been exhausted, this function also launches a new background thread +// ** to populate the new aFile[1]. +// ** +// ** SQLITE_OK is returned on success, or an SQLite error code otherwise. +// */ +func _vdbeIncrSwap(tls *libc.TLS, pIncr uintptr) (r int32) { + var f0 TSorterFile + var rc int32 + _, _ = f0, rc + rc = SQLITE_OK + if (*TIncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { + rc = _vdbeSorterJoinThread(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask) + if rc == SQLITE_OK { + f0 = **(**TSorterFile)(__ccgo_up(pIncr + 40)) + **(**TSorterFile)(__ccgo_up(pIncr + 40)) = **(**TSorterFile)(__ccgo_up(pIncr + 40 + 1*16)) + **(**TSorterFile)(__ccgo_up(pIncr + 40 + 1*16)) = f0 + } + if rc == SQLITE_OK { + if (**(**TSorterFile)(__ccgo_up(pIncr + 40))).FiEof == (*TIncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { + (*TIncrMerger)(unsafe.Pointer(pIncr)).FbEof = int32(1) + } else { + rc = _vdbeIncrBgPopulate(tls, pIncr) + } + } + } else { + rc = _vdbeIncrPopulate(tls, pIncr) + **(**TSorterFile)(__ccgo_up(pIncr + 40)) = **(**TSorterFile)(__ccgo_up(pIncr + 40 + 1*16)) + if (**(**TSorterFile)(__ccgo_up(pIncr + 40))).FiEof == (*TIncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { + (*TIncrMerger)(unsafe.Pointer(pIncr)).FbEof = int32(1) + } + } + return rc +} + +// C documentation +// +// /* +// ** Unlock all of the btrees previously locked by a call to sqlite3VdbeEnter(). +// */ +func _vdbeLeave(tls *libc.TLS, p uintptr) { + var aDb, db uintptr + var i, nDb int32 + _, _, _, _ = aDb, db, i, nDb + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + aDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + nDb = (*Tsqlite3)(unsafe.Pointer(db)).FnDb + i = 0 + for { + if !(i < nDb) { + break + } + if i != int32(1) && (*TVdbe)(unsafe.Pointer(p)).FlockMask&(libc.Uint32FromInt32(1)<aTree[iOut] by comparing the next keys on the +// ** two PmaReaders that feed that entry. Neither of the PmaReaders +// ** are advanced. This routine merely does the comparison. +// */ +func _vdbeMergeEngineCompare(tls *libc.TLS, pMerger uintptr, iOut int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i1, i2, iRes, res int32 + var p1, p2, pTask uintptr + var _ /* bCached at bp+0 */ int32 + _, _, _, _, _, _, _ = i1, i2, iRes, p1, p2, pTask, res + if iOut >= (*TMergeEngine)(unsafe.Pointer(pMerger)).FnTree/int32(2) { + i1 = (iOut - (*TMergeEngine)(unsafe.Pointer(pMerger)).FnTree/int32(2)) * int32(2) + i2 = i1 + int32(1) + } else { + i1 = **(**int32)(__ccgo_up((*TMergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(iOut*int32(2))*4)) + i2 = **(**int32)(__ccgo_up((*TMergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(iOut*int32(2)+int32(1))*4)) + } + p1 = (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(i1)*80 + p2 = (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(i2)*80 + if (*TPmaReader)(unsafe.Pointer(p1)).FpFd == uintptr(0) { + iRes = i2 + } else { + if (*TPmaReader)(unsafe.Pointer(p2)).FpFd == uintptr(0) { + iRes = i1 + } else { + pTask = (*TMergeEngine)(unsafe.Pointer(pMerger)).FpTask + **(**int32)(__ccgo_up(bp)) = 0 + /* from vdbeSortSubtaskMain() */ + res = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSortSubtask)(unsafe.Pointer(pTask)).FxCompare})))(tls, pTask, bp, (*TPmaReader)(unsafe.Pointer(p1)).FaKey, (*TPmaReader)(unsafe.Pointer(p1)).FnKey, (*TPmaReader)(unsafe.Pointer(p2)).FaKey, (*TPmaReader)(unsafe.Pointer(p2)).FnKey) + if res <= 0 { + iRes = i1 + } else { + iRes = i2 + } + } + } + **(**int32)(__ccgo_up((*TMergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(iOut)*4)) = iRes +} + +// C documentation +// +// /* +// ** Free the MergeEngine object passed as the only argument. +// */ +func _vdbeMergeEngineFree(tls *libc.TLS, pMerger uintptr) { + var i int32 + _ = i + if pMerger != 0 { + i = 0 + for { + if !(i < (*TMergeEngine)(unsafe.Pointer(pMerger)).FnTree) { + break + } + _vdbePmaReaderClear(tls, (*TMergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(i)*80) + goto _1 + _1: + ; + i = i + 1 + } + } + Xsqlite3_free(tls, pMerger) +} + +// C documentation +// +// /* +// ** Allocate a new MergeEngine object to merge the contents of nPMA level-0 +// ** PMAs from pTask->file. If no error occurs, set *ppOut to point to +// ** the new object and return SQLITE_OK. Or, if an error does occur, set *ppOut +// ** to NULL and return an SQLite error code. +// ** +// ** When this function is called, *piOffset is set to the offset of the +// ** first PMA to read from pTask->file. Assuming no error occurs, it is +// ** set to the offset immediately following the last byte of the last +// ** PMA before returning. If an error does occur, then the final value of +// ** *piOffset is undefined. +// */ +func _vdbeMergeEngineLevel0(tls *libc.TLS, pTask uintptr, nPMA int32, piOffset uintptr, ppOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, rc int32 + var iOff Ti64 + var pNew, pReadr, v1 uintptr + var _ /* nDummy at bp+0 */ Ti64 + _, _, _, _, _, _ = i, iOff, pNew, pReadr, rc, v1 /* Merge engine to return */ + iOff = **(**Ti64)(__ccgo_up(piOffset)) + rc = SQLITE_OK + v1 = _vdbeMergeEngineNew(tls, nPMA) + pNew = v1 + **(**uintptr)(__ccgo_up(ppOut)) = v1 + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + i = 0 + for { + if !(i < nPMA && rc == SQLITE_OK) { + break + } + **(**Ti64)(__ccgo_up(bp)) = 0 + pReadr = (*TMergeEngine)(unsafe.Pointer(pNew)).FaReadr + uintptr(i)*80 + rc = _vdbePmaReaderInit(tls, pTask, pTask+64, iOff, pReadr, bp) + iOff = (*TPmaReader)(unsafe.Pointer(pReadr)).FiEof + goto _2 + _2: + ; + i = i + 1 + } + if rc != SQLITE_OK { + _vdbeMergeEngineFree(tls, pNew) + **(**uintptr)(__ccgo_up(ppOut)) = uintptr(0) + } + **(**Ti64)(__ccgo_up(piOffset)) = iOff + return rc +} + +// C documentation +// +// /* +// ** The main routine for vdbePmaReaderIncrMergeInit() operations run in +// ** background threads. +// */ +func _vdbePmaReaderBgIncrInit(tls *libc.TLS, pCtx uintptr) (r uintptr) { + var pReader, pRet uintptr + _, _ = pReader, pRet + pReader = pCtx + pRet = uintptr(int64(_vdbePmaReaderIncrMergeInit(tls, pReader, int32(INCRINIT_TASK)))) + (*TSortSubtask)(unsafe.Pointer((*TIncrMerger)(unsafe.Pointer((*TPmaReader)(unsafe.Pointer(pReader)).FpIncr)).FpTask)).FbDone = int32(1) + return pRet +} + +// C documentation +// +// /* +// ** The PmaReader passed as the first argument is guaranteed to be an +// ** incremental-reader (pReadr->pIncr!=0). This function serves to open +// ** and/or initialize the temp file related fields of the IncrMerge +// ** object at (pReadr->pIncr). +// ** +// ** If argument eMode is set to INCRINIT_NORMAL, then all PmaReaders +// ** in the sub-tree headed by pReadr are also initialized. Data is then +// ** loaded into the buffers belonging to pReadr and it is set to point to +// ** the first key in its range. +// ** +// ** If argument eMode is set to INCRINIT_TASK, then pReadr is guaranteed +// ** to be a multi-threaded PmaReader and this function is being called in a +// ** background thread. In this case all PmaReaders in the sub-tree are +// ** initialized as for INCRINIT_NORMAL and the aFile[1] buffer belonging to +// ** pReadr is populated. However, pReadr itself is not set up to point +// ** to its first key. A call to vdbePmaReaderNext() is still required to do +// ** that. +// ** +// ** The reason this function does not call vdbePmaReaderNext() immediately +// ** in the INCRINIT_TASK case is that vdbePmaReaderNext() assumes that it has +// ** to block on thread (pTask->thread) before accessing aFile[1]. But, since +// ** this entire function is being run by thread (pTask->thread), that will +// ** lead to the current background thread attempting to join itself. +// ** +// ** Finally, if argument eMode is set to INCRINIT_ROOT, it may be assumed +// ** that pReadr->pIncr is a multi-threaded IncrMerge objects, and that all +// ** child-trees have already been initialized using IncrInit(INCRINIT_TASK). +// ** In this case vdbePmaReaderNext() is called on all child PmaReaders and +// ** the current PmaReader set to point to the first key in its range. +// ** +// ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. +// */ +func _vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) (r int32) { + var db, pIncr, pTask uintptr + var mxSz, rc int32 + _, _, _, _, _ = db, mxSz, pIncr, pTask, rc + rc = SQLITE_OK + pIncr = (*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr + pTask = (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask + db = (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb + /* eMode is always INCRINIT_NORMAL in single-threaded mode */ + rc = _vdbeMergeEngineInit(tls, pTask, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpMerger, eMode) + /* Set up the required files for pIncr. A multi-threaded IncrMerge object + ** requires two temp files to itself, whereas a single-threaded object + ** only requires a region of pTask->file2. */ + if rc == SQLITE_OK { + mxSz = (*TIncrMerger)(unsafe.Pointer(pIncr)).FmxSz + if (*TIncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { + rc = _vdbeSorterOpenTempFile(tls, db, int64(mxSz), pIncr+40) + if rc == SQLITE_OK { + rc = _vdbeSorterOpenTempFile(tls, db, int64(mxSz), pIncr+40+1*16) + } + } else { + /*if( !pIncr->bUseThread )*/ + if (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd == uintptr(0) { + rc = _vdbeSorterOpenTempFile(tls, db, (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof, pTask+80) + (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof = 0 + } + if rc == SQLITE_OK { + (**(**TSorterFile)(__ccgo_up(pIncr + 40 + 1*16))).FpFd = (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd + (*TIncrMerger)(unsafe.Pointer(pIncr)).FiStartOff = (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof + (*TSortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof += int64(mxSz) + } + } + } + if rc == SQLITE_OK && (*TIncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { + /* Use the current thread to populate aFile[1], even though this + ** PmaReader is multi-threaded. If this is an INCRINIT_TASK object, + ** then this function is already running in background thread + ** pIncr->pTask->thread. + ** + ** If this is the INCRINIT_ROOT object, then it is running in the + ** main VDBE thread. But that is Ok, as that thread cannot return + ** control to the VDBE or proceed with anything useful until the + ** first results are ready from this merger object anyway. + */ + rc = _vdbeIncrPopulate(tls, pIncr) + } + if rc == SQLITE_OK && (libc.Bool(false) || eMode != int32(INCRINIT_TASK)) { + rc = _vdbePmaReaderNext(tls, pReadr) + } + return rc +} + +// C documentation +// +// /* +// ** pRoot is the root of an incremental merge-tree with depth nDepth (according +// ** to vdbeSorterTreeDepth()). pLeaf is the iSeq'th leaf to be added to the +// ** tree, counting from zero. This function adds pLeaf to the tree. +// ** +// ** If successful, SQLITE_OK is returned. If an error occurs, an SQLite error +// ** code is returned and pLeaf is freed. +// */ +func _vdbeSorterAddToTree(tls *libc.TLS, pTask uintptr, nDepth int32, iSeq int32, pRoot uintptr, pLeaf uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, iIter, nDiv, rc int32 + var p, pNew, pReadr uintptr + var _ /* pIncr at bp+0 */ uintptr + _, _, _, _, _, _, _ = i, iIter, nDiv, p, pNew, pReadr, rc + rc = SQLITE_OK + nDiv = int32(1) + p = pRoot + rc = _vdbeIncrMergerNew(tls, pTask, pLeaf, bp) + i = int32(1) + for { + if !(i < nDepth) { + break + } + nDiv = nDiv * int32(SORTER_MAX_MERGE_COUNT) + goto _1 + _1: + ; + i = i + 1 + } + i = int32(1) + for { + if !(i < nDepth && rc == SQLITE_OK) { + break + } + iIter = iSeq / nDiv % int32(SORTER_MAX_MERGE_COUNT) + pReadr = (*TMergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr(iIter)*80 + if (*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr == uintptr(0) { + pNew = _vdbeMergeEngineNew(tls, int32(SORTER_MAX_MERGE_COUNT)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + rc = _vdbeIncrMergerNew(tls, pTask, pNew, pReadr+72) + } + } + if rc == SQLITE_OK { + p = (*TIncrMerger)(unsafe.Pointer((*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr)).FpMerger + nDiv = nDiv / int32(SORTER_MAX_MERGE_COUNT) + } + goto _2 + _2: + ; + i = i + 1 + } + if rc == SQLITE_OK { + (**(**TPmaReader)(__ccgo_up((*TMergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr(iSeq%int32(SORTER_MAX_MERGE_COUNT))*80))).FpIncr = **(**uintptr)(__ccgo_up(bp)) + } else { + _vdbeIncrFree(tls, **(**uintptr)(__ccgo_up(bp))) + } + return rc +} + +// C documentation +// +// /* +// ** The main routine for background threads that write level-0 PMAs. +// */ +func _vdbeSorterFlushThread(tls *libc.TLS, pCtx uintptr) (r uintptr) { + var pTask uintptr + var rc int32 + _, _ = pTask, rc + pTask = pCtx /* Return code */ + rc = _vdbeSorterListToPMA(tls, pTask, pTask+32) + (*TSortSubtask)(unsafe.Pointer(pTask)).FbDone = int32(1) + return uintptr(int64(rc)) +} + +// C documentation +// +// /* +// ** Join thread pTask->thread. +// */ +func _vdbeSorterJoinThread(tls *libc.TLS, pTask uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* pRet at bp+0 */ uintptr + _ = rc + rc = SQLITE_OK + if (*TSortSubtask)(unsafe.Pointer(pTask)).FpThread != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(int64(libc.Int32FromInt32(SQLITE_ERROR))) + _sqlite3ThreadJoin(tls, (*TSortSubtask)(unsafe.Pointer(pTask)).FpThread, bp) + rc = int32(int64(**(**uintptr)(__ccgo_up(bp)))) + (*TSortSubtask)(unsafe.Pointer(pTask)).FbDone = 0 + (*TSortSubtask)(unsafe.Pointer(pTask)).FpThread = uintptr(0) + } + return rc +} + +// C documentation +// +// /* +// ** Merge the two sorted lists p1 and p2 into a single list. +// */ +func _vdbeSorterMerge(tls *libc.TLS, pTask uintptr, p1 uintptr, p2 uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var pp uintptr + var res int32 + var _ /* bCached at bp+8 */ int32 + var _ /* pFinal at bp+0 */ uintptr + _, _ = pp, res + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + pp = bp + **(**int32)(__ccgo_up(bp + 8)) = 0 + for { + res = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSortSubtask)(unsafe.Pointer(pTask)).FxCompare})))(tls, pTask, bp+8, p1+libc.UintptrFromInt32(1)*16, (*TSorterRecord)(unsafe.Pointer(p1)).FnVal, p2+libc.UintptrFromInt32(1)*16, (*TSorterRecord)(unsafe.Pointer(p2)).FnVal) + if res <= 0 { + **(**uintptr)(__ccgo_up(pp)) = p1 + pp = p1 + 8 + p1 = *(*uintptr)(unsafe.Pointer(p1 + 8)) + if p1 == uintptr(0) { + **(**uintptr)(__ccgo_up(pp)) = p2 + break + } + } else { + **(**uintptr)(__ccgo_up(pp)) = p2 + pp = p2 + 8 + p2 = *(*uintptr)(unsafe.Pointer(p2 + 8)) + **(**int32)(__ccgo_up(bp + 8)) = 0 + if p2 == uintptr(0) { + **(**uintptr)(__ccgo_up(pp)) = p1 + break + } + } + goto _1 + _1: + } + return **(**uintptr)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Free the list of sorted records starting at pRecord. +// */ +func _vdbeSorterRecordFree(tls *libc.TLS, db uintptr, pRecord uintptr) { + var p, pNext uintptr + _, _ = p, pNext + p = pRecord + for { + if !(p != 0) { + break + } + pNext = *(*uintptr)(unsafe.Pointer(p + 8)) + _sqlite3DbFree(tls, db, p) + goto _1 + _1: + ; + p = pNext + } +} + +// C documentation +// +// /* +// ** Return a pointer to a buffer owned by the sorter that contains the +// ** current key. +// */ +func _vdbeSorterRowkey(tls *libc.TLS, pSorter uintptr, pnKey uintptr) (r uintptr) { + var pKey, pReader uintptr + _, _ = pKey, pReader + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA != 0 { + if (*TVdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { + pReader = (*TVdbeSorter)(unsafe.Pointer(pSorter)).FpReader + } else { + /*if( !pSorter->bUseThreads )*/ + pReader = (*TMergeEngine)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaReadr + uintptr(**(**int32)(__ccgo_up((*TMergeEngine)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaTree + 1*4)))*80 + } + **(**int32)(__ccgo_up(pnKey)) = (*TPmaReader)(unsafe.Pointer(pReader)).FnKey + pKey = (*TPmaReader)(unsafe.Pointer(pReader)).FaKey + } else { + **(**int32)(__ccgo_up(pnKey)) = (*TSorterRecord)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList)).FnVal + pKey = (*TVdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList + libc.UintptrFromInt32(1)*16 + } + return pKey +} + +// C documentation +// +// /* +// ** Table p is a virtual table. This function moves all elements in the +// ** p->u.vtab.p list to the sqlite3.pDisconnect lists of their associated +// ** database connections to be disconnected at the next opportunity. +// ** Except, if argument db is not NULL, then the entry associated with +// ** connection db is left in the p->u.vtab.p list. +// */ +func _vtabDisconnectAll(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) { + var db2, pNext, pRet, pVTable uintptr + _, _, _, _ = db2, pNext, pRet, pVTable + pRet = uintptr(0) + pVTable = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(p + 64))).Fp + (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(p + 64))).Fp = uintptr(0) + /* Assert that the mutex (if any) associated with the BtShared database + ** that contains table p is held by the caller. See header comments + ** above function sqlite3VtabUnlockList() for an explanation of why + ** this makes it safe to access the sqlite3.pDisconnect list of any + ** database connection that may have an entry in the p->u.vtab.p list. + */ + for pVTable != 0 { + db2 = (*TVTable)(unsafe.Pointer(pVTable)).Fdb + pNext = (*TVTable)(unsafe.Pointer(pVTable)).FpNext + if db2 == db { + pRet = pVTable + (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(p + 64))).Fp = pRet + (*TVTable)(unsafe.Pointer(pRet)).FpNext = uintptr(0) + } else { + (*TVTable)(unsafe.Pointer(pVTable)).FpNext = (*Tsqlite3)(unsafe.Pointer(db2)).FpDisconnect + (*Tsqlite3)(unsafe.Pointer(db2)).FpDisconnect = pVTable + } + pVTable = pNext + } + return pRet +} + +// C documentation +// +// /* +// ** Return a pointer to the WalCkptInfo structure in the wal-index. +// */ +func _walCkptInfo(tls *libc.TLS, pWal uintptr) (r uintptr) { + return **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData)) + uintptr(libc.Uint64FromInt64(48)/libc.Uint64FromInt32(2))*4 +} + +// C documentation +// +// /* +// ** Return the page number associated with frame iFrame in this WAL. +// */ +func _walFramePgno(tls *libc.TLS, pWal uintptr, iFrame Tu32) (r Tu32) { + var iHash int32 + _ = iHash + iHash = _walFramePage(tls, iFrame) + if iHash == 0 { + return **(**Tu32)(__ccgo_up(**(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData)) + uintptr((libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4)+uint64(iFrame)-uint64(1))*4)) + } + return **(**Tu32)(__ccgo_up(**(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iHash)*8)) + uintptr((uint64(iFrame-uint32(1))-(libc.Uint64FromInt32(HASHTABLE_NPAGE)-(libc.Uint64FromInt64(48)*libc.Uint64FromInt32(2)+libc.Uint64FromInt64(40))/libc.Uint64FromInt64(4)))%uint64(HASHTABLE_NPAGE))*4)) +} + +func _walIndexPage(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) (r int32) { + var v1 uintptr + var v2 bool + _, _ = v1, v2 + if v2 = (*TWal)(unsafe.Pointer(pWal)).FnWiData <= iPage; !v2 { + v1 = **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) + **(**uintptr)(__ccgo_up(ppPage)) = v1 + } + if v2 || v1 == uintptr(0) { + return _walIndexPageRealloc(tls, pWal, iPage, ppPage) + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Free a WhereInfo structure +// */ +func _whereInfoFree(tls *libc.TLS, db uintptr, pWInfo uintptr) { + var p, pNext uintptr + _, _ = p, pNext + _sqlite3WhereClauseClear(tls, pWInfo+104) + for (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops != 0 { + p = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops = (*TWhereLoop)(unsafe.Pointer(p)).FpNextLoop + _whereLoopDelete(tls, db, p) + } + for (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree != 0 { + pNext = (*TWhereMemBlock)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree)).FpNext + _sqlite3DbNNFreeNN(tls, db, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree) + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree = pNext + } + _sqlite3DbNNFreeNN(tls, db, pWInfo) +} + +// C documentation +// +// /* +// ** Insert or replace a WhereLoop entry using the template supplied. +// ** +// ** An existing WhereLoop entry might be overwritten if the new template +// ** is better and has fewer dependencies. Or the template will be ignored +// ** and no insert will occur if an existing WhereLoop is faster and has +// ** fewer dependencies than the template. Otherwise a new WhereLoop is +// ** added based on the template. +// ** +// ** If pBuilder->pOrSet is not NULL then we care about only the +// ** prerequisites and rRun and nOut costs of the N best loops. That +// ** information is gathered in the pBuilder->pOrSet object. This special +// ** processing mode is used only for OR clause processing. +// ** +// ** When accumulating multiple loops (when pBuilder->pOrSet is NULL) we +// ** still might overwrite similar loops with the new template if the +// ** new template is better. Loops may be overwritten if the following +// ** conditions are met: +// ** +// ** (1) They have the same iTab. +// ** (2) They have the same iSortIdx. +// ** (3) The template has same or fewer dependencies than the current loop +// ** (4) The template has the same or lower cost than the current loop +// */ +func _whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) (r int32) { + var db, p, pIndex, pToDel, pWInfo, ppPrev, ppTail, v1 uintptr + var rc int32 + _, _, _, _, _, _, _, _, _ = db, p, pIndex, pToDel, pWInfo, ppPrev, ppTail, rc, v1 + pWInfo = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo + db = (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb + /* Stop the search once we hit the query planner search limit */ + if (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit == uint32(0) { + if (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet != 0 { + (*TWhereOrSet)(unsafe.Pointer((*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet)).Fn = uint16(0) + } + return int32(SQLITE_DONE) + } + (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit = (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit - 1 + _whereLoopAdjustCost(tls, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpLoops, pTemplate) + /* If pBuilder->pOrSet is defined, then only keep track of the costs + ** and prereqs. + */ + if (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet != uintptr(0) { + if (*TWhereLoop)(unsafe.Pointer(pTemplate)).FnLTerm != 0 { + _whereOrInsert(tls, (*TWhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet, (*TWhereLoop)(unsafe.Pointer(pTemplate)).Fprereq, (*TWhereLoop)(unsafe.Pointer(pTemplate)).FrRun, (*TWhereLoop)(unsafe.Pointer(pTemplate)).FnOut) + } + return SQLITE_OK + } + /* Look for an existing WhereLoop to replace with pTemplate + */ + ppPrev = _whereLoopFindLesser(tls, pWInfo+80, pTemplate) + if ppPrev == uintptr(0) { + /* There already exists a WhereLoop on the list that is better + ** than pTemplate, so just ignore pTemplate */ + return SQLITE_OK + } else { + p = **(**uintptr)(__ccgo_up(ppPrev)) + } + /* If we reach this point it means that either p[] should be overwritten + ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new + ** WhereLoop and insert it. + */ + if p == uintptr(0) { + /* Allocate a new WhereLoop to add to the end of the list */ + v1 = _sqlite3DbMallocRawNN(tls, db, uint64(104)) + p = v1 + **(**uintptr)(__ccgo_up(ppPrev)) = v1 + if p == uintptr(0) { + return int32(SQLITE_NOMEM) + } + _whereLoopInit(tls, p) + (*TWhereLoop)(unsafe.Pointer(p)).FpNextLoop = uintptr(0) + } else { + /* We will be overwriting WhereLoop p[]. But before we do, first + ** go through the rest of the list and delete any other entries besides + ** p[] that are also supplanted by pTemplate */ + ppTail = p + 72 + for **(**uintptr)(__ccgo_up(ppTail)) != 0 { + ppTail = _whereLoopFindLesser(tls, ppTail, pTemplate) + if ppTail == uintptr(0) { + break + } + pToDel = **(**uintptr)(__ccgo_up(ppTail)) + if pToDel == uintptr(0) { + break + } + **(**uintptr)(__ccgo_up(ppTail)) = (*TWhereLoop)(unsafe.Pointer(pToDel)).FpNextLoop + _whereLoopDelete(tls, db, pToDel) + } + } + rc = _whereLoopXfer(tls, db, p, pTemplate) + if (*TWhereLoop)(unsafe.Pointer(p)).FwsFlags&uint32(WHERE_VIRTUALTABLE) == uint32(0) { + pIndex = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(p + 24))).FpIndex + if pIndex != 0 && int32(uint32(*(*uint16)(unsafe.Pointer(pIndex + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_IPK) { + (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(p + 24))).FpIndex = uintptr(0) + } + } + return rc +} + +// C documentation +// +// /* +// ** Return the number of arguments passed to the window-function associated +// ** with the object passed as the only argument to this function. +// */ +func _windowArgCount(tls *libc.TLS, pWin uintptr) (r int32) { + var pList uintptr + var v1 int32 + _, _ = pList, v1 + pList = *(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)) + if pList != 0 { + v1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v1 = 0 + } + return v1 +} + +// C documentation +// +// /* +// ** Generate code to set the accumulator register for each window function +// ** in the linked list passed as the second argument to NULL. And perform +// ** any equivalent initialization required by any built-in window functions +// ** in the list. +// */ +func _windowInitAccum(tls *libc.TLS, pParse uintptr, pMWin uintptr) (r int32) { + var nArg, regArg, v2 int32 + var pFunc, pWin, v uintptr + _, _, _, _, _, _ = nArg, pFunc, pWin, regArg, v, v2 + v = _sqlite3GetVdbe(tls, pParse) + nArg = 0 + pWin = pMWin + for { + if !(pWin != 0) { + break + } + pFunc = (*TWindow)(unsafe.Pointer(pWin)).FpWFunc + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregAccum) + if nArg > _windowArgCount(tls, pWin) { + v2 = nArg + } else { + v2 = _windowArgCount(tls, pWin) + } + nArg = v2 + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid == 0 { + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_nth_valueName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_first_valueName)) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pWin)).FregApp) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(1)) + } + if (*TFuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&uint32(SQLITE_FUNC_MINMAX) != 0 && (*TWindow)(unsafe.Pointer(pWin)).FcsrApp != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResetSorter), (*TWindow)(unsafe.Pointer(pWin)).FcsrApp) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(1)) + } + } + goto _1 + _1: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + regArg = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nArg + return regArg +} + +// C documentation +// +// /* +// ** Invoke the sub-routine at regGosub (generated by code in select.c) to +// ** return the current row of Window.iEphCsr. If all window functions are +// ** aggregate window functions that use the standard API, a single +// ** OP_Gosub instruction is all that this routine generates. Extra VM code +// ** for per-row processing is only generated for the following built-in window +// ** functions: +// ** +// ** nth_value() +// ** first_value() +// ** lag() +// ** lead() +// */ +func _windowReturnOneRow(tls *libc.TLS, p uintptr) { + var csr, csr1, iEph, lbl, lbl1, nArg, op, tmpReg, tmpReg1, tmpReg2, val, v2 int32 + var pFunc, pMWin, pParse, pWin, v uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = csr, csr1, iEph, lbl, lbl1, nArg, op, pFunc, pMWin, pParse, pWin, tmpReg, tmpReg1, tmpReg2, v, val, v2 + pMWin = (*TWindowCodeArg)(unsafe.Pointer(p)).FpMWin + v = (*TWindowCodeArg)(unsafe.Pointer(p)).FpVdbe + if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { + _windowFullScan(tls, p) + } else { + pParse = (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse + pWin = pMWin + for { + if !(pWin != 0) { + break + } + pFunc = (*TWindow)(unsafe.Pointer(pWin)).FpWFunc + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_nth_valueName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_first_valueName)) { + csr = (*TWindow)(unsafe.Pointer(pWin)).FcsrApp + lbl = _sqlite3VdbeMakeLabel(tls, pParse) + tmpReg = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregResult) + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_nth_valueName)) { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr, (*TWindow)(unsafe.Pointer(pWin)).FiArgCol+int32(1), tmpReg) + _windowCheckValue(tls, pParse, tmpReg, int32(2)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), tmpReg) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Add), tmpReg, (*TWindow)(unsafe.Pointer(pWin)).FregApp, tmpReg) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Gt), (*TWindow)(unsafe.Pointer(pWin)).FregApp+int32(1), lbl, tmpReg) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), csr, 0, tmpReg) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), csr, (*TWindow)(unsafe.Pointer(pWin)).FiArgCol, (*TWindow)(unsafe.Pointer(pWin)).FregResult) + _sqlite3VdbeResolveLabel(tls, v, lbl) + _sqlite3ReleaseTempReg(tls, pParse, tmpReg) + } else { + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_leadName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_lagName)) { + nArg = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TWindow)(unsafe.Pointer(pWin)).FpOwner + 32)))).FnExpr + csr1 = (*TWindow)(unsafe.Pointer(pWin)).FcsrApp + lbl1 = _sqlite3VdbeMakeLabel(tls, pParse) + tmpReg1 = _sqlite3GetTempReg(tls, pParse) + iEph = (*TWindow)(unsafe.Pointer(pMWin)).FiEphCsr + if nArg < int32(3) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, (*TWindow)(unsafe.Pointer(pWin)).FregResult) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEph, (*TWindow)(unsafe.Pointer(pWin)).FiArgCol+int32(2), (*TWindow)(unsafe.Pointer(pWin)).FregResult) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iEph, tmpReg1) + if nArg < int32(2) { + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_leadName)) { + v2 = int32(1) + } else { + v2 = -int32(1) + } + val = v2 + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), tmpReg1, val) + } else { + if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_leadName)) { + v2 = int32(OP_Add) + } else { + v2 = int32(OP_Subtract) + } + op = v2 + tmpReg2 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iEph, (*TWindow)(unsafe.Pointer(pWin)).FiArgCol+int32(1), tmpReg2) + _sqlite3VdbeAddOp3(tls, v, op, tmpReg2, tmpReg1, tmpReg1) + _sqlite3ReleaseTempReg(tls, pParse, tmpReg2) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), csr1, lbl1, tmpReg1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), csr1, (*TWindow)(unsafe.Pointer(pWin)).FiArgCol, (*TWindow)(unsafe.Pointer(pWin)).FregResult) + _sqlite3VdbeResolveLabel(tls, v, lbl1) + _sqlite3ReleaseTempReg(tls, pParse, tmpReg1) + } + } + goto _1 + _1: + ; + pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*TWindowCodeArg)(unsafe.Pointer(p)).FregGosub, (*TWindowCodeArg)(unsafe.Pointer(p)).FaddrGosub) +} + +// C documentation +// +// /* +// ** Pop the parser's stack once. +// ** +// ** If there is a destructor routine associated with the token which +// ** is popped from the stack, then call it. +// */ +func _yy_pop_parser_stack(tls *libc.TLS, pParser uintptr) { + var yytos, v1, v2 uintptr + _, _, _ = yytos, v1, v2 + v2 = pParser + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) -= 24 + yytos = v1 + _yy_destructor(tls, pParser, (*TyyStackEntry)(unsafe.Pointer(yytos)).Fmajor, yytos+8) +} + +func init() { + p := unsafe.Pointer(&_defaultMethods) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_sqlite3MemMalloc) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_sqlite3MemFree) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_sqlite3MemRealloc) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_sqlite3MemSize) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_sqlite3MemRoundup) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_sqlite3MemInit) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_sqlite3MemShutdown) +} + +/************** End of mem1.c ************************************************/ +/************** Begin file mem2.c ********************************************/ +/* +** 2007 August 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains low-level memory allocation drivers for when +** SQLite will use the standard C-library malloc/realloc/free interface +** to obtain the memory it needs while adding lots of additional debugging +** information to each allocation in order to help detect and fix memory +** leaks and memory usage errors. +** +** This file contains implementations of the low-level memory allocation +** routines specified in the sqlite3_mem_methods object. + */ +/* #include "sqliteInt.h" */ + +/* +** This version of the memory allocator is used only if the +** SQLITE_MEMDEBUG macro is defined + */ + +/************** End of mem2.c ************************************************/ +/************** Begin file mem3.c ********************************************/ +/* +** 2007 October 14 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the C functions that implement a memory +** allocation subsystem for use by SQLite. +** +** This version of the memory allocation subsystem omits all +** use of malloc(). The SQLite user supplies a block of memory +** before calling sqlite3_initialize() from which allocations +** are made and returned by the xMalloc() and xRealloc() +** implementations. Once sqlite3_initialize() has been called, +** the amount of memory available to SQLite is fixed and cannot +** be changed. +** +** This version of the memory allocation subsystem is included +** in the build only if SQLITE_ENABLE_MEMSYS3 is defined. + */ +/* #include "sqliteInt.h" */ + +/* +** This version of the memory allocator is only built into the library +** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not +** mean that the library will use a memory-pool by default, just that +** it is available. The mempool allocator is activated by calling +** sqlite3_config(). + */ + +/************** End of mem3.c ************************************************/ +/************** Begin file mem5.c ********************************************/ +/* +** 2007 October 14 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the C functions that implement a memory +** allocation subsystem for use by SQLite. +** +** This version of the memory allocation subsystem omits all +** use of malloc(). The application gives SQLite a block of memory +** before calling sqlite3_initialize() from which allocations +** are made and returned by the xMalloc() and xRealloc() +** implementations. Once sqlite3_initialize() has been called, +** the amount of memory available to SQLite is fixed and cannot +** be changed. +** +** This version of the memory allocation subsystem is included +** in the build only if SQLITE_ENABLE_MEMSYS5 is defined. +** +** This memory allocator uses the following algorithm: +** +** 1. All memory allocation sizes are rounded up to a power of 2. +** +** 2. If two adjacent free blocks are the halves of a larger block, +** then the two blocks are coalesced into the single larger block. +** +** 3. New memory is allocated from the first available free block. +** +** This algorithm is described in: J. M. Robson. "Bounds for Some Functions +** Concerning Dynamic Storage Allocation". Journal of the Association for +** Computing Machinery, Volume 21, Number 8, July 1974, pages 491-499. +** +** Let n be the size of the largest allocation divided by the minimum +** allocation size (after rounding all sizes up to a power of 2.) Let M +** be the maximum amount of memory ever outstanding at one time. Let +** N be the total amount of memory available for allocation. Robson +** proved that this memory allocator will never breakdown due to +** fragmentation as long as the following constraint holds: +** +** N >= M*(1 + log2(n)/2) - n + 1 +** +** The sqlite3_status() logic tracks the maximum values of n and M so +** that an application can, at any time, verify this constraint. + */ +/* #include "sqliteInt.h" */ + +/* +** This version of the memory allocator is used only when +** SQLITE_ENABLE_MEMSYS5 is defined. + */ + +/************** End of mem5.c ************************************************/ +/************** Begin file mutex.c *******************************************/ +/* +** 2007 August 14 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains the C functions that implement mutexes. +** +** This file contains code that is common across all mutex implementations. + */ +/* #include "sqliteInt.h" */ + +func init() { + p := unsafe.Pointer(&_statPushFuncdef) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_statPush) +} + +func init() { + p := unsafe.Pointer(&_sFts5Api) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_fts5ApiUserData) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_fts5ApiColumnCount) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_fts5ApiRowCount) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_fts5ApiColumnTotalSize) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_fts5ApiTokenize) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_fts5ApiPhraseCount) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_fts5ApiPhraseSize) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_fts5ApiInstCount) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_fts5ApiInst) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_fts5ApiRowid) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_fts5ApiColumnText) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_fts5ApiColumnSize) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_fts5ApiQueryPhrase) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_fts5ApiSetAuxdata) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_fts5ApiGetAuxdata) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_fts5ApiPhraseFirst) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_fts5ApiPhraseNext) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_fts5ApiPhraseFirstColumn) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(_fts5ApiPhraseNextColumn) + *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_fts5ApiQueryToken) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(_fts5ApiInstToken) + *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(_fts5ApiColumnLocale) + *(*uintptr)(unsafe.Add(p, 184)) = __ccgo_fp(_fts5ApiTokenize_v2) +} + +func init() { + p := unsafe.Pointer(&_aAgg) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_geopolyBBoxStep) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_geopolyBBoxFinal) +} + +/************** End of geopoly.c *********************************************/ +/************** Continuing where we left off in rtree.c **********************/ + +func init() { + p := unsafe.Pointer(&_aFunc) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_geopolyAreaFunc) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_geopolyBlobFunc) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_geopolyJsonFunc) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_geopolySvgFunc) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_geopolyWithinFunc) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_geopolyContainsPointFunc) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_geopolyOverlapFunc) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(_geopolyDebugFunc) + *(*uintptr)(unsafe.Add(p, 192)) = __ccgo_fp(_geopolyBBoxFunc) + *(*uintptr)(unsafe.Add(p, 216)) = __ccgo_fp(_geopolyXformFunc) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(_geopolyRegularFunc) + *(*uintptr)(unsafe.Add(p, 264)) = __ccgo_fp(_geopolyCcwFunc) +} + +func init() { + p := unsafe.Pointer(&_attach_func) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_attachFunc) +} + +func init() { + p := unsafe.Pointer(&_sMutex) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_noopMutexInit) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_noopMutexEnd) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_noopMutexAlloc) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_noopMutexFree) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_noopMutexEnter) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_noopMutexTry) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_noopMutexLeave) +} + +func init() { + p := unsafe.Pointer(&_aAlterTableFuncs) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_renameColumnFunc) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_renameTableFunc) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(_renameTableTest) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(_dropColumnFunc) + *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(_renameQuotefixFunc) + *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(_dropConstraintFunc) + *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(_failConstraintFunc) + *(*uintptr)(unsafe.Add(p, 528)) = __ccgo_fp(_addConstraintFunc) + *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(_findConstraintFunc) +} + +/************** End of alter.c ***********************************************/ +/************** Begin file analyze.c *****************************************/ +/* +** 2005-07-08 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code associated with the ANALYZE command. +** +** The ANALYZE command gather statistics about the content of tables +** and indices. These statistics are made available to the query planner +** to help it make better decisions about how to perform queries. +** +** The following system tables are or have been supported: +** +** CREATE TABLE sqlite_stat1(tbl, idx, stat); +** CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample); +** CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample); +** CREATE TABLE sqlite_stat4(tbl, idx, nEq, nLt, nDLt, sample); +** +** Additional tables might be added in future releases of SQLite. +** The sqlite_stat2 table is not created or used unless the SQLite version +** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled +** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated. +** The sqlite_stat2 table is superseded by sqlite_stat3, which is only +** created and used by SQLite versions 3.7.9 through 3.29.0 when +** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3 +** is a superset of sqlite_stat2 and is also now deprecated. The +** sqlite_stat4 is an enhanced version of sqlite_stat3 and is only +** available when compiled with SQLITE_ENABLE_STAT4 and in SQLite +** versions 3.8.1 and later. STAT4 is the only variant that is still +** supported. +** +** For most applications, sqlite_stat1 provides all the statistics required +** for the query planner to make good choices. +** +** Format of sqlite_stat1: +** +** There is normally one row per index, with the index identified by the +** name in the idx column. The tbl column is the name of the table to +** which the index belongs. In each such row, the stat column will be +** a string consisting of a list of integers. The first integer in this +** list is the number of rows in the index. (This is the same as the +** number of rows in the table, except for partial indices.) The second +** integer is the average number of rows in the index that have the same +** value in the first column of the index. The third integer is the average +** number of rows in the index that have the same value for the first two +** columns. The N-th integer (for N>1) is the average number of rows in +** the index which have the same value for the first N-1 columns. For +** a K-column index, there will be K+1 integers in the stat column. If +** the index is unique, then the last integer will be 1. +** +** The list of integers in the stat column can optionally be followed +** by the keyword "unordered". The "unordered" keyword, if it is present, +** must be separated from the last integer by a single space. If the +** "unordered" keyword is present, then the query planner assumes that +** the index is unordered and will not use the index for a range query. +** +** If the sqlite_stat1.idx column is NULL, then the sqlite_stat1.stat +** column contains a single integer which is the (estimated) number of +** rows in the table identified by sqlite_stat1.tbl. +** +** Format of sqlite_stat2: +** +** The sqlite_stat2 is only created and is only used if SQLite is compiled +** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between +** 3.6.18 and 3.7.8. The "stat2" table contains additional information +** about the distribution of keys within an index. The index is identified by +** the "idx" column and the "tbl" column is the name of the table to which +** the index belongs. There are usually 10 rows in the sqlite_stat2 +** table for each index. +** +** The sqlite_stat2 entries for an index that have sampleno between 0 and 9 +** inclusive are samples of the left-most key value in the index taken at +** evenly spaced points along the index. Let the number of samples be S +** (10 in the standard build) and let C be the number of rows in the index. +** Then the sampled rows are given by: +** +** rownumber = (i*C*2 + C)/(S*2) +** +** For i between 0 and S-1. Conceptually, the index space is divided into +** S uniform buckets and the samples are the middle row from each bucket. +** +** The format for sqlite_stat2 is recorded here for legacy reference. This +** version of SQLite does not support sqlite_stat2. It neither reads nor +** writes the sqlite_stat2 table. This version of SQLite only supports +** sqlite_stat3. +** +** Format for sqlite_stat3: +** +** The sqlite_stat3 format is a subset of sqlite_stat4. Hence, the +** sqlite_stat4 format will be described first. Further information +** about sqlite_stat3 follows the sqlite_stat4 description. +** +** Format for sqlite_stat4: +** +** As with sqlite_stat2, the sqlite_stat4 table contains histogram data +** to aid the query planner in choosing good indices based on the values +** that indexed columns are compared against in the WHERE clauses of +** queries. +** +** The sqlite_stat4 table contains multiple entries for each index. +** The idx column names the index and the tbl column is the table of the +** index. If the idx and tbl columns are the same, then the sample is +** of the INTEGER PRIMARY KEY. The sample column is a blob which is the +** binary encoding of a key from the index. The nEq column is a +** list of integers. The first integer is the approximate number +** of entries in the index whose left-most column exactly matches +** the left-most column of the sample. The second integer in nEq +** is the approximate number of entries in the index where the +** first two columns match the first two columns of the sample. +** And so forth. nLt is another list of integers that show the approximate +** number of entries that are strictly less than the sample. The first +** integer in nLt contains the number of entries in the index where the +** left-most column is less than the left-most column of the sample. +** The K-th integer in the nLt entry is the number of index entries +** where the first K columns are less than the first K columns of the +** sample. The nDLt column is like nLt except that it contains the +** number of distinct entries in the index that are less than the +** sample. +** +** There can be an arbitrary number of sqlite_stat4 entries per index. +** The ANALYZE command will typically generate sqlite_stat4 tables +** that contain between 10 and 40 samples which are distributed across +** the key space, though not uniformly, and which include samples with +** large nEq values. +** +** Format for sqlite_stat3 redux: +** +** The sqlite_stat3 table is like sqlite_stat4 except that it only +** looks at the left-most column of the index. The sqlite_stat3.sample +** column contains the actual value of the left-most column instead +** of a blob encoding of the complete index key as is found in +** sqlite_stat4.sample. The nEq, nLt, and nDLt entries of sqlite_stat3 +** all contain just a single integer which is the same as the first +** integer in the equivalent columns in sqlite_stat4. + */ +/* #include "sqliteInt.h" */ + +func init() { + p := unsafe.Pointer(&_detach_func) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_detachFunc) +} + +func init() { + p := unsafe.Pointer(&_sqlite3Apis) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(Xsqlite3_aggregate_context) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(Xsqlite3_aggregate_count) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(Xsqlite3_bind_blob) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(Xsqlite3_bind_double) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(Xsqlite3_bind_int) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(Xsqlite3_bind_int64) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(Xsqlite3_bind_null) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(Xsqlite3_bind_parameter_count) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(Xsqlite3_bind_parameter_index) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(Xsqlite3_bind_parameter_name) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(Xsqlite3_bind_text) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(Xsqlite3_bind_text16) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(Xsqlite3_bind_value) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(Xsqlite3_busy_handler) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(Xsqlite3_busy_timeout) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(Xsqlite3_changes) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(Xsqlite3_close) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(Xsqlite3_collation_needed) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(Xsqlite3_collation_needed16) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(Xsqlite3_column_blob) + *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(Xsqlite3_column_bytes) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(Xsqlite3_column_bytes16) + *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(Xsqlite3_column_count) + *(*uintptr)(unsafe.Add(p, 184)) = __ccgo_fp(Xsqlite3_column_database_name) + *(*uintptr)(unsafe.Add(p, 192)) = __ccgo_fp(Xsqlite3_column_database_name16) + *(*uintptr)(unsafe.Add(p, 200)) = __ccgo_fp(Xsqlite3_column_decltype) + *(*uintptr)(unsafe.Add(p, 208)) = __ccgo_fp(Xsqlite3_column_decltype16) + *(*uintptr)(unsafe.Add(p, 216)) = __ccgo_fp(Xsqlite3_column_double) + *(*uintptr)(unsafe.Add(p, 224)) = __ccgo_fp(Xsqlite3_column_int) + *(*uintptr)(unsafe.Add(p, 232)) = __ccgo_fp(Xsqlite3_column_int64) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(Xsqlite3_column_name) + *(*uintptr)(unsafe.Add(p, 248)) = __ccgo_fp(Xsqlite3_column_name16) + *(*uintptr)(unsafe.Add(p, 256)) = __ccgo_fp(Xsqlite3_column_origin_name) + *(*uintptr)(unsafe.Add(p, 264)) = __ccgo_fp(Xsqlite3_column_origin_name16) + *(*uintptr)(unsafe.Add(p, 272)) = __ccgo_fp(Xsqlite3_column_table_name) + *(*uintptr)(unsafe.Add(p, 280)) = __ccgo_fp(Xsqlite3_column_table_name16) + *(*uintptr)(unsafe.Add(p, 288)) = __ccgo_fp(Xsqlite3_column_text) + *(*uintptr)(unsafe.Add(p, 296)) = __ccgo_fp(Xsqlite3_column_text16) + *(*uintptr)(unsafe.Add(p, 304)) = __ccgo_fp(Xsqlite3_column_type) + *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(Xsqlite3_column_value) + *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(Xsqlite3_commit_hook) + *(*uintptr)(unsafe.Add(p, 328)) = __ccgo_fp(Xsqlite3_complete) + *(*uintptr)(unsafe.Add(p, 336)) = __ccgo_fp(Xsqlite3_complete16) + *(*uintptr)(unsafe.Add(p, 344)) = __ccgo_fp(Xsqlite3_create_collation) + *(*uintptr)(unsafe.Add(p, 352)) = __ccgo_fp(Xsqlite3_create_collation16) + *(*uintptr)(unsafe.Add(p, 360)) = __ccgo_fp(Xsqlite3_create_function) + *(*uintptr)(unsafe.Add(p, 368)) = __ccgo_fp(Xsqlite3_create_function16) + *(*uintptr)(unsafe.Add(p, 376)) = __ccgo_fp(Xsqlite3_create_module) + *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(Xsqlite3_data_count) + *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(Xsqlite3_db_handle) + *(*uintptr)(unsafe.Add(p, 400)) = __ccgo_fp(Xsqlite3_declare_vtab) + *(*uintptr)(unsafe.Add(p, 408)) = __ccgo_fp(Xsqlite3_enable_shared_cache) + *(*uintptr)(unsafe.Add(p, 416)) = __ccgo_fp(Xsqlite3_errcode) + *(*uintptr)(unsafe.Add(p, 424)) = __ccgo_fp(Xsqlite3_errmsg) + *(*uintptr)(unsafe.Add(p, 432)) = __ccgo_fp(Xsqlite3_errmsg16) + *(*uintptr)(unsafe.Add(p, 440)) = __ccgo_fp(Xsqlite3_exec) + *(*uintptr)(unsafe.Add(p, 448)) = __ccgo_fp(Xsqlite3_expired) + *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(Xsqlite3_finalize) + *(*uintptr)(unsafe.Add(p, 464)) = __ccgo_fp(Xsqlite3_free) + *(*uintptr)(unsafe.Add(p, 472)) = __ccgo_fp(Xsqlite3_free_table) + *(*uintptr)(unsafe.Add(p, 480)) = __ccgo_fp(Xsqlite3_get_autocommit) + *(*uintptr)(unsafe.Add(p, 488)) = __ccgo_fp(Xsqlite3_get_auxdata) + *(*uintptr)(unsafe.Add(p, 496)) = __ccgo_fp(Xsqlite3_get_table) + *(*uintptr)(unsafe.Add(p, 512)) = __ccgo_fp(Xsqlite3_interrupt) + *(*uintptr)(unsafe.Add(p, 520)) = __ccgo_fp(Xsqlite3_last_insert_rowid) + *(*uintptr)(unsafe.Add(p, 528)) = __ccgo_fp(Xsqlite3_libversion) + *(*uintptr)(unsafe.Add(p, 536)) = __ccgo_fp(Xsqlite3_libversion_number) + *(*uintptr)(unsafe.Add(p, 544)) = __ccgo_fp(Xsqlite3_malloc) + *(*uintptr)(unsafe.Add(p, 552)) = __ccgo_fp(Xsqlite3_mprintf) + *(*uintptr)(unsafe.Add(p, 560)) = __ccgo_fp(Xsqlite3_open) + *(*uintptr)(unsafe.Add(p, 568)) = __ccgo_fp(Xsqlite3_open16) + *(*uintptr)(unsafe.Add(p, 576)) = __ccgo_fp(Xsqlite3_prepare) + *(*uintptr)(unsafe.Add(p, 584)) = __ccgo_fp(Xsqlite3_prepare16) + *(*uintptr)(unsafe.Add(p, 592)) = __ccgo_fp(Xsqlite3_profile) + *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(Xsqlite3_progress_handler) + *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(Xsqlite3_realloc) + *(*uintptr)(unsafe.Add(p, 616)) = __ccgo_fp(Xsqlite3_reset) + *(*uintptr)(unsafe.Add(p, 624)) = __ccgo_fp(Xsqlite3_result_blob) + *(*uintptr)(unsafe.Add(p, 632)) = __ccgo_fp(Xsqlite3_result_double) + *(*uintptr)(unsafe.Add(p, 640)) = __ccgo_fp(Xsqlite3_result_error) + *(*uintptr)(unsafe.Add(p, 648)) = __ccgo_fp(Xsqlite3_result_error16) + *(*uintptr)(unsafe.Add(p, 656)) = __ccgo_fp(Xsqlite3_result_int) + *(*uintptr)(unsafe.Add(p, 664)) = __ccgo_fp(Xsqlite3_result_int64) + *(*uintptr)(unsafe.Add(p, 672)) = __ccgo_fp(Xsqlite3_result_null) + *(*uintptr)(unsafe.Add(p, 680)) = __ccgo_fp(Xsqlite3_result_text) + *(*uintptr)(unsafe.Add(p, 688)) = __ccgo_fp(Xsqlite3_result_text16) + *(*uintptr)(unsafe.Add(p, 696)) = __ccgo_fp(Xsqlite3_result_text16be) + *(*uintptr)(unsafe.Add(p, 704)) = __ccgo_fp(Xsqlite3_result_text16le) + *(*uintptr)(unsafe.Add(p, 712)) = __ccgo_fp(Xsqlite3_result_value) + *(*uintptr)(unsafe.Add(p, 720)) = __ccgo_fp(Xsqlite3_rollback_hook) + *(*uintptr)(unsafe.Add(p, 728)) = __ccgo_fp(Xsqlite3_set_authorizer) + *(*uintptr)(unsafe.Add(p, 736)) = __ccgo_fp(Xsqlite3_set_auxdata) + *(*uintptr)(unsafe.Add(p, 744)) = __ccgo_fp(Xsqlite3_snprintf) + *(*uintptr)(unsafe.Add(p, 752)) = __ccgo_fp(Xsqlite3_step) + *(*uintptr)(unsafe.Add(p, 760)) = __ccgo_fp(Xsqlite3_table_column_metadata) + *(*uintptr)(unsafe.Add(p, 768)) = __ccgo_fp(Xsqlite3_thread_cleanup) + *(*uintptr)(unsafe.Add(p, 776)) = __ccgo_fp(Xsqlite3_total_changes) + *(*uintptr)(unsafe.Add(p, 784)) = __ccgo_fp(Xsqlite3_trace) + *(*uintptr)(unsafe.Add(p, 792)) = __ccgo_fp(Xsqlite3_transfer_bindings) + *(*uintptr)(unsafe.Add(p, 800)) = __ccgo_fp(Xsqlite3_update_hook) + *(*uintptr)(unsafe.Add(p, 808)) = __ccgo_fp(Xsqlite3_user_data) + *(*uintptr)(unsafe.Add(p, 816)) = __ccgo_fp(Xsqlite3_value_blob) + *(*uintptr)(unsafe.Add(p, 824)) = __ccgo_fp(Xsqlite3_value_bytes) + *(*uintptr)(unsafe.Add(p, 832)) = __ccgo_fp(Xsqlite3_value_bytes16) + *(*uintptr)(unsafe.Add(p, 840)) = __ccgo_fp(Xsqlite3_value_double) + *(*uintptr)(unsafe.Add(p, 848)) = __ccgo_fp(Xsqlite3_value_int) + *(*uintptr)(unsafe.Add(p, 856)) = __ccgo_fp(Xsqlite3_value_int64) + *(*uintptr)(unsafe.Add(p, 864)) = __ccgo_fp(Xsqlite3_value_numeric_type) + *(*uintptr)(unsafe.Add(p, 872)) = __ccgo_fp(Xsqlite3_value_text) + *(*uintptr)(unsafe.Add(p, 880)) = __ccgo_fp(Xsqlite3_value_text16) + *(*uintptr)(unsafe.Add(p, 888)) = __ccgo_fp(Xsqlite3_value_text16be) + *(*uintptr)(unsafe.Add(p, 896)) = __ccgo_fp(Xsqlite3_value_text16le) + *(*uintptr)(unsafe.Add(p, 904)) = __ccgo_fp(Xsqlite3_value_type) + *(*uintptr)(unsafe.Add(p, 912)) = __ccgo_fp(Xsqlite3_vmprintf) + *(*uintptr)(unsafe.Add(p, 920)) = __ccgo_fp(Xsqlite3_overload_function) + *(*uintptr)(unsafe.Add(p, 928)) = __ccgo_fp(Xsqlite3_prepare_v2) + *(*uintptr)(unsafe.Add(p, 936)) = __ccgo_fp(Xsqlite3_prepare16_v2) + *(*uintptr)(unsafe.Add(p, 944)) = __ccgo_fp(Xsqlite3_clear_bindings) + *(*uintptr)(unsafe.Add(p, 952)) = __ccgo_fp(Xsqlite3_create_module_v2) + *(*uintptr)(unsafe.Add(p, 960)) = __ccgo_fp(Xsqlite3_bind_zeroblob) + *(*uintptr)(unsafe.Add(p, 968)) = __ccgo_fp(Xsqlite3_blob_bytes) + *(*uintptr)(unsafe.Add(p, 976)) = __ccgo_fp(Xsqlite3_blob_close) + *(*uintptr)(unsafe.Add(p, 984)) = __ccgo_fp(Xsqlite3_blob_open) + *(*uintptr)(unsafe.Add(p, 992)) = __ccgo_fp(Xsqlite3_blob_read) + *(*uintptr)(unsafe.Add(p, 1000)) = __ccgo_fp(Xsqlite3_blob_write) + *(*uintptr)(unsafe.Add(p, 1008)) = __ccgo_fp(Xsqlite3_create_collation_v2) + *(*uintptr)(unsafe.Add(p, 1016)) = __ccgo_fp(Xsqlite3_file_control) + *(*uintptr)(unsafe.Add(p, 1024)) = __ccgo_fp(Xsqlite3_memory_highwater) + *(*uintptr)(unsafe.Add(p, 1032)) = __ccgo_fp(Xsqlite3_memory_used) + *(*uintptr)(unsafe.Add(p, 1040)) = __ccgo_fp(Xsqlite3_mutex_alloc) + *(*uintptr)(unsafe.Add(p, 1048)) = __ccgo_fp(Xsqlite3_mutex_enter) + *(*uintptr)(unsafe.Add(p, 1056)) = __ccgo_fp(Xsqlite3_mutex_free) + *(*uintptr)(unsafe.Add(p, 1064)) = __ccgo_fp(Xsqlite3_mutex_leave) + *(*uintptr)(unsafe.Add(p, 1072)) = __ccgo_fp(Xsqlite3_mutex_try) + *(*uintptr)(unsafe.Add(p, 1080)) = __ccgo_fp(Xsqlite3_open_v2) + *(*uintptr)(unsafe.Add(p, 1088)) = __ccgo_fp(Xsqlite3_release_memory) + *(*uintptr)(unsafe.Add(p, 1096)) = __ccgo_fp(Xsqlite3_result_error_nomem) + *(*uintptr)(unsafe.Add(p, 1104)) = __ccgo_fp(Xsqlite3_result_error_toobig) + *(*uintptr)(unsafe.Add(p, 1112)) = __ccgo_fp(Xsqlite3_sleep) + *(*uintptr)(unsafe.Add(p, 1120)) = __ccgo_fp(Xsqlite3_soft_heap_limit) + *(*uintptr)(unsafe.Add(p, 1128)) = __ccgo_fp(Xsqlite3_vfs_find) + *(*uintptr)(unsafe.Add(p, 1136)) = __ccgo_fp(Xsqlite3_vfs_register) + *(*uintptr)(unsafe.Add(p, 1144)) = __ccgo_fp(Xsqlite3_vfs_unregister) + *(*uintptr)(unsafe.Add(p, 1152)) = __ccgo_fp(Xsqlite3_threadsafe) + *(*uintptr)(unsafe.Add(p, 1160)) = __ccgo_fp(Xsqlite3_result_zeroblob) + *(*uintptr)(unsafe.Add(p, 1168)) = __ccgo_fp(Xsqlite3_result_error_code) + *(*uintptr)(unsafe.Add(p, 1176)) = __ccgo_fp(Xsqlite3_test_control) + *(*uintptr)(unsafe.Add(p, 1184)) = __ccgo_fp(Xsqlite3_randomness) + *(*uintptr)(unsafe.Add(p, 1192)) = __ccgo_fp(Xsqlite3_context_db_handle) + *(*uintptr)(unsafe.Add(p, 1200)) = __ccgo_fp(Xsqlite3_extended_result_codes) + *(*uintptr)(unsafe.Add(p, 1208)) = __ccgo_fp(Xsqlite3_limit) + *(*uintptr)(unsafe.Add(p, 1216)) = __ccgo_fp(Xsqlite3_next_stmt) + *(*uintptr)(unsafe.Add(p, 1224)) = __ccgo_fp(Xsqlite3_sql) + *(*uintptr)(unsafe.Add(p, 1232)) = __ccgo_fp(Xsqlite3_status) + *(*uintptr)(unsafe.Add(p, 1240)) = __ccgo_fp(Xsqlite3_backup_finish) + *(*uintptr)(unsafe.Add(p, 1248)) = __ccgo_fp(Xsqlite3_backup_init) + *(*uintptr)(unsafe.Add(p, 1256)) = __ccgo_fp(Xsqlite3_backup_pagecount) + *(*uintptr)(unsafe.Add(p, 1264)) = __ccgo_fp(Xsqlite3_backup_remaining) + *(*uintptr)(unsafe.Add(p, 1272)) = __ccgo_fp(Xsqlite3_backup_step) + *(*uintptr)(unsafe.Add(p, 1280)) = __ccgo_fp(Xsqlite3_compileoption_get) + *(*uintptr)(unsafe.Add(p, 1288)) = __ccgo_fp(Xsqlite3_compileoption_used) + *(*uintptr)(unsafe.Add(p, 1296)) = __ccgo_fp(Xsqlite3_create_function_v2) + *(*uintptr)(unsafe.Add(p, 1304)) = __ccgo_fp(Xsqlite3_db_config) + *(*uintptr)(unsafe.Add(p, 1312)) = __ccgo_fp(Xsqlite3_db_mutex) + *(*uintptr)(unsafe.Add(p, 1320)) = __ccgo_fp(Xsqlite3_db_status) + *(*uintptr)(unsafe.Add(p, 1328)) = __ccgo_fp(Xsqlite3_extended_errcode) + *(*uintptr)(unsafe.Add(p, 1336)) = __ccgo_fp(Xsqlite3_log) + *(*uintptr)(unsafe.Add(p, 1344)) = __ccgo_fp(Xsqlite3_soft_heap_limit64) + *(*uintptr)(unsafe.Add(p, 1352)) = __ccgo_fp(Xsqlite3_sourceid) + *(*uintptr)(unsafe.Add(p, 1360)) = __ccgo_fp(Xsqlite3_stmt_status) + *(*uintptr)(unsafe.Add(p, 1368)) = __ccgo_fp(Xsqlite3_strnicmp) + *(*uintptr)(unsafe.Add(p, 1376)) = __ccgo_fp(Xsqlite3_unlock_notify) + *(*uintptr)(unsafe.Add(p, 1384)) = __ccgo_fp(Xsqlite3_wal_autocheckpoint) + *(*uintptr)(unsafe.Add(p, 1392)) = __ccgo_fp(Xsqlite3_wal_checkpoint) + *(*uintptr)(unsafe.Add(p, 1400)) = __ccgo_fp(Xsqlite3_wal_hook) + *(*uintptr)(unsafe.Add(p, 1408)) = __ccgo_fp(Xsqlite3_blob_reopen) + *(*uintptr)(unsafe.Add(p, 1416)) = __ccgo_fp(Xsqlite3_vtab_config) + *(*uintptr)(unsafe.Add(p, 1424)) = __ccgo_fp(Xsqlite3_vtab_on_conflict) + *(*uintptr)(unsafe.Add(p, 1432)) = __ccgo_fp(Xsqlite3_close_v2) + *(*uintptr)(unsafe.Add(p, 1440)) = __ccgo_fp(Xsqlite3_db_filename) + *(*uintptr)(unsafe.Add(p, 1448)) = __ccgo_fp(Xsqlite3_db_readonly) + *(*uintptr)(unsafe.Add(p, 1456)) = __ccgo_fp(Xsqlite3_db_release_memory) + *(*uintptr)(unsafe.Add(p, 1464)) = __ccgo_fp(Xsqlite3_errstr) + *(*uintptr)(unsafe.Add(p, 1472)) = __ccgo_fp(Xsqlite3_stmt_busy) + *(*uintptr)(unsafe.Add(p, 1480)) = __ccgo_fp(Xsqlite3_stmt_readonly) + *(*uintptr)(unsafe.Add(p, 1488)) = __ccgo_fp(Xsqlite3_stricmp) + *(*uintptr)(unsafe.Add(p, 1496)) = __ccgo_fp(Xsqlite3_uri_boolean) + *(*uintptr)(unsafe.Add(p, 1504)) = __ccgo_fp(Xsqlite3_uri_int64) + *(*uintptr)(unsafe.Add(p, 1512)) = __ccgo_fp(Xsqlite3_uri_parameter) + *(*uintptr)(unsafe.Add(p, 1520)) = __ccgo_fp(Xsqlite3_vsnprintf) + *(*uintptr)(unsafe.Add(p, 1528)) = __ccgo_fp(Xsqlite3_wal_checkpoint_v2) + *(*uintptr)(unsafe.Add(p, 1536)) = __ccgo_fp(Xsqlite3_auto_extension) + *(*uintptr)(unsafe.Add(p, 1544)) = __ccgo_fp(Xsqlite3_bind_blob64) + *(*uintptr)(unsafe.Add(p, 1552)) = __ccgo_fp(Xsqlite3_bind_text64) + *(*uintptr)(unsafe.Add(p, 1560)) = __ccgo_fp(Xsqlite3_cancel_auto_extension) + *(*uintptr)(unsafe.Add(p, 1568)) = __ccgo_fp(Xsqlite3_load_extension) + *(*uintptr)(unsafe.Add(p, 1576)) = __ccgo_fp(Xsqlite3_malloc64) + *(*uintptr)(unsafe.Add(p, 1584)) = __ccgo_fp(Xsqlite3_msize) + *(*uintptr)(unsafe.Add(p, 1592)) = __ccgo_fp(Xsqlite3_realloc64) + *(*uintptr)(unsafe.Add(p, 1600)) = __ccgo_fp(Xsqlite3_reset_auto_extension) + *(*uintptr)(unsafe.Add(p, 1608)) = __ccgo_fp(Xsqlite3_result_blob64) + *(*uintptr)(unsafe.Add(p, 1616)) = __ccgo_fp(Xsqlite3_result_text64) + *(*uintptr)(unsafe.Add(p, 1624)) = __ccgo_fp(Xsqlite3_strglob) + *(*uintptr)(unsafe.Add(p, 1632)) = __ccgo_fp(Xsqlite3_value_dup) + *(*uintptr)(unsafe.Add(p, 1640)) = __ccgo_fp(Xsqlite3_value_free) + *(*uintptr)(unsafe.Add(p, 1648)) = __ccgo_fp(Xsqlite3_result_zeroblob64) + *(*uintptr)(unsafe.Add(p, 1656)) = __ccgo_fp(Xsqlite3_bind_zeroblob64) + *(*uintptr)(unsafe.Add(p, 1664)) = __ccgo_fp(Xsqlite3_value_subtype) + *(*uintptr)(unsafe.Add(p, 1672)) = __ccgo_fp(Xsqlite3_result_subtype) + *(*uintptr)(unsafe.Add(p, 1680)) = __ccgo_fp(Xsqlite3_status64) + *(*uintptr)(unsafe.Add(p, 1688)) = __ccgo_fp(Xsqlite3_strlike) + *(*uintptr)(unsafe.Add(p, 1696)) = __ccgo_fp(Xsqlite3_db_cacheflush) + *(*uintptr)(unsafe.Add(p, 1704)) = __ccgo_fp(Xsqlite3_system_errno) + *(*uintptr)(unsafe.Add(p, 1712)) = __ccgo_fp(Xsqlite3_trace_v2) + *(*uintptr)(unsafe.Add(p, 1720)) = __ccgo_fp(Xsqlite3_expanded_sql) + *(*uintptr)(unsafe.Add(p, 1728)) = __ccgo_fp(Xsqlite3_set_last_insert_rowid) + *(*uintptr)(unsafe.Add(p, 1736)) = __ccgo_fp(Xsqlite3_prepare_v3) + *(*uintptr)(unsafe.Add(p, 1744)) = __ccgo_fp(Xsqlite3_prepare16_v3) + *(*uintptr)(unsafe.Add(p, 1752)) = __ccgo_fp(Xsqlite3_bind_pointer) + *(*uintptr)(unsafe.Add(p, 1760)) = __ccgo_fp(Xsqlite3_result_pointer) + *(*uintptr)(unsafe.Add(p, 1768)) = __ccgo_fp(Xsqlite3_value_pointer) + *(*uintptr)(unsafe.Add(p, 1776)) = __ccgo_fp(Xsqlite3_vtab_nochange) + *(*uintptr)(unsafe.Add(p, 1784)) = __ccgo_fp(Xsqlite3_value_nochange) + *(*uintptr)(unsafe.Add(p, 1792)) = __ccgo_fp(Xsqlite3_vtab_collation) + *(*uintptr)(unsafe.Add(p, 1800)) = __ccgo_fp(Xsqlite3_keyword_count) + *(*uintptr)(unsafe.Add(p, 1808)) = __ccgo_fp(Xsqlite3_keyword_name) + *(*uintptr)(unsafe.Add(p, 1816)) = __ccgo_fp(Xsqlite3_keyword_check) + *(*uintptr)(unsafe.Add(p, 1824)) = __ccgo_fp(Xsqlite3_str_new) + *(*uintptr)(unsafe.Add(p, 1832)) = __ccgo_fp(Xsqlite3_str_finish) + *(*uintptr)(unsafe.Add(p, 1840)) = __ccgo_fp(Xsqlite3_str_appendf) + *(*uintptr)(unsafe.Add(p, 1848)) = __ccgo_fp(Xsqlite3_str_vappendf) + *(*uintptr)(unsafe.Add(p, 1856)) = __ccgo_fp(Xsqlite3_str_append) + *(*uintptr)(unsafe.Add(p, 1864)) = __ccgo_fp(Xsqlite3_str_appendall) + *(*uintptr)(unsafe.Add(p, 1872)) = __ccgo_fp(Xsqlite3_str_appendchar) + *(*uintptr)(unsafe.Add(p, 1880)) = __ccgo_fp(Xsqlite3_str_reset) + *(*uintptr)(unsafe.Add(p, 1888)) = __ccgo_fp(Xsqlite3_str_errcode) + *(*uintptr)(unsafe.Add(p, 1896)) = __ccgo_fp(Xsqlite3_str_length) + *(*uintptr)(unsafe.Add(p, 1904)) = __ccgo_fp(Xsqlite3_str_value) + *(*uintptr)(unsafe.Add(p, 1912)) = __ccgo_fp(Xsqlite3_create_window_function) + *(*uintptr)(unsafe.Add(p, 1928)) = __ccgo_fp(Xsqlite3_stmt_isexplain) + *(*uintptr)(unsafe.Add(p, 1936)) = __ccgo_fp(Xsqlite3_value_frombind) + *(*uintptr)(unsafe.Add(p, 1944)) = __ccgo_fp(Xsqlite3_drop_modules) + *(*uintptr)(unsafe.Add(p, 1952)) = __ccgo_fp(Xsqlite3_hard_heap_limit64) + *(*uintptr)(unsafe.Add(p, 1960)) = __ccgo_fp(Xsqlite3_uri_key) + *(*uintptr)(unsafe.Add(p, 1968)) = __ccgo_fp(Xsqlite3_filename_database) + *(*uintptr)(unsafe.Add(p, 1976)) = __ccgo_fp(Xsqlite3_filename_journal) + *(*uintptr)(unsafe.Add(p, 1984)) = __ccgo_fp(Xsqlite3_filename_wal) + *(*uintptr)(unsafe.Add(p, 1992)) = __ccgo_fp(Xsqlite3_create_filename) + *(*uintptr)(unsafe.Add(p, 2000)) = __ccgo_fp(Xsqlite3_free_filename) + *(*uintptr)(unsafe.Add(p, 2008)) = __ccgo_fp(Xsqlite3_database_file_object) + *(*uintptr)(unsafe.Add(p, 2016)) = __ccgo_fp(Xsqlite3_txn_state) + *(*uintptr)(unsafe.Add(p, 2024)) = __ccgo_fp(Xsqlite3_changes64) + *(*uintptr)(unsafe.Add(p, 2032)) = __ccgo_fp(Xsqlite3_total_changes64) + *(*uintptr)(unsafe.Add(p, 2040)) = __ccgo_fp(Xsqlite3_autovacuum_pages) + *(*uintptr)(unsafe.Add(p, 2048)) = __ccgo_fp(Xsqlite3_error_offset) + *(*uintptr)(unsafe.Add(p, 2056)) = __ccgo_fp(Xsqlite3_vtab_rhs_value) + *(*uintptr)(unsafe.Add(p, 2064)) = __ccgo_fp(Xsqlite3_vtab_distinct) + *(*uintptr)(unsafe.Add(p, 2072)) = __ccgo_fp(Xsqlite3_vtab_in) + *(*uintptr)(unsafe.Add(p, 2080)) = __ccgo_fp(Xsqlite3_vtab_in_first) + *(*uintptr)(unsafe.Add(p, 2088)) = __ccgo_fp(Xsqlite3_vtab_in_next) + *(*uintptr)(unsafe.Add(p, 2096)) = __ccgo_fp(Xsqlite3_deserialize) + *(*uintptr)(unsafe.Add(p, 2104)) = __ccgo_fp(Xsqlite3_serialize) + *(*uintptr)(unsafe.Add(p, 2112)) = __ccgo_fp(Xsqlite3_db_name) + *(*uintptr)(unsafe.Add(p, 2120)) = __ccgo_fp(Xsqlite3_value_encoding) + *(*uintptr)(unsafe.Add(p, 2128)) = __ccgo_fp(Xsqlite3_is_interrupted) + *(*uintptr)(unsafe.Add(p, 2136)) = __ccgo_fp(Xsqlite3_stmt_explain) + *(*uintptr)(unsafe.Add(p, 2144)) = __ccgo_fp(Xsqlite3_get_clientdata) + *(*uintptr)(unsafe.Add(p, 2152)) = __ccgo_fp(Xsqlite3_set_clientdata) + *(*uintptr)(unsafe.Add(p, 2160)) = __ccgo_fp(Xsqlite3_setlk_timeout) + *(*uintptr)(unsafe.Add(p, 2168)) = __ccgo_fp(Xsqlite3_set_errmsg) + *(*uintptr)(unsafe.Add(p, 2176)) = __ccgo_fp(Xsqlite3_db_status64) + *(*uintptr)(unsafe.Add(p, 2184)) = __ccgo_fp(Xsqlite3_str_truncate) + *(*uintptr)(unsafe.Add(p, 2192)) = __ccgo_fp(Xsqlite3_str_free) +} + +/* True if x is the directory separator character + */ + +func init() { + p := unsafe.Pointer(&_vfs_template) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_rbuVfsOpen) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_rbuVfsDelete) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_rbuVfsAccess) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_rbuVfsFullPathname) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_rbuVfsDlOpen) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_rbuVfsDlError) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_rbuVfsDlSym) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_rbuVfsDlClose) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_rbuVfsRandomness) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_rbuVfsSleep) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_rbuVfsCurrentTime) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_rbuVfsGetLastError) +} + +func init() { + p := unsafe.Pointer(&_statGetFuncdef) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_statGet) +} + +func init() { + p := unsafe.Pointer(&_jsonEachModule) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_jsonEachConnect) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_jsonEachBestIndex) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_jsonEachDisconnect) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_jsonEachOpen) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_jsonEachClose) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_jsonEachFilter) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_jsonEachNext) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_jsonEachEof) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_jsonEachColumn) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_jsonEachRowid) +} + +func init() { + p := unsafe.Pointer(&_memdb_vfs) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_memdbOpen) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_memdbAccess) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_memdbFullPathname) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_memdbDlOpen) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_memdbDlError) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_memdbDlSym) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_memdbDlClose) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_memdbRandomness) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_memdbSleep) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_memdbGetLastError) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_memdbCurrentTimeInt64) +} + +func init() { + p := unsafe.Pointer(&_aBuiltinFunc) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(_soundexFunc) + *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(_loadExt) + *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(_loadExt) + *(*uintptr)(unsafe.Add(p, 528)) = __ccgo_fp(_compileoptionusedFunc) + *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(_compileoptiongetFunc) + *(*uintptr)(unsafe.Add(p, 672)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 744)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 816)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 888)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 960)) = __ccgo_fp(_trimFunc) + *(*uintptr)(unsafe.Add(p, 1032)) = __ccgo_fp(_trimFunc) + *(*uintptr)(unsafe.Add(p, 1104)) = __ccgo_fp(_trimFunc) + *(*uintptr)(unsafe.Add(p, 1176)) = __ccgo_fp(_trimFunc) + *(*uintptr)(unsafe.Add(p, 1248)) = __ccgo_fp(_trimFunc) + *(*uintptr)(unsafe.Add(p, 1320)) = __ccgo_fp(_trimFunc) + *(*uintptr)(unsafe.Add(p, 1392)) = __ccgo_fp(_minmaxFunc) + *(*uintptr)(unsafe.Add(p, 1464)) = __ccgo_fp(_minmaxStep) + *(*uintptr)(unsafe.Add(p, 1472)) = __ccgo_fp(_minMaxFinalize) + *(*uintptr)(unsafe.Add(p, 1480)) = __ccgo_fp(_minMaxValue) + *(*uintptr)(unsafe.Add(p, 1536)) = __ccgo_fp(_minmaxFunc) + *(*uintptr)(unsafe.Add(p, 1608)) = __ccgo_fp(_minmaxStep) + *(*uintptr)(unsafe.Add(p, 1616)) = __ccgo_fp(_minMaxFinalize) + *(*uintptr)(unsafe.Add(p, 1624)) = __ccgo_fp(_minMaxValue) + *(*uintptr)(unsafe.Add(p, 1680)) = __ccgo_fp(_typeofFunc) + *(*uintptr)(unsafe.Add(p, 1752)) = __ccgo_fp(_subtypeFunc) + *(*uintptr)(unsafe.Add(p, 1824)) = __ccgo_fp(_lengthFunc) + *(*uintptr)(unsafe.Add(p, 1896)) = __ccgo_fp(_bytelengthFunc) + *(*uintptr)(unsafe.Add(p, 1968)) = __ccgo_fp(_instrFunc) + *(*uintptr)(unsafe.Add(p, 2040)) = __ccgo_fp(_printfFunc) + *(*uintptr)(unsafe.Add(p, 2112)) = __ccgo_fp(_printfFunc) + *(*uintptr)(unsafe.Add(p, 2184)) = __ccgo_fp(_unicodeFunc) + *(*uintptr)(unsafe.Add(p, 2256)) = __ccgo_fp(_charFunc) + *(*uintptr)(unsafe.Add(p, 2328)) = __ccgo_fp(_absFunc) + *(*uintptr)(unsafe.Add(p, 2400)) = __ccgo_fp(_roundFunc) + *(*uintptr)(unsafe.Add(p, 2472)) = __ccgo_fp(_roundFunc) + *(*uintptr)(unsafe.Add(p, 2544)) = __ccgo_fp(_upperFunc) + *(*uintptr)(unsafe.Add(p, 2616)) = __ccgo_fp(_lowerFunc) + *(*uintptr)(unsafe.Add(p, 2688)) = __ccgo_fp(_hexFunc) + *(*uintptr)(unsafe.Add(p, 2760)) = __ccgo_fp(_unhexFunc) + *(*uintptr)(unsafe.Add(p, 2832)) = __ccgo_fp(_unhexFunc) + *(*uintptr)(unsafe.Add(p, 2904)) = __ccgo_fp(_concatFunc) + *(*uintptr)(unsafe.Add(p, 2976)) = __ccgo_fp(_concatwsFunc) + *(*uintptr)(unsafe.Add(p, 3048)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 3120)) = __ccgo_fp(_randomFunc) + *(*uintptr)(unsafe.Add(p, 3192)) = __ccgo_fp(_randomBlob) + *(*uintptr)(unsafe.Add(p, 3264)) = __ccgo_fp(_nullifFunc) + *(*uintptr)(unsafe.Add(p, 3336)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 3408)) = __ccgo_fp(_sourceidFunc) + *(*uintptr)(unsafe.Add(p, 3480)) = __ccgo_fp(_errlogFunc) + *(*uintptr)(unsafe.Add(p, 3552)) = __ccgo_fp(_unistrFunc) + *(*uintptr)(unsafe.Add(p, 3624)) = __ccgo_fp(_quoteFunc) + *(*uintptr)(unsafe.Add(p, 3696)) = __ccgo_fp(_quoteFunc) + *(*uintptr)(unsafe.Add(p, 3768)) = __ccgo_fp(_last_insert_rowid) + *(*uintptr)(unsafe.Add(p, 3840)) = __ccgo_fp(_changes) + *(*uintptr)(unsafe.Add(p, 3912)) = __ccgo_fp(_total_changes) + *(*uintptr)(unsafe.Add(p, 3984)) = __ccgo_fp(_replaceFunc) + *(*uintptr)(unsafe.Add(p, 4056)) = __ccgo_fp(_zeroblobFunc) + *(*uintptr)(unsafe.Add(p, 4128)) = __ccgo_fp(_substrFunc) + *(*uintptr)(unsafe.Add(p, 4200)) = __ccgo_fp(_substrFunc) + *(*uintptr)(unsafe.Add(p, 4272)) = __ccgo_fp(_substrFunc) + *(*uintptr)(unsafe.Add(p, 4344)) = __ccgo_fp(_substrFunc) + *(*uintptr)(unsafe.Add(p, 4416)) = __ccgo_fp(_sumStep) + *(*uintptr)(unsafe.Add(p, 4424)) = __ccgo_fp(_sumFinalize) + *(*uintptr)(unsafe.Add(p, 4432)) = __ccgo_fp(_sumFinalize) + *(*uintptr)(unsafe.Add(p, 4440)) = __ccgo_fp(_sumInverse) + *(*uintptr)(unsafe.Add(p, 4488)) = __ccgo_fp(_sumStep) + *(*uintptr)(unsafe.Add(p, 4496)) = __ccgo_fp(_totalFinalize) + *(*uintptr)(unsafe.Add(p, 4504)) = __ccgo_fp(_totalFinalize) + *(*uintptr)(unsafe.Add(p, 4512)) = __ccgo_fp(_sumInverse) + *(*uintptr)(unsafe.Add(p, 4560)) = __ccgo_fp(_sumStep) + *(*uintptr)(unsafe.Add(p, 4568)) = __ccgo_fp(_avgFinalize) + *(*uintptr)(unsafe.Add(p, 4576)) = __ccgo_fp(_avgFinalize) + *(*uintptr)(unsafe.Add(p, 4584)) = __ccgo_fp(_sumInverse) + *(*uintptr)(unsafe.Add(p, 4632)) = __ccgo_fp(_countStep) + *(*uintptr)(unsafe.Add(p, 4640)) = __ccgo_fp(_countFinalize) + *(*uintptr)(unsafe.Add(p, 4648)) = __ccgo_fp(_countFinalize) + *(*uintptr)(unsafe.Add(p, 4656)) = __ccgo_fp(_countInverse) + *(*uintptr)(unsafe.Add(p, 4704)) = __ccgo_fp(_countStep) + *(*uintptr)(unsafe.Add(p, 4712)) = __ccgo_fp(_countFinalize) + *(*uintptr)(unsafe.Add(p, 4720)) = __ccgo_fp(_countFinalize) + *(*uintptr)(unsafe.Add(p, 4728)) = __ccgo_fp(_countInverse) + *(*uintptr)(unsafe.Add(p, 4776)) = __ccgo_fp(_groupConcatStep) + *(*uintptr)(unsafe.Add(p, 4784)) = __ccgo_fp(_groupConcatFinalize) + *(*uintptr)(unsafe.Add(p, 4792)) = __ccgo_fp(_groupConcatValue) + *(*uintptr)(unsafe.Add(p, 4800)) = __ccgo_fp(_groupConcatInverse) + *(*uintptr)(unsafe.Add(p, 4848)) = __ccgo_fp(_groupConcatStep) + *(*uintptr)(unsafe.Add(p, 4856)) = __ccgo_fp(_groupConcatFinalize) + *(*uintptr)(unsafe.Add(p, 4864)) = __ccgo_fp(_groupConcatValue) + *(*uintptr)(unsafe.Add(p, 4872)) = __ccgo_fp(_groupConcatInverse) + *(*uintptr)(unsafe.Add(p, 4920)) = __ccgo_fp(_groupConcatStep) + *(*uintptr)(unsafe.Add(p, 4928)) = __ccgo_fp(_groupConcatFinalize) + *(*uintptr)(unsafe.Add(p, 4936)) = __ccgo_fp(_groupConcatValue) + *(*uintptr)(unsafe.Add(p, 4944)) = __ccgo_fp(_groupConcatInverse) + *(*uintptr)(unsafe.Add(p, 4992)) = __ccgo_fp(_likeFunc) + *(*uintptr)(unsafe.Add(p, 5064)) = __ccgo_fp(_likeFunc) + *(*uintptr)(unsafe.Add(p, 5136)) = __ccgo_fp(_likeFunc) + *(*uintptr)(unsafe.Add(p, 5192)) = __ccgo_fp(_xCeil) + *(*uintptr)(unsafe.Add(p, 5208)) = __ccgo_fp(_ceilingFunc) + *(*uintptr)(unsafe.Add(p, 5264)) = __ccgo_fp(_xCeil) + *(*uintptr)(unsafe.Add(p, 5280)) = __ccgo_fp(_ceilingFunc) + *(*uintptr)(unsafe.Add(p, 5336)) = __ccgo_fp(_xFloor) + *(*uintptr)(unsafe.Add(p, 5352)) = __ccgo_fp(_ceilingFunc) + *(*uintptr)(unsafe.Add(p, 5408)) = __ccgo_fp(libc.Xtrunc) + *(*uintptr)(unsafe.Add(p, 5424)) = __ccgo_fp(_ceilingFunc) + *(*uintptr)(unsafe.Add(p, 5496)) = __ccgo_fp(_logFunc) + *(*uintptr)(unsafe.Add(p, 5568)) = __ccgo_fp(_logFunc) + *(*uintptr)(unsafe.Add(p, 5640)) = __ccgo_fp(_logFunc) + *(*uintptr)(unsafe.Add(p, 5712)) = __ccgo_fp(_logFunc) + *(*uintptr)(unsafe.Add(p, 5784)) = __ccgo_fp(_logFunc) + *(*uintptr)(unsafe.Add(p, 5840)) = __ccgo_fp(libc.Xexp) + *(*uintptr)(unsafe.Add(p, 5856)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 5912)) = __ccgo_fp(libc.Xpow) + *(*uintptr)(unsafe.Add(p, 5928)) = __ccgo_fp(_math2Func) + *(*uintptr)(unsafe.Add(p, 5984)) = __ccgo_fp(libc.Xpow) + *(*uintptr)(unsafe.Add(p, 6000)) = __ccgo_fp(_math2Func) + *(*uintptr)(unsafe.Add(p, 6056)) = __ccgo_fp(libc.Xfmod) + *(*uintptr)(unsafe.Add(p, 6072)) = __ccgo_fp(_math2Func) + *(*uintptr)(unsafe.Add(p, 6128)) = __ccgo_fp(libc.Xacos) + *(*uintptr)(unsafe.Add(p, 6144)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6200)) = __ccgo_fp(libc.Xasin) + *(*uintptr)(unsafe.Add(p, 6216)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6272)) = __ccgo_fp(libc.Xatan) + *(*uintptr)(unsafe.Add(p, 6288)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6344)) = __ccgo_fp(libc.Xatan2) + *(*uintptr)(unsafe.Add(p, 6360)) = __ccgo_fp(_math2Func) + *(*uintptr)(unsafe.Add(p, 6416)) = __ccgo_fp(libc.Xcos) + *(*uintptr)(unsafe.Add(p, 6432)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6488)) = __ccgo_fp(libc.Xsin) + *(*uintptr)(unsafe.Add(p, 6504)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6560)) = __ccgo_fp(libc.Xtan) + *(*uintptr)(unsafe.Add(p, 6576)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6632)) = __ccgo_fp(libc.Xcosh) + *(*uintptr)(unsafe.Add(p, 6648)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6704)) = __ccgo_fp(libc.Xsinh) + *(*uintptr)(unsafe.Add(p, 6720)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6776)) = __ccgo_fp(libc.Xtanh) + *(*uintptr)(unsafe.Add(p, 6792)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6848)) = __ccgo_fp(libc.Xacosh) + *(*uintptr)(unsafe.Add(p, 6864)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6920)) = __ccgo_fp(libc.Xasinh) + *(*uintptr)(unsafe.Add(p, 6936)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 6992)) = __ccgo_fp(libc.Xatanh) + *(*uintptr)(unsafe.Add(p, 7008)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 7064)) = __ccgo_fp(libc.Xsqrt) + *(*uintptr)(unsafe.Add(p, 7080)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 7136)) = __ccgo_fp(_degToRad) + *(*uintptr)(unsafe.Add(p, 7152)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 7208)) = __ccgo_fp(_radToDeg) + *(*uintptr)(unsafe.Add(p, 7224)) = __ccgo_fp(_math1Func) + *(*uintptr)(unsafe.Add(p, 7296)) = __ccgo_fp(_piFunc) + *(*uintptr)(unsafe.Add(p, 7368)) = __ccgo_fp(_signFunc) + *(*uintptr)(unsafe.Add(p, 7440)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 7512)) = __ccgo_fp(_versionFunc) + *(*uintptr)(unsafe.Add(p, 7584)) = __ccgo_fp(_versionFunc) +} + +/************** End of func.c ************************************************/ +/************** Begin file fkey.c ********************************************/ +/* +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used by the compiler to add foreign key +** support to compiled SQL statements. + */ +/* #include "sqliteInt.h" */ + +/* +** Deferred and Immediate FKs +** -------------------------- +** +** Foreign keys in SQLite come in two flavours: deferred and immediate. +** If an immediate foreign key constraint is violated, +** SQLITE_CONSTRAINT_FOREIGNKEY is returned and the current +** statement transaction rolled back. If a +** deferred foreign key constraint is violated, no action is taken +** immediately. However if the application attempts to commit the +** transaction before fixing the constraint violation, the attempt fails. +** +** Deferred constraints are implemented using a simple counter associated +** with the database handle. The counter is set to zero each time a +** database transaction is opened. Each time a statement is executed +** that causes a foreign key violation, the counter is incremented. Each +** time a statement is executed that removes an existing violation from +** the database, the counter is decremented. When the transaction is +** committed, the commit fails if the current value of the counter is +** greater than zero. This scheme has two big drawbacks: +** +** * When a commit fails due to a deferred foreign key constraint, +** there is no way to tell which foreign constraint is not satisfied, +** or which row it is not satisfied for. +** +** * If the database contains foreign key violations when the +** transaction is opened, this may cause the mechanism to malfunction. +** +** Despite these problems, this approach is adopted as it seems simpler +** than the alternatives. +** +** INSERT operations: +** +** I.1) For each FK for which the table is the child table, search +** the parent table for a match. If none is found increment the +** constraint counter. +** +** I.2) For each FK for which the table is the parent table, +** search the child table for rows that correspond to the new +** row in the parent table. Decrement the counter for each row +** found (as the constraint is now satisfied). +** +** DELETE operations: +** +** D.1) For each FK for which the table is the child table, +** search the parent table for a row that corresponds to the +** deleted row in the child table. If such a row is not found, +** decrement the counter. +** +** D.2) For each FK for which the table is the parent table, search +** the child table for rows that correspond to the deleted row +** in the parent table. For each found increment the counter. +** +** UPDATE operations: +** +** An UPDATE command requires that all 4 steps above are taken, but only +** for FK constraints for which the affected columns are actually +** modified (values must be compared at runtime). +** +** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2. +** This simplifies the implementation a bit. +** +** For the purposes of immediate FK constraints, the OR REPLACE conflict +** resolution is considered to delete rows before the new row is inserted. +** If a delete caused by OR REPLACE violates an FK constraint, an exception +** is thrown, even if the FK constraint would be satisfied after the new +** row is inserted. +** +** Immediate constraints are usually handled similarly. The only difference +** is that the counter used is stored as part of each individual statement +** object (struct Vdbe). If, after the statement has run, its immediate +** constraint counter is greater than zero, +** it returns SQLITE_CONSTRAINT_FOREIGNKEY +** and the statement transaction is rolled back. An exception is an INSERT +** statement that inserts a single row only (no triggers). In this case, +** instead of using a counter, an exception is thrown immediately if the +** INSERT violates a foreign key constraint. This is necessary as such +** an INSERT does not open a statement transaction. +** +** TODO: How should dropping a table be handled? How should renaming a +** table be handled? +** +** +** Query API Notes +** --------------- +** +** Before coding an UPDATE or DELETE row operation, the code-generator +** for those two operations needs to know whether or not the operation +** requires any FK processing and, if so, which columns of the original +** row are required by the FK processing VDBE code (i.e. if FKs were +** implemented using triggers, which of the old.* columns would be +** accessed). No information is required by the code-generator before +** coding an INSERT operation. The functions used by the UPDATE/DELETE +** generation code to query for this information are: +** +** sqlite3FkRequired() - Test to see if FK processing is required. +** sqlite3FkOldmask() - Query for the set of required old.* columns. +** +** +** Externally accessible module functions +** -------------------------------------- +** +** sqlite3FkCheck() - Check for foreign key violations. +** sqlite3FkActions() - Code triggers for ON UPDATE/ON DELETE actions. +** sqlite3FkDelete() - Delete an FKey structure. + */ + +/* +** VDBE Calling Convention +** ----------------------- +** +** Example: +** +** For the following INSERT statement: +** +** CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c); +** INSERT INTO t1 VALUES(1, 2, 3.1); +** +** Register (x): 2 (type integer) +** Register (x+1): 1 (type integer) +** Register (x+2): NULL (type NULL) +** Register (x+3): 3.1 (type real) + */ + +func init() { + p := unsafe.Pointer(&_fts5Mod) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_fts5CreateMethod) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_fts5ConnectMethod) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_fts5BestIndexMethod) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_fts5DisconnectMethod) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_fts5DestroyMethod) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_fts5OpenMethod) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_fts5CloseMethod) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_fts5FilterMethod) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_fts5NextMethod) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_fts5EofMethod) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_fts5ColumnMethod) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_fts5RowidMethod) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_fts5UpdateMethod) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_fts5BeginMethod) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_fts5SyncMethod) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_fts5CommitMethod) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_fts5RollbackMethod) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_fts5FindFunctionMethod) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(_fts5RenameMethod) + *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_fts5SavepointMethod) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(_fts5ReleaseMethod) + *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(_fts5RollbackToMethod) + *(*uintptr)(unsafe.Add(p, 184)) = __ccgo_fp(_fts5ShadowName) + *(*uintptr)(unsafe.Add(p, 192)) = __ccgo_fp(_fts5IntegrityMethod) +} + +func init() { + p := unsafe.Pointer(&_rbuvfs_io_methods1) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_rbuVfsClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_rbuVfsRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_rbuVfsWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_rbuVfsTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_rbuVfsSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_rbuVfsFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_rbuVfsLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_rbuVfsUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_rbuVfsCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_rbuVfsFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_rbuVfsSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_rbuVfsDeviceCharacteristics) +} + +func init() { + p := unsafe.Pointer(&_rbuvfs_io_methods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_rbuVfsClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_rbuVfsRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_rbuVfsWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_rbuVfsTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_rbuVfsSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_rbuVfsFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_rbuVfsLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_rbuVfsUnlock) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_rbuVfsCheckReservedLock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_rbuVfsFileControl) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_rbuVfsSectorSize) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_rbuVfsDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_rbuVfsShmMap) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_rbuVfsShmLock) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_rbuVfsShmBarrier) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_rbuVfsShmUnmap) +} + +func init() { + p := unsafe.Pointer(&_aWindowFuncs) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_row_numberStepFunc) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_row_numberValueFunc) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_row_numberValueFunc) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_dense_rankStepFunc) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_dense_rankValueFunc) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_dense_rankValueFunc) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(_rankStepFunc) + *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(_rankValueFunc) + *(*uintptr)(unsafe.Add(p, 184)) = __ccgo_fp(_rankValueFunc) + *(*uintptr)(unsafe.Add(p, 192)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(_percent_rankStepFunc) + *(*uintptr)(unsafe.Add(p, 248)) = __ccgo_fp(_percent_rankValueFunc) + *(*uintptr)(unsafe.Add(p, 256)) = __ccgo_fp(_percent_rankValueFunc) + *(*uintptr)(unsafe.Add(p, 264)) = __ccgo_fp(_percent_rankInvFunc) + *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(_cume_distStepFunc) + *(*uintptr)(unsafe.Add(p, 320)) = __ccgo_fp(_cume_distValueFunc) + *(*uintptr)(unsafe.Add(p, 328)) = __ccgo_fp(_cume_distValueFunc) + *(*uintptr)(unsafe.Add(p, 336)) = __ccgo_fp(_cume_distInvFunc) + *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(_ntileStepFunc) + *(*uintptr)(unsafe.Add(p, 392)) = __ccgo_fp(_ntileValueFunc) + *(*uintptr)(unsafe.Add(p, 400)) = __ccgo_fp(_ntileValueFunc) + *(*uintptr)(unsafe.Add(p, 408)) = __ccgo_fp(_ntileInvFunc) + *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(_last_valueStepFunc) + *(*uintptr)(unsafe.Add(p, 464)) = __ccgo_fp(_last_valueFinalizeFunc) + *(*uintptr)(unsafe.Add(p, 472)) = __ccgo_fp(_last_valueValueFunc) + *(*uintptr)(unsafe.Add(p, 480)) = __ccgo_fp(_last_valueInvFunc) + *(*uintptr)(unsafe.Add(p, 528)) = __ccgo_fp(_nth_valueStepFunc) + *(*uintptr)(unsafe.Add(p, 536)) = __ccgo_fp(_nth_valueFinalizeFunc) + *(*uintptr)(unsafe.Add(p, 544)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 552)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(_first_valueStepFunc) + *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(_first_valueFinalizeFunc) + *(*uintptr)(unsafe.Add(p, 616)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 624)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 672)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 680)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 688)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 696)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 744)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 752)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 760)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 768)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 816)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 824)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 832)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 840)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 888)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 896)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 904)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 912)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 960)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 968)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 976)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 984)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 1032)) = __ccgo_fp(_noopStepFunc) + *(*uintptr)(unsafe.Add(p, 1040)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 1048)) = __ccgo_fp(_noopValueFunc) + *(*uintptr)(unsafe.Add(p, 1056)) = __ccgo_fp(_noopStepFunc) +} + +func init() { + p := unsafe.Pointer(&_rtreeModule) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_rtreeCreate) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_rtreeConnect) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_rtreeBestIndex) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_rtreeDisconnect) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_rtreeDestroy) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_rtreeOpen) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_rtreeClose) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_rtreeFilter) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_rtreeNext) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_rtreeEof) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_rtreeColumn) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_rtreeRowid) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_rtreeUpdate) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_rtreeBeginTransaction) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_rtreeEndTransaction) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_rtreeEndTransaction) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_rtreeRollback) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(_rtreeRename) + *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_rtreeSavepoint) + *(*uintptr)(unsafe.Add(p, 184)) = __ccgo_fp(_rtreeShadowName) + *(*uintptr)(unsafe.Add(p, 192)) = __ccgo_fp(_rtreeIntegrity) +} + +func init() { + p := unsafe.Pointer(&_MemJournalMethods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_memjrnlClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_memjrnlRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_memjrnlWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_memjrnlTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_memjrnlSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_memjrnlFileSize) +} + +func init() { + p := unsafe.Pointer(&_defaultMethods1) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_pcache1Init) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_pcache1Shutdown) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_pcache1Create) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_pcache1Cachesize) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_pcache1Pagecount) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_pcache1Fetch) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_pcache1Unpin) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_pcache1Rekey) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_pcache1Truncate) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_pcache1Destroy) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_pcache1Shrink) +} + +func init() { + p := unsafe.Pointer(&_dbstat_module) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_statConnect) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_statConnect) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_statBestIndex) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_statDisconnect) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_statDisconnect) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_statOpen) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_statClose) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_statFilter) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_statNext) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_statEof) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_statColumn) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_statRowid) +} + +/************** End of dbstat.c **********************************************/ +/************** Begin file dbpage.c ******************************************/ +/* +** 2017-10-11 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains an implementation of the "sqlite_dbpage" virtual table. +** +** The sqlite_dbpage virtual table is used to read or write whole raw +** pages of the database file. The pager interface is used so that +** uncommitted changes and changes recorded in the WAL file are correctly +** retrieved. +** +** Usage example: +** +** SELECT data FROM sqlite_dbpage('aux1') WHERE pgno=123; +** +** This is an eponymous virtual table so it does not need to be created before +** use. The optional argument to the sqlite_dbpage() table name is the +** schema for the database file that is to be read. The default schema is +** "main". +** +** The data field of sqlite_dbpage table can be updated. The new +** value must be a BLOB which is the correct page size, otherwise the +** update fails. INSERT operations also work, and operate as if they +** where REPLACE. The size of the database can be extended by INSERT-ing +** new pages on the end. +** +** Rows may not be deleted. However, doing an INSERT to page number N +** with NULL page data causes the N-th page and all subsequent pages to be +** deleted and the database to be truncated. + */ + +/* #include "sqliteInt.h" ** Requires access to internal data structures ** */ + +func init() { + p := unsafe.Pointer(&_aDateTimeFuncs) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_juliandayFunc) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_unixepochFunc) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(_dateFunc) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(_timeFunc) + *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(_datetimeFunc) + *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(_strftimeFunc) + *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(_timediffFunc) + *(*uintptr)(unsafe.Add(p, 528)) = __ccgo_fp(_ctimeFunc) + *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(_ctimestampFunc) + *(*uintptr)(unsafe.Add(p, 672)) = __ccgo_fp(_cdateFunc) +} + +/************** End of date.c ************************************************/ +/************** Begin file os.c **********************************************/ +/* +** 2005 November 29 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains OS interface code that is common to all +** architectures. + */ +/* #include "sqliteInt.h" */ + +/* +** If we compile with the SQLITE_TEST macro set, then the following block +** of code will give us the ability to simulate a disk I/O error. This +** is used for testing the I/O recovery logic. + */ + +/* +** When testing, also keep a count of the number of open files. + */ + +/* +** The default SQLite sqlite3_vfs implementations do not allocate +** memory (actually, os_unix.c allocates a small amount of memory +** from within OsOpen()), but some third-party implementations may. +** So we test the effects of a malloc() failing and the sqlite3OsXXX() +** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro. +** +** The following functions are instrumented for malloc() failure +** testing: +** +** sqlite3OsRead() +** sqlite3OsWrite() +** sqlite3OsSync() +** sqlite3OsFileSize() +** sqlite3OsLock() +** sqlite3OsCheckReservedLock() +** sqlite3OsFileControl() +** sqlite3OsShmMap() +** sqlite3OsOpen() +** sqlite3OsDelete() +** sqlite3OsAccess() +** sqlite3OsFullPathname() +** + */ + +func init() { + p := unsafe.Pointer(&_pragmaVtabModule) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_pragmaVtabConnect) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_pragmaVtabBestIndex) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_pragmaVtabDisconnect) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_pragmaVtabOpen) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_pragmaVtabClose) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_pragmaVtabFilter) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_pragmaVtabNext) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_pragmaVtabEof) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_pragmaVtabColumn) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_pragmaVtabRowid) +} + +func init() { + p := unsafe.Pointer(&_geopolyModule) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_geopolyCreate) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_geopolyConnect) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_geopolyBestIndex) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_rtreeDisconnect) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_rtreeDestroy) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_rtreeOpen) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_rtreeClose) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_geopolyFilter) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_rtreeNext) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_rtreeEof) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_geopolyColumn) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_rtreeRowid) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_geopolyUpdate) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_rtreeBeginTransaction) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_rtreeEndTransaction) + *(*uintptr)(unsafe.Add(p, 128)) = __ccgo_fp(_rtreeEndTransaction) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_rtreeEndTransaction) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_geopolyFindFunction) + *(*uintptr)(unsafe.Add(p, 152)) = __ccgo_fp(_rtreeRename) + *(*uintptr)(unsafe.Add(p, 160)) = __ccgo_fp(_rtreeSavepoint) + *(*uintptr)(unsafe.Add(p, 184)) = __ccgo_fp(_rtreeShadowName) + *(*uintptr)(unsafe.Add(p, 192)) = __ccgo_fp(_rtreeIntegrity) +} + +func init() { + p := unsafe.Pointer(&_dbpage_module) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_dbpageConnect) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_dbpageConnect) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_dbpageBestIndex) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_dbpageDisconnect) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_dbpageDisconnect) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_dbpageOpen) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_dbpageClose) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_dbpageFilter) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_dbpageNext) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_dbpageEof) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_dbpageColumn) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_dbpageRowid) + *(*uintptr)(unsafe.Add(p, 104)) = __ccgo_fp(_dbpageUpdate) + *(*uintptr)(unsafe.Add(p, 112)) = __ccgo_fp(_dbpageBegin) + *(*uintptr)(unsafe.Add(p, 120)) = __ccgo_fp(_dbpageSync) + *(*uintptr)(unsafe.Add(p, 176)) = __ccgo_fp(_dbpageRollbackTo) +} + +/************** End of dbpage.c **********************************************/ +/************** Begin file carray.c ******************************************/ +/* +** 2016-06-29 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file implements a table-valued-function that +** returns the values in a C-language array. +** Examples: +** +** SELECT * FROM carray($ptr,5) +** +** The query above returns 5 integers contained in a C-language array +** at the address $ptr. $ptr is a pointer to the array of integers. +** The pointer value must be assigned to $ptr using the +** sqlite3_bind_pointer() interface with a pointer type of "carray". +** For example: +** +** static int aX[] = { 53, 9, 17, 2231, 4, 99 }; +** int i = sqlite3_bind_parameter_index(pStmt, "$ptr"); +** sqlite3_bind_pointer(pStmt, i, aX, "carray", 0); +** +** There is an optional third parameter to determine the datatype of +** the C-language array. Allowed values of the third parameter are +** 'int32', 'int64', 'double', 'char*', 'struct iovec'. Example: +** +** SELECT * FROM carray($ptr,10,'char*'); +** +** The default value of the third parameter is 'int32'. +** +** HOW IT WORKS +** +** The carray "function" is really a virtual table with the +** following schema: +** +** CREATE TABLE carray( +** value, +** pointer HIDDEN, +** count HIDDEN, +** ctype TEXT HIDDEN +** ); +** +** If the hidden columns "pointer" and "count" are unconstrained, then +** the virtual table has no rows. Otherwise, the virtual table interprets +** the integer value of "pointer" as a pointer to the array and "count" +** as the number of elements in the array. The virtual table steps through +** the array, element by element. + */ + +/************** End of carray.c **********************************************/ +/************** Begin file sqlite3session.c **********************************/ + +/* #include "sqlite3session.h" */ +/* #include */ +/* #include */ + +func init() { + p := unsafe.Pointer(&_aJsonFunc) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_jsonRemoveFunc) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_jsonRemoveFunc) + *(*uintptr)(unsafe.Add(p, 168)) = __ccgo_fp(_jsonArrayFunc) + *(*uintptr)(unsafe.Add(p, 240)) = __ccgo_fp(_jsonArrayFunc) + *(*uintptr)(unsafe.Add(p, 312)) = __ccgo_fp(_jsonSetFunc) + *(*uintptr)(unsafe.Add(p, 384)) = __ccgo_fp(_jsonSetFunc) + *(*uintptr)(unsafe.Add(p, 456)) = __ccgo_fp(_jsonArrayLengthFunc) + *(*uintptr)(unsafe.Add(p, 528)) = __ccgo_fp(_jsonArrayLengthFunc) + *(*uintptr)(unsafe.Add(p, 600)) = __ccgo_fp(_jsonErrorFunc) + *(*uintptr)(unsafe.Add(p, 672)) = __ccgo_fp(_jsonExtractFunc) + *(*uintptr)(unsafe.Add(p, 744)) = __ccgo_fp(_jsonExtractFunc) + *(*uintptr)(unsafe.Add(p, 816)) = __ccgo_fp(_jsonExtractFunc) + *(*uintptr)(unsafe.Add(p, 888)) = __ccgo_fp(_jsonExtractFunc) + *(*uintptr)(unsafe.Add(p, 960)) = __ccgo_fp(_jsonSetFunc) + *(*uintptr)(unsafe.Add(p, 1032)) = __ccgo_fp(_jsonSetFunc) + *(*uintptr)(unsafe.Add(p, 1104)) = __ccgo_fp(_jsonObjectFunc) + *(*uintptr)(unsafe.Add(p, 1176)) = __ccgo_fp(_jsonObjectFunc) + *(*uintptr)(unsafe.Add(p, 1248)) = __ccgo_fp(_jsonPatchFunc) + *(*uintptr)(unsafe.Add(p, 1320)) = __ccgo_fp(_jsonPatchFunc) + *(*uintptr)(unsafe.Add(p, 1392)) = __ccgo_fp(_jsonPrettyFunc) + *(*uintptr)(unsafe.Add(p, 1464)) = __ccgo_fp(_jsonPrettyFunc) + *(*uintptr)(unsafe.Add(p, 1536)) = __ccgo_fp(_jsonQuoteFunc) + *(*uintptr)(unsafe.Add(p, 1608)) = __ccgo_fp(_jsonRemoveFunc) + *(*uintptr)(unsafe.Add(p, 1680)) = __ccgo_fp(_jsonRemoveFunc) + *(*uintptr)(unsafe.Add(p, 1752)) = __ccgo_fp(_jsonReplaceFunc) + *(*uintptr)(unsafe.Add(p, 1824)) = __ccgo_fp(_jsonReplaceFunc) + *(*uintptr)(unsafe.Add(p, 1896)) = __ccgo_fp(_jsonSetFunc) + *(*uintptr)(unsafe.Add(p, 1968)) = __ccgo_fp(_jsonSetFunc) + *(*uintptr)(unsafe.Add(p, 2040)) = __ccgo_fp(_jsonTypeFunc) + *(*uintptr)(unsafe.Add(p, 2112)) = __ccgo_fp(_jsonTypeFunc) + *(*uintptr)(unsafe.Add(p, 2184)) = __ccgo_fp(_jsonValidFunc) + *(*uintptr)(unsafe.Add(p, 2256)) = __ccgo_fp(_jsonValidFunc) + *(*uintptr)(unsafe.Add(p, 2328)) = __ccgo_fp(_jsonArrayStep) + *(*uintptr)(unsafe.Add(p, 2336)) = __ccgo_fp(_jsonArrayFinal) + *(*uintptr)(unsafe.Add(p, 2344)) = __ccgo_fp(_jsonArrayValue) + *(*uintptr)(unsafe.Add(p, 2352)) = __ccgo_fp(_jsonGroupInverse) + *(*uintptr)(unsafe.Add(p, 2400)) = __ccgo_fp(_jsonArrayStep) + *(*uintptr)(unsafe.Add(p, 2408)) = __ccgo_fp(_jsonArrayFinal) + *(*uintptr)(unsafe.Add(p, 2416)) = __ccgo_fp(_jsonArrayValue) + *(*uintptr)(unsafe.Add(p, 2424)) = __ccgo_fp(_jsonGroupInverse) + *(*uintptr)(unsafe.Add(p, 2472)) = __ccgo_fp(_jsonObjectStep) + *(*uintptr)(unsafe.Add(p, 2480)) = __ccgo_fp(_jsonObjectFinal) + *(*uintptr)(unsafe.Add(p, 2488)) = __ccgo_fp(_jsonObjectValue) + *(*uintptr)(unsafe.Add(p, 2496)) = __ccgo_fp(_jsonGroupInverse) + *(*uintptr)(unsafe.Add(p, 2544)) = __ccgo_fp(_jsonObjectStep) + *(*uintptr)(unsafe.Add(p, 2552)) = __ccgo_fp(_jsonObjectFinal) + *(*uintptr)(unsafe.Add(p, 2560)) = __ccgo_fp(_jsonObjectValue) + *(*uintptr)(unsafe.Add(p, 2568)) = __ccgo_fp(_jsonGroupInverse) +} + +func init() { + p := unsafe.Pointer(&_statInitFuncdef) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_statInit) +} + +func init() { + p := unsafe.Pointer(&_memdb_io_methods) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_memdbClose) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_memdbRead) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_memdbWrite) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_memdbTruncate) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_memdbSync) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_memdbFileSize) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_memdbLock) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_memdbUnlock) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_memdbFileControl) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_memdbDeviceCharacteristics) + *(*uintptr)(unsafe.Add(p, 136)) = __ccgo_fp(_memdbFetch) + *(*uintptr)(unsafe.Add(p, 144)) = __ccgo_fp(_memdbUnfetch) +} + +func init() { + p := unsafe.Pointer(&_fts5Vocab) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_fts5VocabCreateMethod) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_fts5VocabConnectMethod) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_fts5VocabBestIndexMethod) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_fts5VocabDisconnectMethod) + *(*uintptr)(unsafe.Add(p, 40)) = __ccgo_fp(_fts5VocabDestroyMethod) + *(*uintptr)(unsafe.Add(p, 48)) = __ccgo_fp(_fts5VocabOpenMethod) + *(*uintptr)(unsafe.Add(p, 56)) = __ccgo_fp(_fts5VocabCloseMethod) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(_fts5VocabFilterMethod) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(_fts5VocabNextMethod) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(_fts5VocabEofMethod) + *(*uintptr)(unsafe.Add(p, 88)) = __ccgo_fp(_fts5VocabColumnMethod) + *(*uintptr)(unsafe.Add(p, 96)) = __ccgo_fp(_fts5VocabRowidMethod) +} + +/* Here ends the fts5.c composite file. */ + +/************** End of fts5.c ************************************************/ +/************** Begin file stmt.c ********************************************/ +/* +** 2017-05-31 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file demonstrates an eponymous virtual table that returns information +** about all prepared statements for the database connection. +** +** Usage example: +** +** .load ./stmt +** .mode line +** .header on +** SELECT * FROM stmt; + */ + +func init() { + p := unsafe.Pointer(&_sqlite3BuiltinExtensions) + *(*uintptr)(unsafe.Add(p, 0)) = __ccgo_fp(_sqlite3Fts5Init) + *(*uintptr)(unsafe.Add(p, 8)) = __ccgo_fp(_sqlite3RtreeInit) + *(*uintptr)(unsafe.Add(p, 16)) = __ccgo_fp(_sqlite3DbpageRegister) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(_sqlite3DbstatRegister) + *(*uintptr)(unsafe.Add(p, 32)) = __ccgo_fp(_sqlite3TestExtInit) +} + +type t__predefined_ptrdiff_t = int64 + +type t__predefined_size_t = uint64 diff --git a/internal/engine/lib/sqlite_g_000000000003feef.go b/internal/engine/lib/sqlite_g_000000000003feef.go new file mode 100644 index 0000000..abfe655 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000003feef.go @@ -0,0 +1,1615 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) + +package sqlite3 + +type TBtCursor = struct { + FeState Tu8 + FcurFlags Tu8 + FcurPagerFlags Tu8 + Fhints Tu8 + FskipNext int32 + FpBtree uintptr + FaOverflow uintptr + FpKey uintptr + FpBt uintptr + FpNext uintptr + Finfo TCellInfo + FnKey Ti64 + FpgnoRoot TPgno + FiPage Ti8 + FcurIntKey Tu8 + Fix Tu16 + FaiIdx [19]Tu16 + FpKeyInfo uintptr + FpPage uintptr + FapPage [19]uintptr +} + +type TBtreePayload = struct { + FpKey uintptr + FnKey Tsqlite3_int64 + FpData uintptr + FaMem uintptr + FnMem Tu16 + FnData int32 + FnZero int32 +} + +/* +** Context object type used by rank(), dense_rank(), percent_rank() and +** cume_dist(). + */ +type TCallCount = struct { + FnValue Ti64 + FnStep Ti64 + FnTotal Ti64 +} + +type TCellInfo = struct { + FnKey Ti64 + FpPayload uintptr + FnPayload Tu32 + FnLocal Tu16 + FnSize Tu16 +} + +// C documentation +// +// /* +// ** The following structure keeps track of state information for the +// ** count() aggregate function. +// */ +type TCountCtx = struct { + Fn Ti64 +} + +// C documentation +// +// /* +// ** Handle type for pages. +// */ +type TDbPage = struct { + FpPage uintptr + FpData uintptr + FpExtra uintptr + FpCache uintptr + FpDirty uintptr + FpPager uintptr + Fpgno TPgno + Fflags Tu16 + FnRef Ti64 + FpDirtyNext uintptr + FpDirtyPrev uintptr +} + +type TFilePoint = struct { + FiOffset Tsqlite3_int64 + FpChunk uintptr +} + +// C documentation +// +// /* +// ** The first time the bm25() function is called for a query, an instance +// ** of the following structure is allocated and populated. +// */ +type TFts5Bm25Data = struct { + FnPhrase int32 + Favgdl float64 + FaIDF uintptr + FaFreq uintptr +} + +type TFts5Cursor = struct { + Fbase Tsqlite3_vtab_cursor + FpNext uintptr + FaColumnSize uintptr + FiCsrId Ti64 + FePlan int32 + FbDesc int32 + FiFirstRowid Ti64 + FiLastRowid Ti64 + FpStmt uintptr + FpExpr uintptr + FpSorter uintptr + Fcsrflags int32 + FiSpecial Ti64 + FzRank uintptr + FzRankArgs uintptr + FpRank uintptr + FnRankArg int32 + FapRankArg uintptr + FpRankArgStmt uintptr + FpAux uintptr + FpAuxdata uintptr + FaInstIter uintptr + FnInstAlloc int32 + FnInstCount int32 + FaInst uintptr +} + +type TFts5DlidxLvl = struct { + FpData uintptr + FiOff int32 + FbEof int32 + FiFirstOff int32 + FiLeafPgno int32 + FiRowid Ti64 +} + +type TFts5DlidxWriter = struct { + Fpgno int32 + FbPrevValid int32 + FiPrev Ti64 + Fbuf TFts5Buffer +} + +type TFts5DoclistIter = struct { + FaEof uintptr + FiRowid Ti64 + FaPoslist uintptr + FnPoslist int32 + FnSize int32 +} + +type TFts5ExprCtx = struct { + FpExpr uintptr + FaPopulator uintptr + FiOff Ti64 +} + +type TFts5ExprNode = struct { + FeType int32 + FbEof int32 + FbNomatch int32 + FiHeight int32 + FxNext uintptr + FiRowid Ti64 + FpNear uintptr + FnChild int32 +} + +type TFts5FlushCtx = struct { + FpIdx uintptr + Fwriter TFts5SegWriter +} + +type TFts5Global = struct { + Fapi Tfts5_api + Fdb uintptr + FiNextId Ti64 + FpAux uintptr + FpTok uintptr + FpDfltTok uintptr + FpCsr uintptr + FaLocaleHdr [4]Tu32 +} + +type TFts5HashEntry = struct { + FpHashNext uintptr + FpScanNext uintptr + FnAlloc int32 + FiSzPoslist int32 + FnData int32 + FnKey int32 + FbDel Tu8 + FbContent Tu8 + FiCol Ti16 + FiPos int32 + FiRowid Ti64 +} + +type TFts5Index = struct { + FpConfig uintptr + FzDataTbl uintptr + FnWorkUnit int32 + FpHash uintptr + FnPendingData int32 + FiWriteRowid Ti64 + FbDelete int32 + FnContentlessDelete int32 + FnPendingRow int32 + Frc int32 + FflushRc int32 + FpReader uintptr + FpWriter uintptr + FpDeleter uintptr + FpIdxWriter uintptr + FpIdxDeleter uintptr + FpIdxSelect uintptr + FpIdxNextSelect uintptr + FnRead int32 + FpDeleteFromIdx uintptr + FpDataVersion uintptr + FiStructVersion Ti64 + FpStruct uintptr +} + +type TFts5IndexIter = struct { + FiRowid Ti64 + FpData uintptr + FnData int32 + FbEof Tu8 +} + +// C documentation +// +// /* +// ** Context object used by sqlite3Fts5StorageIntegrity(). +// */ +type TFts5IntegrityCtx = struct { + FiRowid Ti64 + FiCol int32 + FszCol int32 + Fcksum Tu64 + FpTermset uintptr + FpConfig uintptr +} + +type TFts5Iter = struct { + Fbase TFts5IndexIter + FpTokenDataIter uintptr + FpIndex uintptr + Fposlist TFts5Buffer + FpColset uintptr + FxSetOutputs uintptr + FnSeg int32 + FbRev int32 + FbSkipEmpty Tu8 + FiSwitchRowid Ti64 + FaFirst uintptr +} + +type TFts5LookaheadReader = struct { + Fa uintptr + Fn int32 + Fi int32 + FiPos Ti64 + FiLookahead Ti64 +} + +type TFts5NearTrimmer = struct { + Freader TFts5LookaheadReader + Fwriter TFts5PoslistWriter + FpOut uintptr +} + +type TFts5PoslistPopulator = struct { + Fwriter TFts5PoslistWriter + FbOk int32 + FbMiss int32 +} + +type TFts5PoslistReader = struct { + Fa uintptr + Fn int32 + Fi int32 + FbFlag Tu8 + FbEof Tu8 + FiPos Ti64 +} + +type TFts5PoslistWriter = struct { + FiPrev Ti64 +} + +type TFts5SegIter = struct { + FpSeg uintptr + Fflags int32 + FiLeafPgno int32 + FpLeaf uintptr + FpNextLeaf uintptr + FiLeafOffset Ti64 + FpTombArray uintptr + FxNext uintptr + FiTermLeafPgno int32 + FiTermLeafOffset int32 + FiPgidxOff int32 + FiEndofDoclist int32 + FiRowidOffset int32 + FnRowidOffset int32 + FaRowidOffset uintptr + FpDlidx uintptr + Fterm TFts5Buffer + FiRowid Ti64 + FnPos int32 + FbDel Tu8 +} + +type TFts5SegWriter = struct { + FiSegid int32 + Fwriter TFts5PageWriter + FiPrevRowid Ti64 + FbFirstRowidInDoclist Tu8 + FbFirstRowidInPage Tu8 + FbFirstTermInPage Tu8 + FnLeafWritten int32 + FnEmpty int32 + FnDlidx int32 + FaDlidx uintptr + Fbtterm TFts5Buffer + FiBtPage int32 +} + +type TFts5Sorter = struct { + FpStmt uintptr + FiRowid Ti64 + FaPoslist uintptr + FnIdx int32 +} + +type TFts5Storage = struct { + FpConfig uintptr + FpIndex uintptr + FbTotalsValid int32 + FnTotalRow Ti64 + FaTotalSize uintptr + FpSavedRow uintptr + FaStmt [12]uintptr +} + +type TFts5Structure = struct { + FnRef int32 + FnWriteCounter Tu64 + FnOriginCntr Tu64 + FnSegment int32 + FnLevel int32 +} + +type TFts5StructureSegment = struct { + FiSegid int32 + FpgnoFirst int32 + FpgnoLast int32 + FiOrigin1 Tu64 + FiOrigin2 Tu64 + FnPgTombstone int32 + FnEntryTombstone Tu64 + FnEntry Tu64 +} + +type TFts5TokenDataIter = struct { + FnMapAlloc Ti64 + FnMap Ti64 + FaMap uintptr + Fterms TFts5Buffer + FnIter Ti64 + FnIterAlloc Ti64 + FaPoslistReader uintptr + FaPoslistToIter uintptr +} + +type TFts5TokenDataMap = struct { + FiRowid Ti64 + FiPos Ti64 + FiIter int32 + FnByte int32 +} + +type TFts5VocabCursor = struct { + Fbase Tsqlite3_vtab_cursor + FpStmt uintptr + FpFts5 uintptr + FbEof int32 + FpIter uintptr + FpStruct uintptr + FnLeTerm int32 + FzLeTerm uintptr + FcolUsed int32 + FiCol int32 + FaCnt uintptr + FaDoc uintptr + Frowid Ti64 + Fterm TFts5Buffer + FiInstPos Ti64 + FiInstOff int32 +} + +// C documentation +// +// /* Objects used by the overlap algorithm. */ +type TGeoEvent = struct { + Fx float64 + FeType int32 + FpSeg uintptr + FpNext uintptr +} + +type TGeoSegment = struct { + FC float64 + FB float64 + Fy float64 + Fy0 float32 + Fside uint8 + Fidx uint32 + FpNext uintptr +} + +/* In-memory list of records */ +type TIncrMerger = struct { + FpTask uintptr + FpMerger uintptr + FiStartOff Ti64 + FmxSz int32 + FbEof int32 + FbUseThread int32 + FaFile [2]TSorterFile +} + +// C documentation +// +// /* +// ** This structure is passed around through all the PRAGMA integrity_check +// ** checking routines in order to keep track of some global state information. +// ** +// ** The aRef[] array is allocated so that there is 1 bit for each page in +// ** the database. As the integrity-check proceeds, for each page used in +// ** the database the corresponding bit is set. This allows integrity-check to +// ** detect pages that are used twice and orphaned pages (both of which +// ** indicate corruption). +// */ +type TIntegrityCk = struct { + FpBt uintptr + FpPager uintptr + FaPgRef uintptr + FnCkPage TPgno + FmxErr int32 + FnErr int32 + Frc int32 + FnStep Tu32 + FzPfx uintptr + Fv0 TPgno + Fv1 TPgno + Fv2 int32 + FerrMsg TStrAccum + Fheap uintptr + Fdb uintptr + FnRow Ti64 +} + +type TJsonEachCursor = struct { + Fbase Tsqlite3_vtab_cursor + FiRowid Tu32 + Fi Tu32 + FiEnd Tu32 + FnRoot Tu32 + FeType Tu8 + FbRecursive Tu8 + FeMode Tu8 + FnParent Tu32 + FnParentAlloc Tu32 + FaParent uintptr + Fdb uintptr + Fpath TJsonString + FsParse TJsonParse +} + +// C documentation +// +// /**************************************************************************** +// ** The json_each virtual table +// ****************************************************************************/ +type TJsonParent = struct { + FiHead Tu32 + FiValue Tu32 + FiEnd Tu32 + FnPath Tu32 + FiKey Ti64 +} + +// C documentation +// +// /* +// ** The names of the following types declared in vdbeInt.h are required +// ** for the VdbeOp definition. +// */ +type TMem = struct { + Fu TMemValue + Fz uintptr + Fn int32 + Fflags Tu16 + Fenc Tu8 + FeSubtype Tu8 + Fdb uintptr + FszMalloc int32 + FuTemp Tu32 + FzMalloc uintptr + FxDel uintptr +} + +// C documentation +// +// /* +// ** State information local to the memory allocation subsystem. +// */ +type TMem0Global = struct { + Fmutex uintptr + FalarmThreshold Tsqlite3_int64 + FhardLimit Tsqlite3_int64 + FnearlyFull int32 +} + +// C documentation +// +// /* Forward references to internal structures */ +type TMemJournal = struct { + FpMethod uintptr + FnChunkSize int32 + FnSpill int32 + FpFirst uintptr + Fendpoint TFilePoint + Freadpoint TFilePoint + Fflags int32 + FpVfs uintptr + FzJournal uintptr +} + +type TMemStore = struct { + Fsz Tsqlite3_int64 + FszAlloc Tsqlite3_int64 + FszMax Tsqlite3_int64 + FaData uintptr + FpMutex uintptr + FnMmap int32 + FmFlags uint32 + FnRdLock int32 + FnWrLock int32 + FnRef int32 + FzFName uintptr +} + +type TMemValue = struct { + Fi [0]int64 + FnZero [0]int32 + FzPType [0]uintptr + FpDef [0]uintptr + Fr float64 +} + +/* +** Implementation of built-in window function nth_value(). This +** implementation is used in "slow mode" only - when the EXCLUDE clause +** is not set to the default value "NO OTHERS". + */ +type TNthValueCtx = struct { + FnStep Ti64 + FpValue uintptr +} + +/* +** Context object for ntile() window function. + */ +type TNtileCtx = struct { + FnTotal Ti64 + FnParam Ti64 + FiRow Ti64 +} + +type TPCache = struct { + FpDirty uintptr + FpDirtyTail uintptr + FpSynced uintptr + FnRefSum Ti64 + FszCache int32 + FszSpill int32 + FszPage int32 + FszExtra int32 + FbPurgeable Tu8 + FeCreate Tu8 + FxStress uintptr + FpStress uintptr + FpCache uintptr +} + +// C documentation +// +// /* +// ** An instance of the following structure is allocated for each active +// ** savepoint and statement transaction in the system. All such structures +// ** are stored in the Pager.aSavepoint[] array, which is allocated and +// ** resized using sqlite3Realloc(). +// ** +// ** When a savepoint is created, the PagerSavepoint.iHdrOffset field is +// ** set to 0. If a journal-header is written into the main journal while +// ** the savepoint is active, then iHdrOffset is set to the byte offset +// ** immediately following the last journal record written into the main +// ** journal before the journal-header. This is required during savepoint +// ** rollback (see pagerPlaybackSavepoint()). +// */ +type TPagerSavepoint = struct { + FiOffset Ti64 + FiHdrOffset Ti64 + FpInSavepoint uintptr + FnOrig TPgno + FiSubRec TPgno + FbTruncateOnRelease int32 + FaWalData [4]Tu32 +} + +/* Merge PMAs together */ +type TPmaReader = struct { + FiReadOff Ti64 + FiEof Ti64 + FnAlloc int32 + FnKey int32 + FpFd uintptr + FaAlloc uintptr + FaKey uintptr + FaBuffer uintptr + FnBuffer int32 + FaMap uintptr + FpIncr uintptr +} + +/* Incrementally read one PMA */ +type TPmaWriter = struct { + FeFWErr int32 + FaBuffer uintptr + FnBuffer int32 + FiBufStart int32 + FiBufEnd int32 + FiWriteOff Ti64 + FpFd uintptr + FnPmaSpill Tu64 +} + +// C documentation +// +// /* Definitions of all built-in pragmas */ +type TPragmaName = struct { + FzName uintptr + FePragTyp Tu8 + FmPragFlg Tu8 + FiPragCName Tu8 + FnPragCName Tu8 + FiArg Tu64 +} + +type TPragmaVtabCursor = struct { + Fbase Tsqlite3_vtab_cursor + FpPragma uintptr + FiRowid Tsqlite_int64 + FazArg [2]uintptr +} + +type TPrefixMerger = struct { + Fiter TFts5DoclistIter + FiPos Ti64 + FiOff int32 + FaPos uintptr + FpNext uintptr +} + +// C documentation +// +// /* +// ** Context object passed by fts5SetupPrefixIter() to fts5VisitEntries(). +// */ +type TPrefixSetupCtx = struct { + FxMerge uintptr + FxAppend uintptr + FiLastRowid Ti64 + FnMerge int32 + FaBuf uintptr + FnBuf int32 + Fdoclist TFts5Buffer + FpTokendata uintptr +} + +type TRCStr = struct { + FnRCRef Tu64 +} + +type TRbuState = struct { + FeStage int32 + FzTbl uintptr + FzDataTbl uintptr + FzIdx uintptr + FiWalCksum Ti64 + FnRow int32 + FnProgress Ti64 + FiCookie Tu32 + FiOalSz Ti64 + FnPhaseOneStep Ti64 +} + +/* Structure used to pass information throughout the Walker in order to +** implement sqlite3ReferencesSrcList(). + */ +type TRefSrcList = struct { + Fdb uintptr + FpRef uintptr + FnExclude Ti64 + FaiExclude uintptr +} + +/* An instance of this object describes bulk memory available for use +** by subcomponents of a prepared statement. Space is allocated out +** of a ReusableSpace object by the allocSpace() routine below. + */ +type TReusableSpace = struct { + FpSpace uintptr + FnFree Tsqlite3_int64 + FnNeeded Tsqlite3_int64 +} + +/* +** Each entry in a RowSet is an instance of the following object. +** +** This same object is reused to store a linked list of trees of RowSetEntry +** objects. In that alternative use, pRight points to the next entry +** in the list, pLeft points to the tree, and v is unused. The +** RowSet.pForest value points to the head of this forest list. + */ +type TRowSetEntry = struct { + Fv Ti64 + FpRight uintptr + FpLeft uintptr +} + +type TRtree = struct { + Fbase Tsqlite3_vtab + Fdb uintptr + FiNodeSize int32 + FnDim Tu8 + FnDim2 Tu8 + FeCoordType Tu8 + FnBytesPerCell Tu8 + FinWrTrans Tu8 + FnAux Tu16 + FnAuxNotNull Tu8 + FiDepth int32 + FzDb uintptr + FzName uintptr + FzNodeName uintptr + FnBusy Tu32 + FnRowEst Ti64 + FnCursor Tu32 + FnNodeRef Tu32 + FzReadAuxSql uintptr + FpDeleted uintptr + FpNodeBlob uintptr + FpWriteNode uintptr + FpDeleteNode uintptr + FpReadRowid uintptr + FpWriteRowid uintptr + FpDeleteRowid uintptr + FpReadParent uintptr + FpWriteParent uintptr + FpDeleteParent uintptr + FpWriteAux uintptr + FaHash [97]uintptr +} + +type TRtreeCell = struct { + FiRowid Ti64 + FaCoord [10]TRtreeCoord +} + +type TRtreeConstraint = struct { + FiCoord int32 + Fop int32 + Fu struct { + FxGeom [0]uintptr + FxQueryFunc [0]uintptr + FrValue TRtreeDValue + } + FpInfo uintptr +} + +type TRtreeCursor = struct { + Fbase Tsqlite3_vtab_cursor + FatEOF Tu8 + FbPoint Tu8 + FbAuxValid Tu8 + FiStrategy int32 + FnConstraint int32 + FaConstraint uintptr + FnPointAlloc int32 + FnPoint int32 + FmxLevel int32 + FaPoint uintptr + FpReadAux uintptr + FsPoint TRtreeSearchPoint + FaNode [5]uintptr + FanQueue [41]Tu32 +} + +type TRtreeMatchArg = struct { + FiSize Tu32 + Fcb TRtreeGeomCallback + FnParam int32 + FapSqlParam uintptr +} + +type TRtreeNode = struct { + FpParent uintptr + FiNode Ti64 + FnRef int32 + FisDirty int32 + FzData uintptr + FpNext uintptr +} + +type TRtreeSearchPoint = struct { + FrScore TRtreeDValue + Fid Tsqlite3_int64 + FiLevel Tu8 + FeWithin Tu8 + FiCell Tu8 +} + +type TSavepoint = struct { + FzName uintptr + FnDeferredCons Ti64 + FnDeferredImmCons Ti64 + FpNext uintptr +} + +/* A record being sorted */ +type TSortSubtask = struct { + FpThread uintptr + FbDone int32 + FnPMA int32 + FpSorter uintptr + FpUnpacked uintptr + Flist TSorterList + FxCompare TSorterCompare + Ffile TSorterFile + Ffile2 TSorterFile + FnSpill Tu64 +} + +/* A sub-task in the sort process */ +type TSorterFile = struct { + FpFd uintptr + FiEof Ti64 +} + +/* Temporary file object wrapper */ +type TSorterList = struct { + FpList uintptr + FaMemory uintptr + FszPMA Ti64 +} + +/* +** Structure containing global configuration data for the SQLite library. +** +** This structure also contains some state information. + */ +type TSqlite3Config = struct { + FbMemstat int32 + FbCoreMutex Tu8 + FbFullMutex Tu8 + FbOpenUri Tu8 + FbUseCis Tu8 + FbSmallMalloc Tu8 + FbExtraSchemaChecks Tu8 + FmxStrlen int32 + FneverCorrupt int32 + FszLookaside int32 + FnLookaside int32 + FnStmtSpill int32 + Fm Tsqlite3_mem_methods + Fmutex Tsqlite3_mutex_methods + Fpcache2 Tsqlite3_pcache_methods2 + FpHeap uintptr + FnHeap int32 + FmnReq int32 + FmxReq int32 + FszMmap Tsqlite3_int64 + FmxMmap Tsqlite3_int64 + FpPage uintptr + FszPage int32 + FnPage int32 + FmxParserStack int32 + FsharedCacheEnabled int32 + FszPma Tu32 + FisInit int32 + FinProgress int32 + FisMutexInit int32 + FisMallocInit int32 + FisPCacheInit int32 + FnRefInitMutex int32 + FpInitMutex uintptr + FxLog uintptr + FpLogArg uintptr + FmxMemdbSize Tsqlite3_int64 + FxTestCallback uintptr + FbLocaltimeFault int32 + FxAltLocaltime uintptr + FiOnceResetThreshold int32 + FszSorterRef Tu32 + FiPrngSeed uint32 +} + +type TSrcItem = struct { + FzName uintptr + FzAlias uintptr + FpSTab uintptr + Ffg struct { + Fjointype Tu8 + F__ccgo4 uint32 + } + FiCursor int32 + FcolUsed TBitmask + Fu1 struct { + FpFuncArg [0]uintptr + FnRow [0]Tu32 + FzIndexedBy uintptr + } + Fu2 struct { + FpCteUse [0]uintptr + FpIBIndex uintptr + } + Fu3 struct { + FpUsing [0]uintptr + FpOn uintptr + } + Fu4 struct { + FzDatabase [0]uintptr + FpSubq [0]uintptr + FpSchema uintptr + } +} + +// C documentation +// +// /* +// ** Three SQL functions - stat_init(), stat_push(), and stat_get() - +// ** share an instance of the following structure to hold their state +// ** information. +// */ +type TStatAccum = struct { + Fdb uintptr + FnEst TtRowcnt + FnRow TtRowcnt + FnLimit int32 + FnCol int32 + FnKeyCol int32 + FnSkipAhead Tu8 + Fcurrent TStatSample + FnPSample TtRowcnt + FmxSample int32 + FiPrn Tu32 + FaBest uintptr + FiMin int32 + FnSample int32 + FnMaxEqZero int32 + FiGet int32 + Fa uintptr +} + +type TStatCursor = struct { + Fbase Tsqlite3_vtab_cursor + FpStmt uintptr + FisEof Tu8 + FisAgg Tu8 + FiDb int32 + FaPage [32]TStatPage + FiPage int32 + FiPageno Tu32 + FzName uintptr + FzPath uintptr + FzPagetype uintptr + FnPage int32 + FnCell int32 + FnMxPayload int32 + FnUnused Ti64 + FnPayload Ti64 + FiOffset Ti64 + FszPage Ti64 +} + +type TStatSample = struct { + FanDLt uintptr + FanEq uintptr + FanLt uintptr + Fu struct { + FaRowid [0]uintptr + FiRowid Ti64 + } + FnRowid Tu32 + FisPSample Tu8 + FiCol int32 + FiHash Tu32 +} + +// C documentation +// +// /* +// ** An instance of the following structure holds the context of a +// ** sum() or avg() aggregate computation. +// */ +type TSumCtx = struct { + FrSum float64 + FrErr float64 + FiSum Ti64 + Fcnt Ti64 + Fapprox Tu8 + Fovrfl Tu8 +} + +// C documentation +// +// /* +// ** A VdbeCursor is an superclass (a wrapper) for various cursor objects: +// ** +// ** * A b-tree cursor +// ** - In the main database or in an ephemeral database +// ** - On either an index or a table +// ** * A sorter +// ** * A virtual table +// ** * A one-row "pseudotable" stored in a single register +// */ +type TVdbeCursor = struct { + FeCurType Tu8 + FiDb Ti8 + FnullRow Tu8 + FdeferredMoveto Tu8 + FisTable Tu8 + F__ccgo_align5 [3]byte + F__ccgo8 uint8 + FseekHit Tu16 + Fub struct { + FaAltMap [0]uintptr + FpBtx uintptr + } + FseqCount Ti64 + FcacheStatus Tu32 + FseekResult int32 + FpAltCursor uintptr + Fuc struct { + FpVCur [0]uintptr + FpSorter [0]uintptr + FpCursor uintptr + } + FpKeyInfo uintptr + FiHdrOffset Tu32 + FpgnoRoot TPgno + FnField Ti16 + FnHdrParsed Tu16 + FmovetoTarget Ti64 + FaOffset uintptr + FaRow uintptr + FpayloadSize Tu32 + FszRow Tu32 + FpCache uintptr +} + +// C documentation +// +// /* +// ** When a sub-program is executed (OP_Program), a structure of this type +// ** is allocated to store the current value of the program counter, as +// ** well as the current memory cell array and various other frame specific +// ** values stored in the Vdbe struct. When the sub-program is finished, +// ** these values are copied back to the Vdbe from the VdbeFrame structure, +// ** restoring the state of the VM to as it was before the sub-program +// ** began executing. +// ** +// ** The memory for a VdbeFrame object is allocated and managed by a memory +// ** cell in the parent (calling) frame. When the memory cell is deleted or +// ** overwritten, the VdbeFrame object is not freed immediately. Instead, it +// ** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame +// ** list is deleted when the VM is reset in VdbeHalt(). The reason for doing +// ** this instead of deleting the VdbeFrame immediately is to avoid recursive +// ** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the +// ** child frame are released. +// ** +// ** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is +// ** set to NULL if the currently executing frame is the main program. +// */ +type TVdbeFrame = struct { + Fv uintptr + FpParent uintptr + FaOp uintptr + FaMem uintptr + FapCsr uintptr + FaOnce uintptr + Ftoken uintptr + FlastRowid Ti64 + FpAuxData uintptr + FnCursor int32 + Fpc int32 + FnOp int32 + FnMem int32 + FnChildMem int32 + FnChildCsr int32 + FnChange Ti64 + FnDbChange Ti64 +} + +// C documentation +// +// /* Opaque type used by code in vdbesort.c */ +type TVdbeSorter = struct { + FmnPmaSize int32 + FmxPmaSize int32 + FmxKeysize int32 + Fpgsz int32 + FpReader uintptr + FpMerger uintptr + Fdb uintptr + FpKeyInfo uintptr + FpUnpacked uintptr + Flist TSorterList + FiMemory int32 + FnMemory int32 + FbUsePMA Tu8 + FbUseThreads Tu8 + FiPrev Tu8 + FnTask Tu8 + FtypeMask Tu8 +} + +// C documentation +// +// /* A cache of large TEXT or BLOB values in a VdbeCursor */ +type TVdbeTxtBlbCache = struct { + FpCValue uintptr + FiOffset Ti64 + FiCol int32 + FcacheStatus Tu32 + FcolCacheCtr Tu32 +} + +// C documentation +// +// /* Connection to a write-ahead log (WAL) file. +// ** There is one object of this type for each pager. +// */ +type TWal = struct { + FpVfs uintptr + FpDbFd uintptr + FpWalFd uintptr + FiCallback Tu32 + FmxWalSize Ti64 + FnWiData int32 + FszFirstBlock int32 + FapWiData uintptr + FszPage Tu32 + FreadLock Ti16 + FsyncFlags Tu8 + FexclusiveMode Tu8 + FwriteLock Tu8 + FckptLock Tu8 + FreadOnly Tu8 + FtruncateOnCommit Tu8 + FsyncHeader Tu8 + FpadToSectorBoundary Tu8 + FbShmUnreliable Tu8 + Fhdr TWalIndexHdr + FminFrame Tu32 + FiReCksum Tu32 + FzWalName uintptr + FnCkpt Tu32 + FpSnapshot uintptr + FbGetSnapshot int32 +} + +// C documentation +// +// /* +// ** Information about the current state of the WAL file and where +// ** the next fsync should occur - passed from sqlite3WalFrames() into +// ** walWriteToLog(). +// */ +type TWalWriter = struct { + FpWal uintptr + FpFd uintptr + FiSyncPoint Tsqlite3_int64 + FsyncFlags int32 + FszPage int32 +} + +type TWhereAndInfo = struct { + Fwc TWhereClause +} + +// C documentation +// +// /* Forward references +// */ +type TWhereClause = struct { + FpWInfo uintptr + FpOuter uintptr + Fop Tu8 + FhasOr Tu8 + FnTerm int32 + FnSlot int32 + FnBase int32 + Fa uintptr + FaStatic [8]TWhereTerm +} + +type TWhereLevel = struct { + FiLeftJoin int32 + FiTabCur int32 + FiIdxCur int32 + FaddrBrk int32 + FaddrHalt int32 + FaddrNxt int32 + FaddrSkip int32 + FaddrCont int32 + FaddrFirst int32 + FaddrBody int32 + FregBignull int32 + FaddrBignull int32 + FregFilter int32 + FpRJ uintptr + FiFrom Tu8 + Fop Tu8 + Fp3 Tu8 + Fp5 Tu8 + Fp1 int32 + Fp2 int32 + Fu struct { + FpCoveringIdx [0]uintptr + Fin struct { + FnIn int32 + FaInLoop uintptr + } + } + FpWLoop uintptr + FnotReady TBitmask +} + +type TWhereLoop = struct { + Fprereq TBitmask + FmaskSelf TBitmask + FiTab Tu8 + FiSortIdx Tu8 + FrSetup TLogEst + FrRun TLogEst + FnOut TLogEst + Fu struct { + Fvtab [0]struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + } + Fbtree struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + } + } + FwsFlags Tu32 + FnLTerm Tu16 + FnSkip Tu16 + FnLSlot Tu16 + FaLTerm uintptr + FpNextLoop uintptr + FaLTermSpace [3]uintptr +} + +type TWhereMemBlock = struct { + FpNext uintptr + Fsz Tu64 +} + +type TWhereOrCost = struct { + Fprereq TBitmask + FrRun TLogEst + FnOut TLogEst +} + +type TWhereOrInfo = struct { + Fwc TWhereClause + Findexable TBitmask +} + +type TWhereOrSet = struct { + Fn Tu16 + Fa [3]TWhereOrCost +} + +type TWherePath = struct { + FmaskLoop TBitmask + FrevLoop TBitmask + FnRow TLogEst + FrCost TLogEst + FrUnsort TLogEst + FisOrdered Ti8 + FaLoop uintptr +} + +type TWhereTerm = struct { + FpExpr uintptr + FpWC uintptr + FtruthProb TLogEst + FwtFlags Tu16 + FeOperator Tu16 + FnChild Tu8 + FeMatchOp Tu8 + FiParent int32 + FleftCursor int32 + Fu struct { + FpOrInfo [0]uintptr + FpAndInfo [0]uintptr + Fx struct { + FleftColumn int32 + FiField int32 + } + } + FprereqRight TBitmask + FprereqAll TBitmask +} + +type Tlldiv_t = struct { + Fquot int64 + Frem int64 +} + +type Trbu_file = struct { + Fbase Tsqlite3_file + FpReal uintptr + FpRbuVfs uintptr + FpRbu uintptr + Fsz Ti64 + FopenFlags int32 + FiCookie Tu32 + FiWriteVer Tu8 + FbNolock Tu8 + FnShm int32 + FapShm uintptr + FzDel uintptr + FzWal uintptr + FpWalFd uintptr + FpMainNext uintptr + FpMainRbuNext uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: Database Connection Handle +// ** KEYWORDS: {database connection} {database connections} +// ** +// ** Each open SQLite database is represented by a pointer to an instance of +// ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 +// ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and +// ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] +// ** and [sqlite3_close_v2()] are its destructors. There are many other +// ** interfaces (such as +// ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and +// ** [sqlite3_busy_timeout()] to name but three) that are methods on an +// ** sqlite3 object. +// */ +type Tsqlite3 = struct { + FpVfs uintptr + FpVdbe uintptr + FpDfltColl uintptr + Fmutex uintptr + FaDb uintptr + FnDb int32 + FmDbFlags Tu32 + Fflags Tu64 + FlastRowid Ti64 + FszMmap Ti64 + FnSchemaLock Tu32 + FopenFlags uint32 + FerrCode int32 + FerrByteOffset int32 + FerrMask int32 + FiSysErrno int32 + FdbOptFlags Tu32 + Fenc Tu8 + FautoCommit Tu8 + Ftemp_store Tu8 + FmallocFailed Tu8 + FbBenignMalloc Tu8 + FdfltLockMode Tu8 + FnextAutovac int8 + FsuppressErr Tu8 + FvtabOnConflict Tu8 + FisTransactionSavepoint Tu8 + FmTrace Tu8 + FnoSharedCache Tu8 + FnSqlExec Tu8 + FeOpenState Tu8 + FnFpDigit Tu8 + FnextPagesize int32 + FnChange Ti64 + FnTotalChange Ti64 + FaLimit [13]int32 + FnMaxSorterMmap int32 + Finit1 Tsqlite3InitInfo + FnVdbeActive int32 + FnVdbeRead int32 + FnVdbeWrite int32 + FnVdbeExec int32 + FnVDestroy int32 + FnExtension int32 + FaExtension uintptr + Ftrace struct { + FxV2 [0]uintptr + FxLegacy uintptr + } + FpTraceArg uintptr + FxProfile uintptr + FpProfileArg uintptr + FpCommitArg uintptr + FxCommitCallback uintptr + FpRollbackArg uintptr + FxRollbackCallback uintptr + FpUpdateArg uintptr + FxUpdateCallback uintptr + FpAutovacPagesArg uintptr + FxAutovacDestr uintptr + FxAutovacPages uintptr + FpParse uintptr + FpPreUpdateArg uintptr + FxPreUpdateCallback uintptr + FpPreUpdate uintptr + FxWalCallback uintptr + FpWalArg uintptr + FxCollNeeded uintptr + FxCollNeeded16 uintptr + FpCollNeededArg uintptr + FpErr uintptr + Fu1 struct { + FnotUsed1 [0]float64 + FisInterrupted int32 + F__ccgo_pad2 [4]byte + } + Flookaside TLookaside + FxAuth Tsqlite3_xauth + FpAuthArg uintptr + FxProgress uintptr + FpProgressArg uintptr + FnProgressOps uint32 + FnVTrans int32 + FaModule THash + FpVtabCtx uintptr + FaVTrans uintptr + FpDisconnect uintptr + FaFunc THash + FaCollSeq THash + FbusyHandler TBusyHandler + FaDbStatic [2]TDb + FpSavepoint uintptr + FnAnalysisLimit int32 + FbusyTimeout int32 + FnSavepoint int32 + FnStatement int32 + FnDeferredCons Ti64 + FnDeferredImmCons Ti64 + FpnBytesFreed uintptr + FpDbData uintptr + FnSpill Tu64 + FpBlockingConnection uintptr + FpUnlockConnection uintptr + FpUnlockArg uintptr + FxUnlockNotify uintptr + FpNextBlocked uintptr +} + +type Tsqlite3_index_info = struct { + FnConstraint int32 + FaConstraint uintptr + FnOrderBy int32 + FaOrderBy uintptr + FaConstraintUsage uintptr + FidxNum int32 + FidxStr uintptr + FneedToFreeIdxStr int32 + ForderByConsumed int32 + FestimatedCost float64 + FestimatedRows Tsqlite3_int64 + FidxFlags int32 + FcolUsed Tsqlite3_uint64 +} + +type Tsqlite3_rtree_query_info = struct { + FpContext uintptr + FnParam int32 + FaParam uintptr + FpUser uintptr + FxDelUser uintptr + FaCoord uintptr + FanQueue uintptr + FnCoord int32 + FiLevel int32 + FmxLevel int32 + FiRowid Tsqlite3_int64 + FrParentScore Tsqlite3_rtree_dbl + FeParentWithin int32 + FeWithin int32 + FrScore Tsqlite3_rtree_dbl + FapSqlParam uintptr +} + +// C documentation +// +// /* +// ** CAPI3REF: Session Object Handle +// ** +// ** An instance of this object is a [session] that can be used to +// ** record changes to a database. +// */ +type Tsqlite3_session = struct { + Fdb uintptr + FzDb uintptr + FbEnableSize int32 + FbEnable int32 + FbIndirect int32 + FbAutoAttach int32 + FbImplicitPK int32 + Frc int32 + FpFilterCtx uintptr + FxTableFilter uintptr + FnMalloc Ti64 + FnMaxChangesetSize Ti64 + FpZeroBlob uintptr + FpNext uintptr + FpTable uintptr + Fhook TSessionHook +} + +// C documentation +// +// /* +// ** CAPI3REF: Dynamically Typed Value Object +// ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} +// ** +// ** SQLite uses the sqlite3_value object to represent all values +// ** that can be stored in a database table. SQLite uses dynamic typing +// ** for the values it stores. ^Values stored in sqlite3_value objects +// ** can be integers, floating point values, strings, BLOBs, or NULL. +// ** +// ** An sqlite3_value object may be either "protected" or "unprotected". +// ** Some interfaces require a protected sqlite3_value. Other interfaces +// ** will accept either a protected or an unprotected sqlite3_value. +// ** Every interface that accepts sqlite3_value arguments specifies +// ** whether or not it requires a protected sqlite3_value. The +// ** [sqlite3_value_dup()] interface can be used to construct a new +// ** protected sqlite3_value from an unprotected sqlite3_value. +// ** +// ** The terms "protected" and "unprotected" refer to whether or not +// ** a mutex is held. An internal mutex is held for a protected +// ** sqlite3_value object but no mutex is held for an unprotected +// ** sqlite3_value object. If SQLite is compiled to be single-threaded +// ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) +// ** or if SQLite is run in one of reduced mutex modes +// ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] +// ** then there is no distinction between protected and unprotected +// ** sqlite3_value objects and they can be used interchangeably. However, +// ** for maximum code portability it is recommended that applications +// ** still make the distinction between protected and unprotected +// ** sqlite3_value objects even when not strictly required. +// ** +// ** ^The sqlite3_value objects that are passed as parameters into the +// ** implementation of [application-defined SQL functions] are protected. +// ** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()] +// ** are protected. +// ** ^The sqlite3_value object returned by +// ** [sqlite3_column_value()] is unprotected. +// ** Unprotected sqlite3_value objects may only be used as arguments +// ** to [sqlite3_result_value()], [sqlite3_bind_value()], and +// ** [sqlite3_value_dup()]. +// ** The [sqlite3_value_blob | sqlite3_value_type()] family of +// ** interfaces require protected sqlite3_value objects. +// */ +type Tsqlite3_value = struct { + Fu TMemValue + Fz uintptr + Fn int32 + Fflags Tu16 + Fenc Tu8 + FeSubtype Tu8 + Fdb uintptr + FszMalloc int32 + FuTemp Tu32 + FzMalloc uintptr + FxDel uintptr +} diff --git a/internal/engine/lib/sqlite_g_000000000003ffbb.go b/internal/engine/lib/sqlite_g_000000000003ffbb.go new file mode 100644 index 0000000..69ad3e6 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000003ffbb.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) + +package sqlite3 + +type Tfloat_t = float32 diff --git a/internal/engine/lib/sqlite_g_000000000003fffb.go b/internal/engine/lib/sqlite_g_000000000003fffb.go new file mode 100644 index 0000000..6bf2801 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000003fffb.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) + +package sqlite3 + +type Ttime_t = int64 diff --git a/internal/engine/lib/sqlite_g_0000000000040003.go b/internal/engine/lib/sqlite_g_0000000000040003.go new file mode 100644 index 0000000..2769552 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000040003.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (windows && 386) + +package sqlite3 + +const __USER_LABEL_PREFIX__ = 0 diff --git a/internal/engine/lib/sqlite_g_0000000000040045.go b/internal/engine/lib/sqlite_g_0000000000040045.go new file mode 100644 index 0000000..1ca6be6 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000040045.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && 386) || (linux && 386) || (windows && 386) + +package sqlite3 + +const __LAHF_SAHF__ = 1 diff --git a/internal/engine/lib/sqlite_g_000000000005feff.go b/internal/engine/lib/sqlite_g_000000000005feff.go new file mode 100644 index 0000000..332e5da --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000005feff.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && 386) + +package sqlite3 + +const __GCC_HAVE_DWARF2_CFI_ASM = 1 diff --git a/internal/engine/lib/sqlite_g_000000000005ffff.go b/internal/engine/lib/sqlite_g_000000000005ffff.go new file mode 100644 index 0000000..315d19a --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000005ffff.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && 386) + +package sqlite3 + +type Tpid_t = int32 diff --git a/internal/engine/lib/sqlite_g_0000000000060003.go b/internal/engine/lib/sqlite_g_0000000000060003.go new file mode 100644 index 0000000..e9b7ad7 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000060003.go @@ -0,0 +1,151 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const AF_APPLETALK = 16 + +const AF_CCITT = 10 + +const AF_CHAOS = 5 + +const AF_DATAKIT = 9 + +const AF_DECnet = 12 + +const AF_DLI = 13 + +const AF_ECMA = 8 + +const AF_HYLINK = 15 + +const AF_IMPLINK = 3 + +const AF_INET = 2 + +const AF_ISO = 7 + +const AF_LAT = 14 + +const AF_NS = 6 + +const AF_OSI = 7 + +const AF_PUP = 4 + +const AF_SNA = 11 + +const AF_UNIX = 1 + +const AF_UNSPEC = 0 + +const FALSE = 0 + +const FP_SNAN = 1 + +const INT_FAST16_MAX = 32767 + +const INT_FAST16_MIN = -32768 + +const MSG_DONTROUTE = 4 + +const MSG_OOB = 1 + +const MSG_PEEK = 2 + +const PF_APPLETALK = 16 + +const PF_CCITT = 10 + +const PF_CHAOS = 5 + +const PF_DATAKIT = 9 + +const PF_DECnet = 12 + +const PF_DLI = 13 + +const PF_ECMA = 8 + +const PF_HYLINK = 15 + +const PF_IMPLINK = 3 + +const PF_INET = 2 + +const PF_ISO = 7 + +const PF_LAT = 14 + +const PF_NS = 6 + +const PF_OSI = 7 + +const PF_PUP = 4 + +const PF_SNA = 11 + +const PF_UNIX = 1 + +const PF_UNSPEC = 0 + +const SOCK_DGRAM = 2 + +const SOCK_RAW = 3 + +const SOCK_RDM = 4 + +const SOCK_SEQPACKET = 5 + +const SOCK_STREAM = 1 + +const SOL_SOCKET = 65535 + +const SO_ACCEPTCONN = 2 + +const SO_BROADCAST = 32 + +const SO_DEBUG = 1 + +const SO_DONTROUTE = 16 + +const SO_ERROR = 4103 + +const SO_KEEPALIVE = 8 + +const SO_LINGER = 128 + +const SO_OOBINLINE = 256 + +const SO_RCVBUF = 4098 + +const SO_RCVLOWAT = 4100 + +const SO_RCVTIMEO = 4102 + +const SO_REUSEADDR = 4 + +const SO_SNDBUF = 4097 + +const SO_SNDLOWAT = 4099 + +const SO_SNDTIMEO = 4101 + +const SO_TYPE = 4104 + +const SO_USELOOPBACK = 64 + +const TRUE = 1 + +type Tint_fast16_t = int16 + +type Tuint_fast16_t = uint16 + +const UINT_FAST16_MAX = 65535 + +type linger = Tlinger + +type sockaddr = Tsockaddr + +type sockproto = Tsockproto diff --git a/internal/engine/lib/sqlite_g_000000000006003f.go b/internal/engine/lib/sqlite_g_000000000006003f.go new file mode 100644 index 0000000..b9725e7 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000006003f.go @@ -0,0 +1,19 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +type Terrno_t = int32 + +type Tmode_t = uint16 + +type errno_t = Terrno_t + +type rsize_t = Trsize_t + +const stderr = 0 + +const stdin = 0 + +const stdout = 0 diff --git a/internal/engine/lib/sqlite_g_00000000000600c0.go b/internal/engine/lib/sqlite_g_00000000000600c0.go new file mode 100644 index 0000000..0d1d19f --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000600c0.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __DECIMAL_BID_FORMAT__ = 1 diff --git a/internal/engine/lib/sqlite_g_00000000000602c0.go b/internal/engine/lib/sqlite_g_00000000000602c0.go new file mode 100644 index 0000000..6fbfb74 --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000602c0.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __FLT128_IS_IEC_60559__ = 2 + +const __FLT64X_IS_IEC_60559__ = 2 diff --git a/internal/engine/lib/sqlite_g_0000000000060300.go b/internal/engine/lib/sqlite_g_0000000000060300.go new file mode 100644 index 0000000..28d9e39 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000060300.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && arm) || (linux && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __WCHAR_MIN__ = 0 diff --git a/internal/engine/lib/sqlite_g_00000000000623c0.go b/internal/engine/lib/sqlite_g_00000000000623c0.go new file mode 100644 index 0000000..95f6e56 --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000623c0.go @@ -0,0 +1,21 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && s390x) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __DBL_IS_IEC_60559__ = 2 + +const __FLT32X_IS_IEC_60559__ = 2 + +const __FLT32_IS_IEC_60559__ = 2 + +const __FLT64_IS_IEC_60559__ = 2 + +const __FLT_IS_IEC_60559__ = 2 + +const __GNUC__ = 12 + +const __GXX_ABI_VERSION = 1017 + +const __LDBL_IS_IEC_60559__ = 2 diff --git a/internal/engine/lib/sqlite_g_00000000000628c0.go b/internal/engine/lib/sqlite_g_00000000000628c0.go new file mode 100644 index 0000000..9c56d65 --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000628c0.go @@ -0,0 +1,47 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && ppc64le) || (linux && s390x) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __DEC128_EPSILON__ = 0 + +const __DEC128_MANT_DIG__ = 34 + +const __DEC128_MAX_EXP__ = 6145 + +const __DEC128_MAX__ = 0 + +const __DEC128_MIN_EXP__ = -6142 + +const __DEC128_MIN__ = 0 + +const __DEC128_SUBNORMAL_MIN__ = 0 + +const __DEC32_EPSILON__ = 0 + +const __DEC32_MANT_DIG__ = 7 + +const __DEC32_MAX_EXP__ = 97 + +const __DEC32_MAX__ = 0 + +const __DEC32_MIN_EXP__ = -94 + +const __DEC32_MIN__ = 0 + +const __DEC32_SUBNORMAL_MIN__ = 0 + +const __DEC64_EPSILON__ = 0 + +const __DEC64_MANT_DIG__ = 16 + +const __DEC64_MAX_EXP__ = 385 + +const __DEC64_MAX__ = 0 + +const __DEC64_MIN_EXP__ = -382 + +const __DEC64_MIN__ = 0 + +const __DEC64_SUBNORMAL_MIN__ = 0 diff --git a/internal/engine/lib/sqlite_g_0000000000063fc0.go b/internal/engine/lib/sqlite_g_0000000000063fc0.go new file mode 100644 index 0000000..dc4577a --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000063fc0.go @@ -0,0 +1,23 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const CLOCK_MONOTONIC = 1 + +const CLOCK_THREAD_CPUTIME_ID = 3 + +const EAGAIN = 11 + +const SQLITE_THREADS_IMPLEMENTED = 1 + +const WINT_MIN = 0 + +const _POSIX_MONOTONIC_CLOCK = 200809 + +const _POSIX_TIMERS = 200809 + +const __GNUC_EXECUTION_CHARSET_NAME = "UTF-8" + +const __WINT_MIN__ = 0 diff --git a/internal/engine/lib/sqlite_g_0000000000063fc3.go b/internal/engine/lib/sqlite_g_0000000000063fc3.go new file mode 100644 index 0000000..d3f425e --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000063fc3.go @@ -0,0 +1,17 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const HUGE = 0 + +const INT_FAST8_MAX = 127 + +const INT_FAST8_MIN = -128 + +type Tint_fast8_t = int8 + +type Tuint_fast8_t = uint8 + +const UINT_FAST8_MAX = 255 diff --git a/internal/engine/lib/sqlite_g_0000000000063fff.go b/internal/engine/lib/sqlite_g_0000000000063fff.go new file mode 100644 index 0000000..3f23176 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000063fff.go @@ -0,0 +1,162 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const SQLITE_MAX_MMAP_SIZE = 2147418112 + +// C documentation +// +// /* +// ** Begin a read transaction on the WAL. +// ** +// ** This routine used to be called "pagerOpenSnapshot()" because it essentially +// ** makes a snapshot of the database at the current point in time and preserves +// ** that snapshot for use by the reader in spite of concurrently changes by +// ** other writers or checkpointers. +// */ +func _pagerBeginReadTransaction(tls *libc.TLS, pPager uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* changed at bp+0 */ int32 + _ = rc /* Return code */ + **(**int32)(__ccgo_up(bp)) = 0 /* True if cache must be reset */ + /* sqlite3WalEndReadTransaction() was not called for the previous + ** transaction in locking_mode=EXCLUSIVE. So call it now. If we + ** are in locking_mode=NORMAL and EndRead() was previously called, + ** the duplicate call is harmless. + */ + _sqlite3WalEndReadTransaction(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal) + rc = _sqlite3WalBeginReadTransaction(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, bp) + if rc != SQLITE_OK || **(**int32)(__ccgo_up(bp)) != 0 { + _pager_reset(tls, pPager) + if (*TPager)(unsafe.Pointer(pPager)).FbUseFetch != 0 { + _sqlite3OsUnfetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, 0, uintptr(0)) + } + } + return rc +} + +// C documentation +// +// /* +// ** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of szMmap. +// */ +func _pagerFixMaplimit(tls *libc.TLS, pPager uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var fd uintptr + var _ /* sz at bp+0 */ Tsqlite3_int64 + _ = fd + fd = (*TPager)(unsafe.Pointer(pPager)).Ffd + if (*Tsqlite3_file)(unsafe.Pointer(fd)).FpMethods != uintptr(0) && (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(fd)).FpMethods)).FiVersion >= int32(3) { + **(**Tsqlite3_int64)(__ccgo_up(bp)) = (*TPager)(unsafe.Pointer(pPager)).FszMmap + (*TPager)(unsafe.Pointer(pPager)).FbUseFetch = libc.BoolUint8(**(**Tsqlite3_int64)(__ccgo_up(bp)) > libc.Int64FromInt32(0)) + _setGetterMethod(tls, pPager) + _sqlite3OsFileControlHint(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_MMAP_SIZE), bp) + } +} + +// C documentation +// +// /* +// ** Set the Pager.xGet method for the appropriate routine used to fetch +// ** content from the pager. +// */ +func _setGetterMethod(tls *libc.TLS, pPager uintptr) { + if (*TPager)(unsafe.Pointer(pPager)).FerrCode != 0 { + (*TPager)(unsafe.Pointer(pPager)).FxGet = __ccgo_fp(_getPageError) + } else { + if (*TPager)(unsafe.Pointer(pPager)).FbUseFetch != 0 { + (*TPager)(unsafe.Pointer(pPager)).FxGet = __ccgo_fp(_getPageMMap) + } else { + (*TPager)(unsafe.Pointer(pPager)).FxGet = __ccgo_fp(_getPageNormal) + } + } +} + +// C documentation +// +// /* +// ** Change the limit on the amount of the database file that may be +// ** memory mapped. +// */ +func _sqlite3BtreeSetMmapLimit(tls *libc.TLS, p uintptr, szMmap Tsqlite3_int64) (r int32) { + var pBt uintptr + _ = pBt + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + _sqlite3BtreeEnter(tls, p) + _sqlite3PagerSetMmapLimit(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, szMmap) + _sqlite3BtreeLeave(tls, p) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** The following singleton contains the global configuration for +// ** the SQLite library. +// */ +var _sqlite3Config = TSqlite3Config{ + FbCoreMutex: uint8(1), + FbFullMutex: libc.BoolUint8(true), + FbUseCis: uint8(SQLITE_ALLOW_COVERING_INDEX_SCAN), + FbExtraSchemaChecks: uint8(1), + FmxStrlen: int32(0x7ffffffe), + FszLookaside: int32(1200), + FnLookaside: int32(40), + FnStmtSpill: libc.Int32FromInt32(64) * libc.Int32FromInt32(1024), + FmxMmap: int64(SQLITE_MAX_MMAP_SIZE), + FnPage: int32(SQLITE_DEFAULT_PCACHE_INITSZ), + FszPma: uint32(SQLITE_SORTER_PMASZ), + FmxMemdbSize: int64(SQLITE_MEMDB_DEFAULT_MAXSIZE), + FiOnceResetThreshold: int32(0x7ffffffe), + FszSorterRef: uint32(SQLITE_DEFAULT_SORTERREF_SIZE), +} + +// C documentation +// +// /* The real implementation of xFetch and xUnfetch */ +func _sqlite3OsFetch(tls *libc.TLS, id uintptr, iOff Ti64, iAmt int32, pp uintptr) (r int32) { + return (*(*func(*libc.TLS, uintptr, Tsqlite3_int64, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxFetch})))(tls, id, iOff, iAmt, pp) +} + +func _sqlite3OsUnfetch(tls *libc.TLS, id uintptr, iOff Ti64, p uintptr) (r int32) { + return (*(*func(*libc.TLS, uintptr, Tsqlite3_int64, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxUnfetch})))(tls, id, iOff, p) +} + +// C documentation +// +// /* +// ** Allocate space for a file-handle and open a temporary file. If successful, +// ** set *ppFd to point to the malloc'd file-handle and return SQLITE_OK. +// ** Otherwise, set *ppFd to 0 and return an SQLite error code. +// */ +func _vdbeSorterOpenTempFile(tls *libc.TLS, db uintptr, nExtend Ti64, ppFd uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* max at bp+8 */ Ti64 + var _ /* rc at bp+0 */ int32 + if _sqlite3FaultSim(tls, int32(202)) != 0 { + return libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(13)< 0 { + _vdbeSorterExtendFile(tls, db, **(**uintptr)(__ccgo_up(ppFd)), nExtend) + } + } + return **(**int32)(__ccgo_up(bp)) +} + +type max_align_t = Tmax_align_t diff --git a/internal/engine/lib/sqlite_g_0000000000064003.go b/internal/engine/lib/sqlite_g_0000000000064003.go new file mode 100644 index 0000000..338265e --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000064003.go @@ -0,0 +1,17 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const DOMAIN = 1 + +const OVERFLOW = 3 + +const PLOSS = 6 + +const SING = 2 + +const TLOSS = 5 + +const UNDERFLOW = 4 diff --git a/internal/engine/lib/sqlite_g_000000000006403f.go b/internal/engine/lib/sqlite_g_000000000006403f.go new file mode 100644 index 0000000..5c68238 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000006403f.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +type FILE = TFILE diff --git a/internal/engine/lib/sqlite_g_00000000000640c0.go b/internal/engine/lib/sqlite_g_00000000000640c0.go new file mode 100644 index 0000000..694bb20 --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000640c0.go @@ -0,0 +1,11 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __ATOMIC_HLE_ACQUIRE = 65536 + +const __ATOMIC_HLE_RELEASE = 131072 + +const __LONG_DOUBLE_64__ = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000065ec0.go b/internal/engine/lib/sqlite_g_0000000000065ec0.go new file mode 100644 index 0000000..f284a2d --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000065ec0.go @@ -0,0 +1,65 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __FLT128_DECIMAL_DIG__ = 36 + +const __FLT128_DENORM_MIN__ = 0 + +const __FLT128_DIG__ = 33 + +const __FLT128_EPSILON__ = 0 + +const __FLT128_HAS_DENORM__ = 1 + +const __FLT128_HAS_INFINITY__ = 1 + +const __FLT128_HAS_QUIET_NAN__ = 1 + +const __FLT128_MANT_DIG__ = 113 + +const __FLT128_MAX_10_EXP__ = 4932 + +const __FLT128_MAX_EXP__ = 16384 + +const __FLT128_MAX__ = 0 + +const __FLT128_MIN_10_EXP__ = -4931 + +const __FLT128_MIN_EXP__ = -16381 + +const __FLT128_MIN__ = 0 + +const __FLT128_NORM_MAX__ = 0 + +const __FLT64X_DECIMAL_DIG__ = 36 + +const __FLT64X_DENORM_MIN__ = 0 + +const __FLT64X_DIG__ = 33 + +const __FLT64X_EPSILON__ = 0 + +const __FLT64X_HAS_DENORM__ = 1 + +const __FLT64X_HAS_INFINITY__ = 1 + +const __FLT64X_HAS_QUIET_NAN__ = 1 + +const __FLT64X_MANT_DIG__ = 113 + +const __FLT64X_MAX_10_EXP__ = 4932 + +const __FLT64X_MAX_EXP__ = 16384 + +const __FLT64X_MAX__ = 0 + +const __FLT64X_MIN_10_EXP__ = -4931 + +const __FLT64X_MIN_EXP__ = -16381 + +const __FLT64X_MIN__ = 0 + +const __FLT64X_NORM_MAX__ = 0 diff --git a/internal/engine/lib/sqlite_g_0000000000065fc0.go b/internal/engine/lib/sqlite_g_0000000000065fc0.go new file mode 100644 index 0000000..31743a6 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000065fc0.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __FLOAT_WORD_ORDER__ = 1234 diff --git a/internal/engine/lib/sqlite_g_0000000000066fc0.go b/internal/engine/lib/sqlite_g_0000000000066fc0.go new file mode 100644 index 0000000..fa982fc --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000066fc0.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && s390x) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __HAVE_SPECULATION_SAFE_VALUE = 1 diff --git a/internal/engine/lib/sqlite_g_0000000000067bc0.go b/internal/engine/lib/sqlite_g_0000000000067bc0.go new file mode 100644 index 0000000..bdae755 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000067bc0.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __GNUC_PATCHLEVEL__ = 0 diff --git a/internal/engine/lib/sqlite_g_0000000000067fc0.go b/internal/engine/lib/sqlite_g_0000000000067fc0.go new file mode 100644 index 0000000..d95af7e --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000067fc0.go @@ -0,0 +1,109 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __DEC_EVAL_METHOD__ = 2 + +const __FLT32X_DECIMAL_DIG__ = 17 + +const __FLT32X_DENORM_MIN__ = 0 + +const __FLT32X_DIG__ = 15 + +const __FLT32X_EPSILON__ = 0 + +const __FLT32X_HAS_DENORM__ = 1 + +const __FLT32X_HAS_INFINITY__ = 1 + +const __FLT32X_HAS_QUIET_NAN__ = 1 + +const __FLT32X_MANT_DIG__ = 53 + +const __FLT32X_MAX_10_EXP__ = 308 + +const __FLT32X_MAX_EXP__ = 1024 + +const __FLT32X_MAX__ = 0 + +const __FLT32X_MIN_10_EXP__ = -307 + +const __FLT32X_MIN_EXP__ = -1021 + +const __FLT32X_MIN__ = 0 + +const __FLT32X_NORM_MAX__ = 0 + +const __FLT32_DECIMAL_DIG__ = 9 + +const __FLT32_DENORM_MIN__ = 0 + +const __FLT32_DIG__ = 6 + +const __FLT32_EPSILON__ = 0 + +const __FLT32_HAS_DENORM__ = 1 + +const __FLT32_HAS_INFINITY__ = 1 + +const __FLT32_HAS_QUIET_NAN__ = 1 + +const __FLT32_MANT_DIG__ = 24 + +const __FLT32_MAX_10_EXP__ = 38 + +const __FLT32_MAX_EXP__ = 128 + +const __FLT32_MAX__ = 0 + +const __FLT32_MIN_10_EXP__ = -37 + +const __FLT32_MIN_EXP__ = -125 + +const __FLT32_MIN__ = 0 + +const __FLT32_NORM_MAX__ = 0 + +const __FLT64_DECIMAL_DIG__ = 17 + +const __FLT64_DENORM_MIN__ = 0 + +const __FLT64_DIG__ = 15 + +const __FLT64_EPSILON__ = 0 + +const __FLT64_HAS_DENORM__ = 1 + +const __FLT64_HAS_INFINITY__ = 1 + +const __FLT64_HAS_QUIET_NAN__ = 1 + +const __FLT64_MANT_DIG__ = 53 + +const __FLT64_MAX_10_EXP__ = 308 + +const __FLT64_MAX_EXP__ = 1024 + +const __FLT64_MAX__ = 0 + +const __FLT64_MIN_10_EXP__ = -307 + +const __FLT64_MIN_EXP__ = -1021 + +const __FLT64_MIN__ = 0 + +const __FLT64_NORM_MAX__ = 0 + +const __GCC_IEC_559 = 2 + +const __GCC_IEC_559_COMPLEX = 2 + +const __LONG_LONG_WIDTH__ = 64 + +const __SCHAR_WIDTH__ = 8 + +const __SIG_ATOMIC_MIN__ = -2147483648 + +const __SIG_ATOMIC_TYPE__ = 0 diff --git a/internal/engine/lib/sqlite_g_0000000000067fc3.go b/internal/engine/lib/sqlite_g_0000000000067fc3.go new file mode 100644 index 0000000..ea7ce5d --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000067fc3.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +type tm = Ttm diff --git a/internal/engine/lib/sqlite_g_0000000000067fff.go b/internal/engine/lib/sqlite_g_0000000000067fff.go new file mode 100644 index 0000000..1aedb10 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000067fff.go @@ -0,0 +1,45 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +import ( + "github.com/hanzoai/sqlite/internal/libc" +) + +const M_1_PI = 0 + +const M_2_PI = 0 + +const M_2_SQRTPI = 0 + +const M_E = 0 + +const M_LN10 = 0 + +const M_LN2 = 0 + +const M_LOG10E = 0 + +const M_LOG2E = 0 + +const M_PI = 3.141592653589793 + +const M_PI_2 = 0 + +const M_PI_4 = 0 + +const M_SQRT1_2 = 0 + +const M_SQRT2 = 0 + +// C documentation +// +// /* +// ** Implementation of 0-argument pi() function. +// */ +func _piFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + _ = argv + Xsqlite3_result_double(tls, context, float64(3.141592653589793)) +} diff --git a/internal/engine/lib/sqlite_g_000000000006c0cd.go b/internal/engine/lib/sqlite_g_000000000006c0cd.go new file mode 100644 index 0000000..b4d30f4 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000006c0cd.go @@ -0,0 +1,9 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && 386) || (freebsd && amd64) || (linux && 386) || (linux && amd64) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __SEG_FS = 1 + +const __SEG_GS = 1 diff --git a/internal/engine/lib/sqlite_g_000000000006c4cf.go b/internal/engine/lib/sqlite_g_000000000006c4cf.go new file mode 100644 index 0000000..4180113 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000006c4cf.go @@ -0,0 +1,3150 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (linux && 386) || (linux && amd64) || (linux && loong64) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* The DblquoteStr object holds the text of a double-quoted +// ** string for a prepared statement. A linked list of these objects +// ** is constructed during statement parsing and is held on Vdbe.pDblStr. +// ** When computing a normalized SQL statement for an SQL statement, that +// ** list is consulted for each double-quoted identifier to see if the +// ** identifier should really be a string literal. +// */ +type TDblquoteStr = struct { + FpNextStr uintptr + Fz [8]int8 +} + +type TFpDecode = struct { + Fn int32 + FiDP int32 + Fz uintptr + FzBuf [21]int8 + Fsign int8 + FisSpecial int8 +} + +// C documentation +// +// /* +// ** Extra floating-point literals to allow in JSON. +// */ +type TNanInfName = struct { + Fc1 int8 + Fc2 int8 + Fn int8 + FeType int8 + FnRepl int8 + FzMatch uintptr + FzRepl uintptr +} + +type TPorterTokenizer = struct { + Ftokenizer_v2 Tfts5_tokenizer_v2 + FpTokenizer uintptr + FaBuf [128]int8 +} + +type TReturning = struct { + FpParse uintptr + FpReturnEL uintptr + FretTrig TTrigger + FretTStep TTriggerStep + FiRetCur int32 + FnRetCol int32 + FiRetReg int32 + FzName [40]int8 +} + +type TWhereScan = struct { + FpOrigWC uintptr + FpWC uintptr + FzCollName uintptr + FpIdxExpr uintptr + Fk int32 + FopMask Tu32 + Fidxaff int8 + FiEquiv uint8 + FnEquiv uint8 + FaiCur [11]int32 + FaiColumn [11]Ti16 +} + +// C documentation +// +// /* +// ** Each builtin conversion character (ex: the 'd' in "%d") is described +// ** by an instance of the following structure +// */ +type Tet_info = struct { + Ffmttype int8 + Fbase TetByte + Fflags TetByte + Ftype1 TetByte + Fcharset TetByte + Fprefix TetByte + FiNxt int8 +} + +func Xsqlite3_filename_journal(tls *libc.TLS, zFilename uintptr) (r uintptr) { + if zFilename == uintptr(0) { + return uintptr(0) + } + zFilename = _databaseName(tls, zFilename) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + for zFilename != 0 && **(**int8)(__ccgo_up(zFilename)) != 0 { + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + } + return zFilename + uintptr(1) +} + +func Xsqlite3_snprintf(tls *libc.TLS, n int32, zBuf uintptr, zFormat uintptr, va uintptr) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var ap Tva_list + var _ /* acc at bp+0 */ TStrAccum + _ = ap + if n <= 0 { + return zBuf + } + _sqlite3StrAccumInit(tls, bp, uintptr(0), zBuf, n, 0) + ap = va + Xsqlite3_str_vappendf(tls, bp, zFormat, ap) + _ = ap + **(**int8)(__ccgo_up(zBuf + uintptr((**(**TStrAccum)(__ccgo_up(bp))).FnChar))) = 0 + return zBuf +} + +/* Maximum size of an sqlite3_log() message. */ + +// C documentation +// +// /* Return the current value for p */ +func Xsqlite3_str_value(tls *libc.TLS, p uintptr) (r uintptr) { + if p == uintptr(0) || (*Tsqlite3_str)(unsafe.Pointer(p)).FnChar == uint32(0) { + return uintptr(0) + } + **(**int8)(__ccgo_up((*Tsqlite3_str)(unsafe.Pointer(p)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(p)).FnChar))) = 0 + return (*Tsqlite3_str)(unsafe.Pointer(p)).FzText +} + +// C documentation +// +// /* +// ** Return a pointer to the name of Nth query parameter of the filename. +// */ +func Xsqlite3_uri_key(tls *libc.TLS, zFilename uintptr, N int32) (r uintptr) { + var v1 int32 + var v2 bool + var v3 uintptr + _, _, _ = v1, v2, v3 + if zFilename == uintptr(0) || N < 0 { + return uintptr(0) + } + zFilename = _databaseName(tls, zFilename) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + for { + if v2 = zFilename != 0 && **(**int8)(__ccgo_up(zFilename)) != 0; v2 { + v1 = N + N = N - 1 + } + if !(v2 && v1 > 0) { + break + } + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + } + if **(**int8)(__ccgo_up(zFilename)) != 0 { + v3 = zFilename + } else { + v3 = uintptr(0) + } + return v3 +} + +// C documentation +// +// /* +// ** CAPI3REF: Run-Time Library Version Numbers +// ** KEYWORDS: sqlite3_version sqlite3_sourceid +// ** +// ** These interfaces provide the same information as the [SQLITE_VERSION], +// ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros +// ** but are associated with the library instead of the header file. ^(Cautious +// ** programmers might include assert() statements in their application to +// ** verify that values returned by these interfaces match the macros in +// ** the header, and thus ensure that the application is +// ** compiled with matching library and header files. +// ** +// **
    +//	** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
    +//	** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
    +//	** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
    +//	** 
    )^ +// ** +// ** ^The sqlite3_version[] string constant contains the text of the +// ** [SQLITE_VERSION] macro. ^The sqlite3_libversion() function returns a +// ** pointer to the sqlite3_version[] string constant. The sqlite3_libversion() +// ** function is provided for use in DLLs since DLL users usually do not have +// ** direct access to string constants within the DLL. ^The +// ** sqlite3_libversion_number() function returns an integer equal to +// ** [SQLITE_VERSION_NUMBER]. ^(The sqlite3_sourceid() function returns +// ** a pointer to a string constant whose value is the same as the +// ** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built +// ** using an edited copy of [the amalgamation], then the last four characters +// ** of the hash might be different from [SQLITE_SOURCE_ID].)^ +// ** +// ** See also: [sqlite_version()] and [sqlite_source_id()]. +// */ +var Xsqlite3_version = [7]int8{'3', '.', '5', '3', '.', '2'} + +// C documentation +// +// /* +// ** sqlite3_snprintf() works like snprintf() except that it ignores the +// ** current locale settings. This is important for SQLite because we +// ** are not able to use a "," as the decimal point in place of "." as +// ** specified by some locales. +// ** +// ** Oops: The first two arguments of sqlite3_snprintf() are backwards +// ** from the snprintf() standard. Unfortunately, it is too late to change +// ** this without breaking compatibility, so we just have to live with the +// ** mistake. +// ** +// ** sqlite3_vsnprintf() is the varargs version. +// */ +func Xsqlite3_vsnprintf(tls *libc.TLS, n int32, zBuf uintptr, zFormat uintptr, ap Tva_list) (r uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* acc at bp+0 */ TStrAccum + if n <= 0 { + return zBuf + } + _sqlite3StrAccumInit(tls, bp, uintptr(0), zBuf, n, 0) + Xsqlite3_str_vappendf(tls, bp, zFormat, ap) + **(**int8)(__ccgo_up(zBuf + uintptr((**(**TStrAccum)(__ccgo_up(bp))).FnChar))) = 0 + return zBuf +} + +var _aDigits = [33]int8{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'} + +var _aPrefix = [7]int8{'-', 'x', '0', 0, 'X', '0'} + +var _aSpecial = [32]int8{ + 8: int8('b'), + 9: int8('t'), + 10: int8('n'), + 12: int8('f'), + 13: int8('r'), +} + +// C documentation +// +// /* +// ** The following table defines various date transformations of the form +// ** +// ** 'NNN days' +// ** +// ** Where NNN is an arbitrary floating-point number and "days" can be one +// ** of several units of time. +// */ +var _aXformType = [6]struct { + FnName Tu8 + FzName [7]int8 + FrLimit float32 + FrXform float32 +}{ + 0: { + FnName: uint8(6), + FzName: [7]int8{'s', 'e', 'c', 'o', 'n', 'd'}, + FrLimit: float32(4.6427e+14), + FrXform: float32(1), + }, + 1: { + FnName: uint8(6), + FzName: [7]int8{'m', 'i', 'n', 'u', 't', 'e'}, + FrLimit: float32(7.7379e+12), + FrXform: float32(60), + }, + 2: { + FnName: uint8(4), + FzName: [7]int8{'h', 'o', 'u', 'r'}, + FrLimit: float32(1.2897e+11), + FrXform: float32(3600), + }, + 3: { + FnName: uint8(3), + FzName: [7]int8{'d', 'a', 'y'}, + FrLimit: float32(5.373485e+06), + FrXform: float32(86400), + }, + 4: { + FnName: uint8(5), + FzName: [7]int8{'m', 'o', 'n', 't', 'h'}, + FrLimit: float32(176546), + FrXform: float32(2.592e+06), + }, + 5: { + FnName: uint8(4), + FzName: [7]int8{'y', 'e', 'a', 'r'}, + FrLimit: float32(14713), + FrXform: float32(3.1536e+07), + }, +} + +func _asciiFold(tls *libc.TLS, aOut uintptr, aIn uintptr, nByte int32) { + var c int8 + var i int32 + _, _ = c, i + i = 0 + for { + if !(i < nByte) { + break + } + c = **(**int8)(__ccgo_up(aIn + uintptr(i))) + if int32(c) >= int32('A') && int32(c) <= int32('Z') { + c = int8(int32(c) + libc.Int32FromInt32(32)) + } + **(**int8)(__ccgo_up(aOut + uintptr(i))) = c + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** If the DateTime p is raw number, try to figure out if it is +// ** a julian day number of a unix timestamp. Set the p value +// ** appropriately. +// */ +func _autoAdjustDate(tls *libc.TLS, p uintptr) { + var r float64 + _ = r + if !(int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0) || (*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0 { + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + } else { + if (*TDateTime)(unsafe.Pointer(p)).Fs >= float64(int64(-libc.Int32FromInt32(21086676))*libc.Int64FromInt32(10000)) && (*TDateTime)(unsafe.Pointer(p)).Fs <= float64(libc.Int64FromInt32(25340230)*libc.Int64FromInt32(10000)+libc.Int64FromInt32(799)) { + r = float64((*TDateTime)(unsafe.Pointer(p)).Fs*float64(1000)) + float64(2.1086676e+14) + _clearYMD_HMS_TZ(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(r + libc.Float64FromFloat64(0.5)) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = int8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + } + } +} + +// C documentation +// +// /* +// ** Clear the YMD and HMS and the TZ +// */ +func _clearYMD_HMS_TZ(tls *libc.TLS, p uintptr) { + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = 0 + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 +} + +/* +** On recent Windows platforms, the localtime_s() function is available +** as part of the "Secure CRT". It is essentially equivalent to +** localtime_r() available under most POSIX platforms, except that the +** order of the parameters is reversed. +** +** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx. +** +** If the user has not indicated to use localtime_r() or localtime_s() +** already, check for an MSVC build environment that provides +** localtime_s(). + */ + +// C documentation +// +// /* +// ** Code an OP_Affinity opcode to apply the column affinity string zAff +// ** to the n registers starting at base. +// ** +// ** As an optimization, SQLITE_AFF_BLOB and SQLITE_AFF_NONE entries (which +// ** are no-ops) at the beginning and end of zAff are ignored. If all entries +// ** in zAff are SQLITE_AFF_BLOB or SQLITE_AFF_NONE, then no code gets generated. +// ** +// ** This routine makes its own copy of zAff so that the caller is free +// ** to modify zAff after this routine returns. +// */ +func _codeApplyAffinity(tls *libc.TLS, pParse uintptr, base int32, n int32, zAff uintptr) { + var v uintptr + _ = v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if zAff == uintptr(0) { + return + } + /* Adjust base and n to skip over SQLITE_AFF_BLOB and SQLITE_AFF_NONE + ** entries at the beginning and end of the affinity string. + */ + for n > 0 && int32(**(**int8)(__ccgo_up(zAff))) <= int32(SQLITE_AFF_BLOB) { + n = n - 1 + base = base + 1 + zAff = zAff + 1 + } + for n > int32(1) && int32(**(**int8)(__ccgo_up(zAff + uintptr(n-int32(1))))) <= int32(SQLITE_AFF_BLOB) { + n = n - 1 + } + /* Code the OP_Affinity opcode if there is anything left to do. */ + if n > 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), base, n, 0, zAff, n) + } +} + +// C documentation +// +// /* +// ** Given the YYYY-MM-DD information current in p, determine if there +// ** is day-of-month overflow and set nFloor to the number of days that +// ** would need to be subtracted from the date in order to bring the +// ** date back to the end of the month. +// */ +func _computeFloor(tls *libc.TLS, p uintptr) { + if (*TDateTime)(unsafe.Pointer(p)).FD <= int32(28) { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = 0 + } else { + if int32(1)<<(*TDateTime)(unsafe.Pointer(p)).FM&int32(0x15aa) != 0 { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = 0 + } else { + if (*TDateTime)(unsafe.Pointer(p)).FM != int32(2) { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = libc.BoolInt8((*TDateTime)(unsafe.Pointer(p)).FD == libc.Int32FromInt32(31)) + } else { + if (*TDateTime)(unsafe.Pointer(p)).FY%int32(4) != 0 || (*TDateTime)(unsafe.Pointer(p)).FY%int32(100) == 0 && (*TDateTime)(unsafe.Pointer(p)).FY%int32(400) != 0 { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = int8((*TDateTime)(unsafe.Pointer(p)).FD - int32(28)) + } else { + (*TDateTime)(unsafe.Pointer(p)).FnFloor = int8((*TDateTime)(unsafe.Pointer(p)).FD - int32(29)) + } + } + } + } +} + +// C documentation +// +// /* +// ** Compute the Hour, Minute, and Seconds from the julian day number. +// */ +func _computeHMS(tls *libc.TLS, p uintptr) { + var day_min, day_ms int32 + _, _ = day_min, day_ms /* milliseconds, minutes into the day */ + if (*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0 { + return + } + _computeJD(tls, p) + day_ms = int32(((*TDateTime)(unsafe.Pointer(p)).FiJD + libc.Int64FromInt32(43200000)) % libc.Int64FromInt32(86400000)) + (*TDateTime)(unsafe.Pointer(p)).Fs = float64(day_ms%libc.Int32FromInt32(60000)) / float64(1000) + day_min = day_ms / int32(60000) + (*TDateTime)(unsafe.Pointer(p)).Fm = day_min % int32(60) + (*TDateTime)(unsafe.Pointer(p)).Fh = day_min / int32(60) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = int8(1) +} + +// C documentation +// +// /* +// ** Convert from YYYY-MM-DD HH:MM:SS to julian day. We always assume +// ** that the YYYY-MM-DD is according to the Gregorian calendar. +// ** +// ** Reference: Meeus page 61 +// */ +func _computeJD(tls *libc.TLS, p uintptr) { + var A, B, D, M, X1, X2, Y int32 + _, _, _, _, _, _, _ = A, B, D, M, X1, X2, Y + if (*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0 { + return + } + if (*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0 { + Y = (*TDateTime)(unsafe.Pointer(p)).FY + M = (*TDateTime)(unsafe.Pointer(p)).FM + D = (*TDateTime)(unsafe.Pointer(p)).FD + } else { + Y = int32(2000) /* If no YMD specified, assume 2000-Jan-01 */ + M = int32(1) + D = int32(1) + } + if Y < -int32(4713) || Y > int32(9999) || int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { + _datetimeError(tls, p) + return + } + if M <= int32(2) { + Y = Y - 1 + M = M + int32(12) + } + A = (Y + int32(4800)) / int32(100) + B = int32(38) - A + A/int32(4) + X1 = int32(36525) * (Y + int32(4716)) / int32(100) + X2 = int32(306001) * (M + int32(1)) / int32(10000) + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(float64((float64(X1+X2+D+B) - libc.Float64FromFloat64(1524.5)) * libc.Float64FromInt32(86400000))) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = int8(1) + if (*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0 { + **(**Tsqlite3_int64)(__ccgo_up(p)) += int64((*TDateTime)(unsafe.Pointer(p)).Fh*int32(3600000)+(*TDateTime)(unsafe.Pointer(p)).Fm*int32(60000)) + int64(float64((*TDateTime)(unsafe.Pointer(p)).Fs*libc.Float64FromInt32(1000))+libc.Float64FromFloat64(0.5)) + if (*TDateTime)(unsafe.Pointer(p)).Ftz != 0 { + **(**Tsqlite3_int64)(__ccgo_up(p)) -= int64((*TDateTime)(unsafe.Pointer(p)).Ftz * int32(60000)) + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = 0 + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + } + } +} + +// C documentation +// +// /* +// ** Compute the Year, Month, and Day from the julian day number. +// */ +func _computeYMD(tls *libc.TLS, p uintptr) { + var A, B, C, D, E, X1, Z, alpha, v1 int32 + _, _, _, _, _, _, _, _, _ = A, B, C, D, E, X1, Z, alpha, v1 + if (*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0 { + return + } + if !((*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0) { + (*TDateTime)(unsafe.Pointer(p)).FY = int32(2000) + (*TDateTime)(unsafe.Pointer(p)).FM = int32(1) + (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) + } else { + if !(_validJulianDay(tls, (*TDateTime)(unsafe.Pointer(p)).FiJD) != 0) { + _datetimeError(tls, p) + return + } else { + Z = int32(((*TDateTime)(unsafe.Pointer(p)).FiJD + libc.Int64FromInt32(43200000)) / libc.Int64FromInt32(86400000)) + alpha = int32((float64(Z)+libc.Float64FromFloat64(32044.75))/libc.Float64FromFloat64(36524.25)) - int32(52) + A = Z + int32(1) + alpha - (alpha+int32(100))/int32(4) + int32(25) + B = A + int32(1524) + C = int32((float64(B) - libc.Float64FromFloat64(122.1)) / libc.Float64FromFloat64(365.25)) + D = int32(36525) * (C & int32(32767)) / int32(100) + E = int32(float64(B-D) / libc.Float64FromFloat64(30.6001)) + X1 = int32(float64(libc.Float64FromFloat64(30.6001) * float64(E))) + (*TDateTime)(unsafe.Pointer(p)).FD = B - D - X1 + if E < int32(14) { + v1 = E - int32(1) + } else { + v1 = E - int32(13) + } + (*TDateTime)(unsafe.Pointer(p)).FM = v1 + if (*TDateTime)(unsafe.Pointer(p)).FM > int32(2) { + v1 = C - int32(4716) + } else { + v1 = C - int32(4715) + } + (*TDateTime)(unsafe.Pointer(p)).FY = v1 + } + } + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = int8(1) +} + +var _cume_distName = [10]int8{'c', 'u', 'm', 'e', '_', 'd', 'i', 's', 't'} + +// C documentation +// +// /* +// ** The Pager stores the Database filename, Journal filename, and WAL filename +// ** consecutively in memory, in that order. The database filename is prefixed +// ** by four zero bytes. Locate the start of the database filename by searching +// ** backwards for the first byte following four consecutive zero bytes. +// ** +// ** This only works if the filename passed in was obtained from the Pager. +// */ +func _databaseName(tls *libc.TLS, zName uintptr) (r uintptr) { + for int32(**(**int8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(1))))) != 0 || int32(**(**int8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(2))))) != 0 || int32(**(**int8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(3))))) != 0 || int32(**(**int8)(__ccgo_up(zName + uintptr(-libc.Int32FromInt32(4))))) != 0 { + zName = zName - 1 + } + return zName +} + +// C documentation +// +// /* +// ** date( TIMESTRING, MOD, MOD, ...) +// ** +// ** Return YYYY-MM-DD +// */ +func _dateFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var Y int32 + var _ /* x at bp+0 */ TDateTime + var _ /* zBuf at bp+48 */ [16]int8 + _ = Y + if _isDate(tls, context, argc, argv, bp) == 0 { + _computeYMD(tls, bp) + Y = (**(**TDateTime)(__ccgo_up(bp))).FY + if Y < 0 { + Y = -Y + } + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(1)] = int8(int32('0') + Y/int32(1000)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(2)] = int8(int32('0') + Y/int32(100)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(3)] = int8(int32('0') + Y/int32(10)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(4)] = int8(int32('0') + Y%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(5)] = int8('-') + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(6)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FM/int32(10)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(7)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FM%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(8)] = int8('-') + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(9)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FD/int32(10)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(10)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FD%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(11)] = 0 + if (**(**TDateTime)(__ccgo_up(bp))).FY < 0 { + (**(**[16]int8)(__ccgo_up(bp + 48)))[0] = int8('-') + Xsqlite3_result_text(tls, context, bp+48, int32(11), uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_text(tls, context, bp+48+1, int32(10), uintptr(-libc.Int32FromInt32(1))) + } + } +} + +// C documentation +// +// /* +// ** datetime( TIMESTRING, MOD, MOD, ...) +// ** +// ** Return YYYY-MM-DD HH:MM:SS +// */ +func _datetimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var Y, n, s int32 + var _ /* x at bp+0 */ TDateTime + var _ /* zBuf at bp+48 */ [32]int8 + _, _, _ = Y, n, s + if _isDate(tls, context, argc, argv, bp) == 0 { + _computeYMD_HMS(tls, bp) + Y = (**(**TDateTime)(__ccgo_up(bp))).FY + if Y < 0 { + Y = -Y + } + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(1)] = int8(int32('0') + Y/int32(1000)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(2)] = int8(int32('0') + Y/int32(100)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(3)] = int8(int32('0') + Y/int32(10)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(4)] = int8(int32('0') + Y%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(5)] = int8('-') + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(6)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FM/int32(10)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(7)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FM%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(8)] = int8('-') + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(9)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FD/int32(10)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(10)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).FD%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(11)] = int8(' ') + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(12)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fh/int32(10)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(13)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fh%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(14)] = int8(':') + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(15)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fm/int32(10)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(16)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fm%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(17)] = int8(':') + if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { + s = int32(float64(libc.Float64FromFloat64(1000)*(**(**TDateTime)(__ccgo_up(bp))).Fs) + libc.Float64FromFloat64(0.5)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(18)] = int8(int32('0') + s/int32(10000)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(19)] = int8(int32('0') + s/int32(1000)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(20)] = int8('.') + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(21)] = int8(int32('0') + s/int32(100)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(22)] = int8(int32('0') + s/int32(10)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(23)] = int8(int32('0') + s%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(24)] = 0 + n = int32(24) + } else { + s = int32((**(**TDateTime)(__ccgo_up(bp))).Fs) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(18)] = int8(int32('0') + s/int32(10)%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(19)] = int8(int32('0') + s%int32(10)) + (**(**[32]int8)(__ccgo_up(bp + 48)))[int32(20)] = 0 + n = int32(20) + } + if (**(**TDateTime)(__ccgo_up(bp))).FY < 0 { + (**(**[32]int8)(__ccgo_up(bp + 48)))[0] = int8('-') + Xsqlite3_result_text(tls, context, bp+48, n, uintptr(-libc.Int32FromInt32(1))) + } else { + Xsqlite3_result_text(tls, context, bp+48+1, n-int32(1), uintptr(-libc.Int32FromInt32(1))) + } + } +} + +// C documentation +// +// /* +// ** Compute the number of days after the most recent January 1. +// ** +// ** In other words, compute the zero-based day number for the +// ** current year: +// ** +// ** Jan01 = 0, Jan02 = 1, ..., Jan31 = 30, Feb01 = 31, ... +// ** Dec31 = 364 or 365. +// */ +func _daysAfterJan01(tls *libc.TLS, pDate uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* jan01 at bp+0 */ TDateTime + **(**TDateTime)(__ccgo_up(bp)) = **(**TDateTime)(__ccgo_up(pDate)) + (**(**TDateTime)(__ccgo_up(bp))).FvalidJD = 0 + (**(**TDateTime)(__ccgo_up(bp))).FM = int32(1) + (**(**TDateTime)(__ccgo_up(bp))).FD = int32(1) + _computeJD(tls, bp) + return int32(((*TDateTime)(unsafe.Pointer(pDate)).FiJD - (**(**TDateTime)(__ccgo_up(bp))).FiJD + libc.Int64FromInt32(43200000)) / libc.Int64FromInt32(86400000)) +} + +var _dense_rankName = [11]int8{'d', 'e', 'n', 's', 'e', '_', 'r', 'a', 'n', 'k'} + +// C documentation +// +// /* +// ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of +// ** bytes in this text up to but excluding the first character in +// ** a host parameter. If the text contains no host parameters, return +// ** the total number of bytes in the text. +// */ +func _findNextHostParameter(tls *libc.TLS, zSql uintptr, pnToken uintptr) (r Ti64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var n, nTotal Ti64 + var _ /* tokenType at bp+0 */ int32 + _, _ = n, nTotal + nTotal = 0 + **(**Ti64)(__ccgo_up(pnToken)) = 0 + for **(**int8)(__ccgo_up(zSql)) != 0 { + n = _sqlite3GetToken(tls, zSql, bp) + if **(**int32)(__ccgo_up(bp)) == int32(TK_VARIABLE) { + **(**Ti64)(__ccgo_up(pnToken)) = n + break + } + nTotal = nTotal + n + zSql = zSql + uintptr(n) + } + return nTotal +} + +var _first_valueName = [12]int8{'f', 'i', 'r', 's', 't', '_', 'v', 'a', 'l', 'u', 'e'} + +var _fmtinfo = [23]Tet_info{ + 0: { + Ffmttype: int8('s'), + Fflags: uint8(4), + Ftype1: uint8(etSTRING), + FiNxt: int8(1), + }, + 1: { + Ffmttype: int8('E'), + Fflags: uint8(1), + Ftype1: uint8(etEXP), + Fcharset: uint8(14), + }, + 2: { + Ffmttype: int8('u'), + Fbase: uint8(10), + Ftype1: uint8(etDECIMAL), + FiNxt: int8(3), + }, + 3: { + Ffmttype: int8('G'), + Fflags: uint8(1), + Ftype1: uint8(etGENERIC), + Fcharset: uint8(14), + }, + 4: { + Ffmttype: int8('w'), + Fflags: uint8(4), + Ftype1: uint8(etESCAPE_w), + }, + 5: { + Ffmttype: int8('x'), + Fbase: uint8(16), + Fcharset: uint8(16), + Fprefix: uint8(1), + }, + 6: { + Ffmttype: int8('c'), + Ftype1: uint8(etCHARX), + }, + 7: { + Ffmttype: int8('z'), + Fflags: uint8(4), + Ftype1: uint8(etDYNSTRING), + FiNxt: int8(6), + }, + 8: { + Ffmttype: int8('d'), + Fbase: uint8(10), + Fflags: uint8(1), + Ftype1: uint8(etDECIMAL), + }, + 9: { + Ffmttype: int8('e'), + Fflags: uint8(1), + Ftype1: uint8(etEXP), + Fcharset: uint8(30), + }, + 10: { + Ffmttype: int8('f'), + Fflags: uint8(1), + Ftype1: uint8(etFLOAT), + }, + 11: { + Ffmttype: int8('g'), + Fflags: uint8(1), + Ftype1: uint8(etGENERIC), + Fcharset: uint8(30), + }, + 12: { + Ffmttype: int8('Q'), + Fflags: uint8(4), + Ftype1: uint8(etESCAPE_Q), + }, + 13: { + Ffmttype: int8('i'), + Fbase: uint8(10), + Fflags: uint8(1), + Ftype1: uint8(etDECIMAL), + }, + 14: { + Ffmttype: int8('%'), + Ftype1: uint8(etPERCENT), + FiNxt: int8(16), + }, + 15: { + Ffmttype: int8('T'), + Ftype1: uint8(etTOKEN), + }, + 16: { + Ffmttype: int8('S'), + Ftype1: uint8(etSRCITEM), + }, + 17: { + Ffmttype: int8('X'), + Fbase: uint8(16), + Fprefix: uint8(4), + }, + 18: { + Ffmttype: int8('n'), + Ftype1: uint8(etSIZE), + }, + 19: { + Ffmttype: int8('o'), + Fbase: uint8(8), + Fprefix: uint8(2), + FiNxt: int8(17), + }, + 20: { + Ffmttype: int8('p'), + Fbase: uint8(16), + Ftype1: uint8(etPOINTER), + Fprefix: uint8(1), + }, + 21: { + Ffmttype: int8('q'), + Fflags: uint8(4), + Ftype1: uint8(etESCAPE_q), + }, + 22: { + Ffmttype: int8('r'), + Fbase: uint8(10), + Fflags: uint8(1), + Ftype1: uint8(etORDINAL), + }, +} + +/* Additional Notes: +** +** %S Takes a pointer to SrcItem. Shows name or database.name +** %!S Like %S but prefer the zName over the zAlias + */ + +// C documentation +// +// /* +// ** Argument pIn points to the first character in what is expected to be +// ** a comma-separated list of SQL literals followed by a ')' character. +// ** If it actually is this, return a pointer to the ')'. Otherwise, return +// ** NULL to indicate a parse error. +// */ +func _fts5ConfigSkipArgs(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + for int32(1) != 0 { + p = _fts5ConfigSkipWhitespace(tls, p) + p = _fts5ConfigSkipLiteral(tls, p) + p = _fts5ConfigSkipWhitespace(tls, p) + if p == uintptr(0) || int32(**(**int8)(__ccgo_up(p))) == int32(')') { + break + } + if int32(**(**int8)(__ccgo_up(p))) != int32(',') { + p = uintptr(0) + break + } + p = p + 1 + } + return p +} + +// C documentation +// +// /* +// ** Argument pIn points to a character that is part of a nul-terminated +// ** string. Return a pointer to the first character following *pIn in +// ** the string that is not a "bareword" character. +// */ +func _fts5ConfigSkipBareword(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + for _sqlite3Fts5IsBareword(tls, **(**int8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + if p == pIn { + p = uintptr(0) + } + return p +} + +// C documentation +// +// /* +// ** Argument pIn points to a character that is part of a nul-terminated +// ** string. Return a pointer to the first character following *pIn in +// ** the string that is not a white-space character. +// */ +func _fts5ConfigSkipWhitespace(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + if p != 0 { + for _fts5_iswhitespace(tls, **(**int8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + } + return p +} + +// C documentation +// +// /* +// ** The first character of the string pointed to by argument z is guaranteed +// ** to be an open-quote character (see function fts5_isopenquote()). +// ** +// ** This function searches for the corresponding close-quote character within +// ** the string and, if found, dequotes the string in place and adds a new +// ** nul-terminator byte. +// ** +// ** If the close-quote is found, the value returned is the byte offset of +// ** the character immediately following it. Or, if the close-quote is not +// ** found, -1 is returned. If -1 is returned, the buffer is left in an +// ** undefined state. +// */ +func _fts5Dequote(tls *libc.TLS, z uintptr) (r int32) { + var iIn, iOut, v1, v2 int32 + var q int8 + _, _, _, _, _ = iIn, iOut, q, v1, v2 + iIn = int32(1) + iOut = 0 + q = **(**int8)(__ccgo_up(z)) + /* Set stack variable q to the close-quote character */ + if int32(q) == int32('[') { + q = int8(']') + } + for **(**int8)(__ccgo_up(z + uintptr(iIn))) != 0 { + if int32(**(**int8)(__ccgo_up(z + uintptr(iIn)))) == int32(q) { + if int32(**(**int8)(__ccgo_up(z + uintptr(iIn+int32(1))))) != int32(q) { + /* Character iIn was the close quote. */ + iIn = iIn + 1 + break + } else { + /* Character iIn and iIn+1 form an escaped quote character. Skip + ** the input cursor past both and copy a single quote character + ** to the output buffer. */ + iIn = iIn + int32(2) + v1 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(z + uintptr(v1))) = q + } + } else { + v1 = iOut + iOut = iOut + 1 + v2 = iIn + iIn = iIn + 1 + **(**int8)(__ccgo_up(z + uintptr(v1))) = **(**int8)(__ccgo_up(z + uintptr(v2))) + } + } + **(**int8)(__ccgo_up(z + uintptr(iOut))) = int8('\000') + return iIn +} + +// C documentation +// +// /* +// ** Assuming that buffer z is at least nByte bytes in size and contains a +// ** valid utf-8 string, return the number of characters in the string. +// */ +func _fts5ExprCountChar(tls *libc.TLS, z uintptr, nByte int32) (r int32) { + var ii, nRet int32 + _, _ = ii, nRet + nRet = 0 + ii = 0 + for { + if !(ii < nByte) { + break + } + if int32(**(**int8)(__ccgo_up(z + uintptr(ii))))&int32(0xC0) != int32(0x80) { + nRet = nRet + 1 + } + goto _1 + _1: + ; + ii = ii + 1 + } + return nRet +} + +func _fts5ExprIsspace(tls *libc.TLS, t int8) (r int32) { + return libc.BoolInt32(int32(t) == int32(' ') || int32(t) == int32('\t') || int32(t) == int32('\n') || int32(t) == int32('\r')) +} + +func _fts5PorterGobbleVC(tls *libc.TLS, zStem uintptr, nStem int32, bPrevCons int32) (r int32) { + var bCons, i, v2 int32 + _, _, _ = bCons, i, v2 + bCons = bPrevCons + /* Scan for a vowel */ + i = 0 + for { + if !(i < nStem) { + break + } + v2 = libc.BoolInt32(!(_fts5PorterIsVowel(tls, **(**int8)(__ccgo_up(zStem + uintptr(i))), bCons) != 0)) + bCons = v2 + if 0 == v2 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + /* Scan for a consonent */ + i = i + 1 + for { + if !(i < nStem) { + break + } + v2 = libc.BoolInt32(!(_fts5PorterIsVowel(tls, **(**int8)(__ccgo_up(zStem + uintptr(i))), bCons) != 0)) + bCons = v2 + if v2 != 0 { + return i + int32(1) + } + goto _3 + _3: + ; + i = i + 1 + } + return 0 +} + +func _fts5PorterIsVowel(tls *libc.TLS, c int8, bYIsVowel int32) (r int32) { + return libc.BoolInt32(int32(c) == int32('a') || int32(c) == int32('e') || int32(c) == int32('i') || int32(c) == int32('o') || int32(c) == int32('u') || bYIsVowel != 0 && int32(c) == int32('y')) +} + +func _fts5PorterStep1A(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) { + var nBuf int32 + _ = nBuf + nBuf = **(**int32)(__ccgo_up(pnBuf)) + if int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(1))))) == int32('s') { + if int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) == int32('e') { + if nBuf > int32(4) && int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(4))))) == int32('s') && int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(3))))) == int32('s') || nBuf > int32(3) && int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(3))))) == int32('i') { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } else { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(1) + } + } else { + if int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) != int32('s') { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(1) + } + } + } +} + +// C documentation +// +// /* porter rule condition: (m > 1 and (*S or *T)) */ +func _fts5Porter_MGt1_and_S_or_T(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) { + return libc.BoolInt32((int32(**(**int8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('s') || int32(**(**int8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('t')) && _fts5Porter_MGt1(tls, zStem, nStem) != 0) +} + +// C documentation +// +// /* porter rule condition: (*o) */ +func _fts5Porter_Ostar(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) { + var bCons, i, mask int32 + _, _, _ = bCons, i, mask + if int32(**(**int8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('w') || int32(**(**int8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('x') || int32(**(**int8)(__ccgo_up(zStem + uintptr(nStem-int32(1))))) == int32('y') { + return 0 + } else { + mask = 0 + bCons = 0 + i = 0 + for { + if !(i < nStem) { + break + } + bCons = libc.BoolInt32(!(_fts5PorterIsVowel(tls, **(**int8)(__ccgo_up(zStem + uintptr(i))), bCons) != 0)) + mask = mask< 0)) != 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +/************************************************************************** +*************************************************************************** +** GENERATED CODE STARTS HERE (mkportersteps.tcl) + */ + +// C documentation +// +// /* +// ** pToken is a buffer nToken bytes in size that may or may not contain +// ** an embedded 0x00 byte. If it does, return the number of bytes in +// ** the buffer before the 0x00. If it does not, return nToken. +// */ +func _fts5QueryTerm(tls *libc.TLS, pToken uintptr, nToken int32) (r int32) { + var ii int32 + _ = ii + ii = 0 + for { + if !(ii < nToken && **(**int8)(__ccgo_up(pToken + uintptr(ii))) != 0) { + break + } + goto _1 + _1: + ; + ii = ii + 1 + } + return ii +} + +// C documentation +// +// /* +// ** This function is an xTokenize() callback used by the auxiliary snippet() +// ** function. Its job is to identify tokens that are the first in a sentence. +// ** For each such token, an entry is added to the SFinder.aFirst[] array. +// */ +func _fts5SentenceFinderCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iStartOff int32, iEndOff int32) (r int32) { + var c int8 + var i, rc int32 + var p uintptr + _, _, _, _ = c, i, p, rc + rc = SQLITE_OK + _ = pToken + _ = nToken + _ = iEndOff + if tflags&int32(FTS5_TOKEN_COLOCATED) == 0 { + p = pContext + if (*TFts5SFinder)(unsafe.Pointer(p)).FiPos > 0 { + c = 0 + i = iStartOff - int32(1) + for { + if !(i >= 0) { + break + } + c = **(**int8)(__ccgo_up((*TFts5SFinder)(unsafe.Pointer(p)).FzDoc + uintptr(i))) + if int32(c) != int32(' ') && int32(c) != int32('\t') && int32(c) != int32('\n') && int32(c) != int32('\r') { + break + } + goto _1 + _1: + ; + i = i - 1 + } + if i != iStartOff-int32(1) && (int32(c) == int32('.') || int32(c) == int32(':')) { + rc = _fts5SentenceFinderAdd(tls, p, (*TFts5SFinder)(unsafe.Pointer(p)).FiPos) + } + } else { + rc = _fts5SentenceFinderAdd(tls, p, 0) + } + (*TFts5SFinder)(unsafe.Pointer(p)).FiPos = (*TFts5SFinder)(unsafe.Pointer(p)).FiPos + 1 + } + return rc +} + +func _fts5_isdigit(tls *libc.TLS, a int8) (r int32) { + return libc.BoolInt32(int32(a) >= int32('0') && int32(a) <= int32('9')) +} + +func _fts5_isopenquote(tls *libc.TLS, x int8) (r int32) { + return libc.BoolInt32(int32(x) == int32('"') || int32(x) == int32('\'') || int32(x) == int32('[') || int32(x) == int32('`')) +} + +func _fts5_iswhitespace(tls *libc.TLS, x int8) (r int32) { + return libc.BoolInt32(int32(x) == int32(' ')) +} + +// C documentation +// +// /* +// ** Growing our own isspace() routine this way is twice as fast as +// ** the library isspace() function. +// */ +var _geopolyIsSpace = [256]int8{ + 9: int8(1), + 10: int8(1), + 13: int8(1), + 32: int8(1), +} + +/* Compiler and version */ + +// C documentation +// +// /* Array for converting from half-bytes (nybbles) into ASCII hex +// ** digits. */ +var _hexdigits = [16]int8{ + 0: int8('0'), + 1: int8('1'), + 2: int8('2'), + 3: int8('3'), + 4: int8('4'), + 5: int8('5'), + 6: int8('6'), + 7: int8('7'), + 8: int8('8'), + 9: int8('9'), + 10: int8('A'), + 11: int8('B'), + 12: int8('C'), + 13: int8('D'), + 14: int8('E'), + 15: int8('F'), +} + +// C documentation +// +// /* +// ** Measure the number of characters needed to output the given +// ** identifier. The number returned includes any quotes used +// ** but does not include the null terminator. +// ** +// ** The estimate is conservative. It might be larger that what is +// ** really needed. +// */ +func _identLength(tls *libc.TLS, z uintptr) (r Ti64) { + var n Ti64 + _ = n + n = 0 + for { + if !(**(**int8)(__ccgo_up(z)) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(z))) == int32('"') { + n = n + 1 + } + goto _1 + _1: + ; + n = n + 1 + z = z + 1 + } + return n + int64(2) +} + +// C documentation +// +// /* +// ** The input pBlob is guaranteed to be a Blob that is not marked +// ** with MEM_Zero. Return true if it could be a zero-blob. +// */ +func _isAllZero(tls *libc.TLS, z uintptr, n int32) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < n) { + break + } + if **(**int8)(__ccgo_up(z + uintptr(i))) != 0 { + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + return int32(1) +} + +// C documentation +// +// /* Append a comma separator to the output buffer, if the previous +// ** character is not '[' or '{'. +// */ +func _jsonAppendSeparator(tls *libc.TLS, p uintptr) { + var c int8 + _ = c + if (*TJsonString)(unsafe.Pointer(p)).FnUsed == uint64(0) { + return + } + c = **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed-uint64(1)))) + if int32(c) == int32('[') || int32(c) == int32('{') { + return + } + _jsonAppendChar(tls, p, int8(',')) +} + +// C documentation +// +// /* +// ** If z[0] is 'u' and is followed by exactly 4 hexadecimal character, +// ** then set *pOp to JSONB_TEXTJ and return true. If not, do not make +// ** any changes to *pOp and return false. +// */ +func _jsonIs4HexB(tls *libc.TLS, z uintptr, pOp uintptr) (r int32) { + if int32(**(**int8)(__ccgo_up(z))) != int32('u') { + return 0 + } + if !(_jsonIs4Hex(tls, z+1) != 0) { + return 0 + } + **(**int32)(__ccgo_up(pOp)) = int32(JSONB_TEXTJ) + return int32(1) +} + +// C documentation +// +// /* +// ** Characters that are special to JSON. Control characters, +// ** '"' and '\\' and '\''. Actually, '\'' is not special to +// ** canonical JSON, but it is special in JSON-5, so we include +// ** it in the set of special characters. +// */ +var _jsonIsOk = [256]int8{ + 32: int8(1), + 33: int8(1), + 35: int8(1), + 36: int8(1), + 37: int8(1), + 38: int8(1), + 40: int8(1), + 41: int8(1), + 42: int8(1), + 43: int8(1), + 44: int8(1), + 45: int8(1), + 46: int8(1), + 47: int8(1), + 48: int8(1), + 49: int8(1), + 50: int8(1), + 51: int8(1), + 52: int8(1), + 53: int8(1), + 54: int8(1), + 55: int8(1), + 56: int8(1), + 57: int8(1), + 58: int8(1), + 59: int8(1), + 60: int8(1), + 61: int8(1), + 62: int8(1), + 63: int8(1), + 64: int8(1), + 65: int8(1), + 66: int8(1), + 67: int8(1), + 68: int8(1), + 69: int8(1), + 70: int8(1), + 71: int8(1), + 72: int8(1), + 73: int8(1), + 74: int8(1), + 75: int8(1), + 76: int8(1), + 77: int8(1), + 78: int8(1), + 79: int8(1), + 80: int8(1), + 81: int8(1), + 82: int8(1), + 83: int8(1), + 84: int8(1), + 85: int8(1), + 86: int8(1), + 87: int8(1), + 88: int8(1), + 89: int8(1), + 90: int8(1), + 91: int8(1), + 93: int8(1), + 94: int8(1), + 95: int8(1), + 96: int8(1), + 97: int8(1), + 98: int8(1), + 99: int8(1), + 100: int8(1), + 101: int8(1), + 102: int8(1), + 103: int8(1), + 104: int8(1), + 105: int8(1), + 106: int8(1), + 107: int8(1), + 108: int8(1), + 109: int8(1), + 110: int8(1), + 111: int8(1), + 112: int8(1), + 113: int8(1), + 114: int8(1), + 115: int8(1), + 116: int8(1), + 117: int8(1), + 118: int8(1), + 119: int8(1), + 120: int8(1), + 121: int8(1), + 122: int8(1), + 123: int8(1), + 124: int8(1), + 125: int8(1), + 126: int8(1), + 127: int8(1), + 128: int8(1), + 129: int8(1), + 130: int8(1), + 131: int8(1), + 132: int8(1), + 133: int8(1), + 134: int8(1), + 135: int8(1), + 136: int8(1), + 137: int8(1), + 138: int8(1), + 139: int8(1), + 140: int8(1), + 141: int8(1), + 142: int8(1), + 143: int8(1), + 144: int8(1), + 145: int8(1), + 146: int8(1), + 147: int8(1), + 148: int8(1), + 149: int8(1), + 150: int8(1), + 151: int8(1), + 152: int8(1), + 153: int8(1), + 154: int8(1), + 155: int8(1), + 156: int8(1), + 157: int8(1), + 158: int8(1), + 159: int8(1), + 160: int8(1), + 161: int8(1), + 162: int8(1), + 163: int8(1), + 164: int8(1), + 165: int8(1), + 166: int8(1), + 167: int8(1), + 168: int8(1), + 169: int8(1), + 170: int8(1), + 171: int8(1), + 172: int8(1), + 173: int8(1), + 174: int8(1), + 175: int8(1), + 176: int8(1), + 177: int8(1), + 178: int8(1), + 179: int8(1), + 180: int8(1), + 181: int8(1), + 182: int8(1), + 183: int8(1), + 184: int8(1), + 185: int8(1), + 186: int8(1), + 187: int8(1), + 188: int8(1), + 189: int8(1), + 190: int8(1), + 191: int8(1), + 192: int8(1), + 193: int8(1), + 194: int8(1), + 195: int8(1), + 196: int8(1), + 197: int8(1), + 198: int8(1), + 199: int8(1), + 200: int8(1), + 201: int8(1), + 202: int8(1), + 203: int8(1), + 204: int8(1), + 205: int8(1), + 206: int8(1), + 207: int8(1), + 208: int8(1), + 209: int8(1), + 210: int8(1), + 211: int8(1), + 212: int8(1), + 213: int8(1), + 214: int8(1), + 215: int8(1), + 216: int8(1), + 217: int8(1), + 218: int8(1), + 219: int8(1), + 220: int8(1), + 221: int8(1), + 222: int8(1), + 223: int8(1), + 224: int8(1), + 225: int8(1), + 226: int8(1), + 227: int8(1), + 228: int8(1), + 229: int8(1), + 230: int8(1), + 231: int8(1), + 232: int8(1), + 233: int8(1), + 234: int8(1), + 235: int8(1), + 236: int8(1), + 237: int8(1), + 238: int8(1), + 239: int8(1), + 240: int8(1), + 241: int8(1), + 242: int8(1), + 243: int8(1), + 244: int8(1), + 245: int8(1), + 246: int8(1), + 247: int8(1), + 248: int8(1), + 249: int8(1), + 250: int8(1), + 251: int8(1), + 252: int8(1), + 253: int8(1), + 254: int8(1), + 255: int8(1), +} + +// C documentation +// +// /* +// ** Growing our own isspace() routine this way is twice as fast as +// ** the library isspace() function, resulting in a 7% overall performance +// ** increase for the text-JSON parser. (Ubuntu14.10 gcc 4.8.4 x64 with -Os). +// */ +var _jsonIsSpace = [256]int8{ + 9: int8(1), + 10: int8(1), + 13: int8(1), + 32: int8(1), +} + +// C documentation +// +// /* +// ** The set of all space characters recognized by jsonIsspace(). +// ** Useful as the second argument to strspn(). +// */ +var _jsonSpaces = [5]int8{9, 10, 13, ' '} + +var _lagName = [4]int8{'l', 'a', 'g'} + +var _last_valueName = [11]int8{'l', 'a', 's', 't', '_', 'v', 'a', 'l', 'u', 'e'} + +var _leadName = [5]int8{'l', 'e', 'a', 'd'} + +var _nth_valueName = [10]int8{'n', 't', 'h', '_', 'v', 'a', 'l', 'u', 'e'} + +var _ntileName = [6]int8{'n', 't', 'i', 'l', 'e'} + +/* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */ +var _nullRow = [6]int8{ + 0: int8(6), +} + +/* Set properties of a table column based on the (magical) +** name of the column. + */ + +var _percent_rankName = [13]int8{'p', 'e', 'r', 'c', 'e', 'n', 't', '_', 'r', 'a', 'n', 'k'} + +var _rankName = [5]int8{'r', 'a', 'n', 'k'} + +// C documentation +// +// /* +// ** Return a nul-terminated string consisting of nByte comma separated +// ** "?" expressions. For example, if nByte is 3, return a pointer to +// ** a buffer containing the string "?,?,?". +// ** +// ** The memory for the returned string is obtained from sqlite3_malloc(). +// ** It is the responsibility of the caller to eventually free it using +// ** sqlite3_free(). +// ** +// ** If an OOM error is encountered when allocating space for the new +// ** string, an error code is left in the rbu handle passed as the first +// ** argument and NULL is returned. Or, if an error has already occurred +// ** when this function is called, NULL is returned immediately, without +// ** attempting the allocation or modifying the stored error code. +// */ +func _rbuObjIterGetBindlist(tls *libc.TLS, p uintptr, nBind int32) (r uintptr) { + var i, v2 int32 + var nByte Tsqlite3_int64 + var zRet uintptr + _, _, _, _ = i, nByte, zRet, v2 + zRet = uintptr(0) + nByte = int64(2)*int64(nBind) + int64(1) + zRet = _rbuMalloc(tls, p, nByte) + if zRet != 0 { + i = 0 + for { + if !(i < nBind) { + break + } + **(**int8)(__ccgo_up(zRet + uintptr(i*int32(2)))) = int8('?') + if i+int32(1) == nBind { + v2 = int32('\000') + } else { + v2 = int32(',') + } + **(**int8)(__ccgo_up(zRet + uintptr(i*int32(2)+int32(1)))) = int8(v2) + goto _1 + _1: + ; + i = i + 1 + } + } + return zRet +} + +// C documentation +// +// /* +// ** Static names for the built-in window function names. These static +// ** names are used, rather than string literals, so that FuncDef objects +// ** can be associated with a particular window function by direct +// ** comparison of the zName pointer. Example: +// ** +// ** if( pFuncDef->zName==row_valueName ){ ... } +// */ +var _row_numberName = [11]int8{'r', 'o', 'w', '_', 'n', 'u', 'm', 'b', 'e', 'r'} + +// C documentation +// +// /* +// ** Set the time to the current time reported by the VFS. +// ** +// ** Return the number of errors. +// */ +func _setDateTimeToCurrent(tls *libc.TLS, context uintptr, p uintptr) (r int32) { + (*TDateTime)(unsafe.Pointer(p)).FiJD = _sqlite3StmtCurrentTime(tls, context) + if (*TDateTime)(unsafe.Pointer(p)).FiJD > 0 { + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = int8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + _clearYMD_HMS_TZ(tls, p) + return 0 + } else { + return int32(1) + } + return r +} + +// C documentation +// +// /* +// ** Input "r" is a numeric quantity which might be a julian day number, +// ** or the number of seconds since 1970. If the value if r is within +// ** range of a julian day number, install it as such and set validJD. +// ** If the value is a valid unix timestamp, put it in p->s and set p->rawS. +// */ +func _setRawDateNumber(tls *libc.TLS, p uintptr, r float64) { + (*TDateTime)(unsafe.Pointer(p)).Fs = r + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 0, 0x1) + if r >= float64(0) && r < float64(5.3734845e+06) { + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(float64(r*libc.Float64FromFloat64(8.64e+07)) + libc.Float64FromFloat64(0.5)) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = int8(1) + } +} + +// C documentation +// +// /* +// ** pExpr is an operand of a comparison operator. aff2 is the +// ** type affinity of the other operand. This routine returns the +// ** type affinity that should be used for the comparison operator. +// */ +func _sqlite3CompareAffinity(tls *libc.TLS, pExpr uintptr, aff2 int8) (r int8) { + var aff1 int8 + var v1 int32 + _, _ = aff1, v1 + aff1 = _sqlite3ExprAffinity(tls, pExpr) + if int32(aff1) > int32(SQLITE_AFF_NONE) && int32(aff2) > int32(SQLITE_AFF_NONE) { + /* Both sides of the comparison are columns. If one has numeric + ** affinity, use that. Otherwise use no affinity. + */ + if int32(aff1) >= int32(SQLITE_AFF_NUMERIC) || int32(aff2) >= int32(SQLITE_AFF_NUMERIC) { + return int8(SQLITE_AFF_NUMERIC) + } else { + return int8(SQLITE_AFF_BLOB) + } + } else { + /* One side is a column, the other is not. Use the columns affinity. */ + if int32(aff1) <= int32(SQLITE_AFF_NONE) { + v1 = int32(aff2) + } else { + v1 = int32(aff1) + } + return int8(v1 | int32(SQLITE_AFF_NONE)) + } + return r +} + +// C documentation +// +// /* +// ** Digit pairs used to convert a U64 or I64 into text, two digits +// ** at a time. +// */ +var _sqlite3DigitPairs = *(*struct { + FforceAlignment [0]int16 + Fa [201]int8 + F__ccgo_pad2 [1]byte +})(unsafe.Pointer(&struct { + f [201]int8 + _ [1]byte +}{f: [201]int8{'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'}})) + +/* +** ARMv6, ARMv7, PPC32 are known to not support hardware u64 division. + */ + +// C documentation +// +// /* +// ** The argument must be a TK_TRUEFALSE Expr node. Return 1 if it is TRUE +// ** and 0 if it is FALSE. +// */ +func _sqlite3ExprTruthValue(tls *libc.TLS, pExpr uintptr) (r int32) { + pExpr = _sqlite3ExprSkipCollateAndLikely(tls, pExpr) + return libc.BoolInt32(int32(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pExpr + 8)) + 4))) == 0) +} + +// C documentation +// +// /* +// ** Value pVal is guaranteed to be an fts5_locale() value, according to +// ** sqlite3Fts5IsLocaleValue(). This function extracts the text and locale +// ** from the value and returns them separately. +// ** +// ** If successful, SQLITE_OK is returned and (*ppText) and (*ppLoc) set +// ** to point to buffers containing the text and locale, as utf-8, +// ** respectively. In this case output parameters (*pnText) and (*pnLoc) are +// ** set to the sizes in bytes of these two buffers. +// ** +// ** Or, if an error occurs, then an SQLite error code is returned. The final +// ** value of the four output parameters is undefined in this case. +// */ +func _sqlite3Fts5DecodeLocaleValue(tls *libc.TLS, pVal uintptr, ppText uintptr, pnText uintptr, ppLoc uintptr, pnLoc uintptr) (r int32) { + var n, nLoc int32 + var p uintptr + _, _, _ = n, nLoc, p + p = Xsqlite3_value_blob(tls, pVal) + n = Xsqlite3_value_bytes(tls, pVal) + nLoc = 0 + nLoc = libc.Int32FromInt64(16) + for { + if !(**(**int8)(__ccgo_up(p + uintptr(nLoc))) != 0) { + break + } + if nLoc == n-int32(1) { + return int32(SQLITE_MISMATCH) + } + goto _1 + _1: + ; + nLoc = nLoc + 1 + } + **(**uintptr)(__ccgo_up(ppLoc)) = p + uintptr(libc.Int32FromInt64(16)) + **(**int32)(__ccgo_up(pnLoc)) = nLoc - libc.Int32FromInt64(16) + **(**uintptr)(__ccgo_up(ppText)) = p + uintptr(nLoc+int32(1)) + **(**int32)(__ccgo_up(pnText)) = n - nLoc - int32(1) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Convert an SQL-style quoted string into a normal string by removing +// ** the quote characters. The conversion is done in-place. If the +// ** input does not begin with a quote character, then this routine +// ** is a no-op. +// ** +// ** Examples: +// ** +// ** "abc" becomes abc +// ** 'xyz' becomes xyz +// ** [pqr] becomes pqr +// ** `mno` becomes mno +// */ +func _sqlite3Fts5Dequote(tls *libc.TLS, z uintptr) { + var quote int8 + _ = quote /* Quote character (if any ) */ + quote = **(**int8)(__ccgo_up(z)) + if int32(quote) == int32('[') || int32(quote) == int32('\'') || int32(quote) == int32('"') || int32(quote) == int32('`') { + _fts5Dequote(tls, z) + } +} + +// C documentation +// +// /* +// ** Insert or remove data to or from the index. Each time a document is +// ** added to or removed from the index, this function is called one or more +// ** times. +// ** +// ** For an insert, it must be called once for each token in the new document. +// ** If the operation is a delete, it must be called (at least) once for each +// ** unique token in the document with an iCol value less than zero. The iPos +// ** argument is ignored for a delete. +// */ +func _sqlite3Fts5IndexWrite(tls *libc.TLS, p uintptr, iCol int32, iPos int32, pToken uintptr, nToken int32) (r int32) { + var i, nByte, nChar, rc int32 + var pConfig uintptr + _, _, _, _, _ = i, nByte, nChar, pConfig, rc /* Used to iterate through indexes */ + rc = SQLITE_OK /* Return code */ + pConfig = (*TFts5Index)(unsafe.Pointer(p)).FpConfig + /* Add the entry to the main terms index. */ + rc = _sqlite3Fts5HashWrite(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash, (*TFts5Index)(unsafe.Pointer(p)).FiWriteRowid, iCol, iPos, int8('0'), pToken, nToken) + i = 0 + for { + if !(i < (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix && rc == SQLITE_OK) { + break + } + nChar = **(**int32)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr(i)*4)) + nByte = _sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar) + if nByte != 0 { + rc = _sqlite3Fts5HashWrite(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash, (*TFts5Index)(unsafe.Pointer(p)).FiWriteRowid, iCol, iPos, int8(libc.Int32FromUint8('0')+i+libc.Int32FromInt32(1)), pToken, nByte) + } + goto _1 + _1: + ; + i = i + 1 + } + return rc +} + +// C documentation +// +// /* +// ** Return true if character 't' may be part of an FTS5 bareword, or false +// ** otherwise. Characters that may be part of barewords: +// ** +// ** * All non-ASCII characters, +// ** * The 52 upper and lower case ASCII characters, and +// ** * The 10 integer ASCII characters. +// ** * The underscore character "_" (0x5F). +// ** * The unicode "substitute" character (0x1A). +// */ +func _sqlite3Fts5IsBareword(tls *libc.TLS, t int8) (r int32) { + var aBareword [128]Tu8 + _ = aBareword + aBareword = [128]Tu8{ + 26: uint8(1), + 48: uint8(1), + 49: uint8(1), + 50: uint8(1), + 51: uint8(1), + 52: uint8(1), + 53: uint8(1), + 54: uint8(1), + 55: uint8(1), + 56: uint8(1), + 57: uint8(1), + 65: uint8(1), + 66: uint8(1), + 67: uint8(1), + 68: uint8(1), + 69: uint8(1), + 70: uint8(1), + 71: uint8(1), + 72: uint8(1), + 73: uint8(1), + 74: uint8(1), + 75: uint8(1), + 76: uint8(1), + 77: uint8(1), + 78: uint8(1), + 79: uint8(1), + 80: uint8(1), + 81: uint8(1), + 82: uint8(1), + 83: uint8(1), + 84: uint8(1), + 85: uint8(1), + 86: uint8(1), + 87: uint8(1), + 88: uint8(1), + 89: uint8(1), + 90: uint8(1), + 95: uint8(1), + 97: uint8(1), + 98: uint8(1), + 99: uint8(1), + 100: uint8(1), + 101: uint8(1), + 102: uint8(1), + 103: uint8(1), + 104: uint8(1), + 105: uint8(1), + 106: uint8(1), + 107: uint8(1), + 108: uint8(1), + 109: uint8(1), + 110: uint8(1), + 111: uint8(1), + 112: uint8(1), + 113: uint8(1), + 114: uint8(1), + 115: uint8(1), + 116: uint8(1), + 117: uint8(1), + 118: uint8(1), + 119: uint8(1), + 120: uint8(1), + 121: uint8(1), + 122: uint8(1), + } + return libc.BoolInt32(int32(t)&int32(0x80) != 0 || aBareword[int32(t)] != 0) +} + +func _sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) (r int32) { + **(**Tu8)(__ccgo_up(aArray)) = uint8(1) + switch int32(**(**int8)(__ccgo_up(zCat))) { + case int32('C'): + switch int32(**(**int8)(__ccgo_up(zCat + 1))) { + case int32('c'): + **(**Tu8)(__ccgo_up(aArray + 1)) = uint8(1) + case int32('f'): + **(**Tu8)(__ccgo_up(aArray + 2)) = uint8(1) + case int32('n'): + **(**Tu8)(__ccgo_up(aArray + 3)) = uint8(1) + case int32('s'): + **(**Tu8)(__ccgo_up(aArray + 4)) = uint8(1) + case int32('o'): + **(**Tu8)(__ccgo_up(aArray + 31)) = uint8(1) + case int32('*'): + **(**Tu8)(__ccgo_up(aArray + 1)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 2)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 3)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 4)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 31)) = uint8(1) + default: + return int32(1) + } + case int32('L'): + switch int32(**(**int8)(__ccgo_up(zCat + 1))) { + case int32('l'): + **(**Tu8)(__ccgo_up(aArray + 5)) = uint8(1) + case int32('m'): + **(**Tu8)(__ccgo_up(aArray + 6)) = uint8(1) + case int32('o'): + **(**Tu8)(__ccgo_up(aArray + 7)) = uint8(1) + case int32('t'): + **(**Tu8)(__ccgo_up(aArray + 8)) = uint8(1) + case int32('u'): + **(**Tu8)(__ccgo_up(aArray + 9)) = uint8(1) + case int32('C'): + **(**Tu8)(__ccgo_up(aArray + 30)) = uint8(1) + case int32('*'): + **(**Tu8)(__ccgo_up(aArray + 5)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 6)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 7)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 8)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 9)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 30)) = uint8(1) + default: + return int32(1) + } + case int32('M'): + switch int32(**(**int8)(__ccgo_up(zCat + 1))) { + case int32('c'): + **(**Tu8)(__ccgo_up(aArray + 10)) = uint8(1) + case int32('e'): + **(**Tu8)(__ccgo_up(aArray + 11)) = uint8(1) + case int32('n'): + **(**Tu8)(__ccgo_up(aArray + 12)) = uint8(1) + case int32('*'): + **(**Tu8)(__ccgo_up(aArray + 10)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 11)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 12)) = uint8(1) + default: + return int32(1) + } + case int32('N'): + switch int32(**(**int8)(__ccgo_up(zCat + 1))) { + case int32('d'): + **(**Tu8)(__ccgo_up(aArray + 13)) = uint8(1) + case int32('l'): + **(**Tu8)(__ccgo_up(aArray + 14)) = uint8(1) + case int32('o'): + **(**Tu8)(__ccgo_up(aArray + 15)) = uint8(1) + case int32('*'): + **(**Tu8)(__ccgo_up(aArray + 13)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 14)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 15)) = uint8(1) + default: + return int32(1) + } + case int32('P'): + switch int32(**(**int8)(__ccgo_up(zCat + 1))) { + case int32('c'): + **(**Tu8)(__ccgo_up(aArray + 16)) = uint8(1) + case int32('d'): + **(**Tu8)(__ccgo_up(aArray + 17)) = uint8(1) + case int32('e'): + **(**Tu8)(__ccgo_up(aArray + 18)) = uint8(1) + case int32('f'): + **(**Tu8)(__ccgo_up(aArray + 19)) = uint8(1) + case int32('i'): + **(**Tu8)(__ccgo_up(aArray + 20)) = uint8(1) + case int32('o'): + **(**Tu8)(__ccgo_up(aArray + 21)) = uint8(1) + case int32('s'): + **(**Tu8)(__ccgo_up(aArray + 22)) = uint8(1) + case int32('*'): + **(**Tu8)(__ccgo_up(aArray + 16)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 17)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 18)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 19)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 20)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 21)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 22)) = uint8(1) + default: + return int32(1) + } + case int32('S'): + switch int32(**(**int8)(__ccgo_up(zCat + 1))) { + case int32('c'): + **(**Tu8)(__ccgo_up(aArray + 23)) = uint8(1) + case int32('k'): + **(**Tu8)(__ccgo_up(aArray + 24)) = uint8(1) + case int32('m'): + **(**Tu8)(__ccgo_up(aArray + 25)) = uint8(1) + case int32('o'): + **(**Tu8)(__ccgo_up(aArray + 26)) = uint8(1) + case int32('*'): + **(**Tu8)(__ccgo_up(aArray + 23)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 24)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 25)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 26)) = uint8(1) + default: + return int32(1) + } + case int32('Z'): + switch int32(**(**int8)(__ccgo_up(zCat + 1))) { + case int32('l'): + **(**Tu8)(__ccgo_up(aArray + 27)) = uint8(1) + case int32('p'): + **(**Tu8)(__ccgo_up(aArray + 28)) = uint8(1) + case int32('s'): + **(**Tu8)(__ccgo_up(aArray + 29)) = uint8(1) + case int32('*'): + **(**Tu8)(__ccgo_up(aArray + 27)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 28)) = uint8(1) + **(**Tu8)(__ccgo_up(aArray + 29)) = uint8(1) + default: + return int32(1) + } + default: + return int32(1) + } + return 0 +} + +// C documentation +// +// /* +// ** pExpr is a comparison expression, eg. '=', '<', IN(...) etc. +// ** idx_affinity is the affinity of an indexed column. Return true +// ** if the index with affinity idx_affinity may be used to implement +// ** the comparison in pExpr. +// */ +func _sqlite3IndexAffinityOk(tls *libc.TLS, pExpr uintptr, idx_affinity int8) (r int32) { + var aff int8 + _ = aff + aff = _comparisonAffinity(tls, pExpr) + if int32(aff) < int32(SQLITE_AFF_TEXT) { + return int32(1) + } + if int32(aff) == int32(SQLITE_AFF_TEXT) { + return libc.BoolInt32(int32(idx_affinity) == int32(SQLITE_AFF_TEXT)) + } + return libc.BoolInt32(int32(idx_affinity) >= int32(SQLITE_AFF_NUMERIC)) +} + +// C documentation +// +// /* +// ** Return the affinity for a single column of an index. +// */ +func _sqlite3IndexColumnAffinity(tls *libc.TLS, db uintptr, pIdx uintptr, iCol int32) (r int8) { + if !((*TIndex)(unsafe.Pointer(pIdx)).FzColAff != 0) { + if _sqlite3IndexAffinityStr(tls, db, pIdx) == uintptr(0) { + return int8(SQLITE_AFF_BLOB) + } + } + return **(**int8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FzColAff + uintptr(iCol))) +} + +func _sqlite3OsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nPathOut int32, zPathOut uintptr) (r int32) { + **(**int8)(__ccgo_up(zPathOut)) = 0 + return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxFullPathname})))(tls, pVfs, zPath, nPathOut, zPathOut) +} + +var _sqlite3StdTypeAffinity = [6]int8{ + 0: int8(SQLITE_AFF_NUMERIC), + 1: int8(SQLITE_AFF_BLOB), + 2: int8(SQLITE_AFF_INTEGER), + 3: int8(SQLITE_AFF_INTEGER), + 4: int8(SQLITE_AFF_REAL), + 5: int8(SQLITE_AFF_TEXT), +} + +// C documentation +// +// /* +// ** Name of the default collating sequence +// */ +var _sqlite3StrBINARY = [7]int8{'B', 'I', 'N', 'A', 'R', 'Y'} + +// C documentation +// +// /* +// ** Generate code that initializes multiple registers to string or integer +// ** constants. The registers begin with iDest and increase consecutively. +// ** One register is initialized for each characgter in zTypes[]. For each +// ** "s" character in zTypes[], the register is a string if the argument is +// ** not NULL, or OP_Null if the value is a null pointer. For each "i" character +// ** in zTypes[], the register is initialized to an integer. +// ** +// ** If the input string does not end with "X" then an OP_ResultRow instruction +// ** is generated for the values inserted. +// */ +func _sqlite3VdbeMultiLoad(tls *libc.TLS, p uintptr, iDest int32, zTypes uintptr, va uintptr) { + var ap Tva_list + var c, v2 int8 + var i, v3 int32 + var z uintptr + _, _, _, _, _, _ = ap, c, i, z, v2, v3 + ap = va + i = 0 + for { + v2 = **(**int8)(__ccgo_up(zTypes + uintptr(i))) + c = v2 + if !(int32(v2) != 0) { + break + } + if int32(c) == int32('s') { + z = libc.VaUintptr(&ap) + if z == uintptr(0) { + v3 = int32(OP_Null) + } else { + v3 = int32(OP_String8) + } + _sqlite3VdbeAddOp4(tls, p, v3, 0, iDest+i, 0, z, 0) + } else { + if int32(c) == int32('i') { + _sqlite3VdbeAddOp2(tls, p, int32(OP_Integer), libc.VaInt32(&ap), iDest+i) + } else { + goto skip_op_resultrow + } + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3VdbeAddOp2(tls, p, int32(OP_ResultRow), iDest, i) + goto skip_op_resultrow +skip_op_resultrow: + ; + _ = ap +} + +// C documentation +// +// /* +// ** Elements of sqlite3Stat[] are protected by either the memory allocator +// ** mutex, or by the pcache1 mutex. The following array determines which. +// */ +var _statMutex = [10]int8{ + 1: int8(1), + 2: int8(1), + 7: int8(1), +} + +/* The "wsdStat" macro will resolve to the status information +** state vector. If writable static data is unsupported on the target, +** we have to locate the state vector at run-time. In the more common +** case where writable static data is supported, wsdStat can refer directly +** to the "sqlite3Stat" state vector declared above. + */ + +// C documentation +// +// /* +// ** time( TIMESTRING, MOD, MOD, ...) +// ** +// ** Return HH:MM:SS +// */ +func _timeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var n, s int32 + var _ /* x at bp+0 */ TDateTime + var _ /* zBuf at bp+48 */ [16]int8 + _, _ = n, s + if _isDate(tls, context, argc, argv, bp) == 0 { + _computeHMS(tls, bp) + (**(**[16]int8)(__ccgo_up(bp + 48)))[0] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fh/int32(10)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(1)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fh%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(2)] = int8(':') + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(3)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fm/int32(10)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(4)] = int8(int32('0') + (**(**TDateTime)(__ccgo_up(bp))).Fm%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(5)] = int8(':') + if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { + s = int32(float64(libc.Float64FromFloat64(1000)*(**(**TDateTime)(__ccgo_up(bp))).Fs) + libc.Float64FromFloat64(0.5)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(6)] = int8(int32('0') + s/int32(10000)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(7)] = int8(int32('0') + s/int32(1000)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(8)] = int8('.') + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(9)] = int8(int32('0') + s/int32(100)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(10)] = int8(int32('0') + s/int32(10)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(11)] = int8(int32('0') + s%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(12)] = 0 + n = int32(12) + } else { + s = int32((**(**TDateTime)(__ccgo_up(bp))).Fs) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(6)] = int8(int32('0') + s/int32(10)%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(7)] = int8(int32('0') + s%int32(10)) + (**(**[16]int8)(__ccgo_up(bp + 48)))[int32(8)] = 0 + n = int32(8) + } + Xsqlite3_result_text(tls, context, bp+48, n, uintptr(-libc.Int32FromInt32(1))) + } +} + +// C documentation +// +// /* +// ** Expression pRight, which is the RHS of a comparison operation, is +// ** either a vector of n elements or, if n==1, a scalar expression. +// ** Before the comparison operation, affinity zAff is to be applied +// ** to the pRight values. This function modifies characters within the +// ** affinity string to SQLITE_AFF_BLOB if either: +// ** +// ** * the comparison will be performed with no affinity, or +// ** * the affinity change in zAff is guaranteed not to change the value. +// */ +func _updateRangeAffinityStr(tls *libc.TLS, pRight uintptr, n int32, zAff uintptr) { + var i int32 + var p uintptr + _, _ = i, p + i = 0 + for { + if !(i < n) { + break + } + p = _sqlite3VectorFieldSubexpr(tls, pRight, i) + if int32(_sqlite3CompareAffinity(tls, p, **(**int8)(__ccgo_up(zAff + uintptr(i))))) == int32(SQLITE_AFF_BLOB) || _sqlite3ExprNeedsNoAffinityChange(tls, p, **(**int8)(__ccgo_up(zAff + uintptr(i)))) != 0 { + **(**int8)(__ccgo_up(zAff + uintptr(i))) = int8(SQLITE_AFF_BLOB) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** This routine does the core work of extracting URI parameters from a +// ** database filename for the sqlite3_uri_parameter() interface. +// */ +func _uriParameter(tls *libc.TLS, zFilename uintptr, zParam uintptr) (r uintptr) { + var x int32 + _ = x + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + for zFilename != uintptr(0) && **(**int8)(__ccgo_up(zFilename)) != 0 { + x = libc.Xstrcmp(tls, zFilename, zParam) + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + if x == 0 { + return zFilename + } + zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1)) + } + return uintptr(0) +} + +// C documentation +// +// /* +// ** Write a 32-bit integer into the given file descriptor. Return SQLITE_OK +// ** on success or an error code is something goes wrong. +// */ +func _write32bits(tls *libc.TLS, fd uintptr, offset Ti64, val Tu32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ac at bp+0 */ [4]int8 + _sqlite3Put4byte(tls, bp, val) + return _sqlite3OsWrite(tls, fd, bp, int32(4), offset) +} + +var _zAff = [10]int8{'B', 0, 'C', 0, 'D', 0, 'E', 0, 'F'} + +// C documentation +// +// /* +// ** Page paths: +// ** +// ** The value of the 'path' column describes the path taken from the +// ** root-node of the b-tree structure to each page. The value of the +// ** root-node path is '/'. +// ** +// ** The value of the path for the left-most child page of the root of +// ** a b-tree is '/000/'. (Btrees store content ordered from left to right +// ** so the pages to the left have smaller keys than the pages to the right.) +// ** The next to left-most child of the root page is +// ** '/001', and so on, each sibling page identified by a 3-digit hex +// ** value. The children of the 451st left-most sibling have paths such +// ** as '/1c2/000/, '/1c2/001/' etc. +// ** +// ** Overflow pages are specified by appending a '+' character and a +// ** six-digit hexadecimal value to the path to the cell they are linked +// ** from. For example, the three overflow pages in a chain linked from +// ** the left-most cell of the 450th child of the root page are identified +// ** by the paths: +// ** +// ** '/1c2/000+000000' // First page in overflow chain +// ** '/1c2/000+000001' // Second page in overflow chain +// ** '/1c2/000+000002' // Third page in overflow chain +// ** +// ** If the paths are sorted using the BINARY collation sequence, then +// ** the overflow pages associated with a cell will appear earlier in the +// ** sort-order than its child page: +// ** +// ** '/1c2/000/' // Left-most child of 451st child of root +// */ +var _zDbstatSchema = [258]int8{'C', 'R', 'E', 'A', 'T', 'E', ' ', 'T', 'A', 'B', 'L', 'E', ' ', 'x', '(', ' ', 'n', 'a', 'm', 'e', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'E', 'X', 'T', ',', ' ', 'p', 'a', 't', 'h', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'E', 'X', 'T', ',', ' ', 'p', 'a', 'g', 'e', 'n', 'o', ' ', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'p', 'a', 'g', 'e', 't', 'y', 'p', 'e', ' ', ' ', ' ', 'T', 'E', 'X', 'T', ',', ' ', 'n', 'c', 'e', 'l', 'l', ' ', ' ', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'p', 'a', 'y', 'l', 'o', 'a', 'd', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'u', 'n', 'u', 's', 'e', 'd', ' ', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'm', 'x', '_', 'p', 'a', 'y', 'l', 'o', 'a', 'd', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'p', 'g', 'o', 'f', 'f', 's', 'e', 't', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 'p', 'g', 's', 'i', 'z', 'e', ' ', ' ', ' ', ' ', ' ', 'I', 'N', 'T', 'E', 'G', 'E', 'R', ',', ' ', 's', 'c', 'h', 'e', 'm', 'a', ' ', ' ', ' ', ' ', ' ', 'T', 'E', 'X', 'T', ' ', 'H', 'I', 'D', 'D', 'E', 'N', ',', ' ', 'a', 'g', 'g', 'r', 'e', 'g', 'a', 't', 'e', ' ', ' ', 'B', 'O', 'O', 'L', 'E', 'A', 'N', ' ', 'H', 'I', 'D', 'D', 'E', 'N', ')'} + +var _zFake = [8]int8{} + +// C documentation +// +// /* +// ** The sqlite3KeywordCode function looks up an identifier to determine if +// ** it is a keyword. If it is a keyword, the token code of that keyword is +// ** returned. If the input is not a keyword, TK_ID is returned. +// ** +// ** The implementation of this routine was generated by a program, +// ** mkkeywordhash.c, located in the tool subdirectory of the distribution. +// ** The output of the mkkeywordhash.c program is written into a file +// ** named keywordhash.h and then included into this source file by +// ** the #include below. +// */ +// /************** Include keywordhash.h in the middle of tokenize.c ************/ +// /************** Begin file keywordhash.h *************************************/ +// /***** This file contains automatically generated code ****** +// ** +// ** The code in this file has been automatically generated by +// ** +// ** sqlite/tool/mkkeywordhash.c +// ** +// ** The code in this file implements a function that determines whether +// ** or not a given identifier is really an SQL keyword. The same thing +// ** might be implemented more directly using a hand-written hash table. +// ** But by using this automatically generated code, the size of the code +// ** is substantially reduced. This is important for embedded applications +// ** on platforms with limited memory. +// */ +// /* Hash score: 231 */ +// /* zKWText[] encodes 1007 bytes of keyword text in 667 bytes */ +// /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ +// /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */ +// /* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */ +// /* CONSTRAINTOFFSETRIGGERANGENERATEDETACHAVINGLOBEGINNEREFERENCES */ +// /* UNIQUERYWITHOUTERELEASEATTACHBETWEENOTHINGROUPSCASCADEFAULT */ +// /* CASECOLLATECREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZE */ +// /* PRAGMATERIALIZEDEFERREDISTINCTUPDATEVALUESVIRTUALWAYSWHENWHERE */ +// /* CURSIVEABORTAFTERENAMEANDROPARTITIONAUTOINCREMENTCASTCOLUMN */ +// /* COMMITCONFLICTCROSSCURRENT_TIMESTAMPRECEDINGFAILASTFILTER */ +// /* EPLACEFIRSTFOLLOWINGFROMFULLIMITIFORDERESTRICTOTHERSOVER */ +// /* ETURNINGRIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBY */ +// /* INITIALLYPRIMARY */ +var _zKWText = [666]int8{ + 0: int8('R'), + 1: int8('E'), + 2: int8('I'), + 3: int8('N'), + 4: int8('D'), + 5: int8('E'), + 6: int8('X'), + 7: int8('E'), + 8: int8('D'), + 9: int8('E'), + 10: int8('S'), + 11: int8('C'), + 12: int8('A'), + 13: int8('P'), + 14: int8('E'), + 15: int8('A'), + 16: int8('C'), + 17: int8('H'), + 18: int8('E'), + 19: int8('C'), + 20: int8('K'), + 21: int8('E'), + 22: int8('Y'), + 23: int8('B'), + 24: int8('E'), + 25: int8('F'), + 26: int8('O'), + 27: int8('R'), + 28: int8('E'), + 29: int8('I'), + 30: int8('G'), + 31: int8('N'), + 32: int8('O'), + 33: int8('R'), + 34: int8('E'), + 35: int8('G'), + 36: int8('E'), + 37: int8('X'), + 38: int8('P'), + 39: int8('L'), + 40: int8('A'), + 41: int8('I'), + 42: int8('N'), + 43: int8('S'), + 44: int8('T'), + 45: int8('E'), + 46: int8('A'), + 47: int8('D'), + 48: int8('D'), + 49: int8('A'), + 50: int8('T'), + 51: int8('A'), + 52: int8('B'), + 53: int8('A'), + 54: int8('S'), + 55: int8('E'), + 56: int8('L'), + 57: int8('E'), + 58: int8('C'), + 59: int8('T'), + 60: int8('A'), + 61: int8('B'), + 62: int8('L'), + 63: int8('E'), + 64: int8('F'), + 65: int8('T'), + 66: int8('H'), + 67: int8('E'), + 68: int8('N'), + 69: int8('D'), + 70: int8('E'), + 71: int8('F'), + 72: int8('E'), + 73: int8('R'), + 74: int8('R'), + 75: int8('A'), + 76: int8('B'), + 77: int8('L'), + 78: int8('E'), + 79: int8('L'), + 80: int8('S'), + 81: int8('E'), + 82: int8('X'), + 83: int8('C'), + 84: int8('L'), + 85: int8('U'), + 86: int8('D'), + 87: int8('E'), + 88: int8('L'), + 89: int8('E'), + 90: int8('T'), + 91: int8('E'), + 92: int8('M'), + 93: int8('P'), + 94: int8('O'), + 95: int8('R'), + 96: int8('A'), + 97: int8('R'), + 98: int8('Y'), + 99: int8('I'), + 100: int8('S'), + 101: int8('N'), + 102: int8('U'), + 103: int8('L'), + 104: int8('L'), + 105: int8('S'), + 106: int8('A'), + 107: int8('V'), + 108: int8('E'), + 109: int8('P'), + 110: int8('O'), + 111: int8('I'), + 112: int8('N'), + 113: int8('T'), + 114: int8('E'), + 115: int8('R'), + 116: int8('S'), + 117: int8('E'), + 118: int8('C'), + 119: int8('T'), + 120: int8('I'), + 121: int8('E'), + 122: int8('S'), + 123: int8('N'), + 124: int8('O'), + 125: int8('T'), + 126: int8('N'), + 127: int8('U'), + 128: int8('L'), + 129: int8('L'), + 130: int8('I'), + 131: int8('K'), + 132: int8('E'), + 133: int8('X'), + 134: int8('C'), + 135: int8('E'), + 136: int8('P'), + 137: int8('T'), + 138: int8('R'), + 139: int8('A'), + 140: int8('N'), + 141: int8('S'), + 142: int8('A'), + 143: int8('C'), + 144: int8('T'), + 145: int8('I'), + 146: int8('O'), + 147: int8('N'), + 148: int8('A'), + 149: int8('T'), + 150: int8('U'), + 151: int8('R'), + 152: int8('A'), + 153: int8('L'), + 154: int8('T'), + 155: int8('E'), + 156: int8('R'), + 157: int8('A'), + 158: int8('I'), + 159: int8('S'), + 160: int8('E'), + 161: int8('X'), + 162: int8('C'), + 163: int8('L'), + 164: int8('U'), + 165: int8('S'), + 166: int8('I'), + 167: int8('V'), + 168: int8('E'), + 169: int8('X'), + 170: int8('I'), + 171: int8('S'), + 172: int8('T'), + 173: int8('S'), + 174: int8('C'), + 175: int8('O'), + 176: int8('N'), + 177: int8('S'), + 178: int8('T'), + 179: int8('R'), + 180: int8('A'), + 181: int8('I'), + 182: int8('N'), + 183: int8('T'), + 184: int8('O'), + 185: int8('F'), + 186: int8('F'), + 187: int8('S'), + 188: int8('E'), + 189: int8('T'), + 190: int8('R'), + 191: int8('I'), + 192: int8('G'), + 193: int8('G'), + 194: int8('E'), + 195: int8('R'), + 196: int8('A'), + 197: int8('N'), + 198: int8('G'), + 199: int8('E'), + 200: int8('N'), + 201: int8('E'), + 202: int8('R'), + 203: int8('A'), + 204: int8('T'), + 205: int8('E'), + 206: int8('D'), + 207: int8('E'), + 208: int8('T'), + 209: int8('A'), + 210: int8('C'), + 211: int8('H'), + 212: int8('A'), + 213: int8('V'), + 214: int8('I'), + 215: int8('N'), + 216: int8('G'), + 217: int8('L'), + 218: int8('O'), + 219: int8('B'), + 220: int8('E'), + 221: int8('G'), + 222: int8('I'), + 223: int8('N'), + 224: int8('N'), + 225: int8('E'), + 226: int8('R'), + 227: int8('E'), + 228: int8('F'), + 229: int8('E'), + 230: int8('R'), + 231: int8('E'), + 232: int8('N'), + 233: int8('C'), + 234: int8('E'), + 235: int8('S'), + 236: int8('U'), + 237: int8('N'), + 238: int8('I'), + 239: int8('Q'), + 240: int8('U'), + 241: int8('E'), + 242: int8('R'), + 243: int8('Y'), + 244: int8('W'), + 245: int8('I'), + 246: int8('T'), + 247: int8('H'), + 248: int8('O'), + 249: int8('U'), + 250: int8('T'), + 251: int8('E'), + 252: int8('R'), + 253: int8('E'), + 254: int8('L'), + 255: int8('E'), + 256: int8('A'), + 257: int8('S'), + 258: int8('E'), + 259: int8('A'), + 260: int8('T'), + 261: int8('T'), + 262: int8('A'), + 263: int8('C'), + 264: int8('H'), + 265: int8('B'), + 266: int8('E'), + 267: int8('T'), + 268: int8('W'), + 269: int8('E'), + 270: int8('E'), + 271: int8('N'), + 272: int8('O'), + 273: int8('T'), + 274: int8('H'), + 275: int8('I'), + 276: int8('N'), + 277: int8('G'), + 278: int8('R'), + 279: int8('O'), + 280: int8('U'), + 281: int8('P'), + 282: int8('S'), + 283: int8('C'), + 284: int8('A'), + 285: int8('S'), + 286: int8('C'), + 287: int8('A'), + 288: int8('D'), + 289: int8('E'), + 290: int8('F'), + 291: int8('A'), + 292: int8('U'), + 293: int8('L'), + 294: int8('T'), + 295: int8('C'), + 296: int8('A'), + 297: int8('S'), + 298: int8('E'), + 299: int8('C'), + 300: int8('O'), + 301: int8('L'), + 302: int8('L'), + 303: int8('A'), + 304: int8('T'), + 305: int8('E'), + 306: int8('C'), + 307: int8('R'), + 308: int8('E'), + 309: int8('A'), + 310: int8('T'), + 311: int8('E'), + 312: int8('C'), + 313: int8('U'), + 314: int8('R'), + 315: int8('R'), + 316: int8('E'), + 317: int8('N'), + 318: int8('T'), + 319: int8('_'), + 320: int8('D'), + 321: int8('A'), + 322: int8('T'), + 323: int8('E'), + 324: int8('I'), + 325: int8('M'), + 326: int8('M'), + 327: int8('E'), + 328: int8('D'), + 329: int8('I'), + 330: int8('A'), + 331: int8('T'), + 332: int8('E'), + 333: int8('J'), + 334: int8('O'), + 335: int8('I'), + 336: int8('N'), + 337: int8('S'), + 338: int8('E'), + 339: int8('R'), + 340: int8('T'), + 341: int8('M'), + 342: int8('A'), + 343: int8('T'), + 344: int8('C'), + 345: int8('H'), + 346: int8('P'), + 347: int8('L'), + 348: int8('A'), + 349: int8('N'), + 350: int8('A'), + 351: int8('L'), + 352: int8('Y'), + 353: int8('Z'), + 354: int8('E'), + 355: int8('P'), + 356: int8('R'), + 357: int8('A'), + 358: int8('G'), + 359: int8('M'), + 360: int8('A'), + 361: int8('T'), + 362: int8('E'), + 363: int8('R'), + 364: int8('I'), + 365: int8('A'), + 366: int8('L'), + 367: int8('I'), + 368: int8('Z'), + 369: int8('E'), + 370: int8('D'), + 371: int8('E'), + 372: int8('F'), + 373: int8('E'), + 374: int8('R'), + 375: int8('R'), + 376: int8('E'), + 377: int8('D'), + 378: int8('I'), + 379: int8('S'), + 380: int8('T'), + 381: int8('I'), + 382: int8('N'), + 383: int8('C'), + 384: int8('T'), + 385: int8('U'), + 386: int8('P'), + 387: int8('D'), + 388: int8('A'), + 389: int8('T'), + 390: int8('E'), + 391: int8('V'), + 392: int8('A'), + 393: int8('L'), + 394: int8('U'), + 395: int8('E'), + 396: int8('S'), + 397: int8('V'), + 398: int8('I'), + 399: int8('R'), + 400: int8('T'), + 401: int8('U'), + 402: int8('A'), + 403: int8('L'), + 404: int8('W'), + 405: int8('A'), + 406: int8('Y'), + 407: int8('S'), + 408: int8('W'), + 409: int8('H'), + 410: int8('E'), + 411: int8('N'), + 412: int8('W'), + 413: int8('H'), + 414: int8('E'), + 415: int8('R'), + 416: int8('E'), + 417: int8('C'), + 418: int8('U'), + 419: int8('R'), + 420: int8('S'), + 421: int8('I'), + 422: int8('V'), + 423: int8('E'), + 424: int8('A'), + 425: int8('B'), + 426: int8('O'), + 427: int8('R'), + 428: int8('T'), + 429: int8('A'), + 430: int8('F'), + 431: int8('T'), + 432: int8('E'), + 433: int8('R'), + 434: int8('E'), + 435: int8('N'), + 436: int8('A'), + 437: int8('M'), + 438: int8('E'), + 439: int8('A'), + 440: int8('N'), + 441: int8('D'), + 442: int8('R'), + 443: int8('O'), + 444: int8('P'), + 445: int8('A'), + 446: int8('R'), + 447: int8('T'), + 448: int8('I'), + 449: int8('T'), + 450: int8('I'), + 451: int8('O'), + 452: int8('N'), + 453: int8('A'), + 454: int8('U'), + 455: int8('T'), + 456: int8('O'), + 457: int8('I'), + 458: int8('N'), + 459: int8('C'), + 460: int8('R'), + 461: int8('E'), + 462: int8('M'), + 463: int8('E'), + 464: int8('N'), + 465: int8('T'), + 466: int8('C'), + 467: int8('A'), + 468: int8('S'), + 469: int8('T'), + 470: int8('C'), + 471: int8('O'), + 472: int8('L'), + 473: int8('U'), + 474: int8('M'), + 475: int8('N'), + 476: int8('C'), + 477: int8('O'), + 478: int8('M'), + 479: int8('M'), + 480: int8('I'), + 481: int8('T'), + 482: int8('C'), + 483: int8('O'), + 484: int8('N'), + 485: int8('F'), + 486: int8('L'), + 487: int8('I'), + 488: int8('C'), + 489: int8('T'), + 490: int8('C'), + 491: int8('R'), + 492: int8('O'), + 493: int8('S'), + 494: int8('S'), + 495: int8('C'), + 496: int8('U'), + 497: int8('R'), + 498: int8('R'), + 499: int8('E'), + 500: int8('N'), + 501: int8('T'), + 502: int8('_'), + 503: int8('T'), + 504: int8('I'), + 505: int8('M'), + 506: int8('E'), + 507: int8('S'), + 508: int8('T'), + 509: int8('A'), + 510: int8('M'), + 511: int8('P'), + 512: int8('R'), + 513: int8('E'), + 514: int8('C'), + 515: int8('E'), + 516: int8('D'), + 517: int8('I'), + 518: int8('N'), + 519: int8('G'), + 520: int8('F'), + 521: int8('A'), + 522: int8('I'), + 523: int8('L'), + 524: int8('A'), + 525: int8('S'), + 526: int8('T'), + 527: int8('F'), + 528: int8('I'), + 529: int8('L'), + 530: int8('T'), + 531: int8('E'), + 532: int8('R'), + 533: int8('E'), + 534: int8('P'), + 535: int8('L'), + 536: int8('A'), + 537: int8('C'), + 538: int8('E'), + 539: int8('F'), + 540: int8('I'), + 541: int8('R'), + 542: int8('S'), + 543: int8('T'), + 544: int8('F'), + 545: int8('O'), + 546: int8('L'), + 547: int8('L'), + 548: int8('O'), + 549: int8('W'), + 550: int8('I'), + 551: int8('N'), + 552: int8('G'), + 553: int8('F'), + 554: int8('R'), + 555: int8('O'), + 556: int8('M'), + 557: int8('F'), + 558: int8('U'), + 559: int8('L'), + 560: int8('L'), + 561: int8('I'), + 562: int8('M'), + 563: int8('I'), + 564: int8('T'), + 565: int8('I'), + 566: int8('F'), + 567: int8('O'), + 568: int8('R'), + 569: int8('D'), + 570: int8('E'), + 571: int8('R'), + 572: int8('E'), + 573: int8('S'), + 574: int8('T'), + 575: int8('R'), + 576: int8('I'), + 577: int8('C'), + 578: int8('T'), + 579: int8('O'), + 580: int8('T'), + 581: int8('H'), + 582: int8('E'), + 583: int8('R'), + 584: int8('S'), + 585: int8('O'), + 586: int8('V'), + 587: int8('E'), + 588: int8('R'), + 589: int8('E'), + 590: int8('T'), + 591: int8('U'), + 592: int8('R'), + 593: int8('N'), + 594: int8('I'), + 595: int8('N'), + 596: int8('G'), + 597: int8('R'), + 598: int8('I'), + 599: int8('G'), + 600: int8('H'), + 601: int8('T'), + 602: int8('R'), + 603: int8('O'), + 604: int8('L'), + 605: int8('L'), + 606: int8('B'), + 607: int8('A'), + 608: int8('C'), + 609: int8('K'), + 610: int8('R'), + 611: int8('O'), + 612: int8('W'), + 613: int8('S'), + 614: int8('U'), + 615: int8('N'), + 616: int8('B'), + 617: int8('O'), + 618: int8('U'), + 619: int8('N'), + 620: int8('D'), + 621: int8('E'), + 622: int8('D'), + 623: int8('U'), + 624: int8('N'), + 625: int8('I'), + 626: int8('O'), + 627: int8('N'), + 628: int8('U'), + 629: int8('S'), + 630: int8('I'), + 631: int8('N'), + 632: int8('G'), + 633: int8('V'), + 634: int8('A'), + 635: int8('C'), + 636: int8('U'), + 637: int8('U'), + 638: int8('M'), + 639: int8('V'), + 640: int8('I'), + 641: int8('E'), + 642: int8('W'), + 643: int8('I'), + 644: int8('N'), + 645: int8('D'), + 646: int8('O'), + 647: int8('W'), + 648: int8('B'), + 649: int8('Y'), + 650: int8('I'), + 651: int8('N'), + 652: int8('I'), + 653: int8('T'), + 654: int8('I'), + 655: int8('A'), + 656: int8('L'), + 657: int8('L'), + 658: int8('Y'), + 659: int8('P'), + 660: int8('R'), + 661: int8('I'), + 662: int8('M'), + 663: int8('A'), + 664: int8('R'), + 665: int8('Y'), +} + +/* 0123456789 123456789 123456789 123 */ +var _zKeyText = [34]int8{'n', 'a', 't', 'u', 'r', 'a', 'l', 'e', 'f', 't', 'o', 'u', 't', 'e', 'r', 'i', 'g', 'h', 't', 'f', 'u', 'l', 'l', 'i', 'n', 'n', 'e', 'r', 'c', 'r', 'o', 's', 's'} + +// C documentation +// +// /* +// ** The header string that appears at the beginning of every +// ** SQLite database. +// */ +var _zMagicHeader = [16]int8{'S', 'Q', 'L', 'i', 't', 'e', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', '3'} + +/* +** Set this global variable to 1 to enable tracing using the TRACE +** macro. + */ + +/* +** Extract a 2-byte big-endian integer from an array of unsigned bytes. +** But if the value is zero, make it 65536. +** +** This routine is used to extract the "offset to cell content area" value +** from the header of a btree page. If the page size is 65536 and the page +** is empty, the offset should be 65536, but the 2-byte value stores zero. +** This routine makes the necessary adjustment to 65536. + */ + +/* +** Values passed as the 5th argument to allocateBtreePage() + */ + +/* +** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not +** defined, or 0 if it is. For example: +** +** bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum); + */ + +var _zOrd = [9]int8{'t', 'h', 's', 't', 'n', 'd', 'r', 'd'} + +/* End of function */ + +/* 123456789 123456789 123 */ +var _zText = [25]int8{'o', 'n', 'o', 'f', 'f', 'a', 'l', 's', 'e', 'y', 'e', 's', 't', 'r', 'u', 'e', 'x', 't', 'r', 'a', 'f', 'u', 'l', 'l'} + +var _zeroHdr = [28]int8{} diff --git a/internal/engine/lib/sqlite_g_000000000006c8cc.go b/internal/engine/lib/sqlite_g_000000000006c8cc.go new file mode 100644 index 0000000..aaadd12 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000006c8cc.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (linux && 386) || (linux && amd64) || (linux && ppc64le) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __SIZEOF_FLOAT128__ = 16 diff --git a/internal/engine/lib/sqlite_g_000000000006e9df.go b/internal/engine/lib/sqlite_g_000000000006e9df.go new file mode 100644 index 0000000..ee5e3ab --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000006e9df.go @@ -0,0 +1,21 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && ppc64le) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __DECIMAL_DIG__ = 17 + +const __LDBL_DECIMAL_DIG__ = 17 + +const __LDBL_DIG__ = 15 + +const __LDBL_MANT_DIG__ = 53 + +const __LDBL_MAX_10_EXP__ = 308 + +const __LDBL_MAX_EXP__ = 1024 + +const __LDBL_MIN_10_EXP__ = -307 + +const __LDBL_MIN_EXP__ = -1021 diff --git a/internal/engine/lib/sqlite_g_0000000000078003.go b/internal/engine/lib/sqlite_g_0000000000078003.go new file mode 100644 index 0000000..d46b864 --- /dev/null +++ b/internal/engine/lib/sqlite_g_0000000000078003.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +type wint_t = Twint_t diff --git a/internal/engine/lib/sqlite_g_000000000007803f.go b/internal/engine/lib/sqlite_g_000000000007803f.go new file mode 100644 index 0000000..31f8b32 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007803f.go @@ -0,0 +1,15 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +type Tfpos_t = int64 + +const __INT_FAST16_MAX__ = 32767 + +const __INT_FAST16_WIDTH__ = 16 + +const __UINT_FAST16_MAX__ = 65535 + +type t__gnuc_va_list = uintptr diff --git a/internal/engine/lib/sqlite_g_00000000000781fd.go b/internal/engine/lib/sqlite_g_00000000000781fd.go new file mode 100644 index 0000000..95f0724 --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000781fd.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __GCC_DESTRUCTIVE_SIZE = 64 diff --git a/internal/engine/lib/sqlite_g_00000000000783ff.go b/internal/engine/lib/sqlite_g_00000000000783ff.go new file mode 100644 index 0000000..b3717bd --- /dev/null +++ b/internal/engine/lib/sqlite_g_00000000000783ff.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __GCC_CONSTRUCTIVE_SIZE = 64 diff --git a/internal/engine/lib/sqlite_g_000000000007bfc0.go b/internal/engine/lib/sqlite_g_000000000007bfc0.go new file mode 100644 index 0000000..53664ea --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007bfc0.go @@ -0,0 +1,11 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const CLOCK_PROCESS_CPUTIME_ID = 2 + +const _POSIX_CPUTIME = 200809 + +const _POSIX_THREAD_CPUTIME = 200809 diff --git a/internal/engine/lib/sqlite_g_000000000007bfff.go b/internal/engine/lib/sqlite_g_000000000007bfff.go new file mode 100644 index 0000000..d6f223a --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007bfff.go @@ -0,0 +1,17 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __INT_FAST8_MAX__ = 127 + +const __INT_FAST8_WIDTH__ = 8 + +const __UINT_FAST8_MAX__ = 255 + +type mode_t = Tmode_t + +type off_t = Toff_t + +type pid_t = Tpid_t diff --git a/internal/engine/lib/sqlite_g_000000000007c03f.go b/internal/engine/lib/sqlite_g_000000000007c03f.go new file mode 100644 index 0000000..e6f8364 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007c03f.go @@ -0,0 +1,29 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const EOF = -1 + +const FOPEN_MAX = 20 + +const HUGE_VAL = 0 + +const HUGE_VALL = 0 + +const SEEK_CUR = 1 + +const SEEK_END = 2 + +const SEEK_SET = 0 + +const SQLITE_MUTEX_NOOP = 1 + +type ptrdiff_t = Tptrdiff_t + +type sqlite3_io_methods = Tsqlite3_io_methods + +type timezone = Ttimezone + +type uint_fast32_t = Tuint_fast32_t diff --git a/internal/engine/lib/sqlite_g_000000000007c17f.go b/internal/engine/lib/sqlite_g_000000000007c17f.go new file mode 100644 index 0000000..565ea46 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007c17f.go @@ -0,0 +1,13 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && arm) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __INT_FAST32_MAX__ = 2147483647 + +const __INT_FAST32_TYPE__ = 0 + +const __INT_FAST32_WIDTH__ = 32 + +const __UINT_FAST32_MAX__ = 4294967295 diff --git a/internal/engine/lib/sqlite_g_000000000007c3ef.go b/internal/engine/lib/sqlite_g_000000000007c3ef.go new file mode 100644 index 0000000..836f8c2 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007c3ef.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __GCC_ASM_FLAG_OUTPUTS__ = 1 diff --git a/internal/engine/lib/sqlite_g_000000000007deed.go b/internal/engine/lib/sqlite_g_000000000007deed.go new file mode 100644 index 0000000..a2b5053 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007deed.go @@ -0,0 +1,7 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __BIGGEST_ALIGNMENT__ = 16 diff --git a/internal/engine/lib/sqlite_g_000000000007dfff.go b/internal/engine/lib/sqlite_g_000000000007dfff.go new file mode 100644 index 0000000..e723c37 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007dfff.go @@ -0,0 +1,99 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +const SQLITE_BIGENDIAN = 0 + +const SQLITE_BYTEORDER = 1234 + +const SQLITE_LITTLEENDIAN = 1 + +const SQLITE_UTF16NATIVE = 2 + +// C documentation +// +// /* +// ** This routine is the same as the sqlite3_complete() routine described +// ** above, except that the parameter is required to be UTF-16 encoded, not +// ** UTF-8. +// */ +func Xsqlite3_complete16(tls *libc.TLS, zSql uintptr) (r int32) { + var pVal, zSql8 uintptr + var rc int32 + _, _, _ = pVal, rc, zSql8 + rc = Xsqlite3_initialize(tls) + if rc != 0 { + return rc + } + pVal = _sqlite3ValueNew(tls, uintptr(0)) + _sqlite3ValueSetStr(tls, pVal, -int32(1), zSql, uint8(SQLITE_UTF16LE), libc.UintptrFromInt32(0)) + zSql8 = _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF8)) + if zSql8 != 0 { + rc = Xsqlite3_complete(tls, zSql8) + } else { + rc = int32(SQLITE_NOMEM) + } + _sqlite3ValueFree(tls, pVal) + return rc & int32(0xff) +} + +/************** End of rtree.h ***********************************************/ +/************** Continuing where we left off in main.c ***********************/ + +func Xsqlite3_create_function16(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg int32, eTextRep int32, p uintptr, __ccgo_fp_xSFunc uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr) (r int32) { + var rc int32 + var zFunc8 uintptr + _, _ = rc, zFunc8 + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + zFunc8 = _sqlite3Utf16to8(tls, db, zFunctionName, -int32(1), uint8(SQLITE_UTF16LE)) + rc = _sqlite3CreateFunc(tls, db, zFunc8, nArg, eTextRep, p, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, uintptr(0), uintptr(0), uintptr(0)) + _sqlite3DbFree(tls, db, zFunc8) + rc = _sqlite3ApiExit(tls, db, rc) + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +func Xsqlite3_result_error16(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) { + (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = int32(SQLITE_ERROR) + _sqlite3VdbeMemSetStr(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, int64(n), uint8(SQLITE_UTF16LE), uintptr(-libc.Int32FromInt32(1))) +} + +func Xsqlite3_value_bytes16(tls *libc.TLS, pVal uintptr) (r int32) { + return _sqlite3ValueBytes(tls, pVal, uint8(SQLITE_UTF16LE)) +} + +func Xsqlite3_value_text16(tls *libc.TLS, pVal uintptr) (r uintptr) { + return _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF16LE)) +} + +const __BYTE_ORDER__ = 1234 + +func _readCoord(tls *libc.TLS, p uintptr, pCoord uintptr) { + *(*Tu32)(unsafe.Pointer(pCoord)) = uint32(**(**Tu8)(__ccgo_up(p)))<> libc.Int32FromInt32(24)) + **(**uint8)(__ccgo_up(p + 1)) = uint8(v >> libc.Int32FromInt32(16)) + **(**uint8)(__ccgo_up(p + 2)) = uint8(v >> libc.Int32FromInt32(8)) + **(**uint8)(__ccgo_up(p + 3)) = uint8(v) +} + +func _writeCoord(tls *libc.TLS, p uintptr, pCoord uintptr) (r int32) { + var i Tu32 + _ = i + i = *(*Tu32)(unsafe.Pointer(pCoord)) + **(**Tu8)(__ccgo_up(p)) = uint8(i >> libc.Int32FromInt32(24) & uint32(0xFF)) + **(**Tu8)(__ccgo_up(p + 1)) = uint8(i >> libc.Int32FromInt32(16) & uint32(0xFF)) + **(**Tu8)(__ccgo_up(p + 2)) = uint8(i >> libc.Int32FromInt32(8) & uint32(0xFF)) + **(**Tu8)(__ccgo_up(p + 3)) = uint8(i >> libc.Int32FromInt32(0) & uint32(0xFF)) + return int32(4) +} diff --git a/internal/engine/lib/sqlite_g_000000000007feec.go b/internal/engine/lib/sqlite_g_000000000007feec.go new file mode 100644 index 0000000..9902f50 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007feec.go @@ -0,0 +1,10 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +type Titimerspec = struct { + Fit_interval Ttimespec + Fit_value Ttimespec +} diff --git a/internal/engine/lib/sqlite_g_000000000007feff.go b/internal/engine/lib/sqlite_g_000000000007feff.go new file mode 100644 index 0000000..7850f6d --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007feff.go @@ -0,0 +1,21 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const __GCC_ATOMIC_BOOL_LOCK_FREE = 2 + +const __GCC_ATOMIC_CHAR16_T_LOCK_FREE = 2 + +const __GCC_ATOMIC_CHAR_LOCK_FREE = 2 + +const __GCC_ATOMIC_LLONG_LOCK_FREE = 2 + +const __GCC_ATOMIC_SHORT_LOCK_FREE = 2 + +const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = 1 + +const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = 1 + +const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = 1 diff --git a/internal/engine/lib/sqlite_g_000000000007ffbb.go b/internal/engine/lib/sqlite_g_000000000007ffbb.go new file mode 100644 index 0000000..a9856c7 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007ffbb.go @@ -0,0 +1,340 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Set the soft heap-size limit for the library. An argument of +// ** zero disables the limit. A negative argument is a no-op used to +// ** obtain the return value. +// ** +// ** The return value is the value of the heap limit just before this +// ** interface was called. +// ** +// ** If the hard heap limit is enabled, then the soft heap limit cannot +// ** be disabled nor raised above the hard heap limit. +// */ +func Xsqlite3_soft_heap_limit64(tls *libc.TLS, n Tsqlite3_int64) (r Tsqlite3_int64) { + var excess, nUsed, priorLimit Tsqlite3_int64 + var rc int32 + _, _, _, _ = excess, nUsed, priorLimit, rc + rc = Xsqlite3_initialize(tls) + if rc != 0 { + return int64(-int32(1)) + } + Xsqlite3_mutex_enter(tls, _mem0.Fmutex) + priorLimit = _mem0.FalarmThreshold + if n < 0 { + Xsqlite3_mutex_leave(tls, _mem0.Fmutex) + return priorLimit + } + if _mem0.FhardLimit > 0 && (n > _mem0.FhardLimit || n == 0) { + n = _mem0.FhardLimit + } + _mem0.FalarmThreshold = n + nUsed = _sqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) + libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&_mem0))+24, libc.BoolInt32(n > 0 && n <= nUsed), libc.Int32FromInt32(__ATOMIC_RELAXED)) + Xsqlite3_mutex_leave(tls, _mem0.Fmutex) + excess = Xsqlite3_memory_used(tls) - n + if excess > 0 { + Xsqlite3_release_memory(tls, int32(excess&libc.Int64FromInt32(0x7fffffff))) + } + return priorLimit +} + +func _first_valueFinalizeFunc(tls *libc.TLS, pCtx uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, pCtx, int32(16)) + if p != 0 && (*TNthValueCtx)(unsafe.Pointer(p)).FpValue != 0 { + Xsqlite3_result_value(tls, pCtx, (*TNthValueCtx)(unsafe.Pointer(p)).FpValue) + Xsqlite3_value_free(tls, (*TNthValueCtx)(unsafe.Pointer(p)).FpValue) + (*TNthValueCtx)(unsafe.Pointer(p)).FpValue = uintptr(0) + } +} + +func _first_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { + var p uintptr + _ = p + p = Xsqlite3_aggregate_context(tls, pCtx, int32(16)) + if p != 0 && (*TNthValueCtx)(unsafe.Pointer(p)).FpValue == uintptr(0) { + (*TNthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, **(**uintptr)(__ccgo_up(apArg))) + if !((*TNthValueCtx)(unsafe.Pointer(p)).FpValue != 0) { + Xsqlite3_result_error_nomem(tls, pCtx) + } + } + _ = nArg + _ = apArg +} + +func _fixBoundingBox(tls *libc.TLS, pRtree uintptr, pNode uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var nCell, rc int32 + var pParent uintptr + var _ /* box at bp+8 */ TRtreeCell + var _ /* cell at bp+56 */ TRtreeCell + var _ /* ii at bp+0 */ int32 + _, _, _ = nCell, pParent, rc + pParent = (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent + rc = SQLITE_OK + if pParent != 0 { + nCell = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) /* Bounding box for pNode */ + _nodeGetCell(tls, pRtree, pNode, 0, bp+8) + **(**int32)(__ccgo_up(bp)) = int32(1) + for { + if !(**(**int32)(__ccgo_up(bp)) < nCell) { + break + } + _nodeGetCell(tls, pRtree, pNode, **(**int32)(__ccgo_up(bp)), bp+56) + _cellUnion(tls, pRtree, bp+8, bp+56) + goto _1 + _1: + ; + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + } + (**(**TRtreeCell)(__ccgo_up(bp + 8))).FiRowid = (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode + rc = _nodeParentIndex(tls, pRtree, pNode, bp) + if rc == SQLITE_OK { + _nodeOverwriteCell(tls, pRtree, pParent, bp+8, **(**int32)(__ccgo_up(bp))) + rc = _fixBoundingBox(tls, pRtree, pParent) + } + } + return rc +} + +// C documentation +// +// /* +// ** The iterator passed as the first argument has the following fields set +// ** as follows. This function sets up the rest of the iterator so that it +// ** points to the first rowid in the doclist-index. +// ** +// ** pData: +// ** pointer to doclist-index record, +// ** +// ** When this function is called pIter->iLeafPgno is the page number the +// ** doclist is associated with (the one featuring the term). +// */ +func _fts5DlidxIterFirst(tls *libc.TLS, pIter uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < (*TFts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl) { + break + } + _fts5DlidxLvlNext(tls, pIter+8+uintptr(i)*32) + goto _1 + _1: + ; + i = i + 1 + } + return (*(*TFts5DlidxLvl)(unsafe.Pointer(pIter + 8))).FbEof +} + +// C documentation +// +// /* +// ** Free a doclist-index iterator object allocated by fts5DlidxIterInit(). +// */ +func _fts5DlidxIterFree(tls *libc.TLS, pIter uintptr) { + var i int32 + _ = i + if pIter != 0 { + i = 0 + for { + if !(i < (*TFts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl) { + break + } + _fts5DataRelease(tls, (*(*TFts5DlidxLvl)(unsafe.Pointer(pIter + 8 + uintptr(i)*32))).FpData) + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_free(tls, pIter) + } +} + +func _fts5WriteDlidxClear(tls *libc.TLS, p uintptr, pWriter uintptr, bFlush int32) { + var i int32 + var pDlidx uintptr + _, _ = i, pDlidx + i = 0 + for { + if !(i < (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx) { + break + } + pDlidx = (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32 + if (*TFts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn == 0 { + break + } + if bFlush != 0 { + _fts5DataWrite(tls, p, int64((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(1))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(i)< 0 { + nUsed = _sqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) + if nUsed >= _mem0.FalarmThreshold-int64(nFull) { + libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&_mem0))+24, libc.Int32FromInt32(1), libc.Int32FromInt32(__ATOMIC_RELAXED)) + _sqlite3MallocAlarm(tls, nFull) + if _mem0.FhardLimit != 0 { + nUsed = _sqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) + if nUsed >= _mem0.FhardLimit-int64(nFull) { + **(**uintptr)(__ccgo_up(pp)) = uintptr(0) + return + } + } + } else { + libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&_mem0))+24, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + } + p = (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxMalloc})))(tls, nFull) + if p == uintptr(0) && _mem0.FalarmThreshold > 0 { + _sqlite3MallocAlarm(tls, nFull) + p = (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxMalloc})))(tls, nFull) + } + if p != 0 { + nFull = _sqlite3MallocSize(tls, p) + _sqlite3StatusUp(tls, SQLITE_STATUS_MEMORY_USED, nFull) + _sqlite3StatusUp(tls, int32(SQLITE_STATUS_MALLOC_COUNT), int32(1)) + } + **(**uintptr)(__ccgo_up(pp)) = p +} + +func _reinsertNodeContent(tls *libc.TLS, pRtree uintptr, pNode uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var ii, nCell, rc, rc2 int32 + var _ /* cell at bp+8 */ TRtreeCell + var _ /* pInsert at bp+0 */ uintptr + _, _, _, _ = ii, nCell, rc, rc2 + rc = SQLITE_OK + nCell = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2) + ii = 0 + for { + if !(rc == SQLITE_OK && ii < nCell) { + break + } + _nodeGetCell(tls, pRtree, pNode, ii, bp+8) + /* Find a node to store this cell in. pNode->iNode currently contains + ** the height of the sub-tree headed by the cell. + */ + rc = _ChooseLeaf(tls, pRtree, bp+8, int32((*TRtreeNode)(unsafe.Pointer(pNode)).FiNode), bp) + if rc == SQLITE_OK { + rc = _rtreeInsertCell(tls, pRtree, **(**uintptr)(__ccgo_up(bp)), bp+8, int32((*TRtreeNode)(unsafe.Pointer(pNode)).FiNode)) + rc2 = _nodeRelease(tls, pRtree, **(**uintptr)(__ccgo_up(bp))) + if rc == SQLITE_OK { + rc = rc2 + } + } + goto _1 + _1: + ; + ii = ii + 1 + } + return rc +} + +// C documentation +// +// /* +// ** Return true if the heap is currently under memory pressure - in other +// ** words if the amount of heap used is close to the limit set by +// ** sqlite3_soft_heap_limit(). +// */ +func _sqlite3HeapNearlyFull(tls *libc.TLS) (r int32) { + return libc.AtomicLoadNInt32(uintptr(unsafe.Pointer(&_mem0))+24, libc.Int32FromInt32(__ATOMIC_RELAXED)) +} + +// C documentation +// +// /* Allocate memory that is automatically freed when pWInfo is freed. +// */ +func _sqlite3WhereMalloc(tls *libc.TLS, pWInfo uintptr, nByte Tu64) (r uintptr) { + var pBlock uintptr + _ = pBlock + pBlock = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer((*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb, nByte+uint64(16)) + if pBlock != 0 { + (*TWhereMemBlock)(unsafe.Pointer(pBlock)).FpNext = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree + (*TWhereMemBlock)(unsafe.Pointer(pBlock)).Fsz = nByte + (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree = pBlock + pBlock += 16 + } + return pBlock +} + +func _sumInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iVal Ti64 + var p uintptr + var type1 int32 + var _ /* x at bp+0 */ Ti64 + _, _, _ = iVal, p, type1 + _ = argc + p = Xsqlite3_aggregate_context(tls, context, int32(40)) + type1 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) + /* p is always non-NULL because sumStep() will have been called first + ** to initialize it */ + if p != 0 && type1 != int32(SQLITE_NULL) { + (*TSumCtx)(unsafe.Pointer(p)).Fcnt = (*TSumCtx)(unsafe.Pointer(p)).Fcnt - 1 + if !((*TSumCtx)(unsafe.Pointer(p)).Fapprox != 0) { + **(**Ti64)(__ccgo_up(bp)) = (*TSumCtx)(unsafe.Pointer(p)).FiSum + if _sqlite3SubInt64(tls, bp, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))) == 0 { + (*TSumCtx)(unsafe.Pointer(p)).FiSum = **(**Ti64)(__ccgo_up(bp)) + return + } + (*TSumCtx)(unsafe.Pointer(p)).Fovrfl = uint8(1) + (*TSumCtx)(unsafe.Pointer(p)).Fapprox = uint8(1) + _kahanBabuskaNeumaierInit(tls, p, (*TSumCtx)(unsafe.Pointer(p)).FiSum) + } + if type1 == int32(SQLITE_INTEGER) { + iVal = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))) + if iVal != int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<> int32(32) + b0 = uint64(uint32(b)) + b1 = b >> int32(32) + a0b0 = a0 * b0 + a1b1 = a1 * b1 + a0b1 = a0 * b1 + a1b0 = a1 * b0 + t = a0b0>>libc.Int32FromInt32(32) + uint64(uint32(a0b1)) + uint64(uint32(a1b0)) + **(**Tu64)(__ccgo_up(pLo)) = a0b0&uint64(0xffffffff) | t<>libc.Int32FromInt32(32) + a1b0>>libc.Int32FromInt32(32) + t>>libc.Int32FromInt32(32) +} diff --git a/internal/engine/lib/sqlite_g_000000000007ffdf.go b/internal/engine/lib/sqlite_g_000000000007ffdf.go new file mode 100644 index 0000000..af27623 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007ffdf.go @@ -0,0 +1,190 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +// C documentation +// +// /* +// ** Functions to converts degrees to radians and radians to degrees. +// */ +func _degToRad(tls *libc.TLS, x float64) (r float64) { + return float64(x * (libc.Float64FromFloat64(3.141592653589793) / libc.Float64FromFloat64(180))) +} + +// C documentation +// +// /* +// ** Compute the area enclosed by the polygon. +// ** +// ** This routine can also be used to detect polygons that rotate in +// ** the wrong direction. Polygons are suppose to be counter-clockwise (CCW). +// ** This routine returns a negative value for clockwise (CW) polygons. +// */ +func _geopolyArea(tls *libc.TLS, p uintptr) (r float64) { + var ii int32 + var rArea float64 + _, _ = ii, rArea + rArea = float64(0) + ii = 0 + for { + if !(ii < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex-int32(1)) { + break + } + rArea = rArea + float64(float64((**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4))-**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr((ii+int32(1))*int32(2))*4)))*(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4))+**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr((ii+int32(1))*int32(2)+int32(1))*4))))*float64(0.5)) + goto _1 + _1: + ; + ii = ii + 1 + } + rArea = rArea + float64(float64((**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4))-**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4)))*(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4))+**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4))))*float64(0.5)) + return rArea +} + +// C documentation +// +// /* Fast approximation for sine(X) for X between -0.5*pi and 2*pi +// */ +func _geopolySine(tls *libc.TLS, r float64) (r1 float64) { + var r2, r3, r5 float64 + _, _, _ = r2, r3, r5 + if r >= float64(libc.Float64FromFloat64(1.5)*libc.Float64FromFloat64(3.141592653589793)) { + r = r - float64(libc.Float64FromFloat64(2)*libc.Float64FromFloat64(3.141592653589793)) + } + if r >= float64(libc.Float64FromFloat64(0.5)*libc.Float64FromFloat64(3.141592653589793)) { + return -_geopolySine(tls, r-float64(3.141592653589793)) + } else { + r2 = float64(r * r) + r3 = float64(r2 * r) + r5 = float64(r3 * r2) + return float64(float64(0.9996949)*r) - float64(float64(0.16567)*r3) + float64(float64(0.0075134)*r5) + } + return r1 +} + +// C documentation +// +// /* +// ** Determine if point (x0,y0) is beneath line segment (x1,y1)->(x2,y2). +// ** Returns: +// ** +// ** +2 x0,y0 is on the line segment +// ** +// ** +1 x0,y0 is beneath line segment +// ** +// ** 0 x0,y0 is not on or beneath the line segment or the line segment +// ** is vertical and x0,y0 is not on the line segment +// ** +// ** The left-most coordinate min(x1,x2) is not considered to be part of +// ** the line segment for the purposes of this analysis. +// */ +func _pointBeneathLine(tls *libc.TLS, x0 float64, y0 float64, x1 float64, y1 float64, x2 float64, y2 float64) (r int32) { + var y float64 + _ = y + if x0 == x1 && y0 == y1 { + return int32(2) + } + if x1 < x2 { + if x0 <= x1 || x0 > x2 { + return 0 + } + } else { + if x1 > x2 { + if x0 <= x2 || x0 > x1 { + return 0 + } + } else { + /* Vertical line segment */ + if x0 != x1 { + return 0 + } + if y0 < y1 && y0 < y2 { + return 0 + } + if y0 > y1 && y0 > y2 { + return 0 + } + return int32(2) + } + } + y = y1 + float64((y2-y1)*(x0-x1))/(x2-x1) + if y0 == y { + return int32(2) + } + if y0 < y { + return int32(1) + } + return 0 +} + +func _radToDeg(tls *libc.TLS, x float64) (r float64) { + return float64(x * (libc.Float64FromFloat64(180) / libc.Float64FromFloat64(3.141592653589793))) +} + +// C documentation +// +// /* +// ** Convert an sqlite3_value into an RtreeValue (presumably a float) +// ** while taking care to round toward negative or positive, respectively. +// */ +func _rtreeValueDown(tls *libc.TLS, v uintptr) (r TRtreeValue) { + var d, v1 float64 + var f float32 + _, _, _ = d, f, v1 + d = Xsqlite3_value_double(tls, v) + f = float32(d) + if float64(f) > d { + if d < libc.Float64FromInt32(0) { + v1 = libc.Float64FromFloat64(1) + libc.Float64FromFloat64(1)/libc.Float64FromFloat64(8.388608e+06) + } else { + v1 = libc.Float64FromFloat64(1) - libc.Float64FromFloat64(1)/libc.Float64FromFloat64(8.388608e+06) + } + f = float32(float64(d * v1)) + } + return f +} + +func _rtreeValueUp(tls *libc.TLS, v uintptr) (r TRtreeValue) { + var d, v1 float64 + var f float32 + _, _, _ = d, f, v1 + d = Xsqlite3_value_double(tls, v) + f = float32(d) + if float64(f) < d { + if d < libc.Float64FromInt32(0) { + v1 = libc.Float64FromFloat64(1) - libc.Float64FromFloat64(1)/libc.Float64FromFloat64(8.388608e+06) + } else { + v1 = libc.Float64FromFloat64(1) + libc.Float64FromFloat64(1)/libc.Float64FromFloat64(8.388608e+06) + } + f = float32(float64(d * v1)) + } + return f +} + +func _sqlite3OsCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rc int32 + var _ /* r at bp+0 */ float64 + _ = rc + /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64() + ** method to get the current date and time if that method is available + ** (if iVersion is 2 or greater and the function pointer is not NULL) and + ** will fall back to xCurrentTime() if xCurrentTimeInt64() is + ** unavailable. + */ + if (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion >= int32(2) && (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTimeInt64 != 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTimeInt64})))(tls, pVfs, pTimeOut) + } else { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTime})))(tls, pVfs, bp) + **(**Tsqlite3_int64)(__ccgo_up(pTimeOut)) = int64(float64(**(**float64)(__ccgo_up(bp)) * libc.Float64FromFloat64(8.64e+07))) + } + return rc +} diff --git a/internal/engine/lib/sqlite_g_000000000007fffc.go b/internal/engine/lib/sqlite_g_000000000007fffc.go new file mode 100644 index 0000000..ec38796 --- /dev/null +++ b/internal/engine/lib/sqlite_g_000000000007fffc.go @@ -0,0 +1,23 @@ +// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. + +//go:build (freebsd && 386) || (freebsd && amd64) || (freebsd && arm) || (freebsd && arm64) || (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) || (windows && 386) + +package sqlite3 + +const SQLITE_ENABLE_LOCKING_STYLE = 0 + +const TIMER_ABSTIME = 1 + +const _XOPEN_SOURCE = 600 + +const __FLT_MIN__ = 0 + +const __LDBL_MIN__ = 0 + +var _aMap = [5]uint8{ + 0: uint8(SQLITE_ROLLBACK), + 1: uint8(SQLITE_ABORT), + 2: uint8(SQLITE_FAIL), + 3: uint8(SQLITE_IGNORE), + 4: uint8(SQLITE_REPLACE), +} diff --git a/internal/engine/lib/sqlite_linux_amd64.go b/internal/engine/lib/sqlite_linux_amd64.go new file mode 100644 index 0000000..91961b5 --- /dev/null +++ b/internal/engine/lib/sqlite_linux_amd64.go @@ -0,0 +1,30407 @@ +// Code generated for linux/amd64 by 'generator -mlong-double-64 --package-name libsqlite3 --prefix-enumerator=_ --prefix-external=x_ --prefix-field=F --prefix-static-internal=_ --prefix-static-none=_ --prefix-tagged-enum=_ --prefix-tagged-struct=T --prefix-tagged-union=T --prefix-typename=T --prefix-undefined=_ -ignore-unsupported-alignment -ignore-link-errors -import=sync -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DNDEBUG -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DISABLE_INTRINSIC -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_RBU -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_HAVE_ZLIB=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_WITHOUT_ZONEMALLOC -D_LARGEFILE64_SOURCE -I /home/jnml/src/modernc.org/builder/.exclude/github.com/hanzoai/sqlite/internal/libc/include/linux/amd64 -I /home/jnml/src/modernc.org/builder/.exclude/modernc.org/libz/include/linux/amd64 -I /home/jnml/src/modernc.org/builder/.exclude/modernc.org/libtcl8.6/include/linux/amd64 -extended-errors -o sqlite3.go sqlite3.c -DSQLITE_OS_UNIX=1 -eval-all-macros', DO NOT EDIT. + +//go:build linux && amd64 + +package sqlite3 + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" +) + +type Tstat = struct { + Fst_dev Tdev_t + Fst_ino Tino_t + Fst_nlink Tnlink_t + Fst_mode Tmode_t + Fst_uid Tuid_t + Fst_gid Tgid_t + F__pad0 uint32 + Fst_rdev Tdev_t + Fst_size Toff_t + Fst_blksize Tblksize_t + Fst_blocks Tblkcnt_t + Fst_atim Ttimespec + Fst_mtim Ttimespec + Fst_ctim Ttimespec + F__unused [3]int64 +} + +// C documentation +// +// /* +// ** Given the name of a compile-time option, return true if that option +// ** was used and false if not. +// ** +// ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix +// ** is not required for a match. +// */ +func Xsqlite3_compileoption_used(tls *libc.TLS, zOptName uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azCompileOpt uintptr + var i, n int32 + var _ /* nOpt at bp+0 */ int32 + _, _, _ = azCompileOpt, i, n + azCompileOpt = _sqlite3CompileOptions(tls, bp) + if Xsqlite3_strnicmp(tls, zOptName, __ccgo_ts+26299, int32(7)) == 0 { + zOptName = zOptName + uintptr(7) + } + n = _sqlite3Strlen30(tls, zOptName) + /* Since nOpt is normally in single digits, a linear search is + ** adequate. No need for a binary search. */ + i = 0 + for { + if !(i < **(**int32)(__ccgo_up(bp))) { + break + } + if Xsqlite3_strnicmp(tls, zOptName, **(**uintptr)(__ccgo_up(azCompileOpt + uintptr(i)*8)), n) == 0 && _sqlite3IsIdChar(tls, libc.Uint8FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(azCompileOpt + uintptr(i)*8)) + uintptr(n))))) == 0 { + return int32(1) + } + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +// C documentation +// +// /* +// ** Execute SQL code. Return one of the SQLITE_ success/failure +// ** codes. Also write an error message into memory obtained from +// ** malloc() and make *pzErrMsg point to that message. +// ** +// ** If the SQL is a query, then for each row in the query result +// ** the xCallback() function is called. pArg becomes the first +// ** argument to xCallback(). If xCallback=NULL then no callback +// ** is invoked, even for queries. +// */ +func Xsqlite3_exec(tls *libc.TLS, db uintptr, zSql uintptr, __ccgo_fp_xCallback Tsqlite3_callback, pArg uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var azCols, azVals uintptr + var callbackIsInit, i, nCol, rc int32 + var _ /* pStmt at bp+8 */ uintptr + var _ /* zLeftover at bp+0 */ uintptr + _, _, _, _, _, _ = azCols, azVals, callbackIsInit, i, nCol, rc + rc = SQLITE_OK /* Tail of unprocessed SQL */ + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) /* The current SQL statement */ + azCols = uintptr(0) /* True if callback data is initialized */ + if !(_sqlite3SafetyCheckOk(tls, db) != 0) { + return _sqlite3MisuseError(tls, int32(142203)) + } + if zSql == uintptr(0) { + zSql = __ccgo_ts + 1704 + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + _sqlite3Error(tls, db, SQLITE_OK) + for rc == SQLITE_OK && **(**int8)(__ccgo_up(zSql)) != 0 { + nCol = 0 + azVals = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp+8, bp) + if rc != SQLITE_OK { + continue + } + if !(**(**uintptr)(__ccgo_up(bp + 8)) != 0) { + /* this happens for a comment or white-space */ + zSql = **(**uintptr)(__ccgo_up(bp)) + continue + } + callbackIsInit = 0 + for int32(1) != 0 { + rc = Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) + /* Invoke the callback function if required */ + if __ccgo_fp_xCallback != 0 && (int32(SQLITE_ROW) == rc || int32(SQLITE_DONE) == rc && !(callbackIsInit != 0) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NullCallback) != 0) { + if !(callbackIsInit != 0) { + nCol = Xsqlite3_column_count(tls, **(**uintptr)(__ccgo_up(bp + 8))) + azCols = _sqlite3DbMallocRaw(tls, db, uint64(libc.Uint64FromInt32(libc.Int32FromInt32(2)*nCol+libc.Int32FromInt32(1))*uint64(8))) + if azCols == uintptr(0) { + goto exec_out + } + i = 0 + for { + if !(i < nCol) { + break + } + **(**uintptr)(__ccgo_up(azCols + uintptr(i)*8)) = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) + /* sqlite3VdbeSetColName() installs column names as UTF8 + ** strings so there is no way for sqlite3_column_name() to fail. */ + goto _1 + _1: + ; + i = i + 1 + } + callbackIsInit = int32(1) + } + if rc == int32(SQLITE_ROW) { + azVals = azCols + uintptr(nCol)*8 + i = 0 + for { + if !(i < nCol) { + break + } + **(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) + if !(**(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) != 0) && Xsqlite3_column_type(tls, **(**uintptr)(__ccgo_up(bp + 8)), i) != int32(SQLITE_NULL) { + _sqlite3OomFault(tls, db) + goto exec_out + } + goto _2 + _2: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up(azVals + uintptr(i)*8)) = uintptr(0) + } + if (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xCallback})))(tls, pArg, nCol, azVals, azCols) != 0 { + /* EVIDENCE-OF: R-38229-40159 If the callback function to + ** sqlite3_exec() returns non-zero, then sqlite3_exec() will + ** return SQLITE_ABORT. */ + rc = int32(SQLITE_ABORT) + _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + _sqlite3Error(tls, db, int32(SQLITE_ABORT)) + goto exec_out + } + } + if rc != int32(SQLITE_ROW) { + rc = _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + zSql = **(**uintptr)(__ccgo_up(bp)) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zSql)))])&int32(0x01) != 0 { + zSql = zSql + 1 + } + break + } + } + _sqlite3DbFree(tls, db, azCols) + azCols = uintptr(0) + } + goto exec_out +exec_out: + ; + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + _sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp + 8))) + } + _sqlite3DbFree(tls, db, azCols) + rc = _sqlite3ApiExit(tls, db, rc) + if rc != SQLITE_OK && pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = _sqlite3DbStrDup(tls, uintptr(0), Xsqlite3_errmsg(tls, db)) + if **(**uintptr)(__ccgo_up(pzErrMsg)) == uintptr(0) { + rc = int32(SQLITE_NOMEM) + _sqlite3Error(tls, db, int32(SQLITE_NOMEM)) + } + } else { + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Render a string given by "fmt" into the StrAccum object. +// */ +func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Tva_list) { + bp := tls.Alloc(128) + defer tls.Free(128) + var adj, c, e2, exp, iRound, idx, ii, ix, j, length, nOut, needQuote, nn, nn1, nn2, nn3, precision, width, x, v2, v3 int32 + var bArgList, base Tu8 + var bufpt, cset, escarg, infop, pArgList, pExpr, pItem, pSel, pToken, pre, z, zExtra, zOut, v4 uintptr + var cThousand, done, flag_alternateform, flag_altform2, flag_dp, flag_leftjustify, flag_long, flag_prefix, flag_rtz, flag_zeropad, xtype, v5, v6, v7, v8, v9 TetByte + var ch, px, wx uint32 + var ch1, prefix, q, x1, v54 int8 + var i, j1, k, n1, nBack, nCopyBytes, nCtrl, nPad, nPrior, szBufNeeded, v, v90 Ti64 + var longvalue Tsqlite_uint64 + var n Tu64 + var realvalue float64 + var v12 bool + var _ /* buf at bp+0 */ [70]int8 + var _ /* s at bp+72 */ TFpDecode + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = adj, bArgList, base, bufpt, c, cThousand, ch, ch1, cset, done, e2, escarg, exp, flag_alternateform, flag_altform2, flag_dp, flag_leftjustify, flag_long, flag_prefix, flag_rtz, flag_zeropad, i, iRound, idx, ii, infop, ix, j, j1, k, length, longvalue, n, n1, nBack, nCopyBytes, nCtrl, nOut, nPad, nPrior, needQuote, nn, nn1, nn2, nn3, pArgList, pExpr, pItem, pSel, pToken, pre, precision, prefix, px, q, realvalue, szBufNeeded, v, width, wx, x, x1, xtype, z, zExtra, zOut, v12, v2, v3, v4, v5, v54, v6, v7, v8, v9, v90 /* Thousands separator for %d and %u */ + xtype = uint8(etINVALID) /* Size of the rendering buffer */ + zExtra = uintptr(0) /* True if trailing zeros should be removed */ + pArgList = uintptr(0) /* Conversion buffer */ + /* pAccum never starts out with an empty buffer that was obtained from + ** malloc(). This precondition is required by the mprintf("%z...") + ** optimization. */ + bufpt = uintptr(0) + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_SQLFUNC) != 0 { + pArgList = libc.VaUintptr(&ap) + bArgList = uint8(1) + } else { + bArgList = uint8(0) + } + for { + v2 = int32(**(**int8)(__ccgo_up(fmt))) + c = v2 + if !(v2 != 0) { + break + } + if c != int32('%') { + bufpt = fmt + fmt = libc.Xstrchr(tls, fmt, int32('%')) + if fmt == uintptr(0) { + fmt = bufpt + uintptr(libc.Xstrlen(tls, bufpt)) + } + Xsqlite3_str_append(tls, pAccum, bufpt, int32(int64(fmt)-int64(bufpt))) + if int32(**(**int8)(__ccgo_up(fmt))) == 0 { + break + } + } + fmt = fmt + 1 + v4 = fmt + v2 = int32(**(**int8)(__ccgo_up(v4))) + c = v2 + if v2 == 0 { + Xsqlite3_str_append(tls, pAccum, __ccgo_ts+1688, int32(1)) + break + } + /* Find out what flags are present */ + v9 = libc.Uint8FromInt32(0) + flag_zeropad = v9 + v8 = v9 + flag_altform2 = v8 + v7 = v8 + flag_alternateform = v7 + v6 = v7 + cThousand = v6 + v5 = v6 + flag_prefix = v5 + flag_leftjustify = v5 + done = uint8(0) + width = 0 + flag_long = uint8(0) + precision = -int32(1) + for { + switch c { + case int32('-'): + flag_leftjustify = uint8(1) + case int32('+'): + flag_prefix = uint8('+') + case int32(' '): + flag_prefix = uint8(' ') + case int32('#'): + flag_alternateform = uint8(1) + case int32('!'): + flag_altform2 = uint8(1) + case int32('0'): + flag_zeropad = uint8(1) + case int32(','): + cThousand = uint8(',') + default: + done = uint8(1) + case int32('l'): + flag_long = uint8(1) + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + if c == int32('l') { + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + flag_long = uint8(2) + } + done = uint8(1) + case int32('1'): + fallthrough + case int32('2'): + fallthrough + case int32('3'): + fallthrough + case int32('4'): + fallthrough + case int32('5'): + fallthrough + case int32('6'): + fallthrough + case int32('7'): + fallthrough + case int32('8'): + fallthrough + case int32('9'): + wx = libc.Uint32FromInt32(c - int32('0')) + for { + fmt = fmt + 1 + v4 = fmt + v2 = int32(**(**int8)(__ccgo_up(v4))) + c = v2 + if !(v2 >= int32('0') && c <= int32('9')) { + break + } + wx = wx*uint32(10) + libc.Uint32FromInt32(c) - uint32('0') + } + width = libc.Int32FromUint32(wx & uint32(0x7fffffff)) + if c != int32('.') && c != int32('l') { + done = uint8(1) + } else { + fmt = fmt - 1 + } + case int32('*'): + if bArgList != 0 { + width = int32(_getIntArg(tls, pArgList)) + } else { + width = libc.VaInt32(&ap) + } + if width < 0 { + flag_leftjustify = uint8(1) + if width >= -int32(2147483647) { + v2 = -width + } else { + v2 = 0 + } + width = v2 + } + v2 = int32(**(**int8)(__ccgo_up(fmt + 1))) + c = v2 + if v2 != int32('.') && c != int32('l') { + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + done = uint8(1) + } + case int32('.'): + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + if c == int32('*') { + if bArgList != 0 { + precision = int32(_getIntArg(tls, pArgList)) + } else { + precision = libc.VaInt32(&ap) + } + if precision < 0 { + if precision >= -int32(2147483647) { + v2 = -precision + } else { + v2 = -int32(1) + } + precision = v2 + } + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + } else { + px = uint32(0) + for c >= int32('0') && c <= int32('9') { + px = px*uint32(10) + libc.Uint32FromInt32(c) - uint32('0') + fmt = fmt + 1 + v4 = fmt + c = int32(**(**int8)(__ccgo_up(v4))) + } + precision = libc.Int32FromUint32(px & uint32(0x7fffffff)) + } + if c == int32('l') { + fmt = fmt - 1 + } else { + done = uint8(1) + } + break + } + goto _13 + _13: + ; + if v12 = !(done != 0); v12 { + fmt = fmt + 1 + v4 = fmt + v2 = int32(**(**int8)(__ccgo_up(v4))) + c = v2 + } + if !(v12 && v2 != 0) { + break + } + } + /* Fetch the info entry for the field */ + /* Fast hash-table lookup */ + idx = libc.Int32FromUint32(libc.Uint32FromInt32(c) % uint32(23)) + if v12 = int32(_fmtinfo[idx].Ffmttype) == c; !v12 { + v2 = int32(_fmtinfo[idx].FiNxt) + idx = v2 + } + if v12 || int32(_fmtinfo[v2].Ffmttype) == c { + infop = uintptr(unsafe.Pointer(&_fmtinfo)) + uintptr(idx)*7 + xtype = (*Tet_info)(unsafe.Pointer(infop)).Ftype1 + } else { + infop = uintptr(unsafe.Pointer(&_fmtinfo)) + xtype = uint8(etINVALID) + } + /* + ** At this point, variables are initialized as follows: + ** + ** flag_alternateform TRUE if a '#' is present. + ** flag_altform2 TRUE if a '!' is present. + ** flag_prefix '+' or ' ' or zero + ** flag_leftjustify TRUE if a '-' is present or if the + ** field width was negative. + ** flag_zeropad TRUE if the width began with 0. + ** flag_long 1 for "l", 2 for "ll" + ** width The specified field width. This is + ** always non-negative. Zero is the default. + ** precision The specified precision. The default + ** is -1. + ** xtype The class of the conversion. + ** infop Pointer to the appropriate info struct. + */ + switch libc.Int32FromUint8(xtype) { + case int32(etPOINTER): + goto _27 + case etRADIX: + goto _28 + case int32(etORDINAL): + goto _29 + case int32(etDECIMAL): + goto _30 + case int32(etGENERIC): + goto _31 + case int32(etEXP): + goto _32 + case int32(etFLOAT): + goto _33 + case int32(etSIZE): + goto _34 + case int32(etPERCENT): + goto _35 + case int32(etCHARX): + goto _36 + case int32(etDYNSTRING): + goto _37 + case int32(etSTRING): + goto _38 + case int32(etESCAPE_w): + goto _39 + case int32(etESCAPE_Q): + goto _40 + case int32(etESCAPE_q): + goto _41 + case int32(etTOKEN): + goto _42 + case int32(etSRCITEM): + goto _43 + default: + goto _44 + } + goto _45 + _27: + ; + flag_long = uint8(2) + _29: + ; + _28: + ; + cThousand = uint8(0) + _30: + ; + if libc.Int32FromUint8((*Tet_info)(unsafe.Pointer(infop)).Fflags)&int32(FLAG_SIGNED) != 0 { + if bArgList != 0 { + v = _getIntArg(tls, pArgList) + } else { + if flag_long != 0 { + if libc.Int32FromUint8(flag_long) == int32(2) { + v = libc.VaInt64(&ap) + } else { + v = int64(libc.VaInt64(&ap)) + } + } else { + v = int64(libc.VaInt32(&ap)) + } + } + if v < 0 { + longvalue = libc.Uint64FromInt64(^v) + longvalue = longvalue + 1 + prefix = int8('-') + } else { + longvalue = libc.Uint64FromInt64(v) + prefix = libc.Int8FromUint8(flag_prefix) + } + } else { + if bArgList != 0 { + longvalue = libc.Uint64FromInt64(_getIntArg(tls, pArgList)) + } else { + if flag_long != 0 { + if libc.Int32FromUint8(flag_long) == int32(2) { + longvalue = libc.VaUint64(&ap) + } else { + longvalue = uint64(libc.VaUint64(&ap)) + } + } else { + longvalue = uint64(libc.VaUint32(&ap)) + } + } + prefix = 0 + } + if longvalue == uint64(0) { + flag_alternateform = uint8(0) + } + if flag_zeropad != 0 && precision < width-libc.BoolInt32(int32(prefix) != 0) { + precision = width - libc.BoolInt32(int32(prefix) != 0) + } + if precision < libc.Int32FromInt32(SQLITE_PRINT_BUF_SIZE)-libc.Int32FromInt32(10)-libc.Int32FromInt32(SQLITE_PRINT_BUF_SIZE)/libc.Int32FromInt32(3) { + nOut = int32(SQLITE_PRINT_BUF_SIZE) + zOut = bp + } else { + n = libc.Uint64FromInt32(precision) + uint64(10) + if cThousand != 0 { + n = n + libc.Uint64FromInt32(precision/int32(3)) + } + v4 = _printfTempBuf(tls, pAccum, libc.Int64FromUint64(n)) + zExtra = v4 + zOut = v4 + if zOut == uintptr(0) { + return + } + nOut = libc.Int32FromUint64(n) + } + bufpt = zOut + uintptr(nOut-int32(1)) + if libc.Int32FromUint8(xtype) == int32(etORDINAL) { + x = libc.Int32FromUint64(longvalue % libc.Uint64FromInt32(10)) + if x >= int32(4) || longvalue/uint64(10)%uint64(10) == uint64(1) { + x = 0 + } + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = _zOrd[x*int32(2)+int32(1)] + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = _zOrd[x*int32(2)] + } + cset = uintptr(unsafe.Pointer(&_aDigits)) + uintptr((*Tet_info)(unsafe.Pointer(infop)).Fcharset) + base = (*Tet_info)(unsafe.Pointer(infop)).Fbase + for cond := true; cond; cond = longvalue > uint64(0) { /* Convert to ascii */ + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = **(**int8)(__ccgo_up(cset + uintptr(longvalue%uint64(base)))) + longvalue = longvalue / uint64(base) + } + length = int32(t__predefined_ptrdiff_t(zOut+uintptr(nOut-int32(1))) - int64(bufpt)) + if precision > length { /* zero pad */ + nn = precision - length + bufpt = bufpt - uintptr(nn) + libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(nn)) + length = precision + } + if cThousand != 0 { + nn1 = (length - int32(1)) / int32(3) /* Number of "," to insert */ + ix = (length-int32(1))%int32(3) + int32(1) + bufpt = bufpt - uintptr(nn1) + idx = 0 + for { + if !(nn1 > 0) { + break + } + **(**int8)(__ccgo_up(bufpt + uintptr(idx))) = **(**int8)(__ccgo_up(bufpt + uintptr(idx+nn1))) + ix = ix - 1 + if ix == 0 { + idx = idx + 1 + v2 = idx + **(**int8)(__ccgo_up(bufpt + uintptr(v2))) = libc.Int8FromUint8(cThousand) + nn1 = nn1 - 1 + ix = int32(3) + } + goto _50 + _50: + ; + idx = idx + 1 + } + } + if prefix != 0 { + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = prefix + } /* Add sign */ + if flag_alternateform != 0 && (*Tet_info)(unsafe.Pointer(infop)).Fprefix != 0 { + pre = uintptr(unsafe.Pointer(&_aPrefix)) + uintptr((*Tet_info)(unsafe.Pointer(infop)).Fprefix) + for { + v54 = **(**int8)(__ccgo_up(pre)) + x1 = v54 + if !(int32(v54) != 0) { + break + } + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = x1 + goto _53 + _53: + ; + pre = pre + 1 + } + } + length = int32(t__predefined_ptrdiff_t(zOut+uintptr(nOut-int32(1))) - int64(bufpt)) + goto _45 + _33: + ; + _32: + ; + _31: + ; /* Size needed to hold the output */ + if bArgList != 0 { + realvalue = _getDoubleArg(tls, pArgList) + } else { + realvalue = libc.VaFloat64(&ap) + } + if precision < 0 { + precision = int32(6) + } /* Set default precision */ + if precision > int32(SQLITE_FP_PRECISION_LIMIT) { + precision = int32(SQLITE_FP_PRECISION_LIMIT) + } + if libc.Int32FromUint8(xtype) == int32(etFLOAT) { + iRound = -precision + } else { + if libc.Int32FromUint8(xtype) == int32(etGENERIC) { + if precision == 0 { + precision = int32(1) + } + iRound = precision + } else { + iRound = precision + int32(1) + } + } + if flag_altform2 != 0 { + v2 = int32(20) + } else { + v2 = int32(16) + } + _sqlite3FpDecode(tls, bp+72, realvalue, iRound, v2) + if (**(**TFpDecode)(__ccgo_up(bp + 72))).FisSpecial != 0 { + if int32((**(**TFpDecode)(__ccgo_up(bp + 72))).FisSpecial) == int32(2) { + if flag_zeropad != 0 { + v4 = __ccgo_ts + 1690 + } else { + v4 = __ccgo_ts + 1695 + } + bufpt = v4 + length = _sqlite3Strlen30(tls, bufpt) + goto _45 + } else { + if flag_zeropad != 0 { + **(**int8)(__ccgo_up((**(**TFpDecode)(__ccgo_up(bp + 72))).Fz)) = int8('9') + (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP = int32(1000) + (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn = int32(1) + } else { + libc.Xmemcpy(tls, bp, __ccgo_ts+1699, uint64(5)) + bufpt = bp + if int32((**(**TFpDecode)(__ccgo_up(bp + 72))).Fsign) == int32('-') { + /* no-op */ + } else { + if flag_prefix != 0 { + (**(**[70]int8)(__ccgo_up(bp)))[0] = libc.Int8FromUint8(flag_prefix) + } else { + bufpt = bufpt + 1 + } + } + length = _sqlite3Strlen30(tls, bufpt) + goto _45 + } + } + } + if int32((**(**TFpDecode)(__ccgo_up(bp + 72))).Fsign) == int32('-') { + if flag_alternateform != 0 && !(flag_prefix != 0) && libc.Int32FromUint8(xtype) == int32(etFLOAT) && (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP <= iRound { + /* Suppress the minus sign if all of the following are true: + ** * The value displayed is zero + ** * The '#' flag is used + ** * The '+' flag is not used, and + ** * The format is %f + */ + prefix = 0 + } else { + prefix = int8('-') + } + } else { + prefix = libc.Int8FromUint8(flag_prefix) + } + exp = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + /* + ** If the field type is etGENERIC, then convert to either etEXP + ** or etFLOAT, as appropriate. + */ + if libc.Int32FromUint8(xtype) == int32(etGENERIC) { + precision = precision - 1 + flag_rtz = libc.BoolUint8(!(flag_alternateform != 0)) + if exp < -int32(4) || exp > precision { + xtype = uint8(etEXP) + } else { + precision = precision - exp + xtype = uint8(etFLOAT) + } + } else { + flag_rtz = flag_altform2 + } + if libc.Int32FromUint8(xtype) == int32(etEXP) { + e2 = 0 + } else { + e2 = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + } + if e2 > 0 { + v2 = e2 + } else { + v2 = 0 + } + szBufNeeded = int64(v2) + int64(precision) + int64(width) + int64(10) + if cThousand != 0 && e2 > 0 { + szBufNeeded = szBufNeeded + int64((e2+int32(2))/int32(3)) + } + if szBufNeeded+libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) >= libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc) { + if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc == uint32(0) && libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0 { + /* Unable to allocate space in pAccum, perhaps because it + ** is coming from sqlite3_snprintf() or similar. We'll have + ** to render into temporary space and the memcpy() it over. */ + bufpt = Xsqlite3_malloc(tls, int32(szBufNeeded)) + if bufpt == uintptr(0) { + _sqlite3StrAccumSetError(tls, pAccum, uint8(SQLITE_NOMEM)) + return + } + zExtra = bufpt + } else { + if int64(_sqlite3StrAccumEnlarge(tls, pAccum, szBufNeeded)) < szBufNeeded { + v2 = libc.Int32FromInt32(0) + length = v2 + width = v2 + goto _45 + } else { + bufpt = (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + } + } else { + bufpt = (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + zOut = bufpt + if precision > 0 { + v2 = int32(1) + } else { + v2 = 0 + } + flag_dp = libc.Uint8FromInt32(v2 | libc.Int32FromUint8(flag_alternateform) | libc.Int32FromUint8(flag_altform2)) + /* The sign in front of the number */ + if prefix != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = prefix + } + /* Digits prior to the decimal point */ + j = 0 + if e2 < 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('0') + } else { + if cThousand != 0 { + for { + if !(e2 >= 0) { + break + } + v4 = bufpt + bufpt = bufpt + 1 + if j < (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn { + v3 = j + j = j + 1 + v2 = int32(**(**int8)(__ccgo_up((**(**TFpDecode)(__ccgo_up(bp + 72))).Fz + uintptr(v3)))) + } else { + v2 = int32('0') + } + **(**int8)(__ccgo_up(v4)) = int8(v2) + if e2%int32(3) == 0 && e2 > int32(1) { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8(',') + } + goto _63 + _63: + ; + e2 = e2 - 1 + } + } else { + j = e2 + int32(1) + if j > (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn { + j = (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn + } + libc.Xmemcpy(tls, bufpt, (**(**TFpDecode)(__ccgo_up(bp + 72))).Fz, libc.Uint64FromInt32(j)) + bufpt = bufpt + uintptr(j) + e2 = e2 - j + if e2 >= 0 { + libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(e2+int32(1))) + bufpt = bufpt + uintptr(e2+int32(1)) + e2 = -int32(1) + } + } + } + /* The decimal point */ + if flag_dp != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('.') + } + /* "0" digits after the decimal point but before the first + ** significant digit of the number */ + if e2 < -int32(1) && precision > 0 { + nn2 = -int32(1) - e2 + if nn2 > precision { + nn2 = precision + } + libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(nn2)) + bufpt = bufpt + uintptr(nn2) + precision = precision - nn2 + } + /* Significant digits after the decimal point */ + if precision > 0 { + nn3 = (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn - j + if nn3 > precision { + nn3 = precision + } + if nn3 > 0 { + libc.Xmemcpy(tls, bufpt, (**(**TFpDecode)(__ccgo_up(bp + 72))).Fz+uintptr(j), libc.Uint64FromInt32(nn3)) + bufpt = bufpt + uintptr(nn3) + precision = precision - nn3 + } + if precision > 0 && !(flag_rtz != 0) { + libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(precision)) + bufpt = bufpt + uintptr(precision) + } + } + /* Remove trailing zeros and the "." if no digits follow the "." */ + if flag_rtz != 0 && flag_dp != 0 { + for int32(**(**int8)(__ccgo_up(bufpt + uintptr(-libc.Int32FromInt32(1))))) == int32('0') { + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = 0 + } + if int32(**(**int8)(__ccgo_up(bufpt + uintptr(-libc.Int32FromInt32(1))))) == int32('.') { + if flag_altform2 != 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('0') + } else { + bufpt = bufpt - 1 + v4 = bufpt + **(**int8)(__ccgo_up(v4)) = 0 + } + } + } + /* Add the "eNNN" suffix */ + if libc.Int32FromUint8(xtype) == int32(etEXP) { + exp = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = _aDigits[(*Tet_info)(unsafe.Pointer(infop)).Fcharset] + if exp < 0 { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('-') + exp = -exp + } else { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8('+') + } + if exp >= int32(100) { + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8(exp/libc.Int32FromInt32(100) + libc.Int32FromUint8('0')) /* 100's digit */ + exp = exp % int32(100) + } + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8(exp/libc.Int32FromInt32(10) + libc.Int32FromUint8('0')) /* 10's digit */ + v4 = bufpt + bufpt = bufpt + 1 + **(**int8)(__ccgo_up(v4)) = int8(exp%libc.Int32FromInt32(10) + libc.Int32FromUint8('0')) /* 1's digit */ + } + length = int32(int64(bufpt) - int64(zOut)) + if length < width { + nPad = int64(width - length) + if flag_leftjustify != 0 { + libc.Xmemset(tls, bufpt, int32(' '), libc.Uint64FromInt64(nPad)) + } else { + if !(flag_zeropad != 0) { + libc.Xmemmove(tls, zOut+uintptr(nPad), zOut, libc.Uint64FromInt32(length)) + libc.Xmemset(tls, zOut, int32(' '), libc.Uint64FromInt64(nPad)) + } else { + adj = libc.BoolInt32(int32(prefix) != 0) + libc.Xmemmove(tls, zOut+uintptr(nPad)+uintptr(adj), zOut+uintptr(adj), libc.Uint64FromInt32(length-adj)) + libc.Xmemset(tls, zOut+uintptr(adj), int32('0'), libc.Uint64FromInt64(nPad)) + } + } + length = width + } + if zExtra == uintptr(0) { + /* The result is being rendered directory into pAccum. This + ** is the command and fast case */ + **(**Tu32)(__ccgo_up(pAccum + 24)) += libc.Uint32FromInt32(length) + **(**int8)(__ccgo_up(zOut + uintptr(length))) = 0 + goto _1 + } else { + /* We were unable to render directly into pAccum because we + ** couldn't allocate sufficient memory. We need to memcpy() + ** the rendering (or some prefix thereof) into the output + ** buffer. */ + **(**int8)(__ccgo_up(bufpt)) = 0 + bufpt = zExtra + goto _45 + } + _34: + ; + if !(bArgList != 0) { + **(**int32)(__ccgo_up(libc.VaUintptr(&ap))) = libc.Int32FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _35: + ; + (**(**[70]int8)(__ccgo_up(bp)))[0] = int8('%') + bufpt = bp + length = int32(1) + goto _45 + _36: + ; + if bArgList != 0 { + bufpt = _getTextArg(tls, pArgList) + length = int32(1) + if bufpt != 0 { + v4 = bufpt + bufpt = bufpt + 1 + v2 = int32(**(**int8)(__ccgo_up(v4))) + c = v2 + (**(**[70]int8)(__ccgo_up(bp)))[0] = int8(v2) + if c&int32(0xc0) == int32(0xc0) { + for length < int32(4) && int32(**(**int8)(__ccgo_up(bufpt)))&int32(0xc0) == int32(0x80) { + v2 = length + length = length + 1 + v4 = bufpt + bufpt = bufpt + 1 + (**(**[70]int8)(__ccgo_up(bp)))[v2] = **(**int8)(__ccgo_up(v4)) + } + } + } else { + (**(**[70]int8)(__ccgo_up(bp)))[0] = 0 + } + } else { + ch = libc.VaUint32(&ap) + length = _sqlite3AppendOneUtf8Character(tls, bp, ch) + } + if precision > int32(1) { + nPrior = int64(1) + width = width - (precision - int32(1)) + if width > int32(1) && !(flag_leftjustify != 0) { + Xsqlite3_str_appendchar(tls, pAccum, width-int32(1), int8(' ')) + width = 0 + } + Xsqlite3_str_append(tls, pAccum, bp, length) + precision = precision - 1 + for precision > int32(1) { + if nPrior > int64(precision-int32(1)) { + nPrior = int64(precision - int32(1)) + } + nCopyBytes = int64(length) * nPrior + if _sqlite3StrAccumEnlargeIfNeeded(tls, pAccum, nCopyBytes) != 0 { + break + } + Xsqlite3_str_append(tls, pAccum, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText+uintptr(libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar)-nCopyBytes), int32(nCopyBytes)) + precision = int32(int64(precision) - nPrior) + nPrior = nPrior * int64(2) + } + } + bufpt = bp + flag_altform2 = uint8(1) + goto adjust_width_for_utf8 + _38: + ; + _37: + ; + if bArgList != 0 { + bufpt = _getTextArg(tls, pArgList) + xtype = uint8(etSTRING) + } else { + bufpt = libc.VaUintptr(&ap) + } + if bufpt == uintptr(0) { + bufpt = __ccgo_ts + 1704 + } else { + if libc.Int32FromUint8(xtype) == int32(etDYNSTRING) { + if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar == uint32(0) && (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc != 0 && width == 0 && precision < 0 && libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0 { + /* Special optimization for sqlite3_mprintf("%z..."): + ** Extend an existing memory allocation rather than creating + ** a new one. */ + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText = bufpt + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc = libc.Uint32FromInt32(_sqlite3DbMallocSize(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, bufpt)) + (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar = libc.Uint32FromInt32(int32(0x7fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, bufpt))) + v4 = pAccum + 29 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v4))) | libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) + length = 0 + goto _45 + } + zExtra = bufpt + } + } + if precision >= 0 { + if flag_altform2 != 0 { + /* Set length to the number of bytes needed in order to display + ** precision characters */ + z = bufpt + for { + v2 = precision + precision = precision - 1 + if !(v2 > 0 && **(**uint8)(__ccgo_up(z)) != 0) { + break + } + v4 = z + z = z + 1 + if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) >= int32(0xc0) { + for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { + z = z + 1 + } + } + } + length = int32(int64(z) - int64(bufpt)) + } else { + length = 0 + for { + if !(length < precision && **(**int8)(__ccgo_up(bufpt + uintptr(length))) != 0) { + break + } + goto _86 + _86: + ; + length = length + 1 + } + } + } else { + length = int32(0x7fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, bufpt)) + } + goto adjust_width_for_utf8 + adjust_width_for_utf8: + ; + if flag_altform2 != 0 && width > 0 { + /* Adjust width to account for extra bytes in UTF-8 characters */ + ii = length - int32(1) + for ii >= 0 { + v2 = ii + ii = ii - 1 + if int32(**(**int8)(__ccgo_up(bufpt + uintptr(v2))))&int32(0xc0) == int32(0x80) { + width = width + 1 + } + } + } + goto _45 + _41: + ; /* %q: Escape ' characters */ + _40: + ; /* %Q: Escape ' and enclose in '...' */ + _39: + ; + needQuote = 0 + if bArgList != 0 { + escarg = _getTextArg(tls, pArgList) + } else { + escarg = libc.VaUintptr(&ap) + } + if escarg == uintptr(0) { + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + v4 = __ccgo_ts + 1705 + } else { + v4 = __ccgo_ts + 1710 + } + escarg = v4 + } else { + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + needQuote = int32(1) + } + } + if libc.Int32FromUint8(xtype) == int32(etESCAPE_w) { + q = int8('"') + flag_alternateform = uint8(0) + } else { + q = int8('\'') + } + /* For %q, %Q, and %w, the precision is the number of bytes (or + ** characters if the ! flags is present) to use from the input. + ** Because of the extra quoting characters inserted, the number + ** of output characters may be larger than the precision. + */ + k = int64(precision) + v90 = libc.Int64FromInt32(0) + n1 = v90 + i = v90 + for { + if v12 = k != 0; v12 { + v54 = **(**int8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + } + if !(v12 && int32(v54) != 0) { + break + } + if int32(ch1) == int32(q) { + n1 = n1 + 1 + } + if flag_altform2 != 0 && int32(ch1)&int32(0xc0) == int32(0xc0) { + for int32(**(**int8)(__ccgo_up(escarg + uintptr(i+int64(1)))))&int32(0xc0) == int32(0x80) { + i = i + 1 + } + } + goto _89 + _89: + ; + i = i + 1 + k = k - 1 + } + if flag_alternateform != 0 { + /* For %#q, do unistr()-style backslash escapes for + ** all control characters, and for backslash itself. + ** For %#Q, do the same but only if there is at least + ** one control character. */ + nBack = 0 + nCtrl = 0 + k = 0 + for { + if !(k < i) { + break + } + if int32(**(**int8)(__ccgo_up(escarg + uintptr(k)))) == int32('\\') { + nBack = nBack + 1 + } else { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(escarg + uintptr(k)))) <= int32(0x1f) { + nCtrl = nCtrl + 1 + } + } + goto _93 + _93: + ; + k = k + 1 + } + if nCtrl != 0 || libc.Int32FromUint8(xtype) == int32(etESCAPE_q) { + n1 = n1 + (nBack + int64(5)*nCtrl) + if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { + n1 = n1 + int64(10) + needQuote = int32(2) + } + } else { + flag_alternateform = uint8(0) + } + } + n1 = n1 + (i + int64(3)) + if n1 > int64(SQLITE_PRINT_BUF_SIZE) { + v4 = _printfTempBuf(tls, pAccum, n1) + zExtra = v4 + bufpt = v4 + if bufpt == uintptr(0) { + return + } + } else { + bufpt = bp + } + j1 = 0 + if needQuote != 0 { + if needQuote == int32(2) { + libc.Xmemcpy(tls, bufpt+uintptr(j1), __ccgo_ts+1717, uint64(8)) + j1 = j1 + int64(8) + } else { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('\'') + } + } + k = i + if flag_alternateform != 0 { + i = 0 + for { + if !(i < k) { + break + } + v90 = j1 + j1 = j1 + 1 + v54 = **(**int8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = v54 + if int32(ch1) == int32(q) { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = ch1 + } else { + if int32(ch1) == int32('\\') { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('\\') + } else { + if libc.Int32FromUint8(libc.Uint8FromInt8(ch1)) <= int32(0x1f) { + **(**int8)(__ccgo_up(bufpt + uintptr(j1-int64(1)))) = int8('\\') + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('u') + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('0') + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('0') + v90 = j1 + j1 = j1 + 1 + if int32(ch1) >= int32(0x10) { + v2 = int32('1') + } else { + v2 = int32('0') + } + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8(v2) + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = **(**int8)(__ccgo_up(__ccgo_ts + 1726 + uintptr(int32(ch1)&int32(0xf)))) + } + } + } + goto _96 + _96: + ; + i = i + 1 + } + } else { + i = 0 + for { + if !(i < k) { + break + } + v90 = j1 + j1 = j1 + 1 + v54 = **(**int8)(__ccgo_up(escarg + uintptr(i))) + ch1 = v54 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = v54 + if int32(ch1) == int32(q) { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = ch1 + } + goto _107 + _107: + ; + i = i + 1 + } + } + if needQuote != 0 { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8('\'') + if needQuote == int32(2) { + v90 = j1 + j1 = j1 + 1 + **(**int8)(__ccgo_up(bufpt + uintptr(v90))) = int8(')') + } + } + **(**int8)(__ccgo_up(bufpt + uintptr(j1))) = 0 + length = int32(j1) + goto adjust_width_for_utf8 + _42: + ; + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_INTERNAL) == 0 { + return + } + if flag_alternateform != 0 { + /* %#T means an Expr pointer that uses Expr.u.zToken */ + pExpr = libc.VaUintptr(&ap) + if pExpr != 0 && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)) { + Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + _sqlite3RecordErrorOffsetOfExpr(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, pExpr) + } + } else { + /* %T means a Token pointer */ + pToken = libc.VaUintptr(&ap) + if pToken != 0 && (*TToken)(unsafe.Pointer(pToken)).Fn != 0 { + Xsqlite3_str_append(tls, pAccum, (*TToken)(unsafe.Pointer(pToken)).Fz, libc.Int32FromUint32((*TToken)(unsafe.Pointer(pToken)).Fn)) + _sqlite3RecordErrorByteOffset(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, (*TToken)(unsafe.Pointer(pToken)).Fz) + } + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _43: + ; + if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_INTERNAL) == 0 { + return + } + pItem = libc.VaUintptr(&ap) + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 && !(flag_altform2 != 0) { + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) + } else { + if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) == 0 && int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) == 0 && *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { + Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pItem + 72))) + Xsqlite3_str_append(tls, pAccum, __ccgo_ts+1743, int32(1)) + } + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzName) + } else { + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { + Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) + } else { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { /* Because of tag-20240424-1 */ + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_NestedFrom) != 0 { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1745, libc.VaList(bp+120, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + } else { + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_MultiValue) != 0 { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1755, libc.VaList(bp+120, *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(pItem)).Fu1)))) + } else { + Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1776, libc.VaList(bp+120, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + } + } + } + } + } + } + v2 = libc.Int32FromInt32(0) + width = v2 + length = v2 + goto _45 + _44: + ; + return + _45: + ; /* End switch over the format type */ + /* + ** The text of the conversion is pointed to by "bufpt" and is + ** "length" characters long. The field width is "width". Do + ** the output. Both length and width are in bytes, not characters, + ** at this point. If the "!" flag was present on string conversions + ** indicating that width and precision should be expressed in characters, + ** then the values have been translated prior to reaching this point. + */ + width = width - length + if width > 0 { + if !(flag_leftjustify != 0) { + Xsqlite3_str_appendchar(tls, pAccum, width, int8(' ')) + } + Xsqlite3_str_append(tls, pAccum, bufpt, length) + if flag_leftjustify != 0 { + Xsqlite3_str_appendchar(tls, pAccum, width, int8(' ')) + } + } else { + Xsqlite3_str_append(tls, pAccum, bufpt, length) + } + if zExtra != 0 { + _sqlite3DbFree(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, zExtra) + zExtra = uintptr(0) + } + goto _1 + _1: + ; + fmt = fmt + 1 + } /* End for loop over the format string */ +} + +// C documentation +// +// /* +// ** Checkpoint database zDb. +// */ +func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDb, rc int32 + _, _ = iDb, rc /* Schema to checkpoint */ + /* Initialize the output variables to -1 in case an error occurs. */ + if pnLog != 0 { + **(**int32)(__ccgo_up(pnLog)) = -int32(1) + } + if pnCkpt != 0 { + **(**int32)(__ccgo_up(pnCkpt)) = -int32(1) + } + if eMode < -int32(1) || eMode > int32(SQLITE_CHECKPOINT_TRUNCATE) { + /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint + ** mode: */ + return _sqlite3MisuseError(tls, int32(189780)) + } + Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + if zDb != 0 && **(**int8)(__ccgo_up(zDb)) != 0 { + iDb = _sqlite3FindDbName(tls, db, zDb) + } else { + iDb = libc.Int32FromInt32(SQLITE_MAX_ATTACHED) + libc.Int32FromInt32(2) /* This means process all schemas */ + } + if iDb < 0 { + rc = int32(SQLITE_ERROR) + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_ERROR), __ccgo_ts+25960, libc.VaList(bp+8, zDb)) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 + rc = _sqlite3Checkpoint(tls, db, iDb, eMode, pnLog, pnCkpt) + _sqlite3Error(tls, db, rc) + } + rc = _sqlite3ApiExit(tls, db, rc) + /* If there are no active statements, clear the interrupt flag at this + ** point. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex) + return rc +} + +// C documentation +// +// /* +// ** Append a single path element to the DbPath under construction +// */ +func _appendOnePathElement(tls *libc.TLS, pPath uintptr, zName uintptr, nName int32) { + bp := tls.Alloc(4256) + defer tls.Free(4256) + var got Tssize_t + var zIn, v2 uintptr + var v1 int32 + var _ /* buf at bp+0 */ Tstat + var _ /* zLnk at bp+144 */ [4098]int8 + _, _, _, _ = got, zIn, v1, v2 + if int32(**(**int8)(__ccgo_up(zName))) == int32('.') { + if nName == int32(1) { + return + } + if int32(**(**int8)(__ccgo_up(zName + 1))) == int32('.') && nName == int32(2) { + if (*TDbPath)(unsafe.Pointer(pPath)).FnUsed > int32(1) { + for { + v2 = pPath + 20 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + if !(int32(**(**int8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr(v1)))) != int32('/')) { + break + } + } + } + return + } + } + if (*TDbPath)(unsafe.Pointer(pPath)).FnUsed+nName+int32(2) >= (*TDbPath)(unsafe.Pointer(pPath)).FnOut { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = int32(SQLITE_ERROR) + return + } + v2 = pPath + 20 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr(v1))) = int8('/') + libc.Xmemcpy(tls, (*TDbPath)(unsafe.Pointer(pPath)).FzOut+uintptr((*TDbPath)(unsafe.Pointer(pPath)).FnUsed), zName, libc.Uint64FromInt32(nName)) + **(**int32)(__ccgo_up(pPath + 20)) += nName + if (*TDbPath)(unsafe.Pointer(pPath)).Frc == SQLITE_OK { + **(**int8)(__ccgo_up((*TDbPath)(unsafe.Pointer(pPath)).FzOut + uintptr((*TDbPath)(unsafe.Pointer(pPath)).FnUsed))) = 0 + zIn = (*TDbPath)(unsafe.Pointer(pPath)).FzOut + if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(27)].FpCurrent})))(tls, zIn, bp) != 0 { + if **(**int32)(__ccgo_up(libc.X__errno_location(tls))) != int32(ENOENT) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47142)), __ccgo_ts+3740, zIn, int32(47142)) + } + } else { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFLNK) { + v2 = pPath + 4 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + if v1 > int32(SQLITE_MAX_SYMLINK) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _sqlite3CantopenError(tls, int32(47148)) + return + } + got = (*(*func(*libc.TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(26)].FpCurrent})))(tls, zIn, bp+144, libc.Uint64FromInt64(4098)-libc.Uint64FromInt32(2)) + if got <= 0 || got >= libc.Int64FromInt64(4098)-libc.Int64FromInt32(2) { + (*TDbPath)(unsafe.Pointer(pPath)).Frc = _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47153)), __ccgo_ts+3731, zIn, int32(47153)) + return + } + (**(**[4098]int8)(__ccgo_up(bp + 144)))[got] = 0 + if int32((**(**[4098]int8)(__ccgo_up(bp + 144)))[0]) == int32('/') { + (*TDbPath)(unsafe.Pointer(pPath)).FnUsed = 0 + } else { + **(**int32)(__ccgo_up(pPath + 20)) -= nName + int32(1) + } + _appendAllPathElements(tls, pPath, bp+144) + } + } + } +} + +// C documentation +// +// /* +// ** Generate code to construct the Index object for an automatic index +// ** and to set up the WhereLevel object pLevel so that the code generator +// ** makes use of the automatic index. +// */ +func _constructAutomaticIndex(tls *libc.TLS, pParse uintptr, pWC uintptr, notReady TBitmask, pLevel uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var addrCounter, addrInit, addrTop, i, iCol, iCol1, iContinue, mxBitCol, n, nKeyCol, regBase, regRecord, regYield, v3 int32 + var cMask, cMask1, extraCols, idxCols TBitmask + var pColl, pExpr, pIdx, pLoop, pPartial, pSrc, pSubq, pTabList, pTable, pTerm, pWCEnd, pX, v, v10 uintptr + var sentWarning, useBloomFilter Tu8 + var v2 uint64 + var v4 Tu16 + var _ /* zNotUsed at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCounter, addrInit, addrTop, cMask, cMask1, extraCols, i, iCol, iCol1, iContinue, idxCols, mxBitCol, n, nKeyCol, pColl, pExpr, pIdx, pLoop, pPartial, pSrc, pSubq, pTabList, pTable, pTerm, pWCEnd, pX, regBase, regRecord, regYield, sentWarning, useBloomFilter, v, v10, v2, v3, v4 /* Bitmap of additional columns */ + sentWarning = uint8(0) /* True if a warning has been issued */ + useBloomFilter = uint8(0) /* True to also add a Bloom filter */ + pPartial = uintptr(0) /* Partial Index Expression */ + iContinue = 0 /* The FROM clause term to get the next index */ + addrCounter = 0 /* Array of registers where record is assembled */ + /* Generate code to skip over the creation and initialization of the + ** transient index on 2nd and subsequent iterations of the loop. */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + addrInit = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + /* Count the number of columns that will be added to the index + ** and used to match WHERE clause constraints */ + nKeyCol = 0 + pTabList = (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpTabList + pSrc = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + pTable = (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab + pWCEnd = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)*56 + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + idxCols = uint64(0) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + for { + if !(pTerm < pWCEnd) { + break + } + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + /* Make the automatic index a partial index if there are terms in the + ** WHERE clause (or the ON clause of a LEFT join) that constrain which + ** rows of the target table (pSrc) that can be used. */ + if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VIRTUAL) == 0 && _sqlite3ExprIsSingleTableConstraint(tls, pExpr, pTabList, libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom), 0) != 0 { + pPartial = _sqlite3ExprAnd(tls, pParse, pPartial, _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0)) + } + if _termCanDriveIndex(tls, pTerm, pSrc, notReady) != 0 { + iCol = (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn + if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v2 = libc.Uint64FromInt32(1) << (libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1)) + } else { + v2 = libc.Uint64FromInt32(1) << iCol + } + cMask = v2 + if !(sentWarning != 0) { + Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_WARNING)|libc.Int32FromInt32(1)<= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + extraCols = extraCols | libc.Uint64FromInt32(1)<<(libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1)) + break + } + if idxCols&(libc.Uint64FromInt32(1)<= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { + v2 = libc.Uint64FromInt32(1) << (libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1)) + } else { + v2 = libc.Uint64FromInt32(1) << iCol1 + } + cMask1 = v2 + if idxCols&cMask1 == uint64(0) { + pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + idxCols = idxCols | cMask1 + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) = int16((*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn) + pColl = _sqlite3ExprCompareCollSeq(tls, pParse, pX) + /* TH3 collate01.800 */ + if pColl != 0 { + v10 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName + } else { + v10 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(n)*8)) = v10 + n = n + 1 + if (*TExpr)(unsafe.Pointer(pX)).FpLeft != uintptr(0) && int32(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft)) != int32(SQLITE_AFF_TEXT) { + /* TUNING: only use a Bloom filter on an automatic index + ** if one or more key columns has the ability to hold numeric + ** values, since strings all have the same hash in the Bloom + ** filter implementation and hence a Bloom filter on a text column + ** is not usually helpful. */ + useBloomFilter = uint8(1) + } + } + } + goto _8 + _8: + ; + pTerm += 56 + } + /* Add additional columns needed to make the automatic index into + ** a covering index */ + i = 0 + for { + if !(i < mxBitCol) { + break + } + if extraCols&(libc.Uint64FromInt32(1)<>6) != 0 { + pSubq = *(*uintptr)(unsafe.Pointer(pSrc + 72)) + regYield = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn + addrCounter = _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, 0) + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) + addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), regYield) + } else { + addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt) + } + if pPartial != 0 { + iContinue = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, int32(SQLITE_JUMPIFNULL)) + **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_PARTIALIDX) + } + regRecord = _sqlite3GetTempReg(tls, pParse) + regBase = _sqlite3GenerateIndexKey(tls, pParse, pIdx, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, regRecord, 0, uintptr(0), uintptr(0), 0) + if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0, regBase, libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq)) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) + if pPartial != 0 { + _sqlite3VdbeResolveLabel(tls, v, iContinue) + } + if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40>>6) != 0 { + _sqlite3VdbeChangeP2(tls, v, addrCounter, regBase+n) + _translateColumnToCopy(tls, pParse, addrTop, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FregResult, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + _sqlite3VdbeGoto(tls, v, addrTop) + libc.SetBitFieldPtr32Uint32(pSrc+24+4, libc.Uint32FromInt32(0), 6, 0x40) + _sqlite3VdbeJumpHere(tls, v, addrTop) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, addrTop+int32(1)) + _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_STMTSTATUS_AUTOINDEX)) + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + _sqlite3VdbeJumpHere(tls, v, addrTop) + } + } + _sqlite3ReleaseTempReg(tls, pParse, regRecord) + /* Jump here when skipping the initialization */ + _sqlite3VdbeJumpHere(tls, v, addrInit) + goto end_auto_index_create +end_auto_index_create: + ; + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPartial) +} + +// C documentation +// +// /* +// ** Fill the InitData structure with an error message that indicates +// ** that the database is corrupt. +// */ +func _corruptSchema(tls *libc.TLS, pData uintptr, azObj uintptr, zExtra uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var db, z, zObj, v1 uintptr + _, _, _, _ = db, z, zObj, v1 + db = (*TInitData)(unsafe.Pointer(pData)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (*TInitData)(unsafe.Pointer(pData)).Frc = int32(SQLITE_NOMEM) + } else { + if **(**uintptr)(__ccgo_up((*TInitData)(unsafe.Pointer(pData)).FpzErrMsg)) != uintptr(0) { + /* A error message has already been generated. Do not overwrite it */ + } else { + if (*TInitData)(unsafe.Pointer(pData)).FmInitFlags&libc.Uint32FromInt32(libc.Int32FromInt32(INITFLAG_AlterMask)) != 0 { + **(**uintptr)(__ccgo_up((*TInitData)(unsafe.Pointer(pData)).FpzErrMsg)) = _sqlite3MPrintf(tls, db, __ccgo_ts+20023, libc.VaList(bp+8, **(**uintptr)(__ccgo_up(azObj)), **(**uintptr)(__ccgo_up(azObj + 1*8)), _azAlterType[(*TInitData)(unsafe.Pointer(pData)).FmInitFlags&uint32(INITFLAG_AlterMask)-uint32(1)], zExtra)) + (*TInitData)(unsafe.Pointer(pData)).Frc = int32(SQLITE_ERROR) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_WriteSchema) != 0 { + (*TInitData)(unsafe.Pointer(pData)).Frc = _sqlite3CorruptError(tls, int32(147813)) + } else { + if **(**uintptr)(__ccgo_up(azObj + 1*8)) != 0 { + v1 = **(**uintptr)(__ccgo_up(azObj + 1*8)) + } else { + v1 = __ccgo_ts + 5259 + } + zObj = v1 + z = _sqlite3MPrintf(tls, db, __ccgo_ts+20051, libc.VaList(bp+8, zObj)) + if zExtra != 0 && **(**int8)(__ccgo_up(zExtra)) != 0 { + z = _sqlite3MPrintf(tls, db, __ccgo_ts+20082, libc.VaList(bp+8, z, zExtra)) + } + **(**uintptr)(__ccgo_up((*TInitData)(unsafe.Pointer(pData)).FpzErrMsg)) = z + (*TInitData)(unsafe.Pointer(pData)).Frc = _sqlite3CorruptError(tls, int32(147820)) + } + } + } + } +} + +// C documentation +// +// /* +// ** Generate a CREATE TABLE statement appropriate for the given +// ** table. Memory to hold the text of the statement is obtained +// ** from sqliteMalloc() and must be freed by the calling function. +// */ +func _createTableStmt(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, len1, v2 int32 + var n Ti64 + var pCol, zEnd, zSep, zSep2, zStmt, zType uintptr + var _ /* k at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _ = i, len1, n, pCol, zEnd, zSep, zSep2, zStmt, zType, v2 + n = 0 + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + i = libc.Int32FromInt32(0) + for { + if !(i < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + n = n + (_identLength(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + int64(5)) + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + n = n + _identLength(tls, (*TTable)(unsafe.Pointer(p)).FzName) + if n < int64(50) { + zSep = __ccgo_ts + 1704 + zSep2 = __ccgo_ts + 14346 + zEnd = __ccgo_ts + 5257 + } else { + zSep = __ccgo_ts + 14348 + zSep2 = __ccgo_ts + 14352 + zEnd = __ccgo_ts + 14357 + } + n = n + int64(int32(35)+int32(6)*int32((*TTable)(unsafe.Pointer(p)).FnCol)) + zStmt = _sqlite3DbMallocRaw(tls, uintptr(0), libc.Uint64FromInt64(n)) + if zStmt == uintptr(0) { + _sqlite3OomFault(tls, db) + return uintptr(0) + } + libc.Xmemcpy(tls, zStmt, __ccgo_ts+14360, uint64(13)) + **(**int32)(__ccgo_up(bp)) = int32(13) + _identPut(tls, zStmt, bp, (*TTable)(unsafe.Pointer(p)).FzName) + v2 = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(zStmt + uintptr(v2))) = int8('(') + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + i = libc.Int32FromInt32(0) + for { + if !(i < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + len1 = _sqlite3Strlen30(tls, zSep) + libc.Xmemcpy(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zSep, libc.Uint64FromInt32(len1)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + len1 + zSep = zSep2 + _identPut(tls, zStmt, bp, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + zType = _azType1[int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity)-int32(SQLITE_AFF_BLOB)] + len1 = _sqlite3Strlen30(tls, zType) + libc.Xmemcpy(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zType, libc.Uint64FromInt32(len1)) + **(**int32)(__ccgo_up(bp)) = **(**int32)(__ccgo_up(bp)) + len1 + goto _3 + _3: + ; + i = i + 1 + pCol += 16 + } + len1 = _sqlite3Strlen30(tls, zEnd) + libc.Xmemcpy(tls, zStmt+uintptr(**(**int32)(__ccgo_up(bp))), zEnd, libc.Uint64FromInt32(len1+int32(1))) + return zStmt +} + +// C documentation +// +// /* +// ** The first argument points to a nul-terminated string containing a +// ** list of space separated integers. Read the first nOut of these into +// ** the array aOut[]. +// */ +func _decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, aLog uintptr, pIndex uintptr) { + var c, i, sz, v2 int32 + var v TtRowcnt + var z uintptr + _, _, _, _, _, _ = c, i, sz, v, z, v2 + z = zIntArray + if z == uintptr(0) { + z = __ccgo_ts + 1704 + } + i = 0 + for { + if !(**(**int8)(__ccgo_up(z)) != 0 && i < nOut) { + break + } + v = uint64(0) + for { + v2 = int32(**(**int8)(__ccgo_up(z))) + c = v2 + if !(v2 >= int32('0') && c <= int32('9')) { + break + } + v = v*uint64(10) + libc.Uint64FromInt32(c) - uint64('0') + z = z + 1 + } + if aOut != 0 { + **(**TtRowcnt)(__ccgo_up(aOut + uintptr(i)*8)) = v + } + if aLog != 0 { + **(**TLogEst)(__ccgo_up(aLog + uintptr(i)*2)) = _sqlite3LogEst(tls, v) + } + if int32(**(**int8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + if pIndex != 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 2, 0x4) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 6, 0x40) + for **(**int8)(__ccgo_up(z)) != 0 { + if Xsqlite3_strglob(tls, __ccgo_ts+13052, z) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 2, 0x4) + } else { + if Xsqlite3_strglob(tls, __ccgo_ts+13063, z) == 0 { + sz = _sqlite3Atoi(tls, z+uintptr(3)) + if sz < int32(2) { + sz = int32(2) + } + (*TIndex)(unsafe.Pointer(pIndex)).FszIdxRow = _sqlite3LogEst(tls, libc.Uint64FromInt32(sz)) + } else { + if Xsqlite3_strglob(tls, __ccgo_ts+13073, z) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 6, 0x40) + } + } + } + for int32(**(**int8)(__ccgo_up(z))) != 0 && int32(**(**int8)(__ccgo_up(z))) != int32(' ') { + z = z + 1 + } + for int32(**(**int8)(__ccgo_up(z))) == int32(' ') { + z = z + 1 + } + } + } +} + +// C documentation +// +// /* +// ** An SQL user-function registered to do the work of an DETACH statement. The +// ** three arguments to the function come directly from a detach statement: +// ** +// ** DETACH DATABASE x +// ** +// ** SELECT sqlite_detach(x) +// */ +func _detachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var db, pDb, pEntry, pTrig, zName uintptr + var i int32 + var _ /* zErr at bp+0 */ [128]int8 + _, _, _, _, _, _ = db, i, pDb, pEntry, pTrig, zName + zName = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + db = Xsqlite3_context_db_handle(tls, context) + pDb = uintptr(0) + _ = NotUsed + if zName == uintptr(0) { + zName = __ccgo_ts + 1704 + } + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32 + if (*TDb)(unsafe.Pointer(pDb)).FpBt == uintptr(0) { + goto _1 + } + if _sqlite3DbIsNamed(tls, db, i, zName) != 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i >= (*Tsqlite3)(unsafe.Pointer(db)).FnDb { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13442, libc.VaList(bp+136, zName)) + goto detach_error + } + if i < int32(2) { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13463, libc.VaList(bp+136, zName)) + goto detach_error + } + if _sqlite3BtreeTxnState(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) != SQLITE_TXN_NONE || _sqlite3BtreeIsInBackup(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) != 0 { + Xsqlite3_snprintf(tls, int32(128), bp, __ccgo_ts+13489, libc.VaList(bp+136, zName)) + goto detach_error + } + /* If any TEMP triggers reference the schema being detached, move those + ** triggers to reference the TEMP schema itself. */ + pEntry = (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema + 56)).Ffirst + for pEntry != 0 { + pTrig = (*THashElem)(unsafe.Pointer(pEntry)).Fdata + if (*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema == (*TDb)(unsafe.Pointer(pDb)).FpSchema { + (*TTrigger)(unsafe.Pointer(pTrig)).FpTabSchema = (*TTrigger)(unsafe.Pointer(pTrig)).FpSchema + } + pEntry = (*THashElem)(unsafe.Pointer(pEntry)).Fnext + } + _sqlite3BtreeClose(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + (*TDb)(unsafe.Pointer(pDb)).FpBt = uintptr(0) + (*TDb)(unsafe.Pointer(pDb)).FpSchema = uintptr(0) + _sqlite3CollapseDatabaseArray(tls, db) + return + goto detach_error +detach_error: + ; + Xsqlite3_result_error(tls, context, bp, -int32(1)) +} + +// C documentation +// +// /* +// ** The input to this routine is an WhereTerm structure with only the +// ** "pExpr" field filled in. The job of this routine is to analyze the +// ** subexpression and populate all the other fields of the WhereTerm +// ** structure. +// ** +// ** If the expression is of the form " X" it gets commuted +// ** to the standard form of "X ". +// ** +// ** If the expression is of the form "X Y" where both X and Y are +// ** columns, then the original expression is unchanged and a new virtual +// ** term of the form "Y X" is added to the WHERE clause and +// ** analyzed separately. The original term is marked with TERM_COPIED +// ** and the new term is marked with TERM_DYNAMIC (because it's pExpr +// ** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it +// ** is a commuted copy of a prior term.) The original term has nChild=1 +// ** and the copy has idxParent set to the index of the original term. +// */ +func _exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var c, v12 int8 + var db, pC, pDup, pExpr, pLeft, pLeft1, pLeft2, pLeft3, pList, pMaskSet, pNew, pNew1, pNewExpr, pNewExpr1, pNewExpr11, pNewExpr2, pNewExpr21, pNewTerm, pNewTerm1, pParse, pRight, pRight1, pStr2, pTerm, pWInfo, t, zCollSeqName, v1 uintptr + var eExtraOp, opMask, wtFlags Tu16 + var extraRight, prereqAll, prereqColumn, prereqExpr, prereqLeft, x TBitmask + var i, i1, i2, i3, idxNew, idxNew1, idxNew11, idxNew2, idxNew21, idxNew3, idxNew4, idxNew5, nLeft, op, res, v2 int32 + var v15 bool + var _ /* aiCurCol at bp+24 */ [2]int32 + var _ /* eOp2 at bp+16 */ uint8 + var _ /* isComplete at bp+8 */ int32 + var _ /* noCase at bp+12 */ int32 + var _ /* pLeft at bp+40 */ uintptr + var _ /* pRight at bp+32 */ uintptr + var _ /* pStr1 at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, db, eExtraOp, extraRight, i, i1, i2, i3, idxNew, idxNew1, idxNew11, idxNew2, idxNew21, idxNew3, idxNew4, idxNew5, nLeft, op, opMask, pC, pDup, pExpr, pLeft, pLeft1, pLeft2, pLeft3, pList, pMaskSet, pNew, pNew1, pNewExpr, pNewExpr1, pNewExpr11, pNewExpr2, pNewExpr21, pNewTerm, pNewTerm1, pParse, pRight, pRight1, pStr2, pTerm, pWInfo, prereqAll, prereqColumn, prereqExpr, prereqLeft, res, t, wtFlags, x, zCollSeqName, v1, v12, v15, v2 + pWInfo = (*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo /* Prerequisites of pExpr */ + extraRight = uint64(0) /* Extra dependencies on LEFT JOIN */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* RHS of LIKE/GLOB operator */ + **(**int32)(__ccgo_up(bp + 8)) = 0 /* RHS of LIKE/GLOB ends with wildcard */ + **(**int32)(__ccgo_up(bp + 12)) = 0 /* Top-level operator. pExpr->op */ + pParse = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpParse /* Parsing context */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database connection */ + **(**uint8)(__ccgo_up(bp + 16)) = uint8(0) /* Number of elements on left side vector */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + pMaskSet = pWInfo + 592 + pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr + /* Because malloc() has not failed */ + (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 0 + prereqLeft = _sqlite3WhereExprUsage(tls, pMaskSet, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + if op == int32(TK_IN) { + if _sqlite3ExprCheckIN(tls, pParse, pExpr) != 0 { + return + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } else { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _sqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } + prereqAll = prereqLeft | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight + } else { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = _sqlite3WhereExprUsage(tls, pMaskSet, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft == uintptr(0) || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_xIsSelect)|libc.Int32FromInt32(EP_IfNullRow)) != uint32(0) || *(*uintptr)(unsafe.Pointer(pExpr + 32)) != uintptr(0) { + prereqAll = _sqlite3WhereExprUsageNN(tls, pMaskSet, pExpr) + } else { + prereqAll = prereqLeft | (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight + } + } + if (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect != 0 { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_VARSELECT)) + } + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)|libc.Int32FromInt32(EP_InnerON)) != uint32(0) { + x = _sqlite3WhereGetMask(tls, pMaskSet, *(*int32)(unsafe.Pointer(pExpr + 52))) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) { + prereqAll = prereqAll | x + extraRight = x - uint64(1) /* ON clause terms may not be used with an index + ** on left table of a LEFT JOIN. Ticket #3015 */ + } else { + if prereqAll>>libc.Int32FromInt32(1) >= x { + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_InnerON)) + } + } + } + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = prereqAll + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = -int32(1) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FiParent = -int32(1) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(0) + if _allowedOp(tls, op) != 0 { + pLeft = _sqlite3ExprSkipCollate(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + pRight = _sqlite3ExprSkipCollate(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&prereqLeft == uint64(0) { + v2 = int32(WO_ALL) + } else { + v2 = int32(WO_EQUIV) + } + opMask = libc.Uint16FromInt32(v2) + if (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField > 0 { + pLeft = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 32)) + 8 + uintptr((*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField-int32(1))*32))).FpExpr + } + if _exprMightBeIndexed(tls, pSrc, bp+24, pLeft, op) != 0 { + (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = (**(**[2]int32)(__ccgo_up(bp + 24)))[0] + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FleftColumn = (**(**[2]int32)(__ccgo_up(bp + 24)))[int32(1)] + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = libc.Uint16FromInt32(libc.Int32FromUint16(_operatorMask(tls, op)) & libc.Int32FromUint16(opMask)) + } + if op == int32(TK_IS) { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_IS)) + } + if pRight != 0 && _exprMightBeIndexed(tls, pSrc, bp+24, pRight, op) != 0 && !((*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != libc.Uint32FromInt32(0)) { + eExtraOp = uint16(0) /* Extra bits for pNew->eOperator */ + if (*TWhereTerm)(unsafe.Pointer(pTerm)).FleftCursor >= 0 { + pDup = _sqlite3ExprDup(tls, db, pExpr, 0) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db, pDup) + return + } + idxNew = _whereClauseInsert(tls, pWC, pDup, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + if idxNew == 0 { + return + } + pNew = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*56 + _markTermAsChild(tls, pWC, idxNew, idxTerm) + if op == int32(TK_IS) { + v1 = pNew + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_IS)) + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + if _termIsEquivalence(tls, pParse, pDup, (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList) != 0 { + v1 = pTerm + 20 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(WO_EQUIV)) + eExtraOp = uint16(WO_EQUIV) + } + } else { + pDup = pExpr + pNew = pTerm + } + v1 = pNew + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromUint16(_exprCommute(tls, pParse, pDup))) + (*TWhereTerm)(unsafe.Pointer(pNew)).FleftCursor = (**(**[2]int32)(__ccgo_up(bp + 24)))[0] + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNew + 32))).FleftColumn = (**(**[2]int32)(__ccgo_up(bp + 24)))[int32(1)] + (*TWhereTerm)(unsafe.Pointer(pNew)).FprereqRight = prereqLeft | extraRight + (*TWhereTerm)(unsafe.Pointer(pNew)).FprereqAll = prereqAll + (*TWhereTerm)(unsafe.Pointer(pNew)).FeOperator = libc.Uint16FromInt32((libc.Int32FromUint16(_operatorMask(tls, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pDup)).Fop))) + libc.Int32FromUint16(eExtraOp)) & libc.Int32FromUint16(opMask)) + } else { + if op == int32(TK_ISNULL) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) && 0 == _sqlite3ExprCanBeNull(tls, pLeft) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_TRUEFALSE) /* See tag-20230504-1 */ + *(*uintptr)(unsafe.Pointer(pExpr + 8)) = __ccgo_ts + 8183 + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_IsFalse)) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = uint64(0) + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(0) + } + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_BETWEEN) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + i = 0 + for { + if !(i < int32(2)) { + break + } + pNewExpr = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8(_ops[i]), _sqlite3ExprDup(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, 0), _sqlite3ExprDup(tls, db, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr, 0)) + _transferJoinMarkings(tls, pNewExpr, pExpr) + idxNew1 = _whereClauseInsert(tls, pWC, pNewExpr, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + _exprAnalyze(tls, pSrc, pWC, idxNew1) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + _markTermAsChild(tls, pWC, idxNew1, idxTerm) + goto _8 + _8: + ; + i = i + 1 + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_OR) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != libc.Uint32FromInt32(0)) { + _exprAnalyzeOrTerm(tls, pSrc, pWC, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL) { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == int32(TK_COLUMN) && int32((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).FiColumn) >= 0 && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != libc.Uint32FromInt32(0)) { + pLeft1 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pNewExpr1 = _sqlite3PExpr(tls, pParse, int32(TK_GT), _sqlite3ExprDup(tls, db, pLeft1, 0), _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0)) + idxNew2 = _whereClauseInsert(tls, pWC, pNewExpr1, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC)|libc.Int32FromInt32(TERM_VNULL))) + if idxNew2 != 0 { + pNewTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew2)*56 + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = uint64(0) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*TExpr)(unsafe.Pointer(pLeft1)).FiTable + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNewTerm + 32))).FleftColumn = int32((*TExpr)(unsafe.Pointer(pLeft1)).FiColumn) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = libc.Uint16FromInt32(libc.Int32FromInt32(WO_EQ) << (libc.Int32FromInt32(TK_GT) - libc.Int32FromInt32(TK_EQ))) + _markTermAsChild(tls, pWC, idxNew2, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + (*TWhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll + } + } + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_FUNCTION) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) && _isLikeOrGlob(tls, pParse, pExpr, bp, bp+8, bp+12) != 0 { /* Name of collating sequence */ + wtFlags = libc.Uint16FromInt32(libc.Int32FromInt32(TERM_LIKEOPT) | libc.Int32FromInt32(TERM_VIRTUAL) | libc.Int32FromInt32(TERM_DYNAMIC)) + pLeft2 = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr + pStr2 = _sqlite3ExprDup(tls, db, **(**uintptr)(__ccgo_up(bp)), 0) + /* Convert the lower bound to upper-case and the upper bound to + ** lower-case (upper-case is less than lower-case in ASCII) so that + ** the range constraints also work for BLOBs + */ + if **(**int32)(__ccgo_up(bp + 12)) != 0 && !((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_LIKE)) + i1 = 0 + for { + v12 = **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 8)) + uintptr(i1))) + c = v12 + if !(int32(v12) != 0) { + break + } + **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)) + 8)) + uintptr(i1))) = int8(int32(c) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(c)]) & libc.Int32FromInt32(0x20))) + **(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pStr2 + 8)) + uintptr(i1))) = libc.Int8FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(c)]) + goto _11 + _11: + ; + i1 = i1 + 1 + } + } + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { /* Last character before the first wildcard */ + pC = *(*uintptr)(unsafe.Pointer(pStr2 + 8)) + uintptr(_sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pStr2 + 8)))-int32(1)) + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + /* The point is to increment the last character before the first + ** wildcard. But if we increment '@', that will push it into the + ** alphabetic range where case conversions will mess up the + ** inequality. To avoid this, make sure to also run the full + ** LIKE on all candidate expressions by clearing the isComplete flag + */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pC))) == libc.Int32FromUint8('A')-libc.Int32FromInt32(1) { + **(**int32)(__ccgo_up(bp + 8)) = 0 + } + **(**Tu8)(__ccgo_up(pC)) = _sqlite3UpperToLower[**(**Tu8)(__ccgo_up(pC))] + } + /* Increment the value of the last utf8 character in the prefix. */ + for libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pC))) == int32(0xBF) && pC > *(*uintptr)(unsafe.Pointer(pStr2 + 8)) { + **(**Tu8)(__ccgo_up(pC)) = uint8(0x80) + pC = pC - 1 + } + /* isLikeOrGlob() guarantees this */ + **(**Tu8)(__ccgo_up(pC)) = **(**Tu8)(__ccgo_up(pC)) + 1 + } + if **(**int32)(__ccgo_up(bp + 12)) != 0 { + v1 = __ccgo_ts + 23876 + } else { + v1 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + zCollSeqName = v1 + pNewExpr11 = _sqlite3ExprDup(tls, db, pLeft2, 0) + pNewExpr11 = _sqlite3PExpr(tls, pParse, int32(TK_GE), _sqlite3ExprAddCollateString(tls, pParse, pNewExpr11, zCollSeqName), **(**uintptr)(__ccgo_up(bp))) + _transferJoinMarkings(tls, pNewExpr11, pExpr) + idxNew11 = _whereClauseInsert(tls, pWC, pNewExpr11, wtFlags) + pNewExpr21 = _sqlite3ExprDup(tls, db, pLeft2, 0) + pNewExpr21 = _sqlite3PExpr(tls, pParse, int32(TK_LT), _sqlite3ExprAddCollateString(tls, pParse, pNewExpr21, zCollSeqName), pStr2) + _transferJoinMarkings(tls, pNewExpr21, pExpr) + idxNew21 = _whereClauseInsert(tls, pWC, pNewExpr21, wtFlags) + _exprAnalyze(tls, pSrc, pWC, idxNew11) + _exprAnalyze(tls, pSrc, pWC, idxNew21) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + if **(**int32)(__ccgo_up(bp + 8)) != 0 { + _markTermAsChild(tls, pWC, idxNew11, idxTerm) + _markTermAsChild(tls, pWC, idxNew21, idxTerm) + } + } + } + } + } + } + /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create + ** new terms for each component comparison - "a = ?" and "b = ?". The + ** new terms completely replace the original vector comparison, which is + ** no longer used. + ** + ** This is only required if at least one side of the comparison operation + ** is not a sub-select. + ** + ** tag-20220128a + */ + if v15 = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_EQ) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IS); v15 { + v2 = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + nLeft = v2 + } + if v15 && v2 > int32(1) && _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) == nLeft && ((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags&uint32(EP_xIsSelect) == uint32(0) || (*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpRight)).Fflags&uint32(EP_xIsSelect) == uint32(0)) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + i2 = 0 + for { + if !(i2 < nLeft) { + break + } + pLeft3 = _sqlite3ExprForVectorField(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, i2, nLeft) + pRight1 = _sqlite3ExprForVectorField(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, i2, nLeft) + pNew1 = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop), pLeft3, pRight1) + _transferJoinMarkings(tls, pNew1, pExpr) + idxNew3 = _whereClauseInsert(tls, pWC, pNew1, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_DYNAMIC)|libc.Int32FromInt32(TERM_SLICE))) + _exprAnalyze(tls, pSrc, pWC, idxNew3) + goto _16 + _16: + ; + i2 = i2 + 1 + } + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | (libc.Int32FromInt32(TERM_CODED) | libc.Int32FromInt32(TERM_VIRTUAL))) /* Disable the original */ + (*TWhereTerm)(unsafe.Pointer(pTerm)).FeOperator = uint16(WO_ROWVAL) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_IN) && (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pTerm + 32))).FiField == 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == int32(TK_VECTOR) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && ((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpPrior == uintptr(0) || (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselFlags&uint32(SF_Values) != 0) && (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpWin == uintptr(0) && libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + i3 = 0 + for { + if !(i3 < _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft)) { + break + } + idxNew4 = _whereClauseInsert(tls, pWC, pExpr, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_SLICE))) + *(*int32)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew4)*56 + 32 + 4)) = i3 + int32(1) + _exprAnalyze(tls, pSrc, pWC, idxNew4) + _markTermAsChild(tls, pWC, idxNew4, idxTerm) + goto _18 + _18: + ; + i3 = i3 + 1 + } + } else { + if libc.Int32FromUint8((*TWhereClause)(unsafe.Pointer(pWC)).Fop) == int32(TK_AND) { + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 40)) = uintptr(0) + res = _isAuxiliaryVtabOperator(tls, db, pExpr, bp+16, bp+40, bp+32) + for { + v2 = res + res = res - 1 + if !(v2 > 0) { + break + } + prereqExpr = _sqlite3WhereExprUsage(tls, pMaskSet, **(**uintptr)(__ccgo_up(bp + 32))) + prereqColumn = _sqlite3WhereExprUsage(tls, pMaskSet, **(**uintptr)(__ccgo_up(bp + 40))) + if prereqExpr&prereqColumn == uint64(0) { + pNewExpr2 = _sqlite3PExpr(tls, pParse, int32(TK_MATCH), uintptr(0), _sqlite3ExprDup(tls, db, **(**uintptr)(__ccgo_up(bp + 32)), 0)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) != uint32(0) && pNewExpr2 != 0 { + **(**Tu32)(__ccgo_up(pNewExpr2 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_OuterON)) + *(*int32)(unsafe.Pointer(pNewExpr2 + 52)) = *(*int32)(unsafe.Pointer(pExpr + 52)) + } + idxNew5 = _whereClauseInsert(tls, pWC, pNewExpr2, libc.Uint16FromInt32(libc.Int32FromInt32(TERM_VIRTUAL)|libc.Int32FromInt32(TERM_DYNAMIC))) + pNewTerm1 = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew5)*56 + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FprereqRight = prereqExpr | extraRight + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FleftCursor = (*TExpr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 40)))).FiTable + (*(*struct { + FleftColumn int32 + FiField int32 + })(unsafe.Pointer(pNewTerm1 + 32))).FleftColumn = int32((*TExpr)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 40)))).FiColumn) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FeOperator = uint16(WO_AUX) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FeMatchOp = **(**uint8)(__ccgo_up(bp + 16)) + _markTermAsChild(tls, pWC, idxNew5, idxTerm) + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + v1 = pTerm + 18 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(TERM_COPIED)) + (*TWhereTerm)(unsafe.Pointer(pNewTerm1)).FprereqAll = (*TWhereTerm)(unsafe.Pointer(pTerm)).FprereqAll + } + t = **(**uintptr)(__ccgo_up(bp + 40)) + **(**uintptr)(__ccgo_up(bp + 40)) = **(**uintptr)(__ccgo_up(bp + 32)) + **(**uintptr)(__ccgo_up(bp + 32)) = t + } + } + } + } + /* Prevent ON clause terms of a LEFT JOIN from being used to drive + ** an index for tables to the left of the join. + */ + pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*56 + **(**TBitmask)(__ccgo_up(pTerm + 40)) |= extraRight +} + +// C documentation +// +// /* +// ** Generate code to implement special SQL functions that are implemented +// ** in-line rather than by using the usual callbacks. +// */ +func _exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncId int32, target int32) (r int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var aff int8 + var azAff [6]uintptr + var endCoalesce, i, nFarg int32 + var pA1, pArg, v, v2 uintptr + var _ /* caseExpr at bp+0 */ TExpr + _, _, _, _, _, _, _, _, _ = aff, azAff, endCoalesce, i, nFarg, pA1, pArg, v, v2 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + nFarg = (*TExprList)(unsafe.Pointer(pFarg)).FnExpr + /* All in-line functions have at least one argument */ + switch iFuncId { + case INLINEFUNC_coalesce: + /* Attempt a direct implementation of the built-in COALESCE() and + ** IFNULL() functions. This avoids unnecessary evaluation of + ** arguments past the first non-NULL argument. + */ + endCoalesce = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, target) + i = int32(1) + for { + if !(i < nFarg) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), target, endCoalesce) + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + uintptr(i)*32))).FpExpr, target) + goto _1 + _1: + ; + i = i + 1 + } + _setDoNotMergeFlagOnCopy(tls, v) + _sqlite3VdbeResolveLabel(tls, v, endCoalesce) + case int32(INLINEFUNC_iif): + libc.Xmemset(tls, bp, 0, uint64(72)) + (**(**TExpr)(__ccgo_up(bp))).Fop = uint8(TK_CASE) + *(*uintptr)(unsafe.Pointer(bp + 32)) = pFarg + return _sqlite3ExprCodeTarget(tls, pParse, bp, target) + case int32(INLINEFUNC_sqlite_offset): + pArg = (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pArg)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pArg)).FiTable >= 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Offset), (*TExpr)(unsafe.Pointer(pArg)).FiTable, int32((*TExpr)(unsafe.Pointer(pArg)).FiColumn), target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + default: + /* The UNLIKELY() function is a no-op. The result is the value + ** of the first argument. + */ + target = _sqlite3ExprCodeTarget(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, target) + break + /*********************************************************************** + ** Test-only SQL functions that are only usable if enabled + ** via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS + */ + fallthrough + case int32(INLINEFUNC_expr_compare): + /* Compare two expressions using sqlite3ExprCompare() */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr, -int32(1)), target) + case int32(INLINEFUNC_expr_implies_expr): + /* Compare two expressions using sqlite3ExprImpliesExpr() */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprImpliesExpr(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr, -int32(1)), target) + case int32(INLINEFUNC_implies_nonnull_row): + pA1 = (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pA1)).Fop) == int32(TK_COLUMN) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprImpliesNonNullRow(tls, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr, (*TExpr)(unsafe.Pointer(pA1)).FiTable, int32(1)), target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + case int32(INLINEFUNC_affinity): + /* The AFFINITY() function evaluates to a string that describes + ** the type affinity of the argument. This is used for testing of + ** the SQLite type logic. + */ + azAff = [6]uintptr{ + 0: __ccgo_ts + 8482, + 1: __ccgo_ts + 8487, + 2: __ccgo_ts + 8492, + 3: __ccgo_ts + 6492, + 4: __ccgo_ts + 6487, + 5: __ccgo_ts + 8500, + } + aff = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr) + if int32(aff) <= int32(SQLITE_AFF_NONE) { + v2 = __ccgo_ts + 8508 + } else { + v2 = azAff[int32(aff)-int32(SQLITE_AFF_BLOB)] + } + _sqlite3VdbeLoadString(tls, v, target, v2) + break + } + return target +} + +// C documentation +// +// /* +// ** This function is called by unixOpen() to determine the unix permissions +// ** to create new files with. If no error occurs, then SQLITE_OK is returned +// ** and a value suitable for passing as the third argument to open(2) is +// ** written to *pMode. If an IO error occurs, an SQLite error code is +// ** returned and the value of *pMode is not modified. +// ** +// ** In most cases, this routine sets *pMode to 0, which will become +// ** an indication to robust_open() to create the file using +// ** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask. +// ** But if the file being opened is a WAL or regular journal file, then +// ** this function queries the file-system for the permissions on the +// ** corresponding database file and sets *pMode to this value. Whenever +// ** possible, WAL and journal files are created using the same permissions +// ** as the associated database file. +// ** +// ** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the +// ** original filename is unavailable. But 8_3_NAMES is only used for +// ** FAT filesystems and permissions do not matter there, so just use +// ** the default permissions. In 8_3_NAMES mode, leave *pMode set to zero. +// */ +func _findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr, pUid uintptr, pGid uintptr) (r int32) { + bp := tls.Alloc(528) + defer tls.Free(528) + var nDb, rc int32 + var z uintptr + var _ /* zDb at bp+0 */ [513]int8 + _, _, _ = nDb, rc, z + rc = SQLITE_OK /* Return Code */ + **(**Tmode_t)(__ccgo_up(pMode)) = uint32(0) + **(**Tuid_t)(__ccgo_up(pUid)) = uint32(0) + **(**Tgid_t)(__ccgo_up(pGid)) = uint32(0) + if flags&(libc.Int32FromInt32(SQLITE_OPEN_WAL)|libc.Int32FromInt32(SQLITE_OPEN_MAIN_JOURNAL)) != 0 { /* Number of valid bytes in zDb */ + /* zPath is a path to a WAL or journal file. The following block derives + ** the path to the associated database file from zPath. This block handles + ** the following naming conventions: + ** + ** "-journal" + ** "-wal" + ** "-journalNN" + ** "-walNN" + ** + ** where NN is a decimal number. The NN naming schemes are + ** used by the test_multiplex.c module. + ** + ** In normal operation, the journal file name will always contain + ** a '-' character. However in 8+3 filename mode, or if a corrupt + ** rollback journal specifies a super-journal with a goofy name, then + ** the '-' might be missing or the '-' might be the first character in + ** the filename. In that case, just return SQLITE_OK with *pMode==0. + */ + nDb = _sqlite3Strlen30(tls, zPath) - int32(1) + for nDb > 0 && int32(**(**int8)(__ccgo_up(zPath + uintptr(nDb)))) != int32('.') { + if int32(**(**int8)(__ccgo_up(zPath + uintptr(nDb)))) == int32('-') { + libc.Xmemcpy(tls, bp, zPath, libc.Uint64FromInt32(nDb)) + (**(**[513]int8)(__ccgo_up(bp)))[nDb] = int8('\000') + rc = _getFileMode(tls, bp, pMode, pUid, pGid) + break + } + nDb = nDb - 1 + } + } else { + if flags&int32(SQLITE_OPEN_DELETEONCLOSE) != 0 { + **(**Tmode_t)(__ccgo_up(pMode)) = uint32(0600) + } else { + if flags&int32(SQLITE_OPEN_URI) != 0 { + /* If this is a main database file and the file was opened using a URI + ** filename, check for the "modeof" parameter. If present, interpret + ** its value as a filename and try to copy the mode, uid and gid from + ** that file. */ + z = Xsqlite3_uri_parameter(tls, zPath, __ccgo_ts+4062) + if z != 0 { + rc = _getFileMode(tls, z, pMode, pUid, pGid) + } + } + } + } + return rc +} + +// C documentation +// +// /* +// ** This function is called when an UPDATE or DELETE operation is being +// ** compiled on table pTab, which is the parent table of foreign-key pFKey. +// ** If the current operation is an UPDATE, then the pChanges parameter is +// ** passed a pointer to the list of columns being modified. If it is a +// ** DELETE, pChanges is passed a NULL pointer. +// ** +// ** It returns a pointer to a Trigger structure containing a trigger +// ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. +// ** If the action is "NO ACTION" then a NULL pointer is returned (these actions +// ** require no special handling by the triggers sub-system, code for them is +// ** created by fkScanChildren()). +// ** +// ** For example, if pFKey is the foreign key and pTab is table "p" in +// ** the following schema: +// ** +// ** CREATE TABLE p(pk PRIMARY KEY); +// ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE); +// ** +// ** then the returned trigger structure is equivalent to: +// ** +// ** CREATE TRIGGER ... DELETE ON p BEGIN +// ** DELETE FROM c WHERE ck = old.pk; +// ** END; +// ** +// ** The returned pointer is cached as part of the foreign key object. It +// ** is eventually freed along with the rest of the foreign key object by +// ** sqlite3FkDelete(). +// */ +func _fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, pChanges uintptr) (r uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var action, i, iAction, iFromCol, nFrom, v2 int32 + var db, pCol, pDflt, pEq, pItem, pItem1, pList, pNew, pRaise, pSelect, pSrc, pStep, pTrigger, pWhen, pWhere, zFrom, v4 uintptr + var _ /* aiCol at bp+8 */ uintptr + var _ /* pIdx at bp+0 */ uintptr + var _ /* tFromCol at bp+48 */ TToken + var _ /* tNew at bp+32 */ TToken + var _ /* tOld at bp+16 */ TToken + var _ /* tToCol at bp+64 */ TToken + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = action, db, i, iAction, iFromCol, nFrom, pCol, pDflt, pEq, pItem, pItem1, pList, pNew, pRaise, pSelect, pSrc, pStep, pTrigger, pWhen, pWhere, zFrom, v2, v4 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Trigger definition to return */ + iAction = libc.BoolInt32(pChanges != uintptr(0)) /* 1 for UPDATE, 0 for DELETE */ + action = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pFKey + 45 + uintptr(iAction)))) + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008))< parent key cols */ + pStep = uintptr(0) /* First (only) step of trigger program */ + pWhere = uintptr(0) /* WHERE clause of trigger step */ + pList = uintptr(0) /* Changes list if ON UPDATE CASCADE */ + pSelect = uintptr(0) /* Iterator variable */ + pWhen = uintptr(0) /* WHEN clause for the trigger */ + if _sqlite3FkLocateIndex(tls, pParse, pTab, pFKey, bp, bp+8) != 0 { + return uintptr(0) + } + i = 0 + for { + if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { + break + } + **(**TToken)(__ccgo_up(bp + 16)) = TToken{ + Fz: __ccgo_ts + 6827, + Fn: uint32(3), + } /* Literal "old" token */ + **(**TToken)(__ccgo_up(bp + 32)) = TToken{ + Fz: __ccgo_ts + 6823, + Fn: uint32(3), + } /* tFromCol = OLD.tToCol */ + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v2 = **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + uintptr(i)*4)) + } else { + v2 = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom + } + iFromCol = v2 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + v2 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaiColumn + uintptr(i)*2))) + } else { + v2 = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + _sqlite3TokenInit(tls, bp+64, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(v2)*16))).FzCnName) + _sqlite3TokenInit(tls, bp+48, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16))).FzCnName) + /* Create the expression "OLD.zToCol = zFromCol". It is important + ** that the "OLD.zToCol" term is on the LHS of the = operator, so + ** that the affinity and collation sequence associated with the + ** parent table are used for the comparison. */ + pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+16, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+48, 0)) + pWhere = _sqlite3ExprAnd(tls, pParse, pWhere, pEq) + /* For ON UPDATE, construct the next term of the WHEN clause. + ** The final WHEN clause will be like this: + ** + ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) + */ + if pChanges != 0 { + pEq = _sqlite3PExpr(tls, pParse, int32(TK_IS), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+16, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+32, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0))) + pWhen = _sqlite3ExprAnd(tls, pParse, pWhen, pEq) + } + if action != int32(OE_Restrict) && (action != int32(OE_Cascade) || pChanges != 0) { + if action == int32(OE_Cascade) { + pNew = _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+32, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)) + } else { + if action == int32(OE_SetDflt) { + pCol = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + pDflt = uintptr(0) + } else { + pDflt = _sqlite3ColumnExpr(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, pCol) + } + if pDflt != 0 { + pNew = _sqlite3ExprDup(tls, db, pDflt, 0) + } else { + pNew = _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0) + } + } else { + pNew = _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0) + } + } + pList = _sqlite3ExprListAppend(tls, pParse, pList, pNew) + _sqlite3ExprListSetName(tls, pParse, pList, bp+48, 0) + } + goto _1 + _1: + ; + i = i + 1 + } + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 8))) + zFrom = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName + nFrom = _sqlite3Strlen30(tls, zFrom) + if action == int32(OE_Restrict) { + pRaise = _sqlite3Expr(tls, db, int32(TK_STRING), __ccgo_ts+5392) + pRaise = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), pRaise, uintptr(0)) + if pRaise != 0 { + (*TExpr)(unsafe.Pointer(pRaise)).FaffExpr = int8(OE_Abort) + } + pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + if pSrc != 0 { + pItem = pSrc + 8 + (*TSrcItem)(unsafe.Pointer(pItem)).FzName = _sqlite3DbStrDup(tls, db, zFrom) + libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 16, 0x10000) + *(*uintptr)(unsafe.Pointer(pItem + 72)) = (*TTable)(unsafe.Pointer(pTab)).FpSchema + } + pSelect = _sqlite3SelectNew(tls, pParse, _sqlite3ExprListAppend(tls, pParse, uintptr(0), pRaise), pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + pWhere = uintptr(0) + } + /* Disable lookaside memory allocation */ + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + pTrigger = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt64(72)+libc.Uint64FromInt64(88))) + if pTrigger != 0 { + v4 = pTrigger + 1*72 + (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list = v4 + pStep = v4 + (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) + if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { + pItem1 = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 + (*TSrcItem)(unsafe.Pointer(pItem1)).FzName = _sqlite3DbStrNDup(tls, db, zFrom, libc.Uint64FromInt32(nFrom)) + *(*uintptr)(unsafe.Pointer(pItem1 + 72)) = (*TTable)(unsafe.Pointer(pTab)).FpSchema + libc.SetBitFieldPtr32Uint32(pItem1+24+4, libc.Uint32FromInt32(1), 16, 0x10000) + } + (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere = _sqlite3ExprDup(tls, db, pWhere, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList = _sqlite3ExprListDup(tls, db, pList, int32(EXPRDUP_REDUCE)) + (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect = _sqlite3SelectDup(tls, db, pSelect, int32(EXPRDUP_REDUCE)) + if pWhen != 0 { + pWhen = _sqlite3PExpr(tls, pParse, int32(TK_NOT), pWhen, uintptr(0)) + (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen = _sqlite3ExprDup(tls, db, pWhen, int32(EXPRDUP_REDUCE)) + } + } + /* Re-enable the lookaside buffer, if it was disabled earlier. */ + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v2 = 0 + } else { + v2 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v2) + _sqlite3ExprDelete(tls, db, pWhere) + _sqlite3ExprDelete(tls, db, pWhen) + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3SelectDelete(tls, db, pSelect) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == int32(1) { + _fkTriggerDelete(tls, db, pTrigger) + return uintptr(0) + } + switch action { + case int32(OE_Restrict): + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_SELECT) + case int32(OE_Cascade): + if !(pChanges != 0) { + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_DELETE) + break + } + fallthrough + default: + (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_UPDATE) + } + (*TTriggerStep)(unsafe.Pointer(pStep)).FpTrig = pTrigger + (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + **(**uintptr)(__ccgo_up(pFKey + 48 + uintptr(iAction)*8)) = pTrigger + if pChanges != 0 { + v2 = int32(TK_UPDATE) + } else { + v2 = int32(TK_DELETE) + } + (*TTrigger)(unsafe.Pointer(pTrigger)).Fop = libc.Uint8FromInt32(v2) + } + return pTrigger +} + +// C documentation +// +// /* +// ** Implementation of the xBestIndex method for FTS5 tables. Within the +// ** WHERE constraint, it searches for the following: +// ** +// ** 1. A MATCH constraint against the table column. +// ** 2. A MATCH constraint against the "rank" column. +// ** 3. A MATCH constraint against some other column. +// ** 4. An == constraint against the rowid column. +// ** 5. A < or <= constraint against the rowid column. +// ** 6. A > or >= constraint against the rowid column. +// ** +// ** Within the ORDER BY, the following are supported: +// ** +// ** 5. ORDER BY rank [ASC|DESC] +// ** 6. ORDER BY rowid [ASC|DESC] +// ** +// ** Information for the xFilter call is passed via both the idxNum and +// ** idxStr variables. Specifically, idxNum is a bitmask of the following +// ** flags used to encode the ORDER BY clause: +// ** +// ** FTS5_BI_ORDER_RANK +// ** FTS5_BI_ORDER_ROWID +// ** FTS5_BI_ORDER_DESC +// ** +// ** idxStr is used to encode data from the WHERE clause. For each argument +// ** passed to the xFilter method, the following is appended to idxStr: +// ** +// ** Match against table column: "m" +// ** Match against rank column: "r" +// ** Match against other column: "M" +// ** LIKE against other column: "L" +// ** GLOB against other column: "G" +// ** Equality constraint against the rowid: "=" +// ** A < or <= against the rowid: "<" +// ** A > or >= against the rowid: ">" +// ** +// ** This function ensures that there is at most one "r" or "=". And that if +// ** there exists an "=" then there is no "<" or ">". +// ** +// ** If an unusable MATCH operator is present in the WHERE clause, then +// ** SQLITE_CONSTRAINT is returned. +// ** +// ** Costs are assigned as follows: +// ** +// ** a) If a MATCH operator is present, the cost depends on the other +// ** constraints also present. As follows: +// ** +// ** * No other constraints: cost=50000.0 +// ** * One rowid range constraint: cost=37500.0 +// ** * Both rowid range constraints: cost=30000.0 +// ** * An == rowid constraint: cost=25000.0 +// ** +// ** b) Otherwise, if there is no MATCH: +// ** +// ** * No other constraints: cost=3000000.0 +// ** * One rowid range constraints: cost=2250000.0 +// ** * Both rowid range constraint: cost=750000.0 +// ** * An == rowid constraint: cost=25.0 +// ** +// ** Costs are not modified by the ORDER BY clause. +// ** +// ** The ratios used in case (a) are based on informal results obtained from +// ** the tool/fts5cost.tcl script. The "MATCH and ==" combination has the +// ** cost set quite high because the query may be a prefix query. Unless +// ** there is a prefix index, prefix queries with rowid constraints are much +// ** more expensive than non-prefix queries with rowid constraints. +// ** +// ** The estimated rows returned is set to the cost/40. For simple queries, +// ** experimental results show that cost/4 might be about right. But for +// ** more complex queries that use multiple terms the number of rows might +// ** be far fewer than this. So we compromise and use cost/40. +// */ +func _fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bSeenEq, bSeenGt, bSeenLt, bSeenRank, i, iCol, iCons, iIdxStr, iSort, idxFlags, nCol, nSeenMatch, op, v2, v3 int32 + var idxStr, p, p1, pConfig, pTab uintptr + var nEstRows Ti64 + var v15 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bSeenEq, bSeenGt, bSeenLt, bSeenRank, i, iCol, iCons, iIdxStr, iSort, idxFlags, idxStr, nCol, nEstRows, nSeenMatch, op, p, p1, pConfig, pTab, v15, v2, v3 + pTab = pVTab + pConfig = (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig + nCol = (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol + idxFlags = 0 + iIdxStr = 0 + iCons = 0 + bSeenEq = 0 + bSeenGt = 0 + bSeenLt = 0 + nSeenMatch = 0 + bSeenRank = 0 + if (*TFts5Config)(unsafe.Pointer(pConfig)).FbLock != 0 { + (*TFts5Table)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+39647, 0) + return int32(SQLITE_ERROR) + } + idxStr = Xsqlite3_malloc64(tls, libc.Uint64FromInt64(int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint)*int64(8)+int64(1))) + if idxStr == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FidxStr = idxStr + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FneedToFreeIdxStr = int32(1) + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint) { + break + } + p = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12 + iCol = (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_MATCH) || libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) && iCol >= nCol { + /* A MATCH operator or equivalent */ + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0 || iCol < 0 { + /* As there exists an unusable MATCH constraint this is an + ** unusable plan. Return SQLITE_CONSTRAINT. */ + **(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr))) = 0 + return int32(SQLITE_CONSTRAINT) + } else { + if iCol == nCol+int32(1) { + if bSeenRank != 0 { + goto _1 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('r') + bSeenRank = int32(1) + } else { + nSeenMatch = nSeenMatch + 1 + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('M') + Xsqlite3_snprintf(tls, int32(6), idxStr+uintptr(iIdxStr), __ccgo_ts+5289, libc.VaList(bp+8, iCol)) + iIdxStr = iIdxStr + libc.Int32FromUint64(libc.Xstrlen(tls, idxStr+uintptr(iIdxStr))) + } + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + } + } else { + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 { + if iCol >= 0 && iCol < nCol && _fts5UsePatternMatch(tls, pConfig, p) != 0 { + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + if libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(FTS5_PATTERN_LIKE) { + v3 = int32('L') + } else { + v3 = int32('G') + } + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8(v3) + Xsqlite3_snprintf(tls, int32(6), idxStr+uintptr(iIdxStr), __ccgo_ts+5289, libc.VaList(bp+8, iCol)) + idxStr = idxStr + uintptr(libc.Xstrlen(tls, idxStr+uintptr(iIdxStr))) + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + nSeenMatch = nSeenMatch + 1 + } else { + if bSeenEq == 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) && iCol < 0 { + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('=') + bSeenEq = int32(1) + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).Fomit = uint8(1) + } + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + if bSeenEq == 0 { + i = 0 + for { + if !(i < (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint) { + break + } + p1 = (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12 + if (*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).FiColumn < 0 && (*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).Fusable != 0 { + op = libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p1)).Fop) + if op == int32(SQLITE_INDEX_CONSTRAINT_LT) || op == int32(SQLITE_INDEX_CONSTRAINT_LE) { + if bSeenLt != 0 { + goto _10 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('<') + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + bSeenLt = int32(1) + } else { + if op == int32(SQLITE_INDEX_CONSTRAINT_GT) || op == int32(SQLITE_INDEX_CONSTRAINT_GE) { + if bSeenGt != 0 { + goto _10 + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + **(**int8)(__ccgo_up(idxStr + uintptr(v2))) = int8('>') + iCons = iCons + 1 + v2 = iCons + (**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8))).FargvIndex = v2 + bSeenGt = int32(1) + } + } + } + goto _10 + _10: + ; + i = i + 1 + } + } + **(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr))) = int8('\000') + /* Set idxFlags flags for the ORDER BY clause + ** + ** Note that tokendata=1 tables cannot currently handle "ORDER BY rowid DESC". + */ + if (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == int32(1) { + iSort = (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).FiColumn + if iSort == (*TFts5Config)(unsafe.Pointer(pConfig)).FnCol+int32(1) && nSeenMatch > 0 { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_RANK) + } else { + if iSort == -int32(1) && (!((**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).Fdesc != 0) || !((*TFts5Config)(unsafe.Pointer(pConfig)).FbTokendata != 0)) { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_ROWID) + } + } + if idxFlags&(libc.Int32FromInt32(FTS5_BI_ORDER_RANK)|libc.Int32FromInt32(FTS5_BI_ORDER_ROWID)) != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = int32(1) + if (**(**Tsqlite3_index_orderby)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy))).Fdesc != 0 { + idxFlags = idxFlags | int32(FTS5_BI_ORDER_DESC) + } + } + } + /* Calculate the estimated cost based on the flags set in idxFlags. */ + if bSeenEq != 0 { + if nSeenMatch != 0 { + v15 = float64(25000) + } else { + v15 = float64(25) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = v15 + _fts5SetEstimatedRows(tls, pInfo, int64(1)) + _fts5SetUniqueFlag(tls, pInfo) + } else { + if nSeenMatch != 0 { + if bSeenLt != 0 && bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(50000) + } else { + if bSeenLt != 0 || bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(37500) + } else { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(50000) + } + } + nEstRows = int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / libc.Float64FromFloat64(40)) + i = int32(1) + for { + if !(i < nSeenMatch) { + break + } + **(**float64)(__ccgo_up(pInfo + 64)) *= float64(2.5) + nEstRows = nEstRows / int64(2) + goto _16 + _16: + ; + i = i + 1 + } + } else { + if bSeenLt != 0 && bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(750000) + } else { + if bSeenLt != 0 || bSeenGt != 0 { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(2.25e+06) + } else { + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(3e+06) + } + } + nEstRows = int64((*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / libc.Float64FromFloat64(4)) + } + _fts5SetEstimatedRows(tls, pInfo, nEstRows) + } + (*Tsqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxFlags + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Parse a "special" CREATE VIRTUAL TABLE directive and update +// ** configuration object pConfig as appropriate. +// ** +// ** If successful, object pConfig is updated and SQLITE_OK returned. If +// ** an error occurs, an SQLite error code is returned and an error message +// ** may be left in *pzErr. It is the responsibility of the caller to +// ** eventually free any such error message using sqlite3_free(). +// */ +func _fts5ConfigParseSpecial(tls *libc.TLS, pConfig uintptr, zCmd uintptr, zArg uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var azArg, p, p1, p2, pSpace uintptr + var bFirst, nByte, nCmd, nPre, v2 int32 + var nArg Tsqlite3_int64 + var _ /* aDetail at bp+8 */ [4]TFts5Enum + var _ /* rc at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = azArg, bFirst, nArg, nByte, nCmd, nPre, p, p1, p2, pSpace, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + nCmd = libc.Int32FromUint64(libc.Xstrlen(tls, zCmd)) + if Xsqlite3_strnicmp(tls, __ccgo_ts+37338, zCmd, nCmd) == 0 { + nByte = libc.Int32FromUint64(libc.Uint64FromInt64(4) * libc.Uint64FromInt32(FTS5_MAX_PREFIX_INDEXES)) + bFirst = int32(1) + if (*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix == uintptr(0) { + (*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix = _sqlite3Fts5MallocZero(tls, bp, int64(nByte)) + if **(**int32)(__ccgo_up(bp)) != 0 { + return **(**int32)(__ccgo_up(bp)) + } + } + p = zArg + for int32(1) != 0 { + nPre = 0 + for int32(**(**int8)(__ccgo_up(p))) == int32(' ') { + p = p + 1 + } + if bFirst == 0 && int32(**(**int8)(__ccgo_up(p))) == int32(',') { + p = p + 1 + for int32(**(**int8)(__ccgo_up(p))) == int32(' ') { + p = p + 1 + } + } else { + if int32(**(**int8)(__ccgo_up(p))) == int32('\000') { + break + } + } + if int32(**(**int8)(__ccgo_up(p))) < int32('0') || int32(**(**int8)(__ccgo_up(p))) > int32('9') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37345, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + if (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix == int32(FTS5_MAX_PREFIX_INDEXES) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37376, libc.VaList(bp+80, int32(FTS5_MAX_PREFIX_INDEXES))) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + for int32(**(**int8)(__ccgo_up(p))) >= int32('0') && int32(**(**int8)(__ccgo_up(p))) <= int32('9') && nPre < int32(1000) { + nPre = nPre*int32(10) + (int32(**(**int8)(__ccgo_up(p))) - int32('0')) + p = p + 1 + } + if nPre <= 0 || nPre >= int32(1000) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37409, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + break + } + **(**int32)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr((*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix)*4)) = nPre + (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix = (*TFts5Config)(unsafe.Pointer(pConfig)).FnPrefix + 1 + bFirst = 0 + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37446, zCmd, nCmd) == 0 { + p1 = zArg + nArg = libc.Int64FromUint64(libc.Xstrlen(tls, zArg) + uint64(1)) + azArg = _sqlite3Fts5MallocZero(tls, bp, libc.Int64FromUint64(uint64(libc.Uint64FromInt64(8)+libc.Uint64FromInt32(2))*libc.Uint64FromInt64(nArg))) + if azArg != 0 { + pSpace = azArg + uintptr(nArg)*8 + if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FazArg != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37455, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + nArg = 0 + for { + if !(p1 != 0 && **(**int8)(__ccgo_up(p1)) != 0) { + break + } + p2 = _fts5ConfigSkipWhitespace(tls, p1) + if int32(**(**int8)(__ccgo_up(p2))) == int32('\'') { + p1 = _fts5ConfigSkipLiteral(tls, p2) + } else { + p1 = _fts5ConfigSkipBareword(tls, p2) + } + if p1 != 0 { + libc.Xmemcpy(tls, pSpace, p2, libc.Uint64FromInt64(int64(p1)-int64(p2))) + **(**uintptr)(__ccgo_up(azArg + uintptr(nArg)*8)) = pSpace + _sqlite3Fts5Dequote(tls, pSpace) + pSpace = pSpace + uintptr(int64(p1)-int64(p2)+int64(1)) + p1 = _fts5ConfigSkipWhitespace(tls, p1) + } + goto _1 + _1: + ; + nArg = nArg + 1 + } + if p1 == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37488, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FazArg = azArg + (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FnArg = int32(nArg) + azArg = uintptr(0) + } + } + } + Xsqlite3_free(tls, azArg) + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37522, zCmd, nCmd) == 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37530, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + if **(**int8)(__ccgo_up(zArg)) != 0 { + (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent = int32(FTS5_CONTENT_EXTERNAL) + (*TFts5Config)(unsafe.Pointer(pConfig)).FzContent = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+37562, libc.VaList(bp+80, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, zArg)) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent = int32(FTS5_CONTENT_NONE) + } + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37568, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37587, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessDelete = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37630, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37587, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbContentlessUnindexed = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37652, zCmd, nCmd) == 0 { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FzContentRowid != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37666, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FzContentRowid = _sqlite3Fts5Strndup(tls, bp, zArg, -int32(1)) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37704, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37715, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37750, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37757, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbLocale = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+5666, zCmd, nCmd) == 0 { + **(**[4]TFts5Enum)(__ccgo_up(bp + 8)) = [4]TFts5Enum{ + 0: { + FzName: __ccgo_ts + 8508, + FeVal: int32(FTS5_DETAIL_NONE), + }, + 1: { + FzName: __ccgo_ts + 19016, + }, + 2: { + FzName: __ccgo_ts + 37788, + FeVal: int32(FTS5_DETAIL_COLUMNS), + }, + 3: {}, + } + v2 = _fts5ConfigSetEnum(tls, bp+8, zArg, pConfig+116) + **(**int32)(__ccgo_up(bp)) = v2 + if v2 != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37796, 0) + } + return **(**int32)(__ccgo_up(bp)) + } + if Xsqlite3_strnicmp(tls, __ccgo_ts+37827, zCmd, nCmd) == 0 { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || int32(**(**int8)(__ccgo_up(zArg + 1))) != int32('\000') { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37837, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbTokendata = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('1')) + } + return **(**int32)(__ccgo_up(bp)) + } + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+37871, libc.VaList(bp+80, nCmd, zCmd)) + return int32(SQLITE_ERROR) +} + +func _fts5ConfigSkipLiteral(tls *libc.TLS, pIn uintptr) (r uintptr) { + var p uintptr + _ = p + p = pIn + switch int32(**(**int8)(__ccgo_up(p))) { + case int32('n'): + fallthrough + case int32('N'): + if Xsqlite3_strnicmp(tls, __ccgo_ts+1690, p, int32(4)) == 0 { + p = p + 4 + } else { + p = uintptr(0) + } + case int32('x'): + fallthrough + case int32('X'): + p = p + 1 + if int32(**(**int8)(__ccgo_up(p))) == int32('\'') { + p = p + 1 + for int32(**(**int8)(__ccgo_up(p))) >= int32('a') && int32(**(**int8)(__ccgo_up(p))) <= int32('f') || int32(**(**int8)(__ccgo_up(p))) >= int32('A') && int32(**(**int8)(__ccgo_up(p))) <= int32('F') || int32(**(**int8)(__ccgo_up(p))) >= int32('0') && int32(**(**int8)(__ccgo_up(p))) <= int32('9') { + p = p + 1 + } + if int32(**(**int8)(__ccgo_up(p))) == int32('\'') && 0 == (int64(p)-int64(pIn))%int64(2) { + p = p + 1 + } else { + p = uintptr(0) + } + } else { + p = uintptr(0) + } + case int32('\''): + p = p + 1 + for p != 0 { + if int32(**(**int8)(__ccgo_up(p))) == int32('\'') { + p = p + 1 + if int32(**(**int8)(__ccgo_up(p))) != int32('\'') { + break + } + } + p = p + 1 + if int32(**(**int8)(__ccgo_up(p))) == 0 { + p = uintptr(0) + } + } + default: + /* maybe a number */ + if int32(**(**int8)(__ccgo_up(p))) == int32('+') || int32(**(**int8)(__ccgo_up(p))) == int32('-') { + p = p + 1 + } + for _fts5_isdigit(tls, **(**int8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + /* At this point, if the literal was an integer, the parse is + ** finished. Or, if it is a floating point value, it may continue + ** with either a decimal point or an 'E' character. */ + if int32(**(**int8)(__ccgo_up(p))) == int32('.') && _fts5_isdigit(tls, **(**int8)(__ccgo_up(p + 1))) != 0 { + p = p + uintptr(2) + for _fts5_isdigit(tls, **(**int8)(__ccgo_up(p))) != 0 { + p = p + 1 + } + } + if p == pIn { + p = uintptr(0) + } + break + } + return p +} + +// C documentation +// +// /* +// ** Read the first token from the nul-terminated string at *pz. +// */ +func _fts5ExprGetToken(tls *libc.TLS, pParse uintptr, pz uintptr, pToken uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var tok int32 + var z, z2, z21 uintptr + _, _, _, _ = tok, z, z2, z21 + z = **(**uintptr)(__ccgo_up(pz)) + /* Skip past any whitespace */ + for _fts5ExprIsspace(tls, **(**int8)(__ccgo_up(z))) != 0 { + z = z + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fp = z + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(1) + switch int32(**(**int8)(__ccgo_up(z))) { + case int32('('): + tok = int32(FTS5_LP) + case int32(')'): + tok = int32(FTS5_RP) + case int32('{'): + tok = int32(FTS5_LCP) + case int32('}'): + tok = int32(FTS5_RCP) + case int32(':'): + tok = int32(FTS5_COLON) + case int32(','): + tok = int32(FTS5_COMMA) + case int32('+'): + tok = int32(FTS5_PLUS) + case int32('*'): + tok = int32(FTS5_STAR) + case int32('-'): + tok = int32(FTS5_MINUS) + case int32('^'): + tok = int32(FTS5_CARET) + case int32('\000'): + tok = FTS5_EOF + case int32('"'): + tok = int32(FTS5_STRING) + z2 = z + 1 + for { + if !(int32(1) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(z2))) == int32('"') { + z2 = z2 + 1 + if int32(**(**int8)(__ccgo_up(z2))) != int32('"') { + break + } + } + if int32(**(**int8)(__ccgo_up(z2))) == int32('\000') { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38478, 0) + return FTS5_EOF + } + goto _1 + _1: + ; + z2 = z2 + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(int64(z2) - int64(z)) + default: + if _sqlite3Fts5IsBareword(tls, **(**int8)(__ccgo_up(z))) == 0 { + _sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38498, libc.VaList(bp+8, z)) + return FTS5_EOF + } + tok = int32(FTS5_STRING) + z21 = z + 1 + for { + if !(_sqlite3Fts5IsBareword(tls, **(**int8)(__ccgo_up(z21))) != 0) { + break + } + goto _2 + _2: + ; + z21 = z21 + 1 + } + (*TFts5Token)(unsafe.Pointer(pToken)).Fn = int32(int64(z21) - int64(z)) + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(2) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+38529, uint64(2)) == 0 { + tok = int32(FTS5_OR) + } + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(3) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+38532, uint64(3)) == 0 { + tok = int32(FTS5_NOT) + } + if (*TFts5Token)(unsafe.Pointer(pToken)).Fn == int32(3) && libc.Xmemcmp(tls, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, __ccgo_ts+32339, uint64(3)) == 0 { + tok = int32(FTS5_AND) + } + break + } + **(**uintptr)(__ccgo_up(pz)) = (*TFts5Token)(unsafe.Pointer(pToken)).Fp + uintptr((*TFts5Token)(unsafe.Pointer(pToken)).Fn) + return tok +} + +// C documentation +// +// /* +// ** This is the xFilter interface for the virtual table. See +// ** the virtual table xFilter method documentation for additional +// ** information. +// ** +// ** There are three possible query strategies: +// ** +// ** 1. Full-text search using a MATCH operator. +// ** 2. A by-rowid lookup. +// ** 3. A full-table scan. +// */ +func _fts5FilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, nVal int32, apVal uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var bDesc, bGlob, bInternal, bOrderByRank, bPrefixInsttoken, i, iCol, iIdxStr, rc, v2, v3 int32 + var pConfig, pCsr, pRank, pRowidEq, pRowidGe, pRowidLe, pTab, pzErr, pzErrmsg, zText1, v6 uintptr + var _ /* bFreeAndReset at bp+16 */ int32 + var _ /* pExpr at bp+0 */ uintptr + var _ /* zText at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bDesc, bGlob, bInternal, bOrderByRank, bPrefixInsttoken, i, iCol, iIdxStr, pConfig, pCsr, pRank, pRowidEq, pRowidGe, pRowidLe, pTab, pzErr, pzErrmsg, rc, zText1, v2, v3, v6 + pTab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab + pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig + pCsr = pCursor + rc = SQLITE_OK /* True if ORDER BY rank */ + pRank = uintptr(0) /* rank MATCH ? expression (or NULL) */ + pRowidEq = uintptr(0) /* rowid = ? expression (or NULL) */ + pRowidLe = uintptr(0) /* rowid <= ? expression (or NULL) */ + pRowidGe = uintptr(0) /* Column on LHS of MATCH operator */ + pzErrmsg = (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg + bPrefixInsttoken = (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken + iIdxStr = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan != 0 { + _fts5FreeCursorComponents(tls, pCsr) + libc.Xmemset(tls, pCsr+32, 0, uint64(184)-libc.Uint64FromInt64(int64(pCsr+32)-int64(pCsr))) + } + (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = pTab + 16 + /* Decode the arguments passed through to this function. */ + i = 0 + for { + if !(i < nVal) { + break + } + v2 = iIdxStr + iIdxStr = iIdxStr + 1 + switch int32(**(**int8)(__ccgo_up(idxStr + uintptr(v2)))) { + case int32('r'): + pRank = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + case int32('M'): + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 16)) = 0 + bInternal = 0 + rc = _fts5ExtractExprText(tls, pConfig, **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)), bp+8, bp+16) + if rc != SQLITE_OK { + goto filter_out + } + if **(**uintptr)(__ccgo_up(bp + 8)) == uintptr(0) { + **(**uintptr)(__ccgo_up(bp + 8)) = __ccgo_ts + 1704 + } + if Xsqlite3_value_subtype(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8))) == uint32(FTS5_INSTTOKEN_SUBTYPE) { + (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken = int32(1) + } + iCol = 0 + for cond := true; cond; cond = int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) >= int32('0') && int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) <= int32('9') { + iCol = iCol*int32(10) + (int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) - int32('0')) + iIdxStr = iIdxStr + 1 + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))) == int32('*') { + /* The user has issued a query of the form "MATCH '*...'". This + ** indicates that the MATCH expression is not a full text query, + ** but a request for an internal parameter. */ + rc = _fts5SpecialMatch(tls, pTab, pCsr, **(**uintptr)(__ccgo_up(bp + 8))+1) + bInternal = int32(1) + } else { + pzErr = pTab + 16 + rc = _sqlite3Fts5ExprNew(tls, pConfig, 0, iCol, **(**uintptr)(__ccgo_up(bp + 8)), bp, pzErr) + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprAnd(tls, pCsr+64, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + if **(**int32)(__ccgo_up(bp + 16)) != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + _sqlite3Fts5ClearLocale(tls, pConfig) + } + if bInternal != 0 || rc != SQLITE_OK { + goto filter_out + } + case int32('L'): + fallthrough + case int32('G'): + bGlob = libc.BoolInt32(int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr-int32(1))))) == int32('G')) + zText1 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8))) + iCol = 0 + for cond := true; cond; cond = int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) >= int32('0') && int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) <= int32('9') { + iCol = iCol*int32(10) + (int32(**(**int8)(__ccgo_up(idxStr + uintptr(iIdxStr)))) - int32('0')) + iIdxStr = iIdxStr + 1 + } + if zText1 != 0 { + rc = _sqlite3Fts5ExprPattern(tls, pConfig, bGlob, iCol, zText1, bp) + } + if rc == SQLITE_OK { + rc = _sqlite3Fts5ExprAnd(tls, pCsr+64, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + if rc != SQLITE_OK { + goto filter_out + } + case int32('='): + pRowidEq = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + case int32('<'): + pRowidLe = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + default: + pRowidGe = **(**uintptr)(__ccgo_up(apVal + uintptr(i)*8)) + break + } + goto _1 + _1: + ; + i = i + 1 + } + if idxNum&int32(FTS5_BI_ORDER_RANK) != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + bOrderByRank = v2 + if idxNum&int32(FTS5_BI_ORDER_DESC) != 0 { + v3 = int32(1) + } else { + v3 = 0 + } + v2 = v3 + bDesc = v2 + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FbDesc = v2 + /* Set the cursor upper and lower rowid limits. Only some strategies + ** actually use them. This is ok, as the xBestIndex() method leaves the + ** sqlite3_index_constraint.omit flag clear for range constraints + ** on the rowid field. */ + if pRowidEq != 0 { + v6 = pRowidEq + pRowidGe = v6 + pRowidLe = v6 + } + if bDesc != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = _fts5GetRowidLimit(tls, pRowidLe, libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< ORDER BY rank" query (ePlan is + ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will + ** return results to the user for this query. The current cursor + ** (pCursor) is used to execute the query issued by function + ** fts5CursorFirstSorted() above. */ + if (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FbDesc != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiLastRowid + } else { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiLastRowid + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SOURCE) + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr = (*TFts5Cursor)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FpExpr + rc = _fts5CursorFirst(tls, pTab, pCsr, bDesc) + } else { + if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr != 0 { + rc = _fts5CursorParseRank(tls, pConfig, pCsr, pRank) + if rc == SQLITE_OK { + if bOrderByRank != 0 { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SORTED_MATCH) + rc = _fts5CursorFirstSorted(tls, pTab, pCsr, bDesc) + } else { + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_MATCH) + rc = _fts5CursorFirst(tls, pTab, pCsr, bDesc) + } + } + } else { + if (*TFts5Config)(unsafe.Pointer(pConfig)).FzContent == uintptr(0) { + _fts5SetVtabError(tls, pTab, __ccgo_ts+39848, libc.VaList(bp+32, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName)) + rc = int32(SQLITE_ERROR) + } else { + /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup + ** by rowid (ePlan==FTS5_PLAN_ROWID). */ + if pRowidEq != 0 { + v2 = int32(FTS5_PLAN_ROWID) + } else { + v2 = int32(FTS5_PLAN_SCAN) + } + (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = v2 + rc = _sqlite3Fts5StorageStmt(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, _fts5StmtType(tls, pCsr), pCsr+56, pTab+16) + if rc == SQLITE_OK { + if pRowidEq != uintptr(0) { + Xsqlite3_bind_value(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1), pRowidEq) + } else { + Xsqlite3_bind_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(1), (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid) + Xsqlite3_bind_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, int32(2), (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid) + } + rc = _fts5NextMethod(tls, pCursor) + } + } + } + } + goto filter_out +filter_out: + ; + _sqlite3Fts5ExprFree(tls, **(**uintptr)(__ccgo_up(bp))) + (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = pzErrmsg + (*TFts5Config)(unsafe.Pointer(pConfig)).FbPrefixInsttoken = bPrefixInsttoken + return rc +} + +func _fts5PorterStep1B(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('e'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42107, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+42111, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(2) + } + } else { + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42114, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_Vowel(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + ret = int32(1) + } + } + } + case int32('n'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42117, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_Vowel(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + ret = int32(1) + } + } + break + } + return ret +} + +/* +** GENERATED CODE ENDS HERE (mkportersteps.tcl) +*************************************************************************** +**************************************************************************/ + +func _fts5PorterStep1B2(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41921, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+41901, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + case int32('b'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41924, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+41927, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + case int32('i'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41931, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(2)), __ccgo_ts+41917, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + int32(3) + ret = int32(1) + } + break + } + return ret +} + +func _fts5PorterStep2(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41934, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+41901, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(6) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41942, aBuf+uintptr(nBuf-int32(6)), uint64(6)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(6)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(6)), __ccgo_ts+41949, uint64(4)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(6) + int32(4) + } + } + } + case int32('c'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41954, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41850, uint64(4)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41959, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41845, uint64(4)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(4) + } + } + } + case int32('e'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41964, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41917, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + case int32('g'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41969, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+17165, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + case int32('l'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41974, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+41927, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(3) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41978, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41842, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41983, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41886, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41989, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(3)), __ccgo_ts+41993, uint64(1)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + int32(1) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41995, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41909, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } + } + } + } + } + case int32('o'): + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42001, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+41917, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42009, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41901, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42015, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41901, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(3) + } + } + } + } + case int32('s'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42020, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41842, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42026, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+41913, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42034, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+42042, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } else { + if nBuf > int32(7) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42046, aBuf+uintptr(nBuf-int32(7)), uint64(7)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(7)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(7)), __ccgo_ts+41909, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(7) + int32(3) + } + } + } + } + } + case int32('t'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42054, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41842, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42060, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41913, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(3) + } + } else { + if nBuf > int32(6) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42066, aBuf+uintptr(nBuf-int32(6)), uint64(6)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(6)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(6)), __ccgo_ts+41927, uint64(3)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(6) + int32(3) + } + } + } + } + break + } + return ret +} + +func _fts5PorterStep3(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42073, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(4)), __ccgo_ts+41858, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + int32(2) + } + } + case int32('s'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42078, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + case int32('t'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42083, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41858, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42089, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41858, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } + } + case int32('u'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42042, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('v'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42095, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + } + } + case int32('z'): + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+42101, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt0(tls, aBuf, nBuf-int32(5)) != 0 { + libc.Xmemcpy(tls, aBuf+uintptr(nBuf-int32(5)), __ccgo_ts+41842, uint64(2)) + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + int32(2) + } + } + break + } + return ret +} + +func _fts5PorterStep4(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) (r int32) { + var nBuf, ret int32 + _, _ = nBuf, ret + ret = 0 + nBuf = **(**int32)(__ccgo_up(pnBuf)) + switch int32(**(**int8)(__ccgo_up(aBuf + uintptr(nBuf-int32(2))))) { + case int32('a'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41842, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('c'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41845, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41850, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + } + case int32('e'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41855, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('i'): + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41858, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + case int32('l'): + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41861, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41866, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } + } + case int32('n'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41871, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41875, aBuf+uintptr(nBuf-int32(5)), uint64(5)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(5)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(5) + } + } else { + if nBuf > int32(4) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41881, aBuf+uintptr(nBuf-int32(4)), uint64(4)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(4)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(4) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41886, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + } + } + } + case int32('o'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41890, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1_and_S_or_T(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(2) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41894, aBuf+uintptr(nBuf-int32(2)), uint64(2)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(2)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(2) + } + } + } + case int32('s'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41897, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('t'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41901, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } else { + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41905, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + } + case int32('u'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41909, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('v'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41913, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + case int32('z'): + if nBuf > int32(3) && 0 == libc.Xmemcmp(tls, __ccgo_ts+41917, aBuf+uintptr(nBuf-int32(3)), uint64(3)) { + if _fts5Porter_MGt1(tls, aBuf, nBuf-int32(3)) != 0 { + **(**int32)(__ccgo_up(pnBuf)) = nBuf - int32(3) + } + } + break + } + return ret +} + +// C documentation +// +// /* +// ** Allocate a trigram tokenizer. +// */ +func _fts5TriCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + var i, rc, v2 int32 + var pNew, zArg uintptr + _, _, _, _, _ = i, pNew, rc, zArg, v2 + rc = SQLITE_OK + pNew = uintptr(0) + _ = pUnused + if nArg%int32(2) != 0 { + rc = int32(SQLITE_ERROR) + } else { + pNew = Xsqlite3_malloc64(tls, uint64(8)) + if pNew == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold = int32(1) + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam = 0 + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + zArg = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+42121) { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') || **(**int8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold = libc.BoolInt32(int32(**(**int8)(__ccgo_up(zArg))) == int32('0')) + } + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41807) { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') && int32(**(**int8)(__ccgo_up(zArg))) != int32('2') || **(**int8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') { + v2 = int32(2) + } else { + v2 = 0 + } + (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam = v2 + } + } else { + rc = int32(SQLITE_ERROR) + } + } + goto _1 + _1: + ; + i = i + int32(2) + } + if (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FiFoldParam != 0 && (*TTrigramTokenizer)(unsafe.Pointer(pNew)).FbFold == 0 { + rc = int32(SQLITE_ERROR) + } + if rc != SQLITE_OK { + _fts5TriDelete(tls, pNew) + pNew = uintptr(0) + } + } + } + **(**uintptr)(__ccgo_up(ppOut)) = pNew + return rc +} + +// C documentation +// +// /* +// ** Create a "unicode61" tokenizer. +// */ +func _fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) (r int32) { + var i, rc int32 + var p, zArg, zCat uintptr + _, _, _, _, _ = i, p, rc, zArg, zCat + rc = SQLITE_OK /* Return code */ + p = uintptr(0) /* New tokenizer object */ + _ = pUnused + if nArg%int32(2) != 0 { + rc = int32(SQLITE_ERROR) + } else { + p = Xsqlite3_malloc64(tls, uint64(192)) + if p != 0 { + zCat = __ccgo_ts + 41787 + libc.Xmemset(tls, p, 0, uint64(192)) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = int32(FTS5_REMOVE_DIACRITICS_SIMPLE) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold = int32(64) + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold = Xsqlite3_malloc64(tls, uint64(libc.Uint64FromInt32((*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnFold)*uint64(1))) + if (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } + /* Search for a "categories" argument */ + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41796) { + zCat = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + } + goto _1 + _1: + ; + i = i + int32(2) + } + if rc == SQLITE_OK { + rc = _unicodeSetCategories(tls, p, zCat) + } + i = 0 + for { + if !(rc == SQLITE_OK && i < nArg) { + break + } + zArg = **(**uintptr)(__ccgo_up(azArg + uintptr(i+int32(1))*8)) + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41807) { + if int32(**(**int8)(__ccgo_up(zArg))) != int32('0') && int32(**(**int8)(__ccgo_up(zArg))) != int32('1') && int32(**(**int8)(__ccgo_up(zArg))) != int32('2') || **(**int8)(__ccgo_up(zArg + 1)) != 0 { + rc = int32(SQLITE_ERROR) + } else { + (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = int32(**(**int8)(__ccgo_up(zArg))) - int32('0') + } + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41765) { + rc = _fts5UnicodeAddExceptions(tls, p, zArg, int32(1)) + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41776) { + rc = _fts5UnicodeAddExceptions(tls, p, zArg, 0) + } else { + if 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)), __ccgo_ts+41796) { + /* no-op */ + } else { + rc = int32(SQLITE_ERROR) + } + } + } + } + goto _2 + _2: + ; + i = i + int32(2) + } + } else { + rc = int32(SQLITE_NOMEM) + } + if rc != SQLITE_OK { + _fts5UnicodeDelete(tls, p) + p = uintptr(0) + } + **(**uintptr)(__ccgo_up(ppOut)) = p + } + return rc +} + +// C documentation +// +// /* +// ** SQL function: geopoly_svg(X, ....) +// ** +// ** Interpret X as a polygon and render it as a SVG . +// ** Additional arguments are added as attributes to the . +// */ +func _geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var cSep int8 + var db, p, x, z uintptr + var i int32 + _, _, _, _, _, _ = cSep, db, i, p, x, z + if argc < int32(1) { + return + } + p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0)) + if p != 0 { + db = Xsqlite3_context_db_handle(tls, context) + x = Xsqlite3_str_new(tls, db) + cSep = int8('\'') + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29790, 0) + i = 0 + for { + if !(i < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) { + break + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29808, libc.VaList(bp+8, int32(cSep), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2)+int32(1))*4))))) + cSep = int8(' ') + goto _1 + _1: + ; + i = i + 1 + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29816, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4))))) + i = int32(1) + for { + if !(i < argc) { + break + } + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if z != 0 && **(**int8)(__ccgo_up(z)) != 0 { + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29824, libc.VaList(bp+8, z)) + } + goto _2 + _2: + ; + i = i + 1 + } + Xsqlite3_str_appendf(tls, x, __ccgo_ts+29828, 0) + Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -int32(1), __ccgo_fp(Xsqlite3_free)) + Xsqlite3_free(tls, p) + } +} + +// C documentation +// +// /* c is a control character. Append the canonical JSON representation +// ** of that control character to p. +// ** +// ** This routine assumes that the output buffer has already been enlarged +// ** sufficiently to hold the worst-case encoding plus a nul terminator. +// */ +func _jsonAppendControlChar(tls *libc.TLS, p uintptr, c Tu8) { + if _aSpecial[c] != 0 { + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed))) = int8('\\') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(1)))) = _aSpecial[c] + **(**Tu64)(__ccgo_up(p + 24)) += uint64(2) + } else { + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed))) = int8('\\') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(1)))) = int8('u') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(2)))) = int8('0') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(3)))) = int8('0') + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(4)))) = **(**int8)(__ccgo_up(__ccgo_ts + 1726 + uintptr(libc.Int32FromUint8(c)>>int32(4)))) + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(p)).FnUsed+uint64(5)))) = **(**int8)(__ccgo_up(__ccgo_ts + 1726 + uintptr(libc.Int32FromUint8(c)&int32(0xf)))) + **(**Tu64)(__ccgo_up(p + 24)) += uint64(6) + } +} + +// C documentation +// +// /* +// ** Append the path name for the current element. +// */ +func _jsonAppendPathName(tls *libc.TLS, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var i, k, n Tu32 + var needQuote int32 + var z uintptr + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _ = i, k, n, needQuote, z + if libc.Int32FromUint8((*TJsonEachCursor)(unsafe.Pointer(p)).FeType) == int32(JSONB_ARRAY) { + _jsonPrintf(tls, int32(30), p+56, __ccgo_ts+26876, libc.VaList(bp+16, (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent + uintptr((*TJsonEachCursor)(unsafe.Pointer(p)).FnParent-uint32(1))*24))).FiKey)) + } else { + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + needQuote = 0 + n = _jsonbPayloadSize(tls, p+192, (*TJsonEachCursor)(unsafe.Pointer(p)).Fi, bp) + k = (*TJsonEachCursor)(unsafe.Pointer(p)).Fi + n + z = (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(k) + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z)))])&libc.Int32FromInt32(0x02) != 0) { + needQuote = int32(1) + } else { + i = uint32(0) + for { + if !(i < **(**Tu32)(__ccgo_up(bp))) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i))))])&libc.Int32FromInt32(0x06) != 0) { + needQuote = int32(1) + break + } + goto _1 + _1: + ; + i = i + 1 + } + } + if needQuote != 0 { + _jsonPrintf(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+uint32(4)), p+56, __ccgo_ts+26883, libc.VaList(bp+16, **(**Tu32)(__ccgo_up(bp)), z)) + } else { + _jsonPrintf(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+uint32(2)), p+56, __ccgo_ts+26891, libc.VaList(bp+16, **(**Tu32)(__ccgo_up(bp)), z)) + } + } +} + +// C documentation +// +// /* +// ** json_array_length(JSON) +// ** json_array_length(JSON, PATH) +// ** +// ** Return the number of elements in the top-level JSON array. +// ** Return 0 if the input is not a well-formed JSON array. +// */ +func _jsonArrayLengthFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var cnt Tsqlite3_int64 + var eErr Tu8 + var i Tu32 + var p, zPath, v1 uintptr + _, _, _, _, _, _ = cnt, eErr, i, p, zPath, v1 /* The parse */ + cnt = 0 + eErr = uint8(0) + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if p == uintptr(0) { + return + } + if argc == int32(2) { + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zPath == uintptr(0) { + _jsonParseFree(tls, p) + return + } + if int32(**(**int8)(__ccgo_up(zPath))) == int32('$') { + v1 = zPath + uintptr(1) + } else { + v1 = __ccgo_ts + 26603 + } + i = _jsonLookupStep(tls, p, uint32(0), v1, uint32(0)) + if i >= uint32(JSON_LOOKUP_PATHERROR) { + if i == uint32(JSON_LOOKUP_NOTFOUND) { + /* no-op */ + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(i)) + } + eErr = uint8(1) + i = uint32(0) + } + } else { + i = uint32(0) + } + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob + uintptr(i))))&int32(0x0f) == int32(JSONB_ARRAY) { + cnt = libc.Int64FromUint32(_jsonbArrayCount(tls, p, i)) + } + if !(eErr != 0) { + Xsqlite3_result_int64(tls, ctx, cnt) + } + _jsonParseFree(tls, p) +} + +// C documentation +// +// /* Constructor for the json_each virtual table */ +func _jsonEachConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + var pNew uintptr + var rc, v1 int32 + _, _, _ = pNew, rc, v1 + /* Column numbers */ + /* The xBestIndex method assumes that the JSON and ROOT columns are + ** the last two columns in the table. Should this ever changes, be + ** sure to update the xBestIndex method. */ + _ = pzErr + _ = argv + _ = argc + _ = pAux + rc = Xsqlite3_declare_vtab(tls, db, __ccgo_ts+26793) + if rc == SQLITE_OK { + pNew = _sqlite3DbMallocZero(tls, db, uint64(40)) + **(**uintptr)(__ccgo_up(ppVtab)) = pNew + if pNew == uintptr(0) { + return int32(SQLITE_NOMEM) + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + (*TJsonEachConnection)(unsafe.Pointer(pNew)).Fdb = db + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv)) + 4))) == int32('b') { + v1 = int32(2) + } else { + v1 = int32(1) + } + (*TJsonEachConnection)(unsafe.Pointer(pNew)).FeMode = libc.Uint8FromInt32(v1) + (*TJsonEachConnection)(unsafe.Pointer(pNew)).FbRecursive = libc.BoolUint8(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv)) + uintptr(int32(4)+libc.Int32FromUint8((*TJsonEachConnection)(unsafe.Pointer(pNew)).FeMode))))) == int32('t')) + } + return rc +} + +// C documentation +// +// /* Start a search on a new JSON string */ +func _jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, n, v1 Tu32 + var p, zRoot uintptr + var v2 int32 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _ = i, n, p, zRoot, v1, v2 + p = cur + zRoot = uintptr(0) + _ = idxStr + _ = argc + _jsonEachCursorReset(tls, p) + if idxNum == 0 { + return SQLITE_OK + } + libc.Xmemset(tls, p+192, 0, uint64(72)) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FnJPRef = uint32(1) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.Fdb = (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb + if _jsonArgIsJsonb(tls, **(**uintptr)(__ccgo_up(argv)), p+192) != 0 { + /* We have JSONB */ + } else { + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FnJson = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson == uintptr(0) { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + return SQLITE_OK + } + if _jsonConvertTextToBlob(tls, p+192, uintptr(0)) != 0 { + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.Foom != 0 { + return int32(SQLITE_NOMEM) + } + goto json_each_malformed_input + } + } + if idxNum == int32(3) { + zRoot = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) + if zRoot == uintptr(0) { + return SQLITE_OK + } + if int32(**(**int8)(__ccgo_up(zRoot))) != int32('$') { + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = _jsonBadPathError(tls, uintptr(0), zRoot, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot = libc.Uint32FromInt32(_sqlite3Strlen30(tls, zRoot)) + if int32(**(**int8)(__ccgo_up(zRoot + 1))) == 0 { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + i = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + } else { + i = _jsonLookupStep(tls, p+192, uint32(0), zRoot+uintptr(1), uint32(0)) + if i >= uint32(JSON_LOOKUP_PATHERROR) { + if i == uint32(JSON_LOOKUP_NOTFOUND) { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = uint32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = uint32(0) + return SQLITE_OK + } + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = _jsonBadPathError(tls, uintptr(0), zRoot, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 + } + if (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FiLabel != 0 { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = (*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FiLabel + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(JSONB_OBJECT) + } else { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(JSONB_ARRAY) + } + } + _jsonAppendRaw(tls, p+56, zRoot, (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot) + } else { + v1 = libc.Uint32FromInt32(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = v1 + i = v1 + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = uint8(0) + (*TJsonEachCursor)(unsafe.Pointer(p)).FnRoot = uint32(1) + _jsonAppendRaw(tls, p+56, __ccgo_ts+26897, uint32(1)) + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = uint32(0) + n = _jsonbPayloadSize(tls, p+192, i, bp) + (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd = i + n + **(**Tu32)(__ccgo_up(bp)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i))))&int32(0x0f) >= int32(JSONB_ARRAY) && !((*TJsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0) { + (*TJsonEachCursor)(unsafe.Pointer(p)).Fi = i + n + (*TJsonEachCursor)(unsafe.Pointer(p)).FeType = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FsParse.FaBlob + uintptr(i)))) & int32(0x0f)) + (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent = _sqlite3DbMallocZero(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb, uint64(24)) + if (*TJsonEachCursor)(unsafe.Pointer(p)).FaParent == uintptr(0) { + return int32(SQLITE_NOMEM) + } + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParent = uint32(1) + (*TJsonEachCursor)(unsafe.Pointer(p)).FnParentAlloc = uint32(1) + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiKey = 0 + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiEnd = (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiHead = (*TJsonEachCursor)(unsafe.Pointer(p)).Fi + (**(**TJsonParent)(__ccgo_up((*TJsonEachCursor)(unsafe.Pointer(p)).FaParent))).FiValue = i + } + return SQLITE_OK + goto json_each_malformed_input +json_each_malformed_input: + ; + Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) + (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26393, 0) + _jsonEachCursorReset(tls, p) + if (*Tsqlite3_vtab)(unsafe.Pointer((*Tsqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { + v2 = int32(SQLITE_ERROR) + } else { + v2 = int32(SQLITE_NOMEM) + } + return v2 +} + +// C documentation +// +// /* +// ** json_extract(JSON, PATH, ...) +// ** "->"(JSON,PATH) +// ** "->>"(JSON,PATH) +// ** +// ** Return the element described by PATH. Return NULL if that PATH element +// ** is not found. +// ** +// ** If JSON_JSON is set or if more that one PATH argument is supplied then +// ** always return a JSON representation of the result. If JSON_SQL is set, +// ** then always return an SQL representation of the result. If neither flag +// ** is present and argc==2, then return JSON for objects and arrays and SQL +// ** for all other values. +// ** +// ** When multiple PATH arguments are supplied, the result is a JSON array +// ** containing the result of each PATH. +// ** +// ** Abbreviated JSON path expressions are allows if JSON_ABPATH, for +// ** compatibility with PG. +// */ +func _jsonExtractFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var flags, i, nPath int32 + var j Tu32 + var p, zPath uintptr + var _ /* jx at bp+0 */ TJsonString + _, _, _, _, _, _ = flags, i, j, nPath, p, zPath + p = uintptr(0) /* String for array result */ + if argc < int32(2) { + return + } + p = _jsonParseFuncArg(tls, ctx, **(**uintptr)(__ccgo_up(argv)), uint32(0)) + if p == uintptr(0) { + return + } + flags = int32(int64(Xsqlite3_user_data(tls, ctx))) + _jsonStringInit(tls, bp, ctx) + if argc > int32(2) { + _jsonAppendChar(tls, bp, int8('[')) + } + i = int32(1) + for { + if !(i < argc) { + break + } + /* With a single PATH argument */ + zPath = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + if zPath == uintptr(0) { + goto json_extract_error + } + nPath = _sqlite3Strlen30(tls, zPath) + if int32(**(**int8)(__ccgo_up(zPath))) == int32('$') { + j = _jsonLookupStep(tls, p, uint32(0), zPath+uintptr(1), uint32(0)) + } else { + if flags&int32(JSON_ABPATH) != 0 { + /* The -> and ->> operators accept abbreviated PATH arguments. This + ** is mostly for compatibility with PostgreSQL, but also for + ** convenience. + ** + ** NUMBER ==> $[NUMBER] // PG compatible + ** LABEL ==> $.LABEL // PG compatible + ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience + ** + ** Updated 2024-05-27: If the NUMBER is negative, then PG counts from + ** the right of the array. Hence for negative NUMBER: + ** + ** NUMBER ==> $[#NUMBER] // PG compatible + */ + _jsonStringInit(tls, bp, ctx) + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) == int32(SQLITE_INTEGER) { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26605, uint32(1)) + if int32(**(**int8)(__ccgo_up(zPath))) == int32('-') { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26607, uint32(1)) + } + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+5312, uint32(2)) + } else { + if _jsonAllAlphanum(tls, zPath, nPath) != 0 { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+1743, uint32(1)) + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + } else { + if int32(**(**int8)(__ccgo_up(zPath))) == int32('[') && nPath >= int32(3) && int32(**(**int8)(__ccgo_up(zPath + uintptr(nPath-int32(1))))) == int32(']') { + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + } else { + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26609, uint32(2)) + _jsonAppendRaw(tls, bp, zPath, libc.Uint32FromInt32(nPath)) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+26612, uint32(1)) + } + } + } + _jsonStringTerminate(tls, bp) + j = _jsonLookupStep(tls, p, uint32(0), (**(**TJsonString)(__ccgo_up(bp))).FzBuf, uint32(0)) + _jsonStringReset(tls, bp) + } else { + _jsonBadPathError(tls, ctx, zPath, 0) + goto json_extract_error + } + } + if j < (*TJsonParse)(unsafe.Pointer(p)).FnBlob { + if argc == int32(2) { + if flags&int32(JSON_JSON) != 0 { + _jsonStringInit(tls, bp, ctx) + _jsonTranslateBlobToText(tls, p, j, bp) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + _jsonStringReset(tls, bp) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } else { + _jsonReturnFromBlob(tls, p, j, ctx, 0) + if flags&(libc.Int32FromInt32(JSON_SQL)|libc.Int32FromInt32(JSON_BLOB)) == 0 && libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FaBlob + uintptr(j))))&int32(0x0f) >= int32(JSONB_ARRAY) { + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } + } + } else { + _jsonAppendSeparator(tls, bp) + _jsonTranslateBlobToText(tls, p, j, bp) + } + } else { + if j == uint32(JSON_LOOKUP_NOTFOUND) { + if argc == int32(2) { + goto json_extract_error /* Return NULL if not found */ + } else { + _jsonAppendSeparator(tls, bp) + _jsonAppendRawNZ(tls, bp, __ccgo_ts+1690, uint32(4)) + } + } else { + _jsonBadPathError(tls, ctx, zPath, libc.Int32FromUint32(j)) + goto json_extract_error + } + } + goto _1 + _1: + ; + i = i + 1 + } + if argc > int32(2) { + _jsonAppendChar(tls, bp, int8(']')) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + if flags&int32(JSON_BLOB) == 0 { + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) + } + } + goto json_extract_error +json_extract_error: + ; + _jsonStringReset(tls, bp) + _jsonParseFree(tls, p) + return +} + +/* +** Return codes for jsonMergePatch() + */ + +// C documentation +// +// /* +// ** pArg is a function argument that might be an SQL value or a JSON +// ** value. Figure out what it is and encode it as a JSONB blob. +// ** Return the results in pParse. +// ** +// ** pParse is uninitialized upon entry. This routine will handle the +// ** initialization of pParse. The result will be contained in +// ** pParse->aBlob and pParse->nBlob. pParse->aBlob might be dynamically +// ** allocated (if pParse->nBlobAlloc is greater than zero) in which case +// ** the caller is responsible for freeing the space allocated to pParse->aBlob +// ** when it has finished with it. Or pParse->aBlob might be a static string +// ** or a value obtained from sqlite3_value_blob(pArg). +// ** +// ** If the argument is a BLOB that is clearly not a JSONB, then this +// ** function might set an error message in ctx and return non-zero. +// ** It might also set an error message and return non-zero on an OOM error. +// */ +func _jsonFunctionArgToBlob(tls *libc.TLS, ctx uintptr, pArg uintptr, pParse uintptr) (r1 int32) { + var eType, n, n1, nJson int32 + var r float64 + var z, z1, zJson uintptr + _, _, _, _, _, _, _, _ = eType, n, n1, nJson, r, z, z1, zJson + eType = Xsqlite3_value_type(tls, pArg) + libc.Xmemset(tls, pParse, 0, uint64(72)) + (*TJsonParse)(unsafe.Pointer(pParse)).Fdb = Xsqlite3_context_db_handle(tls, ctx) + switch eType { + default: + (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = uintptr(unsafe.Pointer(&_aNull)) + (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = uint32(1) + return 0 + case int32(SQLITE_BLOB): + if !(_jsonArgIsJsonb(tls, pArg, pParse) != 0) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26364, -int32(1)) + return int32(1) + } + case int32(SQLITE_TEXT): + zJson = Xsqlite3_value_text(tls, pArg) + nJson = Xsqlite3_value_bytes(tls, pArg) + if zJson == uintptr(0) { + return int32(1) + } + if Xsqlite3_value_subtype(tls, pArg) == uint32(JSON_SUBTYPE) { + (*TJsonParse)(unsafe.Pointer(pParse)).FzJson = zJson + (*TJsonParse)(unsafe.Pointer(pParse)).FnJson = nJson + if _jsonConvertTextToBlob(tls, pParse, ctx) != 0 { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26393, -int32(1)) + _sqlite3DbFree(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob) + libc.Xmemset(tls, pParse, 0, uint64(72)) + return int32(1) + } + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_TEXTRAW), libc.Uint64FromInt32(nJson), zJson) + } + case int32(SQLITE_FLOAT): + r = Xsqlite3_value_double(tls, pArg) + if _sqlite3IsNaN(tls, r) != 0 { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_NULL), uint64(0), uintptr(0)) + } else { + n = Xsqlite3_value_bytes(tls, pArg) + z = Xsqlite3_value_text(tls, pArg) + if z == uintptr(0) { + return int32(1) + } + if int32(**(**int8)(__ccgo_up(z))) == int32('I') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26498) + } else { + if int32(**(**int8)(__ccgo_up(z))) == int32('-') && int32(**(**int8)(__ccgo_up(z + 1))) == int32('I') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(6), __ccgo_ts+26491) + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), libc.Uint64FromInt32(n), z) + } + } + } + case int32(SQLITE_INTEGER): + n1 = Xsqlite3_value_bytes(tls, pArg) + z1 = Xsqlite3_value_text(tls, pArg) + if z1 == uintptr(0) { + return int32(1) + } + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_INT), libc.Uint64FromInt32(n1), z1) + break + } + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + Xsqlite3_result_error_nomem(tls, ctx) + return int32(1) + } else { + return 0 + } + return r1 +} + +// C documentation +// +// /* +// ** Search along zPath to find the Json element specified. Return an +// ** index into pParse->aBlob[] for the start of that element's value. +// ** +// ** If the value found by this routine is the value half of label/value pair +// ** within an object, then set pPath->iLabel to the start of the corresponding +// ** label, before returning. +// ** +// ** Return one of the JSON_LOOKUP error codes if problems are seen. +// ** +// ** This routine will also modify the blob. If pParse->eEdit is one of +// ** JEDIT_DEL, JEDIT_REPL, JEDIT_INS, JEDIT_SET, or JEDIT_AINS, then changes +// ** might be made to the selected value. If an edit is performed, then the +// ** return value does not necessarily point to the select element. If an edit +// ** is performed, the return value is only useful for detecting error +// ** conditions. +// */ +func _jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot Tu32, zPath uintptr, iLabel Tu32) (r Tu32) { + bp := tls.Alloc(224) + defer tls.Free(224) + var i, iEnd, j, k, n, nIns, nKey, rc, v Tu32 + var kk, nn Tu64 + var rawKey, rawLabel, v5 int32 + var x Tu8 + var zKey, zLabel, v4 uintptr + var v3 Tu16 + var _ /* ix at bp+80 */ TJsonParse + var _ /* sz at bp+0 */ Tu32 + var _ /* v at bp+152 */ TJsonParse + var _ /* v at bp+8 */ TJsonParse + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, iEnd, j, k, kk, n, nIns, nKey, nn, rawKey, rawLabel, rc, v, x, zKey, zLabel, v3, v4, v5 + if int32(**(**int8)(__ccgo_up(zPath))) == 0 { + if (*TJsonParse)(unsafe.Pointer(pParse)).FeEdit != 0 && _jsonBlobMakeEditable(tls, pParse, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) != 0 { + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + n + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_DEL) { + if iLabel > uint32(0) { + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + (iRoot - iLabel) + iRoot = iLabel + } + _jsonBlobEdit(tls, pParse, iRoot, **(**Tu32)(__ccgo_up(bp)), uintptr(0), uint32(0)) + } else { + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_INS) { + /* Already exists, so json_insert() is a no-op */ + } else { + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_AINS) { + /* json_array_insert() */ + if int32(**(**int8)(__ccgo_up(zPath + uintptr(-libc.Int32FromInt32(1))))) != int32(']') { + return uint32(JSON_LOOKUP_NOTARRAY) + } else { + _jsonBlobEdit(tls, pParse, iRoot, uint32(0), (*TJsonParse)(unsafe.Pointer(pParse)).FaIns, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) + } + } else { + /* json_set() or json_replace() */ + _jsonBlobEdit(tls, pParse, iRoot, **(**Tu32)(__ccgo_up(bp)), (*TJsonParse)(unsafe.Pointer(pParse)).FaIns, (*TJsonParse)(unsafe.Pointer(pParse)).FnIns) + } + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiLabel = iLabel + return iRoot + } + if int32(**(**int8)(__ccgo_up(zPath))) == int32('.') { + rawKey = int32(1) + x = **(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iRoot))) + zPath = zPath + 1 + if int32(**(**int8)(__ccgo_up(zPath))) == int32('"') { + zKey = zPath + uintptr(1) + i = uint32(1) + for { + if !(**(**int8)(__ccgo_up(zPath + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32('"')) { + break + } + if int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) == int32('\\') && int32(**(**int8)(__ccgo_up(zPath + uintptr(i+uint32(1))))) != 0 { + i = i + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + nKey = i - uint32(1) + if **(**int8)(__ccgo_up(zPath + uintptr(i))) != 0 { + i = i + 1 + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + rawKey = libc.BoolInt32(libc.Xmemchr(tls, zKey, int32('\\'), uint64(nKey)) == uintptr(0)) + } else { + zKey = zPath + i = uint32(0) + for { + if !(**(**int8)(__ccgo_up(zPath + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32('.') && int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32('[')) { + break + } + goto _2 + _2: + ; + i = i + 1 + } + nKey = i + if nKey == uint32(0) { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + if libc.Int32FromUint8(x)&int32(0x0f) != int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + j = iRoot + n /* j is the index of a label */ + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + for j < iEnd { + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(j)))) & int32(0x0f)) + if libc.Int32FromUint8(x) < int32(JSONB_TEXT) || libc.Int32FromUint8(x) > int32(JSONB_TEXTRAW) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + k = j + n /* k is the index of the label text */ + if k+**(**Tu32)(__ccgo_up(bp)) >= iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + zLabel = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(k) + rawLabel = libc.BoolInt32(libc.Int32FromUint8(x) == int32(JSONB_TEXT) || libc.Int32FromUint8(x) == int32(JSONB_TEXTRAW)) + if _jsonLabelCompare(tls, zKey, nKey, rawKey, zLabel, **(**Tu32)(__ccgo_up(bp)), rawLabel) != 0 { + v = k + **(**Tu32)(__ccgo_up(bp)) /* v is the index of the value */ + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(v))))&int32(0x0f) > int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, v, bp) + if n == uint32(0) || v+n+**(**Tu32)(__ccgo_up(bp)) > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + v4 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v4)) = *(*Tu16)(unsafe.Pointer(v4)) + 1 + v3 = *(*Tu16)(unsafe.Pointer(v4)) + if libc.Int32FromUint16(v3) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = _jsonLookupStep(tls, pParse, v, zPath+uintptr(i), j) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + j = k + **(**Tu32)(__ccgo_up(bp)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(j))))&int32(0x0f) > int32(JSONB_OBJECT) { + return uint32(JSON_LOOKUP_ERROR) + } + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + if j > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) >= int32(JEDIT_INS) { /* Header of the label to be inserted */ + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) == int32(JEDIT_AINS) && Xsqlite3_strglob(tls, __ccgo_ts+26538, zPath+uintptr(i)) != 0 { + return uint32(JSON_LOOKUP_NOTARRAY) + } + libc.Xmemset(tls, bp+80, 0, uint64(72)) + (**(**TJsonParse)(__ccgo_up(bp + 80))).Fdb = (*TJsonParse)(unsafe.Pointer(pParse)).Fdb + if rawKey != 0 { + v5 = int32(JSONB_TEXTRAW) + } else { + v5 = int32(JSONB_TEXT5) + } + _jsonBlobAppendNode(tls, bp+80, libc.Uint8FromInt32(v5), uint64(nKey), uintptr(0)) + v4 = pParse + 47 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v4))) | libc.Int32FromUint8((**(**TJsonParse)(__ccgo_up(bp + 80))).Foom)) + rc = _jsonCreateEditSubstructure(tls, pParse, bp+8, zPath+uintptr(i)) + if !(rc >= libc.Uint32FromUint32(JSON_LOOKUP_PATHERROR)) && _jsonBlobMakeEditable(tls, pParse, (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob+nKey+(**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob) != 0 { + nIns = (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob + nKey + (**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob + _jsonBlobEdit(tls, pParse, j, uint32(0), uintptr(0), nIns) + if !((*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0) { + /* Because pParse->oom!=0 */ + /* Because pPasre->oom!=0 */ + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(j), (**(**TJsonParse)(__ccgo_up(bp + 80))).FaBlob, uint64((**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob)) + k = j + (**(**TJsonParse)(__ccgo_up(bp + 80))).FnBlob + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(k), zKey, uint64(nKey)) + k = k + nKey + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(k), (**(**TJsonParse)(__ccgo_up(bp + 8))).FaBlob, uint64((**(**TJsonParse)(__ccgo_up(bp + 8))).FnBlob)) + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + } + } + _jsonParseReset(tls, bp+8) + _jsonParseReset(tls, bp+80) + return rc + } + } else { + if int32(**(**int8)(__ccgo_up(zPath))) == int32('[') { + kk = uint64(0) + x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iRoot)))) & int32(0x0f)) + if libc.Int32FromUint8(x) != int32(JSONB_ARRAY) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + n = _jsonbPayloadSize(tls, pParse, iRoot, bp) + i = uint32(1) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zPath + uintptr(i))))])&int32(0x04) != 0 { + if kk < uint64(0xffffffff) { + kk = kk*uint64(10) + libc.Uint64FromInt8(**(**int8)(__ccgo_up(zPath + uintptr(i)))) - uint64('0') + } + /* ^^^^^^^^^^--- Allow kk to be bigger than any JSON array so that + ** we get NOTFOUND instead of PATHERROR, without overflowing kk. */ + i = i + 1 + } + if i < uint32(2) || int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32(']') { + if int32(**(**int8)(__ccgo_up(zPath + 1))) == int32('#') { + kk = uint64(_jsonbArrayCount(tls, pParse, iRoot)) + i = uint32(2) + if int32(**(**int8)(__ccgo_up(zPath + 2))) == int32('-') && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zPath + 3)))])&int32(0x04) != 0 { + nn = uint64(0) + i = uint32(3) + for cond := true; cond; cond = libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zPath + uintptr(i))))])&int32(0x04) != 0 { + if nn < uint64(0xffffffff) { + nn = nn*uint64(10) + libc.Uint64FromInt8(**(**int8)(__ccgo_up(zPath + uintptr(i)))) - uint64('0') + } + /* ^^^^^^^^^^--- Allow nn to be bigger than any JSON array to + ** get NOTFOUND instead of PATHERROR, without overflowing nn. */ + i = i + 1 + } + if nn > kk { + return uint32(JSON_LOOKUP_NOTFOUND) + } + kk = kk - nn + } + if int32(**(**int8)(__ccgo_up(zPath + uintptr(i)))) != int32(']') { + return uint32(JSON_LOOKUP_PATHERROR) + } + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + j = iRoot + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + for j < iEnd { + if kk == uint64(0) { + v4 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v4)) = *(*Tu16)(unsafe.Pointer(v4)) + 1 + v3 = *(*Tu16)(unsafe.Pointer(v4)) + if libc.Int32FromUint16(v3) >= int32(JSON_MAX_DEPTH) { + return uint32(JSON_LOOKUP_TOODEEP) + } + rc = _jsonLookupStep(tls, pParse, j, zPath+uintptr(i+uint32(1)), uint32(0)) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + kk = kk - 1 + n = _jsonbPayloadSize(tls, pParse, j, bp) + if n == uint32(0) { + return uint32(JSON_LOOKUP_ERROR) + } + j = j + (n + **(**Tu32)(__ccgo_up(bp))) + } + if j > iEnd { + return uint32(JSON_LOOKUP_ERROR) + } + if kk > uint64(0) { + return uint32(JSON_LOOKUP_NOTFOUND) + } + if libc.Int32FromUint8((*TJsonParse)(unsafe.Pointer(pParse)).FeEdit) >= int32(JEDIT_INS) { + rc = _jsonCreateEditSubstructure(tls, pParse, bp+152, zPath+uintptr(i+uint32(1))) + if !(rc >= libc.Uint32FromUint32(JSON_LOOKUP_PATHERROR)) && _jsonBlobMakeEditable(tls, pParse, (**(**TJsonParse)(__ccgo_up(bp + 152))).FnBlob) != 0 { + _jsonBlobEdit(tls, pParse, j, uint32(0), (**(**TJsonParse)(__ccgo_up(bp + 152))).FaBlob, (**(**TJsonParse)(__ccgo_up(bp + 152))).FnBlob) + } + _jsonParseReset(tls, bp+152) + if (*TJsonParse)(unsafe.Pointer(pParse)).Fdelta != 0 { + _jsonAfterEditSizeAdjust(tls, pParse, iRoot) + } + return rc + } + } else { + return uint32(JSON_LOOKUP_PATHERROR) + } + } + return uint32(JSON_LOOKUP_NOTFOUND) +} + +func _jsonObjectCompute(tls *libc.TLS, ctx uintptr, isFinal int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var c int8 + var flags, inStr int32 + var i, j, v2, v3 Tu64 + var pOgStr, pStr uintptr + var v8 Tsqlite3_destructor_type + var _ /* tmpStr at bp+0 */ TJsonString + _, _, _, _, _, _, _, _, _, _ = c, flags, i, inStr, j, pOgStr, pStr, v2, v3, v8 + flags = int32(int64(Xsqlite3_user_data(tls, ctx))) + pStr = Xsqlite3_aggregate_context(tls, ctx, 0) + if pStr != 0 { + pOgStr = pStr + _jsonAppendRawNZ(tls, pOgStr, __ccgo_ts+26788, uint32(2)) /* Ensure it is zero-terminated */ + _jsonStringTrimOneChar(tls, pOgStr) /* Remove the zero terminator */ + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + if (*TJsonString)(unsafe.Pointer(pStr)).FeErr != 0 { + _jsonReturnString(tls, pStr, uintptr(0), uintptr(0)) + return + } + if int32(**(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf))) != int32('{') { + inStr = 0 + if !(isFinal != 0) { + /* Work with a temporary copy of the string if this is not the + ** final result */ + _jsonStringInit(tls, bp, ctx) + _jsonAppendRawNZ(tls, bp, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, uint32((*TJsonString)(unsafe.Pointer(pStr)).FnUsed+uint64(1))) + pStr = bp + if (*TJsonString)(unsafe.Pointer(pStr)).FeErr != 0 { + _jsonReturnString(tls, pStr, uintptr(0), uintptr(0)) + return + } + _jsonStringTrimOneChar(tls, pStr) /* Remove zero terminator */ + } + /* Fix up the string by changing the initial "@" flag back to + ** to "{" and removing all subsequence "@" entries, with their + ** associated comma delimeters. */ + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf)) = int8('{') + v2 = libc.Uint64FromInt32(1) + j = v2 + i = v2 + for { + if !(i < (*TJsonString)(unsafe.Pointer(pStr)).FnUsed) { + break + } + c = **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(i))) + if int32(c) == int32('"') { + inStr = libc.BoolInt32(!(inStr != 0)) + v2 = j + j = j + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = int8('"') + } else { + if int32(c) == int32('\\') { + v2 = j + j = j + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = int8('\\') + v2 = j + j = j + 1 + i = i + 1 + v3 = i + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v3))) + } else { + if int32(c) == int32('@') && !(inStr != 0) { + if int32(**(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(i+uint64(1))))) == int32(',') { + i = i + 1 + } else { + if int32(**(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(j-uint64(1))))) == int32(',') { + j = j - 1 + } + } + } else { + v2 = j + j = j + 1 + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(v2))) = c + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf + uintptr(j))) = 0 /* Restore zero terminator */ + (*TJsonString)(unsafe.Pointer(pStr)).FnUsed = j /* Truncate the string */ + } + if flags&int32(JSON_BLOB) != 0 { + _jsonReturnStringAsBlob(tls, pStr) + if isFinal != 0 { + if !((*TJsonString)(unsafe.Pointer(pStr)).FbStatic != 0) { + _sqlite3RCStrUnref(tls, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf) + } + } else { + _jsonStringTrimOneChar(tls, pOgStr) + } + } else { + if isFinal != 0 { + if (*TJsonString)(unsafe.Pointer(pStr)).FbStatic != 0 { + v8 = uintptr(-libc.Int32FromInt32(1)) + } else { + v8 = __ccgo_fp(_sqlite3RCStrUnref) + } + Xsqlite3_result_text(tls, ctx, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed), v8) + (*TJsonString)(unsafe.Pointer(pStr)).FbStatic = uint8(1) + } else { + Xsqlite3_result_text(tls, ctx, (*TJsonString)(unsafe.Pointer(pStr)).FzBuf, libc.Int32FromUint64((*TJsonString)(unsafe.Pointer(pStr)).FnUsed), uintptr(-libc.Int32FromInt32(1))) + _jsonStringTrimOneChar(tls, pOgStr) + } + } + if pStr != pOgStr { + _jsonStringReset(tls, pStr) + } + } else { + if flags&int32(JSON_BLOB) != 0 { + Xsqlite3_result_blob(tls, ctx, uintptr(unsafe.Pointer(&_emptyObject1)), int32(1), libc.UintptrFromInt32(0)) + } else { + Xsqlite3_result_text(tls, ctx, __ccgo_ts+26790, int32(2), libc.UintptrFromInt32(0)) + } + } + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /* +// ** Implementation of the json_object(NAME,VALUE,...) function. Return a JSON +// ** object that contains all name/value given in arguments. Or if any name +// ** is not a string or if any value is a BLOB, throw an error. +// */ +func _jsonObjectFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var i int32 + var n Tu32 + var z uintptr + var _ /* jx at bp+0 */ TJsonString + _, _, _ = i, n, z + if argc&int32(1) != 0 { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26614, -int32(1)) + return + } + _jsonStringInit(tls, bp, ctx) + _jsonAppendChar(tls, bp, int8('{')) + i = 0 + for { + if !(i < argc) { + break + } + if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) != int32(SQLITE_TEXT) { + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26665, -int32(1)) + _jsonStringReset(tls, bp) + return + } + _jsonAppendSeparator(tls, bp) + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8))) + n = libc.Uint32FromInt32(Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv + uintptr(i)*8)))) + _jsonAppendString(tls, bp, z, n) + _jsonAppendChar(tls, bp, int8(':')) + _jsonAppendSqlValue(tls, bp, **(**uintptr)(__ccgo_up(argv + uintptr(i+int32(1))*8))) + goto _1 + _1: + ; + i = i + int32(2) + } + _jsonAppendChar(tls, bp, int8('}')) + _jsonReturnString(tls, bp, uintptr(0), uintptr(0)) + Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE)) +} + +// C documentation +// +// /* +// ** json_group_obj(NAME,VALUE) +// ** +// ** Return a JSON object composed of all names and values in the aggregate. +// ** +// ** Rows for which NAME is NULL do not result in a new entry. However, we +// ** do initially insert a "@" entry into the growing string for each null entry +// ** and change the first character of the string to "@" to signal that the +// ** string contains null entries. The "@" markers are needed in order to +// ** correctly process xInverse() requests. The initial "@" is converted +// ** back into "{" and the "@" null values are removed by jsonObjectCompute(). +// */ +func _jsonObjectStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + var n Tu32 + var pStr, z uintptr + _, _, _ = n, pStr, z + _ = argc + pStr = Xsqlite3_aggregate_context(tls, ctx, int32(136)) + if pStr != 0 { + z = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + n = libc.Uint32FromInt32(_sqlite3Strlen30(tls, z)) + if (*TJsonString)(unsafe.Pointer(pStr)).FzBuf == uintptr(0) { + _jsonStringInit(tls, pStr, ctx) + _jsonAppendChar(tls, pStr, int8('{')) + } else { + if (*TJsonString)(unsafe.Pointer(pStr)).FnUsed > uint64(1) { + _jsonAppendChar(tls, pStr, int8(',')) + } + } + (*TJsonString)(unsafe.Pointer(pStr)).FpCtx = ctx + if z != uintptr(0) { + _jsonAppendString(tls, pStr, z, n) + _jsonAppendChar(tls, pStr, int8(':')) + _jsonAppendSqlValue(tls, pStr, **(**uintptr)(__ccgo_up(argv + 1*8))) + } else { + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pStr)).FzBuf)) = int8('@') + _jsonAppendRawNZ(tls, pStr, __ccgo_ts+26603, uint32(1)) + } + } +} + +// C documentation +// +// /* +// ** Generate a JsonParse object, containing valid JSONB in aBlob and nBlob, +// ** from the SQL function argument pArg. Return a pointer to the new +// ** JsonParse object. +// ** +// ** Ownership of the new JsonParse object is passed to the caller. The +// ** caller should invoke jsonParseFree() on the return value when it +// ** has finished using it. +// ** +// ** If any errors are detected, an appropriate error messages is set +// ** using sqlite3_result_error() or the equivalent and this routine +// ** returns NULL. This routine also returns NULL if the pArg argument +// ** is an SQL NULL value, but no error message is set in that case. This +// ** is so that SQL functions that are given NULL arguments will return +// ** a NULL value. +// */ +func _jsonParseFuncArg(tls *libc.TLS, ctx uintptr, pArg uintptr, flgs Tu32) (r uintptr) { + var db, p, pFromCache, zNew, v2 uintptr + var eType, isRCStr, rc int32 + var nBlob, v1 Tu32 + _, _, _, _, _, _, _, _, _, _ = db, eType, isRCStr, nBlob, p, pFromCache, rc, zNew, v1, v2 /* Datatype of pArg */ + p = uintptr(0) /* Value to be returned */ + pFromCache = uintptr(0) /* The database connection */ + eType = Xsqlite3_value_type(tls, pArg) + if eType == int32(SQLITE_NULL) { + return uintptr(0) + } + pFromCache = _jsonCacheSearch(tls, ctx, pArg) + if pFromCache != 0 { + (*TJsonParse)(unsafe.Pointer(pFromCache)).FnJPRef = (*TJsonParse)(unsafe.Pointer(pFromCache)).FnJPRef + 1 + if flgs&uint32(JSON_EDITABLE) == uint32(0) { + return pFromCache + } + } + db = Xsqlite3_context_db_handle(tls, ctx) + goto rebuild_from_cache +rebuild_from_cache: + ; + p = _sqlite3DbMallocZero(tls, db, uint64(72)) + if p == uintptr(0) { + goto json_pfa_oom + } + libc.Xmemset(tls, p, 0, uint64(72)) + (*TJsonParse)(unsafe.Pointer(p)).Fdb = db + (*TJsonParse)(unsafe.Pointer(p)).FnJPRef = uint32(1) + if pFromCache != uintptr(0) { + nBlob = (*TJsonParse)(unsafe.Pointer(pFromCache)).FnBlob + (*TJsonParse)(unsafe.Pointer(p)).FaBlob = _sqlite3DbMallocRaw(tls, db, uint64(nBlob)) + if (*TJsonParse)(unsafe.Pointer(p)).FaBlob == uintptr(0) { + goto json_pfa_oom + } + libc.Xmemcpy(tls, (*TJsonParse)(unsafe.Pointer(p)).FaBlob, (*TJsonParse)(unsafe.Pointer(pFromCache)).FaBlob, uint64(nBlob)) + v1 = nBlob + (*TJsonParse)(unsafe.Pointer(p)).FnBlob = v1 + (*TJsonParse)(unsafe.Pointer(p)).FnBlobAlloc = v1 + (*TJsonParse)(unsafe.Pointer(p)).FhasNonstd = (*TJsonParse)(unsafe.Pointer(pFromCache)).FhasNonstd + _jsonParseFree(tls, pFromCache) + return p + } + if eType == int32(SQLITE_BLOB) { + if _jsonArgIsJsonb(tls, pArg, p) != 0 { + if flgs&uint32(JSON_EDITABLE) != uint32(0) && _jsonBlobMakeEditable(tls, p, uint32(0)) == 0 { + goto json_pfa_oom + } + return p + } + /* If the blob is not valid JSONB, fall through into trying to cast + ** the blob into text which is then interpreted as JSON. (tag-20240123-a) + ** + ** This goes against all historical documentation about how the SQLite + ** JSON functions were suppose to work. From the beginning, blob was + ** reserved for expansion and a blob value should have raised an error. + ** But it did not, due to a bug. And many applications came to depend + ** upon this buggy behavior, especially when using the CLI and reading + ** JSON text using readfile(), which returns a blob. For this reason + ** we will continue to support the bug moving forward. + ** See for example https://sqlite.org/forum/forumpost/012136abd5292b8d + */ + } + (*TJsonParse)(unsafe.Pointer(p)).FzJson = Xsqlite3_value_text(tls, pArg) + (*TJsonParse)(unsafe.Pointer(p)).FnJson = Xsqlite3_value_bytes(tls, pArg) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto json_pfa_oom + } + if (*TJsonParse)(unsafe.Pointer(p)).FnJson == 0 { + goto json_pfa_malformed + } + if flgs&uint32(JSON_KEEPERROR) != 0 { + v2 = uintptr(0) + } else { + v2 = ctx + } + if _jsonConvertTextToBlob(tls, p, v2) != 0 { + if flgs&uint32(JSON_KEEPERROR) != 0 { + (*TJsonParse)(unsafe.Pointer(p)).FnErr = uint8(1) + return p + } else { + _jsonParseFree(tls, p) + return uintptr(0) + } + } else { + isRCStr = _sqlite3ValueIsOfClass(tls, pArg, __ccgo_fp(_sqlite3RCStrUnref)) + if !(isRCStr != 0) { + zNew = _sqlite3RCStrNew(tls, libc.Uint64FromInt32((*TJsonParse)(unsafe.Pointer(p)).FnJson)) + if zNew == uintptr(0) { + goto json_pfa_oom + } + libc.Xmemcpy(tls, zNew, (*TJsonParse)(unsafe.Pointer(p)).FzJson, libc.Uint64FromInt32((*TJsonParse)(unsafe.Pointer(p)).FnJson)) + (*TJsonParse)(unsafe.Pointer(p)).FzJson = zNew + **(**int8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(p)).FzJson + uintptr((*TJsonParse)(unsafe.Pointer(p)).FnJson))) = 0 + } else { + _sqlite3RCStrRef(tls, (*TJsonParse)(unsafe.Pointer(p)).FzJson) + } + (*TJsonParse)(unsafe.Pointer(p)).FbJsonIsRCStr = uint8(1) + rc = _jsonCacheInsert(tls, ctx, p) + if rc == int32(SQLITE_NOMEM) { + goto json_pfa_oom + } + if flgs&uint32(JSON_EDITABLE) != 0 { + pFromCache = p + p = uintptr(0) + goto rebuild_from_cache + } + } + return p + goto json_pfa_malformed +json_pfa_malformed: + ; + if flgs&uint32(JSON_KEEPERROR) != 0 { + (*TJsonParse)(unsafe.Pointer(p)).FnErr = uint8(1) + return p + } else { + _jsonParseFree(tls, p) + Xsqlite3_result_error(tls, ctx, __ccgo_ts+26393, -int32(1)) + return uintptr(0) + } + goto json_pfa_oom +json_pfa_oom: + ; + _jsonParseFree(tls, pFromCache) + _jsonParseFree(tls, p) + Xsqlite3_result_error_nomem(tls, ctx) + return uintptr(0) +} + +// C documentation +// +// /* +// ** Return the value of the BLOB node at index i. +// ** +// ** If the value is a primitive, return it as an SQL value. +// ** If the value is an array or object, return it as either +// ** JSON text or the BLOB encoding, depending on the eMode flag +// ** as follows: +// ** +// ** eMode==0 JSONB if the JSON_B flag is set in userdata or +// ** text if the JSON_B flag is omitted from userdata. +// ** +// ** eMode==1 Text +// ** +// ** eMode==2 JSONB +// */ +func _jsonReturnFromBlob(tls *libc.TLS, pParse uintptr, i Tu32, pCtx uintptr, eMode int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bNeg, rc int32 + var c, x int8 + var db, z, z1, z2, zOut uintptr + var iIn, iOut, n, nOut, szEscape, v19, v20 Tu32 + var r, v16 float64 + var v17 int64 + var _ /* iRes at bp+8 */ Tsqlite3_int64 + var _ /* r at bp+16 */ float64 + var _ /* sz at bp+0 */ Tu32 + var _ /* v at bp+24 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNeg, c, db, iIn, iOut, n, nOut, r, rc, szEscape, x, z, z1, z2, zOut, v16, v17, v19, v20 + db = Xsqlite3_context_db_handle(tls, pCtx) + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26393, -int32(1)) + return + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case JSONB_NULL: + goto _1 + case int32(JSONB_TRUE): + goto _2 + case int32(JSONB_FALSE): + goto _3 + case int32(JSONB_INT): + goto _4 + case int32(JSONB_INT5): + goto _5 + case int32(JSONB_FLOAT): + goto _6 + case int32(JSONB_FLOAT5): + goto _7 + case int32(JSONB_TEXT): + goto _8 + case int32(JSONB_TEXTRAW): + goto _9 + case int32(JSONB_TEXTJ): + goto _10 + case int32(JSONB_TEXT5): + goto _11 + case int32(JSONB_OBJECT): + goto _12 + case int32(JSONB_ARRAY): + goto _13 + default: + goto _14 + } + goto _15 +_1: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_null(tls, pCtx) + goto _15 +_2: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_int(tls, pCtx, int32(1)) + goto _15 +_3: + ; + if **(**Tu32)(__ccgo_up(bp)) != 0 { + goto returnfromblob_malformed + } + Xsqlite3_result_int(tls, pCtx, 0) + goto _15 +_5: + ; +_4: + ; + **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0 + bNeg = 0 + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto returnfromblob_malformed + } + x = libc.Int8FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n)))) + if int32(x) == int32('-') { + if **(**Tu32)(__ccgo_up(bp)) < uint32(2) { + goto returnfromblob_malformed + } + n = n + 1 + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) - 1 + bNeg = int32(1) + } + z = _sqlite3DbStrNDup(tls, db, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), libc.Uint64FromInt32(libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))))) + if z == uintptr(0) { + goto returnfromblob_oom + } + rc = _sqlite3DecOrHexToI64(tls, z, bp+8) + _sqlite3DbFree(tls, db, z) + if rc == 0 { + if **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) < 0 { + r = float64(**(**Tsqlite3_uint64)(__ccgo_up(bp + 8))) + if bNeg != 0 { + v16 = -r + } else { + v16 = r + } + Xsqlite3_result_double(tls, pCtx, v16) + } else { + if bNeg != 0 { + v17 = -**(**Tsqlite3_int64)(__ccgo_up(bp + 8)) + } else { + v17 = **(**Tsqlite3_int64)(__ccgo_up(bp + 8)) + } + Xsqlite3_result_int64(tls, pCtx, v17) + } + } else { + if rc == int32(3) && bNeg != 0 { + Xsqlite3_result_int64(tls, pCtx, int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>libc.Int32FromInt32(6)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } else { + if **(**Tu32)(__ccgo_up(bp + 24)) < uint32(0x10000) { + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0xe0) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(12)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(6)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } else { + if **(**Tu32)(__ccgo_up(bp + 24)) == uint32(JSON_INVALID_CHAR) { + /* Silently ignore illegal unicode */ + } else { + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0xf0) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(18)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(12)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))>>libc.Int32FromInt32(6)&uint32(0x3f)) + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = libc.Int8FromUint32(uint32(0x80) | **(**Tu32)(__ccgo_up(bp + 24))&uint32(0x3f)) + } + } + } + } + iIn = iIn + (szEscape - uint32(1)) + } else { + v19 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v19))) = c + } + goto _18 + _18: + ; + iIn = iIn + 1 + } /* end for() */ + **(**int8)(__ccgo_up(zOut + uintptr(iOut))) = 0 + Xsqlite3_result_text(tls, pCtx, zOut, libc.Int32FromUint32(iOut), __ccgo_fp(_sqlite3RowSetClear)) + goto _15 +_13: + ; +_12: + ; + if eMode == 0 { + if int32(int64(Xsqlite3_user_data(tls, pCtx)))&int32(JSON_BLOB) != 0 { + eMode = int32(2) + } else { + eMode = int32(1) + } + } + if eMode == int32(2) { + Xsqlite3_result_blob(tls, pCtx, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i), libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp))+n), uintptr(-libc.Int32FromInt32(1))) + } else { + _jsonReturnTextJsonFromBlob(tls, pCtx, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i), **(**Tu32)(__ccgo_up(bp))+n) + } + goto _15 +_14: + ; + goto returnfromblob_malformed +_15: + ; + return + goto returnfromblob_oom +returnfromblob_oom: + ; + Xsqlite3_result_error_nomem(tls, pCtx) + return + goto returnfromblob_malformed +returnfromblob_malformed: + ; + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26393, -int32(1)) + return +} + +// C documentation +// +// /* +// ** Translate the binary JSONB representation of JSON beginning at +// ** pParse->aBlob[i] into a JSON text string. Append the JSON +// ** text onto the end of pOut. Return the index in pParse->aBlob[] +// ** of the first byte past the end of the element that is translated. +// ** +// ** This is a variant of jsonTranslateBlobToText() that "pretty-prints" +// ** the output. Extra whitespace is inserted to make the JSON easier +// ** for humans to read. +// ** +// ** If an error is detected in the BLOB input, the pOut->eErr flag +// ** might get set to JSTRING_MALFORMED. But not all BLOB input errors +// ** are detected. So a malformed JSONB input might either result +// ** in an error, or in incorrect JSON. +// ** +// ** The pOut->eErr JSTRING_OOM flag is set on a OOM. +// */ +func _jsonTranslateBlobToPrettyText(tls *libc.TLS, pPretty uintptr, i Tu32) (r Tu32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iEnd, j, n Tu32 + var pOut, pParse, v1 uintptr + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _ = iEnd, j, n, pOut, pParse, v1 + pParse = (*TJsonPretty)(unsafe.Pointer(pPretty)).FpParse + pOut = (*TJsonPretty)(unsafe.Pointer(pPretty)).FpOut + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + return (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + uint32(1) + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case int32(JSONB_ARRAY): + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + _jsonAppendChar(tls, pOut, int8('[')) + if j < iEnd { + _jsonAppendChar(tls, pOut, int8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent + 1 + if (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent >= uint32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + _jsonPrettyIndent(tls, pPretty) + j = _jsonTranslateBlobToPrettyText(tls, pPretty, j) + if j >= iEnd { + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26532, uint32(2)) + } + _jsonAppendChar(tls, pOut, int8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent - 1 + _jsonPrettyIndent(tls, pPretty) + } + _jsonAppendChar(tls, pOut, int8(']')) + i = iEnd + case int32(JSONB_OBJECT): + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + _jsonAppendChar(tls, pOut, int8('{')) + if j < iEnd { + _jsonAppendChar(tls, pOut, int8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent + 1 + if (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent >= uint32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = uint16((*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent) + for libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + _jsonPrettyIndent(tls, pPretty) + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + if j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26535, uint32(2)) + j = _jsonTranslateBlobToPrettyText(tls, pPretty, j) + if j >= iEnd { + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26532, uint32(2)) + } + _jsonAppendChar(tls, pOut, int8('\n')) + (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent = (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent - 1 + _jsonPrettyIndent(tls, pPretty) + } + _jsonAppendChar(tls, pOut, int8('}')) + i = iEnd + default: + i = _jsonTranslateBlobToText(tls, pParse, i, pOut) + break + } + return i +} + +// C documentation +// +// /* +// ** Translate the binary JSONB representation of JSON beginning at +// ** pParse->aBlob[i] into a JSON text string. Append the JSON +// ** text onto the end of pOut. Return the index in pParse->aBlob[] +// ** of the first byte past the end of the element that is translated. +// ** +// ** If an error is detected in the BLOB input, the pOut->eErr flag +// ** might get set to JSTRING_MALFORMED. But not all BLOB input errors +// ** are detected. So a malformed JSONB input might either result +// ** in an error, or in incorrect JSON. +// ** +// ** The pOut->eErr JSTRING_OOM flag is set on a OOM. +// */ +func _jsonTranslateBlobToText(tls *libc.TLS, pParse uintptr, i Tu32, pOut uintptr) (r Tu32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOverflow, x, v30, v31 int32 + var iEnd, j, k, k1, k2, n, sz2 Tu32 + var u Tsqlite3_uint64 + var zIn, zIn1, zIn2, v1 uintptr + var v25 Tu16 + var _ /* sz at bp+0 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bOverflow, iEnd, j, k, k1, k2, n, sz2, u, x, zIn, zIn1, zIn2, v1, v25, v30, v31 + n = _jsonbPayloadSize(tls, pParse, i, bp) + if n == uint32(0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + return (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + uint32(1) + } + switch libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i)))) & libc.Int32FromInt32(0x0f) { + case JSONB_NULL: + goto _2 + case int32(JSONB_TRUE): + goto _3 + case int32(JSONB_FALSE): + goto _4 + case int32(JSONB_FLOAT): + goto _5 + case int32(JSONB_INT): + goto _6 + case int32(JSONB_INT5): + goto _7 + case int32(JSONB_FLOAT5): + goto _8 + case int32(JSONB_TEXTJ): + goto _9 + case int32(JSONB_TEXT): + goto _10 + case int32(JSONB_TEXT5): + goto _11 + case int32(JSONB_TEXTRAW): + goto _12 + case int32(JSONB_ARRAY): + goto _13 + case int32(JSONB_OBJECT): + goto _14 + default: + goto _15 + } + goto _16 +_2: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+1690, uint32(4)) + return i + uint32(1) +_3: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+8178, uint32(4)) + return i + uint32(1) +_4: + ; + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+8183, uint32(5)) + return i + uint32(1) +_6: + ; +_5: + ; + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + _jsonAppendRaw(tls, pOut, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), **(**Tu32)(__ccgo_up(bp))) + goto _16 +_7: + ; /* Integer literal in hexadecimal notation */ + k = uint32(2) + u = uint64(0) + zIn = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + bOverflow = 0 + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + if int32(**(**int8)(__ccgo_up(zIn))) == int32('-') { + _jsonAppendChar(tls, pOut, int8('-')) + k = k + 1 + } else { + if int32(**(**int8)(__ccgo_up(zIn))) == int32('+') { + k = k + 1 + } + } + for { + if !(k < **(**Tu32)(__ccgo_up(bp))) { + break + } + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn + uintptr(k))))])&libc.Int32FromInt32(0x08) != 0) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } else { + if u>>libc.Int32FromInt32(60) != uint64(0) { + bOverflow = int32(1) + } else { + u = u*uint64(16) + uint64(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(zIn + uintptr(k)))))) + } + } + goto _17 + _17: + ; + k = k + 1 + } + if bOverflow != 0 { + v1 = __ccgo_ts + 26412 + } else { + v1 = __ccgo_ts + 13004 + } + _jsonPrintf(tls, int32(100), pOut, v1, libc.VaList(bp+16, u)) + goto _16 +_8: + ; /* Float literal missing digits beside "." */ + k1 = uint32(0) + zIn1 = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + if **(**Tu32)(__ccgo_up(bp)) == uint32(0) { + goto malformed_jsonb + } + if int32(**(**int8)(__ccgo_up(zIn1))) == int32('-') { + _jsonAppendChar(tls, pOut, int8('-')) + k1 = k1 + 1 + } + if int32(**(**int8)(__ccgo_up(zIn1 + uintptr(k1)))) == int32('.') { + _jsonAppendChar(tls, pOut, int8('0')) + } + for { + if !(k1 < **(**Tu32)(__ccgo_up(bp))) { + break + } + _jsonAppendChar(tls, pOut, **(**int8)(__ccgo_up(zIn1 + uintptr(k1)))) + if int32(**(**int8)(__ccgo_up(zIn1 + uintptr(k1)))) == int32('.') && (k1+uint32(1) == **(**Tu32)(__ccgo_up(bp)) || !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn1 + uintptr(k1+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0)) { + _jsonAppendChar(tls, pOut, int8('0')) + } + goto _20 + _20: + ; + k1 = k1 + 1 + } + goto _16 +_10: + ; +_9: + ; + if (*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(**(**Tu32)(__ccgo_up(bp)))+uint64(2) <= (*TJsonString)(unsafe.Pointer(pOut)).FnAlloc || _jsonStringGrow(tls, pOut, **(**Tu32)(__ccgo_up(bp))+uint32(2)) == 0 { + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pOut)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed))) = int8('"') + libc.Xmemcpy(tls, (*TJsonString)(unsafe.Pointer(pOut)).FzBuf+uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed)+uintptr(1), (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), uint64(**(**Tu32)(__ccgo_up(bp)))) + **(**int8)(__ccgo_up((*TJsonString)(unsafe.Pointer(pOut)).FzBuf + uintptr((*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(**(**Tu32)(__ccgo_up(bp)))+uint64(1)))) = int8('"') + **(**Tu64)(__ccgo_up(pOut + 24)) += uint64(**(**Tu32)(__ccgo_up(bp)) + uint32(2)) + } + goto _16 +_11: + ; + sz2 = **(**Tu32)(__ccgo_up(bp)) + zIn2 = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(i+n) + _jsonAppendChar(tls, pOut, int8('"')) + for sz2 > uint32(0) { + k2 = uint32(0) + for { + if !(k2 < sz2 && (_jsonIsOk[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + uintptr(k2))))] != 0 || int32(**(**int8)(__ccgo_up(zIn2 + uintptr(k2)))) == int32('\''))) { + break + } + goto _21 + _21: + ; + k2 = k2 + 1 + } + if k2 > uint32(0) { + _jsonAppendRawNZ(tls, pOut, zIn2, k2) + if k2 >= sz2 { + break + } + zIn2 = zIn2 + uintptr(k2) + sz2 = sz2 - k2 + } + if int32(**(**int8)(__ccgo_up(zIn2))) == int32('"') { + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26510, uint32(2)) + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + continue + } + if int32(**(**int8)(__ccgo_up(zIn2))) <= int32(0x1f) { + if (*TJsonString)(unsafe.Pointer(pOut)).FnUsed+uint64(7) > (*TJsonString)(unsafe.Pointer(pOut)).FnAlloc && _jsonStringGrow(tls, pOut, uint32(7)) != 0 { + break + } + _jsonAppendControlChar(tls, pOut, libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2)))) + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + continue + } + if sz2 < uint32(2) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + break + } + switch libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + 1)))) { + case int32('\''): + _jsonAppendChar(tls, pOut, int8('\'')) + case int32('v'): + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26513, uint32(6)) + case int32('x'): + if sz2 < uint32(4) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + sz2 = uint32(2) + break + } + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26520, uint32(4)) + _jsonAppendRawNZ(tls, pOut, zIn2+2, uint32(2)) + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + case int32('0'): + _jsonAppendRawNZ(tls, pOut, __ccgo_ts+26525, uint32(6)) + case int32('\r'): + if sz2 > uint32(2) && int32(**(**int8)(__ccgo_up(zIn2 + 2))) == int32('\n') { + zIn2 = zIn2 + 1 + sz2 = sz2 - 1 + } + case int32('\n'): + case int32(0xe2): + /* '\' followed by either U+2028 or U+2029 is ignored as + ** whitespace. Not that in UTF8, U+2028 is 0xe2 0x80 0x29. + ** U+2029 is the same except for the last byte */ + if sz2 < uint32(4) || int32(0x80) != libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + 2)))) || int32(0xa8) != libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + 3)))) && int32(0xa9) != libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn2 + 3)))) { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + sz2 = uint32(2) + break + } + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + default: + _jsonAppendRawNZ(tls, pOut, zIn2, uint32(2)) + break + } + zIn2 = zIn2 + uintptr(2) + sz2 = sz2 - uint32(2) + } + _jsonAppendChar(tls, pOut, int8('"')) + goto _16 +_12: + ; + _jsonAppendString(tls, pOut, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob+uintptr(i+n), **(**Tu32)(__ccgo_up(bp))) + goto _16 +_13: + ; + _jsonAppendChar(tls, pOut, int8('[')) + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + v1 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v25 = *(*Tu16)(unsafe.Pointer(v1)) + if libc.Int32FromUint16(v25) > int32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for j < iEnd && libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + _jsonAppendChar(tls, pOut, int8(',')) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + } + if **(**Tu32)(__ccgo_up(bp)) > uint32(0) { + _jsonStringTrimOneChar(tls, pOut) + } + _jsonAppendChar(tls, pOut, int8(']')) + goto _16 +_14: + ; + x = 0 + _jsonAppendChar(tls, pOut, int8('{')) + j = i + n + iEnd = j + **(**Tu32)(__ccgo_up(bp)) + v1 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v1)) = *(*Tu16)(unsafe.Pointer(v1)) + 1 + v25 = *(*Tu16)(unsafe.Pointer(v1)) + if libc.Int32FromUint16(v25) > int32(JSON_MAX_DEPTH) { + _jsonStringTooDeep(tls, pOut) + } + for j < iEnd && libc.Int32FromUint8((*TJsonString)(unsafe.Pointer(pOut)).FeErr) == 0 { + j = _jsonTranslateBlobToText(tls, pParse, j, pOut) + v31 = x + x = x + 1 + if v31&int32(1) != 0 { + v30 = int32(',') + } else { + v30 = int32(':') + } + _jsonAppendChar(tls, pOut, int8(v30)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + if x&int32(1) != 0 || j > iEnd { + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + } + if **(**Tu32)(__ccgo_up(bp)) > uint32(0) { + _jsonStringTrimOneChar(tls, pOut) + } + _jsonAppendChar(tls, pOut, int8('}')) + goto _16 +_15: + ; + goto malformed_jsonb +malformed_jsonb: + ; + v1 = pOut + 33 + *(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(JSTRING_MALFORMED)) + goto _16 +_16: + ; + return i + n + **(**Tu32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** Translate a single element of JSON text at pParse->zJson[i] into +// ** its equivalent binary JSONB representation. Append the translation into +// ** pParse->aBlob[] beginning at pParse->nBlob. The size of +// ** pParse->aBlob[] is increased as necessary. +// ** +// ** Return the index of the first character past the end of the element parsed, +// ** or one of the following special result codes: +// ** +// ** 0 End of input +// ** -1 Syntax error or OOM +// ** -2 '}' seen ** -3 ']' seen \___ For these returns, pParse->iErr is set to +// ** -4 ',' seen / the index in zJson[] of the seen character +// ** -5 ':' seen / +// */ +func _jsonTranslateTextToBlob(tls *libc.TLS, pParse uintptr, i Tu32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, cDelim int8 + var iBlob, iStart, iThis, j, k1, v46 Tu32 + var k, nn, x, v48 int32 + var opcode, seenE, t Tu8 + var z, v41 uintptr + var v40 Tu16 + var _ /* op at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, cDelim, iBlob, iStart, iThis, j, k, k1, nn, opcode, seenE, t, x, z, v40, v41, v46, v48 + z = (*TJsonParse)(unsafe.Pointer(pParse)).FzJson + goto json_parse_restart +json_parse_restart: + ; + switch libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i))))) { + case int32('{'): + goto _1 + case int32('['): + goto _2 + case int32('"'): + goto _3 + case int32('\''): + goto _4 + case int32('t'): + goto _5 + case int32('f'): + goto _6 + case int32('.'): + goto _7 + case int32('9'): + goto _8 + case int32('8'): + goto _9 + case int32('7'): + goto _10 + case int32('6'): + goto _11 + case int32('5'): + goto _12 + case int32('4'): + goto _13 + case int32('3'): + goto _14 + case int32('2'): + goto _15 + case int32('1'): + goto _16 + case int32('0'): + goto _17 + case int32('-'): + goto _18 + case int32('+'): + goto _19 + case int32('}'): + goto _20 + case int32(']'): + goto _21 + case int32(','): + goto _22 + case int32(':'): + goto _23 + case 0: + goto _24 + case int32(0x20): + goto _25 + case int32(0x0d): + goto _26 + case int32(0x0a): + goto _27 + case int32(0x09): + goto _28 + case int32(0xef): + goto _29 + case int32(0xe3): + goto _30 + case int32(0xe2): + goto _31 + case int32(0xe1): + goto _32 + case int32(0xc2): + goto _33 + case int32('/'): + goto _34 + case int32(0x0c): + goto _35 + case int32(0x0b): + goto _36 + case int32('n'): + goto _37 + default: + goto _38 + } + goto _39 +_1: + ; + /* Parse object */ + iThis = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_OBJECT), uint64(libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pParse)).FnJson)-i), uintptr(0)) + v41 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v41)) = *(*Tu16)(unsafe.Pointer(v41)) + 1 + v40 = *(*Tu16)(unsafe.Pointer(v41)) + if libc.Int32FromUint16(v40) > int32(JSON_MAX_DEPTH) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + iStart = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + j = i + uint32(1) + for { + iBlob = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x == -int32(2) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob != iStart { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + break + } + j = j + libc.Uint32FromInt32(_json5Whitespace(tls, z+uintptr(j))) + **(**int32)(__ccgo_up(bp)) = int32(JSONB_TEXT) + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))])&int32(0x42) != 0 || int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32('\\') && _jsonIs4HexB(tls, z+uintptr(j+uint32(1)), bp) != 0 { + k = libc.Int32FromUint32(j + uint32(1)) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(k))))])&int32(0x46) != 0 && _json5Whitespace(tls, z+uintptr(k)) == 0 || int32(**(**int8)(__ccgo_up(z + uintptr(k)))) == int32('\\') && _jsonIs4HexB(tls, z+uintptr(k+int32(1)), bp) != 0 { + k = k + 1 + } + _jsonBlobAppendNode(tls, pParse, libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp))), uint64(libc.Uint32FromInt32(k)-j), z+uintptr(j)) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + x = k + } else { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + } + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return -int32(1) + } + t = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TJsonParse)(unsafe.Pointer(pParse)).FaBlob + uintptr(iBlob)))) & int32(0x0f)) + if libc.Int32FromUint8(t) < int32(JSONB_TEXT) || libc.Int32FromUint8(t) > int32(JSONB_TEXTRAW) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(':') { + j = j + 1 + } else { + if _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + /* strspn() is not helpful here */ + for cond := true; cond; cond = _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + 1 + } + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(':') { + j = j + 1 + goto parse_object_value + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x != -int32(5) { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + uint32(1) + } + goto parse_object_value + parse_object_value: + ; + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _42 + } else { + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32('}') { + break + } else { + if _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(j+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _42 + } else { + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32('}') { + break + } + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x == -int32(4) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + goto _42 + } + if x == -int32(2) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + break + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + goto _42 + _42: + ; + j = j + 1 + } + _jsonBlobChangePayloadSize(tls, pParse, iThis, (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-iStart) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + return libc.Int32FromUint32(j + uint32(1)) +_2: + ; + /* Parse array */ + iThis = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_ARRAY), uint64(libc.Uint32FromInt32((*TJsonParse)(unsafe.Pointer(pParse)).FnJson)-i), uintptr(0)) + iStart = (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob + if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 { + return -int32(1) + } + v41 = pParse + 44 + *(*Tu16)(unsafe.Pointer(v41)) = *(*Tu16)(unsafe.Pointer(v41)) + 1 + v40 = *(*Tu16)(unsafe.Pointer(v41)) + if libc.Int32FromUint16(v40) > int32(JSON_MAX_DEPTH) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + j = i + uint32(1) + for { + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x <= 0 { + if x == -int32(3) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob != iStart { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } + break + } + if x != -int32(1) { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + } + return -int32(1) + } + j = libc.Uint32FromInt32(x) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _45 + } else { + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(']') { + break + } else { + if _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + j = j + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(j+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(',') { + goto _45 + } else { + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) == int32(']') { + break + } + } + } + x = _jsonTranslateTextToBlob(tls, pParse, j) + if x == -int32(4) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + goto _45 + } + if x == -int32(3) { + j = (*TJsonParse)(unsafe.Pointer(pParse)).FiErr + break + } + } + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + goto _45 + _45: + ; + j = j + 1 + } + _jsonBlobChangePayloadSize(tls, pParse, iThis, (*TJsonParse)(unsafe.Pointer(pParse)).FnBlob-iStart) + (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth = (*TJsonParse)(unsafe.Pointer(pParse)).FiDepth - 1 + return libc.Int32FromUint32(j + uint32(1)) +_4: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + opcode = uint8(JSONB_TEXT) + goto parse_string +_3: + ; + /* Parse string */ + opcode = uint8(JSONB_TEXT) + goto parse_string +parse_string: + ; + cDelim = **(**int8)(__ccgo_up(z + uintptr(i))) + j = i + uint32(1) + for int32(1) != 0 { + if _jsonIsOk[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))] != 0 { + if !(_jsonIsOk[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))))] != 0) { + j = j + uint32(1) + } else { + if !(_jsonIsOk[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(2)))))] != 0) { + j = j + uint32(2) + } else { + j = j + uint32(3) + continue + } + } + } + c = **(**int8)(__ccgo_up(z + uintptr(j))) + if int32(c) == int32(cDelim) { + break + } else { + if int32(c) == int32('\\') { + j = j + 1 + v46 = j + c = **(**int8)(__ccgo_up(z + uintptr(v46))) + if int32(c) == int32('"') || int32(c) == int32('\\') || int32(c) == int32('/') || int32(c) == int32('b') || int32(c) == int32('f') || int32(c) == int32('n') || int32(c) == int32('r') || int32(c) == int32('t') || int32(c) == int32('u') && _jsonIs4Hex(tls, z+uintptr(j+uint32(1))) != 0 { + if libc.Int32FromUint8(opcode) == int32(JSONB_TEXT) { + opcode = uint8(JSONB_TEXTJ) + } + } else { + if int32(c) == int32('\'') || int32(c) == int32('v') || int32(c) == int32('\n') || int32(c) == int32('0') && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0) || int32(0xe2) == libc.Int32FromUint8(libc.Uint8FromInt8(c)) && int32(0x80) == libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))))) && (int32(0xa8) == libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(2)))))) || int32(0xa9) == libc.Int32FromUint8(libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j+uint32(2))))))) || int32(c) == int32('x') && _jsonIs2Hex(tls, z+uintptr(j+uint32(1))) != 0 { + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + if int32(c) == int32('\r') { + if int32(**(**int8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('\n') { + j = j + 1 + } + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + } + } else { + if int32(c) <= int32(0x1f) { + if int32(c) == 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + /* Control characters are not allowed in canonical JSON string + ** literals, but are allowed in JSON5 string literals. */ + opcode = uint8(JSONB_TEXT5) + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + } else { + if int32(c) == int32('"') { + opcode = uint8(JSONB_TEXT5) + } + } + } + } + j = j + 1 + } + _jsonBlobAppendNode(tls, pParse, opcode, uint64(j-uint32(1)-i), z+uintptr(i+uint32(1))) + return libc.Int32FromUint32(j + uint32(1)) +_5: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+8178, uint64(4)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(4)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_TRUE)) + return libc.Int32FromUint32(i + uint32(4)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_6: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+8183, uint64(5)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(5)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_FALSE)) + return libc.Int32FromUint32(i + uint32(5)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_19: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x00) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + goto parse_number +_7: + ; + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x03) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + seenE = uint8(0) + goto parse_number_2 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_18: + ; +_17: + ; +_16: + ; +_15: + ; +_14: + ; +_13: + ; +_12: + ; +_11: + ; +_10: + ; +_9: + ; +_8: + ; + /* Parse number */ + t = uint8(0x00) /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ + goto parse_number +parse_number: + ; + seenE = uint8(0) + c = **(**int8)(__ccgo_up(z + uintptr(i))) + if int32(c) <= int32('0') { + if int32(c) == int32('0') { + if (int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('x') || int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('X')) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(2)))))])&int32(0x08) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = uint8(0x01) + j = i + uint32(3) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))])&int32(0x08) != 0) { + break + } + goto _47 + _47: + ; + j = j + 1 + } + goto parse_number_finish + } else { + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + uint32(1) + return -int32(1) + } + } + } else { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1)))))])&libc.Int32FromInt32(0x04) != 0) { + /* JSON5 allows for "+Infinity" and "-Infinity" using exactly + ** that case. SQLite also allows these in any case and it allows + ** "+inf" and "-inf". */ + if (int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('I') || int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('i')) && Xsqlite3_strnicmp(tls, z+uintptr(i+uint32(1)), __ccgo_ts+26408, int32(3)) == 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + if int32(**(**int8)(__ccgo_up(z + uintptr(i)))) == int32('-') { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(6), __ccgo_ts+26491) + } else { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26498) + } + if Xsqlite3_strnicmp(tls, z+uintptr(i+uint32(4)), __ccgo_ts+26504, int32(5)) == 0 { + v48 = int32(9) + } else { + v48 = int32(4) + } + return libc.Int32FromUint32(i + libc.Uint32FromInt32(v48)) + } + if int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('.') { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + goto parse_number_2 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) + } + if int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(1))))) == int32('0') { + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + uint32(1) + return -int32(1) + } else { + if (int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(2))))) == int32('x') || int32(**(**int8)(__ccgo_up(z + uintptr(i+uint32(2))))) == int32('X')) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(3)))))])&int32(0x08) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + j = i + uint32(4) + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j))))])&int32(0x08) != 0) { + break + } + goto _49 + _49: + ; + j = j + 1 + } + goto parse_number_finish + } + } + } + } + } + goto parse_number_2 +parse_number_2: + ; + j = i + uint32(1) + for { + c = **(**int8)(__ccgo_up(z + uintptr(j))) + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(c)])&int32(0x04) != 0 { + goto _50 + } + if int32(c) == int32('.') { + if libc.Int32FromUint8(t)&int32(0x02) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x02)) + goto _50 + } + if int32(c) == int32('e') || int32(c) == int32('E') { + if int32(**(**int8)(__ccgo_up(z + uintptr(j-uint32(1))))) < int32('0') { + if int32(**(**int8)(__ccgo_up(z + uintptr(j-uint32(1))))) == int32('.') && j-uint32(2) >= i && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j-uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + if seenE != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x02)) + seenE = uint8(1) + c = **(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))) + if int32(c) == int32('+') || int32(c) == int32('-') { + j = j + 1 + c = **(**int8)(__ccgo_up(z + uintptr(j+uint32(1)))) + } + if int32(c) < int32('0') || int32(c) > int32('9') { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + goto _50 + } + break + goto _50 + _50: + ; + j = j + 1 + } + if int32(**(**int8)(__ccgo_up(z + uintptr(j-uint32(1))))) < int32('0') { + if int32(**(**int8)(__ccgo_up(z + uintptr(j-uint32(1))))) == int32('.') && j-uint32(2) >= i && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(j-uint32(2)))))])&int32(0x04) != 0 { + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + t = libc.Uint8FromInt32(int32(t) | libc.Int32FromInt32(0x01)) + } else { + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = j + return -int32(1) + } + } + goto parse_number_finish +parse_number_finish: + ; + if int32(**(**int8)(__ccgo_up(z + uintptr(i)))) == int32('+') { + i = i + 1 + } + _jsonBlobAppendNode(tls, pParse, libc.Uint8FromInt32(int32(JSONB_INT)+libc.Int32FromUint8(t)), uint64(j-i), z+uintptr(i)) + return libc.Int32FromUint32(j) +_20: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(2) /* End of {...} */ +_21: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(3) /* End of [...] */ +_22: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(4) /* List separator */ +_23: + ; + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(5) /* Object label/value separator */ +_24: + ; + return 0 /* End of file */ +_28: + ; +_27: + ; +_26: + ; +_25: + ; + i = i + (uint32(1) + uint32(libc.Xstrspn(tls, z+uintptr(i+uint32(1)), uintptr(unsafe.Pointer(&_jsonSpaces))))) + goto json_parse_restart +_36: + ; +_35: + ; +_34: + ; +_33: + ; +_32: + ; +_31: + ; +_30: + ; +_29: + ; + j = libc.Uint32FromInt32(_json5Whitespace(tls, z+uintptr(i))) + if j > uint32(0) { + i = i + j + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + goto json_parse_restart + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) +_37: + ; + if libc.Xstrncmp(tls, z+uintptr(i), __ccgo_ts+1690, uint64(4)) == 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+uint32(4)))))])&libc.Int32FromInt32(0x06) != 0) { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_NULL)) + return libc.Int32FromUint32(i + uint32(4)) + } + /* fall-through into the default case that checks for NaN */ +_38: + ; + c = **(**int8)(__ccgo_up(z + uintptr(i))) + k1 = uint32(0) + for { + if !(uint64(k1) < libc.Uint64FromInt64(120)/libc.Uint64FromInt64(24)) { + break + } + if int32(c) != int32(_aNanInfName[k1].Fc1) && int32(c) != int32(_aNanInfName[k1].Fc2) { + goto _51 + } + nn = int32(_aNanInfName[k1].Fn) + if Xsqlite3_strnicmp(tls, z+uintptr(i), _aNanInfName[k1].FzMatch, nn) != 0 { + goto _51 + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(i+libc.Uint32FromInt32(nn)))))])&int32(0x06) != 0 { + goto _51 + } + if int32(_aNanInfName[k1].FeType) == int32(JSONB_FLOAT) { + _jsonBlobAppendNode(tls, pParse, uint8(JSONB_FLOAT), uint64(5), __ccgo_ts+26498) + } else { + _jsonBlobAppendOneByte(tls, pParse, uint8(JSONB_NULL)) + } + (*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1) + return libc.Int32FromUint32(i + libc.Uint32FromInt32(nn)) + goto _51 + _51: + ; + k1 = k1 + 1 + } + (*TJsonParse)(unsafe.Pointer(pParse)).FiErr = i + return -int32(1) /* Syntax error */ +_39: + ; /* End switch(z[i]) */ + return r +} + +// C documentation +// +// /* +// ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up +// ** that name in the set of source tables in pSrcList and make the pExpr +// ** expression node refer back to that source column. The following changes +// ** are made to pExpr: +// ** +// ** pExpr->iDb Set the index in db->aDb[] of the database X +// ** (even if X is implied). +// ** pExpr->iTable Set to the cursor number for the table obtained +// ** from pSrcList. +// ** pExpr->y.pTab Points to the Table structure of X.Y (even if +// ** X and/or Y are implied.) +// ** pExpr->iColumn Set to the column number within the table. +// ** pExpr->op Set to TK_COLUMN. +// ** pExpr->pLeft Any expression this points to is deleted +// ** pExpr->pRight Any expression this points to is deleted. +// ** +// ** The zDb variable is the name of the database (the "X"). This value may be +// ** NULL meaning that name is of the form Y.Z or Z. Any available database +// ** can be used. The zTable variable is the name of the table (the "Y"). This +// ** value can be NULL if zDb is also NULL. If zTable is NULL it +// ** means that the form of the name is Z and that columns from any table +// ** can be used. +// ** +// ** If the name cannot be resolved unambiguously, leave an error message +// ** in pParse and return WRC_Abort. Return WRC_Prune on success. +// */ +func _lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, pRight uintptr, pNC uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var cnt, cntTab, eNewExprOp, hit, i, iCol, j, nSubquery, op, v4 int32 + var db, pEList, pItem, pMatch, pOrig, pSchema, pSel, pSrcList, pTab, pTopNC, pUpsert, zAs, zCol, zErr, v8 uintptr + var v5 uint32 + var _ /* bRowid at bp+8 */ int32 + var _ /* pFJMatch at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cnt, cntTab, db, eNewExprOp, hit, i, iCol, j, nSubquery, op, pEList, pItem, pMatch, pOrig, pSchema, pSel, pSrcList, pTab, pTopNC, pUpsert, zAs, zCol, zErr, v4, v5, v8 /* Loop counters */ + cnt = 0 /* Number of matching column names */ + cntTab = 0 /* Number of potential "rowid" matches */ + nSubquery = 0 /* How many levels of subquery */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Use for looping over pSrcList items */ + pMatch = uintptr(0) /* The matching pSrcList item */ + pTopNC = pNC /* First namecontext in the list */ + pSchema = uintptr(0) /* Schema of the expression */ + eNewExprOp = int32(TK_COLUMN) /* New value for pExpr->op on success */ + pTab = uintptr(0) /* Table holding the row */ + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Matches for FULL JOIN .. USING */ + zCol = *(*uintptr)(unsafe.Pointer(pRight + 8)) + /* the name context cannot be NULL. */ + /* The Z in X.Y.Z cannot be NULL */ + /* Initialize the node to no-match */ + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = -int32(1) + /* Translate the schema name in zDb into a pointer to the corresponding + ** schema. If not found, pSchema will remain NULL and nothing will match + ** resulting in an appropriate error message toward the end of this routine + */ + if zDb != 0 { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_IsCheck)) != 0 { + /* Silently ignore database qualifiers inside CHECK constraints and + ** partial indices. Do not raise errors because that might break + ** legacy and because it does not hurt anything to just ignore the + ** database name. */ + zDb = uintptr(0) + } else { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if _sqlite3StrICmp(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName, zDb) == 0 { + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i == (*Tsqlite3)(unsafe.Pointer(db)).FnDb && _sqlite3StrICmp(tls, __ccgo_ts+6816, zDb) == 0 { + /* This branch is taken when the main database has been renamed + ** using SQLITE_DBCONFIG_MAINDBNAME. */ + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName + } + } + } + /* Start at the inner-most context and move outward until a match is found */ + for cond := true; cond; cond = pNC != 0 { + pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + if pSrcList != 0 { + i = 0 + pItem = pSrcList + 8 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc) { + break + } + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { + /* In this case, pItem is a subquery that has been formed from a + ** parenthesized subset of the FROM clause terms. Example: + ** .... FROM t1 LEFT JOIN (t2 RIGHT JOIN t3 USING(x)) USING(y) ... + ** \_________________________/ + ** This pItem -------------^ + */ + hit = 0 + pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect + pEList = (*TSelect)(unsafe.Pointer(pSel)).FpEList + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + **(**int32)(__ccgo_up(bp + 8)) = 0 /* True if possible rowid match */ + if !(_sqlite3MatchEName(tls, pEList+8+uintptr(j)*32, zCol, zTab, zDb, bp+8) != 0) { + goto _3 + } + if **(**int32)(__ccgo_up(bp + 8)) == 0 { + if cnt > 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 64)), zCol) < 0 || pMatch == pItem { + /* Two or more tables have the same column name which is + ** not joined by USING. Or, a single table has two columns + ** that match a USING term (if pMatch==pItem). These are both + ** "ambiguous column name" errors. Signal as much by clearing + ** pFJMatch and letting cnt go above 1. */ + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + /* An INNER or LEFT JOIN. Use the left-most table */ + goto _3 + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) == 0 { + /* A RIGHT JOIN. Use the right-most table */ + cnt = 0 + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + /* For a FULL JOIN, we must construct a coalesce() func */ + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + } + } + } + } + cnt = cnt + 1 + hit = int32(1) + } else { + if cnt > 0 { + /* This is a potential rowid match, but there has already been + ** a real match found. So this can be ignored. */ + goto _3 + } + } + cntTab = cntTab + 1 + pMatch = pItem + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(j) + libc.SetBitFieldPtr16Uint32(pEList+8+uintptr(j)*32+16+4, libc.Uint32FromInt32(1), 6, 0x40) + /* rowid cannot be part of a USING clause - assert() this. */ + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 16 + 4))&0x80>>7)) != 0 { + break + } + goto _3 + _3: + ; + j = j + 1 + } + if hit != 0 || zTab == uintptr(0) { + goto _2 + } + } + if zTab != 0 { + if zDb != 0 { + if (*TTable)(unsafe.Pointer(pTab)).FpSchema != pSchema { + goto _2 + } + if pSchema == uintptr(0) && libc.Xstrcmp(tls, zDb, __ccgo_ts+6821) != 0 { + goto _2 + } + } + if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != uintptr(0) { + if _sqlite3StrICmp(tls, zTab, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) != 0 { + goto _2 + } + } else { + if _sqlite3StrICmp(tls, zTab, (*TTable)(unsafe.Pointer(pTab)).FzName) != 0 { + if (*TTable)(unsafe.Pointer(pTab)).Ftnum != uint32(1) { + goto _2 + } + if !(_isValidSchemaTableName(tls, zTab, pTab, zDb) != 0) { + goto _2 + } + } + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr+64) + } + } + j = _sqlite3ColumnIndex(tls, pTab, zCol) + if j >= 0 { + if cnt > 0 { + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 64)), zCol) < 0 { + /* Two or more tables have the same column name which is + ** not joined by USING. This is an error. Signal as much + ** by clearing pFJMatch and letting cnt go above 1. */ + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { + /* An INNER or LEFT JOIN. Use the left-most table */ + goto _2 + } else { + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) == 0 { + /* A RIGHT JOIN. Use the right-most table */ + cnt = 0 + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } else { + /* For a FULL JOIN, we must construct a coalesce() func */ + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + } + } + } + } + cnt = cnt + 1 + pMatch = pItem + /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + v4 = -int32(1) + } else { + v4 = int32(int16(j)) + } + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(v4) + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { + _sqlite3SrcItemColumnUsed(tls, pItem, j) + } + } + if 0 == cnt && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) { + /* pTab is a potential ROWID match. Keep track of it and match + ** the ROWID later if that seems appropriate. (Search for "cntTab" + ** to find related code.) Only allow a ROWID match if there is + ** a single ROWID match candidate. + */ + /* The (much more common) non-SQLITE_ALLOW_ROWID_IN_VIEW case is + ** simpler since we require exactly one candidate, which will + ** always be a non-VIEW + */ + cntTab = cntTab + 1 + pMatch = pItem + } + goto _2 + _2: + ; + i = i + 1 + pItem += 80 + } + if pMatch != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSrcItem)(unsafe.Pointer(pMatch)).FiCursor + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pMatch)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + pSchema = (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpSchema + } + } /* if( pSrcList ) */ + /* If we have not already resolved the name, then maybe + ** it is a new.* or old.* trigger argument reference. Or + ** maybe it is an excluded.* from an upsert. Or maybe it is + ** a reference in the RETURNING clause to a table being modified. + */ + if cnt == 0 && zDb == uintptr(0) { + pTab = uintptr(0) + if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != uintptr(0) { + op = libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeTriggerOp) + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UBaseReg) != 0 && (zTab == uintptr(0) || _sqlite3StrICmp(tls, zTab, (*TTable)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).FpTriggerTab)).FzName) == 0 || _isValidSchemaTableName(tls, zTab, (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab, uintptr(0)) != 0) { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = libc.BoolInt32(op != int32(TK_DELETE)) + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } + } else { + if op != int32(TK_DELETE) && zTab != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6823, zTab) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = int32(1) + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } else { + if op != int32(TK_INSERT) && zTab != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6827, zTab) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = 0 + pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab + } + } + } + } + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UUpsert) != 0 && zTab != uintptr(0) { + pUpsert = *(*uintptr)(unsafe.Pointer(pNC + 16)) + if pUpsert != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6831, zTab) == 0 { + pTab = (*(*TSrcItem)(unsafe.Pointer((*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8))).FpSTab + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = int32(EXCLUDED_TABLE_NUMBER) + } + } + if pTab != 0 { + pSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema + cntTab = cntTab + 1 + iCol = _sqlite3ColumnIndex(tls, pTab, zCol) + if iCol >= 0 { + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) == iCol { + iCol = -int32(1) + } + } else { + if _sqlite3IsRowid(tls, zCol) != 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) { + iCol = -int32(1) + } else { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } + } + if iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + cnt = cnt + 1 + pMatch = uintptr(0) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == int32(EXCLUDED_TABLE_NUMBER) { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab + eNewExprOp = int32(TK_COLUMN) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TUpsert)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNC + 16)))).FregData + int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + eNewExprOp = int32(TK_REGISTER) + } + } else { + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { + eNewExprOp = int32(TK_REGISTER) + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = uint8(TK_COLUMN) + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = *(*int32)(unsafe.Pointer(&(*TNameContext)(unsafe.Pointer(pNC)).FuNC)) + (int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1))*(*TExpr)(unsafe.Pointer(pExpr)).FiTable + int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + int32(1) + } else { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) + eNewExprOp = int32(TK_TRIGGER) + if iCol < 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_INTEGER) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == 0 { + if iCol >= int32(32) { + v5 = uint32(0xffffffff) + } else { + v5 = libc.Uint32FromInt32(1) << iCol + } + **(**Tu32)(__ccgo_up(pParse + 240)) |= v5 + } else { + if iCol >= int32(32) { + v5 = uint32(0xffffffff) + } else { + v5 = libc.Uint32FromInt32(1) << iCol + } + **(**Tu32)(__ccgo_up(pParse + 244)) |= v5 + } + } + } + } + } + } + } + /* + ** Perhaps the name is a reference to the ROWID + */ + if cnt == 0 && cntTab >= int32(1) && pMatch != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) == 0 && _sqlite3IsRowid(tls, zCol) != 0 && ((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) || int32(*(*uint32)(unsafe.Pointer(pMatch + 24 + 4))&0x4000>>14) != 0) { + cnt = cntTab + if int32(*(*uint32)(unsafe.Pointer(pMatch + 24 + 4))&0x4000>>14) == 0 { + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(-int32(1)) + } + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_INTEGER) + } + /* + ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z + ** might refer to an result-set alias. This happens, for example, when + ** we are resolving names in the WHERE clause of the following command: + ** + ** SELECT a+b AS x FROM table WHERE x<10; + ** + ** In cases like this, replace pExpr with a copy of the expression that + ** forms the result set entry ("a+b" in the example) and return immediately. + ** Note that the expression in the result set should have already been + ** resolved by the time the WHERE clause is resolved. + ** + ** The ability to use an output result-set column in the WHERE, GROUP BY, + ** or HAVING clauses, or as part of a larger expression in the ORDER BY + ** clause is not standard SQL. This is a (goofy) SQLite extension, that + ** is supported for backwards compatibility only. Hence, we issue a warning + ** on sqlite3_log() whenever the capability is used. + */ + if cnt == 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UEList) != 0 && zTab == uintptr(0) { + pEList = *(*uintptr)(unsafe.Pointer(pNC + 16)) + j = 0 + for { + if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + zAs = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*32))).FzEName + if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME && Xsqlite3_stricmp(tls, zAs, zCol) == 0 { + pOrig = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*32))).FpExpr + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowAgg) == 0 && (*TExpr)(unsafe.Pointer(pOrig)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Agg)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6840, libc.VaList(bp+24, zAs)) + return int32(WRC_Abort) + } + if (*TExpr)(unsafe.Pointer(pOrig)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Win)) != uint32(0) && ((*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowWin) == 0 || pNC != pTopNC) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6871, libc.VaList(bp+24, zAs)) + return int32(WRC_Abort) + } + if _sqlite3ExprVectorSize(tls, pOrig) != int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6908, 0) + return int32(WRC_Abort) + } + _resolveAlias(tls, pParse, pEList, j, pExpr, nSubquery) + cnt = int32(1) + pMatch = uintptr(0) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) + } + goto lookupname_end + } + goto _7 + _7: + ; + j = j + 1 + } + } + /* Advance to the next name context. The loop will exit when either + ** we have a match (cnt>0) or when we run out of name contexts. + */ + if cnt != 0 { + break + } + pNC = (*TNameContext)(unsafe.Pointer(pNC)).FpNext + nSubquery = nSubquery + 1 + } + /* + ** If X and Y are NULL (in other words if only the column name Z is + ** supplied) and the value of Z is enclosed in double-quotes, then + ** Z is a string literal if it doesn't match any column names. In that + ** case, we need to return right away and not make any changes to + ** pExpr. + ** + ** Because no reference was made to outer contexts, the pNC->nRef + ** fields are not changed in any context. + */ + if cnt == 0 && zTab == uintptr(0) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_DblQuoted)) != uint32(0) && _areDoubleQuotedStringsEnabled(tls, db, pTopNC) != 0 { + /* If a double-quoted identifier does not match any known column name, + ** then treat it as a string. + ** + ** This hack was added in the early days of SQLite in a misguided attempt + ** to be compatible with MySQL 3.x, which used double-quotes for strings. + ** I now sorely regret putting in this hack. The effect of this hack is + ** that misspelled identifier names are silently converted into strings + ** rather than causing an error, to the frustration of countless + ** programmers. To all those frustrated programmers, my apologies. + ** + ** Someday, I hope to get rid of this hack. Unfortunately there is + ** a huge amount of legacy SQL that uses it. So for now, we just + ** issue a warning. + */ + Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+6926, libc.VaList(bp+24, zCol)) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_STRING) + libc.Xmemset(tls, pExpr+64, 0, uint64(8)) + return int32(WRC_Prune) + } + if _sqlite3ExprIdToTrueFalse(tls, pExpr) != 0 { + return int32(WRC_Prune) + } + } + /* + ** cnt==0 means there was not match. + ** cnt>1 means there were two or more matches. + ** + ** cnt==0 is always an error. cnt>1 is often an error, but might + ** be multiple matches for a NATURAL LEFT JOIN or a LEFT JOIN USING. + */ + if cnt != int32(1) { + if **(**uintptr)(__ccgo_up(bp)) != 0 { + if (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr == cnt-int32(1) { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) != uint32(0) { + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) + } else { + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) + } + _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_FUNCTION) + *(*uintptr)(unsafe.Pointer(pExpr + 8)) = __ccgo_ts + 6961 + *(*uintptr)(unsafe.Pointer(pExpr + 32)) = **(**uintptr)(__ccgo_up(bp)) + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_DEFER) + cnt = int32(1) + goto lookupname_end + } else { + _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + } + } + if cnt == 0 { + v8 = __ccgo_ts + 6970 + } else { + v8 = __ccgo_ts + 6985 + } + zErr = v8 + if zDb != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7007, libc.VaList(bp+24, zErr, zDb, zTab, zCol)) + } else { + if zTab != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7020, libc.VaList(bp+24, zErr, zTab, zCol)) + } else { + if cnt == 0 && (*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_DblQuoted)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7030, libc.VaList(bp+24, zErr, zCol)) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7091, libc.VaList(bp+24, zErr, zCol)) + } + } + } + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) + (*TNameContext)(unsafe.Pointer(pTopNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pTopNC)).FnNcErr + 1 + eNewExprOp = int32(TK_NULL) + } + /* Remove all substructure from pExpr */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)) { + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + (*TExpr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) + } + /* If a column from a table in pSrcList is referenced, then record + ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes + ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is + ** set if the 63rd or any subsequent column is used. + ** + ** The colUsed mask is an optimization used to help determine if an + ** index is a covering index. The correct answer is still obtained + ** if the mask contains extra set bits. However, it is important to + ** avoid setting bits beyond the maximum column number of the table. + ** (See ticket [b92e5e8ec2cdbaa1]). + ** + ** If a generated column is referenced, set bits for every column + ** of the table. + */ + if pMatch != 0 { + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 { + **(**TBitmask)(__ccgo_up(pMatch + 40)) |= _sqlite3ExprColUsed(tls, pExpr) + } else { + libc.SetBitFieldPtr32Uint32(pMatch+24+4, libc.Uint32FromInt32(1), 15, 0x8000) + } + } + (*TExpr)(unsafe.Pointer(pExpr)).Fop = libc.Uint8FromInt32(eNewExprOp) + goto lookupname_end +lookupname_end: + ; + if cnt == int32(1) { + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FxAuth != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_TRIGGER)) { + _sqlite3AuthRead(tls, pParse, pExpr, pSchema, (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList) + } + /* Increment the nRef value on all name contexts from TopNC up to + ** the point where the name matched. */ + for { + (*TNameContext)(unsafe.Pointer(pTopNC)).FnRef = (*TNameContext)(unsafe.Pointer(pTopNC)).FnRef + 1 + if pTopNC == pNC { + break + } + pTopNC = (*TNameContext)(unsafe.Pointer(pTopNC)).FpNext + goto _9 + _9: + } + return int32(WRC_Prune) + } else { + return int32(WRC_Abort) + } + return r +} + +// C documentation +// +// /* +// ** Open a file descriptor to the directory containing file zFilename. +// ** If successful, *pFd is set to the opened file descriptor and +// ** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM +// ** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined +// ** value. +// ** +// ** The directory file descriptor is used for only one thing - to +// ** fsync() a directory to make sure file creation and deletion events +// ** are flushed to disk. Such fsyncs are not needed on newer +// ** journaling filesystems, but are required on older filesystems. +// ** +// ** This routine can be overridden using the xSetSysCall interface. +// ** The ability to override this routine was added in support of the +// ** chromium sandbox. Opening a directory is a security risk (we are +// ** told) so making it overrideable allows the chromium sandbox to +// ** replace this routine with a harmless no-op. To make this routine +// ** a no-op, replace it with a stub that returns SQLITE_OK but leaves +// ** *pFd set to a negative number. +// ** +// ** If SQLITE_OK is returned, the caller is responsible for closing +// ** the file descriptor *pFd using close(). +// */ +func _openDirectory(tls *libc.TLS, zFilename uintptr, pFd uintptr) (r int32) { + bp := tls.Alloc(544) + defer tls.Free(544) + var fd, ii int32 + var _ /* zDirname at bp+0 */ [513]int8 + _, _ = fd, ii + fd = -int32(1) + Xsqlite3_snprintf(tls, int32(MAX_PATHNAME), bp, __ccgo_ts+3944, libc.VaList(bp+528, zFilename)) + ii = libc.Int32FromUint64(libc.Xstrlen(tls, bp)) + for { + if !(ii > 0 && int32((**(**[513]int8)(__ccgo_up(bp)))[ii]) != int32('/')) { + break + } + goto _1 + _1: + ; + ii = ii - 1 + } + if ii > 0 { + (**(**[513]int8)(__ccgo_up(bp)))[ii] = int8('\000') + } else { + if int32((**(**[513]int8)(__ccgo_up(bp)))[0]) != int32('/') { + (**(**[513]int8)(__ccgo_up(bp)))[0] = int8('.') + } + (**(**[513]int8)(__ccgo_up(bp)))[int32(1)] = 0 + } + fd = _robust_open(tls, bp, libc.Int32FromInt32(O_RDONLY)|libc.Int32FromInt32(O_BINARY), uint32(0)) + if fd >= 0 { + } + **(**int32)(__ccgo_up(pFd)) = fd + if fd >= 0 { + return SQLITE_OK + } + return _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(44080)), __ccgo_ts+3659, bp, int32(44080)) +} + +// C documentation +// +// /* +// ** Playback the journal and thus restore the database file to +// ** the state it was in before we started making changes. +// ** +// ** The journal file format is as follows: +// ** +// ** (1) 8 byte prefix. A copy of aJournalMagic[]. +// ** (2) 4 byte big-endian integer which is the number of valid page records +// ** in the journal. If this value is 0xffffffff, then compute the +// ** number of page records from the journal size. +// ** (3) 4 byte big-endian integer which is the initial value for the +// ** sanity checksum. +// ** (4) 4 byte integer which is the number of pages to truncate the +// ** database to during a rollback. +// ** (5) 4 byte big-endian integer which is the sector size. The header +// ** is this many bytes in size. +// ** (6) 4 byte big-endian integer which is the page size. +// ** (7) zero padding out to the next sector size. +// ** (8) Zero or more pages instances, each as follows: +// ** + 4 byte page number. +// ** + pPager->pageSize bytes of data. +// ** + 4 byte checksum +// ** +// ** When we speak of the journal header, we mean the first 7 items above. +// ** Each entry in the journal is an instance of the 8th item. +// ** +// ** Call the value from the second bullet "nRec". nRec is the number of +// ** valid page entries in the journal. In most cases, you can compute the +// ** value of nRec from the size of the journal file. But if a power +// ** failure occurred while the journal was being written, it could be the +// ** case that the size of the journal file had already been increased but +// ** the extra entries had not yet made it safely to disk. In such a case, +// ** the value of nRec computed from the file size would be too large. For +// ** that reason, we always use the nRec value in the header. +// ** +// ** If the nRec value is 0xffffffff it means that nRec should be computed +// ** from the file size. This value is used when the user selects the +// ** no-sync option for the journal. A power failure could lead to corruption +// ** in this case. But for things like temporary table (which will be +// ** deleted when the power is restored) we don't care. +// ** +// ** If the file opened as the journal file is not a well-formed +// ** journal file then all pages up to the first corrupted page are rolled +// ** back (or no pages if the journal header is corrupted). The journal file +// ** is then deleted and SQLITE_OK returned, just as if no corruption had +// ** been encountered. +// ** +// ** If an I/O or malloc() error occurs, the journal-file is not deleted +// ** and an error code is returned. +// ** +// ** The isHot parameter indicates that we are trying to rollback a journal +// ** that might be a hot journal. Or, it could be that the journal is +// ** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE. +// ** If the journal really is hot, reset the pager cache prior rolling +// ** back any content. If the journal is merely persistent, no reset is +// ** needed. +// */ +func _pager_playback(tls *libc.TLS, pPager uintptr, isHot int32) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var nPlayback, needPagerReset, rc int32 + var pVfs, zSuper uintptr + var u Tu32 + var _ /* mxPg at bp+12 */ TPgno + var _ /* nRec at bp+8 */ Tu32 + var _ /* res at bp+16 */ int32 + var _ /* savedPageSize at bp+20 */ Tu32 + var _ /* szJ at bp+0 */ Ti64 + _, _, _, _, _, _ = nPlayback, needPagerReset, pVfs, rc, u, zSuper + pVfs = (*TPager)(unsafe.Pointer(pPager)).FpVfs /* Unsigned loop counter */ + **(**TPgno)(__ccgo_up(bp + 12)) = uint32(0) /* Result code of a subroutine */ + **(**int32)(__ccgo_up(bp + 16)) = int32(1) /* Value returned by sqlite3OsAccess() */ + zSuper = uintptr(0) /* True to reset page prior to first page rollback */ + nPlayback = 0 /* Total number of pages restored from journal */ + **(**Tu32)(__ccgo_up(bp + 20)) = libc.Uint32FromInt64((*TPager)(unsafe.Pointer(pPager)).FpageSize) + /* Figure out how many records are in the journal. Abort early if + ** the journal is empty. + */ + rc = _sqlite3OsFileSize(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, bp) + if rc != SQLITE_OK { + goto end_playback + } + /* Read the super-journal name from the journal, if it is present. + ** If a super-journal file name is specified, but the file is not + ** present on disk, then the journal is not hot and does not need to be + ** played back. + ** + ** TODO: Technically the following is an error because it assumes that + ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that + ** ((pPager->pageSize+8) >= pPager->pVfs->mxPathname+1). Using os_unix.c, + ** mxPathname is 512, which is the same as the minimum allowable value + ** for pageSize, and so this assumption holds. But it might not for some + ** custom VFS. */ + zSuper = (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace + rc = _readSuperJournal(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd, zSuper, libc.Uint64FromInt64(int64(1)+int64((*Tsqlite3_vfs)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).FpVfs)).FmxPathname))) + if rc == SQLITE_OK && **(**int8)(__ccgo_up(zSuper)) != 0 { + rc = _sqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+16) + } + zSuper = uintptr(0) + if rc != SQLITE_OK || !(**(**int32)(__ccgo_up(bp + 16)) != 0) { + goto end_playback + } + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = 0 + needPagerReset = isHot + /* This loop terminates either when a readJournalHdr() or + ** pager_playback_one_page() call returns SQLITE_DONE or an IO error + ** occurs. + */ + for int32(1) != 0 { + /* Read the next journal header from the journal file. If there are + ** not enough bytes left in the journal file for a complete header, or + ** it is corrupted, then a process must have failed while writing it. + ** This indicates nothing more needs to be rolled back. + */ + rc = _readJournalHdr(tls, pPager, isHot, **(**Ti64)(__ccgo_up(bp)), bp+8, bp+12) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + } + goto end_playback + } + /* If nRec is 0xffffffff, then this journal was created by a process + ** working in no-sync mode. This means that the rest of the journal + ** file consists of pages, there are no more journal headers. Compute + ** the value of nRec based on this assumption. + */ + if **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0xffffffff) { + **(**Tu32)(__ccgo_up(bp + 8)) = libc.Uint32FromInt32(int32((**(**Ti64)(__ccgo_up(bp)) - libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize)) / ((*TPager)(unsafe.Pointer(pPager)).FpageSize + libc.Int64FromInt32(8)))) + } + /* If nRec is 0 and this rollback is of a transaction created by this + ** process and if this is the final header in the journal, then it means + ** that this part of the journal was being filled but has not yet been + ** synced to disk. Compute the number of pages based on the remaining + ** size of the file. + ** + ** The third term of the test was added to fix ticket #2565. + ** When rolling back a hot journal, nRec==0 always means that the next + ** chunk of the journal contains zero pages to be rolled back. But + ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in + ** the journal, it means that the journal might contain additional + ** pages that need to be rolled back and that the number of pages + ** should be computed based on the journal file size. + */ + if **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0) && !(isHot != 0) && (*TPager)(unsafe.Pointer(pPager)).FjournalHdr+libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) == (*TPager)(unsafe.Pointer(pPager)).FjournalOff { + **(**Tu32)(__ccgo_up(bp + 8)) = libc.Uint32FromInt32(int32((**(**Ti64)(__ccgo_up(bp)) - (*TPager)(unsafe.Pointer(pPager)).FjournalOff) / ((*TPager)(unsafe.Pointer(pPager)).FpageSize + libc.Int64FromInt32(8)))) + } + /* If this is the first header read from the journal, truncate the + ** database file back to its original size. + */ + if (*TPager)(unsafe.Pointer(pPager)).FjournalOff == libc.Int64FromUint32((*TPager)(unsafe.Pointer(pPager)).FsectorSize) { + rc = _pager_truncate(tls, pPager, **(**TPgno)(__ccgo_up(bp + 12))) + if rc != SQLITE_OK { + goto end_playback + } + (*TPager)(unsafe.Pointer(pPager)).FdbSize = **(**TPgno)(__ccgo_up(bp + 12)) + if (*TPager)(unsafe.Pointer(pPager)).FmxPgno < **(**TPgno)(__ccgo_up(bp + 12)) { + (*TPager)(unsafe.Pointer(pPager)).FmxPgno = **(**TPgno)(__ccgo_up(bp + 12)) + } + } + /* Copy original pages out of the journal and back into the + ** database file and/or page cache. + */ + u = uint32(0) + for { + if !(u < **(**Tu32)(__ccgo_up(bp + 8))) { + break + } + if needPagerReset != 0 { + _pager_reset(tls, pPager) + needPagerReset = 0 + } + rc = _pager_playback_one_page(tls, pPager, pPager+96, uintptr(0), int32(1), 0) + if rc == SQLITE_OK { + nPlayback = nPlayback + 1 + } else { + if rc == int32(SQLITE_DONE) { + (*TPager)(unsafe.Pointer(pPager)).FjournalOff = **(**Ti64)(__ccgo_up(bp)) + break + } else { + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(2)<= int32(PAGER_WRITER_DBMOD) || libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) { + rc = _sqlite3PagerSync(tls, pPager, uintptr(0)) + } + if rc == SQLITE_OK { + rc = _pager_end_transaction(tls, pPager, libc.BoolInt32(int32(**(**int8)(__ccgo_up(zSuper))) != int32('\000')), 0) + } + if rc == SQLITE_OK && **(**int8)(__ccgo_up(zSuper)) != 0 && **(**int32)(__ccgo_up(bp + 16)) != 0 { + /* If there was a super-journal and this routine will return success, + ** see if it is possible to delete the super-journal. + */ + libc.Xmemset(tls, (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace, 0, uint64(4)) + rc = _pager_delsuper(tls, pPager, zSuper) + } + if isHot != 0 && nPlayback != 0 { + Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_NOTICE)|libc.Int32FromInt32(2)< int32(1) { + return int32(1) + } /* IMP: R-33611-57934 */ + _autoAdjustDate(tls, p) + rc = 0 + } + case int32('c'): + /* + ** ceiling + ** + ** Resolve day-of-month overflow by rolling forward into the next + ** month. As this is the default action, this modifier is really + ** a no-op that is only included for symmetry. See "floor". + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1277) == 0 { + _computeJD(tls, p) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + (*TDateTime)(unsafe.Pointer(p)).FnFloor = 0 + } + case int32('f'): + /* + ** floor + ** + ** Resolve day-of-month overflow by rolling back to the end of the + ** previous month. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1285) == 0 { + _computeJD(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) -= int64(int32((*TDateTime)(unsafe.Pointer(p)).FnFloor) * int32(86400000)) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + } + case int32('j'): + /* + ** julianday + ** + ** Always interpret the prior number as a julian-day value. If this + ** is not the first modifier, or if the prior argument is not a numeric + ** value in the allowed range of julian day numbers understood by + ** SQLite (0..5373484.5) then the result will be NULL. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1291) == 0 { + if idx > int32(1) { + return int32(1) + } /* IMP: R-31176-64601 */ + if (*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0 && int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { + rc = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + } + } + case int32('l'): + /* localtime + ** + ** Assuming the current time value is UTC (a.k.a. GMT), shift it to + ** show local time. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1301) == 0 && _sqlite3NotPureFunc(tls, pCtx) != 0 { + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x10>>4)) != 0 { + v1 = SQLITE_OK + } else { + v1 = _toLocaltime(tls, p, pCtx) + } + rc = v1 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 4, 0x10) + } + case int32('u'): + /* + ** unixepoch + ** + ** Treat the current value of p->s as the number of + ** seconds since 1970. Convert to a real julian day number. + */ + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1311) == 0 && int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { + if idx > int32(1) { + return int32(1) + } /* IMP: R-49255-55373 */ + **(**float64)(__ccgo_up(bp)) = float64((*TDateTime)(unsafe.Pointer(p)).Fs*float64(1000)) + float64(2.1086676e+14) + if **(**float64)(__ccgo_up(bp)) >= float64(0) && **(**float64)(__ccgo_up(bp)) < float64(4.642690608e+14) { + _clearYMD_HMS_TZ(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(**(**float64)(__ccgo_up(bp)) + libc.Float64FromFloat64(0.5)) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = int8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + rc = 0 + } + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1321) == 0 && _sqlite3NotPureFunc(tls, pCtx) != 0 { + if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x8>>3)) == 0 { /* Guess at the corresponding utc time */ + cnt = 0 /* Guess is off by this much */ + _computeJD(tls, p) + v2 = (*TDateTime)(unsafe.Pointer(p)).FiJD + iOrigJD = v2 + iGuess = v2 + iErr = 0 + for { + libc.Xmemset(tls, bp+8, 0, uint64(48)) + iGuess = iGuess - iErr + (**(**TDateTime)(__ccgo_up(bp + 8))).FiJD = iGuess + (**(**TDateTime)(__ccgo_up(bp + 8))).FvalidJD = int8(1) + rc = _toLocaltime(tls, bp+8, pCtx) + if rc != 0 { + return rc + } + _computeJD(tls, bp+8) + iErr = (**(**TDateTime)(__ccgo_up(bp + 8))).FiJD - iOrigJD + goto _5 + _5: + ; + if v4 = iErr != 0; v4 { + v1 = cnt + cnt = cnt + 1 + } + if !(v4 && v1 < int32(3)) { + break + } + } + libc.Xmemset(tls, p, 0, uint64(48)) + (*TDateTime)(unsafe.Pointer(p)).FiJD = iGuess + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = int8(1) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) + } + rc = SQLITE_OK + } + } + case int32('w'): + /* + ** weekday N + ** + ** Move the date to the same time on the next occurrence of + ** weekday N where 0==Sunday, 1==Monday, and so forth. If the + ** date is already on the appropriate weekday, this is a no-op. + */ + if v4 = Xsqlite3_strnicmp(tls, z, __ccgo_ts+1325, int32(8)) == 0 && _sqlite3AtoF(tls, z+8, bp) > 0 && **(**float64)(__ccgo_up(bp)) >= float64(0) && **(**float64)(__ccgo_up(bp)) < float64(7); v4 { + v1 = int32(**(**float64)(__ccgo_up(bp))) + n = v1 + } + if v4 && float64(v1) == **(**float64)(__ccgo_up(bp)) { + _computeYMD_HMS(tls, p) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + _computeJD(tls, p) + Z = ((*TDateTime)(unsafe.Pointer(p)).FiJD + int64(129600000)) / int64(86400000) % int64(7) + if Z > int64(n) { + Z = Z - int64(7) + } + **(**Tsqlite3_int64)(__ccgo_up(p)) += (int64(n) - Z) * int64(86400000) + _clearYMD_HMS_TZ(tls, p) + rc = 0 + } + case int32('s'): + /* + ** start of TTTTT + ** + ** Move the date backwards to the beginning of the current day, + ** or month or year. + ** + ** subsecond + ** subsec + ** + ** Show subsecond precision in the output of datetime() and + ** unixepoch() and strftime('%s'). + */ + if Xsqlite3_strnicmp(tls, z, __ccgo_ts+1334, int32(9)) != 0 { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1232) == 0 || Xsqlite3_stricmp(tls, z, __ccgo_ts+1239) == 0 { + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 2, 0x4) + rc = 0 + } + break + } + if !((*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0) && !((*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0) && !((*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0) { + break + } + z = z + uintptr(9) + _computeYMD(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = int8(1) + v1 = libc.Int32FromInt32(0) + (*TDateTime)(unsafe.Pointer(p)).Fm = v1 + (*TDateTime)(unsafe.Pointer(p)).Fh = v1 + (*TDateTime)(unsafe.Pointer(p)).Fs = float64(0) + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1344) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) + rc = 0 + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1350) == 0 { + (*TDateTime)(unsafe.Pointer(p)).FM = int32(1) + (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) + rc = 0 + } else { + if Xsqlite3_stricmp(tls, z, __ccgo_ts+1355) == 0 { + rc = 0 + } + } + } + case int32('+'): + fallthrough + case int32('-'): + fallthrough + case int32('0'): + fallthrough + case int32('1'): + fallthrough + case int32('2'): + fallthrough + case int32('3'): + fallthrough + case int32('4'): + fallthrough + case int32('5'): + fallthrough + case int32('6'): + fallthrough + case int32('7'): + fallthrough + case int32('8'): + fallthrough + case int32('9'): + z2 = z + db = Xsqlite3_context_db_handle(tls, pCtx) + z0 = **(**int8)(__ccgo_up(z)) + n = int32(1) + for { + if !(**(**int8)(__ccgo_up(z + uintptr(n))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(z + uintptr(n)))) == int32(':') { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(n))))])&int32(0x01) != 0 { + break + } + if int32(**(**int8)(__ccgo_up(z + uintptr(n)))) == int32('-') { + if n == int32(5) && _getDigits(tls, z+1, __ccgo_ts+1359, libc.VaList(bp+136, bp+56)) == int32(1) { + break + } + if n == int32(6) && _getDigits(tls, z+1, __ccgo_ts+1363, libc.VaList(bp+136, bp+56)) == int32(1) { + break + } + } + goto _9 + _9: + ; + n = n + 1 + } + zCopy = _sqlite3DbStrNDup(tls, db, z, libc.Uint64FromInt32(n)) + if zCopy == uintptr(0) { + break + } + rx = libc.BoolInt32(_sqlite3AtoF(tls, zCopy, bp) <= 0) + _sqlite3DbFree(tls, db, zCopy) + if rx != 0 { + break + } + if int32(**(**int8)(__ccgo_up(z + uintptr(n)))) == int32('-') { + /* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the + ** specified number of years, months, and days. MM is limited to + ** the range 0-11 and DD is limited to 0-30. + */ + if int32(z0) != int32('+') && int32(z0) != int32('-') { + break + } /* Must start with +/- */ + if n == int32(5) { + if _getDigits(tls, z+1, __ccgo_ts+1367, libc.VaList(bp+136, bp+56, bp+60, bp+64)) != int32(3) { + break + } + } else { + if _getDigits(tls, z+1, __ccgo_ts+1379, libc.VaList(bp+136, bp+56, bp+60, bp+64)) != int32(3) { + break + } + z = z + 1 + } + if **(**int32)(__ccgo_up(bp + 60)) >= int32(12) { + break + } /* M range 0..11 */ + if **(**int32)(__ccgo_up(bp + 64)) >= int32(31) { + break + } /* D range 0..30 */ + _computeYMD_HMS(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + if int32(z0) == int32('-') { + **(**int32)(__ccgo_up(p + 8)) -= **(**int32)(__ccgo_up(bp + 56)) + **(**int32)(__ccgo_up(p + 12)) -= **(**int32)(__ccgo_up(bp + 60)) + **(**int32)(__ccgo_up(bp + 64)) = -**(**int32)(__ccgo_up(bp + 64)) + } else { + **(**int32)(__ccgo_up(p + 8)) += **(**int32)(__ccgo_up(bp + 56)) + **(**int32)(__ccgo_up(p + 12)) += **(**int32)(__ccgo_up(bp + 60)) + } + if (*TDateTime)(unsafe.Pointer(p)).FM > 0 { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(1)) / int32(12) + } else { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(12)) / int32(12) + } + x = v1 + **(**int32)(__ccgo_up(p + 8)) += x + **(**int32)(__ccgo_up(p + 12)) -= x * int32(12) + _computeFloor(tls, p) + _computeJD(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = 0 + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = 0 + **(**Tsqlite3_int64)(__ccgo_up(p)) += int64(**(**int32)(__ccgo_up(bp + 64))) * int64(86400000) + if int32(**(**int8)(__ccgo_up(z + 11))) == 0 { + rc = 0 + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + 11)))])&int32(0x01) != 0 && _getDigits(tls, z+12, __ccgo_ts+1204, libc.VaList(bp+136, bp+68, bp+72)) == int32(2) { + z2 = z + 12 + n = int32(2) + } else { + break + } + } + if int32(**(**int8)(__ccgo_up(z2 + uintptr(n)))) == int32(':') { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z2)))])&libc.Int32FromInt32(0x04) != 0) { + z2 = z2 + 1 + } + libc.Xmemset(tls, bp+80, 0, uint64(48)) + if _parseHhMmSs(tls, z2, bp+80) != 0 { + break + } + _computeJD(tls, bp+80) + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD -= int64(43200000) + day = (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD / int64(86400000) + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD -= day * int64(86400000) + if int32(z0) == int32('-') { + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD = -(**(**TDateTime)(__ccgo_up(bp + 80))).FiJD + } + _computeJD(tls, p) + _clearYMD_HMS_TZ(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) += (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD + rc = 0 + break + } + /* If control reaches this point, it means the transformation is + ** one of the forms like "+NNN days". */ + z = z + uintptr(n) + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z)))])&int32(0x01) != 0 { + z = z + 1 + } + n = _sqlite3Strlen30(tls, z) + if n < int32(3) || n > int32(10) { + break + } + if libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(n-int32(1)))))]) == int32('s') { + n = n - 1 + } + _computeJD(tls, p) + if **(**float64)(__ccgo_up(bp)) < libc.Float64FromInt32(0) { + v11 = -libc.Float64FromFloat64(0.5) + } else { + v11 = +libc.Float64FromFloat64(0.5) + } + rRounder = v11 + (*TDateTime)(unsafe.Pointer(p)).FnFloor = 0 + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(96)/libc.Uint64FromInt64(16))) { + break + } + if libc.Int32FromUint8(_aXformType[i].FnName) == n && Xsqlite3_strnicmp(tls, uintptr(unsafe.Pointer(&_aXformType))+uintptr(i)*16+1, z, n) == 0 && **(**float64)(__ccgo_up(bp)) > float64(-_aXformType[i].FrLimit) && **(**float64)(__ccgo_up(bp)) < float64(_aXformType[i].FrLimit) { + switch i { + case int32(4): /* Special processing to add months */ + _computeYMD_HMS(tls, p) + **(**int32)(__ccgo_up(p + 12)) += int32(**(**float64)(__ccgo_up(bp))) + if (*TDateTime)(unsafe.Pointer(p)).FM > 0 { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(1)) / int32(12) + } else { + v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(12)) / int32(12) + } + x = v1 + **(**int32)(__ccgo_up(p + 8)) += x + **(**int32)(__ccgo_up(p + 12)) -= x * int32(12) + _computeFloor(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + **(**float64)(__ccgo_up(bp)) = **(**float64)(__ccgo_up(bp)) - float64(int32(**(**float64)(__ccgo_up(bp)))) + case int32(5): /* Special processing to add years */ + y = int32(**(**float64)(__ccgo_up(bp))) + _computeYMD_HMS(tls, p) + **(**int32)(__ccgo_up(p + 8)) += y + _computeFloor(tls, p) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + **(**float64)(__ccgo_up(bp)) = **(**float64)(__ccgo_up(bp)) - float64(int32(**(**float64)(__ccgo_up(bp)))) + break + } + _computeJD(tls, p) + **(**Tsqlite3_int64)(__ccgo_up(p)) += int64(float64(float64(**(**float64)(__ccgo_up(bp))*libc.Float64FromFloat64(1000))*float64(_aXformType[i].FrXform)) + rRounder) + rc = 0 + break + } + goto _12 + _12: + ; + i = i + 1 + } + _clearYMD_HMS_TZ(tls, p) + default: + break + } + return rc +} + +// C documentation +// +// /* +// ** Pragma virtual table module xConnect method. +// */ +func _pragmaVtabConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var cSep int8 + var i, j, rc int32 + var pPragma, pTab uintptr + var _ /* acc at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [200]int8 + _, _, _, _, _, _ = cSep, i, j, pPragma, pTab, rc + pPragma = pAux + pTab = uintptr(0) + cSep = int8('(') + _ = argc + _ = argv + _sqlite3StrAccumInit(tls, bp, uintptr(0), bp+32, int32(200), 0) + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+19906) + i = 0 + j = libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FiPragCName) + for { + if !(i < libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FnPragCName)) { + break + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+19921, libc.VaList(bp+240, int32(cSep), _pragCName[j])) + cSep = int8(',') + goto _1 + _1: + ; + i = i + 1 + j = j + 1 + } + if i == 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+19928, libc.VaList(bp+240, (*TPragmaName)(unsafe.Pointer(pPragma)).FzName)) + i = i + 1 + } + j = 0 + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_Result1) != 0 { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+19934) + j = j + 1 + } + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&(libc.Int32FromInt32(PragFlg_SchemaOpt)|libc.Int32FromInt32(PragFlg_SchemaReq)) != 0 { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+19946) + j = j + 1 + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5257, int32(1)) + _sqlite3StrAccumFinish(tls, bp) + rc = Xsqlite3_declare_vtab(tls, db, bp+32) + if rc == SQLITE_OK { + pTab = Xsqlite3_malloc(tls, int32(48)) + if pTab == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + libc.Xmemset(tls, pTab, 0, uint64(48)) + (*TPragmaVtab)(unsafe.Pointer(pTab)).FpName = pPragma + (*TPragmaVtab)(unsafe.Pointer(pTab)).Fdb = db + (*TPragmaVtab)(unsafe.Pointer(pTab)).FiHidden = libc.Uint8FromInt32(i) + (*TPragmaVtab)(unsafe.Pointer(pTab)).FnHidden = libc.Uint8FromInt32(j) + } + } else { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+240, Xsqlite3_errmsg(tls, db))) + } + **(**uintptr)(__ccgo_up(ppVtab)) = pTab + return rc +} + +// C documentation +// +// /* +// ** If the error code currently stored in the RBU handle is SQLITE_CONSTRAINT, +// ** then edit any error message string so as to remove all occurrences of +// ** the pattern "rbu_imp_[0-9]*". +// */ +func _rbuEditErrmsg(tls *libc.TLS, p uintptr) { + var i uint32 + var nDel int32 + var nErrmsg Tsize_t + _, _, _ = i, nDel, nErrmsg + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_CONSTRAINT) && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg != 0 { + nErrmsg = libc.Xstrlen(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg) + i = uint32(0) + for { + if !(uint64(i) < nErrmsg-uint64(8)) { + break + } + if libc.Xmemcmp(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i), __ccgo_ts+32630, uint64(8)) == 0 { + nDel = int32(8) + for int32(**(**int8)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + uintptr(i+libc.Uint32FromInt32(nDel))))) >= int32('0') && int32(**(**int8)(__ccgo_up((*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + uintptr(i+libc.Uint32FromInt32(nDel))))) <= int32('9') { + nDel = nDel + 1 + } + libc.Xmemmove(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i), (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i+libc.Uint32FromInt32(nDel)), nErrmsg+uint64(1)-uint64(i)-libc.Uint64FromInt32(nDel)) + nErrmsg = nErrmsg - libc.Uint64FromInt32(nDel) + } + goto _1 + _1: + ; + i = i + 1 + } + } +} + +func _rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var aIdxCol, zRet, zSql, v1 uintptr + var c int8 + var i, iIdxCol, nIdxAlloc, nParen, nSpan, nSpan1, rc2, v3 int32 + var _ /* pStmt at bp+0 */ uintptr + var _ /* rc at bp+8 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _ = aIdxCol, c, i, iIdxCol, nIdxAlloc, nParen, nSpan, nSpan1, rc2, zRet, zSql, v1, v3 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**int32)(__ccgo_up(bp + 8)) = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc + zRet = uintptr(0) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = _prepareAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, __ccgo_ts+32118) + } + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = Xsqlite3_bind_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx, -int32(1), libc.UintptrFromInt32(0)) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + zSql = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), 0) + if zSql != 0 { + v1 = _rbuStrndup(tls, zSql, bp+8) + zSql = v1 + (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = v1 + } + if zSql != 0 { + nParen = 0 + iIdxCol = 0 + nIdxAlloc = 0 + i = 0 + for { + if !(**(**int8)(__ccgo_up(zSql + uintptr(i))) != 0) { + break + } + c = **(**int8)(__ccgo_up(zSql + uintptr(i))) + /* If necessary, grow the pIter->aIdxCol[] array */ + if iIdxCol == nIdxAlloc { + aIdxCol = Xsqlite3_realloc64(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol, uint64(libc.Uint64FromInt32(nIdxAlloc)*uint64(16)+libc.Uint64FromInt32(16)*libc.Uint64FromInt64(16))) + if aIdxCol == uintptr(0) { + **(**int32)(__ccgo_up(bp + 8)) = int32(SQLITE_NOMEM) + break + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = aIdxCol + nIdxAlloc = nIdxAlloc + int32(16) + } + if int32(c) == int32('(') { + if nParen == 0 { + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol))).FzSpan = zSql + uintptr(i+int32(1)) + } + nParen = nParen + 1 + } else { + if int32(c) == int32(')') { + nParen = nParen - 1 + if nParen == 0 { + nSpan = int32(t__predefined_ptrdiff_t(zSql+uintptr(i)) - int64((**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan)) + v3 = iIdxCol + iIdxCol = iIdxCol + 1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(v3)*16))).FnSpan = nSpan + i = i + 1 + break + } + } else { + if int32(c) == int32(',') && nParen == int32(1) { + nSpan1 = int32(t__predefined_ptrdiff_t(zSql+uintptr(i)) - int64((**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan)) + v3 = iIdxCol + iIdxCol = iIdxCol + 1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(v3)*16))).FnSpan = nSpan1 + (**(**TRbuSpan)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*16))).FzSpan = zSql + uintptr(i+int32(1)) + } else { + if int32(c) == int32('"') || int32(c) == int32('\'') || int32(c) == int32('`') { + i = i + 1 + for { + if !(int32(1) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) == int32(c) { + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i+int32(1))))) != int32(c) { + break + } + i = i + 1 + } + goto _5 + _5: + ; + i = i + 1 + } + } else { + if int32(c) == int32('[') { + i = i + 1 + for { + if !(int32(1) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) == int32(']') { + break + } + goto _6 + _6: + ; + i = i + 1 + } + } else { + if int32(c) == int32('-') && int32(**(**int8)(__ccgo_up(zSql + uintptr(i+int32(1))))) == int32('-') { + i = i + int32(2) + for { + if !(**(**int8)(__ccgo_up(zSql + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) != int32('\n')) { + break + } + goto _7 + _7: + ; + i = i + 1 + } + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) == int32('\000') { + break + } + } else { + if int32(c) == int32('/') && int32(**(**int8)(__ccgo_up(zSql + uintptr(i+int32(1))))) == int32('*') { + i = i + int32(2) + for { + if !(**(**int8)(__ccgo_up(zSql + uintptr(i))) != 0 && (int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) != int32('*') || int32(**(**int8)(__ccgo_up(zSql + uintptr(i+int32(1))))) != int32('/'))) { + break + } + goto _8 + _8: + ; + i = i + 1 + } + if int32(**(**int8)(__ccgo_up(zSql + uintptr(i)))) == int32('\000') { + break + } + i = i + 1 + } + } + } + } + } + } + } + goto _2 + _2: + ; + i = i + 1 + } + if **(**int8)(__ccgo_up(zSql + uintptr(i))) != 0 { + zRet = _rbuStrndup(tls, zSql+uintptr(i), bp+8) + } + (*TRbuObjIter)(unsafe.Pointer(pIter)).FnIdxCol = iIdxCol + } + } + rc2 = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**int32)(__ccgo_up(bp + 8)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp + 8)) = rc2 + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = **(**int32)(__ccgo_up(bp + 8)) + return zRet +} + +// C documentation +// +// /* +// ** Return a nul-terminated string containing the comma separated list of +// ** assignments that should be included following the "SET" keyword of +// ** an UPDATE statement used to update the table object that the iterator +// ** passed as the second argument currently points to if the rbu_control +// ** column of the data_xxx table entry is set to zMask. +// ** +// ** The memory for the returned string is obtained from sqlite3_malloc(). +// ** It is the responsibility of the caller to eventually free it using +// ** sqlite3_free(). +// ** +// ** If an OOM error is encountered when allocating space for the new +// ** string, an error code is left in the rbu handle passed as the first +// ** argument and NULL is returned. Or, if an error has already occurred +// ** when this function is called, NULL is returned immediately, without +// ** attempting the allocation or modifying the stored error code. +// */ +func _rbuObjIterGetSetlist(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr) (r uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var c int8 + var i int32 + var zList, zSep uintptr + _, _, _, _ = c, i, zList, zSep + zList = uintptr(0) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if libc.Int32FromUint64(libc.Xstrlen(tls, zMask)) != (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { + _rbuBadControlError(tls, p) + } else { + zSep = __ccgo_ts + 1704 + i = 0 + for { + if !(i < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnTblCol) { + break + } + c = **(**int8)(__ccgo_up(zMask + uintptr(**(**int32)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4))))) + if int32(c) == int32('x') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31664, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16214 + } else { + if int32(c) == int32('d') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31703, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16214 + } else { + if int32(c) == int32('f') { + zList = _rbuMPrintf(tls, p, __ccgo_ts+31733, libc.VaList(bp+8, zList, zSep, **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)), i+int32(1))) + zSep = __ccgo_ts + 16214 + } + } + } + goto _1 + _1: + ; + i = i + 1 + } + } + } + return zList +} + +// C documentation +// +// /* +// ** Open the database handle and attach the RBU database as "rbu". If an +// ** error occurs, leave an error code and message in the RBU handle. +// ** +// ** If argument dbMain is not NULL, then it is a database handle already +// ** open on the target database. Use this handle instead of opening a new +// ** one. +// */ +func _rbuOpenDatabase(tls *libc.TLS, p uintptr, dbMain uintptr, pbRetry uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOpen, rc int32 + var pState, zExtra, zFile, zTarget, v1, v2 uintptr + _, _, _, _, _, _, _, _ = bOpen, pState, rc, zExtra, zFile, zTarget, v1, v2 + /* Open the RBU database */ + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, int32(1)) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = dbMain + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816, int32(SQLITE_FCNTL_RBUCNT), p) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState == uintptr(0) { + zFile = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState = _rbuMPrintf(tls, p, __ccgo_ts+33351, libc.VaList(bp+8, zFile, zFile)) + } + } + /* If using separate RBU and state databases, attach the state database to + ** the RBU db handle now. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState != 0 { + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33379, libc.VaList(bp+8, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzState)) + libc.Xmemcpy(tls, p+48, __ccgo_ts+3567, uint64(4)) + } else { + libc.Xmemcpy(tls, p+48, __ccgo_ts+6816, uint64(4)) + } + /* If it has not already been created, create the rbu_state table */ + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33397, libc.VaList(bp+8, p+48)) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + bOpen = 0 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu = 0 + (*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd = uintptr(0) + rc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816, int32(SQLITE_FCNTL_RBUCNT), p) + if rc != int32(SQLITE_NOTFOUND) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage >= int32(RBU_STAGE_MOVE) { + bOpen = int32(1) + } else { + pState = _rbuLoadState(tls, p) + if pState != 0 { + bOpen = libc.BoolInt32((*TRbuState)(unsafe.Pointer(pState)).FeStage >= int32(RBU_STAGE_MOVE)) + _rbuFreeState(tls, pState) + } + } + if bOpen != 0 { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu <= int32(1))) + } + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain == uintptr(0) { + if !((*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == libc.UintptrFromInt32(0)) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget, int32(1)) + } else { + if (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FpWalFd != 0 { + if pbRetry != 0 { + (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FbNolock = uint8(0) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu) + Xsqlite3_close(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu = uintptr(0) + **(**int32)(__ccgo_up(pbRetry)) = int32(1) + return + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+33463, 0) + } else { + zExtra = uintptr(0) + if libc.Xstrlen(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu) >= uint64(5) && 0 == libc.Xmemcmp(tls, __ccgo_ts+26049, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu, uint64(5)) { + zExtra = (*Tsqlite3rbu)(unsafe.Pointer(p)).FzRbu + 5 + for **(**int8)(__ccgo_up(zExtra)) != 0 { + v1 = zExtra + zExtra = zExtra + 1 + if int32(**(**int8)(__ccgo_up(v1))) == int32('?') { + break + } + } + if int32(**(**int8)(__ccgo_up(zExtra))) == int32('\000') { + zExtra = uintptr(0) + } + } + if zExtra == uintptr(0) { + v1 = __ccgo_ts + 1704 + } else { + v1 = __ccgo_ts + 33495 + } + if zExtra == uintptr(0) { + v2 = __ccgo_ts + 1704 + } else { + v2 = zExtra + } + zTarget = Xsqlite3_mprintf(tls, __ccgo_ts+33497, libc.VaList(bp+8, Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+6816), v1, v2)) + if zTarget == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + return + } + (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain = _rbuOpenDbhandle(tls, p, zTarget, libc.BoolInt32((*Tsqlite3rbu)(unsafe.Pointer(p)).FnRbu <= int32(1))) + Xsqlite3_free(tls, zTarget) + } + } + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33529, -int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_rbuTmpInsertFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33544, int32(2), int32(SQLITE_UTF8), uintptr(0), __ccgo_fp(_rbuFossilDeltaFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+33561, -int32(1), int32(SQLITE_UTF8), p, __ccgo_fp(_rbuTargetNameFunc), uintptr(0), uintptr(0)) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, int32(SQLITE_FCNTL_RBU), p) + } + _rbuMPrintfExec(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33577, 0) + /* Mark the database file just opened as an RBU target database. If + ** this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use. + ** This is an error. */ + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6816, int32(SQLITE_FCNTL_RBU), p) + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == int32(SQLITE_NOTFOUND) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR) + (*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+33605, 0) + } +} + +// C documentation +// +// /* +// ** The implementation of the rbu_target_name() SQL function. This function +// ** accepts one or two arguments. The first argument is the name of a table - +// ** the name of a table in the RBU database. The second, if it is present, is 1 +// ** for a view or 0 for a table. +// ** +// ** For a non-vacuum RBU handle, if the table name matches the pattern: +// ** +// ** data[0-9]_ +// ** +// ** where is any sequence of 1 or more characters, is returned. +// ** Otherwise, if the only argument does not match the above pattern, an SQL +// ** NULL is returned. +// ** +// ** "data_t1" -> "t1" +// ** "data0123_t2" -> "t2" +// ** "dataAB_t3" -> NULL +// ** +// ** For an rbu vacuum handle, a copy of the first argument is returned if +// ** the second argument is either missing or 0 (not a view). +// */ +func _rbuTargetNameFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { + var i int32 + var p, zIn uintptr + _, _, _ = i, p, zIn + p = Xsqlite3_user_data(tls, pCtx) + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn != 0 { + if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) { + if argc == int32(1) || 0 == Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv + 1*8))) { + Xsqlite3_result_text(tls, pCtx, zIn, -int32(1), libc.UintptrFromInt32(0)) + } + } else { + if libc.Xstrlen(tls, zIn) > uint64(4) && libc.Xmemcmp(tls, __ccgo_ts+27339, zIn, uint64(4)) == 0 { + i = int32(4) + for { + if !(int32(**(**int8)(__ccgo_up(zIn + uintptr(i)))) >= int32('0') && int32(**(**int8)(__ccgo_up(zIn + uintptr(i)))) <= int32('9')) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i)))) == int32('_') && **(**int8)(__ccgo_up(zIn + uintptr(i+int32(1)))) != 0 { + Xsqlite3_result_text(tls, pCtx, zIn+uintptr(i+int32(1)), -int32(1), libc.UintptrFromInt32(0)) + } + } + } + } +} + +// C documentation +// +// /* +// ** This function is called as part of restating an RBU vacuum when the +// ** current operation is writing content to an index. If possible, it +// ** queries the target index b-tree for the largest key already written to +// ** it, then composes and returns an expression that can be used in a WHERE +// ** clause to select the remaining required rows from the source table. +// ** It is only possible to return such an expression if: +// ** +// ** * The index contains no DESC columns, and +// ** * The last key written to the index before the operation was +// ** suspended does not contain any NULL values. +// ** +// ** The expression is of the form: +// ** +// ** (index-field1, index-field2, ...) > (?, ?, ...) +// ** +// ** except that the "?" placeholders are replaced with literal values. +// ** +// ** If the expression cannot be created, NULL is returned. In this case, +// ** the caller has to use an OFFSET clause to extract only the required +// ** rows from the sourct table, just as it does for an RBU update operation. +// */ +func _rbuVacuumIndexStart(tls *libc.TLS, p uintptr, pIter uintptr) (r uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bFailed, i, iCid, iCol int32 + var zCol, zCollate, zLhs, zOrder, zQuoted, zRet, zSelect, zSep, zVector uintptr + var _ /* pSel at bp+8 */ uintptr + var _ /* pXInfo at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _ = bFailed, i, iCid, iCol, zCol, zCollate, zLhs, zOrder, zQuoted, zRet, zSelect, zSep, zVector + zOrder = uintptr(0) + zLhs = uintptr(0) + zSelect = uintptr(0) + zVector = uintptr(0) + zRet = uintptr(0) + bFailed = 0 + zSep = __ccgo_ts + 1704 + iCol = 0 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+30950, libc.VaList(bp+24, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) + for (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) { + iCid = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(1)) + zCollate = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(4)) + if Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(3)) != 0 { + bFailed = int32(1) + break + } + if iCid < 0 { + if (*TRbuObjIter)(unsafe.Pointer(pIter)).FeType == int32(RBU_PK_IPK) { + i = 0 + for { + if !(libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*8)) + } else { + zCol = __ccgo_ts + 31273 + } + } else { + zCol = **(**uintptr)(__ccgo_up((*TRbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCid)*8)) + } + zLhs = _rbuMPrintf(tls, p, __ccgo_ts+31281, libc.VaList(bp+24, zLhs, zSep, zCol, zCollate)) + zOrder = _rbuMPrintf(tls, p, __ccgo_ts+31302, libc.VaList(bp+24, zOrder, zSep, iCol, zCol, zCollate)) + zSelect = _rbuMPrintf(tls, p, __ccgo_ts+31338, libc.VaList(bp+24, zSelect, zSep, iCol, zCol)) + zSep = __ccgo_ts + 16214 + iCol = iCol + 1 + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp))) + if bFailed != 0 { + goto index_start_out + } + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = _prepareFreeAndCollectError(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8, p+64, Xsqlite3_mprintf(tls, __ccgo_ts+31365, libc.VaList(bp+24, zSelect, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) + if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp + 8))) { + zSep = __ccgo_ts + 1704 + iCol = 0 + for { + if !(iCol < (*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol) { + break + } + zQuoted = Xsqlite3_column_text(tls, **(**uintptr)(__ccgo_up(bp + 8)), iCol) + if zQuoted == uintptr(0) { + (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM) + } else { + if int32(**(**int8)(__ccgo_up(zQuoted))) == int32('N') { + bFailed = int32(1) + break + } + } + zVector = _rbuMPrintf(tls, p, __ccgo_ts+31413, libc.VaList(bp+24, zVector, zSep, zQuoted)) + zSep = __ccgo_ts + 16214 + goto _2 + _2: + ; + iCol = iCol + 1 + } + if !(bFailed != 0) { + zRet = _rbuMPrintf(tls, p, __ccgo_ts+31420, libc.VaList(bp+24, zLhs, zVector)) + } + } + _rbuFinalize(tls, p, **(**uintptr)(__ccgo_up(bp + 8))) + } + goto index_start_out +index_start_out: + ; + Xsqlite3_free(tls, zOrder) + Xsqlite3_free(tls, zSelect) + Xsqlite3_free(tls, zVector) + Xsqlite3_free(tls, zLhs) + return zRet +} + +// C documentation +// +// /* +// ** Open an rbu file handle. +// */ +func _rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) (r int32) { + var nOpen Tsize_t + var oflags, rc int32 + var pDb, pFd, pMeth, pRbuVfs, pRealVfs, zOpen uintptr + _, _, _, _, _, _, _, _, _ = nOpen, oflags, pDb, pFd, pMeth, pRbuVfs, pRealVfs, rc, zOpen + pRbuVfs = pVfs + pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs + pFd = pFile + rc = SQLITE_OK + zOpen = zName + oflags = flags + libc.Xmemset(tls, pFd, 0, uint64(104)) + (*Trbu_file)(unsafe.Pointer(pFd)).FpReal = pFd + 1*104 + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbuVfs = pRbuVfs + (*Trbu_file)(unsafe.Pointer(pFd)).FopenFlags = flags + if zName != 0 { + if flags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + /* A main database has just been opened. The following block sets + ** (pFd->zWal) to point to a buffer owned by SQLite that contains + ** the name of the *-wal file this db connection will use. SQLite + ** happens to pass a pointer to this buffer when using xAccess() + ** or xOpen() to operate on the *-wal file. */ + (*Trbu_file)(unsafe.Pointer(pFd)).FzWal = Xsqlite3_filename_wal(tls, zName) + } else { + if flags&int32(SQLITE_OPEN_WAL) != 0 { + pDb = _rbuFindMaindb(tls, pRbuVfs, zName, 0) + if pDb != 0 { + if (*Trbu_file)(unsafe.Pointer(pDb)).FpRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == int32(RBU_STAGE_OAL) { + if (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FzTarget == uintptr(0) { + zOpen = Xsqlite3_db_filename(tls, (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FdbRbu, __ccgo_ts+6816) + zOpen = Xsqlite3_filename_wal(tls, zOpen) + } + nOpen = libc.Xstrlen(tls, zOpen) + **(**int8)(__ccgo_up(zOpen + uintptr(nOpen-uint64(3)))) = int8('o') + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Trbu_file)(unsafe.Pointer(pDb)).FpRbu + } + (*Trbu_file)(unsafe.Pointer(pDb)).FpWalFd = pFd + } + } + } + } else { + (*Trbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRbu + } + if oflags&int32(SQLITE_OPEN_MAIN_DB) != 0 && Xsqlite3_uri_boolean(tls, zName, __ccgo_ts+34676, 0) != 0 { + oflags = libc.Int32FromInt32(SQLITE_OPEN_TEMP_DB) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) + zOpen = uintptr(0) + } + if rc == SQLITE_OK { + rc = (*(*func(*libc.TLS, uintptr, Tsqlite3_filename, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxOpen})))(tls, pRealVfs, zOpen, (*Trbu_file)(unsafe.Pointer(pFd)).FpReal, oflags, pOutFlags) + } + if (*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods != 0 { + pMeth = (*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods + /* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods + ** pointer and, if the file is a main database file, link it into the + ** mutex protected linked list of all such files. */ + if (*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FiVersion < int32(2) || (*Tsqlite3_io_methods)(unsafe.Pointer(pMeth)).FxShmLock == uintptr(0) { + (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&_rbuvfs_io_methods1)) + } else { + (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&_rbuvfs_io_methods)) + } + if flags&int32(SQLITE_OPEN_MAIN_DB) != 0 { + _rbuMainlistAdd(tls, pFd) + } + } else { + Xsqlite3_free(tls, (*Trbu_file)(unsafe.Pointer(pFd)).FzDel) + } + return rc +} + +// C documentation +// +// /* +// ** This function edits SQL statement zSql, replacing each token identified +// ** by the linked list pRename with the text of zNew. If argument bQuote is +// ** true, then zNew is always quoted first. If no error occurs, the result +// ** is loaded into context object pCtx as the result. +// ** +// ** Or, if an error occurs (i.e. an OOM condition), an error is left in +// ** pCtx and an SQLite error code returned. +// */ +func _renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, zNew uintptr, bQuote int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pBest, zBuf1, zBuf2, zOut, zQuot, zReplace, v1 uintptr + var iOff, rc int32 + var nNew, nOut, nQuot, nReplace, nSql Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, iOff, nNew, nOut, nQuot, nReplace, nSql, pBest, rc, zBuf1, zBuf2, zOut, zQuot, zReplace, v1 + nNew = int64(_sqlite3Strlen30(tls, zNew)) + nSql = int64(_sqlite3Strlen30(tls, zSql)) + db = Xsqlite3_context_db_handle(tls, pCtx) + rc = SQLITE_OK + zQuot = uintptr(0) + nQuot = 0 + zBuf1 = uintptr(0) + zBuf2 = uintptr(0) + if zNew != 0 { + /* Set zQuot to point to a buffer containing a quoted copy of the + ** identifier zNew. If the corresponding identifier in the original + ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to + ** point to zQuot so that all substitutions are made using the + ** quoted version of the new column name. */ + zQuot = _sqlite3MPrintf(tls, db, __ccgo_ts+11574, libc.VaList(bp+8, zNew)) + if zQuot == uintptr(0) { + return int32(SQLITE_NOMEM) + } else { + nQuot = int64(_sqlite3Strlen30(tls, zQuot) - int32(1)) + } + zOut = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nSql)+libc.Uint64FromInt32((*TRenameCtx)(unsafe.Pointer(pRename)).FnList)*libc.Uint64FromInt64(nQuot)+uint64(1)) + } else { + zOut = _sqlite3DbMallocZero(tls, db, (uint64(2)*libc.Uint64FromInt64(nSql)+uint64(1))*uint64(3)) + if zOut != 0 { + zBuf1 = zOut + uintptr(nSql*int64(2)+int64(1)) + zBuf2 = zOut + uintptr(nSql*int64(4)+int64(2)) + } + } + /* At this point pRename->pList contains a list of RenameToken objects + ** corresponding to all tokens in the input SQL that must be replaced + ** with the new column name, or with single-quoted versions of themselves. + ** All that remains is to construct and return the edited SQL string. */ + if zOut != 0 { + nOut = nSql + libc.Xmemcpy(tls, zOut, zSql, libc.Uint64FromInt64(nSql)) + for (*TRenameCtx)(unsafe.Pointer(pRename)).FpList != 0 { + pBest = _renameColumnTokenNext(tls, pRename) + if zNew != 0 { + if bQuote == 0 && _sqlite3IsIdChar(tls, **(**Tu8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz))) != 0 { + nReplace = nNew + zReplace = zNew + } else { + nReplace = nQuot + zReplace = zQuot + if int32(**(**int8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)))) == int32('"') { + nReplace = nReplace + 1 + } + } + } else { + /* Dequote the double-quoted token. Then requote it again, this time + ** using single quotes. If the character immediately following the + ** original token within the input SQL was a single quote ('), then + ** add another space after the new, single-quoted version of the + ** token. This is so that (SELECT "string"'alias') maps to + ** (SELECT 'string' 'alias'), and not (SELECT 'string''alias'). */ + libc.Xmemcpy(tls, zBuf1, (*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz, uint64((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)) + **(**int8)(__ccgo_up(zBuf1 + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn))) = 0 + _sqlite3Dequote(tls, zBuf1) + if int32(**(**int8)(__ccgo_up((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz + uintptr((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)))) == int32('\'') { + v1 = __ccgo_ts + 11541 + } else { + v1 = __ccgo_ts + 1704 + } + Xsqlite3_snprintf(tls, int32(nSql*libc.Int64FromInt32(2)), zBuf2, __ccgo_ts+11580, libc.VaList(bp+8, zBuf1, v1)) + zReplace = zBuf2 + nReplace = int64(_sqlite3Strlen30(tls, zReplace)) + } + iOff = int32(int64((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fz) - int64(zSql)) + if libc.Int64FromUint32((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn) != nReplace { + libc.Xmemmove(tls, zOut+uintptr(int64(iOff)+nReplace), zOut+uintptr(libc.Uint32FromInt32(iOff)+(*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn), libc.Uint64FromInt64(nOut-libc.Int64FromUint32(libc.Uint32FromInt32(iOff)+(*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn))) + nOut = nOut + (nReplace - libc.Int64FromUint32((*TRenameToken)(unsafe.Pointer(pBest)).Ft.Fn)) + **(**int8)(__ccgo_up(zOut + uintptr(nOut))) = int8('\000') + } + libc.Xmemcpy(tls, zOut+uintptr(iOff), zReplace, libc.Uint64FromInt64(nReplace)) + _sqlite3DbFree(tls, db, pBest) + } + Xsqlite3_result_text(tls, pCtx, zOut, -int32(1), uintptr(-libc.Int32FromInt32(1))) + _sqlite3DbFree(tls, db, zOut) + } else { + rc = int32(SQLITE_NOMEM) + } + Xsqlite3_free(tls, zQuot) + return rc +} + +// C documentation +// +// /* +// ** This routine is callback for sqlite3WalkExpr(). +// ** +// ** Resolve symbolic names into TK_COLUMN operators for the current +// ** node in the expression tree. Return 0 to continue the search down +// ** the tree or 2 to abort the tree walk. +// ** +// ** This routine also does error checking and name resolution for +// ** function names. The operator for aggregate functions is changed +// ** to TK_AGG_FUNCTION. +// */ +func _resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var anRef [8]int32 + var auth, i, is_agg, n, nLeft, nRef, nRight, no_such_func, rc, savedAllowFlags, wrong_num_args, v5 int32 + var enc Tu8 + var p, pDef, pItem, pLeft, pList, pNC, pNC2, pParse, pRight, pRight1, pSel, pSrcList, pWin, zDb, zId, zTable, zType, v4 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = anRef, auth, enc, i, is_agg, n, nLeft, nRef, nRight, no_such_func, p, pDef, pItem, pLeft, pList, pNC, pNC2, pParse, pRight, pRight1, pSel, pSrcList, pWin, rc, savedAllowFlags, wrong_num_args, zDb, zId, zTable, zType, v4, v5 + pNC = *(*uintptr)(unsafe.Pointer(pWalker + 40)) + pParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse + switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { + /* The special operator TK_ROW means use the rowid for the first + ** column in the FROM clause. This is used by the LIMIT and ORDER BY + ** clause processing on UPDATE and DELETE statements, and by + ** UPDATE ... FROM statement processing. + */ + case int32(TK_ROW): + pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList + pItem = pSrcList + 8 + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_COLUMN) + *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = (*TExpr)(unsafe.Pointer(pExpr)).FiColumn - 1 + (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = int8(SQLITE_AFF_INTEGER) + break + /* An optimization: Attempt to convert + ** + ** "expr IS NOT NULL" --> "TRUE" + ** "expr IS NULL" --> "FALSE" + ** + ** if we can prove that "expr" is never NULL. Call this the + ** "NOT NULL strength reduction optimization". + ** + ** If this optimization occurs, also restore the NameContext ref-counts + ** to the state they where in before the "column" LHS expression was + ** resolved. This prevents "column" from being counted as having been + ** referenced, which might prevent a SELECT from being erroneously + ** marked as correlated. + ** + ** 2024-03-28: Beware of aggregates. A bare column of aggregated table + ** can still evaluate to NULL even though it is marked as NOT NULL. + ** Example: + ** + ** CREATE TABLE t1(a INT NOT NULL); + ** SELECT a, a IS NULL, a IS NOT NULL, count(*) FROM t1; + ** + ** The "a IS NULL" and "a IS NOT NULL" expressions cannot be optimized + ** here because at the time this case is hit, we do not yet know whether + ** or not t1 is being aggregated. We have to assume the worst and omit + ** the optimization. The only time it is safe to apply this optimization + ** is within the WHERE clause. + */ + fallthrough + case int32(TK_NOTNULL): + fallthrough + case int32(TK_ISNULL): + i = 0 + p = pNC + for { + if !(p != 0 && i < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) { + break + } + anRef[i] = (*TNameContext)(unsafe.Pointer(p)).FnRef + goto _1 + _1: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + _sqlite3WalkExpr(tls, pWalker, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return int32(WRC_Prune) + } + if _sqlite3ExprCanBeNull(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) != 0 { + /* The expression can be NULL. So the optimization does not apply */ + return int32(WRC_Prune) + } + i = 0 + p = pNC + for { + if !(p != 0) { + break + } + if (*TNameContext)(unsafe.Pointer(p)).FncFlags&int32(NC_Where) == 0 { + return int32(WRC_Prune) /* Not in a WHERE clause. Unsafe to optimize. */ + } + goto _2 + _2: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fu)) = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL)) + **(**Tu32)(__ccgo_up(pExpr + 4)) |= uint32(EP_IntValue) + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_INTEGER) + i = 0 + p = pNC + for { + if !(p != 0 && i < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) { + break + } + (*TNameContext)(unsafe.Pointer(p)).FnRef = anRef[i] + goto _3 + _3: + ; + p = (*TNameContext)(unsafe.Pointer(p)).FpNext + i = i + 1 + } + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) + return int32(WRC_Prune) + /* A column name: ID + ** Or table name and column name: ID.ID + ** Or a database, table and column: ID.ID.ID + ** + ** The TK_ID and TK_OUT cases are combined so that there will only + ** be one call to lookupName(). Then the compiler will in-line + ** lookupName() for a size reduction and performance increase. + */ + fallthrough + case int32(TK_ID): + fallthrough + case int32(TK_DOT): + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_ID) { + zDb = uintptr(0) + zTable = uintptr(0) + pRight = pExpr + } else { + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7200, uintptr(0), pExpr) + } + pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) == int32(TK_ID) { + zDb = uintptr(0) + } else { + zDb = *(*uintptr)(unsafe.Pointer(pLeft + 8)) + pLeft = (*TExpr)(unsafe.Pointer(pRight)).FpLeft + pRight = (*TExpr)(unsafe.Pointer(pRight)).FpRight + } + zTable = *(*uintptr)(unsafe.Pointer(pLeft + 8)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, pExpr, pRight) + _sqlite3RenameTokenRemap(tls, pParse, pExpr+64, pLeft) + } + } + return _lookupName(tls, pParse, zDb, zTable, pRight, pNC, pExpr) + /* Resolve function names + */ + fallthrough + case int32(TK_FUNCTION): /* Number of arguments */ + no_such_func = 0 /* True if no such function exists */ + wrong_num_args = 0 /* True if wrong number of arguments */ + is_agg = 0 /* Information about the function */ + enc = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc /* The database encoding */ + savedAllowFlags = (*TNameContext)(unsafe.Pointer(pNC)).FncFlags & (libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_AllowWin)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FeFrmType) != int32(TK_FILTER) { + v4 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + } else { + v4 = uintptr(0) + } + pWin = v4 + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if pList != 0 { + v5 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + } else { + v5 = 0 + } + n = v5 + zId = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + pDef = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zId, n, enc, uint8(0)) + if pDef == uintptr(0) { + pDef = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zId, -int32(2), enc, uint8(0)) + if pDef == uintptr(0) { + no_such_func = int32(1) + } else { + wrong_num_args = int32(1) + } + } else { + is_agg = libc.BoolInt32((*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0)) + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_UNLIKELY) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Unlikely)) + if n == int32(2) { + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = _exprProbability(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7217, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + } else { + /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is + ** equivalent to likelihood(X, 0.0625). + ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is + ** short-hand for likelihood(X,0.0625). + ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand + ** for likelihood(X,0.9375). + ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent + ** to likelihood(X,0.9375). */ + /* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */ + if int32(**(**int8)(__ccgo_up((*TFuncDef)(unsafe.Pointer(pDef)).FzName))) == int32('u') { + v5 = int32(8388608) + } else { + v5 = int32(125829120) + } + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = v5 + } + } + auth = _sqlite3AuthCheck(tls, pParse, int32(SQLITE_FUNCTION), uintptr(0), (*TFuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0)) + if auth != SQLITE_OK { + if auth == int32(SQLITE_DENY) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7281, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) + return int32(WRC_Prune) + } + /* If the function may call sqlite3_value_subtype(), then set the + ** EP_SubtArg flag on all of its argument expressions. This prevents + ** where.c from replacing the expression with a value read from an + ** index on the same expression, which will not have the correct + ** subtype. Also set the flag if the function expression itself is + ** an EP_SubtArg expression. In this case subtypes are required as + ** the function may return a value with a subtype back to its + ** caller using sqlite3_result_value(). */ + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_SUBTYPE) != 0 || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromUint32(EP_SubtArg) != uint32(0) { + _resolveSetExprSubtypeArg(tls, pList) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)|libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG)) != 0 { + /* For the purposes of the EP_ConstFunc flag, date and time + ** functions and other functions that change slowly are considered + ** constant because they are constant for the duration of one query. + ** This allows them to be factored out of inner loops. */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_ConstFunc)) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_CONSTANT) == uint32(0) { + /* Clearly non-deterministic functions like random(), but also + ** date/time functions that use 'now', and other functions like + ** sqlite_version() that might change over time cannot be used + ** in an index or generated column. Curiously, they can be used + ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all + ** allow this. */ + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7317, uintptr(0), pExpr) + } + } else { + /* Must fit in 8 bits */ + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = libc.Uint8FromInt32((*TNameContext)(unsafe.Pointer(pNC)).FncFlags & int32(NC_SelfRef)) + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INTERNAL) != uint32(0) && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_InternalFunc) == uint32(0) { + /* Internal-use-only functions are disallowed unless the + ** SQL is being compiled using sqlite3NestedParse() or + ** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be + ** used to activate internal functions for testing purposes */ + no_such_func = int32(1) + pDef = uintptr(0) + } else { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_DIRECT)|libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) != uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_FromDDL) != 0 { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) + } + _sqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) + } + } + } + if 0 == libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME)) { + if pDef != 0 && (*TFuncDef)(unsafe.Pointer(pDef)).FxValue == uintptr(0) && pWin != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7345, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowAgg) == 0 || is_agg != 0 && (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 && !(pWin != 0) || is_agg != 0 && pWin != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowWin) == 0 { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 || pWin != 0 { + zType = __ccgo_ts + 7388 + } else { + zType = __ccgo_ts + 7395 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7405, libc.VaList(bp+8, zType, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + is_agg = 0 + } else { + if no_such_func != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7433, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if wrong_num_args != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7455, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg == 0 && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7499, libc.VaList(bp+8, pExpr)) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } else { + if is_agg == 0 && (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3ExprOrderByAggregateError(tls, pParse, pExpr) + (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 + } + } + } + } + } + } + if is_agg != 0 { + /* Window functions may not be arguments of aggregate functions. + ** Or arguments of other window functions. But aggregate functions + ** may be arguments for window functions. */ + if !(pWin != 0) { + v5 = int32(NC_AllowAgg) + } else { + v5 = 0 + } + **(**int32)(__ccgo_up(pNC + 40)) &= ^(libc.Int32FromInt32(NC_AllowWin) | v5) + } + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) || (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + is_agg = int32(1) + } + } + _sqlite3WalkExprList(tls, pWalker, pList) + if is_agg != 0 { + if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { + _sqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32))) + } + if pWin != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + pSel = (*TNameContext)(unsafe.Pointer(pNC)).FpWinSelect + if libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME)) == 0 { + if pSel != 0 { + v4 = (*TSelect)(unsafe.Pointer(pSel)).FpWinDefn + } else { + v4 = uintptr(0) + } + _sqlite3WindowUpdate(tls, pParse, v4, pWin, pDef) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + break + } + } + _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) + _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) + _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpFilter) + _sqlite3WindowLink(tls, pSel, pWin) + **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_HasWin) + } else { + /* For looping up thru outer contexts */ + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_AGG_FUNCTION) + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = uint8(0) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpFilter) + } + pNC2 = pNC + for pNC2 != 0 && _sqlite3ReferencesSrcList(tls, pParse, pExpr, (*TNameContext)(unsafe.Pointer(pNC2)).FpSrcList) == 0 { + v4 = pExpr + 2 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(uint32(*(*Tu8)(unsafe.Pointer(v4))) + (libc.Uint32FromInt32(1) + (*TNameContext)(unsafe.Pointer(pNC2)).FnNestedSelect)) + pNC2 = (*TNameContext)(unsafe.Pointer(pNC2)).FpNext + } + if pNC2 != 0 && pDef != 0 { + v4 = pExpr + 2 + *(*Tu8)(unsafe.Pointer(v4)) = Tu8(uint32(*(*Tu8)(unsafe.Pointer(v4))) + (*TNameContext)(unsafe.Pointer(pNC2)).FnNestedSelect) + v4 = pNC2 + 40 + *(*int32)(unsafe.Pointer(v4)) = int32(uint32(*(*int32)(unsafe.Pointer(v4))) | (libc.Uint32FromInt32(NC_HasAgg) | ((*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags^libc.Uint32FromInt32(SQLITE_FUNC_ANYORDER))&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_MINMAX)|libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)))) + } + } + **(**int32)(__ccgo_up(pNC + 40)) |= savedAllowFlags + } + /* FIX ME: Compute pExpr->affinity based on the expected return + ** type of the function + */ + return int32(WRC_Prune) + case int32(TK_EXISTS): + fallthrough + case int32(TK_SELECT): + fallthrough + case int32(TK_IN): + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + nRef = (*TNameContext)(unsafe.Pointer(pNC)).FnRef + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_EXISTS) { + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 4, 0x10) + } + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_SelfRef) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7547, pExpr, pExpr) + } else { + _sqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32))) + } + if nRef != (*TNameContext)(unsafe.Pointer(pNC)).FnRef { + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 4)) |= uint32(SF_Correlated) + } + **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_Subquery) + } + case int32(TK_VARIABLE): + if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IsCheck)|libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) != 0 { + _notValidImpl(tls, pParse, pNC, __ccgo_ts+7558, pExpr, pExpr) + } + case int32(TK_IS): + fallthrough + case int32(TK_ISNOT): + pRight1 = _sqlite3ExprSkipCollateAndLikely(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", + ** and "x IS NOT FALSE". */ + if pRight1 != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_ID) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_TRUEFALSE)) { + rc = _resolveExprStep(tls, pWalker, pRight1) + if rc == int32(WRC_Abort) { + return int32(WRC_Abort) + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_TRUEFALSE) { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_TRUTH) + return WRC_Continue + } + } + fallthrough + case int32(TK_BETWEEN): + fallthrough + case int32(TK_EQ): + fallthrough + case int32(TK_NE): + fallthrough + case int32(TK_LT): + fallthrough + case int32(TK_LE): + fallthrough + case int32(TK_GT): + fallthrough + case int32(TK_GE): + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + break + } + nLeft = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_BETWEEN) { + nRight = _sqlite3ExprVectorSize(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr) + if nRight == nLeft { + nRight = _sqlite3ExprVectorSize(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr) + } + } else { + nRight = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + } + if nLeft != nRight { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6908, 0) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + } + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + v5 = int32(WRC_Abort) + } else { + v5 = WRC_Continue + } + return v5 +} + +// C documentation +// +// /* +// ** This function is the implementation of both the xConnect and xCreate +// ** methods of the r-tree virtual table. +// ** +// ** argv[0] -> module name +// ** argv[1] -> database name +// ** argv[2] -> table name +// ** argv[...] -> column names... +// */ +func _rtreeInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr, isCreate int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aErrMsg [5]uintptr + var eCoordType, iErr, ii, nDb, nName, rc, v1 int32 + var pRtree, pSql, zArg, zSql uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = aErrMsg, eCoordType, iErr, ii, nDb, nName, pRtree, pSql, rc, zArg, zSql, v1 + rc = SQLITE_OK + if pAux != 0 { + v1 = int32(RTREE_COORD_INT32) + } else { + v1 = RTREE_COORD_REAL32 + } /* Length of string argv[2] */ + eCoordType = v1 + ii = int32(4) + aErrMsg = [5]uintptr{ + 1: __ccgo_ts + 28732, + 2: __ccgo_ts + 28775, + 3: __ccgo_ts + 28810, + 4: __ccgo_ts + 28846, + } + if argc < int32(6) || argc > libc.Int32FromInt32(RTREE_MAX_AUX_COLUMN)+libc.Int32FromInt32(3) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[int32(2)+libc.BoolInt32(argc >= int32(6))])) + return int32(SQLITE_ERROR) + } + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_CONSTRAINT_SUPPORT), libc.VaList(bp+8, int32(1))) + Xsqlite3_vtab_config(tls, db, int32(SQLITE_VTAB_INNOCUOUS), 0) + /* Allocate the sqlite3_vtab structure */ + nDb = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 1*8)))) + nName = libc.Int32FromUint64(libc.Xstrlen(tls, **(**uintptr)(__ccgo_up(argv + 2*8)))) + pRtree = Xsqlite3_malloc64(tls, uint64(uint64(976)+libc.Uint64FromInt32(nDb)+libc.Uint64FromInt32(nName*int32(2))+uint64(8))) + if !(pRtree != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pRtree, 0, uint64(976)+libc.Uint64FromInt32(nDb)+libc.Uint64FromInt32(nName*int32(2))+uint64(8)) + (*TRtree)(unsafe.Pointer(pRtree)).FnBusy = uint32(1) + (*TRtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&_rtreeModule)) + (*TRtree)(unsafe.Pointer(pRtree)).FzDb = pRtree + 1*976 + (*TRtree)(unsafe.Pointer(pRtree)).FzName = (*TRtree)(unsafe.Pointer(pRtree)).FzDb + uintptr(nDb+int32(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName = (*TRtree)(unsafe.Pointer(pRtree)).FzName + uintptr(nName+int32(1)) + (*TRtree)(unsafe.Pointer(pRtree)).FeCoordType = libc.Uint8FromInt32(eCoordType) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, **(**uintptr)(__ccgo_up(argv + 1*8)), libc.Uint64FromInt32(nDb)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt32(nName)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName, **(**uintptr)(__ccgo_up(argv + 2*8)), libc.Uint64FromInt32(nName)) + libc.Xmemcpy(tls, (*TRtree)(unsafe.Pointer(pRtree)).FzNodeName+uintptr(nName), __ccgo_ts+28883, uint64(6)) + /* Create/Connect to the underlying relational database schema. If + ** that is successful, call sqlite3_declare_vtab() to configure + ** the r-tree table schema. + */ + pSql = Xsqlite3_str_new(tls, db) + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+28889, libc.VaList(bp+8, _rtreeTokenLength(tls, **(**uintptr)(__ccgo_up(argv + 3*8))), **(**uintptr)(__ccgo_up(argv + 3*8)))) + ii = int32(4) + for { + if !(ii < argc) { + break + } + zArg = **(**uintptr)(__ccgo_up(argv + uintptr(ii)*8)) + if int32(**(**int8)(__ccgo_up(zArg))) == int32('+') { + (*TRtree)(unsafe.Pointer(pRtree)).FnAux = (*TRtree)(unsafe.Pointer(pRtree)).FnAux + 1 + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+28913, libc.VaList(bp+8, _rtreeTokenLength(tls, zArg+uintptr(1)), zArg+uintptr(1))) + } else { + if libc.Int32FromUint16((*TRtree)(unsafe.Pointer(pRtree)).FnAux) > 0 { + break + } else { + (*TRtree)(unsafe.Pointer(pRtree)).FnDim2 = (*TRtree)(unsafe.Pointer(pRtree)).FnDim2 + 1 + Xsqlite3_str_appendf(tls, pSql, _azFormat[eCoordType], libc.VaList(bp+8, _rtreeTokenLength(tls, zArg), zArg)) + } + } + goto _2 + _2: + ; + ii = ii + 1 + } + Xsqlite3_str_appendf(tls, pSql, __ccgo_ts+28940, 0) + zSql = Xsqlite3_str_finish(tls, pSql) + if !(zSql != 0) { + rc = int32(SQLITE_NOMEM) + } else { + if ii < argc { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[int32(4)])) + rc = int32(SQLITE_ERROR) + } else { + v1 = Xsqlite3_declare_vtab(tls, db, zSql) + rc = v1 + if SQLITE_OK != v1 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + } + } + } + Xsqlite3_free(tls, zSql) + if rc != 0 { + goto rtreeInit_fail + } + (*TRtree)(unsafe.Pointer(pRtree)).FnDim = libc.Uint8FromInt32(libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) / int32(2)) + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim) < int32(1) { + iErr = int32(2) + } else { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2) > libc.Int32FromInt32(RTREE_MAX_DIMENSIONS)*libc.Int32FromInt32(2) { + iErr = int32(3) + } else { + if libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)%int32(2) != 0 { + iErr = int32(1) + } else { + iErr = 0 + } + } + } + if iErr != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, aErrMsg[iErr])) + goto rtreeInit_fail + } + (*TRtree)(unsafe.Pointer(pRtree)).FnBytesPerCell = libc.Uint8FromInt32(int32(8) + libc.Int32FromUint8((*TRtree)(unsafe.Pointer(pRtree)).FnDim2)*int32(4)) + /* Figure out the node size to use. */ + rc = _getNodeSize(tls, db, pRtree, isCreate, pzErr) + if rc != 0 { + goto rtreeInit_fail + } + rc = _rtreeSqlInit(tls, pRtree, db, **(**uintptr)(__ccgo_up(argv + 1*8)), **(**uintptr)(__ccgo_up(argv + 2*8)), isCreate) + if rc != 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) + goto rtreeInit_fail + } + **(**uintptr)(__ccgo_up(ppVtab)) = pRtree + return SQLITE_OK + goto rtreeInit_fail +rtreeInit_fail: + ; + if rc == SQLITE_OK { + rc = int32(SQLITE_ERROR) + } + _rtreeRelease(tls, pRtree) + return rc +} + +// C documentation +// +// /* +// ** This function is a no-op if *pRc is other than SQLITE_OK when it is +// ** called. Otherwise, append the string representation of integer iVal +// ** to the buffer. No nul-terminator is written. +// ** +// ** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +// ** returning. +// */ +func _sessionAppendInteger(tls *libc.TLS, p uintptr, iVal int32, pRc uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* aBuf at bp+0 */ [24]int8 + Xsqlite3_snprintf(tls, libc.Int32FromUint64(libc.Uint64FromInt64(24)-libc.Uint64FromInt32(1)), bp, __ccgo_ts+5289, libc.VaList(bp+32, iVal)) + _sessionAppendStr(tls, p, bp, pRc) +} + +// C documentation +// +// /* +// ** Add a new column to the table currently being constructed. +// ** +// ** The parser calls this routine once for each column declaration +// ** in a CREATE TABLE statement. sqlite3StartTable() gets called +// ** first to get things going. Then this routine is called for each +// ** column. +// */ +func _sqlite3AddColumn(tls *libc.TLS, pParse uintptr, _sName TToken, _sType TToken) { + bp := tls.Alloc(48) + defer tls.Free(48) + *(*TToken)(unsafe.Pointer(bp)) = _sName + *(*TToken)(unsafe.Pointer(bp + 16)) = _sType + var aNew, db, p, pCol, z, zType, v1 uintptr + var affinity int8 + var eType, h, szEst Tu8 + var i int32 + _, _, _, _, _, _, _, _, _, _, _, _ = aNew, affinity, db, eType, h, i, p, pCol, szEst, z, zType, v1 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + eType = uint8(COLTYPE_CUSTOM) + szEst = uint8(1) + affinity = int8(SQLITE_AFF_BLOB) + v1 = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + p = v1 + if v1 == uintptr(0) { + return + } + if int32((*TTable)(unsafe.Pointer(p)).FnCol)+int32(1) > **(**int32)(__ccgo_up(db + 136 + 2*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13956, libc.VaList(bp+40, (*TTable)(unsafe.Pointer(p)).FzName)) + return + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + _sqlite3DequoteToken(tls, bp) + } + /* Because keywords GENERATE ALWAYS can be converted into identifiers + ** by the parser, we can sometimes end up with a typename that ends + ** with "generated always". Check for this case and omit the surplus + ** text. */ + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(16) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz+uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-libc.Uint32FromInt32(6)), __ccgo_ts+13979, int32(6)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn -= uint32(6) + for (**(**TToken)(__ccgo_up(bp + 16))).Fn > uint32(0) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp + 16))).Fz + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-uint32(1)))))])&int32(0x01) != 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = (**(**TToken)(__ccgo_up(bp + 16))).Fn - 1 + } + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(9) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz+uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-libc.Uint32FromInt32(9)), __ccgo_ts+13986, int32(9)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn -= uint32(9) + for (**(**TToken)(__ccgo_up(bp + 16))).Fn > uint32(0) && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp + 16))).Fz + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-uint32(1)))))])&int32(0x01) != 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = (**(**TToken)(__ccgo_up(bp + 16))).Fn - 1 + } + } + } + /* Check for standard typenames. For standard typenames we will + ** set the Column.eType field rather than storing the typename after + ** the column name, in order to save space. */ + if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(3) { + _sqlite3DequoteToken(tls, bp+16) + i = 0 + for { + if !(i < int32(SQLITE_N_STDTYPE)) { + break + } + if (**(**TToken)(__ccgo_up(bp + 16))).Fn == uint32(_sqlite3StdTypeLen[i]) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz, _sqlite3StdType[i], libc.Int32FromUint32((**(**TToken)(__ccgo_up(bp + 16))).Fn)) == 0 { + (**(**TToken)(__ccgo_up(bp + 16))).Fn = uint32(0) + eType = libc.Uint8FromInt32(i + int32(1)) + affinity = _sqlite3StdTypeAffinity[i] + if int32(affinity) <= int32(SQLITE_AFF_TEXT) { + szEst = uint8(5) + } + break + } + goto _2 + _2: + ; + i = i + 1 + } + } + z = _sqlite3DbMallocRaw(tls, db, libc.Uint64FromInt64(libc.Int64FromUint32((**(**TToken)(__ccgo_up(bp))).Fn)+int64(1)+libc.Int64FromUint32((**(**TToken)(__ccgo_up(bp + 16))).Fn)+libc.BoolInt64((**(**TToken)(__ccgo_up(bp + 16))).Fn > libc.Uint32FromInt32(0)))) + if z == uintptr(0) { + return + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, z, bp) + } + libc.Xmemcpy(tls, z, (**(**TToken)(__ccgo_up(bp))).Fz, uint64((**(**TToken)(__ccgo_up(bp))).Fn)) + **(**int8)(__ccgo_up(z + uintptr((**(**TToken)(__ccgo_up(bp))).Fn))) = 0 + _sqlite3Dequote(tls, z) + if (*TTable)(unsafe.Pointer(p)).FnCol != 0 && _sqlite3ColumnIndex(tls, p, z) >= 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13996, libc.VaList(bp+40, z)) + _sqlite3DbFree(tls, db, z) + return + } + aNew = _sqlite3DbRealloc(tls, db, (*TTable)(unsafe.Pointer(p)).FaCol, libc.Uint64FromInt64(int64((*TTable)(unsafe.Pointer(p)).FnCol)+libc.Int64FromInt32(1))*uint64(16)) + if aNew == uintptr(0) { + _sqlite3DbFree(tls, db, z) + return + } + (*TTable)(unsafe.Pointer(p)).FaCol = aNew + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr((*TTable)(unsafe.Pointer(p)).FnCol)*16 + libc.Xmemset(tls, pCol, 0, uint64(16)) + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = z + (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, z) + if (**(**TToken)(__ccgo_up(bp + 16))).Fn == uint32(0) { + /* If there is no type specified, columns have the default affinity + ** 'BLOB' with a default size of 4 bytes. */ + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = affinity + libc.SetBitFieldPtr8Uint32(pCol+8, uint32(eType), 4, 0xf0) + (*TColumn)(unsafe.Pointer(pCol)).FszEst = szEst + } else { + zType = z + uintptr(_sqlite3Strlen30(tls, z)) + uintptr(1) + libc.Xmemcpy(tls, zType, (**(**TToken)(__ccgo_up(bp + 16))).Fz, uint64((**(**TToken)(__ccgo_up(bp + 16))).Fn)) + **(**int8)(__ccgo_up(zType + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn))) = 0 + _sqlite3Dequote(tls, zType) + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3AffinityType(tls, zType, pCol) + v1 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_HASTYPE)) + } + if int32((*TTable)(unsafe.Pointer(p)).FnCol) <= int32(0xff) { + h = uint8(uint64((*TColumn)(unsafe.Pointer(pCol)).FhName) % uint64(16)) + **(**Tu8)(__ccgo_up(p + 104 + uintptr(h))) = libc.Uint8FromInt16((*TTable)(unsafe.Pointer(p)).FnCol) + } + (*TTable)(unsafe.Pointer(p)).FnCol = (*TTable)(unsafe.Pointer(p)).FnCol + 1 + (*TTable)(unsafe.Pointer(p)).FnNVCol = (*TTable)(unsafe.Pointer(p)).FnNVCol + 1 + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName.Fn = uint32(0) +} + +// C documentation +// +// /* +// ** This function is called by the parser upon parsing an +// ** +// ** ALTER TABLE pSrc DROP COLUMN pName +// ** +// ** statement. Argument pSrc contains the possibly qualified name of the +// ** table being edited, and token pName the name of the column to drop. +// */ +func _sqlite3AlterDropColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + var addr, i, iCol, iColPos, iCur, iDb, iPos, nField, reg, regOut, regRec, v2 int32 + var aff int8 + var db, pPk, pTab, v, zCol, zDb, v1 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, aff, db, i, iCol, iColPos, iCur, iDb, iPos, nField, pPk, pTab, reg, regOut, regRec, v, zCol, zDb, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database containing pTab ("main" etc.) */ + zCol = uintptr(0) /* Index of column zCol in pTab->aCol[] */ + /* Look up the table being altered. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_drop_column + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_drop_column + } + /* Make sure this is not an attempt to ALTER a view, virtual table or + ** system table. */ + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_drop_column + } + if SQLITE_OK != _isRealTable(tls, pParse, pTab, int32(1)) { + goto exit_drop_column + } + /* Find the index of the column being dropped. */ + zCol = _sqlite3NameFromToken(tls, db, pName) + if zCol == uintptr(0) { + goto exit_drop_column + } + iCol = _sqlite3ColumnIndex(tls, pTab, zCol) + if iCol < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11207, libc.VaList(bp+8, pName)) + goto exit_drop_column + } + /* Do not allow the user to drop a PRIMARY KEY column or a column + ** constrained by a UNIQUE constraint. */ + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&(libc.Int32FromInt32(COLFLAG_PRIMKEY)|libc.Int32FromInt32(COLFLAG_UNIQUE)) != 0 { + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + v1 = __ccgo_ts + 11592 + } else { + v1 = __ccgo_ts + 5831 + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11604, libc.VaList(bp+8, v1, zCol)) + goto exit_drop_column + } + /* Do not allow the number of columns to go to zero */ + if int32((*TTable)(unsafe.Pointer(pTab)).FnCol) <= int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11632, libc.VaList(bp+8, zCol)) + goto exit_drop_column + } + /* Edit the sqlite_schema table */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, zCol) != 0 { + goto exit_drop_column + } + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1)), __ccgo_ts+1704, 0) + _renameFixQuotes(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1))) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11680, libc.VaList(bp+8, zDb, iDb, iCol, (*TTable)(unsafe.Pointer(pTab)).FzName)) + /* Drop and reload the database schema. */ + _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterDrop)) + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iDb == int32(1)), __ccgo_ts+11801, int32(1)) + /* Edit rows of table on disk */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + pPk = uintptr(0) + nField = 0 + v = _sqlite3GetVdbe(tls, pParse) + v1 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + iCur = v2 + _sqlite3OpenTable(tls, pParse, iCur, iDb, pTab, int32(OP_OpenWrite)) + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iCur) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + reg = v2 + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), iCur, reg) + **(**int32)(__ccgo_up(pParse + 60)) += int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + **(**int32)(__ccgo_up(pParse + 60)) += libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnColumn) + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iCur, i, reg+i+int32(1)) + goto _6 + _6: + ; + i = i + 1 + } + nField = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + regRec = v2 + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if i != iCol && libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + if pPk != 0 { + iPos = _sqlite3TableColumnToIndex(tls, pPk, i) + iColPos = _sqlite3TableColumnToIndex(tls, pPk, iCol) + if iPos < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) { + goto _9 + } + regOut = reg + int32(1) + iPos - libc.BoolInt32(iPos > iColPos) + } else { + regOut = reg + int32(1) + nField + } + if i == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regOut) + } else { + aff = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity + if int32(aff) == int32(SQLITE_AFF_REAL) { + (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity = int8(SQLITE_AFF_NUMERIC) + } + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, i, regOut) + (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity = aff + } + nField = nField + 1 + } + goto _9 + _9: + ; + i = i + 1 + } + if nField == 0 { + /* dbsqlfuzz 5f09e7bcc78b4954d06bf9f2400d7715f48d1fef */ + (*TParse)(unsafe.Pointer(pParse)).FnMem = (*TParse)(unsafe.Pointer(pParse)).FnMem + 1 + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, reg+int32(1)) + nField = int32(1) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), reg+int32(1), nField, regRec) + if pPk != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iCur, regRec, reg+int32(1), libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iCur, regRec, reg) + } + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), iCur, addr+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addr) + } + goto exit_drop_column +exit_drop_column: + ; + _sqlite3DbFree(tls, db, zCol) + _sqlite3SrcListDelete(tls, db, pSrc) +} + +// C documentation +// +// /* +// ** This function is called after an "ALTER TABLE ... ADD" statement +// ** has been parsed. Argument pColDef contains the text of the new +// ** column definition. +// ** +// ** The Table structure pParse->pNewTable was extended to include +// ** the new column during parsing. +// */ +func _sqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var db, pCol, pDflt, pNew, pTab, v, zCol, zDb, zEnd, zTab, v1 uintptr + var iDb, r1, rc int32 + var _ /* pVal at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, iDb, pCol, pDflt, pNew, pTab, r1, rc, v, zCol, zDb, zEnd, zTab, v1 /* Temporary registers */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pNew)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + zTab = (*TTable)(unsafe.Pointer(pNew)).FzName + 16 /* Skip the "sqlite_altertab_" prefix on the name */ + pCol = (*TTable)(unsafe.Pointer(pNew)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pNew)).FnCol)-int32(1))*16 + pDflt = _sqlite3ColumnExpr(tls, pNew, pCol) + pTab = _sqlite3FindTable(tls, db, zTab, zDb) + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + return + } + /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. + ** If there is a NOT NULL constraint, then the default value for the + ** column must not be NULL. + */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+10289, 0) + return + } + if (*TTable)(unsafe.Pointer(pNew)).FpIndex != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+10321, 0) + return + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) == 0 { + /* If the default value for the new column was specified with a + ** literal NULL, then set pDflt to 0. This simplifies checking + ** for an SQL NULL default below. + */ + if pDflt != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == int32(TK_NULL) { + pDflt = uintptr(0) + } + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FpFKey != 0 && pDflt != 0 { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10348) + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 && !(pDflt != 0) { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10407) + } + /* Ensure the default expression is something that sqlite3ValueFromExpr() + ** can handle (i.e. not CURRENT_TIME etc.) + */ + if pDflt != 0 { + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + rc = _sqlite3ValueFromExpr(tls, db, pDflt, uint8(SQLITE_UTF8), uint8(SQLITE_AFF_BLOB), bp) + if rc != SQLITE_OK { + return + } + if !(**(**uintptr)(__ccgo_up(bp)) != 0) { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10460) + } + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp))) + } + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_STORED) != 0 { + _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10506) + } + } + /* Modify the CREATE TABLE statement. */ + zCol = _sqlite3DbStrNDup(tls, db, (*TToken)(unsafe.Pointer(pColDef)).Fz, uint64((*TToken)(unsafe.Pointer(pColDef)).Fn)) + if zCol != 0 { + zEnd = zCol + uintptr((*TToken)(unsafe.Pointer(pColDef)).Fn-uint32(1)) + for zEnd > zCol && (int32(**(**int8)(__ccgo_up(zEnd))) == int32(';') || libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zEnd)))])&int32(0x01) != 0) { + v1 = zEnd + zEnd = zEnd - 1 + **(**int8)(__ccgo_up(v1)) = int8('\000') + } + /* substr() operations on characters, but addColOffset is in bytes. So we + ** have to use printf() to translate between these units: */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10533, libc.VaList(bp+16, zDb, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FaddColOffset, zCol, (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pNew + 64))).FaddColOffset, zTab)) + _sqlite3DbFree(tls, db, zCol) + } + v = _sqlite3GetVdbe(tls, pParse) + if v != 0 { + /* Make sure the schema version is at least 3. But do not upgrade + ** from less than 3 to 4, as that will corrupt any preexisting DESC + ** index. + */ + r1 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_ReadCookie), iDb, r1, int32(BTREE_FILE_FORMAT)) + _sqlite3VdbeUsesBtree(tls, v, iDb) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), r1, -int32(2)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), r1, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_FILE_FORMAT), int32(3)) + _sqlite3ReleaseTempReg(tls, pParse, r1) + /* Reload the table definition */ + _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterAdd)) + /* Verify that constraints are still satisfied */ + if (*TTable)(unsafe.Pointer(pNew)).FpCheck != uintptr(0) || int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 && libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Strict) != uint32(0) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+10679, libc.VaList(bp+16, zTab, zDb)) + } + } +} + +// C documentation +// +// /* +// ** Handles the following parser reduction: +// ** +// ** cmd ::= ALTER TABLE pSrc RENAME COLUMN pOld TO pNew +// */ +func _sqlite3AlterRenameColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pOld uintptr, pNew uintptr) { + bp := tls.Alloc(80) + defer tls.Free(80) + var bQuote, iCol, iSchema int32 + var db, pTab, zDb, zNew, zOld uintptr + _, _, _, _, _, _, _, _ = bQuote, db, iCol, iSchema, pTab, zDb, zNew, zOld + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Index of column being renamed */ + zOld = uintptr(0) /* Old column name */ + zNew = uintptr(0) /* True to quote the new name */ + /* Locate the table to be altered */ + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8) + if !(pTab != 0) { + goto exit_rename_column + } + /* Cannot alter a system table */ + if SQLITE_OK != _isAlterableTable(tls, pParse, pTab) { + goto exit_rename_column + } + if SQLITE_OK != _isRealTable(tls, pParse, pTab, 0) { + goto exit_rename_column + } + /* Which schema holds the table to be altered */ + iSchema = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*32))).FzDbSName + /* Invoke the authorization callback. */ + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + goto exit_rename_column + } + /* Make sure the old name really is a column name in the table to be + ** altered. Set iCol to be the index of the column being renamed */ + zOld = _sqlite3NameFromToken(tls, db, pOld) + if !(zOld != 0) { + goto exit_rename_column + } + iCol = _sqlite3ColumnIndex(tls, pTab, zOld) + if iCol < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11207, libc.VaList(bp+8, pOld)) + goto exit_rename_column + } + /* Ensure the schema contains no double-quoted strings */ + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1)), __ccgo_ts+1704, 0) + _renameFixQuotes(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1))) + /* Do the rename operation using a recursive UPDATE statement that + ** uses the sqlite_rename_column() SQL function to compute the new + ** CREATE statement text for the sqlite_schema table. + */ + _sqlite3MayAbort(tls, pParse) + zNew = _sqlite3NameFromToken(tls, db, pNew) + if !(zNew != 0) { + goto exit_rename_column + } + bQuote = libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up((*TToken)(unsafe.Pointer(pNew)).Fz)))]) & int32(0x80) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11228, libc.VaList(bp+8, zDb, zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, iCol, zNew, bQuote, libc.BoolInt32(iSchema == int32(1)), (*TTable)(unsafe.Pointer(pTab)).FzName)) + _sqlite3NestedParse(tls, pParse, __ccgo_ts+11410, libc.VaList(bp+8, zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, iCol, zNew, bQuote)) + /* Drop and reload the database schema. */ + _renameReloadSchema(tls, pParse, iSchema, uint16(INITFLAG_AlterRename)) + _renameTestSchema(tls, pParse, zDb, libc.BoolInt32(iSchema == int32(1)), __ccgo_ts+10238, int32(1)) + goto exit_rename_column +exit_rename_column: + ; + _sqlite3SrcListDelete(tls, db, pSrc) + _sqlite3DbFree(tls, db, zOld) + _sqlite3DbFree(tls, db, zNew) + return +} + +// C documentation +// +// /* +// ** This routine does a complete check of the given BTree file. aRoot[] is +// ** an array of pages numbers were each page number is the root page of +// ** a table. nRoot is the number of entries in aRoot. +// ** +// ** A read-only or read-write transaction must be opened before calling +// ** this function. +// ** +// ** Write the number of error seen in *pnErr. Except for some memory +// ** allocation errors, an error message held in memory obtained from +// ** malloc is returned if *pnErr is non-zero. If *pnErr==0 then NULL is +// ** returned. If a memory allocation error occurs, NULL is returned. +// ** +// ** If the first entry in aRoot[] is 0, that indicates that the list of +// ** root pages is incomplete. This is a "partial integrity-check". This +// ** happens when performing an integrity check on a single table. The +// ** zero is skipped, of course. But in addition, the freelist checks +// ** and the checks to make sure every page is referenced are also skipped, +// ** since obviously it is not possible to know which pages are covered by +// ** the unverified btrees. Except, if aRoot[1] is 1, then the freelist +// ** checks are still performed. +// */ +func _sqlite3BtreeIntegrityCheck(tls *libc.TLS, db uintptr, p uintptr, aRoot uintptr, aCnt uintptr, nRoot int32, mxErr int32, pnErr uintptr, pzOut uintptr) (r int32) { + bp := tls.Alloc(272) + defer tls.Free(272) + var bCkFreelist, bPartial int32 + var i, mx, mxInHdr TPgno + var pBt uintptr + var savedDbFlags Tu64 + var _ /* notUsed at bp+232 */ Ti64 + var _ /* sCheck at bp+0 */ TIntegrityCk + var _ /* zErr at bp+128 */ [100]int8 + _, _, _, _, _, _, _ = bCkFreelist, bPartial, i, mx, mxInHdr, pBt, savedDbFlags + pBt = (*TBtree)(unsafe.Pointer(p)).FpBt + savedDbFlags = (*Tsqlite3)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags + bPartial = 0 /* True if not checking all btrees */ + bCkFreelist = int32(1) /* True to scan the freelist */ + /* aRoot[0]==0 means this is a partial check */ + if **(**TPgno)(__ccgo_up(aRoot)) == uint32(0) { + bPartial = int32(1) + if **(**TPgno)(__ccgo_up(aRoot + 1*4)) != uint32(1) { + bCkFreelist = 0 + } + } + _sqlite3BtreeEnter(tls, p) + libc.Xmemset(tls, bp, 0, uint64(128)) + (**(**TIntegrityCk)(__ccgo_up(bp))).Fdb = db + (**(**TIntegrityCk)(__ccgo_up(bp))).FpBt = pBt + (**(**TIntegrityCk)(__ccgo_up(bp))).FpPager = (*TBtShared)(unsafe.Pointer(pBt)).FpPager + (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage = _btreePagecount(tls, (**(**TIntegrityCk)(__ccgo_up(bp))).FpBt) + (**(**TIntegrityCk)(__ccgo_up(bp))).FmxErr = mxErr + _sqlite3StrAccumInit(tls, bp+72, uintptr(0), bp+128, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TIntegrityCk)(__ccgo_up(bp))).FerrMsg.FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + if (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage == uint32(0) { + goto integrity_ck_cleanup + } + (**(**TIntegrityCk)(__ccgo_up(bp))).FaPgRef = _sqlite3MallocZero(tls, uint64((**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage/uint32(8)+uint32(1))) + if !((**(**TIntegrityCk)(__ccgo_up(bp))).FaPgRef != 0) { + _checkOom(tls, bp) + goto integrity_ck_cleanup + } + (**(**TIntegrityCk)(__ccgo_up(bp))).Fheap = _sqlite3PageMalloc(tls, libc.Int32FromUint32((*TBtShared)(unsafe.Pointer(pBt)).FpageSize)) + if (**(**TIntegrityCk)(__ccgo_up(bp))).Fheap == uintptr(0) { + _checkOom(tls, bp) + goto integrity_ck_cleanup + } + i = libc.Uint32FromInt32(_sqlite3PendingByte)/(*TBtShared)(unsafe.Pointer(pBt)).FpageSize + libc.Uint32FromInt32(1) + if i <= (**(**TIntegrityCk)(__ccgo_up(bp))).FnCkPage { + _setPageReferenced(tls, bp, i) + } + /* Check the integrity of the freelist + */ + if bCkFreelist != 0 { + (**(**TIntegrityCk)(__ccgo_up(bp))).FzPfx = __ccgo_ts + 4962 + _checkList(tls, bp, int32(1), _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+32), _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36)) + (**(**TIntegrityCk)(__ccgo_up(bp))).FzPfx = uintptr(0) + } + /* Check all the tables. + */ + if !(bPartial != 0) { + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { + mx = uint32(0) + i = uint32(0) + for { + if !(libc.Int32FromUint32(i) < nRoot) { + break + } + if mx < **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) { + mx = **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) + } + goto _1 + _1: + ; + i = i + 1 + } + mxInHdr = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+52) + if mx != mxInHdr { + _checkAppendMsg(tls, bp, __ccgo_ts+4973, libc.VaList(bp+248, mx, mxInHdr)) + } + } else { + if _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+64) != uint32(0) { + _checkAppendMsg(tls, bp, __ccgo_ts+5018, 0) + } + } + } + **(**Tu64)(__ccgo_up((*TBtShared)(unsafe.Pointer(pBt)).Fdb + 48)) &= ^libc.Uint64FromInt32(SQLITE_CellSizeCk) + i = uint32(0) + for { + if !(libc.Int32FromUint32(i) < nRoot && (**(**TIntegrityCk)(__ccgo_up(bp))).FmxErr != 0) { + break + } + (**(**TIntegrityCk)(__ccgo_up(bp))).FnRow = 0 + if **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) != 0 { + if (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) > uint32(1) && !(bPartial != 0) { + _checkPtrmap(tls, bp, **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)), uint8(PTRMAP_ROOTPAGE), uint32(0)) + } + (**(**TIntegrityCk)(__ccgo_up(bp))).Fv0 = **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)) + _checkTreePage(tls, bp, **(**TPgno)(__ccgo_up(aRoot + uintptr(i)*4)), bp+232, libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)< nFilename { + v1 = nFullPathname + } else { + v1 = nFilename + } + zFullPathname = _sqlite3Malloc(tls, libc.Uint64FromInt32(v1)) + (*TBtree)(unsafe.Pointer(p)).Fsharable = uint8(1) + if !(zFullPathname != 0) { + Xsqlite3_free(tls, p) + return int32(SQLITE_NOMEM) + } + if isMemdb != 0 { + libc.Xmemcpy(tls, zFullPathname, zFilename, libc.Uint64FromInt32(nFilename)) + } else { + rc = _sqlite3OsFullPathname(tls, pVfs, zFilename, nFullPathname, zFullPathname) + if rc != 0 { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(2)<= 0) { + break + } + pExisting = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt + if pExisting != 0 && (*TBtree)(unsafe.Pointer(pExisting)).FpBt == pBt { + Xsqlite3_mutex_leave(tls, mutexShared) + Xsqlite3_mutex_leave(tls, mutexOpen) + Xsqlite3_free(tls, zFullPathname) + Xsqlite3_free(tls, p) + return int32(SQLITE_CONSTRAINT) + } + goto _3 + _3: + ; + iDb = iDb - 1 + } + (*TBtree)(unsafe.Pointer(p)).FpBt = pBt + (*TBtShared)(unsafe.Pointer(pBt)).FnRef = (*TBtShared)(unsafe.Pointer(pBt)).FnRef + 1 + break + } + goto _2 + _2: + ; + pBt = (*TBtShared)(unsafe.Pointer(pBt)).FpNext + } + Xsqlite3_mutex_leave(tls, mutexShared) + Xsqlite3_free(tls, zFullPathname) + } + } + if pBt == uintptr(0) { + /* + ** The following asserts make sure that structures used by the btree are + ** the right size. This is to guard against size changes that result + ** when compiling on a different architecture. + */ + /* Suppress false-positive compiler warning from PVS-Studio */ + libc.Xmemset(tls, bp+16, 0, uint64(8)) + pBt = _sqlite3MallocZero(tls, uint64(152)) + if pBt == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto btree_open_out + } + rc = _sqlite3PagerOpen(tls, pVfs, pBt, zFilename, int32(136), flags, vfsFlags, __ccgo_fp(_pageReinit)) + if rc == SQLITE_OK { + _sqlite3PagerSetMmapLimit(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, (*Tsqlite3)(unsafe.Pointer(db)).FszMmap) + rc = _sqlite3PagerReadFileheader(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, int32(100), bp) + } + if rc != SQLITE_OK { + goto btree_open_out + } + (*TBtShared)(unsafe.Pointer(pBt)).FopenFlags = libc.Uint8FromInt32(flags) + (*TBtShared)(unsafe.Pointer(pBt)).Fdb = db + _sqlite3PagerSetBusyHandler(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, __ccgo_fp(_btreeInvokeBusyHandler), pBt) + (*TBtree)(unsafe.Pointer(p)).FpBt = pBt + (*TBtShared)(unsafe.Pointer(pBt)).FpCursor = uintptr(0) + (*TBtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0) + if _sqlite3PagerIsreadonly(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) != 0 { + v4 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(BTS_READ_ONLY)) + } + /* EVIDENCE-OF: R-51873-39618 The page size for a database file is + ** determined by the 2-byte integer located at an offset of 16 bytes from + ** the beginning of the database file. */ + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = libc.Uint32FromInt32(libc.Int32FromUint8((**(**[100]uint8)(__ccgo_up(bp)))[int32(16)])< uint32(SQLITE_MAX_PAGE_SIZE) || ((*TBtShared)(unsafe.Pointer(pBt)).FpageSize-uint32(1))&(*TBtShared)(unsafe.Pointer(pBt)).FpageSize != uint32(0) { + (*TBtShared)(unsafe.Pointer(pBt)).FpageSize = uint32(0) + /* If the magic name ":memory:" will create an in-memory database, then + ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if + ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if + ** SQLITE_OMIT_MEMORYDB has been defined, then ":memory:" is just a + ** regular file-name. In this case the auto-vacuum applies as per normal. + */ + if zFilename != 0 && !(isMemdb != 0) { + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(libc.Int32FromInt32(0)) + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(libc.Int32FromInt32(0)) + } + nReserve = uint8(0) + } else { + /* EVIDENCE-OF: R-37497-42412 The size of the reserved region is + ** determined by the one-byte unsigned integer found at an offset of 20 + ** into the database file header. */ + nReserve = (**(**[100]uint8)(__ccgo_up(bp)))[int32(20)] + v4 = pBt + 40 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(BTS_PAGESIZE_FIXED)) + if _sqlite3Get4byte(tls, bp+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(4)*libc.Int32FromInt32(4))) != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum = libc.Uint8FromInt32(v1) + if _sqlite3Get4byte(tls, bp+uintptr(libc.Int32FromInt32(36)+libc.Int32FromInt32(7)*libc.Int32FromInt32(4))) != 0 { + v1 = int32(1) + } else { + v1 = 0 + } + (*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = libc.Uint8FromInt32(v1) + } + rc = _sqlite3PagerSetPagesize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pBt+52, libc.Int32FromUint8(nReserve)) + if rc != 0 { + goto btree_open_out + } + (*TBtShared)(unsafe.Pointer(pBt)).FusableSize = (*TBtShared)(unsafe.Pointer(pBt)).FpageSize - uint32(nReserve) + /* 8-byte alignment of pageSize */ + /* Add the new BtShared object to the linked list sharable BtShareds. + */ + (*TBtShared)(unsafe.Pointer(pBt)).FnRef = int32(1) + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + mutexShared1 = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)) + if libc.Bool(int32(SQLITE_THREADSAFE) != 0) && _sqlite3Config.FbCoreMutex != 0 { + (*TBtShared)(unsafe.Pointer(pBt)).Fmutex = _sqlite3MutexAlloc(tls, SQLITE_MUTEX_FAST) + if (*TBtShared)(unsafe.Pointer(pBt)).Fmutex == uintptr(0) { + rc = int32(SQLITE_NOMEM) + goto btree_open_out + } + } + Xsqlite3_mutex_enter(tls, mutexShared1) + (*TBtShared)(unsafe.Pointer(pBt)).FpNext = _sqlite3SharedCacheList + _sqlite3SharedCacheList = pBt + Xsqlite3_mutex_leave(tls, mutexShared1) + } + } + /* If the new Btree uses a sharable pBtShared, then link the new + ** Btree into the list of all sharable Btrees for the same connection. + ** The list is kept in ascending order by pBt address. + */ + if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + v4 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + pSib = v4 + if v4 != uintptr(0) && (*TBtree)(unsafe.Pointer(pSib)).Fsharable != 0 { + for (*TBtree)(unsafe.Pointer(pSib)).FpPrev != 0 { + pSib = (*TBtree)(unsafe.Pointer(pSib)).FpPrev + } + if uint64((*TBtree)(unsafe.Pointer(p)).FpBt) < uint64((*TBtree)(unsafe.Pointer(pSib)).FpBt) { + (*TBtree)(unsafe.Pointer(p)).FpNext = pSib + (*TBtree)(unsafe.Pointer(p)).FpPrev = uintptr(0) + (*TBtree)(unsafe.Pointer(pSib)).FpPrev = p + } else { + for (*TBtree)(unsafe.Pointer(pSib)).FpNext != 0 && uint64((*TBtree)(unsafe.Pointer((*TBtree)(unsafe.Pointer(pSib)).FpNext)).FpBt) < uint64((*TBtree)(unsafe.Pointer(p)).FpBt) { + pSib = (*TBtree)(unsafe.Pointer(pSib)).FpNext + } + (*TBtree)(unsafe.Pointer(p)).FpNext = (*TBtree)(unsafe.Pointer(pSib)).FpNext + (*TBtree)(unsafe.Pointer(p)).FpPrev = pSib + if (*TBtree)(unsafe.Pointer(p)).FpNext != 0 { + (*TBtree)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpNext)).FpPrev = p + } + (*TBtree)(unsafe.Pointer(pSib)).FpNext = p + } + break + } + goto _8 + _8: + ; + i = i + 1 + } + } + **(**uintptr)(__ccgo_up(ppBtree)) = p + goto btree_open_out +btree_open_out: + ; + if rc != SQLITE_OK { + if pBt != 0 && (*TBtShared)(unsafe.Pointer(pBt)).FpPager != 0 { + _sqlite3PagerClose(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, uintptr(0)) + } + Xsqlite3_free(tls, pBt) + Xsqlite3_free(tls, p) + **(**uintptr)(__ccgo_up(ppBtree)) = uintptr(0) + } else { + /* If the B-Tree was successfully opened, set the pager-cache size to the + ** default value. Except, when opening on an existing shared pager-cache, + ** do not change the pager-cache size. + */ + if _sqlite3BtreeSchema(tls, p, 0, uintptr(0)) == uintptr(0) { + _sqlite3BtreeSetCacheSize(tls, p, -int32(2000)) + } + pFile = _sqlite3PagerFile(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + if (*Tsqlite3_file)(unsafe.Pointer(pFile)).FpMethods != 0 { + _sqlite3OsFileControlHint(tls, pFile, int32(SQLITE_FCNTL_PDB), pBt+8) + } + } + if mutexOpen != 0 { + Xsqlite3_mutex_leave(tls, mutexOpen) + } + return rc +} + +// C documentation +// +// /* +// ** Remove entries from the sqlite_statN tables (for N in (1,2,3)) +// ** after a DROP INDEX or DROP TABLE command. +// */ +func _sqlite3ClearStatTables(tls *libc.TLS, pParse uintptr, iDb int32, zType uintptr, zName uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var i int32 + var zDbName uintptr + var _ /* zTab at bp+0 */ [24]int8 + _, _ = i, zDbName + zDbName = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*32))).FzDbSName + i = int32(1) + for { + if !(i <= int32(4)) { + break + } + Xsqlite3_snprintf(tls, int32(24), bp, __ccgo_ts+14951, libc.VaList(bp+32, i)) + if _sqlite3FindTable(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, bp, zDbName) != 0 { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+12936, libc.VaList(bp+32, zDbName, bp, zType, zName)) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +// C documentation +// +// /* +// ** Generate code that will construct an ephemeral table containing all terms +// ** in the RHS of an IN operator. The IN operator can be in either of two +// ** forms: +// ** +// ** x IN (4,5,11) -- IN operator with list on right-hand side +// ** x IN (SELECT a FROM b) -- IN operator with subquery on the right +// ** +// ** The pExpr parameter is the IN operator. The cursor number for the +// ** constructed ephemeral table is returned. The first time the ephemeral +// ** table is computed, the cursor number is also stored in pExpr->iTable, +// ** however the cursor number returned might not be the same, as it might +// ** have been duplicated using OP_OpenDup. +// ** +// ** If the LHS expression ("x" in the examples) is a column value, or +// ** the SELECT statement returns a column value, then the affinity of that +// ** column is used to build the index keys. If both 'x' and the +// ** SELECT... statement are columns, then numeric affinity is used +// ** if either column has NUMERIC or INTEGER affinity. If neither +// ** 'x' nor the SELECT... statement are columns, then numeric affinity +// ** is used. +// */ +func _sqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int32, allowBloom int32) { + bp := tls.Alloc(80) + defer tls.Free(80) + var addr, addrBloom, addrOnce, i, i1, nVal, r1, r2, rc, regBloom, v1 int32 + var p, pCopy, pE2, pEList, pItem, pKeyInfo, pLeft, pList, pSelect, pSig, v, v2 uintptr + var _ /* affinity at bp+40 */ int8 + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addr, addrBloom, addrOnce, i, i1, nVal, p, pCopy, pE2, pEList, pItem, pKeyInfo, pLeft, pList, pSelect, pSig, r1, r2, rc, regBloom, v, v1, v2 + addrOnce = 0 /* the LHS of the IN operator */ + pKeyInfo = uintptr(0) /* The prepared statement under construction */ + pSig = uintptr(0) /* Signature for this subroutine */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + /* The evaluation of the IN must be repeated every time it + ** is encountered if any of the following is true: + ** + ** * The right-hand side is a correlated subquery + ** * The right-hand side is an expression list containing variables + ** * We are inside a trigger + ** + ** If all of the above are false, then we can compute the RHS just once + ** and reuse it many names. + */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) != libc.Uint32FromInt32(0)) && (*TParse)(unsafe.Pointer(pParse)).FiSelfTab == 0 { + /* Reuse of the RHS is allowed + ** + ** Compute a signature for the RHS of the IN operator to facility + ** finding and reusing prior instances of the same IN operator. + */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) && (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselFlags&uint32(SF_All) == uint32(0) { + pSig = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(32)) + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FselId = libc.Int32FromUint32((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselId) + (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff = _exprINAffinity(tls, pParse, pExpr) + } + } + /* Check to see if there is a prior materialization of the RHS of + ** this IN operator. If there is, then make use of that prior + ** materialization rather than recomputing it. + */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) != uint32(0) || _findCompatibleInRhsSubrtn(tls, pParse, pExpr, pSig) != 0 { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8329, libc.VaList(bp+56, (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FselId)) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr) + _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenDup), iTab, (*TExpr)(unsafe.Pointer(pExpr)).FiTable) + _sqlite3VdbeJumpHere(tls, v, addrOnce) + if pSig != 0 { + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSig) + } + return + } + /* Begin coding the subroutine */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn = v1 + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr = _sqlite3VdbeAddOp2(tls, v, int32(OP_BeginSubrtn), 0, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn) + int32(1) + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FbComplete = uint8(0) + (*TSubrtnSig)(unsafe.Pointer(pSig)).FiAddr = (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr + (*TSubrtnSig)(unsafe.Pointer(pSig)).FregReturn = (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn + (*TSubrtnSig)(unsafe.Pointer(pSig)).FiTable = iTab + (*TParse)(unsafe.Pointer(pParse)).FmSubrtnSig = libc.Uint8FromInt32(int32(1) << ((*TSubrtnSig)(unsafe.Pointer(pSig)).FselId & int32(7))) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pSig, -int32(18)) + } + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + /* Check to see if this is a vector IN operator */ + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + nVal = _sqlite3ExprVectorSize(tls, pLeft) + /* Construct the ephemeral table that will contain the content of + ** RHS of the IN operator. + */ + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = iTab + addr = _sqlite3VdbeAddOp2(tls, v, int32(OP_OpenEphemeral), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, nVal) + pKeyInfo = _sqlite3KeyInfoAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, nVal, int32(1)) + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + /* Case 1: expr IN (SELECT ...) + ** + ** Generate code to write the results of the select into the temporary + ** table allocated and opened above. + */ + pSelect = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + pEList = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + if addrOnce != 0 { + v2 = __ccgo_ts + 1704 + } else { + v2 = __ccgo_ts + 8352 + } + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+8364, libc.VaList(bp+56, v2, (*TSelect)(unsafe.Pointer(pSelect)).FselId)) + /* If the LHS and RHS of the IN operator do not match, that + ** error will have been caught long before we reach this point. */ + if (*TExprList)(unsafe.Pointer(pEList)).FnExpr == nVal { + addrBloom = 0 + _sqlite3SelectDestInit(tls, bp, int32(SRT_Set), iTab) + (**(**TSelectDest)(__ccgo_up(bp))).FzAffSdst = _exprINAffinity(tls, pParse, pExpr) + (*TSelect)(unsafe.Pointer(pSelect)).FiLimit = 0 + if addrOnce != 0 && allowBloom != 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_BloomFilter)) == uint32(0) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + regBloom = v1 + addrBloom = _sqlite3VdbeAddOp2(tls, v, int32(OP_Blob), int32(10000), regBloom) + (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 = regBloom + } + /* Caused by OOM in sqlite3KeyInfoAlloc() */ + pCopy = _sqlite3SelectDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect, 0) + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + v1 = int32(1) + } else { + v1 = _sqlite3Select(tls, pParse, pCopy, bp) + } + rc = v1 + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pCopy) + _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (**(**TSelectDest)(__ccgo_up(bp))).FzAffSdst) + if addrBloom != 0 { + /* Remember that location of the Bloom filter in the P3 operand + ** of the OP_Once that began this subroutine. tag-202407032019 */ + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, v, addrOnce))).Fp3 = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 + if (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm2 == 0 { + /* If the Bloom filter won't actually be used, keep it small */ + (*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, v, addrBloom))).Fp1 = int32(10) + } + } + if rc != 0 { + _sqlite3KeyInfoUnref(tls, pKeyInfo) + return + } + /* OOM will cause exit after sqlite3Select() */ + i = 0 + for { + if !(i < nVal) { + break + } + p = _sqlite3VectorFieldSubexpr(tls, pLeft, i) + *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)) = _sqlite3BinaryCompareCollSeq(tls, pParse, p, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr) + goto _7 + _7: + ; + i = i + 1 + } + } + } else { + if *(*uintptr)(unsafe.Pointer(pExpr + 32)) != uintptr(0) { + pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + **(**int8)(__ccgo_up(bp + 40)) = _sqlite3ExprAffinity(tls, pLeft) + if int32(**(**int8)(__ccgo_up(bp + 40))) <= int32(SQLITE_AFF_NONE) { + **(**int8)(__ccgo_up(bp + 40)) = int8(SQLITE_AFF_BLOB) + } else { + if int32(**(**int8)(__ccgo_up(bp + 40))) == int32(SQLITE_AFF_REAL) { + **(**int8)(__ccgo_up(bp + 40)) = int8(SQLITE_AFF_NUMERIC) + } + } + if pKeyInfo != 0 { + *(*uintptr)(unsafe.Pointer(pKeyInfo + 32)) = _sqlite3ExprCollSeq(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) + } + /* Loop through each expression in . */ + r1 = _sqlite3GetTempReg(tls, pParse) + r2 = _sqlite3GetTempReg(tls, pParse) + i1 = (*TExprList)(unsafe.Pointer(pList)).FnExpr + pItem = pList + 8 + for { + if !(i1 > 0) { + break + } + pE2 = (*TExprList_item)(unsafe.Pointer(pItem)).FpExpr + /* If the expression is not constant then we will need to + ** disable the test that was generated above that makes sure + ** this code only executes once. Because for a non-constant + ** expression we need to rerun this code each time. + */ + if addrOnce != 0 && !(_sqlite3ExprIsConstant(tls, pParse, pE2) != 0) { + _sqlite3VdbeChangeToNoop(tls, v, addrOnce-int32(1)) + _sqlite3VdbeChangeToNoop(tls, v, addrOnce) + **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + addrOnce = 0 + } + /* Evaluate the expression and insert it into the temp table */ + _sqlite3ExprCode(tls, pParse, pE2, r1) + _sqlite3VdbeAddOp4(tls, v, int32(OP_MakeRecord), r1, int32(1), r2, bp+40, int32(1)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxInsert), iTab, r2, r1, int32(1)) + goto _8 + _8: + ; + i1 = i1 - 1 + pItem += 32 + } + _sqlite3ReleaseTempReg(tls, pParse, r1) + _sqlite3ReleaseTempReg(tls, pParse, r2) + } + } + if pSig != 0 { + (*TSubrtnSig)(unsafe.Pointer(pSig)).FbComplete = uint8(1) + } + if pKeyInfo != 0 { + _sqlite3VdbeChangeP4(tls, v, addr, pKeyInfo, -int32(9)) + } + if addrOnce != 0 { + _sqlite3VdbeAddOp1(tls, v, int32(OP_NullRow), iTab) + _sqlite3VdbeJumpHere(tls, v, addrOnce) + /* Subroutine return */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr, int32(1)) + _sqlite3ClearTempRegCache(tls, pParse) + } +} + +// C documentation +// +// /* +// ** Generate code for scalar subqueries used as a subquery expression +// ** or EXISTS operator: +// ** +// ** (SELECT a FROM b) -- subquery +// ** EXISTS (SELECT a FROM b) -- EXISTS subquery +// ** +// ** The pExpr parameter is the SELECT or EXISTS operator to be coded. +// ** +// ** Return the register that holds the result. For a multi-column SELECT, +// ** the result is stored in a contiguous array of registers and the +// ** return value is the register of the left-most result column. +// ** Return 0 if an error occurs. +// */ +func _sqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var addrOnce, nReg, rReg, v1 int32 + var db, pLeft, pLimit, pSel, v, v2 uintptr + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _ = addrOnce, db, nReg, pLeft, pLimit, pSel, rReg, v, v1, v2 + addrOnce = 0 /* Address of OP_Once at top of subroutine */ + rReg = 0 /* New limit expression */ + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return 0 + } + pSel = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + /* If this routine has already been coded, then invoke it as a + ** subroutine. */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) != uint32(0) { + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8383, libc.VaList(bp+48, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Gosub), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr) + return (*TExpr)(unsafe.Pointer(pExpr)).FiTable + } + /* Begin coding the subroutine */ + **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subrtn)) + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn = v1 + (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr = _sqlite3VdbeAddOp2(tls, v, int32(OP_BeginSubrtn), 0, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn) + int32(1) + /* The evaluation of the EXISTS/SELECT must be repeated every time it + ** is encountered if any of the following is true: + ** + ** * The right-hand side is a correlated subquery + ** * The right-hand side is an expression list containing variables + ** * We are inside a trigger + ** + ** If all of the above are false, then we can run this code just once + ** save the results, and reuse the same result on subsequent invocations. + */ + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) != libc.Uint32FromInt32(0)) { + addrOnce = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + } + /* For a SELECT, generate code to put the values for all columns of + ** the first row into an array of registers and return the index of + ** the first register. + ** + ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists) + ** into a register and return that register number. + ** + ** In both cases, the query is augmented with "LIMIT 1". Any + ** preexisting limit is discarded in place of the new LIMIT 1. + */ + if addrOnce != 0 { + v2 = __ccgo_ts + 1704 + } else { + v2 = __ccgo_ts + 8352 + } + _sqlite3VdbeExplain(tls, pParse, uint8(1), __ccgo_ts+8401, libc.VaList(bp+48, v2, (*TSelect)(unsafe.Pointer(pSel)).FselId)) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) { + v1 = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpEList)).FnExpr + } else { + v1 = int32(1) + } + nReg = v1 + _sqlite3SelectDestInit(tls, bp, 0, (*TParse)(unsafe.Pointer(pParse)).FnMem+int32(1)) + **(**int32)(__ccgo_up(pParse + 60)) += nReg + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_SELECT) { + (**(**TSelectDest)(__ccgo_up(bp))).FeDest = uint8(SRT_Mem) + if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_Distinct) != 0 && (*TSelect)(unsafe.Pointer(pSel)).FpLimit != 0 && (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpRight != 0 { + /* If there is both a DISTINCT and an OFFSET clause, then allocate + ** a separate dest.iSdst array for sqlite3Select() and other + ** routines to populate. In this case results will be copied over + ** into the dest.iSDParm array only after OFFSET processing. This + ** ensures that in the case where OFFSET excludes all rows, the + ** dest.iSDParm array is not left populated with the contents of the + ** last row visited - it should be all NULLs if all rows were + ** excluded by OFFSET. */ + (**(**TSelectDest)(__ccgo_up(bp))).FiSdst = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nReg + } else { + (**(**TSelectDest)(__ccgo_up(bp))).FiSdst = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm + } + (**(**TSelectDest)(__ccgo_up(bp))).FnSdst = nReg + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm, (*TParse)(unsafe.Pointer(pParse)).FnMem) + } else { + (**(**TSelectDest)(__ccgo_up(bp))).FeDest = uint8(SRT_Exists) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm) + } + if (*TSelect)(unsafe.Pointer(pSel)).FpLimit != 0 { + /* The subquery already has a limit. If the pre-existing limit X is + ** not already integer value 1 or 0, then make the new limit X<>0 so that + ** the new limit is either 1 or 0 */ + pLeft = (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpLeft + if libc.BoolInt32((*TExpr)(unsafe.Pointer(pLeft)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != uint32(0)) == 0 || *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pLeft)).Fu)) != int32(1) && *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pLeft)).Fu)) != 0 { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pLimit = _sqlite3ExprInt32(tls, db, 0) + if pLimit != 0 { + (*TExpr)(unsafe.Pointer(pLimit)).FaffExpr = int8(SQLITE_AFF_NUMERIC) + pLimit = _sqlite3PExpr(tls, pParse, int32(TK_NE), _sqlite3ExprDup(tls, db, pLeft, 0), pLimit) + } + _sqlite3ExprDeferredDelete(tls, pParse, pLeft) + (*TExpr)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpLimit)).FpLeft = pLimit + } + } else { + /* If there is no pre-existing limit add a limit of 1 */ + pLimit = _sqlite3ExprInt32(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(1)) + (*TSelect)(unsafe.Pointer(pSel)).FpLimit = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), pLimit, uintptr(0)) + } + (*TSelect)(unsafe.Pointer(pSel)).FiLimit = 0 + if _sqlite3Select(tls, pParse, pSel, bp) != 0 { + (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop + (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_ERROR) + return 0 + } + v1 = (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm + rReg = v1 + (*TExpr)(unsafe.Pointer(pExpr)).FiTable = v1 + if addrOnce != 0 { + _sqlite3VdbeJumpHere(tls, v, addrOnce) + } + /* Subroutine return */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Return), (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FregReturn, (*(*struct { + FiAddr int32 + FregReturn int32 + })(unsafe.Pointer(pExpr + 64))).FiAddr, int32(1)) + _sqlite3ClearTempRegCache(tls, pParse) + return rReg +} + +// C documentation +// +// /* +// ** Given an expression list (which is really the list of expressions +// ** that form the result set of a SELECT statement) compute appropriate +// ** column names for a table that would hold the expression list. +// ** +// ** All column names will be unique. +// ** +// ** Only the column names are computed. Column.zType, Column.zColl, +// ** and other fields of Column are zeroed. +// ** +// ** Return SQLITE_OK on success. If a memory allocation error occurs, +// ** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM. +// ** +// ** The only guarantee that SQLite makes about column names is that if the +// ** column has an AS clause assigning it a name, that will be the name used. +// ** That is the only documented guarantee. However, countless applications +// ** developed over the years have made baseless assumptions about column names +// ** and will break if those assumptions changes. Hence, use extreme caution +// ** when modifying this routine to avoid breaking legacy. +// ** +// ** See Also: sqlite3GenerateColumnNames() +// */ +func _sqlite3ColumnsFromExprList(tls *libc.TLS, pParse uintptr, pEList uintptr, pnCol uintptr, paCol uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var aCol, db, pCol, pColExpr, pCollide, pTab, pX, zName, v2, v3 uintptr + var i, iCol, j, nCol, nName int32 + var v5 bool + var v8 Tu32 + var _ /* cnt at bp+0 */ Tu32 + var _ /* ht at bp+8 */ THash + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCol, db, i, iCol, j, nCol, nName, pCol, pColExpr, pCollide, pTab, pX, zName, v2, v3, v5, v8 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + _sqlite3HashInit(tls, bp+8) + if pEList != 0 { + nCol = (*TExprList)(unsafe.Pointer(pEList)).FnExpr + aCol = _sqlite3DbMallocZero(tls, db, uint64(uint64(16)*libc.Uint64FromInt32(nCol))) + if nCol > int32(32767) { + nCol = int32(32767) + } + } else { + nCol = 0 + aCol = uintptr(0) + } + **(**Ti16)(__ccgo_up(pnCol)) = int16(nCol) + **(**uintptr)(__ccgo_up(paCol)) = aCol + i = 0 + pCol = aCol + for { + if !(i < nCol && !((*TParse)(unsafe.Pointer(pParse)).FnErr != 0)) { + break + } + pX = pEList + 8 + uintptr(i)*32 + /* Get an appropriate name for the column + */ + v2 = (*TExprList_item)(unsafe.Pointer(pX)).FzEName + zName = v2 + if v2 != uintptr(0) && int32(uint32(*(*uint16)(unsafe.Pointer(pX + 16 + 4))&0x3>>0)) == ENAME_NAME { + /* If the column contains an "AS " phrase, use as the name */ + } else { + pColExpr = _sqlite3ExprSkipCollateAndLikely(tls, (*TExprList_item)(unsafe.Pointer(pX)).FpExpr) + for pColExpr != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_DOT) { + pColExpr = (*TExpr)(unsafe.Pointer(pColExpr)).FpRight + } + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pColExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) && *(*uintptr)(unsafe.Pointer(pColExpr + 64)) != uintptr(0) { + /* For columns use the column name name */ + iCol = int32((*TExpr)(unsafe.Pointer(pColExpr)).FiColumn) + pTab = *(*uintptr)(unsafe.Pointer(pColExpr + 64)) + if iCol < 0 { + iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } + if iCol >= 0 { + v2 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName + } else { + v2 = __ccgo_ts + 17963 + } + zName = v2 + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_ID) { + zName = *(*uintptr)(unsafe.Pointer(pColExpr + 8)) + } else { + /* Use the original text of the column expression as its name */ + /* pointer comparison intended */ + } + } + } + if zName != 0 && !(_sqlite3IsTrueOrFalse(tls, zName) != 0) { + zName = _sqlite3DbStrDup(tls, db, zName) + } else { + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+20632, libc.VaList(bp+40, i+int32(1))) + } + /* Make sure the column name is unique. If the name is not unique, + ** append an integer to the name so that it becomes unique. + */ + **(**Tu32)(__ccgo_up(bp)) = uint32(0) + for { + if v5 = zName != 0; v5 { + v2 = _sqlite3HashFind(tls, bp+8, zName) + pCollide = v2 + } + if !(v5 && v2 != uintptr(0)) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pCollide + 16 + 4))&0x80>>7)) != 0 { + v3 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(COLFLAG_NOEXPAND)) + } + nName = _sqlite3Strlen30(tls, zName) + if nName > 0 { + j = nName - int32(1) + for { + if !(j > 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zName + uintptr(j))))])&int32(0x04) != 0) { + break + } + goto _7 + _7: + ; + j = j - 1 + } + if int32(**(**int8)(__ccgo_up(zName + uintptr(j)))) == int32(':') { + nName = j + } + } + **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + 1 + v8 = **(**Tu32)(__ccgo_up(bp)) + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+20641, libc.VaList(bp+40, nName, zName, v8)) + _sqlite3ProgressCheck(tls, pParse) + if **(**Tu32)(__ccgo_up(bp)) > uint32(3) { + Xsqlite3_randomness(tls, int32(4), bp) + } + } + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = zName + (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, zName) + if int32(uint32(*(*uint16)(unsafe.Pointer(pX + 16 + 4))&0x100>>8)) != 0 { + v2 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(COLFLAG_NOEXPAND)) + } + if zName != 0 && _sqlite3HashInsert(tls, bp+8, zName, pX) == pX { + _sqlite3OomFault(tls, db) + } + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + _sqlite3HashClear(tls, bp+8) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + j = 0 + for { + if !(j < i) { + break + } + _sqlite3DbFree(tls, db, (**(**TColumn)(__ccgo_up(aCol + uintptr(j)*16))).FzCnName) + goto _10 + _10: + ; + j = j + 1 + } + _sqlite3DbFree(tls, db, aCol) + **(**uintptr)(__ccgo_up(paCol)) = uintptr(0) + **(**Ti16)(__ccgo_up(pnCol)) = 0 + return (*TParse)(unsafe.Pointer(pParse)).Frc + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** All regular columns for table pTab have been puts into registers +// ** starting with iRegStore. The registers that correspond to STORED +// ** or VIRTUAL columns have not yet been initialized. This routine goes +// ** back and computes the values for those columns based on the previously +// ** computed normal columns. +// */ +func _sqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore int32, pTab uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var eProgress, i, ii, jj, x, v2 int32 + var pCol, pOp, pRedo, zP4, v4 uintptr + var _ /* w at bp+0 */ TWalker + _, _, _, _, _, _, _, _, _, _, _ = eProgress, i, ii, jj, pCol, pOp, pRedo, x, zP4, v2, v4 + /* Before computing generated columns, first go through and make sure + ** that appropriate affinity has been applied to the regular columns + */ + _sqlite3TableAffinity(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iRegStore) + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_HasStored) != uint32(0) { + pOp = _sqlite3VdbeGetLastOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe) + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Affinity) { + zP4 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + v2 = libc.Int32FromInt32(0) + jj = v2 + ii = v2 + for { + if !(**(**int8)(__ccgo_up(zP4 + uintptr(jj))) != 0) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(ii)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + goto _1 + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(ii)*16))).FcolFlags)&int32(COLFLAG_STORED) != 0 { + **(**int8)(__ccgo_up(zP4 + uintptr(jj))) = int8(SQLITE_AFF_NONE) + } + jj = jj + 1 + goto _1 + _1: + ; + ii = ii + 1 + } + } else { + if libc.Int32FromUint8((*TVdbeOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_TypeCheck) { + /* If an OP_TypeCheck was generated because the table is STRICT, + ** then set the P3 operand to indicate that generated columns should + ** not be checked */ + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp3 = int32(1) + } + } + } + /* Because there can be multiple generated columns that refer to one another, + ** this is a two-pass algorithm. On the first pass, mark all generated + ** columns as "not available". + */ + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + v4 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_NOTAVAIL)) + } + goto _3 + _3: + ; + i = i + 1 + } + *(*uintptr)(unsafe.Pointer(bp + 40)) = pTab + (**(**TWalker)(__ccgo_up(bp))).FxExprCallback = __ccgo_fp(_exprColumnFlagUnion) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback = uintptr(0) + (**(**TWalker)(__ccgo_up(bp))).FxSelectCallback2 = uintptr(0) + /* On the second pass, compute the value of each NOT-AVAILABLE column. + ** Companion code in the TK_COLUMN case of sqlite3ExprCodeTarget() will + ** compute dependencies and mark remove the COLSPAN_NOTAVAIL mark, as + ** they are needed. + */ + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = -iRegStore + for cond := true; cond; cond = pRedo != 0 && eProgress != 0 { + eProgress = 0 + pRedo = uintptr(0) + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_NOTAVAIL) != 0 { + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_BUSY)) + (**(**TWalker)(__ccgo_up(bp))).FeCode = uint16(0) + _sqlite3WalkExpr(tls, bp, _sqlite3ColumnExpr(tls, pTab, pCol)) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^libc.Int32FromInt32(COLFLAG_BUSY)) + if libc.Int32FromUint16((**(**TWalker)(__ccgo_up(bp))).FeCode)&int32(COLFLAG_NOTAVAIL) != 0 { + pRedo = pCol + goto _5 + } + eProgress = int32(1) + x = int32(_sqlite3TableColumnToStorage(tls, pTab, int16(i))) + iRegStore + _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab, pCol, x) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^libc.Int32FromInt32(COLFLAG_NOTAVAIL)) + } + goto _5 + _5: + ; + i = i + 1 + } + } + if pRedo != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8452, libc.VaList(bp+56, (*TColumn)(unsafe.Pointer(pRedo)).FzCnName)) + } + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 +} + +// C documentation +// +// /* +// ** This routine is called to create a new foreign key on the table +// ** currently under construction. pFromCol determines which columns +// ** in the current table point to the foreign key. If pFromCol==0 then +// ** connect the key to the last column inserted. pTo is the name of +// ** the table referred to (a.k.a the "parent" table). pToCol is a list +// ** of tables in the parent pTo table. flags contains all +// ** information about the conflict resolution algorithms specified +// ** in the ON DELETE, ON UPDATE and ON INSERT clauses. +// ** +// ** An FKey structure is created and added to the table currently +// ** under construction in the pParse->pNewTable field. +// ** +// ** The foreign key is set for IMMEDIATE processing. A subsequent call +// ** to sqlite3DeferForeignKey() might change this to DEFERRED. +// */ +func _sqlite3CreateForeignKey(tls *libc.TLS, pParse uintptr, pFromCol uintptr, pTo uintptr, pToCol uintptr, flags int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, p, pFKey, pNextTo, z uintptr + var i, iCol, j, n, nCol int32 + var nByte Ti64 + _, _, _, _, _, _, _, _, _, _, _ = db, i, iCol, j, n, nByte, nCol, p, pFKey, pNextTo, z + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pFKey = uintptr(0) + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) { + goto fk_end + } + if pFromCol == uintptr(0) { + iCol = int32((*TTable)(unsafe.Pointer(p)).FnCol) - int32(1) + if iCol < 0 { + goto fk_end + } + if pToCol != 0 && (*TExprList)(unsafe.Pointer(pToCol)).FnExpr != int32(1) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15171, libc.VaList(bp+8, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(iCol)*16))).FzCnName, pTo)) + goto fk_end + } + nCol = int32(1) + } else { + if pToCol != 0 && (*TExprList)(unsafe.Pointer(pToCol)).FnExpr != (*TExprList)(unsafe.Pointer(pFromCol)).FnExpr { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15234, 0) + goto fk_end + } else { + nCol = (*TExprList)(unsafe.Pointer(pFromCol)).FnExpr + } + } + nByte = libc.Int64FromUint64(uint64(libc.UintptrFromInt32(0)+64) + libc.Uint64FromInt32(nCol)*uint64(16) + uint64((*TToken)(unsafe.Pointer(pTo)).Fn) + uint64(1)) + if pToCol != 0 { + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pToCol)).FnExpr) { + break + } + nByte = nByte + int64(_sqlite3Strlen30(tls, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName)+int32(1)) + goto _1 + _1: + ; + i = i + 1 + } + } + pFKey = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte)) + if pFKey == uintptr(0) { + goto fk_end + } + (*TFKey)(unsafe.Pointer(pFKey)).FpFrom = p + (*TFKey)(unsafe.Pointer(pFKey)).FpNextFrom = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FpFKey + z = pFKey + 64 + uintptr(nCol)*16 + (*TFKey)(unsafe.Pointer(pFKey)).FzTo = z + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, z, pTo) + } + libc.Xmemcpy(tls, z, (*TToken)(unsafe.Pointer(pTo)).Fz, uint64((*TToken)(unsafe.Pointer(pTo)).Fn)) + **(**int8)(__ccgo_up(z + uintptr((*TToken)(unsafe.Pointer(pTo)).Fn))) = 0 + _sqlite3Dequote(tls, z) + z = z + uintptr((*TToken)(unsafe.Pointer(pTo)).Fn+uint32(1)) + (*TFKey)(unsafe.Pointer(pFKey)).FnCol = nCol + if pFromCol == uintptr(0) { + (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom = int32((*TTable)(unsafe.Pointer(p)).FnCol) - int32(1) + } else { + i = 0 + for { + if !(i < nCol) { + break + } + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + if _sqlite3StrICmp(tls, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(j)*16))).FzCnName, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName) == 0 { + (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FiFrom = j + break + } + goto _3 + _3: + ; + j = j + 1 + } + if j >= int32((*TTable)(unsafe.Pointer(p)).FnCol) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15328, libc.VaList(bp+8, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName)) + goto fk_end + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, pFKey+64+uintptr(i)*16, (*(*TExprList_item)(unsafe.Pointer(pFromCol + 8 + uintptr(i)*32))).FzEName) + } + goto _2 + _2: + ; + i = i + 1 + } + } + if pToCol != 0 { + i = 0 + for { + if !(i < nCol) { + break + } + n = _sqlite3Strlen30(tls, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName) + (*(*TsColMap)(unsafe.Pointer(pFKey + 64 + uintptr(i)*16))).FzCol = z + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, z, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName) + } + libc.Xmemcpy(tls, z, (*(*TExprList_item)(unsafe.Pointer(pToCol + 8 + uintptr(i)*32))).FzEName, libc.Uint64FromInt32(n)) + **(**int8)(__ccgo_up(z + uintptr(n))) = 0 + z = z + uintptr(n+int32(1)) + goto _4 + _4: + ; + i = i + 1 + } + } + (*TFKey)(unsafe.Pointer(pFKey)).FisDeferred = uint8(0) + **(**Tu8)(__ccgo_up(pFKey + 45)) = libc.Uint8FromInt32(flags & libc.Int32FromInt32(0xff)) /* ON DELETE action */ + **(**Tu8)(__ccgo_up(pFKey + 45 + 1)) = libc.Uint8FromInt32(flags >> libc.Int32FromInt32(8) & libc.Int32FromInt32(0xff)) /* ON UPDATE action */ + pNextTo = _sqlite3HashInsert(tls, (*TTable)(unsafe.Pointer(p)).FpSchema+80, (*TFKey)(unsafe.Pointer(pFKey)).FzTo, pFKey) + if pNextTo == pFKey { + _sqlite3OomFault(tls, db) + goto fk_end + } + if pNextTo != 0 { + (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo = pNextTo + (*TFKey)(unsafe.Pointer(pNextTo)).FpPrevTo = pFKey + } + /* Link the foreign key to the table as the last step. + */ + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FpFKey = pFKey + pFKey = uintptr(0) + goto fk_end +fk_end: + ; + _sqlite3DbFree(tls, db, pFKey) + _sqlite3ExprListDelete(tls, db, pFromCol) + _sqlite3ExprListDelete(tls, db, pToCol) +} + +// C documentation +// +// /* +// ** Create a new index for an SQL table. pName1.pName2 is the name of the index +// ** and pTblList is the name of the table that is to be indexed. Both will +// ** be NULL for a primary key or an index that is created to satisfy a +// ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse->pNewTable +// ** as the table to be indexed. pParse->pNewTable is a table that is +// ** currently being constructed by a CREATE TABLE statement. +// ** +// ** pList is a list of columns to be indexed. pList will be NULL if this +// ** is a primary key or unique-constraint on the most recent column added +// ** to the table currently under construction. +// */ +func _sqlite3CreateIndex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pTblName uintptr, pList uintptr, onError int32, pStart uintptr, pPIWhere uintptr, sortOrder int32, ifNotExist int32, idxType Tu8) { + bp := tls.Alloc(176) + defer tls.Free(176) + var db, p, pCExpr, pCol, pDb, pExpr, pIdx, pIndex, pListItem, pLoop, pNext, pPk, pTab, pThis, ppFrom, v, z1, z2, zColl, zDb, zName, zStmt, v2 uintptr + var i, iDb, iMem, j, k, n, n1, nColl, nExtra, nExtraCol, nName, requestedSortOrder, sortOrderMask, x, v5 int32 + var _ /* pName at bp+96 */ uintptr + var _ /* prevCol at bp+112 */ TToken + var _ /* sFix at bp+0 */ TDbFixer + var _ /* zExtra at bp+104 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iDb, iMem, j, k, n, n1, nColl, nExtra, nExtraCol, nName, p, pCExpr, pCol, pDb, pExpr, pIdx, pIndex, pListItem, pLoop, pNext, pPk, pTab, pThis, ppFrom, requestedSortOrder, sortOrderMask, v, x, z1, z2, zColl, zDb, zName, zStmt, v2, v5 + pTab = uintptr(0) /* Table to be indexed */ + pIndex = uintptr(0) /* The index to be created */ + zName = uintptr(0) /* 1 to honor DESC in index. 0 to ignore. */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Index of the database that is being written */ + **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) /* For looping over pList */ + nExtra = 0 /* Number of extra columns needed */ + **(**uintptr)(__ccgo_up(bp + 104)) = uintptr(0) /* Extra space after the Index object */ + pPk = uintptr(0) /* PRIMARY KEY index for WITHOUT ROWID tables */ + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) && libc.Int32FromUint8(idxType) != int32(SQLITE_IDXTYPE_PRIMARYKEY) { + goto exit_create_index + } + if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { + goto exit_create_index + } + if _sqlite3HasExplicitNulls(tls, pParse, pList) != 0 { + goto exit_create_index + } + /* + ** Find the table that is to be indexed. Return early if not found. + */ + if pTblName != uintptr(0) { + /* Use the two-part index name to determine the database + ** to search for the table. 'Fix' the table name to this db + ** before looking up the table. + */ + iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp+96) + if iDb < 0 { + goto exit_create_index + } + /* If the index name was unqualified, check if the table + ** is a temp table. If so, set the database to 1. Do not do this + ** if initializing a database schema. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + pTab = _sqlite3SrcListLookup(tls, pParse, pTblName) + if (*TToken)(unsafe.Pointer(pName2)).Fn == uint32(0) && pTab != 0 && (*TTable)(unsafe.Pointer(pTab)).FpSchema == (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema { + iDb = int32(1) + } + } + _sqlite3FixInit(tls, bp, pParse, iDb, __ccgo_ts+15413, **(**uintptr)(__ccgo_up(bp + 96))) + if _sqlite3FixSrcList(tls, bp, pTblName) != 0 { + /* Because the parser constructs pTblName from a single identifier, + ** sqlite3FixSrcList can never fail. */ + } + pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pTblName+8) + if pTab == uintptr(0) { + goto exit_create_index + } + if iDb == int32(1) && (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema != (*TTable)(unsafe.Pointer(pTab)).FpSchema { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15419, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_create_index + } + if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + } + } else { + pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if !(pTab != 0) { + goto exit_create_index + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+6756, int32(7)) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 && pTblName != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15469, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName)) + goto exit_create_index + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15497, 0) + goto exit_create_index + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15522, 0) + goto exit_create_index + } + /* + ** Find the name of the index. Make sure there is not already another + ** index or table with the same name. + ** + ** Exception: If we are reading the names of permanent indices from the + ** sqlite_schema table (because some other process changed the schema) and + ** one of the index names collides with the name of a temporary table or + ** index, then we will continue to process this index. + ** + ** If pName==0 it means that we are + ** dealing with a primary key or UNIQUE constraint. We have to invent our + ** own name. + */ + if **(**uintptr)(__ccgo_up(bp + 96)) != 0 { + zName = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp + 96))) + if zName == uintptr(0) { + goto exit_create_index + } + if SQLITE_OK != _sqlite3CheckObjectName(tls, pParse, zName, __ccgo_ts+15413, (*TTable)(unsafe.Pointer(pTab)).FzName) { + goto exit_create_index + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { + if _sqlite3FindTable(tls, db, zName, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15556, libc.VaList(bp+136, zName)) + goto exit_create_index + } + } + if _sqlite3FindIndex(tls, db, zName, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0) { + if !(ifNotExist != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15590, libc.VaList(bp+136, zName)) + } else { + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3ForceNotReadOnly(tls, pParse) + } + goto exit_create_index + } + } + } else { + pLoop = (*TTable)(unsafe.Pointer(pTab)).FpIndex + n = libc.Int32FromInt32(1) + for { + if !(pLoop != 0) { + break + } + goto _1 + _1: + ; + pLoop = (*TIndex)(unsafe.Pointer(pLoop)).FpNext + n = n + 1 + } + zName = _sqlite3MPrintf(tls, db, __ccgo_ts+15614, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName, n)) + if zName == uintptr(0) { + goto exit_create_index + } + /* Automatic index names generated from within sqlite3_declare_vtab() + ** must have names that are distinct from normal automatic index names. + ** The following statement converts "sqlite3_autoindex..." into + ** "sqlite3_butoindex..." in order to make the names distinct. + ** The "vtab_err.test" test demonstrates the need of this statement. */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + **(**int8)(__ccgo_up(zName + 7)) = **(**int8)(__ccgo_up(zName + 7)) + 1 + } + } + /* Check for authorization to create an index. + */ + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + zDb = (*TDb)(unsafe.Pointer(pDb)).FzDbSName + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + v2 = __ccgo_ts + 6764 + } else { + v2 = __ccgo_ts + 6284 + } + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), v2, uintptr(0), zDb) != 0 { + goto exit_create_index + } + i = int32(SQLITE_CREATE_INDEX) + if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { + i = int32(SQLITE_CREATE_TEMP_INDEX) + } + if _sqlite3AuthCheck(tls, pParse, i, zName, (*TTable)(unsafe.Pointer(pTab)).FzName, zDb) != 0 { + goto exit_create_index + } + } + /* If pList==0, it means this routine was called to make a primary + ** key out of the last column added to the table under construction. + ** So create a fake list to simulate this. + */ + if pList == uintptr(0) { + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1))*16 + v2 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(COLFLAG_UNIQUE)) + _sqlite3TokenInit(tls, bp+112, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) + pList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+112, 0)) + if pList == uintptr(0) { + goto exit_create_index + } + _sqlite3ExprListSetSortOrder(tls, pList, sortOrder, -int32(1)) + } else { + _sqlite3ExprListCheckLength(tls, pParse, pList, __ccgo_ts+15413) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + } + /* Figure out how many bytes of space are required to store explicitly + ** specified collation sequence names. + */ + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + pExpr = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE) { + nExtra = nExtra + (int32(1) + _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)))) + } + goto _4 + _4: + ; + i = i + 1 + } + /* + ** Allocate the index structure. + */ + nName = _sqlite3Strlen30(tls, zName) + if pPk != 0 { + v5 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + } else { + v5 = int32(1) + } + nExtraCol = v5 + pIndex = _sqlite3AllocateIndexObject(tls, db, (*TExprList)(unsafe.Pointer(pList)).FnExpr+nExtraCol, nName+nExtra+int32(1), bp+104) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto exit_create_index + } + (*TIndex)(unsafe.Pointer(pIndex)).FzName = **(**uintptr)(__ccgo_up(bp + 104)) + **(**uintptr)(__ccgo_up(bp + 104)) = **(**uintptr)(__ccgo_up(bp + 104)) + uintptr(nName+int32(1)) + libc.Xmemcpy(tls, (*TIndex)(unsafe.Pointer(pIndex)).FzName, zName, libc.Uint64FromInt32(nName+int32(1))) + (*TIndex)(unsafe.Pointer(pIndex)).FpTable = pTab + (*TIndex)(unsafe.Pointer(pIndex)).FonError = libc.Uint8FromInt32(onError) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.BoolUint32(onError != libc.Int32FromInt32(OE_None)), 3, 0x8) + libc.SetBitFieldPtr16Uint32(pIndex+100, uint32(idxType), 0, 0x3) + (*TIndex)(unsafe.Pointer(pIndex)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + (*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol = libc.Uint16FromInt32((*TExprList)(unsafe.Pointer(pList)).FnExpr) + if pPIWhere != 0 { + _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_PartIdx), pPIWhere, uintptr(0)) + (*TIndex)(unsafe.Pointer(pIndex)).FpPartIdxWhere = pPIWhere + pPIWhere = uintptr(0) + } + /* Check to see if we should honor DESC requests on index columns + */ + if libc.Int32FromUint8((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) >= int32(4) { + sortOrderMask = -int32(1) /* Honor DESC */ + } else { + sortOrderMask = 0 /* Ignore DESC */ + } + /* Analyze the list of expressions that form the terms of the index and + ** report any errors. In the common case where the expression is exactly + ** a table column, store that column in aiColumn[]. For general expressions, + ** populate pIndex->aColExpr and store XN_EXPR (-2) in aiColumn[]. + ** + ** TODO: Issue a warning if two or more columns of the index are identical. + ** TODO: Issue a warning if the table primary key is used as part of the + ** index key. + */ + pListItem = pList + 8 + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr = pList + pList = uintptr(0) + } + i = 0 + for { + if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol)) { + break + } /* Collation sequence name */ + _sqlite3StringToId(tls, (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr) + _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_IdxExpr), (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0)) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto exit_create_index + } + pCExpr = _sqlite3ExprSkipCollate(tls, (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCExpr)).Fop) != int32(TK_COLUMN) { + if pTab == (*TParse)(unsafe.Pointer(pParse)).FpNewTable { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15637, 0) + goto exit_create_index + } + if (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr == uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr = pList + pList = uintptr(0) + } + j = -int32(2) + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-libc.Int32FromInt32(2)) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 11, 0x800) + } else { + j = int32((*TExpr)(unsafe.Pointer(pCExpr)).FiColumn) + if j < 0 { + j = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16 + 8))&0xf>>0)) == 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 3, 0x8) + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 10, 0x400) + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 11, 0x800) + } + } + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(j) + } + zColl = uintptr(0) + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == int32(TK_COLLATE) { + zColl = *(*uintptr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr + 8)) + nColl = _sqlite3Strlen30(tls, zColl) + int32(1) + libc.Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp + 104)), zColl, libc.Uint64FromInt32(nColl)) + zColl = **(**uintptr)(__ccgo_up(bp + 104)) + **(**uintptr)(__ccgo_up(bp + 104)) = **(**uintptr)(__ccgo_up(bp + 104)) + uintptr(nColl) + nExtra = nExtra - nColl + } else { + if j >= 0 { + zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16) + } + } + if !(zColl != 0) { + zColl = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) && !(_sqlite3LocateCollSeq(tls, pParse, zColl) != 0) { + goto exit_create_index + } + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = zColl + requestedSortOrder = libc.Int32FromUint8((*TExprList_item)(unsafe.Pointer(pListItem)).Ffg.FsortFlags) & sortOrderMask + **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = libc.Uint8FromInt32(requestedSortOrder) + goto _6 + _6: + ; + i = i + 1 + pListItem += 32 + } + /* Append the table key to the end of the index. For WITHOUT ROWID + ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For + ** normal tables (when pPk==0) this will be the rowid. + */ + if pPk != 0 { + j = 0 + for { + if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { + break + } + x = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2))) + if _isDupColumn(tls, pIndex, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol), pPk, j) != 0 { + (*TIndex)(unsafe.Pointer(pIndex)).FnColumn = (*TIndex)(unsafe.Pointer(pIndex)).FnColumn - 1 + } else { + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(x) + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*8)) + **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(j))) + i = i + 1 + } + goto _7 + _7: + ; + j = j + 1 + } + } else { + **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-libc.Int32FromInt32(1)) + **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) + } + _sqlite3DefaultRowEst(tls, pIndex) + if (*TParse)(unsafe.Pointer(pParse)).FpNewTable == uintptr(0) { + _estimateIndexWidth(tls, pIndex) + } + /* If this index contains every column of its table, then mark + ** it as a covering index */ + _recomputeColumnsNotIndexed(tls, pIndex) + if pTblName != uintptr(0) && libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnColumn) >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 5, 0x20) + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { + goto _8 + } + if _sqlite3TableColumnToIndex(tls, pIndex, j) >= 0 { + goto _8 + } + libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 5, 0x20) + break + goto _8 + _8: + ; + j = j + 1 + } + } + if pTab == (*TParse)(unsafe.Pointer(pParse)).FpNewTable { + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol) { + goto _9 + } + k = 0 + for { + if !(k < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(k)*2))) != int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(k)*2))) { + break + } + z1 = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(k)*8)) + z2 = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(k)*8)) + if _sqlite3StrICmp(tls, z1, z2) != 0 { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if k == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) { + /* This constraint creates the same index as a previous + ** constraint specified somewhere in the CREATE TABLE statement. + ** However the ON CONFLICT clauses are different. If both this + ** constraint and the previous equivalent constraint have explicit + ** ON CONFLICT clauses this is an error. Otherwise, use the + ** explicitly specified behavior for the index. + */ + if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Default) || libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) == int32(OE_Default)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15698, libc.VaList(bp+136, 0)) + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Default) { + (*TIndex)(unsafe.Pointer(pIdx)).FonError = (*TIndex)(unsafe.Pointer(pIndex)).FonError + } + } + if libc.Int32FromUint8(idxType) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + libc.SetBitFieldPtr16Uint32(pIdx+100, uint32(idxType), 0, 0x3) + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TIndex)(unsafe.Pointer(pIndex)).FpNext = (*TParse)(unsafe.Pointer(pParse)).FpNewIndex + (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex + pIndex = uintptr(0) + } + goto exit_create_index + } + goto _9 + _9: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + } + if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + /* Link the new Index structure to its table and to the other + ** in-memory database structures. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + if pTblName != uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).Ftnum = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum + if _sqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15740, 0) + (*TParse)(unsafe.Pointer(pParse)).Frc = _sqlite3CorruptError(tls, int32(130799)) + goto exit_create_index + } + } + p = _sqlite3HashInsert(tls, (*TIndex)(unsafe.Pointer(pIndex)).FpSchema+32, (*TIndex)(unsafe.Pointer(pIndex)).FzName, pIndex) + if p != 0 { + /* Malloc must have failed */ + _sqlite3OomFault(tls, db) + goto exit_create_index + } + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + } else { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || pTblName != uintptr(0) { + v2 = pParse + 60 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + v5 = *(*int32)(unsafe.Pointer(v2)) + iMem = v5 + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + goto exit_create_index + } + _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) + /* Create the rootpage for the index using CreateIndex. But before + ** doing so, code a Noop instruction and store its address in + ** Index.tnum. This is required in case this index is actually a + ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In + ** that case the convertToWithoutRowidTable() routine will replace + ** the Noop with a Goto to jump over the VDBE code generated below. */ + (*TIndex)(unsafe.Pointer(pIndex)).Ftnum = libc.Uint32FromInt32(_sqlite3VdbeAddOp0(tls, v, int32(OP_Noop))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_CreateBtree), iDb, iMem, int32(BTREE_BLOBKEY)) + /* Gather the complete text of the CREATE INDEX statement into + ** the zStmt variable + */ + if pStart != 0 { + n1 = libc.Int32FromUint32(libc.Uint32FromInt32(int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64((*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz))) + (*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fn) + if int32(**(**int8)(__ccgo_up((*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz + uintptr(n1-int32(1))))) == int32(';') { + n1 = n1 - 1 + } + /* A named index with an explicit CREATE INDEX statement */ + if onError == OE_None { + v2 = __ccgo_ts + 1704 + } else { + v2 = __ccgo_ts + 15757 + } + zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+15765, libc.VaList(bp+136, v2, n1, (*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz)) + } else { + /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ + /* zStmt = sqlite3MPrintf(""); */ + zStmt = uintptr(0) + } + /* Add an entry in sqlite_schema for this index + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+15785, libc.VaList(bp+136, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TIndex)(unsafe.Pointer(pIndex)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, iMem, zStmt)) + _sqlite3DbFree(tls, db, zStmt) + /* Fill the index with data and reparse the schema. Code an OP_Expire + ** to invalidate all pre-compiled statements. + */ + if pTblName != 0 { + _sqlite3RefillIndex(tls, pParse, pIndex, iMem) + _sqlite3ChangeCookie(tls, pParse, iDb) + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+15844, libc.VaList(bp+136, (*TIndex)(unsafe.Pointer(pIndex)).FzName)), uint16(0)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Expire), 0, int32(1)) + } + _sqlite3VdbeJumpHere(tls, v, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIndex)).Ftnum)) + } + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || pTblName == uintptr(0) { + (*TIndex)(unsafe.Pointer(pIndex)).FpNext = (*TTable)(unsafe.Pointer(pTab)).FpIndex + (*TTable)(unsafe.Pointer(pTab)).FpIndex = pIndex + pIndex = uintptr(0) + } else { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex + pIndex = uintptr(0) + } + } + /* Clean up before exiting */ + goto exit_create_index +exit_create_index: + ; + if pIndex != 0 { + _sqlite3FreeIndex(tls, db, pIndex) + } + if pTab != 0 { + ppFrom = pTab + 16 + for { + v2 = **(**uintptr)(__ccgo_up(ppFrom)) + pThis = v2 + if !(v2 != uintptr(0)) { + break + } + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pThis)).FonError) != int32(OE_Replace) { + goto _14 + } + for { + v2 = (*TIndex)(unsafe.Pointer(pThis)).FpNext + pNext = v2 + if !(v2 != uintptr(0) && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pNext)).FonError) != int32(OE_Replace)) { + break + } + **(**uintptr)(__ccgo_up(ppFrom)) = pNext + (*TIndex)(unsafe.Pointer(pThis)).FpNext = (*TIndex)(unsafe.Pointer(pNext)).FpNext + (*TIndex)(unsafe.Pointer(pNext)).FpNext = pThis + ppFrom = pNext + 40 + } + break + goto _14 + _14: + ; + ppFrom = pThis + 40 + } + } + _sqlite3ExprDelete(tls, db, pPIWhere) + _sqlite3ExprListDelete(tls, db, pList) + _sqlite3SrcListDelete(tls, db, pTblName) + _sqlite3DbFree(tls, db, zName) +} + +// C documentation +// +// /* +// ** The parser calls this routine in order to create a new VIEW +// */ +func _sqlite3CreateView(tls *libc.TLS, pParse uintptr, pBegin uintptr, pName1 uintptr, pName2 uintptr, pCNames uintptr, pSelect uintptr, isTemp int32, noErr int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var db, p, z uintptr + var iDb, n int32 + var _ /* pName at bp+112 */ uintptr + var _ /* sEnd at bp+0 */ TToken + var _ /* sFix at bp+16 */ TDbFixer + _, _, _, _, _ = db, iDb, n, p, z + **(**uintptr)(__ccgo_up(bp + 112)) = uintptr(0) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if int32((*TParse)(unsafe.Pointer(pParse)).FnVar) > 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14803, 0) + goto create_view_fail + } + _sqlite3StartTable(tls, pParse, pName1, pName2, isTemp, int32(1), 0, noErr) + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) || (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + goto create_view_fail + } + /* Legacy versions of SQLite allowed the use of the magic "rowid" column + ** on a view, even though views do not have rowids. The following flag + ** setting fixes this problem. But the fix can be disabled by compiling + ** with -DSQLITE_ALLOW_ROWID_IN_VIEW in case there are legacy apps that + ** depend upon the old buggy behavior. The ability can also be toggled + ** using sqlite3_config(SQLITE_CONFIG_ROWID_IN_VIEW,...) */ + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_NoVisibleRowid) /* Never allow rowid in view */ + _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp+112) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(p)).FpSchema) + _sqlite3FixInit(tls, bp+16, pParse, iDb, __ccgo_ts+11115, **(**uintptr)(__ccgo_up(bp + 112))) + if _sqlite3FixSelect(tls, bp+16, pSelect) != 0 { + goto create_view_fail + } + /* Make a copy of the entire SELECT statement that defines the view. + ** This will force all the Expr.token.z values to be dynamically + ** allocated rather than point to the input string - which means that + ** they will persist after the current sqlite3_exec() call returns. + */ + **(**Tu32)(__ccgo_up(pSelect + 4)) |= uint32(SF_View) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(p)).Fu))).FpSelect = pSelect + pSelect = uintptr(0) + } else { + (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(p)).Fu))).FpSelect = _sqlite3SelectDup(tls, db, pSelect, int32(EXPRDUP_REDUCE)) + } + (*TTable)(unsafe.Pointer(p)).FpCheck = _sqlite3ExprListDup(tls, db, pCNames, int32(EXPRDUP_REDUCE)) + (*TTable)(unsafe.Pointer(p)).FeTabType = uint8(TABTYP_VIEW) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto create_view_fail + } + /* Locate the end of the CREATE VIEW statement. Make sEnd point to + ** the end. + */ + **(**TToken)(__ccgo_up(bp)) = (*TParse)(unsafe.Pointer(pParse)).FsLastToken + if int32(**(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp))).Fz))) != int32(';') { + (**(**TToken)(__ccgo_up(bp))).Fz += uintptr((**(**TToken)(__ccgo_up(bp))).Fn) + } + (**(**TToken)(__ccgo_up(bp))).Fn = uint32(0) + n = int32(int64((**(**TToken)(__ccgo_up(bp))).Fz) - int64((*TToken)(unsafe.Pointer(pBegin)).Fz)) + z = (*TToken)(unsafe.Pointer(pBegin)).Fz + for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(n-int32(1)))))])&int32(0x01) != 0 { + n = n - 1 + } + (**(**TToken)(__ccgo_up(bp))).Fz = z + uintptr(n-int32(1)) + (**(**TToken)(__ccgo_up(bp))).Fn = uint32(1) + /* Use sqlite3EndTable() to add the view to the schema table */ + _sqlite3EndTable(tls, pParse, uintptr(0), bp, uint32(0), uintptr(0)) + goto create_view_fail +create_view_fail: + ; + _sqlite3SelectDelete(tls, db, pSelect) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameExprlistUnmap(tls, pParse, pCNames) + } + _sqlite3ExprListDelete(tls, db, pCNames) + return +} + +// C documentation +// +// /* +// ** Transform a UTF-8 integer literal, in either decimal or hexadecimal, +// ** into a 64-bit signed integer. This routine accepts hexadecimal literals, +// ** whereas sqlite3Atoi64() does not. +// ** +// ** Returns: +// ** +// ** 0 Successful transformation. Fits in a 64-bit signed integer. +// ** 1 Excess text after the integer value +// ** 2 Integer too large for a 64-bit signed integer or is malformed +// ** 3 Special case of 9223372036854775808 +// */ +func _sqlite3DecOrHexToI64(tls *libc.TLS, z uintptr, pOut uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, k, n int32 + var _ /* u at bp+0 */ Tu64 + _, _, _ = i, k, n + if int32(**(**int8)(__ccgo_up(z))) == int32('0') && (int32(**(**int8)(__ccgo_up(z + 1))) == int32('x') || int32(**(**int8)(__ccgo_up(z + 1))) == int32('X')) { + **(**Tu64)(__ccgo_up(bp)) = uint64(0) + i = int32(2) + for { + if !(int32(**(**int8)(__ccgo_up(z + uintptr(i)))) == int32('0')) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + k = i + for { + if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(z + uintptr(k))))])&int32(0x08) != 0) { + break + } + **(**Tu64)(__ccgo_up(bp)) = **(**Tu64)(__ccgo_up(bp))*uint64(16) + uint64(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(z + uintptr(k)))))) + goto _2 + _2: + ; + k = k + 1 + } + libc.Xmemcpy(tls, pOut, bp, uint64(8)) + if k-i > int32(16) { + return int32(2) + } + if int32(**(**int8)(__ccgo_up(z + uintptr(k)))) != 0 { + return int32(1) + } + return 0 + } else { + n = libc.Int32FromUint64(libc.Uint64FromInt32(0x3fffffff) & libc.Xstrspn(tls, z, __ccgo_ts+1834)) + if **(**int8)(__ccgo_up(z + uintptr(n))) != 0 { + n = n + 1 + } + return _sqlite3Atoi64(tls, z, pOut, n, uint8(SQLITE_UTF8)) + } + return r +} + +// C documentation +// +// /* +// ** Expression p is a QNUMBER (quoted number). Dequote the value in p->u.zToken +// ** and set the type to INTEGER or FLOAT. "Quoted" integers or floats are those +// ** that contain '_' characters that must be removed before further processing. +// */ +func _sqlite3DequoteNumber(tls *libc.TLS, pParse uintptr, p uintptr) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bHex int32 + var pIn, pOut, v1, v3 uintptr + var _ /* iValue at bp+0 */ int32 + _, _, _, _, _ = bHex, pIn, pOut, v1, v3 + if p != 0 { + pIn = *(*uintptr)(unsafe.Pointer(p + 8)) + pOut = *(*uintptr)(unsafe.Pointer(p + 8)) + bHex = libc.BoolInt32(int32(**(**int8)(__ccgo_up(pIn))) == int32('0') && (int32(**(**int8)(__ccgo_up(pIn + 1))) == int32('x') || int32(**(**int8)(__ccgo_up(pIn + 1))) == int32('X'))) + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_INTEGER) + for { + if int32(**(**int8)(__ccgo_up(pIn))) != int32('_') { + v3 = pOut + pOut = pOut + 1 + **(**int8)(__ccgo_up(v3)) = **(**int8)(__ccgo_up(pIn)) + if int32(**(**int8)(__ccgo_up(pIn))) == int32('e') || int32(**(**int8)(__ccgo_up(pIn))) == int32('E') || int32(**(**int8)(__ccgo_up(pIn))) == int32('.') { + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_FLOAT) + } + } else { + if bHex == 0 && (!(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + uintptr(-libc.Int32FromInt32(1)))))])&libc.Int32FromInt32(0x04) != 0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + 1)))])&libc.Int32FromInt32(0x04) != 0)) || bHex == int32(1) && (!(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + uintptr(-libc.Int32FromInt32(1)))))])&libc.Int32FromInt32(0x08) != 0) || !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(pIn + 1)))])&libc.Int32FromInt32(0x08) != 0)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1790, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(p + 8)))) + } + } + goto _2 + _2: + ; + v1 = pIn + pIn = pIn + 1 + if !(**(**int8)(__ccgo_up(v1)) != 0) { + break + } + } + if bHex != 0 { + (*TExpr)(unsafe.Pointer(p)).Fop = uint8(TK_INTEGER) + } + /* tag-20240227-a: If after dequoting, the number is an integer that + ** fits in 32 bits, then it must be converted into EP_IntValue. Other + ** parts of the code expect this. See also tag-20240227-b. */ + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_INTEGER) && _sqlite3GetInt32(tls, *(*uintptr)(unsafe.Pointer(p + 8)), bp) != 0 { + *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(p)).Fu)) = **(**int32)(__ccgo_up(bp)) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(EP_IntValue) + } + } +} + +// C documentation +// +// /* +// ** This routine is called to report the final ")" that terminates +// ** a CREATE TABLE statement. +// ** +// ** The table structure that other action routines have been building +// ** is added to the internal hash tables, assuming no errors have +// ** occurred. +// ** +// ** An entry for the table is made in the schema table on disk, unless +// ** this is a temporary table or db->init.busy==1. When db->init.busy==1 +// ** it means we are reading the sqlite_schema table because we just +// ** connected to the database or because the sqlite_schema table has +// ** recently changed, so the entry for this table already exists in +// ** the sqlite_schema table. We do not want to create it again. +// ** +// ** If the pSelect argument is not NULL, it means that this routine +// ** was called to create a table generated from a +// ** "CREATE TABLE ... AS SELECT ..." statement. The column names of +// ** the new table will match the result set of the SELECT. +// */ +func _sqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr, tabOpts Tu32, pSelect uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var addrInsLoop, addrTop, iCsr, iDb, ii, ii1, n, nNG, regRec, regRowid, regYield, v4 int32 + var colFlags Tu32 + var db, p, pCol, pDb, pEnd2, pIdx, pOld, pSchema, pSelTab, pX, v, zStmt, zType, zType2, v5 uintptr + var v12 Ti16 + var _ /* dest at bp+0 */ TSelectDest + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrInsLoop, addrTop, colFlags, db, iCsr, iDb, ii, ii1, n, nNG, p, pCol, pDb, pEnd2, pIdx, pOld, pSchema, pSelTab, pX, regRec, regRowid, regYield, v, zStmt, zType, zType2, v12, v4, v5 /* The new table */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* An implied index of the table */ + if pEnd == uintptr(0) && pSelect == uintptr(0) { + return + } + p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable + if p == uintptr(0) { + return + } + if pSelect == uintptr(0) && _sqlite3ShadowTableName(tls, db, (*TTable)(unsafe.Pointer(p)).FzName) != 0 { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Shadow) + } + /* If the db->init.busy is 1 it means we are reading the SQL off the + ** "sqlite_schema" or "sqlite_temp_schema" table on the disk. + ** So do not write to the disk again. Extract the root page number + ** for the table from the db->init.newTnum field. (The page number + ** should have been put there by the sqliteOpenCb routine.) + ** + ** If the root page number is 1, that means this is the sqlite_schema + ** table itself. So mark it read-only. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + if pSelect != 0 || !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) && (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1704, 0) + return + } + (*TTable)(unsafe.Pointer(p)).Ftnum = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum + if (*TTable)(unsafe.Pointer(p)).Ftnum == uint32(1) { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Readonly) + } + } + /* Special processing for tables that include the STRICT keyword: + ** + ** * Do not allow custom column datatypes. Every column must have + ** a datatype that is one of INT, INTEGER, REAL, TEXT, or BLOB. + ** + ** * If a PRIMARY KEY is defined, other than the INTEGER PRIMARY KEY, + ** then all columns of the PRIMARY KEY must have a NOT NULL + ** constraint. + */ + if tabOpts&uint32(TF_Strict) != 0 { + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Strict) + ii = 0 + for { + if !(ii < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr(ii)*16 + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == COLTYPE_CUSTOM { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14396, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, _sqlite3ColumnType(tls, pCol, __ccgo_ts+1704))) + } else { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14429, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + } + return + } else { + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == int32(COLTYPE_ANY) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = int8(SQLITE_AFF_BLOB) + } + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 && int32((*TTable)(unsafe.Pointer(p)).FiPKey) != ii && int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) == OE_None { + libc.SetBitFieldPtr8Uint32(pCol+8, libc.Uint32FromInt32(OE_Abort), 0, 0xf) + **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_HasNotNull) + } + goto _1 + _1: + ; + ii = ii + 1 + } + } + /* Special processing for WITHOUT ROWID Tables */ + if tabOpts&uint32(TF_WithoutRowid) != 0 { + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_Autoincrement) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14456, 0) + return + } + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasPrimaryKey) == uint32(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14506, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName)) + return + } + **(**Tu32)(__ccgo_up(p + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid) | libc.Int32FromInt32(TF_NoVisibleRowid)) + _convertToWithoutRowidTable(tls, pParse, p) + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(p)).FpSchema) + /* Resolve names in all CHECK constraint expressions. + */ + if (*TTable)(unsafe.Pointer(p)).FpCheck != 0 { + _sqlite3ResolveSelfReference(tls, pParse, p, int32(NC_IsCheck), uintptr(0), (*TTable)(unsafe.Pointer(p)).FpCheck) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + /* If errors are seen, delete the CHECK constraints now, else they might + ** actually be used if PRAGMA writable_schema=ON is set. */ + _sqlite3ExprListDelete(tls, db, (*TTable)(unsafe.Pointer(p)).FpCheck) + (*TTable)(unsafe.Pointer(p)).FpCheck = uintptr(0) + } else { + } + } + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasGenerated) != 0 { + nNG = 0 + ii1 = 0 + for { + if !(ii1 < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { + break + } + colFlags = uint32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(ii1)*16))).FcolFlags) + if colFlags&uint32(COLFLAG_GENERATED) != uint32(0) { + pX = _sqlite3ColumnExpr(tls, p, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(ii1)*16) + if _sqlite3ResolveSelfReference(tls, pParse, p, int32(NC_GenCol), pX, uintptr(0)) != 0 { + /* If there are errors in resolving the expression, change the + ** expression to a NULL. This prevents code generators that operate + ** on the expression from inserting extra parts into the expression + ** tree that have been allocated from lookaside memory, which is + ** illegal in a schema and will lead to errors or heap corruption + ** when the database connection closes. */ + _sqlite3ColumnSetExpr(tls, pParse, p, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(ii1)*16, _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0)) + } + } else { + nNG = nNG + 1 + } + goto _2 + _2: + ; + ii1 = ii1 + 1 + } + if nNG == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14538, 0) + return + } + } + /* Estimate the average row size for the table and for all implied indices */ + _estimateTableWidth(tls, p) + pIdx = (*TTable)(unsafe.Pointer(p)).FpIndex + for { + if !(pIdx != 0) { + break + } + _estimateIndexWidth(tls, pIdx) + goto _3 + _3: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + /* If not initializing, then create a record for the new table + ** in the schema table of the database. + ** + ** If this is a TEMPORARY table, write the entry into the auxiliary + ** file instead of into the main database file. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { /* Text of the CREATE TABLE or CREATE VIEW statement */ + v = _sqlite3GetVdbe(tls, pParse) + if v == uintptr(0) { + return + } + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), 0) + /* + ** Initialize zType for the new view or table. + */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM { + /* A regular table */ + zType = __ccgo_ts + 9377 + zType2 = __ccgo_ts + 14582 + } else { + /* A view */ + zType = __ccgo_ts + 11115 + zType2 = __ccgo_ts + 14588 + } + /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT + ** statement to populate the new table. The root-page number for the + ** new table is in register pParse->u1.cr.regRoot. + ** + ** Once the SELECT has been coded by sqlite3Select(), it is in a + ** suitable state to query for the column names and types to be used + ** by the new table. + ** + ** A shared-cache write-lock is not required to write to the new table, + ** as a schema-lock must have already been obtained to create it. Since + ** a schema-lock excludes all other database users, the write-lock would + ** be redundant. + */ + if pSelect != 0 { /* Write cursor on the new table */ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + return + } + v5 = pParse + 56 + v4 = *(*int32)(unsafe.Pointer(v5)) + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + iCsr = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regYield = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regRec = v4 + v5 = pParse + 60 + *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 + v4 = *(*int32)(unsafe.Pointer(v5)) + regRowid = v4 + _sqlite3MayAbort(tls, pParse) + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenWrite), iCsr, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot, iDb) + _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_P2ISREG)) + addrTop = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) + _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, addrTop) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + pSelTab = _sqlite3ResultSetOfSelect(tls, pParse, pSelect, int8(SQLITE_AFF_BLOB)) + if pSelTab == uintptr(0) { + return + } + v12 = (*TTable)(unsafe.Pointer(pSelTab)).FnCol + (*TTable)(unsafe.Pointer(p)).FnNVCol = v12 + (*TTable)(unsafe.Pointer(p)).FnCol = v12 + (*TTable)(unsafe.Pointer(p)).FaCol = (*TTable)(unsafe.Pointer(pSelTab)).FaCol + (*TTable)(unsafe.Pointer(pSelTab)).FnCol = 0 + (*TTable)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) + _sqlite3DeleteTable(tls, db, pSelTab) + _sqlite3SelectDestInit(tls, bp, int32(SRT_Coroutine), regYield) + _sqlite3Select(tls, pParse, pSelect, bp) + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return + } + _sqlite3VdbeEndCoroutine(tls, v, regYield) + _sqlite3VdbeJumpHere(tls, v, addrTop-int32(1)) + addrInsLoop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm) + _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (**(**TSelectDest)(__ccgo_up(bp))).FiSdst, (**(**TSelectDest)(__ccgo_up(bp))).FnSdst, regRec) + _sqlite3TableAffinity(tls, v, p, 0) + _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iCsr, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iCsr, regRec, regRowid) + _sqlite3VdbeGoto(tls, v, addrInsLoop) + _sqlite3VdbeJumpHere(tls, v, addrInsLoop) + _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iCsr) + } + /* Compute the complete text of the CREATE statement */ + if pSelect != 0 { + zStmt = _createTableStmt(tls, db, p) + } else { + if tabOpts != 0 { + v5 = pParse + 280 + } else { + v5 = pEnd + } + pEnd2 = v5 + n = int32(int64((*TToken)(unsafe.Pointer(pEnd2)).Fz) - int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + if int32(**(**int8)(__ccgo_up((*TToken)(unsafe.Pointer(pEnd2)).Fz))) != int32(';') { + n = libc.Int32FromUint32(uint32(n) + (*TToken)(unsafe.Pointer(pEnd2)).Fn) + } + zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+14593, libc.VaList(bp+48, zType2, n, (*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + } + /* A slot for the record has already been allocated in the + ** schema table. We just need to update that slot with all + ** the information we've collected. + */ + _sqlite3NestedParse(tls, pParse, __ccgo_ts+14608, libc.VaList(bp+48, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zType, (*TTable)(unsafe.Pointer(p)).FzName, (*TTable)(unsafe.Pointer(p)).FzName, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRoot, zStmt, (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FregRowid)) + _sqlite3DbFree(tls, db, zStmt) + _sqlite3ChangeCookie(tls, pParse, iDb) + /* Check to see if we need to create an sqlite_sequence table for + ** keeping track of autoincrement keys. + */ + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_Autoincrement) != uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != libc.Int32FromInt32(PARSE_MODE_NORMAL)) { + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + if (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab == uintptr(0) { + _sqlite3NestedParse(tls, pParse, __ccgo_ts+14706, libc.VaList(bp+48, (*TDb)(unsafe.Pointer(pDb)).FzDbSName)) + } + } + /* Reparse everything to update our internal data structures */ + _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+14748, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName)), uint16(0)) + /* Test for cycles in generated columns and illegal expressions + ** in CHECK constraints and in DEFAULT clauses. */ + if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasGenerated) != 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_SqlExec), int32(0x0001), 0, 0, _sqlite3MPrintf(tls, db, __ccgo_ts+14782, libc.VaList(bp+48, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(p)).FzName)), -int32(7)) + } + } + /* Add the table to the in-memory representation of the database. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { + pSchema = (*TTable)(unsafe.Pointer(p)).FpSchema + pOld = _sqlite3HashInsert(tls, pSchema+8, (*TTable)(unsafe.Pointer(p)).FzName, p) + if pOld != 0 { + /* Malloc must have failed inside HashInsert() */ + _sqlite3OomFault(tls, db) + return + } + (*TParse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + /* If this is the magic sqlite_sequence table used by autoincrement, + ** then record a pointer to this table in the main database structure + ** so that INSERT can find the table easily. */ + if libc.Xstrcmp(tls, (*TTable)(unsafe.Pointer(p)).FzName, __ccgo_ts+9899) == 0 { + (*TSchema)(unsafe.Pointer((*TTable)(unsafe.Pointer(p)).FpSchema)).FpSeqTab = p + } + } + if !(pSelect != 0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM { + if (*TToken)(unsafe.Pointer(pCons)).Fz == uintptr(0) { + pCons = pEnd + } + (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(p + 64))).FaddColOffset = int32(13) + int32(int64((*TToken)(unsafe.Pointer(pCons)).Fz)-int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) + } +} + +// C documentation +// +// /* +// ** Assign a variable number to an expression that encodes a wildcard +// ** in the original SQL statement. +// ** +// ** Wildcards consisting of a single "?" are assigned the next sequential +// ** variable number. +// ** +// ** Wildcards of the form "?nnn" are assigned the number "nnn". We make +// ** sure "nnn" is not too big to avoid a denial of service attack when +// ** the SQL statement comes from an external source. +// ** +// ** Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number +// ** as the previous instance of the same wildcard. Or if this is the first +// ** instance of the wildcard, the next sequential variable number is +// ** assigned. +// */ +func _sqlite3ExprAssignVarNumber(tls *libc.TLS, pParse uintptr, pExpr uintptr, n Tu32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var bOk, doAdd int32 + var db, z, v2 uintptr + var x, v1 TynVar + var _ /* i at bp+0 */ Ti64 + _, _, _, _, _, _, _ = bOk, db, doAdd, x, z, v1, v2 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if pExpr == uintptr(0) { + return + } + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + if int32(**(**int8)(__ccgo_up(z + 1))) == 0 { + /* Wildcard of the form "?". Assign the next variable number */ + v2 = pParse + 296 + *(*TynVar)(unsafe.Pointer(v2)) = *(*TynVar)(unsafe.Pointer(v2)) + 1 + v1 = *(*TynVar)(unsafe.Pointer(v2)) + x = v1 + } else { + doAdd = 0 + if int32(**(**int8)(__ccgo_up(z))) == int32('?') { + if n == uint32(2) { /*OPTIMIZATION-IF-TRUE*/ + **(**Ti64)(__ccgo_up(bp)) = int64(int32(**(**int8)(__ccgo_up(z + 1))) - int32('0')) /* The common case of ?N for a single digit N */ + bOk = int32(1) + } else { + bOk = libc.BoolInt32(0 == _sqlite3Atoi64(tls, z+1, bp, libc.Int32FromUint32(n-uint32(1)), uint8(SQLITE_UTF8))) + } + if bOk == 0 || **(**Ti64)(__ccgo_up(bp)) < int64(1) || **(**Ti64)(__ccgo_up(bp)) > int64(**(**int32)(__ccgo_up(db + 136 + 9*4))) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8059, libc.VaList(bp+16, **(**int32)(__ccgo_up(db + 136 + 9*4)))) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + return + } + x = int16(**(**Ti64)(__ccgo_up(bp))) + if int32(x) > int32((*TParse)(unsafe.Pointer(pParse)).FnVar) { + (*TParse)(unsafe.Pointer(pParse)).FnVar = int16(int32(x)) + doAdd = int32(1) + } else { + if _sqlite3VListNumToName(tls, (*TParse)(unsafe.Pointer(pParse)).FpVList, int32(x)) == uintptr(0) { + doAdd = int32(1) + } + } + } else { + /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable + ** number as the prior appearance of the same name, or if the name + ** has never appeared before, reuse the same variable number + */ + x = int16(_sqlite3VListNameToNum(tls, (*TParse)(unsafe.Pointer(pParse)).FpVList, z, libc.Int32FromUint32(n))) + if int32(x) == 0 { + v2 = pParse + 296 + *(*TynVar)(unsafe.Pointer(v2)) = *(*TynVar)(unsafe.Pointer(v2)) + 1 + v1 = *(*TynVar)(unsafe.Pointer(v2)) + x = v1 + doAdd = int32(1) + } + } + if doAdd != 0 { + (*TParse)(unsafe.Pointer(pParse)).FpVList = _sqlite3VListAdd(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpVList, z, libc.Int32FromUint32(n), int32(x)) + } + } + (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = x + if int32(x) > **(**int32)(__ccgo_up(db + 136 + 9*4)) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8102, 0) + _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) + } +} + +// C documentation +// +// /* +// ** Generate code into the current Vdbe to evaluate the given +// ** expression. Attempt to store the results in register "target". +// ** Return the register where results are stored. +// ** +// ** With this routine, there is no guarantee that results will +// ** be stored in target. The result might be stored in some other +// ** register if it is convenient to do so. The calling function +// ** must check the return code and move the results to the desired +// ** register. +// */ +func _sqlite3ExprCodeTarget(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) (r int32) { + bp := tls.Alloc(192) + defer tls.Free(192) + var aListelem, db, db1, pAggInfo, pAggInfo1, pCol, pCol1, pColl, pDef, pDel, pEList, pFarg, pInfo, pLeft, pLeft1, pLeft2, pTab, pTab1, pTab2, pTest, pX, v, z, zBlob, zId, v3 uintptr + var addr, addrINR, addrIsNull, addrIsNull1, aff, bNormal, destIfFalse, destIfNull, endLabel, i, i1, iCol, iCol1, iReg, iSrc, iTab, inReg, isTrue, n, n1, nCol, nExpr, nFarg, nextCase, op, p1, p5, v1 int32 + var constMask Tu32 + var enc, exprOp, okConstFactor Tu8 + var v2 bool + var _ /* opCompare at bp+88 */ TExpr + var _ /* r1 at bp+8 */ int32 + var _ /* r2 at bp+12 */ int32 + var _ /* regFree1 at bp+0 */ int32 + var _ /* regFree2 at bp+4 */ int32 + var _ /* tempX at bp+16 */ TExpr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aListelem, addr, addrINR, addrIsNull, addrIsNull1, aff, bNormal, constMask, db, db1, destIfFalse, destIfNull, enc, endLabel, exprOp, i, i1, iCol, iCol1, iReg, iSrc, iTab, inReg, isTrue, n, n1, nCol, nExpr, nFarg, nextCase, okConstFactor, op, p1, p5, pAggInfo, pAggInfo1, pCol, pCol1, pColl, pDef, pDel, pEList, pFarg, pInfo, pLeft, pLeft1, pLeft2, pTab, pTab1, pTab2, pTest, pX, v, z, zBlob, zId, v1, v2, v3 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* The opcode being coded */ + inReg = target /* Results stored in register inReg */ + **(**int32)(__ccgo_up(bp)) = 0 /* If non-zero free this temporary register */ + **(**int32)(__ccgo_up(bp + 4)) = 0 /* Temporary expression node */ + p5 = 0 + goto expr_code_doover +expr_code_doover: + ; + if pExpr == uintptr(0) { + op = int32(TK_NULL) + } else { + if v2 = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr != uintptr(0) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)); v2 { + v1 = _sqlite3IndexedExprLookup(tls, pParse, pExpr, target) + **(**int32)(__ccgo_up(bp + 8)) = v1 + } + if v2 && v1 >= 0 { + return **(**int32)(__ccgo_up(bp + 8)) + } else { + op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) + } + } + switch op { + case int32(TK_AGG_COLUMN): + pAggInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn { + /* Happens when the left table of a RIGHT JOIN is null and + ** is using an expression index */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + break + } + pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32 + if !((*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode != 0) { + return (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + } else { + if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx != 0 { + pTab = (*TAggInfo_col)(unsafe.Pointer(pCol)).FpTab + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab, (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn, target) + if pTab == uintptr(0) { + /* No comment added */ + } else { + if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn < 0 { + } else { + if int32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + } + } + } + return target + } else { + if *(*uintptr)(unsafe.Pointer(pExpr + 64)) == uintptr(0) { + /* This case happens when the argument to an aggregate function + ** is rewritten by aggregateConvertIndexedExprRefToColumn() */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), target) + return target + } + } + } + /* Otherwise, fall thru into the TK_COLUMN case */ + fallthrough + case int32(TK_COLUMN): + iTab = (*TExpr)(unsafe.Pointer(pExpr)).FiTable + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != uint32(0) { + iReg = _sqlite3ExprCodeTarget(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + aff = int32(_sqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn))) + if aff > int32(SQLITE_AFF_BLOB) { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), iReg, int32(1), 0, uintptr(unsafe.Pointer(&_zAff))+uintptr((aff-int32('B'))*int32(2)), -int32(1)) + } + return iReg + } + if iTab < 0 { + if (*TParse)(unsafe.Pointer(pParse)).FiSelfTab < 0 { + iCol = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + pTab1 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + if iCol < 0 { + return -int32(1) - (*TParse)(unsafe.Pointer(pParse)).FiSelfTab + } + pCol1 = (*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(iCol)*16 + iSrc = int32(_sqlite3TableColumnToStorage(tls, pTab1, int16(iCol))) - (*TParse)(unsafe.Pointer(pParse)).FiSelfTab + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_BUSY) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8452, libc.VaList(bp+168, (*TColumn)(unsafe.Pointer(pCol1)).FzCnName)) + return 0 + } + v3 = pCol1 + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(COLFLAG_BUSY)) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_NOTAVAIL) != 0 { + _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab1, pCol1, iSrc) + } + v3 = pCol1 + 14 + *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(COLFLAG_BUSY) | libc.Int32FromInt32(COLFLAG_NOTAVAIL))) + return iSrc + } else { + if int32((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), iSrc, target) + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + return target + } else { + return iSrc + } + } + } else { + /* Coding an expression that is part of an index where column names + ** in the index refer to the table to which the index belongs */ + iTab = (*TParse)(unsafe.Pointer(pParse)).FiSelfTab - int32(1) + } + } else { + if v2 = (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr != 0; v2 { + v1 = _exprPartidxExprLookup(tls, pParse, pExpr, target) + **(**int32)(__ccgo_up(bp + 8)) = v1 + } + if v2 && 0 != v1 { + return **(**int32)(__ccgo_up(bp + 8)) + } + } + iReg = _sqlite3ExprCodeGetColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), iTab, target, (*TExpr)(unsafe.Pointer(pExpr)).Fop2) + return iReg + case int32(TK_INTEGER): + _codeInteger(tls, pParse, pExpr, 0, target) + return target + case int32(TK_TRUEFALSE): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprTruthValue(tls, pExpr), target) + return target + case int32(TK_FLOAT): + _codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pExpr + 8)), 0, target) + return target + case int32(TK_STRING): + _sqlite3VdbeLoadString(tls, v, target, *(*uintptr)(unsafe.Pointer(pExpr + 8))) + return target + case int32(TK_NULLS): + /* Set a range of registers to NULL. pExpr->y.nReg registers starting + ** with target */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, target, target+*(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fy))-int32(1)) + return target + default: + /* Make NULL the default case so that if a bug causes an illegal + ** Expr node to be passed into this function, it will be handled + ** sanely and not crash. But keep the assert() to bring the problem + ** to the attention of the developers. */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + return target + case int32(TK_BLOB): + z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + 2 + n = _sqlite3Strlen30(tls, z) - int32(1) + zBlob = _sqlite3HexToBlob(tls, _sqlite3VdbeDb(tls, v), z, n) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Blob), n/int32(2), target, 0, zBlob, -int32(7)) + return target + case int32(TK_VARIABLE): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Variable), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), target) + return target + case int32(TK_REGISTER): + return (*TExpr)(unsafe.Pointer(pExpr)).FiTable + case int32(TK_CAST): + /* Expressions of the form: CAST(pLeft AS token) */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Cast), target, int32(_sqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0)))) + return inReg + case int32(TK_IS): + fallthrough + case int32(TK_ISNOT): + if op == int32(TK_IS) { + v1 = int32(TK_EQ) + } else { + v1 = int32(TK_NE) + } + op = v1 + p5 = int32(SQLITE_NULLEQ) + fallthrough + case int32(TK_LT): + fallthrough + case int32(TK_LE): + fallthrough + case int32(TK_GT): + fallthrough + case int32(TK_GE): + fallthrough + case int32(TK_NE): + fallthrough + case int32(TK_EQ): + pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + addrIsNull = 0 + if _sqlite3ExprIsVector(tls, pLeft) != 0 { + _codeVectorCompare(tls, pParse, pExpr, target, libc.Uint8FromInt32(op), libc.Uint8FromInt32(p5)) + } else { + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) && p5 != int32(SQLITE_NULLEQ) { + addrIsNull = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), inReg) + _codeCompare(tls, pParse, pLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, op, **(**int32)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 12)), _sqlite3VdbeCurrentAddr(tls, v)+int32(2), p5, libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0))) + if p5 == int32(SQLITE_NULLEQ) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, inReg) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_ZeroOrNull), **(**int32)(__ccgo_up(bp + 8)), inReg, **(**int32)(__ccgo_up(bp + 12))) + if addrIsNull != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addrIsNull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, inReg) + } + } + } + case int32(TK_AND): + fallthrough + case int32(TK_OR): + inReg = _exprCodeTargetAndOr(tls, pParse, pExpr, target, bp) + case int32(TK_PLUS): + fallthrough + case int32(TK_STAR): + fallthrough + case int32(TK_MINUS): + fallthrough + case int32(TK_REM): + fallthrough + case int32(TK_BITAND): + fallthrough + case int32(TK_BITOR): + fallthrough + case int32(TK_SLASH): + fallthrough + case int32(TK_LSHIFT): + fallthrough + case int32(TK_RSHIFT): + fallthrough + case int32(TK_CONCAT): + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { + addrIsNull1 = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) + addrIsNull1 = 0 + } + _sqlite3VdbeAddOp3(tls, v, op, **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 8)), target) + if addrIsNull1 != 0 { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) + _sqlite3VdbeJumpHere(tls, v, addrIsNull1) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + case int32(TK_UMINUS): + pLeft1 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft1)).Fop) == int32(TK_INTEGER) { + _codeInteger(tls, pParse, pLeft1, int32(1), target) + return target + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft1)).Fop) == int32(TK_FLOAT) { + _codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pLeft1 + 8)), int32(1), target) + return target + } else { + (**(**TExpr)(__ccgo_up(bp + 16))).Fop = uint8(TK_INTEGER) + (**(**TExpr)(__ccgo_up(bp + 16))).Fflags = libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue) | libc.Int32FromInt32(EP_TokenOnly)) + *(*int32)(unsafe.Pointer(bp + 16 + 8)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, bp+16, bp) + **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp+4) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Subtract), **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 8)), target) + } + } + case int32(TK_BITNOT): + fallthrough + case int32(TK_NOT): + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + _sqlite3VdbeAddOp2(tls, v, op, **(**int32)(__ccgo_up(bp + 8)), inReg) + case int32(TK_TRUTH): /* IS TRUE or IS FALSE */ + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + isTrue = _sqlite3ExprTruthValue(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) + bNormal = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) == int32(TK_IS)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsTrue), **(**int32)(__ccgo_up(bp + 8)), inReg, libc.BoolInt32(!(isTrue != 0)), isTrue^bNormal) + case int32(TK_ISNULL): + fallthrough + case int32(TK_NOTNULL): + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), target) + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + addr = _sqlite3VdbeAddOp1(tls, v, op, **(**int32)(__ccgo_up(bp + 8))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, target) + _sqlite3VdbeJumpHere(tls, v, addr) + case int32(TK_AGG_FUNCTION): + pInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if pInfo == uintptr(0) || int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) < 0 || int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pInfo)).FnFunc { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8513, libc.VaList(bp+168, pExpr)) + } else { + return (*TAggInfo)(unsafe.Pointer(pInfo)).FiFirstReg + (*TAggInfo)(unsafe.Pointer(pInfo)).FnColumn + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + } + case int32(TK_FUNCTION): /* The function name */ + constMask = uint32(0) /* Loop counter */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The database connection */ + enc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc /* The text encoding used by this database */ + pColl = uintptr(0) /* A collating sequence */ + if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { + return (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FregResult + } + if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x80>>7)) != 0 && _sqlite3ExprIsConstantNotJoin(tls, pParse, pExpr) != 0 { + /* SQL functions can be expensive. So try to avoid running them + ** multiple times if we know they always give the same result */ + return _sqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -int32(1)) + } + pFarg = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + if pFarg != 0 { + v1 = (*TExprList)(unsafe.Pointer(pFarg)).FnExpr + } else { + v1 = 0 + } + nFarg = v1 + zId = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + pDef = _sqlite3FindFunction(tls, db, zId, nFarg, enc, uint8(0)) + if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8540, libc.VaList(bp+168, pExpr)) + break + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INLINE) != uint32(0) && pFarg != uintptr(0) { + return _exprCodeInlineFunction(tls, pParse, pFarg, int32(int64((*TFuncDef)(unsafe.Pointer(pDef)).FpUserData)), target) + } else { + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_DIRECT)|libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) != 0 { + _sqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) + } + } + i = 0 + for { + if !(i < nFarg) { + break + } + if i < int32(32) && _sqlite3ExprIsConstant(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + uintptr(i)*32))).FpExpr) != 0 { + constMask = constMask | libc.Uint32FromInt32(1)<= int32(2) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InfixFunc)) != uint32(0) { + pDef = _sqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr) + } else { + if nFarg > 0 { + pDef = _sqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr) + } + } + if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 { + if !(pColl != 0) { + pColl = (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_CollSeq), 0, 0, 0, pColl, -int32(2)) + } + _sqlite3VdbeAddFunctionCall(tls, pParse, libc.Int32FromUint32(constMask), **(**int32)(__ccgo_up(bp + 8)), target, nFarg, pDef, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2)) + if nFarg != 0 { + if constMask == uint32(0) { + _sqlite3ReleaseTempRange(tls, pParse, **(**int32)(__ccgo_up(bp + 8)), nFarg) + } else { + } + } + return target + case int32(TK_EXISTS): + fallthrough + case int32(TK_SELECT): + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { + return 0 + } else { + if v2 = op == int32(TK_SELECT) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0); v2 { + v1 = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList)).FnExpr + nCol = v1 + } + if v2 && v1 != int32(1) { + _sqlite3SubselectError(tls, pParse, nCol, int32(1)) + } else { + return _sqlite3CodeSubselect(tls, pParse, pExpr) + } + } + case int32(TK_SELECT_COLUMN): + pLeft2 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + if (*TExpr)(unsafe.Pointer(pLeft2)).FiTable == 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn) > libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft2)).Fop2) { + (*TExpr)(unsafe.Pointer(pLeft2)).FiTable = _sqlite3CodeSubselect(tls, pParse, pLeft2) + (*TExpr)(unsafe.Pointer(pLeft2)).Fop2 = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn + } + n1 = _sqlite3ExprVectorSize(tls, pLeft2) + if (*TExpr)(unsafe.Pointer(pExpr)).FiTable != n1 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8125, libc.VaList(bp+168, (*TExpr)(unsafe.Pointer(pExpr)).FiTable, n1)) + } + return (*TExpr)(unsafe.Pointer(pLeft2)).FiTable + int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + case int32(TK_IN): + destIfFalse = _sqlite3VdbeMakeLabel(tls, pParse) + destIfNull = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + _sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), target) + _sqlite3VdbeResolveLabel(tls, v, destIfFalse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), target, 0) + _sqlite3VdbeResolveLabel(tls, v, destIfNull) + return target + /* + ** x BETWEEN y AND z + ** + ** This is equivalent to + ** + ** x>=y AND x<=z + ** + ** X is stored in pExpr->pLeft. + ** Y is stored in pExpr->pList->a[0].pExpr. + ** Z is stored in pExpr->pList->a[1].pExpr. + */ + fallthrough + case int32(TK_BETWEEN): + _exprCodeBetween(tls, pParse, pExpr, target, uintptr(0), 0) + return target + case int32(TK_COLLATE): + if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != libc.Uint32FromInt32(0)) { + /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called + ** "SOFT-COLLATE" that is added to constraints that are pushed down + ** from outer queries into sub-queries by the WHERE-clause push-down + ** optimization. Clear subtypes as subtypes may not cross a subquery + ** boundary. + */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ClrSubtype), target) + return target + } else { + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + goto expr_code_doover /* 2018-04-28: Prevent deep recursion. */ + } + fallthrough + case int32(TK_SPAN): + fallthrough + case int32(TK_UPLUS): + pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + goto expr_code_doover /* 2018-04-28: Prevent deep recursion. OSSFuzz. */ + case int32(TK_TRIGGER): + pTab2 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) + iCol1 = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) + p1 = (*TExpr)(unsafe.Pointer(pExpr)).FiTable*(int32((*TTable)(unsafe.Pointer(pTab2)).FnCol)+int32(1)) + int32(1) + int32(_sqlite3TableColumnToStorage(tls, pTab2, int16(iCol1))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Param), p1, target) + /* If the column has REAL affinity, it may currently be stored as an + ** integer. Use OP_RealAffinity to make sure it is really real. + ** + ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to + ** floating point when extracting it from the record. */ + if iCol1 >= 0 && int32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab2)).FaCol + uintptr(iCol1)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) + } + case int32(TK_VECTOR): + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6908, 0) + break + /* TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions + ** that derive from the right-hand table of a LEFT JOIN. The + ** Expr.iTable value is the table number for the right-hand table. + ** The expression is only evaluated if that table is not currently + ** on a LEFT JOIN NULL row. + */ + fallthrough + case int32(TK_IF_NULL_ROW): + okConstFactor = libc.Uint8FromInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x80 >> 7))) + pAggInfo1 = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo + if pAggInfo1 != 0 { + if !((*TAggInfo)(unsafe.Pointer(pAggInfo1)).FdirectMode != 0) { + inReg = (*TAggInfo)(unsafe.Pointer(pAggInfo1)).FiFirstReg + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) + break + } + if (*TAggInfo)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo)).FuseSortingIdx != 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo)(unsafe.Pointer(pAggInfo1)).FsortingIdxPTab, (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo1)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32))).FiSorterColumn, target) + inReg = target + break + } + } + addrINR = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNullRow), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, 0, target) + /* The OP_IfNullRow opcode above can overwrite the result register with + ** NULL. So we have to ensure that the result register is not a value + ** that is suppose to be a constant. Two defenses are needed: + ** (1) Temporarily disable factoring of constant expressions + ** (2) Make sure the computed value really is stored in register + ** "target" and not someplace else. + */ + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) /* note (1) above */ + _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) + libc.SetBitFieldPtr16Uint32(pParse+40, uint32(okConstFactor), 7, 0x80) + _sqlite3VdbeJumpHere(tls, v, addrINR) + break + /* + ** Form A: + ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** Form B: + ** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END + ** + ** Form A is can be transformed into the equivalent form B as follows: + ** CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ... + ** WHEN x=eN THEN rN ELSE y END + ** + ** X (if it exists) is in pExpr->pLeft. + ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is + ** odd. The Y is also optional. If the number of elements in x.pList + ** is even, then Y is omitted and the "otherwise" result is NULL. + ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1]. + ** + ** The result of the expression is the Ri for the first matching Ei, + ** or if there is no matching Ei, the ELSE term Y, or if there is + ** no ELSE term, NULL. + */ + fallthrough + case int32(TK_CASE): /* The X expression */ + pTest = uintptr(0) /* X==Ei (form A) or just Ei (form B) */ + pDel = uintptr(0) + db1 = (*TParse)(unsafe.Pointer(pParse)).Fdb + pEList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) + aListelem = pEList + 8 + nExpr = (*TExprList)(unsafe.Pointer(pEList)).FnExpr + endLabel = _sqlite3VdbeMakeLabel(tls, pParse) + v3 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft + pX = v3 + if v3 != uintptr(0) { + pDel = _sqlite3ExprDup(tls, db1, pX, 0) + if (*Tsqlite3)(unsafe.Pointer(db1)).FmallocFailed != 0 { + _sqlite3ExprDelete(tls, db1, pDel) + break + } + _sqlite3ExprToRegister(tls, pDel, _exprCodeVector(tls, pParse, pDel, bp)) + libc.Xmemset(tls, bp+88, 0, uint64(72)) + (**(**TExpr)(__ccgo_up(bp + 88))).Fop = uint8(TK_EQ) + (**(**TExpr)(__ccgo_up(bp + 88))).FpLeft = pDel + pTest = bp + 88 + /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001: + ** The value in regFree1 might get SCopy-ed into the file result. + ** So make sure that the regFree1 register is not reused for other + ** purposes and possibly overwritten. */ + **(**int32)(__ccgo_up(bp)) = 0 + } + i1 = 0 + for { + if !(i1 < nExpr-int32(1)) { + break + } + if pX != 0 { + (**(**TExpr)(__ccgo_up(bp + 88))).FpRight = (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1)*32))).FpExpr + } else { + pTest = (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1)*32))).FpExpr + } + nextCase = _sqlite3VdbeMakeLabel(tls, pParse) + _sqlite3ExprIfFalse(tls, pParse, pTest, nextCase, int32(SQLITE_JUMPIFNULL)) + _sqlite3ExprCode(tls, pParse, (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1+int32(1))*32))).FpExpr, target) + _sqlite3VdbeGoto(tls, v, endLabel) + _sqlite3VdbeResolveLabel(tls, v, nextCase) + goto _13 + _13: + ; + i1 = i1 + int32(2) + } + if nExpr&int32(1) != 0 { + _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(nExpr-int32(1))*32))).FpExpr, target) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) + } + _sqlite3ExprDelete(tls, db1, pDel) + _setDoNotMergeFlagOnCopy(tls, v) + _sqlite3VdbeResolveLabel(tls, v, endLabel) + case int32(TK_RAISE): + if !((*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0) && !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8564, 0) + return 0 + } + if int32((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(OE_Abort) { + _sqlite3MayAbort(tls, pParse) + } + if int32((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(OE_Ignore) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), SQLITE_OK, int32(OE_Ignore)) + } else { + **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) + if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { + v1 = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(7)<, ... FROM
    +// ** +// ** If the RHS of the IN operator is a list or a more complex subquery, then +// ** an ephemeral table might need to be generated from the RHS and then +// ** pX->iTable made to point to the ephemeral table instead of an +// ** existing table. In this case, the creation and initialization of the +// ** ephemeral table might be put inside of a subroutine, the EP_Subrtn flag +// ** will be set on pX and the pX->y.sub fields will be set to show where +// ** the subroutine is coded. +// ** +// ** The inFlags parameter must contain, at a minimum, one of the bits +// ** IN_INDEX_MEMBERSHIP or IN_INDEX_LOOP but not both. If inFlags contains +// ** IN_INDEX_MEMBERSHIP, then the generated table will be used for a fast +// ** membership test. When the IN_INDEX_LOOP bit is set, the IN index will +// ** be used to loop over all values of the RHS of the IN operator. +// ** +// ** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate +// ** through the set members) then the b-tree must not contain duplicates. +// ** An ephemeral table will be created unless the selected columns are guaranteed +// ** to be unique - either because it is an INTEGER PRIMARY KEY or due to +// ** a UNIQUE constraint or index. +// ** +// ** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used +// ** for fast set membership tests) then an ephemeral table must +// ** be used unless is a single INTEGER PRIMARY KEY column or an +// ** index can be found with the specified as its left-most. +// ** +// ** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and +// ** if the RHS of the IN operator is a list (not a subquery) then this +// ** routine might decide that creating an ephemeral b-tree for membership +// ** testing is too expensive and return IN_INDEX_NOOP. In that case, the +// ** calling routine should implement the IN operator using a sequence +// ** of Eq or Ne comparison operations. +// ** +// ** When the b-tree is being used for membership tests, the calling function +// ** might need to know whether or not the RHS side of the IN operator +// ** contains a NULL. If prRhsHasNull is not a NULL pointer and +// ** if there is any chance that the (...) might contain a NULL value at +// ** runtime, then a register is allocated and the register number written +// ** to *prRhsHasNull. If there is no chance that the (...) contains a +// ** NULL value, then *prRhsHasNull is left unchanged. +// ** +// ** If a register is allocated and its location stored in *prRhsHasNull, then +// ** the value in that register will be NULL if the b-tree contains one or more +// ** NULL values, and it will be some non-NULL value if the b-tree contains no +// ** NULL values. +// ** +// ** If the aiMap parameter is not NULL, it must point to an array containing +// ** one element for each column returned by the SELECT statement on the RHS +// ** of the IN(...) operator. The i'th entry of the array is populated with the +// ** offset of the index column that matches the i'th column returned by the +// ** SELECT. For example, if the expression and selected index are: +// ** +// ** (?,?,?) IN (SELECT a, b, c FROM t1) +// ** CREATE INDEX i1 ON t1(b, c, a); +// ** +// ** then aiMap[] is populated with {2, 0, 1}. +// */ +func _sqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags Tu32, prRhsHasNull uintptr, aiMap uintptr, piTab uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var affinity_ok, bloomOk, eType, i, i1, i2, iAddr, iAddr1, iCol, iDb, iTab, j, mustBeUnique, n, nExpr, rMayHaveNull, v1, v10 int32 + var cmpaff, idxaff int8 + var colUsed, mCol TBitmask + var db, p, pEList, pEList1, pIdx, pLhs, pLhs1, pReq, pRhs, pTab, v, v2 uintptr + var savedNQueryLoop Tu32 + var v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = affinity_ok, bloomOk, cmpaff, colUsed, db, eType, i, i1, i2, iAddr, iAddr1, iCol, iDb, iTab, idxaff, j, mCol, mustBeUnique, n, nExpr, p, pEList, pEList1, pIdx, pLhs, pLhs1, pReq, pRhs, pTab, rMayHaveNull, savedNQueryLoop, v, v1, v10, v2, v5 /* SELECT to the right of IN operator */ + eType = 0 /* True if RHS must be unique */ + v = _sqlite3GetVdbe(tls, pParse) /* Virtual machine being coded */ + mustBeUnique = libc.BoolInt32(inFlags&uint32(IN_INDEX_LOOP) != uint32(0)) + v2 = pParse + 56 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + iTab = v1 + /* If the RHS of this IN(...) operator is a SELECT, and if it matters + ** whether or not the SELECT result contains NULL values, check whether + ** or not NULL is actually possible (it may not be, for example, due + ** to NOT NULL constraints in the schema). If no NULL values are possible, + ** set prRhsHasNull to 0 before continuing. */ + if prRhsHasNull != 0 && (*TExpr)(unsafe.Pointer(pX)).Fflags&uint32(EP_xIsSelect) != uint32(0) { + pEList = (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32)))).FpEList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { + break + } + if _sqlite3ExprCanBeNull(tls, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FpExpr) != 0 { + break + } + goto _3 + _3: + ; + i = i + 1 + } + if i == (*TExprList)(unsafe.Pointer(pEList)).FnExpr { + prRhsHasNull = uintptr(0) + } + } + /* Check to see if an existing table or index can be used to + ** satisfy the query. This is preferable to generating a new + ** ephemeral table. */ + if v5 = (*TParse)(unsafe.Pointer(pParse)).FnErr == 0; v5 { + v2 = _isCandidateForInOpt(tls, pX) + p = v2 + } + if v5 && v2 != uintptr(0) { + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Database idx for pTab */ + pEList1 = (*TSelect)(unsafe.Pointer(p)).FpEList + nExpr = (*TExprList)(unsafe.Pointer(pEList1)).FnExpr + /* Because of isCandidateForInOpt(p) */ + /* Because of isCandidateForInOpt(p) */ + /* Because of isCandidateForInOpt(p) */ + pTab = (*(*TSrcItem)(unsafe.Pointer((*TSelect)(unsafe.Pointer(p)).FpSrc + 8))).FpSTab + /* Code an OP_Transaction and OP_TableLock for
    . */ + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab)).FzName) + /* sqlite3GetVdbe() has always been previously called */ + if nExpr == int32(1) && int32((*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList1 + 8))).FpExpr)).FiColumn) < 0 { + /* The "x IN (SELECT rowid FROM table)" case */ + iAddr = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) + _sqlite3OpenTable(tls, pParse, iTab, iDb, pTab, int32(OP_OpenRead)) + eType = int32(IN_INDEX_ROWID) + _sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+8207, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName)) + _sqlite3VdbeJumpHere(tls, v, iAddr) + } else { /* Iterator variable */ + affinity_ok = int32(1) + /* Check that the affinity that will be used to perform each + ** comparison is the same as the affinity of each column in table + ** on the RHS of the IN operator. If it not, it is not possible to + ** use any index of the RHS table. */ + i1 = 0 + for { + if !(i1 < nExpr && affinity_ok != 0) { + break + } + pLhs = _sqlite3VectorFieldSubexpr(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft, i1) + iCol = int32((*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pEList1 + 8 + uintptr(i1)*32))).FpExpr)).FiColumn) + idxaff = _sqlite3TableColumnAffinity(tls, pTab, iCol) /* RHS table */ + cmpaff = _sqlite3CompareAffinity(tls, pLhs, idxaff) + switch int32(cmpaff) { + case int32(SQLITE_AFF_BLOB): + case int32(SQLITE_AFF_TEXT): + /* sqlite3CompareAffinity() only returns TEXT if one side or the + ** other has no affinity and the other side is TEXT. Hence, + ** the only way for cmpaff to be TEXT is for idxaff to be TEXT + ** and for the term on the LHS of the IN to have no affinity. */ + default: + affinity_ok = libc.BoolInt32(int32(idxaff) >= int32(SQLITE_AFF_NUMERIC)) + } + goto _6 + _6: + ; + i1 = i1 + 1 + } + if affinity_ok != 0 { + /* Search for an existing index that will work for this IN operator */ + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0 && eType == 0) { + break + } /* Mask for the current column */ + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) < nExpr { + goto _7 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) { + goto _7 + } + /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute + ** BITMASK(nExpr) without overflowing */ + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { + goto _7 + } + if mustBeUnique != 0 { + if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) > nExpr || libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) > nExpr && !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromInt32(OE_None)) { + goto _7 /* This index is not unique over the IN RHS columns */ + } + } + colUsed = uint64(0) /* Columns of index used so far */ + i1 = 0 + for { + if !(i1 < nExpr) { + break + } + pLhs1 = _sqlite3VectorFieldSubexpr(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft, i1) + pRhs = (*(*TExprList_item)(unsafe.Pointer(pEList1 + 8 + uintptr(i1)*32))).FpExpr + pReq = _sqlite3BinaryCompareCollSeq(tls, pParse, pLhs1, pRhs) + j = 0 + for { + if !(j < nExpr) { + break + } + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) != int32((*TExpr)(unsafe.Pointer(pRhs)).FiColumn) { + goto _9 + } + if pReq != uintptr(0) && _sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pReq)).FzName, **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8))) != 0 { + goto _9 + } + break + goto _9 + _9: + ; + j = j + 1 + } + if j == nExpr { + break + } + mCol = libc.Uint64FromInt32(1) << j + if mCol&colUsed != 0 { + break + } /* Each column used only once */ + colUsed = colUsed | mCol + if aiMap != 0 { + **(**int32)(__ccgo_up(aiMap + uintptr(i1)*4)) = j + } + goto _8 + _8: + ; + i1 = i1 + 1 + } + if colUsed == libc.Uint64FromInt32(1)<0 round to min(iRound,mxRound) significant digits total. +// ** +// ** mxRound must be positive. +// ** +// ** The significant digits of the decimal representation are +// ** stored in p->z[] which is a often (but not always) a pointer +// ** into the middle of p->zBuf[]. There are p->n significant digits. +// ** The p->z[] array is *not* zero-terminated. +// */ +func _sqlite3FpDecode(tls *libc.TLS, p uintptr, _r float64, iRound int32, mxRound int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + *(*float64)(unsafe.Pointer(bp)) = _r + var e, i, j, jj, jj1, kk, kk1, kk2, n, nn, v1 int32 + var v2, v21 Tu64 + var z, zBuf uintptr + var _ /* exp at bp+16 */ int32 + var _ /* v at bp+8 */ Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = e, i, j, jj, jj1, kk, kk1, kk2, n, nn, v2, v21, z, zBuf, v1 + **(**int32)(__ccgo_up(bp + 16)) = 0 /* Local alias for p->z */ + (*TFpDecode)(unsafe.Pointer(p)).FisSpecial = 0 + /* Convert negative numbers to positive. Deal with Infinity, 0.0, and + ** NaN. */ + if **(**float64)(__ccgo_up(bp)) < float64(0) { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = int8('-') + **(**float64)(__ccgo_up(bp)) = -**(**float64)(__ccgo_up(bp)) + } else { + if **(**float64)(__ccgo_up(bp)) == float64(0) { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = int8('+') + (*TFpDecode)(unsafe.Pointer(p)).Fn = int32(1) + (*TFpDecode)(unsafe.Pointer(p)).FiDP = int32(1) + (*TFpDecode)(unsafe.Pointer(p)).Fz = __ccgo_ts + 1850 + return + } else { + (*TFpDecode)(unsafe.Pointer(p)).Fsign = int8('+') + } + } + libc.Xmemcpy(tls, bp+8, bp, uint64(8)) + e = libc.Int32FromUint64(**(**Tu64)(__ccgo_up(bp + 8)) >> libc.Int32FromInt32(52) & uint64(0x7ff)) + if e == int32(0x7ff) { + (*TFpDecode)(unsafe.Pointer(p)).FisSpecial = int8(int32(1) + libc.BoolInt32(**(**Tu64)(__ccgo_up(bp + 8)) != uint64(0x7ff0000000000000))) + (*TFpDecode)(unsafe.Pointer(p)).Fn = 0 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = 0 + (*TFpDecode)(unsafe.Pointer(p)).Fz = p + 16 + return + } + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) & uint64(0x000fffffffffffff) + if e == 0 { + nn = _countLeadingZeros(tls, **(**Tu64)(__ccgo_up(bp + 8))) + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) << libc.Uint64FromInt32(nn) + e = -int32(1074) - nn + } else { + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8))<= int32(18) { + v1 = int32(18) + } else { + v1 = iRound + int32(1) + } + _sqlite3Fp2Convert10(tls, **(**Tu64)(__ccgo_up(bp + 8)), e, v1, bp+8, bp+16) + /* Extract significant digits, start at the right-most slot in p->zBuf + ** and working back to the right. "i" keeps track of the next slot in + ** which to store a digit. */ + zBuf = p + 16 + i = int32(SQLITE_U64_DIGITS) + for **(**Tu64)(__ccgo_up(bp + 8)) >= uint64(10) { + kk = libc.Int32FromUint64(**(**Tu64)(__ccgo_up(bp + 8)) % uint64(100) * uint64(2)) + **(**Tu16)(__ccgo_up(zBuf + uintptr(i-int32(2)))) = **(**Tu16)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3DigitPairs)) + uintptr(kk))) + i = i - int32(2) + **(**Tu64)(__ccgo_up(bp + 8)) = **(**Tu64)(__ccgo_up(bp + 8)) / uint64(100) + } + if **(**Tu64)(__ccgo_up(bp + 8)) != 0 { + i = i - 1 + v1 = i + **(**int8)(__ccgo_up(zBuf + uintptr(v1))) = libc.Int8FromUint64(**(**Tu64)(__ccgo_up(bp + 8)) + uint64('0')) + } + n = int32(SQLITE_U64_DIGITS) - i /* Total number of digits extracted */ + (*TFpDecode)(unsafe.Pointer(p)).FiDP = n + **(**int32)(__ccgo_up(bp + 16)) + if iRound <= 0 { + iRound = (*TFpDecode)(unsafe.Pointer(p)).FiDP - iRound + if iRound == 0 && int32(**(**int8)(__ccgo_up(zBuf + uintptr(i)))) >= int32('5') { + iRound = int32(1) + i = i - 1 + v1 = i + **(**int8)(__ccgo_up(zBuf + uintptr(v1))) = int8('0') + n = n + 1 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = (*TFpDecode)(unsafe.Pointer(p)).FiDP + 1 + } + } + z = zBuf + uintptr(i) /* z points to the first digit */ + if iRound > 0 && (iRound < n || n > mxRound) { + if iRound > mxRound { + iRound = mxRound + } + if iRound == int32(17) { + /* If the precision is exactly 17, which only happens with the "!" + ** flag (ex: "%!.17g") then try to reduce the precision if that + ** yields text that will round-trip to the original floating-point. + ** value. Thus, for exaple, 49.47 will render as 49.47, rather than + ** as 49.469999999999999. */ + if int32(**(**int8)(__ccgo_up(z + 15))) == int32('9') && int32(**(**int8)(__ccgo_up(z + 14))) == int32('9') { + jj = int32(14) + for { + if !(jj > 0 && int32(**(**int8)(__ccgo_up(z + uintptr(jj-int32(1))))) == int32('9')) { + break + } + goto _4 + _4: + ; + jj = jj - 1 + } + if jj == 0 { + v2 = uint64(1) + } else { + v2 = libc.Uint64FromInt32(int32(**(**int8)(__ccgo_up(z))) - int32('0')) + kk1 = int32(1) + for { + if !(kk1 < jj) { + break + } + v2 = v2*uint64(10) + libc.Uint64FromInt8(**(**int8)(__ccgo_up(z + uintptr(kk1)))) - uint64('0') + goto _5 + _5: + ; + kk1 = kk1 + 1 + } + v2 = v2 + 1 + } + if **(**float64)(__ccgo_up(bp)) == _sqlite3Fp10Convert2(tls, v2, **(**int32)(__ccgo_up(bp + 16))+n-jj) { + iRound = jj + int32(1) + } + } else { + if (*TFpDecode)(unsafe.Pointer(p)).FiDP >= n || int32(**(**int8)(__ccgo_up(z + 15))) == int32('0') && int32(**(**int8)(__ccgo_up(z + 14))) == int32('0') && int32(**(**int8)(__ccgo_up(z + 13))) == int32('0') { + jj1 = int32(13) + for { + if !(int32(**(**int8)(__ccgo_up(z + uintptr(jj1-int32(1))))) == int32('0')) { + break + } + goto _6 + _6: + ; + jj1 = jj1 - 1 + } + v21 = libc.Uint64FromInt32(int32(**(**int8)(__ccgo_up(z))) - int32('0')) + kk2 = int32(1) + for { + if !(kk2 < jj1) { + break + } + v21 = v21*uint64(10) + libc.Uint64FromInt8(**(**int8)(__ccgo_up(z + uintptr(kk2)))) - uint64('0') + goto _7 + _7: + ; + kk2 = kk2 + 1 + } + if **(**float64)(__ccgo_up(bp)) == _sqlite3Fp10Convert2(tls, v21, **(**int32)(__ccgo_up(bp + 16))+n-jj1) { + iRound = jj1 + int32(1) + } + } + } + } + n = iRound + if int32(**(**int8)(__ccgo_up(z + uintptr(iRound)))) >= int32('5') { + j = iRound - int32(1) + for int32(1) != 0 { + **(**int8)(__ccgo_up(z + uintptr(j))) = **(**int8)(__ccgo_up(z + uintptr(j))) + 1 + if int32(**(**int8)(__ccgo_up(z + uintptr(j)))) <= int32('9') { + break + } + **(**int8)(__ccgo_up(z + uintptr(j))) = int8('0') + if j == 0 { + z = z - 1 + **(**int8)(__ccgo_up(z)) = int8('1') + n = n + 1 + (*TFpDecode)(unsafe.Pointer(p)).FiDP = (*TFpDecode)(unsafe.Pointer(p)).FiDP + 1 + break + } else { + j = j - 1 + } + } + } + } + for int32(**(**int8)(__ccgo_up(z + uintptr(n-int32(1))))) == int32('0') { + n = n - 1 + } + (*TFpDecode)(unsafe.Pointer(p)).Fn = n + (*TFpDecode)(unsafe.Pointer(p)).Fz = z +} + +// C documentation +// +// /* +// ** Arguments nArg/azArg contain the string arguments passed to the xCreate +// ** or xConnect method of the virtual table. This function attempts to +// ** allocate an instance of Fts5Config containing the results of parsing +// ** those arguments. +// ** +// ** If successful, SQLITE_OK is returned and *ppOut is set to point to the +// ** new Fts5Config object. If an error occurs, an SQLite error code is +// ** returned, *ppOut is set to NULL and an error message may be left in +// ** *pzErr. It is the responsibility of the caller to eventually free any +// ** such error message using sqlite3_free(). +// */ +func _sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int32, azArg uintptr, ppOut uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var bOption, i int32 + var nByte Tsqlite3_int64 + var pRet, z, zOrig, zTail, v1, v2 uintptr + var _ /* bDummy at bp+28 */ int32 + var _ /* bMustBeCol at bp+24 */ int32 + var _ /* bUnindexed at bp+4 */ int32 + var _ /* rc at bp+0 */ int32 + var _ /* zOne at bp+8 */ uintptr + var _ /* zTwo at bp+16 */ uintptr + _, _, _, _, _, _, _, _, _ = bOption, i, nByte, pRet, z, zOrig, zTail, v1, v2 + **(**int32)(__ccgo_up(bp)) = SQLITE_OK + **(**int32)(__ccgo_up(bp + 4)) = 0 /* True if there are one or more UNINDEXED */ + v1 = Xsqlite3_malloc64(tls, uint64(256)) + pRet = v1 + **(**uintptr)(__ccgo_up(ppOut)) = v1 + if pRet == uintptr(0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, pRet, 0, uint64(256)) + (*TFts5Config)(unsafe.Pointer(pRet)).FpGlobal = pGlobal + (*TFts5Config)(unsafe.Pointer(pRet)).Fdb = db + (*TFts5Config)(unsafe.Pointer(pRet)).FiCookie = -int32(1) + nByte = libc.Int64FromUint64(libc.Uint64FromInt32(nArg) * (libc.Uint64FromInt64(8) + libc.Uint64FromInt64(1))) + (*TFts5Config)(unsafe.Pointer(pRet)).FazCol = _sqlite3Fts5MallocZero(tls, bp, nByte) + if (*TFts5Config)(unsafe.Pointer(pRet)).FazCol != 0 { + v1 = (*TFts5Config)(unsafe.Pointer(pRet)).FazCol + uintptr(nArg)*8 + } else { + v1 = uintptr(0) + } + (*TFts5Config)(unsafe.Pointer(pRet)).FabUnindexed = v1 + (*TFts5Config)(unsafe.Pointer(pRet)).FzDb = _sqlite3Fts5Strndup(tls, bp, **(**uintptr)(__ccgo_up(azArg + 1*8)), -int32(1)) + (*TFts5Config)(unsafe.Pointer(pRet)).FzName = _sqlite3Fts5Strndup(tls, bp, **(**uintptr)(__ccgo_up(azArg + 2*8)), -int32(1)) + (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize = int32(1) + (*TFts5Config)(unsafe.Pointer(pRet)).FeDetail = FTS5_DETAIL_FULL + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && Xsqlite3_stricmp(tls, (*TFts5Config)(unsafe.Pointer(pRet)).FzName, __ccgo_ts+37899) == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38010, libc.VaList(bp+40, (*TFts5Config)(unsafe.Pointer(pRet)).FzName)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + i = int32(3) + for { + if !(**(**int32)(__ccgo_up(bp)) == SQLITE_OK && i < nArg) { + break + } + zOrig = **(**uintptr)(__ccgo_up(azArg + uintptr(i)*8)) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + bOption = 0 + **(**int32)(__ccgo_up(bp + 24)) = 0 + z = _fts5ConfigGobbleWord(tls, bp, zOrig, bp+8, bp+24) + z = _fts5ConfigSkipWhitespace(tls, z) + if z != 0 && int32(**(**int8)(__ccgo_up(z))) == int32('=') { + bOption = int32(1) + z = z + 1 + if **(**int32)(__ccgo_up(bp + 24)) != 0 { + z = uintptr(0) + } + } + z = _fts5ConfigSkipWhitespace(tls, z) + if z != 0 && **(**int8)(__ccgo_up(z)) != 0 { + z = _fts5ConfigGobbleWord(tls, bp, z, bp+16, bp+28) + if z != 0 && **(**int8)(__ccgo_up(z)) != 0 { + z = uintptr(0) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + if z == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38039, libc.VaList(bp+40, zOrig)) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } else { + if bOption != 0 { + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v1 = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + v1 = __ccgo_ts + 1704 + } + if **(**uintptr)(__ccgo_up(bp + 16)) != 0 { + v2 = **(**uintptr)(__ccgo_up(bp + 16)) + } else { + v2 = __ccgo_ts + 1704 + } + **(**int32)(__ccgo_up(bp)) = _fts5ConfigParseSpecial(tls, pRet, v1, v2, pzErr) + } else { + **(**int32)(__ccgo_up(bp)) = _fts5ConfigParseColumn(tls, pRet, **(**uintptr)(__ccgo_up(bp + 8)), **(**uintptr)(__ccgo_up(bp + 16)), pzErr, bp+4) + **(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0) + } + } + } + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 8))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 16))) + goto _3 + _3: + ; + i = i + 1 + } + /* We only allow contentless_delete=1 if the table is indeed contentless. */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessDelete != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FeContent != int32(FTS5_CONTENT_NONE) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38059, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* We only allow contentless_delete=1 if columnsize=0 is not present. + ** + ** This restriction may be removed at some point. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessDelete != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize == 0 { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38109, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* We only allow contentless_unindexed=1 if the table is actually a + ** contentless one. + */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessUnindexed != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FeContent != int32(FTS5_CONTENT_NONE) { + **(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+38164, 0) + **(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR) + } + /* If no zContent option was specified, fill in the default values. */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FzContent == uintptr(0) { + zTail = uintptr(0) + if (*TFts5Config)(unsafe.Pointer(pRet)).FeContent == FTS5_CONTENT_NORMAL { + zTail = __ccgo_ts + 37522 + } else { + if **(**int32)(__ccgo_up(bp + 4)) != 0 && (*TFts5Config)(unsafe.Pointer(pRet)).FbContentlessUnindexed != 0 { + (*TFts5Config)(unsafe.Pointer(pRet)).FeContent = int32(FTS5_CONTENT_UNINDEXED) + zTail = __ccgo_ts + 37522 + } else { + if (*TFts5Config)(unsafe.Pointer(pRet)).FbColumnsize != 0 { + zTail = __ccgo_ts + 38217 + } + } + } + if zTail != 0 { + (*TFts5Config)(unsafe.Pointer(pRet)).FzContent = _sqlite3Fts5Mprintf(tls, bp, __ccgo_ts+38225, libc.VaList(bp+40, (*TFts5Config)(unsafe.Pointer(pRet)).FzDb, (*TFts5Config)(unsafe.Pointer(pRet)).FzName, zTail)) + } + } + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pRet)).FzContentRowid == uintptr(0) { + (*TFts5Config)(unsafe.Pointer(pRet)).FzContentRowid = _sqlite3Fts5Strndup(tls, bp, __ccgo_ts+17963, -int32(1)) + } + /* Formulate the zContentExprlist text */ + if **(**int32)(__ccgo_up(bp)) == SQLITE_OK { + **(**int32)(__ccgo_up(bp)) = _fts5ConfigMakeExprlist(tls, pRet) + } + if **(**int32)(__ccgo_up(bp)) != SQLITE_OK { + _sqlite3Fts5ConfigFree(tls, pRet) + **(**uintptr)(__ccgo_up(ppOut)) = uintptr(0) + } + return **(**int32)(__ccgo_up(bp)) +} + +// C documentation +// +// /* +// ** This is the callback routine for the code that initializes the +// ** database. See sqlite3Init() below for additional information. +// ** This routine is also called from the OP_ParseSchema opcode of the VDBE. +// ** +// ** Each callback contains the following information: +// ** +// ** argv[0] = type of object: "table", "index", "trigger", or "view". +// ** argv[1] = name of thing being created +// ** argv[2] = associated table if an index or trigger +// ** argv[3] = root page number for table or index. 0 for trigger or view. +// ** argv[4] = SQL text for the CREATE statement. +// ** +// */ +func _sqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr, NotUsed uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pData, pIndex uintptr + var iDb, rc int32 + var saved_iDb Tu8 + var _ /* pStmt at bp+0 */ uintptr + _, _, _, _, _, _ = db, iDb, pData, pIndex, rc, saved_iDb + pData = pInit + db = (*TInitData)(unsafe.Pointer(pData)).Fdb + iDb = (*TInitData)(unsafe.Pointer(pData)).FiDb + _ = NotUsed + _ = argc + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_EncodingFixed) + if argv == uintptr(0) { + return 0 + } /* Might happen if EMPTY_RESULT_CALLBACKS are on */ + (*TInitData)(unsafe.Pointer(pData)).FnInitRow = (*TInitData)(unsafe.Pointer(pData)).FnInitRow + 1 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _corruptSchema(tls, pData, argv, uintptr(0)) + return int32(1) + } + if **(**uintptr)(__ccgo_up(argv + 3*8)) == uintptr(0) { + _corruptSchema(tls, pData, argv, uintptr(0)) + } else { + if **(**uintptr)(__ccgo_up(argv + 4*8)) != 0 && int32('c') == libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8)))))]) && int32('r') == libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8)) + 1)))]) { + saved_iDb = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb + /* Return code from sqlite3_prepare() */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(iDb) + if _sqlite3GetUInt32(tls, **(**uintptr)(__ccgo_up(argv + 3*8)), db+192) == 0 || (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum > (*TInitData)(unsafe.Pointer(pData)).FmxPage && (*TInitData)(unsafe.Pointer(pData)).FmxPage > uint32(0) { + if _sqlite3Config.FbExtraSchemaChecks != 0 { + _corruptSchema(tls, pData, argv, __ccgo_ts+15740) + } + } + libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(0), 0, 0x1) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = argv + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + _sqlite3Prepare(tls, db, **(**uintptr)(__ccgo_up(argv + 4*8)), -int32(1), uint32(0), uintptr(0), bp, uintptr(0)) + rc = (*Tsqlite3)(unsafe.Pointer(db)).FerrCode + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = saved_iDb + /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */ + if SQLITE_OK != rc { + if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x1>>0)) != 0 { + } else { + if rc > (*TInitData)(unsafe.Pointer(pData)).Frc { + (*TInitData)(unsafe.Pointer(pData)).Frc = rc + } + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } else { + if rc != int32(SQLITE_INTERRUPT) && rc&int32(0xFF) != int32(SQLITE_LOCKED) { + _corruptSchema(tls, pData, argv, Xsqlite3_errmsg(tls, db)) + } + } + } + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = uintptr(unsafe.Pointer(&_sqlite3StdType)) /* Any array of string ptrs will do */ + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) + } else { + if **(**uintptr)(__ccgo_up(argv + 1*8)) == uintptr(0) || **(**uintptr)(__ccgo_up(argv + 4*8)) != uintptr(0) && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8))))) != 0 { + _corruptSchema(tls, pData, argv, uintptr(0)) + } else { + pIndex = _sqlite3FindIndex(tls, db, **(**uintptr)(__ccgo_up(argv + 1*8)), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) + if pIndex == uintptr(0) { + _corruptSchema(tls, pData, argv, __ccgo_ts+20090) + } else { + if _sqlite3GetUInt32(tls, **(**uintptr)(__ccgo_up(argv + 3*8)), pIndex+88) == 0 || (*TIndex)(unsafe.Pointer(pIndex)).Ftnum < uint32(2) || (*TIndex)(unsafe.Pointer(pIndex)).Ftnum > (*TInitData)(unsafe.Pointer(pData)).FmxPage || _sqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 { + if _sqlite3Config.FbExtraSchemaChecks != 0 { + _corruptSchema(tls, pData, argv, __ccgo_ts+15740) + } + } + } + } + } + } + return 0 +} + +// C documentation +// +// /* +// ** Attempt to load an SQLite extension library contained in the file +// ** zFile. The entry point is zProc. zProc may be 0 in which case a +// ** default entry point name (sqlite3_extension_init) is used. Use +// ** of the default name is recommended. +// ** +// ** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong. +// ** +// ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with +// ** error message text. The calling function should free this memory +// ** by calling sqlite3DbFree(db, ). +// */ +func _sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aHandle, handle, pVfs, zAltEntry, zAltFile, zEntry, v1 uintptr + var c, cnt, iEntry, iFile, ii, ncFile, rc, v3, v8 int32 + var nMsg Tu64 + var xInit Tsqlite3_loadext_entry + var v4 bool + var _ /* zErrmsg at bp+0 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aHandle, c, cnt, handle, iEntry, iFile, ii, nMsg, ncFile, pVfs, rc, xInit, zAltEntry, zAltFile, zEntry, v1, v3, v4, v8 + pVfs = (*Tsqlite3)(unsafe.Pointer(db)).FpVfs + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + zAltEntry = uintptr(0) + nMsg = uint64(libc.Xstrlen(tls, zFile)) + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = uintptr(0) + } + /* Ticket #1863. To avoid a creating security problems for older + ** applications that relink against newer versions of SQLite, the + ** ability to run load_extension is turned off by default. One + ** must call either sqlite3_enable_load_extension(db) or + ** sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0) + ** to turn on extension loading. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LoadExtension) == uint64(0) { + if pzErrMsg != 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+13671, 0) + } + return int32(SQLITE_ERROR) + } + if zProc != 0 { + v1 = zProc + } else { + v1 = __ccgo_ts + 17587 + } + zEntry = v1 + /* tag-20210611-1. Some dlopen() implementations will segfault if given + ** an oversize filename. Most filesystems have a pathname limit of 4K, + ** so limit the extension filename length to about twice that. + ** https://sqlite.org/forum/forumpost/08a0d6d9bf + ** + ** Later (2023-03-25): Save an extra 6 bytes for the filename suffix. + ** See https://sqlite.org/forum/forumpost/24083b579d. + */ + if nMsg > uint64(FILENAME_MAX) { + goto extension_not_found + } + /* Do not allow sqlite3_load_extension() to link to a copy of the + ** running application, by passing in an empty filename. */ + if nMsg == uint64(0) { + goto extension_not_found + } + handle = _sqlite3OsDlOpen(tls, pVfs, zFile) + ii = 0 + for { + if !(ii < libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(8)) && handle == uintptr(0)) { + break + } + zAltFile = Xsqlite3_mprintf(tls, __ccgo_ts+13632, libc.VaList(bp+16, zFile, _azEndings[ii])) + if zAltFile == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if nMsg+uint64(libc.Xstrlen(tls, _azEndings[ii]))+uint64(1) <= uint64(FILENAME_MAX) { + handle = _sqlite3OsDlOpen(tls, pVfs, zAltFile) + } + Xsqlite3_free(tls, zAltFile) + goto _2 + _2: + ; + ii = ii + 1 + } + if handle == uintptr(0) { + goto extension_not_found + } + xInit = _sqlite3OsDlSym(tls, pVfs, handle, zEntry) + /* If no entry point was specified and the default legacy + ** entry point name "sqlite3_extension_init" was not found, then + ** construct an entry point name "sqlite3_X_init" where the X is + ** replaced by the lowercase value of every ASCII alphabetic + ** character in the filename after the last "/" up to the first ".", + ** and skipping the first three characters if they are "lib". + ** Examples: + ** + ** /usr/local/lib/libExample5.4.3.so ==> sqlite3_example_init + ** C:/lib/mathfuncs.dll ==> sqlite3_mathfuncs_init + ** + ** If that still finds no entry point, repeat a second time but this + ** time include both alphabetic and numeric characters up to the first + ** ".". Example: + ** + ** /usr/local/lib/libExample5.4.3.so ==> sqlite3_example5_init + */ + if xInit == uintptr(0) && zProc == uintptr(0) { + ncFile = _sqlite3Strlen30(tls, zFile) + cnt = 0 + zAltEntry = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(ncFile+int32(30))) + if zAltEntry == uintptr(0) { + _sqlite3OsDlClose(tls, pVfs, handle) + return int32(SQLITE_NOMEM) + } + for { + libc.Xmemcpy(tls, zAltEntry, __ccgo_ts+17610, uint64(8)) + iFile = ncFile - int32(1) + for { + if !(iFile >= 0 && !(int32(**(**int8)(__ccgo_up(zFile + uintptr(iFile)))) == libc.Int32FromUint8('/'))) { + break + } + goto _6 + _6: + ; + iFile = iFile - 1 + } + iFile = iFile + 1 + if Xsqlite3_strnicmp(tls, zFile+uintptr(iFile), __ccgo_ts+17619, int32(3)) == 0 { + iFile = iFile + int32(3) + } + iEntry = int32(8) + for { + v3 = int32(**(**int8)(__ccgo_up(zFile + uintptr(iFile)))) + c = v3 + if !(v3 != 0 && c != int32('.')) { + break + } + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt32(c)])&int32(0x02) != 0 || cnt != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt32(c)])&int32(0x04) != 0 { + v8 = iEntry + iEntry = iEntry + 1 + **(**int8)(__ccgo_up(zAltEntry + uintptr(v8))) = libc.Int8FromUint8(_sqlite3UpperToLower[libc.Uint32FromInt32(c)]) + } + goto _7 + _7: + ; + iFile = iFile + 1 + } + libc.Xmemcpy(tls, zAltEntry+uintptr(iEntry), __ccgo_ts+17623, uint64(6)) + zEntry = zAltEntry + xInit = _sqlite3OsDlSym(tls, pVfs, handle, zEntry) + goto _5 + _5: + ; + if v4 = xInit == uintptr(0); v4 { + cnt = cnt + 1 + v3 = cnt + } + if !(v4 && v3 < int32(2)) { + break + } + } + } + if xInit == uintptr(0) { + if pzErrMsg != 0 { + nMsg = nMsg + uint64(libc.Xstrlen(tls, zEntry)+uint64(300)) + v1 = Xsqlite3_malloc64(tls, nMsg) + **(**uintptr)(__ccgo_up(bp)) = v1 + **(**uintptr)(__ccgo_up(pzErrMsg)) = v1 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + /* zErrmsg would be NULL if not so */ + Xsqlite3_snprintf(tls, libc.Int32FromUint64(nMsg), **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+17629, libc.VaList(bp+16, zEntry, zFile)) + _sqlite3OsDlError(tls, pVfs, libc.Int32FromUint64(nMsg-uint64(1)), **(**uintptr)(__ccgo_up(bp))) + } + } + _sqlite3OsDlClose(tls, pVfs, handle) + Xsqlite3_free(tls, zAltEntry) + return int32(SQLITE_ERROR) + } + Xsqlite3_free(tls, zAltEntry) + rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xInit})))(tls, db, bp, uintptr(unsafe.Pointer(&_sqlite3Apis))) + if rc != 0 { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(1)<aExtension array. */ + aHandle = _sqlite3DbMallocZero(tls, db, uint64(uint64(8)*libc.Uint64FromInt32((*Tsqlite3)(unsafe.Pointer(db)).FnExtension+libc.Int32FromInt32(1)))) + if aHandle == uintptr(0) { + return int32(SQLITE_NOMEM) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FnExtension > 0 { + libc.Xmemcpy(tls, aHandle, (*Tsqlite3)(unsafe.Pointer(db)).FaExtension, uint64(8)*libc.Uint64FromInt32((*Tsqlite3)(unsafe.Pointer(db)).FnExtension)) + } + _sqlite3DbFree(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FaExtension) + (*Tsqlite3)(unsafe.Pointer(db)).FaExtension = aHandle + v1 = db + 236 + v3 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + **(**uintptr)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaExtension + uintptr(v3)*8)) = handle + return SQLITE_OK + goto extension_not_found +extension_not_found: + ; + if pzErrMsg != 0 { + nMsg = nMsg + uint64(300) + v1 = Xsqlite3_malloc64(tls, nMsg) + **(**uintptr)(__ccgo_up(bp)) = v1 + **(**uintptr)(__ccgo_up(pzErrMsg)) = v1 + if **(**uintptr)(__ccgo_up(bp)) != 0 { + /* zErrmsg would be NULL if not so */ + Xsqlite3_snprintf(tls, libc.Int32FromUint64(nMsg), **(**uintptr)(__ccgo_up(bp)), __ccgo_ts+17704, libc.VaList(bp+16, int32(FILENAME_MAX), zFile)) + _sqlite3OsDlError(tls, pVfs, libc.Int32FromUint64(nMsg-uint64(1)), **(**uintptr)(__ccgo_up(bp))) + } + } + return int32(SQLITE_ERROR) +} + +// C documentation +// +// /* +// ** Allocate and initialize a new Pager object and put a pointer to it +// ** in *ppPager. The pager should eventually be freed by passing it +// ** to sqlite3PagerClose(). +// ** +// ** The zFilename argument is the path to the database file to open. +// ** If zFilename is NULL then a randomly-named temporary file is created +// ** and used as the file to be cached. Temporary files are be deleted +// ** automatically when they are closed. If zFilename is ":memory:" then +// ** all information is held in cache. It is never written to disk. +// ** This can be used to implement an in-memory database. +// ** +// ** The nExtra parameter specifies the number of bytes of space allocated +// ** along with each page reference. This space is available to the user +// ** via the sqlite3PagerGetExtra() API. When a new page is allocated, the +// ** first 8 bytes of this space are zeroed but the remainder is uninitialized. +// ** (The extra space is used by btree as the MemPage object.) +// ** +// ** The flags argument is used to specify properties that affect the +// ** operation of the pager. It should be passed some bitwise combination +// ** of the PAGER_* flags. +// ** +// ** The vfsFlags parameter is a bitmask to pass to the flags parameter +// ** of the xOpen() method of the supplied VFS when opening files. +// ** +// ** If the pager object is allocated and the specified file opened +// ** successfully, SQLITE_OK is returned and *ppPager set to point to +// ** the new pager object. If an error occurs, *ppPager is set to NULL +// ** and error code returned. This function may return SQLITE_NOMEM +// ** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or +// ** various SQLITE_IO_XXX errors. +// */ +func _sqlite3PagerOpen(tls *libc.TLS, pVfs uintptr, ppPager uintptr, zFilename uintptr, nExtra int32, flags int32, vfsFlags int32, __ccgo_fp_xReinit uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var iDc, journalFileSize, memDb, memJM, nPathname, nUriByte, pcacheSize, rc, readOnly, tempFile, useJournal, v4 int32 + var pPtr, z, zPathname, zUri, v1 uintptr + var _ /* fout at bp+12 */ int32 + var _ /* pPager at bp+0 */ uintptr + var _ /* szPageDflt at bp+8 */ Tu32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = iDc, journalFileSize, memDb, memJM, nPathname, nUriByte, pPtr, pcacheSize, rc, readOnly, tempFile, useJournal, z, zPathname, zUri, v1, v4 + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Pager object to allocate and return */ + rc = SQLITE_OK /* Return code */ + tempFile = 0 /* True for temp files (incl. in-memory files) */ + memDb = 0 /* True if this is an in-memory file */ + memJM = 0 /* Memory journal mode */ + readOnly = 0 /* Bytes to allocate for each journal fd */ + zPathname = uintptr(0) /* Full path to database file */ + nPathname = 0 /* Number of bytes in zPathname */ + useJournal = libc.BoolInt32(flags&int32(PAGER_OMIT_JOURNAL) == 0) /* False to omit journal */ + pcacheSize = _sqlite3PcacheSize(tls) /* Bytes to allocate for PCache */ + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(SQLITE_DEFAULT_PAGE_SIZE) /* Default page size */ + zUri = uintptr(0) /* URI args to copy */ + nUriByte = int32(1) /* Number of bytes of URI args at *zUri */ + /* Figure out how much space is required for each journal file-handle + ** (there are two of them, the main journal and the sub-journal). */ + journalFileSize = (_sqlite3JournalSize(tls, pVfs) + int32(7)) & ^libc.Int32FromInt32(7) + /* Set the output variable to NULL in case an error occurs. */ + **(**uintptr)(__ccgo_up(ppPager)) = uintptr(0) + if flags&int32(PAGER_MEMORY) != 0 { + memDb = int32(1) + if zFilename != 0 && **(**int8)(__ccgo_up(zFilename)) != 0 { + zPathname = _sqlite3DbStrDup(tls, uintptr(0), zFilename) + if zPathname == uintptr(0) { + return int32(SQLITE_NOMEM) + } + nPathname = _sqlite3Strlen30(tls, zPathname) + zFilename = uintptr(0) + } + } + /* Compute and store the full pathname in an allocated buffer pointed + ** to by zPathname, length nPathname. Or, if this is a temporary file, + ** leave both nPathname and zPathname set to 0. + */ + if zFilename != 0 && **(**int8)(__ccgo_up(zFilename)) != 0 { + nPathname = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname + int32(1) + zPathname = _sqlite3DbMallocRaw(tls, uintptr(0), libc.Uint64FromInt64(int64(2)*int64(nPathname))) + if zPathname == uintptr(0) { + return int32(SQLITE_NOMEM) + } + **(**int8)(__ccgo_up(zPathname)) = 0 /* Make sure initialized even if FullPathname() fails */ + rc = _sqlite3OsFullPathname(tls, pVfs, zFilename, nPathname, zPathname) + if rc != SQLITE_OK { + if rc == libc.Int32FromInt32(SQLITE_OK)|libc.Int32FromInt32(2)< (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname { + /* This branch is taken when the journal path required by + ** the database being opened will be more than pVfs->mxPathname + ** bytes in length. This means the database cannot be opened, + ** as it will not be possible to open the journal file or even + ** check for a hot-journal before reading. + */ + rc = _sqlite3CantopenError(tls, int32(64423)) + } + if rc != SQLITE_OK { + _sqlite3DbFree(tls, uintptr(0), zPathname) + return rc + } + } + /* Allocate memory for the Pager structure, PCache object, the + ** three file descriptors, the database file name and the journal + ** file name. The layout in memory is as follows: + ** + ** Pager object (sizeof(Pager) bytes) + ** PCache object (sqlite3PcacheSize() bytes) + ** Database file handle (pVfs->szOsFile bytes) + ** Sub-journal file handle (journalFileSize bytes) + ** Main journal file handle (journalFileSize bytes) + ** Ptr back to the Pager (sizeof(Pager*) bytes) + ** \0\0\0\0 database prefix (4 bytes) + ** Database file name (nPathname+1 bytes) + ** URI query parameters (nUriByte bytes) + ** Journal filename (nPathname+8+1 bytes) + ** WAL filename (nPathname+4+1 bytes) + ** \0\0\0 terminator (3 bytes) + ** + ** Some 3rd-party software, over which we have no control, depends on + ** the specific order of the filenames and the \0 separators between them + ** so that it can (for example) find the database filename given the WAL + ** filename without using the sqlite3_filename_database() API. This is a + ** misuse of SQLite and a bug in the 3rd-party software, but the 3rd-party + ** software is in widespread use, so we try to avoid changing the filename + ** order and formatting if possible. In particular, the details of the + ** filename format expected by 3rd-party software should be as follows: + ** + ** - Main Database Path + ** - \0 + ** - Multiple URI components consisting of: + ** - Key + ** - \0 + ** - Value + ** - \0 + ** - \0 + ** - Journal Path + ** - \0 + ** - WAL Path (zWALName) + ** - \0 + ** + ** The sqlite3_create_filename() interface and the databaseFilename() utility + ** that is used by sqlite3_filename_database() and kin also depend on the + ** specific formatting and order of the various filenames, so if the format + ** changes here, be sure to change it there as well. + */ + pPtr = _sqlite3MallocZero(tls, uint64((libc.Uint64FromInt64(312)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32((pcacheSize+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7))+libc.Uint64FromInt32(((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)))+libc.Uint64FromInt32(journalFileSize)*uint64(2)+uint64(__SIZEOF_POINTER__)+uint64(4)+libc.Uint64FromInt32(nPathname)+uint64(1)+libc.Uint64FromInt32(nUriByte)+libc.Uint64FromInt32(nPathname)+uint64(8)+uint64(1)+libc.Uint64FromInt32(nPathname)+uint64(4)+uint64(1)+uint64(3)) + if !(pPtr != 0) { + _sqlite3DbFree(tls, uintptr(0), zPathname) + return int32(SQLITE_NOMEM) + } + **(**uintptr)(__ccgo_up(bp)) = pPtr + pPtr = pPtr + uintptr((libc.Uint64FromInt64(312)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpPCache = pPtr + pPtr = pPtr + uintptr((pcacheSize+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd = pPtr + pPtr = pPtr + uintptr(((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile+libc.Int32FromInt32(7)) & ^libc.Int32FromInt32(7)) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fsjfd = pPtr + pPtr = pPtr + uintptr(journalFileSize) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fjfd = pPtr + pPtr = pPtr + uintptr(journalFileSize) + libc.Xmemcpy(tls, pPtr, bp, uint64(__SIZEOF_POINTER__)) + pPtr = pPtr + uintptr(__SIZEOF_POINTER__) + /* Fill in the Pager.zFilename and pPager.zQueryParam fields */ + pPtr = pPtr + uintptr(4) /* Skip zero prefix */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename = pPtr + if nPathname > 0 { + libc.Xmemcpy(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname)) + pPtr = pPtr + uintptr(nPathname+int32(1)) + if zUri != 0 { + libc.Xmemcpy(tls, pPtr, zUri, libc.Uint64FromInt32(nUriByte)) + pPtr = pPtr + uintptr(nUriByte) + } else { + pPtr = pPtr + 1 + } + } + /* Fill in Pager.zJournal */ + if nPathname > 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzJournal = pPtr + libc.Xmemcpy(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname)) + pPtr = pPtr + uintptr(nPathname) + libc.Xmemcpy(tls, pPtr, __ccgo_ts+4227, uint64(8)) + pPtr = pPtr + uintptr(libc.Int32FromInt32(8)+libc.Int32FromInt32(1)) + } else { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzJournal = uintptr(0) + } + /* Fill in Pager.zWal */ + if nPathname > 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzWal = pPtr + libc.Xmemcpy(tls, pPtr, zPathname, libc.Uint64FromInt32(nPathname)) + pPtr = pPtr + uintptr(nPathname) + libc.Xmemcpy(tls, pPtr, __ccgo_ts+4236, uint64(4)) + pPtr = pPtr + uintptr(libc.Int32FromInt32(4)+libc.Int32FromInt32(1)) + } else { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzWal = uintptr(0) + } + _ = pPtr /* Suppress warning about unused pPtr value */ + if nPathname != 0 { + _sqlite3DbFree(tls, uintptr(0), zPathname) + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpVfs = pVfs + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FvfsFlags = libc.Uint32FromInt32(vfsFlags) + /* Open the pager file. + */ + if !(zFilename != 0 && **(**int8)(__ccgo_up(zFilename)) != 0) { + goto _2 + } + **(**int32)(__ccgo_up(bp + 12)) = 0 /* VFS flags returned by xOpen() */ + rc = _sqlite3OsOpen(tls, pVfs, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd, vfsFlags, bp+12) + v4 = libc.BoolInt32(**(**int32)(__ccgo_up(bp + 12))&libc.Int32FromInt32(SQLITE_OPEN_MEMORY) != libc.Int32FromInt32(0)) + memJM = v4 + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmemVfs = libc.Uint8FromInt32(v4) + readOnly = libc.BoolInt32(**(**int32)(__ccgo_up(bp + 12))&int32(SQLITE_OPEN_READONLY) != 0) + /* If the file was successfully opened for read/write access, + ** choose a default page size in case we have to create the + ** database file. The default page size is the maximum of: + ** + ** + SQLITE_DEFAULT_PAGE_SIZE, + ** + The value returned by sqlite3OsSectorSize() + ** + The largest page size that can be written atomically. + */ + if rc == SQLITE_OK { + iDc = _sqlite3OsDeviceCharacteristics(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd) + if !(readOnly != 0) { + _setSectorSize(tls, **(**uintptr)(__ccgo_up(bp))) + if **(**Tu32)(__ccgo_up(bp + 8)) < (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize { + if (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize > uint32(SQLITE_MAX_DEFAULT_PAGE_SIZE) { + **(**Tu32)(__ccgo_up(bp + 8)) = uint32(SQLITE_MAX_DEFAULT_PAGE_SIZE) + } else { + **(**Tu32)(__ccgo_up(bp + 8)) = (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FsectorSize + } + } + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnoLock = libc.Uint8FromInt32(Xsqlite3_uri_boolean(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, __ccgo_ts+4241, 0)) + if iDc&int32(SQLITE_IOCAP_IMMUTABLE) != 0 || Xsqlite3_uri_boolean(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FzFilename, __ccgo_ts+4248, 0) != 0 { + vfsFlags = vfsFlags | int32(SQLITE_OPEN_READONLY) + goto act_like_temp_file + } + } + goto _3 +_2: + ; + /* If a temporary file is requested, it is not opened immediately. + ** In this case we accept the default page size and delay actually + ** opening the file until the first call to OsWrite(). + ** + ** This branch is also run for an in-memory database. An in-memory + ** database is the same as a temp-file that is never written out to + ** disk and uses an in-memory rollback journal. + ** + ** This branch also runs for files marked as immutable. + */ + goto act_like_temp_file +act_like_temp_file: + ; + tempFile = int32(1) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FeState = uint8(PAGER_READER) /* Pretend we already have a lock */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FeLock = uint8(EXCLUSIVE_LOCK) /* Pretend we are in EXCLUSIVE mode */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnoLock = uint8(1) /* Do no locking */ + readOnly = vfsFlags & int32(SQLITE_OPEN_READONLY) +_3: + ; + /* The following call to PagerSetPagesize() serves to set the value of + ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer. + */ + if rc == SQLITE_OK { + rc = _sqlite3PagerSetPagesize(tls, **(**uintptr)(__ccgo_up(bp)), bp+8, -int32(1)) + } + /* Initialize the PCache object. */ + if rc == SQLITE_OK { + nExtra = (nExtra + int32(7)) & ^libc.Int32FromInt32(7) + if !(memDb != 0) { + v1 = __ccgo_fp(_pagerStress) + } else { + v1 = uintptr(0) + } + rc = _sqlite3PcacheOpen(tls, libc.Int32FromUint32(**(**Tu32)(__ccgo_up(bp + 8))), nExtra, libc.BoolInt32(!(memDb != 0)), v1, **(**uintptr)(__ccgo_up(bp)), (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpPCache) + } + /* If an error occurred above, free the Pager structure and close the file. + */ + if rc != SQLITE_OK { + _sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Ffd) + _sqlite3PageFree(tls, (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpTmpSpace) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp))) + return rc + } + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FuseJournal = libc.Uint8FromInt32(useJournal) + /* pPager->stmtOpen = 0; */ + /* pPager->stmtInUse = 0; */ + /* pPager->nRef = 0; */ + /* pPager->stmtSize = 0; */ + /* pPager->stmtJSize = 0; */ + /* pPager->nPage = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmxPgno = uint32(SQLITE_MAX_PAGE_COUNT) + /* pPager->state = PAGER_UNLOCK; */ + /* pPager->errMask = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FtempFile = libc.Uint8FromInt32(tempFile) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FexclusiveMode = libc.Uint8FromInt32(tempFile) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FchangeCountDone = (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FtempFile + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FmemDb = libc.Uint8FromInt32(memDb) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FreadOnly = libc.Uint8FromInt32(readOnly) + _sqlite3PagerSetFlags(tls, **(**uintptr)(__ccgo_up(bp)), libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DEFAULT_SYNCHRONOUS)+libc.Int32FromInt32(1)|libc.Int32FromInt32(PAGER_CACHESPILL))) + /* pPager->pFirst = 0; */ + /* pPager->pFirstSynced = 0; */ + /* pPager->pLast = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExtra = libc.Uint16FromInt32(nExtra) + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalSizeLimit = int64(-int32(1)) + _setSectorSize(tls, **(**uintptr)(__ccgo_up(bp))) + if !(useJournal != 0) { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalMode = uint8(PAGER_JOURNALMODE_OFF) + } else { + if memDb != 0 || memJM != 0 { + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FjournalMode = uint8(PAGER_JOURNALMODE_MEMORY) + } + } + /* pPager->xBusyHandler = 0; */ + /* pPager->pBusyHandlerArg = 0; */ + (*TPager)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxReiniter = __ccgo_fp_xReinit + _setGetterMethod(tls, **(**uintptr)(__ccgo_up(bp))) + /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */ + /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */ + **(**uintptr)(__ccgo_up(ppPager)) = **(**uintptr)(__ccgo_up(bp)) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** This function is used to parse both URIs and non-URI filenames passed by the +// ** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database +// ** URIs specified as part of ATTACH statements. +// ** +// ** The first argument to this function is the name of the VFS to use (or +// ** a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx" +// ** query parameter. The second argument contains the URI (or non-URI filename) +// ** itself. When this function is called the *pFlags variable should contain +// ** the default flags to open the database handle with. The value stored in +// ** *pFlags may be updated before returning if the URI filename contains +// ** "cache=xxx" or "mode=xxx" query parameters. +// ** +// ** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to +// ** the VFS that should be used to open the database file. *pzFile is set to +// ** point to a buffer containing the name of the file to open. The value +// ** stored in *pzFile is a database name acceptable to sqlite3_uri_parameter() +// ** and is in the same format as names created using sqlite3_create_filename(). +// ** The caller must invoke sqlite3_free_filename() (not sqlite3_free()!) on +// ** the value returned in *pzFile to avoid a memory leak. +// ** +// ** If an error occurs, then an SQLite error code is returned and *pzErrMsg +// ** may be set to point to a buffer containing an English language error +// ** message. It is the responsibility of the caller to eventually release +// ** this buffer by calling sqlite3_free(). +// */ +func _sqlite3ParseUri(tls *libc.TLS, zDefaultVfs uintptr, zUri uintptr, pFlags uintptr, ppVfs uintptr, pzFile uintptr, pzErrMsg uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var aMode, z, zFile, zModeType, zOpt, zVal, zVfs uintptr + var c, v2 int8 + var eState, i, iIn, iOut, limit, mask, mode, nOpt, nUri, nVal, octet, rc, v3, v4 int32 + var flags uint32 + var nByte Tu64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aMode, c, eState, flags, i, iIn, iOut, limit, mask, mode, nByte, nOpt, nUri, nVal, octet, rc, z, zFile, zModeType, zOpt, zVal, zVfs, v2, v3, v4 + rc = SQLITE_OK + flags = **(**uint32)(__ccgo_up(pFlags)) + zVfs = zDefaultVfs + nUri = _sqlite3Strlen30(tls, zUri) + if (flags&uint32(SQLITE_OPEN_URI) != 0 || libc.AtomicLoadNUint8(uintptr(unsafe.Pointer(&_sqlite3Config))+6, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0) && nUri >= int32(5) && libc.Xmemcmp(tls, zUri, __ccgo_ts+26049, uint64(5)) == 0 { /* Input character index */ + iOut = 0 /* Output character index */ + nByte = libc.Uint64FromInt32(nUri + int32(8)) /* Bytes of space to allocate */ + /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen + ** method that there may be extra parameters following the file-name. */ + flags = flags | uint32(SQLITE_OPEN_URI) + iIn = 0 + for { + if !(iIn < nUri) { + break + } + nByte = nByte + libc.BoolUint64(int32(**(**int8)(__ccgo_up(zUri + uintptr(iIn)))) == libc.Int32FromUint8('&')) + goto _1 + _1: + ; + iIn = iIn + 1 + } + zFile = Xsqlite3_malloc64(tls, nByte) + if !(zFile != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, zFile, 0, uint64(4)) /* 4-byte of 0x00 is the start of DB name marker */ + zFile = zFile + uintptr(4) + iIn = int32(5) + /* Discard the scheme and authority segments of the URI. */ + if int32(**(**int8)(__ccgo_up(zUri + 5))) == int32('/') && int32(**(**int8)(__ccgo_up(zUri + 6))) == int32('/') { + iIn = int32(7) + for **(**int8)(__ccgo_up(zUri + uintptr(iIn))) != 0 && int32(**(**int8)(__ccgo_up(zUri + uintptr(iIn)))) != int32('/') { + iIn = iIn + 1 + } + if iIn != int32(7) && (iIn != int32(16) || libc.Xmemcmp(tls, __ccgo_ts+26055, zUri+7, uint64(9)) != 0) { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26065, libc.VaList(bp+8, iIn-int32(7), zUri+7)) + rc = int32(SQLITE_ERROR) + goto parse_uri_out + } + } + /* Copy the filename and any query parameters into the zFile buffer. + ** Decode %HH escape codes along the way. + ** + ** Within this loop, variable eState may be set to 0, 1 or 2, depending + ** on the parsing context. As follows: + ** + ** 0: Parsing file-name. + ** 1: Parsing name section of a name=value query parameter. + ** 2: Parsing value section of a name=value query parameter. + */ + eState = 0 + for { + v2 = **(**int8)(__ccgo_up(zUri + uintptr(iIn))) + c = v2 + if !(int32(v2) != 0 && int32(c) != int32('#')) { + break + } + iIn = iIn + 1 + if int32(c) == int32('%') && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zUri + uintptr(iIn))))])&int32(0x08) != 0 && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zUri + uintptr(iIn+int32(1)))))])&int32(0x08) != 0 { + v3 = iIn + iIn = iIn + 1 + octet = libc.Int32FromUint8(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(zUri + uintptr(v3)))))) << int32(4) + v4 = iIn + iIn = iIn + 1 + octet = octet + libc.Int32FromUint8(_sqlite3HexToInt(tls, int32(**(**int8)(__ccgo_up(zUri + uintptr(v4)))))) + if octet == 0 { + /* This branch is taken when "%00" appears within the URI. In this + ** case we ignore all text in the remainder of the path, name or + ** value currently being parsed. So ignore the current character + ** and skip to the next "?", "=" or "&", as appropriate. */ + for { + v2 = **(**int8)(__ccgo_up(zUri + uintptr(iIn))) + c = v2 + if !(int32(v2) != 0 && int32(c) != int32('#') && (eState != 0 || int32(c) != int32('?')) && (eState != int32(1) || int32(c) != int32('=') && int32(c) != int32('&')) && (eState != int32(2) || int32(c) != int32('&'))) { + break + } + iIn = iIn + 1 + } + continue + } + c = int8(octet) + } else { + if eState == int32(1) && (int32(c) == int32('&') || int32(c) == int32('=')) { + if int32(**(**int8)(__ccgo_up(zFile + uintptr(iOut-int32(1))))) == 0 { + /* An empty option name. Ignore this option altogether. */ + for **(**int8)(__ccgo_up(zUri + uintptr(iIn))) != 0 && int32(**(**int8)(__ccgo_up(zUri + uintptr(iIn)))) != int32('#') && int32(**(**int8)(__ccgo_up(zUri + uintptr(iIn-int32(1))))) != int32('&') { + iIn = iIn + 1 + } + continue + } + if int32(c) == int32('&') { + v3 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zFile + uintptr(v3))) = int8('\000') + } else { + eState = int32(2) + } + c = 0 + } else { + if eState == 0 && int32(c) == int32('?') || eState == int32(2) && int32(c) == int32('&') { + c = 0 + eState = int32(1) + } + } + } + v3 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zFile + uintptr(v3))) = c + } + if eState == int32(1) { + v3 = iOut + iOut = iOut + 1 + **(**int8)(__ccgo_up(zFile + uintptr(v3))) = int8('\000') + } + libc.Xmemset(tls, zFile+uintptr(iOut), 0, uint64(4)) /* end-of-options + empty journal filenames */ + /* Check if there were any options specified that should be interpreted + ** here. Options that are interpreted here include "vfs" and those that + ** correspond to flags that may be passed to the sqlite3_open_v2() + ** method. */ + zOpt = zFile + uintptr(_sqlite3Strlen30(tls, zFile)+int32(1)) + for **(**int8)(__ccgo_up(zOpt)) != 0 { + nOpt = _sqlite3Strlen30(tls, zOpt) + zVal = zOpt + uintptr(nOpt+int32(1)) + nVal = _sqlite3Strlen30(tls, zVal) + if nOpt == int32(3) && libc.Xmemcmp(tls, __ccgo_ts+26093, zOpt, uint64(3)) == 0 { + zVfs = zVal + } else { + aMode = uintptr(0) + zModeType = uintptr(0) + mask = 0 + limit = 0 + if nOpt == int32(5) && libc.Xmemcmp(tls, __ccgo_ts+26097, zOpt, uint64(5)) == 0 { + mask = libc.Int32FromInt32(SQLITE_OPEN_SHAREDCACHE) | libc.Int32FromInt32(SQLITE_OPEN_PRIVATECACHE) + aMode = uintptr(unsafe.Pointer(&_aCacheMode)) + limit = mask + zModeType = __ccgo_ts + 26097 + } + if nOpt == int32(4) && libc.Xmemcmp(tls, __ccgo_ts+26118, zOpt, uint64(4)) == 0 { + mask = libc.Int32FromInt32(SQLITE_OPEN_READONLY) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_MEMORY) + aMode = uintptr(unsafe.Pointer(&_aOpenMode)) + limit = libc.Int32FromUint32(libc.Uint32FromInt32(mask) & flags) + zModeType = __ccgo_ts + 3553 + } + if aMode != 0 { + mode = 0 + i = 0 + for { + if !((**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fz != 0) { + break + } + z = (**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fz + if nVal == _sqlite3Strlen30(tls, z) && 0 == libc.Xmemcmp(tls, zVal, z, libc.Uint64FromInt32(nVal)) { + mode = (**(**struct { + Fz uintptr + Fmode int32 + })(__ccgo_up(aMode + uintptr(i)*16))).Fmode + break + } + goto _9 + _9: + ; + i = i + 1 + } + if mode == 0 { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26133, libc.VaList(bp+8, zModeType, zVal)) + rc = int32(SQLITE_ERROR) + goto parse_uri_out + } + if mode & ^libc.Int32FromInt32(SQLITE_OPEN_MEMORY) > limit { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26153, libc.VaList(bp+8, zModeType, zVal)) + rc = int32(SQLITE_PERM) + goto parse_uri_out + } + flags = flags&libc.Uint32FromInt32(^mask) | libc.Uint32FromInt32(mode) + } + } + zOpt = zVal + uintptr(nVal+int32(1)) + } + } else { + zFile = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nUri+int32(8))) + if !(zFile != 0) { + return int32(SQLITE_NOMEM) + } + libc.Xmemset(tls, zFile, 0, uint64(4)) + zFile = zFile + uintptr(4) + if nUri != 0 { + libc.Xmemcpy(tls, zFile, zUri, libc.Uint64FromInt32(nUri)) + } + libc.Xmemset(tls, zFile+uintptr(nUri), 0, uint64(4)) + flags = flags & libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_OPEN_URI)) + } + **(**uintptr)(__ccgo_up(ppVfs)) = Xsqlite3_vfs_find(tls, zVfs) + if **(**uintptr)(__ccgo_up(ppVfs)) == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErrMsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+26177, libc.VaList(bp+8, zVfs)) + rc = int32(SQLITE_ERROR) + } + goto parse_uri_out +parse_uri_out: + ; + if rc != SQLITE_OK { + Xsqlite3_free_filename(tls, zFile) + zFile = uintptr(0) + } + **(**uint32)(__ccgo_up(pFlags)) = flags + **(**uintptr)(__ccgo_up(pzFile)) = zFile + return rc +} + +// C documentation +// +// /* +// ** Process a pragma statement. +// ** +// ** Pragmas are of this form: +// ** +// ** PRAGMA [schema.]id [= value] +// ** +// ** The identifier might also be a string. The value is a string, and +// ** identifier, or a number. If minusFlag is true, then the value is +// ** a number that was preceded by a minus sign. +// ** +// ** If the left side is "database.id" then pId1 is the database name +// ** and pId2 is the id. If the left side is just "id" then pId1 is the +// ** id and pId2 is any empty string. +// */ +func _sqlite3Pragma(tls *libc.TLS, pParse uintptr, pId1 uintptr, pId2 uintptr, pValue uintptr, minusFlag int32) { + bp := tls.Alloc(240) + defer tls.Free(240) + var a1, a11, addr, addr1, addrCkFault, addrCkOk, addrOk, addrTop, b, bStrict, ckUniq, cnt, doTypeCheck, eAuto, eMode, eMode1, eMode2, i, i1, i10, i2, i3, i4, i5, i6, i7, i8, i9, iAddr, iAddr1, iBt, iCol, iCol1, iCookie, iDb, iDbLast, iEnd, iIdxDb, iLevel, iReg, iTab, iTabCur, iTabDb, iTabDb1, ii, ii1, ii2, ii3, ii4, initNCol, isHidden, isQuick, j2, j3, j4, jmp, jmp2, jmp21, jmp3, jmp4, jmp5, jmp6, jmp61, jmp7, k, k3, kk, label6, labelError, labelOk, loopTop, mx, mxCol, n, nBtree, nCheck, nHidden, nIdx, nIndex, nLimit, p11, p3, p4, r1, r11, r2, rc, regResult, regRow, showInternFunc, size, size1, size2, uniqOk, x1, v2 int32 + var aOp, aOp1, aOp2, aOp3, aOp4, aOp5, aRoot, db, j, j1, k1, k2, k4, p, p1, pBt, pBt1, pBt2, pCheck, pCol, pCol1, pColExpr, pColl, pDb, pEnc, pFK, pFK1, pHash, pIdx, pIdx1, pIdx3, pIdx4, pIdx5, pIdx6, pIdx7, pMod, pObjTab, pPager, pPager1, pParent, pPk, pPk1, pPragma, pPrior, pSchema, pTab, pTab1, pTab10, pTab11, pTab12, pTab2, pTab3, pTab4, pTab5, pTab6, pTab7, pTab8, pTab9, pTbls, pVTab, v, x2, zDb, zErr, zErr1, zErr2, zLeft, zMod, zMode, zOpt, zRet, zRight, zSql, zSubSql, zType, v1, v5 uintptr + var azOrigin [3]uintptr + var cnum Ti16 + var enc Tu8 + var iPrior Tsqlite3_int64 + var iRange, szThreshold TLogEst + var mask Tu64 + var opMask Tu32 + var _ /* N at bp+136 */ Tsqlite3_int64 + var _ /* N at bp+144 */ Tsqlite3_int64 + var _ /* N at bp+152 */ Tsqlite3_int64 + var _ /* N at bp+160 */ Tsqlite3_int64 + var _ /* aFcntl at bp+8 */ [4]uintptr + var _ /* aiCols at bp+96 */ uintptr + var _ /* iDataCur at bp+108 */ int32 + var _ /* iIdxCur at bp+112 */ int32 + var _ /* iLimit at bp+48 */ Ti64 + var _ /* iLimit at bp+56 */ int32 + var _ /* jmp3 at bp+128 */ int32 + var _ /* mxErr at bp+104 */ int32 + var _ /* pDfltValue at bp+120 */ uintptr + var _ /* pDummy at bp+80 */ uintptr + var _ /* pId at bp+0 */ uintptr + var _ /* pIdx at bp+88 */ uintptr + var _ /* res at bp+72 */ int32 + var _ /* size at bp+60 */ int32 + var _ /* sz at bp+64 */ Tsqlite3_int64 + var _ /* x at bp+40 */ Ti64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a1, a11, aOp, aOp1, aOp2, aOp3, aOp4, aOp5, aRoot, addr, addr1, addrCkFault, addrCkOk, addrOk, addrTop, azOrigin, b, bStrict, ckUniq, cnt, cnum, db, doTypeCheck, eAuto, eMode, eMode1, eMode2, enc, i, i1, i10, i2, i3, i4, i5, i6, i7, i8, i9, iAddr, iAddr1, iBt, iCol, iCol1, iCookie, iDb, iDbLast, iEnd, iIdxDb, iLevel, iPrior, iRange, iReg, iTab, iTabCur, iTabDb, iTabDb1, ii, ii1, ii2, ii3, ii4, initNCol, isHidden, isQuick, j, j1, j2, j3, j4, jmp, jmp2, jmp21, jmp3, jmp4, jmp5, jmp6, jmp61, jmp7, k, k1, k2, k3, k4, kk, label6, labelError, labelOk, loopTop, mask, mx, mxCol, n, nBtree, nCheck, nHidden, nIdx, nIndex, nLimit, opMask, p, p1, p11, p3, p4, pBt, pBt1, pBt2, pCheck, pCol, pCol1, pColExpr, pColl, pDb, pEnc, pFK, pFK1, pHash, pIdx, pIdx1, pIdx3, pIdx4, pIdx5, pIdx6, pIdx7, pMod, pObjTab, pPager, pPager1, pParent, pPk, pPk1, pPragma, pPrior, pSchema, pTab, pTab1, pTab10, pTab11, pTab12, pTab2, pTab3, pTab4, pTab5, pTab6, pTab7, pTab8, pTab9, pTbls, pVTab, r1, r11, r2, rc, regResult, regRow, showInternFunc, size, size1, size2, szThreshold, uniqOk, v, x1, x2, zDb, zErr, zErr1, zErr2, zLeft, zMod, zMode, zOpt, zRet, zRight, zSql, zSubSql, zType, v1, v2, v5 + zLeft = uintptr(0) /* Nul-terminated UTF-8 string */ + zRight = uintptr(0) /* Nul-terminated UTF-8 string , or NULL */ + zDb = uintptr(0) /* return value form SQLITE_FCNTL_PRAGMA */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The specific database being pragmaed */ + v = _sqlite3GetVdbe(tls, pParse) /* The pragma */ + if v == uintptr(0) { + return + } + _sqlite3VdbeRunOnlyOnce(tls, v) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(2) + /* Interpret the [schema.] part of the pragma statement. iDb is the + ** index of the database this pragma is being applied to in db.aDb[]. */ + iDb = _sqlite3TwoPartName(tls, pParse, pId1, pId2, bp) + if iDb < 0 { + return + } + pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 + /* If the temp database has been explicitly named as part of the + ** pragma, make sure it is open. + */ + if iDb == int32(1) && _sqlite3OpenTempDatabase(tls, pParse) != 0 { + return + } + zLeft = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) + if !(zLeft != 0) { + return + } + if minusFlag != 0 { + zRight = _sqlite3MPrintf(tls, db, __ccgo_ts+19214, libc.VaList(bp+176, pValue)) + } else { + zRight = _sqlite3NameFromToken(tls, db, pValue) + } + if (*TToken)(unsafe.Pointer(pId2)).Fn > uint32(0) { + v1 = (*TDb)(unsafe.Pointer(pDb)).FzDbSName + } else { + v1 = uintptr(0) + } + zDb = v1 + if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_PRAGMA), zLeft, zRight, zDb) != 0 { + goto pragma_out + } + /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS + ** connection. If it returns SQLITE_OK, then assume that the VFS + ** handled the pragma and generate a no-op prepared statement. + ** + ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed, + ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file + ** object corresponding to the database file to which the pragma + ** statement refers. + ** + ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA + ** file control is an array of pointers to strings (char**) in which the + ** second element of the array is the name of the pragma and the third + ** element is the argument to the pragma or NULL if the pragma has no + ** argument. + */ + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0] = uintptr(0) + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(1)] = zLeft + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(2)] = zRight + (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(3)] = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 + rc = Xsqlite3_file_control(tls, db, zDb, int32(SQLITE_FCNTL_PRAGMA), bp+8) + if rc == SQLITE_OK { + _sqlite3VdbeSetNumCols(tls, v, int32(1)) + _sqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0], uintptr(-libc.Int32FromInt32(1))) + _returnSingleText(tls, v, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + Xsqlite3_free(tls, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + goto pragma_out + } + if rc != int32(SQLITE_NOTFOUND) { + if (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0] != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3944, libc.VaList(bp+176, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0])) + Xsqlite3_free(tls, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) + } + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + goto pragma_out + } + /* Locate the pragma in the lookup table */ + pPragma = _pragmaLocate(tls, zLeft) + if pPragma == uintptr(0) { + /* IMP: R-43042-22504 No error messages are generated if an + ** unknown pragma is issued. */ + goto pragma_out + } + /* Make sure the database schema is loaded if the pragma requires that */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NeedSchema) != 0 { + if _sqlite3ReadSchema(tls, pParse) != 0 { + goto pragma_out + } + } + /* Register the result column names for pragmas that return results */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns) == 0 && (libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns1) == 0 || zRight == uintptr(0)) { + _setPragmaResultColumnNames(tls, v, pPragma) + } + /* Jump to the appropriate pragma handler */ + switch libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FePragTyp) { + /* + ** PRAGMA [schema.]default_cache_size + ** PRAGMA [schema.]default_cache_size=N + ** + ** The first form reports the current persistent setting for the + ** page cache size. The value returned is the maximum number of + ** pages in the page cache. The second form sets both the current + ** page cache size value and the persistent page cache size value + ** stored in the database file. + ** + ** Older versions of SQLite would set the default cache size to a + ** negative number to indicate synchronous=OFF. These days, synchronous + ** is always on by default regardless of the sign of the default cache + ** size. But continue to take the absolute value of the default cache + ** size of historical compatibility. + */ + case int32(PragTyp_DEFAULT_CACHE_SIZE): + _sqlite3VdbeUsesBtree(tls, v, iDb) + if !(zRight != 0) { + **(**int32)(__ccgo_up(pParse + 60)) += int32(2) + aOp = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(36)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_getCacheSize)), _iLn3) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp + 6*24))).Fp1 = -int32(2000) + } else { + size = _sqlite3AbsInt32(tls, _sqlite3Atoi(tls, zRight)) + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_DEFAULT_CACHE_SIZE), size) + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size + _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) + } + break + /* + ** PRAGMA [schema.]page_size + ** PRAGMA [schema.]page_size=N + ** + ** The first form reports the current setting for the + ** database page size in bytes. The second form sets the + ** database page size value. The value can only be set if + ** the database has not yet been created. + */ + fallthrough + case int32(PragTyp_PAGE_SIZE): + pBt = (*TDb)(unsafe.Pointer(pDb)).FpBt + if !(zRight != 0) { + if pBt != 0 { + v2 = _sqlite3BtreeGetPageSize(tls, pBt) + } else { + v2 = 0 + } + size1 = v2 + _returnSingleInt(tls, v, int64(size1)) + } else { + /* Malloc may fail when setting the page-size, as there is an internal + ** buffer that the pager module resizes using sqlite3_realloc(). + */ + (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize = _sqlite3Atoi(tls, zRight) + if int32(SQLITE_NOMEM) == _sqlite3BtreeSetPageSize(tls, pBt, (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { + _sqlite3OomFault(tls, db) + } + } + break + /* + ** PRAGMA [schema.]secure_delete + ** PRAGMA [schema.]secure_delete=ON/OFF/FAST + ** + ** The first form reports the current setting for the + ** secure_delete flag. The second form changes the secure_delete + ** flag setting and reports the new value. + */ + fallthrough + case int32(PragTyp_SECURE_DELETE): + pBt1 = (*TDb)(unsafe.Pointer(pDb)).FpBt + b = -int32(1) + if zRight != 0 { + if Xsqlite3_stricmp(tls, zRight, __ccgo_ts+19218) == 0 { + b = int32(2) + } else { + b = libc.Int32FromUint8(_sqlite3GetBoolean(tls, zRight, uint8(0))) + } + } + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) && b >= 0 { + ii = 0 + for { + if !(ii < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + _sqlite3BtreeSecureDelete(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii)*32))).FpBt, b) + goto _3 + _3: + ; + ii = ii + 1 + } + } + b = _sqlite3BtreeSecureDelete(tls, pBt1, b) + _returnSingleInt(tls, v, int64(b)) + break + /* + ** PRAGMA [schema.]max_page_count + ** PRAGMA [schema.]max_page_count=N + ** + ** The first form reports the current setting for the + ** maximum number of pages in the database file. The + ** second form attempts to change this setting. Both + ** forms return the current setting. + ** + ** The absolute value of N is used. This is undocumented and might + ** change. The only purpose is to provide an easy way to test + ** the sqlite3AbsInt32() function. + ** + ** PRAGMA [schema.]page_count + ** + ** Return the number of pages in the specified database. + */ + fallthrough + case int32(PragTyp_PAGE_COUNT): + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + _sqlite3CodeVerifySchema(tls, pParse, iDb) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + iReg = v2 + if libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zLeft)))]) == int32('p') { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Pagecount), iDb, iReg) + } else { + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+40) == 0 { + if **(**Ti64)(__ccgo_up(bp + 40)) < 0 { + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + } else { + if **(**Ti64)(__ccgo_up(bp + 40)) > libc.Int64FromUint32(0xfffffffe) { + **(**Ti64)(__ccgo_up(bp + 40)) = libc.Int64FromUint32(0xfffffffe) + } + } + } else { + **(**Ti64)(__ccgo_up(bp + 40)) = 0 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_MaxPgcnt), iDb, iReg, int32(**(**Ti64)(__ccgo_up(bp + 40)))) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), iReg, int32(1)) + break + /* + ** PRAGMA [schema.]locking_mode + ** PRAGMA [schema.]locking_mode = (normal|exclusive) + */ + fallthrough + case int32(PragTyp_LOCKING_MODE): + zRet = __ccgo_ts + 19009 + eMode = _getLockingMode(tls, zRight) + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) && eMode == -int32(1) { + /* Simple "PRAGMA locking_mode;" statement. This is a query for + ** the current default locking mode (which may be different to + ** the locking-mode of the main database). + */ + eMode = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FdfltLockMode) + } else { + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + ii1 = int32(2) + for { + if !(ii1 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pPager = _sqlite3BtreePager(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii1)*32))).FpBt) + _sqlite3PagerLockingMode(tls, pPager, eMode) + goto _6 + _6: + ; + ii1 = ii1 + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FdfltLockMode = libc.Uint8FromInt32(eMode) + } + pPager = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + eMode = _sqlite3PagerLockingMode(tls, pPager, eMode) + } + if eMode == int32(PAGER_LOCKINGMODE_EXCLUSIVE) { + zRet = __ccgo_ts + 18999 + } + _returnSingleText(tls, v, zRet) + break + /* + ** PRAGMA [schema.]journal_mode + ** PRAGMA [schema.]journal_mode = + ** (delete|persist|off|truncate|memory|wal|off) + */ + fallthrough + case int32(PragTyp_JOURNAL_MODE): /* Loop counter */ + if zRight == uintptr(0) { + /* If there is no "=MODE" part of the pragma, do a query for the + ** current mode */ + eMode1 = -int32(1) + } else { + n = _sqlite3Strlen30(tls, zRight) + eMode1 = 0 + for { + v1 = _sqlite3JournalModename(tls, eMode1) + zMode = v1 + if !(v1 != uintptr(0)) { + break + } + if Xsqlite3_strnicmp(tls, zRight, zMode, n) == 0 { + break + } + goto _7 + _7: + ; + eMode1 = eMode1 + 1 + } + if !(zMode != 0) { + /* If the "=MODE" part does not match any known journal mode, + ** then do a query */ + eMode1 = -int32(1) + } + if eMode1 == int32(PAGER_JOURNALMODE_OFF) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) { + /* Do not allow journal-mode "OFF" in defensive since the database + ** can become corrupted using ordinary SQL when the journal is off */ + eMode1 = -int32(1) + } + } + if eMode1 == -int32(1) && (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ + iDb = 0 + (*TToken)(unsafe.Pointer(pId2)).Fn = uint32(1) + } + ii2 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + for { + if !(ii2 >= 0) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii2)*32))).FpBt != 0 && (ii2 == iDb || (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0)) { + _sqlite3VdbeUsesBtree(tls, v, ii2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_JournalMode), ii2, int32(1), eMode1) + } + goto _9 + _9: + ; + ii2 = ii2 - 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) + break + /* + ** PRAGMA [schema.]journal_size_limit + ** PRAGMA [schema.]journal_size_limit=N + ** + ** Get or set the size limit on rollback journal files. + */ + fallthrough + case int32(PragTyp_JOURNAL_SIZE_LIMIT): + pPager1 = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + **(**Ti64)(__ccgo_up(bp + 48)) = int64(-int32(2)) + if zRight != 0 { + _sqlite3DecOrHexToI64(tls, zRight, bp+48) + if **(**Ti64)(__ccgo_up(bp + 48)) < int64(-int32(1)) { + **(**Ti64)(__ccgo_up(bp + 48)) = int64(-int32(1)) + } + } + **(**Ti64)(__ccgo_up(bp + 48)) = _sqlite3PagerJournalSizeLimit(tls, pPager1, **(**Ti64)(__ccgo_up(bp + 48))) + _returnSingleInt(tls, v, **(**Ti64)(__ccgo_up(bp + 48))) + break + /* + ** PRAGMA [schema.]auto_vacuum + ** PRAGMA [schema.]auto_vacuum=N + ** + ** Get or set the value of the database 'auto-vacuum' parameter. + ** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL + */ + fallthrough + case int32(PragTyp_AUTO_VACUUM): + pBt2 = (*TDb)(unsafe.Pointer(pDb)).FpBt + if !(zRight != 0) { + _returnSingleInt(tls, v, int64(_sqlite3BtreeGetAutoVacuum(tls, pBt2))) + } else { + eAuto = _getAutoVacuum(tls, zRight) + (*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac = libc.Int8FromUint8(libc.Uint8FromInt32(eAuto)) + /* Call SetAutoVacuum() to set initialize the internal auto and + ** incr-vacuum flags. This is required in case this connection + ** creates the database file. It is important that it is created + ** as an auto-vacuum capable db. + */ + rc = _sqlite3BtreeSetAutoVacuum(tls, pBt2, eAuto) + if rc == SQLITE_OK && (eAuto == int32(1) || eAuto == int32(2)) { + iAddr = _sqlite3VdbeCurrentAddr(tls, v) + aOp1 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(20)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_setMeta6)), _iLn11) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp1))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 2*24))).Fp2 = iAddr + int32(4) + (**(**TVdbeOp)(__ccgo_up(aOp1 + 4*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp1 + 4*24))).Fp3 = eAuto - int32(1) + _sqlite3VdbeUsesBtree(tls, v, iDb) + } + } + break + /* + ** PRAGMA [schema.]incremental_vacuum(N) + ** + ** Do N steps of incremental vacuuming on a database. + */ + fallthrough + case int32(PragTyp_INCREMENTAL_VACUUM): + **(**int32)(__ccgo_up(bp + 56)) = 0 + if zRight == uintptr(0) || !(_sqlite3GetInt32(tls, zRight, bp+56) != 0) || **(**int32)(__ccgo_up(bp + 56)) <= 0 { + **(**int32)(__ccgo_up(bp + 56)) = int32(0x7fffffff) + } + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp + 56)), int32(1)) + addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IncrVacuum), iDb) + _sqlite3VdbeAddOp1(tls, v, int32(OP_ResultRow), int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(1), -int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), int32(1), addr) + _sqlite3VdbeJumpHere(tls, v, addr) + break + /* + ** PRAGMA [schema.]cache_size + ** PRAGMA [schema.]cache_size=N + ** + ** The first form reports the current local setting for the + ** page cache size. The second form sets the local + ** page cache size value. If N is positive then that is the + ** number of pages in the cache. If N is negative, then the + ** number of pages is adjusted so that the cache uses -N kibibytes + ** of memory. + */ + fallthrough + case int32(PragTyp_CACHE_SIZE): + if !(zRight != 0) { + _returnSingleInt(tls, v, int64((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size)) + } else { + size2 = _sqlite3Atoi(tls, zRight) + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size2 + _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) + } + break + /* + ** PRAGMA [schema.]cache_spill + ** PRAGMA cache_spill=BOOLEAN + ** PRAGMA [schema.]cache_spill=N + ** + ** The first form reports the current local setting for the + ** page cache spill size. The second form turns cache spill on + ** or off. When turning cache spill on, the size is set to the + ** current cache_size. The third form sets a spill size that + ** may be different form the cache size. + ** If N is positive then that is the + ** number of pages in the cache. If N is negative, then the + ** number of pages is adjusted so that the cache uses -N kibibytes + ** of memory. + ** + ** If the number of cache_spill pages is less then the number of + ** cache_size pages, no spilling occurs until the page count exceeds + ** the number of cache_size pages. + ** + ** The cache_spill=BOOLEAN setting applies to all attached schemas, + ** not just the schema specified. + */ + fallthrough + case int32(PragTyp_CACHE_SPILL): + if !(zRight != 0) { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_CacheSpill) == uint64(0) { + v2 = 0 + } else { + v2 = _sqlite3BtreeSetSpillSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, 0) + } + _returnSingleInt(tls, v, int64(v2)) + } else { + **(**int32)(__ccgo_up(bp + 60)) = int32(1) + if _sqlite3GetInt32(tls, zRight, bp+60) != 0 { + _sqlite3BtreeSetSpillSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, **(**int32)(__ccgo_up(bp + 60))) + } + if _sqlite3GetBoolean(tls, zRight, libc.BoolUint8(**(**int32)(__ccgo_up(bp + 60)) != 0)) != 0 { + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_CacheSpill) + } else { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_CacheSpill) + } + _setAllPagerFlags(tls, db) + } + break + /* + ** PRAGMA [schema.]mmap_size(N) + ** + ** Used to set mapping size limit. The mapping size limit is + ** used to limit the aggregate size of all memory mapped regions of the + ** database file. If this parameter is set to zero, then memory mapping + ** is not used at all. If N is negative, then the default memory map + ** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_SIZE) is set. + ** The parameter N is measured in bytes. + ** + ** This value is advisory. The underlying VFS is free to memory map + ** as little or as much as it wants. Except, if N is set to 0 then the + ** upper layers will never invoke the xFetch interfaces to the VFS. + */ + fallthrough + case int32(PragTyp_MMAP_SIZE): + if zRight != 0 { + _sqlite3DecOrHexToI64(tls, zRight, bp+64) + if **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) < 0 { + **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) = _sqlite3Config.FszMmap + } + if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { + (*Tsqlite3)(unsafe.Pointer(db)).FszMmap = **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) + } + ii3 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + for { + if !(ii3 >= 0) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii3)*32))).FpBt != 0 && (ii3 == iDb || (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0)) { + _sqlite3BtreeSetMmapLimit(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii3)*32))).FpBt, **(**Tsqlite3_int64)(__ccgo_up(bp + 64))) + } + goto _11 + _11: + ; + ii3 = ii3 - 1 + } + } + **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) = int64(-int32(1)) + rc = Xsqlite3_file_control(tls, db, zDb, int32(SQLITE_FCNTL_MMAP_SIZE), bp+64) + if rc == SQLITE_OK { + _returnSingleInt(tls, v, **(**Tsqlite3_int64)(__ccgo_up(bp + 64))) + } else { + if rc != int32(SQLITE_NOTFOUND) { + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + (*TParse)(unsafe.Pointer(pParse)).Frc = rc + } + } + break + /* + ** PRAGMA temp_store + ** PRAGMA temp_store = "default"|"memory"|"file" + ** + ** Return or set the local value of the temp_store flag. Changing + ** the local value does not make changes to the disk file and the default + ** value will be restored the next time the database is opened. + ** + ** Note that it is possible for the library compile-time options to + ** override this setting + */ + fallthrough + case int32(PragTyp_TEMP_STORE): + if !(zRight != 0) { + _returnSingleInt(tls, v, libc.Int64FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store)) + } else { + _changeTempStorage(tls, pParse, zRight) + } + break + /* + ** PRAGMA temp_store_directory + ** PRAGMA temp_store_directory = ""|"directory_name" + ** + ** Return or set the local value of the temp_store_directory flag. Changing + ** the value sets a specific directory to be used for temporary files. + ** Setting to a null string reverts to the default temporary directory search. + ** If temporary directory is changed, then invalidateTempStorage. + ** + */ + fallthrough + case int32(PragTyp_TEMP_STORE_DIRECTORY): + Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + if !(zRight != 0) { + _returnSingleText(tls, v, Xsqlite3_temp_directory) + } else { + if **(**int8)(__ccgo_up(zRight)) != 0 { + rc = _sqlite3OsAccess(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, zRight, int32(SQLITE_ACCESS_READWRITE), bp+72) + if rc != SQLITE_OK || **(**int32)(__ccgo_up(bp + 72)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19223, 0) + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + goto pragma_out + } + } + if libc.Bool(false) || libc.Bool(true) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) <= int32(1) || libc.Bool(libc.Bool(false) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) == int32(1)) { + _invalidateTempStorage(tls, pParse) + } + Xsqlite3_free(tls, Xsqlite3_temp_directory) + if **(**int8)(__ccgo_up(zRight)) != 0 { + Xsqlite3_temp_directory = Xsqlite3_mprintf(tls, __ccgo_ts+3944, libc.VaList(bp+176, zRight)) + } else { + Xsqlite3_temp_directory = uintptr(0) + } + } + Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) + break + /* + ** PRAGMA [schema.]synchronous + ** PRAGMA [schema.]synchronous=OFF|ON|NORMAL|FULL|EXTRA + ** + ** Return or set the local value of the synchronous flag. Changing + ** the local value does not make changes to the disk file and the + ** default value will be restored the next time the database is + ** opened. + */ + fallthrough + case int32(PragTyp_SYNCHRONOUS): + if !(zRight != 0) { + _returnSingleInt(tls, v, int64(libc.Int32FromUint8((*TDb)(unsafe.Pointer(pDb)).Fsafety_level)-int32(1))) + } else { + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19248, 0) + } else { + if iDb != int32(1) { + iLevel = (libc.Int32FromUint8(_getSafetyLevel(tls, zRight, 0, uint8(1))) + int32(1)) & int32(PAGER_SYNCHRONOUS_MASK) + if iLevel == 0 { + iLevel = int32(1) + } + (*TDb)(unsafe.Pointer(pDb)).Fsafety_level = libc.Uint8FromInt32(iLevel) + (*TDb)(unsafe.Pointer(pDb)).FbSyncSet = uint8(1) + _setAllPagerFlags(tls, db) + } + } + } + case int32(PragTyp_FLAG): + if zRight == uintptr(0) { + _setPragmaResultColumnNames(tls, v, pPragma) + _returnSingleInt(tls, v, libc.BoolInt64((*Tsqlite3)(unsafe.Pointer(db)).Fflags&(*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != uint64(0))) + } else { + mask = (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg /* Mask of bits to set or clear. */ + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 { + /* Foreign key support may not be enabled or disabled while not + ** in auto-commit mode. */ + mask = mask & libc.Uint64FromInt32(^libc.Int32FromInt32(SQLITE_ForeignKeys)) + } + if _sqlite3GetBoolean(tls, zRight, uint8(0)) != 0 { + if mask&uint64(SQLITE_WriteSchema) == uint64(0) || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) == uint64(0) { + **(**Tu64)(__ccgo_up(db + 48)) |= mask + } + } else { + **(**Tu64)(__ccgo_up(db + 48)) &= ^mask + if mask == uint64(SQLITE_DeferFKs) { + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons = 0 + } + if mask&uint64(SQLITE_WriteSchema) != uint64(0) && Xsqlite3_stricmp(tls, zRight, __ccgo_ts+19301) == 0 { + /* IMP: R-60817-01178 If the argument is "RESET" then schema + ** writing is disabled (as with "PRAGMA writable_schema=OFF") and, + ** in addition, the schema is reloaded. */ + _sqlite3ResetAllSchemasOfConnection(tls, db) + } + } + /* Many of the flag-pragmas modify the code generated by the SQL + ** compiler (eg. count_changes). So add an opcode to expire all + ** compiled SQL statements after modifying a pragma value. + */ + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + _setAllPagerFlags(tls, db) + } + break + /* + ** PRAGMA table_info(
    ) + ** + ** Return a single row for each column of the named table. The columns of + ** the returned data set are: + ** + ** cid: Column id (numbered from left to right, starting at 0) + ** name: Column name + ** type: Column declaration type. + ** notnull: True if 'NOT NULL' is part of column declaration + ** dflt_value: The default value for the column, if any. + ** pk: Non-zero for PK fields. + */ + fallthrough + case int32(PragTyp_TABLE_INFO): + if zRight != 0 { + _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) + pTab = _sqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb) + if pTab != 0 { + nHidden = 0 + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(7) + _sqlite3ViewGetColumnNames(tls, pParse, pTab) + i = 0 + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + isHidden = 0 + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_NOINSERT) != 0 { + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg == uint64(0) { + nHidden = nHidden + 1 + goto _12 + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + isHidden = int32(2) /* GENERATED ALWAYS AS ... VIRTUAL */ + } else { + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_STORED) != 0 { + isHidden = int32(3) /* GENERATED ALWAYS AS ... STORED */ + } else { + isHidden = int32(1) /* HIDDEN */ + } + } + } + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) == 0 { + k = 0 + } else { + if pPk == uintptr(0) { + k = int32(1) + } else { + k = int32(1) + for { + if !(k <= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) && int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(k-int32(1))*2))) != i) { + break + } + goto _13 + _13: + ; + k = k + 1 + } + } + } + pColExpr = _sqlite3ColumnExpr(tls, pTab, pCol) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + v1 = __ccgo_ts + 19307 + } else { + v1 = __ccgo_ts + 19315 + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + if isHidden >= int32(2) || pColExpr == uintptr(0) { + v5 = uintptr(0) + } else { + v5 = *(*uintptr)(unsafe.Pointer(pColExpr + 8)) + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), v1, libc.VaList(bp+176, i-nHidden, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, _sqlite3ColumnType(tls, pCol, __ccgo_ts+1704), v2, v5, k, isHidden)) + goto _12 + _12: + ; + i = i + 1 + pCol += 16 + } + } + } + break + /* + ** PRAGMA table_list + ** + ** Return a single row for each table, virtual table, or view in the + ** entire schema. + ** + ** schema: Name of attached database hold this table + ** name: Name of the table itself + ** type: "table", "view", "virtual", "shadow" + ** ncol: Number of columns + ** wr: True for a WITHOUT ROWID table + ** strict: True for a STRICT table + */ + fallthrough + case int32(PragTyp_TABLE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) + ii4 = 0 + for { + if !(ii4 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if zDb != 0 && Xsqlite3_stricmp(tls, zDb, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FzDbSName) != 0 { + goto _17 + } + /* Ensure that the Table.nCol field is initialized for all views + ** and virtual tables. Each time we initialize a Table.nCol value + ** for a table, that can potentially disrupt the hash table, so restart + ** the initialization scan. + */ + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FpSchema + 8 + initNCol = libc.Int32FromUint32((*THash)(unsafe.Pointer(pHash)).Fcount) + for { + v2 = initNCol + initNCol = initNCol - 1 + if !(v2 != 0) { + break + } + k1 = (*THash)(unsafe.Pointer(pHash)).Ffirst + for { + if !(int32(1) != 0) { + break + } + if k1 == uintptr(0) { + initNCol = 0 + break + } + pTab1 = (*THashElem)(unsafe.Pointer(k1)).Fdata + if int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) == 0 { + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+19322, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab1)).FzName)) + if zSql != 0 { + **(**uintptr)(__ccgo_up(bp + 80)) = uintptr(0) + Xsqlite3_prepare_v3(tls, db, zSql, -int32(1), uint32(SQLITE_PREPARE_DONT_LOG), bp+80, uintptr(0)) + Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 80))) + _sqlite3DbFree(tls, db, zSql) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ErrorMsg(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpParse, __ccgo_ts+1674, 0) + (*TParse)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpParse)).Frc = int32(SQLITE_NOMEM) + } + pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FpSchema + 8 + break + } + goto _19 + _19: + ; + k1 = (*THashElem)(unsafe.Pointer(k1)).Fnext + } + } + k1 = (*THash)(unsafe.Pointer(pHash)).Ffirst + for { + if !(k1 != 0) { + break + } + pTab2 = (*THashElem)(unsafe.Pointer(k1)).Fdata + if zRight != 0 && Xsqlite3_stricmp(tls, zRight, (*TTable)(unsafe.Pointer(pTab2)).FzName) != 0 { + goto _20 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VIEW) { + zType = __ccgo_ts + 11115 + } else { + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VTAB) { + zType = __ccgo_ts + 14300 + } else { + if (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Shadow) != 0 { + zType = __ccgo_ts + 19338 + } else { + zType = __ccgo_ts + 9377 + } + } + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19345, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FzDbSName, _sqlite3PreferredTableName(tls, (*TTable)(unsafe.Pointer(pTab2)).FzName), zType, int32((*TTable)(unsafe.Pointer(pTab2)).FnCol), libc.BoolInt32((*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_WithoutRowid) != uint32(0)), libc.BoolInt32((*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Strict) != uint32(0)))) + goto _20 + _20: + ; + k1 = (*THashElem)(unsafe.Pointer(k1)).Fnext + } + goto _17 + _17: + ; + ii4 = ii4 + 1 + } + case int32(PragTyp_INDEX_INFO): + if zRight != 0 { + pIdx = _sqlite3FindIndex(tls, db, zRight, zDb) + if pIdx == uintptr(0) { + /* If there is no index named zRight, check to see if there is a + ** WITHOUT ROWID table named zRight, and if there is, show the + ** structure of the PRIMARY KEY index for that table. */ + pTab3 = _sqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb) + if pTab3 != 0 && !((*TTable)(unsafe.Pointer(pTab3)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + pIdx = _sqlite3PrimaryKeyIndex(tls, pTab3) + } + } + if pIdx != 0 { + iIdxDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIdx)).FpSchema) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + /* PRAGMA index_xinfo (newer version with more rows and columns) */ + mx = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + } else { + /* PRAGMA index_info (legacy version) */ + mx = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + } + pTab3 = (*TIndex)(unsafe.Pointer(pIdx)).FpTable + _sqlite3CodeVerifySchema(tls, pParse, iIdxDb) + i1 = 0 + for { + if !(i1 < mx) { + break + } + cnum = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i1)*2)) + if int32(cnum) < 0 { + v1 = uintptr(0) + } else { + v1 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab3)).FaCol + uintptr(cnum)*16))).FzCnName + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19352, libc.VaList(bp+176, i1, int32(cnum), v1)) + if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { + _sqlite3VdbeMultiLoad(tls, v, int32(4), __ccgo_ts+19357, libc.VaList(bp+176, libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i1)))), **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i1)*8)), libc.BoolInt32(i1 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)))) + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), (*TParse)(unsafe.Pointer(pParse)).FnMem) + goto _21 + _21: + ; + i1 = i1 + 1 + } + } + } + case int32(PragTyp_INDEX_LIST): + if zRight != 0 { + pTab4 = _sqlite3FindTable(tls, db, zRight, zDb) + if pTab4 != 0 { + iTabDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab4)).FpSchema) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(5) + _sqlite3CodeVerifySchema(tls, pParse, iTabDb) + pIdx1 = (*TTable)(unsafe.Pointer(pTab4)).FpIndex + i2 = libc.Int32FromInt32(0) + for { + if !(pIdx1 != 0) { + break + } + azOrigin = [3]uintptr{ + 0: __ccgo_ts + 19362, + 1: __ccgo_ts + 19364, + 2: __ccgo_ts + 17851, + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19366, libc.VaList(bp+176, i2, (*TIndex)(unsafe.Pointer(pIdx1)).FzName, libc.BoolInt32(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx1)).FonError) != OE_None), azOrigin[int32(uint32(*(*uint16)(unsafe.Pointer(pIdx1 + 100))&0x3>>0))], libc.BoolInt32((*TIndex)(unsafe.Pointer(pIdx1)).FpPartIdxWhere != uintptr(0)))) + goto _23 + _23: + ; + pIdx1 = (*TIndex)(unsafe.Pointer(pIdx1)).FpNext + i2 = i2 + 1 + } + } + } + case int32(PragTyp_DATABASE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + i3 = 0 + for { + if !(i3 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FpBt == uintptr(0) { + goto _24 + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19372, libc.VaList(bp+176, i3, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FzDbSName, _sqlite3BtreeGetFilename(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FpBt))) + goto _24 + _24: + ; + i3 = i3 + 1 + } + case int32(PragTyp_COLLATION_LIST): + i4 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(2) + p = (*THash)(unsafe.Pointer(db + 648)).Ffirst + for { + if !(p != 0) { + break + } + pColl = (*THashElem)(unsafe.Pointer(p)).Fdata + v2 = i4 + i4 = i4 + 1 + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19376, libc.VaList(bp+176, v2, (*TCollSeq)(unsafe.Pointer(pColl)).FzName)) + goto _25 + _25: + ; + p = (*THashElem)(unsafe.Pointer(p)).Fnext + } + case int32(PragTyp_FUNCTION_LIST): + showInternFunc = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_InternalFunc) != uint32(0)) + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + i5 = 0 + for { + if !(i5 < int32(SQLITE_FUNC_HASH_SZ)) { + break + } + p1 = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(i5)*8)) + for { + if !(p1 != 0) { + break + } + _pragmaFunclistLine(tls, v, p1, int32(1), showInternFunc) + goto _28 + _28: + ; + p1 = *(*uintptr)(unsafe.Pointer(p1 + 64)) + } + goto _27 + _27: + ; + i5 = i5 + 1 + } + j = (*THash)(unsafe.Pointer(db + 624)).Ffirst + for { + if !(j != 0) { + break + } + p1 = (*THashElem)(unsafe.Pointer(j)).Fdata + _pragmaFunclistLine(tls, v, p1, 0, showInternFunc) + goto _29 + _29: + ; + j = (*THashElem)(unsafe.Pointer(j)).Fnext + } + case int32(PragTyp_MODULE_LIST): + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(1) + j1 = (*THash)(unsafe.Pointer(db + 576)).Ffirst + for { + if !(j1 != 0) { + break + } + pMod = (*THashElem)(unsafe.Pointer(j1)).Fdata + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+7909, libc.VaList(bp+176, (*TModule)(unsafe.Pointer(pMod)).FzName)) + goto _30 + _30: + ; + j1 = (*THashElem)(unsafe.Pointer(j1)).Fnext + } + case int32(PragTyp_PRAGMA_LIST): + i6 = 0 + for { + if !(i6 < libc.Int32FromUint64(libc.Uint64FromInt64(1584)/libc.Uint64FromInt64(24))) { + break + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+7909, libc.VaList(bp+176, _aPragmaName[i6].FzName)) + goto _31 + _31: + ; + i6 = i6 + 1 + } + case int32(PragTyp_FOREIGN_KEY_LIST): + if zRight != 0 { + pTab5 = _sqlite3FindTable(tls, db, zRight, zDb) + if pTab5 != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab5)).FeTabType) == TABTYP_NORM { + pFK = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab5 + 64))).FpFKey + if pFK != 0 { + iTabDb1 = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab5)).FpSchema) + i7 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(8) + _sqlite3CodeVerifySchema(tls, pParse, iTabDb1) + for pFK != 0 { + j2 = 0 + for { + if !(j2 < (*TFKey)(unsafe.Pointer(pFK)).FnCol) { + break + } + _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19379, libc.VaList(bp+176, i7, j2, (*TFKey)(unsafe.Pointer(pFK)).FzTo, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab5)).FaCol + uintptr((*(*TsColMap)(unsafe.Pointer(pFK + 64 + uintptr(j2)*16))).FiFrom)*16))).FzCnName, (*(*TsColMap)(unsafe.Pointer(pFK + 64 + uintptr(j2)*16))).FzCol, _actionName(tls, **(**Tu8)(__ccgo_up(pFK + 45 + 1))), _actionName(tls, **(**Tu8)(__ccgo_up(pFK + 45))), __ccgo_ts+19388)) + goto _32 + _32: + ; + j2 = j2 + 1 + } + i7 = i7 + 1 + pFK = (*TFKey)(unsafe.Pointer(pFK)).FpNextFrom + } + } + } + } + case int32(PragTyp_FOREIGN_KEY_CHECK): /* child to parent column mapping */ + regResult = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += int32(4) + v1 = pParse + 60 + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + v2 = *(*int32)(unsafe.Pointer(v1)) + regRow = v2 + k2 = (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 8)).Ffirst + for k2 != 0 { + if zRight != 0 { + pTab6 = _sqlite3LocateTable(tls, pParse, uint32(0), zRight, zDb) + k2 = uintptr(0) + } else { + pTab6 = (*THashElem)(unsafe.Pointer(k2)).Fdata + k2 = (*THashElem)(unsafe.Pointer(k2)).Fnext + } + if pTab6 == uintptr(0) || !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab6)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) || (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey == uintptr(0) { + continue + } + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab6)).FpSchema) + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + _sqlite3CodeVerifySchema(tls, pParse, iDb) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab6)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab6)).FzName) + _sqlite3TouchRegister(tls, pParse, int32((*TTable)(unsafe.Pointer(pTab6)).FnCol)+regRow) + _sqlite3OpenTable(tls, pParse, 0, iDb, pTab6, int32(OP_OpenRead)) + _sqlite3VdbeLoadString(tls, v, regResult, (*TTable)(unsafe.Pointer(pTab6)).FzName) + i8 = int32(1) + pFK1 = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey + for { + if !(pFK1 != 0) { + break + } + pParent = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, zDb) + if pParent == uintptr(0) { + goto _35 + } + **(**uintptr)(__ccgo_up(bp + 88)) = uintptr(0) + _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pParent)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pParent)).FzName) + x1 = _sqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+88, uintptr(0)) + if x1 == 0 { + if **(**uintptr)(__ccgo_up(bp + 88)) == uintptr(0) { + _sqlite3OpenTable(tls, pParse, i8, iDb, pParent, int32(OP_OpenRead)) + } else { + _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), i8, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 88)))).Ftnum), iDb) + _sqlite3VdbeSetP4KeyInfo(tls, pParse, **(**uintptr)(__ccgo_up(bp + 88))) + } + } else { + k2 = uintptr(0) + break + } + goto _35 + _35: + ; + i8 = i8 + 1 + pFK1 = (*TFKey)(unsafe.Pointer(pFK1)).FpNextFrom + } + if pFK1 != 0 { + break + } + if (*TParse)(unsafe.Pointer(pParse)).FnTab < i8 { + (*TParse)(unsafe.Pointer(pParse)).FnTab = i8 + } + addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), 0) + i8 = int32(1) + pFK1 = (*(*struct { + FaddColOffset int32 + FpFKey uintptr + FpDfltList uintptr + })(unsafe.Pointer(pTab6 + 64))).FpFKey + for { + if !(pFK1 != 0) { + break + } + pParent = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, zDb) + **(**uintptr)(__ccgo_up(bp + 88)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) + if pParent != 0 { + x1 = _sqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+88, bp+96) + } + addrOk = _sqlite3VdbeMakeLabel(tls, pParse) + /* Generate code to read the child key values into registers + ** regRow..regRow+n. If any of the child key values are NULL, this + ** row cannot cause an FK violation. Jump directly to addrOk in + ** this case. */ + _sqlite3TouchRegister(tls, pParse, regRow+(*TFKey)(unsafe.Pointer(pFK1)).FnCol) + j3 = 0 + for { + if !(j3 < (*TFKey)(unsafe.Pointer(pFK1)).FnCol) { + break + } + if **(**uintptr)(__ccgo_up(bp + 96)) != 0 { + v2 = **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 96)) + uintptr(j3)*4)) + } else { + v2 = (*(*TsColMap)(unsafe.Pointer(pFK1 + 64 + uintptr(j3)*16))).FiFrom + } + iCol = v2 + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab6, 0, iCol, regRow+j3) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regRow+j3, addrOk) + goto _37 + _37: + ; + j3 = j3 + 1 + } + /* Generate code to query the parent index for a matching parent + ** key. If a match is found, jump to addrOk. */ + if **(**uintptr)(__ccgo_up(bp + 88)) != 0 { + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), regRow, (*TFKey)(unsafe.Pointer(pFK1)).FnCol, 0, _sqlite3IndexAffinityStr(tls, db, **(**uintptr)(__ccgo_up(bp + 88))), (*TFKey)(unsafe.Pointer(pFK1)).FnCol) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), i8, addrOk, regRow, (*TFKey)(unsafe.Pointer(pFK1)).FnCol) + } else { + if pParent != 0 { + jmp = _sqlite3VdbeCurrentAddr(tls, v) + int32(2) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), i8, jmp, regRow) + _sqlite3VdbeGoto(tls, v, addrOk) + } + } + /* Generate code to report an FK violation to the caller. */ + if (*TTable)(unsafe.Pointer(pTab6)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), 0, regResult+int32(1)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regResult+int32(1)) + } + _sqlite3VdbeMultiLoad(tls, v, regResult+int32(2), __ccgo_ts+19393, libc.VaList(bp+176, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, i8-int32(1))) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), regResult, int32(4)) + _sqlite3VdbeResolveLabel(tls, v, addrOk) + _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 96))) + goto _36 + _36: + ; + i8 = i8 + 1 + pFK1 = (*TFKey)(unsafe.Pointer(pFK1)).FpNextFrom + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), 0, addrTop+int32(1)) + _sqlite3VdbeJumpHere(tls, v, addrTop) + } + break + /* Reinstall the LIKE and GLOB functions. The variant of LIKE + ** used will be case sensitive or not depending on the RHS. + */ + fallthrough + case int32(PragTyp_CASE_SENSITIVE_LIKE): + if zRight != 0 { + _sqlite3RegisterLikeFunctions(tls, db, libc.Int32FromUint8(_sqlite3GetBoolean(tls, zRight, uint8(0)))) + } + break + /* PRAGMA integrity_check + ** PRAGMA integrity_check(N) + ** PRAGMA quick_check + ** PRAGMA quick_check(N) + ** + ** Verify the integrity of the database. + ** + ** The "quick_check" is reduced version of + ** integrity_check designed to detect most database corruption + ** without the overhead of cross-checking indexes. Quick_check + ** is linear time whereas integrity_check is O(NlogN). + ** + ** The maximum number of errors is 100 by default. A different default + ** can be specified using a numeric parameter N. + ** + ** Or, the parameter N can be the name of a table. In that case, only + ** the one table named is verified. The freelist is only verified if + ** the named table is "sqlite_schema" (or one of its aliases). + ** + ** All schemas are checked by default. To check just a single + ** schema, use the form: + ** + ** PRAGMA schema.integrity_check; + */ + fallthrough + case int32(PragTyp_INTEGRITY_CHECK): + pObjTab = uintptr(0) /* Check only this one table, if not NULL */ + isQuick = libc.BoolInt32(libc.Int32FromUint8(_sqlite3UpperToLower[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zLeft)))]) == int32('q')) + /* If the PRAGMA command was of the form "PRAGMA .integrity_check", + ** then iDb is set to the index of the database identified by . + ** In this case, the integrity of database iDb only is verified by + ** the VDBE created below. + ** + ** Otherwise, if the command was simply "PRAGMA integrity_check" (or + ** "PRAGMA quick_check"), then iDb is set to 0. In this case, set iDb + ** to -1 here, to indicate that the VDBE should verify the integrity + ** of all attached databases. */ + if (*TToken)(unsafe.Pointer(pId2)).Fz == uintptr(0) { + iDb = -int32(1) + } + /* Initialize the VDBE program */ + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) + /* Set the maximum error count */ + **(**int32)(__ccgo_up(bp + 104)) = int32(SQLITE_INTEGRITY_CHECK_ERROR_MAX) + if zRight != 0 { + if _sqlite3GetInt32(tls, (*TToken)(unsafe.Pointer(pValue)).Fz, bp+104) != 0 { + if **(**int32)(__ccgo_up(bp + 104)) <= 0 { + **(**int32)(__ccgo_up(bp + 104)) = int32(SQLITE_INTEGRITY_CHECK_ERROR_MAX) + } + } else { + if iDb >= 0 { + v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + } else { + v1 = uintptr(0) + } + pObjTab = _sqlite3LocateTable(tls, pParse, uint32(0), zRight, v1) + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp + 104))-int32(1), int32(1)) /* reg[1] holds errors left */ + /* Do an integrity check on each database file */ + i9 = 0 + for { + if !(i9 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } /* Array of root page numbers of all btrees */ + cnt = 0 /* Number of entries in aRoot[] */ + if libc.Bool(OMIT_TEMPDB != 0) && i9 == int32(1) { + goto _40 + } + if iDb >= 0 && i9 != iDb { + goto _40 + } + _sqlite3CodeVerifySchema(tls, pParse, i9) + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) /* tag-20230327-1 */ + /* Do an integrity check of the B-Tree + ** + ** Begin by finding the root pages numbers + ** for all tables and indices in the database. + */ + pTbls = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i9)*32))).FpSchema + 8 + cnt = 0 + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab7 = (*THashElem)(unsafe.Pointer(x2)).Fdata /* Number of indexes on pTab */ + if _tableSkipIntegrityCheck(tls, pTab7, pObjTab) != 0 { + goto _41 + } + if (*TTable)(unsafe.Pointer(pTab7)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + cnt = cnt + 1 + } + nIdx = 0 + pIdx3 = (*TTable)(unsafe.Pointer(pTab7)).FpIndex + for { + if !(pIdx3 != 0) { + break + } + cnt = cnt + 1 + goto _42 + _42: + ; + pIdx3 = (*TIndex)(unsafe.Pointer(pIdx3)).FpNext + nIdx = nIdx + 1 + } + goto _41 + _41: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + if cnt == 0 { + goto _40 + } + if pObjTab != 0 { + cnt = cnt + 1 + } + aRoot = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(cnt+libc.Int32FromInt32(1)))) + if aRoot == uintptr(0) { + break + } + cnt = 0 + if pObjTab != 0 { + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = 0 + } + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab8 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab8, pObjTab) != 0 { + goto _44 + } + if (*TTable)(unsafe.Pointer(pTab8)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab8)).Ftnum) + } + pIdx4 = (*TTable)(unsafe.Pointer(pTab8)).FpIndex + for { + if !(pIdx4 != 0) { + break + } + cnt = cnt + 1 + v2 = cnt + **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx4)).Ftnum) + goto _46 + _46: + ; + pIdx4 = (*TIndex)(unsafe.Pointer(pIdx4)).FpNext + } + goto _44 + _44: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + **(**int32)(__ccgo_up(aRoot)) = cnt + /* Make sure sufficient number of registers have been allocated */ + _sqlite3TouchRegister(tls, pParse, int32(8)+cnt) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, int32(8), int32(8)+cnt) + _sqlite3ClearTempRegCache(tls, pParse) + /* Do the b-tree integrity checks */ + _sqlite3VdbeAddOp4(tls, v, int32(OP_IntegrityCk), int32(1), cnt, int32(8), aRoot, -int32(15)) + _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(i9)) + addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), int32(2)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+19397, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i9)*32))).FzDbSName)), -int32(7)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(2), int32(3), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, addr1) + /* Check that the indexes all have the right number of rows */ + if pObjTab != 0 { + v2 = int32(1) + } else { + v2 = 0 + } + cnt = v2 + _sqlite3VdbeLoadString(tls, v, int32(2), __ccgo_ts+19421) + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + iTab = 0 + pTab9 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab9, pObjTab) != 0 { + goto _49 + } + if (*TTable)(unsafe.Pointer(pTab9)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + v2 = cnt + cnt = cnt + 1 + iTab = v2 + } else { + iTab = cnt + pIdx5 = (*TTable)(unsafe.Pointer(pTab9)).FpIndex + for { + if !(pIdx5 != 0) { + break + } + if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx5 + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + break + } + iTab = iTab + 1 + goto _51 + _51: + ; + pIdx5 = (*TIndex)(unsafe.Pointer(pIdx5)).FpNext + } + } + pIdx5 = (*TTable)(unsafe.Pointer(pTab9)).FpIndex + for { + if !(pIdx5 != 0) { + break + } + if (*TIndex)(unsafe.Pointer(pIdx5)).FpPartIdxWhere == uintptr(0) { + addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), int32(8)+cnt, 0, int32(8)+iTab) + _sqlite3VdbeLoadString(tls, v, int32(4), (*TIndex)(unsafe.Pointer(pIdx5)).FzName) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(2), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, addr1) + } + cnt = cnt + 1 + goto _52 + _52: + ; + pIdx5 = (*TIndex)(unsafe.Pointer(pIdx5)).FpNext + } + goto _49 + _49: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + /* Make sure all the indices are constructed correctly. + */ + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab10 = (*THashElem)(unsafe.Pointer(x2)).Fdata + pPrior = uintptr(0) + r1 = -int32(1) /* Maximum non-virtual column number */ + if _tableSkipIntegrityCheck(tls, pTab10, pObjTab) != 0 { + goto _53 + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab10)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + goto _53 + } + if isQuick != 0 || (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + pPk1 = uintptr(0) + r2 = 0 + } else { + pPk1 = _sqlite3PrimaryKeyIndex(tls, pTab10) + r2 = _sqlite3GetTempRange(tls, pParse, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), int32(1), r2, r2+libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)-int32(1)) + } + _sqlite3OpenTableAndIndices(tls, pParse, pTab10, int32(OP_OpenRead), uint8(0), int32(1), uintptr(0), bp+108, bp+112) + /* reg[7] counts the number of entries in the table. + ** reg[8+i] counts the number of entries in the i-th index + */ + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, int32(7)) + j4 = 0 + pIdx6 = (*TTable)(unsafe.Pointer(pTab10)).FpIndex + for { + if !(pIdx6 != 0) { + break + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, int32(8)+j4) /* index entries counter */ + goto _54 + _54: + ; + pIdx6 = (*TIndex)(unsafe.Pointer(pIdx6)).FpNext + j4 = j4 + 1 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), **(**int32)(__ccgo_up(bp + 108)), 0) + loopTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(7), int32(1)) + /* Fetch the right-most column from the table. This will cause + ** the entire record header to be parsed and sanity checked. It + ** will also prepopulate the cursor column cache that is used + ** by the OP_IsType code, so it is a required step. + */ + if (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + mxCol = -int32(1) + j4 = 0 + for { + if !(j4 < int32((*TTable)(unsafe.Pointer(pTab10)).FnCol)) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { + mxCol = mxCol + 1 + } + goto _55 + _55: + ; + j4 = j4 + 1 + } + if mxCol == int32((*TTable)(unsafe.Pointer(pTab10)).FiPKey) { + mxCol = mxCol - 1 + } + } else { + /* COLFLAG_VIRTUAL columns are not included in the WITHOUT ROWID + ** PK index column-count, so there is no need to account for them + ** in this case. */ + mxCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(_sqlite3PrimaryKeyIndex(tls, pTab10))).FnColumn) - int32(1) + } + if mxCol >= 0 { + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 108)), mxCol, int32(3)) + _sqlite3VdbeTypeofColumn(tls, v, int32(3)) + } + if !(isQuick != 0) { + if pPk1 != 0 { + a1 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxGT), **(**int32)(__ccgo_up(bp + 108)), 0, r2, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), r2) + zErr = _sqlite3MPrintf(tls, db, __ccgo_ts+19450, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr, -int32(7)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, a1) + _sqlite3VdbeJumpHere(tls, v, a1+int32(1)) + j4 = 0 + for { + if !(j4 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) { + break + } + _sqlite3ExprCodeLoadIndexColumn(tls, pParse, pPk1, **(**int32)(__ccgo_up(bp + 108)), j4, r2+j4) + goto _56 + _56: + ; + j4 = j4 + 1 + } + } + } + /* Verify datatypes for all columns: + ** + ** (1) NOT NULL columns may not contain a NULL + ** (2) Datatype must be exact for non-ANY columns in STRICT tables + ** (3) Datatype for TEXT columns in non-STRICT tables must be + ** NULL, TEXT, or BLOB. + ** (4) Datatype for numeric columns in non-STRICT tables must not + ** be a TEXT value that can be losslessly converted to numeric. + */ + bStrict = libc.BoolInt32((*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_Strict) != uint32(0)) + j4 = 0 + for { + if !(j4 < int32((*TTable)(unsafe.Pointer(pTab10)).FnCol)) { + break + } + pCol1 = (*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16 /* Check datatypes (besides NOT NULL) */ + if j4 == int32((*TTable)(unsafe.Pointer(pTab10)).FiPKey) { + goto _57 + } + if bStrict != 0 { + doTypeCheck = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4)) > int32(COLTYPE_ANY)) + } else { + doTypeCheck = libc.BoolInt32(int32((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) > int32(SQLITE_AFF_BLOB)) + } + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf>>0)) == 0 && !(doTypeCheck != 0) { + goto _57 + } + /* Compute the operands that will be needed for OP_IsType */ + p4 = int32(SQLITE_NULL) + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab10, **(**int32)(__ccgo_up(bp + 108)), j4, int32(3)) + p11 = -int32(1) + p3 = int32(3) + } else { + if (*TColumn)(unsafe.Pointer(pCol1)).FiDflt != 0 { + **(**uintptr)(__ccgo_up(bp + 120)) = uintptr(0) + _sqlite3ValueFromExpr(tls, db, _sqlite3ColumnExpr(tls, pTab10, pCol1), (*Tsqlite3)(unsafe.Pointer(db)).Fenc, libc.Uint8FromInt8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity), bp+120) + if **(**uintptr)(__ccgo_up(bp + 120)) != 0 { + p4 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 120))) + _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp + 120))) + } + } + p11 = **(**int32)(__ccgo_up(bp + 108)) + if !((*TTable)(unsafe.Pointer(pTab10)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { + p3 = _sqlite3TableColumnToIndex(tls, _sqlite3PrimaryKeyIndex(tls, pTab10), j4) + } else { + p3 = int32(_sqlite3TableColumnToStorage(tls, pTab10, int16(j4))) + } + } + labelError = _sqlite3VdbeMakeLabel(tls, pParse) + labelOk = _sqlite3VdbeMakeLabel(tls, pParse) + if int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf>>0)) != 0 { + jmp2 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + if p11 < 0 { + _sqlite3VdbeChangeP5(tls, v, uint16(0x0f)) /* INT, REAL, TEXT, or BLOB */ + jmp3 = jmp2 + } else { + _sqlite3VdbeChangeP5(tls, v, uint16(0x0d)) /* INT, TEXT, or BLOB */ + /* OP_IsType does not detect NaN values in the database file + ** which should be treated as a NULL. So if the header type + ** is REAL, we have to load the actual data using OP_Column + ** to reliably determine if the value is a NULL. */ + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), p11, p3, int32(3)) + _sqlite3ColumnDefault(tls, v, pTab10, j4, int32(3)) + jmp3 = _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), int32(3), labelOk) + } + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19486, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (*TColumn)(unsafe.Pointer(pCol1)).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + if doTypeCheck != 0 { + _sqlite3VdbeGoto(tls, v, labelError) + _sqlite3VdbeJumpHere(tls, v, jmp2) + _sqlite3VdbeJumpHere(tls, v, jmp3) + } else { + /* VDBE byte code will fall thru */ + } + } + if bStrict != 0 && doTypeCheck != 0 { + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(_aStdTypeMask[int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4))-int32(1)])) + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19506, libc.VaList(bp+176, _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4))-int32(1)], (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } else { + if !(bStrict != 0) && int32((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) == int32(SQLITE_AFF_TEXT) { + /* (3) Datatype for TEXT columns in non-STRICT tables must be + ** NULL, TEXT, or BLOB. */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1c)) /* NULL, TEXT, or BLOB */ + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19528, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } else { + if !(bStrict != 0) && int32((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) { + /* (4) Datatype for numeric columns in non-STRICT tables must not + ** be a TEXT value that can be converted to numeric. */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1b)) /* NULL, INT, FLOAT, or BLOB */ + if p11 >= 0 { + _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab10, **(**int32)(__ccgo_up(bp + 108)), j4, int32(3)) + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), int32(3), int32(1), 0, __ccgo_ts+19551, -int32(1)) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), -int32(1), labelOk, int32(3), p4) + _sqlite3VdbeChangeP5(tls, v, uint16(0x1c)) /* NULL, TEXT, or BLOB */ + zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19553, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) + } + } + } + _sqlite3VdbeResolveLabel(tls, v, labelError) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, labelOk) + goto _57 + _57: + ; + j4 = j4 + 1 + } + /* Verify CHECK constraints */ + if (*TTable)(unsafe.Pointer(pTab10)).FpCheck != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_IgnoreChecks) == uint64(0) { + pCheck = _sqlite3ExprListDup(tls, db, (*TTable)(unsafe.Pointer(pTab10)).FpCheck, 0) + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { + addrCkFault = _sqlite3VdbeMakeLabel(tls, pParse) + addrCkOk = _sqlite3VdbeMakeLabel(tls, pParse) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = **(**int32)(__ccgo_up(bp + 108)) + int32(1) + k3 = (*TExprList)(unsafe.Pointer(pCheck)).FnExpr - int32(1) + for { + if !(k3 > 0) { + break + } + _sqlite3ExprIfFalse(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(k3)*32))).FpExpr, addrCkFault, 0) + goto _58 + _58: + ; + k3 = k3 - 1 + } + _sqlite3ExprIfTrue(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pCheck + 8))).FpExpr, addrCkOk, int32(SQLITE_JUMPIFNULL)) + _sqlite3VdbeResolveLabel(tls, v, addrCkFault) + (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 + zErr2 = _sqlite3MPrintf(tls, db, __ccgo_ts+19573, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr2, -int32(7)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, addrCkOk) + } + _sqlite3ExprListDelete(tls, db, pCheck) + } + if !(isQuick != 0) { /* Omit the remaining tests for quick_check */ + /* Validate index entries for the current row */ + j4 = 0 + pIdx6 = (*TTable)(unsafe.Pointer(pTab10)).FpIndex + for { + if !(pIdx6 != 0) { + break + } + ckUniq = _sqlite3VdbeMakeLabel(tls, pParse) + if pPk1 == pIdx6 { + goto _59 + } + r1 = _sqlite3GenerateIndexKey(tls, pParse, pIdx6, **(**int32)(__ccgo_up(bp + 108)), 0, 0, bp+128, pPrior, r1) + pPrior = pIdx6 + _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(8)+j4, int32(1)) /* increment entry count */ + /* Verify that an index entry exists for the current table row */ + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), **(**int32)(__ccgo_up(bp + 112))+j4, ckUniq, r1, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnColumn)) + jmp21 = _sqlite3VdbeAddOp3(tls, v, int32(OP_IFindKey), **(**int32)(__ccgo_up(bp + 112))+j4, ckUniq, r1) + _sqlite3VdbeChangeP4(tls, v, -int32(1), pIdx6, -int32(6)) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+19603, libc.VaList(bp+176, (*TIndex)(unsafe.Pointer(pIdx6)).FzName)), -int32(7)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, ckUniq) + _sqlite3VdbeJumpHere(tls, v, jmp21) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19662) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19667) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(3), int32(3)) + jmp5 = _sqlite3VdbeLoadString(tls, v, int32(4), (*TIndex)(unsafe.Pointer(pIdx6)).FzName) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(3), int32(3)) + jmp4 = _integrityCheckResultRow(tls, v) + _sqlite3VdbeResolveLabel(tls, v, ckUniq) + /* The OP_IdxRowid opcode is an optimized version of OP_Column + ** that extracts the rowid off the end of the index record. + ** But it only works correctly if index record does not have + ** any extra bytes at the end. Verify that this is the case. */ + if (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), **(**int32)(__ccgo_up(bp + 112))+j4, int32(3)) + jmp7 = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), int32(3), 0, r1+libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnColumn)-int32(1)) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19688) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19724) + _sqlite3VdbeGoto(tls, v, jmp5-int32(1)) + _sqlite3VdbeJumpHere(tls, v, jmp7) + } + /* Any indexed columns with non-BINARY collations must still hold + ** the exact same text value as the table. */ + label6 = 0 + kk = 0 + for { + if !(kk < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) { + break + } + if **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx6)).FazColl + uintptr(kk)*8)) == uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) { + goto _60 + } + if label6 == 0 { + label6 = _sqlite3VdbeMakeLabel(tls, pParse) + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 112))+j4, kk, int32(3)) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Ne), int32(3), label6, r1+kk) + goto _60 + _60: + ; + kk = kk + 1 + } + if label6 != 0 { + jmp6 = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) + _sqlite3VdbeResolveLabel(tls, v, label6) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19662) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) + _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19735) + _sqlite3VdbeGoto(tls, v, jmp5-int32(1)) + _sqlite3VdbeJumpHere(tls, v, jmp6) + } + /* For UNIQUE indexes, verify that only one entry exists with the + ** current key. The entry is unique if (1) any column is NULL + ** or (2) the next entry has a different key */ + if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx6)).FonError) != OE_None { + uniqOk = _sqlite3VdbeMakeLabel(tls, pParse) + kk = 0 + for { + if !(kk < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) { + break + } + iCol1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx6)).FaiColumn + uintptr(kk)*2))) + if iCol1 >= 0 && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(iCol1)*16 + 8))&0xf>>0)) != 0 { + goto _61 + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), r1+kk, uniqOk) + goto _61 + _61: + ; + kk = kk + 1 + } + jmp61 = _sqlite3VdbeAddOp1(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 112))+j4) + _sqlite3VdbeGoto(tls, v, uniqOk) + _sqlite3VdbeJumpHere(tls, v, jmp61) + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxGT), **(**int32)(__ccgo_up(bp + 112))+j4, uniqOk, r1, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) + _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19762) + _sqlite3VdbeGoto(tls, v, jmp5) + _sqlite3VdbeResolveLabel(tls, v, uniqOk) + } + _sqlite3VdbeJumpHere(tls, v, jmp4) + _sqlite3ResolvePartIdxLabel(tls, pParse, **(**int32)(__ccgo_up(bp + 128))) + goto _59 + _59: + ; + pIdx6 = (*TIndex)(unsafe.Pointer(pIdx6)).FpNext + j4 = j4 + 1 + } + } + _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 108)), loopTop) + _sqlite3VdbeJumpHere(tls, v, loopTop-int32(1)) + if pPk1 != 0 { + _sqlite3ReleaseTempRange(tls, pParse, r2, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) + } + goto _53 + _53: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + /* Second pass to invoke the xIntegrity method on all virtual + ** tables. + */ + x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst + for { + if !(x2 != 0) { + break + } + pTab11 = (*THashElem)(unsafe.Pointer(x2)).Fdata + if _tableSkipIntegrityCheck(tls, pTab11, pObjTab) != 0 { + goto _62 + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab11)).FeTabType) == TABTYP_NORM { + goto _62 + } + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab11)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { + goto _62 + } + if int32((*TTable)(unsafe.Pointer(pTab11)).FnCol) <= 0 { + zMod = **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).FazArg)) + if _sqlite3HashFind(tls, db+576, zMod) == uintptr(0) { + goto _62 + } + } + _sqlite3ViewGetColumnNames(tls, pParse, pTab11) + if (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).Fp == uintptr(0) { + goto _62 + } + pVTab = (*TVTable)(unsafe.Pointer((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab11 + 64))).Fp)).FpVtab + if pVTab == uintptr(0) { + goto _62 + } + if (*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule == uintptr(0) { + goto _62 + } + if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule)).FiVersion < int32(4) { + goto _62 + } + if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule)).FxIntegrity == uintptr(0) { + goto _62 + } + _sqlite3VdbeAddOp3(tls, v, int32(OP_VCheck), i9, int32(3), isQuick) + (*TTable)(unsafe.Pointer(pTab11)).FnTabRef = (*TTable)(unsafe.Pointer(pTab11)).FnTabRef + 1 + _sqlite3VdbeAppendP4(tls, v, pTab11, -int32(17)) + a11 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), int32(3)) + _integrityCheckResultRow(tls, v) + _sqlite3VdbeJumpHere(tls, v, a11) + goto _62 + goto _62 + _62: + ; + x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext + } + goto _40 + _40: + ; + i9 = i9 + 1 + } + aOp2 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(28)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_endCode)), _iLn21) + if aOp2 != 0 { + (**(**TVdbeOp)(__ccgo_up(aOp2))).Fp2 = int32(1) - **(**int32)(__ccgo_up(bp + 104)) + (**(**TVdbeOp)(__ccgo_up(aOp2 + 2*24))).Fp4type = int8(-libc.Int32FromInt32(1)) + *(*uintptr)(unsafe.Pointer(aOp2 + 2*24 + 16)) = __ccgo_ts + 19789 + (**(**TVdbeOp)(__ccgo_up(aOp2 + 5*24))).Fp4type = int8(-libc.Int32FromInt32(1)) + *(*uintptr)(unsafe.Pointer(aOp2 + 5*24 + 16)) = _sqlite3ErrStr(tls, int32(SQLITE_CORRUPT)) + } + _sqlite3VdbeChangeP3(tls, v, 0, _sqlite3VdbeCurrentAddr(tls, v)-int32(2)) + break + /* + ** PRAGMA encoding + ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" + ** + ** In its first form, this pragma returns the encoding of the main + ** database. If the database is not initialized, it is initialized now. + ** + ** The second form of this pragma is a no-op if the main database file + ** has not already been initialized. In this case it sets the default + ** encoding that will be used for the main database file if a new file + ** is created. If an existing main database file is opened, then the + ** default text encoding for the existing database is used. + ** + ** In all cases new databases created using the ATTACH command are + ** created to use the same default text encoding as the main database. If + ** the main database has not been initialized and/or created when ATTACH + ** is executed, this is done before the ATTACH operation. + ** + ** In the second form this pragma sets the text encoding to be used in + ** new database files created using this database handle. It is only + ** useful if invoked immediately after the main database i + */ + fallthrough + case int32(PragTyp_ENCODING): + if !(zRight != 0) { /* "PRAGMA encoding" */ + if _sqlite3ReadSchema(tls, pParse) != 0 { + goto pragma_out + } + _returnSingleText(tls, v, _encnames1[(*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc].FzName) + } else { /* "PRAGMA encoding = XXX" */ + /* Only change the value of sqlite.enc if the database handle is not + ** initialized. If the main database exists, the new sqlite.enc value + ** will be overwritten when the schema is next loaded. If it does not + ** already exists, it will be created to use the new encoding value. + */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_EncodingFixed) == uint32(0) { + pEnc = uintptr(unsafe.Pointer(&_encnames1)) + for { + if !((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName != 0) { + break + } + if 0 == _sqlite3StrICmp(tls, zRight, (*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName) { + if (*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).Fenc != 0 { + v2 = libc.Int32FromUint8((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).Fenc) + } else { + v2 = int32(SQLITE_UTF16LE) + } + enc = libc.Uint8FromInt32(v2) + (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).Fenc = enc + _sqlite3SetTextEncoding(tls, db, enc) + break + } + goto _63 + _63: + ; + pEnc += 16 + } + if !((*struct { + FzName uintptr + Fenc Tu8 + })(unsafe.Pointer(pEnc)).FzName != 0) { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19850, libc.VaList(bp+176, zRight)) + } + } + } + break + /* + ** PRAGMA [schema.]schema_version + ** PRAGMA [schema.]schema_version = + ** + ** PRAGMA [schema.]user_version + ** PRAGMA [schema.]user_version = + ** + ** PRAGMA [schema.]freelist_count + ** + ** PRAGMA [schema.]data_version + ** + ** PRAGMA [schema.]application_id + ** PRAGMA [schema.]application_id = + ** + ** The pragma's schema_version and user_version are used to set or get + ** the value of the schema-version and user-version, respectively. Both + ** the schema-version and the user-version are 32-bit signed integers + ** stored in the database header. + ** + ** The schema-cookie is usually only manipulated internally by SQLite. It + ** is incremented by SQLite whenever the database schema is modified (by + ** creating or dropping a table or index). The schema version is used by + ** SQLite each time a query is executed to ensure that the internal cache + ** of the schema used when compiling the SQL query matches the schema of + ** the database against which the compiled query is actually executed. + ** Subverting this mechanism by using "PRAGMA schema_version" to modify + ** the schema-version is potentially dangerous and may lead to program + ** crashes or database corruption. Use with caution! + ** + ** The user-version is not used internally by SQLite. It may be used by + ** applications for any purpose. + */ + fallthrough + case int32(PragTyp_HEADER_VALUE): + iCookie = libc.Int32FromUint64((*TPragmaName)(unsafe.Pointer(pPragma)).FiArg) /* Which cookie to read or write */ + _sqlite3VdbeUsesBtree(tls, v, iDb) + if zRight != 0 && libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_ReadOnly) == 0 { + aOp3 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_setCookie)), 0) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp3))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp2 = iCookie + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp3 = _sqlite3Atoi(tls, zRight) + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp5 = uint16(1) + if iCookie == int32(BTREE_SCHEMA_VERSION) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) { + /* Do not allow the use of PRAGMA schema_version=VALUE in defensive + ** mode. Change the OP_SetCookie opcode into a no-op. */ + (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fopcode = uint8(OP_Noop) + } + } else { + aOp4 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(12)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_readCookie)), 0) + if 0 != 0 { + break + } + (**(**TVdbeOp)(__ccgo_up(aOp4))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp4 + 1*24))).Fp1 = iDb + (**(**TVdbeOp)(__ccgo_up(aOp4 + 1*24))).Fp3 = iCookie + _sqlite3VdbeReusable(tls, v) + } + break + /* + ** PRAGMA compile_options + ** + ** Return the names of all compile-time options used in this build, + ** one option per row. + */ + fallthrough + case int32(PragTyp_COMPILE_OPTIONS): + i10 = 0 + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(1) + for { + v2 = i10 + i10 = i10 + 1 + v1 = Xsqlite3_compileoption_get(tls, v2) + zOpt = v1 + if !(v1 != uintptr(0)) { + break + } + _sqlite3VdbeLoadString(tls, v, int32(1), zOpt) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) + } + _sqlite3VdbeReusable(tls, v) + break + /* + ** PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate + ** + ** Checkpoint the database. + */ + fallthrough + case int32(PragTyp_WAL_CHECKPOINT): + if (*TToken)(unsafe.Pointer(pId2)).Fz != 0 { + v2 = iDb + } else { + v2 = libc.Int32FromInt32(SQLITE_MAX_ATTACHED) + libc.Int32FromInt32(2) + } + iBt = v2 + eMode2 = SQLITE_CHECKPOINT_PASSIVE + if zRight != 0 { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19016) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_FULL) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19875) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_RESTART) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19169) == 0 { + eMode2 = int32(SQLITE_CHECKPOINT_TRUNCATE) + } else { + if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19883) == 0 { + eMode2 = -int32(1) + } + } + } + } + } + (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Checkpoint), iBt, eMode2, int32(1)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(3)) + break + /* + ** PRAGMA wal_autocheckpoint + ** PRAGMA wal_autocheckpoint = N + ** + ** Configure a database connection to automatically checkpoint a database + ** after accumulating N frames in the log. Or query for the current value + ** of N. + */ + fallthrough + case int32(PragTyp_WAL_AUTOCHECKPOINT): + if zRight != 0 { + Xsqlite3_wal_autocheckpoint(tls, db, _sqlite3Atoi(tls, zRight)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxWalCallback == __ccgo_fp(_sqlite3WalDefaultHook) { + v2 = int32(int64((*Tsqlite3)(unsafe.Pointer(db)).FpWalArg)) + } else { + v2 = 0 + } + _returnSingleInt(tls, v, int64(v2)) + break + /* + ** PRAGMA shrink_memory + ** + ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database + ** connection on which it is invoked to free up as much memory as it + ** can, by calling sqlite3_db_release_memory(). + */ + fallthrough + case int32(PragTyp_SHRINK_MEMORY): + Xsqlite3_db_release_memory(tls, db) + break + /* + ** PRAGMA optimize + ** PRAGMA optimize(MASK) + ** PRAGMA schema.optimize + ** PRAGMA schema.optimize(MASK) + ** + ** Attempt to optimize the database. All schemas are optimized in the first + ** two forms, and only the specified schema is optimized in the latter two. + ** + ** The details of optimizations performed by this pragma are expected + ** to change and improve over time. Applications should anticipate that + ** this pragma will perform new optimizations in future releases. + ** + ** The optional argument is a bitmask of optimizations to perform: + ** + ** 0x00001 Debugging mode. Do not actually perform any optimizations + ** but instead return one line of text for each optimization + ** that would have been done. Off by default. + ** + ** 0x00002 Run ANALYZE on tables that might benefit. On by default. + ** See below for additional information. + ** + ** 0x00010 Run all ANALYZE operations using an analysis_limit that + ** is the lessor of the current analysis_limit and the + ** SQLITE_DEFAULT_OPTIMIZE_LIMIT compile-time option. + ** The default value of SQLITE_DEFAULT_OPTIMIZE_LIMIT is + ** currently (2024-02-19) set to 2000, which is such that + ** the worst case run-time for PRAGMA optimize on a 100MB + ** database will usually be less than 100 milliseconds on + ** a RaspberryPI-4 class machine. On by default. + ** + ** 0x10000 Look at tables to see if they need to be reanalyzed + ** due to growth or shrinkage even if they have not been + ** queried during the current connection. Off by default. + ** + ** The default MASK is and always shall be 0x0fffe. In the current + ** implementation, the default mask only covers the 0x00002 optimization, + ** though additional optimizations that are covered by 0x0fffe might be + ** added in the future. Optimizations that are off by default and must + ** be explicitly requested have masks of 0x10000 or greater. + ** + ** DETERMINATION OF WHEN TO RUN ANALYZE + ** + ** In the current implementation, a table is analyzed if only if all of + ** the following are true: + ** + ** (1) MASK bit 0x00002 is set. + ** + ** (2) The table is an ordinary table, not a virtual table or view. + ** + ** (3) The table name does not begin with "sqlite_". + ** + ** (4) One or more of the following is true: + ** (4a) The 0x10000 MASK bit is set. + ** (4b) One or more indexes on the table lacks an entry + ** in the sqlite_stat1 table. + ** (4c) The query planner used sqlite_stat1-style statistics for one + ** or more indexes of the table at some point during the lifetime + ** of the current connection. + ** + ** (5) One or more of the following is true: + ** (5a) One or more indexes on the table lacks an entry + ** in the sqlite_stat1 table. (Same as 4a) + ** (5b) The number of rows in the table has increased or decreased by + ** 10-fold. In other words, the current size of the table is + ** 10 times larger than the size in sqlite_stat1 or else the + ** current size is less than 1/10th the size in sqlite_stat1. + ** + ** The rules for when tables are analyzed are likely to change in + ** future releases. Future versions of SQLite might accept a string + ** literal argument to this pragma that contains a mnemonic description + ** of the options rather than a bitmap. + */ + fallthrough + case int32(PragTyp_OPTIMIZE): /* Analysis limit to use */ + nCheck = 0 /* Number of tables to be optimized */ + nBtree = 0 /* Number of indexes on the current table */ + if zRight != 0 { + opMask = libc.Uint32FromInt32(_sqlite3Atoi(tls, zRight)) + if opMask&uint32(0x02) == uint32(0) { + break + } + } else { + opMask = uint32(0xfffe) + } + if opMask&uint32(0x10) == uint32(0) { + nLimit = 0 + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit > 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit < int32(SQLITE_DEFAULT_OPTIMIZE_LIMIT) { + nLimit = 0 + } else { + nLimit = int32(SQLITE_DEFAULT_OPTIMIZE_LIMIT) + } + } + v1 = pParse + 56 + v2 = *(*int32)(unsafe.Pointer(v1)) + *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 + iTabCur = v2 + if zDb != 0 { + v2 = iDb + } else { + v2 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) + } + iDbLast = v2 + for { + if !(iDb <= iDbLast) { + break + } + if iDb == int32(1) { + goto _71 + } + _sqlite3CodeVerifySchema(tls, pParse, iDb) + pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + k4 = (*THash)(unsafe.Pointer(pSchema + 8)).Ffirst + for { + if !(k4 != 0) { + break + } + pTab12 = (*THashElem)(unsafe.Pointer(k4)).Fdata + /* This only works for ordinary tables */ + if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab12)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { + goto _73 + } + /* Do not scan system tables */ + if 0 == Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab12)).FzName, __ccgo_ts+6756, int32(7)) { + goto _73 + } + /* Find the size of the table as last recorded in sqlite_stat1. + ** If any index is unanalyzed, then the threshold is -1 to + ** indicate a new, unanalyzed index + */ + szThreshold = (*TTable)(unsafe.Pointer(pTab12)).FnRowLogEst + nIndex = 0 + pIdx7 = (*TTable)(unsafe.Pointer(pTab12)).FpIndex + for { + if !(pIdx7 != 0) { + break + } + nIndex = nIndex + 1 + if !(int32(uint32(*(*uint16)(unsafe.Pointer(pIdx7 + 100))&0x80>>7)) != 0) { + szThreshold = int16(-int32(1)) /* Always analyze if any index lacks statistics */ + } + goto _74 + _74: + ; + pIdx7 = (*TIndex)(unsafe.Pointer(pIdx7)).FpNext + } + /* If table pTab has not been used in a way that would benefit from + ** having analysis statistics during the current session, then skip it, + ** unless the 0x10000 MASK bit is set. */ + if (*TTable)(unsafe.Pointer(pTab12)).FtabFlags&uint32(TF_MaybeReanalyze) != uint32(0) { + /* Check for size change if stat1 has been used for a query */ + } else { + if opMask&uint32(0x10000) != 0 { + /* Check for size change if 0x10000 is set */ + } else { + if (*TTable)(unsafe.Pointer(pTab12)).FpIndex != uintptr(0) && int32(szThreshold) < 0 { + /* Do analysis if unanalyzed indexes exists */ + } else { + /* Otherwise, we can skip this table */ + goto _73 + } + } + } + nCheck = nCheck + 1 + if nCheck == int32(2) { + /* If ANALYZE might be invoked two or more times, hold a write + ** transaction for efficiency */ + _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) + } + nBtree = nBtree + (nIndex + int32(1)) + /* Reanalyze if the table is 10 times larger or smaller than + ** the last analysis. Unconditional reanalysis if there are + ** unanalyzed indexes. */ + _sqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab12, int32(OP_OpenRead)) + if int32(szThreshold) >= 0 { + iRange = int16(33) /* 10x size change */ + if int32(szThreshold) >= int32(iRange) { + v2 = int32(szThreshold) - int32(iRange) + } else { + v2 = -int32(1) + } + _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IfSizeBetween), iTabCur, libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3VdbeCurrentAddr(tls, v)+int32(2))+opMask&uint32(1)), v2, int32(szThreshold)+int32(iRange)) + } else { + _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iTabCur, libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3VdbeCurrentAddr(tls, v)+int32(2))+opMask&uint32(1))) + } + zSubSql = _sqlite3MPrintf(tls, db, __ccgo_ts+19888, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(pTab12)).FzName)) + if opMask&uint32(0x01) != 0 { + r11 = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, r11, 0, zSubSql, -int32(7)) + _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), r11, int32(1)) + } else { + if nLimit != 0 { + v2 = int32(0x02) + } else { + v2 = 00 + } + _sqlite3VdbeAddOp4(tls, v, int32(OP_SqlExec), v2, nLimit, 0, zSubSql, -int32(7)) + } + goto _73 + _73: + ; + k4 = (*THashElem)(unsafe.Pointer(k4)).Fnext + } + goto _71 + _71: + ; + iDb = iDb + 1 + } + _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) + /* In a schema with a large number of tables and indexes, scale back + ** the analysis_limit to avoid excess run-time in the worst case. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) && nLimit > 0 && nBtree > int32(100) { + nLimit = int32(100) * nLimit / nBtree + if nLimit < int32(100) { + nLimit = int32(100) + } + aOp5 = _sqlite3VdbeGetOp(tls, v, 0) + iEnd = _sqlite3VdbeCurrentAddr(tls, v) + iAddr1 = 0 + for { + if !(iAddr1 < iEnd) { + break + } + if libc.Int32FromUint8((**(**TVdbeOp)(__ccgo_up(aOp5 + uintptr(iAddr1)*24))).Fopcode) == int32(OP_SqlExec) { + (**(**TVdbeOp)(__ccgo_up(aOp5 + uintptr(iAddr1)*24))).Fp2 = nLimit + } + goto _77 + _77: + ; + iAddr1 = iAddr1 + 1 + } + } + break + /* + ** PRAGMA busy_timeout + ** PRAGMA busy_timeout = N + ** + ** Call sqlite3_busy_timeout(db, N). Return the current timeout value + ** if one is set. If no busy handler or a different busy handler is set + ** then 0 is returned. Setting the busy_timeout to 0 or negative + ** disables the timeout. + */ + /*case PragTyp_BUSY_TIMEOUT*/ + fallthrough + default: + if zRight != 0 { + Xsqlite3_busy_timeout(tls, db, _sqlite3Atoi(tls, zRight)) + } + _returnSingleInt(tls, v, int64((*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout)) + break + /* + ** PRAGMA soft_heap_limit + ** PRAGMA soft_heap_limit = N + ** + ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the + ** sqlite3_soft_heap_limit64() interface with the argument N, if N is + ** specified and is a non-negative integer. + ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always + ** returns the same integer that would be returned by the + ** sqlite3_soft_heap_limit64(-1) C-language function. + */ + fallthrough + case int32(PragTyp_SOFT_HEAP_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+136) == SQLITE_OK { + Xsqlite3_soft_heap_limit64(tls, **(**Tsqlite3_int64)(__ccgo_up(bp + 136))) + } + _returnSingleInt(tls, v, Xsqlite3_soft_heap_limit64(tls, int64(-int32(1)))) + break + /* + ** PRAGMA hard_heap_limit + ** PRAGMA hard_heap_limit = N + ** + ** Invoke sqlite3_hard_heap_limit64() to query or set the hard heap + ** limit. The hard heap limit can be activated or lowered by this + ** pragma, but not raised or deactivated. Only the + ** sqlite3_hard_heap_limit64() C-language API can raise or deactivate + ** the hard heap limit. This allows an application to set a heap limit + ** constraint that cannot be relaxed by an untrusted SQL script. + */ + fallthrough + case int32(PragTyp_HARD_HEAP_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+144) == SQLITE_OK { + iPrior = Xsqlite3_hard_heap_limit64(tls, int64(-int32(1))) + if **(**Tsqlite3_int64)(__ccgo_up(bp + 144)) > 0 && (iPrior == 0 || iPrior > **(**Tsqlite3_int64)(__ccgo_up(bp + 144))) { + Xsqlite3_hard_heap_limit64(tls, **(**Tsqlite3_int64)(__ccgo_up(bp + 144))) + } + } + _returnSingleInt(tls, v, Xsqlite3_hard_heap_limit64(tls, int64(-int32(1)))) + break + /* + ** PRAGMA threads + ** PRAGMA threads = N + ** + ** Configure the maximum number of worker threads. Return the new + ** maximum, which might be less than requested. + */ + fallthrough + case int32(PragTyp_THREADS): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+152) == SQLITE_OK && **(**Tsqlite3_int64)(__ccgo_up(bp + 152)) >= 0 { + Xsqlite3_limit(tls, db, int32(SQLITE_LIMIT_WORKER_THREADS), int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 152))&libc.Int64FromInt32(0x7fffffff))) + } + _returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, int32(SQLITE_LIMIT_WORKER_THREADS), -int32(1)))) + break + /* + ** PRAGMA analysis_limit + ** PRAGMA analysis_limit = N + ** + ** Configure the maximum number of rows that ANALYZE will examine + ** in each index that it looks at. Return the new limit. + */ + fallthrough + case int32(PragTyp_ANALYSIS_LIMIT): + if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+160) == SQLITE_OK && **(**Tsqlite3_int64)(__ccgo_up(bp + 160)) >= 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 160)) & libc.Int64FromInt32(0x7fffffff)) + } + _returnSingleInt(tls, v, int64((*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit)) /* IMP: R-57594-65522 */ + break + } /* End of the PRAGMA switch */ + /* The following block is a no-op unless SQLITE_DEBUG is defined. Its only + ** purpose is to execute assert() statements to verify that if the + ** PragFlg_NoColumns1 flag is set and the caller specified an argument + ** to the PRAGMA, the implementation has not added any OP_ResultRow + ** instructions to the VM. */ + if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns1) != 0 && zRight != 0 { + } + goto pragma_out +pragma_out: + ; + _sqlite3DbFree(tls, db, zLeft) + _sqlite3DbFree(tls, db, zRight) +} + +// C documentation +// +// /* +// ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. +// */ +func _sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags Tu32, pReprepare uintptr, ppStmt uintptr, pzTail uintptr) (r int32) { + bp := tls.Alloc(432) + defer tls.Free(432) + var i, mxLen, rc, v1 int32 + var pBt, pT, zDb, zSqlCopy uintptr + var _ /* sParse at bp+0 */ TParse + _, _, _, _, _, _, _, _ = i, mxLen, pBt, pT, rc, zDb, zSqlCopy, v1 + rc = SQLITE_OK /* Parsing context */ + /* sqlite3ParseObjectInit(&sParse, db); // inlined for performance */ + libc.Xmemset(tls, bp+uintptr(uint64(libc.UintptrFromInt32(0)+8)), 0, uint64(libc.UintptrFromInt32(0)+184)-uint64(libc.UintptrFromInt32(0)+8)) + libc.Xmemset(tls, bp+uintptr(uint64(libc.UintptrFromInt32(0)+280)), 0, libc.Uint64FromInt64(416)-uint64(libc.UintptrFromInt32(0)+280)) + (**(**TParse)(__ccgo_up(bp))).FpOuterParse = (*Tsqlite3)(unsafe.Pointer(db)).FpParse + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = bp + (**(**TParse)(__ccgo_up(bp))).Fdb = db + if pReprepare != 0 { + (**(**TParse)(__ccgo_up(bp))).FpReprepare = pReprepare + (**(**TParse)(__ccgo_up(bp))).Fexplain = libc.Uint8FromInt32(Xsqlite3_stmt_isexplain(tls, pReprepare)) + } else { + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3ErrorMsg(tls, bp, __ccgo_ts+1674, 0) + v1 = libc.Int32FromInt32(SQLITE_NOMEM) + rc = v1 + (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = v1 + goto end_prepare + } + /* For a long-term use prepared statement avoid the use of + ** lookaside memory. + */ + if prepFlags&uint32(SQLITE_PREPARE_PERSISTENT) != 0 { + (**(**TParse)(__ccgo_up(bp))).FdisableLookaside = (**(**TParse)(__ccgo_up(bp))).FdisableLookaside + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + } + (**(**TParse)(__ccgo_up(bp))).FprepFlags = uint8(prepFlags & uint32(0xff)) + /* Check to verify that it is possible to get a read lock on all + ** database schemas. The inability to get a read lock indicates that + ** some other database connection is holding a write-lock, which in + ** turn means that the other connection has made uncommitted changes + ** to the schema. + ** + ** Were we to proceed and prepare the statement against the uncommitted + ** schema changes and if those schema changes are subsequently rolled + ** back and different changes are made in their place, then when this + ** prepared statement goes to run the schema cookie would fail to detect + ** the schema change. Disaster would follow. + ** + ** This thread is currently holding mutexes on all Btrees (because + ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it + ** is not possible for another thread to start a new schema change + ** while this routine is running. Hence, we do not need to hold + ** locks on the schema, we just need to make sure nobody else is + ** holding them. + ** + ** Note that setting READ_UNCOMMITTED overrides most lock detection, + ** but it does *not* override schema lock detection, so this all still + ** works even if READ_UNCOMMITTED is set. + */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FnoSharedCache != 0) { + i = 0 + for { + if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt + if pBt != 0 { + rc = _sqlite3BtreeSchemaLocked(tls, pBt) + if rc != 0 { + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName + _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+20235, libc.VaList(bp+424, zDb)) + goto end_prepare + } + } + goto _2 + _2: + ; + i = i + 1 + } + } + if (*Tsqlite3)(unsafe.Pointer(db)).FpDisconnect != 0 { + _sqlite3VtabUnlockList(tls, db) + } + if nBytes >= 0 && (nBytes == 0 || int32(**(**int8)(__ccgo_up(zSql + uintptr(nBytes-int32(1))))) != 0) { + mxLen = **(**int32)(__ccgo_up(db + 136 + 1*4)) + if nBytes > mxLen { + _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_TOOBIG), __ccgo_ts+20265, 0) + rc = _sqlite3ApiExit(tls, db, int32(SQLITE_TOOBIG)) + goto end_prepare + } + zSqlCopy = _sqlite3DbStrNDup(tls, db, zSql, libc.Uint64FromInt32(nBytes)) + if zSqlCopy != 0 { + _sqlite3RunParser(tls, bp, zSqlCopy) + (**(**TParse)(__ccgo_up(bp))).FzTail = zSql + uintptr(int64((**(**TParse)(__ccgo_up(bp))).FzTail)-int64(zSqlCopy)) + _sqlite3DbFree(tls, db, zSqlCopy) + } else { + (**(**TParse)(__ccgo_up(bp))).FzTail = zSql + uintptr(nBytes) + } + } else { + _sqlite3RunParser(tls, bp, zSql) + } + if pzTail != 0 { + **(**uintptr)(__ccgo_up(pzTail)) = (**(**TParse)(__ccgo_up(bp))).FzTail + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { + _sqlite3VdbeSetSql(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe, zSql, int32(int64((**(**TParse)(__ccgo_up(bp))).FzTail)-int64(zSql)), uint8(prepFlags)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + (**(**TParse)(__ccgo_up(bp))).Frc = int32(SQLITE_NOMEM) + libc.SetBitFieldPtr16Uint32(bp+40, libc.Uint32FromInt32(0), 8, 0x100) + } + if (**(**TParse)(__ccgo_up(bp))).Frc != SQLITE_OK && (**(**TParse)(__ccgo_up(bp))).Frc != int32(SQLITE_DONE) { + if int32(Tbft(*(*uint16)(unsafe.Pointer(bp + 40))&0x100>>8)) != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { + _schemaIsValid(tls, bp) + } + if (**(**TParse)(__ccgo_up(bp))).FpVdbe != 0 { + _sqlite3VdbeFinalize(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe) + } + rc = (**(**TParse)(__ccgo_up(bp))).Frc + if (**(**TParse)(__ccgo_up(bp))).FzErrMsg != 0 { + _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+3944, libc.VaList(bp+424, (**(**TParse)(__ccgo_up(bp))).FzErrMsg)) + _sqlite3DbFree(tls, db, (**(**TParse)(__ccgo_up(bp))).FzErrMsg) + } else { + _sqlite3Error(tls, db, rc) + } + } else { + **(**uintptr)(__ccgo_up(ppStmt)) = (**(**TParse)(__ccgo_up(bp))).FpVdbe + rc = SQLITE_OK + _sqlite3ErrorClear(tls, db) + } + /* Delete any TriggerPrg structures allocated while parsing this statement. */ + for (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg != 0 { + pT = (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg + (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg = (*TTriggerPrg)(unsafe.Pointer(pT)).FpNext + _sqlite3DbFree(tls, db, pT) + } + goto end_prepare +end_prepare: + ; + _sqlite3ParseObjectReset(tls, bp) + return rc +} + +// C documentation +// +// /* +// ** This routine processes the join information for a SELECT statement. +// ** +// ** * A NATURAL join is converted into a USING join. After that, we +// ** do not need to be concerned with NATURAL joins and we only have +// ** think about USING joins. +// ** +// ** * ON and USING clauses result in extra terms being added to the +// ** WHERE clause to enforce the specified constraints. The extra +// ** WHERE clause terms will be tagged with EP_OuterON or +// ** EP_InnerON so that we know that they originated in ON/USING. +// ** +// ** The terms of a FROM clause are contained in the Select.pSrc structure. +// ** The left most table is the first entry in Select.pSrc. The right-most +// ** table is the last entry. The join operator is held in the entry to +// ** the right. Thus entry 1 contains the join operator for the join between +// ** entries 0 and 1. Any ON or USING clauses associated with the join are +// ** also attached to the right entry. +// ** +// ** This routine returns the number of errors encountered. +// */ +func _sqlite3ProcessJoin(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var db, pE1, pE2, pEq, pFuncArgs, pLeft, pList, pRight, pRightTab, pSrc, pUsing, zName, zName1 uintptr + var i, iRightCol, j, v2 int32 + var joinType Tu32 + var _ /* iLeft at bp+0 */ int32 + var _ /* iLeftCol at bp+4 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iRightCol, j, joinType, pE1, pE2, pEq, pFuncArgs, pLeft, pList, pRight, pRightTab, pSrc, pUsing, zName, zName1, v2 /* Right table being joined */ + pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc + pLeft = pSrc + 8 + pRight = pLeft + 1*80 + i = 0 + for { + if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc-int32(1)) { + break + } + pRightTab = (*TSrcItem)(unsafe.Pointer(pRight)).FpSTab + if (*TSrcItem)(unsafe.Pointer(pLeft)).FpSTab == uintptr(0) || pRightTab == uintptr(0) { + goto _1 + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&int32(JT_OUTER) != 0 { + v2 = int32(EP_OuterON) + } else { + v2 = int32(EP_InnerON) + } + joinType = libc.Uint32FromInt32(v2) + /* If this is a NATURAL join, synthesize an appropriate USING clause + ** to specify which columns should be joined. + */ + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&int32(JT_NATURAL) != 0 { + pUsing = uintptr(0) + if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x800>>11) != 0 || *(*uintptr)(unsafe.Pointer(pRight + 64)) != 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20314, libc.VaList(bp+16, 0)) + return int32(1) + } + j = 0 + for { + if !(j < int32((*TTable)(unsafe.Pointer(pRightTab)).FnCol)) { + break + } /* Name of column in the right table */ + if libc.Int32FromUint16((*TColumn)(unsafe.Pointer((*TTable)(unsafe.Pointer(pRightTab)).FaCol+uintptr(j)*16)).FcolFlags)&int32(COLFLAG_HIDDEN) != 0 { + goto _3 + } + zName = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*16))).FzCnName + if _tableAndColumnIndex(tls, pSrc, 0, i, zName, uintptr(0), uintptr(0), int32(1)) != 0 { + pUsing = _sqlite3IdListAppend(tls, pParse, pUsing, uintptr(0)) + if pUsing != 0 { + (*(*TIdList_item)(unsafe.Pointer(pUsing + 8 + uintptr((*TIdList)(unsafe.Pointer(pUsing)).FnId-int32(1))*8))).FzName = _sqlite3DbStrDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zName) + } + } + goto _3 + _3: + ; + j = j + 1 + } + if pUsing != 0 { + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 11, 0x800) + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 13, 0x2000) + *(*uintptr)(unsafe.Pointer(pRight + 64)) = pUsing + } + if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { + return int32(1) + } + } + /* Create extra terms on the WHERE clause for each column named + ** in the USING clause. Example: If the two tables to be joined are + ** A and B and the USING clause names X, Y, and Z, then add this + ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z + ** Report an error if any column mentioned in the USING clause is + ** not contained in both tables to be joined. + */ + if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x800>>11) != 0 { + pList = *(*uintptr)(unsafe.Pointer(pRight + 64)) + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + j = 0 + for { + if !(j < (*TIdList)(unsafe.Pointer(pList)).FnId) { + break + } /* Equality constraint. pE1 == pE2 */ + zName1 = (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(j)*8))).FzName + iRightCol = _sqlite3ColumnIndex(tls, pRightTab, zName1) + if iRightCol < 0 || _tableAndColumnIndex(tls, pSrc, 0, i, zName1, bp, bp+4, int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x2000>>13)) == 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20364, libc.VaList(bp+16, zName1)) + return int32(1) + } + pE1 = _sqlite3CreateColumnExpr(tls, db, pSrc, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4))) + _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(**(**int32)(__ccgo_up(bp)))*80, **(**int32)(__ccgo_up(bp + 4))) + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + /* This branch runs if the query contains one or more RIGHT or FULL + ** JOINs. If only a single table on the left side of this join + ** contains the zName column, then this branch is a no-op. + ** But if there are two or more tables on the left side + ** of the join, construct a coalesce() function that gathers all + ** such tables. Raise an error if more than one of those references + ** to zName is not also within a prior USING clause. + ** + ** We really ought to raise an error if there are two or more + ** non-USING references to zName on the left of an INNER or LEFT + ** JOIN. But older versions of SQLite do not do that, so we avoid + ** adding a new error so as to not break legacy applications. + */ + pFuncArgs = uintptr(0) /* Arguments to the coalesce() */ + **(**Tu32)(__ccgo_up(pE1 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + for _tableAndColumnIndex(tls, pSrc, **(**int32)(__ccgo_up(bp))+int32(1), i, zName1, bp, bp+4, int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x2000>>13)) != 0 { + if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(**(**int32)(__ccgo_up(bp)))*80 + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(**(**int32)(__ccgo_up(bp)))*80 + 64)), zName1) < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20428, libc.VaList(bp+16, zName1)) + break + } + pFuncArgs = _sqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1) + pE1 = _sqlite3CreateColumnExpr(tls, db, pSrc, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4))) + _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(**(**int32)(__ccgo_up(bp)))*80, **(**int32)(__ccgo_up(bp + 4))) + } + if pFuncArgs != 0 { + pFuncArgs = _sqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1) + pE1 = _sqlite3ExprFunction(tls, pParse, pFuncArgs, uintptr(unsafe.Pointer(&_tkCoalesce)), 0) + if pE1 != 0 { + (*TExpr)(unsafe.Pointer(pE1)).FaffExpr = int8(SQLITE_AFF_DEFER) + } + } + } else { + if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i+int32(1))*80))).Ffg.Fjointype)&int32(JT_LEFT) != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { + **(**Tu32)(__ccgo_up(pE1 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) + } + } + pE2 = _sqlite3CreateColumnExpr(tls, db, pSrc, i+int32(1), iRightCol) + _sqlite3SrcItemColumnUsed(tls, pRight, iRightCol) + pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), pE1, pE2) + if pEq != 0 { + **(**Tu32)(__ccgo_up(pEq + 4)) |= joinType + *(*int32)(unsafe.Pointer(pEq + 52)) = (*TExpr)(unsafe.Pointer(pE2)).FiTable + } + (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWhere, pEq) + goto _4 + _4: + ; + j = j + 1 + } + } else { + if *(*uintptr)(unsafe.Pointer(pRight + 64)) != 0 { + _sqlite3SetJoinExpr(tls, *(*uintptr)(unsafe.Pointer(pRight + 64)), (*TSrcItem)(unsafe.Pointer(pRight)).FiCursor, joinType) + (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWhere, *(*uintptr)(unsafe.Pointer(pRight + 64))) + *(*uintptr)(unsafe.Pointer(pRight + 64)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 12, 0x1000) + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_OnToWhere) + } + } + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pRightTab)).FeTabType) == int32(TABTYP_VTAB) && joinType == uint32(EP_OuterON) && *(*uintptr)(unsafe.Pointer(pRight + 48)) != 0 { + **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_OnToWhere) + } + goto _1 + _1: + ; + i = i + 1 + pRight += 80 + pLeft += 80 + } + return 0 +} + +// C documentation +// +// /* +// ** Run the parser on the given SQL string. +// */ +func _sqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr) (r int32) { + bp := tls.Alloc(1280) + defer tls.Free(1280) + var db, pEngine, pParentParse uintptr + var lastTokenParsed, nErr int32 + var mxSqlLen, n Ti64 + var _ /* sEngine at bp+8 */ TyyParser + var _ /* tokenType at bp+0 */ int32 + var _ /* x at bp+1240 */ TToken + _, _, _, _, _, _, _ = db, lastTokenParsed, mxSqlLen, n, nErr, pEngine, pParentParse + nErr = 0 /* The LEMON-generated LALR(1) parser */ + n = 0 /* type of the next token */ + lastTokenParsed = -int32(1) /* type of the previous token */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Max length of an SQL string */ + pParentParse = uintptr(0) /* Space to hold the Lemon-generated Parser object */ + mxSqlLen = int64(**(**int32)(__ccgo_up(db + 136 + 1*4))) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { + libc.AtomicStoreNInt32(db+432, libc.Int32FromInt32(0), libc.Int32FromInt32(__ATOMIC_RELAXED)) + } + (*TParse)(unsafe.Pointer(pParse)).Frc = SQLITE_OK + (*TParse)(unsafe.Pointer(pParse)).FzTail = zSql + pEngine = bp + 8 + _sqlite3ParserInit(tls, pEngine, pParse) + pParentParse = (*Tsqlite3)(unsafe.Pointer(db)).FpParse + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = pParse + for int32(1) != 0 { + n = _sqlite3GetToken(tls, zSql, bp) + mxSqlLen = mxSqlLen - n + if mxSqlLen < 0 { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_TOOBIG) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + break + } + if **(**int32)(__ccgo_up(bp)) >= int32(TK_WINDOW) { + if libc.AtomicLoadNInt32(db+432, libc.Int32FromInt32(__ATOMIC_RELAXED)) != 0 { + (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_INTERRUPT) + (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 + break + } + if **(**int32)(__ccgo_up(bp)) == int32(TK_SPACE) { + zSql = zSql + uintptr(n) + continue + } + if int32(**(**int8)(__ccgo_up(zSql))) == 0 { + /* Upon reaching the end of input, call the parser two more times + ** with tokens TK_SEMI and 0, in that order. */ + if lastTokenParsed == int32(TK_SEMI) { + **(**int32)(__ccgo_up(bp)) = 0 + } else { + if lastTokenParsed == 0 { + break + } else { + **(**int32)(__ccgo_up(bp)) = int32(TK_SEMI) + } + } + n = 0 + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_WINDOW) { + **(**int32)(__ccgo_up(bp)) = _analyzeWindowKeyword(tls, zSql+6) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_OVER) { + **(**int32)(__ccgo_up(bp)) = _analyzeOverKeyword(tls, zSql+4, lastTokenParsed) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_FILTER) { + **(**int32)(__ccgo_up(bp)) = _analyzeFilterKeyword(tls, zSql+6, lastTokenParsed) + } else { + if **(**int32)(__ccgo_up(bp)) == int32(TK_COMMENT) && ((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00040))<declareVtab flag is set, do not delete any table + ** structure built up in pParse->pNewTable. The calling code (see vtab.c) + ** will take responsibility for freeing the Table structure. + */ + _sqlite3DeleteTable(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTable) + } + if (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger != 0 && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { + _sqlite3DeleteTrigger(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger) + } + if (*TParse)(unsafe.Pointer(pParse)).FpVList != 0 { + _sqlite3DbNNFreeNN(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpVList) + } + (*Tsqlite3)(unsafe.Pointer(db)).FpParse = pParentParse + return nErr +} + +/************** End of tokenize.c ********************************************/ +/************** Begin file complete.c ****************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** An tokenizer for SQL +** +** This file contains C code that implements the sqlite3_complete() API. +** This code used to be part of the tokenizer.c source file. But by +** separating it out, the code will be automatically omitted from +** static links that do not use it. + */ +/* #include "sqliteInt.h" */ + +/* +** This is defined in tokenize.c. We just have to import the definition. + */ + +/* +** Token types used by the sqlite3_complete() routine. See the header +** comments on that procedure for additional information. + */ + +// C documentation +// +// /* +// ** This routine implements the OP_Vacuum opcode of the VDBE. +// */ +func _sqlite3RunVacuum(tls *libc.TLS, pzErrMsg uintptr, db uintptr, iDb int32, pOut uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var i, isMemDb, nDb, nNew, nRes, rc, v1 int32 + var id, pDb, pMain, pTemp, zDbMain, zFilename, zOut uintptr + var pgflags, saved_mDbFlags, saved_openFlags Tu32 + var saved_flags Tu64 + var saved_mTrace Tu8 + var saved_nChange, saved_nTotalChange Ti64 + var _ /* iRandom at bp+0 */ Tu64 + var _ /* meta at bp+64 */ Tu32 + var _ /* sz at bp+56 */ Ti64 + var _ /* zDbVacuum at bp+8 */ [42]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, id, isMemDb, nDb, nNew, nRes, pDb, pMain, pTemp, pgflags, rc, saved_flags, saved_mDbFlags, saved_mTrace, saved_nChange, saved_nTotalChange, saved_openFlags, zDbMain, zFilename, zOut, v1 + rc = SQLITE_OK /* Saved trace settings */ + pDb = uintptr(0) /* Name of output file */ + pgflags = uint32(PAGER_SYNCHRONOUS_OFF) /* Name of the ATTACH-ed database used for vacuum */ + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+22672) + return int32(SQLITE_ERROR) /* IMP: R-12218-18073 */ + } + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeActive > int32(1) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+22712) + return int32(SQLITE_ERROR) /* IMP: R-15610-35227 */ + } + saved_openFlags = (*Tsqlite3)(unsafe.Pointer(db)).FopenFlags + if pOut != 0 { + if Xsqlite3_value_type(tls, pOut) != int32(SQLITE_TEXT) { + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+22755) + return int32(SQLITE_ERROR) + } + zOut = Xsqlite3_value_text(tls, pOut) + **(**uint32)(__ccgo_up(db + 76)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_OPEN_READONLY)) + **(**uint32)(__ccgo_up(db + 76)) |= libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_READWRITE)) + } else { + zOut = __ccgo_ts + 1704 + } + /* Save the current value of the database flags so that it can be + ** restored before returning. Then set the writable-schema flag, and + ** disable CHECK and foreign key constraints. */ + saved_flags = (*Tsqlite3)(unsafe.Pointer(db)).Fflags + saved_mDbFlags = (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags + saved_nChange = (*Tsqlite3)(unsafe.Pointer(db)).FnChange + saved_nTotalChange = (*Tsqlite3)(unsafe.Pointer(db)).FnTotalChange + saved_mTrace = (*Tsqlite3)(unsafe.Pointer(db)).FmTrace + **(**Tu64)(__ccgo_up(db + 48)) |= libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_WriteSchema)|libc.Int32FromInt32(SQLITE_IgnoreChecks)) | libc.Uint64FromInt32(libc.Int32FromInt32(0x00040))< 0) { + rc = int32(SQLITE_ERROR) + _sqlite3SetString(tls, pzErrMsg, db, __ccgo_ts+22804) + goto end_of_vacuum + } + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_VacuumInto) + /* For a VACUUM INTO, the pager-flags are set to the same values as + ** they are for the database being vacuumed, except that PAGER_CACHESPILL + ** is always set. */ + pgflags = uint32(uint64((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).Fsafety_level) | (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(PAGER_FLAGS_MASK)) + /* If the VACUUM INTO target file is a URI filename and if the + ** "reserve=N" query parameter is present, reset the reserve to the + ** amount specified, if the amount is within range */ + zFilename = _sqlite3BtreeGetFilename(tls, pTemp) + if zFilename != 0 { + nNew = int32(Xsqlite3_uri_int64(tls, zFilename, __ccgo_ts+22831, int64(nRes))) + if nNew >= 0 && nNew <= int32(255) { + nRes = nNew + } + } + } + _sqlite3BtreeSetCacheSize(tls, pTemp, (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema)).Fcache_size) + _sqlite3BtreeSetSpillSize(tls, pTemp, _sqlite3BtreeSetSpillSize(tls, pMain, 0)) + _sqlite3BtreeSetPagerFlags(tls, pTemp, pgflags|uint32(PAGER_CACHESPILL)) + /* Begin a transaction and take an exclusive lock on the main database + ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below, + ** to ensure that we do not try to change the page-size on a WAL database. + */ + rc = _execSql(tls, db, pzErrMsg, __ccgo_ts+16103) + if rc != SQLITE_OK { + goto end_of_vacuum + } + if pOut == uintptr(0) { + v1 = int32(2) + } else { + v1 = 0 + } + rc = _sqlite3BtreeBeginTrans(tls, pMain, v1, uintptr(0)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + /* Do not attempt to change the page size for a WAL database */ + if _sqlite3PagerGetJournalMode(tls, _sqlite3BtreePager(tls, pMain)) == int32(PAGER_JOURNALMODE_WAL) && pOut == uintptr(0) { + (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize = 0 + } + if _sqlite3BtreeSetPageSize(tls, pTemp, _sqlite3BtreeGetPageSize(tls, pMain), nRes, 0) != 0 || !(isMemDb != 0) && _sqlite3BtreeSetPageSize(tls, pTemp, (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, nRes, 0) != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + goto end_of_vacuum + } + if int32((*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac) >= 0 { + v1 = int32((*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac) + } else { + v1 = _sqlite3BtreeGetAutoVacuum(tls, pMain) + } + _sqlite3BtreeSetAutoVacuum(tls, pTemp, v1) + /* Query the schema of the main database. Create a mirror schema + ** in the temporary database. + */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = libc.Uint8FromInt32(nDb) /* force new CREATE statements into vacuum_db */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+22839, libc.VaList(bp+80, zDbMain)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+22947, libc.VaList(bp+80, zDbMain)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + /* Loop through the tables in the main database. For each, do + ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy + ** the contents to the temporary database. + */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+23001, libc.VaList(bp+80, bp+8, zDbMain, bp+8)) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_Vacuum)) + if rc != SQLITE_OK { + goto end_of_vacuum + } + /* Copy the triggers, views, and virtual tables from the main database + ** over to the temporary database. None of these objects has any + ** associated storage, so all we have to do is copy their entries + ** from the schema table. + */ + rc = _execSqlF(tls, db, pzErrMsg, __ccgo_ts+23138, libc.VaList(bp+80, bp+8, zDbMain)) + if rc != 0 { + goto end_of_vacuum + } + /* Copy Btree meta values */ + i = 0 + for { + if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(10)/libc.Uint64FromInt64(1))) { + break + } + /* GetMeta() and UpdateMeta() cannot fail in this context because + ** we already have page 1 loaded into cache and marked dirty. */ + _sqlite3BtreeGetMeta(tls, pMain, libc.Int32FromUint8(_aCopy[i]), bp+64) + rc = _sqlite3BtreeUpdateMeta(tls, pTemp, libc.Int32FromUint8(_aCopy[i]), **(**Tu32)(__ccgo_up(bp + 64))+uint32(_aCopy[i+int32(1)])) + if rc != SQLITE_OK { + goto end_of_vacuum + } + goto _3 + _3: + ; + i = i + int32(2) + } + if pOut == uintptr(0) { + rc = _sqlite3BtreeCopyFile(tls, pMain, pTemp) + } + if rc != SQLITE_OK { + goto end_of_vacuum + } + rc = _sqlite3BtreeCommit(tls, pTemp) + if rc != SQLITE_OK { + goto end_of_vacuum + } + if pOut == uintptr(0) { + _sqlite3BtreeSetAutoVacuum(tls, pMain, _sqlite3BtreeGetAutoVacuum(tls, pTemp)) + } + if pOut == uintptr(0) { + nRes = _sqlite3BtreeGetRequestedReserve(tls, pTemp) + rc = _sqlite3BtreeSetPageSize(tls, pMain, _sqlite3BtreeGetPageSize(tls, pTemp), nRes, int32(1)) + } + goto end_of_vacuum +end_of_vacuum: + ; + /* Restore the original value of db->flags */ + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = uint8(0) + (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags = saved_mDbFlags + (*Tsqlite3)(unsafe.Pointer(db)).Fflags = saved_flags + (*Tsqlite3)(unsafe.Pointer(db)).FnChange = saved_nChange + (*Tsqlite3)(unsafe.Pointer(db)).FnTotalChange = saved_nTotalChange + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = saved_mTrace + _sqlite3BtreeSetPageSize(tls, pMain, -int32(1), 0, int32(1)) + /* Currently there is an SQL level transaction open on the vacuum + ** database. No locks are held on any other files (since the main file + ** was committed at the btree level). So it safe to end the transaction + ** by manually setting the autoCommit flag to true and detaching the + ** vacuum database. The vacuum_db journal file is deleted when the pager + ** is closed by the DETACH. + */ + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(1) + if pDb != 0 { + _sqlite3BtreeClose(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) + (*TDb)(unsafe.Pointer(pDb)).FpBt = uintptr(0) + (*TDb)(unsafe.Pointer(pDb)).FpSchema = uintptr(0) + } + /* This both clears the schemas and reduces the size of the db->aDb[] + ** array. */ + _sqlite3ResetAllSchemasOfConnection(tls, db) + return rc +} + +/* At this point, there is a write transaction open on both the + ** vacuum database and the main database. Assuming no error occurs, + ** both transactions are closed by this block - the main database + ** transaction by sqlite3BtreeCopyFile() and the other by an explicit + ** call to sqlite3BtreeCommit(). + */ + +// C documentation +// +// /* +// ** pTab is a transient Table object that represents a subquery of some +// ** kind (maybe a parenthesized subquery in the FROM clause of a larger +// ** query, or a VIEW, or a CTE). This routine computes type information +// ** for that Table object based on the Select object that implements the +// ** subquery. For the purposes of this routine, "type information" means: +// ** +// ** * The datatype name, as it might appear in a CREATE TABLE statement +// ** * Which collating sequence to use for the column +// ** * The affinity of the column +// */ +func _sqlite3SubqueryColumnTypes(tls *libc.TLS, pParse uintptr, pTab uintptr, pSelect uintptr, aff int8) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, db, p, pCol, pColl, pS2, zType, v4 uintptr + var i, j, m int32 + var k, n Ti64 + var _ /* sNC at bp+0 */ TNameContext + _, _, _, _, _, _, _, _, _, _, _, _, _ = a, db, i, j, k, m, n, p, pCol, pColl, pS2, zType, v4 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + return + } + for (*TSelect)(unsafe.Pointer(pSelect)).FpPrior != 0 { + pSelect = (*TSelect)(unsafe.Pointer(pSelect)).FpPrior + } + a = (*TSelect)(unsafe.Pointer(pSelect)).FpEList + 8 + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = (*TSelect)(unsafe.Pointer(pSelect)).FpSrc + i = 0 + pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + m = 0 + pS2 = pSelect + **(**Tu32)(__ccgo_up(pTab + 48)) |= libc.Uint32FromInt32(libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags) & libc.Int32FromInt32(COLFLAG_NOINSERT)) + p = (**(**TExprList_item)(__ccgo_up(a + uintptr(i)*32))).FpExpr + /* pCol->szEst = ... // Column size est for SELECT tables never used */ + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3ExprAffinity(tls, p) + for int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) <= int32(SQLITE_AFF_NONE) && (*TSelect)(unsafe.Pointer(pS2)).FpNext != uintptr(0) { + m = m | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3ExprAffinity(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) <= int32(SQLITE_AFF_NONE) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = aff + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_TEXT) && ((*TSelect)(unsafe.Pointer(pS2)).FpNext != 0 || pS2 != pSelect) { + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + for { + if !(pS2 != 0) { + break + } + m = m | _sqlite3ExprDataType(tls, (*(*TExprList_item)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pS2)).FpEList + 8 + uintptr(i)*32))).FpExpr) + goto _2 + _2: + ; + pS2 = (*TSelect)(unsafe.Pointer(pS2)).FpNext + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_TEXT) && m&int32(0x01) != 0 { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = int8(SQLITE_AFF_BLOB) + } else { + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) && m&int32(0x02) != 0 { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = int8(SQLITE_AFF_BLOB) + } + } + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p)).Fop) == int32(TK_CAST) { + (*TColumn)(unsafe.Pointer(pCol)).Faffinity = int8(SQLITE_AFF_FLEXNUM) + } + } + zType = _columnTypeImpl(tls, bp, p, uintptr(0), uintptr(0), uintptr(0)) + if zType == uintptr(0) || int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) != int32(_sqlite3AffinityType(tls, zType, uintptr(0))) { + if int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_NUMERIC) || int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) == int32(SQLITE_AFF_FLEXNUM) { + zType = __ccgo_ts + 20649 + } else { + zType = uintptr(0) + j = int32(1) + for { + if !(j < int32(SQLITE_N_STDTYPE)) { + break + } + if int32(_sqlite3StdTypeAffinity[j]) == int32((*TColumn)(unsafe.Pointer(pCol)).Faffinity) { + zType = _sqlite3StdType[j] + break + } + goto _3 + _3: + ; + j = j + 1 + } + } + } + if zType != 0 { + k = libc.Int64FromUint64(libc.Xstrlen(tls, zType)) + n = libc.Int64FromUint64(libc.Xstrlen(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) + (*TColumn)(unsafe.Pointer(pCol)).FzCnName = _sqlite3DbReallocOrFree(tls, db, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, libc.Uint64FromInt64(n+k+int64(2))) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) & ^(libc.Int32FromInt32(COLFLAG_HASTYPE) | libc.Int32FromInt32(COLFLAG_HASCOLL))) + if (*TColumn)(unsafe.Pointer(pCol)).FzCnName != 0 { + libc.Xmemcpy(tls, (*TColumn)(unsafe.Pointer(pCol)).FzCnName+uintptr(n+int64(1)), zType, libc.Uint64FromInt64(k+int64(1))) + v4 = pCol + 14 + *(*Tu16)(unsafe.Pointer(v4)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v4))) | libc.Int32FromInt32(COLFLAG_HASTYPE)) + } + } + pColl = _sqlite3ExprCollSeq(tls, pParse, p) + if pColl != 0 { + _sqlite3ColumnSetColl(tls, db, pCol, (*TCollSeq)(unsafe.Pointer(pColl)).FzName) + } + goto _1 + _1: + ; + i = i + 1 + pCol += 16 + } + (*TTable)(unsafe.Pointer(pTab)).FszTabRow = int16(1) /* Any non-zero value works */ +} + +// C documentation +// +// /* +// ** Analyze the ON CONFLICT clause described by pUpsert. Resolve all +// ** symbols in the conflict-target. +// ** +// ** Return SQLITE_OK if everything works, or an error code is something +// ** is wrong. +// */ +func _sqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr, pUpsert uintptr, pAll uintptr) (r int32) { + bp := tls.Alloc(240) + defer tls.Free(240) + var iCursor, ii, jj, nClause, nn, rc int32 + var pExpr, pIdx, pTab, pTarget, pTerm, v2 uintptr + var v3 bool + var _ /* sCol at bp+56 */ [2]TExpr + var _ /* sNC at bp+0 */ TNameContext + var _ /* zWhich at bp+200 */ [16]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _ = iCursor, ii, jj, nClause, nn, pExpr, pIdx, pTab, pTarget, pTerm, rc, v2, v3 /* Index column converted into an Expr */ + nClause = 0 /* Counter of ON CONFLICT clauses */ + /* Resolve all symbolic names in the conflict-target clause, which + ** includes both the list of columns and the optional partial-index + ** WHERE clause. + */ + libc.Xmemset(tls, bp, 0, uint64(56)) + (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse + (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pTabList + for { + if !(pUpsert != 0 && (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget != 0) { + break + } + rc = _sqlite3ResolveExprListNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) + if rc != 0 { + return rc + } + rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) + if rc != 0 { + return rc + } + /* Check to see if the conflict target matches the rowid. */ + pTab = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FpSTab + pTarget = (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget + iCursor = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor + if v3 = (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) && (*TExprList)(unsafe.Pointer(pTarget)).FnExpr == int32(1); v3 { + v2 = (*(*TExprList_item)(unsafe.Pointer(pTarget + 8))).FpExpr + pTerm = v2 + } + if v3 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(v2)).Fop) == int32(TK_COLUMN) && int32((*TExpr)(unsafe.Pointer(pTerm)).FiColumn) == -int32(1) { + /* The conflict-target is the rowid of the primary table */ + goto _1 + } + /* Initialize sCol[0..1] to be an expression parse tree for a + ** single column of an index. The sCol[0] node will be the TK_COLLATE + ** operator and sCol[1] will be the TK_COLUMN operator. Code below + ** will populate the specific collation and column number values + ** prior to comparing against the conflict-target expression. + */ + libc.Xmemset(tls, bp+56, 0, uint64(144)) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].Fop = uint8(TK_COLLATE) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = bp + 56 + 1*72 + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].Fop = uint8(TK_COLUMN) + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].FiTable = (*(*TSrcItem)(unsafe.Pointer(pTabList + 8))).FiCursor + /* Check for matches against other indexes */ + pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex + for { + if !(pIdx != 0) { + break + } + if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromInt32(OE_None)) { + goto _4 + } + if (*TExprList)(unsafe.Pointer(pTarget)).FnExpr != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { + goto _4 + } + if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { + if (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere == uintptr(0) { + goto _4 + } + if _sqlite3ExprCompare(tls, pParse, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere, (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere, iCursor) != 0 { + goto _4 + } + } + nn = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) + ii = 0 + for { + if !(ii < nn) { + break + } + *(*uintptr)(unsafe.Pointer(bp + 56 + 8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(ii)*8)) + if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2))) == -int32(2) { + pExpr = (*(*TExprList_item)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(ii)*32))).FpExpr + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) != int32(TK_COLLATE) { + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = pExpr + pExpr = bp + 56 + } + } else { + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[0].FpLeft = bp + 56 + 1*72 + (**(**[2]TExpr)(__ccgo_up(bp + 56)))[int32(1)].FiColumn = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2)) + pExpr = bp + 56 + } + jj = 0 + for { + if !(jj < nn) { + break + } + if _sqlite3ExprCompare(tls, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pTarget + 8 + uintptr(jj)*32))).FpExpr, pExpr, iCursor) < int32(2) { + break /* Column ii of the index matches column jj of target */ + } + goto _6 + _6: + ; + jj = jj + 1 + } + if jj >= nn { + /* The target contains no match for column jj of the index */ + break + } + goto _5 + _5: + ; + ii = ii + 1 + } + if ii < nn { + /* Column ii of the index did not match any term of the conflict target. + ** Continue the search with the next index. */ + goto _4 + } + (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx = pIdx + if _sqlite3UpsertOfIndex(tls, pAll, pIdx) != pUpsert { + /* Really this should be an error. The isDup ON CONFLICT clause will + ** never fire. But this problem was not discovered until three years + ** after multi-CONFLICT upsert was added, and so we silently ignore + ** the problem to prevent breaking applications that might actually + ** have redundant ON CONFLICT clauses. */ + (*TUpsert)(unsafe.Pointer(pUpsert)).FisDup = uint8(1) + } + break + goto _4 + _4: + ; + pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext + } + if (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx == uintptr(0) { + if nClause == 0 && (*TUpsert)(unsafe.Pointer(pUpsert)).FpNextUpsert == uintptr(0) { + (**(**[16]int8)(__ccgo_up(bp + 200)))[0] = 0 + } else { + Xsqlite3_snprintf(tls, int32(16), bp+200, __ccgo_ts+22587, libc.VaList(bp+224, nClause+int32(1))) + } + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22591, libc.VaList(bp+224, bp+200)) + return int32(SQLITE_ERROR) + } + goto _1 + _1: + ; + pUpsert = (*TUpsert)(unsafe.Pointer(pUpsert)).FpNextUpsert + nClause = nClause + 1 + } + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Generate bytecode that does an UPDATE as part of an upsert. +// ** +// ** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK. +// ** In this case parameter iCur is a cursor open on the table b-tree that +// ** currently points to the conflicting table row. Otherwise, if pIdx +// ** is not NULL, then pIdx is the constraint that failed and iCur is a +// ** cursor points to the conflicting row. +// */ +func _sqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab uintptr, pIdx uintptr, iCur int32) { + var db, pPk, pSrc, pTop, v uintptr + var i, iDataCur, iPk, k, nPk, regRowid int32 + _, _, _, _, _, _, _, _, _, _, _ = db, i, iDataCur, iPk, k, nPk, pPk, pSrc, pTop, regRowid, v + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe + db = (*TParse)(unsafe.Pointer(pParse)).Fdb + pTop = pUpsert + iDataCur = (*TUpsert)(unsafe.Pointer(pUpsert)).FiDataCur + pUpsert = _sqlite3UpsertOfIndex(tls, pTop, pIdx) + if pIdx != 0 && iCur != iDataCur { + if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + regRowid = _sqlite3GetTempReg(tls, pParse) + _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), iCur, regRowid) + _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), iDataCur, 0, regRowid) + _sqlite3ReleaseTempReg(tls, pParse, regRowid) + } else { + pPk = _sqlite3PrimaryKeyIndex(tls, pTab) + nPk = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) + iPk = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) + **(**int32)(__ccgo_up(pParse + 60)) += nPk + i = 0 + for { + if !(i < nPk) { + break + } + k = _sqlite3TableColumnToIndex(tls, pIdx, int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) + _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iCur, k, iPk+i) + goto _1 + _1: + ; + i = i + 1 + } + i = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), iDataCur, 0, iPk, nPk) + _sqlite3VdbeAddOp4(tls, v, int32(OP_Halt), int32(SQLITE_CORRUPT), int32(OE_Abort), 0, __ccgo_ts+13726, -int32(1)) + _sqlite3MayAbort(tls, pParse) + _sqlite3VdbeJumpHere(tls, v, i) + } + } + /* pUpsert does not own pTop->pUpsertSrc - the outer INSERT statement does. + ** So we have to make a copy before passing it down into sqlite3Update() */ + pSrc = _sqlite3SrcListDup(tls, db, (*TUpsert)(unsafe.Pointer(pTop)).FpUpsertSrc, 0) + /* excluded.* columns of type REAL need to be converted to a hard real */ + i = 0 + for { + if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + if int32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { + _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), (*TUpsert)(unsafe.Pointer(pTop)).FregData+i) + } + goto _2 + _2: + ; + i = i + 1 + } + _sqlite3Update(tls, pParse, pSrc, _sqlite3ExprListDup(tls, db, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSet, 0), _sqlite3ExprDup(tls, db, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere, 0), int32(OE_Abort), uintptr(0), uintptr(0), pUpsert) +} + +/************** End of upsert.c **********************************************/ +/************** Begin file vacuum.c ******************************************/ +/* +** 2003 April 6 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains code used to implement the VACUUM command. +** +** Most of the code in this file may be omitted by defining the +** SQLITE_OMIT_VACUUM macro. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +// C documentation +// +// /* +// ** Execute as much of a VDBE program as we can. +// ** This is the core of sqlite3_step(). +// */ +func _sqlite3VdbeExec(tls *libc.TLS, p uintptr) (r int32) { + bp := tls.Alloc(1024) + defer tls.Free(1024) + var aCol, aMem, aOffset, aOp, aPermute, aRoot, apArg, apArg1, db, pArgc, pBt, pBt1, pBt2, pBt3, pC, pC1, pC10, pC11, pC12, pC13, pC14, pC15, pC16, pC17, pC18, pC19, pC2, pC20, pC21, pC22, pC23, pC24, pC25, pC26, pC27, pC28, pC29, pC3, pC30, pC31, pC32, pC33, pC34, pC4, pC5, pC6, pC7, pC8, pC9, pCaller, pColl, pCrsr, pCrsr1, pCrsr2, pCrsr3, pCrsr4, pCrsr5, pCrsr6, pCrsr7, pCrsr8, pCtx, pCtx1, pCtx2, pCur, pCur1, pCur2, pCur3, pCur4, pCur5, pCur6, pCx, pCx1, pCx2, pCx3, pData, pData0, pDb, pDb1, pDb2, pDb3, pDest, pDest1, pDest2, pEnd, pFrame, pFrame1, pFrame2, pFrame3, pFrame4, pIdxKey, pIn, pIn1, pIn2, pIn3, pKey, pKeyInfo, pKeyInfo1, pKeyInfo2, pLast, pMem, pMem1, pMem2, pMem3, pMem4, pModule, pModule1, pModule2, pModule3, pModule4, pModule5, pModule6, pName, pNew, pOp, pOrig, pOut, pPager, pProgram, pQuery, pRec, pReg, pRhs, pRt, pSavepoint, pSrc, pTab, pTab1, pTab2, pTab3, pTabCur, pTmp, pVCur1, pVTab, pVar, pVtab, pVtab1, pVtab2, pVtab3, pVtab4, pVtab5, pVtab6, pVtab7, pX, pX1, pnErr, t1, z1, z2, z3, zAffinity, zAffinity1, zData, zDb, zDb1, zEndHdr, zErr, zFilename, zHdr, zHdr1, zName, zPayload, zSchema, zSql, zTab, zTrace, v191, v194 uintptr + var affinity int8 + var alreadyExists, bRev, c, c1, c2, cnt, cnt1, desiredAutoCommit, eNew, eOld, eqOnly, exists, i, i1, i2, i4, i5, i6, i7, i8, i9, iCompare, iCookie, iDb, iDb1, iDb2, iDb3, iQuery, iRollback, iSavepoint, iSet, ii, ii1, isLegacy, isSchemaChange, isTransaction, len1, n, n1, n2, n4, nArg, nArg1, nCol, nField, nField1, nField2, nHdr, nKeyCol, nMem, nName, nRoot, nStep, nVarint, oc, opflags, p1, p11, p12, p13, p2, p21, pcDest, pcx, rc, res, res11, res13, res14, res21, savedAnalysisLimit, seekResult, v11, v21, wrFlag, v190, v193 int32 + var colCacheCtr, iAddr, iMap, iPrior, idx, len11, n3, p22, p23, serialType, serial_type, v215, v216 Tu32 + var encoding, isWriteLock, mTrace, op, p5, resetSchemaOnFault, vtabOnConflict, v227 Tu8 + var flags1, flags11, flags2, flags3, flags31, newType, nullFlag, type1, type2, typeMask, v192 Tu16 + var h, h1, iKey1, nAlloc, nData, nProgressLimit, nVmStep, offset64, uu Tu64 + var i3, iA, iB1, iKey, iKey2, nByte, nByte1, nByte2, nCellKey, nZero, sz, v256 Ti64 + var newMax, v213 uint32 + var rA, rB float64 + var xAuth Tsqlite3_xauth + var v206 int64 + var v217 bool + var _ /* aRes at bp+760 */ [3]int32 + var _ /* iA at bp+8 */ Ti64 + var _ /* iB at bp+0 */ Ti64 + var _ /* iMeta at bp+104 */ int32 + var _ /* iMeta at bp+108 */ int32 + var _ /* iMoved at bp+608 */ int32 + var _ /* initData at bp+640 */ TInitData + var _ /* m at bp+552 */ TMem + var _ /* nChange at bp+616 */ Ti64 + var _ /* nEntry at bp+96 */ Ti64 + var _ /* nErr at bp+680 */ int32 + var _ /* nullFunc at bp+896 */ TFuncDef + var _ /* pVCur at bp+832 */ uintptr + var _ /* pgno at bp+624 */ TPgno + var _ /* r at bp+120 */ TUnpackedRecord + var _ /* r at bp+168 */ TUnpackedRecord + var _ /* r at bp+208 */ TUnpackedRecord + var _ /* r at bp+464 */ TUnpackedRecord + var _ /* r at bp+512 */ TUnpackedRecord + var _ /* r at bp+704 */ TUnpackedRecord + var _ /* res at bp+112 */ int32 + var _ /* res at bp+160 */ int32 + var _ /* res at bp+248 */ int32 + var _ /* res at bp+320 */ int32 + var _ /* res at bp+376 */ int32 + var _ /* res at bp+392 */ int32 + var _ /* res at bp+396 */ int32 + var _ /* res at bp+400 */ int32 + var _ /* res at bp+404 */ int32 + var _ /* res at bp+456 */ int32 + var _ /* res at bp+696 */ int32 + var _ /* rowid at bp+504 */ Ti64 + var _ /* rowid at bp+968 */ Tsqlite_int64 + var _ /* sContext at bp+848 */ Tsqlite3_context + var _ /* sMem at bp+24 */ TMem + var _ /* sMem at bp+776 */ TMem + var _ /* t at bp+80 */ Tu32 + var _ /* uA at bp+16 */ Tu64 + var _ /* v at bp+312 */ Ti64 + var _ /* v at bp+384 */ Ti64 + var _ /* v at bp+88 */ Tu64 + var _ /* val at bp+744 */ Ti64 + var _ /* x at bp+256 */ TMem + var _ /* x at bp+328 */ TBtreePayload + var _ /* x at bp+408 */ TBtreePayload + var _ /* x at bp+752 */ Ti64 + var _ /* z at bp+688 */ uintptr + var _ /* zErr at bp+632 */ uintptr + var _ /* zErr at bp+840 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCol, aMem, aOffset, aOp, aPermute, aRoot, affinity, alreadyExists, apArg, apArg1, bRev, c, c1, c2, cnt, cnt1, colCacheCtr, db, desiredAutoCommit, eNew, eOld, encoding, eqOnly, exists, flags1, flags11, flags2, flags3, flags31, h, h1, i, i1, i2, i3, i4, i5, i6, i7, i8, i9, iA, iAddr, iB1, iCompare, iCookie, iDb, iDb1, iDb2, iDb3, iKey, iKey1, iKey2, iMap, iPrior, iQuery, iRollback, iSavepoint, iSet, idx, ii, ii1, isLegacy, isSchemaChange, isTransaction, isWriteLock, len1, len11, mTrace, n, n1, n2, n3, n4, nAlloc, nArg, nArg1, nByte, nByte1, nByte2, nCellKey, nCol, nData, nField, nField1, nField2, nHdr, nKeyCol, nMem, nName, nProgressLimit, nRoot, nStep, nVarint, nVmStep, nZero, newMax, newType, nullFlag, oc, offset64, op, opflags, p1, p11, p12, p13, p2, p21, p22, p23, p5, pArgc, pBt, pBt1, pBt2, pBt3, pC, pC1, pC10, pC11, pC12, pC13, pC14, pC15, pC16, pC17, pC18, pC19, pC2, pC20, pC21, pC22, pC23, pC24, pC25, pC26, pC27, pC28, pC29, pC3, pC30, pC31, pC32, pC33, pC34, pC4, pC5, pC6, pC7, pC8, pC9, pCaller, pColl, pCrsr, pCrsr1, pCrsr2, pCrsr3, pCrsr4, pCrsr5, pCrsr6, pCrsr7, pCrsr8, pCtx, pCtx1, pCtx2, pCur, pCur1, pCur2, pCur3, pCur4, pCur5, pCur6, pCx, pCx1, pCx2, pCx3, pData, pData0, pDb, pDb1, pDb2, pDb3, pDest, pDest1, pDest2, pEnd, pFrame, pFrame1, pFrame2, pFrame3, pFrame4, pIdxKey, pIn, pIn1, pIn2, pIn3, pKey, pKeyInfo, pKeyInfo1, pKeyInfo2, pLast, pMem, pMem1, pMem2, pMem3, pMem4, pModule, pModule1, pModule2, pModule3, pModule4, pModule5, pModule6, pName, pNew, pOp, pOrig, pOut, pPager, pProgram, pQuery, pRec, pReg, pRhs, pRt, pSavepoint, pSrc, pTab, pTab1, pTab2, pTab3, pTabCur, pTmp, pVCur1, pVTab, pVar, pVtab, pVtab1, pVtab2, pVtab3, pVtab4, pVtab5, pVtab6, pVtab7, pX, pX1, pcDest, pcx, pnErr, rA, rB, rc, res, res11, res13, res14, res21, resetSchemaOnFault, savedAnalysisLimit, seekResult, serialType, serial_type, sz, t1, type1, type2, typeMask, uu, v11, v21, vtabOnConflict, wrFlag, xAuth, z1, z2, z3, zAffinity, zAffinity1, zData, zDb, zDb1, zEndHdr, zErr, zFilename, zHdr, zHdr1, zName, zPayload, zSchema, zSql, zTab, zTrace, v190, v191, v192, v193, v194, v206, v213, v215, v216, v217, v227, v256 + aOp = (*TVdbe)(unsafe.Pointer(p)).FaOp /* Copy of p->aOp */ + pOp = aOp /* Current operation */ + rc = SQLITE_OK /* Value to return */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb /* The database */ + resetSchemaOnFault = uint8(0) /* Reset schema after an error if positive */ + encoding = (*Tsqlite3)(unsafe.Pointer(db)).Fenc /* The database encoding */ + iCompare = 0 /* Result of last comparison */ + nVmStep = uint64(0) /* Invoke xProgress() when nVmStep reaches this */ + aMem = (*TVdbe)(unsafe.Pointer(p)).FaMem /* Copy of p->aMem */ + pIn1 = uintptr(0) /* 1st input operand */ + pIn2 = uintptr(0) /* 2nd input operand */ + pIn3 = uintptr(0) /* 3rd input operand */ + pOut = uintptr(0) /* Output operand */ + colCacheCtr = uint32(0) /* Column cache counter */ + /*** INSERT STACK UNION HERE ***/ + /* sqlite3_step() verifies this */ + if (*TVdbe)(unsafe.Pointer(p)).FlockMask != uint32(0) { + _sqlite3VdbeEnter(tls, p) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != 0 { + iPrior = **(**Tu32)(__ccgo_up(p + 212 + 4*4)) + nProgressLimit = uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps - iPrior%(*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + } else { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)<= nProgressLimit && (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0) { + nProgressLimit = nProgressLimit + uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)< 0 && int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == P4_NOTUSED { + zErr = _sqlite3ValueText(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, uint8(SQLITE_UTF8)) + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, zErr)) + } else { + if (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+5856, libc.VaList(bp+984, _azType[libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)-int32(1)])) + if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3MPrintf(tls, db, __ccgo_ts+5877, libc.VaList(bp+984, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + } + } else { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + } + } + _sqlite3VdbeLogAbort(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, pOp, aOp) + } + rc = _sqlite3VdbeHalt(tls, p) + if rc == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_BUSY) + } else { + if (*TVdbe)(unsafe.Pointer(p)).Frc != 0 { + v190 = int32(SQLITE_ERROR) + } else { + v190 = int32(SQLITE_DONE) + } + rc = v190 + } + goto vdbe_return + /* Opcode: Integer P1 P2 * * * + ** Synopsis: r[P2]=P1 + ** + ** The 32-bit integer value P1 is written into register P2. + */ + _10: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = int64((*TOp)(unsafe.Pointer(pOp)).Fp1) + goto _189 + /* Opcode: Int64 * P2 * P4 * + ** Synopsis: r[P2]=P4 + ** + ** P4 is a pointer to a 64-bit integer value. + ** Write that value into register P2. + */ + _11: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))) + goto _189 + /* Opcode: Real * P2 * P4 * + ** Synopsis: r[P2]=P4 + ** + ** P4 is a pointer to a 64-bit floating point value. + ** Write that value into register P2. + */ + _12: + ; /* same as TK_FLOAT, out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Real) + *(*float64)(unsafe.Pointer(pOut)) = **(**float64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))) + goto _189 + /* Opcode: String8 * P2 * P4 * + ** Synopsis: r[P2]='P4' + ** + ** P4 points to a nul terminated UTF-8 string. This opcode is transformed + ** into a String opcode before it is executed for the first time. During + ** this transformation, the length of string P4 is computed and stored + ** as the P1 parameter. + */ + _13: + ; /* same as TK_STRING, out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TOp)(unsafe.Pointer(pOp)).Fp1 = _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pOp + 16))) + if libc.Int32FromUint8(encoding) != int32(SQLITE_UTF8) { + rc = _sqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64(-int32(1)), uint8(SQLITE_UTF8), libc.UintptrFromInt32(0)) + if rc != 0 { + goto too_big + } + if SQLITE_OK != _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8(encoding)) { + goto no_mem + } + (*TMem)(unsafe.Pointer(pOut)).FszMalloc = 0 + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Static)) + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(7) { + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + (*TOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = (*TMem)(unsafe.Pointer(pOut)).Fz + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (*TMem)(unsafe.Pointer(pOut)).Fn + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 > **(**int32)(__ccgo_up(db + 136)) { + goto too_big + } + (*TOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_String) + /* Fall through to the next case, OP_String */ + /* Opcode: String P1 P2 P3 P4 P5 + ** Synopsis: r[P2]='P4' (len=P1) + ** + ** The string value P4 of length P1 (bytes) is stored in register P2. + ** + ** If P3 is not zero and the content of register P3 is equal to P5, then + ** the datatype of the register P2 is converted to BLOB. The content is + ** the same sequence of bytes, it is merely interpreted as a BLOB instead + ** of a string, as if it had been CAST. In other words: + ** + ** if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB) + */ + _14: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fz = *(*uintptr)(unsafe.Pointer(pOp + 16)) + (*TMem)(unsafe.Pointer(pOut)).Fn = (*TOp)(unsafe.Pointer(pOp)).Fp1 + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: BeginSubrtn * P2 * * * + ** Synopsis: r[P2]=NULL + ** + ** Mark the beginning of a subroutine that can be entered in-line + ** or that can be called using OP_Gosub. The subroutine should + ** be terminated by an OP_Return instruction that has a P1 operand that + ** is the same as the P2 operand to this opcode and that has P3 set to 1. + ** If the subroutine is entered in-line, then the OP_Return will simply + ** fall through. But if the subroutine is entered using OP_Gosub, then + ** the OP_Return will jump back to the first instruction after the OP_Gosub. + ** + ** This routine works by loading a NULL into the P2 register. When the + ** return address register contains a NULL, the OP_Return instruction is + ** a no-op that simply falls through to the next instruction (assuming that + ** the OP_Return opcode has a P3 value of 1). Thus if the subroutine is + ** entered in-line, then the OP_Return will cause in-line execution to + ** continue. But if the subroutine is entered via OP_Gosub, then the + ** OP_Return will cause a return to the address following the OP_Gosub. + ** + ** This opcode is identical to OP_Null. It has a different name + ** only to make the byte code easier to read and verify. + */ + /* Opcode: Null P1 P2 P3 * * + ** Synopsis: r[P2..P3]=NULL + ** + ** Write a NULL into registers P2. If P3 greater than P2, then also write + ** NULL into register P3 and every register in between P2 and P3. If P3 + ** is less than P2 (typically P3 is zero) then only register P2 is + ** set to NULL. + ** + ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that + ** NULL values will not compare equal even if SQLITE_NULLEQ is set on + ** OP_Ne or OP_Eq. + */ + _16: + ; + _15: + ; + pOut = _out2Prerelease(tls, p, pOp) + cnt = (*TOp)(unsafe.Pointer(pOp)).Fp3 - (*TOp)(unsafe.Pointer(pOp)).Fp2 + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + v190 = libc.Int32FromInt32(MEM_Null) | libc.Int32FromInt32(MEM_Cleared) + } else { + v190 = int32(MEM_Null) + } + v192 = libc.Uint16FromInt32(v190) + nullFlag = v192 + (*TMem)(unsafe.Pointer(pOut)).Fflags = v192 + (*TMem)(unsafe.Pointer(pOut)).Fn = 0 + for cnt > 0 { + pOut += 56 + _sqlite3VdbeMemSetNull(tls, pOut) + (*TMem)(unsafe.Pointer(pOut)).Fflags = nullFlag + (*TMem)(unsafe.Pointer(pOut)).Fn = 0 + cnt = cnt - 1 + } + goto _189 + /* Opcode: SoftNull P1 * * * * + ** Synopsis: r[P1]=NULL + ** + ** Set register P1 to have the value NULL as seen by the OP_MakeRecord + ** instruction, but do not free any string or blob memory associated with + ** the register, so that if the value was a string or blob that was + ** previously copied using OP_SCopy, the copies will continue to be valid. + */ + _17: + ; + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_Undefined)|libc.Int32FromInt32(MEM_AffMask)) | int32(MEM_Null)) + goto _189 + /* Opcode: Blob P1 P2 * P4 * + ** Synopsis: r[P2]=P4 (len=P1) + ** + ** P4 points to a blob of data P1 bytes long. Store this + ** blob in register P2. If P4 is a NULL pointer, then construct + ** a zero-filled blob that is P1 bytes long in P2. + */ + _18: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + if *(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0) { + _sqlite3VdbeMemSetZeroBlob(tls, pOut, (*TOp)(unsafe.Pointer(pOp)).Fp1) + if _sqlite3VdbeMemExpandBlob(tls, pOut) != 0 { + goto no_mem + } + } else { + _sqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64((*TOp)(unsafe.Pointer(pOp)).Fp1), uint8(0), uintptr(0)) + } + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: Variable P1 P2 * * * + ** Synopsis: r[P2]=parameter(P1) + ** + ** Transfer the values of bound parameter P1 into register P2 + */ + _19: + ; /* Value being transferred */ + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1-int32(1))*56 + if _sqlite3VdbeMemTooBig(tls, pVar) != 0 { + goto too_big + } + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + } + libc.Xmemcpy(tls, pOut, pVar, uint64(libc.UintptrFromInt32(0)+24)) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Ephem))) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | (libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_FromBind))) + goto _189 + /* Opcode: Move P1 P2 P3 * * + ** Synopsis: r[P2@P3]=r[P1@P3] + ** + ** Move the P3 values in register P1..P1+P3-1 over into + ** registers P2..P2+P3-1. Registers P1..P1+P3-1 are + ** left holding a NULL. It is an error for register ranges + ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error + ** for P3 to be less than 1. + */ + _20: + ; /* Register to copy to */ + n = (*TOp)(unsafe.Pointer(pOp)).Fp3 + p1 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + p2 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pIn1 = aMem + uintptr(p1)*56 + pOut = aMem + uintptr(p2)*56 + for { + _sqlite3VdbeMemMove(tls, pOut, pIn1) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + pIn1 += 56 + pOut += 56 + goto _197 + _197: + ; + n = n - 1 + v190 = n + if !(v190 != 0) { + break + } + } + goto _189 + /* Opcode: Copy P1 P2 P3 * P5 + ** Synopsis: r[P2@P3+1]=r[P1@P3+1] + ** + ** Make a copy of registers P1..P1+P3 into registers P2..P2+P3. + ** + ** If the 0x0002 bit of P5 is set then also clear the MEM_Subtype flag in the + ** destination. The 0x0001 bit of P5 indicates that this Copy opcode cannot + ** be merged. The 0x0001 bit is used by the query planner and does not + ** come into play during query execution. + ** + ** This instruction makes a deep copy of the value. A duplicate + ** is made of any string or blob constant. See also OP_SCopy. + */ + _21: + ; + n1 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + for int32(1) != 0 { + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn1, int32(MEM_Ephem)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Subtype) != 0 && libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(0x0002) != 0 { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + } + v190 = n1 + n1 = n1 - 1 + if v190 == 0 { + break + } + pOut += 56 + pIn1 += 56 + } + goto _189 + /* Opcode: SCopy P1 P2 * * * + ** Synopsis: r[P2]=r[P1] + ** + ** Make a shallow copy of register P1 into register P2. + ** + ** This instruction makes a shallow copy of the value. If the value + ** is a string or blob, then the copy is only a pointer to the + ** original and hence if the original changes so will the copy. + ** Worse, if the original is deallocated, the copy becomes invalid. + ** Thus the program must guarantee that the original will not change + ** during the lifetime of the copy. Use OP_Copy to make a complete + ** copy. + */ + _22: + ; /* out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn1, int32(MEM_Ephem)) + goto _189 + /* Opcode: IntCopy P1 P2 * * * + ** Synopsis: r[P2]=r[P1] + ** + ** Transfer the integer value held in register P1 into register P2. + ** + ** This is an optimized version of SCopy that works only for integer + ** values. + */ + _23: + ; /* out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemSetInt64(tls, pOut, *(*Ti64)(unsafe.Pointer(pIn1))) + goto _189 + /* Opcode: FkCheck * * * * * + ** + ** Halt with an SQLITE_CONSTRAINT error if there are any unresolved + ** foreign key constraint violations. If there are no foreign key + ** constraint violations, this is a no-op. + ** + ** FK constraint violations are also checked when the prepared statement + ** exits. This opcode is used to raise foreign key constraint errors prior + ** to returning results such as a row change count or the result of a + ** RETURNING clause. + */ + _24: + ; + v190 = _sqlite3VdbeCheckFkImmediate(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto abort_due_to_error + } + goto _189 + /* Opcode: ResultRow P1 P2 * * * + ** Synopsis: output=r[P1@P2] + ** + ** The registers P1 through P1+P2-1 contain a single row of + ** results. This opcode causes the sqlite3_step() call to terminate + ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt + ** structure to provide access to the r(P1)..r(P1+P2-1) values as + ** the result row. + */ + _25: + ; + (*TVdbe)(unsafe.Pointer(p)).FcacheCtr = (*TVdbe)(unsafe.Pointer(p)).FcacheCtr + uint32(2) | uint32(1) + (*TVdbe)(unsafe.Pointer(p)).FpResultRow = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto no_mem + } + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_ROW) != 0 { + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_ROW), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0)) + } + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp)-int64(aOp))/24) + int32(1) + rc = int32(SQLITE_ROW) + goto vdbe_return + /* Opcode: Concat P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]+r[P1] + ** + ** Add the text in register P1 onto the end of the text in + ** register P2 and store the result in register P3. + ** If either the P1 or P2 text are NULL then store NULL in P3. + ** + ** P3 = P2 || P1 + ** + ** It is illegal for P1 and P3 to be the same register. Sometimes, + ** if P3 is the same register as P2, the implementation is able + ** to avoid a memcpy(). + */ + _26: + ; /* Initial flags for P2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags1 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + if (libc.Int32FromUint16(flags1)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags))&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + goto _189 + } + if libc.Int32FromUint16(flags1)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) == 0 { + if _sqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(0)) != 0 { + goto no_mem + } + flags1 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } else { + if libc.Int32FromUint16(flags1)&int32(MEM_Zero) != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pIn1) != 0 { + goto no_mem + } + flags1 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } + } + flags2 = (*TMem)(unsafe.Pointer(pIn2)).Fflags + if libc.Int32FromUint16(flags2)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) == 0 { + if _sqlite3VdbeMemStringify(tls, pIn2, encoding, uint8(0)) != 0 { + goto no_mem + } + flags2 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } else { + if libc.Int32FromUint16(flags2)&int32(MEM_Zero) != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pIn2) != 0 { + goto no_mem + } + flags2 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) + } + } + nByte = int64((*TMem)(unsafe.Pointer(pIn1)).Fn) + nByte = nByte + int64((*TMem)(unsafe.Pointer(pIn2)).Fn) + if nByte > int64(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + if _sqlite3VdbeMemGrow(tls, pOut, int32(nByte)+int32(2), libc.BoolInt32(pOut == pIn2)) != 0 { + goto no_mem + } + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Str)) + if pOut != pIn2 { + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pOut)).Fz, (*TMem)(unsafe.Pointer(pIn2)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn2)).Fn)) + (*TMem)(unsafe.Pointer(pIn2)).Fflags = flags2 + } + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pOut)).Fz+uintptr((*TMem)(unsafe.Pointer(pIn2)).Fn), (*TMem)(unsafe.Pointer(pIn1)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn)) + (*TMem)(unsafe.Pointer(pIn1)).Fflags = flags1 + if libc.Int32FromUint8(encoding) > int32(SQLITE_UTF8) { + nByte = nByte & int64(^libc.Int32FromInt32(1)) + } + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte))) = 0 + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte+int64(1)))) = 0 + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fn = int32(nByte) + (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding + goto _189 + /* Opcode: Add P1 P2 P3 * * + ** Synopsis: r[P3]=r[P1]+r[P2] + ** + ** Add the value in register P1 to the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Multiply P1 P2 P3 * * + ** Synopsis: r[P3]=r[P1]*r[P2] + ** + ** + ** Multiply the value in register P1 by the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Subtract P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]-r[P1] + ** + ** Subtract the value in register P1 from the value in register P2 + ** and store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + /* Opcode: Divide P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]/r[P1] + ** + ** Divide the value in register P1 by the value in register P2 + ** and store the result in register P3 (P3=P2/P1). If the value in + ** register P1 is zero, then the result is NULL. If either input is + ** NULL, the result is NULL. + */ + /* Opcode: Remainder P1 P2 P3 * * + ** Synopsis: r[P3]=r[P2]%r[P1] + ** + ** Compute the remainder after integer register P2 is divided by + ** register P1 and store the result in register P3. + ** If the value in register P1 is zero the result is NULL. + ** If either operand is NULL, the result is NULL. + */ + _31: + ; /* same as TK_PLUS, in1, in2, out3 */ + _30: + ; /* same as TK_MINUS, in1, in2, out3 */ + _29: + ; /* same as TK_STAR, in1, in2, out3 */ + _28: + ; /* same as TK_SLASH, in1, in2, out3 */ + _27: + ; /* Real value of right operand */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + type1 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + type2 = (*TMem)(unsafe.Pointer(pIn2)).Fflags + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if !(libc.Int32FromUint16(type1)&libc.Int32FromUint16(type2)&int32(MEM_Int) != 0) { + goto _202 + } + goto int_math + int_math: + ; + iA = *(*Ti64)(unsafe.Pointer(pIn1)) + **(**Ti64)(__ccgo_up(bp)) = *(*Ti64)(unsafe.Pointer(pIn2)) + switch libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) { + case int32(OP_Add): + if _sqlite3AddInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Subtract): + if _sqlite3SubInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Multiply): + if _sqlite3MulInt64(tls, bp, iA) != 0 { + goto fp_math + } + case int32(OP_Divide): + if iA == 0 { + goto arithmetic_result_is_null + } + if iA == int64(-int32(1)) && **(**Ti64)(__ccgo_up(bp)) == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>r[P1] + ** + ** Shift the integer value in register P2 to the right by the + ** number of bits specified by the integer in register P1. + ** Store the result in register P3. + ** If either input is NULL, the result is NULL. + */ + _36: + ; /* same as TK_BITAND, in1, in2, out3 */ + _35: + ; /* same as TK_BITOR, in1, in2, out3 */ + _34: + ; /* same as TK_LSHIFT, in1, in2, out3 */ + _33: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if (libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags))&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + goto _189 + } + **(**Ti64)(__ccgo_up(bp + 8)) = _sqlite3VdbeIntValue(tls, pIn2) + iB1 = _sqlite3VdbeIntValue(tls, pIn1) + op = (*TOp)(unsafe.Pointer(pOp)).Fopcode + if libc.Int32FromUint8(op) == int32(OP_BitAnd) { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) & iB1 + } else { + if libc.Int32FromUint8(op) == int32(OP_BitOr) { + **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) | iB1 + } else { + if iB1 != 0 { + /* If shifting by a negative amount, shift in the other direction */ + if iB1 < 0 { + op = libc.Uint8FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(OP_ShiftLeft) + libc.Int32FromInt32(1) - libc.Int32FromUint8(op)) + if iB1 > int64(-libc.Int32FromInt32(64)) { + v206 = -iB1 + } else { + v206 = int64(64) + } + iB1 = v206 + } + if iB1 >= int64(64) { + if **(**Ti64)(__ccgo_up(bp + 8)) >= 0 || libc.Int32FromUint8(op) == int32(OP_ShiftLeft) { + v190 = 0 + } else { + v190 = -int32(1) + } + **(**Ti64)(__ccgo_up(bp + 8)) = int64(v190) + } else { + libc.Xmemcpy(tls, bp+16, bp+8, uint64(8)) + if libc.Int32FromUint8(op) == int32(OP_ShiftLeft) { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) << libc.Uint64FromInt64(iB1) + } else { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) >> libc.Uint64FromInt64(iB1) + /* Sign-extend on a right shift of a negative number */ + if **(**Ti64)(__ccgo_up(bp + 8)) < 0 { + **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) | (libc.Uint64FromUint32(0xffffffff)< + **
  • P2=='A' → BLOB + **
  • P2=='B' → TEXT + **
  • P2=='C' → NUMERIC + **
  • P2=='D' → INTEGER + **
  • P2=='E' → REAL + ** + ** + ** A NULL value is not changed by this routine. It remains NULL. + */ + _40: + ; /* in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn1) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + rc = _sqlite3VdbeMemCast(tls, pIn1, libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2), encoding) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Eq P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]==r[P1] + ** + ** Compare the values in register P1 and P3. If reg(P3)==reg(P1) then + ** jump to address P2. + ** + ** The SQLITE_AFF_MASK portion of P5 must be an affinity character - + ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made + ** to coerce both inputs according to this affinity before the + ** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric + ** affinity is used. Note that the affinity conversions are stored + ** back into the input registers P1 and P3. So this opcode can cause + ** persistent changes to registers P1 and P3. + ** + ** Once any conversions have taken place, and neither value is NULL, + ** the values are compared. If both values are blobs then memcmp() is + ** used to determine the results of the comparison. If both values + ** are text, then the appropriate collating function specified in + ** P4 is used to do the comparison. If P4 is not specified then + ** memcmp() is used to compare text string. If both values are + ** numeric, then a numeric comparison is used. If the two values + ** are of different types, then numbers are considered less than + ** strings and strings are considered less than blobs. + ** + ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either + ** true or false and is never NULL. If both operands are NULL then the result + ** of comparison is true. If either operand is NULL then the result is false. + ** If neither operand is NULL the result is the same as it would be if + ** the SQLITE_NULLEQ flag were omitted from P5. + ** + ** This opcode saves the result of comparison for use by the new + ** OP_Jump opcode. + */ + /* Opcode: Ne P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]!=r[P1] + ** + ** This works just like the Eq opcode except that the jump is taken if + ** the operands in registers P1 and P3 are not equal. See the Eq opcode for + ** additional information. + */ + /* Opcode: Lt P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]r[P1] + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than the content of + ** register P1. See the Lt opcode for additional information. + */ + /* Opcode: Ge P1 P2 P3 P4 P5 + ** Synopsis: IF r[P3]>=r[P1] + ** + ** This works just like the Lt opcode except that the jump is taken if + ** the content of register P3 is greater than or equal to the content of + ** register P1. See the Lt opcode for additional information. + */ + _46: + ; /* same as TK_EQ, jump, in1, in3 */ + _45: + ; /* same as TK_NE, jump, in1, in3 */ + _44: + ; /* same as TK_LT, jump, in1, in3 */ + _43: + ; /* same as TK_LE, jump, in1, in3 */ + _42: + ; /* same as TK_GT, jump, in1, in3 */ + _41: + ; /* Copy of initial value of pIn3->flags */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags11 = (*TMem)(unsafe.Pointer(pIn1)).Fflags + flags3 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + if libc.Int32FromUint16(flags11)&libc.Int32FromUint16(flags3)&int32(MEM_Int) != 0 { + /* Common case of comparison of two integers */ + if *(*Ti64)(unsafe.Pointer(pIn3)) > *(*Ti64)(unsafe.Pointer(pIn1)) { + if **(**uint8)(__ccgo_up(_sqlite3aGTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = +libc.Int32FromInt32(1) + } else { + if *(*Ti64)(unsafe.Pointer(pIn3)) < *(*Ti64)(unsafe.Pointer(pIn1)) { + if **(**uint8)(__ccgo_up(_sqlite3aLTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = -int32(1) + } else { + if **(**uint8)(__ccgo_up(_sqlite3aEQb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { + goto jump_to_p2 + } + iCompare = 0 + } + } + goto _189 + } + if (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Null) != 0 { + /* One or both operands are NULL */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(SQLITE_NULLEQ) != 0 { + /* If SQLITE_NULLEQ is set (which will only happen if the operator is + ** OP_Eq or OP_Ne) then take the jump or not depending on whether + ** or not both operands are null. + */ + if libc.Int32FromUint16(flags11)&libc.Int32FromUint16(flags3)&int32(MEM_Null) != 0 && libc.Int32FromUint16(flags3)&int32(MEM_Cleared) == 0 { + res = 0 /* Operands are equal */ + } else { + if libc.Int32FromUint16(flags3)&int32(MEM_Null) != 0 { + v190 = -int32(1) + } else { + v190 = +libc.Int32FromInt32(1) + } + res = v190 /* Operands are not equal */ + } + } else { + /* SQLITE_NULLEQ is clear and at least one operand is NULL, + ** then the result is always NULL. + ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. + */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(SQLITE_JUMPIFNULL) != 0 { + goto jump_to_p2 + } + iCompare = int32(1) /* Operands are not equal */ + goto _189 + } + } else { + /* Neither operand is NULL and we couldn't do the special high-speed + ** integer comparison case. So do a general-case comparison. */ + affinity = int8(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) & int32(SQLITE_AFF_MASK)) + if int32(affinity) >= int32(SQLITE_AFF_NUMERIC) { + if (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Str) != 0 { + if libc.Int32FromUint16(flags11)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn1, 0) + flags3 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + } + if libc.Int32FromUint16(flags3)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn3, 0) + } + } + } else { + if int32(affinity) == int32(SQLITE_AFF_TEXT) && (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Str) != 0 { + if libc.Int32FromUint16(flags11)&int32(MEM_Str) != 0 { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) + } else { + if libc.Int32FromUint16(flags11)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(1)) + flags11 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_TypeMask) | libc.Int32FromUint16(flags11)&int32(MEM_TypeMask)) + if pIn1 == pIn3 { + flags3 = libc.Uint16FromInt32(libc.Int32FromUint16(flags11) | int32(MEM_Str)) + } + } + } + if libc.Int32FromUint16(flags3)&int32(MEM_Str) != 0 { + v191 = pIn3 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) + } else { + if libc.Int32FromUint16(flags3)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + _sqlite3VdbeMemStringify(tls, pIn3, encoding, uint8(1)) + flags3 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn3)).Fflags) & ^libc.Int32FromInt32(MEM_TypeMask) | libc.Int32FromUint16(flags3)&int32(MEM_TypeMask)) + } + } + } + } + res = _sqlite3MemCompare(tls, pIn3, pIn1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + /* At this point, res is negative, zero, or positive if reg[P1] is + ** less than, equal to, or greater than reg[P3], respectively. Compute + ** the answer to this operator in res2, depending on what the comparison + ** operator actually is. The next block of code depends on the fact + ** that the 6 comparison operators are consecutive integers in this + ** order: NE, EQ, GT, LE, LT, GE */ + if res < 0 { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aLTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } else { + if res == 0 { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aEQb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } else { + res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aGTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) + } + } + iCompare = res + /* Undo any changes made by applyAffinity() to the input registers. */ + (*TMem)(unsafe.Pointer(pIn3)).Fflags = flags3 + (*TMem)(unsafe.Pointer(pIn1)).Fflags = flags11 + if res21 != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: ElseEq * P2 * * * + ** + ** This opcode must follow an OP_Lt or OP_Gt comparison operator. There + ** can be zero or more OP_ReleaseReg opcodes intervening, but no other + ** opcodes are allowed to occur between this instruction and the previous + ** OP_Lt or OP_Gt. + ** + ** If the result of an OP_Eq comparison on the same two operands as + ** the prior OP_Lt or OP_Gt would have been true, then jump to P2. If + ** the result of an OP_Eq comparison on the two previous operands + ** would have been false or NULL, then fall through. + */ + _47: + ; /* same as TK_ESCAPE, jump */ + if iCompare == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Permutation * * * P4 * + ** + ** Set the permutation used by the OP_Compare operator in the next + ** instruction. The permutation is stored in the P4 operand. + ** + ** The permutation is only valid for the next opcode which must be + ** an OP_Compare that has the OPFLAG_PERMUTE bit set in P5. + ** + ** The first integer in the P4 integer array is the length of the array + ** and does not become part of the permutation. + */ + _48: + ; + goto _189 + /* Opcode: Compare P1 P2 P3 P4 P5 + ** Synopsis: r[P1@P3] <-> r[P2@P3] + ** + ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this + ** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of + ** the comparison for use by the next OP_Jump instruct. + ** + ** If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is + ** determined by the most recent OP_Permutation operator. If the + ** OPFLAG_PERMUTE bit is clear, then register are compared in sequential + ** order. + ** + ** P4 is a KeyInfo structure that defines collating sequences and sort + ** orders for the comparison. The permutation applies to registers + ** only. The KeyInfo elements are used sequentially. + ** + ** The comparison is a sort comparison, so NULLs compare equal, + ** NULLs are less than numbers, numbers are less than strings, + ** and strings are less than blobs. + ** + ** This opcode must be immediately followed by an OP_Jump opcode. + */ + _49: + ; /* The permutation */ + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_PERMUTE) == 0 { + aPermute = uintptr(0) + } else { + aPermute = *(*uintptr)(unsafe.Pointer(pOp + uintptr(-libc.Int32FromInt32(1))*24 + 16)) + uintptr(1)*4 + } + n2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) + p11 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + p21 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + i = 0 + for { + if !(i < n2) { + break + } + if aPermute != 0 { + v213 = **(**Tu32)(__ccgo_up(aPermute + uintptr(i)*4)) + } else { + v213 = libc.Uint32FromInt32(i) + } + idx = v213 + pColl = *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)) + bRev = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i)))) & int32(KEYINFO_ORDER_DESC) + iCompare = _sqlite3MemCompare(tls, aMem+uintptr(libc.Uint32FromInt32(p11)+idx)*56, aMem+uintptr(libc.Uint32FromInt32(p21)+idx)*56, pColl) + if iCompare != 0 { + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i))))&int32(KEYINFO_ORDER_BIGNULL) != 0 && (libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr(libc.Uint32FromInt32(p11)+idx)*56))).Fflags)&int32(MEM_Null) != 0 || libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr(libc.Uint32FromInt32(p21)+idx)*56))).Fflags)&int32(MEM_Null) != 0) { + iCompare = -iCompare + } + if bRev != 0 { + iCompare = -iCompare + } + break + } + goto _212 + _212: + ; + i = i + 1 + } + goto _189 + /* Opcode: Jump P1 P2 P3 * * + ** + ** Jump to the instruction at address P1, P2, or P3 depending on whether + ** in the most recent OP_Compare instruction the P1 vector was less than, + ** equal to, or greater than the P2 vector, respectively. + ** + ** This opcode must immediately follow an OP_Compare opcode. + */ + _50: + ; /* jump */ + if iCompare < 0 { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1-int32(1))*24 + } else { + if iCompare == 0 { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2-int32(1))*24 + } else { + pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3-int32(1))*24 + } + } + goto _189 + /* Opcode: And P1 P2 P3 * * + ** Synopsis: r[P3]=(r[P1] && r[P2]) + ** + ** Take the logical AND of the values in registers P1 and P2 and + ** write the result into register P3. + ** + ** If either P1 or P2 is 0 (false) then the result is 0 even if + ** the other input is NULL. A NULL and true or two NULLs give + ** a NULL output. + */ + /* Opcode: Or P1 P2 P3 * * + ** Synopsis: r[P3]=(r[P1] || r[P2]) + ** + ** Take the logical OR of the values in register P1 and P2 and + ** store the answer in register P3. + ** + ** If either P1 or P2 is nonzero (true) then the result is 1 (true) + ** even if the other input is NULL. A NULL and false or two NULLs + ** give a NULL output. + */ + _52: + ; /* same as TK_AND, in1, in2, out3 */ + _51: + ; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ + v11 = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, int32(2)) + v21 = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, int32(2)) + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_And) { + v11 = libc.Int32FromUint8(_and_logic[v11*int32(3)+v21]) + } else { + v11 = libc.Int32FromUint8(_or_logic[v11*int32(3)+v21]) + } + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if v11 == int32(2) { + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Null)) + } else { + *(*Ti64)(unsafe.Pointer(pOut)) = int64(v11) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Int)) + } + goto _189 + /* Opcode: IsTrue P1 P2 P3 P4 * + ** Synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 + ** + ** This opcode implements the IS TRUE, IS FALSE, IS NOT TRUE, and + ** IS NOT FALSE operators. + ** + ** Interpret the value in register P1 as a boolean value. Store that + ** boolean (a 0 or 1) in register P2. Or if the value in register P1 is + ** NULL, then the P3 is stored in register P2. Invert the answer if P4 + ** is 1. + ** + ** The logic is summarized like this: + ** + **
      + **
    • If P3==0 and P4==0 then r[P2] := r[P1] IS TRUE + **
    • If P3==1 and P4==1 then r[P2] := r[P1] IS FALSE + **
    • If P3==0 and P4==1 then r[P2] := r[P1] IS NOT TRUE + **
    • If P3==1 and P4==0 then r[P2] := r[P1] IS NOT FALSE + **
    + */ + _53: + ; /* in1, out2 */ + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, int64(_sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, (*TOp)(unsafe.Pointer(pOp)).Fp3)^(*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) + goto _189 + /* Opcode: Not P1 P2 * * * + ** Synopsis: r[P2]= !r[P1] + ** + ** Interpret the value in register P1 as a boolean value. Store the + ** boolean complement in register P2. If the value in register P1 is + ** NULL, then a NULL is stored in P2. + */ + _54: + ; /* same as TK_NOT, in1, out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + _sqlite3VdbeMemSetInt64(tls, pOut, libc.BoolInt64(!(_sqlite3VdbeBooleanValue(tls, pIn1, 0) != 0))) + } else { + _sqlite3VdbeMemSetNull(tls, pOut) + } + goto _189 + /* Opcode: BitNot P1 P2 * * * + ** Synopsis: r[P2]= ~r[P1] + ** + ** Interpret the content of register P1 as an integer. Store the + ** ones-complement of the P1 value into register P2. If P1 holds + ** a NULL then store a NULL in P2. + */ + _55: + ; /* same as TK_BITNOT, in1, out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemSetNull(tls, pOut) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) + *(*Ti64)(unsafe.Pointer(pOut)) = ^_sqlite3VdbeIntValue(tls, pIn1) + } + goto _189 + /* Opcode: Once P1 P2 P3 * * + ** + ** Fall through to the next instruction the first time this opcode is + ** encountered on each invocation of the byte-code program. Jump to P2 + ** on the second and all subsequent encounters during the same invocation. + ** + ** Top-level programs determine first invocation by comparing the P1 + ** operand against the P1 operand on the OP_Init opcode at the beginning + ** of the program. If the P1 values differ, then fall through and make + ** the P1 of this opcode equal to the P1 of OP_Init. If P1 values are + ** the same then take the jump. + ** + ** For subprograms, there is a bitmask in the VdbeFrame that determines + ** whether or not the jump should be taken. The bitmask is necessary + ** because the self-altering code trick does not work for recursive + ** triggers. + ** + ** The P3 operand is not used directly by this opcode. However P3 is + ** used by the code generator as follows: If this opcode is the start + ** of a subroutine and that subroutine uses a Bloom filter, then P3 will + ** be the register that holds that Bloom filter. See tag-202407032019 + ** in the source code for implementation details. + */ + _56: + ; /* Address of this instruction */ + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + iAddr = libc.Uint32FromInt32(int32((int64(pOp) - int64((*TVdbe)(unsafe.Pointer(p)).FaOp)) / 24)) + if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TVdbeFrame)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/uint32(8)))))&(int32(1)<<(iAddr&uint32(7))) != 0 { + goto jump_to_p2 + } + v191 = (*TVdbeFrame)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/uint32(8)) + *(*Tu8)(unsafe.Pointer(v191)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v191))) | libc.Int32FromInt32(1)<<(iAddr&libc.Uint32FromInt32(7))) + } else { + if (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp))).Fp1 == (*TOp)(unsafe.Pointer(pOp)).Fp1 { + goto jump_to_p2 + } + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp))).Fp1 + goto _189 + /* Opcode: If P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is true. The value + ** is considered true if it is numeric and non-zero. If the value + ** in P1 is NULL then take the jump if and only if P3 is non-zero. + */ + _57: + ; + c = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, (*TOp)(unsafe.Pointer(pOp)).Fp3) + if c != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IfNot P1 P2 P3 * * + ** + ** Jump to P2 if the value in register P1 is False. The value + ** is considered false if it has a numeric value of zero. If the value + ** in P1 is NULL then take the jump if and only if P3 is non-zero. + */ + _58: + ; + c1 = libc.BoolInt32(!(_sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, libc.BoolInt32(!((*TOp)(unsafe.Pointer(pOp)).Fp3 != 0))) != 0)) + if c1 != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IsNull P1 P2 * * * + ** Synopsis: if r[P1]==NULL goto P2 + ** + ** Jump to P2 if the value in register P1 is NULL. + */ + _59: + ; /* same as TK_ISNULL, jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IsType P1 P2 P3 P4 P5 + ** Synopsis: if typeof(P1.P3) in P5 goto P2 + ** + ** Jump to P2 if the type of a column in a btree is one of the types specified + ** by the P5 bitmask. + ** + ** P1 is normally a cursor on a btree for which the row decode cache is + ** valid through at least column P3. In other words, there should have been + ** a prior OP_Column for column P3 or greater. If the cursor is not valid, + ** then this opcode might give spurious results. + ** The the btree row has fewer than P3 columns, then use P4 as the + ** datatype. + ** + ** If P1 is -1, then P3 is a register number and the datatype is taken + ** from the value in that register. + ** + ** P5 is a bitmask of data types. SQLITE_INTEGER is the least significant + ** (0x01) bit. SQLITE_FLOAT is the 0x02 bit. SQLITE_TEXT is 0x04. + ** SQLITE_BLOB is 0x08. SQLITE_NULL is 0x10. + ** + ** WARNING: This opcode does not reliably distinguish between NULL and REAL + ** when P1>=0. If the database contains a NaN value, this opcode will think + ** that the datatype is REAL when it should be NULL. When P1<0 and the value + ** is already stored in register P3, then this opcode does reliably + ** distinguish between NULL and REAL. The problem only arises then P1>=0. + ** + ** Take the jump to address P2 if and only if the datatype of the + ** value determined by P1 and P3 corresponds to one of the bits in the + ** P5 bitmask. + ** + */ + _60: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp1 >= 0 { + pC = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 < libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) { + serialType = *(*Tu32)(unsafe.Pointer(pC + 120 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*4)) + if serialType >= uint32(12) { + if serialType&uint32(1) != 0 { + typeMask = uint16(0x04) /* SQLITE_TEXT */ + } else { + typeMask = uint16(0x08) /* SQLITE_BLOB */ + } + } else { + typeMask = uint16(_aMask[serialType]) + } + } else { + typeMask = libc.Uint16FromInt32(int32(1) << ((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi - int32(1))) + } + } else { + typeMask = libc.Uint16FromInt32(int32(1) << (Xsqlite3_value_type(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56) - int32(1))) + } + if libc.Int32FromUint16(typeMask)&libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: ZeroOrNull P1 P2 P3 * * + ** Synopsis: r[P2] = 0 OR NULL + ** + ** If both registers P1 and P3 are NOT NULL, then store a zero in + ** register P2. If either registers P1 or P3 are NULL then put + ** a NULL in register P2. + */ + _61: + ; /* in1, in2, out2, in3 */ + if libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56))).Fflags)&int32(MEM_Null) != 0 || libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fflags)&int32(MEM_Null) != 0 { + _sqlite3VdbeMemSetNull(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56) + } else { + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, 0) + } + goto _189 + /* Opcode: NotNull P1 P2 * * * + ** Synopsis: if r[P1]!=NULL goto P2 + ** + ** Jump to P2 if the value in register P1 is not NULL. + */ + _62: + ; /* same as TK_NOTNULL, jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: IfNullRow P1 P2 P3 * * + ** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2 + ** + ** Check the cursor P1 to see if it is currently pointing at a NULL row. + ** If it is, then set register P3 to NULL and jump immediately to P2. + ** If P1 is not on a NULL row, then fall through without making any + ** changes. + ** + ** If P1 is not an open cursor, then this opcode is a no-op. + */ + _63: + ; + pC1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pC1 != 0 && (*TVdbeCursor)(unsafe.Pointer(pC1)).FnullRow != 0 { + _sqlite3VdbeMemSetNull(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56) + goto jump_to_p2 + } + goto _189 + /* Opcode: Offset P1 P2 P3 * * + ** Synopsis: r[P3] = sqlite_offset(P1) + ** + ** Store in register r[P3] the byte offset into the database file that is the + ** start of the payload for the record at which that cursor P1 is currently + ** pointing. + ** + ** P2 is the column number for the argument to the sqlite_offset() function. + ** This opcode does not use P2 itself, but the P2 value is used by the + ** code generator. The P1, P2, and P3 operands to this opcode are the + ** same as for OP_Column. + ** + ** This opcode is only available if SQLite is compiled with the + ** -DSQLITE_ENABLE_OFFSET_SQL_FUNC option. + */ + _64: + ; /* The VDBE cursor */ + pC2 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pOut = (*TVdbe)(unsafe.Pointer(p)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if pC2 == uintptr(0) || libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC2)).FeCurType) != CURTYPE_BTREE { + _sqlite3VdbeMemSetNull(tls, pOut) + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC2)).FdeferredMoveto != 0 { + rc = _sqlite3VdbeFinishMoveto(tls, pC2) + if rc != 0 { + goto abort_due_to_error + } + } + if _sqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC2 + 48))) != 0 { + _sqlite3VdbeMemSetNull(tls, pOut) + } else { + _sqlite3VdbeMemSetInt64(tls, pOut, _sqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC2 + 48)))) + } + } + goto _189 + /* Opcode: Column P1 P2 P3 P4 P5 + ** Synopsis: r[P3]=PX cursor P1 column P2 + ** + ** Interpret the data that cursor P1 points to as a structure built using + ** the MakeRecord instruction. (See the MakeRecord opcode for additional + ** information about the format of the data.) Extract the P2-th column + ** from this record. If there are less than (P2+1) + ** values in the record, extract a NULL. + ** + ** The value extracted is stored in register P3. + ** + ** If the record contains fewer than P2 fields, then extract a NULL. Or, + ** if the P4 argument is a P4_MEM use the value of the P4 argument as + ** the result. + ** + ** If the OPFLAG_LENGTHARG bit is set in P5 then the result is guaranteed + ** to only be used by the length() function or the equivalent. The content + ** of large blobs is not loaded, thus saving CPU cycles. If the + ** OPFLAG_TYPEOFARG bit is set then the result will only be used by the + ** typeof() function or the IS NULL or IS NOT NULL operators or the + ** equivalent. In this case, all content loading can be omitted. + */ + _65: + ; /* PseudoTable input register */ + pC3 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + p22 = libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) + goto op_column_restart + op_column_restart: + ; + aOffset = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaOffset + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus != (*TVdbe)(unsafe.Pointer(p)).FcacheCtr { /*OPTIMIZATION-IF-FALSE*/ + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FnullRow != 0 { + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC3)).FeCurType) == int32(CURTYPE_PSEUDO) && (*TVdbeCursor)(unsafe.Pointer(pC3)).FseekResult > 0 { + /* For the special case of as pseudo-cursor, the seekResult field + ** identifies the register that holds the record */ + pReg = aMem + uintptr((*TVdbeCursor)(unsafe.Pointer(pC3)).FseekResult)*56 + v215 = libc.Uint32FromInt32((*TMem)(unsafe.Pointer(pReg)).Fn) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow = v215 + (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = v215 + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = (*TMem)(unsafe.Pointer(pReg)).Fz + } else { + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + _sqlite3VdbeMemSetNull(tls, pDest) + goto op_column_out + } + } else { + pCrsr = *(*uintptr)(unsafe.Pointer(pC3 + 48)) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FdeferredMoveto != 0 { + if v217 = *(*uintptr)(unsafe.Pointer(pC3 + 16)) != 0; v217 { + v215 = **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pC3 + 16)) + uintptr(uint32(1)+p22)*4)) + iMap = v215 + } + if v217 && v215 > uint32(0) { + pC3 = (*TVdbeCursor)(unsafe.Pointer(pC3)).FpAltCursor + p22 = iMap - uint32(1) + goto op_column_restart + } + rc = _sqlite3VdbeFinishMoveto(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + } else { + if _sqlite3BtreeCursorHasMoved(tls, pCrsr) != 0 { + rc = _sqlite3VdbeHandleMovedCursor(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + goto op_column_restart + } + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = _sqlite3BtreePayloadSize(tls, pCrsr) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = _sqlite3BtreePayloadFetch(tls, pCrsr, pC3+108) + /* Maximum page size is 64KiB */ + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = (*TVdbe)(unsafe.Pointer(p)).FcacheCtr + v215 = uint32(**(**Tu8)(__ccgo_up((*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow))) + **(**Tu32)(__ccgo_up(aOffset)) = v215 + if v215 < uint32(0x80) { + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = uint32(1) + } else { + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = uint32(_sqlite3GetVarint32(tls, (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow, aOffset)) + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = uint16(0) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow < **(**Tu32)(__ccgo_up(aOffset)) { /*OPTIMIZATION-IF-FALSE*/ + /* pC->aRow does not have to hold the entire row, but it does at least + ** need to cover the header of the record. If pC->aRow does not contain + ** the complete header, then set it to zero, forcing the header to be + ** dynamically allocated. */ + (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = uintptr(0) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow = uint32(0) + /* Make sure a corrupt database has not given us an oversize header. + ** Do this now to avoid an oversize memory allocation. + ** + ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte + ** types use so much data space that there can only be 4096 and 32 of + ** them, respectively. So the maximum header length results from a + ** 3-byte type for each of the maximum of 32768 columns plus three + ** extra bytes for the header length itself. 32768*3 + 3 = 98307. + */ + if **(**Tu32)(__ccgo_up(aOffset)) > uint32(98307) || **(**Tu32)(__ccgo_up(aOffset)) > (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize { + goto op_column_corrupt + } + } else { + /* This is an optimization. By skipping over the first few tests + ** (ex: pC->nHdrParsed<=p2) in the next section, we achieve a + ** measurable performance gain. + ** + ** This branch is taken even if aOffset[0]==0. Such a record is never + ** generated by SQLite, and could be considered corruption, but we + ** accept it for historical reasons. When aOffset[0]==0, the code this + ** branch jumps to reads past the end of the record, but never more + ** than a few bytes. Even if the record occurs at the end of the page + ** content area, the "page header" comes after the page content and so + ** this overread is harmless. Similar overreads can occur for a corrupt + ** database file. + */ + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + /* Conditional skipped */ + goto op_column_read_header + } + } else { + if _sqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(pC3 + 48))) != 0 { + rc = _sqlite3VdbeHandleMovedCursor(tls, pC3) + if rc != 0 { + goto abort_due_to_error + } + goto op_column_restart + } + } + /* Make sure at least the first p2+1 entries of the header have been + ** parsed and valid information is in aOffset[] and pC->aType[]. + */ + if !(uint32((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22) { + goto _219 + } + /* If there is more header available for parsing in the record, try + ** to extract additional fields up through the p2+1-th field + */ + if !((*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset < **(**Tu32)(__ccgo_up(aOffset))) { + goto _221 + } + /* Make sure zData points to enough of the record to cover the header. */ + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + libc.Xmemset(tls, bp+24, 0, uint64(56)) + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(pC3 + 48)), **(**Tu32)(__ccgo_up(aOffset)), bp+24) + if rc != SQLITE_OK { + goto abort_due_to_error + } + zData = (**(**TMem)(__ccgo_up(bp + 24))).Fz + } else { + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + } + /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */ + goto op_column_read_header + op_column_read_header: + ; + i1 = libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) + offset64 = uint64(**(**Tu32)(__ccgo_up(aOffset + uintptr(i1)*4))) + zHdr = zData + uintptr((*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset) + zEndHdr = zData + uintptr(**(**Tu32)(__ccgo_up(aOffset))) + for cond := true; cond; cond = libc.Uint32FromInt32(i1) <= p22 && zHdr < zEndHdr { + v216 = uint32(**(**Tu8)(__ccgo_up(zHdr))) + **(**Tu32)(__ccgo_up(bp + 80)) = v216 + v215 = v216 + *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(i1)*4)) = v215 + if v215 < uint32(0x80) { + zHdr = zHdr + 1 + offset64 = offset64 + uint64(_sqlite3VdbeOneByteSerialTypeLen(tls, uint8(**(**Tu32)(__ccgo_up(bp + 80))))) + } else { + zHdr = zHdr + uintptr(_sqlite3GetVarint32(tls, zHdr, bp+80)) + *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(i1)*4)) = **(**Tu32)(__ccgo_up(bp + 80)) + offset64 = offset64 + uint64(_sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 80)))) + } + i1 = i1 + 1 + v190 = i1 + **(**Tu32)(__ccgo_up(aOffset + uintptr(v190)*4)) = uint32(offset64 & libc.Uint64FromUint32(0xffffffff)) + } + /* The record is corrupt if any of the following are true: + ** (1) the bytes of the header extend past the declared header size + ** (2) the entire header was used but not all data was used + ** (3) the end of the data extends beyond the end of the record. + */ + if zHdr >= zEndHdr && (zHdr > zEndHdr || offset64 != uint64((*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize)) || offset64 > uint64((*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize) { + if **(**Tu32)(__ccgo_up(aOffset)) == uint32(0) { + i1 = 0 + zHdr = zEndHdr + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + _sqlite3VdbeMemRelease(tls, bp+24) + } + goto op_column_corrupt + } + } + (*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = libc.Uint16FromInt32(i1) + (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = libc.Uint32FromInt64(int64(zHdr) - int64(zData)) + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { + _sqlite3VdbeMemRelease(tls, bp+24) + } + goto _222 + _221: + ; + **(**Tu32)(__ccgo_up(bp + 80)) = uint32(0) + _222: + ; + /* If after trying to extract new entries from the header, nHdrParsed is + ** still not up to p2, that means that the record has fewer than p2 + ** columns. So the result will be either the default value or a NULL. + */ + if uint32((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22 { + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(11) { + _sqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16)), int32(MEM_Static)) + } else { + _sqlite3VdbeMemSetNull(tls, pDest) + } + goto op_column_out + } + goto _220 + _219: + ; + **(**Tu32)(__ccgo_up(bp + 80)) = *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(p22)*4)) + _220: + ; + /* Extract the content for the p2+1-th column. Control can only + ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are + ** all valid. + */ + pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pDest)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { + _sqlite3VdbeMemSetNull(tls, pDest) + } + if (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow >= **(**Tu32)(__ccgo_up(aOffset + uintptr(p22+uint32(1))*4)) { + /* This is the common case where the desired content fits on the original + ** page - where the content is not on an overflow page */ + zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + uintptr(**(**Tu32)(__ccgo_up(aOffset + uintptr(p22)*4))) + if **(**Tu32)(__ccgo_up(bp + 80)) < uint32(12) { + _sqlite3VdbeSerialGet(tls, zData, **(**Tu32)(__ccgo_up(bp + 80)), pDest) + } else { + v190 = libc.Int32FromUint32((**(**Tu32)(__ccgo_up(bp + 80)) - libc.Uint32FromInt32(12)) / libc.Uint32FromInt32(2)) + len1 = v190 + (*TMem)(unsafe.Pointer(pDest)).Fn = v190 + (*TMem)(unsafe.Pointer(pDest)).Fenc = encoding + if (*TMem)(unsafe.Pointer(pDest)).FszMalloc < len1+int32(2) { + if len1 > **(**int32)(__ccgo_up(db + 136)) { + goto too_big + } + (*TMem)(unsafe.Pointer(pDest)).Fflags = uint16(MEM_Null) + if _sqlite3VdbeMemGrow(tls, pDest, len1+int32(2), 0) != 0 { + goto no_mem + } + } else { + (*TMem)(unsafe.Pointer(pDest)).Fz = (*TMem)(unsafe.Pointer(pDest)).FzMalloc + } + libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pDest)).Fz, zData, libc.Uint64FromInt32(len1)) + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1))) = 0 + **(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1+int32(1)))) = 0 + (*TMem)(unsafe.Pointer(pDest)).Fflags = _aFlag1[**(**Tu32)(__ccgo_up(bp + 80))&uint32(1)] + } + } else { + (*TMem)(unsafe.Pointer(pDest)).Fenc = encoding + /* This branch happens only when content is on overflow pages */ + v227 = libc.Uint8FromInt32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) & libc.Int32FromInt32(OPFLAG_BYTELENARG)) + p5 = v227 + if libc.Int32FromUint8(v227) != 0 && (libc.Int32FromUint8(p5) == int32(OPFLAG_TYPEOFARG) || **(**Tu32)(__ccgo_up(bp + 80)) >= uint32(12) && (**(**Tu32)(__ccgo_up(bp + 80))&uint32(1) == uint32(0) || libc.Int32FromUint8(p5) == int32(OPFLAG_BYTELENARG))) || _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 80))) == uint32(0) { + /* Content is irrelevant for + ** 1. the typeof() function, + ** 2. the length(X) function if X is a blob, and + ** 3. if the content length is zero. + ** So we might as well use bogus content rather than reading + ** content from disk. + ** + ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the + ** buffer passed to it, debugging function VdbeMemPrettyPrint() may + ** read more. Use the global constant sqlite3CtypeMap[] as the array, + ** as that array is 256 bytes long (plenty for VdbeMemPrettyPrint()) + ** and it begins with a bunch of zeros. + */ + _sqlite3VdbeSerialGet(tls, uintptr(unsafe.Pointer(&_sqlite3CtypeMap)), **(**Tu32)(__ccgo_up(bp + 80)), pDest) + } else { + rc = _vdbeColumnFromOverflow(tls, pC3, libc.Int32FromUint32(p22), **(**Tu32)(__ccgo_up(bp + 80)), libc.Int64FromUint32(**(**Tu32)(__ccgo_up(aOffset + uintptr(p22)*4))), (*TVdbe)(unsafe.Pointer(p)).FcacheCtr, colCacheCtr, pDest) + if rc != 0 { + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + if rc == int32(SQLITE_TOOBIG) { + goto too_big + } + goto abort_due_to_error + } + } + } + goto op_column_out + op_column_out: + ; + goto _189 + goto op_column_corrupt + op_column_corrupt: + ; + if (**(**TOp)(__ccgo_up(aOp))).Fp3 > 0 { + pOp = aOp + uintptr((**(**TOp)(__ccgo_up(aOp))).Fp3-int32(1))*24 + goto _189 + } else { + rc = _sqlite3CorruptError(tls, int32(99741)) + goto abort_due_to_error + } + /* Opcode: TypeCheck P1 P2 P3 P4 * + ** Synopsis: typecheck(r[P1@P2]) + ** + ** Apply affinities to the range of P2 registers beginning with P1. + ** Take the affinities from the Table object in P4. If any value + ** cannot be coerced into the correct type, then raise an error. + ** + ** If P3==0, then omit checking of VIRTUAL columns. + ** + ** If P3==1, then omit checking of all generated column, both VIRTUAL + ** and STORED. + ** + ** If P3>=2, then only check column number P3-2 in the table (which will + ** be a VIRTUAL column) against the value in reg[P1]. In this case, + ** P2 will be 1. + ** + ** This opcode is similar to OP_Affinity except that this opcode + ** forces the register type to the Table column type. This is used + ** to implement "strict affinity". + ** + ** GENERATED ALWAYS AS ... STATIC columns are only checked if P3 + ** is zero. When P3 is non-zero, no type checking occurs for + ** static generated columns. Virtual columns are computed at query time + ** and so they are never checked. + ** + ** Preconditions: + ** + **
      + **
    • P2 should be the number of non-virtual columns in the + ** table of P4 unless P3>1, in which case P2 will be 1. + **
    • Table P4 is a STRICT table. + **
    + ** + ** If any precondition is false, an assertion fault occurs. + */ + _66: + ; + pTab = *(*uintptr)(unsafe.Pointer(pOp + 16)) + aCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*TOp)(unsafe.Pointer(pOp)).Fp3 < int32(2) { + i2 = 0 + nCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) + } else { + i2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 - int32(2) + nCol = i2 + int32(1) + } + for { + if !(i2 < nCol) { + break + } + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 && (*TOp)(unsafe.Pointer(pOp)).Fp3 < int32(2) { + if libc.Int32FromUint16((**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { + goto _228 + } + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + pIn1 += 56 + goto _228 + } + } + _applyAffinity(tls, pIn1, (**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).Faffinity, encoding) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { + switch int32(uint32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 8)) & 0xf0 >> 4)) { + case int32(COLTYPE_BLOB): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_INTEGER): + fallthrough + case int32(COLTYPE_INT): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Int) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_TEXT): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Str) == 0 { + goto vdbe_type_error + } + case int32(COLTYPE_REAL): + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Int) != 0 { + /* When applying REAL affinity, if the result is still an MEM_Int + ** that will fit in 6 bytes, then change the type to MEM_IntReal + ** so that we keep the high-resolution integer value but know that + ** the type really wants to be REAL. */ + if *(*Ti64)(unsafe.Pointer(pIn1)) <= int64(140737488355327) && *(*Ti64)(unsafe.Pointer(pIn1)) >= -int64(140737488355328) { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } else { + *(*float64)(unsafe.Pointer(pIn1)) = float64(*(*Ti64)(unsafe.Pointer(pIn1))) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + goto vdbe_type_error + } + } + default: + /* COLTYPE_ANY. Accept anything. */ + break + } + } + pIn1 += 56 + goto _228 + _228: + ; + i2 = i2 + 1 + } + goto _189 + goto vdbe_type_error + vdbe_type_error: + ; + _sqlite3VdbeError(tls, p, __ccgo_ts+5884, libc.VaList(bp+984, _vdbeMemTypeName(tls, pIn1), _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 8))&0xf0>>4))-int32(1)], (*TTable)(unsafe.Pointer(pTab)).FzName, (**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FzCnName)) + rc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(12)<= -int64(140737488355328) { + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } else { + *(*float64)(unsafe.Pointer(pIn1)) = float64(*(*Ti64)(unsafe.Pointer(pIn1))) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Str))) + } + } + zAffinity = zAffinity + 1 + if int32(**(**int8)(__ccgo_up(zAffinity))) == 0 { + break + } + pIn1 += 56 + } + goto _189 + /* Opcode: MakeRecord P1 P2 P3 P4 * + ** Synopsis: r[P3]=mkrec(r[P1@P2]) + ** + ** Convert P2 registers beginning with P1 into the [record format] + ** use as a data record in a database table or as a key + ** in an index. The OP_Column opcode can decode the record later. + ** + ** P4 may be a string that is P2 characters long. The N-th character of the + ** string indicates the column affinity that should be used for the N-th + ** field of the index key. + ** + ** The mapping from character to affinity is given by the SQLITE_AFF_ + ** macros defined in sqliteInt.h. + ** + ** If P4 is NULL then all index fields have the affinity BLOB. + ** + ** The meaning of P5 depends on whether or not the SQLITE_ENABLE_NULL_TRIM + ** compile-time option is enabled: + ** + ** * If SQLITE_ENABLE_NULL_TRIM is enabled, then the P5 is the index + ** of the right-most table that can be null-trimmed. + ** + ** * If SQLITE_ENABLE_NULL_TRIM is omitted, then P5 has the value + ** OPFLAG_NOCHNG_MAGIC if the OP_MakeRecord opcode is allowed to + ** accept no-change records with serial_type 10. This value is + ** only used inside an assert() and does not affect the end result. + */ + _68: + ; /* Where to write next byte of the payload */ + /* Assuming the record contains N fields, the record format looks + ** like this: + ** + ** ------------------------------------------------------------------------ + ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | + ** ------------------------------------------------------------------------ + ** + ** Data(0) is taken from register P1. Data(1) comes from register P1+1 + ** and so forth. + ** + ** Each type field is a varint representing the serial type of the + ** corresponding data element (see sqlite3VdbeSerialType()). The + ** hdr-size field is also a varint which is the offset from the beginning + ** of the record to data0. + */ + nData = uint64(0) /* Number of bytes of data space */ + nHdr = 0 /* Number of bytes of header space */ + nZero = 0 /* Number of zero bytes at the end of the record */ + nField = (*TOp)(unsafe.Pointer(pOp)).Fp1 + zAffinity1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pData0 = aMem + uintptr(nField)*56 + nField = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pLast = pData0 + uintptr(nField-int32(1))*56 + /* Identify the output register */ + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + /* Apply the requested affinity to all inputs + */ + if zAffinity1 != 0 { + pRec = pData0 + for cond := true; cond; cond = **(**int8)(__ccgo_up(zAffinity1)) != 0 { + _applyAffinity(tls, pRec, **(**int8)(__ccgo_up(zAffinity1)), encoding) + if int32(**(**int8)(__ccgo_up(zAffinity1))) == int32(SQLITE_AFF_REAL) && libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Int) != 0 { + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) + } + zAffinity1 = zAffinity1 + 1 + pRec += 56 + } + } + /* Loop through the elements that will make up the record to figure + ** out how much space is required for the new record. After this loop, + ** the Mem.uTemp field of each term should hold the serial-type that will + ** be used for that term in the generated record: + ** + ** Mem.uTemp value type + ** --------------- --------------- + ** 0 NULL + ** 1 1-byte signed integer + ** 2 2-byte signed integer + ** 3 3-byte signed integer + ** 4 4-byte signed integer + ** 5 6-byte signed integer + ** 6 8-byte signed integer + ** 7 IEEE float + ** 8 Integer constant 0 + ** 9 Integer constant 1 + ** 10,11 reserved for expansion + ** N>=12 and even BLOB + ** N>=13 and odd text + ** + ** The following additional values are computed: + ** nHdr Number of bytes needed for the record header + ** nData Number of bytes of data space needed for the record + ** nZero Zero bytes at the end of the record + */ + pRec = pLast + for cond := true; cond; cond = int32(1) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Null) != 0 { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Zero) != 0 { + /* Values with MEM_Null and MEM_Zero are created by xColumn virtual + ** table methods that never invoke sqlite3_result_xxxxx() while + ** computing an unchanging column value in an UPDATE statement. + ** Give such values a special internal-use-only serial-type of 10 + ** so that they can be passed through to xUpdate and have + ** a true sqlite3_value_nochange(). */ + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(10) + } else { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(0) + } + nHdr = nHdr + 1 + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */ + i3 = *(*Ti64)(unsafe.Pointer(pRec)) + if i3 < 0 { + uu = libc.Uint64FromInt64(^i3) + } else { + uu = libc.Uint64FromInt64(i3) + } + nHdr = nHdr + 1 + if uu <= uint64(127) { + if i3&int64(1) == i3 && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat) >= int32(4) { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(8) + uint32(uu) + } else { + nData = nData + 1 + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(1) + } + } else { + if uu <= uint64(32767) { + nData = nData + uint64(2) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(2) + } else { + if uu <= uint64(8388607) { + nData = nData + uint64(3) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(3) + } else { + if uu <= uint64(2147483647) { + nData = nData + uint64(4) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(4) + } else { + if uu <= uint64(140737488355327) { + nData = nData + uint64(6) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(5) + } else { + nData = nData + uint64(8) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_IntReal) != 0 { + /* If the value is IntReal and is going to take up 8 bytes to store + ** as an integer, then we might as well make it an 8-byte floating + ** point value */ + *(*float64)(unsafe.Pointer(pRec)) = float64(*(*Ti64)(unsafe.Pointer(pRec))) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_IntReal)) + v191 = pRec + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(7) + } else { + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(6) + } + } + } + } + } + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Real) != 0 { + nHdr = nHdr + 1 + nData = nData + uint64(8) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(7) + } else { + len11 = libc.Uint32FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn) + serial_type = len11*uint32(2) + uint32(12) + libc.BoolUint32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&libc.Int32FromInt32(MEM_Str) != libc.Int32FromInt32(0)) + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Zero) != 0 { + serial_type = serial_type + libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu)))*uint32(2) + if nData != 0 { + if _sqlite3VdbeMemExpandBlob(tls, pRec) != 0 { + goto no_mem + } + len11 = len11 + libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu))) + } else { + nZero = nZero + int64(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu))) + } + } + nData = nData + uint64(len11) + nHdr = nHdr + _sqlite3VarintLen(tls, uint64(serial_type)) + (*TMem)(unsafe.Pointer(pRec)).FuTemp = serial_type + } + } + } + if pRec == pData0 { + break + } + pRec -= 56 + } + /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint + ** which determines the total number of bytes in the header. The varint + ** value is the size of the header in bytes including the size varint + ** itself. */ + if nHdr <= int32(126) { + /* The common case */ + nHdr = nHdr + int32(1) + } else { + /* Rare case of a really large header */ + nVarint = _sqlite3VarintLen(tls, libc.Uint64FromInt32(nHdr)) + nHdr = nHdr + nVarint + if nVarint < _sqlite3VarintLen(tls, libc.Uint64FromInt32(nHdr)) { + nHdr = nHdr + 1 + } + } + nByte1 = libc.Int64FromUint64(libc.Uint64FromInt32(nHdr) + nData) + /* Make sure the output register has a buffer large enough to store + ** the new record. The output register (pOp->p3) is not allowed to + ** be one of the input registers (because the following call to + ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used). + */ + if nByte1+nZero <= int64((*TMem)(unsafe.Pointer(pOut)).FszMalloc) { + /* The output register is already large enough to hold the record. + ** No error checks or buffer enlargement is required */ + (*TMem)(unsafe.Pointer(pOut)).Fz = (*TMem)(unsafe.Pointer(pOut)).FzMalloc + } else { + /* Need to make sure that the output is not too big and then enlarge + ** the output register to hold the full result */ + if nByte1+nZero > int64(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + if _sqlite3VdbeMemClearAndResize(tls, pOut, int32(nByte1)) != 0 { + goto no_mem + } + } + (*TMem)(unsafe.Pointer(pOut)).Fn = int32(nByte1) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Blob) + if nZero != 0 { + *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pOut)).Fu)) = int32(nZero) + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Zero)) + } + zHdr1 = (*TMem)(unsafe.Pointer(pOut)).Fz + zPayload = zHdr1 + uintptr(nHdr) + /* Write the record */ + if nHdr < int32(0x80) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = libc.Uint8FromInt32(nHdr) + } else { + zHdr1 = zHdr1 + uintptr(_sqlite3PutVarint(tls, zHdr1, libc.Uint64FromInt32(nHdr))) + } + pRec = pData0 + for int32(1) != 0 { + serial_type = (*TMem)(unsafe.Pointer(pRec)).FuTemp + /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more + ** additional varints, one per column. + ** EVIDENCE-OF: R-64536-51728 The values for each column in the record + ** immediately follow the header. */ + if serial_type <= uint32(7) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = uint8(serial_type) + if serial_type == uint32(0) { + /* NULL value. No change in zPayload */ + } else { + if serial_type == uint32(7) { + libc.Xmemcpy(tls, bp+88, pRec, uint64(8)) + } else { + **(**Tu64)(__ccgo_up(bp + 88)) = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(pRec))) + } + len11 = uint32(_sqlite3SmallTypeSizes[serial_type]) + switch len11 { + default: + **(**Tu8)(__ccgo_up(zPayload + 7)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + **(**Tu8)(__ccgo_up(zPayload + 6)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(6): + **(**Tu8)(__ccgo_up(zPayload + 5)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + **(**Tu8)(__ccgo_up(zPayload + 4)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(4): + **(**Tu8)(__ccgo_up(zPayload + 3)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(3): + **(**Tu8)(__ccgo_up(zPayload + 2)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(2): + **(**Tu8)(__ccgo_up(zPayload + 1)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) + fallthrough + case uint32(1): + **(**Tu8)(__ccgo_up(zPayload)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) + } + zPayload = zPayload + uintptr(len11) + } + } else { + if serial_type < uint32(0x80) { + v191 = zHdr1 + zHdr1 = zHdr1 + 1 + **(**Tu8)(__ccgo_up(v191)) = uint8(serial_type) + if serial_type >= uint32(14) && (*TMem)(unsafe.Pointer(pRec)).Fn > 0 { + libc.Xmemcpy(tls, zPayload, (*TMem)(unsafe.Pointer(pRec)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn)) + zPayload = zPayload + uintptr((*TMem)(unsafe.Pointer(pRec)).Fn) + } + } else { + zHdr1 = zHdr1 + uintptr(_sqlite3PutVarint(tls, zHdr1, uint64(serial_type))) + if (*TMem)(unsafe.Pointer(pRec)).Fn != 0 { + libc.Xmemcpy(tls, zPayload, (*TMem)(unsafe.Pointer(pRec)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn)) + zPayload = zPayload + uintptr((*TMem)(unsafe.Pointer(pRec)).Fn) + } + } + } + if pRec == pLast { + break + } + pRec += 56 + } + goto _189 + /* Opcode: Count P1 P2 P3 * * + ** Synopsis: r[P2]=count() + ** + ** Store the number of entries (an integer value) in the table or index + ** opened by cursor P1 in register P2. + ** + ** If P3==0, then an exact count is obtained, which involves visiting + ** every btree page of the table. But if P3 is non-zero, an estimate + ** is returned based on the current cursor position. + */ + _69: + ; + pCrsr1 = *(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + 48)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + **(**Ti64)(__ccgo_up(bp + 96)) = _sqlite3BtreeRowCountEst(tls, pCrsr1) + } else { + **(**Ti64)(__ccgo_up(bp + 96)) = 0 /* Not needed. Only used to silence a warning. */ + rc = _sqlite3BtreeCount(tls, db, pCrsr1, bp+96) + if rc != 0 { + goto abort_due_to_error + } + } + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 96)) + goto check_for_interrupt + /* Opcode: Savepoint P1 * * P4 * + ** + ** Open, release or rollback the savepoint named by parameter P4, depending + ** on the value of P1. To open a new savepoint set P1==0 (SAVEPOINT_BEGIN). + ** To release (commit) an existing savepoint set P1==1 (SAVEPOINT_RELEASE). + ** To rollback an existing savepoint set P1==2 (SAVEPOINT_ROLLBACK). + */ + _70: + ; + p12 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + zName = *(*uintptr)(unsafe.Pointer(pOp + 16)) + /* Assert that the p1 parameter is valid. Also that if there is no open + ** transaction, then there cannot be any savepoints. + */ + if p12 == SAVEPOINT_BEGIN { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 { + /* A new savepoint cannot be created if there are active write + ** statements (i.e. open read/write incremental blob handles). + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+5925, 0) + rc = int32(SQLITE_BUSY) + } else { + nName = _sqlite3Strlen30(tls, zName) + /* This call is Ok even if this savepoint is actually a transaction + ** savepoint (and therefore should not prompt xSavepoint()) callbacks. + ** If this is a transaction savepoint being opened, it is guaranteed + ** that the db->aVTrans[] array is empty. */ + rc = _sqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*Tsqlite3)(unsafe.Pointer(db)).FnStatement+(*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint) + if rc != SQLITE_OK { + goto abort_due_to_error + } + /* Create a new savepoint structure. */ + pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(32)+libc.Uint64FromInt32(nName)+uint64(1))) + if pNew != 0 { + (*TSavepoint)(unsafe.Pointer(pNew)).FzName = pNew + 1*32 + libc.Xmemcpy(tls, (*TSavepoint)(unsafe.Pointer(pNew)).FzName, zName, libc.Uint64FromInt32(nName+int32(1))) + /* If there is no open transaction, then mark this as a special + ** "transaction savepoint". */ + if (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(1) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + 1 + } + /* Link the new savepoint into the database handle's list. */ + (*TSavepoint)(unsafe.Pointer(pNew)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint + (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint = pNew + (*TSavepoint)(unsafe.Pointer(pNew)).FnDeferredCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons + (*TSavepoint)(unsafe.Pointer(pNew)).FnDeferredImmCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons + } + } + } else { + iSavepoint = 0 + /* Find the named savepoint. If there is no such savepoint, then an + ** an error is returned to the user. */ + pSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint + for { + if !(pSavepoint != 0 && _sqlite3StrICmp(tls, (*TSavepoint)(unsafe.Pointer(pSavepoint)).FzName, zName) != 0) { + break + } + iSavepoint = iSavepoint + 1 + goto _245 + _245: + ; + pSavepoint = (*TSavepoint)(unsafe.Pointer(pSavepoint)).FpNext + } + if !(pSavepoint != 0) { + _sqlite3VdbeError(tls, p, __ccgo_ts+5976, libc.VaList(bp+984, zName)) + rc = int32(SQLITE_ERROR) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 && p12 == int32(SAVEPOINT_RELEASE) { + /* It is not possible to release (commit) a savepoint if there are + ** active write statements. + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+5998, 0) + rc = int32(SQLITE_BUSY) + } else { + /* Determine whether or not this is a transaction savepoint. If so, + ** and this is a RELEASE command, then the current transaction + ** is committed. + */ + isTransaction = libc.BoolInt32((*TSavepoint)(unsafe.Pointer(pSavepoint)).FpNext == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint != 0) + if isTransaction != 0 && p12 == int32(SAVEPOINT_RELEASE) { + v190 = _sqlite3VdbeCheckFkDeferred(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto vdbe_return + } + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(1) + if _sqlite3VdbeHalt(tls, p) == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + v190 = libc.Int32FromInt32(SQLITE_BUSY) + rc = v190 + (*TVdbe)(unsafe.Pointer(p)).Frc = v190 + goto vdbe_return + } + rc = (*TVdbe)(unsafe.Pointer(p)).Frc + if rc != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(0) + } + } else { + iSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint - iSavepoint - int32(1) + if p12 == int32(SAVEPOINT_ROLLBACK) { + isSchemaChange = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_SchemaChange) != uint32(0)) + ii = 0 + for { + if !(ii < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { + break + } + rc = _sqlite3BtreeTripAllCursors(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii)*32))).FpBt, libc.Int32FromInt32(SQLITE_ABORT)|libc.Int32FromInt32(2)< 0 { + /* If this instruction implements a COMMIT and other VMs are writing + ** return an error indicating that the other VMs must complete first. + */ + _sqlite3VdbeError(tls, p, __ccgo_ts+6052, 0) + rc = int32(SQLITE_BUSY) + goto abort_due_to_error + } else { + v190 = _sqlite3VdbeCheckFkDeferred(tls, p) + rc = v190 + if v190 != SQLITE_OK { + goto vdbe_return + } else { + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = libc.Uint8FromInt32(desiredAutoCommit) + } + } + } + if _sqlite3VdbeHalt(tls, p) == int32(SQLITE_BUSY) { + (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = libc.Uint8FromInt32(libc.Int32FromInt32(1) - desiredAutoCommit) + v190 = libc.Int32FromInt32(SQLITE_BUSY) + rc = v190 + (*TVdbe)(unsafe.Pointer(p)).Frc = v190 + goto vdbe_return + } + _sqlite3CloseSavepoints(tls, db) + if (*TVdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rc = int32(SQLITE_DONE) + } else { + rc = int32(SQLITE_ERROR) + } + goto vdbe_return + } else { + if !(desiredAutoCommit != 0) { + v191 = __ccgo_ts + 6107 + } else { + if iRollback != 0 { + v194 = __ccgo_ts + 6155 + } else { + v194 = __ccgo_ts + 6198 + } + v191 = v194 + } + _sqlite3VdbeError(tls, p, v191, 0) + rc = int32(SQLITE_ERROR) + goto abort_due_to_error + } + /* Opcode: Transaction P1 P2 P3 P4 P5 + ** + ** Begin a transaction on database P1 if a transaction is not already + ** active. + ** If P2 is non-zero, then a write-transaction is started, or if a + ** read-transaction is already active, it is upgraded to a write-transaction. + ** If P2 is zero, then a read-transaction is started. If P2 is 2 or more + ** then an exclusive transaction is started. + ** + ** P1 is the index of the database file on which the transaction is + ** started. Index 0 is the main database file and index 1 is the + ** file used for temporary tables. Indices of 2 or more are used for + ** attached databases. + ** + ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is + ** true (this flag is set if the Vdbe may modify more than one row and may + ** throw an ABORT exception), a statement transaction may also be opened. + ** More specifically, a statement transaction is opened iff the database + ** connection is currently not in autocommit mode, or if there are other + ** active statements. A statement transaction allows the changes made by this + ** VDBE to be rolled back after an error without having to roll back the + ** entire transaction. If no error is encountered, the statement transaction + ** will automatically commit when the VDBE halts. + ** + ** If P5!=0 then this opcode also checks the schema cookie against P3 + ** and the schema generation counter against P4. + ** The cookie changes its value whenever the database schema changes. + ** This operation is used to detect when that the cookie has changed + ** and that the current process needs to reread the schema. If the schema + ** cookie in P3 differs from the schema cookie in the database header or + ** if the schema generation counter in P4 differs from the current + ** generation counter, then an SQLITE_SCHEMA error is raised and execution + ** halts. The sqlite3_step() wrapper function might then reprepare the + ** statement and rerun it from the beginning. + */ + _72: + ; + **(**int32)(__ccgo_up(bp + 104)) = 0 + if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(SQLITE_QueryOnly)|libc.Uint64FromInt32(libc.Int32FromInt32(0x00002))<>5)) != 0 && (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 && (libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 || (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1)) { + if (*TVdbe)(unsafe.Pointer(p)).FiStatement == 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnStatement + 1 + (*TVdbe)(unsafe.Pointer(p)).FiStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement + } + rc = _sqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*TVdbe)(unsafe.Pointer(p)).FiStatement-int32(1)) + if rc == SQLITE_OK { + rc = _sqlite3BtreeBeginStmt(tls, pBt, (*TVdbe)(unsafe.Pointer(p)).FiStatement) + } + /* Store the current value of the database handles deferred constraint + ** counter. If the statement transaction needs to be rolled back, + ** the value of this counter needs to be restored too. */ + (*TVdbe)(unsafe.Pointer(p)).FnStmtDefCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons + (*TVdbe)(unsafe.Pointer(p)).FnStmtDefImmCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons + } + } + if rc == SQLITE_OK && (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 && (**(**int32)(__ccgo_up(bp + 104)) != (*TOp)(unsafe.Pointer(pOp)).Fp3 || (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FiGeneration != (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) { + /* + ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema + ** version is checked to ensure that the schema has not changed since the + ** SQL statement was prepared. + */ + _sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg) + (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3DbStrDup(tls, db, __ccgo_ts+6239) + /* If the schema-cookie from the database file matches the cookie + ** stored with the in-memory representation of the schema, do + ** not reload the schema from the database file. + ** + ** If virtual-tables are in use, this is not just an optimization. + ** Often, v-tables store their data in other SQLite tables, which + ** are queried from within xNext() and other v-table methods using + ** prepared queries. If such a query is out-of-date, we do not want to + ** discard the database schema, as the user code implementing the + ** v-table would have to be ready for the sqlite3_vtab structure itself + ** to be invalidated whenever sqlite3_step() is called from within + ** a v-table method. + */ + if (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpSchema)).Fschema_cookie != **(**int32)(__ccgo_up(bp + 104)) { + _sqlite3ResetOneSchema(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + } + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 0, 0x3) + rc = int32(SQLITE_SCHEMA) + /* Set changeCntOn to 0 to prevent the value returned by sqlite3_changes() + ** from being modified in sqlite3VdbeHalt(). If this statement is + ** reprepared, changeCntOn will be set again. */ + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 4, 0x10) + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: ReadCookie P1 P2 P3 * * + ** + ** Read cookie number P3 from database P1 and write it into register P2. + ** P3==1 is the schema version. P3==2 is the database format. + ** P3==3 is the recommended pager cache size, and so forth. P1==0 is + ** the main database file and P1==1 is the database file used to store + ** temporary tables. + ** + ** There must be a read-lock on the database (either a transaction + ** must be started or there must be an open cursor) before + ** executing this instruction. + */ + _73: + ; + iDb = (*TOp)(unsafe.Pointer(pOp)).Fp1 + iCookie = (*TOp)(unsafe.Pointer(pOp)).Fp3 + _sqlite3BtreeGetMeta(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt, iCookie, bp+108) + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = int64(**(**int32)(__ccgo_up(bp + 108))) + goto _189 + /* Opcode: SetCookie P1 P2 P3 * P5 + ** + ** Write the integer value P3 into cookie number P2 of database P1. + ** P2==1 is the schema version. P2==2 is the database format. + ** P2==3 is the recommended pager cache + ** size, and so forth. P1==0 is the main database file and P1==1 is the + ** database file used to store temporary tables. + ** + ** A transaction must be started before executing this opcode. + ** + ** If P2 is the SCHEMA_VERSION cookie (cookie number 1) then the internal + ** schema version is set to P3-P5. The "PRAGMA schema_version=N" statement + ** has P5 set to 1, so that the internal schema version will be different + ** from the database schema version, resulting in a schema reset. + */ + _74: + ; + pDb1 = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32 + /* See note about index shifting on OP_ReadCookie */ + rc = _sqlite3BtreeUpdateMeta(tls, (*TDb)(unsafe.Pointer(pDb1)).FpBt, (*TOp)(unsafe.Pointer(pOp)).Fp2, libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3)) + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == int32(BTREE_SCHEMA_VERSION) { + /* When the schema cookie changes, record the new cookie internally */ + **(**Tu32)(__ccgo_up((*TDb)(unsafe.Pointer(pDb1)).FpSchema)) = **(**Tu32)(__ccgo_up(pOp + 12)) - uint32((*TOp)(unsafe.Pointer(pOp)).Fp5) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + _sqlite3FkClearTriggerCache(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + } else { + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == int32(BTREE_FILE_FORMAT) { + /* Record changes in the file format */ + (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb1)).FpSchema)).Ffile_format = libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 == int32(1) { + /* Invalidate all prepared statements whenever the TEMP database + ** schema is changed. Ticket #1644 */ + _sqlite3ExpirePreparedStatements(tls, db, 0) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: OpenRead P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** Open a read-only cursor for the database table whose root page is + ** P2 in a database file. The database file is determined by P3. + ** P3==0 means the main database, P3==1 means the database used for + ** temporary tables, and P3>1 means used the corresponding attached + ** database. Give the new cursor an identifier of P1. The P1 + ** values need not be contiguous but all P1 values should be small integers. + ** It is an error for P1 to be negative. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** object, then table being opened must be an [index b-tree] where the + ** KeyInfo object defines the content and collating + ** sequence of that index b-tree. Otherwise, if P4 is an integer + ** value, then the table being opened must be a [table b-tree] with a + ** number of columns no less than the value of P4. + ** + ** See also: OpenWrite, ReopenIdx + */ + /* Opcode: ReopenIdx P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** The ReopenIdx opcode works like OP_OpenRead except that it first + ** checks to see if the cursor on P1 is already open on the same + ** b-tree and if it is this opcode becomes a no-op. In other words, + ** if the cursor is already open, do not reopen it. + ** + ** The ReopenIdx opcode may only be used with P5==0 or P5==OPFLAG_SEEKEQ + ** and with P4 being a P4_KEYINFO object. Furthermore, the P3 value must + ** be the same as every other ReopenIdx or OpenRead for the same cursor + ** number. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    + ** + ** See also: OP_OpenRead, OP_OpenWrite + */ + /* Opcode: OpenWrite P1 P2 P3 P4 P5 + ** Synopsis: root=P2 iDb=P3 + ** + ** Open a read/write cursor named P1 on the table or index whose root + ** page is P2 (or whose root page is held in register P2 if the + ** OPFLAG_P2ISREG bit is set in P5 - see below). + ** + ** The P4 value may be either an integer (P4_INT32) or a pointer to + ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo + ** object, then table being opened must be an [index b-tree] where the + ** KeyInfo object defines the content and collating + ** sequence of that index b-tree. Otherwise, if P4 is an integer + ** value, then the table being opened must be a [table b-tree] with a + ** number of columns no less than the value of P4. + ** + ** Allowed P5 bits: + **
      + **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for + ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT + ** of OP_SeekLE/OP_IdxLT) + **
    • 0x08 OPFLAG_FORDELETE: This cursor is used only to seek + ** and subsequently delete entries in an index btree. This is a + ** hint to the storage engine that the storage engine is allowed to + ** ignore. The hint is not used by the official SQLite b*tree storage + ** engine, but is used by COMDB2. + **
    • 0x10 OPFLAG_P2ISREG: Use the content of register P2 + ** as the root page, not the value of P2 itself. + **
    + ** + ** This instruction works like OpenRead except that it opens the cursor + ** in read/write mode. + ** + ** See also: OP_OpenRead, OP_ReopenIdx + */ + _77: + ; + pCur = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCur != 0 && (*TVdbeCursor)(unsafe.Pointer(pCur)).FpgnoRoot == libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) { + /* Guaranteed by the code generator */ + _sqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pCur + 48))) + goto open_cursor_set_hints + } + /* If the cursor is not currently open or is open on a different + ** index, then fall through into OP_OpenRead to force a reopen */ + _76: + ; /* ncycle */ + _75: + ; + if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x3>>0)) == int32(1) { + rc = libc.Int32FromInt32(SQLITE_ABORT) | libc.Int32FromInt32(2)<>2))), 2, 0x4) + *(*uintptr)(unsafe.Pointer(pCx + 16)) = *(*uintptr)(unsafe.Pointer(pOrig + 16)) + libc.SetBitFieldPtr8Uint32(pCx+8, libc.Uint32FromInt32(1), 3, 0x8) + libc.SetBitFieldPtr8Uint32(pOrig+8, libc.Uint32FromInt32(1), 3, 0x8) + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx + 16)), (*TVdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, int32(BTREE_WRCSR), (*TVdbeCursor)(unsafe.Pointer(pCx)).FpKeyInfo, *(*uintptr)(unsafe.Pointer(pCx + 48))) + /* The sqlite3BtreeCursor() routine can only fail for the first cursor + ** opened for a database. Since there is already an open cursor when this + ** opcode is run, the sqlite3BtreeCursor() cannot fail */ + goto _189 + /* Opcode: OpenEphemeral P1 P2 P3 P4 P5 + ** Synopsis: nColumn=P2 + ** + ** Open a new cursor P1 to a transient table. + ** The cursor is always opened read/write even if + ** the main database is read-only. The ephemeral + ** table is deleted automatically when the cursor is closed. + ** + ** If the cursor P1 is already opened on an ephemeral table, the table + ** is cleared (all content is erased). + ** + ** P2 is the number of columns in the ephemeral table. + ** The cursor points to a BTree table if P4==0 and to a BTree index + ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure + ** that defines the format of keys in the index. + ** + ** The P5 parameter can be a mask of the BTREE_* flags defined + ** in btree.h. These flags control aspects of the operation of + ** the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are + ** added automatically. + ** + ** If P3 is positive, then reg[P3] is modified slightly so that it + ** can be used as zero-length data for OP_Insert. This is an optimization + ** that avoids an extra OP_Blob opcode to initialize that register. + */ + /* Opcode: OpenAutoindex P1 P2 * P4 * + ** Synopsis: nColumn=P2 + ** + ** This opcode works the same as OP_OpenEphemeral. It has a + ** different name to distinguish its use. Tables created using + ** by this opcode will be used for automatically created transient + ** indices in joins. + */ + _80: + ; /* ncycle */ + _79: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp3 > 0 { + /* Make register reg[P3] into a value that can be used as the data + ** form sqlite3BtreeInsert() where the length of the data is zero. */ + /* Only used when number of columns is zero */ + (**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fn = 0 + (**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fz = __ccgo_ts + 1704 + } + pCx1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCx1 != 0 && !(int32(TBool(*(*uint8)(unsafe.Pointer(pCx1 + 8))&0x8>>3)) != 0) && (*TOp)(unsafe.Pointer(pOp)).Fp2 <= int32((*TVdbeCursor)(unsafe.Pointer(pCx1)).FnField) { + /* If the ephemeral table is already open and has no duplicates from + ** OP_OpenDup, then erase all existing content so that the table is + ** empty again, rather than creating a new table. */ + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FseqCount = 0 + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = uint32(CACHE_STALE) + rc = _sqlite3BtreeClearTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), libc.Int32FromUint32((*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot), uintptr(0)) + } else { + pCx1 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_BTREE)) + if pCx1 == uintptr(0) { + goto no_mem + } + libc.SetBitFieldPtr8Uint32(pCx1+8, libc.Uint32FromInt32(1), 0, 0x1) + rc = _sqlite3BtreeOpen(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, pCx1+16, libc.Int32FromInt32(BTREE_OMIT_JOURNAL)|libc.Int32FromInt32(BTREE_SINGLE)|libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5), _vfsFlags) + if rc == SQLITE_OK { + rc = _sqlite3BtreeBeginTrans(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), int32(1), uintptr(0)) + if rc == SQLITE_OK { + /* If a transient index is required, create it by calling + ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before + ** opening it. If a transient table is required, just use the + ** automatically created table with root-page 1 (an BLOB_INTKEY table). + */ + v194 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pKeyInfo2 = v194 + v191 = v194 + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpKeyInfo = v191 + if v191 != uintptr(0) { + rc = _sqlite3BtreeCreateTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), pCx1+68, int32(BTREE_BLOBKEY)|libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)) + if rc == SQLITE_OK { + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, int32(BTREE_WRCSR), pKeyInfo2, *(*uintptr)(unsafe.Pointer(pCx1 + 48))) + } + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FisTable = uint8(0) + } else { + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = uint32(SCHEMA_ROOT) + rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), uint32(SCHEMA_ROOT), int32(BTREE_WRCSR), uintptr(0), *(*uintptr)(unsafe.Pointer(pCx1 + 48))) + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FisTable = uint8(1) + } + } + libc.SetBitFieldPtr8Uint32(pCx1+8, libc.BoolUint32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) != libc.Int32FromInt32(BTREE_UNORDERED)), 2, 0x4) + if rc != 0 { + _sqlite3BtreeClose(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16))) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) = uintptr(0) /* Not required; helps with static analysis */ + } else { + } + } + } + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(pCx1)).FnullRow = uint8(1) + goto _189 + /* Opcode: SorterOpen P1 P2 P3 P4 * + ** + ** This opcode works like OP_OpenEphemeral except that it opens + ** a transient index that is specifically designed to sort large + ** tables using an external merge-sort algorithm. + ** + ** If argument P3 is non-zero, then it indicates that the sorter may + ** assume that a stable sort considering the first P3 fields of each + ** key is sufficient to produce the required results. + */ + _81: + ; + pCx2 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_SORTER)) + if pCx2 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pCx2)).FpKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) + rc = _sqlite3VdbeSorterInit(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp3, pCx2) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: SequenceTest P1 P2 * * * + ** Synopsis: if( cursor[P1].ctr++ ) pc = P2 + ** + ** P1 is a sorter cursor. If the sequence counter is currently zero, jump + ** to P2. Regardless of whether or not the jump is taken, increment the + ** the sequence value. + */ + _82: + ; + pC4 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + v191 = pC4 + 24 + v256 = *(*Ti64)(unsafe.Pointer(v191)) + *(*Ti64)(unsafe.Pointer(v191)) = *(*Ti64)(unsafe.Pointer(v191)) + 1 + if v256 == 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: OpenPseudo P1 P2 P3 * * + ** Synopsis: P3 columns in r[P2] + ** + ** Open a new cursor that points to a fake table that contains a single + ** row of data. The content of that one row is the content of memory + ** register P2. In other words, cursor P1 becomes an alias for the + ** MEM_Blob content contained in register P2. + ** + ** A pseudo-table created by this opcode is used to hold a single + ** row output from the sorter so that the row can be decomposed into + ** individual columns using the OP_Column opcode. The OP_Column opcode + ** is the only cursor opcode that works with a pseudo-table. + ** + ** P3 is the number of fields in the records that will be stored by + ** the pseudo-table. If P2 is 0 or negative then the pseudo-cursor + ** will return NULL for every column. + */ + _83: + ; + pCx3 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp3, uint8(CURTYPE_PSEUDO)) + if pCx3 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FnullRow = uint8(1) + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FseekResult = (*TOp)(unsafe.Pointer(pOp)).Fp2 + (*TVdbeCursor)(unsafe.Pointer(pCx3)).FisTable = uint8(1) + /* Give this pseudo-cursor a fake BtCursor pointer so that pCx + ** can be safely passed to sqlite3VdbeCursorMoveto(). This avoids a test + ** for pCx->eCurType==CURTYPE_BTREE inside of sqlite3VdbeCursorMoveto() + ** which is a performance optimization */ + *(*uintptr)(unsafe.Pointer(pCx3 + 48)) = _sqlite3BtreeFakeValidCursor(tls) + goto _189 + /* Opcode: Close P1 * * * * + ** + ** Close a cursor previously opened as P1. If P1 is not + ** currently open, this instruction is a no-op. + */ + _84: + ; /* ncycle */ + _sqlite3VdbeFreeCursor(tls, p, **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8))) + **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) = uintptr(0) + goto _189 + /* Opcode: SeekGE P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as the key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than or equal to the key value. If there are no records + ** greater than or equal to the key and P2 is not zero, then jump to P2. + ** + ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this + ** opcode will either land on a record that exactly matches the key, or + ** else it will cause a jump to P2. When the cursor is OPFLAG_SEEKEQ, + ** this opcode must be followed by an IdxLE opcode with the same arguments. + ** The IdxGT opcode will be skipped if this opcode succeeds, but the + ** IdxGT opcode will be used on subsequent loop iterations. The + ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this + ** is an equality search. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + ** + ** See also: Found, NotFound, SeekLt, SeekGt, SeekLe + */ + /* Opcode: SeekGT P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the smallest entry that + ** is greater than the key value. If there are no records greater than + ** the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + ** + ** See also: Found, NotFound, SeekLt, SeekGe, SeekLe + */ + /* Opcode: SeekLT P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than the key value. If there are no records less than + ** the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + ** + ** See also: Found, NotFound, SeekGt, SeekGe, SeekLe + */ + /* Opcode: SeekLE P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), + ** use the value in register P3 as a key. If cursor P1 refers + ** to an SQL index, then P3 is the first in an array of P4 registers + ** that are used as an unpacked index key. + ** + ** Reposition cursor P1 so that it points to the largest entry that + ** is less than or equal to the key value. If there are no records + ** less than or equal to the key and P2 is not zero, then jump to P2. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + ** + ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this + ** opcode will either land on a record that exactly matches the key, or + ** else it will cause a jump to P2. When the cursor is OPFLAG_SEEKEQ, + ** this opcode must be followed by an IdxLE opcode with the same arguments. + ** The IdxGE opcode will be skipped if this opcode succeeds, but the + ** IdxGE opcode will be used on subsequent loop iterations. The + ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this + ** is an equality search. + ** + ** See also: Found, NotFound, SeekGt, SeekGe, SeekLt + */ + _88: + ; /* jump0, in3, group, ncycle */ + _87: + ; /* jump0, in3, group, ncycle */ + _86: + ; /* jump0, in3, group, ncycle */ + _85: + ; /* Only interested in == results */ + pC5 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + oc = libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) + eqOnly = 0 + (*TVdbeCursor)(unsafe.Pointer(pC5)).FnullRow = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FcacheStatus = uint32(CACHE_STALE) + if (*TVdbeCursor)(unsafe.Pointer(pC5)).FisTable != 0 { + /* The OPFLAG_SEEKEQ/BTREE_SEEK_EQ flag is only set on index cursors */ + /* The input value in P3 might be of any type: integer, real, string, + ** blob, or NULL. But it needs to be an integer before we can do + ** the seek, so convert it. */ + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + flags31 = (*TMem)(unsafe.Pointer(pIn3)).Fflags + if libc.Int32FromUint16(flags31)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { + _applyNumericAffinity(tls, pIn3, 0) + } + iKey = _sqlite3VdbeIntValue(tls, pIn3) /* Get the integer key value */ + newType = (*TMem)(unsafe.Pointer(pIn3)).Fflags /* Record the type after applying numeric affinity */ + (*TMem)(unsafe.Pointer(pIn3)).Fflags = flags31 /* But convert the type back to its original */ + /* If the P3 value could not be converted into an integer without + ** loss of information, then special processing is required... */ + if libc.Int32FromUint16(newType)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + if libc.Int32FromUint16(newType)&int32(MEM_Real) == 0 { + if libc.Int32FromUint16(newType)&int32(MEM_Null) != 0 || oc >= int32(OP_SeekGE) { + goto jump_to_p2 + } else { + rc = _sqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), bp+112) + if rc != SQLITE_OK { + goto abort_due_to_error + } + goto seek_not_found + } + } + c2 = _sqlite3IntFloatCompare(tls, iKey, *(*float64)(unsafe.Pointer(pIn3))) + /* If the approximation iKey is larger than the actual real search + ** term, substitute >= for > and < for <=. e.g. if the search term + ** is 4.9 and the integer approximation 5: + ** + ** (x > 4.9) -> (x >= 5) + ** (x <= 4.9) -> (x < 5) + */ + if c2 > 0 { + if oc&int32(0x0001) == libc.Int32FromInt32(OP_SeekGT)&libc.Int32FromInt32(0x0001) { + oc = oc - 1 + } + } else { + if c2 < 0 { + if oc&int32(0x0001) == libc.Int32FromInt32(OP_SeekLT)&libc.Int32FromInt32(0x0001) { + oc = oc + 1 + } + } + } + } + rc = _sqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), libc.Int64FromUint64(libc.Uint64FromInt64(iKey)), 0, bp+112) + (*TVdbeCursor)(unsafe.Pointer(pC5)).FmovetoTarget = iKey /* Used by OP_Delete */ + if rc != SQLITE_OK { + goto abort_due_to_error + } + } else { + /* For a cursor with the OPFLAG_SEEKEQ/BTREE_SEEK_EQ hint, only the + ** OP_SeekGE and OP_SeekLE opcodes are allowed, and these must be + ** immediately followed by an OP_IdxGT or OP_IdxLT opcode, respectively, + ** with the same key. + */ + if _sqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), uint32(BTREE_SEEK_EQ)) != 0 { + eqOnly = int32(1) + } + nField2 = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC5)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FnField = libc.Uint16FromInt32(nField2) + /* The next line of code computes as follows, only faster: + ** if( oc==OP_SeekGT || oc==OP_SeekLE ){ + ** r.default_rc = -1; + ** }else{ + ** r.default_rc = +1; + ** } + */ + if int32(1)&(oc-int32(OP_SeekLT)) != 0 { + v190 = -int32(1) + } else { + v190 = +libc.Int32FromInt32(1) + } + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).Fdefault_rc = int8(v190) + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FeqSeen = uint8(0) + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), bp+120, bp+112) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if eqOnly != 0 && libc.Int32FromUint8((**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FeqSeen) == 0 { + goto seek_not_found + } + } + if oc >= int32(OP_SeekGE) { + if **(**int32)(__ccgo_up(bp + 112)) < 0 || **(**int32)(__ccgo_up(bp + 112)) == 0 && oc == int32(OP_SeekGT) { + **(**int32)(__ccgo_up(bp + 112)) = 0 + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), 0) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 112)) = int32(1) + } else { + goto abort_due_to_error + } + } + } else { + **(**int32)(__ccgo_up(bp + 112)) = 0 + } + } else { + if **(**int32)(__ccgo_up(bp + 112)) > 0 || **(**int32)(__ccgo_up(bp + 112)) == 0 && oc == int32(OP_SeekLT) { + **(**int32)(__ccgo_up(bp + 112)) = 0 + rc = _sqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), 0) + if rc != SQLITE_OK { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + **(**int32)(__ccgo_up(bp + 112)) = int32(1) + } else { + goto abort_due_to_error + } + } + } else { + /* res might be negative because the table is empty. Check to + ** see if this is the case. + */ + **(**int32)(__ccgo_up(bp + 112)) = _sqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48))) + } + } + goto seek_not_found + seek_not_found: + ; + if **(**int32)(__ccgo_up(bp + 112)) != 0 { + goto jump_to_p2 + } else { + if eqOnly != 0 { + pOp += 24 /* Skip the OP_IdxLt or OP_IdxGT that follows */ + } + } + goto _189 + /* Opcode: SeekScan P1 P2 * * P5 + ** Synopsis: Scan-ahead up to P1 rows + ** + ** This opcode is a prefix opcode to OP_SeekGE. In other words, this + ** opcode must be immediately followed by OP_SeekGE. This constraint is + ** checked by assert() statements. + ** + ** This opcode uses the P1 through P4 operands of the subsequent + ** OP_SeekGE. In the text that follows, the operands of the subsequent + ** OP_SeekGE opcode are denoted as SeekOP.P1 through SeekOP.P4. Only + ** the P1, P2 and P5 operands of this opcode are also used, and are called + ** This.P1, This.P2 and This.P5. + ** + ** This opcode helps to optimize IN operators on a multi-column index + ** where the IN operator is on the later terms of the index by avoiding + ** unnecessary seeks on the btree, substituting steps to the next row + ** of the b-tree instead. A correct answer is obtained if this opcode + ** is omitted or is a no-op. + ** + ** The SeekGE.P3 and SeekGE.P4 operands identify an unpacked key which + ** is the desired entry that we want the cursor SeekGE.P1 to be pointing + ** to. Call this SeekGE.P3/P4 row the "target". + ** + ** If the SeekGE.P1 cursor is not currently pointing to a valid row, + ** then this opcode is a no-op and control passes through into the OP_SeekGE. + ** + ** If the SeekGE.P1 cursor is pointing to a valid row, then that row + ** might be the target row, or it might be near and slightly before the + ** target row, or it might be after the target row. If the cursor is + ** currently before the target row, then this opcode attempts to position + ** the cursor on or after the target row by invoking sqlite3BtreeStep() + ** on the cursor between 1 and This.P1 times. + ** + ** The This.P5 parameter is a flag that indicates what to do if the + ** cursor ends up pointing at a valid row that is past the target + ** row. If This.P5 is false (0) then a jump is made to SeekGE.P2. If + ** This.P5 is true (non-zero) then a jump is made to This.P2. The P5==0 + ** case occurs when there are no inequality constraints to the right of + ** the IN constraint. The jump to SeekGE.P2 ends the loop. The P5!=0 case + ** occurs when there are inequality constraints to the right of the IN + ** operator. In that case, the This.P2 will point either directly to or + ** to setup code prior to the OP_IdxGT or OP_IdxGE opcode that checks for + ** loop terminate. + ** + ** Possible outcomes from this opcode:
      + ** + **
    1. If the cursor is initially not pointed to any valid row, then + ** fall through into the subsequent OP_SeekGE opcode. + ** + **
    2. If the cursor is left pointing to a row that is before the target + ** row, even after making as many as This.P1 calls to + ** sqlite3BtreeNext(), then also fall through into OP_SeekGE. + ** + **
    3. If the cursor is left pointing at the target row, either because it + ** was at the target row to begin with or because one or more + ** sqlite3BtreeNext() calls moved the cursor to the target row, + ** then jump to This.P2.., + ** + **
    4. If the cursor started out before the target row and a call to + ** to sqlite3BtreeNext() moved the cursor off the end of the index + ** (indicating that the target row definitely does not exist in the + ** btree) then jump to SeekGE.P2, ending the loop. + ** + **
    5. If the cursor ends up on a valid row that is past the target row + ** (indicating that the target row does not exist in the btree) then + ** jump to SeekOP.P2 if This.P5==0 or to This.P2 if This.P5>0. + **
    + */ + _89: + ; + /* If pOp->p5 is clear, then pOp->p2 points to the first instruction past the + ** OP_IdxGT that follows the OP_SeekGE. Otherwise, it points to the first + ** opcode past the OP_SeekGE itself. */ + pC6 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((**(**TOp)(__ccgo_up(pOp + 1*24))).Fp1)*8)) + if !(_sqlite3BtreeCursorIsValidNN(tls, *(*uintptr)(unsafe.Pointer(pC6 + 48))) != 0) { + goto _189 + } + nStep = (*TOp)(unsafe.Pointer(pOp)).Fp1 + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC6)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FnField = libc.Uint16FromInt32(*(*int32)(unsafe.Pointer(pOp + 1*24 + 16))) + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).Fdefault_rc = 0 + (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FaMem = aMem + uintptr((**(**TOp)(__ccgo_up(pOp + 1*24))).Fp3)*56 + **(**int32)(__ccgo_up(bp + 160)) = 0 /* Not needed. Only used to silence a warning. */ + _260: + ; + if !(int32(1) != 0) { + goto _259 + } + rc = _sqlite3VdbeIdxKeyCompare(tls, db, pC6, bp+168, bp+160) + if rc != 0 { + goto abort_due_to_error + } + if !(**(**int32)(__ccgo_up(bp + 160)) > 0 && libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == 0) { + goto _261 + } + goto seekscan_search_fail + seekscan_search_fail: + ; + /* Jump to SeekGE.P2, ending the loop */ + pOp += 24 + goto jump_to_p2 + _261: + ; + if **(**int32)(__ccgo_up(bp + 160)) >= 0 { + /* Jump to This.P2, bypassing the OP_SeekGE opcode */ + goto jump_to_p2 + goto _259 + } + if nStep <= 0 { + goto _259 + } + nStep = nStep - 1 + (*TVdbeCursor)(unsafe.Pointer(pC6)).FcacheStatus = uint32(CACHE_STALE) + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC6 + 48)), 0) + if rc != 0 { + if rc == int32(SQLITE_DONE) { + rc = SQLITE_OK + goto seekscan_search_fail + } else { + goto abort_due_to_error + } + } + goto _260 + _259: + ; + goto _189 + /* Opcode: SeekHit P1 P2 P3 * * + ** Synopsis: set P2<=seekHit<=P3 + ** + ** Increase or decrease the seekHit value for cursor P1, if necessary, + ** so that it is no less than P2 and no greater than P3. + ** + ** The seekHit integer represents the maximum of terms in an index for which + ** there is known to be at least one match. If the seekHit value is smaller + ** than the total number of equality terms in an index lookup, then the + ** OP_IfNoHope opcode might run to see if the IN loop can be abandoned + ** early, thus saving work. This is part of the IN-early-out optimization. + ** + ** P1 must be a valid b-tree cursor. + */ + _90: + ; + pC7 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit) < (*TOp)(unsafe.Pointer(pOp)).Fp2 { + (*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit) > (*TOp)(unsafe.Pointer(pOp)).Fp3 { + (*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + goto _189 + /* Opcode: IfNotOpen P1 P2 * * * + ** Synopsis: if( !csr[P1] ) goto P2 + ** + ** If cursor P1 is not open or if P1 is set to a NULL row using the + ** OP_NullRow opcode, then jump to instruction P2. Otherwise, fall through. + */ + _91: + ; + pCur1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pCur1 == uintptr(0) || (*TVdbeCursor)(unsafe.Pointer(pCur1)).FnullRow != 0 { + goto jump_to_p2_and_check_for_interrupt + } + goto _189 + /* Opcode: Found P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is a prefix of any entry in P1 then a jump is made to P2 and + ** P1 is left pointing at the matching entry. + ** + ** This operation leaves the cursor in a state where it can be + ** advanced in the forward direction. The Next instruction will work, + ** but not the Prev instruction. + ** + ** See also: NotFound, NoConflict, NotExists. SeekGe + */ + /* Opcode: NotFound P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 + ** does contain an entry whose prefix matches the P3/P4 record then control + ** falls through to the next instruction and P1 is left pointing at the + ** matching entry. + ** + ** This operation leaves the cursor in a state where it cannot be + ** advanced in either direction. In other words, the Next and Prev + ** opcodes do not work after this operation. + ** + ** See also: Found, NotExists, NoConflict, IfNoHope + */ + /* Opcode: IfNoHope P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** Register P3 is the first of P4 registers that form an unpacked + ** record. Cursor P1 is an index btree. P2 is a jump destination. + ** In other words, the operands to this opcode are the same as the + ** operands to OP_NotFound and OP_IdxGT. + ** + ** This opcode is an optimization attempt only. If this opcode always + ** falls through, the correct answer is still obtained, but extra work + ** is performed. + ** + ** A value of N in the seekHit flag of cursor P1 means that there exists + ** a key P3:N that will match some record in the index. We want to know + ** if it is possible for a record P3:P4 to match some record in the + ** index. If it is not possible, we can skip some work. So if seekHit + ** is less than P4, attempt to find out if a match is possible by running + ** OP_NotFound. + ** + ** This opcode is used in IN clause processing for a multi-column key. + ** If an IN clause is attached to an element of the key other than the + ** left-most element, and if there are no matches on the most recent + ** seek over the whole key, then it might be that one of the key element + ** to the left is prohibiting a match, and hence there is "no hope" of + ** any match regardless of how many IN clause elements are checked. + ** In such a case, we abandon the IN clause search early, using this + ** opcode. The opcode name comes from the fact that the + ** jump is taken if there is "no hope" of achieving a match. + ** + ** See also: NotFound, SeekHit + */ + /* Opcode: NoConflict P1 P2 P3 P4 * + ** Synopsis: key=r[P3@P4] + ** + ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If + ** P4>0 then register P3 is the first of P4 registers that form an unpacked + ** record. + ** + ** Cursor P1 is on an index btree. If the record identified by P3 and P4 + ** contains any NULL value, jump immediately to P2. If all terms of the + ** record are not-NULL then a check is done to determine if any row in the + ** P1 index btree has a matching key prefix. If there are no matches, jump + ** immediately to P2. If there is a match, fall through and leave the P1 + ** cursor pointing to the matching row. + ** + ** This opcode is similar to OP_NotFound with the exceptions that the + ** branch is always taken if any part of the search key input is NULL. + ** + ** This operation leaves the cursor in a state where it cannot be + ** advanced in either direction. In other words, the Next and Prev + ** opcodes do not work after this operation. + ** + ** See also: NotFound, Found, NotExists + */ + _92: + ; + pC8 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC8)).FseekHit) >= (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi { + goto _189 + } + /* Fall through into OP_NotFound */ + _95: + ; /* jump, in3, ncycle */ + _94: + ; /* jump, in3, ncycle */ + _93: + ; + pC9 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + if libc.Int32FromUint16((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField) > 0 { + /* Key values in an array of registers */ + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).Fdefault_rc = 0 + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 48)), bp+208, pC9+36) + } else { + /* Composite key generated by OP_MakeRecord */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto no_mem + } + pIdxKey = _sqlite3VdbeAllocUnpackedRecord(tls, (*TVdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo) + if pIdxKey == uintptr(0) { + goto no_mem + } + _sqlite3VdbeRecordUnpack(tls, (*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fn, (*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fz, pIdxKey) + (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).Fdefault_rc = 0 + rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 48)), pIdxKey, pC9+36) + _sqlite3DbFreeNN(tls, db, pIdxKey) + } + if rc != SQLITE_OK { + goto abort_due_to_error + } + alreadyExists = libc.BoolInt32((*TVdbeCursor)(unsafe.Pointer(pC9)).FseekResult == 0) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FnullRow = libc.Uint8FromInt32(int32(1) - alreadyExists) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = uint32(CACHE_STALE) + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Found) { + if alreadyExists != 0 { + goto jump_to_p2 + } + } else { + if !(alreadyExists != 0) { + goto jump_to_p2 + } + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_NoConflict) { + /* For the OP_NoConflict opcode, take the jump if any of the + ** input fields are NULL, since any key with a NULL will not + ** conflict */ + ii1 = 0 + for { + if !(ii1 < libc.Int32FromUint16((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField)) { + break + } + if libc.Int32FromUint16((**(**TMem)(__ccgo_up((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem + uintptr(ii1)*56))).Fflags)&int32(MEM_Null) != 0 { + goto jump_to_p2 + } + goto _263 + _263: + ; + ii1 = ii1 + 1 + } + } + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_IfNoHope) { + (*TVdbeCursor)(unsafe.Pointer(pC9)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + } + } + goto _189 + /* Opcode: SeekRowid P1 P2 P3 * * + ** Synopsis: intkey=r[P3] + ** + ** P1 is the index of a cursor open on an SQL table btree (with integer + ** keys). If register P3 does not contain an integer or if P1 does not + ** contain a record with rowid P3 then jump immediately to P2. + ** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain + ** a record with rowid P3 then + ** leave the cursor pointing at that record and fall through to the next + ** instruction. + ** + ** The OP_NotExists opcode performs the same operation, but with OP_NotExists + ** the P3 register must be guaranteed to contain an integer value. With this + ** opcode, register P3 might not contain an integer. + ** + ** The OP_NotFound opcode performs the same operation on index btrees + ** (with arbitrary multi-value keys). + ** + ** This opcode leaves the cursor in a state where it cannot be advanced + ** in either direction. In other words, the Next and Prev opcodes will + ** not work following this opcode. + ** + ** See also: Found, NotFound, NoConflict, SeekRowid + */ + /* Opcode: NotExists P1 P2 P3 * * + ** Synopsis: intkey=r[P3] + ** + ** P1 is the index of a cursor open on an SQL table btree (with integer + ** keys). P3 is an integer rowid. If P1 does not contain a record with + ** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an + ** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then + ** leave the cursor pointing at that record and fall through to the next + ** instruction. + ** + ** The OP_SeekRowid opcode performs the same operation but also allows the + ** P3 register to contain a non-integer value, in which case the jump is + ** always taken. This opcode requires that P3 always contain an integer. + ** + ** The OP_NotFound opcode performs the same operation on index btrees + ** (with arbitrary multi-value keys). + ** + ** This opcode leaves the cursor in a state where it cannot be advanced + ** in either direction. In other words, the Next and Prev opcodes will + ** not work following this opcode. + ** + ** See also: Found, NotFound, NoConflict, SeekRowid + */ + _97: + ; + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn3)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) == 0 { + /* If pIn3->u.i does not contain an integer, compute iKey as the + ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted + ** into an integer without loss of information. Take care to avoid + ** changing the datatype of pIn3, however, as it is used by other + ** parts of the prepared statement. */ + *(*TMem)(unsafe.Pointer(bp + 256)) = TMem{} + /* If pIn3->u.i does not contain an integer, compute iKey as the + ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted + ** into an integer without loss of information. Take care to avoid + ** changing the datatype of pIn3, however, as it is used by other + ** parts of the prepared statement. */ + *(*Tsqlite3_value)(unsafe.Pointer(bp + 256)) = **(**TMem)(__ccgo_up(pIn3)) + _applyAffinity(tls, bp+256, int8(SQLITE_AFF_NUMERIC), encoding) + if libc.Int32FromUint16((**(**TMem)(__ccgo_up(bp + 256))).Fflags)&int32(MEM_Int) == 0 { + goto jump_to_p2 + } + iKey1 = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(bp + 256))) + goto notExistsWithKey + } + /* Fall through into OP_NotExists */ + _96: + ; /* jump, in3, ncycle */ + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + iKey1 = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(pIn3))) + goto notExistsWithKey + notExistsWithKey: + ; + pC10 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr2 = *(*uintptr)(unsafe.Pointer(pC10 + 48)) + **(**int32)(__ccgo_up(bp + 248)) = 0 + rc = _sqlite3BtreeTableMoveto(tls, pCrsr2, libc.Int64FromUint64(iKey1), 0, bp+248) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget = libc.Int64FromUint64(iKey1) /* Used by OP_Delete */ + (*TVdbeCursor)(unsafe.Pointer(pC10)).FnullRow = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = uint32(CACHE_STALE) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC10)).FseekResult = **(**int32)(__ccgo_up(bp + 248)) + if **(**int32)(__ccgo_up(bp + 248)) != 0 { + if (*TOp)(unsafe.Pointer(pOp)).Fp2 == 0 { + rc = _sqlite3CorruptError(tls, int32(102023)) + } else { + goto jump_to_p2 + } + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Sequence P1 P2 * * * + ** Synopsis: r[P2]=cursor[P1].ctr++ + ** + ** Find the next available sequence number for cursor P1. + ** Write the sequence number into register P2. + ** The sequence number on the cursor is incremented after this + ** instruction. + */ + _98: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + v191 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + 24 + v256 = *(*Ti64)(unsafe.Pointer(v191)) + *(*Ti64)(unsafe.Pointer(v191)) = *(*Ti64)(unsafe.Pointer(v191)) + 1 + *(*Ti64)(unsafe.Pointer(pOut)) = v256 + goto _189 + /* Opcode: NewRowid P1 P2 P3 * * + ** Synopsis: r[P2]=rowid + ** + ** Get a new integer record number (a.k.a "rowid") used as the key to a table. + ** The record number is not previously used as a key in the database + ** table that cursor P1 points to. The new record number is written + ** written to register P2. + ** + ** If P3>0 then P3 is a register in the root frame of this VDBE that holds + ** the largest previously generated record number. No new record numbers are + ** allowed to be less than this value. When this value reaches its maximum, + ** an SQLITE_FULL error is generated. The P3 register is updated with the ' + ** generated record number. This P3 mechanism is used to help implement the + ** AUTOINCREMENT feature. + */ + _99: + ; /* Root frame of VDBE */ + **(**Ti64)(__ccgo_up(bp + 312)) = 0 + **(**int32)(__ccgo_up(bp + 320)) = 0 + pOut = _out2Prerelease(tls, p, pOp) + pC11 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + /* The next rowid or record number (different terms for the same + ** thing) is obtained in a two-step algorithm. + ** + ** First we attempt to find the largest existing rowid and add one + ** to that. But if the largest existing rowid is already the maximum + ** positive integer, we have to fall through to the second + ** probabilistic algorithm + ** + ** The second algorithm is to select a rowid at random and see if + ** it already exists in the table. If it does not exist, we have + ** succeeded. If the random rowid does exist, we select a new one + ** and try again, up to 100 times. + */ + /* Some compilers complain about constants of the form 0x7fffffffffffffff. + ** Others complain about 0x7ffffffffffffffffLL. The following macro seems + ** to provide the constant while making all compilers happy. + */ + if !(int32(TBool(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0) { + rc = _sqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48)), bp+320) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 320)) != 0 { + **(**Ti64)(__ccgo_up(bp + 312)) = int64(1) /* IMP: R-61914-48074 */ + } else { + **(**Ti64)(__ccgo_up(bp + 312)) = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48))) + if **(**Ti64)(__ccgo_up(bp + 312)) >= libc.Int64FromUint64(libc.Uint64FromInt32(0x7fffffff)<>1)) != 0 { + rc = int32(SQLITE_FULL) /* IMP: R-17817-00630 */ + goto abort_due_to_error + } + if **(**Ti64)(__ccgo_up(bp + 312)) < *(*Ti64)(unsafe.Pointer(pMem))+int64(1) { + **(**Ti64)(__ccgo_up(bp + 312)) = *(*Ti64)(unsafe.Pointer(pMem)) + int64(1) + } + *(*Ti64)(unsafe.Pointer(pMem)) = **(**Ti64)(__ccgo_up(bp + 312)) + } + if int32(TBool(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0 { + /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the + ** largest possible integer (9223372036854775807) then the database + ** engine starts picking positive candidate ROWIDs at random until + ** it finds one that is not previously used. */ + /* We cannot be in random rowid mode if this is + ** an AUTOINCREMENT table. */ + cnt1 = 0 + for { + Xsqlite3_randomness(tls, int32(8), bp+312) + **(**Ti64)(__ccgo_up(bp + 312)) = **(**Ti64)(__ccgo_up(bp + 312)) & (libc.Int64FromUint64(libc.Uint64FromInt32(0x7fffffff)<> libc.Int32FromInt32(1)) + **(**Ti64)(__ccgo_up(bp + 312)) = **(**Ti64)(__ccgo_up(bp + 312)) + 1 /* Ensure that v is greater than zero */ + goto _270 + _270: + ; + v190 = _sqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48)), libc.Int64FromUint64(libc.Uint64FromInt64(**(**Ti64)(__ccgo_up(bp + 312)))), 0, bp+320) + rc = v190 + if v217 = v190 == SQLITE_OK && **(**int32)(__ccgo_up(bp + 320)) == 0; v217 { + cnt1 = cnt1 + 1 + v193 = cnt1 + } + if !(v217 && v193 < int32(100)) { + break + } + } + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 320)) == 0 { + rc = int32(SQLITE_FULL) /* IMP: R-38219-53002 */ + goto abort_due_to_error + } + /* EV: R-40812-03570 */ + } + (*TVdbeCursor)(unsafe.Pointer(pC11)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC11)).FcacheStatus = uint32(CACHE_STALE) + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 312)) + goto _189 + /* Opcode: Insert P1 P2 P3 P4 P5 + ** Synopsis: intkey=r[P3] data=r[P2] + ** + ** Write an entry into the table of cursor P1. A new entry is + ** created if it doesn't already exist or the data for an existing + ** entry is overwritten. The data is the value MEM_Blob stored in register + ** number P2. The key is stored in register P3. The key must + ** be a MEM_Int. + ** + ** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is + ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, + ** then rowid is stored for subsequent return by the + ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). + ** + ** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might + ** run faster by avoiding an unnecessary seek on cursor P1. However, + ** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior + ** seeks on the cursor or if the most recent seek used a key equal to P3. + ** + ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an + ** UPDATE operation. Otherwise (if the flag is clear) then this opcode + ** is part of an INSERT operation. The difference is only important to + ** the update hook. + ** + ** Parameter P4 may point to a Table structure, or may be NULL. If it is + ** not NULL, then the update-hook (sqlite3.xUpdateCallback) is invoked + ** following a successful insert. + ** + ** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically + ** allocated, then ownership of P2 is transferred to the pseudo-cursor + ** and register P2 becomes ephemeral. If the cursor is changed, the + ** value of register P2 will then change. Make sure this does not + ** cause any problems.) + ** + ** This instruction only works on tables. The equivalent instruction + ** for indices is OP_IdxInsert. + */ + _100: + ; /* Payload to be inserted */ + pData = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pC12 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pKey = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey = *(*Ti64)(unsafe.Pointer(pKey)) + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(5) && ((*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) { + zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TVdbeCursor)(unsafe.Pointer(pC12)).FiDb)*32))).FzDbSName + pTab1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + } else { + pTab1 = uintptr(0) + zDb = uintptr(0) + } + /* Invoke the pre-update hook, if any */ + if pTab1 != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && !(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&libc.Int32FromInt32(OPFLAG_ISUPDATE) != 0) { + _sqlite3VdbePreUpdateHook(tls, p, pC12, int32(SQLITE_INSERT), zDb, pTab1, (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey, (*TOp)(unsafe.Pointer(pOp)).Fp2, -int32(1)) + } + if (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback == uintptr(0) || (*TTable)(unsafe.Pointer(pTab1)).FaCol == uintptr(0) { + /* Prevent post-update hook from running in cases when it should not */ + pTab1 = uintptr(0) + } + } + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_ISNOOP) != 0 { + goto _189 + } + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_LASTROWID) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey + } + } + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FpData = (*TMem)(unsafe.Pointer(pData)).Fz + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnData = (*TMem)(unsafe.Pointer(pData)).Fn + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_USESEEKRESULT) != 0 { + v190 = (*TVdbeCursor)(unsafe.Pointer(pC12)).FseekResult + } else { + v190 = 0 + } + seekResult = v190 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pData)).Fflags)&int32(MEM_Zero) != 0 { + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnZero = *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pData)).Fu)) + } else { + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnZero = 0 + } + (**(**TBtreePayload)(__ccgo_up(bp + 328))).FpKey = uintptr(0) + rc = _sqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC12 + 48)), bp+328, libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&(libc.Int32FromInt32(OPFLAG_APPEND)|libc.Int32FromInt32(OPFLAG_SAVEPOSITION)|libc.Int32FromInt32(OPFLAG_PREFORMAT)), seekResult) + (*TVdbeCursor)(unsafe.Pointer(pC12)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC12)).FcacheStatus = uint32(CACHE_STALE) + colCacheCtr = colCacheCtr + 1 + /* Invoke the update-hook if required. */ + if rc != 0 { + goto abort_due_to_error + } + if pTab1 != 0 { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_ISUPDATE) != 0 { + v190 = int32(SQLITE_UPDATE) + } else { + v190 = int32(SQLITE_INSERT) + } + (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Tsqlite_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg, v190, zDb, (*TTable)(unsafe.Pointer(pTab1)).FzName, (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey) + } + goto _189 + /* Opcode: RowCell P1 P2 P3 * * + ** + ** P1 and P2 are both open cursors. Both must be opened on the same type + ** of table - intkey or index. This opcode is used as part of copying + ** the current row from P2 into P1. If the cursors are opened on intkey + ** tables, register P3 contains the rowid to use with the new record in + ** P1. If they are opened on index tables, P3 is not used. + ** + ** This opcode must be followed by either an Insert or InsertIdx opcode + ** with the OPFLAG_PREFORMAT flag set to complete the insert operation. + */ + _101: + ; /* Rowid value to insert with */ + pDest1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pSrc = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*8)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + v206 = *(*Ti64)(unsafe.Pointer(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56)) + } else { + v206 = 0 + } + iKey2 = v206 + rc = _sqlite3BtreeTransferRow(tls, *(*uintptr)(unsafe.Pointer(pDest1 + 48)), *(*uintptr)(unsafe.Pointer(pSrc + 48)), iKey2) + if rc != SQLITE_OK { + goto abort_due_to_error + } + goto _189 + /* Opcode: Delete P1 P2 P3 P4 P5 + ** + ** Delete the record at which the P1 cursor is currently pointing. + ** + ** If the OPFLAG_SAVEPOSITION bit of the P5 parameter is set, then + ** the cursor will be left pointing at either the next or the previous + ** record in the table. If it is left pointing at the next record, then + ** the next Next instruction will be a no-op. As a result, in this case + ** it is ok to delete a record from within a Next loop. If + ** OPFLAG_SAVEPOSITION bit of P5 is clear, then the cursor will be + ** left in an undefined state. + ** + ** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this + ** delete is one of several associated with deleting a table row and + ** all its associated index entries. Exactly one of those deletes is + ** the "primary" delete. The others are all on OPFLAG_FORDELETE + ** cursors or else are marked with the AUXDELETE flag. + ** + ** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then + ** the row change count is incremented (otherwise not). + ** + ** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the + ** pre-update-hook for deletes is run, but the btree is otherwise unchanged. + ** This happens when the OP_Delete is to be shortly followed by an OP_Insert + ** with the same key, causing the btree entry to be overwritten. + ** + ** P1 must not be pseudo-table. It has to be a real table with + ** multiple rows. + ** + ** If P4 is not NULL then it points to a Table object. In this case either + ** the update or pre-update hook, or both, may be invoked. The P1 cursor must + ** have been positioned using OP_NotFound prior to invoking this opcode in + ** this case. Specifically, if one is configured, the pre-update hook is + ** invoked if P4 is not NULL. The update-hook is invoked if one is configured, + ** P4 is not NULL, and the OPFLAG_NCHANGE flag is set in P2. + ** + ** If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address + ** of the memory cell that contains the value that the rowid of the row will + ** be set to by the update. + */ + _102: + ; + opflags = (*TOp)(unsafe.Pointer(pOp)).Fp2 + pC13 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + /* If the update-hook or pre-update-hook will be invoked, set zDb to + ** the name of the db to pass as to it. Also set local pTab to a copy + ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was + ** last moved with OP_Next or OP_Prev, not Seek or NotFound, set + ** VdbeCursor.movetoTarget to the current rowid. */ + if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(5) && ((*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) { + zDb1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TVdbeCursor)(unsafe.Pointer(pC13)).FiDb)*32))).FzDbSName + pTab2 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_SAVEPOSITION) != 0 && (*TVdbeCursor)(unsafe.Pointer(pC13)).FisTable != 0 { + (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC13 + 48))) + } + } else { + zDb1 = uintptr(0) + pTab2 = uintptr(0) + } + /* Invoke the pre-update-hook if required. */ + if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && pTab2 != 0 { + if opflags&int32(OPFLAG_ISUPDATE) != 0 { + v190 = int32(SQLITE_UPDATE) + } else { + v190 = int32(SQLITE_DELETE) + } + _sqlite3VdbePreUpdateHook(tls, p, pC13, v190, zDb1, pTab2, (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget, (*TOp)(unsafe.Pointer(pOp)).Fp3, -int32(1)) + } + if opflags&int32(OPFLAG_ISNOOP) != 0 { + goto _189 + } + /* Only flags that can be set are SAVEPOISTION and AUXDELETE */ + rc = _sqlite3BtreeDelete(tls, *(*uintptr)(unsafe.Pointer(pC13 + 48)), uint8((*TOp)(unsafe.Pointer(pOp)).Fp5)) + (*TVdbeCursor)(unsafe.Pointer(pC13)).FcacheStatus = uint32(CACHE_STALE) + colCacheCtr = colCacheCtr + 1 + (*TVdbeCursor)(unsafe.Pointer(pC13)).FseekResult = 0 + if rc != 0 { + goto abort_due_to_error + } + /* Invoke the update-hook if required. */ + if opflags&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + if (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0 && pTab2 != uintptr(0) && (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { + (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Tsqlite_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg, int32(SQLITE_DELETE), zDb1, (*TTable)(unsafe.Pointer(pTab2)).FzName, (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget) + } + } + goto _189 + /* Opcode: ResetCount * * * * * + ** + ** The value of the change counter is copied to the database handle + ** change counter (returned by subsequent calls to sqlite3_changes()). + ** Then the VMs internal change counter resets to 0. + ** This is used by trigger programs. + */ + _103: + ; + _sqlite3VdbeSetChanges(tls, db, (*TVdbe)(unsafe.Pointer(p)).FnChange) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + goto _189 + /* Opcode: SorterCompare P1 P2 P3 P4 + ** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2 + ** + ** P1 is a sorter cursor. This instruction compares a prefix of the + ** record blob in register P3 against a prefix of the entry that + ** the sorter cursor currently points to. Only the first P4 fields + ** of r[P3] and the sorter record are compared. + ** + ** If either P3 or the sorter contains a NULL in one of their significant + ** fields (not counting the P4 fields at the end which are ignored) then + ** the comparison is assumed to be equal. + ** + ** Fall through to next instruction if the two records compare equal to + ** each other. Jump to P2 if they are different. + */ + _104: + ; + pC14 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + nKeyCol = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + **(**int32)(__ccgo_up(bp + 376)) = 0 + rc = _sqlite3VdbeSorterCompare(tls, pC14, pIn3, nKeyCol, bp+376) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 376)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: SorterData P1 P2 P3 * * + ** Synopsis: r[P2]=data + ** + ** Write into register P2 the current sorter data for sorter cursor P1. + ** Then clear the column header cache on cursor P3. + ** + ** This opcode is normally used to move a record out of the sorter and into + ** a register that is the source for a pseudo-table cursor created using + ** OpenPseudo. That pseudo-table cursor is the one that is identified by + ** parameter P3. Clearing the P3 column cache as part of this opcode saves + ** us from having to issue a separate NullRow instruction to clear that cache. + */ + _105: + ; + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + pC15 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3VdbeSorterRowkey(tls, pC15, pOut) + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*8)))).FcacheStatus = uint32(CACHE_STALE) + goto _189 + /* Opcode: RowData P1 P2 P3 * * + ** Synopsis: r[P2]=data + ** + ** Write into register P2 the complete row content for the row at + ** which cursor P1 is currently pointing. + ** There is no interpretation of the data. + ** It is just copied onto the P2 register exactly as + ** it is found in the database file. + ** + ** If cursor P1 is an index, then the content is the key of the row. + ** If cursor P2 is a table, then the content extracted is the data. + ** + ** If the P1 cursor must be pointing to a valid row (not a NULL row) + ** of a real table, not a pseudo-table. + ** + ** If P3!=0 then this opcode is allowed to make an ephemeral pointer + ** into the database page. That means that the content of the output + ** register will be invalidated as soon as the cursor moves - including + ** moves caused by other cursors that "save" the current cursors + ** position in order that they can write to the same table. If P3==0 + ** then a copy of the data is made into memory. P3!=0 is faster, but + ** P3==0 is safer. + ** + ** If P3!=0 then the content of the P2 register is unsuitable for use + ** in OP_Result and any OP_Result will invalidate the P2 register content. + ** The P2 register content is invalidated by opcodes like OP_Function or + ** by any use of another cursor pointing to the same table. + */ + _106: + ; + pOut = _out2Prerelease(tls, p, pOp) + pC16 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr3 = *(*uintptr)(unsafe.Pointer(pC16 + 48)) + /* The OP_RowData opcodes always follow OP_NotExists or + ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions + ** that might invalidate the cursor. + ** If this were not the case, one of the following assert()s + ** would fail. Should this ever change (because of changes in the code + ** generator) then the fix would be to insert a call to + ** sqlite3VdbeCursorMoveto(). + */ + n3 = _sqlite3BtreePayloadSize(tls, pCrsr3) + if n3 > libc.Uint32FromInt32(**(**int32)(__ccgo_up(db + 136))) { + goto too_big + } + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCrsr3, n3, pOut) + if rc != 0 { + goto abort_due_to_error + } + if !((*TOp)(unsafe.Pointer(pOp)).Fp3 != 0) { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { + goto no_mem + } + } + goto _189 + /* Opcode: Rowid P1 P2 * * * + ** Synopsis: r[P2]=PX rowid of P1 + ** + ** Store in register P2 an integer which is the key of the table entry that + ** P1 is currently point to. + ** + ** P1 can be either an ordinary table or a virtual table. There used to + ** be a separate OP_VRowid opcode for use with virtual tables, but this + ** one opcode now works for both table types. + */ + _107: + ; + pOut = _out2Prerelease(tls, p, pOp) + pC17 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + goto _189 + } else { + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FdeferredMoveto != 0 { + **(**Ti64)(__ccgo_up(bp + 384)) = (*TVdbeCursor)(unsafe.Pointer(pC17)).FmovetoTarget + } else { + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC17)).FeCurType) == int32(CURTYPE_VTAB) { + pVtab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pC17 + 48)))).FpVtab + pModule = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule)).FxRowid})))(tls, *(*uintptr)(unsafe.Pointer(pC17 + 48)), bp+384) + _sqlite3VtabImportErrmsg(tls, p, pVtab) + if rc != 0 { + goto abort_due_to_error + } + } else { + rc = _sqlite3VdbeCursorRestore(tls, pC17) + if rc != 0 { + goto abort_due_to_error + } + if (*TVdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0 { + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + goto _189 + } + **(**Ti64)(__ccgo_up(bp + 384)) = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC17 + 48))) + } + } + } + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 384)) + goto _189 + /* Opcode: NullRow P1 * * * * + ** + ** Move the cursor P1 to a null row. Any OP_Column operations + ** that occur while the cursor is on the null row will always + ** write a NULL. + ** + ** If cursor P1 is not previously opened, open it now to a special + ** pseudo-cursor that always returns NULL for every column. + */ + _108: + ; + pC18 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if pC18 == uintptr(0) { + /* If the cursor is not already open, create a special kind of + ** pseudo-cursor that always gives null rows. */ + pC18 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, int32(1), uint8(CURTYPE_PSEUDO)) + if pC18 == uintptr(0) { + goto no_mem + } + (*TVdbeCursor)(unsafe.Pointer(pC18)).FseekResult = 0 + (*TVdbeCursor)(unsafe.Pointer(pC18)).FisTable = uint8(1) + libc.SetBitFieldPtr8Uint32(pC18+8, libc.Uint32FromInt32(1), 3, 0x8) + *(*uintptr)(unsafe.Pointer(pC18 + 48)) = _sqlite3BtreeFakeValidCursor(tls) + } + (*TVdbeCursor)(unsafe.Pointer(pC18)).FnullRow = uint8(1) + (*TVdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = uint32(CACHE_STALE) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC18)).FeCurType) == CURTYPE_BTREE { + _sqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pC18 + 48))) + } + goto _189 + /* Opcode: SeekEnd P1 * * * * + ** + ** Position cursor P1 at the end of the btree for the purpose of + ** appending a new entry onto the btree. + ** + ** It is assumed that the cursor is used only for appending and so + ** if the cursor is valid, then the cursor must already be pointing + ** at the end of the btree and so no changes are made to + ** the cursor. + */ + /* Opcode: Last P1 P2 * * * + ** + ** The next use of the Rowid or Column or Prev instruction for P1 + ** will refer to the last entry in the database table or index. + ** If the table or index is empty and P2>0, then jump immediately to P2. + ** If P2 is 0 or if the table or index is not empty, fall through + ** to the following instruction. + ** + ** This opcode leaves the cursor configured to move in reverse order, + ** from the end toward the beginning. In other words, the cursor is + ** configured to use Prev, not Next. + */ + _110: + ; /* ncycle */ + _109: + ; + pC19 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr4 = *(*uintptr)(unsafe.Pointer(pC19 + 48)) + **(**int32)(__ccgo_up(bp + 392)) = 0 + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_SeekEnd) { + (*TVdbeCursor)(unsafe.Pointer(pC19)).FseekResult = -int32(1) + if _sqlite3BtreeCursorIsValidNN(tls, pCrsr4) != 0 { + goto _189 + } + } + rc = _sqlite3BtreeLast(tls, pCrsr4, bp+392) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FnullRow = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 392))) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = uint32(CACHE_STALE) + if rc != 0 { + goto abort_due_to_error + } + if (*TOp)(unsafe.Pointer(pOp)).Fp2 > 0 { + if **(**int32)(__ccgo_up(bp + 392)) != 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: IfSizeBetween P1 P2 P3 P4 * + ** + ** Let N be the approximate number of rows in the table or index + ** with cursor P1 and let X be 10*log2(N) if N is positive or -1 + ** if N is zero. + ** + ** Jump to P2 if X is in between P3 and P4, inclusive. + */ + _111: + ; + pC20 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr5 = *(*uintptr)(unsafe.Pointer(pC20 + 48)) + rc = _sqlite3BtreeFirst(tls, pCrsr5, bp+396) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 396)) != 0 { + sz = int64(-int32(1)) /* -Infinity encoding */ + } else { + sz = _sqlite3BtreeRowCountEst(tls, pCrsr5) + sz = int64(_sqlite3LogEst(tls, libc.Uint64FromInt64(sz))) + } + **(**int32)(__ccgo_up(bp + 396)) = libc.BoolInt32(sz >= int64((*TOp)(unsafe.Pointer(pOp)).Fp3) && sz <= int64((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) + if **(**int32)(__ccgo_up(bp + 396)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: SorterSort P1 P2 * * * + ** + ** After all records have been inserted into the Sorter object + ** identified by P1, invoke this opcode to actually do the sorting. + ** Jump to P2 if there are no records to be sorted. + ** + ** This opcode is an alias for OP_Sort and OP_Rewind that is used + ** for Sorter objects. + */ + /* Opcode: Sort P1 P2 * * * + ** + ** This opcode does exactly the same thing as OP_Rewind except that + ** it increments an undocumented global variable used for testing. + ** + ** Sorting is accomplished by writing records into a sorting index, + ** then rewinding that index and playing it back from beginning to + ** end. We use the OP_Sort opcode instead of OP_Rewind to do the + ** rewinding so that the global variable will be incremented and + ** regression tests can determine whether or not the optimizer is + ** correctly optimizing out sorts. + */ + _113: + ; /* jump ncycle */ + _112: + ; /* jump ncycle */ + **(**Tu32)(__ccgo_up(p + 212 + 2*4)) = **(**Tu32)(__ccgo_up(p + 212 + 2*4)) + 1 + /* Fall through into OP_Rewind */ + /* Opcode: Rewind P1 P2 * * * + ** + ** The next use of the Rowid or Column or Next instruction for P1 + ** will refer to the first entry in the database table or index. + ** If the table or index is empty, jump immediately to P2. + ** If the table or index is not empty, fall through to the following + ** instruction. + ** + ** If P2 is zero, that is an assertion that the P1 table is never + ** empty and hence the jump will never be taken. + ** + ** This opcode leaves the cursor configured to move in forward order, + ** from the beginning toward the end. In other words, the cursor is + ** configured to use Next, not Prev. + */ + _114: + ; + pC21 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + **(**int32)(__ccgo_up(bp + 400)) = int32(1) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC21)).FeCurType) == int32(CURTYPE_SORTER) { + rc = _sqlite3VdbeSorterRewind(tls, pC21, bp+400) + } else { + pCrsr6 = *(*uintptr)(unsafe.Pointer(pC21 + 48)) + rc = _sqlite3BtreeFirst(tls, pCrsr6, bp+400) + (*TVdbeCursor)(unsafe.Pointer(pC21)).FdeferredMoveto = uint8(0) + (*TVdbeCursor)(unsafe.Pointer(pC21)).FcacheStatus = uint32(CACHE_STALE) + } + if rc != 0 { + goto abort_due_to_error + } + (*TVdbeCursor)(unsafe.Pointer(pC21)).FnullRow = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 400))) + if (*TOp)(unsafe.Pointer(pOp)).Fp2 > 0 { + if **(**int32)(__ccgo_up(bp + 400)) != 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: IfEmpty P1 P2 * * * + ** Synopsis: if( empty(P1) ) goto P2 + ** + ** Check to see if the b-tree table that cursor P1 references is empty + ** and jump to P2 if it is. + */ + _115: + ; + pC22 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr7 = *(*uintptr)(unsafe.Pointer(pC22 + 48)) + rc = _sqlite3BtreeIsEmpty(tls, pCrsr7, bp+404) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 404)) != 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Next P1 P2 P3 * P5 + ** + ** Advance cursor P1 so that it points to the next key/data pair in its + ** table or index. If there are no more key/value pairs then fall through + ** to the following instruction. But if the cursor advance was successful, + ** jump immediately to P2. + ** + ** The Next opcode is only valid following an SeekGT, SeekGE, or + ** OP_Rewind opcode used to position the cursor. Next is not allowed + ** to follow SeekLT, SeekLE, or OP_Last. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. P1 must have + ** been opened prior to this opcode or the program will segfault. + ** + ** The P3 value is a hint to the btree implementation. If P3==1, that + ** means P1 is an SQL index and that this instruction could have been + ** omitted if that index had been unique. P3 is usually 0. P3 is + ** always either 0 or 1. + ** + ** If P5 is positive and the jump is taken, then event counter + ** number P5-1 in the prepared statement is incremented. + ** + ** See also: Prev + */ + /* Opcode: Prev P1 P2 P3 * P5 + ** + ** Back up cursor P1 so that it points to the previous key/data pair in its + ** table or index. If there is no previous key/value pairs then fall through + ** to the following instruction. But if the cursor backup was successful, + ** jump immediately to P2. + ** + ** + ** The Prev opcode is only valid following an SeekLT, SeekLE, or + ** OP_Last opcode used to position the cursor. Prev is not allowed + ** to follow SeekGT, SeekGE, or OP_Rewind. + ** + ** The P1 cursor must be for a real table, not a pseudo-table. If P1 is + ** not open then the behavior is undefined. + ** + ** The P3 value is a hint to the btree implementation. If P3==1, that + ** means P1 is an SQL index and that this instruction could have been + ** omitted if that index had been unique. P3 is usually 0. P3 is + ** always either 0 or 1. + ** + ** If P5 is positive and the jump is taken, then event counter + ** number P5-1 in the prepared statement is incremented. + */ + /* Opcode: SorterNext P1 P2 * * P5 + ** + ** This opcode works just like OP_Next except that P1 must be a + ** sorter object for which the OP_SorterSort opcode has been + ** invoked. This opcode advances the cursor to the next sorted + ** record, or jumps to P2 if there are no more sorted records. + */ + _118: + ; + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3VdbeSorterNext(tls, db, pC23) + goto next_tail + _116: + ; /* jump, ncycle */ + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC23 + 48)), (*TOp)(unsafe.Pointer(pOp)).Fp3) + goto next_tail + _117: + ; /* jump, ncycle */ + pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC23 + 48)), (*TOp)(unsafe.Pointer(pOp)).Fp3) + goto next_tail + next_tail: + ; + (*TVdbeCursor)(unsafe.Pointer(pC23)).FcacheStatus = uint32(CACHE_STALE) + if rc == SQLITE_OK { + (*TVdbeCursor)(unsafe.Pointer(pC23)).FnullRow = uint8(0) + **(**Tu32)(__ccgo_up(p + 212 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*4)) = **(**Tu32)(__ccgo_up(p + 212 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*4)) + 1 + goto jump_to_p2_and_check_for_interrupt + } + if rc != int32(SQLITE_DONE) { + goto abort_due_to_error + } + rc = SQLITE_OK + (*TVdbeCursor)(unsafe.Pointer(pC23)).FnullRow = uint8(1) + goto check_for_interrupt + /* Opcode: IdxInsert P1 P2 P3 P4 P5 + ** Synopsis: key=r[P2] + ** + ** Register P2 holds an SQL index key made using the + ** MakeRecord instructions. This opcode writes that key + ** into the index P1. Data for the entry is nil. + ** + ** If P4 is not zero, then it is the number of values in the unpacked + ** key of reg(P2). In that case, P3 is the index of the first register + ** for the unpacked key. The availability of the unpacked key can sometimes + ** be an optimization. + ** + ** If P5 has the OPFLAG_APPEND bit set, that is a hint to the b-tree layer + ** that this insert is likely to be an append. + ** + ** If P5 has the OPFLAG_NCHANGE bit set, then the change counter is + ** incremented by this instruction. If the OPFLAG_NCHANGE bit is clear, + ** then the change counter is unchanged. + ** + ** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might + ** run faster by avoiding an unnecessary seek on cursor P1. However, + ** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior + ** seeks on the cursor or if the most recent seek used a key equivalent + ** to P2. + ** + ** This instruction only works for indices. The equivalent instruction + ** for tables is OP_Insert. + */ + _119: + ; + pC24 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_NCHANGE) != 0 { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + } + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn2) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FnKey = int64((*TMem)(unsafe.Pointer(pIn2)).Fn) + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FpKey = (*TMem)(unsafe.Pointer(pIn2)).Fz + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TBtreePayload)(__ccgo_up(bp + 408))).FnMem = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_USESEEKRESULT) != 0 { + v190 = (*TVdbeCursor)(unsafe.Pointer(pC24)).FseekResult + } else { + v190 = 0 + } + rc = _sqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC24 + 48)), bp+408, libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&(libc.Int32FromInt32(OPFLAG_APPEND)|libc.Int32FromInt32(OPFLAG_SAVEPOSITION)|libc.Int32FromInt32(OPFLAG_PREFORMAT)), v190) + (*TVdbeCursor)(unsafe.Pointer(pC24)).FcacheStatus = uint32(CACHE_STALE) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: SorterInsert P1 P2 * * * + ** Synopsis: key=r[P2] + ** + ** Register P2 holds an SQL index key made using the + ** MakeRecord instructions. This opcode writes that key + ** into the sorter P1. Data for the entry is nil. + */ + _120: + ; + pC25 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags)&int32(MEM_Zero) != 0 { + v190 = _sqlite3VdbeMemExpandBlob(tls, pIn2) + } else { + v190 = 0 + } + rc = v190 + if rc != 0 { + goto abort_due_to_error + } + rc = _sqlite3VdbeSorterWrite(tls, pC25, pIn2) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: IdxDelete P1 P2 P3 P4 * + ** Synopsis: key=r[P2@P3] + ** + ** The content of P3 registers starting at register P2 form + ** an unpacked index key. This opcode removes that entry from the + ** index opened by cursor P1. + ** + ** P4 is a pointer to an Index structure. + ** + ** Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found + ** and not in writable_schema mode. + */ + _121: + ; + pC26 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + pCrsr8 = *(*uintptr)(unsafe.Pointer(pC26 + 48)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC26)).FpKeyInfo + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FnField = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).Fdefault_rc = 0 + (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + rc = _sqlite3BtreeIndexMoveto(tls, pCrsr8, bp+464, bp+456) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 456)) != 0 { + rc = _sqlite3VdbeFindIndexKey(tls, pCrsr8, *(*uintptr)(unsafe.Pointer(pOp + 16)), bp+464, bp+456, 0) + if rc != SQLITE_OK { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 456)) != 0 { + if !(_sqlite3WritableSchema(tls, db) != 0) { + rc = _sqlite3ReportError(tls, libc.Int32FromInt32(SQLITE_CORRUPT)|libc.Int32FromInt32(3)< int64(0x7fffffff) { + rc = _sqlite3CorruptError(tls, int32(103352)) + goto abort_due_to_error + } + _sqlite3VdbeMemInit(tls, bp+552, db, uint16(0)) + rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCur2, libc.Uint32FromInt64(nCellKey), bp+552) + if rc != 0 { + goto abort_due_to_error + } + res11 = _sqlite3VdbeRecordCompareWithSkip(tls, (**(**TMem)(__ccgo_up(bp + 552))).Fn, (**(**TMem)(__ccgo_up(bp + 552))).Fz, bp+512, 0) + _sqlite3VdbeMemReleaseMalloc(tls, bp+552) + /* End of inlined sqlite3VdbeIdxKeyCompare() */ + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode)&int32(1) == libc.Int32FromInt32(OP_IdxLT)&libc.Int32FromInt32(1) { + res11 = -res11 + } else { + res11 = res11 + 1 + } + if res11 > 0 { + goto jump_to_p2 + } + goto _189 + /* Opcode: Destroy P1 P2 P3 * * + ** + ** Delete an entire database table or index whose root page in the database + ** file is given by P1. + ** + ** The table being destroyed is in the main database file if P3==0. If + ** P3==1 then the table to be destroyed is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If AUTOVACUUM is enabled then it is possible that another root page + ** might be moved into the newly deleted root page in order to keep all + ** root pages contiguous at the beginning of the database. The former + ** value of the root page that moved - its value before the move occurred - + ** is stored in register P2. If no page movement was required (because the + ** table being dropped was already the last one in the database) then a + ** zero is stored in register P2. If AUTOVACUUM is disabled then a zero + ** is stored in register P2. + ** + ** This opcode throws an error if there are any active reader VMs when + ** it is invoked. This is done to avoid the difficulty associated with + ** updating existing cursors when a root page is moved in an AUTOVACUUM + ** database. This error is thrown even if the database is not an AUTOVACUUM + ** db in order to avoid introducing an incompatibility between autovacuum + ** and non-autovacuum modes. + ** + ** See also: Clear + */ + _129: + ; + pOut = _out2Prerelease(tls, p, pOp) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > (*Tsqlite3)(unsafe.Pointer(db)).FnVDestroy+int32(1) { + rc = int32(SQLITE_LOCKED) + (*TVdbe)(unsafe.Pointer(p)).FerrorAction = uint8(OE_Abort) + goto abort_due_to_error + } else { + iDb2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 + **(**int32)(__ccgo_up(bp + 608)) = 0 /* Not needed. Only to silence a warning. */ + rc = _sqlite3BtreeDropTable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb2)*32))).FpBt, (*TOp)(unsafe.Pointer(pOp)).Fp1, bp+608) + (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) + *(*Ti64)(unsafe.Pointer(pOut)) = int64(**(**int32)(__ccgo_up(bp + 608))) + if rc != 0 { + goto abort_due_to_error + } + if **(**int32)(__ccgo_up(bp + 608)) != 0 { + _sqlite3RootPageMoved(tls, db, iDb2, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 608))), libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp1)) + /* All OP_Destroy operations occur on the same btree */ + resetSchemaOnFault = libc.Uint8FromInt32(iDb2 + int32(1)) + } + } + goto _189 + /* Opcode: Clear P1 P2 P3 + ** + ** Delete all contents of the database table or index whose root page + ** in the database file is given by P1. But, unlike Destroy, do not + ** remove the table or index from the database file. + ** + ** The table being cleared is in the main database file if P2==0. If + ** P2==1 then the table to be cleared is in the auxiliary database file + ** that is used to store tables create using CREATE TEMPORARY TABLE. + ** + ** If the P3 value is non-zero, then the row change count is incremented + ** by the number of rows in the table being cleared. If P3 is greater + ** than zero, then the value stored in register P3 is also incremented + ** by the number of rows in the table being cleared. + ** + ** See also: Destroy + */ + _130: + ; + **(**Ti64)(__ccgo_up(bp + 616)) = 0 + rc = _sqlite3BtreeClearTable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*32))).FpBt, libc.Int32FromUint32(libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp1)), bp+616) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + **(**Ti64)(__ccgo_up(p + 56)) += **(**Ti64)(__ccgo_up(bp + 616)) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 > 0 { + *(*Ti64)(unsafe.Pointer(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56)) += **(**Ti64)(__ccgo_up(bp + 616)) + } + } + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: ResetSorter P1 * * * * + ** + ** Delete all contents from the ephemeral table or sorter + ** that is open on cursor P1. + ** + ** This opcode only works for cursors used for sorting and + ** opened with OP_OpenEphemeral or OP_SorterOpen. + */ + _131: + ; + pC30 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC30)).FeCurType) == int32(CURTYPE_SORTER) { + _sqlite3VdbeSorterReset(tls, db, *(*uintptr)(unsafe.Pointer(pC30 + 48))) + } else { + rc = _sqlite3BtreeClearTableOfCursor(tls, *(*uintptr)(unsafe.Pointer(pC30 + 48))) + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: CreateBtree P1 P2 P3 * * + ** Synopsis: r[P2]=root iDb=P1 flags=P3 + ** + ** Allocate a new b-tree in the main database file if P1==0 or in the + ** TEMP database file if P1==1 or in an attached database if + ** P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table + ** it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table. + ** The root page number of the new b-tree is stored in register P2. + */ + _132: + ; + pOut = _out2Prerelease(tls, p, pOp) + **(**TPgno)(__ccgo_up(bp + 624)) = uint32(0) + pDb3 = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32 + rc = _sqlite3BtreeCreateTable(tls, (*TDb)(unsafe.Pointer(pDb3)).FpBt, bp+624, (*TOp)(unsafe.Pointer(pOp)).Fp3) + if rc != 0 { + goto abort_due_to_error + } + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(**(**TPgno)(__ccgo_up(bp + 624))) + goto _189 + /* Opcode: SqlExec P1 P2 * P4 * + ** + ** Run the SQL statement or statements specified in the P4 string. + ** + ** The P1 parameter is a bitmask of options: + ** + ** 0x0001 Disable Auth and Trace callbacks while the statements + ** in P4 are running. + ** + ** 0x0002 Set db->nAnalysisLimit to P2 while the statements in + ** P4 are running. + ** + */ + _133: + ; + (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec = (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec + 1 + **(**uintptr)(__ccgo_up(bp + 632)) = uintptr(0) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + mTrace = (*Tsqlite3)(unsafe.Pointer(db)).FmTrace + savedAnalysisLimit = (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit + if (*TOp)(unsafe.Pointer(pOp)).Fp1&int32(0x0001) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = uint8(0) + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1&int32(0x0002) != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = (*TOp)(unsafe.Pointer(pOp)).Fp2 + } + rc = Xsqlite3_exec(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16)), uintptr(0), uintptr(0), bp+632) + (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec = (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec - 1 + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = mTrace + (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = savedAnalysisLimit + if **(**uintptr)(__ccgo_up(bp + 632)) != 0 || rc != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, **(**uintptr)(__ccgo_up(bp + 632)))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 632))) + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + goto abort_due_to_error + } + goto _189 + /* Opcode: ParseSchema P1 * * P4 * + ** + ** Read and parse all entries from the schema table of database P1 + ** that match the WHERE clause P4. If P4 is a NULL pointer, then the + ** entire schema for P1 is reparsed. + ** + ** This opcode invokes the parser to create a new virtual machine, + ** then runs the new virtual machine. It is thus a re-entrant opcode. + */ + _134: + ; + /* Any prepared statement that invokes this opcode will hold mutexes + ** on every btree. This is a prerequisite for invoking + ** sqlite3InitCallback(). + */ + iDb3 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + if *(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0) { + _sqlite3SchemaClear(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FpSchema) + **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_SchemaKnownOk)) + rc = _sqlite3InitOne(tls, db, iDb3, p+168, uint32((*TOp)(unsafe.Pointer(pOp)).Fp5)) + **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + } else { + zSchema = __ccgo_ts + 6284 + (**(**TInitData)(__ccgo_up(bp + 640))).Fdb = db + (**(**TInitData)(__ccgo_up(bp + 640))).FiDb = iDb3 + (**(**TInitData)(__ccgo_up(bp + 640))).FpzErrMsg = p + 168 + (**(**TInitData)(__ccgo_up(bp + 640))).FmInitFlags = uint32(0) + (**(**TInitData)(__ccgo_up(bp + 640))).FmxPage = _sqlite3BtreeLastPage(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FpBt) + zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+6298, libc.VaList(bp+984, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FzDbSName, zSchema, *(*uintptr)(unsafe.Pointer(pOp + 16)))) + if zSql == uintptr(0) { + rc = int32(SQLITE_NOMEM) + } else { + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(1) + (**(**TInitData)(__ccgo_up(bp + 640))).Frc = SQLITE_OK + (**(**TInitData)(__ccgo_up(bp + 640))).FnInitRow = uint32(0) + rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_sqlite3InitCallback), bp+640, uintptr(0)) + if rc == SQLITE_OK { + rc = (**(**TInitData)(__ccgo_up(bp + 640))).Frc + } + if rc == SQLITE_OK && (**(**TInitData)(__ccgo_up(bp + 640))).FnInitRow == uint32(0) { + /* The OP_ParseSchema opcode with a non-NULL P4 argument should parse + ** at least one SQL statement. Any less than that indicates that + ** the sqlite_schema table is corrupt. */ + rc = _sqlite3CorruptError(tls, int32(103645)) + } + _sqlite3DbFreeNN(tls, db, zSql) + (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(0) + } + } + if rc != 0 { + _sqlite3ResetAllSchemasOfConnection(tls, db) + if rc == int32(SQLITE_NOMEM) { + goto no_mem + } + goto abort_due_to_error + } + goto _189 + /* Opcode: LoadAnalysis P1 * * * * + ** + ** Read the sqlite_stat1 table for database P1 and load the content + ** of that table into the internal index hash table. This will cause + ** the analysis to be used when preparing all subsequent queries. + */ + _135: + ; + rc = _sqlite3AnalysisLoad(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: DropTable P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the table named P4 in database P1. This is called after a table + ** is dropped from disk (using the Destroy opcode) in order to keep + ** the internal representation of the + ** schema consistent with what is on disk. + */ + _136: + ; + _sqlite3UnlinkAndDeleteTable(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: DropIndex P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the index named P4 in database P1. This is called after an index + ** is dropped from disk (using the Destroy opcode) + ** in order to keep the internal representation of the + ** schema consistent with what is on disk. + */ + _137: + ; + _sqlite3UnlinkAndDeleteIndex(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: DropTrigger P1 * * P4 * + ** + ** Remove the internal (in-memory) data structures that describe + ** the trigger named P4 in database P1. This is called after a trigger + ** is dropped from disk (using the Destroy opcode) in order to keep + ** the internal representation of the + ** schema consistent with what is on disk. + */ + _138: + ; + _sqlite3UnlinkAndDeleteTrigger(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) + goto _189 + /* Opcode: IntegrityCk P1 P2 P3 P4 P5 + ** + ** Do an analysis of the currently open database. Store in + ** register (P1+1) the text of an error message describing any problems. + ** If no problems are found, store a NULL in register (P1+1). + ** + ** The register (P1) contains one less than the maximum number of allowed + ** errors. At most reg(P1) errors will be reported. + ** In other words, the analysis stops as soon as reg(P1) errors are + ** seen. Reg(P1) is updated with the number of errors remaining. + ** + ** The root page numbers of all tables in the database are integers + ** stored in P4_INTARRAY argument. + ** + ** If P5 is not zero, the check is done on the auxiliary database + ** file, not the main database file. + ** + ** This opcode is used to implement the integrity_check pragma. + */ + _139: + ; /* Register keeping track of errors remaining */ + nRoot = (*TOp)(unsafe.Pointer(pOp)).Fp2 + aRoot = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pnErr = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1+int32(1))*56 + rc = _sqlite3BtreeIntegrityCheck(tls, db, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*32))).FpBt, aRoot+1*4, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, nRoot, int32(*(*Ti64)(unsafe.Pointer(pnErr)))+int32(1), bp+680, bp+688) + _sqlite3VdbeMemSetNull(tls, pIn1) + if **(**int32)(__ccgo_up(bp + 680)) == 0 { + } else { + if rc != 0 { + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 688))) + goto abort_due_to_error + } else { + *(*Ti64)(unsafe.Pointer(pnErr)) -= int64(**(**int32)(__ccgo_up(bp + 680)) - int32(1)) + _sqlite3VdbeMemSetStr(tls, pIn1, **(**uintptr)(__ccgo_up(bp + 688)), int64(-int32(1)), uint8(SQLITE_UTF8), __ccgo_fp(Xsqlite3_free)) + } + } + _sqlite3VdbeChangeEncoding(tls, pIn1, libc.Int32FromUint8(encoding)) + goto check_for_interrupt + /* Opcode: IFindKey P1 P2 P3 P4 * + ** + ** This instruction always follows an OP_Found with the same P1, P2 and P3 + ** values as this instruction and a non-zero P4 value. The P4 value to + ** this opcode is of type P4_INDEX and contains a pointer to the Index + ** object of for the index being searched. + ** + ** This opcode uses sqlite3VdbeFindIndexKey() to search around the current + ** cursor location for an index key that exactly matches all fields that + ** are not indexed expressions or references to VIRTUAL generated columns, + ** and either exactly match or are real numbers that are within 2 ULPs of + ** each other if the don't match. + ** + ** To put it another way, this opcode looks for nearby index entries that + ** are very close to the search key, but which might have small differences + ** in floating-point values that come via an expression. + ** + ** If no nearby alternative entry is found in cursor P1, then jump to P2. + ** But if a close match is found, fall through. + ** + ** This opcode is used by PRAGMA integrity_check to help distinguish + ** between truely corrupt indexes and expression indexes that are holding + ** floating-point values that are off by one or two ULPs. + */ + _140: + ; + pC31 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + libc.Xmemset(tls, bp+704, 0, uint64(40)) + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FnField = (*TIndex)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FnColumn + (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC31)).FpKeyInfo + rc = _sqlite3VdbeFindIndexKey(tls, *(*uintptr)(unsafe.Pointer(pC31 + 48)), *(*uintptr)(unsafe.Pointer(pOp + 16)), bp+704, bp+696, int32(1)) + if rc != 0 || **(**int32)(__ccgo_up(bp + 696)) != 0 { + rc = SQLITE_OK + goto jump_to_p2 + } + (*TVdbeCursor)(unsafe.Pointer(pC31)).FnullRow = uint8(0) + goto _189 + /* Opcode: RowSetAdd P1 P2 * * * + ** Synopsis: rowset(P1)=r[P2] + ** + ** Insert the integer value held by register P2 into a RowSet object + ** held in register P1. + ** + ** An assertion fails if P2 is not an integer. + */ + _141: + ; /* in1, in2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + if _sqlite3VdbeMemSetRowSet(tls, pIn1) != 0 { + goto no_mem + } + } + _sqlite3RowSetInsert(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, *(*Ti64)(unsafe.Pointer(pIn2))) + goto _189 + /* Opcode: RowSetRead P1 P2 P3 * * + ** Synopsis: r[P3]=rowset(P1) + ** + ** Extract the smallest value from the RowSet object in P1 + ** and put that value into register P3. + ** Or, if RowSet object P1 is initially empty, leave P3 + ** unchanged and jump to instruction P2. + */ + _142: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 || _sqlite3RowSetNext(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, bp+744) == 0 { + /* The boolean index is empty */ + _sqlite3VdbeMemSetNull(tls, pIn1) + goto jump_to_p2_and_check_for_interrupt + } else { + /* A value was pulled from the index */ + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, **(**Ti64)(__ccgo_up(bp + 744))) + } + goto check_for_interrupt + /* Opcode: RowSetTest P1 P2 P3 P4 + ** Synopsis: if r[P3] in rowset(P1) goto P2 + ** + ** Register P3 is assumed to hold a 64-bit integer value. If register P1 + ** contains a RowSet object and that RowSet object contains + ** the value held in P3, jump to register P2. Otherwise, insert the + ** integer in P3 into the RowSet and continue on to the + ** next opcode. + ** + ** The RowSet object is optimized for the case where sets of integers + ** are inserted in distinct phases, which each set contains no duplicates. + ** Each set is identified by a unique P4 value. The first set + ** must have P4==0, the final set must have P4==-1, and for all other sets + ** must have P4>0. + ** + ** This allows optimizations: (a) when P4==0 there is no need to test + ** the RowSet object for P3, as it is guaranteed not to contain it, + ** (b) when P4==-1 there is no need to insert the value, as it will + ** never be tested for, and (c) when a value that is part of set X is + ** inserted, there is no need to search to see if the same value was + ** previously inserted as part of set X (only if it was previously + ** inserted as part of some other set). + */ + _143: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + iSet = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi + /* If there is anything other than a rowset object in memory cell P1, + ** delete it now and initialize P1 with an empty rowset + */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { + if _sqlite3VdbeMemSetRowSet(tls, pIn1) != 0 { + goto no_mem + } + } + if iSet != 0 { + exists = _sqlite3RowSetTest(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, iSet, *(*Ti64)(unsafe.Pointer(pIn3))) + if exists != 0 { + goto jump_to_p2 + } + } + if iSet >= 0 { + _sqlite3RowSetInsert(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, *(*Ti64)(unsafe.Pointer(pIn3))) + } + goto _189 + /* Opcode: Program P1 P2 P3 P4 P5 + ** + ** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). + ** + ** P1 contains the address of the memory cell that contains the first memory + ** cell in an array of values used as arguments to the sub-program. P2 + ** contains the address to jump to if the sub-program throws an IGNORE + ** exception using the RAISE() function. P2 might be zero, if there is + ** no possibility that an IGNORE exception will be raised. + ** Register P3 contains the address + ** of a memory cell in this (the parent) VM that is used to allocate the + ** memory required by the sub-vdbe at runtime. + ** + ** P4 is a pointer to the VM containing the trigger program. + ** + ** If P5 is non-zero, then recursive program invocation is enabled. + */ + _144: + ; /* Token identifying trigger */ + pProgram = *(*uintptr)(unsafe.Pointer(pOp + 16)) + pRt = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + /* If the p5 flag is clear, then recursive invocation of triggers is + ** disabled for backwards compatibility (p5 is set if this sub-program + ** is really a trigger, not a foreign key action, and the flag set + ** and cleared by the "PRAGMA recursive_triggers" command is clear). + ** + ** It is recursive invocation of triggers, at the SQL level, that is + ** disabled. In some cases a single trigger may generate more than one + ** SubProgram (if the trigger may be executed with more than one different + ** ON CONFLICT algorithm). SubProgram structures associated with a + ** single trigger all have the same value for the SubProgram.token + ** variable. */ + if (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 { + t1 = (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken + pFrame2 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + for { + if !(pFrame2 != 0 && (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken != t1) { + break + } + goto _278 + _278: + ; + pFrame2 = (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpParent + } + if pFrame2 != 0 { + goto _189 + } + } + if (*TVdbe)(unsafe.Pointer(p)).FnFrame >= **(**int32)(__ccgo_up(db + 136 + 10*4)) { + rc = int32(SQLITE_ERROR) + _sqlite3VdbeError(tls, p, __ccgo_ts+6341, 0) + goto abort_due_to_error + } + /* Register pRt is used to store the memory required to save the state + ** of the current program, and the memory required at runtime to execute + ** the trigger program. If this trigger has been fired before, then pRt + ** is already allocated. Otherwise, it must be initialized. */ + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRt)).Fflags)&int32(MEM_Blob) == 0 { + /* SubProgram.nMem is set to the number of memory cells used by the + ** program stored in SubProgram.aOp. As well as these, one memory + ** cell is required for each cursor used by the program. Set local + ** variable nMem (and later, VdbeFrame.nChildMem) to this value. + */ + nMem = (*TSubProgram)(unsafe.Pointer(pProgram)).FnMem + (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr + if (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr == 0 { + nMem = nMem + 1 + } + nByte2 = libc.Int64FromUint64(uint64((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32(nMem)*uint64(56)+libc.Uint64FromInt32((*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr)*uint64(8)) + libc.Uint64FromInt64((int64(7)+int64((*TSubProgram)(unsafe.Pointer(pProgram)).FnOp))/int64(8))) + pFrame2 = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte2)) + if !(pFrame2 != 0) { + goto no_mem + } + _sqlite3VdbeMemRelease(tls, pRt) + (*TMem)(unsafe.Pointer(pRt)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Blob) | libc.Int32FromInt32(MEM_Dyn)) + (*TMem)(unsafe.Pointer(pRt)).Fz = pFrame2 + (*TMem)(unsafe.Pointer(pRt)).Fn = int32(nByte2) + (*TMem)(unsafe.Pointer(pRt)).FxDel = __ccgo_fp(_sqlite3VdbeFrameMemDel) + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Fv = p + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem = nMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr = (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaMem = (*TVdbe)(unsafe.Pointer(p)).FaMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnMem = (*TVdbe)(unsafe.Pointer(p)).FnMem + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FapCsr = (*TVdbe)(unsafe.Pointer(p)).FapCsr + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnCursor = (*TVdbe)(unsafe.Pointer(p)).FnCursor + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOp = (*TVdbe)(unsafe.Pointer(p)).FaOp + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnOp = (*TVdbe)(unsafe.Pointer(p)).FnOp + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken = (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken + pEnd = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + uintptr((*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*56 + pMem1 = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + for { + if !(pMem1 != pEnd) { + break + } + (*TMem)(unsafe.Pointer(pMem1)).Fflags = uint16(MEM_Undefined) + (*TMem)(unsafe.Pointer(pMem1)).Fdb = db + goto _279 + _279: + ; + pMem1 += 56 + } + } else { + pFrame2 = (*TMem)(unsafe.Pointer(pRt)).Fz + } + (*TVdbe)(unsafe.Pointer(p)).FnFrame = (*TVdbe)(unsafe.Pointer(p)).FnFrame + 1 + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpParent = (*TVdbe)(unsafe.Pointer(p)).FpFrame + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FlastRowid = (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnDbChange = (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FnChange + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpAuxData = (*TVdbe)(unsafe.Pointer(p)).FpAuxData + (*TVdbe)(unsafe.Pointer(p)).FpAuxData = uintptr(0) + (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 + (*TVdbe)(unsafe.Pointer(p)).FpFrame = pFrame2 + v191 = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + aMem = v191 + (*TVdbe)(unsafe.Pointer(p)).FaMem = v191 + (*TVdbe)(unsafe.Pointer(p)).FnMem = (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem + (*TVdbe)(unsafe.Pointer(p)).FnCursor = libc.Int32FromUint16(libc.Uint16FromInt32((*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr)) + (*TVdbe)(unsafe.Pointer(p)).FapCsr = aMem + uintptr((*TVdbe)(unsafe.Pointer(p)).FnMem)*56 + (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce = (*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr)*8 + libc.Xmemset(tls, (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce, 0, libc.Uint64FromInt32(((*TSubProgram)(unsafe.Pointer(pProgram)).FnOp+int32(7))/int32(8))) + v191 = (*TSubProgram)(unsafe.Pointer(pProgram)).FaOp + aOp = v191 + (*TVdbe)(unsafe.Pointer(p)).FaOp = v191 + (*TVdbe)(unsafe.Pointer(p)).FnOp = (*TSubProgram)(unsafe.Pointer(pProgram)).FnOp + pOp = aOp + uintptr(-libc.Int32FromInt32(1))*24 + goto check_for_interrupt + /* Opcode: Param P1 P2 * * * + ** + ** This opcode is only ever present in sub-programs called via the + ** OP_Program instruction. Copy a value currently stored in a memory + ** cell of the calling (parent) frame to cell P2 in the current frames + ** address space. This is used by trigger programs to access the new.* + ** and old.* values. + ** + ** The address of the cell in the parent frame is determined by adding + ** the value of the P1 argument to the value of the P1 argument to the + ** calling OP_Program instruction. + */ + _145: + ; + pOut = _out2Prerelease(tls, p, pOp) + pFrame3 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + pIn = (*TVdbeFrame)(unsafe.Pointer(pFrame3)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1+(**(**TOp)(__ccgo_up((*TVdbeFrame)(unsafe.Pointer(pFrame3)).FaOp + uintptr((*TVdbeFrame)(unsafe.Pointer(pFrame3)).Fpc)*24))).Fp1)*56 + _sqlite3VdbeMemShallowCopy(tls, pOut, pIn, int32(MEM_Ephem)) + goto _189 + /* Opcode: FkCounter P1 P2 * * * + ** Synopsis: fkctr[P1]+=P2 + ** + ** Increment a "constraint counter" by P2 (P2 may be negative or positive). + ** If P1 is non-zero, the database constraint counter is incremented + ** (deferred foreign key constraints). Otherwise, if P1 is zero, the + ** statement counter is incremented (immediate foreign key constraints). + */ + _146: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + **(**Ti64)(__ccgo_up(db + 784)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0 { + **(**Ti64)(__ccgo_up(db + 792)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + **(**Ti64)(__ccgo_up(p + 80)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) + } + } + goto _189 + /* Opcode: FkIfZero P1 P2 * * * + ** Synopsis: if fkctr[P1]==0 goto P2 + ** + ** This opcode tests if a foreign key constraint-counter is currently zero. + ** If so, jump to instruction P2. Otherwise, fall through to the next + ** instruction. + ** + ** If P1 is non-zero, then the jump is taken if the database constraint-counter + ** is zero (the one that counts deferred constraint violations). If P1 is + ** zero, the jump is taken if the statement constraint-counter is zero + ** (immediate foreign key constraint violations). + */ + _147: + ; /* jump */ + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + if (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { + goto jump_to_p2 + } + } else { + if (*TVdbe)(unsafe.Pointer(p)).FnFkConstraint == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { + goto jump_to_p2 + } + } + goto _189 + /* Opcode: MemMax P1 P2 * * * + ** Synopsis: r[P1]=max(r[P1],r[P2]) + ** + ** P1 is a register in the root frame of this VM (the root frame is + ** different from the current frame if this instruction is being executed + ** within a sub-program). Set the value of register P1 to the maximum of + ** its current value and the value in register P2. + ** + ** This instruction throws an error if the memory cell is not initially + ** an integer. + */ + _148: + ; + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + pFrame4 = (*TVdbe)(unsafe.Pointer(p)).FpFrame + for { + if !((*TVdbeFrame)(unsafe.Pointer(pFrame4)).FpParent != 0) { + break + } + goto _282 + _282: + ; + pFrame4 = (*TVdbeFrame)(unsafe.Pointer(pFrame4)).FpParent + } + pIn1 = (*TVdbeFrame)(unsafe.Pointer(pFrame4)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + } else { + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + } + _sqlite3VdbeMemIntegerify(tls, pIn1) + pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + _sqlite3VdbeMemIntegerify(tls, pIn2) + if *(*Ti64)(unsafe.Pointer(pIn1)) < *(*Ti64)(unsafe.Pointer(pIn2)) { + *(*Ti64)(unsafe.Pointer(pIn1)) = *(*Ti64)(unsafe.Pointer(pIn2)) + } + goto _189 + /* Opcode: IfPos P1 P2 P3 * * + ** Synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 + ** + ** Register P1 must contain an integer. + ** If the value of register P1 is 1 or greater, subtract P3 from the + ** value in P1 and jump to P2. + ** + ** If the initial value of register P1 is less than 1, then the + ** value is unchanged and control passes through to the next instruction. + */ + _149: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) > 0 { + *(*Ti64)(unsafe.Pointer(pIn1)) -= int64((*TOp)(unsafe.Pointer(pOp)).Fp3) + goto jump_to_p2 + } + goto _189 + /* Opcode: OffsetLimit P1 P2 P3 * * + ** Synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) + ** + ** This opcode performs a commonly used computation associated with + ** LIMIT and OFFSET processing. r[P1] holds the limit counter. r[P3] + ** holds the offset counter. The opcode computes the combined value + ** of the LIMIT and OFFSET and stores that value in r[P2]. The r[P2] + ** value computed is the total number of rows that will need to be + ** visited in order to complete the query. + ** + ** If r[P3] is zero or negative, that means there is no OFFSET + ** and r[P2] is set to be the value of the LIMIT, r[P1]. + ** + ** if r[P1] is zero or negative, that means there is no LIMIT + ** and r[P2] is set to -1. + ** + ** Otherwise, r[P2] is set to the sum of r[P1] and r[P3]. + */ + _150: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + pOut = _out2Prerelease(tls, p, pOp) + **(**Ti64)(__ccgo_up(bp + 752)) = *(*Ti64)(unsafe.Pointer(pIn1)) + if v217 = **(**Ti64)(__ccgo_up(bp + 752)) <= 0; !v217 { + if *(*Ti64)(unsafe.Pointer(pIn3)) > 0 { + v206 = *(*Ti64)(unsafe.Pointer(pIn3)) + } else { + v206 = 0 + } + } + if v217 || _sqlite3AddInt64(tls, bp+752, v206) != 0 { + /* If the LIMIT is less than or equal to zero, loop forever. This + ** is documented. But also, if the LIMIT+OFFSET exceeds 2^63 then + ** also loop forever. This is undocumented. In fact, one could argue + ** that the loop should terminate. But assuming 1 billion iterations + ** per second (far exceeding the capabilities of any current hardware) + ** it would take nearly 300 years to actually reach the limit. So + ** looping forever is a reasonable approximation. */ + *(*Ti64)(unsafe.Pointer(pOut)) = int64(-int32(1)) + } else { + *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 752)) + } + goto _189 + /* Opcode: IfNotZero P1 P2 * * * + ** Synopsis: if r[P1]!=0 then r[P1]--, goto P2 + ** + ** Register P1 must contain an integer. If the content of register P1 is + ** initially greater than zero, then decrement the value in register P1. + ** If it is non-zero (negative or positive) and then also jump to P2. + ** If register P1 is initially zero, leave it unchanged and fall through. + */ + _151: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) != 0 { + if *(*Ti64)(unsafe.Pointer(pIn1)) > 0 { + *(*Ti64)(unsafe.Pointer(pIn1)) = *(*Ti64)(unsafe.Pointer(pIn1)) - 1 + } + goto jump_to_p2 + } + goto _189 + /* Opcode: DecrJumpZero P1 P2 * * * + ** Synopsis: if (--r[P1])==0 goto P2 + ** + ** Register P1 must hold an integer. Decrement the value in P1 + ** and jump to P2 if the new value is exactly zero. + */ + _152: + ; /* jump, in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if *(*Ti64)(unsafe.Pointer(pIn1)) > int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= 0) { + break + } + *(*uintptr)(unsafe.Pointer(pCtx1 + 48 + uintptr(i4)*8)) = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2+i4)*56 + goto _285 + _285: + ; + i4 = i4 - 1 + } + } + (*TMem)(unsafe.Pointer(pMem2)).Fn = (*TMem)(unsafe.Pointer(pMem2)).Fn + 1 + if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxInverse})))(tls, pCtx1, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+48) + } else { + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxSFunc})))(tls, pCtx1, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+48) + } /* IMP: R-24505-23230 */ + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError != 0 { + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError > 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut))) + rc = (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError + } + if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag != 0 { + i4 = (**(**TOp)(__ccgo_up(pOp + uintptr(-libc.Int32FromInt32(1))*24))).Fp1 + if i4 != 0 { + _sqlite3VdbeMemSetInt64(tls, aMem+uintptr(i4)*56, int64(1)) + } + (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag = uint8(0) + } + _sqlite3VdbeMemRelease(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut) + (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = uint16(MEM_Null) + (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError = 0 + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: AggFinal P1 P2 * P4 * + ** Synopsis: accum=r[P1] N=P2 + ** + ** P1 is the memory location that is the accumulator for an aggregate + ** or window function. Execute the finalizer function + ** for an aggregate and store the result in P1. + ** + ** P2 is the number of arguments that the step function takes and + ** P4 is a pointer to the FuncDef for this function. The P2 + ** argument is not used by this opcode. It is only there to disambiguate + ** functions that can take varying numbers of arguments. The + ** P4 argument is only needed for the case where + ** the step function was not previously called. + */ + /* Opcode: AggValue * P2 P3 P4 * + ** Synopsis: r[P3]=value N=P2 + ** + ** Invoke the xValue() function and store the result in register P3. + ** + ** P2 is the number of arguments that the step function takes and + ** P4 is a pointer to the FuncDef for this function. The P2 + ** argument is not used by this opcode. It is only there to disambiguate + ** functions that can take varying numbers of arguments. The + ** P4 argument is only needed for the case where + ** the step function was not previously called. + */ + _157: + ; + _156: + ; + pMem3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + rc = _sqlite3VdbeMemAggValue(tls, pMem3, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, *(*uintptr)(unsafe.Pointer(pOp + 16))) + pMem3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + } else { + rc = _sqlite3VdbeMemFinalize(tls, pMem3, *(*uintptr)(unsafe.Pointer(pOp + 16))) + } + if rc != 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pMem3))) + goto abort_due_to_error + } + _sqlite3VdbeChangeEncoding(tls, pMem3, libc.Int32FromUint8(encoding)) + goto _189 + /* Opcode: Checkpoint P1 P2 P3 * * + ** + ** Checkpoint database P1. This is a no-op if P1 is not currently in + ** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL, + ** RESTART, or TRUNCATE. Write 1 or 0 into mem[P3] if the checkpoint returns + ** SQLITE_BUSY or not, respectively. Write the number of pages in the + ** WAL after the checkpoint into mem[P3+1] and the number of pages + ** in the WAL that have been checkpointed after the checkpoint + ** completes into mem[P3+2]. However on an error, mem[P3+1] and + ** mem[P3+2] are initialized to -1. + */ + _158: + ; /* Write results here */ + (**(**[3]int32)(__ccgo_up(bp + 760)))[0] = 0 + v190 = -libc.Int32FromInt32(1) + (**(**[3]int32)(__ccgo_up(bp + 760)))[int32(2)] = v190 + (**(**[3]int32)(__ccgo_up(bp + 760)))[int32(1)] = v190 + rc = _sqlite3Checkpoint(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, bp+760+1*4, bp+760+2*4) + if rc != 0 { + if rc != int32(SQLITE_BUSY) { + goto abort_due_to_error + } + rc = SQLITE_OK + (**(**[3]int32)(__ccgo_up(bp + 760)))[0] = int32(1) + } + i5 = 0 + pMem4 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + for { + if !(i5 < int32(3)) { + break + } + _sqlite3VdbeMemSetInt64(tls, pMem4, int64((**(**[3]int32)(__ccgo_up(bp + 760)))[i5])) + goto _287 + _287: + ; + i5 = i5 + 1 + pMem4 += 56 + } + goto _189 + /* Opcode: JournalMode P1 P2 P3 * * + ** + ** Change the journal mode of database P1 to P3. P3 must be one of the + ** PAGER_JOURNALMODE_XXX values. If changing between the various rollback + ** modes (delete, truncate, persist, off and memory), this is a simple + ** operation. No IO is required. + ** + ** If changing into or out of WAL mode the procedure is more complicated. + ** + ** Write a string containing the final journal-mode to register P2. + */ + _159: + ; /* Name of database file for pPager */ + pOut = _out2Prerelease(tls, p, pOp) + eNew = (*TOp)(unsafe.Pointer(pOp)).Fp3 + pBt1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + pPager = _sqlite3BtreePager(tls, pBt1) + eOld = _sqlite3PagerGetJournalMode(tls, pPager) + if eNew == -int32(1) { + eNew = eOld + } + if !(_sqlite3PagerOkToChangeJournalMode(tls, pPager) != 0) { + eNew = eOld + } + zFilename = _sqlite3PagerFilename(tls, pPager, int32(1)) + /* Do not allow a transition to journal_mode=WAL for a database + ** in temporary storage or if the VFS does not support shared memory + */ + if eNew == int32(PAGER_JOURNALMODE_WAL) && (_sqlite3Strlen30(tls, zFilename) == 0 || !(_sqlite3PagerWalSupported(tls, pPager) != 0)) { + eNew = eOld + } + if eNew != eOld && (eOld == int32(PAGER_JOURNALMODE_WAL) || eNew == int32(PAGER_JOURNALMODE_WAL)) { + if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1) { + rc = int32(SQLITE_ERROR) + if eNew == int32(PAGER_JOURNALMODE_WAL) { + v191 = __ccgo_ts + 6378 + } else { + v191 = __ccgo_ts + 6383 + } + _sqlite3VdbeError(tls, p, __ccgo_ts+6390, libc.VaList(bp+984, v191)) + goto abort_due_to_error + } else { + if eOld == int32(PAGER_JOURNALMODE_WAL) { + /* If leaving WAL mode, close the log file. If successful, the call + ** to PagerCloseWal() checkpoints and deletes the write-ahead-log + ** file. An EXCLUSIVE lock may still be held on the database file + ** after a successful return. + */ + rc = _sqlite3PagerCloseWal(tls, pPager, db) + if rc == SQLITE_OK { + _sqlite3PagerSetJournalMode(tls, pPager, eNew) + } + } else { + if eOld == int32(PAGER_JOURNALMODE_MEMORY) { + /* Cannot transition directly from MEMORY to WAL. Use mode OFF + ** as an intermediate */ + _sqlite3PagerSetJournalMode(tls, pPager, int32(PAGER_JOURNALMODE_OFF)) + } + } + /* Open a transaction on the database file. Regardless of the journal + ** mode, this transaction always uses a rollback journal. + */ + if rc == SQLITE_OK { + if eNew == int32(PAGER_JOURNALMODE_WAL) { + v190 = int32(2) + } else { + v190 = int32(1) + } + rc = _sqlite3BtreeSetVersion(tls, pBt1, v190) + } + } + } + if rc != 0 { + eNew = eOld + } + eNew = _sqlite3PagerSetJournalMode(tls, pPager, eNew) + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Term)) + (*TMem)(unsafe.Pointer(pOut)).Fz = _sqlite3JournalModename(tls, eNew) + (*TMem)(unsafe.Pointer(pOut)).Fn = _sqlite3Strlen30(tls, (*TMem)(unsafe.Pointer(pOut)).Fz) + (*TMem)(unsafe.Pointer(pOut)).Fenc = uint8(SQLITE_UTF8) + _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8(encoding)) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: Vacuum P1 P2 * * * + ** + ** Vacuum the entire database P1. P1 is 0 for "main", and 2 or more + ** for an attached database. The "temp" database may not be vacuumed. + ** + ** If P2 is not zero, then it is a register holding a string which is + ** the file into which the result of vacuum should be written. When + ** P2 is zero, the vacuum overwrites the original database. + */ + _160: + ; + if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 { + v191 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + } else { + v191 = uintptr(0) + } + rc = _sqlite3RunVacuum(tls, p+168, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, v191) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: IncrVacuum P1 P2 * * * + ** + ** Perform a single step of the incremental vacuum procedure on + ** the P1 database. If the vacuum has finished, jump to instruction + ** P2. Otherwise, fall through to the next instruction. + */ + _161: + ; + pBt2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + rc = _sqlite3BtreeIncrVacuum(tls, pBt2) + if rc != 0 { + if rc != int32(SQLITE_DONE) { + goto abort_due_to_error + } + rc = SQLITE_OK + goto jump_to_p2 + } + goto _189 + /* Opcode: Expire P1 P2 * * * + ** + ** Cause precompiled statements to expire. When an expired statement + ** is executed using sqlite3_step() it will either automatically + ** reprepare itself (if it was originally created using sqlite3_prepare_v2()) + ** or it will fail with SQLITE_SCHEMA. + ** + ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, + ** then only the currently executing statement is expired. + ** + ** If P2 is 0, then SQL statements are expired immediately. If P2 is 1, + ** then running SQL statements are allowed to continue to run to completion. + ** The P2==1 case occurs when a CREATE INDEX or similar schema change happens + ** that might help the statement run faster but which does not affect the + ** correctness of operation. + */ + _162: + ; + if !((*TOp)(unsafe.Pointer(pOp)).Fp1 != 0) { + _sqlite3ExpirePreparedStatements(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp2) + } else { + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2+libc.Int32FromInt32(1)), 0, 0x3) + } + goto _189 + /* Opcode: CursorLock P1 * * * * + ** + ** Lock the btree to which cursor P1 is pointing so that the btree cannot be + ** written by an other cursor. + */ + _163: + ; + pC32 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + _sqlite3BtreeCursorPin(tls, *(*uintptr)(unsafe.Pointer(pC32 + 48))) + goto _189 + /* Opcode: CursorUnlock P1 * * * * + ** + ** Unlock the btree to which cursor P1 is pointing so that it can be + ** written by other cursors. + */ + _164: + ; + pC33 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + _sqlite3BtreeCursorUnpin(tls, *(*uintptr)(unsafe.Pointer(pC33 + 48))) + goto _189 + /* Opcode: TableLock P1 P2 P3 P4 * + ** Synopsis: iDb=P1 root=P2 write=P3 + ** + ** Obtain a lock on a particular table. This instruction is only used when + ** the shared-cache feature is enabled. + ** + ** P1 is the index of the database in sqlite3.aDb[] of the database + ** on which the lock is acquired. A readlock is obtained if P3==0 or + ** a write lock if P3==1. + ** + ** P2 contains the root-page of the table to lock. + ** + ** P4 contains a pointer to the name of the table being locked. This is only + ** used to generate an error message if the lock cannot be obtained. + */ + _165: + ; + isWriteLock = libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + if isWriteLock != 0 || uint64(0) == (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00004))< 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pDest2))) + rc = (**(**Tsqlite3_context)(__ccgo_up(bp + 848))).FisError + } + _sqlite3VdbeChangeEncoding(tls, pDest2, libc.Int32FromUint8(encoding)) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: VNext P1 P2 * * * + ** + ** Advance virtual table P1 to the next row in its result set and + ** jump to instruction P2. Or, if the virtual table has reached + ** the end of its result set, then fall through to the next instruction. + */ + _174: + ; + pCur6 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + if (*TVdbeCursor)(unsafe.Pointer(pCur6)).FnullRow != 0 { + goto _189 + } + pVtab5 = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCur6 + 48)))).FpVtab + pModule5 = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab5)).FpModule + /* Invoke the xNext() method of the module. There is no way for the + ** underlying implementation to return an error if one occurs during + ** xNext(). Instead, if an error occurs, true is returned (indicating that + ** data is available) and the error code returned when xColumn or + ** some other method is next invoked on the save virtual table cursor. + */ + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule5)).FxNext})))(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 48))) + _sqlite3VtabImportErrmsg(tls, p, pVtab5) + if rc != 0 { + goto abort_due_to_error + } + res14 = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule5)).FxEof})))(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 48))) + if !(res14 != 0) { + /* If there is data, jump to P2 */ + goto jump_to_p2_and_check_for_interrupt + } + goto check_for_interrupt + /* Opcode: VRename P1 * * P4 * + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** This opcode invokes the corresponding xRename method. The value + ** in register P1 is passed as the zName argument to the xRename method. + */ + _175: + ; + isLegacy = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_LegacyAlter)) + **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_LegacyAlter) + pVtab6 = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab + pName = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + rc = _sqlite3VdbeChangeEncoding(tls, pName, int32(SQLITE_UTF8)) + if rc != 0 { + goto abort_due_to_error + } + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVtab6)).FpModule)).FxRename})))(tls, pVtab6, (*TMem)(unsafe.Pointer(pName)).Fz) + if isLegacy == 0 { + **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_LegacyAlter) + } + _sqlite3VtabImportErrmsg(tls, p, pVtab6) + libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) + if rc != 0 { + goto abort_due_to_error + } + goto _189 + /* Opcode: VUpdate P1 P2 P3 P4 P5 + ** Synopsis: data=r[P3@P2] + ** + ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. + ** This opcode invokes the corresponding xUpdate method. P2 values + ** are contiguous memory cells starting at P3 to pass to the xUpdate + ** invocation. The value in register (P3+P2-1) corresponds to the + ** p2th element of the argv array passed to xUpdate. + ** + ** The xUpdate method will do a DELETE or an INSERT or both. + ** The argv[0] element (which corresponds to memory cell P3) + ** is the rowid of a row to delete. If argv[0] is NULL then no + ** deletion occurs. The argv[1] element is the rowid of the new + ** row. This can be NULL to have the virtual table select the new + ** rowid for itself. The subsequent elements in the array are + ** the values of columns in the new row. + ** + ** If P2==1 then no insert is performed. argv[0] is the rowid of + ** a row to delete. + ** + ** P1 is a boolean flag. If it is set to true and the xUpdate call + ** is successful, then the value returned by sqlite3_last_insert_rowid() + ** is set to the value of the rowid for the row just inserted. + ** + ** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to + ** apply in the case of a constraint failure on an insert or update. + */ + _176: + ; + **(**Tsqlite_int64)(__ccgo_up(bp + 968)) = 0 + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + goto no_mem + } + pVtab7 = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab + if pVtab7 == uintptr(0) || (*Tsqlite3_vtab)(unsafe.Pointer(pVtab7)).FpModule == uintptr(0) { + rc = int32(SQLITE_LOCKED) + goto abort_due_to_error + } + pModule6 = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab7)).FpModule + nArg1 = (*TOp)(unsafe.Pointer(pOp)).Fp2 + if (*Tsqlite3_module)(unsafe.Pointer(pModule6)).FxUpdate != 0 { + vtabOnConflict = (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict + apArg1 = (*TVdbe)(unsafe.Pointer(p)).FapArg + pX1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + i7 = 0 + for { + if !(i7 < nArg1) { + break + } + **(**uintptr)(__ccgo_up(apArg1 + uintptr(i7)*8)) = pX1 + pX1 += 56 + goto _292 + _292: + ; + i7 = i7 + 1 + } + (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict = uint8((*TOp)(unsafe.Pointer(pOp)).Fp5) + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule6)).FxUpdate})))(tls, pVtab7, nArg1, apArg1, bp+968) + (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict = vtabOnConflict + _sqlite3VtabImportErrmsg(tls, p, pVtab7) + if rc == SQLITE_OK && (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { + (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = **(**Tsqlite_int64)(__ccgo_up(bp + 968)) + } + if rc&int32(0xff) == int32(SQLITE_CONSTRAINT) && (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FbConstraint != 0 { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == int32(OE_Ignore) { + rc = SQLITE_OK + } else { + if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == int32(OE_Replace) { + v190 = int32(OE_Abort) + } else { + v190 = libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) + } + (*TVdbe)(unsafe.Pointer(p)).FerrorAction = libc.Uint8FromInt32(v190) + } + } else { + (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 + } + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: Pagecount P1 P2 * * * + ** + ** Write the current number of pages in database P1 to memory cell P2. + */ + _177: + ; /* out2 */ + pOut = _out2Prerelease(tls, p, pOp) + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(_sqlite3BtreeLastPage(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt)) + goto _189 + /* Opcode: MaxPgcnt P1 P2 P3 * * + ** + ** Try to set the maximum page count for database P1 to the value in P3. + ** Do not let the maximum page count fall below the current page count and + ** do not change the maximum page count value if P3==0. + ** + ** Store the maximum page count after the change in register P2. + */ + _178: + ; + pOut = _out2Prerelease(tls, p, pOp) + pBt3 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt + newMax = uint32(0) + if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { + newMax = _sqlite3BtreeLastPage(tls, pBt3) + if newMax < libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) { + newMax = libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) + } + } + *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(_sqlite3BtreeMaxPageCount(tls, pBt3, newMax)) + goto _189 + /* Opcode: Function P1 P2 P3 P4 * + ** Synopsis: r[P3]=func(r[P2@NP]) + ** + ** Invoke a user function (P4 is a pointer to an sqlite3_context object that + ** contains a pointer to the function to be run) with arguments taken + ** from register P2 and successors. The number of arguments is in + ** the sqlite3_context object that P4 points to. + ** The result of the function is stored + ** in register P3. Register P3 must not be one of the function inputs. + ** + ** P1 is a 32-bit bitmask indicating whether or not each argument to the + ** function was determined to be constant at compile time. If the first + ** argument was constant then bit 0 of P1 is set. This is used to determine + ** whether meta data associated with a user function argument using the + ** sqlite3_set_auxdata() API may be safely retained until the next + ** invocation of this opcode. + ** + ** See also: AggStep, AggFinal, PureFunc + */ + /* Opcode: PureFunc P1 P2 P3 P4 * + ** Synopsis: r[P3]=func(r[P2@NP]) + ** + ** Invoke a user function (P4 is a pointer to an sqlite3_context object that + ** contains a pointer to the function to be run) with arguments taken + ** from register P2 and successors. The number of arguments is in + ** the sqlite3_context object that P4 points to. + ** The result of the function is stored + ** in register P3. Register P3 must not be one of the function inputs. + ** + ** P1 is a 32-bit bitmask indicating whether or not each argument to the + ** function was determined to be constant at compile time. If the first + ** argument was constant then bit 0 of P1 is set. This is used to determine + ** whether meta data associated with a user function argument using the + ** sqlite3_set_auxdata() API may be safely retained until the next + ** invocation of this opcode. + ** + ** This opcode works exactly like OP_Function. The only difference is in + ** its name. This opcode is used in places where the function must be + ** purely non-deterministic. Some built-in date/time functions can be + ** either deterministic of non-deterministic, depending on their arguments. + ** When those function are used in a non-deterministic way, they will check + ** to see if they were called using OP_PureFunc instead of OP_Function, and + ** if they were, they throw an error. + ** + ** See also: AggStep, AggFinal, Function + */ + _180: + ; /* group */ + _179: + ; + pCtx2 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + /* If this function is inside of a trigger, the register array in aMem[] + ** might change from one evaluation to the next. The next block of code + ** checks to see if the register array has changed, and if so it + ** reinitializes the relevant parts of the sqlite3_context object */ + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpOut != pOut { + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpVdbe = p + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpOut = pOut + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fenc = encoding + i8 = libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fargc) - int32(1) + for { + if !(i8 >= 0) { + break + } + *(*uintptr)(unsafe.Pointer(pCtx2 + 48 + uintptr(i8)*8)) = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2+i8)*56 + goto _294 + _294: + ; + i8 = i8 - 1 + } + } + (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Null)) + (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpFunc)).FxSFunc})))(tls, pCtx2, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fargc), pCtx2+48) /* IMP: R-24505-23230 */ + /* If the function returned an error, throw an exception */ + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError != 0 { + if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError > 0 { + _sqlite3VdbeError(tls, p, __ccgo_ts+3944, libc.VaList(bp+984, Xsqlite3_value_text(tls, pOut))) + rc = (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError + } + _sqlite3VdbeDeleteAuxData(tls, db, p+296, (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FiOp, (*TOp)(unsafe.Pointer(pOp)).Fp1) + (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError = 0 + if rc != 0 { + goto abort_due_to_error + } + } + goto _189 + /* Opcode: ClrSubtype P1 * * * * + ** Synopsis: r[P1].subtype = 0 + ** + ** Clear the subtype from register P1. + */ + _181: + ; /* in1 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + v191 = pIn1 + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + goto _189 + /* Opcode: GetSubtype P1 P2 * * * + ** Synopsis: r[P2] = r[P1].subtype + ** + ** Extract the subtype value from register P1 and write that subtype + ** into register P2. If P1 has no subtype, then P1 gets a NULL. + */ + _182: + ; /* in1 out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Subtype) != 0 { + _sqlite3VdbeMemSetInt64(tls, pOut, libc.Int64FromUint8((*TMem)(unsafe.Pointer(pIn1)).FeSubtype)) + } else { + _sqlite3VdbeMemSetNull(tls, pOut) + } + goto _189 + /* Opcode: SetSubtype P1 P2 * * * + ** Synopsis: r[P2].subtype = r[P1] + ** + ** Set the subtype value of register P2 to the integer from register P1. + ** If P1 is NULL, clear the subtype from p2. + */ + _183: + ; /* in1 out2 */ + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) != 0 { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) + } else { + v191 = pOut + 20 + *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Subtype)) + (*TMem)(unsafe.Pointer(pOut)).FeSubtype = libc.Uint8FromInt64(*(*Ti64)(unsafe.Pointer(pIn1)) & libc.Int64FromInt32(0xff)) + } + goto _189 + /* Opcode: FilterAdd P1 * P3 P4 * + ** Synopsis: filter(P1) += key(P3@P4) + ** + ** Compute a hash on the P4 registers starting with r[P3] and + ** add that hash to the bloom filter contained in r[P1]. + */ + _184: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + h = _filterHash(tls, aMem, pOp) + h = h % libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn*libc.Int32FromInt32(8)) + v191 = (*TMem)(unsafe.Pointer(pIn1)).Fz + uintptr(h/uint64(8)) + *(*int8)(unsafe.Pointer(v191)) = int8(int32(*(*int8)(unsafe.Pointer(v191))) | libc.Int32FromInt32(1)<<(h&libc.Uint64FromInt32(7))) + goto _189 + /* Opcode: Filter P1 P2 P3 P4 * + ** Synopsis: if key(P3@P4) not in filter(P1) goto P2 + ** + ** Compute a hash on the key contained in the P4 registers starting + ** with r[P3]. Check to see if that hash is found in the + ** bloom filter hosted by register P1. If it is not present then + ** maybe jump to P2. Otherwise fall through. + ** + ** False negatives are harmless. It is always safe to fall through, + ** even if the value is in the bloom filter. A false negative causes + ** more CPU cycles to be used, but it should still yield the correct + ** answer. However, an incorrect answer may well arise from a + ** false positive - if the jump is taken when it should fall through. + */ + _185: + ; + pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 + h1 = _filterHash(tls, aMem, pOp) + h1 = h1 % libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn*libc.Int32FromInt32(8)) + if int32(**(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pIn1)).Fz + uintptr(h1/uint64(8)))))&(int32(1)<<(h1&uint64(7))) == 0 { + **(**Tu32)(__ccgo_up(p + 212 + 8*4)) = **(**Tu32)(__ccgo_up(p + 212 + 8*4)) + 1 + goto jump_to_p2 + } else { + **(**Tu32)(__ccgo_up(p + 212 + 7*4)) = **(**Tu32)(__ccgo_up(p + 212 + 7*4)) + 1 + } + goto _189 + /* Opcode: Trace P1 P2 * P4 * + ** + ** Write P4 on the statement trace output if statement tracing is + ** enabled. + ** + ** Operand P1 must be 0x7fffffff and P2 must positive. + */ + /* Opcode: Init P1 P2 P3 P4 * + ** Synopsis: Start at P2 + ** + ** Programs contain a single instance of this opcode as the very first + ** opcode. + ** + ** If tracing is enabled (by the sqlite3_trace()) interface, then + ** the UTF-8 string contained in P4 is emitted on the trace callback. + ** Or if P4 is blank, use the string returned by sqlite3_sql(). + ** + ** If P2 is not zero, jump to instruction P2. + ** + ** Increment the value of P1 so that OP_Once opcodes will jump the + ** first time they are evaluated for this run. + ** + ** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT + ** error is encountered. + */ + _187: + ; + _186: + ; + /* If the P4 argument is not NULL, then it must be an SQL comment string. + ** The "--" string is broken up to prevent false-positives with srcck1.c. + ** + ** This assert() provides evidence for: + ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that + ** would have been returned by the legacy sqlite3_trace() interface by + ** using the X argument when X begins with "--" and invoking + ** sqlite3_expanded_sql(P) otherwise. + */ + /* OP_Init is always instruction 0 */ + if v217 = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&(libc.Int32FromInt32(SQLITE_TRACE_STMT)|libc.Int32FromInt32(SQLITE_TRACE_LEGACY)) != 0 && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat) != int32(254); v217 { + if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 { + v194 = *(*uintptr)(unsafe.Pointer(pOp + 16)) + } else { + v194 = (*TVdbe)(unsafe.Pointer(p)).FzSql + } + v191 = v194 + zTrace = v191 + } + if v217 && v191 != uintptr(0) { + if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_LEGACY) != 0 { + z2 = _sqlite3VdbeExpandSql(tls, p, zTrace) + (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).Ftrace.FxLegacy})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, z2) + Xsqlite3_free(tls, z2) + } else { + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > int32(1) { + z3 = _sqlite3MPrintf(tls, db, __ccgo_ts+6481, libc.VaList(bp+984, zTrace)) + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_STMT), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3) + _sqlite3DbFree(tls, db, z3) + } else { + (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_STMT), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace) + } + } + } + if (*TOp)(unsafe.Pointer(pOp)).Fp1 >= _sqlite3Config.FiOnceResetThreshold { + if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Trace) { + goto _189 + } + i9 = int32(1) + for { + if !(i9 < (*TVdbe)(unsafe.Pointer(p)).FnOp) { + break + } + if libc.Int32FromUint8((**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24))).Fopcode) == int32(OP_Once) { + (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24))).Fp1 = 0 + } + goto _302 + _302: + ; + i9 = i9 + 1 + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = 0 + } + (*TOp)(unsafe.Pointer(pOp)).Fp1 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + 1 + **(**Tu32)(__ccgo_up(p + 212 + 6*4)) = **(**Tu32)(__ccgo_up(p + 212 + 6*4)) + 1 + goto jump_to_p2 + /* Opcode: Noop * * * * * + ** + ** Do nothing. Continue downward to the next opcode. + */ + /* Opcode: Explain P1 P2 P3 P4 * + ** + ** This is the same as OP_Noop during normal query execution. The + ** purpose of this opcode is to hold information about the query + ** plan for the purpose of EXPLAIN QUERY PLAN output. + ** + ** The P4 value is human-readable text that describes the query plan + ** element. Something like "SCAN t1" or "SEARCH t2 USING INDEX t2x1". + ** + ** The P1 value is the ID of the current element and P2 is the parent + ** element for the case of nested query plan elements. If P2 is zero + ** then this element is a top-level element. + ** + ** For loop elements, P3 is the estimated code of each invocation of this + ** element. + ** + ** As with all opcodes, the meanings of the parameters for OP_Explain + ** are subject to change from one release to the next. Applications + ** should not attempt to interpret or use any of the information + ** contained in the OP_Explain opcode. The information provided by this + ** opcode is intended for testing and debugging use only. + */ + _188: + ; /* This is really OP_Noop, OP_Explain */ + goto _189 + /***************************************************************************** + ** The cases of the switch statement above this line should all be indented + ** by 6 spaces. But the left-most 6 spaces have been removed to improve the + ** readability. From this point on down, the normal indentation rules are + ** restored. + *****************************************************************************/ + _189: + ; + /* The following code adds nothing to the actual functionality + ** of the program. It is only here for testing and debugging. + ** On the other hand, it does burn CPU cycles every time through + ** the evaluator loop. So we can leave it out when NDEBUG is defined. + */ + goto _1 + _1: + ; + pOp += 24 + } /* The end of the for(;;) loop the loops through opcodes */ + /* If we reach this point, it means that execution is finished with + ** an error of some kind. + */ + goto abort_due_to_error +abort_due_to_error: + ; + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + rc = int32(SQLITE_NOMEM) + } else { + if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(33)< 0 { + _sqlite3ResetOneSchema(tls, db, libc.Int32FromUint8(resetSchemaOnFault)-int32(1)) + } + /* This is the only way out of this procedure. We have to + ** release the mutexes on btrees that were acquired at the + ** top. */ + goto vdbe_return +vdbe_return: + ; + for nVmStep >= nProgressLimit && (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0) { + nProgressLimit = nProgressLimit + uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { + nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)<aVar[]. Then render +// ** the value as a literal in place of the host parameter name. +// */ +func _sqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) (r uintptr) { + bp := tls.Alloc(128) + defer tls.Free(128) + var db, pVar, zStart, v1 uintptr + var enc Tu8 + var i, nOut, nOut1, nextIndex, v2 int32 + var n Ti64 + var _ /* idx at bp+0 */ int32 + var _ /* nToken at bp+8 */ Ti64 + var _ /* out at bp+16 */ TStrAccum + var _ /* utf8 at bp+48 */ TMem + _, _, _, _, _, _, _, _, _, _, _ = db, enc, i, n, nOut, nOut1, nextIndex, pVar, zStart, v1, v2 /* The database connection */ + **(**int32)(__ccgo_up(bp)) = 0 /* Index of a host parameter */ + nextIndex = int32(1) /* Used to convert UTF16 into UTF8 for display */ + db = (*TVdbe)(unsafe.Pointer(p)).Fdb + _sqlite3StrAccumInit(tls, bp+16, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up(db + 136))) + if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > int32(1) { + for **(**int8)(__ccgo_up(zRawSql)) != 0 { + zStart = zRawSql + for { + v1 = zRawSql + zRawSql = zRawSql + 1 + if !(int32(**(**int8)(__ccgo_up(v1))) != int32('\n') && **(**int8)(__ccgo_up(zRawSql)) != 0) { + break + } + } + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+5713, int32(3)) + Xsqlite3_str_append(tls, bp+16, zStart, int32(int64(zRawSql)-int64(zStart))) + } + } else { + if int32((*TVdbe)(unsafe.Pointer(p)).FnVar) == 0 { + Xsqlite3_str_append(tls, bp+16, zRawSql, _sqlite3Strlen30(tls, zRawSql)) + } else { + for **(**int8)(__ccgo_up(zRawSql)) != 0 { + n = _findNextHostParameter(tls, zRawSql, bp+8) + Xsqlite3_str_append(tls, bp+16, zRawSql, int32(n)) + zRawSql = zRawSql + uintptr(n) + if **(**Ti64)(__ccgo_up(bp + 8)) == 0 { + break + } + if int32(**(**int8)(__ccgo_up(zRawSql))) == int32('?') { + if **(**Ti64)(__ccgo_up(bp + 8)) > int64(1) { + _sqlite3GetInt32(tls, zRawSql+1, bp) + } else { + **(**int32)(__ccgo_up(bp)) = nextIndex + } + } else { + **(**int32)(__ccgo_up(bp)) = _sqlite3VdbeParameterIndex(tls, p, zRawSql, int32(**(**Ti64)(__ccgo_up(bp + 8)))) + } + zRawSql = zRawSql + uintptr(**(**Ti64)(__ccgo_up(bp + 8))) + if **(**int32)(__ccgo_up(bp))+int32(1) > nextIndex { + v2 = **(**int32)(__ccgo_up(bp)) + int32(1) + } else { + v2 = nextIndex + } + nextIndex = v2 + pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr(**(**int32)(__ccgo_up(bp))-int32(1))*56 + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Null) != 0 { + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+1705, int32(4)) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+1465, libc.VaList(bp+112, *(*Ti64)(unsafe.Pointer(pVar)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Real) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+5717, libc.VaList(bp+112, *(*float64)(unsafe.Pointer(pVar)))) + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Str) != 0 { /* Number of bytes of the string text to include in output */ + enc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) { + libc.Xmemset(tls, bp+48, 0, uint64(56)) + (**(**TMem)(__ccgo_up(bp + 48))).Fdb = db + _sqlite3VdbeMemSetStr(tls, bp+48, (*TMem)(unsafe.Pointer(pVar)).Fz, int64((*TMem)(unsafe.Pointer(pVar)).Fn), enc, libc.UintptrFromInt32(0)) + if int32(SQLITE_NOMEM) == _sqlite3VdbeChangeEncoding(tls, bp+48, int32(SQLITE_UTF8)) { + (**(**TStrAccum)(__ccgo_up(bp + 16))).FaccError = uint8(SQLITE_NOMEM) + (**(**TStrAccum)(__ccgo_up(bp + 16))).FnAlloc = uint32(0) + } + pVar = bp + 48 + } + nOut = (*TMem)(unsafe.Pointer(pVar)).Fn + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+5724, libc.VaList(bp+112, nOut, (*TMem)(unsafe.Pointer(pVar)).Fz)) + if libc.Int32FromUint8(enc) != int32(SQLITE_UTF8) { + _sqlite3VdbeMemRelease(tls, bp+48) + } + } else { + if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pVar)).Fflags)&int32(MEM_Zero) != 0 { + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+5731, libc.VaList(bp+112, *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pVar)).Fu)))) + } else { /* Number of bytes of the blob to include in output */ + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+5744, int32(2)) + nOut1 = (*TMem)(unsafe.Pointer(pVar)).Fn + i = 0 + for { + if !(i < nOut1) { + break + } + Xsqlite3_str_appendf(tls, bp+16, __ccgo_ts+5747, libc.VaList(bp+112, int32(**(**int8)(__ccgo_up((*TMem)(unsafe.Pointer(pVar)).Fz + uintptr(i))))&int32(0xff))) + goto _3 + _3: + ; + i = i + 1 + } + Xsqlite3_str_append(tls, bp+16, __ccgo_ts+5752, int32(1)) + } + } + } + } + } + } + } + } + if (**(**TStrAccum)(__ccgo_up(bp + 16))).FaccError != 0 { + Xsqlite3_str_reset(tls, bp+16) + } + return _sqlite3StrAccumFinish(tls, bp+16) +} + +/************** End of vdbetrace.c *******************************************/ +/************** Begin file vdbe.c ********************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** The code in this file implements the function that runs the +** bytecode of a prepared statement. +** +** Various scripts scan this source file in order to generate HTML +** documentation, headers files, or other derived files. The formatting +** of the code in this file is, therefore, important. See other comments +** in this file for details. If in doubt, do not deviate from existing +** commenting and indentation practices when changing or adding code. + */ +/* #include "sqliteInt.h" */ +/* #include "vdbeInt.h" */ + +/* +** High-resolution hardware timer used for debugging and testing only. + */ + +/* +** Invoke this macro on memory cells just prior to changing the +** value of the cell. This macro verifies that shallow copies are +** not misused. A shallow copy of a string or blob just copies a +** pointer to the string or blob, not the content. If the original +** is changed while the copy is still in use, the string or blob might +** be changed out from under the copy. This macro verifies that nothing +** like that ever happens. + */ + +/* +** The following global variable is incremented every time a cursor +** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test +** procedures use this information to make sure that indices are +** working correctly. This variable has no function other than to +** help verify the correct operation of the library. + */ + +/* +** When this global variable is positive, it gets decremented once before +** each instruction in the VDBE. When it reaches zero, the u1.isInterrupted +** field of the sqlite3 structure is set in order to simulate an interrupt. +** +** This facility is used for testing purposes only. It does not function +** in an ordinary build. + */ + +/* +** The next global variable is incremented each type the OP_Sort opcode +** is executed. The test procedures use this information to make sure that +** sorting is occurring or not occurring at appropriate times. This variable +** has no function other than to help verify the correct operation of the +** library. + */ + +/* +** The next global variable records the size of the largest MEM_Blob +** or MEM_Str that has been used by a VDBE opcode. The test procedures +** use this information to make sure that the zero-blob functionality +** is working correctly. This variable has no function other than to +** help verify the correct operation of the library. + */ + +/* +** This macro evaluates to true if either the update hook or the preupdate +** hook are enabled for database connect DB. + */ + +/* +** The next global variable is incremented each time the OP_Found opcode +** is executed. This is used to test whether or not the foreign key +** operation implemented using OP_FkIsZero is working. This variable +** has no function other than to help verify the correct operation of the +** library. + */ + +/* +** Test a register to see if it exceeds the current maximum blob size. +** If it does, record the new maximum blob size. + */ + +/* +** Invoke the VDBE coverage callback, if that callback is defined. This +** feature is used for test suite validation only and does not appear an +** production builds. +** +** M is the type of branch. I is the direction taken for this instance of +** the branch. +** +** M: 2 - two-way branch (I=0: fall-thru 1: jump ) +** 3 - two-way + NULL (I=0: fall-thru 1: jump 2: NULL ) +** 4 - OP_Jump (I=0: jump p1 1: jump p2 2: jump p3) +** +** In other words, if M is 2, then I is either 0 (for fall-through) or +** 1 (for when the branch is taken). If M is 3, the I is 0 for an +** ordinary fall-through, I is 1 if the branch was taken, and I is 2 +** if the result of comparison is NULL. For M=3, I=2 the jump may or +** may not be taken, depending on the SQLITE_JUMPIFNULL flags in p5. +** When M is 4, that means that an OP_Jump is being run. I is 0, 1, or 2 +** depending on if the operands are less than, equal, or greater than. +** +** iSrcLine is the source code line (from the __LINE__ macro) that +** generated the VDBE instruction combined with flag bits. The source +** code line number is in the lower 24 bits of iSrcLine and the upper +** 8 bytes are flags. The lower three bits of the flags indicate +** values for I that should never occur. For example, if the branch is +** always taken, the flags should be 0x05 since the fall-through and +** alternate branch are never taken. If a branch is never taken then +** flags should be 0x06 since only the fall-through approach is allowed. +** +** Bit 0x08 of the flags indicates an OP_Jump opcode that is only +** interested in equal or not-equal. In other words, I==0 and I==2 +** should be treated as equivalent +** +** Since only a line number is retained, not the filename, this macro +** only works for amalgamation builds. But that is ok, since these macros +** should be no-ops except for special builds used to measure test coverage. + */ + +/* +** An ephemeral string value (signified by the MEM_Ephem flag) contains +** a pointer to a dynamically allocated string where some other entity +** is responsible for deallocating that string. Because the register +** does not control the string, it might be deleted without the register +** knowing it. +** +** This routine converts an ephemeral string into a dynamically allocated +** string that the register itself controls. In other words, it +** converts an MEM_Ephem string into a string with P.z==P.zMalloc. + */ + +/* Return true if the cursor was opened using the OP_OpenSorter opcode. */ + +// C documentation +// +// /* +// ** Send a "statement aborts" message to the error log. +// */ +func _sqlite3VdbeLogAbort(tls *libc.TLS, p uintptr, rc int32, pOp uintptr, aOp uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var pc int32 + var zPrefix, zSql uintptr + var _ /* zXtra at bp+0 */ [100]int8 + _, _, _ = pc, zPrefix, zSql + zSql = (*TVdbe)(unsafe.Pointer(p)).FzSql /* Original SQL text */ + zPrefix = __ccgo_ts + 1704 /* Buffer space to store zPrefix */ + if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { + if *(*uintptr)(unsafe.Pointer(aOp + 16)) != uintptr(0) { + Xsqlite3_snprintf(tls, int32(100), bp, __ccgo_ts+5754, libc.VaList(bp+112, *(*uintptr)(unsafe.Pointer(aOp + 16))+uintptr(3))) + zPrefix = bp + } else { + zPrefix = __ccgo_ts + 5764 + } + } + pc = int32((int64(pOp) - int64(aOp)) / 24) + Xsqlite3_log(tls, rc, __ccgo_ts+5787, libc.VaList(bp+112, pc, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, zPrefix, zSql)) +} + +// C documentation +// +// /* +// ** This function sets the P4 value of an existing OP_Explain opcode to +// ** text describing the loop in pLevel. If the OP_Explain opcode already has +// ** a P4 value, it is freed before it is overwritten. +// */ +func _sqlite3WhereAddExplainText(tls *libc.TLS, pParse uintptr, addr int32, pTabList uintptr, pLevel uintptr, wctrlFlags Tu16) { + bp := tls.Alloc(176) + defer tls.Free(176) + var cRangeOp int8 + var db, pIdx, pItem, pLoop, pOp, zFmt, zRowid, v1, v2 uintptr + var flags Tu32 + var isSearch int32 + var _ /* str at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [100]int8 + _, _, _, _, _, _, _, _, _, _, _, _ = cRangeOp, db, flags, isSearch, pIdx, pItem, pLoop, pOp, zFmt, zRowid, v1, v2 + if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 { + v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel + } else { + v1 = pParse + } + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(v1)).Fexplain) == int32(2) || libc.Bool(0 != 0) { + pOp = _sqlite3VdbeGetOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, addr) + pItem = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Initial space for EQP output string */ + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + return + } + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + flags = (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags + isSearch = libc.BoolInt32(flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_BTM_LIMIT)|libc.Int32FromInt32(WHERE_TOP_LIMIT)) != uint32(0) || flags&uint32(WHERE_VIRTUALTABLE) == uint32(0) && libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq) > 0 || libc.Int32FromUint16(wctrlFlags)&(libc.Int32FromInt32(WHERE_ORDERBY_MIN)|libc.Int32FromInt32(WHERE_ORDERBY_MAX)) != 0) + _sqlite3StrAccumInit(tls, bp, db, bp+32, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TStrAccum)(__ccgo_up(bp))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + if isSearch != 0 { + v1 = __ccgo_ts + 23588 + } else { + v1 = __ccgo_ts + 23595 + } + if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x40000>>18) != 0 { + v2 = __ccgo_ts + 23600 + } else { + v2 = __ccgo_ts + 1704 + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23608, libc.VaList(bp+144, v1, pItem, v2)) + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_VIRTUALTABLE)) == uint32(0) { + zFmt = uintptr(0) + pIdx = (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex + if !((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { + if isSearch != 0 { + zFmt = __ccgo_ts + 11592 + } + } else { + if flags&uint32(WHERE_PARTIALIDX) != 0 { + zFmt = __ccgo_ts + 23616 + } else { + if flags&uint32(WHERE_AUTO_INDEX) != 0 { + zFmt = __ccgo_ts + 23649 + } else { + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY)|libc.Int32FromInt32(WHERE_EXPRIDX)) != 0 { + zFmt = __ccgo_ts + 23674 + } else { + zFmt = __ccgo_ts + 23692 + } + } + } + } + if zFmt != 0 { + Xsqlite3_str_append(tls, bp, __ccgo_ts+23701, int32(7)) + Xsqlite3_str_appendf(tls, bp, zFmt, libc.VaList(bp+144, (*TIndex)(unsafe.Pointer(pIdx)).FzName)) + _explainIndexRange(tls, bp, pLoop) + } + } else { + if flags&uint32(WHERE_IPK) != uint32(0) && flags&uint32(WHERE_CONSTRAINT) != uint32(0) { + zRowid = __ccgo_ts + 17963 + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23709, libc.VaList(bp+144, zRowid)) + if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_EQ)|libc.Int32FromInt32(WHERE_COLUMN_IN)) != 0 { + cRangeOp = int8('=') + } else { + if flags&uint32(WHERE_BOTH_LIMIT) == uint32(WHERE_BOTH_LIMIT) { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23740, libc.VaList(bp+144, zRowid)) + cRangeOp = int8('<') + } else { + if flags&uint32(WHERE_BTM_LIMIT) != 0 { + cRangeOp = int8('>') + } else { + cRangeOp = int8('<') + } + } + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23750, libc.VaList(bp+144, int32(cRangeOp))) + } else { + if flags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { + Xsqlite3_str_appendall(tls, bp, __ccgo_ts+23755) + if int32(Tu32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x4>>2)) != 0 { + v1 = __ccgo_ts + 23777 + } else { + v1 = __ccgo_ts + 23785 + } + Xsqlite3_str_appendf(tls, bp, v1, libc.VaList(bp+144, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxNum, (*(*struct { + FidxNum int32 + F__ccgo4 uint8 + FisOrdered Ti8 + FomitMask Tu16 + FidxStr uintptr + FmHandleIn Tu32 + })(unsafe.Pointer(pLoop + 24))).FidxStr)) + } + } + } + if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23791, 0) + } + _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16))) + (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) + *(*uintptr)(unsafe.Pointer(pOp + 16)) = _sqlite3StrAccumFinish(tls, bp) + } +} + +// C documentation +// +// /* +// ** Add a single OP_Explain opcode that describes a Bloom filter. +// ** +// ** Or if not processing EXPLAIN QUERY PLAN and not in a SQLITE_DEBUG and/or +// ** SQLITE_ENABLE_STMT_SCANSTATUS build, then OP_Explain opcodes are not +// ** required and this routine is a no-op. +// ** +// ** If an OP_Explain opcode is added to the VM, its address is returned. +// ** Otherwise, if no OP_Explain is coded, zero is returned. +// */ +func _sqlite3WhereExplainBloomFilter(tls *libc.TLS, pParse uintptr, pWInfo uintptr, pLevel uintptr) (r int32) { + bp := tls.Alloc(160) + defer tls.Free(160) + var db, pItem, pLoop, pTab, v, z, zMsg uintptr + var i, ret int32 + var _ /* str at bp+0 */ TStrAccum + var _ /* zBuf at bp+32 */ [100]int8 + _, _, _, _, _, _, _, _, _ = db, i, pItem, pLoop, pTab, ret, v, z, zMsg + ret = 0 + pItem = (*TWhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 + v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* VM being constructed */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Initial space for EQP output string */ + _sqlite3StrAccumInit(tls, bp, db, bp+32, int32(100), int32(SQLITE_MAX_LENGTH)) + (**(**TStrAccum)(__ccgo_up(bp))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23802, libc.VaList(bp+144, pItem)) + pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop + if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_IPK) != 0 { + pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab + if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) >= 0 { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23571, libc.VaList(bp+144, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TTable)(unsafe.Pointer(pTab)).FiPKey)*16))).FzCnName)) + } else { + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23823, 0) + } + } else { + i = libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) + for { + if !(i < libc.Int32FromUint16((*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FnEq)) { + break + } + z = _explainIndexColumnName(tls, (*(*struct { + FnEq Tu16 + FnBtm Tu16 + FnTop Tu16 + FnDistinctCol Tu16 + FpIndex uintptr + FpOrderBy uintptr + })(unsafe.Pointer(pLoop + 24))).FpIndex, i) + if i > libc.Int32FromUint16((*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip) { + Xsqlite3_str_append(tls, bp, __ccgo_ts+23560, int32(5)) + } + Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23571, libc.VaList(bp+144, z)) + goto _1 + _1: + ; + i = i + 1 + } + } + Xsqlite3_str_append(tls, bp, __ccgo_ts+5257, int32(1)) + zMsg = _sqlite3StrAccumFinish(tls, bp) + ret = _sqlite3VdbeAddOp4(tls, v, int32(OP_Explain), _sqlite3VdbeCurrentAddr(tls, v), (*TParse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -int32(7)) + return ret +} + +// C documentation +// +// /* +// ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) +// ** +// ** Return a string described by FORMAT. Conversions as follows: +// ** +// ** %d day of month 01-31 +// ** %e day of month 1-31 +// ** %f ** fractional seconds SS.SSS +// ** %F ISO date. YYYY-MM-DD +// ** %G ISO year corresponding to %V 0000-9999. +// ** %g 2-digit ISO year corresponding to %V 00-99 +// ** %H hour 00-24 +// ** %k hour 0-24 (leading zero converted to space) +// ** %I hour 01-12 +// ** %j day of year 001-366 +// ** %J ** julian day number +// ** %l hour 1-12 (leading zero converted to space) +// ** %m month 01-12 +// ** %M minute 00-59 +// ** %p "AM" or "PM" +// ** %P "am" or "pm" +// ** %R time as HH:MM +// ** %s seconds since 1970-01-01 +// ** %S seconds 00-59 +// ** %T time as HH:MM:SS +// ** %u day of week 1-7 Monday==1, Sunday==7 +// ** %w day of week 0-6 Sunday==0, Monday==1 +// ** %U week of year 00-53 (First Sunday is start of week 01) +// ** %V week of year 01-53 (First week containing Thursday is week 01) +// ** %W week of year 00-53 (First Monday is start of week 01) +// ** %Y year 0000-9999 +// ** %% % +// */ +func _strftimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(208) + defer tls.Free(208) + var c, cf int8 + var db, zFmt, v3 uintptr + var h int32 + var i, j, v2 Tsize_t + var iS Ti64 + var s float64 + var _ /* sRes at bp+48 */ Tsqlite3_str + var _ /* x at bp+0 */ TDateTime + var _ /* y at bp+128 */ TDateTime + var _ /* y at bp+80 */ TDateTime + _, _, _, _, _, _, _, _, _, _, _ = c, cf, db, h, i, iS, j, s, zFmt, v2, v3 + if argc == 0 { + return + } + zFmt = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zFmt == uintptr(0) || _isDate(tls, context, argc-int32(1), argv+uintptr(1)*8, bp) != 0 { + return + } + db = Xsqlite3_context_db_handle(tls, context) + _sqlite3StrAccumInit(tls, bp+48, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up(db + 136))) + _computeJD(tls, bp) + _computeYMD_HMS(tls, bp) + v2 = libc.Uint64FromInt32(0) + j = v2 + i = v2 + for { + if !(**(**int8)(__ccgo_up(zFmt + uintptr(i))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(zFmt + uintptr(i)))) != int32('%') { + goto _1 + } + if j < i { + Xsqlite3_str_append(tls, bp+48, zFmt+uintptr(j), libc.Int32FromUint64(i-j)) + } + i = i + 1 + j = i + uint64(1) + cf = **(**int8)(__ccgo_up(zFmt + uintptr(i))) + switch int32(cf) { + case int32('d'): /* Fall thru */ + fallthrough + case int32('e'): + if int32(cf) == int32('d') { + v3 = __ccgo_ts + 1391 + } else { + v3 = __ccgo_ts + 1396 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FD)) + case int32('f'): /* Fractional seconds. (Non-standard) */ + s = (**(**TDateTime)(__ccgo_up(bp))).Fs + if s > float64(59.999) { + s = float64(59.999) + } + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1400, libc.VaList(bp+184, s)) + case int32('F'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1407, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FY, (**(**TDateTime)(__ccgo_up(bp))).FM, (**(**TDateTime)(__ccgo_up(bp))).FD)) + case int32('G'): /* Fall thru */ + fallthrough + case int32('g'): + **(**TDateTime)(__ccgo_up(bp + 80)) = **(**TDateTime)(__ccgo_up(bp)) + /* Move y so that it is the Thursday in the same week as x */ + (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD += int64((int32(3) - _daysAfterMonday(tls, bp)) * int32(86400000)) + (**(**TDateTime)(__ccgo_up(bp + 80))).FvalidYMD = 0 + _computeYMD(tls, bp+80) + if int32(cf) == int32('g') { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp + 80))).FY%int32(100))) + } else { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1422, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp + 80))).FY)) + } + case int32('H'): + fallthrough + case int32('k'): + if int32(cf) == int32('H') { + v3 = __ccgo_ts + 1391 + } else { + v3 = __ccgo_ts + 1396 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh)) + case int32('I'): /* Fall thru */ + fallthrough + case int32('l'): + h = (**(**TDateTime)(__ccgo_up(bp))).Fh + if h > int32(12) { + h = h - int32(12) + } + if h == 0 { + h = int32(12) + } + if int32(cf) == int32('I') { + v3 = __ccgo_ts + 1391 + } else { + v3 = __ccgo_ts + 1396 + } + Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, h)) + case int32('j'): /* Day of year. Jan01==1, Jan02==2, and so forth */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1427, libc.VaList(bp+184, _daysAfterJan01(tls, bp)+int32(1))) + case int32('J'): /* Julian day number. (Non-standard) */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1432, libc.VaList(bp+184, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD)/float64(8.64e+07))) + case int32('m'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FM)) + case int32('M'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fm)) + case int32('p'): /* Fall thru */ + fallthrough + case int32('P'): + if (**(**TDateTime)(__ccgo_up(bp))).Fh >= int32(12) { + if int32(cf) == int32('p') { + v3 = __ccgo_ts + 1438 + } else { + v3 = __ccgo_ts + 1441 + } + Xsqlite3_str_append(tls, bp+48, v3, int32(2)) + } else { + if int32(cf) == int32('p') { + v3 = __ccgo_ts + 1444 + } else { + v3 = __ccgo_ts + 1447 + } + Xsqlite3_str_append(tls, bp+48, v3, int32(2)) + } + case int32('R'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1450, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm)) + case int32('s'): + if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1460, libc.VaList(bp+184, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD-libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000000))/float64(1000))) + } else { + iS = (**(**TDateTime)(__ccgo_up(bp))).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000) + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1465, libc.VaList(bp+184, iS)) + } + case int32('S'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, int32((**(**TDateTime)(__ccgo_up(bp))).Fs))) + case int32('T'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1470, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm, int32((**(**TDateTime)(__ccgo_up(bp))).Fs))) + case int32('u'): /* Day of week. 1 to 7. Monday==1, Sunday==7 */ + fallthrough + case int32('w'): /* Day of week. 0 to 6. Sunday==0, Monday==1 */ + c = int8(int32(int8(_daysAfterSunday(tls, bp))) + int32('0')) + if int32(c) == int32('0') && int32(cf) == int32('u') { + c = int8('7') + } + Xsqlite3_str_appendchar(tls, bp+48, int32(1), c) + case int32('U'): /* Week num. 00-53. First Sun of the year is week 01 */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (_daysAfterJan01(tls, bp)-_daysAfterSunday(tls, bp)+int32(7))/int32(7))) + case int32('V'): /* Week num. 01-53. First week with a Thur is week 01 */ + **(**TDateTime)(__ccgo_up(bp + 128)) = **(**TDateTime)(__ccgo_up(bp)) + /* Adjust y so that is the Thursday in the same week as x */ + (**(**TDateTime)(__ccgo_up(bp + 128))).FiJD += int64((int32(3) - _daysAfterMonday(tls, bp)) * int32(86400000)) + (**(**TDateTime)(__ccgo_up(bp + 128))).FvalidYMD = 0 + _computeYMD(tls, bp+128) + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, _daysAfterJan01(tls, bp+128)/int32(7)+int32(1))) + case int32('W'): /* Week num. 00-53. First Mon of the year is week 01 */ + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (_daysAfterJan01(tls, bp)-_daysAfterMonday(tls, bp)+int32(7))/int32(7))) + case int32('Y'): + Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1422, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FY)) + case int32('%'): + Xsqlite3_str_appendchar(tls, bp+48, int32(1), int8('%')) + default: + Xsqlite3_str_reset(tls, bp+48) + return + } + goto _1 + _1: + ; + i = i + 1 + } + if j < i { + Xsqlite3_str_append(tls, bp+48, zFmt+uintptr(j), libc.Int32FromUint64(i-j)) + } + _sqlite3ResultStrAccum(tls, context, bp+48) +} + +// C documentation +// +// /* +// ** timediff(DATE1, DATE2) +// ** +// ** Return the amount of time that must be added to DATE2 in order to +// ** convert it into DATE2. The time difference format is: +// ** +// ** +YYYY-MM-DD HH:MM:SS.SSS +// ** +// ** The initial "+" becomes "-" if DATE1 occurs before DATE2. For +// ** date/time values A and B, the following invariant should hold: +// ** +// ** datetime(A) == (datetime(B, timediff(A,B)) +// ** +// ** Both DATE arguments must be either a julian day number, or an +// ** ISO-8601 string. The unix timestamps are not supported by this +// ** routine. +// */ +func _timediffFunc(tls *libc.TLS, context uintptr, NotUsed1 int32, argv uintptr) { + bp := tls.Alloc(192) + defer tls.Free(192) + var M, Y int32 + var sign int8 + var v1 uintptr + var _ /* d1 at bp+0 */ TDateTime + var _ /* d2 at bp+48 */ TDateTime + var _ /* sRes at bp+96 */ Tsqlite3_str + _, _, _, _ = M, Y, sign, v1 + _ = NotUsed1 + if _isDate(tls, context, int32(1), argv, bp) != 0 { + return + } + if _isDate(tls, context, int32(1), argv+1*8, bp+48) != 0 { + return + } + _computeYMD_HMS(tls, bp) + _computeYMD_HMS(tls, bp+48) + if (**(**TDateTime)(__ccgo_up(bp))).FiJD >= (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + sign = int8('+') + Y = (**(**TDateTime)(__ccgo_up(bp))).FY - (**(**TDateTime)(__ccgo_up(bp + 48))).FY + if Y != 0 { + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp))).FY + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = 0 + _computeJD(tls, bp+48) + } + M = (**(**TDateTime)(__ccgo_up(bp))).FM - (**(**TDateTime)(__ccgo_up(bp + 48))).FM + if M < 0 { + Y = Y - 1 + M = M + int32(12) + } + if M != 0 { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp))).FM + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = 0 + _computeJD(tls, bp+48) + } + for (**(**TDateTime)(__ccgo_up(bp))).FiJD < (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + M = M - 1 + if M < 0 { + M = int32(11) + Y = Y - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp + 48))).FM - 1 + if (**(**TDateTime)(__ccgo_up(bp + 48))).FM < int32(1) { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = int32(12) + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp + 48))).FY - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = 0 + _computeJD(tls, bp+48) + } + (**(**TDateTime)(__ccgo_up(bp))).FiJD -= (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD + v1 = bp + *(*Tsqlite3_int64)(unsafe.Pointer(v1)) = Tsqlite3_int64(uint64(*(*Tsqlite3_int64)(unsafe.Pointer(v1))) + libc.Uint64FromInt32(1486995408)*libc.Uint64FromInt32(100000)) + } else { /* d1 (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD { + M = M - 1 + if M < 0 { + M = int32(11) + Y = Y - 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = (**(**TDateTime)(__ccgo_up(bp + 48))).FM + 1 + if (**(**TDateTime)(__ccgo_up(bp + 48))).FM > int32(12) { + (**(**TDateTime)(__ccgo_up(bp + 48))).FM = int32(1) + (**(**TDateTime)(__ccgo_up(bp + 48))).FY = (**(**TDateTime)(__ccgo_up(bp + 48))).FY + 1 + } + (**(**TDateTime)(__ccgo_up(bp + 48))).FvalidJD = 0 + _computeJD(tls, bp+48) + } + (**(**TDateTime)(__ccgo_up(bp))).FiJD = (**(**TDateTime)(__ccgo_up(bp + 48))).FiJD - (**(**TDateTime)(__ccgo_up(bp))).FiJD + v1 = bp + *(*Tsqlite3_int64)(unsafe.Pointer(v1)) = Tsqlite3_int64(uint64(*(*Tsqlite3_int64)(unsafe.Pointer(v1))) + libc.Uint64FromInt32(1486995408)*libc.Uint64FromInt32(100000)) + } + _clearYMD_HMS_TZ(tls, bp) + _computeYMD_HMS(tls, bp) + _sqlite3StrAccumInit(tls, bp+96, uintptr(0), uintptr(0), 0, int32(100)) + Xsqlite3_str_appendf(tls, bp+96, __ccgo_ts+1485, libc.VaList(bp+136, int32(sign), Y, M, (**(**TDateTime)(__ccgo_up(bp))).FD-int32(1), (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm, (**(**TDateTime)(__ccgo_up(bp))).Fs)) + _sqlite3ResultStrAccum(tls, context, bp+96) +} + +// C documentation +// +// /* +// ** Assuming the input DateTime is UTC, move it to its localtime equivalent. +// */ +func _toLocaltime(tls *libc.TLS, p uintptr, pCtx uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var iYearDiff int32 + var _ /* sLocal at bp+8 */ Ttm + var _ /* t at bp+0 */ Ttime_t + var _ /* x at bp+64 */ TDateTime + _ = iYearDiff + /* Initialize the contents of sLocal to avoid a compiler warning. */ + libc.Xmemset(tls, bp+8, 0, uint64(56)) + _computeJD(tls, p) + if (*TDateTime)(unsafe.Pointer(p)).FiJD < libc.Int64FromInt32(2108667600)*libc.Int64FromInt32(100000) || (*TDateTime)(unsafe.Pointer(p)).FiJD > libc.Int64FromInt32(2130141456)*libc.Int64FromInt32(100000) { + /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only + ** works for years between 1970 and 2037. For dates outside this range, + ** SQLite attempts to map the year into an equivalent year within this + ** range, do the calculation, then map the year back. + */ + **(**TDateTime)(__ccgo_up(bp + 64)) = **(**TDateTime)(__ccgo_up(p)) + _computeYMD_HMS(tls, bp+64) + iYearDiff = int32(2000) + (**(**TDateTime)(__ccgo_up(bp + 64))).FY%int32(4) - (**(**TDateTime)(__ccgo_up(bp + 64))).FY + (**(**TDateTime)(__ccgo_up(bp + 64))).FY += iYearDiff + (**(**TDateTime)(__ccgo_up(bp + 64))).FvalidJD = 0 + _computeJD(tls, bp+64) + **(**Ttime_t)(__ccgo_up(bp)) = int64((**(**TDateTime)(__ccgo_up(bp + 64))).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) + } else { + iYearDiff = 0 + **(**Ttime_t)(__ccgo_up(bp)) = int64((*TDateTime)(unsafe.Pointer(p)).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) + } + if _osLocaltime(tls, bp, bp+8) != 0 { + Xsqlite3_result_error(tls, pCtx, __ccgo_ts+1249, -int32(1)) + return int32(SQLITE_ERROR) + } + (*TDateTime)(unsafe.Pointer(p)).FY = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_year + int32(1900) - iYearDiff + (*TDateTime)(unsafe.Pointer(p)).FM = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_mon + int32(1) + (*TDateTime)(unsafe.Pointer(p)).FD = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_mday + (*TDateTime)(unsafe.Pointer(p)).Fh = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_hour + (*TDateTime)(unsafe.Pointer(p)).Fm = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_min + (*TDateTime)(unsafe.Pointer(p)).Fs = float64((**(**Ttm)(__ccgo_up(bp + 8))).Ftm_sec) + float64(float64((*TDateTime)(unsafe.Pointer(p)).FiJD%libc.Int64FromInt32(1000))*float64(0.001)) + (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = int8(1) + (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = int8(1) + (*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) + (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 + libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 1, 0x2) + return SQLITE_OK +} + +// C documentation +// +// /* +// ** Implementation of the UNISTR() function. +// ** +// ** This is intended to be a work-alike of the UNISTR() function in +// ** PostgreSQL. Quoting from the PG documentation (PostgreSQL 17 - +// ** scraped on 2025-02-22): +// ** +// ** Evaluate escaped Unicode characters in the argument. Unicode +// ** characters can be specified as \XXXX (4 hexadecimal digits), +// ** \+XXXXXX (6 hexadecimal digits), \uXXXX (4 hexadecimal digits), +// ** or \UXXXXXXXX (8 hexadecimal digits). To specify a backslash, +// ** write two backslashes. All other characters are taken literally. +// */ +func _unistrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j, n, nIn, v1 int32 + var z, zIn, zOut uintptr + var _ /* v at bp+0 */ Tu32 + _, _, _, _, _, _, _, _ = i, j, n, nIn, z, zIn, zOut, v1 + _ = argc + zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) + if zIn == uintptr(0) { + return + } + nIn = Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(argv))) + zOut = Xsqlite3_malloc64(tls, libc.Uint64FromInt32(nIn+int32(1))) + if zOut == uintptr(0) { + Xsqlite3_result_error_nomem(tls, context) + return + } + v1 = libc.Int32FromInt32(0) + j = v1 + i = v1 + for i < nIn { + z = libc.Xstrchr(tls, zIn+uintptr(i), int32('\\')) + if z == uintptr(0) { + n = nIn - i + libc.Xmemmove(tls, zOut+uintptr(j), zIn+uintptr(i), libc.Uint64FromInt32(n)) + j = j + n + break + } + n = int32(int64(z) - t__predefined_ptrdiff_t(zIn+uintptr(i))) + if n > 0 { + libc.Xmemmove(tls, zOut+uintptr(j), zIn+uintptr(i), libc.Uint64FromInt32(n)) + j = j + n + i = i + n + } + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('\\') { + i = i + int32(2) + v1 = j + j = j + 1 + **(**int8)(__ccgo_up(zOut + uintptr(v1))) = int8('\\') + } else { + if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1)))))])&int32(0x08) != 0 { + if !(_isNHex(tls, zIn+uintptr(i+int32(1)), int32(4), bp) != 0) { + goto unistr_error + } + i = i + int32(5) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('+') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(6), bp) != 0) { + goto unistr_error + } + i = i + int32(8) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('u') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(4), bp) != 0) { + goto unistr_error + } + i = i + int32(6) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + if int32(**(**int8)(__ccgo_up(zIn + uintptr(i+int32(1))))) == int32('U') { + if !(_isNHex(tls, zIn+uintptr(i+int32(2)), int32(8), bp) != 0) { + goto unistr_error + } + i = i + int32(10) + j = j + _sqlite3AppendOneUtf8Character(tls, zOut+uintptr(j), **(**Tu32)(__ccgo_up(bp))) + } else { + goto unistr_error + } + } + } + } + } + } + **(**int8)(__ccgo_up(zOut + uintptr(j))) = 0 + Xsqlite3_result_text64(tls, context, zOut, libc.Uint64FromInt32(j), __ccgo_fp(Xsqlite3_free), uint8(SQLITE_UTF8_ZT)) + return + goto unistr_error +unistr_error: + ; + Xsqlite3_free(tls, zOut) + Xsqlite3_result_error(tls, context, __ccgo_ts+16571, -int32(1)) + return +} + +// C documentation +// +// /* +// ** Turn a relative pathname into a full pathname. The relative path +// ** is stored as a nul-terminated string in the buffer pointed to by +// ** zPath. +// ** +// ** zOut points to a buffer of at least sqlite3_vfs.mxPathname bytes +// ** (in this case, MAX_PATHNAME bytes). The full-path is written to +// ** this buffer before returning. +// */ +func _unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) (r int32) { + bp := tls.Alloc(4128) + defer tls.Free(4128) + var _ /* path at bp+0 */ TDbPath + var _ /* zPwd at bp+24 */ [4098]int8 + _ = pVfs + (**(**TDbPath)(__ccgo_up(bp))).Frc = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnUsed = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnSymlink = 0 + (**(**TDbPath)(__ccgo_up(bp))).FnOut = nOut + (**(**TDbPath)(__ccgo_up(bp))).FzOut = zOut + if int32(**(**int8)(__ccgo_up(zPath))) != int32('/') { + if (*(*func(*libc.TLS, uintptr, Tsize_t) uintptr)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(3)].FpCurrent})))(tls, bp+24, libc.Uint64FromInt64(4098)-libc.Uint64FromInt32(2)) == uintptr(0) { + return _unixLogErrorAtLine(tls, _sqlite3CantopenError(tls, int32(47211)), __ccgo_ts+3560, zPath, int32(47211)) + } + _appendAllPathElements(tls, bp, bp+24) + } + _appendAllPathElements(tls, bp, zPath) + **(**int8)(__ccgo_up(zOut + uintptr((**(**TDbPath)(__ccgo_up(bp))).FnUsed))) = 0 + if (**(**TDbPath)(__ccgo_up(bp))).Frc != 0 || (**(**TDbPath)(__ccgo_up(bp))).FnUsed < int32(2) { + return _sqlite3CantopenError(tls, int32(47217)) + } + if (**(**TDbPath)(__ccgo_up(bp))).FnSymlink != 0 { + return libc.Int32FromInt32(SQLITE_OK) | libc.Int32FromInt32(2)< (READWRITE | CREATE) +// ** ReadOnly() -> (READONLY) +// ** OpenExclusive() -> (READWRITE | CREATE | EXCLUSIVE) +// ** +// ** The old OpenExclusive() accepted a boolean argument - "delFlag". If +// ** true, the file was configured to be automatically deleted when the +// ** file handle closed. To achieve the same effect using this new +// ** interface, add the DELETEONCLOSE flag to those specified above for +// ** OpenExclusive(). +// */ +func _unixOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, flags int32, pOutFlags uintptr) (r int32) { + bp := tls.Alloc(528) + defer tls.Free(528) + var ctrlFlags, eType, fd, isCreate, isDelete, isExclusive, isNewJrnl, isReadWrite, isReadonly, noLock, openFlags, rc, rc2 int32 + var p, pReadonly, pUnused, zName uintptr + var _ /* gid at bp+524 */ Tgid_t + var _ /* openMode at bp+516 */ Tmode_t + var _ /* uid at bp+520 */ Tuid_t + var _ /* zTmpname at bp+0 */ [514]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ctrlFlags, eType, fd, isCreate, isDelete, isExclusive, isNewJrnl, isReadWrite, isReadonly, noLock, openFlags, p, pReadonly, pUnused, rc, rc2, zName + p = pFile + fd = -int32(1) /* File descriptor returned by open() */ + openFlags = 0 /* Flags to pass to open() */ + eType = flags & int32(0x0FFF00) /* True to omit locking primitives */ + rc = SQLITE_OK /* Function Return Code */ + ctrlFlags = 0 /* UNIXFILE_* flags */ + isExclusive = flags & int32(SQLITE_OPEN_EXCLUSIVE) + isDelete = flags & int32(SQLITE_OPEN_DELETEONCLOSE) + isCreate = flags & int32(SQLITE_OPEN_CREATE) + isReadonly = flags & int32(SQLITE_OPEN_READONLY) + isReadWrite = flags & int32(SQLITE_OPEN_READWRITE) + /* If creating a super- or main-file journal, this function will open + ** a file-descriptor on the directory too. The first time unixSync() + ** is called the directory file descriptor will be fsync()ed and close()d. + */ + isNewJrnl = libc.BoolInt32(isCreate != 0 && (eType == int32(SQLITE_OPEN_SUPER_JOURNAL) || eType == int32(SQLITE_OPEN_MAIN_JOURNAL) || eType == int32(SQLITE_OPEN_WAL))) + zName = zPath + /* Check the following statements are true: + ** + ** (a) Exactly one of the READWRITE and READONLY flags must be set, and + ** (b) if CREATE is set, then READWRITE must also be set, and + ** (c) if EXCLUSIVE is set, then CREATE must also be set. + ** (d) if DELETEONCLOSE is set, then CREATE must also be set. + */ + /* The main DB, main journal, WAL file and super-journal are never + ** automatically deleted. Nor are they ever temporary files. */ + /* Assert that the upper layer has set one of the "file-type" flags. */ + /* Detect a pid change and reset the PRNG. There is a race condition + ** here such that two or more threads all trying to open databases at + ** the same instant might all reset the PRNG. But multiple resets + ** are harmless. + */ + if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_randomnessPid))) != libc.Xgetpid(tls) { + libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_randomnessPid)), libc.Xgetpid(tls)) + Xsqlite3_randomness(tls, 0, uintptr(0)) + } + libc.Xmemset(tls, p, 0, uint64(120)) + if eType == int32(SQLITE_OPEN_MAIN_DB) { + pUnused = _findReusableFd(tls, zName, flags) + if pUnused != 0 { + fd = (*TUnixUnusedFd)(unsafe.Pointer(pUnused)).Ffd + } else { + pUnused = Xsqlite3_malloc64(tls, uint64(16)) + if !(pUnused != 0) { + return int32(SQLITE_NOMEM) + } + } + (*TunixFile)(unsafe.Pointer(p)).FpPreallocatedUnused = pUnused + /* Database filenames are double-zero terminated if they are not + ** URIs with parameters. Hence, they can always be passed into + ** sqlite3_uri_parameter(). */ + } else { + if !(zName != 0) { + /* If zName is NULL, the upper layer is requesting a temp file. */ + rc = _unixGetTempname(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname, bp) + if rc != SQLITE_OK { + return rc + } + zName = bp + /* Generated temporary filenames are always double-zero terminated + ** for use by sqlite3_uri_parameter(). */ + } + } + /* Determine the value of the flags parameter passed to POSIX function + ** open(). These must be calculated even if open() is not called, as + ** they may be stored as part of the file handle and used by the + ** 'conch file' locking functions later on. */ + if isReadonly != 0 { + openFlags = openFlags | O_RDONLY + } + if isReadWrite != 0 { + openFlags = openFlags | int32(O_RDWR) + } + if isCreate != 0 { + openFlags = openFlags | int32(O_CREAT) + } + if isExclusive != 0 { + openFlags = openFlags | (libc.Int32FromInt32(O_EXCL) | libc.Int32FromInt32(O_NOFOLLOW)) + } + openFlags = openFlags | (libc.Int32FromInt32(O_LARGEFILE) | libc.Int32FromInt32(O_BINARY) | libc.Int32FromInt32(O_NOFOLLOW)) + if fd < 0 { /* Groupid for the file */ + rc = _findCreateFileMode(tls, zName, flags, bp+516, bp+520, bp+524) + if rc != SQLITE_OK { + return rc + } + fd = _robust_open(tls, zName, openFlags, **(**Tmode_t)(__ccgo_up(bp + 516))) + if fd < 0 { + if isNewJrnl != 0 && **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(EACCES) && (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zName, F_OK) != 0 { + /* If unable to create a journal because the directory is not + ** writable, change the error code to indicate that. */ + rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(6)<zErrMsg. +// */ +func _viewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var db, pSel, pSelTab, v2 uintptr + var eParseMode Tu8 + var nErr, nSelect, nTab, rc, v1 int32 + var xAuth Tsqlite3_xauth + _, _, _, _, _, _, _, _, _, _, _ = db, eParseMode, nErr, nSelect, nTab, pSel, pSelTab, rc, xAuth, v1, v2 /* Copy of the SELECT that implements the view */ + nErr = 0 /* Number of errors encountered */ + db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Saved xAuth pointer */ + if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTable)).FeTabType) == int32(TABTYP_VTAB) { + (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock + 1 + rc = _sqlite3VtabCallConnect(tls, pParse, pTable) + (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock = (*Tsqlite3)(unsafe.Pointer(db)).FnSchemaLock - 1 + return rc + } + /* A positive nCol means the columns names for this view are + ** already known. This routine is not called unless either the + ** table is virtual or nCol is zero. + */ + /* A negative nCol is a special marker meaning that we are currently + ** trying to compute the column names. If we enter this routine with + ** a negative nCol, it means two or more views form a loop, like this: + ** + ** CREATE VIEW one AS SELECT * FROM two; + ** CREATE VIEW two AS SELECT * FROM one; + ** + ** Actually, the error above is now caught prior to reaching this point. + ** But the following test is still important as it does come up + ** in the following: + ** + ** CREATE TABLE main.ex1(a); + ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1; + ** SELECT * FROM temp.ex1; + */ + if int32((*TTable)(unsafe.Pointer(pTable)).FnCol) < 0 { + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14839, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTable)).FzName)) + return int32(1) + } + /* If we get this far, it means we need to compute the table names. + ** Note that the call to sqlite3ResultSetOfSelect() will expand any + ** "*" elements in the results set of the view and will assign cursors + ** to the elements of the FROM clause. But we do not want these changes + ** to be permanent. So the computation is done on a copy of the SELECT + ** statement that defines the view. + */ + pSel = _sqlite3SelectDup(tls, db, (*(*struct { + FpSelect uintptr + })(unsafe.Pointer(&(*TTable)(unsafe.Pointer(pTable)).Fu))).FpSelect, 0) + if pSel != 0 { + eParseMode = (*TParse)(unsafe.Pointer(pParse)).FeParseMode + nTab = (*TParse)(unsafe.Pointer(pParse)).FnTab + nSelect = (*TParse)(unsafe.Pointer(pParse)).FnSelect + (*TParse)(unsafe.Pointer(pParse)).FeParseMode = uint8(PARSE_MODE_NORMAL) + _sqlite3SrcListAssignCursors(tls, pParse, (*TSelect)(unsafe.Pointer(pSel)).FpSrc) + (*TTable)(unsafe.Pointer(pTable)).FnCol = int16(-int32(1)) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) + xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) + pSelTab = _sqlite3ResultSetOfSelect(tls, pParse, pSel, int8(SQLITE_AFF_NONE)) + (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth + (*TParse)(unsafe.Pointer(pParse)).FnTab = nTab + (*TParse)(unsafe.Pointer(pParse)).FnSelect = nSelect + if pSelTab == uintptr(0) { + (*TTable)(unsafe.Pointer(pTable)).FnCol = 0 + nErr = nErr + 1 + } else { + if (*TTable)(unsafe.Pointer(pTable)).FpCheck != 0 { + /* CREATE VIEW name(arglist) AS ... + ** The names of the columns in the table are taken from + ** arglist which is stored in pTable->pCheck. The pCheck field + ** normally holds CHECK constraints on an ordinary table, but for + ** a VIEW it holds the list of column names. + */ + _sqlite3ColumnsFromExprList(tls, pParse, (*TTable)(unsafe.Pointer(pTable)).FpCheck, pTable+54, pTable+8) + if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 && int32((*TTable)(unsafe.Pointer(pTable)).FnCol) == (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSel)).FpEList)).FnExpr { + _sqlite3SubqueryColumnTypes(tls, pParse, pTable, pSel, int8(SQLITE_AFF_NONE)) + } + } else { + /* CREATE VIEW name AS... without an argument list. Construct + ** the column names from the SELECT statement that defines the view. + */ + (*TTable)(unsafe.Pointer(pTable)).FnCol = (*TTable)(unsafe.Pointer(pSelTab)).FnCol + (*TTable)(unsafe.Pointer(pTable)).FaCol = (*TTable)(unsafe.Pointer(pSelTab)).FaCol + **(**Tu32)(__ccgo_up(pTable + 48)) |= (*TTable)(unsafe.Pointer(pSelTab)).FtabFlags & uint32(COLFLAG_NOINSERT) + (*TTable)(unsafe.Pointer(pSelTab)).FnCol = 0 + (*TTable)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) + } + } + (*TTable)(unsafe.Pointer(pTable)).FnNVCol = (*TTable)(unsafe.Pointer(pTable)).FnCol + _sqlite3DeleteTable(tls, db, pSelTab) + _sqlite3SelectDelete(tls, db, pSel) + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 + if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { + v1 = 0 + } else { + v1 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) + } + (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v1) + (*TParse)(unsafe.Pointer(pParse)).FeParseMode = eParseMode + } else { + nErr = nErr + 1 + } + v2 = (*TTable)(unsafe.Pointer(pTable)).FpSchema + 114 + *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(DB_UnresetViews)) + if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { + _sqlite3DeleteColumnNames(tls, db, pTable) + } + return nErr + (*TParse)(unsafe.Pointer(pParse)).FnErr +} + +// C documentation +// +// /* +// ** Invoke a virtual table constructor (either xCreate or xConnect). The +// ** pointer to the function to invoke is passed as the fourth parameter +// ** to this procedure. +// */ +func _vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, __ccgo_fp_xConstruct uintptr, pzErr uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var azArg, pCtx, pVTable, zFormat, zModuleName, zType, v6 uintptr + var i, iCol, iDb, j, nArg, nDel, nType, rc, v4 int32 + var oooHidden Tu16 + var _ /* sCtx at bp+0 */ TVtabCtx + var _ /* zErr at bp+32 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = azArg, i, iCol, iDb, j, nArg, nDel, nType, oooHidden, pCtx, pVTable, rc, zFormat, zModuleName, zType, v4, v6 + nArg = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FnArg + **(**uintptr)(__ccgo_up(bp + 32)) = uintptr(0) + azArg = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg + /* Check that the virtual-table is not already being initialized */ + pCtx = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + for { + if !(pCtx != 0) { + break + } + if (*TVtabCtx)(unsafe.Pointer(pCtx)).FpTab == pTab { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+23403, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(pTab)).FzName)) + return int32(SQLITE_LOCKED) + } + goto _1 + _1: + ; + pCtx = (*TVtabCtx)(unsafe.Pointer(pCtx)).FpPrior + } + zModuleName = _sqlite3DbStrDup(tls, db, (*TTable)(unsafe.Pointer(pTab)).FzName) + if !(zModuleName != 0) { + return int32(SQLITE_NOMEM) + } + pVTable = _sqlite3MallocZero(tls, uint64(48)) + if !(pVTable != 0) { + _sqlite3OomFault(tls, db) + _sqlite3DbFree(tls, db, zModuleName) + return int32(SQLITE_NOMEM) + } + (*TVTable)(unsafe.Pointer(pVTable)).Fdb = db + (*TVTable)(unsafe.Pointer(pVTable)).FpMod = pMod + (*TVTable)(unsafe.Pointer(pVTable)).FeVtabRisk = uint8(SQLITE_VTABRISK_Normal) + iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) + **(**uintptr)(__ccgo_up((*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).FazArg + 1*8)) = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName + /* Invoke the virtual table constructor */ + (**(**TVtabCtx)(__ccgo_up(bp))).FpTab = pTab + (**(**TVtabCtx)(__ccgo_up(bp))).FpVTable = pVTable + (**(**TVtabCtx)(__ccgo_up(bp))).FpPrior = (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx + (**(**TVtabCtx)(__ccgo_up(bp))).FbDeclared = 0 + (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx = bp + (*TTable)(unsafe.Pointer(pTab)).FnTabRef = (*TTable)(unsafe.Pointer(pTab)).FnTabRef + 1 + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xConstruct})))(tls, db, (*TModule)(unsafe.Pointer(pMod)).FpAux, nArg, azArg, pVTable+16, bp+32) + _sqlite3DeleteTable(tls, db, pTab) + (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx = (**(**TVtabCtx)(__ccgo_up(bp))).FpPrior + if rc == int32(SQLITE_NOMEM) { + _sqlite3OomFault(tls, db) + } + if SQLITE_OK != rc { + if **(**uintptr)(__ccgo_up(bp + 32)) == uintptr(0) { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+23445, libc.VaList(bp+48, zModuleName)) + } else { + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, __ccgo_ts+3944, libc.VaList(bp+48, **(**uintptr)(__ccgo_up(bp + 32)))) + Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 32))) + } + _sqlite3DbFree(tls, db, pVTable) + } else { + if (*TVTable)(unsafe.Pointer(pVTable)).FpVtab != 0 { + /* Justification of ALWAYS(): A correct vtab constructor must allocate + ** the sqlite3_vtab object if successful. */ + libc.Xmemset(tls, (*TVTable)(unsafe.Pointer(pVTable)).FpVtab, 0, uint64(24)) + (*Tsqlite3_vtab)(unsafe.Pointer((*TVTable)(unsafe.Pointer(pVTable)).FpVtab)).FpModule = (*TModule)(unsafe.Pointer(pMod)).FpModule + (*TModule)(unsafe.Pointer(pMod)).FnRefModule = (*TModule)(unsafe.Pointer(pMod)).FnRefModule + 1 + (*TVTable)(unsafe.Pointer(pVTable)).FnRef = int32(1) + if (**(**TVtabCtx)(__ccgo_up(bp))).FbDeclared == 0 { + zFormat = __ccgo_ts + 23475 + **(**uintptr)(__ccgo_up(pzErr)) = _sqlite3MPrintf(tls, db, zFormat, libc.VaList(bp+48, zModuleName)) + _sqlite3VtabUnlock(tls, pVTable) + rc = int32(SQLITE_ERROR) + } else { + oooHidden = uint16(0) + /* If everything went according to plan, link the new VTable structure + ** into the linked list headed by pTab->u.vtab.p. Then loop through the + ** columns of the table to see if any of them contain the token "hidden". + ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from + ** the type string. */ + (*TVTable)(unsafe.Pointer(pVTable)).FpNext = (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp + (*(*struct { + FnArg int32 + FazArg uintptr + Fp uintptr + })(unsafe.Pointer(pTab + 64))).Fp = pVTable + iCol = 0 + for { + if !(iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { + break + } + zType = _sqlite3ColumnType(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16, __ccgo_ts+1704) + i = 0 + nType = _sqlite3Strlen30(tls, zType) + i = 0 + for { + if !(i < nType) { + break + } + if 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+17854, zType+uintptr(i), int32(6)) && (i == 0 || int32(**(**int8)(__ccgo_up(zType + uintptr(i-int32(1))))) == int32(' ')) && (int32(**(**int8)(__ccgo_up(zType + uintptr(i+int32(6))))) == int32('\000') || int32(**(**int8)(__ccgo_up(zType + uintptr(i+int32(6))))) == int32(' ')) { + break + } + goto _3 + _3: + ; + i = i + 1 + } + if i < nType { + if **(**int8)(__ccgo_up(zType + uintptr(i+int32(6)))) != 0 { + v4 = int32(1) + } else { + v4 = 0 + } + nDel = int32(6) + v4 + j = i + for { + if !(j+nDel <= nType) { + break + } + **(**int8)(__ccgo_up(zType + uintptr(j))) = **(**int8)(__ccgo_up(zType + uintptr(j+nDel))) + goto _5 + _5: + ; + j = j + 1 + } + if int32(**(**int8)(__ccgo_up(zType + uintptr(i)))) == int32('\000') && i > 0 { + **(**int8)(__ccgo_up(zType + uintptr(i-int32(1)))) = int8('\000') + } + v6 = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + 14 + *(*Tu16)(unsafe.Pointer(v6)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v6))) | libc.Int32FromInt32(COLFLAG_HIDDEN)) + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(TF_HasHidden) + oooHidden = uint16(TF_OOOHidden) + } else { + **(**Tu32)(__ccgo_up(pTab + 48)) |= uint32(oooHidden) + } + goto _2 + _2: + ; + iCol = iCol + 1 + } + } + } + } + _sqlite3DbFree(tls, db, zModuleName) + return rc +} + +// C documentation +// +// /* +// ** Perform a reduce action and the shift that must immediately +// ** follow the reduce. +// ** +// ** The yyLookahead and yyLookaheadToken parameters provide reduce actions +// ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE +// ** if the lookahead token has already been consumed. As this procedure is +// ** only called from one place, optimizing compilers will in-line it, which +// ** means that the extra parameters have no performance impact. +// */ +func _yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead int32, yyLookaheadToken TToken, pParse uintptr) (r uint16) { + bp := tls.Alloc(160) + defer tls.Free(160) + var bNot, bNot1, i, nExpr, yygoto, yysize, v353 int32 + var n Tu32 + var op Tu8 + var p, p1, p2, p3, p4, p5, pB, pDot, pFrom, pFromClause, pLeft, pLhs, pList, pList1, pList2, pList3, pList4, pNew, pOld, pRHS, pRhs, pRight, pSelect, pSelectRHS, pSrc, pSubquery, pSubquery1, temp1, temp11, temp2, temp21, temp3, temp4, yymsp, v352 uintptr + var yyact uint16 + var v357 TToken + var _ /* all at bp+112 */ TToken + var _ /* as at bp+72 */ TToken + var _ /* dest at bp+16 */ TSelectDest + var _ /* iValue at bp+88 */ int32 + var _ /* t at bp+96 */ TToken + var _ /* x at bp+56 */ TToken + var _ /* yylhsminor at bp+0 */ TYYMINORTYPE + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNot, bNot1, i, n, nExpr, op, p, p1, p2, p3, p4, p5, pB, pDot, pFrom, pFromClause, pLeft, pLhs, pList, pList1, pList2, pList3, pList4, pNew, pOld, pRHS, pRhs, pRight, pSelect, pSelectRHS, pSrc, pSubquery, pSubquery1, temp1, temp11, temp2, temp21, temp3, temp4, yyact, yygoto, yymsp, yysize, v352, v353, v357 /* Amount to pop the stack */ + _ = yyLookahead + _ = yyLookaheadToken + yymsp = (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos + switch yyruleno { + case uint32(0): + goto _1 + case uint32(1): + goto _2 + case uint32(2): + goto _3 + case uint32(3): + goto _4 + case uint32(4): + goto _5 + case uint32(6): + goto _6 + case uint32(5): + goto _7 + case uint32(7): + goto _8 + case uint32(328): + goto _9 + case uint32(9): + goto _10 + case uint32(8): + goto _11 + case uint32(10): + goto _12 + case uint32(11): + goto _13 + case uint32(12): + goto _14 + case uint32(13): + goto _15 + case uint32(14): + goto _16 + case uint32(18): + goto _17 + case uint32(15): + goto _18 + case uint32(47): + goto _19 + case uint32(62): + goto _20 + case uint32(72): + goto _21 + case uint32(81): + goto _22 + case uint32(100): + goto _23 + case uint32(246): + goto _24 + case uint32(16): + goto _25 + case uint32(17): + goto _26 + case uint32(19): + goto _27 + case uint32(20): + goto _28 + case uint32(21): + goto _29 + case uint32(22): + goto _30 + case uint32(23): + goto _31 + case uint32(24): + goto _32 + case uint32(25): + goto _33 + case uint32(65): + goto _34 + case uint32(26): + goto _35 + case uint32(106): + goto _36 + case uint32(27): + goto _37 + case uint32(28): + goto _38 + case uint32(29): + goto _39 + case uint32(30): + goto _40 + case uint32(31): + goto _41 + case uint32(67): + goto _42 + case uint32(32): + goto _43 + case uint32(33): + goto _44 + case uint32(34): + goto _45 + case uint32(35): + goto _46 + case uint32(36): + goto _47 + case uint32(37): + goto _48 + case uint32(38): + goto _49 + case uint32(39): + goto _50 + case uint32(40): + goto _51 + case uint32(41): + goto _52 + case uint32(42): + goto _53 + case uint32(43): + goto _54 + case uint32(44): + goto _55 + case uint32(45): + goto _56 + case uint32(46): + goto _57 + case uint32(48): + goto _58 + case uint32(49): + goto _59 + case uint32(50): + goto _60 + case uint32(51): + goto _61 + case uint32(52): + goto _62 + case uint32(53): + goto _63 + case uint32(54): + goto _64 + case uint32(55): + goto _65 + case uint32(56): + goto _66 + case uint32(57): + goto _67 + case uint32(58): + goto _68 + case uint32(59): + goto _69 + case uint32(60): + goto _70 + case uint32(76): + goto _71 + case uint32(61): + goto _72 + case uint32(173): + goto _73 + case uint32(80): + goto _74 + case uint32(63): + goto _75 + case uint32(219): + goto _76 + case uint32(222): + goto _77 + case uint32(247): + goto _78 + case uint32(64): + goto _79 + case uint32(66): + goto _80 + case uint32(68): + goto _81 + case uint32(69): + goto _82 + case uint32(70): + goto _83 + case uint32(71): + goto _84 + case uint32(75): + goto _85 + case uint32(73): + goto _86 + case uint32(74): + goto _87 + case uint32(77): + goto _88 + case uint32(174): + goto _89 + case uint32(78): + goto _90 + case uint32(79): + goto _91 + case uint32(82): + goto _92 + case uint32(83): + goto _93 + case uint32(84): + goto _94 + case uint32(85): + goto _95 + case uint32(86): + goto _96 + case uint32(87): + goto _97 + case uint32(88): + goto _98 + case uint32(91): + goto _99 + case uint32(89): + goto _100 + case uint32(90): + goto _101 + case uint32(92): + goto _102 + case uint32(93): + goto _103 + case uint32(94): + goto _104 + case uint32(95): + goto _105 + case uint32(97): + goto _106 + case uint32(96): + goto _107 + case uint32(98): + goto _108 + case uint32(99): + goto _109 + case uint32(134): + goto _110 + case uint32(101): + goto _111 + case uint32(144): + goto _112 + case uint32(234): + goto _113 + case uint32(237): + goto _114 + case uint32(242): + goto _115 + case uint32(102): + goto _116 + case uint32(103): + goto _117 + case uint32(104): + goto _118 + case uint32(117): + goto _119 + case uint32(105): + goto _120 + case uint32(258): + goto _121 + case uint32(259): + goto _122 + case uint32(110): + goto _123 + case uint32(107): + goto _124 + case uint32(108): + goto _125 + case uint32(109): + goto _126 + case uint32(111): + goto _127 + case uint32(112): + goto _128 + case uint32(113): + goto _129 + case uint32(114): + goto _130 + case uint32(115): + goto _131 + case uint32(131): + goto _132 + case uint32(116): + goto _133 + case uint32(120): + goto _134 + case uint32(118): + goto _135 + case uint32(121): + goto _136 + case uint32(119): + goto _137 + case uint32(122): + goto _138 + case uint32(123): + goto _139 + case uint32(124): + goto _140 + case uint32(125): + goto _141 + case uint32(126): + goto _142 + case uint32(127): + goto _143 + case uint32(128): + goto _144 + case uint32(129): + goto _145 + case uint32(130): + goto _146 + case uint32(132): + goto _147 + case uint32(133): + goto _148 + case uint32(145): + goto _149 + case uint32(135): + goto _150 + case uint32(136): + goto _151 + case uint32(137): + goto _152 + case uint32(138): + goto _153 + case uint32(139): + goto _154 + case uint32(143): + goto _155 + case uint32(140): + goto _156 + case uint32(141): + goto _157 + case uint32(142): + goto _158 + case uint32(148): + goto _159 + case uint32(146): + goto _160 + case uint32(153): + goto _161 + case uint32(155): + goto _162 + case uint32(232): + goto _163 + case uint32(233): + goto _164 + case uint32(252): + goto _165 + case uint32(154): + goto _166 + case uint32(147): + goto _167 + case uint32(156): + goto _168 + case uint32(231): + goto _169 + case uint32(251): + goto _170 + case uint32(149): + goto _171 + case uint32(150): + goto _172 + case uint32(151): + goto _173 + case uint32(152): + goto _174 + case uint32(157): + goto _175 + case uint32(158): + goto _176 + case uint32(159): + goto _177 + case uint32(160): + goto _178 + case uint32(161): + goto _179 + case uint32(162): + goto _180 + case uint32(163): + goto _181 + case uint32(164): + goto _182 + case uint32(165): + goto _183 + case uint32(166): + goto _184 + case uint32(167): + goto _185 + case uint32(168): + goto _186 + case uint32(169): + goto _187 + case uint32(170): + goto _188 + case uint32(171): + goto _189 + case uint32(172): + goto _190 + case uint32(175): + goto _191 + case uint32(176): + goto _192 + case uint32(177): + goto _193 + case uint32(178): + goto _194 + case uint32(179): + goto _195 + case uint32(180): + goto _196 + case uint32(181): + goto _197 + case uint32(182): + goto _198 + case uint32(184): + goto _199 + case uint32(183): + goto _200 + case uint32(185): + goto _201 + case uint32(186): + goto _202 + case uint32(187): + goto _203 + case uint32(188): + goto _204 + case uint32(189): + goto _205 + case uint32(190): + goto _206 + case uint32(191): + goto _207 + case uint32(192): + goto _208 + case uint32(193): + goto _209 + case uint32(194): + goto _210 + case uint32(195): + goto _211 + case uint32(196): + goto _212 + case uint32(197): + goto _213 + case uint32(199): + goto _214 + case uint32(198): + goto _215 + case uint32(200): + goto _216 + case uint32(201): + goto _217 + case uint32(202): + goto _218 + case uint32(203): + goto _219 + case uint32(204): + goto _220 + case uint32(205): + goto _221 + case uint32(206): + goto _222 + case uint32(207): + goto _223 + case uint32(208): + goto _224 + case uint32(209): + goto _225 + case uint32(210): + goto _226 + case uint32(211): + goto _227 + case uint32(212): + goto _228 + case uint32(213): + goto _229 + case uint32(215): + goto _230 + case uint32(214): + goto _231 + case uint32(216): + goto _232 + case uint32(217): + goto _233 + case uint32(221): + goto _234 + case uint32(218): + goto _235 + case uint32(220): + goto _236 + case uint32(223): + goto _237 + case uint32(224): + goto _238 + case uint32(225): + goto _239 + case uint32(226): + goto _240 + case uint32(227): + goto _241 + case uint32(228): + goto _242 + case uint32(229): + goto _243 + case uint32(230): + goto _244 + case uint32(235): + goto _245 + case uint32(236): + goto _246 + case uint32(243): + goto _247 + case uint32(238): + goto _248 + case uint32(239): + goto _249 + case uint32(281): + goto _250 + case uint32(240): + goto _251 + case uint32(241): + goto _252 + case uint32(244): + goto _253 + case uint32(245): + goto _254 + case uint32(248): + goto _255 + case uint32(249): + goto _256 + case uint32(250): + goto _257 + case uint32(253): + goto _258 + case uint32(254): + goto _259 + case uint32(255): + goto _260 + case uint32(256): + goto _261 + case uint32(257): + goto _262 + case uint32(260): + goto _263 + case uint32(261): + goto _264 + case uint32(262): + goto _265 + case uint32(263): + goto _266 + case uint32(264): + goto _267 + case uint32(266): + goto _268 + case uint32(265): + goto _269 + case uint32(267): + goto _270 + case uint32(286): + goto _271 + case uint32(268): + goto _272 + case uint32(287): + goto _273 + case uint32(269): + goto _274 + case uint32(270): + goto _275 + case uint32(271): + goto _276 + case uint32(272): + goto _277 + case uint32(273): + goto _278 + case uint32(274): + goto _279 + case uint32(275): + goto _280 + case uint32(276): + goto _281 + case uint32(277): + goto _282 + case uint32(278): + goto _283 + case uint32(279): + goto _284 + case uint32(280): + goto _285 + case uint32(282): + goto _286 + case uint32(283): + goto _287 + case uint32(284): + goto _288 + case uint32(285): + goto _289 + case uint32(288): + goto _290 + case uint32(289): + goto _291 + case uint32(290): + goto _292 + case uint32(291): + goto _293 + case uint32(292): + goto _294 + case uint32(293): + goto _295 + case uint32(294): + goto _296 + case uint32(295): + goto _297 + case uint32(296): + goto _298 + case uint32(297): + goto _299 + case uint32(298): + goto _300 + case uint32(299): + goto _301 + case uint32(300): + goto _302 + case uint32(301): + goto _303 + case uint32(302): + goto _304 + case uint32(303): + goto _305 + case uint32(304): + goto _306 + case uint32(305): + goto _307 + case uint32(307): + goto _308 + case uint32(306): + goto _309 + case uint32(308): + goto _310 + case uint32(310): + goto _311 + case uint32(309): + goto _312 + case uint32(311): + goto _313 + case uint32(312): + goto _314 + case uint32(313): + goto _315 + case uint32(314): + goto _316 + case uint32(315): + goto _317 + case uint32(316): + goto _318 + case uint32(317): + goto _319 + case uint32(318): + goto _320 + case uint32(319): + goto _321 + case uint32(320): + goto _322 + case uint32(321): + goto _323 + case uint32(322): + goto _324 + case uint32(323): + goto _325 + case uint32(324): + goto _326 + case uint32(325): + goto _327 + case uint32(326): + goto _328 + case uint32(327): + goto _329 + case uint32(331): + goto _330 + case uint32(329): + goto _331 + case uint32(332): + goto _332 + case uint32(330): + goto _333 + case uint32(334): + goto _334 + case uint32(333): + goto _335 + case uint32(335): + goto _336 + case uint32(336): + goto _337 + case uint32(338): + goto _338 + case uint32(337): + goto _339 + case uint32(339): + goto _340 + case uint32(340): + goto _341 + case uint32(341): + goto _342 + case uint32(342): + goto _343 + case uint32(343): + goto _344 + case uint32(344): + goto _345 + case uint32(345): + goto _346 + case uint32(346): + goto _347 + case uint32(347): + goto _348 + default: + goto _349 + } + goto _350 +_1: + ; /* explain ::= EXPLAIN */ + if (*TParse)(unsafe.Pointer(pParse)).FpReprepare == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Fexplain = uint8(1) + } + goto _350 +_2: + ; /* explain ::= EXPLAIN QUERY PLAN */ + if (*TParse)(unsafe.Pointer(pParse)).FpReprepare == uintptr(0) { + (*TParse)(unsafe.Pointer(pParse)).Fexplain = uint8(2) + } + goto _350 +_3: + ; /* cmdx ::= cmd */ + _sqlite3FinishCoding(tls, pParse) + goto _350 +_4: + ; /* cmd ::= BEGIN transtype trans_opt */ + _sqlite3BeginTransaction(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_5: + ; /* transtype ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(TK_DEFERRED) + goto _350 +_7: + ; /* transtype ::= DEFERRED */ +_6: + ; +_8: + ; +_9: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_11: + ; /* cmd ::= COMMIT|END trans_opt */ +_10: + ; + _sqlite3EndTransaction(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor)) + goto _350 +_12: + ; /* cmd ::= SAVEPOINT nm */ + _sqlite3Savepoint(tls, pParse, SAVEPOINT_BEGIN, yymsp+8) + goto _350 +_13: + ; /* cmd ::= RELEASE savepoint_opt nm */ + _sqlite3Savepoint(tls, pParse, int32(SAVEPOINT_RELEASE), yymsp+8) + goto _350 +_14: + ; /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ + _sqlite3Savepoint(tls, pParse, int32(SAVEPOINT_ROLLBACK), yymsp+8) + goto _350 +_15: + ; /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ + _sqlite3StartTable(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_16: + ; /* createkw ::= CREATE */ + _disableLookaside(tls, pParse) + goto _350 +_18: + ; /* ifnotexists ::= */ +_17: + ; +_19: + ; +_20: + ; +_21: + ; +_22: + ; +_23: + ; +_24: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = 0 + goto _350 +_25: + ; /* ifnotexists ::= IF NOT EXISTS */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = int32(1) + goto _350 +_26: + ; /* temp ::= TEMP */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.BoolInt32(libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0) + goto _350 +_27: + ; /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */ + _sqlite3EndTable(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*Tu32)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + goto _350 +_28: + ; /* create_table_args ::= AS select */ + _sqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint32(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_29: + ; /* table_option_set ::= */ + *(*Tu32)(unsafe.Pointer(yymsp + 1*24 + 8)) = uint32(0) + goto _350 +_30: + ; /* table_option_set ::= table_option_set COMMA table_option */ + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) | *(*Tu32)(unsafe.Pointer(yymsp + 8)) + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_31: + ; /* table_option ::= WITHOUT nm */ + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) == uint32(5) && Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), __ccgo_ts+17963, int32(5)) == 0 { + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid) | libc.Int32FromInt32(TF_NoVisibleRowid)) + } else { + *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint32(0) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24930, libc.VaList(bp+136, *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)))) + } + goto _350 +_32: + ; /* table_option ::= nm */ + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) == uint32(6) && Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), __ccgo_ts+17899, int32(6)) == 0 { + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = uint32(TF_Strict) + } else { + *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = uint32(0) + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24930, libc.VaList(bp+136, *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)))) + } + *(*Tu32)(unsafe.Pointer(yymsp + 8)) = *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_33: + ; /* columnname ::= nm typetoken */ + _sqlite3AddColumn(tls, pParse, *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*TToken)(unsafe.Pointer(yymsp + 8))) + goto _350 +_35: + ; /* typetoken ::= */ +_34: + ; +_36: + ; + *(*uint32)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uint32(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_37: + ; /* typetoken ::= typename LP signed RP */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t(*(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) - int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))))) + goto _350 +_38: + ; /* typetoken ::= typename LP signed COMMA signed RP */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t(*(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) - int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))))) + goto _350 +_39: + ; /* typename ::= typename ID|STRING */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + libc.Uint32FromInt32(int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))))) + goto _350 +_40: + ; /* scanpt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = yyLookaheadToken.Fz + goto _350 +_41: + ; /* scantok ::= */ + *(*TToken)(unsafe.Pointer(yymsp + 1*24 + 8)) = yyLookaheadToken + goto _350 +_43: + ; /* ccons ::= CONSTRAINT nm */ +_42: + ; + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_44: + ; /* ccons ::= DEFAULT scantok term */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_45: + ; /* ccons ::= DEFAULT LP expr RP */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))+uintptr(1), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_46: + ; /* ccons ::= DEFAULT PLUS scantok term */ + _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_47: + ; /* ccons ::= DEFAULT MINUS scantok term */ + p = _sqlite3PExpr(tls, pParse, int32(TK_UMINUS), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + _sqlite3AddDefaultValue(tls, pParse, p, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) + goto _350 +_48: + ; /* ccons ::= DEFAULT scantok ID|INDEXED */ + p1 = _tokenExpr(tls, pParse, int32(TK_STRING), *(*TToken)(unsafe.Pointer(yymsp + 8))) + if p1 != 0 { + _sqlite3ExprIdToTrueFalse(tls, p1) + } + _sqlite3AddDefaultValue(tls, pParse, p1, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) + goto _350 +_49: + ; /* ccons ::= NOT NULL onconf */ + _sqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_50: + ; /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ + _sqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_51: + ; /* ccons ::= UNIQUE onconf */ + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_UNIQUE)) + goto _350 +_52: + ; /* ccons ::= CHECK LP expr RP */ + _sqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_53: + ; /* ccons ::= REFERENCES nm eidlist_opt refargs */ + _sqlite3CreateForeignKey(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_54: + ; /* ccons ::= defer_subclause */ + _sqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_55: + ; /* ccons ::= COLLATE ID|STRING */ + _sqlite3AddCollateType(tls, pParse, yymsp+8) + goto _350 +_56: + ; /* generated ::= LP expr RP */ + _sqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_57: + ; /* generated ::= LP expr RP ID */ + _sqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8) + goto _350 +_58: + ; /* autoinc ::= AUTOINCR */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(1) + goto _350 +_59: + ; /* refargs ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = libc.Int32FromInt32(OE_None) * libc.Int32FromInt32(0x0101) /* EV: R-19803-45884 */ + goto _350 +_60: + ; /* refargs ::= refargs refarg */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) & ^*(*int32)(unsafe.Pointer(yymsp + 8 + 4)) | *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_61: + ; /* refarg ::= MATCH nm */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = 0 + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 4)) = 0x000000 + goto _350 +_62: + ; /* refarg ::= ON INSERT refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = 0 + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = 0x000000 + goto _350 +_63: + ; /* refarg ::= ON DELETE refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = int32(0x0000ff) + goto _350 +_64: + ; /* refarg ::= ON UPDATE refact */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) << int32(8) + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = int32(0x00ff00) + goto _350 +_65: + ; /* refact ::= SET NULL */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(OE_SetNull) /* EV: R-33326-45252 */ + goto _350 +_66: + ; /* refact ::= SET DEFAULT */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(OE_SetDflt) /* EV: R-33326-45252 */ + goto _350 +_67: + ; /* refact ::= CASCADE */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Cascade) /* EV: R-33326-45252 */ + goto _350 +_68: + ; /* refact ::= RESTRICT */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Restrict) /* EV: R-33326-45252 */ + goto _350 +_69: + ; /* refact ::= NO ACTION */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = OE_None /* EV: R-33326-45252 */ + goto _350 +_70: + ; /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = 0 + goto _350 +_72: + ; /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ +_71: + ; +_73: + ; + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_75: + ; /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ +_74: + ; +_76: + ; +_77: + ; +_78: + ; + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(1) + goto _350 +_79: + ; /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = 0 + goto _350 +_80: + ; /* tconscomma ::= COMMA */ + (*(*struct { + FaddrCrTab int32 + FregRowid int32 + FregRoot int32 + FconstraintName TToken + })(unsafe.Pointer(pParse + 248))).FconstraintName.Fn = uint32(0) + goto _350 +_81: + ; /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ + _sqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), 0) + goto _350 +_82: + ; /* tcons ::= UNIQUE LP sortlist RP onconf */ + _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_UNIQUE)) + goto _350 +_83: + ; /* tcons ::= CHECK LP expr RP onconf */ + _sqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_84: + ; /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ + _sqlite3CreateForeignKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + _sqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_86: + ; /* onconf ::= */ +_85: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(OE_Default) + goto _350 +_87: + ; /* onconf ::= ON CONFLICT resolvetype */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) + goto _350 +_88: + ; /* resolvetype ::= IGNORE */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Ignore) + goto _350 +_90: + ; /* resolvetype ::= REPLACE */ +_89: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Replace) + goto _350 +_91: + ; /* cmd ::= DROP TABLE ifexists fullname */ + _sqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), 0, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_92: + ; /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ + _sqlite3CreateView(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(8))*24+8, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))) + goto _350 +_93: + ; /* cmd ::= DROP VIEW ifexists fullname */ + _sqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), int32(1), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_94: + ; /* cmd ::= select */ + **(**TSelectDest)(__ccgo_up(bp + 16)) = TSelectDest{ + FeDest: uint8(SRT_Output), + } + if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_EncodingFixed) != uint32(0) || _sqlite3ReadSchema(tls, pParse) == SQLITE_OK { + _sqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), bp+16) + } + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_95: + ; /* select ::= WITH wqlist selectnowith */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_96: + ; /* select ::= WITH RECURSIVE wqlist selectnowith */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_97: + ; /* select ::= selectnowith */ + p2 = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + if p2 != 0 { + _parserDoubleLinkSelect(tls, pParse, p2) + } + goto _350 +_98: + ; /* selectnowith ::= selectnowith multiselect_op oneselect */ + pRhs = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + pLhs = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + if pRhs != 0 && (*TSelect)(unsafe.Pointer(pRhs)).FpPrior != 0 { + (**(**TToken)(__ccgo_up(bp + 56))).Fn = uint32(0) + _parserDoubleLinkSelect(tls, pParse, pRhs) + pFrom = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+56, pRhs, uintptr(0)) + pRhs = _sqlite3SelectNew(tls, pParse, uintptr(0), pFrom, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + } + if pRhs != 0 { + (*TSelect)(unsafe.Pointer(pRhs)).Fop = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + (*TSelect)(unsafe.Pointer(pRhs)).FpPrior = pLhs + if pLhs != 0 { + **(**Tu32)(__ccgo_up(pLhs + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) + } + **(**Tu32)(__ccgo_up(pRhs + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != int32(TK_ALL) { + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 2, 0x4) + } + } else { + _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pLhs) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = pRhs + goto _350 +_100: + ; /* multiselect_op ::= UNION */ +_99: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-OP*/ + goto _350 +_101: + ; /* multiselect_op ::= UNION ALL */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(TK_ALL) + goto _350 +_102: + ; /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_103: + ; /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)) != 0 { + (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)))).FpWinDefn = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + } else { + _sqlite3WindowListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + } + goto _350 +_104: + ; /* values ::= VALUES LP nexprlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values), uintptr(0)) + goto _350 +_105: + ; /* oneselect ::= mvalues */ + _sqlite3MultiValuesEnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_107: + ; /* mvalues ::= values COMMA LP nexprlist RP */ +_106: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3MultiValues(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_108: + ; /* distinct ::= DISTINCT */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SF_Distinct) + goto _350 +_109: + ; /* distinct ::= ALL */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SF_All) + goto _350 +_111: + ; /* sclp ::= */ +_110: + ; +_112: + ; +_113: + ; +_114: + ; +_115: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_116: + ; /* selcollist ::= sclp scanpt expr scanpt as */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) > uint32(0) { + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+8, int32(1)) + } + _sqlite3ExprListSetSpan(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_117: + ; /* selcollist ::= sclp scanpt STAR */ + p3 = _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_ASTERISK), uintptr(0)) + _sqlite3ExprSetErrorOffset(tls, p3, int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64((*TParse)(unsafe.Pointer(pParse)).FzTail))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), p3) + goto _350 +_118: + ; /* selcollist ::= sclp scanpt nm DOT STAR */ + pRight = _sqlite3PExpr(tls, pParse, int32(TK_ASTERISK), uintptr(0), uintptr(0)) + _sqlite3ExprSetErrorOffset(tls, pRight, int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64((*TParse)(unsafe.Pointer(pParse)).FzTail))) + pLeft = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pDot = _sqlite3PExpr(tls, pParse, int32(TK_DOT), pLeft, pRight) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pDot) + goto _350 +_120: + ; /* as ::= AS nm */ +_119: + ; +_121: + ; +_122: + ; + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_124: + ; /* from ::= */ +_123: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_125: + ; /* from ::= FROM seltablist */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + _sqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_126: + ; /* stl_prefix ::= seltablist joinop */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 && (*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnSrc > 0 { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8 + uintptr((*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnSrc-int32(1))*80))).Ffg.Fjointype = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + 8))) + } + goto _350 +_127: + ; /* seltablist ::= stl_prefix nm dbnm as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + goto _350 +_128: + ; /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, uintptr(0), yymsp+8) + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + goto _350 +_129: + ; /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + _sqlite3SrcListFuncArgs(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + goto _350 +_130: + ; /* seltablist ::= stl_prefix LP select RP as on_using */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_131: + ; /* seltablist ::= stl_prefix LP seltablist RP as on_using */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) == uintptr(0) && *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) == uint32(0) && *(*uintptr)(unsafe.Pointer(yymsp + 8)) == uintptr(0) && *(*uintptr)(unsafe.Pointer(yymsp + 8 + 8)) == uintptr(0) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + } else { + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != uintptr(0) && (*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))).FnSrc == int32(1) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) != 0 { + pNew = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) + 8 + uintptr((*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)))).FnSrc-int32(1))*80 + pOld = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + 8 + (*TSrcItem)(unsafe.Pointer(pNew)).FzName = (*TSrcItem)(unsafe.Pointer(pOld)).FzName + if int32(*(*uint32)(unsafe.Pointer(pOld + 24 + 4))&0x4>>2) != 0 { + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 2, 0x4) + *(*uintptr)(unsafe.Pointer(pNew + 72)) = *(*uintptr)(unsafe.Pointer(pOld + 72)) + *(*uintptr)(unsafe.Pointer(pOld + 72)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pOld+24+4, libc.Uint32FromInt32(0), 2, 0x4) + if (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 72)))).FpSelect)).FselFlags&uint32(SF_NestedFrom) != uint32(0) { + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 14, 0x4000) + } + } else { + *(*uintptr)(unsafe.Pointer(pNew + 72)) = *(*uintptr)(unsafe.Pointer(pOld + 72)) + *(*uintptr)(unsafe.Pointer(pOld + 72)) = uintptr(0) + } + if int32(*(*uint32)(unsafe.Pointer(pOld + 24 + 4))&0x8>>3) != 0 { + *(*uintptr)(unsafe.Pointer(pNew + 48)) = *(*uintptr)(unsafe.Pointer(pOld + 48)) + *(*uintptr)(unsafe.Pointer(pOld + 48)) = uintptr(0) + libc.SetBitFieldPtr32Uint32(pOld+24+4, libc.Uint32FromInt32(0), 3, 0x8) + libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 3, 0x8) + } + (*TSrcItem)(unsafe.Pointer(pOld)).FzName = uintptr(0) + } + _sqlite3SrcListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + } else { + _sqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + pSubquery = _sqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, pSubquery, yymsp+8) + } + } + goto _350 +_133: + ; /* dbnm ::= */ +_132: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + *(*uint32)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uint32(0) + goto _350 +_135: + ; /* fullname ::= nm */ +_134: + ; + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+8, uintptr(0)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+8) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_137: + ; /* fullname ::= nm DOT nm */ +_136: + ; + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+8) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_138: + ; /* xfullname ::= nm AS nm */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, uintptr(0)) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + } else { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzAlias = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, yymsp+8) + } + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_139: + ; /* xfullname ::= nm DOT nm AS nm */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + } else { + (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzAlias = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, yymsp+8) + } + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_140: + ; /* joinop ::= COMMA|JOIN */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(JT_INNER) + goto _350 +_141: + ; /* joinop ::= JOIN_KW JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), uintptr(0)) /*X-overwrites-A*/ + goto _350 +_142: + ; /* joinop ::= JOIN_KW nm JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0)) /*X-overwrites-A*/ + goto _350 +_143: + ; /* joinop ::= JOIN_KW nm nm JOIN */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) /*X-overwrites-A*/ + goto _350 +_144: + ; /* on_using ::= ON expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = uintptr(0) + goto _350 +_145: + ; /* on_using ::= USING LP idlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_146: + ; /* on_using ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uintptr(0) + goto _350 +_147: + ; /* indexed_by ::= INDEXED BY nm */ + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + goto _350 +_148: + ; /* indexed_by ::= NOT INDEXED */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = uint32(1) + goto _350 +_150: + ; /* orderby_opt ::= ORDER BY sortlist */ +_149: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_151: + ; /* sortlist ::= sortlist COMMA expr sortorder nulls */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + _sqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_152: + ; /* sortlist ::= expr sortorder nulls */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) /*A-overwrites-Y*/ + _sqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_153: + ; /* sortorder ::= ASC */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = SQLITE_SO_ASC + goto _350 +_154: + ; /* sortorder ::= DESC */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SQLITE_SO_DESC) + goto _350 +_156: + ; /* sortorder ::= */ +_155: + ; + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = -int32(1) + goto _350 +_157: + ; /* nulls ::= NULLS FIRST */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = SQLITE_SO_ASC + goto _350 +_158: + ; /* nulls ::= NULLS LAST */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(SQLITE_SO_DESC) + goto _350 +_160: + ; /* having_opt ::= */ +_159: + ; +_161: + ; +_162: + ; +_163: + ; +_164: + ; +_165: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_167: + ; /* having_opt ::= HAVING expr */ +_166: + ; +_168: + ; +_169: + ; +_170: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_171: + ; /* limit_opt ::= LIMIT expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) + goto _350 +_172: + ; /* limit_opt ::= LIMIT expr OFFSET expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_173: + ; /* limit_opt ::= LIMIT expr COMMA expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_174: + ; /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + _sqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0)) + goto _350 +_175: + ; /* where_opt_ret ::= RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + goto _350 +_176: + ; /* where_opt_ret ::= WHERE expr RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + goto _350 +_177: + ; /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ + _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + _sqlite3ExprListCheckLength(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), __ccgo_ts+24957) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + pFromClause = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + if (*TSrcList)(unsafe.Pointer(pFromClause)).FnSrc > int32(1) { + pSubquery1 = _sqlite3SelectNew(tls, pParse, uintptr(0), pFromClause, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) + (**(**TToken)(__ccgo_up(bp + 72))).Fn = uint32(0) + (**(**TToken)(__ccgo_up(bp + 72))).Fz = uintptr(0) + pFromClause = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+72, pSubquery1, uintptr(0)) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), pFromClause) + } + _sqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0), uintptr(0), uintptr(0)) + goto _350 +_178: + ; /* setlist ::= setlist COMMA nm EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, int32(1)) + goto _350 +_179: + ; /* setlist ::= setlist COMMA LP idlist RP EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) = _sqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_180: + ; /* setlist ::= nm EQ expr */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, int32(1)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_181: + ; /* setlist ::= LP idlist RP EQ expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_182: + ; /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ + _sqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_183: + ; /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ + _sqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0)) + goto _350 +_184: + ; /* upsert ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_185: + ; /* upsert ::= RETURNING selcollist */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_186: + ; /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(11))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_187: + ; /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_188: + ; /* upsert ::= ON CONFLICT DO NOTHING returning */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + goto _350 +_189: + ; /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_190: + ; /* returning ::= RETURNING selcollist */ + _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_191: + ; /* idlist_opt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_192: + ; /* idlist_opt ::= LP idlist RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_193: + ; /* idlist ::= idlist COMMA nm */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8) + goto _350 +_194: + ; /* idlist ::= nm */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3IdListAppend(tls, pParse, uintptr(0), yymsp+8) /*A-overwrites-Y*/ + goto _350 +_195: + ; /* expr ::= LP expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_196: + ; /* expr ::= ID|INDEXED|JOIN_KW */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_197: + ; /* expr ::= nm DOT nm */ + temp1 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + temp2 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp1, temp2) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_198: + ; /* expr ::= nm DOT nm DOT nm */ + temp11 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + temp21 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + temp3 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) + temp4 = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp21, temp3) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { + _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), temp11) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp11, temp4) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_200: + ; /* term ::= NULL|FLOAT|BLOB */ +_199: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*TToken)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_201: + ; /* term ::= INTEGER */ + if _sqlite3GetInt32(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), bp+88) == 0 { + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_INTEGER), yymsp+8, 0) + } else { + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprInt32(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, **(**int32)(__ccgo_up(bp + 88))) + } + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 52)) = int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8))) - int64((*TParse)(unsafe.Pointer(pParse)).FzTail)) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_202: + ; /* expr ::= VARIABLE */ + if !(int32(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + 8))))) == int32('#') && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + 8)) + 1)))])&int32(0x04) != 0) { + n = *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, int32(TK_VARIABLE), *(*TToken)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), n) + } else { + /* When doing a nested parse, one can include terms in an expression + ** that look like this: #1 #2 ... These terms refer to registers + ** in the virtual machine. #N is the N-th register. */ + **(**TToken)(__ccgo_up(bp + 96)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) /*A-overwrites-X*/ + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { + _parserSyntaxError(tls, pParse, bp+96) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = uintptr(0) + } else { + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_REGISTER), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + _sqlite3GetInt32(tls, (**(**TToken)(__ccgo_up(bp + 96))).Fz+1, *(*uintptr)(unsafe.Pointer(yymsp + 8))+44) + } + } + } + goto _350 +_203: + ; /* expr ::= expr COLLATE ID|STRING */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8, int32(1)) + goto _350 +_204: + ; /* expr ::= CAST LP expr AS typetoken RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_CAST), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, int32(1)) + _sqlite3ExprAttachSubtrees(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0)) + goto _350 +_205: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_206: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))) + _sqlite3ExprAddFunctionOrderBy(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_207: + ; /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_208: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_209: + ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(8))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8))) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + _sqlite3ExprAddFunctionOrderBy(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_210: + ; /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, 0) + _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_211: + ; /* term ::= CTIME_KW */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_212: + ; /* expr ::= LP nexprlist COMMA expr RP */ + pList = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_VECTOR), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = pList + i = 0 + for { + if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { + break + } + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 4)) |= (*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr)).Fflags & libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)|libc.Int32FromInt32(EP_Subquery)|libc.Int32FromInt32(EP_HasFunc)) + goto _351 + _351: + ; + i = i + 1 + } + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList) + } + goto _350 +_213: + ; /* expr ::= expr AND expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_215: + ; /* expr ::= expr OR expr */ +_214: + ; +_216: + ; +_217: + ; +_218: + ; +_219: + ; +_220: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_221: + ; /* likeop ::= NOT LIKE_KW|MATCH */ + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) |= uint32(0x80000000) /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/ + goto _350 +_222: + ; /* expr ::= expr likeop expr */ + bNot = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) & uint32(0x80000000)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) &= uint32(0x7fffffff) + pList1 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + pList1 = _sqlite3ExprListAppend(tls, pParse, pList1, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprFunction(tls, pParse, pList1, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + if bNot != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), uintptr(0)) + } + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) != 0 { + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + 4)) |= uint32(EP_InfixFunc) + } + goto _350 +_223: + ; /* expr ::= expr likeop expr ESCAPE expr */ + bNot1 = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) & uint32(0x80000000)) + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) &= uint32(0x7fffffff) + pList2 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList2 = _sqlite3ExprListAppend(tls, pParse, pList2, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + pList2 = _sqlite3ExprListAppend(tls, pParse, pList2, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprFunction(tls, pParse, pList2, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, 0) + if bNot1 != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 4)) |= uint32(EP_InfixFunc) + } + goto _350 +_224: + ; /* expr ::= expr ISNULL|NOTNULL */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExprIsNull(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_225: + ; /* expr ::= expr NOT NULL */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExprIsNull(tls, pParse, int32(TK_NOTNULL), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_226: + ; /* expr ::= expr IS expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_IS), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_227: + ; /* expr ::= expr IS NOT expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_ISNOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_228: + ; /* expr ::= expr IS NOT DISTINCT FROM expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_IS), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_229: + ; /* expr ::= expr IS DISTINCT FROM expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_ISNOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_231: + ; /* expr ::= NOT expr */ +_230: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) /*A-overwrites-B*/ + goto _350 +_232: + ; /* expr ::= PLUS|MINUS expr */ + p4 = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + op = libc.Uint8FromInt32(libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) + (libc.Int32FromInt32(TK_UPLUS) - libc.Int32FromInt32(TK_PLUS))) + if p4 != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p4)).Fop) == int32(TK_UPLUS) { + (*TExpr)(unsafe.Pointer(p4)).Fop = op + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = p4 + } else { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8(op), p4, uintptr(0)) + /*A-overwrites-B*/ + } + goto _350 +_233: + ; /* expr ::= expr PTR expr */ + pList3 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList3 = _sqlite3ExprListAppend(tls, pParse, pList3, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, pList3, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_235: + ; /* between_op ::= BETWEEN */ +_234: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = 0 + goto _350 +_236: + ; /* expr ::= expr between_op expr AND expr */ + pList4 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + pList4 = _sqlite3ExprListAppend(tls, pParse, pList4, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_BETWEEN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = pList4 + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList4) + } + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_237: + ; /* expr ::= expr in_op LP exprlist RP */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) == uintptr(0) { + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + v352 = __ccgo_ts + 8178 + } else { + v352 = __ccgo_ts + 8183 + } + /* Expressions of the form + ** + ** expr1 IN () + ** expr1 NOT IN () + ** + ** simplify to constants 0 (false) and 1 (true), respectively. + ** + ** Except, do not apply this optimization if expr1 contains a function + ** because that function might be an aggregate (we don't know yet whether + ** it is or not) and if it is an aggregate, that could change the meaning + ** of the whole query. + */ + pB = _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_STRING), v352) + if pB != 0 { + _sqlite3ExprIdToTrueFalse(tls, pB) + } + if !((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)) != libc.Uint32FromInt32(0)) { + _sqlite3ExprUnmapAndDelete(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = pB + } else { + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + v353 = int32(TK_OR) + } else { + v353 = int32(TK_AND) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, v353, pB, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } + } else { + pRHS = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8))).FpExpr + if (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnExpr == int32(1) && _sqlite3ExprIsConstant(tls, pParse, pRHS) != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).Fop) != int32(TK_VECTOR) { + (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8))).FpExpr = uintptr(0) + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + pRHS = _sqlite3PExpr(tls, pParse, int32(TK_UPLUS), pRHS, uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_EQ), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pRHS) + } else { + if (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnExpr == int32(1) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRHS)).Fop) == int32(TK_SELECT) { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(pRHS + 32))) + *(*uintptr)(unsafe.Pointer(pRHS + 32)) = uintptr(0) + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) == uintptr(0) { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).FpLeft)).Fop) == int32(TK_VECTOR) { + nExpr = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).FpLeft + 32)))).FnExpr + pSelectRHS = _sqlite3ExprListToValues(tls, pParse, nExpr, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + if pSelectRHS != 0 { + _parserDoubleLinkSelect(tls, pParse, pSelectRHS) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pSelectRHS) + } + } else { + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } + } + } + } + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + } + goto _350 +_238: + ; /* expr ::= LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_SELECT), uintptr(0), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_239: + ; /* expr ::= expr in_op LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_240: + ; /* expr ::= expr in_op nm dbnm paren_exprlist */ + pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + pSelect = _sqlite3SelectNew(tls, pParse, uintptr(0), pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + if pSelect != 0 { + v352 = pSrc + } else { + v352 = uintptr(0) + } + _sqlite3SrcListFuncArgs(tls, pParse, v352, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + } + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pSelect) + if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) + } + goto _350 +_241: + ; /* expr ::= EXISTS LP select RP */ + v352 = _sqlite3PExpr(tls, pParse, int32(TK_EXISTS), uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = v352 + p5 = v352 + _sqlite3PExprAddSelect(tls, pParse, p5, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_242: + ; /* expr ::= CASE case_operand case_exprlist case_else END */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_CASE), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + v352 = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } else { + v352 = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + } + *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = v352 + _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + } else { + _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } + goto _350 +_243: + ; /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_244: + ; /* case_exprlist ::= WHEN expr THEN expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_245: + ; /* nexprlist ::= nexprlist COMMA expr */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_246: + ; /* nexprlist ::= expr */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-Y*/ + goto _350 +_248: + ; /* paren_exprlist ::= LP exprlist RP */ +_247: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_249: + ; /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + _sqlite3CreateIndex(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, uintptr(0)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(11))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + 8)), SQLITE_SO_ASC, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), uint8(SQLITE_IDXTYPE_APPDEF)) + if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TParse)(unsafe.Pointer(pParse)).FpNewIndex != 0 { + _sqlite3RenameTokenMap(tls, pParse, (*TIndex)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).FpNewIndex)).FzName, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + } + goto _350 +_251: + ; /* uniqueflag ::= UNIQUE */ +_250: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Abort) + goto _350 +_252: + ; /* uniqueflag ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = OE_None + goto _350 +_253: + ; /* eidlist ::= eidlist COMMA nm collate sortorder */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) + goto _350 +_254: + ; /* eidlist ::= nm collate sortorder */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _parserAddExprIdListTerm(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-Y*/ + goto _350 +_255: + ; /* cmd ::= DROP INDEX ifexists fullname */ + _sqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_256: + ; /* cmd ::= VACUUM vinto */ + _sqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_257: + ; /* cmd ::= VACUUM nm vinto */ + _sqlite3Vacuum(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_258: + ; /* cmd ::= PRAGMA nm dbnm */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8, uintptr(0), 0) + goto _350 +_259: + ; /* cmd ::= PRAGMA nm dbnm EQ nmnum */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, 0) + goto _350 +_260: + ; /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) + goto _350 +_261: + ; /* cmd ::= PRAGMA nm dbnm EQ minus_num */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, int32(1)) + goto _350 +_262: + ; /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ + _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, int32(1)) + goto _350 +_263: + ; /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + (**(**TToken)(__ccgo_up(bp + 112))).Fz = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + (**(**TToken)(__ccgo_up(bp + 112))).Fn = libc.Uint32FromInt32(int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))))) + *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + _sqlite3FinishTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), bp+112) + goto _350 +_264: + ; /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + _sqlite3BeginTrigger(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8))) + if *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8 + 8)) == uint32(0) { + v357 = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) + } else { + v357 = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) + } + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)) = v357 /*A-overwrites-T*/ + goto _350 +_265: + ; /* trigger_time ::= BEFORE|AFTER */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_266: + ; /* trigger_time ::= INSTEAD OF */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(TK_INSTEAD) + goto _350 +_267: + ; /* trigger_time ::= */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(TK_BEFORE) + goto _350 +_269: + ; /* trigger_event ::= DELETE|INSERT */ +_268: + ; + *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 + 8)) = uintptr(0) + goto _350 +_270: + ; /* trigger_event ::= UPDATE OF idlist */ + *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = int32(TK_UPDATE) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_272: + ; /* when_clause ::= */ +_271: + ; + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) + goto _350 +_274: + ; /* when_clause ::= WHEN expr */ +_273: + ; + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_275: + ; /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + (*TTriggerStep)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)))).FpLast)).FpNext = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + (*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_276: + ; /* trigger_cmd_list ::= trigger_cmd SEMI */ + (*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_277: + ; /* tridxby ::= INDEXED BY nm */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24966, 0) + goto _350 +_278: + ; /* tridxby ::= NOT INDEXED */ + _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25050, 0) + goto _350 +_279: + ; /* trigger_cmd ::= UPDATE orconf xfullname tridxby SET setlist from where_opt scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerUpdateStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_280: + ; /* trigger_cmd ::= scanpt insert_cmd INTO xfullname idlist_opt select upsert scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerInsertStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_281: + ; /* trigger_cmd ::= DELETE FROM xfullname tridxby where_opt scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerDeleteStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_282: + ; /* trigger_cmd ::= scanpt select scanpt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerSelectStep(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_283: + ; /* expr ::= RAISE LP IGNORE RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { + (*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))).FaffExpr = int8(OE_Ignore) + } + goto _350 +_284: + ; /* expr ::= RAISE LP raisetype COMMA expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) != 0 { + (*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)))).FaffExpr = int8(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) + } + goto _350 +_285: + ; /* raisetype ::= ROLLBACK */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Rollback) + goto _350 +_286: + ; /* raisetype ::= FAIL */ + *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Fail) + goto _350 +_287: + ; /* cmd ::= DROP TRIGGER ifexists fullname */ + _sqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + goto _350 +_288: + ; /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + _sqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_289: + ; /* cmd ::= DETACH database_kw_opt expr */ + _sqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_290: + ; /* cmd ::= REINDEX */ + _sqlite3Reindex(tls, pParse, uintptr(0), uintptr(0)) + goto _350 +_291: + ; /* cmd ::= REINDEX nm dbnm */ + _sqlite3Reindex(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8) + goto _350 +_292: + ; /* cmd ::= ANALYZE */ + _sqlite3Analyze(tls, pParse, uintptr(0), uintptr(0)) + goto _350 +_293: + ; /* cmd ::= ANALYZE nm dbnm */ + _sqlite3Analyze(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8) + goto _350 +_294: + ; /* cmd ::= ALTER TABLE fullname RENAME TO nm */ + _sqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_295: + ; /* cmd ::= alter_add carglist */ + *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))))) + (*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fn + _sqlite3AlterFinishAddColumn(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + goto _350 +_296: + ; /* alter_add ::= ALTER TABLE fullname ADD kwcolumn_opt nm typetoken */ + _disableLookaside(tls, pParse) + _sqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + _sqlite3AddColumn(tls, pParse, *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*TToken)(unsafe.Pointer(yymsp + 8))) + *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_297: + ; /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ + _sqlite3AlterDropColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) + goto _350 +_298: + ; /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + _sqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8) + goto _350 +_299: + ; /* cmd ::= ALTER TABLE fullname DROP CONSTRAINT nm */ + _sqlite3AlterDropConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8, uintptr(0)) + goto _350 +_300: + ; /* cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm DROP NOT NULL */ + _sqlite3AlterDropConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8) + goto _350 +_301: + ; /* cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm SET NOT NULL onconf */ + _sqlite3AlterSetNotNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) + goto _350 +_302: + ; /* cmd ::= ALTER TABLE fullname ADD CONSTRAINT nm CHECK LP expr RP onconf */ + _sqlite3AlterAddConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))+uintptr(1), int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))-libc.Int64FromInt32(1)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_303: + ; /* cmd ::= ALTER TABLE fullname ADD CHECK LP expr RP onconf */ + _sqlite3AlterAddConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))+uintptr(1), int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))-libc.Int64FromInt32(1)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + goto _350 +_304: + ; /* cmd ::= create_vtab */ + _sqlite3VtabFinishParse(tls, pParse, uintptr(0)) + goto _350 +_305: + ; /* cmd ::= create_vtab LP vtabarglist RP */ + _sqlite3VtabFinishParse(tls, pParse, yymsp+8) + goto _350 +_306: + ; /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + _sqlite3VtabBeginParse(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) + goto _350 +_307: + ; /* vtabarg ::= */ + _sqlite3VtabArgInit(tls, pParse) + goto _350 +_309: + ; /* vtabargtoken ::= ANY */ +_308: + ; +_310: + ; + _sqlite3VtabArgExtend(tls, pParse, yymsp+8) + goto _350 +_312: + ; /* with ::= WITH wqlist */ +_311: + ; + _sqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uint8(1)) + goto _350 +_313: + ; /* wqas ::= AS */ + *(*Tu8)(unsafe.Pointer(yymsp + 8)) = uint8(M10d_Any) + goto _350 +_314: + ; /* wqas ::= AS MATERIALIZED */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint8(M10d_Yes) + goto _350 +_315: + ; /* wqas ::= AS NOT MATERIALIZED */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = uint8(M10d_No) + goto _350 +_316: + ; /* wqitem ::= withnm eidlist_opt wqas LP select RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3CteNew(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) /*A-overwrites-X*/ + goto _350 +_317: + ; /* withnm ::= nm */ + libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 6, 0x40) + goto _350 +_318: + ; /* wqlist ::= wqitem */ + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3WithAdd(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ + goto _350 +_319: + ; /* wqlist ::= wqlist COMMA wqitem */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3WithAdd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) + goto _350 +_320: + ; /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ + _sqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_321: + ; /* windowdefn ::= nm AS LP window RP */ + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FzName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uint64(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8 + 8)))) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_322: + ; /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_323: + ; /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(5))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_324: + ; /* window ::= ORDER BY sortlist frame_opt */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) + goto _350 +_325: + ; /* window ::= nm ORDER BY sortlist frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_326: + ; /* window ::= nm frame_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_327: + ; /* frame_opt ::= */ + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = _sqlite3WindowAlloc(tls, pParse, 0, int32(TK_UNBOUNDED), uintptr(0), int32(TK_CURRENT), uintptr(0), uint8(0)) + goto _350 +_328: + ; /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)), int32(TK_CURRENT), uintptr(0), *(*Tu8)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_329: + ; /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)), *(*Tu8)(unsafe.Pointer(yymsp + 8))) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_331: + ; /* frame_bound_s ::= frame_bound */ +_330: + ; + *(*TFrameBound)(unsafe.Pointer(bp)) = *(*TFrameBound)(unsafe.Pointer(yymsp + 8)) + *(*TFrameBound)(unsafe.Pointer(yymsp + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_333: + ; /* frame_bound_s ::= UNBOUNDED PRECEDING */ +_332: + ; +_334: + ; + (*(*TFrameBound)(unsafe.Pointer(bp))).FeType = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) + (*(*TFrameBound)(unsafe.Pointer(bp))).FpExpr = uintptr(0) + *(*TFrameBound)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_335: + ; /* frame_bound ::= expr PRECEDING|FOLLOWING */ + (*(*TFrameBound)(unsafe.Pointer(bp))).FeType = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) + (*(*TFrameBound)(unsafe.Pointer(bp))).FpExpr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + *(*TFrameBound)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) + goto _350 +_336: + ; /* frame_exclude_opt ::= */ + *(*Tu8)(unsafe.Pointer(yymsp + 1*24 + 8)) = uint8(0) + goto _350 +_337: + ; /* frame_exclude_opt ::= EXCLUDE frame_exclude */ + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*Tu8)(unsafe.Pointer(yymsp + 8)) + goto _350 +_339: + ; /* frame_exclude ::= NO OTHERS */ +_338: + ; + *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint8((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) /*A-overwrites-X*/ + goto _350 +_340: + ; /* frame_exclude ::= GROUP|TIES */ + *(*Tu8)(unsafe.Pointer(yymsp + 8)) = uint8((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ + goto _350 +_341: + ; /* window_clause ::= WINDOW windowdefn_list */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + goto _350 +_342: + ; /* filter_over ::= filter_clause over_clause */ + if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) + } + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_343: + ; /* filter_over ::= over_clause */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_344: + ; /* filter_over ::= filter_clause */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) + if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))))).FeFrmType = uint8(TK_FILTER) + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + 8)) + } else { + _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) + } + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_345: + ; /* over_clause ::= OVER LP window RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_346: + ; /* over_clause ::= OVER nm */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) + if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { + (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FzName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uint64(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) + } + goto _350 +_347: + ; /* filter_clause ::= FILTER LP WHERE expr RP */ + *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + goto _350 +_348: + ; /* term ::= QNUMBER */ + *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _tokenExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*TToken)(unsafe.Pointer(yymsp + 8))) + _sqlite3DequoteNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp))))) + *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + goto _350 +_349: + ; + goto _350 + /********** End reduce actions ************************************************/ +_350: + ; + yygoto = libc.Int32FromUint16(_yyRuleInfoLhs[yyruleno]) + yysize = int32(_yyRuleInfoNRhs[yyruleno]) + yyact = _yy_find_reduce_action(tls, (**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(yysize)*24))).Fstateno, libc.Uint16FromInt32(yygoto)) + /* There are no SHIFTREDUCE actions on nonterminals because the table + ** generator has simplified them to pure REDUCE actions. */ + /* It is not possible for a REDUCE to be followed by an error */ + yymsp = yymsp + uintptr(yysize+int32(1))*24 + (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos = yymsp + (*TyyStackEntry)(unsafe.Pointer(yymsp)).Fstateno = yyact + (*TyyStackEntry)(unsafe.Pointer(yymsp)).Fmajor = libc.Uint16FromInt32(yygoto) + return yyact +} + +/* +** The following code executes when the parse fails + */ diff --git a/internal/engine/lib/sqlite_linux_arm64.go b/internal/engine/lib/sqlite_linux_arm64.go new file mode 100644 index 0000000..bd43157 --- /dev/null +++ b/internal/engine/lib/sqlite_linux_arm64.go @@ -0,0 +1,17 @@ +// Code generated for linux/arm64 by 'generator --package-name libsqlite3 --prefix-enumerator=_ --prefix-external=x_ --prefix-field=F --prefix-static-internal=_ --prefix-static-none=_ --prefix-tagged-enum=_ --prefix-tagged-struct=T --prefix-tagged-union=T --prefix-typename=T --prefix-undefined=_ -ignore-unsupported-alignment -ignore-link-errors -import=sync -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DNDEBUG -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DISABLE_INTRINSIC -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_RBU -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_HAVE_ZLIB=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_WITHOUT_ZONEMALLOC -D_LARGEFILE64_SOURCE -I /home/jnml/src/modernc.org/builder/.exclude/github.com/hanzoai/sqlite/internal/libc/include/linux/arm64 -I /home/jnml/src/modernc.org/builder/.exclude/modernc.org/libz/include/linux/arm64 -I /home/jnml/src/modernc.org/builder/.exclude/modernc.org/libtcl8.6/include/linux/arm64 -extended-errors -o sqlite3.go sqlite3.c -DSQLITE_OS_UNIX=1 -eval-all-macros', DO NOT EDIT. + +//go:build linux && arm64 + +package sqlite3 + +const PROT_BTI = 16 + +const PROT_MTE = 32 + +const __ARM_ALIGN_MAX_PWR = 28 + +const __ARM_ALIGN_MAX_STACK_PWR = 16 + +const __ARM_ARCH_8A = 1 + +const __FLT_EVAL_METHOD_C99__ = 0 diff --git a/internal/engine/mutex.go b/internal/engine/mutex.go new file mode 100644 index 0000000..e77c20c --- /dev/null +++ b/internal/engine/mutex.go @@ -0,0 +1,23 @@ +// Copyright 2019 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "sync" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" +) + +type mutex struct { + sync.Mutex +} + +func mutexAlloc(tls *libc.TLS) uintptr { + return libc.Xcalloc(tls, 1, types.Size_t(unsafe.Sizeof(mutex{}))) +} + +func mutexFree(tls *libc.TLS, m uintptr) { libc.Xfree(tls, m) } diff --git a/internal/engine/nodmesg.go b/internal/engine/nodmesg.go new file mode 100644 index 0000000..7766757 --- /dev/null +++ b/internal/engine/nodmesg.go @@ -0,0 +1,12 @@ +// Copyright 2023 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !sqlite.dmesg +// +build !sqlite.dmesg + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +const dmesgs = false + +func dmesg(s string, args ...interface{}) {} diff --git a/internal/engine/pagecache.go b/internal/engine/pagecache.go new file mode 100644 index 0000000..eb67c4c --- /dev/null +++ b/internal/engine/pagecache.go @@ -0,0 +1,359 @@ +// Copyright 2026 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "errors" + "fmt" + "sync" + "sync/atomic" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +// ErrPageCacheTooLate is returned by RegisterPageCache when a SQLite +// connection has already been opened in this process. SQLITE_CONFIG_PCACHE2 +// must be installed before sqlite3_initialize, which is called implicitly +// by the first sqlite3_open_v2. After that point SQLite returns +// SQLITE_MISUSE and the engine cannot switch its page cache backend. +var ErrPageCacheTooLate = errors.New( + "sqlite: RegisterPageCache called after first Open; " + + "SQLITE_CONFIG_PCACHE2 must be installed before any connection is opened") + +// ErrPageCacheConflict is returned when a different PageCache has +// already been registered in this process. The same module value may be +// re-registered without error, which lets multiple library imports share +// a singleton without coordination. +var ErrPageCacheConflict = errors.New( + "sqlite: a different page cache module is already registered") + +// FetchMode tells Cache.Fetch how aggressively to allocate when the +// requested key is absent. It matches the createFlag of SQLite's xFetch +// (https://sqlite.org/c3ref/pcache_methods2.html). +type FetchMode int32 + +const ( + // FetchLookup looks up an existing entry. Fetch returns nil if the + // key is not in cache; no allocation is performed. + FetchLookup FetchMode = 0 + // FetchCreateEasy allocates only if it can be done without effort + // (no eviction, no memory pressure). Fetch may return nil; SQLite + // will then spill dirty pages and retry with FetchCreateForce. + FetchCreateEasy FetchMode = 1 + // FetchCreateForce allocates unconditionally and may evict to make + // room. Fetch should return nil only on a genuine out-of-memory + // condition. + FetchCreateForce FetchMode = 2 +) + +// PageCache is the factory for per-database Cache instances. +// SQLite calls Create once per open database; each call must return a +// fresh Cache with the given pageSize and extraSize. The extraSize +// includes SQLite's private PgHdr overhead and must be honoured as the +// opaque size of every Page's Extra buffer. +// +// purgeable is advisory: when false (in-memory databases), SQLite will +// only call Unpin with discard=true and the cache is permitted to free +// every page on Unpin. When true, the cache may retain unpinned pages +// for re-use. +type PageCache interface { + Create(pageSize, extraSize int, purgeable bool) (Cache, error) +} + +// Cache is one database's worth of cached pages. All callbacks for a +// single Cache are serialised by the SQLite engine: this driver opens +// every connection SQLITE_OPEN_FULLMUTEX without shared-cache mode, +// and database/sql never invokes one driver.Conn from two goroutines, +// so an implementation does not need to synchronise per-Cache state +// against concurrent calls. +// +// Implementations should NOT call RegisterPageCache directly or +// transitively. Callbacks run under the openGate read lock that the +// Open path holds, and a re-entrant Register would deadlock on the +// gate's write lock. +type Cache interface { + // SetSize advises the cache of the new target page count + // (PRAGMA cache_size). The cache is free to ignore the hint. + SetSize(n int) + + // PageCount returns the number of pages currently held (pinned and + // unpinned combined). + PageCount() int + + // Fetch returns the Page for key or nil per FetchMode. The binding + // calls Fetch on every SQLite request and compares the returned + // Page to the value held under key from the previous Fetch; when + // they match (the cache retained the entry) the same + // sqlite3_pcache_page stub is handed back to SQLite, and when they + // differ the binding retires the stale stub and mints a new one. + // The implementation is therefore free to evict and re-allocate + // between Fetches without leaking a stale view to SQLite. + Fetch(key uint32, mode FetchMode) Page + + // Unpin tells the cache that the engine is finished using the + // Page for now. If discard is true SQLite has no further need + // for the page and the cache may release its memory; if discard + // is false the cache may retain the entry for reuse or release + // it at its discretion (the normal way to honour a bounded + // cache_size). SQLite never refcounts: one Unpin call is final + // regardless of how many Fetches preceded. + Unpin(p Page, discard bool) + + // Rekey changes the key under which p is filed from oldKey to + // newKey. If an entry already exists at newKey it must be discarded + // in the same call; SQLite guarantees the colliding entry is not + // pinned at the moment of Rekey. + Rekey(p Page, oldKey, newKey uint32) + + // Truncate discards every entry whose key is greater than or equal + // to limit, including pinned entries. This is the only callback + // permitted to evict a pinned page. + Truncate(limit uint32) + + // Destroy releases every page and any resources owned by this + // Cache. After Destroy returns the binding will not call any + // other method on this Cache. + Destroy() + + // Shrink hints the cache to release as much heap as possible. The + // implementation is not obligated to free anything; this is purely + // a memory-pressure advisory. + Shrink() +} + +// Page is one cache entry. Buf and Extra return pointers into +// implementation-owned memory that MUST remain valid and at the same +// addresses for the duration of the pin: from the Fetch that returned +// the Page until the matching Unpin. While the page is unpinned the +// implementation is free to release the memory; the next Fetch for +// the same key will be consulted afresh and may return either the +// same Page (memory retained) or a different one. +// +// The memory MUST be off-heap: libc.Xmalloc, sqlite3_malloc, mmap, or +// an equivalent allocator outside the Go heap. Go-heap memory is +// forbidden, including memory pinned with runtime.Pinner: SQLite +// stores Extra addresses inside its own C structures and performs +// interior pointer arithmetic on them (it overlays PgHdr at the head +// of Extra), which trips Go's checkptr enforcement under -race the +// moment _sqlite3PcacheFetchFinish runs. Pinned slices preserve the +// allocation but lose checkptr provenance through the binding's +// unsafe.Pointer round-trip, so the failure surfaces only under the +// race detector and not in normal test runs. +// +// Page values are compared by the binding to detect whether the +// implementation retained or replaced the cached entry across a +// Fetch cycle, so Page MUST be a comparable type. Pointer-backed +// implementations (the natural shape) satisfy this automatically. +// +// Buf must be at least pageSize bytes and is where SQLite stores the +// database page contents. Extra must be at least extraSize bytes (the +// extraSize passed to PageCache.Create, which already includes +// SQLite's PgHdr overhead) and is treated by SQLite as opaque scratch +// space. Implementations should zero Extra on a freshly-allocated +// Page so SQLite's PgHdr backpointer is read as null; the binding +// does not touch Extra contents. +type Page interface { + Buf() unsafe.Pointer + Extra() unsafe.Pointer +} + +// pcacheState holds the package-global state shared between +// RegisterPageCache and the Open path. +// +// Locking discipline: +// +// - openGate.RLock is held for the body of withOpenGate (called from +// the Driver.Open path). Many opens may proceed concurrently; what +// is forbidden is registering a page cache while any open is in +// flight. +// - openGate.Lock is held for the body of RegisterPageCache. +// The write lock drains all in-flight opens and blocks all +// subsequent opens until Xsqlite3_config completes. +// - opened is set with an unconditional Store on every Open. The +// Store is intentional and cheap; using CompareAndSwap to only +// mutate on the first Open buys nothing because the read-side +// under the write lock is uncontended. The atomic.Bool lets the +// hot Open path read under RLock without paying for a full mutex +// acquisition. +// - configOnce guarantees Xsqlite3_config runs at most once per +// process. A non-OK return code, an OOM during the methods-table +// allocation, or a panic inside the once body leaves configErr +// set and registered nil; every subsequent Register call returns +// the sticky configErr. Reload is not supported in this MR. +// - registered holds the canonical PageCache for idempotency +// comparison; it is non-nil only after a successful install. +// - cMethods is the libc.Xcalloc-owned C struct SQLite reads at +// sqlite3_initialize time. Allocated once and lives until process +// exit; allocating via libc avoids tripping Go's checkptr when +// the transpiled C code reads the struct (the same reasoning that +// vtab.go:130-141 uses for sqlite3_module). +var pcacheState struct { + openGate sync.RWMutex + opened atomic.Bool + configOnce sync.Once + configErr error + registered PageCache + cMethods uintptr +} + +// markConnectionOpened is called from the Open path under +// pcacheState.openGate.RLock before sqlite3_open_v2. The RLock-side +// store happens-before RUnlock; RegisterPageCache's Lock +// acquisition waits for all readers to drain, so its subsequent Load +// observes every prior store. +func markConnectionOpened() { + pcacheState.opened.Store(true) +} + +// withOpenGate runs fn while holding the openGate read lock. The Open +// path wraps its entire body in this so a concurrent +// RegisterPageCache cannot squeeze in between the opened-flag +// store and sqlite3_open_v2. +func withOpenGate(fn func() error) error { + pcacheState.openGate.RLock() + defer pcacheState.openGate.RUnlock() + markConnectionOpened() + return fn() +} + +// pcacheMethods2 is the Go view of the C sqlite3_pcache_methods2 struct +// as cznic transpiles it. Every supported GOOS/GOARCH pair exports the +// type with the same FiVersion/FpArg/FxInit/... field names; the per-arch +// Go compiler emits the correct byte layout. The remaining old-generator +// arches (freebsd/386, freebsd/arm) are not in build_all_targets and do +// not currently build for unrelated upstream reasons, so no shim is needed. +type pcacheMethods2 = sqlite3.Tsqlite3_pcache_methods2 + +// RegisterPageCache installs m as the process-global SQLite page +// cache via SQLITE_CONFIG_PCACHE2. It MUST be called before the first +// sql.Open or driver.Open in the program. +// +// Concurrency contract: +// +// - Safe to call concurrently with itself and with other Register* +// entry points. +// - Blocks until any sql.Open calls currently in progress complete. +// Trade-off: a Register call may block for the duration of an +// in-flight Open. WAL recovery or cold-file-lock contention can +// make that wait visible. +// - Once any connection has been opened, returns ErrPageCacheTooLate +// without mutating the global module slot. +// - Calling twice with the same module value is a no-op success. +// Calling twice with a different value returns ErrPageCacheConflict. +// - A failed first install is sticky: every subsequent Register call +// returns the same error. Mutating the module fields after the +// first successful Register is silently ignored because SQLite has +// already copied the C methods table. +func RegisterPageCache(m PageCache) error { + if m == nil { + return errors.New("sqlite: RegisterPageCache(nil)") + } + + pcacheState.openGate.Lock() + defer pcacheState.openGate.Unlock() + + // Idempotency / conflict / too-late checks before we touch the + // once. pcacheState.registered is non-nil only after a SUCCESSFUL + // install, so observing it here means a prior Register completed + // without returning configErr. + if pcacheState.registered != nil { + if pcacheState.registered == m { + return nil + } + if pcacheState.opened.Load() { + return ErrPageCacheTooLate + } + return ErrPageCacheConflict + } + if pcacheState.opened.Load() { + return ErrPageCacheTooLate + } + + // First-time install. The once body commits + // pcacheState.registered = m only after Xsqlite3_config succeeds. + // On OOM, SQLite error, or panic, configErr is set and registered + // stays nil; every subsequent Register returns configErr because + // the once is already fired. + pcacheState.configOnce.Do(func() { + defer func() { + if r := recover(); r != nil { + pcacheState.configErr = fmt.Errorf( + "sqlite: panic during PCACHE2 install: %v", r) + pcacheState.registered = nil + pcacheState.cMethods = 0 + } + }() + + tls := libc.NewTLS() + defer tls.Close() + + methodsPtr := libc.Xcalloc(tls, 1, types.Size_t(unsafe.Sizeof(pcacheMethods2{}))) + if methodsPtr == 0 { + pcacheState.configErr = errors.New("sqlite: out of memory allocating pcache_methods2") + return + } + populateCMethods(methodsPtr) + + varArgs := libc.Xmalloc(tls, types.Size_t(unsafe.Sizeof(uintptr(0)))) + if varArgs == 0 { + libc.Xfree(tls, methodsPtr) + pcacheState.configErr = errors.New("sqlite: out of memory allocating va_list") + return + } + defer libc.Xfree(tls, varArgs) + + rc := sqlite3.Xsqlite3_config(tls, + int32(sqlite3.SQLITE_CONFIG_PCACHE2), + libc.VaList(varArgs, methodsPtr)) + if rc != sqlite3.SQLITE_OK { + libc.Xfree(tls, methodsPtr) + pcacheState.configErr = fmt.Errorf( + "sqlite: Xsqlite3_config(SQLITE_CONFIG_PCACHE2) returned %d", rc) + return + } + + // Commit only after every fallible step succeeded. + pcacheState.cMethods = methodsPtr + pcacheState.registered = m + }) + + return pcacheState.configErr +} + +// MustRegisterPageCache is like RegisterPageCache but +// panics on any error. Intended for init() use where a missing page +// cache is fatal. Mirrors the precedent set by +// MustRegisterDeterministicScalarFunction. +func MustRegisterPageCache(m PageCache) { + if err := RegisterPageCache(m); err != nil { + panic(err) + } +} + +// populateCMethods fills the libc-owned SQLite C methods table with the +// addresses of the package-internal trampolines defined in +// pagecache_trampolines.go. The user's PageCache is reached +// through pcacheState.registered, which is set after this call returns +// successfully. Using top-level trampolines avoids passing user +// function values to cFuncPointer, which is undefined for closures and +// method values. +func populateCMethods(ptr uintptr) { + dst := (*pcacheMethods2)(unsafe.Pointer(ptr)) + dst.FiVersion = 1 + dst.FxInit = cFuncPointer(pcacheTrampolineInit) + dst.FxShutdown = cFuncPointer(pcacheTrampolineShutdown) + dst.FxCreate = cFuncPointer(pcacheTrampolineCreate) + dst.FxCachesize = cFuncPointer(pcacheTrampolineCachesize) + dst.FxPagecount = cFuncPointer(pcacheTrampolinePagecount) + dst.FxFetch = cFuncPointer(pcacheTrampolineFetch) + dst.FxUnpin = cFuncPointer(pcacheTrampolineUnpin) + dst.FxRekey = cFuncPointer(pcacheTrampolineRekey) + dst.FxTruncate = cFuncPointer(pcacheTrampolineTruncate) + dst.FxDestroy = cFuncPointer(pcacheTrampolineDestroy) + dst.FxShrink = cFuncPointer(pcacheTrampolineShrink) +} diff --git a/internal/engine/pagecache_trampolines.go b/internal/engine/pagecache_trampolines.go new file mode 100644 index 0000000..991453b --- /dev/null +++ b/internal/engine/pagecache_trampolines.go @@ -0,0 +1,388 @@ +// Copyright 2026 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite + +import ( + "math/bits" + "sync" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +// The pcache binding owns the sqlite3_pcache_page stub that SQLite sees +// and forwards user-facing calls to the registered PageCache and +// per-database Cache instances. The user-facing surface in +// pagecache.go is idiomatic Go; this file holds the package-internal +// trampolines that bridge to the cgo-free C ABI. +// +// Ownership model: +// +// - Each xCreate on the C side mints a fresh pcacheBinding and a +// uintptr handle from pcacheBindings.gen. SQLite stores the handle +// as its opaque sqlite3_pcache*; trampolines recover the binding +// via pcacheBindings.m under RLock. +// - Each xFetch on the C side maps a (binding, key) pair to a +// sqlite3_pcache_page stub allocated via libc.Xcalloc. The stub +// lives until Unpin(discard=true), a Truncate sweep covering the +// key, or Destroy on the owning cache. SQLite re-fetches for the +// same key return the same stub; this is the binding-side fix for +// the "stale pPgHdr->pPage" issue called out in MR #126's +// §2 design note. +// - The Page object the user returns from Cache.Fetch is held in +// the binding's byStub map so a Page-identity comparison on the +// next Fetch for the same key can short-circuit stub reallocation +// when the impl retains the entry. +// +// Threading invariant: all Cache callbacks for a single pcacheBinding +// are serialised by the SQLite engine. This driver opens every +// connection SQLITE_OPEN_FULLMUTEX without shared-cache mode, and +// database/sql never invokes one driver.Conn from two goroutines, so +// the Cache instance returned by xCreate is only ever touched from +// one goroutine at a time. The mutex on pcacheBinding protects the +// maps against any future shared-cache mode and against the +// cross-cache traffic that the package-global pcacheBindings +// registry would otherwise impose; under the current invariant it is +// uncontended. +type pcacheBinding struct { + mu sync.Mutex + cache Cache + byKey map[uint32]uintptr // key -> sqlite3_pcache_page stub uintptr + byStub map[uintptr]pcacheEntry // stub uintptr -> {Page, key} +} + +type pcacheEntry struct { + page Page + key uint32 +} + +// pcacheBindings is the package-global registry mapping the opaque +// sqlite3_pcache* handles SQLite sees to the *pcacheBinding they +// represent. Handles are minted from a bitset-backed allocator so they +// can be reclaimed on Destroy and stay small across the process +// lifetime (otherwise a long-running process that opens and closes many +// caches would grow the map without bound). +var pcacheBindings = struct { + mu sync.RWMutex + m map[uintptr]*pcacheBinding + gen pcacheIDGen +}{ + m: map[uintptr]*pcacheBinding{}, +} + +// lookupPcacheBinding returns the binding for the given C handle, or +// nil if the handle is unknown. It is called from every trampoline +// other than Init/Shutdown. +func lookupPcacheBinding(h uintptr) *pcacheBinding { + pcacheBindings.mu.RLock() + defer pcacheBindings.mu.RUnlock() + return pcacheBindings.m[h] +} + +// registerPcacheBinding installs b into the registry and returns the +// opaque handle SQLite will see. +func registerPcacheBinding(b *pcacheBinding) uintptr { + pcacheBindings.mu.Lock() + defer pcacheBindings.mu.Unlock() + h := pcacheBindings.gen.next() + pcacheBindings.m[h] = b + return h +} + +// unregisterPcacheBinding removes h from the registry and reclaims its +// ID slot. Called from pcacheTrampolineDestroy after the user's +// Destroy returns. +func unregisterPcacheBinding(h uintptr) { + pcacheBindings.mu.Lock() + defer pcacheBindings.mu.Unlock() + delete(pcacheBindings.m, h) + pcacheBindings.gen.reclaim(h) +} + +// pcacheIDGen is a bitset-backed allocator over uintptr handles +// starting at 1 (0 is reserved as a sentinel for "not registered"). +// Identical in shape to the vtab idGen at sqlite.go:808-824; reproduced +// here to keep the pcache subsystem self-contained. +type pcacheIDGen struct { + bitset []uint64 +} + +func (g *pcacheIDGen) next() uintptr { + base := uintptr(1) + for i := 0; i < len(g.bitset); i, base = i+1, base+64 { + b := g.bitset[i] + if b != 1<<64-1 { + n := uintptr(bits.TrailingZeros64(^b)) + g.bitset[i] |= 1 << n + return base + n + } + } + g.bitset = append(g.bitset, 1) + return base +} + +func (g *pcacheIDGen) reclaim(id uintptr) { + bit := id - 1 + g.bitset[bit/64] &^= 1 << (bit % 64) +} + +// Sentinel returned by the binding when SQLite asks for a stub but the +// user impl returned nil or the binding could not allocate. Translating +// to uintptr(0) tells SQLite to fall back to its stress path. +const pcacheNullStub uintptr = 0 + +// pcacheStubSize is the size of the sqlite3_pcache_page struct that +// SQLite reads: two uintptr fields (pBuf, pExtra). Computed at startup +// to keep the trampolines free of unsafe.Sizeof calls on the hot path. +var pcacheStubSize = types.Size_t(unsafe.Sizeof(uintptr(0)) * 2) + +// pcacheTrampolineInit is wired to sqlite3_pcache_methods2.xInit. The +// binding has no per-process state to set up at sqlite3_initialize +// time; PageCache.Create is invoked per database, not per +// initialize, and the package-global pcacheBindings registry is ready +// from package init. Returns SQLITE_OK unconditionally. +func pcacheTrampolineInit(tls *libc.TLS, arg uintptr) int32 { + return sqlite3.SQLITE_OK +} + +// pcacheTrampolineShutdown is wired to xShutdown. The binding does not +// call sqlite3_shutdown internally, so in normal operation this +// trampoline never fires; it exists so the C methods table never +// holds a null xShutdown slot when paired with custom user code that +// might trigger sqlite3_shutdown out of band. +func pcacheTrampolineShutdown(tls *libc.TLS, arg uintptr) {} + +// pcacheTrampolineCreate is wired to xCreate. SQLite asks the binding +// to create a new per-database cache. The trampoline calls +// PageCache.Create on the registered module and registers the +// returned Cache in pcacheBindings, handing SQLite back the opaque +// handle. +// +// szPage and szExtra are the sizes SQLite wants for each page's Buf +// and Extra buffers; szExtra is NOT just the application-visible +// extraSize, it already includes SQLite's PgHdr overhead. The +// Cache implementation must honour it as opaque. +// +// bPurgeable is advisory: 0 for in-memory databases (Unpin will only +// ever be called with discard=true), non-zero otherwise. +// +// A return of 0 tells SQLite the cache could not be created (treated +// as SQLITE_NOMEM by the caller in _sqlite3PcacheSetPageSize). +func pcacheTrampolineCreate(tls *libc.TLS, szPage, szExtra, bPurgeable int32) uintptr { + module := pcacheState.registered + if module == nil { + // Defensive: should be impossible because SQLite only consults + // the methods table after _sqlite3Config.Fpcache2 is installed, + // which happens only after registered is set. + return pcacheNullStub + } + cache, err := module.Create(int(szPage), int(szExtra), bPurgeable != 0) + if err != nil || cache == nil { + return pcacheNullStub + } + b := &pcacheBinding{ + cache: cache, + byKey: map[uint32]uintptr{}, + byStub: map[uintptr]pcacheEntry{}, + } + return registerPcacheBinding(b) +} + +// pcacheTrampolineCachesize forwards SQLite's xCachesize to +// Cache.SetSize. The size is advisory. +func pcacheTrampolineCachesize(tls *libc.TLS, pCache uintptr, nCachesize int32) { + b := lookupPcacheBinding(pCache) + if b == nil { + return + } + b.cache.SetSize(int(nCachesize)) +} + +// pcacheTrampolinePagecount forwards xPagecount to Cache.PageCount. +func pcacheTrampolinePagecount(tls *libc.TLS, pCache uintptr) int32 { + b := lookupPcacheBinding(pCache) + if b == nil { + return 0 + } + return int32(b.cache.PageCount()) +} + +// pcacheTrampolineFetch forwards xFetch to Cache.Fetch on every +// request. SQLite does not require that re-fetches for the same key +// return an identical sqlite3_pcache_page pointer: +// _sqlite3PcacheFetchFinish keys off whether pPage->pExtra is already +// initialised (PgHdr.pPage != 0); a fresh page (zeroed Extra) is just +// re-initialised. So the binding asks the impl on every call and only +// reuses the cached stub when the returned Page is the same value; +// when the impl evicts and replaces the entry the stale stub is +// retired and a fresh one minted. +// +// This makes a bounded, evicting purgeable cache (the normal way an +// impl honours cache_size) safe by construction: an impl that drops +// an entry on Unpin(discard=false) cannot leak a stale stub to +// SQLite because the next Fetch reaches the impl, observes the +// eviction (page == nil or a different Page), and the binding +// updates its bookkeeping accordingly. +func pcacheTrampolineFetch(tls *libc.TLS, pCache uintptr, key uint32, createFlag int32) uintptr { + b := lookupPcacheBinding(pCache) + if b == nil { + return pcacheNullStub + } + page := b.cache.Fetch(key, FetchMode(createFlag)) + + b.mu.Lock() + defer b.mu.Unlock() + old, had := b.byKey[key] + + if page == nil { + // Lookup miss, eviction, or OOM: retire any stale stub the + // binding still held for this key. The next Fetch with + // createFlag > 0 will re-allocate. + if had { + delete(b.byKey, key) + delete(b.byStub, old) + libc.Xfree(tls, old) + } + return pcacheNullStub + } + if had && b.byStub[old].page == page { + // Same Page value retained across the unpin/refetch cycle; + // reuse the existing stub. Buf and Extra addresses are stable + // while the page is pinned, which is exactly the window during + // which SQLite holds the stub pointer. + return old + } + if had { + // Page was replaced for this key (impl evicted and re-allocated + // fresh memory). Retire the stale stub before minting a new one; + // SQLite has already finished using the old stub by the time + // xUnpin returned. + delete(b.byStub, old) + libc.Xfree(tls, old) + } + stub := libc.Xcalloc(tls, 1, pcacheStubSize) + if stub == 0 { + delete(b.byKey, key) + return pcacheNullStub + } + f := (*[2]uintptr)(unsafe.Pointer(stub)) + f[0], f[1] = uintptr(page.Buf()), uintptr(page.Extra()) + b.byKey[key] = stub + b.byStub[stub] = pcacheEntry{page: page, key: key} + return stub +} + +// pcacheTrampolineUnpin forwards xUnpin to Cache.Unpin. When discard +// is non-zero the binding evicts: it frees the stub after the user's +// Unpin returns. When discard is zero the binding only forwards to +// the user; the cache MAY release or retain the page and its memory +// at its discretion. The next Fetch for the key consults the impl, +// so a release between unpin and the next fetch is observed and +// reflected in the binding's bookkeeping. +func pcacheTrampolineUnpin(tls *libc.TLS, pCache, pPage uintptr, discard int32) { + b := lookupPcacheBinding(pCache) + if b == nil { + return + } + b.mu.Lock() + entry, ok := b.byStub[pPage] + b.mu.Unlock() + if !ok { + return + } + b.cache.Unpin(entry.page, discard != 0) + if discard == 0 { + return + } + b.mu.Lock() + delete(b.byKey, entry.key) + delete(b.byStub, pPage) + b.mu.Unlock() + libc.Xfree(tls, pPage) +} + +// pcacheTrampolineRekey forwards xRekey to Cache.Rekey, then updates +// the binding's byKey map so a subsequent Fetch for newKey returns +// the same stub. If newKey already has a stub the spec guarantees +// the colliding entry is unpinned; the binding retires it. +func pcacheTrampolineRekey(tls *libc.TLS, pCache, pPage uintptr, oldKey, newKey uint32) { + b := lookupPcacheBinding(pCache) + if b == nil { + return + } + b.mu.Lock() + entry, ok := b.byStub[pPage] + b.mu.Unlock() + if !ok { + return + } + b.cache.Rekey(entry.page, oldKey, newKey) + b.mu.Lock() + defer b.mu.Unlock() + if collider, ok := b.byKey[newKey]; ok && collider != pPage { + delete(b.byKey, newKey) + delete(b.byStub, collider) + libc.Xfree(tls, collider) + } + delete(b.byKey, oldKey) + b.byKey[newKey] = pPage + entry.key = newKey + b.byStub[pPage] = entry +} + +// pcacheTrampolineTruncate forwards xTruncate to Cache.Truncate +// and then sweeps every binding-owned stub whose key is greater than +// or equal to limit. SQLite documents Truncate as the only callback +// permitted to evict a pinned page, so the binding does the eviction +// unconditionally. +func pcacheTrampolineTruncate(tls *libc.TLS, pCache uintptr, iLimit uint32) { + b := lookupPcacheBinding(pCache) + if b == nil { + return + } + b.cache.Truncate(iLimit) + b.mu.Lock() + for key, stub := range b.byKey { + if key >= iLimit { + delete(b.byKey, key) + delete(b.byStub, stub) + libc.Xfree(tls, stub) + } + } + b.mu.Unlock() +} + +// pcacheTrampolineDestroy forwards xDestroy to Cache.Destroy, +// frees every remaining stub, and removes the binding from the +// registry. After this trampoline returns the SQLite handle is no +// longer valid and the binding instance is unreachable. +func pcacheTrampolineDestroy(tls *libc.TLS, pCache uintptr) { + b := lookupPcacheBinding(pCache) + if b == nil { + return + } + b.cache.Destroy() + b.mu.Lock() + for _, stub := range b.byKey { + libc.Xfree(tls, stub) + } + b.byKey = nil + b.byStub = nil + b.mu.Unlock() + unregisterPcacheBinding(pCache) +} + +// pcacheTrampolineShrink forwards xShrink to Cache.Shrink. SQLite +// calls this as a memory-pressure hint; the user impl is free to +// ignore it. +func pcacheTrampolineShrink(tls *libc.TLS, pCache uintptr) { + b := lookupPcacheBinding(pCache) + if b == nil { + return + } + b.cache.Shrink() +} diff --git a/internal/engine/pre_update_hook.go b/internal/engine/pre_update_hook.go new file mode 100644 index 0000000..b4a5f03 --- /dev/null +++ b/internal/engine/pre_update_hook.go @@ -0,0 +1,227 @@ +package sqlite + +import ( + "errors" + "fmt" + "sync" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +var ( + xPreUpdateHandlers = struct { + mu sync.RWMutex + m map[uintptr]func(SQLitePreUpdateData) + }{ + m: make(map[uintptr]func(SQLitePreUpdateData)), + } + xCommitHandlers = struct { + mu sync.RWMutex + m map[uintptr]CommitHookFn + }{ + m: make(map[uintptr]CommitHookFn), + } + xRollbackHandlers = struct { + mu sync.RWMutex + m map[uintptr]RollbackHookFn + }{ + m: make(map[uintptr]RollbackHookFn), + } +) + +type PreUpdateHookFn func(SQLitePreUpdateData) + +func (c *conn) RegisterPreUpdateHook(callback PreUpdateHookFn) { + + if callback == nil { + xPreUpdateHandlers.mu.Lock() + delete(xPreUpdateHandlers.m, c.db) + xPreUpdateHandlers.mu.Unlock() + sqlite3.Xsqlite3_preupdate_hook(c.tls, c.db, uintptr(unsafe.Pointer(nil)), uintptr(unsafe.Pointer(nil))) + return + } + xPreUpdateHandlers.mu.Lock() + xPreUpdateHandlers.m[c.db] = callback + xPreUpdateHandlers.mu.Unlock() + + sqlite3.Xsqlite3_preupdate_hook(c.tls, c.db, cFuncPointer(preUpdateHookTrampoline), c.db) +} + +type CommitHookFn func() int32 + +func (c *conn) RegisterCommitHook(callback CommitHookFn) { + if callback == nil { + xCommitHandlers.mu.Lock() + delete(xCommitHandlers.m, c.db) + xCommitHandlers.mu.Unlock() + sqlite3.Xsqlite3_commit_hook(c.tls, c.db, uintptr(unsafe.Pointer(nil)), uintptr(unsafe.Pointer(nil))) + return + } + xCommitHandlers.mu.Lock() + xCommitHandlers.m[c.db] = callback + xCommitHandlers.mu.Unlock() + sqlite3.Xsqlite3_commit_hook(c.tls, c.db, cFuncPointer(commitHookTrampoline), c.db) +} + +type RollbackHookFn func() + +func (c *conn) RegisterRollbackHook(callback RollbackHookFn) { + if callback == nil { + xRollbackHandlers.mu.Lock() + delete(xRollbackHandlers.m, c.db) + xRollbackHandlers.mu.Unlock() + sqlite3.Xsqlite3_rollback_hook(c.tls, c.db, uintptr(unsafe.Pointer(nil)), uintptr(unsafe.Pointer(nil))) + return + } + xRollbackHandlers.mu.Lock() + xRollbackHandlers.m[c.db] = callback + xRollbackHandlers.mu.Unlock() + sqlite3.Xsqlite3_rollback_hook(c.tls, c.db, cFuncPointer(rollbackHookTrampoline), c.db) +} + +type SQLitePreUpdateData struct { + tls *libc.TLS + pCsr uintptr + Op int32 + DatabaseName string + TableName string + OldRowID int64 + NewRowID int64 +} + +// Depth returns the source path of the write, see sqlite3_preupdate_depth() +func (d *SQLitePreUpdateData) Depth() int { + return int(sqlite3.Xsqlite3_preupdate_depth(d.tls, d.pCsr)) +} + +// Count returns the number of columns in the row +func (d *SQLitePreUpdateData) Count() int { + return int(sqlite3.Xsqlite3_preupdate_count(d.tls, d.pCsr)) +} + +func (d *SQLitePreUpdateData) row(dest []any, new bool) error { + count := d.Count() + ppValue, err := mallocValue(d.tls) + if err != nil { + return err + } + defer libc.Xfree(d.tls, ppValue) + + for i := 0; i < count && i < len(dest); i++ { + val, err := d.value(ppValue, i, new) + if err != nil { + return err + } + err = convertAssign(&dest[i], val) + if err != nil { + return err + } + } + return nil +} + +// Old populates dest with the row data to be replaced. This works similar to +// database/sql's Rows.Scan() +func (d *SQLitePreUpdateData) Old(dest ...any) error { + if d.Op == sqlite3.SQLITE_INSERT { + return errors.New("there is no old row for INSERT operations") + } + return d.row(dest, false) +} + +// New populates dest with the replacement row data. This works similar to +// database/sql's Rows.Scan() +func (d *SQLitePreUpdateData) New(dest ...any) error { + if d.Op == sqlite3.SQLITE_DELETE { + return errors.New("there is no new row for DELETE operations") + } + return d.row(dest, true) +} + +const ptrValSize = types.Size_t(unsafe.Sizeof(&sqlite3.Sqlite3_value{})) + +func mallocValue(tls *libc.TLS) (uintptr, error) { + p := libc.Xmalloc(tls, ptrValSize) + if p == 0 { + return 0, fmt.Errorf("out of memory") + } + return p, nil +} + +func (d *SQLitePreUpdateData) value(ppValue uintptr, i int, new bool) (any, error) { + var src any + if new { + sqlite3.Xsqlite3_preupdate_new(d.tls, d.pCsr, int32(i), ppValue) + } else { + sqlite3.Xsqlite3_preupdate_old(d.tls, d.pCsr, int32(i), ppValue) + } + ptrValue := *(*uintptr)(unsafe.Pointer(ppValue)) + switch sqlite3.Xsqlite3_value_type(d.tls, ptrValue) { + case sqlite3.SQLITE_INTEGER: + src = int64(sqlite3.Xsqlite3_value_int64(d.tls, ptrValue)) + case sqlite3.SQLITE_FLOAT: + src = float64(sqlite3.Xsqlite3_value_double(d.tls, ptrValue)) + case sqlite3.SQLITE_BLOB: + size := sqlite3.Xsqlite3_value_bytes(d.tls, ptrValue) + blobPtr := sqlite3.Xsqlite3_value_blob(d.tls, ptrValue) + + var v []byte + if size != 0 { + v = make([]byte, size) + copy(v, (*libc.RawMem)(unsafe.Pointer(blobPtr))[:size:size]) + } + src = v + case sqlite3.SQLITE_TEXT: + src = libc.GoString(sqlite3.Xsqlite3_value_text(d.tls, ptrValue)) + case sqlite3.SQLITE_NULL: + src = nil + } + return src, nil +} + +func preUpdateHookTrampoline(tls *libc.TLS, handle uintptr, pCsr uintptr, op int32, zDb uintptr, pTab uintptr, iKey1 int64, iKey2 int64) { + xPreUpdateHandlers.mu.RLock() + xPreUpdateHandler := xPreUpdateHandlers.m[handle] + xPreUpdateHandlers.mu.RUnlock() + + if xPreUpdateHandler == nil { + return + } + data := SQLitePreUpdateData{ + tls: tls, + pCsr: pCsr, + Op: op, + DatabaseName: libc.GoString(zDb), + TableName: libc.GoString(pTab), + OldRowID: iKey1, + NewRowID: iKey2, + } + xPreUpdateHandler(data) +} + +func commitHookTrampoline(tls *libc.TLS, handle uintptr) int32 { + xCommitHandlers.mu.RLock() + xCommitHandler := xCommitHandlers.m[handle] + xCommitHandlers.mu.RUnlock() + + if xCommitHandler == nil { + return 0 + } + + return xCommitHandler() +} + +func rollbackHookTrampoline(tls *libc.TLS, handle uintptr) { + xRollbackHandlers.mu.RLock() + xRollbackHandler := xRollbackHandlers.m[handle] + xRollbackHandlers.mu.RUnlock() + + if xRollbackHandler == nil { + return + } + + xRollbackHandler() +} diff --git a/internal/engine/result.go b/internal/engine/result.go new file mode 100644 index 0000000..1dc6a8d --- /dev/null +++ b/internal/engine/result.go @@ -0,0 +1,42 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +type result struct { + lastInsertID int64 + rowsAffected int +} + +func newResult(c *conn) (_ *result, err error) { + r := &result{} + if r.rowsAffected, err = c.changes(); err != nil { + return nil, err + } + + if r.lastInsertID, err = c.lastInsertRowID(); err != nil { + return nil, err + } + + return r, nil +} + +// LastInsertId returns the database's auto-generated ID after, for example, an +// INSERT into a table with primary key. +func (r *result) LastInsertId() (int64, error) { + if r == nil { + return 0, nil + } + + return r.lastInsertID, nil +} + +// RowsAffected returns the number of rows affected by the query. +func (r *result) RowsAffected() (int64, error) { + if r == nil { + return 0, nil + } + + return int64(r.rowsAffected), nil +} diff --git a/internal/engine/rows.go b/internal/engine/rows.go new file mode 100644 index 0000000..a20df5b --- /dev/null +++ b/internal/engine/rows.go @@ -0,0 +1,334 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "database/sql/driver" + "fmt" + "io" + "math" + "reflect" + "strings" + "time" + + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +type rows struct { + allocs []uintptr + c *conn + columns []string + // decltypes holds the uppercased declared types for every result column, + // captured once at newRows time. The declared type of a column is fixed + // for the lifetime of a prepared statement, so caching the result of + // strings.ToUpper(sqlite3_column_decltype(...)) here removes a per-row + // libc.GoString + strings.ToUpper from the Next() hot path for callers + // that hit the time-conversion branches (_texttotime, _time_format). + decltypes []string + // parseFmtIdx caches, per column, the index into parseTimeFormats that + // matched the first successful (*conn).parseTime call on that column. + // Subsequent rows reuse the saved index as the first attempt instead of + // re-walking the format list from the top. Slot value -1 means no match + // has been recorded yet (either parseTime has not run on this column, or + // the parseTimeString / m= branch matched, which is not in + // parseTimeFormats). The cache is sticky: once a successful index is + // stored it is not overwritten if a later row happens to match a + // different format. A steady-format column therefore wins on every row + // after the first; a mixed-format column falls through as before, paying + // at most one extra format probe on rows whose matching format precedes + // the cached one. + parseFmtIdx []int8 + pstmt uintptr + + doStep bool + empty bool + reuseStmt bool // If true, Close() resets instead of finalizing +} + +func newRows(c *conn, pstmt uintptr, allocs *[]uintptr, empty bool) (r *rows, err error) { + var a []uintptr + if allocs != nil { + a = *allocs + *allocs = nil + } + r = &rows{c: c, pstmt: pstmt, allocs: a, empty: empty} + + defer func() { + if err != nil { + r.Close() + r = nil + } + }() + + n, err := c.columnCount(pstmt) + if err != nil { + return nil, err + } + + r.columns = make([]string, n) + r.decltypes = make([]string, n) + r.parseFmtIdx = make([]int8, n) + for i := range r.columns { + if r.columns[i], err = r.c.columnName(pstmt, i); err != nil { + return nil, err + } + r.decltypes[i] = strings.ToUpper(r.c.columnDeclType(pstmt, i)) + r.parseFmtIdx[i] = -1 + } + + return r, nil +} + +// Close closes the rows iterator. +func (r *rows) Close() (err error) { + r.c.freeAllocs(r.allocs) + r.allocs = nil + + if r.reuseStmt { + // Reset the statement for reuse instead of finalizing it + if e := r.c.reset(r.pstmt); e != nil { + return e + } + return r.c.clearBindings(r.pstmt) + } + + return r.c.finalize(r.pstmt) +} + +// Columns returns the names of the columns. The number of columns of the +// result is inferred from the length of the slice. If a particular column name +// isn't known, an empty string should be returned for that entry. +func (r *rows) Columns() (c []string) { + return r.columns +} + +// Next is called to populate the next row of data into the provided slice. The +// provided slice will be the same size as the Columns() are wide. +// +// Next should return io.EOF when there are no more rows. +func (r *rows) Next(dest []driver.Value) (err error) { + if r.empty { + return io.EOF + } + + rc := sqlite3.SQLITE_ROW + if r.doStep { + if rc, err = r.c.step(r.pstmt); err != nil { + return err + } + } + + r.doStep = true + switch rc { + case sqlite3.SQLITE_ROW: + if g, e := len(dest), len(r.columns); g != e { + return fmt.Errorf("sqlite: Next: have %v destination values, expected %v", g, e) + } + + for i := range dest { + ct, err := r.c.columnType(r.pstmt, i) + if err != nil { + return err + } + + switch ct { + case sqlite3.SQLITE_INTEGER: + v, err := r.c.columnInt64(r.pstmt, i) + if err != nil { + return err + } + + if !r.c.intToTime { + dest[i] = v + } else { + // Inspired by mattn/go-sqlite3: + // https://github.com/mattn/go-sqlite3/blob/f76bae4b0044cbba8fb2c72b8e4559e8fbcffd86/sqlite3.go#L2254-L2262 + // but we put make this compatibility optional behind a DSN + // query parameter, because this changes API behavior, so an + // opt-in is needed. + + switch r.ColumnTypeDatabaseTypeName(i) { + case "DATE", "DATETIME", "TIMESTAMP": + // Check for explicit opt-in first. This fixes the bug for micro/nano users + // without breaking the legacy heuristic for existing users. + switch r.c.integerTimeFormat { + case "unix_micro": + dest[i] = r.c.applyTimezone(time.UnixMicro(v).UTC()) + continue + case "unix_nano": + dest[i] = r.c.applyTimezone(time.Unix(0, v).UTC()) + continue + } + + // Legacy Heuristic (mattn/go-sqlite3 compatibility). NOTE: This heuristic + // fails for Millisecond timestamps representing dates before Sept 9, 2001 + // (value < 1e12). + + // Is it a seconds timestamp or a milliseconds + // timestamp? + if v > 1e12 || v < -1e12 { + // Milliseconds + dest[i] = r.c.applyTimezone(time.UnixMilli(v).UTC()) + } else { + // Seconds + dest[i] = r.c.applyTimezone(time.Unix(v, 0).UTC()) + } + default: + dest[i] = v + } + } + case sqlite3.SQLITE_FLOAT: + v, err := r.c.columnDouble(r.pstmt, i) + if err != nil { + return err + } + + dest[i] = v + case sqlite3.SQLITE_TEXT: + v, err := r.c.columnText(r.pstmt, i) + if err != nil { + return err + } + + switch r.ColumnTypeDatabaseTypeName(i) { + case "DATE", "DATETIME", "TIMESTAMP": + val, ok, idx := r.c.parseTime(v, int(r.parseFmtIdx[i])) + if ok && r.parseFmtIdx[i] < 0 && idx >= 0 { + r.parseFmtIdx[i] = int8(idx) + } + dest[i] = val + default: + dest[i] = v + } + case sqlite3.SQLITE_BLOB: + v, err := r.c.columnBlob(r.pstmt, i) + if err != nil { + return err + } + + dest[i] = v + case sqlite3.SQLITE_NULL: + dest[i] = nil + default: + return fmt.Errorf("internal error: rc %d", rc) + } + } + return nil + case sqlite3.SQLITE_DONE: + return io.EOF + default: + return r.c.errstr(int32(rc)) + } +} + +// RowsColumnTypeDatabaseTypeName may be implemented by Rows. It should return +// the database system type name without the length. Type names should be +// uppercase. Examples of returned types: "VARCHAR", "NVARCHAR", "VARCHAR2", +// "CHAR", "TEXT", "DECIMAL", "SMALLINT", "INT", "BIGINT", "BOOL", "[]BIGINT", +// "JSONB", "XML", "TIMESTAMP". +func (r *rows) ColumnTypeDatabaseTypeName(index int) string { + return r.decltypes[index] +} + +// RowsColumnTypeLength may be implemented by Rows. It should return the length +// of the column type if the column is a variable length type. If the column is +// not a variable length type ok should return false. If length is not limited +// other than system limits, it should return math.MaxInt64. The following are +// examples of returned values for various types: +// +// TEXT (math.MaxInt64, true) +// varchar(10) (10, true) +// nvarchar(10) (10, true) +// decimal (0, false) +// int (0, false) +// bytea(30) (30, true) +func (r *rows) ColumnTypeLength(index int) (length int64, ok bool) { + t, err := r.c.columnType(r.pstmt, index) + if err != nil { + return 0, false + } + + switch t { + case sqlite3.SQLITE_INTEGER: + return 0, false + case sqlite3.SQLITE_FLOAT: + return 0, false + case sqlite3.SQLITE_TEXT: + return math.MaxInt64, true + case sqlite3.SQLITE_BLOB: + return math.MaxInt64, true + case sqlite3.SQLITE_NULL: + return 0, false + default: + return 0, false + } +} + +// RowsColumnTypeNullable may be implemented by Rows. The nullable value should +// be true if it is known the column may be null, or false if the column is +// known to be not nullable. If the column nullability is unknown, ok should be +// false. +func (r *rows) ColumnTypeNullable(index int) (nullable, ok bool) { + return true, true +} + +// RowsColumnTypePrecisionScale may be implemented by Rows. It should return +// the precision and scale for decimal types. If not applicable, ok should be +// false. The following are examples of returned values for various types: +// +// decimal(38, 4) (38, 4, true) +// int (0, 0, false) +// decimal (math.MaxInt64, math.MaxInt64, true) +func (r *rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) { + return 0, 0, false +} + +// RowsColumnTypeScanType may be implemented by Rows. It should return the +// value type that can be used to scan types into. For example, the database +// column type "bigint" this should return "reflect.TypeOf(int64(0))". +func (r *rows) ColumnTypeScanType(index int) reflect.Type { + t, err := r.c.columnType(r.pstmt, index) + if err != nil { + return reflect.TypeOf("") + } + + switch t { + case sqlite3.SQLITE_INTEGER: + switch r.decltypes[index] { + case "BOOLEAN": + return reflect.TypeOf(false) + case "DATE", "DATETIME", "TIME", "TIMESTAMP": + return reflect.TypeOf(time.Time{}) + default: + return reflect.TypeOf(int64(0)) + } + case sqlite3.SQLITE_FLOAT: + return reflect.TypeOf(float64(0)) + case sqlite3.SQLITE_TEXT: + if r.c.textToTime { + switch r.decltypes[index] { + case "DATE", "DATETIME", "TIME", "TIMESTAMP": + return reflect.TypeOf(time.Time{}) + } + } + return reflect.TypeOf("") + case sqlite3.SQLITE_BLOB: + return reflect.TypeOf([]byte(nil)) + case sqlite3.SQLITE_NULL: + return reflect.TypeOf(nil) + default: + return reflect.TypeOf("") + } +} + +// C documentation +// +// int sqlite3_reset(sqlite3_stmt *pStmt); +func (c *conn) reset(pstmt uintptr) error { + if rc := sqlite3.Xsqlite3_reset(c.tls, pstmt); rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + return nil +} diff --git a/internal/engine/rulimit.go b/internal/engine/rulimit.go new file mode 100644 index 0000000..c449efb --- /dev/null +++ b/internal/engine/rulimit.go @@ -0,0 +1,19 @@ +// Copyright 2021 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux || darwin || netbsd || openbsd +// +build linux darwin netbsd openbsd + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "golang.org/x/sys/unix" +) + +func setMaxOpenFiles(n int64) error { + var rLimit unix.Rlimit + rLimit.Max = uint64(n) + rLimit.Cur = uint64(n) + return unix.Setrlimit(unix.RLIMIT_NOFILE, &rLimit) +} diff --git a/internal/engine/sqlite.go b/internal/engine/sqlite.go new file mode 100644 index 0000000..75bd4f2 --- /dev/null +++ b/internal/engine/sqlite.go @@ -0,0 +1,1144 @@ +// Copyright 2017 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:generate go run generator.go -full-path-comments + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "context" + "database/sql" + "database/sql/driver" + "errors" + "fmt" + "math/bits" + "net/url" + "runtime" + "sort" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +var ( + _ driver.Conn = (*conn)(nil) + _ driver.Driver = (*Driver)(nil) + //lint:ignore SA1019 TODO implement ExecerContext + _ driver.Execer = (*conn)(nil) + //lint:ignore SA1019 TODO implement QueryerContext + _ driver.Queryer = (*conn)(nil) + _ driver.Result = (*result)(nil) + _ driver.Rows = (*rows)(nil) + _ driver.RowsColumnTypeDatabaseTypeName = (*rows)(nil) + _ driver.RowsColumnTypeLength = (*rows)(nil) + _ driver.RowsColumnTypeNullable = (*rows)(nil) + _ driver.RowsColumnTypePrecisionScale = (*rows)(nil) + _ driver.RowsColumnTypeScanType = (*rows)(nil) + _ driver.Stmt = (*stmt)(nil) + _ driver.Tx = (*tx)(nil) + _ error = (*Error)(nil) +) + +const ( + driverName = "sqlite" + ptrSize = unsafe.Sizeof(uintptr(0)) + sqliteLockedSharedcache = sqlite3.SQLITE_LOCKED | (1 << 8) +) + +func init() { + sql.Register(driverName, newDriver()) + sqlite3.PatchIssue199() // https://gitlab.com/cznic/sqlite/-/issues/199 + +} + +// Inspired by mattn/go-sqlite3: https://github.com/mattn/go-sqlite3/blob/ab91e934/sqlite3.go#L210-L226 +// +// These time.Parse formats handle formats 1 through 7 listed at https://www.sqlite.org/lang_datefunc.html. +var parseTimeFormats = []string{ + "2006-01-02 15:04:05.999999999-07:00", + "2006-01-02T15:04:05.999999999-07:00", + "2006-01-02 15:04:05.999999999", + "2006-01-02T15:04:05.999999999", + "2006-01-02 15:04", + "2006-01-02T15:04", + "2006-01-02", +} + +// interruptOnDone sets up a goroutine to interrupt the provided db when the +// context is canceled, and returns a function the caller must defer so it +// doesn't interrupt after the caller finishes. +func interruptOnDone( + ctx context.Context, + c *conn, + done *int32, +) func() { + if done == nil { + var d int32 + done = &d + } + // donemu prevents a TOCTOU logical race between checking the done flag and + // calling interrupt in the select statement below. + var donemu sync.Mutex + + donech := make(chan struct{}) + + go func() { + select { + case <-ctx.Done(): + // don't call interrupt if we were already done: it indicates that this + // call to exec is no longer running and we would be interrupting + // nothing, or even possibly an unrelated later call to exec. + donemu.Lock() + if atomic.CompareAndSwapInt32(done, 0, 1) { + c.interrupt(c.db) + } + donemu.Unlock() + case <-donech: + } + }() + + // the caller is expected to defer this function + return func() { + // set the done flag so that a context cancellation right after the caller + // returns doesn't trigger a call to interrupt for some other statement. + donemu.Lock() + atomic.StoreInt32(done, 1) + donemu.Unlock() + close(donech) + } +} + +func getVFSName(query string) (r string, err error) { + q, err := url.ParseQuery(query) + if err != nil { + return "", err + } + + for _, v := range q["vfs"] { + if r != "" && r != v { + return "", fmt.Errorf("conflicting vfs query parameters: %v", q["vfs"]) + } + + r = v + } + + return r, nil +} + +// applyDQSConfig consults the _dqs DSN query parameter and, when set to a +// false value, disables SQLite's double-quoted string literal compatibility +// quirk on the connection by calling sqlite3_db_config with both +// SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML. Absence or a true +// value leaves SQLite's default (DQS enabled) untouched. +// +// Called from newConn after sqlite3_open_v2 and before applyQueryParams. +// The DBCONFIG_DQS_* flags are required to be set before any statement is +// prepared on the connection, and applyQueryParams runs user-supplied +// PRAGMA statements, so this must come first. +// +// See https://www.sqlite.org/quirks.html#dblquote and +// https://gitlab.com/cznic/sqlite/-/issues/61. +func applyDQSConfig(c *conn, query string) error { + q, err := url.ParseQuery(query) + if err != nil { + return err + } + v := q.Get("_dqs") + if v == "" { + return nil + } + on, err := strconv.ParseBool(v) + if err != nil { + return fmt.Errorf("invalid _dqs value %q: %w", v, err) + } + if on { + // _dqs=1 is the SQLite default; nothing to do. + return nil + } + for _, op := range []int32{ + sqlite3.SQLITE_DBCONFIG_DQS_DDL, + sqlite3.SQLITE_DBCONFIG_DQS_DML, + } { + if rc := c.dbConfigBool(op, false); rc != sqlite3.SQLITE_OK { + return fmt.Errorf("sqlite3_db_config(op=%d, off) returned %d", op, rc) + } + } + return nil +} + +// getErrorRcMode reads the _error_rc DSN query parameter and returns +// the parsed boolean. Called from newConn before sqlite3_open_v2 so +// open-time failures get the conditional errmsg treatment too: the +// temporary db handle that openV2 may leave behind on failure carries +// a stale errmsg from earlier initialisation, and the legacy +// "errstr: errmsg" form surfaces that as a misleading message. +// +// Absent parameter or false value preserves the SQLite-default error +// reporting byte-for-byte (legacy behavior). A true value switches +// the connection into the conditional mode described on +// errstrForDB. An unparseable value is reported as a descriptive +// error. +// +// See #230. +func getErrorRcMode(query string) (bool, error) { + q, err := url.ParseQuery(query) + if err != nil { + return false, err + } + v := q.Get("_error_rc") + if v == "" { + return false, nil + } + on, err := strconv.ParseBool(v) + if err != nil { + return false, fmt.Errorf("invalid _error_rc value %q: %w", v, err) + } + return on, nil +} + +func applyQueryParams(c *conn, query string) error { + q, err := url.ParseQuery(query) + if err != nil { + return err + } + + // _reserve_bytes=N sets SQLITE_FCNTL_RESERVE_BYTES before ANY writing pragma + // (journal_mode=WAL touches page 1). The pure-Go SQLCipher codec VFS needs an + // 80-byte per-page reserve for the IV+HMAC trailer; on a new database this must + // be set before page 1 is written. + if v := q.Get("_reserve_bytes"); v != "" { + n, err := strconv.Atoi(v) + if err != nil || n < 0 || n > 255 { + return fmt.Errorf("invalid _reserve_bytes %q", v) + } + if err := c.fileControlReserveBytes(n); err != nil { + return err + } + } + + var a []string + for _, v := range q["_pragma"] { + a = append(a, v) + } + // Push 'busy_timeout' first, the rest in lexicographic order, case insenstive. + // See https://gitlab.com/cznic/sqlite/-/issues/198#note_2233423463 for + // discussion. + sort.Slice(a, func(i, j int) bool { + x, y := strings.TrimSpace(strings.ToLower(a[i])), strings.TrimSpace(strings.ToLower(a[j])) + if strings.HasPrefix(x, "busy_timeout") { + return true + } + if strings.HasPrefix(y, "busy_timeout") { + return false + } + + return x < y + }) + for _, v := range a { + cmd := "pragma " + v + _, err := c.exec(context.Background(), cmd, nil) + if err != nil { + return err + } + } + + if v := q.Get("_time_format"); v != "" { + f, ok := writeTimeFormats[v] + if !ok { + return fmt.Errorf("unknown _time_format %q", v) + } + c.writeTimeFormat = f + } + if v := q.Get("_time_integer_format"); v != "" { + switch v { + case "unix": + case "unix_milli": + case "unix_micro": + case "unix_nano": + default: + return fmt.Errorf("unknown _time_integer_format %q", v) + } + c.integerTimeFormat = v + } + + if v := q.Get("_timezone"); v != "" { + loc, err := time.LoadLocation(v) + if err != nil { + return fmt.Errorf("unknown _timezone %q: %w", v, err) + } + c.loc = loc + } + + if v := q.Get("_txlock"); v != "" { + lower := strings.ToLower(v) + if lower != "deferred" && lower != "immediate" && lower != "exclusive" { + return fmt.Errorf("unknown _txlock %q", v) + } + c.beginMode = v + } + + if v := q.Get("_inttotime"); v != "" { + onoff, err := strconv.ParseBool(v) + if err != nil { + return fmt.Errorf("unknown _inttotime %q, must be 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False", + v) + } + c.intToTime = onoff + } + + if v := q.Get("_texttotime"); v != "" { + onoff, err := strconv.ParseBool(v) + if err != nil { + return fmt.Errorf("unknown _texttotime %q, must be 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False", + v) + } + c.textToTime = onoff + } + + return nil +} + +func unlockNotify(t *libc.TLS, ppArg uintptr, nArg int32) { + for i := int32(0); i < nArg; i++ { + mu := *(*uintptr)(unsafe.Pointer(ppArg)) + (*mutex)(unsafe.Pointer(mu)).Unlock() + ppArg += ptrSize + } +} + +// FunctionImpl describes an [application-defined SQL function]. If Scalar is +// set, it is treated as a scalar function; otherwise, it is treated as an +// aggregate function using MakeAggregate. +// +// [application-defined SQL function]: https://sqlite.org/appfunc.html +type FunctionImpl struct { + // NArgs is the required number of arguments that the function accepts. + // If NArgs is negative, then the function is variadic. + NArgs int32 + + // If Deterministic is true, the function must always give the same + // output when the input parameters are the same. This enables functions + // to be used in additional contexts like the WHERE clause of partial + // indexes and enables additional optimizations. + // + // See https://sqlite.org/c3ref/c_deterministic.html#sqlitedeterministic + // for more details. + Deterministic bool + + // Scalar is called when a scalar function is invoked in SQL. The + // argument Values are not valid past the return of the function. + Scalar func(ctx *FunctionContext, args []driver.Value) (driver.Value, error) + + // MakeAggregate is called at the beginning of each evaluation of an + // aggregate function. + MakeAggregate func(ctx FunctionContext) (AggregateFunction, error) + + // VolatileArgs is an opt-in performance flag that eliminates the per-call + // allocation of string and []byte argument bodies. When true, the driver + // passes argument strings and byte slices as zero-copy views into + // SQLite-owned memory instead of Go-allocated copies. + // + // Setting this is unsafe unless the user-provided Scalar / Step / + // WindowInverse callbacks treat string and []byte arguments as strictly + // transient: they must not be retained past the return of the call, + // neither directly (storing the slice or string in a struct field, map, + // channel, or outer-scope variable) nor indirectly (passing them to + // something that captures them, including most concurrency primitives). + // + // Retaining a volatile argument produces silent data corruption: SQLite + // reuses the underlying buffer for the next row, so on a later read every + // retained value will appear to hold the contents of the most recent row. + // The Go race detector cannot catch this because UDF execution is + // sequential on a single goroutine; the corruption is deterministic and + // invisible to -race. + // + // As a guard against accidental capture, callbacks that must retain + // values across rows should copy: + // + // saved := append([]byte(nil), args[0].([]byte)...) // []byte + // saved := string(append([]byte(nil), args[0].(string)...)) // string, no aliasing + // + // When in doubt, leave VolatileArgs at its default (false) — the driver + // already pools the argument-slice header (issue #226), so the per-row + // overhead with VolatileArgs=false is one make([]byte) per BLOB column + // and one libc.GoString per TEXT column, not a fresh slice header. + // + // Similarly, do not re-enter SQLite on the same connection while a + // volatile argument is in scope. A nested Query/Exec on the same conn + // can cause SQLite to reuse the underlying value buffers, so a volatile + // string or []byte read before the nested call may alias different + // bytes after it returns. + // + // VolatileArgs has no effect on integer, float, time, or NULL arguments. + VolatileArgs bool +} + +// An AggregateFunction is an invocation of an aggregate or window function. See +// the documentation for [aggregate function callbacks] and [application-defined +// window functions] for an overview. +// +// [aggregate function callbacks]: https://www.sqlite.org/appfunc.html#the_aggregate_function_callbacks +// [application-defined window functions]: https://www.sqlite.org/windowfunctions.html#user_defined_aggregate_window_functions +type AggregateFunction interface { + // Step is called for each row of an aggregate function's SQL + // invocation. The argument Values are not valid past the return of the + // function. When the aggregate was registered with + // [FunctionImpl.VolatileArgs] set to true, string and []byte arguments + // in rowArgs are zero-copy views into SQLite-owned memory and retaining + // them produces silent data corruption — see [FunctionImpl.VolatileArgs] + // for the full safety contract. + Step(ctx *FunctionContext, rowArgs []driver.Value) error + + // WindowInverse is called to remove the oldest presently aggregated + // result of Step from the current window. The arguments are those + // passed to Step for the row being removed. The argument Values are not + // valid past the return of the function. The same + // [FunctionImpl.VolatileArgs] caveat applies as for Step. + WindowInverse(ctx *FunctionContext, rowArgs []driver.Value) error + + // WindowValue is called to get the current value of an aggregate + // function. This is used to return the final value of the function, + // whether it is used as a window function or not. + WindowValue(ctx *FunctionContext) (driver.Value, error) + + // Final is called after all of the aggregate function's input rows have + // been stepped through. No other methods will be called on the + // AggregateFunction after calling Final. WindowValue returns the value + // from the function. + Final(ctx *FunctionContext) +} + +type collation struct { + zName uintptr + pApp uintptr + enc int32 +} + +// RegisterCollationUtf8 makes a Go function available as a collation named zName. +// impl receives two UTF-8 strings: left and right. +// The result needs to be: +// +// - 0 if left == right +// - 1 if left < right +// - +1 if left > right +// +// impl must always return the same result given the same inputs. +// Additionally, it must have the following properties for all strings A, B and C: +// - if A==B, then B==A +// - if A==B and B==C, then A==C +// - if AA +// - if A 0 { + fns = fns[x+1:] + } + } + return fmt.Sprintf("%s:%d:%s", fn, fl, fns) +} + +func errorResultFunction(tls *libc.TLS, ctx uintptr) func(error) { + return func(res error) { + errmsg, cerr := libc.CString(res.Error()) + if cerr != nil { + panic(cerr) + } + defer libc.Xfree(tls, errmsg) + sqlite3.Xsqlite3_result_error(tls, ctx, errmsg, -1) + sqlite3.Xsqlite3_result_error_code(tls, ctx, sqlite3.SQLITE_ERROR) + } +} + +// udfArgsPool reuses []driver.Value slices passed to user-defined functions. +// The driver's contract (documented on FunctionImpl.Scalar and +// AggregateFunction.Step/WindowInverse) states that the args values are not +// valid past the return of the user function, which makes the slice itself +// safe to reuse. See https://gitlab.com/cznic/sqlite/-/issues/226. +var udfArgsPool = sync.Pool{ + New: func() any { + s := make([]driver.Value, 0, 8) + return &s + }, +} + +// acquireUDFArgs returns a pooled *[]driver.Value with len == n. The caller +// must invoke releaseUDFArgs after the user function has returned. +func acquireUDFArgs(n int) *[]driver.Value { + sp := udfArgsPool.Get().(*[]driver.Value) + if cap(*sp) < n { + *sp = make([]driver.Value, n) + } else { + *sp = (*sp)[:n] + } + return sp +} + +// releaseUDFArgs returns the slice to the pool after clearing each entry so +// any heap references held in the previous invocation can be reclaimed. +func releaseUDFArgs(sp *[]driver.Value) { + s := *sp + for i := range s { + s[i] = nil + } + *sp = s[:0] + udfArgsPool.Put(sp) +} + +// functionArgs prepares a []driver.Value for one user-function invocation. +// The returned slice is owned by the driver and must be released via +// releaseUDFArgs once the user function returns. +// +// When volatile is true, SQLITE_TEXT and SQLITE_BLOB arguments are returned as +// zero-copy views into SQLite-owned memory (see [FunctionImpl.VolatileArgs] +// for the user-facing safety contract). When false (the default for all +// existing call sites), text and blob payloads are copied into Go-owned +// memory and stay valid for the lifetime of the slice. +func functionArgs(tls *libc.TLS, argc int32, argv uintptr, volatile bool) *[]driver.Value { + sp := acquireUDFArgs(int(argc)) + args := *sp + for i := int32(0); i < argc; i++ { + valPtr := *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*sqliteValPtrSize)) + + switch valType := sqlite3.Xsqlite3_value_type(tls, valPtr); valType { + case sqlite3.SQLITE_TEXT: + if volatile { + p := sqlite3.Xsqlite3_value_text(tls, valPtr) + n := sqlite3.Xsqlite3_value_bytes(tls, valPtr) + if p == 0 || n == 0 { + args[i] = "" + } else { + args[i] = unsafe.String((*byte)(unsafe.Pointer(p)), int(n)) + } + } else { + args[i] = libc.GoString(sqlite3.Xsqlite3_value_text(tls, valPtr)) + } + case sqlite3.SQLITE_INTEGER: + args[i] = sqlite3.Xsqlite3_value_int64(tls, valPtr) + case sqlite3.SQLITE_FLOAT: + args[i] = sqlite3.Xsqlite3_value_double(tls, valPtr) + case sqlite3.SQLITE_NULL: + args[i] = nil + case sqlite3.SQLITE_BLOB: + size := sqlite3.Xsqlite3_value_bytes(tls, valPtr) + blobPtr := sqlite3.Xsqlite3_value_blob(tls, valPtr) + if volatile { + if blobPtr == 0 || size == 0 { + args[i] = make([]byte, 0) + } else { + args[i] = unsafe.Slice((*byte)(unsafe.Pointer(blobPtr)), int(size)) + } + } else { + v := make([]byte, size) + if size != 0 { + copy(v, (*libc.RawMem)(unsafe.Pointer(blobPtr))[:size:size]) + } + args[i] = v + } + default: + panic(fmt.Sprintf("unexpected argument type %q passed by sqlite", valType)) + } + } + + return sp +} + +func functionReturnValue(tls *libc.TLS, ctx uintptr, res driver.Value) error { + switch resTyped := res.(type) { + case nil: + sqlite3.Xsqlite3_result_null(tls, ctx) + case int64: + sqlite3.Xsqlite3_result_int64(tls, ctx, resTyped) + case float64: + sqlite3.Xsqlite3_result_double(tls, ctx, resTyped) + case bool: + sqlite3.Xsqlite3_result_int(tls, ctx, libc.Bool32(resTyped)) + case time.Time: + sqlite3.Xsqlite3_result_int64(tls, ctx, resTyped.Unix()) + case string: + size := int32(len(resTyped)) + cstr, err := libc.CString(resTyped) + if err != nil { + panic(err) + } + defer libc.Xfree(tls, cstr) + sqlite3.Xsqlite3_result_text(tls, ctx, cstr, size, sqlite3.SQLITE_TRANSIENT) + case []byte: + size := int32(len(resTyped)) + if size == 0 { + sqlite3.Xsqlite3_result_zeroblob(tls, ctx, 0) + return nil + } + p := libc.Xmalloc(tls, types.Size_t(size)) + if p == 0 { + panic(fmt.Sprintf("unable to allocate space for blob: %d", size)) + } + defer libc.Xfree(tls, p) + copy((*libc.RawMem)(unsafe.Pointer(p))[:size:size], resTyped) + + sqlite3.Xsqlite3_result_blob(tls, ctx, p, size, sqlite3.SQLITE_TRANSIENT) + default: + return fmt.Errorf("function did not return a valid driver.Value: %T", resTyped) + } + + return nil +} + +// The below is all taken from zombiezen.com/go/sqlite. Aggregate functions need +// to maintain state (for instance, the count of values seen so far). We give +// each aggregate function an ID, generated by idGen, and put that in the pApp +// argument to sqlite3_create_function. We track this on the Go side in +// xAggregateFactories. +// +// When (if) the function is called is called by a query, we call the +// MakeAggregate factory function to set it up, and track that in +// xAggregateContext, retrieving it via sqlite3_aggregate_context. +// +// We also need to ensure that, for both aggregate and scalar functions, the +// function pointer we pass to SQLite meets certain rules on the Go side, so +// that the pointer remains valid. +var ( + xFuncs = struct { + mu sync.RWMutex + m map[uintptr]xFuncEntry + ids idGen + }{ + m: make(map[uintptr]xFuncEntry), + } + + xAggregateFactories = struct { + mu sync.RWMutex + m map[uintptr]xAggregateFactoryEntry + ids idGen + }{ + m: make(map[uintptr]xAggregateFactoryEntry), + } + + xAggregateContext = struct { + mu sync.RWMutex + m map[uintptr]xAggregateContextEntry + ids idGen + }{ + m: make(map[uintptr]xAggregateContextEntry), + } + + xCollations = struct { + mu sync.RWMutex + m map[uintptr]func(string, string) int + ids idGen + }{ + m: make(map[uintptr]func(string, string) int), + } +) + +// xFuncEntry pairs a registered scalar function with the VolatileArgs flag +// captured at registration time. Bundled so trampolines can decide whether to +// pass zero-copy or copied argument values without a second map lookup. +type xFuncEntry struct { + fn func(*FunctionContext, []driver.Value) (driver.Value, error) + volatile bool +} + +// xAggregateFactoryEntry pairs a registered aggregate factory with its +// VolatileArgs flag, for the same reason as xFuncEntry. +type xAggregateFactoryEntry struct { + factory func(FunctionContext) (AggregateFunction, error) + volatile bool +} + +// xAggregateContextEntry holds the AggregateFunction instance for one +// in-flight aggregate evaluation together with the VolatileArgs flag inherited +// from its factory registration. Caching the flag here avoids a second +// xAggregateFactories lookup in the Step / WindowInverse trampolines. +type xAggregateContextEntry struct { + fn AggregateFunction + volatile bool +} + +type idGen struct { + bitset []uint64 +} + +func (gen *idGen) next() uintptr { + base := uintptr(1) + for i := 0; i < len(gen.bitset); i, base = i+1, base+64 { + b := gen.bitset[i] + if b != 1<<64-1 { + n := uintptr(bits.TrailingZeros64(^b)) + gen.bitset[i] |= 1 << n + return base + n + } + } + gen.bitset = append(gen.bitset, 1) + return base +} + +func (gen *idGen) reclaim(id uintptr) { + bit := id - 1 + gen.bitset[bit/64] &^= 1 << (bit % 64) +} + +func makeAggregate(tls *libc.TLS, ctx uintptr) (AggregateFunction, bool, uintptr) { + goCtx := FunctionContext{tls: tls, ctx: ctx} + aggCtx := (*uintptr)(unsafe.Pointer(sqlite3.Xsqlite3_aggregate_context(tls, ctx, int32(ptrSize)))) + setErrorResult := errorResultFunction(tls, ctx) + if aggCtx == nil { + setErrorResult(errors.New("insufficient memory for aggregate")) + return nil, false, 0 + } + if *aggCtx != 0 { + // Already created. + xAggregateContext.mu.RLock() + entry := xAggregateContext.m[*aggCtx] + xAggregateContext.mu.RUnlock() + return entry.fn, entry.volatile, *aggCtx + } + + factoryID := sqlite3.Xsqlite3_user_data(tls, ctx) + xAggregateFactories.mu.RLock() + factoryEntry := xAggregateFactories.m[factoryID] + xAggregateFactories.mu.RUnlock() + + f, err := factoryEntry.factory(goCtx) + if err != nil { + setErrorResult(err) + return nil, false, 0 + } + if f == nil { + setErrorResult(errors.New("MakeAggregate function returned nil")) + return nil, false, 0 + } + + xAggregateContext.mu.Lock() + *aggCtx = xAggregateContext.ids.next() + xAggregateContext.m[*aggCtx] = xAggregateContextEntry{fn: f, volatile: factoryEntry.volatile} + xAggregateContext.mu.Unlock() + return f, factoryEntry.volatile, *aggCtx +} + +// cFuncPointer converts a function defined by a function declaration to a C pointer. +// The result of using cFuncPointer on closures is undefined. +func cFuncPointer[T any](f T) uintptr { + // This assumes the memory representation described in https://golang.org/s/go11func. + // + // cFuncPointer does its conversion by doing the following in order: + // 1) Create a Go struct containing a pointer to a pointer to + // the function. It is assumed that the pointer to the function will be + // stored in the read-only data section and thus will not move. + // 2) Convert the pointer to the Go struct to a pointer to uintptr through + // unsafe.Pointer. This is permitted via Rule #1 of unsafe.Pointer. + // 3) Dereference the pointer to uintptr to obtain the function value as a + // uintptr. This is safe as long as function values are passed as pointers. + return *(*uintptr)(unsafe.Pointer(&struct{ f T }{f})) +} + +func funcTrampoline(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + id := sqlite3.Xsqlite3_user_data(tls, ctx) + xFuncs.mu.RLock() + entry := xFuncs.m[id] + xFuncs.mu.RUnlock() + + setErrorResult := errorResultFunction(tls, ctx) + sp := functionArgs(tls, argc, argv, entry.volatile) + defer releaseUDFArgs(sp) + res, err := entry.fn(&FunctionContext{}, *sp) + + if err != nil { + setErrorResult(err) + return + } + + err = functionReturnValue(tls, ctx, res) + if err != nil { + setErrorResult(err) + } +} + +// sqlite3AllocCString allocates a NUL-terminated copy of s using SQLite's +// memory allocator (sqlite3_malloc). The caller must arrange for SQLite to +// free the returned pointer via sqlite3_free. +func sqlite3AllocCString(tls *libc.TLS, s string) uintptr { + n := len(s) + 1 + p := sqlite3.Xsqlite3_malloc(tls, int32(n)) + if p == 0 { + return 0 + } + mem := (*libc.RawMem)(unsafe.Pointer(p))[:n:n] + copy(mem, []byte(s)) + mem[n-1] = 0 + return p +} + +func stepTrampoline(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + impl, volatile, _ := makeAggregate(tls, ctx) + if impl == nil { + return + } + + setErrorResult := errorResultFunction(tls, ctx) + sp := functionArgs(tls, argc, argv, volatile) + defer releaseUDFArgs(sp) + err := impl.Step(&FunctionContext{}, *sp) + if err != nil { + setErrorResult(err) + } +} + +func inverseTrampoline(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { + impl, volatile, _ := makeAggregate(tls, ctx) + if impl == nil { + return + } + + setErrorResult := errorResultFunction(tls, ctx) + sp := functionArgs(tls, argc, argv, volatile) + defer releaseUDFArgs(sp) + err := impl.WindowInverse(&FunctionContext{}, *sp) + if err != nil { + setErrorResult(err) + } +} + +func valueTrampoline(tls *libc.TLS, ctx uintptr) { + impl, _, _ := makeAggregate(tls, ctx) + if impl == nil { + return + } + + setErrorResult := errorResultFunction(tls, ctx) + res, err := impl.WindowValue(&FunctionContext{}) + if err != nil { + setErrorResult(err) + } else { + err = functionReturnValue(tls, ctx, res) + if err != nil { + setErrorResult(err) + } + } +} + +func finalTrampoline(tls *libc.TLS, ctx uintptr) { + impl, _, id := makeAggregate(tls, ctx) + if impl == nil { + return + } + + setErrorResult := errorResultFunction(tls, ctx) + res, err := impl.WindowValue(&FunctionContext{}) + if err != nil { + setErrorResult(err) + } else { + err = functionReturnValue(tls, ctx, res) + if err != nil { + setErrorResult(err) + } + } + impl.Final(&FunctionContext{}) + + xAggregateContext.mu.Lock() + defer xAggregateContext.mu.Unlock() + delete(xAggregateContext.m, id) + xAggregateContext.ids.reclaim(id) +} + +func collationTrampoline(tls *libc.TLS, pApp uintptr, nLeft int32, zLeft uintptr, nRight int32, zRight uintptr) int32 { + xCollations.mu.RLock() + xCollation := xCollations.m[pApp] + xCollations.mu.RUnlock() + + left := string(libc.GoBytes(zLeft, int(nLeft))) + right := string(libc.GoBytes(zRight, int(nRight))) + + // res is of type int, which can be 64-bit wide + // Since we just need to know if the value is positive, negative, or zero, we can ensure it's -1, 0, +1 + res := xCollation(left, right) + switch { + case res < 0: + return -1 + case res == 0: + return 0 + case res > 0: + return 1 + default: + // Should never hit here, make the compiler happy + return 0 + } +} + +// Limit calls sqlite3_limit, see the docs at +// https://www.sqlite.org/c3ref/limit.html for details. +// +// To get a sql.Conn from a *sql.DB, use (*sql.DB).Conn(). Limits are bound to +// the particular instance of 'c', so getting a new connection only to pass it +// to Limit is possibly not useful above querying what are the various +// configured default values. +func Limit(c *sql.Conn, id int, newVal int) (r int, err error) { + err = c.Raw(func(driverConn any) error { + switch dc := driverConn.(type) { + case *conn: + r = dc.limit(id, newVal) + return nil + default: + return fmt.Errorf("unexpected driverConn type: %T", driverConn) + } + }) + return r, err + +} + +// ColumnInfo describes one output column of a prepared SQL statement. +// +// See https://www.sqlite.org/c3ref/column_database_name.html for more details. +type ColumnInfo struct { + // Name is the column's name, from sqlite3_column_name. + Name string + // DeclType is the declared column type, from sqlite3_column_decltype. + DeclType string + // DatabaseName is the name of the source database, from sqlite3_column_database_name. + // Empty if the column does not resolve to an unambiguous reference to a single database column, + // such as expressions, function calls, or constants. + DatabaseName string + // TableName is the name of the source table, from sqlite3_column_table_name. + // Empty if the column does not resolve to an unambiguous reference to a single database column, + // such as expressions, function calls, or constants. + TableName string + // OriginName is the name of the source column name, from sqlite3_column_origin_name. + // Empty if the column does not resolve to an unambiguous reference to a single database column, + // such as expressions, function calls, or constants. + OriginName string +} diff --git a/internal/engine/stmt.go b/internal/engine/stmt.go new file mode 100644 index 0000000..410b400 --- /dev/null +++ b/internal/engine/stmt.go @@ -0,0 +1,500 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "context" + "database/sql/driver" + "sync/atomic" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +type stmt struct { + c *conn + psql uintptr + pstmt uintptr // The cached SQLite statement handle +} + +func newStmt(c *conn, sql string) (*stmt, error) { + p, err := libc.CString(sql) + if err != nil { + return nil, err + } + s := &stmt{c: c, psql: p} + + // Attempt to prepare the statement immediately + // We make a copy of the pointer because prepareV2 advances it + psql := p + pstmt, err := c.prepareV2(&psql) + if err != nil { + c.free(p) + return nil, err + } + + // Check if there is trailing SQL (indicating a script/multi-statement) + // If *psql (the tail) is 0, we consumed the whole string. + hasTail := *(*byte)(unsafe.Pointer(psql)) != 0 + if pstmt != 0 && !hasTail { + // Optimization: Single statement. Cache it. + s.pstmt = pstmt + return s, nil + } + + // It is either a script (hasTail) or a comment-only string (pstmt==0). + // For scripts: Finalize now. We will re-parse iteratively in Exec/Query + // to handle the multiple statements correctly using the existing loop logic. + if pstmt != 0 { + if err := c.finalize(pstmt); err != nil { + c.free(p) + return nil, err + } + } + + return s, nil +} + +// Close closes the statement. +// +// As of Go 1.1, a Stmt will not be closed if it's in use by any queries. +func (s *stmt) Close() (err error) { + if s.pstmt != 0 { + if e := s.c.finalize(s.pstmt); e != nil { + err = e + } + s.pstmt = 0 + } + if s.psql != 0 { + s.c.free(s.psql) + s.psql = 0 + } + return err +} + +// Exec executes a query that doesn't return rows, such as an INSERT or UPDATE. +// +// Deprecated: Drivers should implement StmtExecContext instead (or +// additionally). +func (s *stmt) Exec(args []driver.Value) (driver.Result, error) { //TODO StmtExecContext + return s.exec(context.Background(), toNamedValues(args)) +} + +// toNamedValues converts []driver.Value to []driver.NamedValue +func toNamedValues(vals []driver.Value) (r []driver.NamedValue) { + r = make([]driver.NamedValue, len(vals)) + for i, val := range vals { + r[i] = driver.NamedValue{Value: val, Ordinal: i + 1} + } + return r +} + +func (s *stmt) exec(ctx context.Context, args []driver.NamedValue) (r driver.Result, err error) { + var pstmt uintptr + var done int32 + if ctx != nil { + if ctxDone := ctx.Done(); ctxDone != nil { + select { + case <-ctxDone: + return nil, ctx.Err() + default: + } + defer interruptOnDone(ctx, s.c, &done)() + } + } + + defer func() { + if ctx != nil && atomic.LoadInt32(&done) != 0 { + r, err = nil, ctx.Err() + } + if pstmt != 0 { + // ensure stmt finalized. + e := s.c.finalize(pstmt) + + if err == nil && e != nil { + // prioritize original + // returned error. + err = e + } + } + }() + + // OPTIMIZED PATH: Single Cached Statement + if s.pstmt != 0 { + err = func() error { + // Bind + n, err := s.c.bindParameterCount(s.pstmt) + if err != nil { + return err + } + if n != 0 { + allocs, err := s.c.bind(s.pstmt, n, args) + if err != nil { + return err + } + // Free allocations after step + if len(allocs) != 0 { + defer func() { s.c.freeAllocs(allocs) }() + } + } + + // Step + rc, err := s.c.step(s.pstmt) + if err != nil { + return err + } + + // Handle Result + switch rc & 0xff { + case sqlite3.SQLITE_DONE: + r, err = newResult(s.c) + case sqlite3.SQLITE_ROW: + // Step to completion, matching C sqlite3_exec() + // semantics. Required for DML RETURNING correctness; + // also drains SELECT results if passed to Exec. + for rc&0xff == sqlite3.SQLITE_ROW { + if atomic.LoadInt32(&done) != 0 { + return ctx.Err() + } + rc, err = s.c.step(s.pstmt) + if err != nil { + return err + } + } + if rc&0xff != sqlite3.SQLITE_DONE { + return s.c.errstr(int32(rc)) + } + r, err = newResult(s.c) + default: + return s.c.errstr(int32(rc)) + } + return err + }() + + // RESET (Crucial: Do not finalize) + // We must reset the VM to allow reuse. + // We also clear bindings to prevent leaking memory or state to next call. + if resetErr := s.c.reset(s.pstmt); resetErr != nil && err == nil { + err = resetErr + } + if clearErr := s.c.clearBindings(s.pstmt); clearErr != nil && err == nil { + err = clearErr + } + return r, err + } + + // FALLBACK PATH: Multi-statement script + for psql := s.psql; *(*byte)(unsafe.Pointer(psql)) != 0 && atomic.LoadInt32(&done) == 0; { + if pstmt, err = s.c.prepareV2(&psql); err != nil { + return nil, err + } + + if pstmt == 0 { + continue + } + err = func() error { + n, err := s.c.bindParameterCount(pstmt) + if err != nil { + return err + } + + if n != 0 { + allocs, err := s.c.bind(pstmt, n, args) + if err != nil { + return err + } + + if len(allocs) != 0 { + defer func() { s.c.freeAllocs(allocs) }() + } + } + + rc, err := s.c.step(pstmt) + if err != nil { + return err + } + + switch rc & 0xff { + case sqlite3.SQLITE_DONE: + r, err = newResult(s.c) + case sqlite3.SQLITE_ROW: + // Step to completion, matching C sqlite3_exec() + // semantics. Required for DML RETURNING correctness; + // also drains SELECT results if passed to Exec. + for rc&0xff == sqlite3.SQLITE_ROW { + if atomic.LoadInt32(&done) != 0 { + return ctx.Err() + } + rc, err = s.c.step(pstmt) + if err != nil { + return err + } + } + if rc&0xff != sqlite3.SQLITE_DONE { + return s.c.errstr(int32(rc)) + } + r, err = newResult(s.c) + default: + return s.c.errstr(int32(rc)) + } + + return err + }() + + e := s.c.finalize(pstmt) + pstmt = 0 // done with + + if err == nil && e != nil { + // prioritize original + // returned error. + err = e + } + + if err != nil { + return nil, err + } + } + return r, err +} + +// NumInput returns the number of placeholder parameters. +// +// If NumInput returns >= 0, the sql package will sanity check argument counts +// from callers and return errors to the caller before the statement's Exec or +// Query methods are called. +// +// NumInput may also return -1, if the driver doesn't know its number of +// placeholders. In that case, the sql package will not sanity check Exec or +// Query argument counts. +func (s *stmt) NumInput() (n int) { + return -1 +} + +// Query executes a query that may return rows, such as a +// SELECT. +// +// Deprecated: Drivers should implement StmtQueryContext instead (or +// additionally). +func (s *stmt) Query(args []driver.Value) (driver.Rows, error) { //TODO StmtQueryContext + return s.query(context.Background(), toNamedValues(args)) +} + +func (s *stmt) query(ctx context.Context, args []driver.NamedValue) (r driver.Rows, err error) { + var pstmt uintptr + var done int32 + if ctx != nil { + if ctxDone := ctx.Done(); ctxDone != nil { + select { + case <-ctxDone: + return nil, ctx.Err() + default: + } + defer interruptOnDone(ctx, s.c, &done)() + } + } + + defer func() { + if ctx != nil && atomic.LoadInt32(&done) != 0 { + if r != nil { + r.Close() + } + r, err = nil, ctx.Err() + } else if r == nil && err == nil { + r, err = newRows(s.c, pstmt, nil, true) + } + + if pstmt != 0 { + // ensure stmt finalized. + e := s.c.finalize(pstmt) + + if err == nil && e != nil { + // prioritize original + // returned error. + err = e + } + } + + }() + + // OPTIMIZED PATH: Single Cached Statement + if s.pstmt != 0 { + var allocs []uintptr + // Bind + n, err := s.c.bindParameterCount(s.pstmt) + if err != nil { + return nil, err + } + if n != 0 { + if allocs, err = s.c.bind(s.pstmt, n, args); err != nil { + return nil, err + } + } + + // Step + rc, err := s.c.step(s.pstmt) + if err != nil { + // On error, we must free allocs manually because 'newRows' won't take ownership + s.c.freeAllocs(allocs) + s.c.reset(s.pstmt) + s.c.clearBindings(s.pstmt) + return nil, err + } + + // Handle Result + switch rc & 0xff { + case sqlite3.SQLITE_ROW: + // Pass reuseStmt=true + if r, err = newRows(s.c, s.pstmt, &allocs, false); err != nil { + s.c.reset(s.pstmt) + s.c.clearBindings(s.pstmt) + return nil, err + } + r.(*rows).reuseStmt = true + return r, nil + + case sqlite3.SQLITE_DONE: + // No rows. Reset immediately. + // We still return a rows object (empty), but we can reset the stmt now + // because the empty rows object won't call step() again. + // However, standard newRows behavior expects a valid stmt to get columns. + // Let's rely on newRows to read columns, then it returns. + + // Actually, if we pass reuseStmt=true to an empty set, + // rows.Close() will eventually reset it. + if r, err = newRows(s.c, s.pstmt, &allocs, true); err != nil { + s.c.reset(s.pstmt) + s.c.clearBindings(s.pstmt) + return nil, err + } + r.(*rows).reuseStmt = true + return r, nil + + default: + // Error case + s.c.freeAllocs(allocs) + s.c.reset(s.pstmt) + s.c.clearBindings(s.pstmt) + return nil, s.c.errstr(int32(rc)) + } + } + + // FALLBACK PATH: Multi-statement script + for psql := s.psql; *(*byte)(unsafe.Pointer(psql)) != 0 && atomic.LoadInt32(&done) == 0; { + if pstmt, err = s.c.prepareV2(&psql); err != nil { + if r != nil { + r.Close() + } + return nil, err + } + + if pstmt == 0 { + continue + } + + err = func() (err error) { + var allocs []uintptr + defer func() { s.c.freeAllocs(allocs) }() + + n, err := s.c.bindParameterCount(pstmt) + if err != nil { + return err + } + + if n != 0 { + if allocs, err = s.c.bind(pstmt, n, args); err != nil { + return err + } + } + + rc, err := s.c.step(pstmt) + if err != nil { + return err + } + + switch rc & 0xff { + case sqlite3.SQLITE_ROW: + if r != nil { + r.Close() + } + if r, err = newRows(s.c, pstmt, &allocs, false); err != nil { + return err + } + pstmt = 0 + return nil + case sqlite3.SQLITE_DONE: + if r == nil { + if r, err = newRows(s.c, pstmt, &allocs, true); err != nil { + return err + } + pstmt = 0 + return nil + } + + // nop + default: + return s.c.errstr(int32(rc)) + } + + if *(*byte)(unsafe.Pointer(psql)) == 0 { + if r != nil { + r.Close() + } + if r, err = newRows(s.c, pstmt, &allocs, true); err != nil { + return err + } + pstmt = 0 + } + return nil + }() + + e := s.c.finalize(pstmt) + pstmt = 0 // done with + + if err == nil && e != nil { + // prioritize original + // returned error. + err = e + } + + if err != nil { + if r != nil { + r.Close() // r is from a previous iteration; clean up since we won't return it + } + return nil, err + } + } + return r, err +} + +// ExecContext implements driver.StmtExecContext +func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (dr driver.Result, err error) { + if dmesgs { + defer func() { + dmesg("stmt %p, ctx %p, args %v: (driver.Result %p, err %v)", s, ctx, args, dr, err) + }() + } + return s.exec(ctx, args) +} + +// QueryContext implements driver.StmtQueryContext +func (s *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (dr driver.Rows, err error) { + if dmesgs { + defer func() { + dmesg("stmt %p, ctx %p, args %v: (driver.Rows %p, err %v)", s, ctx, args, dr, err) + }() + } + return s.query(ctx, args) +} + +// C documentation +// +// int sqlite3_clear_bindings(sqlite3_stmt*); +func (c *conn) clearBindings(pstmt uintptr) error { + if rc := sqlite3.Xsqlite3_clear_bindings(c.tls, pstmt); rc != sqlite3.SQLITE_OK { + return c.errstr(rc) + } + return nil +} diff --git a/internal/engine/tx.go b/internal/engine/tx.go new file mode 100644 index 0000000..188b50a --- /dev/null +++ b/internal/engine/tx.go @@ -0,0 +1,79 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "context" + "database/sql/driver" + + "github.com/hanzoai/sqlite/internal/libc" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +type tx struct { + c *conn +} + +func newTx(ctx context.Context, c *conn, opts driver.TxOptions) (*tx, error) { + r := &tx{c: c} + + sql := "begin" + if !opts.ReadOnly && c.beginMode != "" { + sql = "begin " + c.beginMode + } + + if err := r.exec(ctx, sql); err != nil { + return nil, err + } + + return r, nil +} + +// Commit implements driver.Tx. +func (t *tx) Commit() (err error) { + err = t.exec(context.Background(), "commit") + if err == nil { + return nil + } + + // If Commit fails (e.g., SQLITE_BUSY), the connection might still be inside + // the transaction. database/sql expects the connection to be clean (no active + // transaction) after Commit returns. + // + // We check the low-level autocommit state. 0 means autocommit is disabled => + // we are inside a transaction. + if t.c.db != 0 && sqlite3.Xsqlite3_get_autocommit(t.c.tls, t.c.db) == 0 { + // Force a rollback to clean up the connection. We ignore the rollback error + // because we must return the original Commit error to the user. + t.exec(context.Background(), "rollback") + } + + return err +} + +// Rollback implements driver.Tx. +func (t *tx) Rollback() (err error) { + return t.exec(context.Background(), "rollback") +} + +func (t *tx) exec(ctx context.Context, sql string) (err error) { + psql, err := libc.CString(sql) + if err != nil { + return err + } + + defer t.c.free(psql) + //TODO use t.conn.ExecContext() instead + + if ctx != nil && ctx.Done() != nil { + defer interruptOnDone(ctx, t.c, nil)() + } + + if rc := sqlite3.Xsqlite3_exec(t.c.tls, t.c.db, psql, 0, 0, 0); rc != sqlite3.SQLITE_OK { + return t.c.errstr(rc) + } + + return nil +} diff --git a/internal/engine/vfs/codec.go b/internal/engine/vfs/codec.go new file mode 100644 index 0000000..c39cb79 --- /dev/null +++ b/internal/engine/vfs/codec.go @@ -0,0 +1,750 @@ +// codec.go — a read-write, os-backed SQLite VFS that encrypts every page with +// the SQLCipher-4 page format (github.com/hanzoai/sqlcipher), giving the pure-Go +// engine real at-rest encryption byte-compatible with C SQLCipher. +// +// It is the write side the vendored engine's stock vfs package leaves null (it fills +// only xRead/xFileSize/xClose (read-only). Here codecio wires xWrite/xTruncate/ +// xSync too, backed by a real *os.File, and transforms page bytes with the codec +// on the way through.) +// +// # How it stays byte-compatible AND lets the engine's WAL round-trip +// +// SQLCipher's codec is normally a pager hook; here it is a VFS shim UNDER the +// pager, so the engine computes WAL frame checksums over the PLAINTEXT page, reserve +// region included. The codec overwrites that reserve with a fresh IV+HMAC on every +// write, so a naive decrypt would not reproduce the bytes the engine checksummed and +// WAL recovery would reject every frame. The fix, proven empirically: the engine +// zeros the full page buffer of NEW pages, and codecRead ZEROS the reserve of +// every page it returns — so every page the engine ever checksums has a zero reserve, +// the checksum is always taken over [data‖zeros], and the read-back reproduces it +// exactly. (the main database file carries no checksums, so zeroing the (pager- +// ignored) reserve there is invisible and the on-disk ciphertext is byte-identical +// to what C SQLCipher writes. +// +// # Fail-closed +// +// A wrong key or a tampered page fails Decrypt (HMAC) and is returned as an I/O +// error; plaintext is never produced. Rollback journals are refused (keyed +// databases run WAL-only); temp spill is kept in memory by the DSN. Plaintext +// never reaches disk. +package vfs + +import ( + "crypto/rand" + "fmt" + "os" + "sync" + "unsafe" + + "github.com/hanzoai/sqlcipher" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" + "github.com/hanzoai/sqlite/internal/libc" +) + +// file kinds the codec handles distinctly. +const ( + kindMain = iota // main database: page 1 keeps the salt in the clear + kindWAL // write-ahead log: [32B hdr][24B frame hdr + page]* +) + +// walHdr / frameHdr are the fixed WAL layout sizes (wal.c). +const ( + walHdr = 32 + frameHdr = 24 +) + +// codecVFS is one keyed database's VFS instance, referenced from sqlite3_vfs +// pAppData. The DEK lives here and nowhere global; Close drops the reference. +type codecVFS struct { + key []byte // 32-byte DEK (raw SQLCipher key, no KDF) + ps int // page size (SQLCipher default 4096) + mu sync.Mutex + salt []byte // database salt, set when the main db is opened; shared with the WAL + shm shm // in-process wal-index shared memory for this database +} + +// shm is a database's WAL shared-memory (the wal-index). For a single-writer +// keyed store (MaxOpenConns(1)) it is heap memory owned by the one connection; +// SQLite reads and writes the wal-index through the region pointers xShmMap hands +// back, and rebuilds it from the -wal file after any unmap, so freeing it on close +// loses nothing. One shm per database (per codecVFS), shared by that database's +// connections; the single-writer cap makes the shm locks contention-free, so they +// are no-ops. +type shm struct { + mu sync.Mutex + regions []uintptr // C-allocated, zeroed wal-index regions + szRegion int32 +} + +// codecState is the Go-side handle for one open file, referenced from the +// C-allocated file struct by token (addObject), the same indirection the vendored engine's +// read-only VFS uses to keep Go pointers out of C memory. +type codecState struct { + f *os.File + codec *sqlcipher.Codec + kind int + ps int + delOnClose bool + path string + vfs *codecVFS // back-ref for the shared wal-index (shm) +} + +// codecCFile is the C-visible file: SQLite treats *pFile as sqlite3_file (its +// first field is pMethods); handle indexes back to the codecState. +type codecCFile = struct { + base sqlite3_file + handle uintptr +} + +// codecio is this VFS's io_methods: read AND write, plus the shm (wal-index) +// methods (iVersion 2) that let WAL run on an in-process heap wal-index with no +// -shm file — the single-writer model keyed stores use. +var codecio sqlite3_io_methods + +func init() { + // iVersion 2 advertises the shm (wal-index) methods so WAL works — including + // the DELETE→WAL conversion a new database goes through — without an external + // -shm file. Everything is a single-writer heap wal-index. + codecio.iVersion = 2 + codecio.xClose = fp1(codecClose) + codecio.xRead = fpRW(codecRead) + codecio.xWrite = fpRW(codecWrite) + codecio.xTruncate = fpTrunc(codecTruncate) + codecio.xSync = fpSync(codecSync) + codecio.xFileSize = fpSize(codecFileSize) + codecio.xLock = fpLock(vfsLock) // reused: no-op (single writer) + codecio.xUnlock = fpLock(vfsUnlock) // reused: no-op + codecio.xCheckReservedLock = fpSize(vfsCheckReservedLock) // reused: reports none + codecio.xFileControl = fpFileCtl(vfsFileControl) // reused: SQLITE_NOTFOUND + codecio.xSectorSize = fp1(codecSectorSize) + codecio.xDeviceCharacteristics = fp1(codecDeviceCharacteristics) + codecio.xShmMap = fpShmMap(codecShmMap) + codecio.xShmLock = fpShmLock(codecShmLock) + codecio.xShmBarrier = fp0(codecShmBarrier) + codecio.xShmUnmap = fpSync(codecShmUnmap) +} + +// --- Go-func → C function-pointer reinterprets, one per signature. This is the +// exact idiom ccgo emits (see Xsqlite3_fsFS); the engine's TLS calling convention +// makes a Go func of the matching shape directly callable as a C function pointer. + +func fp1(f func(*libc.TLS, uintptr) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr) int32 + }{f})) +} +func fpRW(f func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32 + }{f})) +} +func fpTrunc(f func(*libc.TLS, uintptr, sqlite_int64) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, sqlite_int64) int32 + }{f})) +} +func fpSync(f func(*libc.TLS, uintptr, int32) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32) int32 + }{f})) +} +func fpSize(f func(*libc.TLS, uintptr, uintptr) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) int32 + }{f})) +} +func fpLock(f func(*libc.TLS, uintptr, int32) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32) int32 + }{f})) +} +func fpFileCtl(f func(*libc.TLS, uintptr, int32, uintptr) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) int32 + }{f})) +} +func fpOpen(f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 + }{f})) +} +func fpDelete(f func(*libc.TLS, uintptr, uintptr, int32) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32) int32 + }{f})) +} +func fpAccess(f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{f})) +} +func fpVoid3(f func(*libc.TLS, uintptr, int32, uintptr)) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{f})) +} +func fpVfs2(f func(*libc.TLS, uintptr, uintptr) uintptr) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) uintptr + }{f})) +} +func fpVfs3(f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr + }{f})) +} +func fpRand(f func(*libc.TLS, uintptr, int32, uintptr) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) int32 + }{f})) +} +func fpShmMap(f func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32 + }{f})) +} +func fpShmLock(f func(*libc.TLS, uintptr, int32, int32, int32) int32) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, int32, int32) int32 + }{f})) +} +func fp0(f func(*libc.TLS, uintptr)) uintptr { + return *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr) + }{f})) +} + +// Register creates and registers a VFS bound to dek and returns its name (for +// `?vfs=`) and a closer that unregisters it and drops the key. dek must be +// a 32-byte raw SQLCipher key. One instance per open database. +func Register(dek []byte) (name string, closer func() error, err error) { + if len(dek) != sqlcipher.KeySize { + return "", nil, fmt.Errorf("sqlcipher/vfs: key must be %d bytes, got %d", sqlcipher.KeySize, len(dek)) + } + tls := libc.NewTLS() + o := &codecVFS{key: append([]byte(nil), dek...), ps: sqlcipher.DefaultPageSize} + h := addObject(o) + name = fmt.Sprintf("sqlcipher-%x", h) + cname, err := libc.CString(name) + if err != nil { + removeObject(h) + tls.Close() + return "", nil, err + } + + p := libc.Xmalloc(tls, libc.Tsize_t(unsafe.Sizeof(sqlite3_vfs{}))) + if p == 0 { + removeObject(h) + libc.Xfree(tls, cname) + tls.Close() + return "", nil, fmt.Errorf("sqlcipher/vfs: out of memory") + } + *(*sqlite3_vfs)(unsafe.Pointer(p)) = sqlite3_vfs{ + iVersion: 1, + szOsFile: int32(unsafe.Sizeof(codecCFile{})), + mxPathname: 1024, + zName: cname, + pAppData: h, + xOpen: fpOpen(codecOpen), + xDelete: fpDelete(codecDelete), + xAccess: fpAccess(codecAccess), + xFullPathname: fpAccess(vfsFullPathname), + xDlOpen: fpVfs2(vfsDlOpen), + xDlError: fpVoid3(vfsDlError), + xDlSym: fpVfs3(vfsDlSym), + xDlClose: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) + }{vfsDlClose})), + xRandomness: fpRand(vfsRandomness), + xSleep: fpSync(vfsSleep), + xCurrentTime: fpSize(vfsCurrentTime), + } + if rc := sqlite3.Xsqlite3_vfs_register(tls, p, libc.Bool32(false)); rc != sqlite3.SQLITE_OK { + removeObject(h) + libc.Xfree(tls, cname) + libc.Xfree(tls, p) + tls.Close() + return "", nil, fmt.Errorf("sqlcipher/vfs: register: %d", rc) + } + + var once sync.Once + closer = func() error { + once.Do(func() { + sqlite3.Xsqlite3_vfs_unregister(tls, p) + o.mu.Lock() + for i := range o.key { // wipe the DEK + o.key[i] = 0 + } + o.mu.Unlock() + removeObject(h) + libc.Xfree(tls, cname) + libc.Xfree(tls, p) + tls.Close() + }) + return nil + } + return name, closer, nil +} + +func codecOpen(tls *libc.TLS, pVfs, zName, pFile uintptr, flags int32, pOutFlags uintptr) int32 { + if zName == 0 { + return sqlite3.SQLITE_CANTOPEN + } + o := getObject((*sqlite3_vfs)(unsafe.Pointer(pVfs)).pAppData).(*codecVFS) + name := libc.GoString(zName) + + // Keyed databases run WAL-only; a rollback journal would put plaintext page + // images on disk, so refuse it (fail closed). The DSN sets journal_mode=WAL, + // so this never fires in normal operation. + if flags&sqlite3.SQLITE_OPEN_MAIN_JOURNAL != 0 { + return sqlite3.SQLITE_CANTOPEN + } + + oflags := os.O_RDWR + if flags&sqlite3.SQLITE_OPEN_CREATE != 0 { + oflags |= os.O_CREATE + } + f, err := os.OpenFile(name, oflags, 0o600) + if err != nil { + return sqlite3.SQLITE_CANTOPEN + } + st, err := f.Stat() + if err != nil { + f.Close() + return sqlite3.SQLITE_CANTOPEN + } + + kind := kindWAL + if flags&sqlite3.SQLITE_OPEN_MAIN_DB != 0 { + kind = kindMain + } + + o.mu.Lock() + if kind == kindMain { + if st.Size() >= int64(sqlcipher.SaltSize) { + hdr := make([]byte, sqlcipher.SaltSize) + if _, e := f.ReadAt(hdr, 0); e != nil { + o.mu.Unlock() + f.Close() + return sqlite3.SQLITE_IOERR + } + o.salt = hdr + } else if o.salt == nil { + o.salt = make([]byte, sqlcipher.SaltSize) + if _, e := rand.Read(o.salt); e != nil { + o.mu.Unlock() + f.Close() + return sqlite3.SQLITE_IOERR + } + } + } + salt := o.salt + o.mu.Unlock() + + if salt == nil { // WAL opened before main — SQLite never does this; fail closed. + f.Close() + return sqlite3.SQLITE_CANTOPEN + } + codec, err := sqlcipher.NewCodec(sqlcipher.RawKey(o.key), salt, sqlcipher.Params{PageSize: o.ps}) + if err != nil { + f.Close() + return sqlite3.SQLITE_CANTOPEN + } + + state := &codecState{ + f: f, + codec: codec, + kind: kind, + ps: o.ps, + delOnClose: flags&sqlite3.SQLITE_OPEN_DELETEONCLOSE != 0, + path: name, + vfs: o, + } + cf := (*codecCFile)(unsafe.Pointer(pFile)) + cf.base.pMethods = uintptr(unsafe.Pointer(&codecio)) + cf.handle = addObject(state) + if pOutFlags != 0 { + *(*int32)(unsafe.Pointer(pOutFlags)) = flags + } + return sqlite3.SQLITE_OK +} + +func state(pFile uintptr) *codecState { + return getObject((*codecCFile)(unsafe.Pointer(pFile)).handle).(*codecState) +} + +func goBytes(p uintptr, n int32) []byte { + return (*libc.RawMem)(unsafe.Pointer(p))[:n:n] +} + +// zeroReserve blanks the per-page reserve trailer so every page the engine sees has +// a deterministic (zero) reserve — the invariant WAL frame checksums depend on. +func zeroReserve(page []byte) { + r := page[len(page)-sqlcipher.Reserve:] + for i := range r { + r[i] = 0 + } +} + +func codecRead(tls *libc.TLS, pFile, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + s := state(pFile) + out := goBytes(zBuf, iAmt) + var err error + var short bool + if s.kind == kindMain { + short, err = s.readMain(out, int64(iOfst)) + } else { + short, err = s.readWAL(out, int64(iOfst)) + } + if err != nil { + return sqlite3.SQLITE_IOERR_READ + } + if short { + return sqlite3.SQLITE_IOERR_SHORT_READ + } + return sqlite3.SQLITE_OK +} + +// readMain decrypts the covering page(s) and copies the requested range out, +// zeroing each page's reserve. A read wholly past EOF returns zeros + short. +func (s *codecState) readMain(out []byte, off int64) (short bool, err error) { + ps := int64(s.ps) + got := 0 + for got < len(out) { + pos := off + int64(got) + pgno := uint32(pos/ps) + 1 + pageStart := int64(pgno-1) * ps + raw := make([]byte, ps) + n, _ := readAtFull(s.f, raw, pageStart) + if n == 0 { // past EOF: zero-fill remainder, signal short read + for i := got; i < len(out); i++ { + out[i] = 0 + } + return true, nil + } + if n < int(ps) { + return false, fmt.Errorf("partial page %d (%d/%d bytes)", pgno, n, ps) + } + plain, derr := s.codec.Decrypt(pgno, raw) + if derr != nil { + return false, derr // wrong key / tamper -> fail closed + } + zeroReserve(plain) + got += copy(out[got:], plain[pos-pageStart:]) + } + return false, nil +} + +// readWAL serves the 32-byte header and 24-byte frame headers verbatim and +// decrypts each frame's page image (pgno read from the frame header on disk). +func (s *codecState) readWAL(out []byte, off int64) (short bool, err error) { + ps := int64(s.ps) + frame := frameHdr + ps + got := 0 + for got < len(out) { + pos := off + int64(got) + var seg []byte + if pos < walHdr { + end := min64(walHdr, off+int64(len(out))) + seg = make([]byte, end-pos) + n, _ := readAtFull(s.f, seg, pos) + if n == 0 { + for i := got; i < len(out); i++ { + out[i] = 0 + } + return true, nil + } + got += copy(out[got:], seg[:n]) + continue + } + rel := pos - walHdr + fi := rel / frame + inF := rel % frame + frameStart := walHdr + fi*frame + if inF < frameHdr { // frame header region — verbatim + end := min64(frameStart+frameHdr, off+int64(len(out))) + seg = make([]byte, end-pos) + n, _ := readAtFull(s.f, seg, pos) + if n == 0 { + for i := got; i < len(out); i++ { + out[i] = 0 + } + return true, nil + } + got += copy(out[got:], seg[:n]) + continue + } + // page-image region: decrypt the whole page, copy the requested slice. + pageStart := frameStart + frameHdr + var fh [4]byte + if _, e := s.f.ReadAt(fh[:], frameStart); e != nil { + return false, e + } + pgno := uint32(fh[0])<<24 | uint32(fh[1])<<16 | uint32(fh[2])<<8 | uint32(fh[3]) + raw := make([]byte, ps) + n, _ := readAtFull(s.f, raw, pageStart) + if n == 0 { + for i := got; i < len(out); i++ { + out[i] = 0 + } + return true, nil + } + if n < int(ps) { + return false, fmt.Errorf("partial wal page frame %d", fi) + } + plain, derr := s.codec.Decrypt(pgno, raw) + if derr != nil { + return false, derr + } + zeroReserve(plain) + got += copy(out[got:], plain[pos-pageStart:]) + } + return false, nil +} + +func codecWrite(tls *libc.TLS, pFile, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + s := state(pFile) + in := goBytes(zBuf, iAmt) + var err error + if s.kind == kindMain { + err = s.writeMain(in, int64(iOfst)) + } else { + err = s.writeWAL(in, int64(iOfst)) + } + if err != nil { + return sqlite3.SQLITE_IOERR_WRITE + } + return sqlite3.SQLITE_OK +} + +// writeMain encrypts each full page and writes the ciphertext at the same offset +// (on-disk size == logical size, 1 page ⇄ 1 page). Non-page-aligned writes get a +// read-modify-write, though the pager only ever writes whole pages here. +func (s *codecState) writeMain(in []byte, off int64) error { + ps := int64(s.ps) + done := 0 + for done < len(in) { + pos := off + int64(done) + pgno := uint32(pos/ps) + 1 + pageStart := int64(pgno-1) * ps + inPageOff := pos - pageStart + nWrite := int(ps - inPageOff) + if done+nWrite > len(in) { + nWrite = len(in) - done + } + var page []byte + if inPageOff == 0 && nWrite == int(ps) { + page = in[done : done+nWrite] + } else { // partial: read-modify-write under the codec + page = make([]byte, ps) + if n, _ := readAtFull(s.f, page, pageStart); n == int(ps) { + pt, err := s.codec.Decrypt(pgno, page) + if err != nil { + return err + } + page = pt + } + copy(page[inPageOff:], in[done:done+nWrite]) + } + ct, err := s.codec.Encrypt(pgno, page) + if err != nil { + return err + } + if _, err := s.f.WriteAt(ct, pageStart); err != nil { + return err + } + done += nWrite + } + return nil +} + +// writeWAL writes the header and frame headers verbatim and encrypts each page +// image (pgno from the frame header, from the buffer if covered else from disk). +func (s *codecState) writeWAL(in []byte, off int64) error { + ps := int64(s.ps) + frame := frameHdr + ps + done := 0 + for done < len(in) { + pos := off + int64(done) + if pos < walHdr { + end := min64(walHdr, off+int64(len(in))) + n := int(end - pos) + if _, err := s.f.WriteAt(in[done:done+n], pos); err != nil { + return err + } + done += n + continue + } + rel := pos - walHdr + fi := rel / frame + inF := rel % frame + frameStart := walHdr + fi*frame + if inF < frameHdr { + end := min64(frameStart+frameHdr, off+int64(len(in))) + n := int(end - pos) + if _, err := s.f.WriteAt(in[done:done+n], pos); err != nil { + return err + } + done += n + continue + } + // page-image region: must be a whole page starting at the image boundary. + pageStart := frameStart + frameHdr + if pos != pageStart || len(in)-done < int(ps) { + return fmt.Errorf("sqlcipher/vfs: unaligned wal page write off=%d amt=%d", pos, len(in)-done) + } + pgno, err := s.walFramePgno(in, done, frameStart) + if err != nil { + return err + } + ct, err := s.codec.Encrypt(pgno, in[done:done+int(ps)]) + if err != nil { + return err + } + if _, err := s.f.WriteAt(ct, pageStart); err != nil { + return err + } + done += int(ps) + } + return nil +} + +// walFramePgno reads the frame's big-endian page number, from the write buffer if +// this write covers the frame header, otherwise from the header already on disk +// (wal.c writes the header in a separate xWrite immediately before the page). +func (s *codecState) walFramePgno(in []byte, done int, frameStart int64) (uint32, error) { + var fh [4]byte + if done >= frameHdr { // header sits just before the page image in this buffer + copy(fh[:], in[done-frameHdr:done-frameHdr+4]) + } else if _, err := s.f.ReadAt(fh[:], frameStart); err != nil { + return 0, err + } + return uint32(fh[0])<<24 | uint32(fh[1])<<16 | uint32(fh[2])<<8 | uint32(fh[3]), nil +} + +func codecTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { + if err := state(pFile).f.Truncate(int64(size)); err != nil { + return sqlite3.SQLITE_IOERR_TRUNCATE + } + return sqlite3.SQLITE_OK +} + +func codecSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { + if err := state(pFile).f.Sync(); err != nil { + return sqlite3.SQLITE_IOERR_FSYNC + } + return sqlite3.SQLITE_OK +} + +func codecFileSize(tls *libc.TLS, pFile, pSize uintptr) int32 { + st, err := state(pFile).f.Stat() + if err != nil { + return sqlite3.SQLITE_IOERR_FSTAT + } + *(*sqlite_int64)(unsafe.Pointer(pSize)) = st.Size() + return sqlite3.SQLITE_OK +} + +func codecClose(tls *libc.TLS, pFile uintptr) int32 { + cf := (*codecCFile)(unsafe.Pointer(pFile)) + s := getObject(cf.handle).(*codecState) + s.f.Close() + if s.delOnClose { + os.Remove(s.path) + } + removeObject(cf.handle) + return sqlite3.SQLITE_OK +} + +func codecSectorSize(tls *libc.TLS, pFile uintptr) int32 { return 4096 } + +func codecDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { return 0 } + +// codecShmMap returns region iRegion of this database's wal-index, allocating and +// zeroing it on demand (SQLite requires a zeroed region on first map). bExtend==0 +// means "don't create it" — return a null pointer, which SQLite treats as +// not-yet-present. +func codecShmMap(tls *libc.TLS, pFile uintptr, iRegion, szRegion, bExtend int32, pp uintptr) int32 { + sh := &state(pFile).vfs.shm + sh.mu.Lock() + defer sh.mu.Unlock() + sh.szRegion = szRegion + for int32(len(sh.regions)) <= iRegion { + if bExtend == 0 { + *(*uintptr)(unsafe.Pointer(pp)) = 0 + return sqlite3.SQLITE_OK + } + p := libc.Xmalloc(tls, libc.Tsize_t(szRegion)) + if p == 0 { + return sqlite3.SQLITE_IOERR_NOMEM + } + z := (*libc.RawMem)(unsafe.Pointer(p))[:szRegion:szRegion] + for i := range z { + z[i] = 0 + } + sh.regions = append(sh.regions, p) + } + *(*uintptr)(unsafe.Pointer(pp)) = sh.regions[iRegion] + return sqlite3.SQLITE_OK +} + +// codecShmLock is a no-op: the keyed store is single-writer (MaxOpenConns(1)), so +// the one connection is the only agent touching the wal-index and there is no +// cross-connection coordination to enforce. +func codecShmLock(tls *libc.TLS, pFile uintptr, offset, n, flags int32) int32 { + return sqlite3.SQLITE_OK +} + +// codecShmBarrier is a no-op: a single goroutine drives the connection, so there +// is no memory ordering to publish across CPUs. +func codecShmBarrier(tls *libc.TLS, pFile uintptr) {} + +// codecShmUnmap frees the wal-index. SQLite rebuilds it from the -wal file on the +// next map, so releasing it here loses nothing. +func codecShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { + sh := &state(pFile).vfs.shm + sh.mu.Lock() + defer sh.mu.Unlock() + for _, p := range sh.regions { + libc.Xfree(tls, p) + } + sh.regions = nil + return sqlite3.SQLITE_OK +} + +func codecDelete(tls *libc.TLS, pVfs, zPath uintptr, dirSync int32) int32 { + if err := os.Remove(libc.GoString(zPath)); err != nil && !os.IsNotExist(err) { + return sqlite3.SQLITE_IOERR_DELETE + } + return sqlite3.SQLITE_OK +} + +func codecAccess(tls *libc.TLS, pVfs, zPath uintptr, flags int32, pResOut uintptr) int32 { + res := int32(0) + if _, err := os.Stat(libc.GoString(zPath)); err == nil { + res = 1 + } + *(*int32)(unsafe.Pointer(pResOut)) = res + return sqlite3.SQLITE_OK +} + +// readAtFull reads len(b) bytes at off, tolerating a short tail at EOF; it returns +// the number of bytes actually read (0 when off is at/after EOF). +func readAtFull(f *os.File, b []byte, off int64) (int, error) { + n := 0 + for n < len(b) { + m, err := f.ReadAt(b[n:], off+int64(n)) + n += m + if err != nil { + return n, nil // treat EOF/short as a short read; caller decides + } + } + return n, nil +} + +func min64(a, b int64) int64 { + if a < b { + return a + } + return b +} diff --git a/internal/engine/vfs/patches.go b/internal/engine/vfs/patches.go new file mode 100644 index 0000000..f2441e7 --- /dev/null +++ b/internal/engine/vfs/patches.go @@ -0,0 +1,226 @@ +// Copyright 2022 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vfs + +import ( + "errors" + "fmt" + "io" + "io/fs" + "os" + "sync" + "sync/atomic" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +var ( + fToken uintptr + + // New, FS.Close + mu sync.Mutex + + objectMu sync.Mutex + objects = map[uintptr]interface{}{} +) + +func token() uintptr { return atomic.AddUintptr(&fToken, 1) } + +func addObject(o interface{}) uintptr { + t := token() + objectMu.Lock() + objects[t] = o + objectMu.Unlock() + return t +} + +func getObject(t uintptr) interface{} { + objectMu.Lock() + o := objects[t] + if o == nil { + panic("internal error") + } + + objectMu.Unlock() + return o +} + +func removeObject(t uintptr) { + objectMu.Lock() + if _, ok := objects[t]; !ok { + panic("internal error") + } + + delete(objects, t) + objectMu.Unlock() +} + +var vfsio = sqlite3_io_methods{ + iVersion: 1, // iVersion +} + +func vfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { + if zName == 0 { + return sqlite3.SQLITE_IOERR + } + + if flags&sqlite3.SQLITE_OPEN_MAIN_JOURNAL != 0 { + return sqlite3.SQLITE_NOMEM + } + + p := pFile + *(*VFSFile)(unsafe.Pointer(p)) = VFSFile{} + fsys := getObject((*sqlite3_vfs)(unsafe.Pointer(pVfs)).pAppData).(fs.FS) + f, err := fsys.Open(libc.GoString(zName)) + if err != nil { + return sqlite3.SQLITE_CANTOPEN + } + + h := addObject(f) + (*VFSFile)(unsafe.Pointer(p)).fsFile = h + if pOutFlags != 0 { + *(*int32)(unsafe.Pointer(pOutFlags)) = int32(os.O_RDONLY) + } + (*VFSFile)(unsafe.Pointer(p)).base.pMethods = uintptr(unsafe.Pointer(&vfsio)) + return sqlite3.SQLITE_OK +} + +func vfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + p := pFile + f := getObject((*VFSFile)(unsafe.Pointer(p)).fsFile).(fs.File) + seeker, ok := f.(io.Seeker) + if !ok { + return sqlite3.SQLITE_IOERR_READ + } + + if n, err := seeker.Seek(iOfst, io.SeekStart); err != nil || n != iOfst { + return sqlite3.SQLITE_IOERR_READ + } + + b := (*libc.RawMem)(unsafe.Pointer(zBuf))[:iAmt] + n, err := io.ReadFull(f, b) + if err == nil { + return sqlite3.SQLITE_OK + } + + if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { + clear(b[n:]) + return sqlite3.SQLITE_IOERR_SHORT_READ + } + + return sqlite3.SQLITE_IOERR_READ +} + +func vfsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { + if flags == sqlite3.SQLITE_ACCESS_READWRITE { + *(*int32)(unsafe.Pointer(pResOut)) = 0 + return sqlite3.SQLITE_OK + } + + fn := libc.GoString(zPath) + fsys := getObject((*sqlite3_vfs)(unsafe.Pointer(pVfs)).pAppData).(fs.FS) + if _, err := fs.Stat(fsys, fn); err != nil { + *(*int32)(unsafe.Pointer(pResOut)) = 0 + return sqlite3.SQLITE_OK + } + + *(*int32)(unsafe.Pointer(pResOut)) = 1 + return sqlite3.SQLITE_OK +} + +func vfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { + p := pFile + f := getObject((*VFSFile)(unsafe.Pointer(p)).fsFile).(fs.File) + fi, err := f.Stat() + if err != nil { + return sqlite3.SQLITE_IOERR_FSTAT + } + + *(*sqlite_int64)(unsafe.Pointer(pSize)) = fi.Size() + return sqlite3.SQLITE_OK +} + +func vfsClose(tls *libc.TLS, pFile uintptr) int32 { + p := pFile + h := (*VFSFile)(unsafe.Pointer(p)).fsFile + f := getObject(h).(fs.File) + f.Close() + removeObject(h) + return sqlite3.SQLITE_OK +} + +// FS represents a SQLite read only file system backed by Go's fs.FS. +type FS struct { + cname uintptr + cvfs uintptr + fsHandle uintptr + name string + tls *libc.TLS + + closed int32 +} + +// New creates a new sqlite VFS and registers it. If successful, the +// file system can be used with the URI parameter `?vfs=`. +func New(fs fs.FS) (name string, _ *FS, _ error) { + if fs == nil { + return "", nil, fmt.Errorf("fs argument cannot be nil") + } + + mu.Lock() + + defer mu.Unlock() + + tls := libc.NewTLS() + h := addObject(fs) + + name = fmt.Sprintf("vfs%x", h) + cname, err := libc.CString(name) + if err != nil { + return "", nil, err + } + + vfs := Xsqlite3_fsFS(tls, cname, h) + if vfs == 0 { + removeObject(h) + libc.Xfree(tls, cname) + tls.Close() + return "", nil, fmt.Errorf("out of memory") + } + + if rc := sqlite3.Xsqlite3_vfs_register(tls, vfs, libc.Bool32(false)); rc != sqlite3.SQLITE_OK { + removeObject(h) + libc.Xfree(tls, cname) + libc.Xfree(tls, vfs) + tls.Close() + return "", nil, fmt.Errorf("registering VFS %s: %d", name, rc) + } + + return name, &FS{name: name, cname: cname, cvfs: vfs, fsHandle: h, tls: tls}, nil +} + +// Close unregisters f and releases its resources. +func (f *FS) Close() error { + if atomic.SwapInt32(&f.closed, 1) != 0 { + return nil + } + + mu.Lock() + + defer mu.Unlock() + + rc := sqlite3.Xsqlite3_vfs_unregister(f.tls, f.cvfs) + libc.Xfree(f.tls, f.cname) + libc.Xfree(f.tls, f.cvfs) + f.tls.Close() + removeObject(f.fsHandle) + if rc != 0 { + return fmt.Errorf("unregistering VFS %s: %d", f.name, rc) + } + + return nil +} diff --git a/internal/engine/vfs/patches64.go b/internal/engine/vfs/patches64.go new file mode 100644 index 0000000..db03560 --- /dev/null +++ b/internal/engine/vfs/patches64.go @@ -0,0 +1,32 @@ +// Copyright 2022 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !arm && !386 +// +build !arm,!386 + +package vfs + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" +) + +func init() { + *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 8)) = vfsClose + *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 16)) = vfsRead + *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 48)) = vfsFileSize + *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 56)) = vfsLock + *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 64)) = vfsUnlock + *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 72)) = vfsCheckReservedLock + *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 80)) = vfsFileControl + *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 88)) = vfsSectorSize + *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfsio)) + 96)) = vfsDeviceCharacteristics +} + +func vfsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nPathOut int32, zPathOut uintptr) int32 { + libc.Xstrncpy(tls, zPathOut, zPath, uint64(nPathOut)) + return sqlite3.SQLITE_OK +} diff --git a/internal/engine/vfs/vfs_darwin_amd64.go b/internal/engine/vfs/vfs_darwin_amd64.go new file mode 100644 index 0000000..a35e31b --- /dev/null +++ b/internal/engine/vfs/vfs_darwin_amd64.go @@ -0,0 +1,2959 @@ +// Code generated by 'ccgo -o vfs_darwin_amd64.go c/vfs.c -I../testdata/sqlite-amalgamation-3380500 -lgithub.com/hanzoai/sqlite/internal/engine/lib -pkgname vfs -nocapi -export-externs X -D SQLITE_OS_UNIX -hide=vfsFullPathname -hide=vfsOpen -hide=vfsRead -hide=vfsAccess -hide=vfsFileSize -hide=vfsClose', DO NOT EDIT. + +package vfs + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/engine/lib" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer +var _ *libc.TLS +var _ types.Size_t + +const ( + FILESEC_OWNER = 1 + FILESEC_GROUP = 2 + FILESEC_UUID = 3 + FILESEC_MODE = 4 + FILESEC_ACL = 5 + FILESEC_GRPUUID = 6 + + FILESEC_ACL_RAW = 100 + FILESEC_ACL_ALLOCSIZE = 101 +) + +const ( + _CLOCK_REALTIME = 0 + _CLOCK_MONOTONIC = 6 + _CLOCK_MONOTONIC_RAW = 4 + _CLOCK_MONOTONIC_RAW_APPROX = 5 + _CLOCK_UPTIME_RAW = 8 + _CLOCK_UPTIME_RAW_APPROX = 9 + _CLOCK_PROCESS_CPUTIME_ID = 12 + _CLOCK_THREAD_CPUTIME_ID = 16 +) + +type ptrdiff_t = int64 + +type size_t = uint64 + +type wchar_t = int32 + +var X__darwin_check_fd_set_overflow uintptr + +type va_list = uintptr + +type sqlite_int64 = int64 +type sqlite_uint64 = uint64 +type sqlite3_int64 = sqlite_int64 +type sqlite3_uint64 = sqlite_uint64 + +type sqlite3_callback = uintptr + +type sqlite3_file1 = struct{ pMethods uintptr } + +type sqlite3_file = sqlite3_file1 +type sqlite3_io_methods1 = struct { + iVersion int32 + _ [4]byte + xClose uintptr + xRead uintptr + xWrite uintptr + xTruncate uintptr + xSync uintptr + xFileSize uintptr + xLock uintptr + xUnlock uintptr + xCheckReservedLock uintptr + xFileControl uintptr + xSectorSize uintptr + xDeviceCharacteristics uintptr + xShmMap uintptr + xShmLock uintptr + xShmBarrier uintptr + xShmUnmap uintptr + xFetch uintptr + xUnfetch uintptr +} + +type sqlite3_io_methods = sqlite3_io_methods1 + +type sqlite3_vfs1 = struct { + iVersion int32 + szOsFile int32 + mxPathname int32 + _ [4]byte + pNext uintptr + zName uintptr + pAppData uintptr + xOpen uintptr + xDelete uintptr + xAccess uintptr + xFullPathname uintptr + xDlOpen uintptr + xDlError uintptr + xDlSym uintptr + xDlClose uintptr + xRandomness uintptr + xSleep uintptr + xCurrentTime uintptr + xGetLastError uintptr + xCurrentTimeInt64 uintptr + xSetSystemCall uintptr + xGetSystemCall uintptr + xNextSystemCall uintptr +} + +type sqlite3_vfs = sqlite3_vfs1 +type sqlite3_syscall_ptr = uintptr + +type sqlite3_mem_methods1 = struct { + xMalloc uintptr + xFree uintptr + xRealloc uintptr + xSize uintptr + xRoundup uintptr + xInit uintptr + xShutdown uintptr + pAppData uintptr +} + +type sqlite3_mem_methods = sqlite3_mem_methods1 + +type sqlite3_destructor_type = uintptr + +type sqlite3_vtab1 = struct { + pModule uintptr + nRef int32 + _ [4]byte + zErrMsg uintptr +} + +type sqlite3_vtab = sqlite3_vtab1 +type sqlite3_index_info1 = struct { + nConstraint int32 + _ [4]byte + aConstraint uintptr + nOrderBy int32 + _ [4]byte + aOrderBy uintptr + aConstraintUsage uintptr + idxNum int32 + _ [4]byte + idxStr uintptr + needToFreeIdxStr int32 + orderByConsumed int32 + estimatedCost float64 + estimatedRows sqlite3_int64 + idxFlags int32 + _ [4]byte + colUsed sqlite3_uint64 +} + +type sqlite3_index_info = sqlite3_index_info1 +type sqlite3_vtab_cursor1 = struct{ pVtab uintptr } + +type sqlite3_vtab_cursor = sqlite3_vtab_cursor1 +type sqlite3_module1 = struct { + iVersion int32 + _ [4]byte + xCreate uintptr + xConnect uintptr + xBestIndex uintptr + xDisconnect uintptr + xDestroy uintptr + xOpen uintptr + xClose uintptr + xFilter uintptr + xNext uintptr + xEof uintptr + xColumn uintptr + xRowid uintptr + xUpdate uintptr + xBegin uintptr + xSync uintptr + xCommit uintptr + xRollback uintptr + xFindFunction uintptr + xRename uintptr + xSavepoint uintptr + xRelease uintptr + xRollbackTo uintptr + xShadowName uintptr +} + +type sqlite3_module = sqlite3_module1 + +type sqlite3_index_constraint = struct { + iColumn int32 + op uint8 + usable uint8 + _ [2]byte + iTermOffset int32 +} + +type sqlite3_index_orderby = struct { + iColumn int32 + desc uint8 + _ [3]byte +} + +type sqlite3_index_constraint_usage = struct { + argvIndex int32 + omit uint8 + _ [3]byte +} + +type sqlite3_mutex_methods1 = struct { + xMutexInit uintptr + xMutexEnd uintptr + xMutexAlloc uintptr + xMutexFree uintptr + xMutexEnter uintptr + xMutexTry uintptr + xMutexLeave uintptr + xMutexHeld uintptr + xMutexNotheld uintptr +} + +type sqlite3_mutex_methods = sqlite3_mutex_methods1 + +type sqlite3_pcache_page1 = struct { + pBuf uintptr + pExtra uintptr +} + +type sqlite3_pcache_page = sqlite3_pcache_page1 + +type sqlite3_pcache_methods21 = struct { + iVersion int32 + _ [4]byte + pArg uintptr + xInit uintptr + xShutdown uintptr + xCreate uintptr + xCachesize uintptr + xPagecount uintptr + xFetch uintptr + xUnpin uintptr + xRekey uintptr + xTruncate uintptr + xDestroy uintptr + xShrink uintptr +} + +type sqlite3_pcache_methods2 = sqlite3_pcache_methods21 + +type sqlite3_pcache_methods1 = struct { + pArg uintptr + xInit uintptr + xShutdown uintptr + xCreate uintptr + xCachesize uintptr + xPagecount uintptr + xFetch uintptr + xUnpin uintptr + xRekey uintptr + xTruncate uintptr + xDestroy uintptr +} + +type sqlite3_pcache_methods = sqlite3_pcache_methods1 + +type sqlite3_snapshot1 = struct{ hidden [48]uint8 } + +type sqlite3_snapshot = sqlite3_snapshot1 + +type sqlite3_rtree_geometry1 = struct { + pContext uintptr + nParam int32 + _ [4]byte + aParam uintptr + pUser uintptr + xDelUser uintptr +} + +type sqlite3_rtree_geometry = sqlite3_rtree_geometry1 +type sqlite3_rtree_query_info1 = struct { + pContext uintptr + nParam int32 + _ [4]byte + aParam uintptr + pUser uintptr + xDelUser uintptr + aCoord uintptr + anQueue uintptr + nCoord int32 + iLevel int32 + mxLevel int32 + _ [4]byte + iRowid sqlite3_int64 + rParentScore sqlite3_rtree_dbl + eParentWithin int32 + eWithin int32 + rScore sqlite3_rtree_dbl + apSqlParam uintptr +} + +type sqlite3_rtree_query_info = sqlite3_rtree_query_info1 + +type sqlite3_rtree_dbl = float64 + +type Fts5ExtensionApi1 = struct { + iVersion int32 + _ [4]byte + xUserData uintptr + xColumnCount uintptr + xRowCount uintptr + xColumnTotalSize uintptr + xTokenize uintptr + xPhraseCount uintptr + xPhraseSize uintptr + xInstCount uintptr + xInst uintptr + xRowid uintptr + xColumnText uintptr + xColumnSize uintptr + xQueryPhrase uintptr + xSetAuxdata uintptr + xGetAuxdata uintptr + xPhraseFirst uintptr + xPhraseNext uintptr + xPhraseFirstColumn uintptr + xPhraseNextColumn uintptr +} + +type Fts5ExtensionApi = Fts5ExtensionApi1 +type Fts5PhraseIter1 = struct { + a uintptr + b uintptr +} + +type Fts5PhraseIter = Fts5PhraseIter1 + +type fts5_extension_function = uintptr +type fts5_tokenizer1 = struct { + xCreate uintptr + xDelete uintptr + xTokenize uintptr +} + +type fts5_tokenizer = fts5_tokenizer1 + +type fts5_api1 = struct { + iVersion int32 + _ [4]byte + xCreateTokenizer uintptr + xFindTokenizer uintptr + xCreateFunction uintptr +} + +type fts5_api = fts5_api1 + +type __darwin_pthread_handler_rec = struct { + __routine uintptr + __arg uintptr + __next uintptr +} + +type _opaque_pthread_attr_t = struct { + __sig int64 + __opaque [56]int8 +} + +type _opaque_pthread_cond_t = struct { + __sig int64 + __opaque [40]int8 +} + +type _opaque_pthread_condattr_t = struct { + __sig int64 + __opaque [8]int8 +} + +type _opaque_pthread_mutex_t = struct { + __sig int64 + __opaque [56]int8 +} + +type _opaque_pthread_mutexattr_t = struct { + __sig int64 + __opaque [8]int8 +} + +type _opaque_pthread_once_t = struct { + __sig int64 + __opaque [8]int8 +} + +type _opaque_pthread_rwlock_t = struct { + __sig int64 + __opaque [192]int8 +} + +type _opaque_pthread_rwlockattr_t = struct { + __sig int64 + __opaque [16]int8 +} + +type _opaque_pthread_t = struct { + __sig int64 + __cleanup_stack uintptr + __opaque [8176]int8 +} + +type int8_t = int8 + +type int16_t = int16 + +type int32_t = int32 + +type int64_t = int64 + +type u_int8_t = uint8 + +type u_int16_t = uint16 + +type u_int32_t = uint32 + +type u_int64_t = uint64 + +type register_t = int64_t + +type intptr_t = int64 + +type uintptr_t = uint64 + +type user_addr_t = u_int64_t +type user_size_t = u_int64_t +type user_ssize_t = int64_t +type user_long_t = int64_t +type user_ulong_t = u_int64_t +type user_time_t = int64_t +type user_off_t = int64_t + +type syscall_arg_t = u_int64_t + +type rsize_t = uint64 + +type errno_t = int32 + +type ssize_t = int64 + +type u_char = uint8 + +type u_short = uint16 + +type u_int = uint32 +type u_long = uint64 +type ushort = uint16 +type uint = uint32 + +type u_quad_t = u_int64_t +type quad_t = int64_t +type qaddr_t = uintptr + +type caddr_t = uintptr + +type daddr_t = int32_t + +type dev_t = int32 + +type fixpt_t = u_int32_t + +type blkcnt_t = int64 + +type blksize_t = int32 + +type gid_t = uint32 + +type in_addr_t = uint32 + +type in_port_t = uint16 + +type ino_t = uint64 + +type ino64_t = uint64 + +type key_t = int32 + +type mode_t = uint16 + +type nlink_t = uint16 + +type id_t = uint32 + +type pid_t = int32 + +type off_t = int64 + +type segsz_t = int32_t +type swblk_t = int32_t + +type uid_t = uint32 + +type clock_t = uint64 + +type time_t = int64 + +type useconds_t = uint32 + +type suseconds_t = int32 + +type fd_set1 = struct{ fds_bits [32]int32 } + +type fd_set = fd_set1 + +func X__darwin_check_fd_set(tls *libc.TLS, _a int32, _b uintptr) int32 { + if uintptr_t(uintptr(unsafe.Pointer(&X__darwin_check_fd_set_overflow))) != uint64(0) { + return (*struct { + f func(*libc.TLS, int32, uintptr, int32) int32 + })(unsafe.Pointer(&struct{ uintptr }{X__darwin_check_fd_set_overflow})).f(tls, _a, _b, 0) + } else { + return 1 + } + return int32(0) +} + +func X__darwin_fd_isset(tls *libc.TLS, _fd int32, _p uintptr) int32 { + if X__darwin_check_fd_set(tls, _fd, _p) != 0 { + return *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) & int32(uint64(1)<<(uint64(_fd)%(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))) + } + + return 0 +} + +func X__darwin_fd_set(tls *libc.TLS, _fd int32, _p uintptr) { + if X__darwin_check_fd_set(tls, _fd, _p) != 0 { + *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) |= int32(uint64(1) << (uint64(_fd) % (uint64(unsafe.Sizeof(int32(0))) * uint64(8)))) + } +} + +func X__darwin_fd_clr(tls *libc.TLS, _fd int32, _p uintptr) { + if X__darwin_check_fd_set(tls, _fd, _p) != 0 { + *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) &= ^int32(uint64(1) << (uint64(_fd) % (uint64(unsafe.Sizeof(int32(0))) * uint64(8)))) + } +} + +type fd_mask = int32 + +type pthread_attr_t = _opaque_pthread_attr_t + +type pthread_cond_t = _opaque_pthread_cond_t + +type pthread_condattr_t = _opaque_pthread_condattr_t + +type pthread_mutex_t = _opaque_pthread_mutex_t + +type pthread_mutexattr_t = _opaque_pthread_mutexattr_t + +type pthread_once_t = _opaque_pthread_once_t + +type pthread_rwlock_t = _opaque_pthread_rwlock_t + +type pthread_rwlockattr_t = _opaque_pthread_rwlockattr_t + +type pthread_t = uintptr + +type pthread_key_t = uint64 + +type fsblkcnt_t = uint32 + +type fsfilcnt_t = uint32 + +type timespec = struct { + tv_sec int64 + tv_nsec int64 +} + +type ostat = struct { + st_dev uint16 + _ [6]byte + st_ino ino_t + st_mode mode_t + st_nlink nlink_t + st_uid uint16 + st_gid uint16 + st_rdev uint16 + _ [2]byte + st_size int32 + st_atimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_mtimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_ctimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_blksize int32 + st_blocks int32 + st_flags uint32 + st_gen uint32 +} + +type stat = struct { + st_dev dev_t + st_mode mode_t + st_nlink nlink_t + st_ino uint64 + st_uid uid_t + st_gid gid_t + st_rdev dev_t + _ [4]byte + st_atimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_mtimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_ctimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_birthtimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_size off_t + st_blocks blkcnt_t + st_blksize blksize_t + st_flags uint32 + st_gen uint32 + st_lspare int32 + st_qspare [2]int64 +} + +type stat64 = struct { + st_dev dev_t + st_mode mode_t + st_nlink nlink_t + st_ino uint64 + st_uid uid_t + st_gid gid_t + st_rdev dev_t + _ [4]byte + st_atimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_mtimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_ctimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_birthtimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_size off_t + st_blocks blkcnt_t + st_blksize blksize_t + st_flags uint32 + st_gen uint32 + st_lspare int32 + st_qspare [2]int64 +} + +type filesec_t = uintptr + +type flock = struct { + l_start off_t + l_len off_t + l_pid pid_t + l_type int16 + l_whence int16 +} + +type flocktimeout = struct { + fl struct { + l_start off_t + l_len off_t + l_pid pid_t + l_type int16 + l_whence int16 + } + timeout struct { + tv_sec int64 + tv_nsec int64 + } +} + +type radvisory = struct { + ra_offset off_t + ra_count int32 + _ [4]byte +} + +type fcodeblobs = struct { + f_cd_hash uintptr + f_hash_size size_t + f_cd_buffer uintptr + f_cd_size size_t + f_out_size uintptr + f_arch int32 + __padding int32 +} + +type fcodeblobs_t = fcodeblobs + +type fsignatures = struct { + fs_file_start off_t + fs_blob_start uintptr + fs_blob_size size_t +} + +type fsignatures_t = fsignatures + +type fchecklv = struct { + lv_file_start off_t + lv_error_message_size size_t + lv_error_message uintptr +} + +type fchecklv_t = fchecklv + +type fstore = struct { + fst_flags uint32 + fst_posmode int32 + fst_offset off_t + fst_length off_t + fst_bytesalloc off_t +} + +type fstore_t = fstore + +type fpunchhole = struct { + fp_flags uint32 + reserved uint32 + fp_offset off_t + fp_length off_t +} + +type fpunchhole_t = fpunchhole + +type ftrimactivefile = struct { + fta_offset off_t + fta_length off_t +} + +type ftrimactivefile_t = ftrimactivefile + +type fspecread = struct { + fsr_flags uint32 + reserved uint32 + fsr_offset off_t + fsr_length off_t +} + +type fspecread_t = fspecread + +type fbootstraptransfer = struct { + fbt_offset off_t + fbt_length size_t + fbt_buffer uintptr +} + +type fbootstraptransfer_t = fbootstraptransfer + +type log2phys = struct { + l2p_flags uint32 + _ [4]byte + l2p_contigbytes off_t + l2p_devoffset off_t +} + +type filesec_property_t = uint32 + +type accessx_descriptor = struct { + ad_name_offset uint32 + ad_flags int32 + ad_pad [2]int32 +} + +type uint64_t = uint64 + +type uint32_t = uint32 +type kauth_cred_t = uintptr +type posix_cred_t = uintptr + +type sig_atomic_t = int32 + +type __darwin_i386_thread_state = struct { + __eax uint32 + __ebx uint32 + __ecx uint32 + __edx uint32 + __edi uint32 + __esi uint32 + __ebp uint32 + __esp uint32 + __ss uint32 + __eflags uint32 + __eip uint32 + __cs uint32 + __ds uint32 + __es uint32 + __fs uint32 + __gs uint32 +} + +type __darwin_fp_control = struct { + _ [0]uint16 + __invalid uint16 +} + +type __darwin_fp_status = struct { + _ [0]uint16 + __invalid uint16 +} + +type __darwin_mmst_reg = struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 +} + +type __darwin_xmm_reg = struct{ __xmm_reg [16]int8 } + +type __darwin_ymm_reg = struct{ __ymm_reg [32]int8 } + +type __darwin_zmm_reg = struct{ __zmm_reg [64]int8 } + +type __darwin_opmask_reg = struct{ __opmask_reg [8]int8 } + +type __darwin_i386_float_state = struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [224]int8 + __fpu_reserved1 int32 +} + +type __darwin_i386_avx_state = struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [224]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } +} + +type __darwin_i386_avx512_state = struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [224]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + __fpu_k0 struct{ __opmask_reg [8]int8 } + __fpu_k1 struct{ __opmask_reg [8]int8 } + __fpu_k2 struct{ __opmask_reg [8]int8 } + __fpu_k3 struct{ __opmask_reg [8]int8 } + __fpu_k4 struct{ __opmask_reg [8]int8 } + __fpu_k5 struct{ __opmask_reg [8]int8 } + __fpu_k6 struct{ __opmask_reg [8]int8 } + __fpu_k7 struct{ __opmask_reg [8]int8 } + __fpu_zmmh0 struct{ __ymm_reg [32]int8 } + __fpu_zmmh1 struct{ __ymm_reg [32]int8 } + __fpu_zmmh2 struct{ __ymm_reg [32]int8 } + __fpu_zmmh3 struct{ __ymm_reg [32]int8 } + __fpu_zmmh4 struct{ __ymm_reg [32]int8 } + __fpu_zmmh5 struct{ __ymm_reg [32]int8 } + __fpu_zmmh6 struct{ __ymm_reg [32]int8 } + __fpu_zmmh7 struct{ __ymm_reg [32]int8 } +} + +type __darwin_i386_exception_state = struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint32 +} + +type __darwin_x86_debug_state32 = struct { + __dr0 uint32 + __dr1 uint32 + __dr2 uint32 + __dr3 uint32 + __dr4 uint32 + __dr5 uint32 + __dr6 uint32 + __dr7 uint32 +} + +type __x86_pagein_state = struct{ __pagein_error int32 } + +type __darwin_x86_thread_state64 = struct { + __rax uint64 + __rbx uint64 + __rcx uint64 + __rdx uint64 + __rdi uint64 + __rsi uint64 + __rbp uint64 + __rsp uint64 + __r8 uint64 + __r9 uint64 + __r10 uint64 + __r11 uint64 + __r12 uint64 + __r13 uint64 + __r14 uint64 + __r15 uint64 + __rip uint64 + __rflags uint64 + __cs uint64 + __fs uint64 + __gs uint64 +} + +type __darwin_x86_thread_full_state64 = struct { + __ss64 struct { + __rax uint64 + __rbx uint64 + __rcx uint64 + __rdx uint64 + __rdi uint64 + __rsi uint64 + __rbp uint64 + __rsp uint64 + __r8 uint64 + __r9 uint64 + __r10 uint64 + __r11 uint64 + __r12 uint64 + __r13 uint64 + __r14 uint64 + __r15 uint64 + __rip uint64 + __rflags uint64 + __cs uint64 + __fs uint64 + __gs uint64 + } + __ds uint64 + __es uint64 + __ss uint64 + __gsbase uint64 +} + +type __darwin_x86_float_state64 = struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 +} + +type __darwin_x86_avx_state64 = struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + __fpu_ymmh8 struct{ __xmm_reg [16]int8 } + __fpu_ymmh9 struct{ __xmm_reg [16]int8 } + __fpu_ymmh10 struct{ __xmm_reg [16]int8 } + __fpu_ymmh11 struct{ __xmm_reg [16]int8 } + __fpu_ymmh12 struct{ __xmm_reg [16]int8 } + __fpu_ymmh13 struct{ __xmm_reg [16]int8 } + __fpu_ymmh14 struct{ __xmm_reg [16]int8 } + __fpu_ymmh15 struct{ __xmm_reg [16]int8 } +} + +type __darwin_x86_avx512_state64 = struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + __fpu_ymmh8 struct{ __xmm_reg [16]int8 } + __fpu_ymmh9 struct{ __xmm_reg [16]int8 } + __fpu_ymmh10 struct{ __xmm_reg [16]int8 } + __fpu_ymmh11 struct{ __xmm_reg [16]int8 } + __fpu_ymmh12 struct{ __xmm_reg [16]int8 } + __fpu_ymmh13 struct{ __xmm_reg [16]int8 } + __fpu_ymmh14 struct{ __xmm_reg [16]int8 } + __fpu_ymmh15 struct{ __xmm_reg [16]int8 } + __fpu_k0 struct{ __opmask_reg [8]int8 } + __fpu_k1 struct{ __opmask_reg [8]int8 } + __fpu_k2 struct{ __opmask_reg [8]int8 } + __fpu_k3 struct{ __opmask_reg [8]int8 } + __fpu_k4 struct{ __opmask_reg [8]int8 } + __fpu_k5 struct{ __opmask_reg [8]int8 } + __fpu_k6 struct{ __opmask_reg [8]int8 } + __fpu_k7 struct{ __opmask_reg [8]int8 } + __fpu_zmmh0 struct{ __ymm_reg [32]int8 } + __fpu_zmmh1 struct{ __ymm_reg [32]int8 } + __fpu_zmmh2 struct{ __ymm_reg [32]int8 } + __fpu_zmmh3 struct{ __ymm_reg [32]int8 } + __fpu_zmmh4 struct{ __ymm_reg [32]int8 } + __fpu_zmmh5 struct{ __ymm_reg [32]int8 } + __fpu_zmmh6 struct{ __ymm_reg [32]int8 } + __fpu_zmmh7 struct{ __ymm_reg [32]int8 } + __fpu_zmmh8 struct{ __ymm_reg [32]int8 } + __fpu_zmmh9 struct{ __ymm_reg [32]int8 } + __fpu_zmmh10 struct{ __ymm_reg [32]int8 } + __fpu_zmmh11 struct{ __ymm_reg [32]int8 } + __fpu_zmmh12 struct{ __ymm_reg [32]int8 } + __fpu_zmmh13 struct{ __ymm_reg [32]int8 } + __fpu_zmmh14 struct{ __ymm_reg [32]int8 } + __fpu_zmmh15 struct{ __ymm_reg [32]int8 } + __fpu_zmm16 struct{ __zmm_reg [64]int8 } + __fpu_zmm17 struct{ __zmm_reg [64]int8 } + __fpu_zmm18 struct{ __zmm_reg [64]int8 } + __fpu_zmm19 struct{ __zmm_reg [64]int8 } + __fpu_zmm20 struct{ __zmm_reg [64]int8 } + __fpu_zmm21 struct{ __zmm_reg [64]int8 } + __fpu_zmm22 struct{ __zmm_reg [64]int8 } + __fpu_zmm23 struct{ __zmm_reg [64]int8 } + __fpu_zmm24 struct{ __zmm_reg [64]int8 } + __fpu_zmm25 struct{ __zmm_reg [64]int8 } + __fpu_zmm26 struct{ __zmm_reg [64]int8 } + __fpu_zmm27 struct{ __zmm_reg [64]int8 } + __fpu_zmm28 struct{ __zmm_reg [64]int8 } + __fpu_zmm29 struct{ __zmm_reg [64]int8 } + __fpu_zmm30 struct{ __zmm_reg [64]int8 } + __fpu_zmm31 struct{ __zmm_reg [64]int8 } +} + +type __darwin_x86_exception_state64 = struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint64 +} + +type __darwin_x86_debug_state64 = struct { + __dr0 uint64 + __dr1 uint64 + __dr2 uint64 + __dr3 uint64 + __dr4 uint64 + __dr5 uint64 + __dr6 uint64 + __dr7 uint64 +} + +type __darwin_x86_cpmu_state64 = struct{ __ctrs [16]uint64 } + +type __darwin_mcontext32 = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint32 + } + __ss struct { + __eax uint32 + __ebx uint32 + __ecx uint32 + __edx uint32 + __edi uint32 + __esi uint32 + __ebp uint32 + __esp uint32 + __ss uint32 + __eflags uint32 + __eip uint32 + __cs uint32 + __ds uint32 + __es uint32 + __fs uint32 + __gs uint32 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [224]int8 + __fpu_reserved1 int32 + } +} + +type __darwin_mcontext_avx32 = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint32 + } + __ss struct { + __eax uint32 + __ebx uint32 + __ecx uint32 + __edx uint32 + __edi uint32 + __esi uint32 + __ebp uint32 + __esp uint32 + __ss uint32 + __eflags uint32 + __eip uint32 + __cs uint32 + __ds uint32 + __es uint32 + __fs uint32 + __gs uint32 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [224]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + } +} + +type __darwin_mcontext_avx512_32 = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint32 + } + __ss struct { + __eax uint32 + __ebx uint32 + __ecx uint32 + __edx uint32 + __edi uint32 + __esi uint32 + __ebp uint32 + __esp uint32 + __ss uint32 + __eflags uint32 + __eip uint32 + __cs uint32 + __ds uint32 + __es uint32 + __fs uint32 + __gs uint32 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [224]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + __fpu_k0 struct{ __opmask_reg [8]int8 } + __fpu_k1 struct{ __opmask_reg [8]int8 } + __fpu_k2 struct{ __opmask_reg [8]int8 } + __fpu_k3 struct{ __opmask_reg [8]int8 } + __fpu_k4 struct{ __opmask_reg [8]int8 } + __fpu_k5 struct{ __opmask_reg [8]int8 } + __fpu_k6 struct{ __opmask_reg [8]int8 } + __fpu_k7 struct{ __opmask_reg [8]int8 } + __fpu_zmmh0 struct{ __ymm_reg [32]int8 } + __fpu_zmmh1 struct{ __ymm_reg [32]int8 } + __fpu_zmmh2 struct{ __ymm_reg [32]int8 } + __fpu_zmmh3 struct{ __ymm_reg [32]int8 } + __fpu_zmmh4 struct{ __ymm_reg [32]int8 } + __fpu_zmmh5 struct{ __ymm_reg [32]int8 } + __fpu_zmmh6 struct{ __ymm_reg [32]int8 } + __fpu_zmmh7 struct{ __ymm_reg [32]int8 } + } +} + +type __darwin_mcontext64 = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint64 + } + __ss struct { + __rax uint64 + __rbx uint64 + __rcx uint64 + __rdx uint64 + __rdi uint64 + __rsi uint64 + __rbp uint64 + __rsp uint64 + __r8 uint64 + __r9 uint64 + __r10 uint64 + __r11 uint64 + __r12 uint64 + __r13 uint64 + __r14 uint64 + __r15 uint64 + __rip uint64 + __rflags uint64 + __cs uint64 + __fs uint64 + __gs uint64 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 + } + _ [4]byte +} + +type __darwin_mcontext64_full = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint64 + } + __ss struct { + __ss64 struct { + __rax uint64 + __rbx uint64 + __rcx uint64 + __rdx uint64 + __rdi uint64 + __rsi uint64 + __rbp uint64 + __rsp uint64 + __r8 uint64 + __r9 uint64 + __r10 uint64 + __r11 uint64 + __r12 uint64 + __r13 uint64 + __r14 uint64 + __r15 uint64 + __rip uint64 + __rflags uint64 + __cs uint64 + __fs uint64 + __gs uint64 + } + __ds uint64 + __es uint64 + __ss uint64 + __gsbase uint64 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 + } + _ [4]byte +} + +type __darwin_mcontext_avx64 = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint64 + } + __ss struct { + __rax uint64 + __rbx uint64 + __rcx uint64 + __rdx uint64 + __rdi uint64 + __rsi uint64 + __rbp uint64 + __rsp uint64 + __r8 uint64 + __r9 uint64 + __r10 uint64 + __r11 uint64 + __r12 uint64 + __r13 uint64 + __r14 uint64 + __r15 uint64 + __rip uint64 + __rflags uint64 + __cs uint64 + __fs uint64 + __gs uint64 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + __fpu_ymmh8 struct{ __xmm_reg [16]int8 } + __fpu_ymmh9 struct{ __xmm_reg [16]int8 } + __fpu_ymmh10 struct{ __xmm_reg [16]int8 } + __fpu_ymmh11 struct{ __xmm_reg [16]int8 } + __fpu_ymmh12 struct{ __xmm_reg [16]int8 } + __fpu_ymmh13 struct{ __xmm_reg [16]int8 } + __fpu_ymmh14 struct{ __xmm_reg [16]int8 } + __fpu_ymmh15 struct{ __xmm_reg [16]int8 } + } + _ [4]byte +} + +type __darwin_mcontext_avx64_full = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint64 + } + __ss struct { + __ss64 struct { + __rax uint64 + __rbx uint64 + __rcx uint64 + __rdx uint64 + __rdi uint64 + __rsi uint64 + __rbp uint64 + __rsp uint64 + __r8 uint64 + __r9 uint64 + __r10 uint64 + __r11 uint64 + __r12 uint64 + __r13 uint64 + __r14 uint64 + __r15 uint64 + __rip uint64 + __rflags uint64 + __cs uint64 + __fs uint64 + __gs uint64 + } + __ds uint64 + __es uint64 + __ss uint64 + __gsbase uint64 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + __fpu_ymmh8 struct{ __xmm_reg [16]int8 } + __fpu_ymmh9 struct{ __xmm_reg [16]int8 } + __fpu_ymmh10 struct{ __xmm_reg [16]int8 } + __fpu_ymmh11 struct{ __xmm_reg [16]int8 } + __fpu_ymmh12 struct{ __xmm_reg [16]int8 } + __fpu_ymmh13 struct{ __xmm_reg [16]int8 } + __fpu_ymmh14 struct{ __xmm_reg [16]int8 } + __fpu_ymmh15 struct{ __xmm_reg [16]int8 } + } + _ [4]byte +} + +type __darwin_mcontext_avx512_64 = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint64 + } + __ss struct { + __rax uint64 + __rbx uint64 + __rcx uint64 + __rdx uint64 + __rdi uint64 + __rsi uint64 + __rbp uint64 + __rsp uint64 + __r8 uint64 + __r9 uint64 + __r10 uint64 + __r11 uint64 + __r12 uint64 + __r13 uint64 + __r14 uint64 + __r15 uint64 + __rip uint64 + __rflags uint64 + __cs uint64 + __fs uint64 + __gs uint64 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + __fpu_ymmh8 struct{ __xmm_reg [16]int8 } + __fpu_ymmh9 struct{ __xmm_reg [16]int8 } + __fpu_ymmh10 struct{ __xmm_reg [16]int8 } + __fpu_ymmh11 struct{ __xmm_reg [16]int8 } + __fpu_ymmh12 struct{ __xmm_reg [16]int8 } + __fpu_ymmh13 struct{ __xmm_reg [16]int8 } + __fpu_ymmh14 struct{ __xmm_reg [16]int8 } + __fpu_ymmh15 struct{ __xmm_reg [16]int8 } + __fpu_k0 struct{ __opmask_reg [8]int8 } + __fpu_k1 struct{ __opmask_reg [8]int8 } + __fpu_k2 struct{ __opmask_reg [8]int8 } + __fpu_k3 struct{ __opmask_reg [8]int8 } + __fpu_k4 struct{ __opmask_reg [8]int8 } + __fpu_k5 struct{ __opmask_reg [8]int8 } + __fpu_k6 struct{ __opmask_reg [8]int8 } + __fpu_k7 struct{ __opmask_reg [8]int8 } + __fpu_zmmh0 struct{ __ymm_reg [32]int8 } + __fpu_zmmh1 struct{ __ymm_reg [32]int8 } + __fpu_zmmh2 struct{ __ymm_reg [32]int8 } + __fpu_zmmh3 struct{ __ymm_reg [32]int8 } + __fpu_zmmh4 struct{ __ymm_reg [32]int8 } + __fpu_zmmh5 struct{ __ymm_reg [32]int8 } + __fpu_zmmh6 struct{ __ymm_reg [32]int8 } + __fpu_zmmh7 struct{ __ymm_reg [32]int8 } + __fpu_zmmh8 struct{ __ymm_reg [32]int8 } + __fpu_zmmh9 struct{ __ymm_reg [32]int8 } + __fpu_zmmh10 struct{ __ymm_reg [32]int8 } + __fpu_zmmh11 struct{ __ymm_reg [32]int8 } + __fpu_zmmh12 struct{ __ymm_reg [32]int8 } + __fpu_zmmh13 struct{ __ymm_reg [32]int8 } + __fpu_zmmh14 struct{ __ymm_reg [32]int8 } + __fpu_zmmh15 struct{ __ymm_reg [32]int8 } + __fpu_zmm16 struct{ __zmm_reg [64]int8 } + __fpu_zmm17 struct{ __zmm_reg [64]int8 } + __fpu_zmm18 struct{ __zmm_reg [64]int8 } + __fpu_zmm19 struct{ __zmm_reg [64]int8 } + __fpu_zmm20 struct{ __zmm_reg [64]int8 } + __fpu_zmm21 struct{ __zmm_reg [64]int8 } + __fpu_zmm22 struct{ __zmm_reg [64]int8 } + __fpu_zmm23 struct{ __zmm_reg [64]int8 } + __fpu_zmm24 struct{ __zmm_reg [64]int8 } + __fpu_zmm25 struct{ __zmm_reg [64]int8 } + __fpu_zmm26 struct{ __zmm_reg [64]int8 } + __fpu_zmm27 struct{ __zmm_reg [64]int8 } + __fpu_zmm28 struct{ __zmm_reg [64]int8 } + __fpu_zmm29 struct{ __zmm_reg [64]int8 } + __fpu_zmm30 struct{ __zmm_reg [64]int8 } + __fpu_zmm31 struct{ __zmm_reg [64]int8 } + } + _ [4]byte +} + +type __darwin_mcontext_avx512_64_full = struct { + __es struct { + __trapno uint16 + __cpu uint16 + __err uint32 + __faultvaddr uint64 + } + __ss struct { + __ss64 struct { + __rax uint64 + __rbx uint64 + __rcx uint64 + __rdx uint64 + __rdi uint64 + __rsi uint64 + __rbp uint64 + __rsp uint64 + __r8 uint64 + __r9 uint64 + __r10 uint64 + __r11 uint64 + __r12 uint64 + __r13 uint64 + __r14 uint64 + __r15 uint64 + __rip uint64 + __rflags uint64 + __cs uint64 + __fs uint64 + __gs uint64 + } + __ds uint64 + __es uint64 + __ss uint64 + __gsbase uint64 + } + __fs struct { + __fpu_reserved [2]int32 + __fpu_fcw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_fsw struct { + _ [0]uint16 + __invalid uint16 + } + __fpu_ftw uint8 + __fpu_rsrv1 uint8 + __fpu_fop uint16 + __fpu_ip uint32 + __fpu_cs uint16 + __fpu_rsrv2 uint16 + __fpu_dp uint32 + __fpu_ds uint16 + __fpu_rsrv3 uint16 + __fpu_mxcsr uint32 + __fpu_mxcsrmask uint32 + __fpu_stmm0 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm1 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm2 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm3 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm4 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm5 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm6 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_stmm7 struct { + __mmst_reg [10]int8 + __mmst_rsrv [6]int8 + } + __fpu_xmm0 struct{ __xmm_reg [16]int8 } + __fpu_xmm1 struct{ __xmm_reg [16]int8 } + __fpu_xmm2 struct{ __xmm_reg [16]int8 } + __fpu_xmm3 struct{ __xmm_reg [16]int8 } + __fpu_xmm4 struct{ __xmm_reg [16]int8 } + __fpu_xmm5 struct{ __xmm_reg [16]int8 } + __fpu_xmm6 struct{ __xmm_reg [16]int8 } + __fpu_xmm7 struct{ __xmm_reg [16]int8 } + __fpu_xmm8 struct{ __xmm_reg [16]int8 } + __fpu_xmm9 struct{ __xmm_reg [16]int8 } + __fpu_xmm10 struct{ __xmm_reg [16]int8 } + __fpu_xmm11 struct{ __xmm_reg [16]int8 } + __fpu_xmm12 struct{ __xmm_reg [16]int8 } + __fpu_xmm13 struct{ __xmm_reg [16]int8 } + __fpu_xmm14 struct{ __xmm_reg [16]int8 } + __fpu_xmm15 struct{ __xmm_reg [16]int8 } + __fpu_rsrv4 [96]int8 + __fpu_reserved1 int32 + __avx_reserved1 [64]int8 + __fpu_ymmh0 struct{ __xmm_reg [16]int8 } + __fpu_ymmh1 struct{ __xmm_reg [16]int8 } + __fpu_ymmh2 struct{ __xmm_reg [16]int8 } + __fpu_ymmh3 struct{ __xmm_reg [16]int8 } + __fpu_ymmh4 struct{ __xmm_reg [16]int8 } + __fpu_ymmh5 struct{ __xmm_reg [16]int8 } + __fpu_ymmh6 struct{ __xmm_reg [16]int8 } + __fpu_ymmh7 struct{ __xmm_reg [16]int8 } + __fpu_ymmh8 struct{ __xmm_reg [16]int8 } + __fpu_ymmh9 struct{ __xmm_reg [16]int8 } + __fpu_ymmh10 struct{ __xmm_reg [16]int8 } + __fpu_ymmh11 struct{ __xmm_reg [16]int8 } + __fpu_ymmh12 struct{ __xmm_reg [16]int8 } + __fpu_ymmh13 struct{ __xmm_reg [16]int8 } + __fpu_ymmh14 struct{ __xmm_reg [16]int8 } + __fpu_ymmh15 struct{ __xmm_reg [16]int8 } + __fpu_k0 struct{ __opmask_reg [8]int8 } + __fpu_k1 struct{ __opmask_reg [8]int8 } + __fpu_k2 struct{ __opmask_reg [8]int8 } + __fpu_k3 struct{ __opmask_reg [8]int8 } + __fpu_k4 struct{ __opmask_reg [8]int8 } + __fpu_k5 struct{ __opmask_reg [8]int8 } + __fpu_k6 struct{ __opmask_reg [8]int8 } + __fpu_k7 struct{ __opmask_reg [8]int8 } + __fpu_zmmh0 struct{ __ymm_reg [32]int8 } + __fpu_zmmh1 struct{ __ymm_reg [32]int8 } + __fpu_zmmh2 struct{ __ymm_reg [32]int8 } + __fpu_zmmh3 struct{ __ymm_reg [32]int8 } + __fpu_zmmh4 struct{ __ymm_reg [32]int8 } + __fpu_zmmh5 struct{ __ymm_reg [32]int8 } + __fpu_zmmh6 struct{ __ymm_reg [32]int8 } + __fpu_zmmh7 struct{ __ymm_reg [32]int8 } + __fpu_zmmh8 struct{ __ymm_reg [32]int8 } + __fpu_zmmh9 struct{ __ymm_reg [32]int8 } + __fpu_zmmh10 struct{ __ymm_reg [32]int8 } + __fpu_zmmh11 struct{ __ymm_reg [32]int8 } + __fpu_zmmh12 struct{ __ymm_reg [32]int8 } + __fpu_zmmh13 struct{ __ymm_reg [32]int8 } + __fpu_zmmh14 struct{ __ymm_reg [32]int8 } + __fpu_zmmh15 struct{ __ymm_reg [32]int8 } + __fpu_zmm16 struct{ __zmm_reg [64]int8 } + __fpu_zmm17 struct{ __zmm_reg [64]int8 } + __fpu_zmm18 struct{ __zmm_reg [64]int8 } + __fpu_zmm19 struct{ __zmm_reg [64]int8 } + __fpu_zmm20 struct{ __zmm_reg [64]int8 } + __fpu_zmm21 struct{ __zmm_reg [64]int8 } + __fpu_zmm22 struct{ __zmm_reg [64]int8 } + __fpu_zmm23 struct{ __zmm_reg [64]int8 } + __fpu_zmm24 struct{ __zmm_reg [64]int8 } + __fpu_zmm25 struct{ __zmm_reg [64]int8 } + __fpu_zmm26 struct{ __zmm_reg [64]int8 } + __fpu_zmm27 struct{ __zmm_reg [64]int8 } + __fpu_zmm28 struct{ __zmm_reg [64]int8 } + __fpu_zmm29 struct{ __zmm_reg [64]int8 } + __fpu_zmm30 struct{ __zmm_reg [64]int8 } + __fpu_zmm31 struct{ __zmm_reg [64]int8 } + } + _ [4]byte +} + +type mcontext_t = uintptr + +type __darwin_sigaltstack = struct { + ss_sp uintptr + ss_size uint64 + ss_flags int32 + _ [4]byte +} + +type stack_t = __darwin_sigaltstack + +type __darwin_ucontext = struct { + uc_onstack int32 + uc_sigmask uint32 + uc_stack struct { + ss_sp uintptr + ss_size uint64 + ss_flags int32 + _ [4]byte + } + uc_link uintptr + uc_mcsize uint64 + uc_mcontext uintptr +} + +type ucontext_t = __darwin_ucontext + +type sigset_t = uint32 + +type sigval = struct { + _ [0]uint64 + sival_int int32 + _ [4]byte +} + +type sigevent = struct { + sigev_notify int32 + sigev_signo int32 + sigev_value struct { + _ [0]uint64 + sival_int int32 + _ [4]byte + } + sigev_notify_function uintptr + sigev_notify_attributes uintptr +} + +type __siginfo = struct { + si_signo int32 + si_errno int32 + si_code int32 + si_pid pid_t + si_uid uid_t + si_status int32 + si_addr uintptr + si_value struct { + _ [0]uint64 + sival_int int32 + _ [4]byte + } + si_band int64 + __pad [7]uint64 +} + +type siginfo_t = __siginfo + +type __sigaction_u = struct{ __sa_handler uintptr } + +type __sigaction = struct { + __sigaction_u struct{ __sa_handler uintptr } + sa_tramp uintptr + sa_mask sigset_t + sa_flags int32 +} + +type sigaction = struct { + __sigaction_u struct{ __sa_handler uintptr } + sa_mask sigset_t + sa_flags int32 +} + +type sig_t = uintptr + +type sigvec = struct { + sv_handler uintptr + sv_mask int32 + sv_flags int32 +} + +type sigstack = struct { + ss_sp uintptr + ss_onstack int32 + _ [4]byte +} + +type timeval = struct { + tv_sec int64 + tv_usec int32 + _ [4]byte +} + +type uuid_t = [16]uint8 + +type tm = struct { + tm_sec int32 + tm_min int32 + tm_hour int32 + tm_mday int32 + tm_mon int32 + tm_year int32 + tm_wday int32 + tm_yday int32 + tm_isdst int32 + _ [4]byte + tm_gmtoff int64 + tm_zone uintptr +} + +type clockid_t = uint32 + +type VFSFile1 = struct { + base sqlite3_file + fsFile uintptr + fd int32 + _ [4]byte + aBuffer uintptr + nBuffer int32 + _ [4]byte + iBufferOfst sqlite3_int64 +} + +type VFSFile = VFSFile1 + +func vfsDirectWrite(tls *libc.TLS, p uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + var ofst off_t + var nWrite size_t + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__)), 178)) + libc.X__builtin_abort(tls) + ofst = libc.Xlseek(tls, (*VFSFile)(unsafe.Pointer(p)).fd, iOfst, 0) + if ofst != iOfst { + return 10 | int32(3)<<8 + } + + nWrite = size_t(libc.Xwrite(tls, (*VFSFile)(unsafe.Pointer(p)).fd, zBuf, uint64(iAmt))) + if nWrite != size_t(iAmt) { + return 10 | int32(3)<<8 + } + + return 0 +} + +var __func__ = *(*[15]int8)(unsafe.Pointer(ts + 13)) + +func vfsFlushBuffer(tls *libc.TLS, p uintptr) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__1)), 198)) + libc.X__builtin_abort(tls) + var rc int32 = 0 + if (*VFSFile)(unsafe.Pointer(p)).nBuffer != 0 { + rc = vfsDirectWrite(tls, p, (*VFSFile)(unsafe.Pointer(p)).aBuffer, (*VFSFile)(unsafe.Pointer(p)).nBuffer, (*VFSFile)(unsafe.Pointer(p)).iBufferOfst) + (*VFSFile)(unsafe.Pointer(p)).nBuffer = 0 + } + return rc +} + +var __func__1 = *(*[15]int8)(unsafe.Pointer(ts + 28)) + +func vfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__4)), 273)) + libc.X__builtin_abort(tls) + var p uintptr = pFile + + if (*VFSFile)(unsafe.Pointer(p)).aBuffer != 0 { + var z uintptr = zBuf + var n int32 = iAmt + var i sqlite3_int64 = iOfst + + for n > 0 { + var nCopy int32 + + if (*VFSFile)(unsafe.Pointer(p)).nBuffer == 8192 || (*VFSFile)(unsafe.Pointer(p)).iBufferOfst+sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) != i { + var rc int32 = vfsFlushBuffer(tls, p) + if rc != 0 { + return rc + } + } + if libc.X__builtin_expect(tls, libc.BoolInt64(!((*VFSFile)(unsafe.Pointer(p)).nBuffer == 0 || (*VFSFile)(unsafe.Pointer(p)).iBufferOfst+sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) == i)), int64(0)) != 0 { + libc.X__assert_rtn(tls, uintptr(unsafe.Pointer(&__func__4)), ts+43, 294, ts+51) + } else { + } + (*VFSFile)(unsafe.Pointer(p)).iBufferOfst = i - sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) + + nCopy = 8192 - (*VFSFile)(unsafe.Pointer(p)).nBuffer + if nCopy > n { + nCopy = n + } + libc.X__builtin___memcpy_chk(tls, (*VFSFile)(unsafe.Pointer(p)).aBuffer+uintptr((*VFSFile)(unsafe.Pointer(p)).nBuffer), z, uint64(nCopy), libc.X__builtin_object_size(tls, (*VFSFile)(unsafe.Pointer(p)).aBuffer+uintptr((*VFSFile)(unsafe.Pointer(p)).nBuffer), 0)) + *(*int32)(unsafe.Pointer(p + 32)) += nCopy + + n = n - nCopy + i = i + sqlite3_int64(nCopy) + z += uintptr(nCopy) + } + } else { + return vfsDirectWrite(tls, p, zBuf, iAmt, iOfst) + } + + return 0 +} + +var __func__4 = *(*[9]int8)(unsafe.Pointer(ts + 97)) + +func vfsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { + return 0 +} + +func vfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__5)), 331)) + libc.X__builtin_abort(tls) + var p uintptr = pFile + var rc int32 + + rc = vfsFlushBuffer(tls, p) + if rc != 0 { + return rc + } + + rc = libc.Xfsync(tls, (*VFSFile)(unsafe.Pointer(p)).fd) + return func() int32 { + if rc == 0 { + return 0 + } + return 10 | int32(4)<<8 + }() +} + +var __func__5 = *(*[8]int8)(unsafe.Pointer(ts + 106)) + +func vfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { + return 0 +} + +func vfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { + return 0 +} + +func vfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { + *(*int32)(unsafe.Pointer(pResOut)) = 0 + return 0 +} + +func vfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { + return 12 +} + +func vfsSectorSize(tls *libc.TLS, pFile uintptr) int32 { + return 0 +} + +func vfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { + return 0 +} + +func vfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { + bp := tls.Alloc(4129) + defer tls.Free(4129) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__8)), 473)) + libc.X__builtin_abort(tls) + var rc int32 + + rc = libc.Xunlink(tls, zPath) + if rc != 0 && *(*int32)(unsafe.Pointer(libc.X__error(tls))) == 2 { + return 0 + } + + if rc == 0 && dirSync != 0 { + var dfd int32 + var i int32 + + sqlite3.Xsqlite3_snprintf(tls, 4096, bp+32, ts+114, libc.VaList(bp+16, zPath)) + *(*int8)(unsafe.Pointer(bp + 32 + 4096)) = int8(0) + for i = int32(libc.Xstrlen(tls, bp+32)); i > 1 && int32(*(*int8)(unsafe.Pointer(bp + 32 + uintptr(i)))) != '/'; i++ { + } + *(*int8)(unsafe.Pointer(bp + 32 + uintptr(i))) = int8(0) + + dfd = libc.Xopen(tls, bp+32, 0x0000, libc.VaList(bp+24, 0)) + if dfd < 0 { + rc = -1 + } else { + rc = libc.Xfsync(tls, dfd) + libc.Xclose(tls, dfd) + } + } + return func() int32 { + if rc == 0 { + return 0 + } + return 10 | int32(10)<<8 + }() +} + +var __func__8 = *(*[10]int8)(unsafe.Pointer(ts + 117)) + +func vfsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { + return uintptr(0) +} + +func vfsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { + sqlite3.Xsqlite3_snprintf(tls, nByte, zErrMsg, ts+127, 0) + *(*int8)(unsafe.Pointer(zErrMsg + uintptr(nByte-1))) = int8(0) +} + +func vfsDlSym(tls *libc.TLS, pVfs uintptr, pH uintptr, z uintptr) uintptr { + return uintptr(0) +} + +func vfsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { + return +} + +func vfsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zByte uintptr) int32 { + return 0 +} + +func vfsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { + libc.Xsleep(tls, uint32(nMicro/1000000)) + libc.Xusleep(tls, uint32(nMicro%1000000)) + return nMicro +} + +func vfsCurrentTime(tls *libc.TLS, pVfs uintptr, pTime uintptr) int32 { + var t time_t = libc.Xtime(tls, uintptr(0)) + *(*float64)(unsafe.Pointer(pTime)) = float64(t)/86400.0 + 2440587.5 + return 0 +} + +func Xsqlite3_fsFS(tls *libc.TLS, zName uintptr, pAppData uintptr) uintptr { + var p uintptr = libc.Xmalloc(tls, types.Size_t(unsafe.Sizeof(sqlite3_vfs{}))) + if !(p != 0) { + return uintptr(0) + } + + *(*sqlite3_vfs)(unsafe.Pointer(p)) = sqlite3_vfs{ + iVersion: 1, + szOsFile: int32(unsafe.Sizeof(VFSFile{})), + mxPathname: 4096, + zName: zName, + pAppData: pAppData, + xOpen: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 + }{vfsOpen})), + xDelete: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32) int32 + }{vfsDelete})), + xAccess: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{vfsAccess})), + xFullPathname: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{vfsFullPathname})), + xDlOpen: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) uintptr + }{vfsDlOpen})), + xDlError: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{vfsDlError})), + xDlSym: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr + }{vfsDlSym})), + xDlClose: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) + }{vfsDlClose})), + xRandomness: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) int32 + }{vfsRandomness})), + xSleep: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32) int32 + }{vfsSleep})), + xCurrentTime: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) int32 + }{vfsCurrentTime}))} + return p +} + +var ts1 = "TODO %s:%i:\n\x00vfsDirectWrite\x00vfsFlushBuffer\x00c/vfs.c\x00p->nBuffer==0 || p->iBufferOfst+p->nBuffer==i\x00vfsWrite\x00vfsSync\x00%s\x00vfsDelete\x00Loadable extensions are not supported\x00" +var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data diff --git a/internal/engine/vfs/vfs_darwin_arm64.go b/internal/engine/vfs/vfs_darwin_arm64.go new file mode 100644 index 0000000..ffbb3b3 --- /dev/null +++ b/internal/engine/vfs/vfs_darwin_arm64.go @@ -0,0 +1,1342 @@ +// Code generated by 'ccgo -o vfs_darwin_arm64.go c/vfs.c -I../testdata/sqlite-amalgamation-3380500 -lgithub.com/hanzoai/sqlite/internal/engine/lib -pkgname vfs -nocapi -export-externs X -D SQLITE_OS_UNIX -hide=vfsFullPathname -hide=vfsOpen -hide=vfsRead -hide=vfsAccess -hide=vfsFileSize -hide=vfsClose', DO NOT EDIT. + +package vfs + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/engine/lib" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer +var _ *libc.TLS +var _ types.Size_t + +const ( + FILESEC_OWNER = 1 + FILESEC_GROUP = 2 + FILESEC_UUID = 3 + FILESEC_MODE = 4 + FILESEC_ACL = 5 + FILESEC_GRPUUID = 6 + + FILESEC_ACL_RAW = 100 + FILESEC_ACL_ALLOCSIZE = 101 +) + +const ( + _CLOCK_REALTIME = 0 + _CLOCK_MONOTONIC = 6 + _CLOCK_MONOTONIC_RAW = 4 + _CLOCK_MONOTONIC_RAW_APPROX = 5 + _CLOCK_UPTIME_RAW = 8 + _CLOCK_UPTIME_RAW_APPROX = 9 + _CLOCK_PROCESS_CPUTIME_ID = 12 + _CLOCK_THREAD_CPUTIME_ID = 16 +) + +type ptrdiff_t = int64 + +type size_t = uint64 + +type wchar_t = int32 + +var X__darwin_check_fd_set_overflow uintptr + +type va_list = uintptr + +type sqlite_int64 = int64 +type sqlite_uint64 = uint64 +type sqlite3_int64 = sqlite_int64 +type sqlite3_uint64 = sqlite_uint64 + +type sqlite3_callback = uintptr + +type sqlite3_file1 = struct{ pMethods uintptr } + +type sqlite3_file = sqlite3_file1 +type sqlite3_io_methods1 = struct { + iVersion int32 + _ [4]byte + xClose uintptr + xRead uintptr + xWrite uintptr + xTruncate uintptr + xSync uintptr + xFileSize uintptr + xLock uintptr + xUnlock uintptr + xCheckReservedLock uintptr + xFileControl uintptr + xSectorSize uintptr + xDeviceCharacteristics uintptr + xShmMap uintptr + xShmLock uintptr + xShmBarrier uintptr + xShmUnmap uintptr + xFetch uintptr + xUnfetch uintptr +} + +type sqlite3_io_methods = sqlite3_io_methods1 + +type sqlite3_vfs1 = struct { + iVersion int32 + szOsFile int32 + mxPathname int32 + _ [4]byte + pNext uintptr + zName uintptr + pAppData uintptr + xOpen uintptr + xDelete uintptr + xAccess uintptr + xFullPathname uintptr + xDlOpen uintptr + xDlError uintptr + xDlSym uintptr + xDlClose uintptr + xRandomness uintptr + xSleep uintptr + xCurrentTime uintptr + xGetLastError uintptr + xCurrentTimeInt64 uintptr + xSetSystemCall uintptr + xGetSystemCall uintptr + xNextSystemCall uintptr +} + +type sqlite3_vfs = sqlite3_vfs1 +type sqlite3_syscall_ptr = uintptr + +type sqlite3_mem_methods1 = struct { + xMalloc uintptr + xFree uintptr + xRealloc uintptr + xSize uintptr + xRoundup uintptr + xInit uintptr + xShutdown uintptr + pAppData uintptr +} + +type sqlite3_mem_methods = sqlite3_mem_methods1 + +type sqlite3_destructor_type = uintptr + +type sqlite3_vtab1 = struct { + pModule uintptr + nRef int32 + _ [4]byte + zErrMsg uintptr +} + +type sqlite3_vtab = sqlite3_vtab1 +type sqlite3_index_info1 = struct { + nConstraint int32 + _ [4]byte + aConstraint uintptr + nOrderBy int32 + _ [4]byte + aOrderBy uintptr + aConstraintUsage uintptr + idxNum int32 + _ [4]byte + idxStr uintptr + needToFreeIdxStr int32 + orderByConsumed int32 + estimatedCost float64 + estimatedRows sqlite3_int64 + idxFlags int32 + _ [4]byte + colUsed sqlite3_uint64 +} + +type sqlite3_index_info = sqlite3_index_info1 +type sqlite3_vtab_cursor1 = struct{ pVtab uintptr } + +type sqlite3_vtab_cursor = sqlite3_vtab_cursor1 +type sqlite3_module1 = struct { + iVersion int32 + _ [4]byte + xCreate uintptr + xConnect uintptr + xBestIndex uintptr + xDisconnect uintptr + xDestroy uintptr + xOpen uintptr + xClose uintptr + xFilter uintptr + xNext uintptr + xEof uintptr + xColumn uintptr + xRowid uintptr + xUpdate uintptr + xBegin uintptr + xSync uintptr + xCommit uintptr + xRollback uintptr + xFindFunction uintptr + xRename uintptr + xSavepoint uintptr + xRelease uintptr + xRollbackTo uintptr + xShadowName uintptr +} + +type sqlite3_module = sqlite3_module1 + +type sqlite3_index_constraint = struct { + iColumn int32 + op uint8 + usable uint8 + _ [2]byte + iTermOffset int32 +} + +type sqlite3_index_orderby = struct { + iColumn int32 + desc uint8 + _ [3]byte +} + +type sqlite3_index_constraint_usage = struct { + argvIndex int32 + omit uint8 + _ [3]byte +} + +type sqlite3_mutex_methods1 = struct { + xMutexInit uintptr + xMutexEnd uintptr + xMutexAlloc uintptr + xMutexFree uintptr + xMutexEnter uintptr + xMutexTry uintptr + xMutexLeave uintptr + xMutexHeld uintptr + xMutexNotheld uintptr +} + +type sqlite3_mutex_methods = sqlite3_mutex_methods1 + +type sqlite3_pcache_page1 = struct { + pBuf uintptr + pExtra uintptr +} + +type sqlite3_pcache_page = sqlite3_pcache_page1 + +type sqlite3_pcache_methods21 = struct { + iVersion int32 + _ [4]byte + pArg uintptr + xInit uintptr + xShutdown uintptr + xCreate uintptr + xCachesize uintptr + xPagecount uintptr + xFetch uintptr + xUnpin uintptr + xRekey uintptr + xTruncate uintptr + xDestroy uintptr + xShrink uintptr +} + +type sqlite3_pcache_methods2 = sqlite3_pcache_methods21 + +type sqlite3_pcache_methods1 = struct { + pArg uintptr + xInit uintptr + xShutdown uintptr + xCreate uintptr + xCachesize uintptr + xPagecount uintptr + xFetch uintptr + xUnpin uintptr + xRekey uintptr + xTruncate uintptr + xDestroy uintptr +} + +type sqlite3_pcache_methods = sqlite3_pcache_methods1 + +type sqlite3_snapshot1 = struct{ hidden [48]uint8 } + +type sqlite3_snapshot = sqlite3_snapshot1 + +type sqlite3_rtree_geometry1 = struct { + pContext uintptr + nParam int32 + _ [4]byte + aParam uintptr + pUser uintptr + xDelUser uintptr +} + +type sqlite3_rtree_geometry = sqlite3_rtree_geometry1 +type sqlite3_rtree_query_info1 = struct { + pContext uintptr + nParam int32 + _ [4]byte + aParam uintptr + pUser uintptr + xDelUser uintptr + aCoord uintptr + anQueue uintptr + nCoord int32 + iLevel int32 + mxLevel int32 + _ [4]byte + iRowid sqlite3_int64 + rParentScore sqlite3_rtree_dbl + eParentWithin int32 + eWithin int32 + rScore sqlite3_rtree_dbl + apSqlParam uintptr +} + +type sqlite3_rtree_query_info = sqlite3_rtree_query_info1 + +type sqlite3_rtree_dbl = float64 + +type Fts5ExtensionApi1 = struct { + iVersion int32 + _ [4]byte + xUserData uintptr + xColumnCount uintptr + xRowCount uintptr + xColumnTotalSize uintptr + xTokenize uintptr + xPhraseCount uintptr + xPhraseSize uintptr + xInstCount uintptr + xInst uintptr + xRowid uintptr + xColumnText uintptr + xColumnSize uintptr + xQueryPhrase uintptr + xSetAuxdata uintptr + xGetAuxdata uintptr + xPhraseFirst uintptr + xPhraseNext uintptr + xPhraseFirstColumn uintptr + xPhraseNextColumn uintptr +} + +type Fts5ExtensionApi = Fts5ExtensionApi1 +type Fts5PhraseIter1 = struct { + a uintptr + b uintptr +} + +type Fts5PhraseIter = Fts5PhraseIter1 + +type fts5_extension_function = uintptr +type fts5_tokenizer1 = struct { + xCreate uintptr + xDelete uintptr + xTokenize uintptr +} + +type fts5_tokenizer = fts5_tokenizer1 + +type fts5_api1 = struct { + iVersion int32 + _ [4]byte + xCreateTokenizer uintptr + xFindTokenizer uintptr + xCreateFunction uintptr +} + +type fts5_api = fts5_api1 + +type __darwin_pthread_handler_rec = struct { + __routine uintptr + __arg uintptr + __next uintptr +} + +type _opaque_pthread_attr_t = struct { + __sig int64 + __opaque [56]int8 +} + +type _opaque_pthread_cond_t = struct { + __sig int64 + __opaque [40]int8 +} + +type _opaque_pthread_condattr_t = struct { + __sig int64 + __opaque [8]int8 +} + +type _opaque_pthread_mutex_t = struct { + __sig int64 + __opaque [56]int8 +} + +type _opaque_pthread_mutexattr_t = struct { + __sig int64 + __opaque [8]int8 +} + +type _opaque_pthread_once_t = struct { + __sig int64 + __opaque [8]int8 +} + +type _opaque_pthread_rwlock_t = struct { + __sig int64 + __opaque [192]int8 +} + +type _opaque_pthread_rwlockattr_t = struct { + __sig int64 + __opaque [16]int8 +} + +type _opaque_pthread_t = struct { + __sig int64 + __cleanup_stack uintptr + __opaque [8176]int8 +} + +type int8_t = int8 + +type int16_t = int16 + +type int32_t = int32 + +type int64_t = int64 + +type u_int8_t = uint8 + +type u_int16_t = uint16 + +type u_int32_t = uint32 + +type u_int64_t = uint64 + +type register_t = int64_t + +type intptr_t = int64 + +type uintptr_t = uint64 + +type user_addr_t = u_int64_t +type user_size_t = u_int64_t +type user_ssize_t = int64_t +type user_long_t = int64_t +type user_ulong_t = u_int64_t +type user_time_t = int64_t +type user_off_t = int64_t + +type syscall_arg_t = u_int64_t + +type rsize_t = uint64 + +type errno_t = int32 + +type ssize_t = int64 +type uint64_t = uint64 + +type int_least64_t = int64_t +type uint_least64_t = uint64_t +type int_fast64_t = int64_t +type uint_fast64_t = uint64_t + +type uint32_t = uint32 + +type int_least32_t = int32_t +type uint_least32_t = uint32_t +type int_fast32_t = int32_t +type uint_fast32_t = uint32_t +type uint16_t = uint16 + +type int_least16_t = int16_t +type uint_least16_t = uint16_t +type int_fast16_t = int16_t +type uint_fast16_t = uint16_t +type uint8_t = uint8 + +type int_least8_t = int8_t +type uint_least8_t = uint8_t +type int_fast8_t = int8_t +type uint_fast8_t = uint8_t + +type intmax_t = int64 +type uintmax_t = uint64 + +func _OSSwapInt16(tls *libc.TLS, _data uint16_t) uint16_t { + return uint16_t(int32(_data)<<8 | int32(_data)>>8) +} + +func _OSSwapInt32(tls *libc.TLS, _data uint32_t) uint32_t { + _data = libc.X__builtin_bswap32(tls, _data) + + return _data +} + +func _OSSwapInt64(tls *libc.TLS, _data uint64_t) uint64_t { + return libc.X__builtin_bswap64(tls, _data) +} + +type _OSUnalignedU16 = struct{ __val uint16_t } + +type _OSUnalignedU32 = struct{ __val uint32_t } + +type _OSUnalignedU64 = struct{ __val uint64_t } + +type u_char = uint8 + +type u_short = uint16 + +type u_int = uint32 +type u_long = uint64 +type ushort = uint16 +type uint = uint32 + +type u_quad_t = u_int64_t +type quad_t = int64_t +type qaddr_t = uintptr + +type caddr_t = uintptr + +type daddr_t = int32_t + +type dev_t = int32 + +type fixpt_t = u_int32_t + +type blkcnt_t = int64 + +type blksize_t = int32 + +type gid_t = uint32 + +type in_addr_t = uint32 + +type in_port_t = uint16 + +type ino_t = uint64 + +type ino64_t = uint64 + +type key_t = int32 + +type mode_t = uint16 + +type nlink_t = uint16 + +type id_t = uint32 + +type pid_t = int32 + +type off_t = int64 + +type segsz_t = int32_t +type swblk_t = int32_t + +type uid_t = uint32 + +type clock_t = uint64 + +type time_t = int64 + +type useconds_t = uint32 + +type suseconds_t = int32 + +type fd_set1 = struct{ fds_bits [32]int32 } + +type fd_set = fd_set1 + +func X__darwin_check_fd_set(tls *libc.TLS, _a int32, _b uintptr) int32 { + if uintptr_t(uintptr(unsafe.Pointer(&X__darwin_check_fd_set_overflow))) != uint64(0) { + return (*struct { + f func(*libc.TLS, int32, uintptr, int32) int32 + })(unsafe.Pointer(&struct{ uintptr }{X__darwin_check_fd_set_overflow})).f(tls, _a, _b, 0) + } else { + return 1 + } + return int32(0) +} + +func X__darwin_fd_isset(tls *libc.TLS, _fd int32, _p uintptr) int32 { + if X__darwin_check_fd_set(tls, _fd, _p) != 0 { + return *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) & int32(uint64(1)<<(uint64(_fd)%(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))) + } + + return 0 +} + +func X__darwin_fd_set(tls *libc.TLS, _fd int32, _p uintptr) { + if X__darwin_check_fd_set(tls, _fd, _p) != 0 { + *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) |= int32(uint64(1) << (uint64(_fd) % (uint64(unsafe.Sizeof(int32(0))) * uint64(8)))) + } +} + +func X__darwin_fd_clr(tls *libc.TLS, _fd int32, _p uintptr) { + if X__darwin_check_fd_set(tls, _fd, _p) != 0 { + *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) &= ^int32(uint64(1) << (uint64(_fd) % (uint64(unsafe.Sizeof(int32(0))) * uint64(8)))) + } +} + +type fd_mask = int32 + +type pthread_attr_t = _opaque_pthread_attr_t + +type pthread_cond_t = _opaque_pthread_cond_t + +type pthread_condattr_t = _opaque_pthread_condattr_t + +type pthread_mutex_t = _opaque_pthread_mutex_t + +type pthread_mutexattr_t = _opaque_pthread_mutexattr_t + +type pthread_once_t = _opaque_pthread_once_t + +type pthread_rwlock_t = _opaque_pthread_rwlock_t + +type pthread_rwlockattr_t = _opaque_pthread_rwlockattr_t + +type pthread_t = uintptr + +type pthread_key_t = uint64 + +type fsblkcnt_t = uint32 + +type fsfilcnt_t = uint32 + +type timespec = struct { + tv_sec int64 + tv_nsec int64 +} + +type ostat = struct { + st_dev uint16 + _ [6]byte + st_ino ino_t + st_mode mode_t + st_nlink nlink_t + st_uid uint16 + st_gid uint16 + st_rdev uint16 + _ [2]byte + st_size int32 + st_atimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_mtimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_ctimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_blksize int32 + st_blocks int32 + st_flags uint32 + st_gen uint32 +} + +type stat = struct { + st_dev dev_t + st_mode mode_t + st_nlink nlink_t + st_ino uint64 + st_uid uid_t + st_gid gid_t + st_rdev dev_t + _ [4]byte + st_atimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_mtimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_ctimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_birthtimespec struct { + tv_sec int64 + tv_nsec int64 + } + st_size off_t + st_blocks blkcnt_t + st_blksize blksize_t + st_flags uint32 + st_gen uint32 + st_lspare int32 + st_qspare [2]int64 +} + +type filesec_t = uintptr + +type flock = struct { + l_start off_t + l_len off_t + l_pid pid_t + l_type int16 + l_whence int16 +} + +type flocktimeout = struct { + fl struct { + l_start off_t + l_len off_t + l_pid pid_t + l_type int16 + l_whence int16 + } + timeout struct { + tv_sec int64 + tv_nsec int64 + } +} + +type radvisory = struct { + ra_offset off_t + ra_count int32 + _ [4]byte +} + +type fsignatures = struct { + fs_file_start off_t + fs_blob_start uintptr + fs_blob_size size_t + fs_fsignatures_size size_t + fs_cdhash [20]int8 + fs_hash_type int32 +} + +type fsignatures_t = fsignatures + +type fsupplement = struct { + fs_file_start off_t + fs_blob_start off_t + fs_blob_size size_t + fs_orig_fd int32 + _ [4]byte +} + +type fsupplement_t = fsupplement + +type fchecklv = struct { + lv_file_start off_t + lv_error_message_size size_t + lv_error_message uintptr +} + +type fchecklv_t = fchecklv + +type fgetsigsinfo = struct { + fg_file_start off_t + fg_info_request int32 + fg_sig_is_platform int32 +} + +type fgetsigsinfo_t = fgetsigsinfo + +type fstore = struct { + fst_flags uint32 + fst_posmode int32 + fst_offset off_t + fst_length off_t + fst_bytesalloc off_t +} + +type fstore_t = fstore + +type fpunchhole = struct { + fp_flags uint32 + reserved uint32 + fp_offset off_t + fp_length off_t +} + +type fpunchhole_t = fpunchhole + +type ftrimactivefile = struct { + fta_offset off_t + fta_length off_t +} + +type ftrimactivefile_t = ftrimactivefile + +type fspecread = struct { + fsr_flags uint32 + reserved uint32 + fsr_offset off_t + fsr_length off_t +} + +type fspecread_t = fspecread + +type fbootstraptransfer = struct { + fbt_offset off_t + fbt_length size_t + fbt_buffer uintptr +} + +type fbootstraptransfer_t = fbootstraptransfer + +type log2phys = struct { + l2p_flags uint32 + _ [4]byte + l2p_contigbytes off_t + l2p_devoffset off_t +} + +type filesec_property_t = uint32 + +type accessx_descriptor = struct { + ad_name_offset uint32 + ad_flags int32 + ad_pad [2]int32 +} + +type kauth_cred_t = uintptr +type posix_cred_t = uintptr + +type sig_atomic_t = int32 + +type __darwin_arm_exception_state = struct { + __exception uint32 + __fsr uint32 + __far uint32 +} + +type __darwin_arm_exception_state64 = struct { + __far uint64 + __esr uint32 + __exception uint32 +} + +type __darwin_arm_thread_state = struct { + __r [13]uint32 + __sp uint32 + __lr uint32 + __pc uint32 + __cpsr uint32 +} + +type __darwin_arm_thread_state64 = struct { + __x [29]uint64 + __fp uint64 + __lr uint64 + __sp uint64 + __pc uint64 + __cpsr uint32 + __pad uint32 +} + +type __darwin_arm_vfp_state = struct { + __r [64]uint32 + __fpscr uint32 +} + +type __darwin_arm_neon_state64 = struct { + __v [32]struct { + lo uint64 + hi uint64 + } + __fpsr uint32 + __fpcr uint32 +} + +type __darwin_arm_neon_state = struct { + __v [16]struct { + lo uint64 + hi uint64 + } + __fpsr uint32 + __fpcr uint32 +} + +type __arm_pagein_state = struct{ __pagein_error int32 } + +type __arm_legacy_debug_state = struct { + __bvr [16]uint32 + __bcr [16]uint32 + __wvr [16]uint32 + __wcr [16]uint32 +} + +type __darwin_arm_debug_state32 = struct { + __bvr [16]uint32 + __bcr [16]uint32 + __wvr [16]uint32 + __wcr [16]uint32 + __mdscr_el1 uint64 +} + +type __darwin_arm_debug_state64 = struct { + __bvr [16]uint64 + __bcr [16]uint64 + __wvr [16]uint64 + __wcr [16]uint64 + __mdscr_el1 uint64 +} + +type __darwin_arm_cpmu_state64 = struct{ __ctrs [16]uint64 } + +type __darwin_mcontext32 = struct { + __es struct { + __exception uint32 + __fsr uint32 + __far uint32 + } + __ss struct { + __r [13]uint32 + __sp uint32 + __lr uint32 + __pc uint32 + __cpsr uint32 + } + __fs struct { + __r [64]uint32 + __fpscr uint32 + } +} + +type __darwin_mcontext64 = struct { + __es struct { + __far uint64 + __esr uint32 + __exception uint32 + } + __ss struct { + __x [29]uint64 + __fp uint64 + __lr uint64 + __sp uint64 + __pc uint64 + __cpsr uint32 + __pad uint32 + } + __ns struct { + __v [32]struct { + lo uint64 + hi uint64 + } + __fpsr uint32 + __fpcr uint32 + } +} + +type mcontext_t = uintptr + +type __darwin_sigaltstack = struct { + ss_sp uintptr + ss_size uint64 + ss_flags int32 + _ [4]byte +} + +type stack_t = __darwin_sigaltstack + +type __darwin_ucontext = struct { + uc_onstack int32 + uc_sigmask uint32 + uc_stack struct { + ss_sp uintptr + ss_size uint64 + ss_flags int32 + _ [4]byte + } + uc_link uintptr + uc_mcsize uint64 + uc_mcontext uintptr +} + +type ucontext_t = __darwin_ucontext + +type sigset_t = uint32 + +type sigval = struct { + _ [0]uint64 + sival_int int32 + _ [4]byte +} + +type sigevent = struct { + sigev_notify int32 + sigev_signo int32 + sigev_value struct { + _ [0]uint64 + sival_int int32 + _ [4]byte + } + sigev_notify_function uintptr + sigev_notify_attributes uintptr +} + +type __siginfo = struct { + si_signo int32 + si_errno int32 + si_code int32 + si_pid pid_t + si_uid uid_t + si_status int32 + si_addr uintptr + si_value struct { + _ [0]uint64 + sival_int int32 + _ [4]byte + } + si_band int64 + __pad [7]uint64 +} + +type siginfo_t = __siginfo + +type __sigaction_u = struct{ __sa_handler uintptr } + +type __sigaction = struct { + __sigaction_u struct{ __sa_handler uintptr } + sa_tramp uintptr + sa_mask sigset_t + sa_flags int32 +} + +type sigaction = struct { + __sigaction_u struct{ __sa_handler uintptr } + sa_mask sigset_t + sa_flags int32 +} + +type sig_t = uintptr + +type sigvec = struct { + sv_handler uintptr + sv_mask int32 + sv_flags int32 +} + +type sigstack = struct { + ss_sp uintptr + ss_onstack int32 + _ [4]byte +} + +type timeval = struct { + tv_sec int64 + tv_usec int32 + _ [4]byte +} + +type uuid_t = [16]uint8 + +type tm = struct { + tm_sec int32 + tm_min int32 + tm_hour int32 + tm_mday int32 + tm_mon int32 + tm_year int32 + tm_wday int32 + tm_yday int32 + tm_isdst int32 + _ [4]byte + tm_gmtoff int64 + tm_zone uintptr +} + +type clockid_t = uint32 + +type VFSFile1 = struct { + base sqlite3_file + fsFile uintptr + fd int32 + _ [4]byte + aBuffer uintptr + nBuffer int32 + _ [4]byte + iBufferOfst sqlite3_int64 +} + +type VFSFile = VFSFile1 + +func vfsDirectWrite(tls *libc.TLS, p uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + var ofst off_t + var nWrite size_t + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__)), 178)) + libc.X__builtin_abort(tls) + ofst = libc.Xlseek(tls, (*VFSFile)(unsafe.Pointer(p)).fd, iOfst, 0) + if ofst != iOfst { + return 10 | int32(3)<<8 + } + + nWrite = size_t(libc.Xwrite(tls, (*VFSFile)(unsafe.Pointer(p)).fd, zBuf, uint64(iAmt))) + if nWrite != size_t(iAmt) { + return 10 | int32(3)<<8 + } + + return 0 +} + +var __func__ = *(*[15]int8)(unsafe.Pointer(ts + 13)) + +func vfsFlushBuffer(tls *libc.TLS, p uintptr) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__1)), 198)) + libc.X__builtin_abort(tls) + var rc int32 = 0 + if (*VFSFile)(unsafe.Pointer(p)).nBuffer != 0 { + rc = vfsDirectWrite(tls, p, (*VFSFile)(unsafe.Pointer(p)).aBuffer, (*VFSFile)(unsafe.Pointer(p)).nBuffer, (*VFSFile)(unsafe.Pointer(p)).iBufferOfst) + (*VFSFile)(unsafe.Pointer(p)).nBuffer = 0 + } + return rc +} + +var __func__1 = *(*[15]int8)(unsafe.Pointer(ts + 28)) + +func vfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__4)), 273)) + libc.X__builtin_abort(tls) + var p uintptr = pFile + + if (*VFSFile)(unsafe.Pointer(p)).aBuffer != 0 { + var z uintptr = zBuf + var n int32 = iAmt + var i sqlite3_int64 = iOfst + + for n > 0 { + var nCopy int32 + + if (*VFSFile)(unsafe.Pointer(p)).nBuffer == 8192 || (*VFSFile)(unsafe.Pointer(p)).iBufferOfst+sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) != i { + var rc int32 = vfsFlushBuffer(tls, p) + if rc != 0 { + return rc + } + } + if libc.X__builtin_expect(tls, libc.BoolInt64(!((*VFSFile)(unsafe.Pointer(p)).nBuffer == 0 || (*VFSFile)(unsafe.Pointer(p)).iBufferOfst+sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) == i)), int64(0)) != 0 { + libc.X__assert_rtn(tls, uintptr(unsafe.Pointer(&__func__4)), ts+43, 294, ts+51) + } else { + } + (*VFSFile)(unsafe.Pointer(p)).iBufferOfst = i - sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) + + nCopy = 8192 - (*VFSFile)(unsafe.Pointer(p)).nBuffer + if nCopy > n { + nCopy = n + } + libc.X__builtin___memcpy_chk(tls, (*VFSFile)(unsafe.Pointer(p)).aBuffer+uintptr((*VFSFile)(unsafe.Pointer(p)).nBuffer), z, uint64(nCopy), libc.X__builtin_object_size(tls, (*VFSFile)(unsafe.Pointer(p)).aBuffer+uintptr((*VFSFile)(unsafe.Pointer(p)).nBuffer), 0)) + *(*int32)(unsafe.Pointer(p + 32)) += nCopy + + n = n - nCopy + i = i + sqlite3_int64(nCopy) + z += uintptr(nCopy) + } + } else { + return vfsDirectWrite(tls, p, zBuf, iAmt, iOfst) + } + + return 0 +} + +var __func__4 = *(*[9]int8)(unsafe.Pointer(ts + 97)) + +func vfsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { + return 0 +} + +func vfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__5)), 331)) + libc.X__builtin_abort(tls) + var p uintptr = pFile + var rc int32 + + rc = vfsFlushBuffer(tls, p) + if rc != 0 { + return rc + } + + rc = libc.Xfsync(tls, (*VFSFile)(unsafe.Pointer(p)).fd) + return func() int32 { + if rc == 0 { + return 0 + } + return 10 | int32(4)<<8 + }() +} + +var __func__5 = *(*[8]int8)(unsafe.Pointer(ts + 106)) + +func vfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { + return 0 +} + +func vfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { + return 0 +} + +func vfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { + *(*int32)(unsafe.Pointer(pResOut)) = 0 + return 0 +} + +func vfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { + return 12 +} + +func vfsSectorSize(tls *libc.TLS, pFile uintptr) int32 { + return 0 +} + +func vfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { + return 0 +} + +func vfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { + bp := tls.Alloc(4129) + defer tls.Free(4129) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__8)), 473)) + libc.X__builtin_abort(tls) + var rc int32 + + rc = libc.Xunlink(tls, zPath) + if rc != 0 && *(*int32)(unsafe.Pointer(libc.X__error(tls))) == 2 { + return 0 + } + + if rc == 0 && dirSync != 0 { + var dfd int32 + var i int32 + + sqlite3.Xsqlite3_snprintf(tls, 4096, bp+32, ts+114, libc.VaList(bp+16, zPath)) + *(*int8)(unsafe.Pointer(bp + 32 + 4096)) = int8(0) + for i = int32(libc.Xstrlen(tls, bp+32)); i > 1 && int32(*(*int8)(unsafe.Pointer(bp + 32 + uintptr(i)))) != '/'; i++ { + } + *(*int8)(unsafe.Pointer(bp + 32 + uintptr(i))) = int8(0) + + dfd = libc.Xopen(tls, bp+32, 0x0000, libc.VaList(bp+24, 0)) + if dfd < 0 { + rc = -1 + } else { + rc = libc.Xfsync(tls, dfd) + libc.Xclose(tls, dfd) + } + } + return func() int32 { + if rc == 0 { + return 0 + } + return 10 | int32(10)<<8 + }() +} + +var __func__8 = *(*[10]int8)(unsafe.Pointer(ts + 117)) + +func vfsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { + return uintptr(0) +} + +func vfsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { + sqlite3.Xsqlite3_snprintf(tls, nByte, zErrMsg, ts+127, 0) + *(*int8)(unsafe.Pointer(zErrMsg + uintptr(nByte-1))) = int8(0) +} + +func vfsDlSym(tls *libc.TLS, pVfs uintptr, pH uintptr, z uintptr) uintptr { + return uintptr(0) +} + +func vfsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { + return +} + +func vfsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zByte uintptr) int32 { + return 0 +} + +func vfsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { + libc.Xsleep(tls, uint32(nMicro/1000000)) + libc.Xusleep(tls, uint32(nMicro%1000000)) + return nMicro +} + +func vfsCurrentTime(tls *libc.TLS, pVfs uintptr, pTime uintptr) int32 { + var t time_t = libc.Xtime(tls, uintptr(0)) + *(*float64)(unsafe.Pointer(pTime)) = float64(t)/86400.0 + 2440587.5 + return 0 +} + +func Xsqlite3_fsFS(tls *libc.TLS, zName uintptr, pAppData uintptr) uintptr { + var p uintptr = libc.Xmalloc(tls, types.Size_t(unsafe.Sizeof(sqlite3_vfs{}))) + if !(p != 0) { + return uintptr(0) + } + + *(*sqlite3_vfs)(unsafe.Pointer(p)) = sqlite3_vfs{ + iVersion: 1, + szOsFile: int32(unsafe.Sizeof(VFSFile{})), + mxPathname: 4096, + zName: zName, + pAppData: pAppData, + xOpen: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 + }{vfsOpen})), + xDelete: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32) int32 + }{vfsDelete})), + xAccess: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{vfsAccess})), + xFullPathname: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{vfsFullPathname})), + xDlOpen: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) uintptr + }{vfsDlOpen})), + xDlError: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{vfsDlError})), + xDlSym: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr + }{vfsDlSym})), + xDlClose: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) + }{vfsDlClose})), + xRandomness: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) int32 + }{vfsRandomness})), + xSleep: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32) int32 + }{vfsSleep})), + xCurrentTime: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) int32 + }{vfsCurrentTime}))} + return p +} + +var ts1 = "TODO %s:%i:\n\x00vfsDirectWrite\x00vfsFlushBuffer\x00c/vfs.c\x00p->nBuffer==0 || p->iBufferOfst+p->nBuffer==i\x00vfsWrite\x00vfsSync\x00%s\x00vfsDelete\x00Loadable extensions are not supported\x00" +var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data diff --git a/internal/engine/vfs/vfs_linux_amd64.go b/internal/engine/vfs/vfs_linux_amd64.go new file mode 100644 index 0000000..e058be2 --- /dev/null +++ b/internal/engine/vfs/vfs_linux_amd64.go @@ -0,0 +1,1528 @@ +// Code generated by 'ccgo3 -o vfs_linux_amd64.go vfs.c -I../testdata/sqlite-amalgamation-3380500 -lgithub.com/hanzoai/sqlite/internal/engine/lib -pkgname vfs -nocapi -export-externs X -D SQLITE_OS_UNIX -hide=vfsFullPathname -hide=vfsOpen -hide=vfsRead -hide=vfsAccess -hide=vfsFileSize -hide=vfsClose', DO NOT EDIT. + +package vfs + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/engine/lib" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer +var _ *libc.TLS +var _ types.Size_t + +const ( + _PC_LINK_MAX = 0 + _PC_MAX_CANON = 1 + _PC_MAX_INPUT = 2 + _PC_NAME_MAX = 3 + _PC_PATH_MAX = 4 + _PC_PIPE_BUF = 5 + _PC_CHOWN_RESTRICTED = 6 + _PC_NO_TRUNC = 7 + _PC_VDISABLE = 8 + _PC_SYNC_IO = 9 + _PC_ASYNC_IO = 10 + _PC_PRIO_IO = 11 + _PC_SOCK_MAXBUF = 12 + _PC_FILESIZEBITS = 13 + _PC_REC_INCR_XFER_SIZE = 14 + _PC_REC_MAX_XFER_SIZE = 15 + _PC_REC_MIN_XFER_SIZE = 16 + _PC_REC_XFER_ALIGN = 17 + _PC_ALLOC_SIZE_MIN = 18 + _PC_SYMLINK_MAX = 19 + _PC_2_SYMLINKS = 20 +) + +const ( + _CS_PATH = 0 + + _CS_V6_WIDTH_RESTRICTED_ENVS = 1 + + _CS_GNU_LIBC_VERSION = 2 + _CS_GNU_LIBPTHREAD_VERSION = 3 + + _CS_V5_WIDTH_RESTRICTED_ENVS = 4 + + _CS_V7_WIDTH_RESTRICTED_ENVS = 5 + + _CS_LFS_CFLAGS = 1000 + _CS_LFS_LDFLAGS = 1001 + _CS_LFS_LIBS = 1002 + _CS_LFS_LINTFLAGS = 1003 + _CS_LFS64_CFLAGS = 1004 + _CS_LFS64_LDFLAGS = 1005 + _CS_LFS64_LIBS = 1006 + _CS_LFS64_LINTFLAGS = 1007 + + _CS_XBS5_ILP32_OFF32_CFLAGS = 1100 + _CS_XBS5_ILP32_OFF32_LDFLAGS = 1101 + _CS_XBS5_ILP32_OFF32_LIBS = 1102 + _CS_XBS5_ILP32_OFF32_LINTFLAGS = 1103 + _CS_XBS5_ILP32_OFFBIG_CFLAGS = 1104 + _CS_XBS5_ILP32_OFFBIG_LDFLAGS = 1105 + _CS_XBS5_ILP32_OFFBIG_LIBS = 1106 + _CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 1107 + _CS_XBS5_LP64_OFF64_CFLAGS = 1108 + _CS_XBS5_LP64_OFF64_LDFLAGS = 1109 + _CS_XBS5_LP64_OFF64_LIBS = 1110 + _CS_XBS5_LP64_OFF64_LINTFLAGS = 1111 + _CS_XBS5_LPBIG_OFFBIG_CFLAGS = 1112 + _CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 1113 + _CS_XBS5_LPBIG_OFFBIG_LIBS = 1114 + _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 1115 + + _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 + _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 + _CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 + _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 + _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 + _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 + _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 + _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 + _CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 + _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 + _CS_POSIX_V6_LP64_OFF64_LIBS = 1126 + _CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 + _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 + _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 + _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 + _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 + + _CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 + _CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 + _CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 + _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 + _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 + _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 + _CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 + _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 + _CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 + _CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 + _CS_POSIX_V7_LP64_OFF64_LIBS = 1142 + _CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 + _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 + _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 + _CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 + _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 + + _CS_V6_ENV = 1148 + _CS_V7_ENV = 1149 +) + +const ( + _SC_ARG_MAX = 0 + _SC_CHILD_MAX = 1 + _SC_CLK_TCK = 2 + _SC_NGROUPS_MAX = 3 + _SC_OPEN_MAX = 4 + _SC_STREAM_MAX = 5 + _SC_TZNAME_MAX = 6 + _SC_JOB_CONTROL = 7 + _SC_SAVED_IDS = 8 + _SC_REALTIME_SIGNALS = 9 + _SC_PRIORITY_SCHEDULING = 10 + _SC_TIMERS = 11 + _SC_ASYNCHRONOUS_IO = 12 + _SC_PRIORITIZED_IO = 13 + _SC_SYNCHRONIZED_IO = 14 + _SC_FSYNC = 15 + _SC_MAPPED_FILES = 16 + _SC_MEMLOCK = 17 + _SC_MEMLOCK_RANGE = 18 + _SC_MEMORY_PROTECTION = 19 + _SC_MESSAGE_PASSING = 20 + _SC_SEMAPHORES = 21 + _SC_SHARED_MEMORY_OBJECTS = 22 + _SC_AIO_LISTIO_MAX = 23 + _SC_AIO_MAX = 24 + _SC_AIO_PRIO_DELTA_MAX = 25 + _SC_DELAYTIMER_MAX = 26 + _SC_MQ_OPEN_MAX = 27 + _SC_MQ_PRIO_MAX = 28 + _SC_VERSION = 29 + _SC_PAGESIZE = 30 + _SC_RTSIG_MAX = 31 + _SC_SEM_NSEMS_MAX = 32 + _SC_SEM_VALUE_MAX = 33 + _SC_SIGQUEUE_MAX = 34 + _SC_TIMER_MAX = 35 + + _SC_BC_BASE_MAX = 36 + _SC_BC_DIM_MAX = 37 + _SC_BC_SCALE_MAX = 38 + _SC_BC_STRING_MAX = 39 + _SC_COLL_WEIGHTS_MAX = 40 + _SC_EQUIV_CLASS_MAX = 41 + _SC_EXPR_NEST_MAX = 42 + _SC_LINE_MAX = 43 + _SC_RE_DUP_MAX = 44 + _SC_CHARCLASS_NAME_MAX = 45 + + _SC_2_VERSION = 46 + _SC_2_C_BIND = 47 + _SC_2_C_DEV = 48 + _SC_2_FORT_DEV = 49 + _SC_2_FORT_RUN = 50 + _SC_2_SW_DEV = 51 + _SC_2_LOCALEDEF = 52 + + _SC_PII = 53 + _SC_PII_XTI = 54 + _SC_PII_SOCKET = 55 + _SC_PII_INTERNET = 56 + _SC_PII_OSI = 57 + _SC_POLL = 58 + _SC_SELECT = 59 + _SC_UIO_MAXIOV = 60 + _SC_IOV_MAX = 60 + _SC_PII_INTERNET_STREAM = 61 + _SC_PII_INTERNET_DGRAM = 62 + _SC_PII_OSI_COTS = 63 + _SC_PII_OSI_CLTS = 64 + _SC_PII_OSI_M = 65 + _SC_T_IOV_MAX = 66 + + _SC_THREADS = 67 + _SC_THREAD_SAFE_FUNCTIONS = 68 + _SC_GETGR_R_SIZE_MAX = 69 + _SC_GETPW_R_SIZE_MAX = 70 + _SC_LOGIN_NAME_MAX = 71 + _SC_TTY_NAME_MAX = 72 + _SC_THREAD_DESTRUCTOR_ITERATIONS = 73 + _SC_THREAD_KEYS_MAX = 74 + _SC_THREAD_STACK_MIN = 75 + _SC_THREAD_THREADS_MAX = 76 + _SC_THREAD_ATTR_STACKADDR = 77 + _SC_THREAD_ATTR_STACKSIZE = 78 + _SC_THREAD_PRIORITY_SCHEDULING = 79 + _SC_THREAD_PRIO_INHERIT = 80 + _SC_THREAD_PRIO_PROTECT = 81 + _SC_THREAD_PROCESS_SHARED = 82 + + _SC_NPROCESSORS_CONF = 83 + _SC_NPROCESSORS_ONLN = 84 + _SC_PHYS_PAGES = 85 + _SC_AVPHYS_PAGES = 86 + _SC_ATEXIT_MAX = 87 + _SC_PASS_MAX = 88 + + _SC_XOPEN_VERSION = 89 + _SC_XOPEN_XCU_VERSION = 90 + _SC_XOPEN_UNIX = 91 + _SC_XOPEN_CRYPT = 92 + _SC_XOPEN_ENH_I18N = 93 + _SC_XOPEN_SHM = 94 + + _SC_2_CHAR_TERM = 95 + _SC_2_C_VERSION = 96 + _SC_2_UPE = 97 + + _SC_XOPEN_XPG2 = 98 + _SC_XOPEN_XPG3 = 99 + _SC_XOPEN_XPG4 = 100 + + _SC_CHAR_BIT = 101 + _SC_CHAR_MAX = 102 + _SC_CHAR_MIN = 103 + _SC_INT_MAX = 104 + _SC_INT_MIN = 105 + _SC_LONG_BIT = 106 + _SC_WORD_BIT = 107 + _SC_MB_LEN_MAX = 108 + _SC_NZERO = 109 + _SC_SSIZE_MAX = 110 + _SC_SCHAR_MAX = 111 + _SC_SCHAR_MIN = 112 + _SC_SHRT_MAX = 113 + _SC_SHRT_MIN = 114 + _SC_UCHAR_MAX = 115 + _SC_UINT_MAX = 116 + _SC_ULONG_MAX = 117 + _SC_USHRT_MAX = 118 + + _SC_NL_ARGMAX = 119 + _SC_NL_LANGMAX = 120 + _SC_NL_MSGMAX = 121 + _SC_NL_NMAX = 122 + _SC_NL_SETMAX = 123 + _SC_NL_TEXTMAX = 124 + + _SC_XBS5_ILP32_OFF32 = 125 + _SC_XBS5_ILP32_OFFBIG = 126 + _SC_XBS5_LP64_OFF64 = 127 + _SC_XBS5_LPBIG_OFFBIG = 128 + + _SC_XOPEN_LEGACY = 129 + _SC_XOPEN_REALTIME = 130 + _SC_XOPEN_REALTIME_THREADS = 131 + + _SC_ADVISORY_INFO = 132 + _SC_BARRIERS = 133 + _SC_BASE = 134 + _SC_C_LANG_SUPPORT = 135 + _SC_C_LANG_SUPPORT_R = 136 + _SC_CLOCK_SELECTION = 137 + _SC_CPUTIME = 138 + _SC_THREAD_CPUTIME = 139 + _SC_DEVICE_IO = 140 + _SC_DEVICE_SPECIFIC = 141 + _SC_DEVICE_SPECIFIC_R = 142 + _SC_FD_MGMT = 143 + _SC_FIFO = 144 + _SC_PIPE = 145 + _SC_FILE_ATTRIBUTES = 146 + _SC_FILE_LOCKING = 147 + _SC_FILE_SYSTEM = 148 + _SC_MONOTONIC_CLOCK = 149 + _SC_MULTI_PROCESS = 150 + _SC_SINGLE_PROCESS = 151 + _SC_NETWORKING = 152 + _SC_READER_WRITER_LOCKS = 153 + _SC_SPIN_LOCKS = 154 + _SC_REGEXP = 155 + _SC_REGEX_VERSION = 156 + _SC_SHELL = 157 + _SC_SIGNALS = 158 + _SC_SPAWN = 159 + _SC_SPORADIC_SERVER = 160 + _SC_THREAD_SPORADIC_SERVER = 161 + _SC_SYSTEM_DATABASE = 162 + _SC_SYSTEM_DATABASE_R = 163 + _SC_TIMEOUTS = 164 + _SC_TYPED_MEMORY_OBJECTS = 165 + _SC_USER_GROUPS = 166 + _SC_USER_GROUPS_R = 167 + _SC_2_PBS = 168 + _SC_2_PBS_ACCOUNTING = 169 + _SC_2_PBS_LOCATE = 170 + _SC_2_PBS_MESSAGE = 171 + _SC_2_PBS_TRACK = 172 + _SC_SYMLOOP_MAX = 173 + _SC_STREAMS = 174 + _SC_2_PBS_CHECKPOINT = 175 + + _SC_V6_ILP32_OFF32 = 176 + _SC_V6_ILP32_OFFBIG = 177 + _SC_V6_LP64_OFF64 = 178 + _SC_V6_LPBIG_OFFBIG = 179 + + _SC_HOST_NAME_MAX = 180 + _SC_TRACE = 181 + _SC_TRACE_EVENT_FILTER = 182 + _SC_TRACE_INHERIT = 183 + _SC_TRACE_LOG = 184 + + _SC_LEVEL1_ICACHE_SIZE = 185 + _SC_LEVEL1_ICACHE_ASSOC = 186 + _SC_LEVEL1_ICACHE_LINESIZE = 187 + _SC_LEVEL1_DCACHE_SIZE = 188 + _SC_LEVEL1_DCACHE_ASSOC = 189 + _SC_LEVEL1_DCACHE_LINESIZE = 190 + _SC_LEVEL2_CACHE_SIZE = 191 + _SC_LEVEL2_CACHE_ASSOC = 192 + _SC_LEVEL2_CACHE_LINESIZE = 193 + _SC_LEVEL3_CACHE_SIZE = 194 + _SC_LEVEL3_CACHE_ASSOC = 195 + _SC_LEVEL3_CACHE_LINESIZE = 196 + _SC_LEVEL4_CACHE_SIZE = 197 + _SC_LEVEL4_CACHE_ASSOC = 198 + _SC_LEVEL4_CACHE_LINESIZE = 199 + + _SC_IPV6 = 235 + _SC_RAW_SOCKETS = 236 + + _SC_V7_ILP32_OFF32 = 237 + _SC_V7_ILP32_OFFBIG = 238 + _SC_V7_LP64_OFF64 = 239 + _SC_V7_LPBIG_OFFBIG = 240 + + _SC_SS_REPL_MAX = 241 + + _SC_TRACE_EVENT_NAME_MAX = 242 + _SC_TRACE_NAME_MAX = 243 + _SC_TRACE_SYS_MAX = 244 + _SC_TRACE_USER_EVENT_MAX = 245 + + _SC_XOPEN_STREAMS = 246 + + _SC_THREAD_ROBUST_PRIO_INHERIT = 247 + _SC_THREAD_ROBUST_PRIO_PROTECT = 248 +) + +const ( + SIGEV_SIGNAL = 0 + SIGEV_NONE = 1 + SIGEV_THREAD = 2 + + SIGEV_THREAD_ID = 4 +) + +const ( + SEGV_MAPERR = 1 + SEGV_ACCERR = 2 + SEGV_BNDERR = 3 + SEGV_PKUERR = 4 + SEGV_ACCADI = 5 + SEGV_ADIDERR = 6 + SEGV_ADIPERR = 7 +) + +const ( + BUS_ADRALN = 1 + BUS_ADRERR = 2 + BUS_OBJERR = 3 + BUS_MCEERR_AR = 4 + BUS_MCEERR_AO = 5 +) + +const ( + CLD_EXITED = 1 + CLD_KILLED = 2 + CLD_DUMPED = 3 + CLD_TRAPPED = 4 + CLD_STOPPED = 5 + CLD_CONTINUED = 6 +) + +const ( + POLL_IN = 1 + POLL_OUT = 2 + POLL_MSG = 3 + POLL_ERR = 4 + POLL_PRI = 5 + POLL_HUP = 6 +) + +const ( + SI_ASYNCNL = -60 + SI_DETHREAD = -7 + + SI_TKILL = -6 + SI_SIGIO = -5 + SI_ASYNCIO = -4 + SI_MESGQ = -3 + SI_TIMER = -2 + SI_QUEUE = -1 + SI_USER = 0 + SI_KERNEL = 128 +) + +const ( + ILL_ILLOPC = 1 + ILL_ILLOPN = 2 + ILL_ILLADR = 3 + ILL_ILLTRP = 4 + ILL_PRVOPC = 5 + ILL_PRVREG = 6 + ILL_COPROC = 7 + ILL_BADSTK = 8 + ILL_BADIADDR = 9 +) + +const ( + FPE_INTDIV = 1 + FPE_INTOVF = 2 + FPE_FLTDIV = 3 + FPE_FLTOVF = 4 + FPE_FLTUND = 5 + FPE_FLTRES = 6 + FPE_FLTINV = 7 + FPE_FLTSUB = 8 + FPE_FLTUNK = 14 + FPE_CONDTRAP = 15 +) + +const ( + SS_ONSTACK = 1 + SS_DISABLE = 2 +) + +type ptrdiff_t = int64 + +type size_t = uint64 + +type wchar_t = int32 + +type va_list = uintptr + +type sqlite_int64 = int64 +type sqlite_uint64 = uint64 +type sqlite3_int64 = sqlite_int64 +type sqlite3_uint64 = sqlite_uint64 + +type sqlite3_callback = uintptr + +type sqlite3_file1 = struct{ pMethods uintptr } + +type sqlite3_file = sqlite3_file1 +type sqlite3_io_methods1 = struct { + iVersion int32 + _ [4]byte + xClose uintptr + xRead uintptr + xWrite uintptr + xTruncate uintptr + xSync uintptr + xFileSize uintptr + xLock uintptr + xUnlock uintptr + xCheckReservedLock uintptr + xFileControl uintptr + xSectorSize uintptr + xDeviceCharacteristics uintptr + xShmMap uintptr + xShmLock uintptr + xShmBarrier uintptr + xShmUnmap uintptr + xFetch uintptr + xUnfetch uintptr +} + +type sqlite3_io_methods = sqlite3_io_methods1 + +type sqlite3_vfs1 = struct { + iVersion int32 + szOsFile int32 + mxPathname int32 + _ [4]byte + pNext uintptr + zName uintptr + pAppData uintptr + xOpen uintptr + xDelete uintptr + xAccess uintptr + xFullPathname uintptr + xDlOpen uintptr + xDlError uintptr + xDlSym uintptr + xDlClose uintptr + xRandomness uintptr + xSleep uintptr + xCurrentTime uintptr + xGetLastError uintptr + xCurrentTimeInt64 uintptr + xSetSystemCall uintptr + xGetSystemCall uintptr + xNextSystemCall uintptr +} + +type sqlite3_vfs = sqlite3_vfs1 +type sqlite3_syscall_ptr = uintptr + +type sqlite3_mem_methods1 = struct { + xMalloc uintptr + xFree uintptr + xRealloc uintptr + xSize uintptr + xRoundup uintptr + xInit uintptr + xShutdown uintptr + pAppData uintptr +} + +type sqlite3_mem_methods = sqlite3_mem_methods1 + +type sqlite3_destructor_type = uintptr + +type sqlite3_vtab1 = struct { + pModule uintptr + nRef int32 + _ [4]byte + zErrMsg uintptr +} + +type sqlite3_vtab = sqlite3_vtab1 +type sqlite3_index_info1 = struct { + nConstraint int32 + _ [4]byte + aConstraint uintptr + nOrderBy int32 + _ [4]byte + aOrderBy uintptr + aConstraintUsage uintptr + idxNum int32 + _ [4]byte + idxStr uintptr + needToFreeIdxStr int32 + orderByConsumed int32 + estimatedCost float64 + estimatedRows sqlite3_int64 + idxFlags int32 + _ [4]byte + colUsed sqlite3_uint64 +} + +type sqlite3_index_info = sqlite3_index_info1 +type sqlite3_vtab_cursor1 = struct{ pVtab uintptr } + +type sqlite3_vtab_cursor = sqlite3_vtab_cursor1 +type sqlite3_module1 = struct { + iVersion int32 + _ [4]byte + xCreate uintptr + xConnect uintptr + xBestIndex uintptr + xDisconnect uintptr + xDestroy uintptr + xOpen uintptr + xClose uintptr + xFilter uintptr + xNext uintptr + xEof uintptr + xColumn uintptr + xRowid uintptr + xUpdate uintptr + xBegin uintptr + xSync uintptr + xCommit uintptr + xRollback uintptr + xFindFunction uintptr + xRename uintptr + xSavepoint uintptr + xRelease uintptr + xRollbackTo uintptr + xShadowName uintptr +} + +type sqlite3_module = sqlite3_module1 + +type sqlite3_index_constraint = struct { + iColumn int32 + op uint8 + usable uint8 + _ [2]byte + iTermOffset int32 +} + +type sqlite3_index_orderby = struct { + iColumn int32 + desc uint8 + _ [3]byte +} + +type sqlite3_index_constraint_usage = struct { + argvIndex int32 + omit uint8 + _ [3]byte +} + +type sqlite3_mutex_methods1 = struct { + xMutexInit uintptr + xMutexEnd uintptr + xMutexAlloc uintptr + xMutexFree uintptr + xMutexEnter uintptr + xMutexTry uintptr + xMutexLeave uintptr + xMutexHeld uintptr + xMutexNotheld uintptr +} + +type sqlite3_mutex_methods = sqlite3_mutex_methods1 + +type sqlite3_pcache_page1 = struct { + pBuf uintptr + pExtra uintptr +} + +type sqlite3_pcache_page = sqlite3_pcache_page1 + +type sqlite3_pcache_methods21 = struct { + iVersion int32 + _ [4]byte + pArg uintptr + xInit uintptr + xShutdown uintptr + xCreate uintptr + xCachesize uintptr + xPagecount uintptr + xFetch uintptr + xUnpin uintptr + xRekey uintptr + xTruncate uintptr + xDestroy uintptr + xShrink uintptr +} + +type sqlite3_pcache_methods2 = sqlite3_pcache_methods21 + +type sqlite3_pcache_methods1 = struct { + pArg uintptr + xInit uintptr + xShutdown uintptr + xCreate uintptr + xCachesize uintptr + xPagecount uintptr + xFetch uintptr + xUnpin uintptr + xRekey uintptr + xTruncate uintptr + xDestroy uintptr +} + +type sqlite3_pcache_methods = sqlite3_pcache_methods1 + +type sqlite3_snapshot1 = struct{ hidden [48]uint8 } + +type sqlite3_snapshot = sqlite3_snapshot1 + +type sqlite3_rtree_geometry1 = struct { + pContext uintptr + nParam int32 + _ [4]byte + aParam uintptr + pUser uintptr + xDelUser uintptr +} + +type sqlite3_rtree_geometry = sqlite3_rtree_geometry1 +type sqlite3_rtree_query_info1 = struct { + pContext uintptr + nParam int32 + _ [4]byte + aParam uintptr + pUser uintptr + xDelUser uintptr + aCoord uintptr + anQueue uintptr + nCoord int32 + iLevel int32 + mxLevel int32 + _ [4]byte + iRowid sqlite3_int64 + rParentScore sqlite3_rtree_dbl + eParentWithin int32 + eWithin int32 + rScore sqlite3_rtree_dbl + apSqlParam uintptr +} + +type sqlite3_rtree_query_info = sqlite3_rtree_query_info1 + +type sqlite3_rtree_dbl = float64 + +type Fts5ExtensionApi1 = struct { + iVersion int32 + _ [4]byte + xUserData uintptr + xColumnCount uintptr + xRowCount uintptr + xColumnTotalSize uintptr + xTokenize uintptr + xPhraseCount uintptr + xPhraseSize uintptr + xInstCount uintptr + xInst uintptr + xRowid uintptr + xColumnText uintptr + xColumnSize uintptr + xQueryPhrase uintptr + xSetAuxdata uintptr + xGetAuxdata uintptr + xPhraseFirst uintptr + xPhraseNext uintptr + xPhraseFirstColumn uintptr + xPhraseNextColumn uintptr +} + +type Fts5ExtensionApi = Fts5ExtensionApi1 +type Fts5PhraseIter1 = struct { + a uintptr + b uintptr +} + +type Fts5PhraseIter = Fts5PhraseIter1 + +type fts5_extension_function = uintptr +type fts5_tokenizer1 = struct { + xCreate uintptr + xDelete uintptr + xTokenize uintptr +} + +type fts5_tokenizer = fts5_tokenizer1 + +type fts5_api1 = struct { + iVersion int32 + _ [4]byte + xCreateTokenizer uintptr + xFindTokenizer uintptr + xCreateFunction uintptr +} + +type fts5_api = fts5_api1 + +type __locale_struct = struct { + __locales [13]uintptr + __ctype_b uintptr + __ctype_tolower uintptr + __ctype_toupper uintptr + __names [13]uintptr +} + +type locale_t = uintptr + +type u_char = uint8 +type u_short = uint16 +type u_int = uint32 +type u_long = uint64 +type quad_t = int64 +type u_quad_t = uint64 +type fsid_t = struct{ __val [2]int32 } +type loff_t = int64 + +type ino_t = uint64 + +type dev_t = uint64 + +type gid_t = uint32 + +type mode_t = uint32 + +type nlink_t = uint64 + +type uid_t = uint32 + +type off_t = int64 + +type pid_t = int32 + +type id_t = uint32 + +type ssize_t = int64 + +type daddr_t = int32 +type caddr_t = uintptr + +type key_t = int32 + +type clock_t = int64 + +type clockid_t = int32 + +type time_t = int64 + +type timer_t = uintptr + +type ulong = uint64 +type ushort = uint16 +type uint = uint32 + +type int8_t = int8 +type int16_t = int16 +type int32_t = int32 +type int64_t = int64 + +type u_int8_t = uint8 +type u_int16_t = uint16 +type u_int32_t = uint32 +type u_int64_t = uint64 + +type register_t = int32 + +type sigset_t = struct{ __val [16]uint64 } + +type timeval = struct { + tv_sec int64 + tv_usec int64 +} + +type timespec = struct { + tv_sec int64 + tv_nsec int64 +} + +type suseconds_t = int64 + +type fd_set = struct{ __fds_bits [16]int64 } + +type fd_mask = int64 + +type blksize_t = int64 + +type blkcnt_t = int64 +type fsblkcnt_t = uint64 +type fsfilcnt_t = uint64 + +type __pthread_internal_list = struct { + __prev uintptr + __next uintptr +} + +type __pthread_internal_slist = struct{ __next uintptr } + +type __pthread_mutex_s = struct { + __lock int32 + __count uint32 + __owner int32 + __nusers uint32 + __kind int32 + __spins int16 + __elision int16 + __list struct { + __prev uintptr + __next uintptr + } +} + +type __pthread_rwlock_arch_t = struct { + __readers uint32 + __writers uint32 + __wrphase_futex uint32 + __writers_futex uint32 + __pad3 uint32 + __pad4 uint32 + __cur_writer int32 + __shared int32 + __rwelision int8 + __pad1 [7]uint8 + __pad2 uint64 + __flags uint32 + _ [4]byte +} + +type __pthread_cond_s = struct { + __0 struct{ __wseq uint64 } + __8 struct{ __g1_start uint64 } + __g_refs [2]uint32 + __g_size [2]uint32 + __g1_orig_size uint32 + __wrefs uint32 + __g_signals [2]uint32 +} + +type pthread_t = uint64 + +type pthread_mutexattr_t = struct { + _ [0]uint32 + __size [4]int8 +} + +type pthread_condattr_t = struct { + _ [0]uint32 + __size [4]int8 +} + +type pthread_key_t = uint32 + +type pthread_once_t = int32 + +type pthread_attr_t1 = struct { + _ [0]uint64 + __size [56]int8 +} + +type pthread_attr_t = pthread_attr_t1 + +type pthread_mutex_t = struct{ __data __pthread_mutex_s } + +type pthread_cond_t = struct{ __data __pthread_cond_s } + +type pthread_rwlock_t = struct{ __data __pthread_rwlock_arch_t } + +type pthread_rwlockattr_t = struct { + _ [0]uint64 + __size [8]int8 +} + +type pthread_spinlock_t = int32 + +type pthread_barrier_t = struct { + _ [0]uint64 + __size [32]int8 +} + +type pthread_barrierattr_t = struct { + _ [0]uint32 + __size [4]int8 +} + +type stat = struct { + st_dev uint64 + st_ino uint64 + st_nlink uint64 + st_mode uint32 + st_uid uint32 + st_gid uint32 + __pad0 int32 + st_rdev uint64 + st_size int64 + st_blksize int64 + st_blocks int64 + st_atim struct { + tv_sec int64 + tv_nsec int64 + } + st_mtim struct { + tv_sec int64 + tv_nsec int64 + } + st_ctim struct { + tv_sec int64 + tv_nsec int64 + } + __glibc_reserved [3]int64 +} + +type flock = struct { + l_type int16 + l_whence int16 + _ [4]byte + l_start int64 + l_len int64 + l_pid int32 + _ [4]byte +} + +type sig_atomic_t = int32 + +type sigval = struct { + _ [0]uint64 + sival_int int32 + _ [4]byte +} + +type siginfo_t = struct { + si_signo int32 + si_errno int32 + si_code int32 + __pad0 int32 + _sifields struct { + _ [0]uint64 + _pad [28]int32 + } +} + +type sigval_t = sigval + +type sigevent = struct { + sigev_value struct { + _ [0]uint64 + sival_int int32 + _ [4]byte + } + sigev_signo int32 + sigev_notify int32 + _sigev_un struct { + _ [0]uint64 + _pad [12]int32 + } +} + +type sigevent_t = sigevent + +type sig_t = uintptr + +type sigaction = struct { + __sigaction_handler struct{ sa_handler uintptr } + sa_mask struct{ __val [16]uint64 } + sa_flags int32 + _ [4]byte + sa_restorer uintptr +} + +type _fpx_sw_bytes = struct { + magic1 uint32 + extended_size uint32 + xstate_bv uint64 + xstate_size uint32 + __glibc_reserved1 [7]uint32 +} + +type _fpreg = struct { + significand [4]uint16 + exponent uint16 +} + +type _fpxreg = struct { + significand [4]uint16 + exponent uint16 + __glibc_reserved1 [3]uint16 +} + +type _xmmreg = struct{ element [4]uint32 } + +type _fpstate = struct { + cwd uint16 + swd uint16 + ftw uint16 + fop uint16 + rip uint64 + rdp uint64 + mxcsr uint32 + mxcr_mask uint32 + _st [8]struct { + significand [4]uint16 + exponent uint16 + __glibc_reserved1 [3]uint16 + } + _xmm [16]struct{ element [4]uint32 } + __glibc_reserved1 [24]uint32 +} + +type sigcontext = struct { + r8 uint64 + r9 uint64 + r10 uint64 + r11 uint64 + r12 uint64 + r13 uint64 + r14 uint64 + r15 uint64 + rdi uint64 + rsi uint64 + rbp uint64 + rbx uint64 + rdx uint64 + rax uint64 + rcx uint64 + rsp uint64 + rip uint64 + eflags uint64 + cs uint16 + gs uint16 + fs uint16 + __pad0 uint16 + err uint64 + trapno uint64 + oldmask uint64 + cr2 uint64 + __184 struct{ fpstate uintptr } + __reserved1 [8]uint64 +} + +type _xsave_hdr = struct { + xstate_bv uint64 + __glibc_reserved1 [2]uint64 + __glibc_reserved2 [5]uint64 +} + +type _ymmh_state = struct{ ymmh_space [64]uint32 } + +type _xstate = struct { + fpstate struct { + cwd uint16 + swd uint16 + ftw uint16 + fop uint16 + rip uint64 + rdp uint64 + mxcsr uint32 + mxcr_mask uint32 + _st [8]struct { + significand [4]uint16 + exponent uint16 + __glibc_reserved1 [3]uint16 + } + _xmm [16]struct{ element [4]uint32 } + __glibc_reserved1 [24]uint32 + } + xstate_hdr struct { + xstate_bv uint64 + __glibc_reserved1 [2]uint64 + __glibc_reserved2 [5]uint64 + } + ymmh struct{ ymmh_space [64]uint32 } +} + +type stack_t = struct { + ss_sp uintptr + ss_flags int32 + _ [4]byte + ss_size size_t +} + +type greg_t = int64 + +type gregset_t = [23]greg_t + +type _libc_fpxreg = struct { + significand [4]uint16 + exponent uint16 + __glibc_reserved1 [3]uint16 +} + +type _libc_xmmreg = struct{ element [4]uint32 } + +type _libc_fpstate = struct { + cwd uint16 + swd uint16 + ftw uint16 + fop uint16 + rip uint64 + rdp uint64 + mxcsr uint32 + mxcr_mask uint32 + _st [8]struct { + significand [4]uint16 + exponent uint16 + __glibc_reserved1 [3]uint16 + } + _xmm [16]struct{ element [4]uint32 } + __glibc_reserved1 [24]uint32 +} + +type fpregset_t = uintptr + +type mcontext_t = struct { + gregs gregset_t + fpregs fpregset_t + __reserved1 [8]uint64 +} + +type ucontext_t1 = struct { + uc_flags uint64 + uc_link uintptr + uc_stack stack_t + uc_mcontext mcontext_t + uc_sigmask sigset_t + __fpregs_mem struct { + cwd uint16 + swd uint16 + ftw uint16 + fop uint16 + rip uint64 + rdp uint64 + mxcsr uint32 + mxcr_mask uint32 + _st [8]struct { + significand [4]uint16 + exponent uint16 + __glibc_reserved1 [3]uint16 + } + _xmm [16]struct{ element [4]uint32 } + __glibc_reserved1 [24]uint32 + } + __ssp [4]uint64 +} + +type ucontext_t = ucontext_t1 + +type sigstack = struct { + ss_sp uintptr + ss_onstack int32 + _ [4]byte +} + +type useconds_t = uint32 + +type intptr_t = int64 + +type socklen_t = uint32 + +type tm = struct { + tm_sec int32 + tm_min int32 + tm_hour int32 + tm_mday int32 + tm_mon int32 + tm_year int32 + tm_wday int32 + tm_yday int32 + tm_isdst int32 + _ [4]byte + tm_gmtoff int64 + tm_zone uintptr +} + +type itimerspec = struct { + it_interval struct { + tv_sec int64 + tv_nsec int64 + } + it_value struct { + tv_sec int64 + tv_nsec int64 + } +} + +type VFSFile1 = struct { + base sqlite3_file + fsFile uintptr + fd int32 + _ [4]byte + aBuffer uintptr + nBuffer int32 + _ [4]byte + iBufferOfst sqlite3_int64 +} + +type VFSFile = VFSFile1 + +func vfsDirectWrite(tls *libc.TLS, p uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + var ofst off_t + var nWrite size_t + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__)), 180)) + libc.X__builtin_abort(tls) + ofst = libc.Xlseek(tls, (*VFSFile)(unsafe.Pointer(p)).fd, iOfst, 0) + if ofst != iOfst { + return 10 | int32(3)<<8 + } + + nWrite = size_t(libc.Xwrite(tls, (*VFSFile)(unsafe.Pointer(p)).fd, zBuf, uint64(iAmt))) + if nWrite != size_t(iAmt) { + return 10 | int32(3)<<8 + } + + return 0 +} + +var __func__ = *(*[15]int8)(unsafe.Pointer(ts + 13)) + +func vfsFlushBuffer(tls *libc.TLS, p uintptr) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__1)), 200)) + libc.X__builtin_abort(tls) + var rc int32 = 0 + if (*VFSFile)(unsafe.Pointer(p)).nBuffer != 0 { + rc = vfsDirectWrite(tls, p, (*VFSFile)(unsafe.Pointer(p)).aBuffer, (*VFSFile)(unsafe.Pointer(p)).nBuffer, (*VFSFile)(unsafe.Pointer(p)).iBufferOfst) + (*VFSFile)(unsafe.Pointer(p)).nBuffer = 0 + } + return rc +} + +var __func__1 = *(*[15]int8)(unsafe.Pointer(ts + 28)) + +func vfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__4)), 275)) + libc.X__builtin_abort(tls) + var p uintptr = pFile + + if (*VFSFile)(unsafe.Pointer(p)).aBuffer != 0 { + var z uintptr = zBuf + var n int32 = iAmt + var i sqlite3_int64 = iOfst + + for n > 0 { + var nCopy int32 + + if (*VFSFile)(unsafe.Pointer(p)).nBuffer == 8192 || (*VFSFile)(unsafe.Pointer(p)).iBufferOfst+sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) != i { + var rc int32 = vfsFlushBuffer(tls, p) + if rc != 0 { + return rc + } + } + if (*VFSFile)(unsafe.Pointer(p)).nBuffer == 0 || (*VFSFile)(unsafe.Pointer(p)).iBufferOfst+sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) == i { + } else { + libc.X__assert_fail(tls, ts+43, ts+89, 296, uintptr(unsafe.Pointer(&__func__4))) + } + (*VFSFile)(unsafe.Pointer(p)).iBufferOfst = i - sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) + + nCopy = 8192 - (*VFSFile)(unsafe.Pointer(p)).nBuffer + if nCopy > n { + nCopy = n + } + libc.Xmemcpy(tls, (*VFSFile)(unsafe.Pointer(p)).aBuffer+uintptr((*VFSFile)(unsafe.Pointer(p)).nBuffer), z, uint64(nCopy)) + *(*int32)(unsafe.Pointer(p + 32)) += nCopy + + n = n - nCopy + i = i + sqlite3_int64(nCopy) + z += uintptr(nCopy) + } + } else { + return vfsDirectWrite(tls, p, zBuf, iAmt, iOfst) + } + + return 0 +} + +var __func__4 = *(*[9]int8)(unsafe.Pointer(ts + 95)) + +func vfsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { + return 0 +} + +func vfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__5)), 333)) + libc.X__builtin_abort(tls) + var p uintptr = pFile + var rc int32 + + rc = vfsFlushBuffer(tls, p) + if rc != 0 { + return rc + } + + rc = libc.Xfsync(tls, (*VFSFile)(unsafe.Pointer(p)).fd) + return func() int32 { + if rc == 0 { + return 0 + } + return 10 | int32(4)<<8 + }() +} + +var __func__5 = *(*[8]int8)(unsafe.Pointer(ts + 104)) + +func vfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { + return 0 +} + +func vfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { + return 0 +} + +func vfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { + *(*int32)(unsafe.Pointer(pResOut)) = 0 + return 0 +} + +func vfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { + return 12 +} + +func vfsSectorSize(tls *libc.TLS, pFile uintptr) int32 { + return 0 +} + +func vfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { + return 0 +} + +func vfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { + bp := tls.Alloc(4129) + defer tls.Free(4129) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__8)), 475)) + libc.X__builtin_abort(tls) + var rc int32 + + rc = libc.Xunlink(tls, zPath) + if rc != 0 && *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == 2 { + return 0 + } + + if rc == 0 && dirSync != 0 { + var dfd int32 + var i int32 + + sqlite3.Xsqlite3_snprintf(tls, 4096, bp+32, ts+112, libc.VaList(bp+16, zPath)) + *(*int8)(unsafe.Pointer(bp + 32 + 4096)) = int8(0) + for i = int32(libc.Xstrlen(tls, bp+32)); i > 1 && int32(*(*int8)(unsafe.Pointer(bp + 32 + uintptr(i)))) != '/'; i++ { + } + *(*int8)(unsafe.Pointer(bp + 32 + uintptr(i))) = int8(0) + + dfd = libc.Xopen(tls, bp+32, 00, libc.VaList(bp+24, 0)) + if dfd < 0 { + rc = -1 + } else { + rc = libc.Xfsync(tls, dfd) + libc.Xclose(tls, dfd) + } + } + return func() int32 { + if rc == 0 { + return 0 + } + return 10 | int32(10)<<8 + }() +} + +var __func__8 = *(*[10]int8)(unsafe.Pointer(ts + 115)) + +func vfsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { + return uintptr(0) +} + +func vfsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { + sqlite3.Xsqlite3_snprintf(tls, nByte, zErrMsg, ts+125, 0) + *(*int8)(unsafe.Pointer(zErrMsg + uintptr(nByte-1))) = int8(0) +} + +func vfsDlSym(tls *libc.TLS, pVfs uintptr, pH uintptr, z uintptr) uintptr { + return uintptr(0) +} + +func vfsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { + return +} + +func vfsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zByte uintptr) int32 { + return 0 +} + +func vfsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { + libc.Xsleep(tls, uint32(nMicro/1000000)) + libc.Xusleep(tls, uint32(nMicro%1000000)) + return nMicro +} + +func vfsCurrentTime(tls *libc.TLS, pVfs uintptr, pTime uintptr) int32 { + var t time_t = libc.Xtime(tls, uintptr(0)) + *(*float64)(unsafe.Pointer(pTime)) = float64(t)/86400.0 + 2440587.5 + return 0 +} + +func Xsqlite3_fsFS(tls *libc.TLS, zName uintptr, pAppData uintptr) uintptr { + var p uintptr = libc.Xmalloc(tls, libc.Tsize_t(unsafe.Sizeof(sqlite3_vfs{}))) + if !(p != 0) { + return uintptr(0) + } + + *(*sqlite3_vfs)(unsafe.Pointer(p)) = sqlite3_vfs{ + iVersion: 1, + szOsFile: int32(unsafe.Sizeof(VFSFile{})), + mxPathname: 4096, + zName: zName, + pAppData: pAppData, + xOpen: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 + }{vfsOpen})), + xDelete: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32) int32 + }{vfsDelete})), + xAccess: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{vfsAccess})), + xFullPathname: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{vfsFullPathname})), + xDlOpen: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) uintptr + }{vfsDlOpen})), + xDlError: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{vfsDlError})), + xDlSym: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr + }{vfsDlSym})), + xDlClose: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) + }{vfsDlClose})), + xRandomness: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) int32 + }{vfsRandomness})), + xSleep: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32) int32 + }{vfsSleep})), + xCurrentTime: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) int32 + }{vfsCurrentTime}))} + return p +} + +var ts1 = "TODO %s:%i:\n\x00vfsDirectWrite\x00vfsFlushBuffer\x00p->nBuffer==0 || p->iBufferOfst+p->nBuffer==i\x00vfs.c\x00vfsWrite\x00vfsSync\x00%s\x00vfsDelete\x00Loadable extensions are not supported\x00" +var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data diff --git a/internal/engine/vfs/vfs_linux_arm64.go b/internal/engine/vfs/vfs_linux_arm64.go new file mode 100644 index 0000000..e00fe57 --- /dev/null +++ b/internal/engine/vfs/vfs_linux_arm64.go @@ -0,0 +1,1559 @@ +// Code generated by 'ccgo -o vfs_linux_arm64.go c/vfs.c -I../testdata/sqlite-amalgamation-3380500 -lgithub.com/hanzoai/sqlite/internal/engine/lib -pkgname vfs -nocapi -export-externs X -D SQLITE_OS_UNIX -hide=vfsFullPathname -hide=vfsOpen -hide=vfsRead -hide=vfsAccess -hide=vfsFileSize -hide=vfsClose', DO NOT EDIT. + +package vfs + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/engine/lib" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer +var _ *libc.TLS +var _ types.Size_t + +const ( + _PC_LINK_MAX = 0 + _PC_MAX_CANON = 1 + _PC_MAX_INPUT = 2 + _PC_NAME_MAX = 3 + _PC_PATH_MAX = 4 + _PC_PIPE_BUF = 5 + _PC_CHOWN_RESTRICTED = 6 + _PC_NO_TRUNC = 7 + _PC_VDISABLE = 8 + _PC_SYNC_IO = 9 + _PC_ASYNC_IO = 10 + _PC_PRIO_IO = 11 + _PC_SOCK_MAXBUF = 12 + _PC_FILESIZEBITS = 13 + _PC_REC_INCR_XFER_SIZE = 14 + _PC_REC_MAX_XFER_SIZE = 15 + _PC_REC_MIN_XFER_SIZE = 16 + _PC_REC_XFER_ALIGN = 17 + _PC_ALLOC_SIZE_MIN = 18 + _PC_SYMLINK_MAX = 19 + _PC_2_SYMLINKS = 20 +) + +const ( + _CS_PATH = 0 + + _CS_V6_WIDTH_RESTRICTED_ENVS = 1 + + _CS_GNU_LIBC_VERSION = 2 + _CS_GNU_LIBPTHREAD_VERSION = 3 + + _CS_V5_WIDTH_RESTRICTED_ENVS = 4 + + _CS_V7_WIDTH_RESTRICTED_ENVS = 5 + + _CS_LFS_CFLAGS = 1000 + _CS_LFS_LDFLAGS = 1001 + _CS_LFS_LIBS = 1002 + _CS_LFS_LINTFLAGS = 1003 + _CS_LFS64_CFLAGS = 1004 + _CS_LFS64_LDFLAGS = 1005 + _CS_LFS64_LIBS = 1006 + _CS_LFS64_LINTFLAGS = 1007 + + _CS_XBS5_ILP32_OFF32_CFLAGS = 1100 + _CS_XBS5_ILP32_OFF32_LDFLAGS = 1101 + _CS_XBS5_ILP32_OFF32_LIBS = 1102 + _CS_XBS5_ILP32_OFF32_LINTFLAGS = 1103 + _CS_XBS5_ILP32_OFFBIG_CFLAGS = 1104 + _CS_XBS5_ILP32_OFFBIG_LDFLAGS = 1105 + _CS_XBS5_ILP32_OFFBIG_LIBS = 1106 + _CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 1107 + _CS_XBS5_LP64_OFF64_CFLAGS = 1108 + _CS_XBS5_LP64_OFF64_LDFLAGS = 1109 + _CS_XBS5_LP64_OFF64_LIBS = 1110 + _CS_XBS5_LP64_OFF64_LINTFLAGS = 1111 + _CS_XBS5_LPBIG_OFFBIG_CFLAGS = 1112 + _CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 1113 + _CS_XBS5_LPBIG_OFFBIG_LIBS = 1114 + _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 1115 + + _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 + _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 + _CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 + _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 + _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 + _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 + _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 + _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 + _CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 + _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 + _CS_POSIX_V6_LP64_OFF64_LIBS = 1126 + _CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 + _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 + _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 + _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 + _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 + + _CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 + _CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 + _CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 + _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 + _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 + _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 + _CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 + _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 + _CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 + _CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 + _CS_POSIX_V7_LP64_OFF64_LIBS = 1142 + _CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 + _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 + _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 + _CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 + _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 + + _CS_V6_ENV = 1148 + _CS_V7_ENV = 1149 +) + +const ( + _SC_ARG_MAX = 0 + _SC_CHILD_MAX = 1 + _SC_CLK_TCK = 2 + _SC_NGROUPS_MAX = 3 + _SC_OPEN_MAX = 4 + _SC_STREAM_MAX = 5 + _SC_TZNAME_MAX = 6 + _SC_JOB_CONTROL = 7 + _SC_SAVED_IDS = 8 + _SC_REALTIME_SIGNALS = 9 + _SC_PRIORITY_SCHEDULING = 10 + _SC_TIMERS = 11 + _SC_ASYNCHRONOUS_IO = 12 + _SC_PRIORITIZED_IO = 13 + _SC_SYNCHRONIZED_IO = 14 + _SC_FSYNC = 15 + _SC_MAPPED_FILES = 16 + _SC_MEMLOCK = 17 + _SC_MEMLOCK_RANGE = 18 + _SC_MEMORY_PROTECTION = 19 + _SC_MESSAGE_PASSING = 20 + _SC_SEMAPHORES = 21 + _SC_SHARED_MEMORY_OBJECTS = 22 + _SC_AIO_LISTIO_MAX = 23 + _SC_AIO_MAX = 24 + _SC_AIO_PRIO_DELTA_MAX = 25 + _SC_DELAYTIMER_MAX = 26 + _SC_MQ_OPEN_MAX = 27 + _SC_MQ_PRIO_MAX = 28 + _SC_VERSION = 29 + _SC_PAGESIZE = 30 + _SC_RTSIG_MAX = 31 + _SC_SEM_NSEMS_MAX = 32 + _SC_SEM_VALUE_MAX = 33 + _SC_SIGQUEUE_MAX = 34 + _SC_TIMER_MAX = 35 + + _SC_BC_BASE_MAX = 36 + _SC_BC_DIM_MAX = 37 + _SC_BC_SCALE_MAX = 38 + _SC_BC_STRING_MAX = 39 + _SC_COLL_WEIGHTS_MAX = 40 + _SC_EQUIV_CLASS_MAX = 41 + _SC_EXPR_NEST_MAX = 42 + _SC_LINE_MAX = 43 + _SC_RE_DUP_MAX = 44 + _SC_CHARCLASS_NAME_MAX = 45 + + _SC_2_VERSION = 46 + _SC_2_C_BIND = 47 + _SC_2_C_DEV = 48 + _SC_2_FORT_DEV = 49 + _SC_2_FORT_RUN = 50 + _SC_2_SW_DEV = 51 + _SC_2_LOCALEDEF = 52 + + _SC_PII = 53 + _SC_PII_XTI = 54 + _SC_PII_SOCKET = 55 + _SC_PII_INTERNET = 56 + _SC_PII_OSI = 57 + _SC_POLL = 58 + _SC_SELECT = 59 + _SC_UIO_MAXIOV = 60 + _SC_IOV_MAX = 60 + _SC_PII_INTERNET_STREAM = 61 + _SC_PII_INTERNET_DGRAM = 62 + _SC_PII_OSI_COTS = 63 + _SC_PII_OSI_CLTS = 64 + _SC_PII_OSI_M = 65 + _SC_T_IOV_MAX = 66 + + _SC_THREADS = 67 + _SC_THREAD_SAFE_FUNCTIONS = 68 + _SC_GETGR_R_SIZE_MAX = 69 + _SC_GETPW_R_SIZE_MAX = 70 + _SC_LOGIN_NAME_MAX = 71 + _SC_TTY_NAME_MAX = 72 + _SC_THREAD_DESTRUCTOR_ITERATIONS = 73 + _SC_THREAD_KEYS_MAX = 74 + _SC_THREAD_STACK_MIN = 75 + _SC_THREAD_THREADS_MAX = 76 + _SC_THREAD_ATTR_STACKADDR = 77 + _SC_THREAD_ATTR_STACKSIZE = 78 + _SC_THREAD_PRIORITY_SCHEDULING = 79 + _SC_THREAD_PRIO_INHERIT = 80 + _SC_THREAD_PRIO_PROTECT = 81 + _SC_THREAD_PROCESS_SHARED = 82 + + _SC_NPROCESSORS_CONF = 83 + _SC_NPROCESSORS_ONLN = 84 + _SC_PHYS_PAGES = 85 + _SC_AVPHYS_PAGES = 86 + _SC_ATEXIT_MAX = 87 + _SC_PASS_MAX = 88 + + _SC_XOPEN_VERSION = 89 + _SC_XOPEN_XCU_VERSION = 90 + _SC_XOPEN_UNIX = 91 + _SC_XOPEN_CRYPT = 92 + _SC_XOPEN_ENH_I18N = 93 + _SC_XOPEN_SHM = 94 + + _SC_2_CHAR_TERM = 95 + _SC_2_C_VERSION = 96 + _SC_2_UPE = 97 + + _SC_XOPEN_XPG2 = 98 + _SC_XOPEN_XPG3 = 99 + _SC_XOPEN_XPG4 = 100 + + _SC_CHAR_BIT = 101 + _SC_CHAR_MAX = 102 + _SC_CHAR_MIN = 103 + _SC_INT_MAX = 104 + _SC_INT_MIN = 105 + _SC_LONG_BIT = 106 + _SC_WORD_BIT = 107 + _SC_MB_LEN_MAX = 108 + _SC_NZERO = 109 + _SC_SSIZE_MAX = 110 + _SC_SCHAR_MAX = 111 + _SC_SCHAR_MIN = 112 + _SC_SHRT_MAX = 113 + _SC_SHRT_MIN = 114 + _SC_UCHAR_MAX = 115 + _SC_UINT_MAX = 116 + _SC_ULONG_MAX = 117 + _SC_USHRT_MAX = 118 + + _SC_NL_ARGMAX = 119 + _SC_NL_LANGMAX = 120 + _SC_NL_MSGMAX = 121 + _SC_NL_NMAX = 122 + _SC_NL_SETMAX = 123 + _SC_NL_TEXTMAX = 124 + + _SC_XBS5_ILP32_OFF32 = 125 + _SC_XBS5_ILP32_OFFBIG = 126 + _SC_XBS5_LP64_OFF64 = 127 + _SC_XBS5_LPBIG_OFFBIG = 128 + + _SC_XOPEN_LEGACY = 129 + _SC_XOPEN_REALTIME = 130 + _SC_XOPEN_REALTIME_THREADS = 131 + + _SC_ADVISORY_INFO = 132 + _SC_BARRIERS = 133 + _SC_BASE = 134 + _SC_C_LANG_SUPPORT = 135 + _SC_C_LANG_SUPPORT_R = 136 + _SC_CLOCK_SELECTION = 137 + _SC_CPUTIME = 138 + _SC_THREAD_CPUTIME = 139 + _SC_DEVICE_IO = 140 + _SC_DEVICE_SPECIFIC = 141 + _SC_DEVICE_SPECIFIC_R = 142 + _SC_FD_MGMT = 143 + _SC_FIFO = 144 + _SC_PIPE = 145 + _SC_FILE_ATTRIBUTES = 146 + _SC_FILE_LOCKING = 147 + _SC_FILE_SYSTEM = 148 + _SC_MONOTONIC_CLOCK = 149 + _SC_MULTI_PROCESS = 150 + _SC_SINGLE_PROCESS = 151 + _SC_NETWORKING = 152 + _SC_READER_WRITER_LOCKS = 153 + _SC_SPIN_LOCKS = 154 + _SC_REGEXP = 155 + _SC_REGEX_VERSION = 156 + _SC_SHELL = 157 + _SC_SIGNALS = 158 + _SC_SPAWN = 159 + _SC_SPORADIC_SERVER = 160 + _SC_THREAD_SPORADIC_SERVER = 161 + _SC_SYSTEM_DATABASE = 162 + _SC_SYSTEM_DATABASE_R = 163 + _SC_TIMEOUTS = 164 + _SC_TYPED_MEMORY_OBJECTS = 165 + _SC_USER_GROUPS = 166 + _SC_USER_GROUPS_R = 167 + _SC_2_PBS = 168 + _SC_2_PBS_ACCOUNTING = 169 + _SC_2_PBS_LOCATE = 170 + _SC_2_PBS_MESSAGE = 171 + _SC_2_PBS_TRACK = 172 + _SC_SYMLOOP_MAX = 173 + _SC_STREAMS = 174 + _SC_2_PBS_CHECKPOINT = 175 + + _SC_V6_ILP32_OFF32 = 176 + _SC_V6_ILP32_OFFBIG = 177 + _SC_V6_LP64_OFF64 = 178 + _SC_V6_LPBIG_OFFBIG = 179 + + _SC_HOST_NAME_MAX = 180 + _SC_TRACE = 181 + _SC_TRACE_EVENT_FILTER = 182 + _SC_TRACE_INHERIT = 183 + _SC_TRACE_LOG = 184 + + _SC_LEVEL1_ICACHE_SIZE = 185 + _SC_LEVEL1_ICACHE_ASSOC = 186 + _SC_LEVEL1_ICACHE_LINESIZE = 187 + _SC_LEVEL1_DCACHE_SIZE = 188 + _SC_LEVEL1_DCACHE_ASSOC = 189 + _SC_LEVEL1_DCACHE_LINESIZE = 190 + _SC_LEVEL2_CACHE_SIZE = 191 + _SC_LEVEL2_CACHE_ASSOC = 192 + _SC_LEVEL2_CACHE_LINESIZE = 193 + _SC_LEVEL3_CACHE_SIZE = 194 + _SC_LEVEL3_CACHE_ASSOC = 195 + _SC_LEVEL3_CACHE_LINESIZE = 196 + _SC_LEVEL4_CACHE_SIZE = 197 + _SC_LEVEL4_CACHE_ASSOC = 198 + _SC_LEVEL4_CACHE_LINESIZE = 199 + + _SC_IPV6 = 235 + _SC_RAW_SOCKETS = 236 + + _SC_V7_ILP32_OFF32 = 237 + _SC_V7_ILP32_OFFBIG = 238 + _SC_V7_LP64_OFF64 = 239 + _SC_V7_LPBIG_OFFBIG = 240 + + _SC_SS_REPL_MAX = 241 + + _SC_TRACE_EVENT_NAME_MAX = 242 + _SC_TRACE_NAME_MAX = 243 + _SC_TRACE_SYS_MAX = 244 + _SC_TRACE_USER_EVENT_MAX = 245 + + _SC_XOPEN_STREAMS = 246 + + _SC_THREAD_ROBUST_PRIO_INHERIT = 247 + _SC_THREAD_ROBUST_PRIO_PROTECT = 248 + + _SC_MINSIGSTKSZ = 249 + + _SC_SIGSTKSZ = 250 +) + +const ( + SIGEV_SIGNAL = 0 + SIGEV_NONE = 1 + SIGEV_THREAD = 2 + + SIGEV_THREAD_ID = 4 +) + +const ( + SEGV_MAPERR = 1 + SEGV_ACCERR = 2 + SEGV_BNDERR = 3 + SEGV_PKUERR = 4 + SEGV_ACCADI = 5 + SEGV_ADIDERR = 6 + SEGV_ADIPERR = 7 + SEGV_MTEAERR = 8 + SEGV_MTESERR = 9 +) + +const ( + BUS_ADRALN = 1 + BUS_ADRERR = 2 + BUS_OBJERR = 3 + BUS_MCEERR_AR = 4 + BUS_MCEERR_AO = 5 +) + +const ( + CLD_EXITED = 1 + CLD_KILLED = 2 + CLD_DUMPED = 3 + CLD_TRAPPED = 4 + CLD_STOPPED = 5 + CLD_CONTINUED = 6 +) + +const ( + POLL_IN = 1 + POLL_OUT = 2 + POLL_MSG = 3 + POLL_ERR = 4 + POLL_PRI = 5 + POLL_HUP = 6 +) + +const ( + SI_ASYNCNL = -60 + SI_DETHREAD = -7 + + SI_TKILL = -6 + SI_SIGIO = -5 + SI_ASYNCIO = -4 + SI_MESGQ = -3 + SI_TIMER = -2 + SI_QUEUE = -1 + SI_USER = 0 + SI_KERNEL = 128 +) + +const ( + ILL_ILLOPC = 1 + ILL_ILLOPN = 2 + ILL_ILLADR = 3 + ILL_ILLTRP = 4 + ILL_PRVOPC = 5 + ILL_PRVREG = 6 + ILL_COPROC = 7 + ILL_BADSTK = 8 + ILL_BADIADDR = 9 +) + +const ( + FPE_INTDIV = 1 + FPE_INTOVF = 2 + FPE_FLTDIV = 3 + FPE_FLTOVF = 4 + FPE_FLTUND = 5 + FPE_FLTRES = 6 + FPE_FLTINV = 7 + FPE_FLTSUB = 8 + FPE_FLTUNK = 14 + FPE_CONDTRAP = 15 +) + +const ( + SS_ONSTACK = 1 + SS_DISABLE = 2 +) + +const ( + ITIMER_REAL = 0 + + ITIMER_VIRTUAL = 1 + + ITIMER_PROF = 2 +) + +type ptrdiff_t = int64 + +type size_t = uint64 + +type wchar_t = uint32 + +type va_list = uintptr + +type sqlite_int64 = int64 +type sqlite_uint64 = uint64 +type sqlite3_int64 = sqlite_int64 +type sqlite3_uint64 = sqlite_uint64 + +type sqlite3_callback = uintptr + +type sqlite3_file1 = struct{ pMethods uintptr } + +type sqlite3_file = sqlite3_file1 +type sqlite3_io_methods1 = struct { + iVersion int32 + _ [4]byte + xClose uintptr + xRead uintptr + xWrite uintptr + xTruncate uintptr + xSync uintptr + xFileSize uintptr + xLock uintptr + xUnlock uintptr + xCheckReservedLock uintptr + xFileControl uintptr + xSectorSize uintptr + xDeviceCharacteristics uintptr + xShmMap uintptr + xShmLock uintptr + xShmBarrier uintptr + xShmUnmap uintptr + xFetch uintptr + xUnfetch uintptr +} + +type sqlite3_io_methods = sqlite3_io_methods1 + +type sqlite3_vfs1 = struct { + iVersion int32 + szOsFile int32 + mxPathname int32 + _ [4]byte + pNext uintptr + zName uintptr + pAppData uintptr + xOpen uintptr + xDelete uintptr + xAccess uintptr + xFullPathname uintptr + xDlOpen uintptr + xDlError uintptr + xDlSym uintptr + xDlClose uintptr + xRandomness uintptr + xSleep uintptr + xCurrentTime uintptr + xGetLastError uintptr + xCurrentTimeInt64 uintptr + xSetSystemCall uintptr + xGetSystemCall uintptr + xNextSystemCall uintptr +} + +type sqlite3_vfs = sqlite3_vfs1 +type sqlite3_syscall_ptr = uintptr + +type sqlite3_mem_methods1 = struct { + xMalloc uintptr + xFree uintptr + xRealloc uintptr + xSize uintptr + xRoundup uintptr + xInit uintptr + xShutdown uintptr + pAppData uintptr +} + +type sqlite3_mem_methods = sqlite3_mem_methods1 + +type sqlite3_destructor_type = uintptr + +type sqlite3_vtab1 = struct { + pModule uintptr + nRef int32 + _ [4]byte + zErrMsg uintptr +} + +type sqlite3_vtab = sqlite3_vtab1 +type sqlite3_index_info1 = struct { + nConstraint int32 + _ [4]byte + aConstraint uintptr + nOrderBy int32 + _ [4]byte + aOrderBy uintptr + aConstraintUsage uintptr + idxNum int32 + _ [4]byte + idxStr uintptr + needToFreeIdxStr int32 + orderByConsumed int32 + estimatedCost float64 + estimatedRows sqlite3_int64 + idxFlags int32 + _ [4]byte + colUsed sqlite3_uint64 +} + +type sqlite3_index_info = sqlite3_index_info1 +type sqlite3_vtab_cursor1 = struct{ pVtab uintptr } + +type sqlite3_vtab_cursor = sqlite3_vtab_cursor1 +type sqlite3_module1 = struct { + iVersion int32 + _ [4]byte + xCreate uintptr + xConnect uintptr + xBestIndex uintptr + xDisconnect uintptr + xDestroy uintptr + xOpen uintptr + xClose uintptr + xFilter uintptr + xNext uintptr + xEof uintptr + xColumn uintptr + xRowid uintptr + xUpdate uintptr + xBegin uintptr + xSync uintptr + xCommit uintptr + xRollback uintptr + xFindFunction uintptr + xRename uintptr + xSavepoint uintptr + xRelease uintptr + xRollbackTo uintptr + xShadowName uintptr +} + +type sqlite3_module = sqlite3_module1 + +type sqlite3_index_constraint = struct { + iColumn int32 + op uint8 + usable uint8 + _ [2]byte + iTermOffset int32 +} + +type sqlite3_index_orderby = struct { + iColumn int32 + desc uint8 + _ [3]byte +} + +type sqlite3_index_constraint_usage = struct { + argvIndex int32 + omit uint8 + _ [3]byte +} + +type sqlite3_mutex_methods1 = struct { + xMutexInit uintptr + xMutexEnd uintptr + xMutexAlloc uintptr + xMutexFree uintptr + xMutexEnter uintptr + xMutexTry uintptr + xMutexLeave uintptr + xMutexHeld uintptr + xMutexNotheld uintptr +} + +type sqlite3_mutex_methods = sqlite3_mutex_methods1 + +type sqlite3_pcache_page1 = struct { + pBuf uintptr + pExtra uintptr +} + +type sqlite3_pcache_page = sqlite3_pcache_page1 + +type sqlite3_pcache_methods21 = struct { + iVersion int32 + _ [4]byte + pArg uintptr + xInit uintptr + xShutdown uintptr + xCreate uintptr + xCachesize uintptr + xPagecount uintptr + xFetch uintptr + xUnpin uintptr + xRekey uintptr + xTruncate uintptr + xDestroy uintptr + xShrink uintptr +} + +type sqlite3_pcache_methods2 = sqlite3_pcache_methods21 + +type sqlite3_pcache_methods1 = struct { + pArg uintptr + xInit uintptr + xShutdown uintptr + xCreate uintptr + xCachesize uintptr + xPagecount uintptr + xFetch uintptr + xUnpin uintptr + xRekey uintptr + xTruncate uintptr + xDestroy uintptr +} + +type sqlite3_pcache_methods = sqlite3_pcache_methods1 + +type sqlite3_snapshot1 = struct{ hidden [48]uint8 } + +type sqlite3_snapshot = sqlite3_snapshot1 + +type sqlite3_rtree_geometry1 = struct { + pContext uintptr + nParam int32 + _ [4]byte + aParam uintptr + pUser uintptr + xDelUser uintptr +} + +type sqlite3_rtree_geometry = sqlite3_rtree_geometry1 +type sqlite3_rtree_query_info1 = struct { + pContext uintptr + nParam int32 + _ [4]byte + aParam uintptr + pUser uintptr + xDelUser uintptr + aCoord uintptr + anQueue uintptr + nCoord int32 + iLevel int32 + mxLevel int32 + _ [4]byte + iRowid sqlite3_int64 + rParentScore sqlite3_rtree_dbl + eParentWithin int32 + eWithin int32 + rScore sqlite3_rtree_dbl + apSqlParam uintptr +} + +type sqlite3_rtree_query_info = sqlite3_rtree_query_info1 + +type sqlite3_rtree_dbl = float64 + +type Fts5ExtensionApi1 = struct { + iVersion int32 + _ [4]byte + xUserData uintptr + xColumnCount uintptr + xRowCount uintptr + xColumnTotalSize uintptr + xTokenize uintptr + xPhraseCount uintptr + xPhraseSize uintptr + xInstCount uintptr + xInst uintptr + xRowid uintptr + xColumnText uintptr + xColumnSize uintptr + xQueryPhrase uintptr + xSetAuxdata uintptr + xGetAuxdata uintptr + xPhraseFirst uintptr + xPhraseNext uintptr + xPhraseFirstColumn uintptr + xPhraseNextColumn uintptr +} + +type Fts5ExtensionApi = Fts5ExtensionApi1 +type Fts5PhraseIter1 = struct { + a uintptr + b uintptr +} + +type Fts5PhraseIter = Fts5PhraseIter1 + +type fts5_extension_function = uintptr +type fts5_tokenizer1 = struct { + xCreate uintptr + xDelete uintptr + xTokenize uintptr +} + +type fts5_tokenizer = fts5_tokenizer1 + +type fts5_api1 = struct { + iVersion int32 + _ [4]byte + xCreateTokenizer uintptr + xFindTokenizer uintptr + xCreateFunction uintptr +} + +type fts5_api = fts5_api1 + +type __locale_struct = struct { + __locales [13]uintptr + __ctype_b uintptr + __ctype_tolower uintptr + __ctype_toupper uintptr + __names [13]uintptr +} + +type locale_t = uintptr + +type u_char = uint8 +type u_short = uint16 +type u_int = uint32 +type u_long = uint64 +type quad_t = int64 +type u_quad_t = uint64 +type fsid_t = struct{ __val [2]int32 } +type loff_t = int64 + +type ino_t = uint64 + +type dev_t = uint64 + +type gid_t = uint32 + +type mode_t = uint32 + +type nlink_t = uint32 + +type uid_t = uint32 + +type off_t = int64 + +type pid_t = int32 + +type id_t = uint32 + +type ssize_t = int64 + +type daddr_t = int32 +type caddr_t = uintptr + +type key_t = int32 + +type clock_t = int64 + +type clockid_t = int32 + +type time_t = int64 + +type timer_t = uintptr + +type ulong = uint64 +type ushort = uint16 +type uint = uint32 + +type int8_t = int8 +type int16_t = int16 +type int32_t = int32 +type int64_t = int64 + +type u_int8_t = uint8 +type u_int16_t = uint16 +type u_int32_t = uint32 +type u_int64_t = uint64 + +type register_t = int32 + +type sigset_t = struct{ __val [16]uint64 } + +type timeval = struct { + tv_sec int64 + tv_usec int64 +} + +type timespec = struct { + tv_sec int64 + tv_nsec int64 +} + +type suseconds_t = int64 + +type fd_set = struct{ __fds_bits [16]int64 } + +type fd_mask = int64 + +type blksize_t = int32 + +type blkcnt_t = int64 +type fsblkcnt_t = uint64 +type fsfilcnt_t = uint64 + +type __pthread_internal_list = struct { + __prev uintptr + __next uintptr +} + +type __pthread_internal_slist = struct{ __next uintptr } + +type __pthread_mutex_s = struct { + __lock int32 + __count uint32 + __owner int32 + __nusers uint32 + __kind int32 + __spins int32 + __list struct { + __prev uintptr + __next uintptr + } +} + +type __pthread_rwlock_arch_t = struct { + __readers uint32 + __writers uint32 + __wrphase_futex uint32 + __writers_futex uint32 + __pad3 uint32 + __pad4 uint32 + __cur_writer int32 + __shared int32 + __pad1 uint64 + __pad2 uint64 + __flags uint32 + _ [4]byte +} + +type __pthread_cond_s = struct { + __0 struct{ __wseq uint64 } + __8 struct{ __g1_start uint64 } + __g_refs [2]uint32 + __g_size [2]uint32 + __g1_orig_size uint32 + __wrefs uint32 + __g_signals [2]uint32 +} + +type pthread_t = uint64 + +type pthread_mutexattr_t = struct { + _ [0]uint32 + __size [8]uint8 +} + +type pthread_condattr_t = struct { + _ [0]uint32 + __size [8]uint8 +} + +type pthread_key_t = uint32 + +type pthread_once_t = int32 + +type pthread_attr_t1 = struct { + _ [0]uint64 + __size [64]uint8 +} + +type pthread_attr_t = pthread_attr_t1 + +type pthread_mutex_t = struct { + __data __pthread_mutex_s + _ [8]byte +} + +type pthread_cond_t = struct{ __data __pthread_cond_s } + +type pthread_rwlock_t = struct{ __data __pthread_rwlock_arch_t } + +type pthread_rwlockattr_t = struct { + _ [0]uint64 + __size [8]uint8 +} + +type pthread_spinlock_t = int32 + +type pthread_barrier_t = struct { + _ [0]uint64 + __size [32]uint8 +} + +type pthread_barrierattr_t = struct { + _ [0]uint32 + __size [8]uint8 +} + +type stat = struct { + st_dev uint64 + st_ino uint64 + st_mode uint32 + st_nlink uint32 + st_uid uint32 + st_gid uint32 + st_rdev uint64 + __pad1 uint64 + st_size int64 + st_blksize int32 + __pad2 int32 + st_blocks int64 + st_atim struct { + tv_sec int64 + tv_nsec int64 + } + st_mtim struct { + tv_sec int64 + tv_nsec int64 + } + st_ctim struct { + tv_sec int64 + tv_nsec int64 + } + __glibc_reserved [2]int32 +} + +type flock = struct { + l_type int16 + l_whence int16 + _ [4]byte + l_start int64 + l_len int64 + l_pid int32 + _ [4]byte +} + +type sig_atomic_t = int32 + +type sigval = struct { + _ [0]uint64 + sival_int int32 + _ [4]byte +} + +type siginfo_t = struct { + si_signo int32 + si_errno int32 + si_code int32 + __pad0 int32 + _sifields struct { + _ [0]uint64 + _pad [28]int32 + } +} + +type sigval_t = sigval + +type sigevent = struct { + sigev_value struct { + _ [0]uint64 + sival_int int32 + _ [4]byte + } + sigev_signo int32 + sigev_notify int32 + _sigev_un struct { + _ [0]uint64 + _pad [12]int32 + } +} + +type sigevent_t = sigevent + +type sig_t = uintptr + +type sigaction = struct { + __sigaction_handler struct{ sa_handler uintptr } + sa_mask struct{ __val [16]uint64 } + sa_flags int32 + _ [4]byte + sa_restorer uintptr +} + +type sigcontext = struct { + fault_address uint64 + regs [31]uint64 + sp uint64 + pc uint64 + pstate uint64 + __reserved [4096]uint8 +} + +type _aarch64_ctx = struct { + magic uint32 + size uint32 +} + +type fpsimd_context = struct { + head struct { + magic uint32 + size uint32 + } + fpsr uint32 + fpcr uint32 + vregs [32]struct { + lo uint64 + hi uint64 + } +} + +type esr_context = struct { + head struct { + magic uint32 + size uint32 + } + esr uint64 +} + +type extra_context = struct { + head struct { + magic uint32 + size uint32 + } + datap uint64 + size uint32 + __reserved [3]uint32 +} + +type sve_context = struct { + head struct { + magic uint32 + size uint32 + } + vl uint16 + __reserved [3]uint16 +} + +type stack_t = struct { + ss_sp uintptr + ss_flags int32 + _ [4]byte + ss_size size_t +} + +type timezone = struct { + tz_minuteswest int32 + tz_dsttime int32 +} + +type itimerval = struct { + it_interval struct { + tv_sec int64 + tv_usec int64 + } + it_value struct { + tv_sec int64 + tv_usec int64 + } +} + +type user_regs_struct = struct { + regs [31]uint64 + sp uint64 + pc uint64 + pstate uint64 +} + +type user_fpsimd_struct = struct { + vregs [32]struct { + lo uint64 + hi uint64 + } + fpsr uint32 + fpcr uint32 +} + +type elf_greg_t = uint64 + +type elf_gregset_t = [34]elf_greg_t + +type elf_fpregset_t = user_fpsimd_struct + +type elf_siginfo = struct { + si_signo int32 + si_code int32 + si_errno int32 +} + +type elf_prstatus = struct { + pr_info struct { + si_signo int32 + si_code int32 + si_errno int32 + } + pr_cursig int16 + _ [2]byte + pr_sigpend uint64 + pr_sighold uint64 + pr_pid int32 + pr_ppid int32 + pr_pgrp int32 + pr_sid int32 + pr_utime struct { + tv_sec int64 + tv_usec int64 + } + pr_stime struct { + tv_sec int64 + tv_usec int64 + } + pr_cutime struct { + tv_sec int64 + tv_usec int64 + } + pr_cstime struct { + tv_sec int64 + tv_usec int64 + } + pr_reg elf_gregset_t + pr_fpvalid int32 + _ [4]byte +} + +type elf_prpsinfo = struct { + pr_state uint8 + pr_sname uint8 + pr_zomb uint8 + pr_nice uint8 + _ [4]byte + pr_flag uint64 + pr_uid uint32 + pr_gid uint32 + pr_pid int32 + pr_ppid int32 + pr_pgrp int32 + pr_sid int32 + pr_fname [16]uint8 + pr_psargs [80]uint8 +} + +type psaddr_t = uintptr + +type prgregset_t = [34]elf_greg_t +type prfpregset_t = user_fpsimd_struct + +type lwpid_t = int32 + +type prstatus_t = elf_prstatus +type prpsinfo_t = elf_prpsinfo + +type greg_t = elf_greg_t + +type gregset_t = elf_gregset_t + +type fpregset_t = elf_fpregset_t + +type mcontext_t = struct { + fault_address uint64 + regs [31]uint64 + sp uint64 + pc uint64 + pstate uint64 + __reserved [4096]uint8 +} + +type ucontext_t1 = struct { + uc_flags uint64 + uc_link uintptr + uc_stack stack_t + uc_sigmask sigset_t + uc_mcontext mcontext_t +} + +type ucontext_t = ucontext_t1 + +type sigstack = struct { + ss_sp uintptr + ss_onstack int32 + _ [4]byte +} + +type useconds_t = uint32 + +type intptr_t = int64 + +type socklen_t = uint32 + +type tm = struct { + tm_sec int32 + tm_min int32 + tm_hour int32 + tm_mday int32 + tm_mon int32 + tm_year int32 + tm_wday int32 + tm_yday int32 + tm_isdst int32 + _ [4]byte + tm_gmtoff int64 + tm_zone uintptr +} + +type itimerspec = struct { + it_interval struct { + tv_sec int64 + tv_nsec int64 + } + it_value struct { + tv_sec int64 + tv_nsec int64 + } +} + +type VFSFile1 = struct { + base sqlite3_file + fsFile uintptr + fd int32 + _ [4]byte + aBuffer uintptr + nBuffer int32 + _ [4]byte + iBufferOfst sqlite3_int64 +} + +type VFSFile = VFSFile1 + +func vfsDirectWrite(tls *libc.TLS, p uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + var ofst off_t + var nWrite size_t + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__)), 178)) + libc.X__builtin_abort(tls) + ofst = libc.Xlseek(tls, (*VFSFile)(unsafe.Pointer(p)).fd, iOfst, 0) + if ofst != iOfst { + return 10 | int32(3)<<8 + } + + nWrite = size_t(libc.Xwrite(tls, (*VFSFile)(unsafe.Pointer(p)).fd, zBuf, uint64(iAmt))) + if nWrite != size_t(iAmt) { + return 10 | int32(3)<<8 + } + + return 0 +} + +var __func__ = *(*[15]uint8)(unsafe.Pointer(ts + 13)) + +func vfsFlushBuffer(tls *libc.TLS, p uintptr) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__1)), 198)) + libc.X__builtin_abort(tls) + var rc int32 = 0 + if (*VFSFile)(unsafe.Pointer(p)).nBuffer != 0 { + rc = vfsDirectWrite(tls, p, (*VFSFile)(unsafe.Pointer(p)).aBuffer, (*VFSFile)(unsafe.Pointer(p)).nBuffer, (*VFSFile)(unsafe.Pointer(p)).iBufferOfst) + (*VFSFile)(unsafe.Pointer(p)).nBuffer = 0 + } + return rc +} + +var __func__1 = *(*[15]uint8)(unsafe.Pointer(ts + 28)) + +func vfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__4)), 273)) + libc.X__builtin_abort(tls) + var p uintptr = pFile + + if (*VFSFile)(unsafe.Pointer(p)).aBuffer != 0 { + var z uintptr = zBuf + var n int32 = iAmt + var i sqlite3_int64 = iOfst + + for n > 0 { + var nCopy int32 + + if (*VFSFile)(unsafe.Pointer(p)).nBuffer == 8192 || (*VFSFile)(unsafe.Pointer(p)).iBufferOfst+sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) != i { + var rc int32 = vfsFlushBuffer(tls, p) + if rc != 0 { + return rc + } + } + if (*VFSFile)(unsafe.Pointer(p)).nBuffer == 0 || (*VFSFile)(unsafe.Pointer(p)).iBufferOfst+sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) == i { + } else { + libc.X__assert_fail(tls, ts+43, ts+89, 294, uintptr(unsafe.Pointer(&__func__4))) + } + (*VFSFile)(unsafe.Pointer(p)).iBufferOfst = i - sqlite3_int64((*VFSFile)(unsafe.Pointer(p)).nBuffer) + + nCopy = 8192 - (*VFSFile)(unsafe.Pointer(p)).nBuffer + if nCopy > n { + nCopy = n + } + libc.Xmemcpy(tls, (*VFSFile)(unsafe.Pointer(p)).aBuffer+uintptr((*VFSFile)(unsafe.Pointer(p)).nBuffer), z, uint64(nCopy)) + *(*int32)(unsafe.Pointer(p + 32)) += nCopy + + n = n - nCopy + i = i + sqlite3_int64(nCopy) + z += uintptr(nCopy) + } + } else { + return vfsDirectWrite(tls, p, zBuf, iAmt, iOfst) + } + + return 0 +} + +var __func__4 = *(*[9]uint8)(unsafe.Pointer(ts + 97)) + +func vfsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { + return 0 +} + +func vfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { + bp := tls.Alloc(16) + defer tls.Free(16) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__5)), 331)) + libc.X__builtin_abort(tls) + var p uintptr = pFile + var rc int32 + + rc = vfsFlushBuffer(tls, p) + if rc != 0 { + return rc + } + + rc = libc.Xfsync(tls, (*VFSFile)(unsafe.Pointer(p)).fd) + return func() int32 { + if rc == 0 { + return 0 + } + return 10 | int32(4)<<8 + }() +} + +var __func__5 = *(*[8]uint8)(unsafe.Pointer(ts + 106)) + +func vfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { + return 0 +} + +func vfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { + return 0 +} + +func vfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { + *(*int32)(unsafe.Pointer(pResOut)) = 0 + return 0 +} + +func vfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { + return 12 +} + +func vfsSectorSize(tls *libc.TLS, pFile uintptr) int32 { + return 0 +} + +func vfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { + return 0 +} + +func vfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { + bp := tls.Alloc(4129) + defer tls.Free(4129) + + libc.X__builtin_printf(tls, ts, libc.VaList(bp, uintptr(unsafe.Pointer(&__func__8)), 473)) + libc.X__builtin_abort(tls) + var rc int32 + + rc = libc.Xunlink(tls, zPath) + if rc != 0 && *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == 2 { + return 0 + } + + if rc == 0 && dirSync != 0 { + var dfd int32 + var i int32 + + sqlite3.Xsqlite3_snprintf(tls, 4096, bp+32, ts+114, libc.VaList(bp+16, zPath)) + *(*uint8)(unsafe.Pointer(bp + 32 + 4096)) = uint8(0) + for i = int32(libc.Xstrlen(tls, bp+32)); i > 1 && int32(*(*uint8)(unsafe.Pointer(bp + 32 + uintptr(i)))) != '/'; i++ { + } + *(*uint8)(unsafe.Pointer(bp + 32 + uintptr(i))) = uint8(0) + + dfd = libc.Xopen(tls, bp+32, 00, libc.VaList(bp+24, 0)) + if dfd < 0 { + rc = -1 + } else { + rc = libc.Xfsync(tls, dfd) + libc.Xclose(tls, dfd) + } + } + return func() int32 { + if rc == 0 { + return 0 + } + return 10 | int32(10)<<8 + }() +} + +var __func__8 = *(*[10]uint8)(unsafe.Pointer(ts + 117)) + +func vfsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { + return uintptr(0) +} + +func vfsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { + sqlite3.Xsqlite3_snprintf(tls, nByte, zErrMsg, ts+127, 0) + *(*uint8)(unsafe.Pointer(zErrMsg + uintptr(nByte-1))) = uint8(0) +} + +func vfsDlSym(tls *libc.TLS, pVfs uintptr, pH uintptr, z uintptr) uintptr { + return uintptr(0) +} + +func vfsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { + return +} + +func vfsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zByte uintptr) int32 { + return 0 +} + +func vfsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { + libc.Xsleep(tls, uint32(nMicro/1000000)) + libc.Xusleep(tls, uint32(nMicro%1000000)) + return nMicro +} + +func vfsCurrentTime(tls *libc.TLS, pVfs uintptr, pTime uintptr) int32 { + var t time_t = libc.Xtime(tls, uintptr(0)) + *(*float64)(unsafe.Pointer(pTime)) = float64(t)/86400.0 + 2440587.5 + return 0 +} + +func Xsqlite3_fsFS(tls *libc.TLS, zName uintptr, pAppData uintptr) uintptr { + var p uintptr = libc.Xmalloc(tls, libc.Tsize_t(unsafe.Sizeof(sqlite3_vfs{}))) + if !(p != 0) { + return uintptr(0) + } + + *(*sqlite3_vfs)(unsafe.Pointer(p)) = sqlite3_vfs{ + iVersion: 1, + szOsFile: int32(unsafe.Sizeof(VFSFile{})), + mxPathname: 4096, + zName: zName, + pAppData: pAppData, + xOpen: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 + }{vfsOpen})), + xDelete: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32) int32 + }{vfsDelete})), + xAccess: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{vfsAccess})), + xFullPathname: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{vfsFullPathname})), + xDlOpen: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) uintptr + }{vfsDlOpen})), + xDlError: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{vfsDlError})), + xDlSym: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr + }{vfsDlSym})), + xDlClose: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) + }{vfsDlClose})), + xRandomness: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) int32 + }{vfsRandomness})), + xSleep: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32) int32 + }{vfsSleep})), + xCurrentTime: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr) int32 + }{vfsCurrentTime}))} + return p +} + +var ts1 = "TODO %s:%i:\n\x00vfsDirectWrite\x00vfsFlushBuffer\x00p->nBuffer==0 || p->iBufferOfst+p->nBuffer==i\x00c/vfs.c\x00vfsWrite\x00vfsSync\x00%s\x00vfsDelete\x00Loadable extensions are not supported\x00" +var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data diff --git a/internal/engine/vtab.go b/internal/engine/vtab.go new file mode 100644 index 0000000..33da487 --- /dev/null +++ b/internal/engine/vtab.go @@ -0,0 +1,932 @@ +// Copyright 2025 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite // import "github.com/hanzoai/sqlite/internal/engine" + +import ( + "fmt" + "math" + "sync" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + sqlite3 "github.com/hanzoai/sqlite/internal/engine/lib" + "github.com/hanzoai/sqlite/internal/engine/vtab" +) + +func init() { + vtab.SetRegisterFunc(registerModule) +} + +var ( + // vtabModules tracks Go virtual table modules registered via the vtab + // package. Each module is identified by an integer ID used as pAux when + // calling sqlite3_create_module_v2, so that trampolines can recover the + // Go Module implementation. + vtabModules = struct { + mu sync.RWMutex + m map[uintptr]*goModule + ids idGen + // name2id keeps stable IDs per module name to avoid unbounded growth + // across connections. + name2id map[string]uintptr + }{ + m: make(map[uintptr]*goModule), + name2id: make(map[string]uintptr), + } + + // nativeModules holds sqlite3_module instances for registered modules, + // allocated via libc so that transpiled C code can access them without + // tripping Go's checkptr instrumentation. + nativeModules = struct { + mu sync.RWMutex + m map[string]uintptr + }{ + m: make(map[string]uintptr), + } + + // vtabTables maps sqlite3_vtab* (pVtab) to the corresponding Go Table. + vtabTables = struct { + mu sync.RWMutex + m map[uintptr]*goTable + }{ + m: make(map[uintptr]*goTable), + } + + // vtabCursors maps sqlite3_vtab_cursor* (pCursor) to the corresponding Go + // Cursor. + vtabCursors = struct { + mu sync.RWMutex + m map[uintptr]*goCursor + }{ + m: make(map[uintptr]*goCursor), + } +) + +// goModule wraps a vtab.Module implementation with its name. +// +// volatile mirrors the opt-in from [vtab.VolatileArgsOpter]: when true, the +// engine passes argument string/[]byte bodies to Cursor.Filter and Updater +// Insert/Update as zero-copy views into SQLite-owned memory. The flag is +// captured once, when the module is registered on a connection, and shared +// by every table created from this module. +type goModule struct { + name string + impl vtab.Module + volatile bool +} + +// goTable wraps a vtab.Table implementation and remembers its module. +type goTable struct { + mod *goModule + impl vtab.Table +} + +// goCursor wraps a vtab.Cursor implementation and remembers its table. +type goCursor struct { + table *goTable + impl vtab.Cursor +} + +// Use aliases of the underlying lib types so field layouts remain correct. +type cIndexConstraint = sqlite3.Tsqlite3_index_constraint +type cIndexOrderBy = sqlite3.Tsqlite3_index_orderby +type cConstraintUsage = sqlite3.Tsqlite3_index_constraint_usage + +// registerModule is installed as the hook for vtab.RegisterModule. +func registerModule(name string, m vtab.Module) error { + if _, exists := d.modules[name]; exists { + return fmt.Errorf("sqlite: module %q already registered", name) + } + d.modules[name] = m + return nil +} + +// registerModules installs all globally registered vtab modules on this +// connection by calling sqlite3_create_module_v2 for each one. +func (c *conn) registerModules() error { + for name, mod := range d.modules { + if err := c.registerSingleModule(name, mod); err != nil { + return err + } + } + return nil +} + +func (c *conn) registerSingleModule(name string, m vtab.Module) error { + // Allocate or reuse a stable ID for this module name and remember the Go implementation. + vtabModules.mu.Lock() + modID, ok := vtabModules.name2id[name] + if !ok { + modID = vtabModules.ids.next() + vtabModules.name2id[name] = modID + } + gm := &goModule{name: name, impl: m} + if v, ok := m.(vtab.VolatileArgsOpter); ok { + gm.volatile = v.VolatileArgs() + } + vtabModules.m[modID] = gm + vtabModules.mu.Unlock() + + nativeModules.mu.Lock() + defer nativeModules.mu.Unlock() + var modPtr uintptr + if existing, exists := nativeModules.m[name]; exists { + modPtr = existing + } else { + // Allocate with the C allocator so the transpiled SQLite code can + // access the struct without tripping Go's checkptr. + modPtr = libc.Xcalloc(c.tls, 1, types.Size_t(unsafe.Sizeof(sqlite3.Sqlite3_module{}))) + if modPtr == 0 { + if !ok { + vtabModules.mu.Lock() + delete(vtabModules.name2id, name) + delete(vtabModules.m, modID) + vtabModules.mu.Unlock() + } + return fmt.Errorf("sqlite: failed to allocate module %q", name) + } + mod := (*sqlite3.Sqlite3_module)(unsafe.Pointer(modPtr)) + mod.FiVersion = 2 + mod.FxCreate = cFuncPointer(vtabCreateTrampoline) + mod.FxConnect = cFuncPointer(vtabConnectTrampoline) + mod.FxBestIndex = cFuncPointer(vtabBestIndexTrampoline) + mod.FxDisconnect = cFuncPointer(vtabDisconnectTrampoline) + mod.FxDestroy = cFuncPointer(vtabDestroyTrampoline) + mod.FxOpen = cFuncPointer(vtabOpenTrampoline) + mod.FxClose = cFuncPointer(vtabCloseTrampoline) + mod.FxFilter = cFuncPointer(vtabFilterTrampoline) + mod.FxNext = cFuncPointer(vtabNextTrampoline) + mod.FxEof = cFuncPointer(vtabEofTrampoline) + mod.FxColumn = cFuncPointer(vtabColumnTrampoline) + mod.FxRowid = cFuncPointer(vtabRowidTrampoline) + mod.FxFindFunction = cFuncPointer(vtabFindFunctionTrampoline) + mod.FxRename = cFuncPointer(vtabRenameTrampoline) + mod.FxUpdate = cFuncPointer(vtabUpdateTrampoline) + mod.FxBegin = cFuncPointer(vtabBeginTrampoline) + mod.FxSync = cFuncPointer(vtabSyncTrampoline) + mod.FxCommit = cFuncPointer(vtabCommitTrampoline) + mod.FxRollback = cFuncPointer(vtabRollbackTrampoline) + mod.FxSavepoint = cFuncPointer(vtabSavepointTrampoline) + mod.FxRelease = cFuncPointer(vtabReleaseTrampoline) + mod.FxRollbackTo = cFuncPointer(vtabRollbackToTrampoline) + + nativeModules.m[name] = modPtr + } + + // Prepare C string for module name. + zName, err := libc.CString(name) + if err != nil { + return err + } + defer libc.Xfree(c.tls, zName) + + // Register the module with this connection. + if rc := sqlite3.Xsqlite3_create_module_v2(c.tls, c.db, zName, modPtr, modID, 0); rc != sqlite3.SQLITE_OK { + return fmt.Errorf("create_module %q: %w", name, c.errstr(rc)) + } + return nil +} + +func vtabConfig(tls *libc.TLS, db uintptr, op int32, args ...int32) error { + var va uintptr + if len(args) > 1 { + return fmt.Errorf("vtab_config: too many args (%d)", len(args)) + } + if len(args) == 1 { + const vaSize = 8 + p := sqlite3.Xsqlite3_malloc(tls, vaSize) + if p == 0 { + return fmt.Errorf("vtab: out of memory") + } + defer sqlite3.Xsqlite3_free(tls, p) + libc.VaList(p, args[0]) + va = p + } + if rc := sqlite3.Xsqlite3_vtab_config(tls, db, op, va); rc != sqlite3.SQLITE_OK { + return fmt.Errorf("vtab_config op=%d: rc=%d", op, rc) + } + return nil +} + +// vtabCreateTrampoline is the xCreate callback. It invokes the corresponding +// Go vtab.Module.Create method, declares a default schema based on argv, and +// allocates a sqlite3_vtab. +func vtabCreateTrampoline(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { + gm := lookupGoModule(pAux) + if gm == nil { + setVtabError(tls, pzErr, fmt.Sprintf("vtab: unknown module id %d", pAux)) + return sqlite3.SQLITE_ERROR + } + args := extractVtabArgs(tls, argc, argv) + ctx := vtab.NewContextWithConfig(func(schema string) error { + zSchema, err := libc.CString(schema) + if err != nil { + return err + } + defer libc.Xfree(tls, zSchema) + if rc := sqlite3.Xsqlite3_declare_vtab(tls, db, zSchema); rc != sqlite3.SQLITE_OK { + return fmt.Errorf("declare_vtab failed: rc=%d", rc) + } + return nil + }, func() error { + return vtabConfig(tls, db, sqlite3.SQLITE_VTAB_CONSTRAINT_SUPPORT, 1) + }, func(op int32, args ...int32) error { + return vtabConfig(tls, db, op, args...) + }) + tbl, err := gm.impl.Create(ctx, args) + if err != nil { + setVtabError(tls, pzErr, err.Error()) + return sqlite3.SQLITE_ERROR + } + sz := unsafe.Sizeof(sqlite3.Sqlite3_vtab{}) + p := sqlite3.Xsqlite3_malloc(tls, int32(sz)) + if p == 0 { + setVtabError(tls, pzErr, "vtab: out of memory") + return sqlite3.SQLITE_NOMEM + } + mem := (*libc.RawMem)(unsafe.Pointer(p))[:sz:sz] + for i := range mem { + mem[i] = 0 + } + *(*uintptr)(unsafe.Pointer(ppVtab)) = p + + gt := &goTable{mod: gm, impl: tbl} + vtabTables.mu.Lock() + vtabTables.m[p] = gt + vtabTables.mu.Unlock() + return sqlite3.SQLITE_OK +} + +// vtabConnectTrampoline is the xConnect callback. It mirrors +// vtabCreateTrampoline but calls Module.Connect. +func vtabConnectTrampoline(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { + gm := lookupGoModule(pAux) + if gm == nil { + setVtabError(tls, pzErr, fmt.Sprintf("vtab: unknown module id %d", pAux)) + return sqlite3.SQLITE_ERROR + } + args := extractVtabArgs(tls, argc, argv) + ctx := vtab.NewContextWithConfig(func(schema string) error { + zSchema, err := libc.CString(schema) + if err != nil { + return err + } + defer libc.Xfree(tls, zSchema) + if rc := sqlite3.Xsqlite3_declare_vtab(tls, db, zSchema); rc != sqlite3.SQLITE_OK { + return fmt.Errorf("declare_vtab failed: rc=%d", rc) + } + return nil + }, func() error { + return vtabConfig(tls, db, sqlite3.SQLITE_VTAB_CONSTRAINT_SUPPORT, 1) + }, func(op int32, args ...int32) error { + return vtabConfig(tls, db, op, args...) + }) + tbl, err := gm.impl.Connect(ctx, args) + if err != nil { + setVtabError(tls, pzErr, err.Error()) + return sqlite3.SQLITE_ERROR + } + sz := unsafe.Sizeof(sqlite3.Sqlite3_vtab{}) + p := sqlite3.Xsqlite3_malloc(tls, int32(sz)) + if p == 0 { + setVtabError(tls, pzErr, "vtab: out of memory") + return sqlite3.SQLITE_NOMEM + } + mem := (*libc.RawMem)(unsafe.Pointer(p))[:sz:sz] + for i := range mem { + mem[i] = 0 + } + *(*uintptr)(unsafe.Pointer(ppVtab)) = p + + gt := &goTable{mod: gm, impl: tbl} + vtabTables.mu.Lock() + vtabTables.m[p] = gt + vtabTables.mu.Unlock() + return sqlite3.SQLITE_OK +} + +// vtabBestIndexTrampoline maps sqlite3_index_info to vtab.IndexInfo and +// delegates to Table.BestIndex. It also mirrors constraint and ORDER BY +// information into the Go structure. +func vtabBestIndexTrampoline(tls *libc.TLS, pVtab uintptr, pInfo uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + + idx := (*sqlite3.Sqlite3_index_info)(unsafe.Pointer(pInfo)) + info := &vtab.IndexInfo{} + + // Populate Constraints from sqlite3_index_info.aConstraint. + if idx.FnConstraint > 0 && idx.FaConstraint != 0 { + n := int(idx.FnConstraint) + cs := make([]vtab.Constraint, 0, n) + base := idx.FaConstraint + sz := unsafe.Sizeof(cIndexConstraint{}) + for i := 0; i < n; i++ { + c := (*cIndexConstraint)(unsafe.Pointer(base + uintptr(i)*sz)) + op := vtab.OpUnknown + switch int32(c.Fop) { + case sqlite3.SQLITE_INDEX_CONSTRAINT_EQ: + op = vtab.OpEQ + case sqlite3.SQLITE_INDEX_CONSTRAINT_GT: + op = vtab.OpGT + case sqlite3.SQLITE_INDEX_CONSTRAINT_LE: + op = vtab.OpLE + case sqlite3.SQLITE_INDEX_CONSTRAINT_LT: + op = vtab.OpLT + case sqlite3.SQLITE_INDEX_CONSTRAINT_GE: + op = vtab.OpGE + case sqlite3.SQLITE_INDEX_CONSTRAINT_MATCH: + op = vtab.OpMATCH + case sqlite3.SQLITE_INDEX_CONSTRAINT_NE: + op = vtab.OpNE + case sqlite3.SQLITE_INDEX_CONSTRAINT_IS: + op = vtab.OpIS + case sqlite3.SQLITE_INDEX_CONSTRAINT_ISNOT: + op = vtab.OpISNOT + case sqlite3.SQLITE_INDEX_CONSTRAINT_ISNULL: + op = vtab.OpISNULL + case sqlite3.SQLITE_INDEX_CONSTRAINT_ISNOTNULL: + op = vtab.OpISNOTNULL + case sqlite3.SQLITE_INDEX_CONSTRAINT_LIKE: + op = vtab.OpLIKE + case sqlite3.SQLITE_INDEX_CONSTRAINT_GLOB: + op = vtab.OpGLOB + case sqlite3.SQLITE_INDEX_CONSTRAINT_REGEXP: + op = vtab.OpREGEXP + case sqlite3.SQLITE_INDEX_CONSTRAINT_FUNCTION: + op = vtab.OpFUNCTION + case sqlite3.SQLITE_INDEX_CONSTRAINT_LIMIT: + op = vtab.OpLIMIT + case sqlite3.SQLITE_INDEX_CONSTRAINT_OFFSET: + op = vtab.OpOFFSET + } + cs = append(cs, vtab.Constraint{ + Column: int(c.FiColumn), + Op: op, + Usable: c.Fusable != 0, + ArgIndex: -1, // 0-based; -1 means ignore + Omit: false, + }) + } + info.Constraints = cs + } + + // Populate OrderBy from sqlite3_index_info.aOrderBy. + if idx.FnOrderBy > 0 && idx.FaOrderBy != 0 { + n := int(idx.FnOrderBy) + obs := make([]vtab.OrderBy, 0, n) + base := idx.FaOrderBy + sz := unsafe.Sizeof(cIndexOrderBy{}) + for i := 0; i < n; i++ { + ob := (*cIndexOrderBy)(unsafe.Pointer(base + uintptr(i)*sz)) + obs = append(obs, vtab.OrderBy{ + Column: int(ob.FiColumn), + Desc: ob.Fdesc != 0, + }) + } + info.OrderBy = obs + } + + // Populate ColUsed and idxFlags for module visibility. + if idx.FcolUsed != 0 { + info.ColUsed = uint64(idx.FcolUsed) + } + if idx.FidxFlags != 0 { + info.IdxFlags = int(idx.FidxFlags) + } + + if err := gt.impl.BestIndex(info); err != nil { + // Report error via zErrMsg on pVtab. + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + + // Propagate any ArgIndex assignments back into aConstraintUsage so that + // SQLite will populate xFilter's argv[] accordingly. + if idx.FnConstraint > 0 && idx.FaConstraintUsage != 0 && len(info.Constraints) > 0 { + n := int(idx.FnConstraint) + base := idx.FaConstraintUsage + sz := unsafe.Sizeof(cConstraintUsage{}) + for i := 0; i < n && i < len(info.Constraints); i++ { + cu := (*cConstraintUsage)(unsafe.Pointer(base + uintptr(i)*sz)) + argIndex := info.Constraints[i].ArgIndex + if argIndex >= 0 { + // Go ArgIndex is 0-based; SQLite wants 1-based. + cu.FargvIndex = int32(argIndex + 1) + } + if info.Constraints[i].Omit { + cu.Fomit = 1 + } + } + } + // Guard against int32 overflow: SQLite expects idxNum as int32. + if info.IdxNum < math.MinInt32 || info.IdxNum > math.MaxInt32 { + setVtabZErrMsg(tls, pVtab, fmt.Sprintf("vtab: IdxNum %d out of int32 range", info.IdxNum)) + return sqlite3.SQLITE_ERROR + } + idx.FidxNum = int32(info.IdxNum) + if info.IdxStr != "" { + // Allocate using SQLite allocator because needToFreeIdxStr=1 instructs + // SQLite to free the string with sqlite3_free. + z := sqlite3AllocCString(tls, info.IdxStr) + if z != 0 { + idx.FidxStr = z + idx.FneedToFreeIdxStr = 1 + } + } + if info.OrderByConsumed { + idx.ForderByConsumed = 1 + } + if info.IdxFlags != 0 { + idx.FidxFlags = int32(info.IdxFlags) + } + if info.EstimatedCost != 0 { + idx.FestimatedCost = info.EstimatedCost + } + if info.EstimatedRows != 0 { + idx.FestimatedRows = sqlite3.Sqlite3_int64(info.EstimatedRows) + } + return sqlite3.SQLITE_OK +} + +// vtabDisconnectTrampoline is xDisconnect. It frees the sqlite3_vtab and +// calls Table.Disconnect. +func vtabDisconnectTrampoline(tls *libc.TLS, pVtab uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt != nil { + _ = gt.impl.Disconnect() + vtabTables.mu.Lock() + delete(vtabTables.m, pVtab) + vtabTables.mu.Unlock() + } + sqlite3.Xsqlite3_free(tls, pVtab) + return sqlite3.SQLITE_OK +} + +// vtabDestroyTrampoline is xDestroy. Currently identical to Disconnect. +func vtabDestroyTrampoline(tls *libc.TLS, pVtab uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt != nil { + _ = gt.impl.Destroy() + vtabTables.mu.Lock() + delete(vtabTables.m, pVtab) + vtabTables.mu.Unlock() + } + sqlite3.Xsqlite3_free(tls, pVtab) + return sqlite3.SQLITE_OK +} + +// vtabOpenTrampoline is xOpen. It allocates an empty sqlite3_vtab_cursor and +// creates a Go Cursor via Table.Open. +func vtabOpenTrampoline(tls *libc.TLS, pVtab uintptr, ppCursor uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + + curImpl, err := gt.impl.Open() + if err != nil { + return sqlite3.SQLITE_ERROR + } + + sz := unsafe.Sizeof(sqlite3.Sqlite3_vtab_cursor{}) + p := sqlite3.Xsqlite3_malloc(tls, int32(sz)) + if p == 0 { + return sqlite3.SQLITE_NOMEM + } + mem := (*libc.RawMem)(unsafe.Pointer(p))[:sz:sz] + for i := range mem { + mem[i] = 0 + } + *(*uintptr)(unsafe.Pointer(ppCursor)) = p + + // Link cursor back to its vtab so error reporting can set zErrMsg. + cur := (*sqlite3.Sqlite3_vtab_cursor)(unsafe.Pointer(p)) + cur.FpVtab = pVtab + + gc := &goCursor{table: gt, impl: curImpl} + vtabCursors.mu.Lock() + vtabCursors.m[p] = gc + vtabCursors.mu.Unlock() + return sqlite3.SQLITE_OK +} + +// vtabCloseTrampoline is xClose. It frees the sqlite3_vtab_cursor and calls +// Cursor.Close. +func vtabCloseTrampoline(tls *libc.TLS, pCursor uintptr) int32 { + vtabCursors.mu.RLock() + gc := vtabCursors.m[pCursor] + vtabCursors.mu.RUnlock() + if gc != nil { + _ = gc.impl.Close() + vtabCursors.mu.Lock() + delete(vtabCursors.m, pCursor) + vtabCursors.mu.Unlock() + } + sqlite3.Xsqlite3_free(tls, pCursor) + return sqlite3.SQLITE_OK +} + +// vtabFilterTrampoline is xFilter. +func vtabFilterTrampoline(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { + vtabCursors.mu.RLock() + gc := vtabCursors.m[pCursor] + vtabCursors.mu.RUnlock() + if gc == nil { + return sqlite3.SQLITE_ERROR + } + + var idxStrGo string + if idxStr != 0 { + idxStrGo = libc.GoString(idxStr) + } + volatile := gc.table != nil && gc.table.mod != nil && gc.table.mod.volatile + sp := functionArgs(tls, argc, argv, volatile) + defer releaseUDFArgs(sp) + err := gc.impl.Filter(int(idxNum), idxStrGo, *sp) + if err != nil { + // Set zErrMsg on the associated vtab for better diagnostics. + if pCursor != 0 { + cur := (*sqlite3.Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)) + if cur.FpVtab != 0 { + setVtabZErrMsg(tls, cur.FpVtab, err.Error()) + } + } + return sqlite3.SQLITE_ERROR + } + return sqlite3.SQLITE_OK +} + +// vtabNextTrampoline is xNext. +func vtabNextTrampoline(tls *libc.TLS, pCursor uintptr) int32 { + _ = tls + vtabCursors.mu.RLock() + gc := vtabCursors.m[pCursor] + vtabCursors.mu.RUnlock() + if gc == nil { + return sqlite3.SQLITE_ERROR + } + if err := gc.impl.Next(); err != nil { + return sqlite3.SQLITE_ERROR + } + return sqlite3.SQLITE_OK +} + +// vtabEofTrampoline is xEof. +func vtabEofTrampoline(tls *libc.TLS, pCursor uintptr) int32 { + _ = tls + vtabCursors.mu.RLock() + gc := vtabCursors.m[pCursor] + vtabCursors.mu.RUnlock() + if gc == nil || gc.impl.Eof() { + return 1 + } + return 0 +} + +// vtabColumnTrampoline is xColumn. +func vtabColumnTrampoline(tls *libc.TLS, pCursor uintptr, ctx uintptr, iCol int32) int32 { + vtabCursors.mu.RLock() + gc := vtabCursors.m[pCursor] + vtabCursors.mu.RUnlock() + if gc == nil { + sqlite3.Xsqlite3_result_null(tls, ctx) + return sqlite3.SQLITE_OK + } + val, err := gc.impl.Column(int(iCol)) + if err != nil { + // Report via result error on the context. + z, cerr := libc.CString(err.Error()) + if cerr == nil { + defer libc.Xfree(tls, z) + sqlite3.Xsqlite3_result_error(tls, ctx, z, -1) + sqlite3.Xsqlite3_result_error_code(tls, ctx, sqlite3.SQLITE_ERROR) + } else { + sqlite3.Xsqlite3_result_error_code(tls, ctx, sqlite3.SQLITE_ERROR) + } + return sqlite3.SQLITE_ERROR + } + if err := functionReturnValue(tls, ctx, val); err != nil { + // Include a descriptive error message for easier debugging + // (e.g., unsupported type conversions). + if err != nil { + z, cerr := libc.CString(err.Error()) + if cerr == nil { + defer libc.Xfree(tls, z) + sqlite3.Xsqlite3_result_error(tls, ctx, z, -1) + } + } + sqlite3.Xsqlite3_result_error_code(tls, ctx, sqlite3.SQLITE_ERROR) + return sqlite3.SQLITE_ERROR + } + return sqlite3.SQLITE_OK +} + +// vtabRowidTrampoline is xRowid. +func vtabRowidTrampoline(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { + _ = tls + vtabCursors.mu.RLock() + gc := vtabCursors.m[pCursor] + vtabCursors.mu.RUnlock() + if gc == nil { + *(*int64)(unsafe.Pointer(pRowid)) = 0 + return sqlite3.SQLITE_OK + } + rowid, err := gc.impl.Rowid() + if err != nil { + *(*int64)(unsafe.Pointer(pRowid)) = 0 + return sqlite3.SQLITE_ERROR + } + *(*int64)(unsafe.Pointer(pRowid)) = rowid + return sqlite3.SQLITE_OK +} + +func lookupGoModule(id uintptr) *goModule { + vtabModules.mu.RLock() + defer vtabModules.mu.RUnlock() + return vtabModules.m[id] +} + +func extractVtabArgs(tls *libc.TLS, argc int32, argv uintptr) []string { + args := make([]string, argc) + for i := int32(0); i < argc; i++ { + cstr := *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*unsafe.Sizeof(uintptr(0)))) + args[i] = libc.GoString(cstr) + } + return args +} + +func setVtabError(tls *libc.TLS, pzErr uintptr, msg string) { + if pzErr == 0 { + return + } + z := sqlite3AllocCString(tls, msg) + if z == 0 { + return + } + *(*uintptr)(unsafe.Pointer(pzErr)) = z +} + +// setVtabZErrMsg sets pVtab->zErrMsg to a newly allocated C string containing +// msg. SQLite will free this pointer. +func setVtabZErrMsg(tls *libc.TLS, pVtab uintptr, msg string) { + if pVtab == 0 { + return + } + vt := (*sqlite3.Sqlite3_vtab)(unsafe.Pointer(pVtab)) + if vt.FzErrMsg != 0 { + sqlite3.Xsqlite3_free(tls, vt.FzErrMsg) + vt.FzErrMsg = 0 + } + z := sqlite3AllocCString(tls, msg) + if z == 0 { + return + } + vt.FzErrMsg = z +} + +// Optional vtab callbacks + +// vtabFindFunctionTrampoline is xFindFunction. We currently do not expose a +// Go surface for per-table SQL functions; report not found (return 0). +func vtabFindFunctionTrampoline(tls *libc.TLS, pVtab uintptr, nArg int32, zName uintptr, pxFunc uintptr, ppArg uintptr) int32 { + _ = tls + _ = pVtab + _ = nArg + _ = zName + if pxFunc != 0 { + *(*uintptr)(unsafe.Pointer(pxFunc)) = 0 + } + if ppArg != 0 { + *(*uintptr)(unsafe.Pointer(ppArg)) = 0 + } + return 0 // not found +} + +// vtabRenameTrampoline is xRename. Calls Table.Rename if implemented. +func vtabRenameTrampoline(tls *libc.TLS, pVtab uintptr, zNew uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + name := libc.GoString(zNew) + if r, ok := gt.impl.(interface{ Rename(string) error }); ok { + if err := r.Rename(name); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + } + return sqlite3.SQLITE_OK +} + +// vtabUpdateTrampoline is xUpdate. Not supported by default; report read-only. +func vtabUpdateTrampoline(tls *libc.TLS, pVtab uintptr, argc int32, argv uintptr, pRowid uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + upd, ok := gt.impl.(interface { + Insert(cols []vtab.Value, rowid *int64) error + Update(oldRowid int64, cols []vtab.Value, newRowid *int64) error + Delete(oldRowid int64) error + }) + if !ok { + return sqlite3.SQLITE_READONLY + } + + // DELETE: argc == 1; argv[0]=oldRowid + if argc == 1 { + valPtr := *(*uintptr)(unsafe.Pointer(argv)) + oldRowid := int64(0) + if sqlite3.Xsqlite3_value_type(tls, valPtr) != sqlite3.SQLITE_NULL { + oldRowid = int64(sqlite3.Xsqlite3_value_int64(tls, valPtr)) + } + if err := upd.Delete(oldRowid); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + return sqlite3.SQLITE_OK + } + + // INSERT or UPDATE: argc == N+2. argv[0]=oldRowid (NULL for insert), + // argv[1]=newRowid (or desired rowid for insert, may be NULL), + // argv[2..N+1]=column values. + if argc < 3 { + return sqlite3.SQLITE_MISUSE + } + nCols := argc - 2 + // Extract column values starting from argv[2] + colsPtr := argv + uintptr(2)*sqliteValPtrSize + volatile := gt.mod != nil && gt.mod.volatile + sp := functionArgs(tls, nCols, colsPtr, volatile) + defer releaseUDFArgs(sp) + cols := *sp + + // Determine old/new rowid + oldPtr := *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*sqliteValPtrSize)) + newPtr := *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*sqliteValPtrSize)) + + oldIsNull := sqlite3.Xsqlite3_value_type(tls, oldPtr) == sqlite3.SQLITE_NULL + newIsNull := sqlite3.Xsqlite3_value_type(tls, newPtr) == sqlite3.SQLITE_NULL + + if oldIsNull { + // INSERT + var rid int64 + if !newIsNull { + rid = int64(sqlite3.Xsqlite3_value_int64(tls, newPtr)) + } + if err := upd.Insert(cols, &rid); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + if pRowid != 0 { + *(*int64)(unsafe.Pointer(pRowid)) = rid + } + return sqlite3.SQLITE_OK + } + + // UPDATE + oldRowid := int64(sqlite3.Xsqlite3_value_int64(tls, oldPtr)) + var newRid int64 + if !newIsNull { + newRid = int64(sqlite3.Xsqlite3_value_int64(tls, newPtr)) + } + if err := upd.Update(oldRowid, cols, &newRid); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + if pRowid != 0 && newRid != 0 { + *(*int64)(unsafe.Pointer(pRowid)) = newRid + } + return sqlite3.SQLITE_OK +} + +// Transactional callbacks +func vtabBeginTrampoline(tls *libc.TLS, pVtab uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + if tr, ok := gt.impl.(interface{ Begin() error }); ok { + if err := tr.Begin(); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + } + return sqlite3.SQLITE_OK +} + +func vtabSyncTrampoline(tls *libc.TLS, pVtab uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + if tr, ok := gt.impl.(interface{ Sync() error }); ok { + if err := tr.Sync(); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + } + return sqlite3.SQLITE_OK +} + +func vtabCommitTrampoline(tls *libc.TLS, pVtab uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + if tr, ok := gt.impl.(interface{ Commit() error }); ok { + if err := tr.Commit(); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + } + return sqlite3.SQLITE_OK +} + +func vtabRollbackTrampoline(tls *libc.TLS, pVtab uintptr) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + if tr, ok := gt.impl.(interface{ Rollback() error }); ok { + if err := tr.Rollback(); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + } + return sqlite3.SQLITE_OK +} + +func vtabSavepointTrampoline(tls *libc.TLS, pVtab uintptr, i int32) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + if tr, ok := gt.impl.(interface{ Savepoint(int) error }); ok { + if err := tr.Savepoint(int(i)); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + } + return sqlite3.SQLITE_OK +} + +func vtabReleaseTrampoline(tls *libc.TLS, pVtab uintptr, i int32) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + if tr, ok := gt.impl.(interface{ Release(int) error }); ok { + if err := tr.Release(int(i)); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + } + return sqlite3.SQLITE_OK +} + +func vtabRollbackToTrampoline(tls *libc.TLS, pVtab uintptr, i int32) int32 { + vtabTables.mu.RLock() + gt := vtabTables.m[pVtab] + vtabTables.mu.RUnlock() + if gt == nil { + return sqlite3.SQLITE_ERROR + } + if tr, ok := gt.impl.(interface{ RollbackTo(int) error }); ok { + if err := tr.RollbackTo(int(i)); err != nil { + setVtabZErrMsg(tls, pVtab, err.Error()) + return sqlite3.SQLITE_ERROR + } + } + return sqlite3.SQLITE_OK +} diff --git a/internal/engine/vtab/doc.go b/internal/engine/vtab/doc.go new file mode 100644 index 0000000..bf50eb1 --- /dev/null +++ b/internal/engine/vtab/doc.go @@ -0,0 +1,59 @@ +// Package vtab defines a Go-facing API for implementing SQLite virtual table +// modules on top of the github.com/hanzoai/sqlite/internal/engine driver. +// +// It is intentionally small and generic so that external projects can +// implement virtual tables without depending on the translated C internals. +package vtab + +// API notes +// +// - Schema declaration: Modules must call Context.Declare from within Create +// or Connect to declare the virtual table schema (a CREATE TABLE statement). +// The driver no longer auto-declares based on USING(...) args to support +// dynamic schemas (e.g., CSV headers). +// +// - Constraint support: Modules that want MATCH/other constraints must call +// Context.EnableConstraintSupport from within Create or Connect. +// +// - Vtab config: Modules can call Context.Config to pass sqlite3_vtab_config +// options (e.g., INNOCUOUS, DIRECTONLY) from within Create or Connect. +// +// - Constraint operators: ConstraintOp includes OpUnknown for operators that +// are not recognized. The driver maps common SQLite operators including EQ, +// NE, GT, GE, LT, LE, MATCH, IS/ISNOT, ISNULL/ISNOTNULL, LIKE, GLOB, REGEXP, +// FUNCTION, LIMIT, and OFFSET. +// +// - ArgIndex: Set as 0-based in Go to indicate which position in argv[] should +// receive a constraint value. The driver adds +1 when communicating with +// SQLite (which is 1-based). Use -1 (default) to ignore. +// +// - Omit: Set Constraint.Omit to ask SQLite to not re-evaluate that constraint +// in the parent query if the virtual table fully handles it. +// +// - ColUsed: IndexInfo.ColUsed provides a bitmask of columns referenced by the +// query. Bit N indicates column N is used. +// +// - IdxFlags: IndexInfo.IdxFlags allows modules to set planning flags. +// Currently, IndexScanUnique (mirrors SQLITE_INDEX_SCAN_UNIQUE) indicates +// the plan will visit at most one row. This can help the optimizer. +// +// Optional interfaces +// +// - Updater: Implement on your Table to support writes via xUpdate. +// Insert(cols, *rowid), Update(oldRowid, cols, *newRowid), Delete(oldRowid). +// The trampoline maps SQLite xUpdate’s calling convention to these methods. +// +// - Renamer: Implement Rename(newName string) on your Table to handle xRename. +// If unimplemented, rename is treated as a no-op. +// +// - Transactional: Implement Begin/Sync/Commit/Rollback/Savepoint/Release/ +// RollbackTo as needed. Unimplemented methods are treated as no-ops. +// These callbacks let writable or advanced modules coordinate with SQLite +// transaction boundaries. +// +// Re-entrancy cautions +// - Avoid executing SQL on the same connection from within vtab methods +// (Create/Connect/BestIndex/Filter/etc.). SQLite virtual table callbacks run +// inside the engine and issuing re-entrant SQL on the same connection can +// lead to deadlocks or undefined behavior. If a module requires issuing SQL, +// consider using a separate connection and document the concurrency model. diff --git a/internal/engine/vtab/vtab.go b/internal/engine/vtab/vtab.go new file mode 100644 index 0000000..51f0357 --- /dev/null +++ b/internal/engine/vtab/vtab.go @@ -0,0 +1,328 @@ +package vtab + +import ( + "database/sql" + "database/sql/driver" + "errors" +) + +// Value is the value type passed to and from virtual table cursors. It +// aliases database/sql/driver.Value to avoid exposing low-level details to +// module authors while remaining compatible with the driver. +type Value = driver.Value + +// Context carries information that a Module may need when creating or +// connecting a table instance. It intentionally does not expose *sql.DB to +// avoid leaking database/sql internals into the vtab API. Additional fields +// may be added in the future as needed. +type Context struct { + declare func(string) error + // constraintSupport enables constraint support (e.g. MATCH) for the module. + constraintSupport func() error + // config issues sqlite3_vtab_config calls for other vtab options. + config func(op int32, args ...int32) error +} + +// Declare must be called by a module from within Create or Connect to declare +// the schema of the virtual table. The provided SQL must be a CREATE TABLE +// statement describing the exposed columns. +// +// The engine installs this callback so that the declaration is executed in the +// correct context. Calling Declare outside of Create/Connect may fail. +func (c Context) Declare(schema string) error { + if c.declare == nil { + return errors.New("vtab: declare not available in this context") + } + return c.declare(schema) +} + +// EnableConstraintSupport enables virtual table constraint support in SQLite. +// This must be called from within Create or Connect. +func (c Context) EnableConstraintSupport() error { + if c.constraintSupport == nil { + return errors.New("vtab: constraint support not available in this context") + } + return c.constraintSupport() +} + +// Config forwards sqlite3_vtab_config options to SQLite. This must be called +// from within Create or Connect. +func (c Context) Config(op int32, args ...int32) error { + if c.config == nil { + return errors.New("vtab: config not available in this context") + } + return c.config(op, args...) +} + +// NewContext is used by the engine to create a Context bound to the current +// xCreate/xConnect call. External modules should not need to call this. +func NewContext(declare func(string) error) Context { return Context{declare: declare} } + +// NewContextWithConstraintSupport is used by the engine to create a Context +// that can enable constraint support. +func NewContextWithConstraintSupport(declare func(string) error, constraintSupport func() error) Context { + return Context{declare: declare, constraintSupport: constraintSupport} +} + +// NewContextWithConfig is used by the engine to create a Context that can +// enable constraint support and other sqlite3_vtab_config options. +func NewContextWithConfig(declare func(string) error, constraintSupport func() error, config func(op int32, args ...int32) error) Context { + return Context{declare: declare, constraintSupport: constraintSupport, config: config} +} + +// Module represents a virtual table module, analogous to sqlite3_module in +// the SQLite C API. Implementations are responsible for creating and +// connecting table instances. +type Module interface { + // Create is called to create a new virtual table. args corresponds to the + // argv array passed to xCreate in the SQLite C API: it contains the module + // name, the database name, the table name, and module arguments. + Create(ctx Context, args []string) (Table, error) + + // Connect is called to connect to an existing virtual table. Its + // semantics mirror xConnect in the SQLite C API. + Connect(ctx Context, args []string) (Table, error) +} + +// Table represents a single virtual table instance (the Go analogue of +// sqlite3_vtab and its associated methods). +type Table interface { + // BestIndex allows the virtual table to inform SQLite about which + // constraints and orderings it can efficiently support. The IndexInfo + // structure mirrors sqlite3_index_info. + BestIndex(info *IndexInfo) error + + // Open creates a new cursor for scanning the table. + Open() (Cursor, error) + + // Disconnect is called to disconnect from a table instance (xDisconnect). + Disconnect() error + + // Destroy is called when a table is dropped (xDestroy). + Destroy() error +} + +// Renamer can be implemented by a Table to handle xRename. +type Renamer interface { + Rename(newName string) error +} + +// Transactional can be implemented by a Table to handle transaction-related +// callbacks. Methods are optional; unimplemented methods are treated as no-op. +type Transactional interface { + Begin() error + Sync() error + Commit() error + Rollback() error + Savepoint(i int) error + Release(i int) error + RollbackTo(i int) error +} + +// Cursor represents a cursor over a virtual table (sqlite3_vtab_cursor). +type Cursor interface { + // Filter corresponds to xFilter. idxNum and idxStr are the chosen index + // number and string; vals are the constraint arguments. The vals slice + // and its entries are not valid past the return of this method; + // implementations must copy any value they wish to retain. + Filter(idxNum int, idxStr string, vals []Value) error + + // Next advances the cursor to the next row (xNext). + Next() error + + // Eof reports whether the cursor is past the last row (xEof != 0). + Eof() bool + + // Column returns the value of the specified column in the current row + // (xColumn). + Column(col int) (Value, error) + + // Rowid returns the current rowid (xRowid). + Rowid() (int64, error) + + // Close closes the cursor (xClose). + Close() error +} + +// Updater can be implemented by a Table to support writes via xUpdate. +// +// Semantics follow SQLite's xUpdate: +// - Delete: Delete(oldRowid) is called. +// - Insert: Insert(cols, rowid) is called. *rowid may contain a desired rowid +// (if provided by SQL) and should be set to the final rowid of the new row. +// - Update: Update(oldRowid, cols, newRowid) is called. *newRowid may be set +// to the final rowid of the updated row when changed. +// +// For Insert and Update, the cols slice and its entries are not valid past +// the return of the method; implementations must copy any value they wish +// to retain. +type Updater interface { + Insert(cols []Value, rowid *int64) error + Update(oldRowid int64, cols []Value, newRowid *int64) error + Delete(oldRowid int64) error +} + +// VolatileArgsOpter is an optional interface implemented by a Module to opt +// into zero-copy access for string and []byte values passed to Cursor.Filter +// and Updater.Insert / Updater.Update. When VolatileArgs returns true, the +// engine hands those arguments to the module as direct views into +// SQLite-owned memory instead of Go-allocated copies, saving one allocation +// per TEXT or BLOB argument per row. +// +// The opt-in is read once when the module is registered on a connection and +// is sticky for the lifetime of that registration; it covers every Filter, +// Insert, and Update call routed to tables created from this module. +// +// The safety contract mirrors github.com/hanzoai/sqlite/internal/engine.FunctionImpl.VolatileArgs: +// +// - The string and []byte values inside the vals / cols slice are valid +// only for the duration of the call. They must not be retained past the +// return of the method, directly (stored in a struct, map, channel, or +// outer-scope variable) or indirectly (passed to anything that captures +// them). +// +// - Retaining a volatile argument produces silent data corruption: SQLite +// reuses the underlying buffer for the next row, so a retained value +// will later appear to hold a different row's bytes. The race detector +// cannot catch this; callbacks run sequentially on a single goroutine. +// +// - To keep a value across rows, copy it: +// +// saved := append([]byte(nil), v.([]byte)...) // BLOB +// saved := string(append([]byte(nil), v.(string)...)) // TEXT, no aliasing +// +// - Do not re-enter SQLite on the same connection while a volatile +// argument is in scope. A nested Query/Exec can cause SQLite to reuse +// the underlying value buffers, so a volatile string or []byte read +// before the nested call may alias different bytes after it returns. +// +// VolatileArgs has no effect on integer, float, time, or NULL arguments. +// When in doubt, leave it returning false: the engine already pools the +// argument-slice header, so the per-row overhead in the default mode is one +// libc.GoString per TEXT column and one make([]byte) per BLOB column, not a +// fresh slice header. +type VolatileArgsOpter interface { + VolatileArgs() bool +} + +// ConstraintOp describes the operator used in a constraint on a virtual +// table column. It loosely mirrors the op field of sqlite3_index_constraint. +type ConstraintOp int + +const ( + // OpUnknown indicates an operator that is not recognized or not mapped. + // Modules should treat this conservatively. + OpUnknown ConstraintOp = iota + OpEQ + OpGT + OpLE + OpLT + OpGE + OpMATCH // "MATCH" operator (e.g. for FTS or KNN semantics) + OpNE + OpIS + OpISNOT + OpISNULL + OpISNOTNULL + OpLIKE + OpGLOB + OpREGEXP + OpFUNCTION + OpLIMIT + OpOFFSET +) + +// Constraint describes a single WHERE-clause constraint that SQLite is +// considering pushing down to the virtual table. +type Constraint struct { + Column int + Op ConstraintOp + Usable bool + // ArgIndex selects which position in argv[] (0-based) should contain the + // RHS value for this constraint when Filter is called. Set to -1 to ignore. + ArgIndex int + // Omit requests SQLite to omit the corresponding constraint from the + // parent query if the virtual table fully handles it. + Omit bool +} + +// OrderBy describes a single ORDER BY term for a query involving a virtual +// table. +type OrderBy struct { + Column int + Desc bool +} + +// IndexInfo holds information about constraints and orderings for a virtual +// table query. It is the Go analogue of sqlite3_index_info. +type IndexInfo struct { + Constraints []Constraint + OrderBy []OrderBy + + // IdxNum selects the query plan chosen in BestIndex. This value is passed + // back to Cursor.Filter. Note: SQLite stores this as a 32-bit signed + // integer (int32). Implementations must ensure IdxNum fits within the + // int32 range; values outside of int32 will cause an error in the driver + // to avoid silent truncation. + IdxNum int64 + IdxStr string + // IdxFlags provides extra information about the chosen plan. + // Set to IndexScanUnique to indicate the plan visits at most one row. + IdxFlags int + OrderByConsumed bool + EstimatedCost float64 + EstimatedRows int64 + // ColUsed is a bitmask indicating which columns are used by the query. + // Bit N is set if column N is referenced. + ColUsed uint64 +} + +// Index flag values for IndexInfo.IdxFlags. +const ( + // IndexScanUnique mirrors SQLITE_INDEX_SCAN_UNIQUE and indicates that the + // chosen plan will visit at most one row. + IndexScanUnique = 1 +) + +// ErrNotImplemented is returned by RegisterModule when the underlying engine +// has not yet installed a registration hook. External projects can depend on +// the vtab API surface before the low-level bridge to sqlite3_create_module +// is fully wired; once the engine sets the hook via SetRegisterFunc, +// RegisterModule will forward calls to it. +var ErrNotImplemented = errors.New("vtab: RegisterModule not wired into engine") + +// registerHook is installed by the engine package via SetRegisterFunc. It is +// invoked by RegisterModule to perform the actual module registration. +var registerHook func(name string, m Module) error + +// SetRegisterFunc is intended to be called by the engine package to provide +// the concrete implementation of module registration. External callers +// should use RegisterModule instead. +func SetRegisterFunc(fn func(name string, m Module) error) { registerHook = fn } + +// RegisterModule registers a virtual table module with the provided *sql.DB. +// +// Registration applies to new connections only. Existing open connections will +// not be updated to include newly registered modules. +// +// Registration is performed when opening a new connection. If the underlying +// sqlite3_create_module_v2 call fails, opening the connection fails and returns +// that error. This fail-fast behavior prevents partially-initialized +// connections when a module cannot be installed. +// +// The db parameter is currently unused by the engine; it is available so +// module implementations can capture it if they need a *sql.DB for their own +// internal queries. +func RegisterModule(db *sql.DB, name string, m Module) error { + _ = db + if registerHook == nil { + return ErrNotImplemented + } + if name == "" { + return errors.New("vtab: module name must be non-empty") + } + if m == nil { + return errors.New("vtab: module implementation is nil") + } + return registerHook(name, m) +} diff --git a/internal/libc/LICENSE b/internal/libc/LICENSE new file mode 100644 index 0000000..0c6500b --- /dev/null +++ b/internal/libc/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2017 The Libc Authors. 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 names of the authors nor the names of the +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. diff --git a/internal/libc/abi0_linux_amd64.go b/internal/libc/abi0_linux_amd64.go new file mode 100644 index 0000000..e8a26f1 --- /dev/null +++ b/internal/libc/abi0_linux_amd64.go @@ -0,0 +1,5765 @@ +// Code generated for linux/amd64 by 'qbecc --abi0wrap .', DO NOT EDIT. + +package libc + +import "unsafe" + +var _ unsafe.Pointer + +//go:noescape +func Y_Exit(tls *TLS, ec int32) + +//go:noescape +func Y_IO_feof_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y_IO_ferror_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y_IO_getc(tls *TLS, f1 uintptr) (r int32) + +//go:noescape +func Y_IO_getc_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y_IO_putc(tls *TLS, c1 int32, f1 uintptr) (r int32) + +//go:noescape +func Y_IO_putc_unlocked(tls *TLS, c int32, f uintptr) (r int32) + +//go:noescape +func Y___errno_location(tls *TLS) (r uintptr) + +//go:noescape +func Y__aio_close(tls *TLS, fd int32) (_2 int32) + +//go:noescape +func Y__asctime_r(tls *TLS, tm uintptr, buf uintptr) (r uintptr) + +//go:noescape +func Y__assert_fail(tls *TLS, expr uintptr, file uintptr, line int32, func1 uintptr) + +//go:noescape +func Y__atomic_compare_exchangeInt16(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) + +//go:noescape +func Y__atomic_compare_exchangeInt32(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) + +//go:noescape +func Y__atomic_compare_exchangeInt64(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) + +//go:noescape +func Y__atomic_compare_exchangeInt8(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) + +//go:noescape +func Y__atomic_compare_exchangeUint16(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) + +//go:noescape +func Y__atomic_compare_exchangeUint32(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) + +//go:noescape +func Y__atomic_compare_exchangeUint64(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) + +//go:noescape +func Y__atomic_compare_exchangeUint8(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) + +//go:noescape +func Y__atomic_exchangeInt16(t *TLS, ptr, val, ret uintptr, _ int32) + +//go:noescape +func Y__atomic_exchangeInt32(t *TLS, ptr, val, ret uintptr, _ int32) + +//go:noescape +func Y__atomic_exchangeInt64(t *TLS, ptr, val, ret uintptr, _ int32) + +//go:noescape +func Y__atomic_exchangeInt8(t *TLS, ptr, val, ret uintptr, _ int32) + +//go:noescape +func Y__atomic_exchangeUint16(t *TLS, ptr, val, ret uintptr, _ int32) + +//go:noescape +func Y__atomic_exchangeUint32(t *TLS, ptr, val, ret uintptr, _ int32) + +//go:noescape +func Y__atomic_exchangeUint64(t *TLS, ptr, val, ret uintptr, _ int32) + +//go:noescape +func Y__atomic_exchangeUint8(t *TLS, ptr, val, ret uintptr, _ int32) + +//go:noescape +func Y__atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__atomic_loadInt16(t *TLS, ptr, ret uintptr, memorder int32) + +//go:noescape +func Y__atomic_loadInt32(t *TLS, ptr, ret uintptr, memorder int32) + +//go:noescape +func Y__atomic_loadInt64(t *TLS, ptr, ret uintptr, memorder int32) + +//go:noescape +func Y__atomic_loadInt8(t *TLS, ptr, ret uintptr, memorder int32) + +//go:noescape +func Y__atomic_loadUint16(t *TLS, ptr, ret uintptr, memorder int32) + +//go:noescape +func Y__atomic_loadUint32(t *TLS, ptr, ret uintptr, memorder int32) + +//go:noescape +func Y__atomic_loadUint64(t *TLS, ptr, ret uintptr, memorder int32) + +//go:noescape +func Y__atomic_loadUint8(t *TLS, ptr, ret uintptr, memorder int32) + +//go:noescape +func Y__atomic_storeInt16(t *TLS, ptr, val uintptr, memorder int32) + +//go:noescape +func Y__atomic_storeInt32(t *TLS, ptr, val uintptr, memorder int32) + +//go:noescape +func Y__atomic_storeInt64(t *TLS, ptr, val uintptr, memorder int32) + +//go:noescape +func Y__atomic_storeInt8(t *TLS, ptr, val uintptr, memorder int32) + +//go:noescape +func Y__atomic_storeUint16(t *TLS, ptr, val uintptr, memorder int32) + +//go:noescape +func Y__atomic_storeUint32(t *TLS, ptr, val uintptr, memorder int32) + +//go:noescape +func Y__atomic_storeUint64(t *TLS, ptr, val uintptr, memorder int32) + +//go:noescape +func Y__atomic_storeUint8(t *TLS, ptr, val uintptr, memorder int32) + +//go:noescape +func Y__block_all_sigs(tls *TLS, set uintptr) + +//go:noescape +func Y__block_app_sigs(tls *TLS, set uintptr) + +//go:noescape +func Y__builtin___memcpy_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (r uintptr) + +//go:noescape +func Y__builtin___memmove_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (_3 uintptr) + +//go:noescape +func Y__builtin___memset_chk(t *TLS, s uintptr, c int32, n, os Tsize_t) (_4 uintptr) + +//go:noescape +func Y__builtin___snprintf_chk(t *TLS, str uintptr, maxlen Tsize_t, flag int32, os Tsize_t, format, args uintptr) (r int32) + +//go:noescape +func Y__builtin___sprintf_chk(t *TLS, s uintptr, flag int32, os Tsize_t, format, args uintptr) (r int32) + +//go:noescape +func Y__builtin___strcat_chk(t *TLS, dest, src uintptr, os Tsize_t) (r uintptr) + +//go:noescape +func Y__builtin___strcpy_chk(t *TLS, dest, src uintptr, os Tsize_t) (_3 uintptr) + +//go:noescape +func Y__builtin___strncpy_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (r uintptr) + +//go:noescape +func Y__builtin___vsnprintf_chk(t *TLS, str uintptr, maxlen Tsize_t, flag int32, os Tsize_t, format, args uintptr) (r int32) + +//go:noescape +func Y__builtin_abort(t *TLS) + +//go:noescape +func Y__builtin_abs(t *TLS, j int32) (_2 int32) + +//go:noescape +func Y__builtin_add_overflowInt64(t *TLS, a, b int64, res uintptr) (_3 int32) + +//go:noescape +func Y__builtin_add_overflowUint32(t *TLS, a, b uint32, res uintptr) (_3 int32) + +//go:noescape +func Y__builtin_add_overflowUint64(t *TLS, a, b uint64, res uintptr) (_3 int32) + +//go:noescape +func Y__builtin_alloca(tls *TLS, size Tsize_t) (_2 uintptr) + +//go:noescape +func Y__builtin_bswap16(t *TLS, x uint16) (_2 uint16) + +//go:noescape +func Y__builtin_bswap32(t *TLS, x uint32) (_2 uint32) + +//go:noescape +func Y__builtin_bswap64(t *TLS, x uint64) (_2 uint64) + +//go:noescape +func Y__builtin_bzero(t *TLS, s uintptr, n Tsize_t) + +//go:noescape +func Y__builtin_clz(t *TLS, n uint32) (_2 int32) + +//go:noescape +func Y__builtin_clzl(t *TLS, n ulong) (_2 int32) + +//go:noescape +func Y__builtin_clzll(t *TLS, n uint64) (_2 int32) + +//go:noescape +func Y__builtin_copysign(t *TLS, x, y float64) (_2 float64) + +//go:noescape +func Y__builtin_copysignf(t *TLS, x, y float32) (_2 float32) + +//go:noescape +func Y__builtin_copysignl(t *TLS, x, y float64) (_2 float64) + +//go:noescape +func Y__builtin_ctz(t *TLS, n uint32) (_2 int32) + +//go:noescape +func Y__builtin_ctzl(tls *TLS, x ulong) (_2 int32) + +//go:noescape +func Y__builtin_exit(t *TLS, status int32) + +//go:noescape +func Y__builtin_expect(t *TLS, exp, c long) (_2 long) + +//go:noescape +func Y__builtin_fabs(t *TLS, x float64) (_2 float64) + +//go:noescape +func Y__builtin_fabsf(t *TLS, x float32) (_2 float32) + +//go:noescape +func Y__builtin_fabsl(t *TLS, x float64) (_2 float64) + +//go:noescape +func Y__builtin_ffs(tls *TLS, i int32) (r int32) + +//go:noescape +func Y__builtin_fma(tls *TLS, x, y, z float64) (r float64) + +//go:noescape +func Y__builtin_fmax(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Y__builtin_fmin(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Y__builtin_free(t *TLS, ptr uintptr) + +//go:noescape +func Y__builtin_getentropy(t *TLS, buf uintptr, n Tsize_t) (_3 int32) + +//go:noescape +func Y__builtin_huge_val(t *TLS) (_1 float64) + +//go:noescape +func Y__builtin_huge_valf(t *TLS) (_1 float32) + +//go:noescape +func Y__builtin_hypot(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Y__builtin_inf(t *TLS) (_1 float64) + +//go:noescape +func Y__builtin_inff(tls *TLS) (_1 float32) + +//go:noescape +func Y__builtin_infl(t *TLS) (_1 float64) + +//go:noescape +func Y__builtin_isblank(tls *TLS, c int32) (r int32) + +//go:noescape +func Y__builtin_isnan(t *TLS, x float64) (_2 int32) + +//go:noescape +func Y__builtin_isnanf(t *TLS, x float32) (_2 int32) + +//go:noescape +func Y__builtin_isnanl(t *TLS, x float64) (_2 int32) + +//go:noescape +func Y__builtin_isprint(tls *TLS, c int32) (r int32) + +//go:noescape +func Y__builtin_isunordered(t *TLS, a, b float64) (_2 int32) + +//go:noescape +func Y__builtin_llabs(tls *TLS, a int64) (_2 int64) + +//go:noescape +func Y__builtin_log2(t *TLS, x float64) (_2 float64) + +//go:noescape +func Y__builtin_lrint(tls *TLS, x float64) (r long) + +//go:noescape +func Y__builtin_lrintf(tls *TLS, x float32) (r long) + +//go:noescape +func Y__builtin_lround(tls *TLS, x float64) (r long) + +//go:noescape +func Y__builtin_malloc(t *TLS, size Tsize_t) (_2 uintptr) + +//go:noescape +func Y__builtin_memcmp(t *TLS, s1, s2 uintptr, n Tsize_t) (_3 int32) + +//go:noescape +func Y__builtin_memcpy(t *TLS, dest, src uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Y__builtin_memset(t *TLS, s uintptr, c int32, n Tsize_t) (_4 uintptr) + +//go:noescape +func Y__builtin_mmap(t *TLS, addr uintptr, length Tsize_t, prot, flags, fd int32, offset Toff_t) (_5 uintptr) + +//go:noescape +func Y__builtin_mul_overflowInt64(t *TLS, a, b int64, res uintptr) (_3 int32) + +//go:noescape +func Y__builtin_mul_overflowUint128(t *TLS, a, b Uint128, res uintptr) (_3 int32) + +//go:noescape +func Y__builtin_mul_overflowUint64(t *TLS, a, b uint64, res uintptr) (_3 int32) + +//go:noescape +func Y__builtin_nan(t *TLS, s uintptr) (_2 float64) + +//go:noescape +func Y__builtin_nanf(tls *TLS, s uintptr) (_2 float32) + +//go:noescape +func Y__builtin_nanl(t *TLS, s uintptr) (_2 float64) + +//go:noescape +func Y__builtin_object_size(t *TLS, p uintptr, typ int32) (_3 Tsize_t) + +//go:noescape +func Y__builtin_popcount(t *TLS, x uint32) (_2 int32) + +//go:noescape +func Y__builtin_popcountl(t *TLS, x ulong) (_2 int32) + +//go:noescape +func Y__builtin_popcountll(t *TLS, x uint64) (_2 int32) + +//go:noescape +func Y__builtin_prefetch(t *TLS, addr, args uintptr) + +//go:noescape +func Y__builtin_printf(tls *TLS, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Y__builtin_rintf(tls *TLS, x float32) (r float32) + +//go:noescape +func Y__builtin_round(tls *TLS, x float64) (r float64) + +//go:noescape +func Y__builtin_roundf(tls *TLS, x float32) (r float32) + +//go:noescape +func Y__builtin_snprintf(t *TLS, str uintptr, size Tsize_t, format, args uintptr) (_4 int32) + +//go:noescape +func Y__builtin_sprintf(t *TLS, str, format, args uintptr) (r int32) + +//go:noescape +func Y__builtin_strchr(t *TLS, s uintptr, c int32) (_3 uintptr) + +//go:noescape +func Y__builtin_strcmp(t *TLS, s1, s2 uintptr) (_2 int32) + +//go:noescape +func Y__builtin_strcpy(t *TLS, dest, src uintptr) (_2 uintptr) + +//go:noescape +func Y__builtin_strlen(t *TLS, s uintptr) (_2 Tsize_t) + +//go:noescape +func Y__builtin_sub_overflowInt64(t *TLS, a, b int64, res uintptr) (_3 int32) + +//go:noescape +func Y__builtin_trap(t *TLS) + +//go:noescape +func Y__builtin_trunc(tls *TLS, x float64) (r float64) + +//go:noescape +func Y__builtin_unreachable(t *TLS) + +//go:noescape +func Y__builtin_vsnprintf(t *TLS, str uintptr, size Tsize_t, format, va uintptr) (_4 int32) + +//go:noescape +func Y__c11_atomic_compare_exchange_strongInt16(t *TLS, ptr, expected uintptr, desired int16, success, failure int32) (_4 int32) + +//go:noescape +func Y__c11_atomic_compare_exchange_strongInt32(t *TLS, ptr, expected uintptr, desired, success, failure int32) (_3 int32) + +//go:noescape +func Y__c11_atomic_compare_exchange_strongInt64(t *TLS, ptr, expected uintptr, desired int64, success, failure int32) (_4 int32) + +//go:noescape +func Y__c11_atomic_compare_exchange_strongInt8(t *TLS, ptr, expected uintptr, desired int8, success, failure int32) (_4 int32) + +//go:noescape +func Y__c11_atomic_compare_exchange_strongUint16(t *TLS, ptr, expected uintptr, desired uint16, success, failure int32) (_4 int32) + +//go:noescape +func Y__c11_atomic_compare_exchange_strongUint32(t *TLS, ptr, expected uintptr, desired uint32, success, failure int32) (_4 int32) + +//go:noescape +func Y__c11_atomic_compare_exchange_strongUint64(t *TLS, ptr, expected uintptr, desired uint64, success, failure int32) (_4 int32) + +//go:noescape +func Y__c11_atomic_compare_exchange_strongUint8(t *TLS, ptr, expected uintptr, desired uint8, success, failure int32) (_4 int32) + +//go:noescape +func Y__c11_atomic_exchangeInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__c11_atomic_exchangeInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__c11_atomic_exchangeInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__c11_atomic_exchangeInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__c11_atomic_exchangeUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__c11_atomic_exchangeUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__c11_atomic_exchangeUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__c11_atomic_exchangeUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__c11_atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__c11_atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__c11_atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__c11_atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__c11_atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__c11_atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__c11_atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__c11_atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__c11_atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__c11_atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__c11_atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__c11_atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__c11_atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__c11_atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__c11_atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__c11_atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__c11_atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__c11_atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__c11_atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__c11_atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__c11_atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__c11_atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__c11_atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__c11_atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__c11_atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__c11_atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__c11_atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__c11_atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__c11_atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__c11_atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__c11_atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__c11_atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__c11_atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) + +//go:noescape +func Y__c11_atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) + +//go:noescape +func Y__c11_atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) + +//go:noescape +func Y__c11_atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) + +//go:noescape +func Y__c11_atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) + +//go:noescape +func Y__c11_atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) + +//go:noescape +func Y__c11_atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) + +//go:noescape +func Y__c11_atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) + +//go:noescape +func Y__c11_atomic_loadInt16(t *TLS, ptr uintptr, memorder int32) (r int16) + +//go:noescape +func Y__c11_atomic_loadInt32(t *TLS, ptr uintptr, memorder int32) (r int32) + +//go:noescape +func Y__c11_atomic_loadInt64(t *TLS, ptr uintptr, memorder int32) (r int64) + +//go:noescape +func Y__c11_atomic_loadInt8(t *TLS, ptr uintptr, memorder int32) (r int8) + +//go:noescape +func Y__c11_atomic_loadUint16(t *TLS, ptr uintptr, memorder int32) (r uint16) + +//go:noescape +func Y__c11_atomic_loadUint32(t *TLS, ptr uintptr, memorder int32) (r uint32) + +//go:noescape +func Y__c11_atomic_loadUint64(t *TLS, ptr uintptr, memorder int32) (r uint64) + +//go:noescape +func Y__c11_atomic_loadUint8(t *TLS, ptr uintptr, memorder int32) (r uint8) + +//go:noescape +func Y__c11_atomic_storeInt16(t *TLS, ptr uintptr, val int16, memorder int32) + +//go:noescape +func Y__c11_atomic_storeInt32(t *TLS, ptr uintptr, val int32, memorder int32) + +//go:noescape +func Y__c11_atomic_storeInt64(t *TLS, ptr uintptr, val int64, memorder int32) + +//go:noescape +func Y__c11_atomic_storeInt8(t *TLS, ptr uintptr, val int8, memorder int32) + +//go:noescape +func Y__c11_atomic_storeUint16(t *TLS, ptr uintptr, val uint16, memorder int32) + +//go:noescape +func Y__c11_atomic_storeUint32(t *TLS, ptr uintptr, val uint32, memorder int32) + +//go:noescape +func Y__c11_atomic_storeUint64(t *TLS, ptr uintptr, val uint64, memorder int32) + +//go:noescape +func Y__c11_atomic_storeUint8(t *TLS, ptr uintptr, val uint8, memorder int32) + +//go:noescape +func Y__ccgo_dmesg(t *TLS, fmt uintptr, va uintptr) + +//go:noescape +func Y__ccgo_getMutexType(tls *TLS, m uintptr) (_2 int32) + +//go:noescape +func Y__ccgo_in6addr_anyp(t *TLS) (_1 uintptr) + +//go:noescape +func Y__ccgo_pthreadAttrGetDetachState(tls *TLS, a uintptr) (_2 int32) + +//go:noescape +func Y__ccgo_pthreadMutexattrGettype(tls *TLS, a uintptr) (_2 int32) + +//go:noescape +func Y__ccgo_sqlite3_log(t *TLS, iErrCode int32, zFormat uintptr, args uintptr) + +//go:noescape +func Y__clock_gettime(tls *TLS, clk Tclockid_t, ts uintptr) (r1 int32) + +//go:noescape +func Y__clock_nanosleep(tls *TLS, clk Tclockid_t, flags int32, req uintptr, rem uintptr) (r int32) + +//go:noescape +func Y__cmsg_nxthdr(t *TLS, msgh, cmsg uintptr) (_2 uintptr) + +//go:noescape +func Y__convert_scm_timestamps(tls *TLS, msg uintptr, csize Tsocklen_t) + +//go:noescape +func Y__cos(tls *TLS, x float64, y float64) (r1 float64) + +//go:noescape +func Y__cosdf(tls *TLS, x float64) (r1 float32) + +//go:noescape +func Y__crypt_blowfish(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) + +//go:noescape +func Y__crypt_des(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) + +//go:noescape +func Y__crypt_md5(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) + +//go:noescape +func Y__crypt_r(tls *TLS, key uintptr, salt uintptr, data uintptr) (r uintptr) + +//go:noescape +func Y__crypt_sha256(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) + +//go:noescape +func Y__crypt_sha512(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) + +//go:noescape +func Y__ctype_b_loc(tls *TLS) (r uintptr) + +//go:noescape +func Y__ctype_get_mb_cur_max(tls *TLS) (r Tsize_t) + +//go:noescape +func Y__ctype_tolower_loc(tls *TLS) (r uintptr) + +//go:noescape +func Y__ctype_toupper_loc(tls *TLS) (r uintptr) + +//go:noescape +func Y__des_setkey(tls *TLS, key uintptr, ekey uintptr) + +//go:noescape +func Y__dn_expand(tls *TLS, base uintptr, end uintptr, src uintptr, dest uintptr, space int32) (r int32) + +//go:noescape +func Y__dns_parse(tls *TLS, r uintptr, rlen int32, __ccgo_fp_callback uintptr, ctx uintptr) (r1 int32) + +//go:noescape +func __ccgo_abi0___dns_parse_2(_0 *TLS, _1 uintptr, _2 int32, _3 uintptr, _4 int32, _5 uintptr, _6 int32, __ccgo_fp uintptr) (_7 int32) + +func __ccgo_abiInternal___dns_parse_2(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 int32, _3 uintptr, _4 int32, _5 uintptr, _6 int32) (_7 int32) { + return __ccgo_abi0___dns_parse_2(_0, _1, _2, _3, _4, _5, _6, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Y__do_des(tls *TLS, l_in Tuint32_t, r_in Tuint32_t, l_out uintptr, r_out uintptr, count Tuint32_t, saltbits Tuint32_t, ekey uintptr) + +//go:noescape +func Y__do_orphaned_stdio_locks(tls *TLS) + +//go:noescape +func Y__dup3(tls *TLS, old int32, new1 int32, flags int32) (r1 int32) + +//go:noescape +func Y__duplocale(tls *TLS, old Tlocale_t) (r Tlocale_t) + +//go:noescape +func Y__env_rm_add(tls *TLS, old uintptr, new1 uintptr) + +//go:noescape +func Y__errno_location(tls *TLS) (r uintptr) + +//go:noescape +func Y__execvpe(tls *TLS, file uintptr, argv uintptr, envp uintptr) (r int32) + +//go:noescape +func Y__expo2(tls *TLS, x float64, sign float64) (r float64) + +//go:noescape +func Y__expo2f(tls *TLS, x float32, sign float32) (r float32) + +//go:noescape +func Y__fbufsize(tls *TLS, f uintptr) (r Tsize_t) + +//go:noescape +func Y__fclose_ca(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__fdopen(tls *TLS, fd int32, mode uintptr) (r uintptr) + +//go:noescape +func Y__fesetround(tls *TLS, r int32) (r1 int32) + +//go:noescape +func Y__fgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) + +//go:noescape +func Y__flbf(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__floatscan(tls *TLS, f uintptr, prec int32, pok int32) (r float64) + +//go:noescape +func Y__fmodeflags(tls *TLS, mode uintptr) (r int32) + +//go:noescape +func Y__fopen_rb_ca(tls *TLS, filename uintptr, f uintptr, buf uintptr, len1 Tsize_t) (r uintptr) + +//go:noescape +func Y__fpclassify(tls *TLS, x float64) (r int32) + +//go:noescape +func Y__fpclassifyf(tls *TLS, x float32) (r int32) + +//go:noescape +func Y__fpclassifyl(tls *TLS, x float64) (r int32) + +//go:noescape +func Y__fpending(tls *TLS, f uintptr) (r Tsize_t) + +//go:noescape +func Y__fpurge(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__fputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) + +//go:noescape +func Y__freadable(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__freadahead(tls *TLS, f uintptr) (r Tsize_t) + +//go:noescape +func Y__freading(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__freadptr(tls *TLS, f uintptr, sizep uintptr) (r uintptr) + +//go:noescape +func Y__freadptrinc(tls *TLS, f uintptr, inc Tsize_t) + +//go:noescape +func Y__freelocale(tls *TLS, l Tlocale_t) + +//go:noescape +func Y__fseeko(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) + +//go:noescape +func Y__fseeko_unlocked(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) + +//go:noescape +func Y__fseterr(tls *TLS, f uintptr) + +//go:noescape +func Y__fsetlocking(tls *TLS, f uintptr, type1 int32) (r int32) + +//go:noescape +func Y__fstat(tls *TLS, fd int32, st uintptr) (r int32) + +//go:noescape +func Y__fstatat(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) + +//go:noescape +func Y__ftello(tls *TLS, f uintptr) (r Toff_t) + +//go:noescape +func Y__ftello_unlocked(tls *TLS, f uintptr) (r Toff_t) + +//go:noescape +func Y__funcs_on_quick_exit(tls *TLS) + +//go:noescape +func Y__futimesat(tls *TLS, dirfd int32, pathname uintptr, times uintptr) (r int32) + +//go:noescape +func Y__fwritable(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__fwritex(tls *TLS, s uintptr, l Tsize_t, f uintptr) (r Tsize_t) + +//go:noescape +func Y__fwriting(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__fxstat(tls *TLS, ver int32, fd int32, buf uintptr) (r int32) + +//go:noescape +func Y__fxstatat(tls *TLS, ver int32, fd int32, path uintptr, buf uintptr, flag int32) (r int32) + +//go:noescape +func Y__get_handler_set(tls *TLS, set uintptr) + +//go:noescape +func Y__get_locale(tls *TLS, cat int32, val uintptr) (r uintptr) + +//go:noescape +func Y__get_resolv_conf(tls *TLS, conf uintptr, search uintptr, search_sz Tsize_t) (r int32) + +//go:noescape +func Y__getauxval(tls *TLS, item uint64) (r uint64) + +//go:noescape +func Y__getdelim(tls *TLS, s uintptr, n uintptr, delim int32, f uintptr) (r Tssize_t) + +//go:noescape +func Y__getgr_a(tls *TLS, name uintptr, gid Tgid_t, gr uintptr, buf uintptr, size uintptr, mem uintptr, nmem uintptr, res uintptr) (r int32) + +//go:noescape +func Y__getgrent_a(tls *TLS, f uintptr, gr uintptr, line uintptr, size uintptr, mem uintptr, nmem uintptr, res uintptr) (r int32) + +//go:noescape +func Y__getopt_msg(tls *TLS, a uintptr, b uintptr, c uintptr, l Tsize_t) + +//go:noescape +func Y__getpw_a(tls *TLS, name uintptr, uid Tuid_t, pw uintptr, buf uintptr, size uintptr, res uintptr) (r int32) + +//go:noescape +func Y__getpwent_a(tls *TLS, f uintptr, pw uintptr, line uintptr, size uintptr, res uintptr) (r int32) + +//go:noescape +func Y__gettextdomain(tls *TLS) (r uintptr) + +//go:noescape +func Y__gmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) + +//go:noescape +func Y__h_errno_location(tls *TLS) (r uintptr) + +//go:noescape +func Y__inet_aton(tls *TLS, s0 uintptr, dest uintptr) (r int32) + +//go:noescape +func Y__init_ssp(tls *TLS, entropy uintptr) + +//go:noescape +func Y__intscan(tls *TLS, f uintptr, base uint32, pok int32, lim uint64) (r uint64) + +//go:noescape +func Y__isalnum_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__isalpha_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__isblank_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__iscntrl_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__isdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__isfinite(tls *TLS, d float64) (_2 int32) + +//go:noescape +func Y__isfinitef(tls *TLS, f float32) (_2 int32) + +//go:noescape +func Y__isfinitel(tls *TLS, d float64) (_2 int32) + +//go:noescape +func Y__isgraph_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__islower_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__isnan(t *TLS, x float64) (_2 int32) + +//go:noescape +func Y__isnanf(t *TLS, arg float32) (_2 int32) + +//go:noescape +func Y__isnanl(t *TLS, arg float64) (_2 int32) + +//go:noescape +func Y__isoc99_fscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Y__isoc99_fwscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Y__isoc99_scanf(tls *TLS, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Y__isoc99_sscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Y__isoc99_swscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Y__isoc99_vfscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Y__isoc99_vfwscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Y__isoc99_vscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Y__isoc99_vsscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Y__isoc99_vswscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Y__isoc99_vwscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Y__isoc99_wscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Y__isprint_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__ispunct_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__isspace_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__isupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswalnum_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswalpha_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswblank_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswcntrl_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswctype_l(tls *TLS, c Twint_t, t Twctype_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswgraph_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswprint_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswpunct_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswspace_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__iswxdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Y__isxdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__lctrans(tls *TLS, msg uintptr, lm uintptr) (r uintptr) + +//go:noescape +func Y__lctrans_cur(tls *TLS, msg uintptr) (r uintptr) + +//go:noescape +func Y__lctrans_impl(tls *TLS, msg uintptr, lm uintptr) (r uintptr) + +//go:noescape +func Y__ldexp_cexp(tls *TLS, z complex128, expt int32) (r complex128) + +//go:noescape +func Y__ldexp_cexpf(tls *TLS, z complex64, expt int32) (r complex64) + +//go:noescape +func Y__lgamma_r(tls *TLS, x float64, signgamp uintptr) (r1 float64) + +//go:noescape +func Y__lgammaf_r(tls *TLS, x float32, signgamp uintptr) (r1 float32) + +//go:noescape +func Y__lgammal_r(tls *TLS, x float64, sg uintptr) (r float64) + +//go:noescape +func Y__libc_current_sigrtmax(tls *TLS) (r int32) + +//go:noescape +func Y__libc_current_sigrtmin(tls *TLS) (r int32) + +//go:noescape +func Y__libc_sigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r1 int32) + +//go:noescape +func Y__loc_is_allocated(tls *TLS, loc Tlocale_t) (r int32) + +//go:noescape +func Y__localtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) + +//go:noescape +func Y__lockfile(tls *TLS, file uintptr) (_2 int32) + +//go:noescape +func Y__lookup_ipliteral(tls *TLS, buf uintptr, name uintptr, family int32) (r int32) + +//go:noescape +func Y__lookup_name(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, flags int32) (r int32) + +//go:noescape +func Y__lookup_serv(tls *TLS, buf uintptr, name uintptr, proto int32, socktype int32, flags int32) (r int32) + +//go:noescape +func Y__lseek(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) + +//go:noescape +func Y__lsysinfo(tls *TLS, info uintptr) (r int32) + +//go:noescape +func Y__lxstat(tls *TLS, ver int32, path uintptr, buf uintptr) (r int32) + +//go:noescape +func Y__madvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) + +//go:noescape +func Y__map_file(tls *TLS, pathname uintptr, size uintptr) (r uintptr) + +//go:noescape +func Y__math_divzero(tls *TLS, sign Tuint32_t) (r float64) + +//go:noescape +func Y__math_divzerof(tls *TLS, sign Tuint32_t) (r float32) + +//go:noescape +func Y__math_invalid(tls *TLS, x float64) (r float64) + +//go:noescape +func Y__math_invalidf(tls *TLS, x float32) (r float32) + +//go:noescape +func Y__math_oflow(tls *TLS, sign Tuint32_t) (r float64) + +//go:noescape +func Y__math_oflowf(tls *TLS, sign Tuint32_t) (r float32) + +//go:noescape +func Y__math_uflow(tls *TLS, sign Tuint32_t) (r float64) + +//go:noescape +func Y__math_uflowf(tls *TLS, sign Tuint32_t) (r float32) + +//go:noescape +func Y__math_xflow(tls *TLS, sign Tuint32_t, y2 float64) (r float64) + +//go:noescape +func Y__math_xflowf(tls *TLS, sign Tuint32_t, y2 float32) (r float32) + +//go:noescape +func Y__memrchr(tls *TLS, m uintptr, c int32, n Tsize_t) (r uintptr) + +//go:noescape +func Y__mkostemps(tls *TLS, template uintptr, len1 int32, flags int32) (r int32) + +//go:noescape +func Y__mmap(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) + +//go:noescape +func Y__mo_lookup(tls *TLS, p uintptr, size Tsize_t, s uintptr) (r uintptr) + +//go:noescape +func Y__month_to_secs(tls *TLS, month int32, is_leap int32) (r int32) + +//go:noescape +func Y__mprotect(tls *TLS, addr uintptr, len1 Tsize_t, prot int32) (r int32) + +//go:noescape +func Y__mremap(tls *TLS, old_addr uintptr, old_len Tsize_t, new_len Tsize_t, flags int32, va uintptr) (r uintptr) + +//go:noescape +func Y__munmap(tls *TLS, start uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Y__newlocale(tls *TLS, mask int32, name uintptr, loc Tlocale_t) (r Tlocale_t) + +//go:noescape +func Y__nl_langinfo(tls *TLS, item Tnl_item) (r uintptr) + +//go:noescape +func Y__nl_langinfo_l(tls *TLS, item Tnl_item, loc Tlocale_t) (r uintptr) + +//go:noescape +func Y__nscd_query(tls *TLS, req Tint32_t, key uintptr, buf uintptr, len1 Tsize_t, swap uintptr) (r uintptr) + +//go:noescape +func Y__ofl_add(tls *TLS, f uintptr) (r uintptr) + +//go:noescape +func Y__ofl_lock(tls *TLS) (r uintptr) + +//go:noescape +func Y__ofl_unlock(tls *TLS) + +//go:noescape +func Y__overflow(tls *TLS, f uintptr, _c int32) (r int32) + +//go:noescape +func Y__pleval(tls *TLS, s uintptr, n uint64) (r uint64) + +//go:noescape +func Y__posix_getopt(tls *TLS, argc int32, argv uintptr, optstring uintptr) (r int32) + +//go:noescape +func Y__procfdname(tls *TLS, buf uintptr, fd uint32) + +//go:noescape +func Y__ptsname_r(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Y__putenv(tls *TLS, s uintptr, l Tsize_t, r uintptr) (r1 int32) + +//go:noescape +func Y__qsort_r(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr) + +//go:noescape +func __ccgo_abi0___qsort_r_3(_0 *TLS, _1 uintptr, _2 uintptr, _3 uintptr, __ccgo_fp uintptr) (_4 int32) + +func __ccgo_abiInternal___qsort_r_3(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr, _3 uintptr) (_4 int32) { + return __ccgo_abi0___qsort_r_3(_0, _1, _2, _3, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Y__rand48_step(tls *TLS, xi uintptr, lc uintptr) (r Tuint64_t) + +//go:noescape +func Y__register_locked_file(tls *TLS, f uintptr, self Tpthread_t) + +//go:noescape +func Y__rem_pio2(tls *TLS, x float64, y uintptr) (r1 int32) + +//go:noescape +func Y__rem_pio2_large(tls *TLS, x uintptr, y uintptr, e0 int32, nx int32, prec int32) (r int32) + +//go:noescape +func Y__rem_pio2f(tls *TLS, x float32, y uintptr) (r int32) + +//go:noescape +func Y__res_mkquery(tls *TLS, op int32, dname uintptr, class int32, type1 int32, data uintptr, datalen int32, newrr uintptr, buf uintptr, buflen int32) (r int32) + +//go:noescape +func Y__res_msend(tls *TLS, nqueries int32, queries uintptr, qlens uintptr, answers uintptr, alens uintptr, asize int32) (r int32) + +//go:noescape +func Y__res_msend_rc(tls *TLS, nqueries int32, queries uintptr, qlens uintptr, answers uintptr, alens uintptr, asize int32, conf uintptr) (r1 int32) + +//go:noescape +func Y__res_send(tls *TLS, _msg uintptr, _msglen int32, _answer uintptr, _anslen int32) (r1 int32) + +//go:noescape +func Y__res_state(tls *TLS) (r uintptr) + +//go:noescape +func Y__reset_tls(tls *TLS) + +//go:noescape +func Y__restore(tls *TLS) + +//go:noescape +func Y__restore_rt(tls *TLS) + +//go:noescape +func Y__restore_sigs(tls *TLS, set uintptr) + +//go:noescape +func Y__rtnetlink_enumerate(tls *TLS, link_af int32, addr_af int32, __ccgo_fp_cb uintptr, ctx uintptr) (r1 int32) + +//go:noescape +func __ccgo_abi0___rtnetlink_enumerate_2(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal___rtnetlink_enumerate_2(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0___rtnetlink_enumerate_2(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Y__secs_to_tm(tls *TLS, t int64, tm uintptr) (r int32) + +//go:noescape +func Y__secs_to_zone(tls *TLS, t int64, local int32, isdst uintptr, offset uintptr, oppoff uintptr, zonename uintptr) + +//go:noescape +func Y__setxid(tls *TLS, nr int32, id int32, eid int32, sid int32) (r int32) + +//go:noescape +func Y__shgetc(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__shlim(tls *TLS, f uintptr, lim Toff_t) + +//go:noescape +func Y__shm_mapname(tls *TLS, name uintptr, buf uintptr) (r uintptr) + +//go:noescape +func Y__sigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r1 int32) + +//go:noescape +func Y__signbit(tls *TLS, x float64) (r int32) + +//go:noescape +func Y__signbitf(tls *TLS, x float32) (r int32) + +//go:noescape +func Y__signbitl(tls *TLS, x float64) (r int32) + +//go:noescape +func Y__sigsetjmp_tail(tls *TLS, jb uintptr, ret int32) (r int32) + +//go:noescape +func Y__sin(tls *TLS, x float64, y float64, iy int32) (r1 float64) + +//go:noescape +func Y__sindf(tls *TLS, x float64) (r1 float32) + +//go:noescape +func Y__stack_chk_fail(tls *TLS) + +//go:noescape +func Y__stack_chk_fail_local(tls *TLS) + +//go:noescape +func Y__stdio_close(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__stdio_exit(tls *TLS) + +//go:noescape +func Y__stdio_exit_needed(tls *TLS) + +//go:noescape +func Y__stdio_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) + +//go:noescape +func Y__stdio_seek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) + +//go:noescape +func Y__stdio_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) + +//go:noescape +func Y__stdout_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) + +//go:noescape +func Y__stpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) + +//go:noescape +func Y__stpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Y__strcasecmp_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) + +//go:noescape +func Y__strchrnul(tls *TLS, s uintptr, c int32) (r uintptr) + +//go:noescape +func Y__strcoll_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) + +//go:noescape +func Y__strerror_l(tls *TLS, e int32, loc Tlocale_t) (r uintptr) + +//go:noescape +func Y__strftime_fmt_1(tls *TLS, s uintptr, l uintptr, f int32, tm uintptr, loc Tlocale_t, pad int32) (r uintptr) + +//go:noescape +func Y__strftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) + +//go:noescape +func Y__strncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, loc Tlocale_t) (r1 int32) + +//go:noescape +func Y__strtod_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) + +//go:noescape +func Y__strtof_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float32) + +//go:noescape +func Y__strtoimax_internal(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) + +//go:noescape +func Y__strtol_internal(tls *TLS, s uintptr, p uintptr, base int32) (r int64) + +//go:noescape +func Y__strtold_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) + +//go:noescape +func Y__strtoll_internal(tls *TLS, s uintptr, p uintptr, base int32) (r int64) + +//go:noescape +func Y__strtoul_internal(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) + +//go:noescape +func Y__strtoull_internal(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) + +//go:noescape +func Y__strtoumax_internal(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) + +//go:noescape +func Y__strxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) + +//go:noescape +func Y__sync_synchronize(t *TLS) + +//go:noescape +func Y__sync_val_compare_and_swapInt16(t *TLS, ptr uintptr, oldval, newval int16) (r int16) + +//go:noescape +func Y__sync_val_compare_and_swapInt32(t *TLS, ptr uintptr, oldval, newval int32) (r int32) + +//go:noescape +func Y__sync_val_compare_and_swapInt64(t *TLS, ptr uintptr, oldval, newval int64) (r int64) + +//go:noescape +func Y__sync_val_compare_and_swapInt8(t *TLS, ptr uintptr, oldval, newval int8) (r int8) + +//go:noescape +func Y__sync_val_compare_and_swapUint16(t *TLS, ptr uintptr, oldval, newval uint16) (r uint16) + +//go:noescape +func Y__sync_val_compare_and_swapUint32(t *TLS, ptr uintptr, oldval, newval uint32) (r uint32) + +//go:noescape +func Y__sync_val_compare_and_swapUint64(t *TLS, ptr uintptr, oldval, newval uint64) (r uint64) + +//go:noescape +func Y__sync_val_compare_and_swapUint8(t *TLS, ptr uintptr, oldval, newval uint8) (r uint8) + +//go:noescape +func Y__syscall0(tls *TLS, n long) (_2 long) + +//go:noescape +func Y__syscall1(tls *TLS, n, a1 long) (_2 long) + +//go:noescape +func Y__syscall2(tls *TLS, n, a1, a2 long) (_2 long) + +//go:noescape +func Y__syscall3(tls *TLS, n, a1, a2, a3 long) (_2 long) + +//go:noescape +func Y__syscall4(tls *TLS, n, a1, a2, a3, a4 long) (_2 long) + +//go:noescape +func Y__syscall5(tls *TLS, n, a1, a2, a3, a4, a5 long) (_2 long) + +//go:noescape +func Y__syscall6(tls *TLS, n, a1, a2, a3, a4, a5, a6 long) (_2 long) + +//go:noescape +func Y__syscall_ret(tls *TLS, r uint64) (r1 int64) + +//go:noescape +func Y__tan(tls *TLS, x float64, y float64, odd int32) (r1 float64) + +//go:noescape +func Y__tandf(tls *TLS, x float64, odd int32) (r1 float32) + +//go:noescape +func Y__tm_to_secs(tls *TLS, tm uintptr) (r int64) + +//go:noescape +func Y__tm_to_tzname(tls *TLS, tm uintptr) (r uintptr) + +//go:noescape +func Y__tolower_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__toread(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__toread_needs_stdio_exit(tls *TLS) + +//go:noescape +func Y__toupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Y__towctrans_l(tls *TLS, c Twint_t, t Twctrans_t, l Tlocale_t) (r Twint_t) + +//go:noescape +func Y__towlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) + +//go:noescape +func Y__towrite(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__towrite_needs_stdio_exit(tls *TLS) + +//go:noescape +func Y__towupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) + +//go:noescape +func Y__tre_mem_alloc_impl(tls *TLS, mem Ttre_mem_t, provided int32, provided_block uintptr, zero int32, size Tsize_t) (r uintptr) + +//go:noescape +func Y__tre_mem_destroy(tls *TLS, mem Ttre_mem_t) + +//go:noescape +func Y__tre_mem_new_impl(tls *TLS, provided int32, provided_block uintptr) (r Ttre_mem_t) + +//go:noescape +func Y__tsearch_balance(tls *TLS, p uintptr) (r int32) + +//go:noescape +func Y__uflow(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Y__unlist_locked_file(tls *TLS, f uintptr) + +//go:noescape +func Y__unlockfile(tls *TLS, file uintptr) + +//go:noescape +func Y__uselocale(tls *TLS, new1 Tlocale_t) (r Tlocale_t) + +//go:noescape +func Y__vm_wait(tls *TLS) + +//go:noescape +func Y__wcscoll_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) + +//go:noescape +func Y__wcsftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) + +//go:noescape +func Y__wcsxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) + +//go:noescape +func Y__wctrans_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctrans_t) + +//go:noescape +func Y__wctype_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctype_t) + +//go:noescape +func Y__xmknod(tls *TLS, ver int32, path uintptr, mode Tmode_t, dev uintptr) (r int32) + +//go:noescape +func Y__xmknodat(tls *TLS, ver int32, fd int32, path uintptr, mode Tmode_t, dev uintptr) (r int32) + +//go:noescape +func Y__xpg_basename(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Y__xpg_strerror_r(tls *TLS, err int32, buf uintptr, buflen Tsize_t) (r int32) + +//go:noescape +func Y__xstat(tls *TLS, ver int32, path uintptr, buf uintptr) (r int32) + +//go:noescape +func Y__year_to_secs(tls *TLS, year int64, is_leap uintptr) (r int64) + +//go:noescape +func Y_exit(tls *TLS, status int32) + +//go:noescape +func Y_flushlbf(tls *TLS) + +//go:noescape +func Y_longjmp(t *TLS, env uintptr, val int32) + +//go:noescape +func Y_obstack_begin(t *TLS, obstack uintptr, size, alignment int32, chunkfun, freefun uintptr) (_4 int32) + +//go:noescape +func Y_obstack_newchunk(t *TLS, obstack uintptr, length int32) (_3 int32) + +//go:noescape +func Y_pthread_cleanup_pop(tls *TLS, _ uintptr, run int32) + +//go:noescape +func Y_pthread_cleanup_push(tls *TLS, _, f, x uintptr) + +//go:noescape +func Y_setjmp(t *TLS, env uintptr) (_2 int32) + +//go:noescape +func Ya64l(tls *TLS, s uintptr) (r int64) + +//go:noescape +func Yabort(tls *TLS) + +//go:noescape +func Yabs(tls *TLS, a int32) (r int32) + +//go:noescape +func Yaccept(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) + +//go:noescape +func Yaccept4(tls *TLS, fd int32, addr uintptr, len1 uintptr, flg int32) (r1 int32) + +//go:noescape +func Yaccess(tls *TLS, filename uintptr, amode int32) (r int32) + +//go:noescape +func Yacct(tls *TLS, filename uintptr) (r int32) + +//go:noescape +func Yacos(tls *TLS, x float64) (r float64) + +//go:noescape +func Yacosf(tls *TLS, x float32) (r float32) + +//go:noescape +func Yacosh(tls *TLS, x float64) (r float64) + +//go:noescape +func Yacoshf(tls *TLS, x float32) (r float32) + +//go:noescape +func Yacoshl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yacosl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yaddmntent(tls *TLS, f uintptr, mnt uintptr) (r int32) + +//go:noescape +func Yadjtime(tls *TLS, in uintptr, out uintptr) (r int32) + +//go:noescape +func Yadjtimex(tls *TLS, tx uintptr) (r int32) + +//go:noescape +func Yalarm(tls *TLS, seconds uint32) (r uint32) + +//go:noescape +func Yalloca(tls *TLS, size Tsize_t) (_2 uintptr) + +//go:noescape +func Yalphasort(tls *TLS, a uintptr, b uintptr) (r int32) + +//go:noescape +func Yarch_prctl(tls *TLS, code int32, addr uint64) (r int32) + +//go:noescape +func Yasctime(tls *TLS, tm uintptr) (r uintptr) + +//go:noescape +func Yasctime_r(tls *TLS, tm uintptr, buf uintptr) (r uintptr) + +//go:noescape +func Yasin(tls *TLS, x float64) (r1 float64) + +//go:noescape +func Yasinf(tls *TLS, x float32) (r float32) + +//go:noescape +func Yasinh(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Yasinhf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Yasinhl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yasinl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yasprintf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Yat_quick_exit(tls *TLS, __ccgo_fp_func uintptr) (r1 int32) + +//go:noescape +func __ccgo_abi0_at_quick_exit_0(_0 *TLS, __ccgo_fp uintptr) + +func __ccgo_abiInternal_at_quick_exit_0(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS) { + __ccgo_abi0_at_quick_exit_0(_0, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Yatan(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Yatan2(tls *TLS, y float64, x float64) (r float64) + +//go:noescape +func Yatan2f(tls *TLS, y float32, x float32) (r float32) + +//go:noescape +func Yatan2l(tls *TLS, y float64, x float64) (r float64) + +//go:noescape +func Yatanf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Yatanh(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Yatanhf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Yatanhl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yatanl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yatexit(tls *TLS, func_ uintptr) (r int32) + +//go:noescape +func Yatof(tls *TLS, s uintptr) (r float64) + +//go:noescape +func Yatoi(tls *TLS, s uintptr) (r int32) + +//go:noescape +func Yatol(tls *TLS, s uintptr) (r int64) + +//go:noescape +func Yatoll(tls *TLS, s uintptr) (r int64) + +//go:noescape +func Ybacktrace(t *TLS, buf uintptr, size int32) (_3 int32) + +//go:noescape +func Ybacktrace_symbols_fd(t *TLS, buffer uintptr, size, fd int32) + +//go:noescape +func Ybasename(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Ybcmp(tls *TLS, s1 uintptr, s2 uintptr, n Tsize_t) (r int32) + +//go:noescape +func Ybcopy(tls *TLS, s1 uintptr, s2 uintptr, n Tsize_t) + +//go:noescape +func Ybind(tls *TLS, fd int32, addr uintptr, len1 Tsocklen_t) (r1 int32) + +//go:noescape +func Ybind_textdomain_codeset(tls *TLS, domainname uintptr, codeset uintptr) (r uintptr) + +//go:noescape +func Ybindtextdomain(tls *TLS, domainname uintptr, dirname uintptr) (r uintptr) + +//go:noescape +func Ybrk(tls *TLS, end uintptr) (r int32) + +//go:noescape +func Ybsearch(tls *TLS, key uintptr, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp uintptr) (r uintptr) + +//go:noescape +func __ccgo_abi0_bsearch_4(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_bsearch_4(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0_bsearch_4(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Ybtowc(tls *TLS, c int32) (r Twint_t) + +//go:noescape +func Ybzero(tls *TLS, s uintptr, n Tsize_t) + +//go:noescape +func Yc16rtomb(tls *TLS, s uintptr, c16 Tchar16_t, ps uintptr) (r Tsize_t) + +//go:noescape +func Yc32rtomb(tls *TLS, s uintptr, c32 Tchar32_t, ps uintptr) (r Tsize_t) + +//go:noescape +func Ycabs(tls *TLS, z complex128) (r float64) + +//go:noescape +func Ycabsf(tls *TLS, z complex64) (r float32) + +//go:noescape +func Ycabsl(tls *TLS, z complex128) (r float64) + +//go:noescape +func Ycacos(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycacosf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycacosh(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycacoshf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycacoshl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycacosl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycalloc(tls *TLS, m Tsize_t, n Tsize_t) (r uintptr) + +//go:noescape +func Ycapget(tls *TLS, a uintptr, b uintptr) (r int32) + +//go:noescape +func Ycapset(tls *TLS, a uintptr, b uintptr) (r int32) + +//go:noescape +func Ycarg(tls *TLS, z complex128) (r float64) + +//go:noescape +func Ycargf(tls *TLS, z complex64) (r float32) + +//go:noescape +func Ycargl(tls *TLS, z complex128) (r float64) + +//go:noescape +func Ycasin(tls *TLS, z complex128) (r1 complex128) + +//go:noescape +func Ycasinf(tls *TLS, z complex64) (r1 complex64) + +//go:noescape +func Ycasinh(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycasinhf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycasinhl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycasinl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycatan(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycatanf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycatanh(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycatanhf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycatanhl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycatanl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycatclose(tls *TLS, catd Tnl_catd) (r int32) + +//go:noescape +func Ycatgets(tls *TLS, catd Tnl_catd, set_id int32, msg_id int32, s uintptr) (r uintptr) + +//go:noescape +func Ycatopen(tls *TLS, name uintptr, oflag int32) (r Tnl_catd) + +//go:noescape +func Ycbrt(tls *TLS, x float64) (r1 float64) + +//go:noescape +func Ycbrtf(tls *TLS, x float32) (r1 float32) + +//go:noescape +func Ycbrtl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yccos(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yccosf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Yccosh(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yccoshf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Yccoshl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yccosl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yceil(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Yceilf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Yceill(tls *TLS, x float64) (r float64) + +//go:noescape +func Ycexp(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycexpf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycexpl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycfgetispeed(tls *TLS, tio uintptr) (r Tspeed_t) + +//go:noescape +func Ycfgetospeed(tls *TLS, tio uintptr) (r Tspeed_t) + +//go:noescape +func Ycfmakeraw(tls *TLS, t uintptr) + +//go:noescape +func Ycfsetispeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) + +//go:noescape +func Ycfsetospeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) + +//go:noescape +func Ycfsetspeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) + +//go:noescape +func Ychdir(tls *TLS, path uintptr) (r int32) + +//go:noescape +func Ychmod(tls *TLS, path uintptr, mode Tmode_t) (r int32) + +//go:noescape +func Ychown(tls *TLS, path uintptr, uid Tuid_t, gid Tgid_t) (r int32) + +//go:noescape +func Ychroot(tls *TLS, path uintptr) (r int32) + +//go:noescape +func Ycimag(tls *TLS, z complex128) (r float64) + +//go:noescape +func Ycimagf(tls *TLS, z complex64) (r float32) + +//go:noescape +func Ycimagl(tls *TLS, z complex128) (r float64) + +//go:noescape +func Yclearenv(tls *TLS) (r int32) + +//go:noescape +func Yclearerr(tls *TLS, f uintptr) + +//go:noescape +func Yclearerr_unlocked(tls *TLS, f uintptr) + +//go:noescape +func Yclock(tls *TLS) (r Tclock_t) + +//go:noescape +func Yclock_adjtime(tls *TLS, clock_id Tclockid_t, utx uintptr) (r1 int32) + +//go:noescape +func Yclock_getcpuclockid(tls *TLS, pid Tpid_t, clk uintptr) (r int32) + +//go:noescape +func Yclock_getres(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) + +//go:noescape +func Yclock_gettime(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) + +//go:noescape +func Yclock_nanosleep(tls *TLS, clk Tclockid_t, flags int32, req uintptr, rem uintptr) (r int32) + +//go:noescape +func Yclock_settime(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) + +//go:noescape +func Yclog(tls *TLS, z complex128) (r1 complex128) + +//go:noescape +func Yclogf(tls *TLS, z complex64) (r1 complex64) + +//go:noescape +func Yclogl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yclose(tls *TLS, fd int32) (r1 int32) + +//go:noescape +func Yclosedir(tls *TLS, dir uintptr) (r int32) + +//go:noescape +func Ycloselog(tls *TLS) + +//go:noescape +func Yconfstr(tls *TLS, name int32, buf uintptr, len1 Tsize_t) (r Tsize_t) + +//go:noescape +func Yconj(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yconjf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Yconjl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yconnect(tls *TLS, fd int32, addr uintptr, len1 Tsocklen_t) (r1 int32) + +//go:noescape +func Ycopy_file_range(tls *TLS, fd_in int32, off_in uintptr, fd_out int32, off_out uintptr, len1 Tsize_t, flags uint32) (r Tssize_t) + +//go:noescape +func Ycopysign(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Ycopysignf(tls *TLS, x float32, y float32) (r float32) + +//go:noescape +func Ycopysignl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Ycos(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Ycosf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Ycosh(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Ycoshf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Ycoshl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ycosl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ycpow(tls *TLS, z complex128, c complex128) (r complex128) + +//go:noescape +func Ycpowf(tls *TLS, z complex64, c complex64) (r complex64) + +//go:noescape +func Ycpowl(tls *TLS, z complex128, c complex128) (r complex128) + +//go:noescape +func Ycproj(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycprojf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycprojl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycreal(tls *TLS, z complex128) (r float64) + +//go:noescape +func Ycrealf(tls *TLS, z complex64) (r float32) + +//go:noescape +func Ycreall(tls *TLS, z complex128) (r float64) + +//go:noescape +func Ycreat(tls *TLS, filename uintptr, mode Tmode_t) (r int32) + +//go:noescape +func Ycrypt(tls *TLS, key uintptr, salt uintptr) (r uintptr) + +//go:noescape +func Ycrypt_r(tls *TLS, key uintptr, salt uintptr, data uintptr) (r uintptr) + +//go:noescape +func Ycsin(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycsinf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycsinh(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycsinhf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycsinhl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycsinl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycsqrt(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Ycsqrtf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Ycsqrtl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yctan(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yctanf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Yctanh(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yctanhf(tls *TLS, z complex64) (r complex64) + +//go:noescape +func Yctanhl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yctanl(tls *TLS, z complex128) (r complex128) + +//go:noescape +func Yctermid(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Yctime(tls *TLS, t uintptr) (r uintptr) + +//go:noescape +func Yctime_r(tls *TLS, t uintptr, buf uintptr) (r uintptr) + +//go:noescape +func Ycuserid(tls *TLS, buf uintptr) (r uintptr) + +//go:noescape +func Ydcgettext(tls *TLS, domainname uintptr, msgid uintptr, category int32) (r uintptr) + +//go:noescape +func Ydcngettext(tls *TLS, domainname uintptr, msgid1 uintptr, msgid2 uintptr, n uint64, category int32) (r1 uintptr) + +//go:noescape +func Ydelete_module(tls *TLS, a uintptr, b uint32) (r int32) + +//go:noescape +func Ydgettext(tls *TLS, domainname uintptr, msgid uintptr) (r uintptr) + +//go:noescape +func Ydifftime(tls *TLS, t1 Ttime_t, t0 Ttime_t) (r float64) + +//go:noescape +func Ydirfd(tls *TLS, d uintptr) (r int32) + +//go:noescape +func Ydirname(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Ydiv(tls *TLS, num int32, den int32) (r Tdiv_t) + +//go:noescape +func Ydlclose(t *TLS, handle uintptr) (_2 int32) + +//go:noescape +func Ydlerror(t *TLS) (_1 uintptr) + +//go:noescape +func Ydlopen(t *TLS, filename uintptr, flags int32) (_3 uintptr) + +//go:noescape +func Ydlsym(t *TLS, handle, symbol uintptr) (_2 uintptr) + +//go:noescape +func Ydn_comp(tls *TLS, src uintptr, dst uintptr, space int32, dnptrs uintptr, lastdnptr uintptr) (r int32) + +//go:noescape +func Ydn_expand(tls *TLS, base uintptr, end uintptr, src uintptr, dest uintptr, space int32) (r int32) + +//go:noescape +func Ydn_skipname(tls *TLS, s uintptr, end uintptr) (r int32) + +//go:noescape +func Ydngettext(tls *TLS, domainname uintptr, msgid1 uintptr, msgid2 uintptr, n uint64) (r uintptr) + +//go:noescape +func Ydprintf(tls *TLS, fd int32, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Ydrand48(tls *TLS) (r float64) + +//go:noescape +func Ydrem(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Ydremf(tls *TLS, x float32, y float32) (r float32) + +//go:noescape +func Ydup(tls *TLS, fd int32) (r int32) + +//go:noescape +func Ydup2(tls *TLS, old int32, new1 int32) (r1 int32) + +//go:noescape +func Ydup3(tls *TLS, old int32, new1 int32, flags int32) (r int32) + +//go:noescape +func Yduplocale(tls *TLS, old Tlocale_t) (r Tlocale_t) + +//go:noescape +func Yeaccess(tls *TLS, filename uintptr, amode int32) (r int32) + +//go:noescape +func Yecvt(tls *TLS, x float64, n int32, dp uintptr, sign uintptr) (r uintptr) + +//go:noescape +func Yencrypt(tls *TLS, block uintptr, edflag int32) + +//go:noescape +func Yendgrent(tls *TLS) + +//go:noescape +func Yendhostent(tls *TLS) + +//go:noescape +func Yendmntent(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yendnetent(tls *TLS) + +//go:noescape +func Yendprotoent(tls *TLS) + +//go:noescape +func Yendpwent(tls *TLS) + +//go:noescape +func Yendservent(tls *TLS) + +//go:noescape +func Yendspent(tls *TLS) + +//go:noescape +func Yendusershell(tls *TLS) + +//go:noescape +func Yendutent(tls *TLS) + +//go:noescape +func Yendutxent(tls *TLS) + +//go:noescape +func Yepoll_create(tls *TLS, size int32) (r int32) + +//go:noescape +func Yepoll_create1(tls *TLS, flags int32) (r1 int32) + +//go:noescape +func Yepoll_ctl(tls *TLS, fd int32, op int32, fd2 int32, ev uintptr) (r int32) + +//go:noescape +func Yepoll_pwait(tls *TLS, fd int32, ev uintptr, cnt int32, to int32, sigs uintptr) (r1 int32) + +//go:noescape +func Yepoll_wait(tls *TLS, fd int32, ev uintptr, cnt int32, to int32) (r int32) + +//go:noescape +func Yerand48(tls *TLS, s uintptr) (r float64) + +//go:noescape +func Yerf(tls *TLS, x float64) (r1 float64) + +//go:noescape +func Yerfc(tls *TLS, x float64) (r1 float64) + +//go:noescape +func Yerfcf(tls *TLS, x float32) (r1 float32) + +//go:noescape +func Yerfcl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yerff(tls *TLS, x float32) (r1 float32) + +//go:noescape +func Yerfl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yerr(tls *TLS, status int32, fmt uintptr, va uintptr) + +//go:noescape +func Yerrx(tls *TLS, status int32, fmt uintptr, va uintptr) + +//go:noescape +func Yether_aton(tls *TLS, x uintptr) (r uintptr) + +//go:noescape +func Yether_aton_r(tls *TLS, x uintptr, p_a uintptr) (r uintptr) + +//go:noescape +func Yether_hostton(tls *TLS, hostname uintptr, e uintptr) (r int32) + +//go:noescape +func Yether_line(tls *TLS, l uintptr, e uintptr, hostname uintptr) (r int32) + +//go:noescape +func Yether_ntoa(tls *TLS, p_a uintptr) (r uintptr) + +//go:noescape +func Yether_ntoa_r(tls *TLS, p_a uintptr, x uintptr) (r uintptr) + +//go:noescape +func Yether_ntohost(tls *TLS, hostname uintptr, e uintptr) (r int32) + +//go:noescape +func Yeuidaccess(tls *TLS, filename uintptr, amode int32) (r int32) + +//go:noescape +func Yeventfd(tls *TLS, count uint32, flags int32) (r1 int32) + +//go:noescape +func Yeventfd_read(tls *TLS, fd int32, value uintptr) (r int32) + +//go:noescape +func Yeventfd_write(tls *TLS, fd int32, _value Teventfd_t) (r int32) + +//go:noescape +func Yexecl(tls *TLS, path uintptr, argv0 uintptr, va uintptr) (r int32) + +//go:noescape +func Yexecle(tls *TLS, path uintptr, argv0 uintptr, va uintptr) (r int32) + +//go:noescape +func Yexeclp(tls *TLS, file uintptr, argv0 uintptr, va uintptr) (r int32) + +//go:noescape +func Yexecv(tls *TLS, path uintptr, argv uintptr) (r int32) + +//go:noescape +func Yexecve(tls *TLS, path uintptr, argv uintptr, envp uintptr) (r int32) + +//go:noescape +func Yexecvp(tls *TLS, file uintptr, argv uintptr) (r int32) + +//go:noescape +func Yexecvpe(tls *TLS, file uintptr, argv uintptr, envp uintptr) (r int32) + +//go:noescape +func Yexit(tls *TLS, code int32) + +//go:noescape +func Yexp(tls *TLS, x1 float64) (r1 float64) + +//go:noescape +func Yexp10(tls *TLS, x float64) (r float64) + +//go:noescape +func Yexp10f(tls *TLS, x float32) (r float32) + +//go:noescape +func Yexp10l(tls *TLS, x float64) (r float64) + +//go:noescape +func Yexp2(tls *TLS, x1 float64) (r1 float64) + +//go:noescape +func Yexp2f(tls *TLS, x2 float32) (r1 float32) + +//go:noescape +func Yexp2l(tls *TLS, x float64) (r float64) + +//go:noescape +func Yexpf(tls *TLS, x2 float32) (r1 float32) + +//go:noescape +func Yexpl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yexplicit_bzero(tls *TLS, d uintptr, n Tsize_t) + +//go:noescape +func Yexpm1(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Yexpm1f(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Yexpm1l(tls *TLS, x float64) (r float64) + +//go:noescape +func Yfabs(tls *TLS, x float64) (r float64) + +//go:noescape +func Yfabsf(tls *TLS, x float32) (r float32) + +//go:noescape +func Yfabsl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yfaccessat(tls *TLS, fd int32, filename uintptr, amode int32, flag int32) (r int32) + +//go:noescape +func Yfallocate(tls *TLS, fd int32, mode int32, base Toff_t, len1 Toff_t) (r int32) + +//go:noescape +func Yfanotify_init(tls *TLS, flags uint32, event_f_flags uint32) (r int32) + +//go:noescape +func Yfanotify_mark(tls *TLS, fanotify_fd int32, flags uint32, mask uint64, dfd int32, pathname uintptr) (r int32) + +//go:noescape +func Yfchdir(tls *TLS, fd int32) (r int32) + +//go:noescape +func Yfchmod(tls *TLS, fd int32, mode Tmode_t) (r int32) + +//go:noescape +func Yfchmodat(tls *TLS, fd int32, path uintptr, mode Tmode_t, flag int32) (r int32) + +//go:noescape +func Yfchown(tls *TLS, fd int32, uid Tuid_t, gid Tgid_t) (r int32) + +//go:noescape +func Yfchownat(tls *TLS, fd int32, path uintptr, uid Tuid_t, gid Tgid_t, flag int32) (r int32) + +//go:noescape +func Yfclose(tls *TLS, f uintptr) (r1 int32) + +//go:noescape +func Yfcntl(tls *TLS, fd int32, cmd int32, va uintptr) (r int32) + +//go:noescape +func Yfcntl64(tls *TLS, fd int32, cmd int32, va uintptr) (r int32) + +//go:noescape +func Yfcvt(tls *TLS, x float64, n int32, dp uintptr, sign uintptr) (r uintptr) + +//go:noescape +func Yfdatasync(tls *TLS, fd int32) (r int32) + +//go:noescape +func Yfdim(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yfdimf(tls *TLS, x float32, y float32) (r float32) + +//go:noescape +func Yfdiml(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yfdopen(tls *TLS, fd int32, mode uintptr) (r uintptr) + +//go:noescape +func Yfdopendir(tls *TLS, fd int32) (r uintptr) + +//go:noescape +func Yfeclearexcept(tls *TLS, mask int32) (r int32) + +//go:noescape +func Yfegetenv(tls *TLS, envp uintptr) (r int32) + +//go:noescape +func Yfegetround(tls *TLS) (r int32) + +//go:noescape +func Yfeof(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yfeof_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yferaiseexcept(tls *TLS, mask int32) (r int32) + +//go:noescape +func Yferror(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yferror_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yfesetenv(tls *TLS, envp uintptr) (r int32) + +//go:noescape +func Yfetestexcept(tls *TLS, mask int32) (r int32) + +//go:noescape +func Yfexecve(tls *TLS, fd int32, argv uintptr, envp uintptr) (r1 int32) + +//go:noescape +func Yfflush(tls *TLS, f uintptr) (r1 int32) + +//go:noescape +func Yfflush_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yffs(tls *TLS, i int32) (r int32) + +//go:noescape +func Yffsl(tls *TLS, i int64) (r int32) + +//go:noescape +func Yffsll(tls *TLS, i int64) (r int32) + +//go:noescape +func Yfgetc(tls *TLS, f1 uintptr) (r int32) + +//go:noescape +func Yfgetc_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yfgetgrent(tls *TLS, f uintptr) (r uintptr) + +//go:noescape +func Yfgetln(tls *TLS, f uintptr, plen uintptr) (r uintptr) + +//go:noescape +func Yfgetpos(tls *TLS, f uintptr, pos uintptr) (r int32) + +//go:noescape +func Yfgetpwent(tls *TLS, f uintptr) (r uintptr) + +//go:noescape +func Yfgets(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) + +//go:noescape +func Yfgets_unlocked(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) + +//go:noescape +func Yfgetwc(tls *TLS, f uintptr) (r Twint_t) + +//go:noescape +func Yfgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) + +//go:noescape +func Yfgetws(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) + +//go:noescape +func Yfgetws_unlocked(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) + +//go:noescape +func Yfgetxattr(tls *TLS, filedes int32, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) + +//go:noescape +func Yfileno(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yfileno_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yfinite(tls *TLS, x float64) (r int32) + +//go:noescape +func Yfinitef(tls *TLS, x float32) (r int32) + +//go:noescape +func Yflistxattr(tls *TLS, filedes int32, list uintptr, size Tsize_t) (r Tssize_t) + +//go:noescape +func Yflock(tls *TLS, fd int32, op int32) (r int32) + +//go:noescape +func Yflockfile(tls *TLS, f uintptr) + +//go:noescape +func Yfloor(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Yfloorf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Yfloorl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yfma(tls *TLS, x1 float64, y float64, z float64) (r1 float64) + +//go:noescape +func Yfmal(tls *TLS, x float64, y float64, z float64) (r float64) + +//go:noescape +func Yfmax(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yfmaxf(tls *TLS, x float32, y float32) (r float32) + +//go:noescape +func Yfmaxl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yfmemopen(tls *TLS, buf uintptr, size Tsize_t, mode uintptr) (r uintptr) + +//go:noescape +func Yfmin(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yfminf(tls *TLS, x float32, y float32) (r float32) + +//go:noescape +func Yfminl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yfmod(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yfmodf(tls *TLS, x float32, y float32) (r float32) + +//go:noescape +func Yfmodl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yfmtmsg(tls *TLS, classification int64, label uintptr, severity int32, text uintptr, action uintptr, tag uintptr) (r int32) + +//go:noescape +func Yfnmatch(tls *TLS, pat uintptr, str uintptr, flags int32) (r int32) + +//go:noescape +func Yfopen(tls *TLS, filename uintptr, mode uintptr) (r uintptr) + +//go:noescape +func Yfopen64(tls *TLS, filename uintptr, mode uintptr) (r uintptr) + +//go:noescape +func Yfopencookie(tls *TLS, cookie uintptr, mode uintptr, iofuncs Tcookie_io_functions_t) (r uintptr) + +//go:noescape +func Yfork(t *TLS) (_1 int32) + +//go:noescape +func Yfpathconf(tls *TLS, fd int32, name int32) (r int64) + +//go:noescape +func Yfprintf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Yfpurge(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yfputc(tls *TLS, c1 int32, f1 uintptr) (r int32) + +//go:noescape +func Yfputc_unlocked(tls *TLS, c int32, f uintptr) (r int32) + +//go:noescape +func Yfputs(tls *TLS, s uintptr, f uintptr) (r int32) + +//go:noescape +func Yfputs_unlocked(tls *TLS, s uintptr, f uintptr) (r int32) + +//go:noescape +func Yfputwc(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) + +//go:noescape +func Yfputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) + +//go:noescape +func Yfputws(tls *TLS, _ws uintptr, f uintptr) (r int32) + +//go:noescape +func Yfputws_unlocked(tls *TLS, _ws uintptr, f uintptr) (r int32) + +//go:noescape +func Yfread(tls *TLS, destv uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) + +//go:noescape +func Yfread_unlocked(tls *TLS, destv uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) + +//go:noescape +func Yfree(tls *TLS, p uintptr) + +//go:noescape +func Yfreeaddrinfo(tls *TLS, p uintptr) + +//go:noescape +func Yfreeifaddrs(tls *TLS, ifp uintptr) + +//go:noescape +func Yfreelocale(tls *TLS, l Tlocale_t) + +//go:noescape +func Yfremovexattr(tls *TLS, fd int32, name uintptr) (r int32) + +//go:noescape +func Yfreopen(tls *TLS, filename uintptr, mode uintptr, f uintptr) (r uintptr) + +//go:noescape +func Yfrexp(tls *TLS, x float64, e uintptr) (r float64) + +//go:noescape +func Yfrexpf(tls *TLS, x float32, e uintptr) (r float32) + +//go:noescape +func Yfrexpl(tls *TLS, x float64, e uintptr) (r float64) + +//go:noescape +func Yfscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Yfseek(tls *TLS, f uintptr, off int64, whence int32) (r int32) + +//go:noescape +func Yfseeko(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) + +//go:noescape +func Yfsetpos(tls *TLS, f uintptr, pos uintptr) (r int32) + +//go:noescape +func Yfsetxattr(tls *TLS, filedes int32, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) + +//go:noescape +func Yfstat(tls *TLS, fd int32, st uintptr) (r int32) + +//go:noescape +func Yfstat64(tls *TLS, fd int32, st uintptr) (r int32) + +//go:noescape +func Yfstatat(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) + +//go:noescape +func Yfstatfs(tls *TLS, fd int32, buf uintptr) (r int32) + +//go:noescape +func Yfstatvfs(tls *TLS, fd int32, buf uintptr) (r int32) + +//go:noescape +func Yfsync(tls *TLS, fd int32) (r int32) + +//go:noescape +func Yftell(tls *TLS, f uintptr) (r int64) + +//go:noescape +func Yftello(tls *TLS, f uintptr) (r Toff_t) + +//go:noescape +func Yftime(tls *TLS, tp uintptr) (r int32) + +//go:noescape +func Yftok(tls *TLS, path uintptr, id int32) (r Tkey_t) + +//go:noescape +func Yftruncate(tls *TLS, fd int32, length Toff_t) (r int32) + +//go:noescape +func Yftruncate64(tls *TLS, fd int32, length Toff_t) (r int32) + +//go:noescape +func Yftrylockfile(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Yfts64_close(t *TLS, ftsp uintptr) (_2 int32) + +//go:noescape +func Yfts64_open(t *TLS, path_argv uintptr, options int32, compar uintptr) (_4 uintptr) + +//go:noescape +func Yfts64_read(t *TLS, ftsp uintptr) (_2 uintptr) + +//go:noescape +func Yfts_close(t *TLS, ftsp uintptr) (_2 int32) + +//go:noescape +func Yfts_open(t *TLS, path_argv uintptr, options int32, compar uintptr) (_4 uintptr) + +//go:noescape +func Yfts_read(t *TLS, ftsp uintptr) (_2 uintptr) + +//go:noescape +func Yftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32) (r int32) + +//go:noescape +func __ccgo_abi0_ftw_1(_0 *TLS, _1 uintptr, _2 uintptr, _3 int32, __ccgo_fp uintptr) (_4 int32) + +func __ccgo_abiInternal_ftw_1(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr, _3 int32) (_4 int32) { + return __ccgo_abi0_ftw_1(_0, _1, _2, _3, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Yfunlockfile(tls *TLS, f uintptr) + +//go:noescape +func Yfutimens(tls *TLS, fd int32, times uintptr) (r int32) + +//go:noescape +func Yfutimes(tls *TLS, fd int32, tv uintptr) (r int32) + +//go:noescape +func Yfutimesat(tls *TLS, dirfd int32, pathname uintptr, times uintptr) (r int32) + +//go:noescape +func Yfwide(tls *TLS, f uintptr, mode int32) (r int32) + +//go:noescape +func Yfwprintf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Yfwrite(tls *TLS, src uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) + +//go:noescape +func Yfwrite_unlocked(tls *TLS, src uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) + +//go:noescape +func Yfwscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Ygai_strerror(tls *TLS, ecode int32) (r uintptr) + +//go:noescape +func Ygcvt(tls *TLS, x float64, n int32, b uintptr) (r uintptr) + +//go:noescape +func Yget_avphys_pages(tls *TLS) (r int64) + +//go:noescape +func Yget_current_dir_name(tls *TLS) (r uintptr) + +//go:noescape +func Yget_nprocs(tls *TLS) (r int32) + +//go:noescape +func Yget_nprocs_conf(tls *TLS) (r int32) + +//go:noescape +func Yget_phys_pages(tls *TLS) (r int64) + +//go:noescape +func Ygetaddrinfo(tls *TLS, host uintptr, serv uintptr, hint uintptr, res uintptr) (r1 int32) + +//go:noescape +func Ygetauxval(tls *TLS, item uint64) (r uint64) + +//go:noescape +func Ygetc(tls *TLS, f1 uintptr) (r int32) + +//go:noescape +func Ygetc_unlocked(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Ygetchar(tls *TLS) (r int32) + +//go:noescape +func Ygetchar_unlocked(tls *TLS) (r int32) + +//go:noescape +func Ygetcwd(tls *TLS, buf uintptr, size Tsize_t) (r uintptr) + +//go:noescape +func Ygetdate(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Ygetdelim(tls *TLS, s uintptr, n uintptr, delim int32, f uintptr) (r Tssize_t) + +//go:noescape +func Ygetdents(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Ygetdomainname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Ygetdtablesize(tls *TLS) (r int32) + +//go:noescape +func Ygetegid(tls *TLS) (r Tgid_t) + +//go:noescape +func Ygetentropy(tls *TLS, buffer uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Ygetenv(tls *TLS, name uintptr) (r uintptr) + +//go:noescape +func Ygeteuid(tls *TLS) (r Tuid_t) + +//go:noescape +func Ygetgid(tls *TLS) (r Tgid_t) + +//go:noescape +func Ygetgrent(tls *TLS) (r uintptr) + +//go:noescape +func Ygetgrgid(tls *TLS, gid Tgid_t) (r uintptr) + +//go:noescape +func Ygetgrgid_r(tls *TLS, gid Tgid_t, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) + +//go:noescape +func Ygetgrnam(tls *TLS, name uintptr) (r uintptr) + +//go:noescape +func Ygetgrnam_r(tls *TLS, name uintptr, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) + +//go:noescape +func Ygetgrouplist(tls *TLS, user uintptr, gid Tgid_t, groups uintptr, ngroups uintptr) (r int32) + +//go:noescape +func Ygetgroups(tls *TLS, count int32, list uintptr) (r int32) + +//go:noescape +func Ygethostbyaddr(tls *TLS, a uintptr, l Tsocklen_t, af int32) (r uintptr) + +//go:noescape +func Ygethostbyaddr_r(tls *TLS, a uintptr, l Tsocklen_t, af int32, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) + +//go:noescape +func Ygethostbyname(tls *TLS, name uintptr) (r uintptr) + +//go:noescape +func Ygethostbyname2(tls *TLS, name uintptr, af int32) (r uintptr) + +//go:noescape +func Ygethostbyname2_r(tls *TLS, name uintptr, af int32, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) + +//go:noescape +func Ygethostbyname_r(tls *TLS, name uintptr, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) + +//go:noescape +func Ygethostent(tls *TLS) (r uintptr) + +//go:noescape +func Ygethostid(tls *TLS) (r int64) + +//go:noescape +func Ygethostname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Ygetifaddrs(tls *TLS, ifap uintptr) (r1 int32) + +//go:noescape +func Ygetitimer(tls *TLS, which int32, old uintptr) (r1 int32) + +//go:noescape +func Ygetline(tls *TLS, s uintptr, n uintptr, f uintptr) (r Tssize_t) + +//go:noescape +func Ygetloadavg(tls *TLS, a uintptr, n int32) (r int32) + +//go:noescape +func Ygetlogin(tls *TLS) (r uintptr) + +//go:noescape +func Ygetlogin_r(tls *TLS, name uintptr, size Tsize_t) (r int32) + +//go:noescape +func Ygetmntent(tls *TLS, f uintptr) (r uintptr) + +//go:noescape +func Ygetmntent_r(tls *TLS, f uintptr, mnt uintptr, linebuf uintptr, buflen int32) (r uintptr) + +//go:noescape +func Ygetnameinfo(tls *TLS, sa uintptr, sl Tsocklen_t, node uintptr, nodelen Tsocklen_t, serv uintptr, servlen Tsocklen_t, flags int32) (r int32) + +//go:noescape +func Ygetnetbyaddr(tls *TLS, net Tuint32_t, type1 int32) (r uintptr) + +//go:noescape +func Ygetnetbyname(tls *TLS, name uintptr) (r uintptr) + +//go:noescape +func Ygetnetent(tls *TLS) (r uintptr) + +//go:noescape +func Ygetopt(tls *TLS, argc int32, argv uintptr, optstring uintptr) (r int32) + +//go:noescape +func Ygetopt_long(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr) (r int32) + +//go:noescape +func Ygetopt_long_only(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr) (r int32) + +//go:noescape +func Ygetpagesize(tls *TLS) (r int32) + +//go:noescape +func Ygetpass(tls *TLS, prompt uintptr) (r uintptr) + +//go:noescape +func Ygetpeername(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) + +//go:noescape +func Ygetpgid(tls *TLS, pid Tpid_t) (r Tpid_t) + +//go:noescape +func Ygetpgrp(tls *TLS) (r Tpid_t) + +//go:noescape +func Ygetpid(tls *TLS) (r Tpid_t) + +//go:noescape +func Ygetppid(tls *TLS) (r Tpid_t) + +//go:noescape +func Ygetpriority(tls *TLS, which int32, who Tid_t) (r int32) + +//go:noescape +func Ygetprotobyname(tls *TLS, name uintptr) (r uintptr) + +//go:noescape +func Ygetprotobynumber(tls *TLS, num int32) (r uintptr) + +//go:noescape +func Ygetprotoent(tls *TLS) (r uintptr) + +//go:noescape +func Ygetpwent(tls *TLS) (r uintptr) + +//go:noescape +func Ygetpwnam(tls *TLS, name uintptr) (r uintptr) + +//go:noescape +func Ygetpwnam_r(tls *TLS, name uintptr, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) + +//go:noescape +func Ygetpwuid(tls *TLS, uid Tuid_t) (r uintptr) + +//go:noescape +func Ygetpwuid_r(tls *TLS, uid Tuid_t, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) + +//go:noescape +func Ygetrandom(tls *TLS, buf uintptr, buflen Tsize_t, flags uint32) (r Tssize_t) + +//go:noescape +func Ygetresgid(tls *TLS, rgid uintptr, egid uintptr, sgid uintptr) (r int32) + +//go:noescape +func Ygetresuid(tls *TLS, ruid uintptr, euid uintptr, suid uintptr) (r int32) + +//go:noescape +func Ygetrlimit(tls *TLS, resource int32, rlim uintptr) (r int32) + +//go:noescape +func Ygetrlimit64(tls *TLS, resource int32, rlim uintptr) (r int32) + +//go:noescape +func Ygetrusage(tls *TLS, who int32, ru uintptr) (r1 int32) + +//go:noescape +func Ygets(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Ygetservbyname(tls *TLS, name uintptr, prots uintptr) (r uintptr) + +//go:noescape +func Ygetservbyname_r(tls *TLS, name uintptr, prots uintptr, se uintptr, buf uintptr, buflen Tsize_t, res uintptr) (r int32) + +//go:noescape +func Ygetservent(tls *TLS) (r uintptr) + +//go:noescape +func Ygetsid(tls *TLS, pid Tpid_t) (r Tpid_t) + +//go:noescape +func Ygetsockname(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) + +//go:noescape +func Ygetsockopt(tls *TLS, fd int32, level int32, optname int32, optval uintptr, optlen uintptr) (r2 int32) + +//go:noescape +func Ygetspent(tls *TLS) (r uintptr) + +//go:noescape +func Ygetsubopt(tls *TLS, opt uintptr, keys uintptr, val uintptr) (r int32) + +//go:noescape +func Ygettext(tls *TLS, msgid uintptr) (r uintptr) + +//go:noescape +func Ygettimeofday(tls *TLS, tv uintptr, tz uintptr) (r int32) + +//go:noescape +func Ygetuid(tls *TLS) (r Tuid_t) + +//go:noescape +func Ygetusershell(tls *TLS) (r uintptr) + +//go:noescape +func Ygetutent(tls *TLS) (r uintptr) + +//go:noescape +func Ygetutid(tls *TLS, ut uintptr) (r uintptr) + +//go:noescape +func Ygetutline(tls *TLS, ut uintptr) (r uintptr) + +//go:noescape +func Ygetutxent(tls *TLS) (r uintptr) + +//go:noescape +func Ygetutxid(tls *TLS, ut uintptr) (r uintptr) + +//go:noescape +func Ygetutxline(tls *TLS, ut uintptr) (r uintptr) + +//go:noescape +func Ygetw(tls *TLS, f uintptr) (r int32) + +//go:noescape +func Ygetwc(tls *TLS, f uintptr) (r Twint_t) + +//go:noescape +func Ygetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) + +//go:noescape +func Ygetwchar(tls *TLS) (r Twint_t) + +//go:noescape +func Ygetwchar_unlocked(tls *TLS) (r Twint_t) + +//go:noescape +func Ygetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) + +//go:noescape +func Yglob(tls *TLS, pat uintptr, flags int32, __ccgo_fp_errfunc uintptr, g_ uintptr) (r int32) + +//go:noescape +func __ccgo_abi0_glob_2(_0 *TLS, _1 uintptr, _2 int32, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_glob_2(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 int32) (_3 int32) { + return __ccgo_abi0_glob_2(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Yglobfree(tls *TLS, g_ uintptr) + +//go:noescape +func Ygmtime(tls *TLS, t uintptr) (r uintptr) + +//go:noescape +func Ygmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) + +//go:noescape +func Ygrantpt(tls *TLS, fd int32) (r int32) + +//go:noescape +func Yhasmntopt(tls *TLS, mnt uintptr, opt uintptr) (r uintptr) + +//go:noescape +func Yhcreate(tls *TLS, nel Tsize_t) (r int32) + +//go:noescape +func Yhdestroy(tls *TLS) + +//go:noescape +func Yherror(tls *TLS, msg uintptr) + +//go:noescape +func Yhsearch(tls *TLS, item TENTRY, action TACTION) (r uintptr) + +//go:noescape +func Yhstrerror(tls *TLS, ecode int32) (r uintptr) + +//go:noescape +func Yhtonl(tls *TLS, n Tuint32_t) (r Tuint32_t) + +//go:noescape +func Yhtons(tls *TLS, n Tuint16_t) (r Tuint16_t) + +//go:noescape +func Yhypot(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yhypotf(tls *TLS, x float32, y float32) (r float32) + +//go:noescape +func Yhypotl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yiconv(tls *TLS, cd Ticonv_t, in uintptr, inb uintptr, out uintptr, outb uintptr) (r Tsize_t) + +//go:noescape +func Yiconv_close(tls *TLS, cd Ticonv_t) (r int32) + +//go:noescape +func Yiconv_open(tls *TLS, to uintptr, from uintptr) (r Ticonv_t) + +//go:noescape +func Yif_freenameindex(tls *TLS, idx uintptr) + +//go:noescape +func Yif_indextoname(tls *TLS, index uint32, name uintptr) (r1 uintptr) + +//go:noescape +func Yif_nameindex(tls *TLS) (r uintptr) + +//go:noescape +func Yif_nametoindex(tls *TLS, name uintptr) (r1 uint32) + +//go:noescape +func Yilogb(tls *TLS, x3 float64) (r int32) + +//go:noescape +func Yilogbf(tls *TLS, x3 float32) (r int32) + +//go:noescape +func Yilogbl(tls *TLS, x float64) (r int32) + +//go:noescape +func Yimaxabs(tls *TLS, a Tintmax_t) (r Tintmax_t) + +//go:noescape +func Yimaxdiv(tls *TLS, num Tintmax_t, den Tintmax_t) (r Timaxdiv_t) + +//go:noescape +func Yindex(tls *TLS, s uintptr, c int32) (r uintptr) + +//go:noescape +func Yinet_addr(tls *TLS, p uintptr) (r Tin_addr_t) + +//go:noescape +func Yinet_aton(tls *TLS, s0 uintptr, dest uintptr) (r int32) + +//go:noescape +func Yinet_lnaof(tls *TLS, in Tin_addr) (r Tin_addr_t) + +//go:noescape +func Yinet_makeaddr(tls *TLS, n Tin_addr_t, h Tin_addr_t) (r Tin_addr) + +//go:noescape +func Yinet_netof(tls *TLS, in Tin_addr) (r Tin_addr_t) + +//go:noescape +func Yinet_network(tls *TLS, p uintptr) (r Tin_addr_t) + +//go:noescape +func Yinet_ntoa(tls *TLS, _in Tin_addr) (r uintptr) + +//go:noescape +func Yinet_ntop(tls *TLS, af int32, a0 uintptr, s uintptr, l Tsocklen_t) (r uintptr) + +//go:noescape +func Yinet_pton(tls *TLS, af int32, s uintptr, a0 uintptr) (r int32) + +//go:noescape +func Yinit_module(tls *TLS, a uintptr, b uint64, c uintptr) (r int32) + +//go:noescape +func Yinitstate(tls *TLS, seed uint32, state uintptr, size Tsize_t) (r uintptr) + +//go:noescape +func Yinitstate_r(t *TLS, seed uint32, statebuf uintptr, statelen Tsize_t, buf uintptr) (_5 int32) + +//go:noescape +func Yinotify_add_watch(tls *TLS, fd int32, pathname uintptr, mask Tuint32_t) (r int32) + +//go:noescape +func Yinotify_init(tls *TLS) (r int32) + +//go:noescape +func Yinotify_init1(tls *TLS, flags int32) (r1 int32) + +//go:noescape +func Yinotify_rm_watch(tls *TLS, fd int32, wd int32) (r int32) + +//go:noescape +func Yinsque(tls *TLS, element uintptr, pred uintptr) + +//go:noescape +func Yioctl(tls *TLS, fd int32, req int32, va uintptr) (r1 int32) + +//go:noescape +func Yioperm(tls *TLS, from uint64, num uint64, turn_on int32) (r int32) + +//go:noescape +func Yiopl(tls *TLS, level int32) (r int32) + +//go:noescape +func Yisalnum(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisalnum_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yisalpha(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisalpha_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yisascii(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisastream(tls *TLS, fd int32) (r int32) + +//go:noescape +func Yisatty(tls *TLS, fd int32) (r1 int32) + +//go:noescape +func Yisblank(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisblank_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yiscntrl(tls *TLS, c int32) (r int32) + +//go:noescape +func Yiscntrl_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yisdigit(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yisgraph(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisgraph_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yislower(tls *TLS, c int32) (r int32) + +//go:noescape +func Yislower_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yisnan(t *TLS, x float64) (_2 int32) + +//go:noescape +func Yisnanf(t *TLS, arg float32) (_2 int32) + +//go:noescape +func Yisnanl(t *TLS, arg float64) (_2 int32) + +//go:noescape +func Yisprint(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisprint_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yispunct(tls *TLS, c int32) (r int32) + +//go:noescape +func Yispunct_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yissetugid(tls *TLS) (r int32) + +//go:noescape +func Yisspace(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisspace_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yisupper(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yiswalnum(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswalnum_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswalpha(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswalpha_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswblank(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswblank_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswcntrl(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswcntrl_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswctype(tls *TLS, wc Twint_t, type1 Twctype_t) (r int32) + +//go:noescape +func Yiswctype_l(tls *TLS, c Twint_t, t Twctype_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswdigit(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswgraph(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswgraph_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswlower(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswprint(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswprint_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswpunct(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswpunct_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswspace(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswspace_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswupper(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yiswxdigit(tls *TLS, wc Twint_t) (r int32) + +//go:noescape +func Yiswxdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) + +//go:noescape +func Yisxdigit(tls *TLS, c int32) (r int32) + +//go:noescape +func Yisxdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Yj0(tls *TLS, x float64) (r1 float64) + +//go:noescape +func Yj0f(tls *TLS, x float32) (r1 float32) + +//go:noescape +func Yj1(tls *TLS, x float64) (r1 float64) + +//go:noescape +func Yj1f(tls *TLS, x float32) (r1 float32) + +//go:noescape +func Yjn(tls *TLS, n int32, x float64) (r float64) + +//go:noescape +func Yjnf(tls *TLS, n int32, x float32) (r float32) + +//go:noescape +func Yjrand48(tls *TLS, s uintptr) (r int64) + +//go:noescape +func Ykill(tls *TLS, pid Tpid_t, sig int32) (r int32) + +//go:noescape +func Ykillpg(tls *TLS, pgid Tpid_t, sig int32) (r int32) + +//go:noescape +func Yklogctl(tls *TLS, type1 int32, buf uintptr, len1 int32) (r int32) + +//go:noescape +func Yl64a(tls *TLS, x0 int64) (r uintptr) + +//go:noescape +func Ylabs(tls *TLS, a int64) (r int64) + +//go:noescape +func Ylchmod(tls *TLS, path uintptr, mode Tmode_t) (r int32) + +//go:noescape +func Ylchown(tls *TLS, path uintptr, uid Tuid_t, gid Tgid_t) (r int32) + +//go:noescape +func Ylckpwdf(tls *TLS) (r int32) + +//go:noescape +func Ylcong48(tls *TLS, p uintptr) + +//go:noescape +func Yldexp(tls *TLS, x float64, n int32) (r float64) + +//go:noescape +func Yldexpf(tls *TLS, x float32, n int32) (r float32) + +//go:noescape +func Yldexpl(tls *TLS, x float64, n int32) (r float64) + +//go:noescape +func Yldiv(tls *TLS, num int64, den int64) (r Tldiv_t) + +//go:noescape +func Ylfind(tls *TLS, key uintptr, base uintptr, nelp uintptr, width Tsize_t, __ccgo_fp_compar uintptr) (r uintptr) + +//go:noescape +func __ccgo_abi0_lfind_4(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_lfind_4(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0_lfind_4(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Ylgamma(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylgamma_r(tls *TLS, x float64, signgamp uintptr) (r float64) + +//go:noescape +func Ylgammaf(tls *TLS, x float32) (r float32) + +//go:noescape +func Ylgammaf_r(tls *TLS, x float32, signgamp uintptr) (r float32) + +//go:noescape +func Ylgammal(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylgammal_r(tls *TLS, x float64, sg uintptr) (r float64) + +//go:noescape +func Ylgetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) + +//go:noescape +func Ylink(tls *TLS, existing uintptr, new1 uintptr) (r int32) + +//go:noescape +func Ylinkat(tls *TLS, fd1 int32, existing uintptr, fd2 int32, new1 uintptr, flag int32) (r int32) + +//go:noescape +func Ylisten(tls *TLS, fd int32, backlog int32) (r1 int32) + +//go:noescape +func Ylistxattr(tls *TLS, path uintptr, list uintptr, size Tsize_t) (r Tssize_t) + +//go:noescape +func Yllabs(tls *TLS, a int64) (r int64) + +//go:noescape +func Ylldiv(tls *TLS, num int64, den int64) (r Tlldiv_t) + +//go:noescape +func Yllistxattr(tls *TLS, path uintptr, list uintptr, size Tsize_t) (r Tssize_t) + +//go:noescape +func Yllrint(tls *TLS, x float64) (r int64) + +//go:noescape +func Yllrintf(tls *TLS, x float32) (r int64) + +//go:noescape +func Yllrintl(tls *TLS, x float64) (r int64) + +//go:noescape +func Yllround(tls *TLS, x float64) (r int64) + +//go:noescape +func Yllroundf(tls *TLS, x float32) (r int64) + +//go:noescape +func Yllroundl(tls *TLS, x float64) (r int64) + +//go:noescape +func Ylocaleconv(tls *TLS) (r uintptr) + +//go:noescape +func Ylocaltime(tls *TLS, t uintptr) (r uintptr) + +//go:noescape +func Ylocaltime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) + +//go:noescape +func Ylockf(tls *TLS, fd int32, op int32, size Toff_t) (r int32) + +//go:noescape +func Ylog(tls *TLS, x1 float64) (r1 float64) + +//go:noescape +func Ylog10(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylog10f(tls *TLS, x float32) (r float32) + +//go:noescape +func Ylog10l(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylog1p(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Ylog1pf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Ylog1pl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylog2(tls *TLS, x1 float64) (r1 float64) + +//go:noescape +func Ylog2f(tls *TLS, x1 float32) (r1 float32) + +//go:noescape +func Ylog2l(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylogb(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylogbf(tls *TLS, x float32) (r float32) + +//go:noescape +func Ylogbl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylogf(tls *TLS, x1 float32) (r1 float32) + +//go:noescape +func Ylogin_tty(tls *TLS, fd int32) (r int32) + +//go:noescape +func Ylogl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ylongjmp(t *TLS, env uintptr, val int32) + +//go:noescape +func Ylrand48(tls *TLS) (r int64) + +//go:noescape +func Ylremovexattr(tls *TLS, path uintptr, name uintptr) (r int32) + +//go:noescape +func Ylrint(tls *TLS, x float64) (r int64) + +//go:noescape +func Ylrintf(tls *TLS, x float32) (r int64) + +//go:noescape +func Ylrintl(tls *TLS, x float64) (r int64) + +//go:noescape +func Ylround(tls *TLS, x float64) (r int64) + +//go:noescape +func Ylroundf(tls *TLS, x float32) (r int64) + +//go:noescape +func Ylroundl(tls *TLS, x float64) (r int64) + +//go:noescape +func Ylsearch(tls *TLS, key uintptr, base uintptr, nelp uintptr, width Tsize_t, __ccgo_fp_compar uintptr) (r uintptr) + +//go:noescape +func __ccgo_abi0_lsearch_4(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_lsearch_4(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0_lsearch_4(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Ylseek(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) + +//go:noescape +func Ylseek64(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) + +//go:noescape +func Ylsetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) + +//go:noescape +func Ylstat(tls *TLS, path uintptr, buf uintptr) (r int32) + +//go:noescape +func Ylstat64(tls *TLS, path uintptr, buf uintptr) (r int32) + +//go:noescape +func Ylutimes(tls *TLS, filename uintptr, tv uintptr) (r int32) + +//go:noescape +func Ymadvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) + +//go:noescape +func Ymalloc(tls *TLS, n Tsize_t) (r uintptr) + +//go:noescape +func Ymalloc_usable_size(tls *TLS, p uintptr) (r Tsize_t) + +//go:noescape +func Ymblen(tls *TLS, s uintptr, n Tsize_t) (r int32) + +//go:noescape +func Ymbrlen(tls *TLS, s uintptr, n Tsize_t, st uintptr) (r Tsize_t) + +//go:noescape +func Ymbrtoc16(tls *TLS, pc16 uintptr, s uintptr, n Tsize_t, ps uintptr) (r Tsize_t) + +//go:noescape +func Ymbrtoc32(tls *TLS, pc32 uintptr, s uintptr, n Tsize_t, ps uintptr) (r Tsize_t) + +//go:noescape +func Ymbrtowc(tls *TLS, wc uintptr, src uintptr, n Tsize_t, st uintptr) (r Tsize_t) + +//go:noescape +func Ymbsinit(tls *TLS, st uintptr) (r int32) + +//go:noescape +func Ymbsnrtowcs(tls *TLS, wcs uintptr, src uintptr, n Tsize_t, wn Tsize_t, st uintptr) (r Tsize_t) + +//go:noescape +func Ymbsrtowcs(tls *TLS, ws uintptr, src uintptr, wn Tsize_t, st uintptr) (r Tsize_t) + +//go:noescape +func Ymbstowcs(tls *TLS, ws uintptr, _s uintptr, wn Tsize_t) (r Tsize_t) + +//go:noescape +func Ymbtowc(tls *TLS, wc uintptr, src uintptr, n Tsize_t) (r int32) + +//go:noescape +func Ymemccpy(tls *TLS, dest uintptr, src uintptr, c int32, n Tsize_t) (r uintptr) + +//go:noescape +func Ymemchr(tls *TLS, src uintptr, c int32, n Tsize_t) (r uintptr) + +//go:noescape +func Ymemcmp(tls *TLS, vl uintptr, vr uintptr, n Tsize_t) (r1 int32) + +//go:noescape +func Ymemcpy(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ymemfd_create(tls *TLS, name uintptr, flags uint32) (r int32) + +//go:noescape +func Ymemmem(tls *TLS, h0 uintptr, k Tsize_t, n0 uintptr, l Tsize_t) (r uintptr) + +//go:noescape +func Ymemmove(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ymempcpy(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ymemrchr(tls *TLS, m uintptr, c int32, n Tsize_t) (r uintptr) + +//go:noescape +func Ymemset(tls *TLS, dest uintptr, c int32, n Tsize_t) (r uintptr) + +//go:noescape +func Ymincore(tls *TLS, addr uintptr, len1 Tsize_t, vec uintptr) (r int32) + +//go:noescape +func Ymkdir(tls *TLS, path uintptr, mode Tmode_t) (r int32) + +//go:noescape +func Ymkdirat(tls *TLS, fd int32, path uintptr, mode Tmode_t) (r int32) + +//go:noescape +func Ymkdtemp(tls *TLS, template uintptr) (r uintptr) + +//go:noescape +func Ymkfifo(tls *TLS, path uintptr, mode Tmode_t) (r int32) + +//go:noescape +func Ymkfifoat(tls *TLS, fd int32, path uintptr, mode Tmode_t) (r int32) + +//go:noescape +func Ymknod(tls *TLS, path uintptr, mode Tmode_t, dev Tdev_t) (r int32) + +//go:noescape +func Ymknodat(tls *TLS, fd int32, path uintptr, mode Tmode_t, dev Tdev_t) (r int32) + +//go:noescape +func Ymkostemp(tls *TLS, template uintptr, flags int32) (r int32) + +//go:noescape +func Ymkostemps(tls *TLS, template uintptr, len1 int32, flags int32) (r int32) + +//go:noescape +func Ymkstemp(tls *TLS, template uintptr) (r int32) + +//go:noescape +func Ymkstemp64(tls *TLS, template uintptr) (r int32) + +//go:noescape +func Ymkstemps(tls *TLS, template uintptr, len1 int32) (r int32) + +//go:noescape +func Ymkstemps64(tls *TLS, template uintptr, len1 int32) (r int32) + +//go:noescape +func Ymktemp(tls *TLS, template uintptr) (r uintptr) + +//go:noescape +func Ymktime(tls *TLS, tm uintptr) (r Ttime_t) + +//go:noescape +func Ymlock(tls *TLS, addr uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Ymlock2(tls *TLS, addr uintptr, len1 Tsize_t, flags uint32) (r int32) + +//go:noescape +func Ymlockall(tls *TLS, flags int32) (r int32) + +//go:noescape +func Ymmap(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) + +//go:noescape +func Ymmap64(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) + +//go:noescape +func Ymodf(tls *TLS, x float64, iptr uintptr) (r float64) + +//go:noescape +func Ymodff(tls *TLS, x float32, iptr uintptr) (r float32) + +//go:noescape +func Ymodfl(tls *TLS, x float64, iptr uintptr) (r1 float64) + +//go:noescape +func Ymount(tls *TLS, special uintptr, dir uintptr, fstype uintptr, flags uint64, data uintptr) (r int32) + +//go:noescape +func Ymprotect(tls *TLS, addr uintptr, len1 Tsize_t, prot int32) (r int32) + +//go:noescape +func Ymrand48(tls *TLS) (r int64) + +//go:noescape +func Ymremap(tls *TLS, old_addr uintptr, old_len Tsize_t, new_len Tsize_t, flags int32, va uintptr) (r uintptr) + +//go:noescape +func Ymsgctl(tls *TLS, q int32, cmd int32, buf uintptr) (r1 int32) + +//go:noescape +func Ymsgget(tls *TLS, k Tkey_t, flag int32) (r int32) + +//go:noescape +func Ymsgrcv(tls *TLS, q int32, m uintptr, len1 Tsize_t, type1 int64, flag int32) (r Tssize_t) + +//go:noescape +func Ymsgsnd(tls *TLS, q int32, m uintptr, len1 Tsize_t, flag int32) (r int32) + +//go:noescape +func Ymsync(tls *TLS, start uintptr, len1 Tsize_t, flags int32) (r int32) + +//go:noescape +func Ymunlock(tls *TLS, addr uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Ymunlockall(tls *TLS) (r int32) + +//go:noescape +func Ymunmap(tls *TLS, start uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Yname_to_handle_at(tls *TLS, dirfd int32, pathname uintptr, handle uintptr, mount_id uintptr, flags int32) (r int32) + +//go:noescape +func Ynan(tls *TLS, s uintptr) (r float64) + +//go:noescape +func Ynanf(tls *TLS, s uintptr) (r float32) + +//go:noescape +func Ynanl(tls *TLS, s uintptr) (r float64) + +//go:noescape +func Ynanosleep(tls *TLS, req uintptr, rem uintptr) (r int32) + +//go:noescape +func Ynewlocale(tls *TLS, mask int32, name uintptr, loc Tlocale_t) (r Tlocale_t) + +//go:noescape +func Ynextafter(tls *TLS, x3 float64, y3 float64) (r float64) + +//go:noescape +func Ynextafterf(tls *TLS, x3 float32, y3 float32) (r float32) + +//go:noescape +func Ynextafterl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Ynexttoward(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Ynexttowardf(tls *TLS, x3 float32, y3 float64) (r float32) + +//go:noescape +func Ynexttowardl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Ynftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32, flags int32) (r1 int32) + +//go:noescape +func __ccgo_abi0_nftw_1(_0 *TLS, _1 uintptr, _2 uintptr, _3 int32, _4 uintptr, __ccgo_fp uintptr) (_5 int32) + +func __ccgo_abiInternal_nftw_1(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr, _3 int32, _4 uintptr) (_5 int32) { + return __ccgo_abi0_nftw_1(_0, _1, _2, _3, _4, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Yngettext(tls *TLS, msgid1 uintptr, msgid2 uintptr, n uint64) (r uintptr) + +//go:noescape +func Ynice(tls *TLS, inc int32) (r int32) + +//go:noescape +func Ynl_langinfo(tls *TLS, item Tnl_item) (r uintptr) + +//go:noescape +func Ynl_langinfo_l(tls *TLS, item Tnl_item, loc Tlocale_t) (r uintptr) + +//go:noescape +func Ynrand48(tls *TLS, s uintptr) (r int64) + +//go:noescape +func Yns_get16(tls *TLS, cp uintptr) (r uint32) + +//go:noescape +func Yns_get32(tls *TLS, cp uintptr) (r uint64) + +//go:noescape +func Yns_initparse(tls *TLS, msg uintptr, msglen int32, handle uintptr) (r1 int32) + +//go:noescape +func Yns_name_uncompress(tls *TLS, msg uintptr, eom uintptr, src uintptr, dst uintptr, dstsiz Tsize_t) (r1 int32) + +//go:noescape +func Yns_parserr(tls *TLS, handle uintptr, section Tns_sect, rrnum int32, rr uintptr) (r1 int32) + +//go:noescape +func Yns_put16(tls *TLS, s uint32, cp uintptr) + +//go:noescape +func Yns_put32(tls *TLS, l uint64, cp uintptr) + +//go:noescape +func Yns_skiprr(tls *TLS, ptr uintptr, eom uintptr, section Tns_sect, count int32) (r1 int32) + +//go:noescape +func Yntohl(tls *TLS, n Tuint32_t) (r Tuint32_t) + +//go:noescape +func Yntohs(tls *TLS, n Tuint16_t) (r Tuint16_t) + +//go:noescape +func Yobstack_free(t *TLS, obstack, obj uintptr) + +//go:noescape +func Yobstack_vprintf(t *TLS, obstack, template, va uintptr) (_2 int32) + +//go:noescape +func Yopen(tls *TLS, filename uintptr, flags int32, va uintptr) (r int32) + +//go:noescape +func Yopen64(tls *TLS, filename uintptr, flags int32, va uintptr) (r int32) + +//go:noescape +func Yopen_by_handle_at(tls *TLS, mount_fd int32, handle uintptr, flags int32) (r int32) + +//go:noescape +func Yopen_memstream(tls *TLS, bufp uintptr, sizep uintptr) (r uintptr) + +//go:noescape +func Yopen_wmemstream(tls *TLS, bufp uintptr, sizep uintptr) (r uintptr) + +//go:noescape +func Yopenat(tls *TLS, fd int32, filename uintptr, flags int32, va uintptr) (r int32) + +//go:noescape +func Yopendir(tls *TLS, name uintptr) (r uintptr) + +//go:noescape +func Yopenlog(tls *TLS, ident uintptr, opt int32, facility int32) + +//go:noescape +func Yopenpty(tls *TLS, pm uintptr, ps uintptr, name uintptr, tio uintptr, ws uintptr) (r int32) + +//go:noescape +func Ypathconf(tls *TLS, path uintptr, name int32) (r int64) + +//go:noescape +func Ypause(tls *TLS) (r int32) + +//go:noescape +func Ypclose(tls *TLS, f uintptr) (r1 int32) + +//go:noescape +func Yperror(tls *TLS, msg uintptr) + +//go:noescape +func Ypersonality(tls *TLS, persona uint64) (r int32) + +//go:noescape +func Ypipe(tls *TLS, fd uintptr) (r int32) + +//go:noescape +func Ypipe2(tls *TLS, fd uintptr, flag int32) (r int32) + +//go:noescape +func Ypivot_root(tls *TLS, new1 uintptr, old uintptr) (r int32) + +//go:noescape +func Ypoll(tls *TLS, fds uintptr, n Tnfds_t, timeout int32) (r int32) + +//go:noescape +func Ypopen(t *TLS, command, type1 uintptr) (_2 uintptr) + +//go:noescape +func Yposix_close(tls *TLS, fd int32, flags int32) (r int32) + +//go:noescape +func Yposix_fadvise(tls *TLS, fd int32, base Toff_t, len1 Toff_t, advice int32) (r int32) + +//go:noescape +func Yposix_fallocate(tls *TLS, fd int32, base Toff_t, len1 Toff_t) (r int32) + +//go:noescape +func Yposix_madvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) + +//go:noescape +func Yposix_openpt(tls *TLS, flags int32) (r1 int32) + +//go:noescape +func Yposix_spawn_file_actions_addchdir_np(tls *TLS, fa uintptr, path uintptr) (r int32) + +//go:noescape +func Yposix_spawn_file_actions_addclose(tls *TLS, fa uintptr, fd int32) (r int32) + +//go:noescape +func Yposix_spawn_file_actions_adddup2(tls *TLS, fa uintptr, srcfd int32, fd int32) (r int32) + +//go:noescape +func Yposix_spawn_file_actions_addfchdir_np(tls *TLS, fa uintptr, fd int32) (r int32) + +//go:noescape +func Yposix_spawn_file_actions_addopen(tls *TLS, fa uintptr, fd int32, path uintptr, flags int32, mode Tmode_t) (r int32) + +//go:noescape +func Yposix_spawn_file_actions_destroy(tls *TLS, fa uintptr) (r int32) + +//go:noescape +func Yposix_spawn_file_actions_init(tls *TLS, fa uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_destroy(tls *TLS, attr uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_getflags(tls *TLS, attr uintptr, flags uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_getpgroup(tls *TLS, attr uintptr, pgrp uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_getschedparam(tls *TLS, attr uintptr, schedparam uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_getschedpolicy(tls *TLS, attr uintptr, policy uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_getsigdefault(tls *TLS, attr uintptr, def uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_getsigmask(tls *TLS, attr uintptr, mask uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_init(tls *TLS, attr uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_setflags(tls *TLS, attr uintptr, flags int16) (r int32) + +//go:noescape +func Yposix_spawnattr_setpgroup(tls *TLS, attr uintptr, pgrp Tpid_t) (r int32) + +//go:noescape +func Yposix_spawnattr_setschedparam(tls *TLS, attr uintptr, schedparam uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_setschedpolicy(tls *TLS, attr uintptr, policy int32) (r int32) + +//go:noescape +func Yposix_spawnattr_setsigdefault(tls *TLS, attr uintptr, def uintptr) (r int32) + +//go:noescape +func Yposix_spawnattr_setsigmask(tls *TLS, attr uintptr, mask uintptr) (r int32) + +//go:noescape +func Ypow(tls *TLS, x1 float64, y1 float64) (r float64) + +//go:noescape +func Ypow10(tls *TLS, x float64) (r float64) + +//go:noescape +func Ypow10f(tls *TLS, x float32) (r float32) + +//go:noescape +func Ypow10l(tls *TLS, x float64) (r float64) + +//go:noescape +func Ypowf(tls *TLS, x1 float32, y1 float32) (r float32) + +//go:noescape +func Ypowl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yppoll(tls *TLS, fds uintptr, n Tnfds_t, to uintptr, mask uintptr) (r int32) + +//go:noescape +func Yprctl(tls *TLS, op int32, va uintptr) (r int32) + +//go:noescape +func Ypread(tls *TLS, fd int32, buf uintptr, size Tsize_t, ofs Toff_t) (r Tssize_t) + +//go:noescape +func Ypreadv(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t) (r Tssize_t) + +//go:noescape +func Ypreadv2(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t, flags int32) (r Tssize_t) + +//go:noescape +func Yprintf(tls *TLS, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Yprlimit(tls *TLS, pid Tpid_t, resource int32, new_limit uintptr, old_limit uintptr) (r1 int32) + +//go:noescape +func Yprocess_vm_readv(tls *TLS, pid Tpid_t, lvec uintptr, liovcnt uint64, rvec uintptr, riovcnt uint64, flags uint64) (r Tssize_t) + +//go:noescape +func Yprocess_vm_writev(tls *TLS, pid Tpid_t, lvec uintptr, liovcnt uint64, rvec uintptr, riovcnt uint64, flags uint64) (r Tssize_t) + +//go:noescape +func Ypselect(tls *TLS, n int32, rfds uintptr, wfds uintptr, efds uintptr, ts uintptr, mask uintptr) (r int32) + +//go:noescape +func Ypsiginfo(tls *TLS, si uintptr, msg uintptr) + +//go:noescape +func Ypsignal(tls *TLS, sig int32, msg uintptr) + +//go:noescape +func Ypthread_atfork(tls *TLS, prepare, parent, child uintptr) (_2 int32) + +//go:noescape +func Ypthread_attr_destroy(tls *TLS, a uintptr) (_2 int32) + +//go:noescape +func Ypthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) (_3 int32) + +//go:noescape +func Ypthread_attr_init(tls *TLS, a uintptr) (_2 int32) + +//go:noescape +func Ypthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) (r int32) + +//go:noescape +func Ypthread_attr_setscope(tls *TLS, a uintptr, scope int32) (_3 int32) + +//go:noescape +func Ypthread_attr_setstacksize(tls *TLS, a uintptr, stacksite Tsize_t) (_3 int32) + +//go:noescape +func Ypthread_cleanup_pop(tls *TLS, run int32) + +//go:noescape +func Ypthread_cleanup_push(tls *TLS, f, x uintptr) + +//go:noescape +func Ypthread_cond_broadcast(tls *TLS, c uintptr) (_2 int32) + +//go:noescape +func Ypthread_cond_destroy(tls *TLS, c uintptr) (_2 int32) + +//go:noescape +func Ypthread_cond_init(tls *TLS, c, a uintptr) (_2 int32) + +//go:noescape +func Ypthread_cond_signal(tls *TLS, c uintptr) (_2 int32) + +//go:noescape +func Ypthread_cond_timedwait(tls *TLS, c, m, ts uintptr) (r int32) + +//go:noescape +func Ypthread_cond_wait(tls *TLS, c, m uintptr) (_2 int32) + +//go:noescape +func Ypthread_create(tls *TLS, res, attrp, entry, arg uintptr) (_2 int32) + +//go:noescape +func Ypthread_detach(tls *TLS, t uintptr) (_2 int32) + +//go:noescape +func Ypthread_equal(tls *TLS, t, u uintptr) (_2 int32) + +//go:noescape +func Ypthread_exit(tls *TLS, result uintptr) + +//go:noescape +func Ypthread_getspecific(tls *TLS, k Tpthread_key_t) (_2 uintptr) + +//go:noescape +func Ypthread_join(tls *TLS, t Tpthread_t, res uintptr) (r int32) + +//go:noescape +func Ypthread_key_create(tls *TLS, k uintptr, dtor uintptr) (_3 int32) + +//go:noescape +func Ypthread_key_delete(tls *TLS, k Tpthread_key_t) (_2 int32) + +//go:noescape +func Ypthread_mutex_destroy(tls *TLS, m uintptr) (_2 int32) + +//go:noescape +func Ypthread_mutex_init(tls *TLS, m, a uintptr) (_2 int32) + +//go:noescape +func Ypthread_mutex_lock(tls *TLS, m uintptr) (_2 int32) + +//go:noescape +func Ypthread_mutex_trylock(tls *TLS, m uintptr) (_2 int32) + +//go:noescape +func Ypthread_mutex_unlock(tls *TLS, m uintptr) (_2 int32) + +//go:noescape +func Ypthread_mutexattr_destroy(tls *TLS, a uintptr) (_2 int32) + +//go:noescape +func Ypthread_mutexattr_init(tls *TLS, a uintptr) (_2 int32) + +//go:noescape +func Ypthread_mutexattr_settype(tls *TLS, a uintptr, typ int32) (_3 int32) + +//go:noescape +func Ypthread_self(tls *TLS) (_1 uintptr) + +//go:noescape +func Ypthread_setcancelstate(tls *TLS, new int32, old uintptr) (_3 int32) + +//go:noescape +func Ypthread_setspecific(tls *TLS, k Tpthread_key_t, x uintptr) (_3 int32) + +//go:noescape +func Ypthread_sigmask(tls *TLS, now int32, set, old uintptr) (_3 int32) + +//go:noescape +func Yptrace(tls *TLS, req int32, va uintptr) (r int64) + +//go:noescape +func Yptsname(tls *TLS, fd int32) (r uintptr) + +//go:noescape +func Yptsname_r(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Yputc(tls *TLS, c1 int32, f1 uintptr) (r int32) + +//go:noescape +func Yputc_unlocked(tls *TLS, c int32, f uintptr) (r int32) + +//go:noescape +func Yputchar(tls *TLS, c1 int32) (r int32) + +//go:noescape +func Yputchar_unlocked(tls *TLS, c int32) (r int32) + +//go:noescape +func Yputenv(tls *TLS, s uintptr) (r int32) + +//go:noescape +func Yputgrent(tls *TLS, gr uintptr, f uintptr) (r1 int32) + +//go:noescape +func Yputpwent(tls *TLS, pw uintptr, f uintptr) (r int32) + +//go:noescape +func Yputs(tls *TLS, s uintptr) (r1 int32) + +//go:noescape +func Yputspent(tls *TLS, sp uintptr, f uintptr) (r int32) + +//go:noescape +func Ypututline(tls *TLS, ut uintptr) (r uintptr) + +//go:noescape +func Ypututxline(tls *TLS, ut uintptr) (r uintptr) + +//go:noescape +func Yputw(tls *TLS, _x int32, f uintptr) (r int32) + +//go:noescape +func Yputwc(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) + +//go:noescape +func Yputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) + +//go:noescape +func Yputwchar(tls *TLS, c Twchar_t) (r Twint_t) + +//go:noescape +func Yputwchar_unlocked(tls *TLS, c Twchar_t) (r Twint_t) + +//go:noescape +func Ypwrite(tls *TLS, fd int32, buf uintptr, size Tsize_t, ofs Toff_t) (r Tssize_t) + +//go:noescape +func Ypwritev(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t) (r Tssize_t) + +//go:noescape +func Ypwritev2(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t, flags int32) (r Tssize_t) + +//go:noescape +func Yqsort(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun) + +//go:noescape +func __ccgo_abi0_qsort_3(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_qsort_3(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0_qsort_3(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Yqsort_r(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr) + +//go:noescape +func __ccgo_abi0_qsort_r_3(_0 *TLS, _1 uintptr, _2 uintptr, _3 uintptr, __ccgo_fp uintptr) (_4 int32) + +func __ccgo_abiInternal_qsort_r_3(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr, _3 uintptr) (_4 int32) { + return __ccgo_abi0_qsort_r_3(_0, _1, _2, _3, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Yquick_exit(tls *TLS, code int32) + +//go:noescape +func Yquotactl(tls *TLS, cmd int32, special uintptr, id int32, addr uintptr) (r int32) + +//go:noescape +func Yraise(tls *TLS, sig int32) (r int32) + +//go:noescape +func Yrand(tls *TLS) (r int32) + +//go:noescape +func Yrand_r(tls *TLS, seed uintptr) (r int32) + +//go:noescape +func Yrandom(tls *TLS) (r int64) + +//go:noescape +func Yrandom_r(t *TLS, buf, result uintptr) (_2 int32) + +//go:noescape +func Yread(tls *TLS, fd int32, buf uintptr, count Tsize_t) (r Tssize_t) + +//go:noescape +func Yreadahead(tls *TLS, fd int32, pos Toff_t, len1 Tsize_t) (r Tssize_t) + +//go:noescape +func Yreaddir(tls *TLS, dir uintptr) (r uintptr) + +//go:noescape +func Yreaddir64(tls *TLS, dir uintptr) (r uintptr) + +//go:noescape +func Yreaddir_r(tls *TLS, dir uintptr, buf uintptr, result uintptr) (r int32) + +//go:noescape +func Yreadlink(tls *TLS, path uintptr, buf uintptr, bufsize Tsize_t) (r1 Tssize_t) + +//go:noescape +func Yreadlinkat(tls *TLS, fd int32, path uintptr, buf uintptr, bufsize Tsize_t) (r1 Tssize_t) + +//go:noescape +func Yreadv(tls *TLS, fd int32, iov uintptr, count int32) (r Tssize_t) + +//go:noescape +func Yrealloc(tls *TLS, p uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Yreallocarray(tls *TLS, ptr uintptr, m Tsize_t, n Tsize_t) (r uintptr) + +//go:noescape +func Yrealpath(tls *TLS, filename uintptr, resolved uintptr) (r uintptr) + +//go:noescape +func Yreboot(tls *TLS, type1 int32) (r int32) + +//go:noescape +func Yrecv(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32) (r Tssize_t) + +//go:noescape +func Yrecvfrom(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32, addr uintptr, alen uintptr) (r1 Tssize_t) + +//go:noescape +func Yrecvmmsg(tls *TLS, fd int32, msgvec uintptr, vlen uint32, flags uint32, timeout uintptr) (r int32) + +//go:noescape +func Yrecvmsg(tls *TLS, fd int32, msg uintptr, flags int32) (r2 Tssize_t) + +//go:noescape +func Yregcomp(tls *TLS, preg uintptr, regex uintptr, cflags int32) (r int32) + +//go:noescape +func Yregerror(tls *TLS, e int32, preg uintptr, buf uintptr, size Tsize_t) (r Tsize_t) + +//go:noescape +func Yregexec(tls *TLS, preg uintptr, string1 uintptr, nmatch Tsize_t, pmatch uintptr, eflags int32) (r int32) + +//go:noescape +func Yregfree(tls *TLS, preg uintptr) + +//go:noescape +func Yremainder(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yremainderf(tls *TLS, x float32, y float32) (r float32) + +//go:noescape +func Yremainderl(tls *TLS, x float64, y float64) (r float64) + +//go:noescape +func Yremap_file_pages(tls *TLS, addr uintptr, size Tsize_t, prot int32, pgoff Tsize_t, flags int32) (r int32) + +//go:noescape +func Yremove(tls *TLS, path uintptr) (r1 int32) + +//go:noescape +func Yremovexattr(tls *TLS, path uintptr, name uintptr) (r int32) + +//go:noescape +func Yremque(tls *TLS, element uintptr) + +//go:noescape +func Yremquo(tls *TLS, x float64, y float64, quo uintptr) (r float64) + +//go:noescape +func Yremquof(tls *TLS, x float32, y float32, quo uintptr) (r float32) + +//go:noescape +func Yremquol(tls *TLS, x float64, y float64, quo uintptr) (r float64) + +//go:noescape +func Yrename(tls *TLS, old uintptr, new1 uintptr) (r int32) + +//go:noescape +func Yrenameat(tls *TLS, oldfd int32, old uintptr, newfd int32, new1 uintptr) (r int32) + +//go:noescape +func Yrenameat2(t *TLS, olddirfd int32, oldpath uintptr, newdirfd int32, newpath uintptr, flags int32) (_6 int32) + +//go:noescape +func Yres_init(tls *TLS) (r int32) + +//go:noescape +func Yres_mkquery(tls *TLS, op int32, dname uintptr, class int32, type1 int32, data uintptr, datalen int32, newrr uintptr, buf uintptr, buflen int32) (r int32) + +//go:noescape +func Yres_send(tls *TLS, _msg uintptr, _msglen int32, _answer uintptr, _anslen int32) (r int32) + +//go:noescape +func Yrewind(tls *TLS, f uintptr) + +//go:noescape +func Yrewinddir(tls *TLS, dir uintptr) + +//go:noescape +func Yrindex(tls *TLS, s uintptr, c int32) (r uintptr) + +//go:noescape +func Yrint(tls *TLS, x float64) (r float64) + +//go:noescape +func Yrintf(tls *TLS, x float32) (r float32) + +//go:noescape +func Yrintl(tls *TLS, x float64) (r float64) + +//go:noescape +func Yrmdir(tls *TLS, path uintptr) (r int32) + +//go:noescape +func Yround(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Yroundf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Yroundl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ysbrk(tls *TLS, inc Tintptr_t) (r uintptr) + +//go:noescape +func Yscalb(tls *TLS, x float64, fn float64) (r float64) + +//go:noescape +func Yscalbf(tls *TLS, x float32, fn float32) (r float32) + +//go:noescape +func Yscalbln(tls *TLS, x float64, n int64) (r float64) + +//go:noescape +func Yscalblnf(tls *TLS, x float32, n int64) (r float32) + +//go:noescape +func Yscalblnl(tls *TLS, x float64, n int64) (r float64) + +//go:noescape +func Yscalbn(tls *TLS, x float64, n int32) (r float64) + +//go:noescape +func Yscalbnf(tls *TLS, x float32, n int32) (r float32) + +//go:noescape +func Yscalbnl(tls *TLS, x float64, n int32) (r float64) + +//go:noescape +func Yscandir(tls *TLS, path uintptr, res uintptr, __ccgo_fp_sel uintptr, __ccgo_fp_cmp uintptr) (r int32) + +//go:noescape +func __ccgo_abi0_scandir_2(_0 *TLS, _1 uintptr, __ccgo_fp uintptr) (_2 int32) + +func __ccgo_abiInternal_scandir_2(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr) (_2 int32) { + return __ccgo_abi0_scandir_2(_0, _1, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func __ccgo_abi0_scandir_3(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_scandir_3(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0_scandir_3(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Yscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Ysched_yield(tls *TLS) (_1 int32) + +//go:noescape +func Ysecure_getenv(tls *TLS, name uintptr) (r uintptr) + +//go:noescape +func Yseed48(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Yseekdir(tls *TLS, dir uintptr, off int64) + +//go:noescape +func Yselect(tls *TLS, n int32, rfds uintptr, wfds uintptr, efds uintptr, tv uintptr) (r int32) + +//go:noescape +func Ysemctl(tls *TLS, id int32, num int32, cmd int32, va uintptr) (r1 int32) + +//go:noescape +func Ysemget(tls *TLS, key Tkey_t, n int32, fl int32) (r int32) + +//go:noescape +func Ysemop(tls *TLS, id int32, buf uintptr, n Tsize_t) (r int32) + +//go:noescape +func Ysemtimedop(tls *TLS, id int32, buf uintptr, n Tsize_t, ts uintptr) (r int32) + +//go:noescape +func Ysend(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32) (r Tssize_t) + +//go:noescape +func Ysendfile(tls *TLS, out_fd int32, in_fd int32, ofs uintptr, count Tsize_t) (r Tssize_t) + +//go:noescape +func Ysendmmsg(tls *TLS, fd int32, msgvec uintptr, vlen uint32, flags uint32) (r1 int32) + +//go:noescape +func Ysendmsg(tls *TLS, fd int32, msg uintptr, flags int32) (r1 Tssize_t) + +//go:noescape +func Ysendto(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32, addr uintptr, alen Tsocklen_t) (r1 Tssize_t) + +//go:noescape +func Ysetbuf(tls *TLS, f uintptr, buf uintptr) + +//go:noescape +func Ysetbuffer(tls *TLS, f uintptr, buf uintptr, size Tsize_t) + +//go:noescape +func Ysetdomainname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Ysetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) (r int32) + +//go:noescape +func Ysetfsgid(tls *TLS, gid Tgid_t) (r int32) + +//go:noescape +func Ysetfsuid(tls *TLS, uid Tuid_t) (r int32) + +//go:noescape +func Ysetgid(tls *TLS, gid Tgid_t) (r int32) + +//go:noescape +func Ysetgrent(tls *TLS) + +//go:noescape +func Ysethostent(tls *TLS, x int32) + +//go:noescape +func Ysethostname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) + +//go:noescape +func Ysetitimer(tls *TLS, which int32, new1 uintptr, old uintptr) (r1 int32) + +//go:noescape +func Ysetjmp(t *TLS, env uintptr) (_2 int32) + +//go:noescape +func Ysetkey(tls *TLS, key uintptr) + +//go:noescape +func Ysetlinebuf(tls *TLS, f uintptr) + +//go:noescape +func Ysetlocale(tls *TLS, cat int32, name uintptr) (r uintptr) + +//go:noescape +func Ysetlogmask(tls *TLS, maskpri int32) (r int32) + +//go:noescape +func Ysetmntent(tls *TLS, name uintptr, mode uintptr) (r uintptr) + +//go:noescape +func Ysetnetent(tls *TLS, x int32) + +//go:noescape +func Ysetns(tls *TLS, fd int32, nstype int32) (r int32) + +//go:noescape +func Ysetpgid(tls *TLS, pid Tpid_t, pgid Tpid_t) (r int32) + +//go:noescape +func Ysetpgrp(tls *TLS) (r Tpid_t) + +//go:noescape +func Ysetpriority(tls *TLS, which int32, who Tid_t, prio int32) (r int32) + +//go:noescape +func Ysetprotoent(tls *TLS, stayopen int32) + +//go:noescape +func Ysetpwent(tls *TLS) + +//go:noescape +func Ysetrlimit(tls *TLS, resource int32, rlim uintptr) (r int32) + +//go:noescape +func Ysetrlimit64(tls *TLS, resource int32, rlim uintptr) (r int32) + +//go:noescape +func Ysetservent(tls *TLS, stayopen int32) + +//go:noescape +func Ysetsid(tls *TLS) (r Tpid_t) + +//go:noescape +func Ysetsockopt(tls *TLS, fd int32, level int32, optname int32, optval uintptr, optlen Tsocklen_t) (r2 int32) + +//go:noescape +func Ysetspent(tls *TLS) + +//go:noescape +func Ysetstate(tls *TLS, state uintptr) (r uintptr) + +//go:noescape +func Ysettimeofday(tls *TLS, tv uintptr, tz uintptr) (r int32) + +//go:noescape +func Ysetuid(tls *TLS, uid Tuid_t) (r int32) + +//go:noescape +func Ysetusershell(tls *TLS) + +//go:noescape +func Ysetutent(tls *TLS) + +//go:noescape +func Ysetutxent(tls *TLS) + +//go:noescape +func Ysetvbuf(tls *TLS, f uintptr, buf uintptr, type1 int32, size Tsize_t) (r int32) + +//go:noescape +func Ysetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) + +//go:noescape +func Yshm_open(tls *TLS, name uintptr, flag int32, mode Tmode_t) (r int32) + +//go:noescape +func Yshm_unlink(tls *TLS, name uintptr) (r int32) + +//go:noescape +func Yshmat(tls *TLS, id int32, addr uintptr, flag int32) (r uintptr) + +//go:noescape +func Yshmctl(tls *TLS, id int32, cmd int32, buf uintptr) (r1 int32) + +//go:noescape +func Yshmdt(tls *TLS, addr uintptr) (r int32) + +//go:noescape +func Yshmget(tls *TLS, key Tkey_t, size Tsize_t, flag int32) (r int32) + +//go:noescape +func Yshutdown(tls *TLS, fd int32, how int32) (r1 int32) + +//go:noescape +func Ysigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r int32) + +//go:noescape +func Ysigaddset(tls *TLS, set uintptr, sig int32) (r int32) + +//go:noescape +func Ysigaltstack(tls *TLS, ss uintptr, old uintptr) (r int32) + +//go:noescape +func Ysigandset(tls *TLS, dest uintptr, left uintptr, right uintptr) (r1 int32) + +//go:noescape +func Ysigdelset(tls *TLS, set uintptr, sig int32) (r int32) + +//go:noescape +func Ysigemptyset(tls *TLS, set uintptr) (r int32) + +//go:noescape +func Ysigfillset(tls *TLS, set uintptr) (r int32) + +//go:noescape +func Ysigisemptyset(tls *TLS, set uintptr) (r int32) + +//go:noescape +func Ysigismember(tls *TLS, set uintptr, sig int32) (r int32) + +//go:noescape +func Ysignal(tls *TLS, signum int32, handler uintptr) (r uintptr) + +//go:noescape +func Ysignalfd(tls *TLS, fd int32, sigs uintptr, flags int32) (r int32) + +//go:noescape +func Ysignificand(tls *TLS, x float64) (r float64) + +//go:noescape +func Ysignificandf(tls *TLS, x float32) (r float32) + +//go:noescape +func Ysigorset(tls *TLS, dest uintptr, left uintptr, right uintptr) (r1 int32) + +//go:noescape +func Ysigpending(tls *TLS, set uintptr) (r int32) + +//go:noescape +func Ysigprocmask(tls *TLS, how int32, set uintptr, old uintptr) (r1 int32) + +//go:noescape +func Ysigqueue(tls *TLS, pid Tpid_t, sig int32, value Tsigval) (r1 int32) + +//go:noescape +func Ysigsuspend(tls *TLS, mask uintptr) (r int32) + +//go:noescape +func Ysigtimedwait(tls *TLS, mask uintptr, si uintptr, timeout uintptr) (r int32) + +//go:noescape +func Ysigwait(tls *TLS, mask uintptr, sig uintptr) (r int32) + +//go:noescape +func Ysigwaitinfo(tls *TLS, mask uintptr, si uintptr) (r int32) + +//go:noescape +func Ysin(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Ysincos(tls *TLS, x3 float64, sin uintptr, cos uintptr) + +//go:noescape +func Ysincosf(tls *TLS, x3 float32, sin uintptr, cos uintptr) + +//go:noescape +func Ysincosl(tls *TLS, x float64, sin uintptr, cos uintptr) + +//go:noescape +func Ysinf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Ysinh(tls *TLS, x float64) (r float64) + +//go:noescape +func Ysinhf(tls *TLS, x float32) (r float32) + +//go:noescape +func Ysinhl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ysinl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ysleep(tls *TLS, seconds uint32) (r uint32) + +//go:noescape +func Ysnprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Ysockatmark(tls *TLS, s int32) (r int32) + +//go:noescape +func Ysocket(tls *TLS, domain int32, type1 int32, protocol int32) (r1 int32) + +//go:noescape +func Ysocketpair(tls *TLS, domain int32, type1 int32, protocol int32, fd uintptr) (r2 int32) + +//go:noescape +func Ysplice(tls *TLS, fd_in int32, off_in uintptr, fd_out int32, off_out uintptr, len1 Tsize_t, flags uint32) (r Tssize_t) + +//go:noescape +func Ysprintf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Ysqrt(tls *TLS, x1 float64) (r1 float64) + +//go:noescape +func Ysqrtf(tls *TLS, x1 float32) (r1 float32) + +//go:noescape +func Ysqrtl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ysrand(tls *TLS, s uint32) + +//go:noescape +func Ysrand48(tls *TLS, seed int64) + +//go:noescape +func Ysrandom(tls *TLS, seed uint32) + +//go:noescape +func Ysscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Ystat(tls *TLS, path uintptr, buf uintptr) (r int32) + +//go:noescape +func Ystat64(tls *TLS, path uintptr, buf uintptr) (r int32) + +//go:noescape +func Ystatvfs(tls *TLS, path uintptr, buf uintptr) (r int32) + +//go:noescape +func Ystatx(tls *TLS, dirfd int32, path uintptr, flags int32, mask uint32, stx uintptr) (r int32) + +//go:noescape +func Ystime(tls *TLS, t uintptr) (r int32) + +//go:noescape +func Ystpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) + +//go:noescape +func Ystpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ystrcasecmp(tls *TLS, _l uintptr, _r uintptr) (r1 int32) + +//go:noescape +func Ystrcasecmp_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) + +//go:noescape +func Ystrcasestr(tls *TLS, h uintptr, n uintptr) (r uintptr) + +//go:noescape +func Ystrcat(tls *TLS, dest uintptr, src uintptr) (r uintptr) + +//go:noescape +func Ystrchr(tls *TLS, s uintptr, c int32) (r1 uintptr) + +//go:noescape +func Ystrchrnul(tls *TLS, s uintptr, c int32) (r uintptr) + +//go:noescape +func Ystrcmp(tls *TLS, l uintptr, r uintptr) (r1 int32) + +//go:noescape +func Ystrcoll(tls *TLS, l uintptr, r uintptr) (r1 int32) + +//go:noescape +func Ystrcoll_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) + +//go:noescape +func Ystrcpy(tls *TLS, dest uintptr, src uintptr) (r uintptr) + +//go:noescape +func Ystrcspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) + +//go:noescape +func Ystrdup(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Ystrerror(tls *TLS, e int32) (r uintptr) + +//go:noescape +func Ystrerror_l(tls *TLS, e int32, loc Tlocale_t) (r uintptr) + +//go:noescape +func Ystrerror_r(tls *TLS, err int32, buf uintptr, buflen Tsize_t) (r int32) + +//go:noescape +func Ystrfmon(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r Tssize_t) + +//go:noescape +func Ystrfmon_l(tls *TLS, s uintptr, n Tsize_t, loc Tlocale_t, fmt uintptr, va uintptr) (r Tssize_t) + +//go:noescape +func Ystrftime(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr) (r Tsize_t) + +//go:noescape +func Ystrftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) + +//go:noescape +func Ystrlcat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t) + +//go:noescape +func Ystrlcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t) + +//go:noescape +func Ystrlen(t *TLS, s uintptr) (r Tsize_t) + +//go:noescape +func Ystrncasecmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32) + +//go:noescape +func Ystrncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, loc Tlocale_t) (r1 int32) + +//go:noescape +func Ystrncat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ystrncmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32) + +//go:noescape +func Ystrncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ystrndup(tls *TLS, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ystrnlen(tls *TLS, s uintptr, n Tsize_t) (r Tsize_t) + +//go:noescape +func Ystrpbrk(tls *TLS, s uintptr, b uintptr) (r uintptr) + +//go:noescape +func Ystrptime(tls *TLS, s uintptr, f uintptr, tm uintptr) (r uintptr) + +//go:noescape +func Ystrrchr(tls *TLS, s uintptr, c int32) (r uintptr) + +//go:noescape +func Ystrsep(tls *TLS, str uintptr, sep uintptr) (r uintptr) + +//go:noescape +func Ystrsignal(tls *TLS, signum int32) (r uintptr) + +//go:noescape +func Ystrspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) + +//go:noescape +func Ystrstr(tls *TLS, h uintptr, n uintptr) (r uintptr) + +//go:noescape +func Ystrtod(tls *TLS, s uintptr, p uintptr) (r float64) + +//go:noescape +func Ystrtod_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) + +//go:noescape +func Ystrtof(tls *TLS, s uintptr, p uintptr) (r float32) + +//go:noescape +func Ystrtof_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float32) + +//go:noescape +func Ystrtoimax(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) + +//go:noescape +func Ystrtok(tls *TLS, s uintptr, sep uintptr) (r uintptr) + +//go:noescape +func Ystrtok_r(tls *TLS, s uintptr, sep uintptr, p uintptr) (r uintptr) + +//go:noescape +func Ystrtol(tls *TLS, s uintptr, p uintptr, base int32) (r int64) + +//go:noescape +func Ystrtold(tls *TLS, s uintptr, p uintptr) (r float64) + +//go:noescape +func Ystrtold_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) + +//go:noescape +func Ystrtoll(tls *TLS, s uintptr, p uintptr, base int32) (r int64) + +//go:noescape +func Ystrtoul(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) + +//go:noescape +func Ystrtoull(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) + +//go:noescape +func Ystrtoumax(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) + +//go:noescape +func Ystrverscmp(tls *TLS, l0 uintptr, r0 uintptr) (r1 int32) + +//go:noescape +func Ystrxfrm(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r Tsize_t) + +//go:noescape +func Ystrxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) + +//go:noescape +func Yswab(tls *TLS, _src uintptr, _dest uintptr, n Tssize_t) + +//go:noescape +func Yswapoff(tls *TLS, path uintptr) (r int32) + +//go:noescape +func Yswapon(tls *TLS, path uintptr, flags int32) (r int32) + +//go:noescape +func Yswprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Yswscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Ysymlink(tls *TLS, existing uintptr, new1 uintptr) (r int32) + +//go:noescape +func Ysymlinkat(tls *TLS, existing uintptr, fd int32, new1 uintptr) (r int32) + +//go:noescape +func Ysync(tls *TLS) + +//go:noescape +func Ysync_file_range(tls *TLS, fd int32, pos Toff_t, len1 Toff_t, flags uint32) (r int32) + +//go:noescape +func Ysyncfs(tls *TLS, fd int32) (r int32) + +//go:noescape +func Ysyscall(tls *TLS, n int64, va uintptr) (r int64) + +//go:noescape +func Ysysconf(tls *TLS, name int32) (r int64) + +//go:noescape +func Ysysctlbyname(t *TLS, name, oldp, oldlenp, newp uintptr, newlen Tsize_t) (_3 int32) + +//go:noescape +func Ysysinfo(tls *TLS, info uintptr) (r int32) + +//go:noescape +func Ysyslog(tls *TLS, priority int32, message uintptr, va uintptr) + +//go:noescape +func Ysystem(t *TLS, command uintptr) (_2 int32) + +//go:noescape +func Ytan(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Ytanf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Ytanh(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Ytanhf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Ytanhl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ytanl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ytcdrain(tls *TLS, fd int32) (r int32) + +//go:noescape +func Ytcflow(tls *TLS, fd int32, action int32) (r int32) + +//go:noescape +func Ytcflush(tls *TLS, fd int32, queue int32) (r int32) + +//go:noescape +func Ytcgetattr(tls *TLS, fd int32, tio uintptr) (r int32) + +//go:noescape +func Ytcgetpgrp(tls *TLS, fd int32) (r Tpid_t) + +//go:noescape +func Ytcgetsid(tls *TLS, fd int32) (r Tpid_t) + +//go:noescape +func Ytcgetwinsize(tls *TLS, fd int32, wsz uintptr) (r int32) + +//go:noescape +func Ytcsendbreak(tls *TLS, fd int32, dur int32) (r int32) + +//go:noescape +func Ytcsetattr(tls *TLS, fd int32, act int32, tio uintptr) (r int32) + +//go:noescape +func Ytcsetpgrp(tls *TLS, fd int32, pgrp Tpid_t) (r int32) + +//go:noescape +func Ytcsetwinsize(tls *TLS, fd int32, wsz uintptr) (r int32) + +//go:noescape +func Ytdelete(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r uintptr) + +//go:noescape +func __ccgo_abi0_tdelete_2(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_tdelete_2(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0_tdelete_2(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Ytdestroy(tls *TLS, root uintptr, __ccgo_fp_freekey uintptr) + +//go:noescape +func __ccgo_abi0_tdestroy_1(_0 *TLS, _1 uintptr, __ccgo_fp uintptr) + +func __ccgo_abiInternal_tdestroy_1(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr) { + __ccgo_abi0_tdestroy_1(_0, _1, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Ytee(tls *TLS, src int32, dest int32, len1 Tsize_t, flags uint32) (r Tssize_t) + +//go:noescape +func Ytelldir(tls *TLS, dir uintptr) (r int64) + +//go:noescape +func Ytempnam(tls *TLS, dir uintptr, pfx uintptr) (r1 uintptr) + +//go:noescape +func Ytextdomain(tls *TLS, domainname uintptr) (r uintptr) + +//go:noescape +func Ytfind(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r uintptr) + +//go:noescape +func __ccgo_abi0_tfind_2(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_tfind_2(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0_tfind_2(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Ytgamma(tls *TLS, x3 float64) (r1 float64) + +//go:noescape +func Ytgammaf(tls *TLS, x float32) (r float32) + +//go:noescape +func Ytgammal(tls *TLS, x float64) (r float64) + +//go:noescape +func Ytime(tls *TLS, t uintptr) (r Ttime_t) + +//go:noescape +func Ytimegm(tls *TLS, tm uintptr) (r Ttime_t) + +//go:noescape +func Ytimer_delete(tls *TLS, t Ttimer_t) (r int32) + +//go:noescape +func Ytimer_getoverrun(tls *TLS, t Ttimer_t) (r int32) + +//go:noescape +func Ytimer_gettime(tls *TLS, t Ttimer_t, val uintptr) (r int32) + +//go:noescape +func Ytimer_settime(tls *TLS, t Ttimer_t, flags int32, val uintptr, old uintptr) (r int32) + +//go:noescape +func Ytimerfd_create(tls *TLS, clockid int32, flags int32) (r int32) + +//go:noescape +func Ytimerfd_gettime(tls *TLS, fd int32, cur uintptr) (r int32) + +//go:noescape +func Ytimerfd_settime(tls *TLS, fd int32, flags int32, new1 uintptr, old uintptr) (r int32) + +//go:noescape +func Ytimes(tls *TLS, tms uintptr) (r Tclock_t) + +//go:noescape +func Ytimespec_get(tls *TLS, ts uintptr, base int32) (r int32) + +//go:noescape +func Ytmpfile(tls *TLS) (r uintptr) + +//go:noescape +func Ytmpnam(tls *TLS, buf uintptr) (r1 uintptr) + +//go:noescape +func Ytoascii(tls *TLS, c int32) (r int32) + +//go:noescape +func Ytolower(tls *TLS, c int32) (r int32) + +//go:noescape +func Ytolower_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Ytoupper(tls *TLS, c int32) (r int32) + +//go:noescape +func Ytoupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) + +//go:noescape +func Ytowctrans(tls *TLS, wc Twint_t, trans Twctrans_t) (r Twint_t) + +//go:noescape +func Ytowctrans_l(tls *TLS, c Twint_t, t Twctrans_t, l Tlocale_t) (r Twint_t) + +//go:noescape +func Ytowlower(tls *TLS, wc Twint_t) (r Twint_t) + +//go:noescape +func Ytowlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) + +//go:noescape +func Ytowupper(tls *TLS, wc Twint_t) (r Twint_t) + +//go:noescape +func Ytowupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) + +//go:noescape +func Ytrunc(tls *TLS, x3 float64) (r float64) + +//go:noescape +func Ytruncate(tls *TLS, path uintptr, length Toff_t) (r int32) + +//go:noescape +func Ytruncf(tls *TLS, x3 float32) (r float32) + +//go:noescape +func Ytruncl(tls *TLS, x float64) (r float64) + +//go:noescape +func Ytsearch(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r1 uintptr) + +//go:noescape +func __ccgo_abi0_tsearch_2(_0 *TLS, _1 uintptr, _2 uintptr, __ccgo_fp uintptr) (_3 int32) + +func __ccgo_abiInternal_tsearch_2(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 uintptr) (_3 int32) { + return __ccgo_abi0_tsearch_2(_0, _1, _2, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Yttyname(tls *TLS, fd int32) (r uintptr) + +//go:noescape +func Yttyname_r(tls *TLS, fd int32, name uintptr, size Tsize_t) (r int32) + +//go:noescape +func Ytwalk(tls *TLS, root uintptr, __ccgo_fp_action uintptr) + +//go:noescape +func __ccgo_abi0_twalk_1(_0 *TLS, _1 uintptr, _2 int32, _3 int32, __ccgo_fp uintptr) + +func __ccgo_abiInternal_twalk_1(tls *TLS, dest, abi0CodePtr uintptr) { + f := func(_0 *TLS, _1 uintptr, _2 int32, _3 int32) { + __ccgo_abi0_twalk_1(_0, _1, _2, _3, abi0CodePtr) + } + *(*[2]uintptr)(unsafe.Pointer(dest)) = *(*[2]uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&f)))) +} + +//go:noescape +func Ytzset(tls *TLS) + +//go:noescape +func Yualarm(tls *TLS, value uint32, interval uint32) (r uint32) + +//go:noescape +func Yulckpwdf(tls *TLS) (r int32) + +//go:noescape +func Yulimit(tls *TLS, cmd int32, va uintptr) (r int64) + +//go:noescape +func Yumask(tls *TLS, mode Tmode_t) (r Tmode_t) + +//go:noescape +func Yumount(tls *TLS, special uintptr) (r int32) + +//go:noescape +func Yumount2(tls *TLS, special uintptr, flags int32) (r int32) + +//go:noescape +func Yuname(tls *TLS, uts uintptr) (r int32) + +//go:noescape +func Yungetc(tls *TLS, c int32, f uintptr) (r int32) + +//go:noescape +func Yungetwc(tls *TLS, c Twint_t, f uintptr) (r Twint_t) + +//go:noescape +func Yunlink(tls *TLS, path uintptr) (r int32) + +//go:noescape +func Yunlinkat(tls *TLS, fd int32, path uintptr, flag int32) (r int32) + +//go:noescape +func Yunlockpt(tls *TLS, fd int32) (r int32) + +//go:noescape +func Yunsetenv(tls *TLS, name uintptr) (r int32) + +//go:noescape +func Yunshare(tls *TLS, flags int32) (r int32) + +//go:noescape +func Yupdwtmp(tls *TLS, f uintptr, u uintptr) + +//go:noescape +func Yupdwtmpx(tls *TLS, f uintptr, u uintptr) + +//go:noescape +func Yuselocale(tls *TLS, new1 Tlocale_t) (r Tlocale_t) + +//go:noescape +func Yusleep(tls *TLS, useconds uint32) (r int32) + +//go:noescape +func Yutime(tls *TLS, path uintptr, times uintptr) (r int32) + +//go:noescape +func Yutimensat(tls *TLS, fd int32, path uintptr, times uintptr, flags int32) (r1 int32) + +//go:noescape +func Yutimes(tls *TLS, path uintptr, times uintptr) (r int32) + +//go:noescape +func Yuuid_copy(t *TLS, dst, src uintptr) + +//go:noescape +func Yuuid_generate_random(t *TLS, out uintptr) + +//go:noescape +func Yuuid_parse(t *TLS, in uintptr, uu uintptr) (_3 int32) + +//go:noescape +func Yuuid_unparse(t *TLS, uu, out uintptr) + +//go:noescape +func Yvasprintf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvdprintf(tls *TLS, fd int32, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yverr(tls *TLS, status int32, fmt uintptr, ap Tva_list) + +//go:noescape +func Yverrx(tls *TLS, status int32, fmt uintptr, ap Tva_list) + +//go:noescape +func Yversionsort(tls *TLS, a uintptr, b uintptr) (r int32) + +//go:noescape +func Yvfork(tls *TLS) (r Tpid_t) + +//go:noescape +func Yvfprintf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvfscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvfwprintf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvfwscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvhangup(tls *TLS) (r int32) + +//go:noescape +func Yvmsplice(tls *TLS, fd int32, iov uintptr, cnt Tsize_t, flags uint32) (r Tssize_t) + +//go:noescape +func Yvprintf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvsnprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvsprintf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvsscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvswprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, ap Tva_list) (r1 int32) + +//go:noescape +func Yvswscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvwarn(tls *TLS, fmt uintptr, ap Tva_list) + +//go:noescape +func Yvwarnx(tls *TLS, fmt uintptr, ap Tva_list) + +//go:noescape +func Yvwprintf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Yvwscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) + +//go:noescape +func Ywait(tls *TLS, status uintptr) (r Tpid_t) + +//go:noescape +func Ywait3(tls *TLS, status uintptr, options int32, usage uintptr) (r Tpid_t) + +//go:noescape +func Ywait4(tls *TLS, pid Tpid_t, status uintptr, options int32, ru uintptr) (r1 Tpid_t) + +//go:noescape +func Ywaitid(tls *TLS, type1 Tidtype_t, id Tid_t, info uintptr, options int32) (r int32) + +//go:noescape +func Ywaitpid(tls *TLS, pid Tpid_t, status uintptr, options int32) (r Tpid_t) + +//go:noescape +func Ywarn(tls *TLS, fmt uintptr, va uintptr) + +//go:noescape +func Ywarnx(tls *TLS, fmt uintptr, va uintptr) + +//go:noescape +func Ywcpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) + +//go:noescape +func Ywcpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ywcrtomb(tls *TLS, s uintptr, wc Twchar_t, st uintptr) (r Tsize_t) + +//go:noescape +func Ywcscasecmp(tls *TLS, l uintptr, r uintptr) (r1 int32) + +//go:noescape +func Ywcscasecmp_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) + +//go:noescape +func Ywcscat(tls *TLS, dest uintptr, src uintptr) (r uintptr) + +//go:noescape +func Ywcschr(tls *TLS, s uintptr, c Twchar_t) (r uintptr) + +//go:noescape +func Ywcscmp(tls *TLS, l uintptr, r uintptr) (r1 int32) + +//go:noescape +func Ywcscoll(tls *TLS, l uintptr, r uintptr) (r1 int32) + +//go:noescape +func Ywcscoll_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) + +//go:noescape +func Ywcscpy(tls *TLS, d uintptr, s uintptr) (r uintptr) + +//go:noescape +func Ywcscspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) + +//go:noescape +func Ywcsdup(tls *TLS, s uintptr) (r uintptr) + +//go:noescape +func Ywcsftime(tls *TLS, wcs uintptr, n Tsize_t, f uintptr, tm uintptr) (r Tsize_t) + +//go:noescape +func Ywcsftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) + +//go:noescape +func Ywcslen(tls *TLS, s uintptr) (r Tsize_t) + +//go:noescape +func Ywcsncasecmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) + +//go:noescape +func Ywcsncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, locale Tlocale_t) (r1 int32) + +//go:noescape +func Ywcsncat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ywcsncmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) + +//go:noescape +func Ywcsncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ywcsnlen(tls *TLS, s uintptr, n Tsize_t) (r Tsize_t) + +//go:noescape +func Ywcsnrtombs(tls *TLS, dst uintptr, wcs uintptr, wn Tsize_t, n Tsize_t, st uintptr) (r Tsize_t) + +//go:noescape +func Ywcspbrk(tls *TLS, s uintptr, b uintptr) (r uintptr) + +//go:noescape +func Ywcsrchr(tls *TLS, s uintptr, c Twchar_t) (r uintptr) + +//go:noescape +func Ywcsrtombs(tls *TLS, s uintptr, ws uintptr, n Tsize_t, st uintptr) (r Tsize_t) + +//go:noescape +func Ywcsspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) + +//go:noescape +func Ywcsstr(tls *TLS, h uintptr, n uintptr) (r uintptr) + +//go:noescape +func Ywcstod(tls *TLS, s uintptr, p uintptr) (r float64) + +//go:noescape +func Ywcstof(tls *TLS, s uintptr, p uintptr) (r float32) + +//go:noescape +func Ywcstoimax(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) + +//go:noescape +func Ywcstok(tls *TLS, s uintptr, sep uintptr, p uintptr) (r uintptr) + +//go:noescape +func Ywcstol(tls *TLS, s uintptr, p uintptr, base int32) (r int64) + +//go:noescape +func Ywcstold(tls *TLS, s uintptr, p uintptr) (r float64) + +//go:noescape +func Ywcstoll(tls *TLS, s uintptr, p uintptr, base int32) (r int64) + +//go:noescape +func Ywcstombs(tls *TLS, s uintptr, ws uintptr, n Tsize_t) (r Tsize_t) + +//go:noescape +func Ywcstoul(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) + +//go:noescape +func Ywcstoull(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) + +//go:noescape +func Ywcstoumax(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) + +//go:noescape +func Ywcswcs(tls *TLS, haystack uintptr, needle uintptr) (r uintptr) + +//go:noescape +func Ywcswidth(tls *TLS, wcs uintptr, n Tsize_t) (r int32) + +//go:noescape +func Ywcsxfrm(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r Tsize_t) + +//go:noescape +func Ywcsxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) + +//go:noescape +func Ywctob(tls *TLS, c Twint_t) (r int32) + +//go:noescape +func Ywctomb(tls *TLS, s uintptr, wc Twchar_t) (r int32) + +//go:noescape +func Ywctrans(tls *TLS, class uintptr) (r Twctrans_t) + +//go:noescape +func Ywctrans_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctrans_t) + +//go:noescape +func Ywctype(tls *TLS, s uintptr) (r Twctype_t) + +//go:noescape +func Ywctype_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctype_t) + +//go:noescape +func Ywcwidth(tls *TLS, wc Twchar_t) (r int32) + +//go:noescape +func Ywmemchr(tls *TLS, s uintptr, c Twchar_t, n Tsize_t) (r uintptr) + +//go:noescape +func Ywmemcmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) + +//go:noescape +func Ywmemcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ywmemmove(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) + +//go:noescape +func Ywmemset(tls *TLS, d uintptr, c Twchar_t, n Tsize_t) (r uintptr) + +//go:noescape +func Ywprintf(tls *TLS, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Ywrite(tls *TLS, fd int32, buf uintptr, count Tsize_t) (r Tssize_t) + +//go:noescape +func Ywritev(tls *TLS, fd int32, iov uintptr, count int32) (r Tssize_t) + +//go:noescape +func Ywscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) + +//go:noescape +func Yy0(tls *TLS, x float64) (r float64) + +//go:noescape +func Yy0f(tls *TLS, x float32) (r float32) + +//go:noescape +func Yy1(tls *TLS, x float64) (r float64) + +//go:noescape +func Yy1f(tls *TLS, x float32) (r float32) + +//go:noescape +func Yyn(tls *TLS, n int32, x float64) (r float64) + +//go:noescape +func Yynf(tls *TLS, n int32, x float32) (r float32) diff --git a/internal/libc/abi0_linux_amd64.s b/internal/libc/abi0_linux_amd64.s new file mode 100644 index 0000000..14b7b0f --- /dev/null +++ b/internal/libc/abi0_linux_amd64.s @@ -0,0 +1,28760 @@ +// Code generated for linux/amd64 by 'qbecc --abi0wrap .', DO NOT EDIT. + +#include "funcdata.h" +#include "textflag.h" + +// func Y_Exit(tls *TLS, ec int32) +TEXT ·Y_Exit(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ec+8(FP), AX + MOVL AX, 8(SP) + CALL ·X_Exit(SB) + RET + +// func Y_IO_feof_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Y_IO_feof_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X_IO_feof_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y_IO_ferror_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Y_IO_ferror_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X_IO_ferror_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y_IO_getc(tls *TLS, f1 uintptr) (r int32) +TEXT ·Y_IO_getc(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X_IO_getc(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y_IO_getc_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Y_IO_getc_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X_IO_getc_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y_IO_putc(tls *TLS, c1 int32, f1 uintptr) (r int32) +TEXT ·Y_IO_putc(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c1+8(FP), AX + MOVL AX, 8(SP) + MOVQ f1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X_IO_putc(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y_IO_putc_unlocked(tls *TLS, c int32, f uintptr) (r int32) +TEXT ·Y_IO_putc_unlocked(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X_IO_putc_unlocked(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y___errno_location(tls *TLS) (r uintptr) +TEXT ·Y___errno_location(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X___errno_location(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__aio_close(tls *TLS, fd int32) (_2 int32) +TEXT ·Y__aio_close(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__aio_close(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__asctime_r(tls *TLS, tm uintptr, buf uintptr) (r uintptr) +TEXT ·Y__asctime_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tm+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__asctime_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__assert_fail(tls *TLS, expr uintptr, file uintptr, line int32, func1 uintptr) +TEXT ·Y__assert_fail(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ expr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ file+16(FP), AX + MOVQ AX, 16(SP) + MOVL line+24(FP), AX + MOVL AX, 24(SP) + MOVQ func1+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__assert_fail(SB) + RET + +// func Y__atomic_compare_exchangeInt16(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) +TEXT ·Y__atomic_compare_exchangeInt16(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL weak+32(FP), AX + MOVL AX, 32(SP) + MOVL success+36(FP), AX + MOVL AX, 36(SP) + MOVL failure+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__atomic_compare_exchangeInt16(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__atomic_compare_exchangeInt32(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) +TEXT ·Y__atomic_compare_exchangeInt32(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL weak+32(FP), AX + MOVL AX, 32(SP) + MOVL success+36(FP), AX + MOVL AX, 36(SP) + MOVL failure+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__atomic_compare_exchangeInt32(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__atomic_compare_exchangeInt64(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) +TEXT ·Y__atomic_compare_exchangeInt64(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL weak+32(FP), AX + MOVL AX, 32(SP) + MOVL success+36(FP), AX + MOVL AX, 36(SP) + MOVL failure+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__atomic_compare_exchangeInt64(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__atomic_compare_exchangeInt8(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) +TEXT ·Y__atomic_compare_exchangeInt8(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL weak+32(FP), AX + MOVL AX, 32(SP) + MOVL success+36(FP), AX + MOVL AX, 36(SP) + MOVL failure+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__atomic_compare_exchangeInt8(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__atomic_compare_exchangeUint16(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) +TEXT ·Y__atomic_compare_exchangeUint16(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL weak+32(FP), AX + MOVL AX, 32(SP) + MOVL success+36(FP), AX + MOVL AX, 36(SP) + MOVL failure+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__atomic_compare_exchangeUint16(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__atomic_compare_exchangeUint32(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) +TEXT ·Y__atomic_compare_exchangeUint32(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL weak+32(FP), AX + MOVL AX, 32(SP) + MOVL success+36(FP), AX + MOVL AX, 36(SP) + MOVL failure+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__atomic_compare_exchangeUint32(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__atomic_compare_exchangeUint64(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) +TEXT ·Y__atomic_compare_exchangeUint64(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL weak+32(FP), AX + MOVL AX, 32(SP) + MOVL success+36(FP), AX + MOVL AX, 36(SP) + MOVL failure+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__atomic_compare_exchangeUint64(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__atomic_compare_exchangeUint8(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) (_3 int32) +TEXT ·Y__atomic_compare_exchangeUint8(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL weak+32(FP), AX + MOVL AX, 32(SP) + MOVL success+36(FP), AX + MOVL AX, 36(SP) + MOVL failure+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__atomic_compare_exchangeUint8(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__atomic_exchangeInt16(t *TLS, ptr, val, ret uintptr, _ int32) +TEXT ·Y__atomic_exchangeInt16(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ret+24(FP), AX + MOVQ AX, 24(SP) + MOVL _+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__atomic_exchangeInt16(SB) + RET + +// func Y__atomic_exchangeInt32(t *TLS, ptr, val, ret uintptr, _ int32) +TEXT ·Y__atomic_exchangeInt32(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ret+24(FP), AX + MOVQ AX, 24(SP) + MOVL _+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__atomic_exchangeInt32(SB) + RET + +// func Y__atomic_exchangeInt64(t *TLS, ptr, val, ret uintptr, _ int32) +TEXT ·Y__atomic_exchangeInt64(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ret+24(FP), AX + MOVQ AX, 24(SP) + MOVL _+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__atomic_exchangeInt64(SB) + RET + +// func Y__atomic_exchangeInt8(t *TLS, ptr, val, ret uintptr, _ int32) +TEXT ·Y__atomic_exchangeInt8(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ret+24(FP), AX + MOVQ AX, 24(SP) + MOVL _+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__atomic_exchangeInt8(SB) + RET + +// func Y__atomic_exchangeUint16(t *TLS, ptr, val, ret uintptr, _ int32) +TEXT ·Y__atomic_exchangeUint16(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ret+24(FP), AX + MOVQ AX, 24(SP) + MOVL _+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__atomic_exchangeUint16(SB) + RET + +// func Y__atomic_exchangeUint32(t *TLS, ptr, val, ret uintptr, _ int32) +TEXT ·Y__atomic_exchangeUint32(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ret+24(FP), AX + MOVQ AX, 24(SP) + MOVL _+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__atomic_exchangeUint32(SB) + RET + +// func Y__atomic_exchangeUint64(t *TLS, ptr, val, ret uintptr, _ int32) +TEXT ·Y__atomic_exchangeUint64(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ret+24(FP), AX + MOVQ AX, 24(SP) + MOVL _+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__atomic_exchangeUint64(SB) + RET + +// func Y__atomic_exchangeUint8(t *TLS, ptr, val, ret uintptr, _ int32) +TEXT ·Y__atomic_exchangeUint8(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ret+24(FP), AX + MOVQ AX, 24(SP) + MOVL _+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__atomic_exchangeUint8(SB) + RET + +// func Y__atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__atomic_fetch_addInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_addInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__atomic_fetch_addInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_addInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__atomic_fetch_addInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_addInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__atomic_fetch_addInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_addInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__atomic_fetch_addUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_addUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__atomic_fetch_addUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_addUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__atomic_fetch_addUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_addUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__atomic_fetch_addUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_addUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__atomic_fetch_andInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_andInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__atomic_fetch_andInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_andInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__atomic_fetch_andInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_andInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__atomic_fetch_andInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_andInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__atomic_fetch_andUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_andUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__atomic_fetch_andUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_andUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__atomic_fetch_andUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_andUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__atomic_fetch_andUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_andUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__atomic_fetch_orInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_orInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__atomic_fetch_orInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_orInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__atomic_fetch_orInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_orInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__atomic_fetch_orInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_orInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__atomic_fetch_orUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_orUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__atomic_fetch_orUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_orUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__atomic_fetch_orUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_orUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__atomic_fetch_orUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_orUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__atomic_fetch_subInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_subInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__atomic_fetch_subInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_subInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__atomic_fetch_subInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_subInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__atomic_fetch_subInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_subInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__atomic_fetch_subUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_subUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__atomic_fetch_subUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_subUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__atomic_fetch_subUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_subUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__atomic_fetch_subUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_subUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__atomic_fetch_xorInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_xorInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__atomic_fetch_xorInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_xorInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__atomic_fetch_xorInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_xorInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__atomic_fetch_xorInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_xorInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__atomic_fetch_xorUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_xorUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__atomic_fetch_xorUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_xorUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__atomic_fetch_xorUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_fetch_xorUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__atomic_fetch_xorUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__atomic_fetch_xorUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__atomic_loadInt16(t *TLS, ptr, ret uintptr, memorder int32) +TEXT ·Y__atomic_loadInt16(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ret+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_loadInt16(SB) + RET + +// func Y__atomic_loadInt32(t *TLS, ptr, ret uintptr, memorder int32) +TEXT ·Y__atomic_loadInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ret+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_loadInt32(SB) + RET + +// func Y__atomic_loadInt64(t *TLS, ptr, ret uintptr, memorder int32) +TEXT ·Y__atomic_loadInt64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ret+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_loadInt64(SB) + RET + +// func Y__atomic_loadInt8(t *TLS, ptr, ret uintptr, memorder int32) +TEXT ·Y__atomic_loadInt8(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ret+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_loadInt8(SB) + RET + +// func Y__atomic_loadUint16(t *TLS, ptr, ret uintptr, memorder int32) +TEXT ·Y__atomic_loadUint16(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ret+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_loadUint16(SB) + RET + +// func Y__atomic_loadUint32(t *TLS, ptr, ret uintptr, memorder int32) +TEXT ·Y__atomic_loadUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ret+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_loadUint32(SB) + RET + +// func Y__atomic_loadUint64(t *TLS, ptr, ret uintptr, memorder int32) +TEXT ·Y__atomic_loadUint64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ret+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_loadUint64(SB) + RET + +// func Y__atomic_loadUint8(t *TLS, ptr, ret uintptr, memorder int32) +TEXT ·Y__atomic_loadUint8(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ret+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_loadUint8(SB) + RET + +// func Y__atomic_storeInt16(t *TLS, ptr, val uintptr, memorder int32) +TEXT ·Y__atomic_storeInt16(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_storeInt16(SB) + RET + +// func Y__atomic_storeInt32(t *TLS, ptr, val uintptr, memorder int32) +TEXT ·Y__atomic_storeInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_storeInt32(SB) + RET + +// func Y__atomic_storeInt64(t *TLS, ptr, val uintptr, memorder int32) +TEXT ·Y__atomic_storeInt64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_storeInt64(SB) + RET + +// func Y__atomic_storeInt8(t *TLS, ptr, val uintptr, memorder int32) +TEXT ·Y__atomic_storeInt8(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_storeInt8(SB) + RET + +// func Y__atomic_storeUint16(t *TLS, ptr, val uintptr, memorder int32) +TEXT ·Y__atomic_storeUint16(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_storeUint16(SB) + RET + +// func Y__atomic_storeUint32(t *TLS, ptr, val uintptr, memorder int32) +TEXT ·Y__atomic_storeUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_storeUint32(SB) + RET + +// func Y__atomic_storeUint64(t *TLS, ptr, val uintptr, memorder int32) +TEXT ·Y__atomic_storeUint64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_storeUint64(SB) + RET + +// func Y__atomic_storeUint8(t *TLS, ptr, val uintptr, memorder int32) +TEXT ·Y__atomic_storeUint8(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__atomic_storeUint8(SB) + RET + +// func Y__block_all_sigs(tls *TLS, set uintptr) +TEXT ·Y__block_all_sigs(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__block_all_sigs(SB) + RET + +// func Y__block_app_sigs(tls *TLS, set uintptr) +TEXT ·Y__block_app_sigs(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__block_app_sigs(SB) + RET + +// func Y__builtin___memcpy_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (r uintptr) +TEXT ·Y__builtin___memcpy_chk(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ os+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__builtin___memcpy_chk(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Y__builtin___memmove_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (_3 uintptr) +TEXT ·Y__builtin___memmove_chk(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ os+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__builtin___memmove_chk(SB) + MOVQ 40(SP), AX + MOVQ AX, _3+40(FP) + RET + +// func Y__builtin___memset_chk(t *TLS, s uintptr, c int32, n, os Tsize_t) (_4 uintptr) +TEXT ·Y__builtin___memset_chk(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ os+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__builtin___memset_chk(SB) + MOVQ 40(SP), AX + MOVQ AX, _4+40(FP) + RET + +// func Y__builtin___snprintf_chk(t *TLS, str uintptr, maxlen Tsize_t, flag int32, os Tsize_t, format, args uintptr) (r int32) +TEXT ·Y__builtin___snprintf_chk(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ str+8(FP), AX + MOVQ AX, 8(SP) + MOVQ maxlen+16(FP), AX + MOVQ AX, 16(SP) + MOVL flag+24(FP), AX + MOVL AX, 24(SP) + MOVQ os+32(FP), AX + MOVQ AX, 32(SP) + MOVQ format+40(FP), AX + MOVQ AX, 40(SP) + MOVQ args+48(FP), AX + MOVQ AX, 48(SP) + CALL ·X__builtin___snprintf_chk(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Y__builtin___sprintf_chk(t *TLS, s uintptr, flag int32, os Tsize_t, format, args uintptr) (r int32) +TEXT ·Y__builtin___sprintf_chk(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL flag+16(FP), AX + MOVL AX, 16(SP) + MOVQ os+24(FP), AX + MOVQ AX, 24(SP) + MOVQ format+32(FP), AX + MOVQ AX, 32(SP) + MOVQ args+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__builtin___sprintf_chk(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Y__builtin___strcat_chk(t *TLS, dest, src uintptr, os Tsize_t) (r uintptr) +TEXT ·Y__builtin___strcat_chk(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ os+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin___strcat_chk(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__builtin___strcpy_chk(t *TLS, dest, src uintptr, os Tsize_t) (_3 uintptr) +TEXT ·Y__builtin___strcpy_chk(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ os+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin___strcpy_chk(SB) + MOVQ 32(SP), AX + MOVQ AX, _3+32(FP) + RET + +// func Y__builtin___strncpy_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (r uintptr) +TEXT ·Y__builtin___strncpy_chk(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ os+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__builtin___strncpy_chk(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Y__builtin___vsnprintf_chk(t *TLS, str uintptr, maxlen Tsize_t, flag int32, os Tsize_t, format, args uintptr) (r int32) +TEXT ·Y__builtin___vsnprintf_chk(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ str+8(FP), AX + MOVQ AX, 8(SP) + MOVQ maxlen+16(FP), AX + MOVQ AX, 16(SP) + MOVL flag+24(FP), AX + MOVL AX, 24(SP) + MOVQ os+32(FP), AX + MOVQ AX, 32(SP) + MOVQ format+40(FP), AX + MOVQ AX, 40(SP) + MOVQ args+48(FP), AX + MOVQ AX, 48(SP) + CALL ·X__builtin___vsnprintf_chk(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Y__builtin_abort(t *TLS) +TEXT ·Y__builtin_abort(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__builtin_abort(SB) + RET + +// func Y__builtin_abs(t *TLS, j int32) (_2 int32) +TEXT ·Y__builtin_abs(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL j+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_abs(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_add_overflowInt64(t *TLS, a, b int64, res uintptr) (_3 int32) +TEXT ·Y__builtin_add_overflowInt64(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + MOVQ res+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_add_overflowInt64(SB) + MOVL 32(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Y__builtin_add_overflowUint32(t *TLS, a, b uint32, res uintptr) (_3 int32) +TEXT ·Y__builtin_add_overflowUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL a+8(FP), AX + MOVL AX, 8(SP) + MOVL b+12(FP), AX + MOVL AX, 12(SP) + MOVQ res+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_add_overflowUint32(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Y__builtin_add_overflowUint64(t *TLS, a, b uint64, res uintptr) (_3 int32) +TEXT ·Y__builtin_add_overflowUint64(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + MOVQ res+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_add_overflowUint64(SB) + MOVL 32(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Y__builtin_alloca(tls *TLS, size Tsize_t) (_2 uintptr) +TEXT ·Y__builtin_alloca(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ size+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_alloca(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_bswap16(t *TLS, x uint16) (_2 uint16) +TEXT ·Y__builtin_bswap16(SB),$24-18 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVW x+8(FP), AX + MOVW AX, 8(SP) + CALL ·X__builtin_bswap16(SB) + MOVW 16(SP), AX + MOVW AX, _2+16(FP) + RET + +// func Y__builtin_bswap32(t *TLS, x uint32) (_2 uint32) +TEXT ·Y__builtin_bswap32(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_bswap32(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_bswap64(t *TLS, x uint64) (_2 uint64) +TEXT ·Y__builtin_bswap64(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_bswap64(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_bzero(t *TLS, s uintptr, n Tsize_t) +TEXT ·Y__builtin_bzero(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_bzero(SB) + RET + +// func Y__builtin_clz(t *TLS, n uint32) (_2 int32) +TEXT ·Y__builtin_clz(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_clz(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_clzl(t *TLS, n ulong) (_2 int32) +TEXT ·Y__builtin_clzl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_clzl(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_clzll(t *TLS, n uint64) (_2 int32) +TEXT ·Y__builtin_clzll(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_clzll(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_copysign(t *TLS, x, y float64) (_2 float64) +TEXT ·Y__builtin_copysign(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_copysign(SB) + MOVQ 24(SP), AX + MOVQ AX, _2+24(FP) + RET + +// func Y__builtin_copysignf(t *TLS, x, y float32) (_2 float32) +TEXT ·Y__builtin_copysignf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·X__builtin_copysignf(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_copysignl(t *TLS, x, y float64) (_2 float64) +TEXT ·Y__builtin_copysignl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_copysignl(SB) + MOVQ 24(SP), AX + MOVQ AX, _2+24(FP) + RET + +// func Y__builtin_ctz(t *TLS, n uint32) (_2 int32) +TEXT ·Y__builtin_ctz(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_ctz(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_ctzl(tls *TLS, x ulong) (_2 int32) +TEXT ·Y__builtin_ctzl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_ctzl(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_exit(t *TLS, status int32) +TEXT ·Y__builtin_exit(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL status+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_exit(SB) + RET + +// func Y__builtin_expect(t *TLS, exp, c long) (_2 long) +TEXT ·Y__builtin_expect(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ exp+8(FP), AX + MOVQ AX, 8(SP) + MOVQ c+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_expect(SB) + MOVQ 24(SP), AX + MOVQ AX, _2+24(FP) + RET + +// func Y__builtin_fabs(t *TLS, x float64) (_2 float64) +TEXT ·Y__builtin_fabs(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_fabs(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_fabsf(t *TLS, x float32) (_2 float32) +TEXT ·Y__builtin_fabsf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_fabsf(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_fabsl(t *TLS, x float64) (_2 float64) +TEXT ·Y__builtin_fabsl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_fabsl(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_ffs(tls *TLS, i int32) (r int32) +TEXT ·Y__builtin_ffs(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL i+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_ffs(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__builtin_fma(tls *TLS, x, y, z float64) (r float64) +TEXT ·Y__builtin_fma(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + MOVQ z+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_fma(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__builtin_fmax(tls *TLS, x float64, y float64) (r float64) +TEXT ·Y__builtin_fmax(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_fmax(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__builtin_fmin(tls *TLS, x float64, y float64) (r float64) +TEXT ·Y__builtin_fmin(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_fmin(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__builtin_free(t *TLS, ptr uintptr) +TEXT ·Y__builtin_free(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_free(SB) + RET + +// func Y__builtin_getentropy(t *TLS, buf uintptr, n Tsize_t) (_3 int32) +TEXT ·Y__builtin_getentropy(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_getentropy(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Y__builtin_huge_val(t *TLS) (_1 float64) +TEXT ·Y__builtin_huge_val(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__builtin_huge_val(SB) + MOVQ 8(SP), AX + MOVQ AX, _1+8(FP) + RET + +// func Y__builtin_huge_valf(t *TLS) (_1 float32) +TEXT ·Y__builtin_huge_valf(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__builtin_huge_valf(SB) + MOVL 8(SP), AX + MOVL AX, _1+8(FP) + RET + +// func Y__builtin_hypot(tls *TLS, x float64, y float64) (r float64) +TEXT ·Y__builtin_hypot(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_hypot(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__builtin_inf(t *TLS) (_1 float64) +TEXT ·Y__builtin_inf(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__builtin_inf(SB) + MOVQ 8(SP), AX + MOVQ AX, _1+8(FP) + RET + +// func Y__builtin_inff(tls *TLS) (_1 float32) +TEXT ·Y__builtin_inff(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__builtin_inff(SB) + MOVL 8(SP), AX + MOVL AX, _1+8(FP) + RET + +// func Y__builtin_infl(t *TLS) (_1 float64) +TEXT ·Y__builtin_infl(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__builtin_infl(SB) + MOVQ 8(SP), AX + MOVQ AX, _1+8(FP) + RET + +// func Y__builtin_isblank(tls *TLS, c int32) (r int32) +TEXT ·Y__builtin_isblank(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_isblank(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__builtin_isnan(t *TLS, x float64) (_2 int32) +TEXT ·Y__builtin_isnan(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_isnan(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_isnanf(t *TLS, x float32) (_2 int32) +TEXT ·Y__builtin_isnanf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_isnanf(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_isnanl(t *TLS, x float64) (_2 int32) +TEXT ·Y__builtin_isnanl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_isnanl(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_isprint(tls *TLS, c int32) (r int32) +TEXT ·Y__builtin_isprint(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_isprint(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__builtin_isunordered(t *TLS, a, b float64) (_2 int32) +TEXT ·Y__builtin_isunordered(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_isunordered(SB) + MOVL 24(SP), AX + MOVL AX, _2+24(FP) + RET + +// func Y__builtin_llabs(tls *TLS, a int64) (_2 int64) +TEXT ·Y__builtin_llabs(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_llabs(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_log2(t *TLS, x float64) (_2 float64) +TEXT ·Y__builtin_log2(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_log2(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_lrint(tls *TLS, x float64) (r long) +TEXT ·Y__builtin_lrint(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_lrint(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__builtin_lrintf(tls *TLS, x float32) (r long) +TEXT ·Y__builtin_lrintf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_lrintf(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__builtin_lround(tls *TLS, x float64) (r long) +TEXT ·Y__builtin_lround(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_lround(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__builtin_malloc(t *TLS, size Tsize_t) (_2 uintptr) +TEXT ·Y__builtin_malloc(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ size+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_malloc(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_memcmp(t *TLS, s1, s2 uintptr, n Tsize_t) (_3 int32) +TEXT ·Y__builtin_memcmp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_memcmp(SB) + MOVL 32(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Y__builtin_memcpy(t *TLS, dest, src uintptr, n Tsize_t) (r uintptr) +TEXT ·Y__builtin_memcpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_memcpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__builtin_memset(t *TLS, s uintptr, c int32, n Tsize_t) (_4 uintptr) +TEXT ·Y__builtin_memset(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_memset(SB) + MOVQ 32(SP), AX + MOVQ AX, _4+32(FP) + RET + +// func Y__builtin_mmap(t *TLS, addr uintptr, length Tsize_t, prot, flags, fd int32, offset Toff_t) (_5 uintptr) +TEXT ·Y__builtin_mmap(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ length+16(FP), AX + MOVQ AX, 16(SP) + MOVL prot+24(FP), AX + MOVL AX, 24(SP) + MOVL flags+28(FP), AX + MOVL AX, 28(SP) + MOVL fd+32(FP), AX + MOVL AX, 32(SP) + MOVQ offset+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__builtin_mmap(SB) + MOVQ 48(SP), AX + MOVQ AX, _5+48(FP) + RET + +// func Y__builtin_mul_overflowInt64(t *TLS, a, b int64, res uintptr) (_3 int32) +TEXT ·Y__builtin_mul_overflowInt64(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + MOVQ res+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_mul_overflowInt64(SB) + MOVL 32(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Y__builtin_mul_overflowUint128(t *TLS, a, b Uint128, res uintptr) (_3 int32) +TEXT ·Y__builtin_mul_overflowUint128(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a_Lo+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a_Hi+16(FP), AX + MOVQ AX, 16(SP) + MOVQ b_Lo+24(FP), AX + MOVQ AX, 24(SP) + MOVQ b_Hi+32(FP), AX + MOVQ AX, 32(SP) + MOVQ res+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__builtin_mul_overflowUint128(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Y__builtin_mul_overflowUint64(t *TLS, a, b uint64, res uintptr) (_3 int32) +TEXT ·Y__builtin_mul_overflowUint64(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + MOVQ res+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_mul_overflowUint64(SB) + MOVL 32(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Y__builtin_nan(t *TLS, s uintptr) (_2 float64) +TEXT ·Y__builtin_nan(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_nan(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_nanf(tls *TLS, s uintptr) (_2 float32) +TEXT ·Y__builtin_nanf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_nanf(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_nanl(t *TLS, s uintptr) (_2 float64) +TEXT ·Y__builtin_nanl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_nanl(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_object_size(t *TLS, p uintptr, typ int32) (_3 Tsize_t) +TEXT ·Y__builtin_object_size(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + MOVL typ+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__builtin_object_size(SB) + MOVQ 24(SP), AX + MOVQ AX, _3+24(FP) + RET + +// func Y__builtin_popcount(t *TLS, x uint32) (_2 int32) +TEXT ·Y__builtin_popcount(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_popcount(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_popcountl(t *TLS, x ulong) (_2 int32) +TEXT ·Y__builtin_popcountl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_popcountl(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_popcountll(t *TLS, x uint64) (_2 int32) +TEXT ·Y__builtin_popcountll(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_popcountll(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__builtin_prefetch(t *TLS, addr, args uintptr) +TEXT ·Y__builtin_prefetch(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ args+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_prefetch(SB) + RET + +// func Y__builtin_printf(tls *TLS, fmt uintptr, va uintptr) (r int32) +TEXT ·Y__builtin_printf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_printf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__builtin_rintf(tls *TLS, x float32) (r float32) +TEXT ·Y__builtin_rintf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_rintf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__builtin_round(tls *TLS, x float64) (r float64) +TEXT ·Y__builtin_round(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_round(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__builtin_roundf(tls *TLS, x float32) (r float32) +TEXT ·Y__builtin_roundf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__builtin_roundf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__builtin_snprintf(t *TLS, str uintptr, size Tsize_t, format, args uintptr) (_4 int32) +TEXT ·Y__builtin_snprintf(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ str+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVQ format+24(FP), AX + MOVQ AX, 24(SP) + MOVQ args+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__builtin_snprintf(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__builtin_sprintf(t *TLS, str, format, args uintptr) (r int32) +TEXT ·Y__builtin_sprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ str+8(FP), AX + MOVQ AX, 8(SP) + MOVQ format+16(FP), AX + MOVQ AX, 16(SP) + MOVQ args+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_sprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__builtin_strchr(t *TLS, s uintptr, c int32) (_3 uintptr) +TEXT ·Y__builtin_strchr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__builtin_strchr(SB) + MOVQ 24(SP), AX + MOVQ AX, _3+24(FP) + RET + +// func Y__builtin_strcmp(t *TLS, s1, s2 uintptr) (_2 int32) +TEXT ·Y__builtin_strcmp(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s2+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_strcmp(SB) + MOVL 24(SP), AX + MOVL AX, _2+24(FP) + RET + +// func Y__builtin_strcpy(t *TLS, dest, src uintptr) (_2 uintptr) +TEXT ·Y__builtin_strcpy(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__builtin_strcpy(SB) + MOVQ 24(SP), AX + MOVQ AX, _2+24(FP) + RET + +// func Y__builtin_strlen(t *TLS, s uintptr) (_2 Tsize_t) +TEXT ·Y__builtin_strlen(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_strlen(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__builtin_sub_overflowInt64(t *TLS, a, b int64, res uintptr) (_3 int32) +TEXT ·Y__builtin_sub_overflowInt64(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + MOVQ res+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__builtin_sub_overflowInt64(SB) + MOVL 32(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Y__builtin_trap(t *TLS) +TEXT ·Y__builtin_trap(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__builtin_trap(SB) + RET + +// func Y__builtin_trunc(tls *TLS, x float64) (r float64) +TEXT ·Y__builtin_trunc(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__builtin_trunc(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__builtin_unreachable(t *TLS) +TEXT ·Y__builtin_unreachable(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__builtin_unreachable(SB) + RET + +// func Y__builtin_vsnprintf(t *TLS, str uintptr, size Tsize_t, format, va uintptr) (_4 int32) +TEXT ·Y__builtin_vsnprintf(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ str+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVQ format+24(FP), AX + MOVQ AX, 24(SP) + MOVQ va+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__builtin_vsnprintf(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__c11_atomic_compare_exchange_strongInt16(t *TLS, ptr, expected uintptr, desired int16, success, failure int32) (_4 int32) +TEXT ·Y__c11_atomic_compare_exchange_strongInt16(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVW desired+24(FP), AX + MOVW AX, 24(SP) + MOVL success+28(FP), AX + MOVL AX, 28(SP) + MOVL failure+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__c11_atomic_compare_exchange_strongInt16(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__c11_atomic_compare_exchange_strongInt32(t *TLS, ptr, expected uintptr, desired, success, failure int32) (_3 int32) +TEXT ·Y__c11_atomic_compare_exchange_strongInt32(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVL desired+24(FP), AX + MOVL AX, 24(SP) + MOVL success+28(FP), AX + MOVL AX, 28(SP) + MOVL failure+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__c11_atomic_compare_exchange_strongInt32(SB) + MOVL 40(SP), AX + MOVL AX, _3+40(FP) + RET + +// func Y__c11_atomic_compare_exchange_strongInt64(t *TLS, ptr, expected uintptr, desired int64, success, failure int32) (_4 int32) +TEXT ·Y__c11_atomic_compare_exchange_strongInt64(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL success+32(FP), AX + MOVL AX, 32(SP) + MOVL failure+36(FP), AX + MOVL AX, 36(SP) + CALL ·X__c11_atomic_compare_exchange_strongInt64(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__c11_atomic_compare_exchange_strongInt8(t *TLS, ptr, expected uintptr, desired int8, success, failure int32) (_4 int32) +TEXT ·Y__c11_atomic_compare_exchange_strongInt8(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVB desired+24(FP), AX + MOVB AX, 24(SP) + MOVL success+28(FP), AX + MOVL AX, 28(SP) + MOVL failure+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__c11_atomic_compare_exchange_strongInt8(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__c11_atomic_compare_exchange_strongUint16(t *TLS, ptr, expected uintptr, desired uint16, success, failure int32) (_4 int32) +TEXT ·Y__c11_atomic_compare_exchange_strongUint16(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVW desired+24(FP), AX + MOVW AX, 24(SP) + MOVL success+28(FP), AX + MOVL AX, 28(SP) + MOVL failure+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__c11_atomic_compare_exchange_strongUint16(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__c11_atomic_compare_exchange_strongUint32(t *TLS, ptr, expected uintptr, desired uint32, success, failure int32) (_4 int32) +TEXT ·Y__c11_atomic_compare_exchange_strongUint32(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVL desired+24(FP), AX + MOVL AX, 24(SP) + MOVL success+28(FP), AX + MOVL AX, 28(SP) + MOVL failure+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__c11_atomic_compare_exchange_strongUint32(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__c11_atomic_compare_exchange_strongUint64(t *TLS, ptr, expected uintptr, desired uint64, success, failure int32) (_4 int32) +TEXT ·Y__c11_atomic_compare_exchange_strongUint64(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVQ desired+24(FP), AX + MOVQ AX, 24(SP) + MOVL success+32(FP), AX + MOVL AX, 32(SP) + MOVL failure+36(FP), AX + MOVL AX, 36(SP) + CALL ·X__c11_atomic_compare_exchange_strongUint64(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__c11_atomic_compare_exchange_strongUint8(t *TLS, ptr, expected uintptr, desired uint8, success, failure int32) (_4 int32) +TEXT ·Y__c11_atomic_compare_exchange_strongUint8(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ expected+16(FP), AX + MOVQ AX, 16(SP) + MOVB desired+24(FP), AX + MOVB AX, 24(SP) + MOVL success+28(FP), AX + MOVL AX, 28(SP) + MOVL failure+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__c11_atomic_compare_exchange_strongUint8(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__c11_atomic_exchangeInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__c11_atomic_exchangeInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_exchangeInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_exchangeInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__c11_atomic_exchangeInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_exchangeInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_exchangeInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__c11_atomic_exchangeInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_exchangeInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_exchangeInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__c11_atomic_exchangeInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_exchangeInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_exchangeUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__c11_atomic_exchangeUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_exchangeUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_exchangeUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__c11_atomic_exchangeUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_exchangeUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_exchangeUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__c11_atomic_exchangeUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_exchangeUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_exchangeUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__c11_atomic_exchangeUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_exchangeUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__c11_atomic_fetch_addInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_addInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__c11_atomic_fetch_addInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_addInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__c11_atomic_fetch_addInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_addInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__c11_atomic_fetch_addInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_addInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__c11_atomic_fetch_addUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_addUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__c11_atomic_fetch_addUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_addUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__c11_atomic_fetch_addUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_addUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__c11_atomic_fetch_addUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_addUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__c11_atomic_fetch_andInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_andInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__c11_atomic_fetch_andInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_andInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__c11_atomic_fetch_andInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_andInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__c11_atomic_fetch_andInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_andInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__c11_atomic_fetch_andUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_andUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__c11_atomic_fetch_andUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_andUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__c11_atomic_fetch_andUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_andUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__c11_atomic_fetch_andUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_andUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__c11_atomic_fetch_orInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_orInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__c11_atomic_fetch_orInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_orInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__c11_atomic_fetch_orInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_orInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__c11_atomic_fetch_orInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_orInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__c11_atomic_fetch_orUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_orUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__c11_atomic_fetch_orUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_orUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__c11_atomic_fetch_orUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_orUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__c11_atomic_fetch_orUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_orUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__c11_atomic_fetch_subInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_subInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__c11_atomic_fetch_subInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_subInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__c11_atomic_fetch_subInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_subInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__c11_atomic_fetch_subInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_subInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__c11_atomic_fetch_subUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_subUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__c11_atomic_fetch_subUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_subUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__c11_atomic_fetch_subUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_subUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__c11_atomic_fetch_subUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_subUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) +TEXT ·Y__c11_atomic_fetch_xorInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_xorInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) +TEXT ·Y__c11_atomic_fetch_xorInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_xorInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) +TEXT ·Y__c11_atomic_fetch_xorInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_xorInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) +TEXT ·Y__c11_atomic_fetch_xorInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_xorInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) +TEXT ·Y__c11_atomic_fetch_xorUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_xorUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) +TEXT ·Y__c11_atomic_fetch_xorUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_xorUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) +TEXT ·Y__c11_atomic_fetch_xorUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL _+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_fetch_xorUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__c11_atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) +TEXT ·Y__c11_atomic_fetch_xorUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL _+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_fetch_xorUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_loadInt16(t *TLS, ptr uintptr, memorder int32) (r int16) +TEXT ·Y__c11_atomic_loadInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL memorder+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__c11_atomic_loadInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_loadInt32(t *TLS, ptr uintptr, memorder int32) (r int32) +TEXT ·Y__c11_atomic_loadInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL memorder+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__c11_atomic_loadInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_loadInt64(t *TLS, ptr uintptr, memorder int32) (r int64) +TEXT ·Y__c11_atomic_loadInt64(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL memorder+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__c11_atomic_loadInt64(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__c11_atomic_loadInt8(t *TLS, ptr uintptr, memorder int32) (r int8) +TEXT ·Y__c11_atomic_loadInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL memorder+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__c11_atomic_loadInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_loadUint16(t *TLS, ptr uintptr, memorder int32) (r uint16) +TEXT ·Y__c11_atomic_loadUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL memorder+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__c11_atomic_loadUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__c11_atomic_loadUint32(t *TLS, ptr uintptr, memorder int32) (r uint32) +TEXT ·Y__c11_atomic_loadUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL memorder+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__c11_atomic_loadUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__c11_atomic_loadUint64(t *TLS, ptr uintptr, memorder int32) (r uint64) +TEXT ·Y__c11_atomic_loadUint64(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL memorder+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__c11_atomic_loadUint64(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__c11_atomic_loadUint8(t *TLS, ptr uintptr, memorder int32) (r uint8) +TEXT ·Y__c11_atomic_loadUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL memorder+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__c11_atomic_loadUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__c11_atomic_storeInt16(t *TLS, ptr uintptr, val int16, memorder int32) +TEXT ·Y__c11_atomic_storeInt16(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL memorder+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_storeInt16(SB) + RET + +// func Y__c11_atomic_storeInt32(t *TLS, ptr uintptr, val int32, memorder int32) +TEXT ·Y__c11_atomic_storeInt32(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL memorder+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_storeInt32(SB) + RET + +// func Y__c11_atomic_storeInt64(t *TLS, ptr uintptr, val int64, memorder int32) +TEXT ·Y__c11_atomic_storeInt64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_storeInt64(SB) + RET + +// func Y__c11_atomic_storeInt8(t *TLS, ptr uintptr, val int8, memorder int32) +TEXT ·Y__c11_atomic_storeInt8(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL memorder+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_storeInt8(SB) + RET + +// func Y__c11_atomic_storeUint16(t *TLS, ptr uintptr, val uint16, memorder int32) +TEXT ·Y__c11_atomic_storeUint16(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW val+16(FP), AX + MOVW AX, 16(SP) + MOVL memorder+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_storeUint16(SB) + RET + +// func Y__c11_atomic_storeUint32(t *TLS, ptr uintptr, val uint32, memorder int32) +TEXT ·Y__c11_atomic_storeUint32(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + MOVL memorder+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_storeUint32(SB) + RET + +// func Y__c11_atomic_storeUint64(t *TLS, ptr uintptr, val uint64, memorder int32) +TEXT ·Y__c11_atomic_storeUint64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + MOVL memorder+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__c11_atomic_storeUint64(SB) + RET + +// func Y__c11_atomic_storeUint8(t *TLS, ptr uintptr, val uint8, memorder int32) +TEXT ·Y__c11_atomic_storeUint8(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB val+16(FP), AX + MOVB AX, 16(SP) + MOVL memorder+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__c11_atomic_storeUint8(SB) + RET + +// func Y__ccgo_dmesg(t *TLS, fmt uintptr, va uintptr) +TEXT ·Y__ccgo_dmesg(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__ccgo_dmesg(SB) + RET + +// func Y__ccgo_getMutexType(tls *TLS, m uintptr) (_2 int32) +TEXT ·Y__ccgo_getMutexType(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__ccgo_getMutexType(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__ccgo_in6addr_anyp(t *TLS) (_1 uintptr) +TEXT ·Y__ccgo_in6addr_anyp(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__ccgo_in6addr_anyp(SB) + MOVQ 8(SP), AX + MOVQ AX, _1+8(FP) + RET + +// func Y__ccgo_pthreadAttrGetDetachState(tls *TLS, a uintptr) (_2 int32) +TEXT ·Y__ccgo_pthreadAttrGetDetachState(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__ccgo_pthreadAttrGetDetachState(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__ccgo_pthreadMutexattrGettype(tls *TLS, a uintptr) (_2 int32) +TEXT ·Y__ccgo_pthreadMutexattrGettype(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__ccgo_pthreadMutexattrGettype(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__ccgo_sqlite3_log(t *TLS, iErrCode int32, zFormat uintptr, args uintptr) +TEXT ·Y__ccgo_sqlite3_log(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL iErrCode+8(FP), AX + MOVL AX, 8(SP) + MOVQ zFormat+16(FP), AX + MOVQ AX, 16(SP) + MOVQ args+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__ccgo_sqlite3_log(SB) + RET + +// func Y__clock_gettime(tls *TLS, clk Tclockid_t, ts uintptr) (r1 int32) +TEXT ·Y__clock_gettime(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL clk+8(FP), AX + MOVL AX, 8(SP) + MOVQ ts+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__clock_gettime(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Y__clock_nanosleep(tls *TLS, clk Tclockid_t, flags int32, req uintptr, rem uintptr) (r int32) +TEXT ·Y__clock_nanosleep(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL clk+8(FP), AX + MOVL AX, 8(SP) + MOVL flags+12(FP), AX + MOVL AX, 12(SP) + MOVQ req+16(FP), AX + MOVQ AX, 16(SP) + MOVQ rem+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__clock_nanosleep(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__cmsg_nxthdr(t *TLS, msgh, cmsg uintptr) (_2 uintptr) +TEXT ·Y__cmsg_nxthdr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msgh+8(FP), AX + MOVQ AX, 8(SP) + MOVQ cmsg+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__cmsg_nxthdr(SB) + MOVQ 24(SP), AX + MOVQ AX, _2+24(FP) + RET + +// func Y__convert_scm_timestamps(tls *TLS, msg uintptr, csize Tsocklen_t) +TEXT ·Y__convert_scm_timestamps(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msg+8(FP), AX + MOVQ AX, 8(SP) + MOVL csize+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__convert_scm_timestamps(SB) + RET + +// func Y__cos(tls *TLS, x float64, y float64) (r1 float64) +TEXT ·Y__cos(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__cos(SB) + MOVQ 24(SP), AX + MOVQ AX, r1+24(FP) + RET + +// func Y__cosdf(tls *TLS, x float64) (r1 float32) +TEXT ·Y__cosdf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__cosdf(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Y__crypt_blowfish(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) +TEXT ·Y__crypt_blowfish(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ setting+16(FP), AX + MOVQ AX, 16(SP) + MOVQ output+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__crypt_blowfish(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__crypt_des(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) +TEXT ·Y__crypt_des(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ setting+16(FP), AX + MOVQ AX, 16(SP) + MOVQ output+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__crypt_des(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__crypt_md5(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) +TEXT ·Y__crypt_md5(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ setting+16(FP), AX + MOVQ AX, 16(SP) + MOVQ output+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__crypt_md5(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__crypt_r(tls *TLS, key uintptr, salt uintptr, data uintptr) (r uintptr) +TEXT ·Y__crypt_r(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ salt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ data+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__crypt_r(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__crypt_sha256(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) +TEXT ·Y__crypt_sha256(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ setting+16(FP), AX + MOVQ AX, 16(SP) + MOVQ output+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__crypt_sha256(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__crypt_sha512(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) +TEXT ·Y__crypt_sha512(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ setting+16(FP), AX + MOVQ AX, 16(SP) + MOVQ output+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__crypt_sha512(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__ctype_b_loc(tls *TLS) (r uintptr) +TEXT ·Y__ctype_b_loc(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__ctype_b_loc(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__ctype_get_mb_cur_max(tls *TLS) (r Tsize_t) +TEXT ·Y__ctype_get_mb_cur_max(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__ctype_get_mb_cur_max(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__ctype_tolower_loc(tls *TLS) (r uintptr) +TEXT ·Y__ctype_tolower_loc(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__ctype_tolower_loc(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__ctype_toupper_loc(tls *TLS) (r uintptr) +TEXT ·Y__ctype_toupper_loc(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__ctype_toupper_loc(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__des_setkey(tls *TLS, key uintptr, ekey uintptr) +TEXT ·Y__des_setkey(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ekey+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__des_setkey(SB) + RET + +// func Y__dn_expand(tls *TLS, base uintptr, end uintptr, src uintptr, dest uintptr, space int32) (r int32) +TEXT ·Y__dn_expand(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ base+8(FP), AX + MOVQ AX, 8(SP) + MOVQ end+16(FP), AX + MOVQ AX, 16(SP) + MOVQ src+24(FP), AX + MOVQ AX, 24(SP) + MOVQ dest+32(FP), AX + MOVQ AX, 32(SP) + MOVL space+40(FP), AX + MOVL AX, 40(SP) + CALL ·X__dn_expand(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Y__dns_parse(tls *TLS, r uintptr, rlen int32, __ccgo_fp_callback uintptr, ctx uintptr) (r1 int32) +TEXT ·Y__dns_parse(SB),$56-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_callback+24(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal___dns_parse_2(SB) // Create the closure for calling __ccgo_fp_callback + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ r+8(FP), AX + MOVQ AX, 8(SP) + MOVL rlen+16(FP), AX + MOVL AX, 16(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 24(SP) + MOVQ ctx+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__dns_parse(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0___dns_parse_2(SB),$72-68 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVL _2+16(FP), AX + MOVL AX, 16(SP) + MOVQ _3+24(FP), AX + MOVQ AX, 24(SP) + MOVL _4+32(FP), AX + MOVL AX, 32(SP) + MOVQ _5+40(FP), AX + MOVQ AX, 40(SP) + MOVL _6+48(FP), AX + MOVL AX, 48(SP) + MOVQ __ccgo_fp+56(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 56(SP), AX + MOVL AX, _7+64(FP) + RET + +// func Y__do_des(tls *TLS, l_in Tuint32_t, r_in Tuint32_t, l_out uintptr, r_out uintptr, count Tuint32_t, saltbits Tuint32_t, ekey uintptr) +TEXT ·Y__do_des(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL l_in+8(FP), AX + MOVL AX, 8(SP) + MOVL r_in+12(FP), AX + MOVL AX, 12(SP) + MOVQ l_out+16(FP), AX + MOVQ AX, 16(SP) + MOVQ r_out+24(FP), AX + MOVQ AX, 24(SP) + MOVL count+32(FP), AX + MOVL AX, 32(SP) + MOVL saltbits+36(FP), AX + MOVL AX, 36(SP) + MOVQ ekey+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__do_des(SB) + RET + +// func Y__do_orphaned_stdio_locks(tls *TLS) +TEXT ·Y__do_orphaned_stdio_locks(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__do_orphaned_stdio_locks(SB) + RET + +// func Y__dup3(tls *TLS, old int32, new1 int32, flags int32) (r1 int32) +TEXT ·Y__dup3(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL old+8(FP), AX + MOVL AX, 8(SP) + MOVL new1+12(FP), AX + MOVL AX, 12(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__dup3(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Y__duplocale(tls *TLS, old Tlocale_t) (r Tlocale_t) +TEXT ·Y__duplocale(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ old+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__duplocale(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__env_rm_add(tls *TLS, old uintptr, new1 uintptr) +TEXT ·Y__env_rm_add(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ old+8(FP), AX + MOVQ AX, 8(SP) + MOVQ new1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__env_rm_add(SB) + RET + +// func Y__errno_location(tls *TLS) (r uintptr) +TEXT ·Y__errno_location(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__errno_location(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__execvpe(tls *TLS, file uintptr, argv uintptr, envp uintptr) (r int32) +TEXT ·Y__execvpe(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ file+8(FP), AX + MOVQ AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ envp+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__execvpe(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__expo2(tls *TLS, x float64, sign float64) (r float64) +TEXT ·Y__expo2(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sign+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__expo2(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__expo2f(tls *TLS, x float32, sign float32) (r float32) +TEXT ·Y__expo2f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL sign+12(FP), AX + MOVL AX, 12(SP) + CALL ·X__expo2f(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fbufsize(tls *TLS, f uintptr) (r Tsize_t) +TEXT ·Y__fbufsize(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fbufsize(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__fclose_ca(tls *TLS, f uintptr) (r int32) +TEXT ·Y__fclose_ca(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fclose_ca(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fdopen(tls *TLS, fd int32, mode uintptr) (r uintptr) +TEXT ·Y__fdopen(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ mode+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__fdopen(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__fesetround(tls *TLS, r int32) (r1 int32) +TEXT ·Y__fesetround(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL r+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__fesetround(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Y__fgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) +TEXT ·Y__fgetwc_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fgetwc_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__flbf(tls *TLS, f uintptr) (r int32) +TEXT ·Y__flbf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__flbf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__floatscan(tls *TLS, f uintptr, prec int32, pok int32) (r float64) +TEXT ·Y__floatscan(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVL prec+16(FP), AX + MOVL AX, 16(SP) + MOVL pok+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__floatscan(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__fmodeflags(tls *TLS, mode uintptr) (r int32) +TEXT ·Y__fmodeflags(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ mode+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fmodeflags(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fopen_rb_ca(tls *TLS, filename uintptr, f uintptr, buf uintptr, len1 Tsize_t) (r uintptr) +TEXT ·Y__fopen_rb_ca(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ len1+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__fopen_rb_ca(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Y__fpclassify(tls *TLS, x float64) (r int32) +TEXT ·Y__fpclassify(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fpclassify(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fpclassifyf(tls *TLS, x float32) (r int32) +TEXT ·Y__fpclassifyf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__fpclassifyf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fpclassifyl(tls *TLS, x float64) (r int32) +TEXT ·Y__fpclassifyl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fpclassifyl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fpending(tls *TLS, f uintptr) (r Tsize_t) +TEXT ·Y__fpending(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fpending(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__fpurge(tls *TLS, f uintptr) (r int32) +TEXT ·Y__fpurge(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fpurge(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) +TEXT ·Y__fputwc_unlocked(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__fputwc_unlocked(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__freadable(tls *TLS, f uintptr) (r int32) +TEXT ·Y__freadable(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__freadable(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__freadahead(tls *TLS, f uintptr) (r Tsize_t) +TEXT ·Y__freadahead(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__freadahead(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__freading(tls *TLS, f uintptr) (r int32) +TEXT ·Y__freading(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__freading(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__freadptr(tls *TLS, f uintptr, sizep uintptr) (r uintptr) +TEXT ·Y__freadptr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sizep+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__freadptr(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__freadptrinc(tls *TLS, f uintptr, inc Tsize_t) +TEXT ·Y__freadptrinc(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ inc+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__freadptrinc(SB) + RET + +// func Y__freelocale(tls *TLS, l Tlocale_t) +TEXT ·Y__freelocale(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__freelocale(SB) + RET + +// func Y__fseeko(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) +TEXT ·Y__fseeko(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ off+16(FP), AX + MOVQ AX, 16(SP) + MOVL whence+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__fseeko(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__fseeko_unlocked(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) +TEXT ·Y__fseeko_unlocked(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ off+16(FP), AX + MOVQ AX, 16(SP) + MOVL whence+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__fseeko_unlocked(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__fseterr(tls *TLS, f uintptr) +TEXT ·Y__fseterr(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fseterr(SB) + RET + +// func Y__fsetlocking(tls *TLS, f uintptr, type1 int32) (r int32) +TEXT ·Y__fsetlocking(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVL type1+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__fsetlocking(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__fstat(tls *TLS, fd int32, st uintptr) (r int32) +TEXT ·Y__fstat(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ st+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__fstat(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__fstatat(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) +TEXT ·Y__fstatat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVQ st+24(FP), AX + MOVQ AX, 24(SP) + MOVL flag+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__fstatat(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Y__ftello(tls *TLS, f uintptr) (r Toff_t) +TEXT ·Y__ftello(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__ftello(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__ftello_unlocked(tls *TLS, f uintptr) (r Toff_t) +TEXT ·Y__ftello_unlocked(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__ftello_unlocked(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__funcs_on_quick_exit(tls *TLS) +TEXT ·Y__funcs_on_quick_exit(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__funcs_on_quick_exit(SB) + RET + +// func Y__futimesat(tls *TLS, dirfd int32, pathname uintptr, times uintptr) (r int32) +TEXT ·Y__futimesat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL dirfd+8(FP), AX + MOVL AX, 8(SP) + MOVQ pathname+16(FP), AX + MOVQ AX, 16(SP) + MOVQ times+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__futimesat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__fwritable(tls *TLS, f uintptr) (r int32) +TEXT ·Y__fwritable(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fwritable(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fwritex(tls *TLS, s uintptr, l Tsize_t, f uintptr) (r Tsize_t) +TEXT ·Y__fwritex(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__fwritex(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__fwriting(tls *TLS, f uintptr) (r int32) +TEXT ·Y__fwriting(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__fwriting(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__fxstat(tls *TLS, ver int32, fd int32, buf uintptr) (r int32) +TEXT ·Y__fxstat(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ver+8(FP), AX + MOVL AX, 8(SP) + MOVL fd+12(FP), AX + MOVL AX, 12(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__fxstat(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__fxstatat(tls *TLS, ver int32, fd int32, path uintptr, buf uintptr, flag int32) (r int32) +TEXT ·Y__fxstatat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ver+8(FP), AX + MOVL AX, 8(SP) + MOVL fd+12(FP), AX + MOVL AX, 12(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVL flag+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__fxstatat(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Y__get_handler_set(tls *TLS, set uintptr) +TEXT ·Y__get_handler_set(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__get_handler_set(SB) + RET + +// func Y__get_locale(tls *TLS, cat int32, val uintptr) (r uintptr) +TEXT ·Y__get_locale(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL cat+8(FP), AX + MOVL AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__get_locale(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__get_resolv_conf(tls *TLS, conf uintptr, search uintptr, search_sz Tsize_t) (r int32) +TEXT ·Y__get_resolv_conf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ conf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ search+16(FP), AX + MOVQ AX, 16(SP) + MOVQ search_sz+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__get_resolv_conf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__getauxval(tls *TLS, item uint64) (r uint64) +TEXT ·Y__getauxval(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ item+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__getauxval(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__getdelim(tls *TLS, s uintptr, n uintptr, delim int32, f uintptr) (r Tssize_t) +TEXT ·Y__getdelim(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVL delim+24(FP), AX + MOVL AX, 24(SP) + MOVQ f+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__getdelim(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Y__getgr_a(tls *TLS, name uintptr, gid Tgid_t, gr uintptr, buf uintptr, size uintptr, mem uintptr, nmem uintptr, res uintptr) (r int32) +TEXT ·Y__getgr_a(SB),$80-76 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVL gid+16(FP), AX + MOVL AX, 16(SP) + MOVQ gr+24(FP), AX + MOVQ AX, 24(SP) + MOVQ buf+32(FP), AX + MOVQ AX, 32(SP) + MOVQ size+40(FP), AX + MOVQ AX, 40(SP) + MOVQ mem+48(FP), AX + MOVQ AX, 48(SP) + MOVQ nmem+56(FP), AX + MOVQ AX, 56(SP) + MOVQ res+64(FP), AX + MOVQ AX, 64(SP) + CALL ·X__getgr_a(SB) + MOVL 72(SP), AX + MOVL AX, r+72(FP) + RET + +// func Y__getgrent_a(tls *TLS, f uintptr, gr uintptr, line uintptr, size uintptr, mem uintptr, nmem uintptr, res uintptr) (r int32) +TEXT ·Y__getgrent_a(SB),$72-68 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ gr+16(FP), AX + MOVQ AX, 16(SP) + MOVQ line+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVQ mem+40(FP), AX + MOVQ AX, 40(SP) + MOVQ nmem+48(FP), AX + MOVQ AX, 48(SP) + MOVQ res+56(FP), AX + MOVQ AX, 56(SP) + CALL ·X__getgrent_a(SB) + MOVL 64(SP), AX + MOVL AX, r+64(FP) + RET + +// func Y__getopt_msg(tls *TLS, a uintptr, b uintptr, c uintptr, l Tsize_t) +TEXT ·Y__getopt_msg(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + MOVQ c+24(FP), AX + MOVQ AX, 24(SP) + MOVQ l+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__getopt_msg(SB) + RET + +// func Y__getpw_a(tls *TLS, name uintptr, uid Tuid_t, pw uintptr, buf uintptr, size uintptr, res uintptr) (r int32) +TEXT ·Y__getpw_a(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVL uid+16(FP), AX + MOVL AX, 16(SP) + MOVQ pw+24(FP), AX + MOVQ AX, 24(SP) + MOVQ buf+32(FP), AX + MOVQ AX, 32(SP) + MOVQ size+40(FP), AX + MOVQ AX, 40(SP) + MOVQ res+48(FP), AX + MOVQ AX, 48(SP) + CALL ·X__getpw_a(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Y__getpwent_a(tls *TLS, f uintptr, pw uintptr, line uintptr, size uintptr, res uintptr) (r int32) +TEXT ·Y__getpwent_a(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ pw+16(FP), AX + MOVQ AX, 16(SP) + MOVQ line+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVQ res+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__getpwent_a(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Y__gettextdomain(tls *TLS) (r uintptr) +TEXT ·Y__gettextdomain(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__gettextdomain(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__gmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) +TEXT ·Y__gmtime_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ tm+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__gmtime_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__h_errno_location(tls *TLS) (r uintptr) +TEXT ·Y__h_errno_location(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__h_errno_location(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__inet_aton(tls *TLS, s0 uintptr, dest uintptr) (r int32) +TEXT ·Y__inet_aton(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s0+8(FP), AX + MOVQ AX, 8(SP) + MOVQ dest+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__inet_aton(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__init_ssp(tls *TLS, entropy uintptr) +TEXT ·Y__init_ssp(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ entropy+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__init_ssp(SB) + RET + +// func Y__intscan(tls *TLS, f uintptr, base uint32, pok int32, lim uint64) (r uint64) +TEXT ·Y__intscan(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVL base+16(FP), AX + MOVL AX, 16(SP) + MOVL pok+20(FP), AX + MOVL AX, 20(SP) + MOVQ lim+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__intscan(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__isalnum_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isalnum_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isalnum_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isalpha_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isalpha_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isalpha_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isblank_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isblank_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isblank_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iscntrl_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__iscntrl_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iscntrl_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isdigit_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isdigit_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isfinite(tls *TLS, d float64) (_2 int32) +TEXT ·Y__isfinite(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__isfinite(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__isfinitef(tls *TLS, f float32) (_2 int32) +TEXT ·Y__isfinitef(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL f+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__isfinitef(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__isfinitel(tls *TLS, d float64) (_2 int32) +TEXT ·Y__isfinitel(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__isfinitel(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__isgraph_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isgraph_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isgraph_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__islower_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__islower_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__islower_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isnan(t *TLS, x float64) (_2 int32) +TEXT ·Y__isnan(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__isnan(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__isnanf(t *TLS, arg float32) (_2 int32) +TEXT ·Y__isnanf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL arg+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__isnanf(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__isnanl(t *TLS, arg float64) (_2 int32) +TEXT ·Y__isnanl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ arg+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__isnanl(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__isoc99_fscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Y__isoc99_fscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__isoc99_fscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__isoc99_fwscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Y__isoc99_fwscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__isoc99_fwscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__isoc99_scanf(tls *TLS, fmt uintptr, va uintptr) (r int32) +TEXT ·Y__isoc99_scanf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isoc99_scanf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isoc99_sscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Y__isoc99_sscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__isoc99_sscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__isoc99_swscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Y__isoc99_swscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__isoc99_swscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__isoc99_vfscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Y__isoc99_vfscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__isoc99_vfscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__isoc99_vfwscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Y__isoc99_vfwscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__isoc99_vfwscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__isoc99_vscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Y__isoc99_vscanf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isoc99_vscanf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isoc99_vsscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Y__isoc99_vsscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__isoc99_vsscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__isoc99_vswscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Y__isoc99_vswscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__isoc99_vswscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__isoc99_vwscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Y__isoc99_vwscanf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isoc99_vwscanf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isoc99_wscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) +TEXT ·Y__isoc99_wscanf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isoc99_wscanf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isprint_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isprint_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isprint_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__ispunct_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__ispunct_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__ispunct_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isspace_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isspace_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isspace_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isupper_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isupper_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswalnum_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswalnum_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswalnum_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswalpha_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswalpha_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswalpha_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswblank_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswblank_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswblank_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswcntrl_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswcntrl_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswcntrl_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswctype_l(tls *TLS, c Twint_t, t Twctype_t, l Tlocale_t) (r int32) +TEXT ·Y__iswctype_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ t+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__iswctype_l(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__iswdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswdigit_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswdigit_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswgraph_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswgraph_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswgraph_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswlower_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswlower_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswprint_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswprint_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswprint_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswpunct_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswpunct_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswpunct_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswspace_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswspace_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswspace_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswupper_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswupper_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__iswxdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Y__iswxdigit_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__iswxdigit_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__isxdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__isxdigit_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__isxdigit_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__lctrans(tls *TLS, msg uintptr, lm uintptr) (r uintptr) +TEXT ·Y__lctrans(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msg+8(FP), AX + MOVQ AX, 8(SP) + MOVQ lm+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__lctrans(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__lctrans_cur(tls *TLS, msg uintptr) (r uintptr) +TEXT ·Y__lctrans_cur(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msg+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__lctrans_cur(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__lctrans_impl(tls *TLS, msg uintptr, lm uintptr) (r uintptr) +TEXT ·Y__lctrans_impl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msg+8(FP), AX + MOVQ AX, 8(SP) + MOVQ lm+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__lctrans_impl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__ldexp_cexp(tls *TLS, z complex128, expt int32) (r complex128) +TEXT ·Y__ldexp_cexp(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + MOVL expt+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__ldexp_cexp(SB) + MOVQ 32(SP), AX + MOVQ AX, r_real+32(FP) + MOVQ 40(SP), AX + MOVQ AX, r_imag+40(FP) + RET + +// func Y__ldexp_cexpf(tls *TLS, z complex64, expt int32) (r complex64) +TEXT ·Y__ldexp_cexpf(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + MOVL expt+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__ldexp_cexpf(SB) + MOVL 24(SP), AX + MOVL AX, r_real+24(FP) + MOVL 28(SP), AX + MOVL AX, r_imag+28(FP) + RET + +// func Y__lgamma_r(tls *TLS, x float64, signgamp uintptr) (r1 float64) +TEXT ·Y__lgamma_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ signgamp+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__lgamma_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r1+24(FP) + RET + +// func Y__lgammaf_r(tls *TLS, x float32, signgamp uintptr) (r1 float32) +TEXT ·Y__lgammaf_r(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVQ signgamp+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__lgammaf_r(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Y__lgammal_r(tls *TLS, x float64, sg uintptr) (r float64) +TEXT ·Y__lgammal_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sg+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__lgammal_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__libc_current_sigrtmax(tls *TLS) (r int32) +TEXT ·Y__libc_current_sigrtmax(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__libc_current_sigrtmax(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Y__libc_current_sigrtmin(tls *TLS) (r int32) +TEXT ·Y__libc_current_sigrtmin(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__libc_current_sigrtmin(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Y__libc_sigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r1 int32) +TEXT ·Y__libc_sigaction(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sig+8(FP), AX + MOVL AX, 8(SP) + MOVQ sa+16(FP), AX + MOVQ AX, 16(SP) + MOVQ old+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__libc_sigaction(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Y__loc_is_allocated(tls *TLS, loc Tlocale_t) (r int32) +TEXT ·Y__loc_is_allocated(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ loc+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__loc_is_allocated(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__localtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) +TEXT ·Y__localtime_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ tm+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__localtime_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__lockfile(tls *TLS, file uintptr) (_2 int32) +TEXT ·Y__lockfile(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ file+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__lockfile(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Y__lookup_ipliteral(tls *TLS, buf uintptr, name uintptr, family int32) (r int32) +TEXT ·Y__lookup_ipliteral(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVL family+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__lookup_ipliteral(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__lookup_name(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, flags int32) (r int32) +TEXT ·Y__lookup_name(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ canon+16(FP), AX + MOVQ AX, 16(SP) + MOVQ name+24(FP), AX + MOVQ AX, 24(SP) + MOVL family+32(FP), AX + MOVL AX, 32(SP) + MOVL flags+36(FP), AX + MOVL AX, 36(SP) + CALL ·X__lookup_name(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Y__lookup_serv(tls *TLS, buf uintptr, name uintptr, proto int32, socktype int32, flags int32) (r int32) +TEXT ·Y__lookup_serv(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVL proto+24(FP), AX + MOVL AX, 24(SP) + MOVL socktype+28(FP), AX + MOVL AX, 28(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__lookup_serv(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Y__lseek(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) +TEXT ·Y__lseek(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ offset+16(FP), AX + MOVQ AX, 16(SP) + MOVL whence+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__lseek(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__lsysinfo(tls *TLS, info uintptr) (r int32) +TEXT ·Y__lsysinfo(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ info+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__lsysinfo(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__lxstat(tls *TLS, ver int32, path uintptr, buf uintptr) (r int32) +TEXT ·Y__lxstat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ver+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__lxstat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__madvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) +TEXT ·Y__madvise(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL advice+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__madvise(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__map_file(tls *TLS, pathname uintptr, size uintptr) (r uintptr) +TEXT ·Y__map_file(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ pathname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__map_file(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__math_divzero(tls *TLS, sign Tuint32_t) (r float64) +TEXT ·Y__math_divzero(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sign+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__math_divzero(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__math_divzerof(tls *TLS, sign Tuint32_t) (r float32) +TEXT ·Y__math_divzerof(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sign+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__math_divzerof(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__math_invalid(tls *TLS, x float64) (r float64) +TEXT ·Y__math_invalid(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__math_invalid(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__math_invalidf(tls *TLS, x float32) (r float32) +TEXT ·Y__math_invalidf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__math_invalidf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__math_oflow(tls *TLS, sign Tuint32_t) (r float64) +TEXT ·Y__math_oflow(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sign+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__math_oflow(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__math_oflowf(tls *TLS, sign Tuint32_t) (r float32) +TEXT ·Y__math_oflowf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sign+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__math_oflowf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__math_uflow(tls *TLS, sign Tuint32_t) (r float64) +TEXT ·Y__math_uflow(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sign+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__math_uflow(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__math_uflowf(tls *TLS, sign Tuint32_t) (r float32) +TEXT ·Y__math_uflowf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sign+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__math_uflowf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__math_xflow(tls *TLS, sign Tuint32_t, y2 float64) (r float64) +TEXT ·Y__math_xflow(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sign+8(FP), AX + MOVL AX, 8(SP) + MOVQ y2+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__math_xflow(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__math_xflowf(tls *TLS, sign Tuint32_t, y2 float32) (r float32) +TEXT ·Y__math_xflowf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sign+8(FP), AX + MOVL AX, 8(SP) + MOVL y2+12(FP), AX + MOVL AX, 12(SP) + CALL ·X__math_xflowf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__memrchr(tls *TLS, m uintptr, c int32, n Tsize_t) (r uintptr) +TEXT ·Y__memrchr(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__memrchr(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__mkostemps(tls *TLS, template uintptr, len1 int32, flags int32) (r int32) +TEXT ·Y__mkostemps(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + MOVL len1+16(FP), AX + MOVL AX, 16(SP) + MOVL flags+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__mkostemps(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__mmap(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) +TEXT ·Y__mmap(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ start+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL prot+24(FP), AX + MOVL AX, 24(SP) + MOVL flags+28(FP), AX + MOVL AX, 28(SP) + MOVL fd+32(FP), AX + MOVL AX, 32(SP) + MOVQ off+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__mmap(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Y__mo_lookup(tls *TLS, p uintptr, size Tsize_t, s uintptr) (r uintptr) +TEXT ·Y__mo_lookup(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVQ s+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__mo_lookup(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__month_to_secs(tls *TLS, month int32, is_leap int32) (r int32) +TEXT ·Y__month_to_secs(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL month+8(FP), AX + MOVL AX, 8(SP) + MOVL is_leap+12(FP), AX + MOVL AX, 12(SP) + CALL ·X__month_to_secs(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__mprotect(tls *TLS, addr uintptr, len1 Tsize_t, prot int32) (r int32) +TEXT ·Y__mprotect(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL prot+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__mprotect(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__mremap(tls *TLS, old_addr uintptr, old_len Tsize_t, new_len Tsize_t, flags int32, va uintptr) (r uintptr) +TEXT ·Y__mremap(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ old_addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ old_len+16(FP), AX + MOVQ AX, 16(SP) + MOVQ new_len+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + MOVQ va+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__mremap(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Y__munmap(tls *TLS, start uintptr, len1 Tsize_t) (r int32) +TEXT ·Y__munmap(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ start+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__munmap(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__newlocale(tls *TLS, mask int32, name uintptr, loc Tlocale_t) (r Tlocale_t) +TEXT ·Y__newlocale(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL mask+8(FP), AX + MOVL AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ loc+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__newlocale(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__nl_langinfo(tls *TLS, item Tnl_item) (r uintptr) +TEXT ·Y__nl_langinfo(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL item+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__nl_langinfo(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__nl_langinfo_l(tls *TLS, item Tnl_item, loc Tlocale_t) (r uintptr) +TEXT ·Y__nl_langinfo_l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL item+8(FP), AX + MOVL AX, 8(SP) + MOVQ loc+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__nl_langinfo_l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__nscd_query(tls *TLS, req Tint32_t, key uintptr, buf uintptr, len1 Tsize_t, swap uintptr) (r uintptr) +TEXT ·Y__nscd_query(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL req+8(FP), AX + MOVL AX, 8(SP) + MOVQ key+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ len1+32(FP), AX + MOVQ AX, 32(SP) + MOVQ swap+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__nscd_query(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Y__ofl_add(tls *TLS, f uintptr) (r uintptr) +TEXT ·Y__ofl_add(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__ofl_add(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__ofl_lock(tls *TLS) (r uintptr) +TEXT ·Y__ofl_lock(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__ofl_lock(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__ofl_unlock(tls *TLS) +TEXT ·Y__ofl_unlock(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__ofl_unlock(SB) + RET + +// func Y__overflow(tls *TLS, f uintptr, _c int32) (r int32) +TEXT ·Y__overflow(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVL _c+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__overflow(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__pleval(tls *TLS, s uintptr, n uint64) (r uint64) +TEXT ·Y__pleval(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__pleval(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__posix_getopt(tls *TLS, argc int32, argv uintptr, optstring uintptr) (r int32) +TEXT ·Y__posix_getopt(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL argc+8(FP), AX + MOVL AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ optstring+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__posix_getopt(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__procfdname(tls *TLS, buf uintptr, fd uint32) +TEXT ·Y__procfdname(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVL fd+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__procfdname(SB) + RET + +// func Y__ptsname_r(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) +TEXT ·Y__ptsname_r(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__ptsname_r(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__putenv(tls *TLS, s uintptr, l Tsize_t, r uintptr) (r1 int32) +TEXT ·Y__putenv(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + MOVQ r+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__putenv(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Y__qsort_r(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr) +TEXT ·Y__qsort_r(SB),$56-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cmp+32(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal___qsort_r_3(SB) // Create the closure for calling __ccgo_fp_cmp + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ base+8(FP), AX + MOVQ AX, 8(SP) + MOVQ nel+16(FP), AX + MOVQ AX, 16(SP) + MOVQ width+24(FP), AX + MOVQ AX, 24(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 32(SP) + MOVQ arg+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__qsort_r(SB) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0___qsort_r_3(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ _3+24(FP), AX + MOVQ AX, 24(SP) + MOVQ __ccgo_fp+32(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 32(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y__rand48_step(tls *TLS, xi uintptr, lc uintptr) (r Tuint64_t) +TEXT ·Y__rand48_step(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ xi+8(FP), AX + MOVQ AX, 8(SP) + MOVQ lc+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__rand48_step(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__register_locked_file(tls *TLS, f uintptr, self Tpthread_t) +TEXT ·Y__register_locked_file(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ self+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__register_locked_file(SB) + RET + +// func Y__rem_pio2(tls *TLS, x float64, y uintptr) (r1 int32) +TEXT ·Y__rem_pio2(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__rem_pio2(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Y__rem_pio2_large(tls *TLS, x uintptr, y uintptr, e0 int32, nx int32, prec int32) (r int32) +TEXT ·Y__rem_pio2_large(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + MOVL e0+24(FP), AX + MOVL AX, 24(SP) + MOVL nx+28(FP), AX + MOVL AX, 28(SP) + MOVL prec+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__rem_pio2_large(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Y__rem_pio2f(tls *TLS, x float32, y uintptr) (r int32) +TEXT ·Y__rem_pio2f(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__rem_pio2f(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__res_mkquery(tls *TLS, op int32, dname uintptr, class int32, type1 int32, data uintptr, datalen int32, newrr uintptr, buf uintptr, buflen int32) (r int32) +TEXT ·Y__res_mkquery(SB),$80-76 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL op+8(FP), AX + MOVL AX, 8(SP) + MOVQ dname+16(FP), AX + MOVQ AX, 16(SP) + MOVL class+24(FP), AX + MOVL AX, 24(SP) + MOVL type1+28(FP), AX + MOVL AX, 28(SP) + MOVQ data+32(FP), AX + MOVQ AX, 32(SP) + MOVL datalen+40(FP), AX + MOVL AX, 40(SP) + MOVQ newrr+48(FP), AX + MOVQ AX, 48(SP) + MOVQ buf+56(FP), AX + MOVQ AX, 56(SP) + MOVL buflen+64(FP), AX + MOVL AX, 64(SP) + CALL ·X__res_mkquery(SB) + MOVL 72(SP), AX + MOVL AX, r+72(FP) + RET + +// func Y__res_msend(tls *TLS, nqueries int32, queries uintptr, qlens uintptr, answers uintptr, alens uintptr, asize int32) (r int32) +TEXT ·Y__res_msend(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL nqueries+8(FP), AX + MOVL AX, 8(SP) + MOVQ queries+16(FP), AX + MOVQ AX, 16(SP) + MOVQ qlens+24(FP), AX + MOVQ AX, 24(SP) + MOVQ answers+32(FP), AX + MOVQ AX, 32(SP) + MOVQ alens+40(FP), AX + MOVQ AX, 40(SP) + MOVL asize+48(FP), AX + MOVL AX, 48(SP) + CALL ·X__res_msend(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Y__res_msend_rc(tls *TLS, nqueries int32, queries uintptr, qlens uintptr, answers uintptr, alens uintptr, asize int32, conf uintptr) (r1 int32) +TEXT ·Y__res_msend_rc(SB),$72-68 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL nqueries+8(FP), AX + MOVL AX, 8(SP) + MOVQ queries+16(FP), AX + MOVQ AX, 16(SP) + MOVQ qlens+24(FP), AX + MOVQ AX, 24(SP) + MOVQ answers+32(FP), AX + MOVQ AX, 32(SP) + MOVQ alens+40(FP), AX + MOVQ AX, 40(SP) + MOVL asize+48(FP), AX + MOVL AX, 48(SP) + MOVQ conf+56(FP), AX + MOVQ AX, 56(SP) + CALL ·X__res_msend_rc(SB) + MOVL 64(SP), AX + MOVL AX, r1+64(FP) + RET + +// func Y__res_send(tls *TLS, _msg uintptr, _msglen int32, _answer uintptr, _anslen int32) (r1 int32) +TEXT ·Y__res_send(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _msg+8(FP), AX + MOVQ AX, 8(SP) + MOVL _msglen+16(FP), AX + MOVL AX, 16(SP) + MOVQ _answer+24(FP), AX + MOVQ AX, 24(SP) + MOVL _anslen+32(FP), AX + MOVL AX, 32(SP) + CALL ·X__res_send(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Y__res_state(tls *TLS) (r uintptr) +TEXT ·Y__res_state(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__res_state(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Y__reset_tls(tls *TLS) +TEXT ·Y__reset_tls(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__reset_tls(SB) + RET + +// func Y__restore(tls *TLS) +TEXT ·Y__restore(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__restore(SB) + RET + +// func Y__restore_rt(tls *TLS) +TEXT ·Y__restore_rt(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__restore_rt(SB) + RET + +// func Y__restore_sigs(tls *TLS, set uintptr) +TEXT ·Y__restore_sigs(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__restore_sigs(SB) + RET + +// func Y__rtnetlink_enumerate(tls *TLS, link_af int32, addr_af int32, __ccgo_fp_cb uintptr, ctx uintptr) (r1 int32) +TEXT ·Y__rtnetlink_enumerate(SB),$48-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cb+16(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal___rtnetlink_enumerate_2(SB) // Create the closure for calling __ccgo_fp_cb + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL link_af+8(FP), AX + MOVL AX, 8(SP) + MOVL addr_af+12(FP), AX + MOVL AX, 12(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 24(SP) + MOVQ ctx+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__rtnetlink_enumerate(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0___rtnetlink_enumerate_2(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Y__secs_to_tm(tls *TLS, t int64, tm uintptr) (r int32) +TEXT ·Y__secs_to_tm(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ tm+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__secs_to_tm(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__secs_to_zone(tls *TLS, t int64, local int32, isdst uintptr, offset uintptr, oppoff uintptr, zonename uintptr) +TEXT ·Y__secs_to_zone(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVL local+16(FP), AX + MOVL AX, 16(SP) + MOVQ isdst+24(FP), AX + MOVQ AX, 24(SP) + MOVQ offset+32(FP), AX + MOVQ AX, 32(SP) + MOVQ oppoff+40(FP), AX + MOVQ AX, 40(SP) + MOVQ zonename+48(FP), AX + MOVQ AX, 48(SP) + CALL ·X__secs_to_zone(SB) + RET + +// func Y__setxid(tls *TLS, nr int32, id int32, eid int32, sid int32) (r int32) +TEXT ·Y__setxid(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL nr+8(FP), AX + MOVL AX, 8(SP) + MOVL id+12(FP), AX + MOVL AX, 12(SP) + MOVL eid+16(FP), AX + MOVL AX, 16(SP) + MOVL sid+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__setxid(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__shgetc(tls *TLS, f uintptr) (r int32) +TEXT ·Y__shgetc(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__shgetc(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__shlim(tls *TLS, f uintptr, lim Toff_t) +TEXT ·Y__shlim(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ lim+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__shlim(SB) + RET + +// func Y__shm_mapname(tls *TLS, name uintptr, buf uintptr) (r uintptr) +TEXT ·Y__shm_mapname(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__shm_mapname(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__sigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r1 int32) +TEXT ·Y__sigaction(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sig+8(FP), AX + MOVL AX, 8(SP) + MOVQ sa+16(FP), AX + MOVQ AX, 16(SP) + MOVQ old+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__sigaction(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Y__signbit(tls *TLS, x float64) (r int32) +TEXT ·Y__signbit(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__signbit(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__signbitf(tls *TLS, x float32) (r int32) +TEXT ·Y__signbitf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·X__signbitf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__signbitl(tls *TLS, x float64) (r int32) +TEXT ·Y__signbitl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__signbitl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__sigsetjmp_tail(tls *TLS, jb uintptr, ret int32) (r int32) +TEXT ·Y__sigsetjmp_tail(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ jb+8(FP), AX + MOVQ AX, 8(SP) + MOVL ret+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__sigsetjmp_tail(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__sin(tls *TLS, x float64, y float64, iy int32) (r1 float64) +TEXT ·Y__sin(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + MOVL iy+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__sin(SB) + MOVQ 32(SP), AX + MOVQ AX, r1+32(FP) + RET + +// func Y__sindf(tls *TLS, x float64) (r1 float32) +TEXT ·Y__sindf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__sindf(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Y__stack_chk_fail(tls *TLS) +TEXT ·Y__stack_chk_fail(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__stack_chk_fail(SB) + RET + +// func Y__stack_chk_fail_local(tls *TLS) +TEXT ·Y__stack_chk_fail_local(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__stack_chk_fail_local(SB) + RET + +// func Y__stdio_close(tls *TLS, f uintptr) (r int32) +TEXT ·Y__stdio_close(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__stdio_close(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__stdio_exit(tls *TLS) +TEXT ·Y__stdio_exit(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__stdio_exit(SB) + RET + +// func Y__stdio_exit_needed(tls *TLS) +TEXT ·Y__stdio_exit_needed(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__stdio_exit_needed(SB) + RET + +// func Y__stdio_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) +TEXT ·Y__stdio_read(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__stdio_read(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__stdio_seek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) +TEXT ·Y__stdio_seek(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ off+16(FP), AX + MOVQ AX, 16(SP) + MOVL whence+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__stdio_seek(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__stdio_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) +TEXT ·Y__stdio_write(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__stdio_write(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__stdout_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) +TEXT ·Y__stdout_write(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__stdout_write(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__stpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) +TEXT ·Y__stpcpy(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__stpcpy(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__stpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Y__stpncpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__stpncpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strcasecmp_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) +TEXT ·Y__strcasecmp_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ loc+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__strcasecmp_l(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Y__strchrnul(tls *TLS, s uintptr, c int32) (r uintptr) +TEXT ·Y__strchrnul(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__strchrnul(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__strcoll_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) +TEXT ·Y__strcoll_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ loc+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__strcoll_l(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Y__strerror_l(tls *TLS, e int32, loc Tlocale_t) (r uintptr) +TEXT ·Y__strerror_l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL e+8(FP), AX + MOVL AX, 8(SP) + MOVQ loc+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__strerror_l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__strftime_fmt_1(tls *TLS, s uintptr, l uintptr, f int32, tm uintptr, loc Tlocale_t, pad int32) (r uintptr) +TEXT ·Y__strftime_fmt_1(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + MOVL f+24(FP), AX + MOVL AX, 24(SP) + MOVQ tm+32(FP), AX + MOVQ AX, 32(SP) + MOVQ loc+40(FP), AX + MOVQ AX, 40(SP) + MOVL pad+48(FP), AX + MOVL AX, 48(SP) + CALL ·X__strftime_fmt_1(SB) + MOVQ 56(SP), AX + MOVQ AX, r+56(FP) + RET + +// func Y__strftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) +TEXT ·Y__strftime_l(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + MOVQ tm+32(FP), AX + MOVQ AX, 32(SP) + MOVQ loc+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__strftime_l(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Y__strncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, loc Tlocale_t) (r1 int32) +TEXT ·Y__strncasecmp_l(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ loc+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__strncasecmp_l(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Y__strtod_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) +TEXT ·Y__strtod_l(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__strtod_l(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strtof_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float32) +TEXT ·Y__strtof_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__strtof_l(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__strtoimax_internal(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) +TEXT ·Y__strtoimax_internal(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__strtoimax_internal(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strtol_internal(tls *TLS, s uintptr, p uintptr, base int32) (r int64) +TEXT ·Y__strtol_internal(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__strtol_internal(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strtold_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) +TEXT ·Y__strtold_l(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__strtold_l(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strtoll_internal(tls *TLS, s uintptr, p uintptr, base int32) (r int64) +TEXT ·Y__strtoll_internal(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__strtoll_internal(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strtoul_internal(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) +TEXT ·Y__strtoul_internal(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__strtoul_internal(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strtoull_internal(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) +TEXT ·Y__strtoull_internal(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__strtoull_internal(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strtoumax_internal(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) +TEXT ·Y__strtoumax_internal(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__strtoumax_internal(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__strxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) +TEXT ·Y__strxfrm_l(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ loc+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__strxfrm_l(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Y__sync_synchronize(t *TLS) +TEXT ·Y__sync_synchronize(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__sync_synchronize(SB) + RET + +// func Y__sync_val_compare_and_swapInt16(t *TLS, ptr uintptr, oldval, newval int16) (r int16) +TEXT ·Y__sync_val_compare_and_swapInt16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW oldval+16(FP), AX + MOVW AX, 16(SP) + MOVW newval+18(FP), AX + MOVW AX, 18(SP) + CALL ·X__sync_val_compare_and_swapInt16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__sync_val_compare_and_swapInt32(t *TLS, ptr uintptr, oldval, newval int32) (r int32) +TEXT ·Y__sync_val_compare_and_swapInt32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL oldval+16(FP), AX + MOVL AX, 16(SP) + MOVL newval+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__sync_val_compare_and_swapInt32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__sync_val_compare_and_swapInt64(t *TLS, ptr uintptr, oldval, newval int64) (r int64) +TEXT ·Y__sync_val_compare_and_swapInt64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ oldval+16(FP), AX + MOVQ AX, 16(SP) + MOVQ newval+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__sync_val_compare_and_swapInt64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__sync_val_compare_and_swapInt8(t *TLS, ptr uintptr, oldval, newval int8) (r int8) +TEXT ·Y__sync_val_compare_and_swapInt8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB oldval+16(FP), AX + MOVB AX, 16(SP) + MOVB newval+17(FP), AX + MOVB AX, 17(SP) + CALL ·X__sync_val_compare_and_swapInt8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__sync_val_compare_and_swapUint16(t *TLS, ptr uintptr, oldval, newval uint16) (r uint16) +TEXT ·Y__sync_val_compare_and_swapUint16(SB),$32-26 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVW oldval+16(FP), AX + MOVW AX, 16(SP) + MOVW newval+18(FP), AX + MOVW AX, 18(SP) + CALL ·X__sync_val_compare_and_swapUint16(SB) + MOVW 24(SP), AX + MOVW AX, r+24(FP) + RET + +// func Y__sync_val_compare_and_swapUint32(t *TLS, ptr uintptr, oldval, newval uint32) (r uint32) +TEXT ·Y__sync_val_compare_and_swapUint32(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVL oldval+16(FP), AX + MOVL AX, 16(SP) + MOVL newval+20(FP), AX + MOVL AX, 20(SP) + CALL ·X__sync_val_compare_and_swapUint32(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__sync_val_compare_and_swapUint64(t *TLS, ptr uintptr, oldval, newval uint64) (r uint64) +TEXT ·Y__sync_val_compare_and_swapUint64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ oldval+16(FP), AX + MOVQ AX, 16(SP) + MOVQ newval+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__sync_val_compare_and_swapUint64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Y__sync_val_compare_and_swapUint8(t *TLS, ptr uintptr, oldval, newval uint8) (r uint8) +TEXT ·Y__sync_val_compare_and_swapUint8(SB),$32-25 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVB oldval+16(FP), AX + MOVB AX, 16(SP) + MOVB newval+17(FP), AX + MOVB AX, 17(SP) + CALL ·X__sync_val_compare_and_swapUint8(SB) + MOVB 24(SP), AX + MOVB AX, r+24(FP) + RET + +// func Y__syscall0(tls *TLS, n long) (_2 long) +TEXT ·Y__syscall0(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__syscall0(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Y__syscall1(tls *TLS, n, a1 long) (_2 long) +TEXT ·Y__syscall1(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__syscall1(SB) + MOVQ 24(SP), AX + MOVQ AX, _2+24(FP) + RET + +// func Y__syscall2(tls *TLS, n, a1, a2 long) (_2 long) +TEXT ·Y__syscall2(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ a2+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__syscall2(SB) + MOVQ 32(SP), AX + MOVQ AX, _2+32(FP) + RET + +// func Y__syscall3(tls *TLS, n, a1, a2, a3 long) (_2 long) +TEXT ·Y__syscall3(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ a2+24(FP), AX + MOVQ AX, 24(SP) + MOVQ a3+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__syscall3(SB) + MOVQ 40(SP), AX + MOVQ AX, _2+40(FP) + RET + +// func Y__syscall4(tls *TLS, n, a1, a2, a3, a4 long) (_2 long) +TEXT ·Y__syscall4(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ a2+24(FP), AX + MOVQ AX, 24(SP) + MOVQ a3+32(FP), AX + MOVQ AX, 32(SP) + MOVQ a4+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__syscall4(SB) + MOVQ 48(SP), AX + MOVQ AX, _2+48(FP) + RET + +// func Y__syscall5(tls *TLS, n, a1, a2, a3, a4, a5 long) (_2 long) +TEXT ·Y__syscall5(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ a2+24(FP), AX + MOVQ AX, 24(SP) + MOVQ a3+32(FP), AX + MOVQ AX, 32(SP) + MOVQ a4+40(FP), AX + MOVQ AX, 40(SP) + MOVQ a5+48(FP), AX + MOVQ AX, 48(SP) + CALL ·X__syscall5(SB) + MOVQ 56(SP), AX + MOVQ AX, _2+56(FP) + RET + +// func Y__syscall6(tls *TLS, n, a1, a2, a3, a4, a5, a6 long) (_2 long) +TEXT ·Y__syscall6(SB),$72-72 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ a2+24(FP), AX + MOVQ AX, 24(SP) + MOVQ a3+32(FP), AX + MOVQ AX, 32(SP) + MOVQ a4+40(FP), AX + MOVQ AX, 40(SP) + MOVQ a5+48(FP), AX + MOVQ AX, 48(SP) + MOVQ a6+56(FP), AX + MOVQ AX, 56(SP) + CALL ·X__syscall6(SB) + MOVQ 64(SP), AX + MOVQ AX, _2+64(FP) + RET + +// func Y__syscall_ret(tls *TLS, r uint64) (r1 int64) +TEXT ·Y__syscall_ret(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ r+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__syscall_ret(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Y__tan(tls *TLS, x float64, y float64, odd int32) (r1 float64) +TEXT ·Y__tan(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + MOVL odd+24(FP), AX + MOVL AX, 24(SP) + CALL ·X__tan(SB) + MOVQ 32(SP), AX + MOVQ AX, r1+32(FP) + RET + +// func Y__tandf(tls *TLS, x float64, odd int32) (r1 float32) +TEXT ·Y__tandf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVL odd+16(FP), AX + MOVL AX, 16(SP) + CALL ·X__tandf(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Y__tm_to_secs(tls *TLS, tm uintptr) (r int64) +TEXT ·Y__tm_to_secs(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tm+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__tm_to_secs(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__tm_to_tzname(tls *TLS, tm uintptr) (r uintptr) +TEXT ·Y__tm_to_tzname(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tm+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__tm_to_tzname(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__tolower_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__tolower_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__tolower_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__toread(tls *TLS, f uintptr) (r int32) +TEXT ·Y__toread(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__toread(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__toread_needs_stdio_exit(tls *TLS) +TEXT ·Y__toread_needs_stdio_exit(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__toread_needs_stdio_exit(SB) + RET + +// func Y__toupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Y__toupper_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__toupper_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__towctrans_l(tls *TLS, c Twint_t, t Twctrans_t, l Tlocale_t) (r Twint_t) +TEXT ·Y__towctrans_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ t+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__towctrans_l(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__towlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) +TEXT ·Y__towlower_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__towlower_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__towrite(tls *TLS, f uintptr) (r int32) +TEXT ·Y__towrite(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__towrite(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__towrite_needs_stdio_exit(tls *TLS) +TEXT ·Y__towrite_needs_stdio_exit(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__towrite_needs_stdio_exit(SB) + RET + +// func Y__towupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) +TEXT ·Y__towupper_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__towupper_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Y__tre_mem_alloc_impl(tls *TLS, mem Ttre_mem_t, provided int32, provided_block uintptr, zero int32, size Tsize_t) (r uintptr) +TEXT ·Y__tre_mem_alloc_impl(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ mem+8(FP), AX + MOVQ AX, 8(SP) + MOVL provided+16(FP), AX + MOVL AX, 16(SP) + MOVQ provided_block+24(FP), AX + MOVQ AX, 24(SP) + MOVL zero+32(FP), AX + MOVL AX, 32(SP) + MOVQ size+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__tre_mem_alloc_impl(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Y__tre_mem_destroy(tls *TLS, mem Ttre_mem_t) +TEXT ·Y__tre_mem_destroy(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ mem+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__tre_mem_destroy(SB) + RET + +// func Y__tre_mem_new_impl(tls *TLS, provided int32, provided_block uintptr) (r Ttre_mem_t) +TEXT ·Y__tre_mem_new_impl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL provided+8(FP), AX + MOVL AX, 8(SP) + MOVQ provided_block+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__tre_mem_new_impl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__tsearch_balance(tls *TLS, p uintptr) (r int32) +TEXT ·Y__tsearch_balance(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__tsearch_balance(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__uflow(tls *TLS, f uintptr) (r int32) +TEXT ·Y__uflow(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__uflow(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Y__unlist_locked_file(tls *TLS, f uintptr) +TEXT ·Y__unlist_locked_file(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__unlist_locked_file(SB) + RET + +// func Y__unlockfile(tls *TLS, file uintptr) +TEXT ·Y__unlockfile(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ file+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__unlockfile(SB) + RET + +// func Y__uselocale(tls *TLS, new1 Tlocale_t) (r Tlocale_t) +TEXT ·Y__uselocale(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ new1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__uselocale(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__vm_wait(tls *TLS) +TEXT ·Y__vm_wait(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X__vm_wait(SB) + RET + +// func Y__wcscoll_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) +TEXT ·Y__wcscoll_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ locale+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__wcscoll_l(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Y__wcsftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) +TEXT ·Y__wcsftime_l(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + MOVQ tm+32(FP), AX + MOVQ AX, 32(SP) + MOVQ loc+40(FP), AX + MOVQ AX, 40(SP) + CALL ·X__wcsftime_l(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Y__wcsxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) +TEXT ·Y__wcsxfrm_l(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ loc+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__wcsxfrm_l(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Y__wctrans_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctrans_t) +TEXT ·Y__wctrans_l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__wctrans_l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__wctype_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctype_t) +TEXT ·Y__wctype_l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__wctype_l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y__xmknod(tls *TLS, ver int32, path uintptr, mode Tmode_t, dev uintptr) (r int32) +TEXT ·Y__xmknod(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ver+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL mode+24(FP), AX + MOVL AX, 24(SP) + MOVQ dev+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__xmknod(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Y__xmknodat(tls *TLS, ver int32, fd int32, path uintptr, mode Tmode_t, dev uintptr) (r int32) +TEXT ·Y__xmknodat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ver+8(FP), AX + MOVL AX, 8(SP) + MOVL fd+12(FP), AX + MOVL AX, 12(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL mode+24(FP), AX + MOVL AX, 24(SP) + MOVQ dev+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X__xmknodat(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Y__xpg_basename(tls *TLS, s uintptr) (r uintptr) +TEXT ·Y__xpg_basename(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X__xpg_basename(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Y__xpg_strerror_r(tls *TLS, err int32, buf uintptr, buflen Tsize_t) (r int32) +TEXT ·Y__xpg_strerror_r(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL err+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buflen+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__xpg_strerror_r(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__xstat(tls *TLS, ver int32, path uintptr, buf uintptr) (r int32) +TEXT ·Y__xstat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ver+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X__xstat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Y__year_to_secs(tls *TLS, year int64, is_leap uintptr) (r int64) +TEXT ·Y__year_to_secs(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ year+8(FP), AX + MOVQ AX, 8(SP) + MOVQ is_leap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·X__year_to_secs(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Y_exit(tls *TLS, status int32) +TEXT ·Y_exit(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL status+8(FP), AX + MOVL AX, 8(SP) + CALL ·X_exit(SB) + RET + +// func Y_flushlbf(tls *TLS) +TEXT ·Y_flushlbf(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·X_flushlbf(SB) + RET + +// func Y_longjmp(t *TLS, env uintptr, val int32) +TEXT ·Y_longjmp(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ env+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + CALL ·X_longjmp(SB) + RET + +// func Y_obstack_begin(t *TLS, obstack uintptr, size, alignment int32, chunkfun, freefun uintptr) (_4 int32) +TEXT ·Y_obstack_begin(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ obstack+8(FP), AX + MOVQ AX, 8(SP) + MOVL size+16(FP), AX + MOVL AX, 16(SP) + MOVL alignment+20(FP), AX + MOVL AX, 20(SP) + MOVQ chunkfun+24(FP), AX + MOVQ AX, 24(SP) + MOVQ freefun+32(FP), AX + MOVQ AX, 32(SP) + CALL ·X_obstack_begin(SB) + MOVL 40(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Y_obstack_newchunk(t *TLS, obstack uintptr, length int32) (_3 int32) +TEXT ·Y_obstack_newchunk(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ obstack+8(FP), AX + MOVQ AX, 8(SP) + MOVL length+16(FP), AX + MOVL AX, 16(SP) + CALL ·X_obstack_newchunk(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Y_pthread_cleanup_pop(tls *TLS, _ uintptr, run int32) +TEXT ·Y_pthread_cleanup_pop(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _+8(FP), AX + MOVQ AX, 8(SP) + MOVL run+16(FP), AX + MOVL AX, 16(SP) + CALL ·X_pthread_cleanup_pop(SB) + RET + +// func Y_pthread_cleanup_push(tls *TLS, _, f, x uintptr) +TEXT ·Y_pthread_cleanup_push(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + MOVQ x+24(FP), AX + MOVQ AX, 24(SP) + CALL ·X_pthread_cleanup_push(SB) + RET + +// func Y_setjmp(t *TLS, env uintptr) (_2 int32) +TEXT ·Y_setjmp(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ env+8(FP), AX + MOVQ AX, 8(SP) + CALL ·X_setjmp(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ya64l(tls *TLS, s uintptr) (r int64) +TEXT ·Ya64l(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xa64l(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yabort(tls *TLS) +TEXT ·Yabort(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xabort(SB) + RET + +// func Yabs(tls *TLS, a int32) (r int32) +TEXT ·Yabs(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL a+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xabs(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yaccept(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) +TEXT ·Yaccept(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ addr+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xaccept(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Yaccept4(tls *TLS, fd int32, addr uintptr, len1 uintptr, flg int32) (r1 int32) +TEXT ·Yaccept4(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ addr+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVL flg+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xaccept4(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Yaccess(tls *TLS, filename uintptr, amode int32) (r int32) +TEXT ·Yaccess(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVL amode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xaccess(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yacct(tls *TLS, filename uintptr) (r int32) +TEXT ·Yacct(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xacct(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yacos(tls *TLS, x float64) (r float64) +TEXT ·Yacos(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xacos(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yacosf(tls *TLS, x float32) (r float32) +TEXT ·Yacosf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xacosf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yacosh(tls *TLS, x float64) (r float64) +TEXT ·Yacosh(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xacosh(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yacoshf(tls *TLS, x float32) (r float32) +TEXT ·Yacoshf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xacoshf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yacoshl(tls *TLS, x float64) (r float64) +TEXT ·Yacoshl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xacoshl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yacosl(tls *TLS, x float64) (r float64) +TEXT ·Yacosl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xacosl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yaddmntent(tls *TLS, f uintptr, mnt uintptr) (r int32) +TEXT ·Yaddmntent(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mnt+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xaddmntent(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yadjtime(tls *TLS, in uintptr, out uintptr) (r int32) +TEXT ·Yadjtime(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ in+8(FP), AX + MOVQ AX, 8(SP) + MOVQ out+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xadjtime(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yadjtimex(tls *TLS, tx uintptr) (r int32) +TEXT ·Yadjtimex(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tx+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xadjtimex(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yalarm(tls *TLS, seconds uint32) (r uint32) +TEXT ·Yalarm(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL seconds+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xalarm(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yalloca(tls *TLS, size Tsize_t) (_2 uintptr) +TEXT ·Yalloca(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ size+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xalloca(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Yalphasort(tls *TLS, a uintptr, b uintptr) (r int32) +TEXT ·Yalphasort(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xalphasort(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yarch_prctl(tls *TLS, code int32, addr uint64) (r int32) +TEXT ·Yarch_prctl(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL code+8(FP), AX + MOVL AX, 8(SP) + MOVQ addr+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xarch_prctl(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yasctime(tls *TLS, tm uintptr) (r uintptr) +TEXT ·Yasctime(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tm+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xasctime(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yasctime_r(tls *TLS, tm uintptr, buf uintptr) (r uintptr) +TEXT ·Yasctime_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tm+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xasctime_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yasin(tls *TLS, x float64) (r1 float64) +TEXT ·Yasin(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xasin(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Yasinf(tls *TLS, x float32) (r float32) +TEXT ·Yasinf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xasinf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yasinh(tls *TLS, x3 float64) (r float64) +TEXT ·Yasinh(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xasinh(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yasinhf(tls *TLS, x3 float32) (r float32) +TEXT ·Yasinhf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xasinhf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yasinhl(tls *TLS, x float64) (r float64) +TEXT ·Yasinhl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xasinhl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yasinl(tls *TLS, x float64) (r float64) +TEXT ·Yasinl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xasinl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yasprintf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Yasprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xasprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yat_quick_exit(tls *TLS, __ccgo_fp_func uintptr) (r1 int32) +TEXT ·Yat_quick_exit(SB),$32-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_func+8(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_at_quick_exit_0(SB) // Create the closure for calling __ccgo_fp_func + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + CALL ·Xat_quick_exit(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_at_quick_exit_0(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ __ccgo_fp+8(FP), AX + CALL *AX // Call the ABI0 code ptr + RET + +// func Yatan(tls *TLS, x3 float64) (r float64) +TEXT ·Yatan(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatan(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yatan2(tls *TLS, y float64, x float64) (r float64) +TEXT ·Yatan2(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ y+8(FP), AX + MOVQ AX, 8(SP) + MOVQ x+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xatan2(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yatan2f(tls *TLS, y float32, x float32) (r float32) +TEXT ·Yatan2f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL y+8(FP), AX + MOVL AX, 8(SP) + MOVL x+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xatan2f(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yatan2l(tls *TLS, y float64, x float64) (r float64) +TEXT ·Yatan2l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ y+8(FP), AX + MOVQ AX, 8(SP) + MOVQ x+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xatan2l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yatanf(tls *TLS, x3 float32) (r float32) +TEXT ·Yatanf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xatanf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yatanh(tls *TLS, x3 float64) (r float64) +TEXT ·Yatanh(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatanh(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yatanhf(tls *TLS, x3 float32) (r float32) +TEXT ·Yatanhf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xatanhf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yatanhl(tls *TLS, x float64) (r float64) +TEXT ·Yatanhl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatanhl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yatanl(tls *TLS, x float64) (r float64) +TEXT ·Yatanl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatanl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yatexit(tls *TLS, func_ uintptr) (r int32) +TEXT ·Yatexit(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ func_+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatexit(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yatof(tls *TLS, s uintptr) (r float64) +TEXT ·Yatof(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatof(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yatoi(tls *TLS, s uintptr) (r int32) +TEXT ·Yatoi(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatoi(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yatol(tls *TLS, s uintptr) (r int64) +TEXT ·Yatol(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatol(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yatoll(tls *TLS, s uintptr) (r int64) +TEXT ·Yatoll(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xatoll(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ybacktrace(t *TLS, buf uintptr, size int32) (_3 int32) +TEXT ·Ybacktrace(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVL size+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xbacktrace(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Ybacktrace_symbols_fd(t *TLS, buffer uintptr, size, fd int32) +TEXT ·Ybacktrace_symbols_fd(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buffer+8(FP), AX + MOVQ AX, 8(SP) + MOVL size+16(FP), AX + MOVL AX, 16(SP) + MOVL fd+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xbacktrace_symbols_fd(SB) + RET + +// func Ybasename(tls *TLS, s uintptr) (r uintptr) +TEXT ·Ybasename(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xbasename(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ybcmp(tls *TLS, s1 uintptr, s2 uintptr, n Tsize_t) (r int32) +TEXT ·Ybcmp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xbcmp(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ybcopy(tls *TLS, s1 uintptr, s2 uintptr, n Tsize_t) +TEXT ·Ybcopy(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xbcopy(SB) + RET + +// func Ybind(tls *TLS, fd int32, addr uintptr, len1 Tsocklen_t) (r1 int32) +TEXT ·Ybind(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ addr+16(FP), AX + MOVQ AX, 16(SP) + MOVL len1+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xbind(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ybind_textdomain_codeset(tls *TLS, domainname uintptr, codeset uintptr) (r uintptr) +TEXT ·Ybind_textdomain_codeset(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ domainname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ codeset+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xbind_textdomain_codeset(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ybindtextdomain(tls *TLS, domainname uintptr, dirname uintptr) (r uintptr) +TEXT ·Ybindtextdomain(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ domainname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ dirname+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xbindtextdomain(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ybrk(tls *TLS, end uintptr) (r int32) +TEXT ·Ybrk(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ end+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xbrk(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ybsearch(tls *TLS, key uintptr, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp uintptr) (r uintptr) +TEXT ·Ybsearch(SB),$64-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cmp+40(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_bsearch_4(SB) // Create the closure for calling __ccgo_fp_cmp + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ base+16(FP), AX + MOVQ AX, 16(SP) + MOVQ nel+24(FP), AX + MOVQ AX, 24(SP) + MOVQ width+32(FP), AX + MOVQ AX, 32(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 40(SP) + CALL ·Xbsearch(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_bsearch_4(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Ybtowc(tls *TLS, c int32) (r Twint_t) +TEXT ·Ybtowc(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xbtowc(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ybzero(tls *TLS, s uintptr, n Tsize_t) +TEXT ·Ybzero(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xbzero(SB) + RET + +// func Yc16rtomb(tls *TLS, s uintptr, c16 Tchar16_t, ps uintptr) (r Tsize_t) +TEXT ·Yc16rtomb(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVW c16+16(FP), AX + MOVW AX, 16(SP) + MOVQ ps+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xc16rtomb(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yc32rtomb(tls *TLS, s uintptr, c32 Tchar32_t, ps uintptr) (r Tsize_t) +TEXT ·Yc32rtomb(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c32+16(FP), AX + MOVL AX, 16(SP) + MOVQ ps+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xc32rtomb(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ycabs(tls *TLS, z complex128) (r float64) +TEXT ·Ycabs(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcabs(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycabsf(tls *TLS, z complex64) (r float32) +TEXT ·Ycabsf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcabsf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycabsl(tls *TLS, z complex128) (r float64) +TEXT ·Ycabsl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcabsl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycacos(tls *TLS, z complex128) (r complex128) +TEXT ·Ycacos(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcacos(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycacosf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycacosf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcacosf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycacosh(tls *TLS, z complex128) (r complex128) +TEXT ·Ycacosh(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcacosh(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycacoshf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycacoshf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcacoshf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycacoshl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycacoshl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcacoshl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycacosl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycacosl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcacosl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycalloc(tls *TLS, m Tsize_t, n Tsize_t) (r uintptr) +TEXT ·Ycalloc(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcalloc(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycapget(tls *TLS, a uintptr, b uintptr) (r int32) +TEXT ·Ycapget(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcapget(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ycapset(tls *TLS, a uintptr, b uintptr) (r int32) +TEXT ·Ycapset(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcapset(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ycarg(tls *TLS, z complex128) (r float64) +TEXT ·Ycarg(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcarg(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycargf(tls *TLS, z complex64) (r float32) +TEXT ·Ycargf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcargf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycargl(tls *TLS, z complex128) (r float64) +TEXT ·Ycargl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcargl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycasin(tls *TLS, z complex128) (r1 complex128) +TEXT ·Ycasin(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcasin(SB) + MOVQ 24(SP), AX + MOVQ AX, r1_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r1_imag+32(FP) + RET + +// func Ycasinf(tls *TLS, z complex64) (r1 complex64) +TEXT ·Ycasinf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcasinf(SB) + MOVL 16(SP), AX + MOVL AX, r1_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r1_imag+20(FP) + RET + +// func Ycasinh(tls *TLS, z complex128) (r complex128) +TEXT ·Ycasinh(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcasinh(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycasinhf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycasinhf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcasinhf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycasinhl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycasinhl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcasinhl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycasinl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycasinl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcasinl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycatan(tls *TLS, z complex128) (r complex128) +TEXT ·Ycatan(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcatan(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycatanf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycatanf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcatanf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycatanh(tls *TLS, z complex128) (r complex128) +TEXT ·Ycatanh(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcatanh(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycatanhf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycatanhf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcatanhf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycatanhl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycatanhl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcatanhl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycatanl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycatanl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcatanl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycatclose(tls *TLS, catd Tnl_catd) (r int32) +TEXT ·Ycatclose(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ catd+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcatclose(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycatgets(tls *TLS, catd Tnl_catd, set_id int32, msg_id int32, s uintptr) (r uintptr) +TEXT ·Ycatgets(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ catd+8(FP), AX + MOVQ AX, 8(SP) + MOVL set_id+16(FP), AX + MOVL AX, 16(SP) + MOVL msg_id+20(FP), AX + MOVL AX, 20(SP) + MOVQ s+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xcatgets(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ycatopen(tls *TLS, name uintptr, oflag int32) (r Tnl_catd) +TEXT ·Ycatopen(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVL oflag+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xcatopen(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycbrt(tls *TLS, x float64) (r1 float64) +TEXT ·Ycbrt(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcbrt(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Ycbrtf(tls *TLS, x float32) (r1 float32) +TEXT ·Ycbrtf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xcbrtf(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Ycbrtl(tls *TLS, x float64) (r float64) +TEXT ·Ycbrtl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcbrtl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yccos(tls *TLS, z complex128) (r complex128) +TEXT ·Yccos(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xccos(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yccosf(tls *TLS, z complex64) (r complex64) +TEXT ·Yccosf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xccosf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Yccosh(tls *TLS, z complex128) (r complex128) +TEXT ·Yccosh(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xccosh(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yccoshf(tls *TLS, z complex64) (r complex64) +TEXT ·Yccoshf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xccoshf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Yccoshl(tls *TLS, z complex128) (r complex128) +TEXT ·Yccoshl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xccoshl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yccosl(tls *TLS, z complex128) (r complex128) +TEXT ·Yccosl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xccosl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yceil(tls *TLS, x3 float64) (r float64) +TEXT ·Yceil(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xceil(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yceilf(tls *TLS, x3 float32) (r float32) +TEXT ·Yceilf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xceilf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yceill(tls *TLS, x float64) (r float64) +TEXT ·Yceill(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xceill(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ycexp(tls *TLS, z complex128) (r complex128) +TEXT ·Ycexp(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcexp(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycexpf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycexpf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcexpf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycexpl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycexpl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcexpl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycfgetispeed(tls *TLS, tio uintptr) (r Tspeed_t) +TEXT ·Ycfgetispeed(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tio+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcfgetispeed(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycfgetospeed(tls *TLS, tio uintptr) (r Tspeed_t) +TEXT ·Ycfgetospeed(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tio+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcfgetospeed(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycfmakeraw(tls *TLS, t uintptr) +TEXT ·Ycfmakeraw(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcfmakeraw(SB) + RET + +// func Ycfsetispeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) +TEXT ·Ycfsetispeed(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tio+8(FP), AX + MOVQ AX, 8(SP) + MOVL speed+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xcfsetispeed(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ycfsetospeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) +TEXT ·Ycfsetospeed(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tio+8(FP), AX + MOVQ AX, 8(SP) + MOVL speed+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xcfsetospeed(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ycfsetspeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) +TEXT ·Ycfsetspeed(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tio+8(FP), AX + MOVQ AX, 8(SP) + MOVL speed+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xcfsetspeed(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ychdir(tls *TLS, path uintptr) (r int32) +TEXT ·Ychdir(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xchdir(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ychmod(tls *TLS, path uintptr, mode Tmode_t) (r int32) +TEXT ·Ychmod(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL mode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xchmod(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ychown(tls *TLS, path uintptr, uid Tuid_t, gid Tgid_t) (r int32) +TEXT ·Ychown(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL uid+16(FP), AX + MOVL AX, 16(SP) + MOVL gid+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xchown(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ychroot(tls *TLS, path uintptr) (r int32) +TEXT ·Ychroot(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xchroot(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycimag(tls *TLS, z complex128) (r float64) +TEXT ·Ycimag(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcimag(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycimagf(tls *TLS, z complex64) (r float32) +TEXT ·Ycimagf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcimagf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycimagl(tls *TLS, z complex128) (r float64) +TEXT ·Ycimagl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcimagl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yclearenv(tls *TLS) (r int32) +TEXT ·Yclearenv(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xclearenv(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yclearerr(tls *TLS, f uintptr) +TEXT ·Yclearerr(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xclearerr(SB) + RET + +// func Yclearerr_unlocked(tls *TLS, f uintptr) +TEXT ·Yclearerr_unlocked(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xclearerr_unlocked(SB) + RET + +// func Yclock(tls *TLS) (r Tclock_t) +TEXT ·Yclock(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xclock(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Yclock_adjtime(tls *TLS, clock_id Tclockid_t, utx uintptr) (r1 int32) +TEXT ·Yclock_adjtime(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL clock_id+8(FP), AX + MOVL AX, 8(SP) + MOVQ utx+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xclock_adjtime(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Yclock_getcpuclockid(tls *TLS, pid Tpid_t, clk uintptr) (r int32) +TEXT ·Yclock_getcpuclockid(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVQ clk+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xclock_getcpuclockid(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yclock_getres(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) +TEXT ·Yclock_getres(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL clk+8(FP), AX + MOVL AX, 8(SP) + MOVQ ts+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xclock_getres(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yclock_gettime(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) +TEXT ·Yclock_gettime(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL clk+8(FP), AX + MOVL AX, 8(SP) + MOVQ ts+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xclock_gettime(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yclock_nanosleep(tls *TLS, clk Tclockid_t, flags int32, req uintptr, rem uintptr) (r int32) +TEXT ·Yclock_nanosleep(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL clk+8(FP), AX + MOVL AX, 8(SP) + MOVL flags+12(FP), AX + MOVL AX, 12(SP) + MOVQ req+16(FP), AX + MOVQ AX, 16(SP) + MOVQ rem+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xclock_nanosleep(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yclock_settime(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) +TEXT ·Yclock_settime(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL clk+8(FP), AX + MOVL AX, 8(SP) + MOVQ ts+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xclock_settime(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yclog(tls *TLS, z complex128) (r1 complex128) +TEXT ·Yclog(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xclog(SB) + MOVQ 24(SP), AX + MOVQ AX, r1_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r1_imag+32(FP) + RET + +// func Yclogf(tls *TLS, z complex64) (r1 complex64) +TEXT ·Yclogf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xclogf(SB) + MOVL 16(SP), AX + MOVL AX, r1_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r1_imag+20(FP) + RET + +// func Yclogl(tls *TLS, z complex128) (r complex128) +TEXT ·Yclogl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xclogl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yclose(tls *TLS, fd int32) (r1 int32) +TEXT ·Yclose(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xclose(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yclosedir(tls *TLS, dir uintptr) (r int32) +TEXT ·Yclosedir(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dir+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xclosedir(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycloselog(tls *TLS) +TEXT ·Ycloselog(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xcloselog(SB) + RET + +// func Yconfstr(tls *TLS, name int32, buf uintptr, len1 Tsize_t) (r Tsize_t) +TEXT ·Yconfstr(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL name+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xconfstr(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yconj(tls *TLS, z complex128) (r complex128) +TEXT ·Yconj(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xconj(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yconjf(tls *TLS, z complex64) (r complex64) +TEXT ·Yconjf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xconjf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Yconjl(tls *TLS, z complex128) (r complex128) +TEXT ·Yconjl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xconjl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yconnect(tls *TLS, fd int32, addr uintptr, len1 Tsocklen_t) (r1 int32) +TEXT ·Yconnect(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ addr+16(FP), AX + MOVQ AX, 16(SP) + MOVL len1+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xconnect(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ycopy_file_range(tls *TLS, fd_in int32, off_in uintptr, fd_out int32, off_out uintptr, len1 Tsize_t, flags uint32) (r Tssize_t) +TEXT ·Ycopy_file_range(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd_in+8(FP), AX + MOVL AX, 8(SP) + MOVQ off_in+16(FP), AX + MOVQ AX, 16(SP) + MOVL fd_out+24(FP), AX + MOVL AX, 24(SP) + MOVQ off_out+32(FP), AX + MOVQ AX, 32(SP) + MOVQ len1+40(FP), AX + MOVQ AX, 40(SP) + MOVL flags+48(FP), AX + MOVL AX, 48(SP) + CALL ·Xcopy_file_range(SB) + MOVQ 56(SP), AX + MOVQ AX, r+56(FP) + RET + +// func Ycopysign(tls *TLS, x float64, y float64) (r float64) +TEXT ·Ycopysign(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcopysign(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycopysignf(tls *TLS, x float32, y float32) (r float32) +TEXT ·Ycopysignf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcopysignf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycopysignl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Ycopysignl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcopysignl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycos(tls *TLS, x3 float64) (r float64) +TEXT ·Ycos(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcos(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ycosf(tls *TLS, x3 float32) (r float32) +TEXT ·Ycosf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xcosf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycosh(tls *TLS, x3 float64) (r float64) +TEXT ·Ycosh(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcosh(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ycoshf(tls *TLS, x3 float32) (r float32) +TEXT ·Ycoshf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xcoshf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycoshl(tls *TLS, x float64) (r float64) +TEXT ·Ycoshl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcoshl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ycosl(tls *TLS, x float64) (r float64) +TEXT ·Ycosl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcosl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ycpow(tls *TLS, z complex128, c complex128) (r complex128) +TEXT ·Ycpow(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + MOVQ c_real+24(FP), AX + MOVQ AX, 24(SP) + MOVQ c_imag+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xcpow(SB) + MOVQ 40(SP), AX + MOVQ AX, r_real+40(FP) + MOVQ 48(SP), AX + MOVQ AX, r_imag+48(FP) + RET + +// func Ycpowf(tls *TLS, z complex64, c complex64) (r complex64) +TEXT ·Ycpowf(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + MOVL c_real+16(FP), AX + MOVL AX, 16(SP) + MOVL c_imag+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xcpowf(SB) + MOVL 24(SP), AX + MOVL AX, r_real+24(FP) + MOVL 28(SP), AX + MOVL AX, r_imag+28(FP) + RET + +// func Ycpowl(tls *TLS, z complex128, c complex128) (r complex128) +TEXT ·Ycpowl(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + MOVQ c_real+24(FP), AX + MOVQ AX, 24(SP) + MOVQ c_imag+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xcpowl(SB) + MOVQ 40(SP), AX + MOVQ AX, r_real+40(FP) + MOVQ 48(SP), AX + MOVQ AX, r_imag+48(FP) + RET + +// func Ycproj(tls *TLS, z complex128) (r complex128) +TEXT ·Ycproj(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcproj(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycprojf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycprojf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcprojf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycprojl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycprojl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcprojl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycreal(tls *TLS, z complex128) (r float64) +TEXT ·Ycreal(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcreal(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycrealf(tls *TLS, z complex64) (r float32) +TEXT ·Ycrealf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcrealf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ycreall(tls *TLS, z complex128) (r float64) +TEXT ·Ycreall(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcreall(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycreat(tls *TLS, filename uintptr, mode Tmode_t) (r int32) +TEXT ·Ycreat(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVL mode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xcreat(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ycrypt(tls *TLS, key uintptr, salt uintptr) (r uintptr) +TEXT ·Ycrypt(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ salt+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcrypt(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycrypt_r(tls *TLS, key uintptr, salt uintptr, data uintptr) (r uintptr) +TEXT ·Ycrypt_r(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ salt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ data+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xcrypt_r(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ycsin(tls *TLS, z complex128) (r complex128) +TEXT ·Ycsin(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcsin(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycsinf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycsinf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcsinf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycsinh(tls *TLS, z complex128) (r complex128) +TEXT ·Ycsinh(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcsinh(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycsinhf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycsinhf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcsinhf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycsinhl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycsinhl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcsinhl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycsinl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycsinl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcsinl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycsqrt(tls *TLS, z complex128) (r complex128) +TEXT ·Ycsqrt(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcsqrt(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Ycsqrtf(tls *TLS, z complex64) (r complex64) +TEXT ·Ycsqrtf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xcsqrtf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Ycsqrtl(tls *TLS, z complex128) (r complex128) +TEXT ·Ycsqrtl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xcsqrtl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yctan(tls *TLS, z complex128) (r complex128) +TEXT ·Yctan(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xctan(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yctanf(tls *TLS, z complex64) (r complex64) +TEXT ·Yctanf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xctanf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Yctanh(tls *TLS, z complex128) (r complex128) +TEXT ·Yctanh(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xctanh(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yctanhf(tls *TLS, z complex64) (r complex64) +TEXT ·Yctanhf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL z_real+8(FP), AX + MOVL AX, 8(SP) + MOVL z_imag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xctanhf(SB) + MOVL 16(SP), AX + MOVL AX, r_real+16(FP) + MOVL 20(SP), AX + MOVL AX, r_imag+20(FP) + RET + +// func Yctanhl(tls *TLS, z complex128) (r complex128) +TEXT ·Yctanhl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xctanhl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yctanl(tls *TLS, z complex128) (r complex128) +TEXT ·Yctanl(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ z_real+8(FP), AX + MOVQ AX, 8(SP) + MOVQ z_imag+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xctanl(SB) + MOVQ 24(SP), AX + MOVQ AX, r_real+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_imag+32(FP) + RET + +// func Yctermid(tls *TLS, s uintptr) (r uintptr) +TEXT ·Yctermid(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xctermid(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yctime(tls *TLS, t uintptr) (r uintptr) +TEXT ·Yctime(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xctime(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yctime_r(tls *TLS, t uintptr, buf uintptr) (r uintptr) +TEXT ·Yctime_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xctime_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ycuserid(tls *TLS, buf uintptr) (r uintptr) +TEXT ·Ycuserid(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xcuserid(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ydcgettext(tls *TLS, domainname uintptr, msgid uintptr, category int32) (r uintptr) +TEXT ·Ydcgettext(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ domainname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ msgid+16(FP), AX + MOVQ AX, 16(SP) + MOVL category+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xdcgettext(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ydcngettext(tls *TLS, domainname uintptr, msgid1 uintptr, msgid2 uintptr, n uint64, category int32) (r1 uintptr) +TEXT ·Ydcngettext(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ domainname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ msgid1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ msgid2+24(FP), AX + MOVQ AX, 24(SP) + MOVQ n+32(FP), AX + MOVQ AX, 32(SP) + MOVL category+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xdcngettext(SB) + MOVQ 48(SP), AX + MOVQ AX, r1+48(FP) + RET + +// func Ydelete_module(tls *TLS, a uintptr, b uint32) (r int32) +TEXT ·Ydelete_module(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVL b+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xdelete_module(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ydgettext(tls *TLS, domainname uintptr, msgid uintptr) (r uintptr) +TEXT ·Ydgettext(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ domainname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ msgid+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xdgettext(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ydifftime(tls *TLS, t1 Ttime_t, t0 Ttime_t) (r float64) +TEXT ·Ydifftime(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ t0+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xdifftime(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ydirfd(tls *TLS, d uintptr) (r int32) +TEXT ·Ydirfd(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xdirfd(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ydirname(tls *TLS, s uintptr) (r uintptr) +TEXT ·Ydirname(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xdirname(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ydiv(tls *TLS, num int32, den int32) (r Tdiv_t) +TEXT ·Ydiv(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL num+8(FP), AX + MOVL AX, 8(SP) + MOVL den+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xdiv(SB) + MOVL 16(SP), AX + MOVL AX, r_Fquot+16(FP) + MOVL 20(SP), AX + MOVL AX, r_Frem+20(FP) + RET + +// func Ydlclose(t *TLS, handle uintptr) (_2 int32) +TEXT ·Ydlclose(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ handle+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xdlclose(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ydlerror(t *TLS) (_1 uintptr) +TEXT ·Ydlerror(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xdlerror(SB) + MOVQ 8(SP), AX + MOVQ AX, _1+8(FP) + RET + +// func Ydlopen(t *TLS, filename uintptr, flags int32) (_3 uintptr) +TEXT ·Ydlopen(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xdlopen(SB) + MOVQ 24(SP), AX + MOVQ AX, _3+24(FP) + RET + +// func Ydlsym(t *TLS, handle, symbol uintptr) (_2 uintptr) +TEXT ·Ydlsym(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ handle+8(FP), AX + MOVQ AX, 8(SP) + MOVQ symbol+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xdlsym(SB) + MOVQ 24(SP), AX + MOVQ AX, _2+24(FP) + RET + +// func Ydn_comp(tls *TLS, src uintptr, dst uintptr, space int32, dnptrs uintptr, lastdnptr uintptr) (r int32) +TEXT ·Ydn_comp(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ src+8(FP), AX + MOVQ AX, 8(SP) + MOVQ dst+16(FP), AX + MOVQ AX, 16(SP) + MOVL space+24(FP), AX + MOVL AX, 24(SP) + MOVQ dnptrs+32(FP), AX + MOVQ AX, 32(SP) + MOVQ lastdnptr+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xdn_comp(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ydn_expand(tls *TLS, base uintptr, end uintptr, src uintptr, dest uintptr, space int32) (r int32) +TEXT ·Ydn_expand(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ base+8(FP), AX + MOVQ AX, 8(SP) + MOVQ end+16(FP), AX + MOVQ AX, 16(SP) + MOVQ src+24(FP), AX + MOVQ AX, 24(SP) + MOVQ dest+32(FP), AX + MOVQ AX, 32(SP) + MOVL space+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xdn_expand(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ydn_skipname(tls *TLS, s uintptr, end uintptr) (r int32) +TEXT ·Ydn_skipname(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ end+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xdn_skipname(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ydngettext(tls *TLS, domainname uintptr, msgid1 uintptr, msgid2 uintptr, n uint64) (r uintptr) +TEXT ·Ydngettext(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ domainname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ msgid1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ msgid2+24(FP), AX + MOVQ AX, 24(SP) + MOVQ n+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xdngettext(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ydprintf(tls *TLS, fd int32, fmt uintptr, va uintptr) (r int32) +TEXT ·Ydprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xdprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ydrand48(tls *TLS) (r float64) +TEXT ·Ydrand48(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xdrand48(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ydrem(tls *TLS, x float64, y float64) (r float64) +TEXT ·Ydrem(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xdrem(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ydremf(tls *TLS, x float32, y float32) (r float32) +TEXT ·Ydremf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xdremf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ydup(tls *TLS, fd int32) (r int32) +TEXT ·Ydup(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xdup(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ydup2(tls *TLS, old int32, new1 int32) (r1 int32) +TEXT ·Ydup2(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL old+8(FP), AX + MOVL AX, 8(SP) + MOVL new1+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xdup2(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Ydup3(tls *TLS, old int32, new1 int32, flags int32) (r int32) +TEXT ·Ydup3(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL old+8(FP), AX + MOVL AX, 8(SP) + MOVL new1+12(FP), AX + MOVL AX, 12(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xdup3(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yduplocale(tls *TLS, old Tlocale_t) (r Tlocale_t) +TEXT ·Yduplocale(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ old+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xduplocale(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yeaccess(tls *TLS, filename uintptr, amode int32) (r int32) +TEXT ·Yeaccess(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVL amode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xeaccess(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yecvt(tls *TLS, x float64, n int32, dp uintptr, sign uintptr) (r uintptr) +TEXT ·Yecvt(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + MOVQ dp+24(FP), AX + MOVQ AX, 24(SP) + MOVQ sign+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xecvt(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yencrypt(tls *TLS, block uintptr, edflag int32) +TEXT ·Yencrypt(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ block+8(FP), AX + MOVQ AX, 8(SP) + MOVL edflag+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xencrypt(SB) + RET + +// func Yendgrent(tls *TLS) +TEXT ·Yendgrent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendgrent(SB) + RET + +// func Yendhostent(tls *TLS) +TEXT ·Yendhostent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendhostent(SB) + RET + +// func Yendmntent(tls *TLS, f uintptr) (r int32) +TEXT ·Yendmntent(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xendmntent(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yendnetent(tls *TLS) +TEXT ·Yendnetent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendnetent(SB) + RET + +// func Yendprotoent(tls *TLS) +TEXT ·Yendprotoent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendprotoent(SB) + RET + +// func Yendpwent(tls *TLS) +TEXT ·Yendpwent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendpwent(SB) + RET + +// func Yendservent(tls *TLS) +TEXT ·Yendservent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendservent(SB) + RET + +// func Yendspent(tls *TLS) +TEXT ·Yendspent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendspent(SB) + RET + +// func Yendusershell(tls *TLS) +TEXT ·Yendusershell(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendusershell(SB) + RET + +// func Yendutent(tls *TLS) +TEXT ·Yendutent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendutent(SB) + RET + +// func Yendutxent(tls *TLS) +TEXT ·Yendutxent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xendutxent(SB) + RET + +// func Yepoll_create(tls *TLS, size int32) (r int32) +TEXT ·Yepoll_create(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL size+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xepoll_create(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yepoll_create1(tls *TLS, flags int32) (r1 int32) +TEXT ·Yepoll_create1(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL flags+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xepoll_create1(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yepoll_ctl(tls *TLS, fd int32, op int32, fd2 int32, ev uintptr) (r int32) +TEXT ·Yepoll_ctl(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL op+12(FP), AX + MOVL AX, 12(SP) + MOVL fd2+16(FP), AX + MOVL AX, 16(SP) + MOVQ ev+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xepoll_ctl(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yepoll_pwait(tls *TLS, fd int32, ev uintptr, cnt int32, to int32, sigs uintptr) (r1 int32) +TEXT ·Yepoll_pwait(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ ev+16(FP), AX + MOVQ AX, 16(SP) + MOVL cnt+24(FP), AX + MOVL AX, 24(SP) + MOVL to+28(FP), AX + MOVL AX, 28(SP) + MOVQ sigs+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xepoll_pwait(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Yepoll_wait(tls *TLS, fd int32, ev uintptr, cnt int32, to int32) (r int32) +TEXT ·Yepoll_wait(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ ev+16(FP), AX + MOVQ AX, 16(SP) + MOVL cnt+24(FP), AX + MOVL AX, 24(SP) + MOVL to+28(FP), AX + MOVL AX, 28(SP) + CALL ·Xepoll_wait(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yerand48(tls *TLS, s uintptr) (r float64) +TEXT ·Yerand48(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xerand48(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yerf(tls *TLS, x float64) (r1 float64) +TEXT ·Yerf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xerf(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Yerfc(tls *TLS, x float64) (r1 float64) +TEXT ·Yerfc(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xerfc(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Yerfcf(tls *TLS, x float32) (r1 float32) +TEXT ·Yerfcf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xerfcf(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yerfcl(tls *TLS, x float64) (r float64) +TEXT ·Yerfcl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xerfcl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yerff(tls *TLS, x float32) (r1 float32) +TEXT ·Yerff(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xerff(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yerfl(tls *TLS, x float64) (r float64) +TEXT ·Yerfl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xerfl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yerr(tls *TLS, status int32, fmt uintptr, va uintptr) +TEXT ·Yerr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL status+8(FP), AX + MOVL AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xerr(SB) + RET + +// func Yerrx(tls *TLS, status int32, fmt uintptr, va uintptr) +TEXT ·Yerrx(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL status+8(FP), AX + MOVL AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xerrx(SB) + RET + +// func Yether_aton(tls *TLS, x uintptr) (r uintptr) +TEXT ·Yether_aton(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xether_aton(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yether_aton_r(tls *TLS, x uintptr, p_a uintptr) (r uintptr) +TEXT ·Yether_aton_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p_a+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xether_aton_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yether_hostton(tls *TLS, hostname uintptr, e uintptr) (r int32) +TEXT ·Yether_hostton(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ hostname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ e+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xether_hostton(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yether_line(tls *TLS, l uintptr, e uintptr, hostname uintptr) (r int32) +TEXT ·Yether_line(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ e+16(FP), AX + MOVQ AX, 16(SP) + MOVQ hostname+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xether_line(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yether_ntoa(tls *TLS, p_a uintptr) (r uintptr) +TEXT ·Yether_ntoa(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p_a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xether_ntoa(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yether_ntoa_r(tls *TLS, p_a uintptr, x uintptr) (r uintptr) +TEXT ·Yether_ntoa_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p_a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ x+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xether_ntoa_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yether_ntohost(tls *TLS, hostname uintptr, e uintptr) (r int32) +TEXT ·Yether_ntohost(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ hostname+8(FP), AX + MOVQ AX, 8(SP) + MOVQ e+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xether_ntohost(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yeuidaccess(tls *TLS, filename uintptr, amode int32) (r int32) +TEXT ·Yeuidaccess(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVL amode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xeuidaccess(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yeventfd(tls *TLS, count uint32, flags int32) (r1 int32) +TEXT ·Yeventfd(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL count+8(FP), AX + MOVL AX, 8(SP) + MOVL flags+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xeventfd(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yeventfd_read(tls *TLS, fd int32, value uintptr) (r int32) +TEXT ·Yeventfd_read(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ value+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xeventfd_read(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yeventfd_write(tls *TLS, fd int32, _value Teventfd_t) (r int32) +TEXT ·Yeventfd_write(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ _value+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xeventfd_write(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yexecl(tls *TLS, path uintptr, argv0 uintptr, va uintptr) (r int32) +TEXT ·Yexecl(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ argv0+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xexecl(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yexecle(tls *TLS, path uintptr, argv0 uintptr, va uintptr) (r int32) +TEXT ·Yexecle(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ argv0+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xexecle(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yexeclp(tls *TLS, file uintptr, argv0 uintptr, va uintptr) (r int32) +TEXT ·Yexeclp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ file+8(FP), AX + MOVQ AX, 8(SP) + MOVQ argv0+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xexeclp(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yexecv(tls *TLS, path uintptr, argv uintptr) (r int32) +TEXT ·Yexecv(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xexecv(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yexecve(tls *TLS, path uintptr, argv uintptr, envp uintptr) (r int32) +TEXT ·Yexecve(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ envp+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xexecve(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yexecvp(tls *TLS, file uintptr, argv uintptr) (r int32) +TEXT ·Yexecvp(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ file+8(FP), AX + MOVQ AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xexecvp(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yexecvpe(tls *TLS, file uintptr, argv uintptr, envp uintptr) (r int32) +TEXT ·Yexecvpe(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ file+8(FP), AX + MOVQ AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ envp+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xexecvpe(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yexit(tls *TLS, code int32) +TEXT ·Yexit(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL code+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xexit(SB) + RET + +// func Yexp(tls *TLS, x1 float64) (r1 float64) +TEXT ·Yexp(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xexp(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Yexp10(tls *TLS, x float64) (r float64) +TEXT ·Yexp10(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xexp10(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yexp10f(tls *TLS, x float32) (r float32) +TEXT ·Yexp10f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xexp10f(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yexp10l(tls *TLS, x float64) (r float64) +TEXT ·Yexp10l(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xexp10l(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yexp2(tls *TLS, x1 float64) (r1 float64) +TEXT ·Yexp2(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xexp2(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Yexp2f(tls *TLS, x2 float32) (r1 float32) +TEXT ·Yexp2f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x2+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xexp2f(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yexp2l(tls *TLS, x float64) (r float64) +TEXT ·Yexp2l(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xexp2l(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yexpf(tls *TLS, x2 float32) (r1 float32) +TEXT ·Yexpf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x2+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xexpf(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yexpl(tls *TLS, x float64) (r float64) +TEXT ·Yexpl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xexpl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yexplicit_bzero(tls *TLS, d uintptr, n Tsize_t) +TEXT ·Yexplicit_bzero(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xexplicit_bzero(SB) + RET + +// func Yexpm1(tls *TLS, x3 float64) (r float64) +TEXT ·Yexpm1(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xexpm1(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yexpm1f(tls *TLS, x3 float32) (r float32) +TEXT ·Yexpm1f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xexpm1f(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yexpm1l(tls *TLS, x float64) (r float64) +TEXT ·Yexpm1l(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xexpm1l(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfabs(tls *TLS, x float64) (r float64) +TEXT ·Yfabs(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfabs(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfabsf(tls *TLS, x float32) (r float32) +TEXT ·Yfabsf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfabsf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfabsl(tls *TLS, x float64) (r float64) +TEXT ·Yfabsl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfabsl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfaccessat(tls *TLS, fd int32, filename uintptr, amode int32, flag int32) (r int32) +TEXT ·Yfaccessat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ filename+16(FP), AX + MOVQ AX, 16(SP) + MOVL amode+24(FP), AX + MOVL AX, 24(SP) + MOVL flag+28(FP), AX + MOVL AX, 28(SP) + CALL ·Xfaccessat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfallocate(tls *TLS, fd int32, mode int32, base Toff_t, len1 Toff_t) (r int32) +TEXT ·Yfallocate(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL mode+12(FP), AX + MOVL AX, 12(SP) + MOVQ base+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfallocate(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfanotify_init(tls *TLS, flags uint32, event_f_flags uint32) (r int32) +TEXT ·Yfanotify_init(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL flags+8(FP), AX + MOVL AX, 8(SP) + MOVL event_f_flags+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xfanotify_init(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfanotify_mark(tls *TLS, fanotify_fd int32, flags uint32, mask uint64, dfd int32, pathname uintptr) (r int32) +TEXT ·Yfanotify_mark(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fanotify_fd+8(FP), AX + MOVL AX, 8(SP) + MOVL flags+12(FP), AX + MOVL AX, 12(SP) + MOVQ mask+16(FP), AX + MOVQ AX, 16(SP) + MOVL dfd+24(FP), AX + MOVL AX, 24(SP) + MOVQ pathname+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xfanotify_mark(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yfchdir(tls *TLS, fd int32) (r int32) +TEXT ·Yfchdir(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfchdir(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfchmod(tls *TLS, fd int32, mode Tmode_t) (r int32) +TEXT ·Yfchmod(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL mode+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xfchmod(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfchmodat(tls *TLS, fd int32, path uintptr, mode Tmode_t, flag int32) (r int32) +TEXT ·Yfchmodat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL mode+24(FP), AX + MOVL AX, 24(SP) + MOVL flag+28(FP), AX + MOVL AX, 28(SP) + CALL ·Xfchmodat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfchown(tls *TLS, fd int32, uid Tuid_t, gid Tgid_t) (r int32) +TEXT ·Yfchown(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL uid+12(FP), AX + MOVL AX, 12(SP) + MOVL gid+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xfchown(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfchownat(tls *TLS, fd int32, path uintptr, uid Tuid_t, gid Tgid_t, flag int32) (r int32) +TEXT ·Yfchownat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL uid+24(FP), AX + MOVL AX, 24(SP) + MOVL gid+28(FP), AX + MOVL AX, 28(SP) + MOVL flag+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xfchownat(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yfclose(tls *TLS, f uintptr) (r1 int32) +TEXT ·Yfclose(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfclose(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yfcntl(tls *TLS, fd int32, cmd int32, va uintptr) (r int32) +TEXT ·Yfcntl(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL cmd+12(FP), AX + MOVL AX, 12(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfcntl(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfcntl64(tls *TLS, fd int32, cmd int32, va uintptr) (r int32) +TEXT ·Yfcntl64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL cmd+12(FP), AX + MOVL AX, 12(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfcntl64(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfcvt(tls *TLS, x float64, n int32, dp uintptr, sign uintptr) (r uintptr) +TEXT ·Yfcvt(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + MOVQ dp+24(FP), AX + MOVQ AX, 24(SP) + MOVQ sign+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xfcvt(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yfdatasync(tls *TLS, fd int32) (r int32) +TEXT ·Yfdatasync(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfdatasync(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfdim(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yfdim(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfdim(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfdimf(tls *TLS, x float32, y float32) (r float32) +TEXT ·Yfdimf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xfdimf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfdiml(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yfdiml(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfdiml(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfdopen(tls *TLS, fd int32, mode uintptr) (r uintptr) +TEXT ·Yfdopen(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ mode+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfdopen(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfdopendir(tls *TLS, fd int32) (r uintptr) +TEXT ·Yfdopendir(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfdopendir(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfeclearexcept(tls *TLS, mask int32) (r int32) +TEXT ·Yfeclearexcept(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL mask+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfeclearexcept(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfegetenv(tls *TLS, envp uintptr) (r int32) +TEXT ·Yfegetenv(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ envp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfegetenv(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfegetround(tls *TLS) (r int32) +TEXT ·Yfegetround(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xfegetround(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yfeof(tls *TLS, f uintptr) (r int32) +TEXT ·Yfeof(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfeof(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfeof_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Yfeof_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfeof_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yferaiseexcept(tls *TLS, mask int32) (r int32) +TEXT ·Yferaiseexcept(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL mask+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xferaiseexcept(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yferror(tls *TLS, f uintptr) (r int32) +TEXT ·Yferror(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xferror(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yferror_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Yferror_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xferror_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfesetenv(tls *TLS, envp uintptr) (r int32) +TEXT ·Yfesetenv(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ envp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfesetenv(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfetestexcept(tls *TLS, mask int32) (r int32) +TEXT ·Yfetestexcept(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL mask+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfetestexcept(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfexecve(tls *TLS, fd int32, argv uintptr, envp uintptr) (r1 int32) +TEXT ·Yfexecve(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ envp+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfexecve(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Yfflush(tls *TLS, f uintptr) (r1 int32) +TEXT ·Yfflush(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfflush(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yfflush_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Yfflush_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfflush_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yffs(tls *TLS, i int32) (r int32) +TEXT ·Yffs(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL i+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xffs(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yffsl(tls *TLS, i int64) (r int32) +TEXT ·Yffsl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ i+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xffsl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yffsll(tls *TLS, i int64) (r int32) +TEXT ·Yffsll(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ i+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xffsll(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfgetc(tls *TLS, f1 uintptr) (r int32) +TEXT ·Yfgetc(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfgetc(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfgetc_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Yfgetc_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfgetc_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfgetgrent(tls *TLS, f uintptr) (r uintptr) +TEXT ·Yfgetgrent(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfgetgrent(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfgetln(tls *TLS, f uintptr, plen uintptr) (r uintptr) +TEXT ·Yfgetln(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ plen+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfgetln(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfgetpos(tls *TLS, f uintptr, pos uintptr) (r int32) +TEXT ·Yfgetpos(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ pos+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfgetpos(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfgetpwent(tls *TLS, f uintptr) (r uintptr) +TEXT ·Yfgetpwent(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfgetpwent(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfgets(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) +TEXT ·Yfgets(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfgets(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yfgets_unlocked(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) +TEXT ·Yfgets_unlocked(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfgets_unlocked(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yfgetwc(tls *TLS, f uintptr) (r Twint_t) +TEXT ·Yfgetwc(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfgetwc(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) +TEXT ·Yfgetwc_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfgetwc_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfgetws(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) +TEXT ·Yfgetws(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfgetws(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yfgetws_unlocked(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) +TEXT ·Yfgetws_unlocked(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfgetws_unlocked(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yfgetxattr(tls *TLS, filedes int32, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) +TEXT ·Yfgetxattr(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL filedes+8(FP), AX + MOVL AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ value+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xfgetxattr(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yfileno(tls *TLS, f uintptr) (r int32) +TEXT ·Yfileno(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfileno(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfileno_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Yfileno_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfileno_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfinite(tls *TLS, x float64) (r int32) +TEXT ·Yfinite(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfinite(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfinitef(tls *TLS, x float32) (r int32) +TEXT ·Yfinitef(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfinitef(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yflistxattr(tls *TLS, filedes int32, list uintptr, size Tsize_t) (r Tssize_t) +TEXT ·Yflistxattr(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL filedes+8(FP), AX + MOVL AX, 8(SP) + MOVQ list+16(FP), AX + MOVQ AX, 16(SP) + MOVQ size+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xflistxattr(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yflock(tls *TLS, fd int32, op int32) (r int32) +TEXT ·Yflock(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL op+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xflock(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yflockfile(tls *TLS, f uintptr) +TEXT ·Yflockfile(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xflockfile(SB) + RET + +// func Yfloor(tls *TLS, x3 float64) (r float64) +TEXT ·Yfloor(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfloor(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfloorf(tls *TLS, x3 float32) (r float32) +TEXT ·Yfloorf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfloorf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfloorl(tls *TLS, x float64) (r float64) +TEXT ·Yfloorl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfloorl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfma(tls *TLS, x1 float64, y float64, z float64) (r1 float64) +TEXT ·Yfma(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + MOVQ z+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfma(SB) + MOVQ 32(SP), AX + MOVQ AX, r1+32(FP) + RET + +// func Yfmal(tls *TLS, x float64, y float64, z float64) (r float64) +TEXT ·Yfmal(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + MOVQ z+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfmal(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yfmax(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yfmax(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfmax(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfmaxf(tls *TLS, x float32, y float32) (r float32) +TEXT ·Yfmaxf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xfmaxf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfmaxl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yfmaxl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfmaxl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfmemopen(tls *TLS, buf uintptr, size Tsize_t, mode uintptr) (r uintptr) +TEXT ·Yfmemopen(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVQ mode+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfmemopen(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yfmin(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yfmin(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfmin(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfminf(tls *TLS, x float32, y float32) (r float32) +TEXT ·Yfminf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xfminf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfminl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yfminl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfminl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfmod(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yfmod(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfmod(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfmodf(tls *TLS, x float32, y float32) (r float32) +TEXT ·Yfmodf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xfmodf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfmodl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yfmodl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfmodl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfmtmsg(tls *TLS, classification int64, label uintptr, severity int32, text uintptr, action uintptr, tag uintptr) (r int32) +TEXT ·Yfmtmsg(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ classification+8(FP), AX + MOVQ AX, 8(SP) + MOVQ label+16(FP), AX + MOVQ AX, 16(SP) + MOVL severity+24(FP), AX + MOVL AX, 24(SP) + MOVQ text+32(FP), AX + MOVQ AX, 32(SP) + MOVQ action+40(FP), AX + MOVQ AX, 40(SP) + MOVQ tag+48(FP), AX + MOVQ AX, 48(SP) + CALL ·Xfmtmsg(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Yfnmatch(tls *TLS, pat uintptr, str uintptr, flags int32) (r int32) +TEXT ·Yfnmatch(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ pat+8(FP), AX + MOVQ AX, 8(SP) + MOVQ str+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xfnmatch(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfopen(tls *TLS, filename uintptr, mode uintptr) (r uintptr) +TEXT ·Yfopen(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mode+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfopen(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfopen64(tls *TLS, filename uintptr, mode uintptr) (r uintptr) +TEXT ·Yfopen64(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mode+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfopen64(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfopencookie(tls *TLS, cookie uintptr, mode uintptr, iofuncs Tcookie_io_functions_t) (r uintptr) +TEXT ·Yfopencookie(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ cookie+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mode+16(FP), AX + MOVQ AX, 16(SP) + MOVQ iofuncs_Fread+24(FP), AX + MOVQ AX, 24(SP) + MOVQ iofuncs_Fwrite+32(FP), AX + MOVQ AX, 32(SP) + MOVQ iofuncs_Fseek+40(FP), AX + MOVQ AX, 40(SP) + MOVQ iofuncs_Fclose1+48(FP), AX + MOVQ AX, 48(SP) + CALL ·Xfopencookie(SB) + MOVQ 56(SP), AX + MOVQ AX, r+56(FP) + RET + +// func Yfork(t *TLS) (_1 int32) +TEXT ·Yfork(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xfork(SB) + MOVL 8(SP), AX + MOVL AX, _1+8(FP) + RET + +// func Yfpathconf(tls *TLS, fd int32, name int32) (r int64) +TEXT ·Yfpathconf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL name+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xfpathconf(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yfprintf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Yfprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfpurge(tls *TLS, f uintptr) (r int32) +TEXT ·Yfpurge(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfpurge(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfputc(tls *TLS, c1 int32, f1 uintptr) (r int32) +TEXT ·Yfputc(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c1+8(FP), AX + MOVL AX, 8(SP) + MOVQ f1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfputc(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfputc_unlocked(tls *TLS, c int32, f uintptr) (r int32) +TEXT ·Yfputc_unlocked(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfputc_unlocked(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfputs(tls *TLS, s uintptr, f uintptr) (r int32) +TEXT ·Yfputs(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfputs(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfputs_unlocked(tls *TLS, s uintptr, f uintptr) (r int32) +TEXT ·Yfputs_unlocked(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfputs_unlocked(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfputwc(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) +TEXT ·Yfputwc(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfputwc(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) +TEXT ·Yfputwc_unlocked(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfputwc_unlocked(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfputws(tls *TLS, _ws uintptr, f uintptr) (r int32) +TEXT ·Yfputws(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _ws+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfputws(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfputws_unlocked(tls *TLS, _ws uintptr, f uintptr) (r int32) +TEXT ·Yfputws_unlocked(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _ws+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfputws_unlocked(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfread(tls *TLS, destv uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) +TEXT ·Yfread(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ destv+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVQ nmemb+24(FP), AX + MOVQ AX, 24(SP) + MOVQ f+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xfread(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yfread_unlocked(tls *TLS, destv uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) +TEXT ·Yfread_unlocked(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ destv+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVQ nmemb+24(FP), AX + MOVQ AX, 24(SP) + MOVQ f+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xfread_unlocked(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yfree(tls *TLS, p uintptr) +TEXT ·Yfree(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfree(SB) + RET + +// func Yfreeaddrinfo(tls *TLS, p uintptr) +TEXT ·Yfreeaddrinfo(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfreeaddrinfo(SB) + RET + +// func Yfreeifaddrs(tls *TLS, ifp uintptr) +TEXT ·Yfreeifaddrs(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ifp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfreeifaddrs(SB) + RET + +// func Yfreelocale(tls *TLS, l Tlocale_t) +TEXT ·Yfreelocale(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfreelocale(SB) + RET + +// func Yfremovexattr(tls *TLS, fd int32, name uintptr) (r int32) +TEXT ·Yfremovexattr(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfremovexattr(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfreopen(tls *TLS, filename uintptr, mode uintptr, f uintptr) (r uintptr) +TEXT ·Yfreopen(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mode+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfreopen(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yfrexp(tls *TLS, x float64, e uintptr) (r float64) +TEXT ·Yfrexp(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ e+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfrexp(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfrexpf(tls *TLS, x float32, e uintptr) (r float32) +TEXT ·Yfrexpf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVQ e+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfrexpf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfrexpl(tls *TLS, x float64, e uintptr) (r float64) +TEXT ·Yfrexpl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ e+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfrexpl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yfscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Yfscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfseek(tls *TLS, f uintptr, off int64, whence int32) (r int32) +TEXT ·Yfseek(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ off+16(FP), AX + MOVQ AX, 16(SP) + MOVL whence+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xfseek(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfseeko(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) +TEXT ·Yfseeko(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ off+16(FP), AX + MOVQ AX, 16(SP) + MOVL whence+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xfseeko(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfsetpos(tls *TLS, f uintptr, pos uintptr) (r int32) +TEXT ·Yfsetpos(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ pos+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfsetpos(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfsetxattr(tls *TLS, filedes int32, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) +TEXT ·Yfsetxattr(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL filedes+8(FP), AX + MOVL AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ value+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVL flags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xfsetxattr(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Yfstat(tls *TLS, fd int32, st uintptr) (r int32) +TEXT ·Yfstat(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ st+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfstat(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfstat64(tls *TLS, fd int32, st uintptr) (r int32) +TEXT ·Yfstat64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ st+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfstat64(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfstatat(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) +TEXT ·Yfstatat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVQ st+24(FP), AX + MOVQ AX, 24(SP) + MOVL flag+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xfstatat(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yfstatfs(tls *TLS, fd int32, buf uintptr) (r int32) +TEXT ·Yfstatfs(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfstatfs(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfstatvfs(tls *TLS, fd int32, buf uintptr) (r int32) +TEXT ·Yfstatvfs(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfstatvfs(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfsync(tls *TLS, fd int32) (r int32) +TEXT ·Yfsync(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xfsync(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yftell(tls *TLS, f uintptr) (r int64) +TEXT ·Yftell(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xftell(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yftello(tls *TLS, f uintptr) (r Toff_t) +TEXT ·Yftello(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xftello(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yftime(tls *TLS, tp uintptr) (r int32) +TEXT ·Yftime(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xftime(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yftok(tls *TLS, path uintptr, id int32) (r Tkey_t) +TEXT ·Yftok(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL id+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xftok(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yftruncate(tls *TLS, fd int32, length Toff_t) (r int32) +TEXT ·Yftruncate(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ length+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xftruncate(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yftruncate64(tls *TLS, fd int32, length Toff_t) (r int32) +TEXT ·Yftruncate64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ length+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xftruncate64(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yftrylockfile(tls *TLS, f uintptr) (r int32) +TEXT ·Yftrylockfile(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xftrylockfile(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yfts64_close(t *TLS, ftsp uintptr) (_2 int32) +TEXT ·Yfts64_close(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ftsp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfts64_close(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Yfts64_open(t *TLS, path_argv uintptr, options int32, compar uintptr) (_4 uintptr) +TEXT ·Yfts64_open(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path_argv+8(FP), AX + MOVQ AX, 8(SP) + MOVL options+16(FP), AX + MOVL AX, 16(SP) + MOVQ compar+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfts64_open(SB) + MOVQ 32(SP), AX + MOVQ AX, _4+32(FP) + RET + +// func Yfts64_read(t *TLS, ftsp uintptr) (_2 uintptr) +TEXT ·Yfts64_read(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ftsp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfts64_read(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Yfts_close(t *TLS, ftsp uintptr) (_2 int32) +TEXT ·Yfts_close(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ftsp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfts_close(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Yfts_open(t *TLS, path_argv uintptr, options int32, compar uintptr) (_4 uintptr) +TEXT ·Yfts_open(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path_argv+8(FP), AX + MOVQ AX, 8(SP) + MOVL options+16(FP), AX + MOVL AX, 16(SP) + MOVQ compar+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfts_open(SB) + MOVQ 32(SP), AX + MOVQ AX, _4+32(FP) + RET + +// func Yfts_read(t *TLS, ftsp uintptr) (_2 uintptr) +TEXT ·Yfts_read(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ftsp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfts_read(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Yftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32) (r int32) +TEXT ·Yftw(SB),$48-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_fn+16(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_ftw_1(SB) // Create the closure for calling __ccgo_fp_fn + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 16(SP) + MOVL fd_limit+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xftw(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_ftw_1(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVL _3+24(FP), AX + MOVL AX, 24(SP) + MOVQ __ccgo_fp+32(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 32(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Yfunlockfile(tls *TLS, f uintptr) +TEXT ·Yfunlockfile(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xfunlockfile(SB) + RET + +// func Yfutimens(tls *TLS, fd int32, times uintptr) (r int32) +TEXT ·Yfutimens(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ times+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfutimens(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfutimes(tls *TLS, fd int32, tv uintptr) (r int32) +TEXT ·Yfutimes(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ tv+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xfutimes(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfutimesat(tls *TLS, dirfd int32, pathname uintptr, times uintptr) (r int32) +TEXT ·Yfutimesat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL dirfd+8(FP), AX + MOVL AX, 8(SP) + MOVQ pathname+16(FP), AX + MOVQ AX, 16(SP) + MOVQ times+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfutimesat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfwide(tls *TLS, f uintptr, mode int32) (r int32) +TEXT ·Yfwide(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVL mode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xfwide(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yfwprintf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Yfwprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfwprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yfwrite(tls *TLS, src uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) +TEXT ·Yfwrite(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ src+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVQ nmemb+24(FP), AX + MOVQ AX, 24(SP) + MOVQ f+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xfwrite(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yfwrite_unlocked(tls *TLS, src uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) +TEXT ·Yfwrite_unlocked(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ src+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVQ nmemb+24(FP), AX + MOVQ AX, 24(SP) + MOVQ f+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xfwrite_unlocked(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yfwscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Yfwscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xfwscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ygai_strerror(tls *TLS, ecode int32) (r uintptr) +TEXT ·Ygai_strerror(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ecode+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xgai_strerror(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygcvt(tls *TLS, x float64, n int32, b uintptr) (r uintptr) +TEXT ·Ygcvt(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + MOVQ b+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgcvt(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yget_avphys_pages(tls *TLS) (r int64) +TEXT ·Yget_avphys_pages(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xget_avphys_pages(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Yget_current_dir_name(tls *TLS) (r uintptr) +TEXT ·Yget_current_dir_name(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xget_current_dir_name(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Yget_nprocs(tls *TLS) (r int32) +TEXT ·Yget_nprocs(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xget_nprocs(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yget_nprocs_conf(tls *TLS) (r int32) +TEXT ·Yget_nprocs_conf(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xget_nprocs_conf(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yget_phys_pages(tls *TLS) (r int64) +TEXT ·Yget_phys_pages(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xget_phys_pages(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetaddrinfo(tls *TLS, host uintptr, serv uintptr, hint uintptr, res uintptr) (r1 int32) +TEXT ·Ygetaddrinfo(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ host+8(FP), AX + MOVQ AX, 8(SP) + MOVQ serv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ hint+24(FP), AX + MOVQ AX, 24(SP) + MOVQ res+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xgetaddrinfo(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Ygetauxval(tls *TLS, item uint64) (r uint64) +TEXT ·Ygetauxval(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ item+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetauxval(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetc(tls *TLS, f1 uintptr) (r int32) +TEXT ·Ygetc(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetc(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ygetc_unlocked(tls *TLS, f uintptr) (r int32) +TEXT ·Ygetc_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetc_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ygetchar(tls *TLS) (r int32) +TEXT ·Ygetchar(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetchar(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetchar_unlocked(tls *TLS) (r int32) +TEXT ·Ygetchar_unlocked(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetchar_unlocked(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetcwd(tls *TLS, buf uintptr, size Tsize_t) (r uintptr) +TEXT ·Ygetcwd(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetcwd(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ygetdate(tls *TLS, s uintptr) (r uintptr) +TEXT ·Ygetdate(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetdate(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetdelim(tls *TLS, s uintptr, n uintptr, delim int32, f uintptr) (r Tssize_t) +TEXT ·Ygetdelim(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVL delim+24(FP), AX + MOVL AX, 24(SP) + MOVQ f+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xgetdelim(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ygetdents(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) +TEXT ·Ygetdents(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgetdents(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ygetdomainname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) +TEXT ·Ygetdomainname(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetdomainname(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygetdtablesize(tls *TLS) (r int32) +TEXT ·Ygetdtablesize(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetdtablesize(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetegid(tls *TLS) (r Tgid_t) +TEXT ·Ygetegid(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetegid(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetentropy(tls *TLS, buffer uintptr, len1 Tsize_t) (r int32) +TEXT ·Ygetentropy(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buffer+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetentropy(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygetenv(tls *TLS, name uintptr) (r uintptr) +TEXT ·Ygetenv(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetenv(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygeteuid(tls *TLS) (r Tuid_t) +TEXT ·Ygeteuid(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgeteuid(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetgid(tls *TLS) (r Tgid_t) +TEXT ·Ygetgid(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetgid(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetgrent(tls *TLS) (r uintptr) +TEXT ·Ygetgrent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetgrent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetgrgid(tls *TLS, gid Tgid_t) (r uintptr) +TEXT ·Ygetgrgid(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL gid+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xgetgrgid(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetgrgid_r(tls *TLS, gid Tgid_t, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) +TEXT ·Ygetgrgid_r(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL gid+8(FP), AX + MOVL AX, 8(SP) + MOVQ gr+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVQ res+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xgetgrgid_r(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ygetgrnam(tls *TLS, name uintptr) (r uintptr) +TEXT ·Ygetgrnam(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetgrnam(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetgrnam_r(tls *TLS, name uintptr, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) +TEXT ·Ygetgrnam_r(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ gr+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVQ res+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xgetgrnam_r(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ygetgrouplist(tls *TLS, user uintptr, gid Tgid_t, groups uintptr, ngroups uintptr) (r int32) +TEXT ·Ygetgrouplist(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ user+8(FP), AX + MOVQ AX, 8(SP) + MOVL gid+16(FP), AX + MOVL AX, 16(SP) + MOVQ groups+24(FP), AX + MOVQ AX, 24(SP) + MOVQ ngroups+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xgetgrouplist(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ygetgroups(tls *TLS, count int32, list uintptr) (r int32) +TEXT ·Ygetgroups(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL count+8(FP), AX + MOVL AX, 8(SP) + MOVQ list+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetgroups(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygethostbyaddr(tls *TLS, a uintptr, l Tsocklen_t, af int32) (r uintptr) +TEXT ·Ygethostbyaddr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVL l+16(FP), AX + MOVL AX, 16(SP) + MOVL af+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xgethostbyaddr(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ygethostbyaddr_r(tls *TLS, a uintptr, l Tsocklen_t, af int32, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) +TEXT ·Ygethostbyaddr_r(SB),$72-68 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVL l+16(FP), AX + MOVL AX, 16(SP) + MOVL af+20(FP), AX + MOVL AX, 20(SP) + MOVQ h+24(FP), AX + MOVQ AX, 24(SP) + MOVQ buf+32(FP), AX + MOVQ AX, 32(SP) + MOVQ buflen+40(FP), AX + MOVQ AX, 40(SP) + MOVQ res+48(FP), AX + MOVQ AX, 48(SP) + MOVQ err+56(FP), AX + MOVQ AX, 56(SP) + CALL ·Xgethostbyaddr_r(SB) + MOVL 64(SP), AX + MOVL AX, r+64(FP) + RET + +// func Ygethostbyname(tls *TLS, name uintptr) (r uintptr) +TEXT ·Ygethostbyname(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgethostbyname(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygethostbyname2(tls *TLS, name uintptr, af int32) (r uintptr) +TEXT ·Ygethostbyname2(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVL af+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xgethostbyname2(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ygethostbyname2_r(tls *TLS, name uintptr, af int32, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) +TEXT ·Ygethostbyname2_r(SB),$72-68 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVL af+16(FP), AX + MOVL AX, 16(SP) + MOVQ h+24(FP), AX + MOVQ AX, 24(SP) + MOVQ buf+32(FP), AX + MOVQ AX, 32(SP) + MOVQ buflen+40(FP), AX + MOVQ AX, 40(SP) + MOVQ res+48(FP), AX + MOVQ AX, 48(SP) + MOVQ err+56(FP), AX + MOVQ AX, 56(SP) + CALL ·Xgethostbyname2_r(SB) + MOVL 64(SP), AX + MOVL AX, r+64(FP) + RET + +// func Ygethostbyname_r(tls *TLS, name uintptr, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) +TEXT ·Ygethostbyname_r(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ h+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ buflen+32(FP), AX + MOVQ AX, 32(SP) + MOVQ res+40(FP), AX + MOVQ AX, 40(SP) + MOVQ err+48(FP), AX + MOVQ AX, 48(SP) + CALL ·Xgethostbyname_r(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Ygethostent(tls *TLS) (r uintptr) +TEXT ·Ygethostent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgethostent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygethostid(tls *TLS) (r int64) +TEXT ·Ygethostid(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgethostid(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygethostname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) +TEXT ·Ygethostname(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgethostname(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygetifaddrs(tls *TLS, ifap uintptr) (r1 int32) +TEXT ·Ygetifaddrs(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ifap+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetifaddrs(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Ygetitimer(tls *TLS, which int32, old uintptr) (r1 int32) +TEXT ·Ygetitimer(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL which+8(FP), AX + MOVL AX, 8(SP) + MOVQ old+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetitimer(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ygetline(tls *TLS, s uintptr, n uintptr, f uintptr) (r Tssize_t) +TEXT ·Ygetline(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgetline(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ygetloadavg(tls *TLS, a uintptr, n int32) (r int32) +TEXT ·Ygetloadavg(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xgetloadavg(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygetlogin(tls *TLS) (r uintptr) +TEXT ·Ygetlogin(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetlogin(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetlogin_r(tls *TLS, name uintptr, size Tsize_t) (r int32) +TEXT ·Ygetlogin_r(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetlogin_r(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygetmntent(tls *TLS, f uintptr) (r uintptr) +TEXT ·Ygetmntent(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetmntent(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetmntent_r(tls *TLS, f uintptr, mnt uintptr, linebuf uintptr, buflen int32) (r uintptr) +TEXT ·Ygetmntent_r(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mnt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ linebuf+24(FP), AX + MOVQ AX, 24(SP) + MOVL buflen+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xgetmntent_r(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ygetnameinfo(tls *TLS, sa uintptr, sl Tsocklen_t, node uintptr, nodelen Tsocklen_t, serv uintptr, servlen Tsocklen_t, flags int32) (r int32) +TEXT ·Ygetnameinfo(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ sa+8(FP), AX + MOVQ AX, 8(SP) + MOVL sl+16(FP), AX + MOVL AX, 16(SP) + MOVQ node+24(FP), AX + MOVQ AX, 24(SP) + MOVL nodelen+32(FP), AX + MOVL AX, 32(SP) + MOVQ serv+40(FP), AX + MOVQ AX, 40(SP) + MOVL servlen+48(FP), AX + MOVL AX, 48(SP) + MOVL flags+52(FP), AX + MOVL AX, 52(SP) + CALL ·Xgetnameinfo(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Ygetnetbyaddr(tls *TLS, net Tuint32_t, type1 int32) (r uintptr) +TEXT ·Ygetnetbyaddr(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL net+8(FP), AX + MOVL AX, 8(SP) + MOVL type1+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xgetnetbyaddr(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetnetbyname(tls *TLS, name uintptr) (r uintptr) +TEXT ·Ygetnetbyname(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetnetbyname(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetnetent(tls *TLS) (r uintptr) +TEXT ·Ygetnetent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetnetent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetopt(tls *TLS, argc int32, argv uintptr, optstring uintptr) (r int32) +TEXT ·Ygetopt(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL argc+8(FP), AX + MOVL AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ optstring+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgetopt(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ygetopt_long(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr) (r int32) +TEXT ·Ygetopt_long(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL argc+8(FP), AX + MOVL AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ optstring+24(FP), AX + MOVQ AX, 24(SP) + MOVQ longopts+32(FP), AX + MOVQ AX, 32(SP) + MOVQ idx+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xgetopt_long(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ygetopt_long_only(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr) (r int32) +TEXT ·Ygetopt_long_only(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL argc+8(FP), AX + MOVL AX, 8(SP) + MOVQ argv+16(FP), AX + MOVQ AX, 16(SP) + MOVQ optstring+24(FP), AX + MOVQ AX, 24(SP) + MOVQ longopts+32(FP), AX + MOVQ AX, 32(SP) + MOVQ idx+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xgetopt_long_only(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ygetpagesize(tls *TLS) (r int32) +TEXT ·Ygetpagesize(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetpagesize(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetpass(tls *TLS, prompt uintptr) (r uintptr) +TEXT ·Ygetpass(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ prompt+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetpass(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetpeername(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) +TEXT ·Ygetpeername(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ addr+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgetpeername(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ygetpgid(tls *TLS, pid Tpid_t) (r Tpid_t) +TEXT ·Ygetpgid(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xgetpgid(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ygetpgrp(tls *TLS) (r Tpid_t) +TEXT ·Ygetpgrp(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetpgrp(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetpid(tls *TLS) (r Tpid_t) +TEXT ·Ygetpid(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetpid(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetppid(tls *TLS) (r Tpid_t) +TEXT ·Ygetppid(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetppid(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetpriority(tls *TLS, which int32, who Tid_t) (r int32) +TEXT ·Ygetpriority(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL which+8(FP), AX + MOVL AX, 8(SP) + MOVL who+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xgetpriority(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ygetprotobyname(tls *TLS, name uintptr) (r uintptr) +TEXT ·Ygetprotobyname(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetprotobyname(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetprotobynumber(tls *TLS, num int32) (r uintptr) +TEXT ·Ygetprotobynumber(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL num+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xgetprotobynumber(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetprotoent(tls *TLS) (r uintptr) +TEXT ·Ygetprotoent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetprotoent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetpwent(tls *TLS) (r uintptr) +TEXT ·Ygetpwent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetpwent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetpwnam(tls *TLS, name uintptr) (r uintptr) +TEXT ·Ygetpwnam(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetpwnam(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetpwnam_r(tls *TLS, name uintptr, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) +TEXT ·Ygetpwnam_r(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ pw+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVQ res+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xgetpwnam_r(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ygetpwuid(tls *TLS, uid Tuid_t) (r uintptr) +TEXT ·Ygetpwuid(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL uid+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xgetpwuid(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetpwuid_r(tls *TLS, uid Tuid_t, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) +TEXT ·Ygetpwuid_r(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL uid+8(FP), AX + MOVL AX, 8(SP) + MOVQ pw+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVQ res+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xgetpwuid_r(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ygetrandom(tls *TLS, buf uintptr, buflen Tsize_t, flags uint32) (r Tssize_t) +TEXT ·Ygetrandom(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buflen+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xgetrandom(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ygetresgid(tls *TLS, rgid uintptr, egid uintptr, sgid uintptr) (r int32) +TEXT ·Ygetresgid(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ rgid+8(FP), AX + MOVQ AX, 8(SP) + MOVQ egid+16(FP), AX + MOVQ AX, 16(SP) + MOVQ sgid+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgetresgid(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ygetresuid(tls *TLS, ruid uintptr, euid uintptr, suid uintptr) (r int32) +TEXT ·Ygetresuid(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ruid+8(FP), AX + MOVQ AX, 8(SP) + MOVQ euid+16(FP), AX + MOVQ AX, 16(SP) + MOVQ suid+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgetresuid(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ygetrlimit(tls *TLS, resource int32, rlim uintptr) (r int32) +TEXT ·Ygetrlimit(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL resource+8(FP), AX + MOVL AX, 8(SP) + MOVQ rlim+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetrlimit(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygetrlimit64(tls *TLS, resource int32, rlim uintptr) (r int32) +TEXT ·Ygetrlimit64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL resource+8(FP), AX + MOVL AX, 8(SP) + MOVQ rlim+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetrlimit64(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygetrusage(tls *TLS, who int32, ru uintptr) (r1 int32) +TEXT ·Ygetrusage(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL who+8(FP), AX + MOVL AX, 8(SP) + MOVQ ru+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetrusage(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ygets(tls *TLS, s uintptr) (r uintptr) +TEXT ·Ygets(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgets(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetservbyname(tls *TLS, name uintptr, prots uintptr) (r uintptr) +TEXT ·Ygetservbyname(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ prots+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgetservbyname(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ygetservbyname_r(tls *TLS, name uintptr, prots uintptr, se uintptr, buf uintptr, buflen Tsize_t, res uintptr) (r int32) +TEXT ·Ygetservbyname_r(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ prots+16(FP), AX + MOVQ AX, 16(SP) + MOVQ se+24(FP), AX + MOVQ AX, 24(SP) + MOVQ buf+32(FP), AX + MOVQ AX, 32(SP) + MOVQ buflen+40(FP), AX + MOVQ AX, 40(SP) + MOVQ res+48(FP), AX + MOVQ AX, 48(SP) + CALL ·Xgetservbyname_r(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Ygetservent(tls *TLS) (r uintptr) +TEXT ·Ygetservent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetservent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetsid(tls *TLS, pid Tpid_t) (r Tpid_t) +TEXT ·Ygetsid(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xgetsid(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ygetsockname(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) +TEXT ·Ygetsockname(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ addr+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgetsockname(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ygetsockopt(tls *TLS, fd int32, level int32, optname int32, optval uintptr, optlen uintptr) (r2 int32) +TEXT ·Ygetsockopt(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL level+12(FP), AX + MOVL AX, 12(SP) + MOVL optname+16(FP), AX + MOVL AX, 16(SP) + MOVQ optval+24(FP), AX + MOVQ AX, 24(SP) + MOVQ optlen+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xgetsockopt(SB) + MOVL 40(SP), AX + MOVL AX, r2+40(FP) + RET + +// func Ygetspent(tls *TLS) (r uintptr) +TEXT ·Ygetspent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetspent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetsubopt(tls *TLS, opt uintptr, keys uintptr, val uintptr) (r int32) +TEXT ·Ygetsubopt(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ opt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ keys+16(FP), AX + MOVQ AX, 16(SP) + MOVQ val+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xgetsubopt(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ygettext(tls *TLS, msgid uintptr) (r uintptr) +TEXT ·Ygettext(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msgid+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgettext(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygettimeofday(tls *TLS, tv uintptr, tz uintptr) (r int32) +TEXT ·Ygettimeofday(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tv+8(FP), AX + MOVQ AX, 8(SP) + MOVQ tz+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgettimeofday(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ygetuid(tls *TLS) (r Tuid_t) +TEXT ·Ygetuid(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetuid(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetusershell(tls *TLS) (r uintptr) +TEXT ·Ygetusershell(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetusershell(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetutent(tls *TLS) (r uintptr) +TEXT ·Ygetutent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetutent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetutid(tls *TLS, ut uintptr) (r uintptr) +TEXT ·Ygetutid(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ut+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetutid(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetutline(tls *TLS, ut uintptr) (r uintptr) +TEXT ·Ygetutline(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ut+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetutline(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetutxent(tls *TLS) (r uintptr) +TEXT ·Ygetutxent(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetutxent(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ygetutxid(tls *TLS, ut uintptr) (r uintptr) +TEXT ·Ygetutxid(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ut+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetutxid(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetutxline(tls *TLS, ut uintptr) (r uintptr) +TEXT ·Ygetutxline(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ut+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetutxline(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygetw(tls *TLS, f uintptr) (r int32) +TEXT ·Ygetw(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetw(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ygetwc(tls *TLS, f uintptr) (r Twint_t) +TEXT ·Ygetwc(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetwc(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ygetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) +TEXT ·Ygetwc_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgetwc_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ygetwchar(tls *TLS) (r Twint_t) +TEXT ·Ygetwchar(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetwchar(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetwchar_unlocked(tls *TLS) (r Twint_t) +TEXT ·Ygetwchar_unlocked(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xgetwchar_unlocked(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ygetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) +TEXT ·Ygetxattr(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ value+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xgetxattr(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yglob(tls *TLS, pat uintptr, flags int32, __ccgo_fp_errfunc uintptr, g_ uintptr) (r int32) +TEXT ·Yglob(SB),$56-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_errfunc+24(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_glob_2(SB) // Create the closure for calling __ccgo_fp_errfunc + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ pat+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 24(SP) + MOVQ g_+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xglob(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_glob_2(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVL _2+16(FP), AX + MOVL AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Yglobfree(tls *TLS, g_ uintptr) +TEXT ·Yglobfree(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ g_+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xglobfree(SB) + RET + +// func Ygmtime(tls *TLS, t uintptr) (r uintptr) +TEXT ·Ygmtime(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xgmtime(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ygmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) +TEXT ·Ygmtime_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ tm+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xgmtime_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ygrantpt(tls *TLS, fd int32) (r int32) +TEXT ·Ygrantpt(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xgrantpt(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yhasmntopt(tls *TLS, mnt uintptr, opt uintptr) (r uintptr) +TEXT ·Yhasmntopt(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ mnt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ opt+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xhasmntopt(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yhcreate(tls *TLS, nel Tsize_t) (r int32) +TEXT ·Yhcreate(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ nel+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xhcreate(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yhdestroy(tls *TLS) +TEXT ·Yhdestroy(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xhdestroy(SB) + RET + +// func Yherror(tls *TLS, msg uintptr) +TEXT ·Yherror(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msg+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xherror(SB) + RET + +// func Yhsearch(tls *TLS, item TENTRY, action TACTION) (r uintptr) +TEXT ·Yhsearch(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ item_Fkey+8(FP), AX + MOVQ AX, 8(SP) + MOVQ item_Fdata+16(FP), AX + MOVQ AX, 16(SP) + MOVL action+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xhsearch(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yhstrerror(tls *TLS, ecode int32) (r uintptr) +TEXT ·Yhstrerror(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL ecode+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xhstrerror(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yhtonl(tls *TLS, n Tuint32_t) (r Tuint32_t) +TEXT ·Yhtonl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xhtonl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yhtons(tls *TLS, n Tuint16_t) (r Tuint16_t) +TEXT ·Yhtons(SB),$24-18 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVW n+8(FP), AX + MOVW AX, 8(SP) + CALL ·Xhtons(SB) + MOVW 16(SP), AX + MOVW AX, r+16(FP) + RET + +// func Yhypot(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yhypot(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xhypot(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yhypotf(tls *TLS, x float32, y float32) (r float32) +TEXT ·Yhypotf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xhypotf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yhypotl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yhypotl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xhypotl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yiconv(tls *TLS, cd Ticonv_t, in uintptr, inb uintptr, out uintptr, outb uintptr) (r Tsize_t) +TEXT ·Yiconv(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ cd+8(FP), AX + MOVQ AX, 8(SP) + MOVQ in+16(FP), AX + MOVQ AX, 16(SP) + MOVQ inb+24(FP), AX + MOVQ AX, 24(SP) + MOVQ out+32(FP), AX + MOVQ AX, 32(SP) + MOVQ outb+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xiconv(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Yiconv_close(tls *TLS, cd Ticonv_t) (r int32) +TEXT ·Yiconv_close(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ cd+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xiconv_close(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiconv_open(tls *TLS, to uintptr, from uintptr) (r Ticonv_t) +TEXT ·Yiconv_open(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ to+8(FP), AX + MOVQ AX, 8(SP) + MOVQ from+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiconv_open(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yif_freenameindex(tls *TLS, idx uintptr) +TEXT ·Yif_freenameindex(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ idx+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xif_freenameindex(SB) + RET + +// func Yif_indextoname(tls *TLS, index uint32, name uintptr) (r1 uintptr) +TEXT ·Yif_indextoname(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL index+8(FP), AX + MOVL AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xif_indextoname(SB) + MOVQ 24(SP), AX + MOVQ AX, r1+24(FP) + RET + +// func Yif_nameindex(tls *TLS) (r uintptr) +TEXT ·Yif_nameindex(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xif_nameindex(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Yif_nametoindex(tls *TLS, name uintptr) (r1 uint32) +TEXT ·Yif_nametoindex(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xif_nametoindex(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yilogb(tls *TLS, x3 float64) (r int32) +TEXT ·Yilogb(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xilogb(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yilogbf(tls *TLS, x3 float32) (r int32) +TEXT ·Yilogbf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xilogbf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yilogbl(tls *TLS, x float64) (r int32) +TEXT ·Yilogbl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xilogbl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yimaxabs(tls *TLS, a Tintmax_t) (r Tintmax_t) +TEXT ·Yimaxabs(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Ximaxabs(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yimaxdiv(tls *TLS, num Tintmax_t, den Tintmax_t) (r Timaxdiv_t) +TEXT ·Yimaxdiv(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ num+8(FP), AX + MOVQ AX, 8(SP) + MOVQ den+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Ximaxdiv(SB) + MOVQ 24(SP), AX + MOVQ AX, r_Fquot+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_Frem+32(FP) + RET + +// func Yindex(tls *TLS, s uintptr, c int32) (r uintptr) +TEXT ·Yindex(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xindex(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yinet_addr(tls *TLS, p uintptr) (r Tin_addr_t) +TEXT ·Yinet_addr(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xinet_addr(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yinet_aton(tls *TLS, s0 uintptr, dest uintptr) (r int32) +TEXT ·Yinet_aton(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s0+8(FP), AX + MOVQ AX, 8(SP) + MOVQ dest+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xinet_aton(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yinet_lnaof(tls *TLS, in Tin_addr) (r Tin_addr_t) +TEXT ·Yinet_lnaof(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL in_Fs_addr+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xinet_lnaof(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yinet_makeaddr(tls *TLS, n Tin_addr_t, h Tin_addr_t) (r Tin_addr) +TEXT ·Yinet_makeaddr(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + MOVL h+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xinet_makeaddr(SB) + MOVL 16(SP), AX + MOVL AX, r_Fs_addr+16(FP) + RET + +// func Yinet_netof(tls *TLS, in Tin_addr) (r Tin_addr_t) +TEXT ·Yinet_netof(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL in_Fs_addr+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xinet_netof(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yinet_network(tls *TLS, p uintptr) (r Tin_addr_t) +TEXT ·Yinet_network(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xinet_network(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yinet_ntoa(tls *TLS, _in Tin_addr) (r uintptr) +TEXT ·Yinet_ntoa(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL _in_Fs_addr+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xinet_ntoa(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yinet_ntop(tls *TLS, af int32, a0 uintptr, s uintptr, l Tsocklen_t) (r uintptr) +TEXT ·Yinet_ntop(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL af+8(FP), AX + MOVL AX, 8(SP) + MOVQ a0+16(FP), AX + MOVQ AX, 16(SP) + MOVQ s+24(FP), AX + MOVQ AX, 24(SP) + MOVL l+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xinet_ntop(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yinet_pton(tls *TLS, af int32, s uintptr, a0 uintptr) (r int32) +TEXT ·Yinet_pton(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL af+8(FP), AX + MOVL AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ a0+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xinet_pton(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yinit_module(tls *TLS, a uintptr, b uint64, c uintptr) (r int32) +TEXT ·Yinit_module(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + MOVQ c+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xinit_module(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yinitstate(tls *TLS, seed uint32, state uintptr, size Tsize_t) (r uintptr) +TEXT ·Yinitstate(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL seed+8(FP), AX + MOVL AX, 8(SP) + MOVQ state+16(FP), AX + MOVQ AX, 16(SP) + MOVQ size+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xinitstate(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yinitstate_r(t *TLS, seed uint32, statebuf uintptr, statelen Tsize_t, buf uintptr) (_5 int32) +TEXT ·Yinitstate_r(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL seed+8(FP), AX + MOVL AX, 8(SP) + MOVQ statebuf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ statelen+24(FP), AX + MOVQ AX, 24(SP) + MOVQ buf+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xinitstate_r(SB) + MOVL 40(SP), AX + MOVL AX, _5+40(FP) + RET + +// func Yinotify_add_watch(tls *TLS, fd int32, pathname uintptr, mask Tuint32_t) (r int32) +TEXT ·Yinotify_add_watch(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ pathname+16(FP), AX + MOVQ AX, 16(SP) + MOVL mask+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xinotify_add_watch(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yinotify_init(tls *TLS) (r int32) +TEXT ·Yinotify_init(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xinotify_init(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yinotify_init1(tls *TLS, flags int32) (r1 int32) +TEXT ·Yinotify_init1(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL flags+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xinotify_init1(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yinotify_rm_watch(tls *TLS, fd int32, wd int32) (r int32) +TEXT ·Yinotify_rm_watch(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL wd+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xinotify_rm_watch(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yinsque(tls *TLS, element uintptr, pred uintptr) +TEXT ·Yinsque(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ element+8(FP), AX + MOVQ AX, 8(SP) + MOVQ pred+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xinsque(SB) + RET + +// func Yioctl(tls *TLS, fd int32, req int32, va uintptr) (r1 int32) +TEXT ·Yioctl(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL req+12(FP), AX + MOVL AX, 12(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xioctl(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Yioperm(tls *TLS, from uint64, num uint64, turn_on int32) (r int32) +TEXT ·Yioperm(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ from+8(FP), AX + MOVQ AX, 8(SP) + MOVQ num+16(FP), AX + MOVQ AX, 16(SP) + MOVL turn_on+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xioperm(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yiopl(tls *TLS, level int32) (r int32) +TEXT ·Yiopl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL level+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiopl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisalnum(tls *TLS, c int32) (r int32) +TEXT ·Yisalnum(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisalnum(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisalnum_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisalnum_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisalnum_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yisalpha(tls *TLS, c int32) (r int32) +TEXT ·Yisalpha(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisalpha(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisalpha_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisalpha_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisalpha_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yisascii(tls *TLS, c int32) (r int32) +TEXT ·Yisascii(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisascii(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisastream(tls *TLS, fd int32) (r int32) +TEXT ·Yisastream(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisastream(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisatty(tls *TLS, fd int32) (r1 int32) +TEXT ·Yisatty(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisatty(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yisblank(tls *TLS, c int32) (r int32) +TEXT ·Yisblank(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisblank(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisblank_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisblank_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisblank_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiscntrl(tls *TLS, c int32) (r int32) +TEXT ·Yiscntrl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiscntrl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiscntrl_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yiscntrl_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiscntrl_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yisdigit(tls *TLS, c int32) (r int32) +TEXT ·Yisdigit(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisdigit(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisdigit_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisdigit_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yisgraph(tls *TLS, c int32) (r int32) +TEXT ·Yisgraph(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisgraph(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisgraph_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisgraph_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisgraph_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yislower(tls *TLS, c int32) (r int32) +TEXT ·Yislower(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xislower(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yislower_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yislower_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xislower_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yisnan(t *TLS, x float64) (_2 int32) +TEXT ·Yisnan(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xisnan(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Yisnanf(t *TLS, arg float32) (_2 int32) +TEXT ·Yisnanf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL arg+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisnanf(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Yisnanl(t *TLS, arg float64) (_2 int32) +TEXT ·Yisnanl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ arg+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xisnanl(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Yisprint(tls *TLS, c int32) (r int32) +TEXT ·Yisprint(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisprint(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisprint_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisprint_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisprint_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yispunct(tls *TLS, c int32) (r int32) +TEXT ·Yispunct(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xispunct(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yispunct_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yispunct_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xispunct_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yissetugid(tls *TLS) (r int32) +TEXT ·Yissetugid(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xissetugid(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yisspace(tls *TLS, c int32) (r int32) +TEXT ·Yisspace(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisspace(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisspace_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisspace_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisspace_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yisupper(tls *TLS, c int32) (r int32) +TEXT ·Yisupper(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisupper(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisupper_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisupper_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswalnum(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswalnum(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswalnum(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswalnum_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswalnum_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswalnum_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswalpha(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswalpha(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswalpha(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswalpha_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswalpha_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswalpha_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswblank(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswblank(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswblank(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswblank_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswblank_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswblank_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswcntrl(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswcntrl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswcntrl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswcntrl_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswcntrl_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswcntrl_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswctype(tls *TLS, wc Twint_t, type1 Twctype_t) (r int32) +TEXT ·Yiswctype(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + MOVQ type1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswctype(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswctype_l(tls *TLS, c Twint_t, t Twctype_t, l Tlocale_t) (r int32) +TEXT ·Yiswctype_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ t+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xiswctype_l(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yiswdigit(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswdigit(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswdigit(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswdigit_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswdigit_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswgraph(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswgraph(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswgraph(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswgraph_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswgraph_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswgraph_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswlower(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswlower(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswlower(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswlower_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswlower_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswprint(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswprint(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswprint(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswprint_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswprint_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswprint_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswpunct(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswpunct(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswpunct(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswpunct_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswpunct_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswpunct_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswspace(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswspace(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswspace(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswspace_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswspace_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswspace_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswupper(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswupper(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswupper(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswupper_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswupper_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yiswxdigit(tls *TLS, wc Twint_t) (r int32) +TEXT ·Yiswxdigit(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xiswxdigit(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yiswxdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) +TEXT ·Yiswxdigit_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xiswxdigit_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yisxdigit(tls *TLS, c int32) (r int32) +TEXT ·Yisxdigit(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xisxdigit(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yisxdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Yisxdigit_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xisxdigit_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yj0(tls *TLS, x float64) (r1 float64) +TEXT ·Yj0(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xj0(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Yj0f(tls *TLS, x float32) (r1 float32) +TEXT ·Yj0f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xj0f(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yj1(tls *TLS, x float64) (r1 float64) +TEXT ·Yj1(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xj1(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Yj1f(tls *TLS, x float32) (r1 float32) +TEXT ·Yj1f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xj1f(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yjn(tls *TLS, n int32, x float64) (r float64) +TEXT ·Yjn(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + MOVQ x+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xjn(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yjnf(tls *TLS, n int32, x float32) (r float32) +TEXT ·Yjnf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + MOVL x+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xjnf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yjrand48(tls *TLS, s uintptr) (r int64) +TEXT ·Yjrand48(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xjrand48(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ykill(tls *TLS, pid Tpid_t, sig int32) (r int32) +TEXT ·Ykill(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVL sig+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xkill(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ykillpg(tls *TLS, pgid Tpid_t, sig int32) (r int32) +TEXT ·Ykillpg(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pgid+8(FP), AX + MOVL AX, 8(SP) + MOVL sig+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xkillpg(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yklogctl(tls *TLS, type1 int32, buf uintptr, len1 int32) (r int32) +TEXT ·Yklogctl(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL type1+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVL len1+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xklogctl(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yl64a(tls *TLS, x0 int64) (r uintptr) +TEXT ·Yl64a(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x0+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xl64a(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylabs(tls *TLS, a int64) (r int64) +TEXT ·Ylabs(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlabs(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylchmod(tls *TLS, path uintptr, mode Tmode_t) (r int32) +TEXT ·Ylchmod(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL mode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xlchmod(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ylchown(tls *TLS, path uintptr, uid Tuid_t, gid Tgid_t) (r int32) +TEXT ·Ylchown(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL uid+16(FP), AX + MOVL AX, 16(SP) + MOVL gid+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xlchown(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ylckpwdf(tls *TLS) (r int32) +TEXT ·Ylckpwdf(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xlckpwdf(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ylcong48(tls *TLS, p uintptr) +TEXT ·Ylcong48(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlcong48(SB) + RET + +// func Yldexp(tls *TLS, x float64, n int32) (r float64) +TEXT ·Yldexp(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xldexp(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yldexpf(tls *TLS, x float32, n int32) (r float32) +TEXT ·Yldexpf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL n+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xldexpf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yldexpl(tls *TLS, x float64, n int32) (r float64) +TEXT ·Yldexpl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xldexpl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yldiv(tls *TLS, num int64, den int64) (r Tldiv_t) +TEXT ·Yldiv(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ num+8(FP), AX + MOVQ AX, 8(SP) + MOVQ den+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xldiv(SB) + MOVQ 24(SP), AX + MOVQ AX, r_Fquot+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_Frem+32(FP) + RET + +// func Ylfind(tls *TLS, key uintptr, base uintptr, nelp uintptr, width Tsize_t, __ccgo_fp_compar uintptr) (r uintptr) +TEXT ·Ylfind(SB),$64-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_compar+40(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_lfind_4(SB) // Create the closure for calling __ccgo_fp_compar + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ base+16(FP), AX + MOVQ AX, 16(SP) + MOVQ nelp+24(FP), AX + MOVQ AX, 24(SP) + MOVQ width+32(FP), AX + MOVQ AX, 32(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 40(SP) + CALL ·Xlfind(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_lfind_4(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Ylgamma(tls *TLS, x float64) (r float64) +TEXT ·Ylgamma(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlgamma(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylgamma_r(tls *TLS, x float64, signgamp uintptr) (r float64) +TEXT ·Ylgamma_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ signgamp+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlgamma_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ylgammaf(tls *TLS, x float32) (r float32) +TEXT ·Ylgammaf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlgammaf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ylgammaf_r(tls *TLS, x float32, signgamp uintptr) (r float32) +TEXT ·Ylgammaf_r(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVQ signgamp+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlgammaf_r(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ylgammal(tls *TLS, x float64) (r float64) +TEXT ·Ylgammal(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlgammal(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylgammal_r(tls *TLS, x float64, sg uintptr) (r float64) +TEXT ·Ylgammal_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sg+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlgammal_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ylgetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) +TEXT ·Ylgetxattr(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ value+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xlgetxattr(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ylink(tls *TLS, existing uintptr, new1 uintptr) (r int32) +TEXT ·Ylink(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ existing+8(FP), AX + MOVQ AX, 8(SP) + MOVQ new1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlink(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ylinkat(tls *TLS, fd1 int32, existing uintptr, fd2 int32, new1 uintptr, flag int32) (r int32) +TEXT ·Ylinkat(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd1+8(FP), AX + MOVL AX, 8(SP) + MOVQ existing+16(FP), AX + MOVQ AX, 16(SP) + MOVL fd2+24(FP), AX + MOVL AX, 24(SP) + MOVQ new1+32(FP), AX + MOVQ AX, 32(SP) + MOVL flag+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xlinkat(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ylisten(tls *TLS, fd int32, backlog int32) (r1 int32) +TEXT ·Ylisten(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL backlog+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xlisten(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Ylistxattr(tls *TLS, path uintptr, list uintptr, size Tsize_t) (r Tssize_t) +TEXT ·Ylistxattr(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ list+16(FP), AX + MOVQ AX, 16(SP) + MOVQ size+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xlistxattr(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yllabs(tls *TLS, a int64) (r int64) +TEXT ·Yllabs(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xllabs(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylldiv(tls *TLS, num int64, den int64) (r Tlldiv_t) +TEXT ·Ylldiv(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ num+8(FP), AX + MOVQ AX, 8(SP) + MOVQ den+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlldiv(SB) + MOVQ 24(SP), AX + MOVQ AX, r_Fquot+24(FP) + MOVQ 32(SP), AX + MOVQ AX, r_Frem+32(FP) + RET + +// func Yllistxattr(tls *TLS, path uintptr, list uintptr, size Tsize_t) (r Tssize_t) +TEXT ·Yllistxattr(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ list+16(FP), AX + MOVQ AX, 16(SP) + MOVQ size+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xllistxattr(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yllrint(tls *TLS, x float64) (r int64) +TEXT ·Yllrint(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xllrint(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yllrintf(tls *TLS, x float32) (r int64) +TEXT ·Yllrintf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xllrintf(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yllrintl(tls *TLS, x float64) (r int64) +TEXT ·Yllrintl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xllrintl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yllround(tls *TLS, x float64) (r int64) +TEXT ·Yllround(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xllround(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yllroundf(tls *TLS, x float32) (r int64) +TEXT ·Yllroundf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xllroundf(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yllroundl(tls *TLS, x float64) (r int64) +TEXT ·Yllroundl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xllroundl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylocaleconv(tls *TLS) (r uintptr) +TEXT ·Ylocaleconv(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xlocaleconv(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ylocaltime(tls *TLS, t uintptr) (r uintptr) +TEXT ·Ylocaltime(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlocaltime(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylocaltime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) +TEXT ·Ylocaltime_r(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ tm+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlocaltime_r(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ylockf(tls *TLS, fd int32, op int32, size Toff_t) (r int32) +TEXT ·Ylockf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL op+12(FP), AX + MOVL AX, 12(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlockf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ylog(tls *TLS, x1 float64) (r1 float64) +TEXT ·Ylog(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlog(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Ylog10(tls *TLS, x float64) (r float64) +TEXT ·Ylog10(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlog10(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylog10f(tls *TLS, x float32) (r float32) +TEXT ·Ylog10f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlog10f(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ylog10l(tls *TLS, x float64) (r float64) +TEXT ·Ylog10l(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlog10l(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylog1p(tls *TLS, x3 float64) (r float64) +TEXT ·Ylog1p(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlog1p(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylog1pf(tls *TLS, x3 float32) (r float32) +TEXT ·Ylog1pf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlog1pf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ylog1pl(tls *TLS, x float64) (r float64) +TEXT ·Ylog1pl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlog1pl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylog2(tls *TLS, x1 float64) (r1 float64) +TEXT ·Ylog2(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlog2(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Ylog2f(tls *TLS, x1 float32) (r1 float32) +TEXT ·Ylog2f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x1+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlog2f(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Ylog2l(tls *TLS, x float64) (r float64) +TEXT ·Ylog2l(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlog2l(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylogb(tls *TLS, x float64) (r float64) +TEXT ·Ylogb(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlogb(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylogbf(tls *TLS, x float32) (r float32) +TEXT ·Ylogbf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlogbf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ylogbl(tls *TLS, x float64) (r float64) +TEXT ·Ylogbl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlogbl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylogf(tls *TLS, x1 float32) (r1 float32) +TEXT ·Ylogf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x1+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlogf(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Ylogin_tty(tls *TLS, fd int32) (r int32) +TEXT ·Ylogin_tty(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlogin_tty(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ylogl(tls *TLS, x float64) (r float64) +TEXT ·Ylogl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlogl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylongjmp(t *TLS, env uintptr, val int32) +TEXT ·Ylongjmp(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ env+8(FP), AX + MOVQ AX, 8(SP) + MOVL val+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xlongjmp(SB) + RET + +// func Ylrand48(tls *TLS) (r int64) +TEXT ·Ylrand48(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xlrand48(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ylremovexattr(tls *TLS, path uintptr, name uintptr) (r int32) +TEXT ·Ylremovexattr(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlremovexattr(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ylrint(tls *TLS, x float64) (r int64) +TEXT ·Ylrint(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlrint(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylrintf(tls *TLS, x float32) (r int64) +TEXT ·Ylrintf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlrintf(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylrintl(tls *TLS, x float64) (r int64) +TEXT ·Ylrintl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlrintl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylround(tls *TLS, x float64) (r int64) +TEXT ·Ylround(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlround(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylroundf(tls *TLS, x float32) (r int64) +TEXT ·Ylroundf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xlroundf(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylroundl(tls *TLS, x float64) (r int64) +TEXT ·Ylroundl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xlroundl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ylsearch(tls *TLS, key uintptr, base uintptr, nelp uintptr, width Tsize_t, __ccgo_fp_compar uintptr) (r uintptr) +TEXT ·Ylsearch(SB),$64-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_compar+40(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_lsearch_4(SB) // Create the closure for calling __ccgo_fp_compar + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ base+16(FP), AX + MOVQ AX, 16(SP) + MOVQ nelp+24(FP), AX + MOVQ AX, 24(SP) + MOVQ width+32(FP), AX + MOVQ AX, 32(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 40(SP) + CALL ·Xlsearch(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_lsearch_4(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Ylseek(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) +TEXT ·Ylseek(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ offset+16(FP), AX + MOVQ AX, 16(SP) + MOVL whence+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xlseek(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ylseek64(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) +TEXT ·Ylseek64(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ offset+16(FP), AX + MOVQ AX, 16(SP) + MOVL whence+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xlseek64(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ylsetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) +TEXT ·Ylsetxattr(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ value+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVL flags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xlsetxattr(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ylstat(tls *TLS, path uintptr, buf uintptr) (r int32) +TEXT ·Ylstat(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlstat(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ylstat64(tls *TLS, path uintptr, buf uintptr) (r int32) +TEXT ·Ylstat64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlstat64(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ylutimes(tls *TLS, filename uintptr, tv uintptr) (r int32) +TEXT ·Ylutimes(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVQ tv+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xlutimes(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymadvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) +TEXT ·Ymadvise(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL advice+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xmadvise(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymalloc(tls *TLS, n Tsize_t) (r uintptr) +TEXT ·Ymalloc(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xmalloc(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ymalloc_usable_size(tls *TLS, p uintptr) (r Tsize_t) +TEXT ·Ymalloc_usable_size(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xmalloc_usable_size(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ymblen(tls *TLS, s uintptr, n Tsize_t) (r int32) +TEXT ·Ymblen(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xmblen(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymbrlen(tls *TLS, s uintptr, n Tsize_t, st uintptr) (r Tsize_t) +TEXT ·Ymbrlen(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ st+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmbrlen(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ymbrtoc16(tls *TLS, pc16 uintptr, s uintptr, n Tsize_t, ps uintptr) (r Tsize_t) +TEXT ·Ymbrtoc16(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ pc16+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ ps+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xmbrtoc16(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ymbrtoc32(tls *TLS, pc32 uintptr, s uintptr, n Tsize_t, ps uintptr) (r Tsize_t) +TEXT ·Ymbrtoc32(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ pc32+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ ps+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xmbrtoc32(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ymbrtowc(tls *TLS, wc uintptr, src uintptr, n Tsize_t, st uintptr) (r Tsize_t) +TEXT ·Ymbrtowc(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ wc+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ st+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xmbrtowc(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ymbsinit(tls *TLS, st uintptr) (r int32) +TEXT ·Ymbsinit(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ st+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xmbsinit(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ymbsnrtowcs(tls *TLS, wcs uintptr, src uintptr, n Tsize_t, wn Tsize_t, st uintptr) (r Tsize_t) +TEXT ·Ymbsnrtowcs(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ wcs+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ wn+32(FP), AX + MOVQ AX, 32(SP) + MOVQ st+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xmbsnrtowcs(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ymbsrtowcs(tls *TLS, ws uintptr, src uintptr, wn Tsize_t, st uintptr) (r Tsize_t) +TEXT ·Ymbsrtowcs(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ws+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ wn+24(FP), AX + MOVQ AX, 24(SP) + MOVQ st+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xmbsrtowcs(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ymbstowcs(tls *TLS, ws uintptr, _s uintptr, wn Tsize_t) (r Tsize_t) +TEXT ·Ymbstowcs(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ws+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ wn+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmbstowcs(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ymbtowc(tls *TLS, wc uintptr, src uintptr, n Tsize_t) (r int32) +TEXT ·Ymbtowc(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ wc+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmbtowc(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymemccpy(tls *TLS, dest uintptr, src uintptr, c int32, n Tsize_t) (r uintptr) +TEXT ·Ymemccpy(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVL c+24(FP), AX + MOVL AX, 24(SP) + MOVQ n+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xmemccpy(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ymemchr(tls *TLS, src uintptr, c int32, n Tsize_t) (r uintptr) +TEXT ·Ymemchr(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ src+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmemchr(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ymemcmp(tls *TLS, vl uintptr, vr uintptr, n Tsize_t) (r1 int32) +TEXT ·Ymemcmp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ vl+8(FP), AX + MOVQ AX, 8(SP) + MOVQ vr+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmemcmp(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ymemcpy(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) +TEXT ·Ymemcpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmemcpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ymemfd_create(tls *TLS, name uintptr, flags uint32) (r int32) +TEXT ·Ymemfd_create(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xmemfd_create(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymemmem(tls *TLS, h0 uintptr, k Tsize_t, n0 uintptr, l Tsize_t) (r uintptr) +TEXT ·Ymemmem(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ h0+8(FP), AX + MOVQ AX, 8(SP) + MOVQ k+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n0+24(FP), AX + MOVQ AX, 24(SP) + MOVQ l+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xmemmem(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ymemmove(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) +TEXT ·Ymemmove(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmemmove(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ymempcpy(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) +TEXT ·Ymempcpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmempcpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ymemrchr(tls *TLS, m uintptr, c int32, n Tsize_t) (r uintptr) +TEXT ·Ymemrchr(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmemrchr(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ymemset(tls *TLS, dest uintptr, c int32, n Tsize_t) (r uintptr) +TEXT ·Ymemset(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmemset(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ymincore(tls *TLS, addr uintptr, len1 Tsize_t, vec uintptr) (r int32) +TEXT ·Ymincore(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ vec+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmincore(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymkdir(tls *TLS, path uintptr, mode Tmode_t) (r int32) +TEXT ·Ymkdir(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL mode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xmkdir(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymkdirat(tls *TLS, fd int32, path uintptr, mode Tmode_t) (r int32) +TEXT ·Ymkdirat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL mode+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xmkdirat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymkdtemp(tls *TLS, template uintptr) (r uintptr) +TEXT ·Ymkdtemp(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xmkdtemp(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ymkfifo(tls *TLS, path uintptr, mode Tmode_t) (r int32) +TEXT ·Ymkfifo(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL mode+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xmkfifo(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymkfifoat(tls *TLS, fd int32, path uintptr, mode Tmode_t) (r int32) +TEXT ·Ymkfifoat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL mode+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xmkfifoat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymknod(tls *TLS, path uintptr, mode Tmode_t, dev Tdev_t) (r int32) +TEXT ·Ymknod(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL mode+16(FP), AX + MOVL AX, 16(SP) + MOVQ dev+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xmknod(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymknodat(tls *TLS, fd int32, path uintptr, mode Tmode_t, dev Tdev_t) (r int32) +TEXT ·Ymknodat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL mode+24(FP), AX + MOVL AX, 24(SP) + MOVQ dev+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xmknodat(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ymkostemp(tls *TLS, template uintptr, flags int32) (r int32) +TEXT ·Ymkostemp(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xmkostemp(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymkostemps(tls *TLS, template uintptr, len1 int32, flags int32) (r int32) +TEXT ·Ymkostemps(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + MOVL len1+16(FP), AX + MOVL AX, 16(SP) + MOVL flags+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xmkostemps(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymkstemp(tls *TLS, template uintptr) (r int32) +TEXT ·Ymkstemp(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xmkstemp(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ymkstemp64(tls *TLS, template uintptr) (r int32) +TEXT ·Ymkstemp64(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xmkstemp64(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ymkstemps(tls *TLS, template uintptr, len1 int32) (r int32) +TEXT ·Ymkstemps(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + MOVL len1+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xmkstemps(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymkstemps64(tls *TLS, template uintptr, len1 int32) (r int32) +TEXT ·Ymkstemps64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + MOVL len1+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xmkstemps64(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymktemp(tls *TLS, template uintptr) (r uintptr) +TEXT ·Ymktemp(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ template+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xmktemp(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ymktime(tls *TLS, tm uintptr) (r Ttime_t) +TEXT ·Ymktime(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tm+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xmktime(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ymlock(tls *TLS, addr uintptr, len1 Tsize_t) (r int32) +TEXT ·Ymlock(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xmlock(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymlock2(tls *TLS, addr uintptr, len1 Tsize_t, flags uint32) (r int32) +TEXT ·Ymlock2(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xmlock2(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymlockall(tls *TLS, flags int32) (r int32) +TEXT ·Ymlockall(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL flags+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xmlockall(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ymmap(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) +TEXT ·Ymmap(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ start+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL prot+24(FP), AX + MOVL AX, 24(SP) + MOVL flags+28(FP), AX + MOVL AX, 28(SP) + MOVL fd+32(FP), AX + MOVL AX, 32(SP) + MOVQ off+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xmmap(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ymmap64(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) +TEXT ·Ymmap64(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ start+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL prot+24(FP), AX + MOVL AX, 24(SP) + MOVL flags+28(FP), AX + MOVL AX, 28(SP) + MOVL fd+32(FP), AX + MOVL AX, 32(SP) + MOVQ off+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xmmap64(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ymodf(tls *TLS, x float64, iptr uintptr) (r float64) +TEXT ·Ymodf(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ iptr+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xmodf(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ymodff(tls *TLS, x float32, iptr uintptr) (r float32) +TEXT ·Ymodff(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVQ iptr+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xmodff(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymodfl(tls *TLS, x float64, iptr uintptr) (r1 float64) +TEXT ·Ymodfl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ iptr+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xmodfl(SB) + MOVQ 24(SP), AX + MOVQ AX, r1+24(FP) + RET + +// func Ymount(tls *TLS, special uintptr, dir uintptr, fstype uintptr, flags uint64, data uintptr) (r int32) +TEXT ·Ymount(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ special+8(FP), AX + MOVQ AX, 8(SP) + MOVQ dir+16(FP), AX + MOVQ AX, 16(SP) + MOVQ fstype+24(FP), AX + MOVQ AX, 24(SP) + MOVQ flags+32(FP), AX + MOVQ AX, 32(SP) + MOVQ data+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xmount(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ymprotect(tls *TLS, addr uintptr, len1 Tsize_t, prot int32) (r int32) +TEXT ·Ymprotect(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL prot+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xmprotect(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymrand48(tls *TLS) (r int64) +TEXT ·Ymrand48(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xmrand48(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ymremap(tls *TLS, old_addr uintptr, old_len Tsize_t, new_len Tsize_t, flags int32, va uintptr) (r uintptr) +TEXT ·Ymremap(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ old_addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ old_len+16(FP), AX + MOVQ AX, 16(SP) + MOVQ new_len+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + MOVQ va+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xmremap(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ymsgctl(tls *TLS, q int32, cmd int32, buf uintptr) (r1 int32) +TEXT ·Ymsgctl(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL q+8(FP), AX + MOVL AX, 8(SP) + MOVL cmd+12(FP), AX + MOVL AX, 12(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xmsgctl(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ymsgget(tls *TLS, k Tkey_t, flag int32) (r int32) +TEXT ·Ymsgget(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL k+8(FP), AX + MOVL AX, 8(SP) + MOVL flag+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xmsgget(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ymsgrcv(tls *TLS, q int32, m uintptr, len1 Tsize_t, type1 int64, flag int32) (r Tssize_t) +TEXT ·Ymsgrcv(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL q+8(FP), AX + MOVL AX, 8(SP) + MOVQ m+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVQ type1+32(FP), AX + MOVQ AX, 32(SP) + MOVL flag+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xmsgrcv(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ymsgsnd(tls *TLS, q int32, m uintptr, len1 Tsize_t, flag int32) (r int32) +TEXT ·Ymsgsnd(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL q+8(FP), AX + MOVL AX, 8(SP) + MOVQ m+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVL flag+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xmsgsnd(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ymsync(tls *TLS, start uintptr, len1 Tsize_t, flags int32) (r int32) +TEXT ·Ymsync(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ start+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xmsync(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ymunlock(tls *TLS, addr uintptr, len1 Tsize_t) (r int32) +TEXT ·Ymunlock(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xmunlock(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ymunlockall(tls *TLS) (r int32) +TEXT ·Ymunlockall(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xmunlockall(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ymunmap(tls *TLS, start uintptr, len1 Tsize_t) (r int32) +TEXT ·Ymunmap(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ start+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xmunmap(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yname_to_handle_at(tls *TLS, dirfd int32, pathname uintptr, handle uintptr, mount_id uintptr, flags int32) (r int32) +TEXT ·Yname_to_handle_at(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL dirfd+8(FP), AX + MOVL AX, 8(SP) + MOVQ pathname+16(FP), AX + MOVQ AX, 16(SP) + MOVQ handle+24(FP), AX + MOVQ AX, 24(SP) + MOVQ mount_id+32(FP), AX + MOVQ AX, 32(SP) + MOVL flags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xname_to_handle_at(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ynan(tls *TLS, s uintptr) (r float64) +TEXT ·Ynan(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xnan(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ynanf(tls *TLS, s uintptr) (r float32) +TEXT ·Ynanf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xnanf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ynanl(tls *TLS, s uintptr) (r float64) +TEXT ·Ynanl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xnanl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ynanosleep(tls *TLS, req uintptr, rem uintptr) (r int32) +TEXT ·Ynanosleep(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ req+8(FP), AX + MOVQ AX, 8(SP) + MOVQ rem+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xnanosleep(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ynewlocale(tls *TLS, mask int32, name uintptr, loc Tlocale_t) (r Tlocale_t) +TEXT ·Ynewlocale(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL mask+8(FP), AX + MOVL AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ loc+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xnewlocale(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ynextafter(tls *TLS, x3 float64, y3 float64) (r float64) +TEXT ·Ynextafter(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y3+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xnextafter(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ynextafterf(tls *TLS, x3 float32, y3 float32) (r float32) +TEXT ·Ynextafterf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + MOVL y3+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xnextafterf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ynextafterl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Ynextafterl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xnextafterl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ynexttoward(tls *TLS, x float64, y float64) (r float64) +TEXT ·Ynexttoward(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xnexttoward(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ynexttowardf(tls *TLS, x3 float32, y3 float64) (r float32) +TEXT ·Ynexttowardf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + MOVQ y3+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xnexttowardf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ynexttowardl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Ynexttowardl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xnexttowardl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ynftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32, flags int32) (r1 int32) +TEXT ·Ynftw(SB),$48-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_fn+16(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_nftw_1(SB) // Create the closure for calling __ccgo_fp_fn + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 16(SP) + MOVL fd_limit+24(FP), AX + MOVL AX, 24(SP) + MOVL flags+28(FP), AX + MOVL AX, 28(SP) + CALL ·Xnftw(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_nftw_1(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVL _3+24(FP), AX + MOVL AX, 24(SP) + MOVQ _4+32(FP), AX + MOVQ AX, 32(SP) + MOVQ __ccgo_fp+40(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 40(SP), AX + MOVL AX, _5+48(FP) + RET + +// func Yngettext(tls *TLS, msgid1 uintptr, msgid2 uintptr, n uint64) (r uintptr) +TEXT ·Yngettext(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msgid1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ msgid2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xngettext(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ynice(tls *TLS, inc int32) (r int32) +TEXT ·Ynice(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL inc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xnice(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ynl_langinfo(tls *TLS, item Tnl_item) (r uintptr) +TEXT ·Ynl_langinfo(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL item+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xnl_langinfo(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ynl_langinfo_l(tls *TLS, item Tnl_item, loc Tlocale_t) (r uintptr) +TEXT ·Ynl_langinfo_l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL item+8(FP), AX + MOVL AX, 8(SP) + MOVQ loc+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xnl_langinfo_l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ynrand48(tls *TLS, s uintptr) (r int64) +TEXT ·Ynrand48(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xnrand48(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yns_get16(tls *TLS, cp uintptr) (r uint32) +TEXT ·Yns_get16(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ cp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xns_get16(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yns_get32(tls *TLS, cp uintptr) (r uint64) +TEXT ·Yns_get32(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ cp+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xns_get32(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yns_initparse(tls *TLS, msg uintptr, msglen int32, handle uintptr) (r1 int32) +TEXT ·Yns_initparse(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msg+8(FP), AX + MOVQ AX, 8(SP) + MOVL msglen+16(FP), AX + MOVL AX, 16(SP) + MOVQ handle+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xns_initparse(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Yns_name_uncompress(tls *TLS, msg uintptr, eom uintptr, src uintptr, dst uintptr, dstsiz Tsize_t) (r1 int32) +TEXT ·Yns_name_uncompress(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msg+8(FP), AX + MOVQ AX, 8(SP) + MOVQ eom+16(FP), AX + MOVQ AX, 16(SP) + MOVQ src+24(FP), AX + MOVQ AX, 24(SP) + MOVQ dst+32(FP), AX + MOVQ AX, 32(SP) + MOVQ dstsiz+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xns_name_uncompress(SB) + MOVL 48(SP), AX + MOVL AX, r1+48(FP) + RET + +// func Yns_parserr(tls *TLS, handle uintptr, section Tns_sect, rrnum int32, rr uintptr) (r1 int32) +TEXT ·Yns_parserr(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ handle+8(FP), AX + MOVQ AX, 8(SP) + MOVL section+16(FP), AX + MOVL AX, 16(SP) + MOVL rrnum+20(FP), AX + MOVL AX, 20(SP) + MOVQ rr+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xns_parserr(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Yns_put16(tls *TLS, s uint32, cp uintptr) +TEXT ·Yns_put16(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL s+8(FP), AX + MOVL AX, 8(SP) + MOVQ cp+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xns_put16(SB) + RET + +// func Yns_put32(tls *TLS, l uint64, cp uintptr) +TEXT ·Yns_put32(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ cp+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xns_put32(SB) + RET + +// func Yns_skiprr(tls *TLS, ptr uintptr, eom uintptr, section Tns_sect, count int32) (r1 int32) +TEXT ·Yns_skiprr(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ eom+16(FP), AX + MOVQ AX, 16(SP) + MOVL section+24(FP), AX + MOVL AX, 24(SP) + MOVL count+28(FP), AX + MOVL AX, 28(SP) + CALL ·Xns_skiprr(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Yntohl(tls *TLS, n Tuint32_t) (r Tuint32_t) +TEXT ·Yntohl(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xntohl(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yntohs(tls *TLS, n Tuint16_t) (r Tuint16_t) +TEXT ·Yntohs(SB),$24-18 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVW n+8(FP), AX + MOVW AX, 8(SP) + CALL ·Xntohs(SB) + MOVW 16(SP), AX + MOVW AX, r+16(FP) + RET + +// func Yobstack_free(t *TLS, obstack, obj uintptr) +TEXT ·Yobstack_free(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ obstack+8(FP), AX + MOVQ AX, 8(SP) + MOVQ obj+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xobstack_free(SB) + RET + +// func Yobstack_vprintf(t *TLS, obstack, template, va uintptr) (_2 int32) +TEXT ·Yobstack_vprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ obstack+8(FP), AX + MOVQ AX, 8(SP) + MOVQ template+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xobstack_vprintf(SB) + MOVL 32(SP), AX + MOVL AX, _2+32(FP) + RET + +// func Yopen(tls *TLS, filename uintptr, flags int32, va uintptr) (r int32) +TEXT ·Yopen(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xopen(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yopen64(tls *TLS, filename uintptr, flags int32, va uintptr) (r int32) +TEXT ·Yopen64(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xopen64(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yopen_by_handle_at(tls *TLS, mount_fd int32, handle uintptr, flags int32) (r int32) +TEXT ·Yopen_by_handle_at(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL mount_fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ handle+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xopen_by_handle_at(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yopen_memstream(tls *TLS, bufp uintptr, sizep uintptr) (r uintptr) +TEXT ·Yopen_memstream(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ bufp+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sizep+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xopen_memstream(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yopen_wmemstream(tls *TLS, bufp uintptr, sizep uintptr) (r uintptr) +TEXT ·Yopen_wmemstream(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ bufp+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sizep+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xopen_wmemstream(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yopenat(tls *TLS, fd int32, filename uintptr, flags int32, va uintptr) (r int32) +TEXT ·Yopenat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ filename+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + MOVQ va+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xopenat(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yopendir(tls *TLS, name uintptr) (r uintptr) +TEXT ·Yopendir(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xopendir(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yopenlog(tls *TLS, ident uintptr, opt int32, facility int32) +TEXT ·Yopenlog(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ident+8(FP), AX + MOVQ AX, 8(SP) + MOVL opt+16(FP), AX + MOVL AX, 16(SP) + MOVL facility+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xopenlog(SB) + RET + +// func Yopenpty(tls *TLS, pm uintptr, ps uintptr, name uintptr, tio uintptr, ws uintptr) (r int32) +TEXT ·Yopenpty(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ pm+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ps+16(FP), AX + MOVQ AX, 16(SP) + MOVQ name+24(FP), AX + MOVQ AX, 24(SP) + MOVQ tio+32(FP), AX + MOVQ AX, 32(SP) + MOVQ ws+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xopenpty(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ypathconf(tls *TLS, path uintptr, name int32) (r int64) +TEXT ·Ypathconf(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL name+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xpathconf(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ypause(tls *TLS) (r int32) +TEXT ·Ypause(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xpause(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ypclose(tls *TLS, f uintptr) (r1 int32) +TEXT ·Ypclose(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpclose(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yperror(tls *TLS, msg uintptr) +TEXT ·Yperror(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ msg+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xperror(SB) + RET + +// func Ypersonality(tls *TLS, persona uint64) (r int32) +TEXT ·Ypersonality(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ persona+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpersonality(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ypipe(tls *TLS, fd uintptr) (r int32) +TEXT ·Ypipe(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fd+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpipe(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ypipe2(tls *TLS, fd uintptr, flag int32) (r int32) +TEXT ·Ypipe2(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fd+8(FP), AX + MOVQ AX, 8(SP) + MOVL flag+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xpipe2(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ypivot_root(tls *TLS, new1 uintptr, old uintptr) (r int32) +TEXT ·Ypivot_root(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ new1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ old+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpivot_root(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ypoll(tls *TLS, fds uintptr, n Tnfds_t, timeout int32) (r int32) +TEXT ·Ypoll(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fds+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVL timeout+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xpoll(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ypopen(t *TLS, command, type1 uintptr) (_2 uintptr) +TEXT ·Ypopen(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ command+8(FP), AX + MOVQ AX, 8(SP) + MOVQ type1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpopen(SB) + MOVQ 24(SP), AX + MOVQ AX, _2+24(FP) + RET + +// func Yposix_close(tls *TLS, fd int32, flags int32) (r int32) +TEXT ·Yposix_close(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL flags+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xposix_close(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yposix_fadvise(tls *TLS, fd int32, base Toff_t, len1 Toff_t, advice int32) (r int32) +TEXT ·Yposix_fadvise(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ base+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVL advice+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xposix_fadvise(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yposix_fallocate(tls *TLS, fd int32, base Toff_t, len1 Toff_t) (r int32) +TEXT ·Yposix_fallocate(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ base+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xposix_fallocate(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yposix_madvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) +TEXT ·Yposix_madvise(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL advice+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xposix_madvise(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yposix_openpt(tls *TLS, flags int32) (r1 int32) +TEXT ·Yposix_openpt(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL flags+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xposix_openpt(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yposix_spawn_file_actions_addchdir_np(tls *TLS, fa uintptr, path uintptr) (r int32) +TEXT ·Yposix_spawn_file_actions_addchdir_np(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fa+8(FP), AX + MOVQ AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawn_file_actions_addchdir_np(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawn_file_actions_addclose(tls *TLS, fa uintptr, fd int32) (r int32) +TEXT ·Yposix_spawn_file_actions_addclose(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fa+8(FP), AX + MOVQ AX, 8(SP) + MOVL fd+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xposix_spawn_file_actions_addclose(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawn_file_actions_adddup2(tls *TLS, fa uintptr, srcfd int32, fd int32) (r int32) +TEXT ·Yposix_spawn_file_actions_adddup2(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fa+8(FP), AX + MOVQ AX, 8(SP) + MOVL srcfd+16(FP), AX + MOVL AX, 16(SP) + MOVL fd+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xposix_spawn_file_actions_adddup2(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawn_file_actions_addfchdir_np(tls *TLS, fa uintptr, fd int32) (r int32) +TEXT ·Yposix_spawn_file_actions_addfchdir_np(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fa+8(FP), AX + MOVQ AX, 8(SP) + MOVL fd+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xposix_spawn_file_actions_addfchdir_np(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawn_file_actions_addopen(tls *TLS, fa uintptr, fd int32, path uintptr, flags int32, mode Tmode_t) (r int32) +TEXT ·Yposix_spawn_file_actions_addopen(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fa+8(FP), AX + MOVQ AX, 8(SP) + MOVL fd+16(FP), AX + MOVL AX, 16(SP) + MOVQ path+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + MOVL mode+36(FP), AX + MOVL AX, 36(SP) + CALL ·Xposix_spawn_file_actions_addopen(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yposix_spawn_file_actions_destroy(tls *TLS, fa uintptr) (r int32) +TEXT ·Yposix_spawn_file_actions_destroy(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fa+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xposix_spawn_file_actions_destroy(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yposix_spawn_file_actions_init(tls *TLS, fa uintptr) (r int32) +TEXT ·Yposix_spawn_file_actions_init(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fa+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xposix_spawn_file_actions_init(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yposix_spawnattr_destroy(tls *TLS, attr uintptr) (r int32) +TEXT ·Yposix_spawnattr_destroy(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xposix_spawnattr_destroy(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yposix_spawnattr_getflags(tls *TLS, attr uintptr, flags uintptr) (r int32) +TEXT ·Yposix_spawnattr_getflags(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ flags+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_getflags(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_getpgroup(tls *TLS, attr uintptr, pgrp uintptr) (r int32) +TEXT ·Yposix_spawnattr_getpgroup(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ pgrp+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_getpgroup(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_getschedparam(tls *TLS, attr uintptr, schedparam uintptr) (r int32) +TEXT ·Yposix_spawnattr_getschedparam(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ schedparam+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_getschedparam(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_getschedpolicy(tls *TLS, attr uintptr, policy uintptr) (r int32) +TEXT ·Yposix_spawnattr_getschedpolicy(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ policy+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_getschedpolicy(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_getsigdefault(tls *TLS, attr uintptr, def uintptr) (r int32) +TEXT ·Yposix_spawnattr_getsigdefault(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ def+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_getsigdefault(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_getsigmask(tls *TLS, attr uintptr, mask uintptr) (r int32) +TEXT ·Yposix_spawnattr_getsigmask(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mask+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_getsigmask(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_init(tls *TLS, attr uintptr) (r int32) +TEXT ·Yposix_spawnattr_init(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xposix_spawnattr_init(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yposix_spawnattr_setflags(tls *TLS, attr uintptr, flags int16) (r int32) +TEXT ·Yposix_spawnattr_setflags(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVW flags+16(FP), AX + MOVW AX, 16(SP) + CALL ·Xposix_spawnattr_setflags(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_setpgroup(tls *TLS, attr uintptr, pgrp Tpid_t) (r int32) +TEXT ·Yposix_spawnattr_setpgroup(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVL pgrp+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xposix_spawnattr_setpgroup(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_setschedparam(tls *TLS, attr uintptr, schedparam uintptr) (r int32) +TEXT ·Yposix_spawnattr_setschedparam(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ schedparam+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_setschedparam(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_setschedpolicy(tls *TLS, attr uintptr, policy int32) (r int32) +TEXT ·Yposix_spawnattr_setschedpolicy(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVL policy+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xposix_spawnattr_setschedpolicy(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_setsigdefault(tls *TLS, attr uintptr, def uintptr) (r int32) +TEXT ·Yposix_spawnattr_setsigdefault(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ def+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_setsigdefault(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yposix_spawnattr_setsigmask(tls *TLS, attr uintptr, mask uintptr) (r int32) +TEXT ·Yposix_spawnattr_setsigmask(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ attr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mask+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xposix_spawnattr_setsigmask(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ypow(tls *TLS, x1 float64, y1 float64) (r float64) +TEXT ·Ypow(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpow(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ypow10(tls *TLS, x float64) (r float64) +TEXT ·Ypow10(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpow10(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ypow10f(tls *TLS, x float32) (r float32) +TEXT ·Ypow10f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xpow10f(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ypow10l(tls *TLS, x float64) (r float64) +TEXT ·Ypow10l(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpow10l(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ypowf(tls *TLS, x1 float32, y1 float32) (r float32) +TEXT ·Ypowf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x1+8(FP), AX + MOVL AX, 8(SP) + MOVL y1+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xpowf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ypowl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Ypowl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpowl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yppoll(tls *TLS, fds uintptr, n Tnfds_t, to uintptr, mask uintptr) (r int32) +TEXT ·Yppoll(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fds+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ to+24(FP), AX + MOVQ AX, 24(SP) + MOVQ mask+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xppoll(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yprctl(tls *TLS, op int32, va uintptr) (r int32) +TEXT ·Yprctl(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL op+8(FP), AX + MOVL AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xprctl(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ypread(tls *TLS, fd int32, buf uintptr, size Tsize_t, ofs Toff_t) (r Tssize_t) +TEXT ·Ypread(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ size+24(FP), AX + MOVQ AX, 24(SP) + MOVQ ofs+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xpread(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ypreadv(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t) (r Tssize_t) +TEXT ·Ypreadv(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ iov+16(FP), AX + MOVQ AX, 16(SP) + MOVL count+24(FP), AX + MOVL AX, 24(SP) + MOVQ ofs+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xpreadv(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ypreadv2(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t, flags int32) (r Tssize_t) +TEXT ·Ypreadv2(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ iov+16(FP), AX + MOVQ AX, 16(SP) + MOVL count+24(FP), AX + MOVL AX, 24(SP) + MOVQ ofs+32(FP), AX + MOVQ AX, 32(SP) + MOVL flags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xpreadv2(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Yprintf(tls *TLS, fmt uintptr, va uintptr) (r int32) +TEXT ·Yprintf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xprintf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yprlimit(tls *TLS, pid Tpid_t, resource int32, new_limit uintptr, old_limit uintptr) (r1 int32) +TEXT ·Yprlimit(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVL resource+12(FP), AX + MOVL AX, 12(SP) + MOVQ new_limit+16(FP), AX + MOVQ AX, 16(SP) + MOVQ old_limit+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xprlimit(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Yprocess_vm_readv(tls *TLS, pid Tpid_t, lvec uintptr, liovcnt uint64, rvec uintptr, riovcnt uint64, flags uint64) (r Tssize_t) +TEXT ·Yprocess_vm_readv(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVQ lvec+16(FP), AX + MOVQ AX, 16(SP) + MOVQ liovcnt+24(FP), AX + MOVQ AX, 24(SP) + MOVQ rvec+32(FP), AX + MOVQ AX, 32(SP) + MOVQ riovcnt+40(FP), AX + MOVQ AX, 40(SP) + MOVQ flags+48(FP), AX + MOVQ AX, 48(SP) + CALL ·Xprocess_vm_readv(SB) + MOVQ 56(SP), AX + MOVQ AX, r+56(FP) + RET + +// func Yprocess_vm_writev(tls *TLS, pid Tpid_t, lvec uintptr, liovcnt uint64, rvec uintptr, riovcnt uint64, flags uint64) (r Tssize_t) +TEXT ·Yprocess_vm_writev(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVQ lvec+16(FP), AX + MOVQ AX, 16(SP) + MOVQ liovcnt+24(FP), AX + MOVQ AX, 24(SP) + MOVQ rvec+32(FP), AX + MOVQ AX, 32(SP) + MOVQ riovcnt+40(FP), AX + MOVQ AX, 40(SP) + MOVQ flags+48(FP), AX + MOVQ AX, 48(SP) + CALL ·Xprocess_vm_writev(SB) + MOVQ 56(SP), AX + MOVQ AX, r+56(FP) + RET + +// func Ypselect(tls *TLS, n int32, rfds uintptr, wfds uintptr, efds uintptr, ts uintptr, mask uintptr) (r int32) +TEXT ·Ypselect(SB),$64-60 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + MOVQ rfds+16(FP), AX + MOVQ AX, 16(SP) + MOVQ wfds+24(FP), AX + MOVQ AX, 24(SP) + MOVQ efds+32(FP), AX + MOVQ AX, 32(SP) + MOVQ ts+40(FP), AX + MOVQ AX, 40(SP) + MOVQ mask+48(FP), AX + MOVQ AX, 48(SP) + CALL ·Xpselect(SB) + MOVL 56(SP), AX + MOVL AX, r+56(FP) + RET + +// func Ypsiginfo(tls *TLS, si uintptr, msg uintptr) +TEXT ·Ypsiginfo(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ si+8(FP), AX + MOVQ AX, 8(SP) + MOVQ msg+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpsiginfo(SB) + RET + +// func Ypsignal(tls *TLS, sig int32, msg uintptr) +TEXT ·Ypsignal(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sig+8(FP), AX + MOVL AX, 8(SP) + MOVQ msg+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpsignal(SB) + RET + +// func Ypthread_atfork(tls *TLS, prepare, parent, child uintptr) (_2 int32) +TEXT ·Ypthread_atfork(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ prepare+8(FP), AX + MOVQ AX, 8(SP) + MOVQ parent+16(FP), AX + MOVQ AX, 16(SP) + MOVQ child+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xpthread_atfork(SB) + MOVL 32(SP), AX + MOVL AX, _2+32(FP) + RET + +// func Ypthread_attr_destroy(tls *TLS, a uintptr) (_2 int32) +TEXT ·Ypthread_attr_destroy(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_attr_destroy(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) (_3 int32) +TEXT ·Ypthread_attr_getdetachstate(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ state+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_attr_getdetachstate(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Ypthread_attr_init(tls *TLS, a uintptr) (_2 int32) +TEXT ·Ypthread_attr_init(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_attr_init(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) (r int32) +TEXT ·Ypthread_attr_setdetachstate(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVL state+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xpthread_attr_setdetachstate(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ypthread_attr_setscope(tls *TLS, a uintptr, scope int32) (_3 int32) +TEXT ·Ypthread_attr_setscope(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVL scope+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xpthread_attr_setscope(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Ypthread_attr_setstacksize(tls *TLS, a uintptr, stacksite Tsize_t) (_3 int32) +TEXT ·Ypthread_attr_setstacksize(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ stacksite+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_attr_setstacksize(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Ypthread_cleanup_pop(tls *TLS, run int32) +TEXT ·Ypthread_cleanup_pop(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL run+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xpthread_cleanup_pop(SB) + RET + +// func Ypthread_cleanup_push(tls *TLS, f, x uintptr) +TEXT ·Ypthread_cleanup_push(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ x+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_cleanup_push(SB) + RET + +// func Ypthread_cond_broadcast(tls *TLS, c uintptr) (_2 int32) +TEXT ·Ypthread_cond_broadcast(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ c+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_cond_broadcast(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_cond_destroy(tls *TLS, c uintptr) (_2 int32) +TEXT ·Ypthread_cond_destroy(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ c+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_cond_destroy(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_cond_init(tls *TLS, c, a uintptr) (_2 int32) +TEXT ·Ypthread_cond_init(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ c+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_cond_init(SB) + MOVL 24(SP), AX + MOVL AX, _2+24(FP) + RET + +// func Ypthread_cond_signal(tls *TLS, c uintptr) (_2 int32) +TEXT ·Ypthread_cond_signal(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ c+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_cond_signal(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_cond_timedwait(tls *TLS, c, m, ts uintptr) (r int32) +TEXT ·Ypthread_cond_timedwait(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ c+8(FP), AX + MOVQ AX, 8(SP) + MOVQ m+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ts+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xpthread_cond_timedwait(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ypthread_cond_wait(tls *TLS, c, m uintptr) (_2 int32) +TEXT ·Ypthread_cond_wait(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ c+8(FP), AX + MOVQ AX, 8(SP) + MOVQ m+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_cond_wait(SB) + MOVL 24(SP), AX + MOVL AX, _2+24(FP) + RET + +// func Ypthread_create(tls *TLS, res, attrp, entry, arg uintptr) (_2 int32) +TEXT ·Ypthread_create(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ res+8(FP), AX + MOVQ AX, 8(SP) + MOVQ attrp+16(FP), AX + MOVQ AX, 16(SP) + MOVQ entry+24(FP), AX + MOVQ AX, 24(SP) + MOVQ arg+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xpthread_create(SB) + MOVL 40(SP), AX + MOVL AX, _2+40(FP) + RET + +// func Ypthread_detach(tls *TLS, t uintptr) (_2 int32) +TEXT ·Ypthread_detach(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_detach(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_equal(tls *TLS, t, u uintptr) (_2 int32) +TEXT ·Ypthread_equal(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ u+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_equal(SB) + MOVL 24(SP), AX + MOVL AX, _2+24(FP) + RET + +// func Ypthread_exit(tls *TLS, result uintptr) +TEXT ·Ypthread_exit(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ result+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_exit(SB) + RET + +// func Ypthread_getspecific(tls *TLS, k Tpthread_key_t) (_2 uintptr) +TEXT ·Ypthread_getspecific(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL k+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xpthread_getspecific(SB) + MOVQ 16(SP), AX + MOVQ AX, _2+16(FP) + RET + +// func Ypthread_join(tls *TLS, t Tpthread_t, res uintptr) (r int32) +TEXT ·Ypthread_join(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ res+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_join(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ypthread_key_create(tls *TLS, k uintptr, dtor uintptr) (_3 int32) +TEXT ·Ypthread_key_create(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ k+8(FP), AX + MOVQ AX, 8(SP) + MOVQ dtor+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_key_create(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Ypthread_key_delete(tls *TLS, k Tpthread_key_t) (_2 int32) +TEXT ·Ypthread_key_delete(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL k+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xpthread_key_delete(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_mutex_destroy(tls *TLS, m uintptr) (_2 int32) +TEXT ·Ypthread_mutex_destroy(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_mutex_destroy(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_mutex_init(tls *TLS, m, a uintptr) (_2 int32) +TEXT ·Ypthread_mutex_init(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + MOVQ a+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_mutex_init(SB) + MOVL 24(SP), AX + MOVL AX, _2+24(FP) + RET + +// func Ypthread_mutex_lock(tls *TLS, m uintptr) (_2 int32) +TEXT ·Ypthread_mutex_lock(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_mutex_lock(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_mutex_trylock(tls *TLS, m uintptr) (_2 int32) +TEXT ·Ypthread_mutex_trylock(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_mutex_trylock(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_mutex_unlock(tls *TLS, m uintptr) (_2 int32) +TEXT ·Ypthread_mutex_unlock(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ m+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_mutex_unlock(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_mutexattr_destroy(tls *TLS, a uintptr) (_2 int32) +TEXT ·Ypthread_mutexattr_destroy(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_mutexattr_destroy(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_mutexattr_init(tls *TLS, a uintptr) (_2 int32) +TEXT ·Ypthread_mutexattr_init(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpthread_mutexattr_init(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ypthread_mutexattr_settype(tls *TLS, a uintptr, typ int32) (_3 int32) +TEXT ·Ypthread_mutexattr_settype(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVL typ+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xpthread_mutexattr_settype(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Ypthread_self(tls *TLS) (_1 uintptr) +TEXT ·Ypthread_self(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xpthread_self(SB) + MOVQ 8(SP), AX + MOVQ AX, _1+8(FP) + RET + +// func Ypthread_setcancelstate(tls *TLS, new int32, old uintptr) (_3 int32) +TEXT ·Ypthread_setcancelstate(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL new+8(FP), AX + MOVL AX, 8(SP) + MOVQ old+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_setcancelstate(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Ypthread_setspecific(tls *TLS, k Tpthread_key_t, x uintptr) (_3 int32) +TEXT ·Ypthread_setspecific(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL k+8(FP), AX + MOVL AX, 8(SP) + MOVQ x+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xpthread_setspecific(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Ypthread_sigmask(tls *TLS, now int32, set, old uintptr) (_3 int32) +TEXT ·Ypthread_sigmask(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL now+8(FP), AX + MOVL AX, 8(SP) + MOVQ set+16(FP), AX + MOVQ AX, 16(SP) + MOVQ old+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xpthread_sigmask(SB) + MOVL 32(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Yptrace(tls *TLS, req int32, va uintptr) (r int64) +TEXT ·Yptrace(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL req+8(FP), AX + MOVL AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xptrace(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yptsname(tls *TLS, fd int32) (r uintptr) +TEXT ·Yptsname(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xptsname(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yptsname_r(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) +TEXT ·Yptsname_r(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xptsname_r(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yputc(tls *TLS, c1 int32, f1 uintptr) (r int32) +TEXT ·Yputc(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c1+8(FP), AX + MOVL AX, 8(SP) + MOVQ f1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xputc(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yputc_unlocked(tls *TLS, c int32, f uintptr) (r int32) +TEXT ·Yputc_unlocked(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xputc_unlocked(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yputchar(tls *TLS, c1 int32) (r int32) +TEXT ·Yputchar(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c1+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xputchar(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yputchar_unlocked(tls *TLS, c int32) (r int32) +TEXT ·Yputchar_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xputchar_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yputenv(tls *TLS, s uintptr) (r int32) +TEXT ·Yputenv(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xputenv(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yputgrent(tls *TLS, gr uintptr, f uintptr) (r1 int32) +TEXT ·Yputgrent(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ gr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xputgrent(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Yputpwent(tls *TLS, pw uintptr, f uintptr) (r int32) +TEXT ·Yputpwent(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ pw+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xputpwent(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yputs(tls *TLS, s uintptr) (r1 int32) +TEXT ·Yputs(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xputs(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yputspent(tls *TLS, sp uintptr, f uintptr) (r int32) +TEXT ·Yputspent(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ sp+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xputspent(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ypututline(tls *TLS, ut uintptr) (r uintptr) +TEXT ·Ypututline(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ut+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpututline(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ypututxline(tls *TLS, ut uintptr) (r uintptr) +TEXT ·Ypututxline(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ut+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xpututxline(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yputw(tls *TLS, _x int32, f uintptr) (r int32) +TEXT ·Yputw(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL _x+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xputw(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yputwc(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) +TEXT ·Yputwc(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xputwc(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) +TEXT ·Yputwc_unlocked(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xputwc_unlocked(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yputwchar(tls *TLS, c Twchar_t) (r Twint_t) +TEXT ·Yputwchar(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xputwchar(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yputwchar_unlocked(tls *TLS, c Twchar_t) (r Twint_t) +TEXT ·Yputwchar_unlocked(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xputwchar_unlocked(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ypwrite(tls *TLS, fd int32, buf uintptr, size Tsize_t, ofs Toff_t) (r Tssize_t) +TEXT ·Ypwrite(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ size+24(FP), AX + MOVQ AX, 24(SP) + MOVQ ofs+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xpwrite(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ypwritev(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t) (r Tssize_t) +TEXT ·Ypwritev(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ iov+16(FP), AX + MOVQ AX, 16(SP) + MOVL count+24(FP), AX + MOVL AX, 24(SP) + MOVQ ofs+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xpwritev(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ypwritev2(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t, flags int32) (r Tssize_t) +TEXT ·Ypwritev2(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ iov+16(FP), AX + MOVQ AX, 16(SP) + MOVL count+24(FP), AX + MOVL AX, 24(SP) + MOVQ ofs+32(FP), AX + MOVQ AX, 32(SP) + MOVL flags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xpwritev2(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Yqsort(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun) +TEXT ·Yqsort(SB),$48-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cmp+32(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_qsort_3(SB) // Create the closure for calling __ccgo_fp_cmp + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ base+8(FP), AX + MOVQ AX, 8(SP) + MOVQ nel+16(FP), AX + MOVQ AX, 16(SP) + MOVQ width+24(FP), AX + MOVQ AX, 24(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 32(SP) + CALL ·Xqsort(SB) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_qsort_3(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Yqsort_r(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr) +TEXT ·Yqsort_r(SB),$56-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cmp+32(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_qsort_r_3(SB) // Create the closure for calling __ccgo_fp_cmp + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ base+8(FP), AX + MOVQ AX, 8(SP) + MOVQ nel+16(FP), AX + MOVQ AX, 16(SP) + MOVQ width+24(FP), AX + MOVQ AX, 24(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 32(SP) + MOVQ arg+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xqsort_r(SB) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_qsort_r_3(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ _3+24(FP), AX + MOVQ AX, 24(SP) + MOVQ __ccgo_fp+32(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 32(SP), AX + MOVL AX, _4+40(FP) + RET + +// func Yquick_exit(tls *TLS, code int32) +TEXT ·Yquick_exit(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL code+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xquick_exit(SB) + RET + +// func Yquotactl(tls *TLS, cmd int32, special uintptr, id int32, addr uintptr) (r int32) +TEXT ·Yquotactl(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL cmd+8(FP), AX + MOVL AX, 8(SP) + MOVQ special+16(FP), AX + MOVQ AX, 16(SP) + MOVL id+24(FP), AX + MOVL AX, 24(SP) + MOVQ addr+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xquotactl(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yraise(tls *TLS, sig int32) (r int32) +TEXT ·Yraise(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sig+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xraise(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yrand(tls *TLS) (r int32) +TEXT ·Yrand(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xrand(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yrand_r(tls *TLS, seed uintptr) (r int32) +TEXT ·Yrand_r(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ seed+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xrand_r(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yrandom(tls *TLS) (r int64) +TEXT ·Yrandom(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xrandom(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Yrandom_r(t *TLS, buf, result uintptr) (_2 int32) +TEXT ·Yrandom_r(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + MOVQ result+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xrandom_r(SB) + MOVL 24(SP), AX + MOVL AX, _2+24(FP) + RET + +// func Yread(tls *TLS, fd int32, buf uintptr, count Tsize_t) (r Tssize_t) +TEXT ·Yread(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ count+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xread(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yreadahead(tls *TLS, fd int32, pos Toff_t, len1 Tsize_t) (r Tssize_t) +TEXT ·Yreadahead(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ pos+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xreadahead(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yreaddir(tls *TLS, dir uintptr) (r uintptr) +TEXT ·Yreaddir(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dir+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xreaddir(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yreaddir64(tls *TLS, dir uintptr) (r uintptr) +TEXT ·Yreaddir64(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dir+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xreaddir64(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yreaddir_r(tls *TLS, dir uintptr, buf uintptr, result uintptr) (r int32) +TEXT ·Yreaddir_r(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dir+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ result+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xreaddir_r(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yreadlink(tls *TLS, path uintptr, buf uintptr, bufsize Tsize_t) (r1 Tssize_t) +TEXT ·Yreadlink(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ bufsize+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xreadlink(SB) + MOVQ 32(SP), AX + MOVQ AX, r1+32(FP) + RET + +// func Yreadlinkat(tls *TLS, fd int32, path uintptr, buf uintptr, bufsize Tsize_t) (r1 Tssize_t) +TEXT ·Yreadlinkat(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ bufsize+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xreadlinkat(SB) + MOVQ 40(SP), AX + MOVQ AX, r1+40(FP) + RET + +// func Yreadv(tls *TLS, fd int32, iov uintptr, count int32) (r Tssize_t) +TEXT ·Yreadv(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ iov+16(FP), AX + MOVQ AX, 16(SP) + MOVL count+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xreadv(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yrealloc(tls *TLS, p uintptr, n Tsize_t) (r uintptr) +TEXT ·Yrealloc(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xrealloc(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yreallocarray(tls *TLS, ptr uintptr, m Tsize_t, n Tsize_t) (r uintptr) +TEXT ·Yreallocarray(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ptr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ m+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xreallocarray(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yrealpath(tls *TLS, filename uintptr, resolved uintptr) (r uintptr) +TEXT ·Yrealpath(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ filename+8(FP), AX + MOVQ AX, 8(SP) + MOVQ resolved+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xrealpath(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yreboot(tls *TLS, type1 int32) (r int32) +TEXT ·Yreboot(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL type1+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xreboot(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yrecv(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32) (r Tssize_t) +TEXT ·Yrecv(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xrecv(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yrecvfrom(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32, addr uintptr, alen uintptr) (r1 Tssize_t) +TEXT ·Yrecvfrom(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + MOVQ addr+40(FP), AX + MOVQ AX, 40(SP) + MOVQ alen+48(FP), AX + MOVQ AX, 48(SP) + CALL ·Xrecvfrom(SB) + MOVQ 56(SP), AX + MOVQ AX, r1+56(FP) + RET + +// func Yrecvmmsg(tls *TLS, fd int32, msgvec uintptr, vlen uint32, flags uint32, timeout uintptr) (r int32) +TEXT ·Yrecvmmsg(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ msgvec+16(FP), AX + MOVQ AX, 16(SP) + MOVL vlen+24(FP), AX + MOVL AX, 24(SP) + MOVL flags+28(FP), AX + MOVL AX, 28(SP) + MOVQ timeout+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xrecvmmsg(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yrecvmsg(tls *TLS, fd int32, msg uintptr, flags int32) (r2 Tssize_t) +TEXT ·Yrecvmsg(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ msg+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xrecvmsg(SB) + MOVQ 32(SP), AX + MOVQ AX, r2+32(FP) + RET + +// func Yregcomp(tls *TLS, preg uintptr, regex uintptr, cflags int32) (r int32) +TEXT ·Yregcomp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ preg+8(FP), AX + MOVQ AX, 8(SP) + MOVQ regex+16(FP), AX + MOVQ AX, 16(SP) + MOVL cflags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xregcomp(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yregerror(tls *TLS, e int32, preg uintptr, buf uintptr, size Tsize_t) (r Tsize_t) +TEXT ·Yregerror(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL e+8(FP), AX + MOVL AX, 8(SP) + MOVQ preg+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buf+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xregerror(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yregexec(tls *TLS, preg uintptr, string1 uintptr, nmatch Tsize_t, pmatch uintptr, eflags int32) (r int32) +TEXT ·Yregexec(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ preg+8(FP), AX + MOVQ AX, 8(SP) + MOVQ string1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ nmatch+24(FP), AX + MOVQ AX, 24(SP) + MOVQ pmatch+32(FP), AX + MOVQ AX, 32(SP) + MOVL eflags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xregexec(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Yregfree(tls *TLS, preg uintptr) +TEXT ·Yregfree(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ preg+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xregfree(SB) + RET + +// func Yremainder(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yremainder(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xremainder(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yremainderf(tls *TLS, x float32, y float32) (r float32) +TEXT ·Yremainderf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xremainderf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yremainderl(tls *TLS, x float64, y float64) (r float64) +TEXT ·Yremainderl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xremainderl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yremap_file_pages(tls *TLS, addr uintptr, size Tsize_t, prot int32, pgoff Tsize_t, flags int32) (r int32) +TEXT ·Yremap_file_pages(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVL prot+24(FP), AX + MOVL AX, 24(SP) + MOVQ pgoff+32(FP), AX + MOVQ AX, 32(SP) + MOVL flags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xremap_file_pages(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Yremove(tls *TLS, path uintptr) (r1 int32) +TEXT ·Yremove(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xremove(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Yremovexattr(tls *TLS, path uintptr, name uintptr) (r int32) +TEXT ·Yremovexattr(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xremovexattr(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yremque(tls *TLS, element uintptr) +TEXT ·Yremque(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ element+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xremque(SB) + RET + +// func Yremquo(tls *TLS, x float64, y float64, quo uintptr) (r float64) +TEXT ·Yremquo(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + MOVQ quo+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xremquo(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yremquof(tls *TLS, x float32, y float32, quo uintptr) (r float32) +TEXT ·Yremquof(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL y+12(FP), AX + MOVL AX, 12(SP) + MOVQ quo+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xremquof(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yremquol(tls *TLS, x float64, y float64, quo uintptr) (r float64) +TEXT ·Yremquol(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ y+16(FP), AX + MOVQ AX, 16(SP) + MOVQ quo+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xremquol(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yrename(tls *TLS, old uintptr, new1 uintptr) (r int32) +TEXT ·Yrename(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ old+8(FP), AX + MOVQ AX, 8(SP) + MOVQ new1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xrename(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yrenameat(tls *TLS, oldfd int32, old uintptr, newfd int32, new1 uintptr) (r int32) +TEXT ·Yrenameat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL oldfd+8(FP), AX + MOVL AX, 8(SP) + MOVQ old+16(FP), AX + MOVQ AX, 16(SP) + MOVL newfd+24(FP), AX + MOVL AX, 24(SP) + MOVQ new1+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xrenameat(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yrenameat2(t *TLS, olddirfd int32, oldpath uintptr, newdirfd int32, newpath uintptr, flags int32) (_6 int32) +TEXT ·Yrenameat2(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVL olddirfd+8(FP), AX + MOVL AX, 8(SP) + MOVQ oldpath+16(FP), AX + MOVQ AX, 16(SP) + MOVL newdirfd+24(FP), AX + MOVL AX, 24(SP) + MOVQ newpath+32(FP), AX + MOVQ AX, 32(SP) + MOVL flags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xrenameat2(SB) + MOVL 48(SP), AX + MOVL AX, _6+48(FP) + RET + +// func Yres_init(tls *TLS) (r int32) +TEXT ·Yres_init(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xres_init(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yres_mkquery(tls *TLS, op int32, dname uintptr, class int32, type1 int32, data uintptr, datalen int32, newrr uintptr, buf uintptr, buflen int32) (r int32) +TEXT ·Yres_mkquery(SB),$80-76 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL op+8(FP), AX + MOVL AX, 8(SP) + MOVQ dname+16(FP), AX + MOVQ AX, 16(SP) + MOVL class+24(FP), AX + MOVL AX, 24(SP) + MOVL type1+28(FP), AX + MOVL AX, 28(SP) + MOVQ data+32(FP), AX + MOVQ AX, 32(SP) + MOVL datalen+40(FP), AX + MOVL AX, 40(SP) + MOVQ newrr+48(FP), AX + MOVQ AX, 48(SP) + MOVQ buf+56(FP), AX + MOVQ AX, 56(SP) + MOVL buflen+64(FP), AX + MOVL AX, 64(SP) + CALL ·Xres_mkquery(SB) + MOVL 72(SP), AX + MOVL AX, r+72(FP) + RET + +// func Yres_send(tls *TLS, _msg uintptr, _msglen int32, _answer uintptr, _anslen int32) (r int32) +TEXT ·Yres_send(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _msg+8(FP), AX + MOVQ AX, 8(SP) + MOVL _msglen+16(FP), AX + MOVL AX, 16(SP) + MOVQ _answer+24(FP), AX + MOVQ AX, 24(SP) + MOVL _anslen+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xres_send(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yrewind(tls *TLS, f uintptr) +TEXT ·Yrewind(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xrewind(SB) + RET + +// func Yrewinddir(tls *TLS, dir uintptr) +TEXT ·Yrewinddir(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dir+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xrewinddir(SB) + RET + +// func Yrindex(tls *TLS, s uintptr, c int32) (r uintptr) +TEXT ·Yrindex(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xrindex(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yrint(tls *TLS, x float64) (r float64) +TEXT ·Yrint(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xrint(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yrintf(tls *TLS, x float32) (r float32) +TEXT ·Yrintf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xrintf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yrintl(tls *TLS, x float64) (r float64) +TEXT ·Yrintl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xrintl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yrmdir(tls *TLS, path uintptr) (r int32) +TEXT ·Yrmdir(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xrmdir(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yround(tls *TLS, x3 float64) (r float64) +TEXT ·Yround(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xround(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yroundf(tls *TLS, x3 float32) (r float32) +TEXT ·Yroundf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xroundf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yroundl(tls *TLS, x float64) (r float64) +TEXT ·Yroundl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xroundl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysbrk(tls *TLS, inc Tintptr_t) (r uintptr) +TEXT ·Ysbrk(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ inc+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsbrk(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yscalb(tls *TLS, x float64, fn float64) (r float64) +TEXT ·Yscalb(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fn+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xscalb(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yscalbf(tls *TLS, x float32, fn float32) (r float32) +TEXT ·Yscalbf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL fn+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xscalbf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yscalbln(tls *TLS, x float64, n int64) (r float64) +TEXT ·Yscalbln(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xscalbln(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yscalblnf(tls *TLS, x float32, n int64) (r float32) +TEXT ·Yscalblnf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xscalblnf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yscalblnl(tls *TLS, x float64, n int64) (r float64) +TEXT ·Yscalblnl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xscalblnl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yscalbn(tls *TLS, x float64, n int32) (r float64) +TEXT ·Yscalbn(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xscalbn(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yscalbnf(tls *TLS, x float32, n int32) (r float32) +TEXT ·Yscalbnf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + MOVL n+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xscalbnf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yscalbnl(tls *TLS, x float64, n int32) (r float64) +TEXT ·Yscalbnl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVL n+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xscalbnl(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yscandir(tls *TLS, path uintptr, res uintptr, __ccgo_fp_sel uintptr, __ccgo_fp_cmp uintptr) (r int32) +TEXT ·Yscandir(SB),$56-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $32, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_sel+24(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_scandir_2(SB) // Create the closure for calling __ccgo_fp_sel + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $16, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cmp+32(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_scandir_3(SB) // Create the closure for calling __ccgo_fp_cmp + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ res+16(FP), AX + MOVQ AX, 16(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 24(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $16, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 32(SP) + CALL ·Xscandir(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_scandir_2(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ __ccgo_fp+16(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 16(SP), AX + MOVL AX, _2+24(FP) + RET + +TEXT ·__ccgo_abi0_scandir_3(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Yscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) +TEXT ·Yscanf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xscanf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysched_yield(tls *TLS) (_1 int32) +TEXT ·Ysched_yield(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsched_yield(SB) + MOVL 8(SP), AX + MOVL AX, _1+8(FP) + RET + +// func Ysecure_getenv(tls *TLS, name uintptr) (r uintptr) +TEXT ·Ysecure_getenv(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsecure_getenv(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yseed48(tls *TLS, s uintptr) (r uintptr) +TEXT ·Yseed48(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xseed48(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yseekdir(tls *TLS, dir uintptr, off int64) +TEXT ·Yseekdir(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dir+8(FP), AX + MOVQ AX, 8(SP) + MOVQ off+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xseekdir(SB) + RET + +// func Yselect(tls *TLS, n int32, rfds uintptr, wfds uintptr, efds uintptr, tv uintptr) (r int32) +TEXT ·Yselect(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + MOVQ rfds+16(FP), AX + MOVQ AX, 16(SP) + MOVQ wfds+24(FP), AX + MOVQ AX, 24(SP) + MOVQ efds+32(FP), AX + MOVQ AX, 32(SP) + MOVQ tv+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xselect(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Ysemctl(tls *TLS, id int32, num int32, cmd int32, va uintptr) (r1 int32) +TEXT ·Ysemctl(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL id+8(FP), AX + MOVL AX, 8(SP) + MOVL num+12(FP), AX + MOVL AX, 12(SP) + MOVL cmd+16(FP), AX + MOVL AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsemctl(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ysemget(tls *TLS, key Tkey_t, n int32, fl int32) (r int32) +TEXT ·Ysemget(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL key+8(FP), AX + MOVL AX, 8(SP) + MOVL n+12(FP), AX + MOVL AX, 12(SP) + MOVL fl+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xsemget(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysemop(tls *TLS, id int32, buf uintptr, n Tsize_t) (r int32) +TEXT ·Ysemop(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL id+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsemop(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ysemtimedop(tls *TLS, id int32, buf uintptr, n Tsize_t, ts uintptr) (r int32) +TEXT ·Ysemtimedop(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL id+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ ts+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xsemtimedop(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ysend(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32) (r Tssize_t) +TEXT ·Ysend(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xsend(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ysendfile(tls *TLS, out_fd int32, in_fd int32, ofs uintptr, count Tsize_t) (r Tssize_t) +TEXT ·Ysendfile(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL out_fd+8(FP), AX + MOVL AX, 8(SP) + MOVL in_fd+12(FP), AX + MOVL AX, 12(SP) + MOVQ ofs+16(FP), AX + MOVQ AX, 16(SP) + MOVQ count+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsendfile(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ysendmmsg(tls *TLS, fd int32, msgvec uintptr, vlen uint32, flags uint32) (r1 int32) +TEXT ·Ysendmmsg(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ msgvec+16(FP), AX + MOVQ AX, 16(SP) + MOVL vlen+24(FP), AX + MOVL AX, 24(SP) + MOVL flags+28(FP), AX + MOVL AX, 28(SP) + CALL ·Xsendmmsg(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ysendmsg(tls *TLS, fd int32, msg uintptr, flags int32) (r1 Tssize_t) +TEXT ·Ysendmsg(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ msg+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xsendmsg(SB) + MOVQ 32(SP), AX + MOVQ AX, r1+32(FP) + RET + +// func Ysendto(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32, addr uintptr, alen Tsocklen_t) (r1 Tssize_t) +TEXT ·Ysendto(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + MOVQ addr+40(FP), AX + MOVQ AX, 40(SP) + MOVL alen+48(FP), AX + MOVL AX, 48(SP) + CALL ·Xsendto(SB) + MOVQ 56(SP), AX + MOVQ AX, r1+56(FP) + RET + +// func Ysetbuf(tls *TLS, f uintptr, buf uintptr) +TEXT ·Ysetbuf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsetbuf(SB) + RET + +// func Ysetbuffer(tls *TLS, f uintptr, buf uintptr, size Tsize_t) +TEXT ·Ysetbuffer(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ size+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsetbuffer(SB) + RET + +// func Ysetdomainname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) +TEXT ·Ysetdomainname(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsetdomainname(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) (r int32) +TEXT ·Ysetenv(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ var1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ value+16(FP), AX + MOVQ AX, 16(SP) + MOVL overwrite+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xsetenv(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ysetfsgid(tls *TLS, gid Tgid_t) (r int32) +TEXT ·Ysetfsgid(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL gid+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsetfsgid(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysetfsuid(tls *TLS, uid Tuid_t) (r int32) +TEXT ·Ysetfsuid(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL uid+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsetfsuid(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysetgid(tls *TLS, gid Tgid_t) (r int32) +TEXT ·Ysetgid(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL gid+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsetgid(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysetgrent(tls *TLS) +TEXT ·Ysetgrent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsetgrent(SB) + RET + +// func Ysethostent(tls *TLS, x int32) +TEXT ·Ysethostent(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsethostent(SB) + RET + +// func Ysethostname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) +TEXT ·Ysethostname(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsethostname(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysetitimer(tls *TLS, which int32, new1 uintptr, old uintptr) (r1 int32) +TEXT ·Ysetitimer(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL which+8(FP), AX + MOVL AX, 8(SP) + MOVQ new1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ old+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsetitimer(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ysetjmp(t *TLS, env uintptr) (_2 int32) +TEXT ·Ysetjmp(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ env+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsetjmp(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ysetkey(tls *TLS, key uintptr) +TEXT ·Ysetkey(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsetkey(SB) + RET + +// func Ysetlinebuf(tls *TLS, f uintptr) +TEXT ·Ysetlinebuf(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsetlinebuf(SB) + RET + +// func Ysetlocale(tls *TLS, cat int32, name uintptr) (r uintptr) +TEXT ·Ysetlocale(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL cat+8(FP), AX + MOVL AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsetlocale(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ysetlogmask(tls *TLS, maskpri int32) (r int32) +TEXT ·Ysetlogmask(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL maskpri+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsetlogmask(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysetmntent(tls *TLS, name uintptr, mode uintptr) (r uintptr) +TEXT ·Ysetmntent(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ mode+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsetmntent(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ysetnetent(tls *TLS, x int32) +TEXT ·Ysetnetent(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsetnetent(SB) + RET + +// func Ysetns(tls *TLS, fd int32, nstype int32) (r int32) +TEXT ·Ysetns(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL nstype+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xsetns(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysetpgid(tls *TLS, pid Tpid_t, pgid Tpid_t) (r int32) +TEXT ·Ysetpgid(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVL pgid+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xsetpgid(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysetpgrp(tls *TLS) (r Tpid_t) +TEXT ·Ysetpgrp(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsetpgrp(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ysetpriority(tls *TLS, which int32, who Tid_t, prio int32) (r int32) +TEXT ·Ysetpriority(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL which+8(FP), AX + MOVL AX, 8(SP) + MOVL who+12(FP), AX + MOVL AX, 12(SP) + MOVL prio+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xsetpriority(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysetprotoent(tls *TLS, stayopen int32) +TEXT ·Ysetprotoent(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL stayopen+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsetprotoent(SB) + RET + +// func Ysetpwent(tls *TLS) +TEXT ·Ysetpwent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsetpwent(SB) + RET + +// func Ysetrlimit(tls *TLS, resource int32, rlim uintptr) (r int32) +TEXT ·Ysetrlimit(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL resource+8(FP), AX + MOVL AX, 8(SP) + MOVQ rlim+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsetrlimit(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysetrlimit64(tls *TLS, resource int32, rlim uintptr) (r int32) +TEXT ·Ysetrlimit64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL resource+8(FP), AX + MOVL AX, 8(SP) + MOVQ rlim+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsetrlimit64(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysetservent(tls *TLS, stayopen int32) +TEXT ·Ysetservent(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL stayopen+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsetservent(SB) + RET + +// func Ysetsid(tls *TLS) (r Tpid_t) +TEXT ·Ysetsid(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsetsid(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Ysetsockopt(tls *TLS, fd int32, level int32, optname int32, optval uintptr, optlen Tsocklen_t) (r2 int32) +TEXT ·Ysetsockopt(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL level+12(FP), AX + MOVL AX, 12(SP) + MOVL optname+16(FP), AX + MOVL AX, 16(SP) + MOVQ optval+24(FP), AX + MOVQ AX, 24(SP) + MOVL optlen+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xsetsockopt(SB) + MOVL 40(SP), AX + MOVL AX, r2+40(FP) + RET + +// func Ysetspent(tls *TLS) +TEXT ·Ysetspent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsetspent(SB) + RET + +// func Ysetstate(tls *TLS, state uintptr) (r uintptr) +TEXT ·Ysetstate(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ state+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsetstate(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysettimeofday(tls *TLS, tv uintptr, tz uintptr) (r int32) +TEXT ·Ysettimeofday(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tv+8(FP), AX + MOVQ AX, 8(SP) + MOVQ tz+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsettimeofday(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysetuid(tls *TLS, uid Tuid_t) (r int32) +TEXT ·Ysetuid(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL uid+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsetuid(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysetusershell(tls *TLS) +TEXT ·Ysetusershell(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsetusershell(SB) + RET + +// func Ysetutent(tls *TLS) +TEXT ·Ysetutent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsetutent(SB) + RET + +// func Ysetutxent(tls *TLS) +TEXT ·Ysetutxent(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsetutxent(SB) + RET + +// func Ysetvbuf(tls *TLS, f uintptr, buf uintptr, type1 int32, size Tsize_t) (r int32) +TEXT ·Ysetvbuf(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVL type1+24(FP), AX + MOVL AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xsetvbuf(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ysetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) +TEXT ·Ysetxattr(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ value+24(FP), AX + MOVQ AX, 24(SP) + MOVQ size+32(FP), AX + MOVQ AX, 32(SP) + MOVL flags+40(FP), AX + MOVL AX, 40(SP) + CALL ·Xsetxattr(SB) + MOVL 48(SP), AX + MOVL AX, r+48(FP) + RET + +// func Yshm_open(tls *TLS, name uintptr, flag int32, mode Tmode_t) (r int32) +TEXT ·Yshm_open(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVL flag+16(FP), AX + MOVL AX, 16(SP) + MOVL mode+20(FP), AX + MOVL AX, 20(SP) + CALL ·Xshm_open(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yshm_unlink(tls *TLS, name uintptr) (r int32) +TEXT ·Yshm_unlink(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xshm_unlink(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yshmat(tls *TLS, id int32, addr uintptr, flag int32) (r uintptr) +TEXT ·Yshmat(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL id+8(FP), AX + MOVL AX, 8(SP) + MOVQ addr+16(FP), AX + MOVQ AX, 16(SP) + MOVL flag+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xshmat(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Yshmctl(tls *TLS, id int32, cmd int32, buf uintptr) (r1 int32) +TEXT ·Yshmctl(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL id+8(FP), AX + MOVL AX, 8(SP) + MOVL cmd+12(FP), AX + MOVL AX, 12(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xshmctl(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Yshmdt(tls *TLS, addr uintptr) (r int32) +TEXT ·Yshmdt(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ addr+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xshmdt(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yshmget(tls *TLS, key Tkey_t, size Tsize_t, flag int32) (r int32) +TEXT ·Yshmget(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL key+8(FP), AX + MOVL AX, 8(SP) + MOVQ size+16(FP), AX + MOVQ AX, 16(SP) + MOVL flag+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xshmget(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yshutdown(tls *TLS, fd int32, how int32) (r1 int32) +TEXT ·Yshutdown(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL how+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xshutdown(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Ysigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r int32) +TEXT ·Ysigaction(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL sig+8(FP), AX + MOVL AX, 8(SP) + MOVQ sa+16(FP), AX + MOVQ AX, 16(SP) + MOVQ old+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsigaction(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ysigaddset(tls *TLS, set uintptr, sig int32) (r int32) +TEXT ·Ysigaddset(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + MOVL sig+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xsigaddset(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysigaltstack(tls *TLS, ss uintptr, old uintptr) (r int32) +TEXT ·Ysigaltstack(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ss+8(FP), AX + MOVQ AX, 8(SP) + MOVQ old+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsigaltstack(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysigandset(tls *TLS, dest uintptr, left uintptr, right uintptr) (r1 int32) +TEXT ·Ysigandset(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ left+16(FP), AX + MOVQ AX, 16(SP) + MOVQ right+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsigandset(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ysigdelset(tls *TLS, set uintptr, sig int32) (r int32) +TEXT ·Ysigdelset(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + MOVL sig+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xsigdelset(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysigemptyset(tls *TLS, set uintptr) (r int32) +TEXT ·Ysigemptyset(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsigemptyset(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysigfillset(tls *TLS, set uintptr) (r int32) +TEXT ·Ysigfillset(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsigfillset(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysigisemptyset(tls *TLS, set uintptr) (r int32) +TEXT ·Ysigisemptyset(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsigisemptyset(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysigismember(tls *TLS, set uintptr, sig int32) (r int32) +TEXT ·Ysigismember(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + MOVL sig+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xsigismember(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysignal(tls *TLS, signum int32, handler uintptr) (r uintptr) +TEXT ·Ysignal(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL signum+8(FP), AX + MOVL AX, 8(SP) + MOVQ handler+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsignal(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ysignalfd(tls *TLS, fd int32, sigs uintptr, flags int32) (r int32) +TEXT ·Ysignalfd(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ sigs+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xsignalfd(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ysignificand(tls *TLS, x float64) (r float64) +TEXT ·Ysignificand(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsignificand(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysignificandf(tls *TLS, x float32) (r float32) +TEXT ·Ysignificandf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsignificandf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysigorset(tls *TLS, dest uintptr, left uintptr, right uintptr) (r1 int32) +TEXT ·Ysigorset(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ left+16(FP), AX + MOVQ AX, 16(SP) + MOVQ right+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsigorset(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ysigpending(tls *TLS, set uintptr) (r int32) +TEXT ·Ysigpending(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ set+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsigpending(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysigprocmask(tls *TLS, how int32, set uintptr, old uintptr) (r1 int32) +TEXT ·Ysigprocmask(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL how+8(FP), AX + MOVL AX, 8(SP) + MOVQ set+16(FP), AX + MOVQ AX, 16(SP) + MOVQ old+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsigprocmask(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ysigqueue(tls *TLS, pid Tpid_t, sig int32, value Tsigval) (r1 int32) +TEXT ·Ysigqueue(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVL sig+12(FP), AX + MOVL AX, 12(SP) + MOVL value_Fsival_int+16(FP), AX + MOVL AX, 16(SP) + MOVB value_F__ccgo_pad2_0+20(FP), AX + MOVB AX, 20(SP) + MOVB value_F__ccgo_pad2_1+21(FP), AX + MOVB AX, 21(SP) + MOVB value_F__ccgo_pad2_2+22(FP), AX + MOVB AX, 22(SP) + MOVB value_F__ccgo_pad2_3+23(FP), AX + MOVB AX, 23(SP) + CALL ·Xsigqueue(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ysigsuspend(tls *TLS, mask uintptr) (r int32) +TEXT ·Ysigsuspend(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ mask+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsigsuspend(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysigtimedwait(tls *TLS, mask uintptr, si uintptr, timeout uintptr) (r int32) +TEXT ·Ysigtimedwait(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ mask+8(FP), AX + MOVQ AX, 8(SP) + MOVQ si+16(FP), AX + MOVQ AX, 16(SP) + MOVQ timeout+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsigtimedwait(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ysigwait(tls *TLS, mask uintptr, sig uintptr) (r int32) +TEXT ·Ysigwait(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ mask+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sig+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsigwait(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysigwaitinfo(tls *TLS, mask uintptr, si uintptr) (r int32) +TEXT ·Ysigwaitinfo(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ mask+8(FP), AX + MOVQ AX, 8(SP) + MOVQ si+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsigwaitinfo(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysin(tls *TLS, x3 float64) (r float64) +TEXT ·Ysin(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsin(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysincos(tls *TLS, x3 float64, sin uintptr, cos uintptr) +TEXT ·Ysincos(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sin+16(FP), AX + MOVQ AX, 16(SP) + MOVQ cos+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsincos(SB) + RET + +// func Ysincosf(tls *TLS, x3 float32, sin uintptr, cos uintptr) +TEXT ·Ysincosf(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + MOVQ sin+16(FP), AX + MOVQ AX, 16(SP) + MOVQ cos+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsincosf(SB) + RET + +// func Ysincosl(tls *TLS, x float64, sin uintptr, cos uintptr) +TEXT ·Ysincosl(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sin+16(FP), AX + MOVQ AX, 16(SP) + MOVQ cos+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsincosl(SB) + RET + +// func Ysinf(tls *TLS, x3 float32) (r float32) +TEXT ·Ysinf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsinf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysinh(tls *TLS, x float64) (r float64) +TEXT ·Ysinh(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsinh(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysinhf(tls *TLS, x float32) (r float32) +TEXT ·Ysinhf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsinhf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysinhl(tls *TLS, x float64) (r float64) +TEXT ·Ysinhl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsinhl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysinl(tls *TLS, x float64) (r float64) +TEXT ·Ysinl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsinl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysleep(tls *TLS, seconds uint32) (r uint32) +TEXT ·Ysleep(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL seconds+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsleep(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysnprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r int32) +TEXT ·Ysnprintf(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ fmt+24(FP), AX + MOVQ AX, 24(SP) + MOVQ va+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xsnprintf(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ysockatmark(tls *TLS, s int32) (r int32) +TEXT ·Ysockatmark(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL s+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsockatmark(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysocket(tls *TLS, domain int32, type1 int32, protocol int32) (r1 int32) +TEXT ·Ysocket(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL domain+8(FP), AX + MOVL AX, 8(SP) + MOVL type1+12(FP), AX + MOVL AX, 12(SP) + MOVL protocol+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xsocket(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ysocketpair(tls *TLS, domain int32, type1 int32, protocol int32, fd uintptr) (r2 int32) +TEXT ·Ysocketpair(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL domain+8(FP), AX + MOVL AX, 8(SP) + MOVL type1+12(FP), AX + MOVL AX, 12(SP) + MOVL protocol+16(FP), AX + MOVL AX, 16(SP) + MOVQ fd+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsocketpair(SB) + MOVL 32(SP), AX + MOVL AX, r2+32(FP) + RET + +// func Ysplice(tls *TLS, fd_in int32, off_in uintptr, fd_out int32, off_out uintptr, len1 Tsize_t, flags uint32) (r Tssize_t) +TEXT ·Ysplice(SB),$64-64 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd_in+8(FP), AX + MOVL AX, 8(SP) + MOVQ off_in+16(FP), AX + MOVQ AX, 16(SP) + MOVL fd_out+24(FP), AX + MOVL AX, 24(SP) + MOVQ off_out+32(FP), AX + MOVQ AX, 32(SP) + MOVQ len1+40(FP), AX + MOVQ AX, 40(SP) + MOVL flags+48(FP), AX + MOVL AX, 48(SP) + CALL ·Xsplice(SB) + MOVQ 56(SP), AX + MOVQ AX, r+56(FP) + RET + +// func Ysprintf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Ysprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ysqrt(tls *TLS, x1 float64) (r1 float64) +TEXT ·Ysqrt(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsqrt(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Ysqrtf(tls *TLS, x1 float32) (r1 float32) +TEXT ·Ysqrtf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x1+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsqrtf(SB) + MOVL 16(SP), AX + MOVL AX, r1+16(FP) + RET + +// func Ysqrtl(tls *TLS, x float64) (r float64) +TEXT ·Ysqrtl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsqrtl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysrand(tls *TLS, s uint32) +TEXT ·Ysrand(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL s+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsrand(SB) + RET + +// func Ysrand48(tls *TLS, seed int64) +TEXT ·Ysrand48(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ seed+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsrand48(SB) + RET + +// func Ysrandom(tls *TLS, seed uint32) +TEXT ·Ysrandom(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL seed+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsrandom(SB) + RET + +// func Ysscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Ysscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ystat(tls *TLS, path uintptr, buf uintptr) (r int32) +TEXT ·Ystat(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstat(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ystat64(tls *TLS, path uintptr, buf uintptr) (r int32) +TEXT ·Ystat64(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstat64(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ystatvfs(tls *TLS, path uintptr, buf uintptr) (r int32) +TEXT ·Ystatvfs(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstatvfs(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ystatx(tls *TLS, dirfd int32, path uintptr, flags int32, mask uint32, stx uintptr) (r int32) +TEXT ·Ystatx(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL dirfd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + MOVL mask+28(FP), AX + MOVL AX, 28(SP) + MOVQ stx+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xstatx(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ystime(tls *TLS, t uintptr) (r int32) +TEXT ·Ystime(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xstime(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ystpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) +TEXT ·Ystpcpy(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstpcpy(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ystpncpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstpncpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrcasecmp(tls *TLS, _l uintptr, _r uintptr) (r1 int32) +TEXT ·Ystrcasecmp(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _r+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrcasecmp(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ystrcasecmp_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) +TEXT ·Ystrcasecmp_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ loc+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrcasecmp_l(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ystrcasestr(tls *TLS, h uintptr, n uintptr) (r uintptr) +TEXT ·Ystrcasestr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ h+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrcasestr(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrcat(tls *TLS, dest uintptr, src uintptr) (r uintptr) +TEXT ·Ystrcat(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrcat(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrchr(tls *TLS, s uintptr, c int32) (r1 uintptr) +TEXT ·Ystrchr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xstrchr(SB) + MOVQ 24(SP), AX + MOVQ AX, r1+24(FP) + RET + +// func Ystrchrnul(tls *TLS, s uintptr, c int32) (r uintptr) +TEXT ·Ystrchrnul(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xstrchrnul(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrcmp(tls *TLS, l uintptr, r uintptr) (r1 int32) +TEXT ·Ystrcmp(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrcmp(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ystrcoll(tls *TLS, l uintptr, r uintptr) (r1 int32) +TEXT ·Ystrcoll(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrcoll(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ystrcoll_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) +TEXT ·Ystrcoll_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ loc+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrcoll_l(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ystrcpy(tls *TLS, dest uintptr, src uintptr) (r uintptr) +TEXT ·Ystrcpy(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrcpy(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrcspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) +TEXT ·Ystrcspn(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ c+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrcspn(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrdup(tls *TLS, s uintptr) (r uintptr) +TEXT ·Ystrdup(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xstrdup(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ystrerror(tls *TLS, e int32) (r uintptr) +TEXT ·Ystrerror(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL e+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xstrerror(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ystrerror_l(tls *TLS, e int32, loc Tlocale_t) (r uintptr) +TEXT ·Ystrerror_l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL e+8(FP), AX + MOVL AX, 8(SP) + MOVQ loc+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrerror_l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrerror_r(tls *TLS, err int32, buf uintptr, buflen Tsize_t) (r int32) +TEXT ·Ystrerror_r(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL err+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ buflen+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrerror_r(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ystrfmon(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r Tssize_t) +TEXT ·Ystrfmon(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ fmt+24(FP), AX + MOVQ AX, 24(SP) + MOVQ va+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xstrfmon(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ystrfmon_l(tls *TLS, s uintptr, n Tsize_t, loc Tlocale_t, fmt uintptr, va uintptr) (r Tssize_t) +TEXT ·Ystrfmon_l(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ loc+24(FP), AX + MOVQ AX, 24(SP) + MOVQ fmt+32(FP), AX + MOVQ AX, 32(SP) + MOVQ va+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xstrfmon_l(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ystrftime(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr) (r Tsize_t) +TEXT ·Ystrftime(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + MOVQ tm+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xstrftime(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ystrftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) +TEXT ·Ystrftime_l(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + MOVQ tm+32(FP), AX + MOVQ AX, 32(SP) + MOVQ loc+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xstrftime_l(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ystrlcat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t) +TEXT ·Ystrlcat(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrlcat(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrlcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t) +TEXT ·Ystrlcpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrlcpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrlen(t *TLS, s uintptr) (r Tsize_t) +TEXT ·Ystrlen(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xstrlen(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ystrncasecmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32) +TEXT ·Ystrncasecmp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrncasecmp(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ystrncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, loc Tlocale_t) (r1 int32) +TEXT ·Ystrncasecmp_l(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ loc+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xstrncasecmp_l(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Ystrncat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ystrncat(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrncat(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrncmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32) +TEXT ·Ystrncmp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrncmp(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ystrncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ystrncpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrncpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrndup(tls *TLS, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ystrndup(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrndup(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrnlen(tls *TLS, s uintptr, n Tsize_t) (r Tsize_t) +TEXT ·Ystrnlen(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrnlen(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrpbrk(tls *TLS, s uintptr, b uintptr) (r uintptr) +TEXT ·Ystrpbrk(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrpbrk(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrptime(tls *TLS, s uintptr, f uintptr, tm uintptr) (r uintptr) +TEXT ·Ystrptime(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + MOVQ tm+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrptime(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrrchr(tls *TLS, s uintptr, c int32) (r uintptr) +TEXT ·Ystrrchr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xstrrchr(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrsep(tls *TLS, str uintptr, sep uintptr) (r uintptr) +TEXT ·Ystrsep(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ str+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sep+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrsep(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrsignal(tls *TLS, signum int32) (r uintptr) +TEXT ·Ystrsignal(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL signum+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xstrsignal(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ystrspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) +TEXT ·Ystrspn(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ c+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrspn(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrstr(tls *TLS, h uintptr, n uintptr) (r uintptr) +TEXT ·Ystrstr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ h+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrstr(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrtod(tls *TLS, s uintptr, p uintptr) (r float64) +TEXT ·Ystrtod(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrtod(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrtod_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) +TEXT ·Ystrtod_l(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrtod_l(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrtof(tls *TLS, s uintptr, p uintptr) (r float32) +TEXT ·Ystrtof(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrtof(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ystrtof_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float32) +TEXT ·Ystrtof_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrtof_l(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ystrtoimax(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) +TEXT ·Ystrtoimax(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xstrtoimax(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrtok(tls *TLS, s uintptr, sep uintptr) (r uintptr) +TEXT ·Ystrtok(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sep+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrtok(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrtok_r(tls *TLS, s uintptr, sep uintptr, p uintptr) (r uintptr) +TEXT ·Ystrtok_r(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sep+16(FP), AX + MOVQ AX, 16(SP) + MOVQ p+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrtok_r(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrtol(tls *TLS, s uintptr, p uintptr, base int32) (r int64) +TEXT ·Ystrtol(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xstrtol(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrtold(tls *TLS, s uintptr, p uintptr) (r float64) +TEXT ·Ystrtold(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrtold(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ystrtold_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) +TEXT ·Ystrtold_l(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrtold_l(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrtoll(tls *TLS, s uintptr, p uintptr, base int32) (r int64) +TEXT ·Ystrtoll(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xstrtoll(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrtoul(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) +TEXT ·Ystrtoul(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xstrtoul(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrtoull(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) +TEXT ·Ystrtoull(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xstrtoull(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrtoumax(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) +TEXT ·Ystrtoumax(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xstrtoumax(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrverscmp(tls *TLS, l0 uintptr, r0 uintptr) (r1 int32) +TEXT ·Ystrverscmp(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l0+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r0+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xstrverscmp(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ystrxfrm(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r Tsize_t) +TEXT ·Ystrxfrm(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xstrxfrm(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ystrxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) +TEXT ·Ystrxfrm_l(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ loc+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xstrxfrm_l(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yswab(tls *TLS, _src uintptr, _dest uintptr, n Tssize_t) +TEXT ·Yswab(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _src+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _dest+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xswab(SB) + RET + +// func Yswapoff(tls *TLS, path uintptr) (r int32) +TEXT ·Yswapoff(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xswapoff(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yswapon(tls *TLS, path uintptr, flags int32) (r int32) +TEXT ·Yswapon(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xswapon(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yswprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r int32) +TEXT ·Yswprintf(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ fmt+24(FP), AX + MOVQ AX, 24(SP) + MOVQ va+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xswprintf(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yswscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) +TEXT ·Yswscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xswscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ysymlink(tls *TLS, existing uintptr, new1 uintptr) (r int32) +TEXT ·Ysymlink(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ existing+8(FP), AX + MOVQ AX, 8(SP) + MOVQ new1+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsymlink(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ysymlinkat(tls *TLS, existing uintptr, fd int32, new1 uintptr) (r int32) +TEXT ·Ysymlinkat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ existing+8(FP), AX + MOVQ AX, 8(SP) + MOVL fd+16(FP), AX + MOVL AX, 16(SP) + MOVQ new1+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsymlinkat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ysync(tls *TLS) +TEXT ·Ysync(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xsync(SB) + RET + +// func Ysync_file_range(tls *TLS, fd int32, pos Toff_t, len1 Toff_t, flags uint32) (r int32) +TEXT ·Ysync_file_range(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ pos+16(FP), AX + MOVQ AX, 16(SP) + MOVQ len1+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xsync_file_range(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ysyncfs(tls *TLS, fd int32) (r int32) +TEXT ·Ysyncfs(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsyncfs(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysyscall(tls *TLS, n int64, va uintptr) (r int64) +TEXT ·Ysyscall(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ n+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xsyscall(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ysysconf(tls *TLS, name int32) (r int64) +TEXT ·Ysysconf(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL name+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xsysconf(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ysysctlbyname(t *TLS, name, oldp, oldlenp, newp uintptr, newlen Tsize_t) (_3 int32) +TEXT ·Ysysctlbyname(SB),$56-52 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + MOVQ oldp+16(FP), AX + MOVQ AX, 16(SP) + MOVQ oldlenp+24(FP), AX + MOVQ AX, 24(SP) + MOVQ newp+32(FP), AX + MOVQ AX, 32(SP) + MOVQ newlen+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xsysctlbyname(SB) + MOVL 48(SP), AX + MOVL AX, _3+48(FP) + RET + +// func Ysysinfo(tls *TLS, info uintptr) (r int32) +TEXT ·Ysysinfo(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ info+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsysinfo(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ysyslog(tls *TLS, priority int32, message uintptr, va uintptr) +TEXT ·Ysyslog(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL priority+8(FP), AX + MOVL AX, 8(SP) + MOVQ message+16(FP), AX + MOVQ AX, 16(SP) + MOVQ va+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xsyslog(SB) + RET + +// func Ysystem(t *TLS, command uintptr) (_2 int32) +TEXT ·Ysystem(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ command+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xsystem(SB) + MOVL 16(SP), AX + MOVL AX, _2+16(FP) + RET + +// func Ytan(tls *TLS, x3 float64) (r float64) +TEXT ·Ytan(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtan(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytanf(tls *TLS, x3 float32) (r float32) +TEXT ·Ytanf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtanf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytanh(tls *TLS, x3 float64) (r float64) +TEXT ·Ytanh(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtanh(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytanhf(tls *TLS, x3 float32) (r float32) +TEXT ·Ytanhf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtanhf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytanhl(tls *TLS, x float64) (r float64) +TEXT ·Ytanhl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtanhl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytanl(tls *TLS, x float64) (r float64) +TEXT ·Ytanl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtanl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytcdrain(tls *TLS, fd int32) (r int32) +TEXT ·Ytcdrain(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtcdrain(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytcflow(tls *TLS, fd int32, action int32) (r int32) +TEXT ·Ytcflow(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL action+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xtcflow(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytcflush(tls *TLS, fd int32, queue int32) (r int32) +TEXT ·Ytcflush(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL queue+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xtcflush(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytcgetattr(tls *TLS, fd int32, tio uintptr) (r int32) +TEXT ·Ytcgetattr(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ tio+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtcgetattr(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytcgetpgrp(tls *TLS, fd int32) (r Tpid_t) +TEXT ·Ytcgetpgrp(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtcgetpgrp(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytcgetsid(tls *TLS, fd int32) (r Tpid_t) +TEXT ·Ytcgetsid(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtcgetsid(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytcgetwinsize(tls *TLS, fd int32, wsz uintptr) (r int32) +TEXT ·Ytcgetwinsize(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ wsz+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtcgetwinsize(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytcsendbreak(tls *TLS, fd int32, dur int32) (r int32) +TEXT ·Ytcsendbreak(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL dur+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xtcsendbreak(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytcsetattr(tls *TLS, fd int32, act int32, tio uintptr) (r int32) +TEXT ·Ytcsetattr(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL act+12(FP), AX + MOVL AX, 12(SP) + MOVQ tio+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtcsetattr(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytcsetpgrp(tls *TLS, fd int32, pgrp Tpid_t) (r int32) +TEXT ·Ytcsetpgrp(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL pgrp+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xtcsetpgrp(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytcsetwinsize(tls *TLS, fd int32, wsz uintptr) (r int32) +TEXT ·Ytcsetwinsize(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ wsz+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtcsetwinsize(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytdelete(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r uintptr) +TEXT ·Ytdelete(SB),$48-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cmp+24(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_tdelete_2(SB) // Create the closure for calling __ccgo_fp_cmp + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ rootp+16(FP), AX + MOVQ AX, 16(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 24(SP) + CALL ·Xtdelete(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_tdelete_2(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Ytdestroy(tls *TLS, root uintptr, __ccgo_fp_freekey uintptr) +TEXT ·Ytdestroy(SB),$32-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_freekey+16(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_tdestroy_1(SB) // Create the closure for calling __ccgo_fp_freekey + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ root+8(FP), AX + MOVQ AX, 8(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 16(SP) + CALL ·Xtdestroy(SB) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_tdestroy_1(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ __ccgo_fp+16(FP), AX + CALL *AX // Call the ABI0 code ptr + RET + +// func Ytee(tls *TLS, src int32, dest int32, len1 Tsize_t, flags uint32) (r Tssize_t) +TEXT ·Ytee(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL src+8(FP), AX + MOVL AX, 8(SP) + MOVL dest+12(FP), AX + MOVL AX, 12(SP) + MOVQ len1+16(FP), AX + MOVQ AX, 16(SP) + MOVL flags+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xtee(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ytelldir(tls *TLS, dir uintptr) (r int64) +TEXT ·Ytelldir(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dir+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtelldir(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytempnam(tls *TLS, dir uintptr, pfx uintptr) (r1 uintptr) +TEXT ·Ytempnam(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dir+8(FP), AX + MOVQ AX, 8(SP) + MOVQ pfx+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtempnam(SB) + MOVQ 24(SP), AX + MOVQ AX, r1+24(FP) + RET + +// func Ytextdomain(tls *TLS, domainname uintptr) (r uintptr) +TEXT ·Ytextdomain(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ domainname+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtextdomain(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytfind(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r uintptr) +TEXT ·Ytfind(SB),$48-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cmp+24(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_tfind_2(SB) // Create the closure for calling __ccgo_fp_cmp + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ rootp+16(FP), AX + MOVQ AX, 16(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 24(SP) + CALL ·Xtfind(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_tfind_2(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Ytgamma(tls *TLS, x3 float64) (r1 float64) +TEXT ·Ytgamma(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtgamma(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Ytgammaf(tls *TLS, x float32) (r float32) +TEXT ·Ytgammaf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtgammaf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytgammal(tls *TLS, x float64) (r float64) +TEXT ·Ytgammal(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtgammal(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytime(tls *TLS, t uintptr) (r Ttime_t) +TEXT ·Ytime(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtime(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytimegm(tls *TLS, tm uintptr) (r Ttime_t) +TEXT ·Ytimegm(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tm+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtimegm(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytimer_delete(tls *TLS, t Ttimer_t) (r int32) +TEXT ·Ytimer_delete(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtimer_delete(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytimer_getoverrun(tls *TLS, t Ttimer_t) (r int32) +TEXT ·Ytimer_getoverrun(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtimer_getoverrun(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytimer_gettime(tls *TLS, t Ttimer_t, val uintptr) (r int32) +TEXT ·Ytimer_gettime(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVQ val+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtimer_gettime(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytimer_settime(tls *TLS, t Ttimer_t, flags int32, val uintptr, old uintptr) (r int32) +TEXT ·Ytimer_settime(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ t+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + MOVQ val+24(FP), AX + MOVQ AX, 24(SP) + MOVQ old+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xtimer_settime(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Ytimerfd_create(tls *TLS, clockid int32, flags int32) (r int32) +TEXT ·Ytimerfd_create(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL clockid+8(FP), AX + MOVL AX, 8(SP) + MOVL flags+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xtimerfd_create(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytimerfd_gettime(tls *TLS, fd int32, cur uintptr) (r int32) +TEXT ·Ytimerfd_gettime(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ cur+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtimerfd_gettime(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytimerfd_settime(tls *TLS, fd int32, flags int32, new1 uintptr, old uintptr) (r int32) +TEXT ·Ytimerfd_settime(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVL flags+12(FP), AX + MOVL AX, 12(SP) + MOVQ new1+16(FP), AX + MOVQ AX, 16(SP) + MOVQ old+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xtimerfd_settime(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ytimes(tls *TLS, tms uintptr) (r Tclock_t) +TEXT ·Ytimes(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ tms+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtimes(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytimespec_get(tls *TLS, ts uintptr, base int32) (r int32) +TEXT ·Ytimespec_get(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ ts+8(FP), AX + MOVQ AX, 8(SP) + MOVL base+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xtimespec_get(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytmpfile(tls *TLS) (r uintptr) +TEXT ·Ytmpfile(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xtmpfile(SB) + MOVQ 8(SP), AX + MOVQ AX, r+8(FP) + RET + +// func Ytmpnam(tls *TLS, buf uintptr) (r1 uintptr) +TEXT ·Ytmpnam(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ buf+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtmpnam(SB) + MOVQ 16(SP), AX + MOVQ AX, r1+16(FP) + RET + +// func Ytoascii(tls *TLS, c int32) (r int32) +TEXT ·Ytoascii(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtoascii(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytolower(tls *TLS, c int32) (r int32) +TEXT ·Ytolower(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtolower(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytolower_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Ytolower_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtolower_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytoupper(tls *TLS, c int32) (r int32) +TEXT ·Ytoupper(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtoupper(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytoupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) +TEXT ·Ytoupper_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtoupper_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytowctrans(tls *TLS, wc Twint_t, trans Twctrans_t) (r Twint_t) +TEXT ·Ytowctrans(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + MOVQ trans+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtowctrans(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytowctrans_l(tls *TLS, c Twint_t, t Twctrans_t, l Tlocale_t) (r Twint_t) +TEXT ·Ytowctrans_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ t+16(FP), AX + MOVQ AX, 16(SP) + MOVQ l+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xtowctrans_l(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ytowlower(tls *TLS, wc Twint_t) (r Twint_t) +TEXT ·Ytowlower(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtowlower(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytowlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) +TEXT ·Ytowlower_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtowlower_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytowupper(tls *TLS, wc Twint_t) (r Twint_t) +TEXT ·Ytowupper(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtowupper(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytowupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) +TEXT ·Ytowupper_l(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtowupper_l(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytrunc(tls *TLS, x3 float64) (r float64) +TEXT ·Ytrunc(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x3+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtrunc(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytruncate(tls *TLS, path uintptr, length Toff_t) (r int32) +TEXT ·Ytruncate(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ length+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xtruncate(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ytruncf(tls *TLS, x3 float32) (r float32) +TEXT ·Ytruncf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x3+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xtruncf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ytruncl(tls *TLS, x float64) (r float64) +TEXT ·Ytruncl(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xtruncl(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ytsearch(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r1 uintptr) +TEXT ·Ytsearch(SB),$48-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_cmp+24(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_tsearch_2(SB) // Create the closure for calling __ccgo_fp_cmp + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ key+8(FP), AX + MOVQ AX, 8(SP) + MOVQ rootp+16(FP), AX + MOVQ AX, 16(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 24(SP) + CALL ·Xtsearch(SB) + MOVQ 32(SP), AX + MOVQ AX, r1+32(FP) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_tsearch_2(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVQ _2+16(FP), AX + MOVQ AX, 16(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + MOVL 24(SP), AX + MOVL AX, _3+32(FP) + RET + +// func Yttyname(tls *TLS, fd int32) (r uintptr) +TEXT ·Yttyname(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xttyname(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yttyname_r(tls *TLS, fd int32, name uintptr, size Tsize_t) (r int32) +TEXT ·Yttyname_r(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ name+16(FP), AX + MOVQ AX, 16(SP) + MOVQ size+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xttyname_r(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ytwalk(tls *TLS, root uintptr, __ccgo_fp_action uintptr) +TEXT ·Ytwalk(SB),$32-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX // alloc all ABI trampolines + MOVQ AX, 0(SP) + MOVQ $16, 8(SP) // 16*(number of func ptrs in signature) + CALL modernc·org∕libc·TLSAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, -8(BP) // Trampolines[0] + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ -8(BP), AX + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 8(SP) + MOVQ __ccgo_fp_action+16(FP), AX // ABI0 code ptr + MOVQ AX, 16(SP) + CALL ·__ccgo_abiInternal_twalk_1(SB) // Create the closure for calling __ccgo_fp_action + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ root+8(FP), AX + MOVQ AX, 8(SP) + MOVQ -8(BP), AX // Trampolines[0] + ADDQ $0, AX // 16*(0-based ordinal number of the func ptr in signature) + MOVQ AX, 16(SP) + CALL ·Xtwalk(SB) + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ $0, 8(SP) + CALL modernc·org∕libc·TLSFree(SB) + RET + +TEXT ·__ccgo_abi0_twalk_1(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ _0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ _1+8(FP), AX + MOVQ AX, 8(SP) + MOVL _2+16(FP), AX + MOVL AX, 16(SP) + MOVL _3+20(FP), AX + MOVL AX, 20(SP) + MOVQ __ccgo_fp+24(FP), AX + CALL *AX // Call the ABI0 code ptr + RET + +// func Ytzset(tls *TLS) +TEXT ·Ytzset(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xtzset(SB) + RET + +// func Yualarm(tls *TLS, value uint32, interval uint32) (r uint32) +TEXT ·Yualarm(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL value+8(FP), AX + MOVL AX, 8(SP) + MOVL interval+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xualarm(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yulckpwdf(tls *TLS) (r int32) +TEXT ·Yulckpwdf(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xulckpwdf(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yulimit(tls *TLS, cmd int32, va uintptr) (r int64) +TEXT ·Yulimit(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL cmd+8(FP), AX + MOVL AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xulimit(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yumask(tls *TLS, mode Tmode_t) (r Tmode_t) +TEXT ·Yumask(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL mode+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xumask(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yumount(tls *TLS, special uintptr) (r int32) +TEXT ·Yumount(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ special+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xumount(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yumount2(tls *TLS, special uintptr, flags int32) (r int32) +TEXT ·Yumount2(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ special+8(FP), AX + MOVQ AX, 8(SP) + MOVL flags+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xumount2(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yuname(tls *TLS, uts uintptr) (r int32) +TEXT ·Yuname(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ uts+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xuname(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yungetc(tls *TLS, c int32, f uintptr) (r int32) +TEXT ·Yungetc(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xungetc(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yungetwc(tls *TLS, c Twint_t, f uintptr) (r Twint_t) +TEXT ·Yungetwc(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + MOVQ f+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xungetwc(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yunlink(tls *TLS, path uintptr) (r int32) +TEXT ·Yunlink(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xunlink(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yunlinkat(tls *TLS, fd int32, path uintptr, flag int32) (r int32) +TEXT ·Yunlinkat(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVL flag+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xunlinkat(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yunlockpt(tls *TLS, fd int32) (r int32) +TEXT ·Yunlockpt(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xunlockpt(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yunsetenv(tls *TLS, name uintptr) (r int32) +TEXT ·Yunsetenv(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ name+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xunsetenv(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yunshare(tls *TLS, flags int32) (r int32) +TEXT ·Yunshare(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL flags+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xunshare(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yupdwtmp(tls *TLS, f uintptr, u uintptr) +TEXT ·Yupdwtmp(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ u+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xupdwtmp(SB) + RET + +// func Yupdwtmpx(tls *TLS, f uintptr, u uintptr) +TEXT ·Yupdwtmpx(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ u+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xupdwtmpx(SB) + RET + +// func Yuselocale(tls *TLS, new1 Tlocale_t) (r Tlocale_t) +TEXT ·Yuselocale(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ new1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xuselocale(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yusleep(tls *TLS, useconds uint32) (r int32) +TEXT ·Yusleep(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL useconds+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xusleep(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yutime(tls *TLS, path uintptr, times uintptr) (r int32) +TEXT ·Yutime(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ times+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xutime(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yutimensat(tls *TLS, fd int32, path uintptr, times uintptr, flags int32) (r1 int32) +TEXT ·Yutimensat(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ path+16(FP), AX + MOVQ AX, 16(SP) + MOVQ times+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xutimensat(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Yutimes(tls *TLS, path uintptr, times uintptr) (r int32) +TEXT ·Yutimes(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ path+8(FP), AX + MOVQ AX, 8(SP) + MOVQ times+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xutimes(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yuuid_copy(t *TLS, dst, src uintptr) +TEXT ·Yuuid_copy(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dst+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xuuid_copy(SB) + RET + +// func Yuuid_generate_random(t *TLS, out uintptr) +TEXT ·Yuuid_generate_random(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ out+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xuuid_generate_random(SB) + RET + +// func Yuuid_parse(t *TLS, in uintptr, uu uintptr) (_3 int32) +TEXT ·Yuuid_parse(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ in+8(FP), AX + MOVQ AX, 8(SP) + MOVQ uu+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xuuid_parse(SB) + MOVL 24(SP), AX + MOVL AX, _3+24(FP) + RET + +// func Yuuid_unparse(t *TLS, uu, out uintptr) +TEXT ·Yuuid_unparse(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ t+0(FP), AX + MOVQ AX, 0(SP) + MOVQ uu+8(FP), AX + MOVQ AX, 8(SP) + MOVQ out+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xuuid_unparse(SB) + RET + +// func Yvasprintf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvasprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvasprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yvdprintf(tls *TLS, fd int32, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvdprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvdprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yverr(tls *TLS, status int32, fmt uintptr, ap Tva_list) +TEXT ·Yverr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL status+8(FP), AX + MOVL AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xverr(SB) + RET + +// func Yverrx(tls *TLS, status int32, fmt uintptr, ap Tva_list) +TEXT ·Yverrx(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL status+8(FP), AX + MOVL AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xverrx(SB) + RET + +// func Yversionsort(tls *TLS, a uintptr, b uintptr) (r int32) +TEXT ·Yversionsort(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ a+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xversionsort(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yvfork(tls *TLS) (r Tpid_t) +TEXT ·Yvfork(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xvfork(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yvfprintf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvfprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvfprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yvfscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvfscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvfscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yvfwprintf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvfwprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvfwprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yvfwscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvfwscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ f+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvfwscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yvhangup(tls *TLS) (r int32) +TEXT ·Yvhangup(SB),$16-12 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + CALL ·Xvhangup(SB) + MOVL 8(SP), AX + MOVL AX, r+8(FP) + RET + +// func Yvmsplice(tls *TLS, fd int32, iov uintptr, cnt Tsize_t, flags uint32) (r Tssize_t) +TEXT ·Yvmsplice(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ iov+16(FP), AX + MOVQ AX, 16(SP) + MOVQ cnt+24(FP), AX + MOVQ AX, 24(SP) + MOVL flags+32(FP), AX + MOVL AX, 32(SP) + CALL ·Xvmsplice(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Yvprintf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvprintf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xvprintf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yvscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvscanf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xvscanf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yvsnprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvsnprintf(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ fmt+24(FP), AX + MOVQ AX, 24(SP) + MOVQ ap+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xvsnprintf(SB) + MOVL 40(SP), AX + MOVL AX, r+40(FP) + RET + +// func Yvsprintf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvsprintf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvsprintf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yvsscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvsscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvsscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yvswprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, ap Tva_list) (r1 int32) +TEXT ·Yvswprintf(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ fmt+24(FP), AX + MOVQ AX, 24(SP) + MOVQ ap+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xvswprintf(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Yvswscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvswscanf(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ fmt+16(FP), AX + MOVQ AX, 16(SP) + MOVQ ap+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xvswscanf(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Yvwarn(tls *TLS, fmt uintptr, ap Tva_list) +TEXT ·Yvwarn(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xvwarn(SB) + RET + +// func Yvwarnx(tls *TLS, fmt uintptr, ap Tva_list) +TEXT ·Yvwarnx(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xvwarnx(SB) + RET + +// func Yvwprintf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvwprintf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xvwprintf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yvwscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) +TEXT ·Yvwscanf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ap+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xvwscanf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ywait(tls *TLS, status uintptr) (r Tpid_t) +TEXT ·Ywait(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ status+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xwait(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ywait3(tls *TLS, status uintptr, options int32, usage uintptr) (r Tpid_t) +TEXT ·Ywait3(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ status+8(FP), AX + MOVQ AX, 8(SP) + MOVL options+16(FP), AX + MOVL AX, 16(SP) + MOVQ usage+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwait3(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ywait4(tls *TLS, pid Tpid_t, status uintptr, options int32, ru uintptr) (r1 Tpid_t) +TEXT ·Ywait4(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVQ status+16(FP), AX + MOVQ AX, 16(SP) + MOVL options+24(FP), AX + MOVL AX, 24(SP) + MOVQ ru+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xwait4(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Ywaitid(tls *TLS, type1 Tidtype_t, id Tid_t, info uintptr, options int32) (r int32) +TEXT ·Ywaitid(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL type1+8(FP), AX + MOVL AX, 8(SP) + MOVL id+12(FP), AX + MOVL AX, 12(SP) + MOVQ info+16(FP), AX + MOVQ AX, 16(SP) + MOVL options+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwaitid(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ywaitpid(tls *TLS, pid Tpid_t, status uintptr, options int32) (r Tpid_t) +TEXT ·Ywaitpid(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL pid+8(FP), AX + MOVL AX, 8(SP) + MOVQ status+16(FP), AX + MOVQ AX, 16(SP) + MOVL options+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwaitpid(SB) + MOVL 32(SP), AX + MOVL AX, r+32(FP) + RET + +// func Ywarn(tls *TLS, fmt uintptr, va uintptr) +TEXT ·Ywarn(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwarn(SB) + RET + +// func Ywarnx(tls *TLS, fmt uintptr, va uintptr) +TEXT ·Ywarnx(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwarnx(SB) + RET + +// func Ywcpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) +TEXT ·Ywcpcpy(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcpcpy(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ywcpncpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcpncpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcrtomb(tls *TLS, s uintptr, wc Twchar_t, st uintptr) (r Tsize_t) +TEXT ·Ywcrtomb(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL wc+16(FP), AX + MOVL AX, 16(SP) + MOVQ st+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcrtomb(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcscasecmp(tls *TLS, l uintptr, r uintptr) (r1 int32) +TEXT ·Ywcscasecmp(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcscasecmp(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ywcscasecmp_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) +TEXT ·Ywcscasecmp_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ locale+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcscasecmp_l(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ywcscat(tls *TLS, dest uintptr, src uintptr) (r uintptr) +TEXT ·Ywcscat(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcscat(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcschr(tls *TLS, s uintptr, c Twchar_t) (r uintptr) +TEXT ·Ywcschr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xwcschr(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcscmp(tls *TLS, l uintptr, r uintptr) (r1 int32) +TEXT ·Ywcscmp(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcscmp(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ywcscoll(tls *TLS, l uintptr, r uintptr) (r1 int32) +TEXT ·Ywcscoll(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcscoll(SB) + MOVL 24(SP), AX + MOVL AX, r1+24(FP) + RET + +// func Ywcscoll_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) +TEXT ·Ywcscoll_l(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ locale+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcscoll_l(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ywcscpy(tls *TLS, d uintptr, s uintptr) (r uintptr) +TEXT ·Ywcscpy(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcscpy(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcscspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) +TEXT ·Ywcscspn(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ c+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcscspn(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcsdup(tls *TLS, s uintptr) (r uintptr) +TEXT ·Ywcsdup(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xwcsdup(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ywcsftime(tls *TLS, wcs uintptr, n Tsize_t, f uintptr, tm uintptr) (r Tsize_t) +TEXT ·Ywcsftime(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ wcs+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + MOVQ tm+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xwcsftime(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ywcsftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) +TEXT ·Ywcsftime_l(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + MOVQ f+24(FP), AX + MOVQ AX, 24(SP) + MOVQ tm+32(FP), AX + MOVQ AX, 32(SP) + MOVQ loc+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xwcsftime_l(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ywcslen(tls *TLS, s uintptr) (r Tsize_t) +TEXT ·Ywcslen(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xwcslen(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ywcsncasecmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) +TEXT ·Ywcsncasecmp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcsncasecmp(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ywcsncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, locale Tlocale_t) (r1 int32) +TEXT ·Ywcsncasecmp_l(SB),$48-44 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ locale+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xwcsncasecmp_l(SB) + MOVL 40(SP), AX + MOVL AX, r1+40(FP) + RET + +// func Ywcsncat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ywcsncat(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcsncat(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcsncmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) +TEXT ·Ywcsncmp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcsncmp(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ywcsncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ywcsncpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcsncpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcsnlen(tls *TLS, s uintptr, n Tsize_t) (r Tsize_t) +TEXT ·Ywcsnlen(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcsnlen(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcsnrtombs(tls *TLS, dst uintptr, wcs uintptr, wn Tsize_t, n Tsize_t, st uintptr) (r Tsize_t) +TEXT ·Ywcsnrtombs(SB),$56-56 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dst+8(FP), AX + MOVQ AX, 8(SP) + MOVQ wcs+16(FP), AX + MOVQ AX, 16(SP) + MOVQ wn+24(FP), AX + MOVQ AX, 24(SP) + MOVQ n+32(FP), AX + MOVQ AX, 32(SP) + MOVQ st+40(FP), AX + MOVQ AX, 40(SP) + CALL ·Xwcsnrtombs(SB) + MOVQ 48(SP), AX + MOVQ AX, r+48(FP) + RET + +// func Ywcspbrk(tls *TLS, s uintptr, b uintptr) (r uintptr) +TEXT ·Ywcspbrk(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ b+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcspbrk(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcsrchr(tls *TLS, s uintptr, c Twchar_t) (r uintptr) +TEXT ·Ywcsrchr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xwcsrchr(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcsrtombs(tls *TLS, s uintptr, ws uintptr, n Tsize_t, st uintptr) (r Tsize_t) +TEXT ·Ywcsrtombs(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ws+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ st+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xwcsrtombs(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ywcsspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) +TEXT ·Ywcsspn(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ c+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcsspn(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcsstr(tls *TLS, h uintptr, n uintptr) (r uintptr) +TEXT ·Ywcsstr(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ h+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcsstr(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcstod(tls *TLS, s uintptr, p uintptr) (r float64) +TEXT ·Ywcstod(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcstod(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcstof(tls *TLS, s uintptr, p uintptr) (r float32) +TEXT ·Ywcstof(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcstof(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ywcstoimax(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) +TEXT ·Ywcstoimax(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwcstoimax(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcstok(tls *TLS, s uintptr, sep uintptr, p uintptr) (r uintptr) +TEXT ·Ywcstok(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ sep+16(FP), AX + MOVQ AX, 16(SP) + MOVQ p+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcstok(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcstol(tls *TLS, s uintptr, p uintptr, base int32) (r int64) +TEXT ·Ywcstol(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwcstol(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcstold(tls *TLS, s uintptr, p uintptr) (r float64) +TEXT ·Ywcstold(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcstold(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcstoll(tls *TLS, s uintptr, p uintptr, base int32) (r int64) +TEXT ·Ywcstoll(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwcstoll(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcstombs(tls *TLS, s uintptr, ws uintptr, n Tsize_t) (r Tsize_t) +TEXT ·Ywcstombs(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ ws+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcstombs(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcstoul(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) +TEXT ·Ywcstoul(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwcstoul(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcstoull(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) +TEXT ·Ywcstoull(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwcstoull(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcstoumax(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) +TEXT ·Ywcstoumax(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ p+16(FP), AX + MOVQ AX, 16(SP) + MOVL base+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwcstoumax(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcswcs(tls *TLS, haystack uintptr, needle uintptr) (r uintptr) +TEXT ·Ywcswcs(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ haystack+8(FP), AX + MOVQ AX, 8(SP) + MOVQ needle+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcswcs(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcswidth(tls *TLS, wcs uintptr, n Tsize_t) (r int32) +TEXT ·Ywcswidth(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ wcs+8(FP), AX + MOVQ AX, 8(SP) + MOVQ n+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwcswidth(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ywcsxfrm(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r Tsize_t) +TEXT ·Ywcsxfrm(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwcsxfrm(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywcsxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) +TEXT ·Ywcsxfrm_l(SB),$48-48 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ dest+8(FP), AX + MOVQ AX, 8(SP) + MOVQ src+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + MOVQ loc+32(FP), AX + MOVQ AX, 32(SP) + CALL ·Xwcsxfrm_l(SB) + MOVQ 40(SP), AX + MOVQ AX, r+40(FP) + RET + +// func Ywctob(tls *TLS, c Twint_t) (r int32) +TEXT ·Ywctob(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL c+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xwctob(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ywctomb(tls *TLS, s uintptr, wc Twchar_t) (r int32) +TEXT ·Ywctomb(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL wc+16(FP), AX + MOVL AX, 16(SP) + CALL ·Xwctomb(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ywctrans(tls *TLS, class uintptr) (r Twctrans_t) +TEXT ·Ywctrans(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ class+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xwctrans(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ywctrans_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctrans_t) +TEXT ·Ywctrans_l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwctrans_l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywctype(tls *TLS, s uintptr) (r Twctype_t) +TEXT ·Ywctype(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xwctype(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Ywctype_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctype_t) +TEXT ·Ywctype_l(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVQ l+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwctype_l(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Ywcwidth(tls *TLS, wc Twchar_t) (r int32) +TEXT ·Ywcwidth(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL wc+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xwcwidth(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Ywmemchr(tls *TLS, s uintptr, c Twchar_t, n Tsize_t) (r uintptr) +TEXT ·Ywmemchr(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ s+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwmemchr(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywmemcmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) +TEXT ·Ywmemcmp(SB),$40-36 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ l+8(FP), AX + MOVQ AX, 8(SP) + MOVQ r+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwmemcmp(SB) + MOVL 32(SP), AX + MOVL AX, r1+32(FP) + RET + +// func Ywmemcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ywmemcpy(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwmemcpy(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywmemmove(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) +TEXT ·Ywmemmove(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVQ s+16(FP), AX + MOVQ AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwmemmove(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywmemset(tls *TLS, d uintptr, c Twchar_t, n Tsize_t) (r uintptr) +TEXT ·Ywmemset(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ d+8(FP), AX + MOVQ AX, 8(SP) + MOVL c+16(FP), AX + MOVL AX, 16(SP) + MOVQ n+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwmemset(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywprintf(tls *TLS, fmt uintptr, va uintptr) (r int32) +TEXT ·Ywprintf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwprintf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Ywrite(tls *TLS, fd int32, buf uintptr, count Tsize_t) (r Tssize_t) +TEXT ·Ywrite(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ buf+16(FP), AX + MOVQ AX, 16(SP) + MOVQ count+24(FP), AX + MOVQ AX, 24(SP) + CALL ·Xwrite(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywritev(tls *TLS, fd int32, iov uintptr, count int32) (r Tssize_t) +TEXT ·Ywritev(SB),$40-40 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL fd+8(FP), AX + MOVL AX, 8(SP) + MOVQ iov+16(FP), AX + MOVQ AX, 16(SP) + MOVL count+24(FP), AX + MOVL AX, 24(SP) + CALL ·Xwritev(SB) + MOVQ 32(SP), AX + MOVQ AX, r+32(FP) + RET + +// func Ywscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) +TEXT ·Ywscanf(SB),$32-28 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ fmt+8(FP), AX + MOVQ AX, 8(SP) + MOVQ va+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xwscanf(SB) + MOVL 24(SP), AX + MOVL AX, r+24(FP) + RET + +// func Yy0(tls *TLS, x float64) (r float64) +TEXT ·Yy0(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xy0(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yy0f(tls *TLS, x float32) (r float32) +TEXT ·Yy0f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xy0f(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yy1(tls *TLS, x float64) (r float64) +TEXT ·Yy1(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVQ x+8(FP), AX + MOVQ AX, 8(SP) + CALL ·Xy1(SB) + MOVQ 16(SP), AX + MOVQ AX, r+16(FP) + RET + +// func Yy1f(tls *TLS, x float32) (r float32) +TEXT ·Yy1f(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL x+8(FP), AX + MOVL AX, 8(SP) + CALL ·Xy1f(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET + +// func Yyn(tls *TLS, n int32, x float64) (r float64) +TEXT ·Yyn(SB),$32-32 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + MOVQ x+16(FP), AX + MOVQ AX, 16(SP) + CALL ·Xyn(SB) + MOVQ 24(SP), AX + MOVQ AX, r+24(FP) + RET + +// func Yynf(tls *TLS, n int32, x float32) (r float32) +TEXT ·Yynf(SB),$24-20 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ tls+0(FP), AX + MOVQ AX, 0(SP) + MOVL n+8(FP), AX + MOVL AX, 8(SP) + MOVL x+12(FP), AX + MOVL AX, 12(SP) + CALL ·Xynf(SB) + MOVL 16(SP), AX + MOVL AX, r+16(FP) + RET diff --git a/internal/libc/aliases.go b/internal/libc/aliases.go new file mode 100644 index 0000000..b1faca7 --- /dev/null +++ b/internal/libc/aliases.go @@ -0,0 +1,109 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +func X__vm_wait(tls *TLS) {} + +// static volatile int *const dummy_lockptr = 0; +// +// weak_alias(dummy_lockptr, __atexit_lockptr); +// weak_alias(dummy_lockptr, __bump_lockptr); +// weak_alias(dummy_lockptr, __sem_open_lockptr); +var X__atexit_lockptr int32 +var X__bump_lockptr int32 +var X__sem_open_lockptr int32 + +// static int dummy(int fd) +// +// { +// return fd; +// } +// +// weak_alias(dummy, __aio_close); +func X__aio_close(tls *TLS, fd int32) int32 { + return fd +} + +func Xtzset(tls *TLS) { + ___tzset(tls) +} + +type DIR = TDIR + +const DT_DETACHED = _DT_DETACHED + +const DT_EXITING = _DT_EXITING + +const DT_JOINABLE = _DT_JOINABLE + +type FILE = TFILE + +type HEADER = THEADER + +func Xfcntl64(tls *TLS, fd int32, cmd int32, va uintptr) (r int32) { + return Xfcntl(tls, fd, cmd, va) +} + +func Xfopen64(tls *TLS, filename uintptr, mode uintptr) (r uintptr) { + return Xfopen(tls, filename, mode) +} + +func Xfstat64(tls *TLS, fd int32, st uintptr) (r int32) { + return Xfstat(tls, fd, st) +} + +func Xftruncate64(tls *TLS, fd int32, length Toff_t) (r int32) { + return Xftruncate(tls, fd, length) +} + +func Xgetrlimit64(tls *TLS, resource int32, rlim uintptr) (r int32) { + return Xgetrlimit(tls, resource, rlim) +} + +func Xlseek64(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) { + return Xlseek(tls, fd, offset, whence) +} + +func Xlstat64(tls *TLS, path uintptr, buf uintptr) (r int32) { + return Xlstat(tls, path, buf) +} + +func Xmkstemp64(tls *TLS, template uintptr) (r int32) { + return Xmkstemp(tls, template) +} + +func Xmkstemps64(tls *TLS, template uintptr, len1 int32) (r int32) { + return Xmkstemps(tls, template, len1) +} + +func Xmmap64(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) { + return Xmmap(tls, start, len1, prot, flags, fd, off) +} + +func Xopen64(tls *TLS, filename uintptr, flags int32, va uintptr) (r int32) { + return Xopen(tls, filename, flags, va) +} + +func Xreaddir64(tls *TLS, dir uintptr) (r uintptr) { + return Xreaddir(tls, dir) +} + +func Xsetrlimit64(tls *TLS, resource int32, rlim uintptr) (r int32) { + return Xsetrlimit(tls, resource, rlim) +} + +func Xstat64(tls *TLS, path uintptr, buf uintptr) (r int32) { + return Xstat(tls, path, buf) +} + +func Xpthread_setcancelstate(tls *TLS, new int32, old uintptr) int32 { + return _pthread_setcancelstate(tls, new, old) +} + +func Xpthread_sigmask(tls *TLS, now int32, set, old uintptr) int32 { + return _pthread_sigmask(tls, now, set, old) +} diff --git a/internal/libc/atomic.go b/internal/libc/atomic.go new file mode 100644 index 0000000..7a38268 --- /dev/null +++ b/internal/libc/atomic.go @@ -0,0 +1,117 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "math" + mbits "math/bits" + "sync/atomic" + "unsafe" +) + +func a_store_8(addr uintptr, val int8) int8 { + *(*int8)(unsafe.Pointer(addr)) = val + return val +} + +func a_load_8(addr uintptr) (val int8) { + return *(*int8)(unsafe.Pointer(addr)) +} + +func a_load_16(addr uintptr) (val int16) { + if addr&1 != 0 { + panic("unaligned atomic access") + } + + return *(*int16)(unsafe.Pointer(addr)) +} + +func a_store_16(addr uintptr, val uint16) { + if addr&1 != 0 { + panic("unaligned atomic access") + } + + *(*uint16)(unsafe.Pointer(addr)) = val +} + +// static inline int a_ctz_64(uint64_t x) +func _a_ctz_64(tls *TLS, x uint64) int32 { + return int32(mbits.TrailingZeros64(x)) +} + +func AtomicAddFloat32(addr *float32, delta float32) (new float32) { + for { + oldBits := atomic.LoadUint32((*uint32)(unsafe.Pointer(addr))) + oldVal := math.Float32frombits(oldBits) + newVal := oldVal + delta + newBits := math.Float32bits(newVal) + if atomic.CompareAndSwapUint32((*uint32)(unsafe.Pointer(addr)), oldBits, newBits) { + return newVal + } + } +} + +func AtomicLoadFloat32(addr *float32) (val float32) { + return math.Float32frombits(atomic.LoadUint32((*uint32)(unsafe.Pointer(addr)))) +} + +func AtomicStoreFloat32(addr *float32, val float32) { + atomic.StoreUint32((*uint32)(unsafe.Pointer(addr)), math.Float32bits(val)) +} + +func AtomicAddFloat64(addr *float64, delta float64) (new float64) { + for { + oldBits := atomic.LoadUint64((*uint64)(unsafe.Pointer(addr))) + oldVal := math.Float64frombits(oldBits) + newVal := oldVal + delta + newBits := math.Float64bits(newVal) + if atomic.CompareAndSwapUint64((*uint64)(unsafe.Pointer(addr)), oldBits, newBits) { + return newVal + } + } +} + +func AtomicLoadFloat64(addr *float64) (val float64) { + return math.Float64frombits(atomic.LoadUint64((*uint64)(unsafe.Pointer(addr)))) +} + +func AtomicStoreFloat64(addr *float64, val float64) { + atomic.StoreUint64((*uint64)(unsafe.Pointer(addr)), math.Float64bits(val)) +} + +func AtomicAddInt32(addr *int32, delta int32) (new int32) { return atomic.AddInt32(addr, delta) } + +func AtomicAddInt64(addr *int64, delta int64) (new int64) { return atomic.AddInt64(addr, delta) } + +func AtomicAddUint32(addr *uint32, delta uint32) (new uint32) { return atomic.AddUint32(addr, delta) } + +func AtomicAddUint64(addr *uint64, delta uint64) (new uint64) { return atomic.AddUint64(addr, delta) } + +func AtomicAddUintptr(addr *uintptr, delta uintptr) (new uintptr) { + return atomic.AddUintptr(addr, delta) + +} + +func AtomicLoadInt32(addr *int32) (val int32) { return atomic.LoadInt32(addr) } + +func AtomicLoadInt64(addr *int64) (val int64) { return atomic.LoadInt64(addr) } + +func AtomicLoadUint32(addr *uint32) (val uint32) { return atomic.LoadUint32(addr) } + +func AtomicLoadUint64(addr *uint64) (val uint64) { return atomic.LoadUint64(addr) } + +func AtomicLoadUintptr(addr *uintptr) (val uintptr) { return atomic.LoadUintptr(addr) } + +func AtomicStoreInt32(addr *int32, val int32) { atomic.StoreInt32(addr, val) } + +func AtomicStoreUint32(addr *uint32, val uint32) { atomic.StoreUint32(addr, val) } + +func AtomicStoreUint64(addr *uint64, val uint64) { atomic.StoreUint64(addr, val) } + +func AtomicStoreUintptr(addr *uintptr, val uintptr) { atomic.StoreUintptr(addr, val) } + +func AtomicStoreInt64(addr *int64, val int64) { atomic.StoreInt64(addr, val) } diff --git a/internal/libc/atomic64.go b/internal/libc/atomic64.go new file mode 100644 index 0000000..dc256e6 --- /dev/null +++ b/internal/libc/atomic64.go @@ -0,0 +1,16 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + mbits "math/bits" +) + +// static inline int a_ctz_l(unsigned long x) +func _a_ctz_l(tls *TLS, x ulong) int32 { + return int32(mbits.TrailingZeros64(x)) +} diff --git a/internal/libc/builtin.go b/internal/libc/builtin.go new file mode 100644 index 0000000..ca46c54 --- /dev/null +++ b/internal/libc/builtin.go @@ -0,0 +1,443 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "fmt" + "math" + mbits "math/bits" + "os" + "unsafe" + + "github.com/hanzoai/sqlite/internal/mathutil" +) + +func X__builtin_inff(tls *TLS) float32 { + return float32(math.Inf(1)) +} + +func X__builtin_nanf(tls *TLS, s uintptr) float32 { + return float32(math.NaN()) +} + +func X__builtin_printf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + return Xprintf(tls, fmt, va) +} + +func X__builtin_round(tls *TLS, x float64) (r float64) { + return Xround(tls, x) +} + +func X__builtin_lround(tls *TLS, x float64) (r long) { + return Xlround(tls, x) +} + +func X__builtin_roundf(tls *TLS, x float32) (r float32) { + return Xroundf(tls, x) +} + +func X__builtin_expect(t *TLS, exp, c long) long { + return exp +} + +func X__builtin_bzero(t *TLS, s uintptr, n Tsize_t) { + Xbzero(t, s, n) +} + +func X__builtin_abort(t *TLS) { + Xabort(t) +} + +func X__builtin_abs(t *TLS, j int32) int32 { + return Xabs(t, j) +} + +func X__builtin_ctz(t *TLS, n uint32) int32 { + return int32(mbits.TrailingZeros32(n)) +} + +func X__builtin_clz(t *TLS, n uint32) int32 { + return int32(mbits.LeadingZeros32(n)) +} + +func X__builtin_clzll(t *TLS, n uint64) int32 { + return int32(mbits.LeadingZeros64(n)) +} +func X__builtin_constant_p_impl() { panic(todo("internal error: should never be called")) } + +func X__builtin_copysign(t *TLS, x, y float64) float64 { + return Xcopysign(t, x, y) +} + +func X__builtin_copysignf(t *TLS, x, y float32) float32 { + return Xcopysignf(t, x, y) +} + +func X__builtin_copysignl(t *TLS, x, y float64) float64 { + return Xcopysign(t, x, y) +} + +func X__builtin_exit(t *TLS, status int32) { + Xexit(t, status) +} + +func X__builtin_fabs(t *TLS, x float64) float64 { + return Xfabs(t, x) +} + +func X__builtin_fabsf(t *TLS, x float32) float32 { + return Xfabsf(t, x) +} + +func X__builtin_fabsl(t *TLS, x float64) float64 { + return Xfabsl(t, x) +} + +func X__builtin_free(t *TLS, ptr uintptr) { + Xfree(t, ptr) +} + +func X__builtin_getentropy(t *TLS, buf uintptr, n Tsize_t) int32 { + return Xgetentropy(t, buf, n) +} + +func X__builtin_huge_val(t *TLS) float64 { + return math.Inf(1) +} + +func X__builtin_huge_valf(t *TLS) float32 { + return float32(math.Inf(1)) +} + +func X__builtin_inf(t *TLS) float64 { + return math.Inf(1) +} + +func X__builtin_infl(t *TLS) float64 { + return math.Inf(1) +} + +func X__builtin_malloc(t *TLS, size Tsize_t) uintptr { + return Xmalloc(t, size) +} + +func X__builtin_memcmp(t *TLS, s1, s2 uintptr, n Tsize_t) int32 { + return Xmemcmp(t, s1, s2, n) +} + +func X__builtin_nan(t *TLS, s uintptr) float64 { + return math.NaN() +} + +func X__builtin_nanl(t *TLS, s uintptr) float64 { + return math.NaN() +} + +func X__builtin_prefetch(t *TLS, addr, args uintptr) { +} + +func X__builtin_strchr(t *TLS, s uintptr, c int32) uintptr { + return Xstrchr(t, s, c) +} + +func X__builtin_strcmp(t *TLS, s1, s2 uintptr) int32 { + return Xstrcmp(t, s1, s2) +} + +func X__builtin_strcpy(t *TLS, dest, src uintptr) uintptr { + return Xstrcpy(t, dest, src) +} + +func X__builtin_strlen(t *TLS, s uintptr) Tsize_t { + return Xstrlen(t, s) +} + +func X__builtin_trap(t *TLS) { + Xabort(t) +} + +func X__builtin_popcount(t *TLS, x uint32) int32 { + return int32(mbits.OnesCount32(x)) +} + +// char * __builtin___strcpy_chk (char *dest, const char *src, size_t os); +func X__builtin___strcpy_chk(t *TLS, dest, src uintptr, os Tsize_t) uintptr { + return Xstrcpy(t, dest, src) +} + +func X__builtin_mmap(t *TLS, addr uintptr, length Tsize_t, prot, flags, fd int32, offset Toff_t) uintptr { + return Xmmap(t, addr, length, prot, flags, fd, offset) +} + +// uint16_t __builtin_bswap16 (uint32_t x) +func X__builtin_bswap16(t *TLS, x uint16) uint16 { + return x<<8 | + x>>8 +} + +// uint32_t __builtin_bswap32 (uint32_t x) +func X__builtin_bswap32(t *TLS, x uint32) uint32 { + return x<<24 | + x&0xff00<<8 | + x&0xff0000>>8 | + x>>24 +} + +// uint64_t __builtin_bswap64 (uint64_t x) +func X__builtin_bswap64(t *TLS, x uint64) uint64 { + return x<<56 | + x&0xff00<<40 | + x&0xff0000<<24 | + x&0xff000000<<8 | + x&0xff00000000>>8 | + x&0xff0000000000>>24 | + x&0xff000000000000>>40 | + x>>56 +} + +// bool __builtin_add_overflow (type1 a, type2 b, type3 *res) +func X__builtin_add_overflowInt64(t *TLS, a, b int64, res uintptr) int32 { + r, ovf := mathutil.AddOverflowInt64(a, b) + *(*int64)(unsafe.Pointer(res)) = r + return Bool32(ovf) +} + +// bool __builtin_add_overflow (type1 a, type2 b, type3 *res) +func X__builtin_add_overflowUint32(t *TLS, a, b uint32, res uintptr) int32 { + r := a + b + *(*uint32)(unsafe.Pointer(res)) = r + return Bool32(r < a) +} + +// bool __builtin_add_overflow (type1 a, type2 b, type3 *res) +func X__builtin_add_overflowUint64(t *TLS, a, b uint64, res uintptr) int32 { + r := a + b + *(*uint64)(unsafe.Pointer(res)) = r + return Bool32(r < a) +} + +// bool __builtin_sub_overflow (type1 a, type2 b, type3 *res) +func X__builtin_sub_overflowInt64(t *TLS, a, b int64, res uintptr) int32 { + r, ovf := mathutil.SubOverflowInt64(a, b) + *(*int64)(unsafe.Pointer(res)) = r + return Bool32(ovf) +} + +// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res) +func X__builtin_mul_overflowInt64(t *TLS, a, b int64, res uintptr) int32 { + r, ovf := mathutil.MulOverflowInt64(a, b) + *(*int64)(unsafe.Pointer(res)) = r + return Bool32(ovf) +} + +// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res) +func X__builtin_mul_overflowUint64(t *TLS, a, b uint64, res uintptr) int32 { + hi, lo := mbits.Mul64(a, b) + *(*uint64)(unsafe.Pointer(res)) = lo + return Bool32(hi != 0) +} + +// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res) +func X__builtin_mul_overflowUint128(t *TLS, a, b Uint128, res uintptr) int32 { + r, ovf := a.mulOvf(b) + *(*Uint128)(unsafe.Pointer(res)) = r + return Bool32(ovf) +} + +func X__builtin_unreachable(t *TLS) { + fmt.Fprintf(os.Stderr, "unrechable\n") + os.Stderr.Sync() + Xexit(t, 1) +} + +func X__builtin_snprintf(t *TLS, str uintptr, size Tsize_t, format, args uintptr) int32 { + return Xsnprintf(t, str, size, format, args) +} + +func X__builtin_sprintf(t *TLS, str, format, args uintptr) (r int32) { + return Xsprintf(t, str, format, args) +} + +func X__builtin_memcpy(t *TLS, dest, src uintptr, n Tsize_t) (r uintptr) { + return Xmemcpy(t, dest, src, n) +} + +// void * __builtin___memcpy_chk (void *dest, const void *src, size_t n, size_t os); +func X__builtin___memcpy_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (r uintptr) { + if os != ^Tsize_t(0) && n < os { + Xabort(t) + } + + return Xmemcpy(t, dest, src, n) +} + +func X__builtin_memset(t *TLS, s uintptr, c int32, n Tsize_t) uintptr { + return Xmemset(t, s, c, n) +} + +// void * __builtin___memset_chk (void *s, int c, size_t n, size_t os); +func X__builtin___memset_chk(t *TLS, s uintptr, c int32, n, os Tsize_t) uintptr { + if os < n { + Xabort(t) + } + + return Xmemset(t, s, c, n) +} + +// size_t __builtin_object_size (const void * ptr, int type) +func X__builtin_object_size(t *TLS, p uintptr, typ int32) Tsize_t { + switch typ { + case 0, 1: + return ^Tsize_t(0) + default: + return 0 + } +} + +// int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...); +func X__builtin___sprintf_chk(t *TLS, s uintptr, flag int32, os Tsize_t, format, args uintptr) (r int32) { + return Xsprintf(t, s, format, args) +} + +func X__builtin_vsnprintf(t *TLS, str uintptr, size Tsize_t, format, va uintptr) int32 { + return Xvsnprintf(t, str, size, format, va) +} + +// int __builtin___snprintf_chk(char * str, size_t maxlen, int flag, size_t os, const char * format, ...); +func X__builtin___snprintf_chk(t *TLS, str uintptr, maxlen Tsize_t, flag int32, os Tsize_t, format, args uintptr) (r int32) { + if os != ^Tsize_t(0) && maxlen > os { + Xabort(t) + } + + return Xsnprintf(t, str, maxlen, format, args) +} + +// int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os, const char *fmt, va_list ap); +func X__builtin___vsnprintf_chk(t *TLS, str uintptr, maxlen Tsize_t, flag int32, os Tsize_t, format, args uintptr) (r int32) { + if os != ^Tsize_t(0) && maxlen > os { + Xabort(t) + } + + return Xsnprintf(t, str, maxlen, format, args) +} + +func Xisnan(t *TLS, x float64) int32 { + return X__builtin_isnan(t, x) +} + +func X__isnan(t *TLS, x float64) int32 { + return X__builtin_isnan(t, x) +} + +func X__builtin_isnan(t *TLS, x float64) int32 { + return Bool32(math.IsNaN(x)) +} + +func Xisnanf(t *TLS, arg float32) int32 { + return X__builtin_isnanf(t, arg) +} + +func X__isnanf(t *TLS, arg float32) int32 { + return X__builtin_isnanf(t, arg) +} + +func X__builtin_isnanf(t *TLS, x float32) int32 { + return Bool32(math.IsNaN(float64(x))) +} + +func Xisnanl(t *TLS, arg float64) int32 { + return X__builtin_isnanl(t, arg) +} + +func X__isnanl(t *TLS, arg float64) int32 { + return X__builtin_isnanl(t, arg) +} + +func X__builtin_isnanl(t *TLS, x float64) int32 { + return Bool32(math.IsNaN(x)) +} + +func X__builtin_llabs(tls *TLS, a int64) int64 { + return Xllabs(tls, a) +} + +func X__builtin_log2(t *TLS, x float64) float64 { + return Xlog2(t, x) +} + +func X__builtin___strncpy_chk(t *TLS, dest, src uintptr, n, os Tsize_t) (r uintptr) { + if n != ^Tsize_t(0) && os < n { + Xabort(t) + } + + return Xstrncpy(t, dest, src, n) +} + +func X__builtin___strcat_chk(t *TLS, dest, src uintptr, os Tsize_t) (r uintptr) { + return Xstrcat(t, dest, src) +} + +func X__builtin___memmove_chk(t *TLS, dest, src uintptr, n, os Tsize_t) uintptr { + if os != ^Tsize_t(0) && os < n { + Xabort(t) + } + + return Xmemmove(t, dest, src, n) +} + +func X__builtin_isunordered(t *TLS, a, b float64) int32 { + return Bool32(math.IsNaN(a) || math.IsNaN(b)) +} + +func X__builtin_ffs(tls *TLS, i int32) (r int32) { + return Xffs(tls, i) +} + +func X__builtin_rintf(tls *TLS, x float32) (r float32) { + return Xrintf(tls, x) +} + +func X__builtin_lrintf(tls *TLS, x float32) (r long) { + return Xlrintf(tls, x) +} + +func X__builtin_lrint(tls *TLS, x float64) (r long) { + return Xlrint(tls, x) +} + +// double __builtin_fma(double x, double y, double z); +func X__builtin_fma(tls *TLS, x, y, z float64) (r float64) { + return math.FMA(x, y, z) +} + +func X__builtin_alloca(tls *TLS, size Tsize_t) uintptr { + return Xalloca(tls, size) +} + +func X__builtin_isprint(tls *TLS, c int32) (r int32) { + return Xisprint(tls, c) +} + +func X__builtin_isblank(tls *TLS, c int32) (r int32) { + return Xisblank(tls, c) +} + +func X__builtin_trunc(tls *TLS, x float64) (r float64) { + return Xtrunc(tls, x) +} + +func X__builtin_hypot(tls *TLS, x float64, y float64) (r float64) { + return Xhypot(tls, x, y) +} + +func X__builtin_fmax(tls *TLS, x float64, y float64) (r float64) { + return Xfmax(tls, x, y) +} + +func X__builtin_fmin(tls *TLS, x float64, y float64) (r float64) { + return Xfmin(tls, x, y) +} diff --git a/internal/libc/builtin64.go b/internal/libc/builtin64.go new file mode 100644 index 0000000..4edd5af --- /dev/null +++ b/internal/libc/builtin64.go @@ -0,0 +1,29 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + mbits "math/bits" +) + +func X__builtin_ctzl(tls *TLS, x ulong) int32 { + return int32(mbits.TrailingZeros64(x)) +} + +func X__builtin_clzl(t *TLS, n ulong) int32 { + return int32(mbits.LeadingZeros64(n)) +} + +// int __builtin_popcountl (unsigned long x) +func X__builtin_popcountl(t *TLS, x ulong) int32 { + return int32(mbits.OnesCount64(x)) +} + +// int __builtin_popcountll (unsigned long long) +func X__builtin_popcountll(t *TLS, x uint64) int32 { + return int32(mbits.OnesCount64(x)) +} diff --git a/internal/libc/builtin_all.go b/internal/libc/builtin_all.go new file mode 100644 index 0000000..a240018 --- /dev/null +++ b/internal/libc/builtin_all.go @@ -0,0 +1,13 @@ +// Copyright 2026 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + mbits "math/bits" +) + +func X__builtin_ctzll(tls *TLS, x uint64) int32 { + return int32(mbits.TrailingZeros64(x)) +} diff --git a/internal/libc/capi_darwin_amd64.go b/internal/libc/capi_darwin_amd64.go new file mode 100644 index 0000000..75e35eb --- /dev/null +++ b/internal/libc/capi_darwin_amd64.go @@ -0,0 +1,540 @@ +// Code generated by 'go generate' - DO NOT EDIT. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +var CAPI = map[string]struct{}{ + "_CurrentRuneLocale": {}, + "_DefaultRuneLocale": {}, + "_IO_putc": {}, + "_NSGetEnviron": {}, + "___errno_location": {}, + "__assert_fail": {}, + "__assert_rtn": {}, + "__builtin___memcpy_chk": {}, + "__builtin___memmove_chk": {}, + "__builtin___memset_chk": {}, + "__builtin___snprintf_chk": {}, + "__builtin___sprintf_chk": {}, + "__builtin___strcat_chk": {}, + "__builtin___strcpy_chk": {}, + "__builtin___strncpy_chk": {}, + "__builtin___vsnprintf_chk": {}, + "__builtin_abort": {}, + "__builtin_abs": {}, + "__builtin_add_overflowInt64": {}, + "__builtin_add_overflowUint32": {}, + "__builtin_add_overflowUint64": {}, + "__builtin_bswap16": {}, + "__builtin_bswap32": {}, + "__builtin_bswap64": {}, + "__builtin_bzero": {}, + "__builtin_clz": {}, + "__builtin_clzl": {}, + "__builtin_clzll": {}, + "__builtin_constant_p_impl": {}, + "__builtin_copysign": {}, + "__builtin_copysignf": {}, + "__builtin_copysignl": {}, + "__builtin_exit": {}, + "__builtin_expect": {}, + "__builtin_fabs": {}, + "__builtin_fabsf": {}, + "__builtin_fabsl": {}, + "__builtin_free": {}, + "__builtin_getentropy": {}, + "__builtin_huge_val": {}, + "__builtin_huge_valf": {}, + "__builtin_inf": {}, + "__builtin_inff": {}, + "__builtin_infl": {}, + "__builtin_isnan": {}, + "__builtin_isunordered": {}, + "__builtin_llabs": {}, + "__builtin_malloc": {}, + "__builtin_memcmp": {}, + "__builtin_memcpy": {}, + "__builtin_memset": {}, + "__builtin_mmap": {}, + "__builtin_mul_overflowInt64": {}, + "__builtin_mul_overflowUint128": {}, + "__builtin_mul_overflowUint64": {}, + "__builtin_nan": {}, + "__builtin_nanf": {}, + "__builtin_nanl": {}, + "__builtin_object_size": {}, + "__builtin_popcount": {}, + "__builtin_popcountl": {}, + "__builtin_prefetch": {}, + "__builtin_printf": {}, + "__builtin_snprintf": {}, + "__builtin_sprintf": {}, + "__builtin_strchr": {}, + "__builtin_strcmp": {}, + "__builtin_strcpy": {}, + "__builtin_strlen": {}, + "__builtin_sub_overflowInt64": {}, + "__builtin_trap": {}, + "__builtin_unreachable": {}, + "__ccgo_dmesg": {}, + "__ccgo_getMutexType": {}, + "__ccgo_in6addr_anyp": {}, + "__ccgo_pthreadAttrGetDetachState": {}, + "__ccgo_pthreadMutexattrGettype": {}, + "__ccgo_sqlite3_log": {}, + "__cmsg_nxthdr": {}, + "__ctype_get_mb_cur_max": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, + "__env_rm_add": {}, + "__errno_location": {}, + "__error": {}, + "__floatscan": {}, + "__fpclassify": {}, + "__fpclassifyf": {}, + "__fpclassifyl": {}, + "__h_errno_location": {}, + "__inet_aton": {}, + "__inline_isnand": {}, + "__inline_isnanf": {}, + "__inline_isnanl": {}, + "__intscan": {}, + "__isctype": {}, + "__isnan": {}, + "__isnanf": {}, + "__isnanl": {}, + "__isoc99_sscanf": {}, + "__istype": {}, + "__lookup_ipliteral": {}, + "__lookup_name": {}, + "__lookup_serv": {}, + "__maskrune": {}, + "__mb_cur_max": {}, + "__putenv": {}, + "__shgetc": {}, + "__shlim": {}, + "__sincos_stret": {}, + "__sincosf_stret": {}, + "__sincospi_stret": {}, + "__sincospif_stret": {}, + "__srget": {}, + "__stderrp": {}, + "__stdinp": {}, + "__stdoutp": {}, + "__strchrnul": {}, + "__strncasecmp_l": {}, + "__svfscanf": {}, + "__swbuf": {}, + "__sync_add_and_fetch_uint32": {}, + "__sync_sub_and_fetch_uint32": {}, + "__tolower": {}, + "__toread": {}, + "__toread_needs_stdio_exit": {}, + "__toupper": {}, + "__uflow": {}, + "__wcwidth": {}, + "_exit": {}, + "_longjmp": {}, + "_obstack_begin": {}, + "_obstack_newchunk": {}, + "_setjmp": {}, + "abort": {}, + "abs": {}, + "accept": {}, + "access": {}, + "acos": {}, + "acosh": {}, + "alarm": {}, + "arc4random_buf": {}, + "asin": {}, + "asinh": {}, + "atan": {}, + "atan2": {}, + "atanh": {}, + "atexit": {}, + "atof": {}, + "atoi": {}, + "atol": {}, + "bind": {}, + "bsearch": {}, + "bzero": {}, + "calloc": {}, + "ceil": {}, + "ceilf": {}, + "cfgetospeed": {}, + "cfsetispeed": {}, + "cfsetospeed": {}, + "chdir": {}, + "chflags": {}, + "chmod": {}, + "chown": {}, + "clock": {}, + "clock_gettime": {}, + "close": {}, + "closedir": {}, + "confstr": {}, + "connect": {}, + "copyfile": {}, + "copysign": {}, + "copysignf": {}, + "copysignl": {}, + "cos": {}, + "cosf": {}, + "cosh": {}, + "ctime": {}, + "ctime_r": {}, + "digittoint": {}, + "dlclose": {}, + "dlerror": {}, + "dlopen": {}, + "dlsym": {}, + "dup2": {}, + "endpwent": {}, + "environ": {}, + "exit": {}, + "exp": {}, + "fabs": {}, + "fabsf": {}, + "fabsl": {}, + "fchmod": {}, + "fchown": {}, + "fclose": {}, + "fcntl": {}, + "fcntl64": {}, + "fdopen": {}, + "ferror": {}, + "fflush": {}, + "fgetc": {}, + "fgets": {}, + "fileno": {}, + "flock": {}, + "floor": {}, + "fmod": {}, + "fmodl": {}, + "fopen": {}, + "fopen64": {}, + "fork": {}, + "fprintf": {}, + "fputc": {}, + "fputs": {}, + "fread": {}, + "free": {}, + "freeaddrinfo": {}, + "frexp": {}, + "fsctl": {}, + "fseek": {}, + "fstat": {}, + "fstat64": {}, + "fstatfs": {}, + "fsync": {}, + "ftell": {}, + "ftruncate": {}, + "fts_close": {}, + "fts_open": {}, + "fts_read": {}, + "futimes": {}, + "fwrite": {}, + "gai_strerror": {}, + "getaddrinfo": {}, + "getattrlist": {}, + "getc": {}, + "getcwd": {}, + "getegid": {}, + "getentropy": {}, + "getenv": {}, + "geteuid": {}, + "getgid": {}, + "getgrgid": {}, + "getgrgid_r": {}, + "getgrnam": {}, + "getgrnam_r": {}, + "gethostbyaddr": {}, + "gethostbyaddr_r": {}, + "gethostbyname": {}, + "gethostbyname2": {}, + "gethostbyname2_r": {}, + "gethostname": {}, + "gethostuuid": {}, + "getnameinfo": {}, + "getpeername": {}, + "getpid": {}, + "getprogname": {}, + "getpwnam": {}, + "getpwnam_r": {}, + "getpwuid": {}, + "getpwuid_r": {}, + "getresgid": {}, + "getresuid": {}, + "getrusage": {}, + "getservbyname": {}, + "getsockname": {}, + "getsockopt": {}, + "gettimeofday": {}, + "getuid": {}, + "gmtime_r": {}, + "h_errno": {}, + "htonl": {}, + "htons": {}, + "hypot": {}, + "inet_ntoa": {}, + "inet_ntop": {}, + "inet_pton": {}, + "initstate": {}, + "initstate_r": {}, + "ioctl": {}, + "isalnum": {}, + "isalpha": {}, + "isascii": {}, + "isatty": {}, + "isblank": {}, + "iscntrl": {}, + "isdigit": {}, + "isgraph": {}, + "ishexnumber": {}, + "isideogram": {}, + "islower": {}, + "isnan": {}, + "isnanf": {}, + "isnanl": {}, + "isnumber": {}, + "isphonogram": {}, + "isprint": {}, + "ispunct": {}, + "isrune": {}, + "issetugid": {}, + "isspace": {}, + "isspecial": {}, + "isupper": {}, + "iswalnum": {}, + "iswspace": {}, + "isxdigit": {}, + "kill": {}, + "ldexp": {}, + "link": {}, + "listen": {}, + "llabs": {}, + "localeconv": {}, + "localtime": {}, + "localtime_r": {}, + "log": {}, + "log10": {}, + "log2": {}, + "longjmp": {}, + "lrand48": {}, + "lseek": {}, + "lseek64": {}, + "lstat": {}, + "lstat64": {}, + "mach_absolute_time": {}, + "mach_timebase_info": {}, + "malloc": {}, + "mblen": {}, + "mbstowcs": {}, + "mbtowc": {}, + "memchr": {}, + "memcmp": {}, + "memcpy": {}, + "memmove": {}, + "memset": {}, + "mkdir": {}, + "mkfifo": {}, + "mknod": {}, + "mkostemp": {}, + "mkstemp": {}, + "mkstemp64": {}, + "mkstemps": {}, + "mkstemps64": {}, + "mktime": {}, + "mmap": {}, + "modf": {}, + "munmap": {}, + "nanf": {}, + "nl_langinfo": {}, + "ntohs": {}, + "obstack_free": {}, + "obstack_vprintf": {}, + "open": {}, + "opendir": {}, + "openpty": {}, + "pathconf": {}, + "pause": {}, + "pclose": {}, + "perror": {}, + "pipe": {}, + "poll": {}, + "popen": {}, + "posix_fadvise": {}, + "pow": {}, + "pread": {}, + "printf": {}, + "pselect": {}, + "pthread_attr_destroy": {}, + "pthread_attr_getdetachstate": {}, + "pthread_attr_init": {}, + "pthread_attr_setdetachstate": {}, + "pthread_attr_setscope": {}, + "pthread_attr_setstacksize": {}, + "pthread_cond_broadcast": {}, + "pthread_cond_destroy": {}, + "pthread_cond_init": {}, + "pthread_cond_signal": {}, + "pthread_cond_timedwait": {}, + "pthread_cond_wait": {}, + "pthread_create": {}, + "pthread_detach": {}, + "pthread_equal": {}, + "pthread_exit": {}, + "pthread_getspecific": {}, + "pthread_join": {}, + "pthread_key_create": {}, + "pthread_key_delete": {}, + "pthread_mutex_destroy": {}, + "pthread_mutex_init": {}, + "pthread_mutex_lock": {}, + "pthread_mutex_trylock": {}, + "pthread_mutex_unlock": {}, + "pthread_mutexattr_destroy": {}, + "pthread_mutexattr_init": {}, + "pthread_mutexattr_settype": {}, + "pthread_self": {}, + "pthread_setspecific": {}, + "putc": {}, + "putchar": {}, + "putenv": {}, + "puts": {}, + "pwrite": {}, + "qsort": {}, + "raise": {}, + "rand": {}, + "rand_r": {}, + "random": {}, + "random_r": {}, + "read": {}, + "readdir": {}, + "readlink": {}, + "readv": {}, + "realloc": {}, + "reallocarray": {}, + "realpath": {}, + "recv": {}, + "recvfrom": {}, + "recvmsg": {}, + "remove": {}, + "rename": {}, + "rewind": {}, + "rindex": {}, + "rint": {}, + "rmdir": {}, + "round": {}, + "scalbn": {}, + "scalbnl": {}, + "sched_yield": {}, + "select": {}, + "send": {}, + "sendmsg": {}, + "sendto": {}, + "setattrlist": {}, + "setbuf": {}, + "setenv": {}, + "setjmp": {}, + "setlocale": {}, + "setsid": {}, + "setsockopt": {}, + "setstate": {}, + "setvbuf": {}, + "shmat": {}, + "shmctl": {}, + "shmdt": {}, + "shutdown": {}, + "sigaction": {}, + "signal": {}, + "sin": {}, + "sinf": {}, + "sinh": {}, + "sleep": {}, + "snprintf": {}, + "socket": {}, + "sprintf": {}, + "sqrt": {}, + "srand48": {}, + "srandomdev": {}, + "sscanf": {}, + "stat": {}, + "stat64": {}, + "statfs": {}, + "stderr": {}, + "stdin": {}, + "stdout": {}, + "strcasecmp": {}, + "strcat": {}, + "strchr": {}, + "strcmp": {}, + "strcpy": {}, + "strcspn": {}, + "strdup": {}, + "strerror": {}, + "strerror_r": {}, + "strlcat": {}, + "strlcpy": {}, + "strlen": {}, + "strncasecmp": {}, + "strncat": {}, + "strncmp": {}, + "strncpy": {}, + "strnlen": {}, + "strpbrk": {}, + "strrchr": {}, + "strspn": {}, + "strstr": {}, + "strtod": {}, + "strtof": {}, + "strtoimax": {}, + "strtok": {}, + "strtol": {}, + "strtold": {}, + "strtoll": {}, + "strtoul": {}, + "strtoull": {}, + "strtoumax": {}, + "symlink": {}, + "sysconf": {}, + "system": {}, + "tan": {}, + "tanh": {}, + "tcgetattr": {}, + "tcsendbreak": {}, + "tcsetattr": {}, + "time": {}, + "tmpfile": {}, + "toascii": {}, + "tolower": {}, + "toupper": {}, + "trunc": {}, + "truncate": {}, + "tzset": {}, + "umask": {}, + "uname": {}, + "ungetc": {}, + "unlink": {}, + "unsetenv": {}, + "usleep": {}, + "utime": {}, + "utimes": {}, + "uuid_copy": {}, + "uuid_generate_random": {}, + "uuid_parse": {}, + "uuid_unparse": {}, + "vasprintf": {}, + "vfprintf": {}, + "vprintf": {}, + "vsnprintf": {}, + "vsprintf": {}, + "waitpid": {}, + "wcschr": {}, + "wctomb": {}, + "wcwidth": {}, + "write": {}, + "writev": {}, + "zero_struct_address": {}, +} diff --git a/internal/libc/capi_darwin_arm64.go b/internal/libc/capi_darwin_arm64.go new file mode 100644 index 0000000..75e35eb --- /dev/null +++ b/internal/libc/capi_darwin_arm64.go @@ -0,0 +1,540 @@ +// Code generated by 'go generate' - DO NOT EDIT. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +var CAPI = map[string]struct{}{ + "_CurrentRuneLocale": {}, + "_DefaultRuneLocale": {}, + "_IO_putc": {}, + "_NSGetEnviron": {}, + "___errno_location": {}, + "__assert_fail": {}, + "__assert_rtn": {}, + "__builtin___memcpy_chk": {}, + "__builtin___memmove_chk": {}, + "__builtin___memset_chk": {}, + "__builtin___snprintf_chk": {}, + "__builtin___sprintf_chk": {}, + "__builtin___strcat_chk": {}, + "__builtin___strcpy_chk": {}, + "__builtin___strncpy_chk": {}, + "__builtin___vsnprintf_chk": {}, + "__builtin_abort": {}, + "__builtin_abs": {}, + "__builtin_add_overflowInt64": {}, + "__builtin_add_overflowUint32": {}, + "__builtin_add_overflowUint64": {}, + "__builtin_bswap16": {}, + "__builtin_bswap32": {}, + "__builtin_bswap64": {}, + "__builtin_bzero": {}, + "__builtin_clz": {}, + "__builtin_clzl": {}, + "__builtin_clzll": {}, + "__builtin_constant_p_impl": {}, + "__builtin_copysign": {}, + "__builtin_copysignf": {}, + "__builtin_copysignl": {}, + "__builtin_exit": {}, + "__builtin_expect": {}, + "__builtin_fabs": {}, + "__builtin_fabsf": {}, + "__builtin_fabsl": {}, + "__builtin_free": {}, + "__builtin_getentropy": {}, + "__builtin_huge_val": {}, + "__builtin_huge_valf": {}, + "__builtin_inf": {}, + "__builtin_inff": {}, + "__builtin_infl": {}, + "__builtin_isnan": {}, + "__builtin_isunordered": {}, + "__builtin_llabs": {}, + "__builtin_malloc": {}, + "__builtin_memcmp": {}, + "__builtin_memcpy": {}, + "__builtin_memset": {}, + "__builtin_mmap": {}, + "__builtin_mul_overflowInt64": {}, + "__builtin_mul_overflowUint128": {}, + "__builtin_mul_overflowUint64": {}, + "__builtin_nan": {}, + "__builtin_nanf": {}, + "__builtin_nanl": {}, + "__builtin_object_size": {}, + "__builtin_popcount": {}, + "__builtin_popcountl": {}, + "__builtin_prefetch": {}, + "__builtin_printf": {}, + "__builtin_snprintf": {}, + "__builtin_sprintf": {}, + "__builtin_strchr": {}, + "__builtin_strcmp": {}, + "__builtin_strcpy": {}, + "__builtin_strlen": {}, + "__builtin_sub_overflowInt64": {}, + "__builtin_trap": {}, + "__builtin_unreachable": {}, + "__ccgo_dmesg": {}, + "__ccgo_getMutexType": {}, + "__ccgo_in6addr_anyp": {}, + "__ccgo_pthreadAttrGetDetachState": {}, + "__ccgo_pthreadMutexattrGettype": {}, + "__ccgo_sqlite3_log": {}, + "__cmsg_nxthdr": {}, + "__ctype_get_mb_cur_max": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, + "__env_rm_add": {}, + "__errno_location": {}, + "__error": {}, + "__floatscan": {}, + "__fpclassify": {}, + "__fpclassifyf": {}, + "__fpclassifyl": {}, + "__h_errno_location": {}, + "__inet_aton": {}, + "__inline_isnand": {}, + "__inline_isnanf": {}, + "__inline_isnanl": {}, + "__intscan": {}, + "__isctype": {}, + "__isnan": {}, + "__isnanf": {}, + "__isnanl": {}, + "__isoc99_sscanf": {}, + "__istype": {}, + "__lookup_ipliteral": {}, + "__lookup_name": {}, + "__lookup_serv": {}, + "__maskrune": {}, + "__mb_cur_max": {}, + "__putenv": {}, + "__shgetc": {}, + "__shlim": {}, + "__sincos_stret": {}, + "__sincosf_stret": {}, + "__sincospi_stret": {}, + "__sincospif_stret": {}, + "__srget": {}, + "__stderrp": {}, + "__stdinp": {}, + "__stdoutp": {}, + "__strchrnul": {}, + "__strncasecmp_l": {}, + "__svfscanf": {}, + "__swbuf": {}, + "__sync_add_and_fetch_uint32": {}, + "__sync_sub_and_fetch_uint32": {}, + "__tolower": {}, + "__toread": {}, + "__toread_needs_stdio_exit": {}, + "__toupper": {}, + "__uflow": {}, + "__wcwidth": {}, + "_exit": {}, + "_longjmp": {}, + "_obstack_begin": {}, + "_obstack_newchunk": {}, + "_setjmp": {}, + "abort": {}, + "abs": {}, + "accept": {}, + "access": {}, + "acos": {}, + "acosh": {}, + "alarm": {}, + "arc4random_buf": {}, + "asin": {}, + "asinh": {}, + "atan": {}, + "atan2": {}, + "atanh": {}, + "atexit": {}, + "atof": {}, + "atoi": {}, + "atol": {}, + "bind": {}, + "bsearch": {}, + "bzero": {}, + "calloc": {}, + "ceil": {}, + "ceilf": {}, + "cfgetospeed": {}, + "cfsetispeed": {}, + "cfsetospeed": {}, + "chdir": {}, + "chflags": {}, + "chmod": {}, + "chown": {}, + "clock": {}, + "clock_gettime": {}, + "close": {}, + "closedir": {}, + "confstr": {}, + "connect": {}, + "copyfile": {}, + "copysign": {}, + "copysignf": {}, + "copysignl": {}, + "cos": {}, + "cosf": {}, + "cosh": {}, + "ctime": {}, + "ctime_r": {}, + "digittoint": {}, + "dlclose": {}, + "dlerror": {}, + "dlopen": {}, + "dlsym": {}, + "dup2": {}, + "endpwent": {}, + "environ": {}, + "exit": {}, + "exp": {}, + "fabs": {}, + "fabsf": {}, + "fabsl": {}, + "fchmod": {}, + "fchown": {}, + "fclose": {}, + "fcntl": {}, + "fcntl64": {}, + "fdopen": {}, + "ferror": {}, + "fflush": {}, + "fgetc": {}, + "fgets": {}, + "fileno": {}, + "flock": {}, + "floor": {}, + "fmod": {}, + "fmodl": {}, + "fopen": {}, + "fopen64": {}, + "fork": {}, + "fprintf": {}, + "fputc": {}, + "fputs": {}, + "fread": {}, + "free": {}, + "freeaddrinfo": {}, + "frexp": {}, + "fsctl": {}, + "fseek": {}, + "fstat": {}, + "fstat64": {}, + "fstatfs": {}, + "fsync": {}, + "ftell": {}, + "ftruncate": {}, + "fts_close": {}, + "fts_open": {}, + "fts_read": {}, + "futimes": {}, + "fwrite": {}, + "gai_strerror": {}, + "getaddrinfo": {}, + "getattrlist": {}, + "getc": {}, + "getcwd": {}, + "getegid": {}, + "getentropy": {}, + "getenv": {}, + "geteuid": {}, + "getgid": {}, + "getgrgid": {}, + "getgrgid_r": {}, + "getgrnam": {}, + "getgrnam_r": {}, + "gethostbyaddr": {}, + "gethostbyaddr_r": {}, + "gethostbyname": {}, + "gethostbyname2": {}, + "gethostbyname2_r": {}, + "gethostname": {}, + "gethostuuid": {}, + "getnameinfo": {}, + "getpeername": {}, + "getpid": {}, + "getprogname": {}, + "getpwnam": {}, + "getpwnam_r": {}, + "getpwuid": {}, + "getpwuid_r": {}, + "getresgid": {}, + "getresuid": {}, + "getrusage": {}, + "getservbyname": {}, + "getsockname": {}, + "getsockopt": {}, + "gettimeofday": {}, + "getuid": {}, + "gmtime_r": {}, + "h_errno": {}, + "htonl": {}, + "htons": {}, + "hypot": {}, + "inet_ntoa": {}, + "inet_ntop": {}, + "inet_pton": {}, + "initstate": {}, + "initstate_r": {}, + "ioctl": {}, + "isalnum": {}, + "isalpha": {}, + "isascii": {}, + "isatty": {}, + "isblank": {}, + "iscntrl": {}, + "isdigit": {}, + "isgraph": {}, + "ishexnumber": {}, + "isideogram": {}, + "islower": {}, + "isnan": {}, + "isnanf": {}, + "isnanl": {}, + "isnumber": {}, + "isphonogram": {}, + "isprint": {}, + "ispunct": {}, + "isrune": {}, + "issetugid": {}, + "isspace": {}, + "isspecial": {}, + "isupper": {}, + "iswalnum": {}, + "iswspace": {}, + "isxdigit": {}, + "kill": {}, + "ldexp": {}, + "link": {}, + "listen": {}, + "llabs": {}, + "localeconv": {}, + "localtime": {}, + "localtime_r": {}, + "log": {}, + "log10": {}, + "log2": {}, + "longjmp": {}, + "lrand48": {}, + "lseek": {}, + "lseek64": {}, + "lstat": {}, + "lstat64": {}, + "mach_absolute_time": {}, + "mach_timebase_info": {}, + "malloc": {}, + "mblen": {}, + "mbstowcs": {}, + "mbtowc": {}, + "memchr": {}, + "memcmp": {}, + "memcpy": {}, + "memmove": {}, + "memset": {}, + "mkdir": {}, + "mkfifo": {}, + "mknod": {}, + "mkostemp": {}, + "mkstemp": {}, + "mkstemp64": {}, + "mkstemps": {}, + "mkstemps64": {}, + "mktime": {}, + "mmap": {}, + "modf": {}, + "munmap": {}, + "nanf": {}, + "nl_langinfo": {}, + "ntohs": {}, + "obstack_free": {}, + "obstack_vprintf": {}, + "open": {}, + "opendir": {}, + "openpty": {}, + "pathconf": {}, + "pause": {}, + "pclose": {}, + "perror": {}, + "pipe": {}, + "poll": {}, + "popen": {}, + "posix_fadvise": {}, + "pow": {}, + "pread": {}, + "printf": {}, + "pselect": {}, + "pthread_attr_destroy": {}, + "pthread_attr_getdetachstate": {}, + "pthread_attr_init": {}, + "pthread_attr_setdetachstate": {}, + "pthread_attr_setscope": {}, + "pthread_attr_setstacksize": {}, + "pthread_cond_broadcast": {}, + "pthread_cond_destroy": {}, + "pthread_cond_init": {}, + "pthread_cond_signal": {}, + "pthread_cond_timedwait": {}, + "pthread_cond_wait": {}, + "pthread_create": {}, + "pthread_detach": {}, + "pthread_equal": {}, + "pthread_exit": {}, + "pthread_getspecific": {}, + "pthread_join": {}, + "pthread_key_create": {}, + "pthread_key_delete": {}, + "pthread_mutex_destroy": {}, + "pthread_mutex_init": {}, + "pthread_mutex_lock": {}, + "pthread_mutex_trylock": {}, + "pthread_mutex_unlock": {}, + "pthread_mutexattr_destroy": {}, + "pthread_mutexattr_init": {}, + "pthread_mutexattr_settype": {}, + "pthread_self": {}, + "pthread_setspecific": {}, + "putc": {}, + "putchar": {}, + "putenv": {}, + "puts": {}, + "pwrite": {}, + "qsort": {}, + "raise": {}, + "rand": {}, + "rand_r": {}, + "random": {}, + "random_r": {}, + "read": {}, + "readdir": {}, + "readlink": {}, + "readv": {}, + "realloc": {}, + "reallocarray": {}, + "realpath": {}, + "recv": {}, + "recvfrom": {}, + "recvmsg": {}, + "remove": {}, + "rename": {}, + "rewind": {}, + "rindex": {}, + "rint": {}, + "rmdir": {}, + "round": {}, + "scalbn": {}, + "scalbnl": {}, + "sched_yield": {}, + "select": {}, + "send": {}, + "sendmsg": {}, + "sendto": {}, + "setattrlist": {}, + "setbuf": {}, + "setenv": {}, + "setjmp": {}, + "setlocale": {}, + "setsid": {}, + "setsockopt": {}, + "setstate": {}, + "setvbuf": {}, + "shmat": {}, + "shmctl": {}, + "shmdt": {}, + "shutdown": {}, + "sigaction": {}, + "signal": {}, + "sin": {}, + "sinf": {}, + "sinh": {}, + "sleep": {}, + "snprintf": {}, + "socket": {}, + "sprintf": {}, + "sqrt": {}, + "srand48": {}, + "srandomdev": {}, + "sscanf": {}, + "stat": {}, + "stat64": {}, + "statfs": {}, + "stderr": {}, + "stdin": {}, + "stdout": {}, + "strcasecmp": {}, + "strcat": {}, + "strchr": {}, + "strcmp": {}, + "strcpy": {}, + "strcspn": {}, + "strdup": {}, + "strerror": {}, + "strerror_r": {}, + "strlcat": {}, + "strlcpy": {}, + "strlen": {}, + "strncasecmp": {}, + "strncat": {}, + "strncmp": {}, + "strncpy": {}, + "strnlen": {}, + "strpbrk": {}, + "strrchr": {}, + "strspn": {}, + "strstr": {}, + "strtod": {}, + "strtof": {}, + "strtoimax": {}, + "strtok": {}, + "strtol": {}, + "strtold": {}, + "strtoll": {}, + "strtoul": {}, + "strtoull": {}, + "strtoumax": {}, + "symlink": {}, + "sysconf": {}, + "system": {}, + "tan": {}, + "tanh": {}, + "tcgetattr": {}, + "tcsendbreak": {}, + "tcsetattr": {}, + "time": {}, + "tmpfile": {}, + "toascii": {}, + "tolower": {}, + "toupper": {}, + "trunc": {}, + "truncate": {}, + "tzset": {}, + "umask": {}, + "uname": {}, + "ungetc": {}, + "unlink": {}, + "unsetenv": {}, + "usleep": {}, + "utime": {}, + "utimes": {}, + "uuid_copy": {}, + "uuid_generate_random": {}, + "uuid_parse": {}, + "uuid_unparse": {}, + "vasprintf": {}, + "vfprintf": {}, + "vprintf": {}, + "vsnprintf": {}, + "vsprintf": {}, + "waitpid": {}, + "wcschr": {}, + "wctomb": {}, + "wcwidth": {}, + "write": {}, + "writev": {}, + "zero_struct_address": {}, +} diff --git a/internal/libc/capi_linux_amd64.go b/internal/libc/capi_linux_amd64.go new file mode 100644 index 0000000..d7b02ef --- /dev/null +++ b/internal/libc/capi_linux_amd64.go @@ -0,0 +1,528 @@ +// Code generated by 'go generate' - DO NOT EDIT. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +var CAPI = map[string]struct{}{ + "_IO_putc": {}, + "___errno_location": {}, + "__assert_fail": {}, + "__builtin___memcpy_chk": {}, + "__builtin___memmove_chk": {}, + "__builtin___memset_chk": {}, + "__builtin___snprintf_chk": {}, + "__builtin___sprintf_chk": {}, + "__builtin___strcat_chk": {}, + "__builtin___strcpy_chk": {}, + "__builtin___strncpy_chk": {}, + "__builtin___vsnprintf_chk": {}, + "__builtin_abort": {}, + "__builtin_abs": {}, + "__builtin_add_overflowInt64": {}, + "__builtin_add_overflowUint32": {}, + "__builtin_add_overflowUint64": {}, + "__builtin_bswap16": {}, + "__builtin_bswap32": {}, + "__builtin_bswap64": {}, + "__builtin_bzero": {}, + "__builtin_clz": {}, + "__builtin_clzl": {}, + "__builtin_clzll": {}, + "__builtin_constant_p_impl": {}, + "__builtin_copysign": {}, + "__builtin_copysignf": {}, + "__builtin_copysignl": {}, + "__builtin_exit": {}, + "__builtin_expect": {}, + "__builtin_fabs": {}, + "__builtin_fabsf": {}, + "__builtin_fabsl": {}, + "__builtin_free": {}, + "__builtin_getentropy": {}, + "__builtin_huge_val": {}, + "__builtin_huge_valf": {}, + "__builtin_inf": {}, + "__builtin_inff": {}, + "__builtin_infl": {}, + "__builtin_isnan": {}, + "__builtin_isunordered": {}, + "__builtin_llabs": {}, + "__builtin_malloc": {}, + "__builtin_memcmp": {}, + "__builtin_memcpy": {}, + "__builtin_memset": {}, + "__builtin_mmap": {}, + "__builtin_mul_overflowInt64": {}, + "__builtin_mul_overflowUint128": {}, + "__builtin_mul_overflowUint64": {}, + "__builtin_nan": {}, + "__builtin_nanf": {}, + "__builtin_nanl": {}, + "__builtin_object_size": {}, + "__builtin_popcount": {}, + "__builtin_popcountl": {}, + "__builtin_prefetch": {}, + "__builtin_printf": {}, + "__builtin_snprintf": {}, + "__builtin_sprintf": {}, + "__builtin_strchr": {}, + "__builtin_strcmp": {}, + "__builtin_strcpy": {}, + "__builtin_strlen": {}, + "__builtin_sub_overflowInt64": {}, + "__builtin_trap": {}, + "__builtin_unreachable": {}, + "__ccgo_dmesg": {}, + "__ccgo_getMutexType": {}, + "__ccgo_in6addr_anyp": {}, + "__ccgo_pthreadAttrGetDetachState": {}, + "__ccgo_pthreadMutexattrGettype": {}, + "__ccgo_sqlite3_log": {}, + "__cmsg_nxthdr": {}, + "__ctype_b_loc": {}, + "__ctype_get_mb_cur_max": {}, + "__errno_location": {}, + "__floatscan": {}, + "__fpclassify": {}, + "__fpclassifyf": {}, + "__fpclassifyl": {}, + "__fsmu8": {}, + "__h_errno_location": {}, + "__inet_aton": {}, + "__intscan": {}, + "__isalnum_l": {}, + "__isalpha_l": {}, + "__isdigit_l": {}, + "__islower_l": {}, + "__isnan": {}, + "__isnanf": {}, + "__isnanl": {}, + "__isoc99_sscanf": {}, + "__isprint_l": {}, + "__isupper_l": {}, + "__isxdigit_l": {}, + "__lockfile": {}, + "__lookup_ipliteral": {}, + "__lookup_name": {}, + "__lookup_serv": {}, + "__shgetc": {}, + "__shlim": {}, + "__strncasecmp_l": {}, + "__sync_add_and_fetch_uint32": {}, + "__sync_sub_and_fetch_uint32": {}, + "__syscall1": {}, + "__syscall3": {}, + "__syscall4": {}, + "__toread": {}, + "__toread_needs_stdio_exit": {}, + "__uflow": {}, + "__unlockfile": {}, + "_exit": {}, + "_longjmp": {}, + "_obstack_begin": {}, + "_obstack_newchunk": {}, + "_setjmp": {}, + "abort": {}, + "abs": {}, + "accept": {}, + "access": {}, + "acos": {}, + "acosh": {}, + "alarm": {}, + "asin": {}, + "asinh": {}, + "atan": {}, + "atan2": {}, + "atanh": {}, + "atexit": {}, + "atof": {}, + "atoi": {}, + "atol": {}, + "backtrace": {}, + "backtrace_symbols_fd": {}, + "bind": {}, + "bsearch": {}, + "bzero": {}, + "calloc": {}, + "ceil": {}, + "ceilf": {}, + "cfgetospeed": {}, + "cfsetispeed": {}, + "cfsetospeed": {}, + "chdir": {}, + "chmod": {}, + "chown": {}, + "clock_gettime": {}, + "close": {}, + "closedir": {}, + "confstr": {}, + "connect": {}, + "copysign": {}, + "copysignf": {}, + "copysignl": {}, + "cos": {}, + "cosf": {}, + "cosh": {}, + "ctime": {}, + "ctime_r": {}, + "dlclose": {}, + "dlerror": {}, + "dlopen": {}, + "dlsym": {}, + "dup2": {}, + "dup3": {}, + "endpwent": {}, + "environ": {}, + "execvp": {}, + "exit": {}, + "exp": {}, + "fabs": {}, + "fabsf": {}, + "fabsl": {}, + "faccessat": {}, + "fchmod": {}, + "fchmodat": {}, + "fchown": {}, + "fchownat": {}, + "fclose": {}, + "fcntl": {}, + "fcntl64": {}, + "fdopen": {}, + "ferror": {}, + "fflush": {}, + "fgetc": {}, + "fgets": {}, + "fileno": {}, + "floor": {}, + "fmod": {}, + "fmodl": {}, + "fopen": {}, + "fopen64": {}, + "fork": {}, + "fprintf": {}, + "fputc": {}, + "fputs": {}, + "fread": {}, + "free": {}, + "freeaddrinfo": {}, + "frexp": {}, + "fscanf": {}, + "fseek": {}, + "fstat": {}, + "fstat64": {}, + "fstatfs": {}, + "fsync": {}, + "ftell": {}, + "ftruncate": {}, + "ftruncate64": {}, + "fts64_close": {}, + "fts64_open": {}, + "fts64_read": {}, + "fts_close": {}, + "fts_open": {}, + "fts_read": {}, + "fwrite": {}, + "gai_strerror": {}, + "getaddrinfo": {}, + "getc": {}, + "getcwd": {}, + "getegid": {}, + "getentropy": {}, + "getenv": {}, + "geteuid": {}, + "getgid": {}, + "getgrgid": {}, + "getgrgid_r": {}, + "getgrnam": {}, + "getgrnam_r": {}, + "gethostbyaddr": {}, + "gethostbyaddr_r": {}, + "gethostbyname": {}, + "gethostbyname2": {}, + "gethostbyname2_r": {}, + "gethostbyname_r": {}, + "gethostname": {}, + "getnameinfo": {}, + "getpeername": {}, + "getpid": {}, + "getpwnam": {}, + "getpwnam_r": {}, + "getpwuid": {}, + "getpwuid_r": {}, + "getrandom": {}, + "getresgid": {}, + "getresuid": {}, + "getrlimit": {}, + "getrlimit64": {}, + "getrusage": {}, + "getservbyname": {}, + "getsockname": {}, + "getsockopt": {}, + "gettimeofday": {}, + "getuid": {}, + "gmtime_r": {}, + "h_errno": {}, + "htonl": {}, + "htons": {}, + "hypot": {}, + "inet_ntoa": {}, + "inet_ntop": {}, + "inet_pton": {}, + "initstate": {}, + "initstate_r": {}, + "ioctl": {}, + "isalnum": {}, + "isalpha": {}, + "isascii": {}, + "isatty": {}, + "isdigit": {}, + "islower": {}, + "isnan": {}, + "isnanf": {}, + "isnanl": {}, + "isprint": {}, + "isupper": {}, + "iswalnum": {}, + "iswspace": {}, + "isxdigit": {}, + "kill": {}, + "ldexp": {}, + "link": {}, + "linkat": {}, + "listen": {}, + "llabs": {}, + "localeconv": {}, + "localtime": {}, + "localtime_r": {}, + "log": {}, + "log10": {}, + "log2": {}, + "longjmp": {}, + "lrand48": {}, + "lseek": {}, + "lseek64": {}, + "lstat": {}, + "lstat64": {}, + "malloc": {}, + "mblen": {}, + "mbrtowc": {}, + "mbsinit": {}, + "mbstowcs": {}, + "mbtowc": {}, + "memchr": {}, + "memcmp": {}, + "memcpy": {}, + "memmove": {}, + "memset": {}, + "mkdir": {}, + "mkdirat": {}, + "mkfifo": {}, + "mknod": {}, + "mknodat": {}, + "mkostemp": {}, + "mkstemp": {}, + "mkstemp64": {}, + "mkstemps": {}, + "mkstemps64": {}, + "mktime": {}, + "mmap": {}, + "mmap64": {}, + "modf": {}, + "mremap": {}, + "munmap": {}, + "nanf": {}, + "nanosleep": {}, + "nl_langinfo": {}, + "ntohs": {}, + "obstack_free": {}, + "obstack_vprintf": {}, + "open": {}, + "open64": {}, + "openat": {}, + "opendir": {}, + "openpty": {}, + "pathconf": {}, + "pause": {}, + "pclose": {}, + "perror": {}, + "pipe": {}, + "pipe2": {}, + "poll": {}, + "popen": {}, + "posix_fadvise": {}, + "pow": {}, + "pread": {}, + "printf": {}, + "pselect": {}, + "pthread_attr_destroy": {}, + "pthread_attr_getdetachstate": {}, + "pthread_attr_init": {}, + "pthread_attr_setdetachstate": {}, + "pthread_attr_setscope": {}, + "pthread_attr_setstacksize": {}, + "pthread_cond_broadcast": {}, + "pthread_cond_destroy": {}, + "pthread_cond_init": {}, + "pthread_cond_signal": {}, + "pthread_cond_timedwait": {}, + "pthread_cond_wait": {}, + "pthread_create": {}, + "pthread_detach": {}, + "pthread_equal": {}, + "pthread_exit": {}, + "pthread_getspecific": {}, + "pthread_join": {}, + "pthread_key_create": {}, + "pthread_key_delete": {}, + "pthread_mutex_destroy": {}, + "pthread_mutex_init": {}, + "pthread_mutex_lock": {}, + "pthread_mutex_trylock": {}, + "pthread_mutex_unlock": {}, + "pthread_mutexattr_destroy": {}, + "pthread_mutexattr_init": {}, + "pthread_mutexattr_settype": {}, + "pthread_self": {}, + "pthread_setspecific": {}, + "putc": {}, + "putchar": {}, + "puts": {}, + "pwrite": {}, + "qsort": {}, + "raise": {}, + "rand": {}, + "rand_r": {}, + "random": {}, + "random_r": {}, + "read": {}, + "readdir": {}, + "readdir64": {}, + "readlink": {}, + "readlinkat": {}, + "readv": {}, + "realloc": {}, + "reallocarray": {}, + "realpath": {}, + "recv": {}, + "recvfrom": {}, + "recvmsg": {}, + "remove": {}, + "rename": {}, + "renameat2": {}, + "rewind": {}, + "rindex": {}, + "rint": {}, + "rmdir": {}, + "round": {}, + "scalbn": {}, + "scalbnl": {}, + "sched_yield": {}, + "select": {}, + "send": {}, + "sendmsg": {}, + "sendto": {}, + "setbuf": {}, + "setenv": {}, + "setjmp": {}, + "setlocale": {}, + "setrlimit": {}, + "setrlimit64": {}, + "setsid": {}, + "setsockopt": {}, + "setstate": {}, + "setvbuf": {}, + "shmat": {}, + "shmctl": {}, + "shmdt": {}, + "shutdown": {}, + "sigaction": {}, + "signal": {}, + "sin": {}, + "sinf": {}, + "sinh": {}, + "sleep": {}, + "snprintf": {}, + "socket": {}, + "sprintf": {}, + "sqrt": {}, + "srand48": {}, + "sscanf": {}, + "stat": {}, + "stat64": {}, + "stderr": {}, + "stdin": {}, + "stdout": {}, + "strcasecmp": {}, + "strcat": {}, + "strchr": {}, + "strcmp": {}, + "strcpy": {}, + "strcspn": {}, + "strdup": {}, + "strerror": {}, + "strerror_r": {}, + "strlcat": {}, + "strlcpy": {}, + "strlen": {}, + "strncasecmp": {}, + "strncat": {}, + "strncmp": {}, + "strncpy": {}, + "strnlen": {}, + "strpbrk": {}, + "strrchr": {}, + "strspn": {}, + "strstr": {}, + "strtod": {}, + "strtof": {}, + "strtoimax": {}, + "strtok": {}, + "strtol": {}, + "strtold": {}, + "strtoll": {}, + "strtoul": {}, + "strtoull": {}, + "strtoumax": {}, + "symlink": {}, + "symlinkat": {}, + "sysconf": {}, + "system": {}, + "tan": {}, + "tanh": {}, + "tcgetattr": {}, + "tcsendbreak": {}, + "tcsetattr": {}, + "time": {}, + "tmpfile": {}, + "tolower": {}, + "toupper": {}, + "trunc": {}, + "tzset": {}, + "umask": {}, + "uname": {}, + "ungetc": {}, + "unlink": {}, + "unlinkat": {}, + "unsetenv": {}, + "usleep": {}, + "utime": {}, + "utimensat": {}, + "utimes": {}, + "uuid_copy": {}, + "uuid_generate_random": {}, + "uuid_parse": {}, + "uuid_unparse": {}, + "vasprintf": {}, + "vfprintf": {}, + "vfscanf": {}, + "vprintf": {}, + "vsnprintf": {}, + "vsprintf": {}, + "vsscanf": {}, + "waitpid": {}, + "wcschr": {}, + "wctomb": {}, + "wcwidth": {}, + "write": {}, + "writev": {}, + "zero_struct_address": {}, +} diff --git a/internal/libc/capi_linux_arm64.go b/internal/libc/capi_linux_arm64.go new file mode 100644 index 0000000..fe7639e --- /dev/null +++ b/internal/libc/capi_linux_arm64.go @@ -0,0 +1,512 @@ +// Code generated by 'go generate' - DO NOT EDIT. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +var CAPI = map[string]struct{}{ + "_IO_putc": {}, + "___errno_location": {}, + "__assert_fail": {}, + "__builtin___memcpy_chk": {}, + "__builtin___memmove_chk": {}, + "__builtin___memset_chk": {}, + "__builtin___snprintf_chk": {}, + "__builtin___sprintf_chk": {}, + "__builtin___strcat_chk": {}, + "__builtin___strcpy_chk": {}, + "__builtin___strncpy_chk": {}, + "__builtin___vsnprintf_chk": {}, + "__builtin_abort": {}, + "__builtin_abs": {}, + "__builtin_add_overflowInt64": {}, + "__builtin_add_overflowUint32": {}, + "__builtin_add_overflowUint64": {}, + "__builtin_bswap16": {}, + "__builtin_bswap32": {}, + "__builtin_bswap64": {}, + "__builtin_bzero": {}, + "__builtin_clz": {}, + "__builtin_clzl": {}, + "__builtin_clzll": {}, + "__builtin_constant_p_impl": {}, + "__builtin_copysign": {}, + "__builtin_copysignf": {}, + "__builtin_copysignl": {}, + "__builtin_exit": {}, + "__builtin_expect": {}, + "__builtin_fabs": {}, + "__builtin_fabsf": {}, + "__builtin_fabsl": {}, + "__builtin_free": {}, + "__builtin_getentropy": {}, + "__builtin_huge_val": {}, + "__builtin_huge_valf": {}, + "__builtin_inf": {}, + "__builtin_inff": {}, + "__builtin_infl": {}, + "__builtin_isnan": {}, + "__builtin_isunordered": {}, + "__builtin_llabs": {}, + "__builtin_malloc": {}, + "__builtin_memcmp": {}, + "__builtin_memcpy": {}, + "__builtin_memset": {}, + "__builtin_mmap": {}, + "__builtin_mul_overflowInt64": {}, + "__builtin_mul_overflowUint128": {}, + "__builtin_mul_overflowUint64": {}, + "__builtin_nan": {}, + "__builtin_nanf": {}, + "__builtin_nanl": {}, + "__builtin_object_size": {}, + "__builtin_popcount": {}, + "__builtin_popcountl": {}, + "__builtin_prefetch": {}, + "__builtin_printf": {}, + "__builtin_snprintf": {}, + "__builtin_sprintf": {}, + "__builtin_strchr": {}, + "__builtin_strcmp": {}, + "__builtin_strcpy": {}, + "__builtin_strlen": {}, + "__builtin_sub_overflowInt64": {}, + "__builtin_trap": {}, + "__builtin_unreachable": {}, + "__ccgo_dmesg": {}, + "__ccgo_getMutexType": {}, + "__ccgo_in6addr_anyp": {}, + "__ccgo_pthreadAttrGetDetachState": {}, + "__ccgo_pthreadMutexattrGettype": {}, + "__ccgo_sqlite3_log": {}, + "__cmsg_nxthdr": {}, + "__ctype_b_loc": {}, + "__ctype_get_mb_cur_max": {}, + "__errno_location": {}, + "__floatscan": {}, + "__fpclassify": {}, + "__fpclassifyf": {}, + "__fpclassifyl": {}, + "__fsmu8": {}, + "__h_errno_location": {}, + "__inet_aton": {}, + "__intscan": {}, + "__isalnum_l": {}, + "__isalpha_l": {}, + "__isdigit_l": {}, + "__islower_l": {}, + "__isnan": {}, + "__isnanf": {}, + "__isnanl": {}, + "__isoc99_sscanf": {}, + "__isprint_l": {}, + "__isupper_l": {}, + "__isxdigit_l": {}, + "__lockfile": {}, + "__lookup_ipliteral": {}, + "__lookup_name": {}, + "__lookup_serv": {}, + "__shgetc": {}, + "__shlim": {}, + "__strncasecmp_l": {}, + "__sync_add_and_fetch_uint32": {}, + "__sync_sub_and_fetch_uint32": {}, + "__syscall1": {}, + "__syscall3": {}, + "__syscall4": {}, + "__toread": {}, + "__toread_needs_stdio_exit": {}, + "__uflow": {}, + "__unlockfile": {}, + "_exit": {}, + "_longjmp": {}, + "_obstack_begin": {}, + "_obstack_newchunk": {}, + "_setjmp": {}, + "abort": {}, + "abs": {}, + "accept": {}, + "access": {}, + "acos": {}, + "acosh": {}, + "alarm": {}, + "asin": {}, + "asinh": {}, + "atan": {}, + "atan2": {}, + "atanh": {}, + "atexit": {}, + "atof": {}, + "atoi": {}, + "atol": {}, + "backtrace": {}, + "backtrace_symbols_fd": {}, + "bind": {}, + "bsearch": {}, + "bzero": {}, + "calloc": {}, + "ceil": {}, + "ceilf": {}, + "cfgetospeed": {}, + "cfsetispeed": {}, + "cfsetospeed": {}, + "chdir": {}, + "chmod": {}, + "chown": {}, + "clock_gettime": {}, + "close": {}, + "closedir": {}, + "confstr": {}, + "connect": {}, + "copysign": {}, + "copysignf": {}, + "copysignl": {}, + "cos": {}, + "cosf": {}, + "cosh": {}, + "ctime": {}, + "ctime_r": {}, + "dlclose": {}, + "dlerror": {}, + "dlopen": {}, + "dlsym": {}, + "dup2": {}, + "endpwent": {}, + "environ": {}, + "execvp": {}, + "exit": {}, + "exp": {}, + "fabs": {}, + "fabsf": {}, + "fabsl": {}, + "fchmod": {}, + "fchown": {}, + "fclose": {}, + "fcntl": {}, + "fcntl64": {}, + "fdopen": {}, + "ferror": {}, + "fflush": {}, + "fgetc": {}, + "fgets": {}, + "fileno": {}, + "floor": {}, + "fmod": {}, + "fmodl": {}, + "fopen": {}, + "fopen64": {}, + "fork": {}, + "fprintf": {}, + "fputc": {}, + "fputs": {}, + "fread": {}, + "free": {}, + "freeaddrinfo": {}, + "frexp": {}, + "fscanf": {}, + "fseek": {}, + "fstat": {}, + "fstat64": {}, + "fstatfs": {}, + "fsync": {}, + "ftell": {}, + "ftruncate": {}, + "ftruncate64": {}, + "fts64_close": {}, + "fts64_open": {}, + "fts64_read": {}, + "fts_close": {}, + "fts_open": {}, + "fts_read": {}, + "fwrite": {}, + "gai_strerror": {}, + "getaddrinfo": {}, + "getc": {}, + "getcwd": {}, + "getegid": {}, + "getentropy": {}, + "getenv": {}, + "geteuid": {}, + "getgid": {}, + "getgrgid": {}, + "getgrgid_r": {}, + "getgrnam": {}, + "getgrnam_r": {}, + "gethostbyaddr": {}, + "gethostbyaddr_r": {}, + "gethostbyname": {}, + "gethostbyname2": {}, + "gethostbyname2_r": {}, + "gethostbyname_r": {}, + "gethostname": {}, + "getnameinfo": {}, + "getpeername": {}, + "getpid": {}, + "getpwnam": {}, + "getpwnam_r": {}, + "getpwuid": {}, + "getpwuid_r": {}, + "getrandom": {}, + "getresgid": {}, + "getresuid": {}, + "getrlimit": {}, + "getrlimit64": {}, + "getrusage": {}, + "getservbyname": {}, + "getsockname": {}, + "getsockopt": {}, + "gettimeofday": {}, + "getuid": {}, + "gmtime_r": {}, + "h_errno": {}, + "htonl": {}, + "htons": {}, + "hypot": {}, + "inet_ntoa": {}, + "inet_ntop": {}, + "inet_pton": {}, + "initstate": {}, + "initstate_r": {}, + "ioctl": {}, + "isalnum": {}, + "isalpha": {}, + "isascii": {}, + "isatty": {}, + "isdigit": {}, + "islower": {}, + "isnan": {}, + "isnanf": {}, + "isnanl": {}, + "isprint": {}, + "isupper": {}, + "isxdigit": {}, + "kill": {}, + "ldexp": {}, + "link": {}, + "listen": {}, + "llabs": {}, + "localeconv": {}, + "localtime": {}, + "localtime_r": {}, + "log": {}, + "log10": {}, + "log2": {}, + "longjmp": {}, + "lrand48": {}, + "lseek": {}, + "lseek64": {}, + "lstat": {}, + "lstat64": {}, + "malloc": {}, + "mblen": {}, + "mbrtowc": {}, + "mbsinit": {}, + "mbstowcs": {}, + "mbtowc": {}, + "memchr": {}, + "memcmp": {}, + "memcpy": {}, + "memmove": {}, + "memset": {}, + "mkdir": {}, + "mkfifo": {}, + "mknod": {}, + "mkostemp": {}, + "mkstemp": {}, + "mkstemp64": {}, + "mkstemps": {}, + "mkstemps64": {}, + "mktime": {}, + "mmap": {}, + "mmap64": {}, + "modf": {}, + "mremap": {}, + "munmap": {}, + "nanf": {}, + "nanosleep": {}, + "nl_langinfo": {}, + "ntohs": {}, + "obstack_free": {}, + "obstack_vprintf": {}, + "open": {}, + "open64": {}, + "opendir": {}, + "openpty": {}, + "pathconf": {}, + "pause": {}, + "pclose": {}, + "perror": {}, + "pipe": {}, + "poll": {}, + "popen": {}, + "posix_fadvise": {}, + "pow": {}, + "pread": {}, + "printf": {}, + "pselect": {}, + "pthread_attr_destroy": {}, + "pthread_attr_getdetachstate": {}, + "pthread_attr_init": {}, + "pthread_attr_setdetachstate": {}, + "pthread_attr_setscope": {}, + "pthread_attr_setstacksize": {}, + "pthread_cond_broadcast": {}, + "pthread_cond_destroy": {}, + "pthread_cond_init": {}, + "pthread_cond_signal": {}, + "pthread_cond_timedwait": {}, + "pthread_cond_wait": {}, + "pthread_create": {}, + "pthread_detach": {}, + "pthread_equal": {}, + "pthread_exit": {}, + "pthread_getspecific": {}, + "pthread_join": {}, + "pthread_key_create": {}, + "pthread_key_delete": {}, + "pthread_mutex_destroy": {}, + "pthread_mutex_init": {}, + "pthread_mutex_lock": {}, + "pthread_mutex_trylock": {}, + "pthread_mutex_unlock": {}, + "pthread_mutexattr_destroy": {}, + "pthread_mutexattr_init": {}, + "pthread_mutexattr_settype": {}, + "pthread_self": {}, + "pthread_setspecific": {}, + "putc": {}, + "putchar": {}, + "puts": {}, + "pwrite": {}, + "qsort": {}, + "raise": {}, + "rand": {}, + "rand_r": {}, + "random": {}, + "random_r": {}, + "read": {}, + "readdir": {}, + "readdir64": {}, + "readlink": {}, + "readv": {}, + "realloc": {}, + "reallocarray": {}, + "realpath": {}, + "recv": {}, + "recvfrom": {}, + "recvmsg": {}, + "remove": {}, + "rename": {}, + "rewind": {}, + "rindex": {}, + "rint": {}, + "rmdir": {}, + "round": {}, + "scalbn": {}, + "scalbnl": {}, + "sched_yield": {}, + "select": {}, + "send": {}, + "sendmsg": {}, + "sendto": {}, + "setbuf": {}, + "setenv": {}, + "setjmp": {}, + "setlocale": {}, + "setrlimit": {}, + "setrlimit64": {}, + "setsid": {}, + "setsockopt": {}, + "setstate": {}, + "setvbuf": {}, + "shmat": {}, + "shmctl": {}, + "shmdt": {}, + "shutdown": {}, + "sigaction": {}, + "signal": {}, + "sin": {}, + "sinf": {}, + "sinh": {}, + "sleep": {}, + "snprintf": {}, + "socket": {}, + "sprintf": {}, + "sqrt": {}, + "srand48": {}, + "sscanf": {}, + "stat": {}, + "stat64": {}, + "stderr": {}, + "stdin": {}, + "stdout": {}, + "strcasecmp": {}, + "strcat": {}, + "strchr": {}, + "strcmp": {}, + "strcpy": {}, + "strcspn": {}, + "strdup": {}, + "strerror": {}, + "strerror_r": {}, + "strlcat": {}, + "strlcpy": {}, + "strlen": {}, + "strncasecmp": {}, + "strncat": {}, + "strncmp": {}, + "strncpy": {}, + "strnlen": {}, + "strpbrk": {}, + "strrchr": {}, + "strspn": {}, + "strstr": {}, + "strtod": {}, + "strtof": {}, + "strtoimax": {}, + "strtok": {}, + "strtol": {}, + "strtold": {}, + "strtoll": {}, + "strtoul": {}, + "strtoull": {}, + "strtoumax": {}, + "symlink": {}, + "sysconf": {}, + "system": {}, + "tan": {}, + "tanh": {}, + "tcgetattr": {}, + "tcsendbreak": {}, + "tcsetattr": {}, + "time": {}, + "tmpfile": {}, + "tolower": {}, + "toupper": {}, + "trunc": {}, + "tzset": {}, + "umask": {}, + "uname": {}, + "ungetc": {}, + "unlink": {}, + "unsetenv": {}, + "usleep": {}, + "utime": {}, + "utimes": {}, + "uuid_copy": {}, + "uuid_generate_random": {}, + "uuid_parse": {}, + "uuid_unparse": {}, + "vasprintf": {}, + "vfprintf": {}, + "vfscanf": {}, + "vprintf": {}, + "vsnprintf": {}, + "vsprintf": {}, + "vsscanf": {}, + "waitpid": {}, + "wcschr": {}, + "wctomb": {}, + "wcwidth": {}, + "write": {}, + "writev": {}, + "zero_struct_address": {}, +} diff --git a/internal/libc/ccgo.go b/internal/libc/ccgo.go new file mode 100644 index 0000000..368651f --- /dev/null +++ b/internal/libc/ccgo.go @@ -0,0 +1,1892 @@ +// Code generated by 'go generate' - DO NOT EDIT. + +//go:build !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "sync/atomic" + "unsafe" +) + +func AtomicStoreNInt32(ptr uintptr, val int32, memorder int32) { + atomic.StoreInt32((*int32)(unsafe.Pointer(ptr)), val) +} + +func AtomicStoreNInt64(ptr uintptr, val int64, memorder int32) { + atomic.StoreInt64((*int64)(unsafe.Pointer(ptr)), val) +} + +func AtomicStoreNUint32(ptr uintptr, val uint32, memorder int32) { + atomic.StoreUint32((*uint32)(unsafe.Pointer(ptr)), val) +} + +func AtomicStoreNUint64(ptr uintptr, val uint64, memorder int32) { + atomic.StoreUint64((*uint64)(unsafe.Pointer(ptr)), val) +} + +func AtomicStoreNUintptr(ptr uintptr, val uintptr, memorder int32) { + atomic.StoreUintptr((*uintptr)(unsafe.Pointer(ptr)), val) +} + +func AtomicLoadNInt32(ptr uintptr, memorder int32) int32 { + return atomic.LoadInt32((*int32)(unsafe.Pointer(ptr))) +} + +func AtomicLoadNInt64(ptr uintptr, memorder int32) int64 { + return atomic.LoadInt64((*int64)(unsafe.Pointer(ptr))) +} + +func AtomicLoadNUint32(ptr uintptr, memorder int32) uint32 { + return atomic.LoadUint32((*uint32)(unsafe.Pointer(ptr))) +} + +func AtomicLoadNUint64(ptr uintptr, memorder int32) uint64 { + return atomic.LoadUint64((*uint64)(unsafe.Pointer(ptr))) +} + +func AtomicLoadNUintptr(ptr uintptr, memorder int32) uintptr { + return atomic.LoadUintptr((*uintptr)(unsafe.Pointer(ptr))) +} +func AssignInt8(p *int8, v int8) int8 { *p = v; return v } +func AssignInt16(p *int16, v int16) int16 { *p = v; return v } +func AssignInt32(p *int32, v int32) int32 { *p = v; return v } +func AssignInt64(p *int64, v int64) int64 { *p = v; return v } +func AssignUint8(p *uint8, v uint8) uint8 { *p = v; return v } +func AssignUint16(p *uint16, v uint16) uint16 { *p = v; return v } +func AssignUint32(p *uint32, v uint32) uint32 { *p = v; return v } +func AssignUint64(p *uint64, v uint64) uint64 { *p = v; return v } +func AssignFloat32(p *float32, v float32) float32 { *p = v; return v } +func AssignFloat64(p *float64, v float64) float64 { *p = v; return v } +func AssignComplex64(p *complex64, v complex64) complex64 { *p = v; return v } +func AssignComplex128(p *complex128, v complex128) complex128 { *p = v; return v } +func AssignUintptr(p *uintptr, v uintptr) uintptr { *p = v; return v } + +func AssignPtrInt8(p uintptr, v int8) int8 { *(*int8)(unsafe.Pointer(p)) = v; return v } +func AssignPtrInt16(p uintptr, v int16) int16 { *(*int16)(unsafe.Pointer(p)) = v; return v } +func AssignPtrInt32(p uintptr, v int32) int32 { *(*int32)(unsafe.Pointer(p)) = v; return v } +func AssignPtrInt64(p uintptr, v int64) int64 { *(*int64)(unsafe.Pointer(p)) = v; return v } +func AssignPtrUint8(p uintptr, v uint8) uint8 { *(*uint8)(unsafe.Pointer(p)) = v; return v } +func AssignPtrUint16(p uintptr, v uint16) uint16 { *(*uint16)(unsafe.Pointer(p)) = v; return v } +func AssignPtrUint32(p uintptr, v uint32) uint32 { *(*uint32)(unsafe.Pointer(p)) = v; return v } +func AssignPtrUint64(p uintptr, v uint64) uint64 { *(*uint64)(unsafe.Pointer(p)) = v; return v } +func AssignPtrFloat32(p uintptr, v float32) float32 { *(*float32)(unsafe.Pointer(p)) = v; return v } +func AssignPtrFloat64(p uintptr, v float64) float64 { *(*float64)(unsafe.Pointer(p)) = v; return v } +func AssignPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) = v + return v +} +func AssignPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) = v + return v +} +func AssignPtrUintptr(p uintptr, v uintptr) uintptr { *(*uintptr)(unsafe.Pointer(p)) = v; return v } + +func AssignMulInt8(p *int8, v int8) int8 { *p *= v; return *p } +func AssignMulInt16(p *int16, v int16) int16 { *p *= v; return *p } +func AssignMulInt32(p *int32, v int32) int32 { *p *= v; return *p } +func AssignMulInt64(p *int64, v int64) int64 { *p *= v; return *p } +func AssignMulUint8(p *uint8, v uint8) uint8 { *p *= v; return *p } +func AssignMulUint16(p *uint16, v uint16) uint16 { *p *= v; return *p } +func AssignMulUint32(p *uint32, v uint32) uint32 { *p *= v; return *p } +func AssignMulUint64(p *uint64, v uint64) uint64 { *p *= v; return *p } +func AssignMulFloat32(p *float32, v float32) float32 { *p *= v; return *p } +func AssignMulFloat64(p *float64, v float64) float64 { *p *= v; return *p } +func AssignMulComplex64(p *complex64, v complex64) complex64 { *p *= v; return *p } +func AssignMulComplex128(p *complex128, v complex128) complex128 { *p *= v; return *p } +func AssignMulUintptr(p *uintptr, v uintptr) uintptr { *p *= v; return *p } + +func AssignDivInt8(p *int8, v int8) int8 { *p /= v; return *p } +func AssignDivInt16(p *int16, v int16) int16 { *p /= v; return *p } +func AssignDivInt32(p *int32, v int32) int32 { *p /= v; return *p } +func AssignDivInt64(p *int64, v int64) int64 { *p /= v; return *p } +func AssignDivUint8(p *uint8, v uint8) uint8 { *p /= v; return *p } +func AssignDivUint16(p *uint16, v uint16) uint16 { *p /= v; return *p } +func AssignDivUint32(p *uint32, v uint32) uint32 { *p /= v; return *p } +func AssignDivUint64(p *uint64, v uint64) uint64 { *p /= v; return *p } +func AssignDivFloat32(p *float32, v float32) float32 { *p /= v; return *p } +func AssignDivFloat64(p *float64, v float64) float64 { *p /= v; return *p } +func AssignDivComplex64(p *complex64, v complex64) complex64 { *p /= v; return *p } +func AssignDivComplex128(p *complex128, v complex128) complex128 { *p /= v; return *p } +func AssignDivUintptr(p *uintptr, v uintptr) uintptr { *p /= v; return *p } + +func AssignRemInt8(p *int8, v int8) int8 { *p %= v; return *p } +func AssignRemInt16(p *int16, v int16) int16 { *p %= v; return *p } +func AssignRemInt32(p *int32, v int32) int32 { *p %= v; return *p } +func AssignRemInt64(p *int64, v int64) int64 { *p %= v; return *p } +func AssignRemUint8(p *uint8, v uint8) uint8 { *p %= v; return *p } +func AssignRemUint16(p *uint16, v uint16) uint16 { *p %= v; return *p } +func AssignRemUint32(p *uint32, v uint32) uint32 { *p %= v; return *p } +func AssignRemUint64(p *uint64, v uint64) uint64 { *p %= v; return *p } +func AssignRemUintptr(p *uintptr, v uintptr) uintptr { *p %= v; return *p } + +func AssignAddInt8(p *int8, v int8) int8 { *p += v; return *p } +func AssignAddInt16(p *int16, v int16) int16 { *p += v; return *p } +func AssignAddInt32(p *int32, v int32) int32 { *p += v; return *p } +func AssignAddInt64(p *int64, v int64) int64 { *p += v; return *p } +func AssignAddUint8(p *uint8, v uint8) uint8 { *p += v; return *p } +func AssignAddUint16(p *uint16, v uint16) uint16 { *p += v; return *p } +func AssignAddUint32(p *uint32, v uint32) uint32 { *p += v; return *p } +func AssignAddUint64(p *uint64, v uint64) uint64 { *p += v; return *p } +func AssignAddFloat32(p *float32, v float32) float32 { *p += v; return *p } +func AssignAddFloat64(p *float64, v float64) float64 { *p += v; return *p } +func AssignAddComplex64(p *complex64, v complex64) complex64 { *p += v; return *p } +func AssignAddComplex128(p *complex128, v complex128) complex128 { *p += v; return *p } +func AssignAddUintptr(p *uintptr, v uintptr) uintptr { *p += v; return *p } + +func AssignSubInt8(p *int8, v int8) int8 { *p -= v; return *p } +func AssignSubInt16(p *int16, v int16) int16 { *p -= v; return *p } +func AssignSubInt32(p *int32, v int32) int32 { *p -= v; return *p } +func AssignSubInt64(p *int64, v int64) int64 { *p -= v; return *p } +func AssignSubUint8(p *uint8, v uint8) uint8 { *p -= v; return *p } +func AssignSubUint16(p *uint16, v uint16) uint16 { *p -= v; return *p } +func AssignSubUint32(p *uint32, v uint32) uint32 { *p -= v; return *p } +func AssignSubUint64(p *uint64, v uint64) uint64 { *p -= v; return *p } +func AssignSubFloat32(p *float32, v float32) float32 { *p -= v; return *p } +func AssignSubFloat64(p *float64, v float64) float64 { *p -= v; return *p } +func AssignSubComplex64(p *complex64, v complex64) complex64 { *p -= v; return *p } +func AssignSubComplex128(p *complex128, v complex128) complex128 { *p -= v; return *p } +func AssignSubUintptr(p *uintptr, v uintptr) uintptr { *p -= v; return *p } + +func AssignAndInt8(p *int8, v int8) int8 { *p &= v; return *p } +func AssignAndInt16(p *int16, v int16) int16 { *p &= v; return *p } +func AssignAndInt32(p *int32, v int32) int32 { *p &= v; return *p } +func AssignAndInt64(p *int64, v int64) int64 { *p &= v; return *p } +func AssignAndUint8(p *uint8, v uint8) uint8 { *p &= v; return *p } +func AssignAndUint16(p *uint16, v uint16) uint16 { *p &= v; return *p } +func AssignAndUint32(p *uint32, v uint32) uint32 { *p &= v; return *p } +func AssignAndUint64(p *uint64, v uint64) uint64 { *p &= v; return *p } +func AssignAndUintptr(p *uintptr, v uintptr) uintptr { *p &= v; return *p } + +func AssignXorInt8(p *int8, v int8) int8 { *p ^= v; return *p } +func AssignXorInt16(p *int16, v int16) int16 { *p ^= v; return *p } +func AssignXorInt32(p *int32, v int32) int32 { *p ^= v; return *p } +func AssignXorInt64(p *int64, v int64) int64 { *p ^= v; return *p } +func AssignXorUint8(p *uint8, v uint8) uint8 { *p ^= v; return *p } +func AssignXorUint16(p *uint16, v uint16) uint16 { *p ^= v; return *p } +func AssignXorUint32(p *uint32, v uint32) uint32 { *p ^= v; return *p } +func AssignXorUint64(p *uint64, v uint64) uint64 { *p ^= v; return *p } +func AssignXorUintptr(p *uintptr, v uintptr) uintptr { *p ^= v; return *p } + +func AssignOrInt8(p *int8, v int8) int8 { *p |= v; return *p } +func AssignOrInt16(p *int16, v int16) int16 { *p |= v; return *p } +func AssignOrInt32(p *int32, v int32) int32 { *p |= v; return *p } +func AssignOrInt64(p *int64, v int64) int64 { *p |= v; return *p } +func AssignOrUint8(p *uint8, v uint8) uint8 { *p |= v; return *p } +func AssignOrUint16(p *uint16, v uint16) uint16 { *p |= v; return *p } +func AssignOrUint32(p *uint32, v uint32) uint32 { *p |= v; return *p } +func AssignOrUint64(p *uint64, v uint64) uint64 { *p |= v; return *p } +func AssignOrUintptr(p *uintptr, v uintptr) uintptr { *p |= v; return *p } + +func AssignMulPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) *= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignMulPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) *= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignMulPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) *= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignMulPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) *= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignMulPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) *= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignMulPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) *= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignMulPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) *= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignMulPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) *= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignMulPtrFloat32(p uintptr, v float32) float32 { + *(*float32)(unsafe.Pointer(p)) *= v + return *(*float32)(unsafe.Pointer(p)) +} + +func AssignMulPtrFloat64(p uintptr, v float64) float64 { + *(*float64)(unsafe.Pointer(p)) *= v + return *(*float64)(unsafe.Pointer(p)) +} + +func AssignMulPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) *= v + return *(*complex64)(unsafe.Pointer(p)) +} + +func AssignMulPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) *= v + return *(*complex128)(unsafe.Pointer(p)) +} + +func AssignMulPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) *= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignDivPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) /= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignDivPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) /= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignDivPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) /= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignDivPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) /= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignDivPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) /= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignDivPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) /= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignDivPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) /= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignDivPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) /= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignDivPtrFloat32(p uintptr, v float32) float32 { + *(*float32)(unsafe.Pointer(p)) /= v + return *(*float32)(unsafe.Pointer(p)) +} + +func AssignDivPtrFloat64(p uintptr, v float64) float64 { + *(*float64)(unsafe.Pointer(p)) /= v + return *(*float64)(unsafe.Pointer(p)) +} + +func AssignDivPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) /= v + return *(*complex64)(unsafe.Pointer(p)) +} + +func AssignDivPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) /= v + return *(*complex128)(unsafe.Pointer(p)) +} + +func AssignDivPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) /= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignRemPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) %= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignRemPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) %= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignRemPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) %= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignRemPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) %= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignRemPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) %= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignRemPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) %= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignRemPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) %= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignRemPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) %= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignRemPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) %= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignAddPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) += v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignAddPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) += v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignAddPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) += v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignAddPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) += v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignAddPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) += v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignAddPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) += v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignAddPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) += v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignAddPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) += v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignAddPtrFloat32(p uintptr, v float32) float32 { + *(*float32)(unsafe.Pointer(p)) += v + return *(*float32)(unsafe.Pointer(p)) +} + +func AssignAddPtrFloat64(p uintptr, v float64) float64 { + *(*float64)(unsafe.Pointer(p)) += v + return *(*float64)(unsafe.Pointer(p)) +} + +func AssignAddPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) += v + return *(*complex64)(unsafe.Pointer(p)) +} + +func AssignAddPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) += v + return *(*complex128)(unsafe.Pointer(p)) +} + +func AssignAddPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) += v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignSubPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) -= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignSubPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) -= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignSubPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) -= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignSubPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) -= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignSubPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) -= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignSubPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) -= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignSubPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) -= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignSubPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) -= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignSubPtrFloat32(p uintptr, v float32) float32 { + *(*float32)(unsafe.Pointer(p)) -= v + return *(*float32)(unsafe.Pointer(p)) +} + +func AssignSubPtrFloat64(p uintptr, v float64) float64 { + *(*float64)(unsafe.Pointer(p)) -= v + return *(*float64)(unsafe.Pointer(p)) +} + +func AssignSubPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) -= v + return *(*complex64)(unsafe.Pointer(p)) +} + +func AssignSubPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) -= v + return *(*complex128)(unsafe.Pointer(p)) +} + +func AssignSubPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) -= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignAndPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) &= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignAndPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) &= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignAndPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) &= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignAndPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) &= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignAndPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) &= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignAndPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) &= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignAndPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) &= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignAndPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) &= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignAndPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) &= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignXorPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) ^= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignXorPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) ^= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignXorPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) ^= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignXorPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) ^= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignXorPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) ^= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignXorPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) ^= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignXorPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) ^= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignXorPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) ^= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignXorPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) ^= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignOrPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) |= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignOrPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) |= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignOrPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) |= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignOrPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) |= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignOrPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) |= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignOrPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) |= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignOrPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) |= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignOrPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) |= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignOrPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) |= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignShlPtrInt8(p uintptr, v int) int8 { + *(*int8)(unsafe.Pointer(p)) <<= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignShlPtrInt16(p uintptr, v int) int16 { + *(*int16)(unsafe.Pointer(p)) <<= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignShlPtrInt32(p uintptr, v int) int32 { + *(*int32)(unsafe.Pointer(p)) <<= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignShlPtrInt64(p uintptr, v int) int64 { + *(*int64)(unsafe.Pointer(p)) <<= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignShlPtrUint8(p uintptr, v int) uint8 { + *(*uint8)(unsafe.Pointer(p)) <<= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignShlPtrUint16(p uintptr, v int) uint16 { + *(*uint16)(unsafe.Pointer(p)) <<= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignShlPtrUint32(p uintptr, v int) uint32 { + *(*uint32)(unsafe.Pointer(p)) <<= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignShlPtrUint64(p uintptr, v int) uint64 { + *(*uint64)(unsafe.Pointer(p)) <<= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignShlPtrUintptr(p uintptr, v int) uintptr { + *(*uintptr)(unsafe.Pointer(p)) <<= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignShrPtrInt8(p uintptr, v int) int8 { + *(*int8)(unsafe.Pointer(p)) >>= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignShrPtrInt16(p uintptr, v int) int16 { + *(*int16)(unsafe.Pointer(p)) >>= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignShrPtrInt32(p uintptr, v int) int32 { + *(*int32)(unsafe.Pointer(p)) >>= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignShrPtrInt64(p uintptr, v int) int64 { + *(*int64)(unsafe.Pointer(p)) >>= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignShrPtrUint8(p uintptr, v int) uint8 { + *(*uint8)(unsafe.Pointer(p)) >>= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignShrPtrUint16(p uintptr, v int) uint16 { + *(*uint16)(unsafe.Pointer(p)) >>= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignShrPtrUint32(p uintptr, v int) uint32 { + *(*uint32)(unsafe.Pointer(p)) >>= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignShrPtrUint64(p uintptr, v int) uint64 { + *(*uint64)(unsafe.Pointer(p)) >>= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignShrPtrUintptr(p uintptr, v int) uintptr { + *(*uintptr)(unsafe.Pointer(p)) >>= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignShlInt8(p *int8, v int) int8 { *p <<= v; return *p } + +func AssignShlInt16(p *int16, v int) int16 { *p <<= v; return *p } + +func AssignShlInt32(p *int32, v int) int32 { *p <<= v; return *p } + +func AssignShlInt64(p *int64, v int) int64 { *p <<= v; return *p } + +func AssignShlUint8(p *uint8, v int) uint8 { *p <<= v; return *p } + +func AssignShlUint16(p *uint16, v int) uint16 { *p <<= v; return *p } + +func AssignShlUint32(p *uint32, v int) uint32 { *p <<= v; return *p } + +func AssignShlUint64(p *uint64, v int) uint64 { *p <<= v; return *p } + +func AssignShlUintptr(p *uintptr, v int) uintptr { *p <<= v; return *p } + +func AssignShrInt8(p *int8, v int) int8 { *p >>= v; return *p } + +func AssignShrInt16(p *int16, v int) int16 { *p >>= v; return *p } + +func AssignShrInt32(p *int32, v int) int32 { *p >>= v; return *p } + +func AssignShrInt64(p *int64, v int) int64 { *p >>= v; return *p } + +func AssignShrUint8(p *uint8, v int) uint8 { *p >>= v; return *p } + +func AssignShrUint16(p *uint16, v int) uint16 { *p >>= v; return *p } + +func AssignShrUint32(p *uint32, v int) uint32 { *p >>= v; return *p } + +func AssignShrUint64(p *uint64, v int) uint64 { *p >>= v; return *p } + +func AssignShrUintptr(p *uintptr, v int) uintptr { *p >>= v; return *p } + +func PreIncInt8(p *int8, d int8) int8 { *p += d; return *p } +func PreIncInt16(p *int16, d int16) int16 { *p += d; return *p } +func PreIncInt32(p *int32, d int32) int32 { *p += d; return *p } +func PreIncInt64(p *int64, d int64) int64 { *p += d; return *p } +func PreIncUint8(p *uint8, d uint8) uint8 { *p += d; return *p } +func PreIncUint16(p *uint16, d uint16) uint16 { *p += d; return *p } +func PreIncUint32(p *uint32, d uint32) uint32 { *p += d; return *p } +func PreIncUint64(p *uint64, d uint64) uint64 { *p += d; return *p } +func PreIncFloat32(p *float32, d float32) float32 { *p += d; return *p } +func PreIncFloat64(p *float64, d float64) float64 { *p += d; return *p } +func PreIncComplex64(p *complex64, d complex64) complex64 { *p += d; return *p } +func PreIncComplex128(p *complex128, d complex128) complex128 { *p += d; return *p } +func PreIncUintptr(p *uintptr, d uintptr) uintptr { *p += d; return *p } + +func PreIncAtomicInt32(p *int32, d int32) int32 { return atomic.AddInt32(p, d) } +func PreIncAtomicInt64(p *int64, d int64) int64 { return atomic.AddInt64(p, d) } +func PreIncAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint32(p, d) } +func PreIncAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, d) } +func PreIncAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, d) } + +func PreDecInt8(p *int8, d int8) int8 { *p -= d; return *p } +func PreDecInt16(p *int16, d int16) int16 { *p -= d; return *p } +func PreDecInt32(p *int32, d int32) int32 { *p -= d; return *p } +func PreDecInt64(p *int64, d int64) int64 { *p -= d; return *p } +func PreDecUint8(p *uint8, d uint8) uint8 { *p -= d; return *p } +func PreDecUint16(p *uint16, d uint16) uint16 { *p -= d; return *p } +func PreDecUint32(p *uint32, d uint32) uint32 { *p -= d; return *p } +func PreDecUint64(p *uint64, d uint64) uint64 { *p -= d; return *p } +func PreDecFloat32(p *float32, d float32) float32 { *p -= d; return *p } +func PreDecFloat64(p *float64, d float64) float64 { *p -= d; return *p } +func PreDecComplex64(p *complex64, d complex64) complex64 { *p -= d; return *p } +func PreDecComplex128(p *complex128, d complex128) complex128 { *p -= d; return *p } +func PreDecUintptr(p *uintptr, d uintptr) uintptr { *p -= d; return *p } + +func PreDecAtomicInt32(p *int32, d int32) int32 { return atomic.AddInt32(p, -d) } +func PreDecAtomicInt64(p *int64, d int64) int64 { return atomic.AddInt64(p, -d) } +func PreDecAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint32(p, -d) } +func PreDecAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, -d) } +func PreDecAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, -d) } + +func PostIncInt8(p *int8, d int8) int8 { r := *p; *p += d; return r } +func PostIncInt16(p *int16, d int16) int16 { r := *p; *p += d; return r } +func PostIncInt32(p *int32, d int32) int32 { r := *p; *p += d; return r } +func PostIncInt64(p *int64, d int64) int64 { r := *p; *p += d; return r } +func PostIncUint8(p *uint8, d uint8) uint8 { r := *p; *p += d; return r } +func PostIncUint16(p *uint16, d uint16) uint16 { r := *p; *p += d; return r } +func PostIncUint32(p *uint32, d uint32) uint32 { r := *p; *p += d; return r } +func PostIncUint64(p *uint64, d uint64) uint64 { r := *p; *p += d; return r } +func PostIncFloat32(p *float32, d float32) float32 { r := *p; *p += d; return r } +func PostIncFloat64(p *float64, d float64) float64 { r := *p; *p += d; return r } +func PostIncComplex64(p *complex64, d complex64) complex64 { r := *p; *p += d; return r } +func PostIncComplex128(p *complex128, d complex128) complex128 { r := *p; *p += d; return r } +func PostIncUintptr(p *uintptr, d uintptr) uintptr { r := *p; *p += d; return r } + +func PostIncAtomicInt32(p *int32, d int32) int32 { return atomic.AddInt32(p, d) - d } +func PostIncAtomicInt64(p *int64, d int64) int64 { return atomic.AddInt64(p, d) - d } +func PostIncAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint32(p, d) - d } +func PostIncAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, d) - d } +func PostIncAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, d) - d } + +func PostIncAtomicInt32P(p uintptr, d int32) int32 { + return atomic.AddInt32((*int32)(unsafe.Pointer(p)), d) - d +} +func PostIncAtomicInt64P(p uintptr, d int64) int64 { + return atomic.AddInt64((*int64)(unsafe.Pointer(p)), d) - d +} +func PostIncAtomicUint32P(p uintptr, d uint32) uint32 { + return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), d) - d +} +func PostIncAtomicUint64P(p uintptr, d uint64) uint64 { + return atomic.AddUint64((*uint64)(unsafe.Pointer(p)), d) - d +} +func PostIncAtomicUintptrP(p uintptr, d uintptr) uintptr { + return atomic.AddUintptr((*uintptr)(unsafe.Pointer(p)), d) - d +} + +func PostDecInt8(p *int8, d int8) int8 { r := *p; *p -= d; return r } +func PostDecInt16(p *int16, d int16) int16 { r := *p; *p -= d; return r } +func PostDecInt32(p *int32, d int32) int32 { r := *p; *p -= d; return r } +func PostDecInt64(p *int64, d int64) int64 { r := *p; *p -= d; return r } +func PostDecUint8(p *uint8, d uint8) uint8 { r := *p; *p -= d; return r } +func PostDecUint16(p *uint16, d uint16) uint16 { r := *p; *p -= d; return r } +func PostDecUint32(p *uint32, d uint32) uint32 { r := *p; *p -= d; return r } +func PostDecUint64(p *uint64, d uint64) uint64 { r := *p; *p -= d; return r } +func PostDecFloat32(p *float32, d float32) float32 { r := *p; *p -= d; return r } +func PostDecFloat64(p *float64, d float64) float64 { r := *p; *p -= d; return r } +func PostDecComplex64(p *complex64, d complex64) complex64 { r := *p; *p -= d; return r } +func PostDecComplex128(p *complex128, d complex128) complex128 { r := *p; *p -= d; return r } +func PostDecUintptr(p *uintptr, d uintptr) uintptr { r := *p; *p -= d; return r } + +func PostDecAtomicInt32(p *int32, d int32) int32 { return atomic.AddInt32(p, -d) + d } +func PostDecAtomicInt64(p *int64, d int64) int64 { return atomic.AddInt64(p, -d) + d } +func PostDecAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint32(p, -d) + d } +func PostDecAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, -d) + d } +func PostDecAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, -d) + d } + +func Int8FromInt8(n int8) int8 { return int8(n) } +func Int8FromInt16(n int16) int8 { return int8(n) } +func Int8FromInt32(n int32) int8 { return int8(n) } +func Int8FromInt64(n int64) int8 { return int8(n) } +func Int8FromUint8(n uint8) int8 { return int8(n) } +func Int8FromUint16(n uint16) int8 { return int8(n) } +func Int8FromUint32(n uint32) int8 { return int8(n) } +func Int8FromUint64(n uint64) int8 { return int8(n) } +func Int8FromFloat32(n float32) int8 { return int8(n) } +func Int8FromFloat64(n float64) int8 { return int8(n) } +func Int8FromComplex64(n complex64) int8 { return int8(real(n)) } +func Int8FromComplex128(n complex128) int8 { return int8(real(n)) } +func Int8FromUintptr(n uintptr) int8 { return int8(n) } +func Int16FromInt8(n int8) int16 { return int16(n) } +func Int16FromInt16(n int16) int16 { return int16(n) } +func Int16FromInt32(n int32) int16 { return int16(n) } +func Int16FromInt64(n int64) int16 { return int16(n) } +func Int16FromUint8(n uint8) int16 { return int16(n) } +func Int16FromUint16(n uint16) int16 { return int16(n) } +func Int16FromUint32(n uint32) int16 { return int16(n) } +func Int16FromUint64(n uint64) int16 { return int16(n) } +func Int16FromFloat32(n float32) int16 { return int16(n) } +func Int16FromFloat64(n float64) int16 { return int16(n) } +func Int16FromComplex64(n complex64) int16 { return int16(real(n)) } +func Int16FromComplex128(n complex128) int16 { return int16(real(n)) } +func Int16FromUintptr(n uintptr) int16 { return int16(n) } +func Int32FromInt8(n int8) int32 { return int32(n) } +func Int32FromInt16(n int16) int32 { return int32(n) } +func Int32FromInt32(n int32) int32 { return int32(n) } +func Int32FromInt64(n int64) int32 { return int32(n) } +func Int32FromUint8(n uint8) int32 { return int32(n) } +func Int32FromUint16(n uint16) int32 { return int32(n) } +func Int32FromUint32(n uint32) int32 { return int32(n) } +func Int32FromUint64(n uint64) int32 { return int32(n) } +func Int32FromFloat32(n float32) int32 { return int32(n) } +func Int32FromFloat64(n float64) int32 { return int32(n) } +func Int32FromComplex64(n complex64) int32 { return int32(real(n)) } +func Int32FromComplex128(n complex128) int32 { return int32(real(n)) } +func Int32FromUintptr(n uintptr) int32 { return int32(n) } +func Int64FromInt8(n int8) int64 { return int64(n) } +func Int64FromInt16(n int16) int64 { return int64(n) } +func Int64FromInt32(n int32) int64 { return int64(n) } +func Int64FromInt64(n int64) int64 { return int64(n) } +func Int64FromUint8(n uint8) int64 { return int64(n) } +func Int64FromUint16(n uint16) int64 { return int64(n) } +func Int64FromUint32(n uint32) int64 { return int64(n) } +func Int64FromUint64(n uint64) int64 { return int64(n) } +func Int64FromFloat32(n float32) int64 { return int64(n) } +func Int64FromFloat64(n float64) int64 { return int64(n) } +func Int64FromComplex64(n complex64) int64 { return int64(real(n)) } +func Int64FromComplex128(n complex128) int64 { return int64(real(n)) } +func Int64FromUintptr(n uintptr) int64 { return int64(n) } +func Uint8FromInt8(n int8) uint8 { return uint8(n) } +func Uint8FromInt16(n int16) uint8 { return uint8(n) } +func Uint8FromInt32(n int32) uint8 { return uint8(n) } +func Uint8FromInt64(n int64) uint8 { return uint8(n) } +func Uint8FromUint8(n uint8) uint8 { return uint8(n) } +func Uint8FromUint16(n uint16) uint8 { return uint8(n) } +func Uint8FromUint32(n uint32) uint8 { return uint8(n) } +func Uint8FromUint64(n uint64) uint8 { return uint8(n) } +func Uint8FromFloat32(n float32) uint8 { return uint8(n) } +func Uint8FromFloat64(n float64) uint8 { return uint8(n) } +func Uint8FromComplex64(n complex64) uint8 { return uint8(real(n)) } +func Uint8FromComplex128(n complex128) uint8 { return uint8(real(n)) } +func Uint8FromUintptr(n uintptr) uint8 { return uint8(n) } +func Uint16FromInt8(n int8) uint16 { return uint16(n) } +func Uint16FromInt16(n int16) uint16 { return uint16(n) } +func Uint16FromInt32(n int32) uint16 { return uint16(n) } +func Uint16FromInt64(n int64) uint16 { return uint16(n) } +func Uint16FromUint8(n uint8) uint16 { return uint16(n) } +func Uint16FromUint16(n uint16) uint16 { return uint16(n) } +func Uint16FromUint32(n uint32) uint16 { return uint16(n) } +func Uint16FromUint64(n uint64) uint16 { return uint16(n) } +func Uint16FromFloat32(n float32) uint16 { return uint16(n) } +func Uint16FromFloat64(n float64) uint16 { return uint16(n) } +func Uint16FromComplex64(n complex64) uint16 { return uint16(real(n)) } +func Uint16FromComplex128(n complex128) uint16 { return uint16(real(n)) } +func Uint16FromUintptr(n uintptr) uint16 { return uint16(n) } +func Uint32FromInt8(n int8) uint32 { return uint32(n) } +func Uint32FromInt16(n int16) uint32 { return uint32(n) } +func Uint32FromInt32(n int32) uint32 { return uint32(n) } +func Uint32FromInt64(n int64) uint32 { return uint32(n) } +func Uint32FromUint8(n uint8) uint32 { return uint32(n) } +func Uint32FromUint16(n uint16) uint32 { return uint32(n) } +func Uint32FromUint32(n uint32) uint32 { return uint32(n) } +func Uint32FromUint64(n uint64) uint32 { return uint32(n) } +func Uint32FromFloat32(n float32) uint32 { return uint32(n) } +func Uint32FromFloat64(n float64) uint32 { return uint32(n) } +func Uint32FromComplex64(n complex64) uint32 { return uint32(real(n)) } +func Uint32FromComplex128(n complex128) uint32 { return uint32(real(n)) } +func Uint32FromUintptr(n uintptr) uint32 { return uint32(n) } +func Uint64FromInt8(n int8) uint64 { return uint64(n) } +func Uint64FromInt16(n int16) uint64 { return uint64(n) } +func Uint64FromInt32(n int32) uint64 { return uint64(n) } +func Uint64FromInt64(n int64) uint64 { return uint64(n) } +func Uint64FromUint8(n uint8) uint64 { return uint64(n) } +func Uint64FromUint16(n uint16) uint64 { return uint64(n) } +func Uint64FromUint32(n uint32) uint64 { return uint64(n) } +func Uint64FromUint64(n uint64) uint64 { return uint64(n) } +func Uint64FromFloat32(n float32) uint64 { return uint64(n) } +func Uint64FromFloat64(n float64) uint64 { return uint64(n) } +func Uint64FromComplex64(n complex64) uint64 { return uint64(real(n)) } +func Uint64FromComplex128(n complex128) uint64 { return uint64(real(n)) } +func Uint64FromUintptr(n uintptr) uint64 { return uint64(n) } +func Float32FromInt8(n int8) float32 { return float32(n) } +func Float32FromInt16(n int16) float32 { return float32(n) } +func Float32FromInt32(n int32) float32 { return float32(n) } +func Float32FromInt64(n int64) float32 { return float32(n) } +func Float32FromUint8(n uint8) float32 { return float32(n) } +func Float32FromUint16(n uint16) float32 { return float32(n) } +func Float32FromUint32(n uint32) float32 { return float32(n) } +func Float32FromUint64(n uint64) float32 { return float32(n) } +func Float32FromFloat32(n float32) float32 { return float32(n) } +func Float32FromFloat64(n float64) float32 { return float32(n) } +func Float32FromComplex64(n complex64) float32 { return float32(real(n)) } +func Float32FromComplex128(n complex128) float32 { return float32(real(n)) } +func Float32FromUintptr(n uintptr) float32 { return float32(n) } +func Float64FromInt8(n int8) float64 { return float64(n) } +func Float64FromInt16(n int16) float64 { return float64(n) } +func Float64FromInt32(n int32) float64 { return float64(n) } +func Float64FromInt64(n int64) float64 { return float64(n) } +func Float64FromUint8(n uint8) float64 { return float64(n) } +func Float64FromUint16(n uint16) float64 { return float64(n) } +func Float64FromUint32(n uint32) float64 { return float64(n) } +func Float64FromUint64(n uint64) float64 { return float64(n) } +func Float64FromFloat32(n float32) float64 { return float64(n) } +func Float64FromFloat64(n float64) float64 { return float64(n) } +func Float64FromComplex64(n complex64) float64 { return float64(real(n)) } +func Float64FromComplex128(n complex128) float64 { return float64(real(n)) } +func Float64FromUintptr(n uintptr) float64 { return float64(n) } +func Complex64FromInt8(n int8) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromInt16(n int16) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromInt32(n int32) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromInt64(n int64) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromUint8(n uint8) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromUint16(n uint16) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromUint32(n uint32) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromUint64(n uint64) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromFloat32(n float32) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromFloat64(n float64) complex64 { return complex64(complex(float32(n), 0)) } +func Complex64FromComplex64(n complex64) complex64 { return complex64(n) } +func Complex64FromComplex128(n complex128) complex64 { return complex64(n) } +func Complex64FromUintptr(n uintptr) complex64 { return complex64(complex(float32(n), 0)) } +func Complex128FromInt8(n int8) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromInt16(n int16) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromInt32(n int32) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromInt64(n int64) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromUint8(n uint8) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromUint16(n uint16) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromUint32(n uint32) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromUint64(n uint64) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromFloat32(n float32) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromFloat64(n float64) complex128 { return complex128(complex(float64(n), 0)) } +func Complex128FromComplex64(n complex64) complex128 { return complex128(n) } +func Complex128FromComplex128(n complex128) complex128 { return complex128(n) } +func Complex128FromUintptr(n uintptr) complex128 { return complex128(complex(float64(n), 0)) } +func UintptrFromInt8(n int8) uintptr { return uintptr(n) } +func UintptrFromInt16(n int16) uintptr { return uintptr(n) } +func UintptrFromInt32(n int32) uintptr { return uintptr(n) } +func UintptrFromInt64(n int64) uintptr { return uintptr(n) } +func UintptrFromUint8(n uint8) uintptr { return uintptr(n) } +func UintptrFromUint16(n uint16) uintptr { return uintptr(n) } +func UintptrFromUint32(n uint32) uintptr { return uintptr(n) } +func UintptrFromUint64(n uint64) uintptr { return uintptr(n) } +func UintptrFromFloat32(n float32) uintptr { return uintptr(n) } +func UintptrFromFloat64(n float64) uintptr { return uintptr(n) } +func UintptrFromComplex64(n complex64) uintptr { return uintptr(real(n)) } +func UintptrFromComplex128(n complex128) uintptr { return uintptr(real(n)) } +func UintptrFromUintptr(n uintptr) uintptr { return uintptr(n) } + +func Int8(n int8) int8 { return n } +func Int16(n int16) int16 { return n } +func Int32(n int32) int32 { return n } +func Int64(n int64) int64 { return n } +func Uint8(n uint8) uint8 { return n } +func Uint16(n uint16) uint16 { return n } +func Uint32(n uint32) uint32 { return n } +func Uint64(n uint64) uint64 { return n } +func Float32(n float32) float32 { return n } +func Float64(n float64) float64 { return n } +func Complex64(n complex64) complex64 { return n } +func Complex128(n complex128) complex128 { return n } +func Uintptr(n uintptr) uintptr { return n } + +func NegInt8(n int8) int8 { return -n } +func NegInt16(n int16) int16 { return -n } +func NegInt32(n int32) int32 { return -n } +func NegInt64(n int64) int64 { return -n } +func NegUint8(n uint8) uint8 { return -n } +func NegUint16(n uint16) uint16 { return -n } +func NegUint32(n uint32) uint32 { return -n } +func NegUint64(n uint64) uint64 { return -n } +func NegUintptr(n uintptr) uintptr { return -n } + +func CplInt8(n int8) int8 { return ^n } +func CplInt16(n int16) int16 { return ^n } +func CplInt32(n int32) int32 { return ^n } +func CplInt64(n int64) int64 { return ^n } +func CplUint8(n uint8) uint8 { return ^n } +func CplUint16(n uint16) uint16 { return ^n } +func CplUint32(n uint32) uint32 { return ^n } +func CplUint64(n uint64) uint64 { return ^n } +func CplUintptr(n uintptr) uintptr { return ^n } + +func BoolInt8(b bool) int8 { + if b { + return 1 + } + return 0 +} + +func BoolInt16(b bool) int16 { + if b { + return 1 + } + return 0 +} + +func BoolInt32(b bool) int32 { + if b { + return 1 + } + return 0 +} + +func BoolInt64(b bool) int64 { + if b { + return 1 + } + return 0 +} + +func BoolUint8(b bool) uint8 { + if b { + return 1 + } + return 0 +} + +func BoolUint16(b bool) uint16 { + if b { + return 1 + } + return 0 +} + +func BoolUint32(b bool) uint32 { + if b { + return 1 + } + return 0 +} + +func BoolUint64(b bool) uint64 { + if b { + return 1 + } + return 0 +} + +func BoolUintptr(b bool) uintptr { + if b { + return 1 + } + return 0 +} + +func SetBitFieldPtr8Int8(p uintptr, v int8, off int, mask uint8) { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^uint8(mask) | uint8(v)<> s +} + +func AssignBitFieldPtr8Int16(p uintptr, v int16, w, off int, mask uint8) int16 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^uint8(mask) | uint8(v)<> s +} + +func AssignBitFieldPtr8Int32(p uintptr, v int32, w, off int, mask uint8) int32 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^uint8(mask) | uint8(v)<> s +} + +func AssignBitFieldPtr8Int64(p uintptr, v int64, w, off int, mask uint8) int64 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^uint8(mask) | uint8(v)<> s +} + +func AssignBitFieldPtr16Int8(p uintptr, v int8, w, off int, mask uint16) int8 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^uint16(mask) | uint16(v)<> s +} + +func AssignBitFieldPtr16Int16(p uintptr, v int16, w, off int, mask uint16) int16 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^uint16(mask) | uint16(v)<> s +} + +func AssignBitFieldPtr16Int32(p uintptr, v int32, w, off int, mask uint16) int32 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^uint16(mask) | uint16(v)<> s +} + +func AssignBitFieldPtr16Int64(p uintptr, v int64, w, off int, mask uint16) int64 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^uint16(mask) | uint16(v)<> s +} + +func AssignBitFieldPtr32Int8(p uintptr, v int8, w, off int, mask uint32) int8 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^uint32(mask) | uint32(v)<> s +} + +func AssignBitFieldPtr32Int16(p uintptr, v int16, w, off int, mask uint32) int16 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^uint32(mask) | uint32(v)<> s +} + +func AssignBitFieldPtr32Int32(p uintptr, v int32, w, off int, mask uint32) int32 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^uint32(mask) | uint32(v)<> s +} + +func AssignBitFieldPtr32Int64(p uintptr, v int64, w, off int, mask uint32) int64 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^uint32(mask) | uint32(v)<> s +} + +func AssignBitFieldPtr64Int8(p uintptr, v int8, w, off int, mask uint64) int8 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^uint64(mask) | uint64(v)<> s +} + +func AssignBitFieldPtr64Int16(p uintptr, v int16, w, off int, mask uint64) int16 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^uint64(mask) | uint64(v)<> s +} + +func AssignBitFieldPtr64Int32(p uintptr, v int32, w, off int, mask uint64) int32 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^uint64(mask) | uint64(v)<> s +} + +func AssignBitFieldPtr64Int64(p uintptr, v int64, w, off int, mask uint64) int64 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^uint64(mask) | uint64(v)<> s +} + +func AssignBitFieldPtr8Uint8(p uintptr, v uint8, w, off int, mask uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^uint8(mask) | uint8(v)<>off) +} + +func AssignBitFieldPtr8Uint16(p uintptr, v uint16, w, off int, mask uint8) uint16 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^uint8(mask) | uint8(v)<>off) +} + +func AssignBitFieldPtr8Uint32(p uintptr, v uint32, w, off int, mask uint8) uint32 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^uint8(mask) | uint8(v)<>off) +} + +func AssignBitFieldPtr8Uint64(p uintptr, v uint64, w, off int, mask uint8) uint64 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^uint8(mask) | uint8(v)<>off) +} + +func AssignBitFieldPtr16Uint8(p uintptr, v uint8, w, off int, mask uint16) uint8 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^uint16(mask) | uint16(v)<>off) +} + +func AssignBitFieldPtr16Uint16(p uintptr, v uint16, w, off int, mask uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^uint16(mask) | uint16(v)<>off) +} + +func AssignBitFieldPtr16Uint32(p uintptr, v uint32, w, off int, mask uint16) uint32 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^uint16(mask) | uint16(v)<>off) +} + +func AssignBitFieldPtr16Uint64(p uintptr, v uint64, w, off int, mask uint16) uint64 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^uint16(mask) | uint16(v)<>off) +} + +func AssignBitFieldPtr32Uint8(p uintptr, v uint8, w, off int, mask uint32) uint8 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^uint32(mask) | uint32(v)<>off) +} + +func AssignBitFieldPtr32Uint16(p uintptr, v uint16, w, off int, mask uint32) uint16 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^uint32(mask) | uint32(v)<>off) +} + +func AssignBitFieldPtr32Uint32(p uintptr, v uint32, w, off int, mask uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^uint32(mask) | uint32(v)<>off) +} + +func AssignBitFieldPtr32Uint64(p uintptr, v uint64, w, off int, mask uint32) uint64 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^uint32(mask) | uint32(v)<>off) +} + +func AssignBitFieldPtr64Uint8(p uintptr, v uint8, w, off int, mask uint64) uint8 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^uint64(mask) | uint64(v)<>off) +} + +func AssignBitFieldPtr64Uint16(p uintptr, v uint16, w, off int, mask uint64) uint16 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^uint64(mask) | uint64(v)<>off) +} + +func AssignBitFieldPtr64Uint32(p uintptr, v uint32, w, off int, mask uint64) uint32 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^uint64(mask) | uint64(v)<>off) +} + +func AssignBitFieldPtr64Uint64(p uintptr, v uint64, w, off int, mask uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^uint64(mask) | uint64(v)<>off) +} + +func PostDecBitFieldPtr8Int8(p uintptr, d int8, w, off int, mask uint8) (r int8) { + x0 := *(*uint8)(unsafe.Pointer(p)) + s := 8 - w - off + r = int8(x0) & int8(mask) << s >> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r-d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r-d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r-d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r-d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r-d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r-d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r-d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r-d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r-d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r-d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r-d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r-d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r-d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r-d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r-d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r-d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r-d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r-d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r-d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r-d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r-d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r-d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r-d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r-d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r-d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r-d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r-d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r-d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r-d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r-d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r-d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r-d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r+d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r+d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r+d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r+d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r+d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r+d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r+d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r+d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r+d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r+d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r+d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r+d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r+d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r+d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r+d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r+d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r+d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r+d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r+d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^uint8(mask) | uint8(r+d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r+d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r+d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r+d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^uint16(mask) | uint16(r+d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r+d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r+d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r+d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^uint32(mask) | uint32(r+d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r+d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r+d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r+d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^uint64(mask) | uint64(r+d)<> int32(32)) + **(**int32)(__ccgo_up(expt)) = Int32FromUint32(hx>>Int32FromInt32(20) - Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(1023)) + _k) + v1 = uint64(hx&Uint32FromInt32(0xfffff)|Uint32FromInt32((Int32FromInt32(0x3ff)+Int32FromInt32(1023))<= ln(DBL_MAX)) +// * where care is needed to avoid overflow. +// * +// * The present implementation is narrowly tailored for our hyperbolic and +// * exponential functions. We assume expt is small (0 or -1), and the caller +// * has filtered out very large x, for which overflow would be inevitable. +// */ +func X__ldexp_cexp(tls *TLS, z complex128, expt int32) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v expt=%v, (%v:)", tls, z, expt, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var exp_x, scale1, scale2, x, y float64 + var half_expt int32 + var v1 Tuint64_t + var v3 [2]float64 + var _ /* ex_expt at bp+0 */ int32 + _, _, _, _, _, _, _, _ = exp_x, half_expt, scale1, scale2, x, y, v1, v3 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + exp_x = ___frexp_exp(tls, x, bp) + expt = expt + **(**int32)(__ccgo_up(bp)) + /* + * Arrange so that scale1 * scale2 == 2**expt. We use this to + * compensate for scalbn being horrendously slow. + */ + half_expt = expt / int32(2) + v1 = Uint64FromInt32((Int32FromInt32(0x3ff)+half_expt)<>Int32FromInt32(23) - Uint32FromInt32(Int32FromInt32(0x7f)+Int32FromInt32(127)) + _k1) + v1 = hx&uint32(0x7fffff) | Uint32FromInt32((Int32FromInt32(0x7f)+Int32FromInt32(127))< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var exp_x, scale1, scale2, x, y float32 + var half_expt int32 + var v1 Tuint32_t + var v3 [2]float32 + var _ /* ex_expt at bp+0 */ int32 + _, _, _, _, _, _, _, _ = exp_x, half_expt, scale1, scale2, x, y, v1, v3 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + exp_x = ___frexp_expf(tls, x, bp) + expt = expt + **(**int32)(__ccgo_up(bp)) + half_expt = expt / int32(2) + v1 = Uint32FromInt32((int32(0x7f) + half_expt) << int32(23)) + scale1 = *(*float32)(unsafe.Pointer(&v1)) + half_expt = expt - half_expt + v1 = Uint32FromInt32((int32(0x7f) + half_expt) << int32(23)) + scale2 = *(*float32)(unsafe.Pointer(&v1)) + v3 = [2]float32{ + 0: float32(float32(float32(Xcosf(tls, y)*exp_x)*scale1) * scale2), + 1: float32(float32(float32(Xsinf(tls, y)*exp_x)*scale1) * scale2), + } + return *(*complex64)(unsafe.Pointer(&v3)) +} + +func Xcabs(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xhypot(tls, Float64FromComplex128(z), +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)]) +} + +func Xcabsf(tls *TLS, z complex64) (r float32) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xhypotf(tls, Float32FromComplex64(z), +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)]) +} + +func Xcabsl(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcabs(tls, Complex128FromComplex128(z)) +} + +const M_PI_21 = 1.5707963267948966 + +// FIXME: Hull et al. "Implementing the complex arcsine and arccosine functions using exception handling" 1997 + +/* acos(z) = pi/2 - asin(z) */ + +func Xcacos(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + z = Xcasin(tls, z) + v1 = [2]float64{ + 0: float64(1.5707963267948966) - Float64FromComplex128(z), + 1: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +// FIXME + +var _float_pi_2 = float32(1.5707963267948966) + +func Xcacosf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + z = Xcasinf(tls, z) + v1 = [2]float32{ + 0: _float_pi_2 - Float32FromComplex64(z), + 1: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +const M_PI_22 = 0 + +/* acosh(z) = i acos(z) */ + +func Xcacosh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var zineg int32 + var v1 uint64 + var v3 [2]float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _ = zineg, v1, v3 + *(*float64)(unsafe.Pointer(bp)) = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + zineg = Int32FromUint64(v1 >> Int32FromInt32(63)) + z = Xcacos(tls, z) + if zineg != 0 { + v3 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v3)) + } else { + v3 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v3)) + } + return r +} + +func Xcacoshf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var zineg int32 + var v1 uint32 + var v3 [2]float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _ = zineg, v1, v3 + *(*float32)(unsafe.Pointer(bp)) = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + zineg = Int32FromUint32(v1 >> Int32FromInt32(31)) + z = Xcacosf(tls, z) + if zineg != 0 { + v3 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v3)) + } else { + v3 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v3)) + } + return r +} + +func Xcacoshl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcacosh(tls, Complex128FromComplex128(z))) +} + +func Xcacosl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcacos(tls, Complex128FromComplex128(z))) +} + +func Xcarg(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xatan2(tls, +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], Float64FromComplex128(z)) +} + +func Xcargf(tls *TLS, z complex64) (r float32) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xatan2f(tls, +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], Float32FromComplex64(z)) +} + +func Xcargl(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcarg(tls, Complex128FromComplex128(z)) +} + +// FIXME + +/* asin(z) = -i log(i z + sqrt(1 - z*z)) */ + +func Xcasin(tls *TLS, z complex128) (r1 complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, w complex128 + var x, y float64 + var v1, v2 [2]float64 + _, _, _, _, _, _ = r, w, x, y, v1, v2 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + v1 = [2]float64{ + 0: float64(1) - float64((x-y)*(x+y)), + 1: float64(float64(-Float64FromFloat64(2)*x) * y), + } + w = *(*complex128)(unsafe.Pointer(&v1)) + v1 = [2]float64{ + 0: -y, + 1: x, + } + r = Xclog(tls, *(*complex128)(unsafe.Pointer(&v1))+Xcsqrt(tls, w)) + v2 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&r)))[int32(1)], + 1: -Float64FromComplex128(r), + } + return *(*complex128)(unsafe.Pointer(&v2)) +} + +// FIXME + +func Xcasinf(tls *TLS, z complex64) (r1 complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, w complex64 + var x, y float32 + var v1, v2 [2]float32 + _, _, _, _, _, _ = r, w, x, y, v1, v2 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + v1 = [2]float32{ + 0: float32(Float64FromFloat64(1) - float64((x-y)*(x+y))), + 1: float32(float64(float64(-Float64FromFloat64(2)*float64(x)) * float64(y))), + } + w = *(*complex64)(unsafe.Pointer(&v1)) + v1 = [2]float32{ + 0: -y, + 1: x, + } + r = Xclogf(tls, *(*complex64)(unsafe.Pointer(&v1))+Xcsqrtf(tls, w)) + v2 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&r)))[int32(1)], + 1: -Float32FromComplex64(r), + } + return *(*complex64)(unsafe.Pointer(&v2)) +} + +/* asinh(z) = -i asin(i z) */ + +func Xcasinh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + z = Xcasin(tls, *(*complex128)(unsafe.Pointer(&v1))) + v1 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xcasinhf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + z = Xcasinf(tls, *(*complex64)(unsafe.Pointer(&v1))) + v1 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xcasinhl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcasinh(tls, Complex128FromComplex128(z))) +} + +func Xcasinl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcasin(tls, Complex128FromComplex128(z))) +} + +const MAXNUM = 0 +const M_PI1 = 3.141592653589793 + +var _DP1 = float64(3.141592651605606) +var _DP2 = float64(1.9841871479187034e-09) +var _DP3 = float64(1.1442377452219664e-17) + +func __redupi(tls *TLS, x float64) (r float64) { + var i int64 + var t float64 + _, _ = i, t + t = x / float64(3.141592653589793) + if t >= float64(0) { + t = t + float64(0.5) + } else { + t = t - float64(0.5) + } + i = int64(t) /* the multiple */ + t = float64(i) + t = x - float64(t*_DP1) - float64(t*_DP2) - float64(t*_DP3) + return t +} + +func Xcatan(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, t, x, x2, y float64 + var w complex128 + var v1 [2]float64 + _, _, _, _, _, _, _ = a, t, w, x, x2, y, v1 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + x2 = float64(x * x) + a = float64(1) - x2 - float64(y*y) + t = float64(float64(0.5) * Xatan2(tls, float64(float64(2)*x), a)) + w = Complex128FromFloat64(__redupi(tls, t)) + t = y - float64(1) + a = x2 + float64(t*t) + t = y + float64(1) + a = (x2 + float64(t*t)) / a + v1 = [2]float64{ + 0: Float64FromComplex128(w), + 1: float64(float64(0.25) * Xlog(tls, a)), + } + w = *(*complex128)(unsafe.Pointer(&v1)) + return w +} + +const MAXNUMF = 0 + +var _DP11 = float64(3.140625) +var _DP21 = float64(0.0009675025939941406) +var _DP31 = float64(1.5099579909783765e-07) + +var _float_pi = float32(3.141592653589793) + +func __redupif(tls *TLS, xx float32) (r float32) { + var i int64 + var t, x float32 + _, _, _ = i, t, x + x = xx + t = x / _float_pi + if t >= Float32FromFloat32(0) { + t = t + Float32FromFloat32(0.5) + } else { + t = t - Float32FromFloat32(0.5) + } + i = int64(t) /* the multiple */ + t = float32(i) + t = float32(float64(x) - float64(float64(t)*_DP11) - float64(float64(t)*_DP21) - float64(float64(t)*_DP31)) + return t +} + +func Xcatanf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, t, x, x2, y float32 + var w complex64 + var v1 [2]float32 + _, _, _, _, _, _, _ = a, t, w, x, x2, y, v1 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + x2 = float32(x * x) + a = Float32FromFloat32(1) - x2 - float32(y*y) + t = float32(Float32FromFloat32(0.5) * Xatan2f(tls, float32(Float32FromFloat32(2)*x), a)) + w = Complex64FromFloat32(__redupif(tls, t)) + t = y - Float32FromFloat32(1) + a = x2 + float32(t*t) + t = y + Float32FromFloat32(1) + a = (x2 + float32(t*t)) / a + v1 = [2]float32{ + 0: Float32FromComplex64(w), + 1: float32(Float32FromFloat32(0.25) * Xlogf(tls, a)), + } + w = *(*complex64)(unsafe.Pointer(&v1)) + return w +} + +const M_PI2 = 0 + +/* atanh = -i atan(i z) */ + +func Xcatanh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + z = Xcatan(tls, *(*complex128)(unsafe.Pointer(&v1))) + v1 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xcatanhf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + z = Xcatanf(tls, *(*complex64)(unsafe.Pointer(&v1))) + v1 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xcatanhl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcatanh(tls, Complex128FromComplex128(z))) +} + +func Xcatanl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcatan(tls, Complex128FromComplex128(z))) +} + +/* cos(z) = cosh(i z) */ + +func Xccos(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + return Xccosh(tls, *(*complex128)(unsafe.Pointer(&v1))) +} + +func Xccosf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + return Xccoshf(tls, *(*complex64)(unsafe.Pointer(&v1))) +} + +var _huge = float64(8.98846567431158e+307) + +func Xccosh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u, __u1 Tuint64_t + var h, x, y float64 + var hx, hy, ix, iy, lx, ly Tint32_t + var v1 [2]float64 + _, _, _, _, _, _, _, _, _, _, _, _ = __u, __u1, h, hx, hy, ix, iy, lx, ly, x, y, v1 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + hx = Int32FromUint64(__u >> int32(32)) + lx = Int32FromUint32(uint32(__u)) + __u1 = *(*Tuint64_t)(unsafe.Pointer(&y)) + hy = Int32FromUint64(__u1 >> int32(32)) + ly = Int32FromUint32(uint32(__u1)) + ix = int32(0x7fffffff) & hx + iy = int32(0x7fffffff) & hy + /* Handle the nearly-non-exceptional cases where x and y are finite. */ + if ix < int32(0x7ff00000) && iy < int32(0x7ff00000) { + if iy|ly == 0 { + v1 = [2]float64{ + 0: Xcosh(tls, x), + 1: float64(x * y), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + if ix < int32(0x40360000) { /* small x: normal case */ + v1 = [2]float64{ + 0: float64(Xcosh(tls, x) * Xcos(tls, y)), + 1: float64(Xsinh(tls, x) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* |x| >= 22, so cosh(x) ~= exp(|x|) */ + if ix < int32(0x40862e42) { + /* x < 710: exp(|x|) won't overflow */ + h = float64(Xexp(tls, Xfabs(tls, x)) * float64(0.5)) + v1 = [2]float64{ + 0: float64(h * Xcos(tls, y)), + 1: float64(Xcopysign(tls, h, x) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + if ix < int32(0x4096bbaa) { + /* x < 1455: scale to avoid overflow */ + v1 = [2]float64{ + 0: Xfabs(tls, x), + 1: y, + } + z = X__ldexp_cexp(tls, *(*complex128)(unsafe.Pointer(&v1)), -int32(1)) + v1 = [2]float64{ + 0: Float64FromComplex128(z), + 1: float64(+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] * Xcopysign(tls, Float64FromInt32(1), x)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + /* x >= 1455: the result always overflows */ + h = float64(_huge * x) + v1 = [2]float64{ + 0: float64(float64(h*h) * Xcos(tls, y)), + 1: float64(h * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + } + } + /* + * cosh(+-0 +- I Inf) = dNaN + I sign(d(+-0, dNaN))0. + * The sign of 0 in the result is unspecified. Choice = normally + * the same as dNaN. Raise the invalid floating-point exception. + * + * cosh(+-0 +- I NaN) = d(NaN) + I sign(d(+-0, NaN))0. + * The sign of 0 in the result is unspecified. Choice = normally + * the same as d(NaN). + */ + if ix|lx == 0 && iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: y - y, + 1: Xcopysign(tls, Float64FromInt32(0), float64(x*(y-y))), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0. + * + * cosh(NaN +- I 0) = d(NaN) + I sign(d(NaN, +-0))0. + * The sign of 0 in the result is unspecified. + */ + if iy|ly == 0 && ix >= int32(0x7ff00000) { + if hx&int32(0xfffff)|lx == 0 { + v1 = [2]float64{ + 0: float64(x * x), + 1: float64(Xcopysign(tls, Float64FromInt32(0), x) * y), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v1 = [2]float64{ + 0: float64(x * x), + 1: Xcopysign(tls, Float64FromInt32(0), float64((x+x)*y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * cosh(x +- I Inf) = dNaN + I dNaN. + * Raise the invalid floating-point exception for finite nonzero x. + * + * cosh(x + I NaN) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception for finite + * nonzero x. Choice = don't raise (except for signaling NaNs). + */ + if ix < int32(0x7ff00000) && iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: y - y, + 1: float64(x * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * cosh(+-Inf + I NaN) = +Inf + I d(NaN). + * + * cosh(+-Inf +- I Inf) = +Inf + I dNaN. + * The sign of Inf in the result is unspecified. Choice = always +. + * Raise the invalid floating-point exception. + * + * cosh(+-Inf + I y) = +Inf cos(y) +- I Inf sin(y) + */ + if ix >= int32(0x7ff00000) && hx&int32(0xfffff)|lx == 0 { + if iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: float64(x * x), + 1: float64(x * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v1 = [2]float64{ + 0: float64(float64(x*x) * Xcos(tls, y)), + 1: float64(x * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * cosh(NaN + I NaN) = d(NaN) + I d(NaN). + * + * cosh(NaN +- I Inf) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception. + * Choice = raise. + * + * cosh(NaN + I y) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception for finite + * nonzero y. Choice = don't raise (except for signaling NaNs). + */ + v1 = [2]float64{ + 0: float64(float64(x*x) * (y - y)), + 1: float64((x + x) * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +var _huge1 = float32(1.7014118346046923e+38) + +func Xccoshf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h, x, y float32 + var hx, hy, ix, iy Tint32_t + var v1 [2]float32 + _, _, _, _, _, _, _, _ = h, hx, hy, ix, iy, x, y, v1 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + hx = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(&x))) + hy = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(&y))) + ix = int32(0x7fffffff) & hx + iy = int32(0x7fffffff) & hy + if ix < int32(0x7f800000) && iy < int32(0x7f800000) { + if iy == 0 { + v1 = [2]float32{ + 0: Xcoshf(tls, x), + 1: float32(x * y), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix < int32(0x41100000) { /* small x: normal case */ + v1 = [2]float32{ + 0: float32(Xcoshf(tls, x) * Xcosf(tls, y)), + 1: float32(Xsinhf(tls, x) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + /* |x| >= 9, so cosh(x) ~= exp(|x|) */ + if ix < int32(0x42b17218) { + /* x < 88.7: expf(|x|) won't overflow */ + h = float32(Xexpf(tls, Xfabsf(tls, x)) * Float32FromFloat32(0.5)) + v1 = [2]float32{ + 0: float32(h * Xcosf(tls, y)), + 1: float32(Xcopysignf(tls, h, x) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + if ix < int32(0x4340b1e7) { + /* x < 192.7: scale to avoid overflow */ + v1 = [2]float32{ + 0: Xfabsf(tls, x), + 1: y, + } + z = X__ldexp_cexpf(tls, *(*complex64)(unsafe.Pointer(&v1)), -int32(1)) + v1 = [2]float32{ + 0: Float32FromComplex64(z), + 1: float32(+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] * Xcopysignf(tls, Float32FromInt32(1), x)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + /* x >= 192.7: the result always overflows */ + h = float32(_huge1 * x) + v1 = [2]float32{ + 0: float32(float32(h*h) * Xcosf(tls, y)), + 1: float32(h * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + } + } + if ix == 0 && iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: y - y, + 1: Xcopysignf(tls, Float32FromInt32(0), float32(x*(y-y))), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if iy == 0 && ix >= int32(0x7f800000) { + if hx&int32(0x7fffff) == 0 { + v1 = [2]float32{ + 0: float32(x * x), + 1: float32(Xcopysignf(tls, Float32FromInt32(0), x) * y), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(x * x), + 1: Xcopysignf(tls, Float32FromInt32(0), float32((x+x)*y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix < int32(0x7f800000) && iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: y - y, + 1: float32(x * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix >= int32(0x7f800000) && hx&int32(0x7fffff) == 0 { + if iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: float32(x * x), + 1: float32(x * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(float32(x*x) * Xcosf(tls, y)), + 1: float32(x * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(float32(x*x) * (y - y)), + 1: float32((x + x) * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +// C documentation +// +// //FIXME +func Xccoshl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xccosh(tls, Complex128FromComplex128(z))) +} + +func Xccosl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xccos(tls, Complex128FromComplex128(z))) +} + +var _exp_ovfl = uint32(0x40862e42) /* high bits of MAX_EXP * ln2 ~= 710 */ +var _cexp_ovfl = uint32(0x4096b8e4) /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ + +func Xcexp(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u, __u1 Tuint64_t + var exp_x, x, y float64 + var hx, hy, lx, ly Tuint32_t + var v1 [2]float64 + _, _, _, _, _, _, _, _, _, _ = __u, __u1, exp_x, hx, hy, lx, ly, x, y, v1 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + __u = *(*Tuint64_t)(unsafe.Pointer(&y)) + hy = uint32(__u >> int32(32)) + ly = uint32(__u) + hy = hy & uint32(0x7fffffff) + /* cexp(x + I 0) = exp(x) + I 0 */ + if hy|ly == uint32(0) { + v1 = [2]float64{ + 0: Xexp(tls, x), + 1: y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + __u1 = *(*Tuint64_t)(unsafe.Pointer(&x)) + hx = uint32(__u1 >> int32(32)) + lx = uint32(__u1) + /* cexp(0 + I y) = cos(y) + I sin(y) */ + if hx&uint32(0x7fffffff)|lx == uint32(0) { + v1 = [2]float64{ + 0: Xcos(tls, y), + 1: Xsin(tls, y), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + if hy >= uint32(0x7ff00000) { + if lx != uint32(0) || hx&uint32(0x7fffffff) != uint32(0x7ff00000) { + /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ + v1 = [2]float64{ + 0: y - y, + 1: y - y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + if hx&uint32(0x80000000) != 0 { + /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ + v1 = [2]float64{} + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ + v1 = [2]float64{ + 0: x, + 1: y - y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + } + } + if hx >= _exp_ovfl && hx <= _cexp_ovfl { + /* + * x is between 709.7 and 1454.3, so we must scale to avoid + * overflow in exp(x). + */ + return X__ldexp_cexp(tls, z, 0) + } else { + /* + * Cases covered here: + * - x < exp_ovfl and exp(x) won't overflow (common case) + * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 + * - x = +-Inf (generated by exp()) + * - x = NaN (spurious inexact exception from y) + */ + exp_x = Xexp(tls, x) + v1 = [2]float64{ + 0: float64(exp_x * Xcos(tls, y)), + 1: float64(exp_x * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + return r +} + +var _exp_ovfl1 = uint32(0x42b17218) /* MAX_EXP * ln2 ~= 88.722839355 */ +var _cexp_ovfl1 = uint32(0x43400074) /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ + +func Xcexpf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var exp_x, x, y float32 + var hx, hy Tuint32_t + var v1 [2]float32 + _, _, _, _, _, _ = exp_x, hx, hy, x, y, v1 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + hy = *(*Tuint32_t)(unsafe.Pointer(&y)) + hy = hy & uint32(0x7fffffff) + /* cexp(x + I 0) = exp(x) + I 0 */ + if hy == uint32(0) { + v1 = [2]float32{ + 0: Xexpf(tls, x), + 1: y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + hx = *(*Tuint32_t)(unsafe.Pointer(&x)) + /* cexp(0 + I y) = cos(y) + I sin(y) */ + if hx&uint32(0x7fffffff) == uint32(0) { + v1 = [2]float32{ + 0: Xcosf(tls, y), + 1: Xsinf(tls, y), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if hy >= uint32(0x7f800000) { + if hx&uint32(0x7fffffff) != uint32(0x7f800000) { + /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ + v1 = [2]float32{ + 0: y - y, + 1: y - y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + if hx&uint32(0x80000000) != 0 { + /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ + v1 = [2]float32{} + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ + v1 = [2]float32{ + 0: x, + 1: y - y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + } + } + if hx >= _exp_ovfl1 && hx <= _cexp_ovfl1 { + /* + * x is between 88.7 and 192, so we must scale to avoid + * overflow in expf(x). + */ + return X__ldexp_cexpf(tls, z, 0) + } else { + /* + * Cases covered here: + * - x < exp_ovfl and exp(x) won't overflow (common case) + * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 + * - x = +-Inf (generated by exp()) + * - x = NaN (spurious inexact exception from y) + */ + exp_x = Xexpf(tls, x) + v1 = [2]float32{ + 0: float32(exp_x * Xcosf(tls, y)), + 1: float32(exp_x * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + return r +} + +// C documentation +// +// //FIXME +func Xcexpl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcexp(tls, Complex128FromComplex128(z))) +} + +func Xcimag(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] +} + +func Xcimagf(tls *TLS, z complex64) (r float32) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] +} + +func Xcimagl(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] +} + +// FIXME + +/* log(z) = log(|z|) + i arg(z) */ + +func Xclog(tls *TLS, z complex128) (r1 complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var phi, r float64 + var v1 [2]float64 + _, _, _ = phi, r, v1 + r = Xcabs(tls, z) + phi = Xcarg(tls, z) + v1 = [2]float64{ + 0: Xlog(tls, r), + 1: phi, + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +// FIXME + +func Xclogf(tls *TLS, z complex64) (r1 complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var phi, r float32 + var v1 [2]float32 + _, _, _ = phi, r, v1 + r = Xcabsf(tls, z) + phi = Xcargf(tls, z) + v1 = [2]float32{ + 0: Xlogf(tls, r), + 1: phi, + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xclogl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xclog(tls, Complex128FromComplex128(z))) +} + +func Xconj(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: Float64FromComplex128(z), + 1: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xconjf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: Float32FromComplex64(z), + 1: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xconjl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: Float64FromComplex128(z), + 1: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +/* pow(z, c) = exp(c log(z)), See C99 G.6.4.1 */ + +func Xcpow(tls *TLS, z complex128, c complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v c=%v, (%v:)", tls, z, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcexp(tls, c*Xclog(tls, z)) +} + +func Xcpowf(tls *TLS, z complex64, c complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v c=%v, (%v:)", tls, z, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcexpf(tls, c*Xclogf(tls, z)) +} + +func Xcpowl(tls *TLS, z complex128, c complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v c=%v, (%v:)", tls, z, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcpow(tls, Complex128FromComplex128(z), Complex128FromComplex128(c))) +} + +func Xcproj(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3 uint64 + var v5 bool + var v6 [2]float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _ = v1, v3, v5, v6 + *(*float64)(unsafe.Pointer(bp)) = Float64FromComplex128(z) + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3 uint32 + var v5 bool + var v6 [2]float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _ = v1, v3, v5, v6 + *(*float32)(unsafe.Pointer(bp)) = Float32FromComplex64(z) + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) == uint32(0x7f800000)) != 0; !v5 { + *(*float32)(unsafe.Pointer(bp)) = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&uint32(0x7fffffff) == uint32(0x7f800000)) != 0 { + v6 = [2]float32{ + 0: X__builtin_inff(tls), + 1: Xcopysignf(tls, float32(0), +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)]), + } + return *(*complex64)(unsafe.Pointer(&v6)) + } + return z +} + +func Xcprojl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcproj(tls, Complex128FromComplex128(z))) +} + +func Xcreal(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Float64FromComplex128(z) +} + +func Xcrealf(tls *TLS, z complex64) (r float32) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Float32FromComplex64(z) +} + +func Xcreall(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Float64FromComplex128(z) +} + +/* sin(z) = -i sinh(i z) */ + +func Xcsin(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + z = Xcsinh(tls, *(*complex128)(unsafe.Pointer(&v1))) + v1 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xcsinf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + z = Xcsinhf(tls, *(*complex64)(unsafe.Pointer(&v1))) + v1 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +var _huge2 = float64(8.98846567431158e+307) + +func Xcsinh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u, __u1 Tuint64_t + var h, x, y float64 + var hx, hy, ix, iy, lx, ly Tint32_t + var v1 [2]float64 + _, _, _, _, _, _, _, _, _, _, _, _ = __u, __u1, h, hx, hy, ix, iy, lx, ly, x, y, v1 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + hx = Int32FromUint64(__u >> int32(32)) + lx = Int32FromUint32(uint32(__u)) + __u1 = *(*Tuint64_t)(unsafe.Pointer(&y)) + hy = Int32FromUint64(__u1 >> int32(32)) + ly = Int32FromUint32(uint32(__u1)) + ix = int32(0x7fffffff) & hx + iy = int32(0x7fffffff) & hy + /* Handle the nearly-non-exceptional cases where x and y are finite. */ + if ix < int32(0x7ff00000) && iy < int32(0x7ff00000) { + if iy|ly == 0 { + v1 = [2]float64{ + 0: Xsinh(tls, x), + 1: y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + if ix < int32(0x40360000) { /* small x: normal case */ + v1 = [2]float64{ + 0: float64(Xsinh(tls, x) * Xcos(tls, y)), + 1: float64(Xcosh(tls, x) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* |x| >= 22, so cosh(x) ~= exp(|x|) */ + if ix < int32(0x40862e42) { + /* x < 710: exp(|x|) won't overflow */ + h = float64(Xexp(tls, Xfabs(tls, x)) * float64(0.5)) + v1 = [2]float64{ + 0: float64(Xcopysign(tls, h, x) * Xcos(tls, y)), + 1: float64(h * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + if ix < int32(0x4096bbaa) { + /* x < 1455: scale to avoid overflow */ + v1 = [2]float64{ + 0: Xfabs(tls, x), + 1: y, + } + z = X__ldexp_cexp(tls, *(*complex128)(unsafe.Pointer(&v1)), -int32(1)) + v1 = [2]float64{ + 0: float64(Float64FromComplex128(z) * Xcopysign(tls, Float64FromInt32(1), x)), + 1: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + /* x >= 1455: the result always overflows */ + h = float64(_huge2 * x) + v1 = [2]float64{ + 0: float64(h * Xcos(tls, y)), + 1: float64(float64(h*h) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + } + } + /* + * sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN. + * The sign of 0 in the result is unspecified. Choice = normally + * the same as dNaN. Raise the invalid floating-point exception. + * + * sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN). + * The sign of 0 in the result is unspecified. Choice = normally + * the same as d(NaN). + */ + if ix|lx == 0 && iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: Xcopysign(tls, Float64FromInt32(0), float64(x*(y-y))), + 1: y - y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * sinh(+-Inf +- I 0) = +-Inf + I +-0. + * + * sinh(NaN +- I 0) = d(NaN) + I +-0. + */ + if iy|ly == 0 && ix >= int32(0x7ff00000) { + if hx&int32(0xfffff)|lx == 0 { + v1 = [2]float64{ + 0: x, + 1: y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v1 = [2]float64{ + 0: x, + 1: Xcopysign(tls, Float64FromInt32(0), y), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * sinh(x +- I Inf) = dNaN + I dNaN. + * Raise the invalid floating-point exception for finite nonzero x. + * + * sinh(x + I NaN) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception for finite + * nonzero x. Choice = don't raise (except for signaling NaNs). + */ + if ix < int32(0x7ff00000) && iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: y - y, + 1: float64(x * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * sinh(+-Inf + I NaN) = +-Inf + I d(NaN). + * The sign of Inf in the result is unspecified. Choice = normally + * the same as d(NaN). + * + * sinh(+-Inf +- I Inf) = +Inf + I dNaN. + * The sign of Inf in the result is unspecified. Choice = always +. + * Raise the invalid floating-point exception. + * + * sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y) + */ + if ix >= int32(0x7ff00000) && hx&int32(0xfffff)|lx == 0 { + if iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: float64(x * x), + 1: float64(x * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v1 = [2]float64{ + 0: float64(x * Xcos(tls, y)), + 1: float64(float64(X__builtin_inff(tls)) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * sinh(NaN + I NaN) = d(NaN) + I d(NaN). + * + * sinh(NaN +- I Inf) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception. + * Choice = raise. + * + * sinh(NaN + I y) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception for finite + * nonzero y. Choice = don't raise (except for signaling NaNs). + */ + v1 = [2]float64{ + 0: float64(float64(x*x) * (y - y)), + 1: float64((x + x) * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +var _huge3 = float32(1.7014118346046923e+38) + +func Xcsinhf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h, x, y float32 + var hx, hy, ix, iy Tint32_t + var v1 [2]float32 + _, _, _, _, _, _, _, _ = h, hx, hy, ix, iy, x, y, v1 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + hx = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(&x))) + hy = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(&y))) + ix = int32(0x7fffffff) & hx + iy = int32(0x7fffffff) & hy + if ix < int32(0x7f800000) && iy < int32(0x7f800000) { + if iy == 0 { + v1 = [2]float32{ + 0: Xsinhf(tls, x), + 1: y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix < int32(0x41100000) { /* small x: normal case */ + v1 = [2]float32{ + 0: float32(Xsinhf(tls, x) * Xcosf(tls, y)), + 1: float32(Xcoshf(tls, x) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + /* |x| >= 9, so cosh(x) ~= exp(|x|) */ + if ix < int32(0x42b17218) { + /* x < 88.7: expf(|x|) won't overflow */ + h = float32(Xexpf(tls, Xfabsf(tls, x)) * Float32FromFloat32(0.5)) + v1 = [2]float32{ + 0: float32(Xcopysignf(tls, h, x) * Xcosf(tls, y)), + 1: float32(h * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + if ix < int32(0x4340b1e7) { + /* x < 192.7: scale to avoid overflow */ + v1 = [2]float32{ + 0: Xfabsf(tls, x), + 1: y, + } + z = X__ldexp_cexpf(tls, *(*complex64)(unsafe.Pointer(&v1)), -int32(1)) + v1 = [2]float32{ + 0: float32(Float32FromComplex64(z) * Xcopysignf(tls, Float32FromInt32(1), x)), + 1: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + /* x >= 192.7: the result always overflows */ + h = float32(_huge3 * x) + v1 = [2]float32{ + 0: float32(h * Xcosf(tls, y)), + 1: float32(float32(h*h) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + } + } + if ix == 0 && iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: Xcopysignf(tls, Float32FromInt32(0), float32(x*(y-y))), + 1: y - y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if iy == 0 && ix >= int32(0x7f800000) { + if hx&int32(0x7fffff) == 0 { + v1 = [2]float32{ + 0: x, + 1: y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: x, + 1: Xcopysignf(tls, Float32FromInt32(0), y), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix < int32(0x7f800000) && iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: y - y, + 1: float32(x * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix >= int32(0x7f800000) && hx&int32(0x7fffff) == 0 { + if iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: float32(x * x), + 1: float32(x * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(x * Xcosf(tls, y)), + 1: float32(X__builtin_inff(tls) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(float32(x*x) * (y - y)), + 1: float32((x + x) * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +// C documentation +// +// //FIXME +func Xcsinhl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcsinh(tls, Complex128FromComplex128(z))) +} + +func Xcsinl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcsin(tls, Complex128FromComplex128(z))) +} + +const THRESH = 7.446288774449766e+307 + +/* + * gcc doesn't implement complex multiplication or division correctly, + * so we need to handle infinities specially. We turn on this pragma to + * notify conforming c99 compilers that the fast-but-incorrect code that + * gcc generates is acceptable, since the special cases have already been + * handled. + */ + +/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */ + +func Xcsqrt(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var a, b, t float64 + var result complex128 + var scale int32 + var v1 [2]float64 + var v2, v5 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _, _ = a, b, result, scale, t, v1, v2, v5 + a = Float64FromComplex128(z) + b = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + /* Handle special cases. */ + if z == Complex128FromInt32(0) { + v1 = [2]float64{ + 1: b, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + *(*float64)(unsafe.Pointer(bp)) = b + v2 = *(*uint64)(unsafe.Pointer(bp)) + goto _3 +_3: + if BoolInt32(v2&(-Uint64FromUint64(1)>>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != 0 { + v1 = [2]float64{ + 0: Xfabs(tls, b-b), + 1: Xcopysign(tls, a, b), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + v1 = [2]float64{ + 0: a, + 1: Xcopysign(tls, b-b, b), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + } + /* + * The remaining special case (b is NaN) is handled just fine by + * the normal code path below. + */ + /* Scale to avoid overflow. */ + if Xfabs(tls, a) >= float64(7.446288774449766e+307) || Xfabs(tls, b) >= float64(7.446288774449766e+307) { + a = a * float64(0.25) + b = b * float64(0.25) + scale = int32(1) + } else { + scale = 0 + } + /* Algorithm 312, CACM vol 10, Oct 1967. */ + if a >= Float64FromInt32(0) { + t = Xsqrt(tls, float64((a+Xhypot(tls, a, b))*float64(0.5))) + v1 = [2]float64{ + 0: t, + 1: b / float64(Float64FromInt32(2)*t), + } + result = *(*complex128)(unsafe.Pointer(&v1)) + } else { + t = Xsqrt(tls, float64((-a+Xhypot(tls, a, b))*float64(0.5))) + v1 = [2]float64{ + 0: Xfabs(tls, b) / float64(Float64FromInt32(2)*t), + 1: Xcopysign(tls, t, b), + } + result = *(*complex128)(unsafe.Pointer(&v1)) + } + /* Rescale. */ + if scale != 0 { + result = result * Complex128FromInt32(2) + } + return result +} + +/* + * gcc doesn't implement complex multiplication or division correctly, + * so we need to handle infinities specially. We turn on this pragma to + * notify conforming c99 compilers that the fast-but-incorrect code that + * gcc generates is acceptable, since the special cases have already been + * handled. + */ + +func Xcsqrtf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var a, b float32 + var t float64 + var v1 [2]float32 + var v2, v5 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _ = a, b, t, v1, v2, v5 + a = Float32FromComplex64(z) + b = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + /* Handle special cases. */ + if z == Complex64FromInt32(0) { + v1 = [2]float32{ + 1: b, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + *(*float32)(unsafe.Pointer(bp)) = b + v2 = *(*uint32)(unsafe.Pointer(bp)) + goto _3 +_3: + if BoolInt32(v2&uint32(0x7fffffff) == uint32(0x7f800000)) != 0 { + v1 = [2]float32{ + 0: X__builtin_inff(tls), + 1: b, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + *(*float32)(unsafe.Pointer(bp)) = a + v2 = *(*uint32)(unsafe.Pointer(bp)) + goto _6 +_6: + if BoolInt32(v2&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + t = float64((b - b) / (b - b)) /* raise invalid if b is not a NaN */ + v1 = [2]float32{ + 0: a, + 1: float32(t), + } + return *(*complex64)(unsafe.Pointer(&v1)) /* return NaN + NaN i */ + } + *(*float32)(unsafe.Pointer(bp)) = a + v2 = *(*uint32)(unsafe.Pointer(bp)) + goto _9 +_9: + if BoolInt32(v2&uint32(0x7fffffff) == uint32(0x7f800000)) != 0 { + /* + * csqrtf(inf + NaN i) = inf + NaN i + * csqrtf(inf + y i) = inf + 0 i + * csqrtf(-inf + NaN i) = NaN +- inf i + * csqrtf(-inf + y i) = 0 + inf i + */ + *(*float32)(unsafe.Pointer(bp)) = a + v5 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v5>>Int32FromInt32(31)) != 0 { + v1 = [2]float32{ + 0: Xfabsf(tls, b-b), + 1: Xcopysignf(tls, a, b), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + v1 = [2]float32{ + 0: a, + 1: Xcopysignf(tls, b-b, b), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + } + /* + * The remaining special case (b is NaN) is handled just fine by + * the normal code path below. + */ + /* + * We compute t in double precision to avoid overflow and to + * provide correct rounding in nearly all cases. + * This is Algorithm 312, CACM vol 10, Oct 1967. + */ + if a >= Float32FromInt32(0) { + t = Xsqrt(tls, float64((float64(a)+Xhypot(tls, float64(a), float64(b)))*float64(0.5))) + v1 = [2]float32{ + 0: float32(t), + 1: float32(float64(b) / float64(Float64FromFloat64(2)*t)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + t = Xsqrt(tls, float64((float64(-a)+Xhypot(tls, float64(a), float64(b)))*float64(0.5))) + v1 = [2]float32{ + 0: float32(float64(Xfabsf(tls, b)) / float64(Float64FromFloat64(2)*t)), + 1: Xcopysignf(tls, float32(t), b), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + return r +} + +// C documentation +// +// //FIXME +func Xcsqrtl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcsqrt(tls, Complex128FromComplex128(z))) +} + +/* tan(z) = -i tanh(i z) */ + +func Xctan(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + z = Xctanh(tls, *(*complex128)(unsafe.Pointer(&v1))) + v1 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xctanf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + z = Xctanhf(tls, *(*complex64)(unsafe.Pointer(&v1))) + v1 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xctanh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var __u1, v3 Tuint64_t + var beta, denom, exp_mx, rho, s, t, x, y, v2 float64 + var hx, ix, lx Tuint32_t + var v1 [2]float64 + var v6 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __u1, beta, denom, exp_mx, hx, ix, lx, rho, s, t, x, y, v1, v2, v3, v6 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + __u1 = *(*Tuint64_t)(unsafe.Pointer(&x)) + hx = uint32(__u1 >> int32(32)) + lx = uint32(__u1) + ix = hx & uint32(0x7fffffff) + /* + * ctanh(NaN + i 0) = NaN + i 0 + * + * ctanh(NaN + i y) = NaN + i NaN for y != 0 + * + * The imaginary part has the sign of x*sin(2*y), but there's no + * special effort to get this right. + * + * ctanh(+-Inf +- i Inf) = +-1 +- 0 + * + * ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite + * + * The imaginary part of the sign is unspecified. This special + * case is only needed to avoid a spurious invalid exception when + * y is infinite. + */ + if ix >= uint32(0x7ff00000) { + if ix&uint32(0xfffff)|lx != 0 { /* x is NaN */ + if y == Float64FromInt32(0) { + v2 = y + } else { + v2 = float64(x * y) + } + v1 = [2]float64{ + 0: x, + 1: v2, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v3 = uint64(hx-Uint32FromInt32(0x40000000))<>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)<= uint32(0x40360000) { /* x >= 22 */ + exp_mx = Xexp(tls, -Xfabs(tls, x)) + v1 = [2]float64{ + 0: Xcopysign(tls, Float64FromInt32(1), x), + 1: float64(float64(float64(float64(Float64FromInt32(4)*Xsin(tls, y))*Xcos(tls, y))*exp_mx) * exp_mx), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* Kahan's algorithm */ + t = Xtan(tls, y) + beta = float64(1) + float64(t*t) /* = 1 / cos^2(y) */ + s = Xsinh(tls, x) + rho = Xsqrt(tls, Float64FromInt32(1)+float64(s*s)) /* = cosh(x) */ + denom = Float64FromInt32(1) + float64(float64(beta*s)*s) + v1 = [2]float64{ + 0: float64(float64(beta*rho)*s) / denom, + 1: t / denom, + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xctanhf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var beta, denom, exp_mx, rho, s, t, x, y, v2 float32 + var hx, ix, v3 Tuint32_t + var v1 [2]float32 + var v6 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = beta, denom, exp_mx, hx, ix, rho, s, t, x, y, v1, v2, v3, v6 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + hx = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = hx & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + if ix&uint32(0x7fffff) != 0 { + if y == Float32FromInt32(0) { + v2 = y + } else { + v2 = float32(x * y) + } + v1 = [2]float32{ + 0: x, + 1: v2, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v3 = hx - uint32(0x40000000) + x = *(*float32)(unsafe.Pointer(&v3)) + *(*float32)(unsafe.Pointer(bp)) = y + v6 = *(*uint32)(unsafe.Pointer(bp)) + goto _7 + _7: + if BoolInt32(v6&uint32(0x7fffffff) == uint32(0x7f800000)) != 0 { + v2 = y + } else { + v2 = float32(Xsinf(tls, y) * Xcosf(tls, y)) + } + v1 = [2]float32{ + 0: x, + 1: Xcopysignf(tls, Float32FromInt32(0), v2), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + *(*float32)(unsafe.Pointer(bp)) = y + v6 = *(*uint32)(unsafe.Pointer(bp)) + goto _9 +_9: + if !(BoolInt32(v6&Uint32FromInt32(0x7fffffff) < Uint32FromInt32(0x7f800000)) != 0) { + if ix != 0 { + v2 = y - y + } else { + v2 = x + } + v1 = [2]float32{ + 0: v2, + 1: y - y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix >= uint32(0x41300000) { /* x >= 11 */ + exp_mx = Xexpf(tls, -Xfabsf(tls, x)) + v1 = [2]float32{ + 0: Xcopysignf(tls, Float32FromInt32(1), x), + 1: float32(float32(float32(float32(Float32FromInt32(4)*Xsinf(tls, y))*Xcosf(tls, y))*exp_mx) * exp_mx), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + t = Xtanf(tls, y) + beta = float32(float64(1) + float64(t*t)) + s = Xsinhf(tls, x) + rho = Xsqrtf(tls, Float32FromInt32(1)+float32(s*s)) + denom = Float32FromInt32(1) + float32(float32(beta*s)*s) + v1 = [2]float32{ + 0: float32(float32(beta*rho)*s) / denom, + 1: t / denom, + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +// C documentation +// +// //FIXME +func Xctanhl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xctanh(tls, Complex128FromComplex128(z))) +} + +func Xctanl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xctan(tls, Complex128FromComplex128(z))) +} + +const BUFSIZ = 1024 +const E2BIG = 7 +const EACCES = 13 +const EADDRINUSE = 98 +const EADDRNOTAVAIL = 99 +const EADV = 68 +const EAFNOSUPPORT = 97 +const EAGAIN = 11 +const EALREADY = 114 +const EBADE = 52 +const EBADF = 9 +const EBADFD = 77 +const EBADMSG = 74 +const EBADR = 53 +const EBADRQC = 56 +const EBADSLT = 57 +const EBFONT = 59 +const EBUSY = 16 +const ECANCELED = 125 +const ECHILD = 10 +const ECHRNG = 44 +const ECOMM = 70 +const ECONNABORTED = 103 +const ECONNREFUSED = 111 +const ECONNRESET = 104 +const EDEADLK = 35 +const EDEADLOCK = 35 +const EDESTADDRREQ = 89 +const EDOM = 33 +const EDOTDOT = 73 +const EDQUOT = 122 +const EEXIST = 17 +const EFAULT = 14 +const EFBIG = 27 +const EHOSTDOWN = 112 +const EHOSTUNREACH = 113 +const EHWPOISON = 133 +const EIDRM = 43 +const EILSEQ = 84 +const EINPROGRESS = 115 +const EINTR = 4 +const EINVAL = 22 +const EIO = 5 +const EISCONN = 106 +const EISDIR = 21 +const EISNAM = 120 +const EKEYEXPIRED = 127 +const EKEYREJECTED = 129 +const EKEYREVOKED = 128 +const EL2HLT = 51 +const EL2NSYNC = 45 +const EL3HLT = 46 +const EL3RST = 47 +const ELIBACC = 79 +const ELIBBAD = 80 +const ELIBEXEC = 83 +const ELIBMAX = 82 +const ELIBSCN = 81 +const ELNRNG = 48 +const ELOOP = 40 +const EMEDIUMTYPE = 124 +const EMFILE = 24 +const EMLINK = 31 +const EMSGSIZE = 90 +const EMULTIHOP = 72 +const ENAMETOOLONG = 36 +const ENAVAIL = 119 +const ENETDOWN = 100 +const ENETRESET = 102 +const ENETUNREACH = 101 +const ENFILE = 23 +const ENOANO = 55 +const ENOBUFS = 105 +const ENOCSI = 50 +const ENODATA = 61 +const ENODEV = 19 +const ENOENT = 2 +const ENOEXEC = 8 +const ENOKEY = 126 +const ENOLCK = 37 +const ENOLINK = 67 +const ENOMEDIUM = 123 +const ENOMEM = 12 +const ENOMSG = 42 +const ENONET = 64 +const ENOPKG = 65 +const ENOPROTOOPT = 92 +const ENOSPC = 28 +const ENOSR = 63 +const ENOSTR = 60 +const ENOSYS = 38 +const ENOTBLK = 15 +const ENOTCONN = 107 +const ENOTDIR = 20 +const ENOTEMPTY = 39 +const ENOTNAM = 118 +const ENOTRECOVERABLE = 131 +const ENOTSOCK = 88 +const ENOTSUP = 95 +const ENOTTY = 25 +const ENOTUNIQ = 76 +const ENXIO = 6 +const EOPNOTSUPP = 95 +const EOVERFLOW = 75 +const EOWNERDEAD = 130 +const EPERM = 1 +const EPFNOSUPPORT = 96 +const EPIPE = 32 +const EPROTO = 71 +const EPROTONOSUPPORT = 93 +const EPROTOTYPE = 91 +const ERANGE = 34 +const EREMCHG = 78 +const EREMOTE = 66 +const EREMOTEIO = 121 +const ERESTART = 85 +const ERFKILL = 132 +const EROFS = 30 +const ESHUTDOWN = 108 +const ESOCKTNOSUPPORT = 94 +const ESPIPE = 29 +const ESRCH = 3 +const ESRMNT = 69 +const ESTALE = 116 +const ESTRPIPE = 86 +const ETIME = 62 +const ETIMEDOUT = 110 +const ETOOMANYREFS = 109 +const ETXTBSY = 26 +const EUCLEAN = 117 +const EUNATCH = 49 +const EUSERS = 87 +const EWOULDBLOCK = 11 +const EXDEV = 18 +const EXFULL = 54 +const FILENAME_MAX = 4096 +const FOPEN_MAX = 1000 +const F_LOCK = 1 +const F_OK = 0 +const F_TEST = 3 +const F_TLOCK = 2 +const F_ULOCK = 0 +const L_ctermid = 20 +const L_tmpnam = 20 +const POSIX_CLOSE_RESTART = 0 +const P_tmpdir = "/tmp" +const R_OK = 4 +const SEEK_DATA = 3 +const SEEK_HOLE = 4 +const STDERR_FILENO = 2 +const STDIN_FILENO = 0 +const STDOUT_FILENO = 1 +const TMP_MAX = 10000 +const W_OK = 2 +const X_OK = 1 +const _CS_GNU_LIBC_VERSION = 2 +const _CS_GNU_LIBPTHREAD_VERSION = 3 +const _CS_PATH = 0 +const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS = 4 +const _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 +const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 +const _CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 +const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 +const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 +const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 +const _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 +const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 +const _CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 +const _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 +const _CS_POSIX_V6_LP64_OFF64_LIBS = 1126 +const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 +const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 +const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 +const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 +const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 +const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 1 +const _CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 +const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 +const _CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 +const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 +const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 +const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 +const _CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 +const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 +const _CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 +const _CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 +const _CS_POSIX_V7_LP64_OFF64_LIBS = 1142 +const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 +const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 +const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 +const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 +const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 +const _CS_POSIX_V7_THREADS_CFLAGS = 1150 +const _CS_POSIX_V7_THREADS_LDFLAGS = 1151 +const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS = 5 +const _CS_V6_ENV = 1148 +const _CS_V7_ENV = 1149 +const _IOFBF = 0 +const _IOLBF = 1 +const _IONBF = 2 +const _PC_2_SYMLINKS = 20 +const _PC_ALLOC_SIZE_MIN = 18 +const _PC_ASYNC_IO = 10 +const _PC_CHOWN_RESTRICTED = 6 +const _PC_FILESIZEBITS = 13 +const _PC_LINK_MAX = 0 +const _PC_MAX_CANON = 1 +const _PC_MAX_INPUT = 2 +const _PC_NAME_MAX = 3 +const _PC_NO_TRUNC = 7 +const _PC_PATH_MAX = 4 +const _PC_PIPE_BUF = 5 +const _PC_PRIO_IO = 11 +const _PC_REC_INCR_XFER_SIZE = 14 +const _PC_REC_MAX_XFER_SIZE = 15 +const _PC_REC_MIN_XFER_SIZE = 16 +const _PC_REC_XFER_ALIGN = 17 +const _PC_SOCK_MAXBUF = 12 +const _PC_SYMLINK_MAX = 19 +const _PC_SYNC_IO = 9 +const _PC_VDISABLE = 8 +const _POSIX2_C_BIND = 200809 +const _POSIX2_VERSION = 200809 +const _POSIX_ADVISORY_INFO = 200809 +const _POSIX_ASYNCHRONOUS_IO = 200809 +const _POSIX_BARRIERS = 200809 +const _POSIX_CHOWN_RESTRICTED = 1 +const _POSIX_CLOCK_SELECTION = 200809 +const _POSIX_CPUTIME = 200809 +const _POSIX_FSYNC = 200809 +const _POSIX_IPV6 = 200809 +const _POSIX_JOB_CONTROL = 1 +const _POSIX_MAPPED_FILES = 200809 +const _POSIX_MEMLOCK = 200809 +const _POSIX_MEMLOCK_RANGE = 200809 +const _POSIX_MEMORY_PROTECTION = 200809 +const _POSIX_MESSAGE_PASSING = 200809 +const _POSIX_MONOTONIC_CLOCK = 200809 +const _POSIX_NO_TRUNC = 1 +const _POSIX_RAW_SOCKETS = 200809 +const _POSIX_READER_WRITER_LOCKS = 200809 +const _POSIX_REALTIME_SIGNALS = 200809 +const _POSIX_REGEXP = 1 +const _POSIX_SAVED_IDS = 1 +const _POSIX_SEMAPHORES = 200809 +const _POSIX_SHARED_MEMORY_OBJECTS = 200809 +const _POSIX_SHELL = 1 +const _POSIX_SPAWN = 200809 +const _POSIX_SPIN_LOCKS = 200809 +const _POSIX_THREADS = 200809 +const _POSIX_THREAD_ATTR_STACKADDR = 200809 +const _POSIX_THREAD_ATTR_STACKSIZE = 200809 +const _POSIX_THREAD_CPUTIME = 200809 +const _POSIX_THREAD_PRIORITY_SCHEDULING = 200809 +const _POSIX_THREAD_PROCESS_SHARED = 200809 +const _POSIX_THREAD_SAFE_FUNCTIONS = 200809 +const _POSIX_TIMEOUTS = 200809 +const _POSIX_TIMERS = 200809 +const _POSIX_V6_LP64_OFF64 = 1 +const _POSIX_V7_LP64_OFF64 = 1 +const _POSIX_VDISABLE = 0 +const _POSIX_VERSION = 200809 +const _SC_2_CHAR_TERM = 95 +const _SC_2_C_BIND = 47 +const _SC_2_C_DEV = 48 +const _SC_2_FORT_DEV = 49 +const _SC_2_FORT_RUN = 50 +const _SC_2_LOCALEDEF = 52 +const _SC_2_PBS = 168 +const _SC_2_PBS_ACCOUNTING = 169 +const _SC_2_PBS_CHECKPOINT = 175 +const _SC_2_PBS_LOCATE = 170 +const _SC_2_PBS_MESSAGE = 171 +const _SC_2_PBS_TRACK = 172 +const _SC_2_SW_DEV = 51 +const _SC_2_UPE = 97 +const _SC_2_VERSION = 46 +const _SC_ADVISORY_INFO = 132 +const _SC_AIO_LISTIO_MAX = 23 +const _SC_AIO_MAX = 24 +const _SC_AIO_PRIO_DELTA_MAX = 25 +const _SC_ARG_MAX = 0 +const _SC_ASYNCHRONOUS_IO = 12 +const _SC_ATEXIT_MAX = 87 +const _SC_AVPHYS_PAGES = 86 +const _SC_BARRIERS = 133 +const _SC_BC_BASE_MAX = 36 +const _SC_BC_DIM_MAX = 37 +const _SC_BC_SCALE_MAX = 38 +const _SC_BC_STRING_MAX = 39 +const _SC_CHILD_MAX = 1 +const _SC_CLK_TCK = 2 +const _SC_CLOCK_SELECTION = 137 +const _SC_COLL_WEIGHTS_MAX = 40 +const _SC_CPUTIME = 138 +const _SC_DELAYTIMER_MAX = 26 +const _SC_EXPR_NEST_MAX = 42 +const _SC_FSYNC = 15 +const _SC_GETGR_R_SIZE_MAX = 69 +const _SC_GETPW_R_SIZE_MAX = 70 +const _SC_HOST_NAME_MAX = 180 +const _SC_IOV_MAX = 60 +const _SC_IPV6 = 235 +const _SC_JOB_CONTROL = 7 +const _SC_LINE_MAX = 43 +const _SC_LOGIN_NAME_MAX = 71 +const _SC_MAPPED_FILES = 16 +const _SC_MEMLOCK = 17 +const _SC_MEMLOCK_RANGE = 18 +const _SC_MEMORY_PROTECTION = 19 +const _SC_MESSAGE_PASSING = 20 +const _SC_MINSIGSTKSZ = 249 +const _SC_MONOTONIC_CLOCK = 149 +const _SC_MQ_OPEN_MAX = 27 +const _SC_MQ_PRIO_MAX = 28 +const _SC_NGROUPS_MAX = 3 +const _SC_NPROCESSORS_CONF = 83 +const _SC_NPROCESSORS_ONLN = 84 +const _SC_NZERO = 109 +const _SC_OPEN_MAX = 4 +const _SC_PAGESIZE = 30 +const _SC_PAGE_SIZE = 30 +const _SC_PASS_MAX = 88 +const _SC_PHYS_PAGES = 85 +const _SC_PRIORITIZED_IO = 13 +const _SC_PRIORITY_SCHEDULING = 10 +const _SC_RAW_SOCKETS = 236 +const _SC_READER_WRITER_LOCKS = 153 +const _SC_REALTIME_SIGNALS = 9 +const _SC_REGEXP = 155 +const _SC_RE_DUP_MAX = 44 +const _SC_RTSIG_MAX = 31 +const _SC_SAVED_IDS = 8 +const _SC_SEMAPHORES = 21 +const _SC_SEM_NSEMS_MAX = 32 +const _SC_SEM_VALUE_MAX = 33 +const _SC_SHARED_MEMORY_OBJECTS = 22 +const _SC_SHELL = 157 +const _SC_SIGQUEUE_MAX = 34 +const _SC_SIGSTKSZ = 250 +const _SC_SPAWN = 159 +const _SC_SPIN_LOCKS = 154 +const _SC_SPORADIC_SERVER = 160 +const _SC_SS_REPL_MAX = 241 +const _SC_STREAMS = 174 +const _SC_STREAM_MAX = 5 +const _SC_SYMLOOP_MAX = 173 +const _SC_SYNCHRONIZED_IO = 14 +const _SC_THREADS = 67 +const _SC_THREAD_ATTR_STACKADDR = 77 +const _SC_THREAD_ATTR_STACKSIZE = 78 +const _SC_THREAD_CPUTIME = 139 +const _SC_THREAD_DESTRUCTOR_ITERATIONS = 73 +const _SC_THREAD_KEYS_MAX = 74 +const _SC_THREAD_PRIORITY_SCHEDULING = 79 +const _SC_THREAD_PRIO_INHERIT = 80 +const _SC_THREAD_PRIO_PROTECT = 81 +const _SC_THREAD_PROCESS_SHARED = 82 +const _SC_THREAD_ROBUST_PRIO_INHERIT = 247 +const _SC_THREAD_ROBUST_PRIO_PROTECT = 248 +const _SC_THREAD_SAFE_FUNCTIONS = 68 +const _SC_THREAD_SPORADIC_SERVER = 161 +const _SC_THREAD_STACK_MIN = 75 +const _SC_THREAD_THREADS_MAX = 76 +const _SC_TIMEOUTS = 164 +const _SC_TIMERS = 11 +const _SC_TIMER_MAX = 35 +const _SC_TRACE = 181 +const _SC_TRACE_EVENT_FILTER = 182 +const _SC_TRACE_EVENT_NAME_MAX = 242 +const _SC_TRACE_INHERIT = 183 +const _SC_TRACE_LOG = 184 +const _SC_TRACE_NAME_MAX = 243 +const _SC_TRACE_SYS_MAX = 244 +const _SC_TRACE_USER_EVENT_MAX = 245 +const _SC_TTY_NAME_MAX = 72 +const _SC_TYPED_MEMORY_OBJECTS = 165 +const _SC_TZNAME_MAX = 6 +const _SC_UIO_MAXIOV = 60 +const _SC_V6_ILP32_OFF32 = 176 +const _SC_V6_ILP32_OFFBIG = 177 +const _SC_V6_LP64_OFF64 = 178 +const _SC_V6_LPBIG_OFFBIG = 179 +const _SC_V7_ILP32_OFF32 = 237 +const _SC_V7_ILP32_OFFBIG = 238 +const _SC_V7_LP64_OFF64 = 239 +const _SC_V7_LPBIG_OFFBIG = 240 +const _SC_VERSION = 29 +const _SC_XBS5_ILP32_OFF32 = 125 +const _SC_XBS5_ILP32_OFFBIG = 126 +const _SC_XBS5_LP64_OFF64 = 127 +const _SC_XBS5_LPBIG_OFFBIG = 128 +const _SC_XOPEN_CRYPT = 92 +const _SC_XOPEN_ENH_I18N = 93 +const _SC_XOPEN_LEGACY = 129 +const _SC_XOPEN_REALTIME = 130 +const _SC_XOPEN_REALTIME_THREADS = 131 +const _SC_XOPEN_SHM = 94 +const _SC_XOPEN_STREAMS = 246 +const _SC_XOPEN_UNIX = 91 +const _SC_XOPEN_VERSION = 89 +const _SC_XOPEN_XCU_VERSION = 90 +const _SC_XOPEN_XPG2 = 98 +const _SC_XOPEN_XPG3 = 99 +const _SC_XOPEN_XPG4 = 100 +const _XOPEN_ENH_I18N = 1 +const _XOPEN_UNIX = 1 +const _XOPEN_VERSION = 700 + +type Tsize_t = uint64 + +type Tssize_t = int64 + +type Toff_t = int64 + +type Tpid_t = int32 + +type Tuid_t = uint32 + +type Tgid_t = uint32 + +type Tuseconds_t = uint32 + +type Tva_list = uintptr + +type t__isoc_va_list = uintptr + +type Tfpos_t = struct { + F__lldata [0]int64 + F__align [0]float64 + F__opaque [16]int8 +} + +type T_G_fpos64_t = Tfpos_t + +func Xconfstr(tls *TLS, name int32, buf uintptr, len1 Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v name=%v buf=%v len1=%v, (%v:)", tls, name, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var s uintptr + _ = s + s = __ccgo_ts + if !(name != 0) { + s = __ccgo_ts + 1 + } else { + if Uint32FromInt32(name) & ^Uint32FromUint32(4) != uint32(1) && Uint32FromInt32(name-int32(_CS_POSIX_V6_ILP32_OFF32_CFLAGS)) > uint32(35) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uint64(0) + } + } + // snprintf is overkill but avoid wasting code size to implement + // this completely useless function and its truncation semantics + return Uint64FromInt32(Xsnprintf(tls, buf, len1, __ccgo_ts+15, VaList(bp+8, s)) + int32(1)) +} + +const ARG_MAX = 131072 +const BC_BASE_MAX = 99 +const BC_DIM_MAX = 2048 +const BC_SCALE_MAX = 99 +const BC_STRING_MAX = 1000 +const CHARCLASS_NAME_MAX = 14 +const CHAR_BIT = 8 +const CHAR_MAX = 255 +const CHAR_MIN = 0 +const COLL_WEIGHTS_MAX = 2 +const DELAYTIMER_MAX = 2147483647 +const EXPR_NEST_MAX = 32 +const FILESIZEBITS = 64 +const HOST_NAME_MAX = 255 +const INT_MAX = 2147483647 +const INT_MIN = -2147483648 +const IOV_MAX = 1024 +const LINE_MAX = 4096 +const LLONG_MAX = 9223372036854775807 +const LLONG_MIN = -9223372036854775808 +const LOGIN_NAME_MAX = 256 +const LONG_BIT = 64 +const LONG_MAX = 9223372036854775807 +const LONG_MIN = -9223372036854775808 +const MB_LEN_MAX = 4 +const MQ_PRIO_MAX = 32768 +const NAME_MAX = 255 +const NGROUPS_MAX = 32 +const NL_ARGMAX = 9 +const NL_LANGMAX = 32 +const NL_MSGMAX = 32767 +const NL_SETMAX = 255 +const NL_TEXTMAX = 2048 +const NZERO = 20 +const PAGESIZE = 4096 +const PAGE_SIZE = 4096 +const PATH_MAX = 4096 +const PIPE_BUF = 4096 +const PTHREAD_DESTRUCTOR_ITERATIONS = 4 +const PTHREAD_KEYS_MAX = 128 +const PTHREAD_STACK_MIN = 2048 +const RE_DUP_MAX = 255 +const SCHAR_MAX = 127 +const SCHAR_MIN = -128 +const SEEK_CUR = 1 +const SEEK_END = 2 +const SEEK_SET = 0 +const SEM_NSEMS_MAX = 256 +const SEM_VALUE_MAX = 2147483647 +const SHRT_MAX = 32767 +const SHRT_MIN = -32768 +const SSIZE_MAX = 9223372036854775807 +const SYMLOOP_MAX = 40 +const TTY_NAME_MAX = 32 +const TZNAME_MAX = 6 +const UCHAR_MAX = 255 +const UINT_MAX = 4294967295 +const ULLONG_MAX = 18446744073709551615 +const ULONG_MAX = 18446744073709551615 +const USHRT_MAX = 65535 +const WORD_BIT = 32 +const _POSIX2_BC_BASE_MAX = 99 +const _POSIX2_BC_DIM_MAX = 2048 +const _POSIX2_BC_SCALE_MAX = 99 +const _POSIX2_BC_STRING_MAX = 1000 +const _POSIX2_CHARCLASS_NAME_MAX = 14 +const _POSIX2_COLL_WEIGHTS_MAX = 2 +const _POSIX2_EXPR_NEST_MAX = 32 +const _POSIX2_LINE_MAX = 2048 +const _POSIX2_RE_DUP_MAX = 255 +const _POSIX_AIO_LISTIO_MAX = 2 +const _POSIX_AIO_MAX = 1 +const _POSIX_ARG_MAX = 4096 +const _POSIX_CHILD_MAX = 25 +const _POSIX_CLOCKRES_MIN = 20000000 +const _POSIX_DELAYTIMER_MAX = 32 +const _POSIX_HOST_NAME_MAX = 255 +const _POSIX_LINK_MAX = 8 +const _POSIX_LOGIN_NAME_MAX = 9 +const _POSIX_MAX_CANON = 255 +const _POSIX_MAX_INPUT = 255 +const _POSIX_MQ_OPEN_MAX = 8 +const _POSIX_MQ_PRIO_MAX = 32 +const _POSIX_NAME_MAX = 14 +const _POSIX_NGROUPS_MAX = 8 +const _POSIX_OPEN_MAX = 20 +const _POSIX_PATH_MAX = 256 +const _POSIX_PIPE_BUF = 512 +const _POSIX_RE_DUP_MAX = 255 +const _POSIX_RTSIG_MAX = 8 +const _POSIX_SEM_NSEMS_MAX = 256 +const _POSIX_SEM_VALUE_MAX = 32767 +const _POSIX_SIGQUEUE_MAX = 32 +const _POSIX_SSIZE_MAX = 32767 +const _POSIX_SS_REPL_MAX = 4 +const _POSIX_STREAM_MAX = 8 +const _POSIX_SYMLINK_MAX = 255 +const _POSIX_SYMLOOP_MAX = 8 +const _POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 +const _POSIX_THREAD_KEYS_MAX = 128 +const _POSIX_THREAD_THREADS_MAX = 64 +const _POSIX_TIMER_MAX = 32 +const _POSIX_TRACE_EVENT_NAME_MAX = 30 +const _POSIX_TRACE_NAME_MAX = 8 +const _POSIX_TRACE_SYS_MAX = 8 +const _POSIX_TRACE_USER_EVENT_MAX = 32 +const _POSIX_TTY_NAME_MAX = 9 +const _POSIX_TZNAME_MAX = 6 +const _XOPEN_IOV_MAX = 16 +const _XOPEN_NAME_MAX = 255 +const _XOPEN_PATH_MAX = 1024 + +func Xfpathconf(tls *TLS, fd int32, name int32) (r int64) { + if __ccgo_strace { + trc("tls=%v fd=%v name=%v, (%v:)", tls, fd, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + if Uint64FromInt32(name) >= Uint64FromInt64(42)/Uint64FromInt64(2) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) + } + return int64(_values[name]) +} + +var _values = [21]int16{ + 0: int16(_POSIX_LINK_MAX), + 1: int16(_POSIX_MAX_CANON), + 2: int16(_POSIX_MAX_INPUT), + 3: int16(NAME_MAX), + 4: int16(PATH_MAX), + 5: int16(PIPE_BUF), + 6: int16(1), + 7: int16(1), + 9: int16(1), + 10: int16(-int32(1)), + 11: int16(-int32(1)), + 12: int16(-int32(1)), + 13: int16(FILESIZEBITS), + 14: int16(4096), + 15: int16(4096), + 16: int16(4096), + 17: int16(4096), + 18: int16(4096), + 19: int16(-int32(1)), + 20: int16(1), +} + +const SI_LOAD_SHIFT = 16 + +type Tsysinfo = struct { + Fuptime uint64 + Floads [3]uint64 + Ftotalram uint64 + Ffreeram uint64 + Fsharedram uint64 + Fbufferram uint64 + Ftotalswap uint64 + Ffreeswap uint64 + Fprocs uint16 + Fpad uint16 + Ftotalhigh uint64 + Ffreehigh uint64 + Fmem_unit uint32 + F__reserved [256]int8 +} + +func Xget_nprocs_conf(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(Xsysconf(tls, int32(_SC_NPROCESSORS_CONF))) +} + +func Xget_nprocs(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(Xsysconf(tls, int32(_SC_NPROCESSORS_ONLN))) +} + +func Xget_phys_pages(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsysconf(tls, int32(_SC_PHYS_PAGES)) +} + +func Xget_avphys_pages(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsysconf(tls, int32(_SC_AVPHYS_PAGES)) +} + +func Xpathconf(tls *TLS, path uintptr, name int32) (r int64) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v, (%v:)", tls, path, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfpathconf(tls, -int32(1), name) +} + +const AT_BASE = 7 +const AT_BASE_PLATFORM = 24 +const AT_CLKTCK = 17 +const AT_DCACHEBSIZE = 19 +const AT_EGID = 14 +const AT_ENTRY = 9 +const AT_EUID = 12 +const AT_EXECFD = 2 +const AT_EXECFN = 31 +const AT_FLAGS = 8 +const AT_FPUCW = 18 +const AT_GID = 13 +const AT_HWCAP = 16 +const AT_HWCAP2 = 26 +const AT_ICACHEBSIZE = 20 +const AT_IGNORE = 1 +const AT_IGNOREPPC = 22 +const AT_L1D_CACHEGEOMETRY = 43 +const AT_L1D_CACHESHAPE = 35 +const AT_L1D_CACHESIZE = 42 +const AT_L1I_CACHEGEOMETRY = 41 +const AT_L1I_CACHESHAPE = 34 +const AT_L1I_CACHESIZE = 40 +const AT_L2_CACHEGEOMETRY = 45 +const AT_L2_CACHESHAPE = 36 +const AT_L2_CACHESIZE = 44 +const AT_L3_CACHEGEOMETRY = 47 +const AT_L3_CACHESHAPE = 37 +const AT_L3_CACHESIZE = 46 +const AT_MINSIGSTKSZ = 51 +const AT_NOTELF = 10 +const AT_NULL = 0 +const AT_PAGESZ = 6 +const AT_PHDR = 3 +const AT_PHENT = 4 +const AT_PHNUM = 5 +const AT_PLATFORM = 15 +const AT_RANDOM = 25 +const AT_SECURE = 23 +const AT_SYSINFO = 32 +const AT_SYSINFO_EHDR = 33 +const AT_UCACHEBSIZE = 21 +const AT_UID = 11 +const BUS_ADRALN = 1 +const BUS_ADRERR = 2 +const BUS_MCEERR_AO = 5 +const BUS_MCEERR_AR = 4 +const BUS_OBJERR = 3 +const CLD_CONTINUED = 6 +const CLD_DUMPED = 3 +const CLD_EXITED = 1 +const CLD_KILLED = 2 +const CLD_STOPPED = 5 +const CLD_TRAPPED = 4 +const DF_1_CONFALT = 8192 +const DF_1_DIRECT = 256 +const DF_1_DISPRELDNE = 32768 +const DF_1_DISPRELPND = 65536 +const DF_1_EDITED = 2097152 +const DF_1_ENDFILTEE = 16384 +const DF_1_GLOBAL = 2 +const DF_1_GLOBAUDIT = 16777216 +const DF_1_GROUP = 4 +const DF_1_IGNMULDEF = 262144 +const DF_1_INITFIRST = 32 +const DF_1_INTERPOSE = 1024 +const DF_1_LOADFLTR = 16 +const DF_1_NODEFLIB = 2048 +const DF_1_NODELETE = 8 +const DF_1_NODIRECT = 131072 +const DF_1_NODUMP = 4096 +const DF_1_NOHDR = 1048576 +const DF_1_NOKSYMS = 524288 +const DF_1_NOOPEN = 64 +const DF_1_NORELOC = 4194304 +const DF_1_NOW = 1 +const DF_1_ORIGIN = 128 +const DF_1_PIE = 134217728 +const DF_1_SINGLETON = 33554432 +const DF_1_STUB = 67108864 +const DF_1_SYMINTPOSE = 8388608 +const DF_1_TRANS = 512 +const DF_BIND_NOW = 8 +const DF_ORIGIN = 1 +const DF_P1_GROUPPERM = 2 +const DF_P1_LAZYLOAD = 1 +const DF_STATIC_TLS = 16 +const DF_SYMBOLIC = 2 +const DF_TEXTREL = 4 +const DTF_1_CONFEXP = 2 +const DTF_1_PARINIT = 1 +const DT_ADDRNUM = 11 +const DT_ADDRRNGHI = 1879047935 +const DT_ADDRRNGLO = 1879047680 +const DT_ALPHA_NUM = 1 +const DT_ALPHA_PLTRO = 1879048192 +const DT_AUDIT = 1879047932 +const DT_AUXILIARY = 2147483645 +const DT_BIND_NOW = 24 +const DT_CHECKSUM = 1879047672 +const DT_CONFIG = 1879047930 +const DT_DEBUG = 21 +const DT_DEPAUDIT = 1879047931 +const DT_ENCODING = 32 +const DT_EXTRANUM = 3 +const DT_FEATURE_1 = 1879047676 +const DT_FILTER = 2147483647 +const DT_FINI = 13 +const DT_FINI_ARRAY = 26 +const DT_FINI_ARRAYSZ = 28 +const DT_FLAGS = 30 +const DT_FLAGS_1 = 1879048187 +const DT_GNU_CONFLICT = 1879047928 +const DT_GNU_CONFLICTSZ = 1879047670 +const DT_GNU_HASH = 1879047925 +const DT_GNU_LIBLIST = 1879047929 +const DT_GNU_LIBLISTSZ = 1879047671 +const DT_GNU_PRELINKED = 1879047669 +const DT_HASH = 4 +const DT_HIOS = 1879044096 +const DT_HIPROC = 2147483647 +const DT_IA_64_NUM = 1 +const DT_IA_64_PLT_RESERVE = 1879048192 +const DT_INIT = 12 +const DT_INIT_ARRAY = 25 +const DT_INIT_ARRAYSZ = 27 +const DT_JMPREL = 23 +const DT_LOOS = 1610612749 +const DT_LOPROC = 1879048192 +const DT_MIPS_AUX_DYNAMIC = 1879048241 +const DT_MIPS_BASE_ADDRESS = 1879048198 +const DT_MIPS_COMPACT_SIZE = 1879048239 +const DT_MIPS_CONFLICT = 1879048200 +const DT_MIPS_CONFLICTNO = 1879048203 +const DT_MIPS_CXX_FLAGS = 1879048226 +const DT_MIPS_DELTA_CLASS = 1879048215 +const DT_MIPS_DELTA_CLASSSYM = 1879048224 +const DT_MIPS_DELTA_CLASSSYM_NO = 1879048225 +const DT_MIPS_DELTA_CLASS_NO = 1879048216 +const DT_MIPS_DELTA_INSTANCE = 1879048217 +const DT_MIPS_DELTA_INSTANCE_NO = 1879048218 +const DT_MIPS_DELTA_RELOC = 1879048219 +const DT_MIPS_DELTA_RELOC_NO = 1879048220 +const DT_MIPS_DELTA_SYM = 1879048221 +const DT_MIPS_DELTA_SYM_NO = 1879048222 +const DT_MIPS_DYNSTR_ALIGN = 1879048235 +const DT_MIPS_FLAGS = 1879048197 +const DT_MIPS_GOTSYM = 1879048211 +const DT_MIPS_GP_VALUE = 1879048240 +const DT_MIPS_HIDDEN_GOTIDX = 1879048231 +const DT_MIPS_HIPAGENO = 1879048212 +const DT_MIPS_ICHECKSUM = 1879048195 +const DT_MIPS_INTERFACE = 1879048234 +const DT_MIPS_INTERFACE_SIZE = 1879048236 +const DT_MIPS_IVERSION = 1879048196 +const DT_MIPS_LIBLIST = 1879048201 +const DT_MIPS_LIBLISTNO = 1879048208 +const DT_MIPS_LOCALPAGE_GOTIDX = 1879048229 +const DT_MIPS_LOCAL_GOTIDX = 1879048230 +const DT_MIPS_LOCAL_GOTNO = 1879048202 +const DT_MIPS_MSYM = 1879048199 +const DT_MIPS_NUM = 54 +const DT_MIPS_OPTIONS = 1879048233 +const DT_MIPS_PERF_SUFFIX = 1879048238 +const DT_MIPS_PIXIE_INIT = 1879048227 +const DT_MIPS_PLTGOT = 1879048242 +const DT_MIPS_PROTECTED_GOTIDX = 1879048232 +const DT_MIPS_RLD_MAP = 1879048214 +const DT_MIPS_RLD_MAP_REL = 1879048245 +const DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 1879048237 +const DT_MIPS_RLD_VERSION = 1879048193 +const DT_MIPS_RWPLT = 1879048244 +const DT_MIPS_SYMBOL_LIB = 1879048228 +const DT_MIPS_SYMTABNO = 1879048209 +const DT_MIPS_TIME_STAMP = 1879048194 +const DT_MIPS_UNREFEXTNO = 1879048210 +const DT_MOVEENT = 1879047674 +const DT_MOVESZ = 1879047675 +const DT_MOVETAB = 1879047934 +const DT_NEEDED = 1 +const DT_NIOS2_GP = 1879048194 +const DT_NULL = 0 +const DT_NUM = 38 +const DT_PLTGOT = 3 +const DT_PLTPAD = 1879047933 +const DT_PLTPADSZ = 1879047673 +const DT_PLTREL = 20 +const DT_PLTRELSZ = 2 +const DT_POSFLAG_1 = 1879047677 +const DT_PPC64_GLINK = 1879048192 +const DT_PPC64_NUM = 4 +const DT_PPC64_OPD = 1879048193 +const DT_PPC64_OPDSZ = 1879048194 +const DT_PPC64_OPT = 1879048195 +const DT_PPC_GOT = 1879048192 +const DT_PPC_NUM = 2 +const DT_PPC_OPT = 1879048193 +const DT_PREINIT_ARRAY = 32 +const DT_PREINIT_ARRAYSZ = 33 +const DT_PROCNUM = 54 +const DT_REL = 17 +const DT_RELA = 7 +const DT_RELACOUNT = 1879048185 +const DT_RELAENT = 9 +const DT_RELASZ = 8 +const DT_RELCOUNT = 1879048186 +const DT_RELENT = 19 +const DT_RELR = 36 +const DT_RELRENT = 37 +const DT_RELRSZ = 35 +const DT_RELSZ = 18 +const DT_RPATH = 15 +const DT_RUNPATH = 29 +const DT_SONAME = 14 +const DT_SPARC_NUM = 2 +const DT_SPARC_REGISTER = 1879048193 +const DT_STRSZ = 10 +const DT_STRTAB = 5 +const DT_SYMBOLIC = 16 +const DT_SYMENT = 11 +const DT_SYMINENT = 1879047679 +const DT_SYMINFO = 1879047935 +const DT_SYMINSZ = 1879047678 +const DT_SYMTAB = 6 +const DT_SYMTAB_SHNDX = 34 +const DT_TEXTREL = 22 +const DT_TLSDESC_GOT = 1879047927 +const DT_TLSDESC_PLT = 1879047926 +const DT_VALNUM = 12 +const DT_VALRNGHI = 1879047679 +const DT_VALRNGLO = 1879047424 +const DT_VERDEF = 1879048188 +const DT_VERDEFNUM = 1879048189 +const DT_VERNEED = 1879048190 +const DT_VERNEEDNUM = 1879048191 +const DT_VERSIONTAGNUM = 16 +const DT_VERSYM = 1879048176 +const EFA_PARISC_1_0 = 523 +const EFA_PARISC_1_1 = 528 +const EFA_PARISC_2_0 = 532 +const EF_ALPHA_32BIT = 1 +const EF_ALPHA_CANRELAX = 2 +const EF_ARM_ABI_FLOAT_HARD = 1024 +const EF_ARM_ABI_FLOAT_SOFT = 512 +const EF_ARM_ALIGN8 = 64 +const EF_ARM_APCS_26 = 8 +const EF_ARM_APCS_FLOAT = 16 +const EF_ARM_BE8 = 8388608 +const EF_ARM_DYNSYMSUSESEGIDX = 8 +const EF_ARM_EABIMASK = 4278190080 +const EF_ARM_EABI_UNKNOWN = 0 +const EF_ARM_EABI_VER1 = 16777216 +const EF_ARM_EABI_VER2 = 33554432 +const EF_ARM_EABI_VER3 = 50331648 +const EF_ARM_EABI_VER4 = 67108864 +const EF_ARM_EABI_VER5 = 83886080 +const EF_ARM_HASENTRY = 2 +const EF_ARM_INTERWORK = 4 +const EF_ARM_LE8 = 4194304 +const EF_ARM_MAPSYMSFIRST = 16 +const EF_ARM_MAVERICK_FLOAT = 2048 +const EF_ARM_NEW_ABI = 128 +const EF_ARM_OLD_ABI = 256 +const EF_ARM_PIC = 32 +const EF_ARM_RELEXEC = 1 +const EF_ARM_SOFT_FLOAT = 512 +const EF_ARM_SYMSARESORTED = 4 +const EF_ARM_VFP_FLOAT = 1024 +const EF_CPU32 = 8454144 +const EF_IA_64_ABI64 = 16 +const EF_IA_64_ARCH = 4278190080 +const EF_IA_64_MASKOS = 15 +const EF_LARCH_ABI_DOUBLE_FLOAT = 3 +const EF_LARCH_ABI_MODIFIER_MASK = 7 +const EF_LARCH_ABI_SINGLE_FLOAT = 2 +const EF_LARCH_ABI_SOFT_FLOAT = 1 +const EF_LARCH_OBJABI_V1 = 64 +const EF_MIPS_64BIT_WHIRL = 16 +const EF_MIPS_ABI2 = 32 +const EF_MIPS_ABI_ON32 = 64 +const EF_MIPS_ARCH = 4026531840 +const EF_MIPS_ARCH_1 = 0 +const EF_MIPS_ARCH_2 = 268435456 +const EF_MIPS_ARCH_3 = 536870912 +const EF_MIPS_ARCH_32 = 1342177280 +const EF_MIPS_ARCH_32R2 = 1879048192 +const EF_MIPS_ARCH_4 = 805306368 +const EF_MIPS_ARCH_5 = 1073741824 +const EF_MIPS_ARCH_64 = 1610612736 +const EF_MIPS_ARCH_64R2 = 2147483648 +const EF_MIPS_CPIC = 4 +const EF_MIPS_FP64 = 512 +const EF_MIPS_NAN2008 = 1024 +const EF_MIPS_NOREORDER = 1 +const EF_MIPS_PIC = 2 +const EF_MIPS_XGOT = 8 +const EF_PARISC_ARCH = 65535 +const EF_PARISC_EXT = 131072 +const EF_PARISC_LAZYSWAP = 4194304 +const EF_PARISC_LSB = 262144 +const EF_PARISC_NO_KABP = 1048576 +const EF_PARISC_TRAPNIL = 65536 +const EF_PARISC_WIDE = 524288 +const EF_PPC64_ABI = 3 +const EF_PPC_EMB = 2147483648 +const EF_PPC_RELOCATABLE = 65536 +const EF_PPC_RELOCATABLE_LIB = 32768 +const EF_SH1 = 1 +const EF_SH2 = 2 +const EF_SH2A = 13 +const EF_SH2A_NOFPU = 19 +const EF_SH2A_SH3E = 24 +const EF_SH2A_SH3_NOFPU = 22 +const EF_SH2A_SH4 = 23 +const EF_SH2A_SH4_NOFPU = 21 +const EF_SH2E = 11 +const EF_SH3 = 3 +const EF_SH3E = 8 +const EF_SH3_DSP = 5 +const EF_SH3_NOMMU = 20 +const EF_SH4 = 9 +const EF_SH4A = 12 +const EF_SH4AL_DSP = 6 +const EF_SH4A_NOFPU = 17 +const EF_SH4_NOFPU = 16 +const EF_SH4_NOMMU_NOFPU = 18 +const EF_SH_DSP = 4 +const EF_SH_MACH_MASK = 31 +const EF_SH_UNKNOWN = 0 +const EF_SPARCV9_MM = 3 +const EF_SPARCV9_PSO = 1 +const EF_SPARCV9_RMO = 2 +const EF_SPARCV9_TSO = 0 +const EF_SPARC_32PLUS = 256 +const EF_SPARC_EXT_MASK = 16776960 +const EF_SPARC_HAL_R1 = 1024 +const EF_SPARC_LEDATA = 8388608 +const EF_SPARC_SUN_US1 = 512 +const EF_SPARC_SUN_US3 = 2048 +const EI_ABIVERSION = 8 +const EI_CLASS = 4 +const EI_DATA = 5 +const EI_MAG0 = 0 +const EI_MAG1 = 1 +const EI_MAG2 = 2 +const EI_MAG3 = 3 +const EI_NIDENT = 16 +const EI_OSABI = 7 +const EI_PAD = 9 +const EI_VERSION = 6 +const ELFCLASS32 = 1 +const ELFCLASS64 = 2 +const ELFCLASSNONE = 0 +const ELFCLASSNUM = 3 +const ELFCOMPRESS_HIOS = 1879048191 +const ELFCOMPRESS_HIPROC = 2147483647 +const ELFCOMPRESS_LOOS = 1610612736 +const ELFCOMPRESS_LOPROC = 1879048192 +const ELFCOMPRESS_ZLIB = 1 +const ELFCOMPRESS_ZSTD = 2 +const ELFDATA2LSB = 1 +const ELFDATA2MSB = 2 +const ELFDATANONE = 0 +const ELFDATANUM = 3 +const ELFMAG = "\\177ELF" +const ELFMAG0 = 127 +const ELFMAG1 = 69 +const ELFMAG2 = 76 +const ELFMAG3 = 70 +const ELFOSABI_AIX = 7 +const ELFOSABI_ARM = 97 +const ELFOSABI_FREEBSD = 9 +const ELFOSABI_GNU = 3 +const ELFOSABI_HPUX = 1 +const ELFOSABI_IRIX = 8 +const ELFOSABI_LINUX = 3 +const ELFOSABI_MODESTO = 11 +const ELFOSABI_NETBSD = 2 +const ELFOSABI_NONE = 0 +const ELFOSABI_OPENBSD = 12 +const ELFOSABI_SOLARIS = 6 +const ELFOSABI_STANDALONE = 255 +const ELFOSABI_SYSV = 0 +const ELFOSABI_TRU64 = 10 +const ELF_NOTE_ABI = 1 +const ELF_NOTE_GNU = "GNU" +const ELF_NOTE_OS_FREEBSD = 3 +const ELF_NOTE_OS_GNU = 1 +const ELF_NOTE_OS_LINUX = 0 +const ELF_NOTE_OS_SOLARIS2 = 2 +const ELF_NOTE_PAGESIZE_HINT = 1 +const ELF_NOTE_SOLARIS = "SUNW Solaris" +const EM_386 = 3 +const EM_56800EX = 200 +const EM_68HC05 = 72 +const EM_68HC08 = 71 +const EM_68HC11 = 70 +const EM_68HC12 = 53 +const EM_68HC16 = 69 +const EM_68K = 4 +const EM_78KOR = 199 +const EM_8051 = 165 +const EM_860 = 7 +const EM_88K = 5 +const EM_960 = 19 +const EM_AARCH64 = 183 +const EM_ALPHA = 36902 +const EM_ALTERA_NIOS2 = 113 +const EM_AMDGPU = 224 +const EM_ARC = 45 +const EM_ARCA = 109 +const EM_ARC_A5 = 93 +const EM_ARC_COMPACT = 93 +const EM_ARC_COMPACT2 = 195 +const EM_ARM = 40 +const EM_AVR = 83 +const EM_AVR32 = 185 +const EM_BA1 = 201 +const EM_BA2 = 202 +const EM_BLACKFIN = 106 +const EM_BPF = 247 +const EM_C166 = 116 +const EM_CDP = 215 +const EM_CE = 119 +const EM_CLOUDSHIELD = 192 +const EM_COGE = 216 +const EM_COLDFIRE = 52 +const EM_COOL = 217 +const EM_COREA_1ST = 193 +const EM_COREA_2ND = 194 +const EM_CR = 103 +const EM_CR16 = 177 +const EM_CRAYNV2 = 172 +const EM_CRIS = 76 +const EM_CRX = 114 +const EM_CSKY = 252 +const EM_CSR_KALIMBA = 219 +const EM_CUDA = 190 +const EM_CYPRESS_M8C = 161 +const EM_D10V = 85 +const EM_D30V = 86 +const EM_DSP24 = 136 +const EM_DSPIC30F = 118 +const EM_DXP = 112 +const EM_ECOG16 = 176 +const EM_ECOG1X = 168 +const EM_ECOG2 = 134 +const EM_EMX16 = 212 +const EM_EMX8 = 213 +const EM_ETPU = 178 +const EM_EXCESS = 111 +const EM_F2MC16 = 104 +const EM_FAKE_ALPHA = 41 +const EM_FIREPATH = 78 +const EM_FR20 = 37 +const EM_FR30 = 84 +const EM_FT32 = 222 +const EM_FX66 = 66 +const EM_H8S = 48 +const EM_H8_300 = 46 +const EM_H8_300H = 47 +const EM_H8_500 = 49 +const EM_HUANY = 81 +const EM_IA_64 = 50 +const EM_IP2K = 101 +const EM_JAVELIN = 77 +const EM_K10M = 181 +const EM_KM32 = 210 +const EM_KMX32 = 211 +const EM_KVARC = 214 +const EM_L10M = 180 +const EM_LATTICEMICO32 = 138 +const EM_LOONGARCH = 258 +const EM_M16C = 117 +const EM_M32 = 1 +const EM_M32C = 120 +const EM_M32R = 88 +const EM_MANIK = 171 +const EM_MAX = 102 +const EM_MAXQ30 = 169 +const EM_MCHP_PIC = 204 +const EM_MCST_ELBRUS = 175 +const EM_ME16 = 59 +const EM_METAG = 174 +const EM_MICROBLAZE = 189 +const EM_MIPS = 8 +const EM_MIPS_RS3_LE = 10 +const EM_MIPS_X = 51 +const EM_MMA = 54 +const EM_MMDSP_PLUS = 160 +const EM_MMIX = 80 +const EM_MN10200 = 90 +const EM_MN10300 = 89 +const EM_MOXIE = 223 +const EM_MSP430 = 105 +const EM_NCPU = 56 +const EM_NDR1 = 57 +const EM_NDS32 = 167 +const EM_NONE = 0 +const EM_NORC = 218 +const EM_NS32K = 97 +const EM_NUM = 259 +const EM_OPEN8 = 196 +const EM_OPENRISC = 92 +const EM_OR1K = 92 +const EM_PARISC = 15 +const EM_PCP = 55 +const EM_PDSP = 63 +const EM_PJ = 91 +const EM_PPC = 20 +const EM_PPC64 = 21 +const EM_PRISM = 82 +const EM_QDSP6 = 164 +const EM_R32C = 162 +const EM_RCE = 39 +const EM_RH32 = 38 +const EM_RISCV = 243 +const EM_RL78 = 197 +const EM_RS08 = 132 +const EM_RX = 173 +const EM_S370 = 9 +const EM_S390 = 22 +const EM_SCORE7 = 135 +const EM_SEP = 108 +const EM_SE_C17 = 139 +const EM_SE_C33 = 107 +const EM_SH = 42 +const EM_SHARC = 133 +const EM_SLE9X = 179 +const EM_SNP1K = 99 +const EM_SPARC = 2 +const EM_SPARC32PLUS = 18 +const EM_SPARCV9 = 43 +const EM_ST100 = 60 +const EM_ST19 = 74 +const EM_ST200 = 100 +const EM_ST7 = 68 +const EM_ST9PLUS = 67 +const EM_STARCORE = 58 +const EM_STM8 = 186 +const EM_STXP7X = 166 +const EM_SVX = 73 +const EM_TILE64 = 187 +const EM_TILEGX = 191 +const EM_TILEPRO = 188 +const EM_TINYJ = 61 +const EM_TI_ARP32 = 143 +const EM_TI_C2000 = 141 +const EM_TI_C5500 = 142 +const EM_TI_C6000 = 140 +const EM_TI_PRU = 144 +const EM_TMM_GPP = 96 +const EM_TPC = 98 +const EM_TRICORE = 44 +const EM_TRIMEDIA = 163 +const EM_TSK3000 = 131 +const EM_UNICORE = 110 +const EM_V800 = 36 +const EM_V850 = 87 +const EM_VAX = 75 +const EM_VIDEOCORE = 95 +const EM_VIDEOCORE3 = 137 +const EM_VIDEOCORE5 = 198 +const EM_VISIUM = 221 +const EM_VPP500 = 17 +const EM_X86_64 = 62 +const EM_XCORE = 203 +const EM_XGATE = 115 +const EM_XIMO16 = 170 +const EM_XTENSA = 94 +const EM_Z80 = 220 +const EM_ZSP = 79 +const ET_CORE = 4 +const ET_DYN = 3 +const ET_EXEC = 2 +const ET_HIOS = 65279 +const ET_HIPROC = 65535 +const ET_LOOS = 65024 +const ET_LOPROC = 65280 +const ET_NONE = 0 +const ET_NUM = 5 +const ET_REL = 1 +const EV_CURRENT = 1 +const EV_NONE = 0 +const EV_NUM = 2 +const EXIT_FAILURE = 1 +const EXIT_SUCCESS = 0 +const E_MIPS_ARCH_1 = 0 +const E_MIPS_ARCH_2 = 268435456 +const E_MIPS_ARCH_3 = 536870912 +const E_MIPS_ARCH_32 = 1342177280 +const E_MIPS_ARCH_4 = 805306368 +const E_MIPS_ARCH_5 = 1073741824 +const E_MIPS_ARCH_64 = 1610612736 +const FD_SETSIZE = 1024 +const FPE_FLTDIV = 3 +const FPE_FLTINV = 7 +const FPE_FLTOVF = 4 +const FPE_FLTRES = 6 +const FPE_FLTSUB = 8 +const FPE_FLTUND = 5 +const FPE_INTDIV = 1 +const FPE_INTOVF = 2 +const GRP_COMDAT = 1 +const ILL_BADSTK = 8 +const ILL_COPROC = 7 +const ILL_ILLADR = 3 +const ILL_ILLOPC = 1 +const ILL_ILLOPN = 2 +const ILL_ILLTRP = 4 +const ILL_PRVOPC = 5 +const ILL_PRVREG = 6 +const IPC_64 = 0 +const ITIMER_PROF = 2 +const ITIMER_REAL = 0 +const ITIMER_VIRTUAL = 1 +const JT_ARG_MAX = -254 +const JT_AVPHYS_PAGES = -247 +const JT_DELAYTIMER_MAX = -245 +const JT_MINSIGSTKSZ = -244 +const JT_MQ_PRIO_MAX = -253 +const JT_NPROCESSORS_CONF = -250 +const JT_NPROCESSORS_ONLN = -249 +const JT_PAGE_SIZE = -252 +const JT_PHYS_PAGES = -248 +const JT_SEM_VALUE_MAX = -251 +const JT_SIGSTKSZ = -243 +const JT_ZERO = -246 +const LITUSE_ALPHA_ADDR = 0 +const LITUSE_ALPHA_BASE = 1 +const LITUSE_ALPHA_BYTOFF = 2 +const LITUSE_ALPHA_JSR = 3 +const LITUSE_ALPHA_TLS_GD = 4 +const LITUSE_ALPHA_TLS_LDM = 5 +const LL_DELAY_LOAD = 16 +const LL_DELTA = 32 +const LL_EXACT_MATCH = 1 +const LL_EXPORTS = 8 +const LL_IGNORE_INT_VER = 2 +const LL_NONE = 0 +const LL_REQUIRE_MINOR = 4 +const MB_CUR_MAX = 0 +const MINSIGSTKSZ = 2048 +const MIPS_AFL_ASE_DSP = 1 +const MIPS_AFL_ASE_DSPR2 = 2 +const MIPS_AFL_ASE_EVA = 4 +const MIPS_AFL_ASE_MASK = 8191 +const MIPS_AFL_ASE_MCU = 8 +const MIPS_AFL_ASE_MDMX = 16 +const MIPS_AFL_ASE_MICROMIPS = 2048 +const MIPS_AFL_ASE_MIPS16 = 1024 +const MIPS_AFL_ASE_MIPS3D = 32 +const MIPS_AFL_ASE_MSA = 512 +const MIPS_AFL_ASE_MT = 64 +const MIPS_AFL_ASE_SMARTMIPS = 128 +const MIPS_AFL_ASE_VIRT = 256 +const MIPS_AFL_ASE_XPA = 4096 +const MIPS_AFL_EXT_10000 = 11 +const MIPS_AFL_EXT_3900 = 10 +const MIPS_AFL_EXT_4010 = 8 +const MIPS_AFL_EXT_4100 = 9 +const MIPS_AFL_EXT_4111 = 13 +const MIPS_AFL_EXT_4120 = 14 +const MIPS_AFL_EXT_4650 = 7 +const MIPS_AFL_EXT_5400 = 15 +const MIPS_AFL_EXT_5500 = 16 +const MIPS_AFL_EXT_5900 = 6 +const MIPS_AFL_EXT_LOONGSON_2E = 17 +const MIPS_AFL_EXT_LOONGSON_2F = 18 +const MIPS_AFL_EXT_LOONGSON_3A = 4 +const MIPS_AFL_EXT_OCTEON = 5 +const MIPS_AFL_EXT_OCTEON2 = 2 +const MIPS_AFL_EXT_OCTEONP = 3 +const MIPS_AFL_EXT_SB1 = 12 +const MIPS_AFL_EXT_XLR = 1 +const MIPS_AFL_FLAGS1_ODDSPREG = 1 +const MIPS_AFL_REG_128 = 3 +const MIPS_AFL_REG_32 = 1 +const MIPS_AFL_REG_64 = 2 +const MIPS_AFL_REG_NONE = 0 +const NT_386_IOPERM = 513 +const NT_386_TLS = 512 +const NT_ARC_V2 = 1536 +const NT_ARM_HW_BREAK = 1026 +const NT_ARM_HW_WATCH = 1027 +const NT_ARM_PACA_KEYS = 1031 +const NT_ARM_PACG_KEYS = 1032 +const NT_ARM_PAC_ENABLED_KEYS = 1034 +const NT_ARM_PAC_MASK = 1030 +const NT_ARM_SVE = 1029 +const NT_ARM_SYSTEM_CALL = 1028 +const NT_ARM_TAGGED_ADDR_CTRL = 1033 +const NT_ARM_TLS = 1025 +const NT_ARM_VFP = 1024 +const NT_ASRS = 8 +const NT_AUXV = 6 +const NT_FILE = 1179208773 +const NT_FPREGSET = 2 +const NT_GNU_ABI_TAG = 1 +const NT_GNU_BUILD_ID = 3 +const NT_GNU_GOLD_VERSION = 4 +const NT_GNU_PROPERTY_TYPE_0 = 5 +const NT_GWINDOWS = 7 +const NT_LOONGARCH_CPUCFG = 2560 +const NT_LOONGARCH_CSR = 2561 +const NT_LOONGARCH_LASX = 2563 +const NT_LOONGARCH_LBT = 2564 +const NT_LOONGARCH_LSX = 2562 +const NT_LWPSINFO = 17 +const NT_LWPSTATUS = 16 +const NT_METAG_CBUF = 1280 +const NT_METAG_RPIPE = 1281 +const NT_METAG_TLS = 1282 +const NT_MIPS_DSP = 2048 +const NT_MIPS_FP_MODE = 2049 +const NT_MIPS_MSA = 2050 +const NT_PLATFORM = 5 +const NT_PPC_DSCR = 261 +const NT_PPC_EBB = 262 +const NT_PPC_PMU = 263 +const NT_PPC_PPR = 260 +const NT_PPC_SPE = 257 +const NT_PPC_TAR = 259 +const NT_PPC_TM_CDSCR = 271 +const NT_PPC_TM_CFPR = 265 +const NT_PPC_TM_CGPR = 264 +const NT_PPC_TM_CPPR = 270 +const NT_PPC_TM_CTAR = 269 +const NT_PPC_TM_CVMX = 266 +const NT_PPC_TM_CVSX = 267 +const NT_PPC_TM_SPR = 268 +const NT_PPC_VMX = 256 +const NT_PPC_VSX = 258 +const NT_PRCRED = 14 +const NT_PRFPREG = 2 +const NT_PRFPXREG = 20 +const NT_PRPSINFO = 3 +const NT_PRSTATUS = 1 +const NT_PRXFPREG = 1189489535 +const NT_PRXREG = 4 +const NT_PSINFO = 13 +const NT_PSTATUS = 10 +const NT_RISCV_CSR = 2304 +const NT_RISCV_VECTOR = 2305 +const NT_S390_CTRS = 772 +const NT_S390_GS_BC = 780 +const NT_S390_GS_CB = 779 +const NT_S390_HIGH_GPRS = 768 +const NT_S390_LAST_BREAK = 774 +const NT_S390_PREFIX = 773 +const NT_S390_RI_CB = 781 +const NT_S390_SYSTEM_CALL = 775 +const NT_S390_TDB = 776 +const NT_S390_TIMER = 769 +const NT_S390_TODCMP = 770 +const NT_S390_TODPREG = 771 +const NT_S390_VXRS_HIGH = 778 +const NT_S390_VXRS_LOW = 777 +const NT_SIGINFO = 1397311305 +const NT_TASKSTRUCT = 4 +const NT_UTSNAME = 15 +const NT_VERSION = 1 +const NT_VMCOREDD = 1792 +const NT_X86_XSTATE = 514 +const ODK_EXCEPTIONS = 2 +const ODK_FILL = 5 +const ODK_HWAND = 7 +const ODK_HWOR = 8 +const ODK_HWPATCH = 4 +const ODK_NULL = 0 +const ODK_PAD = 3 +const ODK_REGINFO = 1 +const ODK_TAGS = 6 +const OEX_DISMISS = 524288 +const OEX_FPDBUG = 262144 +const OEX_FPU_DIV0 = 8 +const OEX_FPU_INEX = 1 +const OEX_FPU_INVAL = 16 +const OEX_FPU_MAX = 7936 +const OEX_FPU_MIN = 31 +const OEX_FPU_OFLO = 4 +const OEX_FPU_UFLO = 2 +const OEX_PAGE0 = 65536 +const OEX_PRECISEFP = 262144 +const OEX_SMM = 131072 +const OHWA0_R4KEOP_CHECKED = 1 +const OHWA1_R4KEOP_CLEAN = 2 +const OHW_R4KEOP = 1 +const OHW_R5KCVTL = 8 +const OHW_R5KEOP = 4 +const OHW_R8KPFETCH = 2 +const OPAD_POSTFIX = 2 +const OPAD_PREFIX = 1 +const OPAD_SYMBOL = 4 +const PF_ARM_ABS = 1073741824 +const PF_ARM_PI = 536870912 +const PF_ARM_SB = 268435456 +const PF_HP_CODE = 16777216 +const PF_HP_FAR_SHARED = 2097152 +const PF_HP_LAZYSWAP = 67108864 +const PF_HP_MODIFY = 33554432 +const PF_HP_NEAR_SHARED = 4194304 +const PF_HP_PAGE_SIZE = 1048576 +const PF_HP_SBP = 134217728 +const PF_IA_64_NORECOV = 2147483648 +const PF_MASKOS = 267386880 +const PF_MASKPROC = 4026531840 +const PF_MIPS_LOCAL = 268435456 +const PF_PARISC_SBP = 134217728 +const PF_R = 4 +const PF_W = 2 +const PF_X = 1 +const PN_XNUM = 65535 +const POLL_ERR = 4 +const POLL_HUP = 6 +const POLL_IN = 1 +const POLL_MSG = 3 +const POLL_OUT = 2 +const POLL_PRI = 5 +const PPC64_OPT_LOCALENTRY = 4 +const PPC64_OPT_MULTI_TOC = 2 +const PPC64_OPT_TLS = 1 +const PPC_OPT_TLS = 1 +const PRIO_MAX = 20 +const PRIO_MIN = -20 +const PRIO_PGRP = 1 +const PRIO_PROCESS = 0 +const PRIO_USER = 2 +const PT_ARM_EXIDX = 1879048193 +const PT_DYNAMIC = 2 +const PT_GNU_EH_FRAME = 1685382480 +const PT_GNU_PROPERTY = 1685382483 +const PT_GNU_RELRO = 1685382482 +const PT_GNU_STACK = 1685382481 +const PT_HIOS = 1879048191 +const PT_HIPROC = 2147483647 +const PT_HISUNW = 1879048191 +const PT_HP_CORE_COMM = 1610612740 +const PT_HP_CORE_KERNEL = 1610612739 +const PT_HP_CORE_LOADABLE = 1610612742 +const PT_HP_CORE_MMF = 1610612745 +const PT_HP_CORE_NONE = 1610612737 +const PT_HP_CORE_PROC = 1610612741 +const PT_HP_CORE_SHM = 1610612744 +const PT_HP_CORE_STACK = 1610612743 +const PT_HP_CORE_VERSION = 1610612738 +const PT_HP_FASTBIND = 1610612753 +const PT_HP_HSL_ANNOT = 1610612755 +const PT_HP_OPT_ANNOT = 1610612754 +const PT_HP_PARALLEL = 1610612752 +const PT_HP_STACK = 1610612756 +const PT_HP_TLS = 1610612736 +const PT_IA_64_ARCHEXT = 1879048192 +const PT_IA_64_HP_HSL_ANOT = 1610612755 +const PT_IA_64_HP_OPT_ANOT = 1610612754 +const PT_IA_64_HP_STACK = 1610612756 +const PT_IA_64_UNWIND = 1879048193 +const PT_INTERP = 3 +const PT_LOAD = 1 +const PT_LOOS = 1610612736 +const PT_LOPROC = 1879048192 +const PT_LOSUNW = 1879048186 +const PT_MIPS_ABIFLAGS = 1879048195 +const PT_MIPS_OPTIONS = 1879048194 +const PT_MIPS_REGINFO = 1879048192 +const PT_MIPS_RTPROC = 1879048193 +const PT_NOTE = 4 +const PT_NULL = 0 +const PT_NUM = 8 +const PT_PARISC_ARCHEXT = 1879048192 +const PT_PARISC_UNWIND = 1879048193 +const PT_PHDR = 6 +const PT_SHLIB = 5 +const PT_SUNWBSS = 1879048186 +const PT_SUNWSTACK = 1879048187 +const PT_TLS = 7 +const RAND_MAX = 2147483647 +const RHF_CORD = 4096 +const RHF_DEFAULT_DELAY_LOAD = 512 +const RHF_DELTA_C_PLUS_PLUS = 64 +const RHF_GUARANTEE_INIT = 32 +const RHF_GUARANTEE_START_INIT = 128 +const RHF_NONE = 0 +const RHF_NOTPOT = 2 +const RHF_NO_LIBRARY_REPLACEMENT = 4 +const RHF_NO_MOVE = 8 +const RHF_NO_UNRES_UNDEF = 8192 +const RHF_PIXIE = 256 +const RHF_QUICKSTART = 1 +const RHF_REQUICKSTART = 1024 +const RHF_REQUICKSTARTED = 2048 +const RHF_RLD_ORDER_SAFE = 16384 +const RHF_SGI_ONLY = 16 +const RLIMIT_AS = 9 +const RLIMIT_CORE = 4 +const RLIMIT_CPU = 0 +const RLIMIT_DATA = 2 +const RLIMIT_FSIZE = 1 +const RLIMIT_LOCKS = 10 +const RLIMIT_MEMLOCK = 8 +const RLIMIT_MSGQUEUE = 12 +const RLIMIT_NICE = 13 +const RLIMIT_NLIMITS = 16 +const RLIMIT_NOFILE = 7 +const RLIMIT_NPROC = 6 +const RLIMIT_RSS = 5 +const RLIMIT_RTPRIO = 14 +const RLIMIT_RTTIME = 15 +const RLIMIT_SIGPENDING = 11 +const RLIMIT_STACK = 3 +const RLIM_INFINITY = 18446744073709551615 +const RLIM_NLIMITS = 16 +const RLIM_SAVED_CUR = 18446744073709551615 +const RLIM_SAVED_MAX = 18446744073709551615 +const RUSAGE_CHILDREN = -1 +const RUSAGE_SELF = 0 +const RUSAGE_THREAD = 1 +const R_386_16 = 20 +const R_386_32 = 1 +const R_386_32PLT = 11 +const R_386_8 = 22 +const R_386_COPY = 5 +const R_386_GLOB_DAT = 6 +const R_386_GOT32 = 3 +const R_386_GOT32X = 43 +const R_386_GOTOFF = 9 +const R_386_GOTPC = 10 +const R_386_IRELATIVE = 42 +const R_386_JMP_SLOT = 7 +const R_386_NONE = 0 +const R_386_NUM = 44 +const R_386_PC16 = 21 +const R_386_PC32 = 2 +const R_386_PC8 = 23 +const R_386_PLT32 = 4 +const R_386_RELATIVE = 8 +const R_386_SIZE32 = 38 +const R_386_TLS_DESC = 41 +const R_386_TLS_DESC_CALL = 40 +const R_386_TLS_DTPMOD32 = 35 +const R_386_TLS_DTPOFF32 = 36 +const R_386_TLS_GD = 18 +const R_386_TLS_GD_32 = 24 +const R_386_TLS_GD_CALL = 26 +const R_386_TLS_GD_POP = 27 +const R_386_TLS_GD_PUSH = 25 +const R_386_TLS_GOTDESC = 39 +const R_386_TLS_GOTIE = 16 +const R_386_TLS_IE = 15 +const R_386_TLS_IE_32 = 33 +const R_386_TLS_LDM = 19 +const R_386_TLS_LDM_32 = 28 +const R_386_TLS_LDM_CALL = 30 +const R_386_TLS_LDM_POP = 31 +const R_386_TLS_LDM_PUSH = 29 +const R_386_TLS_LDO_32 = 32 +const R_386_TLS_LE = 17 +const R_386_TLS_LE_32 = 34 +const R_386_TLS_TPOFF = 14 +const R_386_TLS_TPOFF32 = 37 +const R_390_12 = 2 +const R_390_16 = 3 +const R_390_20 = 57 +const R_390_32 = 4 +const R_390_64 = 22 +const R_390_8 = 1 +const R_390_COPY = 9 +const R_390_GLOB_DAT = 10 +const R_390_GOT12 = 6 +const R_390_GOT16 = 15 +const R_390_GOT20 = 58 +const R_390_GOT32 = 7 +const R_390_GOT64 = 24 +const R_390_GOTENT = 26 +const R_390_GOTOFF16 = 27 +const R_390_GOTOFF32 = 13 +const R_390_GOTOFF64 = 28 +const R_390_GOTPC = 14 +const R_390_GOTPCDBL = 21 +const R_390_GOTPLT12 = 29 +const R_390_GOTPLT16 = 30 +const R_390_GOTPLT20 = 59 +const R_390_GOTPLT32 = 31 +const R_390_GOTPLT64 = 32 +const R_390_GOTPLTENT = 33 +const R_390_JMP_SLOT = 11 +const R_390_NONE = 0 +const R_390_NUM = 61 +const R_390_PC16 = 16 +const R_390_PC16DBL = 17 +const R_390_PC32 = 5 +const R_390_PC32DBL = 19 +const R_390_PC64 = 23 +const R_390_PLT16DBL = 18 +const R_390_PLT32 = 8 +const R_390_PLT32DBL = 20 +const R_390_PLT64 = 25 +const R_390_PLTOFF16 = 34 +const R_390_PLTOFF32 = 35 +const R_390_PLTOFF64 = 36 +const R_390_RELATIVE = 12 +const R_390_TLS_DTPMOD = 54 +const R_390_TLS_DTPOFF = 55 +const R_390_TLS_GD32 = 40 +const R_390_TLS_GD64 = 41 +const R_390_TLS_GDCALL = 38 +const R_390_TLS_GOTIE12 = 42 +const R_390_TLS_GOTIE20 = 60 +const R_390_TLS_GOTIE32 = 43 +const R_390_TLS_GOTIE64 = 44 +const R_390_TLS_IE32 = 47 +const R_390_TLS_IE64 = 48 +const R_390_TLS_IEENT = 49 +const R_390_TLS_LDCALL = 39 +const R_390_TLS_LDM32 = 45 +const R_390_TLS_LDM64 = 46 +const R_390_TLS_LDO32 = 52 +const R_390_TLS_LDO64 = 53 +const R_390_TLS_LE32 = 50 +const R_390_TLS_LE64 = 51 +const R_390_TLS_LOAD = 37 +const R_390_TLS_TPOFF = 56 +const R_68K_16 = 2 +const R_68K_32 = 1 +const R_68K_8 = 3 +const R_68K_COPY = 19 +const R_68K_GLOB_DAT = 20 +const R_68K_GOT16 = 8 +const R_68K_GOT16O = 11 +const R_68K_GOT32 = 7 +const R_68K_GOT32O = 10 +const R_68K_GOT8 = 9 +const R_68K_GOT8O = 12 +const R_68K_JMP_SLOT = 21 +const R_68K_NONE = 0 +const R_68K_NUM = 43 +const R_68K_PC16 = 5 +const R_68K_PC32 = 4 +const R_68K_PC8 = 6 +const R_68K_PLT16 = 14 +const R_68K_PLT16O = 17 +const R_68K_PLT32 = 13 +const R_68K_PLT32O = 16 +const R_68K_PLT8 = 15 +const R_68K_PLT8O = 18 +const R_68K_RELATIVE = 22 +const R_68K_TLS_DTPMOD32 = 40 +const R_68K_TLS_DTPREL32 = 41 +const R_68K_TLS_GD16 = 26 +const R_68K_TLS_GD32 = 25 +const R_68K_TLS_GD8 = 27 +const R_68K_TLS_IE16 = 35 +const R_68K_TLS_IE32 = 34 +const R_68K_TLS_IE8 = 36 +const R_68K_TLS_LDM16 = 29 +const R_68K_TLS_LDM32 = 28 +const R_68K_TLS_LDM8 = 30 +const R_68K_TLS_LDO16 = 32 +const R_68K_TLS_LDO32 = 31 +const R_68K_TLS_LDO8 = 33 +const R_68K_TLS_LE16 = 38 +const R_68K_TLS_LE32 = 37 +const R_68K_TLS_LE8 = 39 +const R_68K_TLS_TPREL32 = 42 +const R_AARCH64_ABS16 = 259 +const R_AARCH64_ABS32 = 258 +const R_AARCH64_ABS64 = 257 +const R_AARCH64_ADD_ABS_LO12_NC = 277 +const R_AARCH64_ADR_GOT_PAGE = 311 +const R_AARCH64_ADR_PREL_LO21 = 274 +const R_AARCH64_ADR_PREL_PG_HI21 = 275 +const R_AARCH64_ADR_PREL_PG_HI21_NC = 276 +const R_AARCH64_CALL26 = 283 +const R_AARCH64_CONDBR19 = 280 +const R_AARCH64_COPY = 1024 +const R_AARCH64_GLOB_DAT = 1025 +const R_AARCH64_GOTREL32 = 308 +const R_AARCH64_GOTREL64 = 307 +const R_AARCH64_GOT_LD_PREL19 = 309 +const R_AARCH64_JUMP26 = 282 +const R_AARCH64_JUMP_SLOT = 1026 +const R_AARCH64_LD64_GOTOFF_LO15 = 310 +const R_AARCH64_LD64_GOTPAGE_LO15 = 313 +const R_AARCH64_LD64_GOT_LO12_NC = 312 +const R_AARCH64_LDST128_ABS_LO12_NC = 299 +const R_AARCH64_LDST16_ABS_LO12_NC = 284 +const R_AARCH64_LDST32_ABS_LO12_NC = 285 +const R_AARCH64_LDST64_ABS_LO12_NC = 286 +const R_AARCH64_LDST8_ABS_LO12_NC = 278 +const R_AARCH64_LD_PREL_LO19 = 273 +const R_AARCH64_MOVW_GOTOFF_G0 = 300 +const R_AARCH64_MOVW_GOTOFF_G0_NC = 301 +const R_AARCH64_MOVW_GOTOFF_G1 = 302 +const R_AARCH64_MOVW_GOTOFF_G1_NC = 303 +const R_AARCH64_MOVW_GOTOFF_G2 = 304 +const R_AARCH64_MOVW_GOTOFF_G2_NC = 305 +const R_AARCH64_MOVW_GOTOFF_G3 = 306 +const R_AARCH64_MOVW_PREL_G0 = 287 +const R_AARCH64_MOVW_PREL_G0_NC = 288 +const R_AARCH64_MOVW_PREL_G1 = 289 +const R_AARCH64_MOVW_PREL_G1_NC = 290 +const R_AARCH64_MOVW_PREL_G2 = 291 +const R_AARCH64_MOVW_PREL_G2_NC = 292 +const R_AARCH64_MOVW_PREL_G3 = 293 +const R_AARCH64_MOVW_SABS_G0 = 270 +const R_AARCH64_MOVW_SABS_G1 = 271 +const R_AARCH64_MOVW_SABS_G2 = 272 +const R_AARCH64_MOVW_UABS_G0 = 263 +const R_AARCH64_MOVW_UABS_G0_NC = 264 +const R_AARCH64_MOVW_UABS_G1 = 265 +const R_AARCH64_MOVW_UABS_G1_NC = 266 +const R_AARCH64_MOVW_UABS_G2 = 267 +const R_AARCH64_MOVW_UABS_G2_NC = 268 +const R_AARCH64_MOVW_UABS_G3 = 269 +const R_AARCH64_NONE = 0 +const R_AARCH64_P32_ABS32 = 1 +const R_AARCH64_P32_COPY = 180 +const R_AARCH64_P32_GLOB_DAT = 181 +const R_AARCH64_P32_IRELATIVE = 188 +const R_AARCH64_P32_JUMP_SLOT = 182 +const R_AARCH64_P32_RELATIVE = 183 +const R_AARCH64_P32_TLSDESC = 187 +const R_AARCH64_P32_TLS_DTPMOD = 184 +const R_AARCH64_P32_TLS_DTPREL = 185 +const R_AARCH64_P32_TLS_TPREL = 186 +const R_AARCH64_PREL16 = 262 +const R_AARCH64_PREL32 = 261 +const R_AARCH64_PREL64 = 260 +const R_AARCH64_RELATIVE = 1027 +const R_AARCH64_TLSDESC = 1031 +const R_AARCH64_TLSDESC_ADD = 568 +const R_AARCH64_TLSDESC_ADD_LO12 = 564 +const R_AARCH64_TLSDESC_ADR_PAGE21 = 562 +const R_AARCH64_TLSDESC_ADR_PREL21 = 561 +const R_AARCH64_TLSDESC_CALL = 569 +const R_AARCH64_TLSDESC_LD64_LO12 = 563 +const R_AARCH64_TLSDESC_LDR = 567 +const R_AARCH64_TLSDESC_LD_PREL19 = 560 +const R_AARCH64_TLSDESC_OFF_G0_NC = 566 +const R_AARCH64_TLSDESC_OFF_G1 = 565 +const R_AARCH64_TLSGD_ADD_LO12_NC = 514 +const R_AARCH64_TLSGD_ADR_PAGE21 = 513 +const R_AARCH64_TLSGD_ADR_PREL21 = 512 +const R_AARCH64_TLSGD_MOVW_G0_NC = 516 +const R_AARCH64_TLSGD_MOVW_G1 = 515 +const R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 541 +const R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 542 +const R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 543 +const R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 540 +const R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 539 +const R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 528 +const R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 529 +const R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 530 +const R_AARCH64_TLSLD_ADD_LO12_NC = 519 +const R_AARCH64_TLSLD_ADR_PAGE21 = 518 +const R_AARCH64_TLSLD_ADR_PREL21 = 517 +const R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572 +const R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573 +const R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 533 +const R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 534 +const R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 535 +const R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 536 +const R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 537 +const R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 538 +const R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 531 +const R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 532 +const R_AARCH64_TLSLD_LD_PREL19 = 522 +const R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 526 +const R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 527 +const R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 524 +const R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 525 +const R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 523 +const R_AARCH64_TLSLD_MOVW_G0_NC = 521 +const R_AARCH64_TLSLD_MOVW_G1 = 520 +const R_AARCH64_TLSLE_ADD_TPREL_HI12 = 549 +const R_AARCH64_TLSLE_ADD_TPREL_LO12 = 550 +const R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 551 +const R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570 +const R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571 +const R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 554 +const R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 555 +const R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 556 +const R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 557 +const R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 558 +const R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 559 +const R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 552 +const R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 553 +const R_AARCH64_TLSLE_MOVW_TPREL_G0 = 547 +const R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 548 +const R_AARCH64_TLSLE_MOVW_TPREL_G1 = 545 +const R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 546 +const R_AARCH64_TLSLE_MOVW_TPREL_G2 = 544 +const R_AARCH64_TLS_DTPMOD = 1028 +const R_AARCH64_TLS_DTPMOD64 = 1028 +const R_AARCH64_TLS_DTPREL = 1029 +const R_AARCH64_TLS_DTPREL64 = 1029 +const R_AARCH64_TLS_TPREL = 1030 +const R_AARCH64_TLS_TPREL64 = 1030 +const R_AARCH64_TSTBR14 = 279 +const R_ALPHA_BRADDR = 7 +const R_ALPHA_COPY = 24 +const R_ALPHA_DTPMOD64 = 31 +const R_ALPHA_DTPREL16 = 36 +const R_ALPHA_DTPREL64 = 33 +const R_ALPHA_DTPRELHI = 34 +const R_ALPHA_DTPRELLO = 35 +const R_ALPHA_GLOB_DAT = 25 +const R_ALPHA_GOTDTPREL = 32 +const R_ALPHA_GOTTPREL = 37 +const R_ALPHA_GPDISP = 6 +const R_ALPHA_GPREL16 = 19 +const R_ALPHA_GPREL32 = 3 +const R_ALPHA_GPRELHIGH = 17 +const R_ALPHA_GPRELLOW = 18 +const R_ALPHA_HINT = 8 +const R_ALPHA_JMP_SLOT = 26 +const R_ALPHA_LITERAL = 4 +const R_ALPHA_LITUSE = 5 +const R_ALPHA_NONE = 0 +const R_ALPHA_NUM = 46 +const R_ALPHA_REFLONG = 1 +const R_ALPHA_REFQUAD = 2 +const R_ALPHA_RELATIVE = 27 +const R_ALPHA_SREL16 = 9 +const R_ALPHA_SREL32 = 10 +const R_ALPHA_SREL64 = 11 +const R_ALPHA_TLSGD = 29 +const R_ALPHA_TLS_GD_HI = 28 +const R_ALPHA_TLS_LDM = 30 +const R_ALPHA_TPREL16 = 41 +const R_ALPHA_TPREL64 = 38 +const R_ALPHA_TPRELHI = 39 +const R_ALPHA_TPRELLO = 40 +const R_ARM_ABS12 = 6 +const R_ARM_ABS16 = 5 +const R_ARM_ABS32 = 2 +const R_ARM_ABS32_NOI = 55 +const R_ARM_ABS8 = 8 +const R_ARM_ALU_PCREL_15_8 = 33 +const R_ARM_ALU_PCREL_23_15 = 34 +const R_ARM_ALU_PCREL_7_0 = 32 +const R_ARM_ALU_PC_G0 = 58 +const R_ARM_ALU_PC_G0_NC = 57 +const R_ARM_ALU_PC_G1 = 60 +const R_ARM_ALU_PC_G1_NC = 59 +const R_ARM_ALU_PC_G2 = 61 +const R_ARM_ALU_SBREL_19_12 = 36 +const R_ARM_ALU_SBREL_27_20 = 37 +const R_ARM_ALU_SB_G0 = 71 +const R_ARM_ALU_SB_G0_NC = 70 +const R_ARM_ALU_SB_G1 = 73 +const R_ARM_ALU_SB_G1_NC = 72 +const R_ARM_ALU_SB_G2 = 74 +const R_ARM_AMP_VCALL9 = 12 +const R_ARM_BASE_ABS = 31 +const R_ARM_CALL = 28 +const R_ARM_COPY = 20 +const R_ARM_GLOB_DAT = 21 +const R_ARM_GNU_VTENTRY = 100 +const R_ARM_GNU_VTINHERIT = 101 +const R_ARM_GOT32 = 26 +const R_ARM_GOTOFF = 24 +const R_ARM_GOTOFF12 = 98 +const R_ARM_GOTPC = 25 +const R_ARM_GOTRELAX = 99 +const R_ARM_GOT_ABS = 95 +const R_ARM_GOT_BREL12 = 97 +const R_ARM_GOT_PREL = 96 +const R_ARM_IRELATIVE = 160 +const R_ARM_JUMP24 = 29 +const R_ARM_JUMP_SLOT = 22 +const R_ARM_LDC_PC_G0 = 67 +const R_ARM_LDC_PC_G1 = 68 +const R_ARM_LDC_PC_G2 = 69 +const R_ARM_LDC_SB_G0 = 81 +const R_ARM_LDC_SB_G1 = 82 +const R_ARM_LDC_SB_G2 = 83 +const R_ARM_LDRS_PC_G0 = 64 +const R_ARM_LDRS_PC_G1 = 65 +const R_ARM_LDRS_PC_G2 = 66 +const R_ARM_LDRS_SB_G0 = 78 +const R_ARM_LDRS_SB_G1 = 79 +const R_ARM_LDRS_SB_G2 = 80 +const R_ARM_LDR_PC_G1 = 62 +const R_ARM_LDR_PC_G2 = 63 +const R_ARM_LDR_SBREL_11_0 = 35 +const R_ARM_LDR_SB_G0 = 75 +const R_ARM_LDR_SB_G1 = 76 +const R_ARM_LDR_SB_G2 = 77 +const R_ARM_ME_TOO = 128 +const R_ARM_MOVT_ABS = 44 +const R_ARM_MOVT_BREL = 85 +const R_ARM_MOVT_PREL = 46 +const R_ARM_MOVW_ABS_NC = 43 +const R_ARM_MOVW_BREL = 86 +const R_ARM_MOVW_BREL_NC = 84 +const R_ARM_MOVW_PREL_NC = 45 +const R_ARM_NONE = 0 +const R_ARM_NUM = 256 +const R_ARM_PC13 = 4 +const R_ARM_PC24 = 1 +const R_ARM_PLT32 = 27 +const R_ARM_PLT32_ABS = 94 +const R_ARM_PREL31 = 42 +const R_ARM_RABS22 = 253 +const R_ARM_RBASE = 255 +const R_ARM_REL32 = 3 +const R_ARM_REL32_NOI = 56 +const R_ARM_RELATIVE = 23 +const R_ARM_RPC24 = 254 +const R_ARM_RREL32 = 252 +const R_ARM_RSBREL32 = 250 +const R_ARM_RXPC25 = 249 +const R_ARM_SBREL31 = 39 +const R_ARM_SBREL32 = 9 +const R_ARM_TARGET1 = 38 +const R_ARM_TARGET2 = 41 +const R_ARM_THM_ABS5 = 7 +const R_ARM_THM_ALU_PREL_11_0 = 53 +const R_ARM_THM_GOT_BREL12 = 131 +const R_ARM_THM_JUMP19 = 51 +const R_ARM_THM_JUMP24 = 30 +const R_ARM_THM_JUMP6 = 52 +const R_ARM_THM_MOVT_ABS = 48 +const R_ARM_THM_MOVT_BREL = 88 +const R_ARM_THM_MOVT_PREL = 50 +const R_ARM_THM_MOVW_ABS_NC = 47 +const R_ARM_THM_MOVW_BREL = 89 +const R_ARM_THM_MOVW_BREL_NC = 87 +const R_ARM_THM_MOVW_PREL_NC = 49 +const R_ARM_THM_PC11 = 102 +const R_ARM_THM_PC12 = 54 +const R_ARM_THM_PC22 = 10 +const R_ARM_THM_PC8 = 11 +const R_ARM_THM_PC9 = 103 +const R_ARM_THM_RPC22 = 251 +const R_ARM_THM_SWI8 = 14 +const R_ARM_THM_TLS_CALL = 93 +const R_ARM_THM_TLS_DESCSEQ = 129 +const R_ARM_THM_TLS_DESCSEQ16 = 129 +const R_ARM_THM_TLS_DESCSEQ32 = 130 +const R_ARM_THM_XPC22 = 16 +const R_ARM_TLS_CALL = 91 +const R_ARM_TLS_DESC = 13 +const R_ARM_TLS_DESCSEQ = 92 +const R_ARM_TLS_DTPMOD32 = 17 +const R_ARM_TLS_DTPOFF32 = 18 +const R_ARM_TLS_GD32 = 104 +const R_ARM_TLS_GOTDESC = 90 +const R_ARM_TLS_IE12GP = 111 +const R_ARM_TLS_IE32 = 107 +const R_ARM_TLS_LDM32 = 105 +const R_ARM_TLS_LDO12 = 109 +const R_ARM_TLS_LDO32 = 106 +const R_ARM_TLS_LE12 = 110 +const R_ARM_TLS_LE32 = 108 +const R_ARM_TLS_TPOFF32 = 19 +const R_ARM_V4BX = 40 +const R_ARM_XPC25 = 15 +const R_BPF_MAP_FD = 1 +const R_BPF_NONE = 0 +const R_CKCORE_ADDR32 = 1 +const R_CKCORE_ADDRGOT = 17 +const R_CKCORE_ADDRGOT_HI16 = 36 +const R_CKCORE_ADDRGOT_LO16 = 37 +const R_CKCORE_ADDRPLT = 18 +const R_CKCORE_ADDRPLT_HI16 = 38 +const R_CKCORE_ADDRPLT_LO16 = 39 +const R_CKCORE_ADDR_HI16 = 24 +const R_CKCORE_ADDR_LO16 = 25 +const R_CKCORE_COPY = 10 +const R_CKCORE_DOFFSET_IMM18 = 44 +const R_CKCORE_DOFFSET_IMM18BY2 = 45 +const R_CKCORE_DOFFSET_IMM18BY4 = 46 +const R_CKCORE_DOFFSET_LO16 = 42 +const R_CKCORE_GLOB_DAT = 11 +const R_CKCORE_GOT12 = 30 +const R_CKCORE_GOT32 = 15 +const R_CKCORE_GOTOFF = 13 +const R_CKCORE_GOTOFF_HI16 = 28 +const R_CKCORE_GOTOFF_LO16 = 29 +const R_CKCORE_GOTPC = 14 +const R_CKCORE_GOTPC_HI16 = 26 +const R_CKCORE_GOTPC_LO16 = 27 +const R_CKCORE_GOT_HI16 = 31 +const R_CKCORE_GOT_IMM18BY4 = 48 +const R_CKCORE_GOT_LO16 = 32 +const R_CKCORE_JUMP_SLOT = 12 +const R_CKCORE_NONE = 0 +const R_CKCORE_PCREL32 = 5 +const R_CKCORE_PCRELIMM11BY2 = 3 +const R_CKCORE_PCRELIMM8BY4 = 2 +const R_CKCORE_PCRELJSR_IMM11BY2 = 6 +const R_CKCORE_PCREL_IMM10BY2 = 22 +const R_CKCORE_PCREL_IMM10BY4 = 23 +const R_CKCORE_PCREL_IMM16BY2 = 20 +const R_CKCORE_PCREL_IMM16BY4 = 21 +const R_CKCORE_PCREL_IMM18BY2 = 43 +const R_CKCORE_PCREL_IMM26BY2 = 19 +const R_CKCORE_PCREL_IMM7BY4 = 50 +const R_CKCORE_PCREL_JSR_IMM26BY2 = 40 +const R_CKCORE_PLT12 = 33 +const R_CKCORE_PLT32 = 16 +const R_CKCORE_PLT_HI16 = 34 +const R_CKCORE_PLT_IMM18BY4 = 49 +const R_CKCORE_PLT_LO16 = 35 +const R_CKCORE_RELATIVE = 9 +const R_CKCORE_TLS_DTPMOD32 = 56 +const R_CKCORE_TLS_DTPOFF32 = 57 +const R_CKCORE_TLS_GD32 = 53 +const R_CKCORE_TLS_IE32 = 52 +const R_CKCORE_TLS_LDM32 = 54 +const R_CKCORE_TLS_LDO32 = 55 +const R_CKCORE_TLS_LE32 = 51 +const R_CKCORE_TLS_TPOFF32 = 58 +const R_CKCORE_TOFFSET_LO16 = 41 +const R_CRIS_16 = 2 +const R_CRIS_16_GOT = 13 +const R_CRIS_16_GOTPLT = 15 +const R_CRIS_16_PCREL = 5 +const R_CRIS_32 = 3 +const R_CRIS_32_GOT = 14 +const R_CRIS_32_GOTPLT = 16 +const R_CRIS_32_GOTREL = 17 +const R_CRIS_32_PCREL = 6 +const R_CRIS_32_PLT_GOTREL = 18 +const R_CRIS_32_PLT_PCREL = 19 +const R_CRIS_8 = 1 +const R_CRIS_8_PCREL = 4 +const R_CRIS_COPY = 9 +const R_CRIS_GLOB_DAT = 10 +const R_CRIS_GNU_VTENTRY = 8 +const R_CRIS_GNU_VTINHERIT = 7 +const R_CRIS_JUMP_SLOT = 11 +const R_CRIS_NONE = 0 +const R_CRIS_NUM = 20 +const R_CRIS_RELATIVE = 12 +const R_IA64_COPY = 132 +const R_IA64_DIR32LSB = 37 +const R_IA64_DIR32MSB = 36 +const R_IA64_DIR64LSB = 39 +const R_IA64_DIR64MSB = 38 +const R_IA64_DTPMOD64LSB = 167 +const R_IA64_DTPMOD64MSB = 166 +const R_IA64_DTPREL14 = 177 +const R_IA64_DTPREL22 = 178 +const R_IA64_DTPREL32LSB = 181 +const R_IA64_DTPREL32MSB = 180 +const R_IA64_DTPREL64I = 179 +const R_IA64_DTPREL64LSB = 183 +const R_IA64_DTPREL64MSB = 182 +const R_IA64_FPTR32LSB = 69 +const R_IA64_FPTR32MSB = 68 +const R_IA64_FPTR64I = 67 +const R_IA64_FPTR64LSB = 71 +const R_IA64_FPTR64MSB = 70 +const R_IA64_GPREL22 = 42 +const R_IA64_GPREL32LSB = 45 +const R_IA64_GPREL32MSB = 44 +const R_IA64_GPREL64I = 43 +const R_IA64_GPREL64LSB = 47 +const R_IA64_GPREL64MSB = 46 +const R_IA64_IMM14 = 33 +const R_IA64_IMM22 = 34 +const R_IA64_IMM64 = 35 +const R_IA64_IPLTLSB = 129 +const R_IA64_IPLTMSB = 128 +const R_IA64_LDXMOV = 135 +const R_IA64_LTOFF22 = 50 +const R_IA64_LTOFF22X = 134 +const R_IA64_LTOFF64I = 51 +const R_IA64_LTOFF_DTPMOD22 = 170 +const R_IA64_LTOFF_DTPREL22 = 186 +const R_IA64_LTOFF_FPTR22 = 82 +const R_IA64_LTOFF_FPTR32LSB = 85 +const R_IA64_LTOFF_FPTR32MSB = 84 +const R_IA64_LTOFF_FPTR64I = 83 +const R_IA64_LTOFF_FPTR64LSB = 87 +const R_IA64_LTOFF_FPTR64MSB = 86 +const R_IA64_LTOFF_TPREL22 = 154 +const R_IA64_LTV32LSB = 117 +const R_IA64_LTV32MSB = 116 +const R_IA64_LTV64LSB = 119 +const R_IA64_LTV64MSB = 118 +const R_IA64_NONE = 0 +const R_IA64_PCREL21B = 73 +const R_IA64_PCREL21BI = 121 +const R_IA64_PCREL21F = 75 +const R_IA64_PCREL21M = 74 +const R_IA64_PCREL22 = 122 +const R_IA64_PCREL32LSB = 77 +const R_IA64_PCREL32MSB = 76 +const R_IA64_PCREL60B = 72 +const R_IA64_PCREL64I = 123 +const R_IA64_PCREL64LSB = 79 +const R_IA64_PCREL64MSB = 78 +const R_IA64_PLTOFF22 = 58 +const R_IA64_PLTOFF64I = 59 +const R_IA64_PLTOFF64LSB = 63 +const R_IA64_PLTOFF64MSB = 62 +const R_IA64_REL32LSB = 109 +const R_IA64_REL32MSB = 108 +const R_IA64_REL64LSB = 111 +const R_IA64_REL64MSB = 110 +const R_IA64_SECREL32LSB = 101 +const R_IA64_SECREL32MSB = 100 +const R_IA64_SECREL64LSB = 103 +const R_IA64_SECREL64MSB = 102 +const R_IA64_SEGREL32LSB = 93 +const R_IA64_SEGREL32MSB = 92 +const R_IA64_SEGREL64LSB = 95 +const R_IA64_SEGREL64MSB = 94 +const R_IA64_SUB = 133 +const R_IA64_TPREL14 = 145 +const R_IA64_TPREL22 = 146 +const R_IA64_TPREL64I = 147 +const R_IA64_TPREL64LSB = 151 +const R_IA64_TPREL64MSB = 150 +const R_LARCH_32 = 1 +const R_LARCH_32_PCREL = 99 +const R_LARCH_64 = 2 +const R_LARCH_ABS64_HI12 = 70 +const R_LARCH_ABS64_LO20 = 69 +const R_LARCH_ABS_HI20 = 67 +const R_LARCH_ABS_LO12 = 68 +const R_LARCH_ADD16 = 48 +const R_LARCH_ADD24 = 49 +const R_LARCH_ADD32 = 50 +const R_LARCH_ADD64 = 51 +const R_LARCH_ADD8 = 47 +const R_LARCH_B16 = 64 +const R_LARCH_B21 = 65 +const R_LARCH_B26 = 66 +const R_LARCH_COPY = 4 +const R_LARCH_GNU_VTENTRY = 58 +const R_LARCH_GNU_VTINHERIT = 57 +const R_LARCH_GOT64_HI12 = 82 +const R_LARCH_GOT64_LO20 = 81 +const R_LARCH_GOT64_PC_HI12 = 78 +const R_LARCH_GOT64_PC_LO20 = 77 +const R_LARCH_GOT_HI20 = 79 +const R_LARCH_GOT_LO12 = 80 +const R_LARCH_GOT_PC_HI20 = 75 +const R_LARCH_GOT_PC_LO12 = 76 +const R_LARCH_IRELATIVE = 12 +const R_LARCH_JUMP_SLOT = 5 +const R_LARCH_MARK_LA = 20 +const R_LARCH_MARK_PCREL = 21 +const R_LARCH_NONE = 0 +const R_LARCH_PCALA64_HI12 = 74 +const R_LARCH_PCALA64_LO20 = 73 +const R_LARCH_PCALA_HI20 = 71 +const R_LARCH_PCALA_LO12 = 72 +const R_LARCH_RELATIVE = 3 +const R_LARCH_RELAX = 100 +const R_LARCH_SOP_ADD = 35 +const R_LARCH_SOP_AND = 36 +const R_LARCH_SOP_ASSERT = 30 +const R_LARCH_SOP_IF_ELSE = 37 +const R_LARCH_SOP_NOT = 31 +const R_LARCH_SOP_POP_32_S_0_10_10_16_S2 = 45 +const R_LARCH_SOP_POP_32_S_0_5_10_16_S2 = 44 +const R_LARCH_SOP_POP_32_S_10_12 = 40 +const R_LARCH_SOP_POP_32_S_10_16 = 41 +const R_LARCH_SOP_POP_32_S_10_16_S2 = 42 +const R_LARCH_SOP_POP_32_S_10_5 = 38 +const R_LARCH_SOP_POP_32_S_5_20 = 43 +const R_LARCH_SOP_POP_32_U = 46 +const R_LARCH_SOP_POP_32_U_10_12 = 39 +const R_LARCH_SOP_PUSH_ABSOLUTE = 23 +const R_LARCH_SOP_PUSH_DUP = 24 +const R_LARCH_SOP_PUSH_GPREL = 25 +const R_LARCH_SOP_PUSH_PCREL = 22 +const R_LARCH_SOP_PUSH_PLT_PCREL = 29 +const R_LARCH_SOP_PUSH_TLS_GD = 28 +const R_LARCH_SOP_PUSH_TLS_GOT = 27 +const R_LARCH_SOP_PUSH_TLS_TPREL = 26 +const R_LARCH_SOP_SL = 33 +const R_LARCH_SOP_SR = 34 +const R_LARCH_SOP_SUB = 32 +const R_LARCH_SUB16 = 53 +const R_LARCH_SUB24 = 54 +const R_LARCH_SUB32 = 55 +const R_LARCH_SUB64 = 56 +const R_LARCH_SUB8 = 52 +const R_LARCH_TLS_DTPMOD32 = 6 +const R_LARCH_TLS_DTPMOD64 = 7 +const R_LARCH_TLS_DTPREL32 = 8 +const R_LARCH_TLS_DTPREL64 = 9 +const R_LARCH_TLS_GD_HI20 = 98 +const R_LARCH_TLS_GD_PC_HI20 = 97 +const R_LARCH_TLS_IE64_HI12 = 94 +const R_LARCH_TLS_IE64_LO20 = 93 +const R_LARCH_TLS_IE64_PC_HI12 = 90 +const R_LARCH_TLS_IE64_PC_LO20 = 89 +const R_LARCH_TLS_IE_HI20 = 91 +const R_LARCH_TLS_IE_LO12 = 92 +const R_LARCH_TLS_IE_PC_HI20 = 87 +const R_LARCH_TLS_IE_PC_LO12 = 88 +const R_LARCH_TLS_LD_HI20 = 96 +const R_LARCH_TLS_LD_PC_HI20 = 95 +const R_LARCH_TLS_LE64_HI12 = 86 +const R_LARCH_TLS_LE64_LO20 = 85 +const R_LARCH_TLS_LE_HI20 = 83 +const R_LARCH_TLS_LE_LO12 = 84 +const R_LARCH_TLS_TPREL32 = 10 +const R_LARCH_TLS_TPREL64 = 11 +const R_M32R_10_PCREL = 4 +const R_M32R_10_PCREL_RELA = 36 +const R_M32R_16 = 1 +const R_M32R_16_RELA = 33 +const R_M32R_18_PCREL = 5 +const R_M32R_18_PCREL_RELA = 37 +const R_M32R_24 = 3 +const R_M32R_24_RELA = 35 +const R_M32R_26_PCREL = 6 +const R_M32R_26_PCREL_RELA = 38 +const R_M32R_26_PLTREL = 49 +const R_M32R_32 = 2 +const R_M32R_32_RELA = 34 +const R_M32R_COPY = 50 +const R_M32R_GLOB_DAT = 51 +const R_M32R_GNU_VTENTRY = 12 +const R_M32R_GNU_VTINHERIT = 11 +const R_M32R_GOT16_HI_SLO = 57 +const R_M32R_GOT16_HI_ULO = 56 +const R_M32R_GOT16_LO = 58 +const R_M32R_GOT24 = 48 +const R_M32R_GOTOFF = 54 +const R_M32R_GOTOFF_HI_SLO = 63 +const R_M32R_GOTOFF_HI_ULO = 62 +const R_M32R_GOTOFF_LO = 64 +const R_M32R_GOTPC24 = 55 +const R_M32R_GOTPC_HI_SLO = 60 +const R_M32R_GOTPC_HI_ULO = 59 +const R_M32R_GOTPC_LO = 61 +const R_M32R_HI16_SLO = 8 +const R_M32R_HI16_SLO_RELA = 40 +const R_M32R_HI16_ULO = 7 +const R_M32R_HI16_ULO_RELA = 39 +const R_M32R_JMP_SLOT = 52 +const R_M32R_LO16 = 9 +const R_M32R_LO16_RELA = 41 +const R_M32R_NONE = 0 +const R_M32R_NUM = 256 +const R_M32R_REL32 = 45 +const R_M32R_RELATIVE = 53 +const R_M32R_RELA_GNU_VTENTRY = 44 +const R_M32R_RELA_GNU_VTINHERIT = 43 +const R_M32R_SDA16 = 10 +const R_M32R_SDA16_RELA = 42 +const R_MICROBLAZE_32 = 1 +const R_MICROBLAZE_32_LO = 6 +const R_MICROBLAZE_32_PCREL = 2 +const R_MICROBLAZE_32_PCREL_LO = 4 +const R_MICROBLAZE_32_SYM_OP_SYM = 10 +const R_MICROBLAZE_64 = 5 +const R_MICROBLAZE_64_NONE = 9 +const R_MICROBLAZE_64_PCREL = 3 +const R_MICROBLAZE_COPY = 21 +const R_MICROBLAZE_GLOB_DAT = 18 +const R_MICROBLAZE_GNU_VTENTRY = 12 +const R_MICROBLAZE_GNU_VTINHERIT = 11 +const R_MICROBLAZE_GOTOFF_32 = 20 +const R_MICROBLAZE_GOTOFF_64 = 19 +const R_MICROBLAZE_GOTPC_64 = 13 +const R_MICROBLAZE_GOT_64 = 14 +const R_MICROBLAZE_JUMP_SLOT = 17 +const R_MICROBLAZE_NONE = 0 +const R_MICROBLAZE_PLT_64 = 15 +const R_MICROBLAZE_REL = 16 +const R_MICROBLAZE_SRO32 = 7 +const R_MICROBLAZE_SRW32 = 8 +const R_MICROBLAZE_TLS = 22 +const R_MICROBLAZE_TLSDTPMOD32 = 25 +const R_MICROBLAZE_TLSDTPREL32 = 26 +const R_MICROBLAZE_TLSDTPREL64 = 27 +const R_MICROBLAZE_TLSGD = 23 +const R_MICROBLAZE_TLSGOTTPREL32 = 28 +const R_MICROBLAZE_TLSLD = 24 +const R_MICROBLAZE_TLSTPREL32 = 29 +const R_MIPS_16 = 1 +const R_MIPS_26 = 4 +const R_MIPS_32 = 2 +const R_MIPS_64 = 18 +const R_MIPS_ADD_IMMEDIATE = 34 +const R_MIPS_CALL16 = 11 +const R_MIPS_CALL_HI16 = 30 +const R_MIPS_CALL_LO16 = 31 +const R_MIPS_COPY = 126 +const R_MIPS_DELETE = 27 +const R_MIPS_GLOB_DAT = 51 +const R_MIPS_GOT16 = 9 +const R_MIPS_GOT_DISP = 19 +const R_MIPS_GOT_HI16 = 22 +const R_MIPS_GOT_LO16 = 23 +const R_MIPS_GOT_OFST = 21 +const R_MIPS_GOT_PAGE = 20 +const R_MIPS_GPREL16 = 7 +const R_MIPS_GPREL32 = 12 +const R_MIPS_HI16 = 5 +const R_MIPS_HIGHER = 28 +const R_MIPS_HIGHEST = 29 +const R_MIPS_INSERT_A = 25 +const R_MIPS_INSERT_B = 26 +const R_MIPS_JALR = 37 +const R_MIPS_JUMP_SLOT = 127 +const R_MIPS_LITERAL = 8 +const R_MIPS_LO16 = 6 +const R_MIPS_NONE = 0 +const R_MIPS_NUM = 128 +const R_MIPS_PC16 = 10 +const R_MIPS_PJUMP = 35 +const R_MIPS_REL16 = 33 +const R_MIPS_REL32 = 3 +const R_MIPS_RELGOT = 36 +const R_MIPS_SCN_DISP = 32 +const R_MIPS_SHIFT5 = 16 +const R_MIPS_SHIFT6 = 17 +const R_MIPS_SUB = 24 +const R_MIPS_TLS_DTPMOD32 = 38 +const R_MIPS_TLS_DTPMOD64 = 40 +const R_MIPS_TLS_DTPREL32 = 39 +const R_MIPS_TLS_DTPREL64 = 41 +const R_MIPS_TLS_DTPREL_HI16 = 44 +const R_MIPS_TLS_DTPREL_LO16 = 45 +const R_MIPS_TLS_GD = 42 +const R_MIPS_TLS_GOTTPREL = 46 +const R_MIPS_TLS_LDM = 43 +const R_MIPS_TLS_TPREL32 = 47 +const R_MIPS_TLS_TPREL64 = 48 +const R_MIPS_TLS_TPREL_HI16 = 49 +const R_MIPS_TLS_TPREL_LO16 = 50 +const R_MN10300_16 = 2 +const R_MN10300_24 = 9 +const R_MN10300_32 = 1 +const R_MN10300_8 = 3 +const R_MN10300_COPY = 20 +const R_MN10300_GLOB_DAT = 21 +const R_MN10300_GNU_VTENTRY = 8 +const R_MN10300_GNU_VTINHERIT = 7 +const R_MN10300_GOT16 = 19 +const R_MN10300_GOT24 = 18 +const R_MN10300_GOT32 = 17 +const R_MN10300_GOTOFF16 = 14 +const R_MN10300_GOTOFF24 = 13 +const R_MN10300_GOTOFF32 = 12 +const R_MN10300_GOTPC16 = 11 +const R_MN10300_GOTPC32 = 10 +const R_MN10300_JMP_SLOT = 22 +const R_MN10300_NONE = 0 +const R_MN10300_NUM = 24 +const R_MN10300_PCREL16 = 5 +const R_MN10300_PCREL32 = 4 +const R_MN10300_PCREL8 = 6 +const R_MN10300_PLT16 = 16 +const R_MN10300_PLT32 = 15 +const R_MN10300_RELATIVE = 23 +const R_NIOS2_ALIGN = 21 +const R_NIOS2_BFD_RELOC_16 = 13 +const R_NIOS2_BFD_RELOC_32 = 12 +const R_NIOS2_BFD_RELOC_8 = 14 +const R_NIOS2_CACHE_OPX = 6 +const R_NIOS2_CALL16 = 23 +const R_NIOS2_CALL26 = 4 +const R_NIOS2_CALL26_NOAT = 41 +const R_NIOS2_CALLR = 20 +const R_NIOS2_CALL_HA = 45 +const R_NIOS2_CALL_LO = 44 +const R_NIOS2_CJMP = 19 +const R_NIOS2_COPY = 36 +const R_NIOS2_GLOB_DAT = 37 +const R_NIOS2_GNU_VTENTRY = 17 +const R_NIOS2_GNU_VTINHERIT = 16 +const R_NIOS2_GOT16 = 22 +const R_NIOS2_GOTOFF = 40 +const R_NIOS2_GOTOFF_HA = 25 +const R_NIOS2_GOTOFF_LO = 24 +const R_NIOS2_GOT_HA = 43 +const R_NIOS2_GOT_LO = 42 +const R_NIOS2_GPREL = 15 +const R_NIOS2_HI16 = 9 +const R_NIOS2_HIADJ16 = 11 +const R_NIOS2_IMM5 = 5 +const R_NIOS2_IMM6 = 7 +const R_NIOS2_IMM8 = 8 +const R_NIOS2_JUMP_SLOT = 38 +const R_NIOS2_LO16 = 10 +const R_NIOS2_NONE = 0 +const R_NIOS2_PCREL16 = 3 +const R_NIOS2_PCREL_HA = 27 +const R_NIOS2_PCREL_LO = 26 +const R_NIOS2_RELATIVE = 39 +const R_NIOS2_S16 = 1 +const R_NIOS2_TLS_DTPMOD = 33 +const R_NIOS2_TLS_DTPREL = 34 +const R_NIOS2_TLS_GD16 = 28 +const R_NIOS2_TLS_IE16 = 31 +const R_NIOS2_TLS_LDM16 = 29 +const R_NIOS2_TLS_LDO16 = 30 +const R_NIOS2_TLS_LE16 = 32 +const R_NIOS2_TLS_TPREL = 35 +const R_NIOS2_U16 = 2 +const R_NIOS2_UJMP = 18 +const R_OR1K_16 = 2 +const R_OR1K_16_PCREL = 10 +const R_OR1K_32 = 1 +const R_OR1K_32_PCREL = 9 +const R_OR1K_8 = 3 +const R_OR1K_8_PCREL = 11 +const R_OR1K_COPY = 18 +const R_OR1K_GLOB_DAT = 19 +const R_OR1K_GNU_VTENTRY = 7 +const R_OR1K_GNU_VTINHERIT = 8 +const R_OR1K_GOT16 = 14 +const R_OR1K_GOTOFF_HI16 = 16 +const R_OR1K_GOTOFF_LO16 = 17 +const R_OR1K_GOTPC_HI16 = 12 +const R_OR1K_GOTPC_LO16 = 13 +const R_OR1K_HI_16_IN_INSN = 5 +const R_OR1K_INSN_REL_26 = 6 +const R_OR1K_JMP_SLOT = 20 +const R_OR1K_LO_16_IN_INSN = 4 +const R_OR1K_NONE = 0 +const R_OR1K_PLT26 = 15 +const R_OR1K_RELATIVE = 21 +const R_OR1K_TLS_DTPMOD = 34 +const R_OR1K_TLS_DTPOFF = 33 +const R_OR1K_TLS_GD_HI16 = 22 +const R_OR1K_TLS_GD_LO16 = 23 +const R_OR1K_TLS_IE_HI16 = 28 +const R_OR1K_TLS_IE_LO16 = 29 +const R_OR1K_TLS_LDM_HI16 = 24 +const R_OR1K_TLS_LDM_LO16 = 25 +const R_OR1K_TLS_LDO_HI16 = 26 +const R_OR1K_TLS_LDO_LO16 = 27 +const R_OR1K_TLS_LE_HI16 = 30 +const R_OR1K_TLS_LE_LO16 = 31 +const R_OR1K_TLS_TPOFF = 32 +const R_PARISC_COPY = 128 +const R_PARISC_DIR14DR = 84 +const R_PARISC_DIR14R = 6 +const R_PARISC_DIR14WR = 83 +const R_PARISC_DIR16DF = 87 +const R_PARISC_DIR16F = 85 +const R_PARISC_DIR16WF = 86 +const R_PARISC_DIR17F = 4 +const R_PARISC_DIR17R = 3 +const R_PARISC_DIR21L = 2 +const R_PARISC_DIR32 = 1 +const R_PARISC_DIR64 = 80 +const R_PARISC_DPREL14R = 22 +const R_PARISC_DPREL21L = 18 +const R_PARISC_EPLT = 130 +const R_PARISC_FPTR64 = 64 +const R_PARISC_GNU_VTENTRY = 232 +const R_PARISC_GNU_VTINHERIT = 233 +const R_PARISC_GPREL14DR = 92 +const R_PARISC_GPREL14R = 30 +const R_PARISC_GPREL14WR = 91 +const R_PARISC_GPREL16DF = 95 +const R_PARISC_GPREL16F = 93 +const R_PARISC_GPREL16WF = 94 +const R_PARISC_GPREL21L = 26 +const R_PARISC_GPREL64 = 88 +const R_PARISC_HIRESERVE = 255 +const R_PARISC_IPLT = 129 +const R_PARISC_LORESERVE = 128 +const R_PARISC_LTOFF14DR = 100 +const R_PARISC_LTOFF14R = 38 +const R_PARISC_LTOFF14WR = 99 +const R_PARISC_LTOFF16DF = 103 +const R_PARISC_LTOFF16F = 101 +const R_PARISC_LTOFF16WF = 102 +const R_PARISC_LTOFF21L = 34 +const R_PARISC_LTOFF64 = 96 +const R_PARISC_LTOFF_FPTR14DR = 124 +const R_PARISC_LTOFF_FPTR14R = 62 +const R_PARISC_LTOFF_FPTR14WR = 123 +const R_PARISC_LTOFF_FPTR16DF = 127 +const R_PARISC_LTOFF_FPTR16F = 125 +const R_PARISC_LTOFF_FPTR16WF = 126 +const R_PARISC_LTOFF_FPTR21L = 58 +const R_PARISC_LTOFF_FPTR32 = 57 +const R_PARISC_LTOFF_FPTR64 = 120 +const R_PARISC_LTOFF_TP14DR = 228 +const R_PARISC_LTOFF_TP14F = 167 +const R_PARISC_LTOFF_TP14R = 166 +const R_PARISC_LTOFF_TP14WR = 227 +const R_PARISC_LTOFF_TP16DF = 231 +const R_PARISC_LTOFF_TP16F = 229 +const R_PARISC_LTOFF_TP16WF = 230 +const R_PARISC_LTOFF_TP21L = 162 +const R_PARISC_LTOFF_TP64 = 224 +const R_PARISC_NONE = 0 +const R_PARISC_PCREL14DR = 76 +const R_PARISC_PCREL14R = 14 +const R_PARISC_PCREL14WR = 75 +const R_PARISC_PCREL16DF = 79 +const R_PARISC_PCREL16F = 77 +const R_PARISC_PCREL16WF = 78 +const R_PARISC_PCREL17F = 12 +const R_PARISC_PCREL17R = 11 +const R_PARISC_PCREL21L = 10 +const R_PARISC_PCREL22F = 74 +const R_PARISC_PCREL32 = 9 +const R_PARISC_PCREL64 = 72 +const R_PARISC_PLABEL14R = 70 +const R_PARISC_PLABEL21L = 66 +const R_PARISC_PLABEL32 = 65 +const R_PARISC_PLTOFF14DR = 116 +const R_PARISC_PLTOFF14R = 54 +const R_PARISC_PLTOFF14WR = 115 +const R_PARISC_PLTOFF16DF = 119 +const R_PARISC_PLTOFF16F = 117 +const R_PARISC_PLTOFF16WF = 118 +const R_PARISC_PLTOFF21L = 50 +const R_PARISC_SECREL32 = 41 +const R_PARISC_SECREL64 = 104 +const R_PARISC_SEGBASE = 48 +const R_PARISC_SEGREL32 = 49 +const R_PARISC_SEGREL64 = 112 +const R_PARISC_TLS_DTPMOD32 = 242 +const R_PARISC_TLS_DTPMOD64 = 243 +const R_PARISC_TLS_DTPOFF32 = 244 +const R_PARISC_TLS_DTPOFF64 = 245 +const R_PARISC_TLS_GD14R = 235 +const R_PARISC_TLS_GD21L = 234 +const R_PARISC_TLS_GDCALL = 236 +const R_PARISC_TLS_IE14R = 166 +const R_PARISC_TLS_IE21L = 162 +const R_PARISC_TLS_LDM14R = 238 +const R_PARISC_TLS_LDM21L = 237 +const R_PARISC_TLS_LDMCALL = 239 +const R_PARISC_TLS_LDO14R = 241 +const R_PARISC_TLS_LDO21L = 240 +const R_PARISC_TLS_LE14R = 158 +const R_PARISC_TLS_LE21L = 154 +const R_PARISC_TLS_TPREL32 = 153 +const R_PARISC_TLS_TPREL64 = 216 +const R_PARISC_TPREL14DR = 220 +const R_PARISC_TPREL14R = 158 +const R_PARISC_TPREL14WR = 219 +const R_PARISC_TPREL16DF = 223 +const R_PARISC_TPREL16F = 221 +const R_PARISC_TPREL16WF = 222 +const R_PARISC_TPREL21L = 154 +const R_PARISC_TPREL32 = 153 +const R_PARISC_TPREL64 = 216 +const R_PPC64_ADDR14 = 7 +const R_PPC64_ADDR14_BRNTAKEN = 9 +const R_PPC64_ADDR14_BRTAKEN = 8 +const R_PPC64_ADDR16 = 3 +const R_PPC64_ADDR16_DS = 56 +const R_PPC64_ADDR16_HA = 6 +const R_PPC64_ADDR16_HI = 5 +const R_PPC64_ADDR16_HIGH = 110 +const R_PPC64_ADDR16_HIGHA = 111 +const R_PPC64_ADDR16_HIGHER = 39 +const R_PPC64_ADDR16_HIGHERA = 40 +const R_PPC64_ADDR16_HIGHEST = 41 +const R_PPC64_ADDR16_HIGHESTA = 42 +const R_PPC64_ADDR16_LO = 4 +const R_PPC64_ADDR16_LO_DS = 57 +const R_PPC64_ADDR24 = 2 +const R_PPC64_ADDR30 = 37 +const R_PPC64_ADDR32 = 1 +const R_PPC64_ADDR64 = 38 +const R_PPC64_COPY = 19 +const R_PPC64_DTPMOD64 = 68 +const R_PPC64_DTPREL16 = 74 +const R_PPC64_DTPREL16_DS = 101 +const R_PPC64_DTPREL16_HA = 77 +const R_PPC64_DTPREL16_HI = 76 +const R_PPC64_DTPREL16_HIGH = 114 +const R_PPC64_DTPREL16_HIGHA = 115 +const R_PPC64_DTPREL16_HIGHER = 103 +const R_PPC64_DTPREL16_HIGHERA = 104 +const R_PPC64_DTPREL16_HIGHEST = 105 +const R_PPC64_DTPREL16_HIGHESTA = 106 +const R_PPC64_DTPREL16_LO = 75 +const R_PPC64_DTPREL16_LO_DS = 102 +const R_PPC64_DTPREL64 = 78 +const R_PPC64_GLOB_DAT = 20 +const R_PPC64_GOT16 = 14 +const R_PPC64_GOT16_DS = 58 +const R_PPC64_GOT16_HA = 17 +const R_PPC64_GOT16_HI = 16 +const R_PPC64_GOT16_LO = 15 +const R_PPC64_GOT16_LO_DS = 59 +const R_PPC64_GOT_DTPREL16_DS = 91 +const R_PPC64_GOT_DTPREL16_HA = 94 +const R_PPC64_GOT_DTPREL16_HI = 93 +const R_PPC64_GOT_DTPREL16_LO_DS = 92 +const R_PPC64_GOT_TLSGD16 = 79 +const R_PPC64_GOT_TLSGD16_HA = 82 +const R_PPC64_GOT_TLSGD16_HI = 81 +const R_PPC64_GOT_TLSGD16_LO = 80 +const R_PPC64_GOT_TLSLD16 = 83 +const R_PPC64_GOT_TLSLD16_HA = 86 +const R_PPC64_GOT_TLSLD16_HI = 85 +const R_PPC64_GOT_TLSLD16_LO = 84 +const R_PPC64_GOT_TPREL16_DS = 87 +const R_PPC64_GOT_TPREL16_HA = 90 +const R_PPC64_GOT_TPREL16_HI = 89 +const R_PPC64_GOT_TPREL16_LO_DS = 88 +const R_PPC64_IRELATIVE = 248 +const R_PPC64_JMP_IREL = 247 +const R_PPC64_JMP_SLOT = 21 +const R_PPC64_NONE = 0 +const R_PPC64_PLT16_HA = 31 +const R_PPC64_PLT16_HI = 30 +const R_PPC64_PLT16_LO = 29 +const R_PPC64_PLT16_LO_DS = 60 +const R_PPC64_PLT32 = 27 +const R_PPC64_PLT64 = 45 +const R_PPC64_PLTGOT16 = 52 +const R_PPC64_PLTGOT16_DS = 65 +const R_PPC64_PLTGOT16_HA = 55 +const R_PPC64_PLTGOT16_HI = 54 +const R_PPC64_PLTGOT16_LO = 53 +const R_PPC64_PLTGOT16_LO_DS = 66 +const R_PPC64_PLTREL32 = 28 +const R_PPC64_PLTREL64 = 46 +const R_PPC64_REL14 = 11 +const R_PPC64_REL14_BRNTAKEN = 13 +const R_PPC64_REL14_BRTAKEN = 12 +const R_PPC64_REL16 = 249 +const R_PPC64_REL16_HA = 252 +const R_PPC64_REL16_HI = 251 +const R_PPC64_REL16_LO = 250 +const R_PPC64_REL24 = 10 +const R_PPC64_REL32 = 26 +const R_PPC64_REL64 = 44 +const R_PPC64_RELATIVE = 22 +const R_PPC64_SECTOFF = 33 +const R_PPC64_SECTOFF_DS = 61 +const R_PPC64_SECTOFF_HA = 36 +const R_PPC64_SECTOFF_HI = 35 +const R_PPC64_SECTOFF_LO = 34 +const R_PPC64_SECTOFF_LO_DS = 62 +const R_PPC64_TLS = 67 +const R_PPC64_TLSGD = 107 +const R_PPC64_TLSLD = 108 +const R_PPC64_TOC = 51 +const R_PPC64_TOC16 = 47 +const R_PPC64_TOC16_DS = 63 +const R_PPC64_TOC16_HA = 50 +const R_PPC64_TOC16_HI = 49 +const R_PPC64_TOC16_LO = 48 +const R_PPC64_TOC16_LO_DS = 64 +const R_PPC64_TOCSAVE = 109 +const R_PPC64_TPREL16 = 69 +const R_PPC64_TPREL16_DS = 95 +const R_PPC64_TPREL16_HA = 72 +const R_PPC64_TPREL16_HI = 71 +const R_PPC64_TPREL16_HIGH = 112 +const R_PPC64_TPREL16_HIGHA = 113 +const R_PPC64_TPREL16_HIGHER = 97 +const R_PPC64_TPREL16_HIGHERA = 98 +const R_PPC64_TPREL16_HIGHEST = 99 +const R_PPC64_TPREL16_HIGHESTA = 100 +const R_PPC64_TPREL16_LO = 70 +const R_PPC64_TPREL16_LO_DS = 96 +const R_PPC64_TPREL64 = 73 +const R_PPC64_UADDR16 = 25 +const R_PPC64_UADDR32 = 24 +const R_PPC64_UADDR64 = 43 +const R_PPC_ADDR14 = 7 +const R_PPC_ADDR14_BRNTAKEN = 9 +const R_PPC_ADDR14_BRTAKEN = 8 +const R_PPC_ADDR16 = 3 +const R_PPC_ADDR16_HA = 6 +const R_PPC_ADDR16_HI = 5 +const R_PPC_ADDR16_LO = 4 +const R_PPC_ADDR24 = 2 +const R_PPC_ADDR32 = 1 +const R_PPC_COPY = 19 +const R_PPC_DIAB_RELSDA_HA = 185 +const R_PPC_DIAB_RELSDA_HI = 184 +const R_PPC_DIAB_RELSDA_LO = 183 +const R_PPC_DIAB_SDA21_HA = 182 +const R_PPC_DIAB_SDA21_HI = 181 +const R_PPC_DIAB_SDA21_LO = 180 +const R_PPC_DTPMOD32 = 68 +const R_PPC_DTPREL16 = 74 +const R_PPC_DTPREL16_HA = 77 +const R_PPC_DTPREL16_HI = 76 +const R_PPC_DTPREL16_LO = 75 +const R_PPC_DTPREL32 = 78 +const R_PPC_EMB_BIT_FLD = 115 +const R_PPC_EMB_MRKREF = 110 +const R_PPC_EMB_NADDR16 = 102 +const R_PPC_EMB_NADDR16_HA = 105 +const R_PPC_EMB_NADDR16_HI = 104 +const R_PPC_EMB_NADDR16_LO = 103 +const R_PPC_EMB_NADDR32 = 101 +const R_PPC_EMB_RELSDA = 116 +const R_PPC_EMB_RELSEC16 = 111 +const R_PPC_EMB_RELST_HA = 114 +const R_PPC_EMB_RELST_HI = 113 +const R_PPC_EMB_RELST_LO = 112 +const R_PPC_EMB_SDA21 = 109 +const R_PPC_EMB_SDA2I16 = 107 +const R_PPC_EMB_SDA2REL = 108 +const R_PPC_EMB_SDAI16 = 106 +const R_PPC_GLOB_DAT = 20 +const R_PPC_GOT16 = 14 +const R_PPC_GOT16_HA = 17 +const R_PPC_GOT16_HI = 16 +const R_PPC_GOT16_LO = 15 +const R_PPC_GOT_DTPREL16 = 91 +const R_PPC_GOT_DTPREL16_HA = 94 +const R_PPC_GOT_DTPREL16_HI = 93 +const R_PPC_GOT_DTPREL16_LO = 92 +const R_PPC_GOT_TLSGD16 = 79 +const R_PPC_GOT_TLSGD16_HA = 82 +const R_PPC_GOT_TLSGD16_HI = 81 +const R_PPC_GOT_TLSGD16_LO = 80 +const R_PPC_GOT_TLSLD16 = 83 +const R_PPC_GOT_TLSLD16_HA = 86 +const R_PPC_GOT_TLSLD16_HI = 85 +const R_PPC_GOT_TLSLD16_LO = 84 +const R_PPC_GOT_TPREL16 = 87 +const R_PPC_GOT_TPREL16_HA = 90 +const R_PPC_GOT_TPREL16_HI = 89 +const R_PPC_GOT_TPREL16_LO = 88 +const R_PPC_IRELATIVE = 248 +const R_PPC_JMP_SLOT = 21 +const R_PPC_LOCAL24PC = 23 +const R_PPC_NONE = 0 +const R_PPC_PLT16_HA = 31 +const R_PPC_PLT16_HI = 30 +const R_PPC_PLT16_LO = 29 +const R_PPC_PLT32 = 27 +const R_PPC_PLTREL24 = 18 +const R_PPC_PLTREL32 = 28 +const R_PPC_REL14 = 11 +const R_PPC_REL14_BRNTAKEN = 13 +const R_PPC_REL14_BRTAKEN = 12 +const R_PPC_REL16 = 249 +const R_PPC_REL16_HA = 252 +const R_PPC_REL16_HI = 251 +const R_PPC_REL16_LO = 250 +const R_PPC_REL24 = 10 +const R_PPC_REL32 = 26 +const R_PPC_RELATIVE = 22 +const R_PPC_SDAREL16 = 32 +const R_PPC_SECTOFF = 33 +const R_PPC_SECTOFF_HA = 36 +const R_PPC_SECTOFF_HI = 35 +const R_PPC_SECTOFF_LO = 34 +const R_PPC_TLS = 67 +const R_PPC_TLSGD = 95 +const R_PPC_TLSLD = 96 +const R_PPC_TOC16 = 255 +const R_PPC_TPREL16 = 69 +const R_PPC_TPREL16_HA = 72 +const R_PPC_TPREL16_HI = 71 +const R_PPC_TPREL16_LO = 70 +const R_PPC_TPREL32 = 73 +const R_PPC_UADDR16 = 25 +const R_PPC_UADDR32 = 24 +const R_RISCV_32 = 1 +const R_RISCV_32_PCREL = 57 +const R_RISCV_64 = 2 +const R_RISCV_ADD16 = 34 +const R_RISCV_ADD32 = 35 +const R_RISCV_ADD64 = 36 +const R_RISCV_ADD8 = 33 +const R_RISCV_ALIGN = 43 +const R_RISCV_BRANCH = 16 +const R_RISCV_CALL = 18 +const R_RISCV_CALL_PLT = 19 +const R_RISCV_COPY = 4 +const R_RISCV_GOT32_PCREL = 41 +const R_RISCV_GOT_HI20 = 20 +const R_RISCV_HI20 = 26 +const R_RISCV_IRELATIVE = 58 +const R_RISCV_JAL = 17 +const R_RISCV_JUMP_SLOT = 5 +const R_RISCV_LO12_I = 27 +const R_RISCV_LO12_S = 28 +const R_RISCV_NONE = 0 +const R_RISCV_PCREL_HI20 = 23 +const R_RISCV_PCREL_LO12_I = 24 +const R_RISCV_PCREL_LO12_S = 25 +const R_RISCV_PLT32 = 59 +const R_RISCV_RELATIVE = 3 +const R_RISCV_RELAX = 51 +const R_RISCV_RVC_BRANCH = 44 +const R_RISCV_RVC_JUMP = 45 +const R_RISCV_RVC_LUI = 46 +const R_RISCV_SET16 = 55 +const R_RISCV_SET32 = 56 +const R_RISCV_SET6 = 53 +const R_RISCV_SET8 = 54 +const R_RISCV_SET_ULEB128 = 60 +const R_RISCV_SUB16 = 38 +const R_RISCV_SUB32 = 39 +const R_RISCV_SUB6 = 52 +const R_RISCV_SUB64 = 40 +const R_RISCV_SUB8 = 37 +const R_RISCV_SUB_ULEB128 = 61 +const R_RISCV_TLSDESC = 12 +const R_RISCV_TLSDESC_ADD_LO12 = 64 +const R_RISCV_TLSDESC_CALL = 65 +const R_RISCV_TLSDESC_HI20 = 62 +const R_RISCV_TLSDESC_LOAD_LO12 = 63 +const R_RISCV_TLS_DTPMOD32 = 6 +const R_RISCV_TLS_DTPMOD64 = 7 +const R_RISCV_TLS_DTPREL32 = 8 +const R_RISCV_TLS_DTPREL64 = 9 +const R_RISCV_TLS_GD_HI20 = 22 +const R_RISCV_TLS_GOT_HI20 = 21 +const R_RISCV_TLS_TPREL32 = 10 +const R_RISCV_TLS_TPREL64 = 11 +const R_RISCV_TPREL_ADD = 32 +const R_RISCV_TPREL_HI20 = 29 +const R_RISCV_TPREL_LO12_I = 30 +const R_RISCV_TPREL_LO12_S = 31 +const R_SH_ALIGN = 29 +const R_SH_CODE = 30 +const R_SH_COPY = 162 +const R_SH_COUNT = 28 +const R_SH_DATA = 31 +const R_SH_DIR32 = 1 +const R_SH_DIR8BP = 7 +const R_SH_DIR8L = 9 +const R_SH_DIR8W = 8 +const R_SH_DIR8WPL = 5 +const R_SH_DIR8WPN = 3 +const R_SH_DIR8WPZ = 6 +const R_SH_FUNCDESC = 207 +const R_SH_FUNCDESC_VALUE = 208 +const R_SH_GLOB_DAT = 163 +const R_SH_GNU_VTENTRY = 35 +const R_SH_GNU_VTINHERIT = 34 +const R_SH_GOT20 = 201 +const R_SH_GOT32 = 160 +const R_SH_GOTFUNCDESC = 203 +const R_SH_GOTFUNCDEST20 = 204 +const R_SH_GOTOFF = 166 +const R_SH_GOTOFF20 = 202 +const R_SH_GOTOFFFUNCDESC = 205 +const R_SH_GOTOFFFUNCDEST20 = 206 +const R_SH_GOTPC = 167 +const R_SH_IND12W = 4 +const R_SH_JMP_SLOT = 164 +const R_SH_LABEL = 32 +const R_SH_NONE = 0 +const R_SH_NUM = 256 +const R_SH_PLT32 = 161 +const R_SH_REL32 = 2 +const R_SH_RELATIVE = 165 +const R_SH_SWITCH16 = 25 +const R_SH_SWITCH32 = 26 +const R_SH_SWITCH8 = 33 +const R_SH_TLS_DTPMOD32 = 149 +const R_SH_TLS_DTPOFF32 = 150 +const R_SH_TLS_GD_32 = 144 +const R_SH_TLS_IE_32 = 147 +const R_SH_TLS_LDO_32 = 146 +const R_SH_TLS_LD_32 = 145 +const R_SH_TLS_LE_32 = 148 +const R_SH_TLS_TPOFF32 = 151 +const R_SH_USES = 27 +const R_SPARC_10 = 30 +const R_SPARC_11 = 31 +const R_SPARC_13 = 11 +const R_SPARC_16 = 2 +const R_SPARC_22 = 10 +const R_SPARC_32 = 3 +const R_SPARC_5 = 44 +const R_SPARC_6 = 45 +const R_SPARC_64 = 32 +const R_SPARC_7 = 43 +const R_SPARC_8 = 1 +const R_SPARC_COPY = 19 +const R_SPARC_DISP16 = 5 +const R_SPARC_DISP32 = 6 +const R_SPARC_DISP64 = 46 +const R_SPARC_DISP8 = 4 +const R_SPARC_GLOB_DAT = 20 +const R_SPARC_GLOB_JMP = 42 +const R_SPARC_GNU_VTENTRY = 251 +const R_SPARC_GNU_VTINHERIT = 250 +const R_SPARC_GOT10 = 13 +const R_SPARC_GOT13 = 14 +const R_SPARC_GOT22 = 15 +const R_SPARC_GOTDATA_HIX22 = 80 +const R_SPARC_GOTDATA_LOX10 = 81 +const R_SPARC_GOTDATA_OP = 84 +const R_SPARC_GOTDATA_OP_HIX22 = 82 +const R_SPARC_GOTDATA_OP_LOX10 = 83 +const R_SPARC_H34 = 85 +const R_SPARC_H44 = 50 +const R_SPARC_HH22 = 34 +const R_SPARC_HI22 = 9 +const R_SPARC_HIPLT22 = 25 +const R_SPARC_HIX22 = 48 +const R_SPARC_HM10 = 35 +const R_SPARC_JMP_SLOT = 21 +const R_SPARC_L44 = 52 +const R_SPARC_LM22 = 36 +const R_SPARC_LO10 = 12 +const R_SPARC_LOPLT10 = 26 +const R_SPARC_LOX10 = 49 +const R_SPARC_M44 = 51 +const R_SPARC_NONE = 0 +const R_SPARC_NUM = 253 +const R_SPARC_OLO10 = 33 +const R_SPARC_PC10 = 16 +const R_SPARC_PC22 = 17 +const R_SPARC_PCPLT10 = 29 +const R_SPARC_PCPLT22 = 28 +const R_SPARC_PCPLT32 = 27 +const R_SPARC_PC_HH22 = 37 +const R_SPARC_PC_HM10 = 38 +const R_SPARC_PC_LM22 = 39 +const R_SPARC_PLT32 = 24 +const R_SPARC_PLT64 = 47 +const R_SPARC_REGISTER = 53 +const R_SPARC_RELATIVE = 22 +const R_SPARC_REV32 = 252 +const R_SPARC_SIZE32 = 86 +const R_SPARC_SIZE64 = 87 +const R_SPARC_TLS_DTPMOD32 = 74 +const R_SPARC_TLS_DTPMOD64 = 75 +const R_SPARC_TLS_DTPOFF32 = 76 +const R_SPARC_TLS_DTPOFF64 = 77 +const R_SPARC_TLS_GD_ADD = 58 +const R_SPARC_TLS_GD_CALL = 59 +const R_SPARC_TLS_GD_HI22 = 56 +const R_SPARC_TLS_GD_LO10 = 57 +const R_SPARC_TLS_IE_ADD = 71 +const R_SPARC_TLS_IE_HI22 = 67 +const R_SPARC_TLS_IE_LD = 69 +const R_SPARC_TLS_IE_LDX = 70 +const R_SPARC_TLS_IE_LO10 = 68 +const R_SPARC_TLS_LDM_ADD = 62 +const R_SPARC_TLS_LDM_CALL = 63 +const R_SPARC_TLS_LDM_HI22 = 60 +const R_SPARC_TLS_LDM_LO10 = 61 +const R_SPARC_TLS_LDO_ADD = 66 +const R_SPARC_TLS_LDO_HIX22 = 64 +const R_SPARC_TLS_LDO_LOX10 = 65 +const R_SPARC_TLS_LE_HIX22 = 72 +const R_SPARC_TLS_LE_LOX10 = 73 +const R_SPARC_TLS_TPOFF32 = 78 +const R_SPARC_TLS_TPOFF64 = 79 +const R_SPARC_UA16 = 55 +const R_SPARC_UA32 = 23 +const R_SPARC_UA64 = 54 +const R_SPARC_WDISP16 = 40 +const R_SPARC_WDISP19 = 41 +const R_SPARC_WDISP22 = 8 +const R_SPARC_WDISP30 = 7 +const R_SPARC_WPLT30 = 18 +const R_X86_64_16 = 12 +const R_X86_64_32 = 10 +const R_X86_64_32S = 11 +const R_X86_64_64 = 1 +const R_X86_64_8 = 14 +const R_X86_64_COPY = 5 +const R_X86_64_DTPMOD64 = 16 +const R_X86_64_DTPOFF32 = 21 +const R_X86_64_DTPOFF64 = 17 +const R_X86_64_GLOB_DAT = 6 +const R_X86_64_GOT32 = 3 +const R_X86_64_GOT64 = 27 +const R_X86_64_GOTOFF64 = 25 +const R_X86_64_GOTPC32 = 26 +const R_X86_64_GOTPC32_TLSDESC = 34 +const R_X86_64_GOTPC64 = 29 +const R_X86_64_GOTPCREL = 9 +const R_X86_64_GOTPCREL64 = 28 +const R_X86_64_GOTPCRELX = 41 +const R_X86_64_GOTPLT64 = 30 +const R_X86_64_GOTTPOFF = 22 +const R_X86_64_IRELATIVE = 37 +const R_X86_64_JUMP_SLOT = 7 +const R_X86_64_NONE = 0 +const R_X86_64_NUM = 43 +const R_X86_64_PC16 = 13 +const R_X86_64_PC32 = 2 +const R_X86_64_PC64 = 24 +const R_X86_64_PC8 = 15 +const R_X86_64_PLT32 = 4 +const R_X86_64_PLTOFF64 = 31 +const R_X86_64_RELATIVE = 8 +const R_X86_64_RELATIVE64 = 38 +const R_X86_64_REX_GOTPCRELX = 42 +const R_X86_64_SIZE32 = 32 +const R_X86_64_SIZE64 = 33 +const R_X86_64_TLSDESC = 36 +const R_X86_64_TLSDESC_CALL = 35 +const R_X86_64_TLSGD = 19 +const R_X86_64_TLSLD = 20 +const R_X86_64_TPOFF32 = 23 +const R_X86_64_TPOFF64 = 18 +const SA_EXPOSE_TAGBITS = 2048 +const SA_NOCLDSTOP = 1 +const SA_NOCLDWAIT = 2 +const SA_NODEFER = 1073741824 +const SA_ONSTACK = 134217728 +const SA_RESETHAND = 2147483648 +const SA_RESTART = 268435456 +const SA_RESTORER = 67108864 +const SA_SIGINFO = 4 +const SA_UNSUPPORTED = 1024 +const SCM_TIMESTAMPING_OLD = 37 +const SCM_TIMESTAMPNS_OLD = 35 +const SCM_TIMESTAMP_OLD = 29 +const SEGV_ACCERR = 2 +const SEGV_BNDERR = 3 +const SEGV_MAPERR = 1 +const SEGV_MTEAERR = 8 +const SEGV_MTESERR = 9 +const SEGV_PKUERR = 4 +const SELFMAG = 4 +const SHF_ALLOC = 2 +const SHF_ALPHA_GPREL = 268435456 +const SHF_ARM_COMDEF = 2147483648 +const SHF_ARM_ENTRYSECT = 268435456 +const SHF_COMPRESSED = 2048 +const SHF_EXCLUDE = 2147483648 +const SHF_EXECINSTR = 4 +const SHF_GROUP = 512 +const SHF_IA_64_NORECOV = 536870912 +const SHF_IA_64_SHORT = 268435456 +const SHF_INFO_LINK = 64 +const SHF_LINK_ORDER = 128 +const SHF_MASKOS = 267386880 +const SHF_MASKPROC = 4026531840 +const SHF_MERGE = 16 +const SHF_MIPS_ADDR = 1073741824 +const SHF_MIPS_GPREL = 268435456 +const SHF_MIPS_LOCAL = 67108864 +const SHF_MIPS_MERGE = 536870912 +const SHF_MIPS_NAMES = 33554432 +const SHF_MIPS_NODUPE = 16777216 +const SHF_MIPS_NOSTRIP = 134217728 +const SHF_MIPS_STRINGS = 2147483648 +const SHF_ORDERED = 1073741824 +const SHF_OS_NONCONFORMING = 256 +const SHF_PARISC_HUGE = 1073741824 +const SHF_PARISC_SBP = 2147483648 +const SHF_PARISC_SHORT = 536870912 +const SHF_STRINGS = 32 +const SHF_TLS = 1024 +const SHF_WRITE = 1 +const SHN_ABS = 65521 +const SHN_AFTER = 65281 +const SHN_BEFORE = 65280 +const SHN_COMMON = 65522 +const SHN_HIOS = 65343 +const SHN_HIPROC = 65311 +const SHN_HIRESERVE = 65535 +const SHN_LOOS = 65312 +const SHN_LOPROC = 65280 +const SHN_LORESERVE = 65280 +const SHN_MIPS_ACOMMON = 65280 +const SHN_MIPS_DATA = 65282 +const SHN_MIPS_SCOMMON = 65283 +const SHN_MIPS_SUNDEFINED = 65284 +const SHN_MIPS_TEXT = 65281 +const SHN_PARISC_ANSI_COMMON = 65280 +const SHN_PARISC_HUGE_COMMON = 65281 +const SHN_UNDEF = 0 +const SHN_XINDEX = 65535 +const SHT_ALPHA_DEBUG = 1879048193 +const SHT_ALPHA_REGINFO = 1879048194 +const SHT_ARM_ATTRIBUTES = 1879048195 +const SHT_ARM_EXIDX = 1879048193 +const SHT_ARM_PREEMPTMAP = 1879048194 +const SHT_CHECKSUM = 1879048184 +const SHT_DYNAMIC = 6 +const SHT_DYNSYM = 11 +const SHT_FINI_ARRAY = 15 +const SHT_GNU_ATTRIBUTES = 1879048181 +const SHT_GNU_HASH = 1879048182 +const SHT_GNU_LIBLIST = 1879048183 +const SHT_GNU_verdef = 1879048189 +const SHT_GNU_verneed = 1879048190 +const SHT_GNU_versym = 1879048191 +const SHT_GROUP = 17 +const SHT_HASH = 5 +const SHT_HIOS = 1879048191 +const SHT_HIPROC = 2147483647 +const SHT_HISUNW = 1879048191 +const SHT_HIUSER = 2415919103 +const SHT_IA_64_EXT = 1879048192 +const SHT_IA_64_UNWIND = 1879048193 +const SHT_INIT_ARRAY = 14 +const SHT_LOOS = 1610612736 +const SHT_LOPROC = 1879048192 +const SHT_LOSUNW = 1879048186 +const SHT_LOUSER = 2147483648 +const SHT_MIPS_AUXSYM = 1879048214 +const SHT_MIPS_CONFLICT = 1879048194 +const SHT_MIPS_CONTENT = 1879048204 +const SHT_MIPS_DEBUG = 1879048197 +const SHT_MIPS_DELTACLASS = 1879048221 +const SHT_MIPS_DELTADECL = 1879048223 +const SHT_MIPS_DELTAINST = 1879048220 +const SHT_MIPS_DELTASYM = 1879048219 +const SHT_MIPS_DENSE = 1879048211 +const SHT_MIPS_DWARF = 1879048222 +const SHT_MIPS_EH_REGION = 1879048231 +const SHT_MIPS_EVENTS = 1879048225 +const SHT_MIPS_EXTSYM = 1879048210 +const SHT_MIPS_FDESC = 1879048209 +const SHT_MIPS_GPTAB = 1879048195 +const SHT_MIPS_IFACE = 1879048203 +const SHT_MIPS_LIBLIST = 1879048192 +const SHT_MIPS_LINE = 1879048217 +const SHT_MIPS_LOCSTR = 1879048216 +const SHT_MIPS_LOCSYM = 1879048213 +const SHT_MIPS_MSYM = 1879048193 +const SHT_MIPS_OPTIONS = 1879048205 +const SHT_MIPS_OPTSYM = 1879048215 +const SHT_MIPS_PACKAGE = 1879048199 +const SHT_MIPS_PACKSYM = 1879048200 +const SHT_MIPS_PDESC = 1879048212 +const SHT_MIPS_PDR_EXCEPTION = 1879048233 +const SHT_MIPS_PIXIE = 1879048227 +const SHT_MIPS_REGINFO = 1879048198 +const SHT_MIPS_RELD = 1879048201 +const SHT_MIPS_RFDESC = 1879048218 +const SHT_MIPS_SHDR = 1879048208 +const SHT_MIPS_SYMBOL_LIB = 1879048224 +const SHT_MIPS_TRANSLATE = 1879048226 +const SHT_MIPS_UCODE = 1879048196 +const SHT_MIPS_WHIRL = 1879048230 +const SHT_MIPS_XLATE = 1879048228 +const SHT_MIPS_XLATE_DEBUG = 1879048229 +const SHT_MIPS_XLATE_OLD = 1879048232 +const SHT_NOBITS = 8 +const SHT_NOTE = 7 +const SHT_NULL = 0 +const SHT_NUM = 20 +const SHT_PARISC_DOC = 1879048194 +const SHT_PARISC_EXT = 1879048192 +const SHT_PARISC_UNWIND = 1879048193 +const SHT_PREINIT_ARRAY = 16 +const SHT_PROGBITS = 1 +const SHT_REL = 9 +const SHT_RELA = 4 +const SHT_RELR = 19 +const SHT_SHLIB = 10 +const SHT_STRTAB = 3 +const SHT_SUNW_COMDAT = 1879048187 +const SHT_SUNW_move = 1879048186 +const SHT_SUNW_syminfo = 1879048188 +const SHT_SYMTAB = 2 +const SHT_SYMTAB_SHNDX = 18 +const SIGABRT = 6 +const SIGALRM = 14 +const SIGBUS = 7 +const SIGCHLD = 17 +const SIGCONT = 18 +const SIGEV_NONE = 1 +const SIGEV_SIGNAL = 0 +const SIGEV_THREAD = 2 +const SIGEV_THREAD_ID = 4 +const SIGFPE = 8 +const SIGHUP = 1 +const SIGILL = 4 +const SIGINT = 2 +const SIGIO = 29 +const SIGIOT = 6 +const SIGKILL = 9 +const SIGPIPE = 13 +const SIGPOLL = 29 +const SIGPROF = 27 +const SIGPWR = 30 +const SIGQUIT = 3 +const SIGRTMAX = 0 +const SIGRTMIN = 0 +const SIGSEGV = 11 +const SIGSTKFLT = 16 +const SIGSTKSZ = 8192 +const SIGSTOP = 19 +const SIGSYS = 31 +const SIGTERM = 15 +const SIGTRAP = 5 +const SIGTSTP = 20 +const SIGTTIN = 21 +const SIGTTOU = 22 +const SIGUNUSED = 31 +const SIGURG = 23 +const SIGUSR1 = 10 +const SIGUSR2 = 12 +const SIGVTALRM = 26 +const SIGWINCH = 28 +const SIGXCPU = 24 +const SIGXFSZ = 25 +const SIG_BLOCK = 0 +const SIG_SETMASK = 2 +const SIG_UNBLOCK = 1 +const SIOCGSTAMPNS_OLD = 35079 +const SIOCGSTAMP_OLD = 35078 +const SI_ASYNCIO = -4 +const SI_ASYNCNL = -60 +const SI_KERNEL = 128 +const SI_MESGQ = -3 +const SI_QUEUE = -1 +const SI_SIGIO = -5 +const SI_TIMER = -2 +const SI_TKILL = -6 +const SI_USER = 0 +const SO_RCVTIMEO_OLD = 20 +const SO_SNDTIMEO_OLD = 21 +const SO_TIMESTAMPING_OLD = 37 +const SO_TIMESTAMPNS_OLD = 35 +const SO_TIMESTAMP_OLD = 29 +const SS_AUTODISARM = 2147483648 +const SS_DISABLE = 2 +const SS_FLAG_BITS = 2147483648 +const SS_ONSTACK = 1 +const STB_GLOBAL = 1 +const STB_GNU_UNIQUE = 10 +const STB_HIOS = 12 +const STB_HIPROC = 15 +const STB_LOCAL = 0 +const STB_LOOS = 10 +const STB_LOPROC = 13 +const STB_MIPS_SPLIT_COMMON = 13 +const STB_NUM = 3 +const STB_WEAK = 2 +const STN_UNDEF = 0 +const STO_ALPHA_NOPV = 128 +const STO_ALPHA_STD_GPLOAD = 136 +const STO_MIPS_DEFAULT = 0 +const STO_MIPS_HIDDEN = 2 +const STO_MIPS_INTERNAL = 1 +const STO_MIPS_PLT = 8 +const STO_MIPS_PROTECTED = 3 +const STO_MIPS_SC_ALIGN_UNUSED = 255 +const STO_PPC64_LOCAL_BIT = 5 +const STO_PPC64_LOCAL_MASK = 224 +const STT_ARM_16BIT = 15 +const STT_ARM_TFUNC = 13 +const STT_COMMON = 5 +const STT_FILE = 4 +const STT_FUNC = 2 +const STT_GNU_IFUNC = 10 +const STT_HIOS = 12 +const STT_HIPROC = 15 +const STT_HP_OPAQUE = 11 +const STT_HP_STUB = 12 +const STT_LOOS = 10 +const STT_LOPROC = 13 +const STT_NOTYPE = 0 +const STT_NUM = 7 +const STT_OBJECT = 1 +const STT_PARISC_MILLICODE = 13 +const STT_SECTION = 3 +const STT_SPARC_REGISTER = 13 +const STT_TLS = 6 +const STV_DEFAULT = 0 +const STV_HIDDEN = 2 +const STV_INTERNAL = 1 +const STV_PROTECTED = 3 +const SYMINFO_BT_LOWRESERVE = 65280 +const SYMINFO_BT_PARENT = 65534 +const SYMINFO_BT_SELF = 65535 +const SYMINFO_CURRENT = 1 +const SYMINFO_FLG_COPY = 4 +const SYMINFO_FLG_DIRECT = 1 +const SYMINFO_FLG_LAZYLOAD = 8 +const SYMINFO_FLG_PASSTHRU = 2 +const SYMINFO_NONE = 0 +const SYMINFO_NUM = 2 +const SYSCALL_MMAP2_UNIT = 4096 +const SYSCALL_RLIM_INFINITY = 18446744073709551615 +const SYS__sysctl = 156 +const SYS_accept = 43 +const SYS_accept4 = 288 +const SYS_access = 21 +const SYS_acct = 163 +const SYS_add_key = 248 +const SYS_adjtimex = 159 +const SYS_afs_syscall = 183 +const SYS_alarm = 37 +const SYS_arch_prctl = 158 +const SYS_bind = 49 +const SYS_bpf = 321 +const SYS_brk = 12 +const SYS_cachestat = 451 +const SYS_capget = 125 +const SYS_capset = 126 +const SYS_chdir = 80 +const SYS_chmod = 90 +const SYS_chown = 92 +const SYS_chroot = 161 +const SYS_clock_adjtime = 305 +const SYS_clock_getres = 229 +const SYS_clock_gettime = 228 +const SYS_clock_nanosleep = 230 +const SYS_clock_settime = 227 +const SYS_clone = 56 +const SYS_clone3 = 435 +const SYS_close = 3 +const SYS_close_range = 436 +const SYS_connect = 42 +const SYS_copy_file_range = 326 +const SYS_creat = 85 +const SYS_create_module = 174 +const SYS_delete_module = 176 +const SYS_dup = 32 +const SYS_dup2 = 33 +const SYS_dup3 = 292 +const SYS_epoll_create = 213 +const SYS_epoll_create1 = 291 +const SYS_epoll_ctl = 233 +const SYS_epoll_ctl_old = 214 +const SYS_epoll_pwait = 281 +const SYS_epoll_pwait2 = 441 +const SYS_epoll_wait = 232 +const SYS_epoll_wait_old = 215 +const SYS_eventfd = 284 +const SYS_eventfd2 = 290 +const SYS_execve = 59 +const SYS_execveat = 322 +const SYS_exit = 60 +const SYS_exit_group = 231 +const SYS_faccessat = 269 +const SYS_faccessat2 = 439 +const SYS_fadvise64 = 221 +const SYS_fallocate = 285 +const SYS_fanotify_init = 300 +const SYS_fanotify_mark = 301 +const SYS_fchdir = 81 +const SYS_fchmod = 91 +const SYS_fchmodat = 268 +const SYS_fchmodat2 = 452 +const SYS_fchown = 93 +const SYS_fchownat = 260 +const SYS_fcntl = 72 +const SYS_fdatasync = 75 +const SYS_fgetxattr = 193 +const SYS_finit_module = 313 +const SYS_flistxattr = 196 +const SYS_flock = 73 +const SYS_fork = 57 +const SYS_fremovexattr = 199 +const SYS_fsconfig = 431 +const SYS_fsetxattr = 190 +const SYS_fsmount = 432 +const SYS_fsopen = 430 +const SYS_fspick = 433 +const SYS_fstat = 5 +const SYS_fstatfs = 138 +const SYS_fsync = 74 +const SYS_ftruncate = 77 +const SYS_futex = 202 +const SYS_futex_waitv = 449 +const SYS_futimesat = 261 +const SYS_get_kernel_syms = 177 +const SYS_get_mempolicy = 239 +const SYS_get_robust_list = 274 +const SYS_get_thread_area = 211 +const SYS_getcpu = 309 +const SYS_getcwd = 79 +const SYS_getdents64 = 217 +const SYS_getegid = 108 +const SYS_geteuid = 107 +const SYS_getgid = 104 +const SYS_getgroups = 115 +const SYS_getitimer = 36 +const SYS_getpeername = 52 +const SYS_getpgid = 121 +const SYS_getpgrp = 111 +const SYS_getpid = 39 +const SYS_getpmsg = 181 +const SYS_getppid = 110 +const SYS_getpriority = 140 +const SYS_getrandom = 318 +const SYS_getresgid = 120 +const SYS_getresuid = 118 +const SYS_getrlimit = 97 +const SYS_getrusage = 98 +const SYS_getsid = 124 +const SYS_getsockname = 51 +const SYS_getsockopt = 55 +const SYS_gettid = 186 +const SYS_gettimeofday = 96 +const SYS_getuid = 102 +const SYS_getxattr = 191 +const SYS_init_module = 175 +const SYS_inotify_add_watch = 254 +const SYS_inotify_init = 253 +const SYS_inotify_init1 = 294 +const SYS_inotify_rm_watch = 255 +const SYS_io_cancel = 210 +const SYS_io_destroy = 207 +const SYS_io_getevents = 208 +const SYS_io_pgetevents = 333 +const SYS_io_setup = 206 +const SYS_io_submit = 209 +const SYS_io_uring_enter = 426 +const SYS_io_uring_register = 427 +const SYS_io_uring_setup = 425 +const SYS_ioctl = 16 +const SYS_ioperm = 173 +const SYS_iopl = 172 +const SYS_ioprio_get = 252 +const SYS_ioprio_set = 251 +const SYS_kcmp = 312 +const SYS_kexec_file_load = 320 +const SYS_kexec_load = 246 +const SYS_keyctl = 250 +const SYS_kill = 62 +const SYS_landlock_add_rule = 445 +const SYS_landlock_create_ruleset = 444 +const SYS_landlock_restrict_self = 446 +const SYS_lchown = 94 +const SYS_lgetxattr = 192 +const SYS_link = 86 +const SYS_linkat = 265 +const SYS_listen = 50 +const SYS_listxattr = 194 +const SYS_llistxattr = 195 +const SYS_lookup_dcookie = 212 +const SYS_lremovexattr = 198 +const SYS_lseek = 8 +const SYS_lsetxattr = 189 +const SYS_lstat = 6 +const SYS_madvise = 28 +const SYS_mbind = 237 +const SYS_membarrier = 324 +const SYS_memfd_create = 319 +const SYS_memfd_secret = 447 +const SYS_migrate_pages = 256 +const SYS_mincore = 27 +const SYS_mkdir = 83 +const SYS_mkdirat = 258 +const SYS_mknod = 133 +const SYS_mknodat = 259 +const SYS_mlock = 149 +const SYS_mlock2 = 325 +const SYS_mlockall = 151 +const SYS_mmap = 9 +const SYS_modify_ldt = 154 +const SYS_mount = 165 +const SYS_mount_setattr = 442 +const SYS_move_mount = 429 +const SYS_move_pages = 279 +const SYS_mprotect = 10 +const SYS_mq_getsetattr = 245 +const SYS_mq_notify = 244 +const SYS_mq_open = 240 +const SYS_mq_timedreceive = 243 +const SYS_mq_timedsend = 242 +const SYS_mq_unlink = 241 +const SYS_mremap = 25 +const SYS_msgctl = 71 +const SYS_msgget = 68 +const SYS_msgrcv = 70 +const SYS_msgsnd = 69 +const SYS_msync = 26 +const SYS_munlock = 150 +const SYS_munlockall = 152 +const SYS_munmap = 11 +const SYS_name_to_handle_at = 303 +const SYS_nanosleep = 35 +const SYS_newfstatat = 262 +const SYS_nfsservctl = 180 +const SYS_open = 2 +const SYS_open_by_handle_at = 304 +const SYS_open_tree = 428 +const SYS_openat = 257 +const SYS_openat2 = 437 +const SYS_pause = 34 +const SYS_perf_event_open = 298 +const SYS_personality = 135 +const SYS_pidfd_getfd = 438 +const SYS_pidfd_open = 434 +const SYS_pidfd_send_signal = 424 +const SYS_pipe = 22 +const SYS_pipe2 = 293 +const SYS_pivot_root = 155 +const SYS_pkey_alloc = 330 +const SYS_pkey_free = 331 +const SYS_pkey_mprotect = 329 +const SYS_poll = 7 +const SYS_ppoll = 271 +const SYS_prctl = 157 +const SYS_pread64 = 17 +const SYS_preadv = 295 +const SYS_preadv2 = 327 +const SYS_prlimit64 = 302 +const SYS_process_madvise = 440 +const SYS_process_mrelease = 448 +const SYS_process_vm_readv = 310 +const SYS_process_vm_writev = 311 +const SYS_pselect6 = 270 +const SYS_ptrace = 101 +const SYS_putpmsg = 182 +const SYS_pwrite64 = 18 +const SYS_pwritev = 296 +const SYS_pwritev2 = 328 +const SYS_query_module = 178 +const SYS_quotactl = 179 +const SYS_read = 0 +const SYS_readahead = 187 +const SYS_readlink = 89 +const SYS_readlinkat = 267 +const SYS_readv = 19 +const SYS_reboot = 169 +const SYS_recvfrom = 45 +const SYS_recvmmsg = 299 +const SYS_recvmsg = 47 +const SYS_remap_file_pages = 216 +const SYS_removexattr = 197 +const SYS_rename = 82 +const SYS_renameat = 264 +const SYS_renameat2 = 316 +const SYS_request_key = 249 +const SYS_restart_syscall = 219 +const SYS_rmdir = 84 +const SYS_rseq = 334 +const SYS_rt_sigaction = 13 +const SYS_rt_sigpending = 127 +const SYS_rt_sigprocmask = 14 +const SYS_rt_sigqueueinfo = 129 +const SYS_rt_sigreturn = 15 +const SYS_rt_sigsuspend = 130 +const SYS_rt_sigtimedwait = 128 +const SYS_rt_tgsigqueueinfo = 297 +const SYS_sched_get_priority_max = 146 +const SYS_sched_get_priority_min = 147 +const SYS_sched_getaffinity = 204 +const SYS_sched_getattr = 315 +const SYS_sched_getparam = 143 +const SYS_sched_getscheduler = 145 +const SYS_sched_rr_get_interval = 148 +const SYS_sched_setaffinity = 203 +const SYS_sched_setattr = 314 +const SYS_sched_setparam = 142 +const SYS_sched_setscheduler = 144 +const SYS_sched_yield = 24 +const SYS_seccomp = 317 +const SYS_security = 185 +const SYS_select = 23 +const SYS_semctl = 66 +const SYS_semget = 64 +const SYS_semop = 65 +const SYS_semtimedop = 220 +const SYS_sendfile = 40 +const SYS_sendmmsg = 307 +const SYS_sendmsg = 46 +const SYS_sendto = 44 +const SYS_set_mempolicy = 238 +const SYS_set_mempolicy_home_node = 450 +const SYS_set_robust_list = 273 +const SYS_set_thread_area = 205 +const SYS_set_tid_address = 218 +const SYS_setdomainname = 171 +const SYS_setfsgid = 123 +const SYS_setfsuid = 122 +const SYS_setgid = 106 +const SYS_setgroups = 116 +const SYS_sethostname = 170 +const SYS_setitimer = 38 +const SYS_setns = 308 +const SYS_setpgid = 109 +const SYS_setpriority = 141 +const SYS_setregid = 114 +const SYS_setresgid = 119 +const SYS_setresuid = 117 +const SYS_setreuid = 113 +const SYS_setrlimit = 160 +const SYS_setsid = 112 +const SYS_setsockopt = 54 +const SYS_settimeofday = 164 +const SYS_setuid = 105 +const SYS_setxattr = 188 +const SYS_shmat = 30 +const SYS_shmctl = 31 +const SYS_shmdt = 67 +const SYS_shmget = 29 +const SYS_shutdown = 48 +const SYS_sigaltstack = 131 +const SYS_signalfd = 282 +const SYS_signalfd4 = 289 +const SYS_socket = 41 +const SYS_socketpair = 53 +const SYS_splice = 275 +const SYS_stat = 4 +const SYS_statfs = 137 +const SYS_statx = 332 +const SYS_swapoff = 168 +const SYS_swapon = 167 +const SYS_symlink = 88 +const SYS_symlinkat = 266 +const SYS_sync = 162 +const SYS_sync_file_range = 277 +const SYS_syncfs = 306 +const SYS_sysfs = 139 +const SYS_sysinfo = 99 +const SYS_syslog = 103 +const SYS_tee = 276 +const SYS_tgkill = 234 +const SYS_time = 201 +const SYS_timer_create = 222 +const SYS_timer_delete = 226 +const SYS_timer_getoverrun = 225 +const SYS_timer_gettime = 224 +const SYS_timer_settime = 223 +const SYS_timerfd_create = 283 +const SYS_timerfd_gettime = 287 +const SYS_timerfd_settime = 286 +const SYS_times = 100 +const SYS_tkill = 200 +const SYS_truncate = 76 +const SYS_tuxcall = 184 +const SYS_umask = 95 +const SYS_umount2 = 166 +const SYS_uname = 63 +const SYS_unlink = 87 +const SYS_unlinkat = 263 +const SYS_unshare = 272 +const SYS_uselib = 134 +const SYS_userfaultfd = 323 +const SYS_ustat = 136 +const SYS_utime = 132 +const SYS_utimensat = 280 +const SYS_utimes = 235 +const SYS_vfork = 58 +const SYS_vhangup = 153 +const SYS_vmsplice = 278 +const SYS_vserver = 236 +const SYS_wait4 = 61 +const SYS_waitid = 247 +const SYS_write = 1 +const SYS_writev = 20 +const TRAP_BRANCH = 3 +const TRAP_BRKPT = 1 +const TRAP_HWBKPT = 4 +const TRAP_TRACE = 2 +const TRAP_UNK = 5 +const VER = -255 +const VER_DEF_CURRENT = 1 +const VER_DEF_NONE = 0 +const VER_DEF_NUM = 2 +const VER_FLG_BASE = 1 +const VER_FLG_WEAK = 2 +const VER_NDX_ELIMINATE = 65281 +const VER_NDX_GLOBAL = 1 +const VER_NDX_LOCAL = 0 +const VER_NDX_LORESERVE = 65280 +const VER_NEED_CURRENT = 1 +const VER_NEED_NONE = 0 +const VER_NEED_NUM = 2 +const WNOHANG = 1 +const WUNTRACED = 2 +const _NSIG = 65 +const __NR__sysctl = 156 +const __NR_accept = 43 +const __NR_accept4 = 288 +const __NR_access = 21 +const __NR_acct = 163 +const __NR_add_key = 248 +const __NR_adjtimex = 159 +const __NR_afs_syscall = 183 +const __NR_alarm = 37 +const __NR_arch_prctl = 158 +const __NR_bind = 49 +const __NR_bpf = 321 +const __NR_brk = 12 +const __NR_cachestat = 451 +const __NR_capget = 125 +const __NR_capset = 126 +const __NR_chdir = 80 +const __NR_chmod = 90 +const __NR_chown = 92 +const __NR_chroot = 161 +const __NR_clock_adjtime = 305 +const __NR_clock_getres = 229 +const __NR_clock_gettime = 228 +const __NR_clock_nanosleep = 230 +const __NR_clock_settime = 227 +const __NR_clone = 56 +const __NR_clone3 = 435 +const __NR_close = 3 +const __NR_close_range = 436 +const __NR_connect = 42 +const __NR_copy_file_range = 326 +const __NR_creat = 85 +const __NR_create_module = 174 +const __NR_delete_module = 176 +const __NR_dup = 32 +const __NR_dup2 = 33 +const __NR_dup3 = 292 +const __NR_epoll_create = 213 +const __NR_epoll_create1 = 291 +const __NR_epoll_ctl = 233 +const __NR_epoll_ctl_old = 214 +const __NR_epoll_pwait = 281 +const __NR_epoll_pwait2 = 441 +const __NR_epoll_wait = 232 +const __NR_epoll_wait_old = 215 +const __NR_eventfd = 284 +const __NR_eventfd2 = 290 +const __NR_execve = 59 +const __NR_execveat = 322 +const __NR_exit = 60 +const __NR_exit_group = 231 +const __NR_faccessat = 269 +const __NR_faccessat2 = 439 +const __NR_fadvise64 = 221 +const __NR_fallocate = 285 +const __NR_fanotify_init = 300 +const __NR_fanotify_mark = 301 +const __NR_fchdir = 81 +const __NR_fchmod = 91 +const __NR_fchmodat = 268 +const __NR_fchmodat2 = 452 +const __NR_fchown = 93 +const __NR_fchownat = 260 +const __NR_fcntl = 72 +const __NR_fdatasync = 75 +const __NR_fgetxattr = 193 +const __NR_finit_module = 313 +const __NR_flistxattr = 196 +const __NR_flock = 73 +const __NR_fork = 57 +const __NR_fremovexattr = 199 +const __NR_fsconfig = 431 +const __NR_fsetxattr = 190 +const __NR_fsmount = 432 +const __NR_fsopen = 430 +const __NR_fspick = 433 +const __NR_fstat = 5 +const __NR_fstatfs = 138 +const __NR_fsync = 74 +const __NR_ftruncate = 77 +const __NR_futex = 202 +const __NR_futex_waitv = 449 +const __NR_futimesat = 261 +const __NR_get_kernel_syms = 177 +const __NR_get_mempolicy = 239 +const __NR_get_robust_list = 274 +const __NR_get_thread_area = 211 +const __NR_getcpu = 309 +const __NR_getcwd = 79 +const __NR_getdents = 78 +const __NR_getdents64 = 217 +const __NR_getegid = 108 +const __NR_geteuid = 107 +const __NR_getgid = 104 +const __NR_getgroups = 115 +const __NR_getitimer = 36 +const __NR_getpeername = 52 +const __NR_getpgid = 121 +const __NR_getpgrp = 111 +const __NR_getpid = 39 +const __NR_getpmsg = 181 +const __NR_getppid = 110 +const __NR_getpriority = 140 +const __NR_getrandom = 318 +const __NR_getresgid = 120 +const __NR_getresuid = 118 +const __NR_getrlimit = 97 +const __NR_getrusage = 98 +const __NR_getsid = 124 +const __NR_getsockname = 51 +const __NR_getsockopt = 55 +const __NR_gettid = 186 +const __NR_gettimeofday = 96 +const __NR_getuid = 102 +const __NR_getxattr = 191 +const __NR_init_module = 175 +const __NR_inotify_add_watch = 254 +const __NR_inotify_init = 253 +const __NR_inotify_init1 = 294 +const __NR_inotify_rm_watch = 255 +const __NR_io_cancel = 210 +const __NR_io_destroy = 207 +const __NR_io_getevents = 208 +const __NR_io_pgetevents = 333 +const __NR_io_setup = 206 +const __NR_io_submit = 209 +const __NR_io_uring_enter = 426 +const __NR_io_uring_register = 427 +const __NR_io_uring_setup = 425 +const __NR_ioctl = 16 +const __NR_ioperm = 173 +const __NR_iopl = 172 +const __NR_ioprio_get = 252 +const __NR_ioprio_set = 251 +const __NR_kcmp = 312 +const __NR_kexec_file_load = 320 +const __NR_kexec_load = 246 +const __NR_keyctl = 250 +const __NR_kill = 62 +const __NR_landlock_add_rule = 445 +const __NR_landlock_create_ruleset = 444 +const __NR_landlock_restrict_self = 446 +const __NR_lchown = 94 +const __NR_lgetxattr = 192 +const __NR_link = 86 +const __NR_linkat = 265 +const __NR_listen = 50 +const __NR_listxattr = 194 +const __NR_llistxattr = 195 +const __NR_lookup_dcookie = 212 +const __NR_lremovexattr = 198 +const __NR_lseek = 8 +const __NR_lsetxattr = 189 +const __NR_lstat = 6 +const __NR_madvise = 28 +const __NR_mbind = 237 +const __NR_membarrier = 324 +const __NR_memfd_create = 319 +const __NR_memfd_secret = 447 +const __NR_migrate_pages = 256 +const __NR_mincore = 27 +const __NR_mkdir = 83 +const __NR_mkdirat = 258 +const __NR_mknod = 133 +const __NR_mknodat = 259 +const __NR_mlock = 149 +const __NR_mlock2 = 325 +const __NR_mlockall = 151 +const __NR_mmap = 9 +const __NR_modify_ldt = 154 +const __NR_mount = 165 +const __NR_mount_setattr = 442 +const __NR_move_mount = 429 +const __NR_move_pages = 279 +const __NR_mprotect = 10 +const __NR_mq_getsetattr = 245 +const __NR_mq_notify = 244 +const __NR_mq_open = 240 +const __NR_mq_timedreceive = 243 +const __NR_mq_timedsend = 242 +const __NR_mq_unlink = 241 +const __NR_mremap = 25 +const __NR_msgctl = 71 +const __NR_msgget = 68 +const __NR_msgrcv = 70 +const __NR_msgsnd = 69 +const __NR_msync = 26 +const __NR_munlock = 150 +const __NR_munlockall = 152 +const __NR_munmap = 11 +const __NR_name_to_handle_at = 303 +const __NR_nanosleep = 35 +const __NR_newfstatat = 262 +const __NR_nfsservctl = 180 +const __NR_open = 2 +const __NR_open_by_handle_at = 304 +const __NR_open_tree = 428 +const __NR_openat = 257 +const __NR_openat2 = 437 +const __NR_pause = 34 +const __NR_perf_event_open = 298 +const __NR_personality = 135 +const __NR_pidfd_getfd = 438 +const __NR_pidfd_open = 434 +const __NR_pidfd_send_signal = 424 +const __NR_pipe = 22 +const __NR_pipe2 = 293 +const __NR_pivot_root = 155 +const __NR_pkey_alloc = 330 +const __NR_pkey_free = 331 +const __NR_pkey_mprotect = 329 +const __NR_poll = 7 +const __NR_ppoll = 271 +const __NR_prctl = 157 +const __NR_pread64 = 17 +const __NR_preadv = 295 +const __NR_preadv2 = 327 +const __NR_prlimit64 = 302 +const __NR_process_madvise = 440 +const __NR_process_mrelease = 448 +const __NR_process_vm_readv = 310 +const __NR_process_vm_writev = 311 +const __NR_pselect6 = 270 +const __NR_ptrace = 101 +const __NR_putpmsg = 182 +const __NR_pwrite64 = 18 +const __NR_pwritev = 296 +const __NR_pwritev2 = 328 +const __NR_query_module = 178 +const __NR_quotactl = 179 +const __NR_read = 0 +const __NR_readahead = 187 +const __NR_readlink = 89 +const __NR_readlinkat = 267 +const __NR_readv = 19 +const __NR_reboot = 169 +const __NR_recvfrom = 45 +const __NR_recvmmsg = 299 +const __NR_recvmsg = 47 +const __NR_remap_file_pages = 216 +const __NR_removexattr = 197 +const __NR_rename = 82 +const __NR_renameat = 264 +const __NR_renameat2 = 316 +const __NR_request_key = 249 +const __NR_restart_syscall = 219 +const __NR_rmdir = 84 +const __NR_rseq = 334 +const __NR_rt_sigaction = 13 +const __NR_rt_sigpending = 127 +const __NR_rt_sigprocmask = 14 +const __NR_rt_sigqueueinfo = 129 +const __NR_rt_sigreturn = 15 +const __NR_rt_sigsuspend = 130 +const __NR_rt_sigtimedwait = 128 +const __NR_rt_tgsigqueueinfo = 297 +const __NR_sched_get_priority_max = 146 +const __NR_sched_get_priority_min = 147 +const __NR_sched_getaffinity = 204 +const __NR_sched_getattr = 315 +const __NR_sched_getparam = 143 +const __NR_sched_getscheduler = 145 +const __NR_sched_rr_get_interval = 148 +const __NR_sched_setaffinity = 203 +const __NR_sched_setattr = 314 +const __NR_sched_setparam = 142 +const __NR_sched_setscheduler = 144 +const __NR_sched_yield = 24 +const __NR_seccomp = 317 +const __NR_security = 185 +const __NR_select = 23 +const __NR_semctl = 66 +const __NR_semget = 64 +const __NR_semop = 65 +const __NR_semtimedop = 220 +const __NR_sendfile = 40 +const __NR_sendmmsg = 307 +const __NR_sendmsg = 46 +const __NR_sendto = 44 +const __NR_set_mempolicy = 238 +const __NR_set_mempolicy_home_node = 450 +const __NR_set_robust_list = 273 +const __NR_set_thread_area = 205 +const __NR_set_tid_address = 218 +const __NR_setdomainname = 171 +const __NR_setfsgid = 123 +const __NR_setfsuid = 122 +const __NR_setgid = 106 +const __NR_setgroups = 116 +const __NR_sethostname = 170 +const __NR_setitimer = 38 +const __NR_setns = 308 +const __NR_setpgid = 109 +const __NR_setpriority = 141 +const __NR_setregid = 114 +const __NR_setresgid = 119 +const __NR_setresuid = 117 +const __NR_setreuid = 113 +const __NR_setrlimit = 160 +const __NR_setsid = 112 +const __NR_setsockopt = 54 +const __NR_settimeofday = 164 +const __NR_setuid = 105 +const __NR_setxattr = 188 +const __NR_shmat = 30 +const __NR_shmctl = 31 +const __NR_shmdt = 67 +const __NR_shmget = 29 +const __NR_shutdown = 48 +const __NR_sigaltstack = 131 +const __NR_signalfd = 282 +const __NR_signalfd4 = 289 +const __NR_socket = 41 +const __NR_socketpair = 53 +const __NR_splice = 275 +const __NR_stat = 4 +const __NR_statfs = 137 +const __NR_statx = 332 +const __NR_swapoff = 168 +const __NR_swapon = 167 +const __NR_symlink = 88 +const __NR_symlinkat = 266 +const __NR_sync = 162 +const __NR_sync_file_range = 277 +const __NR_syncfs = 306 +const __NR_sysfs = 139 +const __NR_sysinfo = 99 +const __NR_syslog = 103 +const __NR_tee = 276 +const __NR_tgkill = 234 +const __NR_time = 201 +const __NR_timer_create = 222 +const __NR_timer_delete = 226 +const __NR_timer_getoverrun = 225 +const __NR_timer_gettime = 224 +const __NR_timer_settime = 223 +const __NR_timerfd_create = 283 +const __NR_timerfd_gettime = 287 +const __NR_timerfd_settime = 286 +const __NR_times = 100 +const __NR_tkill = 200 +const __NR_truncate = 76 +const __NR_tuxcall = 184 +const __NR_umask = 95 +const __NR_umount2 = 166 +const __NR_uname = 63 +const __NR_unlink = 87 +const __NR_unlinkat = 263 +const __NR_unshare = 272 +const __NR_uselib = 134 +const __NR_userfaultfd = 323 +const __NR_ustat = 136 +const __NR_utime = 132 +const __NR_utimensat = 280 +const __NR_utimes = 235 +const __NR_vfork = 58 +const __NR_vhangup = 153 +const __NR_vmsplice = 278 +const __NR_vserver = 236 +const __NR_wait4 = 61 +const __NR_waitid = 247 +const __NR_write = 1 +const __NR_writev = 20 +const __SC_accept = 5 +const __SC_accept4 = 18 +const __SC_bind = 2 +const __SC_connect = 3 +const __SC_getpeername = 7 +const __SC_getsockname = 6 +const __SC_getsockopt = 15 +const __SC_listen = 4 +const __SC_recv = 10 +const __SC_recvfrom = 12 +const __SC_recvmmsg = 19 +const __SC_recvmsg = 17 +const __SC_send = 9 +const __SC_sendmmsg = 20 +const __SC_sendmsg = 16 +const __SC_sendto = 11 +const __SC_setsockopt = 14 +const __SC_shutdown = 13 +const __SC_socket = 1 +const __SC_socketpair = 8 +const libc = 0 + +type Ttime_t = int64 + +type Tsuseconds_t = int64 + +type Ttimeval = struct { + Ftv_sec Ttime_t + Ftv_usec Tsuseconds_t +} + +type Ttimespec = struct { + Ftv_sec Ttime_t + Ftv_nsec int64 +} + +type Tsigset_t = struct { + F__bits [16]uint64 +} + +type t__sigset_t = Tsigset_t + +type Tfd_mask = uint64 + +type Tfd_set = struct { + Ffds_bits [16]uint64 +} + +type Titimerval = struct { + Fit_interval Ttimeval + Fit_value Ttimeval +} + +type Tid_t = uint32 + +type Trlim_t = uint64 + +type Trlimit = struct { + Frlim_cur Trlim_t + Frlim_max Trlim_t +} + +type Trusage = struct { + Fru_utime Ttimeval + Fru_stime Ttimeval + Fru_maxrss int64 + Fru_ixrss int64 + Fru_idrss int64 + Fru_isrss int64 + Fru_minflt int64 + Fru_majflt int64 + Fru_nswap int64 + Fru_inblock int64 + Fru_oublock int64 + Fru_msgsnd int64 + Fru_msgrcv int64 + Fru_nsignals int64 + Fru_nvcsw int64 + Fru_nivcsw int64 + F__reserved [16]int64 +} + +type Tclock_t = int64 + +type Tpthread_t = uintptr + +type Tpthread_attr_t = struct { + F__u struct { + F__vi [0][14]int32 + F__s [0][7]uint64 + F__i [14]int32 + } +} + +type Tstack_t = struct { + Fss_sp uintptr + Fss_flags int32 + Fss_size Tsize_t +} + +type Tsigaltstack = Tstack_t + +type Tmcontext_t = struct { + F__space [32]uint64 +} + +type Tucontext_t = struct { + Fuc_flags uint64 + Fuc_link uintptr + Fuc_stack Tstack_t + Fuc_mcontext Tmcontext_t + Fuc_sigmask Tsigset_t + F__fpregs_mem [64]uint64 +} + +type t__ucontext = Tucontext_t + +type Tsigval = struct { + Fsival_ptr [0]uintptr + Fsival_int int32 + F__ccgo_pad2 [4]byte +} + +type Tsiginfo_t = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + F__si_fields struct { + F__si_common [0]struct { + F__first struct { + F__timer [0]struct { + Fsi_timerid int32 + Fsi_overrun int32 + } + F__piduid struct { + Fsi_pid Tpid_t + Fsi_uid Tuid_t + } + } + F__second struct { + F__sigchld [0]struct { + Fsi_status int32 + Fsi_utime Tclock_t + Fsi_stime Tclock_t + } + Fsi_value Tsigval + F__ccgo_pad2 [16]byte + } + } + F__sigfault [0]struct { + Fsi_addr uintptr + Fsi_addr_lsb int16 + F__first struct { + Fsi_pkey [0]uint32 + F__addr_bnd struct { + Fsi_lower uintptr + Fsi_upper uintptr + } + } + } + F__sigpoll [0]struct { + Fsi_band int64 + Fsi_fd int32 + } + F__sigsys [0]struct { + Fsi_call_addr uintptr + Fsi_syscall int32 + Fsi_arch uint32 + } + F__pad [112]int8 + } +} + +type Tsigaction = struct { + F__sa_handler struct { + Fsa_sigaction [0]uintptr + Fsa_handler uintptr + } + Fsa_mask Tsigset_t + Fsa_flags int32 + Fsa_restorer uintptr +} + +type Tsigevent = struct { + Fsigev_value Tsigval + Fsigev_signo int32 + Fsigev_notify int32 + F__sev_fields struct { + Fsigev_notify_thread_id [0]Tpid_t + F__sev_thread [0]struct { + Fsigev_notify_function uintptr + Fsigev_notify_attributes uintptr + } + F__pad [48]int8 + } +} + +type Tsig_atomic_t = int32 + +type TElf32_Half = uint16 + +type TElf64_Half = uint16 + +type TElf32_Word = uint32 + +type TElf32_Sword = int32 + +type TElf64_Word = uint32 + +type TElf64_Sword = int32 + +type TElf32_Xword = uint64 + +type TElf32_Sxword = int64 + +type TElf64_Xword = uint64 + +type TElf64_Sxword = int64 + +type TElf32_Addr = uint32 + +type TElf64_Addr = uint64 + +type TElf32_Off = uint32 + +type TElf64_Off = uint64 + +type TElf32_Section = uint16 + +type TElf64_Section = uint16 + +type TElf32_Versym = uint16 + +type TElf64_Versym = uint16 + +type TElf32_Ehdr = struct { + Fe_ident [16]uint8 + Fe_type TElf32_Half + Fe_machine TElf32_Half + Fe_version TElf32_Word + Fe_entry TElf32_Addr + Fe_phoff TElf32_Off + Fe_shoff TElf32_Off + Fe_flags TElf32_Word + Fe_ehsize TElf32_Half + Fe_phentsize TElf32_Half + Fe_phnum TElf32_Half + Fe_shentsize TElf32_Half + Fe_shnum TElf32_Half + Fe_shstrndx TElf32_Half +} + +type TElf64_Ehdr = struct { + Fe_ident [16]uint8 + Fe_type TElf64_Half + Fe_machine TElf64_Half + Fe_version TElf64_Word + Fe_entry TElf64_Addr + Fe_phoff TElf64_Off + Fe_shoff TElf64_Off + Fe_flags TElf64_Word + Fe_ehsize TElf64_Half + Fe_phentsize TElf64_Half + Fe_phnum TElf64_Half + Fe_shentsize TElf64_Half + Fe_shnum TElf64_Half + Fe_shstrndx TElf64_Half +} + +type TElf32_Shdr = struct { + Fsh_name TElf32_Word + Fsh_type TElf32_Word + Fsh_flags TElf32_Word + Fsh_addr TElf32_Addr + Fsh_offset TElf32_Off + Fsh_size TElf32_Word + Fsh_link TElf32_Word + Fsh_info TElf32_Word + Fsh_addralign TElf32_Word + Fsh_entsize TElf32_Word +} + +type TElf64_Shdr = struct { + Fsh_name TElf64_Word + Fsh_type TElf64_Word + Fsh_flags TElf64_Xword + Fsh_addr TElf64_Addr + Fsh_offset TElf64_Off + Fsh_size TElf64_Xword + Fsh_link TElf64_Word + Fsh_info TElf64_Word + Fsh_addralign TElf64_Xword + Fsh_entsize TElf64_Xword +} + +type TElf32_Chdr = struct { + Fch_type TElf32_Word + Fch_size TElf32_Word + Fch_addralign TElf32_Word +} + +type TElf64_Chdr = struct { + Fch_type TElf64_Word + Fch_reserved TElf64_Word + Fch_size TElf64_Xword + Fch_addralign TElf64_Xword +} + +type TElf32_Sym = struct { + Fst_name TElf32_Word + Fst_value TElf32_Addr + Fst_size TElf32_Word + Fst_info uint8 + Fst_other uint8 + Fst_shndx TElf32_Section +} + +type TElf64_Sym = struct { + Fst_name TElf64_Word + Fst_info uint8 + Fst_other uint8 + Fst_shndx TElf64_Section + Fst_value TElf64_Addr + Fst_size TElf64_Xword +} + +type TElf32_Syminfo = struct { + Fsi_boundto TElf32_Half + Fsi_flags TElf32_Half +} + +type TElf64_Syminfo = struct { + Fsi_boundto TElf64_Half + Fsi_flags TElf64_Half +} + +type TElf32_Rel = struct { + Fr_offset TElf32_Addr + Fr_info TElf32_Word +} + +type TElf64_Rel = struct { + Fr_offset TElf64_Addr + Fr_info TElf64_Xword +} + +type TElf32_Rela = struct { + Fr_offset TElf32_Addr + Fr_info TElf32_Word + Fr_addend TElf32_Sword +} + +type TElf64_Rela = struct { + Fr_offset TElf64_Addr + Fr_info TElf64_Xword + Fr_addend TElf64_Sxword +} + +type TElf32_Relr = uint32 + +type TElf64_Relr = uint64 + +type TElf32_Phdr = struct { + Fp_type TElf32_Word + Fp_offset TElf32_Off + Fp_vaddr TElf32_Addr + Fp_paddr TElf32_Addr + Fp_filesz TElf32_Word + Fp_memsz TElf32_Word + Fp_flags TElf32_Word + Fp_align TElf32_Word +} + +type TElf64_Phdr = struct { + Fp_type TElf64_Word + Fp_flags TElf64_Word + Fp_offset TElf64_Off + Fp_vaddr TElf64_Addr + Fp_paddr TElf64_Addr + Fp_filesz TElf64_Xword + Fp_memsz TElf64_Xword + Fp_align TElf64_Xword +} + +type TElf32_Dyn = struct { + Fd_tag TElf32_Sword + Fd_un struct { + Fd_ptr [0]TElf32_Addr + Fd_val TElf32_Word + } +} + +type TElf64_Dyn = struct { + Fd_tag TElf64_Sxword + Fd_un struct { + Fd_ptr [0]TElf64_Addr + Fd_val TElf64_Xword + } +} + +type TElf32_Verdef = struct { + Fvd_version TElf32_Half + Fvd_flags TElf32_Half + Fvd_ndx TElf32_Half + Fvd_cnt TElf32_Half + Fvd_hash TElf32_Word + Fvd_aux TElf32_Word + Fvd_next TElf32_Word +} + +type TElf64_Verdef = struct { + Fvd_version TElf64_Half + Fvd_flags TElf64_Half + Fvd_ndx TElf64_Half + Fvd_cnt TElf64_Half + Fvd_hash TElf64_Word + Fvd_aux TElf64_Word + Fvd_next TElf64_Word +} + +type TElf32_Verdaux = struct { + Fvda_name TElf32_Word + Fvda_next TElf32_Word +} + +type TElf64_Verdaux = struct { + Fvda_name TElf64_Word + Fvda_next TElf64_Word +} + +type TElf32_Verneed = struct { + Fvn_version TElf32_Half + Fvn_cnt TElf32_Half + Fvn_file TElf32_Word + Fvn_aux TElf32_Word + Fvn_next TElf32_Word +} + +type TElf64_Verneed = struct { + Fvn_version TElf64_Half + Fvn_cnt TElf64_Half + Fvn_file TElf64_Word + Fvn_aux TElf64_Word + Fvn_next TElf64_Word +} + +type TElf32_Vernaux = struct { + Fvna_hash TElf32_Word + Fvna_flags TElf32_Half + Fvna_other TElf32_Half + Fvna_name TElf32_Word + Fvna_next TElf32_Word +} + +type TElf64_Vernaux = struct { + Fvna_hash TElf64_Word + Fvna_flags TElf64_Half + Fvna_other TElf64_Half + Fvna_name TElf64_Word + Fvna_next TElf64_Word +} + +type TElf32_auxv_t = struct { + Fa_type Tuint32_t + Fa_un struct { + Fa_val Tuint32_t + } +} + +type TElf64_auxv_t = struct { + Fa_type Tuint64_t + Fa_un struct { + Fa_val Tuint64_t + } +} + +type TElf32_Nhdr = struct { + Fn_namesz TElf32_Word + Fn_descsz TElf32_Word + Fn_type TElf32_Word +} + +type TElf64_Nhdr = struct { + Fn_namesz TElf64_Word + Fn_descsz TElf64_Word + Fn_type TElf64_Word +} + +type TElf32_Move = struct { + Fm_value TElf32_Xword + Fm_info TElf32_Word + Fm_poffset TElf32_Word + Fm_repeat TElf32_Half + Fm_stride TElf32_Half +} + +type TElf64_Move = struct { + Fm_value TElf64_Xword + Fm_info TElf64_Xword + Fm_poffset TElf64_Xword + Fm_repeat TElf64_Half + Fm_stride TElf64_Half +} + +type TElf32_gptab = struct { + Fgt_entry [0]struct { + Fgt_g_value TElf32_Word + Fgt_bytes TElf32_Word + } + Fgt_header struct { + Fgt_current_g_value TElf32_Word + Fgt_unused TElf32_Word + } +} + +type TElf32_RegInfo = struct { + Fri_gprmask TElf32_Word + Fri_cprmask [4]TElf32_Word + Fri_gp_value TElf32_Sword +} + +type TElf_Options = struct { + Fkind uint8 + Fsize uint8 + Fsection TElf32_Section + Finfo TElf32_Word +} + +type TElf_Options_Hw = struct { + Fhwp_flags1 TElf32_Word + Fhwp_flags2 TElf32_Word +} + +type TElf32_Lib = struct { + Fl_name TElf32_Word + Fl_time_stamp TElf32_Word + Fl_checksum TElf32_Word + Fl_version TElf32_Word + Fl_flags TElf32_Word +} + +type TElf64_Lib = struct { + Fl_name TElf64_Word + Fl_time_stamp TElf64_Word + Fl_checksum TElf64_Word + Fl_version TElf64_Word + Fl_flags TElf64_Word +} + +type TElf32_Conflict = uint32 + +type TElf_MIPS_ABIFlags_v0 = struct { + Fversion TElf32_Half + Fisa_level uint8 + Fisa_rev uint8 + Fgpr_size uint8 + Fcpr1_size uint8 + Fcpr2_size uint8 + Ffp_abi uint8 + Fisa_ext TElf32_Word + Fases TElf32_Word + Fflags1 TElf32_Word + Fflags2 TElf32_Word +} + +const _Val_GNU_MIPS_ABI_FP_ANY = 0 +const _Val_GNU_MIPS_ABI_FP_DOUBLE = 1 +const _Val_GNU_MIPS_ABI_FP_SINGLE = 2 +const _Val_GNU_MIPS_ABI_FP_SOFT = 3 +const _Val_GNU_MIPS_ABI_FP_OLD_64 = 4 +const _Val_GNU_MIPS_ABI_FP_XX = 5 +const _Val_GNU_MIPS_ABI_FP_64 = 6 +const _Val_GNU_MIPS_ABI_FP_64A = 7 +const _Val_GNU_MIPS_ABI_FP_MAX = 7 + +type Tsyscall_arg_t = int64 + +type Twchar_t = int32 + +type Tdiv_t = struct { + Fquot int32 + Frem int32 +} + +type Tldiv_t = struct { + Fquot int64 + Frem int64 +} + +type Tlldiv_t = struct { + Fquot int64 + Frem int64 +} + +type t__locale_struct = struct { + Fcat [6]uintptr +} + +type Ttls_module = struct { + Fnext uintptr + Fimage uintptr + Flen1 Tsize_t + Fsize Tsize_t + Falign Tsize_t + Foffset Tsize_t +} + +type t__libc = struct { + Fcan_do_threads int8 + Fthreaded int8 + Fsecure int8 + Fneed_locks int8 + Fthreads_minus_1 int32 + Fauxv uintptr + Ftls_head uintptr + Ftls_size Tsize_t + Ftls_align Tsize_t + Ftls_cnt Tsize_t + Fpage_size Tsize_t + Fglobal_locale t__locale_struct +} + +func Xsysconf(tls *TLS, name int32) (r int64) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(512) + defer tls.Free(512) + var cnt, i, v3 int32 + var mem, v1 uint64 + var val int64 + var v5 uintptr + var _ /* lim at bp+0 */ Trlimit + var _ /* set at bp+16 */ [128]uint8 + var _ /* si at bp+144 */ Tsysinfo + _, _, _, _, _, _, _ = cnt, i, mem, val, v1, v3, v5 + if Uint64FromInt32(name) >= Uint64FromInt64(502)/Uint64FromInt64(2) || !(_values1[name] != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) + } else { + if int32(_values1[name]) >= -int32(1) { + return int64(_values1[name]) + } else { + if int32(_values1[name]) < -int32(256) { + Xgetrlimit(tls, int32(_values1[name])&int32(16383), bp) + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur == ^Uint64FromUint64(0) { + return int64(-int32(1)) + } + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur > uint64(0x7fffffffffffffff) { + v1 = uint64(0x7fffffffffffffff) + } else { + v1 = (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur + } + return Int64FromUint64(v1) + } + } + } + switch Int32FromUint8(Uint8FromInt16(_values1[name])) { + case (-Int32FromInt32(256) | Int32FromInt32(1)) & Int32FromInt32(255): + return int64(200809) + case (-Int32FromInt32(256) | Int32FromInt32(2)) & Int32FromInt32(255): + return int64(ARG_MAX) + case (-Int32FromInt32(256) | Int32FromInt32(3)) & Int32FromInt32(255): + return int64(MQ_PRIO_MAX) + case (-Int32FromInt32(256) | Int32FromInt32(4)) & Int32FromInt32(255): + return int64(PAGESIZE) + case (-Int32FromInt32(256) | Int32FromInt32(5)) & Int32FromInt32(255): + return int64(SEM_VALUE_MAX) + case (-Int32FromInt32(256) | Int32FromInt32(11)) & Int32FromInt32(255): + return int64(DELAYTIMER_MAX) + case (-Int32FromInt32(256) | Int32FromInt32(6)) & Int32FromInt32(255): + fallthrough + case (-Int32FromInt32(256) | Int32FromInt32(7)) & Int32FromInt32(255): + **(**[128]uint8)(__ccgo_up(bp + 16)) = [128]uint8{ + 0: uint8(1), + } + X__syscall3(tls, int64(SYS_sched_getaffinity), int64(Int32FromInt32(0)), Int64FromUint64(Uint64FromInt64(128)), int64(bp+16)) + v3 = Int32FromInt32(0) + cnt = v3 + i = v3 + for { + if !(Uint64FromInt32(i) < uint64(128)) { + break + } + for { + if !((**(**[128]uint8)(__ccgo_up(bp + 16)))[i] != 0) { + break + } + goto _4 + _4: + ; + v5 = bp + 16 + uintptr(i) + *(*uint8)(unsafe.Pointer(v5)) = uint8(int32(*(*uint8)(unsafe.Pointer(v5))) & (Int32FromUint8((**(**[128]uint8)(__ccgo_up(bp + 16)))[i]) - Int32FromInt32(1))) + cnt = cnt + 1 + } + goto _2 + _2: + ; + i = i + 1 + } + return int64(cnt) + case (-Int32FromInt32(256) | Int32FromInt32(8)) & Int32FromInt32(255): + fallthrough + case (-Int32FromInt32(256) | Int32FromInt32(9)) & Int32FromInt32(255): + X__lsysinfo(tls, bp+144) + if !((**(**Tsysinfo)(__ccgo_up(bp + 144))).Fmem_unit != 0) { + (**(**Tsysinfo)(__ccgo_up(bp + 144))).Fmem_unit = uint32(1) + } + if name == int32(_SC_PHYS_PAGES) { + mem = uint64((**(**Tsysinfo)(__ccgo_up(bp + 144))).Ftotalram) + } else { + mem = uint64((**(**Tsysinfo)(__ccgo_up(bp + 144))).Ffreeram + (**(**Tsysinfo)(__ccgo_up(bp + 144))).Fbufferram) + } + mem = mem * uint64((**(**Tsysinfo)(__ccgo_up(bp + 144))).Fmem_unit) + mem = mem / uint64(PAGESIZE) + if mem > uint64(0x7fffffffffffffff) { + v1 = uint64(0x7fffffffffffffff) + } else { + v1 = mem + } + return Int64FromUint64(v1) + case (-Int32FromInt32(256) | Int32FromInt32(12)) & Int32FromInt32(255): + fallthrough + case (-Int32FromInt32(256) | Int32FromInt32(13)) & Int32FromInt32(255): + val = Int64FromUint64(X__getauxval(tls, uint64(AT_MINSIGSTKSZ))) + if val < int64(MINSIGSTKSZ) { + val = int64(MINSIGSTKSZ) + } + if int32(_values1[name]) == -Int32FromInt32(256)|Int32FromInt32(13) { + val = val + int64(Int32FromInt32(SIGSTKSZ)-Int32FromInt32(MINSIGSTKSZ)) + } + return val + case (-Int32FromInt32(256) | Int32FromInt32(10)) & Int32FromInt32(255): + return 0 + } + return int64(_values1[name]) +} + +var _values1 = [251]int16{ + 0: int16(-Int32FromInt32(256) | Int32FromInt32(2)), + 1: int16(-Int32FromInt32(32768) | Int32FromInt32(RLIMIT_NPROC)), + 2: int16(100), + 3: int16(32), + 4: int16(-Int32FromInt32(32768) | Int32FromInt32(RLIMIT_NOFILE)), + 5: int16(-int32(1)), + 6: int16(TZNAME_MAX), + 7: int16(1), + 8: int16(1), + 9: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 10: int16(-int32(1)), + 11: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 12: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 13: int16(-int32(1)), + 14: int16(-int32(1)), + 15: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 16: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 17: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 18: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 19: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 20: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 21: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 22: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 23: int16(-int32(1)), + 24: int16(-int32(1)), + 25: int16(-Int32FromInt32(256) | Int32FromInt32(10)), + 26: int16(-Int32FromInt32(256) | Int32FromInt32(11)), + 27: int16(-int32(1)), + 28: int16(-Int32FromInt32(256) | Int32FromInt32(3)), + 29: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 30: int16(-Int32FromInt32(256) | Int32FromInt32(4)), + 31: int16(Int32FromInt32(_NSIG) - Int32FromInt32(1) - Int32FromInt32(31) - Int32FromInt32(3)), + 32: int16(SEM_NSEMS_MAX), + 33: int16(-Int32FromInt32(256) | Int32FromInt32(5)), + 34: int16(-int32(1)), + 35: int16(-int32(1)), + 36: int16(_POSIX2_BC_BASE_MAX), + 37: int16(_POSIX2_BC_DIM_MAX), + 38: int16(_POSIX2_BC_SCALE_MAX), + 39: int16(_POSIX2_BC_STRING_MAX), + 40: int16(COLL_WEIGHTS_MAX), + 42: int16(-int32(1)), + 43: int16(-int32(1)), + 44: int16(RE_DUP_MAX), + 46: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 47: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 48: int16(-int32(1)), + 49: int16(-int32(1)), + 50: int16(-int32(1)), + 51: int16(-int32(1)), + 52: int16(-int32(1)), + 60: int16(IOV_MAX), + 67: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 68: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 69: int16(-int32(1)), + 70: int16(-int32(1)), + 71: int16(256), + 72: int16(TTY_NAME_MAX), + 73: int16(PTHREAD_DESTRUCTOR_ITERATIONS), + 74: int16(PTHREAD_KEYS_MAX), + 75: int16(PTHREAD_STACK_MIN), + 76: int16(-int32(1)), + 77: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 78: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 79: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 80: int16(-int32(1)), + 81: int16(-int32(1)), + 82: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 83: int16(-Int32FromInt32(256) | Int32FromInt32(6)), + 84: int16(-Int32FromInt32(256) | Int32FromInt32(7)), + 85: int16(-Int32FromInt32(256) | Int32FromInt32(8)), + 86: int16(-Int32FromInt32(256) | Int32FromInt32(9)), + 87: int16(-int32(1)), + 88: int16(-int32(1)), + 89: int16(_XOPEN_VERSION), + 90: int16(_XOPEN_VERSION), + 91: int16(1), + 92: int16(-int32(1)), + 93: int16(1), + 94: int16(1), + 95: int16(-int32(1)), + 97: int16(-int32(1)), + 98: int16(-int32(1)), + 99: int16(-int32(1)), + 100: int16(-int32(1)), + 109: int16(NZERO), + 125: int16(-int32(1)), + 126: int16(-int32(1)), + 127: int16(1), + 128: int16(-int32(1)), + 129: int16(-int32(1)), + 130: int16(-int32(1)), + 131: int16(-int32(1)), + 132: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 133: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 137: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 138: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 139: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 149: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 153: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 154: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 155: int16(1), + 157: int16(1), + 159: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 160: int16(-int32(1)), + 161: int16(-int32(1)), + 164: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 165: int16(-int32(1)), + 168: int16(-int32(1)), + 169: int16(-int32(1)), + 170: int16(-int32(1)), + 171: int16(-int32(1)), + 172: int16(-int32(1)), + 173: int16(SYMLOOP_MAX), + 174: int16(-Int32FromInt32(256) | Int32FromInt32(10)), + 175: int16(-int32(1)), + 176: int16(-int32(1)), + 177: int16(-int32(1)), + 178: int16(1), + 179: int16(-int32(1)), + 180: int16(HOST_NAME_MAX), + 181: int16(-int32(1)), + 182: int16(-int32(1)), + 183: int16(-int32(1)), + 184: int16(-int32(1)), + 235: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 236: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 237: int16(-int32(1)), + 238: int16(-int32(1)), + 239: int16(1), + 240: int16(-int32(1)), + 241: int16(-int32(1)), + 242: int16(-int32(1)), + 243: int16(-int32(1)), + 244: int16(-int32(1)), + 245: int16(-int32(1)), + 246: int16(-Int32FromInt32(256) | Int32FromInt32(10)), + 247: int16(-int32(1)), + 248: int16(-int32(1)), + 249: int16(-Int32FromInt32(256) | Int32FromInt32(12)), + 250: int16(-Int32FromInt32(256) | Int32FromInt32(13)), +} + +type Tcrypt_data = struct { + Finitialized int32 + F__buf [256]int8 +} + +func Xcrypt(tls *TLS, key uintptr, salt uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v salt=%v, (%v:)", tls, key, salt, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__crypt_r(tls, key, salt, uintptr(unsafe.Pointer(&_buf))) +} + +/* This buffer is sufficiently large for all + * currently-supported hash types. It needs to be updated if + * longer hashes are added. The cast to struct crypt_data * is + * purely to meet the public API requirements of the crypt_r + * function; the implementation of crypt_r uses the object + * purely as a char buffer. */ +var _buf [128]int8 + +const BF_N = 16 + +type Tlocale_t = uintptr + +type TBF_word = uint32 + +type TBF_word_signed = int32 + +/* Number of Blowfish rounds, this is also hardcoded into a few places */ + +type TBF_key = [18]TBF_word + +type TBF_ctx = struct { + FPS [0][1042]TBF_word + Fs struct { + FP TBF_key + FS [4][256]TBF_word + } +} + +// C documentation +// +// /* +// * Magic IV for 64 Blowfish encryptions that we do at the end. +// * The string is "OrpheanBeholderScryDoubt" on big-endian. +// */ +var _BF_magic_w = [6]TBF_word{ + 0: uint32(0x4F727068), + 1: uint32(0x65616E42), + 2: uint32(0x65686F6C), + 3: uint32(0x64657253), + 4: uint32(0x63727944), + 5: uint32(0x6F756274), +} + +// C documentation +// +// /* +// * P-box and S-box tables initialized with digits of Pi. +// */ +var _BF_init_state = *(*TBF_ctx)(unsafe.Pointer(&struct { + FP TBF_key + FS [4][256]TBF_word +}{ + FP: TBF_key{ + 0: uint32(0x243f6a88), + 1: uint32(0x85a308d3), + 2: uint32(0x13198a2e), + 3: uint32(0x03707344), + 4: uint32(0xa4093822), + 5: uint32(0x299f31d0), + 6: uint32(0x082efa98), + 7: uint32(0xec4e6c89), + 8: uint32(0x452821e6), + 9: uint32(0x38d01377), + 10: uint32(0xbe5466cf), + 11: uint32(0x34e90c6c), + 12: uint32(0xc0ac29b7), + 13: uint32(0xc97c50dd), + 14: uint32(0x3f84d5b5), + 15: uint32(0xb5470917), + 16: uint32(0x9216d5d9), + 17: uint32(0x8979fb1b), + }, + FS: [4][256]TBF_word{ + 0: { + 0: uint32(0xd1310ba6), + 1: uint32(0x98dfb5ac), + 2: uint32(0x2ffd72db), + 3: uint32(0xd01adfb7), + 4: uint32(0xb8e1afed), + 5: uint32(0x6a267e96), + 6: uint32(0xba7c9045), + 7: uint32(0xf12c7f99), + 8: uint32(0x24a19947), + 9: uint32(0xb3916cf7), + 10: uint32(0x0801f2e2), + 11: uint32(0x858efc16), + 12: uint32(0x636920d8), + 13: uint32(0x71574e69), + 14: uint32(0xa458fea3), + 15: uint32(0xf4933d7e), + 16: uint32(0x0d95748f), + 17: uint32(0x728eb658), + 18: uint32(0x718bcd58), + 19: uint32(0x82154aee), + 20: uint32(0x7b54a41d), + 21: uint32(0xc25a59b5), + 22: uint32(0x9c30d539), + 23: uint32(0x2af26013), + 24: uint32(0xc5d1b023), + 25: uint32(0x286085f0), + 26: uint32(0xca417918), + 27: uint32(0xb8db38ef), + 28: uint32(0x8e79dcb0), + 29: uint32(0x603a180e), + 30: uint32(0x6c9e0e8b), + 31: uint32(0xb01e8a3e), + 32: uint32(0xd71577c1), + 33: uint32(0xbd314b27), + 34: uint32(0x78af2fda), + 35: uint32(0x55605c60), + 36: uint32(0xe65525f3), + 37: uint32(0xaa55ab94), + 38: uint32(0x57489862), + 39: uint32(0x63e81440), + 40: uint32(0x55ca396a), + 41: uint32(0x2aab10b6), + 42: uint32(0xb4cc5c34), + 43: uint32(0x1141e8ce), + 44: uint32(0xa15486af), + 45: uint32(0x7c72e993), + 46: uint32(0xb3ee1411), + 47: uint32(0x636fbc2a), + 48: uint32(0x2ba9c55d), + 49: uint32(0x741831f6), + 50: uint32(0xce5c3e16), + 51: uint32(0x9b87931e), + 52: uint32(0xafd6ba33), + 53: uint32(0x6c24cf5c), + 54: uint32(0x7a325381), + 55: uint32(0x28958677), + 56: uint32(0x3b8f4898), + 57: uint32(0x6b4bb9af), + 58: uint32(0xc4bfe81b), + 59: uint32(0x66282193), + 60: uint32(0x61d809cc), + 61: uint32(0xfb21a991), + 62: uint32(0x487cac60), + 63: uint32(0x5dec8032), + 64: uint32(0xef845d5d), + 65: uint32(0xe98575b1), + 66: uint32(0xdc262302), + 67: uint32(0xeb651b88), + 68: uint32(0x23893e81), + 69: uint32(0xd396acc5), + 70: uint32(0x0f6d6ff3), + 71: uint32(0x83f44239), + 72: uint32(0x2e0b4482), + 73: uint32(0xa4842004), + 74: uint32(0x69c8f04a), + 75: uint32(0x9e1f9b5e), + 76: uint32(0x21c66842), + 77: uint32(0xf6e96c9a), + 78: uint32(0x670c9c61), + 79: uint32(0xabd388f0), + 80: uint32(0x6a51a0d2), + 81: uint32(0xd8542f68), + 82: uint32(0x960fa728), + 83: uint32(0xab5133a3), + 84: uint32(0x6eef0b6c), + 85: uint32(0x137a3be4), + 86: uint32(0xba3bf050), + 87: uint32(0x7efb2a98), + 88: uint32(0xa1f1651d), + 89: uint32(0x39af0176), + 90: uint32(0x66ca593e), + 91: uint32(0x82430e88), + 92: uint32(0x8cee8619), + 93: uint32(0x456f9fb4), + 94: uint32(0x7d84a5c3), + 95: uint32(0x3b8b5ebe), + 96: uint32(0xe06f75d8), + 97: uint32(0x85c12073), + 98: uint32(0x401a449f), + 99: uint32(0x56c16aa6), + 100: uint32(0x4ed3aa62), + 101: uint32(0x363f7706), + 102: uint32(0x1bfedf72), + 103: uint32(0x429b023d), + 104: uint32(0x37d0d724), + 105: uint32(0xd00a1248), + 106: uint32(0xdb0fead3), + 107: uint32(0x49f1c09b), + 108: uint32(0x075372c9), + 109: uint32(0x80991b7b), + 110: uint32(0x25d479d8), + 111: uint32(0xf6e8def7), + 112: uint32(0xe3fe501a), + 113: uint32(0xb6794c3b), + 114: uint32(0x976ce0bd), + 115: uint32(0x04c006ba), + 116: uint32(0xc1a94fb6), + 117: uint32(0x409f60c4), + 118: uint32(0x5e5c9ec2), + 119: uint32(0x196a2463), + 120: uint32(0x68fb6faf), + 121: uint32(0x3e6c53b5), + 122: uint32(0x1339b2eb), + 123: uint32(0x3b52ec6f), + 124: uint32(0x6dfc511f), + 125: uint32(0x9b30952c), + 126: uint32(0xcc814544), + 127: uint32(0xaf5ebd09), + 128: uint32(0xbee3d004), + 129: uint32(0xde334afd), + 130: uint32(0x660f2807), + 131: uint32(0x192e4bb3), + 132: uint32(0xc0cba857), + 133: uint32(0x45c8740f), + 134: uint32(0xd20b5f39), + 135: uint32(0xb9d3fbdb), + 136: uint32(0x5579c0bd), + 137: uint32(0x1a60320a), + 138: uint32(0xd6a100c6), + 139: uint32(0x402c7279), + 140: uint32(0x679f25fe), + 141: uint32(0xfb1fa3cc), + 142: uint32(0x8ea5e9f8), + 143: uint32(0xdb3222f8), + 144: uint32(0x3c7516df), + 145: uint32(0xfd616b15), + 146: uint32(0x2f501ec8), + 147: uint32(0xad0552ab), + 148: uint32(0x323db5fa), + 149: uint32(0xfd238760), + 150: uint32(0x53317b48), + 151: uint32(0x3e00df82), + 152: uint32(0x9e5c57bb), + 153: uint32(0xca6f8ca0), + 154: uint32(0x1a87562e), + 155: uint32(0xdf1769db), + 156: uint32(0xd542a8f6), + 157: uint32(0x287effc3), + 158: uint32(0xac6732c6), + 159: uint32(0x8c4f5573), + 160: uint32(0x695b27b0), + 161: uint32(0xbbca58c8), + 162: uint32(0xe1ffa35d), + 163: uint32(0xb8f011a0), + 164: uint32(0x10fa3d98), + 165: uint32(0xfd2183b8), + 166: uint32(0x4afcb56c), + 167: uint32(0x2dd1d35b), + 168: uint32(0x9a53e479), + 169: uint32(0xb6f84565), + 170: uint32(0xd28e49bc), + 171: uint32(0x4bfb9790), + 172: uint32(0xe1ddf2da), + 173: uint32(0xa4cb7e33), + 174: uint32(0x62fb1341), + 175: uint32(0xcee4c6e8), + 176: uint32(0xef20cada), + 177: uint32(0x36774c01), + 178: uint32(0xd07e9efe), + 179: uint32(0x2bf11fb4), + 180: uint32(0x95dbda4d), + 181: uint32(0xae909198), + 182: uint32(0xeaad8e71), + 183: uint32(0x6b93d5a0), + 184: uint32(0xd08ed1d0), + 185: uint32(0xafc725e0), + 186: uint32(0x8e3c5b2f), + 187: uint32(0x8e7594b7), + 188: uint32(0x8ff6e2fb), + 189: uint32(0xf2122b64), + 190: uint32(0x8888b812), + 191: uint32(0x900df01c), + 192: uint32(0x4fad5ea0), + 193: uint32(0x688fc31c), + 194: uint32(0xd1cff191), + 195: uint32(0xb3a8c1ad), + 196: uint32(0x2f2f2218), + 197: uint32(0xbe0e1777), + 198: uint32(0xea752dfe), + 199: uint32(0x8b021fa1), + 200: uint32(0xe5a0cc0f), + 201: uint32(0xb56f74e8), + 202: uint32(0x18acf3d6), + 203: uint32(0xce89e299), + 204: uint32(0xb4a84fe0), + 205: uint32(0xfd13e0b7), + 206: uint32(0x7cc43b81), + 207: uint32(0xd2ada8d9), + 208: uint32(0x165fa266), + 209: uint32(0x80957705), + 210: uint32(0x93cc7314), + 211: uint32(0x211a1477), + 212: uint32(0xe6ad2065), + 213: uint32(0x77b5fa86), + 214: uint32(0xc75442f5), + 215: uint32(0xfb9d35cf), + 216: uint32(0xebcdaf0c), + 217: uint32(0x7b3e89a0), + 218: uint32(0xd6411bd3), + 219: uint32(0xae1e7e49), + 220: uint32(0x00250e2d), + 221: uint32(0x2071b35e), + 222: uint32(0x226800bb), + 223: uint32(0x57b8e0af), + 224: uint32(0x2464369b), + 225: uint32(0xf009b91e), + 226: uint32(0x5563911d), + 227: uint32(0x59dfa6aa), + 228: uint32(0x78c14389), + 229: uint32(0xd95a537f), + 230: uint32(0x207d5ba2), + 231: uint32(0x02e5b9c5), + 232: uint32(0x83260376), + 233: uint32(0x6295cfa9), + 234: uint32(0x11c81968), + 235: uint32(0x4e734a41), + 236: uint32(0xb3472dca), + 237: uint32(0x7b14a94a), + 238: uint32(0x1b510052), + 239: uint32(0x9a532915), + 240: uint32(0xd60f573f), + 241: uint32(0xbc9bc6e4), + 242: uint32(0x2b60a476), + 243: uint32(0x81e67400), + 244: uint32(0x08ba6fb5), + 245: uint32(0x571be91f), + 246: uint32(0xf296ec6b), + 247: uint32(0x2a0dd915), + 248: uint32(0xb6636521), + 249: uint32(0xe7b9f9b6), + 250: uint32(0xff34052e), + 251: uint32(0xc5855664), + 252: uint32(0x53b02d5d), + 253: uint32(0xa99f8fa1), + 254: uint32(0x08ba4799), + 255: uint32(0x6e85076a), + }, + 1: { + 0: uint32(0x4b7a70e9), + 1: uint32(0xb5b32944), + 2: uint32(0xdb75092e), + 3: uint32(0xc4192623), + 4: uint32(0xad6ea6b0), + 5: uint32(0x49a7df7d), + 6: uint32(0x9cee60b8), + 7: uint32(0x8fedb266), + 8: uint32(0xecaa8c71), + 9: uint32(0x699a17ff), + 10: uint32(0x5664526c), + 11: uint32(0xc2b19ee1), + 12: uint32(0x193602a5), + 13: uint32(0x75094c29), + 14: uint32(0xa0591340), + 15: uint32(0xe4183a3e), + 16: uint32(0x3f54989a), + 17: uint32(0x5b429d65), + 18: uint32(0x6b8fe4d6), + 19: uint32(0x99f73fd6), + 20: uint32(0xa1d29c07), + 21: uint32(0xefe830f5), + 22: uint32(0x4d2d38e6), + 23: uint32(0xf0255dc1), + 24: uint32(0x4cdd2086), + 25: uint32(0x8470eb26), + 26: uint32(0x6382e9c6), + 27: uint32(0x021ecc5e), + 28: uint32(0x09686b3f), + 29: uint32(0x3ebaefc9), + 30: uint32(0x3c971814), + 31: uint32(0x6b6a70a1), + 32: uint32(0x687f3584), + 33: uint32(0x52a0e286), + 34: uint32(0xb79c5305), + 35: uint32(0xaa500737), + 36: uint32(0x3e07841c), + 37: uint32(0x7fdeae5c), + 38: uint32(0x8e7d44ec), + 39: uint32(0x5716f2b8), + 40: uint32(0xb03ada37), + 41: uint32(0xf0500c0d), + 42: uint32(0xf01c1f04), + 43: uint32(0x0200b3ff), + 44: uint32(0xae0cf51a), + 45: uint32(0x3cb574b2), + 46: uint32(0x25837a58), + 47: uint32(0xdc0921bd), + 48: uint32(0xd19113f9), + 49: uint32(0x7ca92ff6), + 50: uint32(0x94324773), + 51: uint32(0x22f54701), + 52: uint32(0x3ae5e581), + 53: uint32(0x37c2dadc), + 54: uint32(0xc8b57634), + 55: uint32(0x9af3dda7), + 56: uint32(0xa9446146), + 57: uint32(0x0fd0030e), + 58: uint32(0xecc8c73e), + 59: uint32(0xa4751e41), + 60: uint32(0xe238cd99), + 61: uint32(0x3bea0e2f), + 62: uint32(0x3280bba1), + 63: uint32(0x183eb331), + 64: uint32(0x4e548b38), + 65: uint32(0x4f6db908), + 66: uint32(0x6f420d03), + 67: uint32(0xf60a04bf), + 68: uint32(0x2cb81290), + 69: uint32(0x24977c79), + 70: uint32(0x5679b072), + 71: uint32(0xbcaf89af), + 72: uint32(0xde9a771f), + 73: uint32(0xd9930810), + 74: uint32(0xb38bae12), + 75: uint32(0xdccf3f2e), + 76: uint32(0x5512721f), + 77: uint32(0x2e6b7124), + 78: uint32(0x501adde6), + 79: uint32(0x9f84cd87), + 80: uint32(0x7a584718), + 81: uint32(0x7408da17), + 82: uint32(0xbc9f9abc), + 83: uint32(0xe94b7d8c), + 84: uint32(0xec7aec3a), + 85: uint32(0xdb851dfa), + 86: uint32(0x63094366), + 87: uint32(0xc464c3d2), + 88: uint32(0xef1c1847), + 89: uint32(0x3215d908), + 90: uint32(0xdd433b37), + 91: uint32(0x24c2ba16), + 92: uint32(0x12a14d43), + 93: uint32(0x2a65c451), + 94: uint32(0x50940002), + 95: uint32(0x133ae4dd), + 96: uint32(0x71dff89e), + 97: uint32(0x10314e55), + 98: uint32(0x81ac77d6), + 99: uint32(0x5f11199b), + 100: uint32(0x043556f1), + 101: uint32(0xd7a3c76b), + 102: uint32(0x3c11183b), + 103: uint32(0x5924a509), + 104: uint32(0xf28fe6ed), + 105: uint32(0x97f1fbfa), + 106: uint32(0x9ebabf2c), + 107: uint32(0x1e153c6e), + 108: uint32(0x86e34570), + 109: uint32(0xeae96fb1), + 110: uint32(0x860e5e0a), + 111: uint32(0x5a3e2ab3), + 112: uint32(0x771fe71c), + 113: uint32(0x4e3d06fa), + 114: uint32(0x2965dcb9), + 115: uint32(0x99e71d0f), + 116: uint32(0x803e89d6), + 117: uint32(0x5266c825), + 118: uint32(0x2e4cc978), + 119: uint32(0x9c10b36a), + 120: uint32(0xc6150eba), + 121: uint32(0x94e2ea78), + 122: uint32(0xa5fc3c53), + 123: uint32(0x1e0a2df4), + 124: uint32(0xf2f74ea7), + 125: uint32(0x361d2b3d), + 126: uint32(0x1939260f), + 127: uint32(0x19c27960), + 128: uint32(0x5223a708), + 129: uint32(0xf71312b6), + 130: uint32(0xebadfe6e), + 131: uint32(0xeac31f66), + 132: uint32(0xe3bc4595), + 133: uint32(0xa67bc883), + 134: uint32(0xb17f37d1), + 135: uint32(0x018cff28), + 136: uint32(0xc332ddef), + 137: uint32(0xbe6c5aa5), + 138: uint32(0x65582185), + 139: uint32(0x68ab9802), + 140: uint32(0xeecea50f), + 141: uint32(0xdb2f953b), + 142: uint32(0x2aef7dad), + 143: uint32(0x5b6e2f84), + 144: uint32(0x1521b628), + 145: uint32(0x29076170), + 146: uint32(0xecdd4775), + 147: uint32(0x619f1510), + 148: uint32(0x13cca830), + 149: uint32(0xeb61bd96), + 150: uint32(0x0334fe1e), + 151: uint32(0xaa0363cf), + 152: uint32(0xb5735c90), + 153: uint32(0x4c70a239), + 154: uint32(0xd59e9e0b), + 155: uint32(0xcbaade14), + 156: uint32(0xeecc86bc), + 157: uint32(0x60622ca7), + 158: uint32(0x9cab5cab), + 159: uint32(0xb2f3846e), + 160: uint32(0x648b1eaf), + 161: uint32(0x19bdf0ca), + 162: uint32(0xa02369b9), + 163: uint32(0x655abb50), + 164: uint32(0x40685a32), + 165: uint32(0x3c2ab4b3), + 166: uint32(0x319ee9d5), + 167: uint32(0xc021b8f7), + 168: uint32(0x9b540b19), + 169: uint32(0x875fa099), + 170: uint32(0x95f7997e), + 171: uint32(0x623d7da8), + 172: uint32(0xf837889a), + 173: uint32(0x97e32d77), + 174: uint32(0x11ed935f), + 175: uint32(0x16681281), + 176: uint32(0x0e358829), + 177: uint32(0xc7e61fd6), + 178: uint32(0x96dedfa1), + 179: uint32(0x7858ba99), + 180: uint32(0x57f584a5), + 181: uint32(0x1b227263), + 182: uint32(0x9b83c3ff), + 183: uint32(0x1ac24696), + 184: uint32(0xcdb30aeb), + 185: uint32(0x532e3054), + 186: uint32(0x8fd948e4), + 187: uint32(0x6dbc3128), + 188: uint32(0x58ebf2ef), + 189: uint32(0x34c6ffea), + 190: uint32(0xfe28ed61), + 191: uint32(0xee7c3c73), + 192: uint32(0x5d4a14d9), + 193: uint32(0xe864b7e3), + 194: uint32(0x42105d14), + 195: uint32(0x203e13e0), + 196: uint32(0x45eee2b6), + 197: uint32(0xa3aaabea), + 198: uint32(0xdb6c4f15), + 199: uint32(0xfacb4fd0), + 200: uint32(0xc742f442), + 201: uint32(0xef6abbb5), + 202: uint32(0x654f3b1d), + 203: uint32(0x41cd2105), + 204: uint32(0xd81e799e), + 205: uint32(0x86854dc7), + 206: uint32(0xe44b476a), + 207: uint32(0x3d816250), + 208: uint32(0xcf62a1f2), + 209: uint32(0x5b8d2646), + 210: uint32(0xfc8883a0), + 211: uint32(0xc1c7b6a3), + 212: uint32(0x7f1524c3), + 213: uint32(0x69cb7492), + 214: uint32(0x47848a0b), + 215: uint32(0x5692b285), + 216: uint32(0x095bbf00), + 217: uint32(0xad19489d), + 218: uint32(0x1462b174), + 219: uint32(0x23820e00), + 220: uint32(0x58428d2a), + 221: uint32(0x0c55f5ea), + 222: uint32(0x1dadf43e), + 223: uint32(0x233f7061), + 224: uint32(0x3372f092), + 225: uint32(0x8d937e41), + 226: uint32(0xd65fecf1), + 227: uint32(0x6c223bdb), + 228: uint32(0x7cde3759), + 229: uint32(0xcbee7460), + 230: uint32(0x4085f2a7), + 231: uint32(0xce77326e), + 232: uint32(0xa6078084), + 233: uint32(0x19f8509e), + 234: uint32(0xe8efd855), + 235: uint32(0x61d99735), + 236: uint32(0xa969a7aa), + 237: uint32(0xc50c06c2), + 238: uint32(0x5a04abfc), + 239: uint32(0x800bcadc), + 240: uint32(0x9e447a2e), + 241: uint32(0xc3453484), + 242: uint32(0xfdd56705), + 243: uint32(0x0e1e9ec9), + 244: uint32(0xdb73dbd3), + 245: uint32(0x105588cd), + 246: uint32(0x675fda79), + 247: uint32(0xe3674340), + 248: uint32(0xc5c43465), + 249: uint32(0x713e38d8), + 250: uint32(0x3d28f89e), + 251: uint32(0xf16dff20), + 252: uint32(0x153e21e7), + 253: uint32(0x8fb03d4a), + 254: uint32(0xe6e39f2b), + 255: uint32(0xdb83adf7), + }, + 2: { + 0: uint32(0xe93d5a68), + 1: uint32(0x948140f7), + 2: uint32(0xf64c261c), + 3: uint32(0x94692934), + 4: uint32(0x411520f7), + 5: uint32(0x7602d4f7), + 6: uint32(0xbcf46b2e), + 7: uint32(0xd4a20068), + 8: uint32(0xd4082471), + 9: uint32(0x3320f46a), + 10: uint32(0x43b7d4b7), + 11: uint32(0x500061af), + 12: uint32(0x1e39f62e), + 13: uint32(0x97244546), + 14: uint32(0x14214f74), + 15: uint32(0xbf8b8840), + 16: uint32(0x4d95fc1d), + 17: uint32(0x96b591af), + 18: uint32(0x70f4ddd3), + 19: uint32(0x66a02f45), + 20: uint32(0xbfbc09ec), + 21: uint32(0x03bd9785), + 22: uint32(0x7fac6dd0), + 23: uint32(0x31cb8504), + 24: uint32(0x96eb27b3), + 25: uint32(0x55fd3941), + 26: uint32(0xda2547e6), + 27: uint32(0xabca0a9a), + 28: uint32(0x28507825), + 29: uint32(0x530429f4), + 30: uint32(0x0a2c86da), + 31: uint32(0xe9b66dfb), + 32: uint32(0x68dc1462), + 33: uint32(0xd7486900), + 34: uint32(0x680ec0a4), + 35: uint32(0x27a18dee), + 36: uint32(0x4f3ffea2), + 37: uint32(0xe887ad8c), + 38: uint32(0xb58ce006), + 39: uint32(0x7af4d6b6), + 40: uint32(0xaace1e7c), + 41: uint32(0xd3375fec), + 42: uint32(0xce78a399), + 43: uint32(0x406b2a42), + 44: uint32(0x20fe9e35), + 45: uint32(0xd9f385b9), + 46: uint32(0xee39d7ab), + 47: uint32(0x3b124e8b), + 48: uint32(0x1dc9faf7), + 49: uint32(0x4b6d1856), + 50: uint32(0x26a36631), + 51: uint32(0xeae397b2), + 52: uint32(0x3a6efa74), + 53: uint32(0xdd5b4332), + 54: uint32(0x6841e7f7), + 55: uint32(0xca7820fb), + 56: uint32(0xfb0af54e), + 57: uint32(0xd8feb397), + 58: uint32(0x454056ac), + 59: uint32(0xba489527), + 60: uint32(0x55533a3a), + 61: uint32(0x20838d87), + 62: uint32(0xfe6ba9b7), + 63: uint32(0xd096954b), + 64: uint32(0x55a867bc), + 65: uint32(0xa1159a58), + 66: uint32(0xcca92963), + 67: uint32(0x99e1db33), + 68: uint32(0xa62a4a56), + 69: uint32(0x3f3125f9), + 70: uint32(0x5ef47e1c), + 71: uint32(0x9029317c), + 72: uint32(0xfdf8e802), + 73: uint32(0x04272f70), + 74: uint32(0x80bb155c), + 75: uint32(0x05282ce3), + 76: uint32(0x95c11548), + 77: uint32(0xe4c66d22), + 78: uint32(0x48c1133f), + 79: uint32(0xc70f86dc), + 80: uint32(0x07f9c9ee), + 81: uint32(0x41041f0f), + 82: uint32(0x404779a4), + 83: uint32(0x5d886e17), + 84: uint32(0x325f51eb), + 85: uint32(0xd59bc0d1), + 86: uint32(0xf2bcc18f), + 87: uint32(0x41113564), + 88: uint32(0x257b7834), + 89: uint32(0x602a9c60), + 90: uint32(0xdff8e8a3), + 91: uint32(0x1f636c1b), + 92: uint32(0x0e12b4c2), + 93: uint32(0x02e1329e), + 94: uint32(0xaf664fd1), + 95: uint32(0xcad18115), + 96: uint32(0x6b2395e0), + 97: uint32(0x333e92e1), + 98: uint32(0x3b240b62), + 99: uint32(0xeebeb922), + 100: uint32(0x85b2a20e), + 101: uint32(0xe6ba0d99), + 102: uint32(0xde720c8c), + 103: uint32(0x2da2f728), + 104: uint32(0xd0127845), + 105: uint32(0x95b794fd), + 106: uint32(0x647d0862), + 107: uint32(0xe7ccf5f0), + 108: uint32(0x5449a36f), + 109: uint32(0x877d48fa), + 110: uint32(0xc39dfd27), + 111: uint32(0xf33e8d1e), + 112: uint32(0x0a476341), + 113: uint32(0x992eff74), + 114: uint32(0x3a6f6eab), + 115: uint32(0xf4f8fd37), + 116: uint32(0xa812dc60), + 117: uint32(0xa1ebddf8), + 118: uint32(0x991be14c), + 119: uint32(0xdb6e6b0d), + 120: uint32(0xc67b5510), + 121: uint32(0x6d672c37), + 122: uint32(0x2765d43b), + 123: uint32(0xdcd0e804), + 124: uint32(0xf1290dc7), + 125: uint32(0xcc00ffa3), + 126: uint32(0xb5390f92), + 127: uint32(0x690fed0b), + 128: uint32(0x667b9ffb), + 129: uint32(0xcedb7d9c), + 130: uint32(0xa091cf0b), + 131: uint32(0xd9155ea3), + 132: uint32(0xbb132f88), + 133: uint32(0x515bad24), + 134: uint32(0x7b9479bf), + 135: uint32(0x763bd6eb), + 136: uint32(0x37392eb3), + 137: uint32(0xcc115979), + 138: uint32(0x8026e297), + 139: uint32(0xf42e312d), + 140: uint32(0x6842ada7), + 141: uint32(0xc66a2b3b), + 142: uint32(0x12754ccc), + 143: uint32(0x782ef11c), + 144: uint32(0x6a124237), + 145: uint32(0xb79251e7), + 146: uint32(0x06a1bbe6), + 147: uint32(0x4bfb6350), + 148: uint32(0x1a6b1018), + 149: uint32(0x11caedfa), + 150: uint32(0x3d25bdd8), + 151: uint32(0xe2e1c3c9), + 152: uint32(0x44421659), + 153: uint32(0x0a121386), + 154: uint32(0xd90cec6e), + 155: uint32(0xd5abea2a), + 156: uint32(0x64af674e), + 157: uint32(0xda86a85f), + 158: uint32(0xbebfe988), + 159: uint32(0x64e4c3fe), + 160: uint32(0x9dbc8057), + 161: uint32(0xf0f7c086), + 162: uint32(0x60787bf8), + 163: uint32(0x6003604d), + 164: uint32(0xd1fd8346), + 165: uint32(0xf6381fb0), + 166: uint32(0x7745ae04), + 167: uint32(0xd736fccc), + 168: uint32(0x83426b33), + 169: uint32(0xf01eab71), + 170: uint32(0xb0804187), + 171: uint32(0x3c005e5f), + 172: uint32(0x77a057be), + 173: uint32(0xbde8ae24), + 174: uint32(0x55464299), + 175: uint32(0xbf582e61), + 176: uint32(0x4e58f48f), + 177: uint32(0xf2ddfda2), + 178: uint32(0xf474ef38), + 179: uint32(0x8789bdc2), + 180: uint32(0x5366f9c3), + 181: uint32(0xc8b38e74), + 182: uint32(0xb475f255), + 183: uint32(0x46fcd9b9), + 184: uint32(0x7aeb2661), + 185: uint32(0x8b1ddf84), + 186: uint32(0x846a0e79), + 187: uint32(0x915f95e2), + 188: uint32(0x466e598e), + 189: uint32(0x20b45770), + 190: uint32(0x8cd55591), + 191: uint32(0xc902de4c), + 192: uint32(0xb90bace1), + 193: uint32(0xbb8205d0), + 194: uint32(0x11a86248), + 195: uint32(0x7574a99e), + 196: uint32(0xb77f19b6), + 197: uint32(0xe0a9dc09), + 198: uint32(0x662d09a1), + 199: uint32(0xc4324633), + 200: uint32(0xe85a1f02), + 201: uint32(0x09f0be8c), + 202: uint32(0x4a99a025), + 203: uint32(0x1d6efe10), + 204: uint32(0x1ab93d1d), + 205: uint32(0x0ba5a4df), + 206: uint32(0xa186f20f), + 207: uint32(0x2868f169), + 208: uint32(0xdcb7da83), + 209: uint32(0x573906fe), + 210: uint32(0xa1e2ce9b), + 211: uint32(0x4fcd7f52), + 212: uint32(0x50115e01), + 213: uint32(0xa70683fa), + 214: uint32(0xa002b5c4), + 215: uint32(0x0de6d027), + 216: uint32(0x9af88c27), + 217: uint32(0x773f8641), + 218: uint32(0xc3604c06), + 219: uint32(0x61a806b5), + 220: uint32(0xf0177a28), + 221: uint32(0xc0f586e0), + 222: uint32(0x006058aa), + 223: uint32(0x30dc7d62), + 224: uint32(0x11e69ed7), + 225: uint32(0x2338ea63), + 226: uint32(0x53c2dd94), + 227: uint32(0xc2c21634), + 228: uint32(0xbbcbee56), + 229: uint32(0x90bcb6de), + 230: uint32(0xebfc7da1), + 231: uint32(0xce591d76), + 232: uint32(0x6f05e409), + 233: uint32(0x4b7c0188), + 234: uint32(0x39720a3d), + 235: uint32(0x7c927c24), + 236: uint32(0x86e3725f), + 237: uint32(0x724d9db9), + 238: uint32(0x1ac15bb4), + 239: uint32(0xd39eb8fc), + 240: uint32(0xed545578), + 241: uint32(0x08fca5b5), + 242: uint32(0xd83d7cd3), + 243: uint32(0x4dad0fc4), + 244: uint32(0x1e50ef5e), + 245: uint32(0xb161e6f8), + 246: uint32(0xa28514d9), + 247: uint32(0x6c51133c), + 248: uint32(0x6fd5c7e7), + 249: uint32(0x56e14ec4), + 250: uint32(0x362abfce), + 251: uint32(0xddc6c837), + 252: uint32(0xd79a3234), + 253: uint32(0x92638212), + 254: uint32(0x670efa8e), + 255: uint32(0x406000e0), + }, + 3: { + 0: uint32(0x3a39ce37), + 1: uint32(0xd3faf5cf), + 2: uint32(0xabc27737), + 3: uint32(0x5ac52d1b), + 4: uint32(0x5cb0679e), + 5: uint32(0x4fa33742), + 6: uint32(0xd3822740), + 7: uint32(0x99bc9bbe), + 8: uint32(0xd5118e9d), + 9: uint32(0xbf0f7315), + 10: uint32(0xd62d1c7e), + 11: uint32(0xc700c47b), + 12: uint32(0xb78c1b6b), + 13: uint32(0x21a19045), + 14: uint32(0xb26eb1be), + 15: uint32(0x6a366eb4), + 16: uint32(0x5748ab2f), + 17: uint32(0xbc946e79), + 18: uint32(0xc6a376d2), + 19: uint32(0x6549c2c8), + 20: uint32(0x530ff8ee), + 21: uint32(0x468dde7d), + 22: uint32(0xd5730a1d), + 23: uint32(0x4cd04dc6), + 24: uint32(0x2939bbdb), + 25: uint32(0xa9ba4650), + 26: uint32(0xac9526e8), + 27: uint32(0xbe5ee304), + 28: uint32(0xa1fad5f0), + 29: uint32(0x6a2d519a), + 30: uint32(0x63ef8ce2), + 31: uint32(0x9a86ee22), + 32: uint32(0xc089c2b8), + 33: uint32(0x43242ef6), + 34: uint32(0xa51e03aa), + 35: uint32(0x9cf2d0a4), + 36: uint32(0x83c061ba), + 37: uint32(0x9be96a4d), + 38: uint32(0x8fe51550), + 39: uint32(0xba645bd6), + 40: uint32(0x2826a2f9), + 41: uint32(0xa73a3ae1), + 42: uint32(0x4ba99586), + 43: uint32(0xef5562e9), + 44: uint32(0xc72fefd3), + 45: uint32(0xf752f7da), + 46: uint32(0x3f046f69), + 47: uint32(0x77fa0a59), + 48: uint32(0x80e4a915), + 49: uint32(0x87b08601), + 50: uint32(0x9b09e6ad), + 51: uint32(0x3b3ee593), + 52: uint32(0xe990fd5a), + 53: uint32(0x9e34d797), + 54: uint32(0x2cf0b7d9), + 55: uint32(0x022b8b51), + 56: uint32(0x96d5ac3a), + 57: uint32(0x017da67d), + 58: uint32(0xd1cf3ed6), + 59: uint32(0x7c7d2d28), + 60: uint32(0x1f9f25cf), + 61: uint32(0xadf2b89b), + 62: uint32(0x5ad6b472), + 63: uint32(0x5a88f54c), + 64: uint32(0xe029ac71), + 65: uint32(0xe019a5e6), + 66: uint32(0x47b0acfd), + 67: uint32(0xed93fa9b), + 68: uint32(0xe8d3c48d), + 69: uint32(0x283b57cc), + 70: uint32(0xf8d56629), + 71: uint32(0x79132e28), + 72: uint32(0x785f0191), + 73: uint32(0xed756055), + 74: uint32(0xf7960e44), + 75: uint32(0xe3d35e8c), + 76: uint32(0x15056dd4), + 77: uint32(0x88f46dba), + 78: uint32(0x03a16125), + 79: uint32(0x0564f0bd), + 80: uint32(0xc3eb9e15), + 81: uint32(0x3c9057a2), + 82: uint32(0x97271aec), + 83: uint32(0xa93a072a), + 84: uint32(0x1b3f6d9b), + 85: uint32(0x1e6321f5), + 86: uint32(0xf59c66fb), + 87: uint32(0x26dcf319), + 88: uint32(0x7533d928), + 89: uint32(0xb155fdf5), + 90: uint32(0x03563482), + 91: uint32(0x8aba3cbb), + 92: uint32(0x28517711), + 93: uint32(0xc20ad9f8), + 94: uint32(0xabcc5167), + 95: uint32(0xccad925f), + 96: uint32(0x4de81751), + 97: uint32(0x3830dc8e), + 98: uint32(0x379d5862), + 99: uint32(0x9320f991), + 100: uint32(0xea7a90c2), + 101: uint32(0xfb3e7bce), + 102: uint32(0x5121ce64), + 103: uint32(0x774fbe32), + 104: uint32(0xa8b6e37e), + 105: uint32(0xc3293d46), + 106: uint32(0x48de5369), + 107: uint32(0x6413e680), + 108: uint32(0xa2ae0810), + 109: uint32(0xdd6db224), + 110: uint32(0x69852dfd), + 111: uint32(0x09072166), + 112: uint32(0xb39a460a), + 113: uint32(0x6445c0dd), + 114: uint32(0x586cdecf), + 115: uint32(0x1c20c8ae), + 116: uint32(0x5bbef7dd), + 117: uint32(0x1b588d40), + 118: uint32(0xccd2017f), + 119: uint32(0x6bb4e3bb), + 120: uint32(0xdda26a7e), + 121: uint32(0x3a59ff45), + 122: uint32(0x3e350a44), + 123: uint32(0xbcb4cdd5), + 124: uint32(0x72eacea8), + 125: uint32(0xfa6484bb), + 126: uint32(0x8d6612ae), + 127: uint32(0xbf3c6f47), + 128: uint32(0xd29be463), + 129: uint32(0x542f5d9e), + 130: uint32(0xaec2771b), + 131: uint32(0xf64e6370), + 132: uint32(0x740e0d8d), + 133: uint32(0xe75b1357), + 134: uint32(0xf8721671), + 135: uint32(0xaf537d5d), + 136: uint32(0x4040cb08), + 137: uint32(0x4eb4e2cc), + 138: uint32(0x34d2466a), + 139: uint32(0x0115af84), + 140: uint32(0xe1b00428), + 141: uint32(0x95983a1d), + 142: uint32(0x06b89fb4), + 143: uint32(0xce6ea048), + 144: uint32(0x6f3f3b82), + 145: uint32(0x3520ab82), + 146: uint32(0x011a1d4b), + 147: uint32(0x277227f8), + 148: uint32(0x611560b1), + 149: uint32(0xe7933fdc), + 150: uint32(0xbb3a792b), + 151: uint32(0x344525bd), + 152: uint32(0xa08839e1), + 153: uint32(0x51ce794b), + 154: uint32(0x2f32c9b7), + 155: uint32(0xa01fbac9), + 156: uint32(0xe01cc87e), + 157: uint32(0xbcc7d1f6), + 158: uint32(0xcf0111c3), + 159: uint32(0xa1e8aac7), + 160: uint32(0x1a908749), + 161: uint32(0xd44fbd9a), + 162: uint32(0xd0dadecb), + 163: uint32(0xd50ada38), + 164: uint32(0x0339c32a), + 165: uint32(0xc6913667), + 166: uint32(0x8df9317c), + 167: uint32(0xe0b12b4f), + 168: uint32(0xf79e59b7), + 169: uint32(0x43f5bb3a), + 170: uint32(0xf2d519ff), + 171: uint32(0x27d9459c), + 172: uint32(0xbf97222c), + 173: uint32(0x15e6fc2a), + 174: uint32(0x0f91fc71), + 175: uint32(0x9b941525), + 176: uint32(0xfae59361), + 177: uint32(0xceb69ceb), + 178: uint32(0xc2a86459), + 179: uint32(0x12baa8d1), + 180: uint32(0xb6c1075e), + 181: uint32(0xe3056a0c), + 182: uint32(0x10d25065), + 183: uint32(0xcb03a442), + 184: uint32(0xe0ec6e0e), + 185: uint32(0x1698db3b), + 186: uint32(0x4c98a0be), + 187: uint32(0x3278e964), + 188: uint32(0x9f1f9532), + 189: uint32(0xe0d392df), + 190: uint32(0xd3a0342b), + 191: uint32(0x8971f21e), + 192: uint32(0x1b0a7441), + 193: uint32(0x4ba3348c), + 194: uint32(0xc5be7120), + 195: uint32(0xc37632d8), + 196: uint32(0xdf359f8d), + 197: uint32(0x9b992f2e), + 198: uint32(0xe60b6f47), + 199: uint32(0x0fe3f11d), + 200: uint32(0xe54cda54), + 201: uint32(0x1edad891), + 202: uint32(0xce6279cf), + 203: uint32(0xcd3e7e6f), + 204: uint32(0x1618b166), + 205: uint32(0xfd2c1d05), + 206: uint32(0x848fd2c5), + 207: uint32(0xf6fb2299), + 208: uint32(0xf523f357), + 209: uint32(0xa6327623), + 210: uint32(0x93a83531), + 211: uint32(0x56cccd02), + 212: uint32(0xacf08162), + 213: uint32(0x5a75ebb5), + 214: uint32(0x6e163697), + 215: uint32(0x88d273cc), + 216: uint32(0xde966292), + 217: uint32(0x81b949d0), + 218: uint32(0x4c50901b), + 219: uint32(0x71c65614), + 220: uint32(0xe6c6c7bd), + 221: uint32(0x327a140a), + 222: uint32(0x45e1d006), + 223: uint32(0xc3f27b9a), + 224: uint32(0xc9aa53fd), + 225: uint32(0x62a80f00), + 226: uint32(0xbb25bfe2), + 227: uint32(0x35bdd2f6), + 228: uint32(0x71126905), + 229: uint32(0xb2040222), + 230: uint32(0xb6cbcf7c), + 231: uint32(0xcd769c2b), + 232: uint32(0x53113ec0), + 233: uint32(0x1640e3d3), + 234: uint32(0x38abbd60), + 235: uint32(0x2547adf0), + 236: uint32(0xba38209c), + 237: uint32(0xf746ce76), + 238: uint32(0x77afa1c5), + 239: uint32(0x20756060), + 240: uint32(0x85cbfe4e), + 241: uint32(0x8ae88dd8), + 242: uint32(0x7aaaf9b0), + 243: uint32(0x4cf9aa7e), + 244: uint32(0x1948c25c), + 245: uint32(0x02fb8a8c), + 246: uint32(0x01c36ae4), + 247: uint32(0xd6ebe1f9), + 248: uint32(0x90d4f869), + 249: uint32(0xa65cdea0), + 250: uint32(0x3f09252d), + 251: uint32(0xc208e69f), + 252: uint32(0xb74e6132), + 253: uint32(0xce77e25b), + 254: uint32(0x578fdfe3), + 255: uint32(0x3ac372e6), + }, + }, +})) + +var _BF_itoa64 = [65]uint8{'.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} + +var _BF_atoi64 = [96]uint8{ + 0: uint8(64), + 1: uint8(64), + 2: uint8(64), + 3: uint8(64), + 4: uint8(64), + 5: uint8(64), + 6: uint8(64), + 7: uint8(64), + 8: uint8(64), + 9: uint8(64), + 10: uint8(64), + 11: uint8(64), + 12: uint8(64), + 13: uint8(64), + 15: uint8(1), + 16: uint8(54), + 17: uint8(55), + 18: uint8(56), + 19: uint8(57), + 20: uint8(58), + 21: uint8(59), + 22: uint8(60), + 23: uint8(61), + 24: uint8(62), + 25: uint8(63), + 26: uint8(64), + 27: uint8(64), + 28: uint8(64), + 29: uint8(64), + 30: uint8(64), + 31: uint8(64), + 32: uint8(64), + 33: uint8(2), + 34: uint8(3), + 35: uint8(4), + 36: uint8(5), + 37: uint8(6), + 38: uint8(7), + 39: uint8(8), + 40: uint8(9), + 41: uint8(10), + 42: uint8(11), + 43: uint8(12), + 44: uint8(13), + 45: uint8(14), + 46: uint8(15), + 47: uint8(16), + 48: uint8(17), + 49: uint8(18), + 50: uint8(19), + 51: uint8(20), + 52: uint8(21), + 53: uint8(22), + 54: uint8(23), + 55: uint8(24), + 56: uint8(25), + 57: uint8(26), + 58: uint8(27), + 59: uint8(64), + 60: uint8(64), + 61: uint8(64), + 62: uint8(64), + 63: uint8(64), + 64: uint8(64), + 65: uint8(28), + 66: uint8(29), + 67: uint8(30), + 68: uint8(31), + 69: uint8(32), + 70: uint8(33), + 71: uint8(34), + 72: uint8(35), + 73: uint8(36), + 74: uint8(37), + 75: uint8(38), + 76: uint8(39), + 77: uint8(40), + 78: uint8(41), + 79: uint8(42), + 80: uint8(43), + 81: uint8(44), + 82: uint8(45), + 83: uint8(46), + 84: uint8(47), + 85: uint8(48), + 86: uint8(49), + 87: uint8(50), + 88: uint8(51), + 89: uint8(52), + 90: uint8(53), + 91: uint8(64), + 92: uint8(64), + 93: uint8(64), + 94: uint8(64), + 95: uint8(64), +} + +func _BF_decode(tls *TLS, dst uintptr, src uintptr, size int32) (r int32) { + var c1, c2, c3, c4, tmp uint32 + var dptr, end, sptr, v1 uintptr + _, _, _, _, _, _, _, _, _ = c1, c2, c3, c4, dptr, end, sptr, tmp, v1 + dptr = dst + end = dptr + uintptr(size) + sptr = src + for cond := true; cond; cond = dptr < end { + v1 = sptr + sptr = sptr + 1 + tmp = uint32(**(**uint8)(__ccgo_up(v1))) + tmp = tmp - uint32(0x20) + if tmp >= uint32(0x60) { + return -int32(1) + } + tmp = uint32(_BF_atoi64[tmp]) + if tmp > uint32(63) { + return -int32(1) + } + c1 = tmp + v1 = sptr + sptr = sptr + 1 + tmp = uint32(**(**uint8)(__ccgo_up(v1))) + tmp = tmp - uint32(0x20) + if tmp >= uint32(0x60) { + return -int32(1) + } + tmp = uint32(_BF_atoi64[tmp]) + if tmp > uint32(63) { + return -int32(1) + } + c2 = tmp + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c1<>int32(4)) + if dptr >= end { + break + } + v1 = sptr + sptr = sptr + 1 + tmp = uint32(**(**uint8)(__ccgo_up(v1))) + tmp = tmp - uint32(0x20) + if tmp >= uint32(0x60) { + return -int32(1) + } + tmp = uint32(_BF_atoi64[tmp]) + if tmp > uint32(63) { + return -int32(1) + } + c3 = tmp + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c2&uint32(0x0F)<>int32(2)) + if dptr >= end { + break + } + v1 = sptr + sptr = sptr + 1 + tmp = uint32(**(**uint8)(__ccgo_up(v1))) + tmp = tmp - uint32(0x20) + if tmp >= uint32(0x60) { + return -int32(1) + } + tmp = uint32(_BF_atoi64[tmp]) + if tmp > uint32(63) { + return -int32(1) + } + c4 = tmp + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c3&uint32(0x03)<>int32(2)] + c1 = c1 & uint32(0x03) << int32(4) + if sptr >= end { + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c1] + break + } + v1 = sptr + sptr = sptr + 1 + c2 = uint32(**(**uint8)(__ccgo_up(v1))) + c1 = c1 | c2>>int32(4) + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c1] + c1 = c2 & uint32(0x0f) << int32(2) + if sptr >= end { + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c1] + break + } + v1 = sptr + sptr = sptr + 1 + c2 = uint32(**(**uint8)(__ccgo_up(v1))) + c1 = c1 | c2>>int32(6) + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c1] + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c2&uint32(0x3f)] + } +} + +func _BF_swap(tls *TLS, x uintptr, count int32) { + var tmp TBF_word + var v1, v2 int32 + var v4 uintptr + _, _, _, _ = tmp, v1, v2, v4 + v1 = int32(1) + if *(*int8)(unsafe.Pointer(&v1)) != 0 { + for { + tmp = **(**TBF_word)(__ccgo_up(x)) + tmp = tmp<>Int32FromInt32(16) + v4 = x + x += 4 + **(**TBF_word)(__ccgo_up(v4)) = tmp&uint32(0x00FF00FF)<>Int32FromInt32(8)&uint32(0x00FF00FF) + goto _3 + _3: + ; + count = count - 1 + v2 = count + if !(v2 != 0) { + break + } + } + } +} + +func _BF_encrypt(tls *TLS, ctx uintptr, L TBF_word, R TBF_word, start uintptr, end uintptr) (r TBF_word) { + var i int32 + var ptr, v2 uintptr + var tmp1, tmp2, tmp3, tmp4 TBF_word + _, _, _, _, _, _, _ = i, ptr, tmp1, tmp2, tmp3, tmp4, v2 + ptr = start + for cond := true; cond; cond = ptr < end { + L = L ^ **(**TBF_word)(__ccgo_up(ctx)) + i = 0 + for { + if !(i < int32(16)) { + break + } + tmp1 = L & uint32(0xFF) + tmp2 = L >> int32(8) + tmp2 = tmp2 & uint32(0xFF) + tmp3 = L >> int32(16) + tmp3 = tmp3 & uint32(0xFF) + tmp4 = L >> int32(24) + tmp1 = **(**TBF_word)(__ccgo_up(ctx + 72 + 3*1024 + uintptr(tmp1)*4)) + tmp2 = **(**TBF_word)(__ccgo_up(ctx + 72 + 2*1024 + uintptr(tmp2)*4)) + tmp3 = **(**TBF_word)(__ccgo_up(ctx + 72 + 1*1024 + uintptr(tmp3)*4)) + tmp3 = tmp3 + **(**TBF_word)(__ccgo_up(ctx + 72 + uintptr(tmp4)*4)) + tmp3 = tmp3 ^ tmp2 + R = R ^ **(**TBF_word)(__ccgo_up(ctx + uintptr(i+int32(1))*4)) + tmp3 = tmp3 + tmp1 + R = R ^ tmp3 + tmp1 = R & uint32(0xFF) + tmp2 = R >> int32(8) + tmp2 = tmp2 & uint32(0xFF) + tmp3 = R >> int32(16) + tmp3 = tmp3 & uint32(0xFF) + tmp4 = R >> int32(24) + tmp1 = **(**TBF_word)(__ccgo_up(ctx + 72 + 3*1024 + uintptr(tmp1)*4)) + tmp2 = **(**TBF_word)(__ccgo_up(ctx + 72 + 2*1024 + uintptr(tmp2)*4)) + tmp3 = **(**TBF_word)(__ccgo_up(ctx + 72 + 1*1024 + uintptr(tmp3)*4)) + tmp3 = tmp3 + **(**TBF_word)(__ccgo_up(ctx + 72 + uintptr(tmp4)*4)) + tmp3 = tmp3 ^ tmp2 + L = L ^ **(**TBF_word)(__ccgo_up(ctx + uintptr(i+int32(1)+int32(1))*4)) + tmp3 = tmp3 + tmp1 + L = L ^ tmp3 + goto _1 + _1: + ; + i = i + int32(2) + } + tmp4 = R + R = L + L = tmp4 ^ **(**TBF_word)(__ccgo_up(ctx + uintptr(Int32FromInt32(BF_N)+Int32FromInt32(1))*4)) + v2 = ptr + ptr += 4 + **(**TBF_word)(__ccgo_up(v2)) = L + v2 = ptr + ptr += 4 + **(**TBF_word)(__ccgo_up(v2)) = R + } + return L +} + +func _BF_set_key(tls *TLS, key uintptr, expanded uintptr, initial uintptr, flags uint8) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bug, i, j uint32 + var diff, safety, sign, v1 TBF_word + var ptr uintptr + var _ /* tmp at bp+0 */ [2]TBF_word + _, _, _, _, _, _, _, _ = bug, diff, i, j, ptr, safety, sign, v1 + ptr = key + /* + * There was a sign extension bug in older revisions of this function. While + * we would have liked to simply fix the bug and move on, we have to provide + * a backwards compatibility feature (essentially the bug) for some systems and + * a safety measure for some others. The latter is needed because for certain + * multiple inputs to the buggy algorithm there exist easily found inputs to + * the correct algorithm that produce the same hash. Thus, we optionally + * deviate from the correct algorithm just enough to avoid such collisions. + * While the bug itself affected the majority of passwords containing + * characters with the 8th bit set (although only a percentage of those in a + * collision-producing way), the anti-collision safety measure affects + * only a subset of passwords containing the '\xff' character (not even all of + * those passwords, just some of them). This character is not found in valid + * UTF-8 sequences and is rarely used in popular 8-bit character encodings. + * Thus, the safety measure is unlikely to cause much annoyance, and is a + * reasonable tradeoff to use when authenticating against existing hashes that + * are not reliably known to have been computed with the correct algorithm. + * + * We use an approach that tries to minimize side-channel leaks of password + * information - that is, we mostly use fixed-cost bitwise operations instead + * of branches or table lookups. (One conditional branch based on password + * length remains. It is not part of the bug aftermath, though, and is + * difficult and possibly unreasonable to avoid given the use of C strings by + * the caller, which results in similar timing leaks anyway.) + * + * For actual implementation, we set an array index in the variable "bug" + * (0 means no bug, 1 means sign extension bug emulation) and a flag in the + * variable "safety" (bit 16 is set when the safety measure is requested). + * Valid combinations of settings are: + * + * Prefix "$2a$": bug = 0, safety = 0x10000 + * Prefix "$2b$": bug = 0, safety = 0 + * Prefix "$2x$": bug = 1, safety = 0 + * Prefix "$2y$": bug = 0, safety = 0 + */ + bug = Uint32FromInt32(Int32FromUint8(flags) & int32(1)) + safety = uint32(flags) & uint32(2) << int32(15) + v1 = Uint32FromInt32(0) + diff = v1 + sign = v1 + i = uint32(0) + for { + if !(i < Uint32FromInt32(Int32FromInt32(BF_N)+Int32FromInt32(2))) { + break + } + v1 = Uint32FromInt32(0) + (**(**[2]TBF_word)(__ccgo_up(bp)))[int32(1)] = v1 + (**(**[2]TBF_word)(__ccgo_up(bp)))[0] = v1 + j = uint32(0) + for { + if !(j < uint32(4)) { + break + } + **(**TBF_word)(__ccgo_up(bp)) <<= uint32(8) + **(**TBF_word)(__ccgo_up(bp)) |= uint32(Uint8FromInt8(**(**int8)(__ccgo_up(ptr)))) /* correct */ + **(**TBF_word)(__ccgo_up(bp + 1*4)) <<= uint32(8) + **(**TBF_word)(__ccgo_up(bp + 1*4)) |= Uint32FromInt8(int8(**(**int8)(__ccgo_up(ptr)))) /* bug */ + /* + * Sign extension in the first char has no effect - nothing to overwrite yet, + * and those extra 24 bits will be fully shifted out of the 32-bit word. For + * chars 2, 3, 4 in each four-char block, we set bit 7 of "sign" if sign + * extension in tmp[1] occurs. Once this flag is set, it remains set. + */ + if j != 0 { + sign = sign | (**(**[2]TBF_word)(__ccgo_up(bp)))[int32(1)]&uint32(0x80) + } + if !(**(**int8)(__ccgo_up(ptr)) != 0) { + ptr = key + } else { + ptr = ptr + 1 + } + goto _4 + _4: + ; + j = j + 1 + } + diff = diff | ((**(**[2]TBF_word)(__ccgo_up(bp)))[0] ^ (**(**[2]TBF_word)(__ccgo_up(bp)))[int32(1)]) /* Non-zero on any differences */ + **(**TBF_word)(__ccgo_up(expanded + uintptr(i)*4)) = (**(**[2]TBF_word)(__ccgo_up(bp)))[bug] + **(**TBF_word)(__ccgo_up(initial + uintptr(i)*4)) = **(**TBF_word)(__ccgo_up(uintptr(unsafe.Pointer(&_BF_init_state)) + uintptr(i)*4)) ^ (**(**[2]TBF_word)(__ccgo_up(bp)))[bug] + goto _2 + _2: + ; + i = i + 1 + } + /* + * At this point, "diff" is zero iff the correct and buggy algorithms produced + * exactly the same result. If so and if "sign" is non-zero, which indicates + * that there was a non-benign sign extension, this means that we have a + * collision between the correctly computed hash for this password and a set of + * passwords that could be supplied to the buggy algorithm. Our safety measure + * is meant to protect from such many-buggy to one-correct collisions, by + * deviating from the correct algorithm in such cases. Let's check for this. + */ + diff = diff | diff>>int32(16) /* still zero iff exact match */ + diff = diff & uint32(0xffff) /* ditto */ + diff = diff + uint32(0xffff) /* bit 16 set iff "diff" was non-zero (on non-match) */ + sign = sign << uint32(9) /* move the non-benign sign extension flag to bit 16 */ + sign = sign & (^diff & safety) /* action needed? */ + /* + * If we have determined that we need to deviate from the correct algorithm, + * flip bit 16 in initial expanded key. (The choice of 16 is arbitrary, but + * let's stick to it now. It came out of the approach we used above, and it's + * not any worse than any other choice we could make.) + * + * It is crucial that we don't do the same to the expanded key used in the main + * Eksblowfish loop. By doing it to only one of these two, we deviate from a + * state that could be directly specified by a password to the buggy algorithm + * (and to the fully correct one as well, but that's a side-effect). + */ + **(**TBF_word)(__ccgo_up(initial)) ^= sign +} + +var _flags_by_subtype = [26]uint8{ + 0: uint8(2), + 1: uint8(4), + 23: uint8(1), + 24: uint8(4), +} + +func _BF_crypt(tls *TLS, key uintptr, setting uintptr, output uintptr, min TBF_word) (r uintptr) { + bp := tls.Alloc(4272) + defer tls.Free(4272) + var L, L1, R, count, tmp1, tmp2, tmp3, tmp4, v1 TBF_word + var done, i int32 + var ptr uintptr + var _ /* LR at bp+4264 */ [2]TBF_word + var _ /* data at bp+0 */ struct { + Fctx TBF_ctx + Fexpanded_key TBF_key + Fbinary struct { + Foutput [0][6]TBF_word + Fsalt [4]TBF_word + F__ccgo_pad2 [8]byte + } + } + _, _, _, _, _, _, _, _, _, _, _, _ = L, L1, R, count, done, i, ptr, tmp1, tmp2, tmp3, tmp4, v1 + if int32(**(**int8)(__ccgo_up(setting))) != int32('$') || int32(**(**int8)(__ccgo_up(setting + 1))) != int32('2') || Uint32FromInt32(int32(**(**int8)(__ccgo_up(setting + 2)))-int32('a')) > uint32(25) || !(_flags_by_subtype[int32(**(**int8)(__ccgo_up(setting + 2)))-int32('a')] != 0) || int32(**(**int8)(__ccgo_up(setting + 3))) != int32('$') || Uint32FromInt32(int32(**(**int8)(__ccgo_up(setting + 4)))-int32('0')) > uint32(1) || Uint32FromInt32(int32(**(**int8)(__ccgo_up(setting + 5)))-int32('0')) > uint32(9) || int32(**(**int8)(__ccgo_up(setting + 6))) != int32('$') { + return UintptrFromInt32(0) + } + count = Uint32FromInt32(1) << ((int32(**(**int8)(__ccgo_up(setting + 4)))-int32('0'))*int32(10) + (int32(**(**int8)(__ccgo_up(setting + 5))) - int32('0'))) + if count < min || _BF_decode(tls, bp+4240, setting+7, int32(16)) != 0 { + return UintptrFromInt32(0) + } + _BF_swap(tls, bp+4240, int32(4)) + _BF_set_key(tls, key, bp+4168, bp, _flags_by_subtype[int32(**(**int8)(__ccgo_up(setting + 2)))-int32('a')]) + Xmemcpy(tls, bp+72, uintptr(unsafe.Pointer(&_BF_init_state))+72, uint64(4096)) + L = uint32(0) + R = uint32(0) + ptr = bp + for cond := true; cond; cond = int32(1) != 0 { + L = _BF_encrypt(tls, bp, L^**(**TBF_word)(__ccgo_up(bp + 4240)), R^**(**TBF_word)(__ccgo_up(bp + 4240 + 1*4)), ptr, ptr) + R = **(**TBF_word)(__ccgo_up(ptr + UintptrFromInt32(1)*4)) + ptr = ptr + uintptr(2)*4 + if ptr >= bp+uintptr(Int32FromInt32(BF_N)+Int32FromInt32(2)+Int32FromInt32(4)*Int32FromInt32(0x100))*4 { + break + } + L = _BF_encrypt(tls, bp, L^**(**TBF_word)(__ccgo_up(bp + 4240 + 2*4)), R^**(**TBF_word)(__ccgo_up(bp + 4240 + 3*4)), ptr, ptr) + R = **(**TBF_word)(__ccgo_up(ptr + UintptrFromInt32(1)*4)) + ptr = ptr + uintptr(2)*4 + } + for { + i = 0 + for { + if !(i < Int32FromInt32(BF_N)+Int32FromInt32(2)) { + break + } + **(**TBF_word)(__ccgo_up(bp + uintptr(i)*4)) ^= **(**TBF_word)(__ccgo_up(bp + 4168 + uintptr(i)*4)) + **(**TBF_word)(__ccgo_up(bp + uintptr(i+int32(1))*4)) ^= **(**TBF_word)(__ccgo_up(bp + 4168 + uintptr(i+int32(1))*4)) + goto _3 + _3: + ; + i = i + int32(2) + } + done = 0 + for cond := true; cond; cond = int32(1) != 0 { + _BF_encrypt(tls, bp, uint32(0), uint32(0), bp, bp+uintptr(Int32FromInt32(BF_N)+Int32FromInt32(2)+Int32FromInt32(4)*Int32FromInt32(0x100))*4) + if done != 0 { + break + } + done = int32(1) + tmp1 = **(**TBF_word)(__ccgo_up(bp + 4240)) + tmp2 = **(**TBF_word)(__ccgo_up(bp + 4240 + 1*4)) + tmp3 = **(**TBF_word)(__ccgo_up(bp + 4240 + 2*4)) + tmp4 = **(**TBF_word)(__ccgo_up(bp + 4240 + 3*4)) + i = 0 + for { + if !(i < int32(BF_N)) { + break + } + **(**TBF_word)(__ccgo_up(bp + uintptr(i)*4)) ^= tmp1 + **(**TBF_word)(__ccgo_up(bp + uintptr(i+int32(1))*4)) ^= tmp2 + **(**TBF_word)(__ccgo_up(bp + uintptr(i+int32(2))*4)) ^= tmp3 + **(**TBF_word)(__ccgo_up(bp + uintptr(i+int32(3))*4)) ^= tmp4 + goto _4 + _4: + ; + i = i + int32(4) + } + **(**TBF_word)(__ccgo_up(bp + 16*4)) ^= tmp1 + **(**TBF_word)(__ccgo_up(bp + 17*4)) ^= tmp2 + } + goto _2 + _2: + ; + count = count - 1 + v1 = count + if !(v1 != 0) { + break + } + } + i = 0 + for { + if !(i < int32(6)) { + break + } + L1 = _BF_magic_w[i] + (**(**[2]TBF_word)(__ccgo_up(bp + 4264)))[int32(1)] = _BF_magic_w[i+int32(1)] + count = uint32(64) + for { + L1 = _BF_encrypt(tls, bp, L1, (**(**[2]TBF_word)(__ccgo_up(bp + 4264)))[int32(1)], bp+4264, bp+4264) + goto _7 + _7: + ; + count = count - 1 + v1 = count + if !(v1 != 0) { + break + } + } + **(**TBF_word)(__ccgo_up(bp + 4240 + uintptr(i)*4)) = L1 + **(**TBF_word)(__ccgo_up(bp + 4240 + uintptr(i+int32(1))*4)) = (**(**[2]TBF_word)(__ccgo_up(bp + 4264)))[int32(1)] + goto _5 + _5: + ; + i = i + int32(2) + } + Xmemcpy(tls, output, setting, Uint64FromInt32(Int32FromInt32(7)+Int32FromInt32(22)-Int32FromInt32(1))) + **(**int8)(__ccgo_up(output + uintptr(Int32FromInt32(7)+Int32FromInt32(22)-Int32FromInt32(1)))) = Int8FromUint8(_BF_itoa64[Int32FromUint8(_BF_atoi64[int32(**(**int8)(__ccgo_up(setting + uintptr(Int32FromInt32(7)+Int32FromInt32(22)-Int32FromInt32(1)))))-int32(0x20)])&int32(0x30)]) + /* This has to be bug-compatible with the original implementation, so + * only encode 23 of the 24 bytes. :-) */ + _BF_swap(tls, bp+4240, int32(6)) + _BF_encode(tls, output+uintptr(Int32FromInt32(7)+Int32FromInt32(22)), bp+4240, int32(23)) + **(**int8)(__ccgo_up(output + uintptr(Int32FromInt32(7)+Int32FromInt32(22)+Int32FromInt32(31)))) = int8('\000') + return output +} + +// C documentation +// +// /* +// * Please preserve the runtime self-test. It serves two purposes at once: +// * +// * 1. We really can't afford the risk of producing incompatible hashes e.g. +// * when there's something like gcc bug 26587 again, whereas an application or +// * library integrating this code might not also integrate our external tests or +// * it might not run them after every build. Even if it does, the miscompile +// * might only occur on the production build, but not on a testing build (such +// * as because of different optimization settings). It is painful to recover +// * from incorrectly-computed hashes - merely fixing whatever broke is not +// * enough. Thus, a proactive measure like this self-test is needed. +// * +// * 2. We don't want to leave sensitive data from our actual password hash +// * computation on the stack or in registers. Previous revisions of the code +// * would do explicit cleanups, but simply running the self-test after hash +// * computation is more reliable. +// * +// * The performance cost of this quick self-test is around 0.6% at the "$2a$08" +// * setting. +// */ +func X__crypt_blowfish(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v setting=%v output=%v, (%v:)", tls, key, setting, output, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(384) + defer tls.Free(384) + var flags uint32 + var k, p, retval, test_hash, test_key, test_setting uintptr + var ok int32 + var _ /* ae at bp+96 */ TBF_key + var _ /* ai at bp+168 */ TBF_key + var _ /* buf at bp+0 */ struct { + Fs [30]int8 + Fo [63]int8 + } + var _ /* ye at bp+240 */ TBF_key + var _ /* yi at bp+312 */ TBF_key + _, _, _, _, _, _, _, _ = flags, k, ok, p, retval, test_hash, test_key, test_setting + test_key = __ccgo_ts + 18 + test_setting = __ccgo_ts + 28 + test_hash = uintptr(unsafe.Pointer(&_test_hashes)) + /* Hash the supplied password */ + retval = _BF_crypt(tls, key, setting, output, uint32(16)) + /* + * Do a quick self-test. It is important that we make both calls to BF_crypt() + * from the same scope such that they likely use the same stack locations, + * which makes the second call overwrite the first call's sensitive data on the + * stack and makes it more likely that any alignment related issues would be + * detected by the self-test. + */ + Xmemcpy(tls, bp, test_setting, uint64(30)) + if retval != 0 { + flags = uint32(_flags_by_subtype[int32(**(**int8)(__ccgo_up(setting + 2)))-int32('a')]) + test_hash = uintptr(unsafe.Pointer(&_test_hashes)) + uintptr(flags&uint32(1))*34 + **(**int8)(__ccgo_up(bp + 2)) = **(**int8)(__ccgo_up(setting + 2)) + } + Xmemset(tls, bp+30, int32(0x55), uint64(63)) + **(**int8)(__ccgo_up(bp + 30 + uintptr(Uint64FromInt64(63)-Uint64FromInt32(1)))) = 0 + p = _BF_crypt(tls, test_key, bp, bp+30, uint32(1)) + ok = BoolInt32(p == bp+30 && !(Xmemcmp(tls, p, bp, Uint64FromInt32(Int32FromInt32(7)+Int32FromInt32(22))) != 0) && !(Xmemcmp(tls, p+uintptr(Int32FromInt32(7)+Int32FromInt32(22)), test_hash, Uint64FromInt32(Int32FromInt32(31)+Int32FromInt32(1)+Int32FromInt32(1)+Int32FromInt32(1))) != 0)) + k = __ccgo_ts + 58 + _BF_set_key(tls, k, bp+96, bp+168, uint8(2)) /* $2a$ */ + _BF_set_key(tls, k, bp+240, bp+312, uint8(4)) /* $2y$ */ + **(**TBF_word)(__ccgo_up(bp + 168)) ^= uint32(0x10000) /* undo the safety (for comparison) */ + ok = BoolInt32(ok != 0 && (**(**TBF_key)(__ccgo_up(bp + 168)))[0] == uint32(0xdb9c59bc) && (**(**TBF_key)(__ccgo_up(bp + 240)))[int32(17)] == uint32(0x33343500) && !(Xmemcmp(tls, bp+96, bp+240, uint64(72)) != 0) && !(Xmemcmp(tls, bp+168, bp+312, uint64(72)) != 0)) + if ok != 0 && retval != 0 { + return retval + } + return __ccgo_ts + 70 +} + +var _test_hashes = [2][34]int8{ + 0: {'i', '1', 'D', '7', '0', '9', 'v', 'f', 'a', 'm', 'u', 'l', 'i', 'm', 'l', 'G', 'c', 'q', '0', 'q', 'q', '3', 'U', 'v', 'u', 'U', 'a', 's', 'v', 'E', 'a', 0, 'U'}, + 1: {'V', 'U', 'r', 'P', 'm', 'X', 'D', '6', 'q', '/', 'n', 'V', 'S', 'S', 'p', '7', 'p', 'N', 'D', 'h', 'C', 'R', '9', '0', '7', '1', 'I', 'f', 'I', 'R', 'e', 0, 'U'}, +} + +const _PASSWORD_EFMT1 = 95 + +type Texpanded_key = struct { + Fl [16]Tuint32_t + Fr [16]Tuint32_t +} + +var _key_shifts = [16]uint8{ + 0: uint8(1), + 1: uint8(1), + 2: uint8(2), + 3: uint8(2), + 4: uint8(2), + 5: uint8(2), + 6: uint8(2), + 7: uint8(2), + 8: uint8(1), + 9: uint8(2), + 10: uint8(2), + 11: uint8(2), + 12: uint8(2), + 13: uint8(2), + 14: uint8(2), + 15: uint8(1), +} + +var _psbox = [8][64]Tuint32_t{ + 0: { + 0: uint32(0x00808200), + 2: uint32(0x00008000), + 3: uint32(0x00808202), + 4: uint32(0x00808002), + 5: uint32(0x00008202), + 6: uint32(0x00000002), + 7: uint32(0x00008000), + 8: uint32(0x00000200), + 9: uint32(0x00808200), + 10: uint32(0x00808202), + 11: uint32(0x00000200), + 12: uint32(0x00800202), + 13: uint32(0x00808002), + 14: uint32(0x00800000), + 15: uint32(0x00000002), + 16: uint32(0x00000202), + 17: uint32(0x00800200), + 18: uint32(0x00800200), + 19: uint32(0x00008200), + 20: uint32(0x00008200), + 21: uint32(0x00808000), + 22: uint32(0x00808000), + 23: uint32(0x00800202), + 24: uint32(0x00008002), + 25: uint32(0x00800002), + 26: uint32(0x00800002), + 27: uint32(0x00008002), + 29: uint32(0x00000202), + 30: uint32(0x00008202), + 31: uint32(0x00800000), + 32: uint32(0x00008000), + 33: uint32(0x00808202), + 34: uint32(0x00000002), + 35: uint32(0x00808000), + 36: uint32(0x00808200), + 37: uint32(0x00800000), + 38: uint32(0x00800000), + 39: uint32(0x00000200), + 40: uint32(0x00808002), + 41: uint32(0x00008000), + 42: uint32(0x00008200), + 43: uint32(0x00800002), + 44: uint32(0x00000200), + 45: uint32(0x00000002), + 46: uint32(0x00800202), + 47: uint32(0x00008202), + 48: uint32(0x00808202), + 49: uint32(0x00008002), + 50: uint32(0x00808000), + 51: uint32(0x00800202), + 52: uint32(0x00800002), + 53: uint32(0x00000202), + 54: uint32(0x00008202), + 55: uint32(0x00808200), + 56: uint32(0x00000202), + 57: uint32(0x00800200), + 58: uint32(0x00800200), + 60: uint32(0x00008002), + 61: uint32(0x00008200), + 63: uint32(0x00808002), + }, + 1: { + 0: uint32(0x40084010), + 1: uint32(0x40004000), + 2: uint32(0x00004000), + 3: uint32(0x00084010), + 4: uint32(0x00080000), + 5: uint32(0x00000010), + 6: uint32(0x40080010), + 7: uint32(0x40004010), + 8: uint32(0x40000010), + 9: uint32(0x40084010), + 10: uint32(0x40084000), + 11: uint32(0x40000000), + 12: uint32(0x40004000), + 13: uint32(0x00080000), + 14: uint32(0x00000010), + 15: uint32(0x40080010), + 16: uint32(0x00084000), + 17: uint32(0x00080010), + 18: uint32(0x40004010), + 20: uint32(0x40000000), + 21: uint32(0x00004000), + 22: uint32(0x00084010), + 23: uint32(0x40080000), + 24: uint32(0x00080010), + 25: uint32(0x40000010), + 27: uint32(0x00084000), + 28: uint32(0x00004010), + 29: uint32(0x40084000), + 30: uint32(0x40080000), + 31: uint32(0x00004010), + 33: uint32(0x00084010), + 34: uint32(0x40080010), + 35: uint32(0x00080000), + 36: uint32(0x40004010), + 37: uint32(0x40080000), + 38: uint32(0x40084000), + 39: uint32(0x00004000), + 40: uint32(0x40080000), + 41: uint32(0x40004000), + 42: uint32(0x00000010), + 43: uint32(0x40084010), + 44: uint32(0x00084010), + 45: uint32(0x00000010), + 46: uint32(0x00004000), + 47: uint32(0x40000000), + 48: uint32(0x00004010), + 49: uint32(0x40084000), + 50: uint32(0x00080000), + 51: uint32(0x40000010), + 52: uint32(0x00080010), + 53: uint32(0x40004010), + 54: uint32(0x40000010), + 55: uint32(0x00080010), + 56: uint32(0x00084000), + 58: uint32(0x40004000), + 59: uint32(0x00004010), + 60: uint32(0x40000000), + 61: uint32(0x40080010), + 62: uint32(0x40084010), + 63: uint32(0x00084000), + }, + 2: { + 0: uint32(0x00000104), + 1: uint32(0x04010100), + 3: uint32(0x04010004), + 4: uint32(0x04000100), + 6: uint32(0x00010104), + 7: uint32(0x04000100), + 8: uint32(0x00010004), + 9: uint32(0x04000004), + 10: uint32(0x04000004), + 11: uint32(0x00010000), + 12: uint32(0x04010104), + 13: uint32(0x00010004), + 14: uint32(0x04010000), + 15: uint32(0x00000104), + 16: uint32(0x04000000), + 17: uint32(0x00000004), + 18: uint32(0x04010100), + 19: uint32(0x00000100), + 20: uint32(0x00010100), + 21: uint32(0x04010000), + 22: uint32(0x04010004), + 23: uint32(0x00010104), + 24: uint32(0x04000104), + 25: uint32(0x00010100), + 26: uint32(0x00010000), + 27: uint32(0x04000104), + 28: uint32(0x00000004), + 29: uint32(0x04010104), + 30: uint32(0x00000100), + 31: uint32(0x04000000), + 32: uint32(0x04010100), + 33: uint32(0x04000000), + 34: uint32(0x00010004), + 35: uint32(0x00000104), + 36: uint32(0x00010000), + 37: uint32(0x04010100), + 38: uint32(0x04000100), + 40: uint32(0x00000100), + 41: uint32(0x00010004), + 42: uint32(0x04010104), + 43: uint32(0x04000100), + 44: uint32(0x04000004), + 45: uint32(0x00000100), + 47: uint32(0x04010004), + 48: uint32(0x04000104), + 49: uint32(0x00010000), + 50: uint32(0x04000000), + 51: uint32(0x04010104), + 52: uint32(0x00000004), + 53: uint32(0x00010104), + 54: uint32(0x00010100), + 55: uint32(0x04000004), + 56: uint32(0x04010000), + 57: uint32(0x04000104), + 58: uint32(0x00000104), + 59: uint32(0x04010000), + 60: uint32(0x00010104), + 61: uint32(0x00000004), + 62: uint32(0x04010004), + 63: uint32(0x00010100), + }, + 3: { + 0: uint32(0x80401000), + 1: uint32(0x80001040), + 2: uint32(0x80001040), + 3: uint32(0x00000040), + 4: uint32(0x00401040), + 5: uint32(0x80400040), + 6: uint32(0x80400000), + 7: uint32(0x80001000), + 9: uint32(0x00401000), + 10: uint32(0x00401000), + 11: uint32(0x80401040), + 12: uint32(0x80000040), + 14: uint32(0x00400040), + 15: uint32(0x80400000), + 16: uint32(0x80000000), + 17: uint32(0x00001000), + 18: uint32(0x00400000), + 19: uint32(0x80401000), + 20: uint32(0x00000040), + 21: uint32(0x00400000), + 22: uint32(0x80001000), + 23: uint32(0x00001040), + 24: uint32(0x80400040), + 25: uint32(0x80000000), + 26: uint32(0x00001040), + 27: uint32(0x00400040), + 28: uint32(0x00001000), + 29: uint32(0x00401040), + 30: uint32(0x80401040), + 31: uint32(0x80000040), + 32: uint32(0x00400040), + 33: uint32(0x80400000), + 34: uint32(0x00401000), + 35: uint32(0x80401040), + 36: uint32(0x80000040), + 39: uint32(0x00401000), + 40: uint32(0x00001040), + 41: uint32(0x00400040), + 42: uint32(0x80400040), + 43: uint32(0x80000000), + 44: uint32(0x80401000), + 45: uint32(0x80001040), + 46: uint32(0x80001040), + 47: uint32(0x00000040), + 48: uint32(0x80401040), + 49: uint32(0x80000040), + 50: uint32(0x80000000), + 51: uint32(0x00001000), + 52: uint32(0x80400000), + 53: uint32(0x80001000), + 54: uint32(0x00401040), + 55: uint32(0x80400040), + 56: uint32(0x80001000), + 57: uint32(0x00001040), + 58: uint32(0x00400000), + 59: uint32(0x80401000), + 60: uint32(0x00000040), + 61: uint32(0x00400000), + 62: uint32(0x00001000), + 63: uint32(0x00401040), + }, + 4: { + 0: uint32(0x00000080), + 1: uint32(0x01040080), + 2: uint32(0x01040000), + 3: uint32(0x21000080), + 4: uint32(0x00040000), + 5: uint32(0x00000080), + 6: uint32(0x20000000), + 7: uint32(0x01040000), + 8: uint32(0x20040080), + 9: uint32(0x00040000), + 10: uint32(0x01000080), + 11: uint32(0x20040080), + 12: uint32(0x21000080), + 13: uint32(0x21040000), + 14: uint32(0x00040080), + 15: uint32(0x20000000), + 16: uint32(0x01000000), + 17: uint32(0x20040000), + 18: uint32(0x20040000), + 20: uint32(0x20000080), + 21: uint32(0x21040080), + 22: uint32(0x21040080), + 23: uint32(0x01000080), + 24: uint32(0x21040000), + 25: uint32(0x20000080), + 27: uint32(0x21000000), + 28: uint32(0x01040080), + 29: uint32(0x01000000), + 30: uint32(0x21000000), + 31: uint32(0x00040080), + 32: uint32(0x00040000), + 33: uint32(0x21000080), + 34: uint32(0x00000080), + 35: uint32(0x01000000), + 36: uint32(0x20000000), + 37: uint32(0x01040000), + 38: uint32(0x21000080), + 39: uint32(0x20040080), + 40: uint32(0x01000080), + 41: uint32(0x20000000), + 42: uint32(0x21040000), + 43: uint32(0x01040080), + 44: uint32(0x20040080), + 45: uint32(0x00000080), + 46: uint32(0x01000000), + 47: uint32(0x21040000), + 48: uint32(0x21040080), + 49: uint32(0x00040080), + 50: uint32(0x21000000), + 51: uint32(0x21040080), + 52: uint32(0x01040000), + 54: uint32(0x20040000), + 55: uint32(0x21000000), + 56: uint32(0x00040080), + 57: uint32(0x01000080), + 58: uint32(0x20000080), + 59: uint32(0x00040000), + 61: uint32(0x20040000), + 62: uint32(0x01040080), + 63: uint32(0x20000080), + }, + 5: { + 0: uint32(0x10000008), + 1: uint32(0x10200000), + 2: uint32(0x00002000), + 3: uint32(0x10202008), + 4: uint32(0x10200000), + 5: uint32(0x00000008), + 6: uint32(0x10202008), + 7: uint32(0x00200000), + 8: uint32(0x10002000), + 9: uint32(0x00202008), + 10: uint32(0x00200000), + 11: uint32(0x10000008), + 12: uint32(0x00200008), + 13: uint32(0x10002000), + 14: uint32(0x10000000), + 15: uint32(0x00002008), + 17: uint32(0x00200008), + 18: uint32(0x10002008), + 19: uint32(0x00002000), + 20: uint32(0x00202000), + 21: uint32(0x10002008), + 22: uint32(0x00000008), + 23: uint32(0x10200008), + 24: uint32(0x10200008), + 26: uint32(0x00202008), + 27: uint32(0x10202000), + 28: uint32(0x00002008), + 29: uint32(0x00202000), + 30: uint32(0x10202000), + 31: uint32(0x10000000), + 32: uint32(0x10002000), + 33: uint32(0x00000008), + 34: uint32(0x10200008), + 35: uint32(0x00202000), + 36: uint32(0x10202008), + 37: uint32(0x00200000), + 38: uint32(0x00002008), + 39: uint32(0x10000008), + 40: uint32(0x00200000), + 41: uint32(0x10002000), + 42: uint32(0x10000000), + 43: uint32(0x00002008), + 44: uint32(0x10000008), + 45: uint32(0x10202008), + 46: uint32(0x00202000), + 47: uint32(0x10200000), + 48: uint32(0x00202008), + 49: uint32(0x10202000), + 51: uint32(0x10200008), + 52: uint32(0x00000008), + 53: uint32(0x00002000), + 54: uint32(0x10200000), + 55: uint32(0x00202008), + 56: uint32(0x00002000), + 57: uint32(0x00200008), + 58: uint32(0x10002008), + 60: uint32(0x10202000), + 61: uint32(0x10000000), + 62: uint32(0x00200008), + 63: uint32(0x10002008), + }, + 6: { + 0: uint32(0x00100000), + 1: uint32(0x02100001), + 2: uint32(0x02000401), + 4: uint32(0x00000400), + 5: uint32(0x02000401), + 6: uint32(0x00100401), + 7: uint32(0x02100400), + 8: uint32(0x02100401), + 9: uint32(0x00100000), + 11: uint32(0x02000001), + 12: uint32(0x00000001), + 13: uint32(0x02000000), + 14: uint32(0x02100001), + 15: uint32(0x00000401), + 16: uint32(0x02000400), + 17: uint32(0x00100401), + 18: uint32(0x00100001), + 19: uint32(0x02000400), + 20: uint32(0x02000001), + 21: uint32(0x02100000), + 22: uint32(0x02100400), + 23: uint32(0x00100001), + 24: uint32(0x02100000), + 25: uint32(0x00000400), + 26: uint32(0x00000401), + 27: uint32(0x02100401), + 28: uint32(0x00100400), + 29: uint32(0x00000001), + 30: uint32(0x02000000), + 31: uint32(0x00100400), + 32: uint32(0x02000000), + 33: uint32(0x00100400), + 34: uint32(0x00100000), + 35: uint32(0x02000401), + 36: uint32(0x02000401), + 37: uint32(0x02100001), + 38: uint32(0x02100001), + 39: uint32(0x00000001), + 40: uint32(0x00100001), + 41: uint32(0x02000000), + 42: uint32(0x02000400), + 43: uint32(0x00100000), + 44: uint32(0x02100400), + 45: uint32(0x00000401), + 46: uint32(0x00100401), + 47: uint32(0x02100400), + 48: uint32(0x00000401), + 49: uint32(0x02000001), + 50: uint32(0x02100401), + 51: uint32(0x02100000), + 52: uint32(0x00100400), + 54: uint32(0x00000001), + 55: uint32(0x02100401), + 57: uint32(0x00100401), + 58: uint32(0x02100000), + 59: uint32(0x00000400), + 60: uint32(0x02000001), + 61: uint32(0x02000400), + 62: uint32(0x00000400), + 63: uint32(0x00100001), + }, + 7: { + 0: uint32(0x08000820), + 1: uint32(0x00000800), + 2: uint32(0x00020000), + 3: uint32(0x08020820), + 4: uint32(0x08000000), + 5: uint32(0x08000820), + 6: uint32(0x00000020), + 7: uint32(0x08000000), + 8: uint32(0x00020020), + 9: uint32(0x08020000), + 10: uint32(0x08020820), + 11: uint32(0x00020800), + 12: uint32(0x08020800), + 13: uint32(0x00020820), + 14: uint32(0x00000800), + 15: uint32(0x00000020), + 16: uint32(0x08020000), + 17: uint32(0x08000020), + 18: uint32(0x08000800), + 19: uint32(0x00000820), + 20: uint32(0x00020800), + 21: uint32(0x00020020), + 22: uint32(0x08020020), + 23: uint32(0x08020800), + 24: uint32(0x00000820), + 27: uint32(0x08020020), + 28: uint32(0x08000020), + 29: uint32(0x08000800), + 30: uint32(0x00020820), + 31: uint32(0x00020000), + 32: uint32(0x00020820), + 33: uint32(0x00020000), + 34: uint32(0x08020800), + 35: uint32(0x00000800), + 36: uint32(0x00000020), + 37: uint32(0x08020020), + 38: uint32(0x00000800), + 39: uint32(0x00020820), + 40: uint32(0x08000800), + 41: uint32(0x00000020), + 42: uint32(0x08000020), + 43: uint32(0x08020000), + 44: uint32(0x08020020), + 45: uint32(0x08000000), + 46: uint32(0x00020000), + 47: uint32(0x08000820), + 49: uint32(0x08020820), + 50: uint32(0x00020020), + 51: uint32(0x08000020), + 52: uint32(0x08020000), + 53: uint32(0x08000800), + 54: uint32(0x08000820), + 56: uint32(0x08020820), + 57: uint32(0x00020800), + 58: uint32(0x00020800), + 59: uint32(0x00000820), + 60: uint32(0x00000820), + 61: uint32(0x00020020), + 62: uint32(0x08000000), + 63: uint32(0x08020800), + }, +} +var _ip_maskl = [16][16]Tuint32_t{ + 0: { + 1: uint32(0x00010000), + 3: uint32(0x00010000), + 4: uint32(0x01000000), + 5: uint32(0x01010000), + 6: uint32(0x01000000), + 7: uint32(0x01010000), + 9: uint32(0x00010000), + 11: uint32(0x00010000), + 12: uint32(0x01000000), + 13: uint32(0x01010000), + 14: uint32(0x01000000), + 15: uint32(0x01010000), + }, + 1: { + 1: uint32(0x00000001), + 3: uint32(0x00000001), + 4: uint32(0x00000100), + 5: uint32(0x00000101), + 6: uint32(0x00000100), + 7: uint32(0x00000101), + 9: uint32(0x00000001), + 11: uint32(0x00000001), + 12: uint32(0x00000100), + 13: uint32(0x00000101), + 14: uint32(0x00000100), + 15: uint32(0x00000101), + }, + 2: { + 1: uint32(0x00020000), + 3: uint32(0x00020000), + 4: uint32(0x02000000), + 5: uint32(0x02020000), + 6: uint32(0x02000000), + 7: uint32(0x02020000), + 9: uint32(0x00020000), + 11: uint32(0x00020000), + 12: uint32(0x02000000), + 13: uint32(0x02020000), + 14: uint32(0x02000000), + 15: uint32(0x02020000), + }, + 3: { + 1: uint32(0x00000002), + 3: uint32(0x00000002), + 4: uint32(0x00000200), + 5: uint32(0x00000202), + 6: uint32(0x00000200), + 7: uint32(0x00000202), + 9: uint32(0x00000002), + 11: uint32(0x00000002), + 12: uint32(0x00000200), + 13: uint32(0x00000202), + 14: uint32(0x00000200), + 15: uint32(0x00000202), + }, + 4: { + 1: uint32(0x00040000), + 3: uint32(0x00040000), + 4: uint32(0x04000000), + 5: uint32(0x04040000), + 6: uint32(0x04000000), + 7: uint32(0x04040000), + 9: uint32(0x00040000), + 11: uint32(0x00040000), + 12: uint32(0x04000000), + 13: uint32(0x04040000), + 14: uint32(0x04000000), + 15: uint32(0x04040000), + }, + 5: { + 1: uint32(0x00000004), + 3: uint32(0x00000004), + 4: uint32(0x00000400), + 5: uint32(0x00000404), + 6: uint32(0x00000400), + 7: uint32(0x00000404), + 9: uint32(0x00000004), + 11: uint32(0x00000004), + 12: uint32(0x00000400), + 13: uint32(0x00000404), + 14: uint32(0x00000400), + 15: uint32(0x00000404), + }, + 6: { + 1: uint32(0x00080000), + 3: uint32(0x00080000), + 4: uint32(0x08000000), + 5: uint32(0x08080000), + 6: uint32(0x08000000), + 7: uint32(0x08080000), + 9: uint32(0x00080000), + 11: uint32(0x00080000), + 12: uint32(0x08000000), + 13: uint32(0x08080000), + 14: uint32(0x08000000), + 15: uint32(0x08080000), + }, + 7: { + 1: uint32(0x00000008), + 3: uint32(0x00000008), + 4: uint32(0x00000800), + 5: uint32(0x00000808), + 6: uint32(0x00000800), + 7: uint32(0x00000808), + 9: uint32(0x00000008), + 11: uint32(0x00000008), + 12: uint32(0x00000800), + 13: uint32(0x00000808), + 14: uint32(0x00000800), + 15: uint32(0x00000808), + }, + 8: { + 1: uint32(0x00100000), + 3: uint32(0x00100000), + 4: uint32(0x10000000), + 5: uint32(0x10100000), + 6: uint32(0x10000000), + 7: uint32(0x10100000), + 9: uint32(0x00100000), + 11: uint32(0x00100000), + 12: uint32(0x10000000), + 13: uint32(0x10100000), + 14: uint32(0x10000000), + 15: uint32(0x10100000), + }, + 9: { + 1: uint32(0x00000010), + 3: uint32(0x00000010), + 4: uint32(0x00001000), + 5: uint32(0x00001010), + 6: uint32(0x00001000), + 7: uint32(0x00001010), + 9: uint32(0x00000010), + 11: uint32(0x00000010), + 12: uint32(0x00001000), + 13: uint32(0x00001010), + 14: uint32(0x00001000), + 15: uint32(0x00001010), + }, + 10: { + 1: uint32(0x00200000), + 3: uint32(0x00200000), + 4: uint32(0x20000000), + 5: uint32(0x20200000), + 6: uint32(0x20000000), + 7: uint32(0x20200000), + 9: uint32(0x00200000), + 11: uint32(0x00200000), + 12: uint32(0x20000000), + 13: uint32(0x20200000), + 14: uint32(0x20000000), + 15: uint32(0x20200000), + }, + 11: { + 1: uint32(0x00000020), + 3: uint32(0x00000020), + 4: uint32(0x00002000), + 5: uint32(0x00002020), + 6: uint32(0x00002000), + 7: uint32(0x00002020), + 9: uint32(0x00000020), + 11: uint32(0x00000020), + 12: uint32(0x00002000), + 13: uint32(0x00002020), + 14: uint32(0x00002000), + 15: uint32(0x00002020), + }, + 12: { + 1: uint32(0x00400000), + 3: uint32(0x00400000), + 4: uint32(0x40000000), + 5: uint32(0x40400000), + 6: uint32(0x40000000), + 7: uint32(0x40400000), + 9: uint32(0x00400000), + 11: uint32(0x00400000), + 12: uint32(0x40000000), + 13: uint32(0x40400000), + 14: uint32(0x40000000), + 15: uint32(0x40400000), + }, + 13: { + 1: uint32(0x00000040), + 3: uint32(0x00000040), + 4: uint32(0x00004000), + 5: uint32(0x00004040), + 6: uint32(0x00004000), + 7: uint32(0x00004040), + 9: uint32(0x00000040), + 11: uint32(0x00000040), + 12: uint32(0x00004000), + 13: uint32(0x00004040), + 14: uint32(0x00004000), + 15: uint32(0x00004040), + }, + 14: { + 1: uint32(0x00800000), + 3: uint32(0x00800000), + 4: uint32(0x80000000), + 5: uint32(0x80800000), + 6: uint32(0x80000000), + 7: uint32(0x80800000), + 9: uint32(0x00800000), + 11: uint32(0x00800000), + 12: uint32(0x80000000), + 13: uint32(0x80800000), + 14: uint32(0x80000000), + 15: uint32(0x80800000), + }, + 15: { + 1: uint32(0x00000080), + 3: uint32(0x00000080), + 4: uint32(0x00008000), + 5: uint32(0x00008080), + 6: uint32(0x00008000), + 7: uint32(0x00008080), + 9: uint32(0x00000080), + 11: uint32(0x00000080), + 12: uint32(0x00008000), + 13: uint32(0x00008080), + 14: uint32(0x00008000), + 15: uint32(0x00008080), + }, +} +var _ip_maskr = [16][16]Tuint32_t{ + 0: { + 2: uint32(0x00010000), + 3: uint32(0x00010000), + 6: uint32(0x00010000), + 7: uint32(0x00010000), + 8: uint32(0x01000000), + 9: uint32(0x01000000), + 10: uint32(0x01010000), + 11: uint32(0x01010000), + 12: uint32(0x01000000), + 13: uint32(0x01000000), + 14: uint32(0x01010000), + 15: uint32(0x01010000), + }, + 1: { + 2: uint32(0x00000001), + 3: uint32(0x00000001), + 6: uint32(0x00000001), + 7: uint32(0x00000001), + 8: uint32(0x00000100), + 9: uint32(0x00000100), + 10: uint32(0x00000101), + 11: uint32(0x00000101), + 12: uint32(0x00000100), + 13: uint32(0x00000100), + 14: uint32(0x00000101), + 15: uint32(0x00000101), + }, + 2: { + 2: uint32(0x00020000), + 3: uint32(0x00020000), + 6: uint32(0x00020000), + 7: uint32(0x00020000), + 8: uint32(0x02000000), + 9: uint32(0x02000000), + 10: uint32(0x02020000), + 11: uint32(0x02020000), + 12: uint32(0x02000000), + 13: uint32(0x02000000), + 14: uint32(0x02020000), + 15: uint32(0x02020000), + }, + 3: { + 2: uint32(0x00000002), + 3: uint32(0x00000002), + 6: uint32(0x00000002), + 7: uint32(0x00000002), + 8: uint32(0x00000200), + 9: uint32(0x00000200), + 10: uint32(0x00000202), + 11: uint32(0x00000202), + 12: uint32(0x00000200), + 13: uint32(0x00000200), + 14: uint32(0x00000202), + 15: uint32(0x00000202), + }, + 4: { + 2: uint32(0x00040000), + 3: uint32(0x00040000), + 6: uint32(0x00040000), + 7: uint32(0x00040000), + 8: uint32(0x04000000), + 9: uint32(0x04000000), + 10: uint32(0x04040000), + 11: uint32(0x04040000), + 12: uint32(0x04000000), + 13: uint32(0x04000000), + 14: uint32(0x04040000), + 15: uint32(0x04040000), + }, + 5: { + 2: uint32(0x00000004), + 3: uint32(0x00000004), + 6: uint32(0x00000004), + 7: uint32(0x00000004), + 8: uint32(0x00000400), + 9: uint32(0x00000400), + 10: uint32(0x00000404), + 11: uint32(0x00000404), + 12: uint32(0x00000400), + 13: uint32(0x00000400), + 14: uint32(0x00000404), + 15: uint32(0x00000404), + }, + 6: { + 2: uint32(0x00080000), + 3: uint32(0x00080000), + 6: uint32(0x00080000), + 7: uint32(0x00080000), + 8: uint32(0x08000000), + 9: uint32(0x08000000), + 10: uint32(0x08080000), + 11: uint32(0x08080000), + 12: uint32(0x08000000), + 13: uint32(0x08000000), + 14: uint32(0x08080000), + 15: uint32(0x08080000), + }, + 7: { + 2: uint32(0x00000008), + 3: uint32(0x00000008), + 6: uint32(0x00000008), + 7: uint32(0x00000008), + 8: uint32(0x00000800), + 9: uint32(0x00000800), + 10: uint32(0x00000808), + 11: uint32(0x00000808), + 12: uint32(0x00000800), + 13: uint32(0x00000800), + 14: uint32(0x00000808), + 15: uint32(0x00000808), + }, + 8: { + 2: uint32(0x00100000), + 3: uint32(0x00100000), + 6: uint32(0x00100000), + 7: uint32(0x00100000), + 8: uint32(0x10000000), + 9: uint32(0x10000000), + 10: uint32(0x10100000), + 11: uint32(0x10100000), + 12: uint32(0x10000000), + 13: uint32(0x10000000), + 14: uint32(0x10100000), + 15: uint32(0x10100000), + }, + 9: { + 2: uint32(0x00000010), + 3: uint32(0x00000010), + 6: uint32(0x00000010), + 7: uint32(0x00000010), + 8: uint32(0x00001000), + 9: uint32(0x00001000), + 10: uint32(0x00001010), + 11: uint32(0x00001010), + 12: uint32(0x00001000), + 13: uint32(0x00001000), + 14: uint32(0x00001010), + 15: uint32(0x00001010), + }, + 10: { + 2: uint32(0x00200000), + 3: uint32(0x00200000), + 6: uint32(0x00200000), + 7: uint32(0x00200000), + 8: uint32(0x20000000), + 9: uint32(0x20000000), + 10: uint32(0x20200000), + 11: uint32(0x20200000), + 12: uint32(0x20000000), + 13: uint32(0x20000000), + 14: uint32(0x20200000), + 15: uint32(0x20200000), + }, + 11: { + 2: uint32(0x00000020), + 3: uint32(0x00000020), + 6: uint32(0x00000020), + 7: uint32(0x00000020), + 8: uint32(0x00002000), + 9: uint32(0x00002000), + 10: uint32(0x00002020), + 11: uint32(0x00002020), + 12: uint32(0x00002000), + 13: uint32(0x00002000), + 14: uint32(0x00002020), + 15: uint32(0x00002020), + }, + 12: { + 2: uint32(0x00400000), + 3: uint32(0x00400000), + 6: uint32(0x00400000), + 7: uint32(0x00400000), + 8: uint32(0x40000000), + 9: uint32(0x40000000), + 10: uint32(0x40400000), + 11: uint32(0x40400000), + 12: uint32(0x40000000), + 13: uint32(0x40000000), + 14: uint32(0x40400000), + 15: uint32(0x40400000), + }, + 13: { + 2: uint32(0x00000040), + 3: uint32(0x00000040), + 6: uint32(0x00000040), + 7: uint32(0x00000040), + 8: uint32(0x00004000), + 9: uint32(0x00004000), + 10: uint32(0x00004040), + 11: uint32(0x00004040), + 12: uint32(0x00004000), + 13: uint32(0x00004000), + 14: uint32(0x00004040), + 15: uint32(0x00004040), + }, + 14: { + 2: uint32(0x00800000), + 3: uint32(0x00800000), + 6: uint32(0x00800000), + 7: uint32(0x00800000), + 8: uint32(0x80000000), + 9: uint32(0x80000000), + 10: uint32(0x80800000), + 11: uint32(0x80800000), + 12: uint32(0x80000000), + 13: uint32(0x80000000), + 14: uint32(0x80800000), + 15: uint32(0x80800000), + }, + 15: { + 2: uint32(0x00000080), + 3: uint32(0x00000080), + 6: uint32(0x00000080), + 7: uint32(0x00000080), + 8: uint32(0x00008000), + 9: uint32(0x00008000), + 10: uint32(0x00008080), + 11: uint32(0x00008080), + 12: uint32(0x00008000), + 13: uint32(0x00008000), + 14: uint32(0x00008080), + 15: uint32(0x00008080), + }, +} +var _fp_maskl = [8][16]Tuint32_t{ + 0: { + 1: uint32(0x40000000), + 2: uint32(0x00400000), + 3: uint32(0x40400000), + 4: uint32(0x00004000), + 5: uint32(0x40004000), + 6: uint32(0x00404000), + 7: uint32(0x40404000), + 8: uint32(0x00000040), + 9: uint32(0x40000040), + 10: uint32(0x00400040), + 11: uint32(0x40400040), + 12: uint32(0x00004040), + 13: uint32(0x40004040), + 14: uint32(0x00404040), + 15: uint32(0x40404040), + }, + 1: { + 1: uint32(0x10000000), + 2: uint32(0x00100000), + 3: uint32(0x10100000), + 4: uint32(0x00001000), + 5: uint32(0x10001000), + 6: uint32(0x00101000), + 7: uint32(0x10101000), + 8: uint32(0x00000010), + 9: uint32(0x10000010), + 10: uint32(0x00100010), + 11: uint32(0x10100010), + 12: uint32(0x00001010), + 13: uint32(0x10001010), + 14: uint32(0x00101010), + 15: uint32(0x10101010), + }, + 2: { + 1: uint32(0x04000000), + 2: uint32(0x00040000), + 3: uint32(0x04040000), + 4: uint32(0x00000400), + 5: uint32(0x04000400), + 6: uint32(0x00040400), + 7: uint32(0x04040400), + 8: uint32(0x00000004), + 9: uint32(0x04000004), + 10: uint32(0x00040004), + 11: uint32(0x04040004), + 12: uint32(0x00000404), + 13: uint32(0x04000404), + 14: uint32(0x00040404), + 15: uint32(0x04040404), + }, + 3: { + 1: uint32(0x01000000), + 2: uint32(0x00010000), + 3: uint32(0x01010000), + 4: uint32(0x00000100), + 5: uint32(0x01000100), + 6: uint32(0x00010100), + 7: uint32(0x01010100), + 8: uint32(0x00000001), + 9: uint32(0x01000001), + 10: uint32(0x00010001), + 11: uint32(0x01010001), + 12: uint32(0x00000101), + 13: uint32(0x01000101), + 14: uint32(0x00010101), + 15: uint32(0x01010101), + }, + 4: { + 1: uint32(0x80000000), + 2: uint32(0x00800000), + 3: uint32(0x80800000), + 4: uint32(0x00008000), + 5: uint32(0x80008000), + 6: uint32(0x00808000), + 7: uint32(0x80808000), + 8: uint32(0x00000080), + 9: uint32(0x80000080), + 10: uint32(0x00800080), + 11: uint32(0x80800080), + 12: uint32(0x00008080), + 13: uint32(0x80008080), + 14: uint32(0x00808080), + 15: uint32(0x80808080), + }, + 5: { + 1: uint32(0x20000000), + 2: uint32(0x00200000), + 3: uint32(0x20200000), + 4: uint32(0x00002000), + 5: uint32(0x20002000), + 6: uint32(0x00202000), + 7: uint32(0x20202000), + 8: uint32(0x00000020), + 9: uint32(0x20000020), + 10: uint32(0x00200020), + 11: uint32(0x20200020), + 12: uint32(0x00002020), + 13: uint32(0x20002020), + 14: uint32(0x00202020), + 15: uint32(0x20202020), + }, + 6: { + 1: uint32(0x08000000), + 2: uint32(0x00080000), + 3: uint32(0x08080000), + 4: uint32(0x00000800), + 5: uint32(0x08000800), + 6: uint32(0x00080800), + 7: uint32(0x08080800), + 8: uint32(0x00000008), + 9: uint32(0x08000008), + 10: uint32(0x00080008), + 11: uint32(0x08080008), + 12: uint32(0x00000808), + 13: uint32(0x08000808), + 14: uint32(0x00080808), + 15: uint32(0x08080808), + }, + 7: { + 1: uint32(0x02000000), + 2: uint32(0x00020000), + 3: uint32(0x02020000), + 4: uint32(0x00000200), + 5: uint32(0x02000200), + 6: uint32(0x00020200), + 7: uint32(0x02020200), + 8: uint32(0x00000002), + 9: uint32(0x02000002), + 10: uint32(0x00020002), + 11: uint32(0x02020002), + 12: uint32(0x00000202), + 13: uint32(0x02000202), + 14: uint32(0x00020202), + 15: uint32(0x02020202), + }, +} +var _fp_maskr = [8][16]Tuint32_t{ + 0: { + 1: uint32(0x40000000), + 2: uint32(0x00400000), + 3: uint32(0x40400000), + 4: uint32(0x00004000), + 5: uint32(0x40004000), + 6: uint32(0x00404000), + 7: uint32(0x40404000), + 8: uint32(0x00000040), + 9: uint32(0x40000040), + 10: uint32(0x00400040), + 11: uint32(0x40400040), + 12: uint32(0x00004040), + 13: uint32(0x40004040), + 14: uint32(0x00404040), + 15: uint32(0x40404040), + }, + 1: { + 1: uint32(0x10000000), + 2: uint32(0x00100000), + 3: uint32(0x10100000), + 4: uint32(0x00001000), + 5: uint32(0x10001000), + 6: uint32(0x00101000), + 7: uint32(0x10101000), + 8: uint32(0x00000010), + 9: uint32(0x10000010), + 10: uint32(0x00100010), + 11: uint32(0x10100010), + 12: uint32(0x00001010), + 13: uint32(0x10001010), + 14: uint32(0x00101010), + 15: uint32(0x10101010), + }, + 2: { + 1: uint32(0x04000000), + 2: uint32(0x00040000), + 3: uint32(0x04040000), + 4: uint32(0x00000400), + 5: uint32(0x04000400), + 6: uint32(0x00040400), + 7: uint32(0x04040400), + 8: uint32(0x00000004), + 9: uint32(0x04000004), + 10: uint32(0x00040004), + 11: uint32(0x04040004), + 12: uint32(0x00000404), + 13: uint32(0x04000404), + 14: uint32(0x00040404), + 15: uint32(0x04040404), + }, + 3: { + 1: uint32(0x01000000), + 2: uint32(0x00010000), + 3: uint32(0x01010000), + 4: uint32(0x00000100), + 5: uint32(0x01000100), + 6: uint32(0x00010100), + 7: uint32(0x01010100), + 8: uint32(0x00000001), + 9: uint32(0x01000001), + 10: uint32(0x00010001), + 11: uint32(0x01010001), + 12: uint32(0x00000101), + 13: uint32(0x01000101), + 14: uint32(0x00010101), + 15: uint32(0x01010101), + }, + 4: { + 1: uint32(0x80000000), + 2: uint32(0x00800000), + 3: uint32(0x80800000), + 4: uint32(0x00008000), + 5: uint32(0x80008000), + 6: uint32(0x00808000), + 7: uint32(0x80808000), + 8: uint32(0x00000080), + 9: uint32(0x80000080), + 10: uint32(0x00800080), + 11: uint32(0x80800080), + 12: uint32(0x00008080), + 13: uint32(0x80008080), + 14: uint32(0x00808080), + 15: uint32(0x80808080), + }, + 5: { + 1: uint32(0x20000000), + 2: uint32(0x00200000), + 3: uint32(0x20200000), + 4: uint32(0x00002000), + 5: uint32(0x20002000), + 6: uint32(0x00202000), + 7: uint32(0x20202000), + 8: uint32(0x00000020), + 9: uint32(0x20000020), + 10: uint32(0x00200020), + 11: uint32(0x20200020), + 12: uint32(0x00002020), + 13: uint32(0x20002020), + 14: uint32(0x00202020), + 15: uint32(0x20202020), + }, + 6: { + 1: uint32(0x08000000), + 2: uint32(0x00080000), + 3: uint32(0x08080000), + 4: uint32(0x00000800), + 5: uint32(0x08000800), + 6: uint32(0x00080800), + 7: uint32(0x08080800), + 8: uint32(0x00000008), + 9: uint32(0x08000008), + 10: uint32(0x00080008), + 11: uint32(0x08080008), + 12: uint32(0x00000808), + 13: uint32(0x08000808), + 14: uint32(0x00080808), + 15: uint32(0x08080808), + }, + 7: { + 1: uint32(0x02000000), + 2: uint32(0x00020000), + 3: uint32(0x02020000), + 4: uint32(0x00000200), + 5: uint32(0x02000200), + 6: uint32(0x00020200), + 7: uint32(0x02020200), + 8: uint32(0x00000002), + 9: uint32(0x02000002), + 10: uint32(0x00020002), + 11: uint32(0x02020002), + 12: uint32(0x00000202), + 13: uint32(0x02000202), + 14: uint32(0x00020202), + 15: uint32(0x02020202), + }, +} +var _key_perm_maskl = [8][16]Tuint32_t{ + 0: { + 2: uint32(0x00000010), + 3: uint32(0x00000010), + 4: uint32(0x00001000), + 5: uint32(0x00001000), + 6: uint32(0x00001010), + 7: uint32(0x00001010), + 8: uint32(0x00100000), + 9: uint32(0x00100000), + 10: uint32(0x00100010), + 11: uint32(0x00100010), + 12: uint32(0x00101000), + 13: uint32(0x00101000), + 14: uint32(0x00101010), + 15: uint32(0x00101010), + }, + 1: { + 2: uint32(0x00000020), + 3: uint32(0x00000020), + 4: uint32(0x00002000), + 5: uint32(0x00002000), + 6: uint32(0x00002020), + 7: uint32(0x00002020), + 8: uint32(0x00200000), + 9: uint32(0x00200000), + 10: uint32(0x00200020), + 11: uint32(0x00200020), + 12: uint32(0x00202000), + 13: uint32(0x00202000), + 14: uint32(0x00202020), + 15: uint32(0x00202020), + }, + 2: { + 2: uint32(0x00000040), + 3: uint32(0x00000040), + 4: uint32(0x00004000), + 5: uint32(0x00004000), + 6: uint32(0x00004040), + 7: uint32(0x00004040), + 8: uint32(0x00400000), + 9: uint32(0x00400000), + 10: uint32(0x00400040), + 11: uint32(0x00400040), + 12: uint32(0x00404000), + 13: uint32(0x00404000), + 14: uint32(0x00404040), + 15: uint32(0x00404040), + }, + 3: { + 2: uint32(0x00000080), + 3: uint32(0x00000080), + 4: uint32(0x00008000), + 5: uint32(0x00008000), + 6: uint32(0x00008080), + 7: uint32(0x00008080), + 8: uint32(0x00800000), + 9: uint32(0x00800000), + 10: uint32(0x00800080), + 11: uint32(0x00800080), + 12: uint32(0x00808000), + 13: uint32(0x00808000), + 14: uint32(0x00808080), + 15: uint32(0x00808080), + }, + 4: { + 1: uint32(0x00000001), + 2: uint32(0x00000100), + 3: uint32(0x00000101), + 4: uint32(0x00010000), + 5: uint32(0x00010001), + 6: uint32(0x00010100), + 7: uint32(0x00010101), + 8: uint32(0x01000000), + 9: uint32(0x01000001), + 10: uint32(0x01000100), + 11: uint32(0x01000101), + 12: uint32(0x01010000), + 13: uint32(0x01010001), + 14: uint32(0x01010100), + 15: uint32(0x01010101), + }, + 5: { + 1: uint32(0x00000002), + 2: uint32(0x00000200), + 3: uint32(0x00000202), + 4: uint32(0x00020000), + 5: uint32(0x00020002), + 6: uint32(0x00020200), + 7: uint32(0x00020202), + 8: uint32(0x02000000), + 9: uint32(0x02000002), + 10: uint32(0x02000200), + 11: uint32(0x02000202), + 12: uint32(0x02020000), + 13: uint32(0x02020002), + 14: uint32(0x02020200), + 15: uint32(0x02020202), + }, + 6: { + 1: uint32(0x00000004), + 2: uint32(0x00000400), + 3: uint32(0x00000404), + 4: uint32(0x00040000), + 5: uint32(0x00040004), + 6: uint32(0x00040400), + 7: uint32(0x00040404), + 8: uint32(0x04000000), + 9: uint32(0x04000004), + 10: uint32(0x04000400), + 11: uint32(0x04000404), + 12: uint32(0x04040000), + 13: uint32(0x04040004), + 14: uint32(0x04040400), + 15: uint32(0x04040404), + }, + 7: { + 1: uint32(0x00000008), + 2: uint32(0x00000800), + 3: uint32(0x00000808), + 4: uint32(0x00080000), + 5: uint32(0x00080008), + 6: uint32(0x00080800), + 7: uint32(0x00080808), + 8: uint32(0x08000000), + 9: uint32(0x08000008), + 10: uint32(0x08000800), + 11: uint32(0x08000808), + 12: uint32(0x08080000), + 13: uint32(0x08080008), + 14: uint32(0x08080800), + 15: uint32(0x08080808), + }, +} +var _key_perm_maskr = [12][16]Tuint32_t{ + 0: { + 1: uint32(0x00000001), + 3: uint32(0x00000001), + 5: uint32(0x00000001), + 7: uint32(0x00000001), + 9: uint32(0x00000001), + 11: uint32(0x00000001), + 13: uint32(0x00000001), + 15: uint32(0x00000001), + }, + 1: { + 2: uint32(0x00100000), + 3: uint32(0x00100000), + 4: uint32(0x00001000), + 5: uint32(0x00001000), + 6: uint32(0x00101000), + 7: uint32(0x00101000), + 8: uint32(0x00000010), + 9: uint32(0x00000010), + 10: uint32(0x00100010), + 11: uint32(0x00100010), + 12: uint32(0x00001010), + 13: uint32(0x00001010), + 14: uint32(0x00101010), + 15: uint32(0x00101010), + }, + 2: { + 1: uint32(0x00000002), + 3: uint32(0x00000002), + 5: uint32(0x00000002), + 7: uint32(0x00000002), + 9: uint32(0x00000002), + 11: uint32(0x00000002), + 13: uint32(0x00000002), + 15: uint32(0x00000002), + }, + 3: { + 2: uint32(0x00200000), + 3: uint32(0x00200000), + 4: uint32(0x00002000), + 5: uint32(0x00002000), + 6: uint32(0x00202000), + 7: uint32(0x00202000), + 8: uint32(0x00000020), + 9: uint32(0x00000020), + 10: uint32(0x00200020), + 11: uint32(0x00200020), + 12: uint32(0x00002020), + 13: uint32(0x00002020), + 14: uint32(0x00202020), + 15: uint32(0x00202020), + }, + 4: { + 1: uint32(0x00000004), + 3: uint32(0x00000004), + 5: uint32(0x00000004), + 7: uint32(0x00000004), + 9: uint32(0x00000004), + 11: uint32(0x00000004), + 13: uint32(0x00000004), + 15: uint32(0x00000004), + }, + 5: { + 2: uint32(0x00400000), + 3: uint32(0x00400000), + 4: uint32(0x00004000), + 5: uint32(0x00004000), + 6: uint32(0x00404000), + 7: uint32(0x00404000), + 8: uint32(0x00000040), + 9: uint32(0x00000040), + 10: uint32(0x00400040), + 11: uint32(0x00400040), + 12: uint32(0x00004040), + 13: uint32(0x00004040), + 14: uint32(0x00404040), + 15: uint32(0x00404040), + }, + 6: { + 1: uint32(0x00000008), + 3: uint32(0x00000008), + 5: uint32(0x00000008), + 7: uint32(0x00000008), + 9: uint32(0x00000008), + 11: uint32(0x00000008), + 13: uint32(0x00000008), + 15: uint32(0x00000008), + }, + 7: { + 2: uint32(0x00800000), + 3: uint32(0x00800000), + 4: uint32(0x00008000), + 5: uint32(0x00008000), + 6: uint32(0x00808000), + 7: uint32(0x00808000), + 8: uint32(0x00000080), + 9: uint32(0x00000080), + 10: uint32(0x00800080), + 11: uint32(0x00800080), + 12: uint32(0x00008080), + 13: uint32(0x00008080), + 14: uint32(0x00808080), + 15: uint32(0x00808080), + }, + 8: { + 2: uint32(0x01000000), + 3: uint32(0x01000000), + 4: uint32(0x00010000), + 5: uint32(0x00010000), + 6: uint32(0x01010000), + 7: uint32(0x01010000), + 8: uint32(0x00000100), + 9: uint32(0x00000100), + 10: uint32(0x01000100), + 11: uint32(0x01000100), + 12: uint32(0x00010100), + 13: uint32(0x00010100), + 14: uint32(0x01010100), + 15: uint32(0x01010100), + }, + 9: { + 2: uint32(0x02000000), + 3: uint32(0x02000000), + 4: uint32(0x00020000), + 5: uint32(0x00020000), + 6: uint32(0x02020000), + 7: uint32(0x02020000), + 8: uint32(0x00000200), + 9: uint32(0x00000200), + 10: uint32(0x02000200), + 11: uint32(0x02000200), + 12: uint32(0x00020200), + 13: uint32(0x00020200), + 14: uint32(0x02020200), + 15: uint32(0x02020200), + }, + 10: { + 2: uint32(0x04000000), + 3: uint32(0x04000000), + 4: uint32(0x00040000), + 5: uint32(0x00040000), + 6: uint32(0x04040000), + 7: uint32(0x04040000), + 8: uint32(0x00000400), + 9: uint32(0x00000400), + 10: uint32(0x04000400), + 11: uint32(0x04000400), + 12: uint32(0x00040400), + 13: uint32(0x00040400), + 14: uint32(0x04040400), + 15: uint32(0x04040400), + }, + 11: { + 2: uint32(0x08000000), + 3: uint32(0x08000000), + 4: uint32(0x00080000), + 5: uint32(0x00080000), + 6: uint32(0x08080000), + 7: uint32(0x08080000), + 8: uint32(0x00000800), + 9: uint32(0x00000800), + 10: uint32(0x08000800), + 11: uint32(0x08000800), + 12: uint32(0x00080800), + 13: uint32(0x00080800), + 14: uint32(0x08080800), + 15: uint32(0x08080800), + }, +} +var _comp_maskl0 = [4][8]Tuint32_t{ + 0: { + 1: uint32(0x00020000), + 2: uint32(0x00000001), + 3: uint32(0x00020001), + 4: uint32(0x00080000), + 5: uint32(0x000a0000), + 6: uint32(0x00080001), + 7: uint32(0x000a0001), + }, + 1: { + 1: uint32(0x00001000), + 3: uint32(0x00001000), + 4: uint32(0x00000040), + 5: uint32(0x00001040), + 6: uint32(0x00000040), + 7: uint32(0x00001040), + }, + 2: { + 1: uint32(0x00400000), + 2: uint32(0x00000020), + 3: uint32(0x00400020), + 4: uint32(0x00008000), + 5: uint32(0x00408000), + 6: uint32(0x00008020), + 7: uint32(0x00408020), + }, + 3: { + 1: uint32(0x00100000), + 2: uint32(0x00000800), + 3: uint32(0x00100800), + 5: uint32(0x00100000), + 6: uint32(0x00000800), + 7: uint32(0x00100800), + }, +} +var _comp_maskr0 = [4][8]Tuint32_t{ + 0: { + 1: uint32(0x00200000), + 2: uint32(0x00020000), + 3: uint32(0x00220000), + 4: uint32(0x00000002), + 5: uint32(0x00200002), + 6: uint32(0x00020002), + 7: uint32(0x00220002), + }, + 1: { + 2: uint32(0x00100000), + 3: uint32(0x00100000), + 4: uint32(0x00000004), + 5: uint32(0x00000004), + 6: uint32(0x00100004), + 7: uint32(0x00100004), + }, + 2: { + 1: uint32(0x00004000), + 2: uint32(0x00000800), + 3: uint32(0x00004800), + 5: uint32(0x00004000), + 6: uint32(0x00000800), + 7: uint32(0x00004800), + }, + 3: { + 1: uint32(0x00400000), + 2: uint32(0x00008000), + 3: uint32(0x00408000), + 4: uint32(0x00000008), + 5: uint32(0x00400008), + 6: uint32(0x00008008), + 7: uint32(0x00408008), + }, +} +var _comp_maskl1 = [4][16]Tuint32_t{ + 0: { + 1: uint32(0x00000010), + 2: uint32(0x00004000), + 3: uint32(0x00004010), + 4: uint32(0x00040000), + 5: uint32(0x00040010), + 6: uint32(0x00044000), + 7: uint32(0x00044010), + 8: uint32(0x00000100), + 9: uint32(0x00000110), + 10: uint32(0x00004100), + 11: uint32(0x00004110), + 12: uint32(0x00040100), + 13: uint32(0x00040110), + 14: uint32(0x00044100), + 15: uint32(0x00044110), + }, + 1: { + 1: uint32(0x00800000), + 2: uint32(0x00000002), + 3: uint32(0x00800002), + 4: uint32(0x00000200), + 5: uint32(0x00800200), + 6: uint32(0x00000202), + 7: uint32(0x00800202), + 8: uint32(0x00200000), + 9: uint32(0x00a00000), + 10: uint32(0x00200002), + 11: uint32(0x00a00002), + 12: uint32(0x00200200), + 13: uint32(0x00a00200), + 14: uint32(0x00200202), + 15: uint32(0x00a00202), + }, + 2: { + 1: uint32(0x00002000), + 2: uint32(0x00000004), + 3: uint32(0x00002004), + 4: uint32(0x00000400), + 5: uint32(0x00002400), + 6: uint32(0x00000404), + 7: uint32(0x00002404), + 9: uint32(0x00002000), + 10: uint32(0x00000004), + 11: uint32(0x00002004), + 12: uint32(0x00000400), + 13: uint32(0x00002400), + 14: uint32(0x00000404), + 15: uint32(0x00002404), + }, + 3: { + 1: uint32(0x00010000), + 2: uint32(0x00000008), + 3: uint32(0x00010008), + 4: uint32(0x00000080), + 5: uint32(0x00010080), + 6: uint32(0x00000088), + 7: uint32(0x00010088), + 9: uint32(0x00010000), + 10: uint32(0x00000008), + 11: uint32(0x00010008), + 12: uint32(0x00000080), + 13: uint32(0x00010080), + 14: uint32(0x00000088), + 15: uint32(0x00010088), + }, +} +var _comp_maskr1 = [4][16]Tuint32_t{ + 0: { + 2: uint32(0x00000080), + 3: uint32(0x00000080), + 4: uint32(0x00002000), + 5: uint32(0x00002000), + 6: uint32(0x00002080), + 7: uint32(0x00002080), + 8: uint32(0x00000001), + 9: uint32(0x00000001), + 10: uint32(0x00000081), + 11: uint32(0x00000081), + 12: uint32(0x00002001), + 13: uint32(0x00002001), + 14: uint32(0x00002081), + 15: uint32(0x00002081), + }, + 1: { + 1: uint32(0x00000010), + 2: uint32(0x00800000), + 3: uint32(0x00800010), + 4: uint32(0x00010000), + 5: uint32(0x00010010), + 6: uint32(0x00810000), + 7: uint32(0x00810010), + 8: uint32(0x00000200), + 9: uint32(0x00000210), + 10: uint32(0x00800200), + 11: uint32(0x00800210), + 12: uint32(0x00010200), + 13: uint32(0x00010210), + 14: uint32(0x00810200), + 15: uint32(0x00810210), + }, + 2: { + 1: uint32(0x00000400), + 2: uint32(0x00001000), + 3: uint32(0x00001400), + 4: uint32(0x00080000), + 5: uint32(0x00080400), + 6: uint32(0x00081000), + 7: uint32(0x00081400), + 8: uint32(0x00000020), + 9: uint32(0x00000420), + 10: uint32(0x00001020), + 11: uint32(0x00001420), + 12: uint32(0x00080020), + 13: uint32(0x00080420), + 14: uint32(0x00081020), + 15: uint32(0x00081420), + }, + 3: { + 1: uint32(0x00000100), + 2: uint32(0x00040000), + 3: uint32(0x00040100), + 5: uint32(0x00000100), + 6: uint32(0x00040000), + 7: uint32(0x00040100), + 8: uint32(0x00000040), + 9: uint32(0x00000140), + 10: uint32(0x00040040), + 11: uint32(0x00040140), + 12: uint32(0x00000040), + 13: uint32(0x00000140), + 14: uint32(0x00040040), + 15: uint32(0x00040140), + }, +} + +var _ascii64 = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +/* 0000000000111111111122222222223333333333444444444455555555556666 */ +/* 0123456789012345678901234567890123456789012345678901234567890123 */ + +// C documentation +// +// /* +// * We match the behavior of UFC-crypt on systems where "char" is signed by +// * default (the majority), regardless of char's signedness on our system. +// */ +func _ascii_to_bin(tls *TLS, ch int32) (r Tuint32_t) { + var retval, sch, v1 int32 + _, _, _ = retval, sch, v1 + if ch < int32(0x80) { + v1 = ch + } else { + v1 = -(int32(0x100) - ch) + } + sch = v1 + retval = sch - int32('.') + if sch >= int32('A') { + retval = sch - (Int32FromUint8('A') - Int32FromInt32(12)) + if sch >= int32('a') { + retval = sch - (Int32FromUint8('a') - Int32FromInt32(38)) + } + } + retval = retval & int32(0x3f) + return Uint32FromInt32(retval) +} + +// C documentation +// +// /* +// * When we choose to "support" invalid salts, nevertheless disallow those +// * containing characters that would violate the passwd file format. +// */ +func _ascii_is_unsafe(tls *TLS, ch uint8) (r int32) { + return BoolInt32(!(ch != 0) || Int32FromUint8(ch) == int32('\n') || Int32FromUint8(ch) == int32(':')) +} + +func _setup_salt(tls *TLS, salt Tuint32_t) (r Tuint32_t) { + var i uint32 + var obit, saltbit, saltbits Tuint32_t + _, _, _, _ = i, obit, saltbit, saltbits + saltbits = uint32(0) + saltbit = uint32(1) + obit = uint32(0x800000) + i = uint32(0) + for { + if !(i < uint32(24)) { + break + } + if salt&saltbit != 0 { + saltbits = saltbits | obit + } + saltbit = saltbit << uint32(1) + obit = obit >> uint32(1) + goto _1 + _1: + ; + i = i + 1 + } + return saltbits +} + +func X__des_setkey(tls *TLS, key uintptr, ekey uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v ekey=%v, (%v:)", tls, key, ekey, origin(2)) + } + var i, ibit, j, round, shifts uint32 + var k0, k1, kl, kr, rawkey0, rawkey1, t0, t1, v1 Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, ibit, j, k0, k1, kl, kr, rawkey0, rawkey1, round, shifts, t0, t1, v1 + rawkey0 = uint32(**(**uint8)(__ccgo_up(key + 3))) | uint32(**(**uint8)(__ccgo_up(key + 2)))<>ibit&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_key_perm_maskl)) + uintptr(i+uint32(4))*64 + uintptr(rawkey1>>ibit&uint32(0xf))*4))) + k1 = k1 | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_key_perm_maskr)) + uintptr(j)*64 + uintptr(rawkey0>>ibit&uint32(0xf))*4)) + ibit = ibit - uint32(4) + k1 = k1 | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_key_perm_maskr)) + uintptr(j+uint32(1))*64 + uintptr(rawkey0>>ibit&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_key_perm_maskr)) + uintptr(i+uint32(8))*64 + uintptr(rawkey1>>ibit&uint32(0xf))*4))) + goto _2 + _2: + ; + i = i + 1 + ibit = ibit - uint32(4) + } + /* + * Rotate subkeys and do compression permutation. + */ + shifts = uint32(0) + round = uint32(0) + for { + if !(round < uint32(16)) { + break + } + shifts = shifts + uint32(_key_shifts[round]) + t0 = k0<>(Uint32FromInt32(28)-shifts) + t1 = k1<>(Uint32FromInt32(28)-shifts) + v1 = Uint32FromInt32(0) + kr = v1 + kl = v1 + ibit = uint32(25) + i = uint32(0) + for { + if !(i < uint32(4)) { + break + } + kl = kl | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_comp_maskl0)) + uintptr(i)*32 + uintptr(t0>>ibit&uint32(7))*4)) + kr = kr | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_comp_maskr0)) + uintptr(i)*32 + uintptr(t1>>ibit&uint32(7))*4)) + ibit = ibit - uint32(4) + kl = kl | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_comp_maskl1)) + uintptr(i)*64 + uintptr(t0>>ibit&uint32(0xf))*4)) + kr = kr | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_comp_maskr1)) + uintptr(i)*64 + uintptr(t1>>ibit&uint32(0xf))*4)) + ibit = ibit - uint32(3) + goto _5 + _5: + ; + i = i + 1 + } + **(**Tuint32_t)(__ccgo_up(ekey + uintptr(round)*4)) = kl + **(**Tuint32_t)(__ccgo_up(ekey + 64 + uintptr(round)*4)) = kr + goto _3 + _3: + ; + round = round + 1 + } +} + +// C documentation +// +// /* +// * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. +// */ +func X__do_des(tls *TLS, l_in Tuint32_t, r_in Tuint32_t, l_out uintptr, r_out uintptr, count Tuint32_t, saltbits Tuint32_t, ekey uintptr) { + if __ccgo_strace { + trc("tls=%v l_in=%v r_in=%v l_out=%v r_out=%v count=%v saltbits=%v ekey=%v, (%v:)", tls, l_in, r_in, l_out, r_out, count, saltbits, ekey, origin(2)) + } + var f, l, lo, r, r48l, r48r, ro, v1 Tuint32_t + var i, i1, ibit, ibit1, round, v4 uint32 + var kl, kr, v5 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = f, i, i1, ibit, ibit1, kl, kr, l, lo, r, r48l, r48r, ro, round, v1, v4, v5 + /* + * Do initial permutation (IP). + */ + v1 = Uint32FromInt32(0) + r = v1 + l = v1 + if l_in|r_in != 0 { + i = uint32(0) + ibit = Uint32FromInt32(28) + for { + if !(i < uint32(8)) { + break + } + l = l | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_ip_maskl)) + uintptr(i)*64 + uintptr(l_in>>ibit&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_ip_maskl)) + uintptr(i+uint32(8))*64 + uintptr(r_in>>ibit&uint32(0xf))*4))) + r = r | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_ip_maskr)) + uintptr(i)*64 + uintptr(l_in>>ibit&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_ip_maskr)) + uintptr(i+uint32(8))*64 + uintptr(r_in>>ibit&uint32(0xf))*4))) + goto _2 + _2: + ; + i = i + 1 + ibit = ibit - uint32(4) + } + } + for { + v1 = count + count = count - 1 + if !(v1 != 0) { + break + } + /* + * Do each round. + */ + round = uint32(16) + kl = ekey + kr = ekey + 64 + for { + v4 = round + round = round - 1 + if !(v4 != 0) { + break + } + /* + * Expand R to 48 bits (simulate the E-box). + */ + r48l = r&uint32(0x00000001)<>int32(9) | r&uint32(0x1f800000)>>int32(11) | r&uint32(0x01f80000)>>int32(13) | r&uint32(0x001f8000)>>int32(15) + r48r = r&uint32(0x0001f800)<>int32(31) + /* + * Do salting for crypt() and friends, and + * XOR with the permuted key. + */ + f = (r48l ^ r48r) & saltbits + v5 = kl + kl += 4 + r48l = r48l ^ (f ^ **(**Tuint32_t)(__ccgo_up(v5))) + v5 = kr + kr += 4 + r48r = r48r ^ (f ^ **(**Tuint32_t)(__ccgo_up(v5))) + /* + * Do S-box lookups (which shrink it back to 32 bits) + * and do the P-box permutation at the same time. + */ + f = **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + uintptr(r48l>>int32(18))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 1*256 + uintptr(r48l>>Int32FromInt32(12)&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 2*256 + uintptr(r48l>>Int32FromInt32(6)&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 3*256 + uintptr(r48l&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 4*256 + uintptr(r48r>>int32(18))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 5*256 + uintptr(r48r>>Int32FromInt32(12)&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 6*256 + uintptr(r48r>>Int32FromInt32(6)&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 7*256 + uintptr(r48r&uint32(0x3f))*4)) + /* + * Now that we've permuted things, complete f(). + */ + f = f ^ l + l = r + r = f + } + r = l + l = f + } + /* + * Do final permutation (inverse of IP). + */ + v1 = Uint32FromInt32(0) + ro = v1 + lo = v1 + i1 = uint32(0) + ibit1 = Uint32FromInt32(28) + for { + if !(i1 < uint32(4)) { + break + } + ro = ro | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_fp_maskr)) + uintptr(i1)*64 + uintptr(l>>ibit1&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_fp_maskr)) + uintptr(i1+uint32(4))*64 + uintptr(r>>ibit1&uint32(0xf))*4))) + ibit1 = ibit1 - uint32(4) + lo = lo | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_fp_maskl)) + uintptr(i1)*64 + uintptr(l>>ibit1&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_fp_maskl)) + uintptr(i1+uint32(4))*64 + uintptr(r>>ibit1&uint32(0xf))*4))) + goto _8 + _8: + ; + i1 = i1 + 1 + ibit1 = ibit1 - uint32(4) + } + **(**Tuint32_t)(__ccgo_up(l_out)) = lo + **(**Tuint32_t)(__ccgo_up(r_out)) = ro +} + +func _des_cipher(tls *TLS, in uintptr, out uintptr, count Tuint32_t, saltbits Tuint32_t, ekey uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rawl, rawr Tuint32_t + var _ /* l_out at bp+0 */ Tuint32_t + var _ /* r_out at bp+4 */ Tuint32_t + _, _ = rawl, rawr + rawl = uint32(**(**uint8)(__ccgo_up(in + 3))) | uint32(**(**uint8)(__ccgo_up(in + 2)))<> int32(24)) + **(**uint8)(__ccgo_up(out + 1)) = uint8(**(**Tuint32_t)(__ccgo_up(bp)) >> int32(16)) + **(**uint8)(__ccgo_up(out + 2)) = uint8(**(**Tuint32_t)(__ccgo_up(bp)) >> int32(8)) + **(**uint8)(__ccgo_up(out + 3)) = uint8(**(**Tuint32_t)(__ccgo_up(bp))) + **(**uint8)(__ccgo_up(out + 4)) = uint8(**(**Tuint32_t)(__ccgo_up(bp + 4)) >> int32(24)) + **(**uint8)(__ccgo_up(out + 5)) = uint8(**(**Tuint32_t)(__ccgo_up(bp + 4)) >> int32(16)) + **(**uint8)(__ccgo_up(out + 6)) = uint8(**(**Tuint32_t)(__ccgo_up(bp + 4)) >> int32(8)) + **(**uint8)(__ccgo_up(out + 7)) = uint8(**(**Tuint32_t)(__ccgo_up(bp + 4))) +} + +func __crypt_extended_r_uut(tls *TLS, _key uintptr, _setting uintptr, output uintptr) (r uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var count, l, salt, value, value1 Tuint32_t + var i uint32 + var key, p, q, setting, v1, v4, v5 uintptr + var _ /* ekey at bp+0 */ Texpanded_key + var _ /* keybuf at bp+128 */ [8]uint8 + var _ /* r0 at bp+136 */ Tuint32_t + var _ /* r1 at bp+140 */ Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _ = count, i, key, l, p, q, salt, setting, value, value1, v1, v4, v5 + key = _key + setting = _setting + /* + * Copy the key, shifting each character left by one bit and padding + * with zeroes. + */ + q = bp + 128 + for q <= bp+128+uintptr(Uint64FromInt64(8)-Uint64FromInt32(1)) { + v1 = q + q = q + 1 + **(**uint8)(__ccgo_up(v1)) = Uint8FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(key))) << int32(1)) + if **(**uint8)(__ccgo_up(key)) != 0 { + key = key + 1 + } + } + X__des_setkey(tls, bp+128, bp) + if Int32FromUint8(**(**uint8)(__ccgo_up(setting))) == int32('_') { + /* + * "new"-style: + * setting - underscore, 4 chars of count, 4 chars of salt + * key - unlimited characters + */ + i = uint32(1) + count = Uint32FromInt32(0) + for { + if !(i < uint32(5)) { + break + } + value = _ascii_to_bin(tls, Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(i))))) + if Int32FromUint8(_ascii64[value]) != Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(i)))) { + return UintptrFromInt32(0) + } + count = count | value<<((i-uint32(1))*uint32(6)) + goto _2 + _2: + ; + i = i + 1 + } + if !(count != 0) { + return UintptrFromInt32(0) + } + i = uint32(5) + salt = Uint32FromInt32(0) + for { + if !(i < uint32(9)) { + break + } + value1 = _ascii_to_bin(tls, Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(i))))) + if Int32FromUint8(_ascii64[value1]) != Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(i)))) { + return UintptrFromInt32(0) + } + salt = salt | value1<<((i-uint32(5))*uint32(6)) + goto _3 + _3: + ; + i = i + 1 + } + for **(**uint8)(__ccgo_up(key)) != 0 { + /* + * Encrypt the key with itself. + */ + _des_cipher(tls, bp+128, bp+128, uint32(1), uint32(0), bp) + /* + * And XOR with the next 8 characters of the key. + */ + q = bp + 128 + for q <= bp+128+uintptr(Uint64FromInt64(8)-Uint64FromInt32(1)) && **(**uint8)(__ccgo_up(key)) != 0 { + v4 = q + q = q + 1 + v1 = v4 + v5 = key + key = key + 1 + *(*uint8)(unsafe.Pointer(v1)) = uint8(int32(*(*uint8)(unsafe.Pointer(v1))) ^ Int32FromUint8(**(**uint8)(__ccgo_up(v5)))<> int32(8) + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(18)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(12)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(6)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l&uint32(0x3f)] + l = **(**Tuint32_t)(__ccgo_up(bp + 136))<>Int32FromInt32(16)&uint32(0xffff) + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(18)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(12)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(6)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l&uint32(0x3f)] + l = **(**Tuint32_t)(__ccgo_up(bp + 140)) << int32(2) + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(12)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(6)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l&uint32(0x3f)] + **(**uint8)(__ccgo_up(p)) = uint8(0) + return output +} + +func X__crypt_des(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v setting=%v output=%v, (%v:)", tls, key, setting, output, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var p, retval, test_hash, test_key, test_setting, v1 uintptr + var _ /* test_buf at bp+0 */ [21]int8 + _, _, _, _, _, _ = p, retval, test_hash, test_key, test_setting, v1 + test_key = __ccgo_ts + 72 + test_setting = __ccgo_ts + 93 + test_hash = __ccgo_ts + 103 + if int32(**(**int8)(__ccgo_up(setting))) != int32('_') { + test_setting = __ccgo_ts + 124 + test_hash = __ccgo_ts + 127 + } + /* + * Hash the supplied password. + */ + retval = __crypt_extended_r_uut(tls, key, setting, output) + /* + * Perform a quick self-test. It is important that we make both calls + * to _crypt_extended_r_uut() from the same scope such that they likely + * use the same stack locations, which makes the second call overwrite + * the first call's sensitive data on the stack and makes it more + * likely that any alignment related issues would be detected. + */ + p = __crypt_extended_r_uut(tls, test_key, test_setting, bp) + if p != 0 && !(Xstrcmp(tls, p, test_hash) != 0) && retval != 0 { + return retval + } + if int32(**(**int8)(__ccgo_up(setting))) == int32('*') { + v1 = __ccgo_ts + 141 + } else { + v1 = __ccgo_ts + 70 + } + return v1 +} + +const KEY_MAX = 30000 +const SALT_MAX = 8 + +/* public domain md5 implementation based on rfc1321 and libtomcrypt */ + +type Tmd5 = struct { + Flen1 Tuint64_t + Fh [4]Tuint32_t + Fbuf [64]Tuint8_t +} + +func _rol(tls *TLS, n Tuint32_t, k int32) (r Tuint32_t) { + return n<>(Int32FromInt32(32)-k) +} + +var _tab = [64]Tuint32_t{ + 0: uint32(0xd76aa478), + 1: uint32(0xe8c7b756), + 2: uint32(0x242070db), + 3: uint32(0xc1bdceee), + 4: uint32(0xf57c0faf), + 5: uint32(0x4787c62a), + 6: uint32(0xa8304613), + 7: uint32(0xfd469501), + 8: uint32(0x698098d8), + 9: uint32(0x8b44f7af), + 10: uint32(0xffff5bb1), + 11: uint32(0x895cd7be), + 12: uint32(0x6b901122), + 13: uint32(0xfd987193), + 14: uint32(0xa679438e), + 15: uint32(0x49b40821), + 16: uint32(0xf61e2562), + 17: uint32(0xc040b340), + 18: uint32(0x265e5a51), + 19: uint32(0xe9b6c7aa), + 20: uint32(0xd62f105d), + 21: uint32(0x02441453), + 22: uint32(0xd8a1e681), + 23: uint32(0xe7d3fbc8), + 24: uint32(0x21e1cde6), + 25: uint32(0xc33707d6), + 26: uint32(0xf4d50d87), + 27: uint32(0x455a14ed), + 28: uint32(0xa9e3e905), + 29: uint32(0xfcefa3f8), + 30: uint32(0x676f02d9), + 31: uint32(0x8d2a4c8a), + 32: uint32(0xfffa3942), + 33: uint32(0x8771f681), + 34: uint32(0x6d9d6122), + 35: uint32(0xfde5380c), + 36: uint32(0xa4beea44), + 37: uint32(0x4bdecfa9), + 38: uint32(0xf6bb4b60), + 39: uint32(0xbebfbc70), + 40: uint32(0x289b7ec6), + 41: uint32(0xeaa127fa), + 42: uint32(0xd4ef3085), + 43: uint32(0x04881d05), + 44: uint32(0xd9d4d039), + 45: uint32(0xe6db99e5), + 46: uint32(0x1fa27cf8), + 47: uint32(0xc4ac5665), + 48: uint32(0xf4292244), + 49: uint32(0x432aff97), + 50: uint32(0xab9423a7), + 51: uint32(0xfc93a039), + 52: uint32(0x655b59c3), + 53: uint32(0x8f0ccc92), + 54: uint32(0xffeff47d), + 55: uint32(0x85845dd1), + 56: uint32(0x6fa87e4f), + 57: uint32(0xfe2ce6e0), + 58: uint32(0xa3014314), + 59: uint32(0x4e0811a1), + 60: uint32(0xf7537e82), + 61: uint32(0xbd3af235), + 62: uint32(0x2ad7d2bb), + 63: uint32(0xeb86d391), +} + +func _processblock(tls *TLS, s uintptr, buf uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, b, c, d, i Tuint32_t + var _ /* W at bp+0 */ [16]Tuint32_t + _, _, _, _, _ = a, b, c, d, i + i = uint32(0) + for { + if !(i < uint32(16)) { + break + } + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] = uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(uint32(4)*i)))) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(uint32(4)*i+uint32(1))))) << int32(8) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(uint32(4)*i+uint32(2))))) << int32(16) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(uint32(4)*i+uint32(3))))) << int32(24) + goto _1 + _1: + ; + i = i + 1 + } + a = **(**Tuint32_t)(__ccgo_up(s + 8)) + b = **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) + c = **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) + d = **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) + i = uint32(0) + for i < uint32(16) { + a = a + (d ^ b&(c^d) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] + _tab[i]) + a = _rol(tls, a, int32(7)) + b + i = i + 1 + d = d + (c ^ a&(b^c) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] + _tab[i]) + d = _rol(tls, d, int32(12)) + a + i = i + 1 + c = c + (b ^ d&(a^b) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] + _tab[i]) + c = _rol(tls, c, int32(17)) + d + i = i + 1 + b = b + (a ^ c&(d^a) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] + _tab[i]) + b = _rol(tls, b, int32(22)) + c + i = i + 1 + } + for i < uint32(32) { + a = a + (c ^ d&(c^b) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(5)*i+uint32(1))%uint32(16)] + _tab[i]) + a = _rol(tls, a, int32(5)) + b + i = i + 1 + d = d + (b ^ c&(b^a) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(5)*i+uint32(1))%uint32(16)] + _tab[i]) + d = _rol(tls, d, int32(9)) + a + i = i + 1 + c = c + (a ^ b&(a^d) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(5)*i+uint32(1))%uint32(16)] + _tab[i]) + c = _rol(tls, c, int32(14)) + d + i = i + 1 + b = b + (d ^ a&(d^c) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(5)*i+uint32(1))%uint32(16)] + _tab[i]) + b = _rol(tls, b, int32(20)) + c + i = i + 1 + } + for i < uint32(48) { + a = a + (b ^ c ^ d + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(3)*i+uint32(5))%uint32(16)] + _tab[i]) + a = _rol(tls, a, int32(4)) + b + i = i + 1 + d = d + (a ^ b ^ c + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(3)*i+uint32(5))%uint32(16)] + _tab[i]) + d = _rol(tls, d, int32(11)) + a + i = i + 1 + c = c + (d ^ a ^ b + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(3)*i+uint32(5))%uint32(16)] + _tab[i]) + c = _rol(tls, c, int32(16)) + d + i = i + 1 + b = b + (c ^ d ^ a + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(3)*i+uint32(5))%uint32(16)] + _tab[i]) + b = _rol(tls, b, int32(23)) + c + i = i + 1 + } + for i < uint32(64) { + a = a + (c ^ (b | ^d) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[uint32(7)*i%uint32(16)] + _tab[i]) + a = _rol(tls, a, int32(6)) + b + i = i + 1 + d = d + (b ^ (a | ^c) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[uint32(7)*i%uint32(16)] + _tab[i]) + d = _rol(tls, d, int32(10)) + a + i = i + 1 + c = c + (a ^ (d | ^b) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[uint32(7)*i%uint32(16)] + _tab[i]) + c = _rol(tls, c, int32(15)) + d + i = i + 1 + b = b + (d ^ (c | ^a) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[uint32(7)*i%uint32(16)] + _tab[i]) + b = _rol(tls, b, int32(21)) + c + i = i + 1 + } + **(**Tuint32_t)(__ccgo_up(s + 8)) += a + **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) += b + **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) += c + **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) += d +} + +func _pad(tls *TLS, s uintptr) { + var r, v1 uint32 + _, _ = r, v1 + r = uint32((*Tmd5)(unsafe.Pointer(s)).Flen1 % uint64(64)) + v1 = r + r = r + 1 + **(**Tuint8_t)(__ccgo_up(s + 24 + uintptr(v1))) = uint8(0x80) + if r > uint32(56) { + Xmemset(tls, s+24+uintptr(r), 0, uint64(uint32(64)-r)) + r = uint32(0) + _processblock(tls, s, s+24) + } + Xmemset(tls, s+24+uintptr(r), 0, uint64(uint32(56)-r)) + **(**Tuint64_t)(__ccgo_up(s)) *= uint64(8) + **(**Tuint8_t)(__ccgo_up(s + 24 + 56)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1) + **(**Tuint8_t)(__ccgo_up(s + 24 + 57)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(8)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 58)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(16)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 59)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(24)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 60)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(32)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 61)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(40)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 62)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(48)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 63)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(56)) + _processblock(tls, s, s+24) +} + +func _md5_init(tls *TLS, s uintptr) { + (*Tmd5)(unsafe.Pointer(s)).Flen1 = uint64(0) + **(**Tuint32_t)(__ccgo_up(s + 8)) = uint32(0x67452301) + **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) = uint32(0xefcdab89) + **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) = uint32(0x98badcfe) + **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) = uint32(0x10325476) +} + +func _md5_sum(tls *TLS, s uintptr, md uintptr) { + var i int32 + _ = i + _pad(tls, s) + i = 0 + for { + if !(i < int32(4)) { + break + } + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4))) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(1)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(8)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(2)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(16)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(3)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(24)) + goto _1 + _1: + ; + i = i + 1 + } +} + +func _md5_update(tls *TLS, s uintptr, m uintptr, len1 uint64) { + var p uintptr + var r uint32 + _, _ = p, r + p = m + r = uint32((*Tmd5)(unsafe.Pointer(s)).Flen1 % uint64(64)) + **(**Tuint64_t)(__ccgo_up(s)) += len1 + if r != 0 { + if len1 < uint64(uint32(64)-r) { + Xmemcpy(tls, s+24+uintptr(r), p, len1) + return + } + Xmemcpy(tls, s+24+uintptr(r), p, uint64(uint32(64)-r)) + len1 = len1 - uint64(uint32(64)-r) + p = p + uintptr(uint32(64)-r) + _processblock(tls, s, s+24) + } + for { + if !(len1 >= uint64(64)) { + break + } + _processblock(tls, s, p) + goto _1 + _1: + ; + len1 = len1 - uint64(64) + p = p + uintptr(64) + } + Xmemcpy(tls, s+24, p, len1) +} + +/*- + * Copyright (c) 2003 Poul-Henning Kamp + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* key limit is not part of the original design, added for DoS protection */ + +var _b64 = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +func _to64(tls *TLS, s uintptr, u uint32, n int32) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + for { + n = n - 1 + v1 = n + if !(v1 >= 0) { + break + } + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = Int8FromUint8(_b64[u%uint32(64)]) + u = u / uint32(64) + } + return s +} + +func _md5crypt(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var i, klen, slen uint32 + var p, salt, v5 uintptr + var _ /* ctx at bp+0 */ Tmd5 + var _ /* md at bp+88 */ [16]uint8 + _, _, _, _, _, _ = i, klen, p, salt, slen, v5 + /* reject large keys */ + klen = uint32(Xstrnlen(tls, key, Uint64FromInt32(Int32FromInt32(KEY_MAX)+Int32FromInt32(1)))) + if klen > uint32(KEY_MAX) { + return uintptr(0) + } + /* setting: $1$salt$ (closing $ is optional) */ + if Xstrncmp(tls, setting, __ccgo_ts+143, uint64(3)) != 0 { + return uintptr(0) + } + salt = setting + uintptr(3) + i = uint32(0) + for { + if !(i < uint32(SALT_MAX) && **(**int8)(__ccgo_up(salt + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(salt + uintptr(i)))) != int32('$')) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + slen = i + /* md5(key salt key) */ + _md5_init(tls, bp) + _md5_update(tls, bp, key, uint64(klen)) + _md5_update(tls, bp, salt, uint64(slen)) + _md5_update(tls, bp, key, uint64(klen)) + _md5_sum(tls, bp, bp+88) + /* md5(key $1$ salt repeated-md weird-key[0]-0) */ + _md5_init(tls, bp) + _md5_update(tls, bp, key, uint64(klen)) + _md5_update(tls, bp, setting, uint64(uint32(3)+slen)) + i = klen + for { + if !(uint64(i) > uint64(16)) { + break + } + _md5_update(tls, bp, bp+88, uint64(16)) + goto _2 + _2: + ; + i = uint32(uint64(i) - Uint64FromInt64(16)) + } + _md5_update(tls, bp, bp+88, uint64(i)) + (**(**[16]uint8)(__ccgo_up(bp + 88)))[0] = uint8(0) + i = klen + for { + if !(i != 0) { + break + } + if i&uint32(1) != 0 { + _md5_update(tls, bp, bp+88, uint64(1)) + } else { + _md5_update(tls, bp, key, uint64(1)) + } + goto _3 + _3: + ; + i = i >> uint32(1) + } + _md5_sum(tls, bp, bp+88) + /* md = f(md, key, salt) iteration */ + i = uint32(0) + for { + if !(i < uint32(1000)) { + break + } + _md5_init(tls, bp) + if i%uint32(2) != 0 { + _md5_update(tls, bp, key, uint64(klen)) + } else { + _md5_update(tls, bp, bp+88, uint64(16)) + } + if i%uint32(3) != 0 { + _md5_update(tls, bp, salt, uint64(slen)) + } + if i%uint32(7) != 0 { + _md5_update(tls, bp, key, uint64(klen)) + } + if i%uint32(2) != 0 { + _md5_update(tls, bp, bp+88, uint64(16)) + } else { + _md5_update(tls, bp, key, uint64(klen)) + } + _md5_sum(tls, bp, bp+88) + goto _4 + _4: + ; + i = i + 1 + } + /* output is $1$salt$hash */ + Xmemcpy(tls, output, setting, uint64(uint32(3)+slen)) + p = output + uintptr(3) + uintptr(slen) + v5 = p + p = p + 1 + **(**int8)(__ccgo_up(v5)) = int8('$') + i = uint32(0) + for { + if !(i < uint32(5)) { + break + } + p = _to64(tls, p, Uint32FromInt32(Int32FromUint8((**(**[16]uint8)(__ccgo_up(bp + 88)))[**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_perm)) + uintptr(i)*3))])< %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var p, q uintptr + var _ /* testbuf at bp+0 */ [64]int8 + _, _ = p, q + p = _md5crypt(tls, key, setting, output) + /* self test and stack cleanup */ + q = _md5crypt(tls, uintptr(unsafe.Pointer(&_testkey)), uintptr(unsafe.Pointer(&_testsetting)), bp) + if !(p != 0) || q != bp || Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_testhash)), uint64(35)) != 0 { + return __ccgo_ts + 70 + } + return p +} + +var _testkey = [18]int8{'X', 'y', '0', '1', '@', '#', 1, 2, -128, 127, -1, 13, 10, -127, 9, ' ', '!'} + +var _testsetting = [13]int8{'$', '1', '$', 'a', 'b', 'c', 'd', '0', '1', '2', '3', '$'} + +var _testhash = [35]int8{'$', '1', '$', 'a', 'b', 'c', 'd', '0', '1', '2', '3', '$', '9', 'Q', 'c', 'g', '8', 'D', 'y', 'v', 'i', 'e', 'k', 'V', '3', 't', 'D', 'G', 'M', 'Z', 'y', 'n', 'J', '1'} + +func X__crypt_r(tls *TLS, key uintptr, salt uintptr, data uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v salt=%v data=%v, (%v:)", tls, key, salt, data, origin(2)) + defer func() { trc("-> %v", r) }() + } + var output uintptr + _ = output + /* Per the crypt_r API, the caller has provided a pointer to + * struct crypt_data; however, this implementation does not + * use the structure to store any internal state, and treats + * it purely as a char buffer for storing the result. */ + output = data + if int32(**(**int8)(__ccgo_up(salt))) == int32('$') && **(**int8)(__ccgo_up(salt + 1)) != 0 && **(**int8)(__ccgo_up(salt + 2)) != 0 { + if int32(**(**int8)(__ccgo_up(salt + 1))) == int32('1') && int32(**(**int8)(__ccgo_up(salt + 2))) == int32('$') { + return X__crypt_md5(tls, key, salt, output) + } + if int32(**(**int8)(__ccgo_up(salt + 1))) == int32('2') && int32(**(**int8)(__ccgo_up(salt + 3))) == int32('$') { + return X__crypt_blowfish(tls, key, salt, output) + } + if int32(**(**int8)(__ccgo_up(salt + 1))) == int32('5') && int32(**(**int8)(__ccgo_up(salt + 2))) == int32('$') { + return X__crypt_sha256(tls, key, salt, output) + } + if int32(**(**int8)(__ccgo_up(salt + 1))) == int32('6') && int32(**(**int8)(__ccgo_up(salt + 2))) == int32('$') { + return X__crypt_sha512(tls, key, salt, output) + } + } + return X__crypt_des(tls, key, salt, output) +} + +func Xcrypt_r(tls *TLS, key uintptr, salt uintptr, data uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v salt=%v data=%v, (%v:)", tls, key, salt, data, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__crypt_r(tls, key, salt, data) +} + +const KEY_MAX1 = 256 +const ROUNDS_DEFAULT = 5000 +const ROUNDS_MAX = 9999999 +const ROUNDS_MIN = 1000 +const SALT_MAX1 = 16 + +/* public domain sha256 implementation based on fips180-3 */ + +type Tsha256 = struct { + Flen1 Tuint64_t + Fh [8]Tuint32_t + Fbuf [64]Tuint8_t +} + +func _ror(tls *TLS, n Tuint32_t, k int32) (r Tuint32_t) { + return n>>k | n<<(Int32FromInt32(32)-k) +} + +var _K = [64]Tuint32_t{ + 0: uint32(0x428a2f98), + 1: uint32(0x71374491), + 2: uint32(0xb5c0fbcf), + 3: uint32(0xe9b5dba5), + 4: uint32(0x3956c25b), + 5: uint32(0x59f111f1), + 6: uint32(0x923f82a4), + 7: uint32(0xab1c5ed5), + 8: uint32(0xd807aa98), + 9: uint32(0x12835b01), + 10: uint32(0x243185be), + 11: uint32(0x550c7dc3), + 12: uint32(0x72be5d74), + 13: uint32(0x80deb1fe), + 14: uint32(0x9bdc06a7), + 15: uint32(0xc19bf174), + 16: uint32(0xe49b69c1), + 17: uint32(0xefbe4786), + 18: uint32(0x0fc19dc6), + 19: uint32(0x240ca1cc), + 20: uint32(0x2de92c6f), + 21: uint32(0x4a7484aa), + 22: uint32(0x5cb0a9dc), + 23: uint32(0x76f988da), + 24: uint32(0x983e5152), + 25: uint32(0xa831c66d), + 26: uint32(0xb00327c8), + 27: uint32(0xbf597fc7), + 28: uint32(0xc6e00bf3), + 29: uint32(0xd5a79147), + 30: uint32(0x06ca6351), + 31: uint32(0x14292967), + 32: uint32(0x27b70a85), + 33: uint32(0x2e1b2138), + 34: uint32(0x4d2c6dfc), + 35: uint32(0x53380d13), + 36: uint32(0x650a7354), + 37: uint32(0x766a0abb), + 38: uint32(0x81c2c92e), + 39: uint32(0x92722c85), + 40: uint32(0xa2bfe8a1), + 41: uint32(0xa81a664b), + 42: uint32(0xc24b8b70), + 43: uint32(0xc76c51a3), + 44: uint32(0xd192e819), + 45: uint32(0xd6990624), + 46: uint32(0xf40e3585), + 47: uint32(0x106aa070), + 48: uint32(0x19a4c116), + 49: uint32(0x1e376c08), + 50: uint32(0x2748774c), + 51: uint32(0x34b0bcb5), + 52: uint32(0x391c0cb3), + 53: uint32(0x4ed8aa4a), + 54: uint32(0x5b9cca4f), + 55: uint32(0x682e6ff3), + 56: uint32(0x748f82ee), + 57: uint32(0x78a5636f), + 58: uint32(0x84c87814), + 59: uint32(0x8cc70208), + 60: uint32(0x90befffa), + 61: uint32(0xa4506ceb), + 62: uint32(0xbef9a3f7), + 63: uint32(0xc67178f2), +} + +func _processblock1(tls *TLS, s uintptr, buf uintptr) { + bp := tls.Alloc(256) + defer tls.Free(256) + var a, b, c, d, e, f, g, h, t1, t2 Tuint32_t + var i int32 + var _ /* W at bp+0 */ [64]Tuint32_t + _, _, _, _, _, _, _, _, _, _, _ = a, b, c, d, e, f, g, h, i, t1, t2 + i = 0 + for { + if !(i < int32(16)) { + break + } + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i] = uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(4)*i)))) << int32(24) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(4)*i+int32(1))))) << int32(16) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(4)*i+int32(2))))) << int32(8) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(4)*i+int32(3))))) + goto _1 + _1: + ; + i = i + 1 + } + for { + if !(i < int32(64)) { + break + } + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i] = _ror(tls, (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(2)], int32(17)) ^ _ror(tls, (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(2)], int32(19)) ^ (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(2)]>>Int32FromInt32(10) + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(7)] + (_ror(tls, (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(15)], int32(7)) ^ _ror(tls, (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(15)], int32(18)) ^ (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(15)]>>Int32FromInt32(3)) + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(16)] + goto _2 + _2: + ; + i = i + 1 + } + a = **(**Tuint32_t)(__ccgo_up(s + 8)) + b = **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) + c = **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) + d = **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) + e = **(**Tuint32_t)(__ccgo_up(s + 8 + 4*4)) + f = **(**Tuint32_t)(__ccgo_up(s + 8 + 5*4)) + g = **(**Tuint32_t)(__ccgo_up(s + 8 + 6*4)) + h = **(**Tuint32_t)(__ccgo_up(s + 8 + 7*4)) + i = 0 + for { + if !(i < int32(64)) { + break + } + t1 = h + (_ror(tls, e, int32(6)) ^ _ror(tls, e, int32(11)) ^ _ror(tls, e, int32(25))) + (g ^ e&(f^g)) + _K[i] + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i] + t2 = _ror(tls, a, int32(2)) ^ _ror(tls, a, int32(13)) ^ _ror(tls, a, int32(22)) + (a&b | c&(a|b)) + h = g + g = f + f = e + e = d + t1 + d = c + c = b + b = a + a = t1 + t2 + goto _3 + _3: + ; + i = i + 1 + } + **(**Tuint32_t)(__ccgo_up(s + 8)) += a + **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) += b + **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) += c + **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) += d + **(**Tuint32_t)(__ccgo_up(s + 8 + 4*4)) += e + **(**Tuint32_t)(__ccgo_up(s + 8 + 5*4)) += f + **(**Tuint32_t)(__ccgo_up(s + 8 + 6*4)) += g + **(**Tuint32_t)(__ccgo_up(s + 8 + 7*4)) += h +} + +func _pad1(tls *TLS, s uintptr) { + var r, v1 uint32 + _, _ = r, v1 + r = uint32((*Tsha256)(unsafe.Pointer(s)).Flen1 % uint64(64)) + v1 = r + r = r + 1 + **(**Tuint8_t)(__ccgo_up(s + 40 + uintptr(v1))) = uint8(0x80) + if r > uint32(56) { + Xmemset(tls, s+40+uintptr(r), 0, uint64(uint32(64)-r)) + r = uint32(0) + _processblock1(tls, s, s+40) + } + Xmemset(tls, s+40+uintptr(r), 0, uint64(uint32(56)-r)) + **(**Tuint64_t)(__ccgo_up(s)) *= uint64(8) + **(**Tuint8_t)(__ccgo_up(s + 40 + 56)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(56)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 57)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(48)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 58)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(40)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 59)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(32)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 60)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(24)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 61)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(16)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 62)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(8)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 63)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1) + _processblock1(tls, s, s+40) +} + +func _sha256_init(tls *TLS, s uintptr) { + (*Tsha256)(unsafe.Pointer(s)).Flen1 = uint64(0) + **(**Tuint32_t)(__ccgo_up(s + 8)) = uint32(0x6a09e667) + **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) = uint32(0xbb67ae85) + **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) = uint32(0x3c6ef372) + **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) = uint32(0xa54ff53a) + **(**Tuint32_t)(__ccgo_up(s + 8 + 4*4)) = uint32(0x510e527f) + **(**Tuint32_t)(__ccgo_up(s + 8 + 5*4)) = uint32(0x9b05688c) + **(**Tuint32_t)(__ccgo_up(s + 8 + 6*4)) = uint32(0x1f83d9ab) + **(**Tuint32_t)(__ccgo_up(s + 8 + 7*4)) = uint32(0x5be0cd19) +} + +func _sha256_sum(tls *TLS, s uintptr, md uintptr) { + var i int32 + _ = i + _pad1(tls, s) + i = 0 + for { + if !(i < int32(8)) { + break + } + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(24)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(1)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(16)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(2)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(8)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(3)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4))) + goto _1 + _1: + ; + i = i + 1 + } +} + +func _sha256_update(tls *TLS, s uintptr, m uintptr, len1 uint64) { + var p uintptr + var r uint32 + _, _ = p, r + p = m + r = uint32((*Tsha256)(unsafe.Pointer(s)).Flen1 % uint64(64)) + **(**Tuint64_t)(__ccgo_up(s)) += len1 + if r != 0 { + if len1 < uint64(uint32(64)-r) { + Xmemcpy(tls, s+40+uintptr(r), p, len1) + return + } + Xmemcpy(tls, s+40+uintptr(r), p, uint64(uint32(64)-r)) + len1 = len1 - uint64(uint32(64)-r) + p = p + uintptr(uint32(64)-r) + _processblock1(tls, s, s+40) + } + for { + if !(len1 >= uint64(64)) { + break + } + _processblock1(tls, s, p) + goto _1 + _1: + ; + len1 = len1 - uint64(64) + p = p + uintptr(64) + } + Xmemcpy(tls, s+40, p, len1) +} + +var _b641 = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +func _to641(tls *TLS, s uintptr, u uint32, n int32) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + for { + n = n - 1 + v1 = n + if !(v1 >= 0) { + break + } + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = Int8FromUint8(_b641[u%uint32(64)]) + u = u / uint32(64) + } + return s +} + +/* key limit is not part of the original design, added for DoS protection. + * rounds limit has been lowered (versus the reference/spec), also for DoS + * protection. runtime is O(klen^2 + klen*rounds) */ + +// C documentation +// +// /* hash n bytes of the repeated md message digest */ +func _hashmd(tls *TLS, s uintptr, n uint32, md uintptr) { + var i uint32 + _ = i + i = n + for { + if !(i > uint32(32)) { + break + } + _sha256_update(tls, s, md, uint64(32)) + goto _1 + _1: + ; + i = i - uint32(32) + } + _sha256_update(tls, s, md, uint64(i)) +} + +func _sha256crypt(tls *TLS, key uintptr, setting uintptr, output uintptr) (r1 uintptr) { + bp := tls.Alloc(272) + defer tls.Free(272) + var i, klen, r, slen uint32 + var p, salt uintptr + var u uint64 + var _ /* ctx at bp+0 */ Tsha256 + var _ /* end at bp+224 */ uintptr + var _ /* kmd at bp+136 */ [32]uint8 + var _ /* md at bp+104 */ [32]uint8 + var _ /* rounds at bp+200 */ [20]int8 + var _ /* smd at bp+168 */ [32]uint8 + _, _, _, _, _, _, _ = i, klen, p, r, salt, slen, u + **(**[20]int8)(__ccgo_up(bp + 200)) = [20]int8{} + /* reject large keys */ + klen = uint32(Xstrnlen(tls, key, Uint64FromInt32(Int32FromInt32(KEY_MAX1)+Int32FromInt32(1)))) + if klen > uint32(KEY_MAX1) { + return uintptr(0) + } + /* setting: $5$rounds=n$salt$ (rounds=n$ and closing $ are optional) */ + if Xstrncmp(tls, setting, __ccgo_ts+147, uint64(3)) != 0 { + return uintptr(0) + } + salt = setting + uintptr(3) + r = uint32(ROUNDS_DEFAULT) + if Xstrncmp(tls, salt, __ccgo_ts+151, Uint64FromInt64(8)-Uint64FromInt32(1)) == 0 { + /* + * this is a deviation from the reference: + * bad rounds setting is rejected if it is + * - empty + * - unterminated (missing '$') + * - begins with anything but a decimal digit + * the reference implementation treats these bad + * rounds as part of the salt or parse them with + * strtoul semantics which may cause problems + * including non-portable hashes that depend on + * the host's value of ULONG_MAX. + */ + salt = salt + uintptr(Uint64FromInt64(8)-Uint64FromInt32(1)) + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(salt)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return uintptr(0) + } + u = Xstrtoul(tls, salt, bp+224, int32(10)) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 224))))) != int32('$') { + return uintptr(0) + } + salt = **(**uintptr)(__ccgo_up(bp + 224)) + uintptr(1) + if u < uint64(ROUNDS_MIN) { + r = uint32(ROUNDS_MIN) + } else { + if u > uint64(ROUNDS_MAX) { + return uintptr(0) + } else { + r = uint32(u) + } + } + /* needed when rounds is zero prefixed or out of bounds */ + Xsprintf(tls, bp+200, __ccgo_ts+159, VaList(bp+240, r)) + } + i = uint32(0) + for { + if !(i < uint32(SALT_MAX1) && **(**int8)(__ccgo_up(salt + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(salt + uintptr(i)))) != int32('$')) { + break + } + /* reject characters that interfere with /etc/shadow parsing */ + if int32(**(**int8)(__ccgo_up(salt + uintptr(i)))) == int32('\n') || int32(**(**int8)(__ccgo_up(salt + uintptr(i)))) == int32(':') { + return uintptr(0) + } + goto _1 + _1: + ; + i = i + 1 + } + slen = i + /* B = sha(key salt key) */ + _sha256_init(tls, bp) + _sha256_update(tls, bp, key, uint64(klen)) + _sha256_update(tls, bp, salt, uint64(slen)) + _sha256_update(tls, bp, key, uint64(klen)) + _sha256_sum(tls, bp, bp+104) + /* A = sha(key salt repeat-B alternate-B-key) */ + _sha256_init(tls, bp) + _sha256_update(tls, bp, key, uint64(klen)) + _sha256_update(tls, bp, salt, uint64(slen)) + _hashmd(tls, bp, klen, bp+104) + i = klen + for { + if !(i > uint32(0)) { + break + } + if i&uint32(1) != 0 { + _sha256_update(tls, bp, bp+104, uint64(32)) + } else { + _sha256_update(tls, bp, key, uint64(klen)) + } + goto _2 + _2: + ; + i = i >> uint32(1) + } + _sha256_sum(tls, bp, bp+104) + /* DP = sha(repeat-key), this step takes O(klen^2) time */ + _sha256_init(tls, bp) + i = uint32(0) + for { + if !(i < klen) { + break + } + _sha256_update(tls, bp, key, uint64(klen)) + goto _3 + _3: + ; + i = i + 1 + } + _sha256_sum(tls, bp, bp+136) + /* DS = sha(repeat-salt) */ + _sha256_init(tls, bp) + i = uint32(0) + for { + if !(i < Uint32FromInt32(int32(16)+Int32FromUint8((**(**[32]uint8)(__ccgo_up(bp + 104)))[0]))) { + break + } + _sha256_update(tls, bp, salt, uint64(slen)) + goto _4 + _4: + ; + i = i + 1 + } + _sha256_sum(tls, bp, bp+168) + /* iterate A = f(A,DP,DS), this step takes O(rounds*klen) time */ + i = uint32(0) + for { + if !(i < r) { + break + } + _sha256_init(tls, bp) + if i%uint32(2) != 0 { + _hashmd(tls, bp, klen, bp+136) + } else { + _sha256_update(tls, bp, bp+104, uint64(32)) + } + if i%uint32(3) != 0 { + _sha256_update(tls, bp, bp+168, uint64(slen)) + } + if i%uint32(7) != 0 { + _hashmd(tls, bp, klen, bp+136) + } + if i%uint32(2) != 0 { + _sha256_update(tls, bp, bp+104, uint64(32)) + } else { + _hashmd(tls, bp, klen, bp+136) + } + _sha256_sum(tls, bp, bp+104) + goto _5 + _5: + ; + i = i + 1 + } + /* output is $5$rounds=n$salt$hash */ + p = output + p = p + uintptr(Xsprintf(tls, p, __ccgo_ts+170, VaList(bp+240, bp+200, slen, salt))) + i = uint32(0) + for { + if !(i < uint32(10)) { + break + } + p = _to641(tls, p, Uint32FromInt32(Int32FromUint8((**(**[32]uint8)(__ccgo_up(bp + 104)))[**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_perm1)) + uintptr(i)*3))])< %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var p, q uintptr + var _ /* testbuf at bp+0 */ [128]int8 + _, _ = p, q + p = _sha256crypt(tls, key, setting, output) + /* self test and stack cleanup */ + q = _sha256crypt(tls, uintptr(unsafe.Pointer(&_testkey1)), uintptr(unsafe.Pointer(&_testsetting1)), bp) + if !(p != 0) || q != bp || Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_testhash1)), uint64(73)) != 0 { + return __ccgo_ts + 70 + } + return p +} + +var _testkey1 = [18]int8{'X', 'y', '0', '1', '@', '#', 1, 2, -128, 127, -1, 13, 10, -127, 9, ' ', '!'} + +var _testsetting1 = [30]int8{'$', '5', '$', 'r', 'o', 'u', 'n', 'd', 's', '=', '1', '2', '3', '4', '$', 'a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '$'} + +var _testhash1 = [73]int8{'$', '5', '$', 'r', 'o', 'u', 'n', 'd', 's', '=', '1', '2', '3', '4', '$', 'a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '$', '3', 'V', 'f', 'D', 'j', 'P', 't', '0', '5', 'V', 'H', 'F', 'n', '4', '7', 'C', '/', 'o', 'j', 'F', 'Z', '6', 'K', 'R', 'P', 'Y', 'r', 'O', 'j', 'j', '1', 'l', 'L', 'b', 'H', '.', 'd', 'k', 'F', '3', 'b', 'Z', '6'} + +/* public domain sha512 implementation based on fips180-3 */ +/* >=2^64 bits messages are not supported (about 2000 peta bytes) */ + +type Tsha512 = struct { + Flen1 Tuint64_t + Fh [8]Tuint64_t + Fbuf [128]Tuint8_t +} + +func _ror1(tls *TLS, n Tuint64_t, k int32) (r Tuint64_t) { + return n>>k | n<<(Int32FromInt32(64)-k) +} + +var _K1 = [80]Tuint64_t{ + 0: uint64(0x428a2f98d728ae22), + 1: uint64(0x7137449123ef65cd), + 2: uint64(0xb5c0fbcfec4d3b2f), + 3: uint64(0xe9b5dba58189dbbc), + 4: uint64(0x3956c25bf348b538), + 5: uint64(0x59f111f1b605d019), + 6: uint64(0x923f82a4af194f9b), + 7: uint64(0xab1c5ed5da6d8118), + 8: uint64(0xd807aa98a3030242), + 9: uint64(0x12835b0145706fbe), + 10: uint64(0x243185be4ee4b28c), + 11: uint64(0x550c7dc3d5ffb4e2), + 12: uint64(0x72be5d74f27b896f), + 13: uint64(0x80deb1fe3b1696b1), + 14: uint64(0x9bdc06a725c71235), + 15: uint64(0xc19bf174cf692694), + 16: uint64(0xe49b69c19ef14ad2), + 17: uint64(0xefbe4786384f25e3), + 18: uint64(0x0fc19dc68b8cd5b5), + 19: uint64(0x240ca1cc77ac9c65), + 20: uint64(0x2de92c6f592b0275), + 21: uint64(0x4a7484aa6ea6e483), + 22: uint64(0x5cb0a9dcbd41fbd4), + 23: uint64(0x76f988da831153b5), + 24: uint64(0x983e5152ee66dfab), + 25: uint64(0xa831c66d2db43210), + 26: uint64(0xb00327c898fb213f), + 27: uint64(0xbf597fc7beef0ee4), + 28: uint64(0xc6e00bf33da88fc2), + 29: uint64(0xd5a79147930aa725), + 30: uint64(0x06ca6351e003826f), + 31: uint64(0x142929670a0e6e70), + 32: uint64(0x27b70a8546d22ffc), + 33: uint64(0x2e1b21385c26c926), + 34: uint64(0x4d2c6dfc5ac42aed), + 35: uint64(0x53380d139d95b3df), + 36: uint64(0x650a73548baf63de), + 37: uint64(0x766a0abb3c77b2a8), + 38: uint64(0x81c2c92e47edaee6), + 39: uint64(0x92722c851482353b), + 40: uint64(0xa2bfe8a14cf10364), + 41: uint64(0xa81a664bbc423001), + 42: uint64(0xc24b8b70d0f89791), + 43: uint64(0xc76c51a30654be30), + 44: uint64(0xd192e819d6ef5218), + 45: uint64(0xd69906245565a910), + 46: uint64(0xf40e35855771202a), + 47: uint64(0x106aa07032bbd1b8), + 48: uint64(0x19a4c116b8d2d0c8), + 49: uint64(0x1e376c085141ab53), + 50: uint64(0x2748774cdf8eeb99), + 51: uint64(0x34b0bcb5e19b48a8), + 52: uint64(0x391c0cb3c5c95a63), + 53: uint64(0x4ed8aa4ae3418acb), + 54: uint64(0x5b9cca4f7763e373), + 55: uint64(0x682e6ff3d6b2b8a3), + 56: uint64(0x748f82ee5defb2fc), + 57: uint64(0x78a5636f43172f60), + 58: uint64(0x84c87814a1f0ab72), + 59: uint64(0x8cc702081a6439ec), + 60: uint64(0x90befffa23631e28), + 61: uint64(0xa4506cebde82bde9), + 62: uint64(0xbef9a3f7b2c67915), + 63: uint64(0xc67178f2e372532b), + 64: uint64(0xca273eceea26619c), + 65: uint64(0xd186b8c721c0c207), + 66: uint64(0xeada7dd6cde0eb1e), + 67: uint64(0xf57d4f7fee6ed178), + 68: uint64(0x06f067aa72176fba), + 69: uint64(0x0a637dc5a2c898a6), + 70: uint64(0x113f9804bef90dae), + 71: uint64(0x1b710b35131c471b), + 72: uint64(0x28db77f523047d84), + 73: uint64(0x32caab7b40c72493), + 74: uint64(0x3c9ebe0a15c9bebc), + 75: uint64(0x431d67c49c100d4c), + 76: uint64(0x4cc5d4becb3e42b6), + 77: uint64(0x597f299cfc657e2a), + 78: uint64(0x5fcb6fab3ad6faec), + 79: uint64(0x6c44198c4a475817), +} + +func _processblock2(tls *TLS, s uintptr, buf uintptr) { + bp := tls.Alloc(640) + defer tls.Free(640) + var a, b, c, d, e, f, g, h, t1, t2 Tuint64_t + var i int32 + var _ /* W at bp+0 */ [80]Tuint64_t + _, _, _, _, _, _, _, _, _, _, _ = a, b, c, d, e, f, g, h, i, t1, t2 + i = 0 + for { + if !(i < int32(16)) { + break + } + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i] = uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i)))) << int32(56) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(1))))) << int32(48) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(2))))) << int32(40) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(3))))) << int32(32) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(4))))) << int32(24) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(5))))) << int32(16) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(6))))) << int32(8) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(7))))) + goto _1 + _1: + ; + i = i + 1 + } + for { + if !(i < int32(80)) { + break + } + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i] = _ror1(tls, (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(2)], int32(19)) ^ _ror1(tls, (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(2)], int32(61)) ^ (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(2)]>>Int32FromInt32(6) + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(7)] + (_ror1(tls, (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(15)], int32(1)) ^ _ror1(tls, (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(15)], int32(8)) ^ (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(15)]>>Int32FromInt32(7)) + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(16)] + goto _2 + _2: + ; + i = i + 1 + } + a = **(**Tuint64_t)(__ccgo_up(s + 8)) + b = **(**Tuint64_t)(__ccgo_up(s + 8 + 1*8)) + c = **(**Tuint64_t)(__ccgo_up(s + 8 + 2*8)) + d = **(**Tuint64_t)(__ccgo_up(s + 8 + 3*8)) + e = **(**Tuint64_t)(__ccgo_up(s + 8 + 4*8)) + f = **(**Tuint64_t)(__ccgo_up(s + 8 + 5*8)) + g = **(**Tuint64_t)(__ccgo_up(s + 8 + 6*8)) + h = **(**Tuint64_t)(__ccgo_up(s + 8 + 7*8)) + i = 0 + for { + if !(i < int32(80)) { + break + } + t1 = h + (_ror1(tls, e, int32(14)) ^ _ror1(tls, e, int32(18)) ^ _ror1(tls, e, int32(41))) + (g ^ e&(f^g)) + _K1[i] + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i] + t2 = _ror1(tls, a, int32(28)) ^ _ror1(tls, a, int32(34)) ^ _ror1(tls, a, int32(39)) + (a&b | c&(a|b)) + h = g + g = f + f = e + e = d + t1 + d = c + c = b + b = a + a = t1 + t2 + goto _3 + _3: + ; + i = i + 1 + } + **(**Tuint64_t)(__ccgo_up(s + 8)) += a + **(**Tuint64_t)(__ccgo_up(s + 8 + 1*8)) += b + **(**Tuint64_t)(__ccgo_up(s + 8 + 2*8)) += c + **(**Tuint64_t)(__ccgo_up(s + 8 + 3*8)) += d + **(**Tuint64_t)(__ccgo_up(s + 8 + 4*8)) += e + **(**Tuint64_t)(__ccgo_up(s + 8 + 5*8)) += f + **(**Tuint64_t)(__ccgo_up(s + 8 + 6*8)) += g + **(**Tuint64_t)(__ccgo_up(s + 8 + 7*8)) += h +} + +func _pad2(tls *TLS, s uintptr) { + var r, v1 uint32 + _, _ = r, v1 + r = uint32((*Tsha512)(unsafe.Pointer(s)).Flen1 % uint64(128)) + v1 = r + r = r + 1 + **(**Tuint8_t)(__ccgo_up(s + 72 + uintptr(v1))) = uint8(0x80) + if r > uint32(112) { + Xmemset(tls, s+72+uintptr(r), 0, uint64(uint32(128)-r)) + r = uint32(0) + _processblock2(tls, s, s+72) + } + Xmemset(tls, s+72+uintptr(r), 0, uint64(uint32(120)-r)) + **(**Tuint64_t)(__ccgo_up(s)) *= uint64(8) + **(**Tuint8_t)(__ccgo_up(s + 72 + 120)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(56)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 121)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(48)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 122)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(40)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 123)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(32)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 124)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(24)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 125)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(16)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 126)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(8)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 127)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1) + _processblock2(tls, s, s+72) +} + +func _sha512_init(tls *TLS, s uintptr) { + (*Tsha512)(unsafe.Pointer(s)).Flen1 = uint64(0) + **(**Tuint64_t)(__ccgo_up(s + 8)) = uint64(0x6a09e667f3bcc908) + **(**Tuint64_t)(__ccgo_up(s + 8 + 1*8)) = uint64(0xbb67ae8584caa73b) + **(**Tuint64_t)(__ccgo_up(s + 8 + 2*8)) = uint64(0x3c6ef372fe94f82b) + **(**Tuint64_t)(__ccgo_up(s + 8 + 3*8)) = uint64(0xa54ff53a5f1d36f1) + **(**Tuint64_t)(__ccgo_up(s + 8 + 4*8)) = uint64(0x510e527fade682d1) + **(**Tuint64_t)(__ccgo_up(s + 8 + 5*8)) = uint64(0x9b05688c2b3e6c1f) + **(**Tuint64_t)(__ccgo_up(s + 8 + 6*8)) = uint64(0x1f83d9abfb41bd6b) + **(**Tuint64_t)(__ccgo_up(s + 8 + 7*8)) = uint64(0x5be0cd19137e2179) +} + +func _sha512_sum(tls *TLS, s uintptr, md uintptr) { + var i int32 + _ = i + _pad2(tls, s) + i = 0 + for { + if !(i < int32(8)) { + break + } + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(56)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(1)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(48)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(2)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(40)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(3)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(32)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(4)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(24)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(5)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(16)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(6)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(8)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(7)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } +} + +func _sha512_update(tls *TLS, s uintptr, m uintptr, len1 uint64) { + var p uintptr + var r uint32 + _, _ = p, r + p = m + r = uint32((*Tsha512)(unsafe.Pointer(s)).Flen1 % uint64(128)) + **(**Tuint64_t)(__ccgo_up(s)) += len1 + if r != 0 { + if len1 < uint64(uint32(128)-r) { + Xmemcpy(tls, s+72+uintptr(r), p, len1) + return + } + Xmemcpy(tls, s+72+uintptr(r), p, uint64(uint32(128)-r)) + len1 = len1 - uint64(uint32(128)-r) + p = p + uintptr(uint32(128)-r) + _processblock2(tls, s, s+72) + } + for { + if !(len1 >= uint64(128)) { + break + } + _processblock2(tls, s, p) + goto _1 + _1: + ; + len1 = len1 - uint64(128) + p = p + uintptr(128) + } + Xmemcpy(tls, s+72, p, len1) +} + +var _b642 = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +func _to642(tls *TLS, s uintptr, u uint32, n int32) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + for { + n = n - 1 + v1 = n + if !(v1 >= 0) { + break + } + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = Int8FromUint8(_b642[u%uint32(64)]) + u = u / uint32(64) + } + return s +} + +/* key limit is not part of the original design, added for DoS protection. + * rounds limit has been lowered (versus the reference/spec), also for DoS + * protection. runtime is O(klen^2 + klen*rounds) */ + +// C documentation +// +// /* hash n bytes of the repeated md message digest */ +func _hashmd1(tls *TLS, s uintptr, n uint32, md uintptr) { + var i uint32 + _ = i + i = n + for { + if !(i > uint32(64)) { + break + } + _sha512_update(tls, s, md, uint64(64)) + goto _1 + _1: + ; + i = i - uint32(64) + } + _sha512_update(tls, s, md, uint64(i)) +} + +func _sha512crypt(tls *TLS, key uintptr, setting uintptr, output uintptr) (r1 uintptr) { + bp := tls.Alloc(464) + defer tls.Free(464) + var i, klen, r, slen uint32 + var p, salt uintptr + var u uint64 + var _ /* ctx at bp+0 */ Tsha512 + var _ /* end at bp+416 */ uintptr + var _ /* kmd at bp+264 */ [64]uint8 + var _ /* md at bp+200 */ [64]uint8 + var _ /* rounds at bp+392 */ [20]int8 + var _ /* smd at bp+328 */ [64]uint8 + _, _, _, _, _, _, _ = i, klen, p, r, salt, slen, u + **(**[20]int8)(__ccgo_up(bp + 392)) = [20]int8{} + /* reject large keys */ + i = uint32(0) + for { + if !(i <= uint32(KEY_MAX1) && **(**int8)(__ccgo_up(key + uintptr(i))) != 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i > uint32(KEY_MAX1) { + return uintptr(0) + } + klen = i + /* setting: $6$rounds=n$salt$ (rounds=n$ and closing $ are optional) */ + if Xstrncmp(tls, setting, __ccgo_ts+181, uint64(3)) != 0 { + return uintptr(0) + } + salt = setting + uintptr(3) + r = uint32(ROUNDS_DEFAULT) + if Xstrncmp(tls, salt, __ccgo_ts+151, Uint64FromInt64(8)-Uint64FromInt32(1)) == 0 { + /* + * this is a deviation from the reference: + * bad rounds setting is rejected if it is + * - empty + * - unterminated (missing '$') + * - begins with anything but a decimal digit + * the reference implementation treats these bad + * rounds as part of the salt or parse them with + * strtoul semantics which may cause problems + * including non-portable hashes that depend on + * the host's value of ULONG_MAX. + */ + salt = salt + uintptr(Uint64FromInt64(8)-Uint64FromInt32(1)) + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(salt)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return uintptr(0) + } + u = Xstrtoul(tls, salt, bp+416, int32(10)) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 416))))) != int32('$') { + return uintptr(0) + } + salt = **(**uintptr)(__ccgo_up(bp + 416)) + uintptr(1) + if u < uint64(ROUNDS_MIN) { + r = uint32(ROUNDS_MIN) + } else { + if u > uint64(ROUNDS_MAX) { + return uintptr(0) + } else { + r = uint32(u) + } + } + /* needed when rounds is zero prefixed or out of bounds */ + Xsprintf(tls, bp+392, __ccgo_ts+159, VaList(bp+432, r)) + } + i = uint32(0) + for { + if !(i < uint32(SALT_MAX1) && **(**int8)(__ccgo_up(salt + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(salt + uintptr(i)))) != int32('$')) { + break + } + /* reject characters that interfere with /etc/shadow parsing */ + if int32(**(**int8)(__ccgo_up(salt + uintptr(i)))) == int32('\n') || int32(**(**int8)(__ccgo_up(salt + uintptr(i)))) == int32(':') { + return uintptr(0) + } + goto _2 + _2: + ; + i = i + 1 + } + slen = i + /* B = sha(key salt key) */ + _sha512_init(tls, bp) + _sha512_update(tls, bp, key, uint64(klen)) + _sha512_update(tls, bp, salt, uint64(slen)) + _sha512_update(tls, bp, key, uint64(klen)) + _sha512_sum(tls, bp, bp+200) + /* A = sha(key salt repeat-B alternate-B-key) */ + _sha512_init(tls, bp) + _sha512_update(tls, bp, key, uint64(klen)) + _sha512_update(tls, bp, salt, uint64(slen)) + _hashmd1(tls, bp, klen, bp+200) + i = klen + for { + if !(i > uint32(0)) { + break + } + if i&uint32(1) != 0 { + _sha512_update(tls, bp, bp+200, uint64(64)) + } else { + _sha512_update(tls, bp, key, uint64(klen)) + } + goto _3 + _3: + ; + i = i >> uint32(1) + } + _sha512_sum(tls, bp, bp+200) + /* DP = sha(repeat-key), this step takes O(klen^2) time */ + _sha512_init(tls, bp) + i = uint32(0) + for { + if !(i < klen) { + break + } + _sha512_update(tls, bp, key, uint64(klen)) + goto _4 + _4: + ; + i = i + 1 + } + _sha512_sum(tls, bp, bp+264) + /* DS = sha(repeat-salt) */ + _sha512_init(tls, bp) + i = uint32(0) + for { + if !(i < Uint32FromInt32(int32(16)+Int32FromUint8((**(**[64]uint8)(__ccgo_up(bp + 200)))[0]))) { + break + } + _sha512_update(tls, bp, salt, uint64(slen)) + goto _5 + _5: + ; + i = i + 1 + } + _sha512_sum(tls, bp, bp+328) + /* iterate A = f(A,DP,DS), this step takes O(rounds*klen) time */ + i = uint32(0) + for { + if !(i < r) { + break + } + _sha512_init(tls, bp) + if i%uint32(2) != 0 { + _hashmd1(tls, bp, klen, bp+264) + } else { + _sha512_update(tls, bp, bp+200, uint64(64)) + } + if i%uint32(3) != 0 { + _sha512_update(tls, bp, bp+328, uint64(slen)) + } + if i%uint32(7) != 0 { + _hashmd1(tls, bp, klen, bp+264) + } + if i%uint32(2) != 0 { + _sha512_update(tls, bp, bp+200, uint64(64)) + } else { + _hashmd1(tls, bp, klen, bp+264) + } + _sha512_sum(tls, bp, bp+200) + goto _6 + _6: + ; + i = i + 1 + } + /* output is $6$rounds=n$salt$hash */ + p = output + p = p + uintptr(Xsprintf(tls, p, __ccgo_ts+185, VaList(bp+432, bp+392, slen, salt))) + i = uint32(0) + for { + if !(i < uint32(21)) { + break + } + p = _to642(tls, p, Uint32FromInt32(Int32FromUint8((**(**[64]uint8)(__ccgo_up(bp + 200)))[**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_perm2)) + uintptr(i)*3))])< %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var p, q uintptr + var _ /* testbuf at bp+0 */ [128]int8 + _, _ = p, q + p = _sha512crypt(tls, key, setting, output) + /* self test and stack cleanup */ + q = _sha512crypt(tls, uintptr(unsafe.Pointer(&_testkey2)), uintptr(unsafe.Pointer(&_testsetting2)), bp) + if !(p != 0) || q != bp || Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_testhash2)), uint64(116)) != 0 { + return __ccgo_ts + 70 + } + return p +} + +var _testkey2 = [18]int8{'X', 'y', '0', '1', '@', '#', 1, 2, -128, 127, -1, 13, 10, -127, 9, ' ', '!'} + +var _testsetting2 = [30]int8{'$', '6', '$', 'r', 'o', 'u', 'n', 'd', 's', '=', '1', '2', '3', '4', '$', 'a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '$'} + +var _testhash2 = [116]int8{'$', '6', '$', 'r', 'o', 'u', 'n', 'd', 's', '=', '1', '2', '3', '4', '$', 'a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '$', 'B', 'C', 'p', 't', '8', 'z', 'L', 'r', 'c', '/', 'R', 'c', 'y', 'u', 'X', 'm', 'C', 'D', 'O', 'E', '1', 'A', 'L', 'q', 'M', 'X', 'B', '2', 'M', 'H', '6', 'n', '1', 'g', '8', '9', '1', 'H', 'h', 'F', 'j', '8', '.', 'w', '7', 'L', 'x', 'G', 'v', '.', 'F', 'T', 'k', 'q', 'q', '6', 'V', 'x', 'c', '/', 'k', 'm', '3', 'Y', '0', 'j', 'E', '0', 'j', '2', '4', 'j', 'Y', '5', 'P', 'I', 'v', '/', 'o', 'O', 'u', '6', 'r', 'e', 'g', '1'} + +var ___encrypt_key Texpanded_key + +func Xsetkey(tls *TLS, key uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v, (%v:)", tls, key, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j int32 + var v3 uintptr + var _ /* bkey at bp+0 */ [8]uint8 + _, _, _ = i, j, v3 + i = 0 + for { + if !(i < int32(8)) { + break + } + (**(**[8]uint8)(__ccgo_up(bp)))[i] = uint8(0) + j = int32(7) + for { + if !(j >= 0) { + break + } + v3 = bp + uintptr(i) + *(*uint8)(unsafe.Pointer(v3)) = uint8(uint32(*(*uint8)(unsafe.Pointer(v3))) | Uint32FromInt32(int32(**(**int8)(__ccgo_up(key)))&Int32FromInt32(1))<= 0) { + break + } + **(**Tuint32_t)(__ccgo_up(bp + 128 + uintptr(i)*4)) |= Uint32FromInt32(int32(**(**int8)(__ccgo_up(p)))&Int32FromInt32(1)) << j + goto _2 + _2: + ; + j = j - 1 + p = p + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + key = uintptr(unsafe.Pointer(&___encrypt_key)) + if edflag != 0 { + key = bp + i = 0 + for { + if !(i < int32(16)) { + break + } + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) = **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&___encrypt_key)) + uintptr(int32(15)-i)*4)) + **(**Tuint32_t)(__ccgo_up(bp + 64 + uintptr(i)*4)) = **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&___encrypt_key)) + 64 + uintptr(int32(15)-i)*4)) + goto _3 + _3: + ; + i = i + 1 + } + } + X__do_des(tls, (**(**[2]Tuint32_t)(__ccgo_up(bp + 128)))[0], (**(**[2]Tuint32_t)(__ccgo_up(bp + 128)))[int32(1)], bp+128, bp+128+uintptr(1)*4, uint32(1), uint32(0), key) + p = block + i = 0 + for { + if !(i < int32(2)) { + break + } + j = int32(31) + for { + if !(j >= 0) { + break + } + v6 = p + p = p + 1 + **(**int8)(__ccgo_up(v6)) = Int8FromUint32((**(**[2]Tuint32_t)(__ccgo_up(bp + 128)))[i] >> j & uint32(1)) + goto _5 + _5: + ; + j = j - 1 + } + goto _4 + _4: + ; + i = i + 1 + } +} + +var _table = [384]uint16{ + 128: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 129: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 130: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 131: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 132: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 133: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 134: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 135: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 136: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 137: Uint16FromInt32((Int32FromInt32(0x320)/Int32FromInt32(256) | Int32FromInt32(0x320)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 138: Uint16FromInt32((Int32FromInt32(0x220)/Int32FromInt32(256) | Int32FromInt32(0x220)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 139: Uint16FromInt32((Int32FromInt32(0x220)/Int32FromInt32(256) | Int32FromInt32(0x220)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 140: Uint16FromInt32((Int32FromInt32(0x220)/Int32FromInt32(256) | Int32FromInt32(0x220)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 141: Uint16FromInt32((Int32FromInt32(0x220)/Int32FromInt32(256) | Int32FromInt32(0x220)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 142: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 143: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 144: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 145: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 146: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 147: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 148: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 149: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 150: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 151: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 152: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 153: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 154: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 155: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 156: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 157: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 158: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 159: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 160: Uint16FromInt32((Int32FromInt32(0x160)/Int32FromInt32(256) | Int32FromInt32(0x160)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 161: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 162: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 163: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 164: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 165: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 166: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 167: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 168: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 169: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 170: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 171: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 172: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 173: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 174: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 175: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 176: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 177: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 178: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 179: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 180: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 181: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 182: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 183: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 184: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 185: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 186: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 187: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 188: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 189: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 190: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 191: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 192: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 193: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 194: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 195: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 196: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 197: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 198: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 199: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 200: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 201: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 202: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 203: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 204: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 205: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 206: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 207: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 208: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 209: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 210: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 211: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 212: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 213: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 214: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 215: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 216: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 217: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 218: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 219: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 220: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 221: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 222: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 223: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 224: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 225: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 226: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 227: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 228: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 229: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 230: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 231: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 232: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 233: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 234: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 235: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 236: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 237: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 238: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 239: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 240: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 241: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 242: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 243: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 244: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 245: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 246: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 247: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 248: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 249: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 250: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 251: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 252: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 253: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 254: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 255: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), +} + +var _ptable = uintptr(unsafe.Pointer(&_table)) + uintptr(128)*2 + +func X__ctype_b_loc(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_ptable)) +} + +const CLOCKS_PER_SEC = 1000000 +const CLOCK_BOOTTIME = 7 +const CLOCK_BOOTTIME_ALARM = 9 +const CLOCK_MONOTONIC = 1 +const CLOCK_MONOTONIC_COARSE = 6 +const CLOCK_MONOTONIC_RAW = 4 +const CLOCK_PROCESS_CPUTIME_ID = 2 +const CLOCK_REALTIME = 0 +const CLOCK_REALTIME_ALARM = 8 +const CLOCK_REALTIME_COARSE = 5 +const CLOCK_SGI_CYCLE = 10 +const CLOCK_TAI = 11 +const CLOCK_THREAD_CPUTIME_ID = 3 +const C_LOCALE = 0 +const DEFAULT_GUARD_MAX = 1048576 +const DEFAULT_GUARD_SIZE = 8192 +const DEFAULT_STACK_MAX = 8388608 +const DEFAULT_STACK_SIZE = 131072 +const DTP_OFFSET = 0 +const FUTEX_CLOCK_REALTIME = 256 +const FUTEX_CMP_REQUEUE = 4 +const FUTEX_FD = 2 +const FUTEX_LOCK_PI = 6 +const FUTEX_PRIVATE = 128 +const FUTEX_REQUEUE = 3 +const FUTEX_TRYLOCK_PI = 8 +const FUTEX_UNLOCK_PI = 7 +const FUTEX_WAIT = 0 +const FUTEX_WAIT_BITSET = 9 +const FUTEX_WAKE = 1 +const FUTEX_WAKE_OP = 5 +const LC_ALL = 6 +const LC_ALL_MASK = 2147483647 +const LC_COLLATE = 3 +const LC_COLLATE_MASK = 8 +const LC_CTYPE = 0 +const LC_CTYPE_MASK = 1 +const LC_GLOBAL_LOCALE = -1 +const LC_MESSAGES = 5 +const LC_MESSAGES_MASK = 32 +const LC_MONETARY = 4 +const LC_MONETARY_MASK = 16 +const LC_NUMERIC = 1 +const LC_NUMERIC_MASK = 2 +const LC_TIME = 2 +const LC_TIME_MASK = 4 +const LOCALE_NAME_MAX = 23 +const MAP_32BIT = 64 +const MAP_ANON = 32 +const MAP_ANONYMOUS = 32 +const MAP_DENYWRITE = 2048 +const MAP_EXECUTABLE = 4096 +const MAP_FAILED = -1 +const MAP_FILE = 0 +const MAP_FIXED = 16 +const MAP_FIXED_NOREPLACE = 1048576 +const MAP_GROWSDOWN = 256 +const MAP_HUGETLB = 262144 +const MAP_HUGE_16GB = 2281701376 +const MAP_HUGE_16KB = 939524096 +const MAP_HUGE_16MB = 1610612736 +const MAP_HUGE_1GB = 2013265920 +const MAP_HUGE_1MB = 1342177280 +const MAP_HUGE_256MB = 1879048192 +const MAP_HUGE_2GB = 2080374784 +const MAP_HUGE_2MB = 1409286144 +const MAP_HUGE_32MB = 1677721600 +const MAP_HUGE_512KB = 1275068416 +const MAP_HUGE_512MB = 1946157056 +const MAP_HUGE_64KB = 1073741824 +const MAP_HUGE_8MB = 1543503872 +const MAP_HUGE_MASK = 63 +const MAP_HUGE_SHIFT = 26 +const MAP_LOCKED = 8192 +const MAP_NONBLOCK = 65536 +const MAP_NORESERVE = 16384 +const MAP_POPULATE = 32768 +const MAP_PRIVATE = 2 +const MAP_SHARED = 1 +const MAP_SHARED_VALIDATE = 3 +const MAP_STACK = 131072 +const MAP_SYNC = 524288 +const MAP_TYPE = 15 +const MCL_CURRENT = 1 +const MCL_FUTURE = 2 +const MCL_ONFAULT = 4 +const MS_ASYNC = 1 +const MS_INVALIDATE = 2 +const MS_SYNC = 4 +const POSIX_MADV_DONTNEED = 4 +const POSIX_MADV_NORMAL = 0 +const POSIX_MADV_RANDOM = 1 +const POSIX_MADV_SEQUENTIAL = 2 +const POSIX_MADV_WILLNEED = 3 +const PROT_EXEC = 4 +const PROT_GROWSDOWN = 16777216 +const PROT_GROWSUP = 33554432 +const PROT_NONE = 0 +const PROT_READ = 1 +const PROT_WRITE = 2 +const PTHREAD_BARRIER_SERIAL_THREAD = -1 +const PTHREAD_CANCELED = -1 +const PTHREAD_CANCEL_ASYNCHRONOUS = 1 +const PTHREAD_CANCEL_DEFERRED = 0 +const PTHREAD_CANCEL_DISABLE = 1 +const PTHREAD_CANCEL_ENABLE = 0 +const PTHREAD_CANCEL_MASKED = 2 +const PTHREAD_CREATE_DETACHED = 1 +const PTHREAD_CREATE_JOINABLE = 0 +const PTHREAD_EXPLICIT_SCHED = 1 +const PTHREAD_INHERIT_SCHED = 0 +const PTHREAD_MUTEX_DEFAULT = 0 +const PTHREAD_MUTEX_ERRORCHECK = 2 +const PTHREAD_MUTEX_NORMAL = 0 +const PTHREAD_MUTEX_RECURSIVE = 1 +const PTHREAD_MUTEX_ROBUST = 1 +const PTHREAD_MUTEX_STALLED = 0 +const PTHREAD_ONCE_INIT = 0 +const PTHREAD_PRIO_INHERIT = 1 +const PTHREAD_PRIO_NONE = 0 +const PTHREAD_PRIO_PROTECT = 2 +const PTHREAD_PROCESS_PRIVATE = 0 +const PTHREAD_PROCESS_SHARED = 1 +const PTHREAD_SCOPE_PROCESS = 1 +const PTHREAD_SCOPE_SYSTEM = 0 +const SCHED_BATCH = 3 +const SCHED_DEADLINE = 6 +const SCHED_FIFO = 1 +const SCHED_IDLE = 5 +const SCHED_OTHER = 0 +const SCHED_RESET_ON_FORK = 1073741824 +const SCHED_RR = 2 +const SIGCANCEL = 33 +const SIGSYNCCALL = 34 +const SIGTIMER = 32 +const TIMER_ABSTIME = 1 +const TIME_UTC = 1 +const TP_OFFSET = 0 +const UTF8_LOCALE = 0 +const __CCGO_SIZEOF_GO_MUTEX = 8 +const __SU = 0 +const pthread = 0 +const tls_mod_off_t = 0 + +type Tlconv = struct { + Fdecimal_point uintptr + Fthousands_sep uintptr + Fgrouping uintptr + Fint_curr_symbol uintptr + Fcurrency_symbol uintptr + Fmon_decimal_point uintptr + Fmon_thousands_sep uintptr + Fmon_grouping uintptr + Fpositive_sign uintptr + Fnegative_sign uintptr + Fint_frac_digits int8 + Ffrac_digits int8 + Fp_cs_precedes int8 + Fp_sep_by_space int8 + Fn_cs_precedes int8 + Fn_sep_by_space int8 + Fp_sign_posn int8 + Fn_sign_posn int8 + Fint_p_cs_precedes int8 + Fint_p_sep_by_space int8 + Fint_n_cs_precedes int8 + Fint_n_sep_by_space int8 + Fint_p_sign_posn int8 + Fint_n_sign_posn int8 +} + +type t__locale_map = struct { + Fmap1 uintptr + Fmap_size Tsize_t + Fname [24]int8 + Fnext uintptr +} + +type Tclockid_t = int32 + +type t__pthread = struct { + Fself uintptr + Fdtv uintptr + Fprev uintptr + Fnext uintptr + Fsysinfo Tuintptr_t + Fcanary Tuintptr_t + Ftid int32 + Ferrno_val int32 + Fdetach_state int32 + Fcancel int32 + Fcanceldisable uint8 + Fcancelasync uint8 + F__ccgo66 uint8 + Fmap_base uintptr + Fmap_size Tsize_t + Fstack uintptr + Fstack_size Tsize_t + Fguard_size Tsize_t + Fresult uintptr + Fcancelbuf uintptr + Ftsd uintptr + Frobust_list struct { + Fhead uintptr + Foff int64 + Fpending uintptr + } + Fh_errno_val int32 + Ftimer_id int32 + Flocale Tlocale_t + Fkilllock [1]int32 + Fdlerror_buf uintptr + Fstdio_locks uintptr + F__ccgo_join_mutex [1]int64 +} + +type Tpthread_once_t = int32 + +type Tpthread_key_t = uint32 + +type Tpthread_spinlock_t = int32 + +type Tpthread_mutexattr_t = struct { + F__attr uint32 +} + +type Tpthread_condattr_t = struct { + F__attr uint32 +} + +type Tpthread_barrierattr_t = struct { + F__attr uint32 +} + +type Tpthread_rwlockattr_t = struct { + F__attr [2]uint32 +} + +type Tpthread_mutex_t = struct { + F__u struct { + F__vi [0][10]int32 + F__p [0][5]uintptr + F__i [10]int32 + } +} + +type Tpthread_cond_t = struct { + F__u struct { + F__vi [0][12]int32 + F__p [0][6]uintptr + F__i [12]int32 + } +} + +type Tpthread_rwlock_t = struct { + F__u struct { + F__vi [0][14]int32 + F__p [0][7]uintptr + F__i [14]int32 + } +} + +type Tpthread_barrier_t = struct { + F__u struct { + F__vi [0][8]int32 + F__p [0][4]uintptr + F__i [8]int32 + } +} + +type Tsched_param = struct { + Fsched_priority int32 + F__reserved1 int32 + F__reserved2 [2]struct { + F__reserved1 Ttime_t + F__reserved2 int64 + } + F__reserved3 int32 +} + +type Ttimer_t = uintptr + +type Ttm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__tm_gmtoff int64 + F__tm_zone uintptr +} + +type Titimerspec = struct { + Fit_interval Ttimespec + Fit_value Ttimespec +} + +type t__ptcb = struct { + F__f uintptr + F__x uintptr + F__next uintptr +} + +type Tmode_t = uint32 + +const _DT_EXITED = 0 +const _DT_EXITING = 1 +const _DT_JOINABLE = 2 +const _DT_DETACHED = 3 + +func X__ctype_get_mb_cur_max(tls *TLS) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v1 = int32(4) + } else { + v1 = int32(1) + } + return Uint64FromInt32(v1) +} + +var _table1 = [384]Tint32_t{ + 129: int32(1), + 130: int32(2), + 131: int32(3), + 132: int32(4), + 133: int32(5), + 134: int32(6), + 135: int32(7), + 136: int32(8), + 137: int32(9), + 138: int32(10), + 139: int32(11), + 140: int32(12), + 141: int32(13), + 142: int32(14), + 143: int32(15), + 144: int32(16), + 145: int32(17), + 146: int32(18), + 147: int32(19), + 148: int32(20), + 149: int32(21), + 150: int32(22), + 151: int32(23), + 152: int32(24), + 153: int32(25), + 154: int32(26), + 155: int32(27), + 156: int32(28), + 157: int32(29), + 158: int32(30), + 159: int32(31), + 160: int32(32), + 161: int32(33), + 162: int32(34), + 163: int32(35), + 164: int32(36), + 165: int32(37), + 166: int32(38), + 167: int32(39), + 168: int32(40), + 169: int32(41), + 170: int32(42), + 171: int32(43), + 172: int32(44), + 173: int32(45), + 174: int32(46), + 175: int32(47), + 176: int32(48), + 177: int32(49), + 178: int32(50), + 179: int32(51), + 180: int32(52), + 181: int32(53), + 182: int32(54), + 183: int32(55), + 184: int32(56), + 185: int32(57), + 186: int32(58), + 187: int32(59), + 188: int32(60), + 189: int32(61), + 190: int32(62), + 191: int32(63), + 192: int32(64), + 193: int32('a'), + 194: int32('b'), + 195: int32('c'), + 196: int32('d'), + 197: int32('e'), + 198: int32('f'), + 199: int32('g'), + 200: int32('h'), + 201: int32('i'), + 202: int32('j'), + 203: int32('k'), + 204: int32('l'), + 205: int32('m'), + 206: int32('n'), + 207: int32('o'), + 208: int32('p'), + 209: int32('q'), + 210: int32('r'), + 211: int32('s'), + 212: int32('t'), + 213: int32('u'), + 214: int32('v'), + 215: int32('w'), + 216: int32('x'), + 217: int32('y'), + 218: int32('z'), + 219: int32(91), + 220: int32(92), + 221: int32(93), + 222: int32(94), + 223: int32(95), + 224: int32(96), + 225: int32('a'), + 226: int32('b'), + 227: int32('c'), + 228: int32('d'), + 229: int32('e'), + 230: int32('f'), + 231: int32('g'), + 232: int32('h'), + 233: int32('i'), + 234: int32('j'), + 235: int32('k'), + 236: int32('l'), + 237: int32('m'), + 238: int32('n'), + 239: int32('o'), + 240: int32('p'), + 241: int32('q'), + 242: int32('r'), + 243: int32('s'), + 244: int32('t'), + 245: int32('u'), + 246: int32('v'), + 247: int32('w'), + 248: int32('x'), + 249: int32('y'), + 250: int32('z'), + 251: int32(123), + 252: int32(124), + 253: int32(125), + 254: int32(126), + 255: int32(127), +} + +var _ptable1 = uintptr(unsafe.Pointer(&_table1)) + uintptr(128)*4 + +func X__ctype_tolower_loc(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_ptable1)) +} + +var _table2 = [384]Tint32_t{ + 129: int32(1), + 130: int32(2), + 131: int32(3), + 132: int32(4), + 133: int32(5), + 134: int32(6), + 135: int32(7), + 136: int32(8), + 137: int32(9), + 138: int32(10), + 139: int32(11), + 140: int32(12), + 141: int32(13), + 142: int32(14), + 143: int32(15), + 144: int32(16), + 145: int32(17), + 146: int32(18), + 147: int32(19), + 148: int32(20), + 149: int32(21), + 150: int32(22), + 151: int32(23), + 152: int32(24), + 153: int32(25), + 154: int32(26), + 155: int32(27), + 156: int32(28), + 157: int32(29), + 158: int32(30), + 159: int32(31), + 160: int32(32), + 161: int32(33), + 162: int32(34), + 163: int32(35), + 164: int32(36), + 165: int32(37), + 166: int32(38), + 167: int32(39), + 168: int32(40), + 169: int32(41), + 170: int32(42), + 171: int32(43), + 172: int32(44), + 173: int32(45), + 174: int32(46), + 175: int32(47), + 176: int32(48), + 177: int32(49), + 178: int32(50), + 179: int32(51), + 180: int32(52), + 181: int32(53), + 182: int32(54), + 183: int32(55), + 184: int32(56), + 185: int32(57), + 186: int32(58), + 187: int32(59), + 188: int32(60), + 189: int32(61), + 190: int32(62), + 191: int32(63), + 192: int32(64), + 193: int32('A'), + 194: int32('B'), + 195: int32('C'), + 196: int32('D'), + 197: int32('E'), + 198: int32('F'), + 199: int32('G'), + 200: int32('H'), + 201: int32('I'), + 202: int32('J'), + 203: int32('K'), + 204: int32('L'), + 205: int32('M'), + 206: int32('N'), + 207: int32('O'), + 208: int32('P'), + 209: int32('Q'), + 210: int32('R'), + 211: int32('S'), + 212: int32('T'), + 213: int32('U'), + 214: int32('V'), + 215: int32('W'), + 216: int32('X'), + 217: int32('Y'), + 218: int32('Z'), + 219: int32(91), + 220: int32(92), + 221: int32(93), + 222: int32(94), + 223: int32(95), + 224: int32(96), + 225: int32('A'), + 226: int32('B'), + 227: int32('C'), + 228: int32('D'), + 229: int32('E'), + 230: int32('F'), + 231: int32('G'), + 232: int32('H'), + 233: int32('I'), + 234: int32('J'), + 235: int32('K'), + 236: int32('L'), + 237: int32('M'), + 238: int32('N'), + 239: int32('O'), + 240: int32('P'), + 241: int32('Q'), + 242: int32('R'), + 243: int32('S'), + 244: int32('T'), + 245: int32('U'), + 246: int32('V'), + 247: int32('W'), + 248: int32('X'), + 249: int32('Y'), + 250: int32('Z'), + 251: int32(123), + 252: int32(124), + 253: int32(125), + 254: int32(126), + 255: int32(127), +} + +var _ptable2 = uintptr(unsafe.Pointer(&_table2)) + uintptr(128)*4 + +func X__ctype_toupper_loc(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_ptable2)) +} + +func Xisalnum(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(BoolInt32(Uint32FromInt32(c)|uint32(32)-uint32('a') < uint32(26)) != 0 || BoolInt32(Uint32FromInt32(c)-uint32('0') < uint32(10)) != 0) +} + +func X__isalnum_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisalnum(tls, c) +} + +func Xisalnum_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isalnum_l(tls, c, l) +} + +func Xisalpha(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)|uint32(32)-uint32('a') < uint32(26)) +} + +func X__isalpha_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisalpha(tls, c) +} + +func Xisalpha_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isalpha_l(tls, c, l) +} + +func Xisascii(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(!(c & ^Int32FromInt32(0x7f) != 0)) +} + +func Xisblank(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(c == int32(' ') || c == int32('\t')) +} + +func X__isblank_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisblank(tls, c) +} + +func Xisblank_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isblank_l(tls, c, l) +} + +func Xiscntrl(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c) < uint32(0x20) || c == int32(0x7f)) +} + +func X__iscntrl_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiscntrl(tls, c) +} + +func Xiscntrl_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iscntrl_l(tls, c, l) +} + +func Xisdigit(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32('0') < uint32(10)) +} + +func X__isdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisdigit(tls, c) +} + +func Xisdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isdigit_l(tls, c, l) +} + +func Xisgraph(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32(0x21) < uint32(0x5e)) +} + +func X__isgraph_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisgraph(tls, c) +} + +func Xisgraph_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isgraph_l(tls, c, l) +} + +func Xislower(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32('a') < uint32(26)) +} + +func X__islower_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xislower(tls, c) +} + +func Xislower_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__islower_l(tls, c, l) +} + +func Xisprint(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32(0x20) < uint32(0x5f)) +} + +func X__isprint_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisprint(tls, c) +} + +func Xisprint_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isprint_l(tls, c, l) +} + +func Xispunct(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(BoolInt32(Uint32FromInt32(c)-uint32(0x21) < uint32(0x5e)) != 0 && !(Xisalnum(tls, c) != 0)) +} + +func X__ispunct_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xispunct(tls, c) +} + +func Xispunct_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__ispunct_l(tls, c, l) +} + +func Xisspace(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(c == int32(' ') || Uint32FromInt32(c)-uint32('\t') < uint32(5)) +} + +func X__isspace_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisspace(tls, c) +} + +func Xisspace_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isspace_l(tls, c, l) +} + +func Xisupper(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32('A') < uint32(26)) +} + +func X__isupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisupper(tls, c) +} + +func Xisupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isupper_l(tls, c, l) +} + +type Twint_t = uint32 + +type Twctype_t = uint64 + +type Twctrans_t = uintptr + +func Xiswalnum(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(BoolInt32(wc-uint32('0') < uint32(10)) != 0 || Xiswalpha(tls, wc) != 0) +} + +func X__iswalnum_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswalnum(tls, c) +} + +func Xiswalnum_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswalnum_l(tls, c, l) +} + +var _table3 = [3904]uint8{ + 0: uint8(18), + 1: uint8(17), + 2: uint8(19), + 3: uint8(20), + 4: uint8(21), + 5: uint8(22), + 6: uint8(23), + 7: uint8(24), + 8: uint8(25), + 9: uint8(26), + 10: uint8(27), + 11: uint8(28), + 12: uint8(29), + 13: uint8(30), + 14: uint8(31), + 15: uint8(32), + 16: uint8(33), + 17: uint8(17), + 18: uint8(34), + 19: uint8(35), + 20: uint8(36), + 21: uint8(17), + 22: uint8(37), + 23: uint8(38), + 24: uint8(39), + 25: uint8(40), + 26: uint8(41), + 27: uint8(42), + 28: uint8(43), + 29: uint8(44), + 30: uint8(17), + 31: uint8(45), + 32: uint8(46), + 33: uint8(47), + 34: uint8(16), + 35: uint8(16), + 36: uint8(48), + 37: uint8(16), + 38: uint8(16), + 39: uint8(16), + 40: uint8(16), + 41: uint8(16), + 42: uint8(16), + 43: uint8(16), + 44: uint8(49), + 45: uint8(50), + 46: uint8(51), + 47: uint8(16), + 48: uint8(52), + 49: uint8(53), + 50: uint8(16), + 51: uint8(16), + 52: uint8(17), + 53: uint8(17), + 54: uint8(17), + 55: uint8(17), + 56: uint8(17), + 57: uint8(17), + 58: uint8(17), + 59: uint8(17), + 60: uint8(17), + 61: uint8(17), + 62: uint8(17), + 63: uint8(17), + 64: uint8(17), + 65: uint8(17), + 66: uint8(17), + 67: uint8(17), + 68: uint8(17), + 69: uint8(17), + 70: uint8(17), + 71: uint8(17), + 72: uint8(17), + 73: uint8(17), + 74: uint8(17), + 75: uint8(17), + 76: uint8(17), + 77: uint8(54), + 78: uint8(17), + 79: uint8(17), + 80: uint8(17), + 81: uint8(17), + 82: uint8(17), + 83: uint8(17), + 84: uint8(17), + 85: uint8(17), + 86: uint8(17), + 87: uint8(17), + 88: uint8(17), + 89: uint8(17), + 90: uint8(17), + 91: uint8(17), + 92: uint8(17), + 93: uint8(17), + 94: uint8(17), + 95: uint8(17), + 96: uint8(17), + 97: uint8(17), + 98: uint8(17), + 99: uint8(17), + 100: uint8(17), + 101: uint8(17), + 102: uint8(17), + 103: uint8(17), + 104: uint8(17), + 105: uint8(17), + 106: uint8(17), + 107: uint8(17), + 108: uint8(17), + 109: uint8(17), + 110: uint8(17), + 111: uint8(17), + 112: uint8(17), + 113: uint8(17), + 114: uint8(17), + 115: uint8(17), + 116: uint8(17), + 117: uint8(17), + 118: uint8(17), + 119: uint8(17), + 120: uint8(17), + 121: uint8(17), + 122: uint8(17), + 123: uint8(17), + 124: uint8(17), + 125: uint8(17), + 126: uint8(17), + 127: uint8(17), + 128: uint8(17), + 129: uint8(17), + 130: uint8(17), + 131: uint8(17), + 132: uint8(17), + 133: uint8(17), + 134: uint8(17), + 135: uint8(17), + 136: uint8(17), + 137: uint8(17), + 138: uint8(17), + 139: uint8(17), + 140: uint8(17), + 141: uint8(17), + 142: uint8(17), + 143: uint8(17), + 144: uint8(17), + 145: uint8(17), + 146: uint8(17), + 147: uint8(17), + 148: uint8(17), + 149: uint8(17), + 150: uint8(17), + 151: uint8(17), + 152: uint8(17), + 153: uint8(17), + 154: uint8(17), + 155: uint8(17), + 156: uint8(17), + 157: uint8(17), + 158: uint8(17), + 159: uint8(55), + 160: uint8(17), + 161: uint8(17), + 162: uint8(17), + 163: uint8(17), + 164: uint8(56), + 165: uint8(17), + 166: uint8(57), + 167: uint8(58), + 168: uint8(59), + 169: uint8(60), + 170: uint8(61), + 171: uint8(62), + 172: uint8(17), + 173: uint8(17), + 174: uint8(17), + 175: uint8(17), + 176: uint8(17), + 177: uint8(17), + 178: uint8(17), + 179: uint8(17), + 180: uint8(17), + 181: uint8(17), + 182: uint8(17), + 183: uint8(17), + 184: uint8(17), + 185: uint8(17), + 186: uint8(17), + 187: uint8(17), + 188: uint8(17), + 189: uint8(17), + 190: uint8(17), + 191: uint8(17), + 192: uint8(17), + 193: uint8(17), + 194: uint8(17), + 195: uint8(17), + 196: uint8(17), + 197: uint8(17), + 198: uint8(17), + 199: uint8(17), + 200: uint8(17), + 201: uint8(17), + 202: uint8(17), + 203: uint8(17), + 204: uint8(17), + 205: uint8(17), + 206: uint8(17), + 207: uint8(17), + 208: uint8(17), + 209: uint8(17), + 210: uint8(17), + 211: uint8(17), + 212: uint8(17), + 213: uint8(17), + 214: uint8(17), + 215: uint8(63), + 216: uint8(16), + 217: uint8(16), + 218: uint8(16), + 219: uint8(16), + 220: uint8(16), + 221: uint8(16), + 222: uint8(16), + 223: uint8(16), + 224: uint8(16), + 225: uint8(16), + 226: uint8(16), + 227: uint8(16), + 228: uint8(16), + 229: uint8(16), + 230: uint8(16), + 231: uint8(16), + 232: uint8(16), + 233: uint8(16), + 234: uint8(16), + 235: uint8(16), + 236: uint8(16), + 237: uint8(16), + 238: uint8(16), + 239: uint8(16), + 240: uint8(16), + 241: uint8(16), + 242: uint8(16), + 243: uint8(16), + 244: uint8(16), + 245: uint8(16), + 246: uint8(16), + 247: uint8(16), + 248: uint8(16), + 249: uint8(17), + 250: uint8(64), + 251: uint8(65), + 252: uint8(17), + 253: uint8(66), + 254: uint8(67), + 255: uint8(68), + 256: uint8(69), + 257: uint8(70), + 258: uint8(71), + 259: uint8(72), + 260: uint8(73), + 261: uint8(74), + 262: uint8(17), + 263: uint8(75), + 264: uint8(76), + 265: uint8(77), + 266: uint8(78), + 267: uint8(79), + 268: uint8(80), + 269: uint8(81), + 270: uint8(16), + 271: uint8(82), + 272: uint8(83), + 273: uint8(84), + 274: uint8(85), + 275: uint8(86), + 276: uint8(87), + 277: uint8(88), + 278: uint8(89), + 279: uint8(90), + 280: uint8(91), + 281: uint8(92), + 282: uint8(93), + 283: uint8(16), + 284: uint8(94), + 285: uint8(95), + 286: uint8(96), + 287: uint8(16), + 288: uint8(17), + 289: uint8(17), + 290: uint8(17), + 291: uint8(97), + 292: uint8(98), + 293: uint8(99), + 294: uint8(16), + 295: uint8(16), + 296: uint8(16), + 297: uint8(16), + 298: uint8(16), + 299: uint8(16), + 300: uint8(16), + 301: uint8(16), + 302: uint8(16), + 303: uint8(16), + 304: uint8(17), + 305: uint8(17), + 306: uint8(17), + 307: uint8(17), + 308: uint8(100), + 309: uint8(16), + 310: uint8(16), + 311: uint8(16), + 312: uint8(16), + 313: uint8(16), + 314: uint8(16), + 315: uint8(16), + 316: uint8(16), + 317: uint8(16), + 318: uint8(16), + 319: uint8(16), + 320: uint8(16), + 321: uint8(16), + 322: uint8(16), + 323: uint8(16), + 324: uint8(17), + 325: uint8(17), + 326: uint8(101), + 327: uint8(16), + 328: uint8(16), + 329: uint8(16), + 330: uint8(16), + 331: uint8(16), + 332: uint8(16), + 333: uint8(16), + 334: uint8(16), + 335: uint8(16), + 336: uint8(16), + 337: uint8(16), + 338: uint8(16), + 339: uint8(16), + 340: uint8(16), + 341: uint8(16), + 342: uint8(16), + 343: uint8(16), + 344: uint8(16), + 345: uint8(16), + 346: uint8(16), + 347: uint8(16), + 348: uint8(16), + 349: uint8(16), + 350: uint8(16), + 351: uint8(16), + 352: uint8(16), + 353: uint8(16), + 354: uint8(16), + 355: uint8(16), + 356: uint8(16), + 357: uint8(16), + 358: uint8(16), + 359: uint8(16), + 360: uint8(17), + 361: uint8(17), + 362: uint8(102), + 363: uint8(103), + 364: uint8(16), + 365: uint8(16), + 366: uint8(104), + 367: uint8(105), + 368: uint8(17), + 369: uint8(17), + 370: uint8(17), + 371: uint8(17), + 372: uint8(17), + 373: uint8(17), + 374: uint8(17), + 375: uint8(17), + 376: uint8(17), + 377: uint8(17), + 378: uint8(17), + 379: uint8(17), + 380: uint8(17), + 381: uint8(17), + 382: uint8(17), + 383: uint8(17), + 384: uint8(17), + 385: uint8(17), + 386: uint8(17), + 387: uint8(17), + 388: uint8(17), + 389: uint8(17), + 390: uint8(17), + 391: uint8(106), + 392: uint8(17), + 393: uint8(17), + 394: uint8(107), + 395: uint8(16), + 396: uint8(16), + 397: uint8(16), + 398: uint8(16), + 399: uint8(16), + 400: uint8(16), + 401: uint8(16), + 402: uint8(16), + 403: uint8(16), + 404: uint8(16), + 405: uint8(16), + 406: uint8(16), + 407: uint8(16), + 408: uint8(16), + 409: uint8(16), + 410: uint8(16), + 411: uint8(16), + 412: uint8(16), + 413: uint8(16), + 414: uint8(16), + 415: uint8(16), + 416: uint8(16), + 417: uint8(16), + 418: uint8(16), + 419: uint8(16), + 420: uint8(16), + 421: uint8(16), + 422: uint8(16), + 423: uint8(16), + 424: uint8(16), + 425: uint8(16), + 426: uint8(16), + 427: uint8(16), + 428: uint8(16), + 429: uint8(16), + 430: uint8(16), + 431: uint8(16), + 432: uint8(17), + 433: uint8(108), + 434: uint8(109), + 435: uint8(16), + 436: uint8(16), + 437: uint8(16), + 438: uint8(16), + 439: uint8(16), + 440: uint8(16), + 441: uint8(16), + 442: uint8(16), + 443: uint8(16), + 444: uint8(110), + 445: uint8(16), + 446: uint8(16), + 447: uint8(16), + 448: uint8(16), + 449: uint8(16), + 450: uint8(16), + 451: uint8(16), + 452: uint8(16), + 453: uint8(16), + 454: uint8(16), + 455: uint8(16), + 456: uint8(16), + 457: uint8(16), + 458: uint8(16), + 459: uint8(16), + 460: uint8(16), + 461: uint8(16), + 462: uint8(16), + 463: uint8(16), + 464: uint8(16), + 465: uint8(16), + 466: uint8(16), + 467: uint8(16), + 468: uint8(111), + 469: uint8(112), + 470: uint8(113), + 471: uint8(114), + 472: uint8(16), + 473: uint8(16), + 474: uint8(16), + 475: uint8(16), + 476: uint8(16), + 477: uint8(16), + 478: uint8(16), + 479: uint8(16), + 480: uint8(115), + 481: uint8(116), + 482: uint8(117), + 483: uint8(16), + 484: uint8(16), + 485: uint8(16), + 486: uint8(16), + 487: uint8(16), + 488: uint8(118), + 489: uint8(119), + 490: uint8(16), + 491: uint8(16), + 492: uint8(16), + 493: uint8(16), + 494: uint8(120), + 495: uint8(16), + 496: uint8(16), + 497: uint8(121), + 498: uint8(16), + 499: uint8(16), + 500: uint8(16), + 501: uint8(16), + 502: uint8(16), + 503: uint8(16), + 504: uint8(16), + 505: uint8(16), + 506: uint8(16), + 507: uint8(16), + 508: uint8(16), + 509: uint8(16), + 510: uint8(16), + 511: uint8(16), + 544: uint8(255), + 545: uint8(255), + 546: uint8(255), + 547: uint8(255), + 548: uint8(255), + 549: uint8(255), + 550: uint8(255), + 551: uint8(255), + 552: uint8(255), + 553: uint8(255), + 554: uint8(255), + 555: uint8(255), + 556: uint8(255), + 557: uint8(255), + 558: uint8(255), + 559: uint8(255), + 560: uint8(255), + 561: uint8(255), + 562: uint8(255), + 563: uint8(255), + 564: uint8(255), + 565: uint8(255), + 566: uint8(255), + 567: uint8(255), + 568: uint8(255), + 569: uint8(255), + 570: uint8(255), + 571: uint8(255), + 572: uint8(255), + 573: uint8(255), + 574: uint8(255), + 575: uint8(255), + 584: uint8(254), + 585: uint8(255), + 586: uint8(255), + 587: uint8(7), + 588: uint8(254), + 589: uint8(255), + 590: uint8(255), + 591: uint8(7), + 597: uint8(4), + 598: uint8(32), + 599: uint8(4), + 600: uint8(255), + 601: uint8(255), + 602: uint8(127), + 603: uint8(255), + 604: uint8(255), + 605: uint8(255), + 606: uint8(127), + 607: uint8(255), + 608: uint8(255), + 609: uint8(255), + 610: uint8(255), + 611: uint8(255), + 612: uint8(255), + 613: uint8(255), + 614: uint8(255), + 615: uint8(255), + 616: uint8(255), + 617: uint8(255), + 618: uint8(255), + 619: uint8(255), + 620: uint8(255), + 621: uint8(255), + 622: uint8(255), + 623: uint8(255), + 624: uint8(255), + 625: uint8(255), + 626: uint8(255), + 627: uint8(255), + 628: uint8(255), + 629: uint8(255), + 630: uint8(255), + 631: uint8(255), + 632: uint8(195), + 633: uint8(255), + 634: uint8(3), + 636: uint8(31), + 637: uint8(80), + 648: uint8(32), + 654: uint8(223), + 655: uint8(188), + 656: uint8(64), + 657: uint8(215), + 658: uint8(255), + 659: uint8(255), + 660: uint8(251), + 661: uint8(255), + 662: uint8(255), + 663: uint8(255), + 664: uint8(255), + 665: uint8(255), + 666: uint8(255), + 667: uint8(255), + 668: uint8(255), + 669: uint8(255), + 670: uint8(191), + 671: uint8(255), + 672: uint8(255), + 673: uint8(255), + 674: uint8(255), + 675: uint8(255), + 676: uint8(255), + 677: uint8(255), + 678: uint8(255), + 679: uint8(255), + 680: uint8(255), + 681: uint8(255), + 682: uint8(255), + 683: uint8(255), + 684: uint8(255), + 685: uint8(255), + 686: uint8(255), + 687: uint8(255), + 688: uint8(3), + 689: uint8(252), + 690: uint8(255), + 691: uint8(255), + 692: uint8(255), + 693: uint8(255), + 694: uint8(255), + 695: uint8(255), + 696: uint8(255), + 697: uint8(255), + 698: uint8(255), + 699: uint8(255), + 700: uint8(255), + 701: uint8(255), + 702: uint8(255), + 703: uint8(255), + 704: uint8(255), + 705: uint8(255), + 706: uint8(255), + 707: uint8(255), + 708: uint8(255), + 709: uint8(255), + 710: uint8(254), + 711: uint8(255), + 712: uint8(255), + 713: uint8(255), + 714: uint8(127), + 715: uint8(2), + 716: uint8(255), + 717: uint8(255), + 718: uint8(255), + 719: uint8(255), + 720: uint8(255), + 721: uint8(1), + 726: uint8(255), + 727: uint8(191), + 728: uint8(182), + 730: uint8(255), + 731: uint8(255), + 732: uint8(255), + 733: uint8(135), + 734: uint8(7), + 738: uint8(255), + 739: uint8(7), + 740: uint8(255), + 741: uint8(255), + 742: uint8(255), + 743: uint8(255), + 744: uint8(255), + 745: uint8(255), + 746: uint8(255), + 747: uint8(254), + 748: uint8(255), + 749: uint8(195), + 750: uint8(255), + 751: uint8(255), + 752: uint8(255), + 753: uint8(255), + 754: uint8(255), + 755: uint8(255), + 756: uint8(255), + 757: uint8(255), + 758: uint8(255), + 759: uint8(255), + 760: uint8(255), + 761: uint8(255), + 762: uint8(239), + 763: uint8(31), + 764: uint8(254), + 765: uint8(225), + 766: uint8(255), + 767: uint8(159), + 770: uint8(255), + 771: uint8(255), + 772: uint8(255), + 773: uint8(255), + 774: uint8(255), + 775: uint8(255), + 777: uint8(224), + 778: uint8(255), + 779: uint8(255), + 780: uint8(255), + 781: uint8(255), + 782: uint8(255), + 783: uint8(255), + 784: uint8(255), + 785: uint8(255), + 786: uint8(255), + 787: uint8(255), + 788: uint8(255), + 789: uint8(255), + 790: uint8(3), + 792: uint8(255), + 793: uint8(255), + 794: uint8(255), + 795: uint8(255), + 796: uint8(255), + 797: uint8(7), + 798: uint8(48), + 799: uint8(4), + 800: uint8(255), + 801: uint8(255), + 802: uint8(255), + 803: uint8(252), + 804: uint8(255), + 805: uint8(31), + 808: uint8(255), + 809: uint8(255), + 810: uint8(255), + 811: uint8(1), + 812: uint8(255), + 813: uint8(7), + 820: uint8(255), + 821: uint8(255), + 822: uint8(223), + 823: uint8(63), + 826: uint8(240), + 827: uint8(255), + 828: uint8(248), + 829: uint8(3), + 830: uint8(255), + 831: uint8(255), + 832: uint8(255), + 833: uint8(255), + 834: uint8(255), + 835: uint8(255), + 836: uint8(255), + 837: uint8(255), + 838: uint8(255), + 839: uint8(239), + 840: uint8(255), + 841: uint8(223), + 842: uint8(225), + 843: uint8(255), + 844: uint8(207), + 845: uint8(255), + 846: uint8(254), + 847: uint8(255), + 848: uint8(239), + 849: uint8(159), + 850: uint8(249), + 851: uint8(255), + 852: uint8(255), + 853: uint8(253), + 854: uint8(197), + 855: uint8(227), + 856: uint8(159), + 857: uint8(89), + 858: uint8(128), + 859: uint8(176), + 860: uint8(207), + 861: uint8(255), + 862: uint8(3), + 863: uint8(16), + 864: uint8(238), + 865: uint8(135), + 866: uint8(249), + 867: uint8(255), + 868: uint8(255), + 869: uint8(253), + 870: uint8(109), + 871: uint8(195), + 872: uint8(135), + 873: uint8(25), + 874: uint8(2), + 875: uint8(94), + 876: uint8(192), + 877: uint8(255), + 878: uint8(63), + 880: uint8(238), + 881: uint8(191), + 882: uint8(251), + 883: uint8(255), + 884: uint8(255), + 885: uint8(253), + 886: uint8(237), + 887: uint8(227), + 888: uint8(191), + 889: uint8(27), + 890: uint8(1), + 892: uint8(207), + 893: uint8(255), + 895: uint8(30), + 896: uint8(238), + 897: uint8(159), + 898: uint8(249), + 899: uint8(255), + 900: uint8(255), + 901: uint8(253), + 902: uint8(237), + 903: uint8(227), + 904: uint8(159), + 905: uint8(25), + 906: uint8(192), + 907: uint8(176), + 908: uint8(207), + 909: uint8(255), + 910: uint8(2), + 912: uint8(236), + 913: uint8(199), + 914: uint8(61), + 915: uint8(214), + 916: uint8(24), + 917: uint8(199), + 918: uint8(255), + 919: uint8(195), + 920: uint8(199), + 921: uint8(29), + 922: uint8(129), + 924: uint8(192), + 925: uint8(255), + 928: uint8(239), + 929: uint8(223), + 930: uint8(253), + 931: uint8(255), + 932: uint8(255), + 933: uint8(253), + 934: uint8(255), + 935: uint8(227), + 936: uint8(223), + 937: uint8(29), + 938: uint8(96), + 939: uint8(7), + 940: uint8(207), + 941: uint8(255), + 944: uint8(239), + 945: uint8(223), + 946: uint8(253), + 947: uint8(255), + 948: uint8(255), + 949: uint8(253), + 950: uint8(239), + 951: uint8(227), + 952: uint8(223), + 953: uint8(29), + 954: uint8(96), + 955: uint8(64), + 956: uint8(207), + 957: uint8(255), + 958: uint8(6), + 960: uint8(239), + 961: uint8(223), + 962: uint8(253), + 963: uint8(255), + 964: uint8(255), + 965: uint8(255), + 966: uint8(255), + 967: uint8(231), + 968: uint8(223), + 969: uint8(93), + 970: uint8(240), + 971: uint8(128), + 972: uint8(207), + 973: uint8(255), + 975: uint8(252), + 976: uint8(236), + 977: uint8(255), + 978: uint8(127), + 979: uint8(252), + 980: uint8(255), + 981: uint8(255), + 982: uint8(251), + 983: uint8(47), + 984: uint8(127), + 985: uint8(128), + 986: uint8(95), + 987: uint8(255), + 988: uint8(192), + 989: uint8(255), + 990: uint8(12), + 992: uint8(254), + 993: uint8(255), + 994: uint8(255), + 995: uint8(255), + 996: uint8(255), + 997: uint8(127), + 998: uint8(255), + 999: uint8(7), + 1000: uint8(63), + 1001: uint8(32), + 1002: uint8(255), + 1003: uint8(3), + 1008: uint8(214), + 1009: uint8(247), + 1010: uint8(255), + 1011: uint8(255), + 1012: uint8(175), + 1013: uint8(255), + 1014: uint8(255), + 1015: uint8(59), + 1016: uint8(95), + 1017: uint8(32), + 1018: uint8(255), + 1019: uint8(243), + 1024: uint8(1), + 1028: uint8(255), + 1029: uint8(3), + 1032: uint8(255), + 1033: uint8(254), + 1034: uint8(255), + 1035: uint8(255), + 1036: uint8(255), + 1037: uint8(31), + 1038: uint8(254), + 1039: uint8(255), + 1040: uint8(3), + 1041: uint8(255), + 1042: uint8(255), + 1043: uint8(254), + 1044: uint8(255), + 1045: uint8(255), + 1046: uint8(255), + 1047: uint8(31), + 1056: uint8(255), + 1057: uint8(255), + 1058: uint8(255), + 1059: uint8(255), + 1060: uint8(255), + 1061: uint8(255), + 1062: uint8(127), + 1063: uint8(249), + 1064: uint8(255), + 1065: uint8(3), + 1066: uint8(255), + 1067: uint8(255), + 1068: uint8(255), + 1069: uint8(255), + 1070: uint8(255), + 1071: uint8(255), + 1072: uint8(255), + 1073: uint8(255), + 1074: uint8(255), + 1075: uint8(63), + 1076: uint8(255), + 1077: uint8(255), + 1078: uint8(255), + 1079: uint8(255), + 1080: uint8(191), + 1081: uint8(32), + 1082: uint8(255), + 1083: uint8(255), + 1084: uint8(255), + 1085: uint8(255), + 1086: uint8(255), + 1087: uint8(247), + 1088: uint8(255), + 1089: uint8(255), + 1090: uint8(255), + 1091: uint8(255), + 1092: uint8(255), + 1093: uint8(255), + 1094: uint8(255), + 1095: uint8(255), + 1096: uint8(255), + 1097: uint8(61), + 1098: uint8(127), + 1099: uint8(61), + 1100: uint8(255), + 1101: uint8(255), + 1102: uint8(255), + 1103: uint8(255), + 1104: uint8(255), + 1105: uint8(61), + 1106: uint8(255), + 1107: uint8(255), + 1108: uint8(255), + 1109: uint8(255), + 1110: uint8(61), + 1111: uint8(127), + 1112: uint8(61), + 1113: uint8(255), + 1114: uint8(127), + 1115: uint8(255), + 1116: uint8(255), + 1117: uint8(255), + 1118: uint8(255), + 1119: uint8(255), + 1120: uint8(255), + 1121: uint8(255), + 1122: uint8(61), + 1123: uint8(255), + 1124: uint8(255), + 1125: uint8(255), + 1126: uint8(255), + 1127: uint8(255), + 1128: uint8(255), + 1129: uint8(255), + 1130: uint8(255), + 1131: uint8(7), + 1136: uint8(255), + 1137: uint8(255), + 1140: uint8(255), + 1141: uint8(255), + 1142: uint8(255), + 1143: uint8(255), + 1144: uint8(255), + 1145: uint8(255), + 1146: uint8(255), + 1147: uint8(255), + 1148: uint8(255), + 1149: uint8(255), + 1150: uint8(63), + 1151: uint8(63), + 1152: uint8(254), + 1153: uint8(255), + 1154: uint8(255), + 1155: uint8(255), + 1156: uint8(255), + 1157: uint8(255), + 1158: uint8(255), + 1159: uint8(255), + 1160: uint8(255), + 1161: uint8(255), + 1162: uint8(255), + 1163: uint8(255), + 1164: uint8(255), + 1165: uint8(255), + 1166: uint8(255), + 1167: uint8(255), + 1168: uint8(255), + 1169: uint8(255), + 1170: uint8(255), + 1171: uint8(255), + 1172: uint8(255), + 1173: uint8(255), + 1174: uint8(255), + 1175: uint8(255), + 1176: uint8(255), + 1177: uint8(255), + 1178: uint8(255), + 1179: uint8(255), + 1180: uint8(255), + 1181: uint8(255), + 1182: uint8(255), + 1183: uint8(255), + 1184: uint8(255), + 1185: uint8(255), + 1186: uint8(255), + 1187: uint8(255), + 1188: uint8(255), + 1189: uint8(255), + 1190: uint8(255), + 1191: uint8(255), + 1192: uint8(255), + 1193: uint8(255), + 1194: uint8(255), + 1195: uint8(255), + 1196: uint8(255), + 1197: uint8(159), + 1198: uint8(255), + 1199: uint8(255), + 1200: uint8(254), + 1201: uint8(255), + 1202: uint8(255), + 1203: uint8(7), + 1204: uint8(255), + 1205: uint8(255), + 1206: uint8(255), + 1207: uint8(255), + 1208: uint8(255), + 1209: uint8(255), + 1210: uint8(255), + 1211: uint8(255), + 1212: uint8(255), + 1213: uint8(199), + 1214: uint8(255), + 1215: uint8(1), + 1216: uint8(255), + 1217: uint8(223), + 1218: uint8(15), + 1220: uint8(255), + 1221: uint8(255), + 1222: uint8(15), + 1224: uint8(255), + 1225: uint8(255), + 1226: uint8(15), + 1228: uint8(255), + 1229: uint8(223), + 1230: uint8(13), + 1232: uint8(255), + 1233: uint8(255), + 1234: uint8(255), + 1235: uint8(255), + 1236: uint8(255), + 1237: uint8(255), + 1238: uint8(207), + 1239: uint8(255), + 1240: uint8(255), + 1241: uint8(1), + 1242: uint8(128), + 1243: uint8(16), + 1244: uint8(255), + 1245: uint8(3), + 1250: uint8(255), + 1251: uint8(3), + 1252: uint8(255), + 1253: uint8(255), + 1254: uint8(255), + 1255: uint8(255), + 1256: uint8(255), + 1257: uint8(255), + 1258: uint8(255), + 1259: uint8(255), + 1260: uint8(255), + 1261: uint8(255), + 1262: uint8(255), + 1263: uint8(1), + 1264: uint8(255), + 1265: uint8(255), + 1266: uint8(255), + 1267: uint8(255), + 1268: uint8(255), + 1269: uint8(7), + 1270: uint8(255), + 1271: uint8(255), + 1272: uint8(255), + 1273: uint8(255), + 1274: uint8(255), + 1275: uint8(255), + 1276: uint8(255), + 1277: uint8(255), + 1278: uint8(63), + 1280: uint8(255), + 1281: uint8(255), + 1282: uint8(255), + 1283: uint8(127), + 1284: uint8(255), + 1285: uint8(15), + 1286: uint8(255), + 1287: uint8(1), + 1288: uint8(192), + 1289: uint8(255), + 1290: uint8(255), + 1291: uint8(255), + 1292: uint8(255), + 1293: uint8(63), + 1294: uint8(31), + 1296: uint8(255), + 1297: uint8(255), + 1298: uint8(255), + 1299: uint8(255), + 1300: uint8(255), + 1301: uint8(15), + 1302: uint8(255), + 1303: uint8(255), + 1304: uint8(255), + 1305: uint8(3), + 1306: uint8(255), + 1307: uint8(3), + 1312: uint8(255), + 1313: uint8(255), + 1314: uint8(255), + 1315: uint8(15), + 1316: uint8(255), + 1317: uint8(255), + 1318: uint8(255), + 1319: uint8(255), + 1320: uint8(255), + 1321: uint8(255), + 1322: uint8(255), + 1323: uint8(127), + 1324: uint8(254), + 1325: uint8(255), + 1326: uint8(31), + 1328: uint8(255), + 1329: uint8(3), + 1330: uint8(255), + 1331: uint8(3), + 1332: uint8(128), + 1344: uint8(255), + 1345: uint8(255), + 1346: uint8(255), + 1347: uint8(255), + 1348: uint8(255), + 1349: uint8(255), + 1350: uint8(239), + 1351: uint8(255), + 1352: uint8(239), + 1353: uint8(15), + 1354: uint8(255), + 1355: uint8(3), + 1360: uint8(255), + 1361: uint8(255), + 1362: uint8(255), + 1363: uint8(255), + 1364: uint8(255), + 1365: uint8(243), + 1366: uint8(255), + 1367: uint8(255), + 1368: uint8(255), + 1369: uint8(255), + 1370: uint8(255), + 1371: uint8(255), + 1372: uint8(191), + 1373: uint8(255), + 1374: uint8(3), + 1376: uint8(255), + 1377: uint8(255), + 1378: uint8(255), + 1379: uint8(255), + 1380: uint8(255), + 1381: uint8(255), + 1382: uint8(127), + 1384: uint8(255), + 1385: uint8(227), + 1386: uint8(255), + 1387: uint8(255), + 1388: uint8(255), + 1389: uint8(255), + 1390: uint8(255), + 1391: uint8(63), + 1392: uint8(255), + 1393: uint8(1), + 1394: uint8(255), + 1395: uint8(255), + 1396: uint8(255), + 1397: uint8(255), + 1398: uint8(255), + 1399: uint8(231), + 1405: uint8(222), + 1406: uint8(111), + 1407: uint8(4), + 1408: uint8(255), + 1409: uint8(255), + 1410: uint8(255), + 1411: uint8(255), + 1412: uint8(255), + 1413: uint8(255), + 1414: uint8(255), + 1415: uint8(255), + 1416: uint8(255), + 1417: uint8(255), + 1418: uint8(255), + 1419: uint8(255), + 1420: uint8(255), + 1421: uint8(255), + 1422: uint8(255), + 1423: uint8(255), + 1424: uint8(255), + 1425: uint8(255), + 1426: uint8(255), + 1427: uint8(255), + 1428: uint8(255), + 1429: uint8(255), + 1430: uint8(255), + 1431: uint8(255), + 1436: uint8(128), + 1437: uint8(255), + 1438: uint8(31), + 1440: uint8(255), + 1441: uint8(255), + 1442: uint8(63), + 1443: uint8(63), + 1444: uint8(255), + 1445: uint8(255), + 1446: uint8(255), + 1447: uint8(255), + 1448: uint8(63), + 1449: uint8(63), + 1450: uint8(255), + 1451: uint8(170), + 1452: uint8(255), + 1453: uint8(255), + 1454: uint8(255), + 1455: uint8(63), + 1456: uint8(255), + 1457: uint8(255), + 1458: uint8(255), + 1459: uint8(255), + 1460: uint8(255), + 1461: uint8(255), + 1462: uint8(223), + 1463: uint8(95), + 1464: uint8(220), + 1465: uint8(31), + 1466: uint8(207), + 1467: uint8(15), + 1468: uint8(255), + 1469: uint8(31), + 1470: uint8(220), + 1471: uint8(31), + 1486: uint8(2), + 1487: uint8(128), + 1490: uint8(255), + 1491: uint8(31), + 1504: uint8(132), + 1505: uint8(252), + 1506: uint8(47), + 1507: uint8(62), + 1508: uint8(80), + 1509: uint8(189), + 1510: uint8(255), + 1511: uint8(243), + 1512: uint8(224), + 1513: uint8(67), + 1516: uint8(255), + 1517: uint8(255), + 1518: uint8(255), + 1519: uint8(255), + 1520: uint8(255), + 1521: uint8(1), + 1558: uint8(192), + 1559: uint8(255), + 1560: uint8(255), + 1561: uint8(255), + 1562: uint8(255), + 1563: uint8(255), + 1564: uint8(255), + 1565: uint8(3), + 1568: uint8(255), + 1569: uint8(255), + 1570: uint8(255), + 1571: uint8(255), + 1572: uint8(255), + 1573: uint8(127), + 1574: uint8(255), + 1575: uint8(255), + 1576: uint8(255), + 1577: uint8(255), + 1578: uint8(255), + 1579: uint8(127), + 1580: uint8(255), + 1581: uint8(255), + 1582: uint8(255), + 1583: uint8(255), + 1584: uint8(255), + 1585: uint8(255), + 1586: uint8(255), + 1587: uint8(255), + 1588: uint8(255), + 1589: uint8(255), + 1590: uint8(255), + 1591: uint8(255), + 1592: uint8(255), + 1593: uint8(255), + 1594: uint8(255), + 1595: uint8(255), + 1596: uint8(31), + 1597: uint8(120), + 1598: uint8(12), + 1600: uint8(255), + 1601: uint8(255), + 1602: uint8(255), + 1603: uint8(255), + 1604: uint8(191), + 1605: uint8(32), + 1606: uint8(255), + 1607: uint8(255), + 1608: uint8(255), + 1609: uint8(255), + 1610: uint8(255), + 1611: uint8(255), + 1612: uint8(255), + 1613: uint8(128), + 1616: uint8(255), + 1617: uint8(255), + 1618: uint8(127), + 1620: uint8(127), + 1621: uint8(127), + 1622: uint8(127), + 1623: uint8(127), + 1624: uint8(127), + 1625: uint8(127), + 1626: uint8(127), + 1627: uint8(127), + 1628: uint8(255), + 1629: uint8(255), + 1630: uint8(255), + 1631: uint8(255), + 1637: uint8(128), + 1664: uint8(224), + 1668: uint8(254), + 1669: uint8(3), + 1670: uint8(62), + 1671: uint8(31), + 1672: uint8(254), + 1673: uint8(255), + 1674: uint8(255), + 1675: uint8(255), + 1676: uint8(255), + 1677: uint8(255), + 1678: uint8(255), + 1679: uint8(255), + 1680: uint8(255), + 1681: uint8(255), + 1682: uint8(127), + 1683: uint8(224), + 1684: uint8(254), + 1685: uint8(255), + 1686: uint8(255), + 1687: uint8(255), + 1688: uint8(255), + 1689: uint8(255), + 1690: uint8(255), + 1691: uint8(255), + 1692: uint8(255), + 1693: uint8(255), + 1694: uint8(255), + 1695: uint8(247), + 1696: uint8(224), + 1697: uint8(255), + 1698: uint8(255), + 1699: uint8(255), + 1700: uint8(255), + 1701: uint8(255), + 1702: uint8(254), + 1703: uint8(255), + 1704: uint8(255), + 1705: uint8(255), + 1706: uint8(255), + 1707: uint8(255), + 1708: uint8(255), + 1709: uint8(255), + 1710: uint8(255), + 1711: uint8(255), + 1712: uint8(255), + 1713: uint8(127), + 1716: uint8(255), + 1717: uint8(255), + 1718: uint8(255), + 1719: uint8(7), + 1726: uint8(255), + 1727: uint8(255), + 1728: uint8(255), + 1729: uint8(255), + 1730: uint8(255), + 1731: uint8(255), + 1732: uint8(255), + 1733: uint8(255), + 1734: uint8(255), + 1735: uint8(255), + 1736: uint8(255), + 1737: uint8(255), + 1738: uint8(255), + 1739: uint8(255), + 1740: uint8(255), + 1741: uint8(255), + 1742: uint8(255), + 1743: uint8(255), + 1744: uint8(255), + 1745: uint8(255), + 1746: uint8(255), + 1747: uint8(255), + 1748: uint8(255), + 1749: uint8(255), + 1750: uint8(63), + 1760: uint8(255), + 1761: uint8(255), + 1762: uint8(255), + 1763: uint8(255), + 1764: uint8(255), + 1765: uint8(255), + 1766: uint8(255), + 1767: uint8(255), + 1768: uint8(255), + 1769: uint8(255), + 1770: uint8(255), + 1771: uint8(255), + 1772: uint8(255), + 1773: uint8(255), + 1774: uint8(255), + 1775: uint8(255), + 1776: uint8(255), + 1777: uint8(255), + 1778: uint8(255), + 1779: uint8(255), + 1780: uint8(255), + 1781: uint8(255), + 1782: uint8(255), + 1783: uint8(255), + 1784: uint8(255), + 1785: uint8(255), + 1786: uint8(255), + 1787: uint8(255), + 1788: uint8(255), + 1789: uint8(255), + 1792: uint8(255), + 1793: uint8(255), + 1794: uint8(255), + 1795: uint8(255), + 1796: uint8(255), + 1797: uint8(255), + 1798: uint8(255), + 1799: uint8(255), + 1800: uint8(255), + 1801: uint8(255), + 1802: uint8(255), + 1803: uint8(255), + 1804: uint8(255), + 1805: uint8(255), + 1806: uint8(255), + 1807: uint8(255), + 1808: uint8(255), + 1809: uint8(31), + 1818: uint8(255), + 1819: uint8(255), + 1820: uint8(255), + 1821: uint8(255), + 1822: uint8(255), + 1823: uint8(63), + 1824: uint8(255), + 1825: uint8(31), + 1826: uint8(255), + 1827: uint8(255), + 1828: uint8(255), + 1829: uint8(15), + 1832: uint8(255), + 1833: uint8(255), + 1834: uint8(255), + 1835: uint8(255), + 1836: uint8(255), + 1837: uint8(127), + 1838: uint8(240), + 1839: uint8(143), + 1840: uint8(255), + 1841: uint8(255), + 1842: uint8(255), + 1843: uint8(255), + 1844: uint8(255), + 1845: uint8(255), + 1846: uint8(255), + 1847: uint8(255), + 1848: uint8(255), + 1849: uint8(255), + 1850: uint8(255), + 1851: uint8(255), + 1852: uint8(255), + 1853: uint8(255), + 1858: uint8(128), + 1859: uint8(255), + 1860: uint8(252), + 1861: uint8(255), + 1862: uint8(255), + 1863: uint8(255), + 1864: uint8(255), + 1865: uint8(255), + 1866: uint8(255), + 1867: uint8(255), + 1868: uint8(255), + 1869: uint8(255), + 1870: uint8(255), + 1871: uint8(255), + 1872: uint8(255), + 1873: uint8(249), + 1874: uint8(255), + 1875: uint8(255), + 1876: uint8(255), + 1877: uint8(255), + 1878: uint8(255), + 1879: uint8(255), + 1880: uint8(124), + 1886: uint8(128), + 1887: uint8(255), + 1888: uint8(191), + 1889: uint8(255), + 1890: uint8(255), + 1891: uint8(255), + 1892: uint8(255), + 1896: uint8(255), + 1897: uint8(255), + 1898: uint8(255), + 1899: uint8(255), + 1900: uint8(255), + 1901: uint8(255), + 1902: uint8(15), + 1904: uint8(255), + 1905: uint8(255), + 1906: uint8(255), + 1907: uint8(255), + 1908: uint8(255), + 1909: uint8(255), + 1910: uint8(255), + 1911: uint8(255), + 1912: uint8(47), + 1914: uint8(255), + 1915: uint8(3), + 1918: uint8(252), + 1919: uint8(232), + 1920: uint8(255), + 1921: uint8(255), + 1922: uint8(255), + 1923: uint8(255), + 1924: uint8(255), + 1925: uint8(7), + 1926: uint8(255), + 1927: uint8(255), + 1928: uint8(255), + 1929: uint8(255), + 1930: uint8(7), + 1932: uint8(255), + 1933: uint8(255), + 1934: uint8(255), + 1935: uint8(31), + 1936: uint8(255), + 1937: uint8(255), + 1938: uint8(255), + 1939: uint8(255), + 1940: uint8(255), + 1941: uint8(255), + 1942: uint8(247), + 1943: uint8(255), + 1945: uint8(128), + 1946: uint8(255), + 1947: uint8(3), + 1948: uint8(255), + 1949: uint8(255), + 1950: uint8(255), + 1951: uint8(127), + 1952: uint8(255), + 1953: uint8(255), + 1954: uint8(255), + 1955: uint8(255), + 1956: uint8(255), + 1957: uint8(255), + 1958: uint8(127), + 1960: uint8(255), + 1961: uint8(63), + 1962: uint8(255), + 1963: uint8(3), + 1964: uint8(255), + 1965: uint8(255), + 1966: uint8(127), + 1967: uint8(252), + 1968: uint8(255), + 1969: uint8(255), + 1970: uint8(255), + 1971: uint8(255), + 1972: uint8(255), + 1973: uint8(255), + 1974: uint8(255), + 1975: uint8(127), + 1976: uint8(5), + 1979: uint8(56), + 1980: uint8(255), + 1981: uint8(255), + 1982: uint8(60), + 1984: uint8(126), + 1985: uint8(126), + 1986: uint8(126), + 1988: uint8(127), + 1989: uint8(127), + 1990: uint8(255), + 1991: uint8(255), + 1992: uint8(255), + 1993: uint8(255), + 1994: uint8(255), + 1995: uint8(247), + 1996: uint8(255), + 1998: uint8(255), + 1999: uint8(255), + 2000: uint8(255), + 2001: uint8(255), + 2002: uint8(255), + 2003: uint8(255), + 2004: uint8(255), + 2005: uint8(255), + 2006: uint8(255), + 2007: uint8(255), + 2008: uint8(255), + 2009: uint8(255), + 2010: uint8(255), + 2011: uint8(255), + 2012: uint8(255), + 2013: uint8(7), + 2014: uint8(255), + 2015: uint8(3), + 2016: uint8(255), + 2017: uint8(255), + 2018: uint8(255), + 2019: uint8(255), + 2020: uint8(255), + 2021: uint8(255), + 2022: uint8(255), + 2023: uint8(255), + 2024: uint8(255), + 2025: uint8(255), + 2026: uint8(255), + 2027: uint8(255), + 2028: uint8(255), + 2029: uint8(255), + 2030: uint8(255), + 2031: uint8(255), + 2032: uint8(255), + 2033: uint8(255), + 2034: uint8(255), + 2035: uint8(255), + 2036: uint8(15), + 2038: uint8(255), + 2039: uint8(255), + 2040: uint8(127), + 2041: uint8(248), + 2042: uint8(255), + 2043: uint8(255), + 2044: uint8(255), + 2045: uint8(255), + 2046: uint8(255), + 2047: uint8(15), + 2048: uint8(255), + 2049: uint8(255), + 2050: uint8(255), + 2051: uint8(255), + 2052: uint8(255), + 2053: uint8(255), + 2054: uint8(255), + 2055: uint8(255), + 2056: uint8(255), + 2057: uint8(255), + 2058: uint8(255), + 2059: uint8(255), + 2060: uint8(255), + 2061: uint8(63), + 2062: uint8(255), + 2063: uint8(255), + 2064: uint8(255), + 2065: uint8(255), + 2066: uint8(255), + 2067: uint8(255), + 2068: uint8(255), + 2069: uint8(255), + 2070: uint8(255), + 2071: uint8(255), + 2072: uint8(255), + 2073: uint8(255), + 2074: uint8(255), + 2075: uint8(3), + 2080: uint8(127), + 2082: uint8(248), + 2083: uint8(224), + 2084: uint8(255), + 2085: uint8(253), + 2086: uint8(127), + 2087: uint8(95), + 2088: uint8(219), + 2089: uint8(255), + 2090: uint8(255), + 2091: uint8(255), + 2092: uint8(255), + 2093: uint8(255), + 2094: uint8(255), + 2095: uint8(255), + 2096: uint8(255), + 2097: uint8(255), + 2098: uint8(255), + 2099: uint8(255), + 2100: uint8(255), + 2101: uint8(255), + 2102: uint8(3), + 2106: uint8(248), + 2107: uint8(255), + 2108: uint8(255), + 2109: uint8(255), + 2110: uint8(255), + 2111: uint8(255), + 2112: uint8(255), + 2113: uint8(255), + 2114: uint8(255), + 2115: uint8(255), + 2116: uint8(255), + 2117: uint8(255), + 2118: uint8(255), + 2119: uint8(63), + 2122: uint8(255), + 2123: uint8(255), + 2124: uint8(255), + 2125: uint8(255), + 2126: uint8(255), + 2127: uint8(255), + 2128: uint8(255), + 2129: uint8(255), + 2130: uint8(252), + 2131: uint8(255), + 2132: uint8(255), + 2133: uint8(255), + 2134: uint8(255), + 2135: uint8(255), + 2136: uint8(255), + 2142: uint8(255), + 2143: uint8(15), + 2158: uint8(223), + 2159: uint8(255), + 2160: uint8(255), + 2161: uint8(255), + 2162: uint8(255), + 2163: uint8(255), + 2164: uint8(255), + 2165: uint8(255), + 2166: uint8(255), + 2167: uint8(255), + 2168: uint8(255), + 2169: uint8(255), + 2170: uint8(255), + 2171: uint8(255), + 2172: uint8(255), + 2173: uint8(255), + 2174: uint8(255), + 2175: uint8(31), + 2178: uint8(255), + 2179: uint8(3), + 2180: uint8(254), + 2181: uint8(255), + 2182: uint8(255), + 2183: uint8(7), + 2184: uint8(254), + 2185: uint8(255), + 2186: uint8(255), + 2187: uint8(7), + 2188: uint8(192), + 2189: uint8(255), + 2190: uint8(255), + 2191: uint8(255), + 2192: uint8(255), + 2193: uint8(255), + 2194: uint8(255), + 2195: uint8(255), + 2196: uint8(255), + 2197: uint8(255), + 2198: uint8(255), + 2199: uint8(127), + 2200: uint8(252), + 2201: uint8(252), + 2202: uint8(252), + 2203: uint8(28), + 2208: uint8(255), + 2209: uint8(239), + 2210: uint8(255), + 2211: uint8(255), + 2212: uint8(127), + 2213: uint8(255), + 2214: uint8(255), + 2215: uint8(183), + 2216: uint8(255), + 2217: uint8(63), + 2218: uint8(255), + 2219: uint8(63), + 2224: uint8(255), + 2225: uint8(255), + 2226: uint8(255), + 2227: uint8(255), + 2228: uint8(255), + 2229: uint8(255), + 2230: uint8(255), + 2231: uint8(255), + 2232: uint8(255), + 2233: uint8(255), + 2234: uint8(255), + 2235: uint8(255), + 2236: uint8(255), + 2237: uint8(255), + 2238: uint8(255), + 2239: uint8(7), + 2248: uint8(255), + 2249: uint8(255), + 2250: uint8(255), + 2251: uint8(255), + 2252: uint8(255), + 2253: uint8(255), + 2254: uint8(31), + 2288: uint8(255), + 2289: uint8(255), + 2290: uint8(255), + 2291: uint8(31), + 2292: uint8(255), + 2293: uint8(255), + 2294: uint8(255), + 2295: uint8(255), + 2296: uint8(255), + 2297: uint8(255), + 2298: uint8(1), + 2304: uint8(255), + 2305: uint8(255), + 2306: uint8(255), + 2307: uint8(255), + 2309: uint8(224), + 2310: uint8(255), + 2311: uint8(255), + 2312: uint8(255), + 2313: uint8(7), + 2314: uint8(255), + 2315: uint8(255), + 2316: uint8(255), + 2317: uint8(255), + 2318: uint8(255), + 2319: uint8(7), + 2320: uint8(255), + 2321: uint8(255), + 2322: uint8(255), + 2323: uint8(63), + 2324: uint8(255), + 2325: uint8(255), + 2326: uint8(255), + 2327: uint8(255), + 2328: uint8(15), + 2329: uint8(255), + 2330: uint8(62), + 2336: uint8(255), + 2337: uint8(255), + 2338: uint8(255), + 2339: uint8(255), + 2340: uint8(255), + 2341: uint8(255), + 2342: uint8(255), + 2343: uint8(255), + 2344: uint8(255), + 2345: uint8(255), + 2346: uint8(255), + 2347: uint8(255), + 2348: uint8(255), + 2349: uint8(255), + 2350: uint8(255), + 2351: uint8(255), + 2352: uint8(255), + 2353: uint8(255), + 2354: uint8(255), + 2355: uint8(63), + 2356: uint8(255), + 2357: uint8(3), + 2358: uint8(255), + 2359: uint8(255), + 2360: uint8(255), + 2361: uint8(255), + 2362: uint8(15), + 2363: uint8(255), + 2364: uint8(255), + 2365: uint8(255), + 2366: uint8(255), + 2367: uint8(15), + 2368: uint8(255), + 2369: uint8(255), + 2370: uint8(255), + 2371: uint8(255), + 2372: uint8(255), + 2374: uint8(255), + 2375: uint8(255), + 2376: uint8(255), + 2377: uint8(255), + 2378: uint8(255), + 2379: uint8(255), + 2380: uint8(15), + 2400: uint8(255), + 2401: uint8(255), + 2402: uint8(255), + 2403: uint8(255), + 2404: uint8(255), + 2405: uint8(255), + 2406: uint8(127), + 2408: uint8(255), + 2409: uint8(255), + 2410: uint8(63), + 2412: uint8(255), + 2432: uint8(63), + 2433: uint8(253), + 2434: uint8(255), + 2435: uint8(255), + 2436: uint8(255), + 2437: uint8(255), + 2438: uint8(191), + 2439: uint8(145), + 2440: uint8(255), + 2441: uint8(255), + 2442: uint8(63), + 2444: uint8(255), + 2445: uint8(255), + 2446: uint8(127), + 2448: uint8(255), + 2449: uint8(255), + 2450: uint8(255), + 2451: uint8(127), + 2460: uint8(255), + 2461: uint8(255), + 2462: uint8(55), + 2464: uint8(255), + 2465: uint8(255), + 2466: uint8(63), + 2468: uint8(255), + 2469: uint8(255), + 2470: uint8(255), + 2471: uint8(3), + 2480: uint8(255), + 2481: uint8(255), + 2482: uint8(255), + 2483: uint8(255), + 2484: uint8(255), + 2485: uint8(255), + 2486: uint8(255), + 2487: uint8(192), + 2496: uint8(111), + 2497: uint8(240), + 2498: uint8(239), + 2499: uint8(254), + 2500: uint8(255), + 2501: uint8(255), + 2502: uint8(63), + 2508: uint8(255), + 2509: uint8(255), + 2510: uint8(255), + 2511: uint8(31), + 2512: uint8(255), + 2513: uint8(255), + 2514: uint8(255), + 2515: uint8(31), + 2520: uint8(255), + 2521: uint8(254), + 2522: uint8(255), + 2523: uint8(255), + 2524: uint8(31), + 2528: uint8(255), + 2529: uint8(255), + 2530: uint8(255), + 2531: uint8(255), + 2532: uint8(255), + 2533: uint8(255), + 2534: uint8(63), + 2536: uint8(255), + 2537: uint8(255), + 2538: uint8(63), + 2540: uint8(255), + 2541: uint8(255), + 2542: uint8(7), + 2544: uint8(255), + 2545: uint8(255), + 2546: uint8(3), + 2560: uint8(255), + 2561: uint8(255), + 2562: uint8(255), + 2563: uint8(255), + 2564: uint8(255), + 2565: uint8(255), + 2566: uint8(255), + 2567: uint8(255), + 2568: uint8(255), + 2569: uint8(1), + 2576: uint8(255), + 2577: uint8(255), + 2578: uint8(255), + 2579: uint8(255), + 2580: uint8(255), + 2581: uint8(255), + 2582: uint8(7), + 2584: uint8(255), + 2585: uint8(255), + 2586: uint8(255), + 2587: uint8(255), + 2588: uint8(255), + 2589: uint8(255), + 2590: uint8(7), + 2592: uint8(255), + 2593: uint8(255), + 2594: uint8(255), + 2595: uint8(255), + 2596: uint8(255), + 2598: uint8(255), + 2599: uint8(3), + 2624: uint8(255), + 2625: uint8(255), + 2626: uint8(255), + 2627: uint8(31), + 2628: uint8(128), + 2630: uint8(255), + 2631: uint8(255), + 2632: uint8(63), + 2652: uint8(255), + 2653: uint8(255), + 2654: uint8(127), + 2656: uint8(255), + 2657: uint8(255), + 2658: uint8(255), + 2659: uint8(255), + 2660: uint8(255), + 2661: uint8(255), + 2662: uint8(255), + 2663: uint8(255), + 2664: uint8(63), + 2668: uint8(192), + 2669: uint8(255), + 2672: uint8(252), + 2673: uint8(255), + 2674: uint8(255), + 2675: uint8(255), + 2676: uint8(255), + 2677: uint8(255), + 2678: uint8(255), + 2679: uint8(1), + 2682: uint8(255), + 2683: uint8(255), + 2684: uint8(255), + 2685: uint8(1), + 2686: uint8(255), + 2687: uint8(3), + 2688: uint8(255), + 2689: uint8(255), + 2690: uint8(255), + 2691: uint8(255), + 2692: uint8(255), + 2693: uint8(255), + 2694: uint8(199), + 2695: uint8(255), + 2696: uint8(112), + 2698: uint8(255), + 2699: uint8(255), + 2700: uint8(255), + 2701: uint8(255), + 2702: uint8(71), + 2704: uint8(255), + 2705: uint8(255), + 2706: uint8(255), + 2707: uint8(255), + 2708: uint8(255), + 2709: uint8(255), + 2710: uint8(255), + 2711: uint8(255), + 2712: uint8(30), + 2714: uint8(255), + 2715: uint8(23), + 2720: uint8(255), + 2721: uint8(255), + 2722: uint8(251), + 2723: uint8(255), + 2724: uint8(255), + 2725: uint8(255), + 2726: uint8(159), + 2727: uint8(64), + 2736: uint8(127), + 2737: uint8(189), + 2738: uint8(255), + 2739: uint8(191), + 2740: uint8(255), + 2741: uint8(1), + 2742: uint8(255), + 2743: uint8(255), + 2744: uint8(255), + 2745: uint8(255), + 2746: uint8(255), + 2747: uint8(255), + 2748: uint8(255), + 2749: uint8(1), + 2750: uint8(255), + 2751: uint8(3), + 2752: uint8(239), + 2753: uint8(159), + 2754: uint8(249), + 2755: uint8(255), + 2756: uint8(255), + 2757: uint8(253), + 2758: uint8(237), + 2759: uint8(227), + 2760: uint8(159), + 2761: uint8(25), + 2762: uint8(129), + 2763: uint8(224), + 2764: uint8(15), + 2784: uint8(255), + 2785: uint8(255), + 2786: uint8(255), + 2787: uint8(255), + 2788: uint8(255), + 2789: uint8(255), + 2790: uint8(255), + 2791: uint8(255), + 2792: uint8(187), + 2793: uint8(7), + 2794: uint8(255), + 2795: uint8(131), + 2800: uint8(255), + 2801: uint8(255), + 2802: uint8(255), + 2803: uint8(255), + 2804: uint8(255), + 2805: uint8(255), + 2806: uint8(255), + 2807: uint8(255), + 2808: uint8(179), + 2810: uint8(255), + 2811: uint8(3), + 2832: uint8(255), + 2833: uint8(255), + 2834: uint8(255), + 2835: uint8(255), + 2836: uint8(255), + 2837: uint8(255), + 2838: uint8(63), + 2839: uint8(127), + 2843: uint8(63), + 2848: uint8(255), + 2849: uint8(255), + 2850: uint8(255), + 2851: uint8(255), + 2852: uint8(255), + 2853: uint8(255), + 2854: uint8(255), + 2855: uint8(127), + 2856: uint8(17), + 2858: uint8(255), + 2859: uint8(3), + 2864: uint8(255), + 2865: uint8(255), + 2866: uint8(255), + 2867: uint8(255), + 2868: uint8(255), + 2869: uint8(255), + 2870: uint8(63), + 2871: uint8(1), + 2872: uint8(255), + 2873: uint8(3), + 2880: uint8(255), + 2881: uint8(255), + 2882: uint8(255), + 2883: uint8(231), + 2884: uint8(255), + 2885: uint8(7), + 2886: uint8(255), + 2887: uint8(3), + 2912: uint8(255), + 2913: uint8(255), + 2914: uint8(255), + 2915: uint8(255), + 2916: uint8(255), + 2917: uint8(255), + 2918: uint8(255), + 2919: uint8(1), + 2932: uint8(255), + 2933: uint8(255), + 2934: uint8(255), + 2935: uint8(255), + 2936: uint8(255), + 2937: uint8(255), + 2938: uint8(255), + 2939: uint8(255), + 2940: uint8(255), + 2941: uint8(3), + 2943: uint8(128), + 2964: uint8(255), + 2965: uint8(252), + 2966: uint8(255), + 2967: uint8(255), + 2968: uint8(255), + 2969: uint8(255), + 2970: uint8(255), + 2971: uint8(252), + 2972: uint8(26), + 2976: uint8(255), + 2977: uint8(255), + 2978: uint8(255), + 2979: uint8(255), + 2980: uint8(255), + 2981: uint8(255), + 2982: uint8(231), + 2983: uint8(127), + 2986: uint8(255), + 2987: uint8(255), + 2988: uint8(255), + 2989: uint8(255), + 2990: uint8(255), + 2991: uint8(255), + 2992: uint8(255), + 2993: uint8(255), + 2994: uint8(255), + 2995: uint8(32), + 3000: uint8(255), + 3001: uint8(255), + 3002: uint8(255), + 3003: uint8(255), + 3004: uint8(255), + 3005: uint8(255), + 3006: uint8(255), + 3007: uint8(1), + 3008: uint8(255), + 3009: uint8(253), + 3010: uint8(255), + 3011: uint8(255), + 3012: uint8(255), + 3013: uint8(255), + 3014: uint8(127), + 3015: uint8(127), + 3016: uint8(1), + 3018: uint8(255), + 3019: uint8(3), + 3022: uint8(252), + 3023: uint8(255), + 3024: uint8(255), + 3025: uint8(255), + 3026: uint8(252), + 3027: uint8(255), + 3028: uint8(255), + 3029: uint8(254), + 3030: uint8(127), + 3040: uint8(127), + 3041: uint8(251), + 3042: uint8(255), + 3043: uint8(255), + 3044: uint8(255), + 3045: uint8(255), + 3046: uint8(127), + 3047: uint8(180), + 3048: uint8(203), + 3050: uint8(255), + 3051: uint8(3), + 3052: uint8(191), + 3053: uint8(253), + 3054: uint8(255), + 3055: uint8(255), + 3056: uint8(255), + 3057: uint8(127), + 3058: uint8(123), + 3059: uint8(1), + 3060: uint8(255), + 3061: uint8(3), + 3100: uint8(255), + 3101: uint8(255), + 3102: uint8(127), + 3104: uint8(255), + 3105: uint8(255), + 3106: uint8(255), + 3107: uint8(255), + 3108: uint8(255), + 3109: uint8(255), + 3110: uint8(255), + 3111: uint8(255), + 3112: uint8(255), + 3113: uint8(255), + 3114: uint8(255), + 3115: uint8(255), + 3116: uint8(255), + 3117: uint8(255), + 3118: uint8(255), + 3119: uint8(255), + 3120: uint8(255), + 3121: uint8(255), + 3122: uint8(255), + 3123: uint8(3), + 3136: uint8(255), + 3137: uint8(255), + 3138: uint8(255), + 3139: uint8(255), + 3140: uint8(255), + 3141: uint8(255), + 3142: uint8(255), + 3143: uint8(255), + 3144: uint8(255), + 3145: uint8(255), + 3146: uint8(255), + 3147: uint8(255), + 3148: uint8(255), + 3149: uint8(127), + 3152: uint8(255), + 3153: uint8(255), + 3154: uint8(255), + 3155: uint8(255), + 3156: uint8(255), + 3157: uint8(255), + 3158: uint8(255), + 3159: uint8(255), + 3160: uint8(255), + 3161: uint8(255), + 3162: uint8(255), + 3163: uint8(255), + 3164: uint8(255), + 3165: uint8(255), + 3166: uint8(255), + 3167: uint8(255), + 3168: uint8(255), + 3169: uint8(255), + 3170: uint8(255), + 3171: uint8(255), + 3172: uint8(255), + 3173: uint8(255), + 3174: uint8(255), + 3175: uint8(255), + 3176: uint8(15), + 3200: uint8(255), + 3201: uint8(255), + 3202: uint8(255), + 3203: uint8(255), + 3204: uint8(255), + 3205: uint8(127), + 3232: uint8(255), + 3233: uint8(255), + 3234: uint8(255), + 3235: uint8(255), + 3236: uint8(255), + 3237: uint8(255), + 3238: uint8(255), + 3239: uint8(255), + 3240: uint8(127), + 3264: uint8(255), + 3265: uint8(255), + 3266: uint8(255), + 3267: uint8(255), + 3268: uint8(255), + 3269: uint8(255), + 3270: uint8(255), + 3271: uint8(1), + 3272: uint8(255), + 3273: uint8(255), + 3274: uint8(255), + 3275: uint8(127), + 3276: uint8(255), + 3277: uint8(3), + 3290: uint8(255), + 3291: uint8(255), + 3292: uint8(255), + 3293: uint8(63), + 3296: uint8(255), + 3297: uint8(255), + 3298: uint8(255), + 3299: uint8(255), + 3300: uint8(255), + 3301: uint8(255), + 3304: uint8(15), + 3306: uint8(255), + 3307: uint8(3), + 3308: uint8(248), + 3309: uint8(255), + 3310: uint8(255), + 3311: uint8(224), + 3312: uint8(255), + 3313: uint8(255), + 3336: uint8(255), + 3337: uint8(255), + 3338: uint8(255), + 3339: uint8(255), + 3340: uint8(255), + 3341: uint8(255), + 3342: uint8(255), + 3343: uint8(255), + 3360: uint8(255), + 3361: uint8(255), + 3362: uint8(255), + 3363: uint8(255), + 3364: uint8(255), + 3365: uint8(255), + 3366: uint8(255), + 3367: uint8(255), + 3368: uint8(255), + 3369: uint8(135), + 3370: uint8(255), + 3371: uint8(255), + 3372: uint8(255), + 3373: uint8(255), + 3374: uint8(255), + 3375: uint8(255), + 3376: uint8(255), + 3377: uint8(128), + 3378: uint8(255), + 3379: uint8(255), + 3388: uint8(11), + 3392: uint8(255), + 3393: uint8(255), + 3394: uint8(255), + 3395: uint8(255), + 3396: uint8(255), + 3397: uint8(255), + 3398: uint8(255), + 3399: uint8(255), + 3400: uint8(255), + 3401: uint8(255), + 3402: uint8(255), + 3403: uint8(255), + 3404: uint8(255), + 3405: uint8(255), + 3406: uint8(255), + 3407: uint8(255), + 3408: uint8(255), + 3409: uint8(255), + 3410: uint8(255), + 3411: uint8(255), + 3412: uint8(255), + 3413: uint8(255), + 3414: uint8(255), + 3415: uint8(255), + 3416: uint8(255), + 3417: uint8(255), + 3418: uint8(255), + 3419: uint8(255), + 3420: uint8(255), + 3421: uint8(255), + 3422: uint8(255), + 3424: uint8(255), + 3425: uint8(255), + 3426: uint8(255), + 3427: uint8(255), + 3428: uint8(255), + 3429: uint8(255), + 3430: uint8(255), + 3431: uint8(255), + 3432: uint8(255), + 3433: uint8(255), + 3434: uint8(255), + 3435: uint8(255), + 3436: uint8(255), + 3437: uint8(255), + 3438: uint8(255), + 3439: uint8(255), + 3440: uint8(255), + 3441: uint8(255), + 3442: uint8(255), + 3443: uint8(255), + 3444: uint8(255), + 3445: uint8(255), + 3446: uint8(255), + 3447: uint8(255), + 3448: uint8(255), + 3449: uint8(255), + 3450: uint8(255), + 3451: uint8(255), + 3452: uint8(255), + 3453: uint8(255), + 3454: uint8(7), + 3456: uint8(255), + 3457: uint8(255), + 3458: uint8(255), + 3459: uint8(127), + 3466: uint8(7), + 3468: uint8(240), + 3470: uint8(255), + 3471: uint8(255), + 3472: uint8(255), + 3473: uint8(255), + 3474: uint8(255), + 3475: uint8(255), + 3476: uint8(255), + 3477: uint8(255), + 3478: uint8(255), + 3479: uint8(255), + 3480: uint8(255), + 3481: uint8(255), + 3482: uint8(255), + 3483: uint8(255), + 3484: uint8(255), + 3485: uint8(255), + 3486: uint8(255), + 3487: uint8(255), + 3488: uint8(255), + 3489: uint8(255), + 3490: uint8(255), + 3491: uint8(255), + 3492: uint8(255), + 3493: uint8(255), + 3494: uint8(255), + 3495: uint8(255), + 3496: uint8(255), + 3497: uint8(255), + 3498: uint8(255), + 3499: uint8(255), + 3500: uint8(255), + 3501: uint8(255), + 3502: uint8(255), + 3503: uint8(255), + 3504: uint8(255), + 3505: uint8(255), + 3506: uint8(255), + 3507: uint8(255), + 3508: uint8(255), + 3509: uint8(255), + 3510: uint8(255), + 3511: uint8(255), + 3512: uint8(255), + 3513: uint8(255), + 3514: uint8(255), + 3515: uint8(255), + 3516: uint8(255), + 3517: uint8(255), + 3518: uint8(255), + 3519: uint8(15), + 3520: uint8(255), + 3521: uint8(255), + 3522: uint8(255), + 3523: uint8(255), + 3524: uint8(255), + 3525: uint8(255), + 3526: uint8(255), + 3527: uint8(255), + 3528: uint8(255), + 3529: uint8(255), + 3530: uint8(255), + 3531: uint8(255), + 3532: uint8(255), + 3533: uint8(7), + 3534: uint8(255), + 3535: uint8(31), + 3536: uint8(255), + 3537: uint8(1), + 3538: uint8(255), + 3539: uint8(67), + 3552: uint8(255), + 3553: uint8(255), + 3554: uint8(255), + 3555: uint8(255), + 3556: uint8(255), + 3557: uint8(255), + 3558: uint8(255), + 3559: uint8(255), + 3560: uint8(255), + 3561: uint8(255), + 3562: uint8(223), + 3563: uint8(255), + 3564: uint8(255), + 3565: uint8(255), + 3566: uint8(255), + 3567: uint8(255), + 3568: uint8(255), + 3569: uint8(255), + 3570: uint8(255), + 3571: uint8(223), + 3572: uint8(100), + 3573: uint8(222), + 3574: uint8(255), + 3575: uint8(235), + 3576: uint8(239), + 3577: uint8(255), + 3578: uint8(255), + 3579: uint8(255), + 3580: uint8(255), + 3581: uint8(255), + 3582: uint8(255), + 3583: uint8(255), + 3584: uint8(191), + 3585: uint8(231), + 3586: uint8(223), + 3587: uint8(223), + 3588: uint8(255), + 3589: uint8(255), + 3590: uint8(255), + 3591: uint8(123), + 3592: uint8(95), + 3593: uint8(252), + 3594: uint8(253), + 3595: uint8(255), + 3596: uint8(255), + 3597: uint8(255), + 3598: uint8(255), + 3599: uint8(255), + 3600: uint8(255), + 3601: uint8(255), + 3602: uint8(255), + 3603: uint8(255), + 3604: uint8(255), + 3605: uint8(255), + 3606: uint8(255), + 3607: uint8(255), + 3608: uint8(255), + 3609: uint8(255), + 3610: uint8(255), + 3611: uint8(255), + 3612: uint8(255), + 3613: uint8(255), + 3614: uint8(255), + 3615: uint8(255), + 3616: uint8(255), + 3617: uint8(255), + 3618: uint8(255), + 3619: uint8(255), + 3620: uint8(255), + 3621: uint8(255), + 3622: uint8(255), + 3623: uint8(255), + 3624: uint8(255), + 3625: uint8(255), + 3626: uint8(255), + 3627: uint8(255), + 3628: uint8(255), + 3629: uint8(255), + 3630: uint8(255), + 3631: uint8(255), + 3632: uint8(255), + 3633: uint8(255), + 3634: uint8(255), + 3635: uint8(255), + 3636: uint8(63), + 3637: uint8(255), + 3638: uint8(255), + 3639: uint8(255), + 3640: uint8(253), + 3641: uint8(255), + 3642: uint8(255), + 3643: uint8(247), + 3644: uint8(255), + 3645: uint8(255), + 3646: uint8(255), + 3647: uint8(247), + 3648: uint8(255), + 3649: uint8(255), + 3650: uint8(223), + 3651: uint8(255), + 3652: uint8(255), + 3653: uint8(255), + 3654: uint8(223), + 3655: uint8(255), + 3656: uint8(255), + 3657: uint8(127), + 3658: uint8(255), + 3659: uint8(255), + 3660: uint8(255), + 3661: uint8(127), + 3662: uint8(255), + 3663: uint8(255), + 3664: uint8(255), + 3665: uint8(253), + 3666: uint8(255), + 3667: uint8(255), + 3668: uint8(255), + 3669: uint8(253), + 3670: uint8(255), + 3671: uint8(255), + 3672: uint8(247), + 3673: uint8(207), + 3674: uint8(255), + 3675: uint8(255), + 3676: uint8(255), + 3677: uint8(255), + 3678: uint8(255), + 3679: uint8(255), + 3680: uint8(127), + 3681: uint8(255), + 3682: uint8(255), + 3683: uint8(249), + 3684: uint8(219), + 3685: uint8(7), + 3712: uint8(255), + 3713: uint8(255), + 3714: uint8(255), + 3715: uint8(255), + 3716: uint8(255), + 3717: uint8(31), + 3718: uint8(128), + 3719: uint8(63), + 3720: uint8(255), + 3721: uint8(67), + 3768: uint8(255), + 3769: uint8(255), + 3770: uint8(255), + 3771: uint8(255), + 3772: uint8(255), + 3773: uint8(15), + 3774: uint8(255), + 3775: uint8(3), + 3776: uint8(255), + 3777: uint8(255), + 3778: uint8(255), + 3779: uint8(255), + 3780: uint8(255), + 3781: uint8(255), + 3782: uint8(255), + 3783: uint8(255), + 3784: uint8(255), + 3785: uint8(255), + 3786: uint8(255), + 3787: uint8(255), + 3788: uint8(255), + 3789: uint8(255), + 3790: uint8(255), + 3791: uint8(255), + 3792: uint8(255), + 3793: uint8(255), + 3794: uint8(255), + 3795: uint8(255), + 3796: uint8(255), + 3797: uint8(255), + 3798: uint8(255), + 3799: uint8(255), + 3800: uint8(31), + 3808: uint8(255), + 3809: uint8(255), + 3810: uint8(255), + 3811: uint8(255), + 3812: uint8(255), + 3813: uint8(255), + 3814: uint8(255), + 3815: uint8(255), + 3816: uint8(143), + 3817: uint8(8), + 3818: uint8(255), + 3819: uint8(3), + 3840: uint8(239), + 3841: uint8(255), + 3842: uint8(255), + 3843: uint8(255), + 3844: uint8(150), + 3845: uint8(254), + 3846: uint8(247), + 3847: uint8(10), + 3848: uint8(132), + 3849: uint8(234), + 3850: uint8(150), + 3851: uint8(170), + 3852: uint8(150), + 3853: uint8(247), + 3854: uint8(247), + 3855: uint8(94), + 3856: uint8(255), + 3857: uint8(251), + 3858: uint8(255), + 3859: uint8(15), + 3860: uint8(238), + 3861: uint8(251), + 3862: uint8(255), + 3863: uint8(15), + 3878: uint8(255), + 3879: uint8(255), + 3880: uint8(255), + 3881: uint8(3), + 3882: uint8(255), + 3883: uint8(255), + 3884: uint8(255), + 3885: uint8(3), + 3886: uint8(255), + 3887: uint8(255), + 3888: uint8(255), + 3889: uint8(3), +} + +func Xiswalpha(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if wc < uint32(0x20000) { + return Int32FromUint8(_table3[Uint32FromInt32(Int32FromUint8(_table3[wc>>int32(8)])*int32(32))+wc&uint32(255)>>int32(3)]) >> (wc & uint32(7)) & int32(1) + } + if wc < uint32(0x2fffe) { + return int32(1) + } + return 0 +} + +func X__iswalpha_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswalpha(tls, c) +} + +func Xiswalpha_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswalpha_l(tls, c, l) +} + +func Xiswblank(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisblank(tls, Int32FromUint32(wc)) +} + +func X__iswblank_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswblank(tls, c) +} + +func Xiswblank_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswblank_l(tls, c, l) +} + +func Xiswcntrl(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(wc < uint32(32) || wc-Uint32FromInt32(0x7f) < uint32(33) || wc-Uint32FromInt32(0x2028) < uint32(2) || wc-Uint32FromInt32(0xfff9) < uint32(3)) +} + +func X__iswcntrl_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswcntrl(tls, c) +} + +func Xiswcntrl_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswcntrl_l(tls, c, l) +} + +const WCTYPE_ALNUM = 1 +const WCTYPE_ALPHA = 2 +const WCTYPE_BLANK = 3 +const WCTYPE_CNTRL = 4 +const WCTYPE_DIGIT = 5 +const WCTYPE_GRAPH = 6 +const WCTYPE_LOWER = 7 +const WCTYPE_PRINT = 8 +const WCTYPE_PUNCT = 9 +const WCTYPE_SPACE = 10 +const WCTYPE_UPPER = 11 +const WCTYPE_XDIGIT = 12 + +func Xiswctype(tls *TLS, wc Twint_t, type1 Twctype_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v type1=%v, (%v:)", tls, wc, type1, origin(2)) + defer func() { trc("-> %v", r) }() + } + switch type1 { + case uint64(WCTYPE_ALNUM): + return Xiswalnum(tls, wc) + case uint64(WCTYPE_ALPHA): + return Xiswalpha(tls, wc) + case uint64(WCTYPE_BLANK): + return Xiswblank(tls, wc) + case uint64(WCTYPE_CNTRL): + return Xiswcntrl(tls, wc) + case uint64(WCTYPE_DIGIT): + return BoolInt32(wc-uint32('0') < uint32(10)) + case uint64(WCTYPE_GRAPH): + return Xiswgraph(tls, wc) + case uint64(WCTYPE_LOWER): + return Xiswlower(tls, wc) + case uint64(WCTYPE_PRINT): + return Xiswprint(tls, wc) + case uint64(WCTYPE_PUNCT): + return Xiswpunct(tls, wc) + case uint64(WCTYPE_SPACE): + return Xiswspace(tls, wc) + case uint64(WCTYPE_UPPER): + return Xiswupper(tls, wc) + case uint64(WCTYPE_XDIGIT): + return Xiswxdigit(tls, wc) + } + return 0 +} + +func Xwctype(tls *TLS, s uintptr) (r Twctype_t) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i int32 + var p uintptr + _, _ = i, p + i = int32(1) + p = uintptr(unsafe.Pointer(&_names)) + for { + if !(**(**int8)(__ccgo_up(p)) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(s))) == int32(**(**int8)(__ccgo_up(p))) && !(Xstrcmp(tls, s, p) != 0) { + return Uint64FromInt32(i) + } + goto _1 + _1: + ; + i = i + 1 + p = p + uintptr(6) + } + return uint64(0) +} + +/* order must match! */ +var _names = [73]int8{'a', 'l', 'n', 'u', 'm', 0, 'a', 'l', 'p', 'h', 'a', 0, 'b', 'l', 'a', 'n', 'k', 0, 'c', 'n', 't', 'r', 'l', 0, 'd', 'i', 'g', 'i', 't', 0, 'g', 'r', 'a', 'p', 'h', 0, 'l', 'o', 'w', 'e', 'r', 0, 'p', 'r', 'i', 'n', 't', 0, 'p', 'u', 'n', 'c', 't', 0, 's', 'p', 'a', 'c', 'e', 0, 'u', 'p', 'p', 'e', 'r', 0, 'x', 'd', 'i', 'g', 'i', 't'} + +func X__iswctype_l(tls *TLS, c Twint_t, t Twctype_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v t=%v l=%v, (%v:)", tls, c, t, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswctype(tls, c, t) +} + +func X__wctype_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctype_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v, (%v:)", tls, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwctype(tls, s) +} + +func Xiswctype_l(tls *TLS, c Twint_t, t Twctype_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v t=%v l=%v, (%v:)", tls, c, t, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswctype_l(tls, c, t, l) +} + +func Xwctype_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctype_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v, (%v:)", tls, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wctype_l(tls, s, l) +} + +func Xiswdigit(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(wc-uint32('0') < uint32(10)) +} + +func X__iswdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswdigit(tls, c) +} + +func Xiswdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswdigit_l(tls, c, l) +} + +func Xiswgraph(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* ISO C defines this function as: */ + return BoolInt32(!(Xiswspace(tls, wc) != 0) && Xiswprint(tls, wc) != 0) +} + +func X__iswgraph_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswgraph(tls, c) +} + +func Xiswgraph_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswgraph_l(tls, c, l) +} + +func Xiswlower(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Xtowupper(tls, wc) != wc) +} + +func X__iswlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswlower(tls, c) +} + +func Xiswlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswlower_l(tls, c, l) +} + +/* Consider all legal codepoints as printable except for: + * - C0 and C1 control characters + * - U+2028 and U+2029 (line/para break) + * - U+FFF9 through U+FFFB (interlinear annotation controls) + * The following code is optimized heavily to make hot paths for the + * expected printable characters. */ + +func Xiswprint(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if wc < uint32(0xff) { + return BoolInt32((wc+uint32(1))&uint32(0x7f) >= uint32(0x21)) + } + if wc < uint32(0x2028) || wc-uint32(0x202a) < Uint32FromInt32(Int32FromInt32(0xd800)-Int32FromInt32(0x202a)) || wc-uint32(0xe000) < Uint32FromInt32(Int32FromInt32(0xfff9)-Int32FromInt32(0xe000)) { + return int32(1) + } + if wc-uint32(0xfffc) > Uint32FromInt32(Int32FromInt32(0x10ffff)-Int32FromInt32(0xfffc)) || wc&uint32(0xfffe) == uint32(0xfffe) { + return 0 + } + return int32(1) +} + +func X__iswprint_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswprint(tls, c) +} + +func Xiswprint_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswprint_l(tls, c, l) +} + +var _table4 = [4000]uint8{ + 0: uint8(18), + 1: uint8(16), + 2: uint8(19), + 3: uint8(20), + 4: uint8(21), + 5: uint8(22), + 6: uint8(23), + 7: uint8(24), + 8: uint8(25), + 9: uint8(26), + 10: uint8(27), + 11: uint8(28), + 12: uint8(29), + 13: uint8(30), + 14: uint8(31), + 15: uint8(32), + 16: uint8(33), + 17: uint8(16), + 18: uint8(16), + 19: uint8(34), + 20: uint8(35), + 21: uint8(16), + 22: uint8(36), + 23: uint8(37), + 24: uint8(38), + 25: uint8(39), + 26: uint8(40), + 27: uint8(41), + 28: uint8(42), + 29: uint8(43), + 30: uint8(16), + 31: uint8(44), + 32: uint8(45), + 33: uint8(46), + 34: uint8(17), + 35: uint8(17), + 36: uint8(47), + 37: uint8(17), + 38: uint8(17), + 39: uint8(17), + 40: uint8(17), + 41: uint8(17), + 42: uint8(17), + 43: uint8(48), + 44: uint8(49), + 45: uint8(50), + 46: uint8(51), + 47: uint8(52), + 48: uint8(53), + 49: uint8(54), + 50: uint8(55), + 51: uint8(17), + 52: uint8(16), + 53: uint8(16), + 54: uint8(16), + 55: uint8(16), + 56: uint8(16), + 57: uint8(16), + 58: uint8(16), + 59: uint8(16), + 60: uint8(16), + 61: uint8(16), + 62: uint8(16), + 63: uint8(16), + 64: uint8(16), + 65: uint8(16), + 66: uint8(16), + 67: uint8(16), + 68: uint8(16), + 69: uint8(16), + 70: uint8(16), + 71: uint8(16), + 72: uint8(16), + 73: uint8(16), + 74: uint8(16), + 75: uint8(16), + 76: uint8(16), + 77: uint8(56), + 78: uint8(16), + 79: uint8(16), + 80: uint8(16), + 81: uint8(16), + 82: uint8(16), + 83: uint8(16), + 84: uint8(16), + 85: uint8(16), + 86: uint8(16), + 87: uint8(16), + 88: uint8(16), + 89: uint8(16), + 90: uint8(16), + 91: uint8(16), + 92: uint8(16), + 93: uint8(16), + 94: uint8(16), + 95: uint8(16), + 96: uint8(16), + 97: uint8(16), + 98: uint8(16), + 99: uint8(16), + 100: uint8(16), + 101: uint8(16), + 102: uint8(16), + 103: uint8(16), + 104: uint8(16), + 105: uint8(16), + 106: uint8(16), + 107: uint8(16), + 108: uint8(16), + 109: uint8(16), + 110: uint8(16), + 111: uint8(16), + 112: uint8(16), + 113: uint8(16), + 114: uint8(16), + 115: uint8(16), + 116: uint8(16), + 117: uint8(16), + 118: uint8(16), + 119: uint8(16), + 120: uint8(16), + 121: uint8(16), + 122: uint8(16), + 123: uint8(16), + 124: uint8(16), + 125: uint8(16), + 126: uint8(16), + 127: uint8(16), + 128: uint8(16), + 129: uint8(16), + 130: uint8(16), + 131: uint8(16), + 132: uint8(16), + 133: uint8(16), + 134: uint8(16), + 135: uint8(16), + 136: uint8(16), + 137: uint8(16), + 138: uint8(16), + 139: uint8(16), + 140: uint8(16), + 141: uint8(16), + 142: uint8(16), + 143: uint8(16), + 144: uint8(16), + 145: uint8(16), + 146: uint8(16), + 147: uint8(16), + 148: uint8(16), + 149: uint8(16), + 150: uint8(16), + 151: uint8(16), + 152: uint8(16), + 153: uint8(16), + 154: uint8(16), + 155: uint8(16), + 156: uint8(16), + 157: uint8(16), + 158: uint8(16), + 159: uint8(16), + 160: uint8(16), + 161: uint8(16), + 162: uint8(16), + 163: uint8(16), + 164: uint8(57), + 165: uint8(16), + 166: uint8(58), + 167: uint8(59), + 168: uint8(60), + 169: uint8(61), + 170: uint8(62), + 171: uint8(63), + 172: uint8(16), + 173: uint8(16), + 174: uint8(16), + 175: uint8(16), + 176: uint8(16), + 177: uint8(16), + 178: uint8(16), + 179: uint8(16), + 180: uint8(16), + 181: uint8(16), + 182: uint8(16), + 183: uint8(16), + 184: uint8(16), + 185: uint8(16), + 186: uint8(16), + 187: uint8(16), + 188: uint8(16), + 189: uint8(16), + 190: uint8(16), + 191: uint8(16), + 192: uint8(16), + 193: uint8(16), + 194: uint8(16), + 195: uint8(16), + 196: uint8(16), + 197: uint8(16), + 198: uint8(16), + 199: uint8(16), + 200: uint8(16), + 201: uint8(16), + 202: uint8(16), + 203: uint8(16), + 204: uint8(16), + 205: uint8(16), + 206: uint8(16), + 207: uint8(16), + 208: uint8(16), + 209: uint8(16), + 210: uint8(16), + 211: uint8(16), + 212: uint8(16), + 213: uint8(16), + 214: uint8(16), + 215: uint8(16), + 216: uint8(16), + 217: uint8(16), + 218: uint8(16), + 219: uint8(16), + 220: uint8(16), + 221: uint8(16), + 222: uint8(16), + 223: uint8(16), + 224: uint8(64), + 225: uint8(16), + 226: uint8(16), + 227: uint8(16), + 228: uint8(16), + 229: uint8(16), + 230: uint8(16), + 231: uint8(16), + 232: uint8(16), + 233: uint8(16), + 234: uint8(16), + 235: uint8(16), + 236: uint8(16), + 237: uint8(16), + 238: uint8(16), + 239: uint8(16), + 240: uint8(16), + 241: uint8(16), + 242: uint8(16), + 243: uint8(16), + 244: uint8(16), + 245: uint8(16), + 246: uint8(16), + 247: uint8(16), + 248: uint8(65), + 249: uint8(16), + 250: uint8(16), + 251: uint8(66), + 252: uint8(16), + 253: uint8(67), + 254: uint8(68), + 255: uint8(69), + 256: uint8(16), + 257: uint8(70), + 258: uint8(71), + 259: uint8(72), + 260: uint8(16), + 261: uint8(73), + 262: uint8(16), + 263: uint8(16), + 264: uint8(74), + 265: uint8(75), + 266: uint8(76), + 267: uint8(77), + 268: uint8(78), + 269: uint8(16), + 270: uint8(79), + 271: uint8(80), + 272: uint8(81), + 273: uint8(82), + 274: uint8(83), + 275: uint8(84), + 276: uint8(85), + 277: uint8(86), + 278: uint8(87), + 279: uint8(88), + 280: uint8(89), + 281: uint8(90), + 282: uint8(91), + 283: uint8(16), + 284: uint8(92), + 285: uint8(93), + 286: uint8(94), + 287: uint8(95), + 288: uint8(16), + 289: uint8(16), + 290: uint8(16), + 291: uint8(16), + 292: uint8(96), + 293: uint8(16), + 294: uint8(16), + 295: uint8(16), + 296: uint8(16), + 297: uint8(16), + 298: uint8(16), + 299: uint8(16), + 300: uint8(16), + 301: uint8(16), + 302: uint8(16), + 303: uint8(16), + 304: uint8(16), + 305: uint8(16), + 306: uint8(16), + 307: uint8(16), + 308: uint8(97), + 309: uint8(16), + 310: uint8(16), + 311: uint8(16), + 312: uint8(16), + 313: uint8(16), + 314: uint8(16), + 315: uint8(16), + 316: uint8(16), + 317: uint8(16), + 318: uint8(16), + 319: uint8(16), + 320: uint8(16), + 321: uint8(16), + 322: uint8(16), + 323: uint8(16), + 324: uint8(16), + 325: uint8(16), + 326: uint8(16), + 327: uint8(16), + 328: uint8(16), + 329: uint8(16), + 330: uint8(16), + 331: uint8(16), + 332: uint8(16), + 333: uint8(16), + 334: uint8(16), + 335: uint8(16), + 336: uint8(16), + 337: uint8(16), + 338: uint8(16), + 339: uint8(16), + 340: uint8(16), + 341: uint8(16), + 342: uint8(16), + 343: uint8(16), + 344: uint8(16), + 345: uint8(16), + 346: uint8(16), + 347: uint8(16), + 348: uint8(16), + 349: uint8(16), + 350: uint8(16), + 351: uint8(16), + 352: uint8(16), + 353: uint8(16), + 354: uint8(16), + 355: uint8(16), + 356: uint8(16), + 357: uint8(16), + 358: uint8(16), + 359: uint8(16), + 360: uint8(16), + 361: uint8(16), + 362: uint8(98), + 363: uint8(99), + 364: uint8(16), + 365: uint8(16), + 366: uint8(100), + 367: uint8(101), + 368: uint8(16), + 369: uint8(16), + 370: uint8(16), + 371: uint8(16), + 372: uint8(16), + 373: uint8(16), + 374: uint8(16), + 375: uint8(16), + 376: uint8(16), + 377: uint8(16), + 378: uint8(16), + 379: uint8(16), + 380: uint8(16), + 381: uint8(16), + 382: uint8(16), + 383: uint8(16), + 384: uint8(16), + 385: uint8(16), + 386: uint8(16), + 387: uint8(16), + 388: uint8(16), + 389: uint8(16), + 390: uint8(16), + 391: uint8(16), + 392: uint8(16), + 393: uint8(16), + 394: uint8(16), + 395: uint8(16), + 396: uint8(16), + 397: uint8(16), + 398: uint8(16), + 399: uint8(16), + 400: uint8(16), + 401: uint8(16), + 402: uint8(16), + 403: uint8(16), + 404: uint8(16), + 405: uint8(16), + 406: uint8(16), + 407: uint8(16), + 408: uint8(16), + 409: uint8(16), + 410: uint8(16), + 411: uint8(16), + 412: uint8(16), + 413: uint8(16), + 414: uint8(16), + 415: uint8(16), + 416: uint8(16), + 417: uint8(16), + 418: uint8(16), + 419: uint8(16), + 420: uint8(16), + 421: uint8(16), + 422: uint8(16), + 423: uint8(16), + 424: uint8(16), + 425: uint8(16), + 426: uint8(16), + 427: uint8(16), + 428: uint8(16), + 429: uint8(16), + 430: uint8(16), + 431: uint8(16), + 432: uint8(16), + 433: uint8(16), + 434: uint8(16), + 435: uint8(16), + 436: uint8(16), + 437: uint8(16), + 438: uint8(16), + 439: uint8(16), + 440: uint8(16), + 441: uint8(16), + 442: uint8(16), + 443: uint8(16), + 444: uint8(102), + 445: uint8(16), + 446: uint8(16), + 447: uint8(16), + 448: uint8(16), + 449: uint8(16), + 450: uint8(16), + 451: uint8(16), + 452: uint8(16), + 453: uint8(16), + 454: uint8(16), + 455: uint8(16), + 456: uint8(16), + 457: uint8(16), + 458: uint8(16), + 459: uint8(16), + 460: uint8(16), + 461: uint8(16), + 462: uint8(16), + 463: uint8(16), + 464: uint8(103), + 465: uint8(104), + 466: uint8(105), + 467: uint8(106), + 468: uint8(16), + 469: uint8(16), + 470: uint8(107), + 471: uint8(108), + 472: uint8(17), + 473: uint8(17), + 474: uint8(109), + 475: uint8(16), + 476: uint8(16), + 477: uint8(16), + 478: uint8(16), + 479: uint8(16), + 480: uint8(16), + 481: uint8(110), + 482: uint8(111), + 483: uint8(16), + 484: uint8(16), + 485: uint8(16), + 486: uint8(16), + 487: uint8(16), + 488: uint8(112), + 489: uint8(113), + 490: uint8(16), + 491: uint8(16), + 492: uint8(114), + 493: uint8(115), + 494: uint8(116), + 495: uint8(16), + 496: uint8(117), + 497: uint8(118), + 498: uint8(119), + 499: uint8(17), + 500: uint8(17), + 501: uint8(17), + 502: uint8(120), + 503: uint8(121), + 504: uint8(122), + 505: uint8(123), + 506: uint8(124), + 507: uint8(16), + 508: uint8(16), + 509: uint8(16), + 510: uint8(16), + 511: uint8(16), + 544: uint8(255), + 545: uint8(255), + 546: uint8(255), + 547: uint8(255), + 548: uint8(255), + 549: uint8(255), + 550: uint8(255), + 551: uint8(255), + 552: uint8(255), + 553: uint8(255), + 554: uint8(255), + 555: uint8(255), + 556: uint8(255), + 557: uint8(255), + 558: uint8(255), + 559: uint8(255), + 560: uint8(255), + 561: uint8(255), + 562: uint8(255), + 563: uint8(255), + 564: uint8(255), + 565: uint8(255), + 566: uint8(255), + 567: uint8(255), + 568: uint8(255), + 569: uint8(255), + 570: uint8(255), + 571: uint8(255), + 572: uint8(255), + 573: uint8(255), + 574: uint8(255), + 575: uint8(255), + 580: uint8(254), + 581: uint8(255), + 583: uint8(252), + 584: uint8(1), + 587: uint8(248), + 588: uint8(1), + 591: uint8(120), + 596: uint8(255), + 597: uint8(251), + 598: uint8(223), + 599: uint8(251), + 602: uint8(128), + 606: uint8(128), + 632: uint8(60), + 634: uint8(252), + 635: uint8(255), + 636: uint8(224), + 637: uint8(175), + 638: uint8(255), + 639: uint8(255), + 640: uint8(255), + 641: uint8(255), + 642: uint8(255), + 643: uint8(255), + 644: uint8(255), + 645: uint8(255), + 646: uint8(255), + 647: uint8(255), + 648: uint8(223), + 649: uint8(255), + 650: uint8(255), + 651: uint8(255), + 652: uint8(255), + 653: uint8(255), + 654: uint8(32), + 655: uint8(64), + 656: uint8(176), + 670: uint8(64), + 688: uint8(252), + 689: uint8(3), + 715: uint8(252), + 721: uint8(230), + 722: uint8(254), + 723: uint8(255), + 724: uint8(255), + 725: uint8(255), + 727: uint8(64), + 728: uint8(73), + 734: uint8(24), + 736: uint8(255), + 737: uint8(255), + 739: uint8(216), + 747: uint8(1), + 749: uint8(60), + 762: uint8(16), + 763: uint8(224), + 764: uint8(1), + 765: uint8(30), + 767: uint8(96), + 768: uint8(255), + 769: uint8(191), + 776: uint8(255), + 777: uint8(7), + 797: uint8(248), + 798: uint8(207), + 799: uint8(227), + 803: uint8(3), + 805: uint8(32), + 806: uint8(255), + 807: uint8(127), + 811: uint8(78), + 826: uint8(8), + 828: uint8(7), + 829: uint8(252), + 839: uint8(16), + 841: uint8(32), + 842: uint8(30), + 844: uint8(48), + 846: uint8(1), + 855: uint8(16), + 857: uint8(32), + 862: uint8(252), + 863: uint8(111), + 871: uint8(16), + 873: uint8(32), + 878: uint8(64), + 887: uint8(16), + 889: uint8(32), + 894: uint8(3), + 895: uint8(224), + 903: uint8(16), + 905: uint8(32), + 910: uint8(253), + 921: uint8(32), + 926: uint8(255), + 927: uint8(7), + 928: uint8(16), + 937: uint8(32), + 942: uint8(128), + 943: uint8(255), + 944: uint8(16), + 951: uint8(16), + 953: uint8(32), + 967: uint8(24), + 969: uint8(160), + 971: uint8(127), + 974: uint8(255), + 975: uint8(3), + 985: uint8(4), + 990: uint8(16), + 997: uint8(128), + 999: uint8(128), + 1000: uint8(192), + 1001: uint8(223), + 1003: uint8(12), + 1015: uint8(4), + 1017: uint8(31), + 1024: uint8(254), + 1025: uint8(255), + 1026: uint8(255), + 1027: uint8(255), + 1029: uint8(252), + 1030: uint8(255), + 1031: uint8(255), + 1040: uint8(252), + 1047: uint8(192), + 1048: uint8(255), + 1049: uint8(223), + 1050: uint8(255), + 1051: uint8(7), + 1062: uint8(128), + 1063: uint8(6), + 1065: uint8(252), + 1075: uint8(192), + 1087: uint8(8), + 1099: uint8(224), + 1100: uint8(255), + 1101: uint8(255), + 1102: uint8(255), + 1103: uint8(31), + 1106: uint8(255), + 1107: uint8(3), + 1120: uint8(1), + 1165: uint8(96), + 1168: uint8(1), + 1171: uint8(24), + 1181: uint8(56), + 1186: uint8(16), + 1190: uint8(112), + 1206: uint8(48), + 1209: uint8(254), + 1210: uint8(127), + 1211: uint8(47), + 1214: uint8(255), + 1215: uint8(3), + 1216: uint8(255), + 1217: uint8(127), + 1255: uint8(14), + 1256: uint8(49), + 1275: uint8(196), + 1276: uint8(255), + 1277: uint8(255), + 1278: uint8(255), + 1279: uint8(255), + 1283: uint8(192), + 1292: uint8(1), + 1294: uint8(224), + 1295: uint8(159), + 1300: uint8(127), + 1301: uint8(63), + 1302: uint8(255), + 1303: uint8(127), + 1318: uint8(16), + 1320: uint8(16), + 1323: uint8(252), + 1324: uint8(255), + 1325: uint8(255), + 1326: uint8(255), + 1327: uint8(31), + 1333: uint8(12), + 1340: uint8(64), + 1342: uint8(12), + 1343: uint8(240), + 1350: uint8(128), + 1351: uint8(248), + 1359: uint8(192), + 1368: uint8(255), + 1370: uint8(255), + 1371: uint8(255), + 1372: uint8(255), + 1373: uint8(33), + 1374: uint8(144), + 1375: uint8(3), + 1400: uint8(255), + 1401: uint8(255), + 1402: uint8(255), + 1403: uint8(255), + 1404: uint8(127), + 1406: uint8(224), + 1407: uint8(251), + 1431: uint8(160), + 1432: uint8(3), + 1433: uint8(224), + 1435: uint8(224), + 1437: uint8(224), + 1439: uint8(96), + 1440: uint8(128), + 1441: uint8(248), + 1442: uint8(255), + 1443: uint8(255), + 1444: uint8(255), + 1445: uint8(252), + 1446: uint8(255), + 1447: uint8(255), + 1448: uint8(255), + 1449: uint8(255), + 1450: uint8(255), + 1451: uint8(127), + 1452: uint8(223), + 1453: uint8(255), + 1454: uint8(241), + 1455: uint8(127), + 1456: uint8(255), + 1457: uint8(127), + 1460: uint8(255), + 1461: uint8(255), + 1462: uint8(255), + 1463: uint8(255), + 1466: uint8(255), + 1467: uint8(255), + 1468: uint8(255), + 1469: uint8(255), + 1470: uint8(1), + 1472: uint8(123), + 1473: uint8(3), + 1474: uint8(208), + 1475: uint8(193), + 1476: uint8(175), + 1477: uint8(66), + 1479: uint8(12), + 1480: uint8(31), + 1481: uint8(188), + 1482: uint8(255), + 1483: uint8(255), + 1489: uint8(14), + 1490: uint8(255), + 1491: uint8(255), + 1492: uint8(255), + 1493: uint8(255), + 1494: uint8(255), + 1495: uint8(255), + 1496: uint8(255), + 1497: uint8(255), + 1498: uint8(255), + 1499: uint8(255), + 1500: uint8(255), + 1501: uint8(255), + 1502: uint8(255), + 1503: uint8(255), + 1504: uint8(255), + 1505: uint8(255), + 1506: uint8(255), + 1507: uint8(255), + 1508: uint8(127), + 1512: uint8(255), + 1513: uint8(7), + 1516: uint8(255), + 1517: uint8(255), + 1518: uint8(255), + 1519: uint8(255), + 1520: uint8(255), + 1521: uint8(255), + 1522: uint8(255), + 1523: uint8(255), + 1524: uint8(255), + 1525: uint8(255), + 1526: uint8(63), + 1533: uint8(252), + 1534: uint8(255), + 1535: uint8(255), + 1536: uint8(255), + 1537: uint8(255), + 1538: uint8(255), + 1539: uint8(255), + 1540: uint8(255), + 1541: uint8(255), + 1542: uint8(255), + 1543: uint8(255), + 1544: uint8(255), + 1545: uint8(255), + 1546: uint8(255), + 1547: uint8(255), + 1548: uint8(255), + 1549: uint8(255), + 1550: uint8(207), + 1551: uint8(255), + 1552: uint8(255), + 1553: uint8(255), + 1554: uint8(63), + 1555: uint8(255), + 1556: uint8(255), + 1557: uint8(255), + 1558: uint8(255), + 1559: uint8(255), + 1560: uint8(255), + 1561: uint8(255), + 1562: uint8(255), + 1563: uint8(255), + 1564: uint8(255), + 1565: uint8(255), + 1566: uint8(255), + 1567: uint8(255), + 1596: uint8(224), + 1597: uint8(135), + 1598: uint8(3), + 1599: uint8(254), + 1614: uint8(1), + 1615: uint8(128), + 1632: uint8(255), + 1633: uint8(255), + 1634: uint8(255), + 1635: uint8(255), + 1636: uint8(255), + 1637: uint8(127), + 1638: uint8(255), + 1639: uint8(255), + 1640: uint8(255), + 1641: uint8(255), + 1648: uint8(255), + 1649: uint8(255), + 1650: uint8(255), + 1651: uint8(251), + 1652: uint8(255), + 1653: uint8(255), + 1654: uint8(255), + 1655: uint8(255), + 1656: uint8(255), + 1657: uint8(255), + 1658: uint8(255), + 1659: uint8(255), + 1660: uint8(255), + 1661: uint8(255), + 1662: uint8(15), + 1664: uint8(255), + 1665: uint8(255), + 1666: uint8(255), + 1667: uint8(255), + 1668: uint8(255), + 1669: uint8(255), + 1670: uint8(255), + 1671: uint8(255), + 1672: uint8(255), + 1673: uint8(255), + 1674: uint8(255), + 1675: uint8(255), + 1676: uint8(255), + 1677: uint8(255), + 1678: uint8(255), + 1679: uint8(255), + 1680: uint8(255), + 1681: uint8(255), + 1682: uint8(255), + 1683: uint8(255), + 1684: uint8(255), + 1685: uint8(255), + 1686: uint8(255), + 1687: uint8(255), + 1688: uint8(255), + 1689: uint8(255), + 1690: uint8(63), + 1694: uint8(255), + 1695: uint8(15), + 1696: uint8(30), + 1697: uint8(255), + 1698: uint8(255), + 1699: uint8(255), + 1700: uint8(1), + 1701: uint8(252), + 1702: uint8(193), + 1703: uint8(224), + 1715: uint8(30), + 1716: uint8(1), + 1727: uint8(8), + 1746: uint8(255), + 1747: uint8(255), + 1752: uint8(255), + 1753: uint8(255), + 1754: uint8(255), + 1755: uint8(255), + 1756: uint8(15), + 1760: uint8(255), + 1761: uint8(255), + 1762: uint8(255), + 1763: uint8(127), + 1764: uint8(255), + 1765: uint8(255), + 1766: uint8(255), + 1767: uint8(255), + 1768: uint8(255), + 1769: uint8(255), + 1770: uint8(255), + 1771: uint8(255), + 1772: uint8(255), + 1773: uint8(255), + 1774: uint8(255), + 1775: uint8(255), + 1776: uint8(255), + 1777: uint8(255), + 1778: uint8(255), + 1779: uint8(255), + 1780: uint8(255), + 1781: uint8(255), + 1782: uint8(255), + 1783: uint8(255), + 1784: uint8(255), + 1785: uint8(255), + 1786: uint8(255), + 1787: uint8(255), + 1788: uint8(255), + 1789: uint8(255), + 1790: uint8(255), + 1791: uint8(255), + 1816: uint8(255), + 1817: uint8(255), + 1818: uint8(255), + 1819: uint8(255), + 1820: uint8(255), + 1821: uint8(255), + 1822: uint8(255), + 1823: uint8(255), + 1842: uint8(255), + 1843: uint8(255), + 1844: uint8(255), + 1845: uint8(255), + 1846: uint8(255), + 1847: uint8(255), + 1848: uint8(127), + 1855: uint8(192), + 1857: uint8(224), + 1869: uint8(128), + 1870: uint8(15), + 1871: uint8(112), + 1886: uint8(255), + 1888: uint8(255), + 1889: uint8(255), + 1890: uint8(127), + 1892: uint8(3), + 1905: uint8(6), + 1920: uint8(64), + 1925: uint8(15), + 1926: uint8(255), + 1927: uint8(3), + 1934: uint8(240), + 1944: uint8(16), + 1945: uint8(192), + 1948: uint8(255), + 1949: uint8(255), + 1950: uint8(3), + 1951: uint8(23), + 1957: uint8(248), + 1962: uint8(8), + 1963: uint8(128), + 1974: uint8(8), + 1976: uint8(255), + 1977: uint8(63), + 1979: uint8(192), + 1995: uint8(240), + 1998: uint8(128), + 1999: uint8(3), + 2007: uint8(128), + 2008: uint8(2), + 2011: uint8(192), + 2014: uint8(67), + 2027: uint8(8), + 2045: uint8(56), + 2048: uint8(1), + 2111: uint8(128), + 2117: uint8(2), + 2134: uint8(252), + 2135: uint8(255), + 2136: uint8(3), + 2151: uint8(192), + 2175: uint8(48), + 2176: uint8(255), + 2177: uint8(255), + 2178: uint8(255), + 2179: uint8(3), + 2180: uint8(255), + 2181: uint8(255), + 2182: uint8(255), + 2183: uint8(255), + 2184: uint8(255), + 2185: uint8(255), + 2186: uint8(247), + 2187: uint8(255), + 2188: uint8(127), + 2189: uint8(15), + 2207: uint8(128), + 2208: uint8(254), + 2209: uint8(255), + 2211: uint8(252), + 2212: uint8(1), + 2215: uint8(248), + 2216: uint8(1), + 2219: uint8(248), + 2220: uint8(63), + 2236: uint8(127), + 2237: uint8(127), + 2239: uint8(48), + 2240: uint8(135), + 2241: uint8(255), + 2242: uint8(255), + 2243: uint8(255), + 2244: uint8(255), + 2245: uint8(255), + 2246: uint8(143), + 2247: uint8(255), + 2254: uint8(224), + 2255: uint8(255), + 2256: uint8(255), + 2257: uint8(127), + 2258: uint8(255), + 2259: uint8(15), + 2260: uint8(1), + 2266: uint8(255), + 2267: uint8(255), + 2268: uint8(255), + 2269: uint8(255), + 2270: uint8(255), + 2271: uint8(63), + 2300: uint8(255), + 2301: uint8(255), + 2302: uint8(255), + 2303: uint8(15), + 2308: uint8(15), + 2323: uint8(128), + 2330: uint8(1), + 2349: uint8(128), + 2378: uint8(128), + 2379: uint8(255), + 2382: uint8(128), + 2383: uint8(255), + 2388: uint8(128), + 2389: uint8(255), + 2399: uint8(248), + 2402: uint8(192), + 2403: uint8(143), + 2407: uint8(128), + 2423: uint8(48), + 2424: uint8(255), + 2425: uint8(255), + 2426: uint8(252), + 2427: uint8(255), + 2428: uint8(255), + 2429: uint8(255), + 2430: uint8(255), + 2431: uint8(255), + 2439: uint8(135), + 2440: uint8(255), + 2441: uint8(1), + 2442: uint8(255), + 2443: uint8(1), + 2447: uint8(224), + 2451: uint8(224), + 2457: uint8(1), + 2460: uint8(96), + 2461: uint8(248), + 2462: uint8(127), + 2471: uint8(254), + 2475: uint8(255), + 2479: uint8(255), + 2483: uint8(30), + 2485: uint8(254), + 2527: uint8(252), + 2540: uint8(255), + 2541: uint8(255), + 2542: uint8(255), + 2543: uint8(127), + 2563: uint8(224), + 2564: uint8(127), + 2568: uint8(192), + 2569: uint8(255), + 2570: uint8(255), + 2571: uint8(3), + 2600: uint8(192), + 2601: uint8(63), + 2602: uint8(252), + 2603: uint8(255), + 2604: uint8(63), + 2607: uint8(128), + 2608: uint8(3), + 2615: uint8(254), + 2616: uint8(3), + 2617: uint8(32), + 2630: uint8(24), + 2632: uint8(15), + 2638: uint8(56), + 2648: uint8(225), + 2649: uint8(63), + 2651: uint8(232), + 2652: uint8(254), + 2653: uint8(255), + 2654: uint8(31), + 2662: uint8(96), + 2663: uint8(63), + 2677: uint8(2), + 2685: uint8(6), + 2695: uint8(24), + 2697: uint8(32), + 2700: uint8(192), + 2701: uint8(31), + 2702: uint8(31), + 2728: uint8(68), + 2729: uint8(248), + 2731: uint8(104), + 2744: uint8(76), + 2775: uint8(128), + 2776: uint8(255), + 2777: uint8(255), + 2778: uint8(255), + 2791: uint8(128), + 2792: uint8(14), + 2796: uint8(255), + 2797: uint8(31), + 2806: uint8(192), + 2821: uint8(8), + 2823: uint8(252), + 2855: uint8(14), + 2877: uint8(252), + 2878: uint8(7), + 2908: uint8(5), + 2918: uint8(24), + 2919: uint8(128), + 2920: uint8(255), + 2931: uint8(223), + 2932: uint8(7), + 2951: uint8(128), + 2952: uint8(62), + 2955: uint8(252), + 2956: uint8(255), + 2957: uint8(31), + 2958: uint8(3), + 2984: uint8(52), + 2994: uint8(128), + 3038: uint8(128), + 3039: uint8(1), + 3064: uint8(255), + 3065: uint8(255), + 3066: uint8(255), + 3067: uint8(255), + 3068: uint8(255), + 3069: uint8(255), + 3070: uint8(3), + 3071: uint8(128), + 3086: uint8(31), + 3110: uint8(255), + 3111: uint8(1), + 3149: uint8(192), + 3166: uint8(63), + 3174: uint8(255), + 3175: uint8(255), + 3176: uint8(48), + 3179: uint8(248), + 3180: uint8(3), + 3216: uint8(255), + 3217: uint8(255), + 3218: uint8(255), + 3219: uint8(7), + 3260: uint8(4), + 3283: uint8(176), + 3284: uint8(15), + 3296: uint8(255), + 3297: uint8(255), + 3298: uint8(255), + 3299: uint8(255), + 3300: uint8(255), + 3301: uint8(255), + 3302: uint8(255), + 3303: uint8(255), + 3304: uint8(255), + 3305: uint8(255), + 3306: uint8(255), + 3307: uint8(255), + 3308: uint8(255), + 3309: uint8(255), + 3310: uint8(255), + 3311: uint8(255), + 3312: uint8(255), + 3313: uint8(255), + 3314: uint8(255), + 3315: uint8(255), + 3316: uint8(255), + 3317: uint8(255), + 3318: uint8(255), + 3319: uint8(255), + 3320: uint8(255), + 3321: uint8(255), + 3322: uint8(255), + 3323: uint8(255), + 3324: uint8(255), + 3325: uint8(255), + 3326: uint8(63), + 3328: uint8(255), + 3329: uint8(255), + 3330: uint8(255), + 3331: uint8(255), + 3332: uint8(127), + 3333: uint8(254), + 3334: uint8(255), + 3335: uint8(255), + 3336: uint8(255), + 3337: uint8(255), + 3338: uint8(255), + 3339: uint8(255), + 3340: uint8(255), + 3341: uint8(255), + 3342: uint8(255), + 3343: uint8(255), + 3344: uint8(255), + 3345: uint8(255), + 3346: uint8(255), + 3347: uint8(255), + 3348: uint8(255), + 3349: uint8(255), + 3350: uint8(255), + 3351: uint8(255), + 3352: uint8(255), + 3353: uint8(255), + 3354: uint8(255), + 3355: uint8(255), + 3356: uint8(255), + 3357: uint8(1), + 3360: uint8(255), + 3361: uint8(255), + 3362: uint8(255), + 3363: uint8(255), + 3364: uint8(255), + 3365: uint8(255), + 3366: uint8(255), + 3367: uint8(255), + 3368: uint8(63), + 3388: uint8(255), + 3389: uint8(255), + 3390: uint8(15), + 3392: uint8(255), + 3393: uint8(255), + 3394: uint8(255), + 3395: uint8(255), + 3396: uint8(255), + 3397: uint8(255), + 3398: uint8(255), + 3399: uint8(255), + 3400: uint8(255), + 3401: uint8(255), + 3402: uint8(127), + 3404: uint8(255), + 3405: uint8(255), + 3406: uint8(255), + 3407: uint8(1), + 3448: uint8(2), + 3451: uint8(8), + 3455: uint8(8), + 3458: uint8(32), + 3462: uint8(32), + 3465: uint8(128), + 3469: uint8(128), + 3473: uint8(2), + 3477: uint8(2), + 3480: uint8(8), + 3488: uint8(255), + 3489: uint8(255), + 3490: uint8(255), + 3491: uint8(255), + 3492: uint8(255), + 3493: uint8(255), + 3494: uint8(255), + 3495: uint8(255), + 3496: uint8(255), + 3497: uint8(255), + 3498: uint8(255), + 3499: uint8(255), + 3500: uint8(255), + 3501: uint8(255), + 3502: uint8(255), + 3503: uint8(255), + 3504: uint8(255), + 3505: uint8(15), + 3507: uint8(248), + 3508: uint8(254), + 3509: uint8(255), + 3526: uint8(127), + 3529: uint8(128), + 3581: uint8(240), + 3583: uint8(128), + 3608: uint8(128), + 3609: uint8(255), + 3610: uint8(127), + 3624: uint8(112), + 3625: uint8(7), + 3627: uint8(192), + 3662: uint8(254), + 3663: uint8(255), + 3664: uint8(255), + 3665: uint8(255), + 3666: uint8(255), + 3667: uint8(255), + 3668: uint8(255), + 3669: uint8(255), + 3670: uint8(31), + 3680: uint8(254), + 3681: uint8(255), + 3682: uint8(255), + 3683: uint8(255), + 3684: uint8(255), + 3685: uint8(255), + 3686: uint8(255), + 3687: uint8(63), + 3742: uint8(3), + 3744: uint8(255), + 3745: uint8(255), + 3746: uint8(255), + 3747: uint8(255), + 3748: uint8(255), + 3749: uint8(15), + 3750: uint8(255), + 3751: uint8(255), + 3752: uint8(255), + 3753: uint8(255), + 3754: uint8(255), + 3755: uint8(255), + 3756: uint8(255), + 3757: uint8(255), + 3758: uint8(255), + 3759: uint8(255), + 3760: uint8(255), + 3761: uint8(255), + 3762: uint8(15), + 3764: uint8(255), + 3765: uint8(127), + 3766: uint8(254), + 3767: uint8(255), + 3768: uint8(254), + 3769: uint8(255), + 3770: uint8(254), + 3771: uint8(255), + 3772: uint8(255), + 3773: uint8(255), + 3774: uint8(63), + 3776: uint8(255), + 3777: uint8(31), + 3778: uint8(255), + 3779: uint8(255), + 3780: uint8(255), + 3781: uint8(255), + 3785: uint8(252), + 3789: uint8(28), + 3793: uint8(252), + 3794: uint8(255), + 3795: uint8(255), + 3796: uint8(255), + 3797: uint8(31), + 3804: uint8(192), + 3805: uint8(255), + 3806: uint8(255), + 3807: uint8(255), + 3808: uint8(7), + 3810: uint8(255), + 3811: uint8(255), + 3812: uint8(255), + 3813: uint8(255), + 3814: uint8(255), + 3815: uint8(15), + 3816: uint8(255), + 3817: uint8(1), + 3818: uint8(3), + 3820: uint8(63), + 3840: uint8(255), + 3841: uint8(255), + 3842: uint8(255), + 3843: uint8(255), + 3844: uint8(255), + 3845: uint8(255), + 3846: uint8(255), + 3847: uint8(255), + 3848: uint8(255), + 3849: uint8(255), + 3850: uint8(255), + 3851: uint8(255), + 3852: uint8(255), + 3853: uint8(255), + 3854: uint8(255), + 3855: uint8(255), + 3856: uint8(255), + 3857: uint8(255), + 3858: uint8(255), + 3859: uint8(255), + 3860: uint8(255), + 3861: uint8(255), + 3862: uint8(255), + 3863: uint8(255), + 3864: uint8(255), + 3865: uint8(255), + 3866: uint8(63), + 3868: uint8(255), + 3869: uint8(31), + 3870: uint8(255), + 3871: uint8(7), + 3872: uint8(255), + 3873: uint8(255), + 3874: uint8(255), + 3875: uint8(255), + 3876: uint8(255), + 3877: uint8(255), + 3878: uint8(255), + 3879: uint8(255), + 3880: uint8(255), + 3881: uint8(255), + 3882: uint8(255), + 3883: uint8(255), + 3884: uint8(255), + 3885: uint8(255), + 3886: uint8(15), + 3888: uint8(255), + 3889: uint8(255), + 3890: uint8(255), + 3891: uint8(255), + 3892: uint8(255), + 3893: uint8(255), + 3894: uint8(255), + 3895: uint8(255), + 3896: uint8(255), + 3897: uint8(255), + 3898: uint8(255), + 3899: uint8(1), + 3900: uint8(255), + 3901: uint8(15), + 3904: uint8(255), + 3905: uint8(15), + 3906: uint8(255), + 3907: uint8(255), + 3908: uint8(255), + 3909: uint8(255), + 3910: uint8(255), + 3911: uint8(255), + 3912: uint8(255), + 3914: uint8(255), + 3915: uint8(3), + 3916: uint8(255), + 3917: uint8(255), + 3918: uint8(255), + 3919: uint8(255), + 3920: uint8(255), + 3922: uint8(255), + 3923: uint8(255), + 3924: uint8(255), + 3925: uint8(63), + 3936: uint8(255), + 3937: uint8(239), + 3938: uint8(255), + 3939: uint8(255), + 3940: uint8(255), + 3941: uint8(255), + 3942: uint8(255), + 3943: uint8(255), + 3944: uint8(255), + 3945: uint8(255), + 3946: uint8(255), + 3947: uint8(255), + 3948: uint8(255), + 3949: uint8(255), + 3950: uint8(123), + 3951: uint8(252), + 3952: uint8(255), + 3953: uint8(255), + 3954: uint8(255), + 3955: uint8(255), + 3956: uint8(231), + 3957: uint8(199), + 3958: uint8(255), + 3959: uint8(255), + 3960: uint8(255), + 3961: uint8(231), + 3962: uint8(255), + 3963: uint8(255), + 3964: uint8(255), + 3965: uint8(255), + 3966: uint8(255), + 3967: uint8(255), + 3968: uint8(255), + 3969: uint8(255), + 3970: uint8(255), + 3971: uint8(255), + 3972: uint8(255), + 3973: uint8(255), + 3974: uint8(255), + 3975: uint8(255), + 3976: uint8(255), + 3977: uint8(255), + 3978: uint8(15), + 3980: uint8(255), + 3981: uint8(63), + 3982: uint8(15), + 3983: uint8(7), + 3984: uint8(7), + 3986: uint8(63), +} + +func Xiswpunct(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if wc < uint32(0x20000) { + return Int32FromUint8(_table4[Uint32FromInt32(Int32FromUint8(_table4[wc>>int32(8)])*int32(32))+wc&uint32(255)>>int32(3)]) >> (wc & uint32(7)) & int32(1) + } + return 0 +} + +func X__iswpunct_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswpunct(tls, c) +} + +func Xiswpunct_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswpunct_l(tls, c, l) +} + +type Tmbstate_t = struct { + F__opaque1 uint32 + F__opaque2 uint32 +} + +type t__mbstate_t = Tmbstate_t + +/* Our definition of whitespace is the Unicode White_Space property, + * minus non-breaking spaces (U+00A0, U+2007, and U+202F) and script- + * specific characters with non-blank glyphs (U+1680 and U+180E). */ + +func Xiswspace(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(wc != 0 && Xwcschr(tls, uintptr(unsafe.Pointer(&_spaces)), Int32FromUint32(wc)) != 0) +} + +var _spaces = [22]Twchar_t{ + 0: int32(' '), + 1: int32('\t'), + 2: int32('\n'), + 3: int32('\r'), + 4: int32(11), + 5: int32(12), + 6: int32(0x0085), + 7: int32(0x2000), + 8: int32(0x2001), + 9: int32(0x2002), + 10: int32(0x2003), + 11: int32(0x2004), + 12: int32(0x2005), + 13: int32(0x2006), + 14: int32(0x2008), + 15: int32(0x2009), + 16: int32(0x200a), + 17: int32(0x2028), + 18: int32(0x2029), + 19: int32(0x205f), + 20: int32(0x3000), +} + +func X__iswspace_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswspace(tls, c) +} + +func Xiswspace_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswspace_l(tls, c, l) +} + +func Xiswupper(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Xtowlower(tls, wc) != wc) +} + +func X__iswupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswupper(tls, c) +} + +func Xiswupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswupper_l(tls, c, l) +} + +func Xiswxdigit(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(wc-Uint32FromUint8('0') < uint32(10) || wc|Uint32FromInt32(32)-Uint32FromUint8('a') < uint32(6)) +} + +func X__iswxdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswxdigit(tls, c) +} + +func Xiswxdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswxdigit_l(tls, c, l) +} + +func Xisxdigit(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(BoolInt32(Uint32FromInt32(c)-uint32('0') < uint32(10)) != 0 || Uint32FromInt32(c)|uint32(32)-uint32('a') < uint32(6)) +} + +func X__isxdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisxdigit(tls, c) +} + +func Xisxdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isxdigit_l(tls, c, l) +} + +// C documentation +// +// /* nonsense function that should NEVER be used! */ +func Xtoascii(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return c & int32(0x7f) +} + +func Xtolower(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + if BoolInt32(Uint32FromInt32(c)-uint32('A') < uint32(26)) != 0 { + return c | int32(32) + } + return c +} + +func X__tolower_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtolower(tls, c) +} + +func Xtolower_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__tolower_l(tls, c, l) +} + +func Xtoupper(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + if BoolInt32(Uint32FromInt32(c)-uint32('a') < uint32(26)) != 0 { + return c & int32(0x5f) + } + return c +} + +func X__toupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtoupper(tls, c) +} + +func Xtoupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__toupper_l(tls, c, l) +} + +var _tab1 = [2666]uint8{ + 0: uint8(7), + 1: uint8(8), + 2: uint8(9), + 3: uint8(10), + 4: uint8(11), + 5: uint8(12), + 6: uint8(6), + 7: uint8(6), + 8: uint8(6), + 9: uint8(6), + 10: uint8(6), + 11: uint8(6), + 12: uint8(6), + 13: uint8(6), + 14: uint8(6), + 15: uint8(6), + 16: uint8(13), + 17: uint8(6), + 18: uint8(6), + 19: uint8(14), + 20: uint8(6), + 21: uint8(6), + 22: uint8(6), + 23: uint8(6), + 24: uint8(6), + 25: uint8(6), + 26: uint8(6), + 27: uint8(6), + 28: uint8(15), + 29: uint8(16), + 30: uint8(17), + 31: uint8(18), + 32: uint8(6), + 33: uint8(19), + 34: uint8(6), + 35: uint8(6), + 36: uint8(6), + 37: uint8(6), + 38: uint8(6), + 39: uint8(6), + 40: uint8(6), + 41: uint8(6), + 42: uint8(6), + 43: uint8(6), + 44: uint8(20), + 45: uint8(21), + 46: uint8(6), + 47: uint8(6), + 48: uint8(6), + 49: uint8(6), + 50: uint8(6), + 51: uint8(6), + 52: uint8(6), + 53: uint8(6), + 54: uint8(6), + 55: uint8(6), + 56: uint8(6), + 57: uint8(6), + 58: uint8(6), + 59: uint8(6), + 60: uint8(6), + 61: uint8(6), + 62: uint8(6), + 63: uint8(6), + 64: uint8(6), + 65: uint8(6), + 66: uint8(6), + 67: uint8(6), + 68: uint8(6), + 69: uint8(6), + 70: uint8(6), + 71: uint8(6), + 72: uint8(6), + 73: uint8(6), + 74: uint8(6), + 75: uint8(6), + 76: uint8(6), + 77: uint8(6), + 78: uint8(6), + 79: uint8(6), + 80: uint8(6), + 81: uint8(6), + 82: uint8(6), + 83: uint8(6), + 84: uint8(6), + 85: uint8(6), + 86: uint8(6), + 87: uint8(6), + 88: uint8(6), + 89: uint8(6), + 90: uint8(6), + 91: uint8(6), + 92: uint8(6), + 93: uint8(6), + 94: uint8(6), + 95: uint8(6), + 96: uint8(6), + 97: uint8(6), + 98: uint8(6), + 99: uint8(6), + 100: uint8(6), + 101: uint8(6), + 102: uint8(6), + 103: uint8(6), + 104: uint8(6), + 105: uint8(6), + 106: uint8(6), + 107: uint8(6), + 108: uint8(6), + 109: uint8(6), + 110: uint8(6), + 111: uint8(6), + 112: uint8(6), + 113: uint8(6), + 114: uint8(6), + 115: uint8(6), + 116: uint8(6), + 117: uint8(6), + 118: uint8(6), + 119: uint8(6), + 120: uint8(6), + 121: uint8(6), + 122: uint8(6), + 123: uint8(6), + 124: uint8(6), + 125: uint8(6), + 126: uint8(6), + 127: uint8(6), + 128: uint8(6), + 129: uint8(6), + 130: uint8(6), + 131: uint8(6), + 132: uint8(6), + 133: uint8(6), + 134: uint8(6), + 135: uint8(6), + 136: uint8(6), + 137: uint8(6), + 138: uint8(6), + 139: uint8(6), + 140: uint8(6), + 141: uint8(6), + 142: uint8(6), + 143: uint8(6), + 144: uint8(6), + 145: uint8(6), + 146: uint8(6), + 147: uint8(6), + 148: uint8(6), + 149: uint8(6), + 150: uint8(6), + 151: uint8(6), + 152: uint8(6), + 153: uint8(6), + 154: uint8(6), + 155: uint8(6), + 156: uint8(6), + 157: uint8(6), + 158: uint8(6), + 159: uint8(6), + 160: uint8(6), + 161: uint8(6), + 162: uint8(6), + 163: uint8(6), + 164: uint8(6), + 165: uint8(6), + 166: uint8(22), + 167: uint8(23), + 168: uint8(6), + 169: uint8(6), + 170: uint8(6), + 171: uint8(24), + 172: uint8(6), + 173: uint8(6), + 174: uint8(6), + 175: uint8(6), + 176: uint8(6), + 177: uint8(6), + 178: uint8(6), + 179: uint8(6), + 180: uint8(6), + 181: uint8(6), + 182: uint8(6), + 183: uint8(6), + 184: uint8(6), + 185: uint8(6), + 186: uint8(6), + 187: uint8(6), + 188: uint8(6), + 189: uint8(6), + 190: uint8(6), + 191: uint8(6), + 192: uint8(6), + 193: uint8(6), + 194: uint8(6), + 195: uint8(6), + 196: uint8(6), + 197: uint8(6), + 198: uint8(6), + 199: uint8(6), + 200: uint8(6), + 201: uint8(6), + 202: uint8(6), + 203: uint8(6), + 204: uint8(6), + 205: uint8(6), + 206: uint8(6), + 207: uint8(6), + 208: uint8(6), + 209: uint8(6), + 210: uint8(6), + 211: uint8(6), + 212: uint8(6), + 213: uint8(6), + 214: uint8(6), + 215: uint8(6), + 216: uint8(6), + 217: uint8(6), + 218: uint8(6), + 219: uint8(6), + 220: uint8(6), + 221: uint8(6), + 222: uint8(6), + 223: uint8(6), + 224: uint8(6), + 225: uint8(6), + 226: uint8(6), + 227: uint8(6), + 228: uint8(6), + 229: uint8(6), + 230: uint8(6), + 231: uint8(6), + 232: uint8(6), + 233: uint8(6), + 234: uint8(6), + 235: uint8(6), + 236: uint8(6), + 237: uint8(6), + 238: uint8(6), + 239: uint8(6), + 240: uint8(6), + 241: uint8(6), + 242: uint8(6), + 243: uint8(6), + 244: uint8(6), + 245: uint8(6), + 246: uint8(6), + 247: uint8(6), + 248: uint8(6), + 249: uint8(6), + 250: uint8(6), + 251: uint8(6), + 252: uint8(6), + 253: uint8(6), + 254: uint8(6), + 255: uint8(25), + 256: uint8(6), + 257: uint8(6), + 258: uint8(6), + 259: uint8(6), + 260: uint8(26), + 261: uint8(6), + 262: uint8(6), + 263: uint8(6), + 264: uint8(6), + 265: uint8(6), + 266: uint8(6), + 267: uint8(6), + 268: uint8(27), + 269: uint8(6), + 270: uint8(6), + 271: uint8(6), + 272: uint8(6), + 273: uint8(6), + 274: uint8(6), + 275: uint8(6), + 276: uint8(6), + 277: uint8(6), + 278: uint8(6), + 279: uint8(6), + 280: uint8(28), + 281: uint8(6), + 282: uint8(6), + 283: uint8(6), + 284: uint8(6), + 285: uint8(6), + 286: uint8(6), + 287: uint8(6), + 288: uint8(6), + 289: uint8(6), + 290: uint8(6), + 291: uint8(6), + 292: uint8(6), + 293: uint8(6), + 294: uint8(6), + 295: uint8(6), + 296: uint8(6), + 297: uint8(6), + 298: uint8(6), + 299: uint8(6), + 300: uint8(6), + 301: uint8(6), + 302: uint8(6), + 303: uint8(6), + 304: uint8(6), + 305: uint8(6), + 306: uint8(6), + 307: uint8(6), + 308: uint8(6), + 309: uint8(6), + 310: uint8(6), + 311: uint8(6), + 312: uint8(6), + 313: uint8(6), + 314: uint8(6), + 315: uint8(6), + 316: uint8(6), + 317: uint8(6), + 318: uint8(6), + 319: uint8(6), + 320: uint8(6), + 321: uint8(6), + 322: uint8(6), + 323: uint8(6), + 324: uint8(6), + 325: uint8(6), + 326: uint8(6), + 327: uint8(6), + 328: uint8(6), + 329: uint8(6), + 330: uint8(6), + 331: uint8(6), + 332: uint8(6), + 333: uint8(6), + 334: uint8(6), + 335: uint8(6), + 336: uint8(6), + 337: uint8(6), + 338: uint8(6), + 339: uint8(6), + 340: uint8(6), + 341: uint8(6), + 342: uint8(6), + 343: uint8(6), + 344: uint8(6), + 345: uint8(6), + 346: uint8(6), + 347: uint8(6), + 348: uint8(6), + 349: uint8(6), + 350: uint8(6), + 351: uint8(6), + 352: uint8(6), + 353: uint8(6), + 354: uint8(6), + 355: uint8(6), + 356: uint8(6), + 357: uint8(6), + 358: uint8(6), + 359: uint8(6), + 360: uint8(6), + 361: uint8(6), + 362: uint8(6), + 363: uint8(6), + 364: uint8(6), + 365: uint8(6), + 366: uint8(29), + 367: uint8(6), + 368: uint8(6), + 369: uint8(6), + 370: uint8(6), + 371: uint8(6), + 372: uint8(6), + 373: uint8(6), + 374: uint8(6), + 375: uint8(6), + 376: uint8(6), + 377: uint8(6), + 378: uint8(6), + 379: uint8(6), + 380: uint8(6), + 381: uint8(6), + 382: uint8(6), + 383: uint8(6), + 384: uint8(6), + 385: uint8(6), + 386: uint8(6), + 387: uint8(6), + 388: uint8(6), + 389: uint8(6), + 390: uint8(6), + 391: uint8(6), + 392: uint8(6), + 393: uint8(6), + 394: uint8(6), + 395: uint8(6), + 396: uint8(6), + 397: uint8(6), + 398: uint8(6), + 399: uint8(6), + 400: uint8(6), + 401: uint8(6), + 402: uint8(6), + 403: uint8(6), + 404: uint8(6), + 405: uint8(6), + 406: uint8(6), + 407: uint8(6), + 408: uint8(6), + 409: uint8(6), + 410: uint8(6), + 411: uint8(6), + 412: uint8(6), + 413: uint8(6), + 414: uint8(6), + 415: uint8(6), + 416: uint8(6), + 417: uint8(6), + 418: uint8(6), + 419: uint8(6), + 420: uint8(6), + 421: uint8(6), + 422: uint8(6), + 423: uint8(6), + 424: uint8(6), + 425: uint8(6), + 426: uint8(6), + 427: uint8(6), + 428: uint8(6), + 429: uint8(6), + 430: uint8(6), + 431: uint8(6), + 432: uint8(6), + 433: uint8(6), + 434: uint8(6), + 435: uint8(6), + 436: uint8(6), + 437: uint8(6), + 438: uint8(6), + 439: uint8(6), + 440: uint8(6), + 441: uint8(6), + 442: uint8(6), + 443: uint8(6), + 444: uint8(6), + 445: uint8(6), + 446: uint8(6), + 447: uint8(6), + 448: uint8(6), + 449: uint8(6), + 450: uint8(6), + 451: uint8(6), + 452: uint8(6), + 453: uint8(6), + 454: uint8(6), + 455: uint8(6), + 456: uint8(6), + 457: uint8(6), + 458: uint8(6), + 459: uint8(6), + 460: uint8(6), + 461: uint8(6), + 462: uint8(6), + 463: uint8(6), + 464: uint8(6), + 465: uint8(6), + 466: uint8(6), + 467: uint8(6), + 468: uint8(6), + 469: uint8(6), + 470: uint8(6), + 471: uint8(6), + 472: uint8(6), + 473: uint8(6), + 474: uint8(6), + 475: uint8(6), + 476: uint8(6), + 477: uint8(6), + 478: uint8(6), + 479: uint8(6), + 480: uint8(6), + 481: uint8(6), + 482: uint8(6), + 483: uint8(6), + 484: uint8(6), + 485: uint8(6), + 486: uint8(6), + 487: uint8(6), + 488: uint8(6), + 489: uint8(30), + 490: uint8(6), + 491: uint8(6), + 492: uint8(6), + 493: uint8(6), + 494: uint8(6), + 495: uint8(6), + 496: uint8(6), + 497: uint8(6), + 498: uint8(6), + 499: uint8(6), + 500: uint8(6), + 501: uint8(6), + 502: uint8(6), + 503: uint8(6), + 504: uint8(6), + 505: uint8(6), + 506: uint8(6), + 507: uint8(6), + 508: uint8(6), + 509: uint8(6), + 510: uint8(6), + 511: uint8(6), + 623: uint8(36), + 624: uint8(43), + 625: uint8(43), + 626: uint8(43), + 627: uint8(43), + 628: uint8(43), + 629: uint8(43), + 630: uint8(43), + 631: uint8(43), + 632: uint8(1), + 634: uint8(84), + 635: uint8(86), + 636: uint8(86), + 637: uint8(86), + 638: uint8(86), + 639: uint8(86), + 640: uint8(86), + 641: uint8(86), + 642: uint8(86), + 662: uint8(24), + 666: uint8(43), + 667: uint8(43), + 668: uint8(43), + 669: uint8(43), + 670: uint8(43), + 671: uint8(43), + 672: uint8(43), + 673: uint8(7), + 674: uint8(43), + 675: uint8(43), + 676: uint8(91), + 677: uint8(86), + 678: uint8(86), + 679: uint8(86), + 680: uint8(86), + 681: uint8(86), + 682: uint8(86), + 683: uint8(86), + 684: uint8(74), + 685: uint8(86), + 686: uint8(86), + 687: uint8(5), + 688: uint8(49), + 689: uint8(80), + 690: uint8(49), + 691: uint8(80), + 692: uint8(49), + 693: uint8(80), + 694: uint8(49), + 695: uint8(80), + 696: uint8(49), + 697: uint8(80), + 698: uint8(49), + 699: uint8(80), + 700: uint8(49), + 701: uint8(80), + 702: uint8(49), + 703: uint8(80), + 704: uint8(36), + 705: uint8(80), + 706: uint8(121), + 707: uint8(49), + 708: uint8(80), + 709: uint8(49), + 710: uint8(80), + 711: uint8(49), + 712: uint8(56), + 713: uint8(80), + 714: uint8(49), + 715: uint8(80), + 716: uint8(49), + 717: uint8(80), + 718: uint8(49), + 719: uint8(80), + 720: uint8(49), + 721: uint8(80), + 722: uint8(49), + 723: uint8(80), + 724: uint8(49), + 725: uint8(80), + 726: uint8(49), + 727: uint8(80), + 728: uint8(78), + 729: uint8(49), + 730: uint8(2), + 731: uint8(78), + 732: uint8(13), + 733: uint8(13), + 734: uint8(78), + 735: uint8(3), + 736: uint8(78), + 738: uint8(36), + 739: uint8(110), + 741: uint8(78), + 742: uint8(49), + 743: uint8(38), + 744: uint8(110), + 745: uint8(81), + 746: uint8(78), + 747: uint8(36), + 748: uint8(80), + 749: uint8(78), + 750: uint8(57), + 751: uint8(20), + 752: uint8(129), + 753: uint8(27), + 754: uint8(29), + 755: uint8(29), + 756: uint8(83), + 757: uint8(49), + 758: uint8(80), + 759: uint8(49), + 760: uint8(80), + 761: uint8(13), + 762: uint8(49), + 763: uint8(80), + 764: uint8(49), + 765: uint8(80), + 766: uint8(49), + 767: uint8(80), + 768: uint8(27), + 769: uint8(83), + 770: uint8(36), + 771: uint8(80), + 772: uint8(49), + 773: uint8(2), + 774: uint8(92), + 775: uint8(123), + 776: uint8(92), + 777: uint8(123), + 778: uint8(92), + 779: uint8(123), + 780: uint8(92), + 781: uint8(123), + 782: uint8(92), + 783: uint8(123), + 784: uint8(20), + 785: uint8(121), + 786: uint8(92), + 787: uint8(123), + 788: uint8(92), + 789: uint8(123), + 790: uint8(92), + 791: uint8(45), + 792: uint8(43), + 793: uint8(73), + 794: uint8(3), + 795: uint8(72), + 796: uint8(3), + 797: uint8(120), + 798: uint8(92), + 799: uint8(123), + 800: uint8(20), + 802: uint8(150), + 803: uint8(10), + 804: uint8(1), + 805: uint8(43), + 806: uint8(40), + 807: uint8(6), + 808: uint8(6), + 810: uint8(42), + 811: uint8(6), + 812: uint8(42), + 813: uint8(42), + 814: uint8(43), + 815: uint8(7), + 816: uint8(187), + 817: uint8(181), + 818: uint8(43), + 819: uint8(30), + 821: uint8(43), + 822: uint8(7), + 823: uint8(43), + 824: uint8(43), + 825: uint8(43), + 826: uint8(1), + 827: uint8(43), + 828: uint8(43), + 829: uint8(43), + 830: uint8(43), + 831: uint8(43), + 832: uint8(43), + 833: uint8(43), + 834: uint8(43), + 835: uint8(43), + 836: uint8(43), + 837: uint8(43), + 838: uint8(43), + 839: uint8(43), + 840: uint8(43), + 841: uint8(43), + 842: uint8(43), + 843: uint8(43), + 844: uint8(43), + 845: uint8(43), + 846: uint8(43), + 847: uint8(43), + 848: uint8(43), + 849: uint8(43), + 850: uint8(43), + 851: uint8(43), + 852: uint8(43), + 853: uint8(43), + 854: uint8(43), + 855: uint8(43), + 856: uint8(43), + 857: uint8(43), + 858: uint8(43), + 859: uint8(1), + 860: uint8(43), + 861: uint8(43), + 862: uint8(43), + 863: uint8(43), + 864: uint8(43), + 865: uint8(43), + 866: uint8(43), + 867: uint8(43), + 868: uint8(43), + 869: uint8(43), + 870: uint8(43), + 871: uint8(43), + 872: uint8(43), + 873: uint8(43), + 874: uint8(43), + 875: uint8(43), + 876: uint8(43), + 877: uint8(43), + 878: uint8(43), + 879: uint8(43), + 880: uint8(43), + 881: uint8(43), + 882: uint8(43), + 883: uint8(42), + 884: uint8(43), + 885: uint8(43), + 886: uint8(43), + 887: uint8(43), + 888: uint8(43), + 889: uint8(43), + 890: uint8(43), + 891: uint8(43), + 892: uint8(43), + 893: uint8(43), + 894: uint8(43), + 895: uint8(43), + 896: uint8(43), + 897: uint8(205), + 898: uint8(70), + 899: uint8(205), + 900: uint8(43), + 902: uint8(37), + 903: uint8(43), + 904: uint8(7), + 905: uint8(1), + 906: uint8(6), + 907: uint8(1), + 908: uint8(85), + 909: uint8(86), + 910: uint8(86), + 911: uint8(86), + 912: uint8(86), + 913: uint8(86), + 914: uint8(85), + 915: uint8(86), + 916: uint8(86), + 917: uint8(2), + 918: uint8(36), + 919: uint8(129), + 920: uint8(129), + 921: uint8(129), + 922: uint8(129), + 923: uint8(129), + 924: uint8(21), + 925: uint8(129), + 926: uint8(129), + 927: uint8(129), + 930: uint8(43), + 932: uint8(178), + 933: uint8(209), + 934: uint8(178), + 935: uint8(209), + 936: uint8(178), + 937: uint8(209), + 938: uint8(178), + 939: uint8(209), + 942: uint8(205), + 943: uint8(204), + 944: uint8(1), + 946: uint8(215), + 947: uint8(215), + 948: uint8(215), + 949: uint8(215), + 950: uint8(215), + 951: uint8(131), + 952: uint8(129), + 953: uint8(129), + 954: uint8(129), + 955: uint8(129), + 956: uint8(129), + 957: uint8(129), + 958: uint8(129), + 959: uint8(129), + 960: uint8(129), + 961: uint8(129), + 962: uint8(172), + 963: uint8(172), + 964: uint8(172), + 965: uint8(172), + 966: uint8(172), + 967: uint8(172), + 968: uint8(172), + 969: uint8(172), + 970: uint8(172), + 971: uint8(172), + 972: uint8(28), + 978: uint8(49), + 979: uint8(80), + 980: uint8(49), + 981: uint8(80), + 982: uint8(49), + 983: uint8(80), + 984: uint8(49), + 985: uint8(80), + 986: uint8(49), + 987: uint8(80), + 988: uint8(49), + 989: uint8(2), + 992: uint8(49), + 993: uint8(80), + 994: uint8(49), + 995: uint8(80), + 996: uint8(49), + 997: uint8(80), + 998: uint8(49), + 999: uint8(80), + 1000: uint8(49), + 1001: uint8(80), + 1002: uint8(49), + 1003: uint8(80), + 1004: uint8(49), + 1005: uint8(80), + 1006: uint8(49), + 1007: uint8(80), + 1008: uint8(49), + 1009: uint8(80), + 1010: uint8(78), + 1011: uint8(49), + 1012: uint8(80), + 1013: uint8(49), + 1014: uint8(80), + 1015: uint8(78), + 1016: uint8(49), + 1017: uint8(80), + 1018: uint8(49), + 1019: uint8(80), + 1020: uint8(49), + 1021: uint8(80), + 1022: uint8(49), + 1023: uint8(80), + 1024: uint8(49), + 1025: uint8(80), + 1026: uint8(49), + 1027: uint8(80), + 1028: uint8(49), + 1029: uint8(80), + 1030: uint8(49), + 1031: uint8(2), + 1032: uint8(135), + 1033: uint8(166), + 1034: uint8(135), + 1035: uint8(166), + 1036: uint8(135), + 1037: uint8(166), + 1038: uint8(135), + 1039: uint8(166), + 1040: uint8(135), + 1041: uint8(166), + 1042: uint8(135), + 1043: uint8(166), + 1044: uint8(135), + 1045: uint8(166), + 1046: uint8(135), + 1047: uint8(166), + 1048: uint8(42), + 1049: uint8(43), + 1050: uint8(43), + 1051: uint8(43), + 1052: uint8(43), + 1053: uint8(43), + 1054: uint8(43), + 1055: uint8(43), + 1056: uint8(43), + 1057: uint8(43), + 1058: uint8(43), + 1059: uint8(43), + 1060: uint8(43), + 1064: uint8(84), + 1065: uint8(86), + 1066: uint8(86), + 1067: uint8(86), + 1068: uint8(86), + 1069: uint8(86), + 1070: uint8(86), + 1071: uint8(86), + 1072: uint8(86), + 1073: uint8(86), + 1074: uint8(86), + 1075: uint8(86), + 1076: uint8(86), + 1171: uint8(84), + 1172: uint8(86), + 1173: uint8(86), + 1174: uint8(86), + 1175: uint8(86), + 1176: uint8(86), + 1177: uint8(86), + 1178: uint8(86), + 1179: uint8(86), + 1180: uint8(86), + 1181: uint8(86), + 1182: uint8(86), + 1183: uint8(86), + 1184: uint8(12), + 1186: uint8(12), + 1187: uint8(42), + 1188: uint8(43), + 1189: uint8(43), + 1190: uint8(43), + 1191: uint8(43), + 1192: uint8(43), + 1193: uint8(43), + 1194: uint8(43), + 1195: uint8(43), + 1196: uint8(43), + 1197: uint8(43), + 1198: uint8(43), + 1199: uint8(43), + 1200: uint8(43), + 1201: uint8(7), + 1202: uint8(42), + 1203: uint8(1), + 1257: uint8(42), + 1258: uint8(43), + 1259: uint8(43), + 1260: uint8(43), + 1261: uint8(43), + 1262: uint8(43), + 1263: uint8(43), + 1264: uint8(43), + 1265: uint8(43), + 1266: uint8(43), + 1267: uint8(43), + 1268: uint8(43), + 1269: uint8(43), + 1270: uint8(43), + 1271: uint8(43), + 1272: uint8(43), + 1273: uint8(43), + 1274: uint8(43), + 1275: uint8(43), + 1276: uint8(43), + 1277: uint8(43), + 1278: uint8(43), + 1279: uint8(43), + 1280: uint8(43), + 1281: uint8(43), + 1282: uint8(43), + 1283: uint8(43), + 1284: uint8(86), + 1285: uint8(86), + 1286: uint8(108), + 1287: uint8(129), + 1288: uint8(21), + 1290: uint8(43), + 1291: uint8(43), + 1292: uint8(43), + 1293: uint8(43), + 1294: uint8(43), + 1295: uint8(43), + 1296: uint8(43), + 1297: uint8(43), + 1298: uint8(43), + 1299: uint8(43), + 1300: uint8(43), + 1301: uint8(43), + 1302: uint8(43), + 1303: uint8(43), + 1304: uint8(43), + 1305: uint8(43), + 1306: uint8(43), + 1307: uint8(43), + 1308: uint8(43), + 1309: uint8(43), + 1310: uint8(43), + 1311: uint8(43), + 1312: uint8(43), + 1313: uint8(43), + 1314: uint8(43), + 1315: uint8(43), + 1316: uint8(43), + 1317: uint8(43), + 1318: uint8(43), + 1319: uint8(43), + 1320: uint8(43), + 1321: uint8(43), + 1322: uint8(43), + 1323: uint8(43), + 1324: uint8(43), + 1325: uint8(43), + 1326: uint8(43), + 1327: uint8(43), + 1328: uint8(43), + 1329: uint8(43), + 1330: uint8(43), + 1331: uint8(43), + 1332: uint8(7), + 1333: uint8(108), + 1334: uint8(3), + 1335: uint8(65), + 1336: uint8(43), + 1337: uint8(43), + 1338: uint8(86), + 1339: uint8(86), + 1340: uint8(86), + 1341: uint8(86), + 1342: uint8(86), + 1343: uint8(86), + 1344: uint8(86), + 1345: uint8(86), + 1346: uint8(86), + 1347: uint8(86), + 1348: uint8(86), + 1349: uint8(86), + 1350: uint8(86), + 1351: uint8(86), + 1352: uint8(44), + 1353: uint8(86), + 1354: uint8(43), + 1355: uint8(43), + 1356: uint8(43), + 1357: uint8(43), + 1358: uint8(43), + 1359: uint8(43), + 1360: uint8(43), + 1361: uint8(43), + 1362: uint8(43), + 1363: uint8(43), + 1364: uint8(43), + 1365: uint8(43), + 1366: uint8(43), + 1367: uint8(43), + 1368: uint8(43), + 1369: uint8(43), + 1370: uint8(43), + 1371: uint8(43), + 1372: uint8(43), + 1373: uint8(43), + 1374: uint8(43), + 1375: uint8(1), + 1416: uint8(12), + 1417: uint8(108), + 1423: uint8(6), + 1462: uint8(6), + 1463: uint8(37), + 1464: uint8(6), + 1465: uint8(37), + 1466: uint8(6), + 1467: uint8(37), + 1468: uint8(6), + 1469: uint8(37), + 1470: uint8(6), + 1471: uint8(37), + 1472: uint8(6), + 1473: uint8(37), + 1474: uint8(6), + 1475: uint8(37), + 1476: uint8(6), + 1477: uint8(37), + 1478: uint8(6), + 1479: uint8(37), + 1480: uint8(6), + 1481: uint8(37), + 1482: uint8(6), + 1483: uint8(37), + 1484: uint8(6), + 1485: uint8(37), + 1486: uint8(6), + 1487: uint8(37), + 1488: uint8(6), + 1489: uint8(37), + 1490: uint8(6), + 1491: uint8(37), + 1492: uint8(6), + 1493: uint8(37), + 1494: uint8(6), + 1495: uint8(37), + 1496: uint8(6), + 1497: uint8(37), + 1498: uint8(6), + 1499: uint8(37), + 1500: uint8(6), + 1501: uint8(37), + 1502: uint8(6), + 1503: uint8(37), + 1504: uint8(6), + 1505: uint8(37), + 1506: uint8(6), + 1507: uint8(37), + 1508: uint8(6), + 1509: uint8(37), + 1510: uint8(6), + 1511: uint8(37), + 1512: uint8(86), + 1513: uint8(122), + 1514: uint8(158), + 1515: uint8(38), + 1516: uint8(6), + 1517: uint8(37), + 1518: uint8(6), + 1519: uint8(37), + 1520: uint8(6), + 1521: uint8(37), + 1522: uint8(6), + 1523: uint8(37), + 1524: uint8(6), + 1525: uint8(37), + 1526: uint8(6), + 1527: uint8(37), + 1528: uint8(6), + 1529: uint8(37), + 1530: uint8(6), + 1531: uint8(37), + 1532: uint8(6), + 1533: uint8(37), + 1534: uint8(6), + 1535: uint8(37), + 1536: uint8(6), + 1537: uint8(37), + 1538: uint8(6), + 1539: uint8(37), + 1540: uint8(6), + 1541: uint8(37), + 1542: uint8(6), + 1543: uint8(37), + 1544: uint8(6), + 1545: uint8(37), + 1546: uint8(6), + 1547: uint8(1), + 1548: uint8(43), + 1549: uint8(43), + 1550: uint8(79), + 1551: uint8(86), + 1552: uint8(86), + 1553: uint8(44), + 1554: uint8(43), + 1555: uint8(127), + 1556: uint8(86), + 1557: uint8(86), + 1558: uint8(57), + 1559: uint8(43), + 1560: uint8(43), + 1561: uint8(85), + 1562: uint8(86), + 1563: uint8(86), + 1564: uint8(43), + 1565: uint8(43), + 1566: uint8(79), + 1567: uint8(86), + 1568: uint8(86), + 1569: uint8(44), + 1570: uint8(43), + 1571: uint8(127), + 1572: uint8(86), + 1573: uint8(86), + 1574: uint8(129), + 1575: uint8(55), + 1576: uint8(117), + 1577: uint8(91), + 1578: uint8(123), + 1579: uint8(92), + 1580: uint8(43), + 1581: uint8(43), + 1582: uint8(79), + 1583: uint8(86), + 1584: uint8(86), + 1585: uint8(2), + 1586: uint8(172), + 1587: uint8(4), + 1590: uint8(57), + 1591: uint8(43), + 1592: uint8(43), + 1593: uint8(85), + 1594: uint8(86), + 1595: uint8(86), + 1596: uint8(43), + 1597: uint8(43), + 1598: uint8(79), + 1599: uint8(86), + 1600: uint8(86), + 1601: uint8(44), + 1602: uint8(43), + 1603: uint8(43), + 1604: uint8(86), + 1605: uint8(86), + 1606: uint8(50), + 1607: uint8(19), + 1608: uint8(129), + 1609: uint8(87), + 1611: uint8(111), + 1612: uint8(129), + 1613: uint8(126), + 1614: uint8(201), + 1615: uint8(215), + 1616: uint8(126), + 1617: uint8(45), + 1618: uint8(129), + 1619: uint8(129), + 1620: uint8(14), + 1621: uint8(126), + 1622: uint8(57), + 1623: uint8(127), + 1624: uint8(111), + 1625: uint8(87), + 1627: uint8(129), + 1628: uint8(129), + 1629: uint8(126), + 1630: uint8(21), + 1632: uint8(126), + 1633: uint8(3), + 1634: uint8(43), + 1635: uint8(43), + 1636: uint8(43), + 1637: uint8(43), + 1638: uint8(43), + 1639: uint8(43), + 1640: uint8(43), + 1641: uint8(43), + 1642: uint8(43), + 1643: uint8(43), + 1644: uint8(43), + 1645: uint8(43), + 1646: uint8(7), + 1647: uint8(43), + 1648: uint8(36), + 1649: uint8(43), + 1650: uint8(151), + 1651: uint8(43), + 1652: uint8(43), + 1653: uint8(43), + 1654: uint8(43), + 1655: uint8(43), + 1656: uint8(43), + 1657: uint8(43), + 1658: uint8(43), + 1659: uint8(43), + 1660: uint8(42), + 1661: uint8(43), + 1662: uint8(43), + 1663: uint8(43), + 1664: uint8(43), + 1665: uint8(43), + 1666: uint8(86), + 1667: uint8(86), + 1668: uint8(86), + 1669: uint8(86), + 1670: uint8(86), + 1671: uint8(128), + 1672: uint8(129), + 1673: uint8(129), + 1674: uint8(129), + 1675: uint8(129), + 1676: uint8(57), + 1677: uint8(187), + 1678: uint8(42), + 1679: uint8(43), + 1680: uint8(43), + 1681: uint8(43), + 1682: uint8(43), + 1683: uint8(43), + 1684: uint8(43), + 1685: uint8(43), + 1686: uint8(43), + 1687: uint8(43), + 1688: uint8(43), + 1689: uint8(43), + 1690: uint8(43), + 1691: uint8(43), + 1692: uint8(43), + 1693: uint8(43), + 1694: uint8(43), + 1695: uint8(43), + 1696: uint8(43), + 1697: uint8(43), + 1698: uint8(43), + 1699: uint8(43), + 1700: uint8(43), + 1701: uint8(43), + 1702: uint8(43), + 1703: uint8(43), + 1704: uint8(43), + 1705: uint8(43), + 1706: uint8(43), + 1707: uint8(43), + 1708: uint8(43), + 1709: uint8(43), + 1710: uint8(43), + 1711: uint8(43), + 1712: uint8(43), + 1713: uint8(43), + 1714: uint8(43), + 1715: uint8(43), + 1716: uint8(43), + 1717: uint8(43), + 1718: uint8(43), + 1719: uint8(1), + 1720: uint8(129), + 1721: uint8(129), + 1722: uint8(129), + 1723: uint8(129), + 1724: uint8(129), + 1725: uint8(129), + 1726: uint8(129), + 1727: uint8(129), + 1728: uint8(129), + 1729: uint8(129), + 1730: uint8(129), + 1731: uint8(129), + 1732: uint8(129), + 1733: uint8(129), + 1734: uint8(129), + 1735: uint8(201), + 1736: uint8(172), + 1737: uint8(172), + 1738: uint8(172), + 1739: uint8(172), + 1740: uint8(172), + 1741: uint8(172), + 1742: uint8(172), + 1743: uint8(172), + 1744: uint8(172), + 1745: uint8(172), + 1746: uint8(172), + 1747: uint8(172), + 1748: uint8(172), + 1749: uint8(172), + 1750: uint8(172), + 1751: uint8(208), + 1752: uint8(13), + 1754: uint8(78), + 1755: uint8(49), + 1756: uint8(2), + 1757: uint8(180), + 1758: uint8(193), + 1759: uint8(193), + 1760: uint8(215), + 1761: uint8(215), + 1762: uint8(36), + 1763: uint8(80), + 1764: uint8(49), + 1765: uint8(80), + 1766: uint8(49), + 1767: uint8(80), + 1768: uint8(49), + 1769: uint8(80), + 1770: uint8(49), + 1771: uint8(80), + 1772: uint8(49), + 1773: uint8(80), + 1774: uint8(49), + 1775: uint8(80), + 1776: uint8(49), + 1777: uint8(80), + 1778: uint8(49), + 1779: uint8(80), + 1780: uint8(49), + 1781: uint8(80), + 1782: uint8(49), + 1783: uint8(80), + 1784: uint8(49), + 1785: uint8(80), + 1786: uint8(49), + 1787: uint8(80), + 1788: uint8(49), + 1789: uint8(80), + 1790: uint8(49), + 1791: uint8(80), + 1792: uint8(49), + 1793: uint8(80), + 1794: uint8(49), + 1795: uint8(80), + 1796: uint8(215), + 1797: uint8(215), + 1798: uint8(83), + 1799: uint8(193), + 1800: uint8(71), + 1801: uint8(212), + 1802: uint8(215), + 1803: uint8(215), + 1804: uint8(215), + 1805: uint8(5), + 1806: uint8(43), + 1807: uint8(43), + 1808: uint8(43), + 1809: uint8(43), + 1810: uint8(43), + 1811: uint8(43), + 1812: uint8(43), + 1813: uint8(43), + 1814: uint8(43), + 1815: uint8(43), + 1816: uint8(43), + 1817: uint8(43), + 1818: uint8(7), + 1819: uint8(1), + 1821: uint8(1), + 1913: uint8(78), + 1914: uint8(49), + 1915: uint8(80), + 1916: uint8(49), + 1917: uint8(80), + 1918: uint8(49), + 1919: uint8(80), + 1920: uint8(49), + 1921: uint8(80), + 1922: uint8(49), + 1923: uint8(80), + 1924: uint8(49), + 1925: uint8(80), + 1926: uint8(49), + 1927: uint8(80), + 1928: uint8(13), + 1934: uint8(36), + 1935: uint8(80), + 1936: uint8(49), + 1937: uint8(80), + 1938: uint8(49), + 1939: uint8(80), + 1940: uint8(49), + 1941: uint8(80), + 1942: uint8(49), + 1943: uint8(80), + 1978: uint8(43), + 1979: uint8(43), + 1980: uint8(43), + 1981: uint8(43), + 1982: uint8(43), + 1983: uint8(43), + 1984: uint8(43), + 1985: uint8(43), + 1986: uint8(43), + 1987: uint8(43), + 1988: uint8(43), + 1989: uint8(121), + 1990: uint8(92), + 1991: uint8(123), + 1992: uint8(92), + 1993: uint8(123), + 1994: uint8(79), + 1995: uint8(123), + 1996: uint8(92), + 1997: uint8(123), + 1998: uint8(92), + 1999: uint8(123), + 2000: uint8(92), + 2001: uint8(123), + 2002: uint8(92), + 2003: uint8(123), + 2004: uint8(92), + 2005: uint8(123), + 2006: uint8(92), + 2007: uint8(123), + 2008: uint8(92), + 2009: uint8(123), + 2010: uint8(92), + 2011: uint8(123), + 2012: uint8(92), + 2013: uint8(123), + 2014: uint8(92), + 2015: uint8(45), + 2016: uint8(43), + 2017: uint8(43), + 2018: uint8(121), + 2019: uint8(20), + 2020: uint8(92), + 2021: uint8(123), + 2022: uint8(92), + 2023: uint8(45), + 2024: uint8(121), + 2025: uint8(42), + 2026: uint8(92), + 2027: uint8(39), + 2028: uint8(92), + 2029: uint8(123), + 2030: uint8(92), + 2031: uint8(123), + 2032: uint8(92), + 2033: uint8(123), + 2034: uint8(164), + 2036: uint8(10), + 2037: uint8(180), + 2038: uint8(92), + 2039: uint8(123), + 2040: uint8(92), + 2041: uint8(123), + 2042: uint8(79), + 2043: uint8(3), + 2044: uint8(42), + 2045: uint8(43), + 2046: uint8(43), + 2047: uint8(43), + 2048: uint8(43), + 2049: uint8(43), + 2050: uint8(43), + 2051: uint8(43), + 2052: uint8(43), + 2053: uint8(43), + 2054: uint8(43), + 2055: uint8(43), + 2056: uint8(43), + 2057: uint8(43), + 2058: uint8(43), + 2059: uint8(43), + 2060: uint8(43), + 2061: uint8(43), + 2062: uint8(43), + 2063: uint8(1), + 2091: uint8(72), + 2101: uint8(42), + 2102: uint8(43), + 2103: uint8(43), + 2104: uint8(43), + 2105: uint8(43), + 2106: uint8(43), + 2107: uint8(43), + 2108: uint8(43), + 2109: uint8(43), + 2110: uint8(43), + 2111: uint8(43), + 2112: uint8(43), + 2113: uint8(43), + 2114: uint8(43), + 2115: uint8(43), + 2116: uint8(43), + 2117: uint8(43), + 2118: uint8(43), + 2119: uint8(43), + 2120: uint8(43), + 2121: uint8(43), + 2122: uint8(43), + 2123: uint8(43), + 2124: uint8(43), + 2125: uint8(43), + 2126: uint8(43), + 2127: uint8(43), + 2161: uint8(43), + 2162: uint8(43), + 2163: uint8(43), + 2164: uint8(43), + 2165: uint8(43), + 2166: uint8(43), + 2167: uint8(43), + 2168: uint8(43), + 2169: uint8(7), + 2171: uint8(72), + 2172: uint8(86), + 2173: uint8(86), + 2174: uint8(86), + 2175: uint8(86), + 2176: uint8(86), + 2177: uint8(86), + 2178: uint8(86), + 2179: uint8(86), + 2180: uint8(2), + 2236: uint8(43), + 2237: uint8(43), + 2238: uint8(43), + 2239: uint8(43), + 2240: uint8(43), + 2241: uint8(43), + 2242: uint8(43), + 2243: uint8(43), + 2244: uint8(43), + 2245: uint8(43), + 2246: uint8(43), + 2247: uint8(43), + 2248: uint8(43), + 2249: uint8(85), + 2250: uint8(86), + 2251: uint8(86), + 2252: uint8(86), + 2253: uint8(86), + 2254: uint8(86), + 2255: uint8(86), + 2256: uint8(86), + 2257: uint8(86), + 2258: uint8(86), + 2259: uint8(86), + 2260: uint8(86), + 2261: uint8(86), + 2262: uint8(14), + 2294: uint8(36), + 2295: uint8(43), + 2296: uint8(43), + 2297: uint8(43), + 2298: uint8(43), + 2299: uint8(43), + 2300: uint8(43), + 2301: uint8(43), + 2302: uint8(43), + 2303: uint8(43), + 2304: uint8(43), + 2305: uint8(43), + 2306: uint8(7), + 2308: uint8(86), + 2309: uint8(86), + 2310: uint8(86), + 2311: uint8(86), + 2312: uint8(86), + 2313: uint8(86), + 2314: uint8(86), + 2315: uint8(86), + 2316: uint8(86), + 2317: uint8(86), + 2318: uint8(86), + 2319: uint8(86), + 2364: uint8(36), + 2365: uint8(43), + 2366: uint8(43), + 2367: uint8(43), + 2368: uint8(43), + 2369: uint8(43), + 2370: uint8(43), + 2371: uint8(43), + 2372: uint8(43), + 2373: uint8(43), + 2374: uint8(43), + 2375: uint8(43), + 2376: uint8(43), + 2377: uint8(43), + 2378: uint8(43), + 2379: uint8(43), + 2380: uint8(43), + 2381: uint8(7), + 2386: uint8(86), + 2387: uint8(86), + 2388: uint8(86), + 2389: uint8(86), + 2390: uint8(86), + 2391: uint8(86), + 2392: uint8(86), + 2393: uint8(86), + 2394: uint8(86), + 2395: uint8(86), + 2396: uint8(86), + 2397: uint8(86), + 2398: uint8(86), + 2399: uint8(86), + 2400: uint8(86), + 2401: uint8(86), + 2402: uint8(86), + 2461: uint8(42), + 2462: uint8(43), + 2463: uint8(43), + 2464: uint8(43), + 2465: uint8(43), + 2466: uint8(43), + 2467: uint8(43), + 2468: uint8(43), + 2469: uint8(43), + 2470: uint8(43), + 2471: uint8(43), + 2472: uint8(86), + 2473: uint8(86), + 2474: uint8(86), + 2475: uint8(86), + 2476: uint8(86), + 2477: uint8(86), + 2478: uint8(86), + 2479: uint8(86), + 2480: uint8(86), + 2481: uint8(86), + 2482: uint8(14), + 2515: uint8(42), + 2516: uint8(43), + 2517: uint8(43), + 2518: uint8(43), + 2519: uint8(43), + 2520: uint8(43), + 2521: uint8(43), + 2522: uint8(43), + 2523: uint8(43), + 2524: uint8(43), + 2525: uint8(43), + 2526: uint8(86), + 2527: uint8(86), + 2528: uint8(86), + 2529: uint8(86), + 2530: uint8(86), + 2531: uint8(86), + 2532: uint8(86), + 2533: uint8(86), + 2534: uint8(86), + 2535: uint8(86), + 2536: uint8(14), + 2580: uint8(43), + 2581: uint8(43), + 2582: uint8(43), + 2583: uint8(43), + 2584: uint8(43), + 2585: uint8(43), + 2586: uint8(43), + 2587: uint8(43), + 2588: uint8(43), + 2589: uint8(43), + 2590: uint8(43), + 2591: uint8(85), + 2592: uint8(86), + 2593: uint8(86), + 2594: uint8(86), + 2595: uint8(86), + 2596: uint8(86), + 2597: uint8(86), + 2598: uint8(86), + 2599: uint8(86), + 2600: uint8(86), + 2601: uint8(86), + 2602: uint8(14), +} +var _rules = [240]int32{ + 1: int32(0x2001), + 2: -int32(0x2000), + 3: int32(0x1dbf00), + 4: int32(0x2e700), + 5: int32(0x7900), + 6: int32(0x2402), + 7: int32(0x101), + 8: -int32(0x100), + 10: int32(0x201), + 11: -int32(0x200), + 12: -int32(0xc6ff), + 13: -int32(0xe800), + 14: -int32(0x78ff), + 15: -int32(0x12c00), + 16: int32(0xc300), + 17: int32(0xd201), + 18: int32(0xce01), + 19: int32(0xcd01), + 20: int32(0x4f01), + 21: int32(0xca01), + 22: int32(0xcb01), + 23: int32(0xcf01), + 24: int32(0x6100), + 25: int32(0xd301), + 26: int32(0xd101), + 27: int32(0xa300), + 28: int32(0xd501), + 29: int32(0x8200), + 30: int32(0xd601), + 31: int32(0xda01), + 32: int32(0xd901), + 33: int32(0xdb01), + 34: int32(0x3800), + 35: int32(0x3), + 36: -int32(0x4f00), + 37: -int32(0x60ff), + 38: -int32(0x37ff), + 39: int32(0x242802), + 41: int32(0x101), + 42: -int32(0x100), + 43: -int32(0xcd00), + 44: -int32(0xda00), + 45: -int32(0x81ff), + 46: int32(0x2a2b01), + 47: -int32(0xa2ff), + 48: int32(0x2a2801), + 49: int32(0x2a3f00), + 50: -int32(0xc2ff), + 51: int32(0x4501), + 52: int32(0x4701), + 53: int32(0x2a1f00), + 54: int32(0x2a1c00), + 55: int32(0x2a1e00), + 56: -int32(0xd200), + 57: -int32(0xce00), + 58: -int32(0xca00), + 59: -int32(0xcb00), + 60: int32(0xa54f00), + 61: int32(0xa54b00), + 62: -int32(0xcf00), + 63: int32(0xa52800), + 64: int32(0xa54400), + 65: -int32(0xd100), + 66: -int32(0xd300), + 67: int32(0x29f700), + 68: int32(0xa54100), + 69: int32(0x29fd00), + 70: -int32(0xd500), + 71: -int32(0xd600), + 72: int32(0x29e700), + 73: int32(0xa54300), + 74: int32(0xa52a00), + 75: -int32(0x4500), + 76: -int32(0xd900), + 77: -int32(0x4700), + 78: -int32(0xdb00), + 79: int32(0xa51500), + 80: int32(0xa51200), + 81: int32(0x4c2402), + 83: int32(0x2001), + 84: -int32(0x2000), + 85: int32(0x101), + 86: -int32(0x100), + 87: int32(0x5400), + 88: int32(0x7401), + 89: int32(0x2601), + 90: int32(0x2501), + 91: int32(0x4001), + 92: int32(0x3f01), + 93: -int32(0x2600), + 94: -int32(0x2500), + 95: -int32(0x1f00), + 96: -int32(0x4000), + 97: -int32(0x3f00), + 98: int32(0x801), + 99: -int32(0x3e00), + 100: -int32(0x3900), + 101: -int32(0x2f00), + 102: -int32(0x3600), + 103: -int32(0x800), + 104: -int32(0x5600), + 105: -int32(0x5000), + 106: int32(0x700), + 107: -int32(0x7400), + 108: -int32(0x3bff), + 109: -int32(0x6000), + 110: -int32(0x6ff), + 111: int32(0x701a02), + 112: int32(0x101), + 113: -int32(0x100), + 114: int32(0x2001), + 115: -int32(0x2000), + 116: int32(0x5001), + 117: int32(0xf01), + 118: -int32(0xf00), + 120: int32(0x3001), + 121: -int32(0x3000), + 122: int32(0x101), + 123: -int32(0x100), + 125: int32(0xbc000), + 126: int32(0x1c6001), + 128: int32(0x97d001), + 129: int32(0x801), + 130: -int32(0x800), + 131: int32(0x8a0502), + 133: -int32(0xbbfff), + 134: -int32(0x186200), + 135: int32(0x89c200), + 136: -int32(0x182500), + 137: -int32(0x186e00), + 138: -int32(0x186d00), + 139: -int32(0x186400), + 140: -int32(0x186300), + 141: -int32(0x185c00), + 143: int32(0x8a3800), + 144: int32(0x8a0400), + 145: int32(0xee600), + 146: int32(0x101), + 147: -int32(0x100), + 149: -int32(0x3b00), + 150: -int32(0x1dbeff), + 151: int32(0x8f1d02), + 152: int32(0x800), + 153: -int32(0x7ff), + 155: int32(0x5600), + 156: -int32(0x55ff), + 157: int32(0x4a00), + 158: int32(0x6400), + 159: int32(0x8000), + 160: int32(0x7000), + 161: int32(0x7e00), + 162: int32(0x900), + 163: -int32(0x49ff), + 164: -int32(0x8ff), + 165: -int32(0x1c2500), + 166: -int32(0x63ff), + 167: -int32(0x6fff), + 168: -int32(0x7fff), + 169: -int32(0x7dff), + 170: int32(0xac0502), + 172: int32(0x1001), + 173: -int32(0x1000), + 174: int32(0x1c01), + 175: int32(0x101), + 176: -int32(0x1d5cff), + 177: -int32(0x20beff), + 178: -int32(0x2045ff), + 179: -int32(0x1c00), + 180: int32(0xb10b02), + 181: int32(0x101), + 182: -int32(0x100), + 183: int32(0x3001), + 184: -int32(0x3000), + 186: -int32(0x29f6ff), + 187: -int32(0xee5ff), + 188: -int32(0x29e6ff), + 189: -int32(0x2a2b00), + 190: -int32(0x2a2800), + 191: -int32(0x2a1bff), + 192: -int32(0x29fcff), + 193: -int32(0x2a1eff), + 194: -int32(0x2a1dff), + 195: -int32(0x2a3eff), + 197: -int32(0x1c6000), + 199: int32(0x101), + 200: -int32(0x100), + 201: int32(0xbc0c02), + 203: int32(0x101), + 204: -int32(0x100), + 205: -int32(0xa543ff), + 206: int32(0x3a001), + 207: -int32(0x8a03ff), + 208: -int32(0xa527ff), + 209: int32(0x3000), + 210: -int32(0xa54eff), + 211: -int32(0xa54aff), + 212: -int32(0xa540ff), + 213: -int32(0xa511ff), + 214: -int32(0xa529ff), + 215: -int32(0xa514ff), + 216: -int32(0x2fff), + 217: -int32(0xa542ff), + 218: -int32(0x8a37ff), + 220: -int32(0x97d000), + 221: -int32(0x3a000), + 223: int32(0x2001), + 224: -int32(0x2000), + 226: int32(0x2801), + 227: -int32(0x2800), + 229: int32(0x4001), + 230: -int32(0x4000), + 232: int32(0x2001), + 233: -int32(0x2000), + 235: int32(0x2001), + 236: -int32(0x2000), + 238: int32(0x2201), + 239: -int32(0x2200), +} +var _rulebases = [512]uint8{ + 1: uint8(6), + 2: uint8(39), + 3: uint8(81), + 4: uint8(111), + 5: uint8(119), + 16: uint8(124), + 19: uint8(127), + 28: uint8(131), + 29: uint8(142), + 30: uint8(146), + 31: uint8(151), + 33: uint8(170), + 44: uint8(180), + 45: uint8(196), + 166: uint8(198), + 167: uint8(201), + 171: uint8(219), + 255: uint8(222), + 260: uint8(225), + 268: uint8(228), + 280: uint8(231), + 366: uint8(234), + 489: uint8(237), +} +var _exceptions = [200][2]uint8{ + 0: { + 0: uint8(48), + 1: uint8(12), + }, + 1: { + 0: uint8(49), + 1: uint8(13), + }, + 2: { + 0: uint8(120), + 1: uint8(14), + }, + 3: { + 0: uint8(127), + 1: uint8(15), + }, + 4: { + 0: uint8(128), + 1: uint8(16), + }, + 5: { + 0: uint8(129), + 1: uint8(17), + }, + 6: { + 0: uint8(134), + 1: uint8(18), + }, + 7: { + 0: uint8(137), + 1: uint8(19), + }, + 8: { + 0: uint8(138), + 1: uint8(19), + }, + 9: { + 0: uint8(142), + 1: uint8(20), + }, + 10: { + 0: uint8(143), + 1: uint8(21), + }, + 11: { + 0: uint8(144), + 1: uint8(22), + }, + 12: { + 0: uint8(147), + 1: uint8(19), + }, + 13: { + 0: uint8(148), + 1: uint8(23), + }, + 14: { + 0: uint8(149), + 1: uint8(24), + }, + 15: { + 0: uint8(150), + 1: uint8(25), + }, + 16: { + 0: uint8(151), + 1: uint8(26), + }, + 17: { + 0: uint8(154), + 1: uint8(27), + }, + 18: { + 0: uint8(156), + 1: uint8(25), + }, + 19: { + 0: uint8(157), + 1: uint8(28), + }, + 20: { + 0: uint8(158), + 1: uint8(29), + }, + 21: { + 0: uint8(159), + 1: uint8(30), + }, + 22: { + 0: uint8(166), + 1: uint8(31), + }, + 23: { + 0: uint8(169), + 1: uint8(31), + }, + 24: { + 0: uint8(174), + 1: uint8(31), + }, + 25: { + 0: uint8(177), + 1: uint8(32), + }, + 26: { + 0: uint8(178), + 1: uint8(32), + }, + 27: { + 0: uint8(183), + 1: uint8(33), + }, + 28: { + 0: uint8(191), + 1: uint8(34), + }, + 29: { + 0: uint8(197), + 1: uint8(35), + }, + 30: { + 0: uint8(200), + 1: uint8(35), + }, + 31: { + 0: uint8(203), + 1: uint8(35), + }, + 32: { + 0: uint8(221), + 1: uint8(36), + }, + 33: { + 0: uint8(242), + 1: uint8(35), + }, + 34: { + 0: uint8(246), + 1: uint8(37), + }, + 35: { + 0: uint8(247), + 1: uint8(38), + }, + 36: { + 0: uint8(32), + 1: uint8(45), + }, + 37: { + 0: uint8(58), + 1: uint8(46), + }, + 38: { + 0: uint8(61), + 1: uint8(47), + }, + 39: { + 0: uint8(62), + 1: uint8(48), + }, + 40: { + 0: uint8(63), + 1: uint8(49), + }, + 41: { + 0: uint8(64), + 1: uint8(49), + }, + 42: { + 0: uint8(67), + 1: uint8(50), + }, + 43: { + 0: uint8(68), + 1: uint8(51), + }, + 44: { + 0: uint8(69), + 1: uint8(52), + }, + 45: { + 0: uint8(80), + 1: uint8(53), + }, + 46: { + 0: uint8(81), + 1: uint8(54), + }, + 47: { + 0: uint8(82), + 1: uint8(55), + }, + 48: { + 0: uint8(83), + 1: uint8(56), + }, + 49: { + 0: uint8(84), + 1: uint8(57), + }, + 50: { + 0: uint8(89), + 1: uint8(58), + }, + 51: { + 0: uint8(91), + 1: uint8(59), + }, + 52: { + 0: uint8(92), + 1: uint8(60), + }, + 53: { + 0: uint8(97), + 1: uint8(61), + }, + 54: { + 0: uint8(99), + 1: uint8(62), + }, + 55: { + 0: uint8(101), + 1: uint8(63), + }, + 56: { + 0: uint8(102), + 1: uint8(64), + }, + 57: { + 0: uint8(104), + 1: uint8(65), + }, + 58: { + 0: uint8(105), + 1: uint8(66), + }, + 59: { + 0: uint8(106), + 1: uint8(64), + }, + 60: { + 0: uint8(107), + 1: uint8(67), + }, + 61: { + 0: uint8(108), + 1: uint8(68), + }, + 62: { + 0: uint8(111), + 1: uint8(66), + }, + 63: { + 0: uint8(113), + 1: uint8(69), + }, + 64: { + 0: uint8(114), + 1: uint8(70), + }, + 65: { + 0: uint8(117), + 1: uint8(71), + }, + 66: { + 0: uint8(125), + 1: uint8(72), + }, + 67: { + 0: uint8(130), + 1: uint8(73), + }, + 68: { + 0: uint8(135), + 1: uint8(74), + }, + 69: { + 0: uint8(137), + 1: uint8(75), + }, + 70: { + 0: uint8(138), + 1: uint8(76), + }, + 71: { + 0: uint8(139), + 1: uint8(76), + }, + 72: { + 0: uint8(140), + 1: uint8(77), + }, + 73: { + 0: uint8(146), + 1: uint8(78), + }, + 74: { + 0: uint8(157), + 1: uint8(79), + }, + 75: { + 0: uint8(158), + 1: uint8(80), + }, + 76: { + 0: uint8(69), + 1: uint8(87), + }, + 77: { + 0: uint8(123), + 1: uint8(29), + }, + 78: { + 0: uint8(124), + 1: uint8(29), + }, + 79: { + 0: uint8(125), + 1: uint8(29), + }, + 80: { + 0: uint8(127), + 1: uint8(88), + }, + 81: { + 0: uint8(134), + 1: uint8(89), + }, + 82: { + 0: uint8(136), + 1: uint8(90), + }, + 83: { + 0: uint8(137), + 1: uint8(90), + }, + 84: { + 0: uint8(138), + 1: uint8(90), + }, + 85: { + 0: uint8(140), + 1: uint8(91), + }, + 86: { + 0: uint8(142), + 1: uint8(92), + }, + 87: { + 0: uint8(143), + 1: uint8(92), + }, + 88: { + 0: uint8(172), + 1: uint8(93), + }, + 89: { + 0: uint8(173), + 1: uint8(94), + }, + 90: { + 0: uint8(174), + 1: uint8(94), + }, + 91: { + 0: uint8(175), + 1: uint8(94), + }, + 92: { + 0: uint8(194), + 1: uint8(95), + }, + 93: { + 0: uint8(204), + 1: uint8(96), + }, + 94: { + 0: uint8(205), + 1: uint8(97), + }, + 95: { + 0: uint8(206), + 1: uint8(97), + }, + 96: { + 0: uint8(207), + 1: uint8(98), + }, + 97: { + 0: uint8(208), + 1: uint8(99), + }, + 98: { + 0: uint8(209), + 1: uint8(100), + }, + 99: { + 0: uint8(213), + 1: uint8(101), + }, + 100: { + 0: uint8(214), + 1: uint8(102), + }, + 101: { + 0: uint8(215), + 1: uint8(103), + }, + 102: { + 0: uint8(240), + 1: uint8(104), + }, + 103: { + 0: uint8(241), + 1: uint8(105), + }, + 104: { + 0: uint8(242), + 1: uint8(106), + }, + 105: { + 0: uint8(243), + 1: uint8(107), + }, + 106: { + 0: uint8(244), + 1: uint8(108), + }, + 107: { + 0: uint8(245), + 1: uint8(109), + }, + 108: { + 0: uint8(249), + 1: uint8(110), + }, + 109: { + 0: uint8(253), + 1: uint8(45), + }, + 110: { + 0: uint8(254), + 1: uint8(45), + }, + 111: { + 0: uint8(255), + 1: uint8(45), + }, + 112: { + 0: uint8(80), + 1: uint8(105), + }, + 113: { + 0: uint8(81), + 1: uint8(105), + }, + 114: { + 0: uint8(82), + 1: uint8(105), + }, + 115: { + 0: uint8(83), + 1: uint8(105), + }, + 116: { + 0: uint8(84), + 1: uint8(105), + }, + 117: { + 0: uint8(85), + 1: uint8(105), + }, + 118: { + 0: uint8(86), + 1: uint8(105), + }, + 119: { + 0: uint8(87), + 1: uint8(105), + }, + 120: { + 0: uint8(88), + 1: uint8(105), + }, + 121: { + 0: uint8(89), + 1: uint8(105), + }, + 122: { + 0: uint8(90), + 1: uint8(105), + }, + 123: { + 0: uint8(91), + 1: uint8(105), + }, + 124: { + 0: uint8(92), + 1: uint8(105), + }, + 125: { + 0: uint8(93), + 1: uint8(105), + }, + 126: { + 0: uint8(94), + 1: uint8(105), + }, + 127: { + 0: uint8(95), + 1: uint8(105), + }, + 128: { + 0: uint8(130), + }, + 129: { + 0: uint8(131), + }, + 130: { + 0: uint8(132), + }, + 131: { + 0: uint8(133), + }, + 132: { + 0: uint8(134), + }, + 133: { + 0: uint8(135), + }, + 134: { + 0: uint8(136), + }, + 135: { + 0: uint8(137), + }, + 136: { + 0: uint8(192), + 1: uint8(117), + }, + 137: { + 0: uint8(207), + 1: uint8(118), + }, + 138: { + 0: uint8(128), + 1: uint8(137), + }, + 139: { + 0: uint8(129), + 1: uint8(138), + }, + 140: { + 0: uint8(130), + 1: uint8(139), + }, + 141: { + 0: uint8(133), + 1: uint8(140), + }, + 142: { + 0: uint8(134), + 1: uint8(141), + }, + 143: { + 0: uint8(112), + 1: uint8(157), + }, + 144: { + 0: uint8(113), + 1: uint8(157), + }, + 145: { + 0: uint8(118), + 1: uint8(158), + }, + 146: { + 0: uint8(119), + 1: uint8(158), + }, + 147: { + 0: uint8(120), + 1: uint8(159), + }, + 148: { + 0: uint8(121), + 1: uint8(159), + }, + 149: { + 0: uint8(122), + 1: uint8(160), + }, + 150: { + 0: uint8(123), + 1: uint8(160), + }, + 151: { + 0: uint8(124), + 1: uint8(161), + }, + 152: { + 0: uint8(125), + 1: uint8(161), + }, + 153: { + 0: uint8(179), + 1: uint8(162), + }, + 154: { + 0: uint8(186), + 1: uint8(163), + }, + 155: { + 0: uint8(187), + 1: uint8(163), + }, + 156: { + 0: uint8(188), + 1: uint8(164), + }, + 157: { + 0: uint8(190), + 1: uint8(165), + }, + 158: { + 0: uint8(195), + 1: uint8(162), + }, + 159: { + 0: uint8(204), + 1: uint8(164), + }, + 160: { + 0: uint8(218), + 1: uint8(166), + }, + 161: { + 0: uint8(219), + 1: uint8(166), + }, + 162: { + 0: uint8(229), + 1: uint8(106), + }, + 163: { + 0: uint8(234), + 1: uint8(167), + }, + 164: { + 0: uint8(235), + 1: uint8(167), + }, + 165: { + 0: uint8(236), + 1: uint8(110), + }, + 166: { + 0: uint8(243), + 1: uint8(162), + }, + 167: { + 0: uint8(248), + 1: uint8(168), + }, + 168: { + 0: uint8(249), + 1: uint8(168), + }, + 169: { + 0: uint8(250), + 1: uint8(169), + }, + 170: { + 0: uint8(251), + 1: uint8(169), + }, + 171: { + 0: uint8(252), + 1: uint8(164), + }, + 172: { + 0: uint8(38), + 1: uint8(176), + }, + 173: { + 0: uint8(42), + 1: uint8(177), + }, + 174: { + 0: uint8(43), + 1: uint8(178), + }, + 175: { + 0: uint8(78), + 1: uint8(179), + }, + 176: { + 0: uint8(132), + 1: uint8(8), + }, + 177: { + 0: uint8(98), + 1: uint8(186), + }, + 178: { + 0: uint8(99), + 1: uint8(187), + }, + 179: { + 0: uint8(100), + 1: uint8(188), + }, + 180: { + 0: uint8(101), + 1: uint8(189), + }, + 181: { + 0: uint8(102), + 1: uint8(190), + }, + 182: { + 0: uint8(109), + 1: uint8(191), + }, + 183: { + 0: uint8(110), + 1: uint8(192), + }, + 184: { + 0: uint8(111), + 1: uint8(193), + }, + 185: { + 0: uint8(112), + 1: uint8(194), + }, + 186: { + 0: uint8(126), + 1: uint8(195), + }, + 187: { + 0: uint8(127), + 1: uint8(195), + }, + 188: { + 0: uint8(125), + 1: uint8(207), + }, + 189: { + 0: uint8(141), + 1: uint8(208), + }, + 190: { + 0: uint8(148), + 1: uint8(209), + }, + 191: { + 0: uint8(171), + 1: uint8(210), + }, + 192: { + 0: uint8(172), + 1: uint8(211), + }, + 193: { + 0: uint8(173), + 1: uint8(212), + }, + 194: { + 0: uint8(176), + 1: uint8(213), + }, + 195: { + 0: uint8(177), + 1: uint8(214), + }, + 196: { + 0: uint8(178), + 1: uint8(215), + }, + 197: { + 0: uint8(196), + 1: uint8(216), + }, + 198: { + 0: uint8(197), + 1: uint8(217), + }, + 199: { + 0: uint8(198), + 1: uint8(218), + }, +} + +func _casemap(tls *TLS, c uint32, dir int32) (r1 int32) { + var b, rt, try, v, x, xb, xn, y uint32 + var c0, r, rd, v1 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = b, c0, r, rd, rt, try, v, x, xb, xn, y, v1 + c0 = Int32FromUint32(c) + if c >= uint32(0x20000) { + return Int32FromUint32(c) + } + b = c >> int32(8) + c = c & uint32(255) + x = c / uint32(3) + y = c % uint32(3) + /* lookup entry in two-level base-6 table */ + v = uint32(_tab1[Uint32FromInt32(Int32FromUint8(_tab1[b])*int32(86))+x]) + v = v * Uint32FromInt32(_mt[y]) >> int32(11) % uint32(6) + /* use the bit vector out of the tables as an index into + * a block-specific set of rules and decode the rule into + * a type and a case-mapping delta. */ + r = _rules[uint32(_rulebases[b])+v] + rt = Uint32FromInt32(r & int32(255)) + rd = r >> int32(8) + /* rules 0/1 are simple lower/upper case with a delta. + * apply according to desired mapping direction. */ + if rt < uint32(2) { + return Int32FromUint32(Uint32FromInt32(c0) + Uint32FromInt32(rd)&-(rt^Uint32FromInt32(dir))) + } + /* binary search. endpoints of the binary search for + * this block are stored in the rule delta field. */ + xn = Uint32FromInt32(rd & int32(0xff)) + xb = Uint32FromInt32(rd) >> int32(8) + for xn != 0 { + try = uint32(**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_exceptions)) + uintptr(xb+xn/uint32(2))*2))) + if try == c { + r = _rules[**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_exceptions)) + uintptr(xb+xn/uint32(2))*2 + 1))] + rt = Uint32FromInt32(r & int32(255)) + rd = r >> int32(8) + if rt < uint32(2) { + return Int32FromUint32(Uint32FromInt32(c0) + Uint32FromInt32(rd)&-(rt^Uint32FromInt32(dir))) + } + /* Hard-coded for the four exceptional titlecase */ + if dir != 0 { + v1 = -int32(1) + } else { + v1 = int32(1) + } + return c0 + v1 + } else { + if try > c { + xn = xn / uint32(2) + } else { + xb = xb + xn/uint32(2) + xn = xn - xn/uint32(2) + } + } + } + return c0 +} + +var _mt = [3]int32{ + 0: int32(2048), + 1: int32(342), + 2: int32(57), +} + +func Xtowlower(tls *TLS, wc Twint_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt32(_casemap(tls, wc, 0)) +} + +func Xtowupper(tls *TLS, wc Twint_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt32(_casemap(tls, wc, int32(1))) +} + +func X__towupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtowupper(tls, c) +} + +func X__towlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtowlower(tls, c) +} + +func Xtowlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__towlower_l(tls, c, l) +} + +func Xtowupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__towupper_l(tls, c, l) +} + +func Xwcswidth(tls *TLS, wcs uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wcs=%v n=%v, (%v:)", tls, wcs, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k, l, v3 int32 + var v2 Tsize_t + var v4 bool + _, _, _, _, _ = k, l, v2, v3, v4 + l = 0 + k = 0 + for { + v2 = n + n = n - 1 + if v4 = v2 != 0 && **(**Twchar_t)(__ccgo_up(wcs)) != 0; v4 { + v3 = Xwcwidth(tls, **(**Twchar_t)(__ccgo_up(wcs))) + k = v3 + } + if !(v4 && v3 >= 0) { + break + } + goto _1 + _1: + ; + l = l + k + wcs += 4 + } + if k < 0 { + v3 = k + } else { + v3 = l + } + return v3 +} + +func Xwctrans(tls *TLS, class uintptr) (r Twctrans_t) { + if __ccgo_strace { + trc("tls=%v class=%v, (%v:)", tls, class, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(Xstrcmp(tls, class, __ccgo_ts+196) != 0) { + return UintptrFromInt32(1) + } + if !(Xstrcmp(tls, class, __ccgo_ts+204) != 0) { + return UintptrFromInt32(2) + } + return uintptr(0) +} + +func Xtowctrans(tls *TLS, wc Twint_t, trans Twctrans_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v wc=%v trans=%v, (%v:)", tls, wc, trans, origin(2)) + defer func() { trc("-> %v", r) }() + } + if trans == UintptrFromInt32(1) { + return Xtowupper(tls, wc) + } + if trans == UintptrFromInt32(2) { + return Xtowlower(tls, wc) + } + return wc +} + +func X__wctrans_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctrans_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v, (%v:)", tls, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwctrans(tls, s) +} + +func X__towctrans_l(tls *TLS, c Twint_t, t Twctrans_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v t=%v l=%v, (%v:)", tls, c, t, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtowctrans(tls, c, t) +} + +func Xtowctrans_l(tls *TLS, c Twint_t, t Twctrans_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v t=%v l=%v, (%v:)", tls, c, t, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__towctrans_l(tls, c, t, l) +} + +func Xwctrans_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctrans_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v, (%v:)", tls, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wctrans_l(tls, s, l) +} + +var _table5 = [2784]uint8{ + 0: uint8(16), + 1: uint8(16), + 2: uint8(16), + 3: uint8(18), + 4: uint8(19), + 5: uint8(20), + 6: uint8(21), + 7: uint8(22), + 8: uint8(23), + 9: uint8(24), + 10: uint8(25), + 11: uint8(26), + 12: uint8(27), + 13: uint8(28), + 14: uint8(29), + 15: uint8(30), + 16: uint8(31), + 17: uint8(32), + 18: uint8(16), + 19: uint8(33), + 20: uint8(16), + 21: uint8(16), + 22: uint8(16), + 23: uint8(34), + 24: uint8(35), + 25: uint8(36), + 26: uint8(37), + 27: uint8(38), + 28: uint8(39), + 29: uint8(40), + 30: uint8(16), + 31: uint8(16), + 32: uint8(41), + 33: uint8(16), + 34: uint8(16), + 35: uint8(16), + 36: uint8(16), + 37: uint8(16), + 38: uint8(16), + 39: uint8(16), + 40: uint8(16), + 41: uint8(16), + 42: uint8(16), + 43: uint8(16), + 44: uint8(42), + 45: uint8(43), + 46: uint8(16), + 47: uint8(16), + 48: uint8(44), + 49: uint8(16), + 50: uint8(16), + 51: uint8(16), + 52: uint8(16), + 53: uint8(16), + 54: uint8(16), + 55: uint8(16), + 56: uint8(16), + 57: uint8(16), + 58: uint8(16), + 59: uint8(16), + 60: uint8(16), + 61: uint8(16), + 62: uint8(16), + 63: uint8(16), + 64: uint8(16), + 65: uint8(16), + 66: uint8(16), + 67: uint8(16), + 68: uint8(16), + 69: uint8(16), + 70: uint8(16), + 71: uint8(16), + 72: uint8(16), + 73: uint8(16), + 74: uint8(16), + 75: uint8(16), + 76: uint8(16), + 77: uint8(16), + 78: uint8(16), + 79: uint8(16), + 80: uint8(16), + 81: uint8(16), + 82: uint8(16), + 83: uint8(16), + 84: uint8(16), + 85: uint8(16), + 86: uint8(16), + 87: uint8(16), + 88: uint8(16), + 89: uint8(16), + 90: uint8(16), + 91: uint8(16), + 92: uint8(16), + 93: uint8(16), + 94: uint8(16), + 95: uint8(16), + 96: uint8(16), + 97: uint8(16), + 98: uint8(16), + 99: uint8(16), + 100: uint8(16), + 101: uint8(16), + 102: uint8(16), + 103: uint8(16), + 104: uint8(16), + 105: uint8(16), + 106: uint8(16), + 107: uint8(16), + 108: uint8(16), + 109: uint8(16), + 110: uint8(16), + 111: uint8(16), + 112: uint8(16), + 113: uint8(16), + 114: uint8(16), + 115: uint8(16), + 116: uint8(16), + 117: uint8(16), + 118: uint8(16), + 119: uint8(16), + 120: uint8(16), + 121: uint8(16), + 122: uint8(16), + 123: uint8(16), + 124: uint8(16), + 125: uint8(16), + 126: uint8(16), + 127: uint8(16), + 128: uint8(16), + 129: uint8(16), + 130: uint8(16), + 131: uint8(16), + 132: uint8(16), + 133: uint8(16), + 134: uint8(16), + 135: uint8(16), + 136: uint8(16), + 137: uint8(16), + 138: uint8(16), + 139: uint8(16), + 140: uint8(16), + 141: uint8(16), + 142: uint8(16), + 143: uint8(16), + 144: uint8(16), + 145: uint8(16), + 146: uint8(16), + 147: uint8(16), + 148: uint8(16), + 149: uint8(16), + 150: uint8(16), + 151: uint8(16), + 152: uint8(16), + 153: uint8(16), + 154: uint8(16), + 155: uint8(16), + 156: uint8(16), + 157: uint8(16), + 158: uint8(16), + 159: uint8(16), + 160: uint8(16), + 161: uint8(16), + 162: uint8(16), + 163: uint8(16), + 164: uint8(16), + 165: uint8(16), + 166: uint8(45), + 167: uint8(16), + 168: uint8(46), + 169: uint8(47), + 170: uint8(48), + 171: uint8(49), + 172: uint8(16), + 173: uint8(16), + 174: uint8(16), + 175: uint8(16), + 176: uint8(16), + 177: uint8(16), + 178: uint8(16), + 179: uint8(16), + 180: uint8(16), + 181: uint8(16), + 182: uint8(16), + 183: uint8(16), + 184: uint8(16), + 185: uint8(16), + 186: uint8(16), + 187: uint8(16), + 188: uint8(16), + 189: uint8(16), + 190: uint8(16), + 191: uint8(16), + 192: uint8(16), + 193: uint8(16), + 194: uint8(16), + 195: uint8(16), + 196: uint8(16), + 197: uint8(16), + 198: uint8(16), + 199: uint8(16), + 200: uint8(16), + 201: uint8(16), + 202: uint8(16), + 203: uint8(16), + 204: uint8(16), + 205: uint8(16), + 206: uint8(16), + 207: uint8(16), + 208: uint8(16), + 209: uint8(16), + 210: uint8(16), + 211: uint8(16), + 212: uint8(16), + 213: uint8(16), + 214: uint8(16), + 215: uint8(50), + 216: uint8(16), + 217: uint8(16), + 218: uint8(16), + 219: uint8(16), + 220: uint8(16), + 221: uint8(16), + 222: uint8(16), + 223: uint8(16), + 224: uint8(16), + 225: uint8(16), + 226: uint8(16), + 227: uint8(16), + 228: uint8(16), + 229: uint8(16), + 230: uint8(16), + 231: uint8(16), + 232: uint8(16), + 233: uint8(16), + 234: uint8(16), + 235: uint8(16), + 236: uint8(16), + 237: uint8(16), + 238: uint8(16), + 239: uint8(16), + 240: uint8(16), + 241: uint8(16), + 242: uint8(16), + 243: uint8(16), + 244: uint8(16), + 245: uint8(16), + 246: uint8(16), + 247: uint8(16), + 248: uint8(16), + 249: uint8(16), + 250: uint8(16), + 251: uint8(51), + 252: uint8(16), + 253: uint8(16), + 254: uint8(52), + 255: uint8(53), + 256: uint8(16), + 257: uint8(54), + 258: uint8(55), + 259: uint8(56), + 260: uint8(16), + 261: uint8(16), + 262: uint8(16), + 263: uint8(16), + 264: uint8(16), + 265: uint8(16), + 266: uint8(57), + 267: uint8(16), + 268: uint8(16), + 269: uint8(58), + 270: uint8(16), + 271: uint8(59), + 272: uint8(60), + 273: uint8(61), + 274: uint8(62), + 275: uint8(63), + 276: uint8(64), + 277: uint8(65), + 278: uint8(66), + 279: uint8(67), + 280: uint8(68), + 281: uint8(69), + 282: uint8(70), + 283: uint8(16), + 284: uint8(71), + 285: uint8(72), + 286: uint8(73), + 287: uint8(16), + 288: uint8(16), + 289: uint8(16), + 290: uint8(16), + 291: uint8(16), + 292: uint8(16), + 293: uint8(16), + 294: uint8(16), + 295: uint8(16), + 296: uint8(16), + 297: uint8(16), + 298: uint8(16), + 299: uint8(16), + 300: uint8(16), + 301: uint8(16), + 302: uint8(16), + 303: uint8(16), + 304: uint8(16), + 305: uint8(16), + 306: uint8(16), + 307: uint8(16), + 308: uint8(74), + 309: uint8(16), + 310: uint8(16), + 311: uint8(16), + 312: uint8(16), + 313: uint8(16), + 314: uint8(16), + 315: uint8(16), + 316: uint8(16), + 317: uint8(16), + 318: uint8(16), + 319: uint8(16), + 320: uint8(16), + 321: uint8(16), + 322: uint8(16), + 323: uint8(16), + 324: uint8(16), + 325: uint8(16), + 326: uint8(16), + 327: uint8(16), + 328: uint8(16), + 329: uint8(16), + 330: uint8(16), + 331: uint8(16), + 332: uint8(16), + 333: uint8(16), + 334: uint8(16), + 335: uint8(16), + 336: uint8(16), + 337: uint8(16), + 338: uint8(16), + 339: uint8(16), + 340: uint8(16), + 341: uint8(16), + 342: uint8(16), + 343: uint8(16), + 344: uint8(16), + 345: uint8(16), + 346: uint8(16), + 347: uint8(16), + 348: uint8(16), + 349: uint8(16), + 350: uint8(16), + 351: uint8(16), + 352: uint8(16), + 353: uint8(16), + 354: uint8(16), + 355: uint8(16), + 356: uint8(16), + 357: uint8(16), + 358: uint8(16), + 359: uint8(16), + 360: uint8(16), + 361: uint8(16), + 362: uint8(75), + 363: uint8(76), + 364: uint8(16), + 365: uint8(16), + 366: uint8(16), + 367: uint8(77), + 368: uint8(16), + 369: uint8(16), + 370: uint8(16), + 371: uint8(16), + 372: uint8(16), + 373: uint8(16), + 374: uint8(16), + 375: uint8(16), + 376: uint8(16), + 377: uint8(16), + 378: uint8(16), + 379: uint8(16), + 380: uint8(16), + 381: uint8(16), + 382: uint8(16), + 383: uint8(16), + 384: uint8(16), + 385: uint8(16), + 386: uint8(16), + 387: uint8(16), + 388: uint8(16), + 389: uint8(16), + 390: uint8(16), + 391: uint8(16), + 392: uint8(16), + 393: uint8(16), + 394: uint8(16), + 395: uint8(16), + 396: uint8(16), + 397: uint8(16), + 398: uint8(16), + 399: uint8(16), + 400: uint8(16), + 401: uint8(16), + 402: uint8(16), + 403: uint8(16), + 404: uint8(16), + 405: uint8(16), + 406: uint8(16), + 407: uint8(16), + 408: uint8(16), + 409: uint8(16), + 410: uint8(16), + 411: uint8(16), + 412: uint8(16), + 413: uint8(16), + 414: uint8(16), + 415: uint8(16), + 416: uint8(16), + 417: uint8(16), + 418: uint8(16), + 419: uint8(16), + 420: uint8(16), + 421: uint8(16), + 422: uint8(16), + 423: uint8(16), + 424: uint8(16), + 425: uint8(16), + 426: uint8(16), + 427: uint8(16), + 428: uint8(16), + 429: uint8(16), + 430: uint8(16), + 431: uint8(16), + 432: uint8(16), + 433: uint8(16), + 434: uint8(16), + 435: uint8(16), + 436: uint8(16), + 437: uint8(16), + 438: uint8(16), + 439: uint8(16), + 440: uint8(16), + 441: uint8(16), + 442: uint8(16), + 443: uint8(16), + 444: uint8(78), + 445: uint8(16), + 446: uint8(16), + 447: uint8(16), + 448: uint8(16), + 449: uint8(16), + 450: uint8(16), + 451: uint8(16), + 452: uint8(16), + 453: uint8(16), + 454: uint8(16), + 455: uint8(16), + 456: uint8(16), + 457: uint8(16), + 458: uint8(16), + 459: uint8(16), + 460: uint8(16), + 461: uint8(16), + 462: uint8(16), + 463: uint8(16), + 464: uint8(16), + 465: uint8(79), + 466: uint8(80), + 467: uint8(16), + 468: uint8(16), + 469: uint8(16), + 470: uint8(16), + 471: uint8(16), + 472: uint8(16), + 473: uint8(16), + 474: uint8(81), + 475: uint8(16), + 476: uint8(16), + 477: uint8(16), + 478: uint8(16), + 479: uint8(16), + 480: uint8(82), + 481: uint8(83), + 482: uint8(84), + 483: uint8(16), + 484: uint8(16), + 485: uint8(16), + 486: uint8(16), + 487: uint8(16), + 488: uint8(85), + 489: uint8(86), + 490: uint8(16), + 491: uint8(16), + 492: uint8(16), + 493: uint8(16), + 494: uint8(16), + 495: uint8(16), + 496: uint8(16), + 497: uint8(16), + 498: uint8(16), + 499: uint8(16), + 500: uint8(16), + 501: uint8(16), + 502: uint8(16), + 503: uint8(16), + 504: uint8(16), + 505: uint8(16), + 506: uint8(16), + 507: uint8(16), + 508: uint8(16), + 509: uint8(16), + 510: uint8(16), + 511: uint8(16), + 544: uint8(255), + 545: uint8(255), + 546: uint8(255), + 547: uint8(255), + 548: uint8(255), + 549: uint8(255), + 550: uint8(255), + 551: uint8(255), + 552: uint8(255), + 553: uint8(255), + 554: uint8(255), + 555: uint8(255), + 556: uint8(255), + 557: uint8(255), + 558: uint8(255), + 559: uint8(255), + 560: uint8(255), + 561: uint8(255), + 562: uint8(255), + 563: uint8(255), + 564: uint8(255), + 565: uint8(255), + 566: uint8(255), + 567: uint8(255), + 568: uint8(255), + 569: uint8(255), + 570: uint8(255), + 571: uint8(255), + 572: uint8(255), + 573: uint8(255), + 574: uint8(255), + 575: uint8(255), + 576: uint8(255), + 577: uint8(255), + 578: uint8(255), + 579: uint8(255), + 580: uint8(255), + 581: uint8(255), + 582: uint8(255), + 583: uint8(255), + 584: uint8(255), + 585: uint8(255), + 586: uint8(255), + 587: uint8(255), + 588: uint8(255), + 589: uint8(255), + 624: uint8(248), + 625: uint8(3), + 658: uint8(254), + 659: uint8(255), + 660: uint8(255), + 661: uint8(255), + 662: uint8(255), + 663: uint8(191), + 664: uint8(182), + 672: uint8(63), + 674: uint8(255), + 675: uint8(23), + 681: uint8(248), + 682: uint8(255), + 683: uint8(255), + 686: uint8(1), + 698: uint8(192), + 699: uint8(191), + 700: uint8(159), + 701: uint8(61), + 705: uint8(128), + 706: uint8(2), + 710: uint8(255), + 711: uint8(255), + 712: uint8(255), + 713: uint8(7), + 724: uint8(192), + 725: uint8(255), + 726: uint8(1), + 733: uint8(248), + 734: uint8(15), + 735: uint8(32), + 738: uint8(192), + 739: uint8(251), + 740: uint8(239), + 741: uint8(62), + 747: uint8(14), + 762: uint8(248), + 763: uint8(255), + 764: uint8(255), + 765: uint8(255), + 766: uint8(255), + 767: uint8(255), + 768: uint8(7), + 775: uint8(20), + 776: uint8(254), + 777: uint8(33), + 778: uint8(254), + 780: uint8(12), + 784: uint8(2), + 791: uint8(16), + 792: uint8(30), + 793: uint8(32), + 796: uint8(12), + 799: uint8(64), + 800: uint8(6), + 807: uint8(16), + 808: uint8(134), + 809: uint8(57), + 810: uint8(2), + 814: uint8(35), + 816: uint8(6), + 823: uint8(16), + 824: uint8(190), + 825: uint8(33), + 828: uint8(12), + 831: uint8(252), + 832: uint8(2), + 839: uint8(144), + 840: uint8(30), + 841: uint8(32), + 842: uint8(64), + 844: uint8(12), + 848: uint8(4), + 856: uint8(1), + 857: uint8(32), + 864: uint8(17), + 871: uint8(192), + 872: uint8(193), + 873: uint8(61), + 874: uint8(96), + 876: uint8(12), + 880: uint8(2), + 887: uint8(144), + 888: uint8(64), + 889: uint8(48), + 892: uint8(12), + 896: uint8(3), + 903: uint8(24), + 904: uint8(30), + 905: uint8(32), + 908: uint8(12), + 921: uint8(4), + 922: uint8(92), + 934: uint8(242), + 935: uint8(7), + 936: uint8(128), + 937: uint8(127), + 950: uint8(242), + 951: uint8(31), + 953: uint8(63), + 963: uint8(3), + 966: uint8(160), + 967: uint8(2), + 974: uint8(254), + 975: uint8(127), + 976: uint8(223), + 977: uint8(224), + 978: uint8(255), + 979: uint8(254), + 980: uint8(255), + 981: uint8(255), + 982: uint8(255), + 983: uint8(31), + 984: uint8(64), + 997: uint8(224), + 998: uint8(253), + 999: uint8(102), + 1003: uint8(195), + 1004: uint8(1), + 1006: uint8(30), + 1008: uint8(100), + 1009: uint8(32), + 1011: uint8(32), + 1036: uint8(255), + 1037: uint8(255), + 1038: uint8(255), + 1039: uint8(255), + 1040: uint8(255), + 1041: uint8(255), + 1042: uint8(255), + 1043: uint8(255), + 1044: uint8(255), + 1045: uint8(255), + 1046: uint8(255), + 1047: uint8(255), + 1048: uint8(255), + 1049: uint8(255), + 1050: uint8(255), + 1051: uint8(255), + 1052: uint8(255), + 1053: uint8(255), + 1054: uint8(255), + 1055: uint8(255), + 1067: uint8(224), + 1090: uint8(28), + 1094: uint8(28), + 1098: uint8(12), + 1102: uint8(12), + 1110: uint8(176), + 1111: uint8(63), + 1112: uint8(64), + 1113: uint8(254), + 1114: uint8(15), + 1115: uint8(32), + 1121: uint8(120), + 1136: uint8(96), + 1141: uint8(2), + 1156: uint8(135), + 1157: uint8(1), + 1158: uint8(4), + 1159: uint8(14), + 1186: uint8(128), + 1187: uint8(9), + 1194: uint8(64), + 1195: uint8(127), + 1196: uint8(229), + 1197: uint8(31), + 1198: uint8(248), + 1199: uint8(159), + 1206: uint8(255), + 1207: uint8(127), + 1216: uint8(15), + 1222: uint8(208), + 1223: uint8(23), + 1224: uint8(4), + 1229: uint8(248), + 1230: uint8(15), + 1232: uint8(3), + 1236: uint8(60), + 1237: uint8(59), + 1244: uint8(64), + 1245: uint8(163), + 1246: uint8(3), + 1253: uint8(240), + 1254: uint8(207), + 1274: uint8(247), + 1275: uint8(255), + 1276: uint8(253), + 1277: uint8(33), + 1278: uint8(16), + 1279: uint8(3), + 1304: uint8(255), + 1305: uint8(255), + 1306: uint8(255), + 1307: uint8(255), + 1308: uint8(255), + 1309: uint8(255), + 1310: uint8(255), + 1311: uint8(251), + 1313: uint8(248), + 1317: uint8(124), + 1324: uint8(223), + 1325: uint8(255), + 1338: uint8(255), + 1339: uint8(255), + 1340: uint8(255), + 1341: uint8(255), + 1342: uint8(1), + 1373: uint8(128), + 1374: uint8(3), + 1391: uint8(128), + 1404: uint8(255), + 1405: uint8(255), + 1406: uint8(255), + 1407: uint8(255), + 1413: uint8(60), + 1427: uint8(6), + 1453: uint8(128), + 1454: uint8(247), + 1455: uint8(63), + 1459: uint8(192), + 1470: uint8(3), + 1472: uint8(68), + 1473: uint8(8), + 1476: uint8(96), + 1496: uint8(48), + 1500: uint8(255), + 1501: uint8(255), + 1502: uint8(3), + 1503: uint8(128), + 1508: uint8(192), + 1509: uint8(63), + 1512: uint8(128), + 1513: uint8(255), + 1514: uint8(3), + 1520: uint8(7), + 1526: uint8(200), + 1527: uint8(51), + 1532: uint8(32), + 1541: uint8(126), + 1542: uint8(102), + 1544: uint8(8), + 1545: uint8(16), + 1551: uint8(16), + 1558: uint8(157), + 1559: uint8(193), + 1560: uint8(2), + 1565: uint8(48), + 1566: uint8(64), + 1596: uint8(32), + 1597: uint8(33), + 1622: uint8(255), + 1623: uint8(255), + 1624: uint8(255), + 1625: uint8(255), + 1626: uint8(255), + 1627: uint8(255), + 1628: uint8(255), + 1629: uint8(255), + 1630: uint8(255), + 1631: uint8(255), + 1635: uint8(64), + 1664: uint8(255), + 1665: uint8(255), + 1668: uint8(255), + 1669: uint8(255), + 1695: uint8(128), + 1727: uint8(14), + 1759: uint8(32), + 1788: uint8(1), + 1806: uint8(192), + 1807: uint8(7), + 1824: uint8(110), + 1825: uint8(240), + 1831: uint8(135), + 1852: uint8(96), + 1860: uint8(240), + 1896: uint8(192), + 1897: uint8(255), + 1898: uint8(1), + 1920: uint8(2), + 1927: uint8(255), + 1928: uint8(127), + 1935: uint8(128), + 1936: uint8(3), + 1942: uint8(120), + 1943: uint8(38), + 1945: uint8(32), + 1952: uint8(7), + 1956: uint8(128), + 1957: uint8(239), + 1958: uint8(31), + 1966: uint8(8), + 1968: uint8(3), + 1974: uint8(192), + 1975: uint8(127), + 1977: uint8(30), + 1989: uint8(128), + 1990: uint8(211), + 1991: uint8(64), + 2011: uint8(128), + 2012: uint8(248), + 2013: uint8(7), + 2016: uint8(3), + 2023: uint8(24), + 2024: uint8(1), + 2028: uint8(192), + 2029: uint8(31), + 2030: uint8(31), + 2055: uint8(255), + 2056: uint8(92), + 2059: uint8(64), + 2070: uint8(248), + 2071: uint8(133), + 2072: uint8(13), + 2102: uint8(60), + 2103: uint8(176), + 2104: uint8(1), + 2107: uint8(48), + 2118: uint8(248), + 2119: uint8(167), + 2120: uint8(1), + 2133: uint8(40), + 2134: uint8(191), + 2147: uint8(224), + 2148: uint8(188), + 2149: uint8(15), + 2181: uint8(128), + 2182: uint8(255), + 2183: uint8(6), + 2234: uint8(240), + 2235: uint8(12), + 2236: uint8(1), + 2240: uint8(254), + 2241: uint8(7), + 2246: uint8(248), + 2247: uint8(121), + 2248: uint8(128), + 2250: uint8(126), + 2251: uint8(14), + 2257: uint8(252), + 2258: uint8(127), + 2259: uint8(3), + 2278: uint8(127), + 2279: uint8(191), + 2290: uint8(252), + 2291: uint8(255), + 2292: uint8(255), + 2293: uint8(252), + 2294: uint8(109), + 2310: uint8(126), + 2311: uint8(180), + 2312: uint8(191), + 2322: uint8(163), + 2366: uint8(24), + 2374: uint8(255), + 2375: uint8(1), + 2430: uint8(31), + 2438: uint8(127), + 2473: uint8(128), + 2481: uint8(128), + 2482: uint8(7), + 2515: uint8(96), + 2516: uint8(15), + 2540: uint8(128), + 2541: uint8(3), + 2542: uint8(248), + 2543: uint8(255), + 2544: uint8(231), + 2545: uint8(15), + 2549: uint8(60), + 2568: uint8(28), + 2592: uint8(255), + 2593: uint8(255), + 2594: uint8(255), + 2595: uint8(255), + 2596: uint8(255), + 2597: uint8(255), + 2598: uint8(127), + 2599: uint8(248), + 2600: uint8(255), + 2601: uint8(255), + 2602: uint8(255), + 2603: uint8(255), + 2604: uint8(255), + 2605: uint8(31), + 2606: uint8(32), + 2608: uint8(16), + 2611: uint8(248), + 2612: uint8(254), + 2613: uint8(255), + 2624: uint8(127), + 2625: uint8(255), + 2626: uint8(255), + 2627: uint8(249), + 2628: uint8(219), + 2629: uint8(7), + 2662: uint8(127), + 2717: uint8(240), + 2746: uint8(127), + 2760: uint8(240), + 2761: uint8(7), +} + +var _wtable = [1600]uint8{ + 0: uint8(16), + 1: uint8(16), + 2: uint8(16), + 3: uint8(16), + 4: uint8(16), + 5: uint8(16), + 6: uint8(16), + 7: uint8(16), + 8: uint8(16), + 9: uint8(16), + 10: uint8(16), + 11: uint8(16), + 12: uint8(16), + 13: uint8(16), + 14: uint8(16), + 15: uint8(16), + 16: uint8(16), + 17: uint8(18), + 18: uint8(16), + 19: uint8(16), + 20: uint8(16), + 21: uint8(16), + 22: uint8(16), + 23: uint8(16), + 24: uint8(16), + 25: uint8(16), + 26: uint8(16), + 27: uint8(16), + 28: uint8(16), + 29: uint8(16), + 30: uint8(16), + 31: uint8(16), + 32: uint8(16), + 33: uint8(16), + 34: uint8(16), + 35: uint8(19), + 36: uint8(16), + 37: uint8(20), + 38: uint8(21), + 39: uint8(22), + 40: uint8(16), + 41: uint8(16), + 42: uint8(16), + 43: uint8(23), + 44: uint8(16), + 45: uint8(16), + 46: uint8(24), + 47: uint8(25), + 48: uint8(26), + 49: uint8(27), + 50: uint8(28), + 51: uint8(17), + 52: uint8(17), + 53: uint8(17), + 54: uint8(17), + 55: uint8(17), + 56: uint8(17), + 57: uint8(17), + 58: uint8(17), + 59: uint8(17), + 60: uint8(17), + 61: uint8(17), + 62: uint8(17), + 63: uint8(17), + 64: uint8(17), + 65: uint8(17), + 66: uint8(17), + 67: uint8(17), + 68: uint8(17), + 69: uint8(17), + 70: uint8(17), + 71: uint8(17), + 72: uint8(17), + 73: uint8(17), + 74: uint8(17), + 75: uint8(17), + 76: uint8(17), + 77: uint8(29), + 78: uint8(17), + 79: uint8(17), + 80: uint8(17), + 81: uint8(17), + 82: uint8(17), + 83: uint8(17), + 84: uint8(17), + 85: uint8(17), + 86: uint8(17), + 87: uint8(17), + 88: uint8(17), + 89: uint8(17), + 90: uint8(17), + 91: uint8(17), + 92: uint8(17), + 93: uint8(17), + 94: uint8(17), + 95: uint8(17), + 96: uint8(17), + 97: uint8(17), + 98: uint8(17), + 99: uint8(17), + 100: uint8(17), + 101: uint8(17), + 102: uint8(17), + 103: uint8(17), + 104: uint8(17), + 105: uint8(17), + 106: uint8(17), + 107: uint8(17), + 108: uint8(17), + 109: uint8(17), + 110: uint8(17), + 111: uint8(17), + 112: uint8(17), + 113: uint8(17), + 114: uint8(17), + 115: uint8(17), + 116: uint8(17), + 117: uint8(17), + 118: uint8(17), + 119: uint8(17), + 120: uint8(17), + 121: uint8(17), + 122: uint8(17), + 123: uint8(17), + 124: uint8(17), + 125: uint8(17), + 126: uint8(17), + 127: uint8(17), + 128: uint8(17), + 129: uint8(17), + 130: uint8(17), + 131: uint8(17), + 132: uint8(17), + 133: uint8(17), + 134: uint8(17), + 135: uint8(17), + 136: uint8(17), + 137: uint8(17), + 138: uint8(17), + 139: uint8(17), + 140: uint8(17), + 141: uint8(17), + 142: uint8(17), + 143: uint8(17), + 144: uint8(17), + 145: uint8(17), + 146: uint8(17), + 147: uint8(17), + 148: uint8(17), + 149: uint8(17), + 150: uint8(17), + 151: uint8(17), + 152: uint8(17), + 153: uint8(17), + 154: uint8(17), + 155: uint8(17), + 156: uint8(17), + 157: uint8(17), + 158: uint8(17), + 159: uint8(17), + 160: uint8(17), + 161: uint8(17), + 162: uint8(17), + 163: uint8(17), + 164: uint8(30), + 165: uint8(16), + 166: uint8(16), + 167: uint8(16), + 168: uint8(16), + 169: uint8(31), + 170: uint8(16), + 171: uint8(16), + 172: uint8(17), + 173: uint8(17), + 174: uint8(17), + 175: uint8(17), + 176: uint8(17), + 177: uint8(17), + 178: uint8(17), + 179: uint8(17), + 180: uint8(17), + 181: uint8(17), + 182: uint8(17), + 183: uint8(17), + 184: uint8(17), + 185: uint8(17), + 186: uint8(17), + 187: uint8(17), + 188: uint8(17), + 189: uint8(17), + 190: uint8(17), + 191: uint8(17), + 192: uint8(17), + 193: uint8(17), + 194: uint8(17), + 195: uint8(17), + 196: uint8(17), + 197: uint8(17), + 198: uint8(17), + 199: uint8(17), + 200: uint8(17), + 201: uint8(17), + 202: uint8(17), + 203: uint8(17), + 204: uint8(17), + 205: uint8(17), + 206: uint8(17), + 207: uint8(17), + 208: uint8(17), + 209: uint8(17), + 210: uint8(17), + 211: uint8(17), + 212: uint8(17), + 213: uint8(17), + 214: uint8(17), + 215: uint8(32), + 216: uint8(16), + 217: uint8(16), + 218: uint8(16), + 219: uint8(16), + 220: uint8(16), + 221: uint8(16), + 222: uint8(16), + 223: uint8(16), + 224: uint8(16), + 225: uint8(16), + 226: uint8(16), + 227: uint8(16), + 228: uint8(16), + 229: uint8(16), + 230: uint8(16), + 231: uint8(16), + 232: uint8(16), + 233: uint8(16), + 234: uint8(16), + 235: uint8(16), + 236: uint8(16), + 237: uint8(16), + 238: uint8(16), + 239: uint8(16), + 240: uint8(16), + 241: uint8(16), + 242: uint8(16), + 243: uint8(16), + 244: uint8(16), + 245: uint8(16), + 246: uint8(16), + 247: uint8(16), + 248: uint8(16), + 249: uint8(17), + 250: uint8(17), + 251: uint8(16), + 252: uint8(16), + 253: uint8(16), + 254: uint8(33), + 255: uint8(34), + 256: uint8(16), + 257: uint8(16), + 258: uint8(16), + 259: uint8(16), + 260: uint8(16), + 261: uint8(16), + 262: uint8(16), + 263: uint8(16), + 264: uint8(16), + 265: uint8(16), + 266: uint8(16), + 267: uint8(16), + 268: uint8(16), + 269: uint8(16), + 270: uint8(16), + 271: uint8(16), + 272: uint8(16), + 273: uint8(16), + 274: uint8(16), + 275: uint8(16), + 276: uint8(16), + 277: uint8(16), + 278: uint8(16), + 279: uint8(16), + 280: uint8(16), + 281: uint8(16), + 282: uint8(16), + 283: uint8(16), + 284: uint8(16), + 285: uint8(16), + 286: uint8(16), + 287: uint8(16), + 288: uint8(16), + 289: uint8(16), + 290: uint8(16), + 291: uint8(16), + 292: uint8(16), + 293: uint8(16), + 294: uint8(16), + 295: uint8(16), + 296: uint8(16), + 297: uint8(16), + 298: uint8(16), + 299: uint8(16), + 300: uint8(16), + 301: uint8(16), + 302: uint8(16), + 303: uint8(16), + 304: uint8(16), + 305: uint8(16), + 306: uint8(16), + 307: uint8(16), + 308: uint8(16), + 309: uint8(16), + 310: uint8(16), + 311: uint8(16), + 312: uint8(16), + 313: uint8(16), + 314: uint8(16), + 315: uint8(16), + 316: uint8(16), + 317: uint8(16), + 318: uint8(16), + 319: uint8(16), + 320: uint8(16), + 321: uint8(16), + 322: uint8(16), + 323: uint8(16), + 324: uint8(16), + 325: uint8(16), + 326: uint8(16), + 327: uint8(16), + 328: uint8(16), + 329: uint8(16), + 330: uint8(16), + 331: uint8(16), + 332: uint8(16), + 333: uint8(16), + 334: uint8(16), + 335: uint8(16), + 336: uint8(16), + 337: uint8(16), + 338: uint8(16), + 339: uint8(16), + 340: uint8(16), + 341: uint8(16), + 342: uint8(16), + 343: uint8(16), + 344: uint8(16), + 345: uint8(16), + 346: uint8(16), + 347: uint8(16), + 348: uint8(16), + 349: uint8(16), + 350: uint8(16), + 351: uint8(16), + 352: uint8(16), + 353: uint8(16), + 354: uint8(16), + 355: uint8(16), + 356: uint8(16), + 357: uint8(16), + 358: uint8(16), + 359: uint8(16), + 360: uint8(16), + 361: uint8(16), + 362: uint8(16), + 363: uint8(16), + 364: uint8(16), + 365: uint8(16), + 366: uint8(16), + 367: uint8(35), + 368: uint8(17), + 369: uint8(17), + 370: uint8(17), + 371: uint8(17), + 372: uint8(17), + 373: uint8(17), + 374: uint8(17), + 375: uint8(17), + 376: uint8(17), + 377: uint8(17), + 378: uint8(17), + 379: uint8(17), + 380: uint8(17), + 381: uint8(17), + 382: uint8(17), + 383: uint8(17), + 384: uint8(17), + 385: uint8(17), + 386: uint8(17), + 387: uint8(17), + 388: uint8(17), + 389: uint8(17), + 390: uint8(17), + 391: uint8(36), + 392: uint8(17), + 393: uint8(17), + 394: uint8(37), + 395: uint8(16), + 396: uint8(16), + 397: uint8(16), + 398: uint8(16), + 399: uint8(16), + 400: uint8(16), + 401: uint8(16), + 402: uint8(16), + 403: uint8(16), + 404: uint8(16), + 405: uint8(16), + 406: uint8(16), + 407: uint8(16), + 408: uint8(16), + 409: uint8(16), + 410: uint8(16), + 411: uint8(16), + 412: uint8(16), + 413: uint8(16), + 414: uint8(16), + 415: uint8(16), + 416: uint8(16), + 417: uint8(16), + 418: uint8(16), + 419: uint8(16), + 420: uint8(16), + 421: uint8(16), + 422: uint8(16), + 423: uint8(16), + 424: uint8(16), + 425: uint8(16), + 426: uint8(16), + 427: uint8(16), + 428: uint8(16), + 429: uint8(16), + 430: uint8(16), + 431: uint8(16), + 432: uint8(17), + 433: uint8(38), + 434: uint8(39), + 435: uint8(16), + 436: uint8(16), + 437: uint8(16), + 438: uint8(16), + 439: uint8(16), + 440: uint8(16), + 441: uint8(16), + 442: uint8(16), + 443: uint8(16), + 444: uint8(16), + 445: uint8(16), + 446: uint8(16), + 447: uint8(16), + 448: uint8(16), + 449: uint8(16), + 450: uint8(16), + 451: uint8(16), + 452: uint8(16), + 453: uint8(16), + 454: uint8(16), + 455: uint8(16), + 456: uint8(16), + 457: uint8(16), + 458: uint8(16), + 459: uint8(16), + 460: uint8(16), + 461: uint8(16), + 462: uint8(16), + 463: uint8(16), + 464: uint8(16), + 465: uint8(16), + 466: uint8(16), + 467: uint8(16), + 468: uint8(16), + 469: uint8(16), + 470: uint8(16), + 471: uint8(16), + 472: uint8(16), + 473: uint8(16), + 474: uint8(16), + 475: uint8(16), + 476: uint8(16), + 477: uint8(16), + 478: uint8(16), + 479: uint8(16), + 480: uint8(16), + 481: uint8(16), + 482: uint8(16), + 483: uint8(16), + 484: uint8(16), + 485: uint8(16), + 486: uint8(16), + 487: uint8(16), + 488: uint8(16), + 489: uint8(16), + 490: uint8(16), + 491: uint8(16), + 492: uint8(16), + 493: uint8(16), + 494: uint8(16), + 495: uint8(16), + 496: uint8(40), + 497: uint8(41), + 498: uint8(42), + 499: uint8(43), + 500: uint8(44), + 501: uint8(45), + 502: uint8(46), + 503: uint8(47), + 504: uint8(16), + 505: uint8(48), + 506: uint8(49), + 507: uint8(16), + 508: uint8(16), + 509: uint8(16), + 510: uint8(16), + 511: uint8(16), + 544: uint8(255), + 545: uint8(255), + 546: uint8(255), + 547: uint8(255), + 548: uint8(255), + 549: uint8(255), + 550: uint8(255), + 551: uint8(255), + 552: uint8(255), + 553: uint8(255), + 554: uint8(255), + 555: uint8(255), + 556: uint8(255), + 557: uint8(255), + 558: uint8(255), + 559: uint8(255), + 560: uint8(255), + 561: uint8(255), + 562: uint8(255), + 563: uint8(255), + 564: uint8(255), + 565: uint8(255), + 566: uint8(255), + 567: uint8(255), + 568: uint8(255), + 569: uint8(255), + 570: uint8(255), + 571: uint8(255), + 572: uint8(255), + 573: uint8(255), + 574: uint8(255), + 575: uint8(255), + 576: uint8(255), + 577: uint8(255), + 578: uint8(255), + 579: uint8(255), + 580: uint8(255), + 581: uint8(255), + 582: uint8(255), + 583: uint8(255), + 584: uint8(255), + 585: uint8(255), + 586: uint8(255), + 587: uint8(255), + 611: uint8(12), + 613: uint8(6), + 637: uint8(30), + 638: uint8(9), + 671: uint8(96), + 674: uint8(48), + 681: uint8(255), + 682: uint8(15), + 687: uint8(128), + 690: uint8(8), + 692: uint8(2), + 693: uint8(12), + 695: uint8(96), + 696: uint8(48), + 697: uint8(64), + 698: uint8(16), + 701: uint8(4), + 702: uint8(44), + 703: uint8(36), + 704: uint8(32), + 705: uint8(12), + 709: uint8(1), + 713: uint8(80), + 714: uint8(184), + 722: uint8(224), + 726: uint8(1), + 727: uint8(128), + 739: uint8(24), + 746: uint8(33), + 784: uint8(255), + 785: uint8(255), + 786: uint8(255), + 787: uint8(251), + 788: uint8(255), + 789: uint8(255), + 790: uint8(255), + 791: uint8(255), + 792: uint8(255), + 793: uint8(255), + 794: uint8(255), + 795: uint8(255), + 796: uint8(255), + 797: uint8(255), + 798: uint8(15), + 800: uint8(255), + 801: uint8(255), + 802: uint8(255), + 803: uint8(255), + 804: uint8(255), + 805: uint8(255), + 806: uint8(255), + 807: uint8(255), + 808: uint8(255), + 809: uint8(255), + 810: uint8(255), + 811: uint8(255), + 812: uint8(255), + 813: uint8(255), + 814: uint8(255), + 815: uint8(255), + 816: uint8(255), + 817: uint8(255), + 818: uint8(255), + 819: uint8(255), + 820: uint8(255), + 821: uint8(255), + 822: uint8(255), + 823: uint8(255), + 824: uint8(255), + 825: uint8(255), + 826: uint8(63), + 830: uint8(255), + 831: uint8(15), + 832: uint8(255), + 833: uint8(255), + 834: uint8(255), + 835: uint8(255), + 836: uint8(255), + 837: uint8(255), + 838: uint8(255), + 839: uint8(127), + 840: uint8(254), + 841: uint8(255), + 842: uint8(255), + 843: uint8(255), + 844: uint8(255), + 845: uint8(255), + 846: uint8(255), + 847: uint8(255), + 848: uint8(255), + 849: uint8(255), + 850: uint8(127), + 851: uint8(254), + 852: uint8(255), + 853: uint8(255), + 854: uint8(255), + 855: uint8(255), + 856: uint8(255), + 857: uint8(255), + 858: uint8(255), + 859: uint8(255), + 860: uint8(255), + 861: uint8(255), + 862: uint8(255), + 863: uint8(255), + 864: uint8(224), + 865: uint8(255), + 866: uint8(255), + 867: uint8(255), + 868: uint8(255), + 869: uint8(255), + 870: uint8(254), + 871: uint8(255), + 872: uint8(255), + 873: uint8(255), + 874: uint8(255), + 875: uint8(255), + 876: uint8(255), + 877: uint8(255), + 878: uint8(255), + 879: uint8(255), + 880: uint8(255), + 881: uint8(127), + 882: uint8(255), + 883: uint8(255), + 884: uint8(255), + 885: uint8(255), + 886: uint8(255), + 887: uint8(7), + 888: uint8(255), + 889: uint8(255), + 890: uint8(255), + 891: uint8(255), + 892: uint8(15), + 894: uint8(255), + 895: uint8(255), + 896: uint8(255), + 897: uint8(255), + 898: uint8(255), + 899: uint8(127), + 900: uint8(255), + 901: uint8(255), + 902: uint8(255), + 903: uint8(255), + 904: uint8(255), + 906: uint8(255), + 907: uint8(255), + 908: uint8(255), + 909: uint8(255), + 910: uint8(255), + 911: uint8(255), + 912: uint8(255), + 913: uint8(255), + 914: uint8(255), + 915: uint8(255), + 916: uint8(255), + 917: uint8(255), + 918: uint8(255), + 919: uint8(255), + 920: uint8(255), + 921: uint8(255), + 922: uint8(255), + 923: uint8(255), + 924: uint8(255), + 925: uint8(255), + 926: uint8(255), + 927: uint8(255), + 928: uint8(255), + 929: uint8(255), + 930: uint8(255), + 931: uint8(255), + 932: uint8(255), + 933: uint8(255), + 934: uint8(255), + 935: uint8(255), + 936: uint8(255), + 937: uint8(255), + 938: uint8(255), + 939: uint8(255), + 940: uint8(255), + 941: uint8(255), + 942: uint8(255), + 943: uint8(255), + 944: uint8(255), + 945: uint8(255), + 946: uint8(255), + 947: uint8(255), + 948: uint8(255), + 949: uint8(255), + 950: uint8(255), + 951: uint8(255), + 960: uint8(255), + 961: uint8(255), + 962: uint8(255), + 963: uint8(255), + 964: uint8(255), + 965: uint8(255), + 966: uint8(255), + 967: uint8(255), + 968: uint8(255), + 969: uint8(255), + 970: uint8(255), + 971: uint8(255), + 972: uint8(255), + 973: uint8(255), + 974: uint8(255), + 975: uint8(255), + 976: uint8(255), + 977: uint8(31), + 978: uint8(255), + 979: uint8(255), + 980: uint8(255), + 981: uint8(255), + 982: uint8(255), + 983: uint8(255), + 984: uint8(127), + 1004: uint8(255), + 1005: uint8(255), + 1006: uint8(255), + 1007: uint8(31), + 1024: uint8(255), + 1025: uint8(255), + 1026: uint8(255), + 1027: uint8(255), + 1028: uint8(255), + 1029: uint8(255), + 1030: uint8(255), + 1031: uint8(255), + 1032: uint8(255), + 1033: uint8(255), + 1034: uint8(255), + 1035: uint8(255), + 1036: uint8(255), + 1037: uint8(255), + 1038: uint8(255), + 1039: uint8(255), + 1040: uint8(255), + 1041: uint8(255), + 1042: uint8(255), + 1043: uint8(255), + 1044: uint8(15), + 1058: uint8(255), + 1059: uint8(3), + 1062: uint8(255), + 1063: uint8(255), + 1064: uint8(255), + 1065: uint8(255), + 1066: uint8(247), + 1067: uint8(255), + 1068: uint8(127), + 1069: uint8(15), + 1088: uint8(254), + 1089: uint8(255), + 1090: uint8(255), + 1091: uint8(255), + 1092: uint8(255), + 1093: uint8(255), + 1094: uint8(255), + 1095: uint8(255), + 1096: uint8(255), + 1097: uint8(255), + 1098: uint8(255), + 1099: uint8(255), + 1100: uint8(1), + 1116: uint8(127), + 1148: uint8(15), + 1152: uint8(255), + 1153: uint8(255), + 1154: uint8(255), + 1155: uint8(255), + 1156: uint8(255), + 1157: uint8(255), + 1158: uint8(255), + 1159: uint8(255), + 1160: uint8(255), + 1161: uint8(255), + 1162: uint8(255), + 1163: uint8(255), + 1164: uint8(255), + 1165: uint8(255), + 1166: uint8(255), + 1167: uint8(255), + 1168: uint8(255), + 1169: uint8(255), + 1170: uint8(255), + 1171: uint8(255), + 1172: uint8(255), + 1173: uint8(255), + 1174: uint8(255), + 1175: uint8(255), + 1176: uint8(255), + 1177: uint8(255), + 1178: uint8(255), + 1179: uint8(255), + 1180: uint8(255), + 1181: uint8(255), + 1182: uint8(255), + 1184: uint8(255), + 1185: uint8(255), + 1186: uint8(255), + 1187: uint8(255), + 1188: uint8(255), + 1189: uint8(255), + 1190: uint8(255), + 1191: uint8(255), + 1192: uint8(255), + 1193: uint8(255), + 1194: uint8(255), + 1195: uint8(255), + 1196: uint8(255), + 1197: uint8(255), + 1198: uint8(255), + 1199: uint8(255), + 1200: uint8(255), + 1201: uint8(255), + 1202: uint8(255), + 1203: uint8(255), + 1204: uint8(255), + 1205: uint8(255), + 1206: uint8(255), + 1207: uint8(255), + 1208: uint8(255), + 1209: uint8(255), + 1210: uint8(255), + 1211: uint8(255), + 1212: uint8(255), + 1213: uint8(255), + 1214: uint8(7), + 1216: uint8(255), + 1217: uint8(255), + 1218: uint8(255), + 1219: uint8(127), + 1226: uint8(7), + 1228: uint8(240), + 1230: uint8(255), + 1231: uint8(255), + 1232: uint8(255), + 1233: uint8(255), + 1234: uint8(255), + 1235: uint8(255), + 1236: uint8(255), + 1237: uint8(255), + 1238: uint8(255), + 1239: uint8(255), + 1240: uint8(255), + 1241: uint8(255), + 1242: uint8(255), + 1243: uint8(255), + 1244: uint8(255), + 1245: uint8(255), + 1246: uint8(255), + 1247: uint8(255), + 1248: uint8(255), + 1249: uint8(255), + 1250: uint8(255), + 1251: uint8(255), + 1252: uint8(255), + 1253: uint8(255), + 1254: uint8(255), + 1255: uint8(255), + 1256: uint8(255), + 1257: uint8(255), + 1258: uint8(255), + 1259: uint8(255), + 1260: uint8(255), + 1261: uint8(255), + 1262: uint8(255), + 1263: uint8(255), + 1264: uint8(255), + 1265: uint8(255), + 1266: uint8(255), + 1267: uint8(255), + 1268: uint8(255), + 1269: uint8(255), + 1270: uint8(255), + 1271: uint8(255), + 1272: uint8(255), + 1273: uint8(255), + 1274: uint8(255), + 1275: uint8(255), + 1276: uint8(255), + 1277: uint8(255), + 1278: uint8(255), + 1279: uint8(15), + 1280: uint8(16), + 1305: uint8(128), + 1329: uint8(64), + 1330: uint8(254), + 1331: uint8(7), + 1344: uint8(7), + 1346: uint8(255), + 1347: uint8(255), + 1348: uint8(255), + 1349: uint8(255), + 1350: uint8(255), + 1351: uint8(15), + 1352: uint8(255), + 1353: uint8(1), + 1354: uint8(3), + 1356: uint8(63), + 1376: uint8(255), + 1377: uint8(255), + 1378: uint8(255), + 1379: uint8(255), + 1380: uint8(1), + 1381: uint8(224), + 1382: uint8(191), + 1383: uint8(255), + 1384: uint8(255), + 1385: uint8(255), + 1386: uint8(255), + 1387: uint8(255), + 1388: uint8(255), + 1389: uint8(255), + 1390: uint8(255), + 1391: uint8(223), + 1392: uint8(255), + 1393: uint8(255), + 1394: uint8(15), + 1396: uint8(255), + 1397: uint8(255), + 1398: uint8(255), + 1399: uint8(255), + 1400: uint8(255), + 1401: uint8(135), + 1402: uint8(15), + 1404: uint8(255), + 1405: uint8(255), + 1406: uint8(17), + 1407: uint8(255), + 1408: uint8(255), + 1409: uint8(255), + 1410: uint8(255), + 1411: uint8(255), + 1412: uint8(255), + 1413: uint8(255), + 1414: uint8(255), + 1415: uint8(127), + 1416: uint8(253), + 1417: uint8(255), + 1418: uint8(255), + 1419: uint8(255), + 1420: uint8(255), + 1421: uint8(255), + 1422: uint8(255), + 1423: uint8(255), + 1424: uint8(255), + 1425: uint8(255), + 1426: uint8(255), + 1427: uint8(255), + 1428: uint8(255), + 1429: uint8(255), + 1430: uint8(255), + 1431: uint8(255), + 1432: uint8(255), + 1433: uint8(255), + 1434: uint8(255), + 1435: uint8(255), + 1436: uint8(255), + 1437: uint8(255), + 1438: uint8(255), + 1439: uint8(159), + 1440: uint8(255), + 1441: uint8(255), + 1442: uint8(255), + 1443: uint8(255), + 1444: uint8(255), + 1445: uint8(255), + 1446: uint8(255), + 1447: uint8(63), + 1449: uint8(120), + 1450: uint8(255), + 1451: uint8(255), + 1452: uint8(255), + 1455: uint8(4), + 1458: uint8(96), + 1460: uint8(16), + 1471: uint8(248), + 1472: uint8(255), + 1473: uint8(255), + 1474: uint8(255), + 1475: uint8(255), + 1476: uint8(255), + 1477: uint8(255), + 1478: uint8(255), + 1479: uint8(255), + 1480: uint8(255), + 1481: uint8(255), + 1488: uint8(255), + 1489: uint8(255), + 1490: uint8(255), + 1491: uint8(255), + 1492: uint8(255), + 1493: uint8(255), + 1494: uint8(255), + 1495: uint8(255), + 1496: uint8(63), + 1497: uint8(16), + 1498: uint8(39), + 1501: uint8(24), + 1502: uint8(240), + 1503: uint8(7), + 1532: uint8(255), + 1533: uint8(15), + 1537: uint8(224), + 1538: uint8(255), + 1539: uint8(255), + 1540: uint8(255), + 1541: uint8(255), + 1542: uint8(255), + 1543: uint8(255), + 1544: uint8(255), + 1545: uint8(255), + 1546: uint8(255), + 1547: uint8(255), + 1548: uint8(255), + 1549: uint8(255), + 1550: uint8(123), + 1551: uint8(252), + 1552: uint8(255), + 1553: uint8(255), + 1554: uint8(255), + 1555: uint8(255), + 1556: uint8(231), + 1557: uint8(199), + 1558: uint8(255), + 1559: uint8(255), + 1560: uint8(255), + 1561: uint8(231), + 1562: uint8(255), + 1563: uint8(255), + 1564: uint8(255), + 1565: uint8(255), + 1566: uint8(255), + 1567: uint8(255), + 1582: uint8(15), + 1583: uint8(7), + 1584: uint8(7), + 1586: uint8(63), +} + +func Xwcwidth(tls *TLS, wc Twchar_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v2 int32 + _, _ = v1, v2 + if Uint32FromInt32(wc) < uint32(0xff) { + if (wc+int32(1))&int32(0x7f) >= int32(0x21) { + v1 = int32(1) + } else { + if wc != 0 { + v2 = -int32(1) + } else { + v2 = 0 + } + v1 = v2 + } + return v1 + } + if Uint32FromInt32(wc)&uint32(0xfffeffff) < uint32(0xfffe) { + if Int32FromUint8(_table5[Int32FromUint8(_table5[wc>>int32(8)])*int32(32)+wc&int32(255)>>int32(3)])>>(wc&int32(7))&int32(1) != 0 { + return 0 + } + if Int32FromUint8(_wtable[Int32FromUint8(_wtable[wc>>int32(8)])*int32(32)+wc&int32(255)>>int32(3)])>>(wc&int32(7))&int32(1) != 0 { + return int32(2) + } + return int32(1) + } + if wc&int32(0xfffe) == int32(0xfffe) { + return -int32(1) + } + if Uint32FromInt32(wc)-uint32(0x20000) < uint32(0x20000) { + return int32(2) + } + if wc == int32(0xe0001) || Uint32FromInt32(wc)-uint32(0xe0020) < uint32(0x5f) || Uint32FromInt32(wc)-uint32(0xe0100) < uint32(0xef) { + return 0 + } + return int32(1) +} + +const d_fileno = 0 + +type Tino_t = uint64 + +type Tdirent = struct { + Fd_ino Tino_t + Fd_off Toff_t + Fd_reclen uint16 + Fd_type uint8 + Fd_name [256]int8 +} + +func Xalphasort(tls *TLS, a uintptr, b uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrcoll(tls, **(**uintptr)(__ccgo_up(a))+19, **(**uintptr)(__ccgo_up(b))+19) +} + +type TDIR = struct { + Ftell Toff_t + Ffd int32 + Fbuf_pos int32 + Fbuf_end int32 + Flock [1]int32 + Fbuf [2048]int8 +} + +type t__dirstream = TDIR + +func Xclosedir(tls *TLS, dir uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + ret = Xclose(tls, (*TDIR)(unsafe.Pointer(dir)).Ffd) + Xfree(tls, dir) + return ret +} + +func Xdirfd(tls *TLS, d uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v d=%v, (%v:)", tls, d, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*TDIR)(unsafe.Pointer(d)).Ffd +} + +const AT_EACCESS = 512 +const AT_FDCWD = -100 +const AT_REMOVEDIR = 512 +const AT_SYMLINK_FOLLOW = 1024 +const AT_SYMLINK_NOFOLLOW = 256 +const FD_CLOEXEC = 1 +const F_DUPFD = 0 +const F_DUPFD_CLOEXEC = 1030 +const F_GETFD = 1 +const F_GETFL = 3 +const F_GETLK = 5 +const F_GETOWN = 9 +const F_GETOWNER_UIDS = 17 +const F_GETOWN_EX = 16 +const F_GETSIG = 11 +const F_OFD_GETLK = 36 +const F_OFD_SETLK = 37 +const F_OFD_SETLKW = 38 +const F_RDLCK = 0 +const F_SETFD = 2 +const F_SETFL = 4 +const F_SETLK = 6 +const F_SETLKW = 7 +const F_SETOWN = 8 +const F_SETOWN_EX = 15 +const F_SETSIG = 10 +const F_UNLCK = 2 +const F_WRLCK = 1 +const O_ACCMODE = 2097155 +const O_APPEND = 1024 +const O_ASYNC = 8192 +const O_CLOEXEC = 524288 +const O_CREAT = 64 +const O_DIRECT = 16384 +const O_DIRECTORY = 65536 +const O_DSYNC = 4096 +const O_EXCL = 128 +const O_EXEC = 2097152 +const O_LARGEFILE = 32768 +const O_NDELAY = 2048 +const O_NOATIME = 262144 +const O_NOCTTY = 256 +const O_NOFOLLOW = 131072 +const O_NONBLOCK = 2048 +const O_PATH = 2097152 +const O_RDONLY = 0 +const O_RDWR = 2 +const O_RSYNC = 1052672 +const O_SEARCH = 2097152 +const O_SYNC = 1052672 +const O_TMPFILE = 4259840 +const O_TRUNC = 512 +const O_TTY_INIT = 0 +const O_WRONLY = 1 +const POSIX_FADV_DONTNEED = 4 +const POSIX_FADV_NOREUSE = 5 +const POSIX_FADV_NORMAL = 0 +const POSIX_FADV_RANDOM = 1 +const POSIX_FADV_SEQUENTIAL = 2 +const POSIX_FADV_WILLNEED = 3 +const S_IFBLK = 24576 +const S_IFCHR = 8192 +const S_IFDIR = 16384 +const S_IFIFO = 4096 +const S_IFLNK = 40960 +const S_IFMT = 61440 +const S_IFREG = 32768 +const S_IFSOCK = 49152 +const S_IRGRP = 32 +const S_IROTH = 4 +const S_IRUSR = 256 +const S_IRWXG = 56 +const S_IRWXO = 7 +const S_IRWXU = 448 +const S_ISGID = 1024 +const S_ISUID = 2048 +const S_ISVTX = 512 +const S_IWGRP = 16 +const S_IWOTH = 2 +const S_IWUSR = 128 +const S_IXGRP = 8 +const S_IXOTH = 1 +const S_IXUSR = 64 +const UTIME_NOW = 1073741823 +const UTIME_OMIT = 1073741822 + +type Tflock = struct { + Fl_type int16 + Fl_whence int16 + Fl_start Toff_t + Fl_len Toff_t + Fl_pid Tpid_t +} + +type Tnlink_t = uint64 + +type Tdev_t = uint64 + +type Tblksize_t = int64 + +type Tblkcnt_t = int64 + +type Tstat = struct { + Fst_dev Tdev_t + Fst_ino Tino_t + Fst_nlink Tnlink_t + Fst_mode Tmode_t + Fst_uid Tuid_t + Fst_gid Tgid_t + F__pad0 uint32 + Fst_rdev Tdev_t + Fst_size Toff_t + Fst_blksize Tblksize_t + Fst_blocks Tblkcnt_t + Fst_atim Ttimespec + Fst_mtim Ttimespec + Fst_ctim Ttimespec + F__unused [3]int64 +} + +func Xfdopendir(tls *TLS, fd int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(160) + defer tls.Free(160) + var dir, v1 uintptr + var _ /* st at bp+0 */ Tstat + _, _ = dir, v1 + if Xfstat(tls, fd, bp) < 0 { + return uintptr(0) + } + if Xfcntl(tls, fd, int32(F_GETFL), 0)&int32(O_PATH) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EBADF) + return uintptr(0) + } + if !((**(**Tstat)(__ccgo_up(bp))).Fst_mode&Uint32FromInt32(S_IFMT) == Uint32FromInt32(S_IFDIR)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOTDIR) + return uintptr(0) + } + v1 = Xcalloc(tls, uint64(1), uint64(2072)) + dir = v1 + if !(v1 != 0) { + return uintptr(0) + } + Xfcntl(tls, fd, int32(F_SETFD), VaList(bp+152, int32(FD_CLOEXEC))) + (*TDIR)(unsafe.Pointer(dir)).Ffd = fd + return dir +} + +const AT_EMPTY_PATH = 4096 +const AT_NO_AUTOMOUNT = 2048 +const AT_RECURSIVE = 32768 +const AT_STATX_DONT_SYNC = 16384 +const AT_STATX_FORCE_SYNC = 8192 +const AT_STATX_SYNC_AS_STAT = 0 +const AT_STATX_SYNC_TYPE = 24576 +const DN_ACCESS = 1 +const DN_ATTRIB = 32 +const DN_CREATE = 4 +const DN_DELETE = 8 +const DN_MODIFY = 2 +const DN_MULTISHOT = 2147483648 +const DN_RENAME = 16 +const DT_BLK = 6 +const DT_CHR = 2 +const DT_DIR = 4 +const DT_FIFO = 1 +const DT_LNK = 10 +const DT_REG = 8 +const DT_SOCK = 12 +const DT_UNKNOWN = 0 +const DT_WHT = 14 +const FALLOC_FL_KEEP_SIZE = 1 +const FALLOC_FL_PUNCH_HOLE = 2 +const FAPPEND = 1024 +const FASYNC = 8192 +const FFSYNC = 1052672 +const FNDELAY = 2048 +const FNONBLOCK = 2048 +const F_ADD_SEALS = 1033 +const F_CANCELLK = 1029 +const F_GETLEASE = 1025 +const F_GETPIPE_SZ = 1032 +const F_GET_FILE_RW_HINT = 1037 +const F_GET_RW_HINT = 1035 +const F_GET_SEALS = 1034 +const F_NOTIFY = 1026 +const F_OWNER_GID = 2 +const F_OWNER_PGRP = 2 +const F_OWNER_PID = 1 +const F_OWNER_TID = 0 +const F_SEAL_FUTURE_WRITE = 16 +const F_SEAL_GROW = 4 +const F_SEAL_SEAL = 1 +const F_SEAL_SHRINK = 2 +const F_SEAL_WRITE = 8 +const F_SETLEASE = 1024 +const F_SETPIPE_SZ = 1031 +const F_SET_FILE_RW_HINT = 1038 +const F_SET_RW_HINT = 1036 +const MAX_HANDLE_SZ = 128 +const RWF_WRITE_LIFE_NOT_SET = 0 +const RWH_WRITE_LIFE_EXTREME = 5 +const RWH_WRITE_LIFE_LONG = 4 +const RWH_WRITE_LIFE_MEDIUM = 3 +const RWH_WRITE_LIFE_NONE = 1 +const RWH_WRITE_LIFE_SHORT = 2 +const SPLICE_F_GIFT = 8 +const SPLICE_F_MORE = 4 +const SPLICE_F_MOVE = 1 +const SPLICE_F_NONBLOCK = 2 +const SYNC_FILE_RANGE_WAIT_AFTER = 4 +const SYNC_FILE_RANGE_WAIT_BEFORE = 1 +const SYNC_FILE_RANGE_WRITE = 2 +const alloca = 0 +const loff_t = 0 + +type Tiovec = struct { + Fiov_base uintptr + Fiov_len Tsize_t +} + +type Tfile_handle = struct { + Fhandle_bytes uint32 + Fhandle_type int32 +} + +type Tf_owner_ex = struct { + Ftype1 int32 + Fpid Tpid_t +} + +func Xopendir(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var dir, v2 uintptr + var fd, v1 int32 + _, _, _, _ = dir, fd, v1, v2 + v1 = Xopen(tls, name, Int32FromInt32(O_RDONLY)|Int32FromInt32(O_DIRECTORY)|Int32FromInt32(O_CLOEXEC), 0) + fd = v1 + if v1 < 0 { + return uintptr(0) + } + v2 = Xcalloc(tls, uint64(1), uint64(2072)) + dir = v2 + if !(v2 != 0) { + X__syscall1(tls, int64(SYS_close), int64(fd)) + return uintptr(0) + } + (*TDIR)(unsafe.Pointer(dir)).Ffd = fd + return dir +} + +type Tptrdiff_t = int64 + +type Tdirstream_buf_alignment_check = [1]int8 + +func Xreaddir(tls *TLS, dir uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2)) + defer func() { trc("-> %v", r) }() + } + var de uintptr + var len1 int32 + _, _ = de, len1 + if (*TDIR)(unsafe.Pointer(dir)).Fbuf_pos >= (*TDIR)(unsafe.Pointer(dir)).Fbuf_end { + len1 = int32(X__syscall3(tls, int64(SYS_getdents64), int64((*TDIR)(unsafe.Pointer(dir)).Ffd), int64(dir+24), Int64FromUint64(Uint64FromInt64(2048)))) + if len1 <= 0 { + if len1 < 0 && len1 != -int32(ENOENT) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = -len1 + } + return uintptr(0) + } + (*TDIR)(unsafe.Pointer(dir)).Fbuf_end = len1 + (*TDIR)(unsafe.Pointer(dir)).Fbuf_pos = 0 + } + de = dir + 24 + uintptr((*TDIR)(unsafe.Pointer(dir)).Fbuf_pos) + **(**int32)(__ccgo_up(dir + 12)) += Int32FromUint16((*Tdirent)(unsafe.Pointer(de)).Fd_reclen) + (*TDIR)(unsafe.Pointer(dir)).Ftell = (*Tdirent)(unsafe.Pointer(de)).Fd_off + return de +} + +func Xreaddir_r(tls *TLS, dir uintptr, buf uintptr, result uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dir=%v buf=%v result=%v, (%v:)", tls, dir, buf, result, origin(2)) + defer func() { trc("-> %v", r) }() + } + var de uintptr + var errno_save, ret, v1 int32 + _, _, _, _ = de, errno_save, ret, v1 + errno_save = **(**int32)(__ccgo_up(X__errno_location(tls))) + ___lock(tls, dir+20) + **(**int32)(__ccgo_up(X__errno_location(tls))) = 0 + de = Xreaddir(tls, dir) + v1 = **(**int32)(__ccgo_up(X__errno_location(tls))) + ret = v1 + if v1 != 0 { + ___unlock(tls, dir+20) + return ret + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = errno_save + if de != 0 { + Xmemcpy(tls, buf, de, uint64((*Tdirent)(unsafe.Pointer(de)).Fd_reclen)) + } else { + buf = UintptrFromInt32(0) + } + ___unlock(tls, dir+20) + **(**uintptr)(__ccgo_up(result)) = buf + return 0 +} + +func Xrewinddir(tls *TLS, dir uintptr) { + if __ccgo_strace { + trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2)) + } + var v1 int32 + _ = v1 + ___lock(tls, dir+20) + Xlseek(tls, (*TDIR)(unsafe.Pointer(dir)).Ffd, 0, SEEK_SET) + v1 = Int32FromInt32(0) + (*TDIR)(unsafe.Pointer(dir)).Fbuf_end = v1 + (*TDIR)(unsafe.Pointer(dir)).Fbuf_pos = v1 + (*TDIR)(unsafe.Pointer(dir)).Ftell = 0 + ___unlock(tls, dir+20) +} + +type t__ccgo_fp__Xscandir_2 = func(*TLS, uintptr) int32 + +type t__ccgo_fp__Xscandir_3 = func(*TLS, uintptr, uintptr) int32 + +func Xscandir(tls *TLS, path uintptr, res uintptr, __ccgo_fp_sel uintptr, __ccgo_fp_cmp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v res=%v __ccgo_fp_sel=%v __ccgo_fp_cmp=%v, (%v:)", tls, path, res, __ccgo_fp_sel, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var cnt, len1, v2 Tsize_t + var d, de, names, tmp, v1 uintptr + var old_errno int32 + _, _, _, _, _, _, _, _, _ = cnt, d, de, len1, names, old_errno, tmp, v1, v2 + d = Xopendir(tls, path) + names = uintptr(0) + cnt = uint64(0) + len1 = uint64(0) + old_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + if !(d != 0) { + return -int32(1) + } + for { + **(**int32)(__ccgo_up(X__errno_location(tls))) = 0 + v1 = Xreaddir(tls, d) + de = v1 + if !(v1 != 0) { + break + } + if __ccgo_fp_sel != 0 && !((*(*func(*TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_sel})))(tls, de) != 0) { + continue + } + if cnt >= len1 { + len1 = uint64(2)*len1 + uint64(1) + if len1 > Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt64(8) { + break + } + tmp = Xrealloc(tls, names, len1*uint64(8)) + if !(tmp != 0) { + break + } + names = tmp + } + **(**uintptr)(__ccgo_up(names + uintptr(cnt)*8)) = Xmalloc(tls, uint64((*Tdirent)(unsafe.Pointer(de)).Fd_reclen)) + if !(**(**uintptr)(__ccgo_up(names + uintptr(cnt)*8)) != 0) { + break + } + v2 = cnt + cnt = cnt + 1 + Xmemcpy(tls, **(**uintptr)(__ccgo_up(names + uintptr(v2)*8)), de, uint64((*Tdirent)(unsafe.Pointer(de)).Fd_reclen)) + } + Xclosedir(tls, d) + if **(**int32)(__ccgo_up(X__errno_location(tls))) != 0 { + if names != 0 { + for { + v2 = cnt + cnt = cnt - 1 + if !(v2 > uint64(0)) { + break + } + Xfree(tls, **(**uintptr)(__ccgo_up(names + uintptr(cnt)*8))) + } + } + Xfree(tls, names) + return -int32(1) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + if __ccgo_fp_cmp != 0 { + Xqsort(tls, names, cnt, uint64(8), __ccgo_fp_cmp) + } + **(**uintptr)(__ccgo_up(res)) = names + return Int32FromUint64(cnt) +} + +func Xseekdir(tls *TLS, dir uintptr, off int64) { + if __ccgo_strace { + trc("tls=%v dir=%v off=%v, (%v:)", tls, dir, off, origin(2)) + } + var v1 int32 + _ = v1 + ___lock(tls, dir+20) + (*TDIR)(unsafe.Pointer(dir)).Ftell = Xlseek(tls, (*TDIR)(unsafe.Pointer(dir)).Ffd, off, SEEK_SET) + v1 = Int32FromInt32(0) + (*TDIR)(unsafe.Pointer(dir)).Fbuf_end = v1 + (*TDIR)(unsafe.Pointer(dir)).Fbuf_pos = v1 + ___unlock(tls, dir+20) +} + +func Xtelldir(tls *TLS, dir uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*TDIR)(unsafe.Pointer(dir)).Ftell +} + +func Xversionsort(tls *TLS, a uintptr, b uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrverscmp(tls, **(**uintptr)(__ccgo_up(a))+19, **(**uintptr)(__ccgo_up(b))+19) +} + +func X__reset_tls(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + var i, n Tsize_t + var mem, p uintptr + var self Tpthread_t + _, _, _, _, _ = i, mem, n, p, self + self = uintptr(___get_tp(tls)) + n = **(**Tuintptr_t)(__ccgo_up((*t__pthread)(unsafe.Pointer(self)).Fdtv)) + if n != 0 { + p = X__libc.Ftls_head + i = Uint64FromInt32(1) + for { + if !(i <= n) { + break + } + mem = uintptr(**(**Tuintptr_t)(__ccgo_up((*t__pthread)(unsafe.Pointer(self)).Fdtv + uintptr(i)*8)) - Uint64FromInt32(DTP_OFFSET)) + Xmemcpy(tls, mem, (*Ttls_module)(unsafe.Pointer(p)).Fimage, (*Ttls_module)(unsafe.Pointer(p)).Flen1) + Xmemset(tls, mem+uintptr((*Ttls_module)(unsafe.Pointer(p)).Flen1), 0, (*Ttls_module)(unsafe.Pointer(p)).Fsize-(*Ttls_module)(unsafe.Pointer(p)).Flen1) + goto _1 + _1: + ; + i = i + 1 + p = (*Ttls_module)(unsafe.Pointer(p)).Fnext + } + } +} + +func X__init_ssp(tls *TLS, entropy uintptr) { + if __ccgo_strace { + trc("tls=%v entropy=%v, (%v:)", tls, entropy, origin(2)) + } + if entropy != 0 { + Xmemcpy(tls, uintptr(unsafe.Pointer(&X__stack_chk_guard)), entropy, uint64(8)) + } else { + X__stack_chk_guard = Tuintptr_t(uintptr(unsafe.Pointer(&X__stack_chk_guard))) * uint64(1103515245) + } + /* Sacrifice 8 bits of entropy on 64bit to prevent leaking/ + * overwriting the canary via string-manipulation functions. + * The NULL byte is on the second byte so that off-by-ones can + * still be detected. Endianness is taken care of + * automatically. */ + **(**int8)(__ccgo_up(uintptr(unsafe.Pointer(&X__stack_chk_guard)) + 1)) = 0 + (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Fcanary = X__stack_chk_guard +} + +func X__stack_chk_fail(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + // __asm__ __volatile__( "hlt" : : : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 108, __ccgo_ts+261) +} + +func X__stack_chk_fail_local(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__stack_chk_fail(tls) +} + +const L_INCR = 1 +const L_SET = 0 +const L_XTND = 2 + +func _dummy(tls *TLS, old uintptr, new1 uintptr) { +} + +func Xclearenv(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var e, v1 uintptr + _, _ = e, v1 + e = Xenviron + Xenviron = uintptr(0) + if e != 0 { + for **(**uintptr)(__ccgo_up(e)) != 0 { + v1 = e + e += 8 + X__env_rm_add(tls, **(**uintptr)(__ccgo_up(v1)), uintptr(0)) + } + } + return 0 +} + +func Xgetenv(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var e uintptr + var l Tsize_t + _, _ = e, l + l = Uint64FromInt64(int64(X__strchrnul(tls, name, int32('='))) - int64(name)) + if l != 0 && !(**(**int8)(__ccgo_up(name + uintptr(l))) != 0) && Xenviron != 0 { + e = Xenviron + for { + if !(**(**uintptr)(__ccgo_up(e)) != 0) { + break + } + if !(Xstrncmp(tls, name, **(**uintptr)(__ccgo_up(e)), l) != 0) && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(e)) + uintptr(l)))) == int32('=') { + return **(**uintptr)(__ccgo_up(e)) + uintptr(l) + uintptr(1) + } + goto _1 + _1: + ; + e += 8 + } + } + return uintptr(0) +} + +func _dummy1(tls *TLS, old uintptr, new1 uintptr) { +} + +func X__putenv(tls *TLS, s uintptr, l Tsize_t, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v r=%v, (%v:)", tls, s, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var e, newenv, tmp, v2 uintptr + var i Tsize_t + _, _, _, _, _ = e, i, newenv, tmp, v2 + i = uint64(0) + if Xenviron != 0 { + e = Xenviron + for { + if !(**(**uintptr)(__ccgo_up(e)) != 0) { + break + } + if !(Xstrncmp(tls, s, **(**uintptr)(__ccgo_up(e)), l+uint64(1)) != 0) { + tmp = **(**uintptr)(__ccgo_up(e)) + **(**uintptr)(__ccgo_up(e)) = s + X__env_rm_add(tls, tmp, r) + return 0 + } + goto _1 + _1: + ; + e += 8 + i = i + 1 + } + } + if Xenviron == _oldenv { + newenv = Xrealloc(tls, _oldenv, uint64(8)*(i+uint64(2))) + if !(newenv != 0) { + goto oom + } + } else { + newenv = Xmalloc(tls, uint64(8)*(i+uint64(2))) + if !(newenv != 0) { + goto oom + } + if i != 0 { + Xmemcpy(tls, newenv, Xenviron, uint64(8)*i) + } + Xfree(tls, _oldenv) + } + **(**uintptr)(__ccgo_up(newenv + uintptr(i)*8)) = s + **(**uintptr)(__ccgo_up(newenv + uintptr(i+uint64(1))*8)) = uintptr(0) + v2 = newenv + _oldenv = v2 + Xenviron = v2 + if r != 0 { + X__env_rm_add(tls, uintptr(0), r) + } + return 0 + goto oom +oom: + ; + Xfree(tls, r) + return -int32(1) +} + +var _oldenv uintptr + +func Xputenv(tls *TLS, s uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = Uint64FromInt64(int64(X__strchrnul(tls, s, int32('='))) - int64(s)) + if !(l != 0) || !(**(**int8)(__ccgo_up(s + uintptr(l))) != 0) { + return Xunsetenv(tls, s) + } + return X__putenv(tls, s, l, uintptr(0)) +} + +const L_cuserid = 20 +const NL_NMAX = 16 + +type Tcookie_io_functions_t = struct { + Fread uintptr + Fwrite uintptr + Fseek uintptr + Fclose1 uintptr +} + +type T_IO_cookie_io_functions_t = Tcookie_io_functions_t + +func Xsecure_getenv(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + if X__libc.Fsecure != 0 { + v1 = UintptrFromInt32(0) + } else { + v1 = Xgetenv(tls, name) + } + return v1 +} + +func X__env_rm_add(tls *TLS, old uintptr, new1 uintptr) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v, (%v:)", tls, old, new1, origin(2)) + } + var i, v3 Tsize_t + var t, v2 uintptr + _, _, _, _ = i, t, v2, v3 + i = uint64(0) + for { + if !(i < _env_alloced_n) { + break + } + if **(**uintptr)(__ccgo_up(_env_alloced + uintptr(i)*8)) == old { + **(**uintptr)(__ccgo_up(_env_alloced + uintptr(i)*8)) = new1 + Xfree(tls, old) + return + } else { + if !(**(**uintptr)(__ccgo_up(_env_alloced + uintptr(i)*8)) != 0) && new1 != 0 { + **(**uintptr)(__ccgo_up(_env_alloced + uintptr(i)*8)) = new1 + new1 = uintptr(0) + } + } + goto _1 + _1: + ; + i = i + 1 + } + if !(new1 != 0) { + return + } + t = Xrealloc(tls, _env_alloced, uint64(8)*(_env_alloced_n+uint64(1))) + if !(t != 0) { + return + } + v2 = t + _env_alloced = v2 + v3 = _env_alloced_n + _env_alloced_n = _env_alloced_n + 1 + **(**uintptr)(__ccgo_up(v2 + uintptr(v3)*8)) = new1 +} + +var _env_alloced uintptr + +var _env_alloced_n Tsize_t + +func Xsetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) (r int32) { + if __ccgo_strace { + trc("tls=%v var1=%v value=%v overwrite=%v, (%v:)", tls, var1, value, overwrite, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l1, l2, v1 Tsize_t + var s uintptr + var v2 bool + _, _, _, _, _ = l1, l2, s, v1, v2 + if v2 = !(var1 != 0); !v2 { + v1 = Uint64FromInt64(int64(X__strchrnul(tls, var1, int32('='))) - int64(var1)) + l1 = v1 + } + if v2 || !(v1 != 0) || **(**int8)(__ccgo_up(var1 + uintptr(l1))) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + if !(overwrite != 0) && Xgetenv(tls, var1) != 0 { + return 0 + } + l2 = _strlen(tls, value) + s = Xmalloc(tls, l1+l2+uint64(2)) + if !(s != 0) { + return -int32(1) + } + Xmemcpy(tls, s, var1, l1) + **(**int8)(__ccgo_up(s + uintptr(l1))) = int8('=') + Xmemcpy(tls, s+uintptr(l1)+uintptr(1), value, l2+uint64(1)) + return X__putenv(tls, s, l1, s) +} + +func _dummy2(tls *TLS, old uintptr, new1 uintptr) { +} + +func Xunsetenv(tls *TLS, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var e, eo, v2 uintptr + var l Tsize_t + _, _, _, _ = e, eo, l, v2 + l = Uint64FromInt64(int64(X__strchrnul(tls, name, int32('='))) - int64(name)) + if !(l != 0) || **(**int8)(__ccgo_up(name + uintptr(l))) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + if Xenviron != 0 { + e = Xenviron + eo = e + for { + if !(**(**uintptr)(__ccgo_up(e)) != 0) { + break + } + if !(Xstrncmp(tls, name, **(**uintptr)(__ccgo_up(e)), l) != 0) && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(e)) + uintptr(l)))) == int32('=') { + X__env_rm_add(tls, **(**uintptr)(__ccgo_up(e)), uintptr(0)) + } else { + if eo != e { + v2 = eo + eo += 8 + **(**uintptr)(__ccgo_up(v2)) = **(**uintptr)(__ccgo_up(e)) + } else { + eo += 8 + } + } + goto _1 + _1: + ; + e += 8 + } + if eo != e { + **(**uintptr)(__ccgo_up(eo)) = uintptr(0) + } + } + return 0 +} + +/* mips has one error code outside of the 8-bit range due to a + * historical typo, so we just remap it. */ + +type Terrmsgstr_t = struct { + Fstr0 [21]int8 + FstrEILSEQ [22]int8 + FstrEDOM [13]int8 + FstrERANGE [25]int8 + FstrENOTTY [10]int8 + FstrEACCES [18]int8 + FstrEPERM [24]int8 + FstrENOENT [26]int8 + FstrESRCH [16]int8 + FstrEEXIST [12]int8 + FstrEOVERFLOW [30]int8 + FstrENOSPC [24]int8 + FstrENOMEM [14]int8 + FstrEBUSY [14]int8 + FstrEINTR [24]int8 + FstrEAGAIN [33]int8 + FstrESPIPE [13]int8 + FstrEXDEV [18]int8 + FstrEROFS [22]int8 + FstrENOTEMPTY [20]int8 + FstrECONNRESET [25]int8 + FstrETIMEDOUT [20]int8 + FstrECONNREFUSED [19]int8 + FstrEHOSTDOWN [13]int8 + FstrEHOSTUNREACH [20]int8 + FstrEADDRINUSE [15]int8 + FstrEPIPE [12]int8 + FstrEIO [10]int8 + FstrENXIO [26]int8 + FstrENOTBLK [22]int8 + FstrENODEV [15]int8 + FstrENOTDIR [16]int8 + FstrEISDIR [15]int8 + FstrETXTBSY [15]int8 + FstrENOEXEC [18]int8 + FstrEINVAL [17]int8 + FstrE2BIG [23]int8 + FstrELOOP [19]int8 + FstrENAMETOOLONG [18]int8 + FstrENFILE [30]int8 + FstrEMFILE [30]int8 + FstrEBADF [20]int8 + FstrECHILD [17]int8 + FstrEFAULT [12]int8 + FstrEFBIG [15]int8 + FstrEMLINK [15]int8 + FstrENOLCK [19]int8 + FstrEDEADLK [30]int8 + FstrENOTRECOVERABLE [22]int8 + FstrEOWNERDEAD [20]int8 + FstrECANCELED [19]int8 + FstrENOSYS [25]int8 + FstrENOMSG [27]int8 + FstrEIDRM [19]int8 + FstrENOSTR [20]int8 + FstrENODATA [18]int8 + FstrETIME [15]int8 + FstrENOSR [25]int8 + FstrENOLINK [22]int8 + FstrEPROTO [15]int8 + FstrEBADMSG [12]int8 + FstrEBADFD [29]int8 + FstrENOTSOCK [13]int8 + FstrEDESTADDRREQ [29]int8 + FstrEMSGSIZE [18]int8 + FstrEPROTOTYPE [31]int8 + FstrENOPROTOOPT [23]int8 + FstrEPROTONOSUPPORT [23]int8 + FstrESOCKTNOSUPPORT [26]int8 + FstrENOTSUP [14]int8 + FstrEPFNOSUPPORT [30]int8 + FstrEAFNOSUPPORT [41]int8 + FstrEADDRNOTAVAIL [22]int8 + FstrENETDOWN [16]int8 + FstrENETUNREACH [20]int8 + FstrENETRESET [28]int8 + FstrECONNABORTED [19]int8 + FstrENOBUFS [26]int8 + FstrEISCONN [20]int8 + FstrENOTCONN [21]int8 + FstrESHUTDOWN [34]int8 + FstrEALREADY [30]int8 + FstrEINPROGRESS [22]int8 + FstrESTALE [18]int8 + FstrEREMOTEIO [17]int8 + FstrEDQUOT [15]int8 + FstrENOMEDIUM [16]int8 + FstrEMEDIUMTYPE [18]int8 + FstrEMULTIHOP [19]int8 + FstrENOKEY [27]int8 + FstrEKEYEXPIRED [16]int8 + FstrEKEYREVOKED [21]int8 + FstrEKEYREJECTED [28]int8 +} + +/* mips has one error code outside of the 8-bit range due to a + * historical typo, so we just remap it. */ + +var _errmsgstr = Terrmsgstr_t{ + Fstr0: [21]int8{'N', 'o', ' ', 'e', 'r', 'r', 'o', 'r', ' ', 'i', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n'}, + FstrEILSEQ: [22]int8{'I', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'b', 'y', 't', 'e', ' ', 's', 'e', 'q', 'u', 'e', 'n', 'c', 'e'}, + FstrEDOM: [13]int8{'D', 'o', 'm', 'a', 'i', 'n', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrERANGE: [25]int8{'R', 'e', 's', 'u', 'l', 't', ' ', 'n', 'o', 't', ' ', 'r', 'e', 'p', 'r', 'e', 's', 'e', 'n', 't', 'a', 'b', 'l', 'e'}, + FstrENOTTY: [10]int8{'N', 'o', 't', ' ', 'a', ' ', 't', 't', 'y'}, + FstrEACCES: [18]int8{'P', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n', ' ', 'd', 'e', 'n', 'i', 'e', 'd'}, + FstrEPERM: [24]int8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'n', 'o', 't', ' ', 'p', 'e', 'r', 'm', 'i', 't', 't', 'e', 'd'}, + FstrENOENT: [26]int8{'N', 'o', ' ', 's', 'u', 'c', 'h', ' ', 'f', 'i', 'l', 'e', ' ', 'o', 'r', ' ', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y'}, + FstrESRCH: [16]int8{'N', 'o', ' ', 's', 'u', 'c', 'h', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's'}, + FstrEEXIST: [12]int8{'F', 'i', 'l', 'e', ' ', 'e', 'x', 'i', 's', 't', 's'}, + FstrEOVERFLOW: [30]int8{'V', 'a', 'l', 'u', 'e', ' ', 't', 'o', 'o', ' ', 'l', 'a', 'r', 'g', 'e', ' ', 'f', 'o', 'r', ' ', 'd', 'a', 't', 'a', ' ', 't', 'y', 'p', 'e'}, + FstrENOSPC: [24]int8{'N', 'o', ' ', 's', 'p', 'a', 'c', 'e', ' ', 'l', 'e', 'f', 't', ' ', 'o', 'n', ' ', 'd', 'e', 'v', 'i', 'c', 'e'}, + FstrENOMEM: [14]int8{'O', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y'}, + FstrEBUSY: [14]int8{'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', ' ', 'b', 'u', 's', 'y'}, + FstrEINTR: [24]int8{'I', 'n', 't', 'e', 'r', 'r', 'u', 'p', 't', 'e', 'd', ' ', 's', 'y', 's', 't', 'e', 'm', ' ', 'c', 'a', 'l', 'l'}, + FstrEAGAIN: [33]int8{'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', ' ', 't', 'e', 'm', 'p', 'o', 'r', 'a', 'r', 'i', 'l', 'y', ' ', 'u', 'n', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrESPIPE: [13]int8{'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 's', 'e', 'e', 'k'}, + FstrEXDEV: [18]int8{'C', 'r', 'o', 's', 's', '-', 'd', 'e', 'v', 'i', 'c', 'e', ' ', 'l', 'i', 'n', 'k'}, + FstrEROFS: [22]int8{'R', 'e', 'a', 'd', '-', 'o', 'n', 'l', 'y', ' ', 'f', 'i', 'l', 'e', ' ', 's', 'y', 's', 't', 'e', 'm'}, + FstrENOTEMPTY: [20]int8{'D', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', ' ', 'n', 'o', 't', ' ', 'e', 'm', 'p', 't', 'y'}, + FstrECONNRESET: [25]int8{'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'r', 'e', 's', 'e', 't', ' ', 'b', 'y', ' ', 'p', 'e', 'e', 'r'}, + FstrETIMEDOUT: [20]int8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 't', 'i', 'm', 'e', 'd', ' ', 'o', 'u', 't'}, + FstrECONNREFUSED: [19]int8{'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'r', 'e', 'f', 'u', 's', 'e', 'd'}, + FstrEHOSTDOWN: [13]int8{'H', 'o', 's', 't', ' ', 'i', 's', ' ', 'd', 'o', 'w', 'n'}, + FstrEHOSTUNREACH: [20]int8{'H', 'o', 's', 't', ' ', 'i', 's', ' ', 'u', 'n', 'r', 'e', 'a', 'c', 'h', 'a', 'b', 'l', 'e'}, + FstrEADDRINUSE: [15]int8{'A', 'd', 'd', 'r', 'e', 's', 's', ' ', 'i', 'n', ' ', 'u', 's', 'e'}, + FstrEPIPE: [12]int8{'B', 'r', 'o', 'k', 'e', 'n', ' ', 'p', 'i', 'p', 'e'}, + FstrEIO: [10]int8{'I', '/', 'O', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrENXIO: [26]int8{'N', 'o', ' ', 's', 'u', 'c', 'h', ' ', 'd', 'e', 'v', 'i', 'c', 'e', ' ', 'o', 'r', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's'}, + FstrENOTBLK: [22]int8{'B', 'l', 'o', 'c', 'k', ' ', 'd', 'e', 'v', 'i', 'c', 'e', ' ', 'r', 'e', 'q', 'u', 'i', 'r', 'e', 'd'}, + FstrENODEV: [15]int8{'N', 'o', ' ', 's', 'u', 'c', 'h', ' ', 'd', 'e', 'v', 'i', 'c', 'e'}, + FstrENOTDIR: [16]int8{'N', 'o', 't', ' ', 'a', ' ', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y'}, + FstrEISDIR: [15]int8{'I', 's', ' ', 'a', ' ', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y'}, + FstrETXTBSY: [15]int8{'T', 'e', 'x', 't', ' ', 'f', 'i', 'l', 'e', ' ', 'b', 'u', 's', 'y'}, + FstrENOEXEC: [18]int8{'E', 'x', 'e', 'c', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrEINVAL: [17]int8{'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'a', 'r', 'g', 'u', 'm', 'e', 'n', 't'}, + FstrE2BIG: [23]int8{'A', 'r', 'g', 'u', 'm', 'e', 'n', 't', ' ', 'l', 'i', 's', 't', ' ', 't', 'o', 'o', ' ', 'l', 'o', 'n', 'g'}, + FstrELOOP: [19]int8{'S', 'y', 'm', 'b', 'o', 'l', 'i', 'c', ' ', 'l', 'i', 'n', 'k', ' ', 'l', 'o', 'o', 'p'}, + FstrENAMETOOLONG: [18]int8{'F', 'i', 'l', 'e', 'n', 'a', 'm', 'e', ' ', 't', 'o', 'o', ' ', 'l', 'o', 'n', 'g'}, + FstrENFILE: [30]int8{'T', 'o', 'o', ' ', 'm', 'a', 'n', 'y', ' ', 'o', 'p', 'e', 'n', ' ', 'f', 'i', 'l', 'e', 's', ' ', 'i', 'n', ' ', 's', 'y', 's', 't', 'e', 'm'}, + FstrEMFILE: [30]int8{'N', 'o', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 's', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEBADF: [20]int8{'B', 'a', 'd', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r'}, + FstrECHILD: [17]int8{'N', 'o', ' ', 'c', 'h', 'i', 'l', 'd', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's'}, + FstrEFAULT: [12]int8{'B', 'a', 'd', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's'}, + FstrEFBIG: [15]int8{'F', 'i', 'l', 'e', ' ', 't', 'o', 'o', ' ', 'l', 'a', 'r', 'g', 'e'}, + FstrEMLINK: [15]int8{'T', 'o', 'o', ' ', 'm', 'a', 'n', 'y', ' ', 'l', 'i', 'n', 'k', 's'}, + FstrENOLCK: [19]int8{'N', 'o', ' ', 'l', 'o', 'c', 'k', 's', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEDEADLK: [30]int8{'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', ' ', 'd', 'e', 'a', 'd', 'l', 'o', 'c', 'k', ' ', 'w', 'o', 'u', 'l', 'd', ' ', 'o', 'c', 'c', 'u', 'r'}, + FstrENOTRECOVERABLE: [22]int8{'S', 't', 'a', 't', 'e', ' ', 'n', 'o', 't', ' ', 'r', 'e', 'c', 'o', 'v', 'e', 'r', 'a', 'b', 'l', 'e'}, + FstrEOWNERDEAD: [20]int8{'P', 'r', 'e', 'v', 'i', 'o', 'u', 's', ' ', 'o', 'w', 'n', 'e', 'r', ' ', 'd', 'i', 'e', 'd'}, + FstrECANCELED: [19]int8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'c', 'a', 'n', 'c', 'e', 'l', 'e', 'd'}, + FstrENOSYS: [25]int8{'F', 'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', 'n', 'o', 't', ' ', 'i', 'm', 'p', 'l', 'e', 'm', 'e', 'n', 't', 'e', 'd'}, + FstrENOMSG: [27]int8{'N', 'o', ' ', 'm', 'e', 's', 's', 'a', 'g', 'e', ' ', 'o', 'f', ' ', 'd', 'e', 's', 'i', 'r', 'e', 'd', ' ', 't', 'y', 'p', 'e'}, + FstrEIDRM: [19]int8{'I', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', ' ', 'r', 'e', 'm', 'o', 'v', 'e', 'd'}, + FstrENOSTR: [20]int8{'D', 'e', 'v', 'i', 'c', 'e', ' ', 'n', 'o', 't', ' ', 'a', ' ', 's', 't', 'r', 'e', 'a', 'm'}, + FstrENODATA: [18]int8{'N', 'o', ' ', 'd', 'a', 't', 'a', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrETIME: [15]int8{'D', 'e', 'v', 'i', 'c', 'e', ' ', 't', 'i', 'm', 'e', 'o', 'u', 't'}, + FstrENOSR: [25]int8{'O', 'u', 't', ' ', 'o', 'f', ' ', 's', 't', 'r', 'e', 'a', 'm', 's', ' ', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', 's'}, + FstrENOLINK: [22]int8{'L', 'i', 'n', 'k', ' ', 'h', 'a', 's', ' ', 'b', 'e', 'e', 'n', ' ', 's', 'e', 'v', 'e', 'r', 'e', 'd'}, + FstrEPROTO: [15]int8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrEBADMSG: [12]int8{'B', 'a', 'd', ' ', 'm', 'e', 's', 's', 'a', 'g', 'e'}, + FstrEBADFD: [29]int8{'F', 'i', 'l', 'e', ' ', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', ' ', 'i', 'n', ' ', 'b', 'a', 'd', ' ', 's', 't', 'a', 't', 'e'}, + FstrENOTSOCK: [13]int8{'N', 'o', 't', ' ', 'a', ' ', 's', 'o', 'c', 'k', 'e', 't'}, + FstrEDESTADDRREQ: [29]int8{'D', 'e', 's', 't', 'i', 'n', 'a', 't', 'i', 'o', 'n', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's', ' ', 'r', 'e', 'q', 'u', 'i', 'r', 'e', 'd'}, + FstrEMSGSIZE: [18]int8{'M', 'e', 's', 's', 'a', 'g', 'e', ' ', 't', 'o', 'o', ' ', 'l', 'a', 'r', 'g', 'e'}, + FstrEPROTOTYPE: [31]int8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'w', 'r', 'o', 'n', 'g', ' ', 't', 'y', 'p', 'e', ' ', 'f', 'o', 'r', ' ', 's', 'o', 'c', 'k', 'e', 't'}, + FstrENOPROTOOPT: [23]int8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'n', 'o', 't', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEPROTONOSUPPORT: [23]int8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd'}, + FstrESOCKTNOSUPPORT: [26]int8{'S', 'o', 'c', 'k', 'e', 't', ' ', 't', 'y', 'p', 'e', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd'}, + FstrENOTSUP: [14]int8{'N', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd'}, + FstrEPFNOSUPPORT: [30]int8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'f', 'a', 'm', 'i', 'l', 'y', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd'}, + FstrEAFNOSUPPORT: [41]int8{'A', 'd', 'd', 'r', 'e', 's', 's', ' ', 'f', 'a', 'm', 'i', 'l', 'y', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd', ' ', 'b', 'y', ' ', 'p', 'r', 'o', 't', 'o', 'c', 'o', 'l'}, + FstrEADDRNOTAVAIL: [22]int8{'A', 'd', 'd', 'r', 'e', 's', 's', ' ', 'n', 'o', 't', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrENETDOWN: [16]int8{'N', 'e', 't', 'w', 'o', 'r', 'k', ' ', 'i', 's', ' ', 'd', 'o', 'w', 'n'}, + FstrENETUNREACH: [20]int8{'N', 'e', 't', 'w', 'o', 'r', 'k', ' ', 'u', 'n', 'r', 'e', 'a', 'c', 'h', 'a', 'b', 'l', 'e'}, + FstrENETRESET: [28]int8{'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'r', 'e', 's', 'e', 't', ' ', 'b', 'y', ' ', 'n', 'e', 't', 'w', 'o', 'r', 'k'}, + FstrECONNABORTED: [19]int8{'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'a', 'b', 'o', 'r', 't', 'e', 'd'}, + FstrENOBUFS: [26]int8{'N', 'o', ' ', 'b', 'u', 'f', 'f', 'e', 'r', ' ', 's', 'p', 'a', 'c', 'e', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEISCONN: [20]int8{'S', 'o', 'c', 'k', 'e', 't', ' ', 'i', 's', ' ', 'c', 'o', 'n', 'n', 'e', 'c', 't', 'e', 'd'}, + FstrENOTCONN: [21]int8{'S', 'o', 'c', 'k', 'e', 't', ' ', 'n', 'o', 't', ' ', 'c', 'o', 'n', 'n', 'e', 'c', 't', 'e', 'd'}, + FstrESHUTDOWN: [34]int8{'C', 'a', 'n', 'n', 'o', 't', ' ', 's', 'e', 'n', 'd', ' ', 'a', 'f', 't', 'e', 'r', ' ', 's', 'o', 'c', 'k', 'e', 't', ' ', 's', 'h', 'u', 't', 'd', 'o', 'w', 'n'}, + FstrEALREADY: [30]int8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'a', 'l', 'r', 'e', 'a', 'd', 'y', ' ', 'i', 'n', ' ', 'p', 'r', 'o', 'g', 'r', 'e', 's', 's'}, + FstrEINPROGRESS: [22]int8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'i', 'n', ' ', 'p', 'r', 'o', 'g', 'r', 'e', 's', 's'}, + FstrESTALE: [18]int8{'S', 't', 'a', 'l', 'e', ' ', 'f', 'i', 'l', 'e', ' ', 'h', 'a', 'n', 'd', 'l', 'e'}, + FstrEREMOTEIO: [17]int8{'R', 'e', 'm', 'o', 't', 'e', ' ', 'I', '/', 'O', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrEDQUOT: [15]int8{'Q', 'u', 'o', 't', 'a', ' ', 'e', 'x', 'c', 'e', 'e', 'd', 'e', 'd'}, + FstrENOMEDIUM: [16]int8{'N', 'o', ' ', 'm', 'e', 'd', 'i', 'u', 'm', ' ', 'f', 'o', 'u', 'n', 'd'}, + FstrEMEDIUMTYPE: [18]int8{'W', 'r', 'o', 'n', 'g', ' ', 'm', 'e', 'd', 'i', 'u', 'm', ' ', 't', 'y', 'p', 'e'}, + FstrEMULTIHOP: [19]int8{'M', 'u', 'l', 't', 'i', 'h', 'o', 'p', ' ', 'a', 't', 't', 'e', 'm', 'p', 't', 'e', 'd'}, + FstrENOKEY: [27]int8{'R', 'e', 'q', 'u', 'i', 'r', 'e', 'd', ' ', 'k', 'e', 'y', ' ', 'n', 'o', 't', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEKEYEXPIRED: [16]int8{'K', 'e', 'y', ' ', 'h', 'a', 's', ' ', 'e', 'x', 'p', 'i', 'r', 'e', 'd'}, + FstrEKEYREVOKED: [21]int8{'K', 'e', 'y', ' ', 'h', 'a', 's', ' ', 'b', 'e', 'e', 'n', ' ', 'r', 'e', 'v', 'o', 'k', 'e', 'd'}, + FstrEKEYREJECTED: [28]int8{'K', 'e', 'y', ' ', 'w', 'a', 's', ' ', 'r', 'e', 'j', 'e', 'c', 't', 'e', 'd', ' ', 'b', 'y', ' ', 's', 'e', 'r', 'v', 'i', 'c', 'e'}, +} + +var _errmsgidx = [132]uint16{ + 1: uint16(uint64(UintptrFromInt32(0) + 109)), + 2: uint16(uint64(UintptrFromInt32(0) + 133)), + 3: uint16(uint64(UintptrFromInt32(0) + 159)), + 4: uint16(uint64(UintptrFromInt32(0) + 269)), + 5: uint16(uint64(UintptrFromInt32(0) + 523)), + 6: uint16(uint64(UintptrFromInt32(0) + 533)), + 7: uint16(uint64(UintptrFromInt32(0) + 677)), + 8: uint16(uint64(UintptrFromInt32(0) + 642)), + 9: uint16(uint64(UintptrFromInt32(0) + 797)), + 10: uint16(uint64(UintptrFromInt32(0) + 817)), + 11: uint16(uint64(UintptrFromInt32(0) + 293)), + 12: uint16(uint64(UintptrFromInt32(0) + 241)), + 13: uint16(uint64(UintptrFromInt32(0) + 91)), + 14: uint16(uint64(UintptrFromInt32(0) + 834)), + 15: uint16(uint64(UintptrFromInt32(0) + 559)), + 16: uint16(uint64(UintptrFromInt32(0) + 255)), + 17: uint16(uint64(UintptrFromInt32(0) + 175)), + 18: uint16(uint64(UintptrFromInt32(0) + 339)), + 19: uint16(uint64(UintptrFromInt32(0) + 581)), + 20: uint16(uint64(UintptrFromInt32(0) + 596)), + 21: uint16(uint64(UintptrFromInt32(0) + 612)), + 22: uint16(uint64(UintptrFromInt32(0) + 660)), + 23: uint16(uint64(UintptrFromInt32(0) + 737)), + 24: uint16(uint64(UintptrFromInt32(0) + 767)), + 25: uint16(uint64(UintptrFromInt32(0) + 81)), + 26: uint16(uint64(UintptrFromInt32(0) + 627)), + 27: uint16(uint64(UintptrFromInt32(0) + 846)), + 28: uint16(uint64(UintptrFromInt32(0) + 217)), + 29: uint16(uint64(UintptrFromInt32(0) + 326)), + 30: uint16(uint64(UintptrFromInt32(0) + 357)), + 31: uint16(uint64(UintptrFromInt32(0) + 861)), + 32: uint16(uint64(UintptrFromInt32(0) + 511)), + 33: uint16(uint64(UintptrFromInt32(0) + 43)), + 34: uint16(uint64(UintptrFromInt32(0) + 56)), + 35: uint16(uint64(UintptrFromInt32(0) + 895)), + 36: uint16(uint64(UintptrFromInt32(0) + 719)), + 37: uint16(uint64(UintptrFromInt32(0) + 876)), + 38: uint16(uint64(UintptrFromInt32(0) + 986)), + 39: uint16(uint64(UintptrFromInt32(0) + 379)), + 40: uint16(uint64(UintptrFromInt32(0) + 700)), + 42: uint16(uint64(UintptrFromInt32(0) + 1011)), + 43: uint16(uint64(UintptrFromInt32(0) + 1038)), + 60: uint16(uint64(UintptrFromInt32(0) + 1057)), + 61: uint16(uint64(UintptrFromInt32(0) + 1077)), + 62: uint16(uint64(UintptrFromInt32(0) + 1095)), + 63: uint16(uint64(UintptrFromInt32(0) + 1110)), + 67: uint16(uint64(UintptrFromInt32(0) + 1135)), + 71: uint16(uint64(UintptrFromInt32(0) + 1157)), + 72: uint16(uint64(UintptrFromInt32(0) + 1803)), + 74: uint16(uint64(UintptrFromInt32(0) + 1172)), + 75: uint16(uint64(UintptrFromInt32(0) + 187)), + 77: uint16(uint64(UintptrFromInt32(0) + 1184)), + 84: uint16(uint64(UintptrFromInt32(0) + 21)), + 88: uint16(uint64(UintptrFromInt32(0) + 1213)), + 89: uint16(uint64(UintptrFromInt32(0) + 1226)), + 90: uint16(uint64(UintptrFromInt32(0) + 1255)), + 91: uint16(uint64(UintptrFromInt32(0) + 1273)), + 92: uint16(uint64(UintptrFromInt32(0) + 1304)), + 93: uint16(uint64(UintptrFromInt32(0) + 1327)), + 94: uint16(uint64(UintptrFromInt32(0) + 1350)), + 95: uint16(uint64(UintptrFromInt32(0) + 1376)), + 96: uint16(uint64(UintptrFromInt32(0) + 1390)), + 97: uint16(uint64(UintptrFromInt32(0) + 1420)), + 98: uint16(uint64(UintptrFromInt32(0) + 496)), + 99: uint16(uint64(UintptrFromInt32(0) + 1461)), + 100: uint16(uint64(UintptrFromInt32(0) + 1483)), + 101: uint16(uint64(UintptrFromInt32(0) + 1499)), + 102: uint16(uint64(UintptrFromInt32(0) + 1519)), + 103: uint16(uint64(UintptrFromInt32(0) + 1547)), + 104: uint16(uint64(UintptrFromInt32(0) + 399)), + 105: uint16(uint64(UintptrFromInt32(0) + 1566)), + 106: uint16(uint64(UintptrFromInt32(0) + 1592)), + 107: uint16(uint64(UintptrFromInt32(0) + 1612)), + 108: uint16(uint64(UintptrFromInt32(0) + 1633)), + 110: uint16(uint64(UintptrFromInt32(0) + 424)), + 111: uint16(uint64(UintptrFromInt32(0) + 444)), + 112: uint16(uint64(UintptrFromInt32(0) + 463)), + 113: uint16(uint64(UintptrFromInt32(0) + 476)), + 114: uint16(uint64(UintptrFromInt32(0) + 1667)), + 115: uint16(uint64(UintptrFromInt32(0) + 1697)), + 116: uint16(uint64(UintptrFromInt32(0) + 1719)), + 121: uint16(uint64(UintptrFromInt32(0) + 1737)), + 122: uint16(uint64(UintptrFromInt32(0) + 1754)), + 123: uint16(uint64(UintptrFromInt32(0) + 1769)), + 124: uint16(uint64(UintptrFromInt32(0) + 1785)), + 125: uint16(uint64(UintptrFromInt32(0) + 967)), + 126: uint16(uint64(UintptrFromInt32(0) + 1822)), + 127: uint16(uint64(UintptrFromInt32(0) + 1849)), + 128: uint16(uint64(UintptrFromInt32(0) + 1865)), + 129: uint16(uint64(UintptrFromInt32(0) + 1886)), + 130: uint16(uint64(UintptrFromInt32(0) + 947)), + 131: uint16(uint64(UintptrFromInt32(0) + 925)), +} + +func X__strerror_l(tls *TLS, e int32, loc Tlocale_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v e=%v loc=%v, (%v:)", tls, e, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + _ = s + if Uint64FromInt32(e) >= Uint64FromInt64(264)/Uint64FromInt64(2) { + e = 0 + } + s = uintptr(unsafe.Pointer(&_errmsgstr)) + uintptr(_errmsgidx[e]) + return X__lctrans(tls, s, **(**uintptr)(__ccgo_up(loc + 5*8))) +} + +func Xstrerror(tls *TLS, e int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v e=%v, (%v:)", tls, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strerror_l(tls, e, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xstrerror_l(tls *TLS, e int32, loc Tlocale_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v e=%v loc=%v, (%v:)", tls, e, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strerror_l(tls, e, loc) +} + +func X_Exit(tls *TLS, ec int32) { + if __ccgo_strace { + trc("tls=%v ec=%v, (%v:)", tls, ec, origin(2)) + } + X__syscall1(tls, int64(SYS_exit_group), int64(ec)) + for { + X__syscall1(tls, int64(SYS_exit), int64(ec)) + goto _1 + _1: + } +} + +func X__assert_fail(tls *TLS, expr uintptr, file uintptr, line int32, func1 uintptr) { + if __ccgo_strace { + trc("tls=%v expr=%v file=%v line=%v func1=%v, (%v:)", tls, expr, file, line, func1, origin(2)) + } + bp := tls.Alloc(48) + defer tls.Free(48) + Xfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), __ccgo_ts+278, VaList(bp+8, expr, file, func1, line)) + Xabort(tls) +} + +const COUNT = 32 + +var _funcs [32]uintptr +var _count int32 +var _lock [1]int32 + +func X__funcs_on_quick_exit(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + var func1 uintptr + var v1 int32 + _, _ = func1, v1 + ___lock(tls, uintptr(unsafe.Pointer(&_lock))) + for _count > 0 { + _count = _count - 1 + v1 = _count + func1 = _funcs[v1] + ___unlock(tls, uintptr(unsafe.Pointer(&_lock))) + (*(*func(*TLS))(unsafe.Pointer(&struct{ uintptr }{func1})))(tls) + ___lock(tls, uintptr(unsafe.Pointer(&_lock))) + } +} + +type t__ccgo_fp__Xat_quick_exit_0 = func(*TLS) + +func Xat_quick_exit(tls *TLS, __ccgo_fp_func uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v __ccgo_fp_func=%v, (%v:)", tls, __ccgo_fp_func, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v1 int32 + _, _ = r, v1 + r = 0 + ___lock(tls, uintptr(unsafe.Pointer(&_lock))) + if _count == int32(32) { + r = -int32(1) + } else { + v1 = _count + _count = _count + 1 + _funcs[v1] = __ccgo_fp_func + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock))) + return r +} + +func _dummy3(tls *TLS) { +} + +func Xquick_exit(tls *TLS, code int32) { + if __ccgo_strace { + trc("tls=%v code=%v, (%v:)", tls, code, origin(2)) + } + X__funcs_on_quick_exit(tls) + X_Exit(tls, code) +} + +func Xcreat(tls *TLS, filename uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v mode=%v, (%v:)", tls, filename, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + return Xopen(tls, filename, Int32FromInt32(O_CREAT)|Int32FromInt32(O_WRONLY)|Int32FromInt32(O_TRUNC), VaList(bp+8, mode)) +} + +func Xfcntl(tls *TLS, fd int32, cmd int32, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v cmd=%v va=%v, (%v:)", tls, fd, cmd, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ap Tva_list + var arg uint64 + var ret, ret1, v1 int32 + var _ /* ex at bp+0 */ Tf_owner_ex + _, _, _, _, _ = ap, arg, ret, ret1, v1 + ap = va + arg = VaUint64(&ap) + _ = ap + if cmd == int32(F_SETFL) { + arg = arg | uint64(O_LARGEFILE) + } + if cmd == int32(F_SETLKW) { + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_fcntl), int64(fd), int64(cmd), int64(uintptr(arg)), 0, 0, 0)))) + } + if cmd == int32(F_GETOWN) { + ret = int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETOWN_EX)), int64(bp))) + if ret == -int32(EINVAL) { + return int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(cmd), int64(uintptr(arg)))) + } + if ret != 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + if (**(**Tf_owner_ex)(__ccgo_up(bp))).Ftype1 == int32(F_OWNER_PGRP) { + v1 = -(**(**Tf_owner_ex)(__ccgo_up(bp))).Fpid + } else { + v1 = (**(**Tf_owner_ex)(__ccgo_up(bp))).Fpid + } + return v1 + } + if cmd == int32(F_DUPFD_CLOEXEC) { + ret1 = int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_DUPFD_CLOEXEC)), Int64FromUint64(arg))) + if ret1 != -int32(EINVAL) { + if ret1 >= 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret1), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(ret1))) + } + ret1 = int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_DUPFD_CLOEXEC)), int64(Int32FromInt32(0)))) + if ret1 != -int32(EINVAL) { + if ret1 >= 0 { + X__syscall1(tls, int64(SYS_close), int64(ret1)) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + ret1 = int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_DUPFD)), Int64FromUint64(arg))) + if ret1 >= 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret1), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(ret1))) + } + switch cmd { + case int32(F_SETLK): + fallthrough + case int32(F_GETLK): + fallthrough + case int32(F_GETOWN_EX): + fallthrough + case int32(F_SETOWN_EX): + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(cmd), int64(uintptr(arg)))))) + default: + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(cmd), Int64FromUint64(arg))))) + } + return r +} + +func Xopen(tls *TLS, filename uintptr, flags int32, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v flags=%v va=%v, (%v:)", tls, filename, flags, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var fd int32 + var mode Tmode_t + _, _, _ = ap, fd, mode + mode = uint32(0) + if flags&int32(O_CREAT) != 0 || flags&int32(O_TMPFILE) == int32(O_TMPFILE) { + ap = va + mode = VaUint32(&ap) + _ = ap + } + fd = int32(___syscall_cp(tls, int64(SYS_open), int64(filename), int64(flags|Int32FromInt32(O_LARGEFILE)), Int64FromUint32(mode), 0, 0, 0)) + if fd >= 0 && flags&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(fd))) +} + +func Xopenat(tls *TLS, fd int32, filename uintptr, flags int32, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v filename=%v flags=%v va=%v, (%v:)", tls, fd, filename, flags, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var mode Tmode_t + _, _ = ap, mode + mode = uint32(0) + if flags&int32(O_CREAT) != 0 || flags&int32(O_TMPFILE) == int32(O_TMPFILE) { + ap = va + mode = VaUint32(&ap) + _ = ap + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_openat), int64(fd), int64(filename), int64(flags|Int32FromInt32(O_LARGEFILE)), Int64FromUint32(mode), 0, 0)))) +} + +func Xposix_fadvise(tls *TLS, fd int32, base Toff_t, len1 Toff_t, advice int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v base=%v len1=%v advice=%v, (%v:)", tls, fd, base, len1, advice, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(-X__syscall4(tls, int64(SYS_fadvise64), int64(fd), base, len1, int64(advice))) +} + +func Xposix_fallocate(tls *TLS, fd int32, base Toff_t, len1 Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v base=%v len1=%v, (%v:)", tls, fd, base, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(-X__syscall4(tls, int64(SYS_fallocate), int64(fd), int64(Int32FromInt32(0)), base, len1)) +} + +const FE_ALL_EXCEPT = 63 +const FE_DIVBYZERO = 4 +const FE_DOWNWARD = 1024 +const FE_INEXACT = 32 +const FE_INVALID = 1 +const FE_OVERFLOW = 8 +const FE_TONEAREST = 0 +const FE_TOWARDZERO = 3072 +const FE_UNDERFLOW = 16 +const FE_UPWARD = 2048 +const __FE_DENORM = 2 + +type Tfexcept_t = uint16 + +type Tfenv_t = struct { + F__control_word uint16 + F__unused1 uint16 + F__status_word uint16 + F__unused2 uint16 + F__tags uint16 + F__unused3 uint16 + F__eip uint32 + F__cs_selector uint16 + F__ccgo_align8 [2]byte + F__ccgo20 uint16 + F__data_offset uint32 + F__data_selector uint16 + F__unused5 uint16 + F__mxcsr uint32 +} + +/* Dummy functions for archs lacking fenv implementation */ + +func Xfeclearexcept(tls *TLS, mask int32) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v, (%v:)", tls, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xferaiseexcept(tls *TLS, mask int32) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v, (%v:)", tls, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xfetestexcept(tls *TLS, mask int32) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v, (%v:)", tls, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xfegetround(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return FE_TONEAREST +} + +func X__fesetround(tls *TLS, r int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v r=%v, (%v:)", tls, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return 0 +} + +func Xfegetenv(tls *TLS, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v envp=%v, (%v:)", tls, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xfesetenv(tls *TLS, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v envp=%v, (%v:)", tls, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +const WCONTINUED = 8 +const WEXITED = 4 +const WNOWAIT = 16777216 +const WSTOPPED = 2 +const __WALL = 1073741824 +const __WCLONE = 2147483648 +const __WNOTHREAD = 536870912 + +type Tidtype_t = int32 + +const _P_ALL = 0 +const _P_PID = 1 +const _P_PGID = 2 +const _P_PIDFD = 3 +const F_APP = 128 +const F_EOF = 16 +const F_ERR = 32 +const F_NORD = 4 +const F_NOWR = 8 +const F_PERM = 1 +const F_SVB = 64 +const KMAX = 128 +const LDBL_EPSILON1 = 2.22044604925031308085e-16 +const LDBL_MAX1 = 1.79769313486231570815e+308 +const LDBL_MIN1 = 2.22507385850720138309e-308 +const LD_B1B_DIG = 2 +const LD_B1B_MAX = 254740991 +const MASK = 127 +const MAYBE_WAITERS = 1073741824 +const UNGET = 8 + +type TFILE = struct { + Fflags uint32 + Frpos uintptr + Frend uintptr + Fclose1 uintptr + Fwend uintptr + Fwpos uintptr + Fmustbezero_1 uintptr + Fwbase uintptr + Fread uintptr + Fwrite uintptr + Fseek uintptr + Fbuf uintptr + Fbuf_size Tsize_t + Fprev uintptr + Fnext uintptr + Ffd int32 + Fpipe_pid int32 + Flockcount int64 + Fmode int32 + Flock int32 + Flbf int32 + Fcookie uintptr + Foff Toff_t + Fgetln_buf uintptr + Fmustbezero_2 uintptr + Fshend uintptr + Fshlim Toff_t + Fshcnt Toff_t + Fprev_locked uintptr + Fnext_locked uintptr + Flocale uintptr +} + +type T_IO_FILE = TFILE + +func _scanexp(tls *TLS, f uintptr, pok int32) (r int64) { + var c, neg, x, v1 int32 + var y, v19 int64 + var v2, v3 uintptr + _, _, _, _, _, _, _, _ = c, neg, x, y, v1, v19, v2, v3 + neg = 0 + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if c == int32('+') || c == int32('-') { + neg = BoolInt32(c == int32('-')) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if Uint32FromInt32(c-int32('0')) >= uint32(10) && pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + } + if Uint32FromInt32(c-int32('0')) >= uint32(10) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + return -Int64FromInt64(0x7fffffffffffffff) - Int64FromInt32(1) + } + x = 0 + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) && x < Int32FromInt32(INT_MAX)/Int32FromInt32(10)) { + break + } + x = int32(10)*x + c - int32('0') + goto _7 + _7: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + y = int64(x) + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) && y < Int64FromInt64(0x7fffffffffffffff)/Int64FromInt32(100)) { + break + } + y = int64(10)*y + int64(c) - int64('0') + goto _11 + _11: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10)) { + break + } + goto _15 + _15: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if neg != 0 { + v19 = -y + } else { + v19 = y + } + return v19 +} + +func _decfloat(tls *TLS, f uintptr, c int32, bits int32, emin int32, sign int32, pok int32) (r float64) { + bp := tls.Alloc(512) + defer tls.Free(512) + var a, bitlim, denormal, e2, emax, gotdig, gotrad, i, j, k, lnz, p10, rp, rpm9, sh, z, v2, v6 int32 + var bias, frac, y float64 + var carry, carry1, carry2, t, tmp, tmp2 Tuint32_t + var dc, e10, lrp int64 + var tmp1 Tuint64_t + var v3, v4 uintptr + var _ /* x at bp+0 */ [128]Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, bias, bitlim, carry, carry1, carry2, dc, denormal, e10, e2, emax, frac, gotdig, gotrad, i, j, k, lnz, lrp, p10, rp, rpm9, sh, t, tmp, tmp1, tmp2, y, z, v2, v3, v4, v6 + lrp = 0 + dc = 0 + e10 = 0 + lnz = 0 + gotdig = 0 + gotrad = 0 + emax = -emin - bits + int32(3) + denormal = 0 + frac = Float64FromInt32(0) + bias = Float64FromInt32(0) + j = 0 + k = 0 + /* Don't let leading zeros consume buffer space */ + for { + if !(c == int32('0')) { + break + } + gotdig = int32(1) + goto _1 + _1: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + c = v2 + } + if c == int32('.') { + gotrad = int32(1) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + c = v2 + for { + if !(c == int32('0')) { + break + } + gotdig = int32(1) + lrp = lrp - 1 + goto _5 + _5: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + c = v2 + } + } + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[0] = uint32(0) + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) || c == int32('.')) { + break + } + if c == int32('.') { + if gotrad != 0 { + break + } + gotrad = int32(1) + lrp = dc + } else { + if k < Int32FromInt32(KMAX)-Int32FromInt32(3) { + dc = dc + 1 + if c != int32('0') { + lnz = int32(dc) + } + if j != 0 { + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k]*uint32(10) + Uint32FromInt32(c) - uint32('0') + } else { + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = Uint32FromInt32(c - int32('0')) + } + j = j + 1 + v2 = j + if v2 == int32(9) { + k = k + 1 + j = 0 + } + gotdig = int32(1) + } else { + dc = dc + 1 + if c != int32('0') { + lnz = (Int32FromInt32(KMAX) - Int32FromInt32(4)) * Int32FromInt32(9) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(Int32FromInt32(KMAX)-Int32FromInt32(4))*4)) |= uint32(1) + } + } + } + goto _12 + _12: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + c = v2 + } + if !(gotrad != 0) { + lrp = dc + } + if gotdig != 0 && c|int32(32) == int32('e') { + e10 = _scanexp(tls, f, pok) + if e10 == -Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1) { + if pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } else { + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + e10 = 0 + } + lrp = lrp + e10 + } else { + if c >= 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + } + if !(gotdig != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + /* Handle zero specially to avoid nasty special cases later */ + if !((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0] != 0) { + return float64(float64(sign) * float64(0)) + } + /* Optimize small integers (w/no exponent) and over/under-flow */ + if lrp == dc && dc < int64(10) && (bits > int32(30) || (**(**[128]Tuint32_t)(__ccgo_up(bp)))[0]>>bits == uint32(0)) { + return float64(float64(sign) * float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0])) + } + if lrp > int64(-emin/int32(2)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return float64(float64(float64(sign)*Float64FromFloat64(1.79769313486231570815e+308)) * Float64FromFloat64(1.79769313486231570815e+308)) + } + if lrp < int64(emin-Int32FromInt32(2)*Int32FromInt32(LDBL_MANT_DIG)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return float64(float64(float64(sign)*Float64FromFloat64(2.22507385850720138309e-308)) * Float64FromFloat64(2.22507385850720138309e-308)) + } + /* Align incomplete final B1B digit */ + if j != 0 { + for { + if !(j < int32(9)) { + break + } + **(**Tuint32_t)(__ccgo_up(bp + uintptr(k)*4)) *= uint32(10) + goto _17 + _17: + ; + j = j + 1 + } + k = k + 1 + j = 0 + } + a = 0 + z = k + e2 = 0 + rp = int32(lrp) + /* Optimize small to mid-size integers (even in exp. notation) */ + if lnz < int32(9) && lnz <= rp && rp < int32(18) { + if rp == int32(9) { + return float64(float64(sign) * float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0])) + } + if rp < int32(9) { + return float64(float64(sign)*float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0])) / float64(_p10s[int32(8)-rp]) + } + bitlim = bits - int32(3)*(rp-Int32FromInt32(9)) + if bitlim > int32(30) || (**(**[128]Tuint32_t)(__ccgo_up(bp)))[0]>>bitlim == uint32(0) { + return float64(float64(float64(sign)*float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0])) * float64(_p10s[rp-int32(10)])) + } + } + /* Drop trailing zeros */ + for { + if !!((**(**[128]Tuint32_t)(__ccgo_up(bp)))[z-int32(1)] != 0) { + break + } + goto _18 + _18: + ; + z = z - 1 + } + /* Align radix point to B1B digit boundary */ + if rp%int32(9) != 0 { + if rp >= 0 { + v2 = rp % int32(9) + } else { + v2 = rp%int32(9) + int32(9) + } + rpm9 = v2 + p10 = _p10s[int32(8)-rpm9] + carry = uint32(0) + k = a + for { + if !(k != z) { + break + } + tmp = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] % Uint32FromInt32(p10) + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k]/Uint32FromInt32(p10) + carry + carry = Uint32FromInt32(int32(1000000000)/p10) * tmp + if k == a && !((**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] != 0) { + a = (a + int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + rp = rp - int32(9) + } + goto _20 + _20: + ; + k = k + 1 + } + if carry != 0 { + v2 = z + z = z + 1 + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[v2] = carry + } + rp = rp + (int32(9) - rpm9) + } + /* Upscale until desired number of bits are left of radix point */ + for rp < Int32FromInt32(9)*Int32FromInt32(LD_B1B_DIG) || rp == Int32FromInt32(9)*Int32FromInt32(LD_B1B_DIG) && (**(**[128]Tuint32_t)(__ccgo_up(bp)))[a] < _th[0] { + carry1 = uint32(0) + e2 = e2 - int32(29) + k = (z - int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + for { + tmp1 = uint64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[k])< uint64(1000000000) { + carry1 = uint32(tmp1 / uint64(1000000000)) + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = uint32(tmp1 % uint64(1000000000)) + } else { + carry1 = uint32(0) + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = uint32(tmp1) + } + if k == (z-int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)) && k != a && !((**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] != 0) { + z = k + } + if k == a { + break + } + goto _22 + _22: + ; + k = (k - int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + } + if carry1 != 0 { + rp = rp + int32(9) + a = (a - int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + if a == z { + z = (z - int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + **(**Tuint32_t)(__ccgo_up(bp + uintptr((z-int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)))*4)) |= (**(**[128]Tuint32_t)(__ccgo_up(bp)))[z] + } + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[a] = carry1 + } + } + /* Downscale until exactly number of bits are left of radix point */ + for { + carry2 = uint32(0) + sh = int32(1) + i = 0 + for { + if !(i < int32(LD_B1B_DIG)) { + break + } + k = (a + i) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + if k == z || (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] < _th[i] { + i = int32(LD_B1B_DIG) + break + } + if (**(**[128]Tuint32_t)(__ccgo_up(bp)))[(a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1))] > _th[i] { + break + } + goto _24 + _24: + ; + i = i + 1 + } + if i == int32(LD_B1B_DIG) && rp == Int32FromInt32(9)*Int32FromInt32(LD_B1B_DIG) { + break + } + /* FIXME: find a way to compute optimal sh */ + if rp > Int32FromInt32(9)+Int32FromInt32(9)*Int32FromInt32(LD_B1B_DIG) { + sh = int32(9) + } + e2 = e2 + sh + k = a + for { + if !(k != z) { + break + } + tmp2 = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] & Uint32FromInt32(int32(1)<>sh + carry2 + carry2 = Uint32FromInt32(Int32FromInt32(1000000000)>>sh) * tmp2 + if k == a && !((**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] != 0) { + a = (a + int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + i = i - 1 + rp = rp - int32(9) + } + goto _25 + _25: + ; + k = (k + int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + } + if carry2 != 0 { + if (z+int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)) != a { + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[z] = carry2 + z = (z + int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + } else { + **(**Tuint32_t)(__ccgo_up(bp + uintptr((z-int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)))*4)) |= uint32(1) + } + } + goto _23 + _23: + } + /* Assemble desired bits into floating point variable */ + v2 = Int32FromInt32(0) + i = v2 + y = float64(v2) + for { + if !(i < int32(LD_B1B_DIG)) { + break + } + if (a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1)) == z { + v6 = (z + Int32FromInt32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + z = v6 + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[v6-int32(1)] = uint32(0) + } + y = float64(Float64FromFloat64(1e+09)*y) + float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[(a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1))]) + goto _26 + _26: + ; + i = i + 1 + } + y = y * float64(sign) + /* Limit precision for denormal results */ + if bits > int32(LDBL_MANT_DIG)+e2-emin { + bits = int32(LDBL_MANT_DIG) + e2 - emin + if bits < 0 { + bits = 0 + } + denormal = int32(1) + } + /* Calculate bias term to force rounding, move out lower bits */ + if bits < int32(LDBL_MANT_DIG) { + bias = Xcopysignl(tls, Xscalbn(tls, Float64FromInt32(1), Int32FromInt32(2)*Int32FromInt32(LDBL_MANT_DIG)-bits-int32(1)), y) + frac = Xfmodl(tls, y, Xscalbn(tls, Float64FromInt32(1), int32(LDBL_MANT_DIG)-bits)) + y = y - frac + y = y + bias + } + /* Process tail of decimal input so it can affect rounding */ + if (a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1)) != z { + t = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[(a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1))] + if t < uint32(500000000) && (t != 0 || (a+i+int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)) != z) { + frac = frac + float64(float64(0.25)*float64(sign)) + } else { + if t > uint32(500000000) { + frac = frac + float64(float64(0.75)*float64(sign)) + } else { + if t == uint32(500000000) { + if (a+i+int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)) == z { + frac = frac + float64(float64(0.5)*float64(sign)) + } else { + frac = frac + float64(float64(0.75)*float64(sign)) + } + } + } + } + if int32(LDBL_MANT_DIG)-bits >= int32(2) && !(Xfmodl(tls, frac, Float64FromInt32(1)) != 0) { + frac = frac + 1 + } + } + y = y + frac + y = y - bias + if (e2+int32(LDBL_MANT_DIG))&int32(INT_MAX) > emax-int32(5) { + if Xfabsl(tls, y) >= Float64FromInt32(2)/Float64FromFloat64(2.22044604925031308085e-16) { + if denormal != 0 && bits == int32(LDBL_MANT_DIG)+e2-emin { + denormal = 0 + } + y = y * Float64FromFloat64(0.5) + e2 = e2 + 1 + } + if e2+int32(LDBL_MANT_DIG) > emax || denormal != 0 && frac != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + } + } + return Xscalbnl(tls, y, e2) +} + +var _th = [2]Tuint32_t{ + 0: uint32(9007199), + 1: uint32(254740991), +} + +var _p10s = [8]int32{ + 0: int32(10), + 1: int32(100), + 2: int32(1000), + 3: int32(10000), + 4: int32(100000), + 5: int32(1000000), + 6: int32(10000000), + 7: int32(100000000), +} + +func _hexfloat(tls *TLS, f uintptr, bits int32, emin int32, sign int32, pok int32) (r float64) { + var bias, scale, y float64 + var c, d, gotdig, gotrad, gottail, v1 int32 + var dc, e2, rp int64 + var x Tuint32_t + var v2, v3 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bias, c, d, dc, e2, gotdig, gotrad, gottail, rp, scale, x, y, v1, v2, v3 + x = uint32(0) + y = Float64FromInt32(0) + scale = Float64FromInt32(1) + bias = Float64FromInt32(0) + gottail = 0 + gotrad = 0 + gotdig = 0 + rp = 0 + dc = 0 + e2 = 0 + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + /* Skip leading zeros */ + for { + if !(c == int32('0')) { + break + } + gotdig = int32(1) + goto _4 + _4: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if c == int32('.') { + gotrad = int32(1) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + /* Count zeros after the radix point before significand */ + rp = 0 + for { + if !(c == int32('0')) { + break + } + gotdig = int32(1) + goto _11 + _11: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + rp = rp - 1 + } + } + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) || Uint32FromInt32(c|int32(32)-int32('a')) < uint32(6) || c == int32('.')) { + break + } + if c == int32('.') { + if gotrad != 0 { + break + } + rp = dc + gotrad = int32(1) + } else { + gotdig = int32(1) + if c > int32('9') { + d = c | int32(32) + int32(10) - int32('a') + } else { + d = c - int32('0') + } + if dc < int64(8) { + x = x*uint32(16) + Uint32FromInt32(d) + } else { + if dc < int64(Int32FromInt32(LDBL_MANT_DIG)/Int32FromInt32(4)+Int32FromInt32(1)) { + scale = scale / Float64FromInt32(16) + y = y + float64(float64(d)*scale) + } else { + if d != 0 && !(gottail != 0) { + y = y + float64(Float64FromFloat64(0.5)*scale) + gottail = int32(1) + } + } + } + dc = dc + 1 + } + goto _15 + _15: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if !(gotdig != 0) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if gotrad != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + } else { + X__shlim(tls, f, int64(Int32FromInt32(0))) + } + return float64(float64(sign) * float64(0)) + } + if !(gotrad != 0) { + rp = dc + } + for dc < int64(8) { + x = x * uint32(16) + dc = dc + 1 + } + if c|int32(32) == int32('p') { + e2 = _scanexp(tls, f, pok) + if e2 == -Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1) { + if pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } else { + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + e2 = 0 + } + } else { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + e2 = e2 + (int64(4)*rp - int64(32)) + if !(x != 0) { + return float64(float64(sign) * float64(0)) + } + if e2 > int64(-emin) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return float64(float64(float64(sign)*Float64FromFloat64(1.79769313486231570815e+308)) * Float64FromFloat64(1.79769313486231570815e+308)) + } + if e2 < int64(emin-Int32FromInt32(2)*Int32FromInt32(LDBL_MANT_DIG)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return float64(float64(float64(sign)*Float64FromFloat64(2.22507385850720138309e-308)) * Float64FromFloat64(2.22507385850720138309e-308)) + } + for x < uint32(0x80000000) { + if y >= Float64FromFloat64(0.5) { + x = x + (x + uint32(1)) + y = y + (y - Float64FromInt32(1)) + } else { + x = x + x + y = y + y + } + e2 = e2 - 1 + } + if int64(bits) > int64(32)+e2-int64(emin) { + bits = int32(int64(32) + e2 - int64(emin)) + if bits < 0 { + bits = 0 + } + } + if bits < int32(LDBL_MANT_DIG) { + bias = Xcopysignl(tls, Xscalbn(tls, Float64FromInt32(1), Int32FromInt32(32)+Int32FromInt32(LDBL_MANT_DIG)-bits-int32(1)), float64(sign)) + } + if bits < int32(32) && y != 0 && !(x&Uint32FromInt32(1) != 0) { + x = x + 1 + y = Float64FromInt32(0) + } + y = bias + float64(float64(sign)*float64(x)) + float64(float64(sign)*y) + y = y - bias + if !(y != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + } + return Xscalbnl(tls, y, int32(e2)) +} + +func X__floatscan(tls *TLS, f uintptr, prec int32, pok int32) (r float64) { + if __ccgo_strace { + trc("tls=%v f=%v prec=%v pok=%v, (%v:)", tls, f, prec, pok, origin(2)) + defer func() { trc("-> %v", r) }() + } + var bits, c, emin, sign, v1, v2, v5, v6 int32 + var i, v27 Tsize_t + var v3, v4 uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = bits, c, emin, i, sign, v1, v2, v27, v3, v4, v5, v6 + sign = int32(1) + switch prec { + case 0: + bits = int32(FLT_MANT_DIG) + emin = -int32(125) - bits + case int32(1): + bits = int32(DBL_MANT_DIG) + emin = -int32(1021) - bits + case int32(2): + bits = int32(LDBL_MANT_DIG) + emin = -int32(1021) - bits + default: + return Float64FromInt32(0) + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + v1 = v2 + c = v1 + v5 = v1 + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + if !(v6 != 0) { + break + } + } + if c == int32('+') || c == int32('-') { + sign = sign - int32(2)*BoolInt32(c == int32('-')) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + i = uint64(0) + for { + if !(i < uint64(8) && c|int32(32) == int32(**(**int8)(__ccgo_up(__ccgo_ts + 313 + uintptr(i))))) { + break + } + if i < uint64(7) { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + goto _11 + _11: + ; + i = i + 1 + } + if i == uint64(3) || i == uint64(8) || i > uint64(3) && pok != 0 { + if i != uint64(8) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if pok != 0 { + for { + if !(i > uint64(3)) { + break + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + goto _15 + _15: + ; + i = i - 1 + } + } + } + return float64(float32(sign) * X__builtin_inff(tls)) + } + if !(i != 0) { + i = uint64(0) + for { + if !(i < uint64(3) && c|int32(32) == int32(**(**int8)(__ccgo_up(__ccgo_ts + 322 + uintptr(i))))) { + break + } + if i < uint64(2) { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + goto _16 + _16: + ; + i = i + 1 + } + } + if i == uint64(3) { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + if v1 != int32('(') { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) + } + i = uint64(1) + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if Uint32FromInt32(c-int32('0')) < uint32(10) || Uint32FromInt32(c-int32('A')) < uint32(26) || Uint32FromInt32(c-int32('a')) < uint32(26) || c == int32('_') { + goto _23 + } + if c == int32(')') { + return float64(X__builtin_nanf(tls, __ccgo_ts)) + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if !(pok != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + for { + v27 = i + i = i - 1 + if !(v27 != 0) { + break + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) + goto _23 + _23: + ; + i = i + 1 + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) + } + if i != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + if c == int32('0') { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if c|int32(32) == int32('x') { + return _hexfloat(tls, f, bits, emin, sign, pok) + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + c = int32('0') + } + return _decfloat(tls, f, c, bits, emin, sign, pok) +} + +// C documentation +// +// /* Lookup table for digit values. -1==255>=36 -> invalid */ +var _table6 = [257]uint8{ + 0: Uint8FromInt32(-Int32FromInt32(1)), + 1: Uint8FromInt32(-Int32FromInt32(1)), + 2: Uint8FromInt32(-Int32FromInt32(1)), + 3: Uint8FromInt32(-Int32FromInt32(1)), + 4: Uint8FromInt32(-Int32FromInt32(1)), + 5: Uint8FromInt32(-Int32FromInt32(1)), + 6: Uint8FromInt32(-Int32FromInt32(1)), + 7: Uint8FromInt32(-Int32FromInt32(1)), + 8: Uint8FromInt32(-Int32FromInt32(1)), + 9: Uint8FromInt32(-Int32FromInt32(1)), + 10: Uint8FromInt32(-Int32FromInt32(1)), + 11: Uint8FromInt32(-Int32FromInt32(1)), + 12: Uint8FromInt32(-Int32FromInt32(1)), + 13: Uint8FromInt32(-Int32FromInt32(1)), + 14: Uint8FromInt32(-Int32FromInt32(1)), + 15: Uint8FromInt32(-Int32FromInt32(1)), + 16: Uint8FromInt32(-Int32FromInt32(1)), + 17: Uint8FromInt32(-Int32FromInt32(1)), + 18: Uint8FromInt32(-Int32FromInt32(1)), + 19: Uint8FromInt32(-Int32FromInt32(1)), + 20: Uint8FromInt32(-Int32FromInt32(1)), + 21: Uint8FromInt32(-Int32FromInt32(1)), + 22: Uint8FromInt32(-Int32FromInt32(1)), + 23: Uint8FromInt32(-Int32FromInt32(1)), + 24: Uint8FromInt32(-Int32FromInt32(1)), + 25: Uint8FromInt32(-Int32FromInt32(1)), + 26: Uint8FromInt32(-Int32FromInt32(1)), + 27: Uint8FromInt32(-Int32FromInt32(1)), + 28: Uint8FromInt32(-Int32FromInt32(1)), + 29: Uint8FromInt32(-Int32FromInt32(1)), + 30: Uint8FromInt32(-Int32FromInt32(1)), + 31: Uint8FromInt32(-Int32FromInt32(1)), + 32: Uint8FromInt32(-Int32FromInt32(1)), + 33: Uint8FromInt32(-Int32FromInt32(1)), + 34: Uint8FromInt32(-Int32FromInt32(1)), + 35: Uint8FromInt32(-Int32FromInt32(1)), + 36: Uint8FromInt32(-Int32FromInt32(1)), + 37: Uint8FromInt32(-Int32FromInt32(1)), + 38: Uint8FromInt32(-Int32FromInt32(1)), + 39: Uint8FromInt32(-Int32FromInt32(1)), + 40: Uint8FromInt32(-Int32FromInt32(1)), + 41: Uint8FromInt32(-Int32FromInt32(1)), + 42: Uint8FromInt32(-Int32FromInt32(1)), + 43: Uint8FromInt32(-Int32FromInt32(1)), + 44: Uint8FromInt32(-Int32FromInt32(1)), + 45: Uint8FromInt32(-Int32FromInt32(1)), + 46: Uint8FromInt32(-Int32FromInt32(1)), + 47: Uint8FromInt32(-Int32FromInt32(1)), + 48: Uint8FromInt32(-Int32FromInt32(1)), + 50: uint8(1), + 51: uint8(2), + 52: uint8(3), + 53: uint8(4), + 54: uint8(5), + 55: uint8(6), + 56: uint8(7), + 57: uint8(8), + 58: uint8(9), + 59: Uint8FromInt32(-Int32FromInt32(1)), + 60: Uint8FromInt32(-Int32FromInt32(1)), + 61: Uint8FromInt32(-Int32FromInt32(1)), + 62: Uint8FromInt32(-Int32FromInt32(1)), + 63: Uint8FromInt32(-Int32FromInt32(1)), + 64: Uint8FromInt32(-Int32FromInt32(1)), + 65: Uint8FromInt32(-Int32FromInt32(1)), + 66: uint8(10), + 67: uint8(11), + 68: uint8(12), + 69: uint8(13), + 70: uint8(14), + 71: uint8(15), + 72: uint8(16), + 73: uint8(17), + 74: uint8(18), + 75: uint8(19), + 76: uint8(20), + 77: uint8(21), + 78: uint8(22), + 79: uint8(23), + 80: uint8(24), + 81: uint8(25), + 82: uint8(26), + 83: uint8(27), + 84: uint8(28), + 85: uint8(29), + 86: uint8(30), + 87: uint8(31), + 88: uint8(32), + 89: uint8(33), + 90: uint8(34), + 91: uint8(35), + 92: Uint8FromInt32(-Int32FromInt32(1)), + 93: Uint8FromInt32(-Int32FromInt32(1)), + 94: Uint8FromInt32(-Int32FromInt32(1)), + 95: Uint8FromInt32(-Int32FromInt32(1)), + 96: Uint8FromInt32(-Int32FromInt32(1)), + 97: Uint8FromInt32(-Int32FromInt32(1)), + 98: uint8(10), + 99: uint8(11), + 100: uint8(12), + 101: uint8(13), + 102: uint8(14), + 103: uint8(15), + 104: uint8(16), + 105: uint8(17), + 106: uint8(18), + 107: uint8(19), + 108: uint8(20), + 109: uint8(21), + 110: uint8(22), + 111: uint8(23), + 112: uint8(24), + 113: uint8(25), + 114: uint8(26), + 115: uint8(27), + 116: uint8(28), + 117: uint8(29), + 118: uint8(30), + 119: uint8(31), + 120: uint8(32), + 121: uint8(33), + 122: uint8(34), + 123: uint8(35), + 124: Uint8FromInt32(-Int32FromInt32(1)), + 125: Uint8FromInt32(-Int32FromInt32(1)), + 126: Uint8FromInt32(-Int32FromInt32(1)), + 127: Uint8FromInt32(-Int32FromInt32(1)), + 128: Uint8FromInt32(-Int32FromInt32(1)), + 129: Uint8FromInt32(-Int32FromInt32(1)), + 130: Uint8FromInt32(-Int32FromInt32(1)), + 131: Uint8FromInt32(-Int32FromInt32(1)), + 132: Uint8FromInt32(-Int32FromInt32(1)), + 133: Uint8FromInt32(-Int32FromInt32(1)), + 134: Uint8FromInt32(-Int32FromInt32(1)), + 135: Uint8FromInt32(-Int32FromInt32(1)), + 136: Uint8FromInt32(-Int32FromInt32(1)), + 137: Uint8FromInt32(-Int32FromInt32(1)), + 138: Uint8FromInt32(-Int32FromInt32(1)), + 139: Uint8FromInt32(-Int32FromInt32(1)), + 140: Uint8FromInt32(-Int32FromInt32(1)), + 141: Uint8FromInt32(-Int32FromInt32(1)), + 142: Uint8FromInt32(-Int32FromInt32(1)), + 143: Uint8FromInt32(-Int32FromInt32(1)), + 144: Uint8FromInt32(-Int32FromInt32(1)), + 145: Uint8FromInt32(-Int32FromInt32(1)), + 146: Uint8FromInt32(-Int32FromInt32(1)), + 147: Uint8FromInt32(-Int32FromInt32(1)), + 148: Uint8FromInt32(-Int32FromInt32(1)), + 149: Uint8FromInt32(-Int32FromInt32(1)), + 150: Uint8FromInt32(-Int32FromInt32(1)), + 151: Uint8FromInt32(-Int32FromInt32(1)), + 152: Uint8FromInt32(-Int32FromInt32(1)), + 153: Uint8FromInt32(-Int32FromInt32(1)), + 154: Uint8FromInt32(-Int32FromInt32(1)), + 155: Uint8FromInt32(-Int32FromInt32(1)), + 156: Uint8FromInt32(-Int32FromInt32(1)), + 157: Uint8FromInt32(-Int32FromInt32(1)), + 158: Uint8FromInt32(-Int32FromInt32(1)), + 159: Uint8FromInt32(-Int32FromInt32(1)), + 160: Uint8FromInt32(-Int32FromInt32(1)), + 161: Uint8FromInt32(-Int32FromInt32(1)), + 162: Uint8FromInt32(-Int32FromInt32(1)), + 163: Uint8FromInt32(-Int32FromInt32(1)), + 164: Uint8FromInt32(-Int32FromInt32(1)), + 165: Uint8FromInt32(-Int32FromInt32(1)), + 166: Uint8FromInt32(-Int32FromInt32(1)), + 167: Uint8FromInt32(-Int32FromInt32(1)), + 168: Uint8FromInt32(-Int32FromInt32(1)), + 169: Uint8FromInt32(-Int32FromInt32(1)), + 170: Uint8FromInt32(-Int32FromInt32(1)), + 171: Uint8FromInt32(-Int32FromInt32(1)), + 172: Uint8FromInt32(-Int32FromInt32(1)), + 173: Uint8FromInt32(-Int32FromInt32(1)), + 174: Uint8FromInt32(-Int32FromInt32(1)), + 175: Uint8FromInt32(-Int32FromInt32(1)), + 176: Uint8FromInt32(-Int32FromInt32(1)), + 177: Uint8FromInt32(-Int32FromInt32(1)), + 178: Uint8FromInt32(-Int32FromInt32(1)), + 179: Uint8FromInt32(-Int32FromInt32(1)), + 180: Uint8FromInt32(-Int32FromInt32(1)), + 181: Uint8FromInt32(-Int32FromInt32(1)), + 182: Uint8FromInt32(-Int32FromInt32(1)), + 183: Uint8FromInt32(-Int32FromInt32(1)), + 184: Uint8FromInt32(-Int32FromInt32(1)), + 185: Uint8FromInt32(-Int32FromInt32(1)), + 186: Uint8FromInt32(-Int32FromInt32(1)), + 187: Uint8FromInt32(-Int32FromInt32(1)), + 188: Uint8FromInt32(-Int32FromInt32(1)), + 189: Uint8FromInt32(-Int32FromInt32(1)), + 190: Uint8FromInt32(-Int32FromInt32(1)), + 191: Uint8FromInt32(-Int32FromInt32(1)), + 192: Uint8FromInt32(-Int32FromInt32(1)), + 193: Uint8FromInt32(-Int32FromInt32(1)), + 194: Uint8FromInt32(-Int32FromInt32(1)), + 195: Uint8FromInt32(-Int32FromInt32(1)), + 196: Uint8FromInt32(-Int32FromInt32(1)), + 197: Uint8FromInt32(-Int32FromInt32(1)), + 198: Uint8FromInt32(-Int32FromInt32(1)), + 199: Uint8FromInt32(-Int32FromInt32(1)), + 200: Uint8FromInt32(-Int32FromInt32(1)), + 201: Uint8FromInt32(-Int32FromInt32(1)), + 202: Uint8FromInt32(-Int32FromInt32(1)), + 203: Uint8FromInt32(-Int32FromInt32(1)), + 204: Uint8FromInt32(-Int32FromInt32(1)), + 205: Uint8FromInt32(-Int32FromInt32(1)), + 206: Uint8FromInt32(-Int32FromInt32(1)), + 207: Uint8FromInt32(-Int32FromInt32(1)), + 208: Uint8FromInt32(-Int32FromInt32(1)), + 209: Uint8FromInt32(-Int32FromInt32(1)), + 210: Uint8FromInt32(-Int32FromInt32(1)), + 211: Uint8FromInt32(-Int32FromInt32(1)), + 212: Uint8FromInt32(-Int32FromInt32(1)), + 213: Uint8FromInt32(-Int32FromInt32(1)), + 214: Uint8FromInt32(-Int32FromInt32(1)), + 215: Uint8FromInt32(-Int32FromInt32(1)), + 216: Uint8FromInt32(-Int32FromInt32(1)), + 217: Uint8FromInt32(-Int32FromInt32(1)), + 218: Uint8FromInt32(-Int32FromInt32(1)), + 219: Uint8FromInt32(-Int32FromInt32(1)), + 220: Uint8FromInt32(-Int32FromInt32(1)), + 221: Uint8FromInt32(-Int32FromInt32(1)), + 222: Uint8FromInt32(-Int32FromInt32(1)), + 223: Uint8FromInt32(-Int32FromInt32(1)), + 224: Uint8FromInt32(-Int32FromInt32(1)), + 225: Uint8FromInt32(-Int32FromInt32(1)), + 226: Uint8FromInt32(-Int32FromInt32(1)), + 227: Uint8FromInt32(-Int32FromInt32(1)), + 228: Uint8FromInt32(-Int32FromInt32(1)), + 229: Uint8FromInt32(-Int32FromInt32(1)), + 230: Uint8FromInt32(-Int32FromInt32(1)), + 231: Uint8FromInt32(-Int32FromInt32(1)), + 232: Uint8FromInt32(-Int32FromInt32(1)), + 233: Uint8FromInt32(-Int32FromInt32(1)), + 234: Uint8FromInt32(-Int32FromInt32(1)), + 235: Uint8FromInt32(-Int32FromInt32(1)), + 236: Uint8FromInt32(-Int32FromInt32(1)), + 237: Uint8FromInt32(-Int32FromInt32(1)), + 238: Uint8FromInt32(-Int32FromInt32(1)), + 239: Uint8FromInt32(-Int32FromInt32(1)), + 240: Uint8FromInt32(-Int32FromInt32(1)), + 241: Uint8FromInt32(-Int32FromInt32(1)), + 242: Uint8FromInt32(-Int32FromInt32(1)), + 243: Uint8FromInt32(-Int32FromInt32(1)), + 244: Uint8FromInt32(-Int32FromInt32(1)), + 245: Uint8FromInt32(-Int32FromInt32(1)), + 246: Uint8FromInt32(-Int32FromInt32(1)), + 247: Uint8FromInt32(-Int32FromInt32(1)), + 248: Uint8FromInt32(-Int32FromInt32(1)), + 249: Uint8FromInt32(-Int32FromInt32(1)), + 250: Uint8FromInt32(-Int32FromInt32(1)), + 251: Uint8FromInt32(-Int32FromInt32(1)), + 252: Uint8FromInt32(-Int32FromInt32(1)), + 253: Uint8FromInt32(-Int32FromInt32(1)), + 254: Uint8FromInt32(-Int32FromInt32(1)), + 255: Uint8FromInt32(-Int32FromInt32(1)), + 256: Uint8FromInt32(-Int32FromInt32(1)), +} + +func X__intscan(tls *TLS, f uintptr, base uint32, pok int32, lim uint64) (r uint64) { + if __ccgo_strace { + trc("tls=%v f=%v base=%v pok=%v lim=%v, (%v:)", tls, f, base, pok, lim, origin(2)) + defer func() { trc("-> %v", r) }() + } + var bs, c, neg, v1, v2, v5, v6 int32 + var val, v3, v4 uintptr + var x uint32 + var y uint64 + _, _, _, _, _, _, _, _, _, _, _, _ = bs, c, neg, val, x, y, v1, v2, v3, v4, v5, v6 + val = uintptr(unsafe.Pointer(&_table6)) + uintptr(1) + neg = 0 + if base > uint32(36) || base == uint32(1) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uint64(0) + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + v1 = v2 + c = v1 + v5 = v1 + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + if !(v6 != 0) { + break + } + } + if c == int32('+') || c == int32('-') { + neg = -BoolInt32(c == int32('-')) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if (base == uint32(0) || base == uint32(16)) && c == int32('0') { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if c|int32(32) == int32('x') { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if Int32FromUint8(**(**uint8)(__ccgo_up(val + uintptr(c)))) >= int32(16) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } else { + X__shlim(tls, f, int64(Int32FromInt32(0))) + } + return uint64(0) + } + base = uint32(16) + } else { + if base == uint32(0) { + base = uint32(8) + } + } + } else { + if base == uint32(0) { + base = uint32(10) + } + if uint32(**(**uint8)(__ccgo_up(val + uintptr(c)))) >= base { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + X__shlim(tls, f, int64(Int32FromInt32(0))) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uint64(0) + } + } + if base == uint32(10) { + x = uint32(0) + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) && x <= Uint32FromUint32(0xffffffff)/Uint32FromInt32(10)-Uint32FromInt32(1)) { + break + } + x = x*uint32(10) + Uint32FromInt32(c-Int32FromUint8('0')) + goto _17 + _17: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + y = uint64(x) + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) && y <= (Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1))/Uint64FromInt32(10) && uint64(10)*y <= Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)-Uint64FromInt32(c-Int32FromUint8('0'))) { + break + } + y = y*uint64(10) + Uint64FromInt32(c-Int32FromUint8('0')) + goto _21 + _21: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if Uint32FromInt32(c-int32('0')) >= uint32(10) { + goto done + } + } else { + if !(base&(base-Uint32FromInt32(1)) != 0) { + bs = int32(**(**int8)(__ccgo_up(__ccgo_ts + 326 + uintptr(uint32(0x17)*base>>int32(5)&uint32(7))))) + x = uint32(0) + for { + if !(uint32(**(**uint8)(__ccgo_up(val + uintptr(c)))) < base && x <= Uint32FromUint32(0xffffffff)/Uint32FromInt32(32)) { + break + } + x = x<>bs) { + break + } + y = y<= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if y >= lim { + if !(lim&Uint64FromInt32(1) != 0) && !(neg != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return lim - uint64(1) + } else { + if y > lim { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return lim + } + } + } + return y ^ Uint64FromInt32(neg) - Uint64FromInt32(neg) +} + +func X__procfdname(tls *TLS, buf uintptr, fd uint32) { + if __ccgo_strace { + trc("tls=%v buf=%v fd=%v, (%v:)", tls, buf, fd, origin(2)) + } + var i, j, v5 uint32 + var v2 int8 + _, _, _, _ = i, j, v2, v5 + i = uint32(0) + for { + v2 = **(**int8)(__ccgo_up(__ccgo_ts + 335 + uintptr(i))) + **(**int8)(__ccgo_up(buf + uintptr(i))) = v2 + if !(v2 != 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if !(fd != 0) { + **(**int8)(__ccgo_up(buf + uintptr(i))) = int8('0') + **(**int8)(__ccgo_up(buf + uintptr(i+uint32(1)))) = 0 + return + } + j = fd + for { + if !(j != 0) { + break + } + goto _3 + _3: + ; + j = j / uint32(10) + i = i + 1 + } + **(**int8)(__ccgo_up(buf + uintptr(i))) = 0 + for { + if !(fd != 0) { + break + } + i = i - 1 + v5 = i + **(**int8)(__ccgo_up(buf + uintptr(v5))) = Int8FromUint32(uint32('0') + fd%uint32(10)) + goto _4 + _4: + ; + fd = fd / uint32(10) + } +} + +/* The shcnt field stores the number of bytes read so far, offset by + * the value of buf-rpos at the last function call (__shlim or __shgetc), + * so that between calls the inline shcnt macro can add rpos-buf to get + * the actual count. */ + +func X__shlim(tls *TLS, f uintptr, lim Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v lim=%v, (%v:)", tls, f, lim, origin(2)) + } + (*TFILE)(unsafe.Pointer(f)).Fshlim = lim + (*TFILE)(unsafe.Pointer(f)).Fshcnt = int64((*TFILE)(unsafe.Pointer(f)).Fbuf) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + /* If lim is nonzero, rend must be a valid pointer. */ + if lim != 0 && int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos) > lim { + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frpos + uintptr(lim) + } else { + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frend + } +} + +func X__shgetc(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c, v1 int32 + var cnt Toff_t + var v2 bool + _, _, _, _ = c, cnt, v1, v2 + cnt = (*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) + if v2 = (*TFILE)(unsafe.Pointer(f)).Fshlim != 0 && cnt >= (*TFILE)(unsafe.Pointer(f)).Fshlim; !v2 { + v1 = X__uflow(tls, f) + c = v1 + } + if v2 || v1 < 0 { + (*TFILE)(unsafe.Pointer(f)).Fshcnt = int64((*TFILE)(unsafe.Pointer(f)).Fbuf) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + cnt + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frpos + (*TFILE)(unsafe.Pointer(f)).Fshlim = int64(-int32(1)) + return -int32(1) + } + cnt = cnt + 1 + if (*TFILE)(unsafe.Pointer(f)).Fshlim != 0 && int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos) > (*TFILE)(unsafe.Pointer(f)).Fshlim-cnt { + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frpos + uintptr((*TFILE)(unsafe.Pointer(f)).Fshlim-cnt) + } else { + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frend + } + (*TFILE)(unsafe.Pointer(f)).Fshcnt = int64((*TFILE)(unsafe.Pointer(f)).Fbuf) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + cnt + if (*TFILE)(unsafe.Pointer(f)).Frpos <= (*TFILE)(unsafe.Pointer(f)).Fbuf { + **(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos + uintptr(-Int32FromInt32(1)))) = Uint8FromInt32(c) + } + return c +} + +func X__syscall_ret(tls *TLS, r uint64) (r1 int64) { + if __ccgo_strace { + trc("tls=%v r=%v, (%v:)", tls, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + if r > -Uint64FromUint64(4096) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = Int32FromUint64(-r) + return int64(-int32(1)) + } + return Int64FromUint64(r) +} + +type TElf_Symndx = uint32 + +type Tdl_phdr_info = struct { + Fdlpi_addr TElf64_Addr + Fdlpi_name uintptr + Fdlpi_phdr uintptr + Fdlpi_phnum TElf64_Half + Fdlpi_adds uint64 + Fdlpi_subs uint64 + Fdlpi_tls_modid Tsize_t + Fdlpi_tls_data uintptr +} + +type Tlink_map = struct { + Fl_addr TElf64_Addr + Fl_name uintptr + Fl_ld uintptr + Fl_next uintptr + Fl_prev uintptr +} + +type Tr_debug = struct { + Fr_version int32 + Fr_map uintptr + Fr_brk TElf64_Addr + Fr_state int32 + Fr_ldbase TElf64_Addr +} + +const _RT_CONSISTENT = 0 +const _RT_ADD = 1 +const _RT_DELETE = 2 +const VERSION = "1.2.5" + +const IPC_CREAT = 512 +const IPC_EXCL = 1024 +const IPC_INFO = 3 +const IPC_NOWAIT = 2048 +const IPC_RMID = 0 +const IPC_SET = 1 +const IPC_STAT = 2 +const __ipc_perm_key = 0 +const __ipc_perm_seq = 0 + +type Tkey_t = int32 + +type Tipc_perm = struct { + F__key Tkey_t + Fuid Tuid_t + Fgid Tgid_t + Fcuid Tuid_t + Fcgid Tgid_t + Fmode Tmode_t + F__seq int32 + F__pad1 int64 + F__pad2 int64 +} + +func Xftok(tls *TLS, path uintptr, id int32) (r Tkey_t) { + if __ccgo_strace { + trc("tls=%v path=%v id=%v, (%v:)", tls, path, id, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var _ /* st at bp+0 */ Tstat + if Xstat(tls, path, bp) < 0 { + return -int32(1) + } + return Int32FromUint64((**(**Tstat)(__ccgo_up(bp))).Fst_ino&Uint64FromInt32(0xffff) | (**(**Tstat)(__ccgo_up(bp))).Fst_dev&Uint64FromInt32(0xff)< %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall3(tls, int64(SYS_msgctl), int64(q), int64(cmd & ^(Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) | Int32FromInt32(IPC_64)), int64(buf))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xmsgget(tls *TLS, k Tkey_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v k=%v flag=%v, (%v:)", tls, k, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_msgget), int64(k), int64(flag))))) +} + +func Xmsgrcv(tls *TLS, q int32, m uintptr, len1 Tsize_t, type1 int64, flag int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v q=%v m=%v len1=%v type1=%v flag=%v, (%v:)", tls, q, m, len1, type1, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_msgrcv), int64(q), int64(m), Int64FromUint64(len1), type1, int64(flag), 0))) +} + +func Xmsgsnd(tls *TLS, q int32, m uintptr, len1 Tsize_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v q=%v m=%v len1=%v flag=%v, (%v:)", tls, q, m, len1, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_msgsnd), int64(q), int64(m), Int64FromUint64(len1), int64(flag), 0, 0)))) +} + +const GETALL = 13 +const GETNCNT = 14 +const GETPID = 11 +const GETVAL = 12 +const GETZCNT = 15 +const SEM_INFO = 19 +const SEM_STAT = 18 +const SEM_STAT_ANY = 20 +const SEM_UNDO = 4096 +const SETALL = 17 +const SETVAL = 16 +const _SEM_SEMUN_UNDEFINED = 1 + +type Tsemid_ds = struct { + Fsem_perm Tipc_perm + Fsem_otime Ttime_t + F__unused1 int64 + Fsem_ctime Ttime_t + F__unused2 int64 + Fsem_nsems uint16 + F__sem_nsems_pad [6]int8 + F__unused3 int64 + F__unused4 int64 +} + +type Tseminfo = struct { + Fsemmap int32 + Fsemmni int32 + Fsemmns int32 + Fsemmnu int32 + Fsemmsl int32 + Fsemopm int32 + Fsemume int32 + Fsemusz int32 + Fsemvmx int32 + Fsemaem int32 +} + +type Tsembuf = struct { + Fsem_num uint16 + Fsem_op int16 + Fsem_flg int16 +} + +type Tsemun = struct { + Fbuf [0]uintptr + Farray [0]uintptr + Fval int32 + F__ccgo_pad3 [4]byte +} + +func Xsemctl(tls *TLS, id int32, num int32, cmd int32, va uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v id=%v num=%v cmd=%v va=%v, (%v:)", tls, id, num, cmd, va, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ap Tva_list + var r int32 + var _ /* arg at bp+0 */ Tsemun + _, _ = ap, r + *(*Tsemun)(unsafe.Pointer(bp)) = Tsemun{} + *(*int32)(unsafe.Pointer(bp)) = 0 + switch cmd & ^(Int32FromInt32(IPC_STAT) & Int32FromInt32(0x100)) { + case int32(SETVAL): + fallthrough + case int32(GETALL): + fallthrough + case int32(SETALL): + fallthrough + case int32(IPC_SET): + fallthrough + case int32(IPC_INFO): + fallthrough + case int32(SEM_INFO): + fallthrough + case Int32FromInt32(IPC_STAT) & ^(Int32FromInt32(IPC_STAT) & Int32FromInt32(0x100)): + fallthrough + case (Int32FromInt32(18) | Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) & ^(Int32FromInt32(IPC_STAT) & Int32FromInt32(0x100)): + fallthrough + case (Int32FromInt32(20) | Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) & ^(Int32FromInt32(IPC_STAT) & Int32FromInt32(0x100)): + ap = va + **(**Tsemun)(__ccgo_up(bp)) = *(*Tsemun)(unsafe.Pointer(VaOther(&ap, 8))) + _ = ap + } + r = int32(X__syscall4(tls, int64(SYS_semctl), int64(id), int64(num), int64(cmd & ^(Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) | Int32FromInt32(IPC_64)), int64(*(*uintptr)(unsafe.Pointer(bp))))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xsemget(tls *TLS, key Tkey_t, n int32, fl int32) (r int32) { + if __ccgo_strace { + trc("tls=%v key=%v n=%v fl=%v, (%v:)", tls, key, n, fl, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* The kernel uses the wrong type for the sem_nsems member + * of struct semid_ds, and thus might not check that the + * n fits in the correct (per POSIX) userspace type, so + * we have to check here. */ + if n > int32(USHRT_MAX) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_semget), int64(key), int64(n), int64(fl))))) +} + +func Xsemop(tls *TLS, id int32, buf uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v id=%v buf=%v n=%v, (%v:)", tls, id, buf, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_semop), int64(id), int64(buf), Int64FromUint64(n))))) +} + +const NO_TIME32 = 0 +const __key = 0 +const __seq = 0 + +type Tipc_perm1 = struct { + Fkey Tkey_t + Fuid Tuid_t + Fgid Tgid_t + Fcuid Tuid_t + Fcgid Tgid_t + Fmode Tmode_t + Fseq int32 + F__pad1 int64 + F__pad2 int64 +} + +type Tsemid_ds1 = struct { + Fsem_perm Tipc_perm1 + Fsem_otime Ttime_t + F__unused1 int64 + Fsem_ctime Ttime_t + F__unused2 int64 + Fsem_nsems uint16 + F__sem_nsems_pad [6]int8 + F__unused3 int64 + F__unused4 int64 +} + +func Xsemtimedop(tls *TLS, id int32, buf uintptr, n Tsize_t, ts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v id=%v buf=%v n=%v ts=%v, (%v:)", tls, id, buf, n, ts, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_semtimedop), int64(id), int64(buf), Int64FromUint64(n), int64(ts))))) +} + +const SHMLBA = 4096 +const SHM_DEST = 512 +const SHM_EXEC = 32768 +const SHM_HUGETLB = 2048 +const SHM_HUGE_16GB = 2281701376 +const SHM_HUGE_16MB = 1610612736 +const SHM_HUGE_1GB = 2013265920 +const SHM_HUGE_1MB = 1342177280 +const SHM_HUGE_256MB = 1879048192 +const SHM_HUGE_2GB = 2080374784 +const SHM_HUGE_2MB = 1409286144 +const SHM_HUGE_32MB = 1677721600 +const SHM_HUGE_512KB = 1275068416 +const SHM_HUGE_512MB = 1946157056 +const SHM_HUGE_64KB = 1073741824 +const SHM_HUGE_8MB = 1543503872 +const SHM_HUGE_MASK = 63 +const SHM_HUGE_SHIFT = 26 +const SHM_INFO = 14 +const SHM_LOCK = 11 +const SHM_LOCKED = 1024 +const SHM_NORESERVE = 4096 +const SHM_R = 256 +const SHM_RDONLY = 4096 +const SHM_REMAP = 16384 +const SHM_RND = 8192 +const SHM_STAT = 13 +const SHM_STAT_ANY = 15 +const SHM_UNLOCK = 12 +const SHM_W = 128 + +type Tshmid_ds = struct { + Fshm_perm Tipc_perm + Fshm_segsz Tsize_t + Fshm_atime Ttime_t + Fshm_dtime Ttime_t + Fshm_ctime Ttime_t + Fshm_cpid Tpid_t + Fshm_lpid Tpid_t + Fshm_nattch uint64 + F__pad1 uint64 + F__pad2 uint64 +} + +type Tshminfo = struct { + Fshmmax uint64 + Fshmmin uint64 + Fshmmni uint64 + Fshmseg uint64 + Fshmall uint64 + F__unused [4]uint64 +} + +type Tshm_info = struct { + F__used_ids int32 + Fshm_tot uint64 + Fshm_rss uint64 + Fshm_swp uint64 + F__swap_attempts uint64 + F__swap_successes uint64 +} + +type Tshmatt_t = uint64 + +func Xshmat(tls *TLS, id int32, addr uintptr, flag int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v id=%v addr=%v flag=%v, (%v:)", tls, id, addr, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_shmat), int64(id), int64(addr), int64(flag))))) +} + +func Xshmctl(tls *TLS, id int32, cmd int32, buf uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v id=%v cmd=%v buf=%v, (%v:)", tls, id, cmd, buf, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall3(tls, int64(SYS_shmctl), int64(id), int64(cmd & ^(Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) | Int32FromInt32(IPC_64)), int64(buf))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xshmdt(tls *TLS, addr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v, (%v:)", tls, addr, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_shmdt), int64(addr))))) +} + +func Xshmget(tls *TLS, key Tkey_t, size Tsize_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v key=%v size=%v flag=%v, (%v:)", tls, key, size, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + if size > Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + size = Uint64FromUint64(0xffffffffffffffff) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_shmget), int64(key), Int64FromUint64(size), int64(flag))))) +} + +type Tpasswd = struct { + Fpw_name uintptr + Fpw_passwd uintptr + Fpw_uid Tuid_t + Fpw_gid Tgid_t + Fpw_gecos uintptr + Fpw_dir uintptr + Fpw_shell uintptr +} + +func Xcuserid(tls *TLS, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v buf=%v, (%v:)", tls, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(2112) + defer tls.Free(2112) + var len1 Tsize_t + var _ /* ppw at bp+48 */ uintptr + var _ /* pw at bp+0 */ Tpasswd + var _ /* pwb at bp+56 */ [256]int64 + _ = len1 + if buf != 0 { + **(**int8)(__ccgo_up(buf)) = 0 + } + Xgetpwuid_r(tls, Xgeteuid(tls), bp, bp+56, uint64(2048), bp+48) + if !(**(**uintptr)(__ccgo_up(bp + 48)) != 0) { + return buf + } + len1 = Xstrnlen(tls, (**(**Tpasswd)(__ccgo_up(bp))).Fpw_name, uint64(L_cuserid)) + if len1 == uint64(L_cuserid) { + return buf + } + if !(buf != 0) { + buf = uintptr(unsafe.Pointer(&_usridbuf)) + } + Xmemcpy(tls, buf, (**(**Tpasswd)(__ccgo_up(bp))).Fpw_name, len1+uint64(1)) + return buf +} + +var _usridbuf [20]int8 + +func Xvwarn(tls *TLS, fmt uintptr, ap Tva_list) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + Xfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), __ccgo_ts+350, VaList(bp+8, Xprogram_invocation_short_name)) + if fmt != 0 { + Xvfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), fmt, ap) + Xfputs(tls, __ccgo_ts+355, uintptr(unsafe.Pointer(&X__stderr_FILE))) + } + Xperror(tls, uintptr(0)) +} + +func Xvwarnx(tls *TLS, fmt uintptr, ap Tva_list) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + Xfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), __ccgo_ts+350, VaList(bp+8, Xprogram_invocation_short_name)) + if fmt != 0 { + Xvfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), fmt, ap) + } + Xputc(tls, int32('\n'), uintptr(unsafe.Pointer(&X__stderr_FILE))) +} + +func Xverr(tls *TLS, status int32, fmt uintptr, ap Tva_list) { + if __ccgo_strace { + trc("tls=%v status=%v fmt=%v ap=%v, (%v:)", tls, status, fmt, ap, origin(2)) + } + Xvwarn(tls, fmt, ap) + _exit(tls, status) +} + +func Xverrx(tls *TLS, status int32, fmt uintptr, ap Tva_list) { + if __ccgo_strace { + trc("tls=%v status=%v fmt=%v ap=%v, (%v:)", tls, status, fmt, ap, origin(2)) + } + Xvwarnx(tls, fmt, ap) + _exit(tls, status) +} + +func Xwarn(tls *TLS, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + Xvwarn(tls, fmt, ap) + _ = ap +} + +func Xwarnx(tls *TLS, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + Xvwarnx(tls, fmt, ap) + _ = ap +} + +func Xerr(tls *TLS, status int32, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v status=%v fmt=%v va=%v, (%v:)", tls, status, fmt, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + Xverr(tls, status, fmt, ap) + _ = ap +} + +func Xerrx(tls *TLS, status int32, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v status=%v fmt=%v va=%v, (%v:)", tls, status, fmt, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + Xverrx(tls, status, fmt, ap) + _ = ap +} + +func Xeuidaccess(tls *TLS, filename uintptr, amode int32) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v amode=%v, (%v:)", tls, filename, amode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfaccessat(tls, -int32(100), filename, amode, int32(AT_EACCESS)) +} + +func Xeaccess(tls *TLS, filename uintptr, amode int32) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v amode=%v, (%v:)", tls, filename, amode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xeuidaccess(tls, filename, amode) +} + +const FTW_CHDIR = 4 +const FTW_D = 2 +const FTW_DEPTH = 8 +const FTW_DNR = 3 +const FTW_DP = 6 +const FTW_F = 1 +const FTW_MOUNT = 2 +const FTW_NS = 4 +const FTW_PHYS = 1 +const FTW_SL = 5 +const FTW_SLN = 7 + +type TFTW = struct { + Fbase int32 + Flevel int32 +} + +type t__ccgo_fp__Xftw_1 = func(*TLS, uintptr, uintptr, int32) int32 + +func Xftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v __ccgo_fp_fn=%v fd_limit=%v, (%v:)", tls, path, __ccgo_fp_fn, fd_limit, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* The following cast assumes that calling a function with one + * argument more than it needs behaves as expected. This is + * actually undefined, but works on all real-world machines. */ + return Xnftw(tls, path, __ccgo_fp_fn, fd_limit, int32(FTW_PHYS)) +} + +const STATX_ALL = 4095 +const STATX_ATIME = 32 +const STATX_BASIC_STATS = 2047 +const STATX_BLOCKS = 1024 +const STATX_BTIME = 2048 +const STATX_CTIME = 128 +const STATX_GID = 16 +const STATX_INO = 256 +const STATX_MODE = 2 +const STATX_MTIME = 64 +const STATX_NLINK = 4 +const STATX_SIZE = 512 +const STATX_TYPE = 1 +const STATX_UID = 8 +const S_IEXEC = 64 +const S_IREAD = 256 +const S_IWRITE = 128 + +type Tstatx_timestamp = struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + F__pad Tuint32_t +} + +type Tstatx = struct { + Fstx_mask Tuint32_t + Fstx_blksize Tuint32_t + Fstx_attributes Tuint64_t + Fstx_nlink Tuint32_t + Fstx_uid Tuint32_t + Fstx_gid Tuint32_t + Fstx_mode Tuint16_t + F__pad0 [1]Tuint16_t + Fstx_ino Tuint64_t + Fstx_size Tuint64_t + Fstx_blocks Tuint64_t + Fstx_attributes_mask Tuint64_t + Fstx_atime Tstatx_timestamp + Fstx_btime Tstatx_timestamp + Fstx_ctime Tstatx_timestamp + Fstx_mtime Tstatx_timestamp + Fstx_rdev_major Tuint32_t + Fstx_rdev_minor Tuint32_t + Fstx_dev_major Tuint32_t + Fstx_dev_minor Tuint32_t + F__pad1 [14]Tuint64_t +} + +type Ttimezone = struct { + Ftz_minuteswest int32 + Ftz_dsttime int32 +} + +func Xfutimes(tls *TLS, fd int32, tv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v tv=%v, (%v:)", tls, fd, tv, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* times at bp+0 */ [2]Ttimespec + if !(tv != 0) { + return Xfutimens(tls, fd, uintptr(0)) + } + (**(**[2]Ttimespec)(__ccgo_up(bp)))[0].Ftv_sec = (**(**Ttimeval)(__ccgo_up(tv))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[0].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(tv))).Ftv_usec * int64(1000) + (**(**[2]Ttimespec)(__ccgo_up(bp)))[int32(1)].Ftv_sec = (**(**Ttimeval)(__ccgo_up(tv + 1*16))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[int32(1)].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(tv + 1*16))).Ftv_usec * int64(1000) + return Xfutimens(tls, fd, bp) +} + +const prlimit64 = 0 + +func Xgetdtablesize(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* rl at bp+0 */ Trlimit + _ = v1 + Xgetrlimit(tls, int32(RLIMIT_NOFILE), bp) + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur < uint64(INT_MAX) { + v1 = (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur + } else { + v1 = uint64(INT_MAX) + } + return Int32FromUint64(v1) +} + +func Xgetloadavg(tls *TLS, a uintptr, n int32) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v n=%v, (%v:)", tls, a, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(368) + defer tls.Free(368) + var i, v1 int32 + var _ /* si at bp+0 */ Tsysinfo + _, _ = i, v1 + if n <= 0 { + if n != 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 + } + Xsysinfo(tls, bp) + if n > int32(3) { + n = int32(3) + } + i = 0 + for { + if !(i < n) { + break + } + **(**float64)(__ccgo_up(a + uintptr(i)*8)) = float64(Float64FromFloat64(1) / float64(Int32FromInt32(1)< %v", r) }() + } + return int32(PAGESIZE) +} + +const B0 = 0 +const B1000000 = 4104 +const B110 = 3 +const B115200 = 4098 +const B1152000 = 4105 +const B1200 = 9 +const B134 = 4 +const B150 = 5 +const B1500000 = 4106 +const B1800 = 10 +const B19200 = 14 +const B200 = 6 +const B2000000 = 4107 +const B230400 = 4099 +const B2400 = 11 +const B2500000 = 4108 +const B300 = 7 +const B3000000 = 4109 +const B3500000 = 4110 +const B38400 = 15 +const B4000000 = 4111 +const B460800 = 4100 +const B4800 = 12 +const B50 = 1 +const B500000 = 4101 +const B57600 = 4097 +const B576000 = 4102 +const B600 = 8 +const B75 = 2 +const B921600 = 4103 +const B9600 = 13 +const BRKINT = 2 +const BS0 = 0 +const BS1 = 8192 +const BSDLY = 8192 +const CBAUD = 4111 +const CBAUDEX = 4096 +const CIBAUD = 269418496 +const CLOCAL = 2048 +const CMSPAR = 1073741824 +const CR0 = 0 +const CR1 = 512 +const CR2 = 1024 +const CR3 = 1536 +const CRDLY = 1536 +const CREAD = 128 +const CRTSCTS = 2147483648 +const CS5 = 0 +const CS6 = 16 +const CS7 = 32 +const CS8 = 48 +const CSIZE = 48 +const CSTOPB = 64 +const ECHO = 8 +const ECHOCTL = 512 +const ECHOE = 16 +const ECHOK = 32 +const ECHOKE = 2048 +const ECHONL = 64 +const ECHOPRT = 1024 +const EXTA = 14 +const EXTB = 15 +const EXTPROC = 65536 +const FF0 = 0 +const FF1 = 32768 +const FFDLY = 32768 +const FLUSHO = 4096 +const HUPCL = 1024 +const ICANON = 2 +const ICRNL = 256 +const IEXTEN = 32768 +const IGNBRK = 1 +const IGNCR = 128 +const IGNPAR = 4 +const IMAXBEL = 8192 +const INLCR = 64 +const INPCK = 16 +const ISIG = 1 +const ISTRIP = 32 +const IUCLC = 512 +const IUTF8 = 16384 +const IXANY = 2048 +const IXOFF = 4096 +const IXON = 1024 +const NCCS = 32 +const NL0 = 0 +const NL1 = 256 +const NLDLY = 256 +const NOFLSH = 128 +const OCRNL = 8 +const OFDEL = 128 +const OFILL = 64 +const OLCUC = 2 +const ONLCR = 4 +const ONLRET = 32 +const ONOCR = 16 +const OPOST = 1 +const PARENB = 256 +const PARMRK = 8 +const PARODD = 512 +const PENDIN = 16384 +const TAB0 = 0 +const TAB1 = 2048 +const TAB2 = 4096 +const TAB3 = 6144 +const TABDLY = 6144 +const TCIFLUSH = 0 +const TCIOFF = 2 +const TCIOFLUSH = 2 +const TCION = 3 +const TCOFLUSH = 1 +const TCOOFF = 0 +const TCOON = 1 +const TCSADRAIN = 1 +const TCSAFLUSH = 2 +const TCSANOW = 0 +const TOSTOP = 256 +const VDISCARD = 13 +const VEOF = 4 +const VEOL = 11 +const VEOL2 = 16 +const VERASE = 2 +const VINTR = 0 +const VKILL = 3 +const VLNEXT = 15 +const VMIN = 6 +const VQUIT = 1 +const VREPRINT = 12 +const VSTART = 8 +const VSTOP = 9 +const VSUSP = 10 +const VSWTC = 7 +const VT0 = 0 +const VT1 = 16384 +const VTDLY = 16384 +const VTIME = 5 +const VWERASE = 14 +const XCASE = 4 +const XTABS = 6144 + +type Twinsize = struct { + Fws_row uint16 + Fws_col uint16 + Fws_xpixel uint16 + Fws_ypixel uint16 +} + +type Tcc_t = uint8 + +type Tspeed_t = uint32 + +type Ttcflag_t = uint32 + +type Ttermios = struct { + Fc_iflag Ttcflag_t + Fc_oflag Ttcflag_t + Fc_cflag Ttcflag_t + Fc_lflag Ttcflag_t + Fc_line Tcc_t + Fc_cc [32]Tcc_t + F__c_ispeed Tspeed_t + F__c_ospeed Tspeed_t +} + +func Xgetpass(tls *TLS, prompt uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v prompt=%v, (%v:)", tls, prompt, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var fd, v1 int32 + var l Tssize_t + var v2 uintptr + var _ /* s at bp+0 */ Ttermios + var _ /* t at bp+60 */ Ttermios + _, _, _, _ = fd, l, v1, v2 + v1 = Xopen(tls, __ccgo_ts+358, Int32FromInt32(O_RDWR)|Int32FromInt32(O_NOCTTY)|Int32FromInt32(O_CLOEXEC), 0) + fd = v1 + if v1 < 0 { + return uintptr(0) + } + Xtcgetattr(tls, fd, bp+60) + **(**Ttermios)(__ccgo_up(bp)) = **(**Ttermios)(__ccgo_up(bp + 60)) + (**(**Ttermios)(__ccgo_up(bp + 60))).Fc_lflag &= Uint32FromInt32(^(Int32FromInt32(ECHO) | Int32FromInt32(ISIG))) + (**(**Ttermios)(__ccgo_up(bp + 60))).Fc_lflag |= uint32(ICANON) + (**(**Ttermios)(__ccgo_up(bp + 60))).Fc_iflag &= Uint32FromInt32(^(Int32FromInt32(INLCR) | Int32FromInt32(IGNCR))) + (**(**Ttermios)(__ccgo_up(bp + 60))).Fc_iflag |= uint32(ICRNL) + Xtcsetattr(tls, fd, int32(TCSAFLUSH), bp+60) + Xtcdrain(tls, fd) + Xdprintf(tls, fd, __ccgo_ts+15, VaList(bp+128, prompt)) + l = Xread(tls, fd, uintptr(unsafe.Pointer(&_password)), uint64(128)) + if l >= 0 { + if l > 0 && int32(_password[l-int64(1)]) == int32('\n') || Uint64FromInt64(l) == uint64(128) { + l = l - 1 + } + _password[l] = 0 + } + Xtcsetattr(tls, fd, int32(TCSAFLUSH), bp) + Xdprintf(tls, fd, __ccgo_ts+367, 0) + Xclose(tls, fd) + if l < 0 { + v2 = uintptr(0) + } else { + v2 = uintptr(unsafe.Pointer(&_password)) + } + return v2 +} + +var _password [128]int8 + +var _defshells = [18]int8{'/', 'b', 'i', 'n', '/', 's', 'h', 10, '/', 'b', 'i', 'n', '/', 'c', 's', 'h', 10} + +var _line uintptr +var _linesize Tsize_t +var _f uintptr + +func Xendusershell(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + if _f != 0 { + Xfclose(tls, _f) + } + _f = uintptr(0) +} + +func Xsetusershell(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + if !(_f != 0) { + _f = Xfopen(tls, __ccgo_ts+369, __ccgo_ts+381) + } + if !(_f != 0) { + _f = Xfmemopen(tls, uintptr(unsafe.Pointer(&_defshells)), Uint64FromInt64(18)-Uint64FromInt32(1), __ccgo_ts+385) + } +} + +func Xgetusershell(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tssize_t + _ = l + if !(_f != 0) { + Xsetusershell(tls) + } + if !(_f != 0) { + return uintptr(0) + } + l = Xgetline(tls, uintptr(unsafe.Pointer(&_line)), uintptr(unsafe.Pointer(&_linesize)), _f) + if l <= 0 { + return uintptr(0) + } + if int32(**(**int8)(__ccgo_up(_line + uintptr(l-int64(1))))) == int32('\n') { + **(**int8)(__ccgo_up(_line + uintptr(l-int64(1)))) = 0 + } + return _line +} + +const ANYMARK = 1 +const FLUSHBAND = 4 +const FLUSHR = 1 +const FLUSHRW = 3 +const FLUSHW = 2 +const FMNAMESZ = 8 +const I_ATMARK = 21279 +const I_CANPUT = 21282 +const I_CKBAND = 21277 +const I_FDINSERT = 21264 +const I_FIND = 21259 +const I_FLUSH = 21253 +const I_FLUSHBAND = 21276 +const I_GETBAND = 21278 +const I_GETCLTIME = 21281 +const I_GETSIG = 21258 +const I_GRDOPT = 21255 +const I_GWROPT = 21268 +const I_LINK = 21260 +const I_LIST = 21269 +const I_LOOK = 21252 +const I_NREAD = 21249 +const I_PEEK = 21263 +const I_PLINK = 21270 +const I_POP = 21251 +const I_PUNLINK = 21271 +const I_PUSH = 21250 +const I_RECVFD = 21262 +const I_SENDFD = 21265 +const I_SETCLTIME = 21280 +const I_SETSIG = 21257 +const I_SRDOPT = 21254 +const I_STR = 21256 +const I_SWROPT = 21267 +const I_UNLINK = 21261 +const LASTMARK = 2 +const MORECTL = 1 +const MOREDATA = 2 +const MSG_ANY = 2 +const MSG_BAND = 4 +const MSG_HIPRI = 1 +const MUXID_ALL = -1 +const RMSGD = 1 +const RMSGN = 2 +const RNORM = 0 +const RPROTDAT = 4 +const RPROTDIS = 8 +const RPROTMASK = 28 +const RPROTNORM = 16 +const RS_HIPRI = 1 +const SNDPIPE = 2 +const SNDZERO = 1 +const S_BANDURG = 512 +const S_ERROR = 16 +const S_HANGUP = 32 +const S_HIPRI = 2 +const S_INPUT = 1 +const S_MSG = 8 +const S_OUTPUT = 4 +const S_RDBAND = 128 +const S_RDNORM = 64 +const S_WRBAND = 256 +const S_WRNORM = 4 +const __SID = 21248 + +type Tbandinfo = struct { + Fbi_pri uint8 + Fbi_flag int32 +} + +type Tstrbuf = struct { + Fmaxlen int32 + Flen1 int32 + Fbuf uintptr +} + +type Tstrpeek = struct { + Fctlbuf Tstrbuf + Fdatabuf Tstrbuf + Fflags uint32 +} + +type Tstrfdinsert = struct { + Fctlbuf Tstrbuf + Fdatabuf Tstrbuf + Fflags uint32 + Ffildes int32 + Foffset int32 +} + +type Tstrioctl = struct { + Fic_cmd int32 + Fic_timout int32 + Fic_len int32 + Fic_dp uintptr +} + +type Tstrrecvfd = struct { + Ffd int32 + Fuid int32 + Fgid int32 + F__fill [8]int8 +} + +type Tstr_mlist = struct { + Fl_name [9]int8 +} + +type Tstr_list = struct { + Fsl_nmods int32 + Fsl_modlist uintptr +} + +func Xisastream(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if Xfcntl(tls, fd, int32(F_GETFD), 0) < 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xlutimes(tls *TLS, filename uintptr, tv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v tv=%v, (%v:)", tls, filename, tv, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1 uintptr + var _ /* times at bp+0 */ [2]Ttimespec + _ = v1 + if tv != 0 { + (**(**[2]Ttimespec)(__ccgo_up(bp)))[0].Ftv_sec = (**(**Ttimeval)(__ccgo_up(tv))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[0].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(tv))).Ftv_usec * int64(1000) + (**(**[2]Ttimespec)(__ccgo_up(bp)))[int32(1)].Ftv_sec = (**(**Ttimeval)(__ccgo_up(tv + 1*16))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[int32(1)].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(tv + 1*16))).Ftv_usec * int64(1000) + } + if tv != 0 { + v1 = bp + } else { + v1 = uintptr(0) + } + return Xutimensat(tls, -int32(100), filename, v1, int32(AT_SYMLINK_NOFOLLOW)) +} + +const UL_GETFSIZE = 1 +const UL_SETFSIZE = 2 + +func Xulimit(tls *TLS, cmd int32, va uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v cmd=%v va=%v, (%v:)", tls, cmd, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ap Tva_list + var val int64 + var _ /* rl at bp+0 */ Trlimit + _, _ = ap, val + Xgetrlimit(tls, int32(RLIMIT_FSIZE), bp) + if cmd == int32(UL_SETFSIZE) { + ap = va + val = VaInt64(&ap) + _ = ap + (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur = uint64(512) * Uint64FromInt64(val) + if Xsetrlimit(tls, int32(RLIMIT_FSIZE), bp) != 0 { + return int64(-int32(1)) + } + } + return Int64FromUint64((**(**Trlimit)(__ccgo_up(bp))).Frlim_cur / uint64(512)) +} + +const BOOT_TIME = 2 +const DEAD_PROCESS = 8 +const EMPTY = 0 +const INIT_PROCESS = 5 +const LOGIN_PROCESS = 6 +const NEW_TIME = 3 +const OLD_TIME = 4 +const RUN_LVL = 1 +const USER_PROCESS = 7 +const e_exit = 0 +const e_termination = 0 + +type Tutmpx = struct { + Fut_type int16 + F__ut_pad1 int16 + Fut_pid Tpid_t + Fut_line [32]int8 + Fut_id [4]int8 + Fut_user [32]int8 + Fut_host [256]int8 + Fut_exit struct { + F__e_termination int16 + F__e_exit int16 + } + Fut_session int32 + F__ut_pad2 int32 + Fut_tv Ttimeval + Fut_addr_v6 [4]uint32 + F__unused [20]int8 +} + +func Xendutxent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xsetutxent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xgetutxent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return UintptrFromInt32(0) +} + +func Xgetutxid(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return UintptrFromInt32(0) +} + +func Xgetutxline(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return UintptrFromInt32(0) +} + +func Xpututxline(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return UintptrFromInt32(0) +} + +func Xupdwtmpx(tls *TLS, f uintptr, u uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v u=%v, (%v:)", tls, f, u, origin(2)) + } +} + +func ___utmpxname(tls *TLS, f uintptr) (r int32) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOPNOTSUPP) + return -int32(1) +} + +func Xendutent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xendutxent(tls) +} + +func Xgetutent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetutxent(tls) +} + +func Xgetutid(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetutxid(tls, ut) +} + +func Xgetutline(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetutxline(tls, ut) +} + +func Xpututline(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xpututxline(tls, ut) +} + +func Xsetutent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xsetutxent(tls) +} + +func Xupdwtmp(tls *TLS, f uintptr, u uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v u=%v, (%v:)", tls, f, u, origin(2)) + } + Xupdwtmpx(tls, f, u) +} + +const ADJ_ESTERROR = 8 +const ADJ_FREQUENCY = 2 +const ADJ_MAXERROR = 4 +const ADJ_MICRO = 4096 +const ADJ_NANO = 8192 +const ADJ_OFFSET = 1 +const ADJ_OFFSET_SINGLESHOT = 32769 +const ADJ_OFFSET_SS_READ = 40961 +const ADJ_SETOFFSET = 256 +const ADJ_STATUS = 16 +const ADJ_TAI = 128 +const ADJ_TICK = 16384 +const ADJ_TIMECONST = 32 +const MAXTC = 6 +const MOD_CLKA = 32769 +const MOD_CLKB = 16384 +const MOD_ESTERROR = 8 +const MOD_FREQUENCY = 2 +const MOD_MAXERROR = 4 +const MOD_MICRO = 4096 +const MOD_NANO = 8192 +const MOD_OFFSET = 1 +const MOD_STATUS = 16 +const MOD_TAI = 128 +const MOD_TIMECONST = 32 +const STA_CLK = 32768 +const STA_CLOCKERR = 4096 +const STA_DEL = 32 +const STA_FLL = 8 +const STA_FREQHOLD = 128 +const STA_INS = 16 +const STA_MODE = 16384 +const STA_NANO = 8192 +const STA_PLL = 1 +const STA_PPSERROR = 2048 +const STA_PPSFREQ = 2 +const STA_PPSJITTER = 512 +const STA_PPSSIGNAL = 256 +const STA_PPSTIME = 4 +const STA_PPSWANDER = 1024 +const STA_RONLY = 65280 +const STA_UNSYNC = 64 +const TIME_BAD = 5 +const TIME_DEL = 2 +const TIME_ERROR = 5 +const TIME_INS = 1 +const TIME_OK = 0 +const TIME_OOP = 3 +const TIME_WAIT = 4 + +type Tntptimeval = struct { + Ftime Ttimeval + Fmaxerror int64 + Festerror int64 +} + +type Ttimex = struct { + Fmodes uint32 + Foffset int64 + Ffreq int64 + Fmaxerror int64 + Festerror int64 + Fstatus int32 + Fconstant int64 + Fprecision int64 + Ftolerance int64 + Ftime Ttimeval + Ftick int64 + Fppsfreq int64 + Fjitter int64 + Fshift int32 + Fstabil int64 + Fjitcnt int64 + Fcalcnt int64 + Ferrcnt int64 + Fstbcnt int64 + Ftai int32 + F__padding [11]int32 +} + +func Xadjtime(tls *TLS, in uintptr, out uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v in=%v out=%v, (%v:)", tls, in, out, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(208) + defer tls.Free(208) + var v1 Tsuseconds_t + var _ /* tx at bp+0 */ Ttimex + _ = v1 + **(**Ttimex)(__ccgo_up(bp)) = Ttimex{} + if in != 0 { + if (*Ttimeval)(unsafe.Pointer(in)).Ftv_sec > int64(1000) || (*Ttimeval)(unsafe.Pointer(in)).Ftv_usec > int64(1000000000) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + (**(**Ttimex)(__ccgo_up(bp))).Foffset = (*Ttimeval)(unsafe.Pointer(in)).Ftv_sec*int64(1000000) + (*Ttimeval)(unsafe.Pointer(in)).Ftv_usec + (**(**Ttimex)(__ccgo_up(bp))).Fmodes = uint32(ADJ_OFFSET_SINGLESHOT) + } + if Xadjtimex(tls, bp) < 0 { + return -int32(1) + } + if out != 0 { + (*Ttimeval)(unsafe.Pointer(out)).Ftv_sec = (**(**Ttimex)(__ccgo_up(bp))).Foffset / int64(1000000) + v1 = (**(**Ttimex)(__ccgo_up(bp))).Foffset % Int64FromInt32(1000000) + (*Ttimeval)(unsafe.Pointer(out)).Ftv_usec = v1 + if v1 < 0 { + (*Ttimeval)(unsafe.Pointer(out)).Ftv_sec = (*Ttimeval)(unsafe.Pointer(out)).Ftv_sec - 1 + **(**Tsuseconds_t)(__ccgo_up(out + 8)) += int64(1000000) + } + } + return 0 +} + +func Xadjtimex(tls *TLS, tx uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v tx=%v, (%v:)", tls, tx, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xclock_adjtime(tls, CLOCK_REALTIME, tx) +} + +func Xarch_prctl(tls *TLS, code int32, addr uint64) (r int32) { + if __ccgo_strace { + trc("tls=%v code=%v addr=%v, (%v:)", tls, code, addr, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_arch_prctl), int64(code), Int64FromUint64(addr))))) +} + +func Xbrk(tls *TLS, end uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v end=%v, (%v:)", tls, end, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(ENOMEM)))) +} + +func Xcapset(tls *TLS, a uintptr, b uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_capset), int64(a), int64(b))))) +} + +func Xcapget(tls *TLS, a uintptr, b uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_capget), int64(a), int64(b))))) +} + +func Xchroot(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_chroot), int64(path))))) +} + +type Tktimex64 = struct { + Fmodes uint32 + F__ccgo4 uint32 + Foffset int64 + Ffreq int64 + Fmaxerror int64 + Festerror int64 + Fstatus int32 + F__ccgo44 uint32 + Fconstant int64 + Fprecision int64 + Ftolerance int64 + Ftime_sec int64 + Ftime_usec int64 + Ftick int64 + Fppsfreq int64 + Fjitter int64 + Fshift int32 + F__ccgo116 uint32 + Fstabil int64 + Fjitcnt int64 + Fcalcnt int64 + Ferrcnt int64 + Fstbcnt int64 + Ftai int32 + F__padding [11]int32 +} + +type Tktimex = struct { + Fmodes uint32 + Foffset int64 + Ffreq int64 + Fmaxerror int64 + Festerror int64 + Fstatus int32 + Fconstant int64 + Fprecision int64 + Ftolerance int64 + Ftime_sec int64 + Ftime_usec int64 + Ftick int64 + Fppsfreq int64 + Fjitter int64 + Fshift int32 + Fstabil int64 + Fjitcnt int64 + Fcalcnt int64 + Ferrcnt int64 + Fstbcnt int64 + Ftai int32 + F__padding [11]int32 +} + +func Xclock_adjtime(tls *TLS, clock_id Tclockid_t, utx uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v clock_id=%v utx=%v, (%v:)", tls, clock_id, utx, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(208) + defer tls.Free(208) + var r int32 + var _ /* ktx at bp+0 */ Tktimex + _ = r + r = -int32(ENOSYS) + if uint64(8) > uint64(8) { + **(**Tktimex)(__ccgo_up(bp)) = Tktimex{ + Fmodes: (*Ttimex)(unsafe.Pointer(utx)).Fmodes, + Foffset: (*Ttimex)(unsafe.Pointer(utx)).Foffset, + Ffreq: (*Ttimex)(unsafe.Pointer(utx)).Ffreq, + Fmaxerror: (*Ttimex)(unsafe.Pointer(utx)).Fmaxerror, + Festerror: (*Ttimex)(unsafe.Pointer(utx)).Festerror, + Fstatus: (*Ttimex)(unsafe.Pointer(utx)).Fstatus, + Fconstant: (*Ttimex)(unsafe.Pointer(utx)).Fconstant, + Fprecision: (*Ttimex)(unsafe.Pointer(utx)).Fprecision, + Ftolerance: (*Ttimex)(unsafe.Pointer(utx)).Ftolerance, + Ftime_sec: (*Ttimex)(unsafe.Pointer(utx)).Ftime.Ftv_sec, + Ftime_usec: (*Ttimex)(unsafe.Pointer(utx)).Ftime.Ftv_usec, + Ftick: (*Ttimex)(unsafe.Pointer(utx)).Ftick, + Fppsfreq: (*Ttimex)(unsafe.Pointer(utx)).Fppsfreq, + Fjitter: (*Ttimex)(unsafe.Pointer(utx)).Fjitter, + Fshift: (*Ttimex)(unsafe.Pointer(utx)).Fshift, + Fstabil: (*Ttimex)(unsafe.Pointer(utx)).Fstabil, + Fjitcnt: (*Ttimex)(unsafe.Pointer(utx)).Fjitcnt, + Fcalcnt: (*Ttimex)(unsafe.Pointer(utx)).Fcalcnt, + Ferrcnt: (*Ttimex)(unsafe.Pointer(utx)).Ferrcnt, + Fstbcnt: (*Ttimex)(unsafe.Pointer(utx)).Fstbcnt, + Ftai: (*Ttimex)(unsafe.Pointer(utx)).Ftai, + } + if clock_id == CLOCK_REALTIME { + r = int32(X__syscall1(tls, int64(SYS_adjtimex), int64(bp))) + } else { + r = int32(X__syscall2(tls, int64(SYS_clock_adjtime), int64(clock_id), int64(bp))) + } + if r >= 0 { + (*Ttimex)(unsafe.Pointer(utx)).Fmodes = (**(**Tktimex)(__ccgo_up(bp))).Fmodes + (*Ttimex)(unsafe.Pointer(utx)).Foffset = (**(**Tktimex)(__ccgo_up(bp))).Foffset + (*Ttimex)(unsafe.Pointer(utx)).Ffreq = (**(**Tktimex)(__ccgo_up(bp))).Ffreq + (*Ttimex)(unsafe.Pointer(utx)).Fmaxerror = (**(**Tktimex)(__ccgo_up(bp))).Fmaxerror + (*Ttimex)(unsafe.Pointer(utx)).Festerror = (**(**Tktimex)(__ccgo_up(bp))).Festerror + (*Ttimex)(unsafe.Pointer(utx)).Fstatus = (**(**Tktimex)(__ccgo_up(bp))).Fstatus + (*Ttimex)(unsafe.Pointer(utx)).Fconstant = (**(**Tktimex)(__ccgo_up(bp))).Fconstant + (*Ttimex)(unsafe.Pointer(utx)).Fprecision = (**(**Tktimex)(__ccgo_up(bp))).Fprecision + (*Ttimex)(unsafe.Pointer(utx)).Ftolerance = (**(**Tktimex)(__ccgo_up(bp))).Ftolerance + (*Ttimex)(unsafe.Pointer(utx)).Ftime.Ftv_sec = (**(**Tktimex)(__ccgo_up(bp))).Ftime_sec + (*Ttimex)(unsafe.Pointer(utx)).Ftime.Ftv_usec = (**(**Tktimex)(__ccgo_up(bp))).Ftime_usec + (*Ttimex)(unsafe.Pointer(utx)).Ftick = (**(**Tktimex)(__ccgo_up(bp))).Ftick + (*Ttimex)(unsafe.Pointer(utx)).Fppsfreq = (**(**Tktimex)(__ccgo_up(bp))).Fppsfreq + (*Ttimex)(unsafe.Pointer(utx)).Fjitter = (**(**Tktimex)(__ccgo_up(bp))).Fjitter + (*Ttimex)(unsafe.Pointer(utx)).Fshift = (**(**Tktimex)(__ccgo_up(bp))).Fshift + (*Ttimex)(unsafe.Pointer(utx)).Fstabil = (**(**Tktimex)(__ccgo_up(bp))).Fstabil + (*Ttimex)(unsafe.Pointer(utx)).Fjitcnt = (**(**Tktimex)(__ccgo_up(bp))).Fjitcnt + (*Ttimex)(unsafe.Pointer(utx)).Fcalcnt = (**(**Tktimex)(__ccgo_up(bp))).Fcalcnt + (*Ttimex)(unsafe.Pointer(utx)).Ferrcnt = (**(**Tktimex)(__ccgo_up(bp))).Ferrcnt + (*Ttimex)(unsafe.Pointer(utx)).Fstbcnt = (**(**Tktimex)(__ccgo_up(bp))).Fstbcnt + (*Ttimex)(unsafe.Pointer(utx)).Ftai = (**(**Tktimex)(__ccgo_up(bp))).Ftai + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + if clock_id == CLOCK_REALTIME { + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_adjtimex), int64(utx))))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_clock_adjtime), int64(clock_id), int64(utx))))) +} + +func Xcopy_file_range(tls *TLS, fd_in int32, off_in uintptr, fd_out int32, off_out uintptr, len1 Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd_in=%v off_in=%v fd_out=%v off_out=%v len1=%v flags=%v, (%v:)", tls, fd_in, off_in, fd_out, off_out, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, int64(SYS_copy_file_range), int64(fd_in), int64(off_in), int64(fd_out), int64(off_out), Int64FromUint64(len1), Int64FromUint32(flags)))) +} + +const EPOLLERR = 8 +const EPOLLET = 2147483648 +const EPOLLEXCLUSIVE = 268435456 +const EPOLLHUP = 16 +const EPOLLIN = 1 +const EPOLLMSG = 1024 +const EPOLLNVAL = 32 +const EPOLLONESHOT = 1073741824 +const EPOLLOUT = 4 +const EPOLLPRI = 2 +const EPOLLRDBAND = 128 +const EPOLLRDHUP = 8192 +const EPOLLRDNORM = 64 +const EPOLLWAKEUP = 536870912 +const EPOLLWRBAND = 512 +const EPOLLWRNORM = 256 +const EPOLL_CLOEXEC = 524288 +const EPOLL_CTL_ADD = 1 +const EPOLL_CTL_DEL = 2 +const EPOLL_CTL_MOD = 3 +const EPOLL_NONBLOCK = 2048 + +type Tfsblkcnt_t = uint64 + +type Tfsfilcnt_t = uint64 + +type _EPOLL_EVENTS = int32 + +const ___EPOLL_DUMMY = 0 + +type Tepoll_data_t = struct { + Ffd [0]int32 + Fu32 [0]Tuint32_t + Fu64 [0]Tuint64_t + Fptr uintptr +} + +type Tepoll_data = Tepoll_data_t + +type Tepoll_event = struct { + Fevents Tuint32_t + Fdata Tepoll_data_t +} + +func Xepoll_create(tls *TLS, size int32) (r int32) { + if __ccgo_strace { + trc("tls=%v size=%v, (%v:)", tls, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + if size <= 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + return Xepoll_create1(tls, 0) +} + +func Xepoll_create1(tls *TLS, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall1(tls, int64(SYS_epoll_create1), int64(flags))) + if r == -int32(ENOSYS) && !(flags != 0) { + r = int32(X__syscall1(tls, int64(SYS_epoll_create), int64(Int32FromInt32(1)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xepoll_ctl(tls *TLS, fd int32, op int32, fd2 int32, ev uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v op=%v fd2=%v ev=%v, (%v:)", tls, fd, op, fd2, ev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_epoll_ctl), int64(fd), int64(op), int64(fd2), int64(ev))))) +} + +func Xepoll_pwait(tls *TLS, fd int32, ev uintptr, cnt int32, to int32, sigs uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v ev=%v cnt=%v to=%v sigs=%v, (%v:)", tls, fd, ev, cnt, to, sigs, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(___syscall_cp(tls, int64(SYS_epoll_pwait), int64(fd), int64(ev), int64(cnt), int64(to), int64(sigs), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)))) + if r == -int32(ENOSYS) && !(sigs != 0) { + r = int32(___syscall_cp(tls, int64(SYS_epoll_wait), int64(fd), int64(ev), int64(cnt), int64(to), 0, 0)) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xepoll_wait(tls *TLS, fd int32, ev uintptr, cnt int32, to int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v ev=%v cnt=%v to=%v, (%v:)", tls, fd, ev, cnt, to, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xepoll_pwait(tls, fd, ev, cnt, to, uintptr(0)) +} + +const EFD_CLOEXEC = 524288 +const EFD_NONBLOCK = 2048 +const EFD_SEMAPHORE = 1 + +type Teventfd_t = uint64 + +func Xeventfd(tls *TLS, count uint32, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v count=%v flags=%v, (%v:)", tls, count, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall2(tls, int64(SYS_eventfd2), Int64FromUint32(count), int64(flags))) + if r == -int32(ENOSYS) && !(flags != 0) { + r = int32(X__syscall1(tls, int64(SYS_eventfd), Int64FromUint32(count))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xeventfd_read(tls *TLS, fd int32, value uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v value=%v, (%v:)", tls, fd, value, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if uint64(8) == Uint64FromInt64(Xread(tls, fd, value, uint64(8))) { + v1 = 0 + } else { + v1 = -int32(1) + } + return v1 +} + +func Xeventfd_write(tls *TLS, fd int32, _value Teventfd_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v _value=%v, (%v:)", tls, fd, _value, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*Teventfd_t)(unsafe.Pointer(bp)) = _value + var v1 int32 + _ = v1 + if uint64(8) == Uint64FromInt64(Xwrite(tls, fd, bp, uint64(8))) { + v1 = 0 + } else { + v1 = -int32(1) + } + return v1 +} + +func Xfallocate(tls *TLS, fd int32, mode int32, base Toff_t, len1 Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v mode=%v base=%v len1=%v, (%v:)", tls, fd, mode, base, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_fallocate), int64(fd), int64(mode), base, len1)))) +} + +const FANOTIFY_METADATA_VERSION = 3 +const FAN_ACCESS = 1 +const FAN_ACCESS_PERM = 131072 +const FAN_ALLOW = 1 +const FAN_ALL_CLASS_BITS = 12 +const FAN_ALL_EVENTS = 59 +const FAN_ALL_INIT_FLAGS = 63 +const FAN_ALL_MARK_FLAGS = 255 +const FAN_ALL_OUTGOING_EVENTS = 213051 +const FAN_ALL_PERM_EVENTS = 196608 +const FAN_ATTRIB = 4 +const FAN_AUDIT = 16 +const FAN_CLASS_CONTENT = 4 +const FAN_CLASS_NOTIF = 0 +const FAN_CLASS_PRE_CONTENT = 8 +const FAN_CLOEXEC = 1 +const FAN_CLOSE = 24 +const FAN_CLOSE_NOWRITE = 16 +const FAN_CLOSE_WRITE = 8 +const FAN_CREATE = 256 +const FAN_DELETE = 512 +const FAN_DELETE_SELF = 1024 +const FAN_DENY = 2 +const FAN_DIR_MODIFY = 524288 +const FAN_ENABLE_AUDIT = 64 +const FAN_EVENT_INFO_TYPE_DFID = 3 +const FAN_EVENT_INFO_TYPE_DFID_NAME = 2 +const FAN_EVENT_INFO_TYPE_FID = 1 +const FAN_EVENT_METADATA_LEN = 0 +const FAN_EVENT_ON_CHILD = 134217728 +const FAN_MARK_ADD = 1 +const FAN_MARK_DONT_FOLLOW = 4 +const FAN_MARK_FILESYSTEM = 256 +const FAN_MARK_FLUSH = 128 +const FAN_MARK_IGNORED_MASK = 32 +const FAN_MARK_IGNORED_SURV_MODIFY = 64 +const FAN_MARK_INODE = 0 +const FAN_MARK_MOUNT = 16 +const FAN_MARK_ONLYDIR = 8 +const FAN_MARK_REMOVE = 2 +const FAN_MARK_TYPE_MASK = 272 +const FAN_MODIFY = 2 +const FAN_MOVE = 192 +const FAN_MOVED_FROM = 64 +const FAN_MOVED_TO = 128 +const FAN_MOVE_SELF = 2048 +const FAN_NOFD = -1 +const FAN_NONBLOCK = 2 +const FAN_ONDIR = 1073741824 +const FAN_OPEN = 32 +const FAN_OPEN_EXEC = 4096 +const FAN_OPEN_EXEC_PERM = 262144 +const FAN_OPEN_PERM = 65536 +const FAN_Q_OVERFLOW = 16384 +const FAN_REPORT_DFID_NAME = 3072 +const FAN_REPORT_DIR_FID = 1024 +const FAN_REPORT_FID = 512 +const FAN_REPORT_NAME = 2048 +const FAN_REPORT_TID = 256 +const FAN_UNLIMITED_MARKS = 32 +const FAN_UNLIMITED_QUEUE = 16 +const ST_APPEND = 256 +const ST_IMMUTABLE = 512 +const ST_MANDLOCK = 64 +const ST_NOATIME = 1024 +const ST_NODEV = 4 +const ST_NODIRATIME = 2048 +const ST_NOEXEC = 8 +const ST_NOSUID = 2 +const ST_RDONLY = 1 +const ST_RELATIME = 4096 +const ST_SYNCHRONOUS = 16 +const ST_WRITE = 128 + +type Tstatvfs = struct { + Ff_bsize uint64 + Ff_frsize uint64 + Ff_blocks Tfsblkcnt_t + Ff_bfree Tfsblkcnt_t + Ff_bavail Tfsblkcnt_t + Ff_files Tfsfilcnt_t + Ff_ffree Tfsfilcnt_t + Ff_favail Tfsfilcnt_t + Ff_fsid uint64 + Ff_flag uint64 + Ff_namemax uint64 + Ff_type uint32 + F__reserved [5]int32 +} + +type Tfsid_t = struct { + F__val [2]int32 +} + +type t__fsid_t = Tfsid_t + +type Tstatfs = struct { + Ff_type uint64 + Ff_bsize uint64 + Ff_blocks Tfsblkcnt_t + Ff_bfree Tfsblkcnt_t + Ff_bavail Tfsblkcnt_t + Ff_files Tfsfilcnt_t + Ff_ffree Tfsfilcnt_t + Ff_fsid Tfsid_t + Ff_namelen uint64 + Ff_frsize uint64 + Ff_flags uint64 + Ff_spare [4]uint64 +} + +type Tfanotify_event_metadata = struct { + Fevent_len uint32 + Fvers uint8 + Freserved uint8 + Fmetadata_len uint16 + Fmask uint64 + Ffd int32 + Fpid int32 +} + +type Tfanotify_event_info_header = struct { + Finfo_type uint8 + Fpad uint8 + Flen1 uint16 +} + +type Tfanotify_event_info_fid = struct { + Fhdr Tfanotify_event_info_header + Ffsid Tfsid_t +} + +type Tfanotify_response = struct { + Ffd int32 + Fresponse uint32 +} + +func Xfanotify_init(tls *TLS, flags uint32, event_f_flags uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v flags=%v event_f_flags=%v, (%v:)", tls, flags, event_f_flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_fanotify_init), Int64FromUint32(flags), Int64FromUint32(event_f_flags))))) +} + +func Xfanotify_mark(tls *TLS, fanotify_fd int32, flags uint32, mask uint64, dfd int32, pathname uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fanotify_fd=%v flags=%v mask=%v dfd=%v pathname=%v, (%v:)", tls, fanotify_fd, flags, mask, dfd, pathname, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fanotify_mark), int64(fanotify_fd), Int64FromUint32(flags), Int64FromUint64(mask), int64(dfd), int64(pathname))))) +} + +const LOCK_EX = 2 +const LOCK_NB = 4 +const LOCK_SH = 1 +const LOCK_UN = 8 + +func Xflock(tls *TLS, fd int32, op int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v op=%v, (%v:)", tls, fd, op, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_flock), int64(fd), int64(op))))) +} + +func Xgetdents(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v, (%v:)", tls, fd, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + if len1 > uint64(INT_MAX) { + len1 = uint64(INT_MAX) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_getdents64), int64(fd), int64(buf), Int64FromUint64(len1))))) +} + +const GRND_INSECURE = 4 +const GRND_NONBLOCK = 1 +const GRND_RANDOM = 2 + +func Xgetrandom(tls *TLS, buf uintptr, buflen Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v buf=%v buflen=%v flags=%v, (%v:)", tls, buf, buflen, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_getrandom), int64(buf), Int64FromUint64(buflen), Int64FromUint32(flags), 0, 0, 0))) +} + +const IN_ACCESS = 1 +const IN_ALL_EVENTS = 4095 +const IN_ATTRIB = 4 +const IN_CLOEXEC = 524288 +const IN_CLOSE = 24 +const IN_CLOSE_NOWRITE = 16 +const IN_CLOSE_WRITE = 8 +const IN_CREATE = 256 +const IN_DELETE = 512 +const IN_DELETE_SELF = 1024 +const IN_DONT_FOLLOW = 33554432 +const IN_EXCL_UNLINK = 67108864 +const IN_IGNORED = 32768 +const IN_ISDIR = 1073741824 +const IN_MASK_ADD = 536870912 +const IN_MASK_CREATE = 268435456 +const IN_MODIFY = 2 +const IN_MOVE = 192 +const IN_MOVED_FROM = 64 +const IN_MOVED_TO = 128 +const IN_MOVE_SELF = 2048 +const IN_NONBLOCK = 2048 +const IN_ONESHOT = 2147483648 +const IN_ONLYDIR = 16777216 +const IN_OPEN = 32 +const IN_Q_OVERFLOW = 16384 +const IN_UNMOUNT = 8192 + +type Tinotify_event = struct { + Fwd int32 + Fmask Tuint32_t + Fcookie Tuint32_t + Flen1 Tuint32_t +} + +func Xinotify_init(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xinotify_init1(tls, 0) +} + +func Xinotify_init1(tls *TLS, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall1(tls, int64(SYS_inotify_init1), int64(flags))) + if r == -int32(ENOSYS) && !(flags != 0) { + r = int32(X__syscall0(tls, int64(SYS_inotify_init))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xinotify_add_watch(tls *TLS, fd int32, pathname uintptr, mask Tuint32_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v pathname=%v mask=%v, (%v:)", tls, fd, pathname, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_inotify_add_watch), int64(fd), int64(pathname), Int64FromUint32(mask))))) +} + +func Xinotify_rm_watch(tls *TLS, fd int32, wd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v wd=%v, (%v:)", tls, fd, wd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_inotify_rm_watch), int64(fd), int64(wd))))) +} + +func Xioperm(tls *TLS, from uint64, num uint64, turn_on int32) (r int32) { + if __ccgo_strace { + trc("tls=%v from=%v num=%v turn_on=%v, (%v:)", tls, from, num, turn_on, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_ioperm), Int64FromUint64(from), Int64FromUint64(num), int64(turn_on))))) +} + +func Xiopl(tls *TLS, level int32) (r int32) { + if __ccgo_strace { + trc("tls=%v level=%v, (%v:)", tls, level, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_iopl), int64(level))))) +} + +func Xklogctl(tls *TLS, type1 int32, buf uintptr, len1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v type1=%v buf=%v len1=%v, (%v:)", tls, type1, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_syslog), int64(type1), int64(buf), int64(len1))))) +} + +const MADV_COLD = 20 +const MADV_DODUMP = 17 +const MADV_DOFORK = 11 +const MADV_DONTDUMP = 16 +const MADV_DONTFORK = 10 +const MADV_DONTNEED = 4 +const MADV_FREE = 8 +const MADV_HUGEPAGE = 14 +const MADV_HWPOISON = 100 +const MADV_KEEPONFORK = 19 +const MADV_MERGEABLE = 12 +const MADV_NOHUGEPAGE = 15 +const MADV_NORMAL = 0 +const MADV_PAGEOUT = 21 +const MADV_RANDOM = 1 +const MADV_REMOVE = 9 +const MADV_SEQUENTIAL = 2 +const MADV_SOFT_OFFLINE = 101 +const MADV_UNMERGEABLE = 13 +const MADV_WILLNEED = 3 +const MADV_WIPEONFORK = 18 +const MFD_ALLOW_SEALING = 2 +const MFD_CLOEXEC = 1 +const MFD_HUGETLB = 4 +const MLOCK_ONFAULT = 1 +const MREMAP_DONTUNMAP = 4 +const MREMAP_FIXED = 2 +const MREMAP_MAYMOVE = 1 +const _GNU_SOURCE = 1 + +func Xmemfd_create(tls *TLS, name uintptr, flags uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v flags=%v, (%v:)", tls, name, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_memfd_create), int64(name), Int64FromUint32(flags))))) +} + +func Xmlock2(tls *TLS, addr uintptr, len1 Tsize_t, flags uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v flags=%v, (%v:)", tls, addr, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + if flags == uint32(0) { + return Xmlock(tls, addr, len1) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mlock2), int64(addr), Int64FromUint64(len1), Int64FromUint32(flags))))) +} + +func Xinit_module(tls *TLS, a uintptr, b uint64, c uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v c=%v, (%v:)", tls, a, b, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_init_module), int64(a), Int64FromUint64(b), int64(c))))) +} + +func Xdelete_module(tls *TLS, a uintptr, b uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_delete_module), int64(a), Int64FromUint32(b))))) +} + +const BLKBSZGET = 2147488368 +const BLKBSZSET = 1073746545 +const BLKFLSBUF = 4705 +const BLKFRAGET = 4709 +const BLKFRASET = 4708 +const BLKGETSIZE = 4704 +const BLKGETSIZE64 = 2147488370 +const BLKRAGET = 4707 +const BLKRASET = 4706 +const BLKROGET = 4702 +const BLKROSET = 4701 +const BLKRRPART = 4703 +const BLKSECTGET = 4711 +const BLKSECTSET = 4710 +const BLKSSZGET = 4712 +const FIOASYNC = 21586 +const FIOCLEX = 21585 +const FIOGETOWN = 35075 +const FIONBIO = 21537 +const FIONCLEX = 21584 +const FIONREAD = 21531 +const FIOQSIZE = 21600 +const FIOSETOWN = 35073 +const MNT_DETACH = 2 +const MNT_EXPIRE = 4 +const MNT_FORCE = 1 +const MS_ACTIVE = 1073741824 +const MS_BIND = 4096 +const MS_BORN = 536870912 +const MS_DIRSYNC = 128 +const MS_I_VERSION = 8388608 +const MS_KERNMOUNT = 4194304 +const MS_LAZYTIME = 33554432 +const MS_MANDLOCK = 64 +const MS_MGC_MSK = 4294901760 +const MS_MGC_VAL = 3236757504 +const MS_MOVE = 8192 +const MS_NOATIME = 1024 +const MS_NODEV = 4 +const MS_NODIRATIME = 2048 +const MS_NOEXEC = 8 +const MS_NOREMOTELOCK = 134217728 +const MS_NOSEC = 268435456 +const MS_NOSUID = 2 +const MS_NOSYMFOLLOW = 256 +const MS_NOUSER = 2147483648 +const MS_POSIXACL = 65536 +const MS_PRIVATE = 262144 +const MS_RDONLY = 1 +const MS_REC = 16384 +const MS_RELATIME = 2097152 +const MS_REMOUNT = 32 +const MS_RMT_MASK = 41943121 +const MS_SHARED = 1048576 +const MS_SILENT = 32768 +const MS_SLAVE = 524288 +const MS_STRICTATIME = 16777216 +const MS_SYNCHRONOUS = 16 +const MS_UNBINDABLE = 131072 +const N_6PACK = 7 +const N_AX25 = 5 +const N_CAIF = 20 +const N_GIGASET_M101 = 16 +const N_GSM0710 = 21 +const N_HCI = 15 +const N_HDLC = 13 +const N_IRDA = 11 +const N_MASC = 8 +const N_MOUSE = 2 +const N_NCI = 25 +const N_NULL = 27 +const N_PPP = 3 +const N_PPS = 18 +const N_PROFIBUS_FDL = 10 +const N_R3964 = 9 +const N_SLCAN = 17 +const N_SLIP = 1 +const N_SMSBLOCK = 12 +const N_SPEAKUP = 26 +const N_STRIP = 4 +const N_SYNC_PPP = 14 +const N_TI_WL = 22 +const N_TRACEROUTER = 24 +const N_TRACESINK = 23 +const N_TTY = 0 +const N_V253 = 19 +const N_X25 = 6 +const SIOCADDDLCI = 35200 +const SIOCADDMULTI = 35121 +const SIOCADDRT = 35083 +const SIOCATMARK = 35077 +const SIOCDARP = 35155 +const SIOCDELDLCI = 35201 +const SIOCDELMULTI = 35122 +const SIOCDELRT = 35084 +const SIOCDEVPRIVATE = 35312 +const SIOCDIFADDR = 35126 +const SIOCDRARP = 35168 +const SIOCGARP = 35156 +const SIOCGIFADDR = 35093 +const SIOCGIFBR = 35136 +const SIOCGIFBRDADDR = 35097 +const SIOCGIFCONF = 35090 +const SIOCGIFCOUNT = 35128 +const SIOCGIFDSTADDR = 35095 +const SIOCGIFENCAP = 35109 +const SIOCGIFFLAGS = 35091 +const SIOCGIFHWADDR = 35111 +const SIOCGIFINDEX = 35123 +const SIOCGIFMAP = 35184 +const SIOCGIFMEM = 35103 +const SIOCGIFMETRIC = 35101 +const SIOCGIFMTU = 35105 +const SIOCGIFNAME = 35088 +const SIOCGIFNETMASK = 35099 +const SIOCGIFPFLAGS = 35125 +const SIOCGIFSLAVE = 35113 +const SIOCGIFTXQLEN = 35138 +const SIOCGPGRP = 35076 +const SIOCGRARP = 35169 +const SIOCGSTAMP = 35078 +const SIOCGSTAMPNS = 35079 +const SIOCPROTOPRIVATE = 35296 +const SIOCRTMSG = 35085 +const SIOCSARP = 35157 +const SIOCSIFADDR = 35094 +const SIOCSIFBR = 35137 +const SIOCSIFBRDADDR = 35098 +const SIOCSIFDSTADDR = 35096 +const SIOCSIFENCAP = 35110 +const SIOCSIFFLAGS = 35092 +const SIOCSIFHWADDR = 35108 +const SIOCSIFHWBROADCAST = 35127 +const SIOCSIFLINK = 35089 +const SIOCSIFMAP = 35185 +const SIOCSIFMEM = 35104 +const SIOCSIFMETRIC = 35102 +const SIOCSIFMTU = 35106 +const SIOCSIFNAME = 35107 +const SIOCSIFNETMASK = 35100 +const SIOCSIFPFLAGS = 35124 +const SIOCSIFSLAVE = 35120 +const SIOCSIFTXQLEN = 35139 +const SIOCSPGRP = 35074 +const SIOCSRARP = 35170 +const SIOGIFINDEX = 35123 +const TCFLSH = 21515 +const TCGETA = 21509 +const TCGETS = 21505 +const TCGETX = 21554 +const TCSBRK = 21513 +const TCSBRKP = 21541 +const TCSETA = 21510 +const TCSETAF = 21512 +const TCSETAW = 21511 +const TCSETS = 21506 +const TCSETSF = 21508 +const TCSETSW = 21507 +const TCSETX = 21555 +const TCSETXF = 21556 +const TCSETXW = 21557 +const TCXONC = 21514 +const TIOCCBRK = 21544 +const TIOCCONS = 21533 +const TIOCEXCL = 21516 +const TIOCGDEV = 2147767346 +const TIOCGETD = 21540 +const TIOCGEXCL = 2147767360 +const TIOCGICOUNT = 21597 +const TIOCGISO7816 = 2150126658 +const TIOCGLCKTRMIOS = 21590 +const TIOCGPGRP = 21519 +const TIOCGPKT = 2147767352 +const TIOCGPTLCK = 2147767353 +const TIOCGPTN = 2147767344 +const TIOCGPTPEER = 21569 +const TIOCGRS485 = 21550 +const TIOCGSERIAL = 21534 +const TIOCGSID = 21545 +const TIOCGSOFTCAR = 21529 +const TIOCGWINSZ = 21523 +const TIOCINQ = 21531 +const TIOCLINUX = 21532 +const TIOCMBIC = 21527 +const TIOCMBIS = 21526 +const TIOCMGET = 21525 +const TIOCMIWAIT = 21596 +const TIOCMSET = 21528 +const TIOCM_CAR = 64 +const TIOCM_CD = 64 +const TIOCM_CTS = 32 +const TIOCM_DSR = 256 +const TIOCM_DTR = 2 +const TIOCM_LE = 1 +const TIOCM_LOOP = 32768 +const TIOCM_OUT1 = 8192 +const TIOCM_OUT2 = 16384 +const TIOCM_RI = 128 +const TIOCM_RNG = 128 +const TIOCM_RTS = 4 +const TIOCM_SR = 16 +const TIOCM_ST = 8 +const TIOCNOTTY = 21538 +const TIOCNXCL = 21517 +const TIOCOUTQ = 21521 +const TIOCPKT = 21536 +const TIOCPKT_DATA = 0 +const TIOCPKT_DOSTOP = 32 +const TIOCPKT_FLUSHREAD = 1 +const TIOCPKT_FLUSHWRITE = 2 +const TIOCPKT_IOCTL = 64 +const TIOCPKT_NOSTOP = 16 +const TIOCPKT_START = 8 +const TIOCPKT_STOP = 4 +const TIOCSBRK = 21543 +const TIOCSCTTY = 21518 +const TIOCSERCONFIG = 21587 +const TIOCSERGETLSR = 21593 +const TIOCSERGETMULTI = 21594 +const TIOCSERGSTRUCT = 21592 +const TIOCSERGWILD = 21588 +const TIOCSERSETMULTI = 21595 +const TIOCSERSWILD = 21589 +const TIOCSER_TEMT = 1 +const TIOCSETD = 21539 +const TIOCSIG = 1074025526 +const TIOCSISO7816 = 3223868483 +const TIOCSLCKTRMIOS = 21591 +const TIOCSPGRP = 21520 +const TIOCSPTLCK = 1074025521 +const TIOCSRS485 = 21551 +const TIOCSSERIAL = 21535 +const TIOCSSOFTCAR = 21530 +const TIOCSTI = 21522 +const TIOCSWINSZ = 21524 +const TIOCVHANGUP = 21559 +const UMOUNT_NOFOLLOW = 8 +const _IOC_NONE = 0 +const _IOC_READ = 2 +const _IOC_WRITE = 1 + +func Xmount(tls *TLS, special uintptr, dir uintptr, fstype uintptr, flags uint64, data uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v special=%v dir=%v fstype=%v flags=%v data=%v, (%v:)", tls, special, dir, fstype, flags, data, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_mount), int64(special), int64(dir), int64(fstype), Int64FromUint64(flags), int64(data))))) +} + +func Xumount(tls *TLS, special uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v special=%v, (%v:)", tls, special, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_umount2), int64(special), int64(Int32FromInt32(0)))))) +} + +func Xumount2(tls *TLS, special uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v special=%v flags=%v, (%v:)", tls, special, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_umount2), int64(special), int64(flags))))) +} + +func Xname_to_handle_at(tls *TLS, dirfd int32, pathname uintptr, handle uintptr, mount_id uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v dirfd=%v pathname=%v handle=%v mount_id=%v flags=%v, (%v:)", tls, dirfd, pathname, handle, mount_id, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_name_to_handle_at), int64(dirfd), int64(pathname), int64(handle), int64(mount_id), int64(flags))))) +} + +func Xopen_by_handle_at(tls *TLS, mount_fd int32, handle uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v mount_fd=%v handle=%v flags=%v, (%v:)", tls, mount_fd, handle, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_open_by_handle_at), int64(mount_fd), int64(handle), int64(flags))))) +} + +const ADDR_COMPAT_LAYOUT = 2097152 +const ADDR_LIMIT_32BIT = 8388608 +const ADDR_LIMIT_3GB = 134217728 +const ADDR_NO_RANDOMIZE = 262144 +const FDPIC_FUNCPTRS = 524288 +const MMAP_PAGE_ZERO = 1048576 +const PER_BSD = 6 +const PER_HPUX = 16 +const PER_IRIX32 = 67108873 +const PER_IRIX64 = 67108875 +const PER_IRIXN32 = 67108874 +const PER_ISCR4 = 67108869 +const PER_LINUX = 0 +const PER_LINUX32 = 8 +const PER_LINUX32_3GB = 134217736 +const PER_LINUX_32BIT = 8388608 +const PER_LINUX_FDPIC = 524288 +const PER_MASK = 255 +const PER_OSF4 = 15 +const PER_OSR5 = 100663299 +const PER_RISCOS = 12 +const PER_SCOSVR3 = 117440515 +const PER_SOLARIS = 67108877 +const PER_SUNOS = 67108870 +const PER_SVR3 = 83886082 +const PER_SVR4 = 68157441 +const PER_UW7 = 68157454 +const PER_WYSEV386 = 83886084 +const PER_XENIX = 83886087 +const READ_IMPLIES_EXEC = 4194304 +const SHORT_INODE = 16777216 +const STICKY_TIMEOUTS = 67108864 +const UNAME26 = 131072 +const WHOLE_SECONDS = 33554432 + +func Xpersonality(tls *TLS, persona uint64) (r int32) { + if __ccgo_strace { + trc("tls=%v persona=%v, (%v:)", tls, persona, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_personality), Int64FromUint64(persona))))) +} + +func Xpivot_root(tls *TLS, new1 uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v new1=%v old=%v, (%v:)", tls, new1, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_pivot_root), int64(new1), int64(old))))) +} + +const PR_CAPBSET_DROP = 24 +const PR_CAPBSET_READ = 23 +const PR_CAP_AMBIENT = 47 +const PR_CAP_AMBIENT_CLEAR_ALL = 4 +const PR_CAP_AMBIENT_IS_SET = 1 +const PR_CAP_AMBIENT_LOWER = 3 +const PR_CAP_AMBIENT_RAISE = 2 +const PR_ENDIAN_BIG = 0 +const PR_ENDIAN_LITTLE = 1 +const PR_ENDIAN_PPC_LITTLE = 2 +const PR_FPEMU_NOPRINT = 1 +const PR_FPEMU_SIGFPE = 2 +const PR_FP_EXC_ASYNC = 2 +const PR_FP_EXC_DISABLED = 0 +const PR_FP_EXC_DIV = 65536 +const PR_FP_EXC_INV = 1048576 +const PR_FP_EXC_NONRECOV = 1 +const PR_FP_EXC_OVF = 131072 +const PR_FP_EXC_PRECISE = 3 +const PR_FP_EXC_RES = 524288 +const PR_FP_EXC_SW_ENABLE = 128 +const PR_FP_EXC_UND = 262144 +const PR_FP_MODE_FR = 1 +const PR_FP_MODE_FRE = 2 +const PR_GET_CHILD_SUBREAPER = 37 +const PR_GET_DUMPABLE = 3 +const PR_GET_ENDIAN = 19 +const PR_GET_FPEMU = 9 +const PR_GET_FPEXC = 11 +const PR_GET_FP_MODE = 46 +const PR_GET_IO_FLUSHER = 58 +const PR_GET_KEEPCAPS = 7 +const PR_GET_NAME = 16 +const PR_GET_NO_NEW_PRIVS = 39 +const PR_GET_PDEATHSIG = 2 +const PR_GET_SECCOMP = 21 +const PR_GET_SECUREBITS = 27 +const PR_GET_SPECULATION_CTRL = 52 +const PR_GET_TAGGED_ADDR_CTRL = 56 +const PR_GET_THP_DISABLE = 42 +const PR_GET_TID_ADDRESS = 40 +const PR_GET_TIMERSLACK = 30 +const PR_GET_TIMING = 13 +const PR_GET_TSC = 25 +const PR_GET_UNALIGN = 5 +const PR_MCE_KILL = 33 +const PR_MCE_KILL_CLEAR = 0 +const PR_MCE_KILL_DEFAULT = 2 +const PR_MCE_KILL_EARLY = 1 +const PR_MCE_KILL_GET = 34 +const PR_MCE_KILL_LATE = 0 +const PR_MCE_KILL_SET = 1 +const PR_MPX_DISABLE_MANAGEMENT = 44 +const PR_MPX_ENABLE_MANAGEMENT = 43 +const PR_MTE_TAG_MASK = 524280 +const PR_MTE_TAG_SHIFT = 3 +const PR_MTE_TCF_ASYNC = 4 +const PR_MTE_TCF_MASK = 6 +const PR_MTE_TCF_NONE = 0 +const PR_MTE_TCF_SHIFT = 1 +const PR_MTE_TCF_SYNC = 2 +const PR_PAC_APDAKEY = 4 +const PR_PAC_APDBKEY = 8 +const PR_PAC_APGAKEY = 16 +const PR_PAC_APIAKEY = 1 +const PR_PAC_APIBKEY = 2 +const PR_PAC_GET_ENABLED_KEYS = 61 +const PR_PAC_RESET_KEYS = 54 +const PR_PAC_SET_ENABLED_KEYS = 60 +const PR_SET_CHILD_SUBREAPER = 36 +const PR_SET_DUMPABLE = 4 +const PR_SET_ENDIAN = 20 +const PR_SET_FPEMU = 10 +const PR_SET_FPEXC = 12 +const PR_SET_FP_MODE = 45 +const PR_SET_IO_FLUSHER = 57 +const PR_SET_KEEPCAPS = 8 +const PR_SET_MM = 35 +const PR_SET_MM_ARG_END = 9 +const PR_SET_MM_ARG_START = 8 +const PR_SET_MM_AUXV = 12 +const PR_SET_MM_BRK = 7 +const PR_SET_MM_END_CODE = 2 +const PR_SET_MM_END_DATA = 4 +const PR_SET_MM_ENV_END = 11 +const PR_SET_MM_ENV_START = 10 +const PR_SET_MM_EXE_FILE = 13 +const PR_SET_MM_MAP = 14 +const PR_SET_MM_MAP_SIZE = 15 +const PR_SET_MM_START_BRK = 6 +const PR_SET_MM_START_CODE = 1 +const PR_SET_MM_START_DATA = 3 +const PR_SET_MM_START_STACK = 5 +const PR_SET_NAME = 15 +const PR_SET_NO_NEW_PRIVS = 38 +const PR_SET_PDEATHSIG = 1 +const PR_SET_PTRACER = 1499557217 +const PR_SET_PTRACER_ANY = 18446744073709551615 +const PR_SET_SECCOMP = 22 +const PR_SET_SECUREBITS = 28 +const PR_SET_SPECULATION_CTRL = 53 +const PR_SET_SYSCALL_USER_DISPATCH = 59 +const PR_SET_TAGGED_ADDR_CTRL = 55 +const PR_SET_THP_DISABLE = 41 +const PR_SET_TIMERSLACK = 29 +const PR_SET_TIMING = 14 +const PR_SET_TSC = 26 +const PR_SET_UNALIGN = 6 +const PR_SPEC_DISABLE = 4 +const PR_SPEC_DISABLE_NOEXEC = 16 +const PR_SPEC_ENABLE = 2 +const PR_SPEC_FORCE_DISABLE = 8 +const PR_SPEC_INDIRECT_BRANCH = 1 +const PR_SPEC_NOT_AFFECTED = 0 +const PR_SPEC_PRCTL = 1 +const PR_SPEC_STORE_BYPASS = 0 +const PR_SVE_GET_VL = 51 +const PR_SVE_SET_VL = 50 +const PR_SVE_SET_VL_ONEXEC = 262144 +const PR_SVE_VL_INHERIT = 131072 +const PR_SVE_VL_LEN_MASK = 65535 +const PR_SYS_DISPATCH_OFF = 0 +const PR_SYS_DISPATCH_ON = 1 +const PR_TAGGED_ADDR_ENABLE = 1 +const PR_TASK_PERF_EVENTS_DISABLE = 31 +const PR_TASK_PERF_EVENTS_ENABLE = 32 +const PR_TIMING_STATISTICAL = 0 +const PR_TIMING_TIMESTAMP = 1 +const PR_TSC_ENABLE = 1 +const PR_TSC_SIGSEGV = 2 +const PR_UNALIGN_NOPRINT = 1 +const PR_UNALIGN_SIGBUS = 2 +const SYSCALL_DISPATCH_FILTER_ALLOW = 0 +const SYSCALL_DISPATCH_FILTER_BLOCK = 1 + +type Tprctl_mm_map = struct { + Fstart_code Tuint64_t + Fend_code Tuint64_t + Fstart_data Tuint64_t + Fend_data Tuint64_t + Fstart_brk Tuint64_t + Fbrk Tuint64_t + Fstart_stack Tuint64_t + Farg_start Tuint64_t + Farg_end Tuint64_t + Fenv_start Tuint64_t + Fenv_end Tuint64_t + Fauxv uintptr + Fauxv_size Tuint32_t + Fexe_fd Tuint32_t +} + +func Xprctl(tls *TLS, op int32, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v op=%v va=%v, (%v:)", tls, op, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var i int32 + var x [4]uint64 + _, _, _ = ap, i, x + ap = va + i = 0 + for { + if !(i < int32(4)) { + break + } + x[i] = VaUint64(&ap) + goto _1 + _1: + ; + i = i + 1 + } + _ = ap + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_prctl), int64(op), Int64FromUint64(x[0]), Int64FromUint64(x[int32(1)]), Int64FromUint64(x[int32(2)]), Int64FromUint64(x[int32(3)]))))) +} + +const RWF_APPEND = 16 +const RWF_DSYNC = 2 +const RWF_HIPRI = 1 +const RWF_NOWAIT = 8 +const RWF_SYNC = 4 +const UIO_MAXIOV = 1024 + +func Xpreadv2(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t, flags int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v ofs=%v flags=%v, (%v:)", tls, fd, iov, count, ofs, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(flags != 0) { + if ofs == int64(-int32(1)) { + return Xreadv(tls, fd, iov, count) + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_preadv), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), 0))) + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_preadv2), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), int64(flags)))) +} + +func Xprlimit(tls *TLS, pid Tpid_t, resource int32, new_limit uintptr, old_limit uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v pid=%v resource=%v new_limit=%v old_limit=%v, (%v:)", tls, pid, resource, new_limit, old_limit, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r int32 + var _ /* tmp at bp+0 */ Trlimit + _ = r + if new_limit != 0 && Bool(^Uint64FromUint64(0) != ^Uint64FromUint64(0)) { + **(**Trlimit)(__ccgo_up(bp)) = **(**Trlimit)(__ccgo_up(new_limit)) + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur >= ^Uint64FromUint64(0) { + (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur = ^Uint64FromUint64(0) + } + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_max >= ^Uint64FromUint64(0) { + (**(**Trlimit)(__ccgo_up(bp))).Frlim_max = ^Uint64FromUint64(0) + } + new_limit = bp + } + r = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_prlimit64), int64(pid), int64(resource), int64(new_limit), int64(old_limit))))) + if !(r != 0) && old_limit != 0 && Bool(^Uint64FromUint64(0) != ^Uint64FromUint64(0)) { + if (*Trlimit)(unsafe.Pointer(old_limit)).Frlim_cur >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(old_limit)).Frlim_cur = ^Uint64FromUint64(0) + } + if (*Trlimit)(unsafe.Pointer(old_limit)).Frlim_max >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(old_limit)).Frlim_max = ^Uint64FromUint64(0) + } + } + return r +} + +func Xprocess_vm_writev(tls *TLS, pid Tpid_t, lvec uintptr, liovcnt uint64, rvec uintptr, riovcnt uint64, flags uint64) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v pid=%v lvec=%v liovcnt=%v rvec=%v riovcnt=%v flags=%v, (%v:)", tls, pid, lvec, liovcnt, rvec, riovcnt, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, int64(SYS_process_vm_writev), int64(pid), int64(lvec), Int64FromUint64(liovcnt), int64(rvec), Int64FromUint64(riovcnt), Int64FromUint64(flags)))) +} + +func Xprocess_vm_readv(tls *TLS, pid Tpid_t, lvec uintptr, liovcnt uint64, rvec uintptr, riovcnt uint64, flags uint64) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v pid=%v lvec=%v liovcnt=%v rvec=%v riovcnt=%v flags=%v, (%v:)", tls, pid, lvec, liovcnt, rvec, riovcnt, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, int64(SYS_process_vm_readv), int64(pid), int64(lvec), Int64FromUint64(liovcnt), int64(rvec), Int64FromUint64(riovcnt), Int64FromUint64(flags)))) +} + +const PTRACE_ARCH_PRCTL = 30 +const PTRACE_ATTACH = 16 +const PTRACE_CONT = 7 +const PTRACE_DETACH = 17 +const PTRACE_EVENT_CLONE = 3 +const PTRACE_EVENT_EXEC = 4 +const PTRACE_EVENT_EXIT = 6 +const PTRACE_EVENT_FORK = 1 +const PTRACE_EVENT_SECCOMP = 7 +const PTRACE_EVENT_STOP = 128 +const PTRACE_EVENT_VFORK = 2 +const PTRACE_EVENT_VFORK_DONE = 5 +const PTRACE_GETEVENTMSG = 16897 +const PTRACE_GETFPREGS = 14 +const PTRACE_GETFPXREGS = 18 +const PTRACE_GETREGS = 12 +const PTRACE_GETREGSET = 16900 +const PTRACE_GETSIGINFO = 16898 +const PTRACE_GETSIGMASK = 16906 +const PTRACE_GET_RSEQ_CONFIGURATION = 16911 +const PTRACE_GET_SYSCALL_INFO = 16910 +const PTRACE_GET_THREAD_AREA = 25 +const PTRACE_INTERRUPT = 16903 +const PTRACE_KILL = 8 +const PTRACE_LISTEN = 16904 +const PTRACE_O_EXITKILL = 1048576 +const PTRACE_O_MASK = 3145983 +const PTRACE_O_SUSPEND_SECCOMP = 2097152 +const PTRACE_O_TRACECLONE = 8 +const PTRACE_O_TRACEEXEC = 16 +const PTRACE_O_TRACEEXIT = 64 +const PTRACE_O_TRACEFORK = 2 +const PTRACE_O_TRACESECCOMP = 128 +const PTRACE_O_TRACESYSGOOD = 1 +const PTRACE_O_TRACEVFORK = 4 +const PTRACE_O_TRACEVFORKDONE = 32 +const PTRACE_PEEKDATA = 2 +const PTRACE_PEEKSIGINFO = 16905 +const PTRACE_PEEKSIGINFO_SHARED = 1 +const PTRACE_PEEKTEXT = 1 +const PTRACE_PEEKUSER = 3 +const PTRACE_POKEDATA = 5 +const PTRACE_POKETEXT = 4 +const PTRACE_POKEUSER = 6 +const PTRACE_SECCOMP_GET_FILTER = 16908 +const PTRACE_SECCOMP_GET_METADATA = 16909 +const PTRACE_SEIZE = 16902 +const PTRACE_SETFPREGS = 15 +const PTRACE_SETFPXREGS = 19 +const PTRACE_SETOPTIONS = 16896 +const PTRACE_SETREGS = 13 +const PTRACE_SETREGSET = 16901 +const PTRACE_SETSIGINFO = 16899 +const PTRACE_SETSIGMASK = 16907 +const PTRACE_SET_THREAD_AREA = 26 +const PTRACE_SINGLEBLOCK = 33 +const PTRACE_SINGLESTEP = 9 +const PTRACE_SYSCALL = 24 +const PTRACE_SYSCALL_INFO_ENTRY = 1 +const PTRACE_SYSCALL_INFO_EXIT = 2 +const PTRACE_SYSCALL_INFO_NONE = 0 +const PTRACE_SYSCALL_INFO_SECCOMP = 3 +const PTRACE_SYSEMU = 31 +const PTRACE_SYSEMU_SINGLESTEP = 32 +const PTRACE_TRACEME = 0 +const PT_ARCH_PRCTL = 30 +const PT_ATTACH = 16 +const PT_CONTINUE = 7 +const PT_DETACH = 17 +const PT_GETEVENTMSG = 16897 +const PT_GETFPREGS = 14 +const PT_GETFPXREGS = 18 +const PT_GETREGS = 12 +const PT_GETSIGINFO = 16898 +const PT_GET_THREAD_AREA = 25 +const PT_KILL = 8 +const PT_READ_D = 2 +const PT_READ_I = 1 +const PT_READ_U = 3 +const PT_SETFPREGS = 15 +const PT_SETFPXREGS = 19 +const PT_SETOPTIONS = 16896 +const PT_SETREGS = 13 +const PT_SETSIGINFO = 16899 +const PT_SET_THREAD_AREA = 26 +const PT_STEP = 9 +const PT_STEPBLOCK = 33 +const PT_SYSCALL = 24 +const PT_SYSEMU = 31 +const PT_SYSEMU_SINGLESTEP = 32 +const PT_TRACE_ME = 0 +const PT_WRITE_D = 5 +const PT_WRITE_I = 4 +const PT_WRITE_U = 6 + +type t__ptrace_peeksiginfo_args = struct { + Foff Tuint64_t + Fflags Tuint32_t + Fnr Tint32_t +} + +type t__ptrace_seccomp_metadata = struct { + Ffilter_off Tuint64_t + Fflags Tuint64_t +} + +type t__ptrace_syscall_info = struct { + Fop Tuint8_t + F__pad [3]Tuint8_t + Farch Tuint32_t + Finstruction_pointer Tuint64_t + Fstack_pointer Tuint64_t + F__ccgo5_24 struct { + Fexit [0]struct { + Frval Tint64_t + Fis_error Tuint8_t + } + Fseccomp [0]struct { + Fnr Tuint64_t + Fargs [6]Tuint64_t + Fret_data Tuint32_t + } + Fentry struct { + Fnr Tuint64_t + Fargs [6]Tuint64_t + } + F__ccgo_pad3 [8]byte + } +} + +type t__ptrace_rseq_configuration = struct { + Frseq_abi_pointer Tuint64_t + Frseq_abi_size Tuint32_t + Fsignature Tuint32_t + Fflags Tuint32_t + Fpad Tuint32_t +} + +func Xptrace(tls *TLS, req int32, va uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v req=%v va=%v, (%v:)", tls, req, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var addr, addr2, data uintptr + var ap Tva_list + var pid Tpid_t + var ret int64 + var _ /* result at bp+0 */ int64 + _, _, _, _, _, _ = addr, addr2, ap, data, pid, ret + addr2 = uintptr(0) + ap = va + pid = VaInt32(&ap) + addr = VaUintptr(&ap) + data = VaUintptr(&ap) + /* PTRACE_{READ,WRITE}{DATA,TEXT} (16...19) are specific to SPARC. */ + _ = ap + if Uint32FromInt32(req)-uint32(1) < uint32(3) { + data = bp + } + ret = X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_ptrace), int64(req), int64(pid), int64(addr), int64(data), int64(addr2)))) + if ret < 0 || Uint32FromInt32(req)-uint32(1) >= uint32(3) { + return ret + } + return **(**int64)(__ccgo_up(bp)) +} + +func Xpwritev2(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t, flags int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v ofs=%v flags=%v, (%v:)", tls, fd, iov, count, ofs, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(flags != 0) { + if ofs == int64(-int32(1)) { + return Xwritev(tls, fd, iov, count) + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pwritev), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), 0))) + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pwritev2), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), int64(flags)))) +} + +const GRPQUOTA = 1 +const IIF_ALL = 7 +const IIF_BGRACE = 1 +const IIF_FLAGS = 4 +const IIF_IGRACE = 2 +const MAXQUOTAS = 2 +const MAX_DQ_TIME = 604800 +const MAX_IQ_TIME = 604800 +const NR_DQHASH = 43 +const NR_DQUOTS = 256 +const QFMT_OCFS2 = 3 +const QFMT_VFS_OLD = 1 +const QFMT_VFS_V0 = 2 +const QFMT_VFS_V1 = 4 +const QIF_ALL = 63 +const QIF_BLIMITS = 1 +const QIF_BTIME = 16 +const QIF_ILIMITS = 4 +const QIF_INODES = 8 +const QIF_ITIME = 32 +const QIF_LIMITS = 5 +const QIF_SPACE = 2 +const QIF_TIMES = 48 +const QIF_USAGE = 10 +const QUOTAFILENAME = "quota" +const QUOTAGROUP = "staff" +const Q_GETFMT = 8388612 +const Q_GETINFO = 8388613 +const Q_GETQUOTA = 8388615 +const Q_QUOTAOFF = 8388611 +const Q_QUOTAON = 8388610 +const Q_SETINFO = 8388614 +const Q_SETQUOTA = 8388616 +const Q_SYNC = 8388609 +const SUBCMDMASK = 255 +const SUBCMDSHIFT = 8 +const USRQUOTA = 0 +const _LINUX_QUOTA_VERSION = 2 + +type Tdqblk = struct { + Fdqb_bhardlimit Tuint64_t + Fdqb_bsoftlimit Tuint64_t + Fdqb_curspace Tuint64_t + Fdqb_ihardlimit Tuint64_t + Fdqb_isoftlimit Tuint64_t + Fdqb_curinodes Tuint64_t + Fdqb_btime Tuint64_t + Fdqb_itime Tuint64_t + Fdqb_valid Tuint32_t +} + +type Tdqinfo = struct { + Fdqi_bgrace Tuint64_t + Fdqi_igrace Tuint64_t + Fdqi_flags Tuint32_t + Fdqi_valid Tuint32_t +} + +func Xquotactl(tls *TLS, cmd int32, special uintptr, id int32, addr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v cmd=%v special=%v id=%v addr=%v, (%v:)", tls, cmd, special, id, addr, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_quotactl), int64(cmd), int64(special), int64(id), int64(addr))))) +} + +func Xreadahead(tls *TLS, fd int32, pos Toff_t, len1 Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v pos=%v len1=%v, (%v:)", tls, fd, pos, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_readahead), int64(fd), pos, Int64FromUint64(len1)))) +} + +const RB_AUTOBOOT = 19088743 +const RB_DISABLE_CAD = 0 +const RB_ENABLE_CAD = 2309737967 +const RB_HALT_SYSTEM = 3454992675 +const RB_KEXEC = 1163412803 +const RB_POWER_OFF = 1126301404 +const RB_SW_SUSPEND = 3489725666 + +func Xreboot(tls *TLS, type1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v type1=%v, (%v:)", tls, type1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_reboot), Int64FromUint32(Uint32FromUint32(0xfee1dead)), int64(Int32FromInt32(672274793)), int64(type1))))) +} + +func Xremap_file_pages(tls *TLS, addr uintptr, size Tsize_t, prot int32, pgoff Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v size=%v prot=%v pgoff=%v flags=%v, (%v:)", tls, addr, size, prot, pgoff, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_remap_file_pages), int64(addr), Int64FromUint64(size), int64(prot), Int64FromUint64(pgoff), int64(flags))))) +} + +func Xsbrk(tls *TLS, inc Tintptr_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v inc=%v, (%v:)", tls, inc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if inc != 0 { + return uintptr(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(ENOMEM)))) + } + return uintptr(X__syscall1(tls, int64(SYS_brk), int64(Int32FromInt32(0)))) +} + +func Xsendfile(tls *TLS, out_fd int32, in_fd int32, ofs uintptr, count Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v out_fd=%v in_fd=%v ofs=%v count=%v, (%v:)", tls, out_fd, in_fd, ofs, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_sendfile), int64(out_fd), int64(in_fd), int64(ofs), Int64FromUint64(count)))) +} + +func Xsetfsgid(tls *TLS, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v gid=%v, (%v:)", tls, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_setfsgid), Int64FromUint32(gid))))) +} + +func Xsetfsuid(tls *TLS, uid Tuid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v uid=%v, (%v:)", tls, uid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_setfsuid), Int64FromUint32(uid))))) +} + +func Xsethostname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v len1=%v, (%v:)", tls, name, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_sethostname), int64(name), Int64FromUint64(len1))))) +} + +const CLONE_CHILD_CLEARTID = 2097152 +const CLONE_CHILD_SETTID = 16777216 +const CLONE_DETACHED = 4194304 +const CLONE_FILES = 1024 +const CLONE_FS = 512 +const CLONE_IO = 2147483648 +const CLONE_NEWCGROUP = 33554432 +const CLONE_NEWIPC = 134217728 +const CLONE_NEWNET = 1073741824 +const CLONE_NEWNS = 131072 +const CLONE_NEWPID = 536870912 +const CLONE_NEWTIME = 128 +const CLONE_NEWUSER = 268435456 +const CLONE_NEWUTS = 67108864 +const CLONE_PARENT = 32768 +const CLONE_PARENT_SETTID = 1048576 +const CLONE_PIDFD = 4096 +const CLONE_PTRACE = 8192 +const CLONE_SETTLS = 524288 +const CLONE_SIGHAND = 2048 +const CLONE_SYSVSEM = 262144 +const CLONE_THREAD = 65536 +const CLONE_UNTRACED = 8388608 +const CLONE_VFORK = 16384 +const CLONE_VM = 256 +const CPU_SETSIZE = 1024 +const CSIGNAL = 255 + +type Tcpu_set_t = struct { + F__bits [16]uint64 +} + +func Xsetns(tls *TLS, fd int32, nstype int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v nstype=%v, (%v:)", tls, fd, nstype, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_setns), int64(fd), int64(nstype))))) +} + +const __tm_gmtoff = 0 +const __tm_zone = 0 + +type Ttm1 = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + Ftm_gmtoff int64 + Ftm_zone uintptr +} + +func Xsettimeofday(tls *TLS, tv uintptr, tz uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v tv=%v tz=%v, (%v:)", tls, tv, tz, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + if !(tv != 0) { + return 0 + } + if Uint64FromInt64((*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec) >= uint64(1000000) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + *(*Ttimespec)(unsafe.Pointer(bp)) = Ttimespec{ + Ftv_sec: (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec, + Ftv_nsec: (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec * int64(1000), + } + return Xclock_settime(tls, CLOCK_REALTIME, bp) +} + +const SFD_CLOEXEC = 524288 +const SFD_NONBLOCK = 2048 + +type Tsignalfd_siginfo = struct { + Fssi_signo Tuint32_t + Fssi_errno Tint32_t + Fssi_code Tint32_t + Fssi_pid Tuint32_t + Fssi_uid Tuint32_t + Fssi_fd Tint32_t + Fssi_tid Tuint32_t + Fssi_band Tuint32_t + Fssi_overrun Tuint32_t + Fssi_trapno Tuint32_t + Fssi_status Tint32_t + Fssi_int Tint32_t + Fssi_ptr Tuint64_t + Fssi_utime Tuint64_t + Fssi_stime Tuint64_t + Fssi_addr Tuint64_t + Fssi_addr_lsb Tuint16_t + F__pad2 Tuint16_t + Fssi_syscall Tint32_t + Fssi_call_addr Tuint64_t + Fssi_arch Tuint32_t + F__pad [28]Tuint8_t +} + +func Xsignalfd(tls *TLS, fd int32, sigs uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v sigs=%v flags=%v, (%v:)", tls, fd, sigs, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + ret = int32(X__syscall4(tls, int64(SYS_signalfd4), int64(fd), int64(sigs), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), int64(flags))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + ret = int32(X__syscall3(tls, int64(SYS_signalfd), int64(fd), int64(sigs), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)))) + if ret >= 0 { + if flags&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if flags&int32(O_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) +} + +func Xsplice(tls *TLS, fd_in int32, off_in uintptr, fd_out int32, off_out uintptr, len1 Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd_in=%v off_in=%v fd_out=%v off_out=%v len1=%v flags=%v, (%v:)", tls, fd_in, off_in, fd_out, off_out, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, int64(SYS_splice), int64(fd_in), int64(off_in), int64(fd_out), int64(off_out), Int64FromUint64(len1), Int64FromUint32(flags)))) +} + +func Xstatx(tls *TLS, dirfd int32, path uintptr, flags int32, mask uint32, stx uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dirfd=%v path=%v flags=%v mask=%v stx=%v, (%v:)", tls, dirfd, path, flags, mask, stx, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var ret int32 + var _ /* st at bp+0 */ Tstat + _ = ret + ret = int32(X__syscall5(tls, int64(SYS_statx), int64(dirfd), int64(path), int64(flags), Int64FromUint32(mask), int64(stx))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + ret = Xfstatat(tls, dirfd, path, bp, flags) + if ret != 0 { + return ret + } + (*Tstatx)(unsafe.Pointer(stx)).Fstx_dev_major = uint32((**(**Tstat)(__ccgo_up(bp))).Fst_dev>>Int32FromInt32(31)>>Int32FromInt32(1)&Uint64FromUint32(0xfffff000) | (**(**Tstat)(__ccgo_up(bp))).Fst_dev>>Int32FromInt32(8)&Uint64FromInt32(0x00000fff)) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_dev_minor = uint32((**(**Tstat)(__ccgo_up(bp))).Fst_dev>>Int32FromInt32(12)&Uint64FromUint32(0xffffff00) | (**(**Tstat)(__ccgo_up(bp))).Fst_dev&Uint64FromInt32(0x000000ff)) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_ino = (**(**Tstat)(__ccgo_up(bp))).Fst_ino + (*Tstatx)(unsafe.Pointer(stx)).Fstx_mode = uint16((**(**Tstat)(__ccgo_up(bp))).Fst_mode) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_nlink = uint32((**(**Tstat)(__ccgo_up(bp))).Fst_nlink) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_uid = (**(**Tstat)(__ccgo_up(bp))).Fst_uid + (*Tstatx)(unsafe.Pointer(stx)).Fstx_gid = (**(**Tstat)(__ccgo_up(bp))).Fst_gid + (*Tstatx)(unsafe.Pointer(stx)).Fstx_size = Uint64FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_size) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_blksize = Uint32FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_blksize) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_blocks = Uint64FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_blocks) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_atime.Ftv_sec = (**(**Tstat)(__ccgo_up(bp))).Fst_atim.Ftv_sec + (*Tstatx)(unsafe.Pointer(stx)).Fstx_atime.Ftv_nsec = Uint32FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_atim.Ftv_nsec) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_mtime.Ftv_sec = (**(**Tstat)(__ccgo_up(bp))).Fst_mtim.Ftv_sec + (*Tstatx)(unsafe.Pointer(stx)).Fstx_mtime.Ftv_nsec = Uint32FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_mtim.Ftv_nsec) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_ctime.Ftv_sec = (**(**Tstat)(__ccgo_up(bp))).Fst_ctim.Ftv_sec + (*Tstatx)(unsafe.Pointer(stx)).Fstx_ctime.Ftv_nsec = Uint32FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_ctim.Ftv_nsec) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_btime = Tstatx_timestamp{} + (*Tstatx)(unsafe.Pointer(stx)).Fstx_mask = uint32(0x7ff) + return 0 +} + +func Xstime(tls *TLS, t uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* tv at bp+0 */ Ttimeval + **(**Ttimeval)(__ccgo_up(bp)) = Ttimeval{ + Ftv_sec: **(**Ttime_t)(__ccgo_up(t)), + } + return Xsettimeofday(tls, bp, UintptrFromInt32(0)) +} + +const SWAP_FLAG_DISCARD = 65536 +const SWAP_FLAG_PREFER = 32768 +const SWAP_FLAG_PRIO_MASK = 32767 +const SWAP_FLAG_PRIO_SHIFT = 0 + +func Xswapon(tls *TLS, path uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v flags=%v, (%v:)", tls, path, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_swapon), int64(path), int64(flags))))) +} + +func Xswapoff(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_swapoff), int64(path))))) +} + +func Xsync_file_range(tls *TLS, fd int32, pos Toff_t, len1 Toff_t, flags uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v pos=%v len1=%v flags=%v, (%v:)", tls, fd, pos, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_sync_file_range), int64(fd), pos, len1, Int64FromUint32(flags))))) +} + +func Xsyncfs(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_syncfs), int64(fd))))) +} + +func X__lsysinfo(tls *TLS, info uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v info=%v, (%v:)", tls, info, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_sysinfo), int64(info))))) +} + +func Xsysinfo(tls *TLS, info uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v info=%v, (%v:)", tls, info, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lsysinfo(tls, info) +} + +func Xtee(tls *TLS, src int32, dest int32, len1 Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v src=%v dest=%v len1=%v flags=%v, (%v:)", tls, src, dest, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_tee), int64(src), int64(dest), Int64FromUint64(len1), Int64FromUint32(flags)))) +} + +const TFD_CLOEXEC = 524288 +const TFD_NONBLOCK = 2048 +const TFD_TIMER_ABSTIME = 1 +const TFD_TIMER_CANCEL_ON_SET = 2 + +func Xtimerfd_create(tls *TLS, clockid int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v clockid=%v flags=%v, (%v:)", tls, clockid, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_timerfd_create), int64(clockid), int64(flags))))) +} + +func Xtimerfd_settime(tls *TLS, fd int32, flags int32, new1 uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v flags=%v new1=%v old=%v, (%v:)", tls, fd, flags, new1, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_timerfd_settime), int64(fd), int64(flags), int64(new1), int64(old))))) +} + +func Xtimerfd_gettime(tls *TLS, fd int32, cur uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v cur=%v, (%v:)", tls, fd, cur, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_timerfd_gettime), int64(fd), int64(cur))))) +} + +func Xunshare(tls *TLS, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_unshare), int64(flags))))) +} + +func Xutimes(tls *TLS, path uintptr, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v times=%v, (%v:)", tls, path, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__futimesat(tls, -int32(100), path, times) +} + +func Xvhangup(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall0(tls, int64(SYS_vhangup))))) +} + +func Xvmsplice(tls *TLS, fd int32, iov uintptr, cnt Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v cnt=%v flags=%v, (%v:)", tls, fd, iov, cnt, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_vmsplice), int64(fd), int64(iov), Int64FromUint64(cnt), Int64FromUint32(flags)))) +} + +const NSIG = 65 +const SA_NOMASK = 1073741824 +const SA_ONESHOT = 2147483648 +const SYS_SECCOMP = 1 +const SYS_USER_DISPATCH = 2 +const __ucontext = 0 + +const _REG_R8 = 0 +const _REG_R9 = 1 +const _REG_R10 = 2 +const _REG_R11 = 3 +const _REG_R12 = 4 +const _REG_R13 = 5 +const _REG_R14 = 6 +const _REG_R15 = 7 +const _REG_RDI = 8 +const _REG_RSI = 9 +const _REG_RBP = 10 +const _REG_RBX = 11 +const _REG_RDX = 12 +const _REG_RAX = 13 +const _REG_RCX = 14 +const _REG_RSP = 15 +const _REG_RIP = 16 +const _REG_EFL = 17 +const _REG_CSGSFS = 18 +const _REG_ERR = 19 +const _REG_TRAPNO = 20 +const _REG_OLDMASK = 21 +const _REG_CR2 = 22 + +type Tgreg_t = int64 + +type Tgregset_t = [23]int64 + +type Tfpregset_t = uintptr + +type T_fpstate = struct { + Fcwd uint16 + Fswd uint16 + Fftw uint16 + Ffop uint16 + Frip uint64 + Frdp uint64 + Fmxcsr uint32 + Fmxcr_mask uint32 + F_st [8]struct { + Fsignificand [4]uint16 + Fexponent uint16 + Fpadding [3]uint16 + } + F_xmm [16]struct { + Felement [4]uint32 + } + Fpadding [24]uint32 +} + +type Tsigcontext = struct { + Fr8 uint64 + Fr9 uint64 + Fr10 uint64 + Fr11 uint64 + Fr12 uint64 + Fr13 uint64 + Fr14 uint64 + Fr15 uint64 + Frdi uint64 + Frsi uint64 + Frbp uint64 + Frbx uint64 + Frdx uint64 + Frax uint64 + Frcx uint64 + Frsp uint64 + Frip uint64 + Feflags uint64 + Fcs uint16 + Fgs uint16 + Ffs uint16 + F__pad0 uint16 + Ferr uint64 + Ftrapno uint64 + Foldmask uint64 + Fcr2 uint64 + Ffpstate uintptr + F__reserved1 [8]uint64 +} + +type Tmcontext_t1 = struct { + Fgregs Tgregset_t + Ffpregs Tfpregset_t + F__reserved1 [8]uint64 +} + +type Tucontext_t1 = struct { + Fuc_flags uint64 + Fuc_link uintptr + Fuc_stack Tstack_t + Fuc_mcontext Tmcontext_t1 + Fuc_sigmask Tsigset_t + F__fpregs_mem [64]uint64 +} + +type Tucontext = Tucontext_t1 + +type Tsig_t = uintptr + +type Tsighandler_t = uintptr + +func Xwait3(tls *TLS, status uintptr, options int32, usage uintptr) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v status=%v options=%v usage=%v, (%v:)", tls, status, options, usage, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwait4(tls, -int32(1), status, options, usage) +} + +func Xwait4(tls *TLS, pid Tpid_t, status uintptr, options int32, ru uintptr) (r1 Tpid_t) { + if __ccgo_strace { + trc("tls=%v pid=%v status=%v options=%v ru=%v, (%v:)", tls, pid, status, options, ru, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var dest, v1 uintptr + var r int32 + var _ /* kru at bp+0 */ [4]int64 + _, _, _ = dest, r, v1 + if ru != 0 { + v1 = ru + 32 - uintptr(Uint64FromInt32(4)*Uint64FromInt64(8)) + } else { + v1 = uintptr(0) + } + dest = v1 + r = int32(X__syscall4(tls, int64(SYS_wait4), int64(pid), int64(status), int64(options), int64(dest))) + if r > 0 && ru != 0 && Bool(uint64(8) > uint64(8)) { + Xmemcpy(tls, bp, dest, Uint64FromInt32(4)*Uint64FromInt64(8)) + (*Trusage)(unsafe.Pointer(ru)).Fru_utime = Ttimeval{ + Ftv_sec: (**(**[4]int64)(__ccgo_up(bp)))[0], + Ftv_usec: (**(**[4]int64)(__ccgo_up(bp)))[int32(1)], + } + (*Trusage)(unsafe.Pointer(ru)).Fru_stime = Ttimeval{ + Ftv_sec: (**(**[4]int64)(__ccgo_up(bp)))[int32(2)], + Ftv_usec: (**(**[4]int64)(__ccgo_up(bp)))[int32(3)], + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +const XATTR_CREATE = 1 +const XATTR_REPLACE = 2 +const __UAPI_DEF_XATTR = 0 + +func Xgetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v value=%v size=%v, (%v:)", tls, path, name, value, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_getxattr), int64(path), int64(name), int64(value), Int64FromUint64(size)))) +} + +func Xlgetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v value=%v size=%v, (%v:)", tls, path, name, value, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_lgetxattr), int64(path), int64(name), int64(value), Int64FromUint64(size)))) +} + +func Xfgetxattr(tls *TLS, filedes int32, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v filedes=%v name=%v value=%v size=%v, (%v:)", tls, filedes, name, value, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_fgetxattr), int64(filedes), int64(name), int64(value), Int64FromUint64(size)))) +} + +func Xlistxattr(tls *TLS, path uintptr, list uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v list=%v size=%v, (%v:)", tls, path, list, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_listxattr), int64(path), int64(list), Int64FromUint64(size)))) +} + +func Xllistxattr(tls *TLS, path uintptr, list uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v list=%v size=%v, (%v:)", tls, path, list, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_llistxattr), int64(path), int64(list), Int64FromUint64(size)))) +} + +func Xflistxattr(tls *TLS, filedes int32, list uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v filedes=%v list=%v size=%v, (%v:)", tls, filedes, list, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_flistxattr), int64(filedes), int64(list), Int64FromUint64(size)))) +} + +func Xsetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v value=%v size=%v flags=%v, (%v:)", tls, path, name, value, size, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_setxattr), int64(path), int64(name), int64(value), Int64FromUint64(size), int64(flags))))) +} + +func Xlsetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v value=%v size=%v flags=%v, (%v:)", tls, path, name, value, size, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_lsetxattr), int64(path), int64(name), int64(value), Int64FromUint64(size), int64(flags))))) +} + +func Xfsetxattr(tls *TLS, filedes int32, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v filedes=%v name=%v value=%v size=%v flags=%v, (%v:)", tls, filedes, name, value, size, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fsetxattr), int64(filedes), int64(name), int64(value), Int64FromUint64(size), int64(flags))))) +} + +func Xremovexattr(tls *TLS, path uintptr, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v, (%v:)", tls, path, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_removexattr), int64(path), int64(name))))) +} + +func Xlremovexattr(tls *TLS, path uintptr, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v, (%v:)", tls, path, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_lremovexattr), int64(path), int64(name))))) +} + +func Xfremovexattr(tls *TLS, fd int32, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v name=%v, (%v:)", tls, fd, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_fremovexattr), int64(fd), int64(name))))) +} + +func _dummy4(tls *TLS, msg uintptr, lm uintptr) (r uintptr) { + return msg +} + +func X__lctrans(tls *TLS, msg uintptr, lm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v lm=%v, (%v:)", tls, msg, lm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lctrans_impl(tls, msg, lm) +} + +func X__lctrans_cur(tls *TLS, msg uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v, (%v:)", tls, msg, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lctrans_impl(tls, msg, **(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale + 5*8))) +} + +func _swapc(tls *TLS, x Tuint32_t, c int32) (r Tuint32_t) { + var v1 uint32 + _ = v1 + if c != 0 { + v1 = x>>int32(24) | x>>int32(8)&uint32(0xff00) | x< %v", r) }() + } + var b, n, o, ol, os, t, tl, ts Tuint32_t + var mo uintptr + var sign, sw int32 + _, _, _, _, _, _, _, _, _, _, _ = b, mo, n, o, ol, os, sign, sw, t, tl, ts + mo = p + sw = Int32FromUint32(**(**Tuint32_t)(__ccgo_up(mo)) - uint32(0x950412de)) + b = uint32(0) + n = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + 2*4)), sw) + o = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + 3*4)), sw) + t = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + 4*4)), sw) + if uint64(n) >= size/uint64(4) || uint64(o) >= size-uint64(uint32(4)*n) || uint64(t) >= size-uint64(uint32(4)*n) || (o|t)%uint32(4) != 0 { + return uintptr(0) + } + o = o / uint32(4) + t = t / uint32(4) + for { + ol = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + uintptr(o+uint32(2)*(b+n/uint32(2)))*4)), sw) + os = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + uintptr(o+uint32(2)*(b+n/uint32(2))+uint32(1))*4)), sw) + if uint64(os) >= size || uint64(ol) >= size-uint64(os) || **(**int8)(__ccgo_up(p + uintptr(os+ol))) != 0 { + return uintptr(0) + } + sign = Xstrcmp(tls, s, p+uintptr(os)) + if !(sign != 0) { + tl = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + uintptr(t+uint32(2)*(b+n/uint32(2)))*4)), sw) + ts = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + uintptr(t+uint32(2)*(b+n/uint32(2))+uint32(1))*4)), sw) + if uint64(ts) >= size || uint64(tl) >= size-uint64(ts) || **(**int8)(__ccgo_up(p + uintptr(ts+tl))) != 0 { + return uintptr(0) + } + return p + uintptr(ts) + } else { + if n == uint32(1) { + return uintptr(0) + } else { + if sign < 0 { + n = n / uint32(2) + } else { + b = b + n/uint32(2) + n = n - n/uint32(2) + } + } + } + goto _1 + _1: + } + return uintptr(0) +} + +const __USE_GNU_GETTEXT = 1 + +func Xbind_textdomain_codeset(tls *TLS, domainname uintptr, codeset uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v codeset=%v, (%v:)", tls, domainname, codeset, origin(2)) + defer func() { trc("-> %v", r) }() + } + if codeset != 0 && Xstrcasecmp(tls, codeset, __ccgo_ts+388) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + } + return UintptrFromInt32(0) +} + +var _empty_mo = [5]Tuint32_t{ + 0: uint32(0x950412de), + 2: Uint32FromInt32(-Int32FromInt32(1)), + 3: Uint32FromInt32(-Int32FromInt32(1)), + 4: Uint32FromInt32(-Int32FromInt32(1)), +} + +const NL_CAT_LOCALE = 1 +const NL_SETD = 1 + +type Tnl_item = int32 + +type Tnl_catd = uintptr + +func Xcatclose(tls *TLS, catd Tnl_catd) (r int32) { + if __ccgo_strace { + trc("tls=%v catd=%v, (%v:)", tls, catd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var map1 uintptr + var v1, v2 Tuint32_t + _, _, _ = map1, v1, v2 + map1 = catd + v1 = **(**Tuint32_t)(__ccgo_up(map1 + UintptrFromInt32(8))) + v2 = v1>>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v4>>int32(8)&uint32(0xff00) | v4< y { + v8 = int32(1) + } else { + v8 = 0 + } + v7 = v8 + } + return v7 +} + +func Xcatgets(tls *TLS, catd Tnl_catd, set_id int32, msg_id int32, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v catd=%v set_id=%v msg_id=%v s=%v, (%v:)", tls, catd, set_id, msg_id, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var map1, msg, msgs, set, sets, strings uintptr + var nmsgs, nsets, v1, v10, v11, v13, v14, v2, v4, v5, v7, v8 Tuint32_t + var _ /* msg_id_be at bp+4 */ Tuint32_t + var _ /* set_id_be at bp+0 */ Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = map1, msg, msgs, nmsgs, nsets, set, sets, strings, v1, v10, v11, v13, v14, v2, v4, v5, v7, v8 + map1 = catd + v1 = **(**Tuint32_t)(__ccgo_up(map1 + UintptrFromInt32(4))) + v2 = v1>>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v4>>int32(8)&uint32(0xff00) | v4<>int32(24) | v7>>int32(8)&uint32(0xff00) | v7<>int32(24) | v10>>int32(8)&uint32(0xff00) | v10<>int32(24) | v13>>int32(8)&uint32(0xff00) | v13<>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v4>>int32(8)&uint32(0xff00) | v4<>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v5>>int32(8)&uint32(0xff00) | v5< %v", r) }() + } + bp := tls.Alloc(4096) + defer tls.Free(4096) + var catd Tnl_catd + var i, l Tsize_t + var lang, p, path, v, z, v1 uintptr + var v2 bool + var _ /* buf at bp+0 */ [4096]int8 + _, _, _, _, _, _, _, _, _, _ = catd, i, l, lang, p, path, v, z, v1, v2 + if Xstrchr(tls, name, int32('/')) != 0 { + return _do_catopen(tls, name) + } + if v2 = X__libc.Fsecure != 0; !v2 { + v1 = Xgetenv(tls, __ccgo_ts+394) + path = v1 + } + if v2 || !(v1 != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(-Int32FromInt32(1)) + } + if oflag != 0 { + v1 = Xnl_langinfo(tls, Int32FromInt32(LC_MESSAGES)<= uint64(4096)-i { + break + } + Xmemcpy(tls, bp+uintptr(i), v, l) + i = i + l + goto _5 + _5: + ; + p = p + 1 + } + if !(**(**int8)(__ccgo_up(z)) != 0) && (p < z || !(i != 0)) { + break + } + if p < z { + goto _4 + } + if **(**int8)(__ccgo_up(z)) != 0 { + z = z + 1 + } + (**(**[4096]int8)(__ccgo_up(bp)))[i] = 0 + /* Leading : or :: in NLSPATH is same as %N */ + if i != 0 { + v1 = bp + } else { + v1 = name + } + catd = _do_catopen(tls, v1) + if catd != uintptr(-Int32FromInt32(1)) { + return catd + } + goto _4 + _4: + ; + p = z + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(-Int32FromInt32(1)) +} + +const calloc = 0 +const free = 0 +const malloc = 0 +const realloc = 0 + +type Tbinding = struct { + Fnext uintptr + Fdirlen int32 + Factive int32 + Fdomainname uintptr + Fdirname uintptr +} + +var _bindings uintptr + +func _gettextdir(tls *TLS, domainname uintptr, dirlen uintptr) (r uintptr) { + var p uintptr + _ = p + p = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + for { + if !(p != 0) { + break + } + if !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(p)).Fdomainname, domainname) != 0) && AtomicLoadPInt32(p+12) != 0 { + **(**Tsize_t)(__ccgo_up(dirlen)) = Uint64FromInt32((*Tbinding)(unsafe.Pointer(p)).Fdirlen) + return (*Tbinding)(unsafe.Pointer(p)).Fdirname + } + goto _1 + _1: + ; + p = (*Tbinding)(unsafe.Pointer(p)).Fnext + } + return uintptr(0) +} + +var _lock1 [1]int32 + +func Xbindtextdomain(tls *TLS, domainname uintptr, dirname uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v dirname=%v, (%v:)", tls, domainname, dirname, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var dirlen, domlen Tsize_t + var p2, q, v2 uintptr + _, _, _, _, _ = dirlen, domlen, p2, q, v2 + if !(domainname != 0) { + return uintptr(0) + } + if !(dirname != 0) { + *(*Tsize_t)(unsafe.Pointer(bp)) = uint64(0) + return _gettextdir(tls, domainname, bp) + } + domlen = Xstrnlen(tls, domainname, Uint64FromInt32(Int32FromInt32(NAME_MAX)+Int32FromInt32(1))) + dirlen = Xstrnlen(tls, dirname, uint64(PATH_MAX)) + if domlen > uint64(NAME_MAX) || dirlen >= uint64(PATH_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + ___lock(tls, uintptr(unsafe.Pointer(&_lock1))) + p2 = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + for { + if !(p2 != 0) { + break + } + if !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(p2)).Fdomainname, domainname) != 0) && !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(p2)).Fdirname, dirname) != 0) { + break + } + goto _1 + _1: + ; + p2 = (*Tbinding)(unsafe.Pointer(p2)).Fnext + } + if !(p2 != 0) { + p2 = Xcalloc(tls, uint64(32)+domlen+dirlen+uint64(2), uint64(1)) + if !(p2 != 0) { + ___unlock(tls, uintptr(unsafe.Pointer(&_lock1))) + return uintptr(0) + } + (*Tbinding)(unsafe.Pointer(p2)).Fnext = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + (*Tbinding)(unsafe.Pointer(p2)).Fdirlen = Int32FromUint64(dirlen) + (*Tbinding)(unsafe.Pointer(p2)).Fdomainname = p2 + 32 + (*Tbinding)(unsafe.Pointer(p2)).Fdirname = p2 + 32 + uintptr(domlen) + uintptr(1) + Xmemcpy(tls, (*Tbinding)(unsafe.Pointer(p2)).Fdomainname, domainname, domlen+uint64(1)) + Xmemcpy(tls, (*Tbinding)(unsafe.Pointer(p2)).Fdirname, dirname, dirlen+uint64(1)) + v2 = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + // __asm__( "lock ; cmpxchg %3, %1" + // + // : "=a"(t), "=m"(*(void *volatile *)p) + // : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 13, __ccgo_ts+416) + _ = v2 + goto _3 + _3: + } + // __asm__ __volatile__( + // + // "mov %1, %0 ; lock ; orl $0,(%%rsp)" + // : "=m"(*p) : "r"(x) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 88, __ccgo_ts+416) + q = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + for { + if !(q != 0) { + break + } + if !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(q)).Fdomainname, domainname) != 0) && q != p2 { + // __asm__ __volatile__( + // + // "mov %1, %0 ; lock ; orl $0,(%%rsp)" + // : "=m"(*p) : "r"(x) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 88, __ccgo_ts+416) + } + goto _4 + _4: + ; + q = (*Tbinding)(unsafe.Pointer(q)).Fnext + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock1))) + return (*Tbinding)(unsafe.Pointer(p2)).Fdirname +} + +var _catnames = [6][12]int8{ + 0: {'L', 'C', '_', 'C', 'T', 'Y', 'P', 'E'}, + 1: {'L', 'C', '_', 'N', 'U', 'M', 'E', 'R', 'I', 'C'}, + 2: {'L', 'C', '_', 'T', 'I', 'M', 'E'}, + 3: {'L', 'C', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E'}, + 4: {'L', 'C', '_', 'M', 'O', 'N', 'E', 'T', 'A', 'R', 'Y'}, + 5: {'L', 'C', '_', 'M', 'E', 'S', 'S', 'A', 'G', 'E', 'S'}, +} + +var _catlens = [6]int8{ + 0: int8(8), + 1: int8(10), + 2: int8(7), + 3: int8(10), + 4: int8(11), + 5: int8(11), +} + +type Tmsgcat = struct { + Fnext uintptr + Fmap1 uintptr + Fmap_size Tsize_t + Fplural_rule uintptr + Fnplurals int32 + Fbinding uintptr + Flm uintptr + Fcat int32 +} + +func _dummy_gettextdomain(tls *TLS) (r uintptr) { + return __ccgo_ts + 431 +} + +func Xdcngettext(tls *TLS, domainname uintptr, msgid1 uintptr, msgid2 uintptr, n uint64, category int32) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v msgid1=%v msgid2=%v n=%v category=%v, (%v:)", tls, domainname, msgid1, msgid2, n, category, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var alt_modlen, catlen, dirlen, domlen, l, loclen, modlen, rem, v5 Tsize_t + var catname, csp, dirname, lm, loc, locname, locp, map1, modname, name, old_cats, p1, q, r, rule, trans, v3, v8 uintptr + var np, plural, v21 uint64 + var old_errno, v11, v12 int32 + var v6 t__predefined_size_t + var _ /* map_size at bp+0 */ Tsize_t + var _ /* z at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alt_modlen, catlen, catname, csp, dirlen, dirname, domlen, l, lm, loc, loclen, locname, locp, map1, modlen, modname, name, np, old_cats, old_errno, p1, plural, q, r, rem, rule, trans, v11, v12, v21, v3, v5, v6, v8 + defer func() { Xrealloc(tls, name, 0) }() + loc = (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale + old_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + /* match gnu gettext behaviour */ + if !(msgid1 != 0) { + goto notrans + } + if Uint32FromInt32(category) >= uint32(LC_ALL) { + goto notrans + } + if !(domainname != 0) { + domainname = X__gettextdomain(tls) + } + domlen = Xstrnlen(tls, domainname, Uint64FromInt32(Int32FromInt32(NAME_MAX)+Int32FromInt32(1))) + if domlen > uint64(NAME_MAX) { + goto notrans + } + q = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + for { + if !(q != 0) { + break + } + if !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(q)).Fdomainname, domainname) != 0) && AtomicLoadPInt32(q+12) != 0 { + break + } + goto _1 + _1: + ; + q = (*Tbinding)(unsafe.Pointer(q)).Fnext + } + if !(q != 0) { + goto notrans + } + lm = **(**uintptr)(__ccgo_up(loc + uintptr(category)*8)) + if !!(lm != 0) { + goto _2 + } + goto notrans +notrans: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + if n == uint64(1) { + v3 = msgid1 + } else { + v3 = msgid2 + } + return v3 +_2: + ; + p1 = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_cats))) + for { + if !(p1 != 0) { + break + } + if (*Tmsgcat)(unsafe.Pointer(p1)).Fbinding == q && (*Tmsgcat)(unsafe.Pointer(p1)).Flm == lm && (*Tmsgcat)(unsafe.Pointer(p1)).Fcat == category { + break + } + goto _4 + _4: + ; + p1 = (*Tmsgcat)(unsafe.Pointer(p1)).Fnext + } + if !(p1 != 0) { + dirname = (*Tbinding)(unsafe.Pointer(q)).Fdirname + locname = lm + 16 + catname = uintptr(unsafe.Pointer(&_catnames)) + uintptr(category)*12 + dirlen = Uint64FromInt32((*Tbinding)(unsafe.Pointer(q)).Fdirlen) + loclen = _strlen(tls, locname) + catlen = Uint64FromInt8(_catlens[category]) + /* Logically split @mod suffix from locale name. */ + modname = Xmemchr(tls, locname, int32('@'), loclen) + if !(modname != 0) { + modname = locname + uintptr(loclen) + } + v5 = loclen - Uint64FromInt64(int64(modname)-int64(locname)) + modlen = v5 + alt_modlen = v5 + loclen = Uint64FromInt64(int64(modname) - int64(locname)) + /* Drop .charset identifier; it is not used. */ + csp = Xmemchr(tls, locname, int32('.'), loclen) + if csp != 0 { + loclen = Uint64FromInt64(int64(csp) - int64(locname)) + } + v6 = dirlen + uint64(1) + loclen + modlen + uint64(1) + catlen + uint64(1) + domlen + uint64(3) + uint64(1) + name = Xrealloc(tls, name, v6) + for { + Xsnprintf(tls, name, v6, __ccgo_ts+440, VaList(bp+24, dirname, Int32FromUint64(loclen), locname, Int32FromUint64(alt_modlen), modname, catname, domainname)) + v3 = X__map_file(tls, name, bp) + map1 = v3 + if v3 != 0 { + break + } + /* Try dropping @mod, _YY, then both. */ + if alt_modlen != 0 { + alt_modlen = uint64(0) + } else { + v3 = Xmemchr(tls, locname, int32('_'), loclen) + locp = v3 + if v3 != 0 { + loclen = Uint64FromInt64(int64(locp) - int64(locname)) + alt_modlen = modlen + } else { + break + } + } + goto _7 + _7: + } + if !(map1 != 0) { + goto notrans + } + p1 = Xcalloc(tls, uint64(64), uint64(1)) + if !(p1 != 0) { + X__munmap(tls, map1, **(**Tsize_t)(__ccgo_up(bp))) + goto notrans + } + (*Tmsgcat)(unsafe.Pointer(p1)).Fcat = category + (*Tmsgcat)(unsafe.Pointer(p1)).Fbinding = q + (*Tmsgcat)(unsafe.Pointer(p1)).Flm = lm + (*Tmsgcat)(unsafe.Pointer(p1)).Fmap1 = map1 + (*Tmsgcat)(unsafe.Pointer(p1)).Fmap_size = **(**Tsize_t)(__ccgo_up(bp)) + rule = __ccgo_ts + 462 + np = uint64(2) + r = X__mo_lookup(tls, (*Tmsgcat)(unsafe.Pointer(p1)).Fmap1, (*Tmsgcat)(unsafe.Pointer(p1)).Fmap_size, __ccgo_ts) + for r != 0 && Xstrncmp(tls, r, __ccgo_ts+468, uint64(13)) != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = Xstrchr(tls, r, int32('\n')) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v3 = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(1) + } else { + v3 = uintptr(0) + } + r = v3 + } + if r != 0 { + r = r + uintptr(13) + for { + v11 = int32(**(**int8)(__ccgo_up(r))) + v12 = BoolInt32(v11 == int32(' ') || Uint32FromInt32(v11)-uint32('\t') < uint32(5)) + goto _13 + _13: + if !(v12 != 0) { + break + } + r = r + 1 + } + if !(Xstrncmp(tls, r, __ccgo_ts+482, uint64(9)) != 0) { + np = Xstrtoul(tls, r+uintptr(9), bp+8, int32(10)) + r = **(**uintptr)(__ccgo_up(bp + 8)) + } + for **(**int8)(__ccgo_up(r)) != 0 && int32(**(**int8)(__ccgo_up(r))) != int32(';') { + r = r + 1 + } + if **(**int8)(__ccgo_up(r)) != 0 { + r = r + 1 + for { + v11 = int32(**(**int8)(__ccgo_up(r))) + v12 = BoolInt32(v11 == int32(' ') || Uint32FromInt32(v11)-uint32('\t') < uint32(5)) + goto _16 + _16: + if !(v12 != 0) { + break + } + r = r + 1 + } + if !(Xstrncmp(tls, r, __ccgo_ts+492, uint64(7)) != 0) { + rule = r + uintptr(7) + } + } + } + (*Tmsgcat)(unsafe.Pointer(p1)).Fnplurals = Int32FromUint64(np) + (*Tmsgcat)(unsafe.Pointer(p1)).Fplural_rule = rule + for { + old_cats = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_cats))) + (*Tmsgcat)(unsafe.Pointer(p1)).Fnext = old_cats + goto _20 + _20: + ; + v3 = old_cats + // __asm__( "lock ; cmpxchg %3, %1" + // + // : "=a"(t), "=m"(*(void *volatile *)p) + // : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 13, __ccgo_ts+500) + v8 = v3 + goto _19 + _19: + ; + if !(v8 != old_cats) { + break + } + } + } + trans = X__mo_lookup(tls, (*Tmsgcat)(unsafe.Pointer(p1)).Fmap1, (*Tmsgcat)(unsafe.Pointer(p1)).Fmap_size, msgid1) + if !(trans != 0) { + goto notrans + } + /* Non-plural-processing gettext forms pass a null pointer as + * msgid2 to request that dcngettext suppress plural processing. */ + if msgid2 != 0 && (*Tmsgcat)(unsafe.Pointer(p1)).Fnplurals != 0 { + plural = X__pleval(tls, (*Tmsgcat)(unsafe.Pointer(p1)).Fplural_rule, n) + if plural > Uint64FromInt32((*Tmsgcat)(unsafe.Pointer(p1)).Fnplurals) { + goto notrans + } + for { + v21 = plural + plural = plural - 1 + if !(v21 != 0) { + break + } + rem = (*Tmsgcat)(unsafe.Pointer(p1)).Fmap_size - Uint64FromInt64(int64(trans)-int64((*Tmsgcat)(unsafe.Pointer(p1)).Fmap1)) + l = Xstrnlen(tls, trans, rem) + if l+uint64(1) >= rem { + goto notrans + } + trans = trans + uintptr(l+uint64(1)) + } + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + return trans +} + +var _cats uintptr + +func Xdcgettext(tls *TLS, domainname uintptr, msgid uintptr, category int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v msgid=%v category=%v, (%v:)", tls, domainname, msgid, category, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdcngettext(tls, domainname, msgid, uintptr(0), uint64(1), category) +} + +func Xdngettext(tls *TLS, domainname uintptr, msgid1 uintptr, msgid2 uintptr, n uint64) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v msgid1=%v msgid2=%v n=%v, (%v:)", tls, domainname, msgid1, msgid2, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdcngettext(tls, domainname, msgid1, msgid2, n, int32(LC_MESSAGES)) +} + +func Xdgettext(tls *TLS, domainname uintptr, msgid uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v msgid=%v, (%v:)", tls, domainname, msgid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdcngettext(tls, domainname, msgid, uintptr(0), uint64(1), int32(LC_MESSAGES)) +} + +func X__duplocale(tls *TLS, old Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v old=%v, (%v:)", tls, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + var new1 Tlocale_t + _ = new1 + new1 = Xmalloc(tls, uint64(48)) + if !(new1 != 0) { + return uintptr(0) + } + if old == uintptr(-Int32FromInt32(1)) { + old = uintptr(unsafe.Pointer(&X__libc)) + 56 + } + **(**t__locale_struct)(__ccgo_up(new1)) = **(**t__locale_struct)(__ccgo_up(old)) + return new1 +} + +func Xduplocale(tls *TLS, old Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v old=%v, (%v:)", tls, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__duplocale(tls, old) +} + +func Xfreelocale(tls *TLS, l Tlocale_t) { + if __ccgo_strace { + trc("tls=%v l=%v, (%v:)", tls, l, origin(2)) + } + if X__loc_is_allocated(tls, l) != 0 { + Xfree(tls, l) + } +} + +func X__freelocale(tls *TLS, l Tlocale_t) { + if __ccgo_strace { + trc("tls=%v l=%v, (%v:)", tls, l, origin(2)) + } + Xfreelocale(tls, l) +} + +const BIG5 = 224 +const EUC_JP = 208 +const EUC_KR = 232 +const GB18030 = 216 +const GB2312 = 218 +const GBK = 217 +const ISO2022_JP = 210 +const SHIFT_JIS = 209 +const UCS2 = 204 +const UCS2BE = 196 +const UCS2LE = 197 +const US_ASCII = 199 +const UTF_16 = 202 +const UTF_16BE = 194 +const UTF_16LE = 193 +const UTF_32 = 203 +const UTF_32BE = 192 +const UTF_32LE = 195 +const UTF_8 = 200 +const WCHAR_T = 198 +const mbrtowc_utf8 = 0 +const wctomb_utf8 = 0 + +type Ticonv_t = uintptr + +/* Definitions of charmaps. Each charmap consists of: + * 1. Empty-string-terminated list of null-terminated aliases. + * 2. Special type code or number of elided quads of entries. + * 3. Character table (size determined by field 2), consisting + * of 5 bytes for every 4 characters, interpreted as 10-bit + * indices into the legacy_chars table. */ + +var _charmaps = [4907]uint8{'u', 't', 'f', '8', 0, 'c', 'h', 'a', 'r', 0, 0, 200, 'w', 'c', 'h', 'a', 'r', 't', 0, 0, 198, 'u', 'c', 's', '2', 'b', 'e', 0, 0, 196, 'u', 'c', 's', '2', 'l', 'e', 0, 0, 197, 'u', 't', 'f', '1', '6', 'b', 'e', 0, 0, 194, 'u', 't', 'f', '1', '6', 'l', 'e', 0, 0, 193, 'u', 'c', 's', '4', 'b', 'e', 0, 'u', 't', 'f', '3', '2', 'b', 'e', 0, 0, 192, 'u', 'c', 's', '4', 'l', 'e', 0, 'u', 't', 'f', '3', '2', 'l', 'e', 0, 0, 195, 'a', 's', 'c', 'i', 'i', 0, 'u', 's', 'a', 's', 'c', 'i', 'i', 0, 'i', 's', 'o', '6', '4', '6', 0, 'i', 's', 'o', '6', '4', '6', 'u', 's', 0, 0, 199, 'u', 't', 'f', '1', '6', 0, 0, 202, 'u', 'c', 's', '4', 0, 'u', 't', 'f', '3', '2', 0, 0, 203, 'u', 'c', 's', '2', 0, 0, 204, 'e', 'u', 'c', 'j', 'p', 0, 0, 208, 's', 'h', 'i', 'f', 't', 'j', 'i', 's', 0, 's', 'j', 'i', 's', 0, 'c', 'p', '9', '3', '2', 0, 0, 209, 'i', 's', 'o', '2', '0', '2', '2', 'j', 'p', 0, 0, 210, 'g', 'b', '1', '8', '0', '3', '0', 0, 0, 216, 'g', 'b', 'k', 0, 'c', 'p', '9', '3', '6', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '9', '3', '6', 0, 0, 217, 'g', 'b', '2', '3', '1', '2', 0, 0, 218, 'b', 'i', 'g', '5', 0, 'b', 'i', 'g', 'f', 'i', 'v', 'e', 0, 'c', 'p', '9', '5', '0', 0, 'b', 'i', 'g', '5', 'h', 'k', 's', 'c', 's', 0, 0, 224, 'e', 'u', 'c', 'k', 'r', 0, 'k', 's', 'c', '5', '6', '0', '1', 0, 'k', 's', 'x', '1', '0', '0', '1', 0, 'c', 'p', '9', '4', '9', 0, 0, 232, 'i', 's', 'o', '8', '8', '5', '9', '1', 0, 'l', 'a', 't', 'i', 'n', '1', 0, 0, '@', 'i', 's', 'o', '8', '8', '5', '9', '2', 0, 0, '(', 160, 16, 244, 'W', 'N', 164, 220, 244, 212, ')', 168, 'T', '5', 'U', 'V', 'n', 181, '"', 23, '\\', 176, 20, 20, 152, 'N', 180, 224, 4, 149, '_', 184, 'X', 'E', 149, 'V', 'o', 13, '6', 'W', '\\', 'I', 5, '#', 140, '@', 196, 204, 'd', 208, '1', 12, '%', 'c', 209, '2', 24, '5', 227, 140, 'C', 16, 237, 244, 211, '4', 212, 20, 'e', 205, '5', 'M', 141, 165, 'M', 'Y', 220, 't', 's', 213, '7', 'J', 133, '#', 206, '@', 228, 208, 't', 208, '9', 13, 165, 's', 209, ':', 25, 181, 227, 206, 'C', 17, 241, 4, 212, '<', 244, 24, 'e', 207, '=', 'N', 145, 165, 143, 'Y', 252, 244, 131, 21, '`', 'i', 's', 'o', '8', '8', '5', '9', '3', 0, 0, '(', 160, 144, 244, 215, '(', 164, 0, ' ', 210, ')', 168, 176, '4', 21, 'G', '.', 181, 2, 0, '\\', 176, 148, '$', 203, ',', 180, 212, '2', 210, '-', 184, 180, 'D', 'U', 'G', '/', 245, 2, '@', '\\', 192, 4, '#', 12, 0, 196, '(', 132, 208, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 0, 'D', '#', 205, '4', 212, 'x', 'd', 205, '5', 26, 'e', 163, 205, '6', 220, 132, 21, 213, '7', 224, 132, '#', 14, 0, 228, ',', 148, 208, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 0, 196, '#', 207, '<', 244, '|', 'd', 207, '=', 27, 229, 163, 207, '>', 252, 136, '%', 21, '`', 'i', 's', 'o', '8', '8', '5', '9', '4', 0, 0, '(', 160, 16, '$', 211, 'R', 164, 152, 'T', 211, ')', 168, 'T', '%', 17, 'H', '[', 181, '"', 215, '+', 176, 20, 20, 24, 'S', 180, 156, 'd', 147, '_', 184, 'X', '5', 'Q', 'H', '\\', 5, '5', 151, 'P', 0, 5, '#', 204, '0', 196, 20, 'c', 140, 'J', 12, '%', 'c', 209, '2', 20, '5', 227, 12, 'J', 16, 245, '4', 20, 'L', 212, 'T', 'c', 205, '5', 216, 156, 165, 205, '6', 220, 't', 245, 213, '7', 1, 133, '#', 206, '8', 228, 148, 'c', 206, 'J', 13, 165, 's', 209, ':', 21, 181, 227, 'N', 'J', 17, 249, 'D', 'T', 'L', 244, 212, 'c', 207, '=', 248, 160, 165, 207, '>', 252, 'x', 5, 22, '`', 'i', 's', 'o', '8', '8', '5', '9', '5', 0, 0, '(', 160, 'D', '\'', 221, 't', 212, 'U', 'g', 221, 'u', 216, 'e', 167, 221, 'v', 220, 181, 210, 157, 'w', 223, 129, 23, 158, 'x', 227, 145, 'W', 158, 'y', 231, 161, 151, 158, 'z', 235, 177, 215, 158, '{', 239, 193, 23, 159, '|', 243, 209, 'W', 159, '}', 247, 225, 151, 159, '~', 251, 241, 215, 159, 127, 255, 1, 24, 160, 128, 3, 18, 'X', 160, 129, 7, '"', 152, 160, 130, 11, '2', 216, 160, 131, 15, 'B', 24, 161, 132, 19, 'R', 'X', 161, 133, 23, 'b', 152, 161, 134, 27, 'r', 216, 161, 135, '&', 127, 8, 'b', 136, '"', 142, 'H', 'b', 137, '&', 158, 136, 'b', 138, '*', 158, 178, '"', 139, 'i', 's', 'o', '8', '8', '5', '9', '6', 0, 0, '(', 160, 0, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'b', 182, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 152, 0, 0, 0, 0, 153, 0, 148, 'i', 230, 153, 'h', 166, 169, 230, 154, 'l', 182, 233, 230, 155, 'p', 198, ')', 231, 156, 't', 214, 'i', 231, 157, 'x', 230, 169, 231, 158, '|', 246, 233, '\'', 0, 0, 0, 0, 0, 0, 127, 2, 26, 168, 160, 131, 18, 'Z', 168, 161, 135, '"', 154, 168, 162, 139, '2', 218, 168, 163, 143, 'B', 26, ')', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'i', 's', 'o', '8', '8', '5', '9', '7', 0, 0, '(', 160, 'L', 'L', 241, '(', '$', 151, 'l', 202, ')', 168, 164, 146, 216, '*', 172, 180, 2, '@', 196, 176, 196, '"', 203, ',', 138, '-', 198, 216, '-', 141, '9', 246, 216, '.', 144, 245, 18, 153, 'd', 147, 'Q', 'V', 153, 'e', 151, 'a', 150, 153, 'f', 155, 'q', 214, 153, 'g', 159, 129, 22, 154, 'h', 163, 145, 6, '@', 'i', 166, 157, 134, 'Z', 'j', 170, 173, 198, 'Z', 'k', 174, 189, 6, '[', 'l', 178, 205, 'F', '[', 'm', 182, 221, 134, '[', 'n', 186, 237, 198, '[', 'o', 190, 253, 6, '\\', 'p', 194, 13, 'G', '\\', 'q', 198, 29, 135, '\\', 'r', 202, '-', 199, '\\', 's', 206, '=', 7, 29, 0, 'i', 's', 'o', '8', '8', '5', '9', '8', 0, 0, '(', 160, 0, ' ', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 'r', 205, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 'r', 207, '.', 188, 244, 226, 11, 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, 128, 196, 'B', 14, 'I', 'd', 145, 'F', 30, 137, 'd', 146, 'J', '.', 201, 'd', 147, 'N', '>', 9, 'e', 148, 'R', 'N', 'I', 'e', 149, 'V', '^', 137, 'e', 150, 'Z', 'n', 201, '%', 0, 0, '4', 236, '0', 0, 'i', 's', 'o', '8', '8', '5', '9', '9', 0, 0, '4', 28, 'E', '#', 205, '4', 212, 'T', 'c', 205, '5', 216, 'd', 163, 205, '6', 220, 176, '4', 213, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 29, 197, '#', 207, '<', 244, 212, 'c', 207, '=', 248, 228, 163, 207, '>', 252, 180, 'D', 213, '?', 'i', 's', 'o', '8', '8', '5', '9', '1', '0', 0, 0, '(', 160, 16, '$', 17, 'H', '(', 153, 4, 211, ')', '5', 'A', 'T', 213, 'V', 'r', 181, 242, 'U', 'P', 176, 20, '4', 'Q', 'H', ')', 157, 20, 211, '-', '6', 'E', 'd', 21, 'W', 's', 'E', 12, 150, 'P', 0, 5, '#', 204, '0', 196, 20, 'c', 140, 'J', 12, '%', 'c', 209, '2', 20, '5', 227, 204, '3', 208, 244, '4', 212, '4', 212, 'T', 'c', 'M', 'W', 216, 156, 165, 205, '6', 220, 't', 227, 205, '7', 1, 133, '#', 206, '8', 228, 148, 'c', 206, 'J', 13, 165, 's', 209, ':', 21, 181, 227, 206, ';', 240, 248, 'D', 212, '<', 244, 212, 'c', 143, 'W', 248, 160, 165, 207, '>', 252, 244, 227, 143, 'L', 'i', 's', 'o', '8', '8', '5', '9', '1', '1', 0, 't', 'i', 's', '6', '2', '0', 0, 0, '(', 160, 'x', 250, ')', 168, 161, 138, ':', '*', 169, 165, 154, 'z', '*', 170, 169, 170, 186, '*', 171, 173, 186, 250, '*', 172, 177, 202, ':', '+', 173, 181, 218, 'z', '+', 174, 185, 234, 186, '+', 175, 189, 250, 250, '+', 176, 193, 10, ';', ',', 177, 197, 26, '{', ',', 178, 201, '*', 187, ',', 179, 205, ':', 251, ',', 180, 209, 'J', ';', '-', 181, 213, 'Z', '{', '-', 0, 0, 0, 0, 0, 182, 217, 'j', 187, '-', 183, 221, 'z', 251, '-', 184, 225, 138, ';', '.', 185, 229, 154, '{', '.', 186, 233, 170, 187, '.', 187, 237, 186, 251, '.', 188, 241, 202, ';', '/', 189, 0, 0, 0, 0, 0, 'i', 's', 'o', '8', '8', '5', '9', '1', '3', 0, 0, '(', 160, '\\', ',', 202, '(', 164, '`', 'l', 202, ')', 216, 164, 178, 212, '*', 172, 180, 226, 138, '1', 176, 196, '"', 203, ',', 22, 215, 'b', 203, '-', 248, 228, 194, 212, '.', 188, 244, 226, 139, '9', 4, 169, 4, 144, 'A', 196, 20, 'c', 145, 'D', 12, '%', 227, 22, 'E', ' ', 193, 132, 'R', 'M', 'U', 237, 212, 211, '4', 'C', 'U', 'c', 205, '5', 'g', 229, 244, 212, 'W', 220, 192, '%', 215, '7', 5, 173, 20, 208, 'A', 228, 148, 's', 209, 'D', 13, 165, 243, 'V', 'E', '!', 197, 148, 146, 'M', 'V', 241, 228, 211, '<', 'D', 213, 'c', 207, '=', 'h', 233, 4, 21, 'X', 252, 196, '5', 23, 197, 'i', 's', 'o', '8', '8', '5', '9', '1', '4', 0, 0, '(', 160, 212, 'k', 239, '(', 10, '-', 't', 239, ')', 3, 167, 'R', '0', 190, 9, 183, 226, 'J', '[', 249, 234, 235, 209, 'G', 251, 242, 'k', 'K', 191, 4, 251, 'k', 240, 191, 10, 31, 140, '0', 192, 192, 4, '#', 204, '0', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 'i', 'E', '#', 205, '4', 212, 'T', 'c', 'M', 192, 216, 'd', 163, 205, '6', 220, 't', 179, 214, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 'j', 197, '#', 207, '<', 244, 212, 'c', 143, 192, 248, 228, 163, 207, '>', 252, 244, 195, 214, '?', 'i', 's', 'o', '8', '8', '5', '9', '1', '5', 0, 'l', 'a', 't', 'i', 'n', '9', 0, 0, ')', '$', 151, 'R', 213, ')', 'V', 165, 162, 202, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 'r', 213, 'b', 203, '-', 's', 229, 162, 203, '.', 'G', '!', 213, 214, '/', 192, 4, '#', 204, '0', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 208, 'D', '#', 205, '4', 212, 'T', 'c', 205, '5', 216, 'd', 163, 205, '6', 220, 't', 227, 205, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 240, 196, '#', 207, '<', 244, 212, 'c', 207, '=', 248, 228, 163, 207, '>', 252, 244, 227, 207, '?', 'i', 's', 'o', '8', '8', '5', '9', '1', '6', 0, 0, '(', 160, 16, 'T', 'P', 'N', '$', 'c', '\\', 213, ')', 'V', 165, 146, 215, '*', 'n', 181, 242, 22, '\\', 176, 196, 194, 144, 'N', 'r', ']', 'l', 203, '-', 's', '5', 164, 215, '.', 'G', '!', 213, 'V', '\\', 192, 4, '#', 140, '@', 196, 24, 'd', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 16, 237, '$', 205, '4', 212, 20, 'e', 205, 'S', 'e', 'e', 163, 205, '6', 220, 'X', 180, 215, '7', 224, 132, '#', 206, '@', 228, 28, 'd', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 17, 241, '$', 207, '<', 244, 24, 'e', 15, 'T', 'f', 229, 163, 207, '>', 252, '\\', 196, 215, '?', 'c', 'p', '1', '2', '5', '0', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '0', 0, 0, ' ', '$', 3, 'P', '1', 0, 24, 's', 156, 177, 198, 0, 't', '\\', 149, 199, 'O', 'e', '%', 151, '[', 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 0, 156, 'l', 213, 199, 'P', 'i', '5', 215, '[', 160, 248, 245, 'W', 'N', 164, 16, 'd', 202, ')', 168, 164, '2', 213, '*', 172, 180, 226, 10, '\\', 176, 196, 18, 152, 'N', 180, 212, 'b', 203, '-', 184, 20, 'D', 213, '.', '7', 13, 134, 'S', '\\', 'I', 5, '#', 140, '@', 196, 204, 'd', 208, '1', 12, '%', 'c', 209, '2', 24, '5', 227, 140, 'C', 16, 237, 244, 211, '4', 212, 20, 'e', 205, '5', 'M', 141, 165, 'M', 'Y', 220, 't', 's', 213, '7', 'J', 133, '#', 206, '@', 228, 208, 't', 208, '9', 13, 165, 's', 209, ':', 25, 181, 227, 206, 'C', 17, 241, 4, 212, '<', 244, 24, 'e', 207, '=', 'N', 145, 165, 143, 'Y', 252, 244, 131, 21, '`', 'c', 'p', '1', '2', '5', '1', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '1', 0, 0, ' ', 210, 'M', 'W', 'q', 136, 24, 's', 156, 177, 198, '$', 'w', 156, 157, 199, 218, 'q', 183, 157, 'w', ' ', 'N', 'L', 177, 197, 23, 'o', 252, '0', 196, 0, 156, '|', 226, 199, '(', 170, 152, '"', 139, 160, 't', 183, '"', 'v', 164, 180, 'h', 202, ')', 209, 165, 'B', 221, '*', 172, 180, 226, 202, 'u', 176, 196, 'b', 29, 137, '.', 214, 'b', 203, '-', 31, 154, ',', 226, '.', '&', 'V', '7', 'b', 137, 223, 129, 23, 158, 'x', 227, 145, 'W', 158, 'y', 231, 161, 151, 158, 'z', 235, 177, 215, 158, '{', 239, 193, 23, 159, '|', 243, 209, 'W', 159, '}', 247, 225, 151, 159, '~', 251, 241, 215, 159, 127, 255, 1, 24, 160, 128, 3, 18, 'X', 160, 129, 7, '"', 152, 160, 130, 11, '2', 216, 160, 131, 15, 'B', 24, 161, 132, 19, 'R', 'X', 161, 133, 23, 'b', 152, 161, 134, 27, 'r', 216, 161, 135, 'c', 'p', '1', '2', '5', '2', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '2', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, '}', 'u', '\\', 149, 199, 'G', 1, ' ', 23, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 130, 157, 'l', 213, 199, 'H', 1, '0', 'W', '[', 160, 132, '"', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 162, 202, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 162, 203, '.', 188, 244, 226, 203, '/', 192, 4, '#', 204, '0', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 208, 'D', '#', 205, '4', 212, 'T', 'c', 205, '5', 216, 'd', 163, 205, '6', 220, 't', 227, 205, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 240, 196, '#', 207, '<', 244, 212, 'c', 207, '=', 248, 228, 163, 207, '>', 252, 244, 227, 207, '?', 'c', 'p', '1', '2', '5', '3', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '3', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, 0, 't', 12, 128, 199, 0, 0, 0, 0, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 0, 156, 12, 192, 199, 0, 0, 0, 0, 0, 160, ',', 198, 216, '(', 164, 148, 'b', 202, ')', 168, 164, 2, 192, '*', 172, 180, 226, 'J', 196, 176, 196, '"', 203, ',', 138, 213, 'b', 203, '-', 141, '9', 246, 216, '.', 144, 245, 18, 153, 'd', 147, 'Q', 'V', 153, 'e', 151, 'a', 150, 153, 'f', 155, 'q', 214, 153, 'g', 159, 129, 22, 154, 'h', 163, 145, 6, '@', 'i', 166, 157, 134, 'Z', 'j', 170, 173, 198, 'Z', 'k', 174, 189, 6, '[', 'l', 178, 205, 'F', '[', 'm', 182, 221, 134, '[', 'n', 186, 237, 198, '[', 'o', 190, 253, 6, '\\', 'p', 194, 13, 'G', '\\', 'q', 198, 29, 135, '\\', 'r', 202, '-', 199, '\\', 's', 206, '=', 7, 29, 0, 'c', 'p', '1', '2', '5', '4', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '4', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, '}', 'u', '\\', 149, 199, 'G', 1, 0, 0, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 130, 157, 'l', 213, 199, 'H', 1, 0, '@', '[', 160, 132, '"', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 162, 202, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 162, 203, '.', 188, 244, 226, 203, '/', 192, 4, '#', 204, '0', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 28, 'E', '#', 205, '4', 212, 'T', 'c', 205, '5', 216, 'd', 163, 205, '6', 220, 176, '4', 213, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 29, 197, '#', 207, '<', 244, 212, 'c', 207, '=', 248, 228, 163, 207, '>', 252, 180, 'D', 213, '?', 'c', 'p', '1', '2', '5', '5', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '5', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, '}', 'u', 12, 128, 199, 0, 0, 0, 0, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 130, 157, 12, 192, 199, 0, 0, 0, 0, 0, 160, 132, '"', 202, '(', '"', 151, 'b', 202, ')', 168, 164, 'r', 205, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 'r', 207, '.', 188, 244, 226, 203, '/', '/', 194, 24, 163, 140, '3', 210, 'X', 163, 141, '7', 226, 8, '@', 142, ':', 238, 200, 'c', 143, '>', 254, 8, 'd', 144, ']', 'z', 249, '%', 152, 'a', 2, 0, 0, 0, 0, 0, 0, 0, 0, 'B', 14, 'I', 'd', 145, 'F', 30, 137, 'd', 146, 'J', '.', 201, 'd', 147, 'N', '>', 9, 'e', 148, 'R', 'N', 'I', 'e', 149, 'V', '^', 137, 'e', 150, 'Z', 'n', 201, '%', 0, 0, '4', 236, '0', 0, 'c', 'p', '1', '2', '5', '6', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '6', 0, 0, ' ', '$', 'O', 'Z', '1', ']', 24, 's', 156, 177, 198, '}', 'u', ',', 169, 199, 'G', 'Q', 'z', 'i', 165, 153, 'N', 'L', 177, 197, 23, 'o', 252, '0', 196, 152, 158, 'l', 233, 199, 'H', '-', 204, 176, 166, 160, 136, ')', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 178, 233, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, '2', 230, '.', 188, 244, 226, 11, 153, 156, 150, 'i', 230, 153, 'h', 166, 169, 230, 154, 'l', 182, 233, 230, 155, 'p', 198, ')', 231, 156, 't', 214, 'i', 231, 157, 'x', 230, 169, 231, '5', '{', 242, 217, 167, 159, 127, 2, 26, 168, 160, 224, 12, '*', 14, 161, 133, 26, 'z', 232, '9', 232, 164, 163, 206, ':', 136, '&', 234, 206, ';', 138, '.', 202, 'h', 163, 244, '8', 250, 232, '=', 144, 230, 19, 233, '>', 252, '4', 236, 'p', 167, 'c', 'p', '1', '2', '5', '7', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '7', 0, 0, ' ', '$', 3, 'P', '1', 0, 24, 's', 156, 177, 198, 0, 't', 12, 128, 199, 0, 160, 226, 23, '.', 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 0, 156, 12, 192, 199, 0, 188, 18, 24, 0, 160, 0, ' ', 202, '(', 164, 0, '`', 202, ')', 216, 164, 178, 212, '*', 172, 180, 226, 138, '1', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 248, 228, 194, 212, '.', 188, 244, 226, 139, '9', 4, 169, 4, 144, 'A', 196, 20, 'c', 145, 'D', 12, '%', 227, 22, 'E', ' ', 193, 132, 'R', 'M', 'U', 237, 212, 211, '4', 'C', 'U', 'c', 205, '5', 'g', 229, 244, 212, 'W', 220, 192, '%', 215, '7', 5, 173, 20, 208, 'A', 228, 148, 's', 209, 'D', 13, 165, 243, 'V', 'E', '!', 197, 148, 146, 'M', 'V', 241, 228, 211, '<', 'D', 213, 'c', 207, '=', 'h', 233, 4, 21, 'X', 252, 196, '5', 23, '`', 'c', 'p', '1', '2', '5', '8', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '8', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, '}', 'u', 12, 128, 199, 'G', 1, 0, 0, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 130, 157, 12, 192, 199, 'H', 1, 0, '@', '[', 160, 132, '"', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 162, 202, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 162, 203, '.', 188, 244, 226, 203, '/', 192, 4, '#', 140, '@', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 132, '5', 227, 204, '3', 16, 'E', 's', 216, '4', 212, 212, 'e', 205, '5', 216, 'd', 163, 205, '6', 220, 220, 'e', 216, '7', 224, 132, '#', 206, '@', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 133, 181, 227, 206, ';', 17, 197, 131, 216, '<', 244, 216, 'e', 207, '=', 248, 228, 163, 207, '>', 252, 224, '5', 242, '?', 'k', 'o', 'i', '8', 'r', 0, 0, ' ', '3', 211, '\\', 179, 205, '7', 227, 156, 179, 206, ';', 243, 220, 243, 214, '\\', 'w', 237, 245, 215, '`', 135, '-', 'v', 204, 'c', 163, 156, '2', 203, '.', 191, 12, 138, 204, 176, 200, 'r', 203, '=', '>', 255, 12, 244, 135, 'A', 11, '=', '4', 209, 'E', 27, '}', '4', 210, 'I', '+', 189, '4', 211, 'M', ';', 253, 't', 't', 'P', 'G', '-', 245, 212, 'T', 'W', 'm', 245, 213, 'X', 'g', 173, 'u', '*', 29, 254, 7, '`', 133, 3, 18, '8', 161, 128, 20, 30, 136, '`', 130, 10, '.', 200, '`', 131, 14, 'z', 248, ' ', 132, 17, 'J', 'X', '`', 128, 27, 'j', 'h', 224, 133, 28, 'b', 'h', 'a', 134, 253, '}', 7, '^', '}', 227, 145, '7', 159, 'x', 244, 157, 135, '^', 'z', 234, 173, 199, '^', '{', 238, 249, 247, 30, '|', 241, 201, 'W', '^', 'x', 251, 233, 'g', 222, '}', 252, 225, 'g', '_', '~', 'k', 'o', 'i', '8', 'u', 0, 0, ' ', '3', 211, '\\', 179, 205, '7', 227, 156, 179, 206, ';', 243, 220, 243, 214, '\\', 'w', 237, 245, 215, '`', 135, '-', 'v', 204, 'c', 163, 156, '2', 203, '.', 191, 12, 138, 204, 176, 200, 'r', 203, '=', '>', 255, 12, 244, 135, '"', 10, 'M', 'b', 137, 'E', 27, '}', '4', 210, 'I', 187, 184, '4', 211, 'M', ';', 253, 't', 't', 212, 'E', 'm', 221, 'u', 'T', 'W', 'm', 245, 213, 'X', 183, 168, 'u', '*', 29, 254, 7, '`', 133, 3, 18, '8', 161, 128, 20, 30, 136, '`', 130, 10, '.', 200, '`', 131, 14, 'z', 248, ' ', 132, 17, 'J', 'X', '`', 128, 27, 'j', 'h', 224, 133, 28, 'b', 'h', 'a', 134, 253, '}', 7, '^', '}', 227, 145, '7', 159, 'x', 244, 157, 135, '^', 'z', 234, 173, 199, '^', '{', 238, 249, 247, 30, '|', 241, 201, 'W', '^', 'x', 251, 233, 'g', 222, '}', 252, 225, 'g', '_', '~', 'c', 'p', '4', '3', '7', 0, 0, ' ', 199, 240, 147, 142, '8', 228, 128, 'S', 206, '9', 234, 172, 131, 206, ';', 238, 176, 'C', 'L', '1', 201, 152, 'c', 12, '=', 246, 200, 179, 'O', '>', 255, 'X', 195, 141, '(', 163, 148, 18, '2', ']', 225, 180, '3', 143, '>', 241, 'D', 163, 138, '.', 191, 192, 204, 'J', '/', 188, 132, 178, 202, '.', '`', 135, '-', '6', 205, ':', '?', 13, '5', 209, 'C', 'G', 253, 's', 209, 'K', '+', 157, 180, 205, '7', 243, 188, 's', 206, '3', 247, 204, 't', 211, 'H', 11, '}', '5', 213, 'N', 251, 172, 'u', 213, 'V', 'K', '=', 245, 209, 'F', 3, 29, 't', 214, 'X', 227, '\\', 's', 215, '\\', '{', 253, 245, 214, 179, '}', 'c', 153, 'p', 165, 21, 'W', 139, 'q', 168, 'm', 182, 154, 'm', '*', '#', 'w', 219, 202, '-', 199, 242, 178, 203, '1', 203, '|', 15, 203, 176, 160, '|', 'K', 202, ' ', 203, '2', '6', '(', 'c', 'p', '8', '5', '0', 0, 0, ' ', 199, 240, 147, 142, '8', 228, 128, 'S', 206, '9', 234, 172, 131, 206, ';', 238, 176, 'C', 'L', '1', 201, 152, 'c', 12, '=', 246, 200, 179, 'O', '>', 255, 'X', 195, 13, '>', 163, '`', 's', 13, ']', 225, 180, '3', 143, '>', 241, 'D', 163, 138, '.', 191, 184, 194, 'J', '/', 188, 132, 178, 202, '.', '`', 135, '-', '6', 205, ':', 7, '#', 12, '0', 169, 'D', 253, 's', 209, 'K', 139, 'R', 138, 205, '7', 243, 188, 's', 206, '3', 247, '<', 206, '0', 'H', 11, '}', '5', 213, 'N', 251, 172, '5', ')', 240, '@', 163, 204, '2', 200, 180, 212, 140, '3', 207, 224, '\\', 's', 215, '\\', 155, 194, 204, 214, 211, '|', 'C', 141, '4', 245, 'T', 'S', 139, '?', 222, 'h', 179, 'M', '6', 253, 't', 243, 10, '-', 173, 196, '"', 177, '/', 182, 156, 'r', 15, '.', 176, 160, 'r', 'K', '.', 179, 200, '2', '6', '(', 'c', 'p', '8', '6', '6', 0, 0, ' ', 223, 129, 23, 158, 'x', 227, 145, 'W', 158, 'y', 231, 161, 151, 158, 'z', 235, 177, 215, 158, '{', 239, 193, 23, 159, '|', 243, 209, 'W', 159, '}', 247, 225, 151, 159, '~', 251, 241, 215, 159, 127, 255, 1, 24, 160, 128, 3, 18, 'X', 160, 129, 7, '"', 152, 160, 130, 11, '2', 216, 160, 131, '`', 135, '-', '6', 205, ':', '?', 13, '5', 209, 'C', 'G', 253, 's', 209, 'K', '+', 157, 180, 205, '7', 243, 188, 's', 206, '3', 247, 204, 't', 211, 'H', 11, '}', '5', 213, 'N', 251, 172, 'u', 213, 'V', 'K', '=', 245, 209, 'F', 3, 29, 't', 214, 'X', 227, '\\', 's', 215, '\\', '{', 253, 245, 214, 15, 'B', 24, 161, 132, 19, 'R', 'X', 161, 133, 23, 'b', 152, 161, 134, 27, 'r', 216, 161, 135, 209, '}', 'H', 157, 136, 215, 149, 216, 221, 138, 176, 160, '|', 'K', 202, '&', 147, '2', '6', '(', 'i', 'b', 'm', '1', '0', '4', '7', 0, 'c', 'p', '1', '0', '4', '7', 0, 0, 1, 156, '$', '`', 200, 31, 151, '4', 226, 200, 2, 12, '4', 224, 192, 3, 16, 'D', ' ', 193, 4, 157, 20, 130, 192, '!', 24, 'd', ' ', 201, '#', 28, 't', 224, 193, 7, 128, 4, '"', 200, ' ', 132, '(', 'p', 193, 6, 136, '$', 162, 200, '"', 140, 20, '`', 192, 1, 144, 'D', 'b', 193, '$', 148, 'T', 'b', 9, 1, 152, 'd', 162, 201, '&', 20, 'T', 224, 137, 6, ' ', 128, '"', 14, '9', 224, 132, '3', 'N', '9', 231, 196, '#', 138, 11, '<', 160, 176, 2, 31, '&', 164, 163, 206, ':', 232, 180, 227, 206, ';', 236, '|', 19, 2, 9, '*', 164, 176, 131, 23, '-', 188, ' ', 12, '1', 192, 4, '3', 'L', '1', 199, 'D', 'c', 10, 11, '%', '|', 225, 195, 15, 248, '$', 163, 204, '2', 200, '4', 227, 204, '3', 204, 128, 161, 195, 8, '@', 156, 208, 131, 8, 216, 132, '!', 198, 24, 'd', 148, 'a', 198, 25, 'h', 164, 177, 202, '.', 240, 244, 227, 'O', ',', 176, 168, 177, 6, 27, 'm', 184, 241, 6, 28, 'q', 200, 161, 138, '.', 230, 224, 'b', 12, ')', 181, 248, '1', 7, 29, 'u', 216, 'q', 7, 30, 'y', 232, 17, 202, '/', 208, 'l', 225, 141, '+', 172, 140, 'R', 202, '-', 169, 156, 'b', 11, '/', 189, 248, 210, 13, '*', 175, 't', 'A', 203, '5', '{', 4, '!', 196, 16, 'D', 20, 'a', 196, 17, 'H', '$', 209, 10, '=', 246, 200, '3', 'O', '=', '}', '(', 177, 4, 19, 'M', '8', 241, 4, 20, 'Q', 'H', 145, 203, '>', 252, 228, 163, 207, '?', '\\', 220, '3', 5, 21, 'U', 'X', 'q', 5, 22, 'Y', 'h', '!', 11, '5', 214, 'H', '3', 'M', '5', '0', 196, ' ', 195, 12, '4', 212, '`', 195, 13, '8', 228, '0', 203, '6', 220, 'd', 163, 205, '\''} + +// C documentation +// +// /* Table of characters that appear in legacy 8-bit codepages, +// * limited to 1024 slots (10 bit indices). The first 256 entries +// * are elided since those characters are obviously all included. */ +var _legacy_chars = [612]uint16{ + 0: uint16(256), + 1: uint16(257), + 2: uint16(258), + 3: uint16(259), + 4: uint16(260), + 5: uint16(261), + 6: uint16(262), + 7: uint16(263), + 8: uint16(264), + 9: uint16(265), + 10: uint16(266), + 11: uint16(267), + 12: uint16(268), + 13: uint16(269), + 14: uint16(270), + 15: uint16(271), + 16: uint16(272), + 17: uint16(273), + 18: uint16(274), + 19: uint16(275), + 20: uint16(278), + 21: uint16(279), + 22: uint16(280), + 23: uint16(281), + 24: uint16(282), + 25: uint16(283), + 26: uint16(284), + 27: uint16(285), + 28: uint16(286), + 29: uint16(287), + 30: uint16(288), + 31: uint16(289), + 32: uint16(290), + 33: uint16(291), + 34: uint16(292), + 35: uint16(293), + 36: uint16(294), + 37: uint16(295), + 38: uint16(296), + 39: uint16(297), + 40: uint16(298), + 41: uint16(299), + 42: uint16(302), + 43: uint16(303), + 44: uint16(304), + 45: uint16(305), + 46: uint16(308), + 47: uint16(309), + 48: uint16(310), + 49: uint16(311), + 50: uint16(312), + 51: uint16(313), + 52: uint16(314), + 53: uint16(315), + 54: uint16(316), + 55: uint16(317), + 56: uint16(318), + 57: uint16(321), + 58: uint16(322), + 59: uint16(323), + 60: uint16(324), + 61: uint16(325), + 62: uint16(326), + 63: uint16(327), + 64: uint16(328), + 65: uint16(330), + 66: uint16(331), + 67: uint16(332), + 68: uint16(333), + 69: uint16(336), + 70: uint16(337), + 71: uint16(338), + 72: uint16(339), + 73: uint16(340), + 74: uint16(341), + 75: uint16(342), + 76: uint16(343), + 77: uint16(344), + 78: uint16(345), + 79: uint16(346), + 80: uint16(347), + 81: uint16(348), + 82: uint16(349), + 83: uint16(350), + 84: uint16(351), + 85: uint16(352), + 86: uint16(353), + 87: uint16(354), + 88: uint16(355), + 89: uint16(356), + 90: uint16(357), + 91: uint16(358), + 92: uint16(359), + 93: uint16(360), + 94: uint16(361), + 95: uint16(362), + 96: uint16(363), + 97: uint16(364), + 98: uint16(365), + 99: uint16(366), + 100: uint16(367), + 101: uint16(368), + 102: uint16(369), + 103: uint16(370), + 104: uint16(371), + 105: uint16(372), + 106: uint16(373), + 107: uint16(374), + 108: uint16(375), + 109: uint16(376), + 110: uint16(377), + 111: uint16(378), + 112: uint16(379), + 113: uint16(380), + 114: uint16(381), + 115: uint16(382), + 116: uint16(402), + 117: uint16(416), + 118: uint16(417), + 119: uint16(431), + 120: uint16(432), + 121: uint16(536), + 122: uint16(537), + 123: uint16(538), + 124: uint16(539), + 125: uint16(710), + 126: uint16(711), + 127: uint16(728), + 128: uint16(729), + 129: uint16(731), + 130: uint16(732), + 131: uint16(733), + 132: uint16(768), + 133: uint16(769), + 134: uint16(771), + 135: uint16(777), + 136: uint16(803), + 137: uint16(890), + 138: uint16(900), + 139: uint16(901), + 140: uint16(902), + 141: uint16(904), + 142: uint16(905), + 143: uint16(906), + 144: uint16(908), + 145: uint16(910), + 146: uint16(911), + 147: uint16(912), + 148: uint16(913), + 149: uint16(914), + 150: uint16(915), + 151: uint16(916), + 152: uint16(917), + 153: uint16(918), + 154: uint16(919), + 155: uint16(920), + 156: uint16(921), + 157: uint16(922), + 158: uint16(923), + 159: uint16(924), + 160: uint16(925), + 161: uint16(926), + 162: uint16(927), + 163: uint16(928), + 164: uint16(929), + 165: uint16(931), + 166: uint16(932), + 167: uint16(933), + 168: uint16(934), + 169: uint16(935), + 170: uint16(936), + 171: uint16(937), + 172: uint16(938), + 173: uint16(939), + 174: uint16(940), + 175: uint16(941), + 176: uint16(942), + 177: uint16(943), + 178: uint16(944), + 179: uint16(945), + 180: uint16(946), + 181: uint16(947), + 182: uint16(948), + 183: uint16(949), + 184: uint16(950), + 185: uint16(951), + 186: uint16(952), + 187: uint16(953), + 188: uint16(954), + 189: uint16(955), + 190: uint16(956), + 191: uint16(957), + 192: uint16(958), + 193: uint16(959), + 194: uint16(960), + 195: uint16(961), + 196: uint16(962), + 197: uint16(963), + 198: uint16(964), + 199: uint16(965), + 200: uint16(966), + 201: uint16(967), + 202: uint16(968), + 203: uint16(969), + 204: uint16(970), + 205: uint16(971), + 206: uint16(972), + 207: uint16(973), + 208: uint16(974), + 209: uint16(1025), + 210: uint16(1026), + 211: uint16(1027), + 212: uint16(1028), + 213: uint16(1029), + 214: uint16(1030), + 215: uint16(1031), + 216: uint16(1032), + 217: uint16(1033), + 218: uint16(1034), + 219: uint16(1035), + 220: uint16(1036), + 221: uint16(1038), + 222: uint16(1039), + 223: uint16(1040), + 224: uint16(1041), + 225: uint16(1042), + 226: uint16(1043), + 227: uint16(1044), + 228: uint16(1045), + 229: uint16(1046), + 230: uint16(1047), + 231: uint16(1048), + 232: uint16(1049), + 233: uint16(1050), + 234: uint16(1051), + 235: uint16(1052), + 236: uint16(1053), + 237: uint16(1054), + 238: uint16(1055), + 239: uint16(1056), + 240: uint16(1057), + 241: uint16(1058), + 242: uint16(1059), + 243: uint16(1060), + 244: uint16(1061), + 245: uint16(1062), + 246: uint16(1063), + 247: uint16(1064), + 248: uint16(1065), + 249: uint16(1066), + 250: uint16(1067), + 251: uint16(1068), + 252: uint16(1069), + 253: uint16(1070), + 254: uint16(1071), + 255: uint16(1072), + 256: uint16(1073), + 257: uint16(1074), + 258: uint16(1075), + 259: uint16(1076), + 260: uint16(1077), + 261: uint16(1078), + 262: uint16(1079), + 263: uint16(1080), + 264: uint16(1081), + 265: uint16(1082), + 266: uint16(1083), + 267: uint16(1084), + 268: uint16(1085), + 269: uint16(1086), + 270: uint16(1087), + 271: uint16(1088), + 272: uint16(1089), + 273: uint16(1090), + 274: uint16(1091), + 275: uint16(1092), + 276: uint16(1093), + 277: uint16(1094), + 278: uint16(1095), + 279: uint16(1096), + 280: uint16(1097), + 281: uint16(1098), + 282: uint16(1099), + 283: uint16(1100), + 284: uint16(1101), + 285: uint16(1102), + 286: uint16(1103), + 287: uint16(1105), + 288: uint16(1106), + 289: uint16(1107), + 290: uint16(1108), + 291: uint16(1109), + 292: uint16(1110), + 293: uint16(1111), + 294: uint16(1112), + 295: uint16(1113), + 296: uint16(1114), + 297: uint16(1115), + 298: uint16(1116), + 299: uint16(1118), + 300: uint16(1119), + 301: uint16(1168), + 302: uint16(1169), + 303: uint16(1456), + 304: uint16(1457), + 305: uint16(1458), + 306: uint16(1459), + 307: uint16(1460), + 308: uint16(1461), + 309: uint16(1462), + 310: uint16(1463), + 311: uint16(1464), + 312: uint16(1465), + 313: uint16(1467), + 314: uint16(1468), + 315: uint16(1469), + 316: uint16(1470), + 317: uint16(1471), + 318: uint16(1472), + 319: uint16(1473), + 320: uint16(1474), + 321: uint16(1475), + 322: uint16(1488), + 323: uint16(1489), + 324: uint16(1490), + 325: uint16(1491), + 326: uint16(1492), + 327: uint16(1493), + 328: uint16(1494), + 329: uint16(1495), + 330: uint16(1496), + 331: uint16(1497), + 332: uint16(1498), + 333: uint16(1499), + 334: uint16(1500), + 335: uint16(1501), + 336: uint16(1502), + 337: uint16(1503), + 338: uint16(1504), + 339: uint16(1505), + 340: uint16(1506), + 341: uint16(1507), + 342: uint16(1508), + 343: uint16(1509), + 344: uint16(1510), + 345: uint16(1511), + 346: uint16(1512), + 347: uint16(1513), + 348: uint16(1514), + 349: uint16(1520), + 350: uint16(1521), + 351: uint16(1522), + 352: uint16(1523), + 353: uint16(1524), + 354: uint16(1548), + 355: uint16(1563), + 356: uint16(1567), + 357: uint16(1569), + 358: uint16(1570), + 359: uint16(1571), + 360: uint16(1572), + 361: uint16(1573), + 362: uint16(1574), + 363: uint16(1575), + 364: uint16(1576), + 365: uint16(1577), + 366: uint16(1578), + 367: uint16(1579), + 368: uint16(1580), + 369: uint16(1581), + 370: uint16(1582), + 371: uint16(1583), + 372: uint16(1584), + 373: uint16(1585), + 374: uint16(1586), + 375: uint16(1587), + 376: uint16(1588), + 377: uint16(1589), + 378: uint16(1590), + 379: uint16(1591), + 380: uint16(1592), + 381: uint16(1593), + 382: uint16(1594), + 383: uint16(1600), + 384: uint16(1601), + 385: uint16(1602), + 386: uint16(1603), + 387: uint16(1604), + 388: uint16(1605), + 389: uint16(1606), + 390: uint16(1607), + 391: uint16(1608), + 392: uint16(1609), + 393: uint16(1610), + 394: uint16(1611), + 395: uint16(1612), + 396: uint16(1613), + 397: uint16(1614), + 398: uint16(1615), + 399: uint16(1616), + 400: uint16(1617), + 401: uint16(1618), + 402: uint16(1657), + 403: uint16(1662), + 404: uint16(1670), + 405: uint16(1672), + 406: uint16(1681), + 407: uint16(1688), + 408: uint16(1705), + 409: uint16(1711), + 410: uint16(1722), + 411: uint16(1726), + 412: uint16(1729), + 413: uint16(1746), + 414: uint16(3585), + 415: uint16(3586), + 416: uint16(3587), + 417: uint16(3588), + 418: uint16(3589), + 419: uint16(3590), + 420: uint16(3591), + 421: uint16(3592), + 422: uint16(3593), + 423: uint16(3594), + 424: uint16(3595), + 425: uint16(3596), + 426: uint16(3597), + 427: uint16(3598), + 428: uint16(3599), + 429: uint16(3600), + 430: uint16(3601), + 431: uint16(3602), + 432: uint16(3603), + 433: uint16(3604), + 434: uint16(3605), + 435: uint16(3606), + 436: uint16(3607), + 437: uint16(3608), + 438: uint16(3609), + 439: uint16(3610), + 440: uint16(3611), + 441: uint16(3612), + 442: uint16(3613), + 443: uint16(3614), + 444: uint16(3615), + 445: uint16(3616), + 446: uint16(3617), + 447: uint16(3618), + 448: uint16(3619), + 449: uint16(3620), + 450: uint16(3621), + 451: uint16(3622), + 452: uint16(3623), + 453: uint16(3624), + 454: uint16(3625), + 455: uint16(3626), + 456: uint16(3627), + 457: uint16(3628), + 458: uint16(3629), + 459: uint16(3630), + 460: uint16(3631), + 461: uint16(3632), + 462: uint16(3633), + 463: uint16(3634), + 464: uint16(3635), + 465: uint16(3636), + 466: uint16(3637), + 467: uint16(3638), + 468: uint16(3639), + 469: uint16(3640), + 470: uint16(3641), + 471: uint16(3642), + 472: uint16(3647), + 473: uint16(3648), + 474: uint16(3649), + 475: uint16(3650), + 476: uint16(3651), + 477: uint16(3652), + 478: uint16(3653), + 479: uint16(3654), + 480: uint16(3655), + 481: uint16(3656), + 482: uint16(3657), + 483: uint16(3658), + 484: uint16(3659), + 485: uint16(3660), + 486: uint16(3661), + 487: uint16(3662), + 488: uint16(3663), + 489: uint16(3664), + 490: uint16(3665), + 491: uint16(3666), + 492: uint16(3667), + 493: uint16(3668), + 494: uint16(3669), + 495: uint16(3670), + 496: uint16(3671), + 497: uint16(3672), + 498: uint16(3673), + 499: uint16(3674), + 500: uint16(3675), + 501: uint16(7682), + 502: uint16(7683), + 503: uint16(7690), + 504: uint16(7691), + 505: uint16(7710), + 506: uint16(7711), + 507: uint16(7744), + 508: uint16(7745), + 509: uint16(7766), + 510: uint16(7767), + 511: uint16(7776), + 512: uint16(7777), + 513: uint16(7786), + 514: uint16(7787), + 515: uint16(7808), + 516: uint16(7809), + 517: uint16(7810), + 518: uint16(7811), + 519: uint16(7812), + 520: uint16(7813), + 521: uint16(7922), + 522: uint16(7923), + 523: uint16(8204), + 524: uint16(8205), + 525: uint16(8206), + 526: uint16(8207), + 527: uint16(8211), + 528: uint16(8212), + 529: uint16(8213), + 530: uint16(8215), + 531: uint16(8216), + 532: uint16(8217), + 533: uint16(8218), + 534: uint16(8220), + 535: uint16(8221), + 536: uint16(8222), + 537: uint16(8224), + 538: uint16(8225), + 539: uint16(8226), + 540: uint16(8230), + 541: uint16(8240), + 542: uint16(8249), + 543: uint16(8250), + 544: uint16(8319), + 545: uint16(8359), + 546: uint16(8362), + 547: uint16(8363), + 548: uint16(8364), + 549: uint16(8367), + 550: uint16(8470), + 551: uint16(8482), + 552: uint16(8729), + 553: uint16(8730), + 554: uint16(8734), + 555: uint16(8745), + 556: uint16(8776), + 557: uint16(8801), + 558: uint16(8804), + 559: uint16(8805), + 560: uint16(8976), + 561: uint16(8992), + 562: uint16(8993), + 563: uint16(9472), + 564: uint16(9474), + 565: uint16(9484), + 566: uint16(9488), + 567: uint16(9492), + 568: uint16(9496), + 569: uint16(9500), + 570: uint16(9508), + 571: uint16(9516), + 572: uint16(9524), + 573: uint16(9532), + 574: uint16(9552), + 575: uint16(9553), + 576: uint16(9554), + 577: uint16(9555), + 578: uint16(9556), + 579: uint16(9557), + 580: uint16(9558), + 581: uint16(9559), + 582: uint16(9560), + 583: uint16(9561), + 584: uint16(9562), + 585: uint16(9563), + 586: uint16(9564), + 587: uint16(9565), + 588: uint16(9566), + 589: uint16(9567), + 590: uint16(9568), + 591: uint16(9569), + 592: uint16(9570), + 593: uint16(9571), + 594: uint16(9572), + 595: uint16(9573), + 596: uint16(9574), + 597: uint16(9575), + 598: uint16(9576), + 599: uint16(9577), + 600: uint16(9578), + 601: uint16(9579), + 602: uint16(9580), + 603: uint16(9600), + 604: uint16(9604), + 605: uint16(9608), + 606: uint16(9612), + 607: uint16(9616), + 608: uint16(9617), + 609: uint16(9618), + 610: uint16(9619), + 611: uint16(9632), +} + +var _jis0208 = [84][94]uint16{ + 0: { + 0: uint16(12288), + 1: uint16(12289), + 2: uint16(12290), + 3: uint16(65292), + 4: uint16(65294), + 5: uint16(12539), + 6: uint16(65306), + 7: uint16(65307), + 8: uint16(65311), + 9: uint16(65281), + 10: uint16(12443), + 11: uint16(12444), + 12: uint16(180), + 13: uint16(65344), + 14: uint16(168), + 15: uint16(65342), + 16: uint16(65507), + 17: uint16(65343), + 18: uint16(12541), + 19: uint16(12542), + 20: uint16(12445), + 21: uint16(12446), + 22: uint16(12291), + 23: uint16(20189), + 24: uint16(12293), + 25: uint16(12294), + 26: uint16(12295), + 27: uint16(12540), + 28: uint16(8213), + 29: uint16(8208), + 30: uint16(65295), + 31: uint16(92), + 32: uint16(12316), + 33: uint16(8214), + 34: uint16(65372), + 35: uint16(8230), + 36: uint16(8229), + 37: uint16(8216), + 38: uint16(8217), + 39: uint16(8220), + 40: uint16(8221), + 41: uint16(65288), + 42: uint16(65289), + 43: uint16(12308), + 44: uint16(12309), + 45: uint16(65339), + 46: uint16(65341), + 47: uint16(65371), + 48: uint16(65373), + 49: uint16(12296), + 50: uint16(12297), + 51: uint16(12298), + 52: uint16(12299), + 53: uint16(12300), + 54: uint16(12301), + 55: uint16(12302), + 56: uint16(12303), + 57: uint16(12304), + 58: uint16(12305), + 59: uint16(65291), + 60: uint16(8722), + 61: uint16(177), + 62: uint16(215), + 63: uint16(247), + 64: uint16(65309), + 65: uint16(8800), + 66: uint16(65308), + 67: uint16(65310), + 68: uint16(8806), + 69: uint16(8807), + 70: uint16(8734), + 71: uint16(8756), + 72: uint16(9794), + 73: uint16(9792), + 74: uint16(176), + 75: uint16(8242), + 76: uint16(8243), + 77: uint16(8451), + 78: uint16(65509), + 79: uint16(65284), + 80: uint16(162), + 81: uint16(163), + 82: uint16(65285), + 83: uint16(65283), + 84: uint16(65286), + 85: uint16(65290), + 86: uint16(65312), + 87: uint16(167), + 88: uint16(9734), + 89: uint16(9733), + 90: uint16(9675), + 91: uint16(9679), + 92: uint16(9678), + 93: uint16(9671), + }, + 1: { + 0: uint16(9670), + 1: uint16(9633), + 2: uint16(9632), + 3: uint16(9651), + 4: uint16(9650), + 5: uint16(9661), + 6: uint16(9660), + 7: uint16(8251), + 8: uint16(12306), + 9: uint16(8594), + 10: uint16(8592), + 11: uint16(8593), + 12: uint16(8595), + 13: uint16(12307), + 25: uint16(8712), + 26: uint16(8715), + 27: uint16(8838), + 28: uint16(8839), + 29: uint16(8834), + 30: uint16(8835), + 31: uint16(8746), + 32: uint16(8745), + 41: uint16(8743), + 42: uint16(8744), + 43: uint16(172), + 44: uint16(8658), + 45: uint16(8660), + 46: uint16(8704), + 47: uint16(8707), + 59: uint16(8736), + 60: uint16(8869), + 61: uint16(8978), + 62: uint16(8706), + 63: uint16(8711), + 64: uint16(8801), + 65: uint16(8786), + 66: uint16(8810), + 67: uint16(8811), + 68: uint16(8730), + 69: uint16(8765), + 70: uint16(8733), + 71: uint16(8757), + 72: uint16(8747), + 73: uint16(8748), + 81: uint16(8491), + 82: uint16(8240), + 83: uint16(9839), + 84: uint16(9837), + 85: uint16(9834), + 86: uint16(8224), + 87: uint16(8225), + 88: uint16(182), + 93: uint16(9711), + }, + 2: { + 15: uint16(65296), + 16: uint16(65297), + 17: uint16(65298), + 18: uint16(65299), + 19: uint16(65300), + 20: uint16(65301), + 21: uint16(65302), + 22: uint16(65303), + 23: uint16(65304), + 24: uint16(65305), + 32: uint16(65313), + 33: uint16(65314), + 34: uint16(65315), + 35: uint16(65316), + 36: uint16(65317), + 37: uint16(65318), + 38: uint16(65319), + 39: uint16(65320), + 40: uint16(65321), + 41: uint16(65322), + 42: uint16(65323), + 43: uint16(65324), + 44: uint16(65325), + 45: uint16(65326), + 46: uint16(65327), + 47: uint16(65328), + 48: uint16(65329), + 49: uint16(65330), + 50: uint16(65331), + 51: uint16(65332), + 52: uint16(65333), + 53: uint16(65334), + 54: uint16(65335), + 55: uint16(65336), + 56: uint16(65337), + 57: uint16(65338), + 64: uint16(65345), + 65: uint16(65346), + 66: uint16(65347), + 67: uint16(65348), + 68: uint16(65349), + 69: uint16(65350), + 70: uint16(65351), + 71: uint16(65352), + 72: uint16(65353), + 73: uint16(65354), + 74: uint16(65355), + 75: uint16(65356), + 76: uint16(65357), + 77: uint16(65358), + 78: uint16(65359), + 79: uint16(65360), + 80: uint16(65361), + 81: uint16(65362), + 82: uint16(65363), + 83: uint16(65364), + 84: uint16(65365), + 85: uint16(65366), + 86: uint16(65367), + 87: uint16(65368), + 88: uint16(65369), + 89: uint16(65370), + }, + 3: { + 0: uint16(12353), + 1: uint16(12354), + 2: uint16(12355), + 3: uint16(12356), + 4: uint16(12357), + 5: uint16(12358), + 6: uint16(12359), + 7: uint16(12360), + 8: uint16(12361), + 9: uint16(12362), + 10: uint16(12363), + 11: uint16(12364), + 12: uint16(12365), + 13: uint16(12366), + 14: uint16(12367), + 15: uint16(12368), + 16: uint16(12369), + 17: uint16(12370), + 18: uint16(12371), + 19: uint16(12372), + 20: uint16(12373), + 21: uint16(12374), + 22: uint16(12375), + 23: uint16(12376), + 24: uint16(12377), + 25: uint16(12378), + 26: uint16(12379), + 27: uint16(12380), + 28: uint16(12381), + 29: uint16(12382), + 30: uint16(12383), + 31: uint16(12384), + 32: uint16(12385), + 33: uint16(12386), + 34: uint16(12387), + 35: uint16(12388), + 36: uint16(12389), + 37: uint16(12390), + 38: uint16(12391), + 39: uint16(12392), + 40: uint16(12393), + 41: uint16(12394), + 42: uint16(12395), + 43: uint16(12396), + 44: uint16(12397), + 45: uint16(12398), + 46: uint16(12399), + 47: uint16(12400), + 48: uint16(12401), + 49: uint16(12402), + 50: uint16(12403), + 51: uint16(12404), + 52: uint16(12405), + 53: uint16(12406), + 54: uint16(12407), + 55: uint16(12408), + 56: uint16(12409), + 57: uint16(12410), + 58: uint16(12411), + 59: uint16(12412), + 60: uint16(12413), + 61: uint16(12414), + 62: uint16(12415), + 63: uint16(12416), + 64: uint16(12417), + 65: uint16(12418), + 66: uint16(12419), + 67: uint16(12420), + 68: uint16(12421), + 69: uint16(12422), + 70: uint16(12423), + 71: uint16(12424), + 72: uint16(12425), + 73: uint16(12426), + 74: uint16(12427), + 75: uint16(12428), + 76: uint16(12429), + 77: uint16(12430), + 78: uint16(12431), + 79: uint16(12432), + 80: uint16(12433), + 81: uint16(12434), + 82: uint16(12435), + }, + 4: { + 0: uint16(12449), + 1: uint16(12450), + 2: uint16(12451), + 3: uint16(12452), + 4: uint16(12453), + 5: uint16(12454), + 6: uint16(12455), + 7: uint16(12456), + 8: uint16(12457), + 9: uint16(12458), + 10: uint16(12459), + 11: uint16(12460), + 12: uint16(12461), + 13: uint16(12462), + 14: uint16(12463), + 15: uint16(12464), + 16: uint16(12465), + 17: uint16(12466), + 18: uint16(12467), + 19: uint16(12468), + 20: uint16(12469), + 21: uint16(12470), + 22: uint16(12471), + 23: uint16(12472), + 24: uint16(12473), + 25: uint16(12474), + 26: uint16(12475), + 27: uint16(12476), + 28: uint16(12477), + 29: uint16(12478), + 30: uint16(12479), + 31: uint16(12480), + 32: uint16(12481), + 33: uint16(12482), + 34: uint16(12483), + 35: uint16(12484), + 36: uint16(12485), + 37: uint16(12486), + 38: uint16(12487), + 39: uint16(12488), + 40: uint16(12489), + 41: uint16(12490), + 42: uint16(12491), + 43: uint16(12492), + 44: uint16(12493), + 45: uint16(12494), + 46: uint16(12495), + 47: uint16(12496), + 48: uint16(12497), + 49: uint16(12498), + 50: uint16(12499), + 51: uint16(12500), + 52: uint16(12501), + 53: uint16(12502), + 54: uint16(12503), + 55: uint16(12504), + 56: uint16(12505), + 57: uint16(12506), + 58: uint16(12507), + 59: uint16(12508), + 60: uint16(12509), + 61: uint16(12510), + 62: uint16(12511), + 63: uint16(12512), + 64: uint16(12513), + 65: uint16(12514), + 66: uint16(12515), + 67: uint16(12516), + 68: uint16(12517), + 69: uint16(12518), + 70: uint16(12519), + 71: uint16(12520), + 72: uint16(12521), + 73: uint16(12522), + 74: uint16(12523), + 75: uint16(12524), + 76: uint16(12525), + 77: uint16(12526), + 78: uint16(12527), + 79: uint16(12528), + 80: uint16(12529), + 81: uint16(12530), + 82: uint16(12531), + 83: uint16(12532), + 84: uint16(12533), + 85: uint16(12534), + }, + 5: { + 0: uint16(913), + 1: uint16(914), + 2: uint16(915), + 3: uint16(916), + 4: uint16(917), + 5: uint16(918), + 6: uint16(919), + 7: uint16(920), + 8: uint16(921), + 9: uint16(922), + 10: uint16(923), + 11: uint16(924), + 12: uint16(925), + 13: uint16(926), + 14: uint16(927), + 15: uint16(928), + 16: uint16(929), + 17: uint16(931), + 18: uint16(932), + 19: uint16(933), + 20: uint16(934), + 21: uint16(935), + 22: uint16(936), + 23: uint16(937), + 32: uint16(945), + 33: uint16(946), + 34: uint16(947), + 35: uint16(948), + 36: uint16(949), + 37: uint16(950), + 38: uint16(951), + 39: uint16(952), + 40: uint16(953), + 41: uint16(954), + 42: uint16(955), + 43: uint16(956), + 44: uint16(957), + 45: uint16(958), + 46: uint16(959), + 47: uint16(960), + 48: uint16(961), + 49: uint16(963), + 50: uint16(964), + 51: uint16(965), + 52: uint16(966), + 53: uint16(967), + 54: uint16(968), + 55: uint16(969), + }, + 6: { + 0: uint16(1040), + 1: uint16(1041), + 2: uint16(1042), + 3: uint16(1043), + 4: uint16(1044), + 5: uint16(1045), + 6: uint16(1025), + 7: uint16(1046), + 8: uint16(1047), + 9: uint16(1048), + 10: uint16(1049), + 11: uint16(1050), + 12: uint16(1051), + 13: uint16(1052), + 14: uint16(1053), + 15: uint16(1054), + 16: uint16(1055), + 17: uint16(1056), + 18: uint16(1057), + 19: uint16(1058), + 20: uint16(1059), + 21: uint16(1060), + 22: uint16(1061), + 23: uint16(1062), + 24: uint16(1063), + 25: uint16(1064), + 26: uint16(1065), + 27: uint16(1066), + 28: uint16(1067), + 29: uint16(1068), + 30: uint16(1069), + 31: uint16(1070), + 32: uint16(1071), + 48: uint16(1072), + 49: uint16(1073), + 50: uint16(1074), + 51: uint16(1075), + 52: uint16(1076), + 53: uint16(1077), + 54: uint16(1105), + 55: uint16(1078), + 56: uint16(1079), + 57: uint16(1080), + 58: uint16(1081), + 59: uint16(1082), + 60: uint16(1083), + 61: uint16(1084), + 62: uint16(1085), + 63: uint16(1086), + 64: uint16(1087), + 65: uint16(1088), + 66: uint16(1089), + 67: uint16(1090), + 68: uint16(1091), + 69: uint16(1092), + 70: uint16(1093), + 71: uint16(1094), + 72: uint16(1095), + 73: uint16(1096), + 74: uint16(1097), + 75: uint16(1098), + 76: uint16(1099), + 77: uint16(1100), + 78: uint16(1101), + 79: uint16(1102), + 80: uint16(1103), + }, + 7: { + 0: uint16(9472), + 1: uint16(9474), + 2: uint16(9484), + 3: uint16(9488), + 4: uint16(9496), + 5: uint16(9492), + 6: uint16(9500), + 7: uint16(9516), + 8: uint16(9508), + 9: uint16(9524), + 10: uint16(9532), + 11: uint16(9473), + 12: uint16(9475), + 13: uint16(9487), + 14: uint16(9491), + 15: uint16(9499), + 16: uint16(9495), + 17: uint16(9507), + 18: uint16(9523), + 19: uint16(9515), + 20: uint16(9531), + 21: uint16(9547), + 22: uint16(9504), + 23: uint16(9519), + 24: uint16(9512), + 25: uint16(9527), + 26: uint16(9535), + 27: uint16(9501), + 28: uint16(9520), + 29: uint16(9509), + 30: uint16(9528), + 31: uint16(9538), + }, + 8: {}, + 9: {}, + 10: {}, + 11: {}, + 12: {}, + 13: {}, + 14: {}, + 15: { + 0: uint16(20124), + 1: uint16(21782), + 2: uint16(23043), + 3: uint16(38463), + 4: uint16(21696), + 5: uint16(24859), + 6: uint16(25384), + 7: uint16(23030), + 8: uint16(36898), + 9: uint16(33909), + 10: uint16(33564), + 11: uint16(31312), + 12: uint16(24746), + 13: uint16(25569), + 14: uint16(28197), + 15: uint16(26093), + 16: uint16(33894), + 17: uint16(33446), + 18: uint16(39925), + 19: uint16(26771), + 20: uint16(22311), + 21: uint16(26017), + 22: uint16(25201), + 23: uint16(23451), + 24: uint16(22992), + 25: uint16(34427), + 26: uint16(39156), + 27: uint16(32098), + 28: uint16(32190), + 29: uint16(39822), + 30: uint16(25110), + 31: uint16(31903), + 32: uint16(34999), + 33: uint16(23433), + 34: uint16(24245), + 35: uint16(25353), + 36: uint16(26263), + 37: uint16(26696), + 38: uint16(38343), + 39: uint16(38797), + 40: uint16(26447), + 41: uint16(20197), + 42: uint16(20234), + 43: uint16(20301), + 44: uint16(20381), + 45: uint16(20553), + 46: uint16(22258), + 47: uint16(22839), + 48: uint16(22996), + 49: uint16(23041), + 50: uint16(23561), + 51: uint16(24799), + 52: uint16(24847), + 53: uint16(24944), + 54: uint16(26131), + 55: uint16(26885), + 56: uint16(28858), + 57: uint16(30031), + 58: uint16(30064), + 59: uint16(31227), + 60: uint16(32173), + 61: uint16(32239), + 62: uint16(32963), + 63: uint16(33806), + 64: uint16(34915), + 65: uint16(35586), + 66: uint16(36949), + 67: uint16(36986), + 68: uint16(21307), + 69: uint16(20117), + 70: uint16(20133), + 71: uint16(22495), + 72: uint16(32946), + 73: uint16(37057), + 74: uint16(30959), + 75: uint16(19968), + 76: uint16(22769), + 77: uint16(28322), + 78: uint16(36920), + 79: uint16(31282), + 80: uint16(33576), + 81: uint16(33419), + 82: uint16(39983), + 83: uint16(20801), + 84: uint16(21360), + 85: uint16(21693), + 86: uint16(21729), + 87: uint16(22240), + 88: uint16(23035), + 89: uint16(24341), + 90: uint16(39154), + 91: uint16(28139), + 92: uint16(32996), + 93: uint16(34093), + }, + 16: { + 0: uint16(38498), + 1: uint16(38512), + 2: uint16(38560), + 3: uint16(38907), + 4: uint16(21515), + 5: uint16(21491), + 6: uint16(23431), + 7: uint16(28879), + 8: uint16(32701), + 9: uint16(36802), + 10: uint16(38632), + 11: uint16(21359), + 12: uint16(40284), + 13: uint16(31418), + 14: uint16(19985), + 15: uint16(30867), + 16: uint16(33276), + 17: uint16(28198), + 18: uint16(22040), + 19: uint16(21764), + 20: uint16(27421), + 21: uint16(34074), + 22: uint16(39995), + 23: uint16(23013), + 24: uint16(21417), + 25: uint16(28006), + 26: uint16(29916), + 27: uint16(38287), + 28: uint16(22082), + 29: uint16(20113), + 30: uint16(36939), + 31: uint16(38642), + 32: uint16(33615), + 33: uint16(39180), + 34: uint16(21473), + 35: uint16(21942), + 36: uint16(23344), + 37: uint16(24433), + 38: uint16(26144), + 39: uint16(26355), + 40: uint16(26628), + 41: uint16(27704), + 42: uint16(27891), + 43: uint16(27945), + 44: uint16(29787), + 45: uint16(30408), + 46: uint16(31310), + 47: uint16(38964), + 48: uint16(33521), + 49: uint16(34907), + 50: uint16(35424), + 51: uint16(37613), + 52: uint16(28082), + 53: uint16(30123), + 54: uint16(30410), + 55: uint16(39365), + 56: uint16(24742), + 57: uint16(35585), + 58: uint16(36234), + 59: uint16(38322), + 60: uint16(27022), + 61: uint16(21421), + 62: uint16(20870), + 63: uint16(22290), + 64: uint16(22576), + 65: uint16(22852), + 66: uint16(23476), + 67: uint16(24310), + 68: uint16(24616), + 69: uint16(25513), + 70: uint16(25588), + 71: uint16(27839), + 72: uint16(28436), + 73: uint16(28814), + 74: uint16(28948), + 75: uint16(29017), + 76: uint16(29141), + 77: uint16(29503), + 78: uint16(32257), + 79: uint16(33398), + 80: uint16(33489), + 81: uint16(34199), + 82: uint16(36960), + 83: uint16(37467), + 84: uint16(40219), + 85: uint16(22633), + 86: uint16(26044), + 87: uint16(27738), + 88: uint16(29989), + 89: uint16(20985), + 90: uint16(22830), + 91: uint16(22885), + 92: uint16(24448), + 93: uint16(24540), + }, + 17: { + 0: uint16(25276), + 1: uint16(26106), + 2: uint16(27178), + 3: uint16(27431), + 4: uint16(27572), + 5: uint16(29579), + 6: uint16(32705), + 7: uint16(35158), + 8: uint16(40236), + 9: uint16(40206), + 10: uint16(40644), + 11: uint16(23713), + 12: uint16(27798), + 13: uint16(33659), + 14: uint16(20740), + 15: uint16(23627), + 16: uint16(25014), + 17: uint16(33222), + 18: uint16(26742), + 19: uint16(29281), + 20: uint16(20057), + 21: uint16(20474), + 22: uint16(21368), + 23: uint16(24681), + 24: uint16(28201), + 25: uint16(31311), + 26: uint16(38899), + 27: uint16(19979), + 28: uint16(21270), + 29: uint16(20206), + 30: uint16(20309), + 31: uint16(20285), + 32: uint16(20385), + 33: uint16(20339), + 34: uint16(21152), + 35: uint16(21487), + 36: uint16(22025), + 37: uint16(22799), + 38: uint16(23233), + 39: uint16(23478), + 40: uint16(23521), + 41: uint16(31185), + 42: uint16(26247), + 43: uint16(26524), + 44: uint16(26550), + 45: uint16(27468), + 46: uint16(27827), + 47: uint16(28779), + 48: uint16(29634), + 49: uint16(31117), + 50: uint16(31166), + 51: uint16(31292), + 52: uint16(31623), + 53: uint16(33457), + 54: uint16(33499), + 55: uint16(33540), + 56: uint16(33655), + 57: uint16(33775), + 58: uint16(33747), + 59: uint16(34662), + 60: uint16(35506), + 61: uint16(22057), + 62: uint16(36008), + 63: uint16(36838), + 64: uint16(36942), + 65: uint16(38686), + 66: uint16(34442), + 67: uint16(20420), + 68: uint16(23784), + 69: uint16(25105), + 70: uint16(29273), + 71: uint16(30011), + 72: uint16(33253), + 73: uint16(33469), + 74: uint16(34558), + 75: uint16(36032), + 76: uint16(38597), + 77: uint16(39187), + 78: uint16(39381), + 79: uint16(20171), + 80: uint16(20250), + 81: uint16(35299), + 82: uint16(22238), + 83: uint16(22602), + 84: uint16(22730), + 85: uint16(24315), + 86: uint16(24555), + 87: uint16(24618), + 88: uint16(24724), + 89: uint16(24674), + 90: uint16(25040), + 91: uint16(25106), + 92: uint16(25296), + 93: uint16(25913), + }, + 18: { + 0: uint16(39745), + 1: uint16(26214), + 2: uint16(26800), + 3: uint16(28023), + 4: uint16(28784), + 5: uint16(30028), + 6: uint16(30342), + 7: uint16(32117), + 8: uint16(33445), + 9: uint16(34809), + 10: uint16(38283), + 11: uint16(38542), + 12: uint16(35997), + 13: uint16(20977), + 14: uint16(21182), + 15: uint16(22806), + 16: uint16(21683), + 17: uint16(23475), + 18: uint16(23830), + 19: uint16(24936), + 20: uint16(27010), + 21: uint16(28079), + 22: uint16(30861), + 23: uint16(33995), + 24: uint16(34903), + 25: uint16(35442), + 26: uint16(37799), + 27: uint16(39608), + 28: uint16(28012), + 29: uint16(39336), + 30: uint16(34521), + 31: uint16(22435), + 32: uint16(26623), + 33: uint16(34510), + 34: uint16(37390), + 35: uint16(21123), + 36: uint16(22151), + 37: uint16(21508), + 38: uint16(24275), + 39: uint16(25313), + 40: uint16(25785), + 41: uint16(26684), + 42: uint16(26680), + 43: uint16(27579), + 44: uint16(29554), + 45: uint16(30906), + 46: uint16(31339), + 47: uint16(35226), + 48: uint16(35282), + 49: uint16(36203), + 50: uint16(36611), + 51: uint16(37101), + 52: uint16(38307), + 53: uint16(38548), + 54: uint16(38761), + 55: uint16(23398), + 56: uint16(23731), + 57: uint16(27005), + 58: uint16(38989), + 59: uint16(38990), + 60: uint16(25499), + 61: uint16(31520), + 62: uint16(27179), + 63: uint16(27263), + 64: uint16(26806), + 65: uint16(39949), + 66: uint16(28511), + 67: uint16(21106), + 68: uint16(21917), + 69: uint16(24688), + 70: uint16(25324), + 71: uint16(27963), + 72: uint16(28167), + 73: uint16(28369), + 74: uint16(33883), + 75: uint16(35088), + 76: uint16(36676), + 77: uint16(19988), + 78: uint16(39993), + 79: uint16(21494), + 80: uint16(26907), + 81: uint16(27194), + 82: uint16(38788), + 83: uint16(26666), + 84: uint16(20828), + 85: uint16(31427), + 86: uint16(33970), + 87: uint16(37340), + 88: uint16(37772), + 89: uint16(22107), + 90: uint16(40232), + 91: uint16(26658), + 92: uint16(33541), + 93: uint16(33841), + }, + 19: { + 0: uint16(31909), + 1: uint16(21000), + 2: uint16(33477), + 3: uint16(29926), + 4: uint16(20094), + 5: uint16(20355), + 6: uint16(20896), + 7: uint16(23506), + 8: uint16(21002), + 9: uint16(21208), + 10: uint16(21223), + 11: uint16(24059), + 12: uint16(21914), + 13: uint16(22570), + 14: uint16(23014), + 15: uint16(23436), + 16: uint16(23448), + 17: uint16(23515), + 18: uint16(24178), + 19: uint16(24185), + 20: uint16(24739), + 21: uint16(24863), + 22: uint16(24931), + 23: uint16(25022), + 24: uint16(25563), + 25: uint16(25954), + 26: uint16(26577), + 27: uint16(26707), + 28: uint16(26874), + 29: uint16(27454), + 30: uint16(27475), + 31: uint16(27735), + 32: uint16(28450), + 33: uint16(28567), + 34: uint16(28485), + 35: uint16(29872), + 36: uint16(29976), + 37: uint16(30435), + 38: uint16(30475), + 39: uint16(31487), + 40: uint16(31649), + 41: uint16(31777), + 42: uint16(32233), + 43: uint16(32566), + 44: uint16(32752), + 45: uint16(32925), + 46: uint16(33382), + 47: uint16(33694), + 48: uint16(35251), + 49: uint16(35532), + 50: uint16(36011), + 51: uint16(36996), + 52: uint16(37969), + 53: uint16(38291), + 54: uint16(38289), + 55: uint16(38306), + 56: uint16(38501), + 57: uint16(38867), + 58: uint16(39208), + 59: uint16(33304), + 60: uint16(20024), + 61: uint16(21547), + 62: uint16(23736), + 63: uint16(24012), + 64: uint16(29609), + 65: uint16(30284), + 66: uint16(30524), + 67: uint16(23721), + 68: uint16(32747), + 69: uint16(36107), + 70: uint16(38593), + 71: uint16(38929), + 72: uint16(38996), + 73: uint16(39000), + 74: uint16(20225), + 75: uint16(20238), + 76: uint16(21361), + 77: uint16(21916), + 78: uint16(22120), + 79: uint16(22522), + 80: uint16(22855), + 81: uint16(23305), + 82: uint16(23492), + 83: uint16(23696), + 84: uint16(24076), + 85: uint16(24190), + 86: uint16(24524), + 87: uint16(25582), + 88: uint16(26426), + 89: uint16(26071), + 90: uint16(26082), + 91: uint16(26399), + 92: uint16(26827), + 93: uint16(26820), + }, + 20: { + 0: uint16(27231), + 1: uint16(24112), + 2: uint16(27589), + 3: uint16(27671), + 4: uint16(27773), + 5: uint16(30079), + 6: uint16(31048), + 7: uint16(23395), + 8: uint16(31232), + 9: uint16(32000), + 10: uint16(24509), + 11: uint16(35215), + 12: uint16(35352), + 13: uint16(36020), + 14: uint16(36215), + 15: uint16(36556), + 16: uint16(36637), + 17: uint16(39138), + 18: uint16(39438), + 19: uint16(39740), + 20: uint16(20096), + 21: uint16(20605), + 22: uint16(20736), + 23: uint16(22931), + 24: uint16(23452), + 25: uint16(25135), + 26: uint16(25216), + 27: uint16(25836), + 28: uint16(27450), + 29: uint16(29344), + 30: uint16(30097), + 31: uint16(31047), + 32: uint16(32681), + 33: uint16(34811), + 34: uint16(35516), + 35: uint16(35696), + 36: uint16(25516), + 37: uint16(33738), + 38: uint16(38816), + 39: uint16(21513), + 40: uint16(21507), + 41: uint16(21931), + 42: uint16(26708), + 43: uint16(27224), + 44: uint16(35440), + 45: uint16(30759), + 46: uint16(26485), + 47: uint16(40653), + 48: uint16(21364), + 49: uint16(23458), + 50: uint16(33050), + 51: uint16(34384), + 52: uint16(36870), + 53: uint16(19992), + 54: uint16(20037), + 55: uint16(20167), + 56: uint16(20241), + 57: uint16(21450), + 58: uint16(21560), + 59: uint16(23470), + 60: uint16(24339), + 61: uint16(24613), + 62: uint16(25937), + 63: uint16(26429), + 64: uint16(27714), + 65: uint16(27762), + 66: uint16(27875), + 67: uint16(28792), + 68: uint16(29699), + 69: uint16(31350), + 70: uint16(31406), + 71: uint16(31496), + 72: uint16(32026), + 73: uint16(31998), + 74: uint16(32102), + 75: uint16(26087), + 76: uint16(29275), + 77: uint16(21435), + 78: uint16(23621), + 79: uint16(24040), + 80: uint16(25298), + 81: uint16(25312), + 82: uint16(25369), + 83: uint16(28192), + 84: uint16(34394), + 85: uint16(35377), + 86: uint16(36317), + 87: uint16(37624), + 88: uint16(28417), + 89: uint16(31142), + 90: uint16(39770), + 91: uint16(20136), + 92: uint16(20139), + 93: uint16(20140), + }, + 21: { + 0: uint16(20379), + 1: uint16(20384), + 2: uint16(20689), + 3: uint16(20807), + 4: uint16(31478), + 5: uint16(20849), + 6: uint16(20982), + 7: uint16(21332), + 8: uint16(21281), + 9: uint16(21375), + 10: uint16(21483), + 11: uint16(21932), + 12: uint16(22659), + 13: uint16(23777), + 14: uint16(24375), + 15: uint16(24394), + 16: uint16(24623), + 17: uint16(24656), + 18: uint16(24685), + 19: uint16(25375), + 20: uint16(25945), + 21: uint16(27211), + 22: uint16(27841), + 23: uint16(29378), + 24: uint16(29421), + 25: uint16(30703), + 26: uint16(33016), + 27: uint16(33029), + 28: uint16(33288), + 29: uint16(34126), + 30: uint16(37111), + 31: uint16(37857), + 32: uint16(38911), + 33: uint16(39255), + 34: uint16(39514), + 35: uint16(20208), + 36: uint16(20957), + 37: uint16(23597), + 38: uint16(26241), + 39: uint16(26989), + 40: uint16(23616), + 41: uint16(26354), + 42: uint16(26997), + 43: uint16(29577), + 44: uint16(26704), + 45: uint16(31873), + 46: uint16(20677), + 47: uint16(21220), + 48: uint16(22343), + 49: uint16(24062), + 50: uint16(37670), + 51: uint16(26020), + 52: uint16(27427), + 53: uint16(27453), + 54: uint16(29748), + 55: uint16(31105), + 56: uint16(31165), + 57: uint16(31563), + 58: uint16(32202), + 59: uint16(33465), + 60: uint16(33740), + 61: uint16(34943), + 62: uint16(35167), + 63: uint16(35641), + 64: uint16(36817), + 65: uint16(37329), + 66: uint16(21535), + 67: uint16(37504), + 68: uint16(20061), + 69: uint16(20534), + 70: uint16(21477), + 71: uint16(21306), + 72: uint16(29399), + 73: uint16(29590), + 74: uint16(30697), + 75: uint16(33510), + 76: uint16(36527), + 77: uint16(39366), + 78: uint16(39368), + 79: uint16(39378), + 80: uint16(20855), + 81: uint16(24858), + 82: uint16(34398), + 83: uint16(21936), + 84: uint16(31354), + 85: uint16(20598), + 86: uint16(23507), + 87: uint16(36935), + 88: uint16(38533), + 89: uint16(20018), + 90: uint16(27355), + 91: uint16(37351), + 92: uint16(23633), + 93: uint16(23624), + }, + 22: { + 0: uint16(25496), + 1: uint16(31391), + 2: uint16(27795), + 3: uint16(38772), + 4: uint16(36705), + 5: uint16(31402), + 6: uint16(29066), + 7: uint16(38536), + 8: uint16(31874), + 9: uint16(26647), + 10: uint16(32368), + 11: uint16(26705), + 12: uint16(37740), + 13: uint16(21234), + 14: uint16(21531), + 15: uint16(34219), + 16: uint16(35347), + 17: uint16(32676), + 18: uint16(36557), + 19: uint16(37089), + 20: uint16(21350), + 21: uint16(34952), + 22: uint16(31041), + 23: uint16(20418), + 24: uint16(20670), + 25: uint16(21009), + 26: uint16(20804), + 27: uint16(21843), + 28: uint16(22317), + 29: uint16(29674), + 30: uint16(22411), + 31: uint16(22865), + 32: uint16(24418), + 33: uint16(24452), + 34: uint16(24693), + 35: uint16(24950), + 36: uint16(24935), + 37: uint16(25001), + 38: uint16(25522), + 39: uint16(25658), + 40: uint16(25964), + 41: uint16(26223), + 42: uint16(26690), + 43: uint16(28179), + 44: uint16(30054), + 45: uint16(31293), + 46: uint16(31995), + 47: uint16(32076), + 48: uint16(32153), + 49: uint16(32331), + 50: uint16(32619), + 51: uint16(33550), + 52: uint16(33610), + 53: uint16(34509), + 54: uint16(35336), + 55: uint16(35427), + 56: uint16(35686), + 57: uint16(36605), + 58: uint16(38938), + 59: uint16(40335), + 60: uint16(33464), + 61: uint16(36814), + 62: uint16(39912), + 63: uint16(21127), + 64: uint16(25119), + 65: uint16(25731), + 66: uint16(28608), + 67: uint16(38553), + 68: uint16(26689), + 69: uint16(20625), + 70: uint16(27424), + 71: uint16(27770), + 72: uint16(28500), + 73: uint16(31348), + 74: uint16(32080), + 75: uint16(34880), + 76: uint16(35363), + 77: uint16(26376), + 78: uint16(20214), + 79: uint16(20537), + 80: uint16(20518), + 81: uint16(20581), + 82: uint16(20860), + 83: uint16(21048), + 84: uint16(21091), + 85: uint16(21927), + 86: uint16(22287), + 87: uint16(22533), + 88: uint16(23244), + 89: uint16(24314), + 90: uint16(25010), + 91: uint16(25080), + 92: uint16(25331), + 93: uint16(25458), + }, + 23: { + 0: uint16(26908), + 1: uint16(27177), + 2: uint16(29309), + 3: uint16(29356), + 4: uint16(29486), + 5: uint16(30740), + 6: uint16(30831), + 7: uint16(32121), + 8: uint16(30476), + 9: uint16(32937), + 10: uint16(35211), + 11: uint16(35609), + 12: uint16(36066), + 13: uint16(36562), + 14: uint16(36963), + 15: uint16(37749), + 16: uint16(38522), + 17: uint16(38997), + 18: uint16(39443), + 19: uint16(40568), + 20: uint16(20803), + 21: uint16(21407), + 22: uint16(21427), + 23: uint16(24187), + 24: uint16(24358), + 25: uint16(28187), + 26: uint16(28304), + 27: uint16(29572), + 28: uint16(29694), + 29: uint16(32067), + 30: uint16(33335), + 31: uint16(35328), + 32: uint16(35578), + 33: uint16(38480), + 34: uint16(20046), + 35: uint16(20491), + 36: uint16(21476), + 37: uint16(21628), + 38: uint16(22266), + 39: uint16(22993), + 40: uint16(23396), + 41: uint16(24049), + 42: uint16(24235), + 43: uint16(24359), + 44: uint16(25144), + 45: uint16(25925), + 46: uint16(26543), + 47: uint16(28246), + 48: uint16(29392), + 49: uint16(31946), + 50: uint16(34996), + 51: uint16(32929), + 52: uint16(32993), + 53: uint16(33776), + 54: uint16(34382), + 55: uint16(35463), + 56: uint16(36328), + 57: uint16(37431), + 58: uint16(38599), + 59: uint16(39015), + 60: uint16(40723), + 61: uint16(20116), + 62: uint16(20114), + 63: uint16(20237), + 64: uint16(21320), + 65: uint16(21577), + 66: uint16(21566), + 67: uint16(23087), + 68: uint16(24460), + 69: uint16(24481), + 70: uint16(24735), + 71: uint16(26791), + 72: uint16(27278), + 73: uint16(29786), + 74: uint16(30849), + 75: uint16(35486), + 76: uint16(35492), + 77: uint16(35703), + 78: uint16(37264), + 79: uint16(20062), + 80: uint16(39881), + 81: uint16(20132), + 82: uint16(20348), + 83: uint16(20399), + 84: uint16(20505), + 85: uint16(20502), + 86: uint16(20809), + 87: uint16(20844), + 88: uint16(21151), + 89: uint16(21177), + 90: uint16(21246), + 91: uint16(21402), + 92: uint16(21475), + 93: uint16(21521), + }, + 24: { + 0: uint16(21518), + 1: uint16(21897), + 2: uint16(22353), + 3: uint16(22434), + 4: uint16(22909), + 5: uint16(23380), + 6: uint16(23389), + 7: uint16(23439), + 8: uint16(24037), + 9: uint16(24039), + 10: uint16(24055), + 11: uint16(24184), + 12: uint16(24195), + 13: uint16(24218), + 14: uint16(24247), + 15: uint16(24344), + 16: uint16(24658), + 17: uint16(24908), + 18: uint16(25239), + 19: uint16(25304), + 20: uint16(25511), + 21: uint16(25915), + 22: uint16(26114), + 23: uint16(26179), + 24: uint16(26356), + 25: uint16(26477), + 26: uint16(26657), + 27: uint16(26775), + 28: uint16(27083), + 29: uint16(27743), + 30: uint16(27946), + 31: uint16(28009), + 32: uint16(28207), + 33: uint16(28317), + 34: uint16(30002), + 35: uint16(30343), + 36: uint16(30828), + 37: uint16(31295), + 38: uint16(31968), + 39: uint16(32005), + 40: uint16(32024), + 41: uint16(32094), + 42: uint16(32177), + 43: uint16(32789), + 44: uint16(32771), + 45: uint16(32943), + 46: uint16(32945), + 47: uint16(33108), + 48: uint16(33167), + 49: uint16(33322), + 50: uint16(33618), + 51: uint16(34892), + 52: uint16(34913), + 53: uint16(35611), + 54: uint16(36002), + 55: uint16(36092), + 56: uint16(37066), + 57: uint16(37237), + 58: uint16(37489), + 59: uint16(30783), + 60: uint16(37628), + 61: uint16(38308), + 62: uint16(38477), + 63: uint16(38917), + 64: uint16(39321), + 65: uint16(39640), + 66: uint16(40251), + 67: uint16(21083), + 68: uint16(21163), + 69: uint16(21495), + 70: uint16(21512), + 71: uint16(22741), + 72: uint16(25335), + 73: uint16(28640), + 74: uint16(35946), + 75: uint16(36703), + 76: uint16(40633), + 77: uint16(20811), + 78: uint16(21051), + 79: uint16(21578), + 80: uint16(22269), + 81: uint16(31296), + 82: uint16(37239), + 83: uint16(40288), + 84: uint16(40658), + 85: uint16(29508), + 86: uint16(28425), + 87: uint16(33136), + 88: uint16(29969), + 89: uint16(24573), + 90: uint16(24794), + 91: uint16(39592), + 92: uint16(29403), + 93: uint16(36796), + }, + 25: { + 0: uint16(27492), + 1: uint16(38915), + 2: uint16(20170), + 3: uint16(22256), + 4: uint16(22372), + 5: uint16(22718), + 6: uint16(23130), + 7: uint16(24680), + 8: uint16(25031), + 9: uint16(26127), + 10: uint16(26118), + 11: uint16(26681), + 12: uint16(26801), + 13: uint16(28151), + 14: uint16(30165), + 15: uint16(32058), + 16: uint16(33390), + 17: uint16(39746), + 18: uint16(20123), + 19: uint16(20304), + 20: uint16(21449), + 21: uint16(21766), + 22: uint16(23919), + 23: uint16(24038), + 24: uint16(24046), + 25: uint16(26619), + 26: uint16(27801), + 27: uint16(29811), + 28: uint16(30722), + 29: uint16(35408), + 30: uint16(37782), + 31: uint16(35039), + 32: uint16(22352), + 33: uint16(24231), + 34: uint16(25387), + 35: uint16(20661), + 36: uint16(20652), + 37: uint16(20877), + 38: uint16(26368), + 39: uint16(21705), + 40: uint16(22622), + 41: uint16(22971), + 42: uint16(23472), + 43: uint16(24425), + 44: uint16(25165), + 45: uint16(25505), + 46: uint16(26685), + 47: uint16(27507), + 48: uint16(28168), + 49: uint16(28797), + 50: uint16(37319), + 51: uint16(29312), + 52: uint16(30741), + 53: uint16(30758), + 54: uint16(31085), + 55: uint16(25998), + 56: uint16(32048), + 57: uint16(33756), + 58: uint16(35009), + 59: uint16(36617), + 60: uint16(38555), + 61: uint16(21092), + 62: uint16(22312), + 63: uint16(26448), + 64: uint16(32618), + 65: uint16(36001), + 66: uint16(20916), + 67: uint16(22338), + 68: uint16(38442), + 69: uint16(22586), + 70: uint16(27018), + 71: uint16(32948), + 72: uint16(21682), + 73: uint16(23822), + 74: uint16(22524), + 75: uint16(30869), + 76: uint16(40442), + 77: uint16(20316), + 78: uint16(21066), + 79: uint16(21643), + 80: uint16(25662), + 81: uint16(26152), + 82: uint16(26388), + 83: uint16(26613), + 84: uint16(31364), + 85: uint16(31574), + 86: uint16(32034), + 87: uint16(37679), + 88: uint16(26716), + 89: uint16(39853), + 90: uint16(31545), + 91: uint16(21273), + 92: uint16(20874), + 93: uint16(21047), + }, + 26: { + 0: uint16(23519), + 1: uint16(25334), + 2: uint16(25774), + 3: uint16(25830), + 4: uint16(26413), + 5: uint16(27578), + 6: uint16(34217), + 7: uint16(38609), + 8: uint16(30352), + 9: uint16(39894), + 10: uint16(25420), + 11: uint16(37638), + 12: uint16(39851), + 13: uint16(30399), + 14: uint16(26194), + 15: uint16(19977), + 16: uint16(20632), + 17: uint16(21442), + 18: uint16(23665), + 19: uint16(24808), + 20: uint16(25746), + 21: uint16(25955), + 22: uint16(26719), + 23: uint16(29158), + 24: uint16(29642), + 25: uint16(29987), + 26: uint16(31639), + 27: uint16(32386), + 28: uint16(34453), + 29: uint16(35715), + 30: uint16(36059), + 31: uint16(37240), + 32: uint16(39184), + 33: uint16(26028), + 34: uint16(26283), + 35: uint16(27531), + 36: uint16(20181), + 37: uint16(20180), + 38: uint16(20282), + 39: uint16(20351), + 40: uint16(21050), + 41: uint16(21496), + 42: uint16(21490), + 43: uint16(21987), + 44: uint16(22235), + 45: uint16(22763), + 46: uint16(22987), + 47: uint16(22985), + 48: uint16(23039), + 49: uint16(23376), + 50: uint16(23629), + 51: uint16(24066), + 52: uint16(24107), + 53: uint16(24535), + 54: uint16(24605), + 55: uint16(25351), + 56: uint16(25903), + 57: uint16(23388), + 58: uint16(26031), + 59: uint16(26045), + 60: uint16(26088), + 61: uint16(26525), + 62: uint16(27490), + 63: uint16(27515), + 64: uint16(27663), + 65: uint16(29509), + 66: uint16(31049), + 67: uint16(31169), + 68: uint16(31992), + 69: uint16(32025), + 70: uint16(32043), + 71: uint16(32930), + 72: uint16(33026), + 73: uint16(33267), + 74: uint16(35222), + 75: uint16(35422), + 76: uint16(35433), + 77: uint16(35430), + 78: uint16(35468), + 79: uint16(35566), + 80: uint16(36039), + 81: uint16(36060), + 82: uint16(38604), + 83: uint16(39164), + 84: uint16(27503), + 85: uint16(20107), + 86: uint16(20284), + 87: uint16(20365), + 88: uint16(20816), + 89: uint16(23383), + 90: uint16(23546), + 91: uint16(24904), + 92: uint16(25345), + 93: uint16(26178), + }, + 27: { + 0: uint16(27425), + 1: uint16(28363), + 2: uint16(27835), + 3: uint16(29246), + 4: uint16(29885), + 5: uint16(30164), + 6: uint16(30913), + 7: uint16(31034), + 8: uint16(32780), + 9: uint16(32819), + 10: uint16(33258), + 11: uint16(33940), + 12: uint16(36766), + 13: uint16(27728), + 14: uint16(40575), + 15: uint16(24335), + 16: uint16(35672), + 17: uint16(40235), + 18: uint16(31482), + 19: uint16(36600), + 20: uint16(23437), + 21: uint16(38635), + 22: uint16(19971), + 23: uint16(21489), + 24: uint16(22519), + 25: uint16(22833), + 26: uint16(23241), + 27: uint16(23460), + 28: uint16(24713), + 29: uint16(28287), + 30: uint16(28422), + 31: uint16(30142), + 32: uint16(36074), + 33: uint16(23455), + 34: uint16(34048), + 35: uint16(31712), + 36: uint16(20594), + 37: uint16(26612), + 38: uint16(33437), + 39: uint16(23649), + 40: uint16(34122), + 41: uint16(32286), + 42: uint16(33294), + 43: uint16(20889), + 44: uint16(23556), + 45: uint16(25448), + 46: uint16(36198), + 47: uint16(26012), + 48: uint16(29038), + 49: uint16(31038), + 50: uint16(32023), + 51: uint16(32773), + 52: uint16(35613), + 53: uint16(36554), + 54: uint16(36974), + 55: uint16(34503), + 56: uint16(37034), + 57: uint16(20511), + 58: uint16(21242), + 59: uint16(23610), + 60: uint16(26451), + 61: uint16(28796), + 62: uint16(29237), + 63: uint16(37196), + 64: uint16(37320), + 65: uint16(37675), + 66: uint16(33509), + 67: uint16(23490), + 68: uint16(24369), + 69: uint16(24825), + 70: uint16(20027), + 71: uint16(21462), + 72: uint16(23432), + 73: uint16(25163), + 74: uint16(26417), + 75: uint16(27530), + 76: uint16(29417), + 77: uint16(29664), + 78: uint16(31278), + 79: uint16(33131), + 80: uint16(36259), + 81: uint16(37202), + 82: uint16(39318), + 83: uint16(20754), + 84: uint16(21463), + 85: uint16(21610), + 86: uint16(23551), + 87: uint16(25480), + 88: uint16(27193), + 89: uint16(32172), + 90: uint16(38656), + 91: uint16(22234), + 92: uint16(21454), + 93: uint16(21608), + }, + 28: { + 0: uint16(23447), + 1: uint16(23601), + 2: uint16(24030), + 3: uint16(20462), + 4: uint16(24833), + 5: uint16(25342), + 6: uint16(27954), + 7: uint16(31168), + 8: uint16(31179), + 9: uint16(32066), + 10: uint16(32333), + 11: uint16(32722), + 12: uint16(33261), + 13: uint16(33311), + 14: uint16(33936), + 15: uint16(34886), + 16: uint16(35186), + 17: uint16(35728), + 18: uint16(36468), + 19: uint16(36655), + 20: uint16(36913), + 21: uint16(37195), + 22: uint16(37228), + 23: uint16(38598), + 24: uint16(37276), + 25: uint16(20160), + 26: uint16(20303), + 27: uint16(20805), + 28: uint16(21313), + 29: uint16(24467), + 30: uint16(25102), + 31: uint16(26580), + 32: uint16(27713), + 33: uint16(28171), + 34: uint16(29539), + 35: uint16(32294), + 36: uint16(37325), + 37: uint16(37507), + 38: uint16(21460), + 39: uint16(22809), + 40: uint16(23487), + 41: uint16(28113), + 42: uint16(31069), + 43: uint16(32302), + 44: uint16(31899), + 45: uint16(22654), + 46: uint16(29087), + 47: uint16(20986), + 48: uint16(34899), + 49: uint16(36848), + 50: uint16(20426), + 51: uint16(23803), + 52: uint16(26149), + 53: uint16(30636), + 54: uint16(31459), + 55: uint16(33308), + 56: uint16(39423), + 57: uint16(20934), + 58: uint16(24490), + 59: uint16(26092), + 60: uint16(26991), + 61: uint16(27529), + 62: uint16(28147), + 63: uint16(28310), + 64: uint16(28516), + 65: uint16(30462), + 66: uint16(32020), + 67: uint16(24033), + 68: uint16(36981), + 69: uint16(37255), + 70: uint16(38918), + 71: uint16(20966), + 72: uint16(21021), + 73: uint16(25152), + 74: uint16(26257), + 75: uint16(26329), + 76: uint16(28186), + 77: uint16(24246), + 78: uint16(32210), + 79: uint16(32626), + 80: uint16(26360), + 81: uint16(34223), + 82: uint16(34295), + 83: uint16(35576), + 84: uint16(21161), + 85: uint16(21465), + 86: uint16(22899), + 87: uint16(24207), + 88: uint16(24464), + 89: uint16(24661), + 90: uint16(37604), + 91: uint16(38500), + 92: uint16(20663), + 93: uint16(20767), + }, + 29: { + 0: uint16(21213), + 1: uint16(21280), + 2: uint16(21319), + 3: uint16(21484), + 4: uint16(21736), + 5: uint16(21830), + 6: uint16(21809), + 7: uint16(22039), + 8: uint16(22888), + 9: uint16(22974), + 10: uint16(23100), + 11: uint16(23477), + 12: uint16(23558), + 13: uint16(23567), + 14: uint16(23569), + 15: uint16(23578), + 16: uint16(24196), + 17: uint16(24202), + 18: uint16(24288), + 19: uint16(24432), + 20: uint16(25215), + 21: uint16(25220), + 22: uint16(25307), + 23: uint16(25484), + 24: uint16(25463), + 25: uint16(26119), + 26: uint16(26124), + 27: uint16(26157), + 28: uint16(26230), + 29: uint16(26494), + 30: uint16(26786), + 31: uint16(27167), + 32: uint16(27189), + 33: uint16(27836), + 34: uint16(28040), + 35: uint16(28169), + 36: uint16(28248), + 37: uint16(28988), + 38: uint16(28966), + 39: uint16(29031), + 40: uint16(30151), + 41: uint16(30465), + 42: uint16(30813), + 43: uint16(30977), + 44: uint16(31077), + 45: uint16(31216), + 46: uint16(31456), + 47: uint16(31505), + 48: uint16(31911), + 49: uint16(32057), + 50: uint16(32918), + 51: uint16(33750), + 52: uint16(33931), + 53: uint16(34121), + 54: uint16(34909), + 55: uint16(35059), + 56: uint16(35359), + 57: uint16(35388), + 58: uint16(35412), + 59: uint16(35443), + 60: uint16(35937), + 61: uint16(36062), + 62: uint16(37284), + 63: uint16(37478), + 64: uint16(37758), + 65: uint16(37912), + 66: uint16(38556), + 67: uint16(38808), + 68: uint16(19978), + 69: uint16(19976), + 70: uint16(19998), + 71: uint16(20055), + 72: uint16(20887), + 73: uint16(21104), + 74: uint16(22478), + 75: uint16(22580), + 76: uint16(22732), + 77: uint16(23330), + 78: uint16(24120), + 79: uint16(24773), + 80: uint16(25854), + 81: uint16(26465), + 82: uint16(26454), + 83: uint16(27972), + 84: uint16(29366), + 85: uint16(30067), + 86: uint16(31331), + 87: uint16(33976), + 88: uint16(35698), + 89: uint16(37304), + 90: uint16(37664), + 91: uint16(22065), + 92: uint16(22516), + 93: uint16(39166), + }, + 30: { + 0: uint16(25325), + 1: uint16(26893), + 2: uint16(27542), + 3: uint16(29165), + 4: uint16(32340), + 5: uint16(32887), + 6: uint16(33394), + 7: uint16(35302), + 8: uint16(39135), + 9: uint16(34645), + 10: uint16(36785), + 11: uint16(23611), + 12: uint16(20280), + 13: uint16(20449), + 14: uint16(20405), + 15: uint16(21767), + 16: uint16(23072), + 17: uint16(23517), + 18: uint16(23529), + 19: uint16(24515), + 20: uint16(24910), + 21: uint16(25391), + 22: uint16(26032), + 23: uint16(26187), + 24: uint16(26862), + 25: uint16(27035), + 26: uint16(28024), + 27: uint16(28145), + 28: uint16(30003), + 29: uint16(30137), + 30: uint16(30495), + 31: uint16(31070), + 32: uint16(31206), + 33: uint16(32051), + 34: uint16(33251), + 35: uint16(33455), + 36: uint16(34218), + 37: uint16(35242), + 38: uint16(35386), + 39: uint16(36523), + 40: uint16(36763), + 41: uint16(36914), + 42: uint16(37341), + 43: uint16(38663), + 44: uint16(20154), + 45: uint16(20161), + 46: uint16(20995), + 47: uint16(22645), + 48: uint16(22764), + 49: uint16(23563), + 50: uint16(29978), + 51: uint16(23613), + 52: uint16(33102), + 53: uint16(35338), + 54: uint16(36805), + 55: uint16(38499), + 56: uint16(38765), + 57: uint16(31525), + 58: uint16(35535), + 59: uint16(38920), + 60: uint16(37218), + 61: uint16(22259), + 62: uint16(21416), + 63: uint16(36887), + 64: uint16(21561), + 65: uint16(22402), + 66: uint16(24101), + 67: uint16(25512), + 68: uint16(27700), + 69: uint16(28810), + 70: uint16(30561), + 71: uint16(31883), + 72: uint16(32736), + 73: uint16(34928), + 74: uint16(36930), + 75: uint16(37204), + 76: uint16(37648), + 77: uint16(37656), + 78: uint16(38543), + 79: uint16(29790), + 80: uint16(39620), + 81: uint16(23815), + 82: uint16(23913), + 83: uint16(25968), + 84: uint16(26530), + 85: uint16(36264), + 86: uint16(38619), + 87: uint16(25454), + 88: uint16(26441), + 89: uint16(26905), + 90: uint16(33733), + 91: uint16(38935), + 92: uint16(38592), + 93: uint16(35070), + }, + 31: { + 0: uint16(28548), + 1: uint16(25722), + 2: uint16(23544), + 3: uint16(19990), + 4: uint16(28716), + 5: uint16(30045), + 6: uint16(26159), + 7: uint16(20932), + 8: uint16(21046), + 9: uint16(21218), + 10: uint16(22995), + 11: uint16(24449), + 12: uint16(24615), + 13: uint16(25104), + 14: uint16(25919), + 15: uint16(25972), + 16: uint16(26143), + 17: uint16(26228), + 18: uint16(26866), + 19: uint16(26646), + 20: uint16(27491), + 21: uint16(28165), + 22: uint16(29298), + 23: uint16(29983), + 24: uint16(30427), + 25: uint16(31934), + 26: uint16(32854), + 27: uint16(22768), + 28: uint16(35069), + 29: uint16(35199), + 30: uint16(35488), + 31: uint16(35475), + 32: uint16(35531), + 33: uint16(36893), + 34: uint16(37266), + 35: uint16(38738), + 36: uint16(38745), + 37: uint16(25993), + 38: uint16(31246), + 39: uint16(33030), + 40: uint16(38587), + 41: uint16(24109), + 42: uint16(24796), + 43: uint16(25114), + 44: uint16(26021), + 45: uint16(26132), + 46: uint16(26512), + 47: uint16(30707), + 48: uint16(31309), + 49: uint16(31821), + 50: uint16(32318), + 51: uint16(33034), + 52: uint16(36012), + 53: uint16(36196), + 54: uint16(36321), + 55: uint16(36447), + 56: uint16(30889), + 57: uint16(20999), + 58: uint16(25305), + 59: uint16(25509), + 60: uint16(25666), + 61: uint16(25240), + 62: uint16(35373), + 63: uint16(31363), + 64: uint16(31680), + 65: uint16(35500), + 66: uint16(38634), + 67: uint16(32118), + 68: uint16(33292), + 69: uint16(34633), + 70: uint16(20185), + 71: uint16(20808), + 72: uint16(21315), + 73: uint16(21344), + 74: uint16(23459), + 75: uint16(23554), + 76: uint16(23574), + 77: uint16(24029), + 78: uint16(25126), + 79: uint16(25159), + 80: uint16(25776), + 81: uint16(26643), + 82: uint16(26676), + 83: uint16(27849), + 84: uint16(27973), + 85: uint16(27927), + 86: uint16(26579), + 87: uint16(28508), + 88: uint16(29006), + 89: uint16(29053), + 90: uint16(26059), + 91: uint16(31359), + 92: uint16(31661), + 93: uint16(32218), + }, + 32: { + 0: uint16(32330), + 1: uint16(32680), + 2: uint16(33146), + 3: uint16(33307), + 4: uint16(33337), + 5: uint16(34214), + 6: uint16(35438), + 7: uint16(36046), + 8: uint16(36341), + 9: uint16(36984), + 10: uint16(36983), + 11: uint16(37549), + 12: uint16(37521), + 13: uint16(38275), + 14: uint16(39854), + 15: uint16(21069), + 16: uint16(21892), + 17: uint16(28472), + 18: uint16(28982), + 19: uint16(20840), + 20: uint16(31109), + 21: uint16(32341), + 22: uint16(33203), + 23: uint16(31950), + 24: uint16(22092), + 25: uint16(22609), + 26: uint16(23720), + 27: uint16(25514), + 28: uint16(26366), + 29: uint16(26365), + 30: uint16(26970), + 31: uint16(29401), + 32: uint16(30095), + 33: uint16(30094), + 34: uint16(30990), + 35: uint16(31062), + 36: uint16(31199), + 37: uint16(31895), + 38: uint16(32032), + 39: uint16(32068), + 40: uint16(34311), + 41: uint16(35380), + 42: uint16(38459), + 43: uint16(36961), + 44: uint16(40736), + 45: uint16(20711), + 46: uint16(21109), + 47: uint16(21452), + 48: uint16(21474), + 49: uint16(20489), + 50: uint16(21930), + 51: uint16(22766), + 52: uint16(22863), + 53: uint16(29245), + 54: uint16(23435), + 55: uint16(23652), + 56: uint16(21277), + 57: uint16(24803), + 58: uint16(24819), + 59: uint16(25436), + 60: uint16(25475), + 61: uint16(25407), + 62: uint16(25531), + 63: uint16(25805), + 64: uint16(26089), + 65: uint16(26361), + 66: uint16(24035), + 67: uint16(27085), + 68: uint16(27133), + 69: uint16(28437), + 70: uint16(29157), + 71: uint16(20105), + 72: uint16(30185), + 73: uint16(30456), + 74: uint16(31379), + 75: uint16(31967), + 76: uint16(32207), + 77: uint16(32156), + 78: uint16(32865), + 79: uint16(33609), + 80: uint16(33624), + 81: uint16(33900), + 82: uint16(33980), + 83: uint16(34299), + 84: uint16(35013), + 85: uint16(36208), + 86: uint16(36865), + 87: uint16(36973), + 88: uint16(37783), + 89: uint16(38684), + 90: uint16(39442), + 91: uint16(20687), + 92: uint16(22679), + 93: uint16(24974), + }, + 33: { + 0: uint16(33235), + 1: uint16(34101), + 2: uint16(36104), + 3: uint16(36896), + 4: uint16(20419), + 5: uint16(20596), + 6: uint16(21063), + 7: uint16(21363), + 8: uint16(24687), + 9: uint16(25417), + 10: uint16(26463), + 11: uint16(28204), + 12: uint16(36275), + 13: uint16(36895), + 14: uint16(20439), + 15: uint16(23646), + 16: uint16(36042), + 17: uint16(26063), + 18: uint16(32154), + 19: uint16(21330), + 20: uint16(34966), + 21: uint16(20854), + 22: uint16(25539), + 23: uint16(23384), + 24: uint16(23403), + 25: uint16(23562), + 26: uint16(25613), + 27: uint16(26449), + 28: uint16(36956), + 29: uint16(20182), + 30: uint16(22810), + 31: uint16(22826), + 32: uint16(27760), + 33: uint16(35409), + 34: uint16(21822), + 35: uint16(22549), + 36: uint16(22949), + 37: uint16(24816), + 38: uint16(25171), + 39: uint16(26561), + 40: uint16(33333), + 41: uint16(26965), + 42: uint16(38464), + 43: uint16(39364), + 44: uint16(39464), + 45: uint16(20307), + 46: uint16(22534), + 47: uint16(23550), + 48: uint16(32784), + 49: uint16(23729), + 50: uint16(24111), + 51: uint16(24453), + 52: uint16(24608), + 53: uint16(24907), + 54: uint16(25140), + 55: uint16(26367), + 56: uint16(27888), + 57: uint16(28382), + 58: uint16(32974), + 59: uint16(33151), + 60: uint16(33492), + 61: uint16(34955), + 62: uint16(36024), + 63: uint16(36864), + 64: uint16(36910), + 65: uint16(38538), + 66: uint16(40667), + 67: uint16(39899), + 68: uint16(20195), + 69: uint16(21488), + 70: uint16(22823), + 71: uint16(31532), + 72: uint16(37261), + 73: uint16(38988), + 74: uint16(40441), + 75: uint16(28381), + 76: uint16(28711), + 77: uint16(21331), + 78: uint16(21828), + 79: uint16(23429), + 80: uint16(25176), + 81: uint16(25246), + 82: uint16(25299), + 83: uint16(27810), + 84: uint16(28655), + 85: uint16(29730), + 86: uint16(35351), + 87: uint16(37944), + 88: uint16(28609), + 89: uint16(35582), + 90: uint16(33592), + 91: uint16(20967), + 92: uint16(34552), + 93: uint16(21482), + }, + 34: { + 0: uint16(21481), + 1: uint16(20294), + 2: uint16(36948), + 3: uint16(36784), + 4: uint16(22890), + 5: uint16(33073), + 6: uint16(24061), + 7: uint16(31466), + 8: uint16(36799), + 9: uint16(26842), + 10: uint16(35895), + 11: uint16(29432), + 12: uint16(40008), + 13: uint16(27197), + 14: uint16(35504), + 15: uint16(20025), + 16: uint16(21336), + 17: uint16(22022), + 18: uint16(22374), + 19: uint16(25285), + 20: uint16(25506), + 21: uint16(26086), + 22: uint16(27470), + 23: uint16(28129), + 24: uint16(28251), + 25: uint16(28845), + 26: uint16(30701), + 27: uint16(31471), + 28: uint16(31658), + 29: uint16(32187), + 30: uint16(32829), + 31: uint16(32966), + 32: uint16(34507), + 33: uint16(35477), + 34: uint16(37723), + 35: uint16(22243), + 36: uint16(22727), + 37: uint16(24382), + 38: uint16(26029), + 39: uint16(26262), + 40: uint16(27264), + 41: uint16(27573), + 42: uint16(30007), + 43: uint16(35527), + 44: uint16(20516), + 45: uint16(30693), + 46: uint16(22320), + 47: uint16(24347), + 48: uint16(24677), + 49: uint16(26234), + 50: uint16(27744), + 51: uint16(30196), + 52: uint16(31258), + 53: uint16(32622), + 54: uint16(33268), + 55: uint16(34584), + 56: uint16(36933), + 57: uint16(39347), + 58: uint16(31689), + 59: uint16(30044), + 60: uint16(31481), + 61: uint16(31569), + 62: uint16(33988), + 63: uint16(36880), + 64: uint16(31209), + 65: uint16(31378), + 66: uint16(33590), + 67: uint16(23265), + 68: uint16(30528), + 69: uint16(20013), + 70: uint16(20210), + 71: uint16(23449), + 72: uint16(24544), + 73: uint16(25277), + 74: uint16(26172), + 75: uint16(26609), + 76: uint16(27880), + 77: uint16(34411), + 78: uint16(34935), + 79: uint16(35387), + 80: uint16(37198), + 81: uint16(37619), + 82: uint16(39376), + 83: uint16(27159), + 84: uint16(28710), + 85: uint16(29482), + 86: uint16(33511), + 87: uint16(33879), + 88: uint16(36015), + 89: uint16(19969), + 90: uint16(20806), + 91: uint16(20939), + 92: uint16(21899), + 93: uint16(23541), + }, + 35: { + 0: uint16(24086), + 1: uint16(24115), + 2: uint16(24193), + 3: uint16(24340), + 4: uint16(24373), + 5: uint16(24427), + 6: uint16(24500), + 7: uint16(25074), + 8: uint16(25361), + 9: uint16(26274), + 10: uint16(26397), + 11: uint16(28526), + 12: uint16(29266), + 13: uint16(30010), + 14: uint16(30522), + 15: uint16(32884), + 16: uint16(33081), + 17: uint16(33144), + 18: uint16(34678), + 19: uint16(35519), + 20: uint16(35548), + 21: uint16(36229), + 22: uint16(36339), + 23: uint16(37530), + 24: uint16(38263), + 25: uint16(38914), + 26: uint16(40165), + 27: uint16(21189), + 28: uint16(25431), + 29: uint16(30452), + 30: uint16(26389), + 31: uint16(27784), + 32: uint16(29645), + 33: uint16(36035), + 34: uint16(37806), + 35: uint16(38515), + 36: uint16(27941), + 37: uint16(22684), + 38: uint16(26894), + 39: uint16(27084), + 40: uint16(36861), + 41: uint16(37786), + 42: uint16(30171), + 43: uint16(36890), + 44: uint16(22618), + 45: uint16(26626), + 46: uint16(25524), + 47: uint16(27131), + 48: uint16(20291), + 49: uint16(28460), + 50: uint16(26584), + 51: uint16(36795), + 52: uint16(34086), + 53: uint16(32180), + 54: uint16(37716), + 55: uint16(26943), + 56: uint16(28528), + 57: uint16(22378), + 58: uint16(22775), + 59: uint16(23340), + 60: uint16(32044), + 61: uint16(29226), + 62: uint16(21514), + 63: uint16(37347), + 64: uint16(40372), + 65: uint16(20141), + 66: uint16(20302), + 67: uint16(20572), + 68: uint16(20597), + 69: uint16(21059), + 70: uint16(35998), + 71: uint16(21576), + 72: uint16(22564), + 73: uint16(23450), + 74: uint16(24093), + 75: uint16(24213), + 76: uint16(24237), + 77: uint16(24311), + 78: uint16(24351), + 79: uint16(24716), + 80: uint16(25269), + 81: uint16(25402), + 82: uint16(25552), + 83: uint16(26799), + 84: uint16(27712), + 85: uint16(30855), + 86: uint16(31118), + 87: uint16(31243), + 88: uint16(32224), + 89: uint16(33351), + 90: uint16(35330), + 91: uint16(35558), + 92: uint16(36420), + 93: uint16(36883), + }, + 36: { + 0: uint16(37048), + 1: uint16(37165), + 2: uint16(37336), + 3: uint16(40718), + 4: uint16(27877), + 5: uint16(25688), + 6: uint16(25826), + 7: uint16(25973), + 8: uint16(28404), + 9: uint16(30340), + 10: uint16(31515), + 11: uint16(36969), + 12: uint16(37841), + 13: uint16(28346), + 14: uint16(21746), + 15: uint16(24505), + 16: uint16(25764), + 17: uint16(36685), + 18: uint16(36845), + 19: uint16(37444), + 20: uint16(20856), + 21: uint16(22635), + 22: uint16(22825), + 23: uint16(23637), + 24: uint16(24215), + 25: uint16(28155), + 26: uint16(32399), + 27: uint16(29980), + 28: uint16(36028), + 29: uint16(36578), + 30: uint16(39003), + 31: uint16(28857), + 32: uint16(20253), + 33: uint16(27583), + 34: uint16(28593), + 35: uint16(30000), + 36: uint16(38651), + 37: uint16(20814), + 38: uint16(21520), + 39: uint16(22581), + 40: uint16(22615), + 41: uint16(22956), + 42: uint16(23648), + 43: uint16(24466), + 44: uint16(26007), + 45: uint16(26460), + 46: uint16(28193), + 47: uint16(30331), + 48: uint16(33759), + 49: uint16(36077), + 50: uint16(36884), + 51: uint16(37117), + 52: uint16(37709), + 53: uint16(30757), + 54: uint16(30778), + 55: uint16(21162), + 56: uint16(24230), + 57: uint16(22303), + 58: uint16(22900), + 59: uint16(24594), + 60: uint16(20498), + 61: uint16(20826), + 62: uint16(20908), + 63: uint16(20941), + 64: uint16(20992), + 65: uint16(21776), + 66: uint16(22612), + 67: uint16(22616), + 68: uint16(22871), + 69: uint16(23445), + 70: uint16(23798), + 71: uint16(23947), + 72: uint16(24764), + 73: uint16(25237), + 74: uint16(25645), + 75: uint16(26481), + 76: uint16(26691), + 77: uint16(26812), + 78: uint16(26847), + 79: uint16(30423), + 80: uint16(28120), + 81: uint16(28271), + 82: uint16(28059), + 83: uint16(28783), + 84: uint16(29128), + 85: uint16(24403), + 86: uint16(30168), + 87: uint16(31095), + 88: uint16(31561), + 89: uint16(31572), + 90: uint16(31570), + 91: uint16(31958), + 92: uint16(32113), + 93: uint16(21040), + }, + 37: { + 0: uint16(33891), + 1: uint16(34153), + 2: uint16(34276), + 3: uint16(35342), + 4: uint16(35588), + 5: uint16(35910), + 6: uint16(36367), + 7: uint16(36867), + 8: uint16(36879), + 9: uint16(37913), + 10: uint16(38518), + 11: uint16(38957), + 12: uint16(39472), + 13: uint16(38360), + 14: uint16(20685), + 15: uint16(21205), + 16: uint16(21516), + 17: uint16(22530), + 18: uint16(23566), + 19: uint16(24999), + 20: uint16(25758), + 21: uint16(27934), + 22: uint16(30643), + 23: uint16(31461), + 24: uint16(33012), + 25: uint16(33796), + 26: uint16(36947), + 27: uint16(37509), + 28: uint16(23776), + 29: uint16(40199), + 30: uint16(21311), + 31: uint16(24471), + 32: uint16(24499), + 33: uint16(28060), + 34: uint16(29305), + 35: uint16(30563), + 36: uint16(31167), + 37: uint16(31716), + 38: uint16(27602), + 39: uint16(29420), + 40: uint16(35501), + 41: uint16(26627), + 42: uint16(27233), + 43: uint16(20984), + 44: uint16(31361), + 45: uint16(26932), + 46: uint16(23626), + 47: uint16(40182), + 48: uint16(33515), + 49: uint16(23493), + 50: uint16(37193), + 51: uint16(28702), + 52: uint16(22136), + 53: uint16(23663), + 54: uint16(24775), + 55: uint16(25958), + 56: uint16(27788), + 57: uint16(35930), + 58: uint16(36929), + 59: uint16(38931), + 60: uint16(21585), + 61: uint16(26311), + 62: uint16(37389), + 63: uint16(22856), + 64: uint16(37027), + 65: uint16(20869), + 66: uint16(20045), + 67: uint16(20970), + 68: uint16(34201), + 69: uint16(35598), + 70: uint16(28760), + 71: uint16(25466), + 72: uint16(37707), + 73: uint16(26978), + 74: uint16(39348), + 75: uint16(32260), + 76: uint16(30071), + 77: uint16(21335), + 78: uint16(26976), + 79: uint16(36575), + 80: uint16(38627), + 81: uint16(27741), + 82: uint16(20108), + 83: uint16(23612), + 84: uint16(24336), + 85: uint16(36841), + 86: uint16(21250), + 87: uint16(36049), + 88: uint16(32905), + 89: uint16(34425), + 90: uint16(24319), + 91: uint16(26085), + 92: uint16(20083), + 93: uint16(20837), + }, + 38: { + 0: uint16(22914), + 1: uint16(23615), + 2: uint16(38894), + 3: uint16(20219), + 4: uint16(22922), + 5: uint16(24525), + 6: uint16(35469), + 7: uint16(28641), + 8: uint16(31152), + 9: uint16(31074), + 10: uint16(23527), + 11: uint16(33905), + 12: uint16(29483), + 13: uint16(29105), + 14: uint16(24180), + 15: uint16(24565), + 16: uint16(25467), + 17: uint16(25754), + 18: uint16(29123), + 19: uint16(31896), + 20: uint16(20035), + 21: uint16(24316), + 22: uint16(20043), + 23: uint16(22492), + 24: uint16(22178), + 25: uint16(24745), + 26: uint16(28611), + 27: uint16(32013), + 28: uint16(33021), + 29: uint16(33075), + 30: uint16(33215), + 31: uint16(36786), + 32: uint16(35223), + 33: uint16(34468), + 34: uint16(24052), + 35: uint16(25226), + 36: uint16(25773), + 37: uint16(35207), + 38: uint16(26487), + 39: uint16(27874), + 40: uint16(27966), + 41: uint16(29750), + 42: uint16(30772), + 43: uint16(23110), + 44: uint16(32629), + 45: uint16(33453), + 46: uint16(39340), + 47: uint16(20467), + 48: uint16(24259), + 49: uint16(25309), + 50: uint16(25490), + 51: uint16(25943), + 52: uint16(26479), + 53: uint16(30403), + 54: uint16(29260), + 55: uint16(32972), + 56: uint16(32954), + 57: uint16(36649), + 58: uint16(37197), + 59: uint16(20493), + 60: uint16(22521), + 61: uint16(23186), + 62: uint16(26757), + 63: uint16(26995), + 64: uint16(29028), + 65: uint16(29437), + 66: uint16(36023), + 67: uint16(22770), + 68: uint16(36064), + 69: uint16(38506), + 70: uint16(36889), + 71: uint16(34687), + 72: uint16(31204), + 73: uint16(30695), + 74: uint16(33833), + 75: uint16(20271), + 76: uint16(21093), + 77: uint16(21338), + 78: uint16(25293), + 79: uint16(26575), + 80: uint16(27850), + 81: uint16(30333), + 82: uint16(31636), + 83: uint16(31893), + 84: uint16(33334), + 85: uint16(34180), + 86: uint16(36843), + 87: uint16(26333), + 88: uint16(28448), + 89: uint16(29190), + 90: uint16(32283), + 91: uint16(33707), + 92: uint16(39361), + 93: uint16(40614), + }, + 39: { + 0: uint16(20989), + 1: uint16(31665), + 2: uint16(30834), + 3: uint16(31672), + 4: uint16(32903), + 5: uint16(31560), + 6: uint16(27368), + 7: uint16(24161), + 8: uint16(32908), + 9: uint16(30033), + 10: uint16(30048), + 11: uint16(20843), + 12: uint16(37474), + 13: uint16(28300), + 14: uint16(30330), + 15: uint16(37271), + 16: uint16(39658), + 17: uint16(20240), + 18: uint16(32624), + 19: uint16(25244), + 20: uint16(31567), + 21: uint16(38309), + 22: uint16(40169), + 23: uint16(22138), + 24: uint16(22617), + 25: uint16(34532), + 26: uint16(38588), + 27: uint16(20276), + 28: uint16(21028), + 29: uint16(21322), + 30: uint16(21453), + 31: uint16(21467), + 32: uint16(24070), + 33: uint16(25644), + 34: uint16(26001), + 35: uint16(26495), + 36: uint16(27710), + 37: uint16(27726), + 38: uint16(29256), + 39: uint16(29359), + 40: uint16(29677), + 41: uint16(30036), + 42: uint16(32321), + 43: uint16(33324), + 44: uint16(34281), + 45: uint16(36009), + 46: uint16(31684), + 47: uint16(37318), + 48: uint16(29033), + 49: uint16(38930), + 50: uint16(39151), + 51: uint16(25405), + 52: uint16(26217), + 53: uint16(30058), + 54: uint16(30436), + 55: uint16(30928), + 56: uint16(34115), + 57: uint16(34542), + 58: uint16(21290), + 59: uint16(21329), + 60: uint16(21542), + 61: uint16(22915), + 62: uint16(24199), + 63: uint16(24444), + 64: uint16(24754), + 65: uint16(25161), + 66: uint16(25209), + 67: uint16(25259), + 68: uint16(26000), + 69: uint16(27604), + 70: uint16(27852), + 71: uint16(30130), + 72: uint16(30382), + 73: uint16(30865), + 74: uint16(31192), + 75: uint16(32203), + 76: uint16(32631), + 77: uint16(32933), + 78: uint16(34987), + 79: uint16(35513), + 80: uint16(36027), + 81: uint16(36991), + 82: uint16(38750), + 83: uint16(39131), + 84: uint16(27147), + 85: uint16(31800), + 86: uint16(20633), + 87: uint16(23614), + 88: uint16(24494), + 89: uint16(26503), + 90: uint16(27608), + 91: uint16(29749), + 92: uint16(30473), + 93: uint16(32654), + }, + 40: { + 0: uint16(40763), + 1: uint16(26570), + 2: uint16(31255), + 3: uint16(21305), + 4: uint16(30091), + 5: uint16(39661), + 6: uint16(24422), + 7: uint16(33181), + 8: uint16(33777), + 9: uint16(32920), + 10: uint16(24380), + 11: uint16(24517), + 12: uint16(30050), + 13: uint16(31558), + 14: uint16(36924), + 15: uint16(26727), + 16: uint16(23019), + 17: uint16(23195), + 18: uint16(32016), + 19: uint16(30334), + 20: uint16(35628), + 21: uint16(20469), + 22: uint16(24426), + 23: uint16(27161), + 24: uint16(27703), + 25: uint16(28418), + 26: uint16(29922), + 27: uint16(31080), + 28: uint16(34920), + 29: uint16(35413), + 30: uint16(35961), + 31: uint16(24287), + 32: uint16(25551), + 33: uint16(30149), + 34: uint16(31186), + 35: uint16(33495), + 36: uint16(37672), + 37: uint16(37618), + 38: uint16(33948), + 39: uint16(34541), + 40: uint16(39981), + 41: uint16(21697), + 42: uint16(24428), + 43: uint16(25996), + 44: uint16(27996), + 45: uint16(28693), + 46: uint16(36007), + 47: uint16(36051), + 48: uint16(38971), + 49: uint16(25935), + 50: uint16(29942), + 51: uint16(19981), + 52: uint16(20184), + 53: uint16(22496), + 54: uint16(22827), + 55: uint16(23142), + 56: uint16(23500), + 57: uint16(20904), + 58: uint16(24067), + 59: uint16(24220), + 60: uint16(24598), + 61: uint16(25206), + 62: uint16(25975), + 63: uint16(26023), + 64: uint16(26222), + 65: uint16(28014), + 66: uint16(29238), + 67: uint16(31526), + 68: uint16(33104), + 69: uint16(33178), + 70: uint16(33433), + 71: uint16(35676), + 72: uint16(36000), + 73: uint16(36070), + 74: uint16(36212), + 75: uint16(38428), + 76: uint16(38468), + 77: uint16(20398), + 78: uint16(25771), + 79: uint16(27494), + 80: uint16(33310), + 81: uint16(33889), + 82: uint16(34154), + 83: uint16(37096), + 84: uint16(23553), + 85: uint16(26963), + 86: uint16(39080), + 87: uint16(33914), + 88: uint16(34135), + 89: uint16(20239), + 90: uint16(21103), + 91: uint16(24489), + 92: uint16(24133), + 93: uint16(26381), + }, + 41: { + 0: uint16(31119), + 1: uint16(33145), + 2: uint16(35079), + 3: uint16(35206), + 4: uint16(28149), + 5: uint16(24343), + 6: uint16(25173), + 7: uint16(27832), + 8: uint16(20175), + 9: uint16(29289), + 10: uint16(39826), + 11: uint16(20998), + 12: uint16(21563), + 13: uint16(22132), + 14: uint16(22707), + 15: uint16(24996), + 16: uint16(25198), + 17: uint16(28954), + 18: uint16(22894), + 19: uint16(31881), + 20: uint16(31966), + 21: uint16(32027), + 22: uint16(38640), + 23: uint16(25991), + 24: uint16(32862), + 25: uint16(19993), + 26: uint16(20341), + 27: uint16(20853), + 28: uint16(22592), + 29: uint16(24163), + 30: uint16(24179), + 31: uint16(24330), + 32: uint16(26564), + 33: uint16(20006), + 34: uint16(34109), + 35: uint16(38281), + 36: uint16(38491), + 37: uint16(31859), + 38: uint16(38913), + 39: uint16(20731), + 40: uint16(22721), + 41: uint16(30294), + 42: uint16(30887), + 43: uint16(21029), + 44: uint16(30629), + 45: uint16(34065), + 46: uint16(31622), + 47: uint16(20559), + 48: uint16(22793), + 49: uint16(29255), + 50: uint16(31687), + 51: uint16(32232), + 52: uint16(36794), + 53: uint16(36820), + 54: uint16(36941), + 55: uint16(20415), + 56: uint16(21193), + 57: uint16(23081), + 58: uint16(24321), + 59: uint16(38829), + 60: uint16(20445), + 61: uint16(33303), + 62: uint16(37610), + 63: uint16(22275), + 64: uint16(25429), + 65: uint16(27497), + 66: uint16(29995), + 67: uint16(35036), + 68: uint16(36628), + 69: uint16(31298), + 70: uint16(21215), + 71: uint16(22675), + 72: uint16(24917), + 73: uint16(25098), + 74: uint16(26286), + 75: uint16(27597), + 76: uint16(31807), + 77: uint16(33769), + 78: uint16(20515), + 79: uint16(20472), + 80: uint16(21253), + 81: uint16(21574), + 82: uint16(22577), + 83: uint16(22857), + 84: uint16(23453), + 85: uint16(23792), + 86: uint16(23791), + 87: uint16(23849), + 88: uint16(24214), + 89: uint16(25265), + 90: uint16(25447), + 91: uint16(25918), + 92: uint16(26041), + 93: uint16(26379), + }, + 42: { + 0: uint16(27861), + 1: uint16(27873), + 2: uint16(28921), + 3: uint16(30770), + 4: uint16(32299), + 5: uint16(32990), + 6: uint16(33459), + 7: uint16(33804), + 8: uint16(34028), + 9: uint16(34562), + 10: uint16(35090), + 11: uint16(35370), + 12: uint16(35914), + 13: uint16(37030), + 14: uint16(37586), + 15: uint16(39165), + 16: uint16(40179), + 17: uint16(40300), + 18: uint16(20047), + 19: uint16(20129), + 20: uint16(20621), + 21: uint16(21078), + 22: uint16(22346), + 23: uint16(22952), + 24: uint16(24125), + 25: uint16(24536), + 26: uint16(24537), + 27: uint16(25151), + 28: uint16(26292), + 29: uint16(26395), + 30: uint16(26576), + 31: uint16(26834), + 32: uint16(20882), + 33: uint16(32033), + 34: uint16(32938), + 35: uint16(33192), + 36: uint16(35584), + 37: uint16(35980), + 38: uint16(36031), + 39: uint16(37502), + 40: uint16(38450), + 41: uint16(21536), + 42: uint16(38956), + 43: uint16(21271), + 44: uint16(20693), + 45: uint16(21340), + 46: uint16(22696), + 47: uint16(25778), + 48: uint16(26420), + 49: uint16(29287), + 50: uint16(30566), + 51: uint16(31302), + 52: uint16(37350), + 53: uint16(21187), + 54: uint16(27809), + 55: uint16(27526), + 56: uint16(22528), + 57: uint16(24140), + 58: uint16(22868), + 59: uint16(26412), + 60: uint16(32763), + 61: uint16(20961), + 62: uint16(30406), + 63: uint16(25705), + 64: uint16(30952), + 65: uint16(39764), + 66: uint16(40635), + 67: uint16(22475), + 68: uint16(22969), + 69: uint16(26151), + 70: uint16(26522), + 71: uint16(27598), + 72: uint16(21737), + 73: uint16(27097), + 74: uint16(24149), + 75: uint16(33180), + 76: uint16(26517), + 77: uint16(39850), + 78: uint16(26622), + 79: uint16(40018), + 80: uint16(26717), + 81: uint16(20134), + 82: uint16(20451), + 83: uint16(21448), + 84: uint16(25273), + 85: uint16(26411), + 86: uint16(27819), + 87: uint16(36804), + 88: uint16(20397), + 89: uint16(32365), + 90: uint16(40639), + 91: uint16(19975), + 92: uint16(24930), + 93: uint16(28288), + }, + 43: { + 0: uint16(28459), + 1: uint16(34067), + 2: uint16(21619), + 3: uint16(26410), + 4: uint16(39749), + 5: uint16(24051), + 6: uint16(31637), + 7: uint16(23724), + 8: uint16(23494), + 9: uint16(34588), + 10: uint16(28234), + 11: uint16(34001), + 12: uint16(31252), + 13: uint16(33032), + 14: uint16(22937), + 15: uint16(31885), + 16: uint16(27665), + 17: uint16(30496), + 18: uint16(21209), + 19: uint16(22818), + 20: uint16(28961), + 21: uint16(29279), + 22: uint16(30683), + 23: uint16(38695), + 24: uint16(40289), + 25: uint16(26891), + 26: uint16(23167), + 27: uint16(23064), + 28: uint16(20901), + 29: uint16(21517), + 30: uint16(21629), + 31: uint16(26126), + 32: uint16(30431), + 33: uint16(36855), + 34: uint16(37528), + 35: uint16(40180), + 36: uint16(23018), + 37: uint16(29277), + 38: uint16(28357), + 39: uint16(20813), + 40: uint16(26825), + 41: uint16(32191), + 42: uint16(32236), + 43: uint16(38754), + 44: uint16(40634), + 45: uint16(25720), + 46: uint16(27169), + 47: uint16(33538), + 48: uint16(22916), + 49: uint16(23391), + 50: uint16(27611), + 51: uint16(29467), + 52: uint16(30450), + 53: uint16(32178), + 54: uint16(32791), + 55: uint16(33945), + 56: uint16(20786), + 57: uint16(26408), + 58: uint16(40665), + 59: uint16(30446), + 60: uint16(26466), + 61: uint16(21247), + 62: uint16(39173), + 63: uint16(23588), + 64: uint16(25147), + 65: uint16(31870), + 66: uint16(36016), + 67: uint16(21839), + 68: uint16(24758), + 69: uint16(32011), + 70: uint16(38272), + 71: uint16(21249), + 72: uint16(20063), + 73: uint16(20918), + 74: uint16(22812), + 75: uint16(29242), + 76: uint16(32822), + 77: uint16(37326), + 78: uint16(24357), + 79: uint16(30690), + 80: uint16(21380), + 81: uint16(24441), + 82: uint16(32004), + 83: uint16(34220), + 84: uint16(35379), + 85: uint16(36493), + 86: uint16(38742), + 87: uint16(26611), + 88: uint16(34222), + 89: uint16(37971), + 90: uint16(24841), + 91: uint16(24840), + 92: uint16(27833), + 93: uint16(30290), + }, + 44: { + 0: uint16(35565), + 1: uint16(36664), + 2: uint16(21807), + 3: uint16(20305), + 4: uint16(20778), + 5: uint16(21191), + 6: uint16(21451), + 7: uint16(23461), + 8: uint16(24189), + 9: uint16(24736), + 10: uint16(24962), + 11: uint16(25558), + 12: uint16(26377), + 13: uint16(26586), + 14: uint16(28263), + 15: uint16(28044), + 16: uint16(29494), + 17: uint16(29495), + 18: uint16(30001), + 19: uint16(31056), + 20: uint16(35029), + 21: uint16(35480), + 22: uint16(36938), + 23: uint16(37009), + 24: uint16(37109), + 25: uint16(38596), + 26: uint16(34701), + 27: uint16(22805), + 28: uint16(20104), + 29: uint16(20313), + 30: uint16(19982), + 31: uint16(35465), + 32: uint16(36671), + 33: uint16(38928), + 34: uint16(20653), + 35: uint16(24188), + 36: uint16(22934), + 37: uint16(23481), + 38: uint16(24248), + 39: uint16(25562), + 40: uint16(25594), + 41: uint16(25793), + 42: uint16(26332), + 43: uint16(26954), + 44: uint16(27096), + 45: uint16(27915), + 46: uint16(28342), + 47: uint16(29076), + 48: uint16(29992), + 49: uint16(31407), + 50: uint16(32650), + 51: uint16(32768), + 52: uint16(33865), + 53: uint16(33993), + 54: uint16(35201), + 55: uint16(35617), + 56: uint16(36362), + 57: uint16(36965), + 58: uint16(38525), + 59: uint16(39178), + 60: uint16(24958), + 61: uint16(25233), + 62: uint16(27442), + 63: uint16(27779), + 64: uint16(28020), + 65: uint16(32716), + 66: uint16(32764), + 67: uint16(28096), + 68: uint16(32645), + 69: uint16(34746), + 70: uint16(35064), + 71: uint16(26469), + 72: uint16(33713), + 73: uint16(38972), + 74: uint16(38647), + 75: uint16(27931), + 76: uint16(32097), + 77: uint16(33853), + 78: uint16(37226), + 79: uint16(20081), + 80: uint16(21365), + 81: uint16(23888), + 82: uint16(27396), + 83: uint16(28651), + 84: uint16(34253), + 85: uint16(34349), + 86: uint16(35239), + 87: uint16(21033), + 88: uint16(21519), + 89: uint16(23653), + 90: uint16(26446), + 91: uint16(26792), + 92: uint16(29702), + 93: uint16(29827), + }, + 45: { + 0: uint16(30178), + 1: uint16(35023), + 2: uint16(35041), + 3: uint16(37324), + 4: uint16(38626), + 5: uint16(38520), + 6: uint16(24459), + 7: uint16(29575), + 8: uint16(31435), + 9: uint16(33870), + 10: uint16(25504), + 11: uint16(30053), + 12: uint16(21129), + 13: uint16(27969), + 14: uint16(28316), + 15: uint16(29705), + 16: uint16(30041), + 17: uint16(30827), + 18: uint16(31890), + 19: uint16(38534), + 20: uint16(31452), + 21: uint16(40845), + 22: uint16(20406), + 23: uint16(24942), + 24: uint16(26053), + 25: uint16(34396), + 26: uint16(20102), + 27: uint16(20142), + 28: uint16(20698), + 29: uint16(20001), + 30: uint16(20940), + 31: uint16(23534), + 32: uint16(26009), + 33: uint16(26753), + 34: uint16(28092), + 35: uint16(29471), + 36: uint16(30274), + 37: uint16(30637), + 38: uint16(31260), + 39: uint16(31975), + 40: uint16(33391), + 41: uint16(35538), + 42: uint16(36988), + 43: uint16(37327), + 44: uint16(38517), + 45: uint16(38936), + 46: uint16(21147), + 47: uint16(32209), + 48: uint16(20523), + 49: uint16(21400), + 50: uint16(26519), + 51: uint16(28107), + 52: uint16(29136), + 53: uint16(29747), + 54: uint16(33256), + 55: uint16(36650), + 56: uint16(38563), + 57: uint16(40023), + 58: uint16(40607), + 59: uint16(29792), + 60: uint16(22593), + 61: uint16(28057), + 62: uint16(32047), + 63: uint16(39006), + 64: uint16(20196), + 65: uint16(20278), + 66: uint16(20363), + 67: uint16(20919), + 68: uint16(21169), + 69: uint16(23994), + 70: uint16(24604), + 71: uint16(29618), + 72: uint16(31036), + 73: uint16(33491), + 74: uint16(37428), + 75: uint16(38583), + 76: uint16(38646), + 77: uint16(38666), + 78: uint16(40599), + 79: uint16(40802), + 80: uint16(26278), + 81: uint16(27508), + 82: uint16(21015), + 83: uint16(21155), + 84: uint16(28872), + 85: uint16(35010), + 86: uint16(24265), + 87: uint16(24651), + 88: uint16(24976), + 89: uint16(28451), + 90: uint16(29001), + 91: uint16(31806), + 92: uint16(32244), + 93: uint16(32879), + }, + 46: { + 0: uint16(34030), + 1: uint16(36899), + 2: uint16(37676), + 3: uint16(21570), + 4: uint16(39791), + 5: uint16(27347), + 6: uint16(28809), + 7: uint16(36034), + 8: uint16(36335), + 9: uint16(38706), + 10: uint16(21172), + 11: uint16(23105), + 12: uint16(24266), + 13: uint16(24324), + 14: uint16(26391), + 15: uint16(27004), + 16: uint16(27028), + 17: uint16(28010), + 18: uint16(28431), + 19: uint16(29282), + 20: uint16(29436), + 21: uint16(31725), + 22: uint16(32769), + 23: uint16(32894), + 24: uint16(34635), + 25: uint16(37070), + 26: uint16(20845), + 27: uint16(40595), + 28: uint16(31108), + 29: uint16(32907), + 30: uint16(37682), + 31: uint16(35542), + 32: uint16(20525), + 33: uint16(21644), + 34: uint16(35441), + 35: uint16(27498), + 36: uint16(36036), + 37: uint16(33031), + 38: uint16(24785), + 39: uint16(26528), + 40: uint16(40434), + 41: uint16(20121), + 42: uint16(20120), + 43: uint16(39952), + 44: uint16(35435), + 45: uint16(34241), + 46: uint16(34152), + 47: uint16(26880), + 48: uint16(28286), + 49: uint16(30871), + 50: uint16(33109), + }, + 47: { + 0: uint16(24332), + 1: uint16(19984), + 2: uint16(19989), + 3: uint16(20010), + 4: uint16(20017), + 5: uint16(20022), + 6: uint16(20028), + 7: uint16(20031), + 8: uint16(20034), + 9: uint16(20054), + 10: uint16(20056), + 11: uint16(20098), + 12: uint16(20101), + 13: uint16(35947), + 14: uint16(20106), + 15: uint16(33298), + 16: uint16(24333), + 17: uint16(20110), + 18: uint16(20126), + 19: uint16(20127), + 20: uint16(20128), + 21: uint16(20130), + 22: uint16(20144), + 23: uint16(20147), + 24: uint16(20150), + 25: uint16(20174), + 26: uint16(20173), + 27: uint16(20164), + 28: uint16(20166), + 29: uint16(20162), + 30: uint16(20183), + 31: uint16(20190), + 32: uint16(20205), + 33: uint16(20191), + 34: uint16(20215), + 35: uint16(20233), + 36: uint16(20314), + 37: uint16(20272), + 38: uint16(20315), + 39: uint16(20317), + 40: uint16(20311), + 41: uint16(20295), + 42: uint16(20342), + 43: uint16(20360), + 44: uint16(20367), + 45: uint16(20376), + 46: uint16(20347), + 47: uint16(20329), + 48: uint16(20336), + 49: uint16(20369), + 50: uint16(20335), + 51: uint16(20358), + 52: uint16(20374), + 53: uint16(20760), + 54: uint16(20436), + 55: uint16(20447), + 56: uint16(20430), + 57: uint16(20440), + 58: uint16(20443), + 59: uint16(20433), + 60: uint16(20442), + 61: uint16(20432), + 62: uint16(20452), + 63: uint16(20453), + 64: uint16(20506), + 65: uint16(20520), + 66: uint16(20500), + 67: uint16(20522), + 68: uint16(20517), + 69: uint16(20485), + 70: uint16(20252), + 71: uint16(20470), + 72: uint16(20513), + 73: uint16(20521), + 74: uint16(20524), + 75: uint16(20478), + 76: uint16(20463), + 77: uint16(20497), + 78: uint16(20486), + 79: uint16(20547), + 80: uint16(20551), + 81: uint16(26371), + 82: uint16(20565), + 83: uint16(20560), + 84: uint16(20552), + 85: uint16(20570), + 86: uint16(20566), + 87: uint16(20588), + 88: uint16(20600), + 89: uint16(20608), + 90: uint16(20634), + 91: uint16(20613), + 92: uint16(20660), + 93: uint16(20658), + }, + 48: { + 0: uint16(20681), + 1: uint16(20682), + 2: uint16(20659), + 3: uint16(20674), + 4: uint16(20694), + 5: uint16(20702), + 6: uint16(20709), + 7: uint16(20717), + 8: uint16(20707), + 9: uint16(20718), + 10: uint16(20729), + 11: uint16(20725), + 12: uint16(20745), + 13: uint16(20737), + 14: uint16(20738), + 15: uint16(20758), + 16: uint16(20757), + 17: uint16(20756), + 18: uint16(20762), + 19: uint16(20769), + 20: uint16(20794), + 21: uint16(20791), + 22: uint16(20796), + 23: uint16(20795), + 24: uint16(20799), + 25: uint16(20800), + 26: uint16(20818), + 27: uint16(20812), + 28: uint16(20820), + 29: uint16(20834), + 30: uint16(31480), + 31: uint16(20841), + 32: uint16(20842), + 33: uint16(20846), + 34: uint16(20864), + 35: uint16(20866), + 36: uint16(22232), + 37: uint16(20876), + 38: uint16(20873), + 39: uint16(20879), + 40: uint16(20881), + 41: uint16(20883), + 42: uint16(20885), + 43: uint16(20886), + 44: uint16(20900), + 45: uint16(20902), + 46: uint16(20898), + 47: uint16(20905), + 48: uint16(20906), + 49: uint16(20907), + 50: uint16(20915), + 51: uint16(20913), + 52: uint16(20914), + 53: uint16(20912), + 54: uint16(20917), + 55: uint16(20925), + 56: uint16(20933), + 57: uint16(20937), + 58: uint16(20955), + 59: uint16(20960), + 60: uint16(34389), + 61: uint16(20969), + 62: uint16(20973), + 63: uint16(20976), + 64: uint16(20981), + 65: uint16(20990), + 66: uint16(20996), + 67: uint16(21003), + 68: uint16(21012), + 69: uint16(21006), + 70: uint16(21031), + 71: uint16(21034), + 72: uint16(21038), + 73: uint16(21043), + 74: uint16(21049), + 75: uint16(21071), + 76: uint16(21060), + 77: uint16(21067), + 78: uint16(21068), + 79: uint16(21086), + 80: uint16(21076), + 81: uint16(21098), + 82: uint16(21108), + 83: uint16(21097), + 84: uint16(21107), + 85: uint16(21119), + 86: uint16(21117), + 87: uint16(21133), + 88: uint16(21140), + 89: uint16(21138), + 90: uint16(21105), + 91: uint16(21128), + 92: uint16(21137), + 93: uint16(36776), + }, + 49: { + 0: uint16(36775), + 1: uint16(21164), + 2: uint16(21165), + 3: uint16(21180), + 4: uint16(21173), + 5: uint16(21185), + 6: uint16(21197), + 7: uint16(21207), + 8: uint16(21214), + 9: uint16(21219), + 10: uint16(21222), + 11: uint16(39149), + 12: uint16(21216), + 13: uint16(21235), + 14: uint16(21237), + 15: uint16(21240), + 16: uint16(21241), + 17: uint16(21254), + 18: uint16(21256), + 19: uint16(30008), + 20: uint16(21261), + 21: uint16(21264), + 22: uint16(21263), + 23: uint16(21269), + 24: uint16(21274), + 25: uint16(21283), + 26: uint16(21295), + 27: uint16(21297), + 28: uint16(21299), + 29: uint16(21304), + 30: uint16(21312), + 31: uint16(21318), + 32: uint16(21317), + 33: uint16(19991), + 34: uint16(21321), + 35: uint16(21325), + 36: uint16(20950), + 37: uint16(21342), + 38: uint16(21353), + 39: uint16(21358), + 40: uint16(22808), + 41: uint16(21371), + 42: uint16(21367), + 43: uint16(21378), + 44: uint16(21398), + 45: uint16(21408), + 46: uint16(21414), + 47: uint16(21413), + 48: uint16(21422), + 49: uint16(21424), + 50: uint16(21430), + 51: uint16(21443), + 52: uint16(31762), + 53: uint16(38617), + 54: uint16(21471), + 55: uint16(26364), + 56: uint16(29166), + 57: uint16(21486), + 58: uint16(21480), + 59: uint16(21485), + 60: uint16(21498), + 61: uint16(21505), + 62: uint16(21565), + 63: uint16(21568), + 64: uint16(21548), + 65: uint16(21549), + 66: uint16(21564), + 67: uint16(21550), + 68: uint16(21558), + 69: uint16(21545), + 70: uint16(21533), + 71: uint16(21582), + 72: uint16(21647), + 73: uint16(21621), + 74: uint16(21646), + 75: uint16(21599), + 76: uint16(21617), + 77: uint16(21623), + 78: uint16(21616), + 79: uint16(21650), + 80: uint16(21627), + 81: uint16(21632), + 82: uint16(21622), + 83: uint16(21636), + 84: uint16(21648), + 85: uint16(21638), + 86: uint16(21703), + 87: uint16(21666), + 88: uint16(21688), + 89: uint16(21669), + 90: uint16(21676), + 91: uint16(21700), + 92: uint16(21704), + 93: uint16(21672), + }, + 50: { + 0: uint16(21675), + 1: uint16(21698), + 2: uint16(21668), + 3: uint16(21694), + 4: uint16(21692), + 5: uint16(21720), + 6: uint16(21733), + 7: uint16(21734), + 8: uint16(21775), + 9: uint16(21780), + 10: uint16(21757), + 11: uint16(21742), + 12: uint16(21741), + 13: uint16(21754), + 14: uint16(21730), + 15: uint16(21817), + 16: uint16(21824), + 17: uint16(21859), + 18: uint16(21836), + 19: uint16(21806), + 20: uint16(21852), + 21: uint16(21829), + 22: uint16(21846), + 23: uint16(21847), + 24: uint16(21816), + 25: uint16(21811), + 26: uint16(21853), + 27: uint16(21913), + 28: uint16(21888), + 29: uint16(21679), + 30: uint16(21898), + 31: uint16(21919), + 32: uint16(21883), + 33: uint16(21886), + 34: uint16(21912), + 35: uint16(21918), + 36: uint16(21934), + 37: uint16(21884), + 38: uint16(21891), + 39: uint16(21929), + 40: uint16(21895), + 41: uint16(21928), + 42: uint16(21978), + 43: uint16(21957), + 44: uint16(21983), + 45: uint16(21956), + 46: uint16(21980), + 47: uint16(21988), + 48: uint16(21972), + 49: uint16(22036), + 50: uint16(22007), + 51: uint16(22038), + 52: uint16(22014), + 53: uint16(22013), + 54: uint16(22043), + 55: uint16(22009), + 56: uint16(22094), + 57: uint16(22096), + 58: uint16(29151), + 59: uint16(22068), + 60: uint16(22070), + 61: uint16(22066), + 62: uint16(22072), + 63: uint16(22123), + 64: uint16(22116), + 65: uint16(22063), + 66: uint16(22124), + 67: uint16(22122), + 68: uint16(22150), + 69: uint16(22144), + 70: uint16(22154), + 71: uint16(22176), + 72: uint16(22164), + 73: uint16(22159), + 74: uint16(22181), + 75: uint16(22190), + 76: uint16(22198), + 77: uint16(22196), + 78: uint16(22210), + 79: uint16(22204), + 80: uint16(22209), + 81: uint16(22211), + 82: uint16(22208), + 83: uint16(22216), + 84: uint16(22222), + 85: uint16(22225), + 86: uint16(22227), + 87: uint16(22231), + 88: uint16(22254), + 89: uint16(22265), + 90: uint16(22272), + 91: uint16(22271), + 92: uint16(22276), + 93: uint16(22281), + }, + 51: { + 0: uint16(22280), + 1: uint16(22283), + 2: uint16(22285), + 3: uint16(22291), + 4: uint16(22296), + 5: uint16(22294), + 6: uint16(21959), + 7: uint16(22300), + 8: uint16(22310), + 9: uint16(22327), + 10: uint16(22328), + 11: uint16(22350), + 12: uint16(22331), + 13: uint16(22336), + 14: uint16(22351), + 15: uint16(22377), + 16: uint16(22464), + 17: uint16(22408), + 18: uint16(22369), + 19: uint16(22399), + 20: uint16(22409), + 21: uint16(22419), + 22: uint16(22432), + 23: uint16(22451), + 24: uint16(22436), + 25: uint16(22442), + 26: uint16(22448), + 27: uint16(22467), + 28: uint16(22470), + 29: uint16(22484), + 30: uint16(22482), + 31: uint16(22483), + 32: uint16(22538), + 33: uint16(22486), + 34: uint16(22499), + 35: uint16(22539), + 36: uint16(22553), + 37: uint16(22557), + 38: uint16(22642), + 39: uint16(22561), + 40: uint16(22626), + 41: uint16(22603), + 42: uint16(22640), + 43: uint16(27584), + 44: uint16(22610), + 45: uint16(22589), + 46: uint16(22649), + 47: uint16(22661), + 48: uint16(22713), + 49: uint16(22687), + 50: uint16(22699), + 51: uint16(22714), + 52: uint16(22750), + 53: uint16(22715), + 54: uint16(22712), + 55: uint16(22702), + 56: uint16(22725), + 57: uint16(22739), + 58: uint16(22737), + 59: uint16(22743), + 60: uint16(22745), + 61: uint16(22744), + 62: uint16(22757), + 63: uint16(22748), + 64: uint16(22756), + 65: uint16(22751), + 66: uint16(22767), + 67: uint16(22778), + 68: uint16(22777), + 69: uint16(22779), + 70: uint16(22780), + 71: uint16(22781), + 72: uint16(22786), + 73: uint16(22794), + 74: uint16(22800), + 75: uint16(22811), + 76: uint16(26790), + 77: uint16(22821), + 78: uint16(22828), + 79: uint16(22829), + 80: uint16(22834), + 81: uint16(22840), + 82: uint16(22846), + 83: uint16(31442), + 84: uint16(22869), + 85: uint16(22864), + 86: uint16(22862), + 87: uint16(22874), + 88: uint16(22872), + 89: uint16(22882), + 90: uint16(22880), + 91: uint16(22887), + 92: uint16(22892), + 93: uint16(22889), + }, + 52: { + 0: uint16(22904), + 1: uint16(22913), + 2: uint16(22941), + 3: uint16(20318), + 4: uint16(20395), + 5: uint16(22947), + 6: uint16(22962), + 7: uint16(22982), + 8: uint16(23016), + 9: uint16(23004), + 10: uint16(22925), + 11: uint16(23001), + 12: uint16(23002), + 13: uint16(23077), + 14: uint16(23071), + 15: uint16(23057), + 16: uint16(23068), + 17: uint16(23049), + 18: uint16(23066), + 19: uint16(23104), + 20: uint16(23148), + 21: uint16(23113), + 22: uint16(23093), + 23: uint16(23094), + 24: uint16(23138), + 25: uint16(23146), + 26: uint16(23194), + 27: uint16(23228), + 28: uint16(23230), + 29: uint16(23243), + 30: uint16(23234), + 31: uint16(23229), + 32: uint16(23267), + 33: uint16(23255), + 34: uint16(23270), + 35: uint16(23273), + 36: uint16(23254), + 37: uint16(23290), + 38: uint16(23291), + 39: uint16(23308), + 40: uint16(23307), + 41: uint16(23318), + 42: uint16(23346), + 43: uint16(23248), + 44: uint16(23338), + 45: uint16(23350), + 46: uint16(23358), + 47: uint16(23363), + 48: uint16(23365), + 49: uint16(23360), + 50: uint16(23377), + 51: uint16(23381), + 52: uint16(23386), + 53: uint16(23387), + 54: uint16(23397), + 55: uint16(23401), + 56: uint16(23408), + 57: uint16(23411), + 58: uint16(23413), + 59: uint16(23416), + 60: uint16(25992), + 61: uint16(23418), + 62: uint16(23424), + 63: uint16(23427), + 64: uint16(23462), + 65: uint16(23480), + 66: uint16(23491), + 67: uint16(23495), + 68: uint16(23497), + 69: uint16(23508), + 70: uint16(23504), + 71: uint16(23524), + 72: uint16(23526), + 73: uint16(23522), + 74: uint16(23518), + 75: uint16(23525), + 76: uint16(23531), + 77: uint16(23536), + 78: uint16(23542), + 79: uint16(23539), + 80: uint16(23557), + 81: uint16(23559), + 82: uint16(23560), + 83: uint16(23565), + 84: uint16(23571), + 85: uint16(23584), + 86: uint16(23586), + 87: uint16(23592), + 88: uint16(23608), + 89: uint16(23609), + 90: uint16(23617), + 91: uint16(23622), + 92: uint16(23630), + 93: uint16(23635), + }, + 53: { + 0: uint16(23632), + 1: uint16(23631), + 2: uint16(23409), + 3: uint16(23660), + 4: uint16(23662), + 5: uint16(20066), + 6: uint16(23670), + 7: uint16(23673), + 8: uint16(23692), + 9: uint16(23697), + 10: uint16(23700), + 11: uint16(22939), + 12: uint16(23723), + 13: uint16(23739), + 14: uint16(23734), + 15: uint16(23740), + 16: uint16(23735), + 17: uint16(23749), + 18: uint16(23742), + 19: uint16(23751), + 20: uint16(23769), + 21: uint16(23785), + 22: uint16(23805), + 23: uint16(23802), + 24: uint16(23789), + 25: uint16(23948), + 26: uint16(23786), + 27: uint16(23819), + 28: uint16(23829), + 29: uint16(23831), + 30: uint16(23900), + 31: uint16(23839), + 32: uint16(23835), + 33: uint16(23825), + 34: uint16(23828), + 35: uint16(23842), + 36: uint16(23834), + 37: uint16(23833), + 38: uint16(23832), + 39: uint16(23884), + 40: uint16(23890), + 41: uint16(23886), + 42: uint16(23883), + 43: uint16(23916), + 44: uint16(23923), + 45: uint16(23926), + 46: uint16(23943), + 47: uint16(23940), + 48: uint16(23938), + 49: uint16(23970), + 50: uint16(23965), + 51: uint16(23980), + 52: uint16(23982), + 53: uint16(23997), + 54: uint16(23952), + 55: uint16(23991), + 56: uint16(23996), + 57: uint16(24009), + 58: uint16(24013), + 59: uint16(24019), + 60: uint16(24018), + 61: uint16(24022), + 62: uint16(24027), + 63: uint16(24043), + 64: uint16(24050), + 65: uint16(24053), + 66: uint16(24075), + 67: uint16(24090), + 68: uint16(24089), + 69: uint16(24081), + 70: uint16(24091), + 71: uint16(24118), + 72: uint16(24119), + 73: uint16(24132), + 74: uint16(24131), + 75: uint16(24128), + 76: uint16(24142), + 77: uint16(24151), + 78: uint16(24148), + 79: uint16(24159), + 80: uint16(24162), + 81: uint16(24164), + 82: uint16(24135), + 83: uint16(24181), + 84: uint16(24182), + 85: uint16(24186), + 86: uint16(40636), + 87: uint16(24191), + 88: uint16(24224), + 89: uint16(24257), + 90: uint16(24258), + 91: uint16(24264), + 92: uint16(24272), + 93: uint16(24271), + }, + 54: { + 0: uint16(24278), + 1: uint16(24291), + 2: uint16(24285), + 3: uint16(24282), + 4: uint16(24283), + 5: uint16(24290), + 6: uint16(24289), + 7: uint16(24296), + 8: uint16(24297), + 9: uint16(24300), + 10: uint16(24305), + 11: uint16(24307), + 12: uint16(24304), + 13: uint16(24308), + 14: uint16(24312), + 15: uint16(24318), + 16: uint16(24323), + 17: uint16(24329), + 18: uint16(24413), + 19: uint16(24412), + 20: uint16(24331), + 21: uint16(24337), + 22: uint16(24342), + 23: uint16(24361), + 24: uint16(24365), + 25: uint16(24376), + 26: uint16(24385), + 27: uint16(24392), + 28: uint16(24396), + 29: uint16(24398), + 30: uint16(24367), + 31: uint16(24401), + 32: uint16(24406), + 33: uint16(24407), + 34: uint16(24409), + 35: uint16(24417), + 36: uint16(24429), + 37: uint16(24435), + 38: uint16(24439), + 39: uint16(24451), + 40: uint16(24450), + 41: uint16(24447), + 42: uint16(24458), + 43: uint16(24456), + 44: uint16(24465), + 45: uint16(24455), + 46: uint16(24478), + 47: uint16(24473), + 48: uint16(24472), + 49: uint16(24480), + 50: uint16(24488), + 51: uint16(24493), + 52: uint16(24508), + 53: uint16(24534), + 54: uint16(24571), + 55: uint16(24548), + 56: uint16(24568), + 57: uint16(24561), + 58: uint16(24541), + 59: uint16(24755), + 60: uint16(24575), + 61: uint16(24609), + 62: uint16(24672), + 63: uint16(24601), + 64: uint16(24592), + 65: uint16(24617), + 66: uint16(24590), + 67: uint16(24625), + 68: uint16(24603), + 69: uint16(24597), + 70: uint16(24619), + 71: uint16(24614), + 72: uint16(24591), + 73: uint16(24634), + 74: uint16(24666), + 75: uint16(24641), + 76: uint16(24682), + 77: uint16(24695), + 78: uint16(24671), + 79: uint16(24650), + 80: uint16(24646), + 81: uint16(24653), + 82: uint16(24675), + 83: uint16(24643), + 84: uint16(24676), + 85: uint16(24642), + 86: uint16(24684), + 87: uint16(24683), + 88: uint16(24665), + 89: uint16(24705), + 90: uint16(24717), + 91: uint16(24807), + 92: uint16(24707), + 93: uint16(24730), + }, + 55: { + 0: uint16(24708), + 1: uint16(24731), + 2: uint16(24726), + 3: uint16(24727), + 4: uint16(24722), + 5: uint16(24743), + 6: uint16(24715), + 7: uint16(24801), + 8: uint16(24760), + 9: uint16(24800), + 10: uint16(24787), + 11: uint16(24756), + 12: uint16(24560), + 13: uint16(24765), + 14: uint16(24774), + 15: uint16(24757), + 16: uint16(24792), + 17: uint16(24909), + 18: uint16(24853), + 19: uint16(24838), + 20: uint16(24822), + 21: uint16(24823), + 22: uint16(24832), + 23: uint16(24820), + 24: uint16(24826), + 25: uint16(24835), + 26: uint16(24865), + 27: uint16(24827), + 28: uint16(24817), + 29: uint16(24845), + 30: uint16(24846), + 31: uint16(24903), + 32: uint16(24894), + 33: uint16(24872), + 34: uint16(24871), + 35: uint16(24906), + 36: uint16(24895), + 37: uint16(24892), + 38: uint16(24876), + 39: uint16(24884), + 40: uint16(24893), + 41: uint16(24898), + 42: uint16(24900), + 43: uint16(24947), + 44: uint16(24951), + 45: uint16(24920), + 46: uint16(24921), + 47: uint16(24922), + 48: uint16(24939), + 49: uint16(24948), + 50: uint16(24943), + 51: uint16(24933), + 52: uint16(24945), + 53: uint16(24927), + 54: uint16(24925), + 55: uint16(24915), + 56: uint16(24949), + 57: uint16(24985), + 58: uint16(24982), + 59: uint16(24967), + 60: uint16(25004), + 61: uint16(24980), + 62: uint16(24986), + 63: uint16(24970), + 64: uint16(24977), + 65: uint16(25003), + 66: uint16(25006), + 67: uint16(25036), + 68: uint16(25034), + 69: uint16(25033), + 70: uint16(25079), + 71: uint16(25032), + 72: uint16(25027), + 73: uint16(25030), + 74: uint16(25018), + 75: uint16(25035), + 76: uint16(32633), + 77: uint16(25037), + 78: uint16(25062), + 79: uint16(25059), + 80: uint16(25078), + 81: uint16(25082), + 82: uint16(25076), + 83: uint16(25087), + 84: uint16(25085), + 85: uint16(25084), + 86: uint16(25086), + 87: uint16(25088), + 88: uint16(25096), + 89: uint16(25097), + 90: uint16(25101), + 91: uint16(25100), + 92: uint16(25108), + 93: uint16(25115), + }, + 56: { + 0: uint16(25118), + 1: uint16(25121), + 2: uint16(25130), + 3: uint16(25134), + 4: uint16(25136), + 5: uint16(25138), + 6: uint16(25139), + 7: uint16(25153), + 8: uint16(25166), + 9: uint16(25182), + 10: uint16(25187), + 11: uint16(25179), + 12: uint16(25184), + 13: uint16(25192), + 14: uint16(25212), + 15: uint16(25218), + 16: uint16(25225), + 17: uint16(25214), + 18: uint16(25234), + 19: uint16(25235), + 20: uint16(25238), + 21: uint16(25300), + 22: uint16(25219), + 23: uint16(25236), + 24: uint16(25303), + 25: uint16(25297), + 26: uint16(25275), + 27: uint16(25295), + 28: uint16(25343), + 29: uint16(25286), + 30: uint16(25812), + 31: uint16(25288), + 32: uint16(25308), + 33: uint16(25292), + 34: uint16(25290), + 35: uint16(25282), + 36: uint16(25287), + 37: uint16(25243), + 38: uint16(25289), + 39: uint16(25356), + 40: uint16(25326), + 41: uint16(25329), + 42: uint16(25383), + 43: uint16(25346), + 44: uint16(25352), + 45: uint16(25327), + 46: uint16(25333), + 47: uint16(25424), + 48: uint16(25406), + 49: uint16(25421), + 50: uint16(25628), + 51: uint16(25423), + 52: uint16(25494), + 53: uint16(25486), + 54: uint16(25472), + 55: uint16(25515), + 56: uint16(25462), + 57: uint16(25507), + 58: uint16(25487), + 59: uint16(25481), + 60: uint16(25503), + 61: uint16(25525), + 62: uint16(25451), + 63: uint16(25449), + 64: uint16(25534), + 65: uint16(25577), + 66: uint16(25536), + 67: uint16(25542), + 68: uint16(25571), + 69: uint16(25545), + 70: uint16(25554), + 71: uint16(25590), + 72: uint16(25540), + 73: uint16(25622), + 74: uint16(25652), + 75: uint16(25606), + 76: uint16(25619), + 77: uint16(25638), + 78: uint16(25654), + 79: uint16(25885), + 80: uint16(25623), + 81: uint16(25640), + 82: uint16(25615), + 83: uint16(25703), + 84: uint16(25711), + 85: uint16(25718), + 86: uint16(25678), + 87: uint16(25898), + 88: uint16(25749), + 89: uint16(25747), + 90: uint16(25765), + 91: uint16(25769), + 92: uint16(25736), + 93: uint16(25788), + }, + 57: { + 0: uint16(25818), + 1: uint16(25810), + 2: uint16(25797), + 3: uint16(25799), + 4: uint16(25787), + 5: uint16(25816), + 6: uint16(25794), + 7: uint16(25841), + 8: uint16(25831), + 9: uint16(33289), + 10: uint16(25824), + 11: uint16(25825), + 12: uint16(25260), + 13: uint16(25827), + 14: uint16(25839), + 15: uint16(25900), + 16: uint16(25846), + 17: uint16(25844), + 18: uint16(25842), + 19: uint16(25850), + 20: uint16(25856), + 21: uint16(25853), + 22: uint16(25880), + 23: uint16(25884), + 24: uint16(25861), + 25: uint16(25892), + 26: uint16(25891), + 27: uint16(25899), + 28: uint16(25908), + 29: uint16(25909), + 30: uint16(25911), + 31: uint16(25910), + 32: uint16(25912), + 33: uint16(30027), + 34: uint16(25928), + 35: uint16(25942), + 36: uint16(25941), + 37: uint16(25933), + 38: uint16(25944), + 39: uint16(25950), + 40: uint16(25949), + 41: uint16(25970), + 42: uint16(25976), + 43: uint16(25986), + 44: uint16(25987), + 45: uint16(35722), + 46: uint16(26011), + 47: uint16(26015), + 48: uint16(26027), + 49: uint16(26039), + 50: uint16(26051), + 51: uint16(26054), + 52: uint16(26049), + 53: uint16(26052), + 54: uint16(26060), + 55: uint16(26066), + 56: uint16(26075), + 57: uint16(26073), + 58: uint16(26080), + 59: uint16(26081), + 60: uint16(26097), + 61: uint16(26482), + 62: uint16(26122), + 63: uint16(26115), + 64: uint16(26107), + 65: uint16(26483), + 66: uint16(26165), + 67: uint16(26166), + 68: uint16(26164), + 69: uint16(26140), + 70: uint16(26191), + 71: uint16(26180), + 72: uint16(26185), + 73: uint16(26177), + 74: uint16(26206), + 75: uint16(26205), + 76: uint16(26212), + 77: uint16(26215), + 78: uint16(26216), + 79: uint16(26207), + 80: uint16(26210), + 81: uint16(26224), + 82: uint16(26243), + 83: uint16(26248), + 84: uint16(26254), + 85: uint16(26249), + 86: uint16(26244), + 87: uint16(26264), + 88: uint16(26269), + 89: uint16(26305), + 90: uint16(26297), + 91: uint16(26313), + 92: uint16(26302), + 93: uint16(26300), + }, + 58: { + 0: uint16(26308), + 1: uint16(26296), + 2: uint16(26326), + 3: uint16(26330), + 4: uint16(26336), + 5: uint16(26175), + 6: uint16(26342), + 7: uint16(26345), + 8: uint16(26352), + 9: uint16(26357), + 10: uint16(26359), + 11: uint16(26383), + 12: uint16(26390), + 13: uint16(26398), + 14: uint16(26406), + 15: uint16(26407), + 16: uint16(38712), + 17: uint16(26414), + 18: uint16(26431), + 19: uint16(26422), + 20: uint16(26433), + 21: uint16(26424), + 22: uint16(26423), + 23: uint16(26438), + 24: uint16(26462), + 25: uint16(26464), + 26: uint16(26457), + 27: uint16(26467), + 28: uint16(26468), + 29: uint16(26505), + 30: uint16(26480), + 31: uint16(26537), + 32: uint16(26492), + 33: uint16(26474), + 34: uint16(26508), + 35: uint16(26507), + 36: uint16(26534), + 37: uint16(26529), + 38: uint16(26501), + 39: uint16(26551), + 40: uint16(26607), + 41: uint16(26548), + 42: uint16(26604), + 43: uint16(26547), + 44: uint16(26601), + 45: uint16(26552), + 46: uint16(26596), + 47: uint16(26590), + 48: uint16(26589), + 49: uint16(26594), + 50: uint16(26606), + 51: uint16(26553), + 52: uint16(26574), + 53: uint16(26566), + 54: uint16(26599), + 55: uint16(27292), + 56: uint16(26654), + 57: uint16(26694), + 58: uint16(26665), + 59: uint16(26688), + 60: uint16(26701), + 61: uint16(26674), + 62: uint16(26702), + 63: uint16(26803), + 64: uint16(26667), + 65: uint16(26713), + 66: uint16(26723), + 67: uint16(26743), + 68: uint16(26751), + 69: uint16(26783), + 70: uint16(26767), + 71: uint16(26797), + 72: uint16(26772), + 73: uint16(26781), + 74: uint16(26779), + 75: uint16(26755), + 76: uint16(27310), + 77: uint16(26809), + 78: uint16(26740), + 79: uint16(26805), + 80: uint16(26784), + 81: uint16(26810), + 82: uint16(26895), + 83: uint16(26765), + 84: uint16(26750), + 85: uint16(26881), + 86: uint16(26826), + 87: uint16(26888), + 88: uint16(26840), + 89: uint16(26914), + 90: uint16(26918), + 91: uint16(26849), + 92: uint16(26892), + 93: uint16(26829), + }, + 59: { + 0: uint16(26836), + 1: uint16(26855), + 2: uint16(26837), + 3: uint16(26934), + 4: uint16(26898), + 5: uint16(26884), + 6: uint16(26839), + 7: uint16(26851), + 8: uint16(26917), + 9: uint16(26873), + 10: uint16(26848), + 11: uint16(26863), + 12: uint16(26920), + 13: uint16(26922), + 14: uint16(26906), + 15: uint16(26915), + 16: uint16(26913), + 17: uint16(26822), + 18: uint16(27001), + 19: uint16(26999), + 20: uint16(26972), + 21: uint16(27000), + 22: uint16(26987), + 23: uint16(26964), + 24: uint16(27006), + 25: uint16(26990), + 26: uint16(26937), + 27: uint16(26996), + 28: uint16(26941), + 29: uint16(26969), + 30: uint16(26928), + 31: uint16(26977), + 32: uint16(26974), + 33: uint16(26973), + 34: uint16(27009), + 35: uint16(26986), + 36: uint16(27058), + 37: uint16(27054), + 38: uint16(27088), + 39: uint16(27071), + 40: uint16(27073), + 41: uint16(27091), + 42: uint16(27070), + 43: uint16(27086), + 44: uint16(23528), + 45: uint16(27082), + 46: uint16(27101), + 47: uint16(27067), + 48: uint16(27075), + 49: uint16(27047), + 50: uint16(27182), + 51: uint16(27025), + 52: uint16(27040), + 53: uint16(27036), + 54: uint16(27029), + 55: uint16(27060), + 56: uint16(27102), + 57: uint16(27112), + 58: uint16(27138), + 59: uint16(27163), + 60: uint16(27135), + 61: uint16(27402), + 62: uint16(27129), + 63: uint16(27122), + 64: uint16(27111), + 65: uint16(27141), + 66: uint16(27057), + 67: uint16(27166), + 68: uint16(27117), + 69: uint16(27156), + 70: uint16(27115), + 71: uint16(27146), + 72: uint16(27154), + 73: uint16(27329), + 74: uint16(27171), + 75: uint16(27155), + 76: uint16(27204), + 77: uint16(27148), + 78: uint16(27250), + 79: uint16(27190), + 80: uint16(27256), + 81: uint16(27207), + 82: uint16(27234), + 83: uint16(27225), + 84: uint16(27238), + 85: uint16(27208), + 86: uint16(27192), + 87: uint16(27170), + 88: uint16(27280), + 89: uint16(27277), + 90: uint16(27296), + 91: uint16(27268), + 92: uint16(27298), + 93: uint16(27299), + }, + 60: { + 0: uint16(27287), + 1: uint16(34327), + 2: uint16(27323), + 3: uint16(27331), + 4: uint16(27330), + 5: uint16(27320), + 6: uint16(27315), + 7: uint16(27308), + 8: uint16(27358), + 9: uint16(27345), + 10: uint16(27359), + 11: uint16(27306), + 12: uint16(27354), + 13: uint16(27370), + 14: uint16(27387), + 15: uint16(27397), + 16: uint16(34326), + 17: uint16(27386), + 18: uint16(27410), + 19: uint16(27414), + 20: uint16(39729), + 21: uint16(27423), + 22: uint16(27448), + 23: uint16(27447), + 24: uint16(30428), + 25: uint16(27449), + 26: uint16(39150), + 27: uint16(27463), + 28: uint16(27459), + 29: uint16(27465), + 30: uint16(27472), + 31: uint16(27481), + 32: uint16(27476), + 33: uint16(27483), + 34: uint16(27487), + 35: uint16(27489), + 36: uint16(27512), + 37: uint16(27513), + 38: uint16(27519), + 39: uint16(27520), + 40: uint16(27524), + 41: uint16(27523), + 42: uint16(27533), + 43: uint16(27544), + 44: uint16(27541), + 45: uint16(27550), + 46: uint16(27556), + 47: uint16(27562), + 48: uint16(27563), + 49: uint16(27567), + 50: uint16(27570), + 51: uint16(27569), + 52: uint16(27571), + 53: uint16(27575), + 54: uint16(27580), + 55: uint16(27590), + 56: uint16(27595), + 57: uint16(27603), + 58: uint16(27615), + 59: uint16(27628), + 60: uint16(27627), + 61: uint16(27635), + 62: uint16(27631), + 63: uint16(40638), + 64: uint16(27656), + 65: uint16(27667), + 66: uint16(27668), + 67: uint16(27675), + 68: uint16(27684), + 69: uint16(27683), + 70: uint16(27742), + 71: uint16(27733), + 72: uint16(27746), + 73: uint16(27754), + 74: uint16(27778), + 75: uint16(27789), + 76: uint16(27802), + 77: uint16(27777), + 78: uint16(27803), + 79: uint16(27774), + 80: uint16(27752), + 81: uint16(27763), + 82: uint16(27794), + 83: uint16(27792), + 84: uint16(27844), + 85: uint16(27889), + 86: uint16(27859), + 87: uint16(27837), + 88: uint16(27863), + 89: uint16(27845), + 90: uint16(27869), + 91: uint16(27822), + 92: uint16(27825), + 93: uint16(27838), + }, + 61: { + 0: uint16(27834), + 1: uint16(27867), + 2: uint16(27887), + 3: uint16(27865), + 4: uint16(27882), + 5: uint16(27935), + 6: uint16(34893), + 7: uint16(27958), + 8: uint16(27947), + 9: uint16(27965), + 10: uint16(27960), + 11: uint16(27929), + 12: uint16(27957), + 13: uint16(27955), + 14: uint16(27922), + 15: uint16(27916), + 16: uint16(28003), + 17: uint16(28051), + 18: uint16(28004), + 19: uint16(27994), + 20: uint16(28025), + 21: uint16(27993), + 22: uint16(28046), + 23: uint16(28053), + 24: uint16(28644), + 25: uint16(28037), + 26: uint16(28153), + 27: uint16(28181), + 28: uint16(28170), + 29: uint16(28085), + 30: uint16(28103), + 31: uint16(28134), + 32: uint16(28088), + 33: uint16(28102), + 34: uint16(28140), + 35: uint16(28126), + 36: uint16(28108), + 37: uint16(28136), + 38: uint16(28114), + 39: uint16(28101), + 40: uint16(28154), + 41: uint16(28121), + 42: uint16(28132), + 43: uint16(28117), + 44: uint16(28138), + 45: uint16(28142), + 46: uint16(28205), + 47: uint16(28270), + 48: uint16(28206), + 49: uint16(28185), + 50: uint16(28274), + 51: uint16(28255), + 52: uint16(28222), + 53: uint16(28195), + 54: uint16(28267), + 55: uint16(28203), + 56: uint16(28278), + 57: uint16(28237), + 58: uint16(28191), + 59: uint16(28227), + 60: uint16(28218), + 61: uint16(28238), + 62: uint16(28196), + 63: uint16(28415), + 64: uint16(28189), + 65: uint16(28216), + 66: uint16(28290), + 67: uint16(28330), + 68: uint16(28312), + 69: uint16(28361), + 70: uint16(28343), + 71: uint16(28371), + 72: uint16(28349), + 73: uint16(28335), + 74: uint16(28356), + 75: uint16(28338), + 76: uint16(28372), + 77: uint16(28373), + 78: uint16(28303), + 79: uint16(28325), + 80: uint16(28354), + 81: uint16(28319), + 82: uint16(28481), + 83: uint16(28433), + 84: uint16(28748), + 85: uint16(28396), + 86: uint16(28408), + 87: uint16(28414), + 88: uint16(28479), + 89: uint16(28402), + 90: uint16(28465), + 91: uint16(28399), + 92: uint16(28466), + 93: uint16(28364), + }, + 62: { + 0: uint16(28478), + 1: uint16(28435), + 2: uint16(28407), + 3: uint16(28550), + 4: uint16(28538), + 5: uint16(28536), + 6: uint16(28545), + 7: uint16(28544), + 8: uint16(28527), + 9: uint16(28507), + 10: uint16(28659), + 11: uint16(28525), + 12: uint16(28546), + 13: uint16(28540), + 14: uint16(28504), + 15: uint16(28558), + 16: uint16(28561), + 17: uint16(28610), + 18: uint16(28518), + 19: uint16(28595), + 20: uint16(28579), + 21: uint16(28577), + 22: uint16(28580), + 23: uint16(28601), + 24: uint16(28614), + 25: uint16(28586), + 26: uint16(28639), + 27: uint16(28629), + 28: uint16(28652), + 29: uint16(28628), + 30: uint16(28632), + 31: uint16(28657), + 32: uint16(28654), + 33: uint16(28635), + 34: uint16(28681), + 35: uint16(28683), + 36: uint16(28666), + 37: uint16(28689), + 38: uint16(28673), + 39: uint16(28687), + 40: uint16(28670), + 41: uint16(28699), + 42: uint16(28698), + 43: uint16(28532), + 44: uint16(28701), + 45: uint16(28696), + 46: uint16(28703), + 47: uint16(28720), + 48: uint16(28734), + 49: uint16(28722), + 50: uint16(28753), + 51: uint16(28771), + 52: uint16(28825), + 53: uint16(28818), + 54: uint16(28847), + 55: uint16(28913), + 56: uint16(28844), + 57: uint16(28856), + 58: uint16(28851), + 59: uint16(28846), + 60: uint16(28895), + 61: uint16(28875), + 62: uint16(28893), + 63: uint16(28889), + 64: uint16(28937), + 65: uint16(28925), + 66: uint16(28956), + 67: uint16(28953), + 68: uint16(29029), + 69: uint16(29013), + 70: uint16(29064), + 71: uint16(29030), + 72: uint16(29026), + 73: uint16(29004), + 74: uint16(29014), + 75: uint16(29036), + 76: uint16(29071), + 77: uint16(29179), + 78: uint16(29060), + 79: uint16(29077), + 80: uint16(29096), + 81: uint16(29100), + 82: uint16(29143), + 83: uint16(29113), + 84: uint16(29118), + 85: uint16(29138), + 86: uint16(29129), + 87: uint16(29140), + 88: uint16(29134), + 89: uint16(29152), + 90: uint16(29164), + 91: uint16(29159), + 92: uint16(29173), + 93: uint16(29180), + }, + 63: { + 0: uint16(29177), + 1: uint16(29183), + 2: uint16(29197), + 3: uint16(29200), + 4: uint16(29211), + 5: uint16(29224), + 6: uint16(29229), + 7: uint16(29228), + 8: uint16(29232), + 9: uint16(29234), + 10: uint16(29243), + 11: uint16(29244), + 12: uint16(29247), + 13: uint16(29248), + 14: uint16(29254), + 15: uint16(29259), + 16: uint16(29272), + 17: uint16(29300), + 18: uint16(29310), + 19: uint16(29314), + 20: uint16(29313), + 21: uint16(29319), + 22: uint16(29330), + 23: uint16(29334), + 24: uint16(29346), + 25: uint16(29351), + 26: uint16(29369), + 27: uint16(29362), + 28: uint16(29379), + 29: uint16(29382), + 30: uint16(29380), + 31: uint16(29390), + 32: uint16(29394), + 33: uint16(29410), + 34: uint16(29408), + 35: uint16(29409), + 36: uint16(29433), + 37: uint16(29431), + 38: uint16(20495), + 39: uint16(29463), + 40: uint16(29450), + 41: uint16(29468), + 42: uint16(29462), + 43: uint16(29469), + 44: uint16(29492), + 45: uint16(29487), + 46: uint16(29481), + 47: uint16(29477), + 48: uint16(29502), + 49: uint16(29518), + 50: uint16(29519), + 51: uint16(40664), + 52: uint16(29527), + 53: uint16(29546), + 54: uint16(29544), + 55: uint16(29552), + 56: uint16(29560), + 57: uint16(29557), + 58: uint16(29563), + 59: uint16(29562), + 60: uint16(29640), + 61: uint16(29619), + 62: uint16(29646), + 63: uint16(29627), + 64: uint16(29632), + 65: uint16(29669), + 66: uint16(29678), + 67: uint16(29662), + 68: uint16(29858), + 69: uint16(29701), + 70: uint16(29807), + 71: uint16(29733), + 72: uint16(29688), + 73: uint16(29746), + 74: uint16(29754), + 75: uint16(29781), + 76: uint16(29759), + 77: uint16(29791), + 78: uint16(29785), + 79: uint16(29761), + 80: uint16(29788), + 81: uint16(29801), + 82: uint16(29808), + 83: uint16(29795), + 84: uint16(29802), + 85: uint16(29814), + 86: uint16(29822), + 87: uint16(29835), + 88: uint16(29854), + 89: uint16(29863), + 90: uint16(29898), + 91: uint16(29903), + 92: uint16(29908), + 93: uint16(29681), + }, + 64: { + 0: uint16(29920), + 1: uint16(29923), + 2: uint16(29927), + 3: uint16(29929), + 4: uint16(29934), + 5: uint16(29938), + 6: uint16(29936), + 7: uint16(29937), + 8: uint16(29944), + 9: uint16(29943), + 10: uint16(29956), + 11: uint16(29955), + 12: uint16(29957), + 13: uint16(29964), + 14: uint16(29966), + 15: uint16(29965), + 16: uint16(29973), + 17: uint16(29971), + 18: uint16(29982), + 19: uint16(29990), + 20: uint16(29996), + 21: uint16(30012), + 22: uint16(30020), + 23: uint16(30029), + 24: uint16(30026), + 25: uint16(30025), + 26: uint16(30043), + 27: uint16(30022), + 28: uint16(30042), + 29: uint16(30057), + 30: uint16(30052), + 31: uint16(30055), + 32: uint16(30059), + 33: uint16(30061), + 34: uint16(30072), + 35: uint16(30070), + 36: uint16(30086), + 37: uint16(30087), + 38: uint16(30068), + 39: uint16(30090), + 40: uint16(30089), + 41: uint16(30082), + 42: uint16(30100), + 43: uint16(30106), + 44: uint16(30109), + 45: uint16(30117), + 46: uint16(30115), + 47: uint16(30146), + 48: uint16(30131), + 49: uint16(30147), + 50: uint16(30133), + 51: uint16(30141), + 52: uint16(30136), + 53: uint16(30140), + 54: uint16(30129), + 55: uint16(30157), + 56: uint16(30154), + 57: uint16(30162), + 58: uint16(30169), + 59: uint16(30179), + 60: uint16(30174), + 61: uint16(30206), + 62: uint16(30207), + 63: uint16(30204), + 64: uint16(30209), + 65: uint16(30192), + 66: uint16(30202), + 67: uint16(30194), + 68: uint16(30195), + 69: uint16(30219), + 70: uint16(30221), + 71: uint16(30217), + 72: uint16(30239), + 73: uint16(30247), + 74: uint16(30240), + 75: uint16(30241), + 76: uint16(30242), + 77: uint16(30244), + 78: uint16(30260), + 79: uint16(30256), + 80: uint16(30267), + 81: uint16(30279), + 82: uint16(30280), + 83: uint16(30278), + 84: uint16(30300), + 85: uint16(30296), + 86: uint16(30305), + 87: uint16(30306), + 88: uint16(30312), + 89: uint16(30313), + 90: uint16(30314), + 91: uint16(30311), + 92: uint16(30316), + 93: uint16(30320), + }, + 65: { + 0: uint16(30322), + 1: uint16(30326), + 2: uint16(30328), + 3: uint16(30332), + 4: uint16(30336), + 5: uint16(30339), + 6: uint16(30344), + 7: uint16(30347), + 8: uint16(30350), + 9: uint16(30358), + 10: uint16(30355), + 11: uint16(30361), + 12: uint16(30362), + 13: uint16(30384), + 14: uint16(30388), + 15: uint16(30392), + 16: uint16(30393), + 17: uint16(30394), + 18: uint16(30402), + 19: uint16(30413), + 20: uint16(30422), + 21: uint16(30418), + 22: uint16(30430), + 23: uint16(30433), + 24: uint16(30437), + 25: uint16(30439), + 26: uint16(30442), + 27: uint16(34351), + 28: uint16(30459), + 29: uint16(30472), + 30: uint16(30471), + 31: uint16(30468), + 32: uint16(30505), + 33: uint16(30500), + 34: uint16(30494), + 35: uint16(30501), + 36: uint16(30502), + 37: uint16(30491), + 38: uint16(30519), + 39: uint16(30520), + 40: uint16(30535), + 41: uint16(30554), + 42: uint16(30568), + 43: uint16(30571), + 44: uint16(30555), + 45: uint16(30565), + 46: uint16(30591), + 47: uint16(30590), + 48: uint16(30585), + 49: uint16(30606), + 50: uint16(30603), + 51: uint16(30609), + 52: uint16(30624), + 53: uint16(30622), + 54: uint16(30640), + 55: uint16(30646), + 56: uint16(30649), + 57: uint16(30655), + 58: uint16(30652), + 59: uint16(30653), + 60: uint16(30651), + 61: uint16(30663), + 62: uint16(30669), + 63: uint16(30679), + 64: uint16(30682), + 65: uint16(30684), + 66: uint16(30691), + 67: uint16(30702), + 68: uint16(30716), + 69: uint16(30732), + 70: uint16(30738), + 71: uint16(31014), + 72: uint16(30752), + 73: uint16(31018), + 74: uint16(30789), + 75: uint16(30862), + 76: uint16(30836), + 77: uint16(30854), + 78: uint16(30844), + 79: uint16(30874), + 80: uint16(30860), + 81: uint16(30883), + 82: uint16(30901), + 83: uint16(30890), + 84: uint16(30895), + 85: uint16(30929), + 86: uint16(30918), + 87: uint16(30923), + 88: uint16(30932), + 89: uint16(30910), + 90: uint16(30908), + 91: uint16(30917), + 92: uint16(30922), + 93: uint16(30956), + }, + 66: { + 0: uint16(30951), + 1: uint16(30938), + 2: uint16(30973), + 3: uint16(30964), + 4: uint16(30983), + 5: uint16(30994), + 6: uint16(30993), + 7: uint16(31001), + 8: uint16(31020), + 9: uint16(31019), + 10: uint16(31040), + 11: uint16(31072), + 12: uint16(31063), + 13: uint16(31071), + 14: uint16(31066), + 15: uint16(31061), + 16: uint16(31059), + 17: uint16(31098), + 18: uint16(31103), + 19: uint16(31114), + 20: uint16(31133), + 21: uint16(31143), + 22: uint16(40779), + 23: uint16(31146), + 24: uint16(31150), + 25: uint16(31155), + 26: uint16(31161), + 27: uint16(31162), + 28: uint16(31177), + 29: uint16(31189), + 30: uint16(31207), + 31: uint16(31212), + 32: uint16(31201), + 33: uint16(31203), + 34: uint16(31240), + 35: uint16(31245), + 36: uint16(31256), + 37: uint16(31257), + 38: uint16(31264), + 39: uint16(31263), + 40: uint16(31104), + 41: uint16(31281), + 42: uint16(31291), + 43: uint16(31294), + 44: uint16(31287), + 45: uint16(31299), + 46: uint16(31319), + 47: uint16(31305), + 48: uint16(31329), + 49: uint16(31330), + 50: uint16(31337), + 51: uint16(40861), + 52: uint16(31344), + 53: uint16(31353), + 54: uint16(31357), + 55: uint16(31368), + 56: uint16(31383), + 57: uint16(31381), + 58: uint16(31384), + 59: uint16(31382), + 60: uint16(31401), + 61: uint16(31432), + 62: uint16(31408), + 63: uint16(31414), + 64: uint16(31429), + 65: uint16(31428), + 66: uint16(31423), + 67: uint16(36995), + 68: uint16(31431), + 69: uint16(31434), + 70: uint16(31437), + 71: uint16(31439), + 72: uint16(31445), + 73: uint16(31443), + 74: uint16(31449), + 75: uint16(31450), + 76: uint16(31453), + 77: uint16(31457), + 78: uint16(31458), + 79: uint16(31462), + 80: uint16(31469), + 81: uint16(31472), + 82: uint16(31490), + 83: uint16(31503), + 84: uint16(31498), + 85: uint16(31494), + 86: uint16(31539), + 87: uint16(31512), + 88: uint16(31513), + 89: uint16(31518), + 90: uint16(31541), + 91: uint16(31528), + 92: uint16(31542), + 93: uint16(31568), + }, + 67: { + 0: uint16(31610), + 1: uint16(31492), + 2: uint16(31565), + 3: uint16(31499), + 4: uint16(31564), + 5: uint16(31557), + 6: uint16(31605), + 7: uint16(31589), + 8: uint16(31604), + 9: uint16(31591), + 10: uint16(31600), + 11: uint16(31601), + 12: uint16(31596), + 13: uint16(31598), + 14: uint16(31645), + 15: uint16(31640), + 16: uint16(31647), + 17: uint16(31629), + 18: uint16(31644), + 19: uint16(31642), + 20: uint16(31627), + 21: uint16(31634), + 22: uint16(31631), + 23: uint16(31581), + 24: uint16(31641), + 25: uint16(31691), + 26: uint16(31681), + 27: uint16(31692), + 28: uint16(31695), + 29: uint16(31668), + 30: uint16(31686), + 31: uint16(31709), + 32: uint16(31721), + 33: uint16(31761), + 34: uint16(31764), + 35: uint16(31718), + 36: uint16(31717), + 37: uint16(31840), + 38: uint16(31744), + 39: uint16(31751), + 40: uint16(31763), + 41: uint16(31731), + 42: uint16(31735), + 43: uint16(31767), + 44: uint16(31757), + 45: uint16(31734), + 46: uint16(31779), + 47: uint16(31783), + 48: uint16(31786), + 49: uint16(31775), + 50: uint16(31799), + 51: uint16(31787), + 52: uint16(31805), + 53: uint16(31820), + 54: uint16(31811), + 55: uint16(31828), + 56: uint16(31823), + 57: uint16(31808), + 58: uint16(31824), + 59: uint16(31832), + 60: uint16(31839), + 61: uint16(31844), + 62: uint16(31830), + 63: uint16(31845), + 64: uint16(31852), + 65: uint16(31861), + 66: uint16(31875), + 67: uint16(31888), + 68: uint16(31908), + 69: uint16(31917), + 70: uint16(31906), + 71: uint16(31915), + 72: uint16(31905), + 73: uint16(31912), + 74: uint16(31923), + 75: uint16(31922), + 76: uint16(31921), + 77: uint16(31918), + 78: uint16(31929), + 79: uint16(31933), + 80: uint16(31936), + 81: uint16(31941), + 82: uint16(31938), + 83: uint16(31960), + 84: uint16(31954), + 85: uint16(31964), + 86: uint16(31970), + 87: uint16(39739), + 88: uint16(31983), + 89: uint16(31986), + 90: uint16(31988), + 91: uint16(31990), + 92: uint16(31994), + 93: uint16(32006), + }, + 68: { + 0: uint16(32002), + 1: uint16(32028), + 2: uint16(32021), + 3: uint16(32010), + 4: uint16(32069), + 5: uint16(32075), + 6: uint16(32046), + 7: uint16(32050), + 8: uint16(32063), + 9: uint16(32053), + 10: uint16(32070), + 11: uint16(32115), + 12: uint16(32086), + 13: uint16(32078), + 14: uint16(32114), + 15: uint16(32104), + 16: uint16(32110), + 17: uint16(32079), + 18: uint16(32099), + 19: uint16(32147), + 20: uint16(32137), + 21: uint16(32091), + 22: uint16(32143), + 23: uint16(32125), + 24: uint16(32155), + 25: uint16(32186), + 26: uint16(32174), + 27: uint16(32163), + 28: uint16(32181), + 29: uint16(32199), + 30: uint16(32189), + 31: uint16(32171), + 32: uint16(32317), + 33: uint16(32162), + 34: uint16(32175), + 35: uint16(32220), + 36: uint16(32184), + 37: uint16(32159), + 38: uint16(32176), + 39: uint16(32216), + 40: uint16(32221), + 41: uint16(32228), + 42: uint16(32222), + 43: uint16(32251), + 44: uint16(32242), + 45: uint16(32225), + 46: uint16(32261), + 47: uint16(32266), + 48: uint16(32291), + 49: uint16(32289), + 50: uint16(32274), + 51: uint16(32305), + 52: uint16(32287), + 53: uint16(32265), + 54: uint16(32267), + 55: uint16(32290), + 56: uint16(32326), + 57: uint16(32358), + 58: uint16(32315), + 59: uint16(32309), + 60: uint16(32313), + 61: uint16(32323), + 62: uint16(32311), + 63: uint16(32306), + 64: uint16(32314), + 65: uint16(32359), + 66: uint16(32349), + 67: uint16(32342), + 68: uint16(32350), + 69: uint16(32345), + 70: uint16(32346), + 71: uint16(32377), + 72: uint16(32362), + 73: uint16(32361), + 74: uint16(32380), + 75: uint16(32379), + 76: uint16(32387), + 77: uint16(32213), + 78: uint16(32381), + 79: uint16(36782), + 80: uint16(32383), + 81: uint16(32392), + 82: uint16(32393), + 83: uint16(32396), + 84: uint16(32402), + 85: uint16(32400), + 86: uint16(32403), + 87: uint16(32404), + 88: uint16(32406), + 89: uint16(32398), + 90: uint16(32411), + 91: uint16(32412), + 92: uint16(32568), + 93: uint16(32570), + }, + 69: { + 0: uint16(32581), + 1: uint16(32588), + 2: uint16(32589), + 3: uint16(32590), + 4: uint16(32592), + 5: uint16(32593), + 6: uint16(32597), + 7: uint16(32596), + 8: uint16(32600), + 9: uint16(32607), + 10: uint16(32608), + 11: uint16(32616), + 12: uint16(32617), + 13: uint16(32615), + 14: uint16(32632), + 15: uint16(32642), + 16: uint16(32646), + 17: uint16(32643), + 18: uint16(32648), + 19: uint16(32647), + 20: uint16(32652), + 21: uint16(32660), + 22: uint16(32670), + 23: uint16(32669), + 24: uint16(32666), + 25: uint16(32675), + 26: uint16(32687), + 27: uint16(32690), + 28: uint16(32697), + 29: uint16(32686), + 30: uint16(32694), + 31: uint16(32696), + 32: uint16(35697), + 33: uint16(32709), + 34: uint16(32710), + 35: uint16(32714), + 36: uint16(32725), + 37: uint16(32724), + 38: uint16(32737), + 39: uint16(32742), + 40: uint16(32745), + 41: uint16(32755), + 42: uint16(32761), + 43: uint16(39132), + 44: uint16(32774), + 45: uint16(32772), + 46: uint16(32779), + 47: uint16(32786), + 48: uint16(32792), + 49: uint16(32793), + 50: uint16(32796), + 51: uint16(32801), + 52: uint16(32808), + 53: uint16(32831), + 54: uint16(32827), + 55: uint16(32842), + 56: uint16(32838), + 57: uint16(32850), + 58: uint16(32856), + 59: uint16(32858), + 60: uint16(32863), + 61: uint16(32866), + 62: uint16(32872), + 63: uint16(32883), + 64: uint16(32882), + 65: uint16(32880), + 66: uint16(32886), + 67: uint16(32889), + 68: uint16(32893), + 69: uint16(32895), + 70: uint16(32900), + 71: uint16(32902), + 72: uint16(32901), + 73: uint16(32923), + 74: uint16(32915), + 75: uint16(32922), + 76: uint16(32941), + 77: uint16(20880), + 78: uint16(32940), + 79: uint16(32987), + 80: uint16(32997), + 81: uint16(32985), + 82: uint16(32989), + 83: uint16(32964), + 84: uint16(32986), + 85: uint16(32982), + 86: uint16(33033), + 87: uint16(33007), + 88: uint16(33009), + 89: uint16(33051), + 90: uint16(33065), + 91: uint16(33059), + 92: uint16(33071), + 93: uint16(33099), + }, + 70: { + 0: uint16(38539), + 1: uint16(33094), + 2: uint16(33086), + 3: uint16(33107), + 4: uint16(33105), + 5: uint16(33020), + 6: uint16(33137), + 7: uint16(33134), + 8: uint16(33125), + 9: uint16(33126), + 10: uint16(33140), + 11: uint16(33155), + 12: uint16(33160), + 13: uint16(33162), + 14: uint16(33152), + 15: uint16(33154), + 16: uint16(33184), + 17: uint16(33173), + 18: uint16(33188), + 19: uint16(33187), + 20: uint16(33119), + 21: uint16(33171), + 22: uint16(33193), + 23: uint16(33200), + 24: uint16(33205), + 25: uint16(33214), + 26: uint16(33208), + 27: uint16(33213), + 28: uint16(33216), + 29: uint16(33218), + 30: uint16(33210), + 31: uint16(33225), + 32: uint16(33229), + 33: uint16(33233), + 34: uint16(33241), + 35: uint16(33240), + 36: uint16(33224), + 37: uint16(33242), + 38: uint16(33247), + 39: uint16(33248), + 40: uint16(33255), + 41: uint16(33274), + 42: uint16(33275), + 43: uint16(33278), + 44: uint16(33281), + 45: uint16(33282), + 46: uint16(33285), + 47: uint16(33287), + 48: uint16(33290), + 49: uint16(33293), + 50: uint16(33296), + 51: uint16(33302), + 52: uint16(33321), + 53: uint16(33323), + 54: uint16(33336), + 55: uint16(33331), + 56: uint16(33344), + 57: uint16(33369), + 58: uint16(33368), + 59: uint16(33373), + 60: uint16(33370), + 61: uint16(33375), + 62: uint16(33380), + 63: uint16(33378), + 64: uint16(33384), + 65: uint16(33386), + 66: uint16(33387), + 67: uint16(33326), + 68: uint16(33393), + 69: uint16(33399), + 70: uint16(33400), + 71: uint16(33406), + 72: uint16(33421), + 73: uint16(33426), + 74: uint16(33451), + 75: uint16(33439), + 76: uint16(33467), + 77: uint16(33452), + 78: uint16(33505), + 79: uint16(33507), + 80: uint16(33503), + 81: uint16(33490), + 82: uint16(33524), + 83: uint16(33523), + 84: uint16(33530), + 85: uint16(33683), + 86: uint16(33539), + 87: uint16(33531), + 88: uint16(33529), + 89: uint16(33502), + 90: uint16(33542), + 91: uint16(33500), + 92: uint16(33545), + 93: uint16(33497), + }, + 71: { + 0: uint16(33589), + 1: uint16(33588), + 2: uint16(33558), + 3: uint16(33586), + 4: uint16(33585), + 5: uint16(33600), + 6: uint16(33593), + 7: uint16(33616), + 8: uint16(33605), + 9: uint16(33583), + 10: uint16(33579), + 11: uint16(33559), + 12: uint16(33560), + 13: uint16(33669), + 14: uint16(33690), + 15: uint16(33706), + 16: uint16(33695), + 17: uint16(33698), + 18: uint16(33686), + 19: uint16(33571), + 20: uint16(33678), + 21: uint16(33671), + 22: uint16(33674), + 23: uint16(33660), + 24: uint16(33717), + 25: uint16(33651), + 26: uint16(33653), + 27: uint16(33696), + 28: uint16(33673), + 29: uint16(33704), + 30: uint16(33780), + 31: uint16(33811), + 32: uint16(33771), + 33: uint16(33742), + 34: uint16(33789), + 35: uint16(33795), + 36: uint16(33752), + 37: uint16(33803), + 38: uint16(33729), + 39: uint16(33783), + 40: uint16(33799), + 41: uint16(33760), + 42: uint16(33778), + 43: uint16(33805), + 44: uint16(33826), + 45: uint16(33824), + 46: uint16(33725), + 47: uint16(33848), + 48: uint16(34054), + 49: uint16(33787), + 50: uint16(33901), + 51: uint16(33834), + 52: uint16(33852), + 53: uint16(34138), + 54: uint16(33924), + 55: uint16(33911), + 56: uint16(33899), + 57: uint16(33965), + 58: uint16(33902), + 59: uint16(33922), + 60: uint16(33897), + 61: uint16(33862), + 62: uint16(33836), + 63: uint16(33903), + 64: uint16(33913), + 65: uint16(33845), + 66: uint16(33994), + 67: uint16(33890), + 68: uint16(33977), + 69: uint16(33983), + 70: uint16(33951), + 71: uint16(34009), + 72: uint16(33997), + 73: uint16(33979), + 74: uint16(34010), + 75: uint16(34000), + 76: uint16(33985), + 77: uint16(33990), + 78: uint16(34006), + 79: uint16(33953), + 80: uint16(34081), + 81: uint16(34047), + 82: uint16(34036), + 83: uint16(34071), + 84: uint16(34072), + 85: uint16(34092), + 86: uint16(34079), + 87: uint16(34069), + 88: uint16(34068), + 89: uint16(34044), + 90: uint16(34112), + 91: uint16(34147), + 92: uint16(34136), + 93: uint16(34120), + }, + 72: { + 0: uint16(34113), + 1: uint16(34306), + 2: uint16(34123), + 3: uint16(34133), + 4: uint16(34176), + 5: uint16(34212), + 6: uint16(34184), + 7: uint16(34193), + 8: uint16(34186), + 9: uint16(34216), + 10: uint16(34157), + 11: uint16(34196), + 12: uint16(34203), + 13: uint16(34282), + 14: uint16(34183), + 15: uint16(34204), + 16: uint16(34167), + 17: uint16(34174), + 18: uint16(34192), + 19: uint16(34249), + 20: uint16(34234), + 21: uint16(34255), + 22: uint16(34233), + 23: uint16(34256), + 24: uint16(34261), + 25: uint16(34269), + 26: uint16(34277), + 27: uint16(34268), + 28: uint16(34297), + 29: uint16(34314), + 30: uint16(34323), + 31: uint16(34315), + 32: uint16(34302), + 33: uint16(34298), + 34: uint16(34310), + 35: uint16(34338), + 36: uint16(34330), + 37: uint16(34352), + 38: uint16(34367), + 39: uint16(34381), + 40: uint16(20053), + 41: uint16(34388), + 42: uint16(34399), + 43: uint16(34407), + 44: uint16(34417), + 45: uint16(34451), + 46: uint16(34467), + 47: uint16(34473), + 48: uint16(34474), + 49: uint16(34443), + 50: uint16(34444), + 51: uint16(34486), + 52: uint16(34479), + 53: uint16(34500), + 54: uint16(34502), + 55: uint16(34480), + 56: uint16(34505), + 57: uint16(34851), + 58: uint16(34475), + 59: uint16(34516), + 60: uint16(34526), + 61: uint16(34537), + 62: uint16(34540), + 63: uint16(34527), + 64: uint16(34523), + 65: uint16(34543), + 66: uint16(34578), + 67: uint16(34566), + 68: uint16(34568), + 69: uint16(34560), + 70: uint16(34563), + 71: uint16(34555), + 72: uint16(34577), + 73: uint16(34569), + 74: uint16(34573), + 75: uint16(34553), + 76: uint16(34570), + 77: uint16(34612), + 78: uint16(34623), + 79: uint16(34615), + 80: uint16(34619), + 81: uint16(34597), + 82: uint16(34601), + 83: uint16(34586), + 84: uint16(34656), + 85: uint16(34655), + 86: uint16(34680), + 87: uint16(34636), + 88: uint16(34638), + 89: uint16(34676), + 90: uint16(34647), + 91: uint16(34664), + 92: uint16(34670), + 93: uint16(34649), + }, + 73: { + 0: uint16(34643), + 1: uint16(34659), + 2: uint16(34666), + 3: uint16(34821), + 4: uint16(34722), + 5: uint16(34719), + 6: uint16(34690), + 7: uint16(34735), + 8: uint16(34763), + 9: uint16(34749), + 10: uint16(34752), + 11: uint16(34768), + 12: uint16(38614), + 13: uint16(34731), + 14: uint16(34756), + 15: uint16(34739), + 16: uint16(34759), + 17: uint16(34758), + 18: uint16(34747), + 19: uint16(34799), + 20: uint16(34802), + 21: uint16(34784), + 22: uint16(34831), + 23: uint16(34829), + 24: uint16(34814), + 25: uint16(34806), + 26: uint16(34807), + 27: uint16(34830), + 28: uint16(34770), + 29: uint16(34833), + 30: uint16(34838), + 31: uint16(34837), + 32: uint16(34850), + 33: uint16(34849), + 34: uint16(34865), + 35: uint16(34870), + 36: uint16(34873), + 37: uint16(34855), + 38: uint16(34875), + 39: uint16(34884), + 40: uint16(34882), + 41: uint16(34898), + 42: uint16(34905), + 43: uint16(34910), + 44: uint16(34914), + 45: uint16(34923), + 46: uint16(34945), + 47: uint16(34942), + 48: uint16(34974), + 49: uint16(34933), + 50: uint16(34941), + 51: uint16(34997), + 52: uint16(34930), + 53: uint16(34946), + 54: uint16(34967), + 55: uint16(34962), + 56: uint16(34990), + 57: uint16(34969), + 58: uint16(34978), + 59: uint16(34957), + 60: uint16(34980), + 61: uint16(34992), + 62: uint16(35007), + 63: uint16(34993), + 64: uint16(35011), + 65: uint16(35012), + 66: uint16(35028), + 67: uint16(35032), + 68: uint16(35033), + 69: uint16(35037), + 70: uint16(35065), + 71: uint16(35074), + 72: uint16(35068), + 73: uint16(35060), + 74: uint16(35048), + 75: uint16(35058), + 76: uint16(35076), + 77: uint16(35084), + 78: uint16(35082), + 79: uint16(35091), + 80: uint16(35139), + 81: uint16(35102), + 82: uint16(35109), + 83: uint16(35114), + 84: uint16(35115), + 85: uint16(35137), + 86: uint16(35140), + 87: uint16(35131), + 88: uint16(35126), + 89: uint16(35128), + 90: uint16(35148), + 91: uint16(35101), + 92: uint16(35168), + 93: uint16(35166), + }, + 74: { + 0: uint16(35174), + 1: uint16(35172), + 2: uint16(35181), + 3: uint16(35178), + 4: uint16(35183), + 5: uint16(35188), + 6: uint16(35191), + 7: uint16(35198), + 8: uint16(35203), + 9: uint16(35208), + 10: uint16(35210), + 11: uint16(35219), + 12: uint16(35224), + 13: uint16(35233), + 14: uint16(35241), + 15: uint16(35238), + 16: uint16(35244), + 17: uint16(35247), + 18: uint16(35250), + 19: uint16(35258), + 20: uint16(35261), + 21: uint16(35263), + 22: uint16(35264), + 23: uint16(35290), + 24: uint16(35292), + 25: uint16(35293), + 26: uint16(35303), + 27: uint16(35316), + 28: uint16(35320), + 29: uint16(35331), + 30: uint16(35350), + 31: uint16(35344), + 32: uint16(35340), + 33: uint16(35355), + 34: uint16(35357), + 35: uint16(35365), + 36: uint16(35382), + 37: uint16(35393), + 38: uint16(35419), + 39: uint16(35410), + 40: uint16(35398), + 41: uint16(35400), + 42: uint16(35452), + 43: uint16(35437), + 44: uint16(35436), + 45: uint16(35426), + 46: uint16(35461), + 47: uint16(35458), + 48: uint16(35460), + 49: uint16(35496), + 50: uint16(35489), + 51: uint16(35473), + 52: uint16(35493), + 53: uint16(35494), + 54: uint16(35482), + 55: uint16(35491), + 56: uint16(35524), + 57: uint16(35533), + 58: uint16(35522), + 59: uint16(35546), + 60: uint16(35563), + 61: uint16(35571), + 62: uint16(35559), + 63: uint16(35556), + 64: uint16(35569), + 65: uint16(35604), + 66: uint16(35552), + 67: uint16(35554), + 68: uint16(35575), + 69: uint16(35550), + 70: uint16(35547), + 71: uint16(35596), + 72: uint16(35591), + 73: uint16(35610), + 74: uint16(35553), + 75: uint16(35606), + 76: uint16(35600), + 77: uint16(35607), + 78: uint16(35616), + 79: uint16(35635), + 80: uint16(38827), + 81: uint16(35622), + 82: uint16(35627), + 83: uint16(35646), + 84: uint16(35624), + 85: uint16(35649), + 86: uint16(35660), + 87: uint16(35663), + 88: uint16(35662), + 89: uint16(35657), + 90: uint16(35670), + 91: uint16(35675), + 92: uint16(35674), + 93: uint16(35691), + }, + 75: { + 0: uint16(35679), + 1: uint16(35692), + 2: uint16(35695), + 3: uint16(35700), + 4: uint16(35709), + 5: uint16(35712), + 6: uint16(35724), + 7: uint16(35726), + 8: uint16(35730), + 9: uint16(35731), + 10: uint16(35734), + 11: uint16(35737), + 12: uint16(35738), + 13: uint16(35898), + 14: uint16(35905), + 15: uint16(35903), + 16: uint16(35912), + 17: uint16(35916), + 18: uint16(35918), + 19: uint16(35920), + 20: uint16(35925), + 21: uint16(35938), + 22: uint16(35948), + 23: uint16(35960), + 24: uint16(35962), + 25: uint16(35970), + 26: uint16(35977), + 27: uint16(35973), + 28: uint16(35978), + 29: uint16(35981), + 30: uint16(35982), + 31: uint16(35988), + 32: uint16(35964), + 33: uint16(35992), + 34: uint16(25117), + 35: uint16(36013), + 36: uint16(36010), + 37: uint16(36029), + 38: uint16(36018), + 39: uint16(36019), + 40: uint16(36014), + 41: uint16(36022), + 42: uint16(36040), + 43: uint16(36033), + 44: uint16(36068), + 45: uint16(36067), + 46: uint16(36058), + 47: uint16(36093), + 48: uint16(36090), + 49: uint16(36091), + 50: uint16(36100), + 51: uint16(36101), + 52: uint16(36106), + 53: uint16(36103), + 54: uint16(36111), + 55: uint16(36109), + 56: uint16(36112), + 57: uint16(40782), + 58: uint16(36115), + 59: uint16(36045), + 60: uint16(36116), + 61: uint16(36118), + 62: uint16(36199), + 63: uint16(36205), + 64: uint16(36209), + 65: uint16(36211), + 66: uint16(36225), + 67: uint16(36249), + 68: uint16(36290), + 69: uint16(36286), + 70: uint16(36282), + 71: uint16(36303), + 72: uint16(36314), + 73: uint16(36310), + 74: uint16(36300), + 75: uint16(36315), + 76: uint16(36299), + 77: uint16(36330), + 78: uint16(36331), + 79: uint16(36319), + 80: uint16(36323), + 81: uint16(36348), + 82: uint16(36360), + 83: uint16(36361), + 84: uint16(36351), + 85: uint16(36381), + 86: uint16(36382), + 87: uint16(36368), + 88: uint16(36383), + 89: uint16(36418), + 90: uint16(36405), + 91: uint16(36400), + 92: uint16(36404), + 93: uint16(36426), + }, + 76: { + 0: uint16(36423), + 1: uint16(36425), + 2: uint16(36428), + 3: uint16(36432), + 4: uint16(36424), + 5: uint16(36441), + 6: uint16(36452), + 7: uint16(36448), + 8: uint16(36394), + 9: uint16(36451), + 10: uint16(36437), + 11: uint16(36470), + 12: uint16(36466), + 13: uint16(36476), + 14: uint16(36481), + 15: uint16(36487), + 16: uint16(36485), + 17: uint16(36484), + 18: uint16(36491), + 19: uint16(36490), + 20: uint16(36499), + 21: uint16(36497), + 22: uint16(36500), + 23: uint16(36505), + 24: uint16(36522), + 25: uint16(36513), + 26: uint16(36524), + 27: uint16(36528), + 28: uint16(36550), + 29: uint16(36529), + 30: uint16(36542), + 31: uint16(36549), + 32: uint16(36552), + 33: uint16(36555), + 34: uint16(36571), + 35: uint16(36579), + 36: uint16(36604), + 37: uint16(36603), + 38: uint16(36587), + 39: uint16(36606), + 40: uint16(36618), + 41: uint16(36613), + 42: uint16(36629), + 43: uint16(36626), + 44: uint16(36633), + 45: uint16(36627), + 46: uint16(36636), + 47: uint16(36639), + 48: uint16(36635), + 49: uint16(36620), + 50: uint16(36646), + 51: uint16(36659), + 52: uint16(36667), + 53: uint16(36665), + 54: uint16(36677), + 55: uint16(36674), + 56: uint16(36670), + 57: uint16(36684), + 58: uint16(36681), + 59: uint16(36678), + 60: uint16(36686), + 61: uint16(36695), + 62: uint16(36700), + 63: uint16(36706), + 64: uint16(36707), + 65: uint16(36708), + 66: uint16(36764), + 67: uint16(36767), + 68: uint16(36771), + 69: uint16(36781), + 70: uint16(36783), + 71: uint16(36791), + 72: uint16(36826), + 73: uint16(36837), + 74: uint16(36834), + 75: uint16(36842), + 76: uint16(36847), + 77: uint16(36999), + 78: uint16(36852), + 79: uint16(36869), + 80: uint16(36857), + 81: uint16(36858), + 82: uint16(36881), + 83: uint16(36885), + 84: uint16(36897), + 85: uint16(36877), + 86: uint16(36894), + 87: uint16(36886), + 88: uint16(36875), + 89: uint16(36903), + 90: uint16(36918), + 91: uint16(36917), + 92: uint16(36921), + 93: uint16(36856), + }, + 77: { + 0: uint16(36943), + 1: uint16(36944), + 2: uint16(36945), + 3: uint16(36946), + 4: uint16(36878), + 5: uint16(36937), + 6: uint16(36926), + 7: uint16(36950), + 8: uint16(36952), + 9: uint16(36958), + 10: uint16(36968), + 11: uint16(36975), + 12: uint16(36982), + 13: uint16(38568), + 14: uint16(36978), + 15: uint16(36994), + 16: uint16(36989), + 17: uint16(36993), + 18: uint16(36992), + 19: uint16(37002), + 20: uint16(37001), + 21: uint16(37007), + 22: uint16(37032), + 23: uint16(37039), + 24: uint16(37041), + 25: uint16(37045), + 26: uint16(37090), + 27: uint16(37092), + 28: uint16(25160), + 29: uint16(37083), + 30: uint16(37122), + 31: uint16(37138), + 32: uint16(37145), + 33: uint16(37170), + 34: uint16(37168), + 35: uint16(37194), + 36: uint16(37206), + 37: uint16(37208), + 38: uint16(37219), + 39: uint16(37221), + 40: uint16(37225), + 41: uint16(37235), + 42: uint16(37234), + 43: uint16(37259), + 44: uint16(37257), + 45: uint16(37250), + 46: uint16(37282), + 47: uint16(37291), + 48: uint16(37295), + 49: uint16(37290), + 50: uint16(37301), + 51: uint16(37300), + 52: uint16(37306), + 53: uint16(37312), + 54: uint16(37313), + 55: uint16(37321), + 56: uint16(37323), + 57: uint16(37328), + 58: uint16(37334), + 59: uint16(37343), + 60: uint16(37345), + 61: uint16(37339), + 62: uint16(37372), + 63: uint16(37365), + 64: uint16(37366), + 65: uint16(37406), + 66: uint16(37375), + 67: uint16(37396), + 68: uint16(37420), + 69: uint16(37397), + 70: uint16(37393), + 71: uint16(37470), + 72: uint16(37463), + 73: uint16(37445), + 74: uint16(37449), + 75: uint16(37476), + 76: uint16(37448), + 77: uint16(37525), + 78: uint16(37439), + 79: uint16(37451), + 80: uint16(37456), + 81: uint16(37532), + 82: uint16(37526), + 83: uint16(37523), + 84: uint16(37531), + 85: uint16(37466), + 86: uint16(37583), + 87: uint16(37561), + 88: uint16(37559), + 89: uint16(37609), + 90: uint16(37647), + 91: uint16(37626), + 92: uint16(37700), + 93: uint16(37678), + }, + 78: { + 0: uint16(37657), + 1: uint16(37666), + 2: uint16(37658), + 3: uint16(37667), + 4: uint16(37690), + 5: uint16(37685), + 6: uint16(37691), + 7: uint16(37724), + 8: uint16(37728), + 9: uint16(37756), + 10: uint16(37742), + 11: uint16(37718), + 12: uint16(37808), + 13: uint16(37804), + 14: uint16(37805), + 15: uint16(37780), + 16: uint16(37817), + 17: uint16(37846), + 18: uint16(37847), + 19: uint16(37864), + 20: uint16(37861), + 21: uint16(37848), + 22: uint16(37827), + 23: uint16(37853), + 24: uint16(37840), + 25: uint16(37832), + 26: uint16(37860), + 27: uint16(37914), + 28: uint16(37908), + 29: uint16(37907), + 30: uint16(37891), + 31: uint16(37895), + 32: uint16(37904), + 33: uint16(37942), + 34: uint16(37931), + 35: uint16(37941), + 36: uint16(37921), + 37: uint16(37946), + 38: uint16(37953), + 39: uint16(37970), + 40: uint16(37956), + 41: uint16(37979), + 42: uint16(37984), + 43: uint16(37986), + 44: uint16(37982), + 45: uint16(37994), + 46: uint16(37417), + 47: uint16(38000), + 48: uint16(38005), + 49: uint16(38007), + 50: uint16(38013), + 51: uint16(37978), + 52: uint16(38012), + 53: uint16(38014), + 54: uint16(38017), + 55: uint16(38015), + 56: uint16(38274), + 57: uint16(38279), + 58: uint16(38282), + 59: uint16(38292), + 60: uint16(38294), + 61: uint16(38296), + 62: uint16(38297), + 63: uint16(38304), + 64: uint16(38312), + 65: uint16(38311), + 66: uint16(38317), + 67: uint16(38332), + 68: uint16(38331), + 69: uint16(38329), + 70: uint16(38334), + 71: uint16(38346), + 72: uint16(28662), + 73: uint16(38339), + 74: uint16(38349), + 75: uint16(38348), + 76: uint16(38357), + 77: uint16(38356), + 78: uint16(38358), + 79: uint16(38364), + 80: uint16(38369), + 81: uint16(38373), + 82: uint16(38370), + 83: uint16(38433), + 84: uint16(38440), + 85: uint16(38446), + 86: uint16(38447), + 87: uint16(38466), + 88: uint16(38476), + 89: uint16(38479), + 90: uint16(38475), + 91: uint16(38519), + 92: uint16(38492), + 93: uint16(38494), + }, + 79: { + 0: uint16(38493), + 1: uint16(38495), + 2: uint16(38502), + 3: uint16(38514), + 4: uint16(38508), + 5: uint16(38541), + 6: uint16(38552), + 7: uint16(38549), + 8: uint16(38551), + 9: uint16(38570), + 10: uint16(38567), + 11: uint16(38577), + 12: uint16(38578), + 13: uint16(38576), + 14: uint16(38580), + 15: uint16(38582), + 16: uint16(38584), + 17: uint16(38585), + 18: uint16(38606), + 19: uint16(38603), + 20: uint16(38601), + 21: uint16(38605), + 22: uint16(35149), + 23: uint16(38620), + 24: uint16(38669), + 25: uint16(38613), + 26: uint16(38649), + 27: uint16(38660), + 28: uint16(38662), + 29: uint16(38664), + 30: uint16(38675), + 31: uint16(38670), + 32: uint16(38673), + 33: uint16(38671), + 34: uint16(38678), + 35: uint16(38681), + 36: uint16(38692), + 37: uint16(38698), + 38: uint16(38704), + 39: uint16(38713), + 40: uint16(38717), + 41: uint16(38718), + 42: uint16(38724), + 43: uint16(38726), + 44: uint16(38728), + 45: uint16(38722), + 46: uint16(38729), + 47: uint16(38748), + 48: uint16(38752), + 49: uint16(38756), + 50: uint16(38758), + 51: uint16(38760), + 52: uint16(21202), + 53: uint16(38763), + 54: uint16(38769), + 55: uint16(38777), + 56: uint16(38789), + 57: uint16(38780), + 58: uint16(38785), + 59: uint16(38778), + 60: uint16(38790), + 61: uint16(38795), + 62: uint16(38799), + 63: uint16(38800), + 64: uint16(38812), + 65: uint16(38824), + 66: uint16(38822), + 67: uint16(38819), + 68: uint16(38835), + 69: uint16(38836), + 70: uint16(38851), + 71: uint16(38854), + 72: uint16(38856), + 73: uint16(38859), + 74: uint16(38876), + 75: uint16(38893), + 76: uint16(40783), + 77: uint16(38898), + 78: uint16(31455), + 79: uint16(38902), + 80: uint16(38901), + 81: uint16(38927), + 82: uint16(38924), + 83: uint16(38968), + 84: uint16(38948), + 85: uint16(38945), + 86: uint16(38967), + 87: uint16(38973), + 88: uint16(38982), + 89: uint16(38991), + 90: uint16(38987), + 91: uint16(39019), + 92: uint16(39023), + 93: uint16(39024), + }, + 80: { + 0: uint16(39025), + 1: uint16(39028), + 2: uint16(39027), + 3: uint16(39082), + 4: uint16(39087), + 5: uint16(39089), + 6: uint16(39094), + 7: uint16(39108), + 8: uint16(39107), + 9: uint16(39110), + 10: uint16(39145), + 11: uint16(39147), + 12: uint16(39171), + 13: uint16(39177), + 14: uint16(39186), + 15: uint16(39188), + 16: uint16(39192), + 17: uint16(39201), + 18: uint16(39197), + 19: uint16(39198), + 20: uint16(39204), + 21: uint16(39200), + 22: uint16(39212), + 23: uint16(39214), + 24: uint16(39229), + 25: uint16(39230), + 26: uint16(39234), + 27: uint16(39241), + 28: uint16(39237), + 29: uint16(39248), + 30: uint16(39243), + 31: uint16(39249), + 32: uint16(39250), + 33: uint16(39244), + 34: uint16(39253), + 35: uint16(39319), + 36: uint16(39320), + 37: uint16(39333), + 38: uint16(39341), + 39: uint16(39342), + 40: uint16(39356), + 41: uint16(39391), + 42: uint16(39387), + 43: uint16(39389), + 44: uint16(39384), + 45: uint16(39377), + 46: uint16(39405), + 47: uint16(39406), + 48: uint16(39409), + 49: uint16(39410), + 50: uint16(39419), + 51: uint16(39416), + 52: uint16(39425), + 53: uint16(39439), + 54: uint16(39429), + 55: uint16(39394), + 56: uint16(39449), + 57: uint16(39467), + 58: uint16(39479), + 59: uint16(39493), + 60: uint16(39490), + 61: uint16(39488), + 62: uint16(39491), + 63: uint16(39486), + 64: uint16(39509), + 65: uint16(39501), + 66: uint16(39515), + 67: uint16(39511), + 68: uint16(39519), + 69: uint16(39522), + 70: uint16(39525), + 71: uint16(39524), + 72: uint16(39529), + 73: uint16(39531), + 74: uint16(39530), + 75: uint16(39597), + 76: uint16(39600), + 77: uint16(39612), + 78: uint16(39616), + 79: uint16(39631), + 80: uint16(39633), + 81: uint16(39635), + 82: uint16(39636), + 83: uint16(39646), + 84: uint16(39647), + 85: uint16(39650), + 86: uint16(39651), + 87: uint16(39654), + 88: uint16(39663), + 89: uint16(39659), + 90: uint16(39662), + 91: uint16(39668), + 92: uint16(39665), + 93: uint16(39671), + }, + 81: { + 0: uint16(39675), + 1: uint16(39686), + 2: uint16(39704), + 3: uint16(39706), + 4: uint16(39711), + 5: uint16(39714), + 6: uint16(39715), + 7: uint16(39717), + 8: uint16(39719), + 9: uint16(39720), + 10: uint16(39721), + 11: uint16(39722), + 12: uint16(39726), + 13: uint16(39727), + 14: uint16(39730), + 15: uint16(39748), + 16: uint16(39747), + 17: uint16(39759), + 18: uint16(39757), + 19: uint16(39758), + 20: uint16(39761), + 21: uint16(39768), + 22: uint16(39796), + 23: uint16(39827), + 24: uint16(39811), + 25: uint16(39825), + 26: uint16(39830), + 27: uint16(39831), + 28: uint16(39839), + 29: uint16(39840), + 30: uint16(39848), + 31: uint16(39860), + 32: uint16(39872), + 33: uint16(39882), + 34: uint16(39865), + 35: uint16(39878), + 36: uint16(39887), + 37: uint16(39889), + 38: uint16(39890), + 39: uint16(39907), + 40: uint16(39906), + 41: uint16(39908), + 42: uint16(39892), + 43: uint16(39905), + 44: uint16(39994), + 45: uint16(39922), + 46: uint16(39921), + 47: uint16(39920), + 48: uint16(39957), + 49: uint16(39956), + 50: uint16(39945), + 51: uint16(39955), + 52: uint16(39948), + 53: uint16(39942), + 54: uint16(39944), + 55: uint16(39954), + 56: uint16(39946), + 57: uint16(39940), + 58: uint16(39982), + 59: uint16(39963), + 60: uint16(39973), + 61: uint16(39972), + 62: uint16(39969), + 63: uint16(39984), + 64: uint16(40007), + 65: uint16(39986), + 66: uint16(40006), + 67: uint16(39998), + 68: uint16(40026), + 69: uint16(40032), + 70: uint16(40039), + 71: uint16(40054), + 72: uint16(40056), + 73: uint16(40167), + 74: uint16(40172), + 75: uint16(40176), + 76: uint16(40201), + 77: uint16(40200), + 78: uint16(40171), + 79: uint16(40195), + 80: uint16(40198), + 81: uint16(40234), + 82: uint16(40230), + 83: uint16(40367), + 84: uint16(40227), + 85: uint16(40223), + 86: uint16(40260), + 87: uint16(40213), + 88: uint16(40210), + 89: uint16(40257), + 90: uint16(40255), + 91: uint16(40254), + 92: uint16(40262), + 93: uint16(40264), + }, + 82: { + 0: uint16(40285), + 1: uint16(40286), + 2: uint16(40292), + 3: uint16(40273), + 4: uint16(40272), + 5: uint16(40281), + 6: uint16(40306), + 7: uint16(40329), + 8: uint16(40327), + 9: uint16(40363), + 10: uint16(40303), + 11: uint16(40314), + 12: uint16(40346), + 13: uint16(40356), + 14: uint16(40361), + 15: uint16(40370), + 16: uint16(40388), + 17: uint16(40385), + 18: uint16(40379), + 19: uint16(40376), + 20: uint16(40378), + 21: uint16(40390), + 22: uint16(40399), + 23: uint16(40386), + 24: uint16(40409), + 25: uint16(40403), + 26: uint16(40440), + 27: uint16(40422), + 28: uint16(40429), + 29: uint16(40431), + 30: uint16(40445), + 31: uint16(40474), + 32: uint16(40475), + 33: uint16(40478), + 34: uint16(40565), + 35: uint16(40569), + 36: uint16(40573), + 37: uint16(40577), + 38: uint16(40584), + 39: uint16(40587), + 40: uint16(40588), + 41: uint16(40594), + 42: uint16(40597), + 43: uint16(40593), + 44: uint16(40605), + 45: uint16(40613), + 46: uint16(40617), + 47: uint16(40632), + 48: uint16(40618), + 49: uint16(40621), + 50: uint16(38753), + 51: uint16(40652), + 52: uint16(40654), + 53: uint16(40655), + 54: uint16(40656), + 55: uint16(40660), + 56: uint16(40668), + 57: uint16(40670), + 58: uint16(40669), + 59: uint16(40672), + 60: uint16(40677), + 61: uint16(40680), + 62: uint16(40687), + 63: uint16(40692), + 64: uint16(40694), + 65: uint16(40695), + 66: uint16(40697), + 67: uint16(40699), + 68: uint16(40700), + 69: uint16(40701), + 70: uint16(40711), + 71: uint16(40712), + 72: uint16(30391), + 73: uint16(40725), + 74: uint16(40737), + 75: uint16(40748), + 76: uint16(40766), + 77: uint16(40778), + 78: uint16(40786), + 79: uint16(40788), + 80: uint16(40803), + 81: uint16(40799), + 82: uint16(40800), + 83: uint16(40801), + 84: uint16(40806), + 85: uint16(40807), + 86: uint16(40812), + 87: uint16(40810), + 88: uint16(40823), + 89: uint16(40818), + 90: uint16(40822), + 91: uint16(40853), + 92: uint16(40860), + 93: uint16(40864), + }, + 83: { + 0: uint16(22575), + 1: uint16(27079), + 2: uint16(36953), + 3: uint16(29796), + 4: uint16(20956), + 5: uint16(29081), + }, +} + +var _gb18030 = [126][190]uint16{ + 0: { + 0: uint16(19970), + 1: uint16(19972), + 2: uint16(19973), + 3: uint16(19974), + 4: uint16(19983), + 5: uint16(19986), + 6: uint16(19991), + 7: uint16(19999), + 8: uint16(20000), + 9: uint16(20001), + 10: uint16(20003), + 11: uint16(20006), + 12: uint16(20009), + 13: uint16(20014), + 14: uint16(20015), + 15: uint16(20017), + 16: uint16(20019), + 17: uint16(20021), + 18: uint16(20023), + 19: uint16(20028), + 20: uint16(20032), + 21: uint16(20033), + 22: uint16(20034), + 23: uint16(20036), + 24: uint16(20038), + 25: uint16(20042), + 26: uint16(20049), + 27: uint16(20053), + 28: uint16(20055), + 29: uint16(20058), + 30: uint16(20059), + 31: uint16(20066), + 32: uint16(20067), + 33: uint16(20068), + 34: uint16(20069), + 35: uint16(20071), + 36: uint16(20072), + 37: uint16(20074), + 38: uint16(20075), + 39: uint16(20076), + 40: uint16(20077), + 41: uint16(20078), + 42: uint16(20079), + 43: uint16(20082), + 44: uint16(20084), + 45: uint16(20085), + 46: uint16(20086), + 47: uint16(20087), + 48: uint16(20088), + 49: uint16(20089), + 50: uint16(20090), + 51: uint16(20091), + 52: uint16(20092), + 53: uint16(20093), + 54: uint16(20095), + 55: uint16(20096), + 56: uint16(20097), + 57: uint16(20098), + 58: uint16(20099), + 59: uint16(20100), + 60: uint16(20101), + 61: uint16(20103), + 62: uint16(20106), + 63: uint16(20112), + 64: uint16(20118), + 65: uint16(20119), + 66: uint16(20121), + 67: uint16(20124), + 68: uint16(20125), + 69: uint16(20126), + 70: uint16(20131), + 71: uint16(20138), + 72: uint16(20143), + 73: uint16(20144), + 74: uint16(20145), + 75: uint16(20148), + 76: uint16(20150), + 77: uint16(20151), + 78: uint16(20152), + 79: uint16(20153), + 80: uint16(20156), + 81: uint16(20157), + 82: uint16(20158), + 83: uint16(20168), + 84: uint16(20172), + 85: uint16(20175), + 86: uint16(20176), + 87: uint16(20178), + 88: uint16(20186), + 89: uint16(20187), + 90: uint16(20188), + 91: uint16(20192), + 92: uint16(20194), + 93: uint16(20198), + 94: uint16(20199), + 95: uint16(20201), + 96: uint16(20205), + 97: uint16(20206), + 98: uint16(20207), + 99: uint16(20209), + 100: uint16(20212), + 101: uint16(20216), + 102: uint16(20217), + 103: uint16(20218), + 104: uint16(20220), + 105: uint16(20222), + 106: uint16(20224), + 107: uint16(20226), + 108: uint16(20227), + 109: uint16(20228), + 110: uint16(20229), + 111: uint16(20230), + 112: uint16(20231), + 113: uint16(20232), + 114: uint16(20235), + 115: uint16(20236), + 116: uint16(20242), + 117: uint16(20243), + 118: uint16(20244), + 119: uint16(20245), + 120: uint16(20246), + 121: uint16(20252), + 122: uint16(20253), + 123: uint16(20257), + 124: uint16(20259), + 125: uint16(20264), + 126: uint16(20265), + 127: uint16(20268), + 128: uint16(20269), + 129: uint16(20270), + 130: uint16(20273), + 131: uint16(20275), + 132: uint16(20277), + 133: uint16(20279), + 134: uint16(20281), + 135: uint16(20283), + 136: uint16(20286), + 137: uint16(20287), + 138: uint16(20288), + 139: uint16(20289), + 140: uint16(20290), + 141: uint16(20292), + 142: uint16(20293), + 143: uint16(20295), + 144: uint16(20296), + 145: uint16(20297), + 146: uint16(20298), + 147: uint16(20299), + 148: uint16(20300), + 149: uint16(20306), + 150: uint16(20308), + 151: uint16(20310), + 152: uint16(20321), + 153: uint16(20322), + 154: uint16(20326), + 155: uint16(20328), + 156: uint16(20330), + 157: uint16(20331), + 158: uint16(20333), + 159: uint16(20334), + 160: uint16(20337), + 161: uint16(20338), + 162: uint16(20341), + 163: uint16(20343), + 164: uint16(20344), + 165: uint16(20345), + 166: uint16(20346), + 167: uint16(20349), + 168: uint16(20352), + 169: uint16(20353), + 170: uint16(20354), + 171: uint16(20357), + 172: uint16(20358), + 173: uint16(20359), + 174: uint16(20362), + 175: uint16(20364), + 176: uint16(20366), + 177: uint16(20368), + 178: uint16(20370), + 179: uint16(20371), + 180: uint16(20373), + 181: uint16(20374), + 182: uint16(20376), + 183: uint16(20377), + 184: uint16(20378), + 185: uint16(20380), + 186: uint16(20382), + 187: uint16(20383), + 188: uint16(20385), + 189: uint16(20386), + }, + 1: { + 0: uint16(20388), + 1: uint16(20395), + 2: uint16(20397), + 3: uint16(20400), + 4: uint16(20401), + 5: uint16(20402), + 6: uint16(20403), + 7: uint16(20404), + 8: uint16(20406), + 9: uint16(20407), + 10: uint16(20408), + 11: uint16(20409), + 12: uint16(20410), + 13: uint16(20411), + 14: uint16(20412), + 15: uint16(20413), + 16: uint16(20414), + 17: uint16(20416), + 18: uint16(20417), + 19: uint16(20418), + 20: uint16(20422), + 21: uint16(20423), + 22: uint16(20424), + 23: uint16(20425), + 24: uint16(20427), + 25: uint16(20428), + 26: uint16(20429), + 27: uint16(20434), + 28: uint16(20435), + 29: uint16(20436), + 30: uint16(20437), + 31: uint16(20438), + 32: uint16(20441), + 33: uint16(20443), + 34: uint16(20448), + 35: uint16(20450), + 36: uint16(20452), + 37: uint16(20453), + 38: uint16(20455), + 39: uint16(20459), + 40: uint16(20460), + 41: uint16(20464), + 42: uint16(20466), + 43: uint16(20468), + 44: uint16(20469), + 45: uint16(20470), + 46: uint16(20471), + 47: uint16(20473), + 48: uint16(20475), + 49: uint16(20476), + 50: uint16(20477), + 51: uint16(20479), + 52: uint16(20480), + 53: uint16(20481), + 54: uint16(20482), + 55: uint16(20483), + 56: uint16(20484), + 57: uint16(20485), + 58: uint16(20486), + 59: uint16(20487), + 60: uint16(20488), + 61: uint16(20489), + 62: uint16(20490), + 63: uint16(20491), + 64: uint16(20494), + 65: uint16(20496), + 66: uint16(20497), + 67: uint16(20499), + 68: uint16(20501), + 69: uint16(20502), + 70: uint16(20503), + 71: uint16(20507), + 72: uint16(20509), + 73: uint16(20510), + 74: uint16(20512), + 75: uint16(20514), + 76: uint16(20515), + 77: uint16(20516), + 78: uint16(20519), + 79: uint16(20523), + 80: uint16(20527), + 81: uint16(20528), + 82: uint16(20529), + 83: uint16(20530), + 84: uint16(20531), + 85: uint16(20532), + 86: uint16(20533), + 87: uint16(20534), + 88: uint16(20535), + 89: uint16(20536), + 90: uint16(20537), + 91: uint16(20539), + 92: uint16(20541), + 93: uint16(20543), + 94: uint16(20544), + 95: uint16(20545), + 96: uint16(20546), + 97: uint16(20548), + 98: uint16(20549), + 99: uint16(20550), + 100: uint16(20553), + 101: uint16(20554), + 102: uint16(20555), + 103: uint16(20557), + 104: uint16(20560), + 105: uint16(20561), + 106: uint16(20562), + 107: uint16(20563), + 108: uint16(20564), + 109: uint16(20566), + 110: uint16(20567), + 111: uint16(20568), + 112: uint16(20569), + 113: uint16(20571), + 114: uint16(20573), + 115: uint16(20574), + 116: uint16(20575), + 117: uint16(20576), + 118: uint16(20577), + 119: uint16(20578), + 120: uint16(20579), + 121: uint16(20580), + 122: uint16(20582), + 123: uint16(20583), + 124: uint16(20584), + 125: uint16(20585), + 126: uint16(20586), + 127: uint16(20587), + 128: uint16(20589), + 129: uint16(20590), + 130: uint16(20591), + 131: uint16(20592), + 132: uint16(20593), + 133: uint16(20594), + 134: uint16(20595), + 135: uint16(20596), + 136: uint16(20597), + 137: uint16(20600), + 138: uint16(20601), + 139: uint16(20602), + 140: uint16(20604), + 141: uint16(20605), + 142: uint16(20609), + 143: uint16(20610), + 144: uint16(20611), + 145: uint16(20612), + 146: uint16(20614), + 147: uint16(20615), + 148: uint16(20617), + 149: uint16(20618), + 150: uint16(20619), + 151: uint16(20620), + 152: uint16(20622), + 153: uint16(20623), + 154: uint16(20624), + 155: uint16(20625), + 156: uint16(20626), + 157: uint16(20627), + 158: uint16(20628), + 159: uint16(20629), + 160: uint16(20630), + 161: uint16(20631), + 162: uint16(20632), + 163: uint16(20633), + 164: uint16(20634), + 165: uint16(20635), + 166: uint16(20636), + 167: uint16(20637), + 168: uint16(20638), + 169: uint16(20639), + 170: uint16(20640), + 171: uint16(20641), + 172: uint16(20642), + 173: uint16(20644), + 174: uint16(20646), + 175: uint16(20650), + 176: uint16(20651), + 177: uint16(20653), + 178: uint16(20654), + 179: uint16(20655), + 180: uint16(20656), + 181: uint16(20657), + 182: uint16(20659), + 183: uint16(20660), + 184: uint16(20661), + 185: uint16(20662), + 186: uint16(20663), + 187: uint16(20664), + 188: uint16(20665), + 189: uint16(20668), + }, + 2: { + 0: uint16(20669), + 1: uint16(20670), + 2: uint16(20671), + 3: uint16(20672), + 4: uint16(20673), + 5: uint16(20674), + 6: uint16(20675), + 7: uint16(20676), + 8: uint16(20677), + 9: uint16(20678), + 10: uint16(20679), + 11: uint16(20680), + 12: uint16(20681), + 13: uint16(20682), + 14: uint16(20683), + 15: uint16(20684), + 16: uint16(20685), + 17: uint16(20686), + 18: uint16(20688), + 19: uint16(20689), + 20: uint16(20690), + 21: uint16(20691), + 22: uint16(20692), + 23: uint16(20693), + 24: uint16(20695), + 25: uint16(20696), + 26: uint16(20697), + 27: uint16(20699), + 28: uint16(20700), + 29: uint16(20701), + 30: uint16(20702), + 31: uint16(20703), + 32: uint16(20704), + 33: uint16(20705), + 34: uint16(20706), + 35: uint16(20707), + 36: uint16(20708), + 37: uint16(20709), + 38: uint16(20712), + 39: uint16(20713), + 40: uint16(20714), + 41: uint16(20715), + 42: uint16(20719), + 43: uint16(20720), + 44: uint16(20721), + 45: uint16(20722), + 46: uint16(20724), + 47: uint16(20726), + 48: uint16(20727), + 49: uint16(20728), + 50: uint16(20729), + 51: uint16(20730), + 52: uint16(20732), + 53: uint16(20733), + 54: uint16(20734), + 55: uint16(20735), + 56: uint16(20736), + 57: uint16(20737), + 58: uint16(20738), + 59: uint16(20739), + 60: uint16(20740), + 61: uint16(20741), + 62: uint16(20744), + 63: uint16(20745), + 64: uint16(20746), + 65: uint16(20748), + 66: uint16(20749), + 67: uint16(20750), + 68: uint16(20751), + 69: uint16(20752), + 70: uint16(20753), + 71: uint16(20755), + 72: uint16(20756), + 73: uint16(20757), + 74: uint16(20758), + 75: uint16(20759), + 76: uint16(20760), + 77: uint16(20761), + 78: uint16(20762), + 79: uint16(20763), + 80: uint16(20764), + 81: uint16(20765), + 82: uint16(20766), + 83: uint16(20767), + 84: uint16(20768), + 85: uint16(20770), + 86: uint16(20771), + 87: uint16(20772), + 88: uint16(20773), + 89: uint16(20774), + 90: uint16(20775), + 91: uint16(20776), + 92: uint16(20777), + 93: uint16(20778), + 94: uint16(20779), + 95: uint16(20780), + 96: uint16(20781), + 97: uint16(20782), + 98: uint16(20783), + 99: uint16(20784), + 100: uint16(20785), + 101: uint16(20786), + 102: uint16(20787), + 103: uint16(20788), + 104: uint16(20789), + 105: uint16(20790), + 106: uint16(20791), + 107: uint16(20792), + 108: uint16(20793), + 109: uint16(20794), + 110: uint16(20795), + 111: uint16(20796), + 112: uint16(20797), + 113: uint16(20798), + 114: uint16(20802), + 115: uint16(20807), + 116: uint16(20810), + 117: uint16(20812), + 118: uint16(20814), + 119: uint16(20815), + 120: uint16(20816), + 121: uint16(20818), + 122: uint16(20819), + 123: uint16(20823), + 124: uint16(20824), + 125: uint16(20825), + 126: uint16(20827), + 127: uint16(20829), + 128: uint16(20830), + 129: uint16(20831), + 130: uint16(20832), + 131: uint16(20833), + 132: uint16(20835), + 133: uint16(20836), + 134: uint16(20838), + 135: uint16(20839), + 136: uint16(20841), + 137: uint16(20842), + 138: uint16(20847), + 139: uint16(20850), + 140: uint16(20858), + 141: uint16(20862), + 142: uint16(20863), + 143: uint16(20867), + 144: uint16(20868), + 145: uint16(20870), + 146: uint16(20871), + 147: uint16(20874), + 148: uint16(20875), + 149: uint16(20878), + 150: uint16(20879), + 151: uint16(20880), + 152: uint16(20881), + 153: uint16(20883), + 154: uint16(20884), + 155: uint16(20888), + 156: uint16(20890), + 157: uint16(20893), + 158: uint16(20894), + 159: uint16(20895), + 160: uint16(20897), + 161: uint16(20899), + 162: uint16(20902), + 163: uint16(20903), + 164: uint16(20904), + 165: uint16(20905), + 166: uint16(20906), + 167: uint16(20909), + 168: uint16(20910), + 169: uint16(20916), + 170: uint16(20920), + 171: uint16(20921), + 172: uint16(20922), + 173: uint16(20926), + 174: uint16(20927), + 175: uint16(20929), + 176: uint16(20930), + 177: uint16(20931), + 178: uint16(20933), + 179: uint16(20936), + 180: uint16(20938), + 181: uint16(20941), + 182: uint16(20942), + 183: uint16(20944), + 184: uint16(20946), + 185: uint16(20947), + 186: uint16(20948), + 187: uint16(20949), + 188: uint16(20950), + 189: uint16(20951), + }, + 3: { + 0: uint16(20952), + 1: uint16(20953), + 2: uint16(20954), + 3: uint16(20956), + 4: uint16(20958), + 5: uint16(20959), + 6: uint16(20962), + 7: uint16(20963), + 8: uint16(20965), + 9: uint16(20966), + 10: uint16(20967), + 11: uint16(20968), + 12: uint16(20969), + 13: uint16(20970), + 14: uint16(20972), + 15: uint16(20974), + 16: uint16(20977), + 17: uint16(20978), + 18: uint16(20980), + 19: uint16(20983), + 20: uint16(20990), + 21: uint16(20996), + 22: uint16(20997), + 23: uint16(21001), + 24: uint16(21003), + 25: uint16(21004), + 26: uint16(21007), + 27: uint16(21008), + 28: uint16(21011), + 29: uint16(21012), + 30: uint16(21013), + 31: uint16(21020), + 32: uint16(21022), + 33: uint16(21023), + 34: uint16(21025), + 35: uint16(21026), + 36: uint16(21027), + 37: uint16(21029), + 38: uint16(21030), + 39: uint16(21031), + 40: uint16(21034), + 41: uint16(21036), + 42: uint16(21039), + 43: uint16(21041), + 44: uint16(21042), + 45: uint16(21044), + 46: uint16(21045), + 47: uint16(21052), + 48: uint16(21054), + 49: uint16(21060), + 50: uint16(21061), + 51: uint16(21062), + 52: uint16(21063), + 53: uint16(21064), + 54: uint16(21065), + 55: uint16(21067), + 56: uint16(21070), + 57: uint16(21071), + 58: uint16(21074), + 59: uint16(21075), + 60: uint16(21077), + 61: uint16(21079), + 62: uint16(21080), + 63: uint16(21081), + 64: uint16(21082), + 65: uint16(21083), + 66: uint16(21085), + 67: uint16(21087), + 68: uint16(21088), + 69: uint16(21090), + 70: uint16(21091), + 71: uint16(21092), + 72: uint16(21094), + 73: uint16(21096), + 74: uint16(21099), + 75: uint16(21100), + 76: uint16(21101), + 77: uint16(21102), + 78: uint16(21104), + 79: uint16(21105), + 80: uint16(21107), + 81: uint16(21108), + 82: uint16(21109), + 83: uint16(21110), + 84: uint16(21111), + 85: uint16(21112), + 86: uint16(21113), + 87: uint16(21114), + 88: uint16(21115), + 89: uint16(21116), + 90: uint16(21118), + 91: uint16(21120), + 92: uint16(21123), + 93: uint16(21124), + 94: uint16(21125), + 95: uint16(21126), + 96: uint16(21127), + 97: uint16(21129), + 98: uint16(21130), + 99: uint16(21131), + 100: uint16(21132), + 101: uint16(21133), + 102: uint16(21134), + 103: uint16(21135), + 104: uint16(21137), + 105: uint16(21138), + 106: uint16(21140), + 107: uint16(21141), + 108: uint16(21142), + 109: uint16(21143), + 110: uint16(21144), + 111: uint16(21145), + 112: uint16(21146), + 113: uint16(21148), + 114: uint16(21156), + 115: uint16(21157), + 116: uint16(21158), + 117: uint16(21159), + 118: uint16(21166), + 119: uint16(21167), + 120: uint16(21168), + 121: uint16(21172), + 122: uint16(21173), + 123: uint16(21174), + 124: uint16(21175), + 125: uint16(21176), + 126: uint16(21177), + 127: uint16(21178), + 128: uint16(21179), + 129: uint16(21180), + 130: uint16(21181), + 131: uint16(21184), + 132: uint16(21185), + 133: uint16(21186), + 134: uint16(21188), + 135: uint16(21189), + 136: uint16(21190), + 137: uint16(21192), + 138: uint16(21194), + 139: uint16(21196), + 140: uint16(21197), + 141: uint16(21198), + 142: uint16(21199), + 143: uint16(21201), + 144: uint16(21203), + 145: uint16(21204), + 146: uint16(21205), + 147: uint16(21207), + 148: uint16(21209), + 149: uint16(21210), + 150: uint16(21211), + 151: uint16(21212), + 152: uint16(21213), + 153: uint16(21214), + 154: uint16(21216), + 155: uint16(21217), + 156: uint16(21218), + 157: uint16(21219), + 158: uint16(21221), + 159: uint16(21222), + 160: uint16(21223), + 161: uint16(21224), + 162: uint16(21225), + 163: uint16(21226), + 164: uint16(21227), + 165: uint16(21228), + 166: uint16(21229), + 167: uint16(21230), + 168: uint16(21231), + 169: uint16(21233), + 170: uint16(21234), + 171: uint16(21235), + 172: uint16(21236), + 173: uint16(21237), + 174: uint16(21238), + 175: uint16(21239), + 176: uint16(21240), + 177: uint16(21243), + 178: uint16(21244), + 179: uint16(21245), + 180: uint16(21249), + 181: uint16(21250), + 182: uint16(21251), + 183: uint16(21252), + 184: uint16(21255), + 185: uint16(21257), + 186: uint16(21258), + 187: uint16(21259), + 188: uint16(21260), + 189: uint16(21262), + }, + 4: { + 0: uint16(21265), + 1: uint16(21266), + 2: uint16(21267), + 3: uint16(21268), + 4: uint16(21272), + 5: uint16(21275), + 6: uint16(21276), + 7: uint16(21278), + 8: uint16(21279), + 9: uint16(21282), + 10: uint16(21284), + 11: uint16(21285), + 12: uint16(21287), + 13: uint16(21288), + 14: uint16(21289), + 15: uint16(21291), + 16: uint16(21292), + 17: uint16(21293), + 18: uint16(21295), + 19: uint16(21296), + 20: uint16(21297), + 21: uint16(21298), + 22: uint16(21299), + 23: uint16(21300), + 24: uint16(21301), + 25: uint16(21302), + 26: uint16(21303), + 27: uint16(21304), + 28: uint16(21308), + 29: uint16(21309), + 30: uint16(21312), + 31: uint16(21314), + 32: uint16(21316), + 33: uint16(21318), + 34: uint16(21323), + 35: uint16(21324), + 36: uint16(21325), + 37: uint16(21328), + 38: uint16(21332), + 39: uint16(21336), + 40: uint16(21337), + 41: uint16(21339), + 42: uint16(21341), + 43: uint16(21349), + 44: uint16(21352), + 45: uint16(21354), + 46: uint16(21356), + 47: uint16(21357), + 48: uint16(21362), + 49: uint16(21366), + 50: uint16(21369), + 51: uint16(21371), + 52: uint16(21372), + 53: uint16(21373), + 54: uint16(21374), + 55: uint16(21376), + 56: uint16(21377), + 57: uint16(21379), + 58: uint16(21383), + 59: uint16(21384), + 60: uint16(21386), + 61: uint16(21390), + 62: uint16(21391), + 63: uint16(21392), + 64: uint16(21393), + 65: uint16(21394), + 66: uint16(21395), + 67: uint16(21396), + 68: uint16(21398), + 69: uint16(21399), + 70: uint16(21401), + 71: uint16(21403), + 72: uint16(21404), + 73: uint16(21406), + 74: uint16(21408), + 75: uint16(21409), + 76: uint16(21412), + 77: uint16(21415), + 78: uint16(21418), + 79: uint16(21419), + 80: uint16(21420), + 81: uint16(21421), + 82: uint16(21423), + 83: uint16(21424), + 84: uint16(21425), + 85: uint16(21426), + 86: uint16(21427), + 87: uint16(21428), + 88: uint16(21429), + 89: uint16(21431), + 90: uint16(21432), + 91: uint16(21433), + 92: uint16(21434), + 93: uint16(21436), + 94: uint16(21437), + 95: uint16(21438), + 96: uint16(21440), + 97: uint16(21443), + 98: uint16(21444), + 99: uint16(21445), + 100: uint16(21446), + 101: uint16(21447), + 102: uint16(21454), + 103: uint16(21455), + 104: uint16(21456), + 105: uint16(21458), + 106: uint16(21459), + 107: uint16(21461), + 108: uint16(21466), + 109: uint16(21468), + 110: uint16(21469), + 111: uint16(21470), + 112: uint16(21473), + 113: uint16(21474), + 114: uint16(21479), + 115: uint16(21492), + 116: uint16(21498), + 117: uint16(21502), + 118: uint16(21503), + 119: uint16(21504), + 120: uint16(21506), + 121: uint16(21509), + 122: uint16(21511), + 123: uint16(21515), + 124: uint16(21524), + 125: uint16(21528), + 126: uint16(21529), + 127: uint16(21530), + 128: uint16(21532), + 129: uint16(21538), + 130: uint16(21540), + 131: uint16(21541), + 132: uint16(21546), + 133: uint16(21552), + 134: uint16(21555), + 135: uint16(21558), + 136: uint16(21559), + 137: uint16(21562), + 138: uint16(21565), + 139: uint16(21567), + 140: uint16(21569), + 141: uint16(21570), + 142: uint16(21572), + 143: uint16(21573), + 144: uint16(21575), + 145: uint16(21577), + 146: uint16(21580), + 147: uint16(21581), + 148: uint16(21582), + 149: uint16(21583), + 150: uint16(21585), + 151: uint16(21594), + 152: uint16(21597), + 153: uint16(21598), + 154: uint16(21599), + 155: uint16(21600), + 156: uint16(21601), + 157: uint16(21603), + 158: uint16(21605), + 159: uint16(21607), + 160: uint16(21609), + 161: uint16(21610), + 162: uint16(21611), + 163: uint16(21612), + 164: uint16(21613), + 165: uint16(21614), + 166: uint16(21615), + 167: uint16(21616), + 168: uint16(21620), + 169: uint16(21625), + 170: uint16(21626), + 171: uint16(21630), + 172: uint16(21631), + 173: uint16(21633), + 174: uint16(21635), + 175: uint16(21637), + 176: uint16(21639), + 177: uint16(21640), + 178: uint16(21641), + 179: uint16(21642), + 180: uint16(21645), + 181: uint16(21649), + 182: uint16(21651), + 183: uint16(21655), + 184: uint16(21656), + 185: uint16(21660), + 186: uint16(21662), + 187: uint16(21663), + 188: uint16(21664), + 189: uint16(21665), + }, + 5: { + 0: uint16(21666), + 1: uint16(21669), + 2: uint16(21678), + 3: uint16(21680), + 4: uint16(21682), + 5: uint16(21685), + 6: uint16(21686), + 7: uint16(21687), + 8: uint16(21689), + 9: uint16(21690), + 10: uint16(21692), + 11: uint16(21694), + 12: uint16(21699), + 13: uint16(21701), + 14: uint16(21706), + 15: uint16(21707), + 16: uint16(21718), + 17: uint16(21720), + 18: uint16(21723), + 19: uint16(21728), + 20: uint16(21729), + 21: uint16(21730), + 22: uint16(21731), + 23: uint16(21732), + 24: uint16(21739), + 25: uint16(21740), + 26: uint16(21743), + 27: uint16(21744), + 28: uint16(21745), + 29: uint16(21748), + 30: uint16(21749), + 31: uint16(21750), + 32: uint16(21751), + 33: uint16(21752), + 34: uint16(21753), + 35: uint16(21755), + 36: uint16(21758), + 37: uint16(21760), + 38: uint16(21762), + 39: uint16(21763), + 40: uint16(21764), + 41: uint16(21765), + 42: uint16(21768), + 43: uint16(21770), + 44: uint16(21771), + 45: uint16(21772), + 46: uint16(21773), + 47: uint16(21774), + 48: uint16(21778), + 49: uint16(21779), + 50: uint16(21781), + 51: uint16(21782), + 52: uint16(21783), + 53: uint16(21784), + 54: uint16(21785), + 55: uint16(21786), + 56: uint16(21788), + 57: uint16(21789), + 58: uint16(21790), + 59: uint16(21791), + 60: uint16(21793), + 61: uint16(21797), + 62: uint16(21798), + 63: uint16(21800), + 64: uint16(21801), + 65: uint16(21803), + 66: uint16(21805), + 67: uint16(21810), + 68: uint16(21812), + 69: uint16(21813), + 70: uint16(21814), + 71: uint16(21816), + 72: uint16(21817), + 73: uint16(21818), + 74: uint16(21819), + 75: uint16(21821), + 76: uint16(21824), + 77: uint16(21826), + 78: uint16(21829), + 79: uint16(21831), + 80: uint16(21832), + 81: uint16(21835), + 82: uint16(21836), + 83: uint16(21837), + 84: uint16(21838), + 85: uint16(21839), + 86: uint16(21841), + 87: uint16(21842), + 88: uint16(21843), + 89: uint16(21844), + 90: uint16(21847), + 91: uint16(21848), + 92: uint16(21849), + 93: uint16(21850), + 94: uint16(21851), + 95: uint16(21853), + 96: uint16(21854), + 97: uint16(21855), + 98: uint16(21856), + 99: uint16(21858), + 100: uint16(21859), + 101: uint16(21864), + 102: uint16(21865), + 103: uint16(21867), + 104: uint16(21871), + 105: uint16(21872), + 106: uint16(21873), + 107: uint16(21874), + 108: uint16(21875), + 109: uint16(21876), + 110: uint16(21881), + 111: uint16(21882), + 112: uint16(21885), + 113: uint16(21887), + 114: uint16(21893), + 115: uint16(21894), + 116: uint16(21900), + 117: uint16(21901), + 118: uint16(21902), + 119: uint16(21904), + 120: uint16(21906), + 121: uint16(21907), + 122: uint16(21909), + 123: uint16(21910), + 124: uint16(21911), + 125: uint16(21914), + 126: uint16(21915), + 127: uint16(21918), + 128: uint16(21920), + 129: uint16(21921), + 130: uint16(21922), + 131: uint16(21923), + 132: uint16(21924), + 133: uint16(21925), + 134: uint16(21926), + 135: uint16(21928), + 136: uint16(21929), + 137: uint16(21930), + 138: uint16(21931), + 139: uint16(21932), + 140: uint16(21933), + 141: uint16(21934), + 142: uint16(21935), + 143: uint16(21936), + 144: uint16(21938), + 145: uint16(21940), + 146: uint16(21942), + 147: uint16(21944), + 148: uint16(21946), + 149: uint16(21948), + 150: uint16(21951), + 151: uint16(21952), + 152: uint16(21953), + 153: uint16(21954), + 154: uint16(21955), + 155: uint16(21958), + 156: uint16(21959), + 157: uint16(21960), + 158: uint16(21962), + 159: uint16(21963), + 160: uint16(21966), + 161: uint16(21967), + 162: uint16(21968), + 163: uint16(21973), + 164: uint16(21975), + 165: uint16(21976), + 166: uint16(21977), + 167: uint16(21978), + 168: uint16(21979), + 169: uint16(21982), + 170: uint16(21984), + 171: uint16(21986), + 172: uint16(21991), + 173: uint16(21993), + 174: uint16(21997), + 175: uint16(21998), + 176: uint16(22000), + 177: uint16(22001), + 178: uint16(22004), + 179: uint16(22006), + 180: uint16(22008), + 181: uint16(22009), + 182: uint16(22010), + 183: uint16(22011), + 184: uint16(22012), + 185: uint16(22015), + 186: uint16(22018), + 187: uint16(22019), + 188: uint16(22020), + 189: uint16(22021), + }, + 6: { + 0: uint16(22022), + 1: uint16(22023), + 2: uint16(22026), + 3: uint16(22027), + 4: uint16(22029), + 5: uint16(22032), + 6: uint16(22033), + 7: uint16(22034), + 8: uint16(22035), + 9: uint16(22036), + 10: uint16(22037), + 11: uint16(22038), + 12: uint16(22039), + 13: uint16(22041), + 14: uint16(22042), + 15: uint16(22044), + 16: uint16(22045), + 17: uint16(22048), + 18: uint16(22049), + 19: uint16(22050), + 20: uint16(22053), + 21: uint16(22054), + 22: uint16(22056), + 23: uint16(22057), + 24: uint16(22058), + 25: uint16(22059), + 26: uint16(22062), + 27: uint16(22063), + 28: uint16(22064), + 29: uint16(22067), + 30: uint16(22069), + 31: uint16(22071), + 32: uint16(22072), + 33: uint16(22074), + 34: uint16(22076), + 35: uint16(22077), + 36: uint16(22078), + 37: uint16(22080), + 38: uint16(22081), + 39: uint16(22082), + 40: uint16(22083), + 41: uint16(22084), + 42: uint16(22085), + 43: uint16(22086), + 44: uint16(22087), + 45: uint16(22088), + 46: uint16(22089), + 47: uint16(22090), + 48: uint16(22091), + 49: uint16(22095), + 50: uint16(22096), + 51: uint16(22097), + 52: uint16(22098), + 53: uint16(22099), + 54: uint16(22101), + 55: uint16(22102), + 56: uint16(22106), + 57: uint16(22107), + 58: uint16(22109), + 59: uint16(22110), + 60: uint16(22111), + 61: uint16(22112), + 62: uint16(22113), + 63: uint16(22115), + 64: uint16(22117), + 65: uint16(22118), + 66: uint16(22119), + 67: uint16(22125), + 68: uint16(22126), + 69: uint16(22127), + 70: uint16(22128), + 71: uint16(22130), + 72: uint16(22131), + 73: uint16(22132), + 74: uint16(22133), + 75: uint16(22135), + 76: uint16(22136), + 77: uint16(22137), + 78: uint16(22138), + 79: uint16(22141), + 80: uint16(22142), + 81: uint16(22143), + 82: uint16(22144), + 83: uint16(22145), + 84: uint16(22146), + 85: uint16(22147), + 86: uint16(22148), + 87: uint16(22151), + 88: uint16(22152), + 89: uint16(22153), + 90: uint16(22154), + 91: uint16(22155), + 92: uint16(22156), + 93: uint16(22157), + 94: uint16(22160), + 95: uint16(22161), + 96: uint16(22162), + 97: uint16(22164), + 98: uint16(22165), + 99: uint16(22166), + 100: uint16(22167), + 101: uint16(22168), + 102: uint16(22169), + 103: uint16(22170), + 104: uint16(22171), + 105: uint16(22172), + 106: uint16(22173), + 107: uint16(22174), + 108: uint16(22175), + 109: uint16(22176), + 110: uint16(22177), + 111: uint16(22178), + 112: uint16(22180), + 113: uint16(22181), + 114: uint16(22182), + 115: uint16(22183), + 116: uint16(22184), + 117: uint16(22185), + 118: uint16(22186), + 119: uint16(22187), + 120: uint16(22188), + 121: uint16(22189), + 122: uint16(22190), + 123: uint16(22192), + 124: uint16(22193), + 125: uint16(22194), + 126: uint16(22195), + 127: uint16(22196), + 128: uint16(22197), + 129: uint16(22198), + 130: uint16(22200), + 131: uint16(22201), + 132: uint16(22202), + 133: uint16(22203), + 134: uint16(22205), + 135: uint16(22206), + 136: uint16(22207), + 137: uint16(22208), + 138: uint16(22209), + 139: uint16(22210), + 140: uint16(22211), + 141: uint16(22212), + 142: uint16(22213), + 143: uint16(22214), + 144: uint16(22215), + 145: uint16(22216), + 146: uint16(22217), + 147: uint16(22219), + 148: uint16(22220), + 149: uint16(22221), + 150: uint16(22222), + 151: uint16(22223), + 152: uint16(22224), + 153: uint16(22225), + 154: uint16(22226), + 155: uint16(22227), + 156: uint16(22229), + 157: uint16(22230), + 158: uint16(22232), + 159: uint16(22233), + 160: uint16(22236), + 161: uint16(22243), + 162: uint16(22245), + 163: uint16(22246), + 164: uint16(22247), + 165: uint16(22248), + 166: uint16(22249), + 167: uint16(22250), + 168: uint16(22252), + 169: uint16(22254), + 170: uint16(22255), + 171: uint16(22258), + 172: uint16(22259), + 173: uint16(22262), + 174: uint16(22263), + 175: uint16(22264), + 176: uint16(22267), + 177: uint16(22268), + 178: uint16(22272), + 179: uint16(22273), + 180: uint16(22274), + 181: uint16(22277), + 182: uint16(22279), + 183: uint16(22283), + 184: uint16(22284), + 185: uint16(22285), + 186: uint16(22286), + 187: uint16(22287), + 188: uint16(22288), + 189: uint16(22289), + }, + 7: { + 0: uint16(22290), + 1: uint16(22291), + 2: uint16(22292), + 3: uint16(22293), + 4: uint16(22294), + 5: uint16(22295), + 6: uint16(22296), + 7: uint16(22297), + 8: uint16(22298), + 9: uint16(22299), + 10: uint16(22301), + 11: uint16(22302), + 12: uint16(22304), + 13: uint16(22305), + 14: uint16(22306), + 15: uint16(22308), + 16: uint16(22309), + 17: uint16(22310), + 18: uint16(22311), + 19: uint16(22315), + 20: uint16(22321), + 21: uint16(22322), + 22: uint16(22324), + 23: uint16(22325), + 24: uint16(22326), + 25: uint16(22327), + 26: uint16(22328), + 27: uint16(22332), + 28: uint16(22333), + 29: uint16(22335), + 30: uint16(22337), + 31: uint16(22339), + 32: uint16(22340), + 33: uint16(22341), + 34: uint16(22342), + 35: uint16(22344), + 36: uint16(22345), + 37: uint16(22347), + 38: uint16(22354), + 39: uint16(22355), + 40: uint16(22356), + 41: uint16(22357), + 42: uint16(22358), + 43: uint16(22360), + 44: uint16(22361), + 45: uint16(22370), + 46: uint16(22371), + 47: uint16(22373), + 48: uint16(22375), + 49: uint16(22380), + 50: uint16(22382), + 51: uint16(22384), + 52: uint16(22385), + 53: uint16(22386), + 54: uint16(22388), + 55: uint16(22389), + 56: uint16(22392), + 57: uint16(22393), + 58: uint16(22394), + 59: uint16(22397), + 60: uint16(22398), + 61: uint16(22399), + 62: uint16(22400), + 63: uint16(22401), + 64: uint16(22407), + 65: uint16(22408), + 66: uint16(22409), + 67: uint16(22410), + 68: uint16(22413), + 69: uint16(22414), + 70: uint16(22415), + 71: uint16(22416), + 72: uint16(22417), + 73: uint16(22420), + 74: uint16(22421), + 75: uint16(22422), + 76: uint16(22423), + 77: uint16(22424), + 78: uint16(22425), + 79: uint16(22426), + 80: uint16(22428), + 81: uint16(22429), + 82: uint16(22430), + 83: uint16(22431), + 84: uint16(22437), + 85: uint16(22440), + 86: uint16(22442), + 87: uint16(22444), + 88: uint16(22447), + 89: uint16(22448), + 90: uint16(22449), + 91: uint16(22451), + 92: uint16(22453), + 93: uint16(22454), + 94: uint16(22455), + 95: uint16(22457), + 96: uint16(22458), + 97: uint16(22459), + 98: uint16(22460), + 99: uint16(22461), + 100: uint16(22462), + 101: uint16(22463), + 102: uint16(22464), + 103: uint16(22465), + 104: uint16(22468), + 105: uint16(22469), + 106: uint16(22470), + 107: uint16(22471), + 108: uint16(22472), + 109: uint16(22473), + 110: uint16(22474), + 111: uint16(22476), + 112: uint16(22477), + 113: uint16(22480), + 114: uint16(22481), + 115: uint16(22483), + 116: uint16(22486), + 117: uint16(22487), + 118: uint16(22491), + 119: uint16(22492), + 120: uint16(22494), + 121: uint16(22497), + 122: uint16(22498), + 123: uint16(22499), + 124: uint16(22501), + 125: uint16(22502), + 126: uint16(22503), + 127: uint16(22504), + 128: uint16(22505), + 129: uint16(22506), + 130: uint16(22507), + 131: uint16(22508), + 132: uint16(22510), + 133: uint16(22512), + 134: uint16(22513), + 135: uint16(22514), + 136: uint16(22515), + 137: uint16(22517), + 138: uint16(22518), + 139: uint16(22519), + 140: uint16(22523), + 141: uint16(22524), + 142: uint16(22526), + 143: uint16(22527), + 144: uint16(22529), + 145: uint16(22531), + 146: uint16(22532), + 147: uint16(22533), + 148: uint16(22536), + 149: uint16(22537), + 150: uint16(22538), + 151: uint16(22540), + 152: uint16(22542), + 153: uint16(22543), + 154: uint16(22544), + 155: uint16(22546), + 156: uint16(22547), + 157: uint16(22548), + 158: uint16(22550), + 159: uint16(22551), + 160: uint16(22552), + 161: uint16(22554), + 162: uint16(22555), + 163: uint16(22556), + 164: uint16(22557), + 165: uint16(22559), + 166: uint16(22562), + 167: uint16(22563), + 168: uint16(22565), + 169: uint16(22566), + 170: uint16(22567), + 171: uint16(22568), + 172: uint16(22569), + 173: uint16(22571), + 174: uint16(22572), + 175: uint16(22573), + 176: uint16(22574), + 177: uint16(22575), + 178: uint16(22577), + 179: uint16(22578), + 180: uint16(22579), + 181: uint16(22580), + 182: uint16(22582), + 183: uint16(22583), + 184: uint16(22584), + 185: uint16(22585), + 186: uint16(22586), + 187: uint16(22587), + 188: uint16(22588), + 189: uint16(22589), + }, + 8: { + 0: uint16(22590), + 1: uint16(22591), + 2: uint16(22592), + 3: uint16(22593), + 4: uint16(22594), + 5: uint16(22595), + 6: uint16(22597), + 7: uint16(22598), + 8: uint16(22599), + 9: uint16(22600), + 10: uint16(22601), + 11: uint16(22602), + 12: uint16(22603), + 13: uint16(22606), + 14: uint16(22607), + 15: uint16(22608), + 16: uint16(22610), + 17: uint16(22611), + 18: uint16(22613), + 19: uint16(22614), + 20: uint16(22615), + 21: uint16(22617), + 22: uint16(22618), + 23: uint16(22619), + 24: uint16(22620), + 25: uint16(22621), + 26: uint16(22623), + 27: uint16(22624), + 28: uint16(22625), + 29: uint16(22626), + 30: uint16(22627), + 31: uint16(22628), + 32: uint16(22630), + 33: uint16(22631), + 34: uint16(22632), + 35: uint16(22633), + 36: uint16(22634), + 37: uint16(22637), + 38: uint16(22638), + 39: uint16(22639), + 40: uint16(22640), + 41: uint16(22641), + 42: uint16(22642), + 43: uint16(22643), + 44: uint16(22644), + 45: uint16(22645), + 46: uint16(22646), + 47: uint16(22647), + 48: uint16(22648), + 49: uint16(22649), + 50: uint16(22650), + 51: uint16(22651), + 52: uint16(22652), + 53: uint16(22653), + 54: uint16(22655), + 55: uint16(22658), + 56: uint16(22660), + 57: uint16(22662), + 58: uint16(22663), + 59: uint16(22664), + 60: uint16(22666), + 61: uint16(22667), + 62: uint16(22668), + 63: uint16(22669), + 64: uint16(22670), + 65: uint16(22671), + 66: uint16(22672), + 67: uint16(22673), + 68: uint16(22676), + 69: uint16(22677), + 70: uint16(22678), + 71: uint16(22679), + 72: uint16(22680), + 73: uint16(22683), + 74: uint16(22684), + 75: uint16(22685), + 76: uint16(22688), + 77: uint16(22689), + 78: uint16(22690), + 79: uint16(22691), + 80: uint16(22692), + 81: uint16(22693), + 82: uint16(22694), + 83: uint16(22695), + 84: uint16(22698), + 85: uint16(22699), + 86: uint16(22700), + 87: uint16(22701), + 88: uint16(22702), + 89: uint16(22703), + 90: uint16(22704), + 91: uint16(22705), + 92: uint16(22706), + 93: uint16(22707), + 94: uint16(22708), + 95: uint16(22709), + 96: uint16(22710), + 97: uint16(22711), + 98: uint16(22712), + 99: uint16(22713), + 100: uint16(22714), + 101: uint16(22715), + 102: uint16(22717), + 103: uint16(22718), + 104: uint16(22719), + 105: uint16(22720), + 106: uint16(22722), + 107: uint16(22723), + 108: uint16(22724), + 109: uint16(22726), + 110: uint16(22727), + 111: uint16(22728), + 112: uint16(22729), + 113: uint16(22730), + 114: uint16(22731), + 115: uint16(22732), + 116: uint16(22733), + 117: uint16(22734), + 118: uint16(22735), + 119: uint16(22736), + 120: uint16(22738), + 121: uint16(22739), + 122: uint16(22740), + 123: uint16(22742), + 124: uint16(22743), + 125: uint16(22744), + 126: uint16(22745), + 127: uint16(22746), + 128: uint16(22747), + 129: uint16(22748), + 130: uint16(22749), + 131: uint16(22750), + 132: uint16(22751), + 133: uint16(22752), + 134: uint16(22753), + 135: uint16(22754), + 136: uint16(22755), + 137: uint16(22757), + 138: uint16(22758), + 139: uint16(22759), + 140: uint16(22760), + 141: uint16(22761), + 142: uint16(22762), + 143: uint16(22765), + 144: uint16(22767), + 145: uint16(22769), + 146: uint16(22770), + 147: uint16(22772), + 148: uint16(22773), + 149: uint16(22775), + 150: uint16(22776), + 151: uint16(22778), + 152: uint16(22779), + 153: uint16(22780), + 154: uint16(22781), + 155: uint16(22782), + 156: uint16(22783), + 157: uint16(22784), + 158: uint16(22785), + 159: uint16(22787), + 160: uint16(22789), + 161: uint16(22790), + 162: uint16(22792), + 163: uint16(22793), + 164: uint16(22794), + 165: uint16(22795), + 166: uint16(22796), + 167: uint16(22798), + 168: uint16(22800), + 169: uint16(22801), + 170: uint16(22802), + 171: uint16(22803), + 172: uint16(22807), + 173: uint16(22808), + 174: uint16(22811), + 175: uint16(22813), + 176: uint16(22814), + 177: uint16(22816), + 178: uint16(22817), + 179: uint16(22818), + 180: uint16(22819), + 181: uint16(22822), + 182: uint16(22824), + 183: uint16(22828), + 184: uint16(22832), + 185: uint16(22834), + 186: uint16(22835), + 187: uint16(22837), + 188: uint16(22838), + 189: uint16(22843), + }, + 9: { + 0: uint16(22845), + 1: uint16(22846), + 2: uint16(22847), + 3: uint16(22848), + 4: uint16(22851), + 5: uint16(22853), + 6: uint16(22854), + 7: uint16(22858), + 8: uint16(22860), + 9: uint16(22861), + 10: uint16(22864), + 11: uint16(22866), + 12: uint16(22867), + 13: uint16(22873), + 14: uint16(22875), + 15: uint16(22876), + 16: uint16(22877), + 17: uint16(22878), + 18: uint16(22879), + 19: uint16(22881), + 20: uint16(22883), + 21: uint16(22884), + 22: uint16(22886), + 23: uint16(22887), + 24: uint16(22888), + 25: uint16(22889), + 26: uint16(22890), + 27: uint16(22891), + 28: uint16(22892), + 29: uint16(22893), + 30: uint16(22894), + 31: uint16(22895), + 32: uint16(22896), + 33: uint16(22897), + 34: uint16(22898), + 35: uint16(22901), + 36: uint16(22903), + 37: uint16(22906), + 38: uint16(22907), + 39: uint16(22908), + 40: uint16(22910), + 41: uint16(22911), + 42: uint16(22912), + 43: uint16(22917), + 44: uint16(22921), + 45: uint16(22923), + 46: uint16(22924), + 47: uint16(22926), + 48: uint16(22927), + 49: uint16(22928), + 50: uint16(22929), + 51: uint16(22932), + 52: uint16(22933), + 53: uint16(22936), + 54: uint16(22938), + 55: uint16(22939), + 56: uint16(22940), + 57: uint16(22941), + 58: uint16(22943), + 59: uint16(22944), + 60: uint16(22945), + 61: uint16(22946), + 62: uint16(22950), + 63: uint16(22951), + 64: uint16(22956), + 65: uint16(22957), + 66: uint16(22960), + 67: uint16(22961), + 68: uint16(22963), + 69: uint16(22964), + 70: uint16(22965), + 71: uint16(22966), + 72: uint16(22967), + 73: uint16(22968), + 74: uint16(22970), + 75: uint16(22972), + 76: uint16(22973), + 77: uint16(22975), + 78: uint16(22976), + 79: uint16(22977), + 80: uint16(22978), + 81: uint16(22979), + 82: uint16(22980), + 83: uint16(22981), + 84: uint16(22983), + 85: uint16(22984), + 86: uint16(22985), + 87: uint16(22988), + 88: uint16(22989), + 89: uint16(22990), + 90: uint16(22991), + 91: uint16(22997), + 92: uint16(22998), + 93: uint16(23001), + 94: uint16(23003), + 95: uint16(23006), + 96: uint16(23007), + 97: uint16(23008), + 98: uint16(23009), + 99: uint16(23010), + 100: uint16(23012), + 101: uint16(23014), + 102: uint16(23015), + 103: uint16(23017), + 104: uint16(23018), + 105: uint16(23019), + 106: uint16(23021), + 107: uint16(23022), + 108: uint16(23023), + 109: uint16(23024), + 110: uint16(23025), + 111: uint16(23026), + 112: uint16(23027), + 113: uint16(23028), + 114: uint16(23029), + 115: uint16(23030), + 116: uint16(23031), + 117: uint16(23032), + 118: uint16(23034), + 119: uint16(23036), + 120: uint16(23037), + 121: uint16(23038), + 122: uint16(23040), + 123: uint16(23042), + 124: uint16(23050), + 125: uint16(23051), + 126: uint16(23053), + 127: uint16(23054), + 128: uint16(23055), + 129: uint16(23056), + 130: uint16(23058), + 131: uint16(23060), + 132: uint16(23061), + 133: uint16(23062), + 134: uint16(23063), + 135: uint16(23065), + 136: uint16(23066), + 137: uint16(23067), + 138: uint16(23069), + 139: uint16(23070), + 140: uint16(23073), + 141: uint16(23074), + 142: uint16(23076), + 143: uint16(23078), + 144: uint16(23079), + 145: uint16(23080), + 146: uint16(23082), + 147: uint16(23083), + 148: uint16(23084), + 149: uint16(23085), + 150: uint16(23086), + 151: uint16(23087), + 152: uint16(23088), + 153: uint16(23091), + 154: uint16(23093), + 155: uint16(23095), + 156: uint16(23096), + 157: uint16(23097), + 158: uint16(23098), + 159: uint16(23099), + 160: uint16(23101), + 161: uint16(23102), + 162: uint16(23103), + 163: uint16(23105), + 164: uint16(23106), + 165: uint16(23107), + 166: uint16(23108), + 167: uint16(23109), + 168: uint16(23111), + 169: uint16(23112), + 170: uint16(23115), + 171: uint16(23116), + 172: uint16(23117), + 173: uint16(23118), + 174: uint16(23119), + 175: uint16(23120), + 176: uint16(23121), + 177: uint16(23122), + 178: uint16(23123), + 179: uint16(23124), + 180: uint16(23126), + 181: uint16(23127), + 182: uint16(23128), + 183: uint16(23129), + 184: uint16(23131), + 185: uint16(23132), + 186: uint16(23133), + 187: uint16(23134), + 188: uint16(23135), + 189: uint16(23136), + }, + 10: { + 0: uint16(23137), + 1: uint16(23139), + 2: uint16(23140), + 3: uint16(23141), + 4: uint16(23142), + 5: uint16(23144), + 6: uint16(23145), + 7: uint16(23147), + 8: uint16(23148), + 9: uint16(23149), + 10: uint16(23150), + 11: uint16(23151), + 12: uint16(23152), + 13: uint16(23153), + 14: uint16(23154), + 15: uint16(23155), + 16: uint16(23160), + 17: uint16(23161), + 18: uint16(23163), + 19: uint16(23164), + 20: uint16(23165), + 21: uint16(23166), + 22: uint16(23168), + 23: uint16(23169), + 24: uint16(23170), + 25: uint16(23171), + 26: uint16(23172), + 27: uint16(23173), + 28: uint16(23174), + 29: uint16(23175), + 30: uint16(23176), + 31: uint16(23177), + 32: uint16(23178), + 33: uint16(23179), + 34: uint16(23180), + 35: uint16(23181), + 36: uint16(23182), + 37: uint16(23183), + 38: uint16(23184), + 39: uint16(23185), + 40: uint16(23187), + 41: uint16(23188), + 42: uint16(23189), + 43: uint16(23190), + 44: uint16(23191), + 45: uint16(23192), + 46: uint16(23193), + 47: uint16(23196), + 48: uint16(23197), + 49: uint16(23198), + 50: uint16(23199), + 51: uint16(23200), + 52: uint16(23201), + 53: uint16(23202), + 54: uint16(23203), + 55: uint16(23204), + 56: uint16(23205), + 57: uint16(23206), + 58: uint16(23207), + 59: uint16(23208), + 60: uint16(23209), + 61: uint16(23211), + 62: uint16(23212), + 63: uint16(23213), + 64: uint16(23214), + 65: uint16(23215), + 66: uint16(23216), + 67: uint16(23217), + 68: uint16(23220), + 69: uint16(23222), + 70: uint16(23223), + 71: uint16(23225), + 72: uint16(23226), + 73: uint16(23227), + 74: uint16(23228), + 75: uint16(23229), + 76: uint16(23231), + 77: uint16(23232), + 78: uint16(23235), + 79: uint16(23236), + 80: uint16(23237), + 81: uint16(23238), + 82: uint16(23239), + 83: uint16(23240), + 84: uint16(23242), + 85: uint16(23243), + 86: uint16(23245), + 87: uint16(23246), + 88: uint16(23247), + 89: uint16(23248), + 90: uint16(23249), + 91: uint16(23251), + 92: uint16(23253), + 93: uint16(23255), + 94: uint16(23257), + 95: uint16(23258), + 96: uint16(23259), + 97: uint16(23261), + 98: uint16(23262), + 99: uint16(23263), + 100: uint16(23266), + 101: uint16(23268), + 102: uint16(23269), + 103: uint16(23271), + 104: uint16(23272), + 105: uint16(23274), + 106: uint16(23276), + 107: uint16(23277), + 108: uint16(23278), + 109: uint16(23279), + 110: uint16(23280), + 111: uint16(23282), + 112: uint16(23283), + 113: uint16(23284), + 114: uint16(23285), + 115: uint16(23286), + 116: uint16(23287), + 117: uint16(23288), + 118: uint16(23289), + 119: uint16(23290), + 120: uint16(23291), + 121: uint16(23292), + 122: uint16(23293), + 123: uint16(23294), + 124: uint16(23295), + 125: uint16(23296), + 126: uint16(23297), + 127: uint16(23298), + 128: uint16(23299), + 129: uint16(23300), + 130: uint16(23301), + 131: uint16(23302), + 132: uint16(23303), + 133: uint16(23304), + 134: uint16(23306), + 135: uint16(23307), + 136: uint16(23308), + 137: uint16(23309), + 138: uint16(23310), + 139: uint16(23311), + 140: uint16(23312), + 141: uint16(23313), + 142: uint16(23314), + 143: uint16(23315), + 144: uint16(23316), + 145: uint16(23317), + 146: uint16(23320), + 147: uint16(23321), + 148: uint16(23322), + 149: uint16(23323), + 150: uint16(23324), + 151: uint16(23325), + 152: uint16(23326), + 153: uint16(23327), + 154: uint16(23328), + 155: uint16(23329), + 156: uint16(23330), + 157: uint16(23331), + 158: uint16(23332), + 159: uint16(23333), + 160: uint16(23334), + 161: uint16(23335), + 162: uint16(23336), + 163: uint16(23337), + 164: uint16(23338), + 165: uint16(23339), + 166: uint16(23340), + 167: uint16(23341), + 168: uint16(23342), + 169: uint16(23343), + 170: uint16(23344), + 171: uint16(23345), + 172: uint16(23347), + 173: uint16(23349), + 174: uint16(23350), + 175: uint16(23352), + 176: uint16(23353), + 177: uint16(23354), + 178: uint16(23355), + 179: uint16(23356), + 180: uint16(23357), + 181: uint16(23358), + 182: uint16(23359), + 183: uint16(23361), + 184: uint16(23362), + 185: uint16(23363), + 186: uint16(23364), + 187: uint16(23365), + 188: uint16(23366), + 189: uint16(23367), + }, + 11: { + 0: uint16(23368), + 1: uint16(23369), + 2: uint16(23370), + 3: uint16(23371), + 4: uint16(23372), + 5: uint16(23373), + 6: uint16(23374), + 7: uint16(23375), + 8: uint16(23378), + 9: uint16(23382), + 10: uint16(23390), + 11: uint16(23392), + 12: uint16(23393), + 13: uint16(23399), + 14: uint16(23400), + 15: uint16(23403), + 16: uint16(23405), + 17: uint16(23406), + 18: uint16(23407), + 19: uint16(23410), + 20: uint16(23412), + 21: uint16(23414), + 22: uint16(23415), + 23: uint16(23416), + 24: uint16(23417), + 25: uint16(23419), + 26: uint16(23420), + 27: uint16(23422), + 28: uint16(23423), + 29: uint16(23426), + 30: uint16(23430), + 31: uint16(23434), + 32: uint16(23437), + 33: uint16(23438), + 34: uint16(23440), + 35: uint16(23441), + 36: uint16(23442), + 37: uint16(23444), + 38: uint16(23446), + 39: uint16(23455), + 40: uint16(23463), + 41: uint16(23464), + 42: uint16(23465), + 43: uint16(23468), + 44: uint16(23469), + 45: uint16(23470), + 46: uint16(23471), + 47: uint16(23473), + 48: uint16(23474), + 49: uint16(23479), + 50: uint16(23482), + 51: uint16(23483), + 52: uint16(23484), + 53: uint16(23488), + 54: uint16(23489), + 55: uint16(23491), + 56: uint16(23496), + 57: uint16(23497), + 58: uint16(23498), + 59: uint16(23499), + 60: uint16(23501), + 61: uint16(23502), + 62: uint16(23503), + 63: uint16(23505), + 64: uint16(23508), + 65: uint16(23509), + 66: uint16(23510), + 67: uint16(23511), + 68: uint16(23512), + 69: uint16(23513), + 70: uint16(23514), + 71: uint16(23515), + 72: uint16(23516), + 73: uint16(23520), + 74: uint16(23522), + 75: uint16(23523), + 76: uint16(23526), + 77: uint16(23527), + 78: uint16(23529), + 79: uint16(23530), + 80: uint16(23531), + 81: uint16(23532), + 82: uint16(23533), + 83: uint16(23535), + 84: uint16(23537), + 85: uint16(23538), + 86: uint16(23539), + 87: uint16(23540), + 88: uint16(23541), + 89: uint16(23542), + 90: uint16(23543), + 91: uint16(23549), + 92: uint16(23550), + 93: uint16(23552), + 94: uint16(23554), + 95: uint16(23555), + 96: uint16(23557), + 97: uint16(23559), + 98: uint16(23560), + 99: uint16(23563), + 100: uint16(23564), + 101: uint16(23565), + 102: uint16(23566), + 103: uint16(23568), + 104: uint16(23570), + 105: uint16(23571), + 106: uint16(23575), + 107: uint16(23577), + 108: uint16(23579), + 109: uint16(23582), + 110: uint16(23583), + 111: uint16(23584), + 112: uint16(23585), + 113: uint16(23587), + 114: uint16(23590), + 115: uint16(23592), + 116: uint16(23593), + 117: uint16(23594), + 118: uint16(23595), + 119: uint16(23597), + 120: uint16(23598), + 121: uint16(23599), + 122: uint16(23600), + 123: uint16(23602), + 124: uint16(23603), + 125: uint16(23605), + 126: uint16(23606), + 127: uint16(23607), + 128: uint16(23619), + 129: uint16(23620), + 130: uint16(23622), + 131: uint16(23623), + 132: uint16(23628), + 133: uint16(23629), + 134: uint16(23634), + 135: uint16(23635), + 136: uint16(23636), + 137: uint16(23638), + 138: uint16(23639), + 139: uint16(23640), + 140: uint16(23642), + 141: uint16(23643), + 142: uint16(23644), + 143: uint16(23645), + 144: uint16(23647), + 145: uint16(23650), + 146: uint16(23652), + 147: uint16(23655), + 148: uint16(23656), + 149: uint16(23657), + 150: uint16(23658), + 151: uint16(23659), + 152: uint16(23660), + 153: uint16(23661), + 154: uint16(23664), + 155: uint16(23666), + 156: uint16(23667), + 157: uint16(23668), + 158: uint16(23669), + 159: uint16(23670), + 160: uint16(23671), + 161: uint16(23672), + 162: uint16(23675), + 163: uint16(23676), + 164: uint16(23677), + 165: uint16(23678), + 166: uint16(23680), + 167: uint16(23683), + 168: uint16(23684), + 169: uint16(23685), + 170: uint16(23686), + 171: uint16(23687), + 172: uint16(23689), + 173: uint16(23690), + 174: uint16(23691), + 175: uint16(23694), + 176: uint16(23695), + 177: uint16(23698), + 178: uint16(23699), + 179: uint16(23701), + 180: uint16(23709), + 181: uint16(23710), + 182: uint16(23711), + 183: uint16(23712), + 184: uint16(23713), + 185: uint16(23716), + 186: uint16(23717), + 187: uint16(23718), + 188: uint16(23719), + 189: uint16(23720), + }, + 12: { + 0: uint16(23722), + 1: uint16(23726), + 2: uint16(23727), + 3: uint16(23728), + 4: uint16(23730), + 5: uint16(23732), + 6: uint16(23734), + 7: uint16(23737), + 8: uint16(23738), + 9: uint16(23739), + 10: uint16(23740), + 11: uint16(23742), + 12: uint16(23744), + 13: uint16(23746), + 14: uint16(23747), + 15: uint16(23749), + 16: uint16(23750), + 17: uint16(23751), + 18: uint16(23752), + 19: uint16(23753), + 20: uint16(23754), + 21: uint16(23756), + 22: uint16(23757), + 23: uint16(23758), + 24: uint16(23759), + 25: uint16(23760), + 26: uint16(23761), + 27: uint16(23763), + 28: uint16(23764), + 29: uint16(23765), + 30: uint16(23766), + 31: uint16(23767), + 32: uint16(23768), + 33: uint16(23770), + 34: uint16(23771), + 35: uint16(23772), + 36: uint16(23773), + 37: uint16(23774), + 38: uint16(23775), + 39: uint16(23776), + 40: uint16(23778), + 41: uint16(23779), + 42: uint16(23783), + 43: uint16(23785), + 44: uint16(23787), + 45: uint16(23788), + 46: uint16(23790), + 47: uint16(23791), + 48: uint16(23793), + 49: uint16(23794), + 50: uint16(23795), + 51: uint16(23796), + 52: uint16(23797), + 53: uint16(23798), + 54: uint16(23799), + 55: uint16(23800), + 56: uint16(23801), + 57: uint16(23802), + 58: uint16(23804), + 59: uint16(23805), + 60: uint16(23806), + 61: uint16(23807), + 62: uint16(23808), + 63: uint16(23809), + 64: uint16(23812), + 65: uint16(23813), + 66: uint16(23816), + 67: uint16(23817), + 68: uint16(23818), + 69: uint16(23819), + 70: uint16(23820), + 71: uint16(23821), + 72: uint16(23823), + 73: uint16(23824), + 74: uint16(23825), + 75: uint16(23826), + 76: uint16(23827), + 77: uint16(23829), + 78: uint16(23831), + 79: uint16(23832), + 80: uint16(23833), + 81: uint16(23834), + 82: uint16(23836), + 83: uint16(23837), + 84: uint16(23839), + 85: uint16(23840), + 86: uint16(23841), + 87: uint16(23842), + 88: uint16(23843), + 89: uint16(23845), + 90: uint16(23848), + 91: uint16(23850), + 92: uint16(23851), + 93: uint16(23852), + 94: uint16(23855), + 95: uint16(23856), + 96: uint16(23857), + 97: uint16(23858), + 98: uint16(23859), + 99: uint16(23861), + 100: uint16(23862), + 101: uint16(23863), + 102: uint16(23864), + 103: uint16(23865), + 104: uint16(23866), + 105: uint16(23867), + 106: uint16(23868), + 107: uint16(23871), + 108: uint16(23872), + 109: uint16(23873), + 110: uint16(23874), + 111: uint16(23875), + 112: uint16(23876), + 113: uint16(23877), + 114: uint16(23878), + 115: uint16(23880), + 116: uint16(23881), + 117: uint16(23885), + 118: uint16(23886), + 119: uint16(23887), + 120: uint16(23888), + 121: uint16(23889), + 122: uint16(23890), + 123: uint16(23891), + 124: uint16(23892), + 125: uint16(23893), + 126: uint16(23894), + 127: uint16(23895), + 128: uint16(23897), + 129: uint16(23898), + 130: uint16(23900), + 131: uint16(23902), + 132: uint16(23903), + 133: uint16(23904), + 134: uint16(23905), + 135: uint16(23906), + 136: uint16(23907), + 137: uint16(23908), + 138: uint16(23909), + 139: uint16(23910), + 140: uint16(23911), + 141: uint16(23912), + 142: uint16(23914), + 143: uint16(23917), + 144: uint16(23918), + 145: uint16(23920), + 146: uint16(23921), + 147: uint16(23922), + 148: uint16(23923), + 149: uint16(23925), + 150: uint16(23926), + 151: uint16(23927), + 152: uint16(23928), + 153: uint16(23929), + 154: uint16(23930), + 155: uint16(23931), + 156: uint16(23932), + 157: uint16(23933), + 158: uint16(23934), + 159: uint16(23935), + 160: uint16(23936), + 161: uint16(23937), + 162: uint16(23939), + 163: uint16(23940), + 164: uint16(23941), + 165: uint16(23942), + 166: uint16(23943), + 167: uint16(23944), + 168: uint16(23945), + 169: uint16(23946), + 170: uint16(23947), + 171: uint16(23948), + 172: uint16(23949), + 173: uint16(23950), + 174: uint16(23951), + 175: uint16(23952), + 176: uint16(23953), + 177: uint16(23954), + 178: uint16(23955), + 179: uint16(23956), + 180: uint16(23957), + 181: uint16(23958), + 182: uint16(23959), + 183: uint16(23960), + 184: uint16(23962), + 185: uint16(23963), + 186: uint16(23964), + 187: uint16(23966), + 188: uint16(23967), + 189: uint16(23968), + }, + 13: { + 0: uint16(23969), + 1: uint16(23970), + 2: uint16(23971), + 3: uint16(23972), + 4: uint16(23973), + 5: uint16(23974), + 6: uint16(23975), + 7: uint16(23976), + 8: uint16(23977), + 9: uint16(23978), + 10: uint16(23979), + 11: uint16(23980), + 12: uint16(23981), + 13: uint16(23982), + 14: uint16(23983), + 15: uint16(23984), + 16: uint16(23985), + 17: uint16(23986), + 18: uint16(23987), + 19: uint16(23988), + 20: uint16(23989), + 21: uint16(23990), + 22: uint16(23992), + 23: uint16(23993), + 24: uint16(23994), + 25: uint16(23995), + 26: uint16(23996), + 27: uint16(23997), + 28: uint16(23998), + 29: uint16(23999), + 30: uint16(24000), + 31: uint16(24001), + 32: uint16(24002), + 33: uint16(24003), + 34: uint16(24004), + 35: uint16(24006), + 36: uint16(24007), + 37: uint16(24008), + 38: uint16(24009), + 39: uint16(24010), + 40: uint16(24011), + 41: uint16(24012), + 42: uint16(24014), + 43: uint16(24015), + 44: uint16(24016), + 45: uint16(24017), + 46: uint16(24018), + 47: uint16(24019), + 48: uint16(24020), + 49: uint16(24021), + 50: uint16(24022), + 51: uint16(24023), + 52: uint16(24024), + 53: uint16(24025), + 54: uint16(24026), + 55: uint16(24028), + 56: uint16(24031), + 57: uint16(24032), + 58: uint16(24035), + 59: uint16(24036), + 60: uint16(24042), + 61: uint16(24044), + 62: uint16(24045), + 63: uint16(24048), + 64: uint16(24053), + 65: uint16(24054), + 66: uint16(24056), + 67: uint16(24057), + 68: uint16(24058), + 69: uint16(24059), + 70: uint16(24060), + 71: uint16(24063), + 72: uint16(24064), + 73: uint16(24068), + 74: uint16(24071), + 75: uint16(24073), + 76: uint16(24074), + 77: uint16(24075), + 78: uint16(24077), + 79: uint16(24078), + 80: uint16(24082), + 81: uint16(24083), + 82: uint16(24087), + 83: uint16(24094), + 84: uint16(24095), + 85: uint16(24096), + 86: uint16(24097), + 87: uint16(24098), + 88: uint16(24099), + 89: uint16(24100), + 90: uint16(24101), + 91: uint16(24104), + 92: uint16(24105), + 93: uint16(24106), + 94: uint16(24107), + 95: uint16(24108), + 96: uint16(24111), + 97: uint16(24112), + 98: uint16(24114), + 99: uint16(24115), + 100: uint16(24116), + 101: uint16(24117), + 102: uint16(24118), + 103: uint16(24121), + 104: uint16(24122), + 105: uint16(24126), + 106: uint16(24127), + 107: uint16(24128), + 108: uint16(24129), + 109: uint16(24131), + 110: uint16(24134), + 111: uint16(24135), + 112: uint16(24136), + 113: uint16(24137), + 114: uint16(24138), + 115: uint16(24139), + 116: uint16(24141), + 117: uint16(24142), + 118: uint16(24143), + 119: uint16(24144), + 120: uint16(24145), + 121: uint16(24146), + 122: uint16(24147), + 123: uint16(24150), + 124: uint16(24151), + 125: uint16(24152), + 126: uint16(24153), + 127: uint16(24154), + 128: uint16(24156), + 129: uint16(24157), + 130: uint16(24159), + 131: uint16(24160), + 132: uint16(24163), + 133: uint16(24164), + 134: uint16(24165), + 135: uint16(24166), + 136: uint16(24167), + 137: uint16(24168), + 138: uint16(24169), + 139: uint16(24170), + 140: uint16(24171), + 141: uint16(24172), + 142: uint16(24173), + 143: uint16(24174), + 144: uint16(24175), + 145: uint16(24176), + 146: uint16(24177), + 147: uint16(24181), + 148: uint16(24183), + 149: uint16(24185), + 150: uint16(24190), + 151: uint16(24193), + 152: uint16(24194), + 153: uint16(24195), + 154: uint16(24197), + 155: uint16(24200), + 156: uint16(24201), + 157: uint16(24204), + 158: uint16(24205), + 159: uint16(24206), + 160: uint16(24210), + 161: uint16(24216), + 162: uint16(24219), + 163: uint16(24221), + 164: uint16(24225), + 165: uint16(24226), + 166: uint16(24227), + 167: uint16(24228), + 168: uint16(24232), + 169: uint16(24233), + 170: uint16(24234), + 171: uint16(24235), + 172: uint16(24236), + 173: uint16(24238), + 174: uint16(24239), + 175: uint16(24240), + 176: uint16(24241), + 177: uint16(24242), + 178: uint16(24244), + 179: uint16(24250), + 180: uint16(24251), + 181: uint16(24252), + 182: uint16(24253), + 183: uint16(24255), + 184: uint16(24256), + 185: uint16(24257), + 186: uint16(24258), + 187: uint16(24259), + 188: uint16(24260), + 189: uint16(24261), + }, + 14: { + 0: uint16(24262), + 1: uint16(24263), + 2: uint16(24264), + 3: uint16(24267), + 4: uint16(24268), + 5: uint16(24269), + 6: uint16(24270), + 7: uint16(24271), + 8: uint16(24272), + 9: uint16(24276), + 10: uint16(24277), + 11: uint16(24279), + 12: uint16(24280), + 13: uint16(24281), + 14: uint16(24282), + 15: uint16(24284), + 16: uint16(24285), + 17: uint16(24286), + 18: uint16(24287), + 19: uint16(24288), + 20: uint16(24289), + 21: uint16(24290), + 22: uint16(24291), + 23: uint16(24292), + 24: uint16(24293), + 25: uint16(24294), + 26: uint16(24295), + 27: uint16(24297), + 28: uint16(24299), + 29: uint16(24300), + 30: uint16(24301), + 31: uint16(24302), + 32: uint16(24303), + 33: uint16(24304), + 34: uint16(24305), + 35: uint16(24306), + 36: uint16(24307), + 37: uint16(24309), + 38: uint16(24312), + 39: uint16(24313), + 40: uint16(24315), + 41: uint16(24316), + 42: uint16(24317), + 43: uint16(24325), + 44: uint16(24326), + 45: uint16(24327), + 46: uint16(24329), + 47: uint16(24332), + 48: uint16(24333), + 49: uint16(24334), + 50: uint16(24336), + 51: uint16(24338), + 52: uint16(24340), + 53: uint16(24342), + 54: uint16(24345), + 55: uint16(24346), + 56: uint16(24348), + 57: uint16(24349), + 58: uint16(24350), + 59: uint16(24353), + 60: uint16(24354), + 61: uint16(24355), + 62: uint16(24356), + 63: uint16(24360), + 64: uint16(24363), + 65: uint16(24364), + 66: uint16(24366), + 67: uint16(24368), + 68: uint16(24370), + 69: uint16(24371), + 70: uint16(24372), + 71: uint16(24373), + 72: uint16(24374), + 73: uint16(24375), + 74: uint16(24376), + 75: uint16(24379), + 76: uint16(24381), + 77: uint16(24382), + 78: uint16(24383), + 79: uint16(24385), + 80: uint16(24386), + 81: uint16(24387), + 82: uint16(24388), + 83: uint16(24389), + 84: uint16(24390), + 85: uint16(24391), + 86: uint16(24392), + 87: uint16(24393), + 88: uint16(24394), + 89: uint16(24395), + 90: uint16(24396), + 91: uint16(24397), + 92: uint16(24398), + 93: uint16(24399), + 94: uint16(24401), + 95: uint16(24404), + 96: uint16(24409), + 97: uint16(24410), + 98: uint16(24411), + 99: uint16(24412), + 100: uint16(24414), + 101: uint16(24415), + 102: uint16(24416), + 103: uint16(24419), + 104: uint16(24421), + 105: uint16(24423), + 106: uint16(24424), + 107: uint16(24427), + 108: uint16(24430), + 109: uint16(24431), + 110: uint16(24434), + 111: uint16(24436), + 112: uint16(24437), + 113: uint16(24438), + 114: uint16(24440), + 115: uint16(24442), + 116: uint16(24445), + 117: uint16(24446), + 118: uint16(24447), + 119: uint16(24451), + 120: uint16(24454), + 121: uint16(24461), + 122: uint16(24462), + 123: uint16(24463), + 124: uint16(24465), + 125: uint16(24467), + 126: uint16(24468), + 127: uint16(24470), + 128: uint16(24474), + 129: uint16(24475), + 130: uint16(24477), + 131: uint16(24478), + 132: uint16(24479), + 133: uint16(24480), + 134: uint16(24482), + 135: uint16(24483), + 136: uint16(24484), + 137: uint16(24485), + 138: uint16(24486), + 139: uint16(24487), + 140: uint16(24489), + 141: uint16(24491), + 142: uint16(24492), + 143: uint16(24495), + 144: uint16(24496), + 145: uint16(24497), + 146: uint16(24498), + 147: uint16(24499), + 148: uint16(24500), + 149: uint16(24502), + 150: uint16(24504), + 151: uint16(24505), + 152: uint16(24506), + 153: uint16(24507), + 154: uint16(24510), + 155: uint16(24511), + 156: uint16(24512), + 157: uint16(24513), + 158: uint16(24514), + 159: uint16(24519), + 160: uint16(24520), + 161: uint16(24522), + 162: uint16(24523), + 163: uint16(24526), + 164: uint16(24531), + 165: uint16(24532), + 166: uint16(24533), + 167: uint16(24538), + 168: uint16(24539), + 169: uint16(24540), + 170: uint16(24542), + 171: uint16(24543), + 172: uint16(24546), + 173: uint16(24547), + 174: uint16(24549), + 175: uint16(24550), + 176: uint16(24552), + 177: uint16(24553), + 178: uint16(24556), + 179: uint16(24559), + 180: uint16(24560), + 181: uint16(24562), + 182: uint16(24563), + 183: uint16(24564), + 184: uint16(24566), + 185: uint16(24567), + 186: uint16(24569), + 187: uint16(24570), + 188: uint16(24572), + 189: uint16(24583), + }, + 15: { + 0: uint16(24584), + 1: uint16(24585), + 2: uint16(24587), + 3: uint16(24588), + 4: uint16(24592), + 5: uint16(24593), + 6: uint16(24595), + 7: uint16(24599), + 8: uint16(24600), + 9: uint16(24602), + 10: uint16(24606), + 11: uint16(24607), + 12: uint16(24610), + 13: uint16(24611), + 14: uint16(24612), + 15: uint16(24620), + 16: uint16(24621), + 17: uint16(24622), + 18: uint16(24624), + 19: uint16(24625), + 20: uint16(24626), + 21: uint16(24627), + 22: uint16(24628), + 23: uint16(24630), + 24: uint16(24631), + 25: uint16(24632), + 26: uint16(24633), + 27: uint16(24634), + 28: uint16(24637), + 29: uint16(24638), + 30: uint16(24640), + 31: uint16(24644), + 32: uint16(24645), + 33: uint16(24646), + 34: uint16(24647), + 35: uint16(24648), + 36: uint16(24649), + 37: uint16(24650), + 38: uint16(24652), + 39: uint16(24654), + 40: uint16(24655), + 41: uint16(24657), + 42: uint16(24659), + 43: uint16(24660), + 44: uint16(24662), + 45: uint16(24663), + 46: uint16(24664), + 47: uint16(24667), + 48: uint16(24668), + 49: uint16(24670), + 50: uint16(24671), + 51: uint16(24672), + 52: uint16(24673), + 53: uint16(24677), + 54: uint16(24678), + 55: uint16(24686), + 56: uint16(24689), + 57: uint16(24690), + 58: uint16(24692), + 59: uint16(24693), + 60: uint16(24695), + 61: uint16(24702), + 62: uint16(24704), + 63: uint16(24705), + 64: uint16(24706), + 65: uint16(24709), + 66: uint16(24710), + 67: uint16(24711), + 68: uint16(24712), + 69: uint16(24714), + 70: uint16(24715), + 71: uint16(24718), + 72: uint16(24719), + 73: uint16(24720), + 74: uint16(24721), + 75: uint16(24723), + 76: uint16(24725), + 77: uint16(24727), + 78: uint16(24728), + 79: uint16(24729), + 80: uint16(24732), + 81: uint16(24734), + 82: uint16(24737), + 83: uint16(24738), + 84: uint16(24740), + 85: uint16(24741), + 86: uint16(24743), + 87: uint16(24745), + 88: uint16(24746), + 89: uint16(24750), + 90: uint16(24752), + 91: uint16(24755), + 92: uint16(24757), + 93: uint16(24758), + 94: uint16(24759), + 95: uint16(24761), + 96: uint16(24762), + 97: uint16(24765), + 98: uint16(24766), + 99: uint16(24767), + 100: uint16(24768), + 101: uint16(24769), + 102: uint16(24770), + 103: uint16(24771), + 104: uint16(24772), + 105: uint16(24775), + 106: uint16(24776), + 107: uint16(24777), + 108: uint16(24780), + 109: uint16(24781), + 110: uint16(24782), + 111: uint16(24783), + 112: uint16(24784), + 113: uint16(24786), + 114: uint16(24787), + 115: uint16(24788), + 116: uint16(24790), + 117: uint16(24791), + 118: uint16(24793), + 119: uint16(24795), + 120: uint16(24798), + 121: uint16(24801), + 122: uint16(24802), + 123: uint16(24803), + 124: uint16(24804), + 125: uint16(24805), + 126: uint16(24810), + 127: uint16(24817), + 128: uint16(24818), + 129: uint16(24821), + 130: uint16(24823), + 131: uint16(24824), + 132: uint16(24827), + 133: uint16(24828), + 134: uint16(24829), + 135: uint16(24830), + 136: uint16(24831), + 137: uint16(24834), + 138: uint16(24835), + 139: uint16(24836), + 140: uint16(24837), + 141: uint16(24839), + 142: uint16(24842), + 143: uint16(24843), + 144: uint16(24844), + 145: uint16(24848), + 146: uint16(24849), + 147: uint16(24850), + 148: uint16(24851), + 149: uint16(24852), + 150: uint16(24854), + 151: uint16(24855), + 152: uint16(24856), + 153: uint16(24857), + 154: uint16(24859), + 155: uint16(24860), + 156: uint16(24861), + 157: uint16(24862), + 158: uint16(24865), + 159: uint16(24866), + 160: uint16(24869), + 161: uint16(24872), + 162: uint16(24873), + 163: uint16(24874), + 164: uint16(24876), + 165: uint16(24877), + 166: uint16(24878), + 167: uint16(24879), + 168: uint16(24880), + 169: uint16(24881), + 170: uint16(24882), + 171: uint16(24883), + 172: uint16(24884), + 173: uint16(24885), + 174: uint16(24886), + 175: uint16(24887), + 176: uint16(24888), + 177: uint16(24889), + 178: uint16(24890), + 179: uint16(24891), + 180: uint16(24892), + 181: uint16(24893), + 182: uint16(24894), + 183: uint16(24896), + 184: uint16(24897), + 185: uint16(24898), + 186: uint16(24899), + 187: uint16(24900), + 188: uint16(24901), + 189: uint16(24902), + }, + 16: { + 0: uint16(24903), + 1: uint16(24905), + 2: uint16(24907), + 3: uint16(24909), + 4: uint16(24911), + 5: uint16(24912), + 6: uint16(24914), + 7: uint16(24915), + 8: uint16(24916), + 9: uint16(24918), + 10: uint16(24919), + 11: uint16(24920), + 12: uint16(24921), + 13: uint16(24922), + 14: uint16(24923), + 15: uint16(24924), + 16: uint16(24926), + 17: uint16(24927), + 18: uint16(24928), + 19: uint16(24929), + 20: uint16(24931), + 21: uint16(24932), + 22: uint16(24933), + 23: uint16(24934), + 24: uint16(24937), + 25: uint16(24938), + 26: uint16(24939), + 27: uint16(24940), + 28: uint16(24941), + 29: uint16(24942), + 30: uint16(24943), + 31: uint16(24945), + 32: uint16(24946), + 33: uint16(24947), + 34: uint16(24948), + 35: uint16(24950), + 36: uint16(24952), + 37: uint16(24953), + 38: uint16(24954), + 39: uint16(24955), + 40: uint16(24956), + 41: uint16(24957), + 42: uint16(24958), + 43: uint16(24959), + 44: uint16(24960), + 45: uint16(24961), + 46: uint16(24962), + 47: uint16(24963), + 48: uint16(24964), + 49: uint16(24965), + 50: uint16(24966), + 51: uint16(24967), + 52: uint16(24968), + 53: uint16(24969), + 54: uint16(24970), + 55: uint16(24972), + 56: uint16(24973), + 57: uint16(24975), + 58: uint16(24976), + 59: uint16(24977), + 60: uint16(24978), + 61: uint16(24979), + 62: uint16(24981), + 63: uint16(24982), + 64: uint16(24983), + 65: uint16(24984), + 66: uint16(24985), + 67: uint16(24986), + 68: uint16(24987), + 69: uint16(24988), + 70: uint16(24990), + 71: uint16(24991), + 72: uint16(24992), + 73: uint16(24993), + 74: uint16(24994), + 75: uint16(24995), + 76: uint16(24996), + 77: uint16(24997), + 78: uint16(24998), + 79: uint16(25002), + 80: uint16(25003), + 81: uint16(25005), + 82: uint16(25006), + 83: uint16(25007), + 84: uint16(25008), + 85: uint16(25009), + 86: uint16(25010), + 87: uint16(25011), + 88: uint16(25012), + 89: uint16(25013), + 90: uint16(25014), + 91: uint16(25016), + 92: uint16(25017), + 93: uint16(25018), + 94: uint16(25019), + 95: uint16(25020), + 96: uint16(25021), + 97: uint16(25023), + 98: uint16(25024), + 99: uint16(25025), + 100: uint16(25027), + 101: uint16(25028), + 102: uint16(25029), + 103: uint16(25030), + 104: uint16(25031), + 105: uint16(25033), + 106: uint16(25036), + 107: uint16(25037), + 108: uint16(25038), + 109: uint16(25039), + 110: uint16(25040), + 111: uint16(25043), + 112: uint16(25045), + 113: uint16(25046), + 114: uint16(25047), + 115: uint16(25048), + 116: uint16(25049), + 117: uint16(25050), + 118: uint16(25051), + 119: uint16(25052), + 120: uint16(25053), + 121: uint16(25054), + 122: uint16(25055), + 123: uint16(25056), + 124: uint16(25057), + 125: uint16(25058), + 126: uint16(25059), + 127: uint16(25060), + 128: uint16(25061), + 129: uint16(25063), + 130: uint16(25064), + 131: uint16(25065), + 132: uint16(25066), + 133: uint16(25067), + 134: uint16(25068), + 135: uint16(25069), + 136: uint16(25070), + 137: uint16(25071), + 138: uint16(25072), + 139: uint16(25073), + 140: uint16(25074), + 141: uint16(25075), + 142: uint16(25076), + 143: uint16(25078), + 144: uint16(25079), + 145: uint16(25080), + 146: uint16(25081), + 147: uint16(25082), + 148: uint16(25083), + 149: uint16(25084), + 150: uint16(25085), + 151: uint16(25086), + 152: uint16(25088), + 153: uint16(25089), + 154: uint16(25090), + 155: uint16(25091), + 156: uint16(25092), + 157: uint16(25093), + 158: uint16(25095), + 159: uint16(25097), + 160: uint16(25107), + 161: uint16(25108), + 162: uint16(25113), + 163: uint16(25116), + 164: uint16(25117), + 165: uint16(25118), + 166: uint16(25120), + 167: uint16(25123), + 168: uint16(25126), + 169: uint16(25127), + 170: uint16(25128), + 171: uint16(25129), + 172: uint16(25131), + 173: uint16(25133), + 174: uint16(25135), + 175: uint16(25136), + 176: uint16(25137), + 177: uint16(25138), + 178: uint16(25141), + 179: uint16(25142), + 180: uint16(25144), + 181: uint16(25145), + 182: uint16(25146), + 183: uint16(25147), + 184: uint16(25148), + 185: uint16(25154), + 186: uint16(25156), + 187: uint16(25157), + 188: uint16(25158), + 189: uint16(25162), + }, + 17: { + 0: uint16(25167), + 1: uint16(25168), + 2: uint16(25173), + 3: uint16(25174), + 4: uint16(25175), + 5: uint16(25177), + 6: uint16(25178), + 7: uint16(25180), + 8: uint16(25181), + 9: uint16(25182), + 10: uint16(25183), + 11: uint16(25184), + 12: uint16(25185), + 13: uint16(25186), + 14: uint16(25188), + 15: uint16(25189), + 16: uint16(25192), + 17: uint16(25201), + 18: uint16(25202), + 19: uint16(25204), + 20: uint16(25205), + 21: uint16(25207), + 22: uint16(25208), + 23: uint16(25210), + 24: uint16(25211), + 25: uint16(25213), + 26: uint16(25217), + 27: uint16(25218), + 28: uint16(25219), + 29: uint16(25221), + 30: uint16(25222), + 31: uint16(25223), + 32: uint16(25224), + 33: uint16(25227), + 34: uint16(25228), + 35: uint16(25229), + 36: uint16(25230), + 37: uint16(25231), + 38: uint16(25232), + 39: uint16(25236), + 40: uint16(25241), + 41: uint16(25244), + 42: uint16(25245), + 43: uint16(25246), + 44: uint16(25251), + 45: uint16(25254), + 46: uint16(25255), + 47: uint16(25257), + 48: uint16(25258), + 49: uint16(25261), + 50: uint16(25262), + 51: uint16(25263), + 52: uint16(25264), + 53: uint16(25266), + 54: uint16(25267), + 55: uint16(25268), + 56: uint16(25270), + 57: uint16(25271), + 58: uint16(25272), + 59: uint16(25274), + 60: uint16(25278), + 61: uint16(25280), + 62: uint16(25281), + 63: uint16(25283), + 64: uint16(25291), + 65: uint16(25295), + 66: uint16(25297), + 67: uint16(25301), + 68: uint16(25309), + 69: uint16(25310), + 70: uint16(25312), + 71: uint16(25313), + 72: uint16(25316), + 73: uint16(25322), + 74: uint16(25323), + 75: uint16(25328), + 76: uint16(25330), + 77: uint16(25333), + 78: uint16(25336), + 79: uint16(25337), + 80: uint16(25338), + 81: uint16(25339), + 82: uint16(25344), + 83: uint16(25347), + 84: uint16(25348), + 85: uint16(25349), + 86: uint16(25350), + 87: uint16(25354), + 88: uint16(25355), + 89: uint16(25356), + 90: uint16(25357), + 91: uint16(25359), + 92: uint16(25360), + 93: uint16(25362), + 94: uint16(25363), + 95: uint16(25364), + 96: uint16(25365), + 97: uint16(25367), + 98: uint16(25368), + 99: uint16(25369), + 100: uint16(25372), + 101: uint16(25382), + 102: uint16(25383), + 103: uint16(25385), + 104: uint16(25388), + 105: uint16(25389), + 106: uint16(25390), + 107: uint16(25392), + 108: uint16(25393), + 109: uint16(25395), + 110: uint16(25396), + 111: uint16(25397), + 112: uint16(25398), + 113: uint16(25399), + 114: uint16(25400), + 115: uint16(25403), + 116: uint16(25404), + 117: uint16(25406), + 118: uint16(25407), + 119: uint16(25408), + 120: uint16(25409), + 121: uint16(25412), + 122: uint16(25415), + 123: uint16(25416), + 124: uint16(25418), + 125: uint16(25425), + 126: uint16(25426), + 127: uint16(25427), + 128: uint16(25428), + 129: uint16(25430), + 130: uint16(25431), + 131: uint16(25432), + 132: uint16(25433), + 133: uint16(25434), + 134: uint16(25435), + 135: uint16(25436), + 136: uint16(25437), + 137: uint16(25440), + 138: uint16(25444), + 139: uint16(25445), + 140: uint16(25446), + 141: uint16(25448), + 142: uint16(25450), + 143: uint16(25451), + 144: uint16(25452), + 145: uint16(25455), + 146: uint16(25456), + 147: uint16(25458), + 148: uint16(25459), + 149: uint16(25460), + 150: uint16(25461), + 151: uint16(25464), + 152: uint16(25465), + 153: uint16(25468), + 154: uint16(25469), + 155: uint16(25470), + 156: uint16(25471), + 157: uint16(25473), + 158: uint16(25475), + 159: uint16(25476), + 160: uint16(25477), + 161: uint16(25478), + 162: uint16(25483), + 163: uint16(25485), + 164: uint16(25489), + 165: uint16(25491), + 166: uint16(25492), + 167: uint16(25493), + 168: uint16(25495), + 169: uint16(25497), + 170: uint16(25498), + 171: uint16(25499), + 172: uint16(25500), + 173: uint16(25501), + 174: uint16(25502), + 175: uint16(25503), + 176: uint16(25505), + 177: uint16(25508), + 178: uint16(25510), + 179: uint16(25515), + 180: uint16(25519), + 181: uint16(25521), + 182: uint16(25522), + 183: uint16(25525), + 184: uint16(25526), + 185: uint16(25529), + 186: uint16(25531), + 187: uint16(25533), + 188: uint16(25535), + 189: uint16(25536), + }, + 18: { + 0: uint16(25537), + 1: uint16(25538), + 2: uint16(25539), + 3: uint16(25541), + 4: uint16(25543), + 5: uint16(25544), + 6: uint16(25546), + 7: uint16(25547), + 8: uint16(25548), + 9: uint16(25553), + 10: uint16(25555), + 11: uint16(25556), + 12: uint16(25557), + 13: uint16(25559), + 14: uint16(25560), + 15: uint16(25561), + 16: uint16(25562), + 17: uint16(25563), + 18: uint16(25564), + 19: uint16(25565), + 20: uint16(25567), + 21: uint16(25570), + 22: uint16(25572), + 23: uint16(25573), + 24: uint16(25574), + 25: uint16(25575), + 26: uint16(25576), + 27: uint16(25579), + 28: uint16(25580), + 29: uint16(25582), + 30: uint16(25583), + 31: uint16(25584), + 32: uint16(25585), + 33: uint16(25587), + 34: uint16(25589), + 35: uint16(25591), + 36: uint16(25593), + 37: uint16(25594), + 38: uint16(25595), + 39: uint16(25596), + 40: uint16(25598), + 41: uint16(25603), + 42: uint16(25604), + 43: uint16(25606), + 44: uint16(25607), + 45: uint16(25608), + 46: uint16(25609), + 47: uint16(25610), + 48: uint16(25613), + 49: uint16(25614), + 50: uint16(25617), + 51: uint16(25618), + 52: uint16(25621), + 53: uint16(25622), + 54: uint16(25623), + 55: uint16(25624), + 56: uint16(25625), + 57: uint16(25626), + 58: uint16(25629), + 59: uint16(25631), + 60: uint16(25634), + 61: uint16(25635), + 62: uint16(25636), + 63: uint16(25637), + 64: uint16(25639), + 65: uint16(25640), + 66: uint16(25641), + 67: uint16(25643), + 68: uint16(25646), + 69: uint16(25647), + 70: uint16(25648), + 71: uint16(25649), + 72: uint16(25650), + 73: uint16(25651), + 74: uint16(25653), + 75: uint16(25654), + 76: uint16(25655), + 77: uint16(25656), + 78: uint16(25657), + 79: uint16(25659), + 80: uint16(25660), + 81: uint16(25662), + 82: uint16(25664), + 83: uint16(25666), + 84: uint16(25667), + 85: uint16(25673), + 86: uint16(25675), + 87: uint16(25676), + 88: uint16(25677), + 89: uint16(25678), + 90: uint16(25679), + 91: uint16(25680), + 92: uint16(25681), + 93: uint16(25683), + 94: uint16(25685), + 95: uint16(25686), + 96: uint16(25687), + 97: uint16(25689), + 98: uint16(25690), + 99: uint16(25691), + 100: uint16(25692), + 101: uint16(25693), + 102: uint16(25695), + 103: uint16(25696), + 104: uint16(25697), + 105: uint16(25698), + 106: uint16(25699), + 107: uint16(25700), + 108: uint16(25701), + 109: uint16(25702), + 110: uint16(25704), + 111: uint16(25706), + 112: uint16(25707), + 113: uint16(25708), + 114: uint16(25710), + 115: uint16(25711), + 116: uint16(25712), + 117: uint16(25713), + 118: uint16(25714), + 119: uint16(25715), + 120: uint16(25716), + 121: uint16(25717), + 122: uint16(25718), + 123: uint16(25719), + 124: uint16(25723), + 125: uint16(25724), + 126: uint16(25725), + 127: uint16(25726), + 128: uint16(25727), + 129: uint16(25728), + 130: uint16(25729), + 131: uint16(25731), + 132: uint16(25734), + 133: uint16(25736), + 134: uint16(25737), + 135: uint16(25738), + 136: uint16(25739), + 137: uint16(25740), + 138: uint16(25741), + 139: uint16(25742), + 140: uint16(25743), + 141: uint16(25744), + 142: uint16(25747), + 143: uint16(25748), + 144: uint16(25751), + 145: uint16(25752), + 146: uint16(25754), + 147: uint16(25755), + 148: uint16(25756), + 149: uint16(25757), + 150: uint16(25759), + 151: uint16(25760), + 152: uint16(25761), + 153: uint16(25762), + 154: uint16(25763), + 155: uint16(25765), + 156: uint16(25766), + 157: uint16(25767), + 158: uint16(25768), + 159: uint16(25770), + 160: uint16(25771), + 161: uint16(25775), + 162: uint16(25777), + 163: uint16(25778), + 164: uint16(25779), + 165: uint16(25780), + 166: uint16(25782), + 167: uint16(25785), + 168: uint16(25787), + 169: uint16(25789), + 170: uint16(25790), + 171: uint16(25791), + 172: uint16(25793), + 173: uint16(25795), + 174: uint16(25796), + 175: uint16(25798), + 176: uint16(25799), + 177: uint16(25800), + 178: uint16(25801), + 179: uint16(25802), + 180: uint16(25803), + 181: uint16(25804), + 182: uint16(25807), + 183: uint16(25809), + 184: uint16(25811), + 185: uint16(25812), + 186: uint16(25813), + 187: uint16(25814), + 188: uint16(25817), + 189: uint16(25818), + }, + 19: { + 0: uint16(25819), + 1: uint16(25820), + 2: uint16(25821), + 3: uint16(25823), + 4: uint16(25824), + 5: uint16(25825), + 6: uint16(25827), + 7: uint16(25829), + 8: uint16(25831), + 9: uint16(25832), + 10: uint16(25833), + 11: uint16(25834), + 12: uint16(25835), + 13: uint16(25836), + 14: uint16(25837), + 15: uint16(25838), + 16: uint16(25839), + 17: uint16(25840), + 18: uint16(25841), + 19: uint16(25842), + 20: uint16(25843), + 21: uint16(25844), + 22: uint16(25845), + 23: uint16(25846), + 24: uint16(25847), + 25: uint16(25848), + 26: uint16(25849), + 27: uint16(25850), + 28: uint16(25851), + 29: uint16(25852), + 30: uint16(25853), + 31: uint16(25854), + 32: uint16(25855), + 33: uint16(25857), + 34: uint16(25858), + 35: uint16(25859), + 36: uint16(25860), + 37: uint16(25861), + 38: uint16(25862), + 39: uint16(25863), + 40: uint16(25864), + 41: uint16(25866), + 42: uint16(25867), + 43: uint16(25868), + 44: uint16(25869), + 45: uint16(25870), + 46: uint16(25871), + 47: uint16(25872), + 48: uint16(25873), + 49: uint16(25875), + 50: uint16(25876), + 51: uint16(25877), + 52: uint16(25878), + 53: uint16(25879), + 54: uint16(25881), + 55: uint16(25882), + 56: uint16(25883), + 57: uint16(25884), + 58: uint16(25885), + 59: uint16(25886), + 60: uint16(25887), + 61: uint16(25888), + 62: uint16(25889), + 63: uint16(25890), + 64: uint16(25891), + 65: uint16(25892), + 66: uint16(25894), + 67: uint16(25895), + 68: uint16(25896), + 69: uint16(25897), + 70: uint16(25898), + 71: uint16(25900), + 72: uint16(25901), + 73: uint16(25904), + 74: uint16(25905), + 75: uint16(25906), + 76: uint16(25907), + 77: uint16(25911), + 78: uint16(25914), + 79: uint16(25916), + 80: uint16(25917), + 81: uint16(25920), + 82: uint16(25921), + 83: uint16(25922), + 84: uint16(25923), + 85: uint16(25924), + 86: uint16(25926), + 87: uint16(25927), + 88: uint16(25930), + 89: uint16(25931), + 90: uint16(25933), + 91: uint16(25934), + 92: uint16(25936), + 93: uint16(25938), + 94: uint16(25939), + 95: uint16(25940), + 96: uint16(25943), + 97: uint16(25944), + 98: uint16(25946), + 99: uint16(25948), + 100: uint16(25951), + 101: uint16(25952), + 102: uint16(25953), + 103: uint16(25956), + 104: uint16(25957), + 105: uint16(25959), + 106: uint16(25960), + 107: uint16(25961), + 108: uint16(25962), + 109: uint16(25965), + 110: uint16(25966), + 111: uint16(25967), + 112: uint16(25969), + 113: uint16(25971), + 114: uint16(25973), + 115: uint16(25974), + 116: uint16(25976), + 117: uint16(25977), + 118: uint16(25978), + 119: uint16(25979), + 120: uint16(25980), + 121: uint16(25981), + 122: uint16(25982), + 123: uint16(25983), + 124: uint16(25984), + 125: uint16(25985), + 126: uint16(25986), + 127: uint16(25987), + 128: uint16(25988), + 129: uint16(25989), + 130: uint16(25990), + 131: uint16(25992), + 132: uint16(25993), + 133: uint16(25994), + 134: uint16(25997), + 135: uint16(25998), + 136: uint16(25999), + 137: uint16(26002), + 138: uint16(26004), + 139: uint16(26005), + 140: uint16(26006), + 141: uint16(26008), + 142: uint16(26010), + 143: uint16(26013), + 144: uint16(26014), + 145: uint16(26016), + 146: uint16(26018), + 147: uint16(26019), + 148: uint16(26022), + 149: uint16(26024), + 150: uint16(26026), + 151: uint16(26028), + 152: uint16(26030), + 153: uint16(26033), + 154: uint16(26034), + 155: uint16(26035), + 156: uint16(26036), + 157: uint16(26037), + 158: uint16(26038), + 159: uint16(26039), + 160: uint16(26040), + 161: uint16(26042), + 162: uint16(26043), + 163: uint16(26046), + 164: uint16(26047), + 165: uint16(26048), + 166: uint16(26050), + 167: uint16(26055), + 168: uint16(26056), + 169: uint16(26057), + 170: uint16(26058), + 171: uint16(26061), + 172: uint16(26064), + 173: uint16(26065), + 174: uint16(26067), + 175: uint16(26068), + 176: uint16(26069), + 177: uint16(26072), + 178: uint16(26073), + 179: uint16(26074), + 180: uint16(26075), + 181: uint16(26076), + 182: uint16(26077), + 183: uint16(26078), + 184: uint16(26079), + 185: uint16(26081), + 186: uint16(26083), + 187: uint16(26084), + 188: uint16(26090), + 189: uint16(26091), + }, + 20: { + 0: uint16(26098), + 1: uint16(26099), + 2: uint16(26100), + 3: uint16(26101), + 4: uint16(26104), + 5: uint16(26105), + 6: uint16(26107), + 7: uint16(26108), + 8: uint16(26109), + 9: uint16(26110), + 10: uint16(26111), + 11: uint16(26113), + 12: uint16(26116), + 13: uint16(26117), + 14: uint16(26119), + 15: uint16(26120), + 16: uint16(26121), + 17: uint16(26123), + 18: uint16(26125), + 19: uint16(26128), + 20: uint16(26129), + 21: uint16(26130), + 22: uint16(26134), + 23: uint16(26135), + 24: uint16(26136), + 25: uint16(26138), + 26: uint16(26139), + 27: uint16(26140), + 28: uint16(26142), + 29: uint16(26145), + 30: uint16(26146), + 31: uint16(26147), + 32: uint16(26148), + 33: uint16(26150), + 34: uint16(26153), + 35: uint16(26154), + 36: uint16(26155), + 37: uint16(26156), + 38: uint16(26158), + 39: uint16(26160), + 40: uint16(26162), + 41: uint16(26163), + 42: uint16(26167), + 43: uint16(26168), + 44: uint16(26169), + 45: uint16(26170), + 46: uint16(26171), + 47: uint16(26173), + 48: uint16(26175), + 49: uint16(26176), + 50: uint16(26178), + 51: uint16(26180), + 52: uint16(26181), + 53: uint16(26182), + 54: uint16(26183), + 55: uint16(26184), + 56: uint16(26185), + 57: uint16(26186), + 58: uint16(26189), + 59: uint16(26190), + 60: uint16(26192), + 61: uint16(26193), + 62: uint16(26200), + 63: uint16(26201), + 64: uint16(26203), + 65: uint16(26204), + 66: uint16(26205), + 67: uint16(26206), + 68: uint16(26208), + 69: uint16(26210), + 70: uint16(26211), + 71: uint16(26213), + 72: uint16(26215), + 73: uint16(26217), + 74: uint16(26218), + 75: uint16(26219), + 76: uint16(26220), + 77: uint16(26221), + 78: uint16(26225), + 79: uint16(26226), + 80: uint16(26227), + 81: uint16(26229), + 82: uint16(26232), + 83: uint16(26233), + 84: uint16(26235), + 85: uint16(26236), + 86: uint16(26237), + 87: uint16(26239), + 88: uint16(26240), + 89: uint16(26241), + 90: uint16(26243), + 91: uint16(26245), + 92: uint16(26246), + 93: uint16(26248), + 94: uint16(26249), + 95: uint16(26250), + 96: uint16(26251), + 97: uint16(26253), + 98: uint16(26254), + 99: uint16(26255), + 100: uint16(26256), + 101: uint16(26258), + 102: uint16(26259), + 103: uint16(26260), + 104: uint16(26261), + 105: uint16(26264), + 106: uint16(26265), + 107: uint16(26266), + 108: uint16(26267), + 109: uint16(26268), + 110: uint16(26270), + 111: uint16(26271), + 112: uint16(26272), + 113: uint16(26273), + 114: uint16(26274), + 115: uint16(26275), + 116: uint16(26276), + 117: uint16(26277), + 118: uint16(26278), + 119: uint16(26281), + 120: uint16(26282), + 121: uint16(26283), + 122: uint16(26284), + 123: uint16(26285), + 124: uint16(26287), + 125: uint16(26288), + 126: uint16(26289), + 127: uint16(26290), + 128: uint16(26291), + 129: uint16(26293), + 130: uint16(26294), + 131: uint16(26295), + 132: uint16(26296), + 133: uint16(26298), + 134: uint16(26299), + 135: uint16(26300), + 136: uint16(26301), + 137: uint16(26303), + 138: uint16(26304), + 139: uint16(26305), + 140: uint16(26306), + 141: uint16(26307), + 142: uint16(26308), + 143: uint16(26309), + 144: uint16(26310), + 145: uint16(26311), + 146: uint16(26312), + 147: uint16(26313), + 148: uint16(26314), + 149: uint16(26315), + 150: uint16(26316), + 151: uint16(26317), + 152: uint16(26318), + 153: uint16(26319), + 154: uint16(26320), + 155: uint16(26321), + 156: uint16(26322), + 157: uint16(26323), + 158: uint16(26324), + 159: uint16(26325), + 160: uint16(26326), + 161: uint16(26327), + 162: uint16(26328), + 163: uint16(26330), + 164: uint16(26334), + 165: uint16(26335), + 166: uint16(26336), + 167: uint16(26337), + 168: uint16(26338), + 169: uint16(26339), + 170: uint16(26340), + 171: uint16(26341), + 172: uint16(26343), + 173: uint16(26344), + 174: uint16(26346), + 175: uint16(26347), + 176: uint16(26348), + 177: uint16(26349), + 178: uint16(26350), + 179: uint16(26351), + 180: uint16(26353), + 181: uint16(26357), + 182: uint16(26358), + 183: uint16(26360), + 184: uint16(26362), + 185: uint16(26363), + 186: uint16(26365), + 187: uint16(26369), + 188: uint16(26370), + 189: uint16(26371), + }, + 21: { + 0: uint16(26372), + 1: uint16(26373), + 2: uint16(26374), + 3: uint16(26375), + 4: uint16(26380), + 5: uint16(26382), + 6: uint16(26383), + 7: uint16(26385), + 8: uint16(26386), + 9: uint16(26387), + 10: uint16(26390), + 11: uint16(26392), + 12: uint16(26393), + 13: uint16(26394), + 14: uint16(26396), + 15: uint16(26398), + 16: uint16(26400), + 17: uint16(26401), + 18: uint16(26402), + 19: uint16(26403), + 20: uint16(26404), + 21: uint16(26405), + 22: uint16(26407), + 23: uint16(26409), + 24: uint16(26414), + 25: uint16(26416), + 26: uint16(26418), + 27: uint16(26419), + 28: uint16(26422), + 29: uint16(26423), + 30: uint16(26424), + 31: uint16(26425), + 32: uint16(26427), + 33: uint16(26428), + 34: uint16(26430), + 35: uint16(26431), + 36: uint16(26433), + 37: uint16(26436), + 38: uint16(26437), + 39: uint16(26439), + 40: uint16(26442), + 41: uint16(26443), + 42: uint16(26445), + 43: uint16(26450), + 44: uint16(26452), + 45: uint16(26453), + 46: uint16(26455), + 47: uint16(26456), + 48: uint16(26457), + 49: uint16(26458), + 50: uint16(26459), + 51: uint16(26461), + 52: uint16(26466), + 53: uint16(26467), + 54: uint16(26468), + 55: uint16(26470), + 56: uint16(26471), + 57: uint16(26475), + 58: uint16(26476), + 59: uint16(26478), + 60: uint16(26481), + 61: uint16(26484), + 62: uint16(26486), + 63: uint16(26488), + 64: uint16(26489), + 65: uint16(26490), + 66: uint16(26491), + 67: uint16(26493), + 68: uint16(26496), + 69: uint16(26498), + 70: uint16(26499), + 71: uint16(26501), + 72: uint16(26502), + 73: uint16(26504), + 74: uint16(26506), + 75: uint16(26508), + 76: uint16(26509), + 77: uint16(26510), + 78: uint16(26511), + 79: uint16(26513), + 80: uint16(26514), + 81: uint16(26515), + 82: uint16(26516), + 83: uint16(26518), + 84: uint16(26521), + 85: uint16(26523), + 86: uint16(26527), + 87: uint16(26528), + 88: uint16(26529), + 89: uint16(26532), + 90: uint16(26534), + 91: uint16(26537), + 92: uint16(26540), + 93: uint16(26542), + 94: uint16(26545), + 95: uint16(26546), + 96: uint16(26548), + 97: uint16(26553), + 98: uint16(26554), + 99: uint16(26555), + 100: uint16(26556), + 101: uint16(26557), + 102: uint16(26558), + 103: uint16(26559), + 104: uint16(26560), + 105: uint16(26562), + 106: uint16(26565), + 107: uint16(26566), + 108: uint16(26567), + 109: uint16(26568), + 110: uint16(26569), + 111: uint16(26570), + 112: uint16(26571), + 113: uint16(26572), + 114: uint16(26573), + 115: uint16(26574), + 116: uint16(26581), + 117: uint16(26582), + 118: uint16(26583), + 119: uint16(26587), + 120: uint16(26591), + 121: uint16(26593), + 122: uint16(26595), + 123: uint16(26596), + 124: uint16(26598), + 125: uint16(26599), + 126: uint16(26600), + 127: uint16(26602), + 128: uint16(26603), + 129: uint16(26605), + 130: uint16(26606), + 131: uint16(26610), + 132: uint16(26613), + 133: uint16(26614), + 134: uint16(26615), + 135: uint16(26616), + 136: uint16(26617), + 137: uint16(26618), + 138: uint16(26619), + 139: uint16(26620), + 140: uint16(26622), + 141: uint16(26625), + 142: uint16(26626), + 143: uint16(26627), + 144: uint16(26628), + 145: uint16(26630), + 146: uint16(26637), + 147: uint16(26640), + 148: uint16(26642), + 149: uint16(26644), + 150: uint16(26645), + 151: uint16(26648), + 152: uint16(26649), + 153: uint16(26650), + 154: uint16(26651), + 155: uint16(26652), + 156: uint16(26654), + 157: uint16(26655), + 158: uint16(26656), + 159: uint16(26658), + 160: uint16(26659), + 161: uint16(26660), + 162: uint16(26661), + 163: uint16(26662), + 164: uint16(26663), + 165: uint16(26664), + 166: uint16(26667), + 167: uint16(26668), + 168: uint16(26669), + 169: uint16(26670), + 170: uint16(26671), + 171: uint16(26672), + 172: uint16(26673), + 173: uint16(26676), + 174: uint16(26677), + 175: uint16(26678), + 176: uint16(26682), + 177: uint16(26683), + 178: uint16(26687), + 179: uint16(26695), + 180: uint16(26699), + 181: uint16(26701), + 182: uint16(26703), + 183: uint16(26706), + 184: uint16(26710), + 185: uint16(26711), + 186: uint16(26712), + 187: uint16(26713), + 188: uint16(26714), + 189: uint16(26715), + }, + 22: { + 0: uint16(26716), + 1: uint16(26717), + 2: uint16(26718), + 3: uint16(26719), + 4: uint16(26730), + 5: uint16(26732), + 6: uint16(26733), + 7: uint16(26734), + 8: uint16(26735), + 9: uint16(26736), + 10: uint16(26737), + 11: uint16(26738), + 12: uint16(26739), + 13: uint16(26741), + 14: uint16(26744), + 15: uint16(26745), + 16: uint16(26746), + 17: uint16(26747), + 18: uint16(26748), + 19: uint16(26749), + 20: uint16(26750), + 21: uint16(26751), + 22: uint16(26752), + 23: uint16(26754), + 24: uint16(26756), + 25: uint16(26759), + 26: uint16(26760), + 27: uint16(26761), + 28: uint16(26762), + 29: uint16(26763), + 30: uint16(26764), + 31: uint16(26765), + 32: uint16(26766), + 33: uint16(26768), + 34: uint16(26769), + 35: uint16(26770), + 36: uint16(26772), + 37: uint16(26773), + 38: uint16(26774), + 39: uint16(26776), + 40: uint16(26777), + 41: uint16(26778), + 42: uint16(26779), + 43: uint16(26780), + 44: uint16(26781), + 45: uint16(26782), + 46: uint16(26783), + 47: uint16(26784), + 48: uint16(26785), + 49: uint16(26787), + 50: uint16(26788), + 51: uint16(26789), + 52: uint16(26793), + 53: uint16(26794), + 54: uint16(26795), + 55: uint16(26796), + 56: uint16(26798), + 57: uint16(26801), + 58: uint16(26802), + 59: uint16(26804), + 60: uint16(26806), + 61: uint16(26807), + 62: uint16(26808), + 63: uint16(26809), + 64: uint16(26810), + 65: uint16(26811), + 66: uint16(26812), + 67: uint16(26813), + 68: uint16(26814), + 69: uint16(26815), + 70: uint16(26817), + 71: uint16(26819), + 72: uint16(26820), + 73: uint16(26821), + 74: uint16(26822), + 75: uint16(26823), + 76: uint16(26824), + 77: uint16(26826), + 78: uint16(26828), + 79: uint16(26830), + 80: uint16(26831), + 81: uint16(26832), + 82: uint16(26833), + 83: uint16(26835), + 84: uint16(26836), + 85: uint16(26838), + 86: uint16(26839), + 87: uint16(26841), + 88: uint16(26843), + 89: uint16(26844), + 90: uint16(26845), + 91: uint16(26846), + 92: uint16(26847), + 93: uint16(26849), + 94: uint16(26850), + 95: uint16(26852), + 96: uint16(26853), + 97: uint16(26854), + 98: uint16(26855), + 99: uint16(26856), + 100: uint16(26857), + 101: uint16(26858), + 102: uint16(26859), + 103: uint16(26860), + 104: uint16(26861), + 105: uint16(26863), + 106: uint16(26866), + 107: uint16(26867), + 108: uint16(26868), + 109: uint16(26870), + 110: uint16(26871), + 111: uint16(26872), + 112: uint16(26875), + 113: uint16(26877), + 114: uint16(26878), + 115: uint16(26879), + 116: uint16(26880), + 117: uint16(26882), + 118: uint16(26883), + 119: uint16(26884), + 120: uint16(26886), + 121: uint16(26887), + 122: uint16(26888), + 123: uint16(26889), + 124: uint16(26890), + 125: uint16(26892), + 126: uint16(26895), + 127: uint16(26897), + 128: uint16(26899), + 129: uint16(26900), + 130: uint16(26901), + 131: uint16(26902), + 132: uint16(26903), + 133: uint16(26904), + 134: uint16(26905), + 135: uint16(26906), + 136: uint16(26907), + 137: uint16(26908), + 138: uint16(26909), + 139: uint16(26910), + 140: uint16(26913), + 141: uint16(26914), + 142: uint16(26915), + 143: uint16(26917), + 144: uint16(26918), + 145: uint16(26919), + 146: uint16(26920), + 147: uint16(26921), + 148: uint16(26922), + 149: uint16(26923), + 150: uint16(26924), + 151: uint16(26926), + 152: uint16(26927), + 153: uint16(26929), + 154: uint16(26930), + 155: uint16(26931), + 156: uint16(26933), + 157: uint16(26934), + 158: uint16(26935), + 159: uint16(26936), + 160: uint16(26938), + 161: uint16(26939), + 162: uint16(26940), + 163: uint16(26942), + 164: uint16(26944), + 165: uint16(26945), + 166: uint16(26947), + 167: uint16(26948), + 168: uint16(26949), + 169: uint16(26950), + 170: uint16(26951), + 171: uint16(26952), + 172: uint16(26953), + 173: uint16(26954), + 174: uint16(26955), + 175: uint16(26956), + 176: uint16(26957), + 177: uint16(26958), + 178: uint16(26959), + 179: uint16(26960), + 180: uint16(26961), + 181: uint16(26962), + 182: uint16(26963), + 183: uint16(26965), + 184: uint16(26966), + 185: uint16(26968), + 186: uint16(26969), + 187: uint16(26971), + 188: uint16(26972), + 189: uint16(26975), + }, + 23: { + 0: uint16(26977), + 1: uint16(26978), + 2: uint16(26980), + 3: uint16(26981), + 4: uint16(26983), + 5: uint16(26984), + 6: uint16(26985), + 7: uint16(26986), + 8: uint16(26988), + 9: uint16(26989), + 10: uint16(26991), + 11: uint16(26992), + 12: uint16(26994), + 13: uint16(26995), + 14: uint16(26996), + 15: uint16(26997), + 16: uint16(26998), + 17: uint16(27002), + 18: uint16(27003), + 19: uint16(27005), + 20: uint16(27006), + 21: uint16(27007), + 22: uint16(27009), + 23: uint16(27011), + 24: uint16(27013), + 25: uint16(27018), + 26: uint16(27019), + 27: uint16(27020), + 28: uint16(27022), + 29: uint16(27023), + 30: uint16(27024), + 31: uint16(27025), + 32: uint16(27026), + 33: uint16(27027), + 34: uint16(27030), + 35: uint16(27031), + 36: uint16(27033), + 37: uint16(27034), + 38: uint16(27037), + 39: uint16(27038), + 40: uint16(27039), + 41: uint16(27040), + 42: uint16(27041), + 43: uint16(27042), + 44: uint16(27043), + 45: uint16(27044), + 46: uint16(27045), + 47: uint16(27046), + 48: uint16(27049), + 49: uint16(27050), + 50: uint16(27052), + 51: uint16(27054), + 52: uint16(27055), + 53: uint16(27056), + 54: uint16(27058), + 55: uint16(27059), + 56: uint16(27061), + 57: uint16(27062), + 58: uint16(27064), + 59: uint16(27065), + 60: uint16(27066), + 61: uint16(27068), + 62: uint16(27069), + 63: uint16(27070), + 64: uint16(27071), + 65: uint16(27072), + 66: uint16(27074), + 67: uint16(27075), + 68: uint16(27076), + 69: uint16(27077), + 70: uint16(27078), + 71: uint16(27079), + 72: uint16(27080), + 73: uint16(27081), + 74: uint16(27083), + 75: uint16(27085), + 76: uint16(27087), + 77: uint16(27089), + 78: uint16(27090), + 79: uint16(27091), + 80: uint16(27093), + 81: uint16(27094), + 82: uint16(27095), + 83: uint16(27096), + 84: uint16(27097), + 85: uint16(27098), + 86: uint16(27100), + 87: uint16(27101), + 88: uint16(27102), + 89: uint16(27105), + 90: uint16(27106), + 91: uint16(27107), + 92: uint16(27108), + 93: uint16(27109), + 94: uint16(27110), + 95: uint16(27111), + 96: uint16(27112), + 97: uint16(27113), + 98: uint16(27114), + 99: uint16(27115), + 100: uint16(27116), + 101: uint16(27118), + 102: uint16(27119), + 103: uint16(27120), + 104: uint16(27121), + 105: uint16(27123), + 106: uint16(27124), + 107: uint16(27125), + 108: uint16(27126), + 109: uint16(27127), + 110: uint16(27128), + 111: uint16(27129), + 112: uint16(27130), + 113: uint16(27131), + 114: uint16(27132), + 115: uint16(27134), + 116: uint16(27136), + 117: uint16(27137), + 118: uint16(27138), + 119: uint16(27139), + 120: uint16(27140), + 121: uint16(27141), + 122: uint16(27142), + 123: uint16(27143), + 124: uint16(27144), + 125: uint16(27145), + 126: uint16(27147), + 127: uint16(27148), + 128: uint16(27149), + 129: uint16(27150), + 130: uint16(27151), + 131: uint16(27152), + 132: uint16(27153), + 133: uint16(27154), + 134: uint16(27155), + 135: uint16(27156), + 136: uint16(27157), + 137: uint16(27158), + 138: uint16(27161), + 139: uint16(27162), + 140: uint16(27163), + 141: uint16(27164), + 142: uint16(27165), + 143: uint16(27166), + 144: uint16(27168), + 145: uint16(27170), + 146: uint16(27171), + 147: uint16(27172), + 148: uint16(27173), + 149: uint16(27174), + 150: uint16(27175), + 151: uint16(27177), + 152: uint16(27179), + 153: uint16(27180), + 154: uint16(27181), + 155: uint16(27182), + 156: uint16(27184), + 157: uint16(27186), + 158: uint16(27187), + 159: uint16(27188), + 160: uint16(27190), + 161: uint16(27191), + 162: uint16(27192), + 163: uint16(27193), + 164: uint16(27194), + 165: uint16(27195), + 166: uint16(27196), + 167: uint16(27199), + 168: uint16(27200), + 169: uint16(27201), + 170: uint16(27202), + 171: uint16(27203), + 172: uint16(27205), + 173: uint16(27206), + 174: uint16(27208), + 175: uint16(27209), + 176: uint16(27210), + 177: uint16(27211), + 178: uint16(27212), + 179: uint16(27213), + 180: uint16(27214), + 181: uint16(27215), + 182: uint16(27217), + 183: uint16(27218), + 184: uint16(27219), + 185: uint16(27220), + 186: uint16(27221), + 187: uint16(27222), + 188: uint16(27223), + 189: uint16(27226), + }, + 24: { + 0: uint16(27228), + 1: uint16(27229), + 2: uint16(27230), + 3: uint16(27231), + 4: uint16(27232), + 5: uint16(27234), + 6: uint16(27235), + 7: uint16(27236), + 8: uint16(27238), + 9: uint16(27239), + 10: uint16(27240), + 11: uint16(27241), + 12: uint16(27242), + 13: uint16(27243), + 14: uint16(27244), + 15: uint16(27245), + 16: uint16(27246), + 17: uint16(27247), + 18: uint16(27248), + 19: uint16(27250), + 20: uint16(27251), + 21: uint16(27252), + 22: uint16(27253), + 23: uint16(27254), + 24: uint16(27255), + 25: uint16(27256), + 26: uint16(27258), + 27: uint16(27259), + 28: uint16(27261), + 29: uint16(27262), + 30: uint16(27263), + 31: uint16(27265), + 32: uint16(27266), + 33: uint16(27267), + 34: uint16(27269), + 35: uint16(27270), + 36: uint16(27271), + 37: uint16(27272), + 38: uint16(27273), + 39: uint16(27274), + 40: uint16(27275), + 41: uint16(27276), + 42: uint16(27277), + 43: uint16(27279), + 44: uint16(27282), + 45: uint16(27283), + 46: uint16(27284), + 47: uint16(27285), + 48: uint16(27286), + 49: uint16(27288), + 50: uint16(27289), + 51: uint16(27290), + 52: uint16(27291), + 53: uint16(27292), + 54: uint16(27293), + 55: uint16(27294), + 56: uint16(27295), + 57: uint16(27297), + 58: uint16(27298), + 59: uint16(27299), + 60: uint16(27300), + 61: uint16(27301), + 62: uint16(27302), + 63: uint16(27303), + 64: uint16(27304), + 65: uint16(27306), + 66: uint16(27309), + 67: uint16(27310), + 68: uint16(27311), + 69: uint16(27312), + 70: uint16(27313), + 71: uint16(27314), + 72: uint16(27315), + 73: uint16(27316), + 74: uint16(27317), + 75: uint16(27318), + 76: uint16(27319), + 77: uint16(27320), + 78: uint16(27321), + 79: uint16(27322), + 80: uint16(27323), + 81: uint16(27324), + 82: uint16(27325), + 83: uint16(27326), + 84: uint16(27327), + 85: uint16(27328), + 86: uint16(27329), + 87: uint16(27330), + 88: uint16(27331), + 89: uint16(27332), + 90: uint16(27333), + 91: uint16(27334), + 92: uint16(27335), + 93: uint16(27336), + 94: uint16(27337), + 95: uint16(27338), + 96: uint16(27339), + 97: uint16(27340), + 98: uint16(27341), + 99: uint16(27342), + 100: uint16(27343), + 101: uint16(27344), + 102: uint16(27345), + 103: uint16(27346), + 104: uint16(27347), + 105: uint16(27348), + 106: uint16(27349), + 107: uint16(27350), + 108: uint16(27351), + 109: uint16(27352), + 110: uint16(27353), + 111: uint16(27354), + 112: uint16(27355), + 113: uint16(27356), + 114: uint16(27357), + 115: uint16(27358), + 116: uint16(27359), + 117: uint16(27360), + 118: uint16(27361), + 119: uint16(27362), + 120: uint16(27363), + 121: uint16(27364), + 122: uint16(27365), + 123: uint16(27366), + 124: uint16(27367), + 125: uint16(27368), + 126: uint16(27369), + 127: uint16(27370), + 128: uint16(27371), + 129: uint16(27372), + 130: uint16(27373), + 131: uint16(27374), + 132: uint16(27375), + 133: uint16(27376), + 134: uint16(27377), + 135: uint16(27378), + 136: uint16(27379), + 137: uint16(27380), + 138: uint16(27381), + 139: uint16(27382), + 140: uint16(27383), + 141: uint16(27384), + 142: uint16(27385), + 143: uint16(27386), + 144: uint16(27387), + 145: uint16(27388), + 146: uint16(27389), + 147: uint16(27390), + 148: uint16(27391), + 149: uint16(27392), + 150: uint16(27393), + 151: uint16(27394), + 152: uint16(27395), + 153: uint16(27396), + 154: uint16(27397), + 155: uint16(27398), + 156: uint16(27399), + 157: uint16(27400), + 158: uint16(27401), + 159: uint16(27402), + 160: uint16(27403), + 161: uint16(27404), + 162: uint16(27405), + 163: uint16(27406), + 164: uint16(27407), + 165: uint16(27408), + 166: uint16(27409), + 167: uint16(27410), + 168: uint16(27411), + 169: uint16(27412), + 170: uint16(27413), + 171: uint16(27414), + 172: uint16(27415), + 173: uint16(27416), + 174: uint16(27417), + 175: uint16(27418), + 176: uint16(27419), + 177: uint16(27420), + 178: uint16(27421), + 179: uint16(27422), + 180: uint16(27423), + 181: uint16(27429), + 182: uint16(27430), + 183: uint16(27432), + 184: uint16(27433), + 185: uint16(27434), + 186: uint16(27435), + 187: uint16(27436), + 188: uint16(27437), + 189: uint16(27438), + }, + 25: { + 0: uint16(27439), + 1: uint16(27440), + 2: uint16(27441), + 3: uint16(27443), + 4: uint16(27444), + 5: uint16(27445), + 6: uint16(27446), + 7: uint16(27448), + 8: uint16(27451), + 9: uint16(27452), + 10: uint16(27453), + 11: uint16(27455), + 12: uint16(27456), + 13: uint16(27457), + 14: uint16(27458), + 15: uint16(27460), + 16: uint16(27461), + 17: uint16(27464), + 18: uint16(27466), + 19: uint16(27467), + 20: uint16(27469), + 21: uint16(27470), + 22: uint16(27471), + 23: uint16(27472), + 24: uint16(27473), + 25: uint16(27474), + 26: uint16(27475), + 27: uint16(27476), + 28: uint16(27477), + 29: uint16(27478), + 30: uint16(27479), + 31: uint16(27480), + 32: uint16(27482), + 33: uint16(27483), + 34: uint16(27484), + 35: uint16(27485), + 36: uint16(27486), + 37: uint16(27487), + 38: uint16(27488), + 39: uint16(27489), + 40: uint16(27496), + 41: uint16(27497), + 42: uint16(27499), + 43: uint16(27500), + 44: uint16(27501), + 45: uint16(27502), + 46: uint16(27503), + 47: uint16(27504), + 48: uint16(27505), + 49: uint16(27506), + 50: uint16(27507), + 51: uint16(27508), + 52: uint16(27509), + 53: uint16(27510), + 54: uint16(27511), + 55: uint16(27512), + 56: uint16(27514), + 57: uint16(27517), + 58: uint16(27518), + 59: uint16(27519), + 60: uint16(27520), + 61: uint16(27525), + 62: uint16(27528), + 63: uint16(27532), + 64: uint16(27534), + 65: uint16(27535), + 66: uint16(27536), + 67: uint16(27537), + 68: uint16(27540), + 69: uint16(27541), + 70: uint16(27543), + 71: uint16(27544), + 72: uint16(27545), + 73: uint16(27548), + 74: uint16(27549), + 75: uint16(27550), + 76: uint16(27551), + 77: uint16(27552), + 78: uint16(27554), + 79: uint16(27555), + 80: uint16(27556), + 81: uint16(27557), + 82: uint16(27558), + 83: uint16(27559), + 84: uint16(27560), + 85: uint16(27561), + 86: uint16(27563), + 87: uint16(27564), + 88: uint16(27565), + 89: uint16(27566), + 90: uint16(27567), + 91: uint16(27568), + 92: uint16(27569), + 93: uint16(27570), + 94: uint16(27574), + 95: uint16(27576), + 96: uint16(27577), + 97: uint16(27578), + 98: uint16(27579), + 99: uint16(27580), + 100: uint16(27581), + 101: uint16(27582), + 102: uint16(27584), + 103: uint16(27587), + 104: uint16(27588), + 105: uint16(27590), + 106: uint16(27591), + 107: uint16(27592), + 108: uint16(27593), + 109: uint16(27594), + 110: uint16(27596), + 111: uint16(27598), + 112: uint16(27600), + 113: uint16(27601), + 114: uint16(27608), + 115: uint16(27610), + 116: uint16(27612), + 117: uint16(27613), + 118: uint16(27614), + 119: uint16(27615), + 120: uint16(27616), + 121: uint16(27618), + 122: uint16(27619), + 123: uint16(27620), + 124: uint16(27621), + 125: uint16(27622), + 126: uint16(27623), + 127: uint16(27624), + 128: uint16(27625), + 129: uint16(27628), + 130: uint16(27629), + 131: uint16(27630), + 132: uint16(27632), + 133: uint16(27633), + 134: uint16(27634), + 135: uint16(27636), + 136: uint16(27638), + 137: uint16(27639), + 138: uint16(27640), + 139: uint16(27642), + 140: uint16(27643), + 141: uint16(27644), + 142: uint16(27646), + 143: uint16(27647), + 144: uint16(27648), + 145: uint16(27649), + 146: uint16(27650), + 147: uint16(27651), + 148: uint16(27652), + 149: uint16(27656), + 150: uint16(27657), + 151: uint16(27658), + 152: uint16(27659), + 153: uint16(27660), + 154: uint16(27662), + 155: uint16(27666), + 156: uint16(27671), + 157: uint16(27676), + 158: uint16(27677), + 159: uint16(27678), + 160: uint16(27680), + 161: uint16(27683), + 162: uint16(27685), + 163: uint16(27691), + 164: uint16(27692), + 165: uint16(27693), + 166: uint16(27697), + 167: uint16(27699), + 168: uint16(27702), + 169: uint16(27703), + 170: uint16(27705), + 171: uint16(27706), + 172: uint16(27707), + 173: uint16(27708), + 174: uint16(27710), + 175: uint16(27711), + 176: uint16(27715), + 177: uint16(27716), + 178: uint16(27717), + 179: uint16(27720), + 180: uint16(27723), + 181: uint16(27724), + 182: uint16(27725), + 183: uint16(27726), + 184: uint16(27727), + 185: uint16(27729), + 186: uint16(27730), + 187: uint16(27731), + 188: uint16(27734), + 189: uint16(27736), + }, + 26: { + 0: uint16(27737), + 1: uint16(27738), + 2: uint16(27746), + 3: uint16(27747), + 4: uint16(27749), + 5: uint16(27750), + 6: uint16(27751), + 7: uint16(27755), + 8: uint16(27756), + 9: uint16(27757), + 10: uint16(27758), + 11: uint16(27759), + 12: uint16(27761), + 13: uint16(27763), + 14: uint16(27765), + 15: uint16(27767), + 16: uint16(27768), + 17: uint16(27770), + 18: uint16(27771), + 19: uint16(27772), + 20: uint16(27775), + 21: uint16(27776), + 22: uint16(27780), + 23: uint16(27783), + 24: uint16(27786), + 25: uint16(27787), + 26: uint16(27789), + 27: uint16(27790), + 28: uint16(27793), + 29: uint16(27794), + 30: uint16(27797), + 31: uint16(27798), + 32: uint16(27799), + 33: uint16(27800), + 34: uint16(27802), + 35: uint16(27804), + 36: uint16(27805), + 37: uint16(27806), + 38: uint16(27808), + 39: uint16(27810), + 40: uint16(27816), + 41: uint16(27820), + 42: uint16(27823), + 43: uint16(27824), + 44: uint16(27828), + 45: uint16(27829), + 46: uint16(27830), + 47: uint16(27831), + 48: uint16(27834), + 49: uint16(27840), + 50: uint16(27841), + 51: uint16(27842), + 52: uint16(27843), + 53: uint16(27846), + 54: uint16(27847), + 55: uint16(27848), + 56: uint16(27851), + 57: uint16(27853), + 58: uint16(27854), + 59: uint16(27855), + 60: uint16(27857), + 61: uint16(27858), + 62: uint16(27864), + 63: uint16(27865), + 64: uint16(27866), + 65: uint16(27868), + 66: uint16(27869), + 67: uint16(27871), + 68: uint16(27876), + 69: uint16(27878), + 70: uint16(27879), + 71: uint16(27881), + 72: uint16(27884), + 73: uint16(27885), + 74: uint16(27890), + 75: uint16(27892), + 76: uint16(27897), + 77: uint16(27903), + 78: uint16(27904), + 79: uint16(27906), + 80: uint16(27907), + 81: uint16(27909), + 82: uint16(27910), + 83: uint16(27912), + 84: uint16(27913), + 85: uint16(27914), + 86: uint16(27917), + 87: uint16(27919), + 88: uint16(27920), + 89: uint16(27921), + 90: uint16(27923), + 91: uint16(27924), + 92: uint16(27925), + 93: uint16(27926), + 94: uint16(27928), + 95: uint16(27932), + 96: uint16(27933), + 97: uint16(27935), + 98: uint16(27936), + 99: uint16(27937), + 100: uint16(27938), + 101: uint16(27939), + 102: uint16(27940), + 103: uint16(27942), + 104: uint16(27944), + 105: uint16(27945), + 106: uint16(27948), + 107: uint16(27949), + 108: uint16(27951), + 109: uint16(27952), + 110: uint16(27956), + 111: uint16(27958), + 112: uint16(27959), + 113: uint16(27960), + 114: uint16(27962), + 115: uint16(27967), + 116: uint16(27968), + 117: uint16(27970), + 118: uint16(27972), + 119: uint16(27977), + 120: uint16(27980), + 121: uint16(27984), + 122: uint16(27989), + 123: uint16(27990), + 124: uint16(27991), + 125: uint16(27992), + 126: uint16(27995), + 127: uint16(27997), + 128: uint16(27999), + 129: uint16(28001), + 130: uint16(28002), + 131: uint16(28004), + 132: uint16(28005), + 133: uint16(28007), + 134: uint16(28008), + 135: uint16(28011), + 136: uint16(28012), + 137: uint16(28013), + 138: uint16(28016), + 139: uint16(28017), + 140: uint16(28018), + 141: uint16(28019), + 142: uint16(28021), + 143: uint16(28022), + 144: uint16(28025), + 145: uint16(28026), + 146: uint16(28027), + 147: uint16(28029), + 148: uint16(28030), + 149: uint16(28031), + 150: uint16(28032), + 151: uint16(28033), + 152: uint16(28035), + 153: uint16(28036), + 154: uint16(28038), + 155: uint16(28039), + 156: uint16(28042), + 157: uint16(28043), + 158: uint16(28045), + 159: uint16(28047), + 160: uint16(28048), + 161: uint16(28050), + 162: uint16(28054), + 163: uint16(28055), + 164: uint16(28056), + 165: uint16(28057), + 166: uint16(28058), + 167: uint16(28060), + 168: uint16(28066), + 169: uint16(28069), + 170: uint16(28076), + 171: uint16(28077), + 172: uint16(28080), + 173: uint16(28081), + 174: uint16(28083), + 175: uint16(28084), + 176: uint16(28086), + 177: uint16(28087), + 178: uint16(28089), + 179: uint16(28090), + 180: uint16(28091), + 181: uint16(28092), + 182: uint16(28093), + 183: uint16(28094), + 184: uint16(28097), + 185: uint16(28098), + 186: uint16(28099), + 187: uint16(28104), + 188: uint16(28105), + 189: uint16(28106), + }, + 27: { + 0: uint16(28109), + 1: uint16(28110), + 2: uint16(28111), + 3: uint16(28112), + 4: uint16(28114), + 5: uint16(28115), + 6: uint16(28116), + 7: uint16(28117), + 8: uint16(28119), + 9: uint16(28122), + 10: uint16(28123), + 11: uint16(28124), + 12: uint16(28127), + 13: uint16(28130), + 14: uint16(28131), + 15: uint16(28133), + 16: uint16(28135), + 17: uint16(28136), + 18: uint16(28137), + 19: uint16(28138), + 20: uint16(28141), + 21: uint16(28143), + 22: uint16(28144), + 23: uint16(28146), + 24: uint16(28148), + 25: uint16(28149), + 26: uint16(28150), + 27: uint16(28152), + 28: uint16(28154), + 29: uint16(28157), + 30: uint16(28158), + 31: uint16(28159), + 32: uint16(28160), + 33: uint16(28161), + 34: uint16(28162), + 35: uint16(28163), + 36: uint16(28164), + 37: uint16(28166), + 38: uint16(28167), + 39: uint16(28168), + 40: uint16(28169), + 41: uint16(28171), + 42: uint16(28175), + 43: uint16(28178), + 44: uint16(28179), + 45: uint16(28181), + 46: uint16(28184), + 47: uint16(28185), + 48: uint16(28187), + 49: uint16(28188), + 50: uint16(28190), + 51: uint16(28191), + 52: uint16(28194), + 53: uint16(28198), + 54: uint16(28199), + 55: uint16(28200), + 56: uint16(28202), + 57: uint16(28204), + 58: uint16(28206), + 59: uint16(28208), + 60: uint16(28209), + 61: uint16(28211), + 62: uint16(28213), + 63: uint16(28214), + 64: uint16(28215), + 65: uint16(28217), + 66: uint16(28219), + 67: uint16(28220), + 68: uint16(28221), + 69: uint16(28222), + 70: uint16(28223), + 71: uint16(28224), + 72: uint16(28225), + 73: uint16(28226), + 74: uint16(28229), + 75: uint16(28230), + 76: uint16(28231), + 77: uint16(28232), + 78: uint16(28233), + 79: uint16(28234), + 80: uint16(28235), + 81: uint16(28236), + 82: uint16(28239), + 83: uint16(28240), + 84: uint16(28241), + 85: uint16(28242), + 86: uint16(28245), + 87: uint16(28247), + 88: uint16(28249), + 89: uint16(28250), + 90: uint16(28252), + 91: uint16(28253), + 92: uint16(28254), + 93: uint16(28256), + 94: uint16(28257), + 95: uint16(28258), + 96: uint16(28259), + 97: uint16(28260), + 98: uint16(28261), + 99: uint16(28262), + 100: uint16(28263), + 101: uint16(28264), + 102: uint16(28265), + 103: uint16(28266), + 104: uint16(28268), + 105: uint16(28269), + 106: uint16(28271), + 107: uint16(28272), + 108: uint16(28273), + 109: uint16(28274), + 110: uint16(28275), + 111: uint16(28276), + 112: uint16(28277), + 113: uint16(28278), + 114: uint16(28279), + 115: uint16(28280), + 116: uint16(28281), + 117: uint16(28282), + 118: uint16(28283), + 119: uint16(28284), + 120: uint16(28285), + 121: uint16(28288), + 122: uint16(28289), + 123: uint16(28290), + 124: uint16(28292), + 125: uint16(28295), + 126: uint16(28296), + 127: uint16(28298), + 128: uint16(28299), + 129: uint16(28300), + 130: uint16(28301), + 131: uint16(28302), + 132: uint16(28305), + 133: uint16(28306), + 134: uint16(28307), + 135: uint16(28308), + 136: uint16(28309), + 137: uint16(28310), + 138: uint16(28311), + 139: uint16(28313), + 140: uint16(28314), + 141: uint16(28315), + 142: uint16(28317), + 143: uint16(28318), + 144: uint16(28320), + 145: uint16(28321), + 146: uint16(28323), + 147: uint16(28324), + 148: uint16(28326), + 149: uint16(28328), + 150: uint16(28329), + 151: uint16(28331), + 152: uint16(28332), + 153: uint16(28333), + 154: uint16(28334), + 155: uint16(28336), + 156: uint16(28339), + 157: uint16(28341), + 158: uint16(28344), + 159: uint16(28345), + 160: uint16(28348), + 161: uint16(28350), + 162: uint16(28351), + 163: uint16(28352), + 164: uint16(28355), + 165: uint16(28356), + 166: uint16(28357), + 167: uint16(28358), + 168: uint16(28360), + 169: uint16(28361), + 170: uint16(28362), + 171: uint16(28364), + 172: uint16(28365), + 173: uint16(28366), + 174: uint16(28368), + 175: uint16(28370), + 176: uint16(28374), + 177: uint16(28376), + 178: uint16(28377), + 179: uint16(28379), + 180: uint16(28380), + 181: uint16(28381), + 182: uint16(28387), + 183: uint16(28391), + 184: uint16(28394), + 185: uint16(28395), + 186: uint16(28396), + 187: uint16(28397), + 188: uint16(28398), + 189: uint16(28399), + }, + 28: { + 0: uint16(28400), + 1: uint16(28401), + 2: uint16(28402), + 3: uint16(28403), + 4: uint16(28405), + 5: uint16(28406), + 6: uint16(28407), + 7: uint16(28408), + 8: uint16(28410), + 9: uint16(28411), + 10: uint16(28412), + 11: uint16(28413), + 12: uint16(28414), + 13: uint16(28415), + 14: uint16(28416), + 15: uint16(28417), + 16: uint16(28419), + 17: uint16(28420), + 18: uint16(28421), + 19: uint16(28423), + 20: uint16(28424), + 21: uint16(28426), + 22: uint16(28427), + 23: uint16(28428), + 24: uint16(28429), + 25: uint16(28430), + 26: uint16(28432), + 27: uint16(28433), + 28: uint16(28434), + 29: uint16(28438), + 30: uint16(28439), + 31: uint16(28440), + 32: uint16(28441), + 33: uint16(28442), + 34: uint16(28443), + 35: uint16(28444), + 36: uint16(28445), + 37: uint16(28446), + 38: uint16(28447), + 39: uint16(28449), + 40: uint16(28450), + 41: uint16(28451), + 42: uint16(28453), + 43: uint16(28454), + 44: uint16(28455), + 45: uint16(28456), + 46: uint16(28460), + 47: uint16(28462), + 48: uint16(28464), + 49: uint16(28466), + 50: uint16(28468), + 51: uint16(28469), + 52: uint16(28471), + 53: uint16(28472), + 54: uint16(28473), + 55: uint16(28474), + 56: uint16(28475), + 57: uint16(28476), + 58: uint16(28477), + 59: uint16(28479), + 60: uint16(28480), + 61: uint16(28481), + 62: uint16(28482), + 63: uint16(28483), + 64: uint16(28484), + 65: uint16(28485), + 66: uint16(28488), + 67: uint16(28489), + 68: uint16(28490), + 69: uint16(28492), + 70: uint16(28494), + 71: uint16(28495), + 72: uint16(28496), + 73: uint16(28497), + 74: uint16(28498), + 75: uint16(28499), + 76: uint16(28500), + 77: uint16(28501), + 78: uint16(28502), + 79: uint16(28503), + 80: uint16(28505), + 81: uint16(28506), + 82: uint16(28507), + 83: uint16(28509), + 84: uint16(28511), + 85: uint16(28512), + 86: uint16(28513), + 87: uint16(28515), + 88: uint16(28516), + 89: uint16(28517), + 90: uint16(28519), + 91: uint16(28520), + 92: uint16(28521), + 93: uint16(28522), + 94: uint16(28523), + 95: uint16(28524), + 96: uint16(28527), + 97: uint16(28528), + 98: uint16(28529), + 99: uint16(28531), + 100: uint16(28533), + 101: uint16(28534), + 102: uint16(28535), + 103: uint16(28537), + 104: uint16(28539), + 105: uint16(28541), + 106: uint16(28542), + 107: uint16(28543), + 108: uint16(28544), + 109: uint16(28545), + 110: uint16(28546), + 111: uint16(28547), + 112: uint16(28549), + 113: uint16(28550), + 114: uint16(28551), + 115: uint16(28554), + 116: uint16(28555), + 117: uint16(28559), + 118: uint16(28560), + 119: uint16(28561), + 120: uint16(28562), + 121: uint16(28563), + 122: uint16(28564), + 123: uint16(28565), + 124: uint16(28566), + 125: uint16(28567), + 126: uint16(28568), + 127: uint16(28569), + 128: uint16(28570), + 129: uint16(28571), + 130: uint16(28573), + 131: uint16(28574), + 132: uint16(28575), + 133: uint16(28576), + 134: uint16(28578), + 135: uint16(28579), + 136: uint16(28580), + 137: uint16(28581), + 138: uint16(28582), + 139: uint16(28584), + 140: uint16(28585), + 141: uint16(28586), + 142: uint16(28587), + 143: uint16(28588), + 144: uint16(28589), + 145: uint16(28590), + 146: uint16(28591), + 147: uint16(28592), + 148: uint16(28593), + 149: uint16(28594), + 150: uint16(28596), + 151: uint16(28597), + 152: uint16(28599), + 153: uint16(28600), + 154: uint16(28602), + 155: uint16(28603), + 156: uint16(28604), + 157: uint16(28605), + 158: uint16(28606), + 159: uint16(28607), + 160: uint16(28609), + 161: uint16(28611), + 162: uint16(28612), + 163: uint16(28613), + 164: uint16(28614), + 165: uint16(28615), + 166: uint16(28616), + 167: uint16(28618), + 168: uint16(28619), + 169: uint16(28620), + 170: uint16(28621), + 171: uint16(28622), + 172: uint16(28623), + 173: uint16(28624), + 174: uint16(28627), + 175: uint16(28628), + 176: uint16(28629), + 177: uint16(28630), + 178: uint16(28631), + 179: uint16(28632), + 180: uint16(28633), + 181: uint16(28634), + 182: uint16(28635), + 183: uint16(28636), + 184: uint16(28637), + 185: uint16(28639), + 186: uint16(28642), + 187: uint16(28643), + 188: uint16(28644), + 189: uint16(28645), + }, + 29: { + 0: uint16(28646), + 1: uint16(28647), + 2: uint16(28648), + 3: uint16(28649), + 4: uint16(28650), + 5: uint16(28651), + 6: uint16(28652), + 7: uint16(28653), + 8: uint16(28656), + 9: uint16(28657), + 10: uint16(28658), + 11: uint16(28659), + 12: uint16(28660), + 13: uint16(28661), + 14: uint16(28662), + 15: uint16(28663), + 16: uint16(28664), + 17: uint16(28665), + 18: uint16(28666), + 19: uint16(28667), + 20: uint16(28668), + 21: uint16(28669), + 22: uint16(28670), + 23: uint16(28671), + 24: uint16(28672), + 25: uint16(28673), + 26: uint16(28674), + 27: uint16(28675), + 28: uint16(28676), + 29: uint16(28677), + 30: uint16(28678), + 31: uint16(28679), + 32: uint16(28680), + 33: uint16(28681), + 34: uint16(28682), + 35: uint16(28683), + 36: uint16(28684), + 37: uint16(28685), + 38: uint16(28686), + 39: uint16(28687), + 40: uint16(28688), + 41: uint16(28690), + 42: uint16(28691), + 43: uint16(28692), + 44: uint16(28693), + 45: uint16(28694), + 46: uint16(28695), + 47: uint16(28696), + 48: uint16(28697), + 49: uint16(28700), + 50: uint16(28701), + 51: uint16(28702), + 52: uint16(28703), + 53: uint16(28704), + 54: uint16(28705), + 55: uint16(28706), + 56: uint16(28708), + 57: uint16(28709), + 58: uint16(28710), + 59: uint16(28711), + 60: uint16(28712), + 61: uint16(28713), + 62: uint16(28714), + 63: uint16(28715), + 64: uint16(28716), + 65: uint16(28717), + 66: uint16(28718), + 67: uint16(28719), + 68: uint16(28720), + 69: uint16(28721), + 70: uint16(28722), + 71: uint16(28723), + 72: uint16(28724), + 73: uint16(28726), + 74: uint16(28727), + 75: uint16(28728), + 76: uint16(28730), + 77: uint16(28731), + 78: uint16(28732), + 79: uint16(28733), + 80: uint16(28734), + 81: uint16(28735), + 82: uint16(28736), + 83: uint16(28737), + 84: uint16(28738), + 85: uint16(28739), + 86: uint16(28740), + 87: uint16(28741), + 88: uint16(28742), + 89: uint16(28743), + 90: uint16(28744), + 91: uint16(28745), + 92: uint16(28746), + 93: uint16(28747), + 94: uint16(28749), + 95: uint16(28750), + 96: uint16(28752), + 97: uint16(28753), + 98: uint16(28754), + 99: uint16(28755), + 100: uint16(28756), + 101: uint16(28757), + 102: uint16(28758), + 103: uint16(28759), + 104: uint16(28760), + 105: uint16(28761), + 106: uint16(28762), + 107: uint16(28763), + 108: uint16(28764), + 109: uint16(28765), + 110: uint16(28767), + 111: uint16(28768), + 112: uint16(28769), + 113: uint16(28770), + 114: uint16(28771), + 115: uint16(28772), + 116: uint16(28773), + 117: uint16(28774), + 118: uint16(28775), + 119: uint16(28776), + 120: uint16(28777), + 121: uint16(28778), + 122: uint16(28782), + 123: uint16(28785), + 124: uint16(28786), + 125: uint16(28787), + 126: uint16(28788), + 127: uint16(28791), + 128: uint16(28793), + 129: uint16(28794), + 130: uint16(28795), + 131: uint16(28797), + 132: uint16(28801), + 133: uint16(28802), + 134: uint16(28803), + 135: uint16(28804), + 136: uint16(28806), + 137: uint16(28807), + 138: uint16(28808), + 139: uint16(28811), + 140: uint16(28812), + 141: uint16(28813), + 142: uint16(28815), + 143: uint16(28816), + 144: uint16(28817), + 145: uint16(28819), + 146: uint16(28823), + 147: uint16(28824), + 148: uint16(28826), + 149: uint16(28827), + 150: uint16(28830), + 151: uint16(28831), + 152: uint16(28832), + 153: uint16(28833), + 154: uint16(28834), + 155: uint16(28835), + 156: uint16(28836), + 157: uint16(28837), + 158: uint16(28838), + 159: uint16(28839), + 160: uint16(28840), + 161: uint16(28841), + 162: uint16(28842), + 163: uint16(28848), + 164: uint16(28850), + 165: uint16(28852), + 166: uint16(28853), + 167: uint16(28854), + 168: uint16(28858), + 169: uint16(28862), + 170: uint16(28863), + 171: uint16(28868), + 172: uint16(28869), + 173: uint16(28870), + 174: uint16(28871), + 175: uint16(28873), + 176: uint16(28875), + 177: uint16(28876), + 178: uint16(28877), + 179: uint16(28878), + 180: uint16(28879), + 181: uint16(28880), + 182: uint16(28881), + 183: uint16(28882), + 184: uint16(28883), + 185: uint16(28884), + 186: uint16(28885), + 187: uint16(28886), + 188: uint16(28887), + 189: uint16(28890), + }, + 30: { + 0: uint16(28892), + 1: uint16(28893), + 2: uint16(28894), + 3: uint16(28896), + 4: uint16(28897), + 5: uint16(28898), + 6: uint16(28899), + 7: uint16(28901), + 8: uint16(28906), + 9: uint16(28910), + 10: uint16(28912), + 11: uint16(28913), + 12: uint16(28914), + 13: uint16(28915), + 14: uint16(28916), + 15: uint16(28917), + 16: uint16(28918), + 17: uint16(28920), + 18: uint16(28922), + 19: uint16(28923), + 20: uint16(28924), + 21: uint16(28926), + 22: uint16(28927), + 23: uint16(28928), + 24: uint16(28929), + 25: uint16(28930), + 26: uint16(28931), + 27: uint16(28932), + 28: uint16(28933), + 29: uint16(28934), + 30: uint16(28935), + 31: uint16(28936), + 32: uint16(28939), + 33: uint16(28940), + 34: uint16(28941), + 35: uint16(28942), + 36: uint16(28943), + 37: uint16(28945), + 38: uint16(28946), + 39: uint16(28948), + 40: uint16(28951), + 41: uint16(28955), + 42: uint16(28956), + 43: uint16(28957), + 44: uint16(28958), + 45: uint16(28959), + 46: uint16(28960), + 47: uint16(28961), + 48: uint16(28962), + 49: uint16(28963), + 50: uint16(28964), + 51: uint16(28965), + 52: uint16(28967), + 53: uint16(28968), + 54: uint16(28969), + 55: uint16(28970), + 56: uint16(28971), + 57: uint16(28972), + 58: uint16(28973), + 59: uint16(28974), + 60: uint16(28978), + 61: uint16(28979), + 62: uint16(28980), + 63: uint16(28981), + 64: uint16(28983), + 65: uint16(28984), + 66: uint16(28985), + 67: uint16(28986), + 68: uint16(28987), + 69: uint16(28988), + 70: uint16(28989), + 71: uint16(28990), + 72: uint16(28991), + 73: uint16(28992), + 74: uint16(28993), + 75: uint16(28994), + 76: uint16(28995), + 77: uint16(28996), + 78: uint16(28998), + 79: uint16(28999), + 80: uint16(29000), + 81: uint16(29001), + 82: uint16(29003), + 83: uint16(29005), + 84: uint16(29007), + 85: uint16(29008), + 86: uint16(29009), + 87: uint16(29010), + 88: uint16(29011), + 89: uint16(29012), + 90: uint16(29013), + 91: uint16(29014), + 92: uint16(29015), + 93: uint16(29016), + 94: uint16(29017), + 95: uint16(29018), + 96: uint16(29019), + 97: uint16(29021), + 98: uint16(29023), + 99: uint16(29024), + 100: uint16(29025), + 101: uint16(29026), + 102: uint16(29027), + 103: uint16(29029), + 104: uint16(29033), + 105: uint16(29034), + 106: uint16(29035), + 107: uint16(29036), + 108: uint16(29037), + 109: uint16(29039), + 110: uint16(29040), + 111: uint16(29041), + 112: uint16(29044), + 113: uint16(29045), + 114: uint16(29046), + 115: uint16(29047), + 116: uint16(29049), + 117: uint16(29051), + 118: uint16(29052), + 119: uint16(29054), + 120: uint16(29055), + 121: uint16(29056), + 122: uint16(29057), + 123: uint16(29058), + 124: uint16(29059), + 125: uint16(29061), + 126: uint16(29062), + 127: uint16(29063), + 128: uint16(29064), + 129: uint16(29065), + 130: uint16(29067), + 131: uint16(29068), + 132: uint16(29069), + 133: uint16(29070), + 134: uint16(29072), + 135: uint16(29073), + 136: uint16(29074), + 137: uint16(29075), + 138: uint16(29077), + 139: uint16(29078), + 140: uint16(29079), + 141: uint16(29082), + 142: uint16(29083), + 143: uint16(29084), + 144: uint16(29085), + 145: uint16(29086), + 146: uint16(29089), + 147: uint16(29090), + 148: uint16(29091), + 149: uint16(29092), + 150: uint16(29093), + 151: uint16(29094), + 152: uint16(29095), + 153: uint16(29097), + 154: uint16(29098), + 155: uint16(29099), + 156: uint16(29101), + 157: uint16(29102), + 158: uint16(29103), + 159: uint16(29104), + 160: uint16(29105), + 161: uint16(29106), + 162: uint16(29108), + 163: uint16(29110), + 164: uint16(29111), + 165: uint16(29112), + 166: uint16(29114), + 167: uint16(29115), + 168: uint16(29116), + 169: uint16(29117), + 170: uint16(29118), + 171: uint16(29119), + 172: uint16(29120), + 173: uint16(29121), + 174: uint16(29122), + 175: uint16(29124), + 176: uint16(29125), + 177: uint16(29126), + 178: uint16(29127), + 179: uint16(29128), + 180: uint16(29129), + 181: uint16(29130), + 182: uint16(29131), + 183: uint16(29132), + 184: uint16(29133), + 185: uint16(29135), + 186: uint16(29136), + 187: uint16(29137), + 188: uint16(29138), + 189: uint16(29139), + }, + 31: { + 0: uint16(29142), + 1: uint16(29143), + 2: uint16(29144), + 3: uint16(29145), + 4: uint16(29146), + 5: uint16(29147), + 6: uint16(29148), + 7: uint16(29149), + 8: uint16(29150), + 9: uint16(29151), + 10: uint16(29153), + 11: uint16(29154), + 12: uint16(29155), + 13: uint16(29156), + 14: uint16(29158), + 15: uint16(29160), + 16: uint16(29161), + 17: uint16(29162), + 18: uint16(29163), + 19: uint16(29164), + 20: uint16(29165), + 21: uint16(29167), + 22: uint16(29168), + 23: uint16(29169), + 24: uint16(29170), + 25: uint16(29171), + 26: uint16(29172), + 27: uint16(29173), + 28: uint16(29174), + 29: uint16(29175), + 30: uint16(29176), + 31: uint16(29178), + 32: uint16(29179), + 33: uint16(29180), + 34: uint16(29181), + 35: uint16(29182), + 36: uint16(29183), + 37: uint16(29184), + 38: uint16(29185), + 39: uint16(29186), + 40: uint16(29187), + 41: uint16(29188), + 42: uint16(29189), + 43: uint16(29191), + 44: uint16(29192), + 45: uint16(29193), + 46: uint16(29194), + 47: uint16(29195), + 48: uint16(29196), + 49: uint16(29197), + 50: uint16(29198), + 51: uint16(29199), + 52: uint16(29200), + 53: uint16(29201), + 54: uint16(29202), + 55: uint16(29203), + 56: uint16(29204), + 57: uint16(29205), + 58: uint16(29206), + 59: uint16(29207), + 60: uint16(29208), + 61: uint16(29209), + 62: uint16(29210), + 63: uint16(29211), + 64: uint16(29212), + 65: uint16(29214), + 66: uint16(29215), + 67: uint16(29216), + 68: uint16(29217), + 69: uint16(29218), + 70: uint16(29219), + 71: uint16(29220), + 72: uint16(29221), + 73: uint16(29222), + 74: uint16(29223), + 75: uint16(29225), + 76: uint16(29227), + 77: uint16(29229), + 78: uint16(29230), + 79: uint16(29231), + 80: uint16(29234), + 81: uint16(29235), + 82: uint16(29236), + 83: uint16(29242), + 84: uint16(29244), + 85: uint16(29246), + 86: uint16(29248), + 87: uint16(29249), + 88: uint16(29250), + 89: uint16(29251), + 90: uint16(29252), + 91: uint16(29253), + 92: uint16(29254), + 93: uint16(29257), + 94: uint16(29258), + 95: uint16(29259), + 96: uint16(29262), + 97: uint16(29263), + 98: uint16(29264), + 99: uint16(29265), + 100: uint16(29267), + 101: uint16(29268), + 102: uint16(29269), + 103: uint16(29271), + 104: uint16(29272), + 105: uint16(29274), + 106: uint16(29276), + 107: uint16(29278), + 108: uint16(29280), + 109: uint16(29283), + 110: uint16(29284), + 111: uint16(29285), + 112: uint16(29288), + 113: uint16(29290), + 114: uint16(29291), + 115: uint16(29292), + 116: uint16(29293), + 117: uint16(29296), + 118: uint16(29297), + 119: uint16(29299), + 120: uint16(29300), + 121: uint16(29302), + 122: uint16(29303), + 123: uint16(29304), + 124: uint16(29307), + 125: uint16(29308), + 126: uint16(29309), + 127: uint16(29314), + 128: uint16(29315), + 129: uint16(29317), + 130: uint16(29318), + 131: uint16(29319), + 132: uint16(29320), + 133: uint16(29321), + 134: uint16(29324), + 135: uint16(29326), + 136: uint16(29328), + 137: uint16(29329), + 138: uint16(29331), + 139: uint16(29332), + 140: uint16(29333), + 141: uint16(29334), + 142: uint16(29335), + 143: uint16(29336), + 144: uint16(29337), + 145: uint16(29338), + 146: uint16(29339), + 147: uint16(29340), + 148: uint16(29341), + 149: uint16(29342), + 150: uint16(29344), + 151: uint16(29345), + 152: uint16(29346), + 153: uint16(29347), + 154: uint16(29348), + 155: uint16(29349), + 156: uint16(29350), + 157: uint16(29351), + 158: uint16(29352), + 159: uint16(29353), + 160: uint16(29354), + 161: uint16(29355), + 162: uint16(29358), + 163: uint16(29361), + 164: uint16(29362), + 165: uint16(29363), + 166: uint16(29365), + 167: uint16(29370), + 168: uint16(29371), + 169: uint16(29372), + 170: uint16(29373), + 171: uint16(29374), + 172: uint16(29375), + 173: uint16(29376), + 174: uint16(29381), + 175: uint16(29382), + 176: uint16(29383), + 177: uint16(29385), + 178: uint16(29386), + 179: uint16(29387), + 180: uint16(29388), + 181: uint16(29391), + 182: uint16(29393), + 183: uint16(29395), + 184: uint16(29396), + 185: uint16(29397), + 186: uint16(29398), + 187: uint16(29400), + 188: uint16(29402), + 189: uint16(29403), + }, + 32: { + 0: uint16(58566), + 1: uint16(58567), + 2: uint16(58568), + 3: uint16(58569), + 4: uint16(58570), + 5: uint16(58571), + 6: uint16(58572), + 7: uint16(58573), + 8: uint16(58574), + 9: uint16(58575), + 10: uint16(58576), + 11: uint16(58577), + 12: uint16(58578), + 13: uint16(58579), + 14: uint16(58580), + 15: uint16(58581), + 16: uint16(58582), + 17: uint16(58583), + 18: uint16(58584), + 19: uint16(58585), + 20: uint16(58586), + 21: uint16(58587), + 22: uint16(58588), + 23: uint16(58589), + 24: uint16(58590), + 25: uint16(58591), + 26: uint16(58592), + 27: uint16(58593), + 28: uint16(58594), + 29: uint16(58595), + 30: uint16(58596), + 31: uint16(58597), + 32: uint16(58598), + 33: uint16(58599), + 34: uint16(58600), + 35: uint16(58601), + 36: uint16(58602), + 37: uint16(58603), + 38: uint16(58604), + 39: uint16(58605), + 40: uint16(58606), + 41: uint16(58607), + 42: uint16(58608), + 43: uint16(58609), + 44: uint16(58610), + 45: uint16(58611), + 46: uint16(58612), + 47: uint16(58613), + 48: uint16(58614), + 49: uint16(58615), + 50: uint16(58616), + 51: uint16(58617), + 52: uint16(58618), + 53: uint16(58619), + 54: uint16(58620), + 55: uint16(58621), + 56: uint16(58622), + 57: uint16(58623), + 58: uint16(58624), + 59: uint16(58625), + 60: uint16(58626), + 61: uint16(58627), + 62: uint16(58628), + 63: uint16(58629), + 64: uint16(58630), + 65: uint16(58631), + 66: uint16(58632), + 67: uint16(58633), + 68: uint16(58634), + 69: uint16(58635), + 70: uint16(58636), + 71: uint16(58637), + 72: uint16(58638), + 73: uint16(58639), + 74: uint16(58640), + 75: uint16(58641), + 76: uint16(58642), + 77: uint16(58643), + 78: uint16(58644), + 79: uint16(58645), + 80: uint16(58646), + 81: uint16(58647), + 82: uint16(58648), + 83: uint16(58649), + 84: uint16(58650), + 85: uint16(58651), + 86: uint16(58652), + 87: uint16(58653), + 88: uint16(58654), + 89: uint16(58655), + 90: uint16(58656), + 91: uint16(58657), + 92: uint16(58658), + 93: uint16(58659), + 94: uint16(58660), + 95: uint16(58661), + 96: uint16(12288), + 97: uint16(12289), + 98: uint16(12290), + 99: uint16(183), + 100: uint16(713), + 101: uint16(711), + 102: uint16(168), + 103: uint16(12291), + 104: uint16(12293), + 105: uint16(8212), + 106: uint16(65374), + 107: uint16(8214), + 108: uint16(8230), + 109: uint16(8216), + 110: uint16(8217), + 111: uint16(8220), + 112: uint16(8221), + 113: uint16(12308), + 114: uint16(12309), + 115: uint16(12296), + 116: uint16(12297), + 117: uint16(12298), + 118: uint16(12299), + 119: uint16(12300), + 120: uint16(12301), + 121: uint16(12302), + 122: uint16(12303), + 123: uint16(12310), + 124: uint16(12311), + 125: uint16(12304), + 126: uint16(12305), + 127: uint16(177), + 128: uint16(215), + 129: uint16(247), + 130: uint16(8758), + 131: uint16(8743), + 132: uint16(8744), + 133: uint16(8721), + 134: uint16(8719), + 135: uint16(8746), + 136: uint16(8745), + 137: uint16(8712), + 138: uint16(8759), + 139: uint16(8730), + 140: uint16(8869), + 141: uint16(8741), + 142: uint16(8736), + 143: uint16(8978), + 144: uint16(8857), + 145: uint16(8747), + 146: uint16(8750), + 147: uint16(8801), + 148: uint16(8780), + 149: uint16(8776), + 150: uint16(8765), + 151: uint16(8733), + 152: uint16(8800), + 153: uint16(8814), + 154: uint16(8815), + 155: uint16(8804), + 156: uint16(8805), + 157: uint16(8734), + 158: uint16(8757), + 159: uint16(8756), + 160: uint16(9794), + 161: uint16(9792), + 162: uint16(176), + 163: uint16(8242), + 164: uint16(8243), + 165: uint16(8451), + 166: uint16(65284), + 167: uint16(164), + 168: uint16(65504), + 169: uint16(65505), + 170: uint16(8240), + 171: uint16(167), + 172: uint16(8470), + 173: uint16(9734), + 174: uint16(9733), + 175: uint16(9675), + 176: uint16(9679), + 177: uint16(9678), + 178: uint16(9671), + 179: uint16(9670), + 180: uint16(9633), + 181: uint16(9632), + 182: uint16(9651), + 183: uint16(9650), + 184: uint16(8251), + 185: uint16(8594), + 186: uint16(8592), + 187: uint16(8593), + 188: uint16(8595), + 189: uint16(12307), + }, + 33: { + 0: uint16(58662), + 1: uint16(58663), + 2: uint16(58664), + 3: uint16(58665), + 4: uint16(58666), + 5: uint16(58667), + 6: uint16(58668), + 7: uint16(58669), + 8: uint16(58670), + 9: uint16(58671), + 10: uint16(58672), + 11: uint16(58673), + 12: uint16(58674), + 13: uint16(58675), + 14: uint16(58676), + 15: uint16(58677), + 16: uint16(58678), + 17: uint16(58679), + 18: uint16(58680), + 19: uint16(58681), + 20: uint16(58682), + 21: uint16(58683), + 22: uint16(58684), + 23: uint16(58685), + 24: uint16(58686), + 25: uint16(58687), + 26: uint16(58688), + 27: uint16(58689), + 28: uint16(58690), + 29: uint16(58691), + 30: uint16(58692), + 31: uint16(58693), + 32: uint16(58694), + 33: uint16(58695), + 34: uint16(58696), + 35: uint16(58697), + 36: uint16(58698), + 37: uint16(58699), + 38: uint16(58700), + 39: uint16(58701), + 40: uint16(58702), + 41: uint16(58703), + 42: uint16(58704), + 43: uint16(58705), + 44: uint16(58706), + 45: uint16(58707), + 46: uint16(58708), + 47: uint16(58709), + 48: uint16(58710), + 49: uint16(58711), + 50: uint16(58712), + 51: uint16(58713), + 52: uint16(58714), + 53: uint16(58715), + 54: uint16(58716), + 55: uint16(58717), + 56: uint16(58718), + 57: uint16(58719), + 58: uint16(58720), + 59: uint16(58721), + 60: uint16(58722), + 61: uint16(58723), + 62: uint16(58724), + 63: uint16(58725), + 64: uint16(58726), + 65: uint16(58727), + 66: uint16(58728), + 67: uint16(58729), + 68: uint16(58730), + 69: uint16(58731), + 70: uint16(58732), + 71: uint16(58733), + 72: uint16(58734), + 73: uint16(58735), + 74: uint16(58736), + 75: uint16(58737), + 76: uint16(58738), + 77: uint16(58739), + 78: uint16(58740), + 79: uint16(58741), + 80: uint16(58742), + 81: uint16(58743), + 82: uint16(58744), + 83: uint16(58745), + 84: uint16(58746), + 85: uint16(58747), + 86: uint16(58748), + 87: uint16(58749), + 88: uint16(58750), + 89: uint16(58751), + 90: uint16(58752), + 91: uint16(58753), + 92: uint16(58754), + 93: uint16(58755), + 94: uint16(58756), + 95: uint16(58757), + 96: uint16(8560), + 97: uint16(8561), + 98: uint16(8562), + 99: uint16(8563), + 100: uint16(8564), + 101: uint16(8565), + 102: uint16(8566), + 103: uint16(8567), + 104: uint16(8568), + 105: uint16(8569), + 106: uint16(59238), + 107: uint16(59239), + 108: uint16(59240), + 109: uint16(59241), + 110: uint16(59242), + 111: uint16(59243), + 112: uint16(9352), + 113: uint16(9353), + 114: uint16(9354), + 115: uint16(9355), + 116: uint16(9356), + 117: uint16(9357), + 118: uint16(9358), + 119: uint16(9359), + 120: uint16(9360), + 121: uint16(9361), + 122: uint16(9362), + 123: uint16(9363), + 124: uint16(9364), + 125: uint16(9365), + 126: uint16(9366), + 127: uint16(9367), + 128: uint16(9368), + 129: uint16(9369), + 130: uint16(9370), + 131: uint16(9371), + 132: uint16(9332), + 133: uint16(9333), + 134: uint16(9334), + 135: uint16(9335), + 136: uint16(9336), + 137: uint16(9337), + 138: uint16(9338), + 139: uint16(9339), + 140: uint16(9340), + 141: uint16(9341), + 142: uint16(9342), + 143: uint16(9343), + 144: uint16(9344), + 145: uint16(9345), + 146: uint16(9346), + 147: uint16(9347), + 148: uint16(9348), + 149: uint16(9349), + 150: uint16(9350), + 151: uint16(9351), + 152: uint16(9312), + 153: uint16(9313), + 154: uint16(9314), + 155: uint16(9315), + 156: uint16(9316), + 157: uint16(9317), + 158: uint16(9318), + 159: uint16(9319), + 160: uint16(9320), + 161: uint16(9321), + 162: uint16(8364), + 163: uint16(59245), + 164: uint16(12832), + 165: uint16(12833), + 166: uint16(12834), + 167: uint16(12835), + 168: uint16(12836), + 169: uint16(12837), + 170: uint16(12838), + 171: uint16(12839), + 172: uint16(12840), + 173: uint16(12841), + 174: uint16(59246), + 175: uint16(59247), + 176: uint16(8544), + 177: uint16(8545), + 178: uint16(8546), + 179: uint16(8547), + 180: uint16(8548), + 181: uint16(8549), + 182: uint16(8550), + 183: uint16(8551), + 184: uint16(8552), + 185: uint16(8553), + 186: uint16(8554), + 187: uint16(8555), + 188: uint16(59248), + 189: uint16(59249), + }, + 34: { + 0: uint16(58758), + 1: uint16(58759), + 2: uint16(58760), + 3: uint16(58761), + 4: uint16(58762), + 5: uint16(58763), + 6: uint16(58764), + 7: uint16(58765), + 8: uint16(58766), + 9: uint16(58767), + 10: uint16(58768), + 11: uint16(58769), + 12: uint16(58770), + 13: uint16(58771), + 14: uint16(58772), + 15: uint16(58773), + 16: uint16(58774), + 17: uint16(58775), + 18: uint16(58776), + 19: uint16(58777), + 20: uint16(58778), + 21: uint16(58779), + 22: uint16(58780), + 23: uint16(58781), + 24: uint16(58782), + 25: uint16(58783), + 26: uint16(58784), + 27: uint16(58785), + 28: uint16(58786), + 29: uint16(58787), + 30: uint16(58788), + 31: uint16(58789), + 32: uint16(58790), + 33: uint16(58791), + 34: uint16(58792), + 35: uint16(58793), + 36: uint16(58794), + 37: uint16(58795), + 38: uint16(58796), + 39: uint16(58797), + 40: uint16(58798), + 41: uint16(58799), + 42: uint16(58800), + 43: uint16(58801), + 44: uint16(58802), + 45: uint16(58803), + 46: uint16(58804), + 47: uint16(58805), + 48: uint16(58806), + 49: uint16(58807), + 50: uint16(58808), + 51: uint16(58809), + 52: uint16(58810), + 53: uint16(58811), + 54: uint16(58812), + 55: uint16(58813), + 56: uint16(58814), + 57: uint16(58815), + 58: uint16(58816), + 59: uint16(58817), + 60: uint16(58818), + 61: uint16(58819), + 62: uint16(58820), + 63: uint16(58821), + 64: uint16(58822), + 65: uint16(58823), + 66: uint16(58824), + 67: uint16(58825), + 68: uint16(58826), + 69: uint16(58827), + 70: uint16(58828), + 71: uint16(58829), + 72: uint16(58830), + 73: uint16(58831), + 74: uint16(58832), + 75: uint16(58833), + 76: uint16(58834), + 77: uint16(58835), + 78: uint16(58836), + 79: uint16(58837), + 80: uint16(58838), + 81: uint16(58839), + 82: uint16(58840), + 83: uint16(58841), + 84: uint16(58842), + 85: uint16(58843), + 86: uint16(58844), + 87: uint16(58845), + 88: uint16(58846), + 89: uint16(58847), + 90: uint16(58848), + 91: uint16(58849), + 92: uint16(58850), + 93: uint16(58851), + 94: uint16(58852), + 95: uint16(58853), + 96: uint16(65281), + 97: uint16(65282), + 98: uint16(65283), + 99: uint16(65509), + 100: uint16(65285), + 101: uint16(65286), + 102: uint16(65287), + 103: uint16(65288), + 104: uint16(65289), + 105: uint16(65290), + 106: uint16(65291), + 107: uint16(65292), + 108: uint16(65293), + 109: uint16(65294), + 110: uint16(65295), + 111: uint16(65296), + 112: uint16(65297), + 113: uint16(65298), + 114: uint16(65299), + 115: uint16(65300), + 116: uint16(65301), + 117: uint16(65302), + 118: uint16(65303), + 119: uint16(65304), + 120: uint16(65305), + 121: uint16(65306), + 122: uint16(65307), + 123: uint16(65308), + 124: uint16(65309), + 125: uint16(65310), + 126: uint16(65311), + 127: uint16(65312), + 128: uint16(65313), + 129: uint16(65314), + 130: uint16(65315), + 131: uint16(65316), + 132: uint16(65317), + 133: uint16(65318), + 134: uint16(65319), + 135: uint16(65320), + 136: uint16(65321), + 137: uint16(65322), + 138: uint16(65323), + 139: uint16(65324), + 140: uint16(65325), + 141: uint16(65326), + 142: uint16(65327), + 143: uint16(65328), + 144: uint16(65329), + 145: uint16(65330), + 146: uint16(65331), + 147: uint16(65332), + 148: uint16(65333), + 149: uint16(65334), + 150: uint16(65335), + 151: uint16(65336), + 152: uint16(65337), + 153: uint16(65338), + 154: uint16(65339), + 155: uint16(65340), + 156: uint16(65341), + 157: uint16(65342), + 158: uint16(65343), + 159: uint16(65344), + 160: uint16(65345), + 161: uint16(65346), + 162: uint16(65347), + 163: uint16(65348), + 164: uint16(65349), + 165: uint16(65350), + 166: uint16(65351), + 167: uint16(65352), + 168: uint16(65353), + 169: uint16(65354), + 170: uint16(65355), + 171: uint16(65356), + 172: uint16(65357), + 173: uint16(65358), + 174: uint16(65359), + 175: uint16(65360), + 176: uint16(65361), + 177: uint16(65362), + 178: uint16(65363), + 179: uint16(65364), + 180: uint16(65365), + 181: uint16(65366), + 182: uint16(65367), + 183: uint16(65368), + 184: uint16(65369), + 185: uint16(65370), + 186: uint16(65371), + 187: uint16(65372), + 188: uint16(65373), + 189: uint16(65507), + }, + 35: { + 0: uint16(58854), + 1: uint16(58855), + 2: uint16(58856), + 3: uint16(58857), + 4: uint16(58858), + 5: uint16(58859), + 6: uint16(58860), + 7: uint16(58861), + 8: uint16(58862), + 9: uint16(58863), + 10: uint16(58864), + 11: uint16(58865), + 12: uint16(58866), + 13: uint16(58867), + 14: uint16(58868), + 15: uint16(58869), + 16: uint16(58870), + 17: uint16(58871), + 18: uint16(58872), + 19: uint16(58873), + 20: uint16(58874), + 21: uint16(58875), + 22: uint16(58876), + 23: uint16(58877), + 24: uint16(58878), + 25: uint16(58879), + 26: uint16(58880), + 27: uint16(58881), + 28: uint16(58882), + 29: uint16(58883), + 30: uint16(58884), + 31: uint16(58885), + 32: uint16(58886), + 33: uint16(58887), + 34: uint16(58888), + 35: uint16(58889), + 36: uint16(58890), + 37: uint16(58891), + 38: uint16(58892), + 39: uint16(58893), + 40: uint16(58894), + 41: uint16(58895), + 42: uint16(58896), + 43: uint16(58897), + 44: uint16(58898), + 45: uint16(58899), + 46: uint16(58900), + 47: uint16(58901), + 48: uint16(58902), + 49: uint16(58903), + 50: uint16(58904), + 51: uint16(58905), + 52: uint16(58906), + 53: uint16(58907), + 54: uint16(58908), + 55: uint16(58909), + 56: uint16(58910), + 57: uint16(58911), + 58: uint16(58912), + 59: uint16(58913), + 60: uint16(58914), + 61: uint16(58915), + 62: uint16(58916), + 63: uint16(58917), + 64: uint16(58918), + 65: uint16(58919), + 66: uint16(58920), + 67: uint16(58921), + 68: uint16(58922), + 69: uint16(58923), + 70: uint16(58924), + 71: uint16(58925), + 72: uint16(58926), + 73: uint16(58927), + 74: uint16(58928), + 75: uint16(58929), + 76: uint16(58930), + 77: uint16(58931), + 78: uint16(58932), + 79: uint16(58933), + 80: uint16(58934), + 81: uint16(58935), + 82: uint16(58936), + 83: uint16(58937), + 84: uint16(58938), + 85: uint16(58939), + 86: uint16(58940), + 87: uint16(58941), + 88: uint16(58942), + 89: uint16(58943), + 90: uint16(58944), + 91: uint16(58945), + 92: uint16(58946), + 93: uint16(58947), + 94: uint16(58948), + 95: uint16(58949), + 96: uint16(12353), + 97: uint16(12354), + 98: uint16(12355), + 99: uint16(12356), + 100: uint16(12357), + 101: uint16(12358), + 102: uint16(12359), + 103: uint16(12360), + 104: uint16(12361), + 105: uint16(12362), + 106: uint16(12363), + 107: uint16(12364), + 108: uint16(12365), + 109: uint16(12366), + 110: uint16(12367), + 111: uint16(12368), + 112: uint16(12369), + 113: uint16(12370), + 114: uint16(12371), + 115: uint16(12372), + 116: uint16(12373), + 117: uint16(12374), + 118: uint16(12375), + 119: uint16(12376), + 120: uint16(12377), + 121: uint16(12378), + 122: uint16(12379), + 123: uint16(12380), + 124: uint16(12381), + 125: uint16(12382), + 126: uint16(12383), + 127: uint16(12384), + 128: uint16(12385), + 129: uint16(12386), + 130: uint16(12387), + 131: uint16(12388), + 132: uint16(12389), + 133: uint16(12390), + 134: uint16(12391), + 135: uint16(12392), + 136: uint16(12393), + 137: uint16(12394), + 138: uint16(12395), + 139: uint16(12396), + 140: uint16(12397), + 141: uint16(12398), + 142: uint16(12399), + 143: uint16(12400), + 144: uint16(12401), + 145: uint16(12402), + 146: uint16(12403), + 147: uint16(12404), + 148: uint16(12405), + 149: uint16(12406), + 150: uint16(12407), + 151: uint16(12408), + 152: uint16(12409), + 153: uint16(12410), + 154: uint16(12411), + 155: uint16(12412), + 156: uint16(12413), + 157: uint16(12414), + 158: uint16(12415), + 159: uint16(12416), + 160: uint16(12417), + 161: uint16(12418), + 162: uint16(12419), + 163: uint16(12420), + 164: uint16(12421), + 165: uint16(12422), + 166: uint16(12423), + 167: uint16(12424), + 168: uint16(12425), + 169: uint16(12426), + 170: uint16(12427), + 171: uint16(12428), + 172: uint16(12429), + 173: uint16(12430), + 174: uint16(12431), + 175: uint16(12432), + 176: uint16(12433), + 177: uint16(12434), + 178: uint16(12435), + 179: uint16(59250), + 180: uint16(59251), + 181: uint16(59252), + 182: uint16(59253), + 183: uint16(59254), + 184: uint16(59255), + 185: uint16(59256), + 186: uint16(59257), + 187: uint16(59258), + 188: uint16(59259), + 189: uint16(59260), + }, + 36: { + 0: uint16(58950), + 1: uint16(58951), + 2: uint16(58952), + 3: uint16(58953), + 4: uint16(58954), + 5: uint16(58955), + 6: uint16(58956), + 7: uint16(58957), + 8: uint16(58958), + 9: uint16(58959), + 10: uint16(58960), + 11: uint16(58961), + 12: uint16(58962), + 13: uint16(58963), + 14: uint16(58964), + 15: uint16(58965), + 16: uint16(58966), + 17: uint16(58967), + 18: uint16(58968), + 19: uint16(58969), + 20: uint16(58970), + 21: uint16(58971), + 22: uint16(58972), + 23: uint16(58973), + 24: uint16(58974), + 25: uint16(58975), + 26: uint16(58976), + 27: uint16(58977), + 28: uint16(58978), + 29: uint16(58979), + 30: uint16(58980), + 31: uint16(58981), + 32: uint16(58982), + 33: uint16(58983), + 34: uint16(58984), + 35: uint16(58985), + 36: uint16(58986), + 37: uint16(58987), + 38: uint16(58988), + 39: uint16(58989), + 40: uint16(58990), + 41: uint16(58991), + 42: uint16(58992), + 43: uint16(58993), + 44: uint16(58994), + 45: uint16(58995), + 46: uint16(58996), + 47: uint16(58997), + 48: uint16(58998), + 49: uint16(58999), + 50: uint16(59000), + 51: uint16(59001), + 52: uint16(59002), + 53: uint16(59003), + 54: uint16(59004), + 55: uint16(59005), + 56: uint16(59006), + 57: uint16(59007), + 58: uint16(59008), + 59: uint16(59009), + 60: uint16(59010), + 61: uint16(59011), + 62: uint16(59012), + 63: uint16(59013), + 64: uint16(59014), + 65: uint16(59015), + 66: uint16(59016), + 67: uint16(59017), + 68: uint16(59018), + 69: uint16(59019), + 70: uint16(59020), + 71: uint16(59021), + 72: uint16(59022), + 73: uint16(59023), + 74: uint16(59024), + 75: uint16(59025), + 76: uint16(59026), + 77: uint16(59027), + 78: uint16(59028), + 79: uint16(59029), + 80: uint16(59030), + 81: uint16(59031), + 82: uint16(59032), + 83: uint16(59033), + 84: uint16(59034), + 85: uint16(59035), + 86: uint16(59036), + 87: uint16(59037), + 88: uint16(59038), + 89: uint16(59039), + 90: uint16(59040), + 91: uint16(59041), + 92: uint16(59042), + 93: uint16(59043), + 94: uint16(59044), + 95: uint16(59045), + 96: uint16(12449), + 97: uint16(12450), + 98: uint16(12451), + 99: uint16(12452), + 100: uint16(12453), + 101: uint16(12454), + 102: uint16(12455), + 103: uint16(12456), + 104: uint16(12457), + 105: uint16(12458), + 106: uint16(12459), + 107: uint16(12460), + 108: uint16(12461), + 109: uint16(12462), + 110: uint16(12463), + 111: uint16(12464), + 112: uint16(12465), + 113: uint16(12466), + 114: uint16(12467), + 115: uint16(12468), + 116: uint16(12469), + 117: uint16(12470), + 118: uint16(12471), + 119: uint16(12472), + 120: uint16(12473), + 121: uint16(12474), + 122: uint16(12475), + 123: uint16(12476), + 124: uint16(12477), + 125: uint16(12478), + 126: uint16(12479), + 127: uint16(12480), + 128: uint16(12481), + 129: uint16(12482), + 130: uint16(12483), + 131: uint16(12484), + 132: uint16(12485), + 133: uint16(12486), + 134: uint16(12487), + 135: uint16(12488), + 136: uint16(12489), + 137: uint16(12490), + 138: uint16(12491), + 139: uint16(12492), + 140: uint16(12493), + 141: uint16(12494), + 142: uint16(12495), + 143: uint16(12496), + 144: uint16(12497), + 145: uint16(12498), + 146: uint16(12499), + 147: uint16(12500), + 148: uint16(12501), + 149: uint16(12502), + 150: uint16(12503), + 151: uint16(12504), + 152: uint16(12505), + 153: uint16(12506), + 154: uint16(12507), + 155: uint16(12508), + 156: uint16(12509), + 157: uint16(12510), + 158: uint16(12511), + 159: uint16(12512), + 160: uint16(12513), + 161: uint16(12514), + 162: uint16(12515), + 163: uint16(12516), + 164: uint16(12517), + 165: uint16(12518), + 166: uint16(12519), + 167: uint16(12520), + 168: uint16(12521), + 169: uint16(12522), + 170: uint16(12523), + 171: uint16(12524), + 172: uint16(12525), + 173: uint16(12526), + 174: uint16(12527), + 175: uint16(12528), + 176: uint16(12529), + 177: uint16(12530), + 178: uint16(12531), + 179: uint16(12532), + 180: uint16(12533), + 181: uint16(12534), + 182: uint16(59261), + 183: uint16(59262), + 184: uint16(59263), + 185: uint16(59264), + 186: uint16(59265), + 187: uint16(59266), + 188: uint16(59267), + 189: uint16(59268), + }, + 37: { + 0: uint16(59046), + 1: uint16(59047), + 2: uint16(59048), + 3: uint16(59049), + 4: uint16(59050), + 5: uint16(59051), + 6: uint16(59052), + 7: uint16(59053), + 8: uint16(59054), + 9: uint16(59055), + 10: uint16(59056), + 11: uint16(59057), + 12: uint16(59058), + 13: uint16(59059), + 14: uint16(59060), + 15: uint16(59061), + 16: uint16(59062), + 17: uint16(59063), + 18: uint16(59064), + 19: uint16(59065), + 20: uint16(59066), + 21: uint16(59067), + 22: uint16(59068), + 23: uint16(59069), + 24: uint16(59070), + 25: uint16(59071), + 26: uint16(59072), + 27: uint16(59073), + 28: uint16(59074), + 29: uint16(59075), + 30: uint16(59076), + 31: uint16(59077), + 32: uint16(59078), + 33: uint16(59079), + 34: uint16(59080), + 35: uint16(59081), + 36: uint16(59082), + 37: uint16(59083), + 38: uint16(59084), + 39: uint16(59085), + 40: uint16(59086), + 41: uint16(59087), + 42: uint16(59088), + 43: uint16(59089), + 44: uint16(59090), + 45: uint16(59091), + 46: uint16(59092), + 47: uint16(59093), + 48: uint16(59094), + 49: uint16(59095), + 50: uint16(59096), + 51: uint16(59097), + 52: uint16(59098), + 53: uint16(59099), + 54: uint16(59100), + 55: uint16(59101), + 56: uint16(59102), + 57: uint16(59103), + 58: uint16(59104), + 59: uint16(59105), + 60: uint16(59106), + 61: uint16(59107), + 62: uint16(59108), + 63: uint16(59109), + 64: uint16(59110), + 65: uint16(59111), + 66: uint16(59112), + 67: uint16(59113), + 68: uint16(59114), + 69: uint16(59115), + 70: uint16(59116), + 71: uint16(59117), + 72: uint16(59118), + 73: uint16(59119), + 74: uint16(59120), + 75: uint16(59121), + 76: uint16(59122), + 77: uint16(59123), + 78: uint16(59124), + 79: uint16(59125), + 80: uint16(59126), + 81: uint16(59127), + 82: uint16(59128), + 83: uint16(59129), + 84: uint16(59130), + 85: uint16(59131), + 86: uint16(59132), + 87: uint16(59133), + 88: uint16(59134), + 89: uint16(59135), + 90: uint16(59136), + 91: uint16(59137), + 92: uint16(59138), + 93: uint16(59139), + 94: uint16(59140), + 95: uint16(59141), + 96: uint16(913), + 97: uint16(914), + 98: uint16(915), + 99: uint16(916), + 100: uint16(917), + 101: uint16(918), + 102: uint16(919), + 103: uint16(920), + 104: uint16(921), + 105: uint16(922), + 106: uint16(923), + 107: uint16(924), + 108: uint16(925), + 109: uint16(926), + 110: uint16(927), + 111: uint16(928), + 112: uint16(929), + 113: uint16(931), + 114: uint16(932), + 115: uint16(933), + 116: uint16(934), + 117: uint16(935), + 118: uint16(936), + 119: uint16(937), + 120: uint16(59269), + 121: uint16(59270), + 122: uint16(59271), + 123: uint16(59272), + 124: uint16(59273), + 125: uint16(59274), + 126: uint16(59275), + 127: uint16(59276), + 128: uint16(945), + 129: uint16(946), + 130: uint16(947), + 131: uint16(948), + 132: uint16(949), + 133: uint16(950), + 134: uint16(951), + 135: uint16(952), + 136: uint16(953), + 137: uint16(954), + 138: uint16(955), + 139: uint16(956), + 140: uint16(957), + 141: uint16(958), + 142: uint16(959), + 143: uint16(960), + 144: uint16(961), + 145: uint16(963), + 146: uint16(964), + 147: uint16(965), + 148: uint16(966), + 149: uint16(967), + 150: uint16(968), + 151: uint16(969), + 152: uint16(59277), + 153: uint16(59278), + 154: uint16(59279), + 155: uint16(59280), + 156: uint16(59281), + 157: uint16(59282), + 158: uint16(59283), + 159: uint16(65077), + 160: uint16(65078), + 161: uint16(65081), + 162: uint16(65082), + 163: uint16(65087), + 164: uint16(65088), + 165: uint16(65085), + 166: uint16(65086), + 167: uint16(65089), + 168: uint16(65090), + 169: uint16(65091), + 170: uint16(65092), + 171: uint16(59284), + 172: uint16(59285), + 173: uint16(65083), + 174: uint16(65084), + 175: uint16(65079), + 176: uint16(65080), + 177: uint16(65073), + 178: uint16(59286), + 179: uint16(65075), + 180: uint16(65076), + 181: uint16(59287), + 182: uint16(59288), + 183: uint16(59289), + 184: uint16(59290), + 185: uint16(59291), + 186: uint16(59292), + 187: uint16(59293), + 188: uint16(59294), + 189: uint16(59295), + }, + 38: { + 0: uint16(59142), + 1: uint16(59143), + 2: uint16(59144), + 3: uint16(59145), + 4: uint16(59146), + 5: uint16(59147), + 6: uint16(59148), + 7: uint16(59149), + 8: uint16(59150), + 9: uint16(59151), + 10: uint16(59152), + 11: uint16(59153), + 12: uint16(59154), + 13: uint16(59155), + 14: uint16(59156), + 15: uint16(59157), + 16: uint16(59158), + 17: uint16(59159), + 18: uint16(59160), + 19: uint16(59161), + 20: uint16(59162), + 21: uint16(59163), + 22: uint16(59164), + 23: uint16(59165), + 24: uint16(59166), + 25: uint16(59167), + 26: uint16(59168), + 27: uint16(59169), + 28: uint16(59170), + 29: uint16(59171), + 30: uint16(59172), + 31: uint16(59173), + 32: uint16(59174), + 33: uint16(59175), + 34: uint16(59176), + 35: uint16(59177), + 36: uint16(59178), + 37: uint16(59179), + 38: uint16(59180), + 39: uint16(59181), + 40: uint16(59182), + 41: uint16(59183), + 42: uint16(59184), + 43: uint16(59185), + 44: uint16(59186), + 45: uint16(59187), + 46: uint16(59188), + 47: uint16(59189), + 48: uint16(59190), + 49: uint16(59191), + 50: uint16(59192), + 51: uint16(59193), + 52: uint16(59194), + 53: uint16(59195), + 54: uint16(59196), + 55: uint16(59197), + 56: uint16(59198), + 57: uint16(59199), + 58: uint16(59200), + 59: uint16(59201), + 60: uint16(59202), + 61: uint16(59203), + 62: uint16(59204), + 63: uint16(59205), + 64: uint16(59206), + 65: uint16(59207), + 66: uint16(59208), + 67: uint16(59209), + 68: uint16(59210), + 69: uint16(59211), + 70: uint16(59212), + 71: uint16(59213), + 72: uint16(59214), + 73: uint16(59215), + 74: uint16(59216), + 75: uint16(59217), + 76: uint16(59218), + 77: uint16(59219), + 78: uint16(59220), + 79: uint16(59221), + 80: uint16(59222), + 81: uint16(59223), + 82: uint16(59224), + 83: uint16(59225), + 84: uint16(59226), + 85: uint16(59227), + 86: uint16(59228), + 87: uint16(59229), + 88: uint16(59230), + 89: uint16(59231), + 90: uint16(59232), + 91: uint16(59233), + 92: uint16(59234), + 93: uint16(59235), + 94: uint16(59236), + 95: uint16(59237), + 96: uint16(1040), + 97: uint16(1041), + 98: uint16(1042), + 99: uint16(1043), + 100: uint16(1044), + 101: uint16(1045), + 102: uint16(1025), + 103: uint16(1046), + 104: uint16(1047), + 105: uint16(1048), + 106: uint16(1049), + 107: uint16(1050), + 108: uint16(1051), + 109: uint16(1052), + 110: uint16(1053), + 111: uint16(1054), + 112: uint16(1055), + 113: uint16(1056), + 114: uint16(1057), + 115: uint16(1058), + 116: uint16(1059), + 117: uint16(1060), + 118: uint16(1061), + 119: uint16(1062), + 120: uint16(1063), + 121: uint16(1064), + 122: uint16(1065), + 123: uint16(1066), + 124: uint16(1067), + 125: uint16(1068), + 126: uint16(1069), + 127: uint16(1070), + 128: uint16(1071), + 129: uint16(59296), + 130: uint16(59297), + 131: uint16(59298), + 132: uint16(59299), + 133: uint16(59300), + 134: uint16(59301), + 135: uint16(59302), + 136: uint16(59303), + 137: uint16(59304), + 138: uint16(59305), + 139: uint16(59306), + 140: uint16(59307), + 141: uint16(59308), + 142: uint16(59309), + 143: uint16(59310), + 144: uint16(1072), + 145: uint16(1073), + 146: uint16(1074), + 147: uint16(1075), + 148: uint16(1076), + 149: uint16(1077), + 150: uint16(1105), + 151: uint16(1078), + 152: uint16(1079), + 153: uint16(1080), + 154: uint16(1081), + 155: uint16(1082), + 156: uint16(1083), + 157: uint16(1084), + 158: uint16(1085), + 159: uint16(1086), + 160: uint16(1087), + 161: uint16(1088), + 162: uint16(1089), + 163: uint16(1090), + 164: uint16(1091), + 165: uint16(1092), + 166: uint16(1093), + 167: uint16(1094), + 168: uint16(1095), + 169: uint16(1096), + 170: uint16(1097), + 171: uint16(1098), + 172: uint16(1099), + 173: uint16(1100), + 174: uint16(1101), + 175: uint16(1102), + 176: uint16(1103), + 177: uint16(59311), + 178: uint16(59312), + 179: uint16(59313), + 180: uint16(59314), + 181: uint16(59315), + 182: uint16(59316), + 183: uint16(59317), + 184: uint16(59318), + 185: uint16(59319), + 186: uint16(59320), + 187: uint16(59321), + 188: uint16(59322), + 189: uint16(59323), + }, + 39: { + 0: uint16(714), + 1: uint16(715), + 2: uint16(729), + 3: uint16(8211), + 4: uint16(8213), + 5: uint16(8229), + 6: uint16(8245), + 7: uint16(8453), + 8: uint16(8457), + 9: uint16(8598), + 10: uint16(8599), + 11: uint16(8600), + 12: uint16(8601), + 13: uint16(8725), + 14: uint16(8735), + 15: uint16(8739), + 16: uint16(8786), + 17: uint16(8806), + 18: uint16(8807), + 19: uint16(8895), + 20: uint16(9552), + 21: uint16(9553), + 22: uint16(9554), + 23: uint16(9555), + 24: uint16(9556), + 25: uint16(9557), + 26: uint16(9558), + 27: uint16(9559), + 28: uint16(9560), + 29: uint16(9561), + 30: uint16(9562), + 31: uint16(9563), + 32: uint16(9564), + 33: uint16(9565), + 34: uint16(9566), + 35: uint16(9567), + 36: uint16(9568), + 37: uint16(9569), + 38: uint16(9570), + 39: uint16(9571), + 40: uint16(9572), + 41: uint16(9573), + 42: uint16(9574), + 43: uint16(9575), + 44: uint16(9576), + 45: uint16(9577), + 46: uint16(9578), + 47: uint16(9579), + 48: uint16(9580), + 49: uint16(9581), + 50: uint16(9582), + 51: uint16(9583), + 52: uint16(9584), + 53: uint16(9585), + 54: uint16(9586), + 55: uint16(9587), + 56: uint16(9601), + 57: uint16(9602), + 58: uint16(9603), + 59: uint16(9604), + 60: uint16(9605), + 61: uint16(9606), + 62: uint16(9607), + 63: uint16(9608), + 64: uint16(9609), + 65: uint16(9610), + 66: uint16(9611), + 67: uint16(9612), + 68: uint16(9613), + 69: uint16(9614), + 70: uint16(9615), + 71: uint16(9619), + 72: uint16(9620), + 73: uint16(9621), + 74: uint16(9660), + 75: uint16(9661), + 76: uint16(9698), + 77: uint16(9699), + 78: uint16(9700), + 79: uint16(9701), + 80: uint16(9737), + 81: uint16(8853), + 82: uint16(12306), + 83: uint16(12317), + 84: uint16(12318), + 85: uint16(59324), + 86: uint16(59325), + 87: uint16(59326), + 88: uint16(59327), + 89: uint16(59328), + 90: uint16(59329), + 91: uint16(59330), + 92: uint16(59331), + 93: uint16(59332), + 94: uint16(59333), + 95: uint16(59334), + 96: uint16(257), + 97: uint16(225), + 98: uint16(462), + 99: uint16(224), + 100: uint16(275), + 101: uint16(233), + 102: uint16(283), + 103: uint16(232), + 104: uint16(299), + 105: uint16(237), + 106: uint16(464), + 107: uint16(236), + 108: uint16(333), + 109: uint16(243), + 110: uint16(466), + 111: uint16(242), + 112: uint16(363), + 113: uint16(250), + 114: uint16(468), + 115: uint16(249), + 116: uint16(470), + 117: uint16(472), + 118: uint16(474), + 119: uint16(476), + 120: uint16(252), + 121: uint16(234), + 122: uint16(593), + 123: uint16(59335), + 124: uint16(324), + 125: uint16(328), + 126: uint16(505), + 127: uint16(609), + 128: uint16(59337), + 129: uint16(59338), + 130: uint16(59339), + 131: uint16(59340), + 132: uint16(12549), + 133: uint16(12550), + 134: uint16(12551), + 135: uint16(12552), + 136: uint16(12553), + 137: uint16(12554), + 138: uint16(12555), + 139: uint16(12556), + 140: uint16(12557), + 141: uint16(12558), + 142: uint16(12559), + 143: uint16(12560), + 144: uint16(12561), + 145: uint16(12562), + 146: uint16(12563), + 147: uint16(12564), + 148: uint16(12565), + 149: uint16(12566), + 150: uint16(12567), + 151: uint16(12568), + 152: uint16(12569), + 153: uint16(12570), + 154: uint16(12571), + 155: uint16(12572), + 156: uint16(12573), + 157: uint16(12574), + 158: uint16(12575), + 159: uint16(12576), + 160: uint16(12577), + 161: uint16(12578), + 162: uint16(12579), + 163: uint16(12580), + 164: uint16(12581), + 165: uint16(12582), + 166: uint16(12583), + 167: uint16(12584), + 168: uint16(12585), + 169: uint16(59341), + 170: uint16(59342), + 171: uint16(59343), + 172: uint16(59344), + 173: uint16(59345), + 174: uint16(59346), + 175: uint16(59347), + 176: uint16(59348), + 177: uint16(59349), + 178: uint16(59350), + 179: uint16(59351), + 180: uint16(59352), + 181: uint16(59353), + 182: uint16(59354), + 183: uint16(59355), + 184: uint16(59356), + 185: uint16(59357), + 186: uint16(59358), + 187: uint16(59359), + 188: uint16(59360), + 189: uint16(59361), + }, + 40: { + 0: uint16(12321), + 1: uint16(12322), + 2: uint16(12323), + 3: uint16(12324), + 4: uint16(12325), + 5: uint16(12326), + 6: uint16(12327), + 7: uint16(12328), + 8: uint16(12329), + 9: uint16(12963), + 10: uint16(13198), + 11: uint16(13199), + 12: uint16(13212), + 13: uint16(13213), + 14: uint16(13214), + 15: uint16(13217), + 16: uint16(13252), + 17: uint16(13262), + 18: uint16(13265), + 19: uint16(13266), + 20: uint16(13269), + 21: uint16(65072), + 22: uint16(65506), + 23: uint16(65508), + 24: uint16(59362), + 25: uint16(8481), + 26: uint16(12849), + 27: uint16(59363), + 28: uint16(8208), + 29: uint16(59364), + 30: uint16(59365), + 31: uint16(59366), + 32: uint16(12540), + 33: uint16(12443), + 34: uint16(12444), + 35: uint16(12541), + 36: uint16(12542), + 37: uint16(12294), + 38: uint16(12445), + 39: uint16(12446), + 40: uint16(65097), + 41: uint16(65098), + 42: uint16(65099), + 43: uint16(65100), + 44: uint16(65101), + 45: uint16(65102), + 46: uint16(65103), + 47: uint16(65104), + 48: uint16(65105), + 49: uint16(65106), + 50: uint16(65108), + 51: uint16(65109), + 52: uint16(65110), + 53: uint16(65111), + 54: uint16(65113), + 55: uint16(65114), + 56: uint16(65115), + 57: uint16(65116), + 58: uint16(65117), + 59: uint16(65118), + 60: uint16(65119), + 61: uint16(65120), + 62: uint16(65121), + 63: uint16(65122), + 64: uint16(65123), + 65: uint16(65124), + 66: uint16(65125), + 67: uint16(65126), + 68: uint16(65128), + 69: uint16(65129), + 70: uint16(65130), + 71: uint16(65131), + 72: uint16(12350), + 73: uint16(12272), + 74: uint16(12273), + 75: uint16(12274), + 76: uint16(12275), + 77: uint16(12276), + 78: uint16(12277), + 79: uint16(12278), + 80: uint16(12279), + 81: uint16(12280), + 82: uint16(12281), + 83: uint16(12282), + 84: uint16(12283), + 85: uint16(12295), + 86: uint16(59380), + 87: uint16(59381), + 88: uint16(59382), + 89: uint16(59383), + 90: uint16(59384), + 91: uint16(59385), + 92: uint16(59386), + 93: uint16(59387), + 94: uint16(59388), + 95: uint16(59389), + 96: uint16(59390), + 97: uint16(59391), + 98: uint16(59392), + 99: uint16(9472), + 100: uint16(9473), + 101: uint16(9474), + 102: uint16(9475), + 103: uint16(9476), + 104: uint16(9477), + 105: uint16(9478), + 106: uint16(9479), + 107: uint16(9480), + 108: uint16(9481), + 109: uint16(9482), + 110: uint16(9483), + 111: uint16(9484), + 112: uint16(9485), + 113: uint16(9486), + 114: uint16(9487), + 115: uint16(9488), + 116: uint16(9489), + 117: uint16(9490), + 118: uint16(9491), + 119: uint16(9492), + 120: uint16(9493), + 121: uint16(9494), + 122: uint16(9495), + 123: uint16(9496), + 124: uint16(9497), + 125: uint16(9498), + 126: uint16(9499), + 127: uint16(9500), + 128: uint16(9501), + 129: uint16(9502), + 130: uint16(9503), + 131: uint16(9504), + 132: uint16(9505), + 133: uint16(9506), + 134: uint16(9507), + 135: uint16(9508), + 136: uint16(9509), + 137: uint16(9510), + 138: uint16(9511), + 139: uint16(9512), + 140: uint16(9513), + 141: uint16(9514), + 142: uint16(9515), + 143: uint16(9516), + 144: uint16(9517), + 145: uint16(9518), + 146: uint16(9519), + 147: uint16(9520), + 148: uint16(9521), + 149: uint16(9522), + 150: uint16(9523), + 151: uint16(9524), + 152: uint16(9525), + 153: uint16(9526), + 154: uint16(9527), + 155: uint16(9528), + 156: uint16(9529), + 157: uint16(9530), + 158: uint16(9531), + 159: uint16(9532), + 160: uint16(9533), + 161: uint16(9534), + 162: uint16(9535), + 163: uint16(9536), + 164: uint16(9537), + 165: uint16(9538), + 166: uint16(9539), + 167: uint16(9540), + 168: uint16(9541), + 169: uint16(9542), + 170: uint16(9543), + 171: uint16(9544), + 172: uint16(9545), + 173: uint16(9546), + 174: uint16(9547), + 175: uint16(59393), + 176: uint16(59394), + 177: uint16(59395), + 178: uint16(59396), + 179: uint16(59397), + 180: uint16(59398), + 181: uint16(59399), + 182: uint16(59400), + 183: uint16(59401), + 184: uint16(59402), + 185: uint16(59403), + 186: uint16(59404), + 187: uint16(59405), + 188: uint16(59406), + 189: uint16(59407), + }, + 41: { + 0: uint16(29404), + 1: uint16(29405), + 2: uint16(29407), + 3: uint16(29410), + 4: uint16(29411), + 5: uint16(29412), + 6: uint16(29413), + 7: uint16(29414), + 8: uint16(29415), + 9: uint16(29418), + 10: uint16(29419), + 11: uint16(29429), + 12: uint16(29430), + 13: uint16(29433), + 14: uint16(29437), + 15: uint16(29438), + 16: uint16(29439), + 17: uint16(29440), + 18: uint16(29442), + 19: uint16(29444), + 20: uint16(29445), + 21: uint16(29446), + 22: uint16(29447), + 23: uint16(29448), + 24: uint16(29449), + 25: uint16(29451), + 26: uint16(29452), + 27: uint16(29453), + 28: uint16(29455), + 29: uint16(29456), + 30: uint16(29457), + 31: uint16(29458), + 32: uint16(29460), + 33: uint16(29464), + 34: uint16(29465), + 35: uint16(29466), + 36: uint16(29471), + 37: uint16(29472), + 38: uint16(29475), + 39: uint16(29476), + 40: uint16(29478), + 41: uint16(29479), + 42: uint16(29480), + 43: uint16(29485), + 44: uint16(29487), + 45: uint16(29488), + 46: uint16(29490), + 47: uint16(29491), + 48: uint16(29493), + 49: uint16(29494), + 50: uint16(29498), + 51: uint16(29499), + 52: uint16(29500), + 53: uint16(29501), + 54: uint16(29504), + 55: uint16(29505), + 56: uint16(29506), + 57: uint16(29507), + 58: uint16(29508), + 59: uint16(29509), + 60: uint16(29510), + 61: uint16(29511), + 62: uint16(29512), + 63: uint16(29513), + 64: uint16(29514), + 65: uint16(29515), + 66: uint16(29516), + 67: uint16(29518), + 68: uint16(29519), + 69: uint16(29521), + 70: uint16(29523), + 71: uint16(29524), + 72: uint16(29525), + 73: uint16(29526), + 74: uint16(29528), + 75: uint16(29529), + 76: uint16(29530), + 77: uint16(29531), + 78: uint16(29532), + 79: uint16(29533), + 80: uint16(29534), + 81: uint16(29535), + 82: uint16(29537), + 83: uint16(29538), + 84: uint16(29539), + 85: uint16(29540), + 86: uint16(29541), + 87: uint16(29542), + 88: uint16(29543), + 89: uint16(29544), + 90: uint16(29545), + 91: uint16(29546), + 92: uint16(29547), + 93: uint16(29550), + 94: uint16(29552), + 95: uint16(29553), + 96: uint16(57344), + 97: uint16(57345), + 98: uint16(57346), + 99: uint16(57347), + 100: uint16(57348), + 101: uint16(57349), + 102: uint16(57350), + 103: uint16(57351), + 104: uint16(57352), + 105: uint16(57353), + 106: uint16(57354), + 107: uint16(57355), + 108: uint16(57356), + 109: uint16(57357), + 110: uint16(57358), + 111: uint16(57359), + 112: uint16(57360), + 113: uint16(57361), + 114: uint16(57362), + 115: uint16(57363), + 116: uint16(57364), + 117: uint16(57365), + 118: uint16(57366), + 119: uint16(57367), + 120: uint16(57368), + 121: uint16(57369), + 122: uint16(57370), + 123: uint16(57371), + 124: uint16(57372), + 125: uint16(57373), + 126: uint16(57374), + 127: uint16(57375), + 128: uint16(57376), + 129: uint16(57377), + 130: uint16(57378), + 131: uint16(57379), + 132: uint16(57380), + 133: uint16(57381), + 134: uint16(57382), + 135: uint16(57383), + 136: uint16(57384), + 137: uint16(57385), + 138: uint16(57386), + 139: uint16(57387), + 140: uint16(57388), + 141: uint16(57389), + 142: uint16(57390), + 143: uint16(57391), + 144: uint16(57392), + 145: uint16(57393), + 146: uint16(57394), + 147: uint16(57395), + 148: uint16(57396), + 149: uint16(57397), + 150: uint16(57398), + 151: uint16(57399), + 152: uint16(57400), + 153: uint16(57401), + 154: uint16(57402), + 155: uint16(57403), + 156: uint16(57404), + 157: uint16(57405), + 158: uint16(57406), + 159: uint16(57407), + 160: uint16(57408), + 161: uint16(57409), + 162: uint16(57410), + 163: uint16(57411), + 164: uint16(57412), + 165: uint16(57413), + 166: uint16(57414), + 167: uint16(57415), + 168: uint16(57416), + 169: uint16(57417), + 170: uint16(57418), + 171: uint16(57419), + 172: uint16(57420), + 173: uint16(57421), + 174: uint16(57422), + 175: uint16(57423), + 176: uint16(57424), + 177: uint16(57425), + 178: uint16(57426), + 179: uint16(57427), + 180: uint16(57428), + 181: uint16(57429), + 182: uint16(57430), + 183: uint16(57431), + 184: uint16(57432), + 185: uint16(57433), + 186: uint16(57434), + 187: uint16(57435), + 188: uint16(57436), + 189: uint16(57437), + }, + 42: { + 0: uint16(29554), + 1: uint16(29555), + 2: uint16(29556), + 3: uint16(29557), + 4: uint16(29558), + 5: uint16(29559), + 6: uint16(29560), + 7: uint16(29561), + 8: uint16(29562), + 9: uint16(29563), + 10: uint16(29564), + 11: uint16(29565), + 12: uint16(29567), + 13: uint16(29568), + 14: uint16(29569), + 15: uint16(29570), + 16: uint16(29571), + 17: uint16(29573), + 18: uint16(29574), + 19: uint16(29576), + 20: uint16(29578), + 21: uint16(29580), + 22: uint16(29581), + 23: uint16(29583), + 24: uint16(29584), + 25: uint16(29586), + 26: uint16(29587), + 27: uint16(29588), + 28: uint16(29589), + 29: uint16(29591), + 30: uint16(29592), + 31: uint16(29593), + 32: uint16(29594), + 33: uint16(29596), + 34: uint16(29597), + 35: uint16(29598), + 36: uint16(29600), + 37: uint16(29601), + 38: uint16(29603), + 39: uint16(29604), + 40: uint16(29605), + 41: uint16(29606), + 42: uint16(29607), + 43: uint16(29608), + 44: uint16(29610), + 45: uint16(29612), + 46: uint16(29613), + 47: uint16(29617), + 48: uint16(29620), + 49: uint16(29621), + 50: uint16(29622), + 51: uint16(29624), + 52: uint16(29625), + 53: uint16(29628), + 54: uint16(29629), + 55: uint16(29630), + 56: uint16(29631), + 57: uint16(29633), + 58: uint16(29635), + 59: uint16(29636), + 60: uint16(29637), + 61: uint16(29638), + 62: uint16(29639), + 63: uint16(29643), + 64: uint16(29644), + 65: uint16(29646), + 66: uint16(29650), + 67: uint16(29651), + 68: uint16(29652), + 69: uint16(29653), + 70: uint16(29654), + 71: uint16(29655), + 72: uint16(29656), + 73: uint16(29658), + 74: uint16(29659), + 75: uint16(29660), + 76: uint16(29661), + 77: uint16(29663), + 78: uint16(29665), + 79: uint16(29666), + 80: uint16(29667), + 81: uint16(29668), + 82: uint16(29670), + 83: uint16(29672), + 84: uint16(29674), + 85: uint16(29675), + 86: uint16(29676), + 87: uint16(29678), + 88: uint16(29679), + 89: uint16(29680), + 90: uint16(29681), + 91: uint16(29683), + 92: uint16(29684), + 93: uint16(29685), + 94: uint16(29686), + 95: uint16(29687), + 96: uint16(57438), + 97: uint16(57439), + 98: uint16(57440), + 99: uint16(57441), + 100: uint16(57442), + 101: uint16(57443), + 102: uint16(57444), + 103: uint16(57445), + 104: uint16(57446), + 105: uint16(57447), + 106: uint16(57448), + 107: uint16(57449), + 108: uint16(57450), + 109: uint16(57451), + 110: uint16(57452), + 111: uint16(57453), + 112: uint16(57454), + 113: uint16(57455), + 114: uint16(57456), + 115: uint16(57457), + 116: uint16(57458), + 117: uint16(57459), + 118: uint16(57460), + 119: uint16(57461), + 120: uint16(57462), + 121: uint16(57463), + 122: uint16(57464), + 123: uint16(57465), + 124: uint16(57466), + 125: uint16(57467), + 126: uint16(57468), + 127: uint16(57469), + 128: uint16(57470), + 129: uint16(57471), + 130: uint16(57472), + 131: uint16(57473), + 132: uint16(57474), + 133: uint16(57475), + 134: uint16(57476), + 135: uint16(57477), + 136: uint16(57478), + 137: uint16(57479), + 138: uint16(57480), + 139: uint16(57481), + 140: uint16(57482), + 141: uint16(57483), + 142: uint16(57484), + 143: uint16(57485), + 144: uint16(57486), + 145: uint16(57487), + 146: uint16(57488), + 147: uint16(57489), + 148: uint16(57490), + 149: uint16(57491), + 150: uint16(57492), + 151: uint16(57493), + 152: uint16(57494), + 153: uint16(57495), + 154: uint16(57496), + 155: uint16(57497), + 156: uint16(57498), + 157: uint16(57499), + 158: uint16(57500), + 159: uint16(57501), + 160: uint16(57502), + 161: uint16(57503), + 162: uint16(57504), + 163: uint16(57505), + 164: uint16(57506), + 165: uint16(57507), + 166: uint16(57508), + 167: uint16(57509), + 168: uint16(57510), + 169: uint16(57511), + 170: uint16(57512), + 171: uint16(57513), + 172: uint16(57514), + 173: uint16(57515), + 174: uint16(57516), + 175: uint16(57517), + 176: uint16(57518), + 177: uint16(57519), + 178: uint16(57520), + 179: uint16(57521), + 180: uint16(57522), + 181: uint16(57523), + 182: uint16(57524), + 183: uint16(57525), + 184: uint16(57526), + 185: uint16(57527), + 186: uint16(57528), + 187: uint16(57529), + 188: uint16(57530), + 189: uint16(57531), + }, + 43: { + 0: uint16(29688), + 1: uint16(29689), + 2: uint16(29690), + 3: uint16(29691), + 4: uint16(29692), + 5: uint16(29693), + 6: uint16(29694), + 7: uint16(29695), + 8: uint16(29696), + 9: uint16(29697), + 10: uint16(29698), + 11: uint16(29700), + 12: uint16(29703), + 13: uint16(29704), + 14: uint16(29707), + 15: uint16(29708), + 16: uint16(29709), + 17: uint16(29710), + 18: uint16(29713), + 19: uint16(29714), + 20: uint16(29715), + 21: uint16(29716), + 22: uint16(29717), + 23: uint16(29718), + 24: uint16(29719), + 25: uint16(29720), + 26: uint16(29721), + 27: uint16(29724), + 28: uint16(29725), + 29: uint16(29726), + 30: uint16(29727), + 31: uint16(29728), + 32: uint16(29729), + 33: uint16(29731), + 34: uint16(29732), + 35: uint16(29735), + 36: uint16(29737), + 37: uint16(29739), + 38: uint16(29741), + 39: uint16(29743), + 40: uint16(29745), + 41: uint16(29746), + 42: uint16(29751), + 43: uint16(29752), + 44: uint16(29753), + 45: uint16(29754), + 46: uint16(29755), + 47: uint16(29757), + 48: uint16(29758), + 49: uint16(29759), + 50: uint16(29760), + 51: uint16(29762), + 52: uint16(29763), + 53: uint16(29764), + 54: uint16(29765), + 55: uint16(29766), + 56: uint16(29767), + 57: uint16(29768), + 58: uint16(29769), + 59: uint16(29770), + 60: uint16(29771), + 61: uint16(29772), + 62: uint16(29773), + 63: uint16(29774), + 64: uint16(29775), + 65: uint16(29776), + 66: uint16(29777), + 67: uint16(29778), + 68: uint16(29779), + 69: uint16(29780), + 70: uint16(29782), + 71: uint16(29784), + 72: uint16(29789), + 73: uint16(29792), + 74: uint16(29793), + 75: uint16(29794), + 76: uint16(29795), + 77: uint16(29796), + 78: uint16(29797), + 79: uint16(29798), + 80: uint16(29799), + 81: uint16(29800), + 82: uint16(29801), + 83: uint16(29802), + 84: uint16(29803), + 85: uint16(29804), + 86: uint16(29806), + 87: uint16(29807), + 88: uint16(29809), + 89: uint16(29810), + 90: uint16(29811), + 91: uint16(29812), + 92: uint16(29813), + 93: uint16(29816), + 94: uint16(29817), + 95: uint16(29818), + 96: uint16(57532), + 97: uint16(57533), + 98: uint16(57534), + 99: uint16(57535), + 100: uint16(57536), + 101: uint16(57537), + 102: uint16(57538), + 103: uint16(57539), + 104: uint16(57540), + 105: uint16(57541), + 106: uint16(57542), + 107: uint16(57543), + 108: uint16(57544), + 109: uint16(57545), + 110: uint16(57546), + 111: uint16(57547), + 112: uint16(57548), + 113: uint16(57549), + 114: uint16(57550), + 115: uint16(57551), + 116: uint16(57552), + 117: uint16(57553), + 118: uint16(57554), + 119: uint16(57555), + 120: uint16(57556), + 121: uint16(57557), + 122: uint16(57558), + 123: uint16(57559), + 124: uint16(57560), + 125: uint16(57561), + 126: uint16(57562), + 127: uint16(57563), + 128: uint16(57564), + 129: uint16(57565), + 130: uint16(57566), + 131: uint16(57567), + 132: uint16(57568), + 133: uint16(57569), + 134: uint16(57570), + 135: uint16(57571), + 136: uint16(57572), + 137: uint16(57573), + 138: uint16(57574), + 139: uint16(57575), + 140: uint16(57576), + 141: uint16(57577), + 142: uint16(57578), + 143: uint16(57579), + 144: uint16(57580), + 145: uint16(57581), + 146: uint16(57582), + 147: uint16(57583), + 148: uint16(57584), + 149: uint16(57585), + 150: uint16(57586), + 151: uint16(57587), + 152: uint16(57588), + 153: uint16(57589), + 154: uint16(57590), + 155: uint16(57591), + 156: uint16(57592), + 157: uint16(57593), + 158: uint16(57594), + 159: uint16(57595), + 160: uint16(57596), + 161: uint16(57597), + 162: uint16(57598), + 163: uint16(57599), + 164: uint16(57600), + 165: uint16(57601), + 166: uint16(57602), + 167: uint16(57603), + 168: uint16(57604), + 169: uint16(57605), + 170: uint16(57606), + 171: uint16(57607), + 172: uint16(57608), + 173: uint16(57609), + 174: uint16(57610), + 175: uint16(57611), + 176: uint16(57612), + 177: uint16(57613), + 178: uint16(57614), + 179: uint16(57615), + 180: uint16(57616), + 181: uint16(57617), + 182: uint16(57618), + 183: uint16(57619), + 184: uint16(57620), + 185: uint16(57621), + 186: uint16(57622), + 187: uint16(57623), + 188: uint16(57624), + 189: uint16(57625), + }, + 44: { + 0: uint16(29819), + 1: uint16(29820), + 2: uint16(29821), + 3: uint16(29823), + 4: uint16(29826), + 5: uint16(29828), + 6: uint16(29829), + 7: uint16(29830), + 8: uint16(29832), + 9: uint16(29833), + 10: uint16(29834), + 11: uint16(29836), + 12: uint16(29837), + 13: uint16(29839), + 14: uint16(29841), + 15: uint16(29842), + 16: uint16(29843), + 17: uint16(29844), + 18: uint16(29845), + 19: uint16(29846), + 20: uint16(29847), + 21: uint16(29848), + 22: uint16(29849), + 23: uint16(29850), + 24: uint16(29851), + 25: uint16(29853), + 26: uint16(29855), + 27: uint16(29856), + 28: uint16(29857), + 29: uint16(29858), + 30: uint16(29859), + 31: uint16(29860), + 32: uint16(29861), + 33: uint16(29862), + 34: uint16(29866), + 35: uint16(29867), + 36: uint16(29868), + 37: uint16(29869), + 38: uint16(29870), + 39: uint16(29871), + 40: uint16(29872), + 41: uint16(29873), + 42: uint16(29874), + 43: uint16(29875), + 44: uint16(29876), + 45: uint16(29877), + 46: uint16(29878), + 47: uint16(29879), + 48: uint16(29880), + 49: uint16(29881), + 50: uint16(29883), + 51: uint16(29884), + 52: uint16(29885), + 53: uint16(29886), + 54: uint16(29887), + 55: uint16(29888), + 56: uint16(29889), + 57: uint16(29890), + 58: uint16(29891), + 59: uint16(29892), + 60: uint16(29893), + 61: uint16(29894), + 62: uint16(29895), + 63: uint16(29896), + 64: uint16(29897), + 65: uint16(29898), + 66: uint16(29899), + 67: uint16(29900), + 68: uint16(29901), + 69: uint16(29902), + 70: uint16(29903), + 71: uint16(29904), + 72: uint16(29905), + 73: uint16(29907), + 74: uint16(29908), + 75: uint16(29909), + 76: uint16(29910), + 77: uint16(29911), + 78: uint16(29912), + 79: uint16(29913), + 80: uint16(29914), + 81: uint16(29915), + 82: uint16(29917), + 83: uint16(29919), + 84: uint16(29921), + 85: uint16(29925), + 86: uint16(29927), + 87: uint16(29928), + 88: uint16(29929), + 89: uint16(29930), + 90: uint16(29931), + 91: uint16(29932), + 92: uint16(29933), + 93: uint16(29936), + 94: uint16(29937), + 95: uint16(29938), + 96: uint16(57626), + 97: uint16(57627), + 98: uint16(57628), + 99: uint16(57629), + 100: uint16(57630), + 101: uint16(57631), + 102: uint16(57632), + 103: uint16(57633), + 104: uint16(57634), + 105: uint16(57635), + 106: uint16(57636), + 107: uint16(57637), + 108: uint16(57638), + 109: uint16(57639), + 110: uint16(57640), + 111: uint16(57641), + 112: uint16(57642), + 113: uint16(57643), + 114: uint16(57644), + 115: uint16(57645), + 116: uint16(57646), + 117: uint16(57647), + 118: uint16(57648), + 119: uint16(57649), + 120: uint16(57650), + 121: uint16(57651), + 122: uint16(57652), + 123: uint16(57653), + 124: uint16(57654), + 125: uint16(57655), + 126: uint16(57656), + 127: uint16(57657), + 128: uint16(57658), + 129: uint16(57659), + 130: uint16(57660), + 131: uint16(57661), + 132: uint16(57662), + 133: uint16(57663), + 134: uint16(57664), + 135: uint16(57665), + 136: uint16(57666), + 137: uint16(57667), + 138: uint16(57668), + 139: uint16(57669), + 140: uint16(57670), + 141: uint16(57671), + 142: uint16(57672), + 143: uint16(57673), + 144: uint16(57674), + 145: uint16(57675), + 146: uint16(57676), + 147: uint16(57677), + 148: uint16(57678), + 149: uint16(57679), + 150: uint16(57680), + 151: uint16(57681), + 152: uint16(57682), + 153: uint16(57683), + 154: uint16(57684), + 155: uint16(57685), + 156: uint16(57686), + 157: uint16(57687), + 158: uint16(57688), + 159: uint16(57689), + 160: uint16(57690), + 161: uint16(57691), + 162: uint16(57692), + 163: uint16(57693), + 164: uint16(57694), + 165: uint16(57695), + 166: uint16(57696), + 167: uint16(57697), + 168: uint16(57698), + 169: uint16(57699), + 170: uint16(57700), + 171: uint16(57701), + 172: uint16(57702), + 173: uint16(57703), + 174: uint16(57704), + 175: uint16(57705), + 176: uint16(57706), + 177: uint16(57707), + 178: uint16(57708), + 179: uint16(57709), + 180: uint16(57710), + 181: uint16(57711), + 182: uint16(57712), + 183: uint16(57713), + 184: uint16(57714), + 185: uint16(57715), + 186: uint16(57716), + 187: uint16(57717), + 188: uint16(57718), + 189: uint16(57719), + }, + 45: { + 0: uint16(29939), + 1: uint16(29941), + 2: uint16(29944), + 3: uint16(29945), + 4: uint16(29946), + 5: uint16(29947), + 6: uint16(29948), + 7: uint16(29949), + 8: uint16(29950), + 9: uint16(29952), + 10: uint16(29953), + 11: uint16(29954), + 12: uint16(29955), + 13: uint16(29957), + 14: uint16(29958), + 15: uint16(29959), + 16: uint16(29960), + 17: uint16(29961), + 18: uint16(29962), + 19: uint16(29963), + 20: uint16(29964), + 21: uint16(29966), + 22: uint16(29968), + 23: uint16(29970), + 24: uint16(29972), + 25: uint16(29973), + 26: uint16(29974), + 27: uint16(29975), + 28: uint16(29979), + 29: uint16(29981), + 30: uint16(29982), + 31: uint16(29984), + 32: uint16(29985), + 33: uint16(29986), + 34: uint16(29987), + 35: uint16(29988), + 36: uint16(29990), + 37: uint16(29991), + 38: uint16(29994), + 39: uint16(29998), + 40: uint16(30004), + 41: uint16(30006), + 42: uint16(30009), + 43: uint16(30012), + 44: uint16(30013), + 45: uint16(30015), + 46: uint16(30017), + 47: uint16(30018), + 48: uint16(30019), + 49: uint16(30020), + 50: uint16(30022), + 51: uint16(30023), + 52: uint16(30025), + 53: uint16(30026), + 54: uint16(30029), + 55: uint16(30032), + 56: uint16(30033), + 57: uint16(30034), + 58: uint16(30035), + 59: uint16(30037), + 60: uint16(30038), + 61: uint16(30039), + 62: uint16(30040), + 63: uint16(30045), + 64: uint16(30046), + 65: uint16(30047), + 66: uint16(30048), + 67: uint16(30049), + 68: uint16(30050), + 69: uint16(30051), + 70: uint16(30052), + 71: uint16(30055), + 72: uint16(30056), + 73: uint16(30057), + 74: uint16(30059), + 75: uint16(30060), + 76: uint16(30061), + 77: uint16(30062), + 78: uint16(30063), + 79: uint16(30064), + 80: uint16(30065), + 81: uint16(30067), + 82: uint16(30069), + 83: uint16(30070), + 84: uint16(30071), + 85: uint16(30074), + 86: uint16(30075), + 87: uint16(30076), + 88: uint16(30077), + 89: uint16(30078), + 90: uint16(30080), + 91: uint16(30081), + 92: uint16(30082), + 93: uint16(30084), + 94: uint16(30085), + 95: uint16(30087), + 96: uint16(57720), + 97: uint16(57721), + 98: uint16(57722), + 99: uint16(57723), + 100: uint16(57724), + 101: uint16(57725), + 102: uint16(57726), + 103: uint16(57727), + 104: uint16(57728), + 105: uint16(57729), + 106: uint16(57730), + 107: uint16(57731), + 108: uint16(57732), + 109: uint16(57733), + 110: uint16(57734), + 111: uint16(57735), + 112: uint16(57736), + 113: uint16(57737), + 114: uint16(57738), + 115: uint16(57739), + 116: uint16(57740), + 117: uint16(57741), + 118: uint16(57742), + 119: uint16(57743), + 120: uint16(57744), + 121: uint16(57745), + 122: uint16(57746), + 123: uint16(57747), + 124: uint16(57748), + 125: uint16(57749), + 126: uint16(57750), + 127: uint16(57751), + 128: uint16(57752), + 129: uint16(57753), + 130: uint16(57754), + 131: uint16(57755), + 132: uint16(57756), + 133: uint16(57757), + 134: uint16(57758), + 135: uint16(57759), + 136: uint16(57760), + 137: uint16(57761), + 138: uint16(57762), + 139: uint16(57763), + 140: uint16(57764), + 141: uint16(57765), + 142: uint16(57766), + 143: uint16(57767), + 144: uint16(57768), + 145: uint16(57769), + 146: uint16(57770), + 147: uint16(57771), + 148: uint16(57772), + 149: uint16(57773), + 150: uint16(57774), + 151: uint16(57775), + 152: uint16(57776), + 153: uint16(57777), + 154: uint16(57778), + 155: uint16(57779), + 156: uint16(57780), + 157: uint16(57781), + 158: uint16(57782), + 159: uint16(57783), + 160: uint16(57784), + 161: uint16(57785), + 162: uint16(57786), + 163: uint16(57787), + 164: uint16(57788), + 165: uint16(57789), + 166: uint16(57790), + 167: uint16(57791), + 168: uint16(57792), + 169: uint16(57793), + 170: uint16(57794), + 171: uint16(57795), + 172: uint16(57796), + 173: uint16(57797), + 174: uint16(57798), + 175: uint16(57799), + 176: uint16(57800), + 177: uint16(57801), + 178: uint16(57802), + 179: uint16(57803), + 180: uint16(57804), + 181: uint16(57805), + 182: uint16(57806), + 183: uint16(57807), + 184: uint16(57808), + 185: uint16(57809), + 186: uint16(57810), + 187: uint16(57811), + 188: uint16(57812), + 189: uint16(57813), + }, + 46: { + 0: uint16(30088), + 1: uint16(30089), + 2: uint16(30090), + 3: uint16(30092), + 4: uint16(30093), + 5: uint16(30094), + 6: uint16(30096), + 7: uint16(30099), + 8: uint16(30101), + 9: uint16(30104), + 10: uint16(30107), + 11: uint16(30108), + 12: uint16(30110), + 13: uint16(30114), + 14: uint16(30118), + 15: uint16(30119), + 16: uint16(30120), + 17: uint16(30121), + 18: uint16(30122), + 19: uint16(30125), + 20: uint16(30134), + 21: uint16(30135), + 22: uint16(30138), + 23: uint16(30139), + 24: uint16(30143), + 25: uint16(30144), + 26: uint16(30145), + 27: uint16(30150), + 28: uint16(30155), + 29: uint16(30156), + 30: uint16(30158), + 31: uint16(30159), + 32: uint16(30160), + 33: uint16(30161), + 34: uint16(30163), + 35: uint16(30167), + 36: uint16(30169), + 37: uint16(30170), + 38: uint16(30172), + 39: uint16(30173), + 40: uint16(30175), + 41: uint16(30176), + 42: uint16(30177), + 43: uint16(30181), + 44: uint16(30185), + 45: uint16(30188), + 46: uint16(30189), + 47: uint16(30190), + 48: uint16(30191), + 49: uint16(30194), + 50: uint16(30195), + 51: uint16(30197), + 52: uint16(30198), + 53: uint16(30199), + 54: uint16(30200), + 55: uint16(30202), + 56: uint16(30203), + 57: uint16(30205), + 58: uint16(30206), + 59: uint16(30210), + 60: uint16(30212), + 61: uint16(30214), + 62: uint16(30215), + 63: uint16(30216), + 64: uint16(30217), + 65: uint16(30219), + 66: uint16(30221), + 67: uint16(30222), + 68: uint16(30223), + 69: uint16(30225), + 70: uint16(30226), + 71: uint16(30227), + 72: uint16(30228), + 73: uint16(30230), + 74: uint16(30234), + 75: uint16(30236), + 76: uint16(30237), + 77: uint16(30238), + 78: uint16(30241), + 79: uint16(30243), + 80: uint16(30247), + 81: uint16(30248), + 82: uint16(30252), + 83: uint16(30254), + 84: uint16(30255), + 85: uint16(30257), + 86: uint16(30258), + 87: uint16(30262), + 88: uint16(30263), + 89: uint16(30265), + 90: uint16(30266), + 91: uint16(30267), + 92: uint16(30269), + 93: uint16(30273), + 94: uint16(30274), + 95: uint16(30276), + 96: uint16(57814), + 97: uint16(57815), + 98: uint16(57816), + 99: uint16(57817), + 100: uint16(57818), + 101: uint16(57819), + 102: uint16(57820), + 103: uint16(57821), + 104: uint16(57822), + 105: uint16(57823), + 106: uint16(57824), + 107: uint16(57825), + 108: uint16(57826), + 109: uint16(57827), + 110: uint16(57828), + 111: uint16(57829), + 112: uint16(57830), + 113: uint16(57831), + 114: uint16(57832), + 115: uint16(57833), + 116: uint16(57834), + 117: uint16(57835), + 118: uint16(57836), + 119: uint16(57837), + 120: uint16(57838), + 121: uint16(57839), + 122: uint16(57840), + 123: uint16(57841), + 124: uint16(57842), + 125: uint16(57843), + 126: uint16(57844), + 127: uint16(57845), + 128: uint16(57846), + 129: uint16(57847), + 130: uint16(57848), + 131: uint16(57849), + 132: uint16(57850), + 133: uint16(57851), + 134: uint16(57852), + 135: uint16(57853), + 136: uint16(57854), + 137: uint16(57855), + 138: uint16(57856), + 139: uint16(57857), + 140: uint16(57858), + 141: uint16(57859), + 142: uint16(57860), + 143: uint16(57861), + 144: uint16(57862), + 145: uint16(57863), + 146: uint16(57864), + 147: uint16(57865), + 148: uint16(57866), + 149: uint16(57867), + 150: uint16(57868), + 151: uint16(57869), + 152: uint16(57870), + 153: uint16(57871), + 154: uint16(57872), + 155: uint16(57873), + 156: uint16(57874), + 157: uint16(57875), + 158: uint16(57876), + 159: uint16(57877), + 160: uint16(57878), + 161: uint16(57879), + 162: uint16(57880), + 163: uint16(57881), + 164: uint16(57882), + 165: uint16(57883), + 166: uint16(57884), + 167: uint16(57885), + 168: uint16(57886), + 169: uint16(57887), + 170: uint16(57888), + 171: uint16(57889), + 172: uint16(57890), + 173: uint16(57891), + 174: uint16(57892), + 175: uint16(57893), + 176: uint16(57894), + 177: uint16(57895), + 178: uint16(57896), + 179: uint16(57897), + 180: uint16(57898), + 181: uint16(57899), + 182: uint16(57900), + 183: uint16(57901), + 184: uint16(57902), + 185: uint16(57903), + 186: uint16(57904), + 187: uint16(57905), + 188: uint16(57906), + 189: uint16(57907), + }, + 47: { + 0: uint16(30277), + 1: uint16(30278), + 2: uint16(30279), + 3: uint16(30280), + 4: uint16(30281), + 5: uint16(30282), + 6: uint16(30283), + 7: uint16(30286), + 8: uint16(30287), + 9: uint16(30288), + 10: uint16(30289), + 11: uint16(30290), + 12: uint16(30291), + 13: uint16(30293), + 14: uint16(30295), + 15: uint16(30296), + 16: uint16(30297), + 17: uint16(30298), + 18: uint16(30299), + 19: uint16(30301), + 20: uint16(30303), + 21: uint16(30304), + 22: uint16(30305), + 23: uint16(30306), + 24: uint16(30308), + 25: uint16(30309), + 26: uint16(30310), + 27: uint16(30311), + 28: uint16(30312), + 29: uint16(30313), + 30: uint16(30314), + 31: uint16(30316), + 32: uint16(30317), + 33: uint16(30318), + 34: uint16(30320), + 35: uint16(30321), + 36: uint16(30322), + 37: uint16(30323), + 38: uint16(30324), + 39: uint16(30325), + 40: uint16(30326), + 41: uint16(30327), + 42: uint16(30329), + 43: uint16(30330), + 44: uint16(30332), + 45: uint16(30335), + 46: uint16(30336), + 47: uint16(30337), + 48: uint16(30339), + 49: uint16(30341), + 50: uint16(30345), + 51: uint16(30346), + 52: uint16(30348), + 53: uint16(30349), + 54: uint16(30351), + 55: uint16(30352), + 56: uint16(30354), + 57: uint16(30356), + 58: uint16(30357), + 59: uint16(30359), + 60: uint16(30360), + 61: uint16(30362), + 62: uint16(30363), + 63: uint16(30364), + 64: uint16(30365), + 65: uint16(30366), + 66: uint16(30367), + 67: uint16(30368), + 68: uint16(30369), + 69: uint16(30370), + 70: uint16(30371), + 71: uint16(30373), + 72: uint16(30374), + 73: uint16(30375), + 74: uint16(30376), + 75: uint16(30377), + 76: uint16(30378), + 77: uint16(30379), + 78: uint16(30380), + 79: uint16(30381), + 80: uint16(30383), + 81: uint16(30384), + 82: uint16(30387), + 83: uint16(30389), + 84: uint16(30390), + 85: uint16(30391), + 86: uint16(30392), + 87: uint16(30393), + 88: uint16(30394), + 89: uint16(30395), + 90: uint16(30396), + 91: uint16(30397), + 92: uint16(30398), + 93: uint16(30400), + 94: uint16(30401), + 95: uint16(30403), + 96: uint16(21834), + 97: uint16(38463), + 98: uint16(22467), + 99: uint16(25384), + 100: uint16(21710), + 101: uint16(21769), + 102: uint16(21696), + 103: uint16(30353), + 104: uint16(30284), + 105: uint16(34108), + 106: uint16(30702), + 107: uint16(33406), + 108: uint16(30861), + 109: uint16(29233), + 110: uint16(38552), + 111: uint16(38797), + 112: uint16(27688), + 113: uint16(23433), + 114: uint16(20474), + 115: uint16(25353), + 116: uint16(26263), + 117: uint16(23736), + 118: uint16(33018), + 119: uint16(26696), + 120: uint16(32942), + 121: uint16(26114), + 122: uint16(30414), + 123: uint16(20985), + 124: uint16(25942), + 125: uint16(29100), + 126: uint16(32753), + 127: uint16(34948), + 128: uint16(20658), + 129: uint16(22885), + 130: uint16(25034), + 131: uint16(28595), + 132: uint16(33453), + 133: uint16(25420), + 134: uint16(25170), + 135: uint16(21485), + 136: uint16(21543), + 137: uint16(31494), + 138: uint16(20843), + 139: uint16(30116), + 140: uint16(24052), + 141: uint16(25300), + 142: uint16(36299), + 143: uint16(38774), + 144: uint16(25226), + 145: uint16(32793), + 146: uint16(22365), + 147: uint16(38712), + 148: uint16(32610), + 149: uint16(29240), + 150: uint16(30333), + 151: uint16(26575), + 152: uint16(30334), + 153: uint16(25670), + 154: uint16(20336), + 155: uint16(36133), + 156: uint16(25308), + 157: uint16(31255), + 158: uint16(26001), + 159: uint16(29677), + 160: uint16(25644), + 161: uint16(25203), + 162: uint16(33324), + 163: uint16(39041), + 164: uint16(26495), + 165: uint16(29256), + 166: uint16(25198), + 167: uint16(25292), + 168: uint16(20276), + 169: uint16(29923), + 170: uint16(21322), + 171: uint16(21150), + 172: uint16(32458), + 173: uint16(37030), + 174: uint16(24110), + 175: uint16(26758), + 176: uint16(27036), + 177: uint16(33152), + 178: uint16(32465), + 179: uint16(26834), + 180: uint16(30917), + 181: uint16(34444), + 182: uint16(38225), + 183: uint16(20621), + 184: uint16(35876), + 185: uint16(33502), + 186: uint16(32990), + 187: uint16(21253), + 188: uint16(35090), + 189: uint16(21093), + }, + 48: { + 0: uint16(30404), + 1: uint16(30407), + 2: uint16(30409), + 3: uint16(30411), + 4: uint16(30412), + 5: uint16(30419), + 6: uint16(30421), + 7: uint16(30425), + 8: uint16(30426), + 9: uint16(30428), + 10: uint16(30429), + 11: uint16(30430), + 12: uint16(30432), + 13: uint16(30433), + 14: uint16(30434), + 15: uint16(30435), + 16: uint16(30436), + 17: uint16(30438), + 18: uint16(30439), + 19: uint16(30440), + 20: uint16(30441), + 21: uint16(30442), + 22: uint16(30443), + 23: uint16(30444), + 24: uint16(30445), + 25: uint16(30448), + 26: uint16(30451), + 27: uint16(30453), + 28: uint16(30454), + 29: uint16(30455), + 30: uint16(30458), + 31: uint16(30459), + 32: uint16(30461), + 33: uint16(30463), + 34: uint16(30464), + 35: uint16(30466), + 36: uint16(30467), + 37: uint16(30469), + 38: uint16(30470), + 39: uint16(30474), + 40: uint16(30476), + 41: uint16(30478), + 42: uint16(30479), + 43: uint16(30480), + 44: uint16(30481), + 45: uint16(30482), + 46: uint16(30483), + 47: uint16(30484), + 48: uint16(30485), + 49: uint16(30486), + 50: uint16(30487), + 51: uint16(30488), + 52: uint16(30491), + 53: uint16(30492), + 54: uint16(30493), + 55: uint16(30494), + 56: uint16(30497), + 57: uint16(30499), + 58: uint16(30500), + 59: uint16(30501), + 60: uint16(30503), + 61: uint16(30506), + 62: uint16(30507), + 63: uint16(30508), + 64: uint16(30510), + 65: uint16(30512), + 66: uint16(30513), + 67: uint16(30514), + 68: uint16(30515), + 69: uint16(30516), + 70: uint16(30521), + 71: uint16(30523), + 72: uint16(30525), + 73: uint16(30526), + 74: uint16(30527), + 75: uint16(30530), + 76: uint16(30532), + 77: uint16(30533), + 78: uint16(30534), + 79: uint16(30536), + 80: uint16(30537), + 81: uint16(30538), + 82: uint16(30539), + 83: uint16(30540), + 84: uint16(30541), + 85: uint16(30542), + 86: uint16(30543), + 87: uint16(30546), + 88: uint16(30547), + 89: uint16(30548), + 90: uint16(30549), + 91: uint16(30550), + 92: uint16(30551), + 93: uint16(30552), + 94: uint16(30553), + 95: uint16(30556), + 96: uint16(34180), + 97: uint16(38649), + 98: uint16(20445), + 99: uint16(22561), + 100: uint16(39281), + 101: uint16(23453), + 102: uint16(25265), + 103: uint16(25253), + 104: uint16(26292), + 105: uint16(35961), + 106: uint16(40077), + 107: uint16(29190), + 108: uint16(26479), + 109: uint16(30865), + 110: uint16(24754), + 111: uint16(21329), + 112: uint16(21271), + 113: uint16(36744), + 114: uint16(32972), + 115: uint16(36125), + 116: uint16(38049), + 117: uint16(20493), + 118: uint16(29384), + 119: uint16(22791), + 120: uint16(24811), + 121: uint16(28953), + 122: uint16(34987), + 123: uint16(22868), + 124: uint16(33519), + 125: uint16(26412), + 126: uint16(31528), + 127: uint16(23849), + 128: uint16(32503), + 129: uint16(29997), + 130: uint16(27893), + 131: uint16(36454), + 132: uint16(36856), + 133: uint16(36924), + 134: uint16(40763), + 135: uint16(27604), + 136: uint16(37145), + 137: uint16(31508), + 138: uint16(24444), + 139: uint16(30887), + 140: uint16(34006), + 141: uint16(34109), + 142: uint16(27605), + 143: uint16(27609), + 144: uint16(27606), + 145: uint16(24065), + 146: uint16(24199), + 147: uint16(30201), + 148: uint16(38381), + 149: uint16(25949), + 150: uint16(24330), + 151: uint16(24517), + 152: uint16(36767), + 153: uint16(22721), + 154: uint16(33218), + 155: uint16(36991), + 156: uint16(38491), + 157: uint16(38829), + 158: uint16(36793), + 159: uint16(32534), + 160: uint16(36140), + 161: uint16(25153), + 162: uint16(20415), + 163: uint16(21464), + 164: uint16(21342), + 165: uint16(36776), + 166: uint16(36777), + 167: uint16(36779), + 168: uint16(36941), + 169: uint16(26631), + 170: uint16(24426), + 171: uint16(33176), + 172: uint16(34920), + 173: uint16(40150), + 174: uint16(24971), + 175: uint16(21035), + 176: uint16(30250), + 177: uint16(24428), + 178: uint16(25996), + 179: uint16(28626), + 180: uint16(28392), + 181: uint16(23486), + 182: uint16(25672), + 183: uint16(20853), + 184: uint16(20912), + 185: uint16(26564), + 186: uint16(19993), + 187: uint16(31177), + 188: uint16(39292), + 189: uint16(28851), + }, + 49: { + 0: uint16(30557), + 1: uint16(30558), + 2: uint16(30559), + 3: uint16(30560), + 4: uint16(30564), + 5: uint16(30567), + 6: uint16(30569), + 7: uint16(30570), + 8: uint16(30573), + 9: uint16(30574), + 10: uint16(30575), + 11: uint16(30576), + 12: uint16(30577), + 13: uint16(30578), + 14: uint16(30579), + 15: uint16(30580), + 16: uint16(30581), + 17: uint16(30582), + 18: uint16(30583), + 19: uint16(30584), + 20: uint16(30586), + 21: uint16(30587), + 22: uint16(30588), + 23: uint16(30593), + 24: uint16(30594), + 25: uint16(30595), + 26: uint16(30598), + 27: uint16(30599), + 28: uint16(30600), + 29: uint16(30601), + 30: uint16(30602), + 31: uint16(30603), + 32: uint16(30607), + 33: uint16(30608), + 34: uint16(30611), + 35: uint16(30612), + 36: uint16(30613), + 37: uint16(30614), + 38: uint16(30615), + 39: uint16(30616), + 40: uint16(30617), + 41: uint16(30618), + 42: uint16(30619), + 43: uint16(30620), + 44: uint16(30621), + 45: uint16(30622), + 46: uint16(30625), + 47: uint16(30627), + 48: uint16(30628), + 49: uint16(30630), + 50: uint16(30632), + 51: uint16(30635), + 52: uint16(30637), + 53: uint16(30638), + 54: uint16(30639), + 55: uint16(30641), + 56: uint16(30642), + 57: uint16(30644), + 58: uint16(30646), + 59: uint16(30647), + 60: uint16(30648), + 61: uint16(30649), + 62: uint16(30650), + 63: uint16(30652), + 64: uint16(30654), + 65: uint16(30656), + 66: uint16(30657), + 67: uint16(30658), + 68: uint16(30659), + 69: uint16(30660), + 70: uint16(30661), + 71: uint16(30662), + 72: uint16(30663), + 73: uint16(30664), + 74: uint16(30665), + 75: uint16(30666), + 76: uint16(30667), + 77: uint16(30668), + 78: uint16(30670), + 79: uint16(30671), + 80: uint16(30672), + 81: uint16(30673), + 82: uint16(30674), + 83: uint16(30675), + 84: uint16(30676), + 85: uint16(30677), + 86: uint16(30678), + 87: uint16(30680), + 88: uint16(30681), + 89: uint16(30682), + 90: uint16(30685), + 91: uint16(30686), + 92: uint16(30687), + 93: uint16(30688), + 94: uint16(30689), + 95: uint16(30692), + 96: uint16(30149), + 97: uint16(24182), + 98: uint16(29627), + 99: uint16(33760), + 100: uint16(25773), + 101: uint16(25320), + 102: uint16(38069), + 103: uint16(27874), + 104: uint16(21338), + 105: uint16(21187), + 106: uint16(25615), + 107: uint16(38082), + 108: uint16(31636), + 109: uint16(20271), + 110: uint16(24091), + 111: uint16(33334), + 112: uint16(33046), + 113: uint16(33162), + 114: uint16(28196), + 115: uint16(27850), + 116: uint16(39539), + 117: uint16(25429), + 118: uint16(21340), + 119: uint16(21754), + 120: uint16(34917), + 121: uint16(22496), + 122: uint16(19981), + 123: uint16(24067), + 124: uint16(27493), + 125: uint16(31807), + 126: uint16(37096), + 127: uint16(24598), + 128: uint16(25830), + 129: uint16(29468), + 130: uint16(35009), + 131: uint16(26448), + 132: uint16(25165), + 133: uint16(36130), + 134: uint16(30572), + 135: uint16(36393), + 136: uint16(37319), + 137: uint16(24425), + 138: uint16(33756), + 139: uint16(34081), + 140: uint16(39184), + 141: uint16(21442), + 142: uint16(34453), + 143: uint16(27531), + 144: uint16(24813), + 145: uint16(24808), + 146: uint16(28799), + 147: uint16(33485), + 148: uint16(33329), + 149: uint16(20179), + 150: uint16(27815), + 151: uint16(34255), + 152: uint16(25805), + 153: uint16(31961), + 154: uint16(27133), + 155: uint16(26361), + 156: uint16(33609), + 157: uint16(21397), + 158: uint16(31574), + 159: uint16(20391), + 160: uint16(20876), + 161: uint16(27979), + 162: uint16(23618), + 163: uint16(36461), + 164: uint16(25554), + 165: uint16(21449), + 166: uint16(33580), + 167: uint16(33590), + 168: uint16(26597), + 169: uint16(30900), + 170: uint16(25661), + 171: uint16(23519), + 172: uint16(23700), + 173: uint16(24046), + 174: uint16(35815), + 175: uint16(25286), + 176: uint16(26612), + 177: uint16(35962), + 178: uint16(25600), + 179: uint16(25530), + 180: uint16(34633), + 181: uint16(39307), + 182: uint16(35863), + 183: uint16(32544), + 184: uint16(38130), + 185: uint16(20135), + 186: uint16(38416), + 187: uint16(39076), + 188: uint16(26124), + 189: uint16(29462), + }, + 50: { + 0: uint16(30694), + 1: uint16(30696), + 2: uint16(30698), + 3: uint16(30703), + 4: uint16(30704), + 5: uint16(30705), + 6: uint16(30706), + 7: uint16(30708), + 8: uint16(30709), + 9: uint16(30711), + 10: uint16(30713), + 11: uint16(30714), + 12: uint16(30715), + 13: uint16(30716), + 14: uint16(30723), + 15: uint16(30724), + 16: uint16(30725), + 17: uint16(30726), + 18: uint16(30727), + 19: uint16(30728), + 20: uint16(30730), + 21: uint16(30731), + 22: uint16(30734), + 23: uint16(30735), + 24: uint16(30736), + 25: uint16(30739), + 26: uint16(30741), + 27: uint16(30745), + 28: uint16(30747), + 29: uint16(30750), + 30: uint16(30752), + 31: uint16(30753), + 32: uint16(30754), + 33: uint16(30756), + 34: uint16(30760), + 35: uint16(30762), + 36: uint16(30763), + 37: uint16(30766), + 38: uint16(30767), + 39: uint16(30769), + 40: uint16(30770), + 41: uint16(30771), + 42: uint16(30773), + 43: uint16(30774), + 44: uint16(30781), + 45: uint16(30783), + 46: uint16(30785), + 47: uint16(30786), + 48: uint16(30787), + 49: uint16(30788), + 50: uint16(30790), + 51: uint16(30792), + 52: uint16(30793), + 53: uint16(30794), + 54: uint16(30795), + 55: uint16(30797), + 56: uint16(30799), + 57: uint16(30801), + 58: uint16(30803), + 59: uint16(30804), + 60: uint16(30808), + 61: uint16(30809), + 62: uint16(30810), + 63: uint16(30811), + 64: uint16(30812), + 65: uint16(30814), + 66: uint16(30815), + 67: uint16(30816), + 68: uint16(30817), + 69: uint16(30818), + 70: uint16(30819), + 71: uint16(30820), + 72: uint16(30821), + 73: uint16(30822), + 74: uint16(30823), + 75: uint16(30824), + 76: uint16(30825), + 77: uint16(30831), + 78: uint16(30832), + 79: uint16(30833), + 80: uint16(30834), + 81: uint16(30835), + 82: uint16(30836), + 83: uint16(30837), + 84: uint16(30838), + 85: uint16(30840), + 86: uint16(30841), + 87: uint16(30842), + 88: uint16(30843), + 89: uint16(30845), + 90: uint16(30846), + 91: uint16(30847), + 92: uint16(30848), + 93: uint16(30849), + 94: uint16(30850), + 95: uint16(30851), + 96: uint16(22330), + 97: uint16(23581), + 98: uint16(24120), + 99: uint16(38271), + 100: uint16(20607), + 101: uint16(32928), + 102: uint16(21378), + 103: uint16(25950), + 104: uint16(30021), + 105: uint16(21809), + 106: uint16(20513), + 107: uint16(36229), + 108: uint16(25220), + 109: uint16(38046), + 110: uint16(26397), + 111: uint16(22066), + 112: uint16(28526), + 113: uint16(24034), + 114: uint16(21557), + 115: uint16(28818), + 116: uint16(36710), + 117: uint16(25199), + 118: uint16(25764), + 119: uint16(25507), + 120: uint16(24443), + 121: uint16(28552), + 122: uint16(37108), + 123: uint16(33251), + 124: uint16(36784), + 125: uint16(23576), + 126: uint16(26216), + 127: uint16(24561), + 128: uint16(27785), + 129: uint16(38472), + 130: uint16(36225), + 131: uint16(34924), + 132: uint16(25745), + 133: uint16(31216), + 134: uint16(22478), + 135: uint16(27225), + 136: uint16(25104), + 137: uint16(21576), + 138: uint16(20056), + 139: uint16(31243), + 140: uint16(24809), + 141: uint16(28548), + 142: uint16(35802), + 143: uint16(25215), + 144: uint16(36894), + 145: uint16(39563), + 146: uint16(31204), + 147: uint16(21507), + 148: uint16(30196), + 149: uint16(25345), + 150: uint16(21273), + 151: uint16(27744), + 152: uint16(36831), + 153: uint16(24347), + 154: uint16(39536), + 155: uint16(32827), + 156: uint16(40831), + 157: uint16(20360), + 158: uint16(23610), + 159: uint16(36196), + 160: uint16(32709), + 161: uint16(26021), + 162: uint16(28861), + 163: uint16(20805), + 164: uint16(20914), + 165: uint16(34411), + 166: uint16(23815), + 167: uint16(23456), + 168: uint16(25277), + 169: uint16(37228), + 170: uint16(30068), + 171: uint16(36364), + 172: uint16(31264), + 173: uint16(24833), + 174: uint16(31609), + 175: uint16(20167), + 176: uint16(32504), + 177: uint16(30597), + 178: uint16(19985), + 179: uint16(33261), + 180: uint16(21021), + 181: uint16(20986), + 182: uint16(27249), + 183: uint16(21416), + 184: uint16(36487), + 185: uint16(38148), + 186: uint16(38607), + 187: uint16(28353), + 188: uint16(38500), + 189: uint16(26970), + }, + 51: { + 0: uint16(30852), + 1: uint16(30853), + 2: uint16(30854), + 3: uint16(30856), + 4: uint16(30858), + 5: uint16(30859), + 6: uint16(30863), + 7: uint16(30864), + 8: uint16(30866), + 9: uint16(30868), + 10: uint16(30869), + 11: uint16(30870), + 12: uint16(30873), + 13: uint16(30877), + 14: uint16(30878), + 15: uint16(30880), + 16: uint16(30882), + 17: uint16(30884), + 18: uint16(30886), + 19: uint16(30888), + 20: uint16(30889), + 21: uint16(30890), + 22: uint16(30891), + 23: uint16(30892), + 24: uint16(30893), + 25: uint16(30894), + 26: uint16(30895), + 27: uint16(30901), + 28: uint16(30902), + 29: uint16(30903), + 30: uint16(30904), + 31: uint16(30906), + 32: uint16(30907), + 33: uint16(30908), + 34: uint16(30909), + 35: uint16(30911), + 36: uint16(30912), + 37: uint16(30914), + 38: uint16(30915), + 39: uint16(30916), + 40: uint16(30918), + 41: uint16(30919), + 42: uint16(30920), + 43: uint16(30924), + 44: uint16(30925), + 45: uint16(30926), + 46: uint16(30927), + 47: uint16(30929), + 48: uint16(30930), + 49: uint16(30931), + 50: uint16(30934), + 51: uint16(30935), + 52: uint16(30936), + 53: uint16(30938), + 54: uint16(30939), + 55: uint16(30940), + 56: uint16(30941), + 57: uint16(30942), + 58: uint16(30943), + 59: uint16(30944), + 60: uint16(30945), + 61: uint16(30946), + 62: uint16(30947), + 63: uint16(30948), + 64: uint16(30949), + 65: uint16(30950), + 66: uint16(30951), + 67: uint16(30953), + 68: uint16(30954), + 69: uint16(30955), + 70: uint16(30957), + 71: uint16(30958), + 72: uint16(30959), + 73: uint16(30960), + 74: uint16(30961), + 75: uint16(30963), + 76: uint16(30965), + 77: uint16(30966), + 78: uint16(30968), + 79: uint16(30969), + 80: uint16(30971), + 81: uint16(30972), + 82: uint16(30973), + 83: uint16(30974), + 84: uint16(30975), + 85: uint16(30976), + 86: uint16(30978), + 87: uint16(30979), + 88: uint16(30980), + 89: uint16(30982), + 90: uint16(30983), + 91: uint16(30984), + 92: uint16(30985), + 93: uint16(30986), + 94: uint16(30987), + 95: uint16(30988), + 96: uint16(30784), + 97: uint16(20648), + 98: uint16(30679), + 99: uint16(25616), + 100: uint16(35302), + 101: uint16(22788), + 102: uint16(25571), + 103: uint16(24029), + 104: uint16(31359), + 105: uint16(26941), + 106: uint16(20256), + 107: uint16(33337), + 108: uint16(21912), + 109: uint16(20018), + 110: uint16(30126), + 111: uint16(31383), + 112: uint16(24162), + 113: uint16(24202), + 114: uint16(38383), + 115: uint16(21019), + 116: uint16(21561), + 117: uint16(28810), + 118: uint16(25462), + 119: uint16(38180), + 120: uint16(22402), + 121: uint16(26149), + 122: uint16(26943), + 123: uint16(37255), + 124: uint16(21767), + 125: uint16(28147), + 126: uint16(32431), + 127: uint16(34850), + 128: uint16(25139), + 129: uint16(32496), + 130: uint16(30133), + 131: uint16(33576), + 132: uint16(30913), + 133: uint16(38604), + 134: uint16(36766), + 135: uint16(24904), + 136: uint16(29943), + 137: uint16(35789), + 138: uint16(27492), + 139: uint16(21050), + 140: uint16(36176), + 141: uint16(27425), + 142: uint16(32874), + 143: uint16(33905), + 144: uint16(22257), + 145: uint16(21254), + 146: uint16(20174), + 147: uint16(19995), + 148: uint16(20945), + 149: uint16(31895), + 150: uint16(37259), + 151: uint16(31751), + 152: uint16(20419), + 153: uint16(36479), + 154: uint16(31713), + 155: uint16(31388), + 156: uint16(25703), + 157: uint16(23828), + 158: uint16(20652), + 159: uint16(33030), + 160: uint16(30209), + 161: uint16(31929), + 162: uint16(28140), + 163: uint16(32736), + 164: uint16(26449), + 165: uint16(23384), + 166: uint16(23544), + 167: uint16(30923), + 168: uint16(25774), + 169: uint16(25619), + 170: uint16(25514), + 171: uint16(25387), + 172: uint16(38169), + 173: uint16(25645), + 174: uint16(36798), + 175: uint16(31572), + 176: uint16(30249), + 177: uint16(25171), + 178: uint16(22823), + 179: uint16(21574), + 180: uint16(27513), + 181: uint16(20643), + 182: uint16(25140), + 183: uint16(24102), + 184: uint16(27526), + 185: uint16(20195), + 186: uint16(36151), + 187: uint16(34955), + 188: uint16(24453), + 189: uint16(36910), + }, + 52: { + 0: uint16(30989), + 1: uint16(30990), + 2: uint16(30991), + 3: uint16(30992), + 4: uint16(30993), + 5: uint16(30994), + 6: uint16(30996), + 7: uint16(30997), + 8: uint16(30998), + 9: uint16(30999), + 10: uint16(31000), + 11: uint16(31001), + 12: uint16(31002), + 13: uint16(31003), + 14: uint16(31004), + 15: uint16(31005), + 16: uint16(31007), + 17: uint16(31008), + 18: uint16(31009), + 19: uint16(31010), + 20: uint16(31011), + 21: uint16(31013), + 22: uint16(31014), + 23: uint16(31015), + 24: uint16(31016), + 25: uint16(31017), + 26: uint16(31018), + 27: uint16(31019), + 28: uint16(31020), + 29: uint16(31021), + 30: uint16(31022), + 31: uint16(31023), + 32: uint16(31024), + 33: uint16(31025), + 34: uint16(31026), + 35: uint16(31027), + 36: uint16(31029), + 37: uint16(31030), + 38: uint16(31031), + 39: uint16(31032), + 40: uint16(31033), + 41: uint16(31037), + 42: uint16(31039), + 43: uint16(31042), + 44: uint16(31043), + 45: uint16(31044), + 46: uint16(31045), + 47: uint16(31047), + 48: uint16(31050), + 49: uint16(31051), + 50: uint16(31052), + 51: uint16(31053), + 52: uint16(31054), + 53: uint16(31055), + 54: uint16(31056), + 55: uint16(31057), + 56: uint16(31058), + 57: uint16(31060), + 58: uint16(31061), + 59: uint16(31064), + 60: uint16(31065), + 61: uint16(31073), + 62: uint16(31075), + 63: uint16(31076), + 64: uint16(31078), + 65: uint16(31081), + 66: uint16(31082), + 67: uint16(31083), + 68: uint16(31084), + 69: uint16(31086), + 70: uint16(31088), + 71: uint16(31089), + 72: uint16(31090), + 73: uint16(31091), + 74: uint16(31092), + 75: uint16(31093), + 76: uint16(31094), + 77: uint16(31097), + 78: uint16(31099), + 79: uint16(31100), + 80: uint16(31101), + 81: uint16(31102), + 82: uint16(31103), + 83: uint16(31106), + 84: uint16(31107), + 85: uint16(31110), + 86: uint16(31111), + 87: uint16(31112), + 88: uint16(31113), + 89: uint16(31115), + 90: uint16(31116), + 91: uint16(31117), + 92: uint16(31118), + 93: uint16(31120), + 94: uint16(31121), + 95: uint16(31122), + 96: uint16(24608), + 97: uint16(32829), + 98: uint16(25285), + 99: uint16(20025), + 100: uint16(21333), + 101: uint16(37112), + 102: uint16(25528), + 103: uint16(32966), + 104: uint16(26086), + 105: uint16(27694), + 106: uint16(20294), + 107: uint16(24814), + 108: uint16(28129), + 109: uint16(35806), + 110: uint16(24377), + 111: uint16(34507), + 112: uint16(24403), + 113: uint16(25377), + 114: uint16(20826), + 115: uint16(33633), + 116: uint16(26723), + 117: uint16(20992), + 118: uint16(25443), + 119: uint16(36424), + 120: uint16(20498), + 121: uint16(23707), + 122: uint16(31095), + 123: uint16(23548), + 124: uint16(21040), + 125: uint16(31291), + 126: uint16(24764), + 127: uint16(36947), + 128: uint16(30423), + 129: uint16(24503), + 130: uint16(24471), + 131: uint16(30340), + 132: uint16(36460), + 133: uint16(28783), + 134: uint16(30331), + 135: uint16(31561), + 136: uint16(30634), + 137: uint16(20979), + 138: uint16(37011), + 139: uint16(22564), + 140: uint16(20302), + 141: uint16(28404), + 142: uint16(36842), + 143: uint16(25932), + 144: uint16(31515), + 145: uint16(29380), + 146: uint16(28068), + 147: uint16(32735), + 148: uint16(23265), + 149: uint16(25269), + 150: uint16(24213), + 151: uint16(22320), + 152: uint16(33922), + 153: uint16(31532), + 154: uint16(24093), + 155: uint16(24351), + 156: uint16(36882), + 157: uint16(32532), + 158: uint16(39072), + 159: uint16(25474), + 160: uint16(28359), + 161: uint16(30872), + 162: uint16(28857), + 163: uint16(20856), + 164: uint16(38747), + 165: uint16(22443), + 166: uint16(30005), + 167: uint16(20291), + 168: uint16(30008), + 169: uint16(24215), + 170: uint16(24806), + 171: uint16(22880), + 172: uint16(28096), + 173: uint16(27583), + 174: uint16(30857), + 175: uint16(21500), + 176: uint16(38613), + 177: uint16(20939), + 178: uint16(20993), + 179: uint16(25481), + 180: uint16(21514), + 181: uint16(38035), + 182: uint16(35843), + 183: uint16(36300), + 184: uint16(29241), + 185: uint16(30879), + 186: uint16(34678), + 187: uint16(36845), + 188: uint16(35853), + 189: uint16(21472), + }, + 53: { + 0: uint16(31123), + 1: uint16(31124), + 2: uint16(31125), + 3: uint16(31126), + 4: uint16(31127), + 5: uint16(31128), + 6: uint16(31129), + 7: uint16(31131), + 8: uint16(31132), + 9: uint16(31133), + 10: uint16(31134), + 11: uint16(31135), + 12: uint16(31136), + 13: uint16(31137), + 14: uint16(31138), + 15: uint16(31139), + 16: uint16(31140), + 17: uint16(31141), + 18: uint16(31142), + 19: uint16(31144), + 20: uint16(31145), + 21: uint16(31146), + 22: uint16(31147), + 23: uint16(31148), + 24: uint16(31149), + 25: uint16(31150), + 26: uint16(31151), + 27: uint16(31152), + 28: uint16(31153), + 29: uint16(31154), + 30: uint16(31156), + 31: uint16(31157), + 32: uint16(31158), + 33: uint16(31159), + 34: uint16(31160), + 35: uint16(31164), + 36: uint16(31167), + 37: uint16(31170), + 38: uint16(31172), + 39: uint16(31173), + 40: uint16(31175), + 41: uint16(31176), + 42: uint16(31178), + 43: uint16(31180), + 44: uint16(31182), + 45: uint16(31183), + 46: uint16(31184), + 47: uint16(31187), + 48: uint16(31188), + 49: uint16(31190), + 50: uint16(31191), + 51: uint16(31193), + 52: uint16(31194), + 53: uint16(31195), + 54: uint16(31196), + 55: uint16(31197), + 56: uint16(31198), + 57: uint16(31200), + 58: uint16(31201), + 59: uint16(31202), + 60: uint16(31205), + 61: uint16(31208), + 62: uint16(31210), + 63: uint16(31212), + 64: uint16(31214), + 65: uint16(31217), + 66: uint16(31218), + 67: uint16(31219), + 68: uint16(31220), + 69: uint16(31221), + 70: uint16(31222), + 71: uint16(31223), + 72: uint16(31225), + 73: uint16(31226), + 74: uint16(31228), + 75: uint16(31230), + 76: uint16(31231), + 77: uint16(31233), + 78: uint16(31236), + 79: uint16(31237), + 80: uint16(31239), + 81: uint16(31240), + 82: uint16(31241), + 83: uint16(31242), + 84: uint16(31244), + 85: uint16(31247), + 86: uint16(31248), + 87: uint16(31249), + 88: uint16(31250), + 89: uint16(31251), + 90: uint16(31253), + 91: uint16(31254), + 92: uint16(31256), + 93: uint16(31257), + 94: uint16(31259), + 95: uint16(31260), + 96: uint16(19969), + 97: uint16(30447), + 98: uint16(21486), + 99: uint16(38025), + 100: uint16(39030), + 101: uint16(40718), + 102: uint16(38189), + 103: uint16(23450), + 104: uint16(35746), + 105: uint16(20002), + 106: uint16(19996), + 107: uint16(20908), + 108: uint16(33891), + 109: uint16(25026), + 110: uint16(21160), + 111: uint16(26635), + 112: uint16(20375), + 113: uint16(24683), + 114: uint16(20923), + 115: uint16(27934), + 116: uint16(20828), + 117: uint16(25238), + 118: uint16(26007), + 119: uint16(38497), + 120: uint16(35910), + 121: uint16(36887), + 122: uint16(30168), + 123: uint16(37117), + 124: uint16(30563), + 125: uint16(27602), + 126: uint16(29322), + 127: uint16(29420), + 128: uint16(35835), + 129: uint16(22581), + 130: uint16(30585), + 131: uint16(36172), + 132: uint16(26460), + 133: uint16(38208), + 134: uint16(32922), + 135: uint16(24230), + 136: uint16(28193), + 137: uint16(22930), + 138: uint16(31471), + 139: uint16(30701), + 140: uint16(38203), + 141: uint16(27573), + 142: uint16(26029), + 143: uint16(32526), + 144: uint16(22534), + 145: uint16(20817), + 146: uint16(38431), + 147: uint16(23545), + 148: uint16(22697), + 149: uint16(21544), + 150: uint16(36466), + 151: uint16(25958), + 152: uint16(39039), + 153: uint16(22244), + 154: uint16(38045), + 155: uint16(30462), + 156: uint16(36929), + 157: uint16(25479), + 158: uint16(21702), + 159: uint16(22810), + 160: uint16(22842), + 161: uint16(22427), + 162: uint16(36530), + 163: uint16(26421), + 164: uint16(36346), + 165: uint16(33333), + 166: uint16(21057), + 167: uint16(24816), + 168: uint16(22549), + 169: uint16(34558), + 170: uint16(23784), + 171: uint16(40517), + 172: uint16(20420), + 173: uint16(39069), + 174: uint16(35769), + 175: uint16(23077), + 176: uint16(24694), + 177: uint16(21380), + 178: uint16(25212), + 179: uint16(36943), + 180: uint16(37122), + 181: uint16(39295), + 182: uint16(24681), + 183: uint16(32780), + 184: uint16(20799), + 185: uint16(32819), + 186: uint16(23572), + 187: uint16(39285), + 188: uint16(27953), + 189: uint16(20108), + }, + 54: { + 0: uint16(31261), + 1: uint16(31263), + 2: uint16(31265), + 3: uint16(31266), + 4: uint16(31268), + 5: uint16(31269), + 6: uint16(31270), + 7: uint16(31271), + 8: uint16(31272), + 9: uint16(31273), + 10: uint16(31274), + 11: uint16(31275), + 12: uint16(31276), + 13: uint16(31277), + 14: uint16(31278), + 15: uint16(31279), + 16: uint16(31280), + 17: uint16(31281), + 18: uint16(31282), + 19: uint16(31284), + 20: uint16(31285), + 21: uint16(31286), + 22: uint16(31288), + 23: uint16(31290), + 24: uint16(31294), + 25: uint16(31296), + 26: uint16(31297), + 27: uint16(31298), + 28: uint16(31299), + 29: uint16(31300), + 30: uint16(31301), + 31: uint16(31303), + 32: uint16(31304), + 33: uint16(31305), + 34: uint16(31306), + 35: uint16(31307), + 36: uint16(31308), + 37: uint16(31309), + 38: uint16(31310), + 39: uint16(31311), + 40: uint16(31312), + 41: uint16(31314), + 42: uint16(31315), + 43: uint16(31316), + 44: uint16(31317), + 45: uint16(31318), + 46: uint16(31320), + 47: uint16(31321), + 48: uint16(31322), + 49: uint16(31323), + 50: uint16(31324), + 51: uint16(31325), + 52: uint16(31326), + 53: uint16(31327), + 54: uint16(31328), + 55: uint16(31329), + 56: uint16(31330), + 57: uint16(31331), + 58: uint16(31332), + 59: uint16(31333), + 60: uint16(31334), + 61: uint16(31335), + 62: uint16(31336), + 63: uint16(31337), + 64: uint16(31338), + 65: uint16(31339), + 66: uint16(31340), + 67: uint16(31341), + 68: uint16(31342), + 69: uint16(31343), + 70: uint16(31345), + 71: uint16(31346), + 72: uint16(31347), + 73: uint16(31349), + 74: uint16(31355), + 75: uint16(31356), + 76: uint16(31357), + 77: uint16(31358), + 78: uint16(31362), + 79: uint16(31365), + 80: uint16(31367), + 81: uint16(31369), + 82: uint16(31370), + 83: uint16(31371), + 84: uint16(31372), + 85: uint16(31374), + 86: uint16(31375), + 87: uint16(31376), + 88: uint16(31379), + 89: uint16(31380), + 90: uint16(31385), + 91: uint16(31386), + 92: uint16(31387), + 93: uint16(31390), + 94: uint16(31393), + 95: uint16(31394), + 96: uint16(36144), + 97: uint16(21457), + 98: uint16(32602), + 99: uint16(31567), + 100: uint16(20240), + 101: uint16(20047), + 102: uint16(38400), + 103: uint16(27861), + 104: uint16(29648), + 105: uint16(34281), + 106: uint16(24070), + 107: uint16(30058), + 108: uint16(32763), + 109: uint16(27146), + 110: uint16(30718), + 111: uint16(38034), + 112: uint16(32321), + 113: uint16(20961), + 114: uint16(28902), + 115: uint16(21453), + 116: uint16(36820), + 117: uint16(33539), + 118: uint16(36137), + 119: uint16(29359), + 120: uint16(39277), + 121: uint16(27867), + 122: uint16(22346), + 123: uint16(33459), + 124: uint16(26041), + 125: uint16(32938), + 126: uint16(25151), + 127: uint16(38450), + 128: uint16(22952), + 129: uint16(20223), + 130: uint16(35775), + 131: uint16(32442), + 132: uint16(25918), + 133: uint16(33778), + 134: uint16(38750), + 135: uint16(21857), + 136: uint16(39134), + 137: uint16(32933), + 138: uint16(21290), + 139: uint16(35837), + 140: uint16(21536), + 141: uint16(32954), + 142: uint16(24223), + 143: uint16(27832), + 144: uint16(36153), + 145: uint16(33452), + 146: uint16(37210), + 147: uint16(21545), + 148: uint16(27675), + 149: uint16(20998), + 150: uint16(32439), + 151: uint16(22367), + 152: uint16(28954), + 153: uint16(27774), + 154: uint16(31881), + 155: uint16(22859), + 156: uint16(20221), + 157: uint16(24575), + 158: uint16(24868), + 159: uint16(31914), + 160: uint16(20016), + 161: uint16(23553), + 162: uint16(26539), + 163: uint16(34562), + 164: uint16(23792), + 165: uint16(38155), + 166: uint16(39118), + 167: uint16(30127), + 168: uint16(28925), + 169: uint16(36898), + 170: uint16(20911), + 171: uint16(32541), + 172: uint16(35773), + 173: uint16(22857), + 174: uint16(20964), + 175: uint16(20315), + 176: uint16(21542), + 177: uint16(22827), + 178: uint16(25975), + 179: uint16(32932), + 180: uint16(23413), + 181: uint16(25206), + 182: uint16(25282), + 183: uint16(36752), + 184: uint16(24133), + 185: uint16(27679), + 186: uint16(31526), + 187: uint16(20239), + 188: uint16(20440), + 189: uint16(26381), + }, + 55: { + 0: uint16(31395), + 1: uint16(31396), + 2: uint16(31399), + 3: uint16(31401), + 4: uint16(31402), + 5: uint16(31403), + 6: uint16(31406), + 7: uint16(31407), + 8: uint16(31408), + 9: uint16(31409), + 10: uint16(31410), + 11: uint16(31412), + 12: uint16(31413), + 13: uint16(31414), + 14: uint16(31415), + 15: uint16(31416), + 16: uint16(31417), + 17: uint16(31418), + 18: uint16(31419), + 19: uint16(31420), + 20: uint16(31421), + 21: uint16(31422), + 22: uint16(31424), + 23: uint16(31425), + 24: uint16(31426), + 25: uint16(31427), + 26: uint16(31428), + 27: uint16(31429), + 28: uint16(31430), + 29: uint16(31431), + 30: uint16(31432), + 31: uint16(31433), + 32: uint16(31434), + 33: uint16(31436), + 34: uint16(31437), + 35: uint16(31438), + 36: uint16(31439), + 37: uint16(31440), + 38: uint16(31441), + 39: uint16(31442), + 40: uint16(31443), + 41: uint16(31444), + 42: uint16(31445), + 43: uint16(31447), + 44: uint16(31448), + 45: uint16(31450), + 46: uint16(31451), + 47: uint16(31452), + 48: uint16(31453), + 49: uint16(31457), + 50: uint16(31458), + 51: uint16(31460), + 52: uint16(31463), + 53: uint16(31464), + 54: uint16(31465), + 55: uint16(31466), + 56: uint16(31467), + 57: uint16(31468), + 58: uint16(31470), + 59: uint16(31472), + 60: uint16(31473), + 61: uint16(31474), + 62: uint16(31475), + 63: uint16(31476), + 64: uint16(31477), + 65: uint16(31478), + 66: uint16(31479), + 67: uint16(31480), + 68: uint16(31483), + 69: uint16(31484), + 70: uint16(31486), + 71: uint16(31488), + 72: uint16(31489), + 73: uint16(31490), + 74: uint16(31493), + 75: uint16(31495), + 76: uint16(31497), + 77: uint16(31500), + 78: uint16(31501), + 79: uint16(31502), + 80: uint16(31504), + 81: uint16(31506), + 82: uint16(31507), + 83: uint16(31510), + 84: uint16(31511), + 85: uint16(31512), + 86: uint16(31514), + 87: uint16(31516), + 88: uint16(31517), + 89: uint16(31519), + 90: uint16(31521), + 91: uint16(31522), + 92: uint16(31523), + 93: uint16(31527), + 94: uint16(31529), + 95: uint16(31533), + 96: uint16(28014), + 97: uint16(28074), + 98: uint16(31119), + 99: uint16(34993), + 100: uint16(24343), + 101: uint16(29995), + 102: uint16(25242), + 103: uint16(36741), + 104: uint16(20463), + 105: uint16(37340), + 106: uint16(26023), + 107: uint16(33071), + 108: uint16(33105), + 109: uint16(24220), + 110: uint16(33104), + 111: uint16(36212), + 112: uint16(21103), + 113: uint16(35206), + 114: uint16(36171), + 115: uint16(22797), + 116: uint16(20613), + 117: uint16(20184), + 118: uint16(38428), + 119: uint16(29238), + 120: uint16(33145), + 121: uint16(36127), + 122: uint16(23500), + 123: uint16(35747), + 124: uint16(38468), + 125: uint16(22919), + 126: uint16(32538), + 127: uint16(21648), + 128: uint16(22134), + 129: uint16(22030), + 130: uint16(35813), + 131: uint16(25913), + 132: uint16(27010), + 133: uint16(38041), + 134: uint16(30422), + 135: uint16(28297), + 136: uint16(24178), + 137: uint16(29976), + 138: uint16(26438), + 139: uint16(26577), + 140: uint16(31487), + 141: uint16(32925), + 142: uint16(36214), + 143: uint16(24863), + 144: uint16(31174), + 145: uint16(25954), + 146: uint16(36195), + 147: uint16(20872), + 148: uint16(21018), + 149: uint16(38050), + 150: uint16(32568), + 151: uint16(32923), + 152: uint16(32434), + 153: uint16(23703), + 154: uint16(28207), + 155: uint16(26464), + 156: uint16(31705), + 157: uint16(30347), + 158: uint16(39640), + 159: uint16(33167), + 160: uint16(32660), + 161: uint16(31957), + 162: uint16(25630), + 163: uint16(38224), + 164: uint16(31295), + 165: uint16(21578), + 166: uint16(21733), + 167: uint16(27468), + 168: uint16(25601), + 169: uint16(25096), + 170: uint16(40509), + 171: uint16(33011), + 172: uint16(30105), + 173: uint16(21106), + 174: uint16(38761), + 175: uint16(33883), + 176: uint16(26684), + 177: uint16(34532), + 178: uint16(38401), + 179: uint16(38548), + 180: uint16(38124), + 181: uint16(20010), + 182: uint16(21508), + 183: uint16(32473), + 184: uint16(26681), + 185: uint16(36319), + 186: uint16(32789), + 187: uint16(26356), + 188: uint16(24218), + 189: uint16(32697), + }, + 56: { + 0: uint16(31535), + 1: uint16(31536), + 2: uint16(31538), + 3: uint16(31540), + 4: uint16(31541), + 5: uint16(31542), + 6: uint16(31543), + 7: uint16(31545), + 8: uint16(31547), + 9: uint16(31549), + 10: uint16(31551), + 11: uint16(31552), + 12: uint16(31553), + 13: uint16(31554), + 14: uint16(31555), + 15: uint16(31556), + 16: uint16(31558), + 17: uint16(31560), + 18: uint16(31562), + 19: uint16(31565), + 20: uint16(31566), + 21: uint16(31571), + 22: uint16(31573), + 23: uint16(31575), + 24: uint16(31577), + 25: uint16(31580), + 26: uint16(31582), + 27: uint16(31583), + 28: uint16(31585), + 29: uint16(31587), + 30: uint16(31588), + 31: uint16(31589), + 32: uint16(31590), + 33: uint16(31591), + 34: uint16(31592), + 35: uint16(31593), + 36: uint16(31594), + 37: uint16(31595), + 38: uint16(31596), + 39: uint16(31597), + 40: uint16(31599), + 41: uint16(31600), + 42: uint16(31603), + 43: uint16(31604), + 44: uint16(31606), + 45: uint16(31608), + 46: uint16(31610), + 47: uint16(31612), + 48: uint16(31613), + 49: uint16(31615), + 50: uint16(31617), + 51: uint16(31618), + 52: uint16(31619), + 53: uint16(31620), + 54: uint16(31622), + 55: uint16(31623), + 56: uint16(31624), + 57: uint16(31625), + 58: uint16(31626), + 59: uint16(31627), + 60: uint16(31628), + 61: uint16(31630), + 62: uint16(31631), + 63: uint16(31633), + 64: uint16(31634), + 65: uint16(31635), + 66: uint16(31638), + 67: uint16(31640), + 68: uint16(31641), + 69: uint16(31642), + 70: uint16(31643), + 71: uint16(31646), + 72: uint16(31647), + 73: uint16(31648), + 74: uint16(31651), + 75: uint16(31652), + 76: uint16(31653), + 77: uint16(31662), + 78: uint16(31663), + 79: uint16(31664), + 80: uint16(31666), + 81: uint16(31667), + 82: uint16(31669), + 83: uint16(31670), + 84: uint16(31671), + 85: uint16(31673), + 86: uint16(31674), + 87: uint16(31675), + 88: uint16(31676), + 89: uint16(31677), + 90: uint16(31678), + 91: uint16(31679), + 92: uint16(31680), + 93: uint16(31682), + 94: uint16(31683), + 95: uint16(31684), + 96: uint16(22466), + 97: uint16(32831), + 98: uint16(26775), + 99: uint16(24037), + 100: uint16(25915), + 101: uint16(21151), + 102: uint16(24685), + 103: uint16(40858), + 104: uint16(20379), + 105: uint16(36524), + 106: uint16(20844), + 107: uint16(23467), + 108: uint16(24339), + 109: uint16(24041), + 110: uint16(27742), + 111: uint16(25329), + 112: uint16(36129), + 113: uint16(20849), + 114: uint16(38057), + 115: uint16(21246), + 116: uint16(27807), + 117: uint16(33503), + 118: uint16(29399), + 119: uint16(22434), + 120: uint16(26500), + 121: uint16(36141), + 122: uint16(22815), + 123: uint16(36764), + 124: uint16(33735), + 125: uint16(21653), + 126: uint16(31629), + 127: uint16(20272), + 128: uint16(27837), + 129: uint16(23396), + 130: uint16(22993), + 131: uint16(40723), + 132: uint16(21476), + 133: uint16(34506), + 134: uint16(39592), + 135: uint16(35895), + 136: uint16(32929), + 137: uint16(25925), + 138: uint16(39038), + 139: uint16(22266), + 140: uint16(38599), + 141: uint16(21038), + 142: uint16(29916), + 143: uint16(21072), + 144: uint16(23521), + 145: uint16(25346), + 146: uint16(35074), + 147: uint16(20054), + 148: uint16(25296), + 149: uint16(24618), + 150: uint16(26874), + 151: uint16(20851), + 152: uint16(23448), + 153: uint16(20896), + 154: uint16(35266), + 155: uint16(31649), + 156: uint16(39302), + 157: uint16(32592), + 158: uint16(24815), + 159: uint16(28748), + 160: uint16(36143), + 161: uint16(20809), + 162: uint16(24191), + 163: uint16(36891), + 164: uint16(29808), + 165: uint16(35268), + 166: uint16(22317), + 167: uint16(30789), + 168: uint16(24402), + 169: uint16(40863), + 170: uint16(38394), + 171: uint16(36712), + 172: uint16(39740), + 173: uint16(35809), + 174: uint16(30328), + 175: uint16(26690), + 176: uint16(26588), + 177: uint16(36330), + 178: uint16(36149), + 179: uint16(21053), + 180: uint16(36746), + 181: uint16(28378), + 182: uint16(26829), + 183: uint16(38149), + 184: uint16(37101), + 185: uint16(22269), + 186: uint16(26524), + 187: uint16(35065), + 188: uint16(36807), + 189: uint16(21704), + }, + 57: { + 0: uint16(31685), + 1: uint16(31688), + 2: uint16(31689), + 3: uint16(31690), + 4: uint16(31691), + 5: uint16(31693), + 6: uint16(31694), + 7: uint16(31695), + 8: uint16(31696), + 9: uint16(31698), + 10: uint16(31700), + 11: uint16(31701), + 12: uint16(31702), + 13: uint16(31703), + 14: uint16(31704), + 15: uint16(31707), + 16: uint16(31708), + 17: uint16(31710), + 18: uint16(31711), + 19: uint16(31712), + 20: uint16(31714), + 21: uint16(31715), + 22: uint16(31716), + 23: uint16(31719), + 24: uint16(31720), + 25: uint16(31721), + 26: uint16(31723), + 27: uint16(31724), + 28: uint16(31725), + 29: uint16(31727), + 30: uint16(31728), + 31: uint16(31730), + 32: uint16(31731), + 33: uint16(31732), + 34: uint16(31733), + 35: uint16(31734), + 36: uint16(31736), + 37: uint16(31737), + 38: uint16(31738), + 39: uint16(31739), + 40: uint16(31741), + 41: uint16(31743), + 42: uint16(31744), + 43: uint16(31745), + 44: uint16(31746), + 45: uint16(31747), + 46: uint16(31748), + 47: uint16(31749), + 48: uint16(31750), + 49: uint16(31752), + 50: uint16(31753), + 51: uint16(31754), + 52: uint16(31757), + 53: uint16(31758), + 54: uint16(31760), + 55: uint16(31761), + 56: uint16(31762), + 57: uint16(31763), + 58: uint16(31764), + 59: uint16(31765), + 60: uint16(31767), + 61: uint16(31768), + 62: uint16(31769), + 63: uint16(31770), + 64: uint16(31771), + 65: uint16(31772), + 66: uint16(31773), + 67: uint16(31774), + 68: uint16(31776), + 69: uint16(31777), + 70: uint16(31778), + 71: uint16(31779), + 72: uint16(31780), + 73: uint16(31781), + 74: uint16(31784), + 75: uint16(31785), + 76: uint16(31787), + 77: uint16(31788), + 78: uint16(31789), + 79: uint16(31790), + 80: uint16(31791), + 81: uint16(31792), + 82: uint16(31793), + 83: uint16(31794), + 84: uint16(31795), + 85: uint16(31796), + 86: uint16(31797), + 87: uint16(31798), + 88: uint16(31799), + 89: uint16(31801), + 90: uint16(31802), + 91: uint16(31803), + 92: uint16(31804), + 93: uint16(31805), + 94: uint16(31806), + 95: uint16(31810), + 96: uint16(39608), + 97: uint16(23401), + 98: uint16(28023), + 99: uint16(27686), + 100: uint16(20133), + 101: uint16(23475), + 102: uint16(39559), + 103: uint16(37219), + 104: uint16(25000), + 105: uint16(37039), + 106: uint16(38889), + 107: uint16(21547), + 108: uint16(28085), + 109: uint16(23506), + 110: uint16(20989), + 111: uint16(21898), + 112: uint16(32597), + 113: uint16(32752), + 114: uint16(25788), + 115: uint16(25421), + 116: uint16(26097), + 117: uint16(25022), + 118: uint16(24717), + 119: uint16(28938), + 120: uint16(27735), + 121: uint16(27721), + 122: uint16(22831), + 123: uint16(26477), + 124: uint16(33322), + 125: uint16(22741), + 126: uint16(22158), + 127: uint16(35946), + 128: uint16(27627), + 129: uint16(37085), + 130: uint16(22909), + 131: uint16(32791), + 132: uint16(21495), + 133: uint16(28009), + 134: uint16(21621), + 135: uint16(21917), + 136: uint16(33655), + 137: uint16(33743), + 138: uint16(26680), + 139: uint16(31166), + 140: uint16(21644), + 141: uint16(20309), + 142: uint16(21512), + 143: uint16(30418), + 144: uint16(35977), + 145: uint16(38402), + 146: uint16(27827), + 147: uint16(28088), + 148: uint16(36203), + 149: uint16(35088), + 150: uint16(40548), + 151: uint16(36154), + 152: uint16(22079), + 153: uint16(40657), + 154: uint16(30165), + 155: uint16(24456), + 156: uint16(29408), + 157: uint16(24680), + 158: uint16(21756), + 159: uint16(20136), + 160: uint16(27178), + 161: uint16(34913), + 162: uint16(24658), + 163: uint16(36720), + 164: uint16(21700), + 165: uint16(28888), + 166: uint16(34425), + 167: uint16(40511), + 168: uint16(27946), + 169: uint16(23439), + 170: uint16(24344), + 171: uint16(32418), + 172: uint16(21897), + 173: uint16(20399), + 174: uint16(29492), + 175: uint16(21564), + 176: uint16(21402), + 177: uint16(20505), + 178: uint16(21518), + 179: uint16(21628), + 180: uint16(20046), + 181: uint16(24573), + 182: uint16(29786), + 183: uint16(22774), + 184: uint16(33899), + 185: uint16(32993), + 186: uint16(34676), + 187: uint16(29392), + 188: uint16(31946), + 189: uint16(28246), + }, + 58: { + 0: uint16(31811), + 1: uint16(31812), + 2: uint16(31813), + 3: uint16(31814), + 4: uint16(31815), + 5: uint16(31816), + 6: uint16(31817), + 7: uint16(31818), + 8: uint16(31819), + 9: uint16(31820), + 10: uint16(31822), + 11: uint16(31823), + 12: uint16(31824), + 13: uint16(31825), + 14: uint16(31826), + 15: uint16(31827), + 16: uint16(31828), + 17: uint16(31829), + 18: uint16(31830), + 19: uint16(31831), + 20: uint16(31832), + 21: uint16(31833), + 22: uint16(31834), + 23: uint16(31835), + 24: uint16(31836), + 25: uint16(31837), + 26: uint16(31838), + 27: uint16(31839), + 28: uint16(31840), + 29: uint16(31841), + 30: uint16(31842), + 31: uint16(31843), + 32: uint16(31844), + 33: uint16(31845), + 34: uint16(31846), + 35: uint16(31847), + 36: uint16(31848), + 37: uint16(31849), + 38: uint16(31850), + 39: uint16(31851), + 40: uint16(31852), + 41: uint16(31853), + 42: uint16(31854), + 43: uint16(31855), + 44: uint16(31856), + 45: uint16(31857), + 46: uint16(31858), + 47: uint16(31861), + 48: uint16(31862), + 49: uint16(31863), + 50: uint16(31864), + 51: uint16(31865), + 52: uint16(31866), + 53: uint16(31870), + 54: uint16(31871), + 55: uint16(31872), + 56: uint16(31873), + 57: uint16(31874), + 58: uint16(31875), + 59: uint16(31876), + 60: uint16(31877), + 61: uint16(31878), + 62: uint16(31879), + 63: uint16(31880), + 64: uint16(31882), + 65: uint16(31883), + 66: uint16(31884), + 67: uint16(31885), + 68: uint16(31886), + 69: uint16(31887), + 70: uint16(31888), + 71: uint16(31891), + 72: uint16(31892), + 73: uint16(31894), + 74: uint16(31897), + 75: uint16(31898), + 76: uint16(31899), + 77: uint16(31904), + 78: uint16(31905), + 79: uint16(31907), + 80: uint16(31910), + 81: uint16(31911), + 82: uint16(31912), + 83: uint16(31913), + 84: uint16(31915), + 85: uint16(31916), + 86: uint16(31917), + 87: uint16(31919), + 88: uint16(31920), + 89: uint16(31924), + 90: uint16(31925), + 91: uint16(31926), + 92: uint16(31927), + 93: uint16(31928), + 94: uint16(31930), + 95: uint16(31931), + 96: uint16(24359), + 97: uint16(34382), + 98: uint16(21804), + 99: uint16(25252), + 100: uint16(20114), + 101: uint16(27818), + 102: uint16(25143), + 103: uint16(33457), + 104: uint16(21719), + 105: uint16(21326), + 106: uint16(29502), + 107: uint16(28369), + 108: uint16(30011), + 109: uint16(21010), + 110: uint16(21270), + 111: uint16(35805), + 112: uint16(27088), + 113: uint16(24458), + 114: uint16(24576), + 115: uint16(28142), + 116: uint16(22351), + 117: uint16(27426), + 118: uint16(29615), + 119: uint16(26707), + 120: uint16(36824), + 121: uint16(32531), + 122: uint16(25442), + 123: uint16(24739), + 124: uint16(21796), + 125: uint16(30186), + 126: uint16(35938), + 127: uint16(28949), + 128: uint16(28067), + 129: uint16(23462), + 130: uint16(24187), + 131: uint16(33618), + 132: uint16(24908), + 133: uint16(40644), + 134: uint16(30970), + 135: uint16(34647), + 136: uint16(31783), + 137: uint16(30343), + 138: uint16(20976), + 139: uint16(24822), + 140: uint16(29004), + 141: uint16(26179), + 142: uint16(24140), + 143: uint16(24653), + 144: uint16(35854), + 145: uint16(28784), + 146: uint16(25381), + 147: uint16(36745), + 148: uint16(24509), + 149: uint16(24674), + 150: uint16(34516), + 151: uint16(22238), + 152: uint16(27585), + 153: uint16(24724), + 154: uint16(24935), + 155: uint16(21321), + 156: uint16(24800), + 157: uint16(26214), + 158: uint16(36159), + 159: uint16(31229), + 160: uint16(20250), + 161: uint16(28905), + 162: uint16(27719), + 163: uint16(35763), + 164: uint16(35826), + 165: uint16(32472), + 166: uint16(33636), + 167: uint16(26127), + 168: uint16(23130), + 169: uint16(39746), + 170: uint16(27985), + 171: uint16(28151), + 172: uint16(35905), + 173: uint16(27963), + 174: uint16(20249), + 175: uint16(28779), + 176: uint16(33719), + 177: uint16(25110), + 178: uint16(24785), + 179: uint16(38669), + 180: uint16(36135), + 181: uint16(31096), + 182: uint16(20987), + 183: uint16(22334), + 184: uint16(22522), + 185: uint16(26426), + 186: uint16(30072), + 187: uint16(31293), + 188: uint16(31215), + 189: uint16(31637), + }, + 59: { + 0: uint16(31935), + 1: uint16(31936), + 2: uint16(31938), + 3: uint16(31939), + 4: uint16(31940), + 5: uint16(31942), + 6: uint16(31945), + 7: uint16(31947), + 8: uint16(31950), + 9: uint16(31951), + 10: uint16(31952), + 11: uint16(31953), + 12: uint16(31954), + 13: uint16(31955), + 14: uint16(31956), + 15: uint16(31960), + 16: uint16(31962), + 17: uint16(31963), + 18: uint16(31965), + 19: uint16(31966), + 20: uint16(31969), + 21: uint16(31970), + 22: uint16(31971), + 23: uint16(31972), + 24: uint16(31973), + 25: uint16(31974), + 26: uint16(31975), + 27: uint16(31977), + 28: uint16(31978), + 29: uint16(31979), + 30: uint16(31980), + 31: uint16(31981), + 32: uint16(31982), + 33: uint16(31984), + 34: uint16(31985), + 35: uint16(31986), + 36: uint16(31987), + 37: uint16(31988), + 38: uint16(31989), + 39: uint16(31990), + 40: uint16(31991), + 41: uint16(31993), + 42: uint16(31994), + 43: uint16(31996), + 44: uint16(31997), + 45: uint16(31998), + 46: uint16(31999), + 47: uint16(32000), + 48: uint16(32001), + 49: uint16(32002), + 50: uint16(32003), + 51: uint16(32004), + 52: uint16(32005), + 53: uint16(32006), + 54: uint16(32007), + 55: uint16(32008), + 56: uint16(32009), + 57: uint16(32011), + 58: uint16(32012), + 59: uint16(32013), + 60: uint16(32014), + 61: uint16(32015), + 62: uint16(32016), + 63: uint16(32017), + 64: uint16(32018), + 65: uint16(32019), + 66: uint16(32020), + 67: uint16(32021), + 68: uint16(32022), + 69: uint16(32023), + 70: uint16(32024), + 71: uint16(32025), + 72: uint16(32026), + 73: uint16(32027), + 74: uint16(32028), + 75: uint16(32029), + 76: uint16(32030), + 77: uint16(32031), + 78: uint16(32033), + 79: uint16(32035), + 80: uint16(32036), + 81: uint16(32037), + 82: uint16(32038), + 83: uint16(32040), + 84: uint16(32041), + 85: uint16(32042), + 86: uint16(32044), + 87: uint16(32045), + 88: uint16(32046), + 89: uint16(32048), + 90: uint16(32049), + 91: uint16(32050), + 92: uint16(32051), + 93: uint16(32052), + 94: uint16(32053), + 95: uint16(32054), + 96: uint16(32908), + 97: uint16(39269), + 98: uint16(36857), + 99: uint16(28608), + 100: uint16(35749), + 101: uint16(40481), + 102: uint16(23020), + 103: uint16(32489), + 104: uint16(32521), + 105: uint16(21513), + 106: uint16(26497), + 107: uint16(26840), + 108: uint16(36753), + 109: uint16(31821), + 110: uint16(38598), + 111: uint16(21450), + 112: uint16(24613), + 113: uint16(30142), + 114: uint16(27762), + 115: uint16(21363), + 116: uint16(23241), + 117: uint16(32423), + 118: uint16(25380), + 119: uint16(20960), + 120: uint16(33034), + 121: uint16(24049), + 122: uint16(34015), + 123: uint16(25216), + 124: uint16(20864), + 125: uint16(23395), + 126: uint16(20238), + 127: uint16(31085), + 128: uint16(21058), + 129: uint16(24760), + 130: uint16(27982), + 131: uint16(23492), + 132: uint16(23490), + 133: uint16(35745), + 134: uint16(35760), + 135: uint16(26082), + 136: uint16(24524), + 137: uint16(38469), + 138: uint16(22931), + 139: uint16(32487), + 140: uint16(32426), + 141: uint16(22025), + 142: uint16(26551), + 143: uint16(22841), + 144: uint16(20339), + 145: uint16(23478), + 146: uint16(21152), + 147: uint16(33626), + 148: uint16(39050), + 149: uint16(36158), + 150: uint16(30002), + 151: uint16(38078), + 152: uint16(20551), + 153: uint16(31292), + 154: uint16(20215), + 155: uint16(26550), + 156: uint16(39550), + 157: uint16(23233), + 158: uint16(27516), + 159: uint16(30417), + 160: uint16(22362), + 161: uint16(23574), + 162: uint16(31546), + 163: uint16(38388), + 164: uint16(29006), + 165: uint16(20860), + 166: uint16(32937), + 167: uint16(33392), + 168: uint16(22904), + 169: uint16(32516), + 170: uint16(33575), + 171: uint16(26816), + 172: uint16(26604), + 173: uint16(30897), + 174: uint16(30839), + 175: uint16(25315), + 176: uint16(25441), + 177: uint16(31616), + 178: uint16(20461), + 179: uint16(21098), + 180: uint16(20943), + 181: uint16(33616), + 182: uint16(27099), + 183: uint16(37492), + 184: uint16(36341), + 185: uint16(36145), + 186: uint16(35265), + 187: uint16(38190), + 188: uint16(31661), + 189: uint16(20214), + }, + 60: { + 0: uint16(32055), + 1: uint16(32056), + 2: uint16(32057), + 3: uint16(32058), + 4: uint16(32059), + 5: uint16(32060), + 6: uint16(32061), + 7: uint16(32062), + 8: uint16(32063), + 9: uint16(32064), + 10: uint16(32065), + 11: uint16(32066), + 12: uint16(32067), + 13: uint16(32068), + 14: uint16(32069), + 15: uint16(32070), + 16: uint16(32071), + 17: uint16(32072), + 18: uint16(32073), + 19: uint16(32074), + 20: uint16(32075), + 21: uint16(32076), + 22: uint16(32077), + 23: uint16(32078), + 24: uint16(32079), + 25: uint16(32080), + 26: uint16(32081), + 27: uint16(32082), + 28: uint16(32083), + 29: uint16(32084), + 30: uint16(32085), + 31: uint16(32086), + 32: uint16(32087), + 33: uint16(32088), + 34: uint16(32089), + 35: uint16(32090), + 36: uint16(32091), + 37: uint16(32092), + 38: uint16(32093), + 39: uint16(32094), + 40: uint16(32095), + 41: uint16(32096), + 42: uint16(32097), + 43: uint16(32098), + 44: uint16(32099), + 45: uint16(32100), + 46: uint16(32101), + 47: uint16(32102), + 48: uint16(32103), + 49: uint16(32104), + 50: uint16(32105), + 51: uint16(32106), + 52: uint16(32107), + 53: uint16(32108), + 54: uint16(32109), + 55: uint16(32111), + 56: uint16(32112), + 57: uint16(32113), + 58: uint16(32114), + 59: uint16(32115), + 60: uint16(32116), + 61: uint16(32117), + 62: uint16(32118), + 63: uint16(32120), + 64: uint16(32121), + 65: uint16(32122), + 66: uint16(32123), + 67: uint16(32124), + 68: uint16(32125), + 69: uint16(32126), + 70: uint16(32127), + 71: uint16(32128), + 72: uint16(32129), + 73: uint16(32130), + 74: uint16(32131), + 75: uint16(32132), + 76: uint16(32133), + 77: uint16(32134), + 78: uint16(32135), + 79: uint16(32136), + 80: uint16(32137), + 81: uint16(32138), + 82: uint16(32139), + 83: uint16(32140), + 84: uint16(32141), + 85: uint16(32142), + 86: uint16(32143), + 87: uint16(32144), + 88: uint16(32145), + 89: uint16(32146), + 90: uint16(32147), + 91: uint16(32148), + 92: uint16(32149), + 93: uint16(32150), + 94: uint16(32151), + 95: uint16(32152), + 96: uint16(20581), + 97: uint16(33328), + 98: uint16(21073), + 99: uint16(39279), + 100: uint16(28176), + 101: uint16(28293), + 102: uint16(28071), + 103: uint16(24314), + 104: uint16(20725), + 105: uint16(23004), + 106: uint16(23558), + 107: uint16(27974), + 108: uint16(27743), + 109: uint16(30086), + 110: uint16(33931), + 111: uint16(26728), + 112: uint16(22870), + 113: uint16(35762), + 114: uint16(21280), + 115: uint16(37233), + 116: uint16(38477), + 117: uint16(34121), + 118: uint16(26898), + 119: uint16(30977), + 120: uint16(28966), + 121: uint16(33014), + 122: uint16(20132), + 123: uint16(37066), + 124: uint16(27975), + 125: uint16(39556), + 126: uint16(23047), + 127: uint16(22204), + 128: uint16(25605), + 129: uint16(38128), + 130: uint16(30699), + 131: uint16(20389), + 132: uint16(33050), + 133: uint16(29409), + 134: uint16(35282), + 135: uint16(39290), + 136: uint16(32564), + 137: uint16(32478), + 138: uint16(21119), + 139: uint16(25945), + 140: uint16(37237), + 141: uint16(36735), + 142: uint16(36739), + 143: uint16(21483), + 144: uint16(31382), + 145: uint16(25581), + 146: uint16(25509), + 147: uint16(30342), + 148: uint16(31224), + 149: uint16(34903), + 150: uint16(38454), + 151: uint16(25130), + 152: uint16(21163), + 153: uint16(33410), + 154: uint16(26708), + 155: uint16(26480), + 156: uint16(25463), + 157: uint16(30571), + 158: uint16(31469), + 159: uint16(27905), + 160: uint16(32467), + 161: uint16(35299), + 162: uint16(22992), + 163: uint16(25106), + 164: uint16(34249), + 165: uint16(33445), + 166: uint16(30028), + 167: uint16(20511), + 168: uint16(20171), + 169: uint16(30117), + 170: uint16(35819), + 171: uint16(23626), + 172: uint16(24062), + 173: uint16(31563), + 174: uint16(26020), + 175: uint16(37329), + 176: uint16(20170), + 177: uint16(27941), + 178: uint16(35167), + 179: uint16(32039), + 180: uint16(38182), + 181: uint16(20165), + 182: uint16(35880), + 183: uint16(36827), + 184: uint16(38771), + 185: uint16(26187), + 186: uint16(31105), + 187: uint16(36817), + 188: uint16(28908), + 189: uint16(28024), + }, + 61: { + 0: uint16(32153), + 1: uint16(32154), + 2: uint16(32155), + 3: uint16(32156), + 4: uint16(32157), + 5: uint16(32158), + 6: uint16(32159), + 7: uint16(32160), + 8: uint16(32161), + 9: uint16(32162), + 10: uint16(32163), + 11: uint16(32164), + 12: uint16(32165), + 13: uint16(32167), + 14: uint16(32168), + 15: uint16(32169), + 16: uint16(32170), + 17: uint16(32171), + 18: uint16(32172), + 19: uint16(32173), + 20: uint16(32175), + 21: uint16(32176), + 22: uint16(32177), + 23: uint16(32178), + 24: uint16(32179), + 25: uint16(32180), + 26: uint16(32181), + 27: uint16(32182), + 28: uint16(32183), + 29: uint16(32184), + 30: uint16(32185), + 31: uint16(32186), + 32: uint16(32187), + 33: uint16(32188), + 34: uint16(32189), + 35: uint16(32190), + 36: uint16(32191), + 37: uint16(32192), + 38: uint16(32193), + 39: uint16(32194), + 40: uint16(32195), + 41: uint16(32196), + 42: uint16(32197), + 43: uint16(32198), + 44: uint16(32199), + 45: uint16(32200), + 46: uint16(32201), + 47: uint16(32202), + 48: uint16(32203), + 49: uint16(32204), + 50: uint16(32205), + 51: uint16(32206), + 52: uint16(32207), + 53: uint16(32208), + 54: uint16(32209), + 55: uint16(32210), + 56: uint16(32211), + 57: uint16(32212), + 58: uint16(32213), + 59: uint16(32214), + 60: uint16(32215), + 61: uint16(32216), + 62: uint16(32217), + 63: uint16(32218), + 64: uint16(32219), + 65: uint16(32220), + 66: uint16(32221), + 67: uint16(32222), + 68: uint16(32223), + 69: uint16(32224), + 70: uint16(32225), + 71: uint16(32226), + 72: uint16(32227), + 73: uint16(32228), + 74: uint16(32229), + 75: uint16(32230), + 76: uint16(32231), + 77: uint16(32232), + 78: uint16(32233), + 79: uint16(32234), + 80: uint16(32235), + 81: uint16(32236), + 82: uint16(32237), + 83: uint16(32238), + 84: uint16(32239), + 85: uint16(32240), + 86: uint16(32241), + 87: uint16(32242), + 88: uint16(32243), + 89: uint16(32244), + 90: uint16(32245), + 91: uint16(32246), + 92: uint16(32247), + 93: uint16(32248), + 94: uint16(32249), + 95: uint16(32250), + 96: uint16(23613), + 97: uint16(21170), + 98: uint16(33606), + 99: uint16(20834), + 100: uint16(33550), + 101: uint16(30555), + 102: uint16(26230), + 103: uint16(40120), + 104: uint16(20140), + 105: uint16(24778), + 106: uint16(31934), + 107: uint16(31923), + 108: uint16(32463), + 109: uint16(20117), + 110: uint16(35686), + 111: uint16(26223), + 112: uint16(39048), + 113: uint16(38745), + 114: uint16(22659), + 115: uint16(25964), + 116: uint16(38236), + 117: uint16(24452), + 118: uint16(30153), + 119: uint16(38742), + 120: uint16(31455), + 121: uint16(31454), + 122: uint16(20928), + 123: uint16(28847), + 124: uint16(31384), + 125: uint16(25578), + 126: uint16(31350), + 127: uint16(32416), + 128: uint16(29590), + 129: uint16(38893), + 130: uint16(20037), + 131: uint16(28792), + 132: uint16(20061), + 133: uint16(37202), + 134: uint16(21417), + 135: uint16(25937), + 136: uint16(26087), + 137: uint16(33276), + 138: uint16(33285), + 139: uint16(21646), + 140: uint16(23601), + 141: uint16(30106), + 142: uint16(38816), + 143: uint16(25304), + 144: uint16(29401), + 145: uint16(30141), + 146: uint16(23621), + 147: uint16(39545), + 148: uint16(33738), + 149: uint16(23616), + 150: uint16(21632), + 151: uint16(30697), + 152: uint16(20030), + 153: uint16(27822), + 154: uint16(32858), + 155: uint16(25298), + 156: uint16(25454), + 157: uint16(24040), + 158: uint16(20855), + 159: uint16(36317), + 160: uint16(36382), + 161: uint16(38191), + 162: uint16(20465), + 163: uint16(21477), + 164: uint16(24807), + 165: uint16(28844), + 166: uint16(21095), + 167: uint16(25424), + 168: uint16(40515), + 169: uint16(23071), + 170: uint16(20518), + 171: uint16(30519), + 172: uint16(21367), + 173: uint16(32482), + 174: uint16(25733), + 175: uint16(25899), + 176: uint16(25225), + 177: uint16(25496), + 178: uint16(20500), + 179: uint16(29237), + 180: uint16(35273), + 181: uint16(20915), + 182: uint16(35776), + 183: uint16(32477), + 184: uint16(22343), + 185: uint16(33740), + 186: uint16(38055), + 187: uint16(20891), + 188: uint16(21531), + 189: uint16(23803), + }, + 62: { + 0: uint16(32251), + 1: uint16(32252), + 2: uint16(32253), + 3: uint16(32254), + 4: uint16(32255), + 5: uint16(32256), + 6: uint16(32257), + 7: uint16(32258), + 8: uint16(32259), + 9: uint16(32260), + 10: uint16(32261), + 11: uint16(32262), + 12: uint16(32263), + 13: uint16(32264), + 14: uint16(32265), + 15: uint16(32266), + 16: uint16(32267), + 17: uint16(32268), + 18: uint16(32269), + 19: uint16(32270), + 20: uint16(32271), + 21: uint16(32272), + 22: uint16(32273), + 23: uint16(32274), + 24: uint16(32275), + 25: uint16(32276), + 26: uint16(32277), + 27: uint16(32278), + 28: uint16(32279), + 29: uint16(32280), + 30: uint16(32281), + 31: uint16(32282), + 32: uint16(32283), + 33: uint16(32284), + 34: uint16(32285), + 35: uint16(32286), + 36: uint16(32287), + 37: uint16(32288), + 38: uint16(32289), + 39: uint16(32290), + 40: uint16(32291), + 41: uint16(32292), + 42: uint16(32293), + 43: uint16(32294), + 44: uint16(32295), + 45: uint16(32296), + 46: uint16(32297), + 47: uint16(32298), + 48: uint16(32299), + 49: uint16(32300), + 50: uint16(32301), + 51: uint16(32302), + 52: uint16(32303), + 53: uint16(32304), + 54: uint16(32305), + 55: uint16(32306), + 56: uint16(32307), + 57: uint16(32308), + 58: uint16(32309), + 59: uint16(32310), + 60: uint16(32311), + 61: uint16(32312), + 62: uint16(32313), + 63: uint16(32314), + 64: uint16(32316), + 65: uint16(32317), + 66: uint16(32318), + 67: uint16(32319), + 68: uint16(32320), + 69: uint16(32322), + 70: uint16(32323), + 71: uint16(32324), + 72: uint16(32325), + 73: uint16(32326), + 74: uint16(32328), + 75: uint16(32329), + 76: uint16(32330), + 77: uint16(32331), + 78: uint16(32332), + 79: uint16(32333), + 80: uint16(32334), + 81: uint16(32335), + 82: uint16(32336), + 83: uint16(32337), + 84: uint16(32338), + 85: uint16(32339), + 86: uint16(32340), + 87: uint16(32341), + 88: uint16(32342), + 89: uint16(32343), + 90: uint16(32344), + 91: uint16(32345), + 92: uint16(32346), + 93: uint16(32347), + 94: uint16(32348), + 95: uint16(32349), + 96: uint16(20426), + 97: uint16(31459), + 98: uint16(27994), + 99: uint16(37089), + 100: uint16(39567), + 101: uint16(21888), + 102: uint16(21654), + 103: uint16(21345), + 104: uint16(21679), + 105: uint16(24320), + 106: uint16(25577), + 107: uint16(26999), + 108: uint16(20975), + 109: uint16(24936), + 110: uint16(21002), + 111: uint16(22570), + 112: uint16(21208), + 113: uint16(22350), + 114: uint16(30733), + 115: uint16(30475), + 116: uint16(24247), + 117: uint16(24951), + 118: uint16(31968), + 119: uint16(25179), + 120: uint16(25239), + 121: uint16(20130), + 122: uint16(28821), + 123: uint16(32771), + 124: uint16(25335), + 125: uint16(28900), + 126: uint16(38752), + 127: uint16(22391), + 128: uint16(33499), + 129: uint16(26607), + 130: uint16(26869), + 131: uint16(30933), + 132: uint16(39063), + 133: uint16(31185), + 134: uint16(22771), + 135: uint16(21683), + 136: uint16(21487), + 137: uint16(28212), + 138: uint16(20811), + 139: uint16(21051), + 140: uint16(23458), + 141: uint16(35838), + 142: uint16(32943), + 143: uint16(21827), + 144: uint16(22438), + 145: uint16(24691), + 146: uint16(22353), + 147: uint16(21549), + 148: uint16(31354), + 149: uint16(24656), + 150: uint16(23380), + 151: uint16(25511), + 152: uint16(25248), + 153: uint16(21475), + 154: uint16(25187), + 155: uint16(23495), + 156: uint16(26543), + 157: uint16(21741), + 158: uint16(31391), + 159: uint16(33510), + 160: uint16(37239), + 161: uint16(24211), + 162: uint16(35044), + 163: uint16(22840), + 164: uint16(22446), + 165: uint16(25358), + 166: uint16(36328), + 167: uint16(33007), + 168: uint16(22359), + 169: uint16(31607), + 170: uint16(20393), + 171: uint16(24555), + 172: uint16(23485), + 173: uint16(27454), + 174: uint16(21281), + 175: uint16(31568), + 176: uint16(29378), + 177: uint16(26694), + 178: uint16(30719), + 179: uint16(30518), + 180: uint16(26103), + 181: uint16(20917), + 182: uint16(20111), + 183: uint16(30420), + 184: uint16(23743), + 185: uint16(31397), + 186: uint16(33909), + 187: uint16(22862), + 188: uint16(39745), + 189: uint16(20608), + }, + 63: { + 0: uint16(32350), + 1: uint16(32351), + 2: uint16(32352), + 3: uint16(32353), + 4: uint16(32354), + 5: uint16(32355), + 6: uint16(32356), + 7: uint16(32357), + 8: uint16(32358), + 9: uint16(32359), + 10: uint16(32360), + 11: uint16(32361), + 12: uint16(32362), + 13: uint16(32363), + 14: uint16(32364), + 15: uint16(32365), + 16: uint16(32366), + 17: uint16(32367), + 18: uint16(32368), + 19: uint16(32369), + 20: uint16(32370), + 21: uint16(32371), + 22: uint16(32372), + 23: uint16(32373), + 24: uint16(32374), + 25: uint16(32375), + 26: uint16(32376), + 27: uint16(32377), + 28: uint16(32378), + 29: uint16(32379), + 30: uint16(32380), + 31: uint16(32381), + 32: uint16(32382), + 33: uint16(32383), + 34: uint16(32384), + 35: uint16(32385), + 36: uint16(32387), + 37: uint16(32388), + 38: uint16(32389), + 39: uint16(32390), + 40: uint16(32391), + 41: uint16(32392), + 42: uint16(32393), + 43: uint16(32394), + 44: uint16(32395), + 45: uint16(32396), + 46: uint16(32397), + 47: uint16(32398), + 48: uint16(32399), + 49: uint16(32400), + 50: uint16(32401), + 51: uint16(32402), + 52: uint16(32403), + 53: uint16(32404), + 54: uint16(32405), + 55: uint16(32406), + 56: uint16(32407), + 57: uint16(32408), + 58: uint16(32409), + 59: uint16(32410), + 60: uint16(32412), + 61: uint16(32413), + 62: uint16(32414), + 63: uint16(32430), + 64: uint16(32436), + 65: uint16(32443), + 66: uint16(32444), + 67: uint16(32470), + 68: uint16(32484), + 69: uint16(32492), + 70: uint16(32505), + 71: uint16(32522), + 72: uint16(32528), + 73: uint16(32542), + 74: uint16(32567), + 75: uint16(32569), + 76: uint16(32571), + 77: uint16(32572), + 78: uint16(32573), + 79: uint16(32574), + 80: uint16(32575), + 81: uint16(32576), + 82: uint16(32577), + 83: uint16(32579), + 84: uint16(32582), + 85: uint16(32583), + 86: uint16(32584), + 87: uint16(32585), + 88: uint16(32586), + 89: uint16(32587), + 90: uint16(32588), + 91: uint16(32589), + 92: uint16(32590), + 93: uint16(32591), + 94: uint16(32594), + 95: uint16(32595), + 96: uint16(39304), + 97: uint16(24871), + 98: uint16(28291), + 99: uint16(22372), + 100: uint16(26118), + 101: uint16(25414), + 102: uint16(22256), + 103: uint16(25324), + 104: uint16(25193), + 105: uint16(24275), + 106: uint16(38420), + 107: uint16(22403), + 108: uint16(25289), + 109: uint16(21895), + 110: uint16(34593), + 111: uint16(33098), + 112: uint16(36771), + 113: uint16(21862), + 114: uint16(33713), + 115: uint16(26469), + 116: uint16(36182), + 117: uint16(34013), + 118: uint16(23146), + 119: uint16(26639), + 120: uint16(25318), + 121: uint16(31726), + 122: uint16(38417), + 123: uint16(20848), + 124: uint16(28572), + 125: uint16(35888), + 126: uint16(25597), + 127: uint16(35272), + 128: uint16(25042), + 129: uint16(32518), + 130: uint16(28866), + 131: uint16(28389), + 132: uint16(29701), + 133: uint16(27028), + 134: uint16(29436), + 135: uint16(24266), + 136: uint16(37070), + 137: uint16(26391), + 138: uint16(28010), + 139: uint16(25438), + 140: uint16(21171), + 141: uint16(29282), + 142: uint16(32769), + 143: uint16(20332), + 144: uint16(23013), + 145: uint16(37226), + 146: uint16(28889), + 147: uint16(28061), + 148: uint16(21202), + 149: uint16(20048), + 150: uint16(38647), + 151: uint16(38253), + 152: uint16(34174), + 153: uint16(30922), + 154: uint16(32047), + 155: uint16(20769), + 156: uint16(22418), + 157: uint16(25794), + 158: uint16(32907), + 159: uint16(31867), + 160: uint16(27882), + 161: uint16(26865), + 162: uint16(26974), + 163: uint16(20919), + 164: uint16(21400), + 165: uint16(26792), + 166: uint16(29313), + 167: uint16(40654), + 168: uint16(31729), + 169: uint16(29432), + 170: uint16(31163), + 171: uint16(28435), + 172: uint16(29702), + 173: uint16(26446), + 174: uint16(37324), + 175: uint16(40100), + 176: uint16(31036), + 177: uint16(33673), + 178: uint16(33620), + 179: uint16(21519), + 180: uint16(26647), + 181: uint16(20029), + 182: uint16(21385), + 183: uint16(21169), + 184: uint16(30782), + 185: uint16(21382), + 186: uint16(21033), + 187: uint16(20616), + 188: uint16(20363), + 189: uint16(20432), + }, + 64: { + 0: uint16(32598), + 1: uint16(32601), + 2: uint16(32603), + 3: uint16(32604), + 4: uint16(32605), + 5: uint16(32606), + 6: uint16(32608), + 7: uint16(32611), + 8: uint16(32612), + 9: uint16(32613), + 10: uint16(32614), + 11: uint16(32615), + 12: uint16(32619), + 13: uint16(32620), + 14: uint16(32621), + 15: uint16(32623), + 16: uint16(32624), + 17: uint16(32627), + 18: uint16(32629), + 19: uint16(32630), + 20: uint16(32631), + 21: uint16(32632), + 22: uint16(32634), + 23: uint16(32635), + 24: uint16(32636), + 25: uint16(32637), + 26: uint16(32639), + 27: uint16(32640), + 28: uint16(32642), + 29: uint16(32643), + 30: uint16(32644), + 31: uint16(32645), + 32: uint16(32646), + 33: uint16(32647), + 34: uint16(32648), + 35: uint16(32649), + 36: uint16(32651), + 37: uint16(32653), + 38: uint16(32655), + 39: uint16(32656), + 40: uint16(32657), + 41: uint16(32658), + 42: uint16(32659), + 43: uint16(32661), + 44: uint16(32662), + 45: uint16(32663), + 46: uint16(32664), + 47: uint16(32665), + 48: uint16(32667), + 49: uint16(32668), + 50: uint16(32672), + 51: uint16(32674), + 52: uint16(32675), + 53: uint16(32677), + 54: uint16(32678), + 55: uint16(32680), + 56: uint16(32681), + 57: uint16(32682), + 58: uint16(32683), + 59: uint16(32684), + 60: uint16(32685), + 61: uint16(32686), + 62: uint16(32689), + 63: uint16(32691), + 64: uint16(32692), + 65: uint16(32693), + 66: uint16(32694), + 67: uint16(32695), + 68: uint16(32698), + 69: uint16(32699), + 70: uint16(32702), + 71: uint16(32704), + 72: uint16(32706), + 73: uint16(32707), + 74: uint16(32708), + 75: uint16(32710), + 76: uint16(32711), + 77: uint16(32712), + 78: uint16(32713), + 79: uint16(32715), + 80: uint16(32717), + 81: uint16(32719), + 82: uint16(32720), + 83: uint16(32721), + 84: uint16(32722), + 85: uint16(32723), + 86: uint16(32726), + 87: uint16(32727), + 88: uint16(32729), + 89: uint16(32730), + 90: uint16(32731), + 91: uint16(32732), + 92: uint16(32733), + 93: uint16(32734), + 94: uint16(32738), + 95: uint16(32739), + 96: uint16(30178), + 97: uint16(31435), + 98: uint16(31890), + 99: uint16(27813), + 100: uint16(38582), + 101: uint16(21147), + 102: uint16(29827), + 103: uint16(21737), + 104: uint16(20457), + 105: uint16(32852), + 106: uint16(33714), + 107: uint16(36830), + 108: uint16(38256), + 109: uint16(24265), + 110: uint16(24604), + 111: uint16(28063), + 112: uint16(24088), + 113: uint16(25947), + 114: uint16(33080), + 115: uint16(38142), + 116: uint16(24651), + 117: uint16(28860), + 118: uint16(32451), + 119: uint16(31918), + 120: uint16(20937), + 121: uint16(26753), + 122: uint16(31921), + 123: uint16(33391), + 124: uint16(20004), + 125: uint16(36742), + 126: uint16(37327), + 127: uint16(26238), + 128: uint16(20142), + 129: uint16(35845), + 130: uint16(25769), + 131: uint16(32842), + 132: uint16(20698), + 133: uint16(30103), + 134: uint16(29134), + 135: uint16(23525), + 136: uint16(36797), + 137: uint16(28518), + 138: uint16(20102), + 139: uint16(25730), + 140: uint16(38243), + 141: uint16(24278), + 142: uint16(26009), + 143: uint16(21015), + 144: uint16(35010), + 145: uint16(28872), + 146: uint16(21155), + 147: uint16(29454), + 148: uint16(29747), + 149: uint16(26519), + 150: uint16(30967), + 151: uint16(38678), + 152: uint16(20020), + 153: uint16(37051), + 154: uint16(40158), + 155: uint16(28107), + 156: uint16(20955), + 157: uint16(36161), + 158: uint16(21533), + 159: uint16(25294), + 160: uint16(29618), + 161: uint16(33777), + 162: uint16(38646), + 163: uint16(40836), + 164: uint16(38083), + 165: uint16(20278), + 166: uint16(32666), + 167: uint16(20940), + 168: uint16(28789), + 169: uint16(38517), + 170: uint16(23725), + 171: uint16(39046), + 172: uint16(21478), + 173: uint16(20196), + 174: uint16(28316), + 175: uint16(29705), + 176: uint16(27060), + 177: uint16(30827), + 178: uint16(39311), + 179: uint16(30041), + 180: uint16(21016), + 181: uint16(30244), + 182: uint16(27969), + 183: uint16(26611), + 184: uint16(20845), + 185: uint16(40857), + 186: uint16(32843), + 187: uint16(21657), + 188: uint16(31548), + 189: uint16(31423), + }, + 65: { + 0: uint16(32740), + 1: uint16(32743), + 2: uint16(32744), + 3: uint16(32746), + 4: uint16(32747), + 5: uint16(32748), + 6: uint16(32749), + 7: uint16(32751), + 8: uint16(32754), + 9: uint16(32756), + 10: uint16(32757), + 11: uint16(32758), + 12: uint16(32759), + 13: uint16(32760), + 14: uint16(32761), + 15: uint16(32762), + 16: uint16(32765), + 17: uint16(32766), + 18: uint16(32767), + 19: uint16(32770), + 20: uint16(32775), + 21: uint16(32776), + 22: uint16(32777), + 23: uint16(32778), + 24: uint16(32782), + 25: uint16(32783), + 26: uint16(32785), + 27: uint16(32787), + 28: uint16(32794), + 29: uint16(32795), + 30: uint16(32797), + 31: uint16(32798), + 32: uint16(32799), + 33: uint16(32801), + 34: uint16(32803), + 35: uint16(32804), + 36: uint16(32811), + 37: uint16(32812), + 38: uint16(32813), + 39: uint16(32814), + 40: uint16(32815), + 41: uint16(32816), + 42: uint16(32818), + 43: uint16(32820), + 44: uint16(32825), + 45: uint16(32826), + 46: uint16(32828), + 47: uint16(32830), + 48: uint16(32832), + 49: uint16(32833), + 50: uint16(32836), + 51: uint16(32837), + 52: uint16(32839), + 53: uint16(32840), + 54: uint16(32841), + 55: uint16(32846), + 56: uint16(32847), + 57: uint16(32848), + 58: uint16(32849), + 59: uint16(32851), + 60: uint16(32853), + 61: uint16(32854), + 62: uint16(32855), + 63: uint16(32857), + 64: uint16(32859), + 65: uint16(32860), + 66: uint16(32861), + 67: uint16(32862), + 68: uint16(32863), + 69: uint16(32864), + 70: uint16(32865), + 71: uint16(32866), + 72: uint16(32867), + 73: uint16(32868), + 74: uint16(32869), + 75: uint16(32870), + 76: uint16(32871), + 77: uint16(32872), + 78: uint16(32875), + 79: uint16(32876), + 80: uint16(32877), + 81: uint16(32878), + 82: uint16(32879), + 83: uint16(32880), + 84: uint16(32882), + 85: uint16(32883), + 86: uint16(32884), + 87: uint16(32885), + 88: uint16(32886), + 89: uint16(32887), + 90: uint16(32888), + 91: uint16(32889), + 92: uint16(32890), + 93: uint16(32891), + 94: uint16(32892), + 95: uint16(32893), + 96: uint16(38534), + 97: uint16(22404), + 98: uint16(25314), + 99: uint16(38471), + 100: uint16(27004), + 101: uint16(23044), + 102: uint16(25602), + 103: uint16(31699), + 104: uint16(28431), + 105: uint16(38475), + 106: uint16(33446), + 107: uint16(21346), + 108: uint16(39045), + 109: uint16(24208), + 110: uint16(28809), + 111: uint16(25523), + 112: uint16(21348), + 113: uint16(34383), + 114: uint16(40065), + 115: uint16(40595), + 116: uint16(30860), + 117: uint16(38706), + 118: uint16(36335), + 119: uint16(36162), + 120: uint16(40575), + 121: uint16(28510), + 122: uint16(31108), + 123: uint16(24405), + 124: uint16(38470), + 125: uint16(25134), + 126: uint16(39540), + 127: uint16(21525), + 128: uint16(38109), + 129: uint16(20387), + 130: uint16(26053), + 131: uint16(23653), + 132: uint16(23649), + 133: uint16(32533), + 134: uint16(34385), + 135: uint16(27695), + 136: uint16(24459), + 137: uint16(29575), + 138: uint16(28388), + 139: uint16(32511), + 140: uint16(23782), + 141: uint16(25371), + 142: uint16(23402), + 143: uint16(28390), + 144: uint16(21365), + 145: uint16(20081), + 146: uint16(25504), + 147: uint16(30053), + 148: uint16(25249), + 149: uint16(36718), + 150: uint16(20262), + 151: uint16(20177), + 152: uint16(27814), + 153: uint16(32438), + 154: uint16(35770), + 155: uint16(33821), + 156: uint16(34746), + 157: uint16(32599), + 158: uint16(36923), + 159: uint16(38179), + 160: uint16(31657), + 161: uint16(39585), + 162: uint16(35064), + 163: uint16(33853), + 164: uint16(27931), + 165: uint16(39558), + 166: uint16(32476), + 167: uint16(22920), + 168: uint16(40635), + 169: uint16(29595), + 170: uint16(30721), + 171: uint16(34434), + 172: uint16(39532), + 173: uint16(39554), + 174: uint16(22043), + 175: uint16(21527), + 176: uint16(22475), + 177: uint16(20080), + 178: uint16(40614), + 179: uint16(21334), + 180: uint16(36808), + 181: uint16(33033), + 182: uint16(30610), + 183: uint16(39314), + 184: uint16(34542), + 185: uint16(28385), + 186: uint16(34067), + 187: uint16(26364), + 188: uint16(24930), + 189: uint16(28459), + }, + 66: { + 0: uint16(32894), + 1: uint16(32897), + 2: uint16(32898), + 3: uint16(32901), + 4: uint16(32904), + 5: uint16(32906), + 6: uint16(32909), + 7: uint16(32910), + 8: uint16(32911), + 9: uint16(32912), + 10: uint16(32913), + 11: uint16(32914), + 12: uint16(32916), + 13: uint16(32917), + 14: uint16(32919), + 15: uint16(32921), + 16: uint16(32926), + 17: uint16(32931), + 18: uint16(32934), + 19: uint16(32935), + 20: uint16(32936), + 21: uint16(32940), + 22: uint16(32944), + 23: uint16(32947), + 24: uint16(32949), + 25: uint16(32950), + 26: uint16(32952), + 27: uint16(32953), + 28: uint16(32955), + 29: uint16(32965), + 30: uint16(32967), + 31: uint16(32968), + 32: uint16(32969), + 33: uint16(32970), + 34: uint16(32971), + 35: uint16(32975), + 36: uint16(32976), + 37: uint16(32977), + 38: uint16(32978), + 39: uint16(32979), + 40: uint16(32980), + 41: uint16(32981), + 42: uint16(32984), + 43: uint16(32991), + 44: uint16(32992), + 45: uint16(32994), + 46: uint16(32995), + 47: uint16(32998), + 48: uint16(33006), + 49: uint16(33013), + 50: uint16(33015), + 51: uint16(33017), + 52: uint16(33019), + 53: uint16(33022), + 54: uint16(33023), + 55: uint16(33024), + 56: uint16(33025), + 57: uint16(33027), + 58: uint16(33028), + 59: uint16(33029), + 60: uint16(33031), + 61: uint16(33032), + 62: uint16(33035), + 63: uint16(33036), + 64: uint16(33045), + 65: uint16(33047), + 66: uint16(33049), + 67: uint16(33051), + 68: uint16(33052), + 69: uint16(33053), + 70: uint16(33055), + 71: uint16(33056), + 72: uint16(33057), + 73: uint16(33058), + 74: uint16(33059), + 75: uint16(33060), + 76: uint16(33061), + 77: uint16(33062), + 78: uint16(33063), + 79: uint16(33064), + 80: uint16(33065), + 81: uint16(33066), + 82: uint16(33067), + 83: uint16(33069), + 84: uint16(33070), + 85: uint16(33072), + 86: uint16(33075), + 87: uint16(33076), + 88: uint16(33077), + 89: uint16(33079), + 90: uint16(33081), + 91: uint16(33082), + 92: uint16(33083), + 93: uint16(33084), + 94: uint16(33085), + 95: uint16(33087), + 96: uint16(35881), + 97: uint16(33426), + 98: uint16(33579), + 99: uint16(30450), + 100: uint16(27667), + 101: uint16(24537), + 102: uint16(33725), + 103: uint16(29483), + 104: uint16(33541), + 105: uint16(38170), + 106: uint16(27611), + 107: uint16(30683), + 108: uint16(38086), + 109: uint16(21359), + 110: uint16(33538), + 111: uint16(20882), + 112: uint16(24125), + 113: uint16(35980), + 114: uint16(36152), + 115: uint16(20040), + 116: uint16(29611), + 117: uint16(26522), + 118: uint16(26757), + 119: uint16(37238), + 120: uint16(38665), + 121: uint16(29028), + 122: uint16(27809), + 123: uint16(30473), + 124: uint16(23186), + 125: uint16(38209), + 126: uint16(27599), + 127: uint16(32654), + 128: uint16(26151), + 129: uint16(23504), + 130: uint16(22969), + 131: uint16(23194), + 132: uint16(38376), + 133: uint16(38391), + 134: uint16(20204), + 135: uint16(33804), + 136: uint16(33945), + 137: uint16(27308), + 138: uint16(30431), + 139: uint16(38192), + 140: uint16(29467), + 141: uint16(26790), + 142: uint16(23391), + 143: uint16(30511), + 144: uint16(37274), + 145: uint16(38753), + 146: uint16(31964), + 147: uint16(36855), + 148: uint16(35868), + 149: uint16(24357), + 150: uint16(31859), + 151: uint16(31192), + 152: uint16(35269), + 153: uint16(27852), + 154: uint16(34588), + 155: uint16(23494), + 156: uint16(24130), + 157: uint16(26825), + 158: uint16(30496), + 159: uint16(32501), + 160: uint16(20885), + 161: uint16(20813), + 162: uint16(21193), + 163: uint16(23081), + 164: uint16(32517), + 165: uint16(38754), + 166: uint16(33495), + 167: uint16(25551), + 168: uint16(30596), + 169: uint16(34256), + 170: uint16(31186), + 171: uint16(28218), + 172: uint16(24217), + 173: uint16(22937), + 174: uint16(34065), + 175: uint16(28781), + 176: uint16(27665), + 177: uint16(25279), + 178: uint16(30399), + 179: uint16(25935), + 180: uint16(24751), + 181: uint16(38397), + 182: uint16(26126), + 183: uint16(34719), + 184: uint16(40483), + 185: uint16(38125), + 186: uint16(21517), + 187: uint16(21629), + 188: uint16(35884), + 189: uint16(25720), + }, + 67: { + 0: uint16(33088), + 1: uint16(33089), + 2: uint16(33090), + 3: uint16(33091), + 4: uint16(33092), + 5: uint16(33093), + 6: uint16(33095), + 7: uint16(33097), + 8: uint16(33101), + 9: uint16(33102), + 10: uint16(33103), + 11: uint16(33106), + 12: uint16(33110), + 13: uint16(33111), + 14: uint16(33112), + 15: uint16(33115), + 16: uint16(33116), + 17: uint16(33117), + 18: uint16(33118), + 19: uint16(33119), + 20: uint16(33121), + 21: uint16(33122), + 22: uint16(33123), + 23: uint16(33124), + 24: uint16(33126), + 25: uint16(33128), + 26: uint16(33130), + 27: uint16(33131), + 28: uint16(33132), + 29: uint16(33135), + 30: uint16(33138), + 31: uint16(33139), + 32: uint16(33141), + 33: uint16(33142), + 34: uint16(33143), + 35: uint16(33144), + 36: uint16(33153), + 37: uint16(33155), + 38: uint16(33156), + 39: uint16(33157), + 40: uint16(33158), + 41: uint16(33159), + 42: uint16(33161), + 43: uint16(33163), + 44: uint16(33164), + 45: uint16(33165), + 46: uint16(33166), + 47: uint16(33168), + 48: uint16(33170), + 49: uint16(33171), + 50: uint16(33172), + 51: uint16(33173), + 52: uint16(33174), + 53: uint16(33175), + 54: uint16(33177), + 55: uint16(33178), + 56: uint16(33182), + 57: uint16(33183), + 58: uint16(33184), + 59: uint16(33185), + 60: uint16(33186), + 61: uint16(33188), + 62: uint16(33189), + 63: uint16(33191), + 64: uint16(33193), + 65: uint16(33195), + 66: uint16(33196), + 67: uint16(33197), + 68: uint16(33198), + 69: uint16(33199), + 70: uint16(33200), + 71: uint16(33201), + 72: uint16(33202), + 73: uint16(33204), + 74: uint16(33205), + 75: uint16(33206), + 76: uint16(33207), + 77: uint16(33208), + 78: uint16(33209), + 79: uint16(33212), + 80: uint16(33213), + 81: uint16(33214), + 82: uint16(33215), + 83: uint16(33220), + 84: uint16(33221), + 85: uint16(33223), + 86: uint16(33224), + 87: uint16(33225), + 88: uint16(33227), + 89: uint16(33229), + 90: uint16(33230), + 91: uint16(33231), + 92: uint16(33232), + 93: uint16(33233), + 94: uint16(33234), + 95: uint16(33235), + 96: uint16(25721), + 97: uint16(34321), + 98: uint16(27169), + 99: uint16(33180), + 100: uint16(30952), + 101: uint16(25705), + 102: uint16(39764), + 103: uint16(25273), + 104: uint16(26411), + 105: uint16(33707), + 106: uint16(22696), + 107: uint16(40664), + 108: uint16(27819), + 109: uint16(28448), + 110: uint16(23518), + 111: uint16(38476), + 112: uint16(35851), + 113: uint16(29279), + 114: uint16(26576), + 115: uint16(25287), + 116: uint16(29281), + 117: uint16(20137), + 118: uint16(22982), + 119: uint16(27597), + 120: uint16(22675), + 121: uint16(26286), + 122: uint16(24149), + 123: uint16(21215), + 124: uint16(24917), + 125: uint16(26408), + 126: uint16(30446), + 127: uint16(30566), + 128: uint16(29287), + 129: uint16(31302), + 130: uint16(25343), + 131: uint16(21738), + 132: uint16(21584), + 133: uint16(38048), + 134: uint16(37027), + 135: uint16(23068), + 136: uint16(32435), + 137: uint16(27670), + 138: uint16(20035), + 139: uint16(22902), + 140: uint16(32784), + 141: uint16(22856), + 142: uint16(21335), + 143: uint16(30007), + 144: uint16(38590), + 145: uint16(22218), + 146: uint16(25376), + 147: uint16(33041), + 148: uint16(24700), + 149: uint16(38393), + 150: uint16(28118), + 151: uint16(21602), + 152: uint16(39297), + 153: uint16(20869), + 154: uint16(23273), + 155: uint16(33021), + 156: uint16(22958), + 157: uint16(38675), + 158: uint16(20522), + 159: uint16(27877), + 160: uint16(23612), + 161: uint16(25311), + 162: uint16(20320), + 163: uint16(21311), + 164: uint16(33147), + 165: uint16(36870), + 166: uint16(28346), + 167: uint16(34091), + 168: uint16(25288), + 169: uint16(24180), + 170: uint16(30910), + 171: uint16(25781), + 172: uint16(25467), + 173: uint16(24565), + 174: uint16(23064), + 175: uint16(37247), + 176: uint16(40479), + 177: uint16(23615), + 178: uint16(25423), + 179: uint16(32834), + 180: uint16(23421), + 181: uint16(21870), + 182: uint16(38218), + 183: uint16(38221), + 184: uint16(28037), + 185: uint16(24744), + 186: uint16(26592), + 187: uint16(29406), + 188: uint16(20957), + 189: uint16(23425), + }, + 68: { + 0: uint16(33236), + 1: uint16(33237), + 2: uint16(33238), + 3: uint16(33239), + 4: uint16(33240), + 5: uint16(33241), + 6: uint16(33242), + 7: uint16(33243), + 8: uint16(33244), + 9: uint16(33245), + 10: uint16(33246), + 11: uint16(33247), + 12: uint16(33248), + 13: uint16(33249), + 14: uint16(33250), + 15: uint16(33252), + 16: uint16(33253), + 17: uint16(33254), + 18: uint16(33256), + 19: uint16(33257), + 20: uint16(33259), + 21: uint16(33262), + 22: uint16(33263), + 23: uint16(33264), + 24: uint16(33265), + 25: uint16(33266), + 26: uint16(33269), + 27: uint16(33270), + 28: uint16(33271), + 29: uint16(33272), + 30: uint16(33273), + 31: uint16(33274), + 32: uint16(33277), + 33: uint16(33279), + 34: uint16(33283), + 35: uint16(33287), + 36: uint16(33288), + 37: uint16(33289), + 38: uint16(33290), + 39: uint16(33291), + 40: uint16(33294), + 41: uint16(33295), + 42: uint16(33297), + 43: uint16(33299), + 44: uint16(33301), + 45: uint16(33302), + 46: uint16(33303), + 47: uint16(33304), + 48: uint16(33305), + 49: uint16(33306), + 50: uint16(33309), + 51: uint16(33312), + 52: uint16(33316), + 53: uint16(33317), + 54: uint16(33318), + 55: uint16(33319), + 56: uint16(33321), + 57: uint16(33326), + 58: uint16(33330), + 59: uint16(33338), + 60: uint16(33340), + 61: uint16(33341), + 62: uint16(33343), + 63: uint16(33344), + 64: uint16(33345), + 65: uint16(33346), + 66: uint16(33347), + 67: uint16(33349), + 68: uint16(33350), + 69: uint16(33352), + 70: uint16(33354), + 71: uint16(33356), + 72: uint16(33357), + 73: uint16(33358), + 74: uint16(33360), + 75: uint16(33361), + 76: uint16(33362), + 77: uint16(33363), + 78: uint16(33364), + 79: uint16(33365), + 80: uint16(33366), + 81: uint16(33367), + 82: uint16(33369), + 83: uint16(33371), + 84: uint16(33372), + 85: uint16(33373), + 86: uint16(33374), + 87: uint16(33376), + 88: uint16(33377), + 89: uint16(33378), + 90: uint16(33379), + 91: uint16(33380), + 92: uint16(33381), + 93: uint16(33382), + 94: uint16(33383), + 95: uint16(33385), + 96: uint16(25319), + 97: uint16(27870), + 98: uint16(29275), + 99: uint16(25197), + 100: uint16(38062), + 101: uint16(32445), + 102: uint16(33043), + 103: uint16(27987), + 104: uint16(20892), + 105: uint16(24324), + 106: uint16(22900), + 107: uint16(21162), + 108: uint16(24594), + 109: uint16(22899), + 110: uint16(26262), + 111: uint16(34384), + 112: uint16(30111), + 113: uint16(25386), + 114: uint16(25062), + 115: uint16(31983), + 116: uint16(35834), + 117: uint16(21734), + 118: uint16(27431), + 119: uint16(40485), + 120: uint16(27572), + 121: uint16(34261), + 122: uint16(21589), + 123: uint16(20598), + 124: uint16(27812), + 125: uint16(21866), + 126: uint16(36276), + 127: uint16(29228), + 128: uint16(24085), + 129: uint16(24597), + 130: uint16(29750), + 131: uint16(25293), + 132: uint16(25490), + 133: uint16(29260), + 134: uint16(24472), + 135: uint16(28227), + 136: uint16(27966), + 137: uint16(25856), + 138: uint16(28504), + 139: uint16(30424), + 140: uint16(30928), + 141: uint16(30460), + 142: uint16(30036), + 143: uint16(21028), + 144: uint16(21467), + 145: uint16(20051), + 146: uint16(24222), + 147: uint16(26049), + 148: uint16(32810), + 149: uint16(32982), + 150: uint16(25243), + 151: uint16(21638), + 152: uint16(21032), + 153: uint16(28846), + 154: uint16(34957), + 155: uint16(36305), + 156: uint16(27873), + 157: uint16(21624), + 158: uint16(32986), + 159: uint16(22521), + 160: uint16(35060), + 161: uint16(36180), + 162: uint16(38506), + 163: uint16(37197), + 164: uint16(20329), + 165: uint16(27803), + 166: uint16(21943), + 167: uint16(30406), + 168: uint16(30768), + 169: uint16(25256), + 170: uint16(28921), + 171: uint16(28558), + 172: uint16(24429), + 173: uint16(34028), + 174: uint16(26842), + 175: uint16(30844), + 176: uint16(31735), + 177: uint16(33192), + 178: uint16(26379), + 179: uint16(40527), + 180: uint16(25447), + 181: uint16(30896), + 182: uint16(22383), + 183: uint16(30738), + 184: uint16(38713), + 185: uint16(25209), + 186: uint16(25259), + 187: uint16(21128), + 188: uint16(29749), + 189: uint16(27607), + }, + 69: { + 0: uint16(33386), + 1: uint16(33387), + 2: uint16(33388), + 3: uint16(33389), + 4: uint16(33393), + 5: uint16(33397), + 6: uint16(33398), + 7: uint16(33399), + 8: uint16(33400), + 9: uint16(33403), + 10: uint16(33404), + 11: uint16(33408), + 12: uint16(33409), + 13: uint16(33411), + 14: uint16(33413), + 15: uint16(33414), + 16: uint16(33415), + 17: uint16(33417), + 18: uint16(33420), + 19: uint16(33424), + 20: uint16(33427), + 21: uint16(33428), + 22: uint16(33429), + 23: uint16(33430), + 24: uint16(33434), + 25: uint16(33435), + 26: uint16(33438), + 27: uint16(33440), + 28: uint16(33442), + 29: uint16(33443), + 30: uint16(33447), + 31: uint16(33458), + 32: uint16(33461), + 33: uint16(33462), + 34: uint16(33466), + 35: uint16(33467), + 36: uint16(33468), + 37: uint16(33471), + 38: uint16(33472), + 39: uint16(33474), + 40: uint16(33475), + 41: uint16(33477), + 42: uint16(33478), + 43: uint16(33481), + 44: uint16(33488), + 45: uint16(33494), + 46: uint16(33497), + 47: uint16(33498), + 48: uint16(33501), + 49: uint16(33506), + 50: uint16(33511), + 51: uint16(33512), + 52: uint16(33513), + 53: uint16(33514), + 54: uint16(33516), + 55: uint16(33517), + 56: uint16(33518), + 57: uint16(33520), + 58: uint16(33522), + 59: uint16(33523), + 60: uint16(33525), + 61: uint16(33526), + 62: uint16(33528), + 63: uint16(33530), + 64: uint16(33532), + 65: uint16(33533), + 66: uint16(33534), + 67: uint16(33535), + 68: uint16(33536), + 69: uint16(33546), + 70: uint16(33547), + 71: uint16(33549), + 72: uint16(33552), + 73: uint16(33554), + 74: uint16(33555), + 75: uint16(33558), + 76: uint16(33560), + 77: uint16(33561), + 78: uint16(33565), + 79: uint16(33566), + 80: uint16(33567), + 81: uint16(33568), + 82: uint16(33569), + 83: uint16(33570), + 84: uint16(33571), + 85: uint16(33572), + 86: uint16(33573), + 87: uint16(33574), + 88: uint16(33577), + 89: uint16(33578), + 90: uint16(33582), + 91: uint16(33584), + 92: uint16(33586), + 93: uint16(33591), + 94: uint16(33595), + 95: uint16(33597), + 96: uint16(21860), + 97: uint16(33086), + 98: uint16(30130), + 99: uint16(30382), + 100: uint16(21305), + 101: uint16(30174), + 102: uint16(20731), + 103: uint16(23617), + 104: uint16(35692), + 105: uint16(31687), + 106: uint16(20559), + 107: uint16(29255), + 108: uint16(39575), + 109: uint16(39128), + 110: uint16(28418), + 111: uint16(29922), + 112: uint16(31080), + 113: uint16(25735), + 114: uint16(30629), + 115: uint16(25340), + 116: uint16(39057), + 117: uint16(36139), + 118: uint16(21697), + 119: uint16(32856), + 120: uint16(20050), + 121: uint16(22378), + 122: uint16(33529), + 123: uint16(33805), + 124: uint16(24179), + 125: uint16(20973), + 126: uint16(29942), + 127: uint16(35780), + 128: uint16(23631), + 129: uint16(22369), + 130: uint16(27900), + 131: uint16(39047), + 132: uint16(23110), + 133: uint16(30772), + 134: uint16(39748), + 135: uint16(36843), + 136: uint16(31893), + 137: uint16(21078), + 138: uint16(25169), + 139: uint16(38138), + 140: uint16(20166), + 141: uint16(33670), + 142: uint16(33889), + 143: uint16(33769), + 144: uint16(33970), + 145: uint16(22484), + 146: uint16(26420), + 147: uint16(22275), + 148: uint16(26222), + 149: uint16(28006), + 150: uint16(35889), + 151: uint16(26333), + 152: uint16(28689), + 153: uint16(26399), + 154: uint16(27450), + 155: uint16(26646), + 156: uint16(25114), + 157: uint16(22971), + 158: uint16(19971), + 159: uint16(20932), + 160: uint16(28422), + 161: uint16(26578), + 162: uint16(27791), + 163: uint16(20854), + 164: uint16(26827), + 165: uint16(22855), + 166: uint16(27495), + 167: uint16(30054), + 168: uint16(23822), + 169: uint16(33040), + 170: uint16(40784), + 171: uint16(26071), + 172: uint16(31048), + 173: uint16(31041), + 174: uint16(39569), + 175: uint16(36215), + 176: uint16(23682), + 177: uint16(20062), + 178: uint16(20225), + 179: uint16(21551), + 180: uint16(22865), + 181: uint16(30732), + 182: uint16(22120), + 183: uint16(27668), + 184: uint16(36804), + 185: uint16(24323), + 186: uint16(27773), + 187: uint16(27875), + 188: uint16(35755), + 189: uint16(25488), + }, + 70: { + 0: uint16(33598), + 1: uint16(33599), + 2: uint16(33601), + 3: uint16(33602), + 4: uint16(33604), + 5: uint16(33605), + 6: uint16(33608), + 7: uint16(33610), + 8: uint16(33611), + 9: uint16(33612), + 10: uint16(33613), + 11: uint16(33614), + 12: uint16(33619), + 13: uint16(33621), + 14: uint16(33622), + 15: uint16(33623), + 16: uint16(33624), + 17: uint16(33625), + 18: uint16(33629), + 19: uint16(33634), + 20: uint16(33648), + 21: uint16(33649), + 22: uint16(33650), + 23: uint16(33651), + 24: uint16(33652), + 25: uint16(33653), + 26: uint16(33654), + 27: uint16(33657), + 28: uint16(33658), + 29: uint16(33662), + 30: uint16(33663), + 31: uint16(33664), + 32: uint16(33665), + 33: uint16(33666), + 34: uint16(33667), + 35: uint16(33668), + 36: uint16(33671), + 37: uint16(33672), + 38: uint16(33674), + 39: uint16(33675), + 40: uint16(33676), + 41: uint16(33677), + 42: uint16(33679), + 43: uint16(33680), + 44: uint16(33681), + 45: uint16(33684), + 46: uint16(33685), + 47: uint16(33686), + 48: uint16(33687), + 49: uint16(33689), + 50: uint16(33690), + 51: uint16(33693), + 52: uint16(33695), + 53: uint16(33697), + 54: uint16(33698), + 55: uint16(33699), + 56: uint16(33700), + 57: uint16(33701), + 58: uint16(33702), + 59: uint16(33703), + 60: uint16(33708), + 61: uint16(33709), + 62: uint16(33710), + 63: uint16(33711), + 64: uint16(33717), + 65: uint16(33723), + 66: uint16(33726), + 67: uint16(33727), + 68: uint16(33730), + 69: uint16(33731), + 70: uint16(33732), + 71: uint16(33734), + 72: uint16(33736), + 73: uint16(33737), + 74: uint16(33739), + 75: uint16(33741), + 76: uint16(33742), + 77: uint16(33744), + 78: uint16(33745), + 79: uint16(33746), + 80: uint16(33747), + 81: uint16(33749), + 82: uint16(33751), + 83: uint16(33753), + 84: uint16(33754), + 85: uint16(33755), + 86: uint16(33758), + 87: uint16(33762), + 88: uint16(33763), + 89: uint16(33764), + 90: uint16(33766), + 91: uint16(33767), + 92: uint16(33768), + 93: uint16(33771), + 94: uint16(33772), + 95: uint16(33773), + 96: uint16(24688), + 97: uint16(27965), + 98: uint16(29301), + 99: uint16(25190), + 100: uint16(38030), + 101: uint16(38085), + 102: uint16(21315), + 103: uint16(36801), + 104: uint16(31614), + 105: uint16(20191), + 106: uint16(35878), + 107: uint16(20094), + 108: uint16(40660), + 109: uint16(38065), + 110: uint16(38067), + 111: uint16(21069), + 112: uint16(28508), + 113: uint16(36963), + 114: uint16(27973), + 115: uint16(35892), + 116: uint16(22545), + 117: uint16(23884), + 118: uint16(27424), + 119: uint16(27465), + 120: uint16(26538), + 121: uint16(21595), + 122: uint16(33108), + 123: uint16(32652), + 124: uint16(22681), + 125: uint16(34103), + 126: uint16(24378), + 127: uint16(25250), + 128: uint16(27207), + 129: uint16(38201), + 130: uint16(25970), + 131: uint16(24708), + 132: uint16(26725), + 133: uint16(30631), + 134: uint16(20052), + 135: uint16(20392), + 136: uint16(24039), + 137: uint16(38808), + 138: uint16(25772), + 139: uint16(32728), + 140: uint16(23789), + 141: uint16(20431), + 142: uint16(31373), + 143: uint16(20999), + 144: uint16(33540), + 145: uint16(19988), + 146: uint16(24623), + 147: uint16(31363), + 148: uint16(38054), + 149: uint16(20405), + 150: uint16(20146), + 151: uint16(31206), + 152: uint16(29748), + 153: uint16(21220), + 154: uint16(33465), + 155: uint16(25810), + 156: uint16(31165), + 157: uint16(23517), + 158: uint16(27777), + 159: uint16(38738), + 160: uint16(36731), + 161: uint16(27682), + 162: uint16(20542), + 163: uint16(21375), + 164: uint16(28165), + 165: uint16(25806), + 166: uint16(26228), + 167: uint16(27696), + 168: uint16(24773), + 169: uint16(39031), + 170: uint16(35831), + 171: uint16(24198), + 172: uint16(29756), + 173: uint16(31351), + 174: uint16(31179), + 175: uint16(19992), + 176: uint16(37041), + 177: uint16(29699), + 178: uint16(27714), + 179: uint16(22234), + 180: uint16(37195), + 181: uint16(27845), + 182: uint16(36235), + 183: uint16(21306), + 184: uint16(34502), + 185: uint16(26354), + 186: uint16(36527), + 187: uint16(23624), + 188: uint16(39537), + 189: uint16(28192), + }, + 71: { + 0: uint16(33774), + 1: uint16(33775), + 2: uint16(33779), + 3: uint16(33780), + 4: uint16(33781), + 5: uint16(33782), + 6: uint16(33783), + 7: uint16(33786), + 8: uint16(33787), + 9: uint16(33788), + 10: uint16(33790), + 11: uint16(33791), + 12: uint16(33792), + 13: uint16(33794), + 14: uint16(33797), + 15: uint16(33799), + 16: uint16(33800), + 17: uint16(33801), + 18: uint16(33802), + 19: uint16(33808), + 20: uint16(33810), + 21: uint16(33811), + 22: uint16(33812), + 23: uint16(33813), + 24: uint16(33814), + 25: uint16(33815), + 26: uint16(33817), + 27: uint16(33818), + 28: uint16(33819), + 29: uint16(33822), + 30: uint16(33823), + 31: uint16(33824), + 32: uint16(33825), + 33: uint16(33826), + 34: uint16(33827), + 35: uint16(33833), + 36: uint16(33834), + 37: uint16(33835), + 38: uint16(33836), + 39: uint16(33837), + 40: uint16(33838), + 41: uint16(33839), + 42: uint16(33840), + 43: uint16(33842), + 44: uint16(33843), + 45: uint16(33844), + 46: uint16(33845), + 47: uint16(33846), + 48: uint16(33847), + 49: uint16(33849), + 50: uint16(33850), + 51: uint16(33851), + 52: uint16(33854), + 53: uint16(33855), + 54: uint16(33856), + 55: uint16(33857), + 56: uint16(33858), + 57: uint16(33859), + 58: uint16(33860), + 59: uint16(33861), + 60: uint16(33863), + 61: uint16(33864), + 62: uint16(33865), + 63: uint16(33866), + 64: uint16(33867), + 65: uint16(33868), + 66: uint16(33869), + 67: uint16(33870), + 68: uint16(33871), + 69: uint16(33872), + 70: uint16(33874), + 71: uint16(33875), + 72: uint16(33876), + 73: uint16(33877), + 74: uint16(33878), + 75: uint16(33880), + 76: uint16(33885), + 77: uint16(33886), + 78: uint16(33887), + 79: uint16(33888), + 80: uint16(33890), + 81: uint16(33892), + 82: uint16(33893), + 83: uint16(33894), + 84: uint16(33895), + 85: uint16(33896), + 86: uint16(33898), + 87: uint16(33902), + 88: uint16(33903), + 89: uint16(33904), + 90: uint16(33906), + 91: uint16(33908), + 92: uint16(33911), + 93: uint16(33913), + 94: uint16(33915), + 95: uint16(33916), + 96: uint16(21462), + 97: uint16(23094), + 98: uint16(40843), + 99: uint16(36259), + 100: uint16(21435), + 101: uint16(22280), + 102: uint16(39079), + 103: uint16(26435), + 104: uint16(37275), + 105: uint16(27849), + 106: uint16(20840), + 107: uint16(30154), + 108: uint16(25331), + 109: uint16(29356), + 110: uint16(21048), + 111: uint16(21149), + 112: uint16(32570), + 113: uint16(28820), + 114: uint16(30264), + 115: uint16(21364), + 116: uint16(40522), + 117: uint16(27063), + 118: uint16(30830), + 119: uint16(38592), + 120: uint16(35033), + 121: uint16(32676), + 122: uint16(28982), + 123: uint16(29123), + 124: uint16(20873), + 125: uint16(26579), + 126: uint16(29924), + 127: uint16(22756), + 128: uint16(25880), + 129: uint16(22199), + 130: uint16(35753), + 131: uint16(39286), + 132: uint16(25200), + 133: uint16(32469), + 134: uint16(24825), + 135: uint16(28909), + 136: uint16(22764), + 137: uint16(20161), + 138: uint16(20154), + 139: uint16(24525), + 140: uint16(38887), + 141: uint16(20219), + 142: uint16(35748), + 143: uint16(20995), + 144: uint16(22922), + 145: uint16(32427), + 146: uint16(25172), + 147: uint16(20173), + 148: uint16(26085), + 149: uint16(25102), + 150: uint16(33592), + 151: uint16(33993), + 152: uint16(33635), + 153: uint16(34701), + 154: uint16(29076), + 155: uint16(28342), + 156: uint16(23481), + 157: uint16(32466), + 158: uint16(20887), + 159: uint16(25545), + 160: uint16(26580), + 161: uint16(32905), + 162: uint16(33593), + 163: uint16(34837), + 164: uint16(20754), + 165: uint16(23418), + 166: uint16(22914), + 167: uint16(36785), + 168: uint16(20083), + 169: uint16(27741), + 170: uint16(20837), + 171: uint16(35109), + 172: uint16(36719), + 173: uint16(38446), + 174: uint16(34122), + 175: uint16(29790), + 176: uint16(38160), + 177: uint16(38384), + 178: uint16(28070), + 179: uint16(33509), + 180: uint16(24369), + 181: uint16(25746), + 182: uint16(27922), + 183: uint16(33832), + 184: uint16(33134), + 185: uint16(40131), + 186: uint16(22622), + 187: uint16(36187), + 188: uint16(19977), + 189: uint16(21441), + }, + 72: { + 0: uint16(33917), + 1: uint16(33918), + 2: uint16(33919), + 3: uint16(33920), + 4: uint16(33921), + 5: uint16(33923), + 6: uint16(33924), + 7: uint16(33925), + 8: uint16(33926), + 9: uint16(33930), + 10: uint16(33933), + 11: uint16(33935), + 12: uint16(33936), + 13: uint16(33937), + 14: uint16(33938), + 15: uint16(33939), + 16: uint16(33940), + 17: uint16(33941), + 18: uint16(33942), + 19: uint16(33944), + 20: uint16(33946), + 21: uint16(33947), + 22: uint16(33949), + 23: uint16(33950), + 24: uint16(33951), + 25: uint16(33952), + 26: uint16(33954), + 27: uint16(33955), + 28: uint16(33956), + 29: uint16(33957), + 30: uint16(33958), + 31: uint16(33959), + 32: uint16(33960), + 33: uint16(33961), + 34: uint16(33962), + 35: uint16(33963), + 36: uint16(33964), + 37: uint16(33965), + 38: uint16(33966), + 39: uint16(33968), + 40: uint16(33969), + 41: uint16(33971), + 42: uint16(33973), + 43: uint16(33974), + 44: uint16(33975), + 45: uint16(33979), + 46: uint16(33980), + 47: uint16(33982), + 48: uint16(33984), + 49: uint16(33986), + 50: uint16(33987), + 51: uint16(33989), + 52: uint16(33990), + 53: uint16(33991), + 54: uint16(33992), + 55: uint16(33995), + 56: uint16(33996), + 57: uint16(33998), + 58: uint16(33999), + 59: uint16(34002), + 60: uint16(34004), + 61: uint16(34005), + 62: uint16(34007), + 63: uint16(34008), + 64: uint16(34009), + 65: uint16(34010), + 66: uint16(34011), + 67: uint16(34012), + 68: uint16(34014), + 69: uint16(34017), + 70: uint16(34018), + 71: uint16(34020), + 72: uint16(34023), + 73: uint16(34024), + 74: uint16(34025), + 75: uint16(34026), + 76: uint16(34027), + 77: uint16(34029), + 78: uint16(34030), + 79: uint16(34031), + 80: uint16(34033), + 81: uint16(34034), + 82: uint16(34035), + 83: uint16(34036), + 84: uint16(34037), + 85: uint16(34038), + 86: uint16(34039), + 87: uint16(34040), + 88: uint16(34041), + 89: uint16(34042), + 90: uint16(34043), + 91: uint16(34045), + 92: uint16(34046), + 93: uint16(34048), + 94: uint16(34049), + 95: uint16(34050), + 96: uint16(20254), + 97: uint16(25955), + 98: uint16(26705), + 99: uint16(21971), + 100: uint16(20007), + 101: uint16(25620), + 102: uint16(39578), + 103: uint16(25195), + 104: uint16(23234), + 105: uint16(29791), + 106: uint16(33394), + 107: uint16(28073), + 108: uint16(26862), + 109: uint16(20711), + 110: uint16(33678), + 111: uint16(30722), + 112: uint16(26432), + 113: uint16(21049), + 114: uint16(27801), + 115: uint16(32433), + 116: uint16(20667), + 117: uint16(21861), + 118: uint16(29022), + 119: uint16(31579), + 120: uint16(26194), + 121: uint16(29642), + 122: uint16(33515), + 123: uint16(26441), + 124: uint16(23665), + 125: uint16(21024), + 126: uint16(29053), + 127: uint16(34923), + 128: uint16(38378), + 129: uint16(38485), + 130: uint16(25797), + 131: uint16(36193), + 132: uint16(33203), + 133: uint16(21892), + 134: uint16(27733), + 135: uint16(25159), + 136: uint16(32558), + 137: uint16(22674), + 138: uint16(20260), + 139: uint16(21830), + 140: uint16(36175), + 141: uint16(26188), + 142: uint16(19978), + 143: uint16(23578), + 144: uint16(35059), + 145: uint16(26786), + 146: uint16(25422), + 147: uint16(31245), + 148: uint16(28903), + 149: uint16(33421), + 150: uint16(21242), + 151: uint16(38902), + 152: uint16(23569), + 153: uint16(21736), + 154: uint16(37045), + 155: uint16(32461), + 156: uint16(22882), + 157: uint16(36170), + 158: uint16(34503), + 159: uint16(33292), + 160: uint16(33293), + 161: uint16(36198), + 162: uint16(25668), + 163: uint16(23556), + 164: uint16(24913), + 165: uint16(28041), + 166: uint16(31038), + 167: uint16(35774), + 168: uint16(30775), + 169: uint16(30003), + 170: uint16(21627), + 171: uint16(20280), + 172: uint16(36523), + 173: uint16(28145), + 174: uint16(23072), + 175: uint16(32453), + 176: uint16(31070), + 177: uint16(27784), + 178: uint16(23457), + 179: uint16(23158), + 180: uint16(29978), + 181: uint16(32958), + 182: uint16(24910), + 183: uint16(28183), + 184: uint16(22768), + 185: uint16(29983), + 186: uint16(29989), + 187: uint16(29298), + 188: uint16(21319), + 189: uint16(32499), + }, + 73: { + 0: uint16(34051), + 1: uint16(34052), + 2: uint16(34053), + 3: uint16(34054), + 4: uint16(34055), + 5: uint16(34056), + 6: uint16(34057), + 7: uint16(34058), + 8: uint16(34059), + 9: uint16(34061), + 10: uint16(34062), + 11: uint16(34063), + 12: uint16(34064), + 13: uint16(34066), + 14: uint16(34068), + 15: uint16(34069), + 16: uint16(34070), + 17: uint16(34072), + 18: uint16(34073), + 19: uint16(34075), + 20: uint16(34076), + 21: uint16(34077), + 22: uint16(34078), + 23: uint16(34080), + 24: uint16(34082), + 25: uint16(34083), + 26: uint16(34084), + 27: uint16(34085), + 28: uint16(34086), + 29: uint16(34087), + 30: uint16(34088), + 31: uint16(34089), + 32: uint16(34090), + 33: uint16(34093), + 34: uint16(34094), + 35: uint16(34095), + 36: uint16(34096), + 37: uint16(34097), + 38: uint16(34098), + 39: uint16(34099), + 40: uint16(34100), + 41: uint16(34101), + 42: uint16(34102), + 43: uint16(34110), + 44: uint16(34111), + 45: uint16(34112), + 46: uint16(34113), + 47: uint16(34114), + 48: uint16(34116), + 49: uint16(34117), + 50: uint16(34118), + 51: uint16(34119), + 52: uint16(34123), + 53: uint16(34124), + 54: uint16(34125), + 55: uint16(34126), + 56: uint16(34127), + 57: uint16(34128), + 58: uint16(34129), + 59: uint16(34130), + 60: uint16(34131), + 61: uint16(34132), + 62: uint16(34133), + 63: uint16(34135), + 64: uint16(34136), + 65: uint16(34138), + 66: uint16(34139), + 67: uint16(34140), + 68: uint16(34141), + 69: uint16(34143), + 70: uint16(34144), + 71: uint16(34145), + 72: uint16(34146), + 73: uint16(34147), + 74: uint16(34149), + 75: uint16(34150), + 76: uint16(34151), + 77: uint16(34153), + 78: uint16(34154), + 79: uint16(34155), + 80: uint16(34156), + 81: uint16(34157), + 82: uint16(34158), + 83: uint16(34159), + 84: uint16(34160), + 85: uint16(34161), + 86: uint16(34163), + 87: uint16(34165), + 88: uint16(34166), + 89: uint16(34167), + 90: uint16(34168), + 91: uint16(34172), + 92: uint16(34173), + 93: uint16(34175), + 94: uint16(34176), + 95: uint16(34177), + 96: uint16(30465), + 97: uint16(30427), + 98: uint16(21097), + 99: uint16(32988), + 100: uint16(22307), + 101: uint16(24072), + 102: uint16(22833), + 103: uint16(29422), + 104: uint16(26045), + 105: uint16(28287), + 106: uint16(35799), + 107: uint16(23608), + 108: uint16(34417), + 109: uint16(21313), + 110: uint16(30707), + 111: uint16(25342), + 112: uint16(26102), + 113: uint16(20160), + 114: uint16(39135), + 115: uint16(34432), + 116: uint16(23454), + 117: uint16(35782), + 118: uint16(21490), + 119: uint16(30690), + 120: uint16(20351), + 121: uint16(23630), + 122: uint16(39542), + 123: uint16(22987), + 124: uint16(24335), + 125: uint16(31034), + 126: uint16(22763), + 127: uint16(19990), + 128: uint16(26623), + 129: uint16(20107), + 130: uint16(25325), + 131: uint16(35475), + 132: uint16(36893), + 133: uint16(21183), + 134: uint16(26159), + 135: uint16(21980), + 136: uint16(22124), + 137: uint16(36866), + 138: uint16(20181), + 139: uint16(20365), + 140: uint16(37322), + 141: uint16(39280), + 142: uint16(27663), + 143: uint16(24066), + 144: uint16(24643), + 145: uint16(23460), + 146: uint16(35270), + 147: uint16(35797), + 148: uint16(25910), + 149: uint16(25163), + 150: uint16(39318), + 151: uint16(23432), + 152: uint16(23551), + 153: uint16(25480), + 154: uint16(21806), + 155: uint16(21463), + 156: uint16(30246), + 157: uint16(20861), + 158: uint16(34092), + 159: uint16(26530), + 160: uint16(26803), + 161: uint16(27530), + 162: uint16(25234), + 163: uint16(36755), + 164: uint16(21460), + 165: uint16(33298), + 166: uint16(28113), + 167: uint16(30095), + 168: uint16(20070), + 169: uint16(36174), + 170: uint16(23408), + 171: uint16(29087), + 172: uint16(34223), + 173: uint16(26257), + 174: uint16(26329), + 175: uint16(32626), + 176: uint16(34560), + 177: uint16(40653), + 178: uint16(40736), + 179: uint16(23646), + 180: uint16(26415), + 181: uint16(36848), + 182: uint16(26641), + 183: uint16(26463), + 184: uint16(25101), + 185: uint16(31446), + 186: uint16(22661), + 187: uint16(24246), + 188: uint16(25968), + 189: uint16(28465), + }, + 74: { + 0: uint16(34178), + 1: uint16(34179), + 2: uint16(34182), + 3: uint16(34184), + 4: uint16(34185), + 5: uint16(34186), + 6: uint16(34187), + 7: uint16(34188), + 8: uint16(34189), + 9: uint16(34190), + 10: uint16(34192), + 11: uint16(34193), + 12: uint16(34194), + 13: uint16(34195), + 14: uint16(34196), + 15: uint16(34197), + 16: uint16(34198), + 17: uint16(34199), + 18: uint16(34200), + 19: uint16(34201), + 20: uint16(34202), + 21: uint16(34205), + 22: uint16(34206), + 23: uint16(34207), + 24: uint16(34208), + 25: uint16(34209), + 26: uint16(34210), + 27: uint16(34211), + 28: uint16(34213), + 29: uint16(34214), + 30: uint16(34215), + 31: uint16(34217), + 32: uint16(34219), + 33: uint16(34220), + 34: uint16(34221), + 35: uint16(34225), + 36: uint16(34226), + 37: uint16(34227), + 38: uint16(34228), + 39: uint16(34229), + 40: uint16(34230), + 41: uint16(34232), + 42: uint16(34234), + 43: uint16(34235), + 44: uint16(34236), + 45: uint16(34237), + 46: uint16(34238), + 47: uint16(34239), + 48: uint16(34240), + 49: uint16(34242), + 50: uint16(34243), + 51: uint16(34244), + 52: uint16(34245), + 53: uint16(34246), + 54: uint16(34247), + 55: uint16(34248), + 56: uint16(34250), + 57: uint16(34251), + 58: uint16(34252), + 59: uint16(34253), + 60: uint16(34254), + 61: uint16(34257), + 62: uint16(34258), + 63: uint16(34260), + 64: uint16(34262), + 65: uint16(34263), + 66: uint16(34264), + 67: uint16(34265), + 68: uint16(34266), + 69: uint16(34267), + 70: uint16(34269), + 71: uint16(34270), + 72: uint16(34271), + 73: uint16(34272), + 74: uint16(34273), + 75: uint16(34274), + 76: uint16(34275), + 77: uint16(34277), + 78: uint16(34278), + 79: uint16(34279), + 80: uint16(34280), + 81: uint16(34282), + 82: uint16(34283), + 83: uint16(34284), + 84: uint16(34285), + 85: uint16(34286), + 86: uint16(34287), + 87: uint16(34288), + 88: uint16(34289), + 89: uint16(34290), + 90: uint16(34291), + 91: uint16(34292), + 92: uint16(34293), + 93: uint16(34294), + 94: uint16(34295), + 95: uint16(34296), + 96: uint16(24661), + 97: uint16(21047), + 98: uint16(32781), + 99: uint16(25684), + 100: uint16(34928), + 101: uint16(29993), + 102: uint16(24069), + 103: uint16(26643), + 104: uint16(25332), + 105: uint16(38684), + 106: uint16(21452), + 107: uint16(29245), + 108: uint16(35841), + 109: uint16(27700), + 110: uint16(30561), + 111: uint16(31246), + 112: uint16(21550), + 113: uint16(30636), + 114: uint16(39034), + 115: uint16(33308), + 116: uint16(35828), + 117: uint16(30805), + 118: uint16(26388), + 119: uint16(28865), + 120: uint16(26031), + 121: uint16(25749), + 122: uint16(22070), + 123: uint16(24605), + 124: uint16(31169), + 125: uint16(21496), + 126: uint16(19997), + 127: uint16(27515), + 128: uint16(32902), + 129: uint16(23546), + 130: uint16(21987), + 131: uint16(22235), + 132: uint16(20282), + 133: uint16(20284), + 134: uint16(39282), + 135: uint16(24051), + 136: uint16(26494), + 137: uint16(32824), + 138: uint16(24578), + 139: uint16(39042), + 140: uint16(36865), + 141: uint16(23435), + 142: uint16(35772), + 143: uint16(35829), + 144: uint16(25628), + 145: uint16(33368), + 146: uint16(25822), + 147: uint16(22013), + 148: uint16(33487), + 149: uint16(37221), + 150: uint16(20439), + 151: uint16(32032), + 152: uint16(36895), + 153: uint16(31903), + 154: uint16(20723), + 155: uint16(22609), + 156: uint16(28335), + 157: uint16(23487), + 158: uint16(35785), + 159: uint16(32899), + 160: uint16(37240), + 161: uint16(33948), + 162: uint16(31639), + 163: uint16(34429), + 164: uint16(38539), + 165: uint16(38543), + 166: uint16(32485), + 167: uint16(39635), + 168: uint16(30862), + 169: uint16(23681), + 170: uint16(31319), + 171: uint16(36930), + 172: uint16(38567), + 173: uint16(31071), + 174: uint16(23385), + 175: uint16(25439), + 176: uint16(31499), + 177: uint16(34001), + 178: uint16(26797), + 179: uint16(21766), + 180: uint16(32553), + 181: uint16(29712), + 182: uint16(32034), + 183: uint16(38145), + 184: uint16(25152), + 185: uint16(22604), + 186: uint16(20182), + 187: uint16(23427), + 188: uint16(22905), + 189: uint16(22612), + }, + 75: { + 0: uint16(34297), + 1: uint16(34298), + 2: uint16(34300), + 3: uint16(34301), + 4: uint16(34302), + 5: uint16(34304), + 6: uint16(34305), + 7: uint16(34306), + 8: uint16(34307), + 9: uint16(34308), + 10: uint16(34310), + 11: uint16(34311), + 12: uint16(34312), + 13: uint16(34313), + 14: uint16(34314), + 15: uint16(34315), + 16: uint16(34316), + 17: uint16(34317), + 18: uint16(34318), + 19: uint16(34319), + 20: uint16(34320), + 21: uint16(34322), + 22: uint16(34323), + 23: uint16(34324), + 24: uint16(34325), + 25: uint16(34327), + 26: uint16(34328), + 27: uint16(34329), + 28: uint16(34330), + 29: uint16(34331), + 30: uint16(34332), + 31: uint16(34333), + 32: uint16(34334), + 33: uint16(34335), + 34: uint16(34336), + 35: uint16(34337), + 36: uint16(34338), + 37: uint16(34339), + 38: uint16(34340), + 39: uint16(34341), + 40: uint16(34342), + 41: uint16(34344), + 42: uint16(34346), + 43: uint16(34347), + 44: uint16(34348), + 45: uint16(34349), + 46: uint16(34350), + 47: uint16(34351), + 48: uint16(34352), + 49: uint16(34353), + 50: uint16(34354), + 51: uint16(34355), + 52: uint16(34356), + 53: uint16(34357), + 54: uint16(34358), + 55: uint16(34359), + 56: uint16(34361), + 57: uint16(34362), + 58: uint16(34363), + 59: uint16(34365), + 60: uint16(34366), + 61: uint16(34367), + 62: uint16(34368), + 63: uint16(34369), + 64: uint16(34370), + 65: uint16(34371), + 66: uint16(34372), + 67: uint16(34373), + 68: uint16(34374), + 69: uint16(34375), + 70: uint16(34376), + 71: uint16(34377), + 72: uint16(34378), + 73: uint16(34379), + 74: uint16(34380), + 75: uint16(34386), + 76: uint16(34387), + 77: uint16(34389), + 78: uint16(34390), + 79: uint16(34391), + 80: uint16(34392), + 81: uint16(34393), + 82: uint16(34395), + 83: uint16(34396), + 84: uint16(34397), + 85: uint16(34399), + 86: uint16(34400), + 87: uint16(34401), + 88: uint16(34403), + 89: uint16(34404), + 90: uint16(34405), + 91: uint16(34406), + 92: uint16(34407), + 93: uint16(34408), + 94: uint16(34409), + 95: uint16(34410), + 96: uint16(29549), + 97: uint16(25374), + 98: uint16(36427), + 99: uint16(36367), + 100: uint16(32974), + 101: uint16(33492), + 102: uint16(25260), + 103: uint16(21488), + 104: uint16(27888), + 105: uint16(37214), + 106: uint16(22826), + 107: uint16(24577), + 108: uint16(27760), + 109: uint16(22349), + 110: uint16(25674), + 111: uint16(36138), + 112: uint16(30251), + 113: uint16(28393), + 114: uint16(22363), + 115: uint16(27264), + 116: uint16(30192), + 117: uint16(28525), + 118: uint16(35885), + 119: uint16(35848), + 120: uint16(22374), + 121: uint16(27631), + 122: uint16(34962), + 123: uint16(30899), + 124: uint16(25506), + 125: uint16(21497), + 126: uint16(28845), + 127: uint16(27748), + 128: uint16(22616), + 129: uint16(25642), + 130: uint16(22530), + 131: uint16(26848), + 132: uint16(33179), + 133: uint16(21776), + 134: uint16(31958), + 135: uint16(20504), + 136: uint16(36538), + 137: uint16(28108), + 138: uint16(36255), + 139: uint16(28907), + 140: uint16(25487), + 141: uint16(28059), + 142: uint16(28372), + 143: uint16(32486), + 144: uint16(33796), + 145: uint16(26691), + 146: uint16(36867), + 147: uint16(28120), + 148: uint16(38518), + 149: uint16(35752), + 150: uint16(22871), + 151: uint16(29305), + 152: uint16(34276), + 153: uint16(33150), + 154: uint16(30140), + 155: uint16(35466), + 156: uint16(26799), + 157: uint16(21076), + 158: uint16(36386), + 159: uint16(38161), + 160: uint16(25552), + 161: uint16(39064), + 162: uint16(36420), + 163: uint16(21884), + 164: uint16(20307), + 165: uint16(26367), + 166: uint16(22159), + 167: uint16(24789), + 168: uint16(28053), + 169: uint16(21059), + 170: uint16(23625), + 171: uint16(22825), + 172: uint16(28155), + 173: uint16(22635), + 174: uint16(30000), + 175: uint16(29980), + 176: uint16(24684), + 177: uint16(33300), + 178: uint16(33094), + 179: uint16(25361), + 180: uint16(26465), + 181: uint16(36834), + 182: uint16(30522), + 183: uint16(36339), + 184: uint16(36148), + 185: uint16(38081), + 186: uint16(24086), + 187: uint16(21381), + 188: uint16(21548), + 189: uint16(28867), + }, + 76: { + 0: uint16(34413), + 1: uint16(34415), + 2: uint16(34416), + 3: uint16(34418), + 4: uint16(34419), + 5: uint16(34420), + 6: uint16(34421), + 7: uint16(34422), + 8: uint16(34423), + 9: uint16(34424), + 10: uint16(34435), + 11: uint16(34436), + 12: uint16(34437), + 13: uint16(34438), + 14: uint16(34439), + 15: uint16(34440), + 16: uint16(34441), + 17: uint16(34446), + 18: uint16(34447), + 19: uint16(34448), + 20: uint16(34449), + 21: uint16(34450), + 22: uint16(34452), + 23: uint16(34454), + 24: uint16(34455), + 25: uint16(34456), + 26: uint16(34457), + 27: uint16(34458), + 28: uint16(34459), + 29: uint16(34462), + 30: uint16(34463), + 31: uint16(34464), + 32: uint16(34465), + 33: uint16(34466), + 34: uint16(34469), + 35: uint16(34470), + 36: uint16(34475), + 37: uint16(34477), + 38: uint16(34478), + 39: uint16(34482), + 40: uint16(34483), + 41: uint16(34487), + 42: uint16(34488), + 43: uint16(34489), + 44: uint16(34491), + 45: uint16(34492), + 46: uint16(34493), + 47: uint16(34494), + 48: uint16(34495), + 49: uint16(34497), + 50: uint16(34498), + 51: uint16(34499), + 52: uint16(34501), + 53: uint16(34504), + 54: uint16(34508), + 55: uint16(34509), + 56: uint16(34514), + 57: uint16(34515), + 58: uint16(34517), + 59: uint16(34518), + 60: uint16(34519), + 61: uint16(34522), + 62: uint16(34524), + 63: uint16(34525), + 64: uint16(34528), + 65: uint16(34529), + 66: uint16(34530), + 67: uint16(34531), + 68: uint16(34533), + 69: uint16(34534), + 70: uint16(34535), + 71: uint16(34536), + 72: uint16(34538), + 73: uint16(34539), + 74: uint16(34540), + 75: uint16(34543), + 76: uint16(34549), + 77: uint16(34550), + 78: uint16(34551), + 79: uint16(34554), + 80: uint16(34555), + 81: uint16(34556), + 82: uint16(34557), + 83: uint16(34559), + 84: uint16(34561), + 85: uint16(34564), + 86: uint16(34565), + 87: uint16(34566), + 88: uint16(34571), + 89: uint16(34572), + 90: uint16(34574), + 91: uint16(34575), + 92: uint16(34576), + 93: uint16(34577), + 94: uint16(34580), + 95: uint16(34582), + 96: uint16(27712), + 97: uint16(24311), + 98: uint16(20572), + 99: uint16(20141), + 100: uint16(24237), + 101: uint16(25402), + 102: uint16(33351), + 103: uint16(36890), + 104: uint16(26704), + 105: uint16(37230), + 106: uint16(30643), + 107: uint16(21516), + 108: uint16(38108), + 109: uint16(24420), + 110: uint16(31461), + 111: uint16(26742), + 112: uint16(25413), + 113: uint16(31570), + 114: uint16(32479), + 115: uint16(30171), + 116: uint16(20599), + 117: uint16(25237), + 118: uint16(22836), + 119: uint16(36879), + 120: uint16(20984), + 121: uint16(31171), + 122: uint16(31361), + 123: uint16(22270), + 124: uint16(24466), + 125: uint16(36884), + 126: uint16(28034), + 127: uint16(23648), + 128: uint16(22303), + 129: uint16(21520), + 130: uint16(20820), + 131: uint16(28237), + 132: uint16(22242), + 133: uint16(25512), + 134: uint16(39059), + 135: uint16(33151), + 136: uint16(34581), + 137: uint16(35114), + 138: uint16(36864), + 139: uint16(21534), + 140: uint16(23663), + 141: uint16(33216), + 142: uint16(25302), + 143: uint16(25176), + 144: uint16(33073), + 145: uint16(40501), + 146: uint16(38464), + 147: uint16(39534), + 148: uint16(39548), + 149: uint16(26925), + 150: uint16(22949), + 151: uint16(25299), + 152: uint16(21822), + 153: uint16(25366), + 154: uint16(21703), + 155: uint16(34521), + 156: uint16(27964), + 157: uint16(23043), + 158: uint16(29926), + 159: uint16(34972), + 160: uint16(27498), + 161: uint16(22806), + 162: uint16(35916), + 163: uint16(24367), + 164: uint16(28286), + 165: uint16(29609), + 166: uint16(39037), + 167: uint16(20024), + 168: uint16(28919), + 169: uint16(23436), + 170: uint16(30871), + 171: uint16(25405), + 172: uint16(26202), + 173: uint16(30358), + 174: uint16(24779), + 175: uint16(23451), + 176: uint16(23113), + 177: uint16(19975), + 178: uint16(33109), + 179: uint16(27754), + 180: uint16(29579), + 181: uint16(20129), + 182: uint16(26505), + 183: uint16(32593), + 184: uint16(24448), + 185: uint16(26106), + 186: uint16(26395), + 187: uint16(24536), + 188: uint16(22916), + 189: uint16(23041), + }, + 77: { + 0: uint16(34585), + 1: uint16(34587), + 2: uint16(34589), + 3: uint16(34591), + 4: uint16(34592), + 5: uint16(34596), + 6: uint16(34598), + 7: uint16(34599), + 8: uint16(34600), + 9: uint16(34602), + 10: uint16(34603), + 11: uint16(34604), + 12: uint16(34605), + 13: uint16(34607), + 14: uint16(34608), + 15: uint16(34610), + 16: uint16(34611), + 17: uint16(34613), + 18: uint16(34614), + 19: uint16(34616), + 20: uint16(34617), + 21: uint16(34618), + 22: uint16(34620), + 23: uint16(34621), + 24: uint16(34624), + 25: uint16(34625), + 26: uint16(34626), + 27: uint16(34627), + 28: uint16(34628), + 29: uint16(34629), + 30: uint16(34630), + 31: uint16(34634), + 32: uint16(34635), + 33: uint16(34637), + 34: uint16(34639), + 35: uint16(34640), + 36: uint16(34641), + 37: uint16(34642), + 38: uint16(34644), + 39: uint16(34645), + 40: uint16(34646), + 41: uint16(34648), + 42: uint16(34650), + 43: uint16(34651), + 44: uint16(34652), + 45: uint16(34653), + 46: uint16(34654), + 47: uint16(34655), + 48: uint16(34657), + 49: uint16(34658), + 50: uint16(34662), + 51: uint16(34663), + 52: uint16(34664), + 53: uint16(34665), + 54: uint16(34666), + 55: uint16(34667), + 56: uint16(34668), + 57: uint16(34669), + 58: uint16(34671), + 59: uint16(34673), + 60: uint16(34674), + 61: uint16(34675), + 62: uint16(34677), + 63: uint16(34679), + 64: uint16(34680), + 65: uint16(34681), + 66: uint16(34682), + 67: uint16(34687), + 68: uint16(34688), + 69: uint16(34689), + 70: uint16(34692), + 71: uint16(34694), + 72: uint16(34695), + 73: uint16(34697), + 74: uint16(34698), + 75: uint16(34700), + 76: uint16(34702), + 77: uint16(34703), + 78: uint16(34704), + 79: uint16(34705), + 80: uint16(34706), + 81: uint16(34708), + 82: uint16(34709), + 83: uint16(34710), + 84: uint16(34712), + 85: uint16(34713), + 86: uint16(34714), + 87: uint16(34715), + 88: uint16(34716), + 89: uint16(34717), + 90: uint16(34718), + 91: uint16(34720), + 92: uint16(34721), + 93: uint16(34722), + 94: uint16(34723), + 95: uint16(34724), + 96: uint16(24013), + 97: uint16(24494), + 98: uint16(21361), + 99: uint16(38886), + 100: uint16(36829), + 101: uint16(26693), + 102: uint16(22260), + 103: uint16(21807), + 104: uint16(24799), + 105: uint16(20026), + 106: uint16(28493), + 107: uint16(32500), + 108: uint16(33479), + 109: uint16(33806), + 110: uint16(22996), + 111: uint16(20255), + 112: uint16(20266), + 113: uint16(23614), + 114: uint16(32428), + 115: uint16(26410), + 116: uint16(34074), + 117: uint16(21619), + 118: uint16(30031), + 119: uint16(32963), + 120: uint16(21890), + 121: uint16(39759), + 122: uint16(20301), + 123: uint16(28205), + 124: uint16(35859), + 125: uint16(23561), + 126: uint16(24944), + 127: uint16(21355), + 128: uint16(30239), + 129: uint16(28201), + 130: uint16(34442), + 131: uint16(25991), + 132: uint16(38395), + 133: uint16(32441), + 134: uint16(21563), + 135: uint16(31283), + 136: uint16(32010), + 137: uint16(38382), + 138: uint16(21985), + 139: uint16(32705), + 140: uint16(29934), + 141: uint16(25373), + 142: uint16(34583), + 143: uint16(28065), + 144: uint16(31389), + 145: uint16(25105), + 146: uint16(26017), + 147: uint16(21351), + 148: uint16(25569), + 149: uint16(27779), + 150: uint16(24043), + 151: uint16(21596), + 152: uint16(38056), + 153: uint16(20044), + 154: uint16(27745), + 155: uint16(35820), + 156: uint16(23627), + 157: uint16(26080), + 158: uint16(33436), + 159: uint16(26791), + 160: uint16(21566), + 161: uint16(21556), + 162: uint16(27595), + 163: uint16(27494), + 164: uint16(20116), + 165: uint16(25410), + 166: uint16(21320), + 167: uint16(33310), + 168: uint16(20237), + 169: uint16(20398), + 170: uint16(22366), + 171: uint16(25098), + 172: uint16(38654), + 173: uint16(26212), + 174: uint16(29289), + 175: uint16(21247), + 176: uint16(21153), + 177: uint16(24735), + 178: uint16(35823), + 179: uint16(26132), + 180: uint16(29081), + 181: uint16(26512), + 182: uint16(35199), + 183: uint16(30802), + 184: uint16(30717), + 185: uint16(26224), + 186: uint16(22075), + 187: uint16(21560), + 188: uint16(38177), + 189: uint16(29306), + }, + 78: { + 0: uint16(34725), + 1: uint16(34726), + 2: uint16(34727), + 3: uint16(34729), + 4: uint16(34730), + 5: uint16(34734), + 6: uint16(34736), + 7: uint16(34737), + 8: uint16(34738), + 9: uint16(34740), + 10: uint16(34742), + 11: uint16(34743), + 12: uint16(34744), + 13: uint16(34745), + 14: uint16(34747), + 15: uint16(34748), + 16: uint16(34750), + 17: uint16(34751), + 18: uint16(34753), + 19: uint16(34754), + 20: uint16(34755), + 21: uint16(34756), + 22: uint16(34757), + 23: uint16(34759), + 24: uint16(34760), + 25: uint16(34761), + 26: uint16(34764), + 27: uint16(34765), + 28: uint16(34766), + 29: uint16(34767), + 30: uint16(34768), + 31: uint16(34772), + 32: uint16(34773), + 33: uint16(34774), + 34: uint16(34775), + 35: uint16(34776), + 36: uint16(34777), + 37: uint16(34778), + 38: uint16(34780), + 39: uint16(34781), + 40: uint16(34782), + 41: uint16(34783), + 42: uint16(34785), + 43: uint16(34786), + 44: uint16(34787), + 45: uint16(34788), + 46: uint16(34790), + 47: uint16(34791), + 48: uint16(34792), + 49: uint16(34793), + 50: uint16(34795), + 51: uint16(34796), + 52: uint16(34797), + 53: uint16(34799), + 54: uint16(34800), + 55: uint16(34801), + 56: uint16(34802), + 57: uint16(34803), + 58: uint16(34804), + 59: uint16(34805), + 60: uint16(34806), + 61: uint16(34807), + 62: uint16(34808), + 63: uint16(34810), + 64: uint16(34811), + 65: uint16(34812), + 66: uint16(34813), + 67: uint16(34815), + 68: uint16(34816), + 69: uint16(34817), + 70: uint16(34818), + 71: uint16(34820), + 72: uint16(34821), + 73: uint16(34822), + 74: uint16(34823), + 75: uint16(34824), + 76: uint16(34825), + 77: uint16(34827), + 78: uint16(34828), + 79: uint16(34829), + 80: uint16(34830), + 81: uint16(34831), + 82: uint16(34832), + 83: uint16(34833), + 84: uint16(34834), + 85: uint16(34836), + 86: uint16(34839), + 87: uint16(34840), + 88: uint16(34841), + 89: uint16(34842), + 90: uint16(34844), + 91: uint16(34845), + 92: uint16(34846), + 93: uint16(34847), + 94: uint16(34848), + 95: uint16(34851), + 96: uint16(31232), + 97: uint16(24687), + 98: uint16(24076), + 99: uint16(24713), + 100: uint16(33181), + 101: uint16(22805), + 102: uint16(24796), + 103: uint16(29060), + 104: uint16(28911), + 105: uint16(28330), + 106: uint16(27728), + 107: uint16(29312), + 108: uint16(27268), + 109: uint16(34989), + 110: uint16(24109), + 111: uint16(20064), + 112: uint16(23219), + 113: uint16(21916), + 114: uint16(38115), + 115: uint16(27927), + 116: uint16(31995), + 117: uint16(38553), + 118: uint16(25103), + 119: uint16(32454), + 120: uint16(30606), + 121: uint16(34430), + 122: uint16(21283), + 123: uint16(38686), + 124: uint16(36758), + 125: uint16(26247), + 126: uint16(23777), + 127: uint16(20384), + 128: uint16(29421), + 129: uint16(19979), + 130: uint16(21414), + 131: uint16(22799), + 132: uint16(21523), + 133: uint16(25472), + 134: uint16(38184), + 135: uint16(20808), + 136: uint16(20185), + 137: uint16(40092), + 138: uint16(32420), + 139: uint16(21688), + 140: uint16(36132), + 141: uint16(34900), + 142: uint16(33335), + 143: uint16(38386), + 144: uint16(28046), + 145: uint16(24358), + 146: uint16(23244), + 147: uint16(26174), + 148: uint16(38505), + 149: uint16(29616), + 150: uint16(29486), + 151: uint16(21439), + 152: uint16(33146), + 153: uint16(39301), + 154: uint16(32673), + 155: uint16(23466), + 156: uint16(38519), + 157: uint16(38480), + 158: uint16(32447), + 159: uint16(30456), + 160: uint16(21410), + 161: uint16(38262), + 162: uint16(39321), + 163: uint16(31665), + 164: uint16(35140), + 165: uint16(28248), + 166: uint16(20065), + 167: uint16(32724), + 168: uint16(31077), + 169: uint16(35814), + 170: uint16(24819), + 171: uint16(21709), + 172: uint16(20139), + 173: uint16(39033), + 174: uint16(24055), + 175: uint16(27233), + 176: uint16(20687), + 177: uint16(21521), + 178: uint16(35937), + 179: uint16(33831), + 180: uint16(30813), + 181: uint16(38660), + 182: uint16(21066), + 183: uint16(21742), + 184: uint16(22179), + 185: uint16(38144), + 186: uint16(28040), + 187: uint16(23477), + 188: uint16(28102), + 189: uint16(26195), + }, + 79: { + 0: uint16(34852), + 1: uint16(34853), + 2: uint16(34854), + 3: uint16(34855), + 4: uint16(34856), + 5: uint16(34857), + 6: uint16(34858), + 7: uint16(34859), + 8: uint16(34860), + 9: uint16(34861), + 10: uint16(34862), + 11: uint16(34863), + 12: uint16(34864), + 13: uint16(34865), + 14: uint16(34867), + 15: uint16(34868), + 16: uint16(34869), + 17: uint16(34870), + 18: uint16(34871), + 19: uint16(34872), + 20: uint16(34874), + 21: uint16(34875), + 22: uint16(34877), + 23: uint16(34878), + 24: uint16(34879), + 25: uint16(34881), + 26: uint16(34882), + 27: uint16(34883), + 28: uint16(34886), + 29: uint16(34887), + 30: uint16(34888), + 31: uint16(34889), + 32: uint16(34890), + 33: uint16(34891), + 34: uint16(34894), + 35: uint16(34895), + 36: uint16(34896), + 37: uint16(34897), + 38: uint16(34898), + 39: uint16(34899), + 40: uint16(34901), + 41: uint16(34902), + 42: uint16(34904), + 43: uint16(34906), + 44: uint16(34907), + 45: uint16(34908), + 46: uint16(34909), + 47: uint16(34910), + 48: uint16(34911), + 49: uint16(34912), + 50: uint16(34918), + 51: uint16(34919), + 52: uint16(34922), + 53: uint16(34925), + 54: uint16(34927), + 55: uint16(34929), + 56: uint16(34931), + 57: uint16(34932), + 58: uint16(34933), + 59: uint16(34934), + 60: uint16(34936), + 61: uint16(34937), + 62: uint16(34938), + 63: uint16(34939), + 64: uint16(34940), + 65: uint16(34944), + 66: uint16(34947), + 67: uint16(34950), + 68: uint16(34951), + 69: uint16(34953), + 70: uint16(34954), + 71: uint16(34956), + 72: uint16(34958), + 73: uint16(34959), + 74: uint16(34960), + 75: uint16(34961), + 76: uint16(34963), + 77: uint16(34964), + 78: uint16(34965), + 79: uint16(34967), + 80: uint16(34968), + 81: uint16(34969), + 82: uint16(34970), + 83: uint16(34971), + 84: uint16(34973), + 85: uint16(34974), + 86: uint16(34975), + 87: uint16(34976), + 88: uint16(34977), + 89: uint16(34979), + 90: uint16(34981), + 91: uint16(34982), + 92: uint16(34983), + 93: uint16(34984), + 94: uint16(34985), + 95: uint16(34986), + 96: uint16(23567), + 97: uint16(23389), + 98: uint16(26657), + 99: uint16(32918), + 100: uint16(21880), + 101: uint16(31505), + 102: uint16(25928), + 103: uint16(26964), + 104: uint16(20123), + 105: uint16(27463), + 106: uint16(34638), + 107: uint16(38795), + 108: uint16(21327), + 109: uint16(25375), + 110: uint16(25658), + 111: uint16(37034), + 112: uint16(26012), + 113: uint16(32961), + 114: uint16(35856), + 115: uint16(20889), + 116: uint16(26800), + 117: uint16(21368), + 118: uint16(34809), + 119: uint16(25032), + 120: uint16(27844), + 121: uint16(27899), + 122: uint16(35874), + 123: uint16(23633), + 124: uint16(34218), + 125: uint16(33455), + 126: uint16(38156), + 127: uint16(27427), + 128: uint16(36763), + 129: uint16(26032), + 130: uint16(24571), + 131: uint16(24515), + 132: uint16(20449), + 133: uint16(34885), + 134: uint16(26143), + 135: uint16(33125), + 136: uint16(29481), + 137: uint16(24826), + 138: uint16(20852), + 139: uint16(21009), + 140: uint16(22411), + 141: uint16(24418), + 142: uint16(37026), + 143: uint16(34892), + 144: uint16(37266), + 145: uint16(24184), + 146: uint16(26447), + 147: uint16(24615), + 148: uint16(22995), + 149: uint16(20804), + 150: uint16(20982), + 151: uint16(33016), + 152: uint16(21256), + 153: uint16(27769), + 154: uint16(38596), + 155: uint16(29066), + 156: uint16(20241), + 157: uint16(20462), + 158: uint16(32670), + 159: uint16(26429), + 160: uint16(21957), + 161: uint16(38152), + 162: uint16(31168), + 163: uint16(34966), + 164: uint16(32483), + 165: uint16(22687), + 166: uint16(25100), + 167: uint16(38656), + 168: uint16(34394), + 169: uint16(22040), + 170: uint16(39035), + 171: uint16(24464), + 172: uint16(35768), + 173: uint16(33988), + 174: uint16(37207), + 175: uint16(21465), + 176: uint16(26093), + 177: uint16(24207), + 178: uint16(30044), + 179: uint16(24676), + 180: uint16(32110), + 181: uint16(23167), + 182: uint16(32490), + 183: uint16(32493), + 184: uint16(36713), + 185: uint16(21927), + 186: uint16(23459), + 187: uint16(24748), + 188: uint16(26059), + 189: uint16(29572), + }, + 80: { + 0: uint16(34988), + 1: uint16(34990), + 2: uint16(34991), + 3: uint16(34992), + 4: uint16(34994), + 5: uint16(34995), + 6: uint16(34996), + 7: uint16(34997), + 8: uint16(34998), + 9: uint16(35000), + 10: uint16(35001), + 11: uint16(35002), + 12: uint16(35003), + 13: uint16(35005), + 14: uint16(35006), + 15: uint16(35007), + 16: uint16(35008), + 17: uint16(35011), + 18: uint16(35012), + 19: uint16(35015), + 20: uint16(35016), + 21: uint16(35018), + 22: uint16(35019), + 23: uint16(35020), + 24: uint16(35021), + 25: uint16(35023), + 26: uint16(35024), + 27: uint16(35025), + 28: uint16(35027), + 29: uint16(35030), + 30: uint16(35031), + 31: uint16(35034), + 32: uint16(35035), + 33: uint16(35036), + 34: uint16(35037), + 35: uint16(35038), + 36: uint16(35040), + 37: uint16(35041), + 38: uint16(35046), + 39: uint16(35047), + 40: uint16(35049), + 41: uint16(35050), + 42: uint16(35051), + 43: uint16(35052), + 44: uint16(35053), + 45: uint16(35054), + 46: uint16(35055), + 47: uint16(35058), + 48: uint16(35061), + 49: uint16(35062), + 50: uint16(35063), + 51: uint16(35066), + 52: uint16(35067), + 53: uint16(35069), + 54: uint16(35071), + 55: uint16(35072), + 56: uint16(35073), + 57: uint16(35075), + 58: uint16(35076), + 59: uint16(35077), + 60: uint16(35078), + 61: uint16(35079), + 62: uint16(35080), + 63: uint16(35081), + 64: uint16(35083), + 65: uint16(35084), + 66: uint16(35085), + 67: uint16(35086), + 68: uint16(35087), + 69: uint16(35089), + 70: uint16(35092), + 71: uint16(35093), + 72: uint16(35094), + 73: uint16(35095), + 74: uint16(35096), + 75: uint16(35100), + 76: uint16(35101), + 77: uint16(35102), + 78: uint16(35103), + 79: uint16(35104), + 80: uint16(35106), + 81: uint16(35107), + 82: uint16(35108), + 83: uint16(35110), + 84: uint16(35111), + 85: uint16(35112), + 86: uint16(35113), + 87: uint16(35116), + 88: uint16(35117), + 89: uint16(35118), + 90: uint16(35119), + 91: uint16(35121), + 92: uint16(35122), + 93: uint16(35123), + 94: uint16(35125), + 95: uint16(35127), + 96: uint16(36873), + 97: uint16(30307), + 98: uint16(30505), + 99: uint16(32474), + 100: uint16(38772), + 101: uint16(34203), + 102: uint16(23398), + 103: uint16(31348), + 104: uint16(38634), + 105: uint16(34880), + 106: uint16(21195), + 107: uint16(29071), + 108: uint16(24490), + 109: uint16(26092), + 110: uint16(35810), + 111: uint16(23547), + 112: uint16(39535), + 113: uint16(24033), + 114: uint16(27529), + 115: uint16(27739), + 116: uint16(35757), + 117: uint16(35759), + 118: uint16(36874), + 119: uint16(36805), + 120: uint16(21387), + 121: uint16(25276), + 122: uint16(40486), + 123: uint16(40493), + 124: uint16(21568), + 125: uint16(20011), + 126: uint16(33469), + 127: uint16(29273), + 128: uint16(34460), + 129: uint16(23830), + 130: uint16(34905), + 131: uint16(28079), + 132: uint16(38597), + 133: uint16(21713), + 134: uint16(20122), + 135: uint16(35766), + 136: uint16(28937), + 137: uint16(21693), + 138: uint16(38409), + 139: uint16(28895), + 140: uint16(28153), + 141: uint16(30416), + 142: uint16(20005), + 143: uint16(30740), + 144: uint16(34578), + 145: uint16(23721), + 146: uint16(24310), + 147: uint16(35328), + 148: uint16(39068), + 149: uint16(38414), + 150: uint16(28814), + 151: uint16(27839), + 152: uint16(22852), + 153: uint16(25513), + 154: uint16(30524), + 155: uint16(34893), + 156: uint16(28436), + 157: uint16(33395), + 158: uint16(22576), + 159: uint16(29141), + 160: uint16(21388), + 161: uint16(30746), + 162: uint16(38593), + 163: uint16(21761), + 164: uint16(24422), + 165: uint16(28976), + 166: uint16(23476), + 167: uint16(35866), + 168: uint16(39564), + 169: uint16(27523), + 170: uint16(22830), + 171: uint16(40495), + 172: uint16(31207), + 173: uint16(26472), + 174: uint16(25196), + 175: uint16(20335), + 176: uint16(30113), + 177: uint16(32650), + 178: uint16(27915), + 179: uint16(38451), + 180: uint16(27687), + 181: uint16(20208), + 182: uint16(30162), + 183: uint16(20859), + 184: uint16(26679), + 185: uint16(28478), + 186: uint16(36992), + 187: uint16(33136), + 188: uint16(22934), + 189: uint16(29814), + }, + 81: { + 0: uint16(35128), + 1: uint16(35129), + 2: uint16(35130), + 3: uint16(35131), + 4: uint16(35132), + 5: uint16(35133), + 6: uint16(35134), + 7: uint16(35135), + 8: uint16(35136), + 9: uint16(35138), + 10: uint16(35139), + 11: uint16(35141), + 12: uint16(35142), + 13: uint16(35143), + 14: uint16(35144), + 15: uint16(35145), + 16: uint16(35146), + 17: uint16(35147), + 18: uint16(35148), + 19: uint16(35149), + 20: uint16(35150), + 21: uint16(35151), + 22: uint16(35152), + 23: uint16(35153), + 24: uint16(35154), + 25: uint16(35155), + 26: uint16(35156), + 27: uint16(35157), + 28: uint16(35158), + 29: uint16(35159), + 30: uint16(35160), + 31: uint16(35161), + 32: uint16(35162), + 33: uint16(35163), + 34: uint16(35164), + 35: uint16(35165), + 36: uint16(35168), + 37: uint16(35169), + 38: uint16(35170), + 39: uint16(35171), + 40: uint16(35172), + 41: uint16(35173), + 42: uint16(35175), + 43: uint16(35176), + 44: uint16(35177), + 45: uint16(35178), + 46: uint16(35179), + 47: uint16(35180), + 48: uint16(35181), + 49: uint16(35182), + 50: uint16(35183), + 51: uint16(35184), + 52: uint16(35185), + 53: uint16(35186), + 54: uint16(35187), + 55: uint16(35188), + 56: uint16(35189), + 57: uint16(35190), + 58: uint16(35191), + 59: uint16(35192), + 60: uint16(35193), + 61: uint16(35194), + 62: uint16(35196), + 63: uint16(35197), + 64: uint16(35198), + 65: uint16(35200), + 66: uint16(35202), + 67: uint16(35204), + 68: uint16(35205), + 69: uint16(35207), + 70: uint16(35208), + 71: uint16(35209), + 72: uint16(35210), + 73: uint16(35211), + 74: uint16(35212), + 75: uint16(35213), + 76: uint16(35214), + 77: uint16(35215), + 78: uint16(35216), + 79: uint16(35217), + 80: uint16(35218), + 81: uint16(35219), + 82: uint16(35220), + 83: uint16(35221), + 84: uint16(35222), + 85: uint16(35223), + 86: uint16(35224), + 87: uint16(35225), + 88: uint16(35226), + 89: uint16(35227), + 90: uint16(35228), + 91: uint16(35229), + 92: uint16(35230), + 93: uint16(35231), + 94: uint16(35232), + 95: uint16(35233), + 96: uint16(25671), + 97: uint16(23591), + 98: uint16(36965), + 99: uint16(31377), + 100: uint16(35875), + 101: uint16(23002), + 102: uint16(21676), + 103: uint16(33280), + 104: uint16(33647), + 105: uint16(35201), + 106: uint16(32768), + 107: uint16(26928), + 108: uint16(22094), + 109: uint16(32822), + 110: uint16(29239), + 111: uint16(37326), + 112: uint16(20918), + 113: uint16(20063), + 114: uint16(39029), + 115: uint16(25494), + 116: uint16(19994), + 117: uint16(21494), + 118: uint16(26355), + 119: uint16(33099), + 120: uint16(22812), + 121: uint16(28082), + 122: uint16(19968), + 123: uint16(22777), + 124: uint16(21307), + 125: uint16(25558), + 126: uint16(38129), + 127: uint16(20381), + 128: uint16(20234), + 129: uint16(34915), + 130: uint16(39056), + 131: uint16(22839), + 132: uint16(36951), + 133: uint16(31227), + 134: uint16(20202), + 135: uint16(33008), + 136: uint16(30097), + 137: uint16(27778), + 138: uint16(23452), + 139: uint16(23016), + 140: uint16(24413), + 141: uint16(26885), + 142: uint16(34433), + 143: uint16(20506), + 144: uint16(24050), + 145: uint16(20057), + 146: uint16(30691), + 147: uint16(20197), + 148: uint16(33402), + 149: uint16(25233), + 150: uint16(26131), + 151: uint16(37009), + 152: uint16(23673), + 153: uint16(20159), + 154: uint16(24441), + 155: uint16(33222), + 156: uint16(36920), + 157: uint16(32900), + 158: uint16(30123), + 159: uint16(20134), + 160: uint16(35028), + 161: uint16(24847), + 162: uint16(27589), + 163: uint16(24518), + 164: uint16(20041), + 165: uint16(30410), + 166: uint16(28322), + 167: uint16(35811), + 168: uint16(35758), + 169: uint16(35850), + 170: uint16(35793), + 171: uint16(24322), + 172: uint16(32764), + 173: uint16(32716), + 174: uint16(32462), + 175: uint16(33589), + 176: uint16(33643), + 177: uint16(22240), + 178: uint16(27575), + 179: uint16(38899), + 180: uint16(38452), + 181: uint16(23035), + 182: uint16(21535), + 183: uint16(38134), + 184: uint16(28139), + 185: uint16(23493), + 186: uint16(39278), + 187: uint16(23609), + 188: uint16(24341), + 189: uint16(38544), + }, + 82: { + 0: uint16(35234), + 1: uint16(35235), + 2: uint16(35236), + 3: uint16(35237), + 4: uint16(35238), + 5: uint16(35239), + 6: uint16(35240), + 7: uint16(35241), + 8: uint16(35242), + 9: uint16(35243), + 10: uint16(35244), + 11: uint16(35245), + 12: uint16(35246), + 13: uint16(35247), + 14: uint16(35248), + 15: uint16(35249), + 16: uint16(35250), + 17: uint16(35251), + 18: uint16(35252), + 19: uint16(35253), + 20: uint16(35254), + 21: uint16(35255), + 22: uint16(35256), + 23: uint16(35257), + 24: uint16(35258), + 25: uint16(35259), + 26: uint16(35260), + 27: uint16(35261), + 28: uint16(35262), + 29: uint16(35263), + 30: uint16(35264), + 31: uint16(35267), + 32: uint16(35277), + 33: uint16(35283), + 34: uint16(35284), + 35: uint16(35285), + 36: uint16(35287), + 37: uint16(35288), + 38: uint16(35289), + 39: uint16(35291), + 40: uint16(35293), + 41: uint16(35295), + 42: uint16(35296), + 43: uint16(35297), + 44: uint16(35298), + 45: uint16(35300), + 46: uint16(35303), + 47: uint16(35304), + 48: uint16(35305), + 49: uint16(35306), + 50: uint16(35308), + 51: uint16(35309), + 52: uint16(35310), + 53: uint16(35312), + 54: uint16(35313), + 55: uint16(35314), + 56: uint16(35316), + 57: uint16(35317), + 58: uint16(35318), + 59: uint16(35319), + 60: uint16(35320), + 61: uint16(35321), + 62: uint16(35322), + 63: uint16(35323), + 64: uint16(35324), + 65: uint16(35325), + 66: uint16(35326), + 67: uint16(35327), + 68: uint16(35329), + 69: uint16(35330), + 70: uint16(35331), + 71: uint16(35332), + 72: uint16(35333), + 73: uint16(35334), + 74: uint16(35336), + 75: uint16(35337), + 76: uint16(35338), + 77: uint16(35339), + 78: uint16(35340), + 79: uint16(35341), + 80: uint16(35342), + 81: uint16(35343), + 82: uint16(35344), + 83: uint16(35345), + 84: uint16(35346), + 85: uint16(35347), + 86: uint16(35348), + 87: uint16(35349), + 88: uint16(35350), + 89: uint16(35351), + 90: uint16(35352), + 91: uint16(35353), + 92: uint16(35354), + 93: uint16(35355), + 94: uint16(35356), + 95: uint16(35357), + 96: uint16(21360), + 97: uint16(33521), + 98: uint16(27185), + 99: uint16(23156), + 100: uint16(40560), + 101: uint16(24212), + 102: uint16(32552), + 103: uint16(33721), + 104: uint16(33828), + 105: uint16(33829), + 106: uint16(33639), + 107: uint16(34631), + 108: uint16(36814), + 109: uint16(36194), + 110: uint16(30408), + 111: uint16(24433), + 112: uint16(39062), + 113: uint16(30828), + 114: uint16(26144), + 115: uint16(21727), + 116: uint16(25317), + 117: uint16(20323), + 118: uint16(33219), + 119: uint16(30152), + 120: uint16(24248), + 121: uint16(38605), + 122: uint16(36362), + 123: uint16(34553), + 124: uint16(21647), + 125: uint16(27891), + 126: uint16(28044), + 127: uint16(27704), + 128: uint16(24703), + 129: uint16(21191), + 130: uint16(29992), + 131: uint16(24189), + 132: uint16(20248), + 133: uint16(24736), + 134: uint16(24551), + 135: uint16(23588), + 136: uint16(30001), + 137: uint16(37038), + 138: uint16(38080), + 139: uint16(29369), + 140: uint16(27833), + 141: uint16(28216), + 142: uint16(37193), + 143: uint16(26377), + 144: uint16(21451), + 145: uint16(21491), + 146: uint16(20305), + 147: uint16(37321), + 148: uint16(35825), + 149: uint16(21448), + 150: uint16(24188), + 151: uint16(36802), + 152: uint16(28132), + 153: uint16(20110), + 154: uint16(30402), + 155: uint16(27014), + 156: uint16(34398), + 157: uint16(24858), + 158: uint16(33286), + 159: uint16(20313), + 160: uint16(20446), + 161: uint16(36926), + 162: uint16(40060), + 163: uint16(24841), + 164: uint16(28189), + 165: uint16(28180), + 166: uint16(38533), + 167: uint16(20104), + 168: uint16(23089), + 169: uint16(38632), + 170: uint16(19982), + 171: uint16(23679), + 172: uint16(31161), + 173: uint16(23431), + 174: uint16(35821), + 175: uint16(32701), + 176: uint16(29577), + 177: uint16(22495), + 178: uint16(33419), + 179: uint16(37057), + 180: uint16(21505), + 181: uint16(36935), + 182: uint16(21947), + 183: uint16(23786), + 184: uint16(24481), + 185: uint16(24840), + 186: uint16(27442), + 187: uint16(29425), + 188: uint16(32946), + 189: uint16(35465), + }, + 83: { + 0: uint16(35358), + 1: uint16(35359), + 2: uint16(35360), + 3: uint16(35361), + 4: uint16(35362), + 5: uint16(35363), + 6: uint16(35364), + 7: uint16(35365), + 8: uint16(35366), + 9: uint16(35367), + 10: uint16(35368), + 11: uint16(35369), + 12: uint16(35370), + 13: uint16(35371), + 14: uint16(35372), + 15: uint16(35373), + 16: uint16(35374), + 17: uint16(35375), + 18: uint16(35376), + 19: uint16(35377), + 20: uint16(35378), + 21: uint16(35379), + 22: uint16(35380), + 23: uint16(35381), + 24: uint16(35382), + 25: uint16(35383), + 26: uint16(35384), + 27: uint16(35385), + 28: uint16(35386), + 29: uint16(35387), + 30: uint16(35388), + 31: uint16(35389), + 32: uint16(35391), + 33: uint16(35392), + 34: uint16(35393), + 35: uint16(35394), + 36: uint16(35395), + 37: uint16(35396), + 38: uint16(35397), + 39: uint16(35398), + 40: uint16(35399), + 41: uint16(35401), + 42: uint16(35402), + 43: uint16(35403), + 44: uint16(35404), + 45: uint16(35405), + 46: uint16(35406), + 47: uint16(35407), + 48: uint16(35408), + 49: uint16(35409), + 50: uint16(35410), + 51: uint16(35411), + 52: uint16(35412), + 53: uint16(35413), + 54: uint16(35414), + 55: uint16(35415), + 56: uint16(35416), + 57: uint16(35417), + 58: uint16(35418), + 59: uint16(35419), + 60: uint16(35420), + 61: uint16(35421), + 62: uint16(35422), + 63: uint16(35423), + 64: uint16(35424), + 65: uint16(35425), + 66: uint16(35426), + 67: uint16(35427), + 68: uint16(35428), + 69: uint16(35429), + 70: uint16(35430), + 71: uint16(35431), + 72: uint16(35432), + 73: uint16(35433), + 74: uint16(35434), + 75: uint16(35435), + 76: uint16(35436), + 77: uint16(35437), + 78: uint16(35438), + 79: uint16(35439), + 80: uint16(35440), + 81: uint16(35441), + 82: uint16(35442), + 83: uint16(35443), + 84: uint16(35444), + 85: uint16(35445), + 86: uint16(35446), + 87: uint16(35447), + 88: uint16(35448), + 89: uint16(35450), + 90: uint16(35451), + 91: uint16(35452), + 92: uint16(35453), + 93: uint16(35454), + 94: uint16(35455), + 95: uint16(35456), + 96: uint16(28020), + 97: uint16(23507), + 98: uint16(35029), + 99: uint16(39044), + 100: uint16(35947), + 101: uint16(39533), + 102: uint16(40499), + 103: uint16(28170), + 104: uint16(20900), + 105: uint16(20803), + 106: uint16(22435), + 107: uint16(34945), + 108: uint16(21407), + 109: uint16(25588), + 110: uint16(36757), + 111: uint16(22253), + 112: uint16(21592), + 113: uint16(22278), + 114: uint16(29503), + 115: uint16(28304), + 116: uint16(32536), + 117: uint16(36828), + 118: uint16(33489), + 119: uint16(24895), + 120: uint16(24616), + 121: uint16(38498), + 122: uint16(26352), + 123: uint16(32422), + 124: uint16(36234), + 125: uint16(36291), + 126: uint16(38053), + 127: uint16(23731), + 128: uint16(31908), + 129: uint16(26376), + 130: uint16(24742), + 131: uint16(38405), + 132: uint16(32792), + 133: uint16(20113), + 134: uint16(37095), + 135: uint16(21248), + 136: uint16(38504), + 137: uint16(20801), + 138: uint16(36816), + 139: uint16(34164), + 140: uint16(37213), + 141: uint16(26197), + 142: uint16(38901), + 143: uint16(23381), + 144: uint16(21277), + 145: uint16(30776), + 146: uint16(26434), + 147: uint16(26685), + 148: uint16(21705), + 149: uint16(28798), + 150: uint16(23472), + 151: uint16(36733), + 152: uint16(20877), + 153: uint16(22312), + 154: uint16(21681), + 155: uint16(25874), + 156: uint16(26242), + 157: uint16(36190), + 158: uint16(36163), + 159: uint16(33039), + 160: uint16(33900), + 161: uint16(36973), + 162: uint16(31967), + 163: uint16(20991), + 164: uint16(34299), + 165: uint16(26531), + 166: uint16(26089), + 167: uint16(28577), + 168: uint16(34468), + 169: uint16(36481), + 170: uint16(22122), + 171: uint16(36896), + 172: uint16(30338), + 173: uint16(28790), + 174: uint16(29157), + 175: uint16(36131), + 176: uint16(25321), + 177: uint16(21017), + 178: uint16(27901), + 179: uint16(36156), + 180: uint16(24590), + 181: uint16(22686), + 182: uint16(24974), + 183: uint16(26366), + 184: uint16(36192), + 185: uint16(25166), + 186: uint16(21939), + 187: uint16(28195), + 188: uint16(26413), + 189: uint16(36711), + }, + 84: { + 0: uint16(35457), + 1: uint16(35458), + 2: uint16(35459), + 3: uint16(35460), + 4: uint16(35461), + 5: uint16(35462), + 6: uint16(35463), + 7: uint16(35464), + 8: uint16(35467), + 9: uint16(35468), + 10: uint16(35469), + 11: uint16(35470), + 12: uint16(35471), + 13: uint16(35472), + 14: uint16(35473), + 15: uint16(35474), + 16: uint16(35476), + 17: uint16(35477), + 18: uint16(35478), + 19: uint16(35479), + 20: uint16(35480), + 21: uint16(35481), + 22: uint16(35482), + 23: uint16(35483), + 24: uint16(35484), + 25: uint16(35485), + 26: uint16(35486), + 27: uint16(35487), + 28: uint16(35488), + 29: uint16(35489), + 30: uint16(35490), + 31: uint16(35491), + 32: uint16(35492), + 33: uint16(35493), + 34: uint16(35494), + 35: uint16(35495), + 36: uint16(35496), + 37: uint16(35497), + 38: uint16(35498), + 39: uint16(35499), + 40: uint16(35500), + 41: uint16(35501), + 42: uint16(35502), + 43: uint16(35503), + 44: uint16(35504), + 45: uint16(35505), + 46: uint16(35506), + 47: uint16(35507), + 48: uint16(35508), + 49: uint16(35509), + 50: uint16(35510), + 51: uint16(35511), + 52: uint16(35512), + 53: uint16(35513), + 54: uint16(35514), + 55: uint16(35515), + 56: uint16(35516), + 57: uint16(35517), + 58: uint16(35518), + 59: uint16(35519), + 60: uint16(35520), + 61: uint16(35521), + 62: uint16(35522), + 63: uint16(35523), + 64: uint16(35524), + 65: uint16(35525), + 66: uint16(35526), + 67: uint16(35527), + 68: uint16(35528), + 69: uint16(35529), + 70: uint16(35530), + 71: uint16(35531), + 72: uint16(35532), + 73: uint16(35533), + 74: uint16(35534), + 75: uint16(35535), + 76: uint16(35536), + 77: uint16(35537), + 78: uint16(35538), + 79: uint16(35539), + 80: uint16(35540), + 81: uint16(35541), + 82: uint16(35542), + 83: uint16(35543), + 84: uint16(35544), + 85: uint16(35545), + 86: uint16(35546), + 87: uint16(35547), + 88: uint16(35548), + 89: uint16(35549), + 90: uint16(35550), + 91: uint16(35551), + 92: uint16(35552), + 93: uint16(35553), + 94: uint16(35554), + 95: uint16(35555), + 96: uint16(38113), + 97: uint16(38392), + 98: uint16(30504), + 99: uint16(26629), + 100: uint16(27048), + 101: uint16(21643), + 102: uint16(20045), + 103: uint16(28856), + 104: uint16(35784), + 105: uint16(25688), + 106: uint16(25995), + 107: uint16(23429), + 108: uint16(31364), + 109: uint16(20538), + 110: uint16(23528), + 111: uint16(30651), + 112: uint16(27617), + 113: uint16(35449), + 114: uint16(31896), + 115: uint16(27838), + 116: uint16(30415), + 117: uint16(26025), + 118: uint16(36759), + 119: uint16(23853), + 120: uint16(23637), + 121: uint16(34360), + 122: uint16(26632), + 123: uint16(21344), + 124: uint16(25112), + 125: uint16(31449), + 126: uint16(28251), + 127: uint16(32509), + 128: uint16(27167), + 129: uint16(31456), + 130: uint16(24432), + 131: uint16(28467), + 132: uint16(24352), + 133: uint16(25484), + 134: uint16(28072), + 135: uint16(26454), + 136: uint16(19976), + 137: uint16(24080), + 138: uint16(36134), + 139: uint16(20183), + 140: uint16(32960), + 141: uint16(30260), + 142: uint16(38556), + 143: uint16(25307), + 144: uint16(26157), + 145: uint16(25214), + 146: uint16(27836), + 147: uint16(36213), + 148: uint16(29031), + 149: uint16(32617), + 150: uint16(20806), + 151: uint16(32903), + 152: uint16(21484), + 153: uint16(36974), + 154: uint16(25240), + 155: uint16(21746), + 156: uint16(34544), + 157: uint16(36761), + 158: uint16(32773), + 159: uint16(38167), + 160: uint16(34071), + 161: uint16(36825), + 162: uint16(27993), + 163: uint16(29645), + 164: uint16(26015), + 165: uint16(30495), + 166: uint16(29956), + 167: uint16(30759), + 168: uint16(33275), + 169: uint16(36126), + 170: uint16(38024), + 171: uint16(20390), + 172: uint16(26517), + 173: uint16(30137), + 174: uint16(35786), + 175: uint16(38663), + 176: uint16(25391), + 177: uint16(38215), + 178: uint16(38453), + 179: uint16(33976), + 180: uint16(25379), + 181: uint16(30529), + 182: uint16(24449), + 183: uint16(29424), + 184: uint16(20105), + 185: uint16(24596), + 186: uint16(25972), + 187: uint16(25327), + 188: uint16(27491), + 189: uint16(25919), + }, + 85: { + 0: uint16(35556), + 1: uint16(35557), + 2: uint16(35558), + 3: uint16(35559), + 4: uint16(35560), + 5: uint16(35561), + 6: uint16(35562), + 7: uint16(35563), + 8: uint16(35564), + 9: uint16(35565), + 10: uint16(35566), + 11: uint16(35567), + 12: uint16(35568), + 13: uint16(35569), + 14: uint16(35570), + 15: uint16(35571), + 16: uint16(35572), + 17: uint16(35573), + 18: uint16(35574), + 19: uint16(35575), + 20: uint16(35576), + 21: uint16(35577), + 22: uint16(35578), + 23: uint16(35579), + 24: uint16(35580), + 25: uint16(35581), + 26: uint16(35582), + 27: uint16(35583), + 28: uint16(35584), + 29: uint16(35585), + 30: uint16(35586), + 31: uint16(35587), + 32: uint16(35588), + 33: uint16(35589), + 34: uint16(35590), + 35: uint16(35592), + 36: uint16(35593), + 37: uint16(35594), + 38: uint16(35595), + 39: uint16(35596), + 40: uint16(35597), + 41: uint16(35598), + 42: uint16(35599), + 43: uint16(35600), + 44: uint16(35601), + 45: uint16(35602), + 46: uint16(35603), + 47: uint16(35604), + 48: uint16(35605), + 49: uint16(35606), + 50: uint16(35607), + 51: uint16(35608), + 52: uint16(35609), + 53: uint16(35610), + 54: uint16(35611), + 55: uint16(35612), + 56: uint16(35613), + 57: uint16(35614), + 58: uint16(35615), + 59: uint16(35616), + 60: uint16(35617), + 61: uint16(35618), + 62: uint16(35619), + 63: uint16(35620), + 64: uint16(35621), + 65: uint16(35623), + 66: uint16(35624), + 67: uint16(35625), + 68: uint16(35626), + 69: uint16(35627), + 70: uint16(35628), + 71: uint16(35629), + 72: uint16(35630), + 73: uint16(35631), + 74: uint16(35632), + 75: uint16(35633), + 76: uint16(35634), + 77: uint16(35635), + 78: uint16(35636), + 79: uint16(35637), + 80: uint16(35638), + 81: uint16(35639), + 82: uint16(35640), + 83: uint16(35641), + 84: uint16(35642), + 85: uint16(35643), + 86: uint16(35644), + 87: uint16(35645), + 88: uint16(35646), + 89: uint16(35647), + 90: uint16(35648), + 91: uint16(35649), + 92: uint16(35650), + 93: uint16(35651), + 94: uint16(35652), + 95: uint16(35653), + 96: uint16(24103), + 97: uint16(30151), + 98: uint16(37073), + 99: uint16(35777), + 100: uint16(33437), + 101: uint16(26525), + 102: uint16(25903), + 103: uint16(21553), + 104: uint16(34584), + 105: uint16(30693), + 106: uint16(32930), + 107: uint16(33026), + 108: uint16(27713), + 109: uint16(20043), + 110: uint16(32455), + 111: uint16(32844), + 112: uint16(30452), + 113: uint16(26893), + 114: uint16(27542), + 115: uint16(25191), + 116: uint16(20540), + 117: uint16(20356), + 118: uint16(22336), + 119: uint16(25351), + 120: uint16(27490), + 121: uint16(36286), + 122: uint16(21482), + 123: uint16(26088), + 124: uint16(32440), + 125: uint16(24535), + 126: uint16(25370), + 127: uint16(25527), + 128: uint16(33267), + 129: uint16(33268), + 130: uint16(32622), + 131: uint16(24092), + 132: uint16(23769), + 133: uint16(21046), + 134: uint16(26234), + 135: uint16(31209), + 136: uint16(31258), + 137: uint16(36136), + 138: uint16(28825), + 139: uint16(30164), + 140: uint16(28382), + 141: uint16(27835), + 142: uint16(31378), + 143: uint16(20013), + 144: uint16(30405), + 145: uint16(24544), + 146: uint16(38047), + 147: uint16(34935), + 148: uint16(32456), + 149: uint16(31181), + 150: uint16(32959), + 151: uint16(37325), + 152: uint16(20210), + 153: uint16(20247), + 154: uint16(33311), + 155: uint16(21608), + 156: uint16(24030), + 157: uint16(27954), + 158: uint16(35788), + 159: uint16(31909), + 160: uint16(36724), + 161: uint16(32920), + 162: uint16(24090), + 163: uint16(21650), + 164: uint16(30385), + 165: uint16(23449), + 166: uint16(26172), + 167: uint16(39588), + 168: uint16(29664), + 169: uint16(26666), + 170: uint16(34523), + 171: uint16(26417), + 172: uint16(29482), + 173: uint16(35832), + 174: uint16(35803), + 175: uint16(36880), + 176: uint16(31481), + 177: uint16(28891), + 178: uint16(29038), + 179: uint16(25284), + 180: uint16(30633), + 181: uint16(22065), + 182: uint16(20027), + 183: uint16(33879), + 184: uint16(26609), + 185: uint16(21161), + 186: uint16(34496), + 187: uint16(36142), + 188: uint16(38136), + 189: uint16(31569), + }, + 86: { + 0: uint16(35654), + 1: uint16(35655), + 2: uint16(35656), + 3: uint16(35657), + 4: uint16(35658), + 5: uint16(35659), + 6: uint16(35660), + 7: uint16(35661), + 8: uint16(35662), + 9: uint16(35663), + 10: uint16(35664), + 11: uint16(35665), + 12: uint16(35666), + 13: uint16(35667), + 14: uint16(35668), + 15: uint16(35669), + 16: uint16(35670), + 17: uint16(35671), + 18: uint16(35672), + 19: uint16(35673), + 20: uint16(35674), + 21: uint16(35675), + 22: uint16(35676), + 23: uint16(35677), + 24: uint16(35678), + 25: uint16(35679), + 26: uint16(35680), + 27: uint16(35681), + 28: uint16(35682), + 29: uint16(35683), + 30: uint16(35684), + 31: uint16(35685), + 32: uint16(35687), + 33: uint16(35688), + 34: uint16(35689), + 35: uint16(35690), + 36: uint16(35691), + 37: uint16(35693), + 38: uint16(35694), + 39: uint16(35695), + 40: uint16(35696), + 41: uint16(35697), + 42: uint16(35698), + 43: uint16(35699), + 44: uint16(35700), + 45: uint16(35701), + 46: uint16(35702), + 47: uint16(35703), + 48: uint16(35704), + 49: uint16(35705), + 50: uint16(35706), + 51: uint16(35707), + 52: uint16(35708), + 53: uint16(35709), + 54: uint16(35710), + 55: uint16(35711), + 56: uint16(35712), + 57: uint16(35713), + 58: uint16(35714), + 59: uint16(35715), + 60: uint16(35716), + 61: uint16(35717), + 62: uint16(35718), + 63: uint16(35719), + 64: uint16(35720), + 65: uint16(35721), + 66: uint16(35722), + 67: uint16(35723), + 68: uint16(35724), + 69: uint16(35725), + 70: uint16(35726), + 71: uint16(35727), + 72: uint16(35728), + 73: uint16(35729), + 74: uint16(35730), + 75: uint16(35731), + 76: uint16(35732), + 77: uint16(35733), + 78: uint16(35734), + 79: uint16(35735), + 80: uint16(35736), + 81: uint16(35737), + 82: uint16(35738), + 83: uint16(35739), + 84: uint16(35740), + 85: uint16(35741), + 86: uint16(35742), + 87: uint16(35743), + 88: uint16(35756), + 89: uint16(35761), + 90: uint16(35771), + 91: uint16(35783), + 92: uint16(35792), + 93: uint16(35818), + 94: uint16(35849), + 95: uint16(35870), + 96: uint16(20303), + 97: uint16(27880), + 98: uint16(31069), + 99: uint16(39547), + 100: uint16(25235), + 101: uint16(29226), + 102: uint16(25341), + 103: uint16(19987), + 104: uint16(30742), + 105: uint16(36716), + 106: uint16(25776), + 107: uint16(36186), + 108: uint16(31686), + 109: uint16(26729), + 110: uint16(24196), + 111: uint16(35013), + 112: uint16(22918), + 113: uint16(25758), + 114: uint16(22766), + 115: uint16(29366), + 116: uint16(26894), + 117: uint16(38181), + 118: uint16(36861), + 119: uint16(36184), + 120: uint16(22368), + 121: uint16(32512), + 122: uint16(35846), + 123: uint16(20934), + 124: uint16(25417), + 125: uint16(25305), + 126: uint16(21331), + 127: uint16(26700), + 128: uint16(29730), + 129: uint16(33537), + 130: uint16(37196), + 131: uint16(21828), + 132: uint16(30528), + 133: uint16(28796), + 134: uint16(27978), + 135: uint16(20857), + 136: uint16(21672), + 137: uint16(36164), + 138: uint16(23039), + 139: uint16(28363), + 140: uint16(28100), + 141: uint16(23388), + 142: uint16(32043), + 143: uint16(20180), + 144: uint16(31869), + 145: uint16(28371), + 146: uint16(23376), + 147: uint16(33258), + 148: uint16(28173), + 149: uint16(23383), + 150: uint16(39683), + 151: uint16(26837), + 152: uint16(36394), + 153: uint16(23447), + 154: uint16(32508), + 155: uint16(24635), + 156: uint16(32437), + 157: uint16(37049), + 158: uint16(36208), + 159: uint16(22863), + 160: uint16(25549), + 161: uint16(31199), + 162: uint16(36275), + 163: uint16(21330), + 164: uint16(26063), + 165: uint16(31062), + 166: uint16(35781), + 167: uint16(38459), + 168: uint16(32452), + 169: uint16(38075), + 170: uint16(32386), + 171: uint16(22068), + 172: uint16(37257), + 173: uint16(26368), + 174: uint16(32618), + 175: uint16(23562), + 176: uint16(36981), + 177: uint16(26152), + 178: uint16(24038), + 179: uint16(20304), + 180: uint16(26590), + 181: uint16(20570), + 182: uint16(20316), + 183: uint16(22352), + 184: uint16(24231), + 185: uint16(59408), + 186: uint16(59409), + 187: uint16(59410), + 188: uint16(59411), + 189: uint16(59412), + }, + 87: { + 0: uint16(35896), + 1: uint16(35897), + 2: uint16(35898), + 3: uint16(35899), + 4: uint16(35900), + 5: uint16(35901), + 6: uint16(35902), + 7: uint16(35903), + 8: uint16(35904), + 9: uint16(35906), + 10: uint16(35907), + 11: uint16(35908), + 12: uint16(35909), + 13: uint16(35912), + 14: uint16(35914), + 15: uint16(35915), + 16: uint16(35917), + 17: uint16(35918), + 18: uint16(35919), + 19: uint16(35920), + 20: uint16(35921), + 21: uint16(35922), + 22: uint16(35923), + 23: uint16(35924), + 24: uint16(35926), + 25: uint16(35927), + 26: uint16(35928), + 27: uint16(35929), + 28: uint16(35931), + 29: uint16(35932), + 30: uint16(35933), + 31: uint16(35934), + 32: uint16(35935), + 33: uint16(35936), + 34: uint16(35939), + 35: uint16(35940), + 36: uint16(35941), + 37: uint16(35942), + 38: uint16(35943), + 39: uint16(35944), + 40: uint16(35945), + 41: uint16(35948), + 42: uint16(35949), + 43: uint16(35950), + 44: uint16(35951), + 45: uint16(35952), + 46: uint16(35953), + 47: uint16(35954), + 48: uint16(35956), + 49: uint16(35957), + 50: uint16(35958), + 51: uint16(35959), + 52: uint16(35963), + 53: uint16(35964), + 54: uint16(35965), + 55: uint16(35966), + 56: uint16(35967), + 57: uint16(35968), + 58: uint16(35969), + 59: uint16(35971), + 60: uint16(35972), + 61: uint16(35974), + 62: uint16(35975), + 63: uint16(35976), + 64: uint16(35979), + 65: uint16(35981), + 66: uint16(35982), + 67: uint16(35983), + 68: uint16(35984), + 69: uint16(35985), + 70: uint16(35986), + 71: uint16(35987), + 72: uint16(35989), + 73: uint16(35990), + 74: uint16(35991), + 75: uint16(35993), + 76: uint16(35994), + 77: uint16(35995), + 78: uint16(35996), + 79: uint16(35997), + 80: uint16(35998), + 81: uint16(35999), + 82: uint16(36000), + 83: uint16(36001), + 84: uint16(36002), + 85: uint16(36003), + 86: uint16(36004), + 87: uint16(36005), + 88: uint16(36006), + 89: uint16(36007), + 90: uint16(36008), + 91: uint16(36009), + 92: uint16(36010), + 93: uint16(36011), + 94: uint16(36012), + 95: uint16(36013), + 96: uint16(20109), + 97: uint16(19980), + 98: uint16(20800), + 99: uint16(19984), + 100: uint16(24319), + 101: uint16(21317), + 102: uint16(19989), + 103: uint16(20120), + 104: uint16(19998), + 105: uint16(39730), + 106: uint16(23404), + 107: uint16(22121), + 108: uint16(20008), + 109: uint16(31162), + 110: uint16(20031), + 111: uint16(21269), + 112: uint16(20039), + 113: uint16(22829), + 114: uint16(29243), + 115: uint16(21358), + 116: uint16(27664), + 117: uint16(22239), + 118: uint16(32996), + 119: uint16(39319), + 120: uint16(27603), + 121: uint16(30590), + 122: uint16(40727), + 123: uint16(20022), + 124: uint16(20127), + 125: uint16(40720), + 126: uint16(20060), + 127: uint16(20073), + 128: uint16(20115), + 129: uint16(33416), + 130: uint16(23387), + 131: uint16(21868), + 132: uint16(22031), + 133: uint16(20164), + 134: uint16(21389), + 135: uint16(21405), + 136: uint16(21411), + 137: uint16(21413), + 138: uint16(21422), + 139: uint16(38757), + 140: uint16(36189), + 141: uint16(21274), + 142: uint16(21493), + 143: uint16(21286), + 144: uint16(21294), + 145: uint16(21310), + 146: uint16(36188), + 147: uint16(21350), + 148: uint16(21347), + 149: uint16(20994), + 150: uint16(21000), + 151: uint16(21006), + 152: uint16(21037), + 153: uint16(21043), + 154: uint16(21055), + 155: uint16(21056), + 156: uint16(21068), + 157: uint16(21086), + 158: uint16(21089), + 159: uint16(21084), + 160: uint16(33967), + 161: uint16(21117), + 162: uint16(21122), + 163: uint16(21121), + 164: uint16(21136), + 165: uint16(21139), + 166: uint16(20866), + 167: uint16(32596), + 168: uint16(20155), + 169: uint16(20163), + 170: uint16(20169), + 171: uint16(20162), + 172: uint16(20200), + 173: uint16(20193), + 174: uint16(20203), + 175: uint16(20190), + 176: uint16(20251), + 177: uint16(20211), + 178: uint16(20258), + 179: uint16(20324), + 180: uint16(20213), + 181: uint16(20261), + 182: uint16(20263), + 183: uint16(20233), + 184: uint16(20267), + 185: uint16(20318), + 186: uint16(20327), + 187: uint16(25912), + 188: uint16(20314), + 189: uint16(20317), + }, + 88: { + 0: uint16(36014), + 1: uint16(36015), + 2: uint16(36016), + 3: uint16(36017), + 4: uint16(36018), + 5: uint16(36019), + 6: uint16(36020), + 7: uint16(36021), + 8: uint16(36022), + 9: uint16(36023), + 10: uint16(36024), + 11: uint16(36025), + 12: uint16(36026), + 13: uint16(36027), + 14: uint16(36028), + 15: uint16(36029), + 16: uint16(36030), + 17: uint16(36031), + 18: uint16(36032), + 19: uint16(36033), + 20: uint16(36034), + 21: uint16(36035), + 22: uint16(36036), + 23: uint16(36037), + 24: uint16(36038), + 25: uint16(36039), + 26: uint16(36040), + 27: uint16(36041), + 28: uint16(36042), + 29: uint16(36043), + 30: uint16(36044), + 31: uint16(36045), + 32: uint16(36046), + 33: uint16(36047), + 34: uint16(36048), + 35: uint16(36049), + 36: uint16(36050), + 37: uint16(36051), + 38: uint16(36052), + 39: uint16(36053), + 40: uint16(36054), + 41: uint16(36055), + 42: uint16(36056), + 43: uint16(36057), + 44: uint16(36058), + 45: uint16(36059), + 46: uint16(36060), + 47: uint16(36061), + 48: uint16(36062), + 49: uint16(36063), + 50: uint16(36064), + 51: uint16(36065), + 52: uint16(36066), + 53: uint16(36067), + 54: uint16(36068), + 55: uint16(36069), + 56: uint16(36070), + 57: uint16(36071), + 58: uint16(36072), + 59: uint16(36073), + 60: uint16(36074), + 61: uint16(36075), + 62: uint16(36076), + 63: uint16(36077), + 64: uint16(36078), + 65: uint16(36079), + 66: uint16(36080), + 67: uint16(36081), + 68: uint16(36082), + 69: uint16(36083), + 70: uint16(36084), + 71: uint16(36085), + 72: uint16(36086), + 73: uint16(36087), + 74: uint16(36088), + 75: uint16(36089), + 76: uint16(36090), + 77: uint16(36091), + 78: uint16(36092), + 79: uint16(36093), + 80: uint16(36094), + 81: uint16(36095), + 82: uint16(36096), + 83: uint16(36097), + 84: uint16(36098), + 85: uint16(36099), + 86: uint16(36100), + 87: uint16(36101), + 88: uint16(36102), + 89: uint16(36103), + 90: uint16(36104), + 91: uint16(36105), + 92: uint16(36106), + 93: uint16(36107), + 94: uint16(36108), + 95: uint16(36109), + 96: uint16(20319), + 97: uint16(20311), + 98: uint16(20274), + 99: uint16(20285), + 100: uint16(20342), + 101: uint16(20340), + 102: uint16(20369), + 103: uint16(20361), + 104: uint16(20355), + 105: uint16(20367), + 106: uint16(20350), + 107: uint16(20347), + 108: uint16(20394), + 109: uint16(20348), + 110: uint16(20396), + 111: uint16(20372), + 112: uint16(20454), + 113: uint16(20456), + 114: uint16(20458), + 115: uint16(20421), + 116: uint16(20442), + 117: uint16(20451), + 118: uint16(20444), + 119: uint16(20433), + 120: uint16(20447), + 121: uint16(20472), + 122: uint16(20521), + 123: uint16(20556), + 124: uint16(20467), + 125: uint16(20524), + 126: uint16(20495), + 127: uint16(20526), + 128: uint16(20525), + 129: uint16(20478), + 130: uint16(20508), + 131: uint16(20492), + 132: uint16(20517), + 133: uint16(20520), + 134: uint16(20606), + 135: uint16(20547), + 136: uint16(20565), + 137: uint16(20552), + 138: uint16(20558), + 139: uint16(20588), + 140: uint16(20603), + 141: uint16(20645), + 142: uint16(20647), + 143: uint16(20649), + 144: uint16(20666), + 145: uint16(20694), + 146: uint16(20742), + 147: uint16(20717), + 148: uint16(20716), + 149: uint16(20710), + 150: uint16(20718), + 151: uint16(20743), + 152: uint16(20747), + 153: uint16(20189), + 154: uint16(27709), + 155: uint16(20312), + 156: uint16(20325), + 157: uint16(20430), + 158: uint16(40864), + 159: uint16(27718), + 160: uint16(31860), + 161: uint16(20846), + 162: uint16(24061), + 163: uint16(40649), + 164: uint16(39320), + 165: uint16(20865), + 166: uint16(22804), + 167: uint16(21241), + 168: uint16(21261), + 169: uint16(35335), + 170: uint16(21264), + 171: uint16(20971), + 172: uint16(22809), + 173: uint16(20821), + 174: uint16(20128), + 175: uint16(20822), + 176: uint16(20147), + 177: uint16(34926), + 178: uint16(34980), + 179: uint16(20149), + 180: uint16(33044), + 181: uint16(35026), + 182: uint16(31104), + 183: uint16(23348), + 184: uint16(34819), + 185: uint16(32696), + 186: uint16(20907), + 187: uint16(20913), + 188: uint16(20925), + 189: uint16(20924), + }, + 89: { + 0: uint16(36110), + 1: uint16(36111), + 2: uint16(36112), + 3: uint16(36113), + 4: uint16(36114), + 5: uint16(36115), + 6: uint16(36116), + 7: uint16(36117), + 8: uint16(36118), + 9: uint16(36119), + 10: uint16(36120), + 11: uint16(36121), + 12: uint16(36122), + 13: uint16(36123), + 14: uint16(36124), + 15: uint16(36128), + 16: uint16(36177), + 17: uint16(36178), + 18: uint16(36183), + 19: uint16(36191), + 20: uint16(36197), + 21: uint16(36200), + 22: uint16(36201), + 23: uint16(36202), + 24: uint16(36204), + 25: uint16(36206), + 26: uint16(36207), + 27: uint16(36209), + 28: uint16(36210), + 29: uint16(36216), + 30: uint16(36217), + 31: uint16(36218), + 32: uint16(36219), + 33: uint16(36220), + 34: uint16(36221), + 35: uint16(36222), + 36: uint16(36223), + 37: uint16(36224), + 38: uint16(36226), + 39: uint16(36227), + 40: uint16(36230), + 41: uint16(36231), + 42: uint16(36232), + 43: uint16(36233), + 44: uint16(36236), + 45: uint16(36237), + 46: uint16(36238), + 47: uint16(36239), + 48: uint16(36240), + 49: uint16(36242), + 50: uint16(36243), + 51: uint16(36245), + 52: uint16(36246), + 53: uint16(36247), + 54: uint16(36248), + 55: uint16(36249), + 56: uint16(36250), + 57: uint16(36251), + 58: uint16(36252), + 59: uint16(36253), + 60: uint16(36254), + 61: uint16(36256), + 62: uint16(36257), + 63: uint16(36258), + 64: uint16(36260), + 65: uint16(36261), + 66: uint16(36262), + 67: uint16(36263), + 68: uint16(36264), + 69: uint16(36265), + 70: uint16(36266), + 71: uint16(36267), + 72: uint16(36268), + 73: uint16(36269), + 74: uint16(36270), + 75: uint16(36271), + 76: uint16(36272), + 77: uint16(36274), + 78: uint16(36278), + 79: uint16(36279), + 80: uint16(36281), + 81: uint16(36283), + 82: uint16(36285), + 83: uint16(36288), + 84: uint16(36289), + 85: uint16(36290), + 86: uint16(36293), + 87: uint16(36295), + 88: uint16(36296), + 89: uint16(36297), + 90: uint16(36298), + 91: uint16(36301), + 92: uint16(36304), + 93: uint16(36306), + 94: uint16(36307), + 95: uint16(36308), + 96: uint16(20935), + 97: uint16(20886), + 98: uint16(20898), + 99: uint16(20901), + 100: uint16(35744), + 101: uint16(35750), + 102: uint16(35751), + 103: uint16(35754), + 104: uint16(35764), + 105: uint16(35765), + 106: uint16(35767), + 107: uint16(35778), + 108: uint16(35779), + 109: uint16(35787), + 110: uint16(35791), + 111: uint16(35790), + 112: uint16(35794), + 113: uint16(35795), + 114: uint16(35796), + 115: uint16(35798), + 116: uint16(35800), + 117: uint16(35801), + 118: uint16(35804), + 119: uint16(35807), + 120: uint16(35808), + 121: uint16(35812), + 122: uint16(35816), + 123: uint16(35817), + 124: uint16(35822), + 125: uint16(35824), + 126: uint16(35827), + 127: uint16(35830), + 128: uint16(35833), + 129: uint16(35836), + 130: uint16(35839), + 131: uint16(35840), + 132: uint16(35842), + 133: uint16(35844), + 134: uint16(35847), + 135: uint16(35852), + 136: uint16(35855), + 137: uint16(35857), + 138: uint16(35858), + 139: uint16(35860), + 140: uint16(35861), + 141: uint16(35862), + 142: uint16(35865), + 143: uint16(35867), + 144: uint16(35864), + 145: uint16(35869), + 146: uint16(35871), + 147: uint16(35872), + 148: uint16(35873), + 149: uint16(35877), + 150: uint16(35879), + 151: uint16(35882), + 152: uint16(35883), + 153: uint16(35886), + 154: uint16(35887), + 155: uint16(35890), + 156: uint16(35891), + 157: uint16(35893), + 158: uint16(35894), + 159: uint16(21353), + 160: uint16(21370), + 161: uint16(38429), + 162: uint16(38434), + 163: uint16(38433), + 164: uint16(38449), + 165: uint16(38442), + 166: uint16(38461), + 167: uint16(38460), + 168: uint16(38466), + 169: uint16(38473), + 170: uint16(38484), + 171: uint16(38495), + 172: uint16(38503), + 173: uint16(38508), + 174: uint16(38514), + 175: uint16(38516), + 176: uint16(38536), + 177: uint16(38541), + 178: uint16(38551), + 179: uint16(38576), + 180: uint16(37015), + 181: uint16(37019), + 182: uint16(37021), + 183: uint16(37017), + 184: uint16(37036), + 185: uint16(37025), + 186: uint16(37044), + 187: uint16(37043), + 188: uint16(37046), + 189: uint16(37050), + }, + 90: { + 0: uint16(36309), + 1: uint16(36312), + 2: uint16(36313), + 3: uint16(36316), + 4: uint16(36320), + 5: uint16(36321), + 6: uint16(36322), + 7: uint16(36325), + 8: uint16(36326), + 9: uint16(36327), + 10: uint16(36329), + 11: uint16(36333), + 12: uint16(36334), + 13: uint16(36336), + 14: uint16(36337), + 15: uint16(36338), + 16: uint16(36340), + 17: uint16(36342), + 18: uint16(36348), + 19: uint16(36350), + 20: uint16(36351), + 21: uint16(36352), + 22: uint16(36353), + 23: uint16(36354), + 24: uint16(36355), + 25: uint16(36356), + 26: uint16(36358), + 27: uint16(36359), + 28: uint16(36360), + 29: uint16(36363), + 30: uint16(36365), + 31: uint16(36366), + 32: uint16(36368), + 33: uint16(36369), + 34: uint16(36370), + 35: uint16(36371), + 36: uint16(36373), + 37: uint16(36374), + 38: uint16(36375), + 39: uint16(36376), + 40: uint16(36377), + 41: uint16(36378), + 42: uint16(36379), + 43: uint16(36380), + 44: uint16(36384), + 45: uint16(36385), + 46: uint16(36388), + 47: uint16(36389), + 48: uint16(36390), + 49: uint16(36391), + 50: uint16(36392), + 51: uint16(36395), + 52: uint16(36397), + 53: uint16(36400), + 54: uint16(36402), + 55: uint16(36403), + 56: uint16(36404), + 57: uint16(36406), + 58: uint16(36407), + 59: uint16(36408), + 60: uint16(36411), + 61: uint16(36412), + 62: uint16(36414), + 63: uint16(36415), + 64: uint16(36419), + 65: uint16(36421), + 66: uint16(36422), + 67: uint16(36428), + 68: uint16(36429), + 69: uint16(36430), + 70: uint16(36431), + 71: uint16(36432), + 72: uint16(36435), + 73: uint16(36436), + 74: uint16(36437), + 75: uint16(36438), + 76: uint16(36439), + 77: uint16(36440), + 78: uint16(36442), + 79: uint16(36443), + 80: uint16(36444), + 81: uint16(36445), + 82: uint16(36446), + 83: uint16(36447), + 84: uint16(36448), + 85: uint16(36449), + 86: uint16(36450), + 87: uint16(36451), + 88: uint16(36452), + 89: uint16(36453), + 90: uint16(36455), + 91: uint16(36456), + 92: uint16(36458), + 93: uint16(36459), + 94: uint16(36462), + 95: uint16(36465), + 96: uint16(37048), + 97: uint16(37040), + 98: uint16(37071), + 99: uint16(37061), + 100: uint16(37054), + 101: uint16(37072), + 102: uint16(37060), + 103: uint16(37063), + 104: uint16(37075), + 105: uint16(37094), + 106: uint16(37090), + 107: uint16(37084), + 108: uint16(37079), + 109: uint16(37083), + 110: uint16(37099), + 111: uint16(37103), + 112: uint16(37118), + 113: uint16(37124), + 114: uint16(37154), + 115: uint16(37150), + 116: uint16(37155), + 117: uint16(37169), + 118: uint16(37167), + 119: uint16(37177), + 120: uint16(37187), + 121: uint16(37190), + 122: uint16(21005), + 123: uint16(22850), + 124: uint16(21154), + 125: uint16(21164), + 126: uint16(21165), + 127: uint16(21182), + 128: uint16(21759), + 129: uint16(21200), + 130: uint16(21206), + 131: uint16(21232), + 132: uint16(21471), + 133: uint16(29166), + 134: uint16(30669), + 135: uint16(24308), + 136: uint16(20981), + 137: uint16(20988), + 138: uint16(39727), + 139: uint16(21430), + 140: uint16(24321), + 141: uint16(30042), + 142: uint16(24047), + 143: uint16(22348), + 144: uint16(22441), + 145: uint16(22433), + 146: uint16(22654), + 147: uint16(22716), + 148: uint16(22725), + 149: uint16(22737), + 150: uint16(22313), + 151: uint16(22316), + 152: uint16(22314), + 153: uint16(22323), + 154: uint16(22329), + 155: uint16(22318), + 156: uint16(22319), + 157: uint16(22364), + 158: uint16(22331), + 159: uint16(22338), + 160: uint16(22377), + 161: uint16(22405), + 162: uint16(22379), + 163: uint16(22406), + 164: uint16(22396), + 165: uint16(22395), + 166: uint16(22376), + 167: uint16(22381), + 168: uint16(22390), + 169: uint16(22387), + 170: uint16(22445), + 171: uint16(22436), + 172: uint16(22412), + 173: uint16(22450), + 174: uint16(22479), + 175: uint16(22439), + 176: uint16(22452), + 177: uint16(22419), + 178: uint16(22432), + 179: uint16(22485), + 180: uint16(22488), + 181: uint16(22490), + 182: uint16(22489), + 183: uint16(22482), + 184: uint16(22456), + 185: uint16(22516), + 186: uint16(22511), + 187: uint16(22520), + 188: uint16(22500), + 189: uint16(22493), + }, + 91: { + 0: uint16(36467), + 1: uint16(36469), + 2: uint16(36471), + 3: uint16(36472), + 4: uint16(36473), + 5: uint16(36474), + 6: uint16(36475), + 7: uint16(36477), + 8: uint16(36478), + 9: uint16(36480), + 10: uint16(36482), + 11: uint16(36483), + 12: uint16(36484), + 13: uint16(36486), + 14: uint16(36488), + 15: uint16(36489), + 16: uint16(36490), + 17: uint16(36491), + 18: uint16(36492), + 19: uint16(36493), + 20: uint16(36494), + 21: uint16(36497), + 22: uint16(36498), + 23: uint16(36499), + 24: uint16(36501), + 25: uint16(36502), + 26: uint16(36503), + 27: uint16(36504), + 28: uint16(36505), + 29: uint16(36506), + 30: uint16(36507), + 31: uint16(36509), + 32: uint16(36511), + 33: uint16(36512), + 34: uint16(36513), + 35: uint16(36514), + 36: uint16(36515), + 37: uint16(36516), + 38: uint16(36517), + 39: uint16(36518), + 40: uint16(36519), + 41: uint16(36520), + 42: uint16(36521), + 43: uint16(36522), + 44: uint16(36525), + 45: uint16(36526), + 46: uint16(36528), + 47: uint16(36529), + 48: uint16(36531), + 49: uint16(36532), + 50: uint16(36533), + 51: uint16(36534), + 52: uint16(36535), + 53: uint16(36536), + 54: uint16(36537), + 55: uint16(36539), + 56: uint16(36540), + 57: uint16(36541), + 58: uint16(36542), + 59: uint16(36543), + 60: uint16(36544), + 61: uint16(36545), + 62: uint16(36546), + 63: uint16(36547), + 64: uint16(36548), + 65: uint16(36549), + 66: uint16(36550), + 67: uint16(36551), + 68: uint16(36552), + 69: uint16(36553), + 70: uint16(36554), + 71: uint16(36555), + 72: uint16(36556), + 73: uint16(36557), + 74: uint16(36559), + 75: uint16(36560), + 76: uint16(36561), + 77: uint16(36562), + 78: uint16(36563), + 79: uint16(36564), + 80: uint16(36565), + 81: uint16(36566), + 82: uint16(36567), + 83: uint16(36568), + 84: uint16(36569), + 85: uint16(36570), + 86: uint16(36571), + 87: uint16(36572), + 88: uint16(36573), + 89: uint16(36574), + 90: uint16(36575), + 91: uint16(36576), + 92: uint16(36577), + 93: uint16(36578), + 94: uint16(36579), + 95: uint16(36580), + 96: uint16(22539), + 97: uint16(22541), + 98: uint16(22525), + 99: uint16(22509), + 100: uint16(22528), + 101: uint16(22558), + 102: uint16(22553), + 103: uint16(22596), + 104: uint16(22560), + 105: uint16(22629), + 106: uint16(22636), + 107: uint16(22657), + 108: uint16(22665), + 109: uint16(22682), + 110: uint16(22656), + 111: uint16(39336), + 112: uint16(40729), + 113: uint16(25087), + 114: uint16(33401), + 115: uint16(33405), + 116: uint16(33407), + 117: uint16(33423), + 118: uint16(33418), + 119: uint16(33448), + 120: uint16(33412), + 121: uint16(33422), + 122: uint16(33425), + 123: uint16(33431), + 124: uint16(33433), + 125: uint16(33451), + 126: uint16(33464), + 127: uint16(33470), + 128: uint16(33456), + 129: uint16(33480), + 130: uint16(33482), + 131: uint16(33507), + 132: uint16(33432), + 133: uint16(33463), + 134: uint16(33454), + 135: uint16(33483), + 136: uint16(33484), + 137: uint16(33473), + 138: uint16(33449), + 139: uint16(33460), + 140: uint16(33441), + 141: uint16(33450), + 142: uint16(33439), + 143: uint16(33476), + 144: uint16(33486), + 145: uint16(33444), + 146: uint16(33505), + 147: uint16(33545), + 148: uint16(33527), + 149: uint16(33508), + 150: uint16(33551), + 151: uint16(33543), + 152: uint16(33500), + 153: uint16(33524), + 154: uint16(33490), + 155: uint16(33496), + 156: uint16(33548), + 157: uint16(33531), + 158: uint16(33491), + 159: uint16(33553), + 160: uint16(33562), + 161: uint16(33542), + 162: uint16(33556), + 163: uint16(33557), + 164: uint16(33504), + 165: uint16(33493), + 166: uint16(33564), + 167: uint16(33617), + 168: uint16(33627), + 169: uint16(33628), + 170: uint16(33544), + 171: uint16(33682), + 172: uint16(33596), + 173: uint16(33588), + 174: uint16(33585), + 175: uint16(33691), + 176: uint16(33630), + 177: uint16(33583), + 178: uint16(33615), + 179: uint16(33607), + 180: uint16(33603), + 181: uint16(33631), + 182: uint16(33600), + 183: uint16(33559), + 184: uint16(33632), + 185: uint16(33581), + 186: uint16(33594), + 187: uint16(33587), + 188: uint16(33638), + 189: uint16(33637), + }, + 92: { + 0: uint16(36581), + 1: uint16(36582), + 2: uint16(36583), + 3: uint16(36584), + 4: uint16(36585), + 5: uint16(36586), + 6: uint16(36587), + 7: uint16(36588), + 8: uint16(36589), + 9: uint16(36590), + 10: uint16(36591), + 11: uint16(36592), + 12: uint16(36593), + 13: uint16(36594), + 14: uint16(36595), + 15: uint16(36596), + 16: uint16(36597), + 17: uint16(36598), + 18: uint16(36599), + 19: uint16(36600), + 20: uint16(36601), + 21: uint16(36602), + 22: uint16(36603), + 23: uint16(36604), + 24: uint16(36605), + 25: uint16(36606), + 26: uint16(36607), + 27: uint16(36608), + 28: uint16(36609), + 29: uint16(36610), + 30: uint16(36611), + 31: uint16(36612), + 32: uint16(36613), + 33: uint16(36614), + 34: uint16(36615), + 35: uint16(36616), + 36: uint16(36617), + 37: uint16(36618), + 38: uint16(36619), + 39: uint16(36620), + 40: uint16(36621), + 41: uint16(36622), + 42: uint16(36623), + 43: uint16(36624), + 44: uint16(36625), + 45: uint16(36626), + 46: uint16(36627), + 47: uint16(36628), + 48: uint16(36629), + 49: uint16(36630), + 50: uint16(36631), + 51: uint16(36632), + 52: uint16(36633), + 53: uint16(36634), + 54: uint16(36635), + 55: uint16(36636), + 56: uint16(36637), + 57: uint16(36638), + 58: uint16(36639), + 59: uint16(36640), + 60: uint16(36641), + 61: uint16(36642), + 62: uint16(36643), + 63: uint16(36644), + 64: uint16(36645), + 65: uint16(36646), + 66: uint16(36647), + 67: uint16(36648), + 68: uint16(36649), + 69: uint16(36650), + 70: uint16(36651), + 71: uint16(36652), + 72: uint16(36653), + 73: uint16(36654), + 74: uint16(36655), + 75: uint16(36656), + 76: uint16(36657), + 77: uint16(36658), + 78: uint16(36659), + 79: uint16(36660), + 80: uint16(36661), + 81: uint16(36662), + 82: uint16(36663), + 83: uint16(36664), + 84: uint16(36665), + 85: uint16(36666), + 86: uint16(36667), + 87: uint16(36668), + 88: uint16(36669), + 89: uint16(36670), + 90: uint16(36671), + 91: uint16(36672), + 92: uint16(36673), + 93: uint16(36674), + 94: uint16(36675), + 95: uint16(36676), + 96: uint16(33640), + 97: uint16(33563), + 98: uint16(33641), + 99: uint16(33644), + 100: uint16(33642), + 101: uint16(33645), + 102: uint16(33646), + 103: uint16(33712), + 104: uint16(33656), + 105: uint16(33715), + 106: uint16(33716), + 107: uint16(33696), + 108: uint16(33706), + 109: uint16(33683), + 110: uint16(33692), + 111: uint16(33669), + 112: uint16(33660), + 113: uint16(33718), + 114: uint16(33705), + 115: uint16(33661), + 116: uint16(33720), + 117: uint16(33659), + 118: uint16(33688), + 119: uint16(33694), + 120: uint16(33704), + 121: uint16(33722), + 122: uint16(33724), + 123: uint16(33729), + 124: uint16(33793), + 125: uint16(33765), + 126: uint16(33752), + 127: uint16(22535), + 128: uint16(33816), + 129: uint16(33803), + 130: uint16(33757), + 131: uint16(33789), + 132: uint16(33750), + 133: uint16(33820), + 134: uint16(33848), + 135: uint16(33809), + 136: uint16(33798), + 137: uint16(33748), + 138: uint16(33759), + 139: uint16(33807), + 140: uint16(33795), + 141: uint16(33784), + 142: uint16(33785), + 143: uint16(33770), + 144: uint16(33733), + 145: uint16(33728), + 146: uint16(33830), + 147: uint16(33776), + 148: uint16(33761), + 149: uint16(33884), + 150: uint16(33873), + 151: uint16(33882), + 152: uint16(33881), + 153: uint16(33907), + 154: uint16(33927), + 155: uint16(33928), + 156: uint16(33914), + 157: uint16(33929), + 158: uint16(33912), + 159: uint16(33852), + 160: uint16(33862), + 161: uint16(33897), + 162: uint16(33910), + 163: uint16(33932), + 164: uint16(33934), + 165: uint16(33841), + 166: uint16(33901), + 167: uint16(33985), + 168: uint16(33997), + 169: uint16(34000), + 170: uint16(34022), + 171: uint16(33981), + 172: uint16(34003), + 173: uint16(33994), + 174: uint16(33983), + 175: uint16(33978), + 176: uint16(34016), + 177: uint16(33953), + 178: uint16(33977), + 179: uint16(33972), + 180: uint16(33943), + 181: uint16(34021), + 182: uint16(34019), + 183: uint16(34060), + 184: uint16(29965), + 185: uint16(34104), + 186: uint16(34032), + 187: uint16(34105), + 188: uint16(34079), + 189: uint16(34106), + }, + 93: { + 0: uint16(36677), + 1: uint16(36678), + 2: uint16(36679), + 3: uint16(36680), + 4: uint16(36681), + 5: uint16(36682), + 6: uint16(36683), + 7: uint16(36684), + 8: uint16(36685), + 9: uint16(36686), + 10: uint16(36687), + 11: uint16(36688), + 12: uint16(36689), + 13: uint16(36690), + 14: uint16(36691), + 15: uint16(36692), + 16: uint16(36693), + 17: uint16(36694), + 18: uint16(36695), + 19: uint16(36696), + 20: uint16(36697), + 21: uint16(36698), + 22: uint16(36699), + 23: uint16(36700), + 24: uint16(36701), + 25: uint16(36702), + 26: uint16(36703), + 27: uint16(36704), + 28: uint16(36705), + 29: uint16(36706), + 30: uint16(36707), + 31: uint16(36708), + 32: uint16(36709), + 33: uint16(36714), + 34: uint16(36736), + 35: uint16(36748), + 36: uint16(36754), + 37: uint16(36765), + 38: uint16(36768), + 39: uint16(36769), + 40: uint16(36770), + 41: uint16(36772), + 42: uint16(36773), + 43: uint16(36774), + 44: uint16(36775), + 45: uint16(36778), + 46: uint16(36780), + 47: uint16(36781), + 48: uint16(36782), + 49: uint16(36783), + 50: uint16(36786), + 51: uint16(36787), + 52: uint16(36788), + 53: uint16(36789), + 54: uint16(36791), + 55: uint16(36792), + 56: uint16(36794), + 57: uint16(36795), + 58: uint16(36796), + 59: uint16(36799), + 60: uint16(36800), + 61: uint16(36803), + 62: uint16(36806), + 63: uint16(36809), + 64: uint16(36810), + 65: uint16(36811), + 66: uint16(36812), + 67: uint16(36813), + 68: uint16(36815), + 69: uint16(36818), + 70: uint16(36822), + 71: uint16(36823), + 72: uint16(36826), + 73: uint16(36832), + 74: uint16(36833), + 75: uint16(36835), + 76: uint16(36839), + 77: uint16(36844), + 78: uint16(36847), + 79: uint16(36849), + 80: uint16(36850), + 81: uint16(36852), + 82: uint16(36853), + 83: uint16(36854), + 84: uint16(36858), + 85: uint16(36859), + 86: uint16(36860), + 87: uint16(36862), + 88: uint16(36863), + 89: uint16(36871), + 90: uint16(36872), + 91: uint16(36876), + 92: uint16(36878), + 93: uint16(36883), + 94: uint16(36885), + 95: uint16(36888), + 96: uint16(34134), + 97: uint16(34107), + 98: uint16(34047), + 99: uint16(34044), + 100: uint16(34137), + 101: uint16(34120), + 102: uint16(34152), + 103: uint16(34148), + 104: uint16(34142), + 105: uint16(34170), + 106: uint16(30626), + 107: uint16(34115), + 108: uint16(34162), + 109: uint16(34171), + 110: uint16(34212), + 111: uint16(34216), + 112: uint16(34183), + 113: uint16(34191), + 114: uint16(34169), + 115: uint16(34222), + 116: uint16(34204), + 117: uint16(34181), + 118: uint16(34233), + 119: uint16(34231), + 120: uint16(34224), + 121: uint16(34259), + 122: uint16(34241), + 123: uint16(34268), + 124: uint16(34303), + 125: uint16(34343), + 126: uint16(34309), + 127: uint16(34345), + 128: uint16(34326), + 129: uint16(34364), + 130: uint16(24318), + 131: uint16(24328), + 132: uint16(22844), + 133: uint16(22849), + 134: uint16(32823), + 135: uint16(22869), + 136: uint16(22874), + 137: uint16(22872), + 138: uint16(21263), + 139: uint16(23586), + 140: uint16(23589), + 141: uint16(23596), + 142: uint16(23604), + 143: uint16(25164), + 144: uint16(25194), + 145: uint16(25247), + 146: uint16(25275), + 147: uint16(25290), + 148: uint16(25306), + 149: uint16(25303), + 150: uint16(25326), + 151: uint16(25378), + 152: uint16(25334), + 153: uint16(25401), + 154: uint16(25419), + 155: uint16(25411), + 156: uint16(25517), + 157: uint16(25590), + 158: uint16(25457), + 159: uint16(25466), + 160: uint16(25486), + 161: uint16(25524), + 162: uint16(25453), + 163: uint16(25516), + 164: uint16(25482), + 165: uint16(25449), + 166: uint16(25518), + 167: uint16(25532), + 168: uint16(25586), + 169: uint16(25592), + 170: uint16(25568), + 171: uint16(25599), + 172: uint16(25540), + 173: uint16(25566), + 174: uint16(25550), + 175: uint16(25682), + 176: uint16(25542), + 177: uint16(25534), + 178: uint16(25669), + 179: uint16(25665), + 180: uint16(25611), + 181: uint16(25627), + 182: uint16(25632), + 183: uint16(25612), + 184: uint16(25638), + 185: uint16(25633), + 186: uint16(25694), + 187: uint16(25732), + 188: uint16(25709), + 189: uint16(25750), + }, + 94: { + 0: uint16(36889), + 1: uint16(36892), + 2: uint16(36899), + 3: uint16(36900), + 4: uint16(36901), + 5: uint16(36903), + 6: uint16(36904), + 7: uint16(36905), + 8: uint16(36906), + 9: uint16(36907), + 10: uint16(36908), + 11: uint16(36912), + 12: uint16(36913), + 13: uint16(36914), + 14: uint16(36915), + 15: uint16(36916), + 16: uint16(36919), + 17: uint16(36921), + 18: uint16(36922), + 19: uint16(36925), + 20: uint16(36927), + 21: uint16(36928), + 22: uint16(36931), + 23: uint16(36933), + 24: uint16(36934), + 25: uint16(36936), + 26: uint16(36937), + 27: uint16(36938), + 28: uint16(36939), + 29: uint16(36940), + 30: uint16(36942), + 31: uint16(36948), + 32: uint16(36949), + 33: uint16(36950), + 34: uint16(36953), + 35: uint16(36954), + 36: uint16(36956), + 37: uint16(36957), + 38: uint16(36958), + 39: uint16(36959), + 40: uint16(36960), + 41: uint16(36961), + 42: uint16(36964), + 43: uint16(36966), + 44: uint16(36967), + 45: uint16(36969), + 46: uint16(36970), + 47: uint16(36971), + 48: uint16(36972), + 49: uint16(36975), + 50: uint16(36976), + 51: uint16(36977), + 52: uint16(36978), + 53: uint16(36979), + 54: uint16(36982), + 55: uint16(36983), + 56: uint16(36984), + 57: uint16(36985), + 58: uint16(36986), + 59: uint16(36987), + 60: uint16(36988), + 61: uint16(36990), + 62: uint16(36993), + 63: uint16(36996), + 64: uint16(36997), + 65: uint16(36998), + 66: uint16(36999), + 67: uint16(37001), + 68: uint16(37002), + 69: uint16(37004), + 70: uint16(37005), + 71: uint16(37006), + 72: uint16(37007), + 73: uint16(37008), + 74: uint16(37010), + 75: uint16(37012), + 76: uint16(37014), + 77: uint16(37016), + 78: uint16(37018), + 79: uint16(37020), + 80: uint16(37022), + 81: uint16(37023), + 82: uint16(37024), + 83: uint16(37028), + 84: uint16(37029), + 85: uint16(37031), + 86: uint16(37032), + 87: uint16(37033), + 88: uint16(37035), + 89: uint16(37037), + 90: uint16(37042), + 91: uint16(37047), + 92: uint16(37052), + 93: uint16(37053), + 94: uint16(37055), + 95: uint16(37056), + 96: uint16(25722), + 97: uint16(25783), + 98: uint16(25784), + 99: uint16(25753), + 100: uint16(25786), + 101: uint16(25792), + 102: uint16(25808), + 103: uint16(25815), + 104: uint16(25828), + 105: uint16(25826), + 106: uint16(25865), + 107: uint16(25893), + 108: uint16(25902), + 109: uint16(24331), + 110: uint16(24530), + 111: uint16(29977), + 112: uint16(24337), + 113: uint16(21343), + 114: uint16(21489), + 115: uint16(21501), + 116: uint16(21481), + 117: uint16(21480), + 118: uint16(21499), + 119: uint16(21522), + 120: uint16(21526), + 121: uint16(21510), + 122: uint16(21579), + 123: uint16(21586), + 124: uint16(21587), + 125: uint16(21588), + 126: uint16(21590), + 127: uint16(21571), + 128: uint16(21537), + 129: uint16(21591), + 130: uint16(21593), + 131: uint16(21539), + 132: uint16(21554), + 133: uint16(21634), + 134: uint16(21652), + 135: uint16(21623), + 136: uint16(21617), + 137: uint16(21604), + 138: uint16(21658), + 139: uint16(21659), + 140: uint16(21636), + 141: uint16(21622), + 142: uint16(21606), + 143: uint16(21661), + 144: uint16(21712), + 145: uint16(21677), + 146: uint16(21698), + 147: uint16(21684), + 148: uint16(21714), + 149: uint16(21671), + 150: uint16(21670), + 151: uint16(21715), + 152: uint16(21716), + 153: uint16(21618), + 154: uint16(21667), + 155: uint16(21717), + 156: uint16(21691), + 157: uint16(21695), + 158: uint16(21708), + 159: uint16(21721), + 160: uint16(21722), + 161: uint16(21724), + 162: uint16(21673), + 163: uint16(21674), + 164: uint16(21668), + 165: uint16(21725), + 166: uint16(21711), + 167: uint16(21726), + 168: uint16(21787), + 169: uint16(21735), + 170: uint16(21792), + 171: uint16(21757), + 172: uint16(21780), + 173: uint16(21747), + 174: uint16(21794), + 175: uint16(21795), + 176: uint16(21775), + 177: uint16(21777), + 178: uint16(21799), + 179: uint16(21802), + 180: uint16(21863), + 181: uint16(21903), + 182: uint16(21941), + 183: uint16(21833), + 184: uint16(21869), + 185: uint16(21825), + 186: uint16(21845), + 187: uint16(21823), + 188: uint16(21840), + 189: uint16(21820), + }, + 95: { + 0: uint16(37058), + 1: uint16(37059), + 2: uint16(37062), + 3: uint16(37064), + 4: uint16(37065), + 5: uint16(37067), + 6: uint16(37068), + 7: uint16(37069), + 8: uint16(37074), + 9: uint16(37076), + 10: uint16(37077), + 11: uint16(37078), + 12: uint16(37080), + 13: uint16(37081), + 14: uint16(37082), + 15: uint16(37086), + 16: uint16(37087), + 17: uint16(37088), + 18: uint16(37091), + 19: uint16(37092), + 20: uint16(37093), + 21: uint16(37097), + 22: uint16(37098), + 23: uint16(37100), + 24: uint16(37102), + 25: uint16(37104), + 26: uint16(37105), + 27: uint16(37106), + 28: uint16(37107), + 29: uint16(37109), + 30: uint16(37110), + 31: uint16(37111), + 32: uint16(37113), + 33: uint16(37114), + 34: uint16(37115), + 35: uint16(37116), + 36: uint16(37119), + 37: uint16(37120), + 38: uint16(37121), + 39: uint16(37123), + 40: uint16(37125), + 41: uint16(37126), + 42: uint16(37127), + 43: uint16(37128), + 44: uint16(37129), + 45: uint16(37130), + 46: uint16(37131), + 47: uint16(37132), + 48: uint16(37133), + 49: uint16(37134), + 50: uint16(37135), + 51: uint16(37136), + 52: uint16(37137), + 53: uint16(37138), + 54: uint16(37139), + 55: uint16(37140), + 56: uint16(37141), + 57: uint16(37142), + 58: uint16(37143), + 59: uint16(37144), + 60: uint16(37146), + 61: uint16(37147), + 62: uint16(37148), + 63: uint16(37149), + 64: uint16(37151), + 65: uint16(37152), + 66: uint16(37153), + 67: uint16(37156), + 68: uint16(37157), + 69: uint16(37158), + 70: uint16(37159), + 71: uint16(37160), + 72: uint16(37161), + 73: uint16(37162), + 74: uint16(37163), + 75: uint16(37164), + 76: uint16(37165), + 77: uint16(37166), + 78: uint16(37168), + 79: uint16(37170), + 80: uint16(37171), + 81: uint16(37172), + 82: uint16(37173), + 83: uint16(37174), + 84: uint16(37175), + 85: uint16(37176), + 86: uint16(37178), + 87: uint16(37179), + 88: uint16(37180), + 89: uint16(37181), + 90: uint16(37182), + 91: uint16(37183), + 92: uint16(37184), + 93: uint16(37185), + 94: uint16(37186), + 95: uint16(37188), + 96: uint16(21815), + 97: uint16(21846), + 98: uint16(21877), + 99: uint16(21878), + 100: uint16(21879), + 101: uint16(21811), + 102: uint16(21808), + 103: uint16(21852), + 104: uint16(21899), + 105: uint16(21970), + 106: uint16(21891), + 107: uint16(21937), + 108: uint16(21945), + 109: uint16(21896), + 110: uint16(21889), + 111: uint16(21919), + 112: uint16(21886), + 113: uint16(21974), + 114: uint16(21905), + 115: uint16(21883), + 116: uint16(21983), + 117: uint16(21949), + 118: uint16(21950), + 119: uint16(21908), + 120: uint16(21913), + 121: uint16(21994), + 122: uint16(22007), + 123: uint16(21961), + 124: uint16(22047), + 125: uint16(21969), + 126: uint16(21995), + 127: uint16(21996), + 128: uint16(21972), + 129: uint16(21990), + 130: uint16(21981), + 131: uint16(21956), + 132: uint16(21999), + 133: uint16(21989), + 134: uint16(22002), + 135: uint16(22003), + 136: uint16(21964), + 137: uint16(21965), + 138: uint16(21992), + 139: uint16(22005), + 140: uint16(21988), + 141: uint16(36756), + 142: uint16(22046), + 143: uint16(22024), + 144: uint16(22028), + 145: uint16(22017), + 146: uint16(22052), + 147: uint16(22051), + 148: uint16(22014), + 149: uint16(22016), + 150: uint16(22055), + 151: uint16(22061), + 152: uint16(22104), + 153: uint16(22073), + 154: uint16(22103), + 155: uint16(22060), + 156: uint16(22093), + 157: uint16(22114), + 158: uint16(22105), + 159: uint16(22108), + 160: uint16(22092), + 161: uint16(22100), + 162: uint16(22150), + 163: uint16(22116), + 164: uint16(22129), + 165: uint16(22123), + 166: uint16(22139), + 167: uint16(22140), + 168: uint16(22149), + 169: uint16(22163), + 170: uint16(22191), + 171: uint16(22228), + 172: uint16(22231), + 173: uint16(22237), + 174: uint16(22241), + 175: uint16(22261), + 176: uint16(22251), + 177: uint16(22265), + 178: uint16(22271), + 179: uint16(22276), + 180: uint16(22282), + 181: uint16(22281), + 182: uint16(22300), + 183: uint16(24079), + 184: uint16(24089), + 185: uint16(24084), + 186: uint16(24081), + 187: uint16(24113), + 188: uint16(24123), + 189: uint16(24124), + }, + 96: { + 0: uint16(37189), + 1: uint16(37191), + 2: uint16(37192), + 3: uint16(37201), + 4: uint16(37203), + 5: uint16(37204), + 6: uint16(37205), + 7: uint16(37206), + 8: uint16(37208), + 9: uint16(37209), + 10: uint16(37211), + 11: uint16(37212), + 12: uint16(37215), + 13: uint16(37216), + 14: uint16(37222), + 15: uint16(37223), + 16: uint16(37224), + 17: uint16(37227), + 18: uint16(37229), + 19: uint16(37235), + 20: uint16(37242), + 21: uint16(37243), + 22: uint16(37244), + 23: uint16(37248), + 24: uint16(37249), + 25: uint16(37250), + 26: uint16(37251), + 27: uint16(37252), + 28: uint16(37254), + 29: uint16(37256), + 30: uint16(37258), + 31: uint16(37262), + 32: uint16(37263), + 33: uint16(37267), + 34: uint16(37268), + 35: uint16(37269), + 36: uint16(37270), + 37: uint16(37271), + 38: uint16(37272), + 39: uint16(37273), + 40: uint16(37276), + 41: uint16(37277), + 42: uint16(37278), + 43: uint16(37279), + 44: uint16(37280), + 45: uint16(37281), + 46: uint16(37284), + 47: uint16(37285), + 48: uint16(37286), + 49: uint16(37287), + 50: uint16(37288), + 51: uint16(37289), + 52: uint16(37291), + 53: uint16(37292), + 54: uint16(37296), + 55: uint16(37297), + 56: uint16(37298), + 57: uint16(37299), + 58: uint16(37302), + 59: uint16(37303), + 60: uint16(37304), + 61: uint16(37305), + 62: uint16(37307), + 63: uint16(37308), + 64: uint16(37309), + 65: uint16(37310), + 66: uint16(37311), + 67: uint16(37312), + 68: uint16(37313), + 69: uint16(37314), + 70: uint16(37315), + 71: uint16(37316), + 72: uint16(37317), + 73: uint16(37318), + 74: uint16(37320), + 75: uint16(37323), + 76: uint16(37328), + 77: uint16(37330), + 78: uint16(37331), + 79: uint16(37332), + 80: uint16(37333), + 81: uint16(37334), + 82: uint16(37335), + 83: uint16(37336), + 84: uint16(37337), + 85: uint16(37338), + 86: uint16(37339), + 87: uint16(37341), + 88: uint16(37342), + 89: uint16(37343), + 90: uint16(37344), + 91: uint16(37345), + 92: uint16(37346), + 93: uint16(37347), + 94: uint16(37348), + 95: uint16(37349), + 96: uint16(24119), + 97: uint16(24132), + 98: uint16(24148), + 99: uint16(24155), + 100: uint16(24158), + 101: uint16(24161), + 102: uint16(23692), + 103: uint16(23674), + 104: uint16(23693), + 105: uint16(23696), + 106: uint16(23702), + 107: uint16(23688), + 108: uint16(23704), + 109: uint16(23705), + 110: uint16(23697), + 111: uint16(23706), + 112: uint16(23708), + 113: uint16(23733), + 114: uint16(23714), + 115: uint16(23741), + 116: uint16(23724), + 117: uint16(23723), + 118: uint16(23729), + 119: uint16(23715), + 120: uint16(23745), + 121: uint16(23735), + 122: uint16(23748), + 123: uint16(23762), + 124: uint16(23780), + 125: uint16(23755), + 126: uint16(23781), + 127: uint16(23810), + 128: uint16(23811), + 129: uint16(23847), + 130: uint16(23846), + 131: uint16(23854), + 132: uint16(23844), + 133: uint16(23838), + 134: uint16(23814), + 135: uint16(23835), + 136: uint16(23896), + 137: uint16(23870), + 138: uint16(23860), + 139: uint16(23869), + 140: uint16(23916), + 141: uint16(23899), + 142: uint16(23919), + 143: uint16(23901), + 144: uint16(23915), + 145: uint16(23883), + 146: uint16(23882), + 147: uint16(23913), + 148: uint16(23924), + 149: uint16(23938), + 150: uint16(23961), + 151: uint16(23965), + 152: uint16(35955), + 153: uint16(23991), + 154: uint16(24005), + 155: uint16(24435), + 156: uint16(24439), + 157: uint16(24450), + 158: uint16(24455), + 159: uint16(24457), + 160: uint16(24460), + 161: uint16(24469), + 162: uint16(24473), + 163: uint16(24476), + 164: uint16(24488), + 165: uint16(24493), + 166: uint16(24501), + 167: uint16(24508), + 168: uint16(34914), + 169: uint16(24417), + 170: uint16(29357), + 171: uint16(29360), + 172: uint16(29364), + 173: uint16(29367), + 174: uint16(29368), + 175: uint16(29379), + 176: uint16(29377), + 177: uint16(29390), + 178: uint16(29389), + 179: uint16(29394), + 180: uint16(29416), + 181: uint16(29423), + 182: uint16(29417), + 183: uint16(29426), + 184: uint16(29428), + 185: uint16(29431), + 186: uint16(29441), + 187: uint16(29427), + 188: uint16(29443), + 189: uint16(29434), + }, + 97: { + 0: uint16(37350), + 1: uint16(37351), + 2: uint16(37352), + 3: uint16(37353), + 4: uint16(37354), + 5: uint16(37355), + 6: uint16(37356), + 7: uint16(37357), + 8: uint16(37358), + 9: uint16(37359), + 10: uint16(37360), + 11: uint16(37361), + 12: uint16(37362), + 13: uint16(37363), + 14: uint16(37364), + 15: uint16(37365), + 16: uint16(37366), + 17: uint16(37367), + 18: uint16(37368), + 19: uint16(37369), + 20: uint16(37370), + 21: uint16(37371), + 22: uint16(37372), + 23: uint16(37373), + 24: uint16(37374), + 25: uint16(37375), + 26: uint16(37376), + 27: uint16(37377), + 28: uint16(37378), + 29: uint16(37379), + 30: uint16(37380), + 31: uint16(37381), + 32: uint16(37382), + 33: uint16(37383), + 34: uint16(37384), + 35: uint16(37385), + 36: uint16(37386), + 37: uint16(37387), + 38: uint16(37388), + 39: uint16(37389), + 40: uint16(37390), + 41: uint16(37391), + 42: uint16(37392), + 43: uint16(37393), + 44: uint16(37394), + 45: uint16(37395), + 46: uint16(37396), + 47: uint16(37397), + 48: uint16(37398), + 49: uint16(37399), + 50: uint16(37400), + 51: uint16(37401), + 52: uint16(37402), + 53: uint16(37403), + 54: uint16(37404), + 55: uint16(37405), + 56: uint16(37406), + 57: uint16(37407), + 58: uint16(37408), + 59: uint16(37409), + 60: uint16(37410), + 61: uint16(37411), + 62: uint16(37412), + 63: uint16(37413), + 64: uint16(37414), + 65: uint16(37415), + 66: uint16(37416), + 67: uint16(37417), + 68: uint16(37418), + 69: uint16(37419), + 70: uint16(37420), + 71: uint16(37421), + 72: uint16(37422), + 73: uint16(37423), + 74: uint16(37424), + 75: uint16(37425), + 76: uint16(37426), + 77: uint16(37427), + 78: uint16(37428), + 79: uint16(37429), + 80: uint16(37430), + 81: uint16(37431), + 82: uint16(37432), + 83: uint16(37433), + 84: uint16(37434), + 85: uint16(37435), + 86: uint16(37436), + 87: uint16(37437), + 88: uint16(37438), + 89: uint16(37439), + 90: uint16(37440), + 91: uint16(37441), + 92: uint16(37442), + 93: uint16(37443), + 94: uint16(37444), + 95: uint16(37445), + 96: uint16(29435), + 97: uint16(29463), + 98: uint16(29459), + 99: uint16(29473), + 100: uint16(29450), + 101: uint16(29470), + 102: uint16(29469), + 103: uint16(29461), + 104: uint16(29474), + 105: uint16(29497), + 106: uint16(29477), + 107: uint16(29484), + 108: uint16(29496), + 109: uint16(29489), + 110: uint16(29520), + 111: uint16(29517), + 112: uint16(29527), + 113: uint16(29536), + 114: uint16(29548), + 115: uint16(29551), + 116: uint16(29566), + 117: uint16(33307), + 118: uint16(22821), + 119: uint16(39143), + 120: uint16(22820), + 121: uint16(22786), + 122: uint16(39267), + 123: uint16(39271), + 124: uint16(39272), + 125: uint16(39273), + 126: uint16(39274), + 127: uint16(39275), + 128: uint16(39276), + 129: uint16(39284), + 130: uint16(39287), + 131: uint16(39293), + 132: uint16(39296), + 133: uint16(39300), + 134: uint16(39303), + 135: uint16(39306), + 136: uint16(39309), + 137: uint16(39312), + 138: uint16(39313), + 139: uint16(39315), + 140: uint16(39316), + 141: uint16(39317), + 142: uint16(24192), + 143: uint16(24209), + 144: uint16(24203), + 145: uint16(24214), + 146: uint16(24229), + 147: uint16(24224), + 148: uint16(24249), + 149: uint16(24245), + 150: uint16(24254), + 151: uint16(24243), + 152: uint16(36179), + 153: uint16(24274), + 154: uint16(24273), + 155: uint16(24283), + 156: uint16(24296), + 157: uint16(24298), + 158: uint16(33210), + 159: uint16(24516), + 160: uint16(24521), + 161: uint16(24534), + 162: uint16(24527), + 163: uint16(24579), + 164: uint16(24558), + 165: uint16(24580), + 166: uint16(24545), + 167: uint16(24548), + 168: uint16(24574), + 169: uint16(24581), + 170: uint16(24582), + 171: uint16(24554), + 172: uint16(24557), + 173: uint16(24568), + 174: uint16(24601), + 175: uint16(24629), + 176: uint16(24614), + 177: uint16(24603), + 178: uint16(24591), + 179: uint16(24589), + 180: uint16(24617), + 181: uint16(24619), + 182: uint16(24586), + 183: uint16(24639), + 184: uint16(24609), + 185: uint16(24696), + 186: uint16(24697), + 187: uint16(24699), + 188: uint16(24698), + 189: uint16(24642), + }, + 98: { + 0: uint16(37446), + 1: uint16(37447), + 2: uint16(37448), + 3: uint16(37449), + 4: uint16(37450), + 5: uint16(37451), + 6: uint16(37452), + 7: uint16(37453), + 8: uint16(37454), + 9: uint16(37455), + 10: uint16(37456), + 11: uint16(37457), + 12: uint16(37458), + 13: uint16(37459), + 14: uint16(37460), + 15: uint16(37461), + 16: uint16(37462), + 17: uint16(37463), + 18: uint16(37464), + 19: uint16(37465), + 20: uint16(37466), + 21: uint16(37467), + 22: uint16(37468), + 23: uint16(37469), + 24: uint16(37470), + 25: uint16(37471), + 26: uint16(37472), + 27: uint16(37473), + 28: uint16(37474), + 29: uint16(37475), + 30: uint16(37476), + 31: uint16(37477), + 32: uint16(37478), + 33: uint16(37479), + 34: uint16(37480), + 35: uint16(37481), + 36: uint16(37482), + 37: uint16(37483), + 38: uint16(37484), + 39: uint16(37485), + 40: uint16(37486), + 41: uint16(37487), + 42: uint16(37488), + 43: uint16(37489), + 44: uint16(37490), + 45: uint16(37491), + 46: uint16(37493), + 47: uint16(37494), + 48: uint16(37495), + 49: uint16(37496), + 50: uint16(37497), + 51: uint16(37498), + 52: uint16(37499), + 53: uint16(37500), + 54: uint16(37501), + 55: uint16(37502), + 56: uint16(37503), + 57: uint16(37504), + 58: uint16(37505), + 59: uint16(37506), + 60: uint16(37507), + 61: uint16(37508), + 62: uint16(37509), + 63: uint16(37510), + 64: uint16(37511), + 65: uint16(37512), + 66: uint16(37513), + 67: uint16(37514), + 68: uint16(37515), + 69: uint16(37516), + 70: uint16(37517), + 71: uint16(37519), + 72: uint16(37520), + 73: uint16(37521), + 74: uint16(37522), + 75: uint16(37523), + 76: uint16(37524), + 77: uint16(37525), + 78: uint16(37526), + 79: uint16(37527), + 80: uint16(37528), + 81: uint16(37529), + 82: uint16(37530), + 83: uint16(37531), + 84: uint16(37532), + 85: uint16(37533), + 86: uint16(37534), + 87: uint16(37535), + 88: uint16(37536), + 89: uint16(37537), + 90: uint16(37538), + 91: uint16(37539), + 92: uint16(37540), + 93: uint16(37541), + 94: uint16(37542), + 95: uint16(37543), + 96: uint16(24682), + 97: uint16(24701), + 98: uint16(24726), + 99: uint16(24730), + 100: uint16(24749), + 101: uint16(24733), + 102: uint16(24707), + 103: uint16(24722), + 104: uint16(24716), + 105: uint16(24731), + 106: uint16(24812), + 107: uint16(24763), + 108: uint16(24753), + 109: uint16(24797), + 110: uint16(24792), + 111: uint16(24774), + 112: uint16(24794), + 113: uint16(24756), + 114: uint16(24864), + 115: uint16(24870), + 116: uint16(24853), + 117: uint16(24867), + 118: uint16(24820), + 119: uint16(24832), + 120: uint16(24846), + 121: uint16(24875), + 122: uint16(24906), + 123: uint16(24949), + 124: uint16(25004), + 125: uint16(24980), + 126: uint16(24999), + 127: uint16(25015), + 128: uint16(25044), + 129: uint16(25077), + 130: uint16(24541), + 131: uint16(38579), + 132: uint16(38377), + 133: uint16(38379), + 134: uint16(38385), + 135: uint16(38387), + 136: uint16(38389), + 137: uint16(38390), + 138: uint16(38396), + 139: uint16(38398), + 140: uint16(38403), + 141: uint16(38404), + 142: uint16(38406), + 143: uint16(38408), + 144: uint16(38410), + 145: uint16(38411), + 146: uint16(38412), + 147: uint16(38413), + 148: uint16(38415), + 149: uint16(38418), + 150: uint16(38421), + 151: uint16(38422), + 152: uint16(38423), + 153: uint16(38425), + 154: uint16(38426), + 155: uint16(20012), + 156: uint16(29247), + 157: uint16(25109), + 158: uint16(27701), + 159: uint16(27732), + 160: uint16(27740), + 161: uint16(27722), + 162: uint16(27811), + 163: uint16(27781), + 164: uint16(27792), + 165: uint16(27796), + 166: uint16(27788), + 167: uint16(27752), + 168: uint16(27753), + 169: uint16(27764), + 170: uint16(27766), + 171: uint16(27782), + 172: uint16(27817), + 173: uint16(27856), + 174: uint16(27860), + 175: uint16(27821), + 176: uint16(27895), + 177: uint16(27896), + 178: uint16(27889), + 179: uint16(27863), + 180: uint16(27826), + 181: uint16(27872), + 182: uint16(27862), + 183: uint16(27898), + 184: uint16(27883), + 185: uint16(27886), + 186: uint16(27825), + 187: uint16(27859), + 188: uint16(27887), + 189: uint16(27902), + }, + 99: { + 0: uint16(37544), + 1: uint16(37545), + 2: uint16(37546), + 3: uint16(37547), + 4: uint16(37548), + 5: uint16(37549), + 6: uint16(37551), + 7: uint16(37552), + 8: uint16(37553), + 9: uint16(37554), + 10: uint16(37555), + 11: uint16(37556), + 12: uint16(37557), + 13: uint16(37558), + 14: uint16(37559), + 15: uint16(37560), + 16: uint16(37561), + 17: uint16(37562), + 18: uint16(37563), + 19: uint16(37564), + 20: uint16(37565), + 21: uint16(37566), + 22: uint16(37567), + 23: uint16(37568), + 24: uint16(37569), + 25: uint16(37570), + 26: uint16(37571), + 27: uint16(37572), + 28: uint16(37573), + 29: uint16(37574), + 30: uint16(37575), + 31: uint16(37577), + 32: uint16(37578), + 33: uint16(37579), + 34: uint16(37580), + 35: uint16(37581), + 36: uint16(37582), + 37: uint16(37583), + 38: uint16(37584), + 39: uint16(37585), + 40: uint16(37586), + 41: uint16(37587), + 42: uint16(37588), + 43: uint16(37589), + 44: uint16(37590), + 45: uint16(37591), + 46: uint16(37592), + 47: uint16(37593), + 48: uint16(37594), + 49: uint16(37595), + 50: uint16(37596), + 51: uint16(37597), + 52: uint16(37598), + 53: uint16(37599), + 54: uint16(37600), + 55: uint16(37601), + 56: uint16(37602), + 57: uint16(37603), + 58: uint16(37604), + 59: uint16(37605), + 60: uint16(37606), + 61: uint16(37607), + 62: uint16(37608), + 63: uint16(37609), + 64: uint16(37610), + 65: uint16(37611), + 66: uint16(37612), + 67: uint16(37613), + 68: uint16(37614), + 69: uint16(37615), + 70: uint16(37616), + 71: uint16(37617), + 72: uint16(37618), + 73: uint16(37619), + 74: uint16(37620), + 75: uint16(37621), + 76: uint16(37622), + 77: uint16(37623), + 78: uint16(37624), + 79: uint16(37625), + 80: uint16(37626), + 81: uint16(37627), + 82: uint16(37628), + 83: uint16(37629), + 84: uint16(37630), + 85: uint16(37631), + 86: uint16(37632), + 87: uint16(37633), + 88: uint16(37634), + 89: uint16(37635), + 90: uint16(37636), + 91: uint16(37637), + 92: uint16(37638), + 93: uint16(37639), + 94: uint16(37640), + 95: uint16(37641), + 96: uint16(27961), + 97: uint16(27943), + 98: uint16(27916), + 99: uint16(27971), + 100: uint16(27976), + 101: uint16(27911), + 102: uint16(27908), + 103: uint16(27929), + 104: uint16(27918), + 105: uint16(27947), + 106: uint16(27981), + 107: uint16(27950), + 108: uint16(27957), + 109: uint16(27930), + 110: uint16(27983), + 111: uint16(27986), + 112: uint16(27988), + 113: uint16(27955), + 114: uint16(28049), + 115: uint16(28015), + 116: uint16(28062), + 117: uint16(28064), + 118: uint16(27998), + 119: uint16(28051), + 120: uint16(28052), + 121: uint16(27996), + 122: uint16(28000), + 123: uint16(28028), + 124: uint16(28003), + 125: uint16(28186), + 126: uint16(28103), + 127: uint16(28101), + 128: uint16(28126), + 129: uint16(28174), + 130: uint16(28095), + 131: uint16(28128), + 132: uint16(28177), + 133: uint16(28134), + 134: uint16(28125), + 135: uint16(28121), + 136: uint16(28182), + 137: uint16(28075), + 138: uint16(28172), + 139: uint16(28078), + 140: uint16(28203), + 141: uint16(28270), + 142: uint16(28238), + 143: uint16(28267), + 144: uint16(28338), + 145: uint16(28255), + 146: uint16(28294), + 147: uint16(28243), + 148: uint16(28244), + 149: uint16(28210), + 150: uint16(28197), + 151: uint16(28228), + 152: uint16(28383), + 153: uint16(28337), + 154: uint16(28312), + 155: uint16(28384), + 156: uint16(28461), + 157: uint16(28386), + 158: uint16(28325), + 159: uint16(28327), + 160: uint16(28349), + 161: uint16(28347), + 162: uint16(28343), + 163: uint16(28375), + 164: uint16(28340), + 165: uint16(28367), + 166: uint16(28303), + 167: uint16(28354), + 168: uint16(28319), + 169: uint16(28514), + 170: uint16(28486), + 171: uint16(28487), + 172: uint16(28452), + 173: uint16(28437), + 174: uint16(28409), + 175: uint16(28463), + 176: uint16(28470), + 177: uint16(28491), + 178: uint16(28532), + 179: uint16(28458), + 180: uint16(28425), + 181: uint16(28457), + 182: uint16(28553), + 183: uint16(28557), + 184: uint16(28556), + 185: uint16(28536), + 186: uint16(28530), + 187: uint16(28540), + 188: uint16(28538), + 189: uint16(28625), + }, + 100: { + 0: uint16(37642), + 1: uint16(37643), + 2: uint16(37644), + 3: uint16(37645), + 4: uint16(37646), + 5: uint16(37647), + 6: uint16(37648), + 7: uint16(37649), + 8: uint16(37650), + 9: uint16(37651), + 10: uint16(37652), + 11: uint16(37653), + 12: uint16(37654), + 13: uint16(37655), + 14: uint16(37656), + 15: uint16(37657), + 16: uint16(37658), + 17: uint16(37659), + 18: uint16(37660), + 19: uint16(37661), + 20: uint16(37662), + 21: uint16(37663), + 22: uint16(37664), + 23: uint16(37665), + 24: uint16(37666), + 25: uint16(37667), + 26: uint16(37668), + 27: uint16(37669), + 28: uint16(37670), + 29: uint16(37671), + 30: uint16(37672), + 31: uint16(37673), + 32: uint16(37674), + 33: uint16(37675), + 34: uint16(37676), + 35: uint16(37677), + 36: uint16(37678), + 37: uint16(37679), + 38: uint16(37680), + 39: uint16(37681), + 40: uint16(37682), + 41: uint16(37683), + 42: uint16(37684), + 43: uint16(37685), + 44: uint16(37686), + 45: uint16(37687), + 46: uint16(37688), + 47: uint16(37689), + 48: uint16(37690), + 49: uint16(37691), + 50: uint16(37692), + 51: uint16(37693), + 52: uint16(37695), + 53: uint16(37696), + 54: uint16(37697), + 55: uint16(37698), + 56: uint16(37699), + 57: uint16(37700), + 58: uint16(37701), + 59: uint16(37702), + 60: uint16(37703), + 61: uint16(37704), + 62: uint16(37705), + 63: uint16(37706), + 64: uint16(37707), + 65: uint16(37708), + 66: uint16(37709), + 67: uint16(37710), + 68: uint16(37711), + 69: uint16(37712), + 70: uint16(37713), + 71: uint16(37714), + 72: uint16(37715), + 73: uint16(37716), + 74: uint16(37717), + 75: uint16(37718), + 76: uint16(37719), + 77: uint16(37720), + 78: uint16(37721), + 79: uint16(37722), + 80: uint16(37723), + 81: uint16(37724), + 82: uint16(37725), + 83: uint16(37726), + 84: uint16(37727), + 85: uint16(37728), + 86: uint16(37729), + 87: uint16(37730), + 88: uint16(37731), + 89: uint16(37732), + 90: uint16(37733), + 91: uint16(37734), + 92: uint16(37735), + 93: uint16(37736), + 94: uint16(37737), + 95: uint16(37739), + 96: uint16(28617), + 97: uint16(28583), + 98: uint16(28601), + 99: uint16(28598), + 100: uint16(28610), + 101: uint16(28641), + 102: uint16(28654), + 103: uint16(28638), + 104: uint16(28640), + 105: uint16(28655), + 106: uint16(28698), + 107: uint16(28707), + 108: uint16(28699), + 109: uint16(28729), + 110: uint16(28725), + 111: uint16(28751), + 112: uint16(28766), + 113: uint16(23424), + 114: uint16(23428), + 115: uint16(23445), + 116: uint16(23443), + 117: uint16(23461), + 118: uint16(23480), + 119: uint16(29999), + 120: uint16(39582), + 121: uint16(25652), + 122: uint16(23524), + 123: uint16(23534), + 124: uint16(35120), + 125: uint16(23536), + 126: uint16(36423), + 127: uint16(35591), + 128: uint16(36790), + 129: uint16(36819), + 130: uint16(36821), + 131: uint16(36837), + 132: uint16(36846), + 133: uint16(36836), + 134: uint16(36841), + 135: uint16(36838), + 136: uint16(36851), + 137: uint16(36840), + 138: uint16(36869), + 139: uint16(36868), + 140: uint16(36875), + 141: uint16(36902), + 142: uint16(36881), + 143: uint16(36877), + 144: uint16(36886), + 145: uint16(36897), + 146: uint16(36917), + 147: uint16(36918), + 148: uint16(36909), + 149: uint16(36911), + 150: uint16(36932), + 151: uint16(36945), + 152: uint16(36946), + 153: uint16(36944), + 154: uint16(36968), + 155: uint16(36952), + 156: uint16(36962), + 157: uint16(36955), + 158: uint16(26297), + 159: uint16(36980), + 160: uint16(36989), + 161: uint16(36994), + 162: uint16(37000), + 163: uint16(36995), + 164: uint16(37003), + 165: uint16(24400), + 166: uint16(24407), + 167: uint16(24406), + 168: uint16(24408), + 169: uint16(23611), + 170: uint16(21675), + 171: uint16(23632), + 172: uint16(23641), + 173: uint16(23409), + 174: uint16(23651), + 175: uint16(23654), + 176: uint16(32700), + 177: uint16(24362), + 178: uint16(24361), + 179: uint16(24365), + 180: uint16(33396), + 181: uint16(24380), + 182: uint16(39739), + 183: uint16(23662), + 184: uint16(22913), + 185: uint16(22915), + 186: uint16(22925), + 187: uint16(22953), + 188: uint16(22954), + 189: uint16(22947), + }, + 101: { + 0: uint16(37740), + 1: uint16(37741), + 2: uint16(37742), + 3: uint16(37743), + 4: uint16(37744), + 5: uint16(37745), + 6: uint16(37746), + 7: uint16(37747), + 8: uint16(37748), + 9: uint16(37749), + 10: uint16(37750), + 11: uint16(37751), + 12: uint16(37752), + 13: uint16(37753), + 14: uint16(37754), + 15: uint16(37755), + 16: uint16(37756), + 17: uint16(37757), + 18: uint16(37758), + 19: uint16(37759), + 20: uint16(37760), + 21: uint16(37761), + 22: uint16(37762), + 23: uint16(37763), + 24: uint16(37764), + 25: uint16(37765), + 26: uint16(37766), + 27: uint16(37767), + 28: uint16(37768), + 29: uint16(37769), + 30: uint16(37770), + 31: uint16(37771), + 32: uint16(37772), + 33: uint16(37773), + 34: uint16(37774), + 35: uint16(37776), + 36: uint16(37777), + 37: uint16(37778), + 38: uint16(37779), + 39: uint16(37780), + 40: uint16(37781), + 41: uint16(37782), + 42: uint16(37783), + 43: uint16(37784), + 44: uint16(37785), + 45: uint16(37786), + 46: uint16(37787), + 47: uint16(37788), + 48: uint16(37789), + 49: uint16(37790), + 50: uint16(37791), + 51: uint16(37792), + 52: uint16(37793), + 53: uint16(37794), + 54: uint16(37795), + 55: uint16(37796), + 56: uint16(37797), + 57: uint16(37798), + 58: uint16(37799), + 59: uint16(37800), + 60: uint16(37801), + 61: uint16(37802), + 62: uint16(37803), + 63: uint16(37804), + 64: uint16(37805), + 65: uint16(37806), + 66: uint16(37807), + 67: uint16(37808), + 68: uint16(37809), + 69: uint16(37810), + 70: uint16(37811), + 71: uint16(37812), + 72: uint16(37813), + 73: uint16(37814), + 74: uint16(37815), + 75: uint16(37816), + 76: uint16(37817), + 77: uint16(37818), + 78: uint16(37819), + 79: uint16(37820), + 80: uint16(37821), + 81: uint16(37822), + 82: uint16(37823), + 83: uint16(37824), + 84: uint16(37825), + 85: uint16(37826), + 86: uint16(37827), + 87: uint16(37828), + 88: uint16(37829), + 89: uint16(37830), + 90: uint16(37831), + 91: uint16(37832), + 92: uint16(37833), + 93: uint16(37835), + 94: uint16(37836), + 95: uint16(37837), + 96: uint16(22935), + 97: uint16(22986), + 98: uint16(22955), + 99: uint16(22942), + 100: uint16(22948), + 101: uint16(22994), + 102: uint16(22962), + 103: uint16(22959), + 104: uint16(22999), + 105: uint16(22974), + 106: uint16(23045), + 107: uint16(23046), + 108: uint16(23005), + 109: uint16(23048), + 110: uint16(23011), + 111: uint16(23000), + 112: uint16(23033), + 113: uint16(23052), + 114: uint16(23049), + 115: uint16(23090), + 116: uint16(23092), + 117: uint16(23057), + 118: uint16(23075), + 119: uint16(23059), + 120: uint16(23104), + 121: uint16(23143), + 122: uint16(23114), + 123: uint16(23125), + 124: uint16(23100), + 125: uint16(23138), + 126: uint16(23157), + 127: uint16(33004), + 128: uint16(23210), + 129: uint16(23195), + 130: uint16(23159), + 131: uint16(23162), + 132: uint16(23230), + 133: uint16(23275), + 134: uint16(23218), + 135: uint16(23250), + 136: uint16(23252), + 137: uint16(23224), + 138: uint16(23264), + 139: uint16(23267), + 140: uint16(23281), + 141: uint16(23254), + 142: uint16(23270), + 143: uint16(23256), + 144: uint16(23260), + 145: uint16(23305), + 146: uint16(23319), + 147: uint16(23318), + 148: uint16(23346), + 149: uint16(23351), + 150: uint16(23360), + 151: uint16(23573), + 152: uint16(23580), + 153: uint16(23386), + 154: uint16(23397), + 155: uint16(23411), + 156: uint16(23377), + 157: uint16(23379), + 158: uint16(23394), + 159: uint16(39541), + 160: uint16(39543), + 161: uint16(39544), + 162: uint16(39546), + 163: uint16(39551), + 164: uint16(39549), + 165: uint16(39552), + 166: uint16(39553), + 167: uint16(39557), + 168: uint16(39560), + 169: uint16(39562), + 170: uint16(39568), + 171: uint16(39570), + 172: uint16(39571), + 173: uint16(39574), + 174: uint16(39576), + 175: uint16(39579), + 176: uint16(39580), + 177: uint16(39581), + 178: uint16(39583), + 179: uint16(39584), + 180: uint16(39586), + 181: uint16(39587), + 182: uint16(39589), + 183: uint16(39591), + 184: uint16(32415), + 185: uint16(32417), + 186: uint16(32419), + 187: uint16(32421), + 188: uint16(32424), + 189: uint16(32425), + }, + 102: { + 0: uint16(37838), + 1: uint16(37839), + 2: uint16(37840), + 3: uint16(37841), + 4: uint16(37842), + 5: uint16(37843), + 6: uint16(37844), + 7: uint16(37845), + 8: uint16(37847), + 9: uint16(37848), + 10: uint16(37849), + 11: uint16(37850), + 12: uint16(37851), + 13: uint16(37852), + 14: uint16(37853), + 15: uint16(37854), + 16: uint16(37855), + 17: uint16(37856), + 18: uint16(37857), + 19: uint16(37858), + 20: uint16(37859), + 21: uint16(37860), + 22: uint16(37861), + 23: uint16(37862), + 24: uint16(37863), + 25: uint16(37864), + 26: uint16(37865), + 27: uint16(37866), + 28: uint16(37867), + 29: uint16(37868), + 30: uint16(37869), + 31: uint16(37870), + 32: uint16(37871), + 33: uint16(37872), + 34: uint16(37873), + 35: uint16(37874), + 36: uint16(37875), + 37: uint16(37876), + 38: uint16(37877), + 39: uint16(37878), + 40: uint16(37879), + 41: uint16(37880), + 42: uint16(37881), + 43: uint16(37882), + 44: uint16(37883), + 45: uint16(37884), + 46: uint16(37885), + 47: uint16(37886), + 48: uint16(37887), + 49: uint16(37888), + 50: uint16(37889), + 51: uint16(37890), + 52: uint16(37891), + 53: uint16(37892), + 54: uint16(37893), + 55: uint16(37894), + 56: uint16(37895), + 57: uint16(37896), + 58: uint16(37897), + 59: uint16(37898), + 60: uint16(37899), + 61: uint16(37900), + 62: uint16(37901), + 63: uint16(37902), + 64: uint16(37903), + 65: uint16(37904), + 66: uint16(37905), + 67: uint16(37906), + 68: uint16(37907), + 69: uint16(37908), + 70: uint16(37909), + 71: uint16(37910), + 72: uint16(37911), + 73: uint16(37912), + 74: uint16(37913), + 75: uint16(37914), + 76: uint16(37915), + 77: uint16(37916), + 78: uint16(37917), + 79: uint16(37918), + 80: uint16(37919), + 81: uint16(37920), + 82: uint16(37921), + 83: uint16(37922), + 84: uint16(37923), + 85: uint16(37924), + 86: uint16(37925), + 87: uint16(37926), + 88: uint16(37927), + 89: uint16(37928), + 90: uint16(37929), + 91: uint16(37930), + 92: uint16(37931), + 93: uint16(37932), + 94: uint16(37933), + 95: uint16(37934), + 96: uint16(32429), + 97: uint16(32432), + 98: uint16(32446), + 99: uint16(32448), + 100: uint16(32449), + 101: uint16(32450), + 102: uint16(32457), + 103: uint16(32459), + 104: uint16(32460), + 105: uint16(32464), + 106: uint16(32468), + 107: uint16(32471), + 108: uint16(32475), + 109: uint16(32480), + 110: uint16(32481), + 111: uint16(32488), + 112: uint16(32491), + 113: uint16(32494), + 114: uint16(32495), + 115: uint16(32497), + 116: uint16(32498), + 117: uint16(32525), + 118: uint16(32502), + 119: uint16(32506), + 120: uint16(32507), + 121: uint16(32510), + 122: uint16(32513), + 123: uint16(32514), + 124: uint16(32515), + 125: uint16(32519), + 126: uint16(32520), + 127: uint16(32523), + 128: uint16(32524), + 129: uint16(32527), + 130: uint16(32529), + 131: uint16(32530), + 132: uint16(32535), + 133: uint16(32537), + 134: uint16(32540), + 135: uint16(32539), + 136: uint16(32543), + 137: uint16(32545), + 138: uint16(32546), + 139: uint16(32547), + 140: uint16(32548), + 141: uint16(32549), + 142: uint16(32550), + 143: uint16(32551), + 144: uint16(32554), + 145: uint16(32555), + 146: uint16(32556), + 147: uint16(32557), + 148: uint16(32559), + 149: uint16(32560), + 150: uint16(32561), + 151: uint16(32562), + 152: uint16(32563), + 153: uint16(32565), + 154: uint16(24186), + 155: uint16(30079), + 156: uint16(24027), + 157: uint16(30014), + 158: uint16(37013), + 159: uint16(29582), + 160: uint16(29585), + 161: uint16(29614), + 162: uint16(29602), + 163: uint16(29599), + 164: uint16(29647), + 165: uint16(29634), + 166: uint16(29649), + 167: uint16(29623), + 168: uint16(29619), + 169: uint16(29632), + 170: uint16(29641), + 171: uint16(29640), + 172: uint16(29669), + 173: uint16(29657), + 174: uint16(39036), + 175: uint16(29706), + 176: uint16(29673), + 177: uint16(29671), + 178: uint16(29662), + 179: uint16(29626), + 180: uint16(29682), + 181: uint16(29711), + 182: uint16(29738), + 183: uint16(29787), + 184: uint16(29734), + 185: uint16(29733), + 186: uint16(29736), + 187: uint16(29744), + 188: uint16(29742), + 189: uint16(29740), + }, + 103: { + 0: uint16(37935), + 1: uint16(37936), + 2: uint16(37937), + 3: uint16(37938), + 4: uint16(37939), + 5: uint16(37940), + 6: uint16(37941), + 7: uint16(37942), + 8: uint16(37943), + 9: uint16(37944), + 10: uint16(37945), + 11: uint16(37946), + 12: uint16(37947), + 13: uint16(37948), + 14: uint16(37949), + 15: uint16(37951), + 16: uint16(37952), + 17: uint16(37953), + 18: uint16(37954), + 19: uint16(37955), + 20: uint16(37956), + 21: uint16(37957), + 22: uint16(37958), + 23: uint16(37959), + 24: uint16(37960), + 25: uint16(37961), + 26: uint16(37962), + 27: uint16(37963), + 28: uint16(37964), + 29: uint16(37965), + 30: uint16(37966), + 31: uint16(37967), + 32: uint16(37968), + 33: uint16(37969), + 34: uint16(37970), + 35: uint16(37971), + 36: uint16(37972), + 37: uint16(37973), + 38: uint16(37974), + 39: uint16(37975), + 40: uint16(37976), + 41: uint16(37977), + 42: uint16(37978), + 43: uint16(37979), + 44: uint16(37980), + 45: uint16(37981), + 46: uint16(37982), + 47: uint16(37983), + 48: uint16(37984), + 49: uint16(37985), + 50: uint16(37986), + 51: uint16(37987), + 52: uint16(37988), + 53: uint16(37989), + 54: uint16(37990), + 55: uint16(37991), + 56: uint16(37992), + 57: uint16(37993), + 58: uint16(37994), + 59: uint16(37996), + 60: uint16(37997), + 61: uint16(37998), + 62: uint16(37999), + 63: uint16(38000), + 64: uint16(38001), + 65: uint16(38002), + 66: uint16(38003), + 67: uint16(38004), + 68: uint16(38005), + 69: uint16(38006), + 70: uint16(38007), + 71: uint16(38008), + 72: uint16(38009), + 73: uint16(38010), + 74: uint16(38011), + 75: uint16(38012), + 76: uint16(38013), + 77: uint16(38014), + 78: uint16(38015), + 79: uint16(38016), + 80: uint16(38017), + 81: uint16(38018), + 82: uint16(38019), + 83: uint16(38020), + 84: uint16(38033), + 85: uint16(38038), + 86: uint16(38040), + 87: uint16(38087), + 88: uint16(38095), + 89: uint16(38099), + 90: uint16(38100), + 91: uint16(38106), + 92: uint16(38118), + 93: uint16(38139), + 94: uint16(38172), + 95: uint16(38176), + 96: uint16(29723), + 97: uint16(29722), + 98: uint16(29761), + 99: uint16(29788), + 100: uint16(29783), + 101: uint16(29781), + 102: uint16(29785), + 103: uint16(29815), + 104: uint16(29805), + 105: uint16(29822), + 106: uint16(29852), + 107: uint16(29838), + 108: uint16(29824), + 109: uint16(29825), + 110: uint16(29831), + 111: uint16(29835), + 112: uint16(29854), + 113: uint16(29864), + 114: uint16(29865), + 115: uint16(29840), + 116: uint16(29863), + 117: uint16(29906), + 118: uint16(29882), + 119: uint16(38890), + 120: uint16(38891), + 121: uint16(38892), + 122: uint16(26444), + 123: uint16(26451), + 124: uint16(26462), + 125: uint16(26440), + 126: uint16(26473), + 127: uint16(26533), + 128: uint16(26503), + 129: uint16(26474), + 130: uint16(26483), + 131: uint16(26520), + 132: uint16(26535), + 133: uint16(26485), + 134: uint16(26536), + 135: uint16(26526), + 136: uint16(26541), + 137: uint16(26507), + 138: uint16(26487), + 139: uint16(26492), + 140: uint16(26608), + 141: uint16(26633), + 142: uint16(26584), + 143: uint16(26634), + 144: uint16(26601), + 145: uint16(26544), + 146: uint16(26636), + 147: uint16(26585), + 148: uint16(26549), + 149: uint16(26586), + 150: uint16(26547), + 151: uint16(26589), + 152: uint16(26624), + 153: uint16(26563), + 154: uint16(26552), + 155: uint16(26594), + 156: uint16(26638), + 157: uint16(26561), + 158: uint16(26621), + 159: uint16(26674), + 160: uint16(26675), + 161: uint16(26720), + 162: uint16(26721), + 163: uint16(26702), + 164: uint16(26722), + 165: uint16(26692), + 166: uint16(26724), + 167: uint16(26755), + 168: uint16(26653), + 169: uint16(26709), + 170: uint16(26726), + 171: uint16(26689), + 172: uint16(26727), + 173: uint16(26688), + 174: uint16(26686), + 175: uint16(26698), + 176: uint16(26697), + 177: uint16(26665), + 178: uint16(26805), + 179: uint16(26767), + 180: uint16(26740), + 181: uint16(26743), + 182: uint16(26771), + 183: uint16(26731), + 184: uint16(26818), + 185: uint16(26990), + 186: uint16(26876), + 187: uint16(26911), + 188: uint16(26912), + 189: uint16(26873), + }, + 104: { + 0: uint16(38183), + 1: uint16(38195), + 2: uint16(38205), + 3: uint16(38211), + 4: uint16(38216), + 5: uint16(38219), + 6: uint16(38229), + 7: uint16(38234), + 8: uint16(38240), + 9: uint16(38254), + 10: uint16(38260), + 11: uint16(38261), + 12: uint16(38263), + 13: uint16(38264), + 14: uint16(38265), + 15: uint16(38266), + 16: uint16(38267), + 17: uint16(38268), + 18: uint16(38269), + 19: uint16(38270), + 20: uint16(38272), + 21: uint16(38273), + 22: uint16(38274), + 23: uint16(38275), + 24: uint16(38276), + 25: uint16(38277), + 26: uint16(38278), + 27: uint16(38279), + 28: uint16(38280), + 29: uint16(38281), + 30: uint16(38282), + 31: uint16(38283), + 32: uint16(38284), + 33: uint16(38285), + 34: uint16(38286), + 35: uint16(38287), + 36: uint16(38288), + 37: uint16(38289), + 38: uint16(38290), + 39: uint16(38291), + 40: uint16(38292), + 41: uint16(38293), + 42: uint16(38294), + 43: uint16(38295), + 44: uint16(38296), + 45: uint16(38297), + 46: uint16(38298), + 47: uint16(38299), + 48: uint16(38300), + 49: uint16(38301), + 50: uint16(38302), + 51: uint16(38303), + 52: uint16(38304), + 53: uint16(38305), + 54: uint16(38306), + 55: uint16(38307), + 56: uint16(38308), + 57: uint16(38309), + 58: uint16(38310), + 59: uint16(38311), + 60: uint16(38312), + 61: uint16(38313), + 62: uint16(38314), + 63: uint16(38315), + 64: uint16(38316), + 65: uint16(38317), + 66: uint16(38318), + 67: uint16(38319), + 68: uint16(38320), + 69: uint16(38321), + 70: uint16(38322), + 71: uint16(38323), + 72: uint16(38324), + 73: uint16(38325), + 74: uint16(38326), + 75: uint16(38327), + 76: uint16(38328), + 77: uint16(38329), + 78: uint16(38330), + 79: uint16(38331), + 80: uint16(38332), + 81: uint16(38333), + 82: uint16(38334), + 83: uint16(38335), + 84: uint16(38336), + 85: uint16(38337), + 86: uint16(38338), + 87: uint16(38339), + 88: uint16(38340), + 89: uint16(38341), + 90: uint16(38342), + 91: uint16(38343), + 92: uint16(38344), + 93: uint16(38345), + 94: uint16(38346), + 95: uint16(38347), + 96: uint16(26916), + 97: uint16(26864), + 98: uint16(26891), + 99: uint16(26881), + 100: uint16(26967), + 101: uint16(26851), + 102: uint16(26896), + 103: uint16(26993), + 104: uint16(26937), + 105: uint16(26976), + 106: uint16(26946), + 107: uint16(26973), + 108: uint16(27012), + 109: uint16(26987), + 110: uint16(27008), + 111: uint16(27032), + 112: uint16(27000), + 113: uint16(26932), + 114: uint16(27084), + 115: uint16(27015), + 116: uint16(27016), + 117: uint16(27086), + 118: uint16(27017), + 119: uint16(26982), + 120: uint16(26979), + 121: uint16(27001), + 122: uint16(27035), + 123: uint16(27047), + 124: uint16(27067), + 125: uint16(27051), + 126: uint16(27053), + 127: uint16(27092), + 128: uint16(27057), + 129: uint16(27073), + 130: uint16(27082), + 131: uint16(27103), + 132: uint16(27029), + 133: uint16(27104), + 134: uint16(27021), + 135: uint16(27135), + 136: uint16(27183), + 137: uint16(27117), + 138: uint16(27159), + 139: uint16(27160), + 140: uint16(27237), + 141: uint16(27122), + 142: uint16(27204), + 143: uint16(27198), + 144: uint16(27296), + 145: uint16(27216), + 146: uint16(27227), + 147: uint16(27189), + 148: uint16(27278), + 149: uint16(27257), + 150: uint16(27197), + 151: uint16(27176), + 152: uint16(27224), + 153: uint16(27260), + 154: uint16(27281), + 155: uint16(27280), + 156: uint16(27305), + 157: uint16(27287), + 158: uint16(27307), + 159: uint16(29495), + 160: uint16(29522), + 161: uint16(27521), + 162: uint16(27522), + 163: uint16(27527), + 164: uint16(27524), + 165: uint16(27538), + 166: uint16(27539), + 167: uint16(27533), + 168: uint16(27546), + 169: uint16(27547), + 170: uint16(27553), + 171: uint16(27562), + 172: uint16(36715), + 173: uint16(36717), + 174: uint16(36721), + 175: uint16(36722), + 176: uint16(36723), + 177: uint16(36725), + 178: uint16(36726), + 179: uint16(36728), + 180: uint16(36727), + 181: uint16(36729), + 182: uint16(36730), + 183: uint16(36732), + 184: uint16(36734), + 185: uint16(36737), + 186: uint16(36738), + 187: uint16(36740), + 188: uint16(36743), + 189: uint16(36747), + }, + 105: { + 0: uint16(38348), + 1: uint16(38349), + 2: uint16(38350), + 3: uint16(38351), + 4: uint16(38352), + 5: uint16(38353), + 6: uint16(38354), + 7: uint16(38355), + 8: uint16(38356), + 9: uint16(38357), + 10: uint16(38358), + 11: uint16(38359), + 12: uint16(38360), + 13: uint16(38361), + 14: uint16(38362), + 15: uint16(38363), + 16: uint16(38364), + 17: uint16(38365), + 18: uint16(38366), + 19: uint16(38367), + 20: uint16(38368), + 21: uint16(38369), + 22: uint16(38370), + 23: uint16(38371), + 24: uint16(38372), + 25: uint16(38373), + 26: uint16(38374), + 27: uint16(38375), + 28: uint16(38380), + 29: uint16(38399), + 30: uint16(38407), + 31: uint16(38419), + 32: uint16(38424), + 33: uint16(38427), + 34: uint16(38430), + 35: uint16(38432), + 36: uint16(38435), + 37: uint16(38436), + 38: uint16(38437), + 39: uint16(38438), + 40: uint16(38439), + 41: uint16(38440), + 42: uint16(38441), + 43: uint16(38443), + 44: uint16(38444), + 45: uint16(38445), + 46: uint16(38447), + 47: uint16(38448), + 48: uint16(38455), + 49: uint16(38456), + 50: uint16(38457), + 51: uint16(38458), + 52: uint16(38462), + 53: uint16(38465), + 54: uint16(38467), + 55: uint16(38474), + 56: uint16(38478), + 57: uint16(38479), + 58: uint16(38481), + 59: uint16(38482), + 60: uint16(38483), + 61: uint16(38486), + 62: uint16(38487), + 63: uint16(38488), + 64: uint16(38489), + 65: uint16(38490), + 66: uint16(38492), + 67: uint16(38493), + 68: uint16(38494), + 69: uint16(38496), + 70: uint16(38499), + 71: uint16(38501), + 72: uint16(38502), + 73: uint16(38507), + 74: uint16(38509), + 75: uint16(38510), + 76: uint16(38511), + 77: uint16(38512), + 78: uint16(38513), + 79: uint16(38515), + 80: uint16(38520), + 81: uint16(38521), + 82: uint16(38522), + 83: uint16(38523), + 84: uint16(38524), + 85: uint16(38525), + 86: uint16(38526), + 87: uint16(38527), + 88: uint16(38528), + 89: uint16(38529), + 90: uint16(38530), + 91: uint16(38531), + 92: uint16(38532), + 93: uint16(38535), + 94: uint16(38537), + 95: uint16(38538), + 96: uint16(36749), + 97: uint16(36750), + 98: uint16(36751), + 99: uint16(36760), + 100: uint16(36762), + 101: uint16(36558), + 102: uint16(25099), + 103: uint16(25111), + 104: uint16(25115), + 105: uint16(25119), + 106: uint16(25122), + 107: uint16(25121), + 108: uint16(25125), + 109: uint16(25124), + 110: uint16(25132), + 111: uint16(33255), + 112: uint16(29935), + 113: uint16(29940), + 114: uint16(29951), + 115: uint16(29967), + 116: uint16(29969), + 117: uint16(29971), + 118: uint16(25908), + 119: uint16(26094), + 120: uint16(26095), + 121: uint16(26096), + 122: uint16(26122), + 123: uint16(26137), + 124: uint16(26482), + 125: uint16(26115), + 126: uint16(26133), + 127: uint16(26112), + 128: uint16(28805), + 129: uint16(26359), + 130: uint16(26141), + 131: uint16(26164), + 132: uint16(26161), + 133: uint16(26166), + 134: uint16(26165), + 135: uint16(32774), + 136: uint16(26207), + 137: uint16(26196), + 138: uint16(26177), + 139: uint16(26191), + 140: uint16(26198), + 141: uint16(26209), + 142: uint16(26199), + 143: uint16(26231), + 144: uint16(26244), + 145: uint16(26252), + 146: uint16(26279), + 147: uint16(26269), + 148: uint16(26302), + 149: uint16(26331), + 150: uint16(26332), + 151: uint16(26342), + 152: uint16(26345), + 153: uint16(36146), + 154: uint16(36147), + 155: uint16(36150), + 156: uint16(36155), + 157: uint16(36157), + 158: uint16(36160), + 159: uint16(36165), + 160: uint16(36166), + 161: uint16(36168), + 162: uint16(36169), + 163: uint16(36167), + 164: uint16(36173), + 165: uint16(36181), + 166: uint16(36185), + 167: uint16(35271), + 168: uint16(35274), + 169: uint16(35275), + 170: uint16(35276), + 171: uint16(35278), + 172: uint16(35279), + 173: uint16(35280), + 174: uint16(35281), + 175: uint16(29294), + 176: uint16(29343), + 177: uint16(29277), + 178: uint16(29286), + 179: uint16(29295), + 180: uint16(29310), + 181: uint16(29311), + 182: uint16(29316), + 183: uint16(29323), + 184: uint16(29325), + 185: uint16(29327), + 186: uint16(29330), + 187: uint16(25352), + 188: uint16(25394), + 189: uint16(25520), + }, + 106: { + 0: uint16(38540), + 1: uint16(38542), + 2: uint16(38545), + 3: uint16(38546), + 4: uint16(38547), + 5: uint16(38549), + 6: uint16(38550), + 7: uint16(38554), + 8: uint16(38555), + 9: uint16(38557), + 10: uint16(38558), + 11: uint16(38559), + 12: uint16(38560), + 13: uint16(38561), + 14: uint16(38562), + 15: uint16(38563), + 16: uint16(38564), + 17: uint16(38565), + 18: uint16(38566), + 19: uint16(38568), + 20: uint16(38569), + 21: uint16(38570), + 22: uint16(38571), + 23: uint16(38572), + 24: uint16(38573), + 25: uint16(38574), + 26: uint16(38575), + 27: uint16(38577), + 28: uint16(38578), + 29: uint16(38580), + 30: uint16(38581), + 31: uint16(38583), + 32: uint16(38584), + 33: uint16(38586), + 34: uint16(38587), + 35: uint16(38591), + 36: uint16(38594), + 37: uint16(38595), + 38: uint16(38600), + 39: uint16(38602), + 40: uint16(38603), + 41: uint16(38608), + 42: uint16(38609), + 43: uint16(38611), + 44: uint16(38612), + 45: uint16(38614), + 46: uint16(38615), + 47: uint16(38616), + 48: uint16(38617), + 49: uint16(38618), + 50: uint16(38619), + 51: uint16(38620), + 52: uint16(38621), + 53: uint16(38622), + 54: uint16(38623), + 55: uint16(38625), + 56: uint16(38626), + 57: uint16(38627), + 58: uint16(38628), + 59: uint16(38629), + 60: uint16(38630), + 61: uint16(38631), + 62: uint16(38635), + 63: uint16(38636), + 64: uint16(38637), + 65: uint16(38638), + 66: uint16(38640), + 67: uint16(38641), + 68: uint16(38642), + 69: uint16(38644), + 70: uint16(38645), + 71: uint16(38648), + 72: uint16(38650), + 73: uint16(38651), + 74: uint16(38652), + 75: uint16(38653), + 76: uint16(38655), + 77: uint16(38658), + 78: uint16(38659), + 79: uint16(38661), + 80: uint16(38666), + 81: uint16(38667), + 82: uint16(38668), + 83: uint16(38672), + 84: uint16(38673), + 85: uint16(38674), + 86: uint16(38676), + 87: uint16(38677), + 88: uint16(38679), + 89: uint16(38680), + 90: uint16(38681), + 91: uint16(38682), + 92: uint16(38683), + 93: uint16(38685), + 94: uint16(38687), + 95: uint16(38688), + 96: uint16(25663), + 97: uint16(25816), + 98: uint16(32772), + 99: uint16(27626), + 100: uint16(27635), + 101: uint16(27645), + 102: uint16(27637), + 103: uint16(27641), + 104: uint16(27653), + 105: uint16(27655), + 106: uint16(27654), + 107: uint16(27661), + 108: uint16(27669), + 109: uint16(27672), + 110: uint16(27673), + 111: uint16(27674), + 112: uint16(27681), + 113: uint16(27689), + 114: uint16(27684), + 115: uint16(27690), + 116: uint16(27698), + 117: uint16(25909), + 118: uint16(25941), + 119: uint16(25963), + 120: uint16(29261), + 121: uint16(29266), + 122: uint16(29270), + 123: uint16(29232), + 124: uint16(34402), + 125: uint16(21014), + 126: uint16(32927), + 127: uint16(32924), + 128: uint16(32915), + 129: uint16(32956), + 130: uint16(26378), + 131: uint16(32957), + 132: uint16(32945), + 133: uint16(32939), + 134: uint16(32941), + 135: uint16(32948), + 136: uint16(32951), + 137: uint16(32999), + 138: uint16(33000), + 139: uint16(33001), + 140: uint16(33002), + 141: uint16(32987), + 142: uint16(32962), + 143: uint16(32964), + 144: uint16(32985), + 145: uint16(32973), + 146: uint16(32983), + 147: uint16(26384), + 148: uint16(32989), + 149: uint16(33003), + 150: uint16(33009), + 151: uint16(33012), + 152: uint16(33005), + 153: uint16(33037), + 154: uint16(33038), + 155: uint16(33010), + 156: uint16(33020), + 157: uint16(26389), + 158: uint16(33042), + 159: uint16(35930), + 160: uint16(33078), + 161: uint16(33054), + 162: uint16(33068), + 163: uint16(33048), + 164: uint16(33074), + 165: uint16(33096), + 166: uint16(33100), + 167: uint16(33107), + 168: uint16(33140), + 169: uint16(33113), + 170: uint16(33114), + 171: uint16(33137), + 172: uint16(33120), + 173: uint16(33129), + 174: uint16(33148), + 175: uint16(33149), + 176: uint16(33133), + 177: uint16(33127), + 178: uint16(22605), + 179: uint16(23221), + 180: uint16(33160), + 181: uint16(33154), + 182: uint16(33169), + 183: uint16(28373), + 184: uint16(33187), + 185: uint16(33194), + 186: uint16(33228), + 187: uint16(26406), + 188: uint16(33226), + 189: uint16(33211), + }, + 107: { + 0: uint16(38689), + 1: uint16(38690), + 2: uint16(38691), + 3: uint16(38692), + 4: uint16(38693), + 5: uint16(38694), + 6: uint16(38695), + 7: uint16(38696), + 8: uint16(38697), + 9: uint16(38699), + 10: uint16(38700), + 11: uint16(38702), + 12: uint16(38703), + 13: uint16(38705), + 14: uint16(38707), + 15: uint16(38708), + 16: uint16(38709), + 17: uint16(38710), + 18: uint16(38711), + 19: uint16(38714), + 20: uint16(38715), + 21: uint16(38716), + 22: uint16(38717), + 23: uint16(38719), + 24: uint16(38720), + 25: uint16(38721), + 26: uint16(38722), + 27: uint16(38723), + 28: uint16(38724), + 29: uint16(38725), + 30: uint16(38726), + 31: uint16(38727), + 32: uint16(38728), + 33: uint16(38729), + 34: uint16(38730), + 35: uint16(38731), + 36: uint16(38732), + 37: uint16(38733), + 38: uint16(38734), + 39: uint16(38735), + 40: uint16(38736), + 41: uint16(38737), + 42: uint16(38740), + 43: uint16(38741), + 44: uint16(38743), + 45: uint16(38744), + 46: uint16(38746), + 47: uint16(38748), + 48: uint16(38749), + 49: uint16(38751), + 50: uint16(38755), + 51: uint16(38756), + 52: uint16(38758), + 53: uint16(38759), + 54: uint16(38760), + 55: uint16(38762), + 56: uint16(38763), + 57: uint16(38764), + 58: uint16(38765), + 59: uint16(38766), + 60: uint16(38767), + 61: uint16(38768), + 62: uint16(38769), + 63: uint16(38770), + 64: uint16(38773), + 65: uint16(38775), + 66: uint16(38776), + 67: uint16(38777), + 68: uint16(38778), + 69: uint16(38779), + 70: uint16(38781), + 71: uint16(38782), + 72: uint16(38783), + 73: uint16(38784), + 74: uint16(38785), + 75: uint16(38786), + 76: uint16(38787), + 77: uint16(38788), + 78: uint16(38790), + 79: uint16(38791), + 80: uint16(38792), + 81: uint16(38793), + 82: uint16(38794), + 83: uint16(38796), + 84: uint16(38798), + 85: uint16(38799), + 86: uint16(38800), + 87: uint16(38803), + 88: uint16(38805), + 89: uint16(38806), + 90: uint16(38807), + 91: uint16(38809), + 92: uint16(38810), + 93: uint16(38811), + 94: uint16(38812), + 95: uint16(38813), + 96: uint16(33217), + 97: uint16(33190), + 98: uint16(27428), + 99: uint16(27447), + 100: uint16(27449), + 101: uint16(27459), + 102: uint16(27462), + 103: uint16(27481), + 104: uint16(39121), + 105: uint16(39122), + 106: uint16(39123), + 107: uint16(39125), + 108: uint16(39129), + 109: uint16(39130), + 110: uint16(27571), + 111: uint16(24384), + 112: uint16(27586), + 113: uint16(35315), + 114: uint16(26000), + 115: uint16(40785), + 116: uint16(26003), + 117: uint16(26044), + 118: uint16(26054), + 119: uint16(26052), + 120: uint16(26051), + 121: uint16(26060), + 122: uint16(26062), + 123: uint16(26066), + 124: uint16(26070), + 125: uint16(28800), + 126: uint16(28828), + 127: uint16(28822), + 128: uint16(28829), + 129: uint16(28859), + 130: uint16(28864), + 131: uint16(28855), + 132: uint16(28843), + 133: uint16(28849), + 134: uint16(28904), + 135: uint16(28874), + 136: uint16(28944), + 137: uint16(28947), + 138: uint16(28950), + 139: uint16(28975), + 140: uint16(28977), + 141: uint16(29043), + 142: uint16(29020), + 143: uint16(29032), + 144: uint16(28997), + 145: uint16(29042), + 146: uint16(29002), + 147: uint16(29048), + 148: uint16(29050), + 149: uint16(29080), + 150: uint16(29107), + 151: uint16(29109), + 152: uint16(29096), + 153: uint16(29088), + 154: uint16(29152), + 155: uint16(29140), + 156: uint16(29159), + 157: uint16(29177), + 158: uint16(29213), + 159: uint16(29224), + 160: uint16(28780), + 161: uint16(28952), + 162: uint16(29030), + 163: uint16(29113), + 164: uint16(25150), + 165: uint16(25149), + 166: uint16(25155), + 167: uint16(25160), + 168: uint16(25161), + 169: uint16(31035), + 170: uint16(31040), + 171: uint16(31046), + 172: uint16(31049), + 173: uint16(31067), + 174: uint16(31068), + 175: uint16(31059), + 176: uint16(31066), + 177: uint16(31074), + 178: uint16(31063), + 179: uint16(31072), + 180: uint16(31087), + 181: uint16(31079), + 182: uint16(31098), + 183: uint16(31109), + 184: uint16(31114), + 185: uint16(31130), + 186: uint16(31143), + 187: uint16(31155), + 188: uint16(24529), + 189: uint16(24528), + }, + 108: { + 0: uint16(38814), + 1: uint16(38815), + 2: uint16(38817), + 3: uint16(38818), + 4: uint16(38820), + 5: uint16(38821), + 6: uint16(38822), + 7: uint16(38823), + 8: uint16(38824), + 9: uint16(38825), + 10: uint16(38826), + 11: uint16(38828), + 12: uint16(38830), + 13: uint16(38832), + 14: uint16(38833), + 15: uint16(38835), + 16: uint16(38837), + 17: uint16(38838), + 18: uint16(38839), + 19: uint16(38840), + 20: uint16(38841), + 21: uint16(38842), + 22: uint16(38843), + 23: uint16(38844), + 24: uint16(38845), + 25: uint16(38846), + 26: uint16(38847), + 27: uint16(38848), + 28: uint16(38849), + 29: uint16(38850), + 30: uint16(38851), + 31: uint16(38852), + 32: uint16(38853), + 33: uint16(38854), + 34: uint16(38855), + 35: uint16(38856), + 36: uint16(38857), + 37: uint16(38858), + 38: uint16(38859), + 39: uint16(38860), + 40: uint16(38861), + 41: uint16(38862), + 42: uint16(38863), + 43: uint16(38864), + 44: uint16(38865), + 45: uint16(38866), + 46: uint16(38867), + 47: uint16(38868), + 48: uint16(38869), + 49: uint16(38870), + 50: uint16(38871), + 51: uint16(38872), + 52: uint16(38873), + 53: uint16(38874), + 54: uint16(38875), + 55: uint16(38876), + 56: uint16(38877), + 57: uint16(38878), + 58: uint16(38879), + 59: uint16(38880), + 60: uint16(38881), + 61: uint16(38882), + 62: uint16(38883), + 63: uint16(38884), + 64: uint16(38885), + 65: uint16(38888), + 66: uint16(38894), + 67: uint16(38895), + 68: uint16(38896), + 69: uint16(38897), + 70: uint16(38898), + 71: uint16(38900), + 72: uint16(38903), + 73: uint16(38904), + 74: uint16(38905), + 75: uint16(38906), + 76: uint16(38907), + 77: uint16(38908), + 78: uint16(38909), + 79: uint16(38910), + 80: uint16(38911), + 81: uint16(38912), + 82: uint16(38913), + 83: uint16(38914), + 84: uint16(38915), + 85: uint16(38916), + 86: uint16(38917), + 87: uint16(38918), + 88: uint16(38919), + 89: uint16(38920), + 90: uint16(38921), + 91: uint16(38922), + 92: uint16(38923), + 93: uint16(38924), + 94: uint16(38925), + 95: uint16(38926), + 96: uint16(24636), + 97: uint16(24669), + 98: uint16(24666), + 99: uint16(24679), + 100: uint16(24641), + 101: uint16(24665), + 102: uint16(24675), + 103: uint16(24747), + 104: uint16(24838), + 105: uint16(24845), + 106: uint16(24925), + 107: uint16(25001), + 108: uint16(24989), + 109: uint16(25035), + 110: uint16(25041), + 111: uint16(25094), + 112: uint16(32896), + 113: uint16(32895), + 114: uint16(27795), + 115: uint16(27894), + 116: uint16(28156), + 117: uint16(30710), + 118: uint16(30712), + 119: uint16(30720), + 120: uint16(30729), + 121: uint16(30743), + 122: uint16(30744), + 123: uint16(30737), + 124: uint16(26027), + 125: uint16(30765), + 126: uint16(30748), + 127: uint16(30749), + 128: uint16(30777), + 129: uint16(30778), + 130: uint16(30779), + 131: uint16(30751), + 132: uint16(30780), + 133: uint16(30757), + 134: uint16(30764), + 135: uint16(30755), + 136: uint16(30761), + 137: uint16(30798), + 138: uint16(30829), + 139: uint16(30806), + 140: uint16(30807), + 141: uint16(30758), + 142: uint16(30800), + 143: uint16(30791), + 144: uint16(30796), + 145: uint16(30826), + 146: uint16(30875), + 147: uint16(30867), + 148: uint16(30874), + 149: uint16(30855), + 150: uint16(30876), + 151: uint16(30881), + 152: uint16(30883), + 153: uint16(30898), + 154: uint16(30905), + 155: uint16(30885), + 156: uint16(30932), + 157: uint16(30937), + 158: uint16(30921), + 159: uint16(30956), + 160: uint16(30962), + 161: uint16(30981), + 162: uint16(30964), + 163: uint16(30995), + 164: uint16(31012), + 165: uint16(31006), + 166: uint16(31028), + 167: uint16(40859), + 168: uint16(40697), + 169: uint16(40699), + 170: uint16(40700), + 171: uint16(30449), + 172: uint16(30468), + 173: uint16(30477), + 174: uint16(30457), + 175: uint16(30471), + 176: uint16(30472), + 177: uint16(30490), + 178: uint16(30498), + 179: uint16(30489), + 180: uint16(30509), + 181: uint16(30502), + 182: uint16(30517), + 183: uint16(30520), + 184: uint16(30544), + 185: uint16(30545), + 186: uint16(30535), + 187: uint16(30531), + 188: uint16(30554), + 189: uint16(30568), + }, + 109: { + 0: uint16(38927), + 1: uint16(38928), + 2: uint16(38929), + 3: uint16(38930), + 4: uint16(38931), + 5: uint16(38932), + 6: uint16(38933), + 7: uint16(38934), + 8: uint16(38935), + 9: uint16(38936), + 10: uint16(38937), + 11: uint16(38938), + 12: uint16(38939), + 13: uint16(38940), + 14: uint16(38941), + 15: uint16(38942), + 16: uint16(38943), + 17: uint16(38944), + 18: uint16(38945), + 19: uint16(38946), + 20: uint16(38947), + 21: uint16(38948), + 22: uint16(38949), + 23: uint16(38950), + 24: uint16(38951), + 25: uint16(38952), + 26: uint16(38953), + 27: uint16(38954), + 28: uint16(38955), + 29: uint16(38956), + 30: uint16(38957), + 31: uint16(38958), + 32: uint16(38959), + 33: uint16(38960), + 34: uint16(38961), + 35: uint16(38962), + 36: uint16(38963), + 37: uint16(38964), + 38: uint16(38965), + 39: uint16(38966), + 40: uint16(38967), + 41: uint16(38968), + 42: uint16(38969), + 43: uint16(38970), + 44: uint16(38971), + 45: uint16(38972), + 46: uint16(38973), + 47: uint16(38974), + 48: uint16(38975), + 49: uint16(38976), + 50: uint16(38977), + 51: uint16(38978), + 52: uint16(38979), + 53: uint16(38980), + 54: uint16(38981), + 55: uint16(38982), + 56: uint16(38983), + 57: uint16(38984), + 58: uint16(38985), + 59: uint16(38986), + 60: uint16(38987), + 61: uint16(38988), + 62: uint16(38989), + 63: uint16(38990), + 64: uint16(38991), + 65: uint16(38992), + 66: uint16(38993), + 67: uint16(38994), + 68: uint16(38995), + 69: uint16(38996), + 70: uint16(38997), + 71: uint16(38998), + 72: uint16(38999), + 73: uint16(39000), + 74: uint16(39001), + 75: uint16(39002), + 76: uint16(39003), + 77: uint16(39004), + 78: uint16(39005), + 79: uint16(39006), + 80: uint16(39007), + 81: uint16(39008), + 82: uint16(39009), + 83: uint16(39010), + 84: uint16(39011), + 85: uint16(39012), + 86: uint16(39013), + 87: uint16(39014), + 88: uint16(39015), + 89: uint16(39016), + 90: uint16(39017), + 91: uint16(39018), + 92: uint16(39019), + 93: uint16(39020), + 94: uint16(39021), + 95: uint16(39022), + 96: uint16(30562), + 97: uint16(30565), + 98: uint16(30591), + 99: uint16(30605), + 100: uint16(30589), + 101: uint16(30592), + 102: uint16(30604), + 103: uint16(30609), + 104: uint16(30623), + 105: uint16(30624), + 106: uint16(30640), + 107: uint16(30645), + 108: uint16(30653), + 109: uint16(30010), + 110: uint16(30016), + 111: uint16(30030), + 112: uint16(30027), + 113: uint16(30024), + 114: uint16(30043), + 115: uint16(30066), + 116: uint16(30073), + 117: uint16(30083), + 118: uint16(32600), + 119: uint16(32609), + 120: uint16(32607), + 121: uint16(35400), + 122: uint16(32616), + 123: uint16(32628), + 124: uint16(32625), + 125: uint16(32633), + 126: uint16(32641), + 127: uint16(32638), + 128: uint16(30413), + 129: uint16(30437), + 130: uint16(34866), + 131: uint16(38021), + 132: uint16(38022), + 133: uint16(38023), + 134: uint16(38027), + 135: uint16(38026), + 136: uint16(38028), + 137: uint16(38029), + 138: uint16(38031), + 139: uint16(38032), + 140: uint16(38036), + 141: uint16(38039), + 142: uint16(38037), + 143: uint16(38042), + 144: uint16(38043), + 145: uint16(38044), + 146: uint16(38051), + 147: uint16(38052), + 148: uint16(38059), + 149: uint16(38058), + 150: uint16(38061), + 151: uint16(38060), + 152: uint16(38063), + 153: uint16(38064), + 154: uint16(38066), + 155: uint16(38068), + 156: uint16(38070), + 157: uint16(38071), + 158: uint16(38072), + 159: uint16(38073), + 160: uint16(38074), + 161: uint16(38076), + 162: uint16(38077), + 163: uint16(38079), + 164: uint16(38084), + 165: uint16(38088), + 166: uint16(38089), + 167: uint16(38090), + 168: uint16(38091), + 169: uint16(38092), + 170: uint16(38093), + 171: uint16(38094), + 172: uint16(38096), + 173: uint16(38097), + 174: uint16(38098), + 175: uint16(38101), + 176: uint16(38102), + 177: uint16(38103), + 178: uint16(38105), + 179: uint16(38104), + 180: uint16(38107), + 181: uint16(38110), + 182: uint16(38111), + 183: uint16(38112), + 184: uint16(38114), + 185: uint16(38116), + 186: uint16(38117), + 187: uint16(38119), + 188: uint16(38120), + 189: uint16(38122), + }, + 110: { + 0: uint16(39023), + 1: uint16(39024), + 2: uint16(39025), + 3: uint16(39026), + 4: uint16(39027), + 5: uint16(39028), + 6: uint16(39051), + 7: uint16(39054), + 8: uint16(39058), + 9: uint16(39061), + 10: uint16(39065), + 11: uint16(39075), + 12: uint16(39080), + 13: uint16(39081), + 14: uint16(39082), + 15: uint16(39083), + 16: uint16(39084), + 17: uint16(39085), + 18: uint16(39086), + 19: uint16(39087), + 20: uint16(39088), + 21: uint16(39089), + 22: uint16(39090), + 23: uint16(39091), + 24: uint16(39092), + 25: uint16(39093), + 26: uint16(39094), + 27: uint16(39095), + 28: uint16(39096), + 29: uint16(39097), + 30: uint16(39098), + 31: uint16(39099), + 32: uint16(39100), + 33: uint16(39101), + 34: uint16(39102), + 35: uint16(39103), + 36: uint16(39104), + 37: uint16(39105), + 38: uint16(39106), + 39: uint16(39107), + 40: uint16(39108), + 41: uint16(39109), + 42: uint16(39110), + 43: uint16(39111), + 44: uint16(39112), + 45: uint16(39113), + 46: uint16(39114), + 47: uint16(39115), + 48: uint16(39116), + 49: uint16(39117), + 50: uint16(39119), + 51: uint16(39120), + 52: uint16(39124), + 53: uint16(39126), + 54: uint16(39127), + 55: uint16(39131), + 56: uint16(39132), + 57: uint16(39133), + 58: uint16(39136), + 59: uint16(39137), + 60: uint16(39138), + 61: uint16(39139), + 62: uint16(39140), + 63: uint16(39141), + 64: uint16(39142), + 65: uint16(39145), + 66: uint16(39146), + 67: uint16(39147), + 68: uint16(39148), + 69: uint16(39149), + 70: uint16(39150), + 71: uint16(39151), + 72: uint16(39152), + 73: uint16(39153), + 74: uint16(39154), + 75: uint16(39155), + 76: uint16(39156), + 77: uint16(39157), + 78: uint16(39158), + 79: uint16(39159), + 80: uint16(39160), + 81: uint16(39161), + 82: uint16(39162), + 83: uint16(39163), + 84: uint16(39164), + 85: uint16(39165), + 86: uint16(39166), + 87: uint16(39167), + 88: uint16(39168), + 89: uint16(39169), + 90: uint16(39170), + 91: uint16(39171), + 92: uint16(39172), + 93: uint16(39173), + 94: uint16(39174), + 95: uint16(39175), + 96: uint16(38121), + 97: uint16(38123), + 98: uint16(38126), + 99: uint16(38127), + 100: uint16(38131), + 101: uint16(38132), + 102: uint16(38133), + 103: uint16(38135), + 104: uint16(38137), + 105: uint16(38140), + 106: uint16(38141), + 107: uint16(38143), + 108: uint16(38147), + 109: uint16(38146), + 110: uint16(38150), + 111: uint16(38151), + 112: uint16(38153), + 113: uint16(38154), + 114: uint16(38157), + 115: uint16(38158), + 116: uint16(38159), + 117: uint16(38162), + 118: uint16(38163), + 119: uint16(38164), + 120: uint16(38165), + 121: uint16(38166), + 122: uint16(38168), + 123: uint16(38171), + 124: uint16(38173), + 125: uint16(38174), + 126: uint16(38175), + 127: uint16(38178), + 128: uint16(38186), + 129: uint16(38187), + 130: uint16(38185), + 131: uint16(38188), + 132: uint16(38193), + 133: uint16(38194), + 134: uint16(38196), + 135: uint16(38198), + 136: uint16(38199), + 137: uint16(38200), + 138: uint16(38204), + 139: uint16(38206), + 140: uint16(38207), + 141: uint16(38210), + 142: uint16(38197), + 143: uint16(38212), + 144: uint16(38213), + 145: uint16(38214), + 146: uint16(38217), + 147: uint16(38220), + 148: uint16(38222), + 149: uint16(38223), + 150: uint16(38226), + 151: uint16(38227), + 152: uint16(38228), + 153: uint16(38230), + 154: uint16(38231), + 155: uint16(38232), + 156: uint16(38233), + 157: uint16(38235), + 158: uint16(38238), + 159: uint16(38239), + 160: uint16(38237), + 161: uint16(38241), + 162: uint16(38242), + 163: uint16(38244), + 164: uint16(38245), + 165: uint16(38246), + 166: uint16(38247), + 167: uint16(38248), + 168: uint16(38249), + 169: uint16(38250), + 170: uint16(38251), + 171: uint16(38252), + 172: uint16(38255), + 173: uint16(38257), + 174: uint16(38258), + 175: uint16(38259), + 176: uint16(38202), + 177: uint16(30695), + 178: uint16(30700), + 179: uint16(38601), + 180: uint16(31189), + 181: uint16(31213), + 182: uint16(31203), + 183: uint16(31211), + 184: uint16(31238), + 185: uint16(23879), + 186: uint16(31235), + 187: uint16(31234), + 188: uint16(31262), + 189: uint16(31252), + }, + 111: { + 0: uint16(39176), + 1: uint16(39177), + 2: uint16(39178), + 3: uint16(39179), + 4: uint16(39180), + 5: uint16(39182), + 6: uint16(39183), + 7: uint16(39185), + 8: uint16(39186), + 9: uint16(39187), + 10: uint16(39188), + 11: uint16(39189), + 12: uint16(39190), + 13: uint16(39191), + 14: uint16(39192), + 15: uint16(39193), + 16: uint16(39194), + 17: uint16(39195), + 18: uint16(39196), + 19: uint16(39197), + 20: uint16(39198), + 21: uint16(39199), + 22: uint16(39200), + 23: uint16(39201), + 24: uint16(39202), + 25: uint16(39203), + 26: uint16(39204), + 27: uint16(39205), + 28: uint16(39206), + 29: uint16(39207), + 30: uint16(39208), + 31: uint16(39209), + 32: uint16(39210), + 33: uint16(39211), + 34: uint16(39212), + 35: uint16(39213), + 36: uint16(39215), + 37: uint16(39216), + 38: uint16(39217), + 39: uint16(39218), + 40: uint16(39219), + 41: uint16(39220), + 42: uint16(39221), + 43: uint16(39222), + 44: uint16(39223), + 45: uint16(39224), + 46: uint16(39225), + 47: uint16(39226), + 48: uint16(39227), + 49: uint16(39228), + 50: uint16(39229), + 51: uint16(39230), + 52: uint16(39231), + 53: uint16(39232), + 54: uint16(39233), + 55: uint16(39234), + 56: uint16(39235), + 57: uint16(39236), + 58: uint16(39237), + 59: uint16(39238), + 60: uint16(39239), + 61: uint16(39240), + 62: uint16(39241), + 63: uint16(39242), + 64: uint16(39243), + 65: uint16(39244), + 66: uint16(39245), + 67: uint16(39246), + 68: uint16(39247), + 69: uint16(39248), + 70: uint16(39249), + 71: uint16(39250), + 72: uint16(39251), + 73: uint16(39254), + 74: uint16(39255), + 75: uint16(39256), + 76: uint16(39257), + 77: uint16(39258), + 78: uint16(39259), + 79: uint16(39260), + 80: uint16(39261), + 81: uint16(39262), + 82: uint16(39263), + 83: uint16(39264), + 84: uint16(39265), + 85: uint16(39266), + 86: uint16(39268), + 87: uint16(39270), + 88: uint16(39283), + 89: uint16(39288), + 90: uint16(39289), + 91: uint16(39291), + 92: uint16(39294), + 93: uint16(39298), + 94: uint16(39299), + 95: uint16(39305), + 96: uint16(31289), + 97: uint16(31287), + 98: uint16(31313), + 99: uint16(40655), + 100: uint16(39333), + 101: uint16(31344), + 102: uint16(30344), + 103: uint16(30350), + 104: uint16(30355), + 105: uint16(30361), + 106: uint16(30372), + 107: uint16(29918), + 108: uint16(29920), + 109: uint16(29996), + 110: uint16(40480), + 111: uint16(40482), + 112: uint16(40488), + 113: uint16(40489), + 114: uint16(40490), + 115: uint16(40491), + 116: uint16(40492), + 117: uint16(40498), + 118: uint16(40497), + 119: uint16(40502), + 120: uint16(40504), + 121: uint16(40503), + 122: uint16(40505), + 123: uint16(40506), + 124: uint16(40510), + 125: uint16(40513), + 126: uint16(40514), + 127: uint16(40516), + 128: uint16(40518), + 129: uint16(40519), + 130: uint16(40520), + 131: uint16(40521), + 132: uint16(40523), + 133: uint16(40524), + 134: uint16(40526), + 135: uint16(40529), + 136: uint16(40533), + 137: uint16(40535), + 138: uint16(40538), + 139: uint16(40539), + 140: uint16(40540), + 141: uint16(40542), + 142: uint16(40547), + 143: uint16(40550), + 144: uint16(40551), + 145: uint16(40552), + 146: uint16(40553), + 147: uint16(40554), + 148: uint16(40555), + 149: uint16(40556), + 150: uint16(40561), + 151: uint16(40557), + 152: uint16(40563), + 153: uint16(30098), + 154: uint16(30100), + 155: uint16(30102), + 156: uint16(30112), + 157: uint16(30109), + 158: uint16(30124), + 159: uint16(30115), + 160: uint16(30131), + 161: uint16(30132), + 162: uint16(30136), + 163: uint16(30148), + 164: uint16(30129), + 165: uint16(30128), + 166: uint16(30147), + 167: uint16(30146), + 168: uint16(30166), + 169: uint16(30157), + 170: uint16(30179), + 171: uint16(30184), + 172: uint16(30182), + 173: uint16(30180), + 174: uint16(30187), + 175: uint16(30183), + 176: uint16(30211), + 177: uint16(30193), + 178: uint16(30204), + 179: uint16(30207), + 180: uint16(30224), + 181: uint16(30208), + 182: uint16(30213), + 183: uint16(30220), + 184: uint16(30231), + 185: uint16(30218), + 186: uint16(30245), + 187: uint16(30232), + 188: uint16(30229), + 189: uint16(30233), + }, + 112: { + 0: uint16(39308), + 1: uint16(39310), + 2: uint16(39322), + 3: uint16(39323), + 4: uint16(39324), + 5: uint16(39325), + 6: uint16(39326), + 7: uint16(39327), + 8: uint16(39328), + 9: uint16(39329), + 10: uint16(39330), + 11: uint16(39331), + 12: uint16(39332), + 13: uint16(39334), + 14: uint16(39335), + 15: uint16(39337), + 16: uint16(39338), + 17: uint16(39339), + 18: uint16(39340), + 19: uint16(39341), + 20: uint16(39342), + 21: uint16(39343), + 22: uint16(39344), + 23: uint16(39345), + 24: uint16(39346), + 25: uint16(39347), + 26: uint16(39348), + 27: uint16(39349), + 28: uint16(39350), + 29: uint16(39351), + 30: uint16(39352), + 31: uint16(39353), + 32: uint16(39354), + 33: uint16(39355), + 34: uint16(39356), + 35: uint16(39357), + 36: uint16(39358), + 37: uint16(39359), + 38: uint16(39360), + 39: uint16(39361), + 40: uint16(39362), + 41: uint16(39363), + 42: uint16(39364), + 43: uint16(39365), + 44: uint16(39366), + 45: uint16(39367), + 46: uint16(39368), + 47: uint16(39369), + 48: uint16(39370), + 49: uint16(39371), + 50: uint16(39372), + 51: uint16(39373), + 52: uint16(39374), + 53: uint16(39375), + 54: uint16(39376), + 55: uint16(39377), + 56: uint16(39378), + 57: uint16(39379), + 58: uint16(39380), + 59: uint16(39381), + 60: uint16(39382), + 61: uint16(39383), + 62: uint16(39384), + 63: uint16(39385), + 64: uint16(39386), + 65: uint16(39387), + 66: uint16(39388), + 67: uint16(39389), + 68: uint16(39390), + 69: uint16(39391), + 70: uint16(39392), + 71: uint16(39393), + 72: uint16(39394), + 73: uint16(39395), + 74: uint16(39396), + 75: uint16(39397), + 76: uint16(39398), + 77: uint16(39399), + 78: uint16(39400), + 79: uint16(39401), + 80: uint16(39402), + 81: uint16(39403), + 82: uint16(39404), + 83: uint16(39405), + 84: uint16(39406), + 85: uint16(39407), + 86: uint16(39408), + 87: uint16(39409), + 88: uint16(39410), + 89: uint16(39411), + 90: uint16(39412), + 91: uint16(39413), + 92: uint16(39414), + 93: uint16(39415), + 94: uint16(39416), + 95: uint16(39417), + 96: uint16(30235), + 97: uint16(30268), + 98: uint16(30242), + 99: uint16(30240), + 100: uint16(30272), + 101: uint16(30253), + 102: uint16(30256), + 103: uint16(30271), + 104: uint16(30261), + 105: uint16(30275), + 106: uint16(30270), + 107: uint16(30259), + 108: uint16(30285), + 109: uint16(30302), + 110: uint16(30292), + 111: uint16(30300), + 112: uint16(30294), + 113: uint16(30315), + 114: uint16(30319), + 115: uint16(32714), + 116: uint16(31462), + 117: uint16(31352), + 118: uint16(31353), + 119: uint16(31360), + 120: uint16(31366), + 121: uint16(31368), + 122: uint16(31381), + 123: uint16(31398), + 124: uint16(31392), + 125: uint16(31404), + 126: uint16(31400), + 127: uint16(31405), + 128: uint16(31411), + 129: uint16(34916), + 130: uint16(34921), + 131: uint16(34930), + 132: uint16(34941), + 133: uint16(34943), + 134: uint16(34946), + 135: uint16(34978), + 136: uint16(35014), + 137: uint16(34999), + 138: uint16(35004), + 139: uint16(35017), + 140: uint16(35042), + 141: uint16(35022), + 142: uint16(35043), + 143: uint16(35045), + 144: uint16(35057), + 145: uint16(35098), + 146: uint16(35068), + 147: uint16(35048), + 148: uint16(35070), + 149: uint16(35056), + 150: uint16(35105), + 151: uint16(35097), + 152: uint16(35091), + 153: uint16(35099), + 154: uint16(35082), + 155: uint16(35124), + 156: uint16(35115), + 157: uint16(35126), + 158: uint16(35137), + 159: uint16(35174), + 160: uint16(35195), + 161: uint16(30091), + 162: uint16(32997), + 163: uint16(30386), + 164: uint16(30388), + 165: uint16(30684), + 166: uint16(32786), + 167: uint16(32788), + 168: uint16(32790), + 169: uint16(32796), + 170: uint16(32800), + 171: uint16(32802), + 172: uint16(32805), + 173: uint16(32806), + 174: uint16(32807), + 175: uint16(32809), + 176: uint16(32808), + 177: uint16(32817), + 178: uint16(32779), + 179: uint16(32821), + 180: uint16(32835), + 181: uint16(32838), + 182: uint16(32845), + 183: uint16(32850), + 184: uint16(32873), + 185: uint16(32881), + 186: uint16(35203), + 187: uint16(39032), + 188: uint16(39040), + 189: uint16(39043), + }, + 113: { + 0: uint16(39418), + 1: uint16(39419), + 2: uint16(39420), + 3: uint16(39421), + 4: uint16(39422), + 5: uint16(39423), + 6: uint16(39424), + 7: uint16(39425), + 8: uint16(39426), + 9: uint16(39427), + 10: uint16(39428), + 11: uint16(39429), + 12: uint16(39430), + 13: uint16(39431), + 14: uint16(39432), + 15: uint16(39433), + 16: uint16(39434), + 17: uint16(39435), + 18: uint16(39436), + 19: uint16(39437), + 20: uint16(39438), + 21: uint16(39439), + 22: uint16(39440), + 23: uint16(39441), + 24: uint16(39442), + 25: uint16(39443), + 26: uint16(39444), + 27: uint16(39445), + 28: uint16(39446), + 29: uint16(39447), + 30: uint16(39448), + 31: uint16(39449), + 32: uint16(39450), + 33: uint16(39451), + 34: uint16(39452), + 35: uint16(39453), + 36: uint16(39454), + 37: uint16(39455), + 38: uint16(39456), + 39: uint16(39457), + 40: uint16(39458), + 41: uint16(39459), + 42: uint16(39460), + 43: uint16(39461), + 44: uint16(39462), + 45: uint16(39463), + 46: uint16(39464), + 47: uint16(39465), + 48: uint16(39466), + 49: uint16(39467), + 50: uint16(39468), + 51: uint16(39469), + 52: uint16(39470), + 53: uint16(39471), + 54: uint16(39472), + 55: uint16(39473), + 56: uint16(39474), + 57: uint16(39475), + 58: uint16(39476), + 59: uint16(39477), + 60: uint16(39478), + 61: uint16(39479), + 62: uint16(39480), + 63: uint16(39481), + 64: uint16(39482), + 65: uint16(39483), + 66: uint16(39484), + 67: uint16(39485), + 68: uint16(39486), + 69: uint16(39487), + 70: uint16(39488), + 71: uint16(39489), + 72: uint16(39490), + 73: uint16(39491), + 74: uint16(39492), + 75: uint16(39493), + 76: uint16(39494), + 77: uint16(39495), + 78: uint16(39496), + 79: uint16(39497), + 80: uint16(39498), + 81: uint16(39499), + 82: uint16(39500), + 83: uint16(39501), + 84: uint16(39502), + 85: uint16(39503), + 86: uint16(39504), + 87: uint16(39505), + 88: uint16(39506), + 89: uint16(39507), + 90: uint16(39508), + 91: uint16(39509), + 92: uint16(39510), + 93: uint16(39511), + 94: uint16(39512), + 95: uint16(39513), + 96: uint16(39049), + 97: uint16(39052), + 98: uint16(39053), + 99: uint16(39055), + 100: uint16(39060), + 101: uint16(39066), + 102: uint16(39067), + 103: uint16(39070), + 104: uint16(39071), + 105: uint16(39073), + 106: uint16(39074), + 107: uint16(39077), + 108: uint16(39078), + 109: uint16(34381), + 110: uint16(34388), + 111: uint16(34412), + 112: uint16(34414), + 113: uint16(34431), + 114: uint16(34426), + 115: uint16(34428), + 116: uint16(34427), + 117: uint16(34472), + 118: uint16(34445), + 119: uint16(34443), + 120: uint16(34476), + 121: uint16(34461), + 122: uint16(34471), + 123: uint16(34467), + 124: uint16(34474), + 125: uint16(34451), + 126: uint16(34473), + 127: uint16(34486), + 128: uint16(34500), + 129: uint16(34485), + 130: uint16(34510), + 131: uint16(34480), + 132: uint16(34490), + 133: uint16(34481), + 134: uint16(34479), + 135: uint16(34505), + 136: uint16(34511), + 137: uint16(34484), + 138: uint16(34537), + 139: uint16(34545), + 140: uint16(34546), + 141: uint16(34541), + 142: uint16(34547), + 143: uint16(34512), + 144: uint16(34579), + 145: uint16(34526), + 146: uint16(34548), + 147: uint16(34527), + 148: uint16(34520), + 149: uint16(34513), + 150: uint16(34563), + 151: uint16(34567), + 152: uint16(34552), + 153: uint16(34568), + 154: uint16(34570), + 155: uint16(34573), + 156: uint16(34569), + 157: uint16(34595), + 158: uint16(34619), + 159: uint16(34590), + 160: uint16(34597), + 161: uint16(34606), + 162: uint16(34586), + 163: uint16(34622), + 164: uint16(34632), + 165: uint16(34612), + 166: uint16(34609), + 167: uint16(34601), + 168: uint16(34615), + 169: uint16(34623), + 170: uint16(34690), + 171: uint16(34594), + 172: uint16(34685), + 173: uint16(34686), + 174: uint16(34683), + 175: uint16(34656), + 176: uint16(34672), + 177: uint16(34636), + 178: uint16(34670), + 179: uint16(34699), + 180: uint16(34643), + 181: uint16(34659), + 182: uint16(34684), + 183: uint16(34660), + 184: uint16(34649), + 185: uint16(34661), + 186: uint16(34707), + 187: uint16(34735), + 188: uint16(34728), + 189: uint16(34770), + }, + 114: { + 0: uint16(39514), + 1: uint16(39515), + 2: uint16(39516), + 3: uint16(39517), + 4: uint16(39518), + 5: uint16(39519), + 6: uint16(39520), + 7: uint16(39521), + 8: uint16(39522), + 9: uint16(39523), + 10: uint16(39524), + 11: uint16(39525), + 12: uint16(39526), + 13: uint16(39527), + 14: uint16(39528), + 15: uint16(39529), + 16: uint16(39530), + 17: uint16(39531), + 18: uint16(39538), + 19: uint16(39555), + 20: uint16(39561), + 21: uint16(39565), + 22: uint16(39566), + 23: uint16(39572), + 24: uint16(39573), + 25: uint16(39577), + 26: uint16(39590), + 27: uint16(39593), + 28: uint16(39594), + 29: uint16(39595), + 30: uint16(39596), + 31: uint16(39597), + 32: uint16(39598), + 33: uint16(39599), + 34: uint16(39602), + 35: uint16(39603), + 36: uint16(39604), + 37: uint16(39605), + 38: uint16(39609), + 39: uint16(39611), + 40: uint16(39613), + 41: uint16(39614), + 42: uint16(39615), + 43: uint16(39619), + 44: uint16(39620), + 45: uint16(39622), + 46: uint16(39623), + 47: uint16(39624), + 48: uint16(39625), + 49: uint16(39626), + 50: uint16(39629), + 51: uint16(39630), + 52: uint16(39631), + 53: uint16(39632), + 54: uint16(39634), + 55: uint16(39636), + 56: uint16(39637), + 57: uint16(39638), + 58: uint16(39639), + 59: uint16(39641), + 60: uint16(39642), + 61: uint16(39643), + 62: uint16(39644), + 63: uint16(39645), + 64: uint16(39646), + 65: uint16(39648), + 66: uint16(39650), + 67: uint16(39651), + 68: uint16(39652), + 69: uint16(39653), + 70: uint16(39655), + 71: uint16(39656), + 72: uint16(39657), + 73: uint16(39658), + 74: uint16(39660), + 75: uint16(39662), + 76: uint16(39664), + 77: uint16(39665), + 78: uint16(39666), + 79: uint16(39667), + 80: uint16(39668), + 81: uint16(39669), + 82: uint16(39670), + 83: uint16(39671), + 84: uint16(39672), + 85: uint16(39674), + 86: uint16(39676), + 87: uint16(39677), + 88: uint16(39678), + 89: uint16(39679), + 90: uint16(39680), + 91: uint16(39681), + 92: uint16(39682), + 93: uint16(39684), + 94: uint16(39685), + 95: uint16(39686), + 96: uint16(34758), + 97: uint16(34696), + 98: uint16(34693), + 99: uint16(34733), + 100: uint16(34711), + 101: uint16(34691), + 102: uint16(34731), + 103: uint16(34789), + 104: uint16(34732), + 105: uint16(34741), + 106: uint16(34739), + 107: uint16(34763), + 108: uint16(34771), + 109: uint16(34749), + 110: uint16(34769), + 111: uint16(34752), + 112: uint16(34762), + 113: uint16(34779), + 114: uint16(34794), + 115: uint16(34784), + 116: uint16(34798), + 117: uint16(34838), + 118: uint16(34835), + 119: uint16(34814), + 120: uint16(34826), + 121: uint16(34843), + 122: uint16(34849), + 123: uint16(34873), + 124: uint16(34876), + 125: uint16(32566), + 126: uint16(32578), + 127: uint16(32580), + 128: uint16(32581), + 129: uint16(33296), + 130: uint16(31482), + 131: uint16(31485), + 132: uint16(31496), + 133: uint16(31491), + 134: uint16(31492), + 135: uint16(31509), + 136: uint16(31498), + 137: uint16(31531), + 138: uint16(31503), + 139: uint16(31559), + 140: uint16(31544), + 141: uint16(31530), + 142: uint16(31513), + 143: uint16(31534), + 144: uint16(31537), + 145: uint16(31520), + 146: uint16(31525), + 147: uint16(31524), + 148: uint16(31539), + 149: uint16(31550), + 150: uint16(31518), + 151: uint16(31576), + 152: uint16(31578), + 153: uint16(31557), + 154: uint16(31605), + 155: uint16(31564), + 156: uint16(31581), + 157: uint16(31584), + 158: uint16(31598), + 159: uint16(31611), + 160: uint16(31586), + 161: uint16(31602), + 162: uint16(31601), + 163: uint16(31632), + 164: uint16(31654), + 165: uint16(31655), + 166: uint16(31672), + 167: uint16(31660), + 168: uint16(31645), + 169: uint16(31656), + 170: uint16(31621), + 171: uint16(31658), + 172: uint16(31644), + 173: uint16(31650), + 174: uint16(31659), + 175: uint16(31668), + 176: uint16(31697), + 177: uint16(31681), + 178: uint16(31692), + 179: uint16(31709), + 180: uint16(31706), + 181: uint16(31717), + 182: uint16(31718), + 183: uint16(31722), + 184: uint16(31756), + 185: uint16(31742), + 186: uint16(31740), + 187: uint16(31759), + 188: uint16(31766), + 189: uint16(31755), + }, + 115: { + 0: uint16(39687), + 1: uint16(39689), + 2: uint16(39690), + 3: uint16(39691), + 4: uint16(39692), + 5: uint16(39693), + 6: uint16(39694), + 7: uint16(39696), + 8: uint16(39697), + 9: uint16(39698), + 10: uint16(39700), + 11: uint16(39701), + 12: uint16(39702), + 13: uint16(39703), + 14: uint16(39704), + 15: uint16(39705), + 16: uint16(39706), + 17: uint16(39707), + 18: uint16(39708), + 19: uint16(39709), + 20: uint16(39710), + 21: uint16(39712), + 22: uint16(39713), + 23: uint16(39714), + 24: uint16(39716), + 25: uint16(39717), + 26: uint16(39718), + 27: uint16(39719), + 28: uint16(39720), + 29: uint16(39721), + 30: uint16(39722), + 31: uint16(39723), + 32: uint16(39724), + 33: uint16(39725), + 34: uint16(39726), + 35: uint16(39728), + 36: uint16(39729), + 37: uint16(39731), + 38: uint16(39732), + 39: uint16(39733), + 40: uint16(39734), + 41: uint16(39735), + 42: uint16(39736), + 43: uint16(39737), + 44: uint16(39738), + 45: uint16(39741), + 46: uint16(39742), + 47: uint16(39743), + 48: uint16(39744), + 49: uint16(39750), + 50: uint16(39754), + 51: uint16(39755), + 52: uint16(39756), + 53: uint16(39758), + 54: uint16(39760), + 55: uint16(39762), + 56: uint16(39763), + 57: uint16(39765), + 58: uint16(39766), + 59: uint16(39767), + 60: uint16(39768), + 61: uint16(39769), + 62: uint16(39770), + 63: uint16(39771), + 64: uint16(39772), + 65: uint16(39773), + 66: uint16(39774), + 67: uint16(39775), + 68: uint16(39776), + 69: uint16(39777), + 70: uint16(39778), + 71: uint16(39779), + 72: uint16(39780), + 73: uint16(39781), + 74: uint16(39782), + 75: uint16(39783), + 76: uint16(39784), + 77: uint16(39785), + 78: uint16(39786), + 79: uint16(39787), + 80: uint16(39788), + 81: uint16(39789), + 82: uint16(39790), + 83: uint16(39791), + 84: uint16(39792), + 85: uint16(39793), + 86: uint16(39794), + 87: uint16(39795), + 88: uint16(39796), + 89: uint16(39797), + 90: uint16(39798), + 91: uint16(39799), + 92: uint16(39800), + 93: uint16(39801), + 94: uint16(39802), + 95: uint16(39803), + 96: uint16(31775), + 97: uint16(31786), + 98: uint16(31782), + 99: uint16(31800), + 100: uint16(31809), + 101: uint16(31808), + 102: uint16(33278), + 103: uint16(33281), + 104: uint16(33282), + 105: uint16(33284), + 106: uint16(33260), + 107: uint16(34884), + 108: uint16(33313), + 109: uint16(33314), + 110: uint16(33315), + 111: uint16(33325), + 112: uint16(33327), + 113: uint16(33320), + 114: uint16(33323), + 115: uint16(33336), + 116: uint16(33339), + 117: uint16(33331), + 118: uint16(33332), + 119: uint16(33342), + 120: uint16(33348), + 121: uint16(33353), + 122: uint16(33355), + 123: uint16(33359), + 124: uint16(33370), + 125: uint16(33375), + 126: uint16(33384), + 127: uint16(34942), + 128: uint16(34949), + 129: uint16(34952), + 130: uint16(35032), + 131: uint16(35039), + 132: uint16(35166), + 133: uint16(32669), + 134: uint16(32671), + 135: uint16(32679), + 136: uint16(32687), + 137: uint16(32688), + 138: uint16(32690), + 139: uint16(31868), + 140: uint16(25929), + 141: uint16(31889), + 142: uint16(31901), + 143: uint16(31900), + 144: uint16(31902), + 145: uint16(31906), + 146: uint16(31922), + 147: uint16(31932), + 148: uint16(31933), + 149: uint16(31937), + 150: uint16(31943), + 151: uint16(31948), + 152: uint16(31949), + 153: uint16(31944), + 154: uint16(31941), + 155: uint16(31959), + 156: uint16(31976), + 157: uint16(33390), + 158: uint16(26280), + 159: uint16(32703), + 160: uint16(32718), + 161: uint16(32725), + 162: uint16(32741), + 163: uint16(32737), + 164: uint16(32742), + 165: uint16(32745), + 166: uint16(32750), + 167: uint16(32755), + 168: uint16(31992), + 169: uint16(32119), + 170: uint16(32166), + 171: uint16(32174), + 172: uint16(32327), + 173: uint16(32411), + 174: uint16(40632), + 175: uint16(40628), + 176: uint16(36211), + 177: uint16(36228), + 178: uint16(36244), + 179: uint16(36241), + 180: uint16(36273), + 181: uint16(36199), + 182: uint16(36205), + 183: uint16(35911), + 184: uint16(35913), + 185: uint16(37194), + 186: uint16(37200), + 187: uint16(37198), + 188: uint16(37199), + 189: uint16(37220), + }, + 116: { + 0: uint16(39804), + 1: uint16(39805), + 2: uint16(39806), + 3: uint16(39807), + 4: uint16(39808), + 5: uint16(39809), + 6: uint16(39810), + 7: uint16(39811), + 8: uint16(39812), + 9: uint16(39813), + 10: uint16(39814), + 11: uint16(39815), + 12: uint16(39816), + 13: uint16(39817), + 14: uint16(39818), + 15: uint16(39819), + 16: uint16(39820), + 17: uint16(39821), + 18: uint16(39822), + 19: uint16(39823), + 20: uint16(39824), + 21: uint16(39825), + 22: uint16(39826), + 23: uint16(39827), + 24: uint16(39828), + 25: uint16(39829), + 26: uint16(39830), + 27: uint16(39831), + 28: uint16(39832), + 29: uint16(39833), + 30: uint16(39834), + 31: uint16(39835), + 32: uint16(39836), + 33: uint16(39837), + 34: uint16(39838), + 35: uint16(39839), + 36: uint16(39840), + 37: uint16(39841), + 38: uint16(39842), + 39: uint16(39843), + 40: uint16(39844), + 41: uint16(39845), + 42: uint16(39846), + 43: uint16(39847), + 44: uint16(39848), + 45: uint16(39849), + 46: uint16(39850), + 47: uint16(39851), + 48: uint16(39852), + 49: uint16(39853), + 50: uint16(39854), + 51: uint16(39855), + 52: uint16(39856), + 53: uint16(39857), + 54: uint16(39858), + 55: uint16(39859), + 56: uint16(39860), + 57: uint16(39861), + 58: uint16(39862), + 59: uint16(39863), + 60: uint16(39864), + 61: uint16(39865), + 62: uint16(39866), + 63: uint16(39867), + 64: uint16(39868), + 65: uint16(39869), + 66: uint16(39870), + 67: uint16(39871), + 68: uint16(39872), + 69: uint16(39873), + 70: uint16(39874), + 71: uint16(39875), + 72: uint16(39876), + 73: uint16(39877), + 74: uint16(39878), + 75: uint16(39879), + 76: uint16(39880), + 77: uint16(39881), + 78: uint16(39882), + 79: uint16(39883), + 80: uint16(39884), + 81: uint16(39885), + 82: uint16(39886), + 83: uint16(39887), + 84: uint16(39888), + 85: uint16(39889), + 86: uint16(39890), + 87: uint16(39891), + 88: uint16(39892), + 89: uint16(39893), + 90: uint16(39894), + 91: uint16(39895), + 92: uint16(39896), + 93: uint16(39897), + 94: uint16(39898), + 95: uint16(39899), + 96: uint16(37218), + 97: uint16(37217), + 98: uint16(37232), + 99: uint16(37225), + 100: uint16(37231), + 101: uint16(37245), + 102: uint16(37246), + 103: uint16(37234), + 104: uint16(37236), + 105: uint16(37241), + 106: uint16(37260), + 107: uint16(37253), + 108: uint16(37264), + 109: uint16(37261), + 110: uint16(37265), + 111: uint16(37282), + 112: uint16(37283), + 113: uint16(37290), + 114: uint16(37293), + 115: uint16(37294), + 116: uint16(37295), + 117: uint16(37301), + 118: uint16(37300), + 119: uint16(37306), + 120: uint16(35925), + 121: uint16(40574), + 122: uint16(36280), + 123: uint16(36331), + 124: uint16(36357), + 125: uint16(36441), + 126: uint16(36457), + 127: uint16(36277), + 128: uint16(36287), + 129: uint16(36284), + 130: uint16(36282), + 131: uint16(36292), + 132: uint16(36310), + 133: uint16(36311), + 134: uint16(36314), + 135: uint16(36318), + 136: uint16(36302), + 137: uint16(36303), + 138: uint16(36315), + 139: uint16(36294), + 140: uint16(36332), + 141: uint16(36343), + 142: uint16(36344), + 143: uint16(36323), + 144: uint16(36345), + 145: uint16(36347), + 146: uint16(36324), + 147: uint16(36361), + 148: uint16(36349), + 149: uint16(36372), + 150: uint16(36381), + 151: uint16(36383), + 152: uint16(36396), + 153: uint16(36398), + 154: uint16(36387), + 155: uint16(36399), + 156: uint16(36410), + 157: uint16(36416), + 158: uint16(36409), + 159: uint16(36405), + 160: uint16(36413), + 161: uint16(36401), + 162: uint16(36425), + 163: uint16(36417), + 164: uint16(36418), + 165: uint16(36433), + 166: uint16(36434), + 167: uint16(36426), + 168: uint16(36464), + 169: uint16(36470), + 170: uint16(36476), + 171: uint16(36463), + 172: uint16(36468), + 173: uint16(36485), + 174: uint16(36495), + 175: uint16(36500), + 176: uint16(36496), + 177: uint16(36508), + 178: uint16(36510), + 179: uint16(35960), + 180: uint16(35970), + 181: uint16(35978), + 182: uint16(35973), + 183: uint16(35992), + 184: uint16(35988), + 185: uint16(26011), + 186: uint16(35286), + 187: uint16(35294), + 188: uint16(35290), + 189: uint16(35292), + }, + 117: { + 0: uint16(39900), + 1: uint16(39901), + 2: uint16(39902), + 3: uint16(39903), + 4: uint16(39904), + 5: uint16(39905), + 6: uint16(39906), + 7: uint16(39907), + 8: uint16(39908), + 9: uint16(39909), + 10: uint16(39910), + 11: uint16(39911), + 12: uint16(39912), + 13: uint16(39913), + 14: uint16(39914), + 15: uint16(39915), + 16: uint16(39916), + 17: uint16(39917), + 18: uint16(39918), + 19: uint16(39919), + 20: uint16(39920), + 21: uint16(39921), + 22: uint16(39922), + 23: uint16(39923), + 24: uint16(39924), + 25: uint16(39925), + 26: uint16(39926), + 27: uint16(39927), + 28: uint16(39928), + 29: uint16(39929), + 30: uint16(39930), + 31: uint16(39931), + 32: uint16(39932), + 33: uint16(39933), + 34: uint16(39934), + 35: uint16(39935), + 36: uint16(39936), + 37: uint16(39937), + 38: uint16(39938), + 39: uint16(39939), + 40: uint16(39940), + 41: uint16(39941), + 42: uint16(39942), + 43: uint16(39943), + 44: uint16(39944), + 45: uint16(39945), + 46: uint16(39946), + 47: uint16(39947), + 48: uint16(39948), + 49: uint16(39949), + 50: uint16(39950), + 51: uint16(39951), + 52: uint16(39952), + 53: uint16(39953), + 54: uint16(39954), + 55: uint16(39955), + 56: uint16(39956), + 57: uint16(39957), + 58: uint16(39958), + 59: uint16(39959), + 60: uint16(39960), + 61: uint16(39961), + 62: uint16(39962), + 63: uint16(39963), + 64: uint16(39964), + 65: uint16(39965), + 66: uint16(39966), + 67: uint16(39967), + 68: uint16(39968), + 69: uint16(39969), + 70: uint16(39970), + 71: uint16(39971), + 72: uint16(39972), + 73: uint16(39973), + 74: uint16(39974), + 75: uint16(39975), + 76: uint16(39976), + 77: uint16(39977), + 78: uint16(39978), + 79: uint16(39979), + 80: uint16(39980), + 81: uint16(39981), + 82: uint16(39982), + 83: uint16(39983), + 84: uint16(39984), + 85: uint16(39985), + 86: uint16(39986), + 87: uint16(39987), + 88: uint16(39988), + 89: uint16(39989), + 90: uint16(39990), + 91: uint16(39991), + 92: uint16(39992), + 93: uint16(39993), + 94: uint16(39994), + 95: uint16(39995), + 96: uint16(35301), + 97: uint16(35307), + 98: uint16(35311), + 99: uint16(35390), + 100: uint16(35622), + 101: uint16(38739), + 102: uint16(38633), + 103: uint16(38643), + 104: uint16(38639), + 105: uint16(38662), + 106: uint16(38657), + 107: uint16(38664), + 108: uint16(38671), + 109: uint16(38670), + 110: uint16(38698), + 111: uint16(38701), + 112: uint16(38704), + 113: uint16(38718), + 114: uint16(40832), + 115: uint16(40835), + 116: uint16(40837), + 117: uint16(40838), + 118: uint16(40839), + 119: uint16(40840), + 120: uint16(40841), + 121: uint16(40842), + 122: uint16(40844), + 123: uint16(40702), + 124: uint16(40715), + 125: uint16(40717), + 126: uint16(38585), + 127: uint16(38588), + 128: uint16(38589), + 129: uint16(38606), + 130: uint16(38610), + 131: uint16(30655), + 132: uint16(38624), + 133: uint16(37518), + 134: uint16(37550), + 135: uint16(37576), + 136: uint16(37694), + 137: uint16(37738), + 138: uint16(37834), + 139: uint16(37775), + 140: uint16(37950), + 141: uint16(37995), + 142: uint16(40063), + 143: uint16(40066), + 144: uint16(40069), + 145: uint16(40070), + 146: uint16(40071), + 147: uint16(40072), + 148: uint16(31267), + 149: uint16(40075), + 150: uint16(40078), + 151: uint16(40080), + 152: uint16(40081), + 153: uint16(40082), + 154: uint16(40084), + 155: uint16(40085), + 156: uint16(40090), + 157: uint16(40091), + 158: uint16(40094), + 159: uint16(40095), + 160: uint16(40096), + 161: uint16(40097), + 162: uint16(40098), + 163: uint16(40099), + 164: uint16(40101), + 165: uint16(40102), + 166: uint16(40103), + 167: uint16(40104), + 168: uint16(40105), + 169: uint16(40107), + 170: uint16(40109), + 171: uint16(40110), + 172: uint16(40112), + 173: uint16(40113), + 174: uint16(40114), + 175: uint16(40115), + 176: uint16(40116), + 177: uint16(40117), + 178: uint16(40118), + 179: uint16(40119), + 180: uint16(40122), + 181: uint16(40123), + 182: uint16(40124), + 183: uint16(40125), + 184: uint16(40132), + 185: uint16(40133), + 186: uint16(40134), + 187: uint16(40135), + 188: uint16(40138), + 189: uint16(40139), + }, + 118: { + 0: uint16(39996), + 1: uint16(39997), + 2: uint16(39998), + 3: uint16(39999), + 4: uint16(40000), + 5: uint16(40001), + 6: uint16(40002), + 7: uint16(40003), + 8: uint16(40004), + 9: uint16(40005), + 10: uint16(40006), + 11: uint16(40007), + 12: uint16(40008), + 13: uint16(40009), + 14: uint16(40010), + 15: uint16(40011), + 16: uint16(40012), + 17: uint16(40013), + 18: uint16(40014), + 19: uint16(40015), + 20: uint16(40016), + 21: uint16(40017), + 22: uint16(40018), + 23: uint16(40019), + 24: uint16(40020), + 25: uint16(40021), + 26: uint16(40022), + 27: uint16(40023), + 28: uint16(40024), + 29: uint16(40025), + 30: uint16(40026), + 31: uint16(40027), + 32: uint16(40028), + 33: uint16(40029), + 34: uint16(40030), + 35: uint16(40031), + 36: uint16(40032), + 37: uint16(40033), + 38: uint16(40034), + 39: uint16(40035), + 40: uint16(40036), + 41: uint16(40037), + 42: uint16(40038), + 43: uint16(40039), + 44: uint16(40040), + 45: uint16(40041), + 46: uint16(40042), + 47: uint16(40043), + 48: uint16(40044), + 49: uint16(40045), + 50: uint16(40046), + 51: uint16(40047), + 52: uint16(40048), + 53: uint16(40049), + 54: uint16(40050), + 55: uint16(40051), + 56: uint16(40052), + 57: uint16(40053), + 58: uint16(40054), + 59: uint16(40055), + 60: uint16(40056), + 61: uint16(40057), + 62: uint16(40058), + 63: uint16(40059), + 64: uint16(40061), + 65: uint16(40062), + 66: uint16(40064), + 67: uint16(40067), + 68: uint16(40068), + 69: uint16(40073), + 70: uint16(40074), + 71: uint16(40076), + 72: uint16(40079), + 73: uint16(40083), + 74: uint16(40086), + 75: uint16(40087), + 76: uint16(40088), + 77: uint16(40089), + 78: uint16(40093), + 79: uint16(40106), + 80: uint16(40108), + 81: uint16(40111), + 82: uint16(40121), + 83: uint16(40126), + 84: uint16(40127), + 85: uint16(40128), + 86: uint16(40129), + 87: uint16(40130), + 88: uint16(40136), + 89: uint16(40137), + 90: uint16(40145), + 91: uint16(40146), + 92: uint16(40154), + 93: uint16(40155), + 94: uint16(40160), + 95: uint16(40161), + 96: uint16(40140), + 97: uint16(40141), + 98: uint16(40142), + 99: uint16(40143), + 100: uint16(40144), + 101: uint16(40147), + 102: uint16(40148), + 103: uint16(40149), + 104: uint16(40151), + 105: uint16(40152), + 106: uint16(40153), + 107: uint16(40156), + 108: uint16(40157), + 109: uint16(40159), + 110: uint16(40162), + 111: uint16(38780), + 112: uint16(38789), + 113: uint16(38801), + 114: uint16(38802), + 115: uint16(38804), + 116: uint16(38831), + 117: uint16(38827), + 118: uint16(38819), + 119: uint16(38834), + 120: uint16(38836), + 121: uint16(39601), + 122: uint16(39600), + 123: uint16(39607), + 124: uint16(40536), + 125: uint16(39606), + 126: uint16(39610), + 127: uint16(39612), + 128: uint16(39617), + 129: uint16(39616), + 130: uint16(39621), + 131: uint16(39618), + 132: uint16(39627), + 133: uint16(39628), + 134: uint16(39633), + 135: uint16(39749), + 136: uint16(39747), + 137: uint16(39751), + 138: uint16(39753), + 139: uint16(39752), + 140: uint16(39757), + 141: uint16(39761), + 142: uint16(39144), + 143: uint16(39181), + 144: uint16(39214), + 145: uint16(39253), + 146: uint16(39252), + 147: uint16(39647), + 148: uint16(39649), + 149: uint16(39654), + 150: uint16(39663), + 151: uint16(39659), + 152: uint16(39675), + 153: uint16(39661), + 154: uint16(39673), + 155: uint16(39688), + 156: uint16(39695), + 157: uint16(39699), + 158: uint16(39711), + 159: uint16(39715), + 160: uint16(40637), + 161: uint16(40638), + 162: uint16(32315), + 163: uint16(40578), + 164: uint16(40583), + 165: uint16(40584), + 166: uint16(40587), + 167: uint16(40594), + 168: uint16(37846), + 169: uint16(40605), + 170: uint16(40607), + 171: uint16(40667), + 172: uint16(40668), + 173: uint16(40669), + 174: uint16(40672), + 175: uint16(40671), + 176: uint16(40674), + 177: uint16(40681), + 178: uint16(40679), + 179: uint16(40677), + 180: uint16(40682), + 181: uint16(40687), + 182: uint16(40738), + 183: uint16(40748), + 184: uint16(40751), + 185: uint16(40761), + 186: uint16(40759), + 187: uint16(40765), + 188: uint16(40766), + 189: uint16(40772), + }, + 119: { + 0: uint16(40163), + 1: uint16(40164), + 2: uint16(40165), + 3: uint16(40166), + 4: uint16(40167), + 5: uint16(40168), + 6: uint16(40169), + 7: uint16(40170), + 8: uint16(40171), + 9: uint16(40172), + 10: uint16(40173), + 11: uint16(40174), + 12: uint16(40175), + 13: uint16(40176), + 14: uint16(40177), + 15: uint16(40178), + 16: uint16(40179), + 17: uint16(40180), + 18: uint16(40181), + 19: uint16(40182), + 20: uint16(40183), + 21: uint16(40184), + 22: uint16(40185), + 23: uint16(40186), + 24: uint16(40187), + 25: uint16(40188), + 26: uint16(40189), + 27: uint16(40190), + 28: uint16(40191), + 29: uint16(40192), + 30: uint16(40193), + 31: uint16(40194), + 32: uint16(40195), + 33: uint16(40196), + 34: uint16(40197), + 35: uint16(40198), + 36: uint16(40199), + 37: uint16(40200), + 38: uint16(40201), + 39: uint16(40202), + 40: uint16(40203), + 41: uint16(40204), + 42: uint16(40205), + 43: uint16(40206), + 44: uint16(40207), + 45: uint16(40208), + 46: uint16(40209), + 47: uint16(40210), + 48: uint16(40211), + 49: uint16(40212), + 50: uint16(40213), + 51: uint16(40214), + 52: uint16(40215), + 53: uint16(40216), + 54: uint16(40217), + 55: uint16(40218), + 56: uint16(40219), + 57: uint16(40220), + 58: uint16(40221), + 59: uint16(40222), + 60: uint16(40223), + 61: uint16(40224), + 62: uint16(40225), + 63: uint16(40226), + 64: uint16(40227), + 65: uint16(40228), + 66: uint16(40229), + 67: uint16(40230), + 68: uint16(40231), + 69: uint16(40232), + 70: uint16(40233), + 71: uint16(40234), + 72: uint16(40235), + 73: uint16(40236), + 74: uint16(40237), + 75: uint16(40238), + 76: uint16(40239), + 77: uint16(40240), + 78: uint16(40241), + 79: uint16(40242), + 80: uint16(40243), + 81: uint16(40244), + 82: uint16(40245), + 83: uint16(40246), + 84: uint16(40247), + 85: uint16(40248), + 86: uint16(40249), + 87: uint16(40250), + 88: uint16(40251), + 89: uint16(40252), + 90: uint16(40253), + 91: uint16(40254), + 92: uint16(40255), + 93: uint16(40256), + 94: uint16(40257), + 95: uint16(40258), + 96: uint16(57908), + 97: uint16(57909), + 98: uint16(57910), + 99: uint16(57911), + 100: uint16(57912), + 101: uint16(57913), + 102: uint16(57914), + 103: uint16(57915), + 104: uint16(57916), + 105: uint16(57917), + 106: uint16(57918), + 107: uint16(57919), + 108: uint16(57920), + 109: uint16(57921), + 110: uint16(57922), + 111: uint16(57923), + 112: uint16(57924), + 113: uint16(57925), + 114: uint16(57926), + 115: uint16(57927), + 116: uint16(57928), + 117: uint16(57929), + 118: uint16(57930), + 119: uint16(57931), + 120: uint16(57932), + 121: uint16(57933), + 122: uint16(57934), + 123: uint16(57935), + 124: uint16(57936), + 125: uint16(57937), + 126: uint16(57938), + 127: uint16(57939), + 128: uint16(57940), + 129: uint16(57941), + 130: uint16(57942), + 131: uint16(57943), + 132: uint16(57944), + 133: uint16(57945), + 134: uint16(57946), + 135: uint16(57947), + 136: uint16(57948), + 137: uint16(57949), + 138: uint16(57950), + 139: uint16(57951), + 140: uint16(57952), + 141: uint16(57953), + 142: uint16(57954), + 143: uint16(57955), + 144: uint16(57956), + 145: uint16(57957), + 146: uint16(57958), + 147: uint16(57959), + 148: uint16(57960), + 149: uint16(57961), + 150: uint16(57962), + 151: uint16(57963), + 152: uint16(57964), + 153: uint16(57965), + 154: uint16(57966), + 155: uint16(57967), + 156: uint16(57968), + 157: uint16(57969), + 158: uint16(57970), + 159: uint16(57971), + 160: uint16(57972), + 161: uint16(57973), + 162: uint16(57974), + 163: uint16(57975), + 164: uint16(57976), + 165: uint16(57977), + 166: uint16(57978), + 167: uint16(57979), + 168: uint16(57980), + 169: uint16(57981), + 170: uint16(57982), + 171: uint16(57983), + 172: uint16(57984), + 173: uint16(57985), + 174: uint16(57986), + 175: uint16(57987), + 176: uint16(57988), + 177: uint16(57989), + 178: uint16(57990), + 179: uint16(57991), + 180: uint16(57992), + 181: uint16(57993), + 182: uint16(57994), + 183: uint16(57995), + 184: uint16(57996), + 185: uint16(57997), + 186: uint16(57998), + 187: uint16(57999), + 188: uint16(58000), + 189: uint16(58001), + }, + 120: { + 0: uint16(40259), + 1: uint16(40260), + 2: uint16(40261), + 3: uint16(40262), + 4: uint16(40263), + 5: uint16(40264), + 6: uint16(40265), + 7: uint16(40266), + 8: uint16(40267), + 9: uint16(40268), + 10: uint16(40269), + 11: uint16(40270), + 12: uint16(40271), + 13: uint16(40272), + 14: uint16(40273), + 15: uint16(40274), + 16: uint16(40275), + 17: uint16(40276), + 18: uint16(40277), + 19: uint16(40278), + 20: uint16(40279), + 21: uint16(40280), + 22: uint16(40281), + 23: uint16(40282), + 24: uint16(40283), + 25: uint16(40284), + 26: uint16(40285), + 27: uint16(40286), + 28: uint16(40287), + 29: uint16(40288), + 30: uint16(40289), + 31: uint16(40290), + 32: uint16(40291), + 33: uint16(40292), + 34: uint16(40293), + 35: uint16(40294), + 36: uint16(40295), + 37: uint16(40296), + 38: uint16(40297), + 39: uint16(40298), + 40: uint16(40299), + 41: uint16(40300), + 42: uint16(40301), + 43: uint16(40302), + 44: uint16(40303), + 45: uint16(40304), + 46: uint16(40305), + 47: uint16(40306), + 48: uint16(40307), + 49: uint16(40308), + 50: uint16(40309), + 51: uint16(40310), + 52: uint16(40311), + 53: uint16(40312), + 54: uint16(40313), + 55: uint16(40314), + 56: uint16(40315), + 57: uint16(40316), + 58: uint16(40317), + 59: uint16(40318), + 60: uint16(40319), + 61: uint16(40320), + 62: uint16(40321), + 63: uint16(40322), + 64: uint16(40323), + 65: uint16(40324), + 66: uint16(40325), + 67: uint16(40326), + 68: uint16(40327), + 69: uint16(40328), + 70: uint16(40329), + 71: uint16(40330), + 72: uint16(40331), + 73: uint16(40332), + 74: uint16(40333), + 75: uint16(40334), + 76: uint16(40335), + 77: uint16(40336), + 78: uint16(40337), + 79: uint16(40338), + 80: uint16(40339), + 81: uint16(40340), + 82: uint16(40341), + 83: uint16(40342), + 84: uint16(40343), + 85: uint16(40344), + 86: uint16(40345), + 87: uint16(40346), + 88: uint16(40347), + 89: uint16(40348), + 90: uint16(40349), + 91: uint16(40350), + 92: uint16(40351), + 93: uint16(40352), + 94: uint16(40353), + 95: uint16(40354), + 96: uint16(58002), + 97: uint16(58003), + 98: uint16(58004), + 99: uint16(58005), + 100: uint16(58006), + 101: uint16(58007), + 102: uint16(58008), + 103: uint16(58009), + 104: uint16(58010), + 105: uint16(58011), + 106: uint16(58012), + 107: uint16(58013), + 108: uint16(58014), + 109: uint16(58015), + 110: uint16(58016), + 111: uint16(58017), + 112: uint16(58018), + 113: uint16(58019), + 114: uint16(58020), + 115: uint16(58021), + 116: uint16(58022), + 117: uint16(58023), + 118: uint16(58024), + 119: uint16(58025), + 120: uint16(58026), + 121: uint16(58027), + 122: uint16(58028), + 123: uint16(58029), + 124: uint16(58030), + 125: uint16(58031), + 126: uint16(58032), + 127: uint16(58033), + 128: uint16(58034), + 129: uint16(58035), + 130: uint16(58036), + 131: uint16(58037), + 132: uint16(58038), + 133: uint16(58039), + 134: uint16(58040), + 135: uint16(58041), + 136: uint16(58042), + 137: uint16(58043), + 138: uint16(58044), + 139: uint16(58045), + 140: uint16(58046), + 141: uint16(58047), + 142: uint16(58048), + 143: uint16(58049), + 144: uint16(58050), + 145: uint16(58051), + 146: uint16(58052), + 147: uint16(58053), + 148: uint16(58054), + 149: uint16(58055), + 150: uint16(58056), + 151: uint16(58057), + 152: uint16(58058), + 153: uint16(58059), + 154: uint16(58060), + 155: uint16(58061), + 156: uint16(58062), + 157: uint16(58063), + 158: uint16(58064), + 159: uint16(58065), + 160: uint16(58066), + 161: uint16(58067), + 162: uint16(58068), + 163: uint16(58069), + 164: uint16(58070), + 165: uint16(58071), + 166: uint16(58072), + 167: uint16(58073), + 168: uint16(58074), + 169: uint16(58075), + 170: uint16(58076), + 171: uint16(58077), + 172: uint16(58078), + 173: uint16(58079), + 174: uint16(58080), + 175: uint16(58081), + 176: uint16(58082), + 177: uint16(58083), + 178: uint16(58084), + 179: uint16(58085), + 180: uint16(58086), + 181: uint16(58087), + 182: uint16(58088), + 183: uint16(58089), + 184: uint16(58090), + 185: uint16(58091), + 186: uint16(58092), + 187: uint16(58093), + 188: uint16(58094), + 189: uint16(58095), + }, + 121: { + 0: uint16(40355), + 1: uint16(40356), + 2: uint16(40357), + 3: uint16(40358), + 4: uint16(40359), + 5: uint16(40360), + 6: uint16(40361), + 7: uint16(40362), + 8: uint16(40363), + 9: uint16(40364), + 10: uint16(40365), + 11: uint16(40366), + 12: uint16(40367), + 13: uint16(40368), + 14: uint16(40369), + 15: uint16(40370), + 16: uint16(40371), + 17: uint16(40372), + 18: uint16(40373), + 19: uint16(40374), + 20: uint16(40375), + 21: uint16(40376), + 22: uint16(40377), + 23: uint16(40378), + 24: uint16(40379), + 25: uint16(40380), + 26: uint16(40381), + 27: uint16(40382), + 28: uint16(40383), + 29: uint16(40384), + 30: uint16(40385), + 31: uint16(40386), + 32: uint16(40387), + 33: uint16(40388), + 34: uint16(40389), + 35: uint16(40390), + 36: uint16(40391), + 37: uint16(40392), + 38: uint16(40393), + 39: uint16(40394), + 40: uint16(40395), + 41: uint16(40396), + 42: uint16(40397), + 43: uint16(40398), + 44: uint16(40399), + 45: uint16(40400), + 46: uint16(40401), + 47: uint16(40402), + 48: uint16(40403), + 49: uint16(40404), + 50: uint16(40405), + 51: uint16(40406), + 52: uint16(40407), + 53: uint16(40408), + 54: uint16(40409), + 55: uint16(40410), + 56: uint16(40411), + 57: uint16(40412), + 58: uint16(40413), + 59: uint16(40414), + 60: uint16(40415), + 61: uint16(40416), + 62: uint16(40417), + 63: uint16(40418), + 64: uint16(40419), + 65: uint16(40420), + 66: uint16(40421), + 67: uint16(40422), + 68: uint16(40423), + 69: uint16(40424), + 70: uint16(40425), + 71: uint16(40426), + 72: uint16(40427), + 73: uint16(40428), + 74: uint16(40429), + 75: uint16(40430), + 76: uint16(40431), + 77: uint16(40432), + 78: uint16(40433), + 79: uint16(40434), + 80: uint16(40435), + 81: uint16(40436), + 82: uint16(40437), + 83: uint16(40438), + 84: uint16(40439), + 85: uint16(40440), + 86: uint16(40441), + 87: uint16(40442), + 88: uint16(40443), + 89: uint16(40444), + 90: uint16(40445), + 91: uint16(40446), + 92: uint16(40447), + 93: uint16(40448), + 94: uint16(40449), + 95: uint16(40450), + 96: uint16(58096), + 97: uint16(58097), + 98: uint16(58098), + 99: uint16(58099), + 100: uint16(58100), + 101: uint16(58101), + 102: uint16(58102), + 103: uint16(58103), + 104: uint16(58104), + 105: uint16(58105), + 106: uint16(58106), + 107: uint16(58107), + 108: uint16(58108), + 109: uint16(58109), + 110: uint16(58110), + 111: uint16(58111), + 112: uint16(58112), + 113: uint16(58113), + 114: uint16(58114), + 115: uint16(58115), + 116: uint16(58116), + 117: uint16(58117), + 118: uint16(58118), + 119: uint16(58119), + 120: uint16(58120), + 121: uint16(58121), + 122: uint16(58122), + 123: uint16(58123), + 124: uint16(58124), + 125: uint16(58125), + 126: uint16(58126), + 127: uint16(58127), + 128: uint16(58128), + 129: uint16(58129), + 130: uint16(58130), + 131: uint16(58131), + 132: uint16(58132), + 133: uint16(58133), + 134: uint16(58134), + 135: uint16(58135), + 136: uint16(58136), + 137: uint16(58137), + 138: uint16(58138), + 139: uint16(58139), + 140: uint16(58140), + 141: uint16(58141), + 142: uint16(58142), + 143: uint16(58143), + 144: uint16(58144), + 145: uint16(58145), + 146: uint16(58146), + 147: uint16(58147), + 148: uint16(58148), + 149: uint16(58149), + 150: uint16(58150), + 151: uint16(58151), + 152: uint16(58152), + 153: uint16(58153), + 154: uint16(58154), + 155: uint16(58155), + 156: uint16(58156), + 157: uint16(58157), + 158: uint16(58158), + 159: uint16(58159), + 160: uint16(58160), + 161: uint16(58161), + 162: uint16(58162), + 163: uint16(58163), + 164: uint16(58164), + 165: uint16(58165), + 166: uint16(58166), + 167: uint16(58167), + 168: uint16(58168), + 169: uint16(58169), + 170: uint16(58170), + 171: uint16(58171), + 172: uint16(58172), + 173: uint16(58173), + 174: uint16(58174), + 175: uint16(58175), + 176: uint16(58176), + 177: uint16(58177), + 178: uint16(58178), + 179: uint16(58179), + 180: uint16(58180), + 181: uint16(58181), + 182: uint16(58182), + 183: uint16(58183), + 184: uint16(58184), + 185: uint16(58185), + 186: uint16(58186), + 187: uint16(58187), + 188: uint16(58188), + 189: uint16(58189), + }, + 122: { + 0: uint16(40451), + 1: uint16(40452), + 2: uint16(40453), + 3: uint16(40454), + 4: uint16(40455), + 5: uint16(40456), + 6: uint16(40457), + 7: uint16(40458), + 8: uint16(40459), + 9: uint16(40460), + 10: uint16(40461), + 11: uint16(40462), + 12: uint16(40463), + 13: uint16(40464), + 14: uint16(40465), + 15: uint16(40466), + 16: uint16(40467), + 17: uint16(40468), + 18: uint16(40469), + 19: uint16(40470), + 20: uint16(40471), + 21: uint16(40472), + 22: uint16(40473), + 23: uint16(40474), + 24: uint16(40475), + 25: uint16(40476), + 26: uint16(40477), + 27: uint16(40478), + 28: uint16(40484), + 29: uint16(40487), + 30: uint16(40494), + 31: uint16(40496), + 32: uint16(40500), + 33: uint16(40507), + 34: uint16(40508), + 35: uint16(40512), + 36: uint16(40525), + 37: uint16(40528), + 38: uint16(40530), + 39: uint16(40531), + 40: uint16(40532), + 41: uint16(40534), + 42: uint16(40537), + 43: uint16(40541), + 44: uint16(40543), + 45: uint16(40544), + 46: uint16(40545), + 47: uint16(40546), + 48: uint16(40549), + 49: uint16(40558), + 50: uint16(40559), + 51: uint16(40562), + 52: uint16(40564), + 53: uint16(40565), + 54: uint16(40566), + 55: uint16(40567), + 56: uint16(40568), + 57: uint16(40569), + 58: uint16(40570), + 59: uint16(40571), + 60: uint16(40572), + 61: uint16(40573), + 62: uint16(40576), + 63: uint16(40577), + 64: uint16(40579), + 65: uint16(40580), + 66: uint16(40581), + 67: uint16(40582), + 68: uint16(40585), + 69: uint16(40586), + 70: uint16(40588), + 71: uint16(40589), + 72: uint16(40590), + 73: uint16(40591), + 74: uint16(40592), + 75: uint16(40593), + 76: uint16(40596), + 77: uint16(40597), + 78: uint16(40598), + 79: uint16(40599), + 80: uint16(40600), + 81: uint16(40601), + 82: uint16(40602), + 83: uint16(40603), + 84: uint16(40604), + 85: uint16(40606), + 86: uint16(40608), + 87: uint16(40609), + 88: uint16(40610), + 89: uint16(40611), + 90: uint16(40612), + 91: uint16(40613), + 92: uint16(40615), + 93: uint16(40616), + 94: uint16(40617), + 95: uint16(40618), + 96: uint16(58190), + 97: uint16(58191), + 98: uint16(58192), + 99: uint16(58193), + 100: uint16(58194), + 101: uint16(58195), + 102: uint16(58196), + 103: uint16(58197), + 104: uint16(58198), + 105: uint16(58199), + 106: uint16(58200), + 107: uint16(58201), + 108: uint16(58202), + 109: uint16(58203), + 110: uint16(58204), + 111: uint16(58205), + 112: uint16(58206), + 113: uint16(58207), + 114: uint16(58208), + 115: uint16(58209), + 116: uint16(58210), + 117: uint16(58211), + 118: uint16(58212), + 119: uint16(58213), + 120: uint16(58214), + 121: uint16(58215), + 122: uint16(58216), + 123: uint16(58217), + 124: uint16(58218), + 125: uint16(58219), + 126: uint16(58220), + 127: uint16(58221), + 128: uint16(58222), + 129: uint16(58223), + 130: uint16(58224), + 131: uint16(58225), + 132: uint16(58226), + 133: uint16(58227), + 134: uint16(58228), + 135: uint16(58229), + 136: uint16(58230), + 137: uint16(58231), + 138: uint16(58232), + 139: uint16(58233), + 140: uint16(58234), + 141: uint16(58235), + 142: uint16(58236), + 143: uint16(58237), + 144: uint16(58238), + 145: uint16(58239), + 146: uint16(58240), + 147: uint16(58241), + 148: uint16(58242), + 149: uint16(58243), + 150: uint16(58244), + 151: uint16(58245), + 152: uint16(58246), + 153: uint16(58247), + 154: uint16(58248), + 155: uint16(58249), + 156: uint16(58250), + 157: uint16(58251), + 158: uint16(58252), + 159: uint16(58253), + 160: uint16(58254), + 161: uint16(58255), + 162: uint16(58256), + 163: uint16(58257), + 164: uint16(58258), + 165: uint16(58259), + 166: uint16(58260), + 167: uint16(58261), + 168: uint16(58262), + 169: uint16(58263), + 170: uint16(58264), + 171: uint16(58265), + 172: uint16(58266), + 173: uint16(58267), + 174: uint16(58268), + 175: uint16(58269), + 176: uint16(58270), + 177: uint16(58271), + 178: uint16(58272), + 179: uint16(58273), + 180: uint16(58274), + 181: uint16(58275), + 182: uint16(58276), + 183: uint16(58277), + 184: uint16(58278), + 185: uint16(58279), + 186: uint16(58280), + 187: uint16(58281), + 188: uint16(58282), + 189: uint16(58283), + }, + 123: { + 0: uint16(40619), + 1: uint16(40620), + 2: uint16(40621), + 3: uint16(40622), + 4: uint16(40623), + 5: uint16(40624), + 6: uint16(40625), + 7: uint16(40626), + 8: uint16(40627), + 9: uint16(40629), + 10: uint16(40630), + 11: uint16(40631), + 12: uint16(40633), + 13: uint16(40634), + 14: uint16(40636), + 15: uint16(40639), + 16: uint16(40640), + 17: uint16(40641), + 18: uint16(40642), + 19: uint16(40643), + 20: uint16(40645), + 21: uint16(40646), + 22: uint16(40647), + 23: uint16(40648), + 24: uint16(40650), + 25: uint16(40651), + 26: uint16(40652), + 27: uint16(40656), + 28: uint16(40658), + 29: uint16(40659), + 30: uint16(40661), + 31: uint16(40662), + 32: uint16(40663), + 33: uint16(40665), + 34: uint16(40666), + 35: uint16(40670), + 36: uint16(40673), + 37: uint16(40675), + 38: uint16(40676), + 39: uint16(40678), + 40: uint16(40680), + 41: uint16(40683), + 42: uint16(40684), + 43: uint16(40685), + 44: uint16(40686), + 45: uint16(40688), + 46: uint16(40689), + 47: uint16(40690), + 48: uint16(40691), + 49: uint16(40692), + 50: uint16(40693), + 51: uint16(40694), + 52: uint16(40695), + 53: uint16(40696), + 54: uint16(40698), + 55: uint16(40701), + 56: uint16(40703), + 57: uint16(40704), + 58: uint16(40705), + 59: uint16(40706), + 60: uint16(40707), + 61: uint16(40708), + 62: uint16(40709), + 63: uint16(40710), + 64: uint16(40711), + 65: uint16(40712), + 66: uint16(40713), + 67: uint16(40714), + 68: uint16(40716), + 69: uint16(40719), + 70: uint16(40721), + 71: uint16(40722), + 72: uint16(40724), + 73: uint16(40725), + 74: uint16(40726), + 75: uint16(40728), + 76: uint16(40730), + 77: uint16(40731), + 78: uint16(40732), + 79: uint16(40733), + 80: uint16(40734), + 81: uint16(40735), + 82: uint16(40737), + 83: uint16(40739), + 84: uint16(40740), + 85: uint16(40741), + 86: uint16(40742), + 87: uint16(40743), + 88: uint16(40744), + 89: uint16(40745), + 90: uint16(40746), + 91: uint16(40747), + 92: uint16(40749), + 93: uint16(40750), + 94: uint16(40752), + 95: uint16(40753), + 96: uint16(58284), + 97: uint16(58285), + 98: uint16(58286), + 99: uint16(58287), + 100: uint16(58288), + 101: uint16(58289), + 102: uint16(58290), + 103: uint16(58291), + 104: uint16(58292), + 105: uint16(58293), + 106: uint16(58294), + 107: uint16(58295), + 108: uint16(58296), + 109: uint16(58297), + 110: uint16(58298), + 111: uint16(58299), + 112: uint16(58300), + 113: uint16(58301), + 114: uint16(58302), + 115: uint16(58303), + 116: uint16(58304), + 117: uint16(58305), + 118: uint16(58306), + 119: uint16(58307), + 120: uint16(58308), + 121: uint16(58309), + 122: uint16(58310), + 123: uint16(58311), + 124: uint16(58312), + 125: uint16(58313), + 126: uint16(58314), + 127: uint16(58315), + 128: uint16(58316), + 129: uint16(58317), + 130: uint16(58318), + 131: uint16(58319), + 132: uint16(58320), + 133: uint16(58321), + 134: uint16(58322), + 135: uint16(58323), + 136: uint16(58324), + 137: uint16(58325), + 138: uint16(58326), + 139: uint16(58327), + 140: uint16(58328), + 141: uint16(58329), + 142: uint16(58330), + 143: uint16(58331), + 144: uint16(58332), + 145: uint16(58333), + 146: uint16(58334), + 147: uint16(58335), + 148: uint16(58336), + 149: uint16(58337), + 150: uint16(58338), + 151: uint16(58339), + 152: uint16(58340), + 153: uint16(58341), + 154: uint16(58342), + 155: uint16(58343), + 156: uint16(58344), + 157: uint16(58345), + 158: uint16(58346), + 159: uint16(58347), + 160: uint16(58348), + 161: uint16(58349), + 162: uint16(58350), + 163: uint16(58351), + 164: uint16(58352), + 165: uint16(58353), + 166: uint16(58354), + 167: uint16(58355), + 168: uint16(58356), + 169: uint16(58357), + 170: uint16(58358), + 171: uint16(58359), + 172: uint16(58360), + 173: uint16(58361), + 174: uint16(58362), + 175: uint16(58363), + 176: uint16(58364), + 177: uint16(58365), + 178: uint16(58366), + 179: uint16(58367), + 180: uint16(58368), + 181: uint16(58369), + 182: uint16(58370), + 183: uint16(58371), + 184: uint16(58372), + 185: uint16(58373), + 186: uint16(58374), + 187: uint16(58375), + 188: uint16(58376), + 189: uint16(58377), + }, + 124: { + 0: uint16(40754), + 1: uint16(40755), + 2: uint16(40756), + 3: uint16(40757), + 4: uint16(40758), + 5: uint16(40760), + 6: uint16(40762), + 7: uint16(40764), + 8: uint16(40767), + 9: uint16(40768), + 10: uint16(40769), + 11: uint16(40770), + 12: uint16(40771), + 13: uint16(40773), + 14: uint16(40774), + 15: uint16(40775), + 16: uint16(40776), + 17: uint16(40777), + 18: uint16(40778), + 19: uint16(40779), + 20: uint16(40780), + 21: uint16(40781), + 22: uint16(40782), + 23: uint16(40783), + 24: uint16(40786), + 25: uint16(40787), + 26: uint16(40788), + 27: uint16(40789), + 28: uint16(40790), + 29: uint16(40791), + 30: uint16(40792), + 31: uint16(40793), + 32: uint16(40794), + 33: uint16(40795), + 34: uint16(40796), + 35: uint16(40797), + 36: uint16(40798), + 37: uint16(40799), + 38: uint16(40800), + 39: uint16(40801), + 40: uint16(40802), + 41: uint16(40803), + 42: uint16(40804), + 43: uint16(40805), + 44: uint16(40806), + 45: uint16(40807), + 46: uint16(40808), + 47: uint16(40809), + 48: uint16(40810), + 49: uint16(40811), + 50: uint16(40812), + 51: uint16(40813), + 52: uint16(40814), + 53: uint16(40815), + 54: uint16(40816), + 55: uint16(40817), + 56: uint16(40818), + 57: uint16(40819), + 58: uint16(40820), + 59: uint16(40821), + 60: uint16(40822), + 61: uint16(40823), + 62: uint16(40824), + 63: uint16(40825), + 64: uint16(40826), + 65: uint16(40827), + 66: uint16(40828), + 67: uint16(40829), + 68: uint16(40830), + 69: uint16(40833), + 70: uint16(40834), + 71: uint16(40845), + 72: uint16(40846), + 73: uint16(40847), + 74: uint16(40848), + 75: uint16(40849), + 76: uint16(40850), + 77: uint16(40851), + 78: uint16(40852), + 79: uint16(40853), + 80: uint16(40854), + 81: uint16(40855), + 82: uint16(40856), + 83: uint16(40860), + 84: uint16(40861), + 85: uint16(40862), + 86: uint16(40865), + 87: uint16(40866), + 88: uint16(40867), + 89: uint16(40868), + 90: uint16(40869), + 91: uint16(63788), + 92: uint16(63865), + 93: uint16(63893), + 94: uint16(63975), + 95: uint16(63985), + 96: uint16(58378), + 97: uint16(58379), + 98: uint16(58380), + 99: uint16(58381), + 100: uint16(58382), + 101: uint16(58383), + 102: uint16(58384), + 103: uint16(58385), + 104: uint16(58386), + 105: uint16(58387), + 106: uint16(58388), + 107: uint16(58389), + 108: uint16(58390), + 109: uint16(58391), + 110: uint16(58392), + 111: uint16(58393), + 112: uint16(58394), + 113: uint16(58395), + 114: uint16(58396), + 115: uint16(58397), + 116: uint16(58398), + 117: uint16(58399), + 118: uint16(58400), + 119: uint16(58401), + 120: uint16(58402), + 121: uint16(58403), + 122: uint16(58404), + 123: uint16(58405), + 124: uint16(58406), + 125: uint16(58407), + 126: uint16(58408), + 127: uint16(58409), + 128: uint16(58410), + 129: uint16(58411), + 130: uint16(58412), + 131: uint16(58413), + 132: uint16(58414), + 133: uint16(58415), + 134: uint16(58416), + 135: uint16(58417), + 136: uint16(58418), + 137: uint16(58419), + 138: uint16(58420), + 139: uint16(58421), + 140: uint16(58422), + 141: uint16(58423), + 142: uint16(58424), + 143: uint16(58425), + 144: uint16(58426), + 145: uint16(58427), + 146: uint16(58428), + 147: uint16(58429), + 148: uint16(58430), + 149: uint16(58431), + 150: uint16(58432), + 151: uint16(58433), + 152: uint16(58434), + 153: uint16(58435), + 154: uint16(58436), + 155: uint16(58437), + 156: uint16(58438), + 157: uint16(58439), + 158: uint16(58440), + 159: uint16(58441), + 160: uint16(58442), + 161: uint16(58443), + 162: uint16(58444), + 163: uint16(58445), + 164: uint16(58446), + 165: uint16(58447), + 166: uint16(58448), + 167: uint16(58449), + 168: uint16(58450), + 169: uint16(58451), + 170: uint16(58452), + 171: uint16(58453), + 172: uint16(58454), + 173: uint16(58455), + 174: uint16(58456), + 175: uint16(58457), + 176: uint16(58458), + 177: uint16(58459), + 178: uint16(58460), + 179: uint16(58461), + 180: uint16(58462), + 181: uint16(58463), + 182: uint16(58464), + 183: uint16(58465), + 184: uint16(58466), + 185: uint16(58467), + 186: uint16(58468), + 187: uint16(58469), + 188: uint16(58470), + 189: uint16(58471), + }, + 125: { + 0: uint16(64012), + 1: uint16(64013), + 2: uint16(64014), + 3: uint16(64015), + 4: uint16(64017), + 5: uint16(64019), + 6: uint16(64020), + 7: uint16(64024), + 8: uint16(64031), + 9: uint16(64032), + 10: uint16(64033), + 11: uint16(64035), + 12: uint16(64036), + 13: uint16(64039), + 14: uint16(64040), + 15: uint16(64041), + 16: uint16(11905), + 17: uint16(59414), + 18: uint16(59415), + 19: uint16(59416), + 20: uint16(11908), + 21: uint16(13427), + 22: uint16(13383), + 23: uint16(11912), + 24: uint16(11915), + 25: uint16(59422), + 26: uint16(13726), + 27: uint16(13850), + 28: uint16(13838), + 29: uint16(11916), + 30: uint16(11927), + 31: uint16(14702), + 32: uint16(14616), + 33: uint16(59430), + 34: uint16(14799), + 35: uint16(14815), + 36: uint16(14963), + 37: uint16(14800), + 38: uint16(59435), + 39: uint16(59436), + 40: uint16(15182), + 41: uint16(15470), + 42: uint16(15584), + 43: uint16(11943), + 44: uint16(59441), + 45: uint16(59442), + 46: uint16(11946), + 47: uint16(16470), + 48: uint16(16735), + 49: uint16(11950), + 50: uint16(17207), + 51: uint16(11955), + 52: uint16(11958), + 53: uint16(11959), + 54: uint16(59451), + 55: uint16(17329), + 56: uint16(17324), + 57: uint16(11963), + 58: uint16(17373), + 59: uint16(17622), + 60: uint16(18017), + 61: uint16(17996), + 62: uint16(59459), + 63: uint16(18211), + 64: uint16(18217), + 65: uint16(18300), + 66: uint16(18317), + 67: uint16(11978), + 68: uint16(18759), + 69: uint16(18810), + 70: uint16(18813), + 71: uint16(18818), + 72: uint16(18819), + 73: uint16(18821), + 74: uint16(18822), + 75: uint16(18847), + 76: uint16(18843), + 77: uint16(18871), + 78: uint16(18870), + 79: uint16(59476), + 80: uint16(59477), + 81: uint16(19619), + 82: uint16(19615), + 83: uint16(19616), + 84: uint16(19617), + 85: uint16(19575), + 86: uint16(19618), + 87: uint16(19731), + 88: uint16(19732), + 89: uint16(19733), + 90: uint16(19734), + 91: uint16(19735), + 92: uint16(19736), + 93: uint16(19737), + 94: uint16(19886), + 95: uint16(59492), + 96: uint16(58472), + 97: uint16(58473), + 98: uint16(58474), + 99: uint16(58475), + 100: uint16(58476), + 101: uint16(58477), + 102: uint16(58478), + 103: uint16(58479), + 104: uint16(58480), + 105: uint16(58481), + 106: uint16(58482), + 107: uint16(58483), + 108: uint16(58484), + 109: uint16(58485), + 110: uint16(58486), + 111: uint16(58487), + 112: uint16(58488), + 113: uint16(58489), + 114: uint16(58490), + 115: uint16(58491), + 116: uint16(58492), + 117: uint16(58493), + 118: uint16(58494), + 119: uint16(58495), + 120: uint16(58496), + 121: uint16(58497), + 122: uint16(58498), + 123: uint16(58499), + 124: uint16(58500), + 125: uint16(58501), + 126: uint16(58502), + 127: uint16(58503), + 128: uint16(58504), + 129: uint16(58505), + 130: uint16(58506), + 131: uint16(58507), + 132: uint16(58508), + 133: uint16(58509), + 134: uint16(58510), + 135: uint16(58511), + 136: uint16(58512), + 137: uint16(58513), + 138: uint16(58514), + 139: uint16(58515), + 140: uint16(58516), + 141: uint16(58517), + 142: uint16(58518), + 143: uint16(58519), + 144: uint16(58520), + 145: uint16(58521), + 146: uint16(58522), + 147: uint16(58523), + 148: uint16(58524), + 149: uint16(58525), + 150: uint16(58526), + 151: uint16(58527), + 152: uint16(58528), + 153: uint16(58529), + 154: uint16(58530), + 155: uint16(58531), + 156: uint16(58532), + 157: uint16(58533), + 158: uint16(58534), + 159: uint16(58535), + 160: uint16(58536), + 161: uint16(58537), + 162: uint16(58538), + 163: uint16(58539), + 164: uint16(58540), + 165: uint16(58541), + 166: uint16(58542), + 167: uint16(58543), + 168: uint16(58544), + 169: uint16(58545), + 170: uint16(58546), + 171: uint16(58547), + 172: uint16(58548), + 173: uint16(58549), + 174: uint16(58550), + 175: uint16(58551), + 176: uint16(58552), + 177: uint16(58553), + 178: uint16(58554), + 179: uint16(58555), + 180: uint16(58556), + 181: uint16(58557), + 182: uint16(58558), + 183: uint16(58559), + 184: uint16(58560), + 185: uint16(58561), + 186: uint16(58562), + 187: uint16(58563), + 188: uint16(58564), + 189: uint16(58565), + }, +} + +var _big5 = [89][157]uint16{ + 0: { + 0: uint16(12288), + 1: uint16(65292), + 2: uint16(12289), + 3: uint16(12290), + 4: uint16(65294), + 5: uint16(8231), + 6: uint16(65307), + 7: uint16(65306), + 8: uint16(65311), + 9: uint16(65281), + 10: uint16(65072), + 11: uint16(8230), + 12: uint16(8229), + 13: uint16(65104), + 14: uint16(65105), + 15: uint16(65106), + 16: uint16(183), + 17: uint16(65108), + 18: uint16(65109), + 19: uint16(65110), + 20: uint16(65111), + 21: uint16(65372), + 22: uint16(8211), + 23: uint16(65073), + 24: uint16(8212), + 25: uint16(65075), + 26: uint16(9588), + 27: uint16(65076), + 28: uint16(65103), + 29: uint16(65288), + 30: uint16(65289), + 31: uint16(65077), + 32: uint16(65078), + 33: uint16(65371), + 34: uint16(65373), + 35: uint16(65079), + 36: uint16(65080), + 37: uint16(12308), + 38: uint16(12309), + 39: uint16(65081), + 40: uint16(65082), + 41: uint16(12304), + 42: uint16(12305), + 43: uint16(65083), + 44: uint16(65084), + 45: uint16(12298), + 46: uint16(12299), + 47: uint16(65085), + 48: uint16(65086), + 49: uint16(12296), + 50: uint16(12297), + 51: uint16(65087), + 52: uint16(65088), + 53: uint16(12300), + 54: uint16(12301), + 55: uint16(65089), + 56: uint16(65090), + 57: uint16(12302), + 58: uint16(12303), + 59: uint16(65091), + 60: uint16(65092), + 61: uint16(65113), + 62: uint16(65114), + 63: uint16(65115), + 64: uint16(65116), + 65: uint16(65117), + 66: uint16(65118), + 67: uint16(8216), + 68: uint16(8217), + 69: uint16(8220), + 70: uint16(8221), + 71: uint16(12317), + 72: uint16(12318), + 73: uint16(8245), + 74: uint16(8242), + 75: uint16(65283), + 76: uint16(65286), + 77: uint16(65290), + 78: uint16(8251), + 79: uint16(167), + 80: uint16(12291), + 81: uint16(9675), + 82: uint16(9679), + 83: uint16(9651), + 84: uint16(9650), + 85: uint16(9678), + 86: uint16(9734), + 87: uint16(9733), + 88: uint16(9671), + 89: uint16(9670), + 90: uint16(9633), + 91: uint16(9632), + 92: uint16(9661), + 93: uint16(9660), + 94: uint16(12963), + 95: uint16(8453), + 96: uint16(175), + 97: uint16(65507), + 98: uint16(65343), + 99: uint16(717), + 100: uint16(65097), + 101: uint16(65098), + 102: uint16(65101), + 103: uint16(65102), + 104: uint16(65099), + 105: uint16(65100), + 106: uint16(65119), + 107: uint16(65120), + 108: uint16(65121), + 109: uint16(65291), + 110: uint16(65293), + 111: uint16(215), + 112: uint16(247), + 113: uint16(177), + 114: uint16(8730), + 115: uint16(65308), + 116: uint16(65310), + 117: uint16(65309), + 118: uint16(8806), + 119: uint16(8807), + 120: uint16(8800), + 121: uint16(8734), + 122: uint16(8786), + 123: uint16(8801), + 124: uint16(65122), + 125: uint16(65123), + 126: uint16(65124), + 127: uint16(65125), + 128: uint16(65126), + 129: uint16(65374), + 130: uint16(8745), + 131: uint16(8746), + 132: uint16(8869), + 133: uint16(8736), + 134: uint16(8735), + 135: uint16(8895), + 136: uint16(13266), + 137: uint16(13265), + 138: uint16(8747), + 139: uint16(8750), + 140: uint16(8757), + 141: uint16(8756), + 142: uint16(9792), + 143: uint16(9794), + 144: uint16(8853), + 145: uint16(8857), + 146: uint16(8593), + 147: uint16(8595), + 148: uint16(8592), + 149: uint16(8594), + 150: uint16(8598), + 151: uint16(8599), + 152: uint16(8601), + 153: uint16(8600), + 154: uint16(8741), + 155: uint16(8739), + 156: uint16(65295), + }, + 1: { + 0: uint16(65340), + 1: uint16(8725), + 2: uint16(65128), + 3: uint16(65284), + 4: uint16(65509), + 5: uint16(12306), + 6: uint16(65504), + 7: uint16(65505), + 8: uint16(65285), + 9: uint16(65312), + 10: uint16(8451), + 11: uint16(8457), + 12: uint16(65129), + 13: uint16(65130), + 14: uint16(65131), + 15: uint16(13269), + 16: uint16(13212), + 17: uint16(13213), + 18: uint16(13214), + 19: uint16(13262), + 20: uint16(13217), + 21: uint16(13198), + 22: uint16(13199), + 23: uint16(13252), + 24: uint16(176), + 25: uint16(20825), + 26: uint16(20827), + 27: uint16(20830), + 28: uint16(20829), + 29: uint16(20833), + 30: uint16(20835), + 31: uint16(21991), + 32: uint16(29929), + 33: uint16(31950), + 34: uint16(9601), + 35: uint16(9602), + 36: uint16(9603), + 37: uint16(9604), + 38: uint16(9605), + 39: uint16(9606), + 40: uint16(9607), + 41: uint16(9608), + 42: uint16(9615), + 43: uint16(9614), + 44: uint16(9613), + 45: uint16(9612), + 46: uint16(9611), + 47: uint16(9610), + 48: uint16(9609), + 49: uint16(9532), + 50: uint16(9524), + 51: uint16(9516), + 52: uint16(9508), + 53: uint16(9500), + 54: uint16(9620), + 55: uint16(9472), + 56: uint16(9474), + 57: uint16(9621), + 58: uint16(9484), + 59: uint16(9488), + 60: uint16(9492), + 61: uint16(9496), + 62: uint16(9581), + 63: uint16(9582), + 64: uint16(9584), + 65: uint16(9583), + 66: uint16(9552), + 67: uint16(9566), + 68: uint16(9578), + 69: uint16(9569), + 70: uint16(9698), + 71: uint16(9699), + 72: uint16(9701), + 73: uint16(9700), + 74: uint16(9585), + 75: uint16(9586), + 76: uint16(9587), + 77: uint16(65296), + 78: uint16(65297), + 79: uint16(65298), + 80: uint16(65299), + 81: uint16(65300), + 82: uint16(65301), + 83: uint16(65302), + 84: uint16(65303), + 85: uint16(65304), + 86: uint16(65305), + 87: uint16(8544), + 88: uint16(8545), + 89: uint16(8546), + 90: uint16(8547), + 91: uint16(8548), + 92: uint16(8549), + 93: uint16(8550), + 94: uint16(8551), + 95: uint16(8552), + 96: uint16(8553), + 97: uint16(12321), + 98: uint16(12322), + 99: uint16(12323), + 100: uint16(12324), + 101: uint16(12325), + 102: uint16(12326), + 103: uint16(12327), + 104: uint16(12328), + 105: uint16(12329), + 106: uint16(21313), + 107: uint16(21316), + 108: uint16(21317), + 109: uint16(65313), + 110: uint16(65314), + 111: uint16(65315), + 112: uint16(65316), + 113: uint16(65317), + 114: uint16(65318), + 115: uint16(65319), + 116: uint16(65320), + 117: uint16(65321), + 118: uint16(65322), + 119: uint16(65323), + 120: uint16(65324), + 121: uint16(65325), + 122: uint16(65326), + 123: uint16(65327), + 124: uint16(65328), + 125: uint16(65329), + 126: uint16(65330), + 127: uint16(65331), + 128: uint16(65332), + 129: uint16(65333), + 130: uint16(65334), + 131: uint16(65335), + 132: uint16(65336), + 133: uint16(65337), + 134: uint16(65338), + 135: uint16(65345), + 136: uint16(65346), + 137: uint16(65347), + 138: uint16(65348), + 139: uint16(65349), + 140: uint16(65350), + 141: uint16(65351), + 142: uint16(65352), + 143: uint16(65353), + 144: uint16(65354), + 145: uint16(65355), + 146: uint16(65356), + 147: uint16(65357), + 148: uint16(65358), + 149: uint16(65359), + 150: uint16(65360), + 151: uint16(65361), + 152: uint16(65362), + 153: uint16(65363), + 154: uint16(65364), + 155: uint16(65365), + 156: uint16(65366), + }, + 2: { + 0: uint16(65367), + 1: uint16(65368), + 2: uint16(65369), + 3: uint16(65370), + 4: uint16(913), + 5: uint16(914), + 6: uint16(915), + 7: uint16(916), + 8: uint16(917), + 9: uint16(918), + 10: uint16(919), + 11: uint16(920), + 12: uint16(921), + 13: uint16(922), + 14: uint16(923), + 15: uint16(924), + 16: uint16(925), + 17: uint16(926), + 18: uint16(927), + 19: uint16(928), + 20: uint16(929), + 21: uint16(931), + 22: uint16(932), + 23: uint16(933), + 24: uint16(934), + 25: uint16(935), + 26: uint16(936), + 27: uint16(937), + 28: uint16(945), + 29: uint16(946), + 30: uint16(947), + 31: uint16(948), + 32: uint16(949), + 33: uint16(950), + 34: uint16(951), + 35: uint16(952), + 36: uint16(953), + 37: uint16(954), + 38: uint16(955), + 39: uint16(956), + 40: uint16(957), + 41: uint16(958), + 42: uint16(959), + 43: uint16(960), + 44: uint16(961), + 45: uint16(963), + 46: uint16(964), + 47: uint16(965), + 48: uint16(966), + 49: uint16(967), + 50: uint16(968), + 51: uint16(969), + 52: uint16(12549), + 53: uint16(12550), + 54: uint16(12551), + 55: uint16(12552), + 56: uint16(12553), + 57: uint16(12554), + 58: uint16(12555), + 59: uint16(12556), + 60: uint16(12557), + 61: uint16(12558), + 62: uint16(12559), + 63: uint16(12560), + 64: uint16(12561), + 65: uint16(12562), + 66: uint16(12563), + 67: uint16(12564), + 68: uint16(12565), + 69: uint16(12566), + 70: uint16(12567), + 71: uint16(12568), + 72: uint16(12569), + 73: uint16(12570), + 74: uint16(12571), + 75: uint16(12572), + 76: uint16(12573), + 77: uint16(12574), + 78: uint16(12575), + 79: uint16(12576), + 80: uint16(12577), + 81: uint16(12578), + 82: uint16(12579), + 83: uint16(12580), + 84: uint16(12581), + 85: uint16(12582), + 86: uint16(12583), + 87: uint16(12584), + 88: uint16(12585), + 89: uint16(729), + 90: uint16(713), + 91: uint16(714), + 92: uint16(711), + 93: uint16(715), + 94: uint16(9216), + 95: uint16(9217), + 96: uint16(9218), + 97: uint16(9219), + 98: uint16(9220), + 99: uint16(9221), + 100: uint16(9222), + 101: uint16(9223), + 102: uint16(9224), + 103: uint16(9225), + 104: uint16(9226), + 105: uint16(9227), + 106: uint16(9228), + 107: uint16(9229), + 108: uint16(9230), + 109: uint16(9231), + 110: uint16(9232), + 111: uint16(9233), + 112: uint16(9234), + 113: uint16(9235), + 114: uint16(9236), + 115: uint16(9237), + 116: uint16(9238), + 117: uint16(9239), + 118: uint16(9240), + 119: uint16(9241), + 120: uint16(9242), + 121: uint16(9243), + 122: uint16(9244), + 123: uint16(9245), + 124: uint16(9246), + 125: uint16(9247), + 126: uint16(9249), + 127: uint16(8364), + }, + 3: { + 0: uint16(19968), + 1: uint16(20057), + 2: uint16(19969), + 3: uint16(19971), + 4: uint16(20035), + 5: uint16(20061), + 6: uint16(20102), + 7: uint16(20108), + 8: uint16(20154), + 9: uint16(20799), + 10: uint16(20837), + 11: uint16(20843), + 12: uint16(20960), + 13: uint16(20992), + 14: uint16(20993), + 15: uint16(21147), + 16: uint16(21269), + 17: uint16(21313), + 18: uint16(21340), + 19: uint16(21448), + 20: uint16(19977), + 21: uint16(19979), + 22: uint16(19976), + 23: uint16(19978), + 24: uint16(20011), + 25: uint16(20024), + 26: uint16(20961), + 27: uint16(20037), + 28: uint16(20040), + 29: uint16(20063), + 30: uint16(20062), + 31: uint16(20110), + 32: uint16(20129), + 33: uint16(20800), + 34: uint16(20995), + 35: uint16(21242), + 36: uint16(21315), + 37: uint16(21449), + 38: uint16(21475), + 39: uint16(22303), + 40: uint16(22763), + 41: uint16(22805), + 42: uint16(22823), + 43: uint16(22899), + 44: uint16(23376), + 45: uint16(23377), + 46: uint16(23379), + 47: uint16(23544), + 48: uint16(23567), + 49: uint16(23586), + 50: uint16(23608), + 51: uint16(23665), + 52: uint16(24029), + 53: uint16(24037), + 54: uint16(24049), + 55: uint16(24050), + 56: uint16(24051), + 57: uint16(24062), + 58: uint16(24178), + 59: uint16(24318), + 60: uint16(24331), + 61: uint16(24339), + 62: uint16(25165), + 63: uint16(19985), + 64: uint16(19984), + 65: uint16(19981), + 66: uint16(20013), + 67: uint16(20016), + 68: uint16(20025), + 69: uint16(20043), + 70: uint16(23609), + 71: uint16(20104), + 72: uint16(20113), + 73: uint16(20117), + 74: uint16(20114), + 75: uint16(20116), + 76: uint16(20130), + 77: uint16(20161), + 78: uint16(20160), + 79: uint16(20163), + 80: uint16(20166), + 81: uint16(20167), + 82: uint16(20173), + 83: uint16(20170), + 84: uint16(20171), + 85: uint16(20164), + 86: uint16(20803), + 87: uint16(20801), + 88: uint16(20839), + 89: uint16(20845), + 90: uint16(20846), + 91: uint16(20844), + 92: uint16(20887), + 93: uint16(20982), + 94: uint16(20998), + 95: uint16(20999), + 96: uint16(21000), + 97: uint16(21243), + 98: uint16(21246), + 99: uint16(21247), + 100: uint16(21270), + 101: uint16(21305), + 102: uint16(21320), + 103: uint16(21319), + 104: uint16(21317), + 105: uint16(21342), + 106: uint16(21380), + 107: uint16(21451), + 108: uint16(21450), + 109: uint16(21453), + 110: uint16(22764), + 111: uint16(22825), + 112: uint16(22827), + 113: uint16(22826), + 114: uint16(22829), + 115: uint16(23380), + 116: uint16(23569), + 117: uint16(23588), + 118: uint16(23610), + 119: uint16(23663), + 120: uint16(24052), + 121: uint16(24187), + 122: uint16(24319), + 123: uint16(24340), + 124: uint16(24341), + 125: uint16(24515), + 126: uint16(25096), + 127: uint16(25142), + 128: uint16(25163), + 129: uint16(25166), + 130: uint16(25903), + 131: uint16(25991), + 132: uint16(26007), + 133: uint16(26020), + 134: uint16(26041), + 135: uint16(26085), + 136: uint16(26352), + 137: uint16(26376), + 138: uint16(26408), + 139: uint16(27424), + 140: uint16(27490), + 141: uint16(27513), + 142: uint16(27595), + 143: uint16(27604), + 144: uint16(27611), + 145: uint16(27663), + 146: uint16(27700), + 147: uint16(28779), + 148: uint16(29226), + 149: uint16(29238), + 150: uint16(29243), + 151: uint16(29255), + 152: uint16(29273), + 153: uint16(29275), + 154: uint16(29356), + 155: uint16(29579), + 156: uint16(19993), + }, + 4: { + 0: uint16(19990), + 1: uint16(19989), + 2: uint16(19988), + 3: uint16(19992), + 4: uint16(20027), + 5: uint16(20045), + 6: uint16(20047), + 7: uint16(20046), + 8: uint16(20197), + 9: uint16(20184), + 10: uint16(20180), + 11: uint16(20181), + 12: uint16(20182), + 13: uint16(20183), + 14: uint16(20195), + 15: uint16(20196), + 16: uint16(20185), + 17: uint16(20190), + 18: uint16(20805), + 19: uint16(20804), + 20: uint16(20873), + 21: uint16(20874), + 22: uint16(20908), + 23: uint16(20985), + 24: uint16(20986), + 25: uint16(20984), + 26: uint16(21002), + 27: uint16(21152), + 28: uint16(21151), + 29: uint16(21253), + 30: uint16(21254), + 31: uint16(21271), + 32: uint16(21277), + 33: uint16(20191), + 34: uint16(21322), + 35: uint16(21321), + 36: uint16(21345), + 37: uint16(21344), + 38: uint16(21359), + 39: uint16(21358), + 40: uint16(21435), + 41: uint16(21487), + 42: uint16(21476), + 43: uint16(21491), + 44: uint16(21484), + 45: uint16(21486), + 46: uint16(21481), + 47: uint16(21480), + 48: uint16(21500), + 49: uint16(21496), + 50: uint16(21493), + 51: uint16(21483), + 52: uint16(21478), + 53: uint16(21482), + 54: uint16(21490), + 55: uint16(21489), + 56: uint16(21488), + 57: uint16(21477), + 58: uint16(21485), + 59: uint16(21499), + 60: uint16(22235), + 61: uint16(22234), + 62: uint16(22806), + 63: uint16(22830), + 64: uint16(22833), + 65: uint16(22900), + 66: uint16(22902), + 67: uint16(23381), + 68: uint16(23427), + 69: uint16(23612), + 70: uint16(24040), + 71: uint16(24039), + 72: uint16(24038), + 73: uint16(24066), + 74: uint16(24067), + 75: uint16(24179), + 76: uint16(24188), + 77: uint16(24321), + 78: uint16(24344), + 79: uint16(24343), + 80: uint16(24517), + 81: uint16(25098), + 82: uint16(25171), + 83: uint16(25172), + 84: uint16(25170), + 85: uint16(25169), + 86: uint16(26021), + 87: uint16(26086), + 88: uint16(26414), + 89: uint16(26412), + 90: uint16(26410), + 91: uint16(26411), + 92: uint16(26413), + 93: uint16(27491), + 94: uint16(27597), + 95: uint16(27665), + 96: uint16(27664), + 97: uint16(27704), + 98: uint16(27713), + 99: uint16(27712), + 100: uint16(27710), + 101: uint16(29359), + 102: uint16(29572), + 103: uint16(29577), + 104: uint16(29916), + 105: uint16(29926), + 106: uint16(29976), + 107: uint16(29983), + 108: uint16(29992), + 109: uint16(29993), + 110: uint16(30000), + 111: uint16(30001), + 112: uint16(30002), + 113: uint16(30003), + 114: uint16(30091), + 115: uint16(30333), + 116: uint16(30382), + 117: uint16(30399), + 118: uint16(30446), + 119: uint16(30683), + 120: uint16(30690), + 121: uint16(30707), + 122: uint16(31034), + 123: uint16(31166), + 124: uint16(31348), + 125: uint16(31435), + 126: uint16(19998), + 127: uint16(19999), + 128: uint16(20050), + 129: uint16(20051), + 130: uint16(20073), + 131: uint16(20121), + 132: uint16(20132), + 133: uint16(20134), + 134: uint16(20133), + 135: uint16(20223), + 136: uint16(20233), + 137: uint16(20249), + 138: uint16(20234), + 139: uint16(20245), + 140: uint16(20237), + 141: uint16(20240), + 142: uint16(20241), + 143: uint16(20239), + 144: uint16(20210), + 145: uint16(20214), + 146: uint16(20219), + 147: uint16(20208), + 148: uint16(20211), + 149: uint16(20221), + 150: uint16(20225), + 151: uint16(20235), + 152: uint16(20809), + 153: uint16(20807), + 154: uint16(20806), + 155: uint16(20808), + 156: uint16(20840), + }, + 5: { + 0: uint16(20849), + 1: uint16(20877), + 2: uint16(20912), + 3: uint16(21015), + 4: uint16(21009), + 5: uint16(21010), + 6: uint16(21006), + 7: uint16(21014), + 8: uint16(21155), + 9: uint16(21256), + 10: uint16(21281), + 11: uint16(21280), + 12: uint16(21360), + 13: uint16(21361), + 14: uint16(21513), + 15: uint16(21519), + 16: uint16(21516), + 17: uint16(21514), + 18: uint16(21520), + 19: uint16(21505), + 20: uint16(21515), + 21: uint16(21508), + 22: uint16(21521), + 23: uint16(21517), + 24: uint16(21512), + 25: uint16(21507), + 26: uint16(21518), + 27: uint16(21510), + 28: uint16(21522), + 29: uint16(22240), + 30: uint16(22238), + 31: uint16(22237), + 32: uint16(22323), + 33: uint16(22320), + 34: uint16(22312), + 35: uint16(22317), + 36: uint16(22316), + 37: uint16(22319), + 38: uint16(22313), + 39: uint16(22809), + 40: uint16(22810), + 41: uint16(22839), + 42: uint16(22840), + 43: uint16(22916), + 44: uint16(22904), + 45: uint16(22915), + 46: uint16(22909), + 47: uint16(22905), + 48: uint16(22914), + 49: uint16(22913), + 50: uint16(23383), + 51: uint16(23384), + 52: uint16(23431), + 53: uint16(23432), + 54: uint16(23429), + 55: uint16(23433), + 56: uint16(23546), + 57: uint16(23574), + 58: uint16(23673), + 59: uint16(24030), + 60: uint16(24070), + 61: uint16(24182), + 62: uint16(24180), + 63: uint16(24335), + 64: uint16(24347), + 65: uint16(24537), + 66: uint16(24534), + 67: uint16(25102), + 68: uint16(25100), + 69: uint16(25101), + 70: uint16(25104), + 71: uint16(25187), + 72: uint16(25179), + 73: uint16(25176), + 74: uint16(25910), + 75: uint16(26089), + 76: uint16(26088), + 77: uint16(26092), + 78: uint16(26093), + 79: uint16(26354), + 80: uint16(26355), + 81: uint16(26377), + 82: uint16(26429), + 83: uint16(26420), + 84: uint16(26417), + 85: uint16(26421), + 86: uint16(27425), + 87: uint16(27492), + 88: uint16(27515), + 89: uint16(27670), + 90: uint16(27741), + 91: uint16(27735), + 92: uint16(27737), + 93: uint16(27743), + 94: uint16(27744), + 95: uint16(27728), + 96: uint16(27733), + 97: uint16(27745), + 98: uint16(27739), + 99: uint16(27725), + 100: uint16(27726), + 101: uint16(28784), + 102: uint16(29279), + 103: uint16(29277), + 104: uint16(30334), + 105: uint16(31481), + 106: uint16(31859), + 107: uint16(31992), + 108: uint16(32566), + 109: uint16(32650), + 110: uint16(32701), + 111: uint16(32769), + 112: uint16(32771), + 113: uint16(32780), + 114: uint16(32786), + 115: uint16(32819), + 116: uint16(32895), + 117: uint16(32905), + 118: uint16(32907), + 119: uint16(32908), + 120: uint16(33251), + 121: uint16(33258), + 122: uint16(33267), + 123: uint16(33276), + 124: uint16(33292), + 125: uint16(33307), + 126: uint16(33311), + 127: uint16(33390), + 128: uint16(33394), + 129: uint16(33406), + 130: uint16(34411), + 131: uint16(34880), + 132: uint16(34892), + 133: uint16(34915), + 134: uint16(35199), + 135: uint16(38433), + 136: uint16(20018), + 137: uint16(20136), + 138: uint16(20301), + 139: uint16(20303), + 140: uint16(20295), + 141: uint16(20311), + 142: uint16(20318), + 143: uint16(20276), + 144: uint16(20315), + 145: uint16(20309), + 146: uint16(20272), + 147: uint16(20304), + 148: uint16(20305), + 149: uint16(20285), + 150: uint16(20282), + 151: uint16(20280), + 152: uint16(20291), + 153: uint16(20308), + 154: uint16(20284), + 155: uint16(20294), + 156: uint16(20323), + }, + 6: { + 0: uint16(20316), + 1: uint16(20320), + 2: uint16(20271), + 3: uint16(20302), + 4: uint16(20278), + 5: uint16(20313), + 6: uint16(20317), + 7: uint16(20296), + 8: uint16(20314), + 9: uint16(20812), + 10: uint16(20811), + 11: uint16(20813), + 12: uint16(20853), + 13: uint16(20918), + 14: uint16(20919), + 15: uint16(21029), + 16: uint16(21028), + 17: uint16(21033), + 18: uint16(21034), + 19: uint16(21032), + 20: uint16(21163), + 21: uint16(21161), + 22: uint16(21162), + 23: uint16(21164), + 24: uint16(21283), + 25: uint16(21363), + 26: uint16(21365), + 27: uint16(21533), + 28: uint16(21549), + 29: uint16(21534), + 30: uint16(21566), + 31: uint16(21542), + 32: uint16(21582), + 33: uint16(21543), + 34: uint16(21574), + 35: uint16(21571), + 36: uint16(21555), + 37: uint16(21576), + 38: uint16(21570), + 39: uint16(21531), + 40: uint16(21545), + 41: uint16(21578), + 42: uint16(21561), + 43: uint16(21563), + 44: uint16(21560), + 45: uint16(21550), + 46: uint16(21557), + 47: uint16(21558), + 48: uint16(21536), + 49: uint16(21564), + 50: uint16(21568), + 51: uint16(21553), + 52: uint16(21547), + 53: uint16(21535), + 54: uint16(21548), + 55: uint16(22250), + 56: uint16(22256), + 57: uint16(22244), + 58: uint16(22251), + 59: uint16(22346), + 60: uint16(22353), + 61: uint16(22336), + 62: uint16(22349), + 63: uint16(22343), + 64: uint16(22350), + 65: uint16(22334), + 66: uint16(22352), + 67: uint16(22351), + 68: uint16(22331), + 69: uint16(22767), + 70: uint16(22846), + 71: uint16(22941), + 72: uint16(22930), + 73: uint16(22952), + 74: uint16(22942), + 75: uint16(22947), + 76: uint16(22937), + 77: uint16(22934), + 78: uint16(22925), + 79: uint16(22948), + 80: uint16(22931), + 81: uint16(22922), + 82: uint16(22949), + 83: uint16(23389), + 84: uint16(23388), + 85: uint16(23386), + 86: uint16(23387), + 87: uint16(23436), + 88: uint16(23435), + 89: uint16(23439), + 90: uint16(23596), + 91: uint16(23616), + 92: uint16(23617), + 93: uint16(23615), + 94: uint16(23614), + 95: uint16(23696), + 96: uint16(23697), + 97: uint16(23700), + 98: uint16(23692), + 99: uint16(24043), + 100: uint16(24076), + 101: uint16(24207), + 102: uint16(24199), + 103: uint16(24202), + 104: uint16(24311), + 105: uint16(24324), + 106: uint16(24351), + 107: uint16(24420), + 108: uint16(24418), + 109: uint16(24439), + 110: uint16(24441), + 111: uint16(24536), + 112: uint16(24524), + 113: uint16(24535), + 114: uint16(24525), + 115: uint16(24561), + 116: uint16(24555), + 117: uint16(24568), + 118: uint16(24554), + 119: uint16(25106), + 120: uint16(25105), + 121: uint16(25220), + 122: uint16(25239), + 123: uint16(25238), + 124: uint16(25216), + 125: uint16(25206), + 126: uint16(25225), + 127: uint16(25197), + 128: uint16(25226), + 129: uint16(25212), + 130: uint16(25214), + 131: uint16(25209), + 132: uint16(25203), + 133: uint16(25234), + 134: uint16(25199), + 135: uint16(25240), + 136: uint16(25198), + 137: uint16(25237), + 138: uint16(25235), + 139: uint16(25233), + 140: uint16(25222), + 141: uint16(25913), + 142: uint16(25915), + 143: uint16(25912), + 144: uint16(26097), + 145: uint16(26356), + 146: uint16(26463), + 147: uint16(26446), + 148: uint16(26447), + 149: uint16(26448), + 150: uint16(26449), + 151: uint16(26460), + 152: uint16(26454), + 153: uint16(26462), + 154: uint16(26441), + 155: uint16(26438), + 156: uint16(26464), + }, + 7: { + 0: uint16(26451), + 1: uint16(26455), + 2: uint16(27493), + 3: uint16(27599), + 4: uint16(27714), + 5: uint16(27742), + 6: uint16(27801), + 7: uint16(27777), + 8: uint16(27784), + 9: uint16(27785), + 10: uint16(27781), + 11: uint16(27803), + 12: uint16(27754), + 13: uint16(27770), + 14: uint16(27792), + 15: uint16(27760), + 16: uint16(27788), + 17: uint16(27752), + 18: uint16(27798), + 19: uint16(27794), + 20: uint16(27773), + 21: uint16(27779), + 22: uint16(27762), + 23: uint16(27774), + 24: uint16(27764), + 25: uint16(27782), + 26: uint16(27766), + 27: uint16(27789), + 28: uint16(27796), + 29: uint16(27800), + 30: uint16(27778), + 31: uint16(28790), + 32: uint16(28796), + 33: uint16(28797), + 34: uint16(28792), + 35: uint16(29282), + 36: uint16(29281), + 37: uint16(29280), + 38: uint16(29380), + 39: uint16(29378), + 40: uint16(29590), + 41: uint16(29996), + 42: uint16(29995), + 43: uint16(30007), + 44: uint16(30008), + 45: uint16(30338), + 46: uint16(30447), + 47: uint16(30691), + 48: uint16(31169), + 49: uint16(31168), + 50: uint16(31167), + 51: uint16(31350), + 52: uint16(31995), + 53: uint16(32597), + 54: uint16(32918), + 55: uint16(32915), + 56: uint16(32925), + 57: uint16(32920), + 58: uint16(32923), + 59: uint16(32922), + 60: uint16(32946), + 61: uint16(33391), + 62: uint16(33426), + 63: uint16(33419), + 64: uint16(33421), + 65: uint16(35211), + 66: uint16(35282), + 67: uint16(35328), + 68: uint16(35895), + 69: uint16(35910), + 70: uint16(35925), + 71: uint16(35997), + 72: uint16(36196), + 73: uint16(36208), + 74: uint16(36275), + 75: uint16(36523), + 76: uint16(36554), + 77: uint16(36763), + 78: uint16(36784), + 79: uint16(36802), + 80: uint16(36806), + 81: uint16(36805), + 82: uint16(36804), + 83: uint16(24033), + 84: uint16(37009), + 85: uint16(37026), + 86: uint16(37034), + 87: uint16(37030), + 88: uint16(37027), + 89: uint16(37193), + 90: uint16(37318), + 91: uint16(37324), + 92: uint16(38450), + 93: uint16(38446), + 94: uint16(38449), + 95: uint16(38442), + 96: uint16(38444), + 97: uint16(20006), + 98: uint16(20054), + 99: uint16(20083), + 100: uint16(20107), + 101: uint16(20123), + 102: uint16(20126), + 103: uint16(20139), + 104: uint16(20140), + 105: uint16(20335), + 106: uint16(20381), + 107: uint16(20365), + 108: uint16(20339), + 109: uint16(20351), + 110: uint16(20332), + 111: uint16(20379), + 112: uint16(20363), + 113: uint16(20358), + 114: uint16(20355), + 115: uint16(20336), + 116: uint16(20341), + 117: uint16(20360), + 118: uint16(20329), + 119: uint16(20347), + 120: uint16(20374), + 121: uint16(20350), + 122: uint16(20367), + 123: uint16(20369), + 124: uint16(20346), + 125: uint16(20820), + 126: uint16(20818), + 127: uint16(20821), + 128: uint16(20841), + 129: uint16(20855), + 130: uint16(20854), + 131: uint16(20856), + 132: uint16(20925), + 133: uint16(20989), + 134: uint16(21051), + 135: uint16(21048), + 136: uint16(21047), + 137: uint16(21050), + 138: uint16(21040), + 139: uint16(21038), + 140: uint16(21046), + 141: uint16(21057), + 142: uint16(21182), + 143: uint16(21179), + 144: uint16(21330), + 145: uint16(21332), + 146: uint16(21331), + 147: uint16(21329), + 148: uint16(21350), + 149: uint16(21367), + 150: uint16(21368), + 151: uint16(21369), + 152: uint16(21462), + 153: uint16(21460), + 154: uint16(21463), + 155: uint16(21619), + 156: uint16(21621), + }, + 8: { + 0: uint16(21654), + 1: uint16(21624), + 2: uint16(21653), + 3: uint16(21632), + 4: uint16(21627), + 5: uint16(21623), + 6: uint16(21636), + 7: uint16(21650), + 8: uint16(21638), + 9: uint16(21628), + 10: uint16(21648), + 11: uint16(21617), + 12: uint16(21622), + 13: uint16(21644), + 14: uint16(21658), + 15: uint16(21602), + 16: uint16(21608), + 17: uint16(21643), + 18: uint16(21629), + 19: uint16(21646), + 20: uint16(22266), + 21: uint16(22403), + 22: uint16(22391), + 23: uint16(22378), + 24: uint16(22377), + 25: uint16(22369), + 26: uint16(22374), + 27: uint16(22372), + 28: uint16(22396), + 29: uint16(22812), + 30: uint16(22857), + 31: uint16(22855), + 32: uint16(22856), + 33: uint16(22852), + 34: uint16(22868), + 35: uint16(22974), + 36: uint16(22971), + 37: uint16(22996), + 38: uint16(22969), + 39: uint16(22958), + 40: uint16(22993), + 41: uint16(22982), + 42: uint16(22992), + 43: uint16(22989), + 44: uint16(22987), + 45: uint16(22995), + 46: uint16(22986), + 47: uint16(22959), + 48: uint16(22963), + 49: uint16(22994), + 50: uint16(22981), + 51: uint16(23391), + 52: uint16(23396), + 53: uint16(23395), + 54: uint16(23447), + 55: uint16(23450), + 56: uint16(23448), + 57: uint16(23452), + 58: uint16(23449), + 59: uint16(23451), + 60: uint16(23578), + 61: uint16(23624), + 62: uint16(23621), + 63: uint16(23622), + 64: uint16(23735), + 65: uint16(23713), + 66: uint16(23736), + 67: uint16(23721), + 68: uint16(23723), + 69: uint16(23729), + 70: uint16(23731), + 71: uint16(24088), + 72: uint16(24090), + 73: uint16(24086), + 74: uint16(24085), + 75: uint16(24091), + 76: uint16(24081), + 77: uint16(24184), + 78: uint16(24218), + 79: uint16(24215), + 80: uint16(24220), + 81: uint16(24213), + 82: uint16(24214), + 83: uint16(24310), + 84: uint16(24358), + 85: uint16(24359), + 86: uint16(24361), + 87: uint16(24448), + 88: uint16(24449), + 89: uint16(24447), + 90: uint16(24444), + 91: uint16(24541), + 92: uint16(24544), + 93: uint16(24573), + 94: uint16(24565), + 95: uint16(24575), + 96: uint16(24591), + 97: uint16(24596), + 98: uint16(24623), + 99: uint16(24629), + 100: uint16(24598), + 101: uint16(24618), + 102: uint16(24597), + 103: uint16(24609), + 104: uint16(24615), + 105: uint16(24617), + 106: uint16(24619), + 107: uint16(24603), + 108: uint16(25110), + 109: uint16(25109), + 110: uint16(25151), + 111: uint16(25150), + 112: uint16(25152), + 113: uint16(25215), + 114: uint16(25289), + 115: uint16(25292), + 116: uint16(25284), + 117: uint16(25279), + 118: uint16(25282), + 119: uint16(25273), + 120: uint16(25298), + 121: uint16(25307), + 122: uint16(25259), + 123: uint16(25299), + 124: uint16(25300), + 125: uint16(25291), + 126: uint16(25288), + 127: uint16(25256), + 128: uint16(25277), + 129: uint16(25276), + 130: uint16(25296), + 131: uint16(25305), + 132: uint16(25287), + 133: uint16(25293), + 134: uint16(25269), + 135: uint16(25306), + 136: uint16(25265), + 137: uint16(25304), + 138: uint16(25302), + 139: uint16(25303), + 140: uint16(25286), + 141: uint16(25260), + 142: uint16(25294), + 143: uint16(25918), + 144: uint16(26023), + 145: uint16(26044), + 146: uint16(26106), + 147: uint16(26132), + 148: uint16(26131), + 149: uint16(26124), + 150: uint16(26118), + 151: uint16(26114), + 152: uint16(26126), + 153: uint16(26112), + 154: uint16(26127), + 155: uint16(26133), + 156: uint16(26122), + }, + 9: { + 0: uint16(26119), + 1: uint16(26381), + 2: uint16(26379), + 3: uint16(26477), + 4: uint16(26507), + 5: uint16(26517), + 6: uint16(26481), + 7: uint16(26524), + 8: uint16(26483), + 9: uint16(26487), + 10: uint16(26503), + 11: uint16(26525), + 12: uint16(26519), + 13: uint16(26479), + 14: uint16(26480), + 15: uint16(26495), + 16: uint16(26505), + 17: uint16(26494), + 18: uint16(26512), + 19: uint16(26485), + 20: uint16(26522), + 21: uint16(26515), + 22: uint16(26492), + 23: uint16(26474), + 24: uint16(26482), + 25: uint16(27427), + 26: uint16(27494), + 27: uint16(27495), + 28: uint16(27519), + 29: uint16(27667), + 30: uint16(27675), + 31: uint16(27875), + 32: uint16(27880), + 33: uint16(27891), + 34: uint16(27825), + 35: uint16(27852), + 36: uint16(27877), + 37: uint16(27827), + 38: uint16(27837), + 39: uint16(27838), + 40: uint16(27836), + 41: uint16(27874), + 42: uint16(27819), + 43: uint16(27861), + 44: uint16(27859), + 45: uint16(27832), + 46: uint16(27844), + 47: uint16(27833), + 48: uint16(27841), + 49: uint16(27822), + 50: uint16(27863), + 51: uint16(27845), + 52: uint16(27889), + 53: uint16(27839), + 54: uint16(27835), + 55: uint16(27873), + 56: uint16(27867), + 57: uint16(27850), + 58: uint16(27820), + 59: uint16(27887), + 60: uint16(27868), + 61: uint16(27862), + 62: uint16(27872), + 63: uint16(28821), + 64: uint16(28814), + 65: uint16(28818), + 66: uint16(28810), + 67: uint16(28825), + 68: uint16(29228), + 69: uint16(29229), + 70: uint16(29240), + 71: uint16(29256), + 72: uint16(29287), + 73: uint16(29289), + 74: uint16(29376), + 75: uint16(29390), + 76: uint16(29401), + 77: uint16(29399), + 78: uint16(29392), + 79: uint16(29609), + 80: uint16(29608), + 81: uint16(29599), + 82: uint16(29611), + 83: uint16(29605), + 84: uint16(30013), + 85: uint16(30109), + 86: uint16(30105), + 87: uint16(30106), + 88: uint16(30340), + 89: uint16(30402), + 90: uint16(30450), + 91: uint16(30452), + 92: uint16(30693), + 93: uint16(30717), + 94: uint16(31038), + 95: uint16(31040), + 96: uint16(31041), + 97: uint16(31177), + 98: uint16(31176), + 99: uint16(31354), + 100: uint16(31353), + 101: uint16(31482), + 102: uint16(31998), + 103: uint16(32596), + 104: uint16(32652), + 105: uint16(32651), + 106: uint16(32773), + 107: uint16(32954), + 108: uint16(32933), + 109: uint16(32930), + 110: uint16(32945), + 111: uint16(32929), + 112: uint16(32939), + 113: uint16(32937), + 114: uint16(32948), + 115: uint16(32938), + 116: uint16(32943), + 117: uint16(33253), + 118: uint16(33278), + 119: uint16(33293), + 120: uint16(33459), + 121: uint16(33437), + 122: uint16(33433), + 123: uint16(33453), + 124: uint16(33469), + 125: uint16(33439), + 126: uint16(33465), + 127: uint16(33457), + 128: uint16(33452), + 129: uint16(33445), + 130: uint16(33455), + 131: uint16(33464), + 132: uint16(33443), + 133: uint16(33456), + 134: uint16(33470), + 135: uint16(33463), + 136: uint16(34382), + 137: uint16(34417), + 138: uint16(21021), + 139: uint16(34920), + 140: uint16(36555), + 141: uint16(36814), + 142: uint16(36820), + 143: uint16(36817), + 144: uint16(37045), + 145: uint16(37048), + 146: uint16(37041), + 147: uint16(37046), + 148: uint16(37319), + 149: uint16(37329), + 150: uint16(38263), + 151: uint16(38272), + 152: uint16(38428), + 153: uint16(38464), + 154: uint16(38463), + 155: uint16(38459), + 156: uint16(38468), + }, + 10: { + 0: uint16(38466), + 1: uint16(38585), + 2: uint16(38632), + 3: uint16(38738), + 4: uint16(38750), + 5: uint16(20127), + 6: uint16(20141), + 7: uint16(20142), + 8: uint16(20449), + 9: uint16(20405), + 10: uint16(20399), + 11: uint16(20415), + 12: uint16(20448), + 13: uint16(20433), + 14: uint16(20431), + 15: uint16(20445), + 16: uint16(20419), + 17: uint16(20406), + 18: uint16(20440), + 19: uint16(20447), + 20: uint16(20426), + 21: uint16(20439), + 22: uint16(20398), + 23: uint16(20432), + 24: uint16(20420), + 25: uint16(20418), + 26: uint16(20442), + 27: uint16(20430), + 28: uint16(20446), + 29: uint16(20407), + 30: uint16(20823), + 31: uint16(20882), + 32: uint16(20881), + 33: uint16(20896), + 34: uint16(21070), + 35: uint16(21059), + 36: uint16(21066), + 37: uint16(21069), + 38: uint16(21068), + 39: uint16(21067), + 40: uint16(21063), + 41: uint16(21191), + 42: uint16(21193), + 43: uint16(21187), + 44: uint16(21185), + 45: uint16(21261), + 46: uint16(21335), + 47: uint16(21371), + 48: uint16(21402), + 49: uint16(21467), + 50: uint16(21676), + 51: uint16(21696), + 52: uint16(21672), + 53: uint16(21710), + 54: uint16(21705), + 55: uint16(21688), + 56: uint16(21670), + 57: uint16(21683), + 58: uint16(21703), + 59: uint16(21698), + 60: uint16(21693), + 61: uint16(21674), + 62: uint16(21697), + 63: uint16(21700), + 64: uint16(21704), + 65: uint16(21679), + 66: uint16(21675), + 67: uint16(21681), + 68: uint16(21691), + 69: uint16(21673), + 70: uint16(21671), + 71: uint16(21695), + 72: uint16(22271), + 73: uint16(22402), + 74: uint16(22411), + 75: uint16(22432), + 76: uint16(22435), + 77: uint16(22434), + 78: uint16(22478), + 79: uint16(22446), + 80: uint16(22419), + 81: uint16(22869), + 82: uint16(22865), + 83: uint16(22863), + 84: uint16(22862), + 85: uint16(22864), + 86: uint16(23004), + 87: uint16(23000), + 88: uint16(23039), + 89: uint16(23011), + 90: uint16(23016), + 91: uint16(23043), + 92: uint16(23013), + 93: uint16(23018), + 94: uint16(23002), + 95: uint16(23014), + 96: uint16(23041), + 97: uint16(23035), + 98: uint16(23401), + 99: uint16(23459), + 100: uint16(23462), + 101: uint16(23460), + 102: uint16(23458), + 103: uint16(23461), + 104: uint16(23553), + 105: uint16(23630), + 106: uint16(23631), + 107: uint16(23629), + 108: uint16(23627), + 109: uint16(23769), + 110: uint16(23762), + 111: uint16(24055), + 112: uint16(24093), + 113: uint16(24101), + 114: uint16(24095), + 115: uint16(24189), + 116: uint16(24224), + 117: uint16(24230), + 118: uint16(24314), + 119: uint16(24328), + 120: uint16(24365), + 121: uint16(24421), + 122: uint16(24456), + 123: uint16(24453), + 124: uint16(24458), + 125: uint16(24459), + 126: uint16(24455), + 127: uint16(24460), + 128: uint16(24457), + 129: uint16(24594), + 130: uint16(24605), + 131: uint16(24608), + 132: uint16(24613), + 133: uint16(24590), + 134: uint16(24616), + 135: uint16(24653), + 136: uint16(24688), + 137: uint16(24680), + 138: uint16(24674), + 139: uint16(24646), + 140: uint16(24643), + 141: uint16(24684), + 142: uint16(24683), + 143: uint16(24682), + 144: uint16(24676), + 145: uint16(25153), + 146: uint16(25308), + 147: uint16(25366), + 148: uint16(25353), + 149: uint16(25340), + 150: uint16(25325), + 151: uint16(25345), + 152: uint16(25326), + 153: uint16(25341), + 154: uint16(25351), + 155: uint16(25329), + 156: uint16(25335), + }, + 11: { + 0: uint16(25327), + 1: uint16(25324), + 2: uint16(25342), + 3: uint16(25332), + 4: uint16(25361), + 5: uint16(25346), + 6: uint16(25919), + 7: uint16(25925), + 8: uint16(26027), + 9: uint16(26045), + 10: uint16(26082), + 11: uint16(26149), + 12: uint16(26157), + 13: uint16(26144), + 14: uint16(26151), + 15: uint16(26159), + 16: uint16(26143), + 17: uint16(26152), + 18: uint16(26161), + 19: uint16(26148), + 20: uint16(26359), + 21: uint16(26623), + 22: uint16(26579), + 23: uint16(26609), + 24: uint16(26580), + 25: uint16(26576), + 26: uint16(26604), + 27: uint16(26550), + 28: uint16(26543), + 29: uint16(26613), + 30: uint16(26601), + 31: uint16(26607), + 32: uint16(26564), + 33: uint16(26577), + 34: uint16(26548), + 35: uint16(26586), + 36: uint16(26597), + 37: uint16(26552), + 38: uint16(26575), + 39: uint16(26590), + 40: uint16(26611), + 41: uint16(26544), + 42: uint16(26585), + 43: uint16(26594), + 44: uint16(26589), + 45: uint16(26578), + 46: uint16(27498), + 47: uint16(27523), + 48: uint16(27526), + 49: uint16(27573), + 50: uint16(27602), + 51: uint16(27607), + 52: uint16(27679), + 53: uint16(27849), + 54: uint16(27915), + 55: uint16(27954), + 56: uint16(27946), + 57: uint16(27969), + 58: uint16(27941), + 59: uint16(27916), + 60: uint16(27953), + 61: uint16(27934), + 62: uint16(27927), + 63: uint16(27963), + 64: uint16(27965), + 65: uint16(27966), + 66: uint16(27958), + 67: uint16(27931), + 68: uint16(27893), + 69: uint16(27961), + 70: uint16(27943), + 71: uint16(27960), + 72: uint16(27945), + 73: uint16(27950), + 74: uint16(27957), + 75: uint16(27918), + 76: uint16(27947), + 77: uint16(28843), + 78: uint16(28858), + 79: uint16(28851), + 80: uint16(28844), + 81: uint16(28847), + 82: uint16(28845), + 83: uint16(28856), + 84: uint16(28846), + 85: uint16(28836), + 86: uint16(29232), + 87: uint16(29298), + 88: uint16(29295), + 89: uint16(29300), + 90: uint16(29417), + 91: uint16(29408), + 92: uint16(29409), + 93: uint16(29623), + 94: uint16(29642), + 95: uint16(29627), + 96: uint16(29618), + 97: uint16(29645), + 98: uint16(29632), + 99: uint16(29619), + 100: uint16(29978), + 101: uint16(29997), + 102: uint16(30031), + 103: uint16(30028), + 104: uint16(30030), + 105: uint16(30027), + 106: uint16(30123), + 107: uint16(30116), + 108: uint16(30117), + 109: uint16(30114), + 110: uint16(30115), + 111: uint16(30328), + 112: uint16(30342), + 113: uint16(30343), + 114: uint16(30344), + 115: uint16(30408), + 116: uint16(30406), + 117: uint16(30403), + 118: uint16(30405), + 119: uint16(30465), + 120: uint16(30457), + 121: uint16(30456), + 122: uint16(30473), + 123: uint16(30475), + 124: uint16(30462), + 125: uint16(30460), + 126: uint16(30471), + 127: uint16(30684), + 128: uint16(30722), + 129: uint16(30740), + 130: uint16(30732), + 131: uint16(30733), + 132: uint16(31046), + 133: uint16(31049), + 134: uint16(31048), + 135: uint16(31047), + 136: uint16(31161), + 137: uint16(31162), + 138: uint16(31185), + 139: uint16(31186), + 140: uint16(31179), + 141: uint16(31359), + 142: uint16(31361), + 143: uint16(31487), + 144: uint16(31485), + 145: uint16(31869), + 146: uint16(32002), + 147: uint16(32005), + 148: uint16(32000), + 149: uint16(32009), + 150: uint16(32007), + 151: uint16(32004), + 152: uint16(32006), + 153: uint16(32568), + 154: uint16(32654), + 155: uint16(32703), + 156: uint16(32772), + }, + 12: { + 0: uint16(32784), + 1: uint16(32781), + 2: uint16(32785), + 3: uint16(32822), + 4: uint16(32982), + 5: uint16(32997), + 6: uint16(32986), + 7: uint16(32963), + 8: uint16(32964), + 9: uint16(32972), + 10: uint16(32993), + 11: uint16(32987), + 12: uint16(32974), + 13: uint16(32990), + 14: uint16(32996), + 15: uint16(32989), + 16: uint16(33268), + 17: uint16(33314), + 18: uint16(33511), + 19: uint16(33539), + 20: uint16(33541), + 21: uint16(33507), + 22: uint16(33499), + 23: uint16(33510), + 24: uint16(33540), + 25: uint16(33509), + 26: uint16(33538), + 27: uint16(33545), + 28: uint16(33490), + 29: uint16(33495), + 30: uint16(33521), + 31: uint16(33537), + 32: uint16(33500), + 33: uint16(33492), + 34: uint16(33489), + 35: uint16(33502), + 36: uint16(33491), + 37: uint16(33503), + 38: uint16(33519), + 39: uint16(33542), + 40: uint16(34384), + 41: uint16(34425), + 42: uint16(34427), + 43: uint16(34426), + 44: uint16(34893), + 45: uint16(34923), + 46: uint16(35201), + 47: uint16(35284), + 48: uint16(35336), + 49: uint16(35330), + 50: uint16(35331), + 51: uint16(35998), + 52: uint16(36000), + 53: uint16(36212), + 54: uint16(36211), + 55: uint16(36276), + 56: uint16(36557), + 57: uint16(36556), + 58: uint16(36848), + 59: uint16(36838), + 60: uint16(36834), + 61: uint16(36842), + 62: uint16(36837), + 63: uint16(36845), + 64: uint16(36843), + 65: uint16(36836), + 66: uint16(36840), + 67: uint16(37066), + 68: uint16(37070), + 69: uint16(37057), + 70: uint16(37059), + 71: uint16(37195), + 72: uint16(37194), + 73: uint16(37325), + 74: uint16(38274), + 75: uint16(38480), + 76: uint16(38475), + 77: uint16(38476), + 78: uint16(38477), + 79: uint16(38754), + 80: uint16(38761), + 81: uint16(38859), + 82: uint16(38893), + 83: uint16(38899), + 84: uint16(38913), + 85: uint16(39080), + 86: uint16(39131), + 87: uint16(39135), + 88: uint16(39318), + 89: uint16(39321), + 90: uint16(20056), + 91: uint16(20147), + 92: uint16(20492), + 93: uint16(20493), + 94: uint16(20515), + 95: uint16(20463), + 96: uint16(20518), + 97: uint16(20517), + 98: uint16(20472), + 99: uint16(20521), + 100: uint16(20502), + 101: uint16(20486), + 102: uint16(20540), + 103: uint16(20511), + 104: uint16(20506), + 105: uint16(20498), + 106: uint16(20497), + 107: uint16(20474), + 108: uint16(20480), + 109: uint16(20500), + 110: uint16(20520), + 111: uint16(20465), + 112: uint16(20513), + 113: uint16(20491), + 114: uint16(20505), + 115: uint16(20504), + 116: uint16(20467), + 117: uint16(20462), + 118: uint16(20525), + 119: uint16(20522), + 120: uint16(20478), + 121: uint16(20523), + 122: uint16(20489), + 123: uint16(20860), + 124: uint16(20900), + 125: uint16(20901), + 126: uint16(20898), + 127: uint16(20941), + 128: uint16(20940), + 129: uint16(20934), + 130: uint16(20939), + 131: uint16(21078), + 132: uint16(21084), + 133: uint16(21076), + 134: uint16(21083), + 135: uint16(21085), + 136: uint16(21290), + 137: uint16(21375), + 138: uint16(21407), + 139: uint16(21405), + 140: uint16(21471), + 141: uint16(21736), + 142: uint16(21776), + 143: uint16(21761), + 144: uint16(21815), + 145: uint16(21756), + 146: uint16(21733), + 147: uint16(21746), + 148: uint16(21766), + 149: uint16(21754), + 150: uint16(21780), + 151: uint16(21737), + 152: uint16(21741), + 153: uint16(21729), + 154: uint16(21769), + 155: uint16(21742), + 156: uint16(21738), + }, + 13: { + 0: uint16(21734), + 1: uint16(21799), + 2: uint16(21767), + 3: uint16(21757), + 4: uint16(21775), + 5: uint16(22275), + 6: uint16(22276), + 7: uint16(22466), + 8: uint16(22484), + 9: uint16(22475), + 10: uint16(22467), + 11: uint16(22537), + 12: uint16(22799), + 13: uint16(22871), + 14: uint16(22872), + 15: uint16(22874), + 16: uint16(23057), + 17: uint16(23064), + 18: uint16(23068), + 19: uint16(23071), + 20: uint16(23067), + 21: uint16(23059), + 22: uint16(23020), + 23: uint16(23072), + 24: uint16(23075), + 25: uint16(23081), + 26: uint16(23077), + 27: uint16(23052), + 28: uint16(23049), + 29: uint16(23403), + 30: uint16(23640), + 31: uint16(23472), + 32: uint16(23475), + 33: uint16(23478), + 34: uint16(23476), + 35: uint16(23470), + 36: uint16(23477), + 37: uint16(23481), + 38: uint16(23480), + 39: uint16(23556), + 40: uint16(23633), + 41: uint16(23637), + 42: uint16(23632), + 43: uint16(23789), + 44: uint16(23805), + 45: uint16(23803), + 46: uint16(23786), + 47: uint16(23784), + 48: uint16(23792), + 49: uint16(23798), + 50: uint16(23809), + 51: uint16(23796), + 52: uint16(24046), + 53: uint16(24109), + 54: uint16(24107), + 55: uint16(24235), + 56: uint16(24237), + 57: uint16(24231), + 58: uint16(24369), + 59: uint16(24466), + 60: uint16(24465), + 61: uint16(24464), + 62: uint16(24665), + 63: uint16(24675), + 64: uint16(24677), + 65: uint16(24656), + 66: uint16(24661), + 67: uint16(24685), + 68: uint16(24681), + 69: uint16(24687), + 70: uint16(24708), + 71: uint16(24735), + 72: uint16(24730), + 73: uint16(24717), + 74: uint16(24724), + 75: uint16(24716), + 76: uint16(24709), + 77: uint16(24726), + 78: uint16(25159), + 79: uint16(25331), + 80: uint16(25352), + 81: uint16(25343), + 82: uint16(25422), + 83: uint16(25406), + 84: uint16(25391), + 85: uint16(25429), + 86: uint16(25410), + 87: uint16(25414), + 88: uint16(25423), + 89: uint16(25417), + 90: uint16(25402), + 91: uint16(25424), + 92: uint16(25405), + 93: uint16(25386), + 94: uint16(25387), + 95: uint16(25384), + 96: uint16(25421), + 97: uint16(25420), + 98: uint16(25928), + 99: uint16(25929), + 100: uint16(26009), + 101: uint16(26049), + 102: uint16(26053), + 103: uint16(26178), + 104: uint16(26185), + 105: uint16(26191), + 106: uint16(26179), + 107: uint16(26194), + 108: uint16(26188), + 109: uint16(26181), + 110: uint16(26177), + 111: uint16(26360), + 112: uint16(26388), + 113: uint16(26389), + 114: uint16(26391), + 115: uint16(26657), + 116: uint16(26680), + 117: uint16(26696), + 118: uint16(26694), + 119: uint16(26707), + 120: uint16(26681), + 121: uint16(26690), + 122: uint16(26708), + 123: uint16(26665), + 124: uint16(26803), + 125: uint16(26647), + 126: uint16(26700), + 127: uint16(26705), + 128: uint16(26685), + 129: uint16(26612), + 130: uint16(26704), + 131: uint16(26688), + 132: uint16(26684), + 133: uint16(26691), + 134: uint16(26666), + 135: uint16(26693), + 136: uint16(26643), + 137: uint16(26648), + 138: uint16(26689), + 139: uint16(27530), + 140: uint16(27529), + 141: uint16(27575), + 142: uint16(27683), + 143: uint16(27687), + 144: uint16(27688), + 145: uint16(27686), + 146: uint16(27684), + 147: uint16(27888), + 148: uint16(28010), + 149: uint16(28053), + 150: uint16(28040), + 151: uint16(28039), + 152: uint16(28006), + 153: uint16(28024), + 154: uint16(28023), + 155: uint16(27993), + 156: uint16(28051), + }, + 14: { + 0: uint16(28012), + 1: uint16(28041), + 2: uint16(28014), + 3: uint16(27994), + 4: uint16(28020), + 5: uint16(28009), + 6: uint16(28044), + 7: uint16(28042), + 8: uint16(28025), + 9: uint16(28037), + 10: uint16(28005), + 11: uint16(28052), + 12: uint16(28874), + 13: uint16(28888), + 14: uint16(28900), + 15: uint16(28889), + 16: uint16(28872), + 17: uint16(28879), + 18: uint16(29241), + 19: uint16(29305), + 20: uint16(29436), + 21: uint16(29433), + 22: uint16(29437), + 23: uint16(29432), + 24: uint16(29431), + 25: uint16(29574), + 26: uint16(29677), + 27: uint16(29705), + 28: uint16(29678), + 29: uint16(29664), + 30: uint16(29674), + 31: uint16(29662), + 32: uint16(30036), + 33: uint16(30045), + 34: uint16(30044), + 35: uint16(30042), + 36: uint16(30041), + 37: uint16(30142), + 38: uint16(30149), + 39: uint16(30151), + 40: uint16(30130), + 41: uint16(30131), + 42: uint16(30141), + 43: uint16(30140), + 44: uint16(30137), + 45: uint16(30146), + 46: uint16(30136), + 47: uint16(30347), + 48: uint16(30384), + 49: uint16(30410), + 50: uint16(30413), + 51: uint16(30414), + 52: uint16(30505), + 53: uint16(30495), + 54: uint16(30496), + 55: uint16(30504), + 56: uint16(30697), + 57: uint16(30768), + 58: uint16(30759), + 59: uint16(30776), + 60: uint16(30749), + 61: uint16(30772), + 62: uint16(30775), + 63: uint16(30757), + 64: uint16(30765), + 65: uint16(30752), + 66: uint16(30751), + 67: uint16(30770), + 68: uint16(31061), + 69: uint16(31056), + 70: uint16(31072), + 71: uint16(31071), + 72: uint16(31062), + 73: uint16(31070), + 74: uint16(31069), + 75: uint16(31063), + 76: uint16(31066), + 77: uint16(31204), + 78: uint16(31203), + 79: uint16(31207), + 80: uint16(31199), + 81: uint16(31206), + 82: uint16(31209), + 83: uint16(31192), + 84: uint16(31364), + 85: uint16(31368), + 86: uint16(31449), + 87: uint16(31494), + 88: uint16(31505), + 89: uint16(31881), + 90: uint16(32033), + 91: uint16(32023), + 92: uint16(32011), + 93: uint16(32010), + 94: uint16(32032), + 95: uint16(32034), + 96: uint16(32020), + 97: uint16(32016), + 98: uint16(32021), + 99: uint16(32026), + 100: uint16(32028), + 101: uint16(32013), + 102: uint16(32025), + 103: uint16(32027), + 104: uint16(32570), + 105: uint16(32607), + 106: uint16(32660), + 107: uint16(32709), + 108: uint16(32705), + 109: uint16(32774), + 110: uint16(32792), + 111: uint16(32789), + 112: uint16(32793), + 113: uint16(32791), + 114: uint16(32829), + 115: uint16(32831), + 116: uint16(33009), + 117: uint16(33026), + 118: uint16(33008), + 119: uint16(33029), + 120: uint16(33005), + 121: uint16(33012), + 122: uint16(33030), + 123: uint16(33016), + 124: uint16(33011), + 125: uint16(33032), + 126: uint16(33021), + 127: uint16(33034), + 128: uint16(33020), + 129: uint16(33007), + 130: uint16(33261), + 131: uint16(33260), + 132: uint16(33280), + 133: uint16(33296), + 134: uint16(33322), + 135: uint16(33323), + 136: uint16(33320), + 137: uint16(33324), + 138: uint16(33467), + 139: uint16(33579), + 140: uint16(33618), + 141: uint16(33620), + 142: uint16(33610), + 143: uint16(33592), + 144: uint16(33616), + 145: uint16(33609), + 146: uint16(33589), + 147: uint16(33588), + 148: uint16(33615), + 149: uint16(33586), + 150: uint16(33593), + 151: uint16(33590), + 152: uint16(33559), + 153: uint16(33600), + 154: uint16(33585), + 155: uint16(33576), + 156: uint16(33603), + }, + 15: { + 0: uint16(34388), + 1: uint16(34442), + 2: uint16(34474), + 3: uint16(34451), + 4: uint16(34468), + 5: uint16(34473), + 6: uint16(34444), + 7: uint16(34467), + 8: uint16(34460), + 9: uint16(34928), + 10: uint16(34935), + 11: uint16(34945), + 12: uint16(34946), + 13: uint16(34941), + 14: uint16(34937), + 15: uint16(35352), + 16: uint16(35344), + 17: uint16(35342), + 18: uint16(35340), + 19: uint16(35349), + 20: uint16(35338), + 21: uint16(35351), + 22: uint16(35347), + 23: uint16(35350), + 24: uint16(35343), + 25: uint16(35345), + 26: uint16(35912), + 27: uint16(35962), + 28: uint16(35961), + 29: uint16(36001), + 30: uint16(36002), + 31: uint16(36215), + 32: uint16(36524), + 33: uint16(36562), + 34: uint16(36564), + 35: uint16(36559), + 36: uint16(36785), + 37: uint16(36865), + 38: uint16(36870), + 39: uint16(36855), + 40: uint16(36864), + 41: uint16(36858), + 42: uint16(36852), + 43: uint16(36867), + 44: uint16(36861), + 45: uint16(36869), + 46: uint16(36856), + 47: uint16(37013), + 48: uint16(37089), + 49: uint16(37085), + 50: uint16(37090), + 51: uint16(37202), + 52: uint16(37197), + 53: uint16(37196), + 54: uint16(37336), + 55: uint16(37341), + 56: uint16(37335), + 57: uint16(37340), + 58: uint16(37337), + 59: uint16(38275), + 60: uint16(38498), + 61: uint16(38499), + 62: uint16(38497), + 63: uint16(38491), + 64: uint16(38493), + 65: uint16(38500), + 66: uint16(38488), + 67: uint16(38494), + 68: uint16(38587), + 69: uint16(39138), + 70: uint16(39340), + 71: uint16(39592), + 72: uint16(39640), + 73: uint16(39717), + 74: uint16(39730), + 75: uint16(39740), + 76: uint16(20094), + 77: uint16(20602), + 78: uint16(20605), + 79: uint16(20572), + 80: uint16(20551), + 81: uint16(20547), + 82: uint16(20556), + 83: uint16(20570), + 84: uint16(20553), + 85: uint16(20581), + 86: uint16(20598), + 87: uint16(20558), + 88: uint16(20565), + 89: uint16(20597), + 90: uint16(20596), + 91: uint16(20599), + 92: uint16(20559), + 93: uint16(20495), + 94: uint16(20591), + 95: uint16(20589), + 96: uint16(20828), + 97: uint16(20885), + 98: uint16(20976), + 99: uint16(21098), + 100: uint16(21103), + 101: uint16(21202), + 102: uint16(21209), + 103: uint16(21208), + 104: uint16(21205), + 105: uint16(21264), + 106: uint16(21263), + 107: uint16(21273), + 108: uint16(21311), + 109: uint16(21312), + 110: uint16(21310), + 111: uint16(21443), + 112: uint16(26364), + 113: uint16(21830), + 114: uint16(21866), + 115: uint16(21862), + 116: uint16(21828), + 117: uint16(21854), + 118: uint16(21857), + 119: uint16(21827), + 120: uint16(21834), + 121: uint16(21809), + 122: uint16(21846), + 123: uint16(21839), + 124: uint16(21845), + 125: uint16(21807), + 126: uint16(21860), + 127: uint16(21816), + 128: uint16(21806), + 129: uint16(21852), + 130: uint16(21804), + 131: uint16(21859), + 132: uint16(21811), + 133: uint16(21825), + 134: uint16(21847), + 135: uint16(22280), + 136: uint16(22283), + 137: uint16(22281), + 138: uint16(22495), + 139: uint16(22533), + 140: uint16(22538), + 141: uint16(22534), + 142: uint16(22496), + 143: uint16(22500), + 144: uint16(22522), + 145: uint16(22530), + 146: uint16(22581), + 147: uint16(22519), + 148: uint16(22521), + 149: uint16(22816), + 150: uint16(22882), + 151: uint16(23094), + 152: uint16(23105), + 153: uint16(23113), + 154: uint16(23142), + 155: uint16(23146), + 156: uint16(23104), + }, + 16: { + 0: uint16(23100), + 1: uint16(23138), + 2: uint16(23130), + 3: uint16(23110), + 4: uint16(23114), + 5: uint16(23408), + 6: uint16(23495), + 7: uint16(23493), + 8: uint16(23492), + 9: uint16(23490), + 10: uint16(23487), + 11: uint16(23494), + 12: uint16(23561), + 13: uint16(23560), + 14: uint16(23559), + 15: uint16(23648), + 16: uint16(23644), + 17: uint16(23645), + 18: uint16(23815), + 19: uint16(23814), + 20: uint16(23822), + 21: uint16(23835), + 22: uint16(23830), + 23: uint16(23842), + 24: uint16(23825), + 25: uint16(23849), + 26: uint16(23828), + 27: uint16(23833), + 28: uint16(23844), + 29: uint16(23847), + 30: uint16(23831), + 31: uint16(24034), + 32: uint16(24120), + 33: uint16(24118), + 34: uint16(24115), + 35: uint16(24119), + 36: uint16(24247), + 37: uint16(24248), + 38: uint16(24246), + 39: uint16(24245), + 40: uint16(24254), + 41: uint16(24373), + 42: uint16(24375), + 43: uint16(24407), + 44: uint16(24428), + 45: uint16(24425), + 46: uint16(24427), + 47: uint16(24471), + 48: uint16(24473), + 49: uint16(24478), + 50: uint16(24472), + 51: uint16(24481), + 52: uint16(24480), + 53: uint16(24476), + 54: uint16(24703), + 55: uint16(24739), + 56: uint16(24713), + 57: uint16(24736), + 58: uint16(24744), + 59: uint16(24779), + 60: uint16(24756), + 61: uint16(24806), + 62: uint16(24765), + 63: uint16(24773), + 64: uint16(24763), + 65: uint16(24757), + 66: uint16(24796), + 67: uint16(24764), + 68: uint16(24792), + 69: uint16(24789), + 70: uint16(24774), + 71: uint16(24799), + 72: uint16(24760), + 73: uint16(24794), + 74: uint16(24775), + 75: uint16(25114), + 76: uint16(25115), + 77: uint16(25160), + 78: uint16(25504), + 79: uint16(25511), + 80: uint16(25458), + 81: uint16(25494), + 82: uint16(25506), + 83: uint16(25509), + 84: uint16(25463), + 85: uint16(25447), + 86: uint16(25496), + 87: uint16(25514), + 88: uint16(25457), + 89: uint16(25513), + 90: uint16(25481), + 91: uint16(25475), + 92: uint16(25499), + 93: uint16(25451), + 94: uint16(25512), + 95: uint16(25476), + 96: uint16(25480), + 97: uint16(25497), + 98: uint16(25505), + 99: uint16(25516), + 100: uint16(25490), + 101: uint16(25487), + 102: uint16(25472), + 103: uint16(25467), + 104: uint16(25449), + 105: uint16(25448), + 106: uint16(25466), + 107: uint16(25949), + 108: uint16(25942), + 109: uint16(25937), + 110: uint16(25945), + 111: uint16(25943), + 112: uint16(21855), + 113: uint16(25935), + 114: uint16(25944), + 115: uint16(25941), + 116: uint16(25940), + 117: uint16(26012), + 118: uint16(26011), + 119: uint16(26028), + 120: uint16(26063), + 121: uint16(26059), + 122: uint16(26060), + 123: uint16(26062), + 124: uint16(26205), + 125: uint16(26202), + 126: uint16(26212), + 127: uint16(26216), + 128: uint16(26214), + 129: uint16(26206), + 130: uint16(26361), + 131: uint16(21207), + 132: uint16(26395), + 133: uint16(26753), + 134: uint16(26799), + 135: uint16(26786), + 136: uint16(26771), + 137: uint16(26805), + 138: uint16(26751), + 139: uint16(26742), + 140: uint16(26801), + 141: uint16(26791), + 142: uint16(26775), + 143: uint16(26800), + 144: uint16(26755), + 145: uint16(26820), + 146: uint16(26797), + 147: uint16(26758), + 148: uint16(26757), + 149: uint16(26772), + 150: uint16(26781), + 151: uint16(26792), + 152: uint16(26783), + 153: uint16(26785), + 154: uint16(26754), + 155: uint16(27442), + 156: uint16(27578), + }, + 17: { + 0: uint16(27627), + 1: uint16(27628), + 2: uint16(27691), + 3: uint16(28046), + 4: uint16(28092), + 5: uint16(28147), + 6: uint16(28121), + 7: uint16(28082), + 8: uint16(28129), + 9: uint16(28108), + 10: uint16(28132), + 11: uint16(28155), + 12: uint16(28154), + 13: uint16(28165), + 14: uint16(28103), + 15: uint16(28107), + 16: uint16(28079), + 17: uint16(28113), + 18: uint16(28078), + 19: uint16(28126), + 20: uint16(28153), + 21: uint16(28088), + 22: uint16(28151), + 23: uint16(28149), + 24: uint16(28101), + 25: uint16(28114), + 26: uint16(28186), + 27: uint16(28085), + 28: uint16(28122), + 29: uint16(28139), + 30: uint16(28120), + 31: uint16(28138), + 32: uint16(28145), + 33: uint16(28142), + 34: uint16(28136), + 35: uint16(28102), + 36: uint16(28100), + 37: uint16(28074), + 38: uint16(28140), + 39: uint16(28095), + 40: uint16(28134), + 41: uint16(28921), + 42: uint16(28937), + 43: uint16(28938), + 44: uint16(28925), + 45: uint16(28911), + 46: uint16(29245), + 47: uint16(29309), + 48: uint16(29313), + 49: uint16(29468), + 50: uint16(29467), + 51: uint16(29462), + 52: uint16(29459), + 53: uint16(29465), + 54: uint16(29575), + 55: uint16(29701), + 56: uint16(29706), + 57: uint16(29699), + 58: uint16(29702), + 59: uint16(29694), + 60: uint16(29709), + 61: uint16(29920), + 62: uint16(29942), + 63: uint16(29943), + 64: uint16(29980), + 65: uint16(29986), + 66: uint16(30053), + 67: uint16(30054), + 68: uint16(30050), + 69: uint16(30064), + 70: uint16(30095), + 71: uint16(30164), + 72: uint16(30165), + 73: uint16(30133), + 74: uint16(30154), + 75: uint16(30157), + 76: uint16(30350), + 77: uint16(30420), + 78: uint16(30418), + 79: uint16(30427), + 80: uint16(30519), + 81: uint16(30526), + 82: uint16(30524), + 83: uint16(30518), + 84: uint16(30520), + 85: uint16(30522), + 86: uint16(30827), + 87: uint16(30787), + 88: uint16(30798), + 89: uint16(31077), + 90: uint16(31080), + 91: uint16(31085), + 92: uint16(31227), + 93: uint16(31378), + 94: uint16(31381), + 95: uint16(31520), + 96: uint16(31528), + 97: uint16(31515), + 98: uint16(31532), + 99: uint16(31526), + 100: uint16(31513), + 101: uint16(31518), + 102: uint16(31534), + 103: uint16(31890), + 104: uint16(31895), + 105: uint16(31893), + 106: uint16(32070), + 107: uint16(32067), + 108: uint16(32113), + 109: uint16(32046), + 110: uint16(32057), + 111: uint16(32060), + 112: uint16(32064), + 113: uint16(32048), + 114: uint16(32051), + 115: uint16(32068), + 116: uint16(32047), + 117: uint16(32066), + 118: uint16(32050), + 119: uint16(32049), + 120: uint16(32573), + 121: uint16(32670), + 122: uint16(32666), + 123: uint16(32716), + 124: uint16(32718), + 125: uint16(32722), + 126: uint16(32796), + 127: uint16(32842), + 128: uint16(32838), + 129: uint16(33071), + 130: uint16(33046), + 131: uint16(33059), + 132: uint16(33067), + 133: uint16(33065), + 134: uint16(33072), + 135: uint16(33060), + 136: uint16(33282), + 137: uint16(33333), + 138: uint16(33335), + 139: uint16(33334), + 140: uint16(33337), + 141: uint16(33678), + 142: uint16(33694), + 143: uint16(33688), + 144: uint16(33656), + 145: uint16(33698), + 146: uint16(33686), + 147: uint16(33725), + 148: uint16(33707), + 149: uint16(33682), + 150: uint16(33674), + 151: uint16(33683), + 152: uint16(33673), + 153: uint16(33696), + 154: uint16(33655), + 155: uint16(33659), + 156: uint16(33660), + }, + 18: { + 0: uint16(33670), + 1: uint16(33703), + 2: uint16(34389), + 3: uint16(24426), + 4: uint16(34503), + 5: uint16(34496), + 6: uint16(34486), + 7: uint16(34500), + 8: uint16(34485), + 9: uint16(34502), + 10: uint16(34507), + 11: uint16(34481), + 12: uint16(34479), + 13: uint16(34505), + 14: uint16(34899), + 15: uint16(34974), + 16: uint16(34952), + 17: uint16(34987), + 18: uint16(34962), + 19: uint16(34966), + 20: uint16(34957), + 21: uint16(34955), + 22: uint16(35219), + 23: uint16(35215), + 24: uint16(35370), + 25: uint16(35357), + 26: uint16(35363), + 27: uint16(35365), + 28: uint16(35377), + 29: uint16(35373), + 30: uint16(35359), + 31: uint16(35355), + 32: uint16(35362), + 33: uint16(35913), + 34: uint16(35930), + 35: uint16(36009), + 36: uint16(36012), + 37: uint16(36011), + 38: uint16(36008), + 39: uint16(36010), + 40: uint16(36007), + 41: uint16(36199), + 42: uint16(36198), + 43: uint16(36286), + 44: uint16(36282), + 45: uint16(36571), + 46: uint16(36575), + 47: uint16(36889), + 48: uint16(36877), + 49: uint16(36890), + 50: uint16(36887), + 51: uint16(36899), + 52: uint16(36895), + 53: uint16(36893), + 54: uint16(36880), + 55: uint16(36885), + 56: uint16(36894), + 57: uint16(36896), + 58: uint16(36879), + 59: uint16(36898), + 60: uint16(36886), + 61: uint16(36891), + 62: uint16(36884), + 63: uint16(37096), + 64: uint16(37101), + 65: uint16(37117), + 66: uint16(37207), + 67: uint16(37326), + 68: uint16(37365), + 69: uint16(37350), + 70: uint16(37347), + 71: uint16(37351), + 72: uint16(37357), + 73: uint16(37353), + 74: uint16(38281), + 75: uint16(38506), + 76: uint16(38517), + 77: uint16(38515), + 78: uint16(38520), + 79: uint16(38512), + 80: uint16(38516), + 81: uint16(38518), + 82: uint16(38519), + 83: uint16(38508), + 84: uint16(38592), + 85: uint16(38634), + 86: uint16(38633), + 87: uint16(31456), + 88: uint16(31455), + 89: uint16(38914), + 90: uint16(38915), + 91: uint16(39770), + 92: uint16(40165), + 93: uint16(40565), + 94: uint16(40575), + 95: uint16(40613), + 96: uint16(40635), + 97: uint16(20642), + 98: uint16(20621), + 99: uint16(20613), + 100: uint16(20633), + 101: uint16(20625), + 102: uint16(20608), + 103: uint16(20630), + 104: uint16(20632), + 105: uint16(20634), + 106: uint16(26368), + 107: uint16(20977), + 108: uint16(21106), + 109: uint16(21108), + 110: uint16(21109), + 111: uint16(21097), + 112: uint16(21214), + 113: uint16(21213), + 114: uint16(21211), + 115: uint16(21338), + 116: uint16(21413), + 117: uint16(21883), + 118: uint16(21888), + 119: uint16(21927), + 120: uint16(21884), + 121: uint16(21898), + 122: uint16(21917), + 123: uint16(21912), + 124: uint16(21890), + 125: uint16(21916), + 126: uint16(21930), + 127: uint16(21908), + 128: uint16(21895), + 129: uint16(21899), + 130: uint16(21891), + 131: uint16(21939), + 132: uint16(21934), + 133: uint16(21919), + 134: uint16(21822), + 135: uint16(21938), + 136: uint16(21914), + 137: uint16(21947), + 138: uint16(21932), + 139: uint16(21937), + 140: uint16(21886), + 141: uint16(21897), + 142: uint16(21931), + 143: uint16(21913), + 144: uint16(22285), + 145: uint16(22575), + 146: uint16(22570), + 147: uint16(22580), + 148: uint16(22564), + 149: uint16(22576), + 150: uint16(22577), + 151: uint16(22561), + 152: uint16(22557), + 153: uint16(22560), + 154: uint16(22777), + 155: uint16(22778), + 156: uint16(22880), + }, + 19: { + 0: uint16(23159), + 1: uint16(23194), + 2: uint16(23167), + 3: uint16(23186), + 4: uint16(23195), + 5: uint16(23207), + 6: uint16(23411), + 7: uint16(23409), + 8: uint16(23506), + 9: uint16(23500), + 10: uint16(23507), + 11: uint16(23504), + 12: uint16(23562), + 13: uint16(23563), + 14: uint16(23601), + 15: uint16(23884), + 16: uint16(23888), + 17: uint16(23860), + 18: uint16(23879), + 19: uint16(24061), + 20: uint16(24133), + 21: uint16(24125), + 22: uint16(24128), + 23: uint16(24131), + 24: uint16(24190), + 25: uint16(24266), + 26: uint16(24257), + 27: uint16(24258), + 28: uint16(24260), + 29: uint16(24380), + 30: uint16(24429), + 31: uint16(24489), + 32: uint16(24490), + 33: uint16(24488), + 34: uint16(24785), + 35: uint16(24801), + 36: uint16(24754), + 37: uint16(24758), + 38: uint16(24800), + 39: uint16(24860), + 40: uint16(24867), + 41: uint16(24826), + 42: uint16(24853), + 43: uint16(24816), + 44: uint16(24827), + 45: uint16(24820), + 46: uint16(24936), + 47: uint16(24817), + 48: uint16(24846), + 49: uint16(24822), + 50: uint16(24841), + 51: uint16(24832), + 52: uint16(24850), + 53: uint16(25119), + 54: uint16(25161), + 55: uint16(25507), + 56: uint16(25484), + 57: uint16(25551), + 58: uint16(25536), + 59: uint16(25577), + 60: uint16(25545), + 61: uint16(25542), + 62: uint16(25549), + 63: uint16(25554), + 64: uint16(25571), + 65: uint16(25552), + 66: uint16(25569), + 67: uint16(25558), + 68: uint16(25581), + 69: uint16(25582), + 70: uint16(25462), + 71: uint16(25588), + 72: uint16(25578), + 73: uint16(25563), + 74: uint16(25682), + 75: uint16(25562), + 76: uint16(25593), + 77: uint16(25950), + 78: uint16(25958), + 79: uint16(25954), + 80: uint16(25955), + 81: uint16(26001), + 82: uint16(26000), + 83: uint16(26031), + 84: uint16(26222), + 85: uint16(26224), + 86: uint16(26228), + 87: uint16(26230), + 88: uint16(26223), + 89: uint16(26257), + 90: uint16(26234), + 91: uint16(26238), + 92: uint16(26231), + 93: uint16(26366), + 94: uint16(26367), + 95: uint16(26399), + 96: uint16(26397), + 97: uint16(26874), + 98: uint16(26837), + 99: uint16(26848), + 100: uint16(26840), + 101: uint16(26839), + 102: uint16(26885), + 103: uint16(26847), + 104: uint16(26869), + 105: uint16(26862), + 106: uint16(26855), + 107: uint16(26873), + 108: uint16(26834), + 109: uint16(26866), + 110: uint16(26851), + 111: uint16(26827), + 112: uint16(26829), + 113: uint16(26893), + 114: uint16(26898), + 115: uint16(26894), + 116: uint16(26825), + 117: uint16(26842), + 118: uint16(26990), + 119: uint16(26875), + 120: uint16(27454), + 121: uint16(27450), + 122: uint16(27453), + 123: uint16(27544), + 124: uint16(27542), + 125: uint16(27580), + 126: uint16(27631), + 127: uint16(27694), + 128: uint16(27695), + 129: uint16(27692), + 130: uint16(28207), + 131: uint16(28216), + 132: uint16(28244), + 133: uint16(28193), + 134: uint16(28210), + 135: uint16(28263), + 136: uint16(28234), + 137: uint16(28192), + 138: uint16(28197), + 139: uint16(28195), + 140: uint16(28187), + 141: uint16(28251), + 142: uint16(28248), + 143: uint16(28196), + 144: uint16(28246), + 145: uint16(28270), + 146: uint16(28205), + 147: uint16(28198), + 148: uint16(28271), + 149: uint16(28212), + 150: uint16(28237), + 151: uint16(28218), + 152: uint16(28204), + 153: uint16(28227), + 154: uint16(28189), + 155: uint16(28222), + 156: uint16(28363), + }, + 20: { + 0: uint16(28297), + 1: uint16(28185), + 2: uint16(28238), + 3: uint16(28259), + 4: uint16(28228), + 5: uint16(28274), + 6: uint16(28265), + 7: uint16(28255), + 8: uint16(28953), + 9: uint16(28954), + 10: uint16(28966), + 11: uint16(28976), + 12: uint16(28961), + 13: uint16(28982), + 14: uint16(29038), + 15: uint16(28956), + 16: uint16(29260), + 17: uint16(29316), + 18: uint16(29312), + 19: uint16(29494), + 20: uint16(29477), + 21: uint16(29492), + 22: uint16(29481), + 23: uint16(29754), + 24: uint16(29738), + 25: uint16(29747), + 26: uint16(29730), + 27: uint16(29733), + 28: uint16(29749), + 29: uint16(29750), + 30: uint16(29748), + 31: uint16(29743), + 32: uint16(29723), + 33: uint16(29734), + 34: uint16(29736), + 35: uint16(29989), + 36: uint16(29990), + 37: uint16(30059), + 38: uint16(30058), + 39: uint16(30178), + 40: uint16(30171), + 41: uint16(30179), + 42: uint16(30169), + 43: uint16(30168), + 44: uint16(30174), + 45: uint16(30176), + 46: uint16(30331), + 47: uint16(30332), + 48: uint16(30358), + 49: uint16(30355), + 50: uint16(30388), + 51: uint16(30428), + 52: uint16(30543), + 53: uint16(30701), + 54: uint16(30813), + 55: uint16(30828), + 56: uint16(30831), + 57: uint16(31245), + 58: uint16(31240), + 59: uint16(31243), + 60: uint16(31237), + 61: uint16(31232), + 62: uint16(31384), + 63: uint16(31383), + 64: uint16(31382), + 65: uint16(31461), + 66: uint16(31459), + 67: uint16(31561), + 68: uint16(31574), + 69: uint16(31558), + 70: uint16(31568), + 71: uint16(31570), + 72: uint16(31572), + 73: uint16(31565), + 74: uint16(31563), + 75: uint16(31567), + 76: uint16(31569), + 77: uint16(31903), + 78: uint16(31909), + 79: uint16(32094), + 80: uint16(32080), + 81: uint16(32104), + 82: uint16(32085), + 83: uint16(32043), + 84: uint16(32110), + 85: uint16(32114), + 86: uint16(32097), + 87: uint16(32102), + 88: uint16(32098), + 89: uint16(32112), + 90: uint16(32115), + 91: uint16(21892), + 92: uint16(32724), + 93: uint16(32725), + 94: uint16(32779), + 95: uint16(32850), + 96: uint16(32901), + 97: uint16(33109), + 98: uint16(33108), + 99: uint16(33099), + 100: uint16(33105), + 101: uint16(33102), + 102: uint16(33081), + 103: uint16(33094), + 104: uint16(33086), + 105: uint16(33100), + 106: uint16(33107), + 107: uint16(33140), + 108: uint16(33298), + 109: uint16(33308), + 110: uint16(33769), + 111: uint16(33795), + 112: uint16(33784), + 113: uint16(33805), + 114: uint16(33760), + 115: uint16(33733), + 116: uint16(33803), + 117: uint16(33729), + 118: uint16(33775), + 119: uint16(33777), + 120: uint16(33780), + 121: uint16(33879), + 122: uint16(33802), + 123: uint16(33776), + 124: uint16(33804), + 125: uint16(33740), + 126: uint16(33789), + 127: uint16(33778), + 128: uint16(33738), + 129: uint16(33848), + 130: uint16(33806), + 131: uint16(33796), + 132: uint16(33756), + 133: uint16(33799), + 134: uint16(33748), + 135: uint16(33759), + 136: uint16(34395), + 137: uint16(34527), + 138: uint16(34521), + 139: uint16(34541), + 140: uint16(34516), + 141: uint16(34523), + 142: uint16(34532), + 143: uint16(34512), + 144: uint16(34526), + 145: uint16(34903), + 146: uint16(35009), + 147: uint16(35010), + 148: uint16(34993), + 149: uint16(35203), + 150: uint16(35222), + 151: uint16(35387), + 152: uint16(35424), + 153: uint16(35413), + 154: uint16(35422), + 155: uint16(35388), + 156: uint16(35393), + }, + 21: { + 0: uint16(35412), + 1: uint16(35419), + 2: uint16(35408), + 3: uint16(35398), + 4: uint16(35380), + 5: uint16(35386), + 6: uint16(35382), + 7: uint16(35414), + 8: uint16(35937), + 9: uint16(35970), + 10: uint16(36015), + 11: uint16(36028), + 12: uint16(36019), + 13: uint16(36029), + 14: uint16(36033), + 15: uint16(36027), + 16: uint16(36032), + 17: uint16(36020), + 18: uint16(36023), + 19: uint16(36022), + 20: uint16(36031), + 21: uint16(36024), + 22: uint16(36234), + 23: uint16(36229), + 24: uint16(36225), + 25: uint16(36302), + 26: uint16(36317), + 27: uint16(36299), + 28: uint16(36314), + 29: uint16(36305), + 30: uint16(36300), + 31: uint16(36315), + 32: uint16(36294), + 33: uint16(36603), + 34: uint16(36600), + 35: uint16(36604), + 36: uint16(36764), + 37: uint16(36910), + 38: uint16(36917), + 39: uint16(36913), + 40: uint16(36920), + 41: uint16(36914), + 42: uint16(36918), + 43: uint16(37122), + 44: uint16(37109), + 45: uint16(37129), + 46: uint16(37118), + 47: uint16(37219), + 48: uint16(37221), + 49: uint16(37327), + 50: uint16(37396), + 51: uint16(37397), + 52: uint16(37411), + 53: uint16(37385), + 54: uint16(37406), + 55: uint16(37389), + 56: uint16(37392), + 57: uint16(37383), + 58: uint16(37393), + 59: uint16(38292), + 60: uint16(38287), + 61: uint16(38283), + 62: uint16(38289), + 63: uint16(38291), + 64: uint16(38290), + 65: uint16(38286), + 66: uint16(38538), + 67: uint16(38542), + 68: uint16(38539), + 69: uint16(38525), + 70: uint16(38533), + 71: uint16(38534), + 72: uint16(38541), + 73: uint16(38514), + 74: uint16(38532), + 75: uint16(38593), + 76: uint16(38597), + 77: uint16(38596), + 78: uint16(38598), + 79: uint16(38599), + 80: uint16(38639), + 81: uint16(38642), + 82: uint16(38860), + 83: uint16(38917), + 84: uint16(38918), + 85: uint16(38920), + 86: uint16(39143), + 87: uint16(39146), + 88: uint16(39151), + 89: uint16(39145), + 90: uint16(39154), + 91: uint16(39149), + 92: uint16(39342), + 93: uint16(39341), + 94: uint16(40643), + 95: uint16(40653), + 96: uint16(40657), + 97: uint16(20098), + 98: uint16(20653), + 99: uint16(20661), + 100: uint16(20658), + 101: uint16(20659), + 102: uint16(20677), + 103: uint16(20670), + 104: uint16(20652), + 105: uint16(20663), + 106: uint16(20667), + 107: uint16(20655), + 108: uint16(20679), + 109: uint16(21119), + 110: uint16(21111), + 111: uint16(21117), + 112: uint16(21215), + 113: uint16(21222), + 114: uint16(21220), + 115: uint16(21218), + 116: uint16(21219), + 117: uint16(21295), + 118: uint16(21983), + 119: uint16(21992), + 120: uint16(21971), + 121: uint16(21990), + 122: uint16(21966), + 123: uint16(21980), + 124: uint16(21959), + 125: uint16(21969), + 126: uint16(21987), + 127: uint16(21988), + 128: uint16(21999), + 129: uint16(21978), + 130: uint16(21985), + 131: uint16(21957), + 132: uint16(21958), + 133: uint16(21989), + 134: uint16(21961), + 135: uint16(22290), + 136: uint16(22291), + 137: uint16(22622), + 138: uint16(22609), + 139: uint16(22616), + 140: uint16(22615), + 141: uint16(22618), + 142: uint16(22612), + 143: uint16(22635), + 144: uint16(22604), + 145: uint16(22637), + 146: uint16(22602), + 147: uint16(22626), + 148: uint16(22610), + 149: uint16(22603), + 150: uint16(22887), + 151: uint16(23233), + 152: uint16(23241), + 153: uint16(23244), + 154: uint16(23230), + 155: uint16(23229), + 156: uint16(23228), + }, + 22: { + 0: uint16(23219), + 1: uint16(23234), + 2: uint16(23218), + 3: uint16(23913), + 4: uint16(23919), + 5: uint16(24140), + 6: uint16(24185), + 7: uint16(24265), + 8: uint16(24264), + 9: uint16(24338), + 10: uint16(24409), + 11: uint16(24492), + 12: uint16(24494), + 13: uint16(24858), + 14: uint16(24847), + 15: uint16(24904), + 16: uint16(24863), + 17: uint16(24819), + 18: uint16(24859), + 19: uint16(24825), + 20: uint16(24833), + 21: uint16(24840), + 22: uint16(24910), + 23: uint16(24908), + 24: uint16(24900), + 25: uint16(24909), + 26: uint16(24894), + 27: uint16(24884), + 28: uint16(24871), + 29: uint16(24845), + 30: uint16(24838), + 31: uint16(24887), + 32: uint16(25121), + 33: uint16(25122), + 34: uint16(25619), + 35: uint16(25662), + 36: uint16(25630), + 37: uint16(25642), + 38: uint16(25645), + 39: uint16(25661), + 40: uint16(25644), + 41: uint16(25615), + 42: uint16(25628), + 43: uint16(25620), + 44: uint16(25613), + 45: uint16(25654), + 46: uint16(25622), + 47: uint16(25623), + 48: uint16(25606), + 49: uint16(25964), + 50: uint16(26015), + 51: uint16(26032), + 52: uint16(26263), + 53: uint16(26249), + 54: uint16(26247), + 55: uint16(26248), + 56: uint16(26262), + 57: uint16(26244), + 58: uint16(26264), + 59: uint16(26253), + 60: uint16(26371), + 61: uint16(27028), + 62: uint16(26989), + 63: uint16(26970), + 64: uint16(26999), + 65: uint16(26976), + 66: uint16(26964), + 67: uint16(26997), + 68: uint16(26928), + 69: uint16(27010), + 70: uint16(26954), + 71: uint16(26984), + 72: uint16(26987), + 73: uint16(26974), + 74: uint16(26963), + 75: uint16(27001), + 76: uint16(27014), + 77: uint16(26973), + 78: uint16(26979), + 79: uint16(26971), + 80: uint16(27463), + 81: uint16(27506), + 82: uint16(27584), + 83: uint16(27583), + 84: uint16(27603), + 85: uint16(27645), + 86: uint16(28322), + 87: uint16(28335), + 88: uint16(28371), + 89: uint16(28342), + 90: uint16(28354), + 91: uint16(28304), + 92: uint16(28317), + 93: uint16(28359), + 94: uint16(28357), + 95: uint16(28325), + 96: uint16(28312), + 97: uint16(28348), + 98: uint16(28346), + 99: uint16(28331), + 100: uint16(28369), + 101: uint16(28310), + 102: uint16(28316), + 103: uint16(28356), + 104: uint16(28372), + 105: uint16(28330), + 106: uint16(28327), + 107: uint16(28340), + 108: uint16(29006), + 109: uint16(29017), + 110: uint16(29033), + 111: uint16(29028), + 112: uint16(29001), + 113: uint16(29031), + 114: uint16(29020), + 115: uint16(29036), + 116: uint16(29030), + 117: uint16(29004), + 118: uint16(29029), + 119: uint16(29022), + 120: uint16(28998), + 121: uint16(29032), + 122: uint16(29014), + 123: uint16(29242), + 124: uint16(29266), + 125: uint16(29495), + 126: uint16(29509), + 127: uint16(29503), + 128: uint16(29502), + 129: uint16(29807), + 130: uint16(29786), + 131: uint16(29781), + 132: uint16(29791), + 133: uint16(29790), + 134: uint16(29761), + 135: uint16(29759), + 136: uint16(29785), + 137: uint16(29787), + 138: uint16(29788), + 139: uint16(30070), + 140: uint16(30072), + 141: uint16(30208), + 142: uint16(30192), + 143: uint16(30209), + 144: uint16(30194), + 145: uint16(30193), + 146: uint16(30202), + 147: uint16(30207), + 148: uint16(30196), + 149: uint16(30195), + 150: uint16(30430), + 151: uint16(30431), + 152: uint16(30555), + 153: uint16(30571), + 154: uint16(30566), + 155: uint16(30558), + 156: uint16(30563), + }, + 23: { + 0: uint16(30585), + 1: uint16(30570), + 2: uint16(30572), + 3: uint16(30556), + 4: uint16(30565), + 5: uint16(30568), + 6: uint16(30562), + 7: uint16(30702), + 8: uint16(30862), + 9: uint16(30896), + 10: uint16(30871), + 11: uint16(30872), + 12: uint16(30860), + 13: uint16(30857), + 14: uint16(30844), + 15: uint16(30865), + 16: uint16(30867), + 17: uint16(30847), + 18: uint16(31098), + 19: uint16(31103), + 20: uint16(31105), + 21: uint16(33836), + 22: uint16(31165), + 23: uint16(31260), + 24: uint16(31258), + 25: uint16(31264), + 26: uint16(31252), + 27: uint16(31263), + 28: uint16(31262), + 29: uint16(31391), + 30: uint16(31392), + 31: uint16(31607), + 32: uint16(31680), + 33: uint16(31584), + 34: uint16(31598), + 35: uint16(31591), + 36: uint16(31921), + 37: uint16(31923), + 38: uint16(31925), + 39: uint16(32147), + 40: uint16(32121), + 41: uint16(32145), + 42: uint16(32129), + 43: uint16(32143), + 44: uint16(32091), + 45: uint16(32622), + 46: uint16(32617), + 47: uint16(32618), + 48: uint16(32626), + 49: uint16(32681), + 50: uint16(32680), + 51: uint16(32676), + 52: uint16(32854), + 53: uint16(32856), + 54: uint16(32902), + 55: uint16(32900), + 56: uint16(33137), + 57: uint16(33136), + 58: uint16(33144), + 59: uint16(33125), + 60: uint16(33134), + 61: uint16(33139), + 62: uint16(33131), + 63: uint16(33145), + 64: uint16(33146), + 65: uint16(33126), + 66: uint16(33285), + 67: uint16(33351), + 68: uint16(33922), + 69: uint16(33911), + 70: uint16(33853), + 71: uint16(33841), + 72: uint16(33909), + 73: uint16(33894), + 74: uint16(33899), + 75: uint16(33865), + 76: uint16(33900), + 77: uint16(33883), + 78: uint16(33852), + 79: uint16(33845), + 80: uint16(33889), + 81: uint16(33891), + 82: uint16(33897), + 83: uint16(33901), + 84: uint16(33862), + 85: uint16(34398), + 86: uint16(34396), + 87: uint16(34399), + 88: uint16(34553), + 89: uint16(34579), + 90: uint16(34568), + 91: uint16(34567), + 92: uint16(34560), + 93: uint16(34558), + 94: uint16(34555), + 95: uint16(34562), + 96: uint16(34563), + 97: uint16(34566), + 98: uint16(34570), + 99: uint16(34905), + 100: uint16(35039), + 101: uint16(35028), + 102: uint16(35033), + 103: uint16(35036), + 104: uint16(35032), + 105: uint16(35037), + 106: uint16(35041), + 107: uint16(35018), + 108: uint16(35029), + 109: uint16(35026), + 110: uint16(35228), + 111: uint16(35299), + 112: uint16(35435), + 113: uint16(35442), + 114: uint16(35443), + 115: uint16(35430), + 116: uint16(35433), + 117: uint16(35440), + 118: uint16(35463), + 119: uint16(35452), + 120: uint16(35427), + 121: uint16(35488), + 122: uint16(35441), + 123: uint16(35461), + 124: uint16(35437), + 125: uint16(35426), + 126: uint16(35438), + 127: uint16(35436), + 128: uint16(35449), + 129: uint16(35451), + 130: uint16(35390), + 131: uint16(35432), + 132: uint16(35938), + 133: uint16(35978), + 134: uint16(35977), + 135: uint16(36042), + 136: uint16(36039), + 137: uint16(36040), + 138: uint16(36036), + 139: uint16(36018), + 140: uint16(36035), + 141: uint16(36034), + 142: uint16(36037), + 143: uint16(36321), + 144: uint16(36319), + 145: uint16(36328), + 146: uint16(36335), + 147: uint16(36339), + 148: uint16(36346), + 149: uint16(36330), + 150: uint16(36324), + 151: uint16(36326), + 152: uint16(36530), + 153: uint16(36611), + 154: uint16(36617), + 155: uint16(36606), + 156: uint16(36618), + }, + 24: { + 0: uint16(36767), + 1: uint16(36786), + 2: uint16(36939), + 3: uint16(36938), + 4: uint16(36947), + 5: uint16(36930), + 6: uint16(36948), + 7: uint16(36924), + 8: uint16(36949), + 9: uint16(36944), + 10: uint16(36935), + 11: uint16(36943), + 12: uint16(36942), + 13: uint16(36941), + 14: uint16(36945), + 15: uint16(36926), + 16: uint16(36929), + 17: uint16(37138), + 18: uint16(37143), + 19: uint16(37228), + 20: uint16(37226), + 21: uint16(37225), + 22: uint16(37321), + 23: uint16(37431), + 24: uint16(37463), + 25: uint16(37432), + 26: uint16(37437), + 27: uint16(37440), + 28: uint16(37438), + 29: uint16(37467), + 30: uint16(37451), + 31: uint16(37476), + 32: uint16(37457), + 33: uint16(37428), + 34: uint16(37449), + 35: uint16(37453), + 36: uint16(37445), + 37: uint16(37433), + 38: uint16(37439), + 39: uint16(37466), + 40: uint16(38296), + 41: uint16(38552), + 42: uint16(38548), + 43: uint16(38549), + 44: uint16(38605), + 45: uint16(38603), + 46: uint16(38601), + 47: uint16(38602), + 48: uint16(38647), + 49: uint16(38651), + 50: uint16(38649), + 51: uint16(38646), + 52: uint16(38742), + 53: uint16(38772), + 54: uint16(38774), + 55: uint16(38928), + 56: uint16(38929), + 57: uint16(38931), + 58: uint16(38922), + 59: uint16(38930), + 60: uint16(38924), + 61: uint16(39164), + 62: uint16(39156), + 63: uint16(39165), + 64: uint16(39166), + 65: uint16(39347), + 66: uint16(39345), + 67: uint16(39348), + 68: uint16(39649), + 69: uint16(40169), + 70: uint16(40578), + 71: uint16(40718), + 72: uint16(40723), + 73: uint16(40736), + 74: uint16(20711), + 75: uint16(20718), + 76: uint16(20709), + 77: uint16(20694), + 78: uint16(20717), + 79: uint16(20698), + 80: uint16(20693), + 81: uint16(20687), + 82: uint16(20689), + 83: uint16(20721), + 84: uint16(20686), + 85: uint16(20713), + 86: uint16(20834), + 87: uint16(20979), + 88: uint16(21123), + 89: uint16(21122), + 90: uint16(21297), + 91: uint16(21421), + 92: uint16(22014), + 93: uint16(22016), + 94: uint16(22043), + 95: uint16(22039), + 96: uint16(22013), + 97: uint16(22036), + 98: uint16(22022), + 99: uint16(22025), + 100: uint16(22029), + 101: uint16(22030), + 102: uint16(22007), + 103: uint16(22038), + 104: uint16(22047), + 105: uint16(22024), + 106: uint16(22032), + 107: uint16(22006), + 108: uint16(22296), + 109: uint16(22294), + 110: uint16(22645), + 111: uint16(22654), + 112: uint16(22659), + 113: uint16(22675), + 114: uint16(22666), + 115: uint16(22649), + 116: uint16(22661), + 117: uint16(22653), + 118: uint16(22781), + 119: uint16(22821), + 120: uint16(22818), + 121: uint16(22820), + 122: uint16(22890), + 123: uint16(22889), + 124: uint16(23265), + 125: uint16(23270), + 126: uint16(23273), + 127: uint16(23255), + 128: uint16(23254), + 129: uint16(23256), + 130: uint16(23267), + 131: uint16(23413), + 132: uint16(23518), + 133: uint16(23527), + 134: uint16(23521), + 135: uint16(23525), + 136: uint16(23526), + 137: uint16(23528), + 138: uint16(23522), + 139: uint16(23524), + 140: uint16(23519), + 141: uint16(23565), + 142: uint16(23650), + 143: uint16(23940), + 144: uint16(23943), + 145: uint16(24155), + 146: uint16(24163), + 147: uint16(24149), + 148: uint16(24151), + 149: uint16(24148), + 150: uint16(24275), + 151: uint16(24278), + 152: uint16(24330), + 153: uint16(24390), + 154: uint16(24432), + 155: uint16(24505), + 156: uint16(24903), + }, + 25: { + 0: uint16(24895), + 1: uint16(24907), + 2: uint16(24951), + 3: uint16(24930), + 4: uint16(24931), + 5: uint16(24927), + 6: uint16(24922), + 7: uint16(24920), + 8: uint16(24949), + 9: uint16(25130), + 10: uint16(25735), + 11: uint16(25688), + 12: uint16(25684), + 13: uint16(25764), + 14: uint16(25720), + 15: uint16(25695), + 16: uint16(25722), + 17: uint16(25681), + 18: uint16(25703), + 19: uint16(25652), + 20: uint16(25709), + 21: uint16(25723), + 22: uint16(25970), + 23: uint16(26017), + 24: uint16(26071), + 25: uint16(26070), + 26: uint16(26274), + 27: uint16(26280), + 28: uint16(26269), + 29: uint16(27036), + 30: uint16(27048), + 31: uint16(27029), + 32: uint16(27073), + 33: uint16(27054), + 34: uint16(27091), + 35: uint16(27083), + 36: uint16(27035), + 37: uint16(27063), + 38: uint16(27067), + 39: uint16(27051), + 40: uint16(27060), + 41: uint16(27088), + 42: uint16(27085), + 43: uint16(27053), + 44: uint16(27084), + 45: uint16(27046), + 46: uint16(27075), + 47: uint16(27043), + 48: uint16(27465), + 49: uint16(27468), + 50: uint16(27699), + 51: uint16(28467), + 52: uint16(28436), + 53: uint16(28414), + 54: uint16(28435), + 55: uint16(28404), + 56: uint16(28457), + 57: uint16(28478), + 58: uint16(28448), + 59: uint16(28460), + 60: uint16(28431), + 61: uint16(28418), + 62: uint16(28450), + 63: uint16(28415), + 64: uint16(28399), + 65: uint16(28422), + 66: uint16(28465), + 67: uint16(28472), + 68: uint16(28466), + 69: uint16(28451), + 70: uint16(28437), + 71: uint16(28459), + 72: uint16(28463), + 73: uint16(28552), + 74: uint16(28458), + 75: uint16(28396), + 76: uint16(28417), + 77: uint16(28402), + 78: uint16(28364), + 79: uint16(28407), + 80: uint16(29076), + 81: uint16(29081), + 82: uint16(29053), + 83: uint16(29066), + 84: uint16(29060), + 85: uint16(29074), + 86: uint16(29246), + 87: uint16(29330), + 88: uint16(29334), + 89: uint16(29508), + 90: uint16(29520), + 91: uint16(29796), + 92: uint16(29795), + 93: uint16(29802), + 94: uint16(29808), + 95: uint16(29805), + 96: uint16(29956), + 97: uint16(30097), + 98: uint16(30247), + 99: uint16(30221), + 100: uint16(30219), + 101: uint16(30217), + 102: uint16(30227), + 103: uint16(30433), + 104: uint16(30435), + 105: uint16(30596), + 106: uint16(30589), + 107: uint16(30591), + 108: uint16(30561), + 109: uint16(30913), + 110: uint16(30879), + 111: uint16(30887), + 112: uint16(30899), + 113: uint16(30889), + 114: uint16(30883), + 115: uint16(31118), + 116: uint16(31119), + 117: uint16(31117), + 118: uint16(31278), + 119: uint16(31281), + 120: uint16(31402), + 121: uint16(31401), + 122: uint16(31469), + 123: uint16(31471), + 124: uint16(31649), + 125: uint16(31637), + 126: uint16(31627), + 127: uint16(31605), + 128: uint16(31639), + 129: uint16(31645), + 130: uint16(31636), + 131: uint16(31631), + 132: uint16(31672), + 133: uint16(31623), + 134: uint16(31620), + 135: uint16(31929), + 136: uint16(31933), + 137: uint16(31934), + 138: uint16(32187), + 139: uint16(32176), + 140: uint16(32156), + 141: uint16(32189), + 142: uint16(32190), + 143: uint16(32160), + 144: uint16(32202), + 145: uint16(32180), + 146: uint16(32178), + 147: uint16(32177), + 148: uint16(32186), + 149: uint16(32162), + 150: uint16(32191), + 151: uint16(32181), + 152: uint16(32184), + 153: uint16(32173), + 154: uint16(32210), + 155: uint16(32199), + 156: uint16(32172), + }, + 26: { + 0: uint16(32624), + 1: uint16(32736), + 2: uint16(32737), + 3: uint16(32735), + 4: uint16(32862), + 5: uint16(32858), + 6: uint16(32903), + 7: uint16(33104), + 8: uint16(33152), + 9: uint16(33167), + 10: uint16(33160), + 11: uint16(33162), + 12: uint16(33151), + 13: uint16(33154), + 14: uint16(33255), + 15: uint16(33274), + 16: uint16(33287), + 17: uint16(33300), + 18: uint16(33310), + 19: uint16(33355), + 20: uint16(33993), + 21: uint16(33983), + 22: uint16(33990), + 23: uint16(33988), + 24: uint16(33945), + 25: uint16(33950), + 26: uint16(33970), + 27: uint16(33948), + 28: uint16(33995), + 29: uint16(33976), + 30: uint16(33984), + 31: uint16(34003), + 32: uint16(33936), + 33: uint16(33980), + 34: uint16(34001), + 35: uint16(33994), + 36: uint16(34623), + 37: uint16(34588), + 38: uint16(34619), + 39: uint16(34594), + 40: uint16(34597), + 41: uint16(34612), + 42: uint16(34584), + 43: uint16(34645), + 44: uint16(34615), + 45: uint16(34601), + 46: uint16(35059), + 47: uint16(35074), + 48: uint16(35060), + 49: uint16(35065), + 50: uint16(35064), + 51: uint16(35069), + 52: uint16(35048), + 53: uint16(35098), + 54: uint16(35055), + 55: uint16(35494), + 56: uint16(35468), + 57: uint16(35486), + 58: uint16(35491), + 59: uint16(35469), + 60: uint16(35489), + 61: uint16(35475), + 62: uint16(35492), + 63: uint16(35498), + 64: uint16(35493), + 65: uint16(35496), + 66: uint16(35480), + 67: uint16(35473), + 68: uint16(35482), + 69: uint16(35495), + 70: uint16(35946), + 71: uint16(35981), + 72: uint16(35980), + 73: uint16(36051), + 74: uint16(36049), + 75: uint16(36050), + 76: uint16(36203), + 77: uint16(36249), + 78: uint16(36245), + 79: uint16(36348), + 80: uint16(36628), + 81: uint16(36626), + 82: uint16(36629), + 83: uint16(36627), + 84: uint16(36771), + 85: uint16(36960), + 86: uint16(36952), + 87: uint16(36956), + 88: uint16(36963), + 89: uint16(36953), + 90: uint16(36958), + 91: uint16(36962), + 92: uint16(36957), + 93: uint16(36955), + 94: uint16(37145), + 95: uint16(37144), + 96: uint16(37150), + 97: uint16(37237), + 98: uint16(37240), + 99: uint16(37239), + 100: uint16(37236), + 101: uint16(37496), + 102: uint16(37504), + 103: uint16(37509), + 104: uint16(37528), + 105: uint16(37526), + 106: uint16(37499), + 107: uint16(37523), + 108: uint16(37532), + 109: uint16(37544), + 110: uint16(37500), + 111: uint16(37521), + 112: uint16(38305), + 113: uint16(38312), + 114: uint16(38313), + 115: uint16(38307), + 116: uint16(38309), + 117: uint16(38308), + 118: uint16(38553), + 119: uint16(38556), + 120: uint16(38555), + 121: uint16(38604), + 122: uint16(38610), + 123: uint16(38656), + 124: uint16(38780), + 125: uint16(38789), + 126: uint16(38902), + 127: uint16(38935), + 128: uint16(38936), + 129: uint16(39087), + 130: uint16(39089), + 131: uint16(39171), + 132: uint16(39173), + 133: uint16(39180), + 134: uint16(39177), + 135: uint16(39361), + 136: uint16(39599), + 137: uint16(39600), + 138: uint16(39654), + 139: uint16(39745), + 140: uint16(39746), + 141: uint16(40180), + 142: uint16(40182), + 143: uint16(40179), + 144: uint16(40636), + 145: uint16(40763), + 146: uint16(40778), + 147: uint16(20740), + 148: uint16(20736), + 149: uint16(20731), + 150: uint16(20725), + 151: uint16(20729), + 152: uint16(20738), + 153: uint16(20744), + 154: uint16(20745), + 155: uint16(20741), + 156: uint16(20956), + }, + 27: { + 0: uint16(21127), + 1: uint16(21128), + 2: uint16(21129), + 3: uint16(21133), + 4: uint16(21130), + 5: uint16(21232), + 6: uint16(21426), + 7: uint16(22062), + 8: uint16(22075), + 9: uint16(22073), + 10: uint16(22066), + 11: uint16(22079), + 12: uint16(22068), + 13: uint16(22057), + 14: uint16(22099), + 15: uint16(22094), + 16: uint16(22103), + 17: uint16(22132), + 18: uint16(22070), + 19: uint16(22063), + 20: uint16(22064), + 21: uint16(22656), + 22: uint16(22687), + 23: uint16(22686), + 24: uint16(22707), + 25: uint16(22684), + 26: uint16(22702), + 27: uint16(22697), + 28: uint16(22694), + 29: uint16(22893), + 30: uint16(23305), + 31: uint16(23291), + 32: uint16(23307), + 33: uint16(23285), + 34: uint16(23308), + 35: uint16(23304), + 36: uint16(23534), + 37: uint16(23532), + 38: uint16(23529), + 39: uint16(23531), + 40: uint16(23652), + 41: uint16(23653), + 42: uint16(23965), + 43: uint16(23956), + 44: uint16(24162), + 45: uint16(24159), + 46: uint16(24161), + 47: uint16(24290), + 48: uint16(24282), + 49: uint16(24287), + 50: uint16(24285), + 51: uint16(24291), + 52: uint16(24288), + 53: uint16(24392), + 54: uint16(24433), + 55: uint16(24503), + 56: uint16(24501), + 57: uint16(24950), + 58: uint16(24935), + 59: uint16(24942), + 60: uint16(24925), + 61: uint16(24917), + 62: uint16(24962), + 63: uint16(24956), + 64: uint16(24944), + 65: uint16(24939), + 66: uint16(24958), + 67: uint16(24999), + 68: uint16(24976), + 69: uint16(25003), + 70: uint16(24974), + 71: uint16(25004), + 72: uint16(24986), + 73: uint16(24996), + 74: uint16(24980), + 75: uint16(25006), + 76: uint16(25134), + 77: uint16(25705), + 78: uint16(25711), + 79: uint16(25721), + 80: uint16(25758), + 81: uint16(25778), + 82: uint16(25736), + 83: uint16(25744), + 84: uint16(25776), + 85: uint16(25765), + 86: uint16(25747), + 87: uint16(25749), + 88: uint16(25769), + 89: uint16(25746), + 90: uint16(25774), + 91: uint16(25773), + 92: uint16(25771), + 93: uint16(25754), + 94: uint16(25772), + 95: uint16(25753), + 96: uint16(25762), + 97: uint16(25779), + 98: uint16(25973), + 99: uint16(25975), + 100: uint16(25976), + 101: uint16(26286), + 102: uint16(26283), + 103: uint16(26292), + 104: uint16(26289), + 105: uint16(27171), + 106: uint16(27167), + 107: uint16(27112), + 108: uint16(27137), + 109: uint16(27166), + 110: uint16(27161), + 111: uint16(27133), + 112: uint16(27169), + 113: uint16(27155), + 114: uint16(27146), + 115: uint16(27123), + 116: uint16(27138), + 117: uint16(27141), + 118: uint16(27117), + 119: uint16(27153), + 120: uint16(27472), + 121: uint16(27470), + 122: uint16(27556), + 123: uint16(27589), + 124: uint16(27590), + 125: uint16(28479), + 126: uint16(28540), + 127: uint16(28548), + 128: uint16(28497), + 129: uint16(28518), + 130: uint16(28500), + 131: uint16(28550), + 132: uint16(28525), + 133: uint16(28507), + 134: uint16(28536), + 135: uint16(28526), + 136: uint16(28558), + 137: uint16(28538), + 138: uint16(28528), + 139: uint16(28516), + 140: uint16(28567), + 141: uint16(28504), + 142: uint16(28373), + 143: uint16(28527), + 144: uint16(28512), + 145: uint16(28511), + 146: uint16(29087), + 147: uint16(29100), + 148: uint16(29105), + 149: uint16(29096), + 150: uint16(29270), + 151: uint16(29339), + 152: uint16(29518), + 153: uint16(29527), + 154: uint16(29801), + 155: uint16(29835), + 156: uint16(29827), + }, + 28: { + 0: uint16(29822), + 1: uint16(29824), + 2: uint16(30079), + 3: uint16(30240), + 4: uint16(30249), + 5: uint16(30239), + 6: uint16(30244), + 7: uint16(30246), + 8: uint16(30241), + 9: uint16(30242), + 10: uint16(30362), + 11: uint16(30394), + 12: uint16(30436), + 13: uint16(30606), + 14: uint16(30599), + 15: uint16(30604), + 16: uint16(30609), + 17: uint16(30603), + 18: uint16(30923), + 19: uint16(30917), + 20: uint16(30906), + 21: uint16(30922), + 22: uint16(30910), + 23: uint16(30933), + 24: uint16(30908), + 25: uint16(30928), + 26: uint16(31295), + 27: uint16(31292), + 28: uint16(31296), + 29: uint16(31293), + 30: uint16(31287), + 31: uint16(31291), + 32: uint16(31407), + 33: uint16(31406), + 34: uint16(31661), + 35: uint16(31665), + 36: uint16(31684), + 37: uint16(31668), + 38: uint16(31686), + 39: uint16(31687), + 40: uint16(31681), + 41: uint16(31648), + 42: uint16(31692), + 43: uint16(31946), + 44: uint16(32224), + 45: uint16(32244), + 46: uint16(32239), + 47: uint16(32251), + 48: uint16(32216), + 49: uint16(32236), + 50: uint16(32221), + 51: uint16(32232), + 52: uint16(32227), + 53: uint16(32218), + 54: uint16(32222), + 55: uint16(32233), + 56: uint16(32158), + 57: uint16(32217), + 58: uint16(32242), + 59: uint16(32249), + 60: uint16(32629), + 61: uint16(32631), + 62: uint16(32687), + 63: uint16(32745), + 64: uint16(32806), + 65: uint16(33179), + 66: uint16(33180), + 67: uint16(33181), + 68: uint16(33184), + 69: uint16(33178), + 70: uint16(33176), + 71: uint16(34071), + 72: uint16(34109), + 73: uint16(34074), + 74: uint16(34030), + 75: uint16(34092), + 76: uint16(34093), + 77: uint16(34067), + 78: uint16(34065), + 79: uint16(34083), + 80: uint16(34081), + 81: uint16(34068), + 82: uint16(34028), + 83: uint16(34085), + 84: uint16(34047), + 85: uint16(34054), + 86: uint16(34690), + 87: uint16(34676), + 88: uint16(34678), + 89: uint16(34656), + 90: uint16(34662), + 91: uint16(34680), + 92: uint16(34664), + 93: uint16(34649), + 94: uint16(34647), + 95: uint16(34636), + 96: uint16(34643), + 97: uint16(34907), + 98: uint16(34909), + 99: uint16(35088), + 100: uint16(35079), + 101: uint16(35090), + 102: uint16(35091), + 103: uint16(35093), + 104: uint16(35082), + 105: uint16(35516), + 106: uint16(35538), + 107: uint16(35527), + 108: uint16(35524), + 109: uint16(35477), + 110: uint16(35531), + 111: uint16(35576), + 112: uint16(35506), + 113: uint16(35529), + 114: uint16(35522), + 115: uint16(35519), + 116: uint16(35504), + 117: uint16(35542), + 118: uint16(35533), + 119: uint16(35510), + 120: uint16(35513), + 121: uint16(35547), + 122: uint16(35916), + 123: uint16(35918), + 124: uint16(35948), + 125: uint16(36064), + 126: uint16(36062), + 127: uint16(36070), + 128: uint16(36068), + 129: uint16(36076), + 130: uint16(36077), + 131: uint16(36066), + 132: uint16(36067), + 133: uint16(36060), + 134: uint16(36074), + 135: uint16(36065), + 136: uint16(36205), + 137: uint16(36255), + 138: uint16(36259), + 139: uint16(36395), + 140: uint16(36368), + 141: uint16(36381), + 142: uint16(36386), + 143: uint16(36367), + 144: uint16(36393), + 145: uint16(36383), + 146: uint16(36385), + 147: uint16(36382), + 148: uint16(36538), + 149: uint16(36637), + 150: uint16(36635), + 151: uint16(36639), + 152: uint16(36649), + 153: uint16(36646), + 154: uint16(36650), + 155: uint16(36636), + 156: uint16(36638), + }, + 29: { + 0: uint16(36645), + 1: uint16(36969), + 2: uint16(36974), + 3: uint16(36968), + 4: uint16(36973), + 5: uint16(36983), + 6: uint16(37168), + 7: uint16(37165), + 8: uint16(37159), + 9: uint16(37169), + 10: uint16(37255), + 11: uint16(37257), + 12: uint16(37259), + 13: uint16(37251), + 14: uint16(37573), + 15: uint16(37563), + 16: uint16(37559), + 17: uint16(37610), + 18: uint16(37548), + 19: uint16(37604), + 20: uint16(37569), + 21: uint16(37555), + 22: uint16(37564), + 23: uint16(37586), + 24: uint16(37575), + 25: uint16(37616), + 26: uint16(37554), + 27: uint16(38317), + 28: uint16(38321), + 29: uint16(38660), + 30: uint16(38662), + 31: uint16(38663), + 32: uint16(38665), + 33: uint16(38752), + 34: uint16(38797), + 35: uint16(38795), + 36: uint16(38799), + 37: uint16(38945), + 38: uint16(38955), + 39: uint16(38940), + 40: uint16(39091), + 41: uint16(39178), + 42: uint16(39187), + 43: uint16(39186), + 44: uint16(39192), + 45: uint16(39389), + 46: uint16(39376), + 47: uint16(39391), + 48: uint16(39387), + 49: uint16(39377), + 50: uint16(39381), + 51: uint16(39378), + 52: uint16(39385), + 53: uint16(39607), + 54: uint16(39662), + 55: uint16(39663), + 56: uint16(39719), + 57: uint16(39749), + 58: uint16(39748), + 59: uint16(39799), + 60: uint16(39791), + 61: uint16(40198), + 62: uint16(40201), + 63: uint16(40195), + 64: uint16(40617), + 65: uint16(40638), + 66: uint16(40654), + 67: uint16(22696), + 68: uint16(40786), + 69: uint16(20754), + 70: uint16(20760), + 71: uint16(20756), + 72: uint16(20752), + 73: uint16(20757), + 74: uint16(20864), + 75: uint16(20906), + 76: uint16(20957), + 77: uint16(21137), + 78: uint16(21139), + 79: uint16(21235), + 80: uint16(22105), + 81: uint16(22123), + 82: uint16(22137), + 83: uint16(22121), + 84: uint16(22116), + 85: uint16(22136), + 86: uint16(22122), + 87: uint16(22120), + 88: uint16(22117), + 89: uint16(22129), + 90: uint16(22127), + 91: uint16(22124), + 92: uint16(22114), + 93: uint16(22134), + 94: uint16(22721), + 95: uint16(22718), + 96: uint16(22727), + 97: uint16(22725), + 98: uint16(22894), + 99: uint16(23325), + 100: uint16(23348), + 101: uint16(23416), + 102: uint16(23536), + 103: uint16(23566), + 104: uint16(24394), + 105: uint16(25010), + 106: uint16(24977), + 107: uint16(25001), + 108: uint16(24970), + 109: uint16(25037), + 110: uint16(25014), + 111: uint16(25022), + 112: uint16(25034), + 113: uint16(25032), + 114: uint16(25136), + 115: uint16(25797), + 116: uint16(25793), + 117: uint16(25803), + 118: uint16(25787), + 119: uint16(25788), + 120: uint16(25818), + 121: uint16(25796), + 122: uint16(25799), + 123: uint16(25794), + 124: uint16(25805), + 125: uint16(25791), + 126: uint16(25810), + 127: uint16(25812), + 128: uint16(25790), + 129: uint16(25972), + 130: uint16(26310), + 131: uint16(26313), + 132: uint16(26297), + 133: uint16(26308), + 134: uint16(26311), + 135: uint16(26296), + 136: uint16(27197), + 137: uint16(27192), + 138: uint16(27194), + 139: uint16(27225), + 140: uint16(27243), + 141: uint16(27224), + 142: uint16(27193), + 143: uint16(27204), + 144: uint16(27234), + 145: uint16(27233), + 146: uint16(27211), + 147: uint16(27207), + 148: uint16(27189), + 149: uint16(27231), + 150: uint16(27208), + 151: uint16(27481), + 152: uint16(27511), + 153: uint16(27653), + 154: uint16(28610), + 155: uint16(28593), + 156: uint16(28577), + }, + 30: { + 0: uint16(28611), + 1: uint16(28580), + 2: uint16(28609), + 3: uint16(28583), + 4: uint16(28595), + 5: uint16(28608), + 6: uint16(28601), + 7: uint16(28598), + 8: uint16(28582), + 9: uint16(28576), + 10: uint16(28596), + 11: uint16(29118), + 12: uint16(29129), + 13: uint16(29136), + 14: uint16(29138), + 15: uint16(29128), + 16: uint16(29141), + 17: uint16(29113), + 18: uint16(29134), + 19: uint16(29145), + 20: uint16(29148), + 21: uint16(29123), + 22: uint16(29124), + 23: uint16(29544), + 24: uint16(29852), + 25: uint16(29859), + 26: uint16(29848), + 27: uint16(29855), + 28: uint16(29854), + 29: uint16(29922), + 30: uint16(29964), + 31: uint16(29965), + 32: uint16(30260), + 33: uint16(30264), + 34: uint16(30266), + 35: uint16(30439), + 36: uint16(30437), + 37: uint16(30624), + 38: uint16(30622), + 39: uint16(30623), + 40: uint16(30629), + 41: uint16(30952), + 42: uint16(30938), + 43: uint16(30956), + 44: uint16(30951), + 45: uint16(31142), + 46: uint16(31309), + 47: uint16(31310), + 48: uint16(31302), + 49: uint16(31308), + 50: uint16(31307), + 51: uint16(31418), + 52: uint16(31705), + 53: uint16(31761), + 54: uint16(31689), + 55: uint16(31716), + 56: uint16(31707), + 57: uint16(31713), + 58: uint16(31721), + 59: uint16(31718), + 60: uint16(31957), + 61: uint16(31958), + 62: uint16(32266), + 63: uint16(32273), + 64: uint16(32264), + 65: uint16(32283), + 66: uint16(32291), + 67: uint16(32286), + 68: uint16(32285), + 69: uint16(32265), + 70: uint16(32272), + 71: uint16(32633), + 72: uint16(32690), + 73: uint16(32752), + 74: uint16(32753), + 75: uint16(32750), + 76: uint16(32808), + 77: uint16(33203), + 78: uint16(33193), + 79: uint16(33192), + 80: uint16(33275), + 81: uint16(33288), + 82: uint16(33368), + 83: uint16(33369), + 84: uint16(34122), + 85: uint16(34137), + 86: uint16(34120), + 87: uint16(34152), + 88: uint16(34153), + 89: uint16(34115), + 90: uint16(34121), + 91: uint16(34157), + 92: uint16(34154), + 93: uint16(34142), + 94: uint16(34691), + 95: uint16(34719), + 96: uint16(34718), + 97: uint16(34722), + 98: uint16(34701), + 99: uint16(34913), + 100: uint16(35114), + 101: uint16(35122), + 102: uint16(35109), + 103: uint16(35115), + 104: uint16(35105), + 105: uint16(35242), + 106: uint16(35238), + 107: uint16(35558), + 108: uint16(35578), + 109: uint16(35563), + 110: uint16(35569), + 111: uint16(35584), + 112: uint16(35548), + 113: uint16(35559), + 114: uint16(35566), + 115: uint16(35582), + 116: uint16(35585), + 117: uint16(35586), + 118: uint16(35575), + 119: uint16(35565), + 120: uint16(35571), + 121: uint16(35574), + 122: uint16(35580), + 123: uint16(35947), + 124: uint16(35949), + 125: uint16(35987), + 126: uint16(36084), + 127: uint16(36420), + 128: uint16(36401), + 129: uint16(36404), + 130: uint16(36418), + 131: uint16(36409), + 132: uint16(36405), + 133: uint16(36667), + 134: uint16(36655), + 135: uint16(36664), + 136: uint16(36659), + 137: uint16(36776), + 138: uint16(36774), + 139: uint16(36981), + 140: uint16(36980), + 141: uint16(36984), + 142: uint16(36978), + 143: uint16(36988), + 144: uint16(36986), + 145: uint16(37172), + 146: uint16(37266), + 147: uint16(37664), + 148: uint16(37686), + 149: uint16(37624), + 150: uint16(37683), + 151: uint16(37679), + 152: uint16(37666), + 153: uint16(37628), + 154: uint16(37675), + 155: uint16(37636), + 156: uint16(37658), + }, + 31: { + 0: uint16(37648), + 1: uint16(37670), + 2: uint16(37665), + 3: uint16(37653), + 4: uint16(37678), + 5: uint16(37657), + 6: uint16(38331), + 7: uint16(38567), + 8: uint16(38568), + 9: uint16(38570), + 10: uint16(38613), + 11: uint16(38670), + 12: uint16(38673), + 13: uint16(38678), + 14: uint16(38669), + 15: uint16(38675), + 16: uint16(38671), + 17: uint16(38747), + 18: uint16(38748), + 19: uint16(38758), + 20: uint16(38808), + 21: uint16(38960), + 22: uint16(38968), + 23: uint16(38971), + 24: uint16(38967), + 25: uint16(38957), + 26: uint16(38969), + 27: uint16(38948), + 28: uint16(39184), + 29: uint16(39208), + 30: uint16(39198), + 31: uint16(39195), + 32: uint16(39201), + 33: uint16(39194), + 34: uint16(39405), + 35: uint16(39394), + 36: uint16(39409), + 37: uint16(39608), + 38: uint16(39612), + 39: uint16(39675), + 40: uint16(39661), + 41: uint16(39720), + 42: uint16(39825), + 43: uint16(40213), + 44: uint16(40227), + 45: uint16(40230), + 46: uint16(40232), + 47: uint16(40210), + 48: uint16(40219), + 49: uint16(40664), + 50: uint16(40660), + 51: uint16(40845), + 52: uint16(40860), + 53: uint16(20778), + 54: uint16(20767), + 55: uint16(20769), + 56: uint16(20786), + 57: uint16(21237), + 58: uint16(22158), + 59: uint16(22144), + 60: uint16(22160), + 61: uint16(22149), + 62: uint16(22151), + 63: uint16(22159), + 64: uint16(22741), + 65: uint16(22739), + 66: uint16(22737), + 67: uint16(22734), + 68: uint16(23344), + 69: uint16(23338), + 70: uint16(23332), + 71: uint16(23418), + 72: uint16(23607), + 73: uint16(23656), + 74: uint16(23996), + 75: uint16(23994), + 76: uint16(23997), + 77: uint16(23992), + 78: uint16(24171), + 79: uint16(24396), + 80: uint16(24509), + 81: uint16(25033), + 82: uint16(25026), + 83: uint16(25031), + 84: uint16(25062), + 85: uint16(25035), + 86: uint16(25138), + 87: uint16(25140), + 88: uint16(25806), + 89: uint16(25802), + 90: uint16(25816), + 91: uint16(25824), + 92: uint16(25840), + 93: uint16(25830), + 94: uint16(25836), + 95: uint16(25841), + 96: uint16(25826), + 97: uint16(25837), + 98: uint16(25986), + 99: uint16(25987), + 100: uint16(26329), + 101: uint16(26326), + 102: uint16(27264), + 103: uint16(27284), + 104: uint16(27268), + 105: uint16(27298), + 106: uint16(27292), + 107: uint16(27355), + 108: uint16(27299), + 109: uint16(27262), + 110: uint16(27287), + 111: uint16(27280), + 112: uint16(27296), + 113: uint16(27484), + 114: uint16(27566), + 115: uint16(27610), + 116: uint16(27656), + 117: uint16(28632), + 118: uint16(28657), + 119: uint16(28639), + 120: uint16(28640), + 121: uint16(28635), + 122: uint16(28644), + 123: uint16(28651), + 124: uint16(28655), + 125: uint16(28544), + 126: uint16(28652), + 127: uint16(28641), + 128: uint16(28649), + 129: uint16(28629), + 130: uint16(28654), + 131: uint16(28656), + 132: uint16(29159), + 133: uint16(29151), + 134: uint16(29166), + 135: uint16(29158), + 136: uint16(29157), + 137: uint16(29165), + 138: uint16(29164), + 139: uint16(29172), + 140: uint16(29152), + 141: uint16(29237), + 142: uint16(29254), + 143: uint16(29552), + 144: uint16(29554), + 145: uint16(29865), + 146: uint16(29872), + 147: uint16(29862), + 148: uint16(29864), + 149: uint16(30278), + 150: uint16(30274), + 151: uint16(30284), + 152: uint16(30442), + 153: uint16(30643), + 154: uint16(30634), + 155: uint16(30640), + 156: uint16(30636), + }, + 32: { + 0: uint16(30631), + 1: uint16(30637), + 2: uint16(30703), + 3: uint16(30967), + 4: uint16(30970), + 5: uint16(30964), + 6: uint16(30959), + 7: uint16(30977), + 8: uint16(31143), + 9: uint16(31146), + 10: uint16(31319), + 11: uint16(31423), + 12: uint16(31751), + 13: uint16(31757), + 14: uint16(31742), + 15: uint16(31735), + 16: uint16(31756), + 17: uint16(31712), + 18: uint16(31968), + 19: uint16(31964), + 20: uint16(31966), + 21: uint16(31970), + 22: uint16(31967), + 23: uint16(31961), + 24: uint16(31965), + 25: uint16(32302), + 26: uint16(32318), + 27: uint16(32326), + 28: uint16(32311), + 29: uint16(32306), + 30: uint16(32323), + 31: uint16(32299), + 32: uint16(32317), + 33: uint16(32305), + 34: uint16(32325), + 35: uint16(32321), + 36: uint16(32308), + 37: uint16(32313), + 38: uint16(32328), + 39: uint16(32309), + 40: uint16(32319), + 41: uint16(32303), + 42: uint16(32580), + 43: uint16(32755), + 44: uint16(32764), + 45: uint16(32881), + 46: uint16(32882), + 47: uint16(32880), + 48: uint16(32879), + 49: uint16(32883), + 50: uint16(33222), + 51: uint16(33219), + 52: uint16(33210), + 53: uint16(33218), + 54: uint16(33216), + 55: uint16(33215), + 56: uint16(33213), + 57: uint16(33225), + 58: uint16(33214), + 59: uint16(33256), + 60: uint16(33289), + 61: uint16(33393), + 62: uint16(34218), + 63: uint16(34180), + 64: uint16(34174), + 65: uint16(34204), + 66: uint16(34193), + 67: uint16(34196), + 68: uint16(34223), + 69: uint16(34203), + 70: uint16(34183), + 71: uint16(34216), + 72: uint16(34186), + 73: uint16(34407), + 74: uint16(34752), + 75: uint16(34769), + 76: uint16(34739), + 77: uint16(34770), + 78: uint16(34758), + 79: uint16(34731), + 80: uint16(34747), + 81: uint16(34746), + 82: uint16(34760), + 83: uint16(34763), + 84: uint16(35131), + 85: uint16(35126), + 86: uint16(35140), + 87: uint16(35128), + 88: uint16(35133), + 89: uint16(35244), + 90: uint16(35598), + 91: uint16(35607), + 92: uint16(35609), + 93: uint16(35611), + 94: uint16(35594), + 95: uint16(35616), + 96: uint16(35613), + 97: uint16(35588), + 98: uint16(35600), + 99: uint16(35905), + 100: uint16(35903), + 101: uint16(35955), + 102: uint16(36090), + 103: uint16(36093), + 104: uint16(36092), + 105: uint16(36088), + 106: uint16(36091), + 107: uint16(36264), + 108: uint16(36425), + 109: uint16(36427), + 110: uint16(36424), + 111: uint16(36426), + 112: uint16(36676), + 113: uint16(36670), + 114: uint16(36674), + 115: uint16(36677), + 116: uint16(36671), + 117: uint16(36991), + 118: uint16(36989), + 119: uint16(36996), + 120: uint16(36993), + 121: uint16(36994), + 122: uint16(36992), + 123: uint16(37177), + 124: uint16(37283), + 125: uint16(37278), + 126: uint16(37276), + 127: uint16(37709), + 128: uint16(37762), + 129: uint16(37672), + 130: uint16(37749), + 131: uint16(37706), + 132: uint16(37733), + 133: uint16(37707), + 134: uint16(37656), + 135: uint16(37758), + 136: uint16(37740), + 137: uint16(37723), + 138: uint16(37744), + 139: uint16(37722), + 140: uint16(37716), + 141: uint16(38346), + 142: uint16(38347), + 143: uint16(38348), + 144: uint16(38344), + 145: uint16(38342), + 146: uint16(38577), + 147: uint16(38584), + 148: uint16(38614), + 149: uint16(38684), + 150: uint16(38686), + 151: uint16(38816), + 152: uint16(38867), + 153: uint16(38982), + 154: uint16(39094), + 155: uint16(39221), + 156: uint16(39425), + }, + 33: { + 0: uint16(39423), + 1: uint16(39854), + 2: uint16(39851), + 3: uint16(39850), + 4: uint16(39853), + 5: uint16(40251), + 6: uint16(40255), + 7: uint16(40587), + 8: uint16(40655), + 9: uint16(40670), + 10: uint16(40668), + 11: uint16(40669), + 12: uint16(40667), + 13: uint16(40766), + 14: uint16(40779), + 15: uint16(21474), + 16: uint16(22165), + 17: uint16(22190), + 18: uint16(22745), + 19: uint16(22744), + 20: uint16(23352), + 21: uint16(24413), + 22: uint16(25059), + 23: uint16(25139), + 24: uint16(25844), + 25: uint16(25842), + 26: uint16(25854), + 27: uint16(25862), + 28: uint16(25850), + 29: uint16(25851), + 30: uint16(25847), + 31: uint16(26039), + 32: uint16(26332), + 33: uint16(26406), + 34: uint16(27315), + 35: uint16(27308), + 36: uint16(27331), + 37: uint16(27323), + 38: uint16(27320), + 39: uint16(27330), + 40: uint16(27310), + 41: uint16(27311), + 42: uint16(27487), + 43: uint16(27512), + 44: uint16(27567), + 45: uint16(28681), + 46: uint16(28683), + 47: uint16(28670), + 48: uint16(28678), + 49: uint16(28666), + 50: uint16(28689), + 51: uint16(28687), + 52: uint16(29179), + 53: uint16(29180), + 54: uint16(29182), + 55: uint16(29176), + 56: uint16(29559), + 57: uint16(29557), + 58: uint16(29863), + 59: uint16(29887), + 60: uint16(29973), + 61: uint16(30294), + 62: uint16(30296), + 63: uint16(30290), + 64: uint16(30653), + 65: uint16(30655), + 66: uint16(30651), + 67: uint16(30652), + 68: uint16(30990), + 69: uint16(31150), + 70: uint16(31329), + 71: uint16(31330), + 72: uint16(31328), + 73: uint16(31428), + 74: uint16(31429), + 75: uint16(31787), + 76: uint16(31783), + 77: uint16(31786), + 78: uint16(31774), + 79: uint16(31779), + 80: uint16(31777), + 81: uint16(31975), + 82: uint16(32340), + 83: uint16(32341), + 84: uint16(32350), + 85: uint16(32346), + 86: uint16(32353), + 87: uint16(32338), + 88: uint16(32345), + 89: uint16(32584), + 90: uint16(32761), + 91: uint16(32763), + 92: uint16(32887), + 93: uint16(32886), + 94: uint16(33229), + 95: uint16(33231), + 96: uint16(33290), + 97: uint16(34255), + 98: uint16(34217), + 99: uint16(34253), + 100: uint16(34256), + 101: uint16(34249), + 102: uint16(34224), + 103: uint16(34234), + 104: uint16(34233), + 105: uint16(34214), + 106: uint16(34799), + 107: uint16(34796), + 108: uint16(34802), + 109: uint16(34784), + 110: uint16(35206), + 111: uint16(35250), + 112: uint16(35316), + 113: uint16(35624), + 114: uint16(35641), + 115: uint16(35628), + 116: uint16(35627), + 117: uint16(35920), + 118: uint16(36101), + 119: uint16(36441), + 120: uint16(36451), + 121: uint16(36454), + 122: uint16(36452), + 123: uint16(36447), + 124: uint16(36437), + 125: uint16(36544), + 126: uint16(36681), + 127: uint16(36685), + 128: uint16(36999), + 129: uint16(36995), + 130: uint16(37000), + 131: uint16(37291), + 132: uint16(37292), + 133: uint16(37328), + 134: uint16(37780), + 135: uint16(37770), + 136: uint16(37782), + 137: uint16(37794), + 138: uint16(37811), + 139: uint16(37806), + 140: uint16(37804), + 141: uint16(37808), + 142: uint16(37784), + 143: uint16(37786), + 144: uint16(37783), + 145: uint16(38356), + 146: uint16(38358), + 147: uint16(38352), + 148: uint16(38357), + 149: uint16(38626), + 150: uint16(38620), + 151: uint16(38617), + 152: uint16(38619), + 153: uint16(38622), + 154: uint16(38692), + 155: uint16(38819), + 156: uint16(38822), + }, + 34: { + 0: uint16(38829), + 1: uint16(38905), + 2: uint16(38989), + 3: uint16(38991), + 4: uint16(38988), + 5: uint16(38990), + 6: uint16(38995), + 7: uint16(39098), + 8: uint16(39230), + 9: uint16(39231), + 10: uint16(39229), + 11: uint16(39214), + 12: uint16(39333), + 13: uint16(39438), + 14: uint16(39617), + 15: uint16(39683), + 16: uint16(39686), + 17: uint16(39759), + 18: uint16(39758), + 19: uint16(39757), + 20: uint16(39882), + 21: uint16(39881), + 22: uint16(39933), + 23: uint16(39880), + 24: uint16(39872), + 25: uint16(40273), + 26: uint16(40285), + 27: uint16(40288), + 28: uint16(40672), + 29: uint16(40725), + 30: uint16(40748), + 31: uint16(20787), + 32: uint16(22181), + 33: uint16(22750), + 34: uint16(22751), + 35: uint16(22754), + 36: uint16(23541), + 37: uint16(40848), + 38: uint16(24300), + 39: uint16(25074), + 40: uint16(25079), + 41: uint16(25078), + 42: uint16(25077), + 43: uint16(25856), + 44: uint16(25871), + 45: uint16(26336), + 46: uint16(26333), + 47: uint16(27365), + 48: uint16(27357), + 49: uint16(27354), + 50: uint16(27347), + 51: uint16(28699), + 52: uint16(28703), + 53: uint16(28712), + 54: uint16(28698), + 55: uint16(28701), + 56: uint16(28693), + 57: uint16(28696), + 58: uint16(29190), + 59: uint16(29197), + 60: uint16(29272), + 61: uint16(29346), + 62: uint16(29560), + 63: uint16(29562), + 64: uint16(29885), + 65: uint16(29898), + 66: uint16(29923), + 67: uint16(30087), + 68: uint16(30086), + 69: uint16(30303), + 70: uint16(30305), + 71: uint16(30663), + 72: uint16(31001), + 73: uint16(31153), + 74: uint16(31339), + 75: uint16(31337), + 76: uint16(31806), + 77: uint16(31807), + 78: uint16(31800), + 79: uint16(31805), + 80: uint16(31799), + 81: uint16(31808), + 82: uint16(32363), + 83: uint16(32365), + 84: uint16(32377), + 85: uint16(32361), + 86: uint16(32362), + 87: uint16(32645), + 88: uint16(32371), + 89: uint16(32694), + 90: uint16(32697), + 91: uint16(32696), + 92: uint16(33240), + 93: uint16(34281), + 94: uint16(34269), + 95: uint16(34282), + 96: uint16(34261), + 97: uint16(34276), + 98: uint16(34277), + 99: uint16(34295), + 100: uint16(34811), + 101: uint16(34821), + 102: uint16(34829), + 103: uint16(34809), + 104: uint16(34814), + 105: uint16(35168), + 106: uint16(35167), + 107: uint16(35158), + 108: uint16(35166), + 109: uint16(35649), + 110: uint16(35676), + 111: uint16(35672), + 112: uint16(35657), + 113: uint16(35674), + 114: uint16(35662), + 115: uint16(35663), + 116: uint16(35654), + 117: uint16(35673), + 118: uint16(36104), + 119: uint16(36106), + 120: uint16(36476), + 121: uint16(36466), + 122: uint16(36487), + 123: uint16(36470), + 124: uint16(36460), + 125: uint16(36474), + 126: uint16(36468), + 127: uint16(36692), + 128: uint16(36686), + 129: uint16(36781), + 130: uint16(37002), + 131: uint16(37003), + 132: uint16(37297), + 133: uint16(37294), + 134: uint16(37857), + 135: uint16(37841), + 136: uint16(37855), + 137: uint16(37827), + 138: uint16(37832), + 139: uint16(37852), + 140: uint16(37853), + 141: uint16(37846), + 142: uint16(37858), + 143: uint16(37837), + 144: uint16(37848), + 145: uint16(37860), + 146: uint16(37847), + 147: uint16(37864), + 148: uint16(38364), + 149: uint16(38580), + 150: uint16(38627), + 151: uint16(38698), + 152: uint16(38695), + 153: uint16(38753), + 154: uint16(38876), + 155: uint16(38907), + 156: uint16(39006), + }, + 35: { + 0: uint16(39000), + 1: uint16(39003), + 2: uint16(39100), + 3: uint16(39237), + 4: uint16(39241), + 5: uint16(39446), + 6: uint16(39449), + 7: uint16(39693), + 8: uint16(39912), + 9: uint16(39911), + 10: uint16(39894), + 11: uint16(39899), + 12: uint16(40329), + 13: uint16(40289), + 14: uint16(40306), + 15: uint16(40298), + 16: uint16(40300), + 17: uint16(40594), + 18: uint16(40599), + 19: uint16(40595), + 20: uint16(40628), + 21: uint16(21240), + 22: uint16(22184), + 23: uint16(22199), + 24: uint16(22198), + 25: uint16(22196), + 26: uint16(22204), + 27: uint16(22756), + 28: uint16(23360), + 29: uint16(23363), + 30: uint16(23421), + 31: uint16(23542), + 32: uint16(24009), + 33: uint16(25080), + 34: uint16(25082), + 35: uint16(25880), + 36: uint16(25876), + 37: uint16(25881), + 38: uint16(26342), + 39: uint16(26407), + 40: uint16(27372), + 41: uint16(28734), + 42: uint16(28720), + 43: uint16(28722), + 44: uint16(29200), + 45: uint16(29563), + 46: uint16(29903), + 47: uint16(30306), + 48: uint16(30309), + 49: uint16(31014), + 50: uint16(31018), + 51: uint16(31020), + 52: uint16(31019), + 53: uint16(31431), + 54: uint16(31478), + 55: uint16(31820), + 56: uint16(31811), + 57: uint16(31821), + 58: uint16(31983), + 59: uint16(31984), + 60: uint16(36782), + 61: uint16(32381), + 62: uint16(32380), + 63: uint16(32386), + 64: uint16(32588), + 65: uint16(32768), + 66: uint16(33242), + 67: uint16(33382), + 68: uint16(34299), + 69: uint16(34297), + 70: uint16(34321), + 71: uint16(34298), + 72: uint16(34310), + 73: uint16(34315), + 74: uint16(34311), + 75: uint16(34314), + 76: uint16(34836), + 77: uint16(34837), + 78: uint16(35172), + 79: uint16(35258), + 80: uint16(35320), + 81: uint16(35696), + 82: uint16(35692), + 83: uint16(35686), + 84: uint16(35695), + 85: uint16(35679), + 86: uint16(35691), + 87: uint16(36111), + 88: uint16(36109), + 89: uint16(36489), + 90: uint16(36481), + 91: uint16(36485), + 92: uint16(36482), + 93: uint16(37300), + 94: uint16(37323), + 95: uint16(37912), + 96: uint16(37891), + 97: uint16(37885), + 98: uint16(38369), + 99: uint16(38704), + 100: uint16(39108), + 101: uint16(39250), + 102: uint16(39249), + 103: uint16(39336), + 104: uint16(39467), + 105: uint16(39472), + 106: uint16(39479), + 107: uint16(39477), + 108: uint16(39955), + 109: uint16(39949), + 110: uint16(40569), + 111: uint16(40629), + 112: uint16(40680), + 113: uint16(40751), + 114: uint16(40799), + 115: uint16(40803), + 116: uint16(40801), + 117: uint16(20791), + 118: uint16(20792), + 119: uint16(22209), + 120: uint16(22208), + 121: uint16(22210), + 122: uint16(22804), + 123: uint16(23660), + 124: uint16(24013), + 125: uint16(25084), + 126: uint16(25086), + 127: uint16(25885), + 128: uint16(25884), + 129: uint16(26005), + 130: uint16(26345), + 131: uint16(27387), + 132: uint16(27396), + 133: uint16(27386), + 134: uint16(27570), + 135: uint16(28748), + 136: uint16(29211), + 137: uint16(29351), + 138: uint16(29910), + 139: uint16(29908), + 140: uint16(30313), + 141: uint16(30675), + 142: uint16(31824), + 143: uint16(32399), + 144: uint16(32396), + 145: uint16(32700), + 146: uint16(34327), + 147: uint16(34349), + 148: uint16(34330), + 149: uint16(34851), + 150: uint16(34850), + 151: uint16(34849), + 152: uint16(34847), + 153: uint16(35178), + 154: uint16(35180), + 155: uint16(35261), + 156: uint16(35700), + }, + 36: { + 0: uint16(35703), + 1: uint16(35709), + 2: uint16(36115), + 3: uint16(36490), + 4: uint16(36493), + 5: uint16(36491), + 6: uint16(36703), + 7: uint16(36783), + 8: uint16(37306), + 9: uint16(37934), + 10: uint16(37939), + 11: uint16(37941), + 12: uint16(37946), + 13: uint16(37944), + 14: uint16(37938), + 15: uint16(37931), + 16: uint16(38370), + 17: uint16(38712), + 18: uint16(38713), + 19: uint16(38706), + 20: uint16(38911), + 21: uint16(39015), + 22: uint16(39013), + 23: uint16(39255), + 24: uint16(39493), + 25: uint16(39491), + 26: uint16(39488), + 27: uint16(39486), + 28: uint16(39631), + 29: uint16(39764), + 30: uint16(39761), + 31: uint16(39981), + 32: uint16(39973), + 33: uint16(40367), + 34: uint16(40372), + 35: uint16(40386), + 36: uint16(40376), + 37: uint16(40605), + 38: uint16(40687), + 39: uint16(40729), + 40: uint16(40796), + 41: uint16(40806), + 42: uint16(40807), + 43: uint16(20796), + 44: uint16(20795), + 45: uint16(22216), + 46: uint16(22218), + 47: uint16(22217), + 48: uint16(23423), + 49: uint16(24020), + 50: uint16(24018), + 51: uint16(24398), + 52: uint16(25087), + 53: uint16(25892), + 54: uint16(27402), + 55: uint16(27489), + 56: uint16(28753), + 57: uint16(28760), + 58: uint16(29568), + 59: uint16(29924), + 60: uint16(30090), + 61: uint16(30318), + 62: uint16(30316), + 63: uint16(31155), + 64: uint16(31840), + 65: uint16(31839), + 66: uint16(32894), + 67: uint16(32893), + 68: uint16(33247), + 69: uint16(35186), + 70: uint16(35183), + 71: uint16(35324), + 72: uint16(35712), + 73: uint16(36118), + 74: uint16(36119), + 75: uint16(36497), + 76: uint16(36499), + 77: uint16(36705), + 78: uint16(37192), + 79: uint16(37956), + 80: uint16(37969), + 81: uint16(37970), + 82: uint16(38717), + 83: uint16(38718), + 84: uint16(38851), + 85: uint16(38849), + 86: uint16(39019), + 87: uint16(39253), + 88: uint16(39509), + 89: uint16(39501), + 90: uint16(39634), + 91: uint16(39706), + 92: uint16(40009), + 93: uint16(39985), + 94: uint16(39998), + 95: uint16(39995), + 96: uint16(40403), + 97: uint16(40407), + 98: uint16(40756), + 99: uint16(40812), + 100: uint16(40810), + 101: uint16(40852), + 102: uint16(22220), + 103: uint16(24022), + 104: uint16(25088), + 105: uint16(25891), + 106: uint16(25899), + 107: uint16(25898), + 108: uint16(26348), + 109: uint16(27408), + 110: uint16(29914), + 111: uint16(31434), + 112: uint16(31844), + 113: uint16(31843), + 114: uint16(31845), + 115: uint16(32403), + 116: uint16(32406), + 117: uint16(32404), + 118: uint16(33250), + 119: uint16(34360), + 120: uint16(34367), + 121: uint16(34865), + 122: uint16(35722), + 123: uint16(37008), + 124: uint16(37007), + 125: uint16(37987), + 126: uint16(37984), + 127: uint16(37988), + 128: uint16(38760), + 129: uint16(39023), + 130: uint16(39260), + 131: uint16(39514), + 132: uint16(39515), + 133: uint16(39511), + 134: uint16(39635), + 135: uint16(39636), + 136: uint16(39633), + 137: uint16(40020), + 138: uint16(40023), + 139: uint16(40022), + 140: uint16(40421), + 141: uint16(40607), + 142: uint16(40692), + 143: uint16(22225), + 144: uint16(22761), + 145: uint16(25900), + 146: uint16(28766), + 147: uint16(30321), + 148: uint16(30322), + 149: uint16(30679), + 150: uint16(32592), + 151: uint16(32648), + 152: uint16(34870), + 153: uint16(34873), + 154: uint16(34914), + 155: uint16(35731), + 156: uint16(35730), + }, + 37: { + 0: uint16(35734), + 1: uint16(33399), + 2: uint16(36123), + 3: uint16(37312), + 4: uint16(37994), + 5: uint16(38722), + 6: uint16(38728), + 7: uint16(38724), + 8: uint16(38854), + 9: uint16(39024), + 10: uint16(39519), + 11: uint16(39714), + 12: uint16(39768), + 13: uint16(40031), + 14: uint16(40441), + 15: uint16(40442), + 16: uint16(40572), + 17: uint16(40573), + 18: uint16(40711), + 19: uint16(40823), + 20: uint16(40818), + 21: uint16(24307), + 22: uint16(27414), + 23: uint16(28771), + 24: uint16(31852), + 25: uint16(31854), + 26: uint16(34875), + 27: uint16(35264), + 28: uint16(36513), + 29: uint16(37313), + 30: uint16(38002), + 31: uint16(38000), + 32: uint16(39025), + 33: uint16(39262), + 34: uint16(39638), + 35: uint16(39715), + 36: uint16(40652), + 37: uint16(28772), + 38: uint16(30682), + 39: uint16(35738), + 40: uint16(38007), + 41: uint16(38857), + 42: uint16(39522), + 43: uint16(39525), + 44: uint16(32412), + 45: uint16(35740), + 46: uint16(36522), + 47: uint16(37317), + 48: uint16(38013), + 49: uint16(38014), + 50: uint16(38012), + 51: uint16(40055), + 52: uint16(40056), + 53: uint16(40695), + 54: uint16(35924), + 55: uint16(38015), + 56: uint16(40474), + 57: uint16(29224), + 58: uint16(39530), + 59: uint16(39729), + 60: uint16(40475), + 61: uint16(40478), + 62: uint16(31858), + 63: uint16(9312), + 64: uint16(9313), + 65: uint16(9314), + 66: uint16(9315), + 67: uint16(9316), + 68: uint16(9317), + 69: uint16(9318), + 70: uint16(9319), + 71: uint16(9320), + 72: uint16(9321), + 73: uint16(9332), + 74: uint16(9333), + 75: uint16(9334), + 76: uint16(9335), + 77: uint16(9336), + 78: uint16(9337), + 79: uint16(9338), + 80: uint16(9339), + 81: uint16(9340), + 82: uint16(9341), + 83: uint16(8560), + 84: uint16(8561), + 85: uint16(8562), + 86: uint16(8563), + 87: uint16(8564), + 88: uint16(8565), + 89: uint16(8566), + 90: uint16(8567), + 91: uint16(8568), + 92: uint16(8569), + 93: uint16(20022), + 94: uint16(20031), + 95: uint16(20101), + 96: uint16(20128), + 97: uint16(20866), + 98: uint16(20886), + 99: uint16(20907), + 100: uint16(21241), + 101: uint16(21304), + 102: uint16(21353), + 103: uint16(21430), + 104: uint16(22794), + 105: uint16(23424), + 106: uint16(24027), + 107: uint16(24186), + 108: uint16(24191), + 109: uint16(24308), + 110: uint16(24400), + 111: uint16(24417), + 112: uint16(25908), + 113: uint16(26080), + 114: uint16(30098), + 115: uint16(30326), + 116: uint16(36789), + 117: uint16(38582), + 118: uint16(168), + 119: uint16(710), + 120: uint16(12541), + 121: uint16(12542), + 122: uint16(12445), + 123: uint16(12446), + 126: uint16(12293), + 127: uint16(12294), + 128: uint16(12295), + 129: uint16(12540), + 130: uint16(65339), + 131: uint16(65341), + 132: uint16(10045), + 133: uint16(12353), + 134: uint16(12354), + 135: uint16(12355), + 136: uint16(12356), + 137: uint16(12357), + 138: uint16(12358), + 139: uint16(12359), + 140: uint16(12360), + 141: uint16(12361), + 142: uint16(12362), + 143: uint16(12363), + 144: uint16(12364), + 145: uint16(12365), + 146: uint16(12366), + 147: uint16(12367), + 148: uint16(12368), + 149: uint16(12369), + 150: uint16(12370), + 151: uint16(12371), + 152: uint16(12372), + 153: uint16(12373), + 154: uint16(12374), + 155: uint16(12375), + 156: uint16(12376), + }, + 38: { + 0: uint16(12377), + 1: uint16(12378), + 2: uint16(12379), + 3: uint16(12380), + 4: uint16(12381), + 5: uint16(12382), + 6: uint16(12383), + 7: uint16(12384), + 8: uint16(12385), + 9: uint16(12386), + 10: uint16(12387), + 11: uint16(12388), + 12: uint16(12389), + 13: uint16(12390), + 14: uint16(12391), + 15: uint16(12392), + 16: uint16(12393), + 17: uint16(12394), + 18: uint16(12395), + 19: uint16(12396), + 20: uint16(12397), + 21: uint16(12398), + 22: uint16(12399), + 23: uint16(12400), + 24: uint16(12401), + 25: uint16(12402), + 26: uint16(12403), + 27: uint16(12404), + 28: uint16(12405), + 29: uint16(12406), + 30: uint16(12407), + 31: uint16(12408), + 32: uint16(12409), + 33: uint16(12410), + 34: uint16(12411), + 35: uint16(12412), + 36: uint16(12413), + 37: uint16(12414), + 38: uint16(12415), + 39: uint16(12416), + 40: uint16(12417), + 41: uint16(12418), + 42: uint16(12419), + 43: uint16(12420), + 44: uint16(12421), + 45: uint16(12422), + 46: uint16(12423), + 47: uint16(12424), + 48: uint16(12425), + 49: uint16(12426), + 50: uint16(12427), + 51: uint16(12428), + 52: uint16(12429), + 53: uint16(12430), + 54: uint16(12431), + 55: uint16(12432), + 56: uint16(12433), + 57: uint16(12434), + 58: uint16(12435), + 59: uint16(12449), + 60: uint16(12450), + 61: uint16(12451), + 62: uint16(12452), + 63: uint16(12453), + 64: uint16(12454), + 65: uint16(12455), + 66: uint16(12456), + 67: uint16(12457), + 68: uint16(12458), + 69: uint16(12459), + 70: uint16(12460), + 71: uint16(12461), + 72: uint16(12462), + 73: uint16(12463), + 74: uint16(12464), + 75: uint16(12465), + 76: uint16(12466), + 77: uint16(12467), + 78: uint16(12468), + 79: uint16(12469), + 80: uint16(12470), + 81: uint16(12471), + 82: uint16(12472), + 83: uint16(12473), + 84: uint16(12474), + 85: uint16(12475), + 86: uint16(12476), + 87: uint16(12477), + 88: uint16(12478), + 89: uint16(12479), + 90: uint16(12480), + 91: uint16(12481), + 92: uint16(12482), + 93: uint16(12483), + 94: uint16(12484), + 95: uint16(12485), + 96: uint16(12486), + 97: uint16(12487), + 98: uint16(12488), + 99: uint16(12489), + 100: uint16(12490), + 101: uint16(12491), + 102: uint16(12492), + 103: uint16(12493), + 104: uint16(12494), + 105: uint16(12495), + 106: uint16(12496), + 107: uint16(12497), + 108: uint16(12498), + 109: uint16(12499), + 110: uint16(12500), + 111: uint16(12501), + 112: uint16(12502), + 113: uint16(12503), + 114: uint16(12504), + 115: uint16(12505), + 116: uint16(12506), + 117: uint16(12507), + 118: uint16(12508), + 119: uint16(12509), + 120: uint16(12510), + 121: uint16(12511), + 122: uint16(12512), + 123: uint16(12513), + 124: uint16(12514), + 125: uint16(12515), + 126: uint16(12516), + 127: uint16(12517), + 128: uint16(12518), + 129: uint16(12519), + 130: uint16(12520), + 131: uint16(12521), + 132: uint16(12522), + 133: uint16(12523), + 134: uint16(12524), + 135: uint16(12525), + 136: uint16(12526), + 137: uint16(12527), + 138: uint16(12528), + 139: uint16(12529), + 140: uint16(12530), + 141: uint16(12531), + 142: uint16(12532), + 143: uint16(12533), + 144: uint16(12534), + 145: uint16(1040), + 146: uint16(1041), + 147: uint16(1042), + 148: uint16(1043), + 149: uint16(1044), + 150: uint16(1045), + 151: uint16(1025), + 152: uint16(1046), + 153: uint16(1047), + 154: uint16(1048), + 155: uint16(1049), + 156: uint16(1050), + }, + 39: { + 0: uint16(1051), + 1: uint16(1052), + 2: uint16(1053), + 3: uint16(1054), + 4: uint16(1055), + 5: uint16(1056), + 6: uint16(1057), + 7: uint16(1058), + 8: uint16(1059), + 9: uint16(1060), + 10: uint16(1061), + 11: uint16(1062), + 12: uint16(1063), + 13: uint16(1064), + 14: uint16(1065), + 15: uint16(1066), + 16: uint16(1067), + 17: uint16(1068), + 18: uint16(1069), + 19: uint16(1070), + 20: uint16(1071), + 21: uint16(1072), + 22: uint16(1073), + 23: uint16(1074), + 24: uint16(1075), + 25: uint16(1076), + 26: uint16(1077), + 27: uint16(1105), + 28: uint16(1078), + 29: uint16(1079), + 30: uint16(1080), + 31: uint16(1081), + 32: uint16(1082), + 33: uint16(1083), + 34: uint16(1084), + 35: uint16(1085), + 36: uint16(1086), + 37: uint16(1087), + 38: uint16(1088), + 39: uint16(1089), + 40: uint16(1090), + 41: uint16(1091), + 42: uint16(1092), + 43: uint16(1093), + 44: uint16(1094), + 45: uint16(1095), + 46: uint16(1096), + 47: uint16(1097), + 48: uint16(1098), + 49: uint16(1099), + 50: uint16(1100), + 51: uint16(1101), + 52: uint16(1102), + 53: uint16(1103), + 54: uint16(8679), + 55: uint16(8632), + 56: uint16(8633), + 57: uint16(12751), + 58: uint16(204), + 59: uint16(20058), + 60: uint16(138), + 61: uint16(20994), + 62: uint16(17553), + 63: uint16(40880), + 64: uint16(20872), + 65: uint16(40881), + 66: uint16(30215), + 107: uint16(65506), + 108: uint16(65508), + 109: uint16(65287), + 110: uint16(65282), + 111: uint16(12849), + 112: uint16(8470), + 113: uint16(8481), + 114: uint16(12443), + 115: uint16(12444), + 116: uint16(11904), + 117: uint16(11908), + 118: uint16(11910), + 119: uint16(11911), + 120: uint16(11912), + 121: uint16(11914), + 122: uint16(11916), + 123: uint16(11917), + 124: uint16(11925), + 125: uint16(11932), + 126: uint16(11933), + 127: uint16(11941), + 128: uint16(11943), + 129: uint16(11946), + 130: uint16(11948), + 131: uint16(11950), + 132: uint16(11958), + 133: uint16(11964), + 134: uint16(11966), + 135: uint16(11974), + 136: uint16(11978), + 137: uint16(11980), + 138: uint16(11981), + 139: uint16(11983), + 140: uint16(11990), + 141: uint16(11991), + 142: uint16(11998), + 143: uint16(12003), + 147: uint16(643), + 148: uint16(592), + 149: uint16(603), + 150: uint16(596), + 151: uint16(629), + 152: uint16(339), + 153: uint16(248), + 154: uint16(331), + 155: uint16(650), + 156: uint16(618), + }, + 40: { + 0: uint16(20034), + 1: uint16(20060), + 2: uint16(20981), + 3: uint16(21274), + 4: uint16(21378), + 5: uint16(19975), + 6: uint16(19980), + 7: uint16(20039), + 8: uint16(20109), + 9: uint16(22231), + 10: uint16(64012), + 11: uint16(23662), + 12: uint16(24435), + 13: uint16(19983), + 14: uint16(20871), + 15: uint16(19982), + 16: uint16(20014), + 17: uint16(20115), + 18: uint16(20162), + 19: uint16(20169), + 20: uint16(20168), + 21: uint16(20888), + 22: uint16(21244), + 23: uint16(21356), + 24: uint16(21433), + 25: uint16(22304), + 26: uint16(22787), + 27: uint16(22828), + 28: uint16(23568), + 29: uint16(24063), + 30: uint16(26081), + 31: uint16(27571), + 32: uint16(27596), + 33: uint16(27668), + 34: uint16(29247), + 35: uint16(20017), + 36: uint16(20028), + 37: uint16(20200), + 38: uint16(20188), + 39: uint16(20201), + 40: uint16(20193), + 41: uint16(20189), + 42: uint16(20186), + 43: uint16(21004), + 44: uint16(21276), + 45: uint16(21324), + 46: uint16(22306), + 47: uint16(22307), + 48: uint16(22807), + 49: uint16(22831), + 50: uint16(23425), + 51: uint16(23428), + 52: uint16(23570), + 53: uint16(23611), + 54: uint16(23668), + 55: uint16(23667), + 56: uint16(24068), + 57: uint16(24192), + 58: uint16(24194), + 59: uint16(24521), + 60: uint16(25097), + 61: uint16(25168), + 62: uint16(27669), + 63: uint16(27702), + 64: uint16(27715), + 65: uint16(27711), + 66: uint16(27707), + 67: uint16(29358), + 68: uint16(29360), + 69: uint16(29578), + 70: uint16(31160), + 71: uint16(32906), + 72: uint16(38430), + 73: uint16(20238), + 74: uint16(20248), + 75: uint16(20268), + 76: uint16(20213), + 77: uint16(20244), + 78: uint16(20209), + 79: uint16(20224), + 80: uint16(20215), + 81: uint16(20232), + 82: uint16(20253), + 83: uint16(20226), + 84: uint16(20229), + 85: uint16(20258), + 86: uint16(20243), + 87: uint16(20228), + 88: uint16(20212), + 89: uint16(20242), + 90: uint16(20913), + 91: uint16(21011), + 92: uint16(21001), + 93: uint16(21008), + 94: uint16(21158), + 95: uint16(21282), + 96: uint16(21279), + 97: uint16(21325), + 98: uint16(21386), + 99: uint16(21511), + 100: uint16(22241), + 101: uint16(22239), + 102: uint16(22318), + 103: uint16(22314), + 104: uint16(22324), + 105: uint16(22844), + 106: uint16(22912), + 107: uint16(22908), + 108: uint16(22917), + 109: uint16(22907), + 110: uint16(22910), + 111: uint16(22903), + 112: uint16(22911), + 113: uint16(23382), + 114: uint16(23573), + 115: uint16(23589), + 116: uint16(23676), + 117: uint16(23674), + 118: uint16(23675), + 119: uint16(23678), + 120: uint16(24031), + 121: uint16(24181), + 122: uint16(24196), + 123: uint16(24322), + 124: uint16(24346), + 125: uint16(24436), + 126: uint16(24533), + 127: uint16(24532), + 128: uint16(24527), + 129: uint16(25180), + 130: uint16(25182), + 131: uint16(25188), + 132: uint16(25185), + 133: uint16(25190), + 134: uint16(25186), + 135: uint16(25177), + 136: uint16(25184), + 137: uint16(25178), + 138: uint16(25189), + 139: uint16(26095), + 140: uint16(26094), + 141: uint16(26430), + 142: uint16(26425), + 143: uint16(26424), + 144: uint16(26427), + 145: uint16(26426), + 146: uint16(26431), + 147: uint16(26428), + 148: uint16(26419), + 149: uint16(27672), + 150: uint16(27718), + 151: uint16(27730), + 152: uint16(27740), + 153: uint16(27727), + 154: uint16(27722), + 155: uint16(27732), + 156: uint16(27723), + }, + 41: { + 0: uint16(27724), + 1: uint16(28785), + 2: uint16(29278), + 3: uint16(29364), + 4: uint16(29365), + 5: uint16(29582), + 6: uint16(29994), + 7: uint16(30335), + 8: uint16(31349), + 9: uint16(32593), + 10: uint16(33400), + 11: uint16(33404), + 12: uint16(33408), + 13: uint16(33405), + 14: uint16(33407), + 15: uint16(34381), + 16: uint16(35198), + 17: uint16(37017), + 18: uint16(37015), + 19: uint16(37016), + 20: uint16(37019), + 21: uint16(37012), + 22: uint16(38434), + 23: uint16(38436), + 24: uint16(38432), + 25: uint16(38435), + 26: uint16(20310), + 27: uint16(20283), + 28: uint16(20322), + 29: uint16(20297), + 30: uint16(20307), + 31: uint16(20324), + 32: uint16(20286), + 33: uint16(20327), + 34: uint16(20306), + 35: uint16(20319), + 36: uint16(20289), + 37: uint16(20312), + 38: uint16(20269), + 39: uint16(20275), + 40: uint16(20287), + 41: uint16(20321), + 42: uint16(20879), + 43: uint16(20921), + 44: uint16(21020), + 45: uint16(21022), + 46: uint16(21025), + 47: uint16(21165), + 48: uint16(21166), + 49: uint16(21257), + 50: uint16(21347), + 51: uint16(21362), + 52: uint16(21390), + 53: uint16(21391), + 54: uint16(21552), + 55: uint16(21559), + 56: uint16(21546), + 57: uint16(21588), + 58: uint16(21573), + 59: uint16(21529), + 60: uint16(21532), + 61: uint16(21541), + 62: uint16(21528), + 63: uint16(21565), + 64: uint16(21583), + 65: uint16(21569), + 66: uint16(21544), + 67: uint16(21540), + 68: uint16(21575), + 69: uint16(22254), + 70: uint16(22247), + 71: uint16(22245), + 72: uint16(22337), + 73: uint16(22341), + 74: uint16(22348), + 75: uint16(22345), + 76: uint16(22347), + 77: uint16(22354), + 78: uint16(22790), + 79: uint16(22848), + 80: uint16(22950), + 81: uint16(22936), + 82: uint16(22944), + 83: uint16(22935), + 84: uint16(22926), + 85: uint16(22946), + 86: uint16(22928), + 87: uint16(22927), + 88: uint16(22951), + 89: uint16(22945), + 90: uint16(23438), + 91: uint16(23442), + 92: uint16(23592), + 93: uint16(23594), + 94: uint16(23693), + 95: uint16(23695), + 96: uint16(23688), + 97: uint16(23691), + 98: uint16(23689), + 99: uint16(23698), + 100: uint16(23690), + 101: uint16(23686), + 102: uint16(23699), + 103: uint16(23701), + 104: uint16(24032), + 105: uint16(24074), + 106: uint16(24078), + 107: uint16(24203), + 108: uint16(24201), + 109: uint16(24204), + 110: uint16(24200), + 111: uint16(24205), + 112: uint16(24325), + 113: uint16(24349), + 114: uint16(24440), + 115: uint16(24438), + 116: uint16(24530), + 117: uint16(24529), + 118: uint16(24528), + 119: uint16(24557), + 120: uint16(24552), + 121: uint16(24558), + 122: uint16(24563), + 123: uint16(24545), + 124: uint16(24548), + 125: uint16(24547), + 126: uint16(24570), + 127: uint16(24559), + 128: uint16(24567), + 129: uint16(24571), + 130: uint16(24576), + 131: uint16(24564), + 132: uint16(25146), + 133: uint16(25219), + 134: uint16(25228), + 135: uint16(25230), + 136: uint16(25231), + 137: uint16(25236), + 138: uint16(25223), + 139: uint16(25201), + 140: uint16(25211), + 141: uint16(25210), + 142: uint16(25200), + 143: uint16(25217), + 144: uint16(25224), + 145: uint16(25207), + 146: uint16(25213), + 147: uint16(25202), + 148: uint16(25204), + 149: uint16(25911), + 150: uint16(26096), + 151: uint16(26100), + 152: uint16(26099), + 153: uint16(26098), + 154: uint16(26101), + 155: uint16(26437), + 156: uint16(26439), + }, + 42: { + 0: uint16(26457), + 1: uint16(26453), + 2: uint16(26444), + 3: uint16(26440), + 4: uint16(26461), + 5: uint16(26445), + 6: uint16(26458), + 7: uint16(26443), + 8: uint16(27600), + 9: uint16(27673), + 10: uint16(27674), + 11: uint16(27768), + 12: uint16(27751), + 13: uint16(27755), + 14: uint16(27780), + 15: uint16(27787), + 16: uint16(27791), + 17: uint16(27761), + 18: uint16(27759), + 19: uint16(27753), + 20: uint16(27802), + 21: uint16(27757), + 22: uint16(27783), + 23: uint16(27797), + 24: uint16(27804), + 25: uint16(27750), + 26: uint16(27763), + 27: uint16(27749), + 28: uint16(27771), + 29: uint16(27790), + 30: uint16(28788), + 31: uint16(28794), + 32: uint16(29283), + 33: uint16(29375), + 34: uint16(29373), + 35: uint16(29379), + 36: uint16(29382), + 37: uint16(29377), + 38: uint16(29370), + 39: uint16(29381), + 40: uint16(29589), + 41: uint16(29591), + 42: uint16(29587), + 43: uint16(29588), + 44: uint16(29586), + 45: uint16(30010), + 46: uint16(30009), + 47: uint16(30100), + 48: uint16(30101), + 49: uint16(30337), + 50: uint16(31037), + 51: uint16(32820), + 52: uint16(32917), + 53: uint16(32921), + 54: uint16(32912), + 55: uint16(32914), + 56: uint16(32924), + 57: uint16(33424), + 58: uint16(33423), + 59: uint16(33413), + 60: uint16(33422), + 61: uint16(33425), + 62: uint16(33427), + 63: uint16(33418), + 64: uint16(33411), + 65: uint16(33412), + 66: uint16(35960), + 67: uint16(36809), + 68: uint16(36799), + 69: uint16(37023), + 70: uint16(37025), + 71: uint16(37029), + 72: uint16(37022), + 73: uint16(37031), + 74: uint16(37024), + 75: uint16(38448), + 76: uint16(38440), + 77: uint16(38447), + 78: uint16(38445), + 79: uint16(20019), + 80: uint16(20376), + 81: uint16(20348), + 82: uint16(20357), + 83: uint16(20349), + 84: uint16(20352), + 85: uint16(20359), + 86: uint16(20342), + 87: uint16(20340), + 88: uint16(20361), + 89: uint16(20356), + 90: uint16(20343), + 91: uint16(20300), + 92: uint16(20375), + 93: uint16(20330), + 94: uint16(20378), + 95: uint16(20345), + 96: uint16(20353), + 97: uint16(20344), + 98: uint16(20368), + 99: uint16(20380), + 100: uint16(20372), + 101: uint16(20382), + 102: uint16(20370), + 103: uint16(20354), + 104: uint16(20373), + 105: uint16(20331), + 106: uint16(20334), + 107: uint16(20894), + 108: uint16(20924), + 109: uint16(20926), + 110: uint16(21045), + 111: uint16(21042), + 112: uint16(21043), + 113: uint16(21062), + 114: uint16(21041), + 115: uint16(21180), + 116: uint16(21258), + 117: uint16(21259), + 118: uint16(21308), + 119: uint16(21394), + 120: uint16(21396), + 121: uint16(21639), + 122: uint16(21631), + 123: uint16(21633), + 124: uint16(21649), + 125: uint16(21634), + 126: uint16(21640), + 127: uint16(21611), + 128: uint16(21626), + 129: uint16(21630), + 130: uint16(21605), + 131: uint16(21612), + 132: uint16(21620), + 133: uint16(21606), + 134: uint16(21645), + 135: uint16(21615), + 136: uint16(21601), + 137: uint16(21600), + 138: uint16(21656), + 139: uint16(21603), + 140: uint16(21607), + 141: uint16(21604), + 142: uint16(22263), + 143: uint16(22265), + 144: uint16(22383), + 145: uint16(22386), + 146: uint16(22381), + 147: uint16(22379), + 148: uint16(22385), + 149: uint16(22384), + 150: uint16(22390), + 151: uint16(22400), + 152: uint16(22389), + 153: uint16(22395), + 154: uint16(22387), + 155: uint16(22388), + 156: uint16(22370), + }, + 43: { + 0: uint16(22376), + 1: uint16(22397), + 2: uint16(22796), + 3: uint16(22853), + 4: uint16(22965), + 5: uint16(22970), + 6: uint16(22991), + 7: uint16(22990), + 8: uint16(22962), + 9: uint16(22988), + 10: uint16(22977), + 11: uint16(22966), + 12: uint16(22972), + 13: uint16(22979), + 14: uint16(22998), + 15: uint16(22961), + 16: uint16(22973), + 17: uint16(22976), + 18: uint16(22984), + 19: uint16(22964), + 20: uint16(22983), + 21: uint16(23394), + 22: uint16(23397), + 23: uint16(23443), + 24: uint16(23445), + 25: uint16(23620), + 26: uint16(23623), + 27: uint16(23726), + 28: uint16(23716), + 29: uint16(23712), + 30: uint16(23733), + 31: uint16(23727), + 32: uint16(23720), + 33: uint16(23724), + 34: uint16(23711), + 35: uint16(23715), + 36: uint16(23725), + 37: uint16(23714), + 38: uint16(23722), + 39: uint16(23719), + 40: uint16(23709), + 41: uint16(23717), + 42: uint16(23734), + 43: uint16(23728), + 44: uint16(23718), + 45: uint16(24087), + 46: uint16(24084), + 47: uint16(24089), + 48: uint16(24360), + 49: uint16(24354), + 50: uint16(24355), + 51: uint16(24356), + 52: uint16(24404), + 53: uint16(24450), + 54: uint16(24446), + 55: uint16(24445), + 56: uint16(24542), + 57: uint16(24549), + 58: uint16(24621), + 59: uint16(24614), + 60: uint16(24601), + 61: uint16(24626), + 62: uint16(24587), + 63: uint16(24628), + 64: uint16(24586), + 65: uint16(24599), + 66: uint16(24627), + 67: uint16(24602), + 68: uint16(24606), + 69: uint16(24620), + 70: uint16(24610), + 71: uint16(24589), + 72: uint16(24592), + 73: uint16(24622), + 74: uint16(24595), + 75: uint16(24593), + 76: uint16(24588), + 77: uint16(24585), + 78: uint16(24604), + 79: uint16(25108), + 80: uint16(25149), + 81: uint16(25261), + 82: uint16(25268), + 83: uint16(25297), + 84: uint16(25278), + 85: uint16(25258), + 86: uint16(25270), + 87: uint16(25290), + 88: uint16(25262), + 89: uint16(25267), + 90: uint16(25263), + 91: uint16(25275), + 92: uint16(25257), + 93: uint16(25264), + 94: uint16(25272), + 95: uint16(25917), + 96: uint16(26024), + 97: uint16(26043), + 98: uint16(26121), + 99: uint16(26108), + 100: uint16(26116), + 101: uint16(26130), + 102: uint16(26120), + 103: uint16(26107), + 104: uint16(26115), + 105: uint16(26123), + 106: uint16(26125), + 107: uint16(26117), + 108: uint16(26109), + 109: uint16(26129), + 110: uint16(26128), + 111: uint16(26358), + 112: uint16(26378), + 113: uint16(26501), + 114: uint16(26476), + 115: uint16(26510), + 116: uint16(26514), + 117: uint16(26486), + 118: uint16(26491), + 119: uint16(26520), + 120: uint16(26502), + 121: uint16(26500), + 122: uint16(26484), + 123: uint16(26509), + 124: uint16(26508), + 125: uint16(26490), + 126: uint16(26527), + 127: uint16(26513), + 128: uint16(26521), + 129: uint16(26499), + 130: uint16(26493), + 131: uint16(26497), + 132: uint16(26488), + 133: uint16(26489), + 134: uint16(26516), + 135: uint16(27429), + 136: uint16(27520), + 137: uint16(27518), + 138: uint16(27614), + 139: uint16(27677), + 140: uint16(27795), + 141: uint16(27884), + 142: uint16(27883), + 143: uint16(27886), + 144: uint16(27865), + 145: uint16(27830), + 146: uint16(27860), + 147: uint16(27821), + 148: uint16(27879), + 149: uint16(27831), + 150: uint16(27856), + 151: uint16(27842), + 152: uint16(27834), + 153: uint16(27843), + 154: uint16(27846), + 155: uint16(27885), + 156: uint16(27890), + }, + 44: { + 0: uint16(27858), + 1: uint16(27869), + 2: uint16(27828), + 3: uint16(27786), + 4: uint16(27805), + 5: uint16(27776), + 6: uint16(27870), + 7: uint16(27840), + 8: uint16(27952), + 9: uint16(27853), + 10: uint16(27847), + 11: uint16(27824), + 12: uint16(27897), + 13: uint16(27855), + 14: uint16(27881), + 15: uint16(27857), + 16: uint16(28820), + 17: uint16(28824), + 18: uint16(28805), + 19: uint16(28819), + 20: uint16(28806), + 21: uint16(28804), + 22: uint16(28817), + 23: uint16(28822), + 24: uint16(28802), + 25: uint16(28826), + 26: uint16(28803), + 27: uint16(29290), + 28: uint16(29398), + 29: uint16(29387), + 30: uint16(29400), + 31: uint16(29385), + 32: uint16(29404), + 33: uint16(29394), + 34: uint16(29396), + 35: uint16(29402), + 36: uint16(29388), + 37: uint16(29393), + 38: uint16(29604), + 39: uint16(29601), + 40: uint16(29613), + 41: uint16(29606), + 42: uint16(29602), + 43: uint16(29600), + 44: uint16(29612), + 45: uint16(29597), + 46: uint16(29917), + 47: uint16(29928), + 48: uint16(30015), + 49: uint16(30016), + 50: uint16(30014), + 51: uint16(30092), + 52: uint16(30104), + 53: uint16(30383), + 54: uint16(30451), + 55: uint16(30449), + 56: uint16(30448), + 57: uint16(30453), + 58: uint16(30712), + 59: uint16(30716), + 60: uint16(30713), + 61: uint16(30715), + 62: uint16(30714), + 63: uint16(30711), + 64: uint16(31042), + 65: uint16(31039), + 66: uint16(31173), + 67: uint16(31352), + 68: uint16(31355), + 69: uint16(31483), + 70: uint16(31861), + 71: uint16(31997), + 72: uint16(32821), + 73: uint16(32911), + 74: uint16(32942), + 75: uint16(32931), + 76: uint16(32952), + 77: uint16(32949), + 78: uint16(32941), + 79: uint16(33312), + 80: uint16(33440), + 81: uint16(33472), + 82: uint16(33451), + 83: uint16(33434), + 84: uint16(33432), + 85: uint16(33435), + 86: uint16(33461), + 87: uint16(33447), + 88: uint16(33454), + 89: uint16(33468), + 90: uint16(33438), + 91: uint16(33466), + 92: uint16(33460), + 93: uint16(33448), + 94: uint16(33441), + 95: uint16(33449), + 96: uint16(33474), + 97: uint16(33444), + 98: uint16(33475), + 99: uint16(33462), + 100: uint16(33442), + 101: uint16(34416), + 102: uint16(34415), + 103: uint16(34413), + 104: uint16(34414), + 105: uint16(35926), + 106: uint16(36818), + 107: uint16(36811), + 108: uint16(36819), + 109: uint16(36813), + 110: uint16(36822), + 111: uint16(36821), + 112: uint16(36823), + 113: uint16(37042), + 114: uint16(37044), + 115: uint16(37039), + 116: uint16(37043), + 117: uint16(37040), + 118: uint16(38457), + 119: uint16(38461), + 120: uint16(38460), + 121: uint16(38458), + 122: uint16(38467), + 123: uint16(20429), + 124: uint16(20421), + 125: uint16(20435), + 126: uint16(20402), + 127: uint16(20425), + 128: uint16(20427), + 129: uint16(20417), + 130: uint16(20436), + 131: uint16(20444), + 132: uint16(20441), + 133: uint16(20411), + 134: uint16(20403), + 135: uint16(20443), + 136: uint16(20423), + 137: uint16(20438), + 138: uint16(20410), + 139: uint16(20416), + 140: uint16(20409), + 141: uint16(20460), + 142: uint16(21060), + 143: uint16(21065), + 144: uint16(21184), + 145: uint16(21186), + 146: uint16(21309), + 147: uint16(21372), + 148: uint16(21399), + 149: uint16(21398), + 150: uint16(21401), + 151: uint16(21400), + 152: uint16(21690), + 153: uint16(21665), + 154: uint16(21677), + 155: uint16(21669), + 156: uint16(21711), + }, + 45: { + 0: uint16(21699), + 1: uint16(33549), + 2: uint16(21687), + 3: uint16(21678), + 4: uint16(21718), + 5: uint16(21686), + 6: uint16(21701), + 7: uint16(21702), + 8: uint16(21664), + 9: uint16(21616), + 10: uint16(21692), + 11: uint16(21666), + 12: uint16(21694), + 13: uint16(21618), + 14: uint16(21726), + 15: uint16(21680), + 16: uint16(22453), + 17: uint16(22430), + 18: uint16(22431), + 19: uint16(22436), + 20: uint16(22412), + 21: uint16(22423), + 22: uint16(22429), + 23: uint16(22427), + 24: uint16(22420), + 25: uint16(22424), + 26: uint16(22415), + 27: uint16(22425), + 28: uint16(22437), + 29: uint16(22426), + 30: uint16(22421), + 31: uint16(22772), + 32: uint16(22797), + 33: uint16(22867), + 34: uint16(23009), + 35: uint16(23006), + 36: uint16(23022), + 37: uint16(23040), + 38: uint16(23025), + 39: uint16(23005), + 40: uint16(23034), + 41: uint16(23037), + 42: uint16(23036), + 43: uint16(23030), + 44: uint16(23012), + 45: uint16(23026), + 46: uint16(23031), + 47: uint16(23003), + 48: uint16(23017), + 49: uint16(23027), + 50: uint16(23029), + 51: uint16(23008), + 52: uint16(23038), + 53: uint16(23028), + 54: uint16(23021), + 55: uint16(23464), + 56: uint16(23628), + 57: uint16(23760), + 58: uint16(23768), + 59: uint16(23756), + 60: uint16(23767), + 61: uint16(23755), + 62: uint16(23771), + 63: uint16(23774), + 64: uint16(23770), + 65: uint16(23753), + 66: uint16(23751), + 67: uint16(23754), + 68: uint16(23766), + 69: uint16(23763), + 70: uint16(23764), + 71: uint16(23759), + 72: uint16(23752), + 73: uint16(23750), + 74: uint16(23758), + 75: uint16(23775), + 76: uint16(23800), + 77: uint16(24057), + 78: uint16(24097), + 79: uint16(24098), + 80: uint16(24099), + 81: uint16(24096), + 82: uint16(24100), + 83: uint16(24240), + 84: uint16(24228), + 85: uint16(24226), + 86: uint16(24219), + 87: uint16(24227), + 88: uint16(24229), + 89: uint16(24327), + 90: uint16(24366), + 91: uint16(24406), + 92: uint16(24454), + 93: uint16(24631), + 94: uint16(24633), + 95: uint16(24660), + 96: uint16(24690), + 97: uint16(24670), + 98: uint16(24645), + 99: uint16(24659), + 100: uint16(24647), + 101: uint16(24649), + 102: uint16(24667), + 103: uint16(24652), + 104: uint16(24640), + 105: uint16(24642), + 106: uint16(24671), + 107: uint16(24612), + 108: uint16(24644), + 109: uint16(24664), + 110: uint16(24678), + 111: uint16(24686), + 112: uint16(25154), + 113: uint16(25155), + 114: uint16(25295), + 115: uint16(25357), + 116: uint16(25355), + 117: uint16(25333), + 118: uint16(25358), + 119: uint16(25347), + 120: uint16(25323), + 121: uint16(25337), + 122: uint16(25359), + 123: uint16(25356), + 124: uint16(25336), + 125: uint16(25334), + 126: uint16(25344), + 127: uint16(25363), + 128: uint16(25364), + 129: uint16(25338), + 130: uint16(25365), + 131: uint16(25339), + 132: uint16(25328), + 133: uint16(25921), + 134: uint16(25923), + 135: uint16(26026), + 136: uint16(26047), + 137: uint16(26166), + 138: uint16(26145), + 139: uint16(26162), + 140: uint16(26165), + 141: uint16(26140), + 142: uint16(26150), + 143: uint16(26146), + 144: uint16(26163), + 145: uint16(26155), + 146: uint16(26170), + 147: uint16(26141), + 148: uint16(26164), + 149: uint16(26169), + 150: uint16(26158), + 151: uint16(26383), + 152: uint16(26384), + 153: uint16(26561), + 154: uint16(26610), + 155: uint16(26568), + 156: uint16(26554), + }, + 46: { + 0: uint16(26588), + 1: uint16(26555), + 2: uint16(26616), + 3: uint16(26584), + 4: uint16(26560), + 5: uint16(26551), + 6: uint16(26565), + 7: uint16(26603), + 8: uint16(26596), + 9: uint16(26591), + 10: uint16(26549), + 11: uint16(26573), + 12: uint16(26547), + 13: uint16(26615), + 14: uint16(26614), + 15: uint16(26606), + 16: uint16(26595), + 17: uint16(26562), + 18: uint16(26553), + 19: uint16(26574), + 20: uint16(26599), + 21: uint16(26608), + 22: uint16(26546), + 23: uint16(26620), + 24: uint16(26566), + 25: uint16(26605), + 26: uint16(26572), + 27: uint16(26542), + 28: uint16(26598), + 29: uint16(26587), + 30: uint16(26618), + 31: uint16(26569), + 32: uint16(26570), + 33: uint16(26563), + 34: uint16(26602), + 35: uint16(26571), + 36: uint16(27432), + 37: uint16(27522), + 38: uint16(27524), + 39: uint16(27574), + 40: uint16(27606), + 41: uint16(27608), + 42: uint16(27616), + 43: uint16(27680), + 44: uint16(27681), + 45: uint16(27944), + 46: uint16(27956), + 47: uint16(27949), + 48: uint16(27935), + 49: uint16(27964), + 50: uint16(27967), + 51: uint16(27922), + 52: uint16(27914), + 53: uint16(27866), + 54: uint16(27955), + 55: uint16(27908), + 56: uint16(27929), + 57: uint16(27962), + 58: uint16(27930), + 59: uint16(27921), + 60: uint16(27904), + 61: uint16(27933), + 62: uint16(27970), + 63: uint16(27905), + 64: uint16(27928), + 65: uint16(27959), + 66: uint16(27907), + 67: uint16(27919), + 68: uint16(27968), + 69: uint16(27911), + 70: uint16(27936), + 71: uint16(27948), + 72: uint16(27912), + 73: uint16(27938), + 74: uint16(27913), + 75: uint16(27920), + 76: uint16(28855), + 77: uint16(28831), + 78: uint16(28862), + 79: uint16(28849), + 80: uint16(28848), + 81: uint16(28833), + 82: uint16(28852), + 83: uint16(28853), + 84: uint16(28841), + 85: uint16(29249), + 86: uint16(29257), + 87: uint16(29258), + 88: uint16(29292), + 89: uint16(29296), + 90: uint16(29299), + 91: uint16(29294), + 92: uint16(29386), + 93: uint16(29412), + 94: uint16(29416), + 95: uint16(29419), + 96: uint16(29407), + 97: uint16(29418), + 98: uint16(29414), + 99: uint16(29411), + 100: uint16(29573), + 101: uint16(29644), + 102: uint16(29634), + 103: uint16(29640), + 104: uint16(29637), + 105: uint16(29625), + 106: uint16(29622), + 107: uint16(29621), + 108: uint16(29620), + 109: uint16(29675), + 110: uint16(29631), + 111: uint16(29639), + 112: uint16(29630), + 113: uint16(29635), + 114: uint16(29638), + 115: uint16(29624), + 116: uint16(29643), + 117: uint16(29932), + 118: uint16(29934), + 119: uint16(29998), + 120: uint16(30023), + 121: uint16(30024), + 122: uint16(30119), + 123: uint16(30122), + 124: uint16(30329), + 125: uint16(30404), + 126: uint16(30472), + 127: uint16(30467), + 128: uint16(30468), + 129: uint16(30469), + 130: uint16(30474), + 131: uint16(30455), + 132: uint16(30459), + 133: uint16(30458), + 134: uint16(30695), + 135: uint16(30696), + 136: uint16(30726), + 137: uint16(30737), + 138: uint16(30738), + 139: uint16(30725), + 140: uint16(30736), + 141: uint16(30735), + 142: uint16(30734), + 143: uint16(30729), + 144: uint16(30723), + 145: uint16(30739), + 146: uint16(31050), + 147: uint16(31052), + 148: uint16(31051), + 149: uint16(31045), + 150: uint16(31044), + 151: uint16(31189), + 152: uint16(31181), + 153: uint16(31183), + 154: uint16(31190), + 155: uint16(31182), + 156: uint16(31360), + }, + 47: { + 0: uint16(31358), + 1: uint16(31441), + 2: uint16(31488), + 3: uint16(31489), + 4: uint16(31866), + 5: uint16(31864), + 6: uint16(31865), + 7: uint16(31871), + 8: uint16(31872), + 9: uint16(31873), + 10: uint16(32003), + 11: uint16(32008), + 12: uint16(32001), + 13: uint16(32600), + 14: uint16(32657), + 15: uint16(32653), + 16: uint16(32702), + 17: uint16(32775), + 18: uint16(32782), + 19: uint16(32783), + 20: uint16(32788), + 21: uint16(32823), + 22: uint16(32984), + 23: uint16(32967), + 24: uint16(32992), + 25: uint16(32977), + 26: uint16(32968), + 27: uint16(32962), + 28: uint16(32976), + 29: uint16(32965), + 30: uint16(32995), + 31: uint16(32985), + 32: uint16(32988), + 33: uint16(32970), + 34: uint16(32981), + 35: uint16(32969), + 36: uint16(32975), + 37: uint16(32983), + 38: uint16(32998), + 39: uint16(32973), + 40: uint16(33279), + 41: uint16(33313), + 42: uint16(33428), + 43: uint16(33497), + 44: uint16(33534), + 45: uint16(33529), + 46: uint16(33543), + 47: uint16(33512), + 48: uint16(33536), + 49: uint16(33493), + 50: uint16(33594), + 51: uint16(33515), + 52: uint16(33494), + 53: uint16(33524), + 54: uint16(33516), + 55: uint16(33505), + 56: uint16(33522), + 57: uint16(33525), + 58: uint16(33548), + 59: uint16(33531), + 60: uint16(33526), + 61: uint16(33520), + 62: uint16(33514), + 63: uint16(33508), + 64: uint16(33504), + 65: uint16(33530), + 66: uint16(33523), + 67: uint16(33517), + 68: uint16(34423), + 69: uint16(34420), + 70: uint16(34428), + 71: uint16(34419), + 72: uint16(34881), + 73: uint16(34894), + 74: uint16(34919), + 75: uint16(34922), + 76: uint16(34921), + 77: uint16(35283), + 78: uint16(35332), + 79: uint16(35335), + 80: uint16(36210), + 81: uint16(36835), + 82: uint16(36833), + 83: uint16(36846), + 84: uint16(36832), + 85: uint16(37105), + 86: uint16(37053), + 87: uint16(37055), + 88: uint16(37077), + 89: uint16(37061), + 90: uint16(37054), + 91: uint16(37063), + 92: uint16(37067), + 93: uint16(37064), + 94: uint16(37332), + 95: uint16(37331), + 96: uint16(38484), + 97: uint16(38479), + 98: uint16(38481), + 99: uint16(38483), + 100: uint16(38474), + 101: uint16(38478), + 102: uint16(20510), + 103: uint16(20485), + 104: uint16(20487), + 105: uint16(20499), + 106: uint16(20514), + 107: uint16(20528), + 108: uint16(20507), + 109: uint16(20469), + 110: uint16(20468), + 111: uint16(20531), + 112: uint16(20535), + 113: uint16(20524), + 114: uint16(20470), + 115: uint16(20471), + 116: uint16(20503), + 117: uint16(20508), + 118: uint16(20512), + 119: uint16(20519), + 120: uint16(20533), + 121: uint16(20527), + 122: uint16(20529), + 123: uint16(20494), + 124: uint16(20826), + 125: uint16(20884), + 126: uint16(20883), + 127: uint16(20938), + 128: uint16(20932), + 129: uint16(20933), + 130: uint16(20936), + 131: uint16(20942), + 132: uint16(21089), + 133: uint16(21082), + 134: uint16(21074), + 135: uint16(21086), + 136: uint16(21087), + 137: uint16(21077), + 138: uint16(21090), + 139: uint16(21197), + 140: uint16(21262), + 141: uint16(21406), + 142: uint16(21798), + 143: uint16(21730), + 144: uint16(21783), + 145: uint16(21778), + 146: uint16(21735), + 147: uint16(21747), + 148: uint16(21732), + 149: uint16(21786), + 150: uint16(21759), + 151: uint16(21764), + 152: uint16(21768), + 153: uint16(21739), + 154: uint16(21777), + 155: uint16(21765), + 156: uint16(21745), + }, + 48: { + 0: uint16(21770), + 1: uint16(21755), + 2: uint16(21751), + 3: uint16(21752), + 4: uint16(21728), + 5: uint16(21774), + 6: uint16(21763), + 7: uint16(21771), + 8: uint16(22273), + 9: uint16(22274), + 10: uint16(22476), + 11: uint16(22578), + 12: uint16(22485), + 13: uint16(22482), + 14: uint16(22458), + 15: uint16(22470), + 16: uint16(22461), + 17: uint16(22460), + 18: uint16(22456), + 19: uint16(22454), + 20: uint16(22463), + 21: uint16(22471), + 22: uint16(22480), + 23: uint16(22457), + 24: uint16(22465), + 25: uint16(22798), + 26: uint16(22858), + 27: uint16(23065), + 28: uint16(23062), + 29: uint16(23085), + 30: uint16(23086), + 31: uint16(23061), + 32: uint16(23055), + 33: uint16(23063), + 34: uint16(23050), + 35: uint16(23070), + 36: uint16(23091), + 37: uint16(23404), + 38: uint16(23463), + 39: uint16(23469), + 40: uint16(23468), + 41: uint16(23555), + 42: uint16(23638), + 43: uint16(23636), + 44: uint16(23788), + 45: uint16(23807), + 46: uint16(23790), + 47: uint16(23793), + 48: uint16(23799), + 49: uint16(23808), + 50: uint16(23801), + 51: uint16(24105), + 52: uint16(24104), + 53: uint16(24232), + 54: uint16(24238), + 55: uint16(24234), + 56: uint16(24236), + 57: uint16(24371), + 58: uint16(24368), + 59: uint16(24423), + 60: uint16(24669), + 61: uint16(24666), + 62: uint16(24679), + 63: uint16(24641), + 64: uint16(24738), + 65: uint16(24712), + 66: uint16(24704), + 67: uint16(24722), + 68: uint16(24705), + 69: uint16(24733), + 70: uint16(24707), + 71: uint16(24725), + 72: uint16(24731), + 73: uint16(24727), + 74: uint16(24711), + 75: uint16(24732), + 76: uint16(24718), + 77: uint16(25113), + 78: uint16(25158), + 79: uint16(25330), + 80: uint16(25360), + 81: uint16(25430), + 82: uint16(25388), + 83: uint16(25412), + 84: uint16(25413), + 85: uint16(25398), + 86: uint16(25411), + 87: uint16(25572), + 88: uint16(25401), + 89: uint16(25419), + 90: uint16(25418), + 91: uint16(25404), + 92: uint16(25385), + 93: uint16(25409), + 94: uint16(25396), + 95: uint16(25432), + 96: uint16(25428), + 97: uint16(25433), + 98: uint16(25389), + 99: uint16(25415), + 100: uint16(25395), + 101: uint16(25434), + 102: uint16(25425), + 103: uint16(25400), + 104: uint16(25431), + 105: uint16(25408), + 106: uint16(25416), + 107: uint16(25930), + 108: uint16(25926), + 109: uint16(26054), + 110: uint16(26051), + 111: uint16(26052), + 112: uint16(26050), + 113: uint16(26186), + 114: uint16(26207), + 115: uint16(26183), + 116: uint16(26193), + 117: uint16(26386), + 118: uint16(26387), + 119: uint16(26655), + 120: uint16(26650), + 121: uint16(26697), + 122: uint16(26674), + 123: uint16(26675), + 124: uint16(26683), + 125: uint16(26699), + 126: uint16(26703), + 127: uint16(26646), + 128: uint16(26673), + 129: uint16(26652), + 130: uint16(26677), + 131: uint16(26667), + 132: uint16(26669), + 133: uint16(26671), + 134: uint16(26702), + 135: uint16(26692), + 136: uint16(26676), + 137: uint16(26653), + 138: uint16(26642), + 139: uint16(26644), + 140: uint16(26662), + 141: uint16(26664), + 142: uint16(26670), + 143: uint16(26701), + 144: uint16(26682), + 145: uint16(26661), + 146: uint16(26656), + 147: uint16(27436), + 148: uint16(27439), + 149: uint16(27437), + 150: uint16(27441), + 151: uint16(27444), + 152: uint16(27501), + 153: uint16(32898), + 154: uint16(27528), + 155: uint16(27622), + 156: uint16(27620), + }, + 49: { + 0: uint16(27624), + 1: uint16(27619), + 2: uint16(27618), + 3: uint16(27623), + 4: uint16(27685), + 5: uint16(28026), + 6: uint16(28003), + 7: uint16(28004), + 8: uint16(28022), + 9: uint16(27917), + 10: uint16(28001), + 11: uint16(28050), + 12: uint16(27992), + 13: uint16(28002), + 14: uint16(28013), + 15: uint16(28015), + 16: uint16(28049), + 17: uint16(28045), + 18: uint16(28143), + 19: uint16(28031), + 20: uint16(28038), + 21: uint16(27998), + 22: uint16(28007), + 23: uint16(28000), + 24: uint16(28055), + 25: uint16(28016), + 26: uint16(28028), + 27: uint16(27999), + 28: uint16(28034), + 29: uint16(28056), + 30: uint16(27951), + 31: uint16(28008), + 32: uint16(28043), + 33: uint16(28030), + 34: uint16(28032), + 35: uint16(28036), + 36: uint16(27926), + 37: uint16(28035), + 38: uint16(28027), + 39: uint16(28029), + 40: uint16(28021), + 41: uint16(28048), + 42: uint16(28892), + 43: uint16(28883), + 44: uint16(28881), + 45: uint16(28893), + 46: uint16(28875), + 47: uint16(32569), + 48: uint16(28898), + 49: uint16(28887), + 50: uint16(28882), + 51: uint16(28894), + 52: uint16(28896), + 53: uint16(28884), + 54: uint16(28877), + 55: uint16(28869), + 56: uint16(28870), + 57: uint16(28871), + 58: uint16(28890), + 59: uint16(28878), + 60: uint16(28897), + 61: uint16(29250), + 62: uint16(29304), + 63: uint16(29303), + 64: uint16(29302), + 65: uint16(29440), + 66: uint16(29434), + 67: uint16(29428), + 68: uint16(29438), + 69: uint16(29430), + 70: uint16(29427), + 71: uint16(29435), + 72: uint16(29441), + 73: uint16(29651), + 74: uint16(29657), + 75: uint16(29669), + 76: uint16(29654), + 77: uint16(29628), + 78: uint16(29671), + 79: uint16(29667), + 80: uint16(29673), + 81: uint16(29660), + 82: uint16(29650), + 83: uint16(29659), + 84: uint16(29652), + 85: uint16(29661), + 86: uint16(29658), + 87: uint16(29655), + 88: uint16(29656), + 89: uint16(29672), + 90: uint16(29918), + 91: uint16(29919), + 92: uint16(29940), + 93: uint16(29941), + 94: uint16(29985), + 95: uint16(30043), + 96: uint16(30047), + 97: uint16(30128), + 98: uint16(30145), + 99: uint16(30139), + 100: uint16(30148), + 101: uint16(30144), + 102: uint16(30143), + 103: uint16(30134), + 104: uint16(30138), + 105: uint16(30346), + 106: uint16(30409), + 107: uint16(30493), + 108: uint16(30491), + 109: uint16(30480), + 110: uint16(30483), + 111: uint16(30482), + 112: uint16(30499), + 113: uint16(30481), + 114: uint16(30485), + 115: uint16(30489), + 116: uint16(30490), + 117: uint16(30498), + 118: uint16(30503), + 119: uint16(30755), + 120: uint16(30764), + 121: uint16(30754), + 122: uint16(30773), + 123: uint16(30767), + 124: uint16(30760), + 125: uint16(30766), + 126: uint16(30763), + 127: uint16(30753), + 128: uint16(30761), + 129: uint16(30771), + 130: uint16(30762), + 131: uint16(30769), + 132: uint16(31060), + 133: uint16(31067), + 134: uint16(31055), + 135: uint16(31068), + 136: uint16(31059), + 137: uint16(31058), + 138: uint16(31057), + 139: uint16(31211), + 140: uint16(31212), + 141: uint16(31200), + 142: uint16(31214), + 143: uint16(31213), + 144: uint16(31210), + 145: uint16(31196), + 146: uint16(31198), + 147: uint16(31197), + 148: uint16(31366), + 149: uint16(31369), + 150: uint16(31365), + 151: uint16(31371), + 152: uint16(31372), + 153: uint16(31370), + 154: uint16(31367), + 155: uint16(31448), + 156: uint16(31504), + }, + 50: { + 0: uint16(31492), + 1: uint16(31507), + 2: uint16(31493), + 3: uint16(31503), + 4: uint16(31496), + 5: uint16(31498), + 6: uint16(31502), + 7: uint16(31497), + 8: uint16(31506), + 9: uint16(31876), + 10: uint16(31889), + 11: uint16(31882), + 12: uint16(31884), + 13: uint16(31880), + 14: uint16(31885), + 15: uint16(31877), + 16: uint16(32030), + 17: uint16(32029), + 18: uint16(32017), + 19: uint16(32014), + 20: uint16(32024), + 21: uint16(32022), + 22: uint16(32019), + 23: uint16(32031), + 24: uint16(32018), + 25: uint16(32015), + 26: uint16(32012), + 27: uint16(32604), + 28: uint16(32609), + 29: uint16(32606), + 30: uint16(32608), + 31: uint16(32605), + 32: uint16(32603), + 33: uint16(32662), + 34: uint16(32658), + 35: uint16(32707), + 36: uint16(32706), + 37: uint16(32704), + 38: uint16(32790), + 39: uint16(32830), + 40: uint16(32825), + 41: uint16(33018), + 42: uint16(33010), + 43: uint16(33017), + 44: uint16(33013), + 45: uint16(33025), + 46: uint16(33019), + 47: uint16(33024), + 48: uint16(33281), + 49: uint16(33327), + 50: uint16(33317), + 51: uint16(33587), + 52: uint16(33581), + 53: uint16(33604), + 54: uint16(33561), + 55: uint16(33617), + 56: uint16(33573), + 57: uint16(33622), + 58: uint16(33599), + 59: uint16(33601), + 60: uint16(33574), + 61: uint16(33564), + 62: uint16(33570), + 63: uint16(33602), + 64: uint16(33614), + 65: uint16(33563), + 66: uint16(33578), + 67: uint16(33544), + 68: uint16(33596), + 69: uint16(33613), + 70: uint16(33558), + 71: uint16(33572), + 72: uint16(33568), + 73: uint16(33591), + 74: uint16(33583), + 75: uint16(33577), + 76: uint16(33607), + 77: uint16(33605), + 78: uint16(33612), + 79: uint16(33619), + 80: uint16(33566), + 81: uint16(33580), + 82: uint16(33611), + 83: uint16(33575), + 84: uint16(33608), + 85: uint16(34387), + 86: uint16(34386), + 87: uint16(34466), + 88: uint16(34472), + 89: uint16(34454), + 90: uint16(34445), + 91: uint16(34449), + 92: uint16(34462), + 93: uint16(34439), + 94: uint16(34455), + 95: uint16(34438), + 96: uint16(34443), + 97: uint16(34458), + 98: uint16(34437), + 99: uint16(34469), + 100: uint16(34457), + 101: uint16(34465), + 102: uint16(34471), + 103: uint16(34453), + 104: uint16(34456), + 105: uint16(34446), + 106: uint16(34461), + 107: uint16(34448), + 108: uint16(34452), + 109: uint16(34883), + 110: uint16(34884), + 111: uint16(34925), + 112: uint16(34933), + 113: uint16(34934), + 114: uint16(34930), + 115: uint16(34944), + 116: uint16(34929), + 117: uint16(34943), + 118: uint16(34927), + 119: uint16(34947), + 120: uint16(34942), + 121: uint16(34932), + 122: uint16(34940), + 123: uint16(35346), + 124: uint16(35911), + 125: uint16(35927), + 126: uint16(35963), + 127: uint16(36004), + 128: uint16(36003), + 129: uint16(36214), + 130: uint16(36216), + 131: uint16(36277), + 132: uint16(36279), + 133: uint16(36278), + 134: uint16(36561), + 135: uint16(36563), + 136: uint16(36862), + 137: uint16(36853), + 138: uint16(36866), + 139: uint16(36863), + 140: uint16(36859), + 141: uint16(36868), + 142: uint16(36860), + 143: uint16(36854), + 144: uint16(37078), + 145: uint16(37088), + 146: uint16(37081), + 147: uint16(37082), + 148: uint16(37091), + 149: uint16(37087), + 150: uint16(37093), + 151: uint16(37080), + 152: uint16(37083), + 153: uint16(37079), + 154: uint16(37084), + 155: uint16(37092), + 156: uint16(37200), + }, + 51: { + 0: uint16(37198), + 1: uint16(37199), + 2: uint16(37333), + 3: uint16(37346), + 4: uint16(37338), + 5: uint16(38492), + 6: uint16(38495), + 7: uint16(38588), + 8: uint16(39139), + 9: uint16(39647), + 10: uint16(39727), + 11: uint16(20095), + 12: uint16(20592), + 13: uint16(20586), + 14: uint16(20577), + 15: uint16(20574), + 16: uint16(20576), + 17: uint16(20563), + 18: uint16(20555), + 19: uint16(20573), + 20: uint16(20594), + 21: uint16(20552), + 22: uint16(20557), + 23: uint16(20545), + 24: uint16(20571), + 25: uint16(20554), + 26: uint16(20578), + 27: uint16(20501), + 28: uint16(20549), + 29: uint16(20575), + 30: uint16(20585), + 31: uint16(20587), + 32: uint16(20579), + 33: uint16(20580), + 34: uint16(20550), + 35: uint16(20544), + 36: uint16(20590), + 37: uint16(20595), + 38: uint16(20567), + 39: uint16(20561), + 40: uint16(20944), + 41: uint16(21099), + 42: uint16(21101), + 43: uint16(21100), + 44: uint16(21102), + 45: uint16(21206), + 46: uint16(21203), + 47: uint16(21293), + 48: uint16(21404), + 49: uint16(21877), + 50: uint16(21878), + 51: uint16(21820), + 52: uint16(21837), + 53: uint16(21840), + 54: uint16(21812), + 55: uint16(21802), + 56: uint16(21841), + 57: uint16(21858), + 58: uint16(21814), + 59: uint16(21813), + 60: uint16(21808), + 61: uint16(21842), + 62: uint16(21829), + 63: uint16(21772), + 64: uint16(21810), + 65: uint16(21861), + 66: uint16(21838), + 67: uint16(21817), + 68: uint16(21832), + 69: uint16(21805), + 70: uint16(21819), + 71: uint16(21824), + 72: uint16(21835), + 73: uint16(22282), + 74: uint16(22279), + 75: uint16(22523), + 76: uint16(22548), + 77: uint16(22498), + 78: uint16(22518), + 79: uint16(22492), + 80: uint16(22516), + 81: uint16(22528), + 82: uint16(22509), + 83: uint16(22525), + 84: uint16(22536), + 85: uint16(22520), + 86: uint16(22539), + 87: uint16(22515), + 88: uint16(22479), + 89: uint16(22535), + 90: uint16(22510), + 91: uint16(22499), + 92: uint16(22514), + 93: uint16(22501), + 94: uint16(22508), + 95: uint16(22497), + 96: uint16(22542), + 97: uint16(22524), + 98: uint16(22544), + 99: uint16(22503), + 100: uint16(22529), + 101: uint16(22540), + 102: uint16(22513), + 103: uint16(22505), + 104: uint16(22512), + 105: uint16(22541), + 106: uint16(22532), + 107: uint16(22876), + 108: uint16(23136), + 109: uint16(23128), + 110: uint16(23125), + 111: uint16(23143), + 112: uint16(23134), + 113: uint16(23096), + 114: uint16(23093), + 115: uint16(23149), + 116: uint16(23120), + 117: uint16(23135), + 118: uint16(23141), + 119: uint16(23148), + 120: uint16(23123), + 121: uint16(23140), + 122: uint16(23127), + 123: uint16(23107), + 124: uint16(23133), + 125: uint16(23122), + 126: uint16(23108), + 127: uint16(23131), + 128: uint16(23112), + 129: uint16(23182), + 130: uint16(23102), + 131: uint16(23117), + 132: uint16(23097), + 133: uint16(23116), + 134: uint16(23152), + 135: uint16(23145), + 136: uint16(23111), + 137: uint16(23121), + 138: uint16(23126), + 139: uint16(23106), + 140: uint16(23132), + 141: uint16(23410), + 142: uint16(23406), + 143: uint16(23489), + 144: uint16(23488), + 145: uint16(23641), + 146: uint16(23838), + 147: uint16(23819), + 148: uint16(23837), + 149: uint16(23834), + 150: uint16(23840), + 151: uint16(23820), + 152: uint16(23848), + 153: uint16(23821), + 154: uint16(23846), + 155: uint16(23845), + 156: uint16(23823), + }, + 52: { + 0: uint16(23856), + 1: uint16(23826), + 2: uint16(23843), + 3: uint16(23839), + 4: uint16(23854), + 5: uint16(24126), + 6: uint16(24116), + 7: uint16(24241), + 8: uint16(24244), + 9: uint16(24249), + 10: uint16(24242), + 11: uint16(24243), + 12: uint16(24374), + 13: uint16(24376), + 14: uint16(24475), + 15: uint16(24470), + 16: uint16(24479), + 17: uint16(24714), + 18: uint16(24720), + 19: uint16(24710), + 20: uint16(24766), + 21: uint16(24752), + 22: uint16(24762), + 23: uint16(24787), + 24: uint16(24788), + 25: uint16(24783), + 26: uint16(24804), + 27: uint16(24793), + 28: uint16(24797), + 29: uint16(24776), + 30: uint16(24753), + 31: uint16(24795), + 32: uint16(24759), + 33: uint16(24778), + 34: uint16(24767), + 35: uint16(24771), + 36: uint16(24781), + 37: uint16(24768), + 38: uint16(25394), + 39: uint16(25445), + 40: uint16(25482), + 41: uint16(25474), + 42: uint16(25469), + 43: uint16(25533), + 44: uint16(25502), + 45: uint16(25517), + 46: uint16(25501), + 47: uint16(25495), + 48: uint16(25515), + 49: uint16(25486), + 50: uint16(25455), + 51: uint16(25479), + 52: uint16(25488), + 53: uint16(25454), + 54: uint16(25519), + 55: uint16(25461), + 56: uint16(25500), + 57: uint16(25453), + 58: uint16(25518), + 59: uint16(25468), + 60: uint16(25508), + 61: uint16(25403), + 62: uint16(25503), + 63: uint16(25464), + 64: uint16(25477), + 65: uint16(25473), + 66: uint16(25489), + 67: uint16(25485), + 68: uint16(25456), + 69: uint16(25939), + 70: uint16(26061), + 71: uint16(26213), + 72: uint16(26209), + 73: uint16(26203), + 74: uint16(26201), + 75: uint16(26204), + 76: uint16(26210), + 77: uint16(26392), + 78: uint16(26745), + 79: uint16(26759), + 80: uint16(26768), + 81: uint16(26780), + 82: uint16(26733), + 83: uint16(26734), + 84: uint16(26798), + 85: uint16(26795), + 86: uint16(26966), + 87: uint16(26735), + 88: uint16(26787), + 89: uint16(26796), + 90: uint16(26793), + 91: uint16(26741), + 92: uint16(26740), + 93: uint16(26802), + 94: uint16(26767), + 95: uint16(26743), + 96: uint16(26770), + 97: uint16(26748), + 98: uint16(26731), + 99: uint16(26738), + 100: uint16(26794), + 101: uint16(26752), + 102: uint16(26737), + 103: uint16(26750), + 104: uint16(26779), + 105: uint16(26774), + 106: uint16(26763), + 107: uint16(26784), + 108: uint16(26761), + 109: uint16(26788), + 110: uint16(26744), + 111: uint16(26747), + 112: uint16(26769), + 113: uint16(26764), + 114: uint16(26762), + 115: uint16(26749), + 116: uint16(27446), + 117: uint16(27443), + 118: uint16(27447), + 119: uint16(27448), + 120: uint16(27537), + 121: uint16(27535), + 122: uint16(27533), + 123: uint16(27534), + 124: uint16(27532), + 125: uint16(27690), + 126: uint16(28096), + 127: uint16(28075), + 128: uint16(28084), + 129: uint16(28083), + 130: uint16(28276), + 131: uint16(28076), + 132: uint16(28137), + 133: uint16(28130), + 134: uint16(28087), + 135: uint16(28150), + 136: uint16(28116), + 137: uint16(28160), + 138: uint16(28104), + 139: uint16(28128), + 140: uint16(28127), + 141: uint16(28118), + 142: uint16(28094), + 143: uint16(28133), + 144: uint16(28124), + 145: uint16(28125), + 146: uint16(28123), + 147: uint16(28148), + 148: uint16(28106), + 149: uint16(28093), + 150: uint16(28141), + 151: uint16(28144), + 152: uint16(28090), + 153: uint16(28117), + 154: uint16(28098), + 155: uint16(28111), + 156: uint16(28105), + }, + 53: { + 0: uint16(28112), + 1: uint16(28146), + 2: uint16(28115), + 3: uint16(28157), + 4: uint16(28119), + 5: uint16(28109), + 6: uint16(28131), + 7: uint16(28091), + 8: uint16(28922), + 9: uint16(28941), + 10: uint16(28919), + 11: uint16(28951), + 12: uint16(28916), + 13: uint16(28940), + 14: uint16(28912), + 15: uint16(28932), + 16: uint16(28915), + 17: uint16(28944), + 18: uint16(28924), + 19: uint16(28927), + 20: uint16(28934), + 21: uint16(28947), + 22: uint16(28928), + 23: uint16(28920), + 24: uint16(28918), + 25: uint16(28939), + 26: uint16(28930), + 27: uint16(28942), + 28: uint16(29310), + 29: uint16(29307), + 30: uint16(29308), + 31: uint16(29311), + 32: uint16(29469), + 33: uint16(29463), + 34: uint16(29447), + 35: uint16(29457), + 36: uint16(29464), + 37: uint16(29450), + 38: uint16(29448), + 39: uint16(29439), + 40: uint16(29455), + 41: uint16(29470), + 42: uint16(29576), + 43: uint16(29686), + 44: uint16(29688), + 45: uint16(29685), + 46: uint16(29700), + 47: uint16(29697), + 48: uint16(29693), + 49: uint16(29703), + 50: uint16(29696), + 51: uint16(29690), + 52: uint16(29692), + 53: uint16(29695), + 54: uint16(29708), + 55: uint16(29707), + 56: uint16(29684), + 57: uint16(29704), + 58: uint16(30052), + 59: uint16(30051), + 60: uint16(30158), + 61: uint16(30162), + 62: uint16(30159), + 63: uint16(30155), + 64: uint16(30156), + 65: uint16(30161), + 66: uint16(30160), + 67: uint16(30351), + 68: uint16(30345), + 69: uint16(30419), + 70: uint16(30521), + 71: uint16(30511), + 72: uint16(30509), + 73: uint16(30513), + 74: uint16(30514), + 75: uint16(30516), + 76: uint16(30515), + 77: uint16(30525), + 78: uint16(30501), + 79: uint16(30523), + 80: uint16(30517), + 81: uint16(30792), + 82: uint16(30802), + 83: uint16(30793), + 84: uint16(30797), + 85: uint16(30794), + 86: uint16(30796), + 87: uint16(30758), + 88: uint16(30789), + 89: uint16(30800), + 90: uint16(31076), + 91: uint16(31079), + 92: uint16(31081), + 93: uint16(31082), + 94: uint16(31075), + 95: uint16(31083), + 96: uint16(31073), + 97: uint16(31163), + 98: uint16(31226), + 99: uint16(31224), + 100: uint16(31222), + 101: uint16(31223), + 102: uint16(31375), + 103: uint16(31380), + 104: uint16(31376), + 105: uint16(31541), + 106: uint16(31559), + 107: uint16(31540), + 108: uint16(31525), + 109: uint16(31536), + 110: uint16(31522), + 111: uint16(31524), + 112: uint16(31539), + 113: uint16(31512), + 114: uint16(31530), + 115: uint16(31517), + 116: uint16(31537), + 117: uint16(31531), + 118: uint16(31533), + 119: uint16(31535), + 120: uint16(31538), + 121: uint16(31544), + 122: uint16(31514), + 123: uint16(31523), + 124: uint16(31892), + 125: uint16(31896), + 126: uint16(31894), + 127: uint16(31907), + 128: uint16(32053), + 129: uint16(32061), + 130: uint16(32056), + 131: uint16(32054), + 132: uint16(32058), + 133: uint16(32069), + 134: uint16(32044), + 135: uint16(32041), + 136: uint16(32065), + 137: uint16(32071), + 138: uint16(32062), + 139: uint16(32063), + 140: uint16(32074), + 141: uint16(32059), + 142: uint16(32040), + 143: uint16(32611), + 144: uint16(32661), + 145: uint16(32668), + 146: uint16(32669), + 147: uint16(32667), + 148: uint16(32714), + 149: uint16(32715), + 150: uint16(32717), + 151: uint16(32720), + 152: uint16(32721), + 153: uint16(32711), + 154: uint16(32719), + 155: uint16(32713), + 156: uint16(32799), + }, + 54: { + 0: uint16(32798), + 1: uint16(32795), + 2: uint16(32839), + 3: uint16(32835), + 4: uint16(32840), + 5: uint16(33048), + 6: uint16(33061), + 7: uint16(33049), + 8: uint16(33051), + 9: uint16(33069), + 10: uint16(33055), + 11: uint16(33068), + 12: uint16(33054), + 13: uint16(33057), + 14: uint16(33045), + 15: uint16(33063), + 16: uint16(33053), + 17: uint16(33058), + 18: uint16(33297), + 19: uint16(33336), + 20: uint16(33331), + 21: uint16(33338), + 22: uint16(33332), + 23: uint16(33330), + 24: uint16(33396), + 25: uint16(33680), + 26: uint16(33699), + 27: uint16(33704), + 28: uint16(33677), + 29: uint16(33658), + 30: uint16(33651), + 31: uint16(33700), + 32: uint16(33652), + 33: uint16(33679), + 34: uint16(33665), + 35: uint16(33685), + 36: uint16(33689), + 37: uint16(33653), + 38: uint16(33684), + 39: uint16(33705), + 40: uint16(33661), + 41: uint16(33667), + 42: uint16(33676), + 43: uint16(33693), + 44: uint16(33691), + 45: uint16(33706), + 46: uint16(33675), + 47: uint16(33662), + 48: uint16(33701), + 49: uint16(33711), + 50: uint16(33672), + 51: uint16(33687), + 52: uint16(33712), + 53: uint16(33663), + 54: uint16(33702), + 55: uint16(33671), + 56: uint16(33710), + 57: uint16(33654), + 58: uint16(33690), + 59: uint16(34393), + 60: uint16(34390), + 61: uint16(34495), + 62: uint16(34487), + 63: uint16(34498), + 64: uint16(34497), + 65: uint16(34501), + 66: uint16(34490), + 67: uint16(34480), + 68: uint16(34504), + 69: uint16(34489), + 70: uint16(34483), + 71: uint16(34488), + 72: uint16(34508), + 73: uint16(34484), + 74: uint16(34491), + 75: uint16(34492), + 76: uint16(34499), + 77: uint16(34493), + 78: uint16(34494), + 79: uint16(34898), + 80: uint16(34953), + 81: uint16(34965), + 82: uint16(34984), + 83: uint16(34978), + 84: uint16(34986), + 85: uint16(34970), + 86: uint16(34961), + 87: uint16(34977), + 88: uint16(34975), + 89: uint16(34968), + 90: uint16(34983), + 91: uint16(34969), + 92: uint16(34971), + 93: uint16(34967), + 94: uint16(34980), + 95: uint16(34988), + 96: uint16(34956), + 97: uint16(34963), + 98: uint16(34958), + 99: uint16(35202), + 100: uint16(35286), + 101: uint16(35289), + 102: uint16(35285), + 103: uint16(35376), + 104: uint16(35367), + 105: uint16(35372), + 106: uint16(35358), + 107: uint16(35897), + 108: uint16(35899), + 109: uint16(35932), + 110: uint16(35933), + 111: uint16(35965), + 112: uint16(36005), + 113: uint16(36221), + 114: uint16(36219), + 115: uint16(36217), + 116: uint16(36284), + 117: uint16(36290), + 118: uint16(36281), + 119: uint16(36287), + 120: uint16(36289), + 121: uint16(36568), + 122: uint16(36574), + 123: uint16(36573), + 124: uint16(36572), + 125: uint16(36567), + 126: uint16(36576), + 127: uint16(36577), + 128: uint16(36900), + 129: uint16(36875), + 130: uint16(36881), + 131: uint16(36892), + 132: uint16(36876), + 133: uint16(36897), + 134: uint16(37103), + 135: uint16(37098), + 136: uint16(37104), + 137: uint16(37108), + 138: uint16(37106), + 139: uint16(37107), + 140: uint16(37076), + 141: uint16(37099), + 142: uint16(37100), + 143: uint16(37097), + 144: uint16(37206), + 145: uint16(37208), + 146: uint16(37210), + 147: uint16(37203), + 148: uint16(37205), + 149: uint16(37356), + 150: uint16(37364), + 151: uint16(37361), + 152: uint16(37363), + 153: uint16(37368), + 154: uint16(37348), + 155: uint16(37369), + 156: uint16(37354), + }, + 55: { + 0: uint16(37355), + 1: uint16(37367), + 2: uint16(37352), + 3: uint16(37358), + 4: uint16(38266), + 5: uint16(38278), + 6: uint16(38280), + 7: uint16(38524), + 8: uint16(38509), + 9: uint16(38507), + 10: uint16(38513), + 11: uint16(38511), + 12: uint16(38591), + 13: uint16(38762), + 14: uint16(38916), + 15: uint16(39141), + 16: uint16(39319), + 17: uint16(20635), + 18: uint16(20629), + 19: uint16(20628), + 20: uint16(20638), + 21: uint16(20619), + 22: uint16(20643), + 23: uint16(20611), + 24: uint16(20620), + 25: uint16(20622), + 26: uint16(20637), + 27: uint16(20584), + 28: uint16(20636), + 29: uint16(20626), + 30: uint16(20610), + 31: uint16(20615), + 32: uint16(20831), + 33: uint16(20948), + 34: uint16(21266), + 35: uint16(21265), + 36: uint16(21412), + 37: uint16(21415), + 38: uint16(21905), + 39: uint16(21928), + 40: uint16(21925), + 41: uint16(21933), + 42: uint16(21879), + 43: uint16(22085), + 44: uint16(21922), + 45: uint16(21907), + 46: uint16(21896), + 47: uint16(21903), + 48: uint16(21941), + 49: uint16(21889), + 50: uint16(21923), + 51: uint16(21906), + 52: uint16(21924), + 53: uint16(21885), + 54: uint16(21900), + 55: uint16(21926), + 56: uint16(21887), + 57: uint16(21909), + 58: uint16(21921), + 59: uint16(21902), + 60: uint16(22284), + 61: uint16(22569), + 62: uint16(22583), + 63: uint16(22553), + 64: uint16(22558), + 65: uint16(22567), + 66: uint16(22563), + 67: uint16(22568), + 68: uint16(22517), + 69: uint16(22600), + 70: uint16(22565), + 71: uint16(22556), + 72: uint16(22555), + 73: uint16(22579), + 74: uint16(22591), + 75: uint16(22582), + 76: uint16(22574), + 77: uint16(22585), + 78: uint16(22584), + 79: uint16(22573), + 80: uint16(22572), + 81: uint16(22587), + 82: uint16(22881), + 83: uint16(23215), + 84: uint16(23188), + 85: uint16(23199), + 86: uint16(23162), + 87: uint16(23202), + 88: uint16(23198), + 89: uint16(23160), + 90: uint16(23206), + 91: uint16(23164), + 92: uint16(23205), + 93: uint16(23212), + 94: uint16(23189), + 95: uint16(23214), + 96: uint16(23095), + 97: uint16(23172), + 98: uint16(23178), + 99: uint16(23191), + 100: uint16(23171), + 101: uint16(23179), + 102: uint16(23209), + 103: uint16(23163), + 104: uint16(23165), + 105: uint16(23180), + 106: uint16(23196), + 107: uint16(23183), + 108: uint16(23187), + 109: uint16(23197), + 110: uint16(23530), + 111: uint16(23501), + 112: uint16(23499), + 113: uint16(23508), + 114: uint16(23505), + 115: uint16(23498), + 116: uint16(23502), + 117: uint16(23564), + 118: uint16(23600), + 119: uint16(23863), + 120: uint16(23875), + 121: uint16(23915), + 122: uint16(23873), + 123: uint16(23883), + 124: uint16(23871), + 125: uint16(23861), + 126: uint16(23889), + 127: uint16(23886), + 128: uint16(23893), + 129: uint16(23859), + 130: uint16(23866), + 131: uint16(23890), + 132: uint16(23869), + 133: uint16(23857), + 134: uint16(23897), + 135: uint16(23874), + 136: uint16(23865), + 137: uint16(23881), + 138: uint16(23864), + 139: uint16(23868), + 140: uint16(23858), + 141: uint16(23862), + 142: uint16(23872), + 143: uint16(23877), + 144: uint16(24132), + 145: uint16(24129), + 146: uint16(24408), + 147: uint16(24486), + 148: uint16(24485), + 149: uint16(24491), + 150: uint16(24777), + 151: uint16(24761), + 152: uint16(24780), + 153: uint16(24802), + 154: uint16(24782), + 155: uint16(24772), + 156: uint16(24852), + }, + 56: { + 0: uint16(24818), + 1: uint16(24842), + 2: uint16(24854), + 3: uint16(24837), + 4: uint16(24821), + 5: uint16(24851), + 6: uint16(24824), + 7: uint16(24828), + 8: uint16(24830), + 9: uint16(24769), + 10: uint16(24835), + 11: uint16(24856), + 12: uint16(24861), + 13: uint16(24848), + 14: uint16(24831), + 15: uint16(24836), + 16: uint16(24843), + 17: uint16(25162), + 18: uint16(25492), + 19: uint16(25521), + 20: uint16(25520), + 21: uint16(25550), + 22: uint16(25573), + 23: uint16(25576), + 24: uint16(25583), + 25: uint16(25539), + 26: uint16(25757), + 27: uint16(25587), + 28: uint16(25546), + 29: uint16(25568), + 30: uint16(25590), + 31: uint16(25557), + 32: uint16(25586), + 33: uint16(25589), + 34: uint16(25697), + 35: uint16(25567), + 36: uint16(25534), + 37: uint16(25565), + 38: uint16(25564), + 39: uint16(25540), + 40: uint16(25560), + 41: uint16(25555), + 42: uint16(25538), + 43: uint16(25543), + 44: uint16(25548), + 45: uint16(25547), + 46: uint16(25544), + 47: uint16(25584), + 48: uint16(25559), + 49: uint16(25561), + 50: uint16(25906), + 51: uint16(25959), + 52: uint16(25962), + 53: uint16(25956), + 54: uint16(25948), + 55: uint16(25960), + 56: uint16(25957), + 57: uint16(25996), + 58: uint16(26013), + 59: uint16(26014), + 60: uint16(26030), + 61: uint16(26064), + 62: uint16(26066), + 63: uint16(26236), + 64: uint16(26220), + 65: uint16(26235), + 66: uint16(26240), + 67: uint16(26225), + 68: uint16(26233), + 69: uint16(26218), + 70: uint16(26226), + 71: uint16(26369), + 72: uint16(26892), + 73: uint16(26835), + 74: uint16(26884), + 75: uint16(26844), + 76: uint16(26922), + 77: uint16(26860), + 78: uint16(26858), + 79: uint16(26865), + 80: uint16(26895), + 81: uint16(26838), + 82: uint16(26871), + 83: uint16(26859), + 84: uint16(26852), + 85: uint16(26870), + 86: uint16(26899), + 87: uint16(26896), + 88: uint16(26867), + 89: uint16(26849), + 90: uint16(26887), + 91: uint16(26828), + 92: uint16(26888), + 93: uint16(26992), + 94: uint16(26804), + 95: uint16(26897), + 96: uint16(26863), + 97: uint16(26822), + 98: uint16(26900), + 99: uint16(26872), + 100: uint16(26832), + 101: uint16(26877), + 102: uint16(26876), + 103: uint16(26856), + 104: uint16(26891), + 105: uint16(26890), + 106: uint16(26903), + 107: uint16(26830), + 108: uint16(26824), + 109: uint16(26845), + 110: uint16(26846), + 111: uint16(26854), + 112: uint16(26868), + 113: uint16(26833), + 114: uint16(26886), + 115: uint16(26836), + 116: uint16(26857), + 117: uint16(26901), + 118: uint16(26917), + 119: uint16(26823), + 120: uint16(27449), + 121: uint16(27451), + 122: uint16(27455), + 123: uint16(27452), + 124: uint16(27540), + 125: uint16(27543), + 126: uint16(27545), + 127: uint16(27541), + 128: uint16(27581), + 129: uint16(27632), + 130: uint16(27634), + 131: uint16(27635), + 132: uint16(27696), + 133: uint16(28156), + 134: uint16(28230), + 135: uint16(28231), + 136: uint16(28191), + 137: uint16(28233), + 138: uint16(28296), + 139: uint16(28220), + 140: uint16(28221), + 141: uint16(28229), + 142: uint16(28258), + 143: uint16(28203), + 144: uint16(28223), + 145: uint16(28225), + 146: uint16(28253), + 147: uint16(28275), + 148: uint16(28188), + 149: uint16(28211), + 150: uint16(28235), + 151: uint16(28224), + 152: uint16(28241), + 153: uint16(28219), + 154: uint16(28163), + 155: uint16(28206), + 156: uint16(28254), + }, + 57: { + 0: uint16(28264), + 1: uint16(28252), + 2: uint16(28257), + 3: uint16(28209), + 4: uint16(28200), + 5: uint16(28256), + 6: uint16(28273), + 7: uint16(28267), + 8: uint16(28217), + 9: uint16(28194), + 10: uint16(28208), + 11: uint16(28243), + 12: uint16(28261), + 13: uint16(28199), + 14: uint16(28280), + 15: uint16(28260), + 16: uint16(28279), + 17: uint16(28245), + 18: uint16(28281), + 19: uint16(28242), + 20: uint16(28262), + 21: uint16(28213), + 22: uint16(28214), + 23: uint16(28250), + 24: uint16(28960), + 25: uint16(28958), + 26: uint16(28975), + 27: uint16(28923), + 28: uint16(28974), + 29: uint16(28977), + 30: uint16(28963), + 31: uint16(28965), + 32: uint16(28962), + 33: uint16(28978), + 34: uint16(28959), + 35: uint16(28968), + 36: uint16(28986), + 37: uint16(28955), + 38: uint16(29259), + 39: uint16(29274), + 40: uint16(29320), + 41: uint16(29321), + 42: uint16(29318), + 43: uint16(29317), + 44: uint16(29323), + 45: uint16(29458), + 46: uint16(29451), + 47: uint16(29488), + 48: uint16(29474), + 49: uint16(29489), + 50: uint16(29491), + 51: uint16(29479), + 52: uint16(29490), + 53: uint16(29485), + 54: uint16(29478), + 55: uint16(29475), + 56: uint16(29493), + 57: uint16(29452), + 58: uint16(29742), + 59: uint16(29740), + 60: uint16(29744), + 61: uint16(29739), + 62: uint16(29718), + 63: uint16(29722), + 64: uint16(29729), + 65: uint16(29741), + 66: uint16(29745), + 67: uint16(29732), + 68: uint16(29731), + 69: uint16(29725), + 70: uint16(29737), + 71: uint16(29728), + 72: uint16(29746), + 73: uint16(29947), + 74: uint16(29999), + 75: uint16(30063), + 76: uint16(30060), + 77: uint16(30183), + 78: uint16(30170), + 79: uint16(30177), + 80: uint16(30182), + 81: uint16(30173), + 82: uint16(30175), + 83: uint16(30180), + 84: uint16(30167), + 85: uint16(30357), + 86: uint16(30354), + 87: uint16(30426), + 88: uint16(30534), + 89: uint16(30535), + 90: uint16(30532), + 91: uint16(30541), + 92: uint16(30533), + 93: uint16(30538), + 94: uint16(30542), + 95: uint16(30539), + 96: uint16(30540), + 97: uint16(30686), + 98: uint16(30700), + 99: uint16(30816), + 100: uint16(30820), + 101: uint16(30821), + 102: uint16(30812), + 103: uint16(30829), + 104: uint16(30833), + 105: uint16(30826), + 106: uint16(30830), + 107: uint16(30832), + 108: uint16(30825), + 109: uint16(30824), + 110: uint16(30814), + 111: uint16(30818), + 112: uint16(31092), + 113: uint16(31091), + 114: uint16(31090), + 115: uint16(31088), + 116: uint16(31234), + 117: uint16(31242), + 118: uint16(31235), + 119: uint16(31244), + 120: uint16(31236), + 121: uint16(31385), + 122: uint16(31462), + 123: uint16(31460), + 124: uint16(31562), + 125: uint16(31547), + 126: uint16(31556), + 127: uint16(31560), + 128: uint16(31564), + 129: uint16(31566), + 130: uint16(31552), + 131: uint16(31576), + 132: uint16(31557), + 133: uint16(31906), + 134: uint16(31902), + 135: uint16(31912), + 136: uint16(31905), + 137: uint16(32088), + 138: uint16(32111), + 139: uint16(32099), + 140: uint16(32083), + 141: uint16(32086), + 142: uint16(32103), + 143: uint16(32106), + 144: uint16(32079), + 145: uint16(32109), + 146: uint16(32092), + 147: uint16(32107), + 148: uint16(32082), + 149: uint16(32084), + 150: uint16(32105), + 151: uint16(32081), + 152: uint16(32095), + 153: uint16(32078), + 154: uint16(32574), + 155: uint16(32575), + 156: uint16(32613), + }, + 58: { + 0: uint16(32614), + 1: uint16(32674), + 2: uint16(32672), + 3: uint16(32673), + 4: uint16(32727), + 5: uint16(32849), + 6: uint16(32847), + 7: uint16(32848), + 8: uint16(33022), + 9: uint16(32980), + 10: uint16(33091), + 11: uint16(33098), + 12: uint16(33106), + 13: uint16(33103), + 14: uint16(33095), + 15: uint16(33085), + 16: uint16(33101), + 17: uint16(33082), + 18: uint16(33254), + 19: uint16(33262), + 20: uint16(33271), + 21: uint16(33272), + 22: uint16(33273), + 23: uint16(33284), + 24: uint16(33340), + 25: uint16(33341), + 26: uint16(33343), + 27: uint16(33397), + 28: uint16(33595), + 29: uint16(33743), + 30: uint16(33785), + 31: uint16(33827), + 32: uint16(33728), + 33: uint16(33768), + 34: uint16(33810), + 35: uint16(33767), + 36: uint16(33764), + 37: uint16(33788), + 38: uint16(33782), + 39: uint16(33808), + 40: uint16(33734), + 41: uint16(33736), + 42: uint16(33771), + 43: uint16(33763), + 44: uint16(33727), + 45: uint16(33793), + 46: uint16(33757), + 47: uint16(33765), + 48: uint16(33752), + 49: uint16(33791), + 50: uint16(33761), + 51: uint16(33739), + 52: uint16(33742), + 53: uint16(33750), + 54: uint16(33781), + 55: uint16(33737), + 56: uint16(33801), + 57: uint16(33807), + 58: uint16(33758), + 59: uint16(33809), + 60: uint16(33798), + 61: uint16(33730), + 62: uint16(33779), + 63: uint16(33749), + 64: uint16(33786), + 65: uint16(33735), + 66: uint16(33745), + 67: uint16(33770), + 68: uint16(33811), + 69: uint16(33731), + 70: uint16(33772), + 71: uint16(33774), + 72: uint16(33732), + 73: uint16(33787), + 74: uint16(33751), + 75: uint16(33762), + 76: uint16(33819), + 77: uint16(33755), + 78: uint16(33790), + 79: uint16(34520), + 80: uint16(34530), + 81: uint16(34534), + 82: uint16(34515), + 83: uint16(34531), + 84: uint16(34522), + 85: uint16(34538), + 86: uint16(34525), + 87: uint16(34539), + 88: uint16(34524), + 89: uint16(34540), + 90: uint16(34537), + 91: uint16(34519), + 92: uint16(34536), + 93: uint16(34513), + 94: uint16(34888), + 95: uint16(34902), + 96: uint16(34901), + 97: uint16(35002), + 98: uint16(35031), + 99: uint16(35001), + 100: uint16(35000), + 101: uint16(35008), + 102: uint16(35006), + 103: uint16(34998), + 104: uint16(35004), + 105: uint16(34999), + 106: uint16(35005), + 107: uint16(34994), + 108: uint16(35073), + 109: uint16(35017), + 110: uint16(35221), + 111: uint16(35224), + 112: uint16(35223), + 113: uint16(35293), + 114: uint16(35290), + 115: uint16(35291), + 116: uint16(35406), + 117: uint16(35405), + 118: uint16(35385), + 119: uint16(35417), + 120: uint16(35392), + 121: uint16(35415), + 122: uint16(35416), + 123: uint16(35396), + 124: uint16(35397), + 125: uint16(35410), + 126: uint16(35400), + 127: uint16(35409), + 128: uint16(35402), + 129: uint16(35404), + 130: uint16(35407), + 131: uint16(35935), + 132: uint16(35969), + 133: uint16(35968), + 134: uint16(36026), + 135: uint16(36030), + 136: uint16(36016), + 137: uint16(36025), + 138: uint16(36021), + 139: uint16(36228), + 140: uint16(36224), + 141: uint16(36233), + 142: uint16(36312), + 143: uint16(36307), + 144: uint16(36301), + 145: uint16(36295), + 146: uint16(36310), + 147: uint16(36316), + 148: uint16(36303), + 149: uint16(36309), + 150: uint16(36313), + 151: uint16(36296), + 152: uint16(36311), + 153: uint16(36293), + 154: uint16(36591), + 155: uint16(36599), + 156: uint16(36602), + }, + 59: { + 0: uint16(36601), + 1: uint16(36582), + 2: uint16(36590), + 3: uint16(36581), + 4: uint16(36597), + 5: uint16(36583), + 6: uint16(36584), + 7: uint16(36598), + 8: uint16(36587), + 9: uint16(36593), + 10: uint16(36588), + 11: uint16(36596), + 12: uint16(36585), + 13: uint16(36909), + 14: uint16(36916), + 15: uint16(36911), + 16: uint16(37126), + 17: uint16(37164), + 18: uint16(37124), + 19: uint16(37119), + 20: uint16(37116), + 21: uint16(37128), + 22: uint16(37113), + 23: uint16(37115), + 24: uint16(37121), + 25: uint16(37120), + 26: uint16(37127), + 27: uint16(37125), + 28: uint16(37123), + 29: uint16(37217), + 30: uint16(37220), + 31: uint16(37215), + 32: uint16(37218), + 33: uint16(37216), + 34: uint16(37377), + 35: uint16(37386), + 36: uint16(37413), + 37: uint16(37379), + 38: uint16(37402), + 39: uint16(37414), + 40: uint16(37391), + 41: uint16(37388), + 42: uint16(37376), + 43: uint16(37394), + 44: uint16(37375), + 45: uint16(37373), + 46: uint16(37382), + 47: uint16(37380), + 48: uint16(37415), + 49: uint16(37378), + 50: uint16(37404), + 51: uint16(37412), + 52: uint16(37401), + 53: uint16(37399), + 54: uint16(37381), + 55: uint16(37398), + 56: uint16(38267), + 57: uint16(38285), + 58: uint16(38284), + 59: uint16(38288), + 60: uint16(38535), + 61: uint16(38526), + 62: uint16(38536), + 63: uint16(38537), + 64: uint16(38531), + 65: uint16(38528), + 66: uint16(38594), + 67: uint16(38600), + 68: uint16(38595), + 69: uint16(38641), + 70: uint16(38640), + 71: uint16(38764), + 72: uint16(38768), + 73: uint16(38766), + 74: uint16(38919), + 75: uint16(39081), + 76: uint16(39147), + 77: uint16(40166), + 78: uint16(40697), + 79: uint16(20099), + 80: uint16(20100), + 81: uint16(20150), + 82: uint16(20669), + 83: uint16(20671), + 84: uint16(20678), + 85: uint16(20654), + 86: uint16(20676), + 87: uint16(20682), + 88: uint16(20660), + 89: uint16(20680), + 90: uint16(20674), + 91: uint16(20656), + 92: uint16(20673), + 93: uint16(20666), + 94: uint16(20657), + 95: uint16(20683), + 96: uint16(20681), + 97: uint16(20662), + 98: uint16(20664), + 99: uint16(20951), + 100: uint16(21114), + 101: uint16(21112), + 102: uint16(21115), + 103: uint16(21116), + 104: uint16(21955), + 105: uint16(21979), + 106: uint16(21964), + 107: uint16(21968), + 108: uint16(21963), + 109: uint16(21962), + 110: uint16(21981), + 111: uint16(21952), + 112: uint16(21972), + 113: uint16(21956), + 114: uint16(21993), + 115: uint16(21951), + 116: uint16(21970), + 117: uint16(21901), + 118: uint16(21967), + 119: uint16(21973), + 120: uint16(21986), + 121: uint16(21974), + 122: uint16(21960), + 123: uint16(22002), + 124: uint16(21965), + 125: uint16(21977), + 126: uint16(21954), + 127: uint16(22292), + 128: uint16(22611), + 129: uint16(22632), + 130: uint16(22628), + 131: uint16(22607), + 132: uint16(22605), + 133: uint16(22601), + 134: uint16(22639), + 135: uint16(22613), + 136: uint16(22606), + 137: uint16(22621), + 138: uint16(22617), + 139: uint16(22629), + 140: uint16(22619), + 141: uint16(22589), + 142: uint16(22627), + 143: uint16(22641), + 144: uint16(22780), + 145: uint16(23239), + 146: uint16(23236), + 147: uint16(23243), + 148: uint16(23226), + 149: uint16(23224), + 150: uint16(23217), + 151: uint16(23221), + 152: uint16(23216), + 153: uint16(23231), + 154: uint16(23240), + 155: uint16(23227), + 156: uint16(23238), + }, + 60: { + 0: uint16(23223), + 1: uint16(23232), + 2: uint16(23242), + 3: uint16(23220), + 4: uint16(23222), + 5: uint16(23245), + 6: uint16(23225), + 7: uint16(23184), + 8: uint16(23510), + 9: uint16(23512), + 10: uint16(23513), + 11: uint16(23583), + 12: uint16(23603), + 13: uint16(23921), + 14: uint16(23907), + 15: uint16(23882), + 16: uint16(23909), + 17: uint16(23922), + 18: uint16(23916), + 19: uint16(23902), + 20: uint16(23912), + 21: uint16(23911), + 22: uint16(23906), + 23: uint16(24048), + 24: uint16(24143), + 25: uint16(24142), + 26: uint16(24138), + 27: uint16(24141), + 28: uint16(24139), + 29: uint16(24261), + 30: uint16(24268), + 31: uint16(24262), + 32: uint16(24267), + 33: uint16(24263), + 34: uint16(24384), + 35: uint16(24495), + 36: uint16(24493), + 37: uint16(24823), + 38: uint16(24905), + 39: uint16(24906), + 40: uint16(24875), + 41: uint16(24901), + 42: uint16(24886), + 43: uint16(24882), + 44: uint16(24878), + 45: uint16(24902), + 46: uint16(24879), + 47: uint16(24911), + 48: uint16(24873), + 49: uint16(24896), + 50: uint16(25120), + 51: uint16(37224), + 52: uint16(25123), + 53: uint16(25125), + 54: uint16(25124), + 55: uint16(25541), + 56: uint16(25585), + 57: uint16(25579), + 58: uint16(25616), + 59: uint16(25618), + 60: uint16(25609), + 61: uint16(25632), + 62: uint16(25636), + 63: uint16(25651), + 64: uint16(25667), + 65: uint16(25631), + 66: uint16(25621), + 67: uint16(25624), + 68: uint16(25657), + 69: uint16(25655), + 70: uint16(25634), + 71: uint16(25635), + 72: uint16(25612), + 73: uint16(25638), + 74: uint16(25648), + 75: uint16(25640), + 76: uint16(25665), + 77: uint16(25653), + 78: uint16(25647), + 79: uint16(25610), + 80: uint16(25626), + 81: uint16(25664), + 82: uint16(25637), + 83: uint16(25639), + 84: uint16(25611), + 85: uint16(25575), + 86: uint16(25627), + 87: uint16(25646), + 88: uint16(25633), + 89: uint16(25614), + 90: uint16(25967), + 91: uint16(26002), + 92: uint16(26067), + 93: uint16(26246), + 94: uint16(26252), + 95: uint16(26261), + 96: uint16(26256), + 97: uint16(26251), + 98: uint16(26250), + 99: uint16(26265), + 100: uint16(26260), + 101: uint16(26232), + 102: uint16(26400), + 103: uint16(26982), + 104: uint16(26975), + 105: uint16(26936), + 106: uint16(26958), + 107: uint16(26978), + 108: uint16(26993), + 109: uint16(26943), + 110: uint16(26949), + 111: uint16(26986), + 112: uint16(26937), + 113: uint16(26946), + 114: uint16(26967), + 115: uint16(26969), + 116: uint16(27002), + 117: uint16(26952), + 118: uint16(26953), + 119: uint16(26933), + 120: uint16(26988), + 121: uint16(26931), + 122: uint16(26941), + 123: uint16(26981), + 124: uint16(26864), + 125: uint16(27000), + 126: uint16(26932), + 127: uint16(26985), + 128: uint16(26944), + 129: uint16(26991), + 130: uint16(26948), + 131: uint16(26998), + 132: uint16(26968), + 133: uint16(26945), + 134: uint16(26996), + 135: uint16(26956), + 136: uint16(26939), + 137: uint16(26955), + 138: uint16(26935), + 139: uint16(26972), + 140: uint16(26959), + 141: uint16(26961), + 142: uint16(26930), + 143: uint16(26962), + 144: uint16(26927), + 145: uint16(27003), + 146: uint16(26940), + 147: uint16(27462), + 148: uint16(27461), + 149: uint16(27459), + 150: uint16(27458), + 151: uint16(27464), + 152: uint16(27457), + 153: uint16(27547), + 154: uint16(64013), + 155: uint16(27643), + 156: uint16(27644), + }, + 61: { + 0: uint16(27641), + 1: uint16(27639), + 2: uint16(27640), + 3: uint16(28315), + 4: uint16(28374), + 5: uint16(28360), + 6: uint16(28303), + 7: uint16(28352), + 8: uint16(28319), + 9: uint16(28307), + 10: uint16(28308), + 11: uint16(28320), + 12: uint16(28337), + 13: uint16(28345), + 14: uint16(28358), + 15: uint16(28370), + 16: uint16(28349), + 17: uint16(28353), + 18: uint16(28318), + 19: uint16(28361), + 20: uint16(28343), + 21: uint16(28336), + 22: uint16(28365), + 23: uint16(28326), + 24: uint16(28367), + 25: uint16(28338), + 26: uint16(28350), + 27: uint16(28355), + 28: uint16(28380), + 29: uint16(28376), + 30: uint16(28313), + 31: uint16(28306), + 32: uint16(28302), + 33: uint16(28301), + 34: uint16(28324), + 35: uint16(28321), + 36: uint16(28351), + 37: uint16(28339), + 38: uint16(28368), + 39: uint16(28362), + 40: uint16(28311), + 41: uint16(28334), + 42: uint16(28323), + 43: uint16(28999), + 44: uint16(29012), + 45: uint16(29010), + 46: uint16(29027), + 47: uint16(29024), + 48: uint16(28993), + 49: uint16(29021), + 50: uint16(29026), + 51: uint16(29042), + 52: uint16(29048), + 53: uint16(29034), + 54: uint16(29025), + 55: uint16(28994), + 56: uint16(29016), + 57: uint16(28995), + 58: uint16(29003), + 59: uint16(29040), + 60: uint16(29023), + 61: uint16(29008), + 62: uint16(29011), + 63: uint16(28996), + 64: uint16(29005), + 65: uint16(29018), + 66: uint16(29263), + 67: uint16(29325), + 68: uint16(29324), + 69: uint16(29329), + 70: uint16(29328), + 71: uint16(29326), + 72: uint16(29500), + 73: uint16(29506), + 74: uint16(29499), + 75: uint16(29498), + 76: uint16(29504), + 77: uint16(29514), + 78: uint16(29513), + 79: uint16(29764), + 80: uint16(29770), + 81: uint16(29771), + 82: uint16(29778), + 83: uint16(29777), + 84: uint16(29783), + 85: uint16(29760), + 86: uint16(29775), + 87: uint16(29776), + 88: uint16(29774), + 89: uint16(29762), + 90: uint16(29766), + 91: uint16(29773), + 92: uint16(29780), + 93: uint16(29921), + 94: uint16(29951), + 95: uint16(29950), + 96: uint16(29949), + 97: uint16(29981), + 98: uint16(30073), + 99: uint16(30071), + 100: uint16(27011), + 101: uint16(30191), + 102: uint16(30223), + 103: uint16(30211), + 104: uint16(30199), + 105: uint16(30206), + 106: uint16(30204), + 107: uint16(30201), + 108: uint16(30200), + 109: uint16(30224), + 110: uint16(30203), + 111: uint16(30198), + 112: uint16(30189), + 113: uint16(30197), + 114: uint16(30205), + 115: uint16(30361), + 116: uint16(30389), + 117: uint16(30429), + 118: uint16(30549), + 119: uint16(30559), + 120: uint16(30560), + 121: uint16(30546), + 122: uint16(30550), + 123: uint16(30554), + 124: uint16(30569), + 125: uint16(30567), + 126: uint16(30548), + 127: uint16(30553), + 128: uint16(30573), + 129: uint16(30688), + 130: uint16(30855), + 131: uint16(30874), + 132: uint16(30868), + 133: uint16(30863), + 134: uint16(30852), + 135: uint16(30869), + 136: uint16(30853), + 137: uint16(30854), + 138: uint16(30881), + 139: uint16(30851), + 140: uint16(30841), + 141: uint16(30873), + 142: uint16(30848), + 143: uint16(30870), + 144: uint16(30843), + 145: uint16(31100), + 146: uint16(31106), + 147: uint16(31101), + 148: uint16(31097), + 149: uint16(31249), + 150: uint16(31256), + 151: uint16(31257), + 152: uint16(31250), + 153: uint16(31255), + 154: uint16(31253), + 155: uint16(31266), + 156: uint16(31251), + }, + 62: { + 0: uint16(31259), + 1: uint16(31248), + 2: uint16(31395), + 3: uint16(31394), + 4: uint16(31390), + 5: uint16(31467), + 6: uint16(31590), + 7: uint16(31588), + 8: uint16(31597), + 9: uint16(31604), + 10: uint16(31593), + 11: uint16(31602), + 12: uint16(31589), + 13: uint16(31603), + 14: uint16(31601), + 15: uint16(31600), + 16: uint16(31585), + 17: uint16(31608), + 18: uint16(31606), + 19: uint16(31587), + 20: uint16(31922), + 21: uint16(31924), + 22: uint16(31919), + 23: uint16(32136), + 24: uint16(32134), + 25: uint16(32128), + 26: uint16(32141), + 27: uint16(32127), + 28: uint16(32133), + 29: uint16(32122), + 30: uint16(32142), + 31: uint16(32123), + 32: uint16(32131), + 33: uint16(32124), + 34: uint16(32140), + 35: uint16(32148), + 36: uint16(32132), + 37: uint16(32125), + 38: uint16(32146), + 39: uint16(32621), + 40: uint16(32619), + 41: uint16(32615), + 42: uint16(32616), + 43: uint16(32620), + 44: uint16(32678), + 45: uint16(32677), + 46: uint16(32679), + 47: uint16(32731), + 48: uint16(32732), + 49: uint16(32801), + 50: uint16(33124), + 51: uint16(33120), + 52: uint16(33143), + 53: uint16(33116), + 54: uint16(33129), + 55: uint16(33115), + 56: uint16(33122), + 57: uint16(33138), + 58: uint16(26401), + 59: uint16(33118), + 60: uint16(33142), + 61: uint16(33127), + 62: uint16(33135), + 63: uint16(33092), + 64: uint16(33121), + 65: uint16(33309), + 66: uint16(33353), + 67: uint16(33348), + 68: uint16(33344), + 69: uint16(33346), + 70: uint16(33349), + 71: uint16(34033), + 72: uint16(33855), + 73: uint16(33878), + 74: uint16(33910), + 75: uint16(33913), + 76: uint16(33935), + 77: uint16(33933), + 78: uint16(33893), + 79: uint16(33873), + 80: uint16(33856), + 81: uint16(33926), + 82: uint16(33895), + 83: uint16(33840), + 84: uint16(33869), + 85: uint16(33917), + 86: uint16(33882), + 87: uint16(33881), + 88: uint16(33908), + 89: uint16(33907), + 90: uint16(33885), + 91: uint16(34055), + 92: uint16(33886), + 93: uint16(33847), + 94: uint16(33850), + 95: uint16(33844), + 96: uint16(33914), + 97: uint16(33859), + 98: uint16(33912), + 99: uint16(33842), + 100: uint16(33861), + 101: uint16(33833), + 102: uint16(33753), + 103: uint16(33867), + 104: uint16(33839), + 105: uint16(33858), + 106: uint16(33837), + 107: uint16(33887), + 108: uint16(33904), + 109: uint16(33849), + 110: uint16(33870), + 111: uint16(33868), + 112: uint16(33874), + 113: uint16(33903), + 114: uint16(33989), + 115: uint16(33934), + 116: uint16(33851), + 117: uint16(33863), + 118: uint16(33846), + 119: uint16(33843), + 120: uint16(33896), + 121: uint16(33918), + 122: uint16(33860), + 123: uint16(33835), + 124: uint16(33888), + 125: uint16(33876), + 126: uint16(33902), + 127: uint16(33872), + 128: uint16(34571), + 129: uint16(34564), + 130: uint16(34551), + 131: uint16(34572), + 132: uint16(34554), + 133: uint16(34518), + 134: uint16(34549), + 135: uint16(34637), + 136: uint16(34552), + 137: uint16(34574), + 138: uint16(34569), + 139: uint16(34561), + 140: uint16(34550), + 141: uint16(34573), + 142: uint16(34565), + 143: uint16(35030), + 144: uint16(35019), + 145: uint16(35021), + 146: uint16(35022), + 147: uint16(35038), + 148: uint16(35035), + 149: uint16(35034), + 150: uint16(35020), + 151: uint16(35024), + 152: uint16(35205), + 153: uint16(35227), + 154: uint16(35295), + 155: uint16(35301), + 156: uint16(35300), + }, + 63: { + 0: uint16(35297), + 1: uint16(35296), + 2: uint16(35298), + 3: uint16(35292), + 4: uint16(35302), + 5: uint16(35446), + 6: uint16(35462), + 7: uint16(35455), + 8: uint16(35425), + 9: uint16(35391), + 10: uint16(35447), + 11: uint16(35458), + 12: uint16(35460), + 13: uint16(35445), + 14: uint16(35459), + 15: uint16(35457), + 16: uint16(35444), + 17: uint16(35450), + 18: uint16(35900), + 19: uint16(35915), + 20: uint16(35914), + 21: uint16(35941), + 22: uint16(35940), + 23: uint16(35942), + 24: uint16(35974), + 25: uint16(35972), + 26: uint16(35973), + 27: uint16(36044), + 28: uint16(36200), + 29: uint16(36201), + 30: uint16(36241), + 31: uint16(36236), + 32: uint16(36238), + 33: uint16(36239), + 34: uint16(36237), + 35: uint16(36243), + 36: uint16(36244), + 37: uint16(36240), + 38: uint16(36242), + 39: uint16(36336), + 40: uint16(36320), + 41: uint16(36332), + 42: uint16(36337), + 43: uint16(36334), + 44: uint16(36304), + 45: uint16(36329), + 46: uint16(36323), + 47: uint16(36322), + 48: uint16(36327), + 49: uint16(36338), + 50: uint16(36331), + 51: uint16(36340), + 52: uint16(36614), + 53: uint16(36607), + 54: uint16(36609), + 55: uint16(36608), + 56: uint16(36613), + 57: uint16(36615), + 58: uint16(36616), + 59: uint16(36610), + 60: uint16(36619), + 61: uint16(36946), + 62: uint16(36927), + 63: uint16(36932), + 64: uint16(36937), + 65: uint16(36925), + 66: uint16(37136), + 67: uint16(37133), + 68: uint16(37135), + 69: uint16(37137), + 70: uint16(37142), + 71: uint16(37140), + 72: uint16(37131), + 73: uint16(37134), + 74: uint16(37230), + 75: uint16(37231), + 76: uint16(37448), + 77: uint16(37458), + 78: uint16(37424), + 79: uint16(37434), + 80: uint16(37478), + 81: uint16(37427), + 82: uint16(37477), + 83: uint16(37470), + 84: uint16(37507), + 85: uint16(37422), + 86: uint16(37450), + 87: uint16(37446), + 88: uint16(37485), + 89: uint16(37484), + 90: uint16(37455), + 91: uint16(37472), + 92: uint16(37479), + 93: uint16(37487), + 94: uint16(37430), + 95: uint16(37473), + 96: uint16(37488), + 97: uint16(37425), + 98: uint16(37460), + 99: uint16(37475), + 100: uint16(37456), + 101: uint16(37490), + 102: uint16(37454), + 103: uint16(37459), + 104: uint16(37452), + 105: uint16(37462), + 106: uint16(37426), + 107: uint16(38303), + 108: uint16(38300), + 109: uint16(38302), + 110: uint16(38299), + 111: uint16(38546), + 112: uint16(38547), + 113: uint16(38545), + 114: uint16(38551), + 115: uint16(38606), + 116: uint16(38650), + 117: uint16(38653), + 118: uint16(38648), + 119: uint16(38645), + 120: uint16(38771), + 121: uint16(38775), + 122: uint16(38776), + 123: uint16(38770), + 124: uint16(38927), + 125: uint16(38925), + 126: uint16(38926), + 127: uint16(39084), + 128: uint16(39158), + 129: uint16(39161), + 130: uint16(39343), + 131: uint16(39346), + 132: uint16(39344), + 133: uint16(39349), + 134: uint16(39597), + 135: uint16(39595), + 136: uint16(39771), + 137: uint16(40170), + 138: uint16(40173), + 139: uint16(40167), + 140: uint16(40576), + 141: uint16(40701), + 142: uint16(20710), + 143: uint16(20692), + 144: uint16(20695), + 145: uint16(20712), + 146: uint16(20723), + 147: uint16(20699), + 148: uint16(20714), + 149: uint16(20701), + 150: uint16(20708), + 151: uint16(20691), + 152: uint16(20716), + 153: uint16(20720), + 154: uint16(20719), + 155: uint16(20707), + 156: uint16(20704), + }, + 64: { + 0: uint16(20952), + 1: uint16(21120), + 2: uint16(21121), + 3: uint16(21225), + 4: uint16(21227), + 5: uint16(21296), + 6: uint16(21420), + 7: uint16(22055), + 8: uint16(22037), + 9: uint16(22028), + 10: uint16(22034), + 11: uint16(22012), + 12: uint16(22031), + 13: uint16(22044), + 14: uint16(22017), + 15: uint16(22035), + 16: uint16(22018), + 17: uint16(22010), + 18: uint16(22045), + 19: uint16(22020), + 20: uint16(22015), + 21: uint16(22009), + 22: uint16(22665), + 23: uint16(22652), + 24: uint16(22672), + 25: uint16(22680), + 26: uint16(22662), + 27: uint16(22657), + 28: uint16(22655), + 29: uint16(22644), + 30: uint16(22667), + 31: uint16(22650), + 32: uint16(22663), + 33: uint16(22673), + 34: uint16(22670), + 35: uint16(22646), + 36: uint16(22658), + 37: uint16(22664), + 38: uint16(22651), + 39: uint16(22676), + 40: uint16(22671), + 41: uint16(22782), + 42: uint16(22891), + 43: uint16(23260), + 44: uint16(23278), + 45: uint16(23269), + 46: uint16(23253), + 47: uint16(23274), + 48: uint16(23258), + 49: uint16(23277), + 50: uint16(23275), + 51: uint16(23283), + 52: uint16(23266), + 53: uint16(23264), + 54: uint16(23259), + 55: uint16(23276), + 56: uint16(23262), + 57: uint16(23261), + 58: uint16(23257), + 59: uint16(23272), + 60: uint16(23263), + 61: uint16(23415), + 62: uint16(23520), + 63: uint16(23523), + 64: uint16(23651), + 65: uint16(23938), + 66: uint16(23936), + 67: uint16(23933), + 68: uint16(23942), + 69: uint16(23930), + 70: uint16(23937), + 71: uint16(23927), + 72: uint16(23946), + 73: uint16(23945), + 74: uint16(23944), + 75: uint16(23934), + 76: uint16(23932), + 77: uint16(23949), + 78: uint16(23929), + 79: uint16(23935), + 80: uint16(24152), + 81: uint16(24153), + 82: uint16(24147), + 83: uint16(24280), + 84: uint16(24273), + 85: uint16(24279), + 86: uint16(24270), + 87: uint16(24284), + 88: uint16(24277), + 89: uint16(24281), + 90: uint16(24274), + 91: uint16(24276), + 92: uint16(24388), + 93: uint16(24387), + 94: uint16(24431), + 95: uint16(24502), + 96: uint16(24876), + 97: uint16(24872), + 98: uint16(24897), + 99: uint16(24926), + 100: uint16(24945), + 101: uint16(24947), + 102: uint16(24914), + 103: uint16(24915), + 104: uint16(24946), + 105: uint16(24940), + 106: uint16(24960), + 107: uint16(24948), + 108: uint16(24916), + 109: uint16(24954), + 110: uint16(24923), + 111: uint16(24933), + 112: uint16(24891), + 113: uint16(24938), + 114: uint16(24929), + 115: uint16(24918), + 116: uint16(25129), + 117: uint16(25127), + 118: uint16(25131), + 119: uint16(25643), + 120: uint16(25677), + 121: uint16(25691), + 122: uint16(25693), + 123: uint16(25716), + 124: uint16(25718), + 125: uint16(25714), + 126: uint16(25715), + 127: uint16(25725), + 128: uint16(25717), + 129: uint16(25702), + 130: uint16(25766), + 131: uint16(25678), + 132: uint16(25730), + 133: uint16(25694), + 134: uint16(25692), + 135: uint16(25675), + 136: uint16(25683), + 137: uint16(25696), + 138: uint16(25680), + 139: uint16(25727), + 140: uint16(25663), + 141: uint16(25708), + 142: uint16(25707), + 143: uint16(25689), + 144: uint16(25701), + 145: uint16(25719), + 146: uint16(25971), + 147: uint16(26016), + 148: uint16(26273), + 149: uint16(26272), + 150: uint16(26271), + 151: uint16(26373), + 152: uint16(26372), + 153: uint16(26402), + 154: uint16(27057), + 155: uint16(27062), + 156: uint16(27081), + }, + 65: { + 0: uint16(27040), + 1: uint16(27086), + 2: uint16(27030), + 3: uint16(27056), + 4: uint16(27052), + 5: uint16(27068), + 6: uint16(27025), + 7: uint16(27033), + 8: uint16(27022), + 9: uint16(27047), + 10: uint16(27021), + 11: uint16(27049), + 12: uint16(27070), + 13: uint16(27055), + 14: uint16(27071), + 15: uint16(27076), + 16: uint16(27069), + 17: uint16(27044), + 18: uint16(27092), + 19: uint16(27065), + 20: uint16(27082), + 21: uint16(27034), + 22: uint16(27087), + 23: uint16(27059), + 24: uint16(27027), + 25: uint16(27050), + 26: uint16(27041), + 27: uint16(27038), + 28: uint16(27097), + 29: uint16(27031), + 30: uint16(27024), + 31: uint16(27074), + 32: uint16(27061), + 33: uint16(27045), + 34: uint16(27078), + 35: uint16(27466), + 36: uint16(27469), + 37: uint16(27467), + 38: uint16(27550), + 39: uint16(27551), + 40: uint16(27552), + 41: uint16(27587), + 42: uint16(27588), + 43: uint16(27646), + 44: uint16(28366), + 45: uint16(28405), + 46: uint16(28401), + 47: uint16(28419), + 48: uint16(28453), + 49: uint16(28408), + 50: uint16(28471), + 51: uint16(28411), + 52: uint16(28462), + 53: uint16(28425), + 54: uint16(28494), + 55: uint16(28441), + 56: uint16(28442), + 57: uint16(28455), + 58: uint16(28440), + 59: uint16(28475), + 60: uint16(28434), + 61: uint16(28397), + 62: uint16(28426), + 63: uint16(28470), + 64: uint16(28531), + 65: uint16(28409), + 66: uint16(28398), + 67: uint16(28461), + 68: uint16(28480), + 69: uint16(28464), + 70: uint16(28476), + 71: uint16(28469), + 72: uint16(28395), + 73: uint16(28423), + 74: uint16(28430), + 75: uint16(28483), + 76: uint16(28421), + 77: uint16(28413), + 78: uint16(28406), + 79: uint16(28473), + 80: uint16(28444), + 81: uint16(28412), + 82: uint16(28474), + 83: uint16(28447), + 84: uint16(28429), + 85: uint16(28446), + 86: uint16(28424), + 87: uint16(28449), + 88: uint16(29063), + 89: uint16(29072), + 90: uint16(29065), + 91: uint16(29056), + 92: uint16(29061), + 93: uint16(29058), + 94: uint16(29071), + 95: uint16(29051), + 96: uint16(29062), + 97: uint16(29057), + 98: uint16(29079), + 99: uint16(29252), + 100: uint16(29267), + 101: uint16(29335), + 102: uint16(29333), + 103: uint16(29331), + 104: uint16(29507), + 105: uint16(29517), + 106: uint16(29521), + 107: uint16(29516), + 108: uint16(29794), + 109: uint16(29811), + 110: uint16(29809), + 111: uint16(29813), + 112: uint16(29810), + 113: uint16(29799), + 114: uint16(29806), + 115: uint16(29952), + 116: uint16(29954), + 117: uint16(29955), + 118: uint16(30077), + 119: uint16(30096), + 120: uint16(30230), + 121: uint16(30216), + 122: uint16(30220), + 123: uint16(30229), + 124: uint16(30225), + 125: uint16(30218), + 126: uint16(30228), + 127: uint16(30392), + 128: uint16(30593), + 129: uint16(30588), + 130: uint16(30597), + 131: uint16(30594), + 132: uint16(30574), + 133: uint16(30592), + 134: uint16(30575), + 135: uint16(30590), + 136: uint16(30595), + 137: uint16(30898), + 138: uint16(30890), + 139: uint16(30900), + 140: uint16(30893), + 141: uint16(30888), + 142: uint16(30846), + 143: uint16(30891), + 144: uint16(30878), + 145: uint16(30885), + 146: uint16(30880), + 147: uint16(30892), + 148: uint16(30882), + 149: uint16(30884), + 150: uint16(31128), + 151: uint16(31114), + 152: uint16(31115), + 153: uint16(31126), + 154: uint16(31125), + 155: uint16(31124), + 156: uint16(31123), + }, + 66: { + 0: uint16(31127), + 1: uint16(31112), + 2: uint16(31122), + 3: uint16(31120), + 4: uint16(31275), + 5: uint16(31306), + 6: uint16(31280), + 7: uint16(31279), + 8: uint16(31272), + 9: uint16(31270), + 10: uint16(31400), + 11: uint16(31403), + 12: uint16(31404), + 13: uint16(31470), + 14: uint16(31624), + 15: uint16(31644), + 16: uint16(31626), + 17: uint16(31633), + 18: uint16(31632), + 19: uint16(31638), + 20: uint16(31629), + 21: uint16(31628), + 22: uint16(31643), + 23: uint16(31630), + 24: uint16(31621), + 25: uint16(31640), + 26: uint16(21124), + 27: uint16(31641), + 28: uint16(31652), + 29: uint16(31618), + 30: uint16(31931), + 31: uint16(31935), + 32: uint16(31932), + 33: uint16(31930), + 34: uint16(32167), + 35: uint16(32183), + 36: uint16(32194), + 37: uint16(32163), + 38: uint16(32170), + 39: uint16(32193), + 40: uint16(32192), + 41: uint16(32197), + 42: uint16(32157), + 43: uint16(32206), + 44: uint16(32196), + 45: uint16(32198), + 46: uint16(32203), + 47: uint16(32204), + 48: uint16(32175), + 49: uint16(32185), + 50: uint16(32150), + 51: uint16(32188), + 52: uint16(32159), + 53: uint16(32166), + 54: uint16(32174), + 55: uint16(32169), + 56: uint16(32161), + 57: uint16(32201), + 58: uint16(32627), + 59: uint16(32738), + 60: uint16(32739), + 61: uint16(32741), + 62: uint16(32734), + 63: uint16(32804), + 64: uint16(32861), + 65: uint16(32860), + 66: uint16(33161), + 67: uint16(33158), + 68: uint16(33155), + 69: uint16(33159), + 70: uint16(33165), + 71: uint16(33164), + 72: uint16(33163), + 73: uint16(33301), + 74: uint16(33943), + 75: uint16(33956), + 76: uint16(33953), + 77: uint16(33951), + 78: uint16(33978), + 79: uint16(33998), + 80: uint16(33986), + 81: uint16(33964), + 82: uint16(33966), + 83: uint16(33963), + 84: uint16(33977), + 85: uint16(33972), + 86: uint16(33985), + 87: uint16(33997), + 88: uint16(33962), + 89: uint16(33946), + 90: uint16(33969), + 91: uint16(34000), + 92: uint16(33949), + 93: uint16(33959), + 94: uint16(33979), + 95: uint16(33954), + 96: uint16(33940), + 97: uint16(33991), + 98: uint16(33996), + 99: uint16(33947), + 100: uint16(33961), + 101: uint16(33967), + 102: uint16(33960), + 103: uint16(34006), + 104: uint16(33944), + 105: uint16(33974), + 106: uint16(33999), + 107: uint16(33952), + 108: uint16(34007), + 109: uint16(34004), + 110: uint16(34002), + 111: uint16(34011), + 112: uint16(33968), + 113: uint16(33937), + 114: uint16(34401), + 115: uint16(34611), + 116: uint16(34595), + 117: uint16(34600), + 118: uint16(34667), + 119: uint16(34624), + 120: uint16(34606), + 121: uint16(34590), + 122: uint16(34593), + 123: uint16(34585), + 124: uint16(34587), + 125: uint16(34627), + 126: uint16(34604), + 127: uint16(34625), + 128: uint16(34622), + 129: uint16(34630), + 130: uint16(34592), + 131: uint16(34610), + 132: uint16(34602), + 133: uint16(34605), + 134: uint16(34620), + 135: uint16(34578), + 136: uint16(34618), + 137: uint16(34609), + 138: uint16(34613), + 139: uint16(34626), + 140: uint16(34598), + 141: uint16(34599), + 142: uint16(34616), + 143: uint16(34596), + 144: uint16(34586), + 145: uint16(34608), + 146: uint16(34577), + 147: uint16(35063), + 148: uint16(35047), + 149: uint16(35057), + 150: uint16(35058), + 151: uint16(35066), + 152: uint16(35070), + 153: uint16(35054), + 154: uint16(35068), + 155: uint16(35062), + 156: uint16(35067), + }, + 67: { + 0: uint16(35056), + 1: uint16(35052), + 2: uint16(35051), + 3: uint16(35229), + 4: uint16(35233), + 5: uint16(35231), + 6: uint16(35230), + 7: uint16(35305), + 8: uint16(35307), + 9: uint16(35304), + 10: uint16(35499), + 11: uint16(35481), + 12: uint16(35467), + 13: uint16(35474), + 14: uint16(35471), + 15: uint16(35478), + 16: uint16(35901), + 17: uint16(35944), + 18: uint16(35945), + 19: uint16(36053), + 20: uint16(36047), + 21: uint16(36055), + 22: uint16(36246), + 23: uint16(36361), + 24: uint16(36354), + 25: uint16(36351), + 26: uint16(36365), + 27: uint16(36349), + 28: uint16(36362), + 29: uint16(36355), + 30: uint16(36359), + 31: uint16(36358), + 32: uint16(36357), + 33: uint16(36350), + 34: uint16(36352), + 35: uint16(36356), + 36: uint16(36624), + 37: uint16(36625), + 38: uint16(36622), + 39: uint16(36621), + 40: uint16(37155), + 41: uint16(37148), + 42: uint16(37152), + 43: uint16(37154), + 44: uint16(37151), + 45: uint16(37149), + 46: uint16(37146), + 47: uint16(37156), + 48: uint16(37153), + 49: uint16(37147), + 50: uint16(37242), + 51: uint16(37234), + 52: uint16(37241), + 53: uint16(37235), + 54: uint16(37541), + 55: uint16(37540), + 56: uint16(37494), + 57: uint16(37531), + 58: uint16(37498), + 59: uint16(37536), + 60: uint16(37524), + 61: uint16(37546), + 62: uint16(37517), + 63: uint16(37542), + 64: uint16(37530), + 65: uint16(37547), + 66: uint16(37497), + 67: uint16(37527), + 68: uint16(37503), + 69: uint16(37539), + 70: uint16(37614), + 71: uint16(37518), + 72: uint16(37506), + 73: uint16(37525), + 74: uint16(37538), + 75: uint16(37501), + 76: uint16(37512), + 77: uint16(37537), + 78: uint16(37514), + 79: uint16(37510), + 80: uint16(37516), + 81: uint16(37529), + 82: uint16(37543), + 83: uint16(37502), + 84: uint16(37511), + 85: uint16(37545), + 86: uint16(37533), + 87: uint16(37515), + 88: uint16(37421), + 89: uint16(38558), + 90: uint16(38561), + 91: uint16(38655), + 92: uint16(38744), + 93: uint16(38781), + 94: uint16(38778), + 95: uint16(38782), + 96: uint16(38787), + 97: uint16(38784), + 98: uint16(38786), + 99: uint16(38779), + 100: uint16(38788), + 101: uint16(38785), + 102: uint16(38783), + 103: uint16(38862), + 104: uint16(38861), + 105: uint16(38934), + 106: uint16(39085), + 107: uint16(39086), + 108: uint16(39170), + 109: uint16(39168), + 110: uint16(39175), + 111: uint16(39325), + 112: uint16(39324), + 113: uint16(39363), + 114: uint16(39353), + 115: uint16(39355), + 116: uint16(39354), + 117: uint16(39362), + 118: uint16(39357), + 119: uint16(39367), + 120: uint16(39601), + 121: uint16(39651), + 122: uint16(39655), + 123: uint16(39742), + 124: uint16(39743), + 125: uint16(39776), + 126: uint16(39777), + 127: uint16(39775), + 128: uint16(40177), + 129: uint16(40178), + 130: uint16(40181), + 131: uint16(40615), + 132: uint16(20735), + 133: uint16(20739), + 134: uint16(20784), + 135: uint16(20728), + 136: uint16(20742), + 137: uint16(20743), + 138: uint16(20726), + 139: uint16(20734), + 140: uint16(20747), + 141: uint16(20748), + 142: uint16(20733), + 143: uint16(20746), + 144: uint16(21131), + 145: uint16(21132), + 146: uint16(21233), + 147: uint16(21231), + 148: uint16(22088), + 149: uint16(22082), + 150: uint16(22092), + 151: uint16(22069), + 152: uint16(22081), + 153: uint16(22090), + 154: uint16(22089), + 155: uint16(22086), + 156: uint16(22104), + }, + 68: { + 0: uint16(22106), + 1: uint16(22080), + 2: uint16(22067), + 3: uint16(22077), + 4: uint16(22060), + 5: uint16(22078), + 6: uint16(22072), + 7: uint16(22058), + 8: uint16(22074), + 9: uint16(22298), + 10: uint16(22699), + 11: uint16(22685), + 12: uint16(22705), + 13: uint16(22688), + 14: uint16(22691), + 15: uint16(22703), + 16: uint16(22700), + 17: uint16(22693), + 18: uint16(22689), + 19: uint16(22783), + 20: uint16(23295), + 21: uint16(23284), + 22: uint16(23293), + 23: uint16(23287), + 24: uint16(23286), + 25: uint16(23299), + 26: uint16(23288), + 27: uint16(23298), + 28: uint16(23289), + 29: uint16(23297), + 30: uint16(23303), + 31: uint16(23301), + 32: uint16(23311), + 33: uint16(23655), + 34: uint16(23961), + 35: uint16(23959), + 36: uint16(23967), + 37: uint16(23954), + 38: uint16(23970), + 39: uint16(23955), + 40: uint16(23957), + 41: uint16(23968), + 42: uint16(23964), + 43: uint16(23969), + 44: uint16(23962), + 45: uint16(23966), + 46: uint16(24169), + 47: uint16(24157), + 48: uint16(24160), + 49: uint16(24156), + 50: uint16(32243), + 51: uint16(24283), + 52: uint16(24286), + 53: uint16(24289), + 54: uint16(24393), + 55: uint16(24498), + 56: uint16(24971), + 57: uint16(24963), + 58: uint16(24953), + 59: uint16(25009), + 60: uint16(25008), + 61: uint16(24994), + 62: uint16(24969), + 63: uint16(24987), + 64: uint16(24979), + 65: uint16(25007), + 66: uint16(25005), + 67: uint16(24991), + 68: uint16(24978), + 69: uint16(25002), + 70: uint16(24993), + 71: uint16(24973), + 72: uint16(24934), + 73: uint16(25011), + 74: uint16(25133), + 75: uint16(25710), + 76: uint16(25712), + 77: uint16(25750), + 78: uint16(25760), + 79: uint16(25733), + 80: uint16(25751), + 81: uint16(25756), + 82: uint16(25743), + 83: uint16(25739), + 84: uint16(25738), + 85: uint16(25740), + 86: uint16(25763), + 87: uint16(25759), + 88: uint16(25704), + 89: uint16(25777), + 90: uint16(25752), + 91: uint16(25974), + 92: uint16(25978), + 93: uint16(25977), + 94: uint16(25979), + 95: uint16(26034), + 96: uint16(26035), + 97: uint16(26293), + 98: uint16(26288), + 99: uint16(26281), + 100: uint16(26290), + 101: uint16(26295), + 102: uint16(26282), + 103: uint16(26287), + 104: uint16(27136), + 105: uint16(27142), + 106: uint16(27159), + 107: uint16(27109), + 108: uint16(27128), + 109: uint16(27157), + 110: uint16(27121), + 111: uint16(27108), + 112: uint16(27168), + 113: uint16(27135), + 114: uint16(27116), + 115: uint16(27106), + 116: uint16(27163), + 117: uint16(27165), + 118: uint16(27134), + 119: uint16(27175), + 120: uint16(27122), + 121: uint16(27118), + 122: uint16(27156), + 123: uint16(27127), + 124: uint16(27111), + 125: uint16(27200), + 126: uint16(27144), + 127: uint16(27110), + 128: uint16(27131), + 129: uint16(27149), + 130: uint16(27132), + 131: uint16(27115), + 132: uint16(27145), + 133: uint16(27140), + 134: uint16(27160), + 135: uint16(27173), + 136: uint16(27151), + 137: uint16(27126), + 138: uint16(27174), + 139: uint16(27143), + 140: uint16(27124), + 141: uint16(27158), + 142: uint16(27473), + 143: uint16(27557), + 144: uint16(27555), + 145: uint16(27554), + 146: uint16(27558), + 147: uint16(27649), + 148: uint16(27648), + 149: uint16(27647), + 150: uint16(27650), + 151: uint16(28481), + 152: uint16(28454), + 153: uint16(28542), + 154: uint16(28551), + 155: uint16(28614), + 156: uint16(28562), + }, + 69: { + 0: uint16(28557), + 1: uint16(28553), + 2: uint16(28556), + 3: uint16(28514), + 4: uint16(28495), + 5: uint16(28549), + 6: uint16(28506), + 7: uint16(28566), + 8: uint16(28534), + 9: uint16(28524), + 10: uint16(28546), + 11: uint16(28501), + 12: uint16(28530), + 13: uint16(28498), + 14: uint16(28496), + 15: uint16(28503), + 16: uint16(28564), + 17: uint16(28563), + 18: uint16(28509), + 19: uint16(28416), + 20: uint16(28513), + 21: uint16(28523), + 22: uint16(28541), + 23: uint16(28519), + 24: uint16(28560), + 25: uint16(28499), + 26: uint16(28555), + 27: uint16(28521), + 28: uint16(28543), + 29: uint16(28565), + 30: uint16(28515), + 31: uint16(28535), + 32: uint16(28522), + 33: uint16(28539), + 34: uint16(29106), + 35: uint16(29103), + 36: uint16(29083), + 37: uint16(29104), + 38: uint16(29088), + 39: uint16(29082), + 40: uint16(29097), + 41: uint16(29109), + 42: uint16(29085), + 43: uint16(29093), + 44: uint16(29086), + 45: uint16(29092), + 46: uint16(29089), + 47: uint16(29098), + 48: uint16(29084), + 49: uint16(29095), + 50: uint16(29107), + 51: uint16(29336), + 52: uint16(29338), + 53: uint16(29528), + 54: uint16(29522), + 55: uint16(29534), + 56: uint16(29535), + 57: uint16(29536), + 58: uint16(29533), + 59: uint16(29531), + 60: uint16(29537), + 61: uint16(29530), + 62: uint16(29529), + 63: uint16(29538), + 64: uint16(29831), + 65: uint16(29833), + 66: uint16(29834), + 67: uint16(29830), + 68: uint16(29825), + 69: uint16(29821), + 70: uint16(29829), + 71: uint16(29832), + 72: uint16(29820), + 73: uint16(29817), + 74: uint16(29960), + 75: uint16(29959), + 76: uint16(30078), + 77: uint16(30245), + 78: uint16(30238), + 79: uint16(30233), + 80: uint16(30237), + 81: uint16(30236), + 82: uint16(30243), + 83: uint16(30234), + 84: uint16(30248), + 85: uint16(30235), + 86: uint16(30364), + 87: uint16(30365), + 88: uint16(30366), + 89: uint16(30363), + 90: uint16(30605), + 91: uint16(30607), + 92: uint16(30601), + 93: uint16(30600), + 94: uint16(30925), + 95: uint16(30907), + 96: uint16(30927), + 97: uint16(30924), + 98: uint16(30929), + 99: uint16(30926), + 100: uint16(30932), + 101: uint16(30920), + 102: uint16(30915), + 103: uint16(30916), + 104: uint16(30921), + 105: uint16(31130), + 106: uint16(31137), + 107: uint16(31136), + 108: uint16(31132), + 109: uint16(31138), + 110: uint16(31131), + 111: uint16(27510), + 112: uint16(31289), + 113: uint16(31410), + 114: uint16(31412), + 115: uint16(31411), + 116: uint16(31671), + 117: uint16(31691), + 118: uint16(31678), + 119: uint16(31660), + 120: uint16(31694), + 121: uint16(31663), + 122: uint16(31673), + 123: uint16(31690), + 124: uint16(31669), + 125: uint16(31941), + 126: uint16(31944), + 127: uint16(31948), + 128: uint16(31947), + 129: uint16(32247), + 130: uint16(32219), + 131: uint16(32234), + 132: uint16(32231), + 133: uint16(32215), + 134: uint16(32225), + 135: uint16(32259), + 136: uint16(32250), + 137: uint16(32230), + 138: uint16(32246), + 139: uint16(32241), + 140: uint16(32240), + 141: uint16(32238), + 142: uint16(32223), + 143: uint16(32630), + 144: uint16(32684), + 145: uint16(32688), + 146: uint16(32685), + 147: uint16(32749), + 148: uint16(32747), + 149: uint16(32746), + 150: uint16(32748), + 151: uint16(32742), + 152: uint16(32744), + 153: uint16(32868), + 154: uint16(32871), + 155: uint16(33187), + 156: uint16(33183), + }, + 70: { + 0: uint16(33182), + 1: uint16(33173), + 2: uint16(33186), + 3: uint16(33177), + 4: uint16(33175), + 5: uint16(33302), + 6: uint16(33359), + 7: uint16(33363), + 8: uint16(33362), + 9: uint16(33360), + 10: uint16(33358), + 11: uint16(33361), + 12: uint16(34084), + 13: uint16(34107), + 14: uint16(34063), + 15: uint16(34048), + 16: uint16(34089), + 17: uint16(34062), + 18: uint16(34057), + 19: uint16(34061), + 20: uint16(34079), + 21: uint16(34058), + 22: uint16(34087), + 23: uint16(34076), + 24: uint16(34043), + 25: uint16(34091), + 26: uint16(34042), + 27: uint16(34056), + 28: uint16(34060), + 29: uint16(34036), + 30: uint16(34090), + 31: uint16(34034), + 32: uint16(34069), + 33: uint16(34039), + 34: uint16(34027), + 35: uint16(34035), + 36: uint16(34044), + 37: uint16(34066), + 38: uint16(34026), + 39: uint16(34025), + 40: uint16(34070), + 41: uint16(34046), + 42: uint16(34088), + 43: uint16(34077), + 44: uint16(34094), + 45: uint16(34050), + 46: uint16(34045), + 47: uint16(34078), + 48: uint16(34038), + 49: uint16(34097), + 50: uint16(34086), + 51: uint16(34023), + 52: uint16(34024), + 53: uint16(34032), + 54: uint16(34031), + 55: uint16(34041), + 56: uint16(34072), + 57: uint16(34080), + 58: uint16(34096), + 59: uint16(34059), + 60: uint16(34073), + 61: uint16(34095), + 62: uint16(34402), + 63: uint16(34646), + 64: uint16(34659), + 65: uint16(34660), + 66: uint16(34679), + 67: uint16(34785), + 68: uint16(34675), + 69: uint16(34648), + 70: uint16(34644), + 71: uint16(34651), + 72: uint16(34642), + 73: uint16(34657), + 74: uint16(34650), + 75: uint16(34641), + 76: uint16(34654), + 77: uint16(34669), + 78: uint16(34666), + 79: uint16(34640), + 80: uint16(34638), + 81: uint16(34655), + 82: uint16(34653), + 83: uint16(34671), + 84: uint16(34668), + 85: uint16(34682), + 86: uint16(34670), + 87: uint16(34652), + 88: uint16(34661), + 89: uint16(34639), + 90: uint16(34683), + 91: uint16(34677), + 92: uint16(34658), + 93: uint16(34663), + 94: uint16(34665), + 95: uint16(34906), + 96: uint16(35077), + 97: uint16(35084), + 98: uint16(35092), + 99: uint16(35083), + 100: uint16(35095), + 101: uint16(35096), + 102: uint16(35097), + 103: uint16(35078), + 104: uint16(35094), + 105: uint16(35089), + 106: uint16(35086), + 107: uint16(35081), + 108: uint16(35234), + 109: uint16(35236), + 110: uint16(35235), + 111: uint16(35309), + 112: uint16(35312), + 113: uint16(35308), + 114: uint16(35535), + 115: uint16(35526), + 116: uint16(35512), + 117: uint16(35539), + 118: uint16(35537), + 119: uint16(35540), + 120: uint16(35541), + 121: uint16(35515), + 122: uint16(35543), + 123: uint16(35518), + 124: uint16(35520), + 125: uint16(35525), + 126: uint16(35544), + 127: uint16(35523), + 128: uint16(35514), + 129: uint16(35517), + 130: uint16(35545), + 131: uint16(35902), + 132: uint16(35917), + 133: uint16(35983), + 134: uint16(36069), + 135: uint16(36063), + 136: uint16(36057), + 137: uint16(36072), + 138: uint16(36058), + 139: uint16(36061), + 140: uint16(36071), + 141: uint16(36256), + 142: uint16(36252), + 143: uint16(36257), + 144: uint16(36251), + 145: uint16(36384), + 146: uint16(36387), + 147: uint16(36389), + 148: uint16(36388), + 149: uint16(36398), + 150: uint16(36373), + 151: uint16(36379), + 152: uint16(36374), + 153: uint16(36369), + 154: uint16(36377), + 155: uint16(36390), + 156: uint16(36391), + }, + 71: { + 0: uint16(36372), + 1: uint16(36370), + 2: uint16(36376), + 3: uint16(36371), + 4: uint16(36380), + 5: uint16(36375), + 6: uint16(36378), + 7: uint16(36652), + 8: uint16(36644), + 9: uint16(36632), + 10: uint16(36634), + 11: uint16(36640), + 12: uint16(36643), + 13: uint16(36630), + 14: uint16(36631), + 15: uint16(36979), + 16: uint16(36976), + 17: uint16(36975), + 18: uint16(36967), + 19: uint16(36971), + 20: uint16(37167), + 21: uint16(37163), + 22: uint16(37161), + 23: uint16(37162), + 24: uint16(37170), + 25: uint16(37158), + 26: uint16(37166), + 27: uint16(37253), + 28: uint16(37254), + 29: uint16(37258), + 30: uint16(37249), + 31: uint16(37250), + 32: uint16(37252), + 33: uint16(37248), + 34: uint16(37584), + 35: uint16(37571), + 36: uint16(37572), + 37: uint16(37568), + 38: uint16(37593), + 39: uint16(37558), + 40: uint16(37583), + 41: uint16(37617), + 42: uint16(37599), + 43: uint16(37592), + 44: uint16(37609), + 45: uint16(37591), + 46: uint16(37597), + 47: uint16(37580), + 48: uint16(37615), + 49: uint16(37570), + 50: uint16(37608), + 51: uint16(37578), + 52: uint16(37576), + 53: uint16(37582), + 54: uint16(37606), + 55: uint16(37581), + 56: uint16(37589), + 57: uint16(37577), + 58: uint16(37600), + 59: uint16(37598), + 60: uint16(37607), + 61: uint16(37585), + 62: uint16(37587), + 63: uint16(37557), + 64: uint16(37601), + 65: uint16(37574), + 66: uint16(37556), + 67: uint16(38268), + 68: uint16(38316), + 69: uint16(38315), + 70: uint16(38318), + 71: uint16(38320), + 72: uint16(38564), + 73: uint16(38562), + 74: uint16(38611), + 75: uint16(38661), + 76: uint16(38664), + 77: uint16(38658), + 78: uint16(38746), + 79: uint16(38794), + 80: uint16(38798), + 81: uint16(38792), + 82: uint16(38864), + 83: uint16(38863), + 84: uint16(38942), + 85: uint16(38941), + 86: uint16(38950), + 87: uint16(38953), + 88: uint16(38952), + 89: uint16(38944), + 90: uint16(38939), + 91: uint16(38951), + 92: uint16(39090), + 93: uint16(39176), + 94: uint16(39162), + 95: uint16(39185), + 96: uint16(39188), + 97: uint16(39190), + 98: uint16(39191), + 99: uint16(39189), + 100: uint16(39388), + 101: uint16(39373), + 102: uint16(39375), + 103: uint16(39379), + 104: uint16(39380), + 105: uint16(39374), + 106: uint16(39369), + 107: uint16(39382), + 108: uint16(39384), + 109: uint16(39371), + 110: uint16(39383), + 111: uint16(39372), + 112: uint16(39603), + 113: uint16(39660), + 114: uint16(39659), + 115: uint16(39667), + 116: uint16(39666), + 117: uint16(39665), + 118: uint16(39750), + 119: uint16(39747), + 120: uint16(39783), + 121: uint16(39796), + 122: uint16(39793), + 123: uint16(39782), + 124: uint16(39798), + 125: uint16(39797), + 126: uint16(39792), + 127: uint16(39784), + 128: uint16(39780), + 129: uint16(39788), + 130: uint16(40188), + 131: uint16(40186), + 132: uint16(40189), + 133: uint16(40191), + 134: uint16(40183), + 135: uint16(40199), + 136: uint16(40192), + 137: uint16(40185), + 138: uint16(40187), + 139: uint16(40200), + 140: uint16(40197), + 141: uint16(40196), + 142: uint16(40579), + 143: uint16(40659), + 144: uint16(40719), + 145: uint16(40720), + 146: uint16(20764), + 147: uint16(20755), + 148: uint16(20759), + 149: uint16(20762), + 150: uint16(20753), + 151: uint16(20958), + 152: uint16(21300), + 153: uint16(21473), + 154: uint16(22128), + 155: uint16(22112), + 156: uint16(22126), + }, + 72: { + 0: uint16(22131), + 1: uint16(22118), + 2: uint16(22115), + 3: uint16(22125), + 4: uint16(22130), + 5: uint16(22110), + 6: uint16(22135), + 7: uint16(22300), + 8: uint16(22299), + 9: uint16(22728), + 10: uint16(22717), + 11: uint16(22729), + 12: uint16(22719), + 13: uint16(22714), + 14: uint16(22722), + 15: uint16(22716), + 16: uint16(22726), + 17: uint16(23319), + 18: uint16(23321), + 19: uint16(23323), + 20: uint16(23329), + 21: uint16(23316), + 22: uint16(23315), + 23: uint16(23312), + 24: uint16(23318), + 25: uint16(23336), + 26: uint16(23322), + 27: uint16(23328), + 28: uint16(23326), + 29: uint16(23535), + 30: uint16(23980), + 31: uint16(23985), + 32: uint16(23977), + 33: uint16(23975), + 34: uint16(23989), + 35: uint16(23984), + 36: uint16(23982), + 37: uint16(23978), + 38: uint16(23976), + 39: uint16(23986), + 40: uint16(23981), + 41: uint16(23983), + 42: uint16(23988), + 43: uint16(24167), + 44: uint16(24168), + 45: uint16(24166), + 46: uint16(24175), + 47: uint16(24297), + 48: uint16(24295), + 49: uint16(24294), + 50: uint16(24296), + 51: uint16(24293), + 52: uint16(24395), + 53: uint16(24508), + 54: uint16(24989), + 55: uint16(25000), + 56: uint16(24982), + 57: uint16(25029), + 58: uint16(25012), + 59: uint16(25030), + 60: uint16(25025), + 61: uint16(25036), + 62: uint16(25018), + 63: uint16(25023), + 64: uint16(25016), + 65: uint16(24972), + 66: uint16(25815), + 67: uint16(25814), + 68: uint16(25808), + 69: uint16(25807), + 70: uint16(25801), + 71: uint16(25789), + 72: uint16(25737), + 73: uint16(25795), + 74: uint16(25819), + 75: uint16(25843), + 76: uint16(25817), + 77: uint16(25907), + 78: uint16(25983), + 79: uint16(25980), + 80: uint16(26018), + 81: uint16(26312), + 82: uint16(26302), + 83: uint16(26304), + 84: uint16(26314), + 85: uint16(26315), + 86: uint16(26319), + 87: uint16(26301), + 88: uint16(26299), + 89: uint16(26298), + 90: uint16(26316), + 91: uint16(26403), + 92: uint16(27188), + 93: uint16(27238), + 94: uint16(27209), + 95: uint16(27239), + 96: uint16(27186), + 97: uint16(27240), + 98: uint16(27198), + 99: uint16(27229), + 100: uint16(27245), + 101: uint16(27254), + 102: uint16(27227), + 103: uint16(27217), + 104: uint16(27176), + 105: uint16(27226), + 106: uint16(27195), + 107: uint16(27199), + 108: uint16(27201), + 109: uint16(27242), + 110: uint16(27236), + 111: uint16(27216), + 112: uint16(27215), + 113: uint16(27220), + 114: uint16(27247), + 115: uint16(27241), + 116: uint16(27232), + 117: uint16(27196), + 118: uint16(27230), + 119: uint16(27222), + 120: uint16(27221), + 121: uint16(27213), + 122: uint16(27214), + 123: uint16(27206), + 124: uint16(27477), + 125: uint16(27476), + 126: uint16(27478), + 127: uint16(27559), + 128: uint16(27562), + 129: uint16(27563), + 130: uint16(27592), + 131: uint16(27591), + 132: uint16(27652), + 133: uint16(27651), + 134: uint16(27654), + 135: uint16(28589), + 136: uint16(28619), + 137: uint16(28579), + 138: uint16(28615), + 139: uint16(28604), + 140: uint16(28622), + 141: uint16(28616), + 142: uint16(28510), + 143: uint16(28612), + 144: uint16(28605), + 145: uint16(28574), + 146: uint16(28618), + 147: uint16(28584), + 148: uint16(28676), + 149: uint16(28581), + 150: uint16(28590), + 151: uint16(28602), + 152: uint16(28588), + 153: uint16(28586), + 154: uint16(28623), + 155: uint16(28607), + 156: uint16(28600), + }, + 73: { + 0: uint16(28578), + 1: uint16(28617), + 2: uint16(28587), + 3: uint16(28621), + 4: uint16(28591), + 5: uint16(28594), + 6: uint16(28592), + 7: uint16(29125), + 8: uint16(29122), + 9: uint16(29119), + 10: uint16(29112), + 11: uint16(29142), + 12: uint16(29120), + 13: uint16(29121), + 14: uint16(29131), + 15: uint16(29140), + 16: uint16(29130), + 17: uint16(29127), + 18: uint16(29135), + 19: uint16(29117), + 20: uint16(29144), + 21: uint16(29116), + 22: uint16(29126), + 23: uint16(29146), + 24: uint16(29147), + 25: uint16(29341), + 26: uint16(29342), + 27: uint16(29545), + 28: uint16(29542), + 29: uint16(29543), + 30: uint16(29548), + 31: uint16(29541), + 32: uint16(29547), + 33: uint16(29546), + 34: uint16(29823), + 35: uint16(29850), + 36: uint16(29856), + 37: uint16(29844), + 38: uint16(29842), + 39: uint16(29845), + 40: uint16(29857), + 41: uint16(29963), + 42: uint16(30080), + 43: uint16(30255), + 44: uint16(30253), + 45: uint16(30257), + 46: uint16(30269), + 47: uint16(30259), + 48: uint16(30268), + 49: uint16(30261), + 50: uint16(30258), + 51: uint16(30256), + 52: uint16(30395), + 53: uint16(30438), + 54: uint16(30618), + 55: uint16(30621), + 56: uint16(30625), + 57: uint16(30620), + 58: uint16(30619), + 59: uint16(30626), + 60: uint16(30627), + 61: uint16(30613), + 62: uint16(30617), + 63: uint16(30615), + 64: uint16(30941), + 65: uint16(30953), + 66: uint16(30949), + 67: uint16(30954), + 68: uint16(30942), + 69: uint16(30947), + 70: uint16(30939), + 71: uint16(30945), + 72: uint16(30946), + 73: uint16(30957), + 74: uint16(30943), + 75: uint16(30944), + 76: uint16(31140), + 77: uint16(31300), + 78: uint16(31304), + 79: uint16(31303), + 80: uint16(31414), + 81: uint16(31416), + 82: uint16(31413), + 83: uint16(31409), + 84: uint16(31415), + 85: uint16(31710), + 86: uint16(31715), + 87: uint16(31719), + 88: uint16(31709), + 89: uint16(31701), + 90: uint16(31717), + 91: uint16(31706), + 92: uint16(31720), + 93: uint16(31737), + 94: uint16(31700), + 95: uint16(31722), + 96: uint16(31714), + 97: uint16(31708), + 98: uint16(31723), + 99: uint16(31704), + 100: uint16(31711), + 101: uint16(31954), + 102: uint16(31956), + 103: uint16(31959), + 104: uint16(31952), + 105: uint16(31953), + 106: uint16(32274), + 107: uint16(32289), + 108: uint16(32279), + 109: uint16(32268), + 110: uint16(32287), + 111: uint16(32288), + 112: uint16(32275), + 113: uint16(32270), + 114: uint16(32284), + 115: uint16(32277), + 116: uint16(32282), + 117: uint16(32290), + 118: uint16(32267), + 119: uint16(32271), + 120: uint16(32278), + 121: uint16(32269), + 122: uint16(32276), + 123: uint16(32293), + 124: uint16(32292), + 125: uint16(32579), + 126: uint16(32635), + 127: uint16(32636), + 128: uint16(32634), + 129: uint16(32689), + 130: uint16(32751), + 131: uint16(32810), + 132: uint16(32809), + 133: uint16(32876), + 134: uint16(33201), + 135: uint16(33190), + 136: uint16(33198), + 137: uint16(33209), + 138: uint16(33205), + 139: uint16(33195), + 140: uint16(33200), + 141: uint16(33196), + 142: uint16(33204), + 143: uint16(33202), + 144: uint16(33207), + 145: uint16(33191), + 146: uint16(33266), + 147: uint16(33365), + 148: uint16(33366), + 149: uint16(33367), + 150: uint16(34134), + 151: uint16(34117), + 152: uint16(34155), + 153: uint16(34125), + 154: uint16(34131), + 155: uint16(34145), + 156: uint16(34136), + }, + 74: { + 0: uint16(34112), + 1: uint16(34118), + 2: uint16(34148), + 3: uint16(34113), + 4: uint16(34146), + 5: uint16(34116), + 6: uint16(34129), + 7: uint16(34119), + 8: uint16(34147), + 9: uint16(34110), + 10: uint16(34139), + 11: uint16(34161), + 12: uint16(34126), + 13: uint16(34158), + 14: uint16(34165), + 15: uint16(34133), + 16: uint16(34151), + 17: uint16(34144), + 18: uint16(34188), + 19: uint16(34150), + 20: uint16(34141), + 21: uint16(34132), + 22: uint16(34149), + 23: uint16(34156), + 24: uint16(34403), + 25: uint16(34405), + 26: uint16(34404), + 27: uint16(34715), + 28: uint16(34703), + 29: uint16(34711), + 30: uint16(34707), + 31: uint16(34706), + 32: uint16(34696), + 33: uint16(34689), + 34: uint16(34710), + 35: uint16(34712), + 36: uint16(34681), + 37: uint16(34695), + 38: uint16(34723), + 39: uint16(34693), + 40: uint16(34704), + 41: uint16(34705), + 42: uint16(34717), + 43: uint16(34692), + 44: uint16(34708), + 45: uint16(34716), + 46: uint16(34714), + 47: uint16(34697), + 48: uint16(35102), + 49: uint16(35110), + 50: uint16(35120), + 51: uint16(35117), + 52: uint16(35118), + 53: uint16(35111), + 54: uint16(35121), + 55: uint16(35106), + 56: uint16(35113), + 57: uint16(35107), + 58: uint16(35119), + 59: uint16(35116), + 60: uint16(35103), + 61: uint16(35313), + 62: uint16(35552), + 63: uint16(35554), + 64: uint16(35570), + 65: uint16(35572), + 66: uint16(35573), + 67: uint16(35549), + 68: uint16(35604), + 69: uint16(35556), + 70: uint16(35551), + 71: uint16(35568), + 72: uint16(35528), + 73: uint16(35550), + 74: uint16(35553), + 75: uint16(35560), + 76: uint16(35583), + 77: uint16(35567), + 78: uint16(35579), + 79: uint16(35985), + 80: uint16(35986), + 81: uint16(35984), + 82: uint16(36085), + 83: uint16(36078), + 84: uint16(36081), + 85: uint16(36080), + 86: uint16(36083), + 87: uint16(36204), + 88: uint16(36206), + 89: uint16(36261), + 90: uint16(36263), + 91: uint16(36403), + 92: uint16(36414), + 93: uint16(36408), + 94: uint16(36416), + 95: uint16(36421), + 96: uint16(36406), + 97: uint16(36412), + 98: uint16(36413), + 99: uint16(36417), + 100: uint16(36400), + 101: uint16(36415), + 102: uint16(36541), + 103: uint16(36662), + 104: uint16(36654), + 105: uint16(36661), + 106: uint16(36658), + 107: uint16(36665), + 108: uint16(36663), + 109: uint16(36660), + 110: uint16(36982), + 111: uint16(36985), + 112: uint16(36987), + 113: uint16(36998), + 114: uint16(37114), + 115: uint16(37171), + 116: uint16(37173), + 117: uint16(37174), + 118: uint16(37267), + 119: uint16(37264), + 120: uint16(37265), + 121: uint16(37261), + 122: uint16(37263), + 123: uint16(37671), + 124: uint16(37662), + 125: uint16(37640), + 126: uint16(37663), + 127: uint16(37638), + 128: uint16(37647), + 129: uint16(37754), + 130: uint16(37688), + 131: uint16(37692), + 132: uint16(37659), + 133: uint16(37667), + 134: uint16(37650), + 135: uint16(37633), + 136: uint16(37702), + 137: uint16(37677), + 138: uint16(37646), + 139: uint16(37645), + 140: uint16(37579), + 141: uint16(37661), + 142: uint16(37626), + 143: uint16(37669), + 144: uint16(37651), + 145: uint16(37625), + 146: uint16(37623), + 147: uint16(37684), + 148: uint16(37634), + 149: uint16(37668), + 150: uint16(37631), + 151: uint16(37673), + 152: uint16(37689), + 153: uint16(37685), + 154: uint16(37674), + 155: uint16(37652), + 156: uint16(37644), + }, + 75: { + 0: uint16(37643), + 1: uint16(37630), + 2: uint16(37641), + 3: uint16(37632), + 4: uint16(37627), + 5: uint16(37654), + 6: uint16(38332), + 7: uint16(38349), + 8: uint16(38334), + 9: uint16(38329), + 10: uint16(38330), + 11: uint16(38326), + 12: uint16(38335), + 13: uint16(38325), + 14: uint16(38333), + 15: uint16(38569), + 16: uint16(38612), + 17: uint16(38667), + 18: uint16(38674), + 19: uint16(38672), + 20: uint16(38809), + 21: uint16(38807), + 22: uint16(38804), + 23: uint16(38896), + 24: uint16(38904), + 25: uint16(38965), + 26: uint16(38959), + 27: uint16(38962), + 28: uint16(39204), + 29: uint16(39199), + 30: uint16(39207), + 31: uint16(39209), + 32: uint16(39326), + 33: uint16(39406), + 34: uint16(39404), + 35: uint16(39397), + 36: uint16(39396), + 37: uint16(39408), + 38: uint16(39395), + 39: uint16(39402), + 40: uint16(39401), + 41: uint16(39399), + 42: uint16(39609), + 43: uint16(39615), + 44: uint16(39604), + 45: uint16(39611), + 46: uint16(39670), + 47: uint16(39674), + 48: uint16(39673), + 49: uint16(39671), + 50: uint16(39731), + 51: uint16(39808), + 52: uint16(39813), + 53: uint16(39815), + 54: uint16(39804), + 55: uint16(39806), + 56: uint16(39803), + 57: uint16(39810), + 58: uint16(39827), + 59: uint16(39826), + 60: uint16(39824), + 61: uint16(39802), + 62: uint16(39829), + 63: uint16(39805), + 64: uint16(39816), + 65: uint16(40229), + 66: uint16(40215), + 67: uint16(40224), + 68: uint16(40222), + 69: uint16(40212), + 70: uint16(40233), + 71: uint16(40221), + 72: uint16(40216), + 73: uint16(40226), + 74: uint16(40208), + 75: uint16(40217), + 76: uint16(40223), + 77: uint16(40584), + 78: uint16(40582), + 79: uint16(40583), + 80: uint16(40622), + 81: uint16(40621), + 82: uint16(40661), + 83: uint16(40662), + 84: uint16(40698), + 85: uint16(40722), + 86: uint16(40765), + 87: uint16(20774), + 88: uint16(20773), + 89: uint16(20770), + 90: uint16(20772), + 91: uint16(20768), + 92: uint16(20777), + 93: uint16(21236), + 94: uint16(22163), + 95: uint16(22156), + 96: uint16(22157), + 97: uint16(22150), + 98: uint16(22148), + 99: uint16(22147), + 100: uint16(22142), + 101: uint16(22146), + 102: uint16(22143), + 103: uint16(22145), + 104: uint16(22742), + 105: uint16(22740), + 106: uint16(22735), + 107: uint16(22738), + 108: uint16(23341), + 109: uint16(23333), + 110: uint16(23346), + 111: uint16(23331), + 112: uint16(23340), + 113: uint16(23335), + 114: uint16(23334), + 115: uint16(23343), + 116: uint16(23342), + 117: uint16(23419), + 118: uint16(23537), + 119: uint16(23538), + 120: uint16(23991), + 121: uint16(24172), + 122: uint16(24170), + 123: uint16(24510), + 124: uint16(24507), + 125: uint16(25027), + 126: uint16(25013), + 127: uint16(25020), + 128: uint16(25063), + 129: uint16(25056), + 130: uint16(25061), + 131: uint16(25060), + 132: uint16(25064), + 133: uint16(25054), + 134: uint16(25839), + 135: uint16(25833), + 136: uint16(25827), + 137: uint16(25835), + 138: uint16(25828), + 139: uint16(25832), + 140: uint16(25985), + 141: uint16(25984), + 142: uint16(26038), + 143: uint16(26074), + 144: uint16(26322), + 145: uint16(27277), + 146: uint16(27286), + 147: uint16(27265), + 148: uint16(27301), + 149: uint16(27273), + 150: uint16(27295), + 151: uint16(27291), + 152: uint16(27297), + 153: uint16(27294), + 154: uint16(27271), + 155: uint16(27283), + 156: uint16(27278), + }, + 76: { + 0: uint16(27285), + 1: uint16(27267), + 2: uint16(27304), + 3: uint16(27300), + 4: uint16(27281), + 5: uint16(27263), + 6: uint16(27302), + 7: uint16(27290), + 8: uint16(27269), + 9: uint16(27276), + 10: uint16(27282), + 11: uint16(27483), + 12: uint16(27565), + 13: uint16(27657), + 14: uint16(28620), + 15: uint16(28585), + 16: uint16(28660), + 17: uint16(28628), + 18: uint16(28643), + 19: uint16(28636), + 20: uint16(28653), + 21: uint16(28647), + 22: uint16(28646), + 23: uint16(28638), + 24: uint16(28658), + 25: uint16(28637), + 26: uint16(28642), + 27: uint16(28648), + 28: uint16(29153), + 29: uint16(29169), + 30: uint16(29160), + 31: uint16(29170), + 32: uint16(29156), + 33: uint16(29168), + 34: uint16(29154), + 35: uint16(29555), + 36: uint16(29550), + 37: uint16(29551), + 38: uint16(29847), + 39: uint16(29874), + 40: uint16(29867), + 41: uint16(29840), + 42: uint16(29866), + 43: uint16(29869), + 44: uint16(29873), + 45: uint16(29861), + 46: uint16(29871), + 47: uint16(29968), + 48: uint16(29969), + 49: uint16(29970), + 50: uint16(29967), + 51: uint16(30084), + 52: uint16(30275), + 53: uint16(30280), + 54: uint16(30281), + 55: uint16(30279), + 56: uint16(30372), + 57: uint16(30441), + 58: uint16(30645), + 59: uint16(30635), + 60: uint16(30642), + 61: uint16(30647), + 62: uint16(30646), + 63: uint16(30644), + 64: uint16(30641), + 65: uint16(30632), + 66: uint16(30704), + 67: uint16(30963), + 68: uint16(30973), + 69: uint16(30978), + 70: uint16(30971), + 71: uint16(30972), + 72: uint16(30962), + 73: uint16(30981), + 74: uint16(30969), + 75: uint16(30974), + 76: uint16(30980), + 77: uint16(31147), + 78: uint16(31144), + 79: uint16(31324), + 80: uint16(31323), + 81: uint16(31318), + 82: uint16(31320), + 83: uint16(31316), + 84: uint16(31322), + 85: uint16(31422), + 86: uint16(31424), + 87: uint16(31425), + 88: uint16(31749), + 89: uint16(31759), + 90: uint16(31730), + 91: uint16(31744), + 92: uint16(31743), + 93: uint16(31739), + 94: uint16(31758), + 95: uint16(31732), + 96: uint16(31755), + 97: uint16(31731), + 98: uint16(31746), + 99: uint16(31753), + 100: uint16(31747), + 101: uint16(31745), + 102: uint16(31736), + 103: uint16(31741), + 104: uint16(31750), + 105: uint16(31728), + 106: uint16(31729), + 107: uint16(31760), + 108: uint16(31754), + 109: uint16(31976), + 110: uint16(32301), + 111: uint16(32316), + 112: uint16(32322), + 113: uint16(32307), + 114: uint16(38984), + 115: uint16(32312), + 116: uint16(32298), + 117: uint16(32329), + 118: uint16(32320), + 119: uint16(32327), + 120: uint16(32297), + 121: uint16(32332), + 122: uint16(32304), + 123: uint16(32315), + 124: uint16(32310), + 125: uint16(32324), + 126: uint16(32314), + 127: uint16(32581), + 128: uint16(32639), + 129: uint16(32638), + 130: uint16(32637), + 131: uint16(32756), + 132: uint16(32754), + 133: uint16(32812), + 134: uint16(33211), + 135: uint16(33220), + 136: uint16(33228), + 137: uint16(33226), + 138: uint16(33221), + 139: uint16(33223), + 140: uint16(33212), + 141: uint16(33257), + 142: uint16(33371), + 143: uint16(33370), + 144: uint16(33372), + 145: uint16(34179), + 146: uint16(34176), + 147: uint16(34191), + 148: uint16(34215), + 149: uint16(34197), + 150: uint16(34208), + 151: uint16(34187), + 152: uint16(34211), + 153: uint16(34171), + 154: uint16(34212), + 155: uint16(34202), + 156: uint16(34206), + }, + 77: { + 0: uint16(34167), + 1: uint16(34172), + 2: uint16(34185), + 3: uint16(34209), + 4: uint16(34170), + 5: uint16(34168), + 6: uint16(34135), + 7: uint16(34190), + 8: uint16(34198), + 9: uint16(34182), + 10: uint16(34189), + 11: uint16(34201), + 12: uint16(34205), + 13: uint16(34177), + 14: uint16(34210), + 15: uint16(34178), + 16: uint16(34184), + 17: uint16(34181), + 18: uint16(34169), + 19: uint16(34166), + 20: uint16(34200), + 21: uint16(34192), + 22: uint16(34207), + 23: uint16(34408), + 24: uint16(34750), + 25: uint16(34730), + 26: uint16(34733), + 27: uint16(34757), + 28: uint16(34736), + 29: uint16(34732), + 30: uint16(34745), + 31: uint16(34741), + 32: uint16(34748), + 33: uint16(34734), + 34: uint16(34761), + 35: uint16(34755), + 36: uint16(34754), + 37: uint16(34764), + 38: uint16(34743), + 39: uint16(34735), + 40: uint16(34756), + 41: uint16(34762), + 42: uint16(34740), + 43: uint16(34742), + 44: uint16(34751), + 45: uint16(34744), + 46: uint16(34749), + 47: uint16(34782), + 48: uint16(34738), + 49: uint16(35125), + 50: uint16(35123), + 51: uint16(35132), + 52: uint16(35134), + 53: uint16(35137), + 54: uint16(35154), + 55: uint16(35127), + 56: uint16(35138), + 57: uint16(35245), + 58: uint16(35247), + 59: uint16(35246), + 60: uint16(35314), + 61: uint16(35315), + 62: uint16(35614), + 63: uint16(35608), + 64: uint16(35606), + 65: uint16(35601), + 66: uint16(35589), + 67: uint16(35595), + 68: uint16(35618), + 69: uint16(35599), + 70: uint16(35602), + 71: uint16(35605), + 72: uint16(35591), + 73: uint16(35597), + 74: uint16(35592), + 75: uint16(35590), + 76: uint16(35612), + 77: uint16(35603), + 78: uint16(35610), + 79: uint16(35919), + 80: uint16(35952), + 81: uint16(35954), + 82: uint16(35953), + 83: uint16(35951), + 84: uint16(35989), + 85: uint16(35988), + 86: uint16(36089), + 87: uint16(36207), + 88: uint16(36430), + 89: uint16(36429), + 90: uint16(36435), + 91: uint16(36432), + 92: uint16(36428), + 93: uint16(36423), + 94: uint16(36675), + 95: uint16(36672), + 96: uint16(36997), + 97: uint16(36990), + 98: uint16(37176), + 99: uint16(37274), + 100: uint16(37282), + 101: uint16(37275), + 102: uint16(37273), + 103: uint16(37279), + 104: uint16(37281), + 105: uint16(37277), + 106: uint16(37280), + 107: uint16(37793), + 108: uint16(37763), + 109: uint16(37807), + 110: uint16(37732), + 111: uint16(37718), + 112: uint16(37703), + 113: uint16(37756), + 114: uint16(37720), + 115: uint16(37724), + 116: uint16(37750), + 117: uint16(37705), + 118: uint16(37712), + 119: uint16(37713), + 120: uint16(37728), + 121: uint16(37741), + 122: uint16(37775), + 123: uint16(37708), + 124: uint16(37738), + 125: uint16(37753), + 126: uint16(37719), + 127: uint16(37717), + 128: uint16(37714), + 129: uint16(37711), + 130: uint16(37745), + 131: uint16(37751), + 132: uint16(37755), + 133: uint16(37729), + 134: uint16(37726), + 135: uint16(37731), + 136: uint16(37735), + 137: uint16(37760), + 138: uint16(37710), + 139: uint16(37721), + 140: uint16(38343), + 141: uint16(38336), + 142: uint16(38345), + 143: uint16(38339), + 144: uint16(38341), + 145: uint16(38327), + 146: uint16(38574), + 147: uint16(38576), + 148: uint16(38572), + 149: uint16(38688), + 150: uint16(38687), + 151: uint16(38680), + 152: uint16(38685), + 153: uint16(38681), + 154: uint16(38810), + 155: uint16(38817), + 156: uint16(38812), + }, + 78: { + 0: uint16(38814), + 1: uint16(38813), + 2: uint16(38869), + 3: uint16(38868), + 4: uint16(38897), + 5: uint16(38977), + 6: uint16(38980), + 7: uint16(38986), + 8: uint16(38985), + 9: uint16(38981), + 10: uint16(38979), + 11: uint16(39205), + 12: uint16(39211), + 13: uint16(39212), + 14: uint16(39210), + 15: uint16(39219), + 16: uint16(39218), + 17: uint16(39215), + 18: uint16(39213), + 19: uint16(39217), + 20: uint16(39216), + 21: uint16(39320), + 22: uint16(39331), + 23: uint16(39329), + 24: uint16(39426), + 25: uint16(39418), + 26: uint16(39412), + 27: uint16(39415), + 28: uint16(39417), + 29: uint16(39416), + 30: uint16(39414), + 31: uint16(39419), + 32: uint16(39421), + 33: uint16(39422), + 34: uint16(39420), + 35: uint16(39427), + 36: uint16(39614), + 37: uint16(39678), + 38: uint16(39677), + 39: uint16(39681), + 40: uint16(39676), + 41: uint16(39752), + 42: uint16(39834), + 43: uint16(39848), + 44: uint16(39838), + 45: uint16(39835), + 46: uint16(39846), + 47: uint16(39841), + 48: uint16(39845), + 49: uint16(39844), + 50: uint16(39814), + 51: uint16(39842), + 52: uint16(39840), + 53: uint16(39855), + 54: uint16(40243), + 55: uint16(40257), + 56: uint16(40295), + 57: uint16(40246), + 58: uint16(40238), + 59: uint16(40239), + 60: uint16(40241), + 61: uint16(40248), + 62: uint16(40240), + 63: uint16(40261), + 64: uint16(40258), + 65: uint16(40259), + 66: uint16(40254), + 67: uint16(40247), + 68: uint16(40256), + 69: uint16(40253), + 70: uint16(32757), + 71: uint16(40237), + 72: uint16(40586), + 73: uint16(40585), + 74: uint16(40589), + 75: uint16(40624), + 76: uint16(40648), + 77: uint16(40666), + 78: uint16(40699), + 79: uint16(40703), + 80: uint16(40740), + 81: uint16(40739), + 82: uint16(40738), + 83: uint16(40788), + 84: uint16(40864), + 85: uint16(20785), + 86: uint16(20781), + 87: uint16(20782), + 88: uint16(22168), + 89: uint16(22172), + 90: uint16(22167), + 91: uint16(22170), + 92: uint16(22173), + 93: uint16(22169), + 94: uint16(22896), + 95: uint16(23356), + 96: uint16(23657), + 97: uint16(23658), + 98: uint16(24000), + 99: uint16(24173), + 100: uint16(24174), + 101: uint16(25048), + 102: uint16(25055), + 103: uint16(25069), + 104: uint16(25070), + 105: uint16(25073), + 106: uint16(25066), + 107: uint16(25072), + 108: uint16(25067), + 109: uint16(25046), + 110: uint16(25065), + 111: uint16(25855), + 112: uint16(25860), + 113: uint16(25853), + 114: uint16(25848), + 115: uint16(25857), + 116: uint16(25859), + 117: uint16(25852), + 118: uint16(26004), + 119: uint16(26075), + 120: uint16(26330), + 121: uint16(26331), + 122: uint16(26328), + 123: uint16(27333), + 124: uint16(27321), + 125: uint16(27325), + 126: uint16(27361), + 127: uint16(27334), + 128: uint16(27322), + 129: uint16(27318), + 130: uint16(27319), + 131: uint16(27335), + 132: uint16(27316), + 133: uint16(27309), + 134: uint16(27486), + 135: uint16(27593), + 136: uint16(27659), + 137: uint16(28679), + 138: uint16(28684), + 139: uint16(28685), + 140: uint16(28673), + 141: uint16(28677), + 142: uint16(28692), + 143: uint16(28686), + 144: uint16(28671), + 145: uint16(28672), + 146: uint16(28667), + 147: uint16(28710), + 148: uint16(28668), + 149: uint16(28663), + 150: uint16(28682), + 151: uint16(29185), + 152: uint16(29183), + 153: uint16(29177), + 154: uint16(29187), + 155: uint16(29181), + 156: uint16(29558), + }, + 79: { + 0: uint16(29880), + 1: uint16(29888), + 2: uint16(29877), + 3: uint16(29889), + 4: uint16(29886), + 5: uint16(29878), + 6: uint16(29883), + 7: uint16(29890), + 8: uint16(29972), + 9: uint16(29971), + 10: uint16(30300), + 11: uint16(30308), + 12: uint16(30297), + 13: uint16(30288), + 14: uint16(30291), + 15: uint16(30295), + 16: uint16(30298), + 17: uint16(30374), + 18: uint16(30397), + 19: uint16(30444), + 20: uint16(30658), + 21: uint16(30650), + 22: uint16(30975), + 23: uint16(30988), + 24: uint16(30995), + 25: uint16(30996), + 26: uint16(30985), + 27: uint16(30992), + 28: uint16(30994), + 29: uint16(30993), + 30: uint16(31149), + 31: uint16(31148), + 32: uint16(31327), + 33: uint16(31772), + 34: uint16(31785), + 35: uint16(31769), + 36: uint16(31776), + 37: uint16(31775), + 38: uint16(31789), + 39: uint16(31773), + 40: uint16(31782), + 41: uint16(31784), + 42: uint16(31778), + 43: uint16(31781), + 44: uint16(31792), + 45: uint16(32348), + 46: uint16(32336), + 47: uint16(32342), + 48: uint16(32355), + 49: uint16(32344), + 50: uint16(32354), + 51: uint16(32351), + 52: uint16(32337), + 53: uint16(32352), + 54: uint16(32343), + 55: uint16(32339), + 56: uint16(32693), + 57: uint16(32691), + 58: uint16(32759), + 59: uint16(32760), + 60: uint16(32885), + 61: uint16(33233), + 62: uint16(33234), + 63: uint16(33232), + 64: uint16(33375), + 65: uint16(33374), + 66: uint16(34228), + 67: uint16(34246), + 68: uint16(34240), + 69: uint16(34243), + 70: uint16(34242), + 71: uint16(34227), + 72: uint16(34229), + 73: uint16(34237), + 74: uint16(34247), + 75: uint16(34244), + 76: uint16(34239), + 77: uint16(34251), + 78: uint16(34254), + 79: uint16(34248), + 80: uint16(34245), + 81: uint16(34225), + 82: uint16(34230), + 83: uint16(34258), + 84: uint16(34340), + 85: uint16(34232), + 86: uint16(34231), + 87: uint16(34238), + 88: uint16(34409), + 89: uint16(34791), + 90: uint16(34790), + 91: uint16(34786), + 92: uint16(34779), + 93: uint16(34795), + 94: uint16(34794), + 95: uint16(34789), + 96: uint16(34783), + 97: uint16(34803), + 98: uint16(34788), + 99: uint16(34772), + 100: uint16(34780), + 101: uint16(34771), + 102: uint16(34797), + 103: uint16(34776), + 104: uint16(34787), + 105: uint16(34724), + 106: uint16(34775), + 107: uint16(34777), + 108: uint16(34817), + 109: uint16(34804), + 110: uint16(34792), + 111: uint16(34781), + 112: uint16(35155), + 113: uint16(35147), + 114: uint16(35151), + 115: uint16(35148), + 116: uint16(35142), + 117: uint16(35152), + 118: uint16(35153), + 119: uint16(35145), + 120: uint16(35626), + 121: uint16(35623), + 122: uint16(35619), + 123: uint16(35635), + 124: uint16(35632), + 125: uint16(35637), + 126: uint16(35655), + 127: uint16(35631), + 128: uint16(35644), + 129: uint16(35646), + 130: uint16(35633), + 131: uint16(35621), + 132: uint16(35639), + 133: uint16(35622), + 134: uint16(35638), + 135: uint16(35630), + 136: uint16(35620), + 137: uint16(35643), + 138: uint16(35645), + 139: uint16(35642), + 140: uint16(35906), + 141: uint16(35957), + 142: uint16(35993), + 143: uint16(35992), + 144: uint16(35991), + 145: uint16(36094), + 146: uint16(36100), + 147: uint16(36098), + 148: uint16(36096), + 149: uint16(36444), + 150: uint16(36450), + 151: uint16(36448), + 152: uint16(36439), + 153: uint16(36438), + 154: uint16(36446), + 155: uint16(36453), + 156: uint16(36455), + }, + 80: { + 0: uint16(36443), + 1: uint16(36442), + 2: uint16(36449), + 3: uint16(36445), + 4: uint16(36457), + 5: uint16(36436), + 6: uint16(36678), + 7: uint16(36679), + 8: uint16(36680), + 9: uint16(36683), + 10: uint16(37160), + 11: uint16(37178), + 12: uint16(37179), + 13: uint16(37182), + 14: uint16(37288), + 15: uint16(37285), + 16: uint16(37287), + 17: uint16(37295), + 18: uint16(37290), + 19: uint16(37813), + 20: uint16(37772), + 21: uint16(37778), + 22: uint16(37815), + 23: uint16(37787), + 24: uint16(37789), + 25: uint16(37769), + 26: uint16(37799), + 27: uint16(37774), + 28: uint16(37802), + 29: uint16(37790), + 30: uint16(37798), + 31: uint16(37781), + 32: uint16(37768), + 33: uint16(37785), + 34: uint16(37791), + 35: uint16(37773), + 36: uint16(37809), + 37: uint16(37777), + 38: uint16(37810), + 39: uint16(37796), + 40: uint16(37800), + 41: uint16(37812), + 42: uint16(37795), + 43: uint16(37797), + 44: uint16(38354), + 45: uint16(38355), + 46: uint16(38353), + 47: uint16(38579), + 48: uint16(38615), + 49: uint16(38618), + 50: uint16(24002), + 51: uint16(38623), + 52: uint16(38616), + 53: uint16(38621), + 54: uint16(38691), + 55: uint16(38690), + 56: uint16(38693), + 57: uint16(38828), + 58: uint16(38830), + 59: uint16(38824), + 60: uint16(38827), + 61: uint16(38820), + 62: uint16(38826), + 63: uint16(38818), + 64: uint16(38821), + 65: uint16(38871), + 66: uint16(38873), + 67: uint16(38870), + 68: uint16(38872), + 69: uint16(38906), + 70: uint16(38992), + 71: uint16(38993), + 72: uint16(38994), + 73: uint16(39096), + 74: uint16(39233), + 75: uint16(39228), + 76: uint16(39226), + 77: uint16(39439), + 78: uint16(39435), + 79: uint16(39433), + 80: uint16(39437), + 81: uint16(39428), + 82: uint16(39441), + 83: uint16(39434), + 84: uint16(39429), + 85: uint16(39431), + 86: uint16(39430), + 87: uint16(39616), + 88: uint16(39644), + 89: uint16(39688), + 90: uint16(39684), + 91: uint16(39685), + 92: uint16(39721), + 93: uint16(39733), + 94: uint16(39754), + 95: uint16(39756), + 96: uint16(39755), + 97: uint16(39879), + 98: uint16(39878), + 99: uint16(39875), + 100: uint16(39871), + 101: uint16(39873), + 102: uint16(39861), + 103: uint16(39864), + 104: uint16(39891), + 105: uint16(39862), + 106: uint16(39876), + 107: uint16(39865), + 108: uint16(39869), + 109: uint16(40284), + 110: uint16(40275), + 111: uint16(40271), + 112: uint16(40266), + 113: uint16(40283), + 114: uint16(40267), + 115: uint16(40281), + 116: uint16(40278), + 117: uint16(40268), + 118: uint16(40279), + 119: uint16(40274), + 120: uint16(40276), + 121: uint16(40287), + 122: uint16(40280), + 123: uint16(40282), + 124: uint16(40590), + 125: uint16(40588), + 126: uint16(40671), + 127: uint16(40705), + 128: uint16(40704), + 129: uint16(40726), + 130: uint16(40741), + 131: uint16(40747), + 132: uint16(40746), + 133: uint16(40745), + 134: uint16(40744), + 135: uint16(40780), + 136: uint16(40789), + 137: uint16(20788), + 138: uint16(20789), + 139: uint16(21142), + 140: uint16(21239), + 141: uint16(21428), + 142: uint16(22187), + 143: uint16(22189), + 144: uint16(22182), + 145: uint16(22183), + 146: uint16(22186), + 147: uint16(22188), + 148: uint16(22746), + 149: uint16(22749), + 150: uint16(22747), + 151: uint16(22802), + 152: uint16(23357), + 153: uint16(23358), + 154: uint16(23359), + 155: uint16(24003), + 156: uint16(24176), + }, + 81: { + 0: uint16(24511), + 1: uint16(25083), + 2: uint16(25863), + 3: uint16(25872), + 4: uint16(25869), + 5: uint16(25865), + 6: uint16(25868), + 7: uint16(25870), + 8: uint16(25988), + 9: uint16(26078), + 10: uint16(26077), + 11: uint16(26334), + 12: uint16(27367), + 13: uint16(27360), + 14: uint16(27340), + 15: uint16(27345), + 16: uint16(27353), + 17: uint16(27339), + 18: uint16(27359), + 19: uint16(27356), + 20: uint16(27344), + 21: uint16(27371), + 22: uint16(27343), + 23: uint16(27341), + 24: uint16(27358), + 25: uint16(27488), + 26: uint16(27568), + 27: uint16(27660), + 28: uint16(28697), + 29: uint16(28711), + 30: uint16(28704), + 31: uint16(28694), + 32: uint16(28715), + 33: uint16(28705), + 34: uint16(28706), + 35: uint16(28707), + 36: uint16(28713), + 37: uint16(28695), + 38: uint16(28708), + 39: uint16(28700), + 40: uint16(28714), + 41: uint16(29196), + 42: uint16(29194), + 43: uint16(29191), + 44: uint16(29186), + 45: uint16(29189), + 46: uint16(29349), + 47: uint16(29350), + 48: uint16(29348), + 49: uint16(29347), + 50: uint16(29345), + 51: uint16(29899), + 52: uint16(29893), + 53: uint16(29879), + 54: uint16(29891), + 55: uint16(29974), + 56: uint16(30304), + 57: uint16(30665), + 58: uint16(30666), + 59: uint16(30660), + 60: uint16(30705), + 61: uint16(31005), + 62: uint16(31003), + 63: uint16(31009), + 64: uint16(31004), + 65: uint16(30999), + 66: uint16(31006), + 67: uint16(31152), + 68: uint16(31335), + 69: uint16(31336), + 70: uint16(31795), + 71: uint16(31804), + 72: uint16(31801), + 73: uint16(31788), + 74: uint16(31803), + 75: uint16(31980), + 76: uint16(31978), + 77: uint16(32374), + 78: uint16(32373), + 79: uint16(32376), + 80: uint16(32368), + 81: uint16(32375), + 82: uint16(32367), + 83: uint16(32378), + 84: uint16(32370), + 85: uint16(32372), + 86: uint16(32360), + 87: uint16(32587), + 88: uint16(32586), + 89: uint16(32643), + 90: uint16(32646), + 91: uint16(32695), + 92: uint16(32765), + 93: uint16(32766), + 94: uint16(32888), + 95: uint16(33239), + 96: uint16(33237), + 97: uint16(33380), + 98: uint16(33377), + 99: uint16(33379), + 100: uint16(34283), + 101: uint16(34289), + 102: uint16(34285), + 103: uint16(34265), + 104: uint16(34273), + 105: uint16(34280), + 106: uint16(34266), + 107: uint16(34263), + 108: uint16(34284), + 109: uint16(34290), + 110: uint16(34296), + 111: uint16(34264), + 112: uint16(34271), + 113: uint16(34275), + 114: uint16(34268), + 115: uint16(34257), + 116: uint16(34288), + 117: uint16(34278), + 118: uint16(34287), + 119: uint16(34270), + 120: uint16(34274), + 121: uint16(34816), + 122: uint16(34810), + 123: uint16(34819), + 124: uint16(34806), + 125: uint16(34807), + 126: uint16(34825), + 127: uint16(34828), + 128: uint16(34827), + 129: uint16(34822), + 130: uint16(34812), + 131: uint16(34824), + 132: uint16(34815), + 133: uint16(34826), + 134: uint16(34818), + 135: uint16(35170), + 136: uint16(35162), + 137: uint16(35163), + 138: uint16(35159), + 139: uint16(35169), + 140: uint16(35164), + 141: uint16(35160), + 142: uint16(35165), + 143: uint16(35161), + 144: uint16(35208), + 145: uint16(35255), + 146: uint16(35254), + 147: uint16(35318), + 148: uint16(35664), + 149: uint16(35656), + 150: uint16(35658), + 151: uint16(35648), + 152: uint16(35667), + 153: uint16(35670), + 154: uint16(35668), + 155: uint16(35659), + 156: uint16(35669), + }, + 82: { + 0: uint16(35665), + 1: uint16(35650), + 2: uint16(35666), + 3: uint16(35671), + 4: uint16(35907), + 5: uint16(35959), + 6: uint16(35958), + 7: uint16(35994), + 8: uint16(36102), + 9: uint16(36103), + 10: uint16(36105), + 11: uint16(36268), + 12: uint16(36266), + 13: uint16(36269), + 14: uint16(36267), + 15: uint16(36461), + 16: uint16(36472), + 17: uint16(36467), + 18: uint16(36458), + 19: uint16(36463), + 20: uint16(36475), + 21: uint16(36546), + 22: uint16(36690), + 23: uint16(36689), + 24: uint16(36687), + 25: uint16(36688), + 26: uint16(36691), + 27: uint16(36788), + 28: uint16(37184), + 29: uint16(37183), + 30: uint16(37296), + 31: uint16(37293), + 32: uint16(37854), + 33: uint16(37831), + 34: uint16(37839), + 35: uint16(37826), + 36: uint16(37850), + 37: uint16(37840), + 38: uint16(37881), + 39: uint16(37868), + 40: uint16(37836), + 41: uint16(37849), + 42: uint16(37801), + 43: uint16(37862), + 44: uint16(37834), + 45: uint16(37844), + 46: uint16(37870), + 47: uint16(37859), + 48: uint16(37845), + 49: uint16(37828), + 50: uint16(37838), + 51: uint16(37824), + 52: uint16(37842), + 53: uint16(37863), + 54: uint16(38269), + 55: uint16(38362), + 56: uint16(38363), + 57: uint16(38625), + 58: uint16(38697), + 59: uint16(38699), + 60: uint16(38700), + 61: uint16(38696), + 62: uint16(38694), + 63: uint16(38835), + 64: uint16(38839), + 65: uint16(38838), + 66: uint16(38877), + 67: uint16(38878), + 68: uint16(38879), + 69: uint16(39004), + 70: uint16(39001), + 71: uint16(39005), + 72: uint16(38999), + 73: uint16(39103), + 74: uint16(39101), + 75: uint16(39099), + 76: uint16(39102), + 77: uint16(39240), + 78: uint16(39239), + 79: uint16(39235), + 80: uint16(39334), + 81: uint16(39335), + 82: uint16(39450), + 83: uint16(39445), + 84: uint16(39461), + 85: uint16(39453), + 86: uint16(39460), + 87: uint16(39451), + 88: uint16(39458), + 89: uint16(39456), + 90: uint16(39463), + 91: uint16(39459), + 92: uint16(39454), + 93: uint16(39452), + 94: uint16(39444), + 95: uint16(39618), + 96: uint16(39691), + 97: uint16(39690), + 98: uint16(39694), + 99: uint16(39692), + 100: uint16(39735), + 101: uint16(39914), + 102: uint16(39915), + 103: uint16(39904), + 104: uint16(39902), + 105: uint16(39908), + 106: uint16(39910), + 107: uint16(39906), + 108: uint16(39920), + 109: uint16(39892), + 110: uint16(39895), + 111: uint16(39916), + 112: uint16(39900), + 113: uint16(39897), + 114: uint16(39909), + 115: uint16(39893), + 116: uint16(39905), + 117: uint16(39898), + 118: uint16(40311), + 119: uint16(40321), + 120: uint16(40330), + 121: uint16(40324), + 122: uint16(40328), + 123: uint16(40305), + 124: uint16(40320), + 125: uint16(40312), + 126: uint16(40326), + 127: uint16(40331), + 128: uint16(40332), + 129: uint16(40317), + 130: uint16(40299), + 131: uint16(40308), + 132: uint16(40309), + 133: uint16(40304), + 134: uint16(40297), + 135: uint16(40325), + 136: uint16(40307), + 137: uint16(40315), + 138: uint16(40322), + 139: uint16(40303), + 140: uint16(40313), + 141: uint16(40319), + 142: uint16(40327), + 143: uint16(40296), + 144: uint16(40596), + 145: uint16(40593), + 146: uint16(40640), + 147: uint16(40700), + 148: uint16(40749), + 149: uint16(40768), + 150: uint16(40769), + 151: uint16(40781), + 152: uint16(40790), + 153: uint16(40791), + 154: uint16(40792), + 155: uint16(21303), + 156: uint16(22194), + }, + 83: { + 0: uint16(22197), + 1: uint16(22195), + 2: uint16(22755), + 3: uint16(23365), + 4: uint16(24006), + 5: uint16(24007), + 6: uint16(24302), + 7: uint16(24303), + 8: uint16(24512), + 9: uint16(24513), + 10: uint16(25081), + 11: uint16(25879), + 12: uint16(25878), + 13: uint16(25877), + 14: uint16(25875), + 15: uint16(26079), + 16: uint16(26344), + 17: uint16(26339), + 18: uint16(26340), + 19: uint16(27379), + 20: uint16(27376), + 21: uint16(27370), + 22: uint16(27368), + 23: uint16(27385), + 24: uint16(27377), + 25: uint16(27374), + 26: uint16(27375), + 27: uint16(28732), + 28: uint16(28725), + 29: uint16(28719), + 30: uint16(28727), + 31: uint16(28724), + 32: uint16(28721), + 33: uint16(28738), + 34: uint16(28728), + 35: uint16(28735), + 36: uint16(28730), + 37: uint16(28729), + 38: uint16(28736), + 39: uint16(28731), + 40: uint16(28723), + 41: uint16(28737), + 42: uint16(29203), + 43: uint16(29204), + 44: uint16(29352), + 45: uint16(29565), + 46: uint16(29564), + 47: uint16(29882), + 48: uint16(30379), + 49: uint16(30378), + 50: uint16(30398), + 51: uint16(30445), + 52: uint16(30668), + 53: uint16(30670), + 54: uint16(30671), + 55: uint16(30669), + 56: uint16(30706), + 57: uint16(31013), + 58: uint16(31011), + 59: uint16(31015), + 60: uint16(31016), + 61: uint16(31012), + 62: uint16(31017), + 63: uint16(31154), + 64: uint16(31342), + 65: uint16(31340), + 66: uint16(31341), + 67: uint16(31479), + 68: uint16(31817), + 69: uint16(31816), + 70: uint16(31818), + 71: uint16(31815), + 72: uint16(31813), + 73: uint16(31982), + 74: uint16(32379), + 75: uint16(32382), + 76: uint16(32385), + 77: uint16(32384), + 78: uint16(32698), + 79: uint16(32767), + 80: uint16(32889), + 81: uint16(33243), + 82: uint16(33241), + 83: uint16(33291), + 84: uint16(33384), + 85: uint16(33385), + 86: uint16(34338), + 87: uint16(34303), + 88: uint16(34305), + 89: uint16(34302), + 90: uint16(34331), + 91: uint16(34304), + 92: uint16(34294), + 93: uint16(34308), + 94: uint16(34313), + 95: uint16(34309), + 96: uint16(34316), + 97: uint16(34301), + 98: uint16(34841), + 99: uint16(34832), + 100: uint16(34833), + 101: uint16(34839), + 102: uint16(34835), + 103: uint16(34838), + 104: uint16(35171), + 105: uint16(35174), + 106: uint16(35257), + 107: uint16(35319), + 108: uint16(35680), + 109: uint16(35690), + 110: uint16(35677), + 111: uint16(35688), + 112: uint16(35683), + 113: uint16(35685), + 114: uint16(35687), + 115: uint16(35693), + 116: uint16(36270), + 117: uint16(36486), + 118: uint16(36488), + 119: uint16(36484), + 120: uint16(36697), + 121: uint16(36694), + 122: uint16(36695), + 123: uint16(36693), + 124: uint16(36696), + 125: uint16(36698), + 126: uint16(37005), + 127: uint16(37187), + 128: uint16(37185), + 129: uint16(37303), + 130: uint16(37301), + 131: uint16(37298), + 132: uint16(37299), + 133: uint16(37899), + 134: uint16(37907), + 135: uint16(37883), + 136: uint16(37920), + 137: uint16(37903), + 138: uint16(37908), + 139: uint16(37886), + 140: uint16(37909), + 141: uint16(37904), + 142: uint16(37928), + 143: uint16(37913), + 144: uint16(37901), + 145: uint16(37877), + 146: uint16(37888), + 147: uint16(37879), + 148: uint16(37895), + 149: uint16(37902), + 150: uint16(37910), + 151: uint16(37906), + 152: uint16(37882), + 153: uint16(37897), + 154: uint16(37880), + 155: uint16(37898), + 156: uint16(37887), + }, + 84: { + 0: uint16(37884), + 1: uint16(37900), + 2: uint16(37878), + 3: uint16(37905), + 4: uint16(37894), + 5: uint16(38366), + 6: uint16(38368), + 7: uint16(38367), + 8: uint16(38702), + 9: uint16(38703), + 10: uint16(38841), + 11: uint16(38843), + 12: uint16(38909), + 13: uint16(38910), + 14: uint16(39008), + 15: uint16(39010), + 16: uint16(39011), + 17: uint16(39007), + 18: uint16(39105), + 19: uint16(39106), + 20: uint16(39248), + 21: uint16(39246), + 22: uint16(39257), + 23: uint16(39244), + 24: uint16(39243), + 25: uint16(39251), + 26: uint16(39474), + 27: uint16(39476), + 28: uint16(39473), + 29: uint16(39468), + 30: uint16(39466), + 31: uint16(39478), + 32: uint16(39465), + 33: uint16(39470), + 34: uint16(39480), + 35: uint16(39469), + 36: uint16(39623), + 37: uint16(39626), + 38: uint16(39622), + 39: uint16(39696), + 40: uint16(39698), + 41: uint16(39697), + 42: uint16(39947), + 43: uint16(39944), + 44: uint16(39927), + 45: uint16(39941), + 46: uint16(39954), + 47: uint16(39928), + 48: uint16(40000), + 49: uint16(39943), + 50: uint16(39950), + 51: uint16(39942), + 52: uint16(39959), + 53: uint16(39956), + 54: uint16(39945), + 55: uint16(40351), + 56: uint16(40345), + 57: uint16(40356), + 58: uint16(40349), + 59: uint16(40338), + 60: uint16(40344), + 61: uint16(40336), + 62: uint16(40347), + 63: uint16(40352), + 64: uint16(40340), + 65: uint16(40348), + 66: uint16(40362), + 67: uint16(40343), + 68: uint16(40353), + 69: uint16(40346), + 70: uint16(40354), + 71: uint16(40360), + 72: uint16(40350), + 73: uint16(40355), + 74: uint16(40383), + 75: uint16(40361), + 76: uint16(40342), + 77: uint16(40358), + 78: uint16(40359), + 79: uint16(40601), + 80: uint16(40603), + 81: uint16(40602), + 82: uint16(40677), + 83: uint16(40676), + 84: uint16(40679), + 85: uint16(40678), + 86: uint16(40752), + 87: uint16(40750), + 88: uint16(40795), + 89: uint16(40800), + 90: uint16(40798), + 91: uint16(40797), + 92: uint16(40793), + 93: uint16(40849), + 94: uint16(20794), + 95: uint16(20793), + 96: uint16(21144), + 97: uint16(21143), + 98: uint16(22211), + 99: uint16(22205), + 100: uint16(22206), + 101: uint16(23368), + 102: uint16(23367), + 103: uint16(24011), + 104: uint16(24015), + 105: uint16(24305), + 106: uint16(25085), + 107: uint16(25883), + 108: uint16(27394), + 109: uint16(27388), + 110: uint16(27395), + 111: uint16(27384), + 112: uint16(27392), + 113: uint16(28739), + 114: uint16(28740), + 115: uint16(28746), + 116: uint16(28744), + 117: uint16(28745), + 118: uint16(28741), + 119: uint16(28742), + 120: uint16(29213), + 121: uint16(29210), + 122: uint16(29209), + 123: uint16(29566), + 124: uint16(29975), + 125: uint16(30314), + 126: uint16(30672), + 127: uint16(31021), + 128: uint16(31025), + 129: uint16(31023), + 130: uint16(31828), + 131: uint16(31827), + 132: uint16(31986), + 133: uint16(32394), + 134: uint16(32391), + 135: uint16(32392), + 136: uint16(32395), + 137: uint16(32390), + 138: uint16(32397), + 139: uint16(32589), + 140: uint16(32699), + 141: uint16(32816), + 142: uint16(33245), + 143: uint16(34328), + 144: uint16(34346), + 145: uint16(34342), + 146: uint16(34335), + 147: uint16(34339), + 148: uint16(34332), + 149: uint16(34329), + 150: uint16(34343), + 151: uint16(34350), + 152: uint16(34337), + 153: uint16(34336), + 154: uint16(34345), + 155: uint16(34334), + 156: uint16(34341), + }, + 85: { + 0: uint16(34857), + 1: uint16(34845), + 2: uint16(34843), + 3: uint16(34848), + 4: uint16(34852), + 5: uint16(34844), + 6: uint16(34859), + 7: uint16(34890), + 8: uint16(35181), + 9: uint16(35177), + 10: uint16(35182), + 11: uint16(35179), + 12: uint16(35322), + 13: uint16(35705), + 14: uint16(35704), + 15: uint16(35653), + 16: uint16(35706), + 17: uint16(35707), + 18: uint16(36112), + 19: uint16(36116), + 20: uint16(36271), + 21: uint16(36494), + 22: uint16(36492), + 23: uint16(36702), + 24: uint16(36699), + 25: uint16(36701), + 26: uint16(37190), + 27: uint16(37188), + 28: uint16(37189), + 29: uint16(37305), + 30: uint16(37951), + 31: uint16(37947), + 32: uint16(37942), + 33: uint16(37929), + 34: uint16(37949), + 35: uint16(37948), + 36: uint16(37936), + 37: uint16(37945), + 38: uint16(37930), + 39: uint16(37943), + 40: uint16(37932), + 41: uint16(37952), + 42: uint16(37937), + 43: uint16(38373), + 44: uint16(38372), + 45: uint16(38371), + 46: uint16(38709), + 47: uint16(38714), + 48: uint16(38847), + 49: uint16(38881), + 50: uint16(39012), + 51: uint16(39113), + 52: uint16(39110), + 53: uint16(39104), + 54: uint16(39256), + 55: uint16(39254), + 56: uint16(39481), + 57: uint16(39485), + 58: uint16(39494), + 59: uint16(39492), + 60: uint16(39490), + 61: uint16(39489), + 62: uint16(39482), + 63: uint16(39487), + 64: uint16(39629), + 65: uint16(39701), + 66: uint16(39703), + 67: uint16(39704), + 68: uint16(39702), + 69: uint16(39738), + 70: uint16(39762), + 71: uint16(39979), + 72: uint16(39965), + 73: uint16(39964), + 74: uint16(39980), + 75: uint16(39971), + 76: uint16(39976), + 77: uint16(39977), + 78: uint16(39972), + 79: uint16(39969), + 80: uint16(40375), + 81: uint16(40374), + 82: uint16(40380), + 83: uint16(40385), + 84: uint16(40391), + 85: uint16(40394), + 86: uint16(40399), + 87: uint16(40382), + 88: uint16(40389), + 89: uint16(40387), + 90: uint16(40379), + 91: uint16(40373), + 92: uint16(40398), + 93: uint16(40377), + 94: uint16(40378), + 95: uint16(40364), + 96: uint16(40392), + 97: uint16(40369), + 98: uint16(40365), + 99: uint16(40396), + 100: uint16(40371), + 101: uint16(40397), + 102: uint16(40370), + 103: uint16(40570), + 104: uint16(40604), + 105: uint16(40683), + 106: uint16(40686), + 107: uint16(40685), + 108: uint16(40731), + 109: uint16(40728), + 110: uint16(40730), + 111: uint16(40753), + 112: uint16(40782), + 113: uint16(40805), + 114: uint16(40804), + 115: uint16(40850), + 116: uint16(20153), + 117: uint16(22214), + 118: uint16(22213), + 119: uint16(22219), + 120: uint16(22897), + 121: uint16(23371), + 122: uint16(23372), + 123: uint16(24021), + 124: uint16(24017), + 125: uint16(24306), + 126: uint16(25889), + 127: uint16(25888), + 128: uint16(25894), + 129: uint16(25890), + 130: uint16(27403), + 131: uint16(27400), + 132: uint16(27401), + 133: uint16(27661), + 134: uint16(28757), + 135: uint16(28758), + 136: uint16(28759), + 137: uint16(28754), + 138: uint16(29214), + 139: uint16(29215), + 140: uint16(29353), + 141: uint16(29567), + 142: uint16(29912), + 143: uint16(29909), + 144: uint16(29913), + 145: uint16(29911), + 146: uint16(30317), + 147: uint16(30381), + 148: uint16(31029), + 149: uint16(31156), + 150: uint16(31344), + 151: uint16(31345), + 152: uint16(31831), + 153: uint16(31836), + 154: uint16(31833), + 155: uint16(31835), + 156: uint16(31834), + }, + 86: { + 0: uint16(31988), + 1: uint16(31985), + 2: uint16(32401), + 3: uint16(32591), + 4: uint16(32647), + 5: uint16(33246), + 6: uint16(33387), + 7: uint16(34356), + 8: uint16(34357), + 9: uint16(34355), + 10: uint16(34348), + 11: uint16(34354), + 12: uint16(34358), + 13: uint16(34860), + 14: uint16(34856), + 15: uint16(34854), + 16: uint16(34858), + 17: uint16(34853), + 18: uint16(35185), + 19: uint16(35263), + 20: uint16(35262), + 21: uint16(35323), + 22: uint16(35710), + 23: uint16(35716), + 24: uint16(35714), + 25: uint16(35718), + 26: uint16(35717), + 27: uint16(35711), + 28: uint16(36117), + 29: uint16(36501), + 30: uint16(36500), + 31: uint16(36506), + 32: uint16(36498), + 33: uint16(36496), + 34: uint16(36502), + 35: uint16(36503), + 36: uint16(36704), + 37: uint16(36706), + 38: uint16(37191), + 39: uint16(37964), + 40: uint16(37968), + 41: uint16(37962), + 42: uint16(37963), + 43: uint16(37967), + 44: uint16(37959), + 45: uint16(37957), + 46: uint16(37960), + 47: uint16(37961), + 48: uint16(37958), + 49: uint16(38719), + 50: uint16(38883), + 51: uint16(39018), + 52: uint16(39017), + 53: uint16(39115), + 54: uint16(39252), + 55: uint16(39259), + 56: uint16(39502), + 57: uint16(39507), + 58: uint16(39508), + 59: uint16(39500), + 60: uint16(39503), + 61: uint16(39496), + 62: uint16(39498), + 63: uint16(39497), + 64: uint16(39506), + 65: uint16(39504), + 66: uint16(39632), + 67: uint16(39705), + 68: uint16(39723), + 69: uint16(39739), + 70: uint16(39766), + 71: uint16(39765), + 72: uint16(40006), + 73: uint16(40008), + 74: uint16(39999), + 75: uint16(40004), + 76: uint16(39993), + 77: uint16(39987), + 78: uint16(40001), + 79: uint16(39996), + 80: uint16(39991), + 81: uint16(39988), + 82: uint16(39986), + 83: uint16(39997), + 84: uint16(39990), + 85: uint16(40411), + 86: uint16(40402), + 87: uint16(40414), + 88: uint16(40410), + 89: uint16(40395), + 90: uint16(40400), + 91: uint16(40412), + 92: uint16(40401), + 93: uint16(40415), + 94: uint16(40425), + 95: uint16(40409), + 96: uint16(40408), + 97: uint16(40406), + 98: uint16(40437), + 99: uint16(40405), + 100: uint16(40413), + 101: uint16(40630), + 102: uint16(40688), + 103: uint16(40757), + 104: uint16(40755), + 105: uint16(40754), + 106: uint16(40770), + 107: uint16(40811), + 108: uint16(40853), + 109: uint16(40866), + 110: uint16(20797), + 111: uint16(21145), + 112: uint16(22760), + 113: uint16(22759), + 114: uint16(22898), + 115: uint16(23373), + 116: uint16(24024), + 117: uint16(34863), + 118: uint16(24399), + 119: uint16(25089), + 120: uint16(25091), + 121: uint16(25092), + 122: uint16(25897), + 123: uint16(25893), + 124: uint16(26006), + 125: uint16(26347), + 126: uint16(27409), + 127: uint16(27410), + 128: uint16(27407), + 129: uint16(27594), + 130: uint16(28763), + 131: uint16(28762), + 132: uint16(29218), + 133: uint16(29570), + 134: uint16(29569), + 135: uint16(29571), + 136: uint16(30320), + 137: uint16(30676), + 138: uint16(31847), + 139: uint16(31846), + 140: uint16(32405), + 141: uint16(33388), + 142: uint16(34362), + 143: uint16(34368), + 144: uint16(34361), + 145: uint16(34364), + 146: uint16(34353), + 147: uint16(34363), + 148: uint16(34366), + 149: uint16(34864), + 150: uint16(34866), + 151: uint16(34862), + 152: uint16(34867), + 153: uint16(35190), + 154: uint16(35188), + 155: uint16(35187), + 156: uint16(35326), + }, + 87: { + 0: uint16(35724), + 1: uint16(35726), + 2: uint16(35723), + 3: uint16(35720), + 4: uint16(35909), + 5: uint16(36121), + 6: uint16(36504), + 7: uint16(36708), + 8: uint16(36707), + 9: uint16(37308), + 10: uint16(37986), + 11: uint16(37973), + 12: uint16(37981), + 13: uint16(37975), + 14: uint16(37982), + 15: uint16(38852), + 16: uint16(38853), + 17: uint16(38912), + 18: uint16(39510), + 19: uint16(39513), + 20: uint16(39710), + 21: uint16(39711), + 22: uint16(39712), + 23: uint16(40018), + 24: uint16(40024), + 25: uint16(40016), + 26: uint16(40010), + 27: uint16(40013), + 28: uint16(40011), + 29: uint16(40021), + 30: uint16(40025), + 31: uint16(40012), + 32: uint16(40014), + 33: uint16(40443), + 34: uint16(40439), + 35: uint16(40431), + 36: uint16(40419), + 37: uint16(40427), + 38: uint16(40440), + 39: uint16(40420), + 40: uint16(40438), + 41: uint16(40417), + 42: uint16(40430), + 43: uint16(40422), + 44: uint16(40434), + 45: uint16(40432), + 46: uint16(40418), + 47: uint16(40428), + 48: uint16(40436), + 49: uint16(40435), + 50: uint16(40424), + 51: uint16(40429), + 52: uint16(40642), + 53: uint16(40656), + 54: uint16(40690), + 55: uint16(40691), + 56: uint16(40710), + 57: uint16(40732), + 58: uint16(40760), + 59: uint16(40759), + 60: uint16(40758), + 61: uint16(40771), + 62: uint16(40783), + 63: uint16(40817), + 64: uint16(40816), + 65: uint16(40814), + 66: uint16(40815), + 67: uint16(22227), + 68: uint16(22221), + 69: uint16(23374), + 70: uint16(23661), + 71: uint16(25901), + 72: uint16(26349), + 73: uint16(26350), + 74: uint16(27411), + 75: uint16(28767), + 76: uint16(28769), + 77: uint16(28765), + 78: uint16(28768), + 79: uint16(29219), + 80: uint16(29915), + 81: uint16(29925), + 82: uint16(30677), + 83: uint16(31032), + 84: uint16(31159), + 85: uint16(31158), + 86: uint16(31850), + 87: uint16(32407), + 88: uint16(32649), + 89: uint16(33389), + 90: uint16(34371), + 91: uint16(34872), + 92: uint16(34871), + 93: uint16(34869), + 94: uint16(34891), + 95: uint16(35732), + 96: uint16(35733), + 97: uint16(36510), + 98: uint16(36511), + 99: uint16(36512), + 100: uint16(36509), + 101: uint16(37310), + 102: uint16(37309), + 103: uint16(37314), + 104: uint16(37995), + 105: uint16(37992), + 106: uint16(37993), + 107: uint16(38629), + 108: uint16(38726), + 109: uint16(38723), + 110: uint16(38727), + 111: uint16(38855), + 112: uint16(38885), + 113: uint16(39518), + 114: uint16(39637), + 115: uint16(39769), + 116: uint16(40035), + 117: uint16(40039), + 118: uint16(40038), + 119: uint16(40034), + 120: uint16(40030), + 121: uint16(40032), + 122: uint16(40450), + 123: uint16(40446), + 124: uint16(40455), + 125: uint16(40451), + 126: uint16(40454), + 127: uint16(40453), + 128: uint16(40448), + 129: uint16(40449), + 130: uint16(40457), + 131: uint16(40447), + 132: uint16(40445), + 133: uint16(40452), + 134: uint16(40608), + 135: uint16(40734), + 136: uint16(40774), + 137: uint16(40820), + 138: uint16(40821), + 139: uint16(40822), + 140: uint16(22228), + 141: uint16(25902), + 142: uint16(26040), + 143: uint16(27416), + 144: uint16(27417), + 145: uint16(27415), + 146: uint16(27418), + 147: uint16(28770), + 148: uint16(29222), + 149: uint16(29354), + 150: uint16(30680), + 151: uint16(30681), + 152: uint16(31033), + 153: uint16(31849), + 154: uint16(31851), + 155: uint16(31990), + 156: uint16(32410), + }, + 88: { + 0: uint16(32408), + 1: uint16(32411), + 2: uint16(32409), + 3: uint16(33248), + 4: uint16(33249), + 5: uint16(34374), + 6: uint16(34375), + 7: uint16(34376), + 8: uint16(35193), + 9: uint16(35194), + 10: uint16(35196), + 11: uint16(35195), + 12: uint16(35327), + 13: uint16(35736), + 14: uint16(35737), + 15: uint16(36517), + 16: uint16(36516), + 17: uint16(36515), + 18: uint16(37998), + 19: uint16(37997), + 20: uint16(37999), + 21: uint16(38001), + 22: uint16(38003), + 23: uint16(38729), + 24: uint16(39026), + 25: uint16(39263), + 26: uint16(40040), + 27: uint16(40046), + 28: uint16(40045), + 29: uint16(40459), + 30: uint16(40461), + 31: uint16(40464), + 32: uint16(40463), + 33: uint16(40466), + 34: uint16(40465), + 35: uint16(40609), + 36: uint16(40693), + 37: uint16(40713), + 38: uint16(40775), + 39: uint16(40824), + 40: uint16(40827), + 41: uint16(40826), + 42: uint16(40825), + 43: uint16(22302), + 44: uint16(28774), + 45: uint16(31855), + 46: uint16(34876), + 47: uint16(36274), + 48: uint16(36518), + 49: uint16(37315), + 50: uint16(38004), + 51: uint16(38008), + 52: uint16(38006), + 53: uint16(38005), + 54: uint16(39520), + 55: uint16(40052), + 56: uint16(40051), + 57: uint16(40049), + 58: uint16(40053), + 59: uint16(40468), + 60: uint16(40467), + 61: uint16(40694), + 62: uint16(40714), + 63: uint16(40868), + 64: uint16(28776), + 65: uint16(28773), + 66: uint16(31991), + 67: uint16(34410), + 68: uint16(34878), + 69: uint16(34877), + 70: uint16(34879), + 71: uint16(35742), + 72: uint16(35996), + 73: uint16(36521), + 74: uint16(36553), + 75: uint16(38731), + 76: uint16(39027), + 77: uint16(39028), + 78: uint16(39116), + 79: uint16(39265), + 80: uint16(39339), + 81: uint16(39524), + 82: uint16(39526), + 83: uint16(39527), + 84: uint16(39716), + 85: uint16(40469), + 86: uint16(40471), + 87: uint16(40776), + 88: uint16(25095), + 89: uint16(27422), + 90: uint16(29223), + 91: uint16(34380), + 92: uint16(36520), + 93: uint16(38018), + 94: uint16(38016), + 95: uint16(38017), + 96: uint16(39529), + 97: uint16(39528), + 98: uint16(39726), + 99: uint16(40473), + 100: uint16(29225), + 101: uint16(34379), + 102: uint16(35743), + 103: uint16(38019), + 104: uint16(40057), + 105: uint16(40631), + 106: uint16(30325), + 107: uint16(39531), + 108: uint16(40058), + 109: uint16(40477), + 110: uint16(28777), + 111: uint16(28778), + 112: uint16(40612), + 113: uint16(40830), + 114: uint16(40777), + 115: uint16(40856), + 116: uint16(30849), + 117: uint16(37561), + 118: uint16(35023), + 119: uint16(22715), + 120: uint16(24658), + 121: uint16(31911), + 122: uint16(23290), + 123: uint16(9556), + 124: uint16(9574), + 125: uint16(9559), + 126: uint16(9568), + 127: uint16(9580), + 128: uint16(9571), + 129: uint16(9562), + 130: uint16(9577), + 131: uint16(9565), + 132: uint16(9554), + 133: uint16(9572), + 134: uint16(9557), + 135: uint16(9566), + 136: uint16(9578), + 137: uint16(9569), + 138: uint16(9560), + 139: uint16(9575), + 140: uint16(9563), + 141: uint16(9555), + 142: uint16(9573), + 143: uint16(9558), + 144: uint16(9567), + 145: uint16(9579), + 146: uint16(9570), + 147: uint16(9561), + 148: uint16(9576), + 149: uint16(9564), + 150: uint16(9553), + 151: uint16(9552), + 152: uint16(9581), + 153: uint16(9582), + 154: uint16(9584), + 155: uint16(9583), + 156: uint16(9619), + }, +} + +var _hkscs = [5172]uint16{ + 0: uint16(17392), + 1: uint16(19506), + 2: uint16(17923), + 3: uint16(17830), + 4: uint16(17784), + 5: uint16(29287), + 6: uint16(19831), + 7: uint16(17843), + 8: uint16(31921), + 9: uint16(19682), + 10: uint16(31941), + 11: uint16(15253), + 12: uint16(18230), + 13: uint16(18244), + 14: uint16(19527), + 15: uint16(19520), + 16: uint16(17087), + 17: uint16(13847), + 18: uint16(29522), + 19: uint16(28299), + 20: uint16(28882), + 21: uint16(19543), + 22: uint16(41809), + 23: uint16(18255), + 24: uint16(17882), + 25: uint16(19589), + 26: uint16(31852), + 27: uint16(19719), + 28: uint16(19108), + 29: uint16(18081), + 30: uint16(27427), + 31: uint16(29221), + 32: uint16(23124), + 33: uint16(6755), + 34: uint16(15878), + 35: uint16(16225), + 36: uint16(26189), + 37: uint16(22267), + 39: uint16(32149), + 40: uint16(22813), + 41: uint16(35769), + 42: uint16(15860), + 43: uint16(38708), + 44: uint16(31727), + 45: uint16(23515), + 46: uint16(7518), + 47: uint16(23204), + 48: uint16(13861), + 49: uint16(40624), + 50: uint16(23249), + 51: uint16(23479), + 52: uint16(23804), + 53: uint16(26478), + 54: uint16(34195), + 55: uint16(39237), + 56: uint16(29793), + 57: uint16(29853), + 58: uint16(14453), + 59: uint16(7507), + 60: uint16(13982), + 61: uint16(24609), + 62: uint16(16108), + 63: uint16(22750), + 64: uint16(15093), + 65: uint16(31484), + 66: uint16(40855), + 67: uint16(16737), + 68: uint16(35085), + 69: uint16(12778), + 70: uint16(2698), + 71: uint16(12894), + 72: uint16(17162), + 73: uint16(33924), + 74: uint16(40854), + 75: uint16(37935), + 76: uint16(18736), + 77: uint16(34323), + 78: uint16(22678), + 79: uint16(38730), + 80: uint16(37400), + 81: uint16(31184), + 82: uint16(31282), + 83: uint16(26208), + 84: uint16(27177), + 85: uint16(34973), + 86: uint16(29772), + 87: uint16(31685), + 88: uint16(26498), + 89: uint16(31276), + 90: uint16(21071), + 91: uint16(36934), + 92: uint16(13542), + 93: uint16(29636), + 94: uint16(23993), + 95: uint16(29894), + 96: uint16(40903), + 97: uint16(22451), + 98: uint16(18735), + 99: uint16(21580), + 100: uint16(16689), + 101: uint16(13966), + 102: uint16(22552), + 103: uint16(31346), + 104: uint16(31589), + 105: uint16(35727), + 106: uint16(18094), + 107: uint16(28296), + 108: uint16(16769), + 109: uint16(23961), + 110: uint16(31662), + 111: uint16(9404), + 112: uint16(40904), + 113: uint16(9409), + 114: uint16(9417), + 115: uint16(9420), + 116: uint16(40905), + 117: uint16(34052), + 118: uint16(13755), + 119: uint16(16564), + 120: uint16(40906), + 121: uint16(17633), + 122: uint16(44543), + 123: uint16(25281), + 124: uint16(28782), + 125: uint16(40907), + 157: uint16(12736), + 158: uint16(12737), + 159: uint16(12738), + 160: uint16(12739), + 161: uint16(12740), + 162: uint16(268), + 163: uint16(12741), + 164: uint16(209), + 165: uint16(205), + 166: uint16(12742), + 167: uint16(12743), + 168: uint16(203), + 169: uint16(8168), + 170: uint16(12744), + 171: uint16(202), + 172: uint16(12745), + 173: uint16(12746), + 174: uint16(12747), + 175: uint16(12748), + 176: uint16(270), + 177: uint16(12749), + 178: uint16(12750), + 179: uint16(256), + 180: uint16(193), + 181: uint16(461), + 182: uint16(192), + 183: uint16(274), + 184: uint16(201), + 185: uint16(282), + 186: uint16(200), + 187: uint16(332), + 188: uint16(211), + 189: uint16(465), + 190: uint16(210), + 191: uint16(56320), + 192: uint16(7870), + 193: uint16(56324), + 194: uint16(7872), + 195: uint16(202), + 196: uint16(257), + 197: uint16(225), + 198: uint16(462), + 199: uint16(224), + 200: uint16(593), + 201: uint16(275), + 202: uint16(233), + 203: uint16(283), + 204: uint16(232), + 205: uint16(299), + 206: uint16(237), + 207: uint16(464), + 208: uint16(236), + 209: uint16(333), + 210: uint16(243), + 211: uint16(466), + 212: uint16(242), + 213: uint16(363), + 214: uint16(250), + 215: uint16(468), + 216: uint16(249), + 217: uint16(470), + 218: uint16(472), + 219: uint16(474), + 220: uint16(476), + 221: uint16(252), + 222: uint16(56328), + 223: uint16(7871), + 224: uint16(56332), + 225: uint16(7873), + 226: uint16(234), + 227: uint16(609), + 228: uint16(9178), + 229: uint16(9179), + 314: uint16(41897), + 315: uint16(4421), + 317: uint16(25866), + 320: uint16(20029), + 321: uint16(28381), + 322: uint16(40270), + 323: uint16(37343), + 326: uint16(30517), + 327: uint16(25745), + 328: uint16(20250), + 329: uint16(20264), + 330: uint16(20392), + 331: uint16(20822), + 332: uint16(20852), + 333: uint16(20892), + 334: uint16(20964), + 335: uint16(21153), + 336: uint16(21160), + 337: uint16(21307), + 338: uint16(21326), + 339: uint16(21457), + 340: uint16(21464), + 341: uint16(22242), + 342: uint16(22768), + 343: uint16(22788), + 344: uint16(22791), + 345: uint16(22834), + 346: uint16(22836), + 347: uint16(23398), + 348: uint16(23454), + 349: uint16(23455), + 350: uint16(23706), + 351: uint16(24198), + 352: uint16(24635), + 353: uint16(25993), + 354: uint16(26622), + 355: uint16(26628), + 356: uint16(26725), + 357: uint16(27982), + 358: uint16(28860), + 359: uint16(30005), + 360: uint16(32420), + 361: uint16(32428), + 362: uint16(32442), + 363: uint16(32455), + 364: uint16(32463), + 365: uint16(32479), + 366: uint16(32518), + 367: uint16(32567), + 368: uint16(33402), + 369: uint16(33487), + 370: uint16(33647), + 371: uint16(35270), + 372: uint16(35774), + 373: uint16(35810), + 374: uint16(36710), + 375: uint16(36711), + 376: uint16(36718), + 377: uint16(29713), + 378: uint16(31996), + 379: uint16(32205), + 380: uint16(26950), + 381: uint16(31433), + 382: uint16(21031), + 387: uint16(37260), + 388: uint16(30904), + 389: uint16(37214), + 390: uint16(32956), + 392: uint16(36107), + 393: uint16(33014), + 394: uint16(2535), + 397: uint16(32927), + 398: uint16(40647), + 399: uint16(19661), + 400: uint16(40393), + 401: uint16(40460), + 402: uint16(19518), + 403: uint16(40438), + 404: uint16(28686), + 405: uint16(40458), + 406: uint16(41267), + 407: uint16(13761), + 409: uint16(28314), + 410: uint16(33342), + 411: uint16(29977), + 413: uint16(18705), + 414: uint16(39532), + 415: uint16(39567), + 416: uint16(40857), + 417: uint16(31111), + 418: uint16(33900), + 419: uint16(7626), + 420: uint16(1488), + 421: uint16(10982), + 422: uint16(20004), + 423: uint16(20097), + 424: uint16(20096), + 425: uint16(20103), + 426: uint16(20159), + 427: uint16(20203), + 428: uint16(20279), + 429: uint16(13388), + 430: uint16(20413), + 431: uint16(15944), + 432: uint16(20483), + 433: uint16(20616), + 434: uint16(13437), + 435: uint16(13459), + 436: uint16(13477), + 437: uint16(20870), + 438: uint16(22789), + 439: uint16(20955), + 440: uint16(20988), + 441: uint16(20997), + 442: uint16(20105), + 443: uint16(21113), + 444: uint16(21136), + 445: uint16(21287), + 446: uint16(13767), + 447: uint16(21417), + 448: uint16(13649), + 449: uint16(21424), + 450: uint16(13651), + 451: uint16(21442), + 452: uint16(21539), + 453: uint16(13677), + 454: uint16(13682), + 455: uint16(13953), + 456: uint16(21651), + 457: uint16(21667), + 458: uint16(21684), + 459: uint16(21689), + 460: uint16(21712), + 461: uint16(21743), + 462: uint16(21784), + 463: uint16(21795), + 464: uint16(21800), + 465: uint16(13720), + 466: uint16(21823), + 467: uint16(13733), + 468: uint16(13759), + 469: uint16(21975), + 470: uint16(13765), + 471: uint16(32132), + 472: uint16(21797), + 474: uint16(3138), + 475: uint16(3349), + 476: uint16(20779), + 477: uint16(21904), + 478: uint16(11462), + 479: uint16(14828), + 480: uint16(833), + 481: uint16(36422), + 482: uint16(19896), + 483: uint16(38117), + 484: uint16(16467), + 485: uint16(32958), + 486: uint16(30586), + 487: uint16(11320), + 488: uint16(14900), + 489: uint16(18389), + 490: uint16(33117), + 491: uint16(27122), + 492: uint16(19946), + 493: uint16(25821), + 494: uint16(3452), + 495: uint16(4020), + 496: uint16(3285), + 497: uint16(4340), + 498: uint16(25741), + 499: uint16(36478), + 500: uint16(3734), + 501: uint16(3083), + 502: uint16(3940), + 503: uint16(11433), + 504: uint16(33366), + 505: uint16(17619), + 507: uint16(3398), + 508: uint16(39501), + 509: uint16(33001), + 510: uint16(18420), + 511: uint16(20135), + 512: uint16(11458), + 513: uint16(39602), + 514: uint16(14951), + 515: uint16(38388), + 516: uint16(16365), + 517: uint16(13574), + 518: uint16(21191), + 519: uint16(38868), + 520: uint16(30920), + 521: uint16(11588), + 522: uint16(40302), + 523: uint16(38933), + 525: uint16(17369), + 526: uint16(24741), + 527: uint16(25780), + 528: uint16(21731), + 529: uint16(11596), + 530: uint16(11210), + 531: uint16(4215), + 532: uint16(14843), + 533: uint16(4207), + 534: uint16(26330), + 535: uint16(26390), + 536: uint16(31136), + 537: uint16(25834), + 538: uint16(20562), + 539: uint16(3139), + 540: uint16(36456), + 541: uint16(8609), + 542: uint16(35660), + 543: uint16(1841), + 545: uint16(18443), + 546: uint16(425), + 547: uint16(16378), + 548: uint16(22643), + 549: uint16(11661), + 551: uint16(17864), + 552: uint16(1276), + 553: uint16(24727), + 554: uint16(3916), + 555: uint16(3478), + 556: uint16(21881), + 557: uint16(16571), + 558: uint16(17338), + 560: uint16(19124), + 561: uint16(10854), + 562: uint16(4253), + 563: uint16(33194), + 564: uint16(39157), + 565: uint16(3484), + 566: uint16(25465), + 567: uint16(14846), + 568: uint16(10101), + 569: uint16(36288), + 570: uint16(22177), + 571: uint16(25724), + 572: uint16(15939), + 574: uint16(42497), + 575: uint16(3593), + 576: uint16(10959), + 577: uint16(11465), + 579: uint16(4296), + 580: uint16(14786), + 581: uint16(14738), + 582: uint16(14854), + 583: uint16(33435), + 584: uint16(13688), + 585: uint16(24137), + 586: uint16(8391), + 587: uint16(22098), + 588: uint16(3889), + 589: uint16(11442), + 590: uint16(38688), + 591: uint16(13500), + 592: uint16(27709), + 593: uint16(20027), + 596: uint16(30068), + 597: uint16(11915), + 598: uint16(8712), + 599: uint16(42587), + 600: uint16(36045), + 601: uint16(3706), + 602: uint16(3124), + 603: uint16(26652), + 604: uint16(32659), + 605: uint16(4303), + 606: uint16(10243), + 607: uint16(10553), + 608: uint16(13819), + 609: uint16(20963), + 610: uint16(3724), + 611: uint16(3981), + 612: uint16(3754), + 613: uint16(16275), + 614: uint16(3888), + 615: uint16(3399), + 616: uint16(4431), + 617: uint16(3660), + 619: uint16(3755), + 620: uint16(2985), + 621: uint16(3400), + 622: uint16(4288), + 623: uint16(4413), + 624: uint16(16377), + 625: uint16(9878), + 626: uint16(25650), + 627: uint16(4013), + 628: uint16(13300), + 629: uint16(30265), + 630: uint16(11214), + 631: uint16(3454), + 632: uint16(3455), + 633: uint16(11345), + 634: uint16(11349), + 635: uint16(14872), + 636: uint16(3736), + 637: uint16(4295), + 638: uint16(3886), + 639: uint16(42546), + 640: uint16(27472), + 641: uint16(36050), + 642: uint16(36249), + 643: uint16(36042), + 644: uint16(38314), + 645: uint16(21708), + 646: uint16(33476), + 647: uint16(21945), + 649: uint16(40643), + 650: uint16(39974), + 651: uint16(39606), + 652: uint16(30558), + 653: uint16(11758), + 654: uint16(28992), + 655: uint16(33133), + 656: uint16(33004), + 657: uint16(23580), + 658: uint16(25970), + 659: uint16(33076), + 660: uint16(14231), + 661: uint16(21343), + 662: uint16(32957), + 663: uint16(37302), + 664: uint16(3834), + 665: uint16(3599), + 666: uint16(3703), + 667: uint16(3835), + 668: uint16(13789), + 669: uint16(19947), + 670: uint16(13833), + 671: uint16(3286), + 672: uint16(22191), + 673: uint16(10165), + 674: uint16(4297), + 675: uint16(3600), + 676: uint16(3704), + 677: uint16(4216), + 678: uint16(4424), + 679: uint16(33287), + 680: uint16(5205), + 681: uint16(3705), + 682: uint16(20048), + 683: uint16(11684), + 684: uint16(23124), + 685: uint16(4125), + 686: uint16(4126), + 687: uint16(4341), + 688: uint16(4342), + 689: uint16(22428), + 690: uint16(3601), + 691: uint16(30356), + 692: uint16(33485), + 693: uint16(4021), + 694: uint16(3707), + 695: uint16(20862), + 696: uint16(14083), + 697: uint16(4022), + 698: uint16(4480), + 699: uint16(21208), + 700: uint16(41661), + 701: uint16(18906), + 702: uint16(6202), + 703: uint16(16759), + 704: uint16(33404), + 705: uint16(22681), + 706: uint16(21096), + 707: uint16(13850), + 708: uint16(22333), + 709: uint16(31666), + 710: uint16(23400), + 711: uint16(18432), + 712: uint16(19244), + 713: uint16(40743), + 714: uint16(18919), + 715: uint16(39967), + 716: uint16(39821), + 717: uint16(23412), + 718: uint16(12605), + 719: uint16(22011), + 720: uint16(13810), + 721: uint16(22153), + 722: uint16(20008), + 723: uint16(22786), + 724: uint16(7105), + 725: uint16(63608), + 726: uint16(38737), + 727: uint16(134), + 728: uint16(20059), + 729: uint16(20155), + 730: uint16(13630), + 731: uint16(23587), + 732: uint16(24401), + 733: uint16(24516), + 734: uint16(14586), + 735: uint16(25164), + 736: uint16(25909), + 737: uint16(27514), + 738: uint16(27701), + 739: uint16(27706), + 740: uint16(28780), + 741: uint16(29227), + 742: uint16(20012), + 743: uint16(29357), + 744: uint16(18665), + 745: uint16(32594), + 746: uint16(31035), + 747: uint16(31993), + 748: uint16(32595), + 749: uint16(25194), + 750: uint16(13505), + 752: uint16(25419), + 753: uint16(32770), + 754: uint16(32896), + 755: uint16(26130), + 756: uint16(26961), + 757: uint16(21341), + 758: uint16(34916), + 759: uint16(35265), + 760: uint16(30898), + 761: uint16(35744), + 762: uint16(36125), + 763: uint16(38021), + 764: uint16(38264), + 765: uint16(38271), + 766: uint16(38376), + 767: uint16(36367), + 768: uint16(38886), + 769: uint16(39029), + 770: uint16(39118), + 771: uint16(39134), + 772: uint16(39267), + 773: uint16(38928), + 774: uint16(40060), + 775: uint16(40479), + 776: uint16(40644), + 777: uint16(27503), + 778: uint16(63751), + 779: uint16(20023), + 780: uint16(135), + 781: uint16(38429), + 782: uint16(25143), + 783: uint16(38050), + 785: uint16(20539), + 786: uint16(28158), + 787: uint16(40051), + 788: uint16(40870), + 789: uint16(15817), + 790: uint16(34959), + 791: uint16(16718), + 792: uint16(28791), + 793: uint16(23797), + 794: uint16(19232), + 795: uint16(20941), + 796: uint16(13657), + 797: uint16(23856), + 798: uint16(24866), + 799: uint16(35378), + 800: uint16(36775), + 801: uint16(37366), + 802: uint16(29073), + 803: uint16(26393), + 804: uint16(29626), + 805: uint16(12929), + 806: uint16(41223), + 807: uint16(15499), + 808: uint16(6528), + 809: uint16(19216), + 810: uint16(30948), + 811: uint16(29698), + 812: uint16(20910), + 813: uint16(34575), + 814: uint16(16393), + 815: uint16(27235), + 816: uint16(41658), + 817: uint16(16931), + 818: uint16(34319), + 819: uint16(2671), + 820: uint16(31274), + 821: uint16(39239), + 822: uint16(35562), + 823: uint16(38741), + 824: uint16(28749), + 825: uint16(21284), + 826: uint16(8318), + 827: uint16(37876), + 828: uint16(30425), + 829: uint16(35299), + 830: uint16(40871), + 831: uint16(30685), + 832: uint16(20131), + 833: uint16(20464), + 834: uint16(20668), + 835: uint16(20015), + 836: uint16(20247), + 837: uint16(40872), + 838: uint16(21556), + 839: uint16(32139), + 840: uint16(22674), + 841: uint16(22736), + 842: uint16(7606), + 843: uint16(24210), + 844: uint16(24217), + 845: uint16(24514), + 846: uint16(10002), + 847: uint16(25995), + 848: uint16(13305), + 849: uint16(26905), + 850: uint16(27203), + 851: uint16(15459), + 852: uint16(27903), + 854: uint16(29184), + 855: uint16(17669), + 856: uint16(29580), + 857: uint16(16091), + 858: uint16(18963), + 859: uint16(23317), + 860: uint16(29881), + 861: uint16(35715), + 862: uint16(23716), + 863: uint16(22165), + 864: uint16(31379), + 865: uint16(31724), + 866: uint16(31939), + 867: uint16(32364), + 868: uint16(33528), + 869: uint16(34199), + 870: uint16(40873), + 871: uint16(34960), + 872: uint16(40874), + 873: uint16(36537), + 874: uint16(40875), + 875: uint16(36815), + 876: uint16(34143), + 877: uint16(39392), + 878: uint16(37409), + 879: uint16(40876), + 880: uint16(36281), + 881: uint16(5183), + 882: uint16(16497), + 883: uint16(17058), + 884: uint16(23066), + 888: uint16(39016), + 889: uint16(26475), + 890: uint16(17014), + 891: uint16(22333), + 893: uint16(34262), + 894: uint16(18811), + 895: uint16(33471), + 896: uint16(28941), + 897: uint16(19585), + 898: uint16(28020), + 899: uint16(23931), + 900: uint16(27413), + 901: uint16(28606), + 902: uint16(40877), + 903: uint16(40878), + 904: uint16(23446), + 905: uint16(40879), + 906: uint16(26343), + 907: uint16(32347), + 908: uint16(28247), + 909: uint16(31178), + 910: uint16(15752), + 911: uint16(17603), + 912: uint16(12886), + 913: uint16(10134), + 914: uint16(17306), + 915: uint16(17718), + 917: uint16(23765), + 918: uint16(15130), + 919: uint16(35577), + 920: uint16(23672), + 921: uint16(15634), + 922: uint16(13649), + 923: uint16(23928), + 924: uint16(40882), + 925: uint16(29015), + 926: uint16(17752), + 927: uint16(16620), + 928: uint16(7715), + 929: uint16(19575), + 930: uint16(14712), + 931: uint16(13386), + 932: uint16(420), + 933: uint16(27713), + 934: uint16(35532), + 935: uint16(20404), + 936: uint16(569), + 937: uint16(22975), + 938: uint16(33132), + 939: uint16(38998), + 940: uint16(39162), + 941: uint16(24379), + 942: uint16(2975), + 944: uint16(8641), + 945: uint16(35181), + 946: uint16(16642), + 947: uint16(18107), + 948: uint16(36985), + 949: uint16(16135), + 950: uint16(40883), + 951: uint16(41397), + 952: uint16(16632), + 953: uint16(14294), + 954: uint16(18167), + 955: uint16(27718), + 956: uint16(16764), + 957: uint16(34482), + 958: uint16(29695), + 959: uint16(17773), + 960: uint16(14548), + 961: uint16(21658), + 962: uint16(17761), + 963: uint16(17691), + 964: uint16(19849), + 965: uint16(19579), + 966: uint16(19830), + 967: uint16(17898), + 968: uint16(16328), + 969: uint16(19215), + 970: uint16(13921), + 971: uint16(17630), + 972: uint16(17597), + 973: uint16(16877), + 974: uint16(23870), + 975: uint16(23880), + 976: uint16(23894), + 977: uint16(15868), + 978: uint16(14351), + 979: uint16(23972), + 980: uint16(23993), + 981: uint16(14368), + 982: uint16(14392), + 983: uint16(24130), + 984: uint16(24253), + 985: uint16(24357), + 986: uint16(24451), + 987: uint16(14600), + 988: uint16(14612), + 989: uint16(14655), + 990: uint16(14669), + 991: uint16(24791), + 992: uint16(24893), + 993: uint16(23781), + 994: uint16(14729), + 995: uint16(25015), + 996: uint16(25017), + 997: uint16(25039), + 998: uint16(14776), + 999: uint16(25132), + 1000: uint16(25232), + 1001: uint16(25317), + 1002: uint16(25368), + 1003: uint16(14840), + 1004: uint16(22193), + 1005: uint16(14851), + 1006: uint16(25570), + 1007: uint16(25595), + 1008: uint16(25607), + 1009: uint16(25690), + 1010: uint16(14923), + 1011: uint16(25792), + 1012: uint16(23829), + 1013: uint16(22049), + 1014: uint16(40863), + 1015: uint16(14999), + 1016: uint16(25990), + 1017: uint16(15037), + 1018: uint16(26111), + 1019: uint16(26195), + 1020: uint16(15090), + 1021: uint16(26258), + 1022: uint16(15138), + 1023: uint16(26390), + 1024: uint16(15170), + 1025: uint16(26532), + 1026: uint16(26624), + 1027: uint16(15192), + 1028: uint16(26698), + 1029: uint16(26756), + 1030: uint16(15218), + 1031: uint16(15217), + 1032: uint16(15227), + 1033: uint16(26889), + 1034: uint16(26947), + 1035: uint16(29276), + 1036: uint16(26980), + 1037: uint16(27039), + 1038: uint16(27013), + 1039: uint16(15292), + 1040: uint16(27094), + 1041: uint16(15325), + 1042: uint16(27237), + 1043: uint16(27252), + 1044: uint16(27249), + 1045: uint16(27266), + 1046: uint16(15340), + 1047: uint16(27289), + 1048: uint16(15346), + 1049: uint16(27307), + 1050: uint16(27317), + 1051: uint16(27348), + 1052: uint16(27382), + 1053: uint16(27521), + 1054: uint16(27585), + 1055: uint16(27626), + 1056: uint16(27765), + 1057: uint16(27818), + 1058: uint16(15563), + 1059: uint16(27906), + 1060: uint16(27910), + 1061: uint16(27942), + 1062: uint16(28033), + 1063: uint16(15599), + 1064: uint16(28068), + 1065: uint16(28081), + 1066: uint16(28181), + 1067: uint16(28184), + 1068: uint16(28201), + 1069: uint16(28294), + 1070: uint16(35264), + 1071: uint16(28347), + 1072: uint16(28386), + 1073: uint16(28378), + 1074: uint16(40831), + 1075: uint16(28392), + 1076: uint16(28393), + 1077: uint16(28452), + 1078: uint16(28468), + 1079: uint16(15686), + 1080: uint16(16193), + 1081: uint16(28545), + 1082: uint16(28606), + 1083: uint16(15722), + 1084: uint16(15733), + 1085: uint16(29111), + 1086: uint16(23705), + 1087: uint16(15754), + 1088: uint16(28716), + 1089: uint16(15761), + 1090: uint16(28752), + 1091: uint16(28756), + 1092: uint16(28783), + 1093: uint16(28799), + 1094: uint16(28809), + 1095: uint16(805), + 1096: uint16(17345), + 1097: uint16(13809), + 1098: uint16(3800), + 1099: uint16(16087), + 1100: uint16(22462), + 1101: uint16(28371), + 1102: uint16(28990), + 1103: uint16(22496), + 1104: uint16(13902), + 1105: uint16(27042), + 1106: uint16(35817), + 1107: uint16(23412), + 1108: uint16(31305), + 1109: uint16(22753), + 1110: uint16(38105), + 1111: uint16(31333), + 1112: uint16(31357), + 1113: uint16(22956), + 1114: uint16(31419), + 1115: uint16(31408), + 1116: uint16(31426), + 1117: uint16(31427), + 1118: uint16(29137), + 1119: uint16(25741), + 1120: uint16(16842), + 1121: uint16(31450), + 1122: uint16(31453), + 1123: uint16(31466), + 1124: uint16(16879), + 1125: uint16(21682), + 1126: uint16(23553), + 1127: uint16(31499), + 1128: uint16(31573), + 1129: uint16(31529), + 1130: uint16(21262), + 1131: uint16(23806), + 1132: uint16(31650), + 1133: uint16(31599), + 1134: uint16(33692), + 1135: uint16(23476), + 1136: uint16(27775), + 1137: uint16(31696), + 1138: uint16(33825), + 1139: uint16(31634), + 1141: uint16(23840), + 1142: uint16(15789), + 1143: uint16(23653), + 1144: uint16(33938), + 1145: uint16(31738), + 1147: uint16(31797), + 1148: uint16(23745), + 1149: uint16(31812), + 1150: uint16(31875), + 1151: uint16(18562), + 1152: uint16(31910), + 1153: uint16(26237), + 1154: uint16(17784), + 1155: uint16(31945), + 1156: uint16(31943), + 1157: uint16(31974), + 1158: uint16(31860), + 1159: uint16(31987), + 1160: uint16(31989), + 1162: uint16(32359), + 1163: uint16(17693), + 1164: uint16(28228), + 1165: uint16(32093), + 1166: uint16(28374), + 1167: uint16(29837), + 1168: uint16(32137), + 1169: uint16(32171), + 1170: uint16(28981), + 1171: uint16(32179), + 1173: uint16(16471), + 1174: uint16(24617), + 1175: uint16(32228), + 1176: uint16(15635), + 1177: uint16(32245), + 1178: uint16(6137), + 1179: uint16(32229), + 1180: uint16(33645), + 1182: uint16(24865), + 1183: uint16(24922), + 1184: uint16(32366), + 1185: uint16(32402), + 1186: uint16(17195), + 1187: uint16(37996), + 1188: uint16(32295), + 1189: uint16(32576), + 1190: uint16(32577), + 1191: uint16(32583), + 1192: uint16(31030), + 1193: uint16(25296), + 1194: uint16(39393), + 1195: uint16(32663), + 1196: uint16(25425), + 1197: uint16(32675), + 1198: uint16(5729), + 1199: uint16(104), + 1200: uint16(17756), + 1201: uint16(14182), + 1202: uint16(17667), + 1203: uint16(33594), + 1204: uint16(32762), + 1205: uint16(25737), + 1207: uint16(32776), + 1208: uint16(32797), + 1210: uint16(32815), + 1211: uint16(41095), + 1212: uint16(27843), + 1213: uint16(32827), + 1214: uint16(32828), + 1215: uint16(32865), + 1216: uint16(10004), + 1217: uint16(18825), + 1218: uint16(26150), + 1219: uint16(15843), + 1220: uint16(26344), + 1221: uint16(26405), + 1222: uint16(32935), + 1223: uint16(35400), + 1224: uint16(33031), + 1225: uint16(33050), + 1226: uint16(22704), + 1227: uint16(9974), + 1228: uint16(27775), + 1229: uint16(25752), + 1230: uint16(20408), + 1231: uint16(25831), + 1232: uint16(5258), + 1233: uint16(33304), + 1234: uint16(6238), + 1235: uint16(27219), + 1236: uint16(19045), + 1237: uint16(19093), + 1238: uint16(17530), + 1239: uint16(33321), + 1240: uint16(2829), + 1241: uint16(27218), + 1242: uint16(15742), + 1243: uint16(20473), + 1244: uint16(5373), + 1245: uint16(34018), + 1246: uint16(33634), + 1247: uint16(27402), + 1248: uint16(18855), + 1249: uint16(13616), + 1250: uint16(6003), + 1251: uint16(15864), + 1252: uint16(33450), + 1253: uint16(26907), + 1254: uint16(63892), + 1255: uint16(16859), + 1256: uint16(34123), + 1257: uint16(33488), + 1258: uint16(33562), + 1259: uint16(3606), + 1260: uint16(6068), + 1261: uint16(14017), + 1262: uint16(12669), + 1263: uint16(13658), + 1264: uint16(33403), + 1265: uint16(33506), + 1266: uint16(33560), + 1267: uint16(16011), + 1268: uint16(28067), + 1269: uint16(27397), + 1270: uint16(27543), + 1271: uint16(13774), + 1272: uint16(15807), + 1273: uint16(33565), + 1274: uint16(21996), + 1275: uint16(33669), + 1276: uint16(17675), + 1277: uint16(28069), + 1278: uint16(33708), + 1280: uint16(33747), + 1281: uint16(13438), + 1282: uint16(28372), + 1283: uint16(27223), + 1284: uint16(34138), + 1285: uint16(13462), + 1286: uint16(28226), + 1287: uint16(12015), + 1288: uint16(33880), + 1289: uint16(23524), + 1290: uint16(33905), + 1291: uint16(15827), + 1292: uint16(17636), + 1293: uint16(27303), + 1294: uint16(33866), + 1295: uint16(15541), + 1296: uint16(31064), + 1298: uint16(27542), + 1299: uint16(28279), + 1300: uint16(28227), + 1301: uint16(34014), + 1303: uint16(33681), + 1304: uint16(17568), + 1305: uint16(33939), + 1306: uint16(34020), + 1307: uint16(23697), + 1308: uint16(16960), + 1309: uint16(23744), + 1310: uint16(17731), + 1311: uint16(34100), + 1312: uint16(23282), + 1313: uint16(28313), + 1314: uint16(17703), + 1315: uint16(34163), + 1316: uint16(17686), + 1317: uint16(26559), + 1318: uint16(34326), + 1319: uint16(34341), + 1320: uint16(34363), + 1321: uint16(34241), + 1322: uint16(28808), + 1323: uint16(34306), + 1324: uint16(5506), + 1325: uint16(28877), + 1326: uint16(63922), + 1327: uint16(17770), + 1328: uint16(34344), + 1329: uint16(13896), + 1330: uint16(6306), + 1331: uint16(21495), + 1332: uint16(29594), + 1333: uint16(34430), + 1334: uint16(34673), + 1335: uint16(41208), + 1336: uint16(34798), + 1337: uint16(11303), + 1338: uint16(34737), + 1339: uint16(34778), + 1340: uint16(34831), + 1341: uint16(22113), + 1342: uint16(34412), + 1343: uint16(26710), + 1344: uint16(17935), + 1345: uint16(34885), + 1346: uint16(34886), + 1347: uint16(30176), + 1348: uint16(15801), + 1349: uint16(30180), + 1350: uint16(34910), + 1351: uint16(34972), + 1352: uint16(18011), + 1353: uint16(34996), + 1354: uint16(34997), + 1355: uint16(25537), + 1356: uint16(35013), + 1357: uint16(30583), + 1358: uint16(30479), + 1359: uint16(35207), + 1360: uint16(35210), + 1363: uint16(35239), + 1364: uint16(35260), + 1365: uint16(35365), + 1366: uint16(35303), + 1367: uint16(31012), + 1368: uint16(31421), + 1369: uint16(35484), + 1370: uint16(30611), + 1371: uint16(37374), + 1372: uint16(35472), + 1373: uint16(31321), + 1374: uint16(31465), + 1375: uint16(31546), + 1376: uint16(16271), + 1377: uint16(18195), + 1378: uint16(31544), + 1379: uint16(29052), + 1380: uint16(35596), + 1381: uint16(35615), + 1382: uint16(21552), + 1383: uint16(21861), + 1384: uint16(35647), + 1385: uint16(35660), + 1386: uint16(35661), + 1387: uint16(35497), + 1388: uint16(19066), + 1389: uint16(35728), + 1390: uint16(35739), + 1391: uint16(35503), + 1392: uint16(5855), + 1393: uint16(17941), + 1394: uint16(34895), + 1395: uint16(35995), + 1396: uint16(32084), + 1397: uint16(32143), + 1398: uint16(63956), + 1399: uint16(14117), + 1400: uint16(32083), + 1401: uint16(36054), + 1402: uint16(32152), + 1403: uint16(32189), + 1404: uint16(36114), + 1405: uint16(36099), + 1406: uint16(6416), + 1407: uint16(36059), + 1408: uint16(28764), + 1409: uint16(36113), + 1410: uint16(19657), + 1411: uint16(16080), + 1413: uint16(36265), + 1414: uint16(32770), + 1415: uint16(4116), + 1416: uint16(18826), + 1417: uint16(15228), + 1418: uint16(33212), + 1419: uint16(28940), + 1420: uint16(31463), + 1421: uint16(36525), + 1422: uint16(36534), + 1423: uint16(36547), + 1424: uint16(37588), + 1425: uint16(36633), + 1426: uint16(36653), + 1427: uint16(33637), + 1428: uint16(33810), + 1429: uint16(36773), + 1430: uint16(37635), + 1431: uint16(41631), + 1432: uint16(2640), + 1433: uint16(36787), + 1434: uint16(18730), + 1435: uint16(35294), + 1436: uint16(34109), + 1437: uint16(15803), + 1438: uint16(24312), + 1439: uint16(12898), + 1440: uint16(36857), + 1441: uint16(40980), + 1442: uint16(34492), + 1443: uint16(34049), + 1444: uint16(8997), + 1445: uint16(14720), + 1446: uint16(28375), + 1447: uint16(36919), + 1448: uint16(34108), + 1449: uint16(31422), + 1450: uint16(36961), + 1451: uint16(34156), + 1452: uint16(34315), + 1453: uint16(37032), + 1454: uint16(34579), + 1455: uint16(37060), + 1456: uint16(34534), + 1457: uint16(37038), + 1459: uint16(37223), + 1460: uint16(15088), + 1461: uint16(37289), + 1462: uint16(37316), + 1463: uint16(31916), + 1464: uint16(35123), + 1465: uint16(7817), + 1466: uint16(37390), + 1467: uint16(27807), + 1468: uint16(37441), + 1469: uint16(37474), + 1470: uint16(21945), + 1472: uint16(35526), + 1473: uint16(15515), + 1474: uint16(35596), + 1475: uint16(21979), + 1476: uint16(3377), + 1477: uint16(37676), + 1478: uint16(37739), + 1479: uint16(35553), + 1480: uint16(35819), + 1481: uint16(28815), + 1482: uint16(23235), + 1483: uint16(35554), + 1484: uint16(35557), + 1485: uint16(18789), + 1486: uint16(37444), + 1487: uint16(35820), + 1488: uint16(35897), + 1489: uint16(35839), + 1490: uint16(37747), + 1491: uint16(37979), + 1492: uint16(36540), + 1493: uint16(38277), + 1494: uint16(38310), + 1495: uint16(37926), + 1496: uint16(38304), + 1497: uint16(28662), + 1498: uint16(17081), + 1499: uint16(9850), + 1500: uint16(34520), + 1501: uint16(4732), + 1502: uint16(15918), + 1503: uint16(18911), + 1504: uint16(27676), + 1505: uint16(38523), + 1506: uint16(38550), + 1507: uint16(16748), + 1508: uint16(38563), + 1509: uint16(28373), + 1510: uint16(25050), + 1511: uint16(38582), + 1512: uint16(30965), + 1513: uint16(35552), + 1514: uint16(38589), + 1515: uint16(21452), + 1516: uint16(18849), + 1517: uint16(27832), + 1518: uint16(628), + 1519: uint16(25616), + 1520: uint16(37039), + 1521: uint16(37093), + 1522: uint16(19153), + 1523: uint16(6421), + 1524: uint16(13066), + 1525: uint16(38705), + 1526: uint16(34370), + 1527: uint16(38710), + 1528: uint16(18959), + 1529: uint16(17725), + 1530: uint16(17797), + 1531: uint16(19177), + 1532: uint16(28789), + 1533: uint16(23361), + 1534: uint16(38683), + 1536: uint16(37333), + 1537: uint16(38743), + 1538: uint16(23370), + 1539: uint16(37355), + 1540: uint16(38751), + 1541: uint16(37925), + 1542: uint16(20688), + 1543: uint16(12471), + 1544: uint16(12476), + 1545: uint16(38793), + 1546: uint16(38815), + 1547: uint16(38833), + 1548: uint16(38846), + 1549: uint16(38848), + 1550: uint16(38866), + 1551: uint16(38880), + 1552: uint16(21612), + 1553: uint16(38894), + 1554: uint16(29724), + 1555: uint16(37939), + 1557: uint16(38901), + 1558: uint16(37917), + 1559: uint16(31098), + 1560: uint16(19153), + 1561: uint16(38964), + 1562: uint16(38963), + 1563: uint16(38987), + 1564: uint16(39014), + 1565: uint16(15118), + 1566: uint16(29045), + 1567: uint16(15697), + 1568: uint16(1584), + 1569: uint16(16732), + 1570: uint16(22278), + 1571: uint16(39114), + 1572: uint16(39095), + 1573: uint16(39112), + 1574: uint16(39111), + 1575: uint16(19199), + 1576: uint16(27943), + 1577: uint16(5843), + 1578: uint16(21936), + 1579: uint16(39137), + 1580: uint16(39142), + 1581: uint16(39148), + 1582: uint16(37752), + 1583: uint16(39225), + 1584: uint16(18985), + 1585: uint16(19314), + 1586: uint16(38999), + 1587: uint16(39173), + 1588: uint16(39413), + 1589: uint16(39436), + 1590: uint16(39483), + 1591: uint16(39440), + 1592: uint16(39512), + 1593: uint16(22309), + 1594: uint16(14020), + 1595: uint16(37041), + 1596: uint16(39893), + 1597: uint16(39648), + 1598: uint16(39650), + 1599: uint16(39685), + 1600: uint16(39668), + 1601: uint16(19470), + 1602: uint16(39700), + 1603: uint16(39725), + 1604: uint16(34304), + 1605: uint16(20532), + 1606: uint16(39732), + 1607: uint16(27048), + 1608: uint16(14531), + 1609: uint16(12413), + 1610: uint16(39760), + 1611: uint16(39744), + 1612: uint16(40254), + 1613: uint16(23109), + 1614: uint16(6243), + 1615: uint16(39822), + 1616: uint16(16971), + 1617: uint16(39938), + 1618: uint16(39935), + 1619: uint16(39948), + 1620: uint16(40552), + 1621: uint16(40404), + 1622: uint16(40887), + 1623: uint16(41362), + 1624: uint16(41387), + 1625: uint16(41185), + 1626: uint16(41251), + 1627: uint16(41439), + 1628: uint16(40318), + 1629: uint16(40323), + 1630: uint16(41268), + 1631: uint16(40462), + 1632: uint16(26760), + 1633: uint16(40388), + 1634: uint16(8539), + 1635: uint16(41363), + 1636: uint16(41504), + 1637: uint16(6459), + 1638: uint16(41523), + 1639: uint16(40249), + 1640: uint16(41145), + 1641: uint16(41652), + 1642: uint16(40592), + 1643: uint16(40597), + 1644: uint16(40606), + 1645: uint16(40610), + 1646: uint16(19764), + 1647: uint16(40618), + 1648: uint16(40623), + 1649: uint16(17252), + 1650: uint16(40641), + 1651: uint16(15200), + 1652: uint16(14821), + 1653: uint16(15645), + 1654: uint16(20274), + 1655: uint16(14270), + 1656: uint16(35883), + 1657: uint16(40706), + 1658: uint16(40712), + 1659: uint16(19350), + 1660: uint16(37924), + 1661: uint16(28066), + 1662: uint16(40727), + 1664: uint16(40761), + 1665: uint16(22175), + 1666: uint16(22154), + 1667: uint16(40773), + 1668: uint16(39352), + 1669: uint16(37003), + 1670: uint16(38898), + 1671: uint16(33919), + 1672: uint16(40802), + 1673: uint16(40809), + 1674: uint16(31452), + 1675: uint16(40846), + 1676: uint16(29206), + 1677: uint16(19390), + 1678: uint16(18805), + 1679: uint16(18875), + 1680: uint16(29047), + 1681: uint16(18936), + 1682: uint16(17224), + 1683: uint16(19025), + 1684: uint16(29598), + 1685: uint16(35802), + 1686: uint16(6394), + 1687: uint16(31135), + 1688: uint16(35198), + 1689: uint16(36406), + 1690: uint16(37737), + 1691: uint16(37875), + 1692: uint16(35396), + 1693: uint16(37612), + 1694: uint16(37761), + 1695: uint16(37835), + 1696: uint16(35180), + 1697: uint16(17593), + 1698: uint16(29207), + 1699: uint16(16107), + 1700: uint16(30578), + 1701: uint16(31299), + 1702: uint16(28880), + 1703: uint16(17523), + 1704: uint16(17400), + 1705: uint16(29054), + 1706: uint16(6127), + 1707: uint16(28835), + 1708: uint16(6334), + 1709: uint16(13721), + 1710: uint16(16071), + 1711: uint16(6277), + 1712: uint16(21551), + 1713: uint16(6136), + 1714: uint16(14114), + 1715: uint16(5883), + 1716: uint16(6201), + 1717: uint16(14049), + 1718: uint16(6004), + 1719: uint16(6353), + 1720: uint16(24395), + 1721: uint16(14115), + 1722: uint16(5824), + 1723: uint16(22363), + 1724: uint16(18981), + 1725: uint16(5118), + 1726: uint16(4776), + 1727: uint16(5062), + 1728: uint16(5302), + 1729: uint16(34051), + 1730: uint16(13990), + 1732: uint16(33877), + 1733: uint16(18836), + 1734: uint16(29029), + 1735: uint16(15921), + 1736: uint16(21852), + 1737: uint16(16123), + 1738: uint16(28754), + 1739: uint16(17652), + 1740: uint16(14062), + 1741: uint16(39325), + 1742: uint16(28454), + 1743: uint16(26617), + 1744: uint16(14131), + 1745: uint16(15381), + 1746: uint16(15847), + 1747: uint16(22636), + 1748: uint16(6434), + 1749: uint16(26640), + 1750: uint16(16471), + 1751: uint16(14143), + 1752: uint16(16609), + 1753: uint16(16523), + 1754: uint16(16655), + 1755: uint16(27681), + 1756: uint16(21707), + 1757: uint16(22174), + 1758: uint16(26289), + 1759: uint16(22162), + 1760: uint16(4063), + 1761: uint16(2984), + 1762: uint16(3597), + 1763: uint16(37830), + 1764: uint16(35603), + 1765: uint16(37788), + 1766: uint16(20216), + 1767: uint16(20779), + 1768: uint16(14361), + 1769: uint16(17462), + 1770: uint16(20156), + 1771: uint16(1125), + 1772: uint16(895), + 1773: uint16(20299), + 1774: uint16(20362), + 1775: uint16(22097), + 1776: uint16(23144), + 1777: uint16(427), + 1778: uint16(971), + 1779: uint16(14745), + 1780: uint16(778), + 1781: uint16(1044), + 1782: uint16(13365), + 1783: uint16(20265), + 1784: uint16(704), + 1785: uint16(36531), + 1786: uint16(629), + 1787: uint16(35546), + 1788: uint16(524), + 1789: uint16(20120), + 1790: uint16(20685), + 1791: uint16(20749), + 1792: uint16(20386), + 1793: uint16(20227), + 1794: uint16(18958), + 1795: uint16(16010), + 1796: uint16(20290), + 1797: uint16(20526), + 1798: uint16(20588), + 1799: uint16(20609), + 1800: uint16(20428), + 1801: uint16(20453), + 1802: uint16(20568), + 1803: uint16(20732), + 1808: uint16(28278), + 1809: uint16(13717), + 1810: uint16(15929), + 1811: uint16(16063), + 1812: uint16(28018), + 1813: uint16(6276), + 1814: uint16(16009), + 1815: uint16(20904), + 1816: uint16(20931), + 1817: uint16(1504), + 1818: uint16(17629), + 1819: uint16(1187), + 1820: uint16(1170), + 1821: uint16(1169), + 1822: uint16(36218), + 1823: uint16(35484), + 1824: uint16(1806), + 1825: uint16(21081), + 1826: uint16(21156), + 1827: uint16(2163), + 1828: uint16(21217), + 1830: uint16(18042), + 1831: uint16(29068), + 1832: uint16(17292), + 1833: uint16(3104), + 1834: uint16(18860), + 1835: uint16(4324), + 1836: uint16(27089), + 1837: uint16(3613), + 1839: uint16(16094), + 1840: uint16(29849), + 1841: uint16(29716), + 1842: uint16(29782), + 1843: uint16(29592), + 1844: uint16(19342), + 1845: uint16(19132), + 1846: uint16(16525), + 1847: uint16(21456), + 1848: uint16(13700), + 1849: uint16(29199), + 1850: uint16(16585), + 1851: uint16(21940), + 1852: uint16(837), + 1853: uint16(21709), + 1854: uint16(3014), + 1855: uint16(22301), + 1856: uint16(37469), + 1857: uint16(38644), + 1858: uint16(37734), + 1859: uint16(22493), + 1860: uint16(22413), + 1861: uint16(22399), + 1862: uint16(13886), + 1863: uint16(22731), + 1864: uint16(23193), + 1865: uint16(35398), + 1866: uint16(5882), + 1867: uint16(5999), + 1868: uint16(5904), + 1869: uint16(23084), + 1870: uint16(22968), + 1871: uint16(37519), + 1872: uint16(23166), + 1873: uint16(23247), + 1874: uint16(23058), + 1875: uint16(22854), + 1876: uint16(6643), + 1877: uint16(6241), + 1878: uint16(17045), + 1879: uint16(14069), + 1880: uint16(27909), + 1881: uint16(29763), + 1882: uint16(23073), + 1883: uint16(24195), + 1884: uint16(23169), + 1885: uint16(35799), + 1886: uint16(1043), + 1887: uint16(37856), + 1888: uint16(29836), + 1889: uint16(4867), + 1890: uint16(28933), + 1891: uint16(18802), + 1892: uint16(37896), + 1893: uint16(35323), + 1894: uint16(37821), + 1895: uint16(14240), + 1896: uint16(23582), + 1897: uint16(23710), + 1898: uint16(24158), + 1899: uint16(24136), + 1900: uint16(6550), + 1901: uint16(6524), + 1902: uint16(15086), + 1903: uint16(24269), + 1904: uint16(23375), + 1905: uint16(6403), + 1906: uint16(6404), + 1907: uint16(14081), + 1908: uint16(6304), + 1909: uint16(14045), + 1910: uint16(5886), + 1911: uint16(14035), + 1912: uint16(33066), + 1913: uint16(35399), + 1914: uint16(7610), + 1915: uint16(13426), + 1916: uint16(35240), + 1917: uint16(24332), + 1918: uint16(24334), + 1919: uint16(6439), + 1920: uint16(6059), + 1921: uint16(23147), + 1922: uint16(5947), + 1923: uint16(23364), + 1924: uint16(34324), + 1925: uint16(30205), + 1926: uint16(34912), + 1927: uint16(24702), + 1928: uint16(10336), + 1929: uint16(9771), + 1930: uint16(24539), + 1931: uint16(16056), + 1932: uint16(9647), + 1933: uint16(9662), + 1934: uint16(37000), + 1935: uint16(28531), + 1936: uint16(25024), + 1937: uint16(62), + 1938: uint16(70), + 1939: uint16(9755), + 1940: uint16(24985), + 1941: uint16(24984), + 1942: uint16(24693), + 1943: uint16(11419), + 1944: uint16(11527), + 1945: uint16(18132), + 1946: uint16(37197), + 1947: uint16(25713), + 1948: uint16(18021), + 1949: uint16(11114), + 1950: uint16(14889), + 1951: uint16(11042), + 1952: uint16(13392), + 1953: uint16(39146), + 1954: uint16(11896), + 1955: uint16(25399), + 1956: uint16(42075), + 1957: uint16(25782), + 1958: uint16(25393), + 1959: uint16(25553), + 1960: uint16(18915), + 1961: uint16(11623), + 1962: uint16(25252), + 1963: uint16(11425), + 1964: uint16(25659), + 1965: uint16(25963), + 1966: uint16(26994), + 1967: uint16(15348), + 1968: uint16(12430), + 1969: uint16(12973), + 1970: uint16(18825), + 1971: uint16(12971), + 1972: uint16(21773), + 1973: uint16(13024), + 1974: uint16(6361), + 1975: uint16(37951), + 1976: uint16(26318), + 1977: uint16(12937), + 1978: uint16(12723), + 1979: uint16(15072), + 1980: uint16(16784), + 1981: uint16(21892), + 1982: uint16(35618), + 1983: uint16(21903), + 1984: uint16(5884), + 1985: uint16(21851), + 1986: uint16(21541), + 1987: uint16(30958), + 1988: uint16(12547), + 1989: uint16(6186), + 1990: uint16(12852), + 1991: uint16(13412), + 1992: uint16(12815), + 1993: uint16(12674), + 1994: uint16(17097), + 1995: uint16(26254), + 1996: uint16(27940), + 1997: uint16(26219), + 1998: uint16(19347), + 1999: uint16(26160), + 2000: uint16(30832), + 2001: uint16(7659), + 2002: uint16(26211), + 2003: uint16(13010), + 2004: uint16(13025), + 2005: uint16(26142), + 2006: uint16(22642), + 2007: uint16(14545), + 2008: uint16(14394), + 2009: uint16(14268), + 2010: uint16(15257), + 2011: uint16(14242), + 2012: uint16(13310), + 2013: uint16(29904), + 2014: uint16(15254), + 2015: uint16(26511), + 2016: uint16(17962), + 2017: uint16(26806), + 2018: uint16(26654), + 2019: uint16(15300), + 2020: uint16(27326), + 2021: uint16(14435), + 2022: uint16(14293), + 2023: uint16(17543), + 2024: uint16(27187), + 2025: uint16(27218), + 2026: uint16(27337), + 2027: uint16(27397), + 2028: uint16(6418), + 2029: uint16(25873), + 2030: uint16(26776), + 2031: uint16(27212), + 2032: uint16(15319), + 2033: uint16(27258), + 2034: uint16(27479), + 2035: uint16(16320), + 2036: uint16(15514), + 2037: uint16(37792), + 2038: uint16(37618), + 2039: uint16(35818), + 2040: uint16(35531), + 2041: uint16(37513), + 2042: uint16(32798), + 2043: uint16(35292), + 2044: uint16(37991), + 2045: uint16(28069), + 2046: uint16(28427), + 2047: uint16(18924), + 2049: uint16(16255), + 2050: uint16(15759), + 2051: uint16(28164), + 2052: uint16(16444), + 2053: uint16(23101), + 2054: uint16(28170), + 2055: uint16(22599), + 2056: uint16(27940), + 2057: uint16(30786), + 2058: uint16(28987), + 2059: uint16(17178), + 2060: uint16(17014), + 2061: uint16(28913), + 2062: uint16(29264), + 2063: uint16(29319), + 2064: uint16(29332), + 2065: uint16(18319), + 2066: uint16(18213), + 2067: uint16(20857), + 2068: uint16(19108), + 2069: uint16(1515), + 2070: uint16(29818), + 2071: uint16(16120), + 2072: uint16(13919), + 2073: uint16(19018), + 2074: uint16(18711), + 2075: uint16(24545), + 2076: uint16(16134), + 2077: uint16(16049), + 2078: uint16(19167), + 2079: uint16(35875), + 2080: uint16(16181), + 2081: uint16(24743), + 2082: uint16(16115), + 2083: uint16(29900), + 2084: uint16(29756), + 2085: uint16(37767), + 2086: uint16(29751), + 2087: uint16(17567), + 2088: uint16(28138), + 2089: uint16(17745), + 2090: uint16(30083), + 2091: uint16(16227), + 2092: uint16(19673), + 2093: uint16(19718), + 2094: uint16(16216), + 2095: uint16(30037), + 2096: uint16(30323), + 2097: uint16(42438), + 2098: uint16(15129), + 2099: uint16(29800), + 2100: uint16(35532), + 2101: uint16(18859), + 2102: uint16(18830), + 2103: uint16(15099), + 2104: uint16(15821), + 2105: uint16(19022), + 2106: uint16(16127), + 2107: uint16(18885), + 2108: uint16(18675), + 2109: uint16(37370), + 2110: uint16(22322), + 2111: uint16(37698), + 2112: uint16(35555), + 2113: uint16(6244), + 2114: uint16(20703), + 2115: uint16(21025), + 2116: uint16(20967), + 2117: uint16(30584), + 2118: uint16(12850), + 2119: uint16(30478), + 2120: uint16(30479), + 2121: uint16(30587), + 2122: uint16(18071), + 2123: uint16(14209), + 2124: uint16(14942), + 2125: uint16(18672), + 2126: uint16(29752), + 2127: uint16(29851), + 2128: uint16(16063), + 2129: uint16(19130), + 2130: uint16(19143), + 2131: uint16(16584), + 2132: uint16(19094), + 2133: uint16(25006), + 2134: uint16(37639), + 2135: uint16(21889), + 2136: uint16(30750), + 2137: uint16(30861), + 2138: uint16(30856), + 2139: uint16(30930), + 2140: uint16(29648), + 2141: uint16(31065), + 2142: uint16(30529), + 2143: uint16(22243), + 2144: uint16(16654), + 2146: uint16(33942), + 2147: uint16(31141), + 2148: uint16(27181), + 2149: uint16(16122), + 2150: uint16(31290), + 2151: uint16(31220), + 2152: uint16(16750), + 2153: uint16(5862), + 2154: uint16(16690), + 2155: uint16(37429), + 2156: uint16(31217), + 2157: uint16(3404), + 2158: uint16(18828), + 2159: uint16(665), + 2160: uint16(15802), + 2161: uint16(5998), + 2162: uint16(13719), + 2163: uint16(21867), + 2164: uint16(13680), + 2165: uint16(13994), + 2166: uint16(468), + 2167: uint16(3085), + 2168: uint16(31458), + 2169: uint16(23129), + 2170: uint16(9973), + 2171: uint16(23215), + 2172: uint16(23196), + 2173: uint16(23053), + 2174: uint16(603), + 2175: uint16(30960), + 2176: uint16(23082), + 2177: uint16(23494), + 2178: uint16(31486), + 2179: uint16(16889), + 2180: uint16(31837), + 2181: uint16(31853), + 2182: uint16(16913), + 2183: uint16(23475), + 2184: uint16(24252), + 2185: uint16(24230), + 2186: uint16(31949), + 2187: uint16(18937), + 2188: uint16(6064), + 2189: uint16(31886), + 2190: uint16(31868), + 2191: uint16(31918), + 2192: uint16(27314), + 2193: uint16(32220), + 2194: uint16(32263), + 2195: uint16(32211), + 2196: uint16(32590), + 2197: uint16(25185), + 2198: uint16(24924), + 2199: uint16(31560), + 2200: uint16(32151), + 2201: uint16(24194), + 2202: uint16(17002), + 2203: uint16(27509), + 2204: uint16(2326), + 2205: uint16(26582), + 2206: uint16(78), + 2207: uint16(13775), + 2208: uint16(22468), + 2209: uint16(25618), + 2210: uint16(25592), + 2211: uint16(18786), + 2212: uint16(32733), + 2213: uint16(31527), + 2214: uint16(2092), + 2215: uint16(23273), + 2216: uint16(23875), + 2217: uint16(31500), + 2218: uint16(24078), + 2219: uint16(39398), + 2220: uint16(34373), + 2221: uint16(39523), + 2222: uint16(27164), + 2223: uint16(13375), + 2224: uint16(14818), + 2225: uint16(18935), + 2226: uint16(26029), + 2227: uint16(39455), + 2228: uint16(26016), + 2229: uint16(33920), + 2230: uint16(28967), + 2231: uint16(27857), + 2232: uint16(17642), + 2233: uint16(33079), + 2234: uint16(17410), + 2235: uint16(32966), + 2236: uint16(33033), + 2237: uint16(33090), + 2238: uint16(26548), + 2239: uint16(39107), + 2240: uint16(27202), + 2241: uint16(33378), + 2242: uint16(33381), + 2243: uint16(27217), + 2244: uint16(33875), + 2245: uint16(28071), + 2246: uint16(34320), + 2247: uint16(29211), + 2248: uint16(23174), + 2249: uint16(16767), + 2250: uint16(6208), + 2251: uint16(23339), + 2252: uint16(6305), + 2253: uint16(23268), + 2254: uint16(6360), + 2255: uint16(34464), + 2256: uint16(63932), + 2257: uint16(15759), + 2258: uint16(34861), + 2259: uint16(29730), + 2260: uint16(23042), + 2261: uint16(34926), + 2262: uint16(20293), + 2263: uint16(34951), + 2264: uint16(35007), + 2265: uint16(35046), + 2266: uint16(35173), + 2267: uint16(35149), + 2268: uint16(22147), + 2269: uint16(35156), + 2270: uint16(30597), + 2271: uint16(30596), + 2272: uint16(35829), + 2273: uint16(35801), + 2274: uint16(35740), + 2275: uint16(35321), + 2276: uint16(16045), + 2277: uint16(33955), + 2278: uint16(18165), + 2279: uint16(18127), + 2280: uint16(14322), + 2281: uint16(35389), + 2282: uint16(35356), + 2283: uint16(37960), + 2284: uint16(24397), + 2285: uint16(37419), + 2286: uint16(17028), + 2287: uint16(26068), + 2288: uint16(28969), + 2289: uint16(28868), + 2290: uint16(6213), + 2291: uint16(40301), + 2292: uint16(35999), + 2293: uint16(36073), + 2294: uint16(32220), + 2295: uint16(22938), + 2296: uint16(30659), + 2297: uint16(23024), + 2298: uint16(17262), + 2299: uint16(14036), + 2300: uint16(36394), + 2301: uint16(36519), + 2302: uint16(19465), + 2303: uint16(36656), + 2304: uint16(36682), + 2305: uint16(17140), + 2306: uint16(27736), + 2307: uint16(28603), + 2308: uint16(8993), + 2309: uint16(18587), + 2310: uint16(28537), + 2311: uint16(28299), + 2312: uint16(6106), + 2313: uint16(39913), + 2314: uint16(14005), + 2315: uint16(18735), + 2316: uint16(37051), + 2318: uint16(21873), + 2319: uint16(18694), + 2320: uint16(37307), + 2321: uint16(37892), + 2322: uint16(35403), + 2323: uint16(16482), + 2324: uint16(35580), + 2325: uint16(37927), + 2326: uint16(35869), + 2327: uint16(35899), + 2328: uint16(34021), + 2329: uint16(35371), + 2330: uint16(38297), + 2331: uint16(38311), + 2332: uint16(38295), + 2333: uint16(38294), + 2334: uint16(36148), + 2335: uint16(29765), + 2336: uint16(16066), + 2337: uint16(18687), + 2338: uint16(19010), + 2339: uint16(17386), + 2340: uint16(16103), + 2341: uint16(12837), + 2342: uint16(38543), + 2343: uint16(36583), + 2344: uint16(36454), + 2345: uint16(36453), + 2346: uint16(16076), + 2347: uint16(18925), + 2348: uint16(19064), + 2349: uint16(16366), + 2350: uint16(29714), + 2351: uint16(29803), + 2352: uint16(16124), + 2353: uint16(38721), + 2354: uint16(37040), + 2355: uint16(26695), + 2356: uint16(18973), + 2357: uint16(37011), + 2358: uint16(22495), + 2360: uint16(37736), + 2361: uint16(35209), + 2362: uint16(35878), + 2363: uint16(35631), + 2364: uint16(25534), + 2365: uint16(37562), + 2366: uint16(23313), + 2367: uint16(35689), + 2368: uint16(18748), + 2369: uint16(29689), + 2370: uint16(16923), + 2371: uint16(38811), + 2372: uint16(38769), + 2373: uint16(39224), + 2374: uint16(3878), + 2375: uint16(24001), + 2376: uint16(35781), + 2377: uint16(19122), + 2378: uint16(38943), + 2379: uint16(38106), + 2380: uint16(37622), + 2381: uint16(38359), + 2382: uint16(37349), + 2383: uint16(17600), + 2384: uint16(35664), + 2385: uint16(19047), + 2386: uint16(35684), + 2387: uint16(39132), + 2388: uint16(35397), + 2389: uint16(16128), + 2390: uint16(37418), + 2391: uint16(18725), + 2392: uint16(33812), + 2393: uint16(39227), + 2394: uint16(39245), + 2395: uint16(31494), + 2396: uint16(15869), + 2397: uint16(39323), + 2398: uint16(19311), + 2399: uint16(39338), + 2400: uint16(39516), + 2401: uint16(35685), + 2402: uint16(22728), + 2403: uint16(27279), + 2404: uint16(39457), + 2405: uint16(23294), + 2406: uint16(39471), + 2407: uint16(39153), + 2408: uint16(19344), + 2409: uint16(39240), + 2410: uint16(39356), + 2411: uint16(19389), + 2412: uint16(19351), + 2413: uint16(37757), + 2414: uint16(22642), + 2415: uint16(4866), + 2416: uint16(22562), + 2417: uint16(18872), + 2418: uint16(5352), + 2419: uint16(30788), + 2420: uint16(10015), + 2421: uint16(15800), + 2422: uint16(26821), + 2423: uint16(15741), + 2424: uint16(37976), + 2425: uint16(14631), + 2426: uint16(24912), + 2427: uint16(10113), + 2428: uint16(10603), + 2429: uint16(24839), + 2430: uint16(40015), + 2431: uint16(40019), + 2432: uint16(40059), + 2433: uint16(39989), + 2434: uint16(39952), + 2435: uint16(39807), + 2436: uint16(39887), + 2437: uint16(40493), + 2438: uint16(39839), + 2439: uint16(41461), + 2440: uint16(41214), + 2441: uint16(40225), + 2442: uint16(19630), + 2443: uint16(16644), + 2444: uint16(40472), + 2445: uint16(19632), + 2446: uint16(40204), + 2447: uint16(41396), + 2448: uint16(41197), + 2449: uint16(41203), + 2450: uint16(39215), + 2451: uint16(40357), + 2452: uint16(33981), + 2453: uint16(28178), + 2454: uint16(28639), + 2455: uint16(27522), + 2456: uint16(34300), + 2457: uint16(17715), + 2458: uint16(28068), + 2459: uint16(28292), + 2460: uint16(28144), + 2461: uint16(33824), + 2462: uint16(34286), + 2463: uint16(28160), + 2464: uint16(14295), + 2465: uint16(24676), + 2466: uint16(31202), + 2467: uint16(13724), + 2468: uint16(13888), + 2469: uint16(18733), + 2470: uint16(18910), + 2471: uint16(15714), + 2472: uint16(37851), + 2473: uint16(37566), + 2474: uint16(37704), + 2475: uint16(703), + 2476: uint16(30905), + 2477: uint16(37495), + 2478: uint16(37965), + 2479: uint16(20452), + 2480: uint16(13376), + 2481: uint16(36964), + 2482: uint16(21853), + 2483: uint16(30781), + 2484: uint16(30804), + 2485: uint16(30902), + 2486: uint16(30795), + 2487: uint16(5975), + 2488: uint16(12745), + 2489: uint16(18753), + 2490: uint16(13978), + 2491: uint16(20338), + 2492: uint16(28634), + 2493: uint16(28633), + 2495: uint16(28702), + 2496: uint16(21524), + 2497: uint16(16821), + 2498: uint16(22459), + 2499: uint16(22771), + 2500: uint16(22410), + 2501: uint16(40214), + 2502: uint16(22487), + 2503: uint16(28980), + 2504: uint16(13487), + 2505: uint16(16812), + 2506: uint16(29163), + 2507: uint16(27712), + 2508: uint16(20375), + 2510: uint16(6069), + 2511: uint16(35401), + 2512: uint16(24844), + 2513: uint16(23246), + 2514: uint16(23051), + 2515: uint16(17084), + 2516: uint16(17544), + 2517: uint16(14124), + 2518: uint16(19323), + 2519: uint16(35324), + 2520: uint16(37819), + 2521: uint16(37816), + 2522: uint16(6358), + 2523: uint16(3869), + 2524: uint16(33906), + 2525: uint16(27840), + 2526: uint16(5139), + 2527: uint16(17146), + 2528: uint16(11302), + 2529: uint16(17345), + 2530: uint16(22932), + 2531: uint16(15799), + 2532: uint16(26433), + 2533: uint16(32168), + 2534: uint16(24923), + 2535: uint16(24740), + 2536: uint16(18873), + 2537: uint16(18827), + 2538: uint16(35322), + 2539: uint16(37605), + 2540: uint16(29666), + 2541: uint16(16105), + 2542: uint16(29876), + 2543: uint16(35683), + 2544: uint16(6303), + 2545: uint16(16097), + 2546: uint16(19123), + 2547: uint16(27352), + 2548: uint16(29683), + 2549: uint16(29691), + 2550: uint16(16086), + 2551: uint16(19006), + 2552: uint16(19092), + 2553: uint16(6105), + 2554: uint16(19046), + 2555: uint16(935), + 2556: uint16(5156), + 2557: uint16(18917), + 2558: uint16(29768), + 2559: uint16(18710), + 2560: uint16(28837), + 2561: uint16(18806), + 2562: uint16(37508), + 2563: uint16(29670), + 2564: uint16(37727), + 2565: uint16(1278), + 2566: uint16(37681), + 2567: uint16(35534), + 2568: uint16(35350), + 2569: uint16(37766), + 2570: uint16(35815), + 2571: uint16(21973), + 2572: uint16(18741), + 2573: uint16(35458), + 2574: uint16(29035), + 2575: uint16(18755), + 2576: uint16(3327), + 2577: uint16(22180), + 2578: uint16(1562), + 2579: uint16(3051), + 2580: uint16(3256), + 2581: uint16(21762), + 2582: uint16(31172), + 2583: uint16(6138), + 2584: uint16(32254), + 2585: uint16(5826), + 2586: uint16(19024), + 2587: uint16(6226), + 2588: uint16(17710), + 2589: uint16(37889), + 2590: uint16(14090), + 2591: uint16(35520), + 2592: uint16(18861), + 2593: uint16(22960), + 2594: uint16(6335), + 2595: uint16(6275), + 2596: uint16(29828), + 2597: uint16(23201), + 2598: uint16(14050), + 2599: uint16(15707), + 2600: uint16(14000), + 2601: uint16(37471), + 2602: uint16(23161), + 2603: uint16(35457), + 2604: uint16(6242), + 2605: uint16(37748), + 2606: uint16(15565), + 2607: uint16(2740), + 2608: uint16(19094), + 2609: uint16(14730), + 2610: uint16(20724), + 2611: uint16(15721), + 2612: uint16(15692), + 2613: uint16(5020), + 2614: uint16(29045), + 2615: uint16(17147), + 2616: uint16(33304), + 2617: uint16(28175), + 2618: uint16(37092), + 2619: uint16(17643), + 2620: uint16(27991), + 2621: uint16(32335), + 2622: uint16(28775), + 2623: uint16(27823), + 2624: uint16(15574), + 2625: uint16(16365), + 2626: uint16(15917), + 2627: uint16(28162), + 2628: uint16(28428), + 2629: uint16(15727), + 2630: uint16(1013), + 2631: uint16(30033), + 2632: uint16(14012), + 2633: uint16(13512), + 2634: uint16(18048), + 2635: uint16(16090), + 2636: uint16(18545), + 2637: uint16(22980), + 2638: uint16(37486), + 2639: uint16(18750), + 2640: uint16(36673), + 2641: uint16(35868), + 2642: uint16(27584), + 2643: uint16(22546), + 2644: uint16(22472), + 2645: uint16(14038), + 2646: uint16(5202), + 2647: uint16(28926), + 2648: uint16(17250), + 2649: uint16(19057), + 2650: uint16(12259), + 2651: uint16(4784), + 2652: uint16(9149), + 2653: uint16(26809), + 2654: uint16(26983), + 2655: uint16(5016), + 2656: uint16(13541), + 2657: uint16(31732), + 2658: uint16(14047), + 2659: uint16(35459), + 2660: uint16(14294), + 2661: uint16(13306), + 2662: uint16(19615), + 2663: uint16(27162), + 2664: uint16(13997), + 2665: uint16(27831), + 2666: uint16(33854), + 2667: uint16(17631), + 2668: uint16(17614), + 2669: uint16(27942), + 2670: uint16(27985), + 2671: uint16(27778), + 2672: uint16(28638), + 2673: uint16(28439), + 2674: uint16(28937), + 2675: uint16(33597), + 2676: uint16(5946), + 2677: uint16(33773), + 2678: uint16(27776), + 2679: uint16(28755), + 2680: uint16(6107), + 2681: uint16(22921), + 2682: uint16(23170), + 2683: uint16(6067), + 2684: uint16(23137), + 2685: uint16(23153), + 2686: uint16(6405), + 2687: uint16(16892), + 2688: uint16(14125), + 2689: uint16(23023), + 2690: uint16(5948), + 2691: uint16(14023), + 2692: uint16(29070), + 2693: uint16(37776), + 2694: uint16(26266), + 2695: uint16(17061), + 2696: uint16(23150), + 2697: uint16(23083), + 2698: uint16(17043), + 2699: uint16(27179), + 2700: uint16(16121), + 2701: uint16(30518), + 2702: uint16(17499), + 2703: uint16(17098), + 2704: uint16(28957), + 2705: uint16(16985), + 2706: uint16(35297), + 2707: uint16(20400), + 2708: uint16(27944), + 2709: uint16(23746), + 2710: uint16(17614), + 2711: uint16(32333), + 2712: uint16(17341), + 2713: uint16(27148), + 2714: uint16(16982), + 2715: uint16(4868), + 2716: uint16(28838), + 2717: uint16(28979), + 2718: uint16(17385), + 2719: uint16(15781), + 2720: uint16(27871), + 2721: uint16(63525), + 2722: uint16(19023), + 2723: uint16(32357), + 2724: uint16(23019), + 2725: uint16(23855), + 2726: uint16(15859), + 2727: uint16(24412), + 2728: uint16(19037), + 2729: uint16(6111), + 2730: uint16(32164), + 2731: uint16(33830), + 2732: uint16(21637), + 2733: uint16(15098), + 2734: uint16(13056), + 2735: uint16(532), + 2736: uint16(22398), + 2737: uint16(2261), + 2738: uint16(1561), + 2739: uint16(16357), + 2740: uint16(8094), + 2741: uint16(41654), + 2742: uint16(28675), + 2743: uint16(37211), + 2744: uint16(23920), + 2745: uint16(29583), + 2746: uint16(31955), + 2747: uint16(35417), + 2748: uint16(37920), + 2749: uint16(20424), + 2750: uint16(32743), + 2751: uint16(29389), + 2752: uint16(29456), + 2753: uint16(31476), + 2754: uint16(29496), + 2755: uint16(29497), + 2756: uint16(22262), + 2757: uint16(29505), + 2758: uint16(29512), + 2759: uint16(16041), + 2760: uint16(31512), + 2761: uint16(36972), + 2762: uint16(29173), + 2763: uint16(18674), + 2764: uint16(29665), + 2765: uint16(33270), + 2766: uint16(16074), + 2767: uint16(30476), + 2768: uint16(16081), + 2769: uint16(27810), + 2770: uint16(22269), + 2771: uint16(29721), + 2772: uint16(29726), + 2773: uint16(29727), + 2774: uint16(16098), + 2775: uint16(16112), + 2776: uint16(16116), + 2777: uint16(16122), + 2778: uint16(29907), + 2779: uint16(16142), + 2780: uint16(16211), + 2781: uint16(30018), + 2782: uint16(30061), + 2783: uint16(30066), + 2784: uint16(30093), + 2785: uint16(16252), + 2786: uint16(30152), + 2787: uint16(30172), + 2788: uint16(16320), + 2789: uint16(30285), + 2790: uint16(16343), + 2791: uint16(30324), + 2792: uint16(16348), + 2793: uint16(30330), + 2794: uint16(20316), + 2795: uint16(29064), + 2796: uint16(22051), + 2797: uint16(35200), + 2798: uint16(22633), + 2799: uint16(16413), + 2800: uint16(30531), + 2801: uint16(16441), + 2802: uint16(26465), + 2803: uint16(16453), + 2804: uint16(13787), + 2805: uint16(30616), + 2806: uint16(16490), + 2807: uint16(16495), + 2808: uint16(23646), + 2809: uint16(30654), + 2810: uint16(30667), + 2811: uint16(22770), + 2812: uint16(30744), + 2813: uint16(28857), + 2814: uint16(30748), + 2815: uint16(16552), + 2816: uint16(30777), + 2817: uint16(30791), + 2818: uint16(30801), + 2819: uint16(30822), + 2820: uint16(33864), + 2821: uint16(21813), + 2822: uint16(31027), + 2823: uint16(26627), + 2824: uint16(31026), + 2825: uint16(16643), + 2826: uint16(16649), + 2827: uint16(31121), + 2828: uint16(31129), + 2829: uint16(36795), + 2830: uint16(31238), + 2831: uint16(36796), + 2832: uint16(16743), + 2833: uint16(31377), + 2834: uint16(16818), + 2835: uint16(31420), + 2836: uint16(33401), + 2837: uint16(16836), + 2838: uint16(31439), + 2839: uint16(31451), + 2840: uint16(16847), + 2841: uint16(20001), + 2842: uint16(31586), + 2843: uint16(31596), + 2844: uint16(31611), + 2845: uint16(31762), + 2846: uint16(31771), + 2847: uint16(16992), + 2848: uint16(17018), + 2849: uint16(31867), + 2850: uint16(31900), + 2851: uint16(17036), + 2852: uint16(31928), + 2853: uint16(17044), + 2854: uint16(31981), + 2855: uint16(36755), + 2856: uint16(28864), + 2857: uint16(3279), + 2858: uint16(32207), + 2859: uint16(32212), + 2860: uint16(32208), + 2861: uint16(32253), + 2862: uint16(32686), + 2863: uint16(32692), + 2864: uint16(29343), + 2865: uint16(17303), + 2866: uint16(32800), + 2867: uint16(32805), + 2868: uint16(31545), + 2869: uint16(32814), + 2870: uint16(32817), + 2871: uint16(32852), + 2872: uint16(15820), + 2873: uint16(22452), + 2874: uint16(28832), + 2875: uint16(32951), + 2876: uint16(33001), + 2877: uint16(17389), + 2878: uint16(33036), + 2879: uint16(29482), + 2880: uint16(33038), + 2881: uint16(33042), + 2882: uint16(30048), + 2883: uint16(33044), + 2884: uint16(17409), + 2885: uint16(15161), + 2886: uint16(33110), + 2887: uint16(33113), + 2888: uint16(33114), + 2889: uint16(17427), + 2890: uint16(22586), + 2891: uint16(33148), + 2892: uint16(33156), + 2893: uint16(17445), + 2894: uint16(33171), + 2895: uint16(17453), + 2896: uint16(33189), + 2897: uint16(22511), + 2898: uint16(33217), + 2899: uint16(33252), + 2900: uint16(33364), + 2901: uint16(17551), + 2902: uint16(33446), + 2903: uint16(33398), + 2904: uint16(33482), + 2905: uint16(33496), + 2906: uint16(33535), + 2907: uint16(17584), + 2908: uint16(33623), + 2909: uint16(38505), + 2910: uint16(27018), + 2911: uint16(33797), + 2912: uint16(28917), + 2913: uint16(33892), + 2914: uint16(24803), + 2915: uint16(33928), + 2916: uint16(17668), + 2917: uint16(33982), + 2918: uint16(34017), + 2919: uint16(34040), + 2920: uint16(34064), + 2921: uint16(34104), + 2922: uint16(34130), + 2923: uint16(17723), + 2924: uint16(34159), + 2925: uint16(34160), + 2926: uint16(34272), + 2927: uint16(17783), + 2928: uint16(34418), + 2929: uint16(34450), + 2930: uint16(34482), + 2931: uint16(34543), + 2932: uint16(38469), + 2933: uint16(34699), + 2934: uint16(17926), + 2935: uint16(17943), + 2936: uint16(34990), + 2937: uint16(35071), + 2938: uint16(35108), + 2939: uint16(35143), + 2940: uint16(35217), + 2941: uint16(31079), + 2942: uint16(35369), + 2943: uint16(35384), + 2944: uint16(35476), + 2945: uint16(35508), + 2946: uint16(35921), + 2947: uint16(36052), + 2948: uint16(36082), + 2949: uint16(36124), + 2950: uint16(18328), + 2951: uint16(22623), + 2952: uint16(36291), + 2953: uint16(18413), + 2954: uint16(20206), + 2955: uint16(36410), + 2956: uint16(21976), + 2957: uint16(22356), + 2958: uint16(36465), + 2959: uint16(22005), + 2960: uint16(36528), + 2961: uint16(18487), + 2962: uint16(36558), + 2963: uint16(36578), + 2964: uint16(36580), + 2965: uint16(36589), + 2966: uint16(36594), + 2967: uint16(36791), + 2968: uint16(36801), + 2969: uint16(36810), + 2970: uint16(36812), + 2971: uint16(36915), + 2972: uint16(39364), + 2973: uint16(18605), + 2974: uint16(39136), + 2975: uint16(37395), + 2976: uint16(18718), + 2977: uint16(37416), + 2978: uint16(37464), + 2979: uint16(37483), + 2980: uint16(37553), + 2981: uint16(37550), + 2982: uint16(37567), + 2983: uint16(37603), + 2984: uint16(37611), + 2985: uint16(37619), + 2986: uint16(37620), + 2987: uint16(37629), + 2988: uint16(37699), + 2989: uint16(37764), + 2990: uint16(37805), + 2991: uint16(18757), + 2992: uint16(18769), + 2993: uint16(40639), + 2994: uint16(37911), + 2995: uint16(21249), + 2996: uint16(37917), + 2997: uint16(37933), + 2998: uint16(37950), + 2999: uint16(18794), + 3000: uint16(37972), + 3001: uint16(38009), + 3002: uint16(38189), + 3003: uint16(38306), + 3004: uint16(18855), + 3005: uint16(38388), + 3006: uint16(38451), + 3007: uint16(18917), + 3008: uint16(26528), + 3009: uint16(18980), + 3010: uint16(38720), + 3011: uint16(18997), + 3012: uint16(38834), + 3013: uint16(38850), + 3014: uint16(22100), + 3015: uint16(19172), + 3016: uint16(24808), + 3017: uint16(39097), + 3018: uint16(19225), + 3019: uint16(39153), + 3020: uint16(22596), + 3021: uint16(39182), + 3022: uint16(39193), + 3023: uint16(20916), + 3024: uint16(39196), + 3025: uint16(39223), + 3026: uint16(39234), + 3027: uint16(39261), + 3028: uint16(39266), + 3029: uint16(19312), + 3030: uint16(39365), + 3031: uint16(19357), + 3032: uint16(39484), + 3033: uint16(39695), + 3034: uint16(31363), + 3035: uint16(39785), + 3036: uint16(39809), + 3037: uint16(39901), + 3038: uint16(39921), + 3039: uint16(39924), + 3040: uint16(19565), + 3041: uint16(39968), + 3042: uint16(14191), + 3043: uint16(7106), + 3044: uint16(40265), + 3045: uint16(39994), + 3046: uint16(40702), + 3047: uint16(22096), + 3048: uint16(40339), + 3049: uint16(40381), + 3050: uint16(40384), + 3051: uint16(40444), + 3052: uint16(38134), + 3053: uint16(36790), + 3054: uint16(40571), + 3055: uint16(40620), + 3056: uint16(40625), + 3057: uint16(40637), + 3058: uint16(40646), + 3059: uint16(38108), + 3060: uint16(40674), + 3061: uint16(40689), + 3062: uint16(40696), + 3063: uint16(31432), + 3064: uint16(40772), + 3065: uint16(148), + 3066: uint16(695), + 3067: uint16(928), + 3068: uint16(26906), + 3069: uint16(38083), + 3070: uint16(22956), + 3071: uint16(1239), + 3072: uint16(22592), + 3073: uint16(38081), + 3074: uint16(14265), + 3075: uint16(1493), + 3076: uint16(1557), + 3077: uint16(1654), + 3078: uint16(5818), + 3079: uint16(22359), + 3080: uint16(29043), + 3081: uint16(2754), + 3082: uint16(2765), + 3083: uint16(3007), + 3084: uint16(21610), + 3085: uint16(63547), + 3086: uint16(3019), + 3087: uint16(21662), + 3088: uint16(3067), + 3089: uint16(3131), + 3090: uint16(3155), + 3091: uint16(3173), + 3092: uint16(3196), + 3093: uint16(24807), + 3094: uint16(3213), + 3095: uint16(22138), + 3096: uint16(3253), + 3097: uint16(3293), + 3098: uint16(3309), + 3099: uint16(3439), + 3100: uint16(3506), + 3101: uint16(3528), + 3102: uint16(26965), + 3103: uint16(39983), + 3104: uint16(34725), + 3105: uint16(3588), + 3106: uint16(3598), + 3107: uint16(3799), + 3108: uint16(3984), + 3109: uint16(3885), + 3110: uint16(3699), + 3111: uint16(23584), + 3112: uint16(4028), + 3113: uint16(24075), + 3114: uint16(4188), + 3115: uint16(4175), + 3116: uint16(4214), + 3117: uint16(26398), + 3118: uint16(4219), + 3119: uint16(4232), + 3120: uint16(4246), + 3121: uint16(13895), + 3122: uint16(4287), + 3123: uint16(4307), + 3124: uint16(4399), + 3125: uint16(4411), + 3126: uint16(21348), + 3127: uint16(33965), + 3128: uint16(4835), + 3129: uint16(4981), + 3130: uint16(4918), + 3131: uint16(35713), + 3132: uint16(5495), + 3133: uint16(5657), + 3134: uint16(6083), + 3135: uint16(6087), + 3136: uint16(20088), + 3137: uint16(28859), + 3138: uint16(6189), + 3139: uint16(6506), + 3140: uint16(6701), + 3141: uint16(6725), + 3142: uint16(7210), + 3143: uint16(7280), + 3144: uint16(7340), + 3145: uint16(7880), + 3146: uint16(25283), + 3147: uint16(7893), + 3148: uint16(7957), + 3149: uint16(29080), + 3150: uint16(26709), + 3151: uint16(8261), + 3152: uint16(27113), + 3153: uint16(14024), + 3154: uint16(8828), + 3155: uint16(9175), + 3156: uint16(9210), + 3157: uint16(10026), + 3158: uint16(10353), + 3159: uint16(10575), + 3160: uint16(33533), + 3161: uint16(10599), + 3162: uint16(10643), + 3163: uint16(10965), + 3164: uint16(35237), + 3165: uint16(10984), + 3166: uint16(36768), + 3167: uint16(11022), + 3168: uint16(38840), + 3169: uint16(11071), + 3170: uint16(38983), + 3171: uint16(39613), + 3172: uint16(11340), + 3174: uint16(11400), + 3175: uint16(11447), + 3176: uint16(23528), + 3177: uint16(11528), + 3178: uint16(11538), + 3179: uint16(11703), + 3180: uint16(11669), + 3181: uint16(11842), + 3182: uint16(12148), + 3183: uint16(12236), + 3184: uint16(12339), + 3185: uint16(12390), + 3186: uint16(13087), + 3187: uint16(13278), + 3188: uint16(24497), + 3189: uint16(26184), + 3190: uint16(26303), + 3191: uint16(31353), + 3192: uint16(13671), + 3193: uint16(13811), + 3195: uint16(18874), + 3197: uint16(13850), + 3198: uint16(14102), + 3200: uint16(838), + 3201: uint16(22709), + 3202: uint16(26382), + 3203: uint16(26904), + 3204: uint16(15015), + 3205: uint16(30295), + 3206: uint16(24546), + 3207: uint16(15889), + 3208: uint16(16057), + 3209: uint16(30206), + 3210: uint16(8346), + 3211: uint16(18640), + 3212: uint16(19128), + 3213: uint16(16665), + 3214: uint16(35482), + 3215: uint16(17134), + 3216: uint16(17165), + 3217: uint16(16443), + 3218: uint16(17204), + 3219: uint16(17302), + 3220: uint16(19013), + 3221: uint16(1482), + 3222: uint16(20946), + 3223: uint16(1553), + 3224: uint16(22943), + 3225: uint16(7848), + 3226: uint16(15294), + 3227: uint16(15615), + 3228: uint16(17412), + 3229: uint16(17622), + 3230: uint16(22408), + 3231: uint16(18036), + 3232: uint16(14747), + 3233: uint16(18223), + 3234: uint16(34280), + 3235: uint16(39369), + 3236: uint16(14178), + 3237: uint16(8643), + 3238: uint16(35678), + 3239: uint16(35662), + 3241: uint16(18450), + 3242: uint16(18683), + 3243: uint16(18965), + 3244: uint16(29193), + 3245: uint16(19136), + 3246: uint16(3192), + 3247: uint16(22885), + 3248: uint16(20133), + 3249: uint16(20358), + 3250: uint16(1913), + 3251: uint16(36570), + 3252: uint16(20524), + 3253: uint16(21135), + 3254: uint16(22335), + 3255: uint16(29041), + 3256: uint16(21145), + 3257: uint16(21529), + 3258: uint16(16202), + 3259: uint16(19111), + 3260: uint16(21948), + 3261: uint16(21574), + 3262: uint16(21614), + 3263: uint16(27474), + 3265: uint16(13427), + 3266: uint16(21823), + 3267: uint16(30258), + 3268: uint16(21854), + 3269: uint16(18200), + 3270: uint16(21858), + 3271: uint16(21862), + 3272: uint16(22471), + 3273: uint16(18751), + 3274: uint16(22621), + 3275: uint16(20582), + 3276: uint16(13563), + 3277: uint16(13260), + 3279: uint16(22787), + 3280: uint16(18300), + 3281: uint16(35144), + 3282: uint16(23214), + 3283: uint16(23433), + 3284: uint16(23558), + 3285: uint16(7568), + 3286: uint16(22433), + 3287: uint16(29009), + 3289: uint16(24834), + 3290: uint16(31762), + 3291: uint16(36950), + 3292: uint16(25010), + 3293: uint16(20378), + 3294: uint16(35682), + 3295: uint16(25602), + 3296: uint16(25674), + 3297: uint16(23899), + 3298: uint16(27639), + 3300: uint16(25732), + 3301: uint16(6428), + 3302: uint16(35562), + 3303: uint16(18934), + 3304: uint16(25736), + 3305: uint16(16367), + 3306: uint16(25874), + 3307: uint16(19392), + 3308: uint16(26047), + 3309: uint16(26293), + 3310: uint16(10011), + 3311: uint16(37989), + 3312: uint16(22497), + 3313: uint16(24981), + 3314: uint16(23079), + 3315: uint16(63693), + 3317: uint16(22201), + 3318: uint16(17697), + 3319: uint16(26364), + 3320: uint16(20074), + 3321: uint16(18740), + 3322: uint16(38486), + 3323: uint16(28047), + 3324: uint16(27837), + 3325: uint16(13848), + 3326: uint16(35191), + 3327: uint16(26521), + 3328: uint16(26734), + 3329: uint16(25617), + 3330: uint16(26718), + 3332: uint16(26823), + 3333: uint16(31554), + 3334: uint16(37056), + 3335: uint16(2577), + 3336: uint16(26918), + 3338: uint16(26937), + 3339: uint16(31301), + 3341: uint16(27130), + 3342: uint16(39462), + 3343: uint16(27181), + 3344: uint16(13919), + 3345: uint16(25705), + 3346: uint16(33), + 3347: uint16(31107), + 3348: uint16(27188), + 3349: uint16(27483), + 3350: uint16(23852), + 3351: uint16(13593), + 3353: uint16(27549), + 3354: uint16(18128), + 3355: uint16(27812), + 3356: uint16(30011), + 3357: uint16(34917), + 3358: uint16(28078), + 3359: uint16(22710), + 3360: uint16(14108), + 3361: uint16(9613), + 3362: uint16(28747), + 3363: uint16(29133), + 3364: uint16(15444), + 3365: uint16(29312), + 3366: uint16(29317), + 3367: uint16(37505), + 3368: uint16(8570), + 3369: uint16(29323), + 3370: uint16(37680), + 3371: uint16(29414), + 3372: uint16(18896), + 3373: uint16(27705), + 3374: uint16(38047), + 3375: uint16(29776), + 3376: uint16(3832), + 3377: uint16(34855), + 3378: uint16(35061), + 3379: uint16(10534), + 3380: uint16(33907), + 3381: uint16(6065), + 3382: uint16(28344), + 3383: uint16(18986), + 3384: uint16(6176), + 3385: uint16(14756), + 3386: uint16(14009), + 3389: uint16(17727), + 3390: uint16(26294), + 3391: uint16(40109), + 3392: uint16(39076), + 3393: uint16(35139), + 3394: uint16(30668), + 3395: uint16(30808), + 3396: uint16(22230), + 3397: uint16(16607), + 3398: uint16(5642), + 3399: uint16(14753), + 3400: uint16(14127), + 3401: uint16(33000), + 3402: uint16(5061), + 3403: uint16(29101), + 3404: uint16(33638), + 3405: uint16(31197), + 3406: uint16(37288), + 3408: uint16(19639), + 3409: uint16(28847), + 3410: uint16(35243), + 3411: uint16(31229), + 3412: uint16(31242), + 3413: uint16(31499), + 3414: uint16(32102), + 3415: uint16(16762), + 3416: uint16(31555), + 3417: uint16(31102), + 3418: uint16(32777), + 3419: uint16(28597), + 3420: uint16(41695), + 3421: uint16(27139), + 3422: uint16(33560), + 3423: uint16(21410), + 3424: uint16(28167), + 3425: uint16(37823), + 3426: uint16(26678), + 3427: uint16(38749), + 3428: uint16(33135), + 3429: uint16(32803), + 3430: uint16(27061), + 3431: uint16(5101), + 3432: uint16(12847), + 3433: uint16(32840), + 3434: uint16(23941), + 3435: uint16(35888), + 3436: uint16(32899), + 3437: uint16(22293), + 3438: uint16(38947), + 3439: uint16(35145), + 3440: uint16(23979), + 3441: uint16(18824), + 3442: uint16(26046), + 3443: uint16(27093), + 3444: uint16(21458), + 3445: uint16(19109), + 3446: uint16(16257), + 3447: uint16(15377), + 3448: uint16(26422), + 3449: uint16(32912), + 3450: uint16(33012), + 3451: uint16(33070), + 3452: uint16(8097), + 3453: uint16(33103), + 3454: uint16(33161), + 3455: uint16(33199), + 3456: uint16(33306), + 3457: uint16(33542), + 3458: uint16(33583), + 3459: uint16(33674), + 3460: uint16(13770), + 3461: uint16(33896), + 3462: uint16(34474), + 3463: uint16(18682), + 3464: uint16(25574), + 3465: uint16(35158), + 3466: uint16(30728), + 3467: uint16(37461), + 3468: uint16(35256), + 3469: uint16(17394), + 3470: uint16(35303), + 3471: uint16(17375), + 3472: uint16(35304), + 3473: uint16(35654), + 3474: uint16(35796), + 3475: uint16(23032), + 3476: uint16(35849), + 3478: uint16(36805), + 3479: uint16(37100), + 3481: uint16(37136), + 3482: uint16(37180), + 3483: uint16(15863), + 3484: uint16(37214), + 3485: uint16(19146), + 3486: uint16(36816), + 3487: uint16(29327), + 3488: uint16(22155), + 3489: uint16(38119), + 3490: uint16(38377), + 3491: uint16(38320), + 3492: uint16(38328), + 3493: uint16(38706), + 3494: uint16(39121), + 3495: uint16(39241), + 3496: uint16(39274), + 3497: uint16(39363), + 3498: uint16(39464), + 3499: uint16(39694), + 3500: uint16(40282), + 3501: uint16(40347), + 3502: uint16(32415), + 3503: uint16(40696), + 3504: uint16(40739), + 3505: uint16(19620), + 3506: uint16(38215), + 3507: uint16(41619), + 3508: uint16(29090), + 3509: uint16(41727), + 3510: uint16(19857), + 3511: uint16(36882), + 3512: uint16(42443), + 3513: uint16(19868), + 3514: uint16(3228), + 3515: uint16(36798), + 3516: uint16(21953), + 3517: uint16(36794), + 3518: uint16(9392), + 3519: uint16(36793), + 3520: uint16(19091), + 3521: uint16(17673), + 3522: uint16(32383), + 3523: uint16(28502), + 3524: uint16(27313), + 3525: uint16(20202), + 3526: uint16(13540), + 3527: uint16(35628), + 3528: uint16(30877), + 3529: uint16(14138), + 3530: uint16(36480), + 3531: uint16(6133), + 3532: uint16(32804), + 3533: uint16(35692), + 3534: uint16(35737), + 3535: uint16(31294), + 3536: uint16(26287), + 3537: uint16(15851), + 3538: uint16(30293), + 3539: uint16(15543), + 3540: uint16(22069), + 3541: uint16(22870), + 3542: uint16(20122), + 3543: uint16(24193), + 3544: uint16(25176), + 3545: uint16(22207), + 3546: uint16(3693), + 3547: uint16(36366), + 3548: uint16(23405), + 3549: uint16(16008), + 3550: uint16(19614), + 3551: uint16(25566), + 3553: uint16(6134), + 3554: uint16(6267), + 3555: uint16(25904), + 3556: uint16(22061), + 3557: uint16(23626), + 3558: uint16(21530), + 3559: uint16(21265), + 3560: uint16(15814), + 3561: uint16(40344), + 3562: uint16(19581), + 3563: uint16(22050), + 3564: uint16(22046), + 3565: uint16(32585), + 3566: uint16(24280), + 3567: uint16(22901), + 3568: uint16(15680), + 3569: uint16(34672), + 3570: uint16(19996), + 3571: uint16(4074), + 3572: uint16(3401), + 3573: uint16(14010), + 3574: uint16(33047), + 3575: uint16(40286), + 3576: uint16(36120), + 3577: uint16(30267), + 3578: uint16(40005), + 3579: uint16(30286), + 3580: uint16(30649), + 3581: uint16(37701), + 3582: uint16(21554), + 3583: uint16(33096), + 3584: uint16(33527), + 3585: uint16(22053), + 3586: uint16(33074), + 3587: uint16(33816), + 3588: uint16(32957), + 3589: uint16(21994), + 3590: uint16(31074), + 3591: uint16(22083), + 3592: uint16(21526), + 3593: uint16(3741), + 3594: uint16(13774), + 3595: uint16(22021), + 3596: uint16(22001), + 3597: uint16(26353), + 3598: uint16(33506), + 3599: uint16(13869), + 3600: uint16(30004), + 3601: uint16(22000), + 3602: uint16(21946), + 3603: uint16(21655), + 3604: uint16(21874), + 3605: uint16(3137), + 3606: uint16(3222), + 3607: uint16(24272), + 3608: uint16(20808), + 3609: uint16(3702), + 3610: uint16(11362), + 3611: uint16(3746), + 3612: uint16(40619), + 3613: uint16(32090), + 3614: uint16(21982), + 3615: uint16(4213), + 3616: uint16(25245), + 3617: uint16(38765), + 3618: uint16(21652), + 3619: uint16(36045), + 3620: uint16(29174), + 3621: uint16(37238), + 3622: uint16(25596), + 3623: uint16(25529), + 3624: uint16(25598), + 3625: uint16(21865), + 3626: uint16(11075), + 3627: uint16(40050), + 3628: uint16(11955), + 3629: uint16(20890), + 3630: uint16(13535), + 3631: uint16(3495), + 3632: uint16(20903), + 3633: uint16(21581), + 3634: uint16(21790), + 3635: uint16(21779), + 3636: uint16(30310), + 3637: uint16(36397), + 3638: uint16(26762), + 3639: uint16(30129), + 3640: uint16(32950), + 3641: uint16(34820), + 3642: uint16(34694), + 3643: uint16(35015), + 3644: uint16(33206), + 3645: uint16(33820), + 3646: uint16(4289), + 3647: uint16(17644), + 3648: uint16(29444), + 3649: uint16(18182), + 3650: uint16(23440), + 3651: uint16(33547), + 3652: uint16(26771), + 3653: uint16(22139), + 3654: uint16(9972), + 3655: uint16(32047), + 3656: uint16(16803), + 3657: uint16(32115), + 3658: uint16(28368), + 3659: uint16(29366), + 3660: uint16(37232), + 3661: uint16(4569), + 3662: uint16(37384), + 3663: uint16(15612), + 3664: uint16(42665), + 3665: uint16(3756), + 3666: uint16(3833), + 3667: uint16(29286), + 3668: uint16(7330), + 3669: uint16(18254), + 3670: uint16(20418), + 3671: uint16(32761), + 3672: uint16(4075), + 3673: uint16(16634), + 3674: uint16(40029), + 3675: uint16(25887), + 3676: uint16(11680), + 3677: uint16(18675), + 3678: uint16(18400), + 3679: uint16(40316), + 3680: uint16(4076), + 3681: uint16(3594), + 3683: uint16(30115), + 3684: uint16(4077), + 3686: uint16(24648), + 3687: uint16(4487), + 3688: uint16(29091), + 3689: uint16(32398), + 3690: uint16(40272), + 3691: uint16(19994), + 3692: uint16(19972), + 3693: uint16(13687), + 3694: uint16(23309), + 3695: uint16(27826), + 3696: uint16(21351), + 3697: uint16(13996), + 3698: uint16(14812), + 3699: uint16(21373), + 3700: uint16(13989), + 3701: uint16(17944), + 3702: uint16(22682), + 3703: uint16(19310), + 3704: uint16(33325), + 3705: uint16(21579), + 3706: uint16(22442), + 3707: uint16(23189), + 3708: uint16(2425), + 3710: uint16(14930), + 3711: uint16(9317), + 3712: uint16(29556), + 3713: uint16(40620), + 3714: uint16(19721), + 3715: uint16(39917), + 3716: uint16(15614), + 3717: uint16(40752), + 3718: uint16(19547), + 3719: uint16(20393), + 3720: uint16(38302), + 3721: uint16(40926), + 3722: uint16(33884), + 3723: uint16(15798), + 3724: uint16(29362), + 3725: uint16(26547), + 3726: uint16(14112), + 3727: uint16(25390), + 3728: uint16(32037), + 3729: uint16(16119), + 3730: uint16(15916), + 3731: uint16(14890), + 3732: uint16(36872), + 3733: uint16(21196), + 3734: uint16(15988), + 3735: uint16(13946), + 3736: uint16(17897), + 3737: uint16(1166), + 3738: uint16(30272), + 3739: uint16(23280), + 3740: uint16(3766), + 3741: uint16(30842), + 3742: uint16(32558), + 3743: uint16(22695), + 3744: uint16(16575), + 3745: uint16(22140), + 3746: uint16(39819), + 3747: uint16(23924), + 3748: uint16(30292), + 3749: uint16(42036), + 3750: uint16(40581), + 3751: uint16(19681), + 3753: uint16(14331), + 3754: uint16(24857), + 3755: uint16(12506), + 3756: uint16(17394), + 3758: uint16(22109), + 3759: uint16(4777), + 3760: uint16(22439), + 3761: uint16(18787), + 3762: uint16(40454), + 3763: uint16(21044), + 3764: uint16(28846), + 3765: uint16(13741), + 3767: uint16(40316), + 3768: uint16(31830), + 3769: uint16(39737), + 3770: uint16(22494), + 3771: uint16(5996), + 3772: uint16(23635), + 3773: uint16(25811), + 3774: uint16(38096), + 3775: uint16(25397), + 3776: uint16(29028), + 3777: uint16(34477), + 3778: uint16(3368), + 3779: uint16(27938), + 3780: uint16(19170), + 3781: uint16(3441), + 3783: uint16(20990), + 3784: uint16(7951), + 3785: uint16(23950), + 3786: uint16(38659), + 3787: uint16(7633), + 3788: uint16(40577), + 3789: uint16(36940), + 3790: uint16(31519), + 3791: uint16(39682), + 3792: uint16(23761), + 3793: uint16(31651), + 3794: uint16(25192), + 3795: uint16(25397), + 3796: uint16(39679), + 3797: uint16(31695), + 3798: uint16(39722), + 3799: uint16(31870), + 3801: uint16(31810), + 3802: uint16(31878), + 3803: uint16(39957), + 3804: uint16(31740), + 3805: uint16(39689), + 3807: uint16(39963), + 3808: uint16(18750), + 3809: uint16(40794), + 3810: uint16(21875), + 3811: uint16(23491), + 3812: uint16(20477), + 3813: uint16(40600), + 3814: uint16(20466), + 3815: uint16(21088), + 3816: uint16(15878), + 3817: uint16(21201), + 3818: uint16(22375), + 3819: uint16(20566), + 3820: uint16(22967), + 3821: uint16(24082), + 3822: uint16(38856), + 3823: uint16(40363), + 3824: uint16(36700), + 3825: uint16(21609), + 3826: uint16(38836), + 3827: uint16(39232), + 3828: uint16(38842), + 3829: uint16(21292), + 3830: uint16(24880), + 3831: uint16(26924), + 3832: uint16(21466), + 3833: uint16(39946), + 3834: uint16(40194), + 3835: uint16(19515), + 3836: uint16(38465), + 3837: uint16(27008), + 3838: uint16(20646), + 3839: uint16(30022), + 3840: uint16(5997), + 3841: uint16(39386), + 3842: uint16(21107), + 3844: uint16(37209), + 3845: uint16(38529), + 3846: uint16(37212), + 3848: uint16(37201), + 3849: uint16(36503), + 3850: uint16(25471), + 3851: uint16(27939), + 3852: uint16(27338), + 3853: uint16(22033), + 3854: uint16(37262), + 3855: uint16(30074), + 3856: uint16(25221), + 3857: uint16(1020), + 3858: uint16(29519), + 3859: uint16(31856), + 3860: uint16(23585), + 3861: uint16(15613), + 3863: uint16(18713), + 3864: uint16(30422), + 3865: uint16(39837), + 3866: uint16(20010), + 3867: uint16(3284), + 3868: uint16(33726), + 3869: uint16(34882), + 3871: uint16(23626), + 3872: uint16(27072), + 3874: uint16(22394), + 3875: uint16(21023), + 3876: uint16(24053), + 3877: uint16(20174), + 3878: uint16(27697), + 3879: uint16(498), + 3880: uint16(20281), + 3881: uint16(21660), + 3882: uint16(21722), + 3883: uint16(21146), + 3884: uint16(36226), + 3885: uint16(13822), + 3887: uint16(13811), + 3889: uint16(27474), + 3890: uint16(37244), + 3891: uint16(40869), + 3892: uint16(39831), + 3893: uint16(38958), + 3894: uint16(39092), + 3895: uint16(39610), + 3896: uint16(40616), + 3897: uint16(40580), + 3898: uint16(29050), + 3899: uint16(31508), + 3901: uint16(27642), + 3902: uint16(34840), + 3903: uint16(32632), + 3905: uint16(22048), + 3906: uint16(42570), + 3907: uint16(36471), + 3908: uint16(40787), + 3910: uint16(36308), + 3911: uint16(36431), + 3912: uint16(40476), + 3913: uint16(36353), + 3914: uint16(25218), + 3915: uint16(33661), + 3916: uint16(36392), + 3917: uint16(36469), + 3918: uint16(31443), + 3919: uint16(19063), + 3920: uint16(31294), + 3921: uint16(30936), + 3922: uint16(27882), + 3923: uint16(35431), + 3924: uint16(30215), + 3925: uint16(35418), + 3926: uint16(40742), + 3927: uint16(27854), + 3928: uint16(34774), + 3929: uint16(30147), + 3930: uint16(41650), + 3931: uint16(30803), + 3932: uint16(63552), + 3933: uint16(36108), + 3934: uint16(29410), + 3935: uint16(29553), + 3936: uint16(35629), + 3937: uint16(29442), + 3938: uint16(29937), + 3939: uint16(36075), + 3940: uint16(19131), + 3941: uint16(34351), + 3942: uint16(24506), + 3943: uint16(34976), + 3944: uint16(17591), + 3946: uint16(6203), + 3947: uint16(28165), + 3949: uint16(35454), + 3950: uint16(9499), + 3952: uint16(24829), + 3953: uint16(30311), + 3954: uint16(39639), + 3955: uint16(40260), + 3956: uint16(37742), + 3957: uint16(39823), + 3958: uint16(34805), + 3961: uint16(36087), + 3962: uint16(29484), + 3963: uint16(38689), + 3964: uint16(39856), + 3965: uint16(13782), + 3966: uint16(29362), + 3967: uint16(19463), + 3968: uint16(31825), + 3969: uint16(39242), + 3970: uint16(24921), + 3971: uint16(24921), + 3972: uint16(19460), + 3973: uint16(40598), + 3974: uint16(24957), + 3976: uint16(22367), + 3977: uint16(24943), + 3978: uint16(25254), + 3979: uint16(25145), + 3981: uint16(14940), + 3982: uint16(25058), + 3983: uint16(21418), + 3984: uint16(13301), + 3985: uint16(25444), + 3986: uint16(26626), + 3987: uint16(13778), + 3988: uint16(23895), + 3989: uint16(35778), + 3990: uint16(36826), + 3991: uint16(36409), + 3993: uint16(20697), + 3994: uint16(7494), + 3995: uint16(30982), + 3996: uint16(21298), + 3997: uint16(38456), + 3998: uint16(3899), + 3999: uint16(16485), + 4001: uint16(30718), + 4003: uint16(31938), + 4004: uint16(24346), + 4005: uint16(31962), + 4006: uint16(31277), + 4007: uint16(32870), + 4008: uint16(32867), + 4009: uint16(32077), + 4010: uint16(29957), + 4011: uint16(29938), + 4012: uint16(35220), + 4013: uint16(33306), + 4014: uint16(26380), + 4015: uint16(32866), + 4016: uint16(29830), + 4017: uint16(32859), + 4018: uint16(29936), + 4019: uint16(33027), + 4020: uint16(30500), + 4021: uint16(35209), + 4022: uint16(26572), + 4023: uint16(30035), + 4024: uint16(28369), + 4025: uint16(34729), + 4026: uint16(34766), + 4027: uint16(33224), + 4028: uint16(34700), + 4029: uint16(35401), + 4030: uint16(36013), + 4031: uint16(35651), + 4032: uint16(30507), + 4033: uint16(29944), + 4034: uint16(34010), + 4035: uint16(13877), + 4036: uint16(27058), + 4037: uint16(36262), + 4039: uint16(35241), + 4041: uint16(28089), + 4042: uint16(34753), + 4043: uint16(16401), + 4044: uint16(29927), + 4045: uint16(15835), + 4046: uint16(29046), + 4047: uint16(24740), + 4048: uint16(24988), + 4049: uint16(15569), + 4051: uint16(24695), + 4053: uint16(32625), + 4054: uint16(35629), + 4056: uint16(24809), + 4057: uint16(19326), + 4058: uint16(21024), + 4059: uint16(15384), + 4060: uint16(15559), + 4061: uint16(24279), + 4062: uint16(30294), + 4063: uint16(21809), + 4064: uint16(6468), + 4065: uint16(4862), + 4066: uint16(39171), + 4067: uint16(28124), + 4068: uint16(28845), + 4069: uint16(23745), + 4070: uint16(25005), + 4071: uint16(35343), + 4072: uint16(13943), + 4073: uint16(238), + 4074: uint16(26694), + 4075: uint16(20238), + 4076: uint16(17762), + 4077: uint16(23327), + 4078: uint16(25420), + 4079: uint16(40784), + 4080: uint16(40614), + 4081: uint16(25195), + 4082: uint16(1351), + 4083: uint16(37595), + 4084: uint16(1503), + 4085: uint16(16325), + 4086: uint16(34124), + 4087: uint16(17077), + 4088: uint16(29679), + 4089: uint16(20917), + 4090: uint16(13897), + 4091: uint16(18754), + 4092: uint16(35300), + 4093: uint16(37700), + 4094: uint16(6619), + 4095: uint16(33518), + 4096: uint16(15560), + 4097: uint16(30780), + 4098: uint16(26436), + 4099: uint16(25311), + 4100: uint16(18739), + 4101: uint16(35242), + 4102: uint16(672), + 4103: uint16(27571), + 4104: uint16(4869), + 4105: uint16(20395), + 4106: uint16(9453), + 4107: uint16(20488), + 4108: uint16(27945), + 4109: uint16(31364), + 4110: uint16(13824), + 4111: uint16(19121), + 4112: uint16(9491), + 4114: uint16(894), + 4115: uint16(24484), + 4116: uint16(896), + 4117: uint16(839), + 4118: uint16(28379), + 4119: uint16(1055), + 4121: uint16(20737), + 4122: uint16(13434), + 4123: uint16(20750), + 4124: uint16(39020), + 4125: uint16(14147), + 4126: uint16(33814), + 4127: uint16(18852), + 4128: uint16(1159), + 4129: uint16(20832), + 4130: uint16(13236), + 4131: uint16(20842), + 4132: uint16(3071), + 4133: uint16(8444), + 4134: uint16(741), + 4135: uint16(9520), + 4136: uint16(1422), + 4137: uint16(12851), + 4138: uint16(6531), + 4139: uint16(23426), + 4140: uint16(34685), + 4141: uint16(1459), + 4142: uint16(15513), + 4143: uint16(20914), + 4144: uint16(20920), + 4145: uint16(40244), + 4146: uint16(20937), + 4147: uint16(20943), + 4148: uint16(20945), + 4149: uint16(15580), + 4150: uint16(20947), + 4151: uint16(19110), + 4152: uint16(20915), + 4153: uint16(20962), + 4154: uint16(21314), + 4155: uint16(20973), + 4156: uint16(33741), + 4157: uint16(26942), + 4158: uint16(14125), + 4159: uint16(24443), + 4160: uint16(21003), + 4161: uint16(21030), + 4162: uint16(21052), + 4163: uint16(21173), + 4164: uint16(21079), + 4165: uint16(21140), + 4166: uint16(21177), + 4167: uint16(21189), + 4168: uint16(31765), + 4169: uint16(34114), + 4170: uint16(21216), + 4171: uint16(34317), + 4172: uint16(27411), + 4174: uint16(35550), + 4175: uint16(21833), + 4176: uint16(28377), + 4177: uint16(16256), + 4178: uint16(2388), + 4179: uint16(16364), + 4180: uint16(21299), + 4182: uint16(3042), + 4183: uint16(27851), + 4184: uint16(5926), + 4185: uint16(26651), + 4186: uint16(29653), + 4187: uint16(24650), + 4188: uint16(16042), + 4189: uint16(14540), + 4190: uint16(5864), + 4191: uint16(29149), + 4192: uint16(17570), + 4193: uint16(21357), + 4194: uint16(21364), + 4195: uint16(34475), + 4196: uint16(21374), + 4198: uint16(5526), + 4199: uint16(5651), + 4200: uint16(30694), + 4201: uint16(21395), + 4202: uint16(35483), + 4203: uint16(21408), + 4204: uint16(21419), + 4205: uint16(21422), + 4206: uint16(29607), + 4207: uint16(22386), + 4208: uint16(16217), + 4209: uint16(29596), + 4210: uint16(21441), + 4211: uint16(21445), + 4212: uint16(27721), + 4213: uint16(20041), + 4214: uint16(22526), + 4215: uint16(21465), + 4216: uint16(15019), + 4217: uint16(2959), + 4218: uint16(21472), + 4219: uint16(16363), + 4220: uint16(11683), + 4221: uint16(21494), + 4222: uint16(3191), + 4223: uint16(21523), + 4224: uint16(28793), + 4225: uint16(21803), + 4226: uint16(26199), + 4227: uint16(27995), + 4228: uint16(21613), + 4229: uint16(27475), + 4230: uint16(3444), + 4231: uint16(21853), + 4232: uint16(21647), + 4233: uint16(21668), + 4234: uint16(18342), + 4235: uint16(5901), + 4236: uint16(3805), + 4237: uint16(15796), + 4238: uint16(3405), + 4239: uint16(35260), + 4240: uint16(9880), + 4241: uint16(21831), + 4242: uint16(19693), + 4243: uint16(21551), + 4244: uint16(29719), + 4245: uint16(21894), + 4246: uint16(21929), + 4248: uint16(6359), + 4249: uint16(16442), + 4250: uint16(17746), + 4251: uint16(17461), + 4252: uint16(26291), + 4253: uint16(4276), + 4254: uint16(22071), + 4255: uint16(26317), + 4256: uint16(12938), + 4257: uint16(26276), + 4258: uint16(26285), + 4259: uint16(22093), + 4260: uint16(22095), + 4261: uint16(30961), + 4262: uint16(22257), + 4263: uint16(38791), + 4264: uint16(21502), + 4265: uint16(22272), + 4266: uint16(22255), + 4267: uint16(22253), + 4268: uint16(35686), + 4269: uint16(13859), + 4270: uint16(4687), + 4271: uint16(22342), + 4272: uint16(16805), + 4273: uint16(27758), + 4274: uint16(28811), + 4275: uint16(22338), + 4276: uint16(14001), + 4277: uint16(27774), + 4278: uint16(22502), + 4279: uint16(5142), + 4280: uint16(22531), + 4281: uint16(5204), + 4282: uint16(17251), + 4283: uint16(22566), + 4284: uint16(19445), + 4285: uint16(22620), + 4286: uint16(22698), + 4287: uint16(13665), + 4288: uint16(22752), + 4289: uint16(22748), + 4290: uint16(4668), + 4291: uint16(22779), + 4292: uint16(23551), + 4293: uint16(22339), + 4294: uint16(41296), + 4295: uint16(17016), + 4296: uint16(37843), + 4297: uint16(13729), + 4298: uint16(22815), + 4299: uint16(26790), + 4300: uint16(14019), + 4301: uint16(28249), + 4302: uint16(5694), + 4303: uint16(23076), + 4304: uint16(21843), + 4305: uint16(5778), + 4306: uint16(34053), + 4307: uint16(22985), + 4308: uint16(3406), + 4309: uint16(27777), + 4310: uint16(27946), + 4311: uint16(6108), + 4312: uint16(23001), + 4313: uint16(6139), + 4314: uint16(6066), + 4315: uint16(28070), + 4316: uint16(28017), + 4317: uint16(6184), + 4318: uint16(5845), + 4319: uint16(23033), + 4320: uint16(28229), + 4321: uint16(23211), + 4322: uint16(23139), + 4323: uint16(14054), + 4324: uint16(18857), + 4326: uint16(14088), + 4327: uint16(23190), + 4328: uint16(29797), + 4329: uint16(23251), + 4330: uint16(28577), + 4331: uint16(9556), + 4332: uint16(15749), + 4333: uint16(6417), + 4334: uint16(14130), + 4335: uint16(5816), + 4336: uint16(24195), + 4337: uint16(21200), + 4338: uint16(23414), + 4339: uint16(25992), + 4340: uint16(23420), + 4341: uint16(31246), + 4342: uint16(16388), + 4343: uint16(18525), + 4344: uint16(516), + 4345: uint16(23509), + 4346: uint16(24928), + 4347: uint16(6708), + 4348: uint16(22988), + 4349: uint16(1445), + 4350: uint16(23539), + 4351: uint16(23453), + 4352: uint16(19728), + 4353: uint16(23557), + 4354: uint16(6980), + 4355: uint16(23571), + 4356: uint16(29646), + 4357: uint16(23572), + 4358: uint16(7333), + 4359: uint16(27432), + 4360: uint16(23625), + 4361: uint16(18653), + 4362: uint16(23685), + 4363: uint16(23785), + 4364: uint16(23791), + 4365: uint16(23947), + 4366: uint16(7673), + 4367: uint16(7735), + 4368: uint16(23824), + 4369: uint16(23832), + 4370: uint16(23878), + 4371: uint16(7844), + 4372: uint16(23738), + 4373: uint16(24023), + 4374: uint16(33532), + 4375: uint16(14381), + 4376: uint16(18689), + 4377: uint16(8265), + 4378: uint16(8563), + 4379: uint16(33415), + 4380: uint16(14390), + 4381: uint16(15298), + 4382: uint16(24110), + 4383: uint16(27274), + 4385: uint16(24186), + 4386: uint16(17596), + 4387: uint16(3283), + 4388: uint16(21414), + 4389: uint16(20151), + 4391: uint16(21416), + 4392: uint16(6001), + 4393: uint16(24073), + 4394: uint16(24308), + 4395: uint16(33922), + 4396: uint16(24313), + 4397: uint16(24315), + 4398: uint16(14496), + 4399: uint16(24316), + 4400: uint16(26686), + 4401: uint16(37915), + 4402: uint16(24333), + 4403: uint16(449), + 4404: uint16(63636), + 4405: uint16(15070), + 4406: uint16(18606), + 4407: uint16(4922), + 4408: uint16(24378), + 4409: uint16(26760), + 4410: uint16(9168), + 4412: uint16(9329), + 4413: uint16(24419), + 4414: uint16(38845), + 4415: uint16(28270), + 4416: uint16(24434), + 4417: uint16(37696), + 4418: uint16(35382), + 4419: uint16(24487), + 4420: uint16(23990), + 4421: uint16(15711), + 4422: uint16(21072), + 4423: uint16(8042), + 4424: uint16(28920), + 4425: uint16(9832), + 4426: uint16(37334), + 4427: uint16(670), + 4428: uint16(35369), + 4429: uint16(24625), + 4430: uint16(26245), + 4431: uint16(6263), + 4432: uint16(14691), + 4433: uint16(15815), + 4434: uint16(13881), + 4435: uint16(22416), + 4436: uint16(10164), + 4437: uint16(31089), + 4438: uint16(15936), + 4439: uint16(24734), + 4441: uint16(24755), + 4442: uint16(18818), + 4443: uint16(18831), + 4444: uint16(31315), + 4445: uint16(29860), + 4446: uint16(20705), + 4447: uint16(23200), + 4448: uint16(24932), + 4449: uint16(33828), + 4450: uint16(24898), + 4451: uint16(63654), + 4452: uint16(28370), + 4453: uint16(24961), + 4454: uint16(20980), + 4455: uint16(1622), + 4456: uint16(24967), + 4457: uint16(23466), + 4458: uint16(16311), + 4459: uint16(10335), + 4460: uint16(25043), + 4461: uint16(35741), + 4462: uint16(39261), + 4463: uint16(25040), + 4464: uint16(14642), + 4465: uint16(10624), + 4466: uint16(10433), + 4467: uint16(24611), + 4468: uint16(24924), + 4469: uint16(25886), + 4470: uint16(25483), + 4471: uint16(280), + 4472: uint16(25285), + 4473: uint16(6000), + 4474: uint16(25301), + 4475: uint16(11789), + 4476: uint16(25452), + 4477: uint16(18911), + 4478: uint16(14871), + 4479: uint16(25656), + 4480: uint16(25592), + 4481: uint16(5006), + 4482: uint16(6140), + 4484: uint16(28554), + 4485: uint16(11830), + 4486: uint16(38932), + 4487: uint16(16524), + 4488: uint16(22301), + 4489: uint16(25825), + 4490: uint16(25829), + 4491: uint16(38011), + 4492: uint16(14950), + 4493: uint16(25658), + 4494: uint16(14935), + 4495: uint16(25933), + 4496: uint16(28438), + 4497: uint16(18984), + 4498: uint16(18979), + 4499: uint16(25989), + 4500: uint16(25965), + 4501: uint16(25951), + 4502: uint16(12414), + 4503: uint16(26037), + 4504: uint16(18752), + 4505: uint16(19255), + 4506: uint16(26065), + 4507: uint16(16600), + 4508: uint16(6185), + 4509: uint16(26080), + 4510: uint16(26083), + 4511: uint16(24543), + 4512: uint16(13312), + 4513: uint16(26136), + 4514: uint16(12791), + 4515: uint16(12792), + 4516: uint16(26180), + 4517: uint16(12708), + 4518: uint16(12709), + 4519: uint16(26187), + 4520: uint16(3701), + 4521: uint16(26215), + 4522: uint16(20966), + 4523: uint16(26227), + 4525: uint16(7741), + 4526: uint16(12849), + 4527: uint16(34292), + 4528: uint16(12744), + 4529: uint16(21267), + 4530: uint16(30661), + 4531: uint16(10487), + 4532: uint16(39332), + 4533: uint16(26370), + 4534: uint16(17308), + 4535: uint16(18977), + 4536: uint16(15147), + 4537: uint16(27130), + 4538: uint16(14274), + 4540: uint16(26471), + 4541: uint16(26466), + 4542: uint16(16845), + 4543: uint16(37101), + 4544: uint16(26583), + 4545: uint16(17641), + 4546: uint16(26658), + 4547: uint16(28240), + 4548: uint16(37436), + 4549: uint16(26625), + 4550: uint16(13286), + 4551: uint16(28064), + 4552: uint16(26717), + 4553: uint16(13423), + 4554: uint16(27105), + 4555: uint16(27147), + 4556: uint16(35551), + 4557: uint16(26995), + 4558: uint16(26819), + 4559: uint16(13773), + 4560: uint16(26881), + 4561: uint16(26880), + 4562: uint16(15666), + 4563: uint16(14849), + 4564: uint16(13884), + 4565: uint16(15232), + 4566: uint16(26540), + 4567: uint16(26977), + 4568: uint16(35402), + 4569: uint16(17148), + 4570: uint16(26934), + 4571: uint16(27032), + 4572: uint16(15265), + 4573: uint16(969), + 4574: uint16(33635), + 4575: uint16(20624), + 4576: uint16(27129), + 4577: uint16(13913), + 4578: uint16(8490), + 4579: uint16(27205), + 4580: uint16(14083), + 4581: uint16(27293), + 4582: uint16(15347), + 4583: uint16(26545), + 4584: uint16(27336), + 4585: uint16(37276), + 4586: uint16(15373), + 4587: uint16(27421), + 4588: uint16(2339), + 4589: uint16(24798), + 4590: uint16(27445), + 4591: uint16(27508), + 4592: uint16(10189), + 4593: uint16(28341), + 4594: uint16(15067), + 4595: uint16(949), + 4596: uint16(6488), + 4597: uint16(14144), + 4598: uint16(21537), + 4599: uint16(15194), + 4600: uint16(27617), + 4601: uint16(16124), + 4602: uint16(27612), + 4603: uint16(27703), + 4604: uint16(9355), + 4605: uint16(18673), + 4606: uint16(27473), + 4607: uint16(27738), + 4608: uint16(33318), + 4609: uint16(27769), + 4610: uint16(15804), + 4611: uint16(17605), + 4612: uint16(15805), + 4613: uint16(16804), + 4614: uint16(18700), + 4615: uint16(18688), + 4616: uint16(15561), + 4617: uint16(14053), + 4618: uint16(15595), + 4619: uint16(3378), + 4620: uint16(39811), + 4621: uint16(12793), + 4622: uint16(9361), + 4623: uint16(32655), + 4624: uint16(26679), + 4625: uint16(27941), + 4626: uint16(28065), + 4627: uint16(28139), + 4628: uint16(28054), + 4629: uint16(27996), + 4630: uint16(28284), + 4631: uint16(28420), + 4632: uint16(18815), + 4633: uint16(16517), + 4634: uint16(28274), + 4635: uint16(34099), + 4636: uint16(28532), + 4637: uint16(20935), + 4640: uint16(33838), + 4641: uint16(35617), + 4643: uint16(15919), + 4644: uint16(29779), + 4645: uint16(16258), + 4646: uint16(31180), + 4647: uint16(28239), + 4648: uint16(23185), + 4649: uint16(12363), + 4650: uint16(28664), + 4651: uint16(14093), + 4652: uint16(28573), + 4653: uint16(15920), + 4654: uint16(28410), + 4655: uint16(5271), + 4656: uint16(16445), + 4657: uint16(17749), + 4658: uint16(37872), + 4659: uint16(28484), + 4660: uint16(28508), + 4661: uint16(15694), + 4662: uint16(28532), + 4663: uint16(37232), + 4664: uint16(15675), + 4665: uint16(28575), + 4666: uint16(16708), + 4667: uint16(28627), + 4668: uint16(16529), + 4669: uint16(16725), + 4670: uint16(16441), + 4671: uint16(16368), + 4672: uint16(16308), + 4673: uint16(16703), + 4674: uint16(20959), + 4675: uint16(16726), + 4676: uint16(16727), + 4677: uint16(16704), + 4678: uint16(25053), + 4679: uint16(28747), + 4680: uint16(28798), + 4681: uint16(28839), + 4682: uint16(28801), + 4683: uint16(28876), + 4684: uint16(28885), + 4685: uint16(28886), + 4686: uint16(28895), + 4687: uint16(16644), + 4688: uint16(15848), + 4689: uint16(29108), + 4690: uint16(29078), + 4691: uint16(17015), + 4692: uint16(28971), + 4693: uint16(28997), + 4694: uint16(23176), + 4695: uint16(29002), + 4697: uint16(23708), + 4698: uint16(17253), + 4699: uint16(29007), + 4700: uint16(37730), + 4701: uint16(17089), + 4702: uint16(28972), + 4703: uint16(17498), + 4704: uint16(18983), + 4705: uint16(18978), + 4706: uint16(29114), + 4707: uint16(35816), + 4708: uint16(28861), + 4709: uint16(29198), + 4710: uint16(37954), + 4711: uint16(29205), + 4712: uint16(22801), + 4713: uint16(37955), + 4714: uint16(29220), + 4715: uint16(37697), + 4716: uint16(22021), + 4717: uint16(29230), + 4718: uint16(29248), + 4719: uint16(18804), + 4720: uint16(26813), + 4721: uint16(29269), + 4722: uint16(29271), + 4723: uint16(15957), + 4724: uint16(12356), + 4725: uint16(26637), + 4726: uint16(28477), + 4727: uint16(29314), + 4729: uint16(29483), + 4730: uint16(18467), + 4731: uint16(34859), + 4732: uint16(18669), + 4733: uint16(34820), + 4734: uint16(29480), + 4735: uint16(29486), + 4736: uint16(29647), + 4737: uint16(29610), + 4738: uint16(3130), + 4739: uint16(27182), + 4740: uint16(29641), + 4741: uint16(29769), + 4742: uint16(16866), + 4743: uint16(5863), + 4744: uint16(18980), + 4745: uint16(26147), + 4746: uint16(14021), + 4747: uint16(18871), + 4748: uint16(18829), + 4749: uint16(18939), + 4750: uint16(29687), + 4751: uint16(29717), + 4752: uint16(26883), + 4753: uint16(18982), + 4754: uint16(29753), + 4755: uint16(1475), + 4756: uint16(16087), + 4758: uint16(10413), + 4759: uint16(29792), + 4760: uint16(36530), + 4761: uint16(29767), + 4762: uint16(29668), + 4763: uint16(29814), + 4764: uint16(33721), + 4765: uint16(29804), + 4766: uint16(14128), + 4767: uint16(29812), + 4768: uint16(37873), + 4769: uint16(27180), + 4770: uint16(29826), + 4771: uint16(18771), + 4772: uint16(19084), + 4773: uint16(16735), + 4774: uint16(19065), + 4775: uint16(35727), + 4776: uint16(23366), + 4777: uint16(35843), + 4778: uint16(6302), + 4779: uint16(29896), + 4780: uint16(6536), + 4781: uint16(29966), + 4783: uint16(29982), + 4784: uint16(36569), + 4785: uint16(6731), + 4786: uint16(23511), + 4787: uint16(36524), + 4788: uint16(37765), + 4789: uint16(30029), + 4790: uint16(30026), + 4791: uint16(30055), + 4792: uint16(30062), + 4793: uint16(20354), + 4794: uint16(16132), + 4795: uint16(19731), + 4796: uint16(30094), + 4797: uint16(29789), + 4798: uint16(30110), + 4799: uint16(30132), + 4800: uint16(30210), + 4801: uint16(30252), + 4802: uint16(30289), + 4803: uint16(30287), + 4804: uint16(30319), + 4805: uint16(30326), + 4806: uint16(25589), + 4807: uint16(30352), + 4808: uint16(33263), + 4809: uint16(14328), + 4810: uint16(26897), + 4811: uint16(26894), + 4812: uint16(30369), + 4813: uint16(30373), + 4814: uint16(30391), + 4815: uint16(30412), + 4816: uint16(28575), + 4817: uint16(33890), + 4818: uint16(20637), + 4819: uint16(20861), + 4820: uint16(7708), + 4821: uint16(30494), + 4822: uint16(30502), + 4823: uint16(30528), + 4824: uint16(25775), + 4825: uint16(21024), + 4826: uint16(30552), + 4827: uint16(12972), + 4828: uint16(30639), + 4829: uint16(35172), + 4830: uint16(35176), + 4831: uint16(5825), + 4832: uint16(30708), + 4834: uint16(4982), + 4835: uint16(18962), + 4836: uint16(26826), + 4837: uint16(30895), + 4838: uint16(30919), + 4839: uint16(30931), + 4840: uint16(38565), + 4841: uint16(31022), + 4842: uint16(21984), + 4843: uint16(30935), + 4844: uint16(31028), + 4845: uint16(30897), + 4846: uint16(30220), + 4847: uint16(36792), + 4848: uint16(34948), + 4849: uint16(35627), + 4850: uint16(24707), + 4851: uint16(9756), + 4852: uint16(31110), + 4853: uint16(35072), + 4854: uint16(26882), + 4855: uint16(31104), + 4856: uint16(22615), + 4857: uint16(31133), + 4858: uint16(31545), + 4859: uint16(31036), + 4860: uint16(31145), + 4861: uint16(28202), + 4862: uint16(28966), + 4863: uint16(16040), + 4864: uint16(31174), + 4865: uint16(37133), + 4866: uint16(31188), + 4867: uint16(1312), + 4868: uint16(17503), + 4869: uint16(21007), + 4870: uint16(47234), + 4871: uint16(248), + 4872: uint16(16384), + 4873: uint16(43296), + 4874: uint16(1102), + 4877: uint16(2868), + 4878: uint16(1), + 4886: uint16(3072), + 4887: uint16(64), + 4891: uint16(1024), + 4892: uint16(88), + 4893: uint16(60), + 4896: uint16(23680), + 4897: uint16(56493), + 4898: uint16(48115), + 4899: uint16(17353), + 4900: uint16(60910), + 4901: uint16(4004), + 4902: uint16(49446), + 4903: uint16(30363), + 4904: uint16(61426), + 4905: uint16(64478), + 4906: uint16(63482), + 4907: uint16(12815), + 4908: uint16(44868), + 4909: uint16(61438), + 4910: uint16(65277), + 4911: uint16(24593), + 4912: uint16(176), + 4913: uint16(8448), + 4914: uint16(33049), + 4915: uint16(4128), + 4916: uint16(43144), + 4917: uint16(8544), + 4918: uint16(9321), + 4919: uint16(17408), + 4920: uint16(50313), + 4922: uint16(16387), + 4923: uint16(53), + 4924: uint16(33859), + 4925: uint16(20785), + 4926: uint16(26771), + 4927: uint16(514), + 4933: uint16(16384), + 4934: uint16(256), + 4935: uint16(44160), + 4936: uint16(33380), + 4937: uint16(35904), + 4938: uint16(37025), + 4939: uint16(20484), + 4940: uint16(54368), + 4941: uint16(53760), + 4942: uint16(6186), + 4943: uint16(26781), + 4944: uint16(38709), + 4945: uint16(55375), + 4946: uint16(8440), + 4947: uint16(33476), + 4948: uint16(10268), + 4949: uint16(30082), + 4950: uint16(660), + 4951: uint16(16440), + 4952: uint16(41376), + 4953: uint16(4293), + 4954: uint16(19825), + 4955: uint16(3524), + 4956: uint16(47512), + 4957: uint16(23390), + 4958: uint16(17153), + 4959: uint16(39327), + 4960: uint16(30723), + 4961: uint16(57888), + 4962: uint16(2079), + 4963: uint16(393), + 4964: uint16(16585), + 4965: uint16(775), + 4966: uint16(39437), + 4967: uint16(21136), + 4968: uint16(20433), + 4969: uint16(892), + 4970: uint16(8450), + 4971: uint16(49184), + 4972: uint16(4974), + 4973: uint16(46467), + 4974: uint16(62939), + 4975: uint16(30693), + 4976: uint16(20368), + 4977: uint16(39447), + 4978: uint16(5942), + 4979: uint16(12), + 4980: uint16(47726), + 4981: uint16(12041), + 4982: uint16(21600), + 4983: uint16(7680), + 4984: uint16(26744), + 4985: uint16(28706), + 4986: uint16(40534), + 4987: uint16(62245), + 4988: uint16(46990), + 4989: uint16(2839), + 4990: uint16(59119), + 4991: uint16(6007), + 4992: uint16(7003), + 4993: uint16(4289), + 4994: uint16(36248), + 4995: uint16(6162), + 4996: uint16(53174), + 4997: uint16(12545), + 4998: uint16(6770), + 4999: uint16(11355), + 5000: uint16(49334), + 5001: uint16(57888), + 5002: uint16(23747), + 5003: uint16(7042), + 5004: uint16(56032), + 5005: uint16(34254), + 5006: uint16(16598), + 5007: uint16(21673), + 5008: uint16(53259), + 5009: uint16(18447), + 5010: uint16(16452), + 5011: uint16(2320), + 5012: uint16(16596), + 5013: uint16(15278), + 5014: uint16(7780), + 5015: uint16(11076), + 5016: uint16(2071), + 5017: uint16(33414), + 5018: uint16(6198), + 5019: uint16(35232), + 5020: uint16(40167), + 5021: uint16(2139), + 5022: uint16(900), + 5023: uint16(55810), + 5024: uint16(60560), + 5025: uint16(34779), + 5026: uint16(49029), + 5027: uint16(44450), + 5028: uint16(36509), + 5029: uint16(39069), + 5030: uint16(9504), + 5031: uint16(70), + 5032: uint16(40774), + 5033: uint16(58239), + 5034: uint16(51669), + 5035: uint16(62596), + 5036: uint16(19926), + 5037: uint16(58118), + 5038: uint16(6326), + 5039: uint16(2322), + 5041: uint16(1024), + 5043: uint16(32), + 5045: uint16(512), + 5050: uint16(8192), + 5057: uint16(8), + 5058: uint16(36352), + 5059: uint16(28280), + 5060: uint16(16223), + 5061: uint16(56702), + 5062: uint16(63293), + 5063: uint16(39932), + 5064: uint16(44796), + 5065: uint16(65490), + 5066: uint16(27535), + 5067: uint16(59377), + 5068: uint16(47807), + 5069: uint16(28334), + 5070: uint16(61207), + 5071: uint16(42972), + 5072: uint16(46654), + 5073: uint16(30645), + 5074: uint16(37577), + 5075: uint16(42455), + 5076: uint16(19126), + 5077: uint16(39790), + 5078: uint16(33209), + 5079: uint16(26445), + 5080: uint16(21758), + 5081: uint16(39921), + 5082: uint16(65122), + 5083: uint16(21103), + 5084: uint16(14039), + 5085: uint16(49150), + 5086: uint16(17705), + 5087: uint16(63873), + 5088: uint16(26045), + 5089: uint16(17062), + 5090: uint16(57), + 5091: uint16(16896), + 5092: uint16(36704), + 5093: uint16(37888), + 5094: uint16(16448), + 5095: uint16(45010), + 5096: uint16(53719), + 5097: uint16(219), + 5098: uint16(39072), + 5099: uint16(31666), + 5100: uint16(20998), + 5101: uint16(38944), + 5102: uint16(51222), + 5103: uint16(2365), + 5105: uint16(1), + 5107: uint16(2561), + 5108: uint16(2226), + 5109: uint16(128), + 5111: uint16(34820), + 5112: uint16(5152), + 5113: uint16(19472), + 5115: uint16(4), + 5116: uint16(17569), + 5117: uint16(16), + 5118: uint16(321), + 5119: uint16(2048), + 5120: uint16(61504), + 5121: uint16(20447), + 5122: uint16(22582), + 5123: uint16(62961), + 5124: uint16(32949), + 5125: uint16(26613), + 5126: uint16(16512), + 5127: uint16(20480), + 5128: uint16(16718), + 5129: uint16(33992), + 5130: uint16(23040), + 5131: uint16(55392), + 5132: uint16(11009), + 5133: uint16(20481), + 5134: uint16(5793), + 5135: uint16(16580), + 5136: uint16(28402), + 5137: uint16(44049), + 5138: uint16(14624), + 5139: uint16(49348), + 5140: uint16(1800), + 5141: uint16(2316), + 5142: uint16(38552), + 5143: uint16(39876), + 5144: uint16(7184), + 5145: uint16(27800), + 5146: uint16(10886), + 5147: uint16(422), + 5148: uint16(4422), + 5149: uint16(58733), + 5150: uint16(50379), + 5151: uint16(37568), + 5152: uint16(8464), + 5153: uint16(4630), + 5154: uint16(29341), + 5155: uint16(27124), + 5156: uint16(5902), + 5157: uint16(41514), + 5158: uint16(62593), + 5159: uint16(123), + 5160: uint16(41992), + 5161: uint16(36875), + 5162: uint16(11280), + 5163: uint16(14796), + 5164: uint16(330), + 5165: uint16(5872), + 5166: uint16(2571), + 5167: uint16(3136), + 5168: uint16(59933), + 5169: uint16(17420), + 5170: uint16(17678), + 5171: uint16(2), +} + +var _ksc = [93][94]uint16{ + 0: { + 0: uint16(12288), + 1: uint16(12289), + 2: uint16(12290), + 3: uint16(183), + 4: uint16(8229), + 5: uint16(8230), + 6: uint16(168), + 7: uint16(12291), + 8: uint16(173), + 9: uint16(8213), + 10: uint16(8741), + 11: uint16(65340), + 12: uint16(8764), + 13: uint16(8216), + 14: uint16(8217), + 15: uint16(8220), + 16: uint16(8221), + 17: uint16(12308), + 18: uint16(12309), + 19: uint16(12296), + 20: uint16(12297), + 21: uint16(12298), + 22: uint16(12299), + 23: uint16(12300), + 24: uint16(12301), + 25: uint16(12302), + 26: uint16(12303), + 27: uint16(12304), + 28: uint16(12305), + 29: uint16(177), + 30: uint16(215), + 31: uint16(247), + 32: uint16(8800), + 33: uint16(8804), + 34: uint16(8805), + 35: uint16(8734), + 36: uint16(8756), + 37: uint16(176), + 38: uint16(8242), + 39: uint16(8243), + 40: uint16(8451), + 41: uint16(8491), + 42: uint16(65504), + 43: uint16(65505), + 44: uint16(65509), + 45: uint16(9794), + 46: uint16(9792), + 47: uint16(8736), + 48: uint16(8869), + 49: uint16(8978), + 50: uint16(8706), + 51: uint16(8711), + 52: uint16(8801), + 53: uint16(8786), + 54: uint16(167), + 55: uint16(8251), + 56: uint16(9734), + 57: uint16(9733), + 58: uint16(9675), + 59: uint16(9679), + 60: uint16(9678), + 61: uint16(9671), + 62: uint16(9670), + 63: uint16(9633), + 64: uint16(9632), + 65: uint16(9651), + 66: uint16(9650), + 67: uint16(9661), + 68: uint16(9660), + 69: uint16(8594), + 70: uint16(8592), + 71: uint16(8593), + 72: uint16(8595), + 73: uint16(8596), + 74: uint16(12307), + 75: uint16(8810), + 76: uint16(8811), + 77: uint16(8730), + 78: uint16(8765), + 79: uint16(8733), + 80: uint16(8757), + 81: uint16(8747), + 82: uint16(8748), + 83: uint16(8712), + 84: uint16(8715), + 85: uint16(8838), + 86: uint16(8839), + 87: uint16(8834), + 88: uint16(8835), + 89: uint16(8746), + 90: uint16(8745), + 91: uint16(8743), + 92: uint16(8744), + 93: uint16(65506), + }, + 1: { + 0: uint16(8658), + 1: uint16(8660), + 2: uint16(8704), + 3: uint16(8707), + 4: uint16(180), + 5: uint16(65374), + 6: uint16(711), + 7: uint16(728), + 8: uint16(733), + 9: uint16(730), + 10: uint16(729), + 11: uint16(184), + 12: uint16(731), + 13: uint16(161), + 14: uint16(191), + 15: uint16(720), + 16: uint16(8750), + 17: uint16(8721), + 18: uint16(8719), + 19: uint16(164), + 20: uint16(8457), + 21: uint16(8240), + 22: uint16(9665), + 23: uint16(9664), + 24: uint16(9655), + 25: uint16(9654), + 26: uint16(9828), + 27: uint16(9824), + 28: uint16(9825), + 29: uint16(9829), + 30: uint16(9831), + 31: uint16(9827), + 32: uint16(8857), + 33: uint16(9672), + 34: uint16(9635), + 35: uint16(9680), + 36: uint16(9681), + 37: uint16(9618), + 38: uint16(9636), + 39: uint16(9637), + 40: uint16(9640), + 41: uint16(9639), + 42: uint16(9638), + 43: uint16(9641), + 44: uint16(9832), + 45: uint16(9743), + 46: uint16(9742), + 47: uint16(9756), + 48: uint16(9758), + 49: uint16(182), + 50: uint16(8224), + 51: uint16(8225), + 52: uint16(8597), + 53: uint16(8599), + 54: uint16(8601), + 55: uint16(8598), + 56: uint16(8600), + 57: uint16(9837), + 58: uint16(9833), + 59: uint16(9834), + 60: uint16(9836), + 61: uint16(12927), + 62: uint16(12828), + 63: uint16(8470), + 64: uint16(13255), + 65: uint16(8482), + 66: uint16(13250), + 67: uint16(13272), + 68: uint16(8481), + 69: uint16(8364), + 70: uint16(174), + }, + 2: { + 0: uint16(65281), + 1: uint16(65282), + 2: uint16(65283), + 3: uint16(65284), + 4: uint16(65285), + 5: uint16(65286), + 6: uint16(65287), + 7: uint16(65288), + 8: uint16(65289), + 9: uint16(65290), + 10: uint16(65291), + 11: uint16(65292), + 12: uint16(65293), + 13: uint16(65294), + 14: uint16(65295), + 15: uint16(65296), + 16: uint16(65297), + 17: uint16(65298), + 18: uint16(65299), + 19: uint16(65300), + 20: uint16(65301), + 21: uint16(65302), + 22: uint16(65303), + 23: uint16(65304), + 24: uint16(65305), + 25: uint16(65306), + 26: uint16(65307), + 27: uint16(65308), + 28: uint16(65309), + 29: uint16(65310), + 30: uint16(65311), + 31: uint16(65312), + 32: uint16(65313), + 33: uint16(65314), + 34: uint16(65315), + 35: uint16(65316), + 36: uint16(65317), + 37: uint16(65318), + 38: uint16(65319), + 39: uint16(65320), + 40: uint16(65321), + 41: uint16(65322), + 42: uint16(65323), + 43: uint16(65324), + 44: uint16(65325), + 45: uint16(65326), + 46: uint16(65327), + 47: uint16(65328), + 48: uint16(65329), + 49: uint16(65330), + 50: uint16(65331), + 51: uint16(65332), + 52: uint16(65333), + 53: uint16(65334), + 54: uint16(65335), + 55: uint16(65336), + 56: uint16(65337), + 57: uint16(65338), + 58: uint16(65339), + 59: uint16(65510), + 60: uint16(65341), + 61: uint16(65342), + 62: uint16(65343), + 63: uint16(65344), + 64: uint16(65345), + 65: uint16(65346), + 66: uint16(65347), + 67: uint16(65348), + 68: uint16(65349), + 69: uint16(65350), + 70: uint16(65351), + 71: uint16(65352), + 72: uint16(65353), + 73: uint16(65354), + 74: uint16(65355), + 75: uint16(65356), + 76: uint16(65357), + 77: uint16(65358), + 78: uint16(65359), + 79: uint16(65360), + 80: uint16(65361), + 81: uint16(65362), + 82: uint16(65363), + 83: uint16(65364), + 84: uint16(65365), + 85: uint16(65366), + 86: uint16(65367), + 87: uint16(65368), + 88: uint16(65369), + 89: uint16(65370), + 90: uint16(65371), + 91: uint16(65372), + 92: uint16(65373), + 93: uint16(65507), + }, + 3: { + 0: uint16(12593), + 1: uint16(12594), + 2: uint16(12595), + 3: uint16(12596), + 4: uint16(12597), + 5: uint16(12598), + 6: uint16(12599), + 7: uint16(12600), + 8: uint16(12601), + 9: uint16(12602), + 10: uint16(12603), + 11: uint16(12604), + 12: uint16(12605), + 13: uint16(12606), + 14: uint16(12607), + 15: uint16(12608), + 16: uint16(12609), + 17: uint16(12610), + 18: uint16(12611), + 19: uint16(12612), + 20: uint16(12613), + 21: uint16(12614), + 22: uint16(12615), + 23: uint16(12616), + 24: uint16(12617), + 25: uint16(12618), + 26: uint16(12619), + 27: uint16(12620), + 28: uint16(12621), + 29: uint16(12622), + 30: uint16(12623), + 31: uint16(12624), + 32: uint16(12625), + 33: uint16(12626), + 34: uint16(12627), + 35: uint16(12628), + 36: uint16(12629), + 37: uint16(12630), + 38: uint16(12631), + 39: uint16(12632), + 40: uint16(12633), + 41: uint16(12634), + 42: uint16(12635), + 43: uint16(12636), + 44: uint16(12637), + 45: uint16(12638), + 46: uint16(12639), + 47: uint16(12640), + 48: uint16(12641), + 49: uint16(12642), + 50: uint16(12643), + 51: uint16(12644), + 52: uint16(12645), + 53: uint16(12646), + 54: uint16(12647), + 55: uint16(12648), + 56: uint16(12649), + 57: uint16(12650), + 58: uint16(12651), + 59: uint16(12652), + 60: uint16(12653), + 61: uint16(12654), + 62: uint16(12655), + 63: uint16(12656), + 64: uint16(12657), + 65: uint16(12658), + 66: uint16(12659), + 67: uint16(12660), + 68: uint16(12661), + 69: uint16(12662), + 70: uint16(12663), + 71: uint16(12664), + 72: uint16(12665), + 73: uint16(12666), + 74: uint16(12667), + 75: uint16(12668), + 76: uint16(12669), + 77: uint16(12670), + 78: uint16(12671), + 79: uint16(12672), + 80: uint16(12673), + 81: uint16(12674), + 82: uint16(12675), + 83: uint16(12676), + 84: uint16(12677), + 85: uint16(12678), + 86: uint16(12679), + 87: uint16(12680), + 88: uint16(12681), + 89: uint16(12682), + 90: uint16(12683), + 91: uint16(12684), + 92: uint16(12685), + 93: uint16(12686), + }, + 4: { + 0: uint16(8560), + 1: uint16(8561), + 2: uint16(8562), + 3: uint16(8563), + 4: uint16(8564), + 5: uint16(8565), + 6: uint16(8566), + 7: uint16(8567), + 8: uint16(8568), + 9: uint16(8569), + 15: uint16(8544), + 16: uint16(8545), + 17: uint16(8546), + 18: uint16(8547), + 19: uint16(8548), + 20: uint16(8549), + 21: uint16(8550), + 22: uint16(8551), + 23: uint16(8552), + 24: uint16(8553), + 32: uint16(913), + 33: uint16(914), + 34: uint16(915), + 35: uint16(916), + 36: uint16(917), + 37: uint16(918), + 38: uint16(919), + 39: uint16(920), + 40: uint16(921), + 41: uint16(922), + 42: uint16(923), + 43: uint16(924), + 44: uint16(925), + 45: uint16(926), + 46: uint16(927), + 47: uint16(928), + 48: uint16(929), + 49: uint16(931), + 50: uint16(932), + 51: uint16(933), + 52: uint16(934), + 53: uint16(935), + 54: uint16(936), + 55: uint16(937), + 64: uint16(945), + 65: uint16(946), + 66: uint16(947), + 67: uint16(948), + 68: uint16(949), + 69: uint16(950), + 70: uint16(951), + 71: uint16(952), + 72: uint16(953), + 73: uint16(954), + 74: uint16(955), + 75: uint16(956), + 76: uint16(957), + 77: uint16(958), + 78: uint16(959), + 79: uint16(960), + 80: uint16(961), + 81: uint16(963), + 82: uint16(964), + 83: uint16(965), + 84: uint16(966), + 85: uint16(967), + 86: uint16(968), + 87: uint16(969), + }, + 5: { + 0: uint16(9472), + 1: uint16(9474), + 2: uint16(9484), + 3: uint16(9488), + 4: uint16(9496), + 5: uint16(9492), + 6: uint16(9500), + 7: uint16(9516), + 8: uint16(9508), + 9: uint16(9524), + 10: uint16(9532), + 11: uint16(9473), + 12: uint16(9475), + 13: uint16(9487), + 14: uint16(9491), + 15: uint16(9499), + 16: uint16(9495), + 17: uint16(9507), + 18: uint16(9523), + 19: uint16(9515), + 20: uint16(9531), + 21: uint16(9547), + 22: uint16(9504), + 23: uint16(9519), + 24: uint16(9512), + 25: uint16(9527), + 26: uint16(9535), + 27: uint16(9501), + 28: uint16(9520), + 29: uint16(9509), + 30: uint16(9528), + 31: uint16(9538), + 32: uint16(9490), + 33: uint16(9489), + 34: uint16(9498), + 35: uint16(9497), + 36: uint16(9494), + 37: uint16(9493), + 38: uint16(9486), + 39: uint16(9485), + 40: uint16(9502), + 41: uint16(9503), + 42: uint16(9505), + 43: uint16(9506), + 44: uint16(9510), + 45: uint16(9511), + 46: uint16(9513), + 47: uint16(9514), + 48: uint16(9517), + 49: uint16(9518), + 50: uint16(9521), + 51: uint16(9522), + 52: uint16(9525), + 53: uint16(9526), + 54: uint16(9529), + 55: uint16(9530), + 56: uint16(9533), + 57: uint16(9534), + 58: uint16(9536), + 59: uint16(9537), + 60: uint16(9539), + 61: uint16(9540), + 62: uint16(9541), + 63: uint16(9542), + 64: uint16(9543), + 65: uint16(9544), + 66: uint16(9545), + 67: uint16(9546), + }, + 6: { + 0: uint16(13205), + 1: uint16(13206), + 2: uint16(13207), + 3: uint16(8467), + 4: uint16(13208), + 5: uint16(13252), + 6: uint16(13219), + 7: uint16(13220), + 8: uint16(13221), + 9: uint16(13222), + 10: uint16(13209), + 11: uint16(13210), + 12: uint16(13211), + 13: uint16(13212), + 14: uint16(13213), + 15: uint16(13214), + 16: uint16(13215), + 17: uint16(13216), + 18: uint16(13217), + 19: uint16(13218), + 20: uint16(13258), + 21: uint16(13197), + 22: uint16(13198), + 23: uint16(13199), + 24: uint16(13263), + 25: uint16(13192), + 26: uint16(13193), + 27: uint16(13256), + 28: uint16(13223), + 29: uint16(13224), + 30: uint16(13232), + 31: uint16(13233), + 32: uint16(13234), + 33: uint16(13235), + 34: uint16(13236), + 35: uint16(13237), + 36: uint16(13238), + 37: uint16(13239), + 38: uint16(13240), + 39: uint16(13241), + 40: uint16(13184), + 41: uint16(13185), + 42: uint16(13186), + 43: uint16(13187), + 44: uint16(13188), + 45: uint16(13242), + 46: uint16(13243), + 47: uint16(13244), + 48: uint16(13245), + 49: uint16(13246), + 50: uint16(13247), + 51: uint16(13200), + 52: uint16(13201), + 53: uint16(13202), + 54: uint16(13203), + 55: uint16(13204), + 56: uint16(8486), + 57: uint16(13248), + 58: uint16(13249), + 59: uint16(13194), + 60: uint16(13195), + 61: uint16(13196), + 62: uint16(13270), + 63: uint16(13253), + 64: uint16(13229), + 65: uint16(13230), + 66: uint16(13231), + 67: uint16(13275), + 68: uint16(13225), + 69: uint16(13226), + 70: uint16(13227), + 71: uint16(13228), + 72: uint16(13277), + 73: uint16(13264), + 74: uint16(13267), + 75: uint16(13251), + 76: uint16(13257), + 77: uint16(13276), + 78: uint16(13254), + }, + 7: { + 0: uint16(198), + 1: uint16(208), + 2: uint16(170), + 3: uint16(294), + 5: uint16(306), + 7: uint16(319), + 8: uint16(321), + 9: uint16(216), + 10: uint16(338), + 11: uint16(186), + 12: uint16(222), + 13: uint16(358), + 14: uint16(330), + 16: uint16(12896), + 17: uint16(12897), + 18: uint16(12898), + 19: uint16(12899), + 20: uint16(12900), + 21: uint16(12901), + 22: uint16(12902), + 23: uint16(12903), + 24: uint16(12904), + 25: uint16(12905), + 26: uint16(12906), + 27: uint16(12907), + 28: uint16(12908), + 29: uint16(12909), + 30: uint16(12910), + 31: uint16(12911), + 32: uint16(12912), + 33: uint16(12913), + 34: uint16(12914), + 35: uint16(12915), + 36: uint16(12916), + 37: uint16(12917), + 38: uint16(12918), + 39: uint16(12919), + 40: uint16(12920), + 41: uint16(12921), + 42: uint16(12922), + 43: uint16(12923), + 44: uint16(9424), + 45: uint16(9425), + 46: uint16(9426), + 47: uint16(9427), + 48: uint16(9428), + 49: uint16(9429), + 50: uint16(9430), + 51: uint16(9431), + 52: uint16(9432), + 53: uint16(9433), + 54: uint16(9434), + 55: uint16(9435), + 56: uint16(9436), + 57: uint16(9437), + 58: uint16(9438), + 59: uint16(9439), + 60: uint16(9440), + 61: uint16(9441), + 62: uint16(9442), + 63: uint16(9443), + 64: uint16(9444), + 65: uint16(9445), + 66: uint16(9446), + 67: uint16(9447), + 68: uint16(9448), + 69: uint16(9449), + 70: uint16(9312), + 71: uint16(9313), + 72: uint16(9314), + 73: uint16(9315), + 74: uint16(9316), + 75: uint16(9317), + 76: uint16(9318), + 77: uint16(9319), + 78: uint16(9320), + 79: uint16(9321), + 80: uint16(9322), + 81: uint16(9323), + 82: uint16(9324), + 83: uint16(9325), + 84: uint16(9326), + 85: uint16(189), + 86: uint16(8531), + 87: uint16(8532), + 88: uint16(188), + 89: uint16(190), + 90: uint16(8539), + 91: uint16(8540), + 92: uint16(8541), + 93: uint16(8542), + }, + 8: { + 0: uint16(230), + 1: uint16(273), + 2: uint16(240), + 3: uint16(295), + 4: uint16(305), + 5: uint16(307), + 6: uint16(312), + 7: uint16(320), + 8: uint16(322), + 9: uint16(248), + 10: uint16(339), + 11: uint16(223), + 12: uint16(254), + 13: uint16(359), + 14: uint16(331), + 15: uint16(329), + 16: uint16(12800), + 17: uint16(12801), + 18: uint16(12802), + 19: uint16(12803), + 20: uint16(12804), + 21: uint16(12805), + 22: uint16(12806), + 23: uint16(12807), + 24: uint16(12808), + 25: uint16(12809), + 26: uint16(12810), + 27: uint16(12811), + 28: uint16(12812), + 29: uint16(12813), + 30: uint16(12814), + 31: uint16(12815), + 32: uint16(12816), + 33: uint16(12817), + 34: uint16(12818), + 35: uint16(12819), + 36: uint16(12820), + 37: uint16(12821), + 38: uint16(12822), + 39: uint16(12823), + 40: uint16(12824), + 41: uint16(12825), + 42: uint16(12826), + 43: uint16(12827), + 44: uint16(9372), + 45: uint16(9373), + 46: uint16(9374), + 47: uint16(9375), + 48: uint16(9376), + 49: uint16(9377), + 50: uint16(9378), + 51: uint16(9379), + 52: uint16(9380), + 53: uint16(9381), + 54: uint16(9382), + 55: uint16(9383), + 56: uint16(9384), + 57: uint16(9385), + 58: uint16(9386), + 59: uint16(9387), + 60: uint16(9388), + 61: uint16(9389), + 62: uint16(9390), + 63: uint16(9391), + 64: uint16(9392), + 65: uint16(9393), + 66: uint16(9394), + 67: uint16(9395), + 68: uint16(9396), + 69: uint16(9397), + 70: uint16(9332), + 71: uint16(9333), + 72: uint16(9334), + 73: uint16(9335), + 74: uint16(9336), + 75: uint16(9337), + 76: uint16(9338), + 77: uint16(9339), + 78: uint16(9340), + 79: uint16(9341), + 80: uint16(9342), + 81: uint16(9343), + 82: uint16(9344), + 83: uint16(9345), + 84: uint16(9346), + 85: uint16(185), + 86: uint16(178), + 87: uint16(179), + 88: uint16(8308), + 89: uint16(8319), + 90: uint16(8321), + 91: uint16(8322), + 92: uint16(8323), + 93: uint16(8324), + }, + 9: { + 0: uint16(12353), + 1: uint16(12354), + 2: uint16(12355), + 3: uint16(12356), + 4: uint16(12357), + 5: uint16(12358), + 6: uint16(12359), + 7: uint16(12360), + 8: uint16(12361), + 9: uint16(12362), + 10: uint16(12363), + 11: uint16(12364), + 12: uint16(12365), + 13: uint16(12366), + 14: uint16(12367), + 15: uint16(12368), + 16: uint16(12369), + 17: uint16(12370), + 18: uint16(12371), + 19: uint16(12372), + 20: uint16(12373), + 21: uint16(12374), + 22: uint16(12375), + 23: uint16(12376), + 24: uint16(12377), + 25: uint16(12378), + 26: uint16(12379), + 27: uint16(12380), + 28: uint16(12381), + 29: uint16(12382), + 30: uint16(12383), + 31: uint16(12384), + 32: uint16(12385), + 33: uint16(12386), + 34: uint16(12387), + 35: uint16(12388), + 36: uint16(12389), + 37: uint16(12390), + 38: uint16(12391), + 39: uint16(12392), + 40: uint16(12393), + 41: uint16(12394), + 42: uint16(12395), + 43: uint16(12396), + 44: uint16(12397), + 45: uint16(12398), + 46: uint16(12399), + 47: uint16(12400), + 48: uint16(12401), + 49: uint16(12402), + 50: uint16(12403), + 51: uint16(12404), + 52: uint16(12405), + 53: uint16(12406), + 54: uint16(12407), + 55: uint16(12408), + 56: uint16(12409), + 57: uint16(12410), + 58: uint16(12411), + 59: uint16(12412), + 60: uint16(12413), + 61: uint16(12414), + 62: uint16(12415), + 63: uint16(12416), + 64: uint16(12417), + 65: uint16(12418), + 66: uint16(12419), + 67: uint16(12420), + 68: uint16(12421), + 69: uint16(12422), + 70: uint16(12423), + 71: uint16(12424), + 72: uint16(12425), + 73: uint16(12426), + 74: uint16(12427), + 75: uint16(12428), + 76: uint16(12429), + 77: uint16(12430), + 78: uint16(12431), + 79: uint16(12432), + 80: uint16(12433), + 81: uint16(12434), + 82: uint16(12435), + }, + 10: { + 0: uint16(12449), + 1: uint16(12450), + 2: uint16(12451), + 3: uint16(12452), + 4: uint16(12453), + 5: uint16(12454), + 6: uint16(12455), + 7: uint16(12456), + 8: uint16(12457), + 9: uint16(12458), + 10: uint16(12459), + 11: uint16(12460), + 12: uint16(12461), + 13: uint16(12462), + 14: uint16(12463), + 15: uint16(12464), + 16: uint16(12465), + 17: uint16(12466), + 18: uint16(12467), + 19: uint16(12468), + 20: uint16(12469), + 21: uint16(12470), + 22: uint16(12471), + 23: uint16(12472), + 24: uint16(12473), + 25: uint16(12474), + 26: uint16(12475), + 27: uint16(12476), + 28: uint16(12477), + 29: uint16(12478), + 30: uint16(12479), + 31: uint16(12480), + 32: uint16(12481), + 33: uint16(12482), + 34: uint16(12483), + 35: uint16(12484), + 36: uint16(12485), + 37: uint16(12486), + 38: uint16(12487), + 39: uint16(12488), + 40: uint16(12489), + 41: uint16(12490), + 42: uint16(12491), + 43: uint16(12492), + 44: uint16(12493), + 45: uint16(12494), + 46: uint16(12495), + 47: uint16(12496), + 48: uint16(12497), + 49: uint16(12498), + 50: uint16(12499), + 51: uint16(12500), + 52: uint16(12501), + 53: uint16(12502), + 54: uint16(12503), + 55: uint16(12504), + 56: uint16(12505), + 57: uint16(12506), + 58: uint16(12507), + 59: uint16(12508), + 60: uint16(12509), + 61: uint16(12510), + 62: uint16(12511), + 63: uint16(12512), + 64: uint16(12513), + 65: uint16(12514), + 66: uint16(12515), + 67: uint16(12516), + 68: uint16(12517), + 69: uint16(12518), + 70: uint16(12519), + 71: uint16(12520), + 72: uint16(12521), + 73: uint16(12522), + 74: uint16(12523), + 75: uint16(12524), + 76: uint16(12525), + 77: uint16(12526), + 78: uint16(12527), + 79: uint16(12528), + 80: uint16(12529), + 81: uint16(12530), + 82: uint16(12531), + 83: uint16(12532), + 84: uint16(12533), + 85: uint16(12534), + }, + 11: { + 0: uint16(1040), + 1: uint16(1041), + 2: uint16(1042), + 3: uint16(1043), + 4: uint16(1044), + 5: uint16(1045), + 6: uint16(1025), + 7: uint16(1046), + 8: uint16(1047), + 9: uint16(1048), + 10: uint16(1049), + 11: uint16(1050), + 12: uint16(1051), + 13: uint16(1052), + 14: uint16(1053), + 15: uint16(1054), + 16: uint16(1055), + 17: uint16(1056), + 18: uint16(1057), + 19: uint16(1058), + 20: uint16(1059), + 21: uint16(1060), + 22: uint16(1061), + 23: uint16(1062), + 24: uint16(1063), + 25: uint16(1064), + 26: uint16(1065), + 27: uint16(1066), + 28: uint16(1067), + 29: uint16(1068), + 30: uint16(1069), + 31: uint16(1070), + 32: uint16(1071), + 48: uint16(1072), + 49: uint16(1073), + 50: uint16(1074), + 51: uint16(1075), + 52: uint16(1076), + 53: uint16(1077), + 54: uint16(1105), + 55: uint16(1078), + 56: uint16(1079), + 57: uint16(1080), + 58: uint16(1081), + 59: uint16(1082), + 60: uint16(1083), + 61: uint16(1084), + 62: uint16(1085), + 63: uint16(1086), + 64: uint16(1087), + 65: uint16(1088), + 66: uint16(1089), + 67: uint16(1090), + 68: uint16(1091), + 69: uint16(1092), + 70: uint16(1093), + 71: uint16(1094), + 72: uint16(1095), + 73: uint16(1096), + 74: uint16(1097), + 75: uint16(1098), + 76: uint16(1099), + 77: uint16(1100), + 78: uint16(1101), + 79: uint16(1102), + 80: uint16(1103), + }, + 12: {}, + 13: {}, + 14: {}, + 15: { + 0: uint16(44032), + 1: uint16(44033), + 2: uint16(44036), + 3: uint16(44039), + 4: uint16(44040), + 5: uint16(44041), + 6: uint16(44042), + 7: uint16(44048), + 8: uint16(44049), + 9: uint16(44050), + 10: uint16(44051), + 11: uint16(44052), + 12: uint16(44053), + 13: uint16(44054), + 14: uint16(44055), + 15: uint16(44057), + 16: uint16(44058), + 17: uint16(44059), + 18: uint16(44060), + 19: uint16(44061), + 20: uint16(44064), + 21: uint16(44068), + 22: uint16(44076), + 23: uint16(44077), + 24: uint16(44079), + 25: uint16(44080), + 26: uint16(44081), + 27: uint16(44088), + 28: uint16(44089), + 29: uint16(44092), + 30: uint16(44096), + 31: uint16(44107), + 32: uint16(44109), + 33: uint16(44116), + 34: uint16(44120), + 35: uint16(44124), + 36: uint16(44144), + 37: uint16(44145), + 38: uint16(44148), + 39: uint16(44151), + 40: uint16(44152), + 41: uint16(44154), + 42: uint16(44160), + 43: uint16(44161), + 44: uint16(44163), + 45: uint16(44164), + 46: uint16(44165), + 47: uint16(44166), + 48: uint16(44169), + 49: uint16(44170), + 50: uint16(44171), + 51: uint16(44172), + 52: uint16(44176), + 53: uint16(44180), + 54: uint16(44188), + 55: uint16(44189), + 56: uint16(44191), + 57: uint16(44192), + 58: uint16(44193), + 59: uint16(44200), + 60: uint16(44201), + 61: uint16(44202), + 62: uint16(44204), + 63: uint16(44207), + 64: uint16(44208), + 65: uint16(44216), + 66: uint16(44217), + 67: uint16(44219), + 68: uint16(44220), + 69: uint16(44221), + 70: uint16(44225), + 71: uint16(44228), + 72: uint16(44232), + 73: uint16(44236), + 74: uint16(44245), + 75: uint16(44247), + 76: uint16(44256), + 77: uint16(44257), + 78: uint16(44260), + 79: uint16(44263), + 80: uint16(44264), + 81: uint16(44266), + 82: uint16(44268), + 83: uint16(44271), + 84: uint16(44272), + 85: uint16(44273), + 86: uint16(44275), + 87: uint16(44277), + 88: uint16(44278), + 89: uint16(44284), + 90: uint16(44285), + 91: uint16(44288), + 92: uint16(44292), + 93: uint16(44294), + }, + 16: { + 0: uint16(44300), + 1: uint16(44301), + 2: uint16(44303), + 3: uint16(44305), + 4: uint16(44312), + 5: uint16(44316), + 6: uint16(44320), + 7: uint16(44329), + 8: uint16(44332), + 9: uint16(44333), + 10: uint16(44340), + 11: uint16(44341), + 12: uint16(44344), + 13: uint16(44348), + 14: uint16(44356), + 15: uint16(44357), + 16: uint16(44359), + 17: uint16(44361), + 18: uint16(44368), + 19: uint16(44372), + 20: uint16(44376), + 21: uint16(44385), + 22: uint16(44387), + 23: uint16(44396), + 24: uint16(44397), + 25: uint16(44400), + 26: uint16(44403), + 27: uint16(44404), + 28: uint16(44405), + 29: uint16(44406), + 30: uint16(44411), + 31: uint16(44412), + 32: uint16(44413), + 33: uint16(44415), + 34: uint16(44417), + 35: uint16(44418), + 36: uint16(44424), + 37: uint16(44425), + 38: uint16(44428), + 39: uint16(44432), + 40: uint16(44444), + 41: uint16(44445), + 42: uint16(44452), + 43: uint16(44471), + 44: uint16(44480), + 45: uint16(44481), + 46: uint16(44484), + 47: uint16(44488), + 48: uint16(44496), + 49: uint16(44497), + 50: uint16(44499), + 51: uint16(44508), + 52: uint16(44512), + 53: uint16(44516), + 54: uint16(44536), + 55: uint16(44537), + 56: uint16(44540), + 57: uint16(44543), + 58: uint16(44544), + 59: uint16(44545), + 60: uint16(44552), + 61: uint16(44553), + 62: uint16(44555), + 63: uint16(44557), + 64: uint16(44564), + 65: uint16(44592), + 66: uint16(44593), + 67: uint16(44596), + 68: uint16(44599), + 69: uint16(44600), + 70: uint16(44602), + 71: uint16(44608), + 72: uint16(44609), + 73: uint16(44611), + 74: uint16(44613), + 75: uint16(44614), + 76: uint16(44618), + 77: uint16(44620), + 78: uint16(44621), + 79: uint16(44622), + 80: uint16(44624), + 81: uint16(44628), + 82: uint16(44630), + 83: uint16(44636), + 84: uint16(44637), + 85: uint16(44639), + 86: uint16(44640), + 87: uint16(44641), + 88: uint16(44645), + 89: uint16(44648), + 90: uint16(44649), + 91: uint16(44652), + 92: uint16(44656), + 93: uint16(44664), + }, + 17: { + 0: uint16(44665), + 1: uint16(44667), + 2: uint16(44668), + 3: uint16(44669), + 4: uint16(44676), + 5: uint16(44677), + 6: uint16(44684), + 7: uint16(44732), + 8: uint16(44733), + 9: uint16(44734), + 10: uint16(44736), + 11: uint16(44740), + 12: uint16(44748), + 13: uint16(44749), + 14: uint16(44751), + 15: uint16(44752), + 16: uint16(44753), + 17: uint16(44760), + 18: uint16(44761), + 19: uint16(44764), + 20: uint16(44776), + 21: uint16(44779), + 22: uint16(44781), + 23: uint16(44788), + 24: uint16(44792), + 25: uint16(44796), + 26: uint16(44807), + 27: uint16(44808), + 28: uint16(44813), + 29: uint16(44816), + 30: uint16(44844), + 31: uint16(44845), + 32: uint16(44848), + 33: uint16(44850), + 34: uint16(44852), + 35: uint16(44860), + 36: uint16(44861), + 37: uint16(44863), + 38: uint16(44865), + 39: uint16(44866), + 40: uint16(44867), + 41: uint16(44872), + 42: uint16(44873), + 43: uint16(44880), + 44: uint16(44892), + 45: uint16(44893), + 46: uint16(44900), + 47: uint16(44901), + 48: uint16(44921), + 49: uint16(44928), + 50: uint16(44932), + 51: uint16(44936), + 52: uint16(44944), + 53: uint16(44945), + 54: uint16(44949), + 55: uint16(44956), + 56: uint16(44984), + 57: uint16(44985), + 58: uint16(44988), + 59: uint16(44992), + 60: uint16(44999), + 61: uint16(45000), + 62: uint16(45001), + 63: uint16(45003), + 64: uint16(45005), + 65: uint16(45006), + 66: uint16(45012), + 67: uint16(45020), + 68: uint16(45032), + 69: uint16(45033), + 70: uint16(45040), + 71: uint16(45041), + 72: uint16(45044), + 73: uint16(45048), + 74: uint16(45056), + 75: uint16(45057), + 76: uint16(45060), + 77: uint16(45068), + 78: uint16(45072), + 79: uint16(45076), + 80: uint16(45084), + 81: uint16(45085), + 82: uint16(45096), + 83: uint16(45124), + 84: uint16(45125), + 85: uint16(45128), + 86: uint16(45130), + 87: uint16(45132), + 88: uint16(45134), + 89: uint16(45139), + 90: uint16(45140), + 91: uint16(45141), + 92: uint16(45143), + 93: uint16(45145), + }, + 18: { + 0: uint16(45149), + 1: uint16(45180), + 2: uint16(45181), + 3: uint16(45184), + 4: uint16(45188), + 5: uint16(45196), + 6: uint16(45197), + 7: uint16(45199), + 8: uint16(45201), + 9: uint16(45208), + 10: uint16(45209), + 11: uint16(45210), + 12: uint16(45212), + 13: uint16(45215), + 14: uint16(45216), + 15: uint16(45217), + 16: uint16(45218), + 17: uint16(45224), + 18: uint16(45225), + 19: uint16(45227), + 20: uint16(45228), + 21: uint16(45229), + 22: uint16(45230), + 23: uint16(45231), + 24: uint16(45233), + 25: uint16(45235), + 26: uint16(45236), + 27: uint16(45237), + 28: uint16(45240), + 29: uint16(45244), + 30: uint16(45252), + 31: uint16(45253), + 32: uint16(45255), + 33: uint16(45256), + 34: uint16(45257), + 35: uint16(45264), + 36: uint16(45265), + 37: uint16(45268), + 38: uint16(45272), + 39: uint16(45280), + 40: uint16(45285), + 41: uint16(45320), + 42: uint16(45321), + 43: uint16(45323), + 44: uint16(45324), + 45: uint16(45328), + 46: uint16(45330), + 47: uint16(45331), + 48: uint16(45336), + 49: uint16(45337), + 50: uint16(45339), + 51: uint16(45340), + 52: uint16(45341), + 53: uint16(45347), + 54: uint16(45348), + 55: uint16(45349), + 56: uint16(45352), + 57: uint16(45356), + 58: uint16(45364), + 59: uint16(45365), + 60: uint16(45367), + 61: uint16(45368), + 62: uint16(45369), + 63: uint16(45376), + 64: uint16(45377), + 65: uint16(45380), + 66: uint16(45384), + 67: uint16(45392), + 68: uint16(45393), + 69: uint16(45396), + 70: uint16(45397), + 71: uint16(45400), + 72: uint16(45404), + 73: uint16(45408), + 74: uint16(45432), + 75: uint16(45433), + 76: uint16(45436), + 77: uint16(45440), + 78: uint16(45442), + 79: uint16(45448), + 80: uint16(45449), + 81: uint16(45451), + 82: uint16(45453), + 83: uint16(45458), + 84: uint16(45459), + 85: uint16(45460), + 86: uint16(45464), + 87: uint16(45468), + 88: uint16(45480), + 89: uint16(45516), + 90: uint16(45520), + 91: uint16(45524), + 92: uint16(45532), + 93: uint16(45533), + }, + 19: { + 0: uint16(45535), + 1: uint16(45544), + 2: uint16(45545), + 3: uint16(45548), + 4: uint16(45552), + 5: uint16(45561), + 6: uint16(45563), + 7: uint16(45565), + 8: uint16(45572), + 9: uint16(45573), + 10: uint16(45576), + 11: uint16(45579), + 12: uint16(45580), + 13: uint16(45588), + 14: uint16(45589), + 15: uint16(45591), + 16: uint16(45593), + 17: uint16(45600), + 18: uint16(45620), + 19: uint16(45628), + 20: uint16(45656), + 21: uint16(45660), + 22: uint16(45664), + 23: uint16(45672), + 24: uint16(45673), + 25: uint16(45684), + 26: uint16(45685), + 27: uint16(45692), + 28: uint16(45700), + 29: uint16(45701), + 30: uint16(45705), + 31: uint16(45712), + 32: uint16(45713), + 33: uint16(45716), + 34: uint16(45720), + 35: uint16(45721), + 36: uint16(45722), + 37: uint16(45728), + 38: uint16(45729), + 39: uint16(45731), + 40: uint16(45733), + 41: uint16(45734), + 42: uint16(45738), + 43: uint16(45740), + 44: uint16(45744), + 45: uint16(45748), + 46: uint16(45768), + 47: uint16(45769), + 48: uint16(45772), + 49: uint16(45776), + 50: uint16(45778), + 51: uint16(45784), + 52: uint16(45785), + 53: uint16(45787), + 54: uint16(45789), + 55: uint16(45794), + 56: uint16(45796), + 57: uint16(45797), + 58: uint16(45798), + 59: uint16(45800), + 60: uint16(45803), + 61: uint16(45804), + 62: uint16(45805), + 63: uint16(45806), + 64: uint16(45807), + 65: uint16(45811), + 66: uint16(45812), + 67: uint16(45813), + 68: uint16(45815), + 69: uint16(45816), + 70: uint16(45817), + 71: uint16(45818), + 72: uint16(45819), + 73: uint16(45823), + 74: uint16(45824), + 75: uint16(45825), + 76: uint16(45828), + 77: uint16(45832), + 78: uint16(45840), + 79: uint16(45841), + 80: uint16(45843), + 81: uint16(45844), + 82: uint16(45845), + 83: uint16(45852), + 84: uint16(45908), + 85: uint16(45909), + 86: uint16(45910), + 87: uint16(45912), + 88: uint16(45915), + 89: uint16(45916), + 90: uint16(45918), + 91: uint16(45919), + 92: uint16(45924), + 93: uint16(45925), + }, + 20: { + 0: uint16(45927), + 1: uint16(45929), + 2: uint16(45931), + 3: uint16(45934), + 4: uint16(45936), + 5: uint16(45937), + 6: uint16(45940), + 7: uint16(45944), + 8: uint16(45952), + 9: uint16(45953), + 10: uint16(45955), + 11: uint16(45956), + 12: uint16(45957), + 13: uint16(45964), + 14: uint16(45968), + 15: uint16(45972), + 16: uint16(45984), + 17: uint16(45985), + 18: uint16(45992), + 19: uint16(45996), + 20: uint16(46020), + 21: uint16(46021), + 22: uint16(46024), + 23: uint16(46027), + 24: uint16(46028), + 25: uint16(46030), + 26: uint16(46032), + 27: uint16(46036), + 28: uint16(46037), + 29: uint16(46039), + 30: uint16(46041), + 31: uint16(46043), + 32: uint16(46045), + 33: uint16(46048), + 34: uint16(46052), + 35: uint16(46056), + 36: uint16(46076), + 37: uint16(46096), + 38: uint16(46104), + 39: uint16(46108), + 40: uint16(46112), + 41: uint16(46120), + 42: uint16(46121), + 43: uint16(46123), + 44: uint16(46132), + 45: uint16(46160), + 46: uint16(46161), + 47: uint16(46164), + 48: uint16(46168), + 49: uint16(46176), + 50: uint16(46177), + 51: uint16(46179), + 52: uint16(46181), + 53: uint16(46188), + 54: uint16(46208), + 55: uint16(46216), + 56: uint16(46237), + 57: uint16(46244), + 58: uint16(46248), + 59: uint16(46252), + 60: uint16(46261), + 61: uint16(46263), + 62: uint16(46265), + 63: uint16(46272), + 64: uint16(46276), + 65: uint16(46280), + 66: uint16(46288), + 67: uint16(46293), + 68: uint16(46300), + 69: uint16(46301), + 70: uint16(46304), + 71: uint16(46307), + 72: uint16(46308), + 73: uint16(46310), + 74: uint16(46316), + 75: uint16(46317), + 76: uint16(46319), + 77: uint16(46321), + 78: uint16(46328), + 79: uint16(46356), + 80: uint16(46357), + 81: uint16(46360), + 82: uint16(46363), + 83: uint16(46364), + 84: uint16(46372), + 85: uint16(46373), + 86: uint16(46375), + 87: uint16(46376), + 88: uint16(46377), + 89: uint16(46378), + 90: uint16(46384), + 91: uint16(46385), + 92: uint16(46388), + 93: uint16(46392), + }, + 21: { + 0: uint16(46400), + 1: uint16(46401), + 2: uint16(46403), + 3: uint16(46404), + 4: uint16(46405), + 5: uint16(46411), + 6: uint16(46412), + 7: uint16(46413), + 8: uint16(46416), + 9: uint16(46420), + 10: uint16(46428), + 11: uint16(46429), + 12: uint16(46431), + 13: uint16(46432), + 14: uint16(46433), + 15: uint16(46496), + 16: uint16(46497), + 17: uint16(46500), + 18: uint16(46504), + 19: uint16(46506), + 20: uint16(46507), + 21: uint16(46512), + 22: uint16(46513), + 23: uint16(46515), + 24: uint16(46516), + 25: uint16(46517), + 26: uint16(46523), + 27: uint16(46524), + 28: uint16(46525), + 29: uint16(46528), + 30: uint16(46532), + 31: uint16(46540), + 32: uint16(46541), + 33: uint16(46543), + 34: uint16(46544), + 35: uint16(46545), + 36: uint16(46552), + 37: uint16(46572), + 38: uint16(46608), + 39: uint16(46609), + 40: uint16(46612), + 41: uint16(46616), + 42: uint16(46629), + 43: uint16(46636), + 44: uint16(46644), + 45: uint16(46664), + 46: uint16(46692), + 47: uint16(46696), + 48: uint16(46748), + 49: uint16(46749), + 50: uint16(46752), + 51: uint16(46756), + 52: uint16(46763), + 53: uint16(46764), + 54: uint16(46769), + 55: uint16(46804), + 56: uint16(46832), + 57: uint16(46836), + 58: uint16(46840), + 59: uint16(46848), + 60: uint16(46849), + 61: uint16(46853), + 62: uint16(46888), + 63: uint16(46889), + 64: uint16(46892), + 65: uint16(46895), + 66: uint16(46896), + 67: uint16(46904), + 68: uint16(46905), + 69: uint16(46907), + 70: uint16(46916), + 71: uint16(46920), + 72: uint16(46924), + 73: uint16(46932), + 74: uint16(46933), + 75: uint16(46944), + 76: uint16(46948), + 77: uint16(46952), + 78: uint16(46960), + 79: uint16(46961), + 80: uint16(46963), + 81: uint16(46965), + 82: uint16(46972), + 83: uint16(46973), + 84: uint16(46976), + 85: uint16(46980), + 86: uint16(46988), + 87: uint16(46989), + 88: uint16(46991), + 89: uint16(46992), + 90: uint16(46993), + 91: uint16(46994), + 92: uint16(46998), + 93: uint16(46999), + }, + 22: { + 0: uint16(47000), + 1: uint16(47001), + 2: uint16(47004), + 3: uint16(47008), + 4: uint16(47016), + 5: uint16(47017), + 6: uint16(47019), + 7: uint16(47020), + 8: uint16(47021), + 9: uint16(47028), + 10: uint16(47029), + 11: uint16(47032), + 12: uint16(47047), + 13: uint16(47049), + 14: uint16(47084), + 15: uint16(47085), + 16: uint16(47088), + 17: uint16(47092), + 18: uint16(47100), + 19: uint16(47101), + 20: uint16(47103), + 21: uint16(47104), + 22: uint16(47105), + 23: uint16(47111), + 24: uint16(47112), + 25: uint16(47113), + 26: uint16(47116), + 27: uint16(47120), + 28: uint16(47128), + 29: uint16(47129), + 30: uint16(47131), + 31: uint16(47133), + 32: uint16(47140), + 33: uint16(47141), + 34: uint16(47144), + 35: uint16(47148), + 36: uint16(47156), + 37: uint16(47157), + 38: uint16(47159), + 39: uint16(47160), + 40: uint16(47161), + 41: uint16(47168), + 42: uint16(47172), + 43: uint16(47185), + 44: uint16(47187), + 45: uint16(47196), + 46: uint16(47197), + 47: uint16(47200), + 48: uint16(47204), + 49: uint16(47212), + 50: uint16(47213), + 51: uint16(47215), + 52: uint16(47217), + 53: uint16(47224), + 54: uint16(47228), + 55: uint16(47245), + 56: uint16(47272), + 57: uint16(47280), + 58: uint16(47284), + 59: uint16(47288), + 60: uint16(47296), + 61: uint16(47297), + 62: uint16(47299), + 63: uint16(47301), + 64: uint16(47308), + 65: uint16(47312), + 66: uint16(47316), + 67: uint16(47325), + 68: uint16(47327), + 69: uint16(47329), + 70: uint16(47336), + 71: uint16(47337), + 72: uint16(47340), + 73: uint16(47344), + 74: uint16(47352), + 75: uint16(47353), + 76: uint16(47355), + 77: uint16(47357), + 78: uint16(47364), + 79: uint16(47384), + 80: uint16(47392), + 81: uint16(47420), + 82: uint16(47421), + 83: uint16(47424), + 84: uint16(47428), + 85: uint16(47436), + 86: uint16(47439), + 87: uint16(47441), + 88: uint16(47448), + 89: uint16(47449), + 90: uint16(47452), + 91: uint16(47456), + 92: uint16(47464), + 93: uint16(47465), + }, + 23: { + 0: uint16(47467), + 1: uint16(47469), + 2: uint16(47476), + 3: uint16(47477), + 4: uint16(47480), + 5: uint16(47484), + 6: uint16(47492), + 7: uint16(47493), + 8: uint16(47495), + 9: uint16(47497), + 10: uint16(47498), + 11: uint16(47501), + 12: uint16(47502), + 13: uint16(47532), + 14: uint16(47533), + 15: uint16(47536), + 16: uint16(47540), + 17: uint16(47548), + 18: uint16(47549), + 19: uint16(47551), + 20: uint16(47553), + 21: uint16(47560), + 22: uint16(47561), + 23: uint16(47564), + 24: uint16(47566), + 25: uint16(47567), + 26: uint16(47568), + 27: uint16(47569), + 28: uint16(47570), + 29: uint16(47576), + 30: uint16(47577), + 31: uint16(47579), + 32: uint16(47581), + 33: uint16(47582), + 34: uint16(47585), + 35: uint16(47587), + 36: uint16(47588), + 37: uint16(47589), + 38: uint16(47592), + 39: uint16(47596), + 40: uint16(47604), + 41: uint16(47605), + 42: uint16(47607), + 43: uint16(47608), + 44: uint16(47609), + 45: uint16(47610), + 46: uint16(47616), + 47: uint16(47617), + 48: uint16(47624), + 49: uint16(47637), + 50: uint16(47672), + 51: uint16(47673), + 52: uint16(47676), + 53: uint16(47680), + 54: uint16(47682), + 55: uint16(47688), + 56: uint16(47689), + 57: uint16(47691), + 58: uint16(47693), + 59: uint16(47694), + 60: uint16(47699), + 61: uint16(47700), + 62: uint16(47701), + 63: uint16(47704), + 64: uint16(47708), + 65: uint16(47716), + 66: uint16(47717), + 67: uint16(47719), + 68: uint16(47720), + 69: uint16(47721), + 70: uint16(47728), + 71: uint16(47729), + 72: uint16(47732), + 73: uint16(47736), + 74: uint16(47747), + 75: uint16(47748), + 76: uint16(47749), + 77: uint16(47751), + 78: uint16(47756), + 79: uint16(47784), + 80: uint16(47785), + 81: uint16(47787), + 82: uint16(47788), + 83: uint16(47792), + 84: uint16(47794), + 85: uint16(47800), + 86: uint16(47801), + 87: uint16(47803), + 88: uint16(47805), + 89: uint16(47812), + 90: uint16(47816), + 91: uint16(47832), + 92: uint16(47833), + 93: uint16(47868), + }, + 24: { + 0: uint16(47872), + 1: uint16(47876), + 2: uint16(47885), + 3: uint16(47887), + 4: uint16(47889), + 5: uint16(47896), + 6: uint16(47900), + 7: uint16(47904), + 8: uint16(47913), + 9: uint16(47915), + 10: uint16(47924), + 11: uint16(47925), + 12: uint16(47926), + 13: uint16(47928), + 14: uint16(47931), + 15: uint16(47932), + 16: uint16(47933), + 17: uint16(47934), + 18: uint16(47940), + 19: uint16(47941), + 20: uint16(47943), + 21: uint16(47945), + 22: uint16(47949), + 23: uint16(47951), + 24: uint16(47952), + 25: uint16(47956), + 26: uint16(47960), + 27: uint16(47969), + 28: uint16(47971), + 29: uint16(47980), + 30: uint16(48008), + 31: uint16(48012), + 32: uint16(48016), + 33: uint16(48036), + 34: uint16(48040), + 35: uint16(48044), + 36: uint16(48052), + 37: uint16(48055), + 38: uint16(48064), + 39: uint16(48068), + 40: uint16(48072), + 41: uint16(48080), + 42: uint16(48083), + 43: uint16(48120), + 44: uint16(48121), + 45: uint16(48124), + 46: uint16(48127), + 47: uint16(48128), + 48: uint16(48130), + 49: uint16(48136), + 50: uint16(48137), + 51: uint16(48139), + 52: uint16(48140), + 53: uint16(48141), + 54: uint16(48143), + 55: uint16(48145), + 56: uint16(48148), + 57: uint16(48149), + 58: uint16(48150), + 59: uint16(48151), + 60: uint16(48152), + 61: uint16(48155), + 62: uint16(48156), + 63: uint16(48157), + 64: uint16(48158), + 65: uint16(48159), + 66: uint16(48164), + 67: uint16(48165), + 68: uint16(48167), + 69: uint16(48169), + 70: uint16(48173), + 71: uint16(48176), + 72: uint16(48177), + 73: uint16(48180), + 74: uint16(48184), + 75: uint16(48192), + 76: uint16(48193), + 77: uint16(48195), + 78: uint16(48196), + 79: uint16(48197), + 80: uint16(48201), + 81: uint16(48204), + 82: uint16(48205), + 83: uint16(48208), + 84: uint16(48221), + 85: uint16(48260), + 86: uint16(48261), + 87: uint16(48264), + 88: uint16(48267), + 89: uint16(48268), + 90: uint16(48270), + 91: uint16(48276), + 92: uint16(48277), + 93: uint16(48279), + }, + 25: { + 0: uint16(48281), + 1: uint16(48282), + 2: uint16(48288), + 3: uint16(48289), + 4: uint16(48292), + 5: uint16(48295), + 6: uint16(48296), + 7: uint16(48304), + 8: uint16(48305), + 9: uint16(48307), + 10: uint16(48308), + 11: uint16(48309), + 12: uint16(48316), + 13: uint16(48317), + 14: uint16(48320), + 15: uint16(48324), + 16: uint16(48333), + 17: uint16(48335), + 18: uint16(48336), + 19: uint16(48337), + 20: uint16(48341), + 21: uint16(48344), + 22: uint16(48348), + 23: uint16(48372), + 24: uint16(48373), + 25: uint16(48374), + 26: uint16(48376), + 27: uint16(48380), + 28: uint16(48388), + 29: uint16(48389), + 30: uint16(48391), + 31: uint16(48393), + 32: uint16(48400), + 33: uint16(48404), + 34: uint16(48420), + 35: uint16(48428), + 36: uint16(48448), + 37: uint16(48456), + 38: uint16(48457), + 39: uint16(48460), + 40: uint16(48464), + 41: uint16(48472), + 42: uint16(48473), + 43: uint16(48484), + 44: uint16(48488), + 45: uint16(48512), + 46: uint16(48513), + 47: uint16(48516), + 48: uint16(48519), + 49: uint16(48520), + 50: uint16(48521), + 51: uint16(48522), + 52: uint16(48528), + 53: uint16(48529), + 54: uint16(48531), + 55: uint16(48533), + 56: uint16(48537), + 57: uint16(48538), + 58: uint16(48540), + 59: uint16(48548), + 60: uint16(48560), + 61: uint16(48568), + 62: uint16(48596), + 63: uint16(48597), + 64: uint16(48600), + 65: uint16(48604), + 66: uint16(48617), + 67: uint16(48624), + 68: uint16(48628), + 69: uint16(48632), + 70: uint16(48640), + 71: uint16(48643), + 72: uint16(48645), + 73: uint16(48652), + 74: uint16(48653), + 75: uint16(48656), + 76: uint16(48660), + 77: uint16(48668), + 78: uint16(48669), + 79: uint16(48671), + 80: uint16(48708), + 81: uint16(48709), + 82: uint16(48712), + 83: uint16(48716), + 84: uint16(48718), + 85: uint16(48724), + 86: uint16(48725), + 87: uint16(48727), + 88: uint16(48729), + 89: uint16(48730), + 90: uint16(48731), + 91: uint16(48736), + 92: uint16(48737), + 93: uint16(48740), + }, + 26: { + 0: uint16(48744), + 1: uint16(48746), + 2: uint16(48752), + 3: uint16(48753), + 4: uint16(48755), + 5: uint16(48756), + 6: uint16(48757), + 7: uint16(48763), + 8: uint16(48764), + 9: uint16(48765), + 10: uint16(48768), + 11: uint16(48772), + 12: uint16(48780), + 13: uint16(48781), + 14: uint16(48783), + 15: uint16(48784), + 16: uint16(48785), + 17: uint16(48792), + 18: uint16(48793), + 19: uint16(48808), + 20: uint16(48848), + 21: uint16(48849), + 22: uint16(48852), + 23: uint16(48855), + 24: uint16(48856), + 25: uint16(48864), + 26: uint16(48867), + 27: uint16(48868), + 28: uint16(48869), + 29: uint16(48876), + 30: uint16(48897), + 31: uint16(48904), + 32: uint16(48905), + 33: uint16(48920), + 34: uint16(48921), + 35: uint16(48923), + 36: uint16(48924), + 37: uint16(48925), + 38: uint16(48960), + 39: uint16(48961), + 40: uint16(48964), + 41: uint16(48968), + 42: uint16(48976), + 43: uint16(48977), + 44: uint16(48981), + 45: uint16(49044), + 46: uint16(49072), + 47: uint16(49093), + 48: uint16(49100), + 49: uint16(49101), + 50: uint16(49104), + 51: uint16(49108), + 52: uint16(49116), + 53: uint16(49119), + 54: uint16(49121), + 55: uint16(49212), + 56: uint16(49233), + 57: uint16(49240), + 58: uint16(49244), + 59: uint16(49248), + 60: uint16(49256), + 61: uint16(49257), + 62: uint16(49296), + 63: uint16(49297), + 64: uint16(49300), + 65: uint16(49304), + 66: uint16(49312), + 67: uint16(49313), + 68: uint16(49315), + 69: uint16(49317), + 70: uint16(49324), + 71: uint16(49325), + 72: uint16(49327), + 73: uint16(49328), + 74: uint16(49331), + 75: uint16(49332), + 76: uint16(49333), + 77: uint16(49334), + 78: uint16(49340), + 79: uint16(49341), + 80: uint16(49343), + 81: uint16(49344), + 82: uint16(49345), + 83: uint16(49349), + 84: uint16(49352), + 85: uint16(49353), + 86: uint16(49356), + 87: uint16(49360), + 88: uint16(49368), + 89: uint16(49369), + 90: uint16(49371), + 91: uint16(49372), + 92: uint16(49373), + 93: uint16(49380), + }, + 27: { + 0: uint16(49381), + 1: uint16(49384), + 2: uint16(49388), + 3: uint16(49396), + 4: uint16(49397), + 5: uint16(49399), + 6: uint16(49401), + 7: uint16(49408), + 8: uint16(49412), + 9: uint16(49416), + 10: uint16(49424), + 11: uint16(49429), + 12: uint16(49436), + 13: uint16(49437), + 14: uint16(49438), + 15: uint16(49439), + 16: uint16(49440), + 17: uint16(49443), + 18: uint16(49444), + 19: uint16(49446), + 20: uint16(49447), + 21: uint16(49452), + 22: uint16(49453), + 23: uint16(49455), + 24: uint16(49456), + 25: uint16(49457), + 26: uint16(49462), + 27: uint16(49464), + 28: uint16(49465), + 29: uint16(49468), + 30: uint16(49472), + 31: uint16(49480), + 32: uint16(49481), + 33: uint16(49483), + 34: uint16(49484), + 35: uint16(49485), + 36: uint16(49492), + 37: uint16(49493), + 38: uint16(49496), + 39: uint16(49500), + 40: uint16(49508), + 41: uint16(49509), + 42: uint16(49511), + 43: uint16(49512), + 44: uint16(49513), + 45: uint16(49520), + 46: uint16(49524), + 47: uint16(49528), + 48: uint16(49541), + 49: uint16(49548), + 50: uint16(49549), + 51: uint16(49550), + 52: uint16(49552), + 53: uint16(49556), + 54: uint16(49558), + 55: uint16(49564), + 56: uint16(49565), + 57: uint16(49567), + 58: uint16(49569), + 59: uint16(49573), + 60: uint16(49576), + 61: uint16(49577), + 62: uint16(49580), + 63: uint16(49584), + 64: uint16(49597), + 65: uint16(49604), + 66: uint16(49608), + 67: uint16(49612), + 68: uint16(49620), + 69: uint16(49623), + 70: uint16(49624), + 71: uint16(49632), + 72: uint16(49636), + 73: uint16(49640), + 74: uint16(49648), + 75: uint16(49649), + 76: uint16(49651), + 77: uint16(49660), + 78: uint16(49661), + 79: uint16(49664), + 80: uint16(49668), + 81: uint16(49676), + 82: uint16(49677), + 83: uint16(49679), + 84: uint16(49681), + 85: uint16(49688), + 86: uint16(49689), + 87: uint16(49692), + 88: uint16(49695), + 89: uint16(49696), + 90: uint16(49704), + 91: uint16(49705), + 92: uint16(49707), + 93: uint16(49709), + }, + 28: { + 0: uint16(49711), + 1: uint16(49713), + 2: uint16(49714), + 3: uint16(49716), + 4: uint16(49736), + 5: uint16(49744), + 6: uint16(49745), + 7: uint16(49748), + 8: uint16(49752), + 9: uint16(49760), + 10: uint16(49765), + 11: uint16(49772), + 12: uint16(49773), + 13: uint16(49776), + 14: uint16(49780), + 15: uint16(49788), + 16: uint16(49789), + 17: uint16(49791), + 18: uint16(49793), + 19: uint16(49800), + 20: uint16(49801), + 21: uint16(49808), + 22: uint16(49816), + 23: uint16(49819), + 24: uint16(49821), + 25: uint16(49828), + 26: uint16(49829), + 27: uint16(49832), + 28: uint16(49836), + 29: uint16(49837), + 30: uint16(49844), + 31: uint16(49845), + 32: uint16(49847), + 33: uint16(49849), + 34: uint16(49884), + 35: uint16(49885), + 36: uint16(49888), + 37: uint16(49891), + 38: uint16(49892), + 39: uint16(49899), + 40: uint16(49900), + 41: uint16(49901), + 42: uint16(49903), + 43: uint16(49905), + 44: uint16(49910), + 45: uint16(49912), + 46: uint16(49913), + 47: uint16(49915), + 48: uint16(49916), + 49: uint16(49920), + 50: uint16(49928), + 51: uint16(49929), + 52: uint16(49932), + 53: uint16(49933), + 54: uint16(49939), + 55: uint16(49940), + 56: uint16(49941), + 57: uint16(49944), + 58: uint16(49948), + 59: uint16(49956), + 60: uint16(49957), + 61: uint16(49960), + 62: uint16(49961), + 63: uint16(49989), + 64: uint16(50024), + 65: uint16(50025), + 66: uint16(50028), + 67: uint16(50032), + 68: uint16(50034), + 69: uint16(50040), + 70: uint16(50041), + 71: uint16(50044), + 72: uint16(50045), + 73: uint16(50052), + 74: uint16(50056), + 75: uint16(50060), + 76: uint16(50112), + 77: uint16(50136), + 78: uint16(50137), + 79: uint16(50140), + 80: uint16(50143), + 81: uint16(50144), + 82: uint16(50146), + 83: uint16(50152), + 84: uint16(50153), + 85: uint16(50157), + 86: uint16(50164), + 87: uint16(50165), + 88: uint16(50168), + 89: uint16(50184), + 90: uint16(50192), + 91: uint16(50212), + 92: uint16(50220), + 93: uint16(50224), + }, + 29: { + 0: uint16(50228), + 1: uint16(50236), + 2: uint16(50237), + 3: uint16(50248), + 4: uint16(50276), + 5: uint16(50277), + 6: uint16(50280), + 7: uint16(50284), + 8: uint16(50292), + 9: uint16(50293), + 10: uint16(50297), + 11: uint16(50304), + 12: uint16(50324), + 13: uint16(50332), + 14: uint16(50360), + 15: uint16(50364), + 16: uint16(50409), + 17: uint16(50416), + 18: uint16(50417), + 19: uint16(50420), + 20: uint16(50424), + 21: uint16(50426), + 22: uint16(50431), + 23: uint16(50432), + 24: uint16(50433), + 25: uint16(50444), + 26: uint16(50448), + 27: uint16(50452), + 28: uint16(50460), + 29: uint16(50472), + 30: uint16(50473), + 31: uint16(50476), + 32: uint16(50480), + 33: uint16(50488), + 34: uint16(50489), + 35: uint16(50491), + 36: uint16(50493), + 37: uint16(50500), + 38: uint16(50501), + 39: uint16(50504), + 40: uint16(50505), + 41: uint16(50506), + 42: uint16(50508), + 43: uint16(50509), + 44: uint16(50510), + 45: uint16(50515), + 46: uint16(50516), + 47: uint16(50517), + 48: uint16(50519), + 49: uint16(50520), + 50: uint16(50521), + 51: uint16(50525), + 52: uint16(50526), + 53: uint16(50528), + 54: uint16(50529), + 55: uint16(50532), + 56: uint16(50536), + 57: uint16(50544), + 58: uint16(50545), + 59: uint16(50547), + 60: uint16(50548), + 61: uint16(50549), + 62: uint16(50556), + 63: uint16(50557), + 64: uint16(50560), + 65: uint16(50564), + 66: uint16(50567), + 67: uint16(50572), + 68: uint16(50573), + 69: uint16(50575), + 70: uint16(50577), + 71: uint16(50581), + 72: uint16(50583), + 73: uint16(50584), + 74: uint16(50588), + 75: uint16(50592), + 76: uint16(50601), + 77: uint16(50612), + 78: uint16(50613), + 79: uint16(50616), + 80: uint16(50617), + 81: uint16(50619), + 82: uint16(50620), + 83: uint16(50621), + 84: uint16(50622), + 85: uint16(50628), + 86: uint16(50629), + 87: uint16(50630), + 88: uint16(50631), + 89: uint16(50632), + 90: uint16(50633), + 91: uint16(50634), + 92: uint16(50636), + 93: uint16(50638), + }, + 30: { + 0: uint16(50640), + 1: uint16(50641), + 2: uint16(50644), + 3: uint16(50648), + 4: uint16(50656), + 5: uint16(50657), + 6: uint16(50659), + 7: uint16(50661), + 8: uint16(50668), + 9: uint16(50669), + 10: uint16(50670), + 11: uint16(50672), + 12: uint16(50676), + 13: uint16(50678), + 14: uint16(50679), + 15: uint16(50684), + 16: uint16(50685), + 17: uint16(50686), + 18: uint16(50687), + 19: uint16(50688), + 20: uint16(50689), + 21: uint16(50693), + 22: uint16(50694), + 23: uint16(50695), + 24: uint16(50696), + 25: uint16(50700), + 26: uint16(50704), + 27: uint16(50712), + 28: uint16(50713), + 29: uint16(50715), + 30: uint16(50716), + 31: uint16(50724), + 32: uint16(50725), + 33: uint16(50728), + 34: uint16(50732), + 35: uint16(50733), + 36: uint16(50734), + 37: uint16(50736), + 38: uint16(50739), + 39: uint16(50740), + 40: uint16(50741), + 41: uint16(50743), + 42: uint16(50745), + 43: uint16(50747), + 44: uint16(50752), + 45: uint16(50753), + 46: uint16(50756), + 47: uint16(50760), + 48: uint16(50768), + 49: uint16(50769), + 50: uint16(50771), + 51: uint16(50772), + 52: uint16(50773), + 53: uint16(50780), + 54: uint16(50781), + 55: uint16(50784), + 56: uint16(50796), + 57: uint16(50799), + 58: uint16(50801), + 59: uint16(50808), + 60: uint16(50809), + 61: uint16(50812), + 62: uint16(50816), + 63: uint16(50824), + 64: uint16(50825), + 65: uint16(50827), + 66: uint16(50829), + 67: uint16(50836), + 68: uint16(50837), + 69: uint16(50840), + 70: uint16(50844), + 71: uint16(50852), + 72: uint16(50853), + 73: uint16(50855), + 74: uint16(50857), + 75: uint16(50864), + 76: uint16(50865), + 77: uint16(50868), + 78: uint16(50872), + 79: uint16(50873), + 80: uint16(50874), + 81: uint16(50880), + 82: uint16(50881), + 83: uint16(50883), + 84: uint16(50885), + 85: uint16(50892), + 86: uint16(50893), + 87: uint16(50896), + 88: uint16(50900), + 89: uint16(50908), + 90: uint16(50909), + 91: uint16(50912), + 92: uint16(50913), + 93: uint16(50920), + }, + 31: { + 0: uint16(50921), + 1: uint16(50924), + 2: uint16(50928), + 3: uint16(50936), + 4: uint16(50937), + 5: uint16(50941), + 6: uint16(50948), + 7: uint16(50949), + 8: uint16(50952), + 9: uint16(50956), + 10: uint16(50964), + 11: uint16(50965), + 12: uint16(50967), + 13: uint16(50969), + 14: uint16(50976), + 15: uint16(50977), + 16: uint16(50980), + 17: uint16(50984), + 18: uint16(50992), + 19: uint16(50993), + 20: uint16(50995), + 21: uint16(50997), + 22: uint16(50999), + 23: uint16(51004), + 24: uint16(51005), + 25: uint16(51008), + 26: uint16(51012), + 27: uint16(51018), + 28: uint16(51020), + 29: uint16(51021), + 30: uint16(51023), + 31: uint16(51025), + 32: uint16(51026), + 33: uint16(51027), + 34: uint16(51028), + 35: uint16(51029), + 36: uint16(51030), + 37: uint16(51031), + 38: uint16(51032), + 39: uint16(51036), + 40: uint16(51040), + 41: uint16(51048), + 42: uint16(51051), + 43: uint16(51060), + 44: uint16(51061), + 45: uint16(51064), + 46: uint16(51068), + 47: uint16(51069), + 48: uint16(51070), + 49: uint16(51075), + 50: uint16(51076), + 51: uint16(51077), + 52: uint16(51079), + 53: uint16(51080), + 54: uint16(51081), + 55: uint16(51082), + 56: uint16(51086), + 57: uint16(51088), + 58: uint16(51089), + 59: uint16(51092), + 60: uint16(51094), + 61: uint16(51095), + 62: uint16(51096), + 63: uint16(51098), + 64: uint16(51104), + 65: uint16(51105), + 66: uint16(51107), + 67: uint16(51108), + 68: uint16(51109), + 69: uint16(51110), + 70: uint16(51116), + 71: uint16(51117), + 72: uint16(51120), + 73: uint16(51124), + 74: uint16(51132), + 75: uint16(51133), + 76: uint16(51135), + 77: uint16(51136), + 78: uint16(51137), + 79: uint16(51144), + 80: uint16(51145), + 81: uint16(51148), + 82: uint16(51150), + 83: uint16(51152), + 84: uint16(51160), + 85: uint16(51165), + 86: uint16(51172), + 87: uint16(51176), + 88: uint16(51180), + 89: uint16(51200), + 90: uint16(51201), + 91: uint16(51204), + 92: uint16(51208), + 93: uint16(51210), + }, + 32: { + 0: uint16(51216), + 1: uint16(51217), + 2: uint16(51219), + 3: uint16(51221), + 4: uint16(51222), + 5: uint16(51228), + 6: uint16(51229), + 7: uint16(51232), + 8: uint16(51236), + 9: uint16(51244), + 10: uint16(51245), + 11: uint16(51247), + 12: uint16(51249), + 13: uint16(51256), + 14: uint16(51260), + 15: uint16(51264), + 16: uint16(51272), + 17: uint16(51273), + 18: uint16(51276), + 19: uint16(51277), + 20: uint16(51284), + 21: uint16(51312), + 22: uint16(51313), + 23: uint16(51316), + 24: uint16(51320), + 25: uint16(51322), + 26: uint16(51328), + 27: uint16(51329), + 28: uint16(51331), + 29: uint16(51333), + 30: uint16(51334), + 31: uint16(51335), + 32: uint16(51339), + 33: uint16(51340), + 34: uint16(51341), + 35: uint16(51348), + 36: uint16(51357), + 37: uint16(51359), + 38: uint16(51361), + 39: uint16(51368), + 40: uint16(51388), + 41: uint16(51389), + 42: uint16(51396), + 43: uint16(51400), + 44: uint16(51404), + 45: uint16(51412), + 46: uint16(51413), + 47: uint16(51415), + 48: uint16(51417), + 49: uint16(51424), + 50: uint16(51425), + 51: uint16(51428), + 52: uint16(51445), + 53: uint16(51452), + 54: uint16(51453), + 55: uint16(51456), + 56: uint16(51460), + 57: uint16(51461), + 58: uint16(51462), + 59: uint16(51468), + 60: uint16(51469), + 61: uint16(51471), + 62: uint16(51473), + 63: uint16(51480), + 64: uint16(51500), + 65: uint16(51508), + 66: uint16(51536), + 67: uint16(51537), + 68: uint16(51540), + 69: uint16(51544), + 70: uint16(51552), + 71: uint16(51553), + 72: uint16(51555), + 73: uint16(51564), + 74: uint16(51568), + 75: uint16(51572), + 76: uint16(51580), + 77: uint16(51592), + 78: uint16(51593), + 79: uint16(51596), + 80: uint16(51600), + 81: uint16(51608), + 82: uint16(51609), + 83: uint16(51611), + 84: uint16(51613), + 85: uint16(51648), + 86: uint16(51649), + 87: uint16(51652), + 88: uint16(51655), + 89: uint16(51656), + 90: uint16(51658), + 91: uint16(51664), + 92: uint16(51665), + 93: uint16(51667), + }, + 33: { + 0: uint16(51669), + 1: uint16(51670), + 2: uint16(51673), + 3: uint16(51674), + 4: uint16(51676), + 5: uint16(51677), + 6: uint16(51680), + 7: uint16(51682), + 8: uint16(51684), + 9: uint16(51687), + 10: uint16(51692), + 11: uint16(51693), + 12: uint16(51695), + 13: uint16(51696), + 14: uint16(51697), + 15: uint16(51704), + 16: uint16(51705), + 17: uint16(51708), + 18: uint16(51712), + 19: uint16(51720), + 20: uint16(51721), + 21: uint16(51723), + 22: uint16(51724), + 23: uint16(51725), + 24: uint16(51732), + 25: uint16(51736), + 26: uint16(51753), + 27: uint16(51788), + 28: uint16(51789), + 29: uint16(51792), + 30: uint16(51796), + 31: uint16(51804), + 32: uint16(51805), + 33: uint16(51807), + 34: uint16(51808), + 35: uint16(51809), + 36: uint16(51816), + 37: uint16(51837), + 38: uint16(51844), + 39: uint16(51864), + 40: uint16(51900), + 41: uint16(51901), + 42: uint16(51904), + 43: uint16(51908), + 44: uint16(51916), + 45: uint16(51917), + 46: uint16(51919), + 47: uint16(51921), + 48: uint16(51923), + 49: uint16(51928), + 50: uint16(51929), + 51: uint16(51936), + 52: uint16(51948), + 53: uint16(51956), + 54: uint16(51976), + 55: uint16(51984), + 56: uint16(51988), + 57: uint16(51992), + 58: uint16(52000), + 59: uint16(52001), + 60: uint16(52033), + 61: uint16(52040), + 62: uint16(52041), + 63: uint16(52044), + 64: uint16(52048), + 65: uint16(52056), + 66: uint16(52057), + 67: uint16(52061), + 68: uint16(52068), + 69: uint16(52088), + 70: uint16(52089), + 71: uint16(52124), + 72: uint16(52152), + 73: uint16(52180), + 74: uint16(52196), + 75: uint16(52199), + 76: uint16(52201), + 77: uint16(52236), + 78: uint16(52237), + 79: uint16(52240), + 80: uint16(52244), + 81: uint16(52252), + 82: uint16(52253), + 83: uint16(52257), + 84: uint16(52258), + 85: uint16(52263), + 86: uint16(52264), + 87: uint16(52265), + 88: uint16(52268), + 89: uint16(52270), + 90: uint16(52272), + 91: uint16(52280), + 92: uint16(52281), + 93: uint16(52283), + }, + 34: { + 0: uint16(52284), + 1: uint16(52285), + 2: uint16(52286), + 3: uint16(52292), + 4: uint16(52293), + 5: uint16(52296), + 6: uint16(52300), + 7: uint16(52308), + 8: uint16(52309), + 9: uint16(52311), + 10: uint16(52312), + 11: uint16(52313), + 12: uint16(52320), + 13: uint16(52324), + 14: uint16(52326), + 15: uint16(52328), + 16: uint16(52336), + 17: uint16(52341), + 18: uint16(52376), + 19: uint16(52377), + 20: uint16(52380), + 21: uint16(52384), + 22: uint16(52392), + 23: uint16(52393), + 24: uint16(52395), + 25: uint16(52396), + 26: uint16(52397), + 27: uint16(52404), + 28: uint16(52405), + 29: uint16(52408), + 30: uint16(52412), + 31: uint16(52420), + 32: uint16(52421), + 33: uint16(52423), + 34: uint16(52425), + 35: uint16(52432), + 36: uint16(52436), + 37: uint16(52452), + 38: uint16(52460), + 39: uint16(52464), + 40: uint16(52481), + 41: uint16(52488), + 42: uint16(52489), + 43: uint16(52492), + 44: uint16(52496), + 45: uint16(52504), + 46: uint16(52505), + 47: uint16(52507), + 48: uint16(52509), + 49: uint16(52516), + 50: uint16(52520), + 51: uint16(52524), + 52: uint16(52537), + 53: uint16(52572), + 54: uint16(52576), + 55: uint16(52580), + 56: uint16(52588), + 57: uint16(52589), + 58: uint16(52591), + 59: uint16(52593), + 60: uint16(52600), + 61: uint16(52616), + 62: uint16(52628), + 63: uint16(52629), + 64: uint16(52632), + 65: uint16(52636), + 66: uint16(52644), + 67: uint16(52645), + 68: uint16(52647), + 69: uint16(52649), + 70: uint16(52656), + 71: uint16(52676), + 72: uint16(52684), + 73: uint16(52688), + 74: uint16(52712), + 75: uint16(52716), + 76: uint16(52720), + 77: uint16(52728), + 78: uint16(52729), + 79: uint16(52731), + 80: uint16(52733), + 81: uint16(52740), + 82: uint16(52744), + 83: uint16(52748), + 84: uint16(52756), + 85: uint16(52761), + 86: uint16(52768), + 87: uint16(52769), + 88: uint16(52772), + 89: uint16(52776), + 90: uint16(52784), + 91: uint16(52785), + 92: uint16(52787), + 93: uint16(52789), + }, + 35: { + 0: uint16(52824), + 1: uint16(52825), + 2: uint16(52828), + 3: uint16(52831), + 4: uint16(52832), + 5: uint16(52833), + 6: uint16(52840), + 7: uint16(52841), + 8: uint16(52843), + 9: uint16(52845), + 10: uint16(52852), + 11: uint16(52853), + 12: uint16(52856), + 13: uint16(52860), + 14: uint16(52868), + 15: uint16(52869), + 16: uint16(52871), + 17: uint16(52873), + 18: uint16(52880), + 19: uint16(52881), + 20: uint16(52884), + 21: uint16(52888), + 22: uint16(52896), + 23: uint16(52897), + 24: uint16(52899), + 25: uint16(52900), + 26: uint16(52901), + 27: uint16(52908), + 28: uint16(52909), + 29: uint16(52929), + 30: uint16(52964), + 31: uint16(52965), + 32: uint16(52968), + 33: uint16(52971), + 34: uint16(52972), + 35: uint16(52980), + 36: uint16(52981), + 37: uint16(52983), + 38: uint16(52984), + 39: uint16(52985), + 40: uint16(52992), + 41: uint16(52993), + 42: uint16(52996), + 43: uint16(53000), + 44: uint16(53008), + 45: uint16(53009), + 46: uint16(53011), + 47: uint16(53013), + 48: uint16(53020), + 49: uint16(53024), + 50: uint16(53028), + 51: uint16(53036), + 52: uint16(53037), + 53: uint16(53039), + 54: uint16(53040), + 55: uint16(53041), + 56: uint16(53048), + 57: uint16(53076), + 58: uint16(53077), + 59: uint16(53080), + 60: uint16(53084), + 61: uint16(53092), + 62: uint16(53093), + 63: uint16(53095), + 64: uint16(53097), + 65: uint16(53104), + 66: uint16(53105), + 67: uint16(53108), + 68: uint16(53112), + 69: uint16(53120), + 70: uint16(53125), + 71: uint16(53132), + 72: uint16(53153), + 73: uint16(53160), + 74: uint16(53168), + 75: uint16(53188), + 76: uint16(53216), + 77: uint16(53217), + 78: uint16(53220), + 79: uint16(53224), + 80: uint16(53232), + 81: uint16(53233), + 82: uint16(53235), + 83: uint16(53237), + 84: uint16(53244), + 85: uint16(53248), + 86: uint16(53252), + 87: uint16(53265), + 88: uint16(53272), + 89: uint16(53293), + 90: uint16(53300), + 91: uint16(53301), + 92: uint16(53304), + 93: uint16(53308), + }, + 36: { + 0: uint16(53316), + 1: uint16(53317), + 2: uint16(53319), + 3: uint16(53321), + 4: uint16(53328), + 5: uint16(53332), + 6: uint16(53336), + 7: uint16(53344), + 8: uint16(53356), + 9: uint16(53357), + 10: uint16(53360), + 11: uint16(53364), + 12: uint16(53372), + 13: uint16(53373), + 14: uint16(53377), + 15: uint16(53412), + 16: uint16(53413), + 17: uint16(53416), + 18: uint16(53420), + 19: uint16(53428), + 20: uint16(53429), + 21: uint16(53431), + 22: uint16(53433), + 23: uint16(53440), + 24: uint16(53441), + 25: uint16(53444), + 26: uint16(53448), + 27: uint16(53449), + 28: uint16(53456), + 29: uint16(53457), + 30: uint16(53459), + 31: uint16(53460), + 32: uint16(53461), + 33: uint16(53468), + 34: uint16(53469), + 35: uint16(53472), + 36: uint16(53476), + 37: uint16(53484), + 38: uint16(53485), + 39: uint16(53487), + 40: uint16(53488), + 41: uint16(53489), + 42: uint16(53496), + 43: uint16(53517), + 44: uint16(53552), + 45: uint16(53553), + 46: uint16(53556), + 47: uint16(53560), + 48: uint16(53562), + 49: uint16(53568), + 50: uint16(53569), + 51: uint16(53571), + 52: uint16(53572), + 53: uint16(53573), + 54: uint16(53580), + 55: uint16(53581), + 56: uint16(53584), + 57: uint16(53588), + 58: uint16(53596), + 59: uint16(53597), + 60: uint16(53599), + 61: uint16(53601), + 62: uint16(53608), + 63: uint16(53612), + 64: uint16(53628), + 65: uint16(53636), + 66: uint16(53640), + 67: uint16(53664), + 68: uint16(53665), + 69: uint16(53668), + 70: uint16(53672), + 71: uint16(53680), + 72: uint16(53681), + 73: uint16(53683), + 74: uint16(53685), + 75: uint16(53690), + 76: uint16(53692), + 77: uint16(53696), + 78: uint16(53720), + 79: uint16(53748), + 80: uint16(53752), + 81: uint16(53767), + 82: uint16(53769), + 83: uint16(53776), + 84: uint16(53804), + 85: uint16(53805), + 86: uint16(53808), + 87: uint16(53812), + 88: uint16(53820), + 89: uint16(53821), + 90: uint16(53823), + 91: uint16(53825), + 92: uint16(53832), + 93: uint16(53852), + }, + 37: { + 0: uint16(53860), + 1: uint16(53888), + 2: uint16(53889), + 3: uint16(53892), + 4: uint16(53896), + 5: uint16(53904), + 6: uint16(53905), + 7: uint16(53909), + 8: uint16(53916), + 9: uint16(53920), + 10: uint16(53924), + 11: uint16(53932), + 12: uint16(53937), + 13: uint16(53944), + 14: uint16(53945), + 15: uint16(53948), + 16: uint16(53951), + 17: uint16(53952), + 18: uint16(53954), + 19: uint16(53960), + 20: uint16(53961), + 21: uint16(53963), + 22: uint16(53972), + 23: uint16(53976), + 24: uint16(53980), + 25: uint16(53988), + 26: uint16(53989), + 27: uint16(54000), + 28: uint16(54001), + 29: uint16(54004), + 30: uint16(54008), + 31: uint16(54016), + 32: uint16(54017), + 33: uint16(54019), + 34: uint16(54021), + 35: uint16(54028), + 36: uint16(54029), + 37: uint16(54030), + 38: uint16(54032), + 39: uint16(54036), + 40: uint16(54038), + 41: uint16(54044), + 42: uint16(54045), + 43: uint16(54047), + 44: uint16(54048), + 45: uint16(54049), + 46: uint16(54053), + 47: uint16(54056), + 48: uint16(54057), + 49: uint16(54060), + 50: uint16(54064), + 51: uint16(54072), + 52: uint16(54073), + 53: uint16(54075), + 54: uint16(54076), + 55: uint16(54077), + 56: uint16(54084), + 57: uint16(54085), + 58: uint16(54140), + 59: uint16(54141), + 60: uint16(54144), + 61: uint16(54148), + 62: uint16(54156), + 63: uint16(54157), + 64: uint16(54159), + 65: uint16(54160), + 66: uint16(54161), + 67: uint16(54168), + 68: uint16(54169), + 69: uint16(54172), + 70: uint16(54176), + 71: uint16(54184), + 72: uint16(54185), + 73: uint16(54187), + 74: uint16(54189), + 75: uint16(54196), + 76: uint16(54200), + 77: uint16(54204), + 78: uint16(54212), + 79: uint16(54213), + 80: uint16(54216), + 81: uint16(54217), + 82: uint16(54224), + 83: uint16(54232), + 84: uint16(54241), + 85: uint16(54243), + 86: uint16(54252), + 87: uint16(54253), + 88: uint16(54256), + 89: uint16(54260), + 90: uint16(54268), + 91: uint16(54269), + 92: uint16(54271), + 93: uint16(54273), + }, + 38: { + 0: uint16(54280), + 1: uint16(54301), + 2: uint16(54336), + 3: uint16(54340), + 4: uint16(54364), + 5: uint16(54368), + 6: uint16(54372), + 7: uint16(54381), + 8: uint16(54383), + 9: uint16(54392), + 10: uint16(54393), + 11: uint16(54396), + 12: uint16(54399), + 13: uint16(54400), + 14: uint16(54402), + 15: uint16(54408), + 16: uint16(54409), + 17: uint16(54411), + 18: uint16(54413), + 19: uint16(54420), + 20: uint16(54441), + 21: uint16(54476), + 22: uint16(54480), + 23: uint16(54484), + 24: uint16(54492), + 25: uint16(54495), + 26: uint16(54504), + 27: uint16(54508), + 28: uint16(54512), + 29: uint16(54520), + 30: uint16(54523), + 31: uint16(54525), + 32: uint16(54532), + 33: uint16(54536), + 34: uint16(54540), + 35: uint16(54548), + 36: uint16(54549), + 37: uint16(54551), + 38: uint16(54588), + 39: uint16(54589), + 40: uint16(54592), + 41: uint16(54596), + 42: uint16(54604), + 43: uint16(54605), + 44: uint16(54607), + 45: uint16(54609), + 46: uint16(54616), + 47: uint16(54617), + 48: uint16(54620), + 49: uint16(54624), + 50: uint16(54629), + 51: uint16(54632), + 52: uint16(54633), + 53: uint16(54635), + 54: uint16(54637), + 55: uint16(54644), + 56: uint16(54645), + 57: uint16(54648), + 58: uint16(54652), + 59: uint16(54660), + 60: uint16(54661), + 61: uint16(54663), + 62: uint16(54664), + 63: uint16(54665), + 64: uint16(54672), + 65: uint16(54693), + 66: uint16(54728), + 67: uint16(54729), + 68: uint16(54732), + 69: uint16(54736), + 70: uint16(54738), + 71: uint16(54744), + 72: uint16(54745), + 73: uint16(54747), + 74: uint16(54749), + 75: uint16(54756), + 76: uint16(54757), + 77: uint16(54760), + 78: uint16(54764), + 79: uint16(54772), + 80: uint16(54773), + 81: uint16(54775), + 82: uint16(54777), + 83: uint16(54784), + 84: uint16(54785), + 85: uint16(54788), + 86: uint16(54792), + 87: uint16(54800), + 88: uint16(54801), + 89: uint16(54803), + 90: uint16(54804), + 91: uint16(54805), + 92: uint16(54812), + 93: uint16(54816), + }, + 39: { + 0: uint16(54820), + 1: uint16(54829), + 2: uint16(54840), + 3: uint16(54841), + 4: uint16(54844), + 5: uint16(54848), + 6: uint16(54853), + 7: uint16(54856), + 8: uint16(54857), + 9: uint16(54859), + 10: uint16(54861), + 11: uint16(54865), + 12: uint16(54868), + 13: uint16(54869), + 14: uint16(54872), + 15: uint16(54876), + 16: uint16(54887), + 17: uint16(54889), + 18: uint16(54896), + 19: uint16(54897), + 20: uint16(54900), + 21: uint16(54915), + 22: uint16(54917), + 23: uint16(54924), + 24: uint16(54925), + 25: uint16(54928), + 26: uint16(54932), + 27: uint16(54941), + 28: uint16(54943), + 29: uint16(54945), + 30: uint16(54952), + 31: uint16(54956), + 32: uint16(54960), + 33: uint16(54969), + 34: uint16(54971), + 35: uint16(54980), + 36: uint16(54981), + 37: uint16(54984), + 38: uint16(54988), + 39: uint16(54993), + 40: uint16(54996), + 41: uint16(54999), + 42: uint16(55001), + 43: uint16(55008), + 44: uint16(55012), + 45: uint16(55016), + 46: uint16(55024), + 47: uint16(55029), + 48: uint16(55036), + 49: uint16(55037), + 50: uint16(55040), + 51: uint16(55044), + 52: uint16(55057), + 53: uint16(55064), + 54: uint16(55065), + 55: uint16(55068), + 56: uint16(55072), + 57: uint16(55080), + 58: uint16(55081), + 59: uint16(55083), + 60: uint16(55085), + 61: uint16(55092), + 62: uint16(55093), + 63: uint16(55096), + 64: uint16(55100), + 65: uint16(55108), + 66: uint16(55111), + 67: uint16(55113), + 68: uint16(55120), + 69: uint16(55121), + 70: uint16(55124), + 71: uint16(55126), + 72: uint16(55127), + 73: uint16(55128), + 74: uint16(55129), + 75: uint16(55136), + 76: uint16(55137), + 77: uint16(55139), + 78: uint16(55141), + 79: uint16(55145), + 80: uint16(55148), + 81: uint16(55152), + 82: uint16(55156), + 83: uint16(55164), + 84: uint16(55165), + 85: uint16(55169), + 86: uint16(55176), + 87: uint16(55177), + 88: uint16(55180), + 89: uint16(55184), + 90: uint16(55192), + 91: uint16(55193), + 92: uint16(55195), + 93: uint16(55197), + }, + 40: {}, + 41: { + 0: uint16(20285), + 1: uint16(20339), + 2: uint16(20551), + 3: uint16(20729), + 4: uint16(21152), + 5: uint16(21487), + 6: uint16(21621), + 7: uint16(21733), + 8: uint16(22025), + 9: uint16(23233), + 10: uint16(23478), + 11: uint16(26247), + 12: uint16(26550), + 13: uint16(26551), + 14: uint16(26607), + 15: uint16(27468), + 16: uint16(29634), + 17: uint16(30146), + 18: uint16(31292), + 19: uint16(33499), + 20: uint16(33540), + 21: uint16(34903), + 22: uint16(34952), + 23: uint16(35382), + 24: uint16(36040), + 25: uint16(36303), + 26: uint16(36603), + 27: uint16(36838), + 28: uint16(39381), + 29: uint16(21051), + 30: uint16(21364), + 31: uint16(21508), + 32: uint16(24682), + 33: uint16(24932), + 34: uint16(27580), + 35: uint16(29647), + 36: uint16(33050), + 37: uint16(35258), + 38: uint16(35282), + 39: uint16(38307), + 40: uint16(20355), + 41: uint16(21002), + 42: uint16(22718), + 43: uint16(22904), + 44: uint16(23014), + 45: uint16(24178), + 46: uint16(24185), + 47: uint16(25031), + 48: uint16(25536), + 49: uint16(26438), + 50: uint16(26604), + 51: uint16(26751), + 52: uint16(28567), + 53: uint16(30286), + 54: uint16(30475), + 55: uint16(30965), + 56: uint16(31240), + 57: uint16(31487), + 58: uint16(31777), + 59: uint16(32925), + 60: uint16(33390), + 61: uint16(33393), + 62: uint16(35563), + 63: uint16(38291), + 64: uint16(20075), + 65: uint16(21917), + 66: uint16(26359), + 67: uint16(28212), + 68: uint16(30883), + 69: uint16(31469), + 70: uint16(33883), + 71: uint16(35088), + 72: uint16(34638), + 73: uint16(38824), + 74: uint16(21208), + 75: uint16(22350), + 76: uint16(22570), + 77: uint16(23884), + 78: uint16(24863), + 79: uint16(25022), + 80: uint16(25121), + 81: uint16(25954), + 82: uint16(26577), + 83: uint16(27204), + 84: uint16(28187), + 85: uint16(29976), + 86: uint16(30131), + 87: uint16(30435), + 88: uint16(30640), + 89: uint16(32058), + 90: uint16(37039), + 91: uint16(37969), + 92: uint16(37970), + 93: uint16(40853), + }, + 42: { + 0: uint16(21283), + 1: uint16(23724), + 2: uint16(30002), + 3: uint16(32987), + 4: uint16(37440), + 5: uint16(38296), + 6: uint16(21083), + 7: uint16(22536), + 8: uint16(23004), + 9: uint16(23713), + 10: uint16(23831), + 11: uint16(24247), + 12: uint16(24378), + 13: uint16(24394), + 14: uint16(24951), + 15: uint16(27743), + 16: uint16(30074), + 17: uint16(30086), + 18: uint16(31968), + 19: uint16(32115), + 20: uint16(32177), + 21: uint16(32652), + 22: uint16(33108), + 23: uint16(33313), + 24: uint16(34193), + 25: uint16(35137), + 26: uint16(35611), + 27: uint16(37628), + 28: uint16(38477), + 29: uint16(40007), + 30: uint16(20171), + 31: uint16(20215), + 32: uint16(20491), + 33: uint16(20977), + 34: uint16(22607), + 35: uint16(24887), + 36: uint16(24894), + 37: uint16(24936), + 38: uint16(25913), + 39: uint16(27114), + 40: uint16(28433), + 41: uint16(30117), + 42: uint16(30342), + 43: uint16(30422), + 44: uint16(31623), + 45: uint16(33445), + 46: uint16(33995), + 47: uint16(63744), + 48: uint16(37799), + 49: uint16(38283), + 50: uint16(21888), + 51: uint16(23458), + 52: uint16(22353), + 53: uint16(63745), + 54: uint16(31923), + 55: uint16(32697), + 56: uint16(37301), + 57: uint16(20520), + 58: uint16(21435), + 59: uint16(23621), + 60: uint16(24040), + 61: uint16(25298), + 62: uint16(25454), + 63: uint16(25818), + 64: uint16(25831), + 65: uint16(28192), + 66: uint16(28844), + 67: uint16(31067), + 68: uint16(36317), + 69: uint16(36382), + 70: uint16(63746), + 71: uint16(36989), + 72: uint16(37445), + 73: uint16(37624), + 74: uint16(20094), + 75: uint16(20214), + 76: uint16(20581), + 77: uint16(24062), + 78: uint16(24314), + 79: uint16(24838), + 80: uint16(26967), + 81: uint16(33137), + 82: uint16(34388), + 83: uint16(36423), + 84: uint16(37749), + 85: uint16(39467), + 86: uint16(20062), + 87: uint16(20625), + 88: uint16(26480), + 89: uint16(26688), + 90: uint16(20745), + 91: uint16(21133), + 92: uint16(21138), + 93: uint16(27298), + }, + 43: { + 0: uint16(30652), + 1: uint16(37392), + 2: uint16(40660), + 3: uint16(21163), + 4: uint16(24623), + 5: uint16(36850), + 6: uint16(20552), + 7: uint16(25001), + 8: uint16(25581), + 9: uint16(25802), + 10: uint16(26684), + 11: uint16(27268), + 12: uint16(28608), + 13: uint16(33160), + 14: uint16(35233), + 15: uint16(38548), + 16: uint16(22533), + 17: uint16(29309), + 18: uint16(29356), + 19: uint16(29956), + 20: uint16(32121), + 21: uint16(32365), + 22: uint16(32937), + 23: uint16(35211), + 24: uint16(35700), + 25: uint16(36963), + 26: uint16(40273), + 27: uint16(25225), + 28: uint16(27770), + 29: uint16(28500), + 30: uint16(32080), + 31: uint16(32570), + 32: uint16(35363), + 33: uint16(20860), + 34: uint16(24906), + 35: uint16(31645), + 36: uint16(35609), + 37: uint16(37463), + 38: uint16(37772), + 39: uint16(20140), + 40: uint16(20435), + 41: uint16(20510), + 42: uint16(20670), + 43: uint16(20742), + 44: uint16(21185), + 45: uint16(21197), + 46: uint16(21375), + 47: uint16(22384), + 48: uint16(22659), + 49: uint16(24218), + 50: uint16(24465), + 51: uint16(24950), + 52: uint16(25004), + 53: uint16(25806), + 54: uint16(25964), + 55: uint16(26223), + 56: uint16(26299), + 57: uint16(26356), + 58: uint16(26775), + 59: uint16(28039), + 60: uint16(28805), + 61: uint16(28913), + 62: uint16(29855), + 63: uint16(29861), + 64: uint16(29898), + 65: uint16(30169), + 66: uint16(30828), + 67: uint16(30956), + 68: uint16(31455), + 69: uint16(31478), + 70: uint16(32069), + 71: uint16(32147), + 72: uint16(32789), + 73: uint16(32831), + 74: uint16(33051), + 75: uint16(33686), + 76: uint16(35686), + 77: uint16(36629), + 78: uint16(36885), + 79: uint16(37857), + 80: uint16(38915), + 81: uint16(38968), + 82: uint16(39514), + 83: uint16(39912), + 84: uint16(20418), + 85: uint16(21843), + 86: uint16(22586), + 87: uint16(22865), + 88: uint16(23395), + 89: uint16(23622), + 90: uint16(24760), + 91: uint16(25106), + 92: uint16(26690), + 93: uint16(26800), + }, + 44: { + 0: uint16(26856), + 1: uint16(28330), + 2: uint16(30028), + 3: uint16(30328), + 4: uint16(30926), + 5: uint16(31293), + 6: uint16(31995), + 7: uint16(32363), + 8: uint16(32380), + 9: uint16(35336), + 10: uint16(35489), + 11: uint16(35903), + 12: uint16(38542), + 13: uint16(40388), + 14: uint16(21476), + 15: uint16(21481), + 16: uint16(21578), + 17: uint16(21617), + 18: uint16(22266), + 19: uint16(22993), + 20: uint16(23396), + 21: uint16(23611), + 22: uint16(24235), + 23: uint16(25335), + 24: uint16(25911), + 25: uint16(25925), + 26: uint16(25970), + 27: uint16(26272), + 28: uint16(26543), + 29: uint16(27073), + 30: uint16(27837), + 31: uint16(30204), + 32: uint16(30352), + 33: uint16(30590), + 34: uint16(31295), + 35: uint16(32660), + 36: uint16(32771), + 37: uint16(32929), + 38: uint16(33167), + 39: uint16(33510), + 40: uint16(33533), + 41: uint16(33776), + 42: uint16(34241), + 43: uint16(34865), + 44: uint16(34996), + 45: uint16(35493), + 46: uint16(63747), + 47: uint16(36764), + 48: uint16(37678), + 49: uint16(38599), + 50: uint16(39015), + 51: uint16(39640), + 52: uint16(40723), + 53: uint16(21741), + 54: uint16(26011), + 55: uint16(26354), + 56: uint16(26767), + 57: uint16(31296), + 58: uint16(35895), + 59: uint16(40288), + 60: uint16(22256), + 61: uint16(22372), + 62: uint16(23825), + 63: uint16(26118), + 64: uint16(26801), + 65: uint16(26829), + 66: uint16(28414), + 67: uint16(29736), + 68: uint16(34974), + 69: uint16(39908), + 70: uint16(27752), + 71: uint16(63748), + 72: uint16(39592), + 73: uint16(20379), + 74: uint16(20844), + 75: uint16(20849), + 76: uint16(21151), + 77: uint16(23380), + 78: uint16(24037), + 79: uint16(24656), + 80: uint16(24685), + 81: uint16(25329), + 82: uint16(25511), + 83: uint16(25915), + 84: uint16(29657), + 85: uint16(31354), + 86: uint16(34467), + 87: uint16(36002), + 88: uint16(38799), + 89: uint16(20018), + 90: uint16(23521), + 91: uint16(25096), + 92: uint16(26524), + 93: uint16(29916), + }, + 45: { + 0: uint16(31185), + 1: uint16(33747), + 2: uint16(35463), + 3: uint16(35506), + 4: uint16(36328), + 5: uint16(36942), + 6: uint16(37707), + 7: uint16(38982), + 8: uint16(24275), + 9: uint16(27112), + 10: uint16(34303), + 11: uint16(37101), + 12: uint16(63749), + 13: uint16(20896), + 14: uint16(23448), + 15: uint16(23532), + 16: uint16(24931), + 17: uint16(26874), + 18: uint16(27454), + 19: uint16(28748), + 20: uint16(29743), + 21: uint16(29912), + 22: uint16(31649), + 23: uint16(32592), + 24: uint16(33733), + 25: uint16(35264), + 26: uint16(36011), + 27: uint16(38364), + 28: uint16(39208), + 29: uint16(21038), + 30: uint16(24669), + 31: uint16(25324), + 32: uint16(36866), + 33: uint16(20362), + 34: uint16(20809), + 35: uint16(21281), + 36: uint16(22745), + 37: uint16(24291), + 38: uint16(26336), + 39: uint16(27960), + 40: uint16(28826), + 41: uint16(29378), + 42: uint16(29654), + 43: uint16(31568), + 44: uint16(33009), + 45: uint16(37979), + 46: uint16(21350), + 47: uint16(25499), + 48: uint16(32619), + 49: uint16(20054), + 50: uint16(20608), + 51: uint16(22602), + 52: uint16(22750), + 53: uint16(24618), + 54: uint16(24871), + 55: uint16(25296), + 56: uint16(27088), + 57: uint16(39745), + 58: uint16(23439), + 59: uint16(32024), + 60: uint16(32945), + 61: uint16(36703), + 62: uint16(20132), + 63: uint16(20689), + 64: uint16(21676), + 65: uint16(21932), + 66: uint16(23308), + 67: uint16(23968), + 68: uint16(24039), + 69: uint16(25898), + 70: uint16(25934), + 71: uint16(26657), + 72: uint16(27211), + 73: uint16(29409), + 74: uint16(30350), + 75: uint16(30703), + 76: uint16(32094), + 77: uint16(32761), + 78: uint16(33184), + 79: uint16(34126), + 80: uint16(34527), + 81: uint16(36611), + 82: uint16(36686), + 83: uint16(37066), + 84: uint16(39171), + 85: uint16(39509), + 86: uint16(39851), + 87: uint16(19992), + 88: uint16(20037), + 89: uint16(20061), + 90: uint16(20167), + 91: uint16(20465), + 92: uint16(20855), + 93: uint16(21246), + }, + 46: { + 0: uint16(21312), + 1: uint16(21475), + 2: uint16(21477), + 3: uint16(21646), + 4: uint16(22036), + 5: uint16(22389), + 6: uint16(22434), + 7: uint16(23495), + 8: uint16(23943), + 9: uint16(24272), + 10: uint16(25084), + 11: uint16(25304), + 12: uint16(25937), + 13: uint16(26552), + 14: uint16(26601), + 15: uint16(27083), + 16: uint16(27472), + 17: uint16(27590), + 18: uint16(27628), + 19: uint16(27714), + 20: uint16(28317), + 21: uint16(28792), + 22: uint16(29399), + 23: uint16(29590), + 24: uint16(29699), + 25: uint16(30655), + 26: uint16(30697), + 27: uint16(31350), + 28: uint16(32127), + 29: uint16(32777), + 30: uint16(33276), + 31: uint16(33285), + 32: uint16(33290), + 33: uint16(33503), + 34: uint16(34914), + 35: uint16(35635), + 36: uint16(36092), + 37: uint16(36544), + 38: uint16(36881), + 39: uint16(37041), + 40: uint16(37476), + 41: uint16(37558), + 42: uint16(39378), + 43: uint16(39493), + 44: uint16(40169), + 45: uint16(40407), + 46: uint16(40860), + 47: uint16(22283), + 48: uint16(23616), + 49: uint16(33738), + 50: uint16(38816), + 51: uint16(38827), + 52: uint16(40628), + 53: uint16(21531), + 54: uint16(31384), + 55: uint16(32676), + 56: uint16(35033), + 57: uint16(36557), + 58: uint16(37089), + 59: uint16(22528), + 60: uint16(23624), + 61: uint16(25496), + 62: uint16(31391), + 63: uint16(23470), + 64: uint16(24339), + 65: uint16(31353), + 66: uint16(31406), + 67: uint16(33422), + 68: uint16(36524), + 69: uint16(20518), + 70: uint16(21048), + 71: uint16(21240), + 72: uint16(21367), + 73: uint16(22280), + 74: uint16(25331), + 75: uint16(25458), + 76: uint16(27402), + 77: uint16(28099), + 78: uint16(30519), + 79: uint16(21413), + 80: uint16(29527), + 81: uint16(34152), + 82: uint16(36470), + 83: uint16(38357), + 84: uint16(26426), + 85: uint16(27331), + 86: uint16(28528), + 87: uint16(35437), + 88: uint16(36556), + 89: uint16(39243), + 90: uint16(63750), + 91: uint16(26231), + 92: uint16(27512), + 93: uint16(36020), + }, + 47: { + 0: uint16(39740), + 1: uint16(63751), + 2: uint16(21483), + 3: uint16(22317), + 4: uint16(22862), + 5: uint16(25542), + 6: uint16(27131), + 7: uint16(29674), + 8: uint16(30789), + 9: uint16(31418), + 10: uint16(31429), + 11: uint16(31998), + 12: uint16(33909), + 13: uint16(35215), + 14: uint16(36211), + 15: uint16(36917), + 16: uint16(38312), + 17: uint16(21243), + 18: uint16(22343), + 19: uint16(30023), + 20: uint16(31584), + 21: uint16(33740), + 22: uint16(37406), + 23: uint16(63752), + 24: uint16(27224), + 25: uint16(20811), + 26: uint16(21067), + 27: uint16(21127), + 28: uint16(25119), + 29: uint16(26840), + 30: uint16(26997), + 31: uint16(38553), + 32: uint16(20677), + 33: uint16(21156), + 34: uint16(21220), + 35: uint16(25027), + 36: uint16(26020), + 37: uint16(26681), + 38: uint16(27135), + 39: uint16(29822), + 40: uint16(31563), + 41: uint16(33465), + 42: uint16(33771), + 43: uint16(35250), + 44: uint16(35641), + 45: uint16(36817), + 46: uint16(39241), + 47: uint16(63753), + 48: uint16(20170), + 49: uint16(22935), + 50: uint16(25810), + 51: uint16(26129), + 52: uint16(27278), + 53: uint16(29748), + 54: uint16(31105), + 55: uint16(31165), + 56: uint16(33449), + 57: uint16(34942), + 58: uint16(34943), + 59: uint16(35167), + 60: uint16(63754), + 61: uint16(37670), + 62: uint16(20235), + 63: uint16(21450), + 64: uint16(24613), + 65: uint16(25201), + 66: uint16(27762), + 67: uint16(32026), + 68: uint16(32102), + 69: uint16(20120), + 70: uint16(20834), + 71: uint16(30684), + 72: uint16(32943), + 73: uint16(20225), + 74: uint16(20238), + 75: uint16(20854), + 76: uint16(20864), + 77: uint16(21980), + 78: uint16(22120), + 79: uint16(22331), + 80: uint16(22522), + 81: uint16(22524), + 82: uint16(22804), + 83: uint16(22855), + 84: uint16(22931), + 85: uint16(23492), + 86: uint16(23696), + 87: uint16(23822), + 88: uint16(24049), + 89: uint16(24190), + 90: uint16(24524), + 91: uint16(25216), + 92: uint16(26071), + 93: uint16(26083), + }, + 48: { + 0: uint16(26398), + 1: uint16(26399), + 2: uint16(26462), + 3: uint16(26827), + 4: uint16(26820), + 5: uint16(27231), + 6: uint16(27450), + 7: uint16(27683), + 8: uint16(27773), + 9: uint16(27778), + 10: uint16(28103), + 11: uint16(29592), + 12: uint16(29734), + 13: uint16(29738), + 14: uint16(29826), + 15: uint16(29859), + 16: uint16(30072), + 17: uint16(30079), + 18: uint16(30849), + 19: uint16(30959), + 20: uint16(31041), + 21: uint16(31047), + 22: uint16(31048), + 23: uint16(31098), + 24: uint16(31637), + 25: uint16(32000), + 26: uint16(32186), + 27: uint16(32648), + 28: uint16(32774), + 29: uint16(32813), + 30: uint16(32908), + 31: uint16(35352), + 32: uint16(35663), + 33: uint16(35912), + 34: uint16(36215), + 35: uint16(37665), + 36: uint16(37668), + 37: uint16(39138), + 38: uint16(39249), + 39: uint16(39438), + 40: uint16(39439), + 41: uint16(39525), + 42: uint16(40594), + 43: uint16(32202), + 44: uint16(20342), + 45: uint16(21513), + 46: uint16(25326), + 47: uint16(26708), + 48: uint16(37329), + 49: uint16(21931), + 50: uint16(20794), + 51: uint16(63755), + 52: uint16(63756), + 53: uint16(23068), + 54: uint16(25062), + 55: uint16(63757), + 56: uint16(25295), + 57: uint16(25343), + 58: uint16(63758), + 59: uint16(63759), + 60: uint16(63760), + 61: uint16(63761), + 62: uint16(63762), + 63: uint16(63763), + 64: uint16(37027), + 65: uint16(63764), + 66: uint16(63765), + 67: uint16(63766), + 68: uint16(63767), + 69: uint16(63768), + 70: uint16(35582), + 71: uint16(63769), + 72: uint16(63770), + 73: uint16(63771), + 74: uint16(63772), + 75: uint16(26262), + 76: uint16(63773), + 77: uint16(29014), + 78: uint16(63774), + 79: uint16(63775), + 80: uint16(38627), + 81: uint16(63776), + 82: uint16(25423), + 83: uint16(25466), + 84: uint16(21335), + 85: uint16(63777), + 86: uint16(26511), + 87: uint16(26976), + 88: uint16(28275), + 89: uint16(63778), + 90: uint16(30007), + 91: uint16(63779), + 92: uint16(63780), + 93: uint16(63781), + }, + 49: { + 0: uint16(32013), + 1: uint16(63782), + 2: uint16(63783), + 3: uint16(34930), + 4: uint16(22218), + 5: uint16(23064), + 6: uint16(63784), + 7: uint16(63785), + 8: uint16(63786), + 9: uint16(63787), + 10: uint16(63788), + 11: uint16(20035), + 12: uint16(63789), + 13: uint16(20839), + 14: uint16(22856), + 15: uint16(26608), + 16: uint16(32784), + 17: uint16(63790), + 18: uint16(22899), + 19: uint16(24180), + 20: uint16(25754), + 21: uint16(31178), + 22: uint16(24565), + 23: uint16(24684), + 24: uint16(25288), + 25: uint16(25467), + 26: uint16(23527), + 27: uint16(23511), + 28: uint16(21162), + 29: uint16(63791), + 30: uint16(22900), + 31: uint16(24361), + 32: uint16(24594), + 33: uint16(63792), + 34: uint16(63793), + 35: uint16(63794), + 36: uint16(29785), + 37: uint16(63795), + 38: uint16(63796), + 39: uint16(63797), + 40: uint16(63798), + 41: uint16(63799), + 42: uint16(63800), + 43: uint16(39377), + 44: uint16(63801), + 45: uint16(63802), + 46: uint16(63803), + 47: uint16(63804), + 48: uint16(63805), + 49: uint16(63806), + 50: uint16(63807), + 51: uint16(63808), + 52: uint16(63809), + 53: uint16(63810), + 54: uint16(63811), + 55: uint16(28611), + 56: uint16(63812), + 57: uint16(63813), + 58: uint16(33215), + 59: uint16(36786), + 60: uint16(24817), + 61: uint16(63814), + 62: uint16(63815), + 63: uint16(33126), + 64: uint16(63816), + 65: uint16(63817), + 66: uint16(23615), + 67: uint16(63818), + 68: uint16(63819), + 69: uint16(63820), + 70: uint16(63821), + 71: uint16(63822), + 72: uint16(63823), + 73: uint16(63824), + 74: uint16(63825), + 75: uint16(23273), + 76: uint16(35365), + 77: uint16(26491), + 78: uint16(32016), + 79: uint16(63826), + 80: uint16(63827), + 81: uint16(63828), + 82: uint16(63829), + 83: uint16(63830), + 84: uint16(63831), + 85: uint16(33021), + 86: uint16(63832), + 87: uint16(63833), + 88: uint16(23612), + 89: uint16(27877), + 90: uint16(21311), + 91: uint16(28346), + 92: uint16(22810), + 93: uint16(33590), + }, + 50: { + 0: uint16(20025), + 1: uint16(20150), + 2: uint16(20294), + 3: uint16(21934), + 4: uint16(22296), + 5: uint16(22727), + 6: uint16(24406), + 7: uint16(26039), + 8: uint16(26086), + 9: uint16(27264), + 10: uint16(27573), + 11: uint16(28237), + 12: uint16(30701), + 13: uint16(31471), + 14: uint16(31774), + 15: uint16(32222), + 16: uint16(34507), + 17: uint16(34962), + 18: uint16(37170), + 19: uint16(37723), + 20: uint16(25787), + 21: uint16(28606), + 22: uint16(29562), + 23: uint16(30136), + 24: uint16(36948), + 25: uint16(21846), + 26: uint16(22349), + 27: uint16(25018), + 28: uint16(25812), + 29: uint16(26311), + 30: uint16(28129), + 31: uint16(28251), + 32: uint16(28525), + 33: uint16(28601), + 34: uint16(30192), + 35: uint16(32835), + 36: uint16(33213), + 37: uint16(34113), + 38: uint16(35203), + 39: uint16(35527), + 40: uint16(35674), + 41: uint16(37663), + 42: uint16(27795), + 43: uint16(30035), + 44: uint16(31572), + 45: uint16(36367), + 46: uint16(36957), + 47: uint16(21776), + 48: uint16(22530), + 49: uint16(22616), + 50: uint16(24162), + 51: uint16(25095), + 52: uint16(25758), + 53: uint16(26848), + 54: uint16(30070), + 55: uint16(31958), + 56: uint16(34739), + 57: uint16(40680), + 58: uint16(20195), + 59: uint16(22408), + 60: uint16(22382), + 61: uint16(22823), + 62: uint16(23565), + 63: uint16(23729), + 64: uint16(24118), + 65: uint16(24453), + 66: uint16(25140), + 67: uint16(25825), + 68: uint16(29619), + 69: uint16(33274), + 70: uint16(34955), + 71: uint16(36024), + 72: uint16(38538), + 73: uint16(40667), + 74: uint16(23429), + 75: uint16(24503), + 76: uint16(24755), + 77: uint16(20498), + 78: uint16(20992), + 79: uint16(21040), + 80: uint16(22294), + 81: uint16(22581), + 82: uint16(22615), + 83: uint16(23566), + 84: uint16(23648), + 85: uint16(23798), + 86: uint16(23947), + 87: uint16(24230), + 88: uint16(24466), + 89: uint16(24764), + 90: uint16(25361), + 91: uint16(25481), + 92: uint16(25623), + 93: uint16(26691), + }, + 51: { + 0: uint16(26873), + 1: uint16(27330), + 2: uint16(28120), + 3: uint16(28193), + 4: uint16(28372), + 5: uint16(28644), + 6: uint16(29182), + 7: uint16(30428), + 8: uint16(30585), + 9: uint16(31153), + 10: uint16(31291), + 11: uint16(33796), + 12: uint16(35241), + 13: uint16(36077), + 14: uint16(36339), + 15: uint16(36424), + 16: uint16(36867), + 17: uint16(36884), + 18: uint16(36947), + 19: uint16(37117), + 20: uint16(37709), + 21: uint16(38518), + 22: uint16(38876), + 23: uint16(27602), + 24: uint16(28678), + 25: uint16(29272), + 26: uint16(29346), + 27: uint16(29544), + 28: uint16(30563), + 29: uint16(31167), + 30: uint16(31716), + 31: uint16(32411), + 32: uint16(35712), + 33: uint16(22697), + 34: uint16(24775), + 35: uint16(25958), + 36: uint16(26109), + 37: uint16(26302), + 38: uint16(27788), + 39: uint16(28958), + 40: uint16(29129), + 41: uint16(35930), + 42: uint16(38931), + 43: uint16(20077), + 44: uint16(31361), + 45: uint16(20189), + 46: uint16(20908), + 47: uint16(20941), + 48: uint16(21205), + 49: uint16(21516), + 50: uint16(24999), + 51: uint16(26481), + 52: uint16(26704), + 53: uint16(26847), + 54: uint16(27934), + 55: uint16(28540), + 56: uint16(30140), + 57: uint16(30643), + 58: uint16(31461), + 59: uint16(33012), + 60: uint16(33891), + 61: uint16(37509), + 62: uint16(20828), + 63: uint16(26007), + 64: uint16(26460), + 65: uint16(26515), + 66: uint16(30168), + 67: uint16(31431), + 68: uint16(33651), + 69: uint16(63834), + 70: uint16(35910), + 71: uint16(36887), + 72: uint16(38957), + 73: uint16(23663), + 74: uint16(33216), + 75: uint16(33434), + 76: uint16(36929), + 77: uint16(36975), + 78: uint16(37389), + 79: uint16(24471), + 80: uint16(23965), + 81: uint16(27225), + 82: uint16(29128), + 83: uint16(30331), + 84: uint16(31561), + 85: uint16(34276), + 86: uint16(35588), + 87: uint16(37159), + 88: uint16(39472), + 89: uint16(21895), + 90: uint16(25078), + 91: uint16(63835), + 92: uint16(30313), + 93: uint16(32645), + }, + 52: { + 0: uint16(34367), + 1: uint16(34746), + 2: uint16(35064), + 3: uint16(37007), + 4: uint16(63836), + 5: uint16(27931), + 6: uint16(28889), + 7: uint16(29662), + 8: uint16(32097), + 9: uint16(33853), + 10: uint16(63837), + 11: uint16(37226), + 12: uint16(39409), + 13: uint16(63838), + 14: uint16(20098), + 15: uint16(21365), + 16: uint16(27396), + 17: uint16(27410), + 18: uint16(28734), + 19: uint16(29211), + 20: uint16(34349), + 21: uint16(40478), + 22: uint16(21068), + 23: uint16(36771), + 24: uint16(23888), + 25: uint16(25829), + 26: uint16(25900), + 27: uint16(27414), + 28: uint16(28651), + 29: uint16(31811), + 30: uint16(32412), + 31: uint16(34253), + 32: uint16(35172), + 33: uint16(35261), + 34: uint16(25289), + 35: uint16(33240), + 36: uint16(34847), + 37: uint16(24266), + 38: uint16(26391), + 39: uint16(28010), + 40: uint16(29436), + 41: uint16(29701), + 42: uint16(29807), + 43: uint16(34690), + 44: uint16(37086), + 45: uint16(20358), + 46: uint16(23821), + 47: uint16(24480), + 48: uint16(33802), + 49: uint16(20919), + 50: uint16(25504), + 51: uint16(30053), + 52: uint16(20142), + 53: uint16(20486), + 54: uint16(20841), + 55: uint16(20937), + 56: uint16(26753), + 57: uint16(27153), + 58: uint16(31918), + 59: uint16(31921), + 60: uint16(31975), + 61: uint16(33391), + 62: uint16(35538), + 63: uint16(36635), + 64: uint16(37327), + 65: uint16(20406), + 66: uint16(20791), + 67: uint16(21237), + 68: uint16(21570), + 69: uint16(24300), + 70: uint16(24942), + 71: uint16(25150), + 72: uint16(26053), + 73: uint16(27354), + 74: uint16(28670), + 75: uint16(31018), + 76: uint16(34268), + 77: uint16(34851), + 78: uint16(38317), + 79: uint16(39522), + 80: uint16(39530), + 81: uint16(40599), + 82: uint16(40654), + 83: uint16(21147), + 84: uint16(26310), + 85: uint16(27511), + 86: uint16(28701), + 87: uint16(31019), + 88: uint16(36706), + 89: uint16(38722), + 90: uint16(24976), + 91: uint16(25088), + 92: uint16(25891), + 93: uint16(28451), + }, + 53: { + 0: uint16(29001), + 1: uint16(29833), + 2: uint16(32244), + 3: uint16(32879), + 4: uint16(34030), + 5: uint16(36646), + 6: uint16(36899), + 7: uint16(37706), + 8: uint16(20925), + 9: uint16(21015), + 10: uint16(21155), + 11: uint16(27916), + 12: uint16(28872), + 13: uint16(35010), + 14: uint16(24265), + 15: uint16(25986), + 16: uint16(27566), + 17: uint16(28610), + 18: uint16(31806), + 19: uint16(29557), + 20: uint16(20196), + 21: uint16(20278), + 22: uint16(22265), + 23: uint16(63839), + 24: uint16(23738), + 25: uint16(23994), + 26: uint16(24604), + 27: uint16(29618), + 28: uint16(31533), + 29: uint16(32666), + 30: uint16(32718), + 31: uint16(32838), + 32: uint16(36894), + 33: uint16(37428), + 34: uint16(38646), + 35: uint16(38728), + 36: uint16(38936), + 37: uint16(40801), + 38: uint16(20363), + 39: uint16(28583), + 40: uint16(31150), + 41: uint16(37300), + 42: uint16(38583), + 43: uint16(21214), + 44: uint16(63840), + 45: uint16(25736), + 46: uint16(25796), + 47: uint16(27347), + 48: uint16(28510), + 49: uint16(28696), + 50: uint16(29200), + 51: uint16(30439), + 52: uint16(32769), + 53: uint16(34310), + 54: uint16(34396), + 55: uint16(36335), + 56: uint16(36613), + 57: uint16(38706), + 58: uint16(39791), + 59: uint16(40442), + 60: uint16(40565), + 61: uint16(30860), + 62: uint16(31103), + 63: uint16(32160), + 64: uint16(33737), + 65: uint16(37636), + 66: uint16(40575), + 67: uint16(40595), + 68: uint16(35542), + 69: uint16(22751), + 70: uint16(24324), + 71: uint16(26407), + 72: uint16(28711), + 73: uint16(29903), + 74: uint16(31840), + 75: uint16(32894), + 76: uint16(20769), + 77: uint16(28712), + 78: uint16(29282), + 79: uint16(30922), + 80: uint16(36034), + 81: uint16(36058), + 82: uint16(36084), + 83: uint16(38647), + 84: uint16(20102), + 85: uint16(20698), + 86: uint16(23534), + 87: uint16(24278), + 88: uint16(26009), + 89: uint16(29134), + 90: uint16(30274), + 91: uint16(30637), + 92: uint16(32842), + 93: uint16(34044), + }, + 54: { + 0: uint16(36988), + 1: uint16(39719), + 2: uint16(40845), + 3: uint16(22744), + 4: uint16(23105), + 5: uint16(23650), + 6: uint16(27155), + 7: uint16(28122), + 8: uint16(28431), + 9: uint16(30267), + 10: uint16(32047), + 11: uint16(32311), + 12: uint16(34078), + 13: uint16(35128), + 14: uint16(37860), + 15: uint16(38475), + 16: uint16(21129), + 17: uint16(26066), + 18: uint16(26611), + 19: uint16(27060), + 20: uint16(27969), + 21: uint16(28316), + 22: uint16(28687), + 23: uint16(29705), + 24: uint16(29792), + 25: uint16(30041), + 26: uint16(30244), + 27: uint16(30827), + 28: uint16(35628), + 29: uint16(39006), + 30: uint16(20845), + 31: uint16(25134), + 32: uint16(38520), + 33: uint16(20374), + 34: uint16(20523), + 35: uint16(23833), + 36: uint16(28138), + 37: uint16(32184), + 38: uint16(36650), + 39: uint16(24459), + 40: uint16(24900), + 41: uint16(26647), + 42: uint16(63841), + 43: uint16(38534), + 44: uint16(21202), + 45: uint16(32907), + 46: uint16(20956), + 47: uint16(20940), + 48: uint16(26974), + 49: uint16(31260), + 50: uint16(32190), + 51: uint16(33777), + 52: uint16(38517), + 53: uint16(20442), + 54: uint16(21033), + 55: uint16(21400), + 56: uint16(21519), + 57: uint16(21774), + 58: uint16(23653), + 59: uint16(24743), + 60: uint16(26446), + 61: uint16(26792), + 62: uint16(28012), + 63: uint16(29313), + 64: uint16(29432), + 65: uint16(29702), + 66: uint16(29827), + 67: uint16(63842), + 68: uint16(30178), + 69: uint16(31852), + 70: uint16(32633), + 71: uint16(32696), + 72: uint16(33673), + 73: uint16(35023), + 74: uint16(35041), + 75: uint16(37324), + 76: uint16(37328), + 77: uint16(38626), + 78: uint16(39881), + 79: uint16(21533), + 80: uint16(28542), + 81: uint16(29136), + 82: uint16(29848), + 83: uint16(34298), + 84: uint16(36522), + 85: uint16(38563), + 86: uint16(40023), + 87: uint16(40607), + 88: uint16(26519), + 89: uint16(28107), + 90: uint16(29747), + 91: uint16(33256), + 92: uint16(38678), + 93: uint16(30764), + }, + 55: { + 0: uint16(31435), + 1: uint16(31520), + 2: uint16(31890), + 3: uint16(25705), + 4: uint16(29802), + 5: uint16(30194), + 6: uint16(30908), + 7: uint16(30952), + 8: uint16(39340), + 9: uint16(39764), + 10: uint16(40635), + 11: uint16(23518), + 12: uint16(24149), + 13: uint16(28448), + 14: uint16(33180), + 15: uint16(33707), + 16: uint16(37000), + 17: uint16(19975), + 18: uint16(21325), + 19: uint16(23081), + 20: uint16(24018), + 21: uint16(24398), + 22: uint16(24930), + 23: uint16(25405), + 24: uint16(26217), + 25: uint16(26364), + 26: uint16(28415), + 27: uint16(28459), + 28: uint16(28771), + 29: uint16(30622), + 30: uint16(33836), + 31: uint16(34067), + 32: uint16(34875), + 33: uint16(36627), + 34: uint16(39237), + 35: uint16(39995), + 36: uint16(21788), + 37: uint16(25273), + 38: uint16(26411), + 39: uint16(27819), + 40: uint16(33545), + 41: uint16(35178), + 42: uint16(38778), + 43: uint16(20129), + 44: uint16(22916), + 45: uint16(24536), + 46: uint16(24537), + 47: uint16(26395), + 48: uint16(32178), + 49: uint16(32596), + 50: uint16(33426), + 51: uint16(33579), + 52: uint16(33725), + 53: uint16(36638), + 54: uint16(37017), + 55: uint16(22475), + 56: uint16(22969), + 57: uint16(23186), + 58: uint16(23504), + 59: uint16(26151), + 60: uint16(26522), + 61: uint16(26757), + 62: uint16(27599), + 63: uint16(29028), + 64: uint16(32629), + 65: uint16(36023), + 66: uint16(36067), + 67: uint16(36993), + 68: uint16(39749), + 69: uint16(33032), + 70: uint16(35978), + 71: uint16(38476), + 72: uint16(39488), + 73: uint16(40613), + 74: uint16(23391), + 75: uint16(27667), + 76: uint16(29467), + 77: uint16(30450), + 78: uint16(30431), + 79: uint16(33804), + 80: uint16(20906), + 81: uint16(35219), + 82: uint16(20813), + 83: uint16(20885), + 84: uint16(21193), + 85: uint16(26825), + 86: uint16(27796), + 87: uint16(30468), + 88: uint16(30496), + 89: uint16(32191), + 90: uint16(32236), + 91: uint16(38754), + 92: uint16(40629), + 93: uint16(28357), + }, + 56: { + 0: uint16(34065), + 1: uint16(20901), + 2: uint16(21517), + 3: uint16(21629), + 4: uint16(26126), + 5: uint16(26269), + 6: uint16(26919), + 7: uint16(28319), + 8: uint16(30399), + 9: uint16(30609), + 10: uint16(33559), + 11: uint16(33986), + 12: uint16(34719), + 13: uint16(37225), + 14: uint16(37528), + 15: uint16(40180), + 16: uint16(34946), + 17: uint16(20398), + 18: uint16(20882), + 19: uint16(21215), + 20: uint16(22982), + 21: uint16(24125), + 22: uint16(24917), + 23: uint16(25720), + 24: uint16(25721), + 25: uint16(26286), + 26: uint16(26576), + 27: uint16(27169), + 28: uint16(27597), + 29: uint16(27611), + 30: uint16(29279), + 31: uint16(29281), + 32: uint16(29761), + 33: uint16(30520), + 34: uint16(30683), + 35: uint16(32791), + 36: uint16(33468), + 37: uint16(33541), + 38: uint16(35584), + 39: uint16(35624), + 40: uint16(35980), + 41: uint16(26408), + 42: uint16(27792), + 43: uint16(29287), + 44: uint16(30446), + 45: uint16(30566), + 46: uint16(31302), + 47: uint16(40361), + 48: uint16(27519), + 49: uint16(27794), + 50: uint16(22818), + 51: uint16(26406), + 52: uint16(33945), + 53: uint16(21359), + 54: uint16(22675), + 55: uint16(22937), + 56: uint16(24287), + 57: uint16(25551), + 58: uint16(26164), + 59: uint16(26483), + 60: uint16(28218), + 61: uint16(29483), + 62: uint16(31447), + 63: uint16(33495), + 64: uint16(37672), + 65: uint16(21209), + 66: uint16(24043), + 67: uint16(25006), + 68: uint16(25035), + 69: uint16(25098), + 70: uint16(25287), + 71: uint16(25771), + 72: uint16(26080), + 73: uint16(26969), + 74: uint16(27494), + 75: uint16(27595), + 76: uint16(28961), + 77: uint16(29687), + 78: uint16(30045), + 79: uint16(32326), + 80: uint16(33310), + 81: uint16(33538), + 82: uint16(34154), + 83: uint16(35491), + 84: uint16(36031), + 85: uint16(38695), + 86: uint16(40289), + 87: uint16(22696), + 88: uint16(40664), + 89: uint16(20497), + 90: uint16(21006), + 91: uint16(21563), + 92: uint16(21839), + 93: uint16(25991), + }, + 57: { + 0: uint16(27766), + 1: uint16(32010), + 2: uint16(32011), + 3: uint16(32862), + 4: uint16(34442), + 5: uint16(38272), + 6: uint16(38639), + 7: uint16(21247), + 8: uint16(27797), + 9: uint16(29289), + 10: uint16(21619), + 11: uint16(23194), + 12: uint16(23614), + 13: uint16(23883), + 14: uint16(24396), + 15: uint16(24494), + 16: uint16(26410), + 17: uint16(26806), + 18: uint16(26979), + 19: uint16(28220), + 20: uint16(28228), + 21: uint16(30473), + 22: uint16(31859), + 23: uint16(32654), + 24: uint16(34183), + 25: uint16(35598), + 26: uint16(36855), + 27: uint16(38753), + 28: uint16(40692), + 29: uint16(23735), + 30: uint16(24758), + 31: uint16(24845), + 32: uint16(25003), + 33: uint16(25935), + 34: uint16(26107), + 35: uint16(26108), + 36: uint16(27665), + 37: uint16(27887), + 38: uint16(29599), + 39: uint16(29641), + 40: uint16(32225), + 41: uint16(38292), + 42: uint16(23494), + 43: uint16(34588), + 44: uint16(35600), + 45: uint16(21085), + 46: uint16(21338), + 47: uint16(25293), + 48: uint16(25615), + 49: uint16(25778), + 50: uint16(26420), + 51: uint16(27192), + 52: uint16(27850), + 53: uint16(29632), + 54: uint16(29854), + 55: uint16(31636), + 56: uint16(31893), + 57: uint16(32283), + 58: uint16(33162), + 59: uint16(33334), + 60: uint16(34180), + 61: uint16(36843), + 62: uint16(38649), + 63: uint16(39361), + 64: uint16(20276), + 65: uint16(21322), + 66: uint16(21453), + 67: uint16(21467), + 68: uint16(25292), + 69: uint16(25644), + 70: uint16(25856), + 71: uint16(26001), + 72: uint16(27075), + 73: uint16(27886), + 74: uint16(28504), + 75: uint16(29677), + 76: uint16(30036), + 77: uint16(30242), + 78: uint16(30436), + 79: uint16(30460), + 80: uint16(30928), + 81: uint16(30971), + 82: uint16(31020), + 83: uint16(32070), + 84: uint16(33324), + 85: uint16(34784), + 86: uint16(36820), + 87: uint16(38930), + 88: uint16(39151), + 89: uint16(21187), + 90: uint16(25300), + 91: uint16(25765), + 92: uint16(28196), + 93: uint16(28497), + }, + 58: { + 0: uint16(30332), + 1: uint16(36299), + 2: uint16(37297), + 3: uint16(37474), + 4: uint16(39662), + 5: uint16(39747), + 6: uint16(20515), + 7: uint16(20621), + 8: uint16(22346), + 9: uint16(22952), + 10: uint16(23592), + 11: uint16(24135), + 12: uint16(24439), + 13: uint16(25151), + 14: uint16(25918), + 15: uint16(26041), + 16: uint16(26049), + 17: uint16(26121), + 18: uint16(26507), + 19: uint16(27036), + 20: uint16(28354), + 21: uint16(30917), + 22: uint16(32033), + 23: uint16(32938), + 24: uint16(33152), + 25: uint16(33323), + 26: uint16(33459), + 27: uint16(33953), + 28: uint16(34444), + 29: uint16(35370), + 30: uint16(35607), + 31: uint16(37030), + 32: uint16(38450), + 33: uint16(40848), + 34: uint16(20493), + 35: uint16(20467), + 36: uint16(63843), + 37: uint16(22521), + 38: uint16(24472), + 39: uint16(25308), + 40: uint16(25490), + 41: uint16(26479), + 42: uint16(28227), + 43: uint16(28953), + 44: uint16(30403), + 45: uint16(32972), + 46: uint16(32986), + 47: uint16(35060), + 48: uint16(35061), + 49: uint16(35097), + 50: uint16(36064), + 51: uint16(36649), + 52: uint16(37197), + 53: uint16(38506), + 54: uint16(20271), + 55: uint16(20336), + 56: uint16(24091), + 57: uint16(26575), + 58: uint16(26658), + 59: uint16(30333), + 60: uint16(30334), + 61: uint16(39748), + 62: uint16(24161), + 63: uint16(27146), + 64: uint16(29033), + 65: uint16(29140), + 66: uint16(30058), + 67: uint16(63844), + 68: uint16(32321), + 69: uint16(34115), + 70: uint16(34281), + 71: uint16(39132), + 72: uint16(20240), + 73: uint16(31567), + 74: uint16(32624), + 75: uint16(38309), + 76: uint16(20961), + 77: uint16(24070), + 78: uint16(26805), + 79: uint16(27710), + 80: uint16(27726), + 81: uint16(27867), + 82: uint16(29359), + 83: uint16(31684), + 84: uint16(33539), + 85: uint16(27861), + 86: uint16(29754), + 87: uint16(20731), + 88: uint16(21128), + 89: uint16(22721), + 90: uint16(25816), + 91: uint16(27287), + 92: uint16(29863), + 93: uint16(30294), + }, + 59: { + 0: uint16(30887), + 1: uint16(34327), + 2: uint16(38370), + 3: uint16(38713), + 4: uint16(63845), + 5: uint16(21342), + 6: uint16(24321), + 7: uint16(35722), + 8: uint16(36776), + 9: uint16(36783), + 10: uint16(37002), + 11: uint16(21029), + 12: uint16(30629), + 13: uint16(40009), + 14: uint16(40712), + 15: uint16(19993), + 16: uint16(20482), + 17: uint16(20853), + 18: uint16(23643), + 19: uint16(24183), + 20: uint16(26142), + 21: uint16(26170), + 22: uint16(26564), + 23: uint16(26821), + 24: uint16(28851), + 25: uint16(29953), + 26: uint16(30149), + 27: uint16(31177), + 28: uint16(31453), + 29: uint16(36647), + 30: uint16(39200), + 31: uint16(39432), + 32: uint16(20445), + 33: uint16(22561), + 34: uint16(22577), + 35: uint16(23542), + 36: uint16(26222), + 37: uint16(27493), + 38: uint16(27921), + 39: uint16(28282), + 40: uint16(28541), + 41: uint16(29668), + 42: uint16(29995), + 43: uint16(33769), + 44: uint16(35036), + 45: uint16(35091), + 46: uint16(35676), + 47: uint16(36628), + 48: uint16(20239), + 49: uint16(20693), + 50: uint16(21264), + 51: uint16(21340), + 52: uint16(23443), + 53: uint16(24489), + 54: uint16(26381), + 55: uint16(31119), + 56: uint16(33145), + 57: uint16(33583), + 58: uint16(34068), + 59: uint16(35079), + 60: uint16(35206), + 61: uint16(36665), + 62: uint16(36667), + 63: uint16(39333), + 64: uint16(39954), + 65: uint16(26412), + 66: uint16(20086), + 67: uint16(20472), + 68: uint16(22857), + 69: uint16(23553), + 70: uint16(23791), + 71: uint16(23792), + 72: uint16(25447), + 73: uint16(26834), + 74: uint16(28925), + 75: uint16(29090), + 76: uint16(29739), + 77: uint16(32299), + 78: uint16(34028), + 79: uint16(34562), + 80: uint16(36898), + 81: uint16(37586), + 82: uint16(40179), + 83: uint16(19981), + 84: uint16(20184), + 85: uint16(20463), + 86: uint16(20613), + 87: uint16(21078), + 88: uint16(21103), + 89: uint16(21542), + 90: uint16(21648), + 91: uint16(22496), + 92: uint16(22827), + 93: uint16(23142), + }, + 60: { + 0: uint16(23386), + 1: uint16(23413), + 2: uint16(23500), + 3: uint16(24220), + 4: uint16(63846), + 5: uint16(25206), + 6: uint16(25975), + 7: uint16(26023), + 8: uint16(28014), + 9: uint16(28325), + 10: uint16(29238), + 11: uint16(31526), + 12: uint16(31807), + 13: uint16(32566), + 14: uint16(33104), + 15: uint16(33105), + 16: uint16(33178), + 17: uint16(33344), + 18: uint16(33433), + 19: uint16(33705), + 20: uint16(35331), + 21: uint16(36000), + 22: uint16(36070), + 23: uint16(36091), + 24: uint16(36212), + 25: uint16(36282), + 26: uint16(37096), + 27: uint16(37340), + 28: uint16(38428), + 29: uint16(38468), + 30: uint16(39385), + 31: uint16(40167), + 32: uint16(21271), + 33: uint16(20998), + 34: uint16(21545), + 35: uint16(22132), + 36: uint16(22707), + 37: uint16(22868), + 38: uint16(22894), + 39: uint16(24575), + 40: uint16(24996), + 41: uint16(25198), + 42: uint16(26128), + 43: uint16(27774), + 44: uint16(28954), + 45: uint16(30406), + 46: uint16(31881), + 47: uint16(31966), + 48: uint16(32027), + 49: uint16(33452), + 50: uint16(36033), + 51: uint16(38640), + 52: uint16(63847), + 53: uint16(20315), + 54: uint16(24343), + 55: uint16(24447), + 56: uint16(25282), + 57: uint16(23849), + 58: uint16(26379), + 59: uint16(26842), + 60: uint16(30844), + 61: uint16(32323), + 62: uint16(40300), + 63: uint16(19989), + 64: uint16(20633), + 65: uint16(21269), + 66: uint16(21290), + 67: uint16(21329), + 68: uint16(22915), + 69: uint16(23138), + 70: uint16(24199), + 71: uint16(24754), + 72: uint16(24970), + 73: uint16(25161), + 74: uint16(25209), + 75: uint16(26000), + 76: uint16(26503), + 77: uint16(27047), + 78: uint16(27604), + 79: uint16(27606), + 80: uint16(27607), + 81: uint16(27608), + 82: uint16(27832), + 83: uint16(63848), + 84: uint16(29749), + 85: uint16(30202), + 86: uint16(30738), + 87: uint16(30865), + 88: uint16(31189), + 89: uint16(31192), + 90: uint16(31875), + 91: uint16(32203), + 92: uint16(32737), + 93: uint16(32933), + }, + 61: { + 0: uint16(33086), + 1: uint16(33218), + 2: uint16(33778), + 3: uint16(34586), + 4: uint16(35048), + 5: uint16(35513), + 6: uint16(35692), + 7: uint16(36027), + 8: uint16(37145), + 9: uint16(38750), + 10: uint16(39131), + 11: uint16(40763), + 12: uint16(22188), + 13: uint16(23338), + 14: uint16(24428), + 15: uint16(25996), + 16: uint16(27315), + 17: uint16(27567), + 18: uint16(27996), + 19: uint16(28657), + 20: uint16(28693), + 21: uint16(29277), + 22: uint16(29613), + 23: uint16(36007), + 24: uint16(36051), + 25: uint16(38971), + 26: uint16(24977), + 27: uint16(27703), + 28: uint16(32856), + 29: uint16(39425), + 30: uint16(20045), + 31: uint16(20107), + 32: uint16(20123), + 33: uint16(20181), + 34: uint16(20282), + 35: uint16(20284), + 36: uint16(20351), + 37: uint16(20447), + 38: uint16(20735), + 39: uint16(21490), + 40: uint16(21496), + 41: uint16(21766), + 42: uint16(21987), + 43: uint16(22235), + 44: uint16(22763), + 45: uint16(22882), + 46: uint16(23057), + 47: uint16(23531), + 48: uint16(23546), + 49: uint16(23556), + 50: uint16(24051), + 51: uint16(24107), + 52: uint16(24473), + 53: uint16(24605), + 54: uint16(25448), + 55: uint16(26012), + 56: uint16(26031), + 57: uint16(26614), + 58: uint16(26619), + 59: uint16(26797), + 60: uint16(27515), + 61: uint16(27801), + 62: uint16(27863), + 63: uint16(28195), + 64: uint16(28681), + 65: uint16(29509), + 66: uint16(30722), + 67: uint16(31038), + 68: uint16(31040), + 69: uint16(31072), + 70: uint16(31169), + 71: uint16(31721), + 72: uint16(32023), + 73: uint16(32114), + 74: uint16(32902), + 75: uint16(33293), + 76: uint16(33678), + 77: uint16(34001), + 78: uint16(34503), + 79: uint16(35039), + 80: uint16(35408), + 81: uint16(35422), + 82: uint16(35613), + 83: uint16(36060), + 84: uint16(36198), + 85: uint16(36781), + 86: uint16(37034), + 87: uint16(39164), + 88: uint16(39391), + 89: uint16(40605), + 90: uint16(21066), + 91: uint16(63849), + 92: uint16(26388), + 93: uint16(63850), + }, + 62: { + 0: uint16(20632), + 1: uint16(21034), + 2: uint16(23665), + 3: uint16(25955), + 4: uint16(27733), + 5: uint16(29642), + 6: uint16(29987), + 7: uint16(30109), + 8: uint16(31639), + 9: uint16(33948), + 10: uint16(37240), + 11: uint16(38704), + 12: uint16(20087), + 13: uint16(25746), + 14: uint16(27578), + 15: uint16(29022), + 16: uint16(34217), + 17: uint16(19977), + 18: uint16(63851), + 19: uint16(26441), + 20: uint16(26862), + 21: uint16(28183), + 22: uint16(33439), + 23: uint16(34072), + 24: uint16(34923), + 25: uint16(25591), + 26: uint16(28545), + 27: uint16(37394), + 28: uint16(39087), + 29: uint16(19978), + 30: uint16(20663), + 31: uint16(20687), + 32: uint16(20767), + 33: uint16(21830), + 34: uint16(21930), + 35: uint16(22039), + 36: uint16(23360), + 37: uint16(23577), + 38: uint16(23776), + 39: uint16(24120), + 40: uint16(24202), + 41: uint16(24224), + 42: uint16(24258), + 43: uint16(24819), + 44: uint16(26705), + 45: uint16(27233), + 46: uint16(28248), + 47: uint16(29245), + 48: uint16(29248), + 49: uint16(29376), + 50: uint16(30456), + 51: uint16(31077), + 52: uint16(31665), + 53: uint16(32724), + 54: uint16(35059), + 55: uint16(35316), + 56: uint16(35443), + 57: uint16(35937), + 58: uint16(36062), + 59: uint16(38684), + 60: uint16(22622), + 61: uint16(29885), + 62: uint16(36093), + 63: uint16(21959), + 64: uint16(63852), + 65: uint16(31329), + 66: uint16(32034), + 67: uint16(33394), + 68: uint16(29298), + 69: uint16(29983), + 70: uint16(29989), + 71: uint16(63853), + 72: uint16(31513), + 73: uint16(22661), + 74: uint16(22779), + 75: uint16(23996), + 76: uint16(24207), + 77: uint16(24246), + 78: uint16(24464), + 79: uint16(24661), + 80: uint16(25234), + 81: uint16(25471), + 82: uint16(25933), + 83: uint16(26257), + 84: uint16(26329), + 85: uint16(26360), + 86: uint16(26646), + 87: uint16(26866), + 88: uint16(29312), + 89: uint16(29790), + 90: uint16(31598), + 91: uint16(32110), + 92: uint16(32214), + 93: uint16(32626), + }, + 63: { + 0: uint16(32997), + 1: uint16(33298), + 2: uint16(34223), + 3: uint16(35199), + 4: uint16(35475), + 5: uint16(36893), + 6: uint16(37604), + 7: uint16(40653), + 8: uint16(40736), + 9: uint16(22805), + 10: uint16(22893), + 11: uint16(24109), + 12: uint16(24796), + 13: uint16(26132), + 14: uint16(26227), + 15: uint16(26512), + 16: uint16(27728), + 17: uint16(28101), + 18: uint16(28511), + 19: uint16(30707), + 20: uint16(30889), + 21: uint16(33990), + 22: uint16(37323), + 23: uint16(37675), + 24: uint16(20185), + 25: uint16(20682), + 26: uint16(20808), + 27: uint16(21892), + 28: uint16(23307), + 29: uint16(23459), + 30: uint16(25159), + 31: uint16(25982), + 32: uint16(26059), + 33: uint16(28210), + 34: uint16(29053), + 35: uint16(29697), + 36: uint16(29764), + 37: uint16(29831), + 38: uint16(29887), + 39: uint16(30316), + 40: uint16(31146), + 41: uint16(32218), + 42: uint16(32341), + 43: uint16(32680), + 44: uint16(33146), + 45: uint16(33203), + 46: uint16(33337), + 47: uint16(34330), + 48: uint16(34796), + 49: uint16(35445), + 50: uint16(36323), + 51: uint16(36984), + 52: uint16(37521), + 53: uint16(37925), + 54: uint16(39245), + 55: uint16(39854), + 56: uint16(21352), + 57: uint16(23633), + 58: uint16(26964), + 59: uint16(27844), + 60: uint16(27945), + 61: uint16(28203), + 62: uint16(33292), + 63: uint16(34203), + 64: uint16(35131), + 65: uint16(35373), + 66: uint16(35498), + 67: uint16(38634), + 68: uint16(40807), + 69: uint16(21089), + 70: uint16(26297), + 71: uint16(27570), + 72: uint16(32406), + 73: uint16(34814), + 74: uint16(36109), + 75: uint16(38275), + 76: uint16(38493), + 77: uint16(25885), + 78: uint16(28041), + 79: uint16(29166), + 80: uint16(63854), + 81: uint16(22478), + 82: uint16(22995), + 83: uint16(23468), + 84: uint16(24615), + 85: uint16(24826), + 86: uint16(25104), + 87: uint16(26143), + 88: uint16(26207), + 89: uint16(29481), + 90: uint16(29689), + 91: uint16(30427), + 92: uint16(30465), + 93: uint16(31596), + }, + 64: { + 0: uint16(32854), + 1: uint16(32882), + 2: uint16(33125), + 3: uint16(35488), + 4: uint16(37266), + 5: uint16(19990), + 6: uint16(21218), + 7: uint16(27506), + 8: uint16(27927), + 9: uint16(31237), + 10: uint16(31545), + 11: uint16(32048), + 12: uint16(63855), + 13: uint16(36016), + 14: uint16(21484), + 15: uint16(22063), + 16: uint16(22609), + 17: uint16(23477), + 18: uint16(23567), + 19: uint16(23569), + 20: uint16(24034), + 21: uint16(25152), + 22: uint16(25475), + 23: uint16(25620), + 24: uint16(26157), + 25: uint16(26803), + 26: uint16(27836), + 27: uint16(28040), + 28: uint16(28335), + 29: uint16(28703), + 30: uint16(28836), + 31: uint16(29138), + 32: uint16(29990), + 33: uint16(30095), + 34: uint16(30094), + 35: uint16(30233), + 36: uint16(31505), + 37: uint16(31712), + 38: uint16(31787), + 39: uint16(32032), + 40: uint16(32057), + 41: uint16(34092), + 42: uint16(34157), + 43: uint16(34311), + 44: uint16(35380), + 45: uint16(36877), + 46: uint16(36961), + 47: uint16(37045), + 48: uint16(37559), + 49: uint16(38902), + 50: uint16(39479), + 51: uint16(20439), + 52: uint16(23660), + 53: uint16(26463), + 54: uint16(28049), + 55: uint16(31903), + 56: uint16(32396), + 57: uint16(35606), + 58: uint16(36118), + 59: uint16(36895), + 60: uint16(23403), + 61: uint16(24061), + 62: uint16(25613), + 63: uint16(33984), + 64: uint16(36956), + 65: uint16(39137), + 66: uint16(29575), + 67: uint16(23435), + 68: uint16(24730), + 69: uint16(26494), + 70: uint16(28126), + 71: uint16(35359), + 72: uint16(35494), + 73: uint16(36865), + 74: uint16(38924), + 75: uint16(21047), + 76: uint16(63856), + 77: uint16(28753), + 78: uint16(30862), + 79: uint16(37782), + 80: uint16(34928), + 81: uint16(37335), + 82: uint16(20462), + 83: uint16(21463), + 84: uint16(22013), + 85: uint16(22234), + 86: uint16(22402), + 87: uint16(22781), + 88: uint16(23234), + 89: uint16(23432), + 90: uint16(23723), + 91: uint16(23744), + 92: uint16(24101), + 93: uint16(24833), + }, + 65: { + 0: uint16(25101), + 1: uint16(25163), + 2: uint16(25480), + 3: uint16(25628), + 4: uint16(25910), + 5: uint16(25976), + 6: uint16(27193), + 7: uint16(27530), + 8: uint16(27700), + 9: uint16(27929), + 10: uint16(28465), + 11: uint16(29159), + 12: uint16(29417), + 13: uint16(29560), + 14: uint16(29703), + 15: uint16(29874), + 16: uint16(30246), + 17: uint16(30561), + 18: uint16(31168), + 19: uint16(31319), + 20: uint16(31466), + 21: uint16(31929), + 22: uint16(32143), + 23: uint16(32172), + 24: uint16(32353), + 25: uint16(32670), + 26: uint16(33065), + 27: uint16(33585), + 28: uint16(33936), + 29: uint16(34010), + 30: uint16(34282), + 31: uint16(34966), + 32: uint16(35504), + 33: uint16(35728), + 34: uint16(36664), + 35: uint16(36930), + 36: uint16(36995), + 37: uint16(37228), + 38: uint16(37526), + 39: uint16(37561), + 40: uint16(38539), + 41: uint16(38567), + 42: uint16(38568), + 43: uint16(38614), + 44: uint16(38656), + 45: uint16(38920), + 46: uint16(39318), + 47: uint16(39635), + 48: uint16(39706), + 49: uint16(21460), + 50: uint16(22654), + 51: uint16(22809), + 52: uint16(23408), + 53: uint16(23487), + 54: uint16(28113), + 55: uint16(28506), + 56: uint16(29087), + 57: uint16(29729), + 58: uint16(29881), + 59: uint16(32901), + 60: uint16(33789), + 61: uint16(24033), + 62: uint16(24455), + 63: uint16(24490), + 64: uint16(24642), + 65: uint16(26092), + 66: uint16(26642), + 67: uint16(26991), + 68: uint16(27219), + 69: uint16(27529), + 70: uint16(27957), + 71: uint16(28147), + 72: uint16(29667), + 73: uint16(30462), + 74: uint16(30636), + 75: uint16(31565), + 76: uint16(32020), + 77: uint16(33059), + 78: uint16(33308), + 79: uint16(33600), + 80: uint16(34036), + 81: uint16(34147), + 82: uint16(35426), + 83: uint16(35524), + 84: uint16(37255), + 85: uint16(37662), + 86: uint16(38918), + 87: uint16(39348), + 88: uint16(25100), + 89: uint16(34899), + 90: uint16(36848), + 91: uint16(37477), + 92: uint16(23815), + 93: uint16(23847), + }, + 66: { + 0: uint16(23913), + 1: uint16(29791), + 2: uint16(33181), + 3: uint16(34664), + 4: uint16(28629), + 5: uint16(25342), + 6: uint16(32722), + 7: uint16(35126), + 8: uint16(35186), + 9: uint16(19998), + 10: uint16(20056), + 11: uint16(20711), + 12: uint16(21213), + 13: uint16(21319), + 14: uint16(25215), + 15: uint16(26119), + 16: uint16(32361), + 17: uint16(34821), + 18: uint16(38494), + 19: uint16(20365), + 20: uint16(21273), + 21: uint16(22070), + 22: uint16(22987), + 23: uint16(23204), + 24: uint16(23608), + 25: uint16(23630), + 26: uint16(23629), + 27: uint16(24066), + 28: uint16(24337), + 29: uint16(24643), + 30: uint16(26045), + 31: uint16(26159), + 32: uint16(26178), + 33: uint16(26558), + 34: uint16(26612), + 35: uint16(29468), + 36: uint16(30690), + 37: uint16(31034), + 38: uint16(32709), + 39: uint16(33940), + 40: uint16(33997), + 41: uint16(35222), + 42: uint16(35430), + 43: uint16(35433), + 44: uint16(35553), + 45: uint16(35925), + 46: uint16(35962), + 47: uint16(22516), + 48: uint16(23508), + 49: uint16(24335), + 50: uint16(24687), + 51: uint16(25325), + 52: uint16(26893), + 53: uint16(27542), + 54: uint16(28252), + 55: uint16(29060), + 56: uint16(31698), + 57: uint16(34645), + 58: uint16(35672), + 59: uint16(36606), + 60: uint16(39135), + 61: uint16(39166), + 62: uint16(20280), + 63: uint16(20353), + 64: uint16(20449), + 65: uint16(21627), + 66: uint16(23072), + 67: uint16(23480), + 68: uint16(24892), + 69: uint16(26032), + 70: uint16(26216), + 71: uint16(29180), + 72: uint16(30003), + 73: uint16(31070), + 74: uint16(32051), + 75: uint16(33102), + 76: uint16(33251), + 77: uint16(33688), + 78: uint16(34218), + 79: uint16(34254), + 80: uint16(34563), + 81: uint16(35338), + 82: uint16(36523), + 83: uint16(36763), + 84: uint16(63857), + 85: uint16(36805), + 86: uint16(22833), + 87: uint16(23460), + 88: uint16(23526), + 89: uint16(24713), + 90: uint16(23529), + 91: uint16(23563), + 92: uint16(24515), + 93: uint16(27777), + }, + 67: { + 0: uint16(63858), + 1: uint16(28145), + 2: uint16(28683), + 3: uint16(29978), + 4: uint16(33455), + 5: uint16(35574), + 6: uint16(20160), + 7: uint16(21313), + 8: uint16(63859), + 9: uint16(38617), + 10: uint16(27663), + 11: uint16(20126), + 12: uint16(20420), + 13: uint16(20818), + 14: uint16(21854), + 15: uint16(23077), + 16: uint16(23784), + 17: uint16(25105), + 18: uint16(29273), + 19: uint16(33469), + 20: uint16(33706), + 21: uint16(34558), + 22: uint16(34905), + 23: uint16(35357), + 24: uint16(38463), + 25: uint16(38597), + 26: uint16(39187), + 27: uint16(40201), + 28: uint16(40285), + 29: uint16(22538), + 30: uint16(23731), + 31: uint16(23997), + 32: uint16(24132), + 33: uint16(24801), + 34: uint16(24853), + 35: uint16(25569), + 36: uint16(27138), + 37: uint16(28197), + 38: uint16(37122), + 39: uint16(37716), + 40: uint16(38990), + 41: uint16(39952), + 42: uint16(40823), + 43: uint16(23433), + 44: uint16(23736), + 45: uint16(25353), + 46: uint16(26191), + 47: uint16(26696), + 48: uint16(30524), + 49: uint16(38593), + 50: uint16(38797), + 51: uint16(38996), + 52: uint16(39839), + 53: uint16(26017), + 54: uint16(35585), + 55: uint16(36555), + 56: uint16(38332), + 57: uint16(21813), + 58: uint16(23721), + 59: uint16(24022), + 60: uint16(24245), + 61: uint16(26263), + 62: uint16(30284), + 63: uint16(33780), + 64: uint16(38343), + 65: uint16(22739), + 66: uint16(25276), + 67: uint16(29390), + 68: uint16(40232), + 69: uint16(20208), + 70: uint16(22830), + 71: uint16(24591), + 72: uint16(26171), + 73: uint16(27523), + 74: uint16(31207), + 75: uint16(40230), + 76: uint16(21395), + 77: uint16(21696), + 78: uint16(22467), + 79: uint16(23830), + 80: uint16(24859), + 81: uint16(26326), + 82: uint16(28079), + 83: uint16(30861), + 84: uint16(33406), + 85: uint16(38552), + 86: uint16(38724), + 87: uint16(21380), + 88: uint16(25212), + 89: uint16(25494), + 90: uint16(28082), + 91: uint16(32266), + 92: uint16(33099), + 93: uint16(38989), + }, + 68: { + 0: uint16(27387), + 1: uint16(32588), + 2: uint16(40367), + 3: uint16(40474), + 4: uint16(20063), + 5: uint16(20539), + 6: uint16(20918), + 7: uint16(22812), + 8: uint16(24825), + 9: uint16(25590), + 10: uint16(26928), + 11: uint16(29242), + 12: uint16(32822), + 13: uint16(63860), + 14: uint16(37326), + 15: uint16(24369), + 16: uint16(63861), + 17: uint16(63862), + 18: uint16(32004), + 19: uint16(33509), + 20: uint16(33903), + 21: uint16(33979), + 22: uint16(34277), + 23: uint16(36493), + 24: uint16(63863), + 25: uint16(20335), + 26: uint16(63864), + 27: uint16(63865), + 28: uint16(22756), + 29: uint16(23363), + 30: uint16(24665), + 31: uint16(25562), + 32: uint16(25880), + 33: uint16(25965), + 34: uint16(26264), + 35: uint16(63866), + 36: uint16(26954), + 37: uint16(27171), + 38: uint16(27915), + 39: uint16(28673), + 40: uint16(29036), + 41: uint16(30162), + 42: uint16(30221), + 43: uint16(31155), + 44: uint16(31344), + 45: uint16(63867), + 46: uint16(32650), + 47: uint16(63868), + 48: uint16(35140), + 49: uint16(63869), + 50: uint16(35731), + 51: uint16(37312), + 52: uint16(38525), + 53: uint16(63870), + 54: uint16(39178), + 55: uint16(22276), + 56: uint16(24481), + 57: uint16(26044), + 58: uint16(28417), + 59: uint16(30208), + 60: uint16(31142), + 61: uint16(35486), + 62: uint16(39341), + 63: uint16(39770), + 64: uint16(40812), + 65: uint16(20740), + 66: uint16(25014), + 67: uint16(25233), + 68: uint16(27277), + 69: uint16(33222), + 70: uint16(20547), + 71: uint16(22576), + 72: uint16(24422), + 73: uint16(28937), + 74: uint16(35328), + 75: uint16(35578), + 76: uint16(23420), + 77: uint16(34326), + 78: uint16(20474), + 79: uint16(20796), + 80: uint16(22196), + 81: uint16(22852), + 82: uint16(25513), + 83: uint16(28153), + 84: uint16(23978), + 85: uint16(26989), + 86: uint16(20870), + 87: uint16(20104), + 88: uint16(20313), + 89: uint16(63871), + 90: uint16(63872), + 91: uint16(63873), + 92: uint16(22914), + 93: uint16(63874), + }, + 69: { + 0: uint16(63875), + 1: uint16(27487), + 2: uint16(27741), + 3: uint16(63876), + 4: uint16(29877), + 5: uint16(30998), + 6: uint16(63877), + 7: uint16(33287), + 8: uint16(33349), + 9: uint16(33593), + 10: uint16(36671), + 11: uint16(36701), + 12: uint16(63878), + 13: uint16(39192), + 14: uint16(63879), + 15: uint16(63880), + 16: uint16(63881), + 17: uint16(20134), + 18: uint16(63882), + 19: uint16(22495), + 20: uint16(24441), + 21: uint16(26131), + 22: uint16(63883), + 23: uint16(63884), + 24: uint16(30123), + 25: uint16(32377), + 26: uint16(35695), + 27: uint16(63885), + 28: uint16(36870), + 29: uint16(39515), + 30: uint16(22181), + 31: uint16(22567), + 32: uint16(23032), + 33: uint16(23071), + 34: uint16(23476), + 35: uint16(63886), + 36: uint16(24310), + 37: uint16(63887), + 38: uint16(63888), + 39: uint16(25424), + 40: uint16(25403), + 41: uint16(63889), + 42: uint16(26941), + 43: uint16(27783), + 44: uint16(27839), + 45: uint16(28046), + 46: uint16(28051), + 47: uint16(28149), + 48: uint16(28436), + 49: uint16(63890), + 50: uint16(28895), + 51: uint16(28982), + 52: uint16(29017), + 53: uint16(63891), + 54: uint16(29123), + 55: uint16(29141), + 56: uint16(63892), + 57: uint16(30799), + 58: uint16(30831), + 59: uint16(63893), + 60: uint16(31605), + 61: uint16(32227), + 62: uint16(63894), + 63: uint16(32303), + 64: uint16(63895), + 65: uint16(34893), + 66: uint16(36575), + 67: uint16(63896), + 68: uint16(63897), + 69: uint16(63898), + 70: uint16(37467), + 71: uint16(63899), + 72: uint16(40182), + 73: uint16(63900), + 74: uint16(63901), + 75: uint16(63902), + 76: uint16(24709), + 77: uint16(28037), + 78: uint16(63903), + 79: uint16(29105), + 80: uint16(63904), + 81: uint16(63905), + 82: uint16(38321), + 83: uint16(21421), + 84: uint16(63906), + 85: uint16(63907), + 86: uint16(63908), + 87: uint16(26579), + 88: uint16(63909), + 89: uint16(28814), + 90: uint16(28976), + 91: uint16(29744), + 92: uint16(33398), + 93: uint16(33490), + }, + 70: { + 0: uint16(63910), + 1: uint16(38331), + 2: uint16(39653), + 3: uint16(40573), + 4: uint16(26308), + 5: uint16(63911), + 6: uint16(29121), + 7: uint16(33865), + 8: uint16(63912), + 9: uint16(63913), + 10: uint16(22603), + 11: uint16(63914), + 12: uint16(63915), + 13: uint16(23992), + 14: uint16(24433), + 15: uint16(63916), + 16: uint16(26144), + 17: uint16(26254), + 18: uint16(27001), + 19: uint16(27054), + 20: uint16(27704), + 21: uint16(27891), + 22: uint16(28214), + 23: uint16(28481), + 24: uint16(28634), + 25: uint16(28699), + 26: uint16(28719), + 27: uint16(29008), + 28: uint16(29151), + 29: uint16(29552), + 30: uint16(63917), + 31: uint16(29787), + 32: uint16(63918), + 33: uint16(29908), + 34: uint16(30408), + 35: uint16(31310), + 36: uint16(32403), + 37: uint16(63919), + 38: uint16(63920), + 39: uint16(33521), + 40: uint16(35424), + 41: uint16(36814), + 42: uint16(63921), + 43: uint16(37704), + 44: uint16(63922), + 45: uint16(38681), + 46: uint16(63923), + 47: uint16(63924), + 48: uint16(20034), + 49: uint16(20522), + 50: uint16(63925), + 51: uint16(21000), + 52: uint16(21473), + 53: uint16(26355), + 54: uint16(27757), + 55: uint16(28618), + 56: uint16(29450), + 57: uint16(30591), + 58: uint16(31330), + 59: uint16(33454), + 60: uint16(34269), + 61: uint16(34306), + 62: uint16(63926), + 63: uint16(35028), + 64: uint16(35427), + 65: uint16(35709), + 66: uint16(35947), + 67: uint16(63927), + 68: uint16(37555), + 69: uint16(63928), + 70: uint16(38675), + 71: uint16(38928), + 72: uint16(20116), + 73: uint16(20237), + 74: uint16(20425), + 75: uint16(20658), + 76: uint16(21320), + 77: uint16(21566), + 78: uint16(21555), + 79: uint16(21978), + 80: uint16(22626), + 81: uint16(22714), + 82: uint16(22887), + 83: uint16(23067), + 84: uint16(23524), + 85: uint16(24735), + 86: uint16(63929), + 87: uint16(25034), + 88: uint16(25942), + 89: uint16(26111), + 90: uint16(26212), + 91: uint16(26791), + 92: uint16(27738), + 93: uint16(28595), + }, + 71: { + 0: uint16(28879), + 1: uint16(29100), + 2: uint16(29522), + 3: uint16(31613), + 4: uint16(34568), + 5: uint16(35492), + 6: uint16(39986), + 7: uint16(40711), + 8: uint16(23627), + 9: uint16(27779), + 10: uint16(29508), + 11: uint16(29577), + 12: uint16(37434), + 13: uint16(28331), + 14: uint16(29797), + 15: uint16(30239), + 16: uint16(31337), + 17: uint16(32277), + 18: uint16(34314), + 19: uint16(20800), + 20: uint16(22725), + 21: uint16(25793), + 22: uint16(29934), + 23: uint16(29973), + 24: uint16(30320), + 25: uint16(32705), + 26: uint16(37013), + 27: uint16(38605), + 28: uint16(39252), + 29: uint16(28198), + 30: uint16(29926), + 31: uint16(31401), + 32: uint16(31402), + 33: uint16(33253), + 34: uint16(34521), + 35: uint16(34680), + 36: uint16(35355), + 37: uint16(23113), + 38: uint16(23436), + 39: uint16(23451), + 40: uint16(26785), + 41: uint16(26880), + 42: uint16(28003), + 43: uint16(29609), + 44: uint16(29715), + 45: uint16(29740), + 46: uint16(30871), + 47: uint16(32233), + 48: uint16(32747), + 49: uint16(33048), + 50: uint16(33109), + 51: uint16(33694), + 52: uint16(35916), + 53: uint16(38446), + 54: uint16(38929), + 55: uint16(26352), + 56: uint16(24448), + 57: uint16(26106), + 58: uint16(26505), + 59: uint16(27754), + 60: uint16(29579), + 61: uint16(20525), + 62: uint16(23043), + 63: uint16(27498), + 64: uint16(30702), + 65: uint16(22806), + 66: uint16(23916), + 67: uint16(24013), + 68: uint16(29477), + 69: uint16(30031), + 70: uint16(63930), + 71: uint16(63931), + 72: uint16(20709), + 73: uint16(20985), + 74: uint16(22575), + 75: uint16(22829), + 76: uint16(22934), + 77: uint16(23002), + 78: uint16(23525), + 79: uint16(63932), + 80: uint16(63933), + 81: uint16(23970), + 82: uint16(25303), + 83: uint16(25622), + 84: uint16(25747), + 85: uint16(25854), + 86: uint16(63934), + 87: uint16(26332), + 88: uint16(63935), + 89: uint16(27208), + 90: uint16(63936), + 91: uint16(29183), + 92: uint16(29796), + 93: uint16(63937), + }, + 72: { + 0: uint16(31368), + 1: uint16(31407), + 2: uint16(32327), + 3: uint16(32350), + 4: uint16(32768), + 5: uint16(33136), + 6: uint16(63938), + 7: uint16(34799), + 8: uint16(35201), + 9: uint16(35616), + 10: uint16(36953), + 11: uint16(63939), + 12: uint16(36992), + 13: uint16(39250), + 14: uint16(24958), + 15: uint16(27442), + 16: uint16(28020), + 17: uint16(32287), + 18: uint16(35109), + 19: uint16(36785), + 20: uint16(20433), + 21: uint16(20653), + 22: uint16(20887), + 23: uint16(21191), + 24: uint16(22471), + 25: uint16(22665), + 26: uint16(23481), + 27: uint16(24248), + 28: uint16(24898), + 29: uint16(27029), + 30: uint16(28044), + 31: uint16(28263), + 32: uint16(28342), + 33: uint16(29076), + 34: uint16(29794), + 35: uint16(29992), + 36: uint16(29996), + 37: uint16(32883), + 38: uint16(33592), + 39: uint16(33993), + 40: uint16(36362), + 41: uint16(37780), + 42: uint16(37854), + 43: uint16(63940), + 44: uint16(20110), + 45: uint16(20305), + 46: uint16(20598), + 47: uint16(20778), + 48: uint16(21448), + 49: uint16(21451), + 50: uint16(21491), + 51: uint16(23431), + 52: uint16(23507), + 53: uint16(23588), + 54: uint16(24858), + 55: uint16(24962), + 56: uint16(26100), + 57: uint16(29275), + 58: uint16(29591), + 59: uint16(29760), + 60: uint16(30402), + 61: uint16(31056), + 62: uint16(31121), + 63: uint16(31161), + 64: uint16(32006), + 65: uint16(32701), + 66: uint16(33419), + 67: uint16(34261), + 68: uint16(34398), + 69: uint16(36802), + 70: uint16(36935), + 71: uint16(37109), + 72: uint16(37354), + 73: uint16(38533), + 74: uint16(38632), + 75: uint16(38633), + 76: uint16(21206), + 77: uint16(24423), + 78: uint16(26093), + 79: uint16(26161), + 80: uint16(26671), + 81: uint16(29020), + 82: uint16(31286), + 83: uint16(37057), + 84: uint16(38922), + 85: uint16(20113), + 86: uint16(63941), + 87: uint16(27218), + 88: uint16(27550), + 89: uint16(28560), + 90: uint16(29065), + 91: uint16(32792), + 92: uint16(33464), + 93: uint16(34131), + }, + 73: { + 0: uint16(36939), + 1: uint16(38549), + 2: uint16(38642), + 3: uint16(38907), + 4: uint16(34074), + 5: uint16(39729), + 6: uint16(20112), + 7: uint16(29066), + 8: uint16(38596), + 9: uint16(20803), + 10: uint16(21407), + 11: uint16(21729), + 12: uint16(22291), + 13: uint16(22290), + 14: uint16(22435), + 15: uint16(23195), + 16: uint16(23236), + 17: uint16(23491), + 18: uint16(24616), + 19: uint16(24895), + 20: uint16(25588), + 21: uint16(27781), + 22: uint16(27961), + 23: uint16(28274), + 24: uint16(28304), + 25: uint16(29232), + 26: uint16(29503), + 27: uint16(29783), + 28: uint16(33489), + 29: uint16(34945), + 30: uint16(36677), + 31: uint16(36960), + 32: uint16(63942), + 33: uint16(38498), + 34: uint16(39000), + 35: uint16(40219), + 36: uint16(26376), + 37: uint16(36234), + 38: uint16(37470), + 39: uint16(20301), + 40: uint16(20553), + 41: uint16(20702), + 42: uint16(21361), + 43: uint16(22285), + 44: uint16(22996), + 45: uint16(23041), + 46: uint16(23561), + 47: uint16(24944), + 48: uint16(26256), + 49: uint16(28205), + 50: uint16(29234), + 51: uint16(29771), + 52: uint16(32239), + 53: uint16(32963), + 54: uint16(33806), + 55: uint16(33894), + 56: uint16(34111), + 57: uint16(34655), + 58: uint16(34907), + 59: uint16(35096), + 60: uint16(35586), + 61: uint16(36949), + 62: uint16(38859), + 63: uint16(39759), + 64: uint16(20083), + 65: uint16(20369), + 66: uint16(20754), + 67: uint16(20842), + 68: uint16(63943), + 69: uint16(21807), + 70: uint16(21929), + 71: uint16(23418), + 72: uint16(23461), + 73: uint16(24188), + 74: uint16(24189), + 75: uint16(24254), + 76: uint16(24736), + 77: uint16(24799), + 78: uint16(24840), + 79: uint16(24841), + 80: uint16(25540), + 81: uint16(25912), + 82: uint16(26377), + 83: uint16(63944), + 84: uint16(26580), + 85: uint16(26586), + 86: uint16(63945), + 87: uint16(26977), + 88: uint16(26978), + 89: uint16(27833), + 90: uint16(27943), + 91: uint16(63946), + 92: uint16(28216), + 93: uint16(63947), + }, + 74: { + 0: uint16(28641), + 1: uint16(29494), + 2: uint16(29495), + 3: uint16(63948), + 4: uint16(29788), + 5: uint16(30001), + 6: uint16(63949), + 7: uint16(30290), + 8: uint16(63950), + 9: uint16(63951), + 10: uint16(32173), + 11: uint16(33278), + 12: uint16(33848), + 13: uint16(35029), + 14: uint16(35480), + 15: uint16(35547), + 16: uint16(35565), + 17: uint16(36400), + 18: uint16(36418), + 19: uint16(36938), + 20: uint16(36926), + 21: uint16(36986), + 22: uint16(37193), + 23: uint16(37321), + 24: uint16(37742), + 25: uint16(63952), + 26: uint16(63953), + 27: uint16(22537), + 28: uint16(63954), + 29: uint16(27603), + 30: uint16(32905), + 31: uint16(32946), + 32: uint16(63955), + 33: uint16(63956), + 34: uint16(20801), + 35: uint16(22891), + 36: uint16(23609), + 37: uint16(63957), + 38: uint16(63958), + 39: uint16(28516), + 40: uint16(29607), + 41: uint16(32996), + 42: uint16(36103), + 43: uint16(63959), + 44: uint16(37399), + 45: uint16(38287), + 46: uint16(63960), + 47: uint16(63961), + 48: uint16(63962), + 49: uint16(63963), + 50: uint16(32895), + 51: uint16(25102), + 52: uint16(28700), + 53: uint16(32104), + 54: uint16(34701), + 55: uint16(63964), + 56: uint16(22432), + 57: uint16(24681), + 58: uint16(24903), + 59: uint16(27575), + 60: uint16(35518), + 61: uint16(37504), + 62: uint16(38577), + 63: uint16(20057), + 64: uint16(21535), + 65: uint16(28139), + 66: uint16(34093), + 67: uint16(38512), + 68: uint16(38899), + 69: uint16(39150), + 70: uint16(25558), + 71: uint16(27875), + 72: uint16(37009), + 73: uint16(20957), + 74: uint16(25033), + 75: uint16(33210), + 76: uint16(40441), + 77: uint16(20381), + 78: uint16(20506), + 79: uint16(20736), + 80: uint16(23452), + 81: uint16(24847), + 82: uint16(25087), + 83: uint16(25836), + 84: uint16(26885), + 85: uint16(27589), + 86: uint16(30097), + 87: uint16(30691), + 88: uint16(32681), + 89: uint16(33380), + 90: uint16(34191), + 91: uint16(34811), + 92: uint16(34915), + 93: uint16(35516), + }, + 75: { + 0: uint16(35696), + 1: uint16(37291), + 2: uint16(20108), + 3: uint16(20197), + 4: uint16(20234), + 5: uint16(63965), + 6: uint16(63966), + 7: uint16(22839), + 8: uint16(23016), + 9: uint16(63967), + 10: uint16(24050), + 11: uint16(24347), + 12: uint16(24411), + 13: uint16(24609), + 14: uint16(63968), + 15: uint16(63969), + 16: uint16(63970), + 17: uint16(63971), + 18: uint16(29246), + 19: uint16(29669), + 20: uint16(63972), + 21: uint16(30064), + 22: uint16(30157), + 23: uint16(63973), + 24: uint16(31227), + 25: uint16(63974), + 26: uint16(32780), + 27: uint16(32819), + 28: uint16(32900), + 29: uint16(33505), + 30: uint16(33617), + 31: uint16(63975), + 32: uint16(63976), + 33: uint16(36029), + 34: uint16(36019), + 35: uint16(36999), + 36: uint16(63977), + 37: uint16(63978), + 38: uint16(39156), + 39: uint16(39180), + 40: uint16(63979), + 41: uint16(63980), + 42: uint16(28727), + 43: uint16(30410), + 44: uint16(32714), + 45: uint16(32716), + 46: uint16(32764), + 47: uint16(35610), + 48: uint16(20154), + 49: uint16(20161), + 50: uint16(20995), + 51: uint16(21360), + 52: uint16(63981), + 53: uint16(21693), + 54: uint16(22240), + 55: uint16(23035), + 56: uint16(23493), + 57: uint16(24341), + 58: uint16(24525), + 59: uint16(28270), + 60: uint16(63982), + 61: uint16(63983), + 62: uint16(32106), + 63: uint16(33589), + 64: uint16(63984), + 65: uint16(34451), + 66: uint16(35469), + 67: uint16(63985), + 68: uint16(38765), + 69: uint16(38775), + 70: uint16(63986), + 71: uint16(63987), + 72: uint16(19968), + 73: uint16(20314), + 74: uint16(20350), + 75: uint16(22777), + 76: uint16(26085), + 77: uint16(28322), + 78: uint16(36920), + 79: uint16(37808), + 80: uint16(39353), + 81: uint16(20219), + 82: uint16(22764), + 83: uint16(22922), + 84: uint16(23001), + 85: uint16(24641), + 86: uint16(63988), + 87: uint16(63989), + 88: uint16(31252), + 89: uint16(63990), + 90: uint16(33615), + 91: uint16(36035), + 92: uint16(20837), + 93: uint16(21316), + }, + 76: { + 0: uint16(63991), + 1: uint16(63992), + 2: uint16(63993), + 3: uint16(20173), + 4: uint16(21097), + 5: uint16(23381), + 6: uint16(33471), + 7: uint16(20180), + 8: uint16(21050), + 9: uint16(21672), + 10: uint16(22985), + 11: uint16(23039), + 12: uint16(23376), + 13: uint16(23383), + 14: uint16(23388), + 15: uint16(24675), + 16: uint16(24904), + 17: uint16(28363), + 18: uint16(28825), + 19: uint16(29038), + 20: uint16(29574), + 21: uint16(29943), + 22: uint16(30133), + 23: uint16(30913), + 24: uint16(32043), + 25: uint16(32773), + 26: uint16(33258), + 27: uint16(33576), + 28: uint16(34071), + 29: uint16(34249), + 30: uint16(35566), + 31: uint16(36039), + 32: uint16(38604), + 33: uint16(20316), + 34: uint16(21242), + 35: uint16(22204), + 36: uint16(26027), + 37: uint16(26152), + 38: uint16(28796), + 39: uint16(28856), + 40: uint16(29237), + 41: uint16(32189), + 42: uint16(33421), + 43: uint16(37196), + 44: uint16(38592), + 45: uint16(40306), + 46: uint16(23409), + 47: uint16(26855), + 48: uint16(27544), + 49: uint16(28538), + 50: uint16(30430), + 51: uint16(23697), + 52: uint16(26283), + 53: uint16(28507), + 54: uint16(31668), + 55: uint16(31786), + 56: uint16(34870), + 57: uint16(38620), + 58: uint16(19976), + 59: uint16(20183), + 60: uint16(21280), + 61: uint16(22580), + 62: uint16(22715), + 63: uint16(22767), + 64: uint16(22892), + 65: uint16(23559), + 66: uint16(24115), + 67: uint16(24196), + 68: uint16(24373), + 69: uint16(25484), + 70: uint16(26290), + 71: uint16(26454), + 72: uint16(27167), + 73: uint16(27299), + 74: uint16(27404), + 75: uint16(28479), + 76: uint16(29254), + 77: uint16(63994), + 78: uint16(29520), + 79: uint16(29835), + 80: uint16(31456), + 81: uint16(31911), + 82: uint16(33144), + 83: uint16(33247), + 84: uint16(33255), + 85: uint16(33674), + 86: uint16(33900), + 87: uint16(34083), + 88: uint16(34196), + 89: uint16(34255), + 90: uint16(35037), + 91: uint16(36115), + 92: uint16(37292), + 93: uint16(38263), + }, + 77: { + 0: uint16(38556), + 1: uint16(20877), + 2: uint16(21705), + 3: uint16(22312), + 4: uint16(23472), + 5: uint16(25165), + 6: uint16(26448), + 7: uint16(26685), + 8: uint16(26771), + 9: uint16(28221), + 10: uint16(28371), + 11: uint16(28797), + 12: uint16(32289), + 13: uint16(35009), + 14: uint16(36001), + 15: uint16(36617), + 16: uint16(40779), + 17: uint16(40782), + 18: uint16(29229), + 19: uint16(31631), + 20: uint16(35533), + 21: uint16(37658), + 22: uint16(20295), + 23: uint16(20302), + 24: uint16(20786), + 25: uint16(21632), + 26: uint16(22992), + 27: uint16(24213), + 28: uint16(25269), + 29: uint16(26485), + 30: uint16(26990), + 31: uint16(27159), + 32: uint16(27822), + 33: uint16(28186), + 34: uint16(29401), + 35: uint16(29482), + 36: uint16(30141), + 37: uint16(31672), + 38: uint16(32053), + 39: uint16(33511), + 40: uint16(33785), + 41: uint16(33879), + 42: uint16(34295), + 43: uint16(35419), + 44: uint16(36015), + 45: uint16(36487), + 46: uint16(36889), + 47: uint16(37048), + 48: uint16(38606), + 49: uint16(40799), + 50: uint16(21219), + 51: uint16(21514), + 52: uint16(23265), + 53: uint16(23490), + 54: uint16(25688), + 55: uint16(25973), + 56: uint16(28404), + 57: uint16(29380), + 58: uint16(63995), + 59: uint16(30340), + 60: uint16(31309), + 61: uint16(31515), + 62: uint16(31821), + 63: uint16(32318), + 64: uint16(32735), + 65: uint16(33659), + 66: uint16(35627), + 67: uint16(36042), + 68: uint16(36196), + 69: uint16(36321), + 70: uint16(36447), + 71: uint16(36842), + 72: uint16(36857), + 73: uint16(36969), + 74: uint16(37841), + 75: uint16(20291), + 76: uint16(20346), + 77: uint16(20659), + 78: uint16(20840), + 79: uint16(20856), + 80: uint16(21069), + 81: uint16(21098), + 82: uint16(22625), + 83: uint16(22652), + 84: uint16(22880), + 85: uint16(23560), + 86: uint16(23637), + 87: uint16(24283), + 88: uint16(24731), + 89: uint16(25136), + 90: uint16(26643), + 91: uint16(27583), + 92: uint16(27656), + 93: uint16(28593), + }, + 78: { + 0: uint16(29006), + 1: uint16(29728), + 2: uint16(30000), + 3: uint16(30008), + 4: uint16(30033), + 5: uint16(30322), + 6: uint16(31564), + 7: uint16(31627), + 8: uint16(31661), + 9: uint16(31686), + 10: uint16(32399), + 11: uint16(35438), + 12: uint16(36670), + 13: uint16(36681), + 14: uint16(37439), + 15: uint16(37523), + 16: uint16(37666), + 17: uint16(37931), + 18: uint16(38651), + 19: uint16(39002), + 20: uint16(39019), + 21: uint16(39198), + 22: uint16(20999), + 23: uint16(25130), + 24: uint16(25240), + 25: uint16(27993), + 26: uint16(30308), + 27: uint16(31434), + 28: uint16(31680), + 29: uint16(32118), + 30: uint16(21344), + 31: uint16(23742), + 32: uint16(24215), + 33: uint16(28472), + 34: uint16(28857), + 35: uint16(31896), + 36: uint16(38673), + 37: uint16(39822), + 38: uint16(40670), + 39: uint16(25509), + 40: uint16(25722), + 41: uint16(34678), + 42: uint16(19969), + 43: uint16(20117), + 44: uint16(20141), + 45: uint16(20572), + 46: uint16(20597), + 47: uint16(21576), + 48: uint16(22979), + 49: uint16(23450), + 50: uint16(24128), + 51: uint16(24237), + 52: uint16(24311), + 53: uint16(24449), + 54: uint16(24773), + 55: uint16(25402), + 56: uint16(25919), + 57: uint16(25972), + 58: uint16(26060), + 59: uint16(26230), + 60: uint16(26232), + 61: uint16(26622), + 62: uint16(26984), + 63: uint16(27273), + 64: uint16(27491), + 65: uint16(27712), + 66: uint16(28096), + 67: uint16(28136), + 68: uint16(28191), + 69: uint16(28254), + 70: uint16(28702), + 71: uint16(28833), + 72: uint16(29582), + 73: uint16(29693), + 74: uint16(30010), + 75: uint16(30555), + 76: uint16(30855), + 77: uint16(31118), + 78: uint16(31243), + 79: uint16(31357), + 80: uint16(31934), + 81: uint16(32142), + 82: uint16(33351), + 83: uint16(35330), + 84: uint16(35562), + 85: uint16(35998), + 86: uint16(37165), + 87: uint16(37194), + 88: uint16(37336), + 89: uint16(37478), + 90: uint16(37580), + 91: uint16(37664), + 92: uint16(38662), + 93: uint16(38742), + }, + 79: { + 0: uint16(38748), + 1: uint16(38914), + 2: uint16(40718), + 3: uint16(21046), + 4: uint16(21137), + 5: uint16(21884), + 6: uint16(22564), + 7: uint16(24093), + 8: uint16(24351), + 9: uint16(24716), + 10: uint16(25552), + 11: uint16(26799), + 12: uint16(28639), + 13: uint16(31085), + 14: uint16(31532), + 15: uint16(33229), + 16: uint16(34234), + 17: uint16(35069), + 18: uint16(35576), + 19: uint16(36420), + 20: uint16(37261), + 21: uint16(38500), + 22: uint16(38555), + 23: uint16(38717), + 24: uint16(38988), + 25: uint16(40778), + 26: uint16(20430), + 27: uint16(20806), + 28: uint16(20939), + 29: uint16(21161), + 30: uint16(22066), + 31: uint16(24340), + 32: uint16(24427), + 33: uint16(25514), + 34: uint16(25805), + 35: uint16(26089), + 36: uint16(26177), + 37: uint16(26362), + 38: uint16(26361), + 39: uint16(26397), + 40: uint16(26781), + 41: uint16(26839), + 42: uint16(27133), + 43: uint16(28437), + 44: uint16(28526), + 45: uint16(29031), + 46: uint16(29157), + 47: uint16(29226), + 48: uint16(29866), + 49: uint16(30522), + 50: uint16(31062), + 51: uint16(31066), + 52: uint16(31199), + 53: uint16(31264), + 54: uint16(31381), + 55: uint16(31895), + 56: uint16(31967), + 57: uint16(32068), + 58: uint16(32368), + 59: uint16(32903), + 60: uint16(34299), + 61: uint16(34468), + 62: uint16(35412), + 63: uint16(35519), + 64: uint16(36249), + 65: uint16(36481), + 66: uint16(36896), + 67: uint16(36973), + 68: uint16(37347), + 69: uint16(38459), + 70: uint16(38613), + 71: uint16(40165), + 72: uint16(26063), + 73: uint16(31751), + 74: uint16(36275), + 75: uint16(37827), + 76: uint16(23384), + 77: uint16(23562), + 78: uint16(21330), + 79: uint16(25305), + 80: uint16(29469), + 81: uint16(20519), + 82: uint16(23447), + 83: uint16(24478), + 84: uint16(24752), + 85: uint16(24939), + 86: uint16(26837), + 87: uint16(28121), + 88: uint16(29742), + 89: uint16(31278), + 90: uint16(32066), + 91: uint16(32156), + 92: uint16(32305), + 93: uint16(33131), + }, + 80: { + 0: uint16(36394), + 1: uint16(36405), + 2: uint16(37758), + 3: uint16(37912), + 4: uint16(20304), + 5: uint16(22352), + 6: uint16(24038), + 7: uint16(24231), + 8: uint16(25387), + 9: uint16(32618), + 10: uint16(20027), + 11: uint16(20303), + 12: uint16(20367), + 13: uint16(20570), + 14: uint16(23005), + 15: uint16(32964), + 16: uint16(21610), + 17: uint16(21608), + 18: uint16(22014), + 19: uint16(22863), + 20: uint16(23449), + 21: uint16(24030), + 22: uint16(24282), + 23: uint16(26205), + 24: uint16(26417), + 25: uint16(26609), + 26: uint16(26666), + 27: uint16(27880), + 28: uint16(27954), + 29: uint16(28234), + 30: uint16(28557), + 31: uint16(28855), + 32: uint16(29664), + 33: uint16(30087), + 34: uint16(31820), + 35: uint16(32002), + 36: uint16(32044), + 37: uint16(32162), + 38: uint16(33311), + 39: uint16(34523), + 40: uint16(35387), + 41: uint16(35461), + 42: uint16(36208), + 43: uint16(36490), + 44: uint16(36659), + 45: uint16(36913), + 46: uint16(37198), + 47: uint16(37202), + 48: uint16(37956), + 49: uint16(39376), + 50: uint16(31481), + 51: uint16(31909), + 52: uint16(20426), + 53: uint16(20737), + 54: uint16(20934), + 55: uint16(22472), + 56: uint16(23535), + 57: uint16(23803), + 58: uint16(26201), + 59: uint16(27197), + 60: uint16(27994), + 61: uint16(28310), + 62: uint16(28652), + 63: uint16(28940), + 64: uint16(30063), + 65: uint16(31459), + 66: uint16(34850), + 67: uint16(36897), + 68: uint16(36981), + 69: uint16(38603), + 70: uint16(39423), + 71: uint16(33537), + 72: uint16(20013), + 73: uint16(20210), + 74: uint16(34886), + 75: uint16(37325), + 76: uint16(21373), + 77: uint16(27355), + 78: uint16(26987), + 79: uint16(27713), + 80: uint16(33914), + 81: uint16(22686), + 82: uint16(24974), + 83: uint16(26366), + 84: uint16(25327), + 85: uint16(28893), + 86: uint16(29969), + 87: uint16(30151), + 88: uint16(32338), + 89: uint16(33976), + 90: uint16(35657), + 91: uint16(36104), + 92: uint16(20043), + 93: uint16(21482), + }, + 81: { + 0: uint16(21675), + 1: uint16(22320), + 2: uint16(22336), + 3: uint16(24535), + 4: uint16(25345), + 5: uint16(25351), + 6: uint16(25711), + 7: uint16(25903), + 8: uint16(26088), + 9: uint16(26234), + 10: uint16(26525), + 11: uint16(26547), + 12: uint16(27490), + 13: uint16(27744), + 14: uint16(27802), + 15: uint16(28460), + 16: uint16(30693), + 17: uint16(30757), + 18: uint16(31049), + 19: uint16(31063), + 20: uint16(32025), + 21: uint16(32930), + 22: uint16(33026), + 23: uint16(33267), + 24: uint16(33437), + 25: uint16(33463), + 26: uint16(34584), + 27: uint16(35468), + 28: uint16(63996), + 29: uint16(36100), + 30: uint16(36286), + 31: uint16(36978), + 32: uint16(30452), + 33: uint16(31257), + 34: uint16(31287), + 35: uint16(32340), + 36: uint16(32887), + 37: uint16(21767), + 38: uint16(21972), + 39: uint16(22645), + 40: uint16(25391), + 41: uint16(25634), + 42: uint16(26185), + 43: uint16(26187), + 44: uint16(26733), + 45: uint16(27035), + 46: uint16(27524), + 47: uint16(27941), + 48: uint16(28337), + 49: uint16(29645), + 50: uint16(29800), + 51: uint16(29857), + 52: uint16(30043), + 53: uint16(30137), + 54: uint16(30433), + 55: uint16(30494), + 56: uint16(30603), + 57: uint16(31206), + 58: uint16(32265), + 59: uint16(32285), + 60: uint16(33275), + 61: uint16(34095), + 62: uint16(34967), + 63: uint16(35386), + 64: uint16(36049), + 65: uint16(36587), + 66: uint16(36784), + 67: uint16(36914), + 68: uint16(37805), + 69: uint16(38499), + 70: uint16(38515), + 71: uint16(38663), + 72: uint16(20356), + 73: uint16(21489), + 74: uint16(23018), + 75: uint16(23241), + 76: uint16(24089), + 77: uint16(26702), + 78: uint16(29894), + 79: uint16(30142), + 80: uint16(31209), + 81: uint16(31378), + 82: uint16(33187), + 83: uint16(34541), + 84: uint16(36074), + 85: uint16(36300), + 86: uint16(36845), + 87: uint16(26015), + 88: uint16(26389), + 89: uint16(63997), + 90: uint16(22519), + 91: uint16(28503), + 92: uint16(32221), + 93: uint16(36655), + }, + 82: { + 0: uint16(37878), + 1: uint16(38598), + 2: uint16(24501), + 3: uint16(25074), + 4: uint16(28548), + 5: uint16(19988), + 6: uint16(20376), + 7: uint16(20511), + 8: uint16(21449), + 9: uint16(21983), + 10: uint16(23919), + 11: uint16(24046), + 12: uint16(27425), + 13: uint16(27492), + 14: uint16(30923), + 15: uint16(31642), + 16: uint16(63998), + 17: uint16(36425), + 18: uint16(36554), + 19: uint16(36974), + 20: uint16(25417), + 21: uint16(25662), + 22: uint16(30528), + 23: uint16(31364), + 24: uint16(37679), + 25: uint16(38015), + 26: uint16(40810), + 27: uint16(25776), + 28: uint16(28591), + 29: uint16(29158), + 30: uint16(29864), + 31: uint16(29914), + 32: uint16(31428), + 33: uint16(31762), + 34: uint16(32386), + 35: uint16(31922), + 36: uint16(32408), + 37: uint16(35738), + 38: uint16(36106), + 39: uint16(38013), + 40: uint16(39184), + 41: uint16(39244), + 42: uint16(21049), + 43: uint16(23519), + 44: uint16(25830), + 45: uint16(26413), + 46: uint16(32046), + 47: uint16(20717), + 48: uint16(21443), + 49: uint16(22649), + 50: uint16(24920), + 51: uint16(24921), + 52: uint16(25082), + 53: uint16(26028), + 54: uint16(31449), + 55: uint16(35730), + 56: uint16(35734), + 57: uint16(20489), + 58: uint16(20513), + 59: uint16(21109), + 60: uint16(21809), + 61: uint16(23100), + 62: uint16(24288), + 63: uint16(24432), + 64: uint16(24884), + 65: uint16(25950), + 66: uint16(26124), + 67: uint16(26166), + 68: uint16(26274), + 69: uint16(27085), + 70: uint16(28356), + 71: uint16(28466), + 72: uint16(29462), + 73: uint16(30241), + 74: uint16(31379), + 75: uint16(33081), + 76: uint16(33369), + 77: uint16(33750), + 78: uint16(33980), + 79: uint16(20661), + 80: uint16(22512), + 81: uint16(23488), + 82: uint16(23528), + 83: uint16(24425), + 84: uint16(25505), + 85: uint16(30758), + 86: uint16(32181), + 87: uint16(33756), + 88: uint16(34081), + 89: uint16(37319), + 90: uint16(37365), + 91: uint16(20874), + 92: uint16(26613), + 93: uint16(31574), + }, + 83: { + 0: uint16(36012), + 1: uint16(20932), + 2: uint16(22971), + 3: uint16(24765), + 4: uint16(34389), + 5: uint16(20508), + 6: uint16(63999), + 7: uint16(21076), + 8: uint16(23610), + 9: uint16(24957), + 10: uint16(25114), + 11: uint16(25299), + 12: uint16(25842), + 13: uint16(26021), + 14: uint16(28364), + 15: uint16(30240), + 16: uint16(33034), + 17: uint16(36448), + 18: uint16(38495), + 19: uint16(38587), + 20: uint16(20191), + 21: uint16(21315), + 22: uint16(21912), + 23: uint16(22825), + 24: uint16(24029), + 25: uint16(25797), + 26: uint16(27849), + 27: uint16(28154), + 28: uint16(29588), + 29: uint16(31359), + 30: uint16(33307), + 31: uint16(34214), + 32: uint16(36068), + 33: uint16(36368), + 34: uint16(36983), + 35: uint16(37351), + 36: uint16(38369), + 37: uint16(38433), + 38: uint16(38854), + 39: uint16(20984), + 40: uint16(21746), + 41: uint16(21894), + 42: uint16(24505), + 43: uint16(25764), + 44: uint16(28552), + 45: uint16(32180), + 46: uint16(36639), + 47: uint16(36685), + 48: uint16(37941), + 49: uint16(20681), + 50: uint16(23574), + 51: uint16(27838), + 52: uint16(28155), + 53: uint16(29979), + 54: uint16(30651), + 55: uint16(31805), + 56: uint16(31844), + 57: uint16(35449), + 58: uint16(35522), + 59: uint16(22558), + 60: uint16(22974), + 61: uint16(24086), + 62: uint16(25463), + 63: uint16(29266), + 64: uint16(30090), + 65: uint16(30571), + 66: uint16(35548), + 67: uint16(36028), + 68: uint16(36626), + 69: uint16(24307), + 70: uint16(26228), + 71: uint16(28152), + 72: uint16(32893), + 73: uint16(33729), + 74: uint16(35531), + 75: uint16(38737), + 76: uint16(39894), + 77: uint16(64000), + 78: uint16(21059), + 79: uint16(26367), + 80: uint16(28053), + 81: uint16(28399), + 82: uint16(32224), + 83: uint16(35558), + 84: uint16(36910), + 85: uint16(36958), + 86: uint16(39636), + 87: uint16(21021), + 88: uint16(21119), + 89: uint16(21736), + 90: uint16(24980), + 91: uint16(25220), + 92: uint16(25307), + 93: uint16(26786), + }, + 84: { + 0: uint16(26898), + 1: uint16(26970), + 2: uint16(27189), + 3: uint16(28818), + 4: uint16(28966), + 5: uint16(30813), + 6: uint16(30977), + 7: uint16(30990), + 8: uint16(31186), + 9: uint16(31245), + 10: uint16(32918), + 11: uint16(33400), + 12: uint16(33493), + 13: uint16(33609), + 14: uint16(34121), + 15: uint16(35970), + 16: uint16(36229), + 17: uint16(37218), + 18: uint16(37259), + 19: uint16(37294), + 20: uint16(20419), + 21: uint16(22225), + 22: uint16(29165), + 23: uint16(30679), + 24: uint16(34560), + 25: uint16(35320), + 26: uint16(23544), + 27: uint16(24534), + 28: uint16(26449), + 29: uint16(37032), + 30: uint16(21474), + 31: uint16(22618), + 32: uint16(23541), + 33: uint16(24740), + 34: uint16(24961), + 35: uint16(25696), + 36: uint16(32317), + 37: uint16(32880), + 38: uint16(34085), + 39: uint16(37507), + 40: uint16(25774), + 41: uint16(20652), + 42: uint16(23828), + 43: uint16(26368), + 44: uint16(22684), + 45: uint16(25277), + 46: uint16(25512), + 47: uint16(26894), + 48: uint16(27000), + 49: uint16(27166), + 50: uint16(28267), + 51: uint16(30394), + 52: uint16(31179), + 53: uint16(33467), + 54: uint16(33833), + 55: uint16(35535), + 56: uint16(36264), + 57: uint16(36861), + 58: uint16(37138), + 59: uint16(37195), + 60: uint16(37276), + 61: uint16(37648), + 62: uint16(37656), + 63: uint16(37786), + 64: uint16(38619), + 65: uint16(39478), + 66: uint16(39949), + 67: uint16(19985), + 68: uint16(30044), + 69: uint16(31069), + 70: uint16(31482), + 71: uint16(31569), + 72: uint16(31689), + 73: uint16(32302), + 74: uint16(33988), + 75: uint16(36441), + 76: uint16(36468), + 77: uint16(36600), + 78: uint16(36880), + 79: uint16(26149), + 80: uint16(26943), + 81: uint16(29763), + 82: uint16(20986), + 83: uint16(26414), + 84: uint16(40668), + 85: uint16(20805), + 86: uint16(24544), + 87: uint16(27798), + 88: uint16(34802), + 89: uint16(34909), + 90: uint16(34935), + 91: uint16(24756), + 92: uint16(33205), + 93: uint16(33795), + }, + 85: { + 0: uint16(36101), + 1: uint16(21462), + 2: uint16(21561), + 3: uint16(22068), + 4: uint16(23094), + 5: uint16(23601), + 6: uint16(28810), + 7: uint16(32736), + 8: uint16(32858), + 9: uint16(33030), + 10: uint16(33261), + 11: uint16(36259), + 12: uint16(37257), + 13: uint16(39519), + 14: uint16(40434), + 15: uint16(20596), + 16: uint16(20164), + 17: uint16(21408), + 18: uint16(24827), + 19: uint16(28204), + 20: uint16(23652), + 21: uint16(20360), + 22: uint16(20516), + 23: uint16(21988), + 24: uint16(23769), + 25: uint16(24159), + 26: uint16(24677), + 27: uint16(26772), + 28: uint16(27835), + 29: uint16(28100), + 30: uint16(29118), + 31: uint16(30164), + 32: uint16(30196), + 33: uint16(30305), + 34: uint16(31258), + 35: uint16(31305), + 36: uint16(32199), + 37: uint16(32251), + 38: uint16(32622), + 39: uint16(33268), + 40: uint16(34473), + 41: uint16(36636), + 42: uint16(38601), + 43: uint16(39347), + 44: uint16(40786), + 45: uint16(21063), + 46: uint16(21189), + 47: uint16(39149), + 48: uint16(35242), + 49: uint16(19971), + 50: uint16(26578), + 51: uint16(28422), + 52: uint16(20405), + 53: uint16(23522), + 54: uint16(26517), + 55: uint16(27784), + 56: uint16(28024), + 57: uint16(29723), + 58: uint16(30759), + 59: uint16(37341), + 60: uint16(37756), + 61: uint16(34756), + 62: uint16(31204), + 63: uint16(31281), + 64: uint16(24555), + 65: uint16(20182), + 66: uint16(21668), + 67: uint16(21822), + 68: uint16(22702), + 69: uint16(22949), + 70: uint16(24816), + 71: uint16(25171), + 72: uint16(25302), + 73: uint16(26422), + 74: uint16(26965), + 75: uint16(33333), + 76: uint16(38464), + 77: uint16(39345), + 78: uint16(39389), + 79: uint16(20524), + 80: uint16(21331), + 81: uint16(21828), + 82: uint16(22396), + 83: uint16(64001), + 84: uint16(25176), + 85: uint16(64002), + 86: uint16(25826), + 87: uint16(26219), + 88: uint16(26589), + 89: uint16(28609), + 90: uint16(28655), + 91: uint16(29730), + 92: uint16(29752), + 93: uint16(35351), + }, + 86: { + 0: uint16(37944), + 1: uint16(21585), + 2: uint16(22022), + 3: uint16(22374), + 4: uint16(24392), + 5: uint16(24986), + 6: uint16(27470), + 7: uint16(28760), + 8: uint16(28845), + 9: uint16(32187), + 10: uint16(35477), + 11: uint16(22890), + 12: uint16(33067), + 13: uint16(25506), + 14: uint16(30472), + 15: uint16(32829), + 16: uint16(36010), + 17: uint16(22612), + 18: uint16(25645), + 19: uint16(27067), + 20: uint16(23445), + 21: uint16(24081), + 22: uint16(28271), + 23: uint16(64003), + 24: uint16(34153), + 25: uint16(20812), + 26: uint16(21488), + 27: uint16(22826), + 28: uint16(24608), + 29: uint16(24907), + 30: uint16(27526), + 31: uint16(27760), + 32: uint16(27888), + 33: uint16(31518), + 34: uint16(32974), + 35: uint16(33492), + 36: uint16(36294), + 37: uint16(37040), + 38: uint16(39089), + 39: uint16(64004), + 40: uint16(25799), + 41: uint16(28580), + 42: uint16(25745), + 43: uint16(25860), + 44: uint16(20814), + 45: uint16(21520), + 46: uint16(22303), + 47: uint16(35342), + 48: uint16(24927), + 49: uint16(26742), + 50: uint16(64005), + 51: uint16(30171), + 52: uint16(31570), + 53: uint16(32113), + 54: uint16(36890), + 55: uint16(22534), + 56: uint16(27084), + 57: uint16(33151), + 58: uint16(35114), + 59: uint16(36864), + 60: uint16(38969), + 61: uint16(20600), + 62: uint16(22871), + 63: uint16(22956), + 64: uint16(25237), + 65: uint16(36879), + 66: uint16(39722), + 67: uint16(24925), + 68: uint16(29305), + 69: uint16(38358), + 70: uint16(22369), + 71: uint16(23110), + 72: uint16(24052), + 73: uint16(25226), + 74: uint16(25773), + 75: uint16(25850), + 76: uint16(26487), + 77: uint16(27874), + 78: uint16(27966), + 79: uint16(29228), + 80: uint16(29750), + 81: uint16(30772), + 82: uint16(32631), + 83: uint16(33453), + 84: uint16(36315), + 85: uint16(38935), + 86: uint16(21028), + 87: uint16(22338), + 88: uint16(26495), + 89: uint16(29256), + 90: uint16(29923), + 91: uint16(36009), + 92: uint16(36774), + 93: uint16(37393), + }, + 87: { + 0: uint16(38442), + 1: uint16(20843), + 2: uint16(21485), + 3: uint16(25420), + 4: uint16(20329), + 5: uint16(21764), + 6: uint16(24726), + 7: uint16(25943), + 8: uint16(27803), + 9: uint16(28031), + 10: uint16(29260), + 11: uint16(29437), + 12: uint16(31255), + 13: uint16(35207), + 14: uint16(35997), + 15: uint16(24429), + 16: uint16(28558), + 17: uint16(28921), + 18: uint16(33192), + 19: uint16(24846), + 20: uint16(20415), + 21: uint16(20559), + 22: uint16(25153), + 23: uint16(29255), + 24: uint16(31687), + 25: uint16(32232), + 26: uint16(32745), + 27: uint16(36941), + 28: uint16(38829), + 29: uint16(39449), + 30: uint16(36022), + 31: uint16(22378), + 32: uint16(24179), + 33: uint16(26544), + 34: uint16(33805), + 35: uint16(35413), + 36: uint16(21536), + 37: uint16(23318), + 38: uint16(24163), + 39: uint16(24290), + 40: uint16(24330), + 41: uint16(25987), + 42: uint16(32954), + 43: uint16(34109), + 44: uint16(38281), + 45: uint16(38491), + 46: uint16(20296), + 47: uint16(21253), + 48: uint16(21261), + 49: uint16(21263), + 50: uint16(21638), + 51: uint16(21754), + 52: uint16(22275), + 53: uint16(24067), + 54: uint16(24598), + 55: uint16(25243), + 56: uint16(25265), + 57: uint16(25429), + 58: uint16(64006), + 59: uint16(27873), + 60: uint16(28006), + 61: uint16(30129), + 62: uint16(30770), + 63: uint16(32990), + 64: uint16(33071), + 65: uint16(33502), + 66: uint16(33889), + 67: uint16(33970), + 68: uint16(34957), + 69: uint16(35090), + 70: uint16(36875), + 71: uint16(37610), + 72: uint16(39165), + 73: uint16(39825), + 74: uint16(24133), + 75: uint16(26292), + 76: uint16(26333), + 77: uint16(28689), + 78: uint16(29190), + 79: uint16(64007), + 80: uint16(20469), + 81: uint16(21117), + 82: uint16(24426), + 83: uint16(24915), + 84: uint16(26451), + 85: uint16(27161), + 86: uint16(28418), + 87: uint16(29922), + 88: uint16(31080), + 89: uint16(34920), + 90: uint16(35961), + 91: uint16(39111), + 92: uint16(39108), + 93: uint16(39491), + }, + 88: { + 0: uint16(21697), + 1: uint16(31263), + 2: uint16(26963), + 3: uint16(35575), + 4: uint16(35914), + 5: uint16(39080), + 6: uint16(39342), + 7: uint16(24444), + 8: uint16(25259), + 9: uint16(30130), + 10: uint16(30382), + 11: uint16(34987), + 12: uint16(36991), + 13: uint16(38466), + 14: uint16(21305), + 15: uint16(24380), + 16: uint16(24517), + 17: uint16(27852), + 18: uint16(29644), + 19: uint16(30050), + 20: uint16(30091), + 21: uint16(31558), + 22: uint16(33534), + 23: uint16(39325), + 24: uint16(20047), + 25: uint16(36924), + 26: uint16(19979), + 27: uint16(20309), + 28: uint16(21414), + 29: uint16(22799), + 30: uint16(24264), + 31: uint16(26160), + 32: uint16(27827), + 33: uint16(29781), + 34: uint16(33655), + 35: uint16(34662), + 36: uint16(36032), + 37: uint16(36944), + 38: uint16(38686), + 39: uint16(39957), + 40: uint16(22737), + 41: uint16(23416), + 42: uint16(34384), + 43: uint16(35604), + 44: uint16(40372), + 45: uint16(23506), + 46: uint16(24680), + 47: uint16(24717), + 48: uint16(26097), + 49: uint16(27735), + 50: uint16(28450), + 51: uint16(28579), + 52: uint16(28698), + 53: uint16(32597), + 54: uint16(32752), + 55: uint16(38289), + 56: uint16(38290), + 57: uint16(38480), + 58: uint16(38867), + 59: uint16(21106), + 60: uint16(36676), + 61: uint16(20989), + 62: uint16(21547), + 63: uint16(21688), + 64: uint16(21859), + 65: uint16(21898), + 66: uint16(27323), + 67: uint16(28085), + 68: uint16(32216), + 69: uint16(33382), + 70: uint16(37532), + 71: uint16(38519), + 72: uint16(40569), + 73: uint16(21512), + 74: uint16(21704), + 75: uint16(30418), + 76: uint16(34532), + 77: uint16(38308), + 78: uint16(38356), + 79: uint16(38492), + 80: uint16(20130), + 81: uint16(20233), + 82: uint16(23022), + 83: uint16(23270), + 84: uint16(24055), + 85: uint16(24658), + 86: uint16(25239), + 87: uint16(26477), + 88: uint16(26689), + 89: uint16(27782), + 90: uint16(28207), + 91: uint16(32568), + 92: uint16(32923), + 93: uint16(33322), + }, + 89: { + 0: uint16(64008), + 1: uint16(64009), + 2: uint16(38917), + 3: uint16(20133), + 4: uint16(20565), + 5: uint16(21683), + 6: uint16(22419), + 7: uint16(22874), + 8: uint16(23401), + 9: uint16(23475), + 10: uint16(25032), + 11: uint16(26999), + 12: uint16(28023), + 13: uint16(28707), + 14: uint16(34809), + 15: uint16(35299), + 16: uint16(35442), + 17: uint16(35559), + 18: uint16(36994), + 19: uint16(39405), + 20: uint16(39608), + 21: uint16(21182), + 22: uint16(26680), + 23: uint16(20502), + 24: uint16(24184), + 25: uint16(26447), + 26: uint16(33607), + 27: uint16(34892), + 28: uint16(20139), + 29: uint16(21521), + 30: uint16(22190), + 31: uint16(29670), + 32: uint16(37141), + 33: uint16(38911), + 34: uint16(39177), + 35: uint16(39255), + 36: uint16(39321), + 37: uint16(22099), + 38: uint16(22687), + 39: uint16(34395), + 40: uint16(35377), + 41: uint16(25010), + 42: uint16(27382), + 43: uint16(29563), + 44: uint16(36562), + 45: uint16(27463), + 46: uint16(38570), + 47: uint16(39511), + 48: uint16(22869), + 49: uint16(29184), + 50: uint16(36203), + 51: uint16(38761), + 52: uint16(20436), + 53: uint16(23796), + 54: uint16(24358), + 55: uint16(25080), + 56: uint16(26203), + 57: uint16(27883), + 58: uint16(28843), + 59: uint16(29572), + 60: uint16(29625), + 61: uint16(29694), + 62: uint16(30505), + 63: uint16(30541), + 64: uint16(32067), + 65: uint16(32098), + 66: uint16(32291), + 67: uint16(33335), + 68: uint16(34898), + 69: uint16(64010), + 70: uint16(36066), + 71: uint16(37449), + 72: uint16(39023), + 73: uint16(23377), + 74: uint16(31348), + 75: uint16(34880), + 76: uint16(38913), + 77: uint16(23244), + 78: uint16(20448), + 79: uint16(21332), + 80: uint16(22846), + 81: uint16(23805), + 82: uint16(25406), + 83: uint16(28025), + 84: uint16(29433), + 85: uint16(33029), + 86: uint16(33031), + 87: uint16(33698), + 88: uint16(37583), + 89: uint16(38960), + 90: uint16(20136), + 91: uint16(20804), + 92: uint16(21009), + 93: uint16(22411), + }, + 90: { + 0: uint16(24418), + 1: uint16(27842), + 2: uint16(28366), + 3: uint16(28677), + 4: uint16(28752), + 5: uint16(28847), + 6: uint16(29074), + 7: uint16(29673), + 8: uint16(29801), + 9: uint16(33610), + 10: uint16(34722), + 11: uint16(34913), + 12: uint16(36872), + 13: uint16(37026), + 14: uint16(37795), + 15: uint16(39336), + 16: uint16(20846), + 17: uint16(24407), + 18: uint16(24800), + 19: uint16(24935), + 20: uint16(26291), + 21: uint16(34137), + 22: uint16(36426), + 23: uint16(37295), + 24: uint16(38795), + 25: uint16(20046), + 26: uint16(20114), + 27: uint16(21628), + 28: uint16(22741), + 29: uint16(22778), + 30: uint16(22909), + 31: uint16(23733), + 32: uint16(24359), + 33: uint16(25142), + 34: uint16(25160), + 35: uint16(26122), + 36: uint16(26215), + 37: uint16(27627), + 38: uint16(28009), + 39: uint16(28111), + 40: uint16(28246), + 41: uint16(28408), + 42: uint16(28564), + 43: uint16(28640), + 44: uint16(28649), + 45: uint16(28765), + 46: uint16(29392), + 47: uint16(29733), + 48: uint16(29786), + 49: uint16(29920), + 50: uint16(30355), + 51: uint16(31068), + 52: uint16(31946), + 53: uint16(32286), + 54: uint16(32993), + 55: uint16(33446), + 56: uint16(33899), + 57: uint16(33983), + 58: uint16(34382), + 59: uint16(34399), + 60: uint16(34676), + 61: uint16(35703), + 62: uint16(35946), + 63: uint16(37804), + 64: uint16(38912), + 65: uint16(39013), + 66: uint16(24785), + 67: uint16(25110), + 68: uint16(37239), + 69: uint16(23130), + 70: uint16(26127), + 71: uint16(28151), + 72: uint16(28222), + 73: uint16(29759), + 74: uint16(39746), + 75: uint16(24573), + 76: uint16(24794), + 77: uint16(31503), + 78: uint16(21700), + 79: uint16(24344), + 80: uint16(27742), + 81: uint16(27859), + 82: uint16(27946), + 83: uint16(28888), + 84: uint16(32005), + 85: uint16(34425), + 86: uint16(35340), + 87: uint16(40251), + 88: uint16(21270), + 89: uint16(21644), + 90: uint16(23301), + 91: uint16(27194), + 92: uint16(28779), + 93: uint16(30069), + }, + 91: { + 0: uint16(31117), + 1: uint16(31166), + 2: uint16(33457), + 3: uint16(33775), + 4: uint16(35441), + 5: uint16(35649), + 6: uint16(36008), + 7: uint16(38772), + 8: uint16(64011), + 9: uint16(25844), + 10: uint16(25899), + 11: uint16(30906), + 12: uint16(30907), + 13: uint16(31339), + 14: uint16(20024), + 15: uint16(21914), + 16: uint16(22864), + 17: uint16(23462), + 18: uint16(24187), + 19: uint16(24739), + 20: uint16(25563), + 21: uint16(27489), + 22: uint16(26213), + 23: uint16(26707), + 24: uint16(28185), + 25: uint16(29029), + 26: uint16(29872), + 27: uint16(32008), + 28: uint16(36996), + 29: uint16(39529), + 30: uint16(39973), + 31: uint16(27963), + 32: uint16(28369), + 33: uint16(29502), + 34: uint16(35905), + 35: uint16(38346), + 36: uint16(20976), + 37: uint16(24140), + 38: uint16(24488), + 39: uint16(24653), + 40: uint16(24822), + 41: uint16(24880), + 42: uint16(24908), + 43: uint16(26179), + 44: uint16(26180), + 45: uint16(27045), + 46: uint16(27841), + 47: uint16(28255), + 48: uint16(28361), + 49: uint16(28514), + 50: uint16(29004), + 51: uint16(29852), + 52: uint16(30343), + 53: uint16(31681), + 54: uint16(31783), + 55: uint16(33618), + 56: uint16(34647), + 57: uint16(36945), + 58: uint16(38541), + 59: uint16(40643), + 60: uint16(21295), + 61: uint16(22238), + 62: uint16(24315), + 63: uint16(24458), + 64: uint16(24674), + 65: uint16(24724), + 66: uint16(25079), + 67: uint16(26214), + 68: uint16(26371), + 69: uint16(27292), + 70: uint16(28142), + 71: uint16(28590), + 72: uint16(28784), + 73: uint16(29546), + 74: uint16(32362), + 75: uint16(33214), + 76: uint16(33588), + 77: uint16(34516), + 78: uint16(35496), + 79: uint16(36036), + 80: uint16(21123), + 81: uint16(29554), + 82: uint16(23446), + 83: uint16(27243), + 84: uint16(37892), + 85: uint16(21742), + 86: uint16(22150), + 87: uint16(23389), + 88: uint16(25928), + 89: uint16(25989), + 90: uint16(26313), + 91: uint16(26783), + 92: uint16(28045), + 93: uint16(28102), + }, + 92: { + 0: uint16(29243), + 1: uint16(32948), + 2: uint16(37237), + 3: uint16(39501), + 4: uint16(20399), + 5: uint16(20505), + 6: uint16(21402), + 7: uint16(21518), + 8: uint16(21564), + 9: uint16(21897), + 10: uint16(21957), + 11: uint16(24127), + 12: uint16(24460), + 13: uint16(26429), + 14: uint16(29030), + 15: uint16(29661), + 16: uint16(36869), + 17: uint16(21211), + 18: uint16(21235), + 19: uint16(22628), + 20: uint16(22734), + 21: uint16(28932), + 22: uint16(29071), + 23: uint16(29179), + 24: uint16(34224), + 25: uint16(35347), + 26: uint16(26248), + 27: uint16(34216), + 28: uint16(21927), + 29: uint16(26244), + 30: uint16(29002), + 31: uint16(33841), + 32: uint16(21321), + 33: uint16(21913), + 34: uint16(27585), + 35: uint16(24409), + 36: uint16(24509), + 37: uint16(25582), + 38: uint16(26249), + 39: uint16(28999), + 40: uint16(35569), + 41: uint16(36637), + 42: uint16(40638), + 43: uint16(20241), + 44: uint16(25658), + 45: uint16(28875), + 46: uint16(30054), + 47: uint16(34407), + 48: uint16(24676), + 49: uint16(35662), + 50: uint16(40440), + 51: uint16(20807), + 52: uint16(20982), + 53: uint16(21256), + 54: uint16(27958), + 55: uint16(33016), + 56: uint16(40657), + 57: uint16(26133), + 58: uint16(27427), + 59: uint16(28824), + 60: uint16(30165), + 61: uint16(21507), + 62: uint16(23673), + 63: uint16(32007), + 64: uint16(35350), + 65: uint16(27424), + 66: uint16(27453), + 67: uint16(27462), + 68: uint16(21560), + 69: uint16(24688), + 70: uint16(27965), + 71: uint16(32725), + 72: uint16(33288), + 73: uint16(20694), + 74: uint16(20958), + 75: uint16(21916), + 76: uint16(22123), + 77: uint16(22221), + 78: uint16(23020), + 79: uint16(23305), + 80: uint16(24076), + 81: uint16(24985), + 82: uint16(24984), + 83: uint16(25137), + 84: uint16(26206), + 85: uint16(26342), + 86: uint16(29081), + 87: uint16(29113), + 88: uint16(29114), + 89: uint16(29351), + 90: uint16(31143), + 91: uint16(31232), + 92: uint16(32690), + 93: uint16(35440), + }, +} + +var _rev_jis = [6879]uint16{ + 0: uint16(31), + 1: uint16(80), + 2: uint16(81), + 3: uint16(87), + 4: uint16(14), + 5: uint16(299), + 6: uint16(74), + 7: uint16(61), + 8: uint16(12), + 9: uint16(344), + 10: uint16(62), + 11: uint16(63), + 12: uint16(1280), + 13: uint16(1281), + 14: uint16(1282), + 15: uint16(1283), + 16: uint16(1284), + 17: uint16(1285), + 18: uint16(1286), + 19: uint16(1287), + 20: uint16(1288), + 21: uint16(1289), + 22: uint16(1290), + 23: uint16(1291), + 24: uint16(1292), + 25: uint16(1293), + 26: uint16(1294), + 27: uint16(1295), + 28: uint16(1296), + 29: uint16(1297), + 30: uint16(1298), + 31: uint16(1299), + 32: uint16(1300), + 33: uint16(1301), + 34: uint16(1302), + 35: uint16(1303), + 36: uint16(1312), + 37: uint16(1313), + 38: uint16(1314), + 39: uint16(1315), + 40: uint16(1316), + 41: uint16(1317), + 42: uint16(1318), + 43: uint16(1319), + 44: uint16(1320), + 45: uint16(1321), + 46: uint16(1322), + 47: uint16(1323), + 48: uint16(1324), + 49: uint16(1325), + 50: uint16(1326), + 51: uint16(1327), + 52: uint16(1328), + 53: uint16(1329), + 54: uint16(1330), + 55: uint16(1331), + 56: uint16(1332), + 57: uint16(1333), + 58: uint16(1334), + 59: uint16(1335), + 60: uint16(1542), + 61: uint16(1536), + 62: uint16(1537), + 63: uint16(1538), + 64: uint16(1539), + 65: uint16(1540), + 66: uint16(1541), + 67: uint16(1543), + 68: uint16(1544), + 69: uint16(1545), + 70: uint16(1546), + 71: uint16(1547), + 72: uint16(1548), + 73: uint16(1549), + 74: uint16(1550), + 75: uint16(1551), + 76: uint16(1552), + 77: uint16(1553), + 78: uint16(1554), + 79: uint16(1555), + 80: uint16(1556), + 81: uint16(1557), + 82: uint16(1558), + 83: uint16(1559), + 84: uint16(1560), + 85: uint16(1561), + 86: uint16(1562), + 87: uint16(1563), + 88: uint16(1564), + 89: uint16(1565), + 90: uint16(1566), + 91: uint16(1567), + 92: uint16(1568), + 93: uint16(1584), + 94: uint16(1585), + 95: uint16(1586), + 96: uint16(1587), + 97: uint16(1588), + 98: uint16(1589), + 99: uint16(1591), + 100: uint16(1592), + 101: uint16(1593), + 102: uint16(1594), + 103: uint16(1595), + 104: uint16(1596), + 105: uint16(1597), + 106: uint16(1598), + 107: uint16(1599), + 108: uint16(1600), + 109: uint16(1601), + 110: uint16(1602), + 111: uint16(1603), + 112: uint16(1604), + 113: uint16(1605), + 114: uint16(1606), + 115: uint16(1607), + 116: uint16(1608), + 117: uint16(1609), + 118: uint16(1610), + 119: uint16(1611), + 120: uint16(1612), + 121: uint16(1613), + 122: uint16(1614), + 123: uint16(1615), + 124: uint16(1616), + 125: uint16(1590), + 126: uint16(29), + 127: uint16(28), + 128: uint16(33), + 129: uint16(37), + 130: uint16(38), + 131: uint16(39), + 132: uint16(40), + 133: uint16(342), + 134: uint16(343), + 135: uint16(36), + 136: uint16(35), + 137: uint16(338), + 138: uint16(75), + 139: uint16(76), + 140: uint16(263), + 141: uint16(77), + 142: uint16(337), + 143: uint16(266), + 144: uint16(267), + 145: uint16(265), + 146: uint16(268), + 147: uint16(300), + 148: uint16(301), + 149: uint16(302), + 150: uint16(318), + 151: uint16(303), + 152: uint16(319), + 153: uint16(281), + 154: uint16(282), + 155: uint16(60), + 156: uint16(324), + 157: uint16(326), + 158: uint16(70), + 159: uint16(315), + 160: uint16(297), + 161: uint16(298), + 162: uint16(288), + 163: uint16(287), + 164: uint16(328), + 165: uint16(329), + 166: uint16(71), + 167: uint16(327), + 168: uint16(325), + 169: uint16(321), + 170: uint16(65), + 171: uint16(320), + 172: uint16(68), + 173: uint16(69), + 174: uint16(322), + 175: uint16(323), + 176: uint16(285), + 177: uint16(286), + 178: uint16(283), + 179: uint16(284), + 180: uint16(316), + 181: uint16(317), + 182: uint16(1792), + 183: uint16(1803), + 184: uint16(1793), + 185: uint16(1804), + 186: uint16(1794), + 187: uint16(1805), + 188: uint16(1795), + 189: uint16(1806), + 190: uint16(1797), + 191: uint16(1808), + 192: uint16(1796), + 193: uint16(1807), + 194: uint16(1798), + 195: uint16(1819), + 196: uint16(1814), + 197: uint16(1809), + 198: uint16(1800), + 199: uint16(1821), + 200: uint16(1816), + 201: uint16(1811), + 202: uint16(1799), + 203: uint16(1815), + 204: uint16(1820), + 205: uint16(1810), + 206: uint16(1801), + 207: uint16(1817), + 208: uint16(1822), + 209: uint16(1812), + 210: uint16(1802), + 211: uint16(1818), + 212: uint16(1823), + 213: uint16(1813), + 214: uint16(258), + 215: uint16(257), + 216: uint16(260), + 217: uint16(259), + 218: uint16(262), + 219: uint16(261), + 220: uint16(256), + 221: uint16(93), + 222: uint16(90), + 223: uint16(92), + 224: uint16(91), + 225: uint16(349), + 226: uint16(89), + 227: uint16(88), + 228: uint16(73), + 229: uint16(72), + 230: uint16(341), + 231: uint16(340), + 232: uint16(339), + 234: uint16(1), + 235: uint16(2), + 236: uint16(22), + 237: uint16(24), + 238: uint16(25), + 239: uint16(26), + 240: uint16(49), + 241: uint16(50), + 242: uint16(51), + 243: uint16(52), + 244: uint16(53), + 245: uint16(54), + 246: uint16(55), + 247: uint16(56), + 248: uint16(57), + 249: uint16(58), + 250: uint16(264), + 251: uint16(269), + 252: uint16(43), + 253: uint16(44), + 254: uint16(32), + 255: uint16(768), + 256: uint16(769), + 257: uint16(770), + 258: uint16(771), + 259: uint16(772), + 260: uint16(773), + 261: uint16(774), + 262: uint16(775), + 263: uint16(776), + 264: uint16(777), + 265: uint16(778), + 266: uint16(779), + 267: uint16(780), + 268: uint16(781), + 269: uint16(782), + 270: uint16(783), + 271: uint16(784), + 272: uint16(785), + 273: uint16(786), + 274: uint16(787), + 275: uint16(788), + 276: uint16(789), + 277: uint16(790), + 278: uint16(791), + 279: uint16(792), + 280: uint16(793), + 281: uint16(794), + 282: uint16(795), + 283: uint16(796), + 284: uint16(797), + 285: uint16(798), + 286: uint16(799), + 287: uint16(800), + 288: uint16(801), + 289: uint16(802), + 290: uint16(803), + 291: uint16(804), + 292: uint16(805), + 293: uint16(806), + 294: uint16(807), + 295: uint16(808), + 296: uint16(809), + 297: uint16(810), + 298: uint16(811), + 299: uint16(812), + 300: uint16(813), + 301: uint16(814), + 302: uint16(815), + 303: uint16(816), + 304: uint16(817), + 305: uint16(818), + 306: uint16(819), + 307: uint16(820), + 308: uint16(821), + 309: uint16(822), + 310: uint16(823), + 311: uint16(824), + 312: uint16(825), + 313: uint16(826), + 314: uint16(827), + 315: uint16(828), + 316: uint16(829), + 317: uint16(830), + 318: uint16(831), + 319: uint16(832), + 320: uint16(833), + 321: uint16(834), + 322: uint16(835), + 323: uint16(836), + 324: uint16(837), + 325: uint16(838), + 326: uint16(839), + 327: uint16(840), + 328: uint16(841), + 329: uint16(842), + 330: uint16(843), + 331: uint16(844), + 332: uint16(845), + 333: uint16(846), + 334: uint16(847), + 335: uint16(848), + 336: uint16(849), + 337: uint16(850), + 338: uint16(10), + 339: uint16(11), + 340: uint16(20), + 341: uint16(21), + 342: uint16(1024), + 343: uint16(1025), + 344: uint16(1026), + 345: uint16(1027), + 346: uint16(1028), + 347: uint16(1029), + 348: uint16(1030), + 349: uint16(1031), + 350: uint16(1032), + 351: uint16(1033), + 352: uint16(1034), + 353: uint16(1035), + 354: uint16(1036), + 355: uint16(1037), + 356: uint16(1038), + 357: uint16(1039), + 358: uint16(1040), + 359: uint16(1041), + 360: uint16(1042), + 361: uint16(1043), + 362: uint16(1044), + 363: uint16(1045), + 364: uint16(1046), + 365: uint16(1047), + 366: uint16(1048), + 367: uint16(1049), + 368: uint16(1050), + 369: uint16(1051), + 370: uint16(1052), + 371: uint16(1053), + 372: uint16(1054), + 373: uint16(1055), + 374: uint16(1056), + 375: uint16(1057), + 376: uint16(1058), + 377: uint16(1059), + 378: uint16(1060), + 379: uint16(1061), + 380: uint16(1062), + 381: uint16(1063), + 382: uint16(1064), + 383: uint16(1065), + 384: uint16(1066), + 385: uint16(1067), + 386: uint16(1068), + 387: uint16(1069), + 388: uint16(1070), + 389: uint16(1071), + 390: uint16(1072), + 391: uint16(1073), + 392: uint16(1074), + 393: uint16(1075), + 394: uint16(1076), + 395: uint16(1077), + 396: uint16(1078), + 397: uint16(1079), + 398: uint16(1080), + 399: uint16(1081), + 400: uint16(1082), + 401: uint16(1083), + 402: uint16(1084), + 403: uint16(1085), + 404: uint16(1086), + 405: uint16(1087), + 406: uint16(1088), + 407: uint16(1089), + 408: uint16(1090), + 409: uint16(1091), + 410: uint16(1092), + 411: uint16(1093), + 412: uint16(1094), + 413: uint16(1095), + 414: uint16(1096), + 415: uint16(1097), + 416: uint16(1098), + 417: uint16(1099), + 418: uint16(1100), + 419: uint16(1101), + 420: uint16(1102), + 421: uint16(1103), + 422: uint16(1104), + 423: uint16(1105), + 424: uint16(1106), + 425: uint16(1107), + 426: uint16(1108), + 427: uint16(1109), + 428: uint16(5), + 429: uint16(27), + 430: uint16(18), + 431: uint16(19), + 432: uint16(3915), + 433: uint16(8793), + 434: uint16(6934), + 435: uint16(10843), + 436: uint16(7493), + 437: uint16(6671), + 438: uint16(7492), + 439: uint16(4379), + 440: uint16(10291), + 441: uint16(11294), + 442: uint16(12033), + 443: uint16(4110), + 444: uint16(4685), + 445: uint16(12034), + 446: uint16(7939), + 447: uint16(12577), + 448: uint16(5173), + 449: uint16(10521), + 450: uint16(7494), + 451: uint16(11549), + 452: uint16(10529), + 453: uint16(12035), + 454: uint16(8773), + 455: uint16(12036), + 456: uint16(5465), + 457: uint16(12037), + 458: uint16(4924), + 459: uint16(8719), + 460: uint16(6982), + 461: uint16(12038), + 462: uint16(12039), + 463: uint16(12040), + 464: uint16(9748), + 465: uint16(5174), + 466: uint16(9750), + 467: uint16(9538), + 468: uint16(5922), + 469: uint16(10770), + 470: uint16(18472), + 471: uint16(12041), + 472: uint16(7495), + 473: uint16(12042), + 474: uint16(4372), + 475: uint16(5444), + 476: uint16(5967), + 477: uint16(11080), + 478: uint16(13573), + 479: uint16(11343), + 480: uint16(9564), + 481: uint16(4868), + 482: uint16(5140), + 483: uint16(12043), + 484: uint16(12044), + 485: uint16(11546), + 486: uint16(11292), + 487: uint16(8263), + 488: uint16(12046), + 489: uint16(6741), + 490: uint16(9554), + 491: uint16(12049), + 492: uint16(4125), + 493: uint16(5950), + 494: uint16(5949), + 495: uint16(3909), + 496: uint16(11818), + 497: uint16(11817), + 498: uint16(6418), + 499: uint16(3840), + 500: uint16(12050), + 501: uint16(12051), + 502: uint16(12052), + 503: uint16(10771), + 504: uint16(12053), + 505: uint16(5969), + 506: uint16(3910), + 507: uint16(10833), + 508: uint16(5211), + 509: uint16(5212), + 510: uint16(5213), + 511: uint16(9025), + 512: uint16(11547), + 513: uint16(12054), + 514: uint16(12055), + 515: uint16(12056), + 516: uint16(7724), + 517: uint16(7193), + 518: uint16(7725), + 519: uint16(12061), + 520: uint16(12059), + 521: uint16(12060), + 522: uint16(5175), + 523: uint16(6402), + 524: uint16(4431), + 525: uint16(12058), + 526: uint16(12057), + 527: uint16(10504), + 528: uint16(6693), + 529: uint16(6692), + 530: uint16(8477), + 531: uint16(12062), + 532: uint16(10292), + 533: uint16(8006), + 534: uint16(23), + 535: uint16(12063), + 536: uint16(12065), + 537: uint16(8516), + 538: uint16(11584), + 539: uint16(3881), + 540: uint16(12064), + 541: uint16(4381), + 542: uint16(5411), + 543: uint16(8774), + 544: uint16(5710), + 545: uint16(12066), + 546: uint16(9731), + 547: uint16(4938), + 548: uint16(12067), + 549: uint16(3882), + 550: uint16(5951), + 551: uint16(4939), + 552: uint16(10329), + 553: uint16(10001), + 554: uint16(5176), + 555: uint16(4432), + 556: uint16(12102), + 557: uint16(9248), + 558: uint16(9803), + 559: uint16(12069), + 560: uint16(10011), + 561: uint16(11585), + 562: uint16(7692), + 563: uint16(6694), + 564: uint16(6742), + 565: uint16(4383), + 566: uint16(9008), + 567: uint16(8705), + 568: uint16(12073), + 569: uint16(3883), + 570: uint16(9026), + 571: uint16(7194), + 572: uint16(6419), + 573: uint16(11267), + 574: uint16(8493), + 575: uint16(4382), + 576: uint16(12072), + 577: uint16(11293), + 578: uint16(12068), + 579: uint16(12070), + 580: uint16(6477), + 581: uint16(12071), + 582: uint16(13315), + 583: uint16(12079), + 584: uint16(12082), + 585: uint16(12080), + 586: uint16(4385), + 587: uint16(10522), + 588: uint16(12074), + 589: uint16(12078), + 590: uint16(5970), + 591: uint16(6695), + 592: uint16(4869), + 593: uint16(12083), + 594: uint16(12075), + 595: uint16(11586), + 596: uint16(6743), + 597: uint16(12076), + 598: uint16(12081), + 599: uint16(12084), + 600: uint16(12077), + 601: uint16(5376), + 602: uint16(3884), + 603: uint16(5377), + 604: uint16(4384), + 605: uint16(13316), + 606: uint16(10840), + 607: uint16(10317), + 608: uint16(5971), + 609: uint16(7694), + 610: uint16(11542), + 611: uint16(10551), + 612: uint16(5655), + 613: uint16(8452), + 614: uint16(4419), + 615: uint16(7218), + 616: uint16(12088), + 617: uint16(12093), + 618: uint16(12091), + 619: uint16(12086), + 620: uint16(8462), + 621: uint16(12089), + 622: uint16(12092), + 623: uint16(12090), + 624: uint16(10556), + 625: uint16(12087), + 626: uint16(7693), + 627: uint16(10834), + 628: uint16(12094), + 629: uint16(12095), + 630: uint16(7171), + 631: uint16(12108), + 632: uint16(9775), + 633: uint16(10261), + 634: uint16(12103), + 635: uint16(10575), + 636: uint16(4373), + 637: uint16(12107), + 638: uint16(12101), + 639: uint16(12110), + 640: uint16(8241), + 641: uint16(5923), + 642: uint16(9787), + 643: uint16(16166), + 644: uint16(12109), + 645: uint16(9276), + 646: uint16(12098), + 647: uint16(5973), + 648: uint16(5972), + 649: uint16(12096), + 650: uint16(6969), + 651: uint16(12104), + 652: uint16(10574), + 653: uint16(8748), + 654: uint16(12100), + 655: uint16(5712), + 656: uint16(12097), + 657: uint16(12105), + 658: uint16(12099), + 659: uint16(11568), + 660: uint16(12106), + 661: uint16(11808), + 662: uint16(5445), + 663: uint16(5711), + 664: uint16(12111), + 665: uint16(12112), + 666: uint16(12116), + 667: uint16(3885), + 668: uint16(10543), + 669: uint16(12115), + 670: uint16(12114), + 671: uint16(12118), + 672: uint16(12117), + 673: uint16(9027), + 674: uint16(5713), + 675: uint16(12119), + 676: uint16(6948), + 677: uint16(8453), + 678: uint16(9028), + 679: uint16(5461), + 680: uint16(12120), + 681: uint16(5141), + 682: uint16(12121), + 683: uint16(12123), + 684: uint16(10772), + 685: uint16(5701), + 686: uint16(6672), + 687: uint16(10070), + 688: uint16(12122), + 689: uint16(6436), + 690: uint16(11298), + 691: uint16(12125), + 692: uint16(12290), + 693: uint16(12124), + 694: uint16(6435), + 695: uint16(7260), + 696: uint16(5656), + 697: uint16(12291), + 698: uint16(5422), + 699: uint16(12288), + 700: uint16(12289), + 701: uint16(9486), + 702: uint16(8283), + 703: uint16(5378), + 704: uint16(10796), + 705: uint16(12292), + 706: uint16(11548), + 707: uint16(12293), + 708: uint16(12296), + 709: uint16(12294), + 710: uint16(8237), + 711: uint16(12295), + 712: uint16(12297), + 713: uint16(12299), + 714: uint16(12298), + 715: uint16(10535), + 716: uint16(5142), + 717: uint16(12301), + 718: uint16(12302), + 719: uint16(4366), + 720: uint16(12300), + 721: uint16(6995), + 722: uint16(12305), + 723: uint16(12304), + 724: uint16(12303), + 725: uint16(12085), + 726: uint16(12306), + 727: uint16(7261), + 728: uint16(12307), + 729: uint16(11268), + 730: uint16(11064), + 731: uint16(12309), + 732: uint16(12308), + 733: uint16(12311), + 734: uint16(12310), + 735: uint16(12312), + 736: uint16(12313), + 737: uint16(3923), + 738: uint16(5908), + 739: uint16(5658), + 740: uint16(7195), + 741: uint16(8794), + 742: uint16(5379), + 743: uint16(8007), + 744: uint16(5974), + 745: uint16(6221), + 746: uint16(12315), + 747: uint16(11047), + 748: uint16(9253), + 749: uint16(6744), + 750: uint16(12314), + 751: uint16(12316), + 752: uint16(9277), + 753: uint16(4692), + 754: uint16(12317), + 755: uint16(9565), + 756: uint16(8211), + 757: uint16(12319), + 758: uint16(12320), + 759: uint16(9995), + 760: uint16(5975), + 761: uint16(11802), + 762: uint16(12321), + 763: uint16(5381), + 764: uint16(10523), + 765: uint16(8469), + 766: uint16(5456), + 767: uint16(9236), + 768: uint16(5714), + 769: uint16(12322), + 770: uint16(12323), + 771: uint16(9537), + 772: uint16(4158), + 773: uint16(12326), + 774: uint16(6492), + 775: uint16(12325), + 776: uint16(6437), + 777: uint16(12327), + 778: uint16(17741), + 779: uint16(12328), + 780: uint16(10784), + 781: uint16(12329), + 782: uint16(12330), + 783: uint16(12331), + 784: uint16(7496), + 785: uint16(6955), + 786: uint16(4870), + 787: uint16(12334), + 788: uint16(12332), + 789: uint16(11036), + 790: uint16(12333), + 791: uint16(10297), + 792: uint16(12335), + 793: uint16(12336), + 794: uint16(12337), + 795: uint16(9278), + 796: uint16(12341), + 797: uint16(12339), + 798: uint16(12340), + 799: uint16(12338), + 800: uint16(6466), + 801: uint16(12342), + 802: uint16(11081), + 803: uint16(11587), + 804: uint16(12343), + 805: uint16(7943), + 806: uint16(12344), + 807: uint16(7225), + 808: uint16(12345), + 809: uint16(8795), + 810: uint16(11550), + 811: uint16(9279), + 812: uint16(12580), + 813: uint16(12346), + 814: uint16(21252), + 815: uint16(5412), + 816: uint16(12347), + 817: uint16(10813), + 818: uint16(7239), + 819: uint16(8539), + 820: uint16(12349), + 821: uint16(9539), + 822: uint16(12350), + 823: uint16(12351), + 824: uint16(4621), + 825: uint16(12352), + 826: uint16(5382), + 827: uint16(9515), + 828: uint16(4185), + 829: uint16(7215), + 830: uint16(9984), + 831: uint16(12353), + 832: uint16(9280), + 833: uint16(7726), + 834: uint16(12354), + 835: uint16(10507), + 836: uint16(7993), + 837: uint16(4865), + 838: uint16(4872), + 839: uint16(12355), + 840: uint16(12357), + 841: uint16(5657), + 842: uint16(12356), + 843: uint16(11602), + 844: uint16(7240), + 845: uint16(10012), + 846: uint16(10539), + 847: uint16(12358), + 848: uint16(11351), + 849: uint16(12359), + 850: uint16(12360), + 851: uint16(9309), + 852: uint16(12361), + 853: uint16(7944), + 854: uint16(6493), + 855: uint16(5715), + 856: uint16(12362), + 857: uint16(6696), + 858: uint16(6222), + 859: uint16(9029), + 860: uint16(12364), + 861: uint16(8454), + 862: uint16(6478), + 863: uint16(12365), + 864: uint16(12366), + 865: uint16(8207), + 866: uint16(12363), + 867: uint16(12368), + 868: uint16(10773), + 869: uint16(6211), + 870: uint16(12367), + 871: uint16(5716), + 872: uint16(6461), + 873: uint16(9804), + 874: uint16(12371), + 875: uint16(12369), + 876: uint16(10330), + 877: uint16(7497), + 878: uint16(12378), + 879: uint16(4675), + 880: uint16(12372), + 881: uint16(12370), + 882: uint16(8238), + 883: uint16(12374), + 884: uint16(12373), + 885: uint16(4643), + 886: uint16(5695), + 887: uint16(12379), + 888: uint16(11532), + 889: uint16(12375), + 890: uint16(12380), + 891: uint16(12377), + 892: uint16(12376), + 893: uint16(11566), + 894: uint16(5976), + 895: uint16(4386), + 896: uint16(11603), + 897: uint16(7252), + 898: uint16(9271), + 899: uint16(6212), + 900: uint16(12545), + 901: uint16(12546), + 902: uint16(11588), + 903: uint16(11786), + 904: uint16(12548), + 905: uint16(5977), + 906: uint16(12547), + 907: uint16(4622), + 908: uint16(12549), + 909: uint16(10805), + 910: uint16(8987), + 911: uint16(11269), + 912: uint16(10552), + 913: uint16(12550), + 914: uint16(20276), + 915: uint16(9487), + 916: uint16(12551), + 917: uint16(4873), + 918: uint16(11026), + 919: uint16(7424), + 920: uint16(12552), + 921: uint16(10566), + 922: uint16(12556), + 923: uint16(7945), + 924: uint16(12553), + 925: uint16(5423), + 926: uint16(12554), + 927: uint16(4874), + 928: uint16(5645), + 929: uint16(12557), + 930: uint16(12558), + 931: uint16(12559), + 932: uint16(12560), + 933: uint16(6970), + 934: uint16(5978), + 935: uint16(11069), + 936: uint16(11079), + 937: uint16(9558), + 938: uint16(10576), + 939: uint16(12561), + 940: uint16(12562), + 941: uint16(12564), + 942: uint16(12566), + 943: uint16(12565), + 944: uint16(12567), + 945: uint16(4380), + 946: uint16(10795), + 947: uint16(6491), + 948: uint16(12568), + 949: uint16(8248), + 950: uint16(7425), + 951: uint16(5384), + 952: uint16(12569), + 953: uint16(10042), + 954: uint16(12570), + 955: uint16(12571), + 956: uint16(12572), + 957: uint16(12573), + 958: uint16(10243), + 959: uint16(5447), + 960: uint16(3908), + 961: uint16(9502), + 962: uint16(12574), + 963: uint16(7196), + 964: uint16(8008), + 965: uint16(12576), + 966: uint16(12575), + 967: uint16(7426), + 968: uint16(5952), + 969: uint16(12578), + 970: uint16(10013), + 971: uint16(12579), + 972: uint16(10043), + 973: uint16(8467), + 974: uint16(8525), + 975: uint16(5383), + 976: uint16(9549), + 977: uint16(8720), + 978: uint16(9805), + 979: uint16(10797), + 980: uint16(12581), + 981: uint16(8009), + 982: uint16(5652), + 983: uint16(12582), + 984: uint16(12583), + 985: uint16(4107), + 986: uint16(3924), + 987: uint16(4940), + 988: uint16(8455), + 989: uint16(5168), + 990: uint16(11344), + 991: uint16(12586), + 992: uint16(4374), + 993: uint16(12585), + 994: uint16(5385), + 995: uint16(12587), + 996: uint16(11088), + 997: uint16(12588), + 998: uint16(11569), + 999: uint16(5979), + 1000: uint16(5909), + 1001: uint16(12589), + 1002: uint16(12591), + 1003: uint16(12590), + 1004: uint16(7742), + 1005: uint16(4120), + 1006: uint16(4157), + 1007: uint16(12592), + 1008: uint16(12593), + 1009: uint16(5910), + 1010: uint16(12594), + 1011: uint16(5197), + 1012: uint16(6673), + 1013: uint16(12595), + 1014: uint16(10835), + 1015: uint16(6420), + 1016: uint16(5177), + 1017: uint16(11270), + 1018: uint16(8239), + 1019: uint16(10014), + 1020: uint16(7004), + 1021: uint16(7206), + 1022: uint16(6983), + 1023: uint16(6996), + 1024: uint16(7253), + 1025: uint16(10015), + 1026: uint16(12598), + 1027: uint16(4130), + 1028: uint16(8240), + 1029: uint16(5980), + 1030: uint16(5924), + 1031: uint16(5446), + 1032: uint16(12602), + 1033: uint16(8704), + 1034: uint16(8541), + 1035: uint16(5386), + 1036: uint16(7427), + 1037: uint16(12603), + 1038: uint16(12601), + 1039: uint16(4387), + 1040: uint16(8517), + 1041: uint16(6935), + 1042: uint16(6698), + 1043: uint16(4101), + 1044: uint16(4687), + 1045: uint16(6213), + 1046: uint16(6697), + 1047: uint16(12604), + 1048: uint16(12605), + 1049: uint16(5160), + 1050: uint16(4645), + 1051: uint16(6214), + 1052: uint16(5159), + 1053: uint16(9022), + 1054: uint16(4100), + 1055: uint16(9488), + 1056: uint16(11037), + 1057: uint16(6144), + 1058: uint16(11352), + 1059: uint16(9254), + 1060: uint16(5981), + 1061: uint16(5646), + 1062: uint16(12614), + 1063: uint16(5442), + 1064: uint16(10793), + 1065: uint16(10044), + 1066: uint16(12613), + 1067: uint16(4925), + 1068: uint16(12608), + 1069: uint16(12609), + 1070: uint16(12611), + 1071: uint16(12612), + 1072: uint16(5178), + 1073: uint16(7744), + 1074: uint16(10508), + 1075: uint16(12610), + 1076: uint16(12606), + 1077: uint16(5954), + 1078: uint16(12607), + 1079: uint16(11779), + 1080: uint16(10577), + 1081: uint16(9031), + 1082: uint16(5953), + 1083: uint16(6223), + 1084: uint16(12615), + 1085: uint16(9532), + 1086: uint16(12619), + 1087: uint16(7005), + 1088: uint16(6997), + 1089: uint16(12622), + 1090: uint16(12620), + 1091: uint16(11010), + 1092: uint16(12617), + 1093: uint16(12626), + 1094: uint16(12621), + 1095: uint16(12624), + 1096: uint16(5925), + 1097: uint16(11038), + 1098: uint16(12625), + 1099: uint16(12627), + 1100: uint16(12629), + 1101: uint16(6479), + 1102: uint16(11809), + 1103: uint16(12618), + 1104: uint16(12616), + 1105: uint16(12628), + 1106: uint16(12623), + 1107: uint16(12631), + 1108: uint16(12802), + 1109: uint16(12633), + 1110: uint16(12637), + 1111: uint16(12800), + 1112: uint16(12634), + 1113: uint16(12829), + 1114: uint16(6472), + 1115: uint16(4624), + 1116: uint16(12632), + 1117: uint16(12804), + 1118: uint16(3925), + 1119: uint16(12803), + 1120: uint16(3844), + 1121: uint16(10281), + 1122: uint16(12801), + 1123: uint16(12635), + 1124: uint16(12630), + 1125: uint16(12636), + 1126: uint16(6439), + 1127: uint16(12805), + 1128: uint16(3926), + 1129: uint16(12814), + 1130: uint16(12806), + 1131: uint16(12807), + 1132: uint16(7428), + 1133: uint16(10824), + 1134: uint16(12812), + 1135: uint16(12811), + 1136: uint16(9230), + 1137: uint16(12813), + 1138: uint16(12810), + 1139: uint16(4115), + 1140: uint16(6421), + 1141: uint16(7695), + 1142: uint16(12808), + 1143: uint16(9281), + 1144: uint16(12809), + 1145: uint16(3841), + 1146: uint16(12819), + 1147: uint16(11266), + 1148: uint16(7430), + 1149: uint16(12825), + 1150: uint16(12824), + 1151: uint16(12815), + 1152: uint16(8482), + 1153: uint16(12816), + 1154: uint16(8526), + 1155: uint16(12821), + 1156: uint16(7429), + 1157: uint16(12818), + 1158: uint16(11075), + 1159: uint16(5659), + 1160: uint16(12822), + 1161: uint16(12823), + 1162: uint16(12820), + 1163: uint16(12826), + 1164: uint16(12817), + 1165: uint16(12832), + 1166: uint16(12837), + 1167: uint16(12833), + 1168: uint16(12828), + 1169: uint16(12838), + 1170: uint16(8208), + 1171: uint16(12840), + 1172: uint16(6145), + 1173: uint16(12830), + 1174: uint16(8796), + 1175: uint16(12834), + 1176: uint16(12827), + 1177: uint16(4876), + 1178: uint16(4941), + 1179: uint16(4676), + 1180: uint16(12835), + 1181: uint16(12831), + 1182: uint16(5717), + 1183: uint16(12841), + 1184: uint16(12839), + 1185: uint16(8242), + 1186: uint16(5161), + 1187: uint16(5387), + 1188: uint16(12836), + 1189: uint16(5459), + 1190: uint16(4131), + 1191: uint16(12845), + 1192: uint16(12843), + 1193: uint16(13062), + 1194: uint16(12848), + 1195: uint16(12842), + 1196: uint16(12846), + 1197: uint16(12844), + 1198: uint16(6699), + 1199: uint16(12847), + 1200: uint16(12850), + 1201: uint16(12855), + 1202: uint16(12853), + 1203: uint16(12852), + 1204: uint16(8721), + 1205: uint16(4388), + 1206: uint16(12849), + 1207: uint16(12851), + 1208: uint16(7431), + 1209: uint16(4114), + 1210: uint16(12854), + 1211: uint16(4413), + 1212: uint16(12865), + 1213: uint16(7515), + 1214: uint16(12861), + 1215: uint16(12859), + 1216: uint16(12860), + 1217: uint16(12862), + 1218: uint16(4124), + 1219: uint16(8216), + 1220: uint16(12856), + 1221: uint16(12857), + 1222: uint16(4697), + 1223: uint16(12864), + 1224: uint16(4942), + 1225: uint16(12867), + 1226: uint16(12863), + 1227: uint16(12866), + 1228: uint16(10509), + 1229: uint16(9524), + 1230: uint16(10007), + 1231: uint16(12869), + 1232: uint16(12868), + 1233: uint16(4644), + 1234: uint16(12870), + 1235: uint16(12873), + 1236: uint16(12872), + 1237: uint16(12871), + 1238: uint16(9752), + 1239: uint16(12874), + 1240: uint16(12875), + 1241: uint16(12877), + 1242: uint16(12876), + 1243: uint16(12879), + 1244: uint16(12882), + 1245: uint16(12880), + 1246: uint16(12878), + 1247: uint16(12881), + 1248: uint16(12883), + 1249: uint16(12884), + 1250: uint16(12885), + 1251: uint16(12886), + 1252: uint16(12887), + 1253: uint16(12324), + 1254: uint16(7003), + 1255: uint16(6700), + 1256: uint16(4434), + 1257: uint16(3927), + 1258: uint16(8739), + 1259: uint16(12888), + 1260: uint16(6403), + 1261: uint16(3886), + 1262: uint16(7741), + 1263: uint16(12889), + 1264: uint16(5926), + 1265: uint16(6224), + 1266: uint16(12891), + 1267: uint16(12890), + 1268: uint16(10559), + 1269: uint16(12892), + 1270: uint16(13056), + 1271: uint16(12893), + 1272: uint16(13057), + 1273: uint16(13058), + 1274: uint16(5718), + 1275: uint16(4159), + 1276: uint16(13059), + 1277: uint16(13061), + 1278: uint16(13060), + 1279: uint16(13063), + 1280: uint16(9273), + 1281: uint16(13064), + 1282: uint16(3860), + 1283: uint16(6462), + 1284: uint16(5660), + 1285: uint16(8750), + 1286: uint16(13065), + 1287: uint16(13066), + 1288: uint16(13068), + 1289: uint16(13069), + 1290: uint16(6467), + 1291: uint16(5424), + 1292: uint16(10774), + 1293: uint16(13067), + 1294: uint16(13070), + 1295: uint16(6432), + 1296: uint16(6146), + 1297: uint16(13074), + 1298: uint16(6404), + 1299: uint16(8722), + 1300: uint16(13071), + 1301: uint16(9017), + 1302: uint16(13075), + 1303: uint16(7745), + 1304: uint16(13073), + 1305: uint16(13076), + 1306: uint16(5662), + 1307: uint16(13077), + 1308: uint16(13078), + 1309: uint16(6147), + 1310: uint16(4639), + 1311: uint16(13080), + 1312: uint16(13081), + 1313: uint16(13082), + 1314: uint16(13079), + 1315: uint16(13072), + 1316: uint16(13083), + 1317: uint16(13084), + 1318: uint16(10819), + 1319: uint16(7498), + 1320: uint16(13086), + 1321: uint16(13087), + 1322: uint16(13085), + 1323: uint16(13089), + 1324: uint16(9751), + 1325: uint16(3911), + 1326: uint16(10293), + 1327: uint16(13090), + 1328: uint16(7516), + 1329: uint16(6936), + 1330: uint16(9788), + 1331: uint16(4943), + 1332: uint16(6474), + 1333: uint16(10808), + 1334: uint16(9489), + 1335: uint16(5719), + 1336: uint16(8494), + 1337: uint16(13088), + 1338: uint16(13091), + 1339: uint16(8483), + 1340: uint16(13092), + 1341: uint16(13093), + 1342: uint16(13095), + 1343: uint16(9032), + 1344: uint16(4877), + 1345: uint16(21248), + 1346: uint16(4160), + 1347: uint16(10578), + 1348: uint16(7499), + 1349: uint16(9255), + 1350: uint16(6469), + 1351: uint16(13101), + 1352: uint16(10524), + 1353: uint16(11580), + 1354: uint16(4435), + 1355: uint16(13097), + 1356: uint16(8217), + 1357: uint16(13100), + 1358: uint16(9282), + 1359: uint16(9256), + 1360: uint16(9283), + 1361: uint16(10008), + 1362: uint16(9004), + 1363: uint16(6440), + 1364: uint16(13096), + 1365: uint16(4181), + 1366: uint16(9237), + 1367: uint16(13098), + 1368: uint16(13094), + 1369: uint16(7727), + 1370: uint16(13102), + 1371: uint16(7213), + 1372: uint16(5388), + 1373: uint16(13103), + 1374: uint16(10567), + 1375: uint16(8284), + 1376: uint16(8997), + 1377: uint16(13105), + 1378: uint16(10798), + 1379: uint16(13106), + 1380: uint16(13111), + 1381: uint16(10510), + 1382: uint16(13110), + 1383: uint16(13104), + 1384: uint16(13107), + 1385: uint16(13109), + 1386: uint16(6405), + 1387: uint16(10536), + 1388: uint16(13112), + 1389: uint16(8740), + 1390: uint16(4436), + 1391: uint16(7500), + 1392: uint16(13114), + 1393: uint16(13113), + 1394: uint16(6215), + 1395: uint16(13115), + 1396: uint16(13117), + 1397: uint16(13116), + 1398: uint16(13119), + 1399: uint16(13108), + 1400: uint16(13121), + 1401: uint16(13120), + 1402: uint16(13118), + 1403: uint16(6701), + 1404: uint16(7728), + 1405: uint16(8243), + 1406: uint16(13122), + 1407: uint16(7963), + 1408: uint16(3916), + 1409: uint16(9795), + 1410: uint16(9018), + 1411: uint16(13124), + 1412: uint16(13123), + 1413: uint16(13125), + 1414: uint16(13126), + 1415: uint16(13127), + 1416: uint16(13128), + 1417: uint16(10544), + 1418: uint16(13129), + 1419: uint16(4389), + 1420: uint16(13130), + 1421: uint16(11291), + 1422: uint16(4623), + 1423: uint16(12584), + 1424: uint16(7207), + 1425: uint16(8478), + 1426: uint16(13131), + 1427: uint16(11082), + 1428: uint16(11027), + 1429: uint16(13133), + 1430: uint16(8518), + 1431: uint16(9238), + 1432: uint16(8479), + 1433: uint16(10294), + 1434: uint16(13134), + 1435: uint16(13135), + 1436: uint16(4186), + 1437: uint16(6937), + 1438: uint16(13136), + 1439: uint16(3887), + 1440: uint16(13137), + 1441: uint16(13138), + 1442: uint16(4161), + 1443: uint16(4944), + 1444: uint16(9535), + 1445: uint16(10579), + 1446: uint16(13142), + 1447: uint16(8244), + 1448: uint16(13141), + 1449: uint16(5663), + 1450: uint16(10810), + 1451: uint16(13140), + 1452: uint16(9284), + 1453: uint16(13144), + 1454: uint16(13143), + 1455: uint16(13146), + 1456: uint16(13145), + 1457: uint16(4187), + 1458: uint16(13147), + 1459: uint16(7432), + 1460: uint16(13149), + 1461: uint16(8708), + 1462: uint16(13148), + 1463: uint16(10514), + 1464: uint16(7254), + 1465: uint16(9274), + 1466: uint16(13312), + 1467: uint16(6148), + 1468: uint16(13313), + 1469: uint16(9728), + 1470: uint16(10045), + 1471: uint16(11056), + 1472: uint16(9732), + 1473: uint16(13322), + 1474: uint16(5143), + 1475: uint16(11300), + 1476: uint16(11022), + 1477: uint16(13579), + 1478: uint16(13314), + 1479: uint16(13317), + 1480: uint16(8484), + 1481: uint16(10775), + 1482: uint16(9257), + 1483: uint16(13318), + 1484: uint16(10820), + 1485: uint16(6441), + 1486: uint16(7433), + 1487: uint16(13319), + 1488: uint16(6703), + 1489: uint16(6702), + 1490: uint16(3864), + 1491: uint16(5927), + 1492: uint16(7946), + 1493: uint16(3888), + 1494: uint16(13323), + 1495: uint16(13324), + 1496: uint16(13321), + 1497: uint16(4119), + 1498: uint16(4878), + 1499: uint16(13320), + 1500: uint16(11044), + 1501: uint16(10256), + 1502: uint16(3847), + 1503: uint16(3928), + 1504: uint16(6704), + 1505: uint16(3889), + 1506: uint16(3842), + 1507: uint16(13329), + 1508: uint16(13327), + 1509: uint16(11035), + 1510: uint16(13330), + 1511: uint16(13328), + 1512: uint16(13326), + 1513: uint16(7696), + 1514: uint16(13325), + 1515: uint16(10553), + 1516: uint16(5955), + 1517: uint16(13334), + 1518: uint16(13335), + 1519: uint16(7434), + 1520: uint16(13331), + 1521: uint16(11787), + 1522: uint16(9771), + 1523: uint16(13333), + 1524: uint16(6406), + 1525: uint16(13336), + 1526: uint16(10295), + 1527: uint16(13337), + 1528: uint16(13332), + 1529: uint16(11034), + 1530: uint16(9789), + 1531: uint16(13338), + 1532: uint16(10257), + 1533: uint16(13339), + 1534: uint16(13343), + 1535: uint16(13340), + 1536: uint16(4390), + 1537: uint16(13342), + 1538: uint16(6938), + 1539: uint16(13341), + 1540: uint16(5720), + 1541: uint16(13355), + 1542: uint16(13348), + 1543: uint16(13345), + 1544: uint16(8771), + 1545: uint16(13344), + 1546: uint16(13346), + 1547: uint16(13347), + 1548: uint16(13349), + 1549: uint16(13350), + 1550: uint16(4945), + 1551: uint16(13352), + 1552: uint16(13351), + 1553: uint16(13353), + 1554: uint16(7501), + 1555: uint16(13356), + 1556: uint16(9019), + 1557: uint16(4132), + 1558: uint16(13354), + 1559: uint16(13357), + 1560: uint16(13358), + 1561: uint16(13361), + 1562: uint16(13359), + 1563: uint16(13360), + 1564: uint16(6705), + 1565: uint16(13362), + 1566: uint16(6149), + 1567: uint16(13363), + 1568: uint16(6745), + 1569: uint16(8471), + 1570: uint16(13364), + 1571: uint16(13365), + 1572: uint16(6713), + 1573: uint16(6150), + 1574: uint16(11057), + 1575: uint16(5127), + 1576: uint16(5928), + 1577: uint16(13366), + 1578: uint16(4663), + 1579: uint16(13367), + 1580: uint16(8472), + 1581: uint16(13368), + 1582: uint16(13570), + 1583: uint16(13369), + 1584: uint16(13370), + 1585: uint16(13371), + 1586: uint16(13373), + 1587: uint16(13374), + 1588: uint16(13375), + 1589: uint16(8527), + 1590: uint16(4102), + 1591: uint16(6984), + 1592: uint16(3873), + 1593: uint16(8246), + 1594: uint16(4879), + 1595: uint16(6932), + 1596: uint16(6151), + 1597: uint16(9285), + 1598: uint16(7168), + 1599: uint16(4880), + 1600: uint16(8775), + 1601: uint16(9033), + 1602: uint16(3863), + 1603: uint16(5144), + 1604: uint16(10580), + 1605: uint16(6945), + 1606: uint16(5169), + 1607: uint16(8010), + 1608: uint16(6939), + 1609: uint16(11271), + 1610: uint16(13376), + 1611: uint16(5179), + 1612: uint16(6442), + 1613: uint16(4625), + 1614: uint16(4162), + 1615: uint16(7435), + 1616: uint16(4391), + 1617: uint16(13377), + 1618: uint16(11301), + 1619: uint16(7208), + 1620: uint16(6979), + 1621: uint16(13378), + 1622: uint16(4946), + 1623: uint16(9521), + 1624: uint16(11016), + 1625: uint16(13379), + 1626: uint16(13380), + 1627: uint16(10296), + 1628: uint16(13382), + 1629: uint16(4871), + 1630: uint16(5462), + 1631: uint16(13381), + 1632: uint16(4881), + 1633: uint16(7697), + 1634: uint16(13386), + 1635: uint16(6656), + 1636: uint16(4392), + 1637: uint16(13385), + 1638: uint16(13383), + 1639: uint16(13387), + 1640: uint16(13384), + 1641: uint16(9738), + 1642: uint16(15148), + 1643: uint16(7698), + 1644: uint16(13388), + 1645: uint16(11551), + 1646: uint16(13389), + 1647: uint16(13391), + 1648: uint16(8797), + 1649: uint16(13390), + 1650: uint16(7938), + 1651: uint16(6746), + 1652: uint16(8495), + 1653: uint16(6998), + 1654: uint16(10324), + 1655: uint16(8011), + 1656: uint16(6956), + 1657: uint16(13392), + 1658: uint16(7436), + 1659: uint16(13393), + 1660: uint16(13394), + 1661: uint16(3890), + 1662: uint16(8473), + 1663: uint16(7729), + 1664: uint16(13395), + 1665: uint16(9490), + 1666: uint16(7437), + 1667: uint16(7438), + 1668: uint16(13396), + 1669: uint16(8012), + 1670: uint16(7439), + 1671: uint16(13397), + 1672: uint16(13398), + 1673: uint16(11071), + 1674: uint16(13399), + 1675: uint16(5413), + 1676: uint16(7169), + 1677: uint16(13400), + 1678: uint16(13401), + 1679: uint16(6971), + 1680: uint16(7691), + 1681: uint16(9555), + 1682: uint16(7731), + 1683: uint16(10071), + 1684: uint16(9729), + 1685: uint16(5416), + 1686: uint16(13402), + 1687: uint16(5198), + 1688: uint16(13403), + 1689: uint16(5469), + 1690: uint16(9518), + 1691: uint16(4367), + 1692: uint16(6706), + 1693: uint16(13404), + 1694: uint16(13569), + 1695: uint16(13568), + 1696: uint16(5468), + 1697: uint16(13405), + 1698: uint16(9239), + 1699: uint16(8463), + 1700: uint16(9258), + 1701: uint16(6951), + 1702: uint16(8247), + 1703: uint16(11353), + 1704: uint16(13571), + 1705: uint16(13572), + 1706: uint16(9525), + 1707: uint16(6674), + 1708: uint16(13574), + 1709: uint16(13575), + 1710: uint16(13576), + 1711: uint16(4947), + 1712: uint16(13577), + 1713: uint16(13578), + 1714: uint16(4363), + 1715: uint16(8218), + 1716: uint16(4931), + 1717: uint16(13580), + 1718: uint16(11015), + 1719: uint16(8497), + 1720: uint16(4664), + 1721: uint16(13582), + 1722: uint16(13584), + 1723: uint16(4926), + 1724: uint16(13581), + 1725: uint16(13583), + 1726: uint16(13586), + 1727: uint16(13585), + 1728: uint16(13587), + 1729: uint16(13588), + 1730: uint16(9500), + 1731: uint16(5389), + 1732: uint16(4420), + 1733: uint16(13589), + 1734: uint16(13594), + 1735: uint16(13592), + 1736: uint16(10582), + 1737: uint16(10581), + 1738: uint16(9286), + 1739: uint16(13591), + 1740: uint16(7219), + 1741: uint16(13590), + 1742: uint16(7761), + 1743: uint16(13595), + 1744: uint16(6473), + 1745: uint16(13601), + 1746: uint16(13602), + 1747: uint16(13596), + 1748: uint16(4626), + 1749: uint16(13597), + 1750: uint16(13606), + 1751: uint16(13605), + 1752: uint16(13604), + 1753: uint16(13600), + 1754: uint16(13599), + 1755: uint16(13603), + 1756: uint16(10583), + 1757: uint16(13610), + 1758: uint16(13607), + 1759: uint16(13609), + 1760: uint16(11345), + 1761: uint16(13608), + 1762: uint16(13598), + 1763: uint16(7762), + 1764: uint16(13611), + 1765: uint16(6422), + 1766: uint16(13612), + 1767: uint16(13613), + 1768: uint16(13616), + 1769: uint16(13615), + 1770: uint16(13614), + 1771: uint16(9287), + 1772: uint16(13593), + 1773: uint16(13622), + 1774: uint16(13618), + 1775: uint16(13617), + 1776: uint16(13619), + 1777: uint16(13620), + 1778: uint16(13623), + 1779: uint16(11589), + 1780: uint16(13624), + 1781: uint16(13621), + 1782: uint16(13625), + 1783: uint16(4927), + 1784: uint16(13626), + 1785: uint16(13628), + 1786: uint16(13627), + 1787: uint16(13629), + 1788: uint16(13630), + 1789: uint16(8013), + 1790: uint16(7170), + 1791: uint16(7235), + 1792: uint16(8258), + 1793: uint16(6152), + 1794: uint16(6423), + 1795: uint16(6153), + 1796: uint16(5199), + 1797: uint16(13631), + 1798: uint16(6424), + 1799: uint16(5929), + 1800: uint16(13632), + 1801: uint16(11013), + 1802: uint16(9762), + 1803: uint16(13633), + 1804: uint16(6154), + 1805: uint16(4875), + 1806: uint16(8710), + 1807: uint16(5425), + 1808: uint16(6707), + 1809: uint16(10298), + 1810: uint16(10016), + 1811: uint16(13634), + 1812: uint16(4948), + 1813: uint16(13637), + 1814: uint16(8960), + 1815: uint16(13636), + 1816: uint16(13635), + 1817: uint16(13638), + 1818: uint16(9034), + 1819: uint16(7746), + 1820: uint16(6708), + 1821: uint16(7977), + 1822: uint16(8498), + 1823: uint16(5121), + 1824: uint16(8961), + 1825: uint16(13639), + 1826: uint16(13640), + 1827: uint16(7502), + 1828: uint16(10776), + 1829: uint16(13643), + 1830: uint16(13642), + 1831: uint16(13641), + 1832: uint16(10332), + 1833: uint16(13650), + 1834: uint16(10809), + 1835: uint16(13644), + 1836: uint16(13646), + 1837: uint16(10826), + 1838: uint16(13645), + 1839: uint16(13647), + 1840: uint16(9991), + 1841: uint16(13648), + 1842: uint16(10525), + 1843: uint16(13649), + 1844: uint16(4882), + 1845: uint16(10526), + 1846: uint16(9742), + 1847: uint16(13651), + 1848: uint16(13652), + 1849: uint16(6155), + 1850: uint16(4883), + 1851: uint16(13653), + 1852: uint16(5911), + 1853: uint16(11299), + 1854: uint16(11272), + 1855: uint16(4949), + 1856: uint16(13655), + 1857: uint16(8962), + 1858: uint16(6156), + 1859: uint16(7440), + 1860: uint16(10046), + 1861: uint16(7441), + 1862: uint16(7255), + 1863: uint16(9035), + 1864: uint16(10584), + 1865: uint16(9240), + 1866: uint16(6157), + 1867: uint16(10299), + 1868: uint16(13656), + 1869: uint16(9272), + 1870: uint16(6433), + 1871: uint16(5930), + 1872: uint16(9036), + 1873: uint16(3874), + 1874: uint16(7245), + 1875: uint16(6158), + 1876: uint16(11302), + 1877: uint16(13657), + 1878: uint16(13658), + 1879: uint16(9776), + 1880: uint16(13659), + 1881: uint16(11606), + 1882: uint16(11788), + 1883: uint16(13661), + 1884: uint16(13660), + 1885: uint16(4646), + 1886: uint16(13824), + 1887: uint16(13827), + 1888: uint16(13828), + 1889: uint16(13826), + 1890: uint16(10271), + 1891: uint16(7442), + 1892: uint16(13830), + 1893: uint16(13829), + 1894: uint16(13825), + 1895: uint16(13831), + 1896: uint16(13832), + 1897: uint16(13833), + 1898: uint16(13836), + 1899: uint16(13834), + 1900: uint16(13835), + 1901: uint16(13837), + 1902: uint16(4163), + 1903: uint16(9037), + 1904: uint16(13838), + 1905: uint16(5721), + 1906: uint16(4437), + 1907: uint16(9749), + 1908: uint16(13839), + 1909: uint16(9562), + 1910: uint16(10554), + 1911: uint16(13840), + 1912: uint16(11789), + 1913: uint16(13841), + 1914: uint16(10527), + 1915: uint16(13844), + 1916: uint16(12032), + 1917: uint16(12048), + 1918: uint16(6927), + 1919: uint16(9556), + 1920: uint16(13845), + 1921: uint16(5180), + 1922: uint16(8963), + 1923: uint16(3929), + 1924: uint16(13846), + 1925: uint16(10501), + 1926: uint16(6159), + 1927: uint16(8751), + 1928: uint16(9038), + 1929: uint16(11086), + 1930: uint16(5912), + 1931: uint16(5931), + 1932: uint16(13847), + 1933: uint16(13848), + 1934: uint16(13854), + 1935: uint16(6980), + 1936: uint16(8964), + 1937: uint16(5390), + 1938: uint16(13849), + 1939: uint16(10250), + 1940: uint16(8741), + 1941: uint16(13850), + 1942: uint16(13851), + 1943: uint16(5391), + 1944: uint16(13852), + 1945: uint16(13853), + 1946: uint16(13855), + 1947: uint16(9301), + 1948: uint16(13856), + 1949: uint16(13857), + 1950: uint16(13858), + 1951: uint16(13843), + 1952: uint16(13842), + 1953: uint16(13859), + 1954: uint16(5664), + 1955: uint16(10246), + 1956: uint16(6443), + 1957: uint16(10262), + 1958: uint16(8965), + 1959: uint16(10282), + 1960: uint16(13860), + 1961: uint16(7443), + 1962: uint16(4133), + 1963: uint16(13861), + 1964: uint16(13862), + 1965: uint16(11089), + 1966: uint16(10047), + 1967: uint16(13865), + 1968: uint16(4188), + 1969: uint16(7947), + 1970: uint16(13864), + 1971: uint16(13863), + 1972: uint16(5665), + 1973: uint16(8499), + 1974: uint16(13869), + 1975: uint16(13867), + 1976: uint16(13866), + 1977: uint16(11526), + 1978: uint16(5956), + 1979: uint16(7256), + 1980: uint16(13868), + 1981: uint16(9259), + 1982: uint16(7197), + 1983: uint16(9503), + 1984: uint16(13872), + 1985: uint16(13871), + 1986: uint16(13870), + 1987: uint16(13873), + 1988: uint16(5957), + 1989: uint16(13874), + 1990: uint16(10331), + 1991: uint16(7226), + 1992: uint16(13875), + 1993: uint16(10072), + 1994: uint16(9504), + 1995: uint16(8966), + 1996: uint16(9231), + 1997: uint16(13876), + 1998: uint16(5130), + 1999: uint16(7699), + 2000: uint16(10251), + 2001: uint16(4950), + 2002: uint16(9733), + 2003: uint16(13877), + 2004: uint16(6709), + 2005: uint16(10777), + 2006: uint16(10778), + 2007: uint16(4189), + 2008: uint16(13882), + 2009: uint16(8776), + 2010: uint16(13879), + 2011: uint16(4438), + 2012: uint16(14092), + 2013: uint16(13881), + 2014: uint16(9743), + 2015: uint16(13880), + 2016: uint16(13878), + 2017: uint16(6233), + 2018: uint16(13884), + 2019: uint16(13890), + 2020: uint16(13896), + 2021: uint16(13888), + 2022: uint16(9275), + 2023: uint16(13893), + 2024: uint16(10300), + 2025: uint16(13887), + 2026: uint16(13892), + 2027: uint16(11590), + 2028: uint16(6710), + 2029: uint16(8500), + 2030: uint16(13885), + 2031: uint16(5181), + 2032: uint16(13895), + 2033: uint16(7948), + 2034: uint16(4164), + 2035: uint16(13889), + 2036: uint16(4439), + 2037: uint16(13894), + 2038: uint16(5392), + 2039: uint16(13891), + 2040: uint16(13897), + 2041: uint16(13899), + 2042: uint16(13909), + 2043: uint16(13907), + 2044: uint16(13904), + 2045: uint16(13903), + 2046: uint16(11607), + 2047: uint16(13905), + 2048: uint16(5393), + 2049: uint16(6160), + 2050: uint16(7257), + 2051: uint16(13912), + 2052: uint16(13898), + 2053: uint16(13902), + 2054: uint16(13886), + 2055: uint16(4441), + 2056: uint16(13906), + 2057: uint16(13908), + 2058: uint16(8752), + 2059: uint16(6407), + 2060: uint16(4375), + 2061: uint16(13900), + 2062: uint16(13911), + 2063: uint16(13910), + 2064: uint16(5394), + 2065: uint16(8456), + 2066: uint16(4677), + 2067: uint16(5666), + 2068: uint16(13901), + 2069: uint16(13913), + 2070: uint16(13916), + 2071: uint16(14080), + 2072: uint16(6940), + 2073: uint16(14086), + 2074: uint16(9039), + 2075: uint16(13914), + 2076: uint16(14084), + 2077: uint16(4440), + 2078: uint16(14082), + 2079: uint16(14083), + 2080: uint16(13917), + 2081: uint16(14081), + 2082: uint16(5958), + 2083: uint16(11273), + 2084: uint16(4884), + 2085: uint16(4152), + 2086: uint16(14085), + 2087: uint16(9753), + 2088: uint16(3852), + 2089: uint16(10048), + 2090: uint16(13883), + 2091: uint16(14091), + 2092: uint16(14095), + 2093: uint16(11076), + 2094: uint16(14088), + 2095: uint16(9288), + 2096: uint16(14093), + 2097: uint16(7503), + 2098: uint16(14094), + 2099: uint16(9526), + 2100: uint16(11814), + 2101: uint16(14090), + 2102: uint16(14096), + 2103: uint16(6234), + 2104: uint16(7978), + 2105: uint16(3891), + 2106: uint16(14089), + 2107: uint16(14087), + 2108: uint16(8249), + 2109: uint16(13915), + 2110: uint16(6675), + 2111: uint16(8485), + 2112: uint16(14108), + 2113: uint16(8250), + 2114: uint16(14103), + 2115: uint16(14100), + 2116: uint16(14101), + 2117: uint16(6981), + 2118: uint16(14104), + 2119: uint16(14107), + 2120: uint16(14102), + 2121: uint16(7172), + 2122: uint16(14105), + 2123: uint16(14099), + 2124: uint16(11099), + 2125: uint16(11098), + 2126: uint16(14109), + 2127: uint16(14110), + 2128: uint16(3892), + 2129: uint16(14098), + 2130: uint16(5457), + 2131: uint16(3845), + 2132: uint16(4885), + 2133: uint16(14106), + 2134: uint16(14114), + 2135: uint16(14113), + 2136: uint16(14118), + 2137: uint16(14119), + 2138: uint16(14117), + 2139: uint16(14120), + 2140: uint16(14112), + 2141: uint16(14116), + 2142: uint16(14121), + 2143: uint16(14122), + 2144: uint16(14111), + 2145: uint16(6747), + 2146: uint16(14115), + 2147: uint16(8501), + 2148: uint16(6161), + 2149: uint16(14097), + 2150: uint16(7700), + 2151: uint16(14135), + 2152: uint16(10568), + 2153: uint16(14125), + 2154: uint16(14126), + 2155: uint16(14127), + 2156: uint16(14134), + 2157: uint16(14133), + 2158: uint16(10844), + 2159: uint16(4886), + 2160: uint16(14131), + 2161: uint16(5668), + 2162: uint16(4627), + 2163: uint16(14128), + 2164: uint16(11543), + 2165: uint16(14130), + 2166: uint16(3893), + 2167: uint16(14132), + 2168: uint16(14123), + 2169: uint16(14129), + 2170: uint16(14136), + 2171: uint16(5667), + 2172: uint16(14124), + 2173: uint16(11324), + 2174: uint16(11274), + 2175: uint16(14139), + 2176: uint16(14143), + 2177: uint16(8285), + 2178: uint16(11608), + 2179: uint16(14144), + 2180: uint16(14141), + 2181: uint16(14138), + 2182: uint16(14137), + 2183: uint16(14142), + 2184: uint16(10511), + 2185: uint16(9491), + 2186: uint16(5669), + 2187: uint16(14145), + 2188: uint16(14140), + 2189: uint16(14146), + 2190: uint16(5722), + 2191: uint16(4368), + 2192: uint16(14154), + 2193: uint16(4887), + 2194: uint16(14152), + 2195: uint16(14153), + 2196: uint16(6408), + 2197: uint16(14151), + 2198: uint16(14149), + 2199: uint16(14148), + 2200: uint16(14155), + 2201: uint16(14147), + 2202: uint16(14157), + 2203: uint16(4442), + 2204: uint16(14159), + 2205: uint16(14158), + 2206: uint16(8967), + 2207: uint16(14162), + 2208: uint16(14160), + 2209: uint16(14150), + 2210: uint16(5723), + 2211: uint16(14161), + 2212: uint16(14165), + 2213: uint16(14164), + 2214: uint16(14166), + 2215: uint16(14163), + 2216: uint16(14167), + 2217: uint16(14168), + 2218: uint16(14169), + 2219: uint16(10569), + 2220: uint16(14171), + 2221: uint16(14170), + 2222: uint16(7198), + 2223: uint16(7949), + 2224: uint16(4421), + 2225: uint16(4443), + 2226: uint16(14172), + 2227: uint16(3870), + 2228: uint16(7979), + 2229: uint16(14173), + 2230: uint16(19234), + 2231: uint16(14336), + 2232: uint16(5696), + 2233: uint16(14337), + 2234: uint16(8014), + 2235: uint16(14338), + 2236: uint16(14339), + 2237: uint16(5145), + 2238: uint16(14340), + 2239: uint16(14341), + 2240: uint16(14342), + 2241: uint16(8502), + 2242: uint16(5932), + 2243: uint16(11072), + 2244: uint16(10779), + 2245: uint16(7241), + 2246: uint16(14343), + 2247: uint16(8015), + 2248: uint16(19740), + 2249: uint16(10049), + 2250: uint16(6985), + 2251: uint16(6444), + 2252: uint16(14344), + 2253: uint16(8486), + 2254: uint16(10502), + 2255: uint16(8528), + 2256: uint16(14347), + 2257: uint16(14345), + 2258: uint16(14348), + 2259: uint16(14346), + 2260: uint16(14349), + 2261: uint16(10512), + 2262: uint16(3862), + 2263: uint16(10301), + 2264: uint16(10050), + 2265: uint16(14350), + 2266: uint16(14353), + 2267: uint16(7444), + 2268: uint16(5146), + 2269: uint16(14351), + 2270: uint16(14358), + 2271: uint16(7445), + 2272: uint16(14352), + 2273: uint16(9763), + 2274: uint16(11325), + 2275: uint16(14354), + 2276: uint16(14355), + 2277: uint16(14359), + 2278: uint16(9289), + 2279: uint16(14356), + 2280: uint16(6162), + 2281: uint16(7997), + 2282: uint16(14373), + 2283: uint16(10003), + 2284: uint16(8529), + 2285: uint16(10051), + 2286: uint16(14604), + 2287: uint16(10585), + 2288: uint16(9040), + 2289: uint16(10836), + 2290: uint16(14362), + 2291: uint16(4352), + 2292: uint16(8777), + 2293: uint16(14371), + 2294: uint16(8723), + 2295: uint16(14365), + 2296: uint16(14372), + 2297: uint16(14367), + 2298: uint16(14374), + 2299: uint16(14370), + 2300: uint16(14369), + 2301: uint16(9806), + 2302: uint16(14363), + 2303: uint16(4444), + 2304: uint16(14361), + 2305: uint16(5200), + 2306: uint16(8530), + 2307: uint16(14357), + 2308: uint16(14360), + 2309: uint16(6163), + 2310: uint16(7994), + 2311: uint16(7446), + 2312: uint16(14368), + 2313: uint16(9777), + 2314: uint16(5201), + 2315: uint16(4647), + 2316: uint16(4678), + 2317: uint16(7680), + 2318: uint16(14376), + 2319: uint16(14381), + 2320: uint16(14377), + 2321: uint16(5724), + 2322: uint16(14382), + 2323: uint16(6657), + 2324: uint16(6216), + 2325: uint16(7173), + 2326: uint16(14364), + 2327: uint16(6748), + 2328: uint16(14379), + 2329: uint16(6711), + 2330: uint16(14380), + 2331: uint16(3875), + 2332: uint16(14375), + 2333: uint16(8968), + 2334: uint16(5202), + 2335: uint16(5395), + 2336: uint16(14378), + 2337: uint16(3846), + 2338: uint16(6434), + 2339: uint16(7701), + 2340: uint16(9041), + 2341: uint16(10035), + 2342: uint16(14384), + 2343: uint16(8253), + 2344: uint16(8457), + 2345: uint16(6666), + 2346: uint16(14385), + 2347: uint16(14387), + 2348: uint16(14383), + 2349: uint16(10560), + 2350: uint16(8988), + 2351: uint16(8251), + 2352: uint16(10586), + 2353: uint16(6957), + 2354: uint16(14399), + 2355: uint16(14398), + 2356: uint16(7767), + 2357: uint16(5725), + 2358: uint16(14392), + 2359: uint16(7448), + 2360: uint16(9543), + 2361: uint16(9744), + 2362: uint16(14390), + 2363: uint16(8252), + 2364: uint16(6999), + 2365: uint16(14395), + 2366: uint16(7447), + 2367: uint16(14389), + 2368: uint16(14394), + 2369: uint16(9778), + 2370: uint16(14388), + 2371: uint16(5632), + 2372: uint16(4668), + 2373: uint16(14396), + 2374: uint16(11530), + 2375: uint16(6445), + 2376: uint16(8724), + 2377: uint16(14393), + 2378: uint16(7995), + 2379: uint16(6164), + 2380: uint16(7747), + 2381: uint16(4165), + 2382: uint16(8219), + 2383: uint16(14391), + 2384: uint16(5156), + 2385: uint16(5670), + 2386: uint16(9006), + 2387: uint16(14397), + 2388: uint16(8254), + 2389: uint16(14400), + 2390: uint16(14402), + 2391: uint16(8470), + 2392: uint16(14408), + 2393: uint16(14403), + 2394: uint16(14405), + 2395: uint16(10272), + 2396: uint16(9042), + 2397: uint16(14406), + 2398: uint16(11275), + 2399: uint16(11303), + 2400: uint16(4888), + 2401: uint16(3853), + 2402: uint16(14404), + 2403: uint16(14401), + 2404: uint16(4951), + 2405: uint16(4166), + 2406: uint16(14407), + 2407: uint16(11304), + 2408: uint16(14411), + 2409: uint16(8474), + 2410: uint16(14418), + 2411: uint16(14412), + 2412: uint16(14409), + 2413: uint16(14416), + 2414: uint16(14386), + 2415: uint16(14413), + 2416: uint16(14417), + 2417: uint16(10017), + 2418: uint16(9290), + 2419: uint16(14410), + 2420: uint16(14414), + 2421: uint16(5671), + 2422: uint16(6480), + 2423: uint16(7996), + 2424: uint16(14422), + 2425: uint16(9221), + 2426: uint16(14419), + 2427: uint16(10815), + 2428: uint16(14420), + 2429: uint16(14421), + 2430: uint16(11053), + 2431: uint16(7937), + 2432: uint16(5697), + 2433: uint16(14428), + 2434: uint16(6676), + 2435: uint16(14425), + 2436: uint16(14424), + 2437: uint16(9745), + 2438: uint16(9492), + 2439: uint16(9232), + 2440: uint16(14426), + 2441: uint16(14427), + 2442: uint16(10318), + 2443: uint16(9764), + 2444: uint16(6658), + 2445: uint16(8016), + 2446: uint16(10799), + 2447: uint16(4648), + 2448: uint16(14596), + 2449: uint16(14429), + 2450: uint16(11305), + 2451: uint16(14598), + 2452: uint16(14594), + 2453: uint16(14595), + 2454: uint16(8255), + 2455: uint16(14593), + 2456: uint16(14366), + 2457: uint16(14597), + 2458: uint16(14592), + 2459: uint16(14602), + 2460: uint16(14603), + 2461: uint16(9222), + 2462: uint16(14605), + 2463: uint16(6659), + 2464: uint16(14600), + 2465: uint16(5147), + 2466: uint16(14606), + 2467: uint16(14599), + 2468: uint16(14610), + 2469: uint16(14609), + 2470: uint16(14608), + 2471: uint16(14611), + 2472: uint16(14613), + 2473: uint16(7504), + 2474: uint16(14612), + 2475: uint16(14616), + 2476: uint16(14614), + 2477: uint16(14615), + 2478: uint16(14415), + 2479: uint16(14618), + 2480: uint16(14617), + 2481: uint16(14423), + 2482: uint16(14619), + 2483: uint16(14607), + 2484: uint16(6712), + 2485: uint16(14620), + 2486: uint16(14621), + 2487: uint16(14623), + 2488: uint16(14622), + 2489: uint16(14624), + 2490: uint16(4445), + 2491: uint16(6165), + 2492: uint16(10587), + 2493: uint16(7950), + 2494: uint16(5933), + 2495: uint16(14626), + 2496: uint16(14629), + 2497: uint16(10289), + 2498: uint16(5182), + 2499: uint16(14628), + 2500: uint16(14627), + 2501: uint16(9779), + 2502: uint16(14630), + 2503: uint16(5396), + 2504: uint16(14632), + 2505: uint16(14631), + 2506: uint16(4889), + 2507: uint16(6677), + 2508: uint16(9527), + 2509: uint16(5672), + 2510: uint16(7763), + 2511: uint16(14633), + 2512: uint16(7951), + 2513: uint16(9223), + 2514: uint16(10302), + 2515: uint16(14634), + 2516: uint16(14635), + 2517: uint16(14636), + 2518: uint16(10519), + 2519: uint16(13372), + 2520: uint16(7973), + 2521: uint16(10283), + 2522: uint16(6455), + 2523: uint16(10052), + 2524: uint16(10018), + 2525: uint16(9260), + 2526: uint16(11552), + 2527: uint16(14638), + 2528: uint16(6959), + 2529: uint16(14639), + 2530: uint16(3861), + 2531: uint16(5427), + 2532: uint16(7980), + 2533: uint16(10303), + 2534: uint16(14640), + 2535: uint16(6689), + 2536: uint16(8742), + 2537: uint16(6714), + 2538: uint16(7702), + 2539: uint16(14641), + 2540: uint16(10588), + 2541: uint16(4182), + 2542: uint16(6715), + 2543: uint16(14644), + 2544: uint16(14642), + 2545: uint16(14645), + 2546: uint16(11544), + 2547: uint16(14643), + 2548: uint16(8026), + 2549: uint16(14646), + 2550: uint16(8465), + 2551: uint16(14647), + 2552: uint16(4953), + 2553: uint16(14649), + 2554: uint16(14648), + 2555: uint16(14650), + 2556: uint16(14651), + 2557: uint16(4954), + 2558: uint16(9563), + 2559: uint16(8725), + 2560: uint16(5195), + 2561: uint16(6716), + 2562: uint16(8256), + 2563: uint16(7227), + 2564: uint16(3855), + 2565: uint16(14652), + 2566: uint16(4353), + 2567: uint16(14656), + 2568: uint16(6166), + 2569: uint16(14655), + 2570: uint16(6410), + 2571: uint16(7449), + 2572: uint16(14654), + 2573: uint16(7450), + 2574: uint16(11039), + 2575: uint16(6409), + 2576: uint16(3894), + 2577: uint16(7981), + 2578: uint16(14661), + 2579: uint16(7952), + 2580: uint16(4134), + 2581: uint16(7220), + 2582: uint16(10821), + 2583: uint16(6481), + 2584: uint16(7451), + 2585: uint16(7942), + 2586: uint16(14660), + 2587: uint16(14658), + 2588: uint16(14659), + 2589: uint16(8778), + 2590: uint16(14853), + 2591: uint16(14665), + 2592: uint16(6749), + 2593: uint16(6167), + 2594: uint16(14663), + 2595: uint16(14664), + 2596: uint16(7703), + 2597: uint16(14662), + 2598: uint16(6670), + 2599: uint16(14667), + 2600: uint16(14666), + 2601: uint16(14671), + 2602: uint16(14672), + 2603: uint16(14668), + 2604: uint16(4609), + 2605: uint16(14669), + 2606: uint16(14670), + 2607: uint16(10036), + 2608: uint16(10304), + 2609: uint16(5673), + 2610: uint16(14673), + 2611: uint16(7953), + 2612: uint16(7452), + 2613: uint16(8753), + 2614: uint16(5414), + 2615: uint16(14674), + 2616: uint16(14678), + 2617: uint16(4394), + 2618: uint16(14675), + 2619: uint16(14677), + 2620: uint16(14676), + 2621: uint16(7242), + 2622: uint16(8743), + 2623: uint16(3876), + 2624: uint16(14679), + 2625: uint16(14680), + 2626: uint16(8969), + 2627: uint16(11600), + 2628: uint16(6690), + 2629: uint16(10570), + 2630: uint16(10780), + 2631: uint16(14849), + 2632: uint16(14682), + 2633: uint16(14685), + 2634: uint16(14684), + 2635: uint16(14681), + 2636: uint16(14848), + 2637: uint16(9533), + 2638: uint16(14683), + 2639: uint16(14850), + 2640: uint16(7243), + 2641: uint16(14851), + 2642: uint16(11306), + 2643: uint16(9815), + 2644: uint16(14852), + 2645: uint16(14854), + 2646: uint16(14855), + 2647: uint16(14856), + 2648: uint16(5417), + 2649: uint16(4135), + 2650: uint16(6168), + 2651: uint16(14857), + 2652: uint16(14858), + 2653: uint16(7248), + 2654: uint16(8257), + 2655: uint16(12599), + 2656: uint16(8221), + 2657: uint16(8220), + 2658: uint16(8503), + 2659: uint16(6438), + 2660: uint16(12113), + 2661: uint16(5709), + 2662: uint16(11276), + 2663: uint16(10589), + 2664: uint16(10333), + 2665: uint16(14859), + 2666: uint16(6482), + 2667: uint16(8990), + 2668: uint16(14860), + 2669: uint16(11790), + 2670: uint16(10781), + 2671: uint16(8970), + 2672: uint16(14861), + 2673: uint16(4955), + 2674: uint16(14862), + 2675: uint16(14863), + 2676: uint16(11065), + 2677: uint16(11011), + 2678: uint16(10837), + 2679: uint16(10811), + 2680: uint16(6660), + 2681: uint16(14865), + 2682: uint16(6986), + 2683: uint16(10800), + 2684: uint16(14867), + 2685: uint16(14870), + 2686: uint16(14869), + 2687: uint16(4952), + 2688: uint16(5183), + 2689: uint16(14866), + 2690: uint16(14868), + 2691: uint16(14871), + 2692: uint16(7768), + 2693: uint16(11354), + 2694: uint16(3880), + 2695: uint16(6463), + 2696: uint16(8475), + 2697: uint16(6972), + 2698: uint16(7506), + 2699: uint16(14874), + 2700: uint16(9261), + 2701: uint16(14872), + 2702: uint16(8458), + 2703: uint16(14873), + 2704: uint16(7505), + 2705: uint16(11068), + 2706: uint16(14875), + 2707: uint16(14876), + 2708: uint16(11335), + 2709: uint16(14881), + 2710: uint16(6169), + 2711: uint16(9780), + 2712: uint16(14878), + 2713: uint16(9291), + 2714: uint16(14653), + 2715: uint16(14657), + 2716: uint16(5166), + 2717: uint16(9766), + 2718: uint16(14880), + 2719: uint16(7453), + 2720: uint16(10019), + 2721: uint16(14886), + 2722: uint16(10073), + 2723: uint16(14877), + 2724: uint16(14883), + 2725: uint16(14882), + 2726: uint16(7982), + 2727: uint16(10828), + 2728: uint16(11570), + 2729: uint16(10822), + 2730: uint16(4395), + 2731: uint16(6717), + 2732: uint16(11815), + 2733: uint16(14885), + 2734: uint16(7764), + 2735: uint16(14884), + 2736: uint16(14879), + 2737: uint16(5934), + 2738: uint16(14891), + 2739: uint16(14889), + 2740: uint16(4396), + 2741: uint16(14887), + 2742: uint16(14893), + 2743: uint16(14899), + 2744: uint16(8487), + 2745: uint16(10528), + 2746: uint16(14901), + 2747: uint16(10241), + 2748: uint16(14900), + 2749: uint16(9807), + 2750: uint16(10782), + 2751: uint16(4890), + 2752: uint16(8022), + 2753: uint16(7199), + 2754: uint16(9010), + 2755: uint16(11277), + 2756: uint16(14896), + 2757: uint16(14895), + 2758: uint16(14897), + 2759: uint16(14894), + 2760: uint16(14902), + 2761: uint16(14892), + 2762: uint16(14890), + 2763: uint16(14898), + 2764: uint16(14888), + 2765: uint16(8779), + 2766: uint16(11095), + 2767: uint16(6949), + 2768: uint16(6483), + 2769: uint16(6425), + 2770: uint16(10830), + 2771: uint16(4640), + 2772: uint16(9005), + 2773: uint16(9513), + 2774: uint16(4136), + 2775: uint16(8017), + 2776: uint16(7955), + 2777: uint16(5641), + 2778: uint16(14904), + 2779: uint16(6170), + 2780: uint16(4699), + 2781: uint16(14906), + 2782: uint16(4691), + 2783: uint16(14912), + 2784: uint16(14909), + 2785: uint16(8018), + 2786: uint16(4650), + 2787: uint16(6411), + 2788: uint16(4649), + 2789: uint16(6446), + 2790: uint16(14907), + 2791: uint16(5700), + 2792: uint16(5674), + 2793: uint16(9292), + 2794: uint16(14905), + 2795: uint16(3877), + 2796: uint16(14908), + 2797: uint16(14910), + 2798: uint16(5420), + 2799: uint16(5643), + 2800: uint16(4891), + 2801: uint16(5162), + 2802: uint16(14913), + 2803: uint16(6488), + 2804: uint16(10832), + 2805: uint16(6678), + 2806: uint16(14914), + 2807: uint16(10255), + 2808: uint16(14926), + 2809: uint16(4370), + 2810: uint16(14915), + 2811: uint16(14932), + 2812: uint16(14916), + 2813: uint16(11553), + 2814: uint16(14923), + 2815: uint16(9790), + 2816: uint16(14931), + 2817: uint16(14918), + 2818: uint16(3859), + 2819: uint16(14920), + 2820: uint16(6171), + 2821: uint16(14922), + 2822: uint16(14921), + 2823: uint16(14917), + 2824: uint16(14928), + 2825: uint16(7454), + 2826: uint16(13132), + 2827: uint16(5959), + 2828: uint16(11355), + 2829: uint16(14919), + 2830: uint16(9043), + 2831: uint16(4610), + 2832: uint16(6412), + 2833: uint16(14911), + 2834: uint16(14927), + 2835: uint16(4672), + 2836: uint16(14925), + 2837: uint16(14929), + 2838: uint16(9293), + 2839: uint16(4957), + 2840: uint16(15121), + 2841: uint16(11048), + 2842: uint16(14934), + 2843: uint16(4956), + 2844: uint16(14941), + 2845: uint16(10783), + 2846: uint16(15104), + 2847: uint16(15106), + 2848: uint16(15110), + 2849: uint16(14936), + 2850: uint16(8713), + 2851: uint16(9294), + 2852: uint16(15114), + 2853: uint16(14939), + 2854: uint16(15111), + 2855: uint16(15105), + 2856: uint16(7704), + 2857: uint16(15115), + 2858: uint16(7954), + 2859: uint16(15113), + 2860: uint16(4892), + 2861: uint16(11823), + 2862: uint16(14933), + 2863: uint16(15109), + 2864: uint16(3895), + 2865: uint16(14935), + 2866: uint16(11033), + 2867: uint16(14940), + 2868: uint16(7681), + 2869: uint16(8998), + 2870: uint16(14930), + 2871: uint16(15108), + 2872: uint16(7769), + 2873: uint16(15118), + 2874: uint16(4688), + 2875: uint16(5888), + 2876: uint16(15120), + 2877: uint16(14937), + 2878: uint16(15119), + 2879: uint16(15112), + 2880: uint16(14938), + 2881: uint16(15116), + 2882: uint16(15117), + 2883: uint16(15134), + 2884: uint16(9517), + 2885: uint16(15107), + 2886: uint16(15130), + 2887: uint16(15132), + 2888: uint16(9015), + 2889: uint16(11307), + 2890: uint16(10325), + 2891: uint16(15127), + 2892: uint16(8489), + 2893: uint16(15133), + 2894: uint16(8222), + 2895: uint16(15124), + 2896: uint16(15137), + 2897: uint16(15136), + 2898: uint16(9550), + 2899: uint16(15135), + 2900: uint16(9545), + 2901: uint16(15139), + 2902: uint16(15126), + 2903: uint16(5415), + 2904: uint16(15129), + 2905: uint16(7228), + 2906: uint16(9791), + 2907: uint16(15131), + 2908: uint16(5418), + 2909: uint16(15123), + 2910: uint16(15125), + 2911: uint16(15122), + 2912: uint16(11791), + 2913: uint16(4665), + 2914: uint16(15128), + 2915: uint16(15138), + 2916: uint16(4628), + 2917: uint16(6470), + 2918: uint16(4156), + 2919: uint16(15155), + 2920: uint16(11792), + 2921: uint16(15158), + 2922: uint16(7705), + 2923: uint16(15157), + 2924: uint16(15156), + 2925: uint16(15153), + 2926: uint16(15141), + 2927: uint16(15170), + 2928: uint16(15140), + 2929: uint16(15159), + 2930: uint16(15151), + 2931: uint16(15146), + 2932: uint16(15143), + 2933: uint16(15144), + 2934: uint16(15152), + 2935: uint16(21249), + 2936: uint16(15149), + 2937: uint16(6172), + 2938: uint16(8999), + 2939: uint16(8259), + 2940: uint16(15147), + 2941: uint16(15142), + 2942: uint16(15145), + 2943: uint16(11308), + 2944: uint16(10825), + 2945: uint16(15150), + 2946: uint16(15160), + 2947: uint16(15168), + 2948: uint16(15161), + 2949: uint16(15174), + 2950: uint16(15172), + 2951: uint16(15167), + 2952: uint16(15166), + 2953: uint16(9007), + 2954: uint16(8260), + 2955: uint16(15164), + 2956: uint16(15162), + 2957: uint16(15169), + 2958: uint16(15175), + 2959: uint16(10068), + 2960: uint16(15181), + 2961: uint16(15176), + 2962: uint16(15179), + 2963: uint16(15173), + 2964: uint16(8787), + 2965: uint16(10263), + 2966: uint16(15163), + 2967: uint16(15171), + 2968: uint16(7455), + 2969: uint16(11054), + 2970: uint16(15191), + 2971: uint16(15178), + 2972: uint16(5889), + 2973: uint16(4354), + 2974: uint16(4670), + 2975: uint16(15154), + 2976: uint16(7456), + 2977: uint16(15183), + 2978: uint16(15190), + 2979: uint16(7000), + 2980: uint16(4689), + 2981: uint16(8717), + 2982: uint16(15180), + 2983: uint16(15185), + 2984: uint16(15189), + 2985: uint16(5397), + 2986: uint16(5163), + 2987: uint16(15187), + 2988: uint16(5120), + 2989: uint16(9514), + 2990: uint16(15186), + 2991: uint16(15188), + 2992: uint16(15182), + 2993: uint16(15184), + 2994: uint16(4671), + 2995: uint16(8744), + 2996: uint16(15195), + 2997: uint16(15193), + 2998: uint16(5960), + 2999: uint16(15192), + 3000: uint16(15360), + 3001: uint16(14903), + 3002: uint16(15194), + 3003: uint16(15196), + 3004: uint16(15197), + 3005: uint16(15371), + 3006: uint16(15367), + 3007: uint16(14924), + 3008: uint16(15366), + 3009: uint16(15365), + 3010: uint16(15362), + 3011: uint16(15177), + 3012: uint16(15364), + 3013: uint16(15363), + 3014: uint16(15369), + 3015: uint16(11781), + 3016: uint16(15372), + 3017: uint16(5466), + 3018: uint16(15368), + 3019: uint16(15370), + 3020: uint16(9990), + 3021: uint16(15373), + 3022: uint16(15377), + 3023: uint16(15374), + 3024: uint16(11346), + 3025: uint16(15375), + 3026: uint16(15165), + 3027: uint16(15378), + 3028: uint16(15379), + 3029: uint16(4116), + 3030: uint16(15381), + 3031: uint16(5702), + 3032: uint16(6912), + 3033: uint16(5428), + 3034: uint16(4355), + 3035: uint16(11326), + 3036: uint16(15383), + 3037: uint16(15382), + 3038: uint16(15385), + 3039: uint16(5148), + 3040: uint16(5429), + 3041: uint16(4893), + 3042: uint16(15388), + 3043: uint16(15387), + 3044: uint16(15389), + 3045: uint16(4397), + 3046: uint16(8726), + 3047: uint16(15390), + 3048: uint16(4894), + 3049: uint16(15392), + 3050: uint16(15391), + 3051: uint16(15393), + 3052: uint16(15394), + 3053: uint16(15395), + 3054: uint16(6718), + 3055: uint16(7956), + 3056: uint16(6400), + 3057: uint16(10319), + 3058: uint16(10561), + 3059: uint16(11811), + 3060: uint16(6740), + 3061: uint16(6447), + 3062: uint16(11601), + 3063: uint16(15396), + 3064: uint16(15397), + 3065: uint16(6719), + 3066: uint16(15398), + 3067: uint16(15399), + 3068: uint16(15401), + 3069: uint16(15400), + 3070: uint16(10807), + 3071: uint16(7229), + 3072: uint16(6987), + 3073: uint16(6691), + 3074: uint16(15402), + 3075: uint16(15404), + 3076: uint16(7682), + 3077: uint16(15403), + 3078: uint16(15405), + 3079: uint16(15406), + 3080: uint16(15407), + 3081: uint16(15408), + 3082: uint16(15409), + 3083: uint16(15411), + 3084: uint16(15410), + 3085: uint16(15412), + 3086: uint16(4356), + 3087: uint16(8745), + 3088: uint16(15413), + 3089: uint16(6661), + 3090: uint16(4651), + 3091: uint16(15414), + 3092: uint16(9249), + 3093: uint16(13099), + 3094: uint16(5122), + 3095: uint16(15415), + 3096: uint16(15416), + 3097: uint16(10571), + 3098: uint16(10823), + 3099: uint16(9510), + 3100: uint16(15417), + 3101: uint16(10053), + 3102: uint16(10074), + 3103: uint16(11058), + 3104: uint16(15418), + 3105: uint16(15420), + 3106: uint16(15419), + 3107: uint16(15422), + 3108: uint16(15421), + 3109: uint16(15424), + 3110: uint16(6720), + 3111: uint16(11024), + 3112: uint16(15425), + 3113: uint16(15426), + 3114: uint16(5123), + 3115: uint16(15427), + 3116: uint16(15429), + 3117: uint16(15428), + 3118: uint16(7748), + 3119: uint16(10264), + 3120: uint16(4137), + 3121: uint16(10020), + 3122: uint16(9044), + 3123: uint16(7200), + 3124: uint16(5184), + 3125: uint16(10021), + 3126: uint16(6925), + 3127: uint16(15431), + 3128: uint16(4895), + 3129: uint16(4183), + 3130: uint16(9553), + 3131: uint16(15430), + 3132: uint16(6173), + 3133: uint16(8754), + 3134: uint16(15432), + 3135: uint16(15440), + 3136: uint16(15433), + 3137: uint16(8480), + 3138: uint16(5185), + 3139: uint16(15441), + 3140: uint16(5703), + 3141: uint16(5124), + 3142: uint16(15439), + 3143: uint16(15437), + 3144: uint16(15434), + 3145: uint16(11327), + 3146: uint16(8991), + 3147: uint16(9528), + 3148: uint16(15435), + 3149: uint16(15443), + 3150: uint16(15442), + 3151: uint16(5634), + 3152: uint16(4364), + 3153: uint16(6426), + 3154: uint16(15436), + 3155: uint16(15438), + 3156: uint16(10806), + 3157: uint16(8531), + 3158: uint16(10838), + 3159: uint16(15451), + 3160: uint16(15452), + 3161: uint16(4398), + 3162: uint16(10503), + 3163: uint16(11100), + 3164: uint16(15616), + 3165: uint16(6914), + 3166: uint16(7457), + 3167: uint16(15447), + 3168: uint16(15453), + 3169: uint16(4167), + 3170: uint16(5398), + 3171: uint16(15444), + 3172: uint16(15449), + 3173: uint16(8019), + 3174: uint16(9808), + 3175: uint16(10054), + 3176: uint16(15446), + 3177: uint16(10752), + 3178: uint16(15448), + 3179: uint16(15619), + 3180: uint16(15617), + 3181: uint16(15450), + 3182: uint16(10753), + 3183: uint16(9767), + 3184: uint16(5186), + 3185: uint16(9220), + 3186: uint16(8780), + 3187: uint16(15620), + 3188: uint16(15618), + 3189: uint16(8504), + 3190: uint16(15445), + 3191: uint16(4138), + 3192: uint16(11309), + 3193: uint16(15631), + 3194: uint16(15630), + 3195: uint16(8021), + 3196: uint16(15627), + 3197: uint16(11339), + 3198: uint16(9493), + 3199: uint16(15621), + 3200: uint16(8996), + 3201: uint16(4139), + 3202: uint16(6174), + 3203: uint16(15624), + 3204: uint16(7174), + 3205: uint16(15629), + 3206: uint16(15628), + 3207: uint16(15623), + 3208: uint16(15626), + 3209: uint16(4679), + 3210: uint16(15625), + 3211: uint16(9768), + 3212: uint16(11533), + 3213: uint16(7507), + 3214: uint16(8020), + 3215: uint16(15637), + 3216: uint16(15635), + 3217: uint16(10284), + 3218: uint16(15632), + 3219: uint16(15634), + 3220: uint16(4121), + 3221: uint16(6175), + 3222: uint16(11793), + 3223: uint16(4636), + 3224: uint16(10305), + 3225: uint16(11328), + 3226: uint16(4611), + 3227: uint16(7706), + 3228: uint16(15636), + 3229: uint16(15641), + 3230: uint16(7458), + 3231: uint16(11279), + 3232: uint16(15638), + 3233: uint16(15633), + 3234: uint16(15639), + 3235: uint16(11581), + 3236: uint16(9298), + 3237: uint16(9505), + 3238: uint16(4629), + 3239: uint16(4148), + 3240: uint16(15645), + 3241: uint16(15648), + 3242: uint16(11554), + 3243: uint16(11331), + 3244: uint16(15655), + 3245: uint16(15649), + 3246: uint16(15646), + 3247: uint16(11571), + 3248: uint16(15652), + 3249: uint16(7209), + 3250: uint16(15654), + 3251: uint16(15659), + 3252: uint16(9296), + 3253: uint16(15657), + 3254: uint16(15651), + 3255: uint16(8727), + 3256: uint16(15658), + 3257: uint16(15647), + 3258: uint16(15653), + 3259: uint16(15660), + 3260: uint16(3931), + 3261: uint16(15650), + 3262: uint16(15661), + 3263: uint16(7707), + 3264: uint16(7230), + 3265: uint16(10500), + 3266: uint16(6413), + 3267: uint16(15642), + 3268: uint16(15656), + 3269: uint16(9241), + 3270: uint16(7957), + 3271: uint16(4680), + 3272: uint16(6448), + 3273: uint16(7459), + 3274: uint16(15644), + 3275: uint16(7201), + 3276: uint16(5675), + 3277: uint16(15643), + 3278: uint16(15665), + 3279: uint16(7244), + 3280: uint16(5913), + 3281: uint16(15680), + 3282: uint16(15674), + 3283: uint16(5203), + 3284: uint16(9262), + 3285: uint16(15669), + 3286: uint16(15678), + 3287: uint16(3854), + 3288: uint16(4113), + 3289: uint16(4376), + 3290: uint16(15671), + 3291: uint16(8459), + 3292: uint16(15662), + 3293: uint16(15664), + 3294: uint16(6176), + 3295: uint16(15681), + 3296: uint16(15676), + 3297: uint16(15668), + 3298: uint16(15675), + 3299: uint16(11018), + 3300: uint16(15673), + 3301: uint16(15677), + 3302: uint16(5935), + 3303: uint16(7460), + 3304: uint16(8728), + 3305: uint16(15667), + 3306: uint16(11278), + 3307: uint16(15670), + 3308: uint16(15663), + 3309: uint16(9297), + 3310: uint16(15666), + 3311: uint16(15672), + 3312: uint16(11824), + 3313: uint16(6941), + 3314: uint16(10845), + 3315: uint16(15682), + 3316: uint16(9997), + 3317: uint16(15694), + 3318: uint16(5914), + 3319: uint16(7231), + 3320: uint16(15684), + 3321: uint16(11534), + 3322: uint16(6177), + 3323: uint16(15697), + 3324: uint16(3917), + 3325: uint16(15695), + 3326: uint16(15683), + 3327: uint16(15689), + 3328: uint16(15691), + 3329: uint16(11310), + 3330: uint16(15686), + 3331: uint16(9229), + 3332: uint16(15688), + 3333: uint16(15696), + 3334: uint16(15690), + 3335: uint16(11046), + 3336: uint16(15685), + 3337: uint16(6913), + 3338: uint16(15709), + 3339: uint16(4681), + 3340: uint16(15687), + 3341: uint16(15692), + 3342: uint16(15693), + 3343: uint16(8523), + 3344: uint16(8505), + 3345: uint16(15701), + 3346: uint16(15707), + 3347: uint16(15705), + 3348: uint16(9224), + 3349: uint16(15874), + 3350: uint16(15702), + 3351: uint16(15703), + 3352: uint16(15679), + 3353: uint16(5208), + 3354: uint16(10265), + 3355: uint16(6942), + 3356: uint16(6230), + 3357: uint16(11794), + 3358: uint16(15699), + 3359: uint16(15873), + 3360: uint16(4168), + 3361: uint16(8261), + 3362: uint16(9816), + 3363: uint16(4896), + 3364: uint16(11609), + 3365: uint16(11008), + 3366: uint16(9009), + 3367: uint16(15706), + 3368: uint16(15708), + 3369: uint16(8209), + 3370: uint16(15872), + 3371: uint16(15704), + 3372: uint16(15698), + 3373: uint16(4898), + 3374: uint16(5704), + 3375: uint16(15886), + 3376: uint16(15881), + 3377: uint16(8023), + 3378: uint16(4674), + 3379: uint16(7232), + 3380: uint16(15890), + 3381: uint16(15883), + 3382: uint16(8971), + 3383: uint16(15880), + 3384: uint16(9016), + 3385: uint16(15915), + 3386: uint16(15877), + 3387: uint16(15876), + 3388: uint16(15885), + 3389: uint16(15879), + 3390: uint16(15878), + 3391: uint16(15884), + 3392: uint16(7936), + 3393: uint16(15875), + 3394: uint16(15887), + 3395: uint16(15888), + 3396: uint16(4897), + 3397: uint16(15893), + 3398: uint16(15892), + 3399: uint16(15894), + 3400: uint16(15897), + 3401: uint16(9250), + 3402: uint16(15891), + 3403: uint16(15895), + 3404: uint16(5698), + 3405: uint16(8536), + 3406: uint16(15889), + 3407: uint16(9754), + 3408: uint16(15896), + 3409: uint16(15901), + 3410: uint16(15899), + 3411: uint16(15902), + 3412: uint16(15905), + 3413: uint16(15898), + 3414: uint16(6217), + 3415: uint16(9735), + 3416: uint16(15640), + 3417: uint16(11347), + 3418: uint16(15900), + 3419: uint16(15904), + 3420: uint16(8532), + 3421: uint16(15903), + 3422: uint16(15882), + 3423: uint16(20040), + 3424: uint16(15908), + 3425: uint16(15912), + 3426: uint16(15910), + 3427: uint16(15906), + 3428: uint16(15907), + 3429: uint16(15911), + 3430: uint16(15909), + 3431: uint16(10285), + 3432: uint16(15917), + 3433: uint16(15914), + 3434: uint16(15913), + 3435: uint16(15916), + 3436: uint16(9523), + 3437: uint16(15918), + 3438: uint16(8788), + 3439: uint16(8524), + 3440: uint16(7940), + 3441: uint16(15919), + 3442: uint16(15921), + 3443: uint16(15920), + 3444: uint16(15700), + 3445: uint16(15922), + 3446: uint16(9542), + 3447: uint16(15923), + 3448: uint16(4399), + 3449: uint16(9299), + 3450: uint16(4612), + 3451: uint16(5187), + 3452: uint16(6973), + 3453: uint16(6449), + 3454: uint16(11782), + 3455: uint16(7749), + 3456: uint16(4169), + 3457: uint16(15925), + 3458: uint16(15924), + 3459: uint16(15928), + 3460: uint16(8729), + 3461: uint16(15931), + 3462: uint16(15926), + 3463: uint16(15930), + 3464: uint16(15929), + 3465: uint16(9247), + 3466: uint16(3896), + 3467: uint16(11604), + 3468: uint16(15933), + 3469: uint16(4103), + 3470: uint16(15935), + 3471: uint16(15934), + 3472: uint16(15932), + 3473: uint16(15927), + 3474: uint16(10754), + 3475: uint16(15937), + 3476: uint16(15936), + 3477: uint16(4170), + 3478: uint16(15939), + 3479: uint16(10513), + 3480: uint16(15938), + 3481: uint16(11028), + 3482: uint16(7462), + 3483: uint16(8210), + 3484: uint16(7461), + 3485: uint16(11610), + 3486: uint16(15945), + 3487: uint16(8024), + 3488: uint16(15941), + 3489: uint16(15946), + 3490: uint16(4171), + 3491: uint16(15944), + 3492: uint16(9792), + 3493: uint16(15940), + 3494: uint16(15943), + 3495: uint16(7463), + 3496: uint16(10032), + 3497: uint16(15947), + 3498: uint16(6960), + 3499: uint16(8025), + 3500: uint16(15950), + 3501: uint16(15942), + 3502: uint16(5638), + 3503: uint16(15948), + 3504: uint16(11311), + 3505: uint16(15951), + 3506: uint16(21253), + 3507: uint16(7214), + 3508: uint16(15952), + 3509: uint16(15953), + 3510: uint16(9741), + 3511: uint16(15955), + 3512: uint16(15956), + 3513: uint16(9746), + 3514: uint16(9300), + 3515: uint16(15958), + 3516: uint16(15960), + 3517: uint16(11572), + 3518: uint16(15957), + 3519: uint16(15959), + 3520: uint16(4172), + 3521: uint16(15954), + 3522: uint16(12858), + 3523: uint16(15961), + 3524: uint16(8262), + 3525: uint16(6679), + 3526: uint16(15963), + 3527: uint16(15962), + 3528: uint16(7683), + 3529: uint16(12600), + 3530: uint16(15964), + 3531: uint16(16128), + 3532: uint16(15949), + 3533: uint16(15965), + 3534: uint16(16129), + 3535: uint16(9817), + 3536: uint16(16130), + 3537: uint16(16131), + 3538: uint16(16132), + 3539: uint16(16133), + 3540: uint16(9021), + 3541: uint16(16135), + 3542: uint16(16134), + 3543: uint16(16136), + 3544: uint16(16137), + 3545: uint16(6974), + 3546: uint16(10306), + 3547: uint16(11083), + 3548: uint16(16138), + 3549: uint16(16139), + 3550: uint16(8245), + 3551: uint16(6915), + 3552: uint16(16140), + 3553: uint16(16141), + 3554: uint16(16142), + 3555: uint16(10545), + 3556: uint16(10022), + 3557: uint16(16143), + 3558: uint16(9782), + 3559: uint16(8972), + 3560: uint16(16144), + 3561: uint16(4422), + 3562: uint16(5196), + 3563: uint16(11045), + 3564: uint16(11029), + 3565: uint16(4371), + 3566: uint16(11795), + 3567: uint16(10801), + 3568: uint16(10505), + 3569: uint16(7958), + 3570: uint16(16145), + 3571: uint16(9506), + 3572: uint16(5890), + 3573: uint16(16146), + 3574: uint16(6451), + 3575: uint16(16148), + 3576: uint16(16147), + 3577: uint16(16149), + 3578: uint16(16150), + 3579: uint16(16151), + 3580: uint16(5149), + 3581: uint16(16152), + 3582: uint16(16153), + 3583: uint16(5891), + 3584: uint16(10023), + 3585: uint16(16155), + 3586: uint16(7508), + 3587: uint16(16154), + 3588: uint16(5399), + 3589: uint16(16156), + 3590: uint16(16158), + 3591: uint16(16157), + 3592: uint16(16159), + 3593: uint16(5936), + 3594: uint16(16160), + 3595: uint16(5448), + 3596: uint16(8223), + 3597: uint16(6236), + 3598: uint16(16162), + 3599: uint16(16163), + 3600: uint16(16161), + 3601: uint16(6988), + 3602: uint16(9511), + 3603: uint16(5400), + 3604: uint16(16165), + 3605: uint16(8715), + 3606: uint16(16164), + 3607: uint16(11796), + 3608: uint16(9793), + 3609: uint16(16168), + 3610: uint16(16170), + 3611: uint16(16167), + 3612: uint16(11059), + 3613: uint16(16169), + 3614: uint16(16171), + 3615: uint16(11555), + 3616: uint16(16175), + 3617: uint16(16174), + 3618: uint16(8789), + 3619: uint16(9740), + 3620: uint16(5892), + 3621: uint16(16173), + 3622: uint16(16172), + 3623: uint16(11280), + 3624: uint16(11281), + 3625: uint16(16176), + 3626: uint16(4173), + 3627: uint16(6229), + 3628: uint16(6721), + 3629: uint16(16177), + 3630: uint16(16178), + 3631: uint16(16180), + 3632: uint16(7202), + 3633: uint16(16182), + 3634: uint16(16181), + 3635: uint16(16183), + 3636: uint16(4652), + 3637: uint16(16185), + 3638: uint16(16184), + 3639: uint16(16187), + 3640: uint16(16186), + 3641: uint16(5915), + 3642: uint16(11527), + 3643: uint16(5419), + 3644: uint16(4357), + 3645: uint16(5449), + 3646: uint16(4928), + 3647: uint16(11591), + 3648: uint16(16189), + 3649: uint16(16191), + 3650: uint16(16192), + 3651: uint16(4400), + 3652: uint16(16188), + 3653: uint16(6680), + 3654: uint16(8992), + 3655: uint16(16190), + 3656: uint16(16195), + 3657: uint16(6989), + 3658: uint16(16193), + 3659: uint16(5661), + 3660: uint16(10024), + 3661: uint16(16194), + 3662: uint16(16221), + 3663: uint16(16200), + 3664: uint16(5916), + 3665: uint16(5188), + 3666: uint16(16197), + 3667: uint16(11356), + 3668: uint16(11535), + 3669: uint16(8533), + 3670: uint16(16199), + 3671: uint16(16201), + 3672: uint16(11573), + 3673: uint16(5430), + 3674: uint16(10075), + 3675: uint16(9769), + 3676: uint16(16202), + 3677: uint16(16204), + 3678: uint16(16207), + 3679: uint16(16203), + 3680: uint16(16206), + 3681: uint16(5961), + 3682: uint16(4140), + 3683: uint16(16208), + 3684: uint16(7759), + 3685: uint16(16205), + 3686: uint16(11579), + 3687: uint16(16211), + 3688: uint16(21251), + 3689: uint16(16209), + 3690: uint16(16212), + 3691: uint16(16198), + 3692: uint16(16210), + 3693: uint16(6427), + 3694: uint16(16213), + 3695: uint16(16214), + 3696: uint16(11357), + 3697: uint16(16215), + 3698: uint16(16216), + 3699: uint16(16196), + 3700: uint16(16217), + 3701: uint16(4899), + 3702: uint16(6916), + 3703: uint16(16218), + 3704: uint16(16219), + 3705: uint16(16220), + 3706: uint16(4122), + 3707: uint16(16384), + 3708: uint16(10266), + 3709: uint16(16385), + 3710: uint16(4867), + 3711: uint16(16386), + 3712: uint16(16387), + 3713: uint16(16388), + 3714: uint16(16390), + 3715: uint16(16391), + 3716: uint16(16389), + 3717: uint16(10290), + 3718: uint16(16393), + 3719: uint16(16392), + 3720: uint16(16395), + 3721: uint16(16394), + 3722: uint16(16396), + 3723: uint16(16397), + 3724: uint16(16399), + 3725: uint16(16398), + 3726: uint16(6232), + 3727: uint16(16401), + 3728: uint16(16400), + 3729: uint16(4900), + 3730: uint16(7730), + 3731: uint16(9243), + 3732: uint16(16402), + 3733: uint16(7959), + 3734: uint16(6681), + 3735: uint16(4184), + 3736: uint16(16403), + 3737: uint16(11312), + 3738: uint16(10562), + 3739: uint16(16404), + 3740: uint16(9251), + 3741: uint16(11282), + 3742: uint16(6178), + 3743: uint16(7708), + 3744: uint16(8746), + 3745: uint16(12563), + 3746: uint16(8973), + 3747: uint16(4423), + 3748: uint16(16405), + 3749: uint16(16406), + 3750: uint16(16411), + 3751: uint16(16409), + 3752: uint16(16408), + 3753: uint16(14625), + 3754: uint16(4613), + 3755: uint16(16407), + 3756: uint16(3897), + 3757: uint16(9993), + 3758: uint16(10025), + 3759: uint16(11536), + 3760: uint16(16412), + 3761: uint16(16410), + 3762: uint16(8763), + 3763: uint16(7941), + 3764: uint16(9994), + 3765: uint16(10252), + 3766: uint16(16414), + 3767: uint16(11531), + 3768: uint16(5676), + 3769: uint16(16415), + 3770: uint16(16413), + 3771: uint16(10037), + 3772: uint16(16416), + 3773: uint16(16417), + 3774: uint16(3898), + 3775: uint16(7509), + 3776: uint16(16422), + 3777: uint16(16419), + 3778: uint16(9548), + 3779: uint16(16418), + 3780: uint16(5125), + 3781: uint16(16425), + 3782: uint16(16420), + 3783: uint16(16421), + 3784: uint16(16424), + 3785: uint16(16423), + 3786: uint16(10244), + 3787: uint16(8225), + 3788: uint16(8224), + 3789: uint16(5150), + 3790: uint16(16426), + 3791: uint16(16427), + 3792: uint16(16428), + 3793: uint16(16430), + 3794: uint16(16429), + 3795: uint16(4149), + 3796: uint16(16438), + 3797: uint16(10055), + 3798: uint16(16432), + 3799: uint16(16434), + 3800: uint16(16436), + 3801: uint16(7709), + 3802: uint16(16437), + 3803: uint16(16435), + 3804: uint16(6943), + 3805: uint16(16431), + 3806: uint16(16433), + 3807: uint16(10273), + 3808: uint16(7464), + 3809: uint16(16440), + 3810: uint16(16439), + 3811: uint16(16441), + 3812: uint16(6917), + 3813: uint16(6414), + 3814: uint16(9302), + 3815: uint16(16442), + 3816: uint16(9002), + 3817: uint16(16444), + 3818: uint16(11520), + 3819: uint16(16443), + 3820: uint16(8264), + 3821: uint16(16449), + 3822: uint16(16451), + 3823: uint16(16452), + 3824: uint16(8755), + 3825: uint16(16450), + 3826: uint16(16447), + 3827: uint16(16445), + 3828: uint16(16446), + 3829: uint16(16448), + 3830: uint16(16455), + 3831: uint16(16453), + 3832: uint16(16454), + 3833: uint16(16456), + 3834: uint16(16458), + 3835: uint16(16459), + 3836: uint16(16460), + 3837: uint16(16461), + 3838: uint16(16457), + 3839: uint16(16463), + 3840: uint16(16462), + 3841: uint16(16464), + 3842: uint16(11556), + 3843: uint16(16467), + 3844: uint16(16465), + 3845: uint16(16466), + 3846: uint16(4929), + 3847: uint16(11101), + 3848: uint16(10537), + 3849: uint16(16469), + 3850: uint16(16468), + 3851: uint16(16470), + 3852: uint16(16471), + 3853: uint16(16475), + 3854: uint16(16472), + 3855: uint16(16473), + 3856: uint16(16474), + 3857: uint16(16476), + 3858: uint16(16477), + 3859: uint16(16640), + 3860: uint16(16641), + 3861: uint16(16642), + 3862: uint16(9998), + 3863: uint16(9263), + 3864: uint16(16643), + 3865: uint16(9809), + 3866: uint16(10259), + 3867: uint16(16644), + 3868: uint16(16645), + 3869: uint16(9225), + 3870: uint16(4614), + 3871: uint16(6179), + 3872: uint16(16646), + 3873: uint16(16647), + 3874: uint16(16648), + 3875: uint16(6664), + 3876: uint16(16650), + 3877: uint16(16649), + 3878: uint16(16651), + 3879: uint16(16652), + 3880: uint16(10056), + 3881: uint16(16653), + 3882: uint16(16654), + 3883: uint16(21064), + 3884: uint16(16655), + 3885: uint16(16656), + 3886: uint16(16657), + 3887: uint16(6669), + 3888: uint16(16658), + 3889: uint16(9781), + 3890: uint16(10814), + 3891: uint16(4141), + 3892: uint16(4150), + 3893: uint16(16659), + 3894: uint16(16661), + 3895: uint16(16660), + 3896: uint16(9295), + 3897: uint16(7960), + 3898: uint16(15384), + 3899: uint16(16662), + 3900: uint16(11040), + 3901: uint16(16663), + 3902: uint16(4901), + 3903: uint16(10038), + 3904: uint16(16664), + 3905: uint16(16665), + 3906: uint16(16666), + 3907: uint16(11067), + 3908: uint16(11060), + 3909: uint16(8989), + 3910: uint16(8265), + 3911: uint16(16668), + 3912: uint16(7233), + 3913: uint16(7465), + 3914: uint16(16671), + 3915: uint16(16670), + 3916: uint16(16669), + 3917: uint16(10076), + 3918: uint16(4902), + 3919: uint16(5896), + 3920: uint16(16677), + 3921: uint16(16674), + 3922: uint16(7710), + 3923: uint16(11025), + 3924: uint16(16673), + 3925: uint16(16675), + 3926: uint16(16676), + 3927: uint16(16672), + 3928: uint16(16678), + 3929: uint16(16679), + 3930: uint16(8974), + 3931: uint16(4930), + 3932: uint16(8772), + 3933: uint16(16680), + 3934: uint16(16681), + 3935: uint16(16684), + 3936: uint16(7750), + 3937: uint16(9507), + 3938: uint16(16685), + 3939: uint16(10802), + 3940: uint16(16682), + 3941: uint16(16683), + 3942: uint16(16688), + 3943: uint16(16687), + 3944: uint16(16686), + 3945: uint16(16690), + 3946: uint16(16689), + 3947: uint16(16691), + 3948: uint16(16693), + 3949: uint16(16692), + 3950: uint16(10540), + 3951: uint16(7221), + 3952: uint16(11557), + 3953: uint16(16694), + 3954: uint16(9494), + 3955: uint16(16695), + 3956: uint16(16696), + 3957: uint16(16700), + 3958: uint16(16698), + 3959: uint16(16699), + 3960: uint16(16697), + 3961: uint16(16701), + 3962: uint16(16702), + 3963: uint16(16703), + 3964: uint16(16704), + 3965: uint16(11030), + 3966: uint16(16705), + 3967: uint16(11087), + 3968: uint16(16706), + 3969: uint16(8749), + 3970: uint16(9801), + 3971: uint16(5450), + 3972: uint16(8730), + 3973: uint16(16707), + 3974: uint16(5401), + 3975: uint16(7983), + 3976: uint16(16708), + 3977: uint16(6428), + 3978: uint16(16709), + 3979: uint16(16710), + 3980: uint16(5893), + 3981: uint16(6452), + 3982: uint16(16712), + 3983: uint16(9269), + 3984: uint16(6453), + 3985: uint16(5165), + 3986: uint16(10755), + 3987: uint16(9770), + 3988: uint16(9270), + 3989: uint16(6203), + 3990: uint16(16714), + 3991: uint16(7466), + 3992: uint16(11537), + 3993: uint16(6180), + 3994: uint16(5894), + 3995: uint16(9986), + 3996: uint16(16716), + 3997: uint16(16718), + 3998: uint16(5962), + 3999: uint16(16717), + 4000: uint16(9045), + 4001: uint16(16720), + 4002: uint16(4630), + 4003: uint16(16715), + 4004: uint16(10057), + 4005: uint16(4111), + 4006: uint16(6475), + 4007: uint16(11825), + 4008: uint16(16719), + 4009: uint16(16721), + 4010: uint16(10538), + 4011: uint16(7992), + 4012: uint16(16723), + 4013: uint16(16724), + 4014: uint16(16722), + 4015: uint16(4653), + 4016: uint16(16730), + 4017: uint16(16729), + 4018: uint16(6918), + 4019: uint16(16731), + 4020: uint16(16726), + 4021: uint16(16732), + 4022: uint16(16727), + 4023: uint16(10039), + 4024: uint16(16725), + 4025: uint16(16728), + 4026: uint16(16897), + 4027: uint16(16896), + 4028: uint16(10816), + 4029: uint16(16733), + 4030: uint16(3914), + 4031: uint16(16899), + 4032: uint16(16898), + 4033: uint16(7467), + 4034: uint16(16900), + 4035: uint16(8226), + 4036: uint16(16902), + 4037: uint16(16901), + 4038: uint16(16903), + 4039: uint16(16711), + 4040: uint16(16713), + 4041: uint16(16905), + 4042: uint16(16904), + 4043: uint16(6919), + 4044: uint16(11592), + 4045: uint16(6961), + 4046: uint16(16906), + 4047: uint16(5654), + 4048: uint16(5151), + 4049: uint16(5126), + 4050: uint16(6722), + 4051: uint16(11283), + 4052: uint16(16912), + 4053: uint16(16911), + 4054: uint16(8227), + 4055: uint16(16908), + 4056: uint16(16910), + 4057: uint16(7210), + 4058: uint16(7711), + 4059: uint16(16909), + 4060: uint16(16907), + 4061: uint16(9737), + 4062: uint16(7468), + 4063: uint16(10267), + 4064: uint16(6454), + 4065: uint16(9303), + 4066: uint16(16913), + 4067: uint16(16914), + 4068: uint16(16936), + 4069: uint16(5431), + 4070: uint16(11804), + 4071: uint16(8212), + 4072: uint16(16915), + 4073: uint16(4401), + 4074: uint16(9046), + 4075: uint16(10496), + 4076: uint16(16916), + 4077: uint16(5209), + 4078: uint16(16917), + 4079: uint16(16919), + 4080: uint16(16920), + 4081: uint16(9736), + 4082: uint16(16921), + 4083: uint16(16922), + 4084: uint16(16923), + 4085: uint16(5432), + 4086: uint16(4402), + 4087: uint16(9508), + 4088: uint16(7175), + 4089: uint16(6723), + 4090: uint16(16924), + 4091: uint16(7176), + 4092: uint16(4393), + 4093: uint16(10274), + 4094: uint16(16925), + 4095: uint16(10058), + 4096: uint16(8228), + 4097: uint16(16928), + 4098: uint16(16929), + 4099: uint16(9800), + 4100: uint16(7712), + 4101: uint16(16926), + 4102: uint16(8768), + 4103: uint16(16927), + 4104: uint16(7469), + 4105: uint16(3899), + 4106: uint16(5128), + 4107: uint16(16930), + 4108: uint16(9047), + 4109: uint16(16931), + 4110: uint16(7974), + 4111: uint16(11020), + 4112: uint16(10242), + 4113: uint16(16932), + 4114: uint16(16933), + 4115: uint16(8756), + 4116: uint16(11558), + 4117: uint16(16935), + 4118: uint16(16934), + 4119: uint16(6990), + 4120: uint16(16937), + 4121: uint16(3919), + 4122: uint16(16940), + 4123: uint16(16938), + 4124: uint16(4403), + 4125: uint16(5677), + 4126: uint16(16939), + 4127: uint16(6181), + 4128: uint16(6225), + 4129: uint16(10565), + 4130: uint16(16941), + 4131: uint16(10803), + 4132: uint16(16943), + 4133: uint16(7984), + 4134: uint16(4142), + 4135: uint16(4377), + 4136: uint16(3851), + 4137: uint16(16942), + 4138: uint16(16944), + 4139: uint16(16945), + 4140: uint16(7510), + 4141: uint16(16946), + 4142: uint16(4654), + 4143: uint16(16948), + 4144: uint16(5705), + 4145: uint16(5189), + 4146: uint16(16949), + 4147: uint16(5460), + 4148: uint16(16950), + 4149: uint16(8027), + 4150: uint16(9516), + 4151: uint16(7999), + 4152: uint16(6484), + 4153: uint16(16951), + 4154: uint16(8769), + 4155: uint16(8266), + 4156: uint16(16953), + 4157: uint16(16955), + 4158: uint16(16952), + 4159: uint16(16954), + 4160: uint16(5633), + 4161: uint16(16956), + 4162: uint16(5637), + 4163: uint16(5190), + 4164: uint16(11313), + 4165: uint16(16958), + 4166: uint16(16959), + 4167: uint16(4109), + 4168: uint16(16962), + 4169: uint16(4693), + 4170: uint16(16961), + 4171: uint16(16960), + 4172: uint16(16964), + 4173: uint16(16957), + 4174: uint16(16965), + 4175: uint16(11528), + 4176: uint16(16966), + 4177: uint16(16967), + 4178: uint16(13139), + 4179: uint16(16969), + 4180: uint16(16968), + 4181: uint16(16970), + 4182: uint16(16971), + 4183: uint16(11540), + 4184: uint16(16972), + 4185: uint16(20302), + 4186: uint16(7470), + 4187: uint16(16973), + 4188: uint16(16974), + 4189: uint16(7222), + 4190: uint16(9495), + 4191: uint16(16975), + 4192: uint16(8711), + 4193: uint16(16976), + 4194: uint16(8731), + 4195: uint16(16977), + 4196: uint16(5380), + 4197: uint16(12318), + 4198: uint16(8764), + 4199: uint16(6930), + 4200: uint16(4903), + 4201: uint16(16978), + 4202: uint16(17153), + 4203: uint16(16981), + 4204: uint16(5191), + 4205: uint16(16980), + 4206: uint16(17155), + 4207: uint16(16979), + 4208: uint16(7471), + 4209: uint16(16983), + 4210: uint16(16984), + 4211: uint16(9226), + 4212: uint16(16985), + 4213: uint16(4669), + 4214: uint16(7737), + 4215: uint16(10307), + 4216: uint16(16987), + 4217: uint16(8519), + 4218: uint16(16982), + 4219: uint16(16986), + 4220: uint16(16988), + 4221: uint16(6490), + 4222: uint16(17157), + 4223: uint16(10253), + 4224: uint16(9989), + 4225: uint16(9304), + 4226: uint16(5433), + 4227: uint16(17156), + 4228: uint16(17154), + 4229: uint16(10004), + 4230: uint16(16989), + 4231: uint16(8765), + 4232: uint16(9306), + 4233: uint16(9305), + 4234: uint16(6485), + 4235: uint16(17175), + 4236: uint16(17159), + 4237: uint16(17161), + 4238: uint16(17164), + 4239: uint16(17165), + 4240: uint16(17162), + 4241: uint16(17163), + 4242: uint16(17160), + 4243: uint16(17158), + 4244: uint16(17152), + 4245: uint16(10542), + 4246: uint16(4404), + 4247: uint16(17172), + 4248: uint16(17169), + 4249: uint16(17174), + 4250: uint16(17173), + 4251: uint16(9810), + 4252: uint16(11014), + 4253: uint16(6682), + 4254: uint16(17167), + 4255: uint16(17176), + 4256: uint16(17171), + 4257: uint16(17170), + 4258: uint16(17166), + 4259: uint16(17168), + 4260: uint16(4904), + 4261: uint16(8732), + 4262: uint16(8028), + 4263: uint16(9985), + 4264: uint16(17181), + 4265: uint16(9987), + 4266: uint16(8000), + 4267: uint16(17178), + 4268: uint16(10030), + 4269: uint16(17182), + 4270: uint16(10546), + 4271: uint16(8762), + 4272: uint16(17177), + 4273: uint16(17179), + 4274: uint16(17180), + 4275: uint16(17183), + 4276: uint16(6947), + 4277: uint16(9509), + 4278: uint16(17188), + 4279: uint16(17187), + 4280: uint16(17184), + 4281: uint16(11797), + 4282: uint16(17193), + 4283: uint16(17197), + 4284: uint16(17194), + 4285: uint16(17190), + 4286: uint16(17191), + 4287: uint16(17196), + 4288: uint16(17185), + 4289: uint16(12596), + 4290: uint16(17192), + 4291: uint16(17186), + 4292: uint16(17195), + 4293: uint16(17201), + 4294: uint16(4905), + 4295: uint16(17198), + 4296: uint16(17199), + 4297: uint16(17200), + 4298: uint16(17203), + 4299: uint16(17202), + 4300: uint16(10069), + 4301: uint16(17204), + 4302: uint16(11611), + 4303: uint16(10572), + 4304: uint16(17209), + 4305: uint16(17206), + 4306: uint16(17205), + 4307: uint16(7985), + 4308: uint16(17208), + 4309: uint16(17210), + 4310: uint16(17207), + 4311: uint16(17214), + 4312: uint16(17211), + 4313: uint16(17212), + 4314: uint16(17189), + 4315: uint16(17213), + 4316: uint16(17215), + 4317: uint16(17216), + 4318: uint16(10533), + 4319: uint16(17217), + 4320: uint16(11073), + 4321: uint16(5421), + 4322: uint16(5640), + 4323: uint16(17218), + 4324: uint16(10515), + 4325: uint16(7751), + 4326: uint16(11023), + 4327: uint16(17219), + 4328: uint16(11538), + 4329: uint16(9811), + 4330: uint16(8229), + 4331: uint16(9747), + 4332: uint16(7212), + 4333: uint16(3871), + 4334: uint16(17224), + 4335: uint16(17222), + 4336: uint16(17220), + 4337: uint16(4864), + 4338: uint16(7472), + 4339: uint16(17225), + 4340: uint16(17223), + 4341: uint16(17221), + 4342: uint16(17229), + 4343: uint16(17228), + 4344: uint16(17227), + 4345: uint16(17226), + 4346: uint16(17230), + 4347: uint16(17231), + 4348: uint16(7961), + 4349: uint16(17232), + 4350: uint16(17234), + 4351: uint16(17233), + 4352: uint16(5937), + 4353: uint16(8215), + 4354: uint16(17236), + 4355: uint16(9307), + 4356: uint16(17235), + 4357: uint16(17237), + 4358: uint16(10516), + 4359: uint16(8267), + 4360: uint16(6182), + 4361: uint16(17238), + 4362: uint16(11559), + 4363: uint16(17240), + 4364: uint16(17241), + 4365: uint16(17242), + 4366: uint16(17243), + 4367: uint16(6724), + 4368: uint16(17244), + 4369: uint16(5678), + 4370: uint16(5193), + 4371: uint16(5129), + 4372: uint16(17408), + 4373: uint16(11090), + 4374: uint16(6183), + 4375: uint16(17245), + 4376: uint16(17411), + 4377: uint16(11077), + 4378: uint16(9755), + 4379: uint16(10258), + 4380: uint16(7234), + 4381: uint16(17410), + 4382: uint16(6962), + 4383: uint16(6184), + 4384: uint16(6725), + 4385: uint16(5192), + 4386: uint16(10517), + 4387: uint16(17409), + 4388: uint16(8230), + 4389: uint16(10785), + 4390: uint16(6486), + 4391: uint16(6726), + 4392: uint16(9020), + 4393: uint16(17414), + 4394: uint16(11582), + 4395: uint16(6456), + 4396: uint16(17415), + 4397: uint16(7713), + 4398: uint16(17417), + 4399: uint16(7473), + 4400: uint16(6415), + 4401: uint16(17416), + 4402: uint16(7177), + 4403: uint16(5917), + 4404: uint16(8231), + 4405: uint16(17412), + 4406: uint16(17418), + 4407: uint16(17413), + 4408: uint16(5679), + 4409: uint16(17421), + 4410: uint16(17425), + 4411: uint16(5706), + 4412: uint16(17420), + 4413: uint16(17429), + 4414: uint16(6185), + 4415: uint16(11340), + 4416: uint16(3867), + 4417: uint16(17426), + 4418: uint16(5194), + 4419: uint16(17423), + 4420: uint16(17424), + 4421: uint16(9308), + 4422: uint16(17422), + 4423: uint16(17419), + 4424: uint16(4615), + 4425: uint16(8003), + 4426: uint16(5895), + 4427: uint16(17431), + 4428: uint16(17428), + 4429: uint16(17430), + 4430: uint16(17427), + 4431: uint16(5680), + 4432: uint16(8466), + 4433: uint16(17432), + 4434: uint16(8269), + 4435: uint16(17445), + 4436: uint16(17441), + 4437: uint16(17435), + 4438: uint16(17439), + 4439: uint16(7001), + 4440: uint16(3900), + 4441: uint16(17434), + 4442: uint16(17442), + 4443: uint16(17446), + 4444: uint16(6186), + 4445: uint16(11061), + 4446: uint16(9013), + 4447: uint16(17436), + 4448: uint16(17444), + 4449: uint16(17433), + 4450: uint16(8733), + 4451: uint16(17438), + 4452: uint16(3868), + 4453: uint16(11049), + 4454: uint16(17437), + 4455: uint16(5434), + 4456: uint16(10059), + 4457: uint16(8268), + 4458: uint16(11567), + 4459: uint16(7246), + 4460: uint16(17485), + 4461: uint16(17447), + 4462: uint16(8029), + 4463: uint16(17443), + 4464: uint16(17448), + 4465: uint16(17450), + 4466: uint16(9048), + 4467: uint16(17453), + 4468: uint16(17449), + 4469: uint16(10547), + 4470: uint16(4906), + 4471: uint16(11050), + 4472: uint16(3901), + 4473: uint16(17452), + 4474: uint16(11612), + 4475: uint16(17451), + 4476: uint16(4174), + 4477: uint16(9547), + 4478: uint16(17454), + 4479: uint16(17461), + 4480: uint16(17455), + 4481: uint16(17462), + 4482: uint16(17458), + 4483: uint16(9818), + 4484: uint16(6953), + 4485: uint16(17460), + 4486: uint16(17457), + 4487: uint16(17463), + 4488: uint16(17456), + 4489: uint16(7203), + 4490: uint16(10756), + 4491: uint16(7211), + 4492: uint16(17459), + 4493: uint16(17471), + 4494: uint16(17467), + 4495: uint16(17470), + 4496: uint16(17468), + 4497: uint16(17472), + 4498: uint16(17466), + 4499: uint16(17440), + 4500: uint16(7986), + 4501: uint16(10026), + 4502: uint16(17469), + 4503: uint16(17464), + 4504: uint16(8192), + 4505: uint16(5681), + 4506: uint16(7178), + 4507: uint16(7684), + 4508: uint16(8213), + 4509: uint16(17475), + 4510: uint16(17477), + 4511: uint16(17478), + 4512: uint16(17474), + 4513: uint16(17476), + 4514: uint16(17465), + 4515: uint16(17473), + 4516: uint16(17481), + 4517: uint16(17480), + 4518: uint16(10841), + 4519: uint16(5642), + 4520: uint16(17479), + 4521: uint16(17483), + 4522: uint16(17482), + 4523: uint16(17486), + 4524: uint16(17488), + 4525: uint16(6683), + 4526: uint16(17484), + 4527: uint16(17489), + 4528: uint16(17490), + 4529: uint16(17491), + 4530: uint16(17497), + 4531: uint16(9242), + 4532: uint16(17493), + 4533: uint16(17492), + 4534: uint16(17494), + 4535: uint16(17495), + 4536: uint16(17496), + 4537: uint16(17498), + 4538: uint16(17499), + 4539: uint16(4907), + 4540: uint16(17500), + 4541: uint16(17501), + 4542: uint16(17664), + 4543: uint16(17665), + 4544: uint16(17666), + 4545: uint16(17667), + 4546: uint16(17668), + 4547: uint16(17669), + 4548: uint16(17671), + 4549: uint16(17670), + 4550: uint16(17672), + 4551: uint16(17673), + 4552: uint16(17674), + 4553: uint16(17677), + 4554: uint16(17675), + 4555: uint16(17676), + 4556: uint16(6464), + 4557: uint16(5682), + 4558: uint16(8757), + 4559: uint16(10002), + 4560: uint16(7247), + 4561: uint16(9772), + 4562: uint16(10060), + 4563: uint16(17678), + 4564: uint16(14156), + 4565: uint16(17679), + 4566: uint16(17681), + 4567: uint16(11332), + 4568: uint16(17680), + 4569: uint16(17683), + 4570: uint16(17682), + 4571: uint16(11314), + 4572: uint16(17684), + 4573: uint16(10077), + 4574: uint16(17685), + 4575: uint16(17688), + 4576: uint16(17687), + 4577: uint16(17686), + 4578: uint16(17689), + 4579: uint16(5649), + 4580: uint16(8193), + 4581: uint16(5152), + 4582: uint16(17693), + 4583: uint16(17690), + 4584: uint16(17691), + 4585: uint16(17694), + 4586: uint16(17695), + 4587: uint16(17692), + 4588: uint16(4104), + 4589: uint16(4358), + 4590: uint16(17697), + 4591: uint16(17698), + 4592: uint16(17699), + 4593: uint16(11329), + 4594: uint16(7179), + 4595: uint16(17701), + 4596: uint16(17700), + 4597: uint16(7752), + 4598: uint16(17702), + 4599: uint16(17703), + 4600: uint16(17704), + 4601: uint16(4932), + 4602: uint16(4908), + 4603: uint16(17705), + 4604: uint16(17706), + 4605: uint16(10812), + 4606: uint16(11330), + 4607: uint16(11315), + 4608: uint16(11798), + 4609: uint16(6188), + 4610: uint16(17709), + 4611: uint16(6963), + 4612: uint16(17708), + 4613: uint16(17710), + 4614: uint16(6920), + 4615: uint16(8496), + 4616: uint16(17711), + 4617: uint16(6187), + 4618: uint16(11062), + 4619: uint16(17712), + 4620: uint16(17713), + 4621: uint16(17714), + 4622: uint16(17715), + 4623: uint16(17716), + 4624: uint16(6921), + 4625: uint16(11084), + 4626: uint16(17718), + 4627: uint16(8734), + 4628: uint16(17717), + 4629: uint16(17720), + 4630: uint16(17719), + 4631: uint16(17721), + 4632: uint16(7962), + 4633: uint16(17722), + 4634: uint16(17723), + 4635: uint16(10520), + 4636: uint16(17724), + 4637: uint16(8270), + 4638: uint16(17725), + 4639: uint16(17726), + 4640: uint16(11613), + 4641: uint16(17729), + 4642: uint16(17728), + 4643: uint16(17727), + 4644: uint16(8975), + 4645: uint16(17730), + 4646: uint16(7685), + 4647: uint16(17731), + 4648: uint16(17732), + 4649: uint16(11799), + 4650: uint16(17733), + 4651: uint16(17734), + 4652: uint16(17736), + 4653: uint16(17735), + 4654: uint16(9988), + 4655: uint16(9560), + 4656: uint16(11805), + 4657: uint16(9992), + 4658: uint16(17738), + 4659: uint16(7474), + 4660: uint16(10249), + 4661: uint16(17739), + 4662: uint16(17737), + 4663: uint16(4909), + 4664: uint16(5939), + 4665: uint16(6727), + 4666: uint16(10061), + 4667: uint16(5897), + 4668: uint16(10786), + 4669: uint16(17742), + 4670: uint16(17740), + 4671: uint16(6189), + 4672: uint16(6190), + 4673: uint16(3912), + 4674: uint16(6471), + 4675: uint16(9784), + 4676: uint16(3902), + 4677: uint16(17747), + 4678: uint16(8735), + 4679: uint16(9783), + 4680: uint16(8506), + 4681: uint16(17749), + 4682: uint16(17745), + 4683: uint16(17748), + 4684: uint16(17743), + 4685: uint16(17746), + 4686: uint16(10757), + 4687: uint16(5940), + 4688: uint16(3932), + 4689: uint16(17744), + 4690: uint16(17751), + 4691: uint16(17752), + 4692: uint16(9496), + 4693: uint16(5402), + 4694: uint16(17925), + 4695: uint16(9756), + 4696: uint16(6728), + 4697: uint16(5403), + 4698: uint16(7975), + 4699: uint16(11813), + 4700: uint16(11021), + 4701: uint16(17750), + 4702: uint16(7987), + 4703: uint16(5170), + 4704: uint16(17753), + 4705: uint16(17755), + 4706: uint16(17754), + 4707: uint16(17756), + 4708: uint16(8709), + 4709: uint16(9757), + 4710: uint16(8976), + 4711: uint16(17922), + 4712: uint16(17921), + 4713: uint16(17757), + 4714: uint16(7732), + 4715: uint16(10308), + 4716: uint16(17924), + 4717: uint16(17923), + 4718: uint16(6191), + 4719: uint16(11826), + 4720: uint16(17940), + 4721: uint16(17928), + 4722: uint16(17929), + 4723: uint16(6991), + 4724: uint16(17927), + 4725: uint16(6231), + 4726: uint16(17926), + 4727: uint16(17930), + 4728: uint16(8977), + 4729: uint16(10497), + 4730: uint16(8194), + 4731: uint16(8507), + 4732: uint16(17934), + 4733: uint16(17935), + 4734: uint16(17931), + 4735: uint16(17932), + 4736: uint16(17933), + 4737: uint16(6192), + 4738: uint16(17941), + 4739: uint16(17937), + 4740: uint16(10309), + 4741: uint16(10827), + 4742: uint16(10247), + 4743: uint16(17936), + 4744: uint16(17939), + 4745: uint16(17938), + 4746: uint16(10787), + 4747: uint16(17942), + 4748: uint16(17943), + 4749: uint16(8214), + 4750: uint16(17944), + 4751: uint16(17946), + 4752: uint16(17950), + 4753: uint16(17947), + 4754: uint16(17945), + 4755: uint16(9758), + 4756: uint16(17948), + 4757: uint16(17949), + 4758: uint16(4369), + 4759: uint16(17956), + 4760: uint16(17951), + 4761: uint16(17952), + 4762: uint16(17953), + 4763: uint16(8448), + 4764: uint16(17955), + 4765: uint16(17954), + 4766: uint16(17957), + 4767: uint16(17958), + 4768: uint16(17959), + 4769: uint16(7714), + 4770: uint16(4424), + 4771: uint16(17960), + 4772: uint16(11574), + 4773: uint16(6922), + 4774: uint16(7180), + 4775: uint16(6729), + 4776: uint16(8758), + 4777: uint16(17961), + 4778: uint16(17962), + 4779: uint16(4112), + 4780: uint16(17963), + 4781: uint16(17964), + 4782: uint16(17965), + 4783: uint16(17966), + 4784: uint16(17967), + 4785: uint16(5404), + 4786: uint16(14601), + 4787: uint16(17968), + 4788: uint16(8004), + 4789: uint16(17969), + 4790: uint16(6954), + 4791: uint16(17970), + 4792: uint16(12047), + 4793: uint16(17971), + 4794: uint16(10557), + 4795: uint16(4923), + 4796: uint16(8195), + 4797: uint16(7223), + 4798: uint16(10320), + 4799: uint16(7181), + 4800: uint16(17972), + 4801: uint16(6193), + 4802: uint16(17973), + 4803: uint16(10027), + 4804: uint16(17987), + 4805: uint16(17975), + 4806: uint16(8488), + 4807: uint16(9812), + 4808: uint16(5918), + 4809: uint16(17974), + 4810: uint16(8196), + 4811: uint16(17976), + 4812: uint16(9049), + 4813: uint16(17978), + 4814: uint16(17977), + 4815: uint16(17980), + 4816: uint16(17979), + 4817: uint16(17981), + 4818: uint16(17983), + 4819: uint16(17982), + 4820: uint16(4910), + 4821: uint16(17984), + 4822: uint16(17985), + 4823: uint16(17986), + 4824: uint16(6416), + 4825: uint16(11560), + 4826: uint16(17988), + 4827: uint16(7686), + 4828: uint16(4175), + 4829: uint16(17989), + 4830: uint16(17990), + 4831: uint16(17991), + 4832: uint16(3921), + 4833: uint16(17992), + 4834: uint16(17993), + 4835: uint16(10310), + 4836: uint16(6950), + 4837: uint16(17995), + 4838: uint16(4616), + 4839: uint16(3857), + 4840: uint16(17994), + 4841: uint16(17997), + 4842: uint16(9773), + 4843: uint16(7715), + 4844: uint16(4405), + 4845: uint16(10758), + 4846: uint16(5692), + 4847: uint16(5435), + 4848: uint16(17996), + 4849: uint16(4425), + 4850: uint16(4866), + 4851: uint16(4176), + 4852: uint16(18001), + 4853: uint16(11593), + 4854: uint16(8508), + 4855: uint16(10275), + 4856: uint16(18013), + 4857: uint16(4406), + 4858: uint16(18011), + 4859: uint16(18009), + 4860: uint16(18000), + 4861: uint16(17998), + 4862: uint16(17999), + 4863: uint16(6978), + 4864: uint16(5451), + 4865: uint16(8790), + 4866: uint16(9520), + 4867: uint16(4144), + 4868: uint16(18003), + 4869: uint16(18002), + 4870: uint16(18008), + 4871: uint16(18004), + 4872: uint16(18007), + 4873: uint16(11055), + 4874: uint16(18006), + 4875: uint16(4407), + 4876: uint16(4700), + 4877: uint16(18010), + 4878: uint16(18012), + 4879: uint16(5683), + 4880: uint16(18178), + 4881: uint16(18187), + 4882: uint16(18188), + 4883: uint16(3850), + 4884: uint16(18195), + 4885: uint16(3920), + 4886: uint16(18186), + 4887: uint16(18185), + 4888: uint16(18180), + 4889: uint16(18179), + 4890: uint16(18177), + 4891: uint16(18176), + 4892: uint16(8770), + 4893: uint16(8538), + 4894: uint16(18182), + 4895: uint16(18181), + 4896: uint16(18184), + 4897: uint16(8271), + 4898: uint16(5684), + 4899: uint16(4128), + 4900: uint16(18183), + 4901: uint16(6194), + 4902: uint16(8272), + 4903: uint16(18201), + 4904: uint16(18202), + 4905: uint16(4408), + 4906: uint16(4365), + 4907: uint16(18199), + 4908: uint16(18189), + 4909: uint16(18197), + 4910: uint16(18204), + 4911: uint16(18198), + 4912: uint16(18196), + 4913: uint16(18005), + 4914: uint16(18194), + 4915: uint16(18190), + 4916: uint16(4911), + 4917: uint16(18192), + 4918: uint16(18203), + 4919: uint16(18193), + 4920: uint16(18205), + 4921: uint16(18191), + 4922: uint16(9819), + 4923: uint16(11336), + 4924: uint16(18200), + 4925: uint16(18222), + 4926: uint16(18214), + 4927: uint16(7770), + 4928: uint16(5157), + 4929: uint16(5436), + 4930: uint16(18209), + 4931: uint16(4410), + 4932: uint16(7475), + 4933: uint16(18212), + 4934: uint16(6457), + 4935: uint16(9264), + 4936: uint16(18217), + 4937: uint16(10573), + 4938: uint16(18208), + 4939: uint16(4409), + 4940: uint16(5941), + 4941: uint16(10248), + 4942: uint16(18218), + 4943: uint16(18206), + 4944: uint16(18215), + 4945: uint16(18225), + 4946: uint16(18210), + 4947: uint16(18211), + 4948: uint16(9497), + 4949: uint16(18216), + 4950: uint16(18213), + 4951: uint16(10759), + 4952: uint16(18219), + 4953: uint16(3903), + 4954: uint16(18207), + 4955: uint16(18221), + 4956: uint16(18220), + 4957: uint16(9802), + 4958: uint16(18227), + 4959: uint16(18238), + 4960: uint16(4701), + 4961: uint16(18241), + 4962: uint16(18223), + 4963: uint16(18228), + 4964: uint16(11341), + 4965: uint16(18237), + 4966: uint16(11316), + 4967: uint16(11529), + 4968: uint16(8791), + 4969: uint16(4682), + 4970: uint16(10321), + 4971: uint16(18243), + 4972: uint16(9472), + 4973: uint16(3856), + 4974: uint16(18236), + 4975: uint16(18232), + 4976: uint16(8273), + 4977: uint16(18226), + 4978: uint16(18234), + 4979: uint16(18239), + 4980: uint16(9739), + 4981: uint16(3849), + 4982: uint16(18231), + 4983: uint16(18240), + 4984: uint16(10327), + 4985: uint16(18235), + 4986: uint16(18230), + 4987: uint16(7476), + 4988: uint16(7182), + 4989: uint16(6923), + 4990: uint16(11063), + 4991: uint16(10278), + 4992: uint16(18246), + 4993: uint16(18255), + 4994: uint16(18233), + 4995: uint16(4694), + 4996: uint16(7511), + 4997: uint16(18244), + 4998: uint16(18249), + 4999: uint16(8274), + 5000: uint16(18245), + 5001: uint16(18252), + 5002: uint16(8766), + 5003: uint16(18253), + 5004: uint16(11317), + 5005: uint16(18242), + 5006: uint16(4631), + 5007: uint16(18248), + 5008: uint16(18251), + 5009: uint16(11019), + 5010: uint16(18254), + 5011: uint16(18247), + 5012: uint16(18250), + 5013: uint16(10760), + 5014: uint16(11776), + 5015: uint16(18258), + 5016: uint16(18265), + 5017: uint16(18257), + 5018: uint16(6946), + 5019: uint16(18224), + 5020: uint16(10541), + 5021: uint16(11009), + 5022: uint16(18264), + 5023: uint16(18263), + 5024: uint16(18259), + 5025: uint16(18260), + 5026: uint16(4117), + 5027: uint16(18262), + 5028: uint16(18256), + 5029: uint16(9012), + 5030: uint16(18261), + 5031: uint16(3933), + 5032: uint16(8449), + 5033: uint16(10530), + 5034: uint16(18266), + 5035: uint16(18432), + 5036: uint16(10040), + 5037: uint16(18269), + 5038: uint16(7477), + 5039: uint16(6952), + 5040: uint16(18434), + 5041: uint16(5405), + 5042: uint16(18435), + 5043: uint16(10328), + 5044: uint16(18268), + 5045: uint16(18229), + 5046: uint16(18267), + 5047: uint16(11822), + 5048: uint16(9473), + 5049: uint16(10322), + 5050: uint16(18442), + 5051: uint16(18448), + 5052: uint16(18449), + 5053: uint16(18436), + 5054: uint16(9813), + 5055: uint16(18446), + 5056: uint16(18438), + 5057: uint16(18440), + 5058: uint16(18450), + 5059: uint16(18439), + 5060: uint16(18443), + 5061: uint16(4177), + 5062: uint16(9540), + 5063: uint16(18444), + 5064: uint16(18447), + 5065: uint16(18437), + 5066: uint16(8197), + 5067: uint16(18441), + 5068: uint16(6662), + 5069: uint16(7716), + 5070: uint16(5647), + 5071: uint16(11091), + 5072: uint16(11096), + 5073: uint16(7249), + 5074: uint16(18454), + 5075: uint16(18452), + 5076: uint16(11821), + 5077: uint16(18451), + 5078: uint16(11348), + 5079: uint16(18453), + 5080: uint16(18455), + 5081: uint16(18456), + 5082: uint16(18459), + 5083: uint16(18457), + 5084: uint16(9474), + 5085: uint16(18458), + 5086: uint16(10028), + 5087: uint16(18445), + 5088: uint16(7250), + 5089: uint16(18460), + 5090: uint16(18465), + 5091: uint16(8275), + 5092: uint16(18464), + 5093: uint16(18433), + 5094: uint16(18466), + 5095: uint16(8232), + 5096: uint16(18461), + 5097: uint16(18463), + 5098: uint16(18462), + 5099: uint16(15376), + 5100: uint16(15361), + 5101: uint16(18468), + 5102: uint16(18467), + 5103: uint16(11349), + 5104: uint16(16667), + 5105: uint16(18469), + 5106: uint16(18470), + 5107: uint16(18471), + 5108: uint16(5942), + 5109: uint16(5171), + 5110: uint16(18473), + 5111: uint16(12348), + 5112: uint16(5204), + 5113: uint16(11545), + 5114: uint16(5458), + 5115: uint16(18474), + 5116: uint16(18475), + 5117: uint16(8781), + 5118: uint16(18476), + 5119: uint16(9561), + 5120: uint16(3865), + 5121: uint16(4418), + 5122: uint16(18481), + 5123: uint16(18482), + 5124: uint16(18477), + 5125: uint16(6684), + 5126: uint16(18478), + 5127: uint16(9761), + 5128: uint16(18479), + 5129: uint16(18480), + 5130: uint16(18490), + 5131: uint16(18484), + 5132: uint16(18487), + 5133: uint16(18483), + 5134: uint16(18485), + 5135: uint16(18486), + 5136: uint16(6967), + 5137: uint16(18488), + 5138: uint16(8736), + 5139: uint16(5685), + 5140: uint16(4641), + 5141: uint16(18491), + 5142: uint16(4638), + 5143: uint16(18496), + 5144: uint16(18492), + 5145: uint16(18495), + 5146: uint16(10009), + 5147: uint16(18493), + 5148: uint16(18494), + 5149: uint16(10279), + 5150: uint16(10041), + 5151: uint16(18497), + 5152: uint16(8540), + 5153: uint16(18507), + 5154: uint16(18503), + 5155: uint16(4426), + 5156: uint16(18501), + 5157: uint16(10761), + 5158: uint16(18502), + 5159: uint16(18499), + 5160: uint16(18500), + 5161: uint16(18505), + 5162: uint16(18508), + 5163: uint16(18506), + 5164: uint16(18504), + 5165: uint16(18498), + 5166: uint16(8759), + 5167: uint16(18515), + 5168: uint16(11017), + 5169: uint16(18513), + 5170: uint16(18514), + 5171: uint16(18509), + 5172: uint16(18511), + 5173: uint16(18512), + 5174: uint16(18510), + 5175: uint16(8005), + 5176: uint16(11800), + 5177: uint16(18519), + 5178: uint16(18520), + 5179: uint16(18688), + 5180: uint16(7689), + 5181: uint16(18522), + 5182: uint16(18525), + 5183: uint16(18517), + 5184: uint16(18516), + 5185: uint16(18689), + 5186: uint16(4411), + 5187: uint16(18523), + 5188: uint16(18690), + 5189: uint16(18524), + 5190: uint16(18521), + 5191: uint16(8978), + 5192: uint16(18518), + 5193: uint16(9799), + 5194: uint16(18694), + 5195: uint16(11290), + 5196: uint16(18693), + 5197: uint16(18692), + 5198: uint16(18701), + 5199: uint16(18695), + 5200: uint16(18703), + 5201: uint16(11333), + 5202: uint16(18706), + 5203: uint16(18697), + 5204: uint16(18698), + 5205: uint16(18702), + 5206: uint16(18705), + 5207: uint16(18704), + 5208: uint16(18696), + 5209: uint16(18699), + 5210: uint16(18716), + 5211: uint16(18709), + 5212: uint16(18707), + 5213: uint16(18708), + 5214: uint16(18713), + 5215: uint16(18714), + 5216: uint16(4617), + 5217: uint16(5153), + 5218: uint16(18712), + 5219: uint16(18691), + 5220: uint16(18711), + 5221: uint16(18715), + 5222: uint16(18710), + 5223: uint16(18717), + 5224: uint16(18719), + 5225: uint16(18718), + 5226: uint16(18721), + 5227: uint16(18720), + 5228: uint16(18489), + 5229: uint16(18725), + 5230: uint16(18722), + 5231: uint16(18723), + 5232: uint16(18724), + 5233: uint16(18726), + 5234: uint16(5707), + 5235: uint16(18728), + 5236: uint16(18727), + 5237: uint16(7183), + 5238: uint16(6195), + 5239: uint16(15622), + 5240: uint16(18729), + 5241: uint16(7216), + 5242: uint16(4632), + 5243: uint16(18730), + 5244: uint16(4145), + 5245: uint16(7478), + 5246: uint16(18731), + 5247: uint16(6196), + 5248: uint16(18732), + 5249: uint16(3904), + 5250: uint16(10268), + 5251: uint16(18733), + 5252: uint16(7753), + 5253: uint16(18740), + 5254: uint16(18737), + 5255: uint16(8782), + 5256: uint16(18738), + 5257: uint16(18735), + 5258: uint16(5437), + 5259: uint16(18734), + 5260: uint16(18741), + 5261: uint16(5653), + 5262: uint16(8509), + 5263: uint16(18747), + 5264: uint16(18743), + 5265: uint16(8468), + 5266: uint16(18742), + 5267: uint16(18745), + 5268: uint16(18736), + 5269: uint16(18746), + 5270: uint16(18748), + 5271: uint16(10062), + 5272: uint16(18744), + 5273: uint16(18749), + 5274: uint16(18751), + 5275: uint16(5938), + 5276: uint16(18739), + 5277: uint16(3872), + 5278: uint16(18750), + 5279: uint16(6458), + 5280: uint16(11605), + 5281: uint16(18752), + 5282: uint16(18753), + 5283: uint16(8276), + 5284: uint16(11521), + 5285: uint16(18754), + 5286: uint16(11284), + 5287: uint16(18755), + 5288: uint16(18756), + 5289: uint16(10563), + 5290: uint16(18757), + 5291: uint16(6431), + 5292: uint16(11522), + 5293: uint16(18762), + 5294: uint16(18763), + 5295: uint16(7479), + 5296: uint16(18761), + 5297: uint16(11334), + 5298: uint16(18758), + 5299: uint16(18760), + 5300: uint16(7964), + 5301: uint16(7773), + 5302: uint16(18759), + 5303: uint16(18764), + 5304: uint16(10498), + 5305: uint16(18766), + 5306: uint16(18765), + 5307: uint16(4683), + 5308: uint16(10762), + 5309: uint16(18767), + 5310: uint16(18779), + 5311: uint16(18769), + 5312: uint16(18770), + 5313: uint16(18771), + 5314: uint16(18772), + 5315: uint16(18776), + 5316: uint16(18777), + 5317: uint16(18775), + 5318: uint16(18773), + 5319: uint16(18768), + 5320: uint16(18774), + 5321: uint16(18778), + 5322: uint16(20246), + 5323: uint16(4359), + 5324: uint16(18781), + 5325: uint16(5438), + 5326: uint16(18780), + 5327: uint16(18945), + 5328: uint16(18944), + 5329: uint16(18947), + 5330: uint16(18946), + 5331: uint16(18948), + 5332: uint16(7184), + 5333: uint16(18949), + 5334: uint16(18950), + 5335: uint16(18951), + 5336: uint16(7965), + 5337: uint16(11318), + 5338: uint16(18952), + 5339: uint16(10499), + 5340: uint16(9765), + 5341: uint16(18953), + 5342: uint16(18954), + 5343: uint16(5898), + 5344: uint16(5131), + 5345: uint16(18955), + 5346: uint16(6730), + 5347: uint16(9760), + 5348: uint16(18956), + 5349: uint16(4655), + 5350: uint16(18957), + 5351: uint16(18959), + 5352: uint16(11350), + 5353: uint16(18958), + 5354: uint16(7717), + 5355: uint16(18960), + 5356: uint16(18961), + 5357: uint16(18962), + 5358: uint16(4912), + 5359: uint16(18963), + 5360: uint16(18964), + 5361: uint16(18965), + 5362: uint16(18966), + 5363: uint16(4656), + 5364: uint16(18967), + 5365: uint16(18968), + 5366: uint16(18969), + 5367: uint16(4433), + 5368: uint16(7687), + 5369: uint16(18970), + 5370: uint16(18971), + 5371: uint16(18972), + 5372: uint16(5919), + 5373: uint16(9050), + 5374: uint16(18973), + 5375: uint16(5686), + 5376: uint16(7733), + 5377: uint16(18976), + 5378: uint16(9475), + 5379: uint16(18975), + 5380: uint16(5648), + 5381: uint16(18974), + 5382: uint16(8534), + 5383: uint16(5132), + 5384: uint16(18977), + 5385: uint16(18978), + 5386: uint16(7480), + 5387: uint16(5708), + 5388: uint16(18979), + 5389: uint16(10763), + 5390: uint16(7998), + 5391: uint16(5205), + 5392: uint16(11092), + 5393: uint16(8233), + 5394: uint16(18980), + 5395: uint16(7718), + 5396: uint16(8783), + 5397: uint16(7481), + 5398: uint16(18981), + 5399: uint16(18984), + 5400: uint16(18985), + 5401: uint16(6429), + 5402: uint16(8481), + 5403: uint16(18983), + 5404: uint16(7482), + 5405: uint16(10269), + 5406: uint16(18982), + 5407: uint16(6731), + 5408: uint16(4146), + 5409: uint16(18989), + 5410: uint16(5687), + 5411: uint16(6733), + 5412: uint16(6732), + 5413: uint16(11820), + 5414: uint16(18988), + 5415: uint16(18987), + 5416: uint16(8198), + 5417: uint16(5164), + 5418: uint16(11810), + 5419: uint16(4633), + 5420: uint16(7483), + 5421: uint16(18986), + 5422: uint16(18991), + 5423: uint16(18992), + 5424: uint16(18990), + 5425: uint16(5943), + 5426: uint16(11295), + 5427: uint16(6734), + 5428: uint16(9734), + 5429: uint16(18995), + 5430: uint16(7967), + 5431: uint16(8737), + 5432: uint16(11285), + 5433: uint16(18998), + 5434: uint16(5963), + 5435: uint16(7966), + 5436: uint16(18994), + 5437: uint16(18999), + 5438: uint16(5964), + 5439: uint16(18996), + 5440: uint16(18997), + 5441: uint16(18993), + 5442: uint16(8001), + 5443: uint16(9512), + 5444: uint16(8718), + 5445: uint16(4412), + 5446: uint16(10063), + 5447: uint16(5154), + 5448: uint16(8979), + 5449: uint16(19002), + 5450: uint16(19000), + 5451: uint16(8747), + 5452: uint16(7968), + 5453: uint16(4913), + 5454: uint16(19001), + 5455: uint16(7738), + 5456: uint16(11561), + 5457: uint16(11807), + 5458: uint16(19003), + 5459: uint16(19014), + 5460: uint16(8980), + 5461: uint16(19013), + 5462: uint16(19010), + 5463: uint16(19018), + 5464: uint16(19011), + 5465: uint16(19007), + 5466: uint16(9051), + 5467: uint16(19006), + 5468: uint16(19004), + 5469: uint16(11264), + 5470: uint16(6735), + 5471: uint16(19008), + 5472: uint16(19005), + 5473: uint16(19012), + 5474: uint16(7251), + 5475: uint16(5920), + 5476: uint16(8537), + 5477: uint16(10788), + 5478: uint16(4153), + 5479: uint16(3905), + 5480: uint16(9476), + 5481: uint16(19016), + 5482: uint16(19015), + 5483: uint16(9541), + 5484: uint16(19020), + 5485: uint16(19009), + 5486: uint16(19019), + 5487: uint16(19021), + 5488: uint16(5899), + 5489: uint16(19017), + 5490: uint16(6197), + 5491: uint16(6964), + 5492: uint16(19022), + 5493: uint16(11319), + 5494: uint16(19025), + 5495: uint16(19028), + 5496: uint16(19026), + 5497: uint16(10260), + 5498: uint16(19023), + 5499: uint16(5439), + 5500: uint16(19027), + 5501: uint16(19029), + 5502: uint16(19033), + 5503: uint16(19030), + 5504: uint16(19032), + 5505: uint16(19031), + 5506: uint16(19034), + 5507: uint16(6928), + 5508: uint16(19036), + 5509: uint16(19035), + 5510: uint16(10311), + 5511: uint16(19200), + 5512: uint16(5688), + 5513: uint16(19037), + 5514: uint16(19201), + 5515: uint16(19202), + 5516: uint16(5155), + 5517: uint16(17696), + 5518: uint16(7512), + 5519: uint16(19203), + 5520: uint16(5965), + 5521: uint16(19204), + 5522: uint16(19205), + 5523: uint16(6685), + 5524: uint16(14637), + 5525: uint16(19206), + 5526: uint16(19207), + 5527: uint16(7185), + 5528: uint16(19208), + 5529: uint16(19209), + 5530: uint16(19210), + 5531: uint16(19211), + 5532: uint16(19212), + 5533: uint16(8714), + 5534: uint16(19213), + 5535: uint16(19215), + 5536: uint16(19214), + 5537: uint16(9477), + 5538: uint16(19216), + 5539: uint16(10764), + 5540: uint16(19217), + 5541: uint16(19218), + 5542: uint16(19219), + 5543: uint16(19220), + 5544: uint16(9529), + 5545: uint16(7484), + 5546: uint16(19221), + 5547: uint16(6218), + 5548: uint16(12045), + 5549: uint16(19222), + 5550: uint16(19223), + 5551: uint16(10270), + 5552: uint16(19224), + 5553: uint16(19232), + 5554: uint16(19225), + 5555: uint16(19227), + 5556: uint16(19226), + 5557: uint16(19228), + 5558: uint16(10789), + 5559: uint16(19229), + 5560: uint16(19230), + 5561: uint16(19231), + 5562: uint16(19233), + 5563: uint16(4620), + 5564: uint16(9030), + 5565: uint16(10312), + 5566: uint16(6465), + 5567: uint16(6198), + 5568: uint16(10286), + 5569: uint16(4414), + 5570: uint16(10029), + 5571: uint16(19236), + 5572: uint16(4914), + 5573: uint16(7988), + 5574: uint16(19235), + 5575: uint16(19240), + 5576: uint16(8792), + 5577: uint16(11074), + 5578: uint16(19238), + 5579: uint16(19239), + 5580: uint16(5133), + 5581: uint16(19241), + 5582: uint16(9794), + 5583: uint16(8510), + 5584: uint16(10064), + 5585: uint16(9244), + 5586: uint16(19237), + 5587: uint16(10790), + 5588: uint16(4427), + 5589: uint16(19243), + 5590: uint16(11783), + 5591: uint16(8993), + 5592: uint16(11812), + 5593: uint16(6736), + 5594: uint16(19242), + 5595: uint16(8464), + 5596: uint16(19259), + 5597: uint16(8199), + 5598: uint16(9559), + 5599: uint16(10287), + 5600: uint16(19246), + 5601: uint16(6686), + 5602: uint16(6737), + 5603: uint16(7485), + 5604: uint16(9796), + 5605: uint16(5900), + 5606: uint16(19245), + 5607: uint16(19244), + 5608: uint16(10313), + 5609: uint16(6944), + 5610: uint16(9265), + 5611: uint16(19248), + 5612: uint16(19249), + 5613: uint16(6199), + 5614: uint16(19247), + 5615: uint16(19250), + 5616: uint16(19251), + 5617: uint16(19253), + 5618: uint16(8450), + 5619: uint16(19252), + 5620: uint16(4933), + 5621: uint16(19255), + 5622: uint16(19254), + 5623: uint16(19256), + 5624: uint16(19258), + 5625: uint16(19260), + 5626: uint16(19261), + 5627: uint16(7989), + 5628: uint16(6958), + 5629: uint16(19262), + 5630: uint16(4657), + 5631: uint16(19263), + 5632: uint16(8277), + 5633: uint16(19264), + 5634: uint16(19265), + 5635: uint16(10314), + 5636: uint16(5134), + 5637: uint16(19266), + 5638: uint16(8981), + 5639: uint16(4154), + 5640: uint16(19267), + 5641: uint16(6992), + 5642: uint16(7765), + 5643: uint16(8460), + 5644: uint16(19270), + 5645: uint16(19269), + 5646: uint16(19268), + 5647: uint16(19276), + 5648: uint16(19274), + 5649: uint16(19271), + 5650: uint16(19273), + 5651: uint16(19272), + 5652: uint16(19275), + 5653: uint16(5206), + 5654: uint16(19279), + 5655: uint16(7990), + 5656: uint16(19280), + 5657: uint16(5944), + 5658: uint16(19277), + 5659: uint16(19278), + 5660: uint16(11784), + 5661: uint16(8982), + 5662: uint16(8200), + 5663: uint16(19281), + 5664: uint16(19284), + 5665: uint16(19282), + 5666: uint16(19283), + 5667: uint16(11320), + 5668: uint16(9478), + 5669: uint16(19287), + 5670: uint16(19285), + 5671: uint16(19286), + 5672: uint16(19288), + 5673: uint16(19464), + 5674: uint16(19291), + 5675: uint16(19292), + 5676: uint16(19290), + 5677: uint16(19289), + 5678: uint16(9052), + 5679: uint16(19456), + 5680: uint16(19460), + 5681: uint16(19457), + 5682: uint16(19293), + 5683: uint16(19458), + 5684: uint16(19459), + 5685: uint16(19466), + 5686: uint16(19461), + 5687: uint16(7991), + 5688: uint16(19463), + 5689: uint16(19465), + 5690: uint16(19462), + 5691: uint16(19468), + 5692: uint16(7186), + 5693: uint16(19467), + 5694: uint16(19469), + 5695: uint16(19470), + 5696: uint16(19473), + 5697: uint16(19472), + 5698: uint16(19471), + 5699: uint16(19475), + 5700: uint16(19474), + 5701: uint16(11093), + 5702: uint16(19477), + 5703: uint16(19476), + 5704: uint16(19478), + 5705: uint16(19479), + 5706: uint16(19481), + 5707: uint16(19480), + 5708: uint16(7719), + 5709: uint16(19482), + 5710: uint16(5452), + 5711: uint16(19483), + 5712: uint16(19485), + 5713: uint16(19486), + 5714: uint16(19487), + 5715: uint16(19484), + 5716: uint16(19488), + 5717: uint16(6965), + 5718: uint16(19489), + 5719: uint16(5135), + 5720: uint16(5650), + 5721: uint16(5901), + 5722: uint16(19490), + 5723: uint16(9551), + 5724: uint16(9245), + 5725: uint16(19491), + 5726: uint16(19494), + 5727: uint16(6931), + 5728: uint16(19493), + 5729: uint16(19492), + 5730: uint16(5689), + 5731: uint16(19495), + 5732: uint16(4658), + 5733: uint16(19497), + 5734: uint16(6459), + 5735: uint16(19496), + 5736: uint16(19505), + 5737: uint16(19499), + 5738: uint16(19501), + 5739: uint16(10564), + 5740: uint16(19498), + 5741: uint16(19500), + 5742: uint16(19504), + 5743: uint16(19502), + 5744: uint16(5136), + 5745: uint16(19503), + 5746: uint16(19506), + 5747: uint16(9785), + 5748: uint16(11575), + 5749: uint16(7187), + 5750: uint16(19507), + 5751: uint16(11265), + 5752: uint16(19509), + 5753: uint16(19508), + 5754: uint16(19512), + 5755: uint16(11296), + 5756: uint16(19511), + 5757: uint16(4684), + 5758: uint16(19510), + 5759: uint16(19515), + 5760: uint16(19514), + 5761: uint16(19513), + 5762: uint16(9233), + 5763: uint16(19516), + 5764: uint16(19517), + 5765: uint16(19518), + 5766: uint16(6219), + 5767: uint16(5636), + 5768: uint16(19519), + 5769: uint16(19520), + 5770: uint16(19521), + 5771: uint16(7720), + 5772: uint16(19522), + 5773: uint16(6924), + 5774: uint16(19523), + 5775: uint16(19524), + 5776: uint16(12544), + 5777: uint16(12381), + 5778: uint16(19525), + 5779: uint16(17487), + 5780: uint16(19526), + 5781: uint16(8707), + 5782: uint16(7690), + 5783: uint16(9759), + 5784: uint16(19527), + 5785: uint16(10548), + 5786: uint16(9011), + 5787: uint16(6237), + 5788: uint16(8712), + 5789: uint16(4105), + 5790: uint16(10839), + 5791: uint16(7734), + 5792: uint16(5693), + 5793: uint16(5440), + 5794: uint16(10549), + 5795: uint16(19528), + 5796: uint16(19530), + 5797: uint16(19529), + 5798: uint16(4415), + 5799: uint16(9557), + 5800: uint16(19531), + 5801: uint16(9814), + 5802: uint16(9234), + 5803: uint16(19532), + 5804: uint16(7217), + 5805: uint16(19534), + 5806: uint16(11041), + 5807: uint16(19549), + 5808: uint16(19536), + 5809: uint16(19537), + 5810: uint16(9000), + 5811: uint16(8511), + 5812: uint16(8278), + 5813: uint16(9479), + 5814: uint16(19535), + 5815: uint16(5172), + 5816: uint16(19544), + 5817: uint16(19541), + 5818: uint16(19716), + 5819: uint16(9480), + 5820: uint16(8767), + 5821: uint16(19538), + 5822: uint16(9053), + 5823: uint16(9266), + 5824: uint16(19539), + 5825: uint16(19543), + 5826: uint16(7743), + 5827: uint16(9798), + 5828: uint16(9003), + 5829: uint16(7969), + 5830: uint16(19542), + 5831: uint16(8461), + 5832: uint16(8451), + 5833: uint16(19540), + 5834: uint16(3848), + 5835: uint16(11777), + 5836: uint16(19545), + 5837: uint16(8512), + 5838: uint16(7188), + 5839: uint16(7721), + 5840: uint16(19547), + 5841: uint16(19546), + 5842: uint16(3918), + 5843: uint16(19548), + 5844: uint16(10254), + 5845: uint16(19718), + 5846: uint16(9530), + 5847: uint16(7754), + 5848: uint16(8760), + 5849: uint16(5463), + 5850: uint16(19717), + 5851: uint16(11286), + 5852: uint16(4126), + 5853: uint16(10550), + 5854: uint16(4416), + 5855: uint16(19712), + 5856: uint16(19713), + 5857: uint16(19714), + 5858: uint16(19715), + 5859: uint16(9498), + 5860: uint16(8706), + 5861: uint16(3906), + 5862: uint16(19719), + 5863: uint16(19720), + 5864: uint16(21250), + 5865: uint16(8476), + 5866: uint16(19721), + 5867: uint16(4178), + 5868: uint16(8235), + 5869: uint16(5902), + 5870: uint16(11321), + 5871: uint16(19722), + 5872: uint16(9227), + 5873: uint16(8279), + 5874: uint16(6966), + 5875: uint16(19723), + 5876: uint16(19726), + 5877: uint16(7236), + 5878: uint16(19724), + 5879: uint16(8202), + 5880: uint16(8201), + 5881: uint16(3907), + 5882: uint16(11562), + 5883: uint16(19728), + 5884: uint16(10065), + 5885: uint16(19730), + 5886: uint16(19729), + 5887: uint16(19727), + 5888: uint16(16963), + 5889: uint16(4915), + 5890: uint16(19533), + 5891: uint16(19732), + 5892: uint16(19731), + 5893: uint16(19733), + 5894: uint16(11287), + 5895: uint16(9536), + 5896: uint16(10765), + 5897: uint16(19734), + 5898: uint16(6968), + 5899: uint16(19735), + 5900: uint16(19736), + 5901: uint16(19737), + 5902: uint16(9216), + 5903: uint16(3913), + 5904: uint16(6200), + 5905: uint16(11801), + 5906: uint16(19741), + 5907: uint16(5651), + 5908: uint16(19738), + 5909: uint16(19739), + 5910: uint16(10323), + 5911: uint16(4659), + 5912: uint16(11288), + 5913: uint16(5406), + 5914: uint16(9267), + 5915: uint16(19742), + 5916: uint16(19743), + 5917: uint16(19744), + 5918: uint16(9217), + 5919: uint16(19746), + 5920: uint16(19745), + 5921: uint16(9522), + 5922: uint16(19747), + 5923: uint16(7189), + 5924: uint16(6975), + 5925: uint16(9786), + 5926: uint16(8784), + 5927: uint16(6993), + 5928: uint16(7755), + 5929: uint16(19748), + 5930: uint16(19749), + 5931: uint16(7740), + 5932: uint16(19750), + 5933: uint16(19751), + 5934: uint16(19752), + 5935: uint16(11342), + 5936: uint16(7190), + 5937: uint16(19754), + 5938: uint16(19753), + 5939: uint16(6201), + 5940: uint16(6226), + 5941: uint16(6687), + 5942: uint16(19757), + 5943: uint16(7237), + 5944: uint16(19756), + 5945: uint16(19755), + 5946: uint16(8520), + 5947: uint16(5966), + 5948: uint16(7970), + 5949: uint16(9999), + 5950: uint16(7192), + 5951: uint16(19758), + 5952: uint16(7486), + 5953: uint16(19761), + 5954: uint16(19759), + 5955: uint16(19760), + 5956: uint16(19763), + 5957: uint16(19762), + 5958: uint16(7513), + 5959: uint16(19764), + 5960: uint16(19765), + 5961: uint16(19766), + 5962: uint16(10031), + 5963: uint16(6450), + 5964: uint16(6976), + 5965: uint16(19767), + 5966: uint16(19768), + 5967: uint16(11523), + 5968: uint16(7204), + 5969: uint16(11085), + 5970: uint16(11563), + 5971: uint16(19769), + 5972: uint16(5441), + 5973: uint16(19770), + 5974: uint16(9218), + 5975: uint16(19773), + 5976: uint16(4695), + 5977: uint16(7722), + 5978: uint16(19771), + 5979: uint16(19772), + 5980: uint16(9023), + 5981: uint16(10804), + 5982: uint16(5467), + 5983: uint16(19775), + 5984: uint16(19776), + 5985: uint16(19774), + 5986: uint16(19778), + 5987: uint16(9534), + 5988: uint16(4642), + 5989: uint16(19782), + 5990: uint16(19779), + 5991: uint16(19781), + 5992: uint16(19777), + 5993: uint16(20014), + 5994: uint16(19780), + 5995: uint16(11594), + 5996: uint16(5945), + 5997: uint16(19790), + 5998: uint16(9235), + 5999: uint16(19785), + 6000: uint16(19788), + 6001: uint16(19786), + 6002: uint16(19791), + 6003: uint16(19792), + 6004: uint16(19784), + 6005: uint16(19797), + 6006: uint16(4179), + 6007: uint16(19783), + 6008: uint16(9996), + 6009: uint16(19787), + 6010: uint16(7487), + 6011: uint16(6202), + 6012: uint16(10791), + 6013: uint16(5443), + 6014: uint16(7205), + 6015: uint16(9499), + 6016: uint16(8204), + 6017: uint16(19795), + 6018: uint16(19789), + 6019: uint16(19794), + 6020: uint16(11042), + 6021: uint16(8983), + 6022: uint16(19796), + 6023: uint16(19793), + 6024: uint16(8203), + 6025: uint16(19800), + 6026: uint16(19799), + 6027: uint16(19798), + 6028: uint16(10766), + 6029: uint16(7258), + 6030: uint16(19801), + 6031: uint16(10558), + 6032: uint16(4147), + 6033: uint16(10277), + 6034: uint16(8785), + 6035: uint16(5207), + 6036: uint16(19803), + 6037: uint16(6204), + 6038: uint16(6667), + 6039: uint16(19802), + 6040: uint16(7756), + 6041: uint16(7757), + 6042: uint16(19968), + 6043: uint16(19970), + 6044: uint16(7514), + 6045: uint16(19969), + 6046: uint16(19971), + 6047: uint16(5426), + 6048: uint16(10276), + 6049: uint16(6977), + 6050: uint16(11778), + 6051: uint16(19805), + 6052: uint16(6487), + 6053: uint16(11806), + 6054: uint16(19973), + 6055: uint16(19972), + 6056: uint16(19974), + 6057: uint16(19804), + 6058: uint16(9544), + 6059: uint16(9268), + 6060: uint16(9014), + 6061: uint16(19979), + 6062: uint16(8738), + 6063: uint16(19975), + 6064: uint16(19976), + 6065: uint16(5644), + 6066: uint16(19978), + 6067: uint16(5903), + 6068: uint16(19977), + 6069: uint16(7488), + 6070: uint16(4696), + 6071: uint16(19983), + 6072: uint16(6430), + 6073: uint16(8280), + 6074: uint16(9001), + 6075: uint16(4634), + 6076: uint16(19981), + 6077: uint16(19982), + 6078: uint16(8994), + 6079: uint16(19980), + 6080: uint16(19984), + 6081: uint16(19990), + 6082: uint16(19993), + 6083: uint16(19992), + 6084: uint16(9228), + 6085: uint16(19985), + 6086: uint16(19986), + 6087: uint16(19989), + 6088: uint16(19991), + 6089: uint16(5407), + 6090: uint16(19994), + 6091: uint16(19988), + 6092: uint16(19987), + 6093: uint16(19998), + 6094: uint16(19999), + 6095: uint16(20000), + 6096: uint16(19997), + 6097: uint16(19996), + 6098: uint16(7489), + 6099: uint16(9481), + 6100: uint16(19995), + 6101: uint16(20004), + 6102: uint16(20002), + 6103: uint16(20003), + 6104: uint16(20001), + 6105: uint16(8535), + 6106: uint16(20005), + 6107: uint16(20006), + 6108: uint16(20008), + 6109: uint16(4916), + 6110: uint16(20007), + 6111: uint16(11097), + 6112: uint16(20019), + 6113: uint16(20009), + 6114: uint16(20012), + 6115: uint16(20010), + 6116: uint16(20011), + 6117: uint16(20013), + 6118: uint16(20015), + 6119: uint16(20016), + 6120: uint16(20017), + 6121: uint16(20020), + 6122: uint16(20018), + 6123: uint16(20021), + 6124: uint16(20023), + 6125: uint16(20022), + 6126: uint16(8984), + 6127: uint16(11078), + 6128: uint16(20024), + 6129: uint16(8205), + 6130: uint16(20025), + 6131: uint16(10531), + 6132: uint16(20026), + 6133: uint16(4618), + 6134: uint16(4123), + 6135: uint16(4918), + 6136: uint16(4917), + 6137: uint16(20027), + 6138: uint16(20028), + 6139: uint16(20029), + 6140: uint16(20030), + 6141: uint16(20031), + 6142: uint16(4919), + 6143: uint16(4660), + 6144: uint16(6205), + 6145: uint16(10005), + 6146: uint16(20033), + 6147: uint16(20032), + 6148: uint16(20034), + 6149: uint16(4155), + 6150: uint16(20037), + 6151: uint16(20036), + 6152: uint16(20035), + 6153: uint16(20038), + 6154: uint16(20041), + 6155: uint16(3878), + 6156: uint16(20039), + 6157: uint16(20043), + 6158: uint16(20042), + 6159: uint16(20045), + 6160: uint16(20044), + 6161: uint16(20046), + 6162: uint16(9485), + 6163: uint16(20047), + 6164: uint16(20048), + 6165: uint16(20050), + 6166: uint16(20049), + 6167: uint16(10315), + 6168: uint16(20051), + 6169: uint16(20052), + 6170: uint16(6468), + 6171: uint16(20053), + 6172: uint16(20054), + 6173: uint16(10792), + 6174: uint16(8234), + 6175: uint16(3843), + 6176: uint16(8490), + 6177: uint16(20055), + 6178: uint16(10316), + 6179: uint16(20058), + 6180: uint16(20056), + 6181: uint16(6206), + 6182: uint16(20057), + 6183: uint16(5921), + 6184: uint16(10532), + 6185: uint16(20060), + 6186: uint16(20224), + 6187: uint16(20061), + 6188: uint16(20225), + 6189: uint16(4096), + 6190: uint16(7735), + 6191: uint16(7259), + 6192: uint16(4920), + 6193: uint16(20226), + 6194: uint16(9797), + 6195: uint16(20228), + 6196: uint16(4097), + 6197: uint16(20227), + 6198: uint16(8995), + 6199: uint16(11564), + 6200: uint16(9482), + 6201: uint16(20059), + 6202: uint16(11525), + 6203: uint16(5904), + 6204: uint16(11322), + 6205: uint16(5464), + 6206: uint16(11539), + 6207: uint16(5639), + 6208: uint16(8513), + 6209: uint16(17920), + 6210: uint16(20229), + 6211: uint16(4619), + 6212: uint16(7758), + 6213: uint16(4661), + 6214: uint16(20231), + 6215: uint16(20232), + 6216: uint16(20230), + 6217: uint16(5699), + 6218: uint16(6460), + 6219: uint16(7490), + 6220: uint16(4098), + 6221: uint16(11576), + 6222: uint16(20234), + 6223: uint16(19725), + 6224: uint16(20233), + 6225: uint16(20237), + 6226: uint16(20235), + 6227: uint16(20236), + 6228: uint16(20238), + 6229: uint16(20239), + 6230: uint16(11595), + 6231: uint16(20240), + 6232: uint16(20241), + 6233: uint16(7976), + 6234: uint16(10010), + 6235: uint16(7772), + 6236: uint16(4934), + 6237: uint16(11289), + 6238: uint16(4428), + 6239: uint16(7191), + 6240: uint16(5946), + 6241: uint16(20244), + 6242: uint16(20243), + 6243: uint16(6738), + 6244: uint16(20245), + 6245: uint16(20242), + 6246: uint16(6663), + 6247: uint16(20249), + 6248: uint16(18700), + 6249: uint16(12597), + 6250: uint16(7766), + 6251: uint16(20247), + 6252: uint16(11524), + 6253: uint16(9552), + 6254: uint16(4106), + 6255: uint16(8002), + 6256: uint16(6933), + 6257: uint16(10518), + 6258: uint16(4127), + 6259: uint16(11596), + 6260: uint16(11338), + 6261: uint16(20250), + 6262: uint16(9252), + 6263: uint16(7002), + 6264: uint16(20251), + 6265: uint16(20252), + 6266: uint16(7723), + 6267: uint16(20253), + 6268: uint16(11597), + 6269: uint16(20248), + 6270: uint16(20255), + 6271: uint16(20257), + 6272: uint16(20256), + 6273: uint16(20254), + 6274: uint16(20258), + 6275: uint16(20259), + 6276: uint16(8281), + 6277: uint16(4417), + 6278: uint16(20260), + 6279: uint16(11031), + 6280: uint16(20261), + 6281: uint16(20262), + 6282: uint16(11785), + 6283: uint16(14864), + 6284: uint16(20263), + 6285: uint16(20264), + 6286: uint16(20265), + 6287: uint16(20269), + 6288: uint16(20266), + 6289: uint16(20267), + 6290: uint16(20268), + 6291: uint16(20270), + 6292: uint16(7971), + 6293: uint16(11094), + 6294: uint16(7972), + 6295: uint16(20271), + 6296: uint16(10066), + 6297: uint16(20272), + 6298: uint16(21042), + 6299: uint16(11051), + 6300: uint16(20273), + 6301: uint16(20274), + 6302: uint16(20275), + 6303: uint16(4662), + 6304: uint16(20277), + 6305: uint16(7736), + 6306: uint16(20278), + 6307: uint16(5635), + 6308: uint16(20279), + 6309: uint16(20283), + 6310: uint16(20281), + 6311: uint16(20282), + 6312: uint16(4690), + 6313: uint16(20280), + 6314: uint16(20284), + 6315: uint16(20285), + 6316: uint16(3879), + 6317: uint16(20286), + 6318: uint16(20287), + 6319: uint16(7491), + 6320: uint16(20288), + 6321: uint16(5158), + 6322: uint16(20291), + 6323: uint16(20290), + 6324: uint16(20289), + 6325: uint16(19024), + 6326: uint16(10555), + 6327: uint16(20292), + 6328: uint16(20293), + 6329: uint16(20294), + 6330: uint16(20295), + 6331: uint16(20296), + 6332: uint16(20297), + 6333: uint16(4921), + 6334: uint16(20298), + 6335: uint16(20299), + 6336: uint16(9730), + 6337: uint16(20301), + 6338: uint16(4378), + 6339: uint16(20304), + 6340: uint16(20303), + 6341: uint16(4099), + 6342: uint16(5408), + 6343: uint16(10534), + 6344: uint16(8985), + 6345: uint16(6401), + 6346: uint16(6207), + 6347: uint16(7238), + 6348: uint16(7739), + 6349: uint16(20306), + 6350: uint16(20305), + 6351: uint16(11297), + 6352: uint16(4935), + 6353: uint16(10033), + 6354: uint16(9531), + 6355: uint16(7771), + 6356: uint16(11565), + 6357: uint16(5690), + 6358: uint16(20309), + 6359: uint16(20308), + 6360: uint16(10794), + 6361: uint16(9483), + 6362: uint16(4143), + 6363: uint16(20310), + 6364: uint16(20307), + 6365: uint16(10288), + 6366: uint16(11337), + 6367: uint16(20311), + 6368: uint16(20312), + 6369: uint16(20314), + 6370: uint16(8521), + 6371: uint16(4666), + 6372: uint16(4667), + 6373: uint16(20313), + 6374: uint16(4936), + 6375: uint16(5905), + 6376: uint16(4937), + 6377: uint16(9246), + 6378: uint16(11583), + 6379: uint16(5947), + 6380: uint16(20315), + 6381: uint16(20316), + 6382: uint16(20317), + 6383: uint16(20480), + 6384: uint16(20482), + 6385: uint16(20481), + 6386: uint16(10326), + 6387: uint16(20483), + 6388: uint16(20484), + 6389: uint16(20485), + 6390: uint16(20486), + 6391: uint16(20488), + 6392: uint16(20487), + 6393: uint16(20489), + 6394: uint16(10067), + 6395: uint16(17707), + 6396: uint16(7688), + 6397: uint16(5137), + 6398: uint16(20490), + 6399: uint16(20491), + 6400: uint16(12555), + 6401: uint16(15386), + 6402: uint16(10034), + 6403: uint16(3930), + 6404: uint16(3866), + 6405: uint16(6739), + 6406: uint16(10767), + 6407: uint16(7517), + 6408: uint16(20492), + 6409: uint16(11070), + 6410: uint16(20493), + 6411: uint16(11323), + 6412: uint16(4129), + 6413: uint16(6688), + 6414: uint16(20494), + 6415: uint16(4429), + 6416: uint16(20495), + 6417: uint16(20496), + 6418: uint16(20498), + 6419: uint16(20499), + 6420: uint16(20501), + 6421: uint16(20497), + 6422: uint16(20500), + 6423: uint16(4922), + 6424: uint16(20502), + 6425: uint16(20503), + 6426: uint16(20504), + 6427: uint16(20505), + 6428: uint16(20506), + 6429: uint16(20508), + 6430: uint16(20507), + 6431: uint16(20510), + 6432: uint16(20513), + 6433: uint16(20509), + 6434: uint16(20511), + 6435: uint16(20512), + 6436: uint16(20514), + 6437: uint16(5409), + 6438: uint16(6994), + 6439: uint16(20515), + 6440: uint16(20516), + 6441: uint16(6208), + 6442: uint16(20517), + 6443: uint16(4637), + 6444: uint16(9774), + 6445: uint16(20518), + 6446: uint16(20519), + 6447: uint16(8761), + 6448: uint16(9546), + 6449: uint16(20520), + 6450: uint16(9820), + 6451: uint16(8491), + 6452: uint16(4151), + 6453: uint16(5453), + 6454: uint16(5454), + 6455: uint16(8786), + 6456: uint16(20525), + 6457: uint16(5455), + 6458: uint16(4430), + 6459: uint16(20524), + 6460: uint16(20522), + 6461: uint16(20523), + 6462: uint16(20521), + 6463: uint16(20535), + 6464: uint16(20526), + 6465: uint16(20527), + 6466: uint16(20528), + 6467: uint16(20529), + 6468: uint16(20531), + 6469: uint16(20530), + 6470: uint16(7224), + 6471: uint16(20532), + 6472: uint16(20534), + 6473: uint16(5138), + 6474: uint16(20533), + 6475: uint16(8282), + 6476: uint16(5906), + 6477: uint16(20536), + 6478: uint16(8492), + 6479: uint16(20537), + 6480: uint16(9484), + 6481: uint16(20538), + 6482: uint16(20543), + 6483: uint16(20541), + 6484: uint16(20540), + 6485: uint16(20542), + 6486: uint16(20539), + 6487: uint16(20545), + 6488: uint16(20544), + 6489: uint16(20547), + 6490: uint16(5410), + 6491: uint16(20546), + 6492: uint16(20548), + 6493: uint16(20549), + 6494: uint16(20551), + 6495: uint16(20550), + 6496: uint16(20552), + 6497: uint16(20554), + 6498: uint16(20553), + 6499: uint16(6235), + 6500: uint16(20555), + 6501: uint16(20556), + 6502: uint16(4635), + 6503: uint16(20557), + 6504: uint16(20558), + 6505: uint16(7760), + 6506: uint16(20559), + 6507: uint16(20560), + 6508: uint16(20561), + 6509: uint16(20562), + 6510: uint16(6209), + 6511: uint16(20563), + 6512: uint16(20564), + 6513: uint16(20565), + 6514: uint16(20566), + 6515: uint16(20567), + 6516: uint16(10000), + 6517: uint16(20569), + 6518: uint16(10245), + 6519: uint16(20570), + 6520: uint16(20568), + 6521: uint16(20572), + 6522: uint16(20571), + 6523: uint16(20573), + 6524: uint16(20736), + 6525: uint16(20737), + 6526: uint16(20738), + 6527: uint16(20739), + 6528: uint16(20740), + 6529: uint16(20741), + 6530: uint16(20742), + 6531: uint16(20743), + 6532: uint16(20744), + 6533: uint16(20745), + 6534: uint16(20746), + 6535: uint16(20747), + 6536: uint16(20748), + 6537: uint16(20749), + 6538: uint16(15380), + 6539: uint16(20750), + 6540: uint16(17239), + 6541: uint16(5139), + 6542: uint16(4608), + 6543: uint16(6417), + 6544: uint16(20752), + 6545: uint16(20751), + 6546: uint16(11012), + 6547: uint16(20754), + 6548: uint16(20755), + 6549: uint16(20753), + 6550: uint16(20756), + 6551: uint16(10817), + 6552: uint16(20757), + 6553: uint16(5210), + 6554: uint16(11780), + 6555: uint16(20758), + 6556: uint16(20760), + 6557: uint16(3869), + 6558: uint16(20761), + 6559: uint16(10506), + 6560: uint16(20759), + 6561: uint16(20762), + 6562: uint16(20763), + 6563: uint16(20764), + 6564: uint16(20765), + 6565: uint16(20766), + 6566: uint16(10829), + 6567: uint16(6668), + 6568: uint16(6489), + 6569: uint16(8206), + 6570: uint16(20767), + 6571: uint16(20770), + 6572: uint16(20768), + 6573: uint16(20771), + 6574: uint16(5968), + 6575: uint16(20769), + 6576: uint16(20772), + 6577: uint16(20773), + 6578: uint16(20774), + 6579: uint16(20778), + 6580: uint16(6665), + 6581: uint16(8515), + 6582: uint16(20779), + 6583: uint16(20776), + 6584: uint16(20775), + 6585: uint16(20777), + 6586: uint16(5694), + 6587: uint16(20783), + 6588: uint16(20782), + 6589: uint16(20781), + 6590: uint16(3858), + 6591: uint16(20793), + 6592: uint16(20789), + 6593: uint16(20790), + 6594: uint16(20786), + 6595: uint16(20792), + 6596: uint16(20788), + 6597: uint16(4673), + 6598: uint16(11819), + 6599: uint16(20791), + 6600: uint16(20787), + 6601: uint16(20785), + 6602: uint16(20784), + 6603: uint16(20795), + 6604: uint16(20798), + 6605: uint16(20797), + 6606: uint16(20796), + 6607: uint16(10280), + 6608: uint16(20794), + 6609: uint16(3922), + 6610: uint16(20799), + 6611: uint16(20801), + 6612: uint16(4686), + 6613: uint16(20780), + 6614: uint16(4118), + 6615: uint16(20803), + 6616: uint16(20802), + 6617: uint16(20800), + 6618: uint16(8716), + 6619: uint16(10831), + 6620: uint16(11577), + 6621: uint16(20804), + 6622: uint16(20805), + 6623: uint16(20806), + 6624: uint16(20807), + 6625: uint16(20808), + 6626: uint16(8986), + 6627: uint16(20809), + 6628: uint16(10006), + 6629: uint16(20814), + 6630: uint16(20810), + 6631: uint16(20811), + 6632: uint16(10768), + 6633: uint16(11043), + 6634: uint16(9519), + 6635: uint16(20815), + 6636: uint16(20816), + 6637: uint16(9501), + 6638: uint16(20813), + 6639: uint16(20812), + 6640: uint16(4361), + 6641: uint16(20824), + 6642: uint16(20823), + 6643: uint16(4180), + 6644: uint16(20821), + 6645: uint16(20820), + 6646: uint16(20818), + 6647: uint16(4698), + 6648: uint16(20817), + 6649: uint16(6929), + 6650: uint16(4360), + 6651: uint16(6210), + 6652: uint16(20827), + 6653: uint16(20826), + 6654: uint16(20825), + 6655: uint16(20822), + 6656: uint16(20828), + 6657: uint16(20829), + 6658: uint16(20996), + 6659: uint16(20995), + 6660: uint16(20997), + 6661: uint16(4108), + 6662: uint16(20992), + 6663: uint16(20993), + 6664: uint16(6227), + 6665: uint16(11032), + 6666: uint16(20994), + 6667: uint16(10769), + 6668: uint16(21002), + 6669: uint16(20998), + 6670: uint16(21003), + 6671: uint16(21000), + 6672: uint16(20999), + 6673: uint16(5691), + 6674: uint16(21004), + 6675: uint16(21005), + 6676: uint16(21006), + 6677: uint16(21001), + 6678: uint16(20819), + 6679: uint16(21007), + 6680: uint16(9024), + 6681: uint16(21011), + 6682: uint16(21012), + 6683: uint16(21010), + 6684: uint16(21009), + 6685: uint16(21015), + 6686: uint16(21008), + 6687: uint16(21013), + 6688: uint16(21014), + 6689: uint16(21017), + 6690: uint16(21016), + 6691: uint16(21019), + 6692: uint16(21020), + 6693: uint16(21021), + 6694: uint16(11816), + 6695: uint16(21018), + 6696: uint16(8522), + 6697: uint16(6476), + 6698: uint16(21022), + 6699: uint16(21023), + 6700: uint16(21024), + 6701: uint16(21025), + 6702: uint16(21026), + 6703: uint16(5907), + 6704: uint16(21027), + 6705: uint16(21028), + 6706: uint16(6926), + 6707: uint16(21029), + 6708: uint16(21030), + 6709: uint16(21031), + 6710: uint16(21032), + 6711: uint16(21035), + 6712: uint16(21033), + 6713: uint16(11803), + 6714: uint16(21034), + 6715: uint16(11598), + 6716: uint16(21036), + 6717: uint16(11578), + 6718: uint16(21037), + 6719: uint16(9821), + 6720: uint16(21038), + 6721: uint16(21040), + 6722: uint16(21041), + 6723: uint16(21039), + 6724: uint16(6220), + 6725: uint16(11052), + 6726: uint16(10818), + 6727: uint16(13654), + 6728: uint16(15423), + 6729: uint16(10842), + 6730: uint16(4362), + 6731: uint16(21043), + 6732: uint16(5167), + 6733: uint16(21044), + 6734: uint16(21045), + 6735: uint16(21046), + 6736: uint16(6228), + 6737: uint16(21047), + 6738: uint16(16179), + 6739: uint16(11066), + 6740: uint16(8514), + 6741: uint16(21048), + 6742: uint16(21050), + 6743: uint16(21049), + 6744: uint16(21051), + 6745: uint16(21052), + 6746: uint16(21053), + 6747: uint16(21054), + 6748: uint16(21055), + 6749: uint16(21056), + 6750: uint16(21057), + 6751: uint16(21058), + 6752: uint16(21059), + 6753: uint16(21060), + 6754: uint16(21061), + 6755: uint16(21062), + 6756: uint16(21063), + 6757: uint16(9219), + 6758: uint16(5948), + 6759: uint16(21065), + 6760: uint16(8236), + 6761: uint16(21066), + 6762: uint16(21067), + 6763: uint16(10240), + 6764: uint16(21068), + 6765: uint16(21069), + 6766: uint16(16918), + 6767: uint16(19257), + 6768: uint16(20300), + 6769: uint16(21070), + 6770: uint16(21071), + 6771: uint16(21073), + 6772: uint16(21074), + 6773: uint16(21075), + 6774: uint16(11599), + 6775: uint16(21072), + 6776: uint16(21076), + 6777: uint16(21077), + 6778: uint16(21079), + 6779: uint16(21078), + 6780: uint16(21081), + 6781: uint16(21082), + 6782: uint16(21080), + 6783: uint16(11541), + 6784: uint16(21083), + 6785: uint16(21084), + 6786: uint16(16947), + 6787: uint16(21085), + 6788: uint16(9), + 6789: uint16(83), + 6790: uint16(79), + 6791: uint16(82), + 6792: uint16(84), + 6793: uint16(41), + 6794: uint16(42), + 6795: uint16(85), + 6796: uint16(59), + 6797: uint16(3), + 6798: uint16(4), + 6799: uint16(30), + 6800: uint16(527), + 6801: uint16(528), + 6802: uint16(529), + 6803: uint16(530), + 6804: uint16(531), + 6805: uint16(532), + 6806: uint16(533), + 6807: uint16(534), + 6808: uint16(535), + 6809: uint16(536), + 6810: uint16(6), + 6811: uint16(7), + 6812: uint16(66), + 6813: uint16(64), + 6814: uint16(67), + 6815: uint16(8), + 6816: uint16(86), + 6817: uint16(544), + 6818: uint16(545), + 6819: uint16(546), + 6820: uint16(547), + 6821: uint16(548), + 6822: uint16(549), + 6823: uint16(550), + 6824: uint16(551), + 6825: uint16(552), + 6826: uint16(553), + 6827: uint16(554), + 6828: uint16(555), + 6829: uint16(556), + 6830: uint16(557), + 6831: uint16(558), + 6832: uint16(559), + 6833: uint16(560), + 6834: uint16(561), + 6835: uint16(562), + 6836: uint16(563), + 6837: uint16(564), + 6838: uint16(565), + 6839: uint16(566), + 6840: uint16(567), + 6841: uint16(568), + 6842: uint16(569), + 6843: uint16(45), + 6844: uint16(46), + 6845: uint16(15), + 6846: uint16(17), + 6847: uint16(13), + 6848: uint16(576), + 6849: uint16(577), + 6850: uint16(578), + 6851: uint16(579), + 6852: uint16(580), + 6853: uint16(581), + 6854: uint16(582), + 6855: uint16(583), + 6856: uint16(584), + 6857: uint16(585), + 6858: uint16(586), + 6859: uint16(587), + 6860: uint16(588), + 6861: uint16(589), + 6862: uint16(590), + 6863: uint16(591), + 6864: uint16(592), + 6865: uint16(593), + 6866: uint16(594), + 6867: uint16(595), + 6868: uint16(596), + 6869: uint16(597), + 6870: uint16(598), + 6871: uint16(599), + 6872: uint16(600), + 6873: uint16(601), + 6874: uint16(47), + 6875: uint16(34), + 6876: uint16(48), + 6877: uint16(16), + 6878: uint16(78), +} + +func _fuzzycmp(tls *TLS, a uintptr, b uintptr) (r int32) { + for { + if !(**(**uint8)(__ccgo_up(a)) != 0 && **(**uint8)(__ccgo_up(b)) != 0) { + break + } + for **(**uint8)(__ccgo_up(a)) != 0 && uint32(**(**uint8)(__ccgo_up(a)))|uint32(32)-uint32('a') > uint32(26) && Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(a)))-int32('0')) > uint32(10) { + a = a + 1 + } + if uint32(**(**uint8)(__ccgo_up(a)))|uint32(32) != uint32(**(**uint8)(__ccgo_up(b))) { + return int32(1) + } + goto _1 + _1: + ; + a = a + 1 + b = b + 1 + } + return BoolInt32(Int32FromUint8(**(**uint8)(__ccgo_up(a))) != Int32FromUint8(**(**uint8)(__ccgo_up(b)))) +} + +func _find_charmap(tls *TLS, name uintptr) (r Tsize_t) { + var s uintptr + _ = s + if !(**(**int8)(__ccgo_up(name)) != 0) { + name = uintptr(unsafe.Pointer(&_charmaps)) + } /* "utf8" */ + s = uintptr(unsafe.Pointer(&_charmaps)) + for { + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + if !(_fuzzycmp(tls, name, s) != 0) { + for { + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + goto _2 + _2: + ; + s = s + uintptr(_strlen(tls, s)+uint64(1)) + } + return Uint64FromInt64(int64(s+uintptr(1)) - t__predefined_ptrdiff_t(uintptr(unsafe.Pointer(&_charmaps)))) + } + s = s + uintptr(_strlen(tls, s)+uint64(1)) + if !(**(**uint8)(__ccgo_up(s)) != 0) { + if Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) > int32(0200) { + s = s + uintptr(2) + } else { + s = s + uintptr(uint32(2)+(uint32(64)-uint32(**(**uint8)(__ccgo_up(s + 1))))*uint32(5)) + } + } + goto _1 + _1: + } + return Uint64FromInt32(-Int32FromInt32(1)) +} + +type Tstateful_cd = struct { + Fbase_cd Ticonv_t + Fstate uint32 +} + +func _combine_to_from(tls *TLS, t Tsize_t, f Tsize_t) (r Ticonv_t) { + return uintptr(f<> int32(16) +} + +func _extract_to(tls *TLS, cd Ticonv_t) (r Tsize_t) { + return uint64(cd) >> int32(1) & uint64(0x7fff) +} + +func Xiconv_open(tls *TLS, to uintptr, from uintptr) (r Ticonv_t) { + if __ccgo_strace { + trc("tls=%v to=%v from=%v, (%v:)", tls, to, from, origin(2)) + defer func() { trc("-> %v", r) }() + } + var cd Ticonv_t + var f, t, v1, v2 Tsize_t + var scd uintptr + var v3 bool + _, _, _, _, _, _, _ = cd, f, scd, t, v1, v2, v3 + v1 = _find_charmap(tls, to) + t = v1 + if v3 = v1 == Uint64FromInt32(-Int32FromInt32(1)); !v3 { + v2 = _find_charmap(tls, from) + f = v2 + } + if v3 || v2 == Uint64FromInt32(-Int32FromInt32(1)) || Int32FromUint8(_charmaps[t]) >= int32(0330) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(-Int32FromInt32(1)) + } + cd = _combine_to_from(tls, t, f) + switch Int32FromUint8(_charmaps[f]) { + case int32(UTF_16): + fallthrough + case int32(UTF_32): + fallthrough + case int32(UCS2): + fallthrough + case int32(ISO2022_JP): + scd = Xmalloc(tls, uint64(16)) + if !(scd != 0) { + return uintptr(-Int32FromInt32(1)) + } + (*Tstateful_cd)(unsafe.Pointer(scd)).Fbase_cd = cd + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(0) + cd = scd + } + return cd +} + +func _get_16(tls *TLS, s uintptr, e int32) (r uint32) { + e = e & int32(1) + return Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(e))))<> int32(8)) + **(**uint8)(__ccgo_up(s + uintptr(int32(1)-e))) = uint8(c) +} + +func _get_32(tls *TLS, s uintptr, e int32) (r uint32) { + e = e & int32(3) + return (uint32(**(**uint8)(__ccgo_up(s + uintptr(e))))+0)<> int32(24)) + **(**uint8)(__ccgo_up(s + uintptr(e^int32(1)))) = uint8(c >> int32(16)) + **(**uint8)(__ccgo_up(s + uintptr(e^int32(2)))) = uint8(c >> int32(8)) + **(**uint8)(__ccgo_up(s + uintptr(e^int32(3)))) = uint8(c) +} + +/* Adapt as needed */ + +func _legacy_map(tls *TLS, map1 uintptr, c uint32) (r uint32) { + var x, v1 uint32 + _, _ = x, v1 + if c < Uint32FromInt32(int32(4)*Int32FromUint8(**(**uint8)(__ccgo_up(map1 + uintptr(-Int32FromInt32(1)))))) { + return c + } + x = c - Uint32FromInt32(int32(4)*Int32FromUint8(**(**uint8)(__ccgo_up(map1 + uintptr(-Int32FromInt32(1)))))) + x = Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(map1 + uintptr(x*uint32(5)/uint32(4)))))>>(uint32(2)*x%uint32(8)) | Int32FromUint8(**(**uint8)(__ccgo_up(map1 + uintptr(x*uint32(5)/uint32(4)+uint32(1)))))<<(uint32(8)-uint32(2)*x%uint32(8))&int32(1023)) + if x < uint32(256) { + v1 = x + } else { + v1 = uint32(_legacy_chars[x-uint32(256)]) + } + return v1 +} + +func _uni_to_jis(tls *TLS, c uint32) (r uint32) { + var b, d, i, j, nel uint32 + _, _, _, _, _ = b, d, i, j, nel + nel = uint32(Uint64FromInt64(13758) / Uint64FromInt64(2)) + b = uint32(0) + for { + i = nel / uint32(2) + j = uint32(_rev_jis[b+i]) + d = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_jis0208)) + uintptr(j/uint32(256))*188 + uintptr(j%uint32(256))*2))) + if d == c { + return j + uint32(0x2121) + } else { + if nel == uint32(1) { + return uint32(0) + } else { + if c < d { + nel = nel / uint32(2) + } else { + b = b + i + nel = nel - nel/uint32(2) + } + } + } + goto _1 + _1: + } + return r +} + +func Xiconv(tls *TLS, cd Ticonv_t, in uintptr, inb uintptr, out uintptr, outb uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v cd=%v in=%v inb=%v out=%v outb=%v, (%v:)", tls, cd, in, inb, out, outb, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var c, d, from, to, v62 uint32 + var err, i, i1, j, j1, v25, v26, v27 int32 + var k, l, tmplen, tmpx, x Tsize_t + var loc Tlocale_t + var map1, ploc, scd, tomap, v54, v55 uintptr + var totype, type1 uint8 + var _ /* ptmp at bp+48 */ uintptr + var _ /* st at bp+24 */ Tmbstate_t + var _ /* tmp at bp+40 */ struct { + Fwc [0][2]Twchar_t + Fc [8]int8 + } + var _ /* tmp at bp+56 */ [4]int8 + var _ /* wc at bp+32 */ Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, d, err, from, i, i1, j, j1, k, l, loc, map1, ploc, scd, tmplen, tmpx, to, tomap, totype, type1, x, v25, v26, v27, v54, v55, v62 + x = uint64(0) + scd = uintptr(0) + if !(uint64(cd)&Uint64FromInt32(1) != 0) { + scd = cd + cd = (*Tstateful_cd)(unsafe.Pointer(scd)).Fbase_cd + } + to = uint32(_extract_to(tls, cd)) + from = uint32(_extract_from(tls, cd)) + map1 = uintptr(unsafe.Pointer(&_charmaps)) + uintptr(from) + uintptr(1) + tomap = uintptr(unsafe.Pointer(&_charmaps)) + uintptr(to) + uintptr(1) + **(**Tmbstate_t)(__ccgo_up(bp + 24)) = Tmbstate_t{} + type1 = **(**uint8)(__ccgo_up(map1 + uintptr(-Int32FromInt32(1)))) + totype = **(**uint8)(__ccgo_up(tomap + uintptr(-Int32FromInt32(1)))) + ploc = uintptr(___get_tp(tls)) + 168 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if !(in != 0) || !(**(**uintptr)(__ccgo_up(in)) != 0) || !(**(**Tsize_t)(__ccgo_up(inb)) != 0) { + return uint64(0) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = uintptr(unsafe.Pointer(&X__c_dot_utf8_locale)) + for { + if !(**(**Tsize_t)(__ccgo_up(inb)) != 0) { + break + } + c = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in))))) + l = uint64(1) + switch Int32FromUint8(type1) { + case int32(UTF_8): + goto _2 + case int32(US_ASCII): + goto _3 + case int32(WCHAR_T): + goto _4 + case int32(UTF_32LE): + goto _5 + case int32(UTF_32BE): + goto _6 + case int32(UTF_16LE): + goto _7 + case int32(UTF_16BE): + goto _8 + case int32(UCS2LE): + goto _9 + case int32(UCS2BE): + goto _10 + case int32(UTF_16): + goto _11 + case int32(UCS2): + goto _12 + case int32(UTF_32): + goto _13 + case int32(SHIFT_JIS): + goto _14 + case int32(EUC_JP): + goto _15 + case int32(ISO2022_JP): + goto _16 + case int32(GB2312): + goto _17 + case int32(GBK): + goto _18 + case int32(GB18030): + goto _19 + case int32(BIG5): + goto _20 + case int32(EUC_KR): + goto _21 + default: + goto _22 + } + goto _23 + _2: + ; + if c < uint32(128) { + goto _23 + } + l = Xmbrtowc(tls, bp+32, **(**uintptr)(__ccgo_up(in)), **(**Tsize_t)(__ccgo_up(inb)), bp+24) + if l == Uint64FromInt32(-Int32FromInt32(1)) { + goto ilseq + } + if l == Uint64FromInt32(-Int32FromInt32(2)) { + goto starved + } + c = Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp + 32))) + goto _23 + _3: + ; + if c >= uint32(128) { + goto ilseq + } + goto _23 + _4: + ; + l = uint64(4) + if **(**Tsize_t)(__ccgo_up(inb)) < l { + goto starved + } + c = Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(in))))) + if !(0 != 0) { + goto _24 + } + _6: + ; + _5: + ; + l = uint64(4) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(4) { + goto starved + } + c = _get_32(tls, **(**uintptr)(__ccgo_up(in)), Int32FromUint8(type1)) + _24: + ; + if c-uint32(0xd800) < uint32(0x800) || c >= uint32(0x110000) { + goto ilseq + } + goto _23 + _10: + ; + _9: + ; + _8: + ; + _7: + ; + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + c = _get_16(tls, **(**uintptr)(__ccgo_up(in)), Int32FromUint8(type1)) + if c-Uint32FromInt32(0xdc00) < uint32(0x400) { + goto ilseq + } + if c-Uint32FromInt32(0xd800) < uint32(0x400) { + if Uint32FromInt32(Int32FromUint8(type1)-int32(UCS2BE)) < uint32(2) { + goto ilseq + } + l = uint64(4) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(4) { + goto starved + } + d = _get_16(tls, **(**uintptr)(__ccgo_up(in))+UintptrFromInt32(2), Int32FromUint8(type1)) + if d-Uint32FromInt32(0xdc00) >= uint32(0x400) { + goto ilseq + } + c = (c-uint32(0xd7c0))< uint32(127) { + d = d - 1 + } + d = d - uint32(64) + } else { + if d-uint32(159) <= Uint32FromInt32(Int32FromInt32(252)-Int32FromInt32(159)) { + c = c + 1 + d = d - uint32(159) + } + } + if c >= uint32(84) { + goto ilseq + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_jis0208)) + uintptr(c)*188 + uintptr(d)*2))) + if !(c != 0) { + goto ilseq + } + goto _23 + _15: + ; + if c < uint32(128) { + goto _23 + } + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + if c == uint32(0x8e) { + c = d + if c-uint32(0xa1) > Uint32FromInt32(Int32FromInt32(0xdf)-Int32FromInt32(0xa1)) { + goto ilseq + } + c = c + Uint32FromInt32(Int32FromInt32(0xff61)-Int32FromInt32(0xa1)) + goto _23 + } + c = c - uint32(0xa1) + d = d - uint32(0xa1) + if c >= uint32(84) || d >= uint32(94) { + goto ilseq + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_jis0208)) + uintptr(c)*188 + uintptr(d)*2))) + if !(c != 0) { + goto ilseq + } + goto _23 + _16: + ; + if c >= uint32(128) { + goto ilseq + } + if c == uint32('\033') { + l = uint64(3) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(3) { + goto starved + } + c = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(2)))) + if c != uint32('(') && c != uint32('$') { + goto ilseq + } + switch Uint32FromInt32(Int32FromInt32(128)*BoolInt32(c == Uint32FromUint8('$'))) + d { + case uint32('B'): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(0) + goto _1 + case uint32('J'): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(1) + goto _1 + case uint32('I'): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(4) + goto _1 + case Uint32FromInt32(Int32FromInt32(128) + Int32FromUint8('@')): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(2) + goto _1 + case Uint32FromInt32(Int32FromInt32(128) + Int32FromUint8('B')): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(3) + goto _1 + } + goto ilseq + } + switch (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate { + case uint32(1): + if c == uint32('\\') { + c = uint32(0xa5) + } + if c == uint32('~') { + c = uint32(0x203e) + } + case uint32(2): + fallthrough + case uint32(3): + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + c = c - uint32(0x21) + d = d - uint32(0x21) + if c >= uint32(84) || d >= uint32(94) { + goto ilseq + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_jis0208)) + uintptr(c)*188 + uintptr(d)*2))) + if !(c != 0) { + goto ilseq + } + case uint32(4): + if c-uint32(0x60) < uint32(0x1f) { + goto ilseq + } + if c-uint32(0x21) < uint32(0x5e) { + c = c + Uint32FromInt32(Int32FromInt32(0xff61)-Int32FromInt32(0x21)) + } + break + } + goto _23 + _17: + ; + if c < uint32(128) { + goto _23 + } + if c < uint32(0xa1) { + goto ilseq + } + _18: + ; + if c == uint32(128) { + c = uint32(0x20ac) + goto _23 + } + _19: + ; + if c < uint32(128) { + goto _23 + } + c = c - uint32(0x81) + if c >= uint32(126) { + goto ilseq + } + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + if d < uint32(0xa1) && Int32FromUint8(type1) == int32(GB2312) { + goto ilseq + } + if d-uint32(0x40) >= uint32(191) || d == uint32(127) { + if d-uint32('0') > uint32(9) || Int32FromUint8(type1) != int32(GB18030) { + goto ilseq + } + l = uint64(4) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(4) { + goto starved + } + c = (uint32(10)*c + d - uint32('0')) * uint32(1260) + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(2)))) + if d-uint32(0x81) > uint32(126) { + goto ilseq + } + c = c + uint32(10)*(d-uint32(0x81)) + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(3)))) + if d-uint32('0') > uint32(9) { + goto ilseq + } + c = c + (d - uint32('0')) + c = c + uint32(128) + d = uint32(0) + for { + if !(d <= c) { + break + } + k = uint64(0) + i = 0 + for { + if !(i < int32(126)) { + break + } + j = 0 + for { + if !(j < int32(190)) { + break + } + if uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_gb18030)) + uintptr(i)*380 + uintptr(j)*2)))-d <= c-d { + k = k + 1 + } + goto _31 + _31: + ; + j = j + 1 + } + goto _30 + _30: + ; + i = i + 1 + } + d = c + uint32(1) + c = uint32(uint64(c) + k) + goto _29 + _29: + } + goto _23 + } + d = d - uint32(0x40) + if d > uint32(63) { + d = d - 1 + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_gb18030)) + uintptr(c)*380 + uintptr(d)*2))) + goto _23 + _20: + ; + if c < uint32(128) { + goto _23 + } + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + if d-uint32(0x40) >= Uint32FromInt32(Int32FromInt32(0xff)-Int32FromInt32(0x40)) || d-uint32(0x7f) < Uint32FromInt32(Int32FromInt32(0xa1)-Int32FromInt32(0x7f)) { + goto ilseq + } + d = d - uint32(0x40) + if d > uint32(0x3e) { + d = d - uint32(0x22) + } + if c-uint32(0xa1) >= Uint32FromInt32(Int32FromInt32(0xfa)-Int32FromInt32(0xa1)) { + if c-uint32(0x87) >= Uint32FromInt32(Int32FromInt32(0xff)-Int32FromInt32(0x87)) { + goto ilseq + } + if c < uint32(0xa1) { + c = c - uint32(0x87) + } else { + c = c - Uint32FromInt32(Int32FromInt32(0x87)+(Int32FromInt32(0xfa)-Int32FromInt32(0xa1))) + } + c = Uint32FromInt32(Int32FromUint16(_hkscs[uint32(4867)+(c*uint32(157)+d)/uint32(16)])>>((c*uint32(157)+d)%uint32(16))%int32(2)< **(**Tsize_t)(__ccgo_up(outb)) { + goto toobig + } + if tmpx != 0 { + x = x + 1 + } + Xmemcpy(tls, **(**uintptr)(__ccgo_up(out)), bp+40, tmplen) + **(**uintptr)(__ccgo_up(out)) += uintptr(tmplen) + **(**Tsize_t)(__ccgo_up(outb)) -= tmplen + goto _1 + } + if !(c != 0) { + goto ilseq + } + goto _23 + } + c = c - uint32(0xa1) + c = Uint32FromInt32(Int32FromUint16(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_big5)) + uintptr(c)*314 + uintptr(d)*2))) | BoolInt32(c == uint32(0x27) && (d == uint32(0x3a) || d == uint32(0x3c) || d == uint32(0x42)))<= uint32(93) || d >= uint32(94) { + c = c + Uint32FromInt32(Int32FromInt32(0xa1)-Int32FromInt32(0x81)) + d = d + uint32(0xa1) + if c >= uint32(93) || c >= Uint32FromInt32(Int32FromInt32(0xc6)-Int32FromInt32(0x81)) && d > uint32(0x52) { + goto ilseq + } + if d-uint32('A') < uint32(26) { + d = d - uint32('A') + } else { + if d-uint32('a') < uint32(26) { + d = d - uint32('a') + uint32(26) + } else { + if d-uint32(0x81) < Uint32FromInt32(Int32FromInt32(0xff)-Int32FromInt32(0x81)) { + d = d - uint32(0x81) + uint32(52) + } else { + goto ilseq + } + } + } + if c < uint32(0x20) { + c = uint32(178)*c + d + } else { + c = Uint32FromInt32(Int32FromInt32(178)*Int32FromInt32(0x20)) + uint32(84)*(c-uint32(0x20)) + d + } + c = c + uint32(0xac00) + d = uint32(0xac00) + for { + if !(d <= c) { + break + } + k = uint64(0) + i1 = 0 + for { + if !(i1 < int32(93)) { + break + } + j1 = 0 + for { + if !(j1 < int32(94)) { + break + } + if uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_ksc)) + uintptr(i1)*188 + uintptr(j1)*2)))-d <= c-d { + k = k + 1 + } + goto _34 + _34: + ; + j1 = j1 + 1 + } + goto _33 + _33: + ; + i1 = i1 + 1 + } + d = c + uint32(1) + c = uint32(uint64(c) + k) + goto _32 + _32: + } + goto _23 + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_ksc)) + uintptr(c)*188 + uintptr(d)*2))) + if !(c != 0) { + goto ilseq + } + goto _23 + _22: + ; + if !(c != 0) { + goto _23 + } + c = _legacy_map(tls, map1, c) + if !(c != 0) { + goto ilseq + } + _23: + ; + switch Int32FromUint8(totype) { + case int32(WCHAR_T): + goto _35 + case int32(UTF_8): + goto _36 + case int32(US_ASCII): + goto _37 + default: + goto _38 + case int32(SHIFT_JIS): + goto _39 + case int32(EUC_JP): + goto _40 + case int32(ISO2022_JP): + goto _41 + case int32(UCS2): + goto _42 + case int32(UTF_16LE): + goto _43 + case int32(UTF_16BE): + goto _44 + case int32(UTF_16): + goto _45 + case int32(UCS2LE): + goto _46 + case int32(UCS2BE): + goto _47 + case int32(UTF_32): + goto _48 + case int32(UTF_32LE): + goto _49 + case int32(UTF_32BE): + goto _50 + } + goto _51 + _35: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(4) { + goto toobig + } + **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(out)))) = Int32FromUint32(c) + **(**uintptr)(__ccgo_up(out)) += uintptr(4) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(4) + goto _51 + _36: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(4) { + k = Uint64FromInt32(Xwctomb(tls, bp+56, Int32FromUint32(c))) + if **(**Tsize_t)(__ccgo_up(outb)) < k { + goto toobig + } + Xmemcpy(tls, **(**uintptr)(__ccgo_up(out)), bp+56, k) + } else { + k = Uint64FromInt32(Xwctomb(tls, **(**uintptr)(__ccgo_up(out)), Int32FromUint32(c))) + } + **(**uintptr)(__ccgo_up(out)) += uintptr(k) + **(**Tsize_t)(__ccgo_up(outb)) -= k + goto _51 + _37: + ; + if !(c > uint32(0x7f)) { + goto _52 + } + goto subst + subst: + ; + x = x + 1 + c = Uint32FromUint8('*') + _52: + ; + _38: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(1) { + goto toobig + } + if !(c < uint32(256) && c == _legacy_map(tls, tomap, c)) { + goto _53 + } + goto revout + revout: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(1) { + goto toobig + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = Int8FromUint32(c) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(1) + goto _51 + _53: + ; + d = c + c = Uint32FromInt32(int32(4) * Int32FromUint8(totype)) + for { + if !(c < uint32(256)) { + break + } + if d == _legacy_map(tls, tomap, c) { + goto revout + } + goto _56 + _56: + ; + c = c + 1 + } + goto subst + _39: + ; + if c < uint32(128) { + goto revout + } + if c == uint32(0xa5) { + x = x + 1 + c = uint32('\\') + goto revout + } + if c == uint32(0x203e) { + x = x + 1 + c = uint32('~') + goto revout + } + if c-uint32(0xff61) <= Uint32FromInt32(Int32FromInt32(0xdf)-Int32FromInt32(0xa1)) { + c = c + Uint32FromInt32(Int32FromInt32(0xa1)-Int32FromInt32(0xff61)) + goto revout + } + c = _uni_to_jis(tls, c) + if !(c != 0) { + goto subst + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(2) { + goto toobig + } + d = c % uint32(256) + c = c / uint32(256) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + if c < uint32(95) { + v25 = int32(112) + } else { + v25 = int32(176) + } + **(**int8)(__ccgo_up(v54)) = Int8FromUint32((c+uint32(1))/uint32(2) + Uint32FromInt32(v25)) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + if c%uint32(2) != 0 { + v62 = d + uint32(31) + d/uint32(96) + } else { + v62 = d + uint32(126) + } + **(**int8)(__ccgo_up(v54)) = Int8FromUint32(v62) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(2) + goto _51 + _40: + ; + if c < uint32(128) { + goto revout + } + if c-uint32(0xff61) <= Uint32FromInt32(Int32FromInt32(0xdf)-Int32FromInt32(0xa1)) { + c = c + Uint32FromInt32(Int32FromInt32(0x0e00)+Int32FromInt32(0x21)-Int32FromInt32(0xff61)) + } else { + c = _uni_to_jis(tls, c) + } + if !(c != 0) { + goto subst + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(2) { + goto toobig + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = Int8FromUint32(c/uint32(256) + uint32(0x80)) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = Int8FromUint32(c%uint32(256) + uint32(0x80)) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(2) + goto _51 + _41: + ; + if c < uint32(128) { + goto revout + } + if c-uint32(0xff61) <= Uint32FromInt32(Int32FromInt32(0xdf)-Int32FromInt32(0xa1)) || c == uint32(0xa5) || c == uint32(0x203e) { + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(7) { + goto toobig + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('\033') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('(') + if c == uint32(0xa5) { + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('J') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('\\') + } else { + if c == uint32(0x203e) { + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('J') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('~') + } else { + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('I') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = Int8FromUint32(c - uint32(0xff61) + uint32(0x21)) + } + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('\033') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('(') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('B') + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(7) + goto _51 + } + c = _uni_to_jis(tls, c) + if !(c != 0) { + goto subst + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(8) { + goto toobig + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('\033') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('$') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('B') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = Int8FromUint32(c / uint32(256)) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = Int8FromUint32(c % uint32(256)) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('\033') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('(') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**int8)(__ccgo_up(v54)) = int8('B') + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(8) + goto _51 + _42: + ; + totype = uint8(UCS2BE) + _47: + ; + _46: + ; + _45: + ; + _44: + ; + _43: + ; + if c < uint32(0x10000) || Uint32FromInt32(Int32FromUint8(totype)-int32(UCS2BE)) < uint32(2) { + if c >= uint32(0x10000) { + c = uint32(0xFFFD) + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(2) { + goto toobig + } + _put_16(tls, **(**uintptr)(__ccgo_up(out)), c, Int32FromUint8(totype)) + **(**uintptr)(__ccgo_up(out)) += uintptr(2) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(2) + goto _51 + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(4) { + goto toobig + } + c = c - uint32(0x10000) + _put_16(tls, **(**uintptr)(__ccgo_up(out)), c>>int32(10)|uint32(0xd800), Int32FromUint8(totype)) + _put_16(tls, **(**uintptr)(__ccgo_up(out))+UintptrFromInt32(2), c&uint32(0x3ff)|uint32(0xdc00), Int32FromUint8(totype)) + **(**uintptr)(__ccgo_up(out)) += uintptr(4) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(4) + goto _51 + _48: + ; + totype = uint8(UTF_32BE) + _50: + ; + _49: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(4) { + goto toobig + } + _put_32(tls, **(**uintptr)(__ccgo_up(out)), c, Int32FromUint8(totype)) + **(**uintptr)(__ccgo_up(out)) += uintptr(4) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(4) + goto _51 + _51: + ; + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(in)) += uintptr(l) + **(**Tsize_t)(__ccgo_up(inb)) -= l + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return x + goto ilseq +ilseq: + ; + err = int32(EILSEQ) + x = Uint64FromInt32(-Int32FromInt32(1)) + goto end + goto toobig +toobig: + ; + err = int32(E2BIG) + x = Uint64FromInt32(-Int32FromInt32(1)) + goto end + goto starved +starved: + ; + err = int32(EINVAL) + x = Uint64FromInt32(-Int32FromInt32(1)) + goto end +end: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = err + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return x +} + +func Xiconv_close(tls *TLS, cd Ticonv_t) (r int32) { + if __ccgo_strace { + trc("tls=%v cd=%v, (%v:)", tls, cd, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(uint64(cd)&Uint64FromInt32(1) != 0) { + Xfree(tls, cd) + } + return 0 +} + +var _c_time = [316]int8{'S', 'u', 'n', 0, 'M', 'o', 'n', 0, 'T', 'u', 'e', 0, 'W', 'e', 'd', 0, 'T', 'h', 'u', 0, 'F', 'r', 'i', 0, 'S', 'a', 't', 0, 'S', 'u', 'n', 'd', 'a', 'y', 0, 'M', 'o', 'n', 'd', 'a', 'y', 0, 'T', 'u', 'e', 's', 'd', 'a', 'y', 0, 'W', 'e', 'd', 'n', 'e', 's', 'd', 'a', 'y', 0, 'T', 'h', 'u', 'r', 's', 'd', 'a', 'y', 0, 'F', 'r', 'i', 'd', 'a', 'y', 0, 'S', 'a', 't', 'u', 'r', 'd', 'a', 'y', 0, 'J', 'a', 'n', 0, 'F', 'e', 'b', 0, 'M', 'a', 'r', 0, 'A', 'p', 'r', 0, 'M', 'a', 'y', 0, 'J', 'u', 'n', 0, 'J', 'u', 'l', 0, 'A', 'u', 'g', 0, 'S', 'e', 'p', 0, 'O', 'c', 't', 0, 'N', 'o', 'v', 0, 'D', 'e', 'c', 0, 'J', 'a', 'n', 'u', 'a', 'r', 'y', 0, 'F', 'e', 'b', 'r', 'u', 'a', 'r', 'y', 0, 'M', 'a', 'r', 'c', 'h', 0, 'A', 'p', 'r', 'i', 'l', 0, 'M', 'a', 'y', 0, 'J', 'u', 'n', 'e', 0, 'J', 'u', 'l', 'y', 0, 'A', 'u', 'g', 'u', 's', 't', 0, 'S', 'e', 'p', 't', 'e', 'm', 'b', 'e', 'r', 0, 'O', 'c', 't', 'o', 'b', 'e', 'r', 0, 'N', 'o', 'v', 'e', 'm', 'b', 'e', 'r', 0, 'D', 'e', 'c', 'e', 'm', 'b', 'e', 'r', 0, 'A', 'M', 0, 'P', 'M', 0, '%', 'a', ' ', '%', 'b', ' ', '%', 'e', ' ', '%', 'T', ' ', '%', 'Y', 0, '%', 'm', '/', '%', 'd', '/', '%', 'y', 0, '%', 'H', ':', '%', 'M', ':', '%', 'S', 0, '%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p', 0, 0, 0, '%', 'm', '/', '%', 'd', '/', '%', 'y', 0, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, '%', 'a', ' ', '%', 'b', ' ', '%', 'e', ' ', '%', 'T', ' ', '%', 'Y', 0, '%', 'H', ':', '%', 'M', ':', '%', 'S'} + +var _c_messages = [19]int8{'^', '[', 'y', 'Y', ']', 0, '^', '[', 'n', 'N', ']', 0, 'y', 'e', 's', 0, 'n', 'o'} +var _c_numeric = [3]int8{'.'} + +func X__nl_langinfo_l(tls *TLS, item Tnl_item, loc Tlocale_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v loc=%v, (%v:)", tls, item, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var cat, idx int32 + var str, v1 uintptr + _, _, _, _ = cat, idx, str, v1 + cat = item >> int32(16) + idx = item & int32(65535) + if item == int32(CODESET) { + if **(**uintptr)(__ccgo_up(loc)) != 0 { + v1 = __ccgo_ts + 388 + } else { + v1 = __ccgo_ts + 533 + } + return v1 + } + /* _NL_LOCALE_NAME extension */ + if idx == int32(65535) && cat < int32(LC_ALL) { + if **(**uintptr)(__ccgo_up(loc + uintptr(cat)*8)) != 0 { + v1 = **(**uintptr)(__ccgo_up(loc + uintptr(cat)*8)) + 16 + } else { + v1 = __ccgo_ts + 539 + } + return v1 + } + switch cat { + case int32(LC_NUMERIC): + if idx > int32(1) { + return __ccgo_ts + } + str = uintptr(unsafe.Pointer(&_c_numeric)) + case int32(LC_TIME): + if idx > int32(0x31) { + return __ccgo_ts + } + str = uintptr(unsafe.Pointer(&_c_time)) + case int32(LC_MONETARY): + if idx > 0 { + return __ccgo_ts + } + str = __ccgo_ts + case int32(LC_MESSAGES): + if idx > int32(3) { + return __ccgo_ts + } + str = uintptr(unsafe.Pointer(&_c_messages)) + default: + return __ccgo_ts + } + for { + if !(idx != 0) { + break + } + for { + if !(**(**int8)(__ccgo_up(str)) != 0) { + break + } + goto _4 + _4: + ; + str = str + 1 + } + goto _3 + _3: + ; + idx = idx - 1 + str = str + 1 + } + if cat != int32(LC_NUMERIC) && **(**int8)(__ccgo_up(str)) != 0 { + str = X__lctrans(tls, str, **(**uintptr)(__ccgo_up(loc + uintptr(cat)*8))) + } + return str +} + +func X__nl_langinfo(tls *TLS, item Tnl_item) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v, (%v:)", tls, item, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__nl_langinfo_l(tls, item, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xnl_langinfo(tls *TLS, item Tnl_item) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v, (%v:)", tls, item, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__nl_langinfo(tls, item) +} + +func Xnl_langinfo_l(tls *TLS, item Tnl_item, loc Tlocale_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v loc=%v, (%v:)", tls, item, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__nl_langinfo_l(tls, item, loc) +} + +func X__lctrans_impl(tls *TLS, msg uintptr, lm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v lm=%v, (%v:)", tls, msg, lm, origin(2)) + defer func() { trc("-> %v", r) }() + } + var trans, v1 uintptr + _, _ = trans, v1 + trans = uintptr(0) + if lm != 0 { + trans = X__mo_lookup(tls, (*t__locale_map)(unsafe.Pointer(lm)).Fmap1, (*t__locale_map)(unsafe.Pointer(lm)).Fmap_size, msg) + } + if trans != 0 { + v1 = trans + } else { + v1 = msg + } + return v1 +} + +var _envvars = [6][12]int8{ + 0: {'L', 'C', '_', 'C', 'T', 'Y', 'P', 'E'}, + 1: {'L', 'C', '_', 'N', 'U', 'M', 'E', 'R', 'I', 'C'}, + 2: {'L', 'C', '_', 'T', 'I', 'M', 'E'}, + 3: {'L', 'C', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E'}, + 4: {'L', 'C', '_', 'M', 'O', 'N', 'E', 'T', 'A', 'R', 'Y'}, + 5: {'L', 'C', '_', 'M', 'E', 'S', 'S', 'A', 'G', 'E', 'S'}, +} + +func X__get_locale(tls *TLS, cat int32, val uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v cat=%v val=%v, (%v:)", tls, cat, val, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(272) + defer tls.Free(272) + var builtin int32 + var l, n Tsize_t + var map1, new1, p, path, z, v1, v2, v4, v6 uintptr + var v3, v5, v7 bool + var _ /* buf at bp+0 */ [256]int8 + var _ /* map_size at bp+256 */ Tsize_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = builtin, l, map1, n, new1, p, path, z, v1, v2, v3, v4, v5, v6, v7 + new1 = uintptr(0) + path = uintptr(0) + if !(**(**int8)(__ccgo_up(val)) != 0) { + v1 = Xgetenv(tls, __ccgo_ts+541) + val = v1 + if v3 = v1 != 0 && **(**int8)(__ccgo_up(val)) != 0; !v3 { + v2 = Xgetenv(tls, uintptr(unsafe.Pointer(&_envvars))+uintptr(cat)*12) + val = v2 + } + if v5 = v3 || v2 != 0 && **(**int8)(__ccgo_up(val)) != 0; !v5 { + v4 = Xgetenv(tls, __ccgo_ts+402) + val = v4 + } + if v7 = v5 || v4 != 0 && **(**int8)(__ccgo_up(val)) != 0; !v7 { + v6 = __ccgo_ts + 548 + val = v6 + } + _ = v7 || v6 != 0 + } + /* Limit name length and forbid leading dot or any slashes. */ + n = uint64(0) + for { + if !(n < uint64(LOCALE_NAME_MAX) && **(**int8)(__ccgo_up(val + uintptr(n))) != 0 && int32(**(**int8)(__ccgo_up(val + uintptr(n)))) != int32('/')) { + break + } + goto _8 + _8: + ; + n = n + 1 + } + if int32(**(**int8)(__ccgo_up(val))) == int32('.') || **(**int8)(__ccgo_up(val + uintptr(n))) != 0 { + val = __ccgo_ts + 548 + } + builtin = BoolInt32(int32(**(**int8)(__ccgo_up(val))) == int32('C') && !(**(**int8)(__ccgo_up(val + 1)) != 0) || !(Xstrcmp(tls, val, __ccgo_ts+548) != 0) || !(Xstrcmp(tls, val, __ccgo_ts+556) != 0)) + if builtin != 0 { + if cat == LC_CTYPE && int32(**(**int8)(__ccgo_up(val + 1))) == int32('.') { + return uintptr(unsafe.Pointer(&X__c_dot_utf8)) + } + return uintptr(0) + } + p = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_loc_head))) + for { + if !(p != 0) { + break + } + if !(Xstrcmp(tls, val, p+16) != 0) { + return p + } + goto _9 + _9: + ; + p = (*t__locale_map)(unsafe.Pointer(p)).Fnext + } + if !(X__libc.Fsecure != 0) { + path = Xgetenv(tls, __ccgo_ts+562) + } + /* FIXME: add a default path? */ + if path != 0 { + for { + if !(**(**int8)(__ccgo_up(path)) != 0) { + break + } + z = X__strchrnul(tls, path, int32(':')) + l = Uint64FromInt64(int64(z) - int64(path)) + if l >= uint64(256)-n-uint64(2) { + goto _10 + } + Xmemcpy(tls, bp, path, l) + (**(**[256]int8)(__ccgo_up(bp)))[l] = int8('/') + Xmemcpy(tls, bp+uintptr(l)+uintptr(1), val, n) + (**(**[256]int8)(__ccgo_up(bp)))[l+uint64(1)+n] = 0 + map1 = X__map_file(tls, bp, bp+256) + if map1 != 0 { + new1 = Xmalloc(tls, uint64(48)) + if !(new1 != 0) { + X__munmap(tls, map1, **(**Tsize_t)(__ccgo_up(bp + 256))) + break + } + (*t__locale_map)(unsafe.Pointer(new1)).Fmap1 = map1 + (*t__locale_map)(unsafe.Pointer(new1)).Fmap_size = **(**Tsize_t)(__ccgo_up(bp + 256)) + Xmemcpy(tls, new1+16, val, n) + **(**int8)(__ccgo_up(new1 + 16 + uintptr(n))) = 0 + (*t__locale_map)(unsafe.Pointer(new1)).Fnext = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_loc_head))) + AtomicStorePUintptr(uintptr(unsafe.Pointer(&_loc_head)), new1) + break + } + goto _10 + _10: + ; + path = z + BoolUintptr(!!(**(**int8)(__ccgo_up(z)) != 0)) + } + } + /* If no locale definition was found, make a locale map + * object anyway to store the name, which is kept for the + * sake of being able to do message translations at the + * application level. */ + if v3 = !(new1 != 0); v3 { + v1 = Xmalloc(tls, uint64(48)) + new1 = v1 + } + if v3 && v1 != 0 { + (*t__locale_map)(unsafe.Pointer(new1)).Fmap1 = X__c_dot_utf8.Fmap1 + (*t__locale_map)(unsafe.Pointer(new1)).Fmap_size = X__c_dot_utf8.Fmap_size + Xmemcpy(tls, new1+16, val, n) + **(**int8)(__ccgo_up(new1 + 16 + uintptr(n))) = 0 + (*t__locale_map)(unsafe.Pointer(new1)).Fnext = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_loc_head))) + AtomicStorePUintptr(uintptr(unsafe.Pointer(&_loc_head)), new1) + } + /* For LC_CTYPE, never return a null pointer unless the + * requested name was "C" or "POSIX". */ + if !(new1 != 0) && cat == LC_CTYPE { + new1 = uintptr(unsafe.Pointer(&X__c_dot_utf8)) + } + return new1 +} + +var _loc_head uintptr + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +var _posix_lconv = Tlconv{ + Fdecimal_point: __ccgo_ts + 575, + Fthousands_sep: __ccgo_ts, + Fgrouping: __ccgo_ts, + Fint_curr_symbol: __ccgo_ts, + Fcurrency_symbol: __ccgo_ts, + Fmon_decimal_point: __ccgo_ts, + Fmon_thousands_sep: __ccgo_ts, + Fmon_grouping: __ccgo_ts, + Fpositive_sign: __ccgo_ts, + Fnegative_sign: __ccgo_ts, + Fint_frac_digits: Int8FromInt32(CHAR_MAX), + Ffrac_digits: Int8FromInt32(CHAR_MAX), + Fp_cs_precedes: Int8FromInt32(CHAR_MAX), + Fp_sep_by_space: Int8FromInt32(CHAR_MAX), + Fn_cs_precedes: Int8FromInt32(CHAR_MAX), + Fn_sep_by_space: Int8FromInt32(CHAR_MAX), + Fp_sign_posn: Int8FromInt32(CHAR_MAX), + Fn_sign_posn: Int8FromInt32(CHAR_MAX), + Fint_p_cs_precedes: Int8FromInt32(CHAR_MAX), + Fint_p_sep_by_space: Int8FromInt32(CHAR_MAX), + Fint_n_cs_precedes: Int8FromInt32(CHAR_MAX), + Fint_n_sep_by_space: Int8FromInt32(CHAR_MAX), + Fint_p_sign_posn: Int8FromInt32(CHAR_MAX), + Fint_n_sign_posn: Int8FromInt32(CHAR_MAX), +} + +func Xlocaleconv(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_posix_lconv)) +} + +var _default_locale_init_done int32 +var _default_locale t__locale_struct +var _default_ctype_locale t__locale_struct + +func X__loc_is_allocated(tls *TLS, loc Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v loc=%v, (%v:)", tls, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(loc != 0 && loc != uintptr(unsafe.Pointer(&X__c_locale)) && loc != uintptr(unsafe.Pointer(&X__c_dot_utf8_locale)) && loc != uintptr(unsafe.Pointer(&_default_locale)) && loc != uintptr(unsafe.Pointer(&_default_ctype_locale))) +} + +func _do_newlocale(tls *TLS, mask int32, name uintptr, loc Tlocale_t) (r Tlocale_t) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, i1 int32 + var v2, v3 uintptr + var v5 Tlocale_t + var _ /* tmp at bp+0 */ t__locale_struct + _, _, _, _, _ = i, i1, v2, v3, v5 + i = 0 + for { + if !(i < int32(LC_ALL)) { + break + } + if !(mask&(Int32FromInt32(1)< %v", r) }() + } + ___lock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + loc = _do_newlocale(tls, mask, name, loc) + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + return loc +} + +func Xnewlocale(tls *TLS, mask int32, name uintptr, loc Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v mask=%v name=%v loc=%v, (%v:)", tls, mask, name, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__newlocale(tls, mask, name, loc) +} + +/* +grammar: + +Start = Expr ';' +Expr = Or | Or '?' Expr ':' Expr +Or = And | Or '||' And +And = Eq | And '&&' Eq +Eq = Rel | Eq '==' Rel | Eq '!=' Rel +Rel = Add | Rel '<=' Add | Rel '>=' Add | Rel '<' Add | Rel '>' Add +Add = Mul | Add '+' Mul | Add '-' Mul +Mul = Prim | Mul '*' Prim | Mul '/' Prim | Mul '%' Prim +Prim = '(' Expr ')' | '!' Prim | decimal | 'n' + +internals: + +recursive descent expression evaluator with stack depth limit. +for binary operators an operator-precedence parser is used. +eval* functions store the result of the parsed subexpression +and return a pointer to the next non-space character. +*/ + +type Tst = struct { + Fr uint64 + Fn uint64 + Fop int32 +} + +func _skipspace(tls *TLS, s uintptr) (r uintptr) { + var v1, v2 int32 + _, _ = v1, v2 + for { + v1 = int32(**(**int8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if !(v2 != 0) { + break + } + s = s + 1 + } + return s +} + +func _evalprim(tls *TLS, st uintptr, s uintptr, d int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 int32 + var _ /* e at bp+0 */ uintptr + _ = v1 + d = d - 1 + v1 = d + if v1 < 0 { + return __ccgo_ts + } + s = _skipspace(tls, s) + if BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0 { + (*Tst)(unsafe.Pointer(st)).Fr = Xstrtoul(tls, s, bp, int32(10)) + if **(**uintptr)(__ccgo_up(bp)) == s || (*Tst)(unsafe.Pointer(st)).Fr == Uint64FromInt32(-Int32FromInt32(1)) { + return __ccgo_ts + } + return _skipspace(tls, **(**uintptr)(__ccgo_up(bp))) + } + if int32(**(**int8)(__ccgo_up(s))) == int32('n') { + (*Tst)(unsafe.Pointer(st)).Fr = (*Tst)(unsafe.Pointer(st)).Fn + return _skipspace(tls, s+uintptr(1)) + } + if int32(**(**int8)(__ccgo_up(s))) == int32('(') { + s = _evalexpr(tls, st, s+uintptr(1), d) + if int32(**(**int8)(__ccgo_up(s))) != int32(')') { + return __ccgo_ts + } + return _skipspace(tls, s+uintptr(1)) + } + if int32(**(**int8)(__ccgo_up(s))) == int32('!') { + s = _evalprim(tls, st, s+uintptr(1), d) + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(!((*Tst)(unsafe.Pointer(st)).Fr != 0)) + return s + } + return __ccgo_ts +} + +func _binop(tls *TLS, st uintptr, op int32, left uint64) (r int32) { + var a, b uint64 + _, _ = a, b + a = left + b = (*Tst)(unsafe.Pointer(st)).Fr + switch op { + case 0: + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a != 0 || b != 0) + return 0 + case int32(1): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a != 0 && b != 0) + return 0 + case int32(2): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a == b) + return 0 + case int32(3): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a != b) + return 0 + case int32(4): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a >= b) + return 0 + case int32(5): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a <= b) + return 0 + case int32(6): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a > b) + return 0 + case int32(7): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a < b) + return 0 + case int32(8): + (*Tst)(unsafe.Pointer(st)).Fr = a + b + return 0 + case int32(9): + (*Tst)(unsafe.Pointer(st)).Fr = a - b + return 0 + case int32(10): + (*Tst)(unsafe.Pointer(st)).Fr = a * b + return 0 + case int32(11): + if b != 0 { + (*Tst)(unsafe.Pointer(st)).Fr = a % b + return 0 + } + return int32(1) + case int32(12): + if b != 0 { + (*Tst)(unsafe.Pointer(st)).Fr = a / b + return 0 + } + return int32(1) + } + return int32(1) +} + +func _parseop(tls *TLS, st uintptr, s uintptr) (r uintptr) { + var i int32 + _ = i + i = 0 + for { + if !(i < int32(11)) { + break + } + if int32(**(**int8)(__ccgo_up(s))) == int32(_opch[i]) { + /* note: >,< are accepted with or without = */ + if i < int32(6) && int32(**(**int8)(__ccgo_up(s + 1))) == int32(_opch2[i]) { + (*Tst)(unsafe.Pointer(st)).Fop = i + return s + uintptr(2) + } + if i >= int32(4) { + (*Tst)(unsafe.Pointer(st)).Fop = i + int32(2) + return s + uintptr(1) + } + break + } + goto _1 + _1: + ; + i = i + 1 + } + (*Tst)(unsafe.Pointer(st)).Fop = int32(13) + return s +} + +var _opch = [11]int8{'|', '&', '=', '!', '>', '<', '+', '-', '*', '%', '/'} + +var _opch2 = [6]int8{'|', '&', '=', '=', '=', '='} + +func _evalbinop(tls *TLS, st uintptr, s uintptr, minprec int32, d int32) (r uintptr) { + var left uint64 + var op int32 + _, _ = left, op + d = d - 1 + s = _evalprim(tls, st, s, d) + s = _parseop(tls, st, s) + for { + /* + st->r (left hand side value) and st->op are now set, + get the right hand side or back out if op has low prec, + if op was missing then prec[op]==0 + */ + op = (*Tst)(unsafe.Pointer(st)).Fop + if int32(_prec[op]) <= minprec { + return s + } + left = (*Tst)(unsafe.Pointer(st)).Fr + s = _evalbinop(tls, st, s, int32(_prec[op]), d) + if _binop(tls, st, op, left) != 0 { + return __ccgo_ts + } + goto _1 + _1: + } + return r +} + +var _prec = [14]int8{ + 0: int8(1), + 1: int8(2), + 2: int8(3), + 3: int8(3), + 4: int8(4), + 5: int8(4), + 6: int8(4), + 7: int8(4), + 8: int8(5), + 9: int8(5), + 10: int8(6), + 11: int8(6), + 12: int8(6), +} + +func _evalexpr(tls *TLS, st uintptr, s uintptr, d int32) (r uintptr) { + var a, b, v2 uint64 + var v1 int32 + _, _, _, _ = a, b, v1, v2 + d = d - 1 + v1 = d + if v1 < 0 { + return __ccgo_ts + } + s = _evalbinop(tls, st, s, 0, d) + if int32(**(**int8)(__ccgo_up(s))) != int32('?') { + return s + } + a = (*Tst)(unsafe.Pointer(st)).Fr + s = _evalexpr(tls, st, s+uintptr(1), d) + if int32(**(**int8)(__ccgo_up(s))) != int32(':') { + return __ccgo_ts + } + b = (*Tst)(unsafe.Pointer(st)).Fr + s = _evalexpr(tls, st, s+uintptr(1), d) + if a != 0 { + v2 = b + } else { + v2 = (*Tst)(unsafe.Pointer(st)).Fr + } + (*Tst)(unsafe.Pointer(st)).Fr = v2 + return s +} + +func X__pleval(tls *TLS, s uintptr, n uint64) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1 uint64 + var _ /* st at bp+0 */ Tst + _ = v1 + (**(**Tst)(__ccgo_up(bp))).Fn = n + s = _evalexpr(tls, bp, s, int32(100)) + if int32(**(**int8)(__ccgo_up(s))) == int32(';') { + v1 = (**(**Tst)(__ccgo_up(bp))).Fr + } else { + v1 = Uint64FromInt32(-Int32FromInt32(1)) + } + return v1 +} + +var _buf1 [144]int8 + +func Xsetlocale(tls *TLS, cat int32, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v cat=%v name=%v, (%v:)", tls, cat, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var i, same int32 + var l Tsize_t + var lm, lm1, p, part1, ret, s, z, v3 uintptr + var _ /* part at bp+48 */ [24]int8 + var _ /* tmp_locale at bp+0 */ t__locale_struct + _, _, _, _, _, _, _, _, _, _, _ = i, l, lm, lm1, p, part1, ret, s, same, z, v3 + if Uint32FromInt32(cat) > uint32(LC_ALL) { + return uintptr(0) + } + ___lock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + /* For LC_ALL, setlocale is required to return a string which + * encodes the current setting for all categories. The format of + * this string is unspecified, and only the following code, which + * performs both the serialization and deserialization, depends + * on the format, so it can easily be changed if needed. */ + if cat == int32(LC_ALL) { + if name != 0 { + **(**[24]int8)(__ccgo_up(bp + 48)) = [24]int8{'C', '.', 'U', 'T', 'F', '-', '8'} + p = name + i = 0 + for { + if !(i < int32(LC_ALL)) { + break + } + z = X__strchrnul(tls, p, int32(';')) + if int64(z)-int64(p) <= int64(LOCALE_NAME_MAX) { + Xmemcpy(tls, bp+48, p, Uint64FromInt64(int64(z)-int64(p))) + (**(**[24]int8)(__ccgo_up(bp + 48)))[int64(z)-int64(p)] = 0 + if **(**int8)(__ccgo_up(z)) != 0 { + p = z + uintptr(1) + } + } + lm = X__get_locale(tls, i, bp+48) + if lm == uintptr(-Int32FromInt32(1)) { + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + return uintptr(0) + } + **(**uintptr)(__ccgo_up(bp + uintptr(i)*8)) = lm + goto _1 + _1: + ; + i = i + 1 + } + X__libc.Fglobal_locale = **(**t__locale_struct)(__ccgo_up(bp)) + } + s = uintptr(unsafe.Pointer(&_buf1)) + same = 0 + i = 0 + for { + if !(i < int32(LC_ALL)) { + break + } + lm1 = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&X__libc)) + 56 + uintptr(i)*8)) + if lm1 == **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&X__libc)) + 56)) { + same = same + 1 + } + if lm1 != 0 { + v3 = lm1 + 16 + } else { + v3 = __ccgo_ts + 539 + } + part1 = v3 + l = _strlen(tls, part1) + Xmemcpy(tls, s, part1, l) + **(**int8)(__ccgo_up(s + uintptr(l))) = int8(';') + s = s + uintptr(l+uint64(1)) + goto _2 + _2: + ; + i = i + 1 + } + s = s - 1 + v3 = s + **(**int8)(__ccgo_up(v3)) = 0 + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + if same == int32(LC_ALL) { + v3 = part1 + } else { + v3 = uintptr(unsafe.Pointer(&_buf1)) + } + return v3 + } + if name != 0 { + lm = X__get_locale(tls, cat, name) + if lm == uintptr(-Int32FromInt32(1)) { + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + return uintptr(0) + } + **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&X__libc)) + 56 + uintptr(cat)*8)) = lm + } else { + lm = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&X__libc)) + 56 + uintptr(cat)*8)) + } + if lm != 0 { + v3 = lm + 16 + } else { + v3 = __ccgo_ts + 539 + } + ret = v3 + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + return ret +} + +func X__strcoll_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v loc=%v, (%v:)", tls, l, r, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xstrcmp(tls, l, r) +} + +func Xstrcoll(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__strcoll_l(tls, l, r, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xstrcoll_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v loc=%v, (%v:)", tls, l, r, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__strcoll_l(tls, l, r, loc) +} + +func _vstrfmon_l(tls *TLS, s uintptr, n Tsize_t, loc Tlocale_t, fmt uintptr, ap Tva_list) (r Tssize_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var fill, fw, intl, left, lp, negpar, nogrp, nosym, rp, w int32 + var l Tsize_t + var s0, v5, v6 uintptr + var x float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = fill, fw, intl, l, left, lp, negpar, nogrp, nosym, rp, s0, w, x, v5, v6 + s0 = s +_3: + ; + if !(n != 0 && **(**int8)(__ccgo_up(fmt)) != 0) { + goto _1 + } + if !(int32(**(**int8)(__ccgo_up(fmt))) != int32('%')) { + goto _4 + } + goto literal +literal: + ; + v5 = s + s = s + 1 + v6 = fmt + fmt = fmt + 1 + **(**int8)(__ccgo_up(v5)) = **(**int8)(__ccgo_up(v6)) + n = n - 1 + goto _2 +_4: + ; + fmt = fmt + 1 + if int32(**(**int8)(__ccgo_up(fmt))) == int32('%') { + goto literal + } + fill = int32(' ') + nogrp = 0 + negpar = 0 + nosym = 0 + left = 0 + for { + switch int32(**(**int8)(__ccgo_up(fmt))) { + case int32('='): + fmt = fmt + 1 + v5 = fmt + fill = int32(**(**int8)(__ccgo_up(v5))) + goto _7 + case int32('^'): + nogrp = int32(1) + goto _7 + case int32('('): + negpar = int32(1) + fallthrough + case int32('+'): + goto _7 + case int32('!'): + nosym = int32(1) + goto _7 + case int32('-'): + left = int32(1) + goto _7 + } + break + goto _7 + _7: + ; + fmt = fmt + 1 + } + fw = 0 + for { + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(fmt)))-uint32('0') < uint32(10)) != 0) { + break + } + fw = int32(10)*fw + (int32(**(**int8)(__ccgo_up(fmt))) - int32('0')) + goto _9 + _9: + ; + fmt = fmt + 1 + } + lp = 0 + rp = int32(2) + if int32(**(**int8)(__ccgo_up(fmt))) == int32('#') { + lp = 0 + fmt = fmt + 1 + for { + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(fmt)))-uint32('0') < uint32(10)) != 0) { + break + } + lp = int32(10)*lp + (int32(**(**int8)(__ccgo_up(fmt))) - int32('0')) + goto _10 + _10: + ; + fmt = fmt + 1 + } + } + if int32(**(**int8)(__ccgo_up(fmt))) == int32('.') { + rp = 0 + fmt = fmt + 1 + for { + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(fmt)))-uint32('0') < uint32(10)) != 0) { + break + } + rp = int32(10)*rp + (int32(**(**int8)(__ccgo_up(fmt))) - int32('0')) + goto _11 + _11: + ; + fmt = fmt + 1 + } + } + v5 = fmt + fmt = fmt + 1 + intl = BoolInt32(int32(**(**int8)(__ccgo_up(v5))) == int32('i')) + w = lp + int32(1) + rp + if !(left != 0) && fw > w { + w = fw + } + x = VaFloat64(&ap) + l = Uint64FromInt32(Xsnprintf(tls, s, n, __ccgo_ts+577, VaList(bp+8, w, rp, x))) + if l >= n { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(E2BIG) + return int64(-int32(1)) + } + s = s + uintptr(l) + n = n - l + goto _2 +_2: + ; + goto _3 + goto _1 +_1: + ; + return int64(s) - int64(s0) +} + +func Xstrfmon_l(tls *TLS, s uintptr, n Tsize_t, loc Tlocale_t, fmt uintptr, va uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v loc=%v fmt=%v va=%v, (%v:)", tls, s, n, loc, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret Tssize_t + _, _ = ap, ret + ap = va + ret = _vstrfmon_l(tls, s, n, loc, fmt, ap) + _ = ap + return ret +} + +func Xstrfmon(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v va=%v, (%v:)", tls, s, n, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret Tssize_t + _, _ = ap, ret + ap = va + ret = _vstrfmon_l(tls, s, n, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale, fmt, ap) + _ = ap + return ret +} + +func Xstrtof_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtof(tls, s, p) +} + +func Xstrtod_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtod(tls, s, p) +} + +func Xstrtold_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtold(tls, s, p) +} + +func X__strtod_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtod_l(tls, s, p, l) +} + +func X__strtof_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtof_l(tls, s, p, l) +} + +func X__strtold_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtold_l(tls, s, p, l) +} + +// C documentation +// +// /* collate only by code points */ +func X__strxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v loc=%v, (%v:)", tls, dest, src, n, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = _strlen(tls, src) + if n > l { + Xstrcpy(tls, dest, src) + } + return l +} + +func Xstrxfrm(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strxfrm_l(tls, dest, src, n, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +// C documentation +// +// /* collate only by code points */ +func Xstrxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v loc=%v, (%v:)", tls, dest, src, n, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strxfrm_l(tls, dest, src, n, loc) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +var _current_domain uintptr + +func X__gettextdomain(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + if _current_domain != 0 { + v1 = _current_domain + } else { + v1 = __ccgo_ts + 431 + } + return v1 +} + +func Xtextdomain(tls *TLS, domainname uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v, (%v:)", tls, domainname, origin(2)) + defer func() { trc("-> %v", r) }() + } + var domlen Tsize_t + _ = domlen + if !(domainname != 0) { + return X__gettextdomain(tls) + } + domlen = _strlen(tls, domainname) + if domlen > uint64(NAME_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + if !(_current_domain != 0) { + _current_domain = Xmalloc(tls, Uint64FromInt32(Int32FromInt32(NAME_MAX)+Int32FromInt32(1))) + if !(_current_domain != 0) { + return uintptr(0) + } + } + Xmemcpy(tls, _current_domain, domainname, domlen+uint64(1)) + return _current_domain +} + +func Xgettext(tls *TLS, msgid uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msgid=%v, (%v:)", tls, msgid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdgettext(tls, uintptr(0), msgid) +} + +func Xngettext(tls *TLS, msgid1 uintptr, msgid2 uintptr, n uint64) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msgid1=%v msgid2=%v n=%v, (%v:)", tls, msgid1, msgid2, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdngettext(tls, uintptr(0), msgid1, msgid2, n) +} + +func X__uselocale(tls *TLS, new1 Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v new1=%v, (%v:)", tls, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var global, old, v1 Tlocale_t + var self Tpthread_t + _, _, _, _ = global, old, self, v1 + self = uintptr(___get_tp(tls)) + old = (*t__pthread)(unsafe.Pointer(self)).Flocale + global = uintptr(unsafe.Pointer(&X__libc)) + 56 + if new1 != 0 { + if new1 == uintptr(-Int32FromInt32(1)) { + v1 = global + } else { + v1 = new1 + } + (*t__pthread)(unsafe.Pointer(self)).Flocale = v1 + } + if old == global { + v1 = uintptr(-Int32FromInt32(1)) + } else { + v1 = old + } + return v1 +} + +func Xuselocale(tls *TLS, new1 Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v new1=%v, (%v:)", tls, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__uselocale(tls, new1) +} + +// C documentation +// +// /* FIXME: stub */ +func X__wcscoll_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v locale=%v, (%v:)", tls, l, r, locale, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xwcscmp(tls, l, r) +} + +func Xwcscoll(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__wcscoll_l(tls, l, r, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +// C documentation +// +// /* FIXME: stub */ +func Xwcscoll_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v locale=%v, (%v:)", tls, l, r, locale, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__wcscoll_l(tls, l, r, locale) +} + +// C documentation +// +// /* collate only by code points */ +func X__wcsxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v loc=%v, (%v:)", tls, dest, src, n, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = Xwcslen(tls, src) + if l < n { + Xwmemcpy(tls, dest, src, l+uint64(1)) + } else { + if n != 0 { + Xwmemcpy(tls, dest, src, n-uint64(1)) + **(**Twchar_t)(__ccgo_up(dest + uintptr(n-uint64(1))*4)) = 0 + } + } + return l +} + +func Xwcsxfrm(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wcsxfrm_l(tls, dest, src, n, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +// C documentation +// +// /* collate only by code points */ +func Xwcsxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v loc=%v, (%v:)", tls, dest, src, n, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wcsxfrm_l(tls, dest, src, n, loc) +} + +func Xreallocarray(tls *TLS, ptr uintptr, m Tsize_t, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ptr=%v m=%v n=%v, (%v:)", tls, ptr, m, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n != 0 && m > Uint64FromInt32(-Int32FromInt32(1))/n { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return uintptr(0) + } + return Xrealloc(tls, ptr, m*n) +} + +const LDBL_EPSILON2 = 0 +const LDBL_MAX2 = 0 +const LDBL_MIN2 = 0 + +var _C1 = float64(0.0416666666666666) /* 0x3FA55555, 0x5555554C */ +var _C2 = -Float64FromFloat64(0.001388888888887411) /* 0xBF56C16C, 0x16C15177 */ +var _C3 = float64(2.480158728947673e-05) /* 0x3EFA01A0, 0x19CB1590 */ +var _C4 = -Float64FromFloat64(2.7557314351390663e-07) /* 0xBE927E4F, 0x809C52AD */ +var _C5 = float64(2.087572321298175e-09) /* 0x3E21EE9E, 0xBDB4B1C4 */ +var _C6 = -Float64FromFloat64(1.1359647557788195e-11) /* 0xBDA8FAE9, 0xBE8838D4 */ + +func X__cos(tls *TLS, x float64, y float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var hz, r, w, z Tdouble_t + _, _, _, _ = hz, r, w, z + z = Tdouble_t(x * x) + w = Tdouble_t(z * z) + r = Tdouble_t(z*(_C1+float64(z*(_C2+float64(z*_C3))))) + Tdouble_t(Tdouble_t(w*w)*(_C4+float64(z*(_C5+float64(z*_C6))))) + hz = Tdouble_t(float64(0.5) * z) + w = float64(1) - hz + return w + (Float64FromFloat64(1) - w - hz + (Tdouble_t(z*r) - Tdouble_t(x*y))) +} + +// C documentation +// +// /* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */ + +var _C0 = -Float64FromFloat64(0.499999997251031) /* -0.499999997251031003120 */ +var _C11 = float64(0.04166662332373906) /* 0.0416666233237390631894 */ +var _C21 = -Float64FromFloat64(0.001388676377460993) /* -0.00138867637746099294692 */ +var _C31 = float64(2.439044879627741e-05) /* 0.0000243904487962774090654 */ + +func X__cosdf(tls *TLS, x float64) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, w, z Tdouble_t + _, _, _ = r, w, z + /* Try to optimize for parallel evaluation as in __tandf.c. */ + z = Tdouble_t(x * x) + w = Tdouble_t(z * z) + r = _C21 + float64(z*_C31) + return float32(float64(1) + float64(z*_C0) + float64(w*_C11) + float64(Tdouble_t(w*z)*r)) +} + +// C documentation +// +// /* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */ +var _k2 = int32(2043) +var _kln22 = float64(1416.0996898839683) + +// C documentation +// +// /* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */ +func X__expo2(tls *TLS, x float64, sign float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v sign=%v, (%v:)", tls, x, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + var scale float64 + var v1 Tuint64_t + _, _ = scale, v1 + /* note that k is odd and scale*scale overflows */ + v1 = uint64(Uint32FromInt32(Int32FromInt32(0x3ff)+_k2/Int32FromInt32(2))< log(FLT_MIN) */ +var _k3 = int32(235) +var _kln23 = Float32FromFloat32(162.88958740234375) + +// C documentation +// +// /* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */ +func X__expo2f(tls *TLS, x float32, sign float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v sign=%v, (%v:)", tls, x, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + var scale float32 + var v1 Tuint32_t + _, _ = scale, v1 + /* note that k is odd and scale*scale overflows */ + v1 = Uint32FromInt32(Int32FromInt32(0x7f)+_k3/Int32FromInt32(2)) << int32(23) + scale = *(*float32)(unsafe.Pointer(&v1)) + /* exp(x - k ln2) * 2**(k-1) */ + /* in directed rounding correct sign before rounding or overflow is important */ + return float32(float32(Xexpf(tls, x-_kln23)*float32(sign*scale)) * scale) +} + +func X__fpclassify(tls *TLS, x float64) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v1 int32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _ = e, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if !(e != 0) { + if *(*Tuint64_t)(unsafe.Pointer(bp))< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v1 int32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _ = e, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + if !(e != 0) { + if *(*Tuint32_t)(unsafe.Pointer(bp))< %v", r) }() + } + return X__fpclassify(tls, x) +} + +const pio2_hi = 0 +const pio2_lo = 0 + +func X__math_divzero(tls *TLS, sign Tuint32_t) (r float64) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + var y, v1, v2 float64 + _, _, _ = y, v1, v2 + if sign != 0 { + v1 = -Float64FromFloat64(1) + } else { + v1 = float64(1) + } + y = v1 + v2 = y + goto _3 +_3: + return v2 / float64(0) +} + +func X__math_divzerof(tls *TLS, sign Tuint32_t) (r float32) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + var y, v1, v2 float32 + _, _, _ = y, v1, v2 + if sign != 0 { + v1 = -Float32FromFloat32(1) + } else { + v1 = Float32FromFloat32(1) + } + y = v1 + v2 = y + goto _3 +_3: + return v2 / Float32FromFloat32(0) +} + +func X__math_invalid(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (x - x) / (x - x) +} + +func X__math_invalidf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (x - x) / (x - x) +} + +func X__math_oflow(tls *TLS, sign Tuint32_t) (r float64) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__math_xflow(tls, sign, float64(3.105036184601418e+231)) +} + +func X__math_oflowf(tls *TLS, sign Tuint32_t) (r float32) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__math_xflowf(tls, sign, Float32FromFloat32(1.5845632502852868e+29)) +} + +func X__math_uflow(tls *TLS, sign Tuint32_t) (r float64) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__math_xflow(tls, sign, float64(1.2882297539194267e-231)) +} + +func X__math_uflowf(tls *TLS, sign Tuint32_t) (r float32) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__math_xflowf(tls, sign, Float32FromFloat32(2.524354896707238e-29)) +} + +func X__math_xflow(tls *TLS, sign Tuint32_t, y2 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v sign=%v y2=%v, (%v:)", tls, sign, y2, origin(2)) + defer func() { trc("-> %v", r) }() + } + var y, y1, v1, v2, v4 float64 + _, _, _, _, _ = y, y1, v1, v2, v4 + if sign != 0 { + v1 = -y2 + } else { + v1 = y2 + } + y1 = v1 + v2 = y1 + goto _3 +_3: + y = float64(v2 * y2) + v4 = y + goto _5 +_5: + return v4 +} + +func X__math_xflowf(tls *TLS, sign Tuint32_t, y2 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v sign=%v y2=%v, (%v:)", tls, sign, y2, origin(2)) + defer func() { trc("-> %v", r) }() + } + var y, y1, v1, v2, v4 float32 + _, _, _, _, _ = y, y1, v1, v2, v4 + if sign != 0 { + v1 = -y2 + } else { + v1 = y2 + } + y1 = v1 + v2 = y1 + goto _3 +_3: + y = float32(v2 * y2) + v4 = y + goto _5 +_5: + return v4 +} + +const DBL_EPSILON1 = 2.220446049250313e-16 +const EPS = 0 + +// C documentation +// +// /* +// * 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) +// */ + +var _toint = Float64FromFloat64(1.5) / Float64FromFloat64(2.220446049250313e-16) +var _pio4 = float64(0.7853981633974483) +var _invpio2 = float64(0.6366197723675814) /* 0x3FE45F30, 0x6DC9C883 */ +var _pio2_1 = float64(1.5707963267341256) /* 0x3FF921FB, 0x54400000 */ +var _pio2_1t = float64(6.077100506506192e-11) /* 0x3DD0B461, 0x1A626331 */ +var _pio2_2 = float64(6.077100506303966e-11) /* 0x3DD0B461, 0x1A600000 */ +var _pio2_2t = float64(2.0222662487959506e-21) /* 0x3BA3198A, 0x2E037073 */ +var _pio2_3 = float64(2.0222662487111665e-21) /* 0x3BA3198A, 0x2E000000 */ +var _pio2_3t = float64(8.4784276603689e-32) /* 0x397B839A, 0x252049C1 */ + +// C documentation +// +// /* caller must handle the case when reduction is not needed: |x| ~<= pi/4 */ +func X__rem_pio2(tls *TLS, x float64, y uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var ex, ey, i, n, sign int32 + var fn, r, t, w, z Tdouble_t + var ix Tuint32_t + var v2 float64 + var _ /* tx at bp+8 */ [3]float64 + var _ /* ty at bp+32 */ [2]float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _ = ex, ey, fn, i, ix, n, r, sign, t, w, z, v2 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if ix <= uint32(0x400f6a7a) { /* |x| ~<= 5pi/4 */ + if ix&uint32(0xfffff) == uint32(0x921fb) { /* |x| ~= pi/2 or 2pi/2 */ + goto medium + } /* cancellation -- use medium case */ + if ix <= uint32(0x4002d97c) { /* |x| ~<= 3pi/4 */ + if !(sign != 0) { + z = x - _pio2_1 /* one round good to 85 bits */ + **(**float64)(__ccgo_up(y)) = z - _pio2_1t + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) - _pio2_1t + return int32(1) + } else { + z = x + _pio2_1 + **(**float64)(__ccgo_up(y)) = z + _pio2_1t + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) + _pio2_1t + return -int32(1) + } + } else { + if !(sign != 0) { + z = x - float64(Float64FromInt32(2)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z - Tdouble_t(Float64FromInt32(2)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) - Tdouble_t(Float64FromInt32(2)*_pio2_1t) + return int32(2) + } else { + z = x + float64(Float64FromInt32(2)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z + Tdouble_t(Float64FromInt32(2)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) + Tdouble_t(Float64FromInt32(2)*_pio2_1t) + return -int32(2) + } + } + } + if ix <= uint32(0x401c463b) { /* |x| ~<= 9pi/4 */ + if ix <= uint32(0x4015fdbc) { /* |x| ~<= 7pi/4 */ + if ix == uint32(0x4012d97c) { /* |x| ~= 3pi/2 */ + goto medium + } + if !(sign != 0) { + z = x - float64(Float64FromInt32(3)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z - Tdouble_t(Float64FromInt32(3)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) - Tdouble_t(Float64FromInt32(3)*_pio2_1t) + return int32(3) + } else { + z = x + float64(Float64FromInt32(3)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z + Tdouble_t(Float64FromInt32(3)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) + Tdouble_t(Float64FromInt32(3)*_pio2_1t) + return -int32(3) + } + } else { + if ix == uint32(0x401921fb) { /* |x| ~= 4pi/2 */ + goto medium + } + if !(sign != 0) { + z = x - float64(Float64FromInt32(4)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z - Tdouble_t(Float64FromInt32(4)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) - Tdouble_t(Float64FromInt32(4)*_pio2_1t) + return int32(4) + } else { + z = x + float64(Float64FromInt32(4)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z + Tdouble_t(Float64FromInt32(4)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) + Tdouble_t(Float64FromInt32(4)*_pio2_1t) + return -int32(4) + } + } + } + if !(ix < uint32(0x413921fb)) { + goto _1 + } /* |x| ~< 2^20*(pi/2), medium size */ + goto medium +medium: + ; + /* rint(x/(pi/2)) */ + fn = Tdouble_t(x*_invpio2) + _toint - _toint + n = int32(fn) + r = x - float64(fn*_pio2_1) + w = Tdouble_t(fn * _pio2_1t) /* 1st round, good to 85 bits */ + /* Matters with directed rounding. */ + if r-w < -_pio4 { + n = n - 1 + fn = fn - 1 + r = x - float64(fn*_pio2_1) + w = Tdouble_t(fn * _pio2_1t) + } else { + if r-w > _pio4 { + n = n + 1 + fn = fn + 1 + r = x - float64(fn*_pio2_1) + w = Tdouble_t(fn * _pio2_1t) + } + } + **(**float64)(__ccgo_up(y)) = r - w + *(*float64)(unsafe.Pointer(bp)) = **(**float64)(__ccgo_up(y)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + ex = Int32FromUint32(ix >> int32(20)) + if ex-ey > int32(16) { /* 2nd round, good to 118 bits */ + t = r + w = Tdouble_t(fn * _pio2_2) + r = t - w + w = Tdouble_t(fn*_pio2_2t) - (t - r - w) + **(**float64)(__ccgo_up(y)) = r - w + *(*float64)(unsafe.Pointer(bp)) = **(**float64)(__ccgo_up(y)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if ex-ey > int32(49) { /* 3rd round, good to 151 bits, covers all cases */ + t = r + w = Tdouble_t(fn * _pio2_3) + r = t - w + w = Tdouble_t(fn*_pio2_3t) - (t - r - w) + **(**float64)(__ccgo_up(y)) = r - w + } + } + **(**float64)(__ccgo_up(y + 1*8)) = r - **(**float64)(__ccgo_up(y)) - w + return n +_1: + ; + /* + * all other (large) arguments + */ + if ix >= uint32(0x7ff00000) { /* x is inf or NaN */ + v2 = x - x + **(**float64)(__ccgo_up(y + 1*8)) = v2 + **(**float64)(__ccgo_up(y)) = v2 + return 0 + } + /* set z = scalbn(|x|,-ilogb(x)+23) */ + *(*float64)(unsafe.Pointer(bp)) = x + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) >> Int32FromInt32(12) + *(*Tuint64_t)(unsafe.Pointer(bp)) |= Uint64FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(23)) << Int32FromInt32(52) + z = *(*float64)(unsafe.Pointer(bp)) + i = 0 + for { + if !(i < int32(2)) { + break + } + (**(**[3]float64)(__ccgo_up(bp + 8)))[i] = float64(int32(z)) + z = Tdouble_t((z - (**(**[3]float64)(__ccgo_up(bp + 8)))[i]) * float64(1.6777216e+07)) + goto _3 + _3: + ; + i = i + 1 + } + (**(**[3]float64)(__ccgo_up(bp + 8)))[i] = z + /* skip zero terms, first term is non-zero */ + for (**(**[3]float64)(__ccgo_up(bp + 8)))[i] == float64(0) { + i = i - 1 + } + n = X__rem_pio2_large(tls, bp+8, bp+32, Int32FromUint32(ix>>Int32FromInt32(20))-(Int32FromInt32(0x3ff)+Int32FromInt32(23)), i+int32(1), int32(1)) + if sign != 0 { + **(**float64)(__ccgo_up(y)) = -(**(**[2]float64)(__ccgo_up(bp + 32)))[0] + **(**float64)(__ccgo_up(y + 1*8)) = -(**(**[2]float64)(__ccgo_up(bp + 32)))[int32(1)] + return -n + } + **(**float64)(__ccgo_up(y)) = (**(**[2]float64)(__ccgo_up(bp + 32)))[0] + **(**float64)(__ccgo_up(y + 1*8)) = (**(**[2]float64)(__ccgo_up(bp + 32)))[int32(1)] + return n +} + +const DBL_EPSILON2 = 0 + +var _init_jk = [4]int32{ + 0: int32(3), + 1: int32(4), + 2: int32(4), + 3: int32(6), +} /* initial value for jk */ + +// C documentation +// +// /* +// * 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. +// */ +var _ipio2 = [66]Tint32_t{ + 0: int32(0xA2F983), + 1: int32(0x6E4E44), + 2: int32(0x1529FC), + 3: int32(0x2757D1), + 4: int32(0xF534DD), + 5: int32(0xC0DB62), + 6: int32(0x95993C), + 7: int32(0x439041), + 8: int32(0xFE5163), + 9: int32(0xABDEBB), + 10: int32(0xC561B7), + 11: int32(0x246E3A), + 12: int32(0x424DD2), + 13: int32(0xE00649), + 14: int32(0x2EEA09), + 15: int32(0xD1921C), + 16: int32(0xFE1DEB), + 17: int32(0x1CB129), + 18: int32(0xA73EE8), + 19: int32(0x8235F5), + 20: int32(0x2EBB44), + 21: int32(0x84E99C), + 22: int32(0x7026B4), + 23: int32(0x5F7E41), + 24: int32(0x3991D6), + 25: int32(0x398353), + 26: int32(0x39F49C), + 27: int32(0x845F8B), + 28: int32(0xBDF928), + 29: int32(0x3B1FF8), + 30: int32(0x97FFDE), + 31: int32(0x05980F), + 32: int32(0xEF2F11), + 33: int32(0x8B5A0A), + 34: int32(0x6D1F6D), + 35: int32(0x367ECF), + 36: int32(0x27CB09), + 37: int32(0xB74F46), + 38: int32(0x3F669E), + 39: int32(0x5FEA2D), + 40: int32(0x7527BA), + 41: int32(0xC7EBE5), + 42: int32(0xF17B3D), + 43: int32(0x0739F7), + 44: int32(0x8A5292), + 45: int32(0xEA6BFB), + 46: int32(0x5FB11F), + 47: int32(0x8D5D08), + 48: int32(0x560330), + 49: int32(0x46FC7B), + 50: int32(0x6BABF0), + 51: int32(0xCFBC20), + 52: int32(0x9AF436), + 53: int32(0x1DA9E3), + 54: int32(0x91615E), + 55: int32(0xE61B08), + 56: int32(0x659985), + 57: int32(0x5F14A0), + 58: int32(0x68408D), + 59: int32(0xFFD880), + 60: int32(0x4D7327), + 61: int32(0x310606), + 62: int32(0x1556CA), + 63: int32(0x73A8C9), + 64: int32(0x60E27B), + 65: int32(0xC08C6B), +} + +var _PIo2 = [8]float64{ + 0: float64(1.570796251296997), + 1: float64(7.549789415861596e-08), + 2: float64(5.390302529957765e-15), + 3: float64(3.282003415807913e-22), + 4: float64(1.270655753080676e-29), + 5: float64(1.2293330898111133e-36), + 6: float64(2.7337005381646456e-44), + 7: float64(2.1674168387780482e-51), +} + +func X__rem_pio2_large(tls *TLS, x uintptr, y uintptr, e0 int32, nx int32, prec int32) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v e0=%v nx=%v prec=%v, (%v:)", tls, x, y, e0, nx, prec, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(240) + defer tls.Free(240) + var carry, i, ih, j, jk, jp, jv, jx, jz, k, m, n, q0 Tint32_t + var f, q [20]float64 + var fw, z, v2 float64 + var _ /* fq at bp+80 */ [20]float64 + var _ /* iq at bp+0 */ [20]Tint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = carry, f, fw, i, ih, j, jk, jp, jv, jx, jz, k, m, n, q, q0, z, v2 + /* initialize jk*/ + jk = _init_jk[prec] + jp = jk + /* determine jx,jv,q0, note that 3>q0 */ + jx = nx - int32(1) + jv = (e0 - int32(3)) / int32(24) + if jv < 0 { + jv = 0 + } + q0 = e0 - int32(24)*(jv+int32(1)) + /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ + j = jv - jx + m = jx + jk + i = 0 + for { + if !(i <= m) { + break + } + if j < 0 { + v2 = float64(0) + } else { + v2 = float64(_ipio2[j]) + } + f[i] = v2 + goto _1 + _1: + ; + i = i + 1 + j = j + 1 + } + /* compute q[0],q[1],...q[jk] */ + i = 0 + for { + if !(i <= jk) { + break + } + j = 0 + fw = Float64FromFloat64(0) + for { + if !(j <= jx) { + break + } + fw = fw + float64(**(**float64)(__ccgo_up(x + uintptr(j)*8))*f[jx+i-j]) + goto _4 + _4: + ; + j = j + 1 + } + q[i] = fw + goto _3 + _3: + ; + i = i + 1 + } + jz = jk + goto recompute +recompute: + ; + /* distill q[] into iq[] reversingly */ + i = 0 + j = jz + z = q[jz] + for { + if !(j > 0) { + break + } + fw = float64(int32(float64(Float64FromFloat64(5.960464477539063e-08) * z))) + (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] = int32(z - float64(Float64FromFloat64(1.6777216e+07)*fw)) + z = q[j-int32(1)] + fw + goto _5 + _5: + ; + i = i + 1 + j = j - 1 + } + /* compute n */ + z = Xscalbn(tls, z, q0) /* actual value of z */ + z = z - float64(float64(8)*Xfloor(tls, float64(z*float64(0.125)))) /* trim off integer >= 8 */ + n = int32(z) + z = z - float64(n) + ih = 0 + if q0 > 0 { /* need iq[jz-1] to determine n */ + i = (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz-int32(1)] >> (int32(24) - q0) + n = n + i + **(**Tint32_t)(__ccgo_up(bp + uintptr(jz-int32(1))*4)) -= i << (int32(24) - q0) + ih = (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz-int32(1)] >> (int32(23) - q0) + } else { + if q0 == 0 { + ih = (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz-int32(1)] >> int32(23) + } else { + if z >= float64(0.5) { + ih = int32(2) + } + } + } + if ih > 0 { /* q > 0.5 */ + n = n + int32(1) + carry = 0 + i = 0 + for { + if !(i < jz) { + break + } /* compute 1-q */ + j = (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] + if carry == 0 { + if j != 0 { + carry = int32(1) + (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] = int32(0x1000000) - j + } + } else { + (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] = int32(0xffffff) - j + } + goto _6 + _6: + ; + i = i + 1 + } + if q0 > 0 { /* rare case: chance is 1 in 12 */ + switch q0 { + case int32(1): + **(**Tint32_t)(__ccgo_up(bp + uintptr(jz-int32(1))*4)) &= int32(0x7fffff) + case int32(2): + **(**Tint32_t)(__ccgo_up(bp + uintptr(jz-int32(1))*4)) &= int32(0x3fffff) + break + } + } + if ih == int32(2) { + z = float64(1) - z + if carry != 0 { + z = z - Xscalbn(tls, float64(1), q0) + } + } + } + /* check if recomputation is needed */ + if z == float64(0) { + j = 0 + i = jz - int32(1) + for { + if !(i >= jk) { + break + } + j = j | (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] + goto _7 + _7: + ; + i = i - 1 + } + if j == 0 { /* need recomputation */ + k = int32(1) + for { + if !((**(**[20]Tint32_t)(__ccgo_up(bp)))[jk-k] == 0) { + break + } + goto _8 + _8: + ; + k = k + 1 + } /* k = no. of terms needed */ + i = jz + int32(1) + for { + if !(i <= jz+k) { + break + } /* add q[jz+1] to q[jz+k] */ + f[jx+i] = float64(_ipio2[jv+i]) + j = 0 + fw = Float64FromFloat64(0) + for { + if !(j <= jx) { + break + } + fw = fw + float64(**(**float64)(__ccgo_up(x + uintptr(j)*8))*f[jx+i-j]) + goto _10 + _10: + ; + j = j + 1 + } + q[i] = fw + goto _9 + _9: + ; + i = i + 1 + } + jz = jz + k + goto recompute + } + } + /* chop off zero terms */ + if z == float64(0) { + jz = jz - int32(1) + q0 = q0 - int32(24) + for (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz] == 0 { + jz = jz - 1 + q0 = q0 - int32(24) + } + } else { /* break z into 24-bit if necessary */ + z = Xscalbn(tls, z, -q0) + if z >= float64(1.6777216e+07) { + fw = float64(int32(float64(Float64FromFloat64(5.960464477539063e-08) * z))) + (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz] = int32(z - float64(Float64FromFloat64(1.6777216e+07)*fw)) + jz = jz + int32(1) + q0 = q0 + int32(24) + (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz] = int32(fw) + } else { + (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz] = int32(z) + } + } + /* convert integer "bit" chunk to floating-point value */ + fw = Xscalbn(tls, float64(1), q0) + i = jz + for { + if !(i >= 0) { + break + } + q[i] = float64(fw * float64((**(**[20]Tint32_t)(__ccgo_up(bp)))[i])) + fw = fw * float64(5.960464477539063e-08) + goto _11 + _11: + ; + i = i - 1 + } + /* compute PIo2[0,...,jp]*q[jz,...,0] */ + i = jz + for { + if !(i >= 0) { + break + } + fw = float64(0) + k = Int32FromInt32(0) + for { + if !(k <= jp && k <= jz-i) { + break + } + fw = fw + float64(_PIo2[k]*q[i+k]) + goto _13 + _13: + ; + k = k + 1 + } + (**(**[20]float64)(__ccgo_up(bp + 80)))[jz-i] = fw + goto _12 + _12: + ; + i = i - 1 + } + /* compress fq[] into y[] */ + switch prec { + case 0: + goto _14 + case int32(2): + goto _15 + case int32(1): + goto _16 + case int32(3): + goto _17 + } + goto _18 +_14: + ; + fw = float64(0) + i = jz + for { + if !(i >= 0) { + break + } + fw = fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + goto _19 + _19: + ; + i = i - 1 + } + if ih == 0 { + v2 = fw + } else { + v2 = -fw + } + **(**float64)(__ccgo_up(y)) = v2 + goto _18 +_16: + ; +_15: + ; + fw = float64(0) + i = jz + for { + if !(i >= 0) { + break + } + fw = fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + goto _21 + _21: + ; + i = i - 1 + } + // TODO: drop excess precision here once double_t is used + fw = fw + if ih == 0 { + v2 = fw + } else { + v2 = -fw + } + **(**float64)(__ccgo_up(y)) = v2 + fw = (**(**[20]float64)(__ccgo_up(bp + 80)))[0] - fw + i = int32(1) + for { + if !(i <= jz) { + break + } + fw = fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + goto _23 + _23: + ; + i = i + 1 + } + if ih == 0 { + v2 = fw + } else { + v2 = -fw + } + **(**float64)(__ccgo_up(y + 1*8)) = v2 + goto _18 +_17: + ; /* painful */ + i = jz +_27: + ; + if !(i > 0) { + goto _25 + } + fw = (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + **(**float64)(__ccgo_up(bp + 80 + uintptr(i)*8)) += (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] - fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] = fw + goto _26 +_26: + ; + i = i - 1 + goto _27 + goto _25 +_25: + ; + i = jz + for { + if !(i > int32(1)) { + break + } + fw = (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + **(**float64)(__ccgo_up(bp + 80 + uintptr(i)*8)) += (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] - fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] = fw + goto _28 + _28: + ; + i = i - 1 + } + fw = float64(0) + i = jz + for { + if !(i >= int32(2)) { + break + } + fw = fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + goto _29 + _29: + ; + i = i - 1 + } + if ih == 0 { + **(**float64)(__ccgo_up(y)) = (**(**[20]float64)(__ccgo_up(bp + 80)))[0] + **(**float64)(__ccgo_up(y + 1*8)) = (**(**[20]float64)(__ccgo_up(bp + 80)))[int32(1)] + **(**float64)(__ccgo_up(y + 2*8)) = fw + } else { + **(**float64)(__ccgo_up(y)) = -(**(**[20]float64)(__ccgo_up(bp + 80)))[0] + **(**float64)(__ccgo_up(y + 1*8)) = -(**(**[20]float64)(__ccgo_up(bp + 80)))[int32(1)] + **(**float64)(__ccgo_up(y + 2*8)) = -fw + } +_18: + ; + return n & int32(7) +} + +const DBL_EPSILON3 = 2.220446049250313e-16 + +// C documentation +// +// /* +// * invpio2: 53 bits of 2/pi +// * pio2_1: first 25 bits of pi/2 +// * pio2_1t: pi/2 - pio2_1 +// */ + +var _toint1 = Float64FromFloat64(1.5) / Float64FromFloat64(2.220446049250313e-16) +var _pio41 = float64(0.7853981852531433) +var _invpio21 = float64(0.6366197723675814) /* 0x3FE45F30, 0x6DC9C883 */ +var _pio2_11 = float64(1.5707963109016418) /* 0x3FF921FB, 0x50000000 */ +var _pio2_1t1 = float64(1.5893254773528196e-08) /* 0x3E5110b4, 0x611A6263 */ + +func X__rem_pio2f(tls *TLS, x float32, y uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var e0, n, sign int32 + var fn Tdouble_t + var ix Tuint32_t + var _ /* tx at bp+8 */ [1]float64 + var _ /* ty at bp+16 */ [1]float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e0, fn, ix, n, sign + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + /* 25+53 bit pi is good enough for medium size */ + if ix < uint32(0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */ + /* Use a specialized rint() to get fn. */ + fn = Tdouble_t(float64(x)*_invpio21) + _toint1 - _toint1 + n = int32(fn) + **(**float64)(__ccgo_up(y)) = float64(x) - Tdouble_t(fn*_pio2_11) - Tdouble_t(fn*_pio2_1t1) + /* Matters with directed rounding. */ + if **(**float64)(__ccgo_up(y)) < -_pio41 { + n = n - 1 + fn = fn - 1 + **(**float64)(__ccgo_up(y)) = float64(x) - Tdouble_t(fn*_pio2_11) - Tdouble_t(fn*_pio2_1t1) + } else { + if **(**float64)(__ccgo_up(y)) > _pio41 { + n = n + 1 + fn = fn + 1 + **(**float64)(__ccgo_up(y)) = float64(x) - Tdouble_t(fn*_pio2_11) - Tdouble_t(fn*_pio2_1t1) + } + } + return n + } + if ix >= uint32(0x7f800000) { /* x is inf or NaN */ + **(**float64)(__ccgo_up(y)) = float64(x - x) + return 0 + } + /* scale x into [2^23, 2^24-1] */ + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + e0 = Int32FromUint32(ix>>Int32FromInt32(23) - Uint32FromInt32(Int32FromInt32(0x7f)+Int32FromInt32(23))) /* e0 = ilogb(|x|)-23, positive */ + *(*Tuint32_t)(unsafe.Pointer(bp)) = ix - Uint32FromInt32(e0< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* y at bp+0 */ struct { + Fi [0]Tuint64_t + Fd float64 + } + *(*struct { + Fi [0]Tuint64_t + Fd float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Fd float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + return Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) +} + +// C documentation +// +// // FIXME: macro in math.h +func X__signbitf(tls *TLS, x float32) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* y at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + return Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) +} + +func X__signbitl(tls *TLS, x float64) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__signbit(tls, x) +} + +var _S1 = -Float64FromFloat64(0.16666666666666632) /* 0xBFC55555, 0x55555549 */ +var _S2 = float64(0.00833333333332249) /* 0x3F811111, 0x1110F8A6 */ +var _S3 = -Float64FromFloat64(0.0001984126982985795) /* 0xBF2A01A0, 0x19C161D5 */ +var _S4 = float64(2.7557313707070068e-06) /* 0x3EC71DE3, 0x57B1FE7D */ +var _S5 = -Float64FromFloat64(2.5050760253406863e-08) /* 0xBE5AE5E6, 0x8A2B9CEB */ +var _S6 = float64(1.58969099521155e-10) /* 0x3DE5D93A, 0x5ACFD57C */ + +func X__sin(tls *TLS, x float64, y float64, iy int32) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v iy=%v, (%v:)", tls, x, y, iy, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v, w, z Tdouble_t + _, _, _, _ = r, v, w, z + z = Tdouble_t(x * x) + w = Tdouble_t(z * z) + r = _S2 + float64(z*(_S3+float64(z*_S4))) + float64(Tdouble_t(z*w)*(_S5+float64(z*_S6))) + v = Tdouble_t(z * x) + if iy == 0 { + return x + float64(v*(_S1+float64(z*r))) + } else { + return x - (Tdouble_t(z*(float64(Float64FromFloat64(0.5)*y)-float64(v*r))) - y - Tdouble_t(v*_S1)) + } + return r1 +} + +// C documentation +// +// /* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */ + +var _S11 = -Float64FromFloat64(0.16666666641626524) /* -0.166666666416265235595 */ +var _S21 = float64(0.008333329385889463) /* 0.0083333293858894631756 */ +var _S31 = -Float64FromFloat64(0.00019839334836096632) /* -0.000198393348360966317347 */ +var _S41 = float64(2.718311493989822e-06) /* 0.0000027183114939898219064 */ + +func X__sindf(tls *TLS, x float64) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, s, w, z Tdouble_t + _, _, _, _ = r, s, w, z + /* Try to optimize for parallel evaluation as in __tandf.c. */ + z = Tdouble_t(x * x) + w = Tdouble_t(z * z) + r = _S31 + float64(z*_S41) + s = Tdouble_t(z * x) + return float32(x + float64(s*(_S11+float64(z*_S21))) + float64(Tdouble_t(s*w)*r)) +} + +var _T = [13]float64{ + 0: float64(0.3333333333333341), + 1: float64(0.13333333333320124), + 2: float64(0.05396825397622605), + 3: float64(0.021869488294859542), + 4: float64(0.0088632398235993), + 5: float64(0.0035920791075913124), + 6: float64(0.0014562094543252903), + 7: float64(0.0005880412408202641), + 8: float64(0.0002464631348184699), + 9: float64(7.817944429395571e-05), + 10: float64(7.140724913826082e-05), + 11: -Float64FromFloat64(1.8558637485527546e-05), + 12: float64(2.590730518636337e-05), +} +var _pio42 = float64(0.7853981633974483) /* 3FE921FB, 54442D18 */ +var _pio4lo = float64(3.061616997868383e-17) /* 3C81A626, 33145C07 */ + +func X__tan(tls *TLS, x float64, y float64, odd int32) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v odd=%v, (%v:)", tls, x, y, odd, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var a, r, s, v, w, z, v1 Tdouble_t + var a0, w0 float64 + var big, sign int32 + var hx Tuint32_t + var v2 Tuint64_t + _, _, _, _, _, _, _, _, _, _, _, _, _ = a, a0, big, hx, r, s, sign, v, w, w0, z, v1, v2 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + big = BoolInt32(hx&uint32(0x7fffffff) >= uint32(0x3FE59428)) /* |x| >= 0.6744 */ + if big != 0 { + sign = Int32FromUint32(hx >> int32(31)) + if sign != 0 { + x = -x + y = -y + } + x = _pio42 - x + (_pio4lo - y) + y = float64(0) + } + z = Tdouble_t(x * x) + w = Tdouble_t(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[int32(1)] + float64(w*(_T[int32(3)]+float64(w*(_T[int32(5)]+float64(w*(_T[int32(7)]+float64(w*(_T[int32(9)]+float64(w*_T[int32(11)]))))))))) + v = Tdouble_t(z * (_T[int32(2)] + float64(w*(_T[int32(4)]+float64(w*(_T[int32(6)]+float64(w*(_T[int32(8)]+float64(w*(_T[int32(10)]+float64(w*_T[int32(12)]))))))))))) + s = Tdouble_t(z * x) + r = y + float64(z*(Tdouble_t(s*(r+v))+y)) + float64(s*_T[0]) + w = x + r + if big != 0 { + s = float64(int32(1) - int32(2)*odd) + v = s - Tdouble_t(float64(2)*(x+(r-Tdouble_t(w*w)/(w+s)))) + if sign != 0 { + v1 = -v + } else { + v1 = v + } + return v1 + } + if !(odd != 0) { + return w + } + /* -1.0/(x+r) has up to 2ulp error, so compute it accurately */ + w0 = w + v2 = *(*Tuint64_t)(unsafe.Pointer(&w0))>>Int32FromInt32(32)<>Int32FromInt32(32)< %v", r1) }() + } + var r, s, t, u, w, z Tdouble_t + var v1 float64 + _, _, _, _, _, _, _ = r, s, t, u, w, z, v1 + z = Tdouble_t(x * x) + /* + * Split up the polynomial into small independent terms to give + * opportunities for parallel evaluation. The chosen splitting is + * micro-optimized for Athlons (XP, X64). It costs 2 multiplications + * relative to Horner's method on sequential machines. + * + * We add the small terms from lowest degree up for efficiency on + * non-sequential machines (the lowest degree terms tend to be ready + * earlier). Apart from this, we don't care about order of + * operations, and don't need to to care since we have precision to + * spare. However, the chosen splitting is good for accuracy too, + * and would give results as accurate as Horner's method if the + * small terms were added from highest degree down. + */ + r = _T1[int32(4)] + float64(z*_T1[int32(5)]) + t = _T1[int32(2)] + float64(z*_T1[int32(3)]) + w = Tdouble_t(z * z) + s = Tdouble_t(z * x) + u = _T1[0] + float64(z*_T1[int32(1)]) + r = x + float64(s*u) + float64(Tdouble_t(s*w)*(t+Tdouble_t(w*r))) + if odd != 0 { + v1 = -Float64FromFloat64(1) / r + } else { + v1 = r + } + return float32(v1) +} + +var _pio2_hi = float64(1.5707963267948966) /* 0x3FF921FB, 0x54442D18 */ +var _pio2_lo = float64(6.123233995736766e-17) /* 0x3C91A626, 0x33145C07 */ +var _pS0 = float64(0.16666666666666666) /* 0x3FC55555, 0x55555555 */ +var _pS1 = -Float64FromFloat64(0.3255658186224009) /* 0xBFD4D612, 0x03EB6F7D */ +var _pS2 = float64(0.20121253213486293) /* 0x3FC9C155, 0x0E884455 */ +var _pS3 = -Float64FromFloat64(0.04005553450067941) /* 0xBFA48228, 0xB5688F3B */ +var _pS4 = float64(0.0007915349942898145) /* 0x3F49EFE0, 0x7501B288 */ +var _pS5 = float64(3.479331075960212e-05) /* 0x3F023DE1, 0x0DFDF709 */ +var _qS1 = -Float64FromFloat64(2.403394911734414) /* 0xC0033A27, 0x1C8A2D4B */ +var _qS2 = float64(2.0209457602335057) /* 0x40002AE5, 0x9C598AC8 */ +var _qS3 = -Float64FromFloat64(0.6882839716054533) /* 0xBFE6066C, 0x1B8D0159 */ +var _qS4 = float64(0.07703815055590194) /* 0x3FB3B8C5, 0xB12E9282 */ + +func _R(tls *TLS, z float64) (r float64) { + var p, q Tdouble_t + _, _ = p, q + p = Tdouble_t(z * (_pS0 + float64(z*(_pS1+float64(z*(_pS2+float64(z*(_pS3+float64(z*(_pS4+float64(z*_pS5))))))))))) + q = float64(1) + float64(z*(_qS1+float64(z*(_qS2+float64(z*(_qS3+float64(z*_qS4))))))) + return p / q +} + +func Xacos(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c, df, s, w, z float64 + var hx, ix, lx Tuint32_t + var v1 Tuint64_t + _, _, _, _, _, _, _, _, _ = c, df, hx, ix, lx, s, w, z, v1 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = hx & uint32(0x7fffffff) + /* |x| >= 1 or nan */ + if ix >= uint32(0x3ff00000) { + lx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x))) + if ix-uint32(0x3ff00000)|lx == uint32(0) { + /* acos(1)=0, acos(-1)=pi */ + if hx>>int32(31) != 0 { + return float64(Float64FromInt32(2)*_pio2_hi) + Float64FromFloat32(7.52316384526264e-37) + } + return Float64FromInt32(0) + } + return Float64FromInt32(0) / (x - x) + } + /* |x| < 0.5 */ + if ix < uint32(0x3fe00000) { + if ix <= uint32(0x3c600000) { /* |x| < 2**-57 */ + return _pio2_hi + Float64FromFloat32(7.52316384526264e-37) + } + return _pio2_hi - (x - (_pio2_lo - float64(x*_R(tls, float64(x*x))))) + } + /* x < -0.5 */ + if hx>>int32(31) != 0 { + z = float64((float64(1) + x) * float64(0.5)) + s = Xsqrt(tls, z) + w = float64(_R(tls, z)*s) - _pio2_lo + return float64(Float64FromInt32(2) * (_pio2_hi - (s + w))) + } + /* x > 0.5 */ + z = float64((float64(1) - x) * float64(0.5)) + s = Xsqrt(tls, z) + df = s + v1 = *(*Tuint64_t)(unsafe.Pointer(&df))>>Int32FromInt32(32)< %v", r) }() + } + var c, df, s, w, z float32 + var hx, ix, v1 Tuint32_t + _, _, _, _, _, _, _, _ = c, df, hx, ix, s, w, z, v1 + hx = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = hx & uint32(0x7fffffff) + /* |x| >= 1 or nan */ + if ix >= uint32(0x3f800000) { + if ix == uint32(0x3f800000) { + if hx>>int32(31) != 0 { + return float32(Float32FromInt32(2)*_pio2_hi1) + Float32FromFloat32(7.52316384526264e-37) + } + return Float32FromInt32(0) + } + return Float32FromInt32(0) / (x - x) + } + /* |x| < 0.5 */ + if ix < uint32(0x3f000000) { + if ix <= uint32(0x32800000) { /* |x| < 2**-26 */ + return _pio2_hi1 + Float32FromFloat32(7.52316384526264e-37) + } + return _pio2_hi1 - (x - (_pio2_lo1 - float32(x*_R1(tls, float32(x*x))))) + } + /* x < -0.5 */ + if hx>>int32(31) != 0 { + z = float32((Float32FromInt32(1) + x) * Float32FromFloat32(0.5)) + s = Xsqrtf(tls, z) + w = float32(_R1(tls, z)*s) - _pio2_lo1 + return float32(Float32FromInt32(2) * (_pio2_hi1 - (s + w))) + } + /* x > 0.5 */ + z = float32((Float32FromInt32(1) - x) * Float32FromFloat32(0.5)) + s = Xsqrtf(tls, z) + hx = *(*Tuint32_t)(unsafe.Pointer(&s)) + v1 = hx & uint32(0xfffff000) + df = *(*float32)(unsafe.Pointer(&v1)) + c = (z - float32(df*df)) / (s + df) + w = float32(_R1(tls, z)*s) + c + return float32(Float32FromInt32(2) * (df + w)) +} + +// C documentation +// +// /* acosh(x) = log(x + sqrt(x*x-1)) */ +func Xacosh(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e uint32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = e + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + e = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + /* x < 1 domain error is handled in the called functions */ + if e < Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(1)) { + /* |x| < 2, up to 2ulp error in [1,1.125] */ + return Xlog1p(tls, x-Float64FromInt32(1)+Xsqrt(tls, float64((x-Float64FromInt32(1))*(x-Float64FromInt32(1)))+float64(Float64FromInt32(2)*(x-Float64FromInt32(1))))) + } + if e < Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(26)) { + /* |x| < 0x1p26 */ + return Xlog(tls, float64(Float64FromInt32(2)*x)-Float64FromInt32(1)/(x+Xsqrt(tls, float64(x*x)-Float64FromInt32(1)))) + } + /* |x| >= 0x1p26 or nan */ + return Xlog(tls, x) + float64(0.6931471805599453) +} + +// C documentation +// +// /* acosh(x) = log(x + sqrt(x*x-1)) */ +func Xacoshf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var a Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _ = a + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + a = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + if a < Uint32FromInt32(Int32FromInt32(0x3f800000)+Int32FromInt32(1)<= 0x1p12 or x <= -2 or nan */ + return Xlogf(tls, x) + Float32FromFloat32(0.6931471805599453) +} + +func Xacoshl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xacosh(tls, x) +} + +func Xacosl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xacos(tls, x) +} + +var _pio2_hi2 = float64(1.5707963267948966) /* 0x3FF921FB, 0x54442D18 */ +var _pio2_lo2 = float64(6.123233995736766e-17) /* 0x3C91A626, 0x33145C07 */ +/* coefficients for R(x^2) */ +var _pS02 = float64(0.16666666666666666) /* 0x3FC55555, 0x55555555 */ +var _pS12 = -Float64FromFloat64(0.3255658186224009) /* 0xBFD4D612, 0x03EB6F7D */ +var _pS22 = float64(0.20121253213486293) /* 0x3FC9C155, 0x0E884455 */ +var _pS31 = -Float64FromFloat64(0.04005553450067941) /* 0xBFA48228, 0xB5688F3B */ +var _pS41 = float64(0.0007915349942898145) /* 0x3F49EFE0, 0x7501B288 */ +var _pS51 = float64(3.479331075960212e-05) /* 0x3F023DE1, 0x0DFDF709 */ +var _qS12 = -Float64FromFloat64(2.403394911734414) /* 0xC0033A27, 0x1C8A2D4B */ +var _qS21 = float64(2.0209457602335057) /* 0x40002AE5, 0x9C598AC8 */ +var _qS31 = -Float64FromFloat64(0.6882839716054533) /* 0xBFE6066C, 0x1B8D0159 */ +var _qS41 = float64(0.07703815055590194) /* 0x3FB3B8C5, 0xB12E9282 */ + +func _R2(tls *TLS, z float64) (r float64) { + var p, q Tdouble_t + _, _ = p, q + p = Tdouble_t(z * (_pS02 + float64(z*(_pS12+float64(z*(_pS22+float64(z*(_pS31+float64(z*(_pS41+float64(z*_pS51))))))))))) + q = float64(1) + float64(z*(_qS12+float64(z*(_qS21+float64(z*(_qS31+float64(z*_qS41))))))) + return p / q +} + +func Xasin(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var c, f, r, s, z float64 + var hx, ix, lx Tuint32_t + var v1 Tuint64_t + _, _, _, _, _, _, _, _, _ = c, f, hx, ix, lx, r, s, z, v1 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = hx & uint32(0x7fffffff) + /* |x| >= 1 or nan */ + if ix >= uint32(0x3ff00000) { + lx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x))) + if ix-uint32(0x3ff00000)|lx == uint32(0) { + /* asin(1) = +-pi/2 with inexact */ + return float64(x*_pio2_hi2) + Float64FromFloat32(7.52316384526264e-37) + } + return Float64FromInt32(0) / (x - x) + } + /* |x| < 0.5 */ + if ix < uint32(0x3fe00000) { + /* if 0x1p-1022 <= |x| < 0x1p-26, avoid raising underflow */ + if ix < uint32(0x3e500000) && ix >= uint32(0x00100000) { + return x + } + return x + float64(x*_R2(tls, float64(x*x))) + } + /* 1 > |x| >= 0.5 */ + z = float64((Float64FromInt32(1) - Xfabs(tls, x)) * float64(0.5)) + s = Xsqrt(tls, z) + r = _R2(tls, z) + if ix >= uint32(0x3fef3333) { /* if |x| > 0.975 */ + x = _pio2_hi2 - (float64(Float64FromInt32(2)*(s+float64(s*r))) - _pio2_lo2) + } else { + /* f+c = sqrt(z) */ + f = s + v1 = *(*Tuint64_t)(unsafe.Pointer(&f))>>Int32FromInt32(32)<>int32(31) != 0 { + return -x + } + return x +} + +var _pio2 = float64(1.5707963267948966) + +/* coefficients for R(x^2) */ +var _pS03 = float32(0.16666586697) +var _pS13 = float32(-Float64FromFloat64(0.042743422091)) +var _pS23 = float32(-Float64FromFloat64(0.008656363003)) +var _qS13 = float32(-Float64FromFloat64(0.7066296339)) + +func _R3(tls *TLS, z float32) (r float32) { + var p, q Tfloat_t + _, _ = p, q + p = Tfloat_t(z * (_pS03 + float32(z*(_pS13+float32(z*_pS23))))) + q = Float32FromFloat32(1) + float32(z*_qS13) + return p / q +} + +func Xasinf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var hx, ix Tuint32_t + var s float64 + var z float32 + _, _, _, _ = hx, ix, s, z + hx = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = hx & uint32(0x7fffffff) + if ix >= uint32(0x3f800000) { /* |x| >= 1 */ + if ix == uint32(0x3f800000) { /* |x| == 1 */ + return float32(float64(float64(x)*_pio2) + Float64FromFloat32(7.52316384526264e-37)) + } /* asin(+-1) = +-pi/2 with inexact */ + return Float32FromInt32(0) / (x - x) /* asin(|x|>1) is NaN */ + } + if ix < uint32(0x3f000000) { /* |x| < 0.5 */ + /* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */ + if ix < uint32(0x39800000) && ix >= uint32(0x00800000) { + return x + } + return x + float32(x*_R3(tls, float32(x*x))) + } + /* 1 > |x| >= 0.5 */ + z = float32((Float32FromInt32(1) - Xfabsf(tls, x)) * Float32FromFloat32(0.5)) + s = Xsqrt(tls, float64(z)) + x = float32(_pio2 - float64(Float64FromInt32(2)*(s+float64(s*float64(_R3(tls, z)))))) + if hx>>int32(31) != 0 { + return -x + } + return x +} + +// C documentation +// +// /* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ +func Xasinh(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s uint32 + var y float32 + var y1, y2, v1 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = e, s, y, y1, y2, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + s = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + /* |x| */ + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + x3 = *(*float64)(unsafe.Pointer(bp)) + if e >= Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(26)) { + /* |x| >= 0x1p26 or inf or nan */ + x3 = Xlog(tls, x3) + float64(0.6931471805599453) + } else { + if e >= Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(1)) { + /* |x| >= 2 */ + x3 = Xlog(tls, float64(Float64FromInt32(2)*x3)+Float64FromInt32(1)/(Xsqrt(tls, float64(x3*x3)+Float64FromInt32(1))+x3)) + } else { + if e >= Uint32FromInt32(Int32FromInt32(0x3ff)-Int32FromInt32(26)) { + /* |x| >= 0x1p-26, up to 1.6ulp error in [0.125,0.5] */ + x3 = Xlog1p(tls, x3+float64(x3*x3)/(Xsqrt(tls, float64(x3*x3)+Float64FromInt32(1))+Float64FromInt32(1))) + } else { + /* |x| < 0x1p-26, raise inexact if x != 0 */ + if uint64(8) == uint64(4) { + y = float32(x3 + Float64FromFloat32(1.329227995784916e+36)) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } else { + y2 = float64(x3 + Float64FromFloat32(1.329227995784916e+36)) + } + } + } + } + } + if s != 0 { + v1 = -x3 + } else { + v1 = x3 + } + return v1 +} + +// C documentation +// +// /* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ +func Xasinhf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i Tuint32_t + var s uint32 + var y, v1 float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _ = i, s, y, y1, y2, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + i = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + s = *(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31) + /* |x| */ + *(*Tuint32_t)(unsafe.Pointer(bp)) = i + x3 = *(*float32)(unsafe.Pointer(bp)) + if i >= Uint32FromInt32(Int32FromInt32(0x3f800000)+Int32FromInt32(12)<= 0x1p12 or inf or nan */ + x3 = Xlogf(tls, x3) + Float32FromFloat32(0.6931471805599453) + } else { + if i >= Uint32FromInt32(Int32FromInt32(0x3f800000)+Int32FromInt32(1)<= 2 */ + x3 = Xlogf(tls, float32(Float32FromInt32(2)*x3)+Float32FromInt32(1)/(Xsqrtf(tls, float32(x3*x3)+Float32FromInt32(1))+x3)) + } else { + if i >= Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(12)<= 0x1p-12, up to 1.6ulp error in [0.125,0.5] */ + x3 = Xlog1pf(tls, x3+float32(x3*x3)/(Xsqrtf(tls, float32(x3*x3)+Float32FromInt32(1))+Float32FromInt32(1))) + } else { + /* |x| < 0x1p-12, raise inexact if x!=0 */ + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + } + } + } + if s != 0 { + v1 = -x3 + } else { + v1 = x3 + } + return v1 +} + +func Xasinhl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xasinh(tls, x) +} + +func Xasinl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xasin(tls, x) +} + +var _atanhi = [4]float64{ + 0: float64(0.4636476090008061), + 1: float64(0.7853981633974483), + 2: float64(0.982793723247329), + 3: float64(1.5707963267948966), +} + +var _atanlo = [4]float64{ + 0: float64(2.2698777452961687e-17), + 1: float64(3.061616997868383e-17), + 2: float64(1.3903311031230998e-17), + 3: float64(6.123233995736766e-17), +} + +var _aT = [11]float64{ + 0: float64(0.3333333333333293), + 1: -Float64FromFloat64(0.19999999999876483), + 2: float64(0.14285714272503466), + 3: -Float64FromFloat64(0.11111110405462356), + 4: float64(0.09090887133436507), + 5: -Float64FromFloat64(0.0769187620504483), + 6: float64(0.06661073137387531), + 7: -Float64FromFloat64(0.058335701337905735), + 8: float64(0.049768779946159324), + 9: -Float64FromFloat64(0.036531572744216916), + 10: float64(0.016285820115365782), +} + +func Xatan(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var id int32 + var ix, sign Tuint32_t + var s1, s2, w, z, v3 Tdouble_t + var y float32 + var y1, y2 float64 + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _, _, _, _, _, _ = id, ix, s1, s2, sign, w, y, y1, y2, z, v1, v3 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x44100000) { /* if |x| >= 2^66 */ + *(*float64)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 + _2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var __u1, __u2 Tuint64_t + var ix, iy, lx, ly, m Tuint32_t + var z, v6 float64 + var v1, v3 uint64 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _, _, _, _, _, _ = __u1, __u2, ix, iy, lx, ly, m, z, v1, v3, v5, v6 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<> int32(32)) + lx = uint32(__u1) + __u2 = *(*Tuint64_t)(unsafe.Pointer(&y)) + iy = uint32(__u2 >> int32(32)) + ly = uint32(__u2) + if ix-uint32(0x3ff00000)|lx == uint32(0) { /* x = 1.0 */ + return Xatan(tls, y) + } + m = iy>>Int32FromInt32(31)&uint32(1) | ix>>Int32FromInt32(30)&uint32(2) /* 2*sign(x)+sign(y) */ + ix = ix & uint32(0x7fffffff) + iy = iy & uint32(0x7fffffff) + /* when y = 0 */ + if iy|ly == uint32(0) { + switch m { + case uint32(0): + fallthrough + case uint32(1): + return y /* atan(+-0,+anything)=+-0 */ + case uint32(2): + return _pi /* atan(+0,-anything) = pi */ + case uint32(3): + return -_pi /* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if ix|lx == uint32(0) { + if m&uint32(1) != 0 { + v6 = -_pi / Float64FromInt32(2) + } else { + v6 = _pi / Float64FromInt32(2) + } + return v6 + } + /* when x is INF */ + if ix == uint32(0x7ff00000) { + if iy == uint32(0x7ff00000) { + switch m { + case uint32(0): + return _pi / Float64FromInt32(4) /* atan(+INF,+INF) */ + case uint32(1): + return -_pi / Float64FromInt32(4) /* atan(-INF,+INF) */ + case uint32(2): + return float64(Float64FromInt32(3)*_pi) / Float64FromInt32(4) /* atan(+INF,-INF) */ + case uint32(3): + return float64(float64(-Int32FromInt32(3))*_pi) / Float64FromInt32(4) /* atan(-INF,-INF) */ + } + } else { + switch m { + case uint32(0): + return float64(0) /* atan(+...,+INF) */ + case uint32(1): + return -Float64FromFloat64(0) /* atan(-...,+INF) */ + case uint32(2): + return _pi /* atan(+...,-INF) */ + case uint32(3): + return -_pi /* atan(-...,-INF) */ + } + } + } + /* |y/x| > 0x1p64 */ + if ix+Uint32FromInt32(Int32FromInt32(64)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix, iy, m Tuint32_t + var z, v6 float32 + var v1, v3 uint32 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _, _, _ = ix, iy, m, z, v1, v3, v5, v6 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0; !v5 { + *(*float32)(unsafe.Pointer(bp)) = y + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + y + } + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + iy = *(*Tuint32_t)(unsafe.Pointer(&y)) + if ix == uint32(0x3f800000) { /* x=1.0 */ + return Xatanf(tls, y) + } + m = iy>>Int32FromInt32(31)&uint32(1) | ix>>Int32FromInt32(30)&uint32(2) /* 2*sign(x)+sign(y) */ + ix = ix & uint32(0x7fffffff) + iy = iy & uint32(0x7fffffff) + /* when y = 0 */ + if iy == uint32(0) { + switch m { + case uint32(0): + fallthrough + case uint32(1): + return y /* atan(+-0,+anything)=+-0 */ + case uint32(2): + return _pi1 /* atan(+0,-anything) = pi */ + case uint32(3): + return -_pi1 /* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if ix == uint32(0) { + if m&uint32(1) != 0 { + v6 = -_pi1 / Float32FromInt32(2) + } else { + v6 = _pi1 / Float32FromInt32(2) + } + return v6 + } + /* when x is INF */ + if ix == uint32(0x7f800000) { + if iy == uint32(0x7f800000) { + switch m { + case uint32(0): + return _pi1 / Float32FromInt32(4) /* atan(+INF,+INF) */ + case uint32(1): + return -_pi1 / Float32FromInt32(4) /* atan(-INF,+INF) */ + case uint32(2): + return float32(Float32FromInt32(3)*_pi1) / Float32FromInt32(4) /*atan(+INF,-INF)*/ + case uint32(3): + return float32(float32(-Int32FromInt32(3))*_pi1) / Float32FromInt32(4) /*atan(-INF,-INF)*/ + } + } else { + switch m { + case uint32(0): + return Float32FromFloat32(0) /* atan(+...,+INF) */ + case uint32(1): + return -Float32FromFloat32(0) /* atan(-...,+INF) */ + case uint32(2): + return _pi1 /* atan(+...,-INF) */ + case uint32(3): + return -_pi1 /* atan(-...,-INF) */ + } + } + } + /* |y/x| > 0x1p26 */ + if ix+Uint32FromInt32(Int32FromInt32(26)< %v", r) }() + } + return Xatan2(tls, y, x) +} + +var _atanhi1 = [4]float32{ + 0: float32(0.46364760399), + 1: float32(0.78539812565), + 2: float32(0.98279368877), + 3: float32(1.5707962513), +} + +var _atanlo1 = [4]float32{ + 0: float32(5.012158244e-09), + 1: float32(3.7748947079e-08), + 2: float32(3.447321717e-08), + 3: float32(7.5497894159e-08), +} + +var _aT1 = [5]float32{ + 0: float32(0.33333328366), + 1: float32(-Float64FromFloat64(0.19999158382)), + 2: float32(0.14253635705), + 3: float32(-Float64FromFloat64(0.10648017377)), + 4: float32(0.061687607318), +} + +func Xatanf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var id int32 + var ix, sign Tuint32_t + var s1, s2, w, z, v3 Tfloat_t + var y float32 + var y1, y2 float64 + var v1 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _, _, _, _, _, _, _ = id, ix, s1, s2, sign, w, y, y1, y2, z, v1, v3 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x4c800000) { /* if |x| >= 2**26 */ + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 + _2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x3 + } + z = _atanhi1[int32(3)] + Float32FromFloat32(7.52316384526264e-37) + if sign != 0 { + v3 = -z + } else { + v3 = z + } + return v3 + } + if ix < uint32(0x3ee00000) { /* |x| < 0.4375 */ + if ix < uint32(0x39800000) { /* |x| < 2**-12 */ + if ix < uint32(0x00800000) { + /* raise underflow for subnormal x */ + if uint64(4) == uint64(4) { + y = float32(x3 * x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 * x3) + } else { + y2 = float64(x3 * x3) + } + } + } + return x3 + } + id = -int32(1) + } else { + x3 = Xfabsf(tls, x3) + if ix < uint32(0x3f980000) { /* |x| < 1.1875 */ + if ix < uint32(0x3f300000) { /* 7/16 <= |x| < 11/16 */ + id = 0 + x3 = (float32(Float32FromFloat32(2)*x3) - Float32FromFloat32(1)) / (Float32FromFloat32(2) + x3) + } else { /* 11/16 <= |x| < 19/16 */ + id = int32(1) + x3 = (x3 - Float32FromFloat32(1)) / (x3 + Float32FromFloat32(1)) + } + } else { + if ix < uint32(0x401c0000) { /* |x| < 2.4375 */ + id = int32(2) + x3 = (x3 - Float32FromFloat32(1.5)) / (Float32FromFloat32(1) + float32(Float32FromFloat32(1.5)*x3)) + } else { /* 2.4375 <= |x| < 2**26 */ + id = int32(3) + x3 = -Float32FromFloat32(1) / x3 + } + } + } + /* end of argument reduction */ + z = Tfloat_t(x3 * x3) + w = Tfloat_t(z * z) + /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ + s1 = Tfloat_t(z * (_aT1[0] + float32(w*(_aT1[int32(2)]+float32(w*_aT1[int32(4)]))))) + s2 = Tfloat_t(w * (_aT1[int32(1)] + float32(w*_aT1[int32(3)]))) + if id < 0 { + return x3 - float32(x3*(s1+s2)) + } + z = _atanhi1[id] - (float32(x3*(s1+s2)) - _atanlo1[id] - x3) + if sign != 0 { + v3 = -z + } else { + v3 = z + } + return v3 +} + +// C documentation +// +// /* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ +func Xatanh(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s uint32 + var y float32 + var y1, y2 float64 + var y3, v1 Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _ = e, s, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + s = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + /* |x| */ + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + y3 = *(*float64)(unsafe.Pointer(bp)) + if e < Uint32FromInt32(Int32FromInt32(0x3ff)-Int32FromInt32(1)) { + if e < Uint32FromInt32(Int32FromInt32(0x3ff)-Int32FromInt32(32)) { + /* handle underflow */ + if e == uint32(0) { + if uint64(4) == uint64(4) { + y = float32(y3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(y3)) + } else { + y2 = float64(float32(y3)) + } + } + } + } else { + /* |x| < 0.5, up to 1.7ulp error */ + y3 = Tdouble_t(float64(0.5) * Xlog1p(tls, Tdouble_t(Float64FromInt32(2)*y3)+Tdouble_t(Tdouble_t(Float64FromInt32(2)*y3)*y3)/(Float64FromInt32(1)-y3))) + } + } else { + /* avoid overflow */ + y3 = Tdouble_t(float64(0.5) * Xlog1p(tls, float64(Float64FromInt32(2)*(y3/(Float64FromInt32(1)-y3))))) + } + if s != 0 { + v1 = -y3 + } else { + v1 = y3 + } + return v1 +} + +// C documentation +// +// /* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ +func Xatanhf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var s uint32 + var y float32 + var y1, y2 float64 + var y3, v1 Tfloat_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _ = s, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + s = *(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31) + /* |x| */ + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + y3 = *(*float32)(unsafe.Pointer(bp)) + if *(*Tuint32_t)(unsafe.Pointer(bp)) < Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(1)< %v", r) }() + } + return Xatanh(tls, x) +} + +func Xatanl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xatan(tls, x) +} + +var _B1 = uint32(715094163) /* B1 = (1023-1023/3-0.03306235651)*2**20 */ +var _B2 = uint32(696219795) /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */ + +// C documentation +// +// /* |1/cbrt(x) - p(x)| < 2**-23.5 (~[-7.93e-8, 7.929e-8]). */ + +var _P0 = float64(1.87595182427177) /* 0x3ffe03e6, 0x0f61e692 */ +var _P1 = -Float64FromFloat64(1.8849797954337717) /* 0xbffe28e0, 0x92f02420 */ +var _P2 = float64(1.6214297201053545) /* 0x3ff9f160, 0x4a49d6c2 */ +var _P3 = -Float64FromFloat64(0.758397934778766) /* 0xbfe844cb, 0xbee751d9 */ +var _P4 = float64(0.14599619288661245) /* 0x3fc2b000, 0xd4e4edd7 */ + +func Xcbrt(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var hx Tuint32_t + var r, s, t, w Tdouble_t + var v1 uintptr + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = hx, r, s, t, w, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if hx >= uint32(0x7ff00000) { /* cbrt(NaN,INF) is itself */ + return x + x + } + /* + * Rough cbrt to 5 bits: + * cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3) + * where e is integral and >= 0, m is real and in [0, 1), and "/" and + * "%" are integer division and modulus with rounding towards minus + * infinity. The RHS is always >= the LHS and has a maximum relative + * error of about 1 in 16. Adding a bias of -0.03306235651 to the + * (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE + * floating point representation, for finite positive normal values, + * ordinary integer divison of the value in bits magically gives + * almost exactly the RHS of the above provided we first subtract the + * exponent bias (1023 for doubles) and later add it back. We do the + * subtraction virtually to keep e >= 0 so that ordinary integer + * division rounds towards minus infinity; this is also efficient. + */ + if hx < uint32(0x00100000) { /* zero or subnormal? */ + *(*float64)(unsafe.Pointer(bp)) = float64(x * float64(1.8014398509481984e+16)) + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if hx == uint32(0) { + return x + } /* cbrt(0) is itself */ + hx = hx/uint32(3) + _B2 + } else { + hx = hx/uint32(3) + _B1 + } + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (Uint64FromUint64(1) << Int32FromInt32(63))) + *(*Tuint64_t)(unsafe.Pointer(bp)) |= uint64(hx) << int32(32) + t = *(*float64)(unsafe.Pointer(bp)) + /* + * New cbrt to 23 bits: + * cbrt(x) = t*cbrt(x/t**3) ~= t*P(t**3/x) + * where P(r) is a polynomial of degree 4 that approximates 1/cbrt(r) + * to within 2**-23.5 when |r - 1| < 1/10. The rough approximation + * has produced t such than |t/cbrt(x) - 1| ~< 1/32, and cubing this + * gives us bounds for r = t**3/x. + * + * Try to optimize for parallel evaluation as in __tanf.c. + */ + r = Tdouble_t(Tdouble_t(t*t) * (t / x)) + t = Tdouble_t(t * (_P0 + float64(r*(_P1+float64(r*_P2))) + float64(Tdouble_t(Tdouble_t(r*r)*r)*(_P3+float64(r*_P4))))) + /* + * Round t away from zero to 23 bits (sloppily except for ensuring that + * the result is larger in magnitude than cbrt(x) but not much more than + * 2 23-bit ulps larger). With rounding towards zero, the error bound + * would be ~5/6 instead of ~4/6. With a maximum error of 2 23-bit ulps + * in the rounded t, the infinite-precision error in the Newton + * approximation barely affects third digit in the final error + * 0.667; the error in the rounded t can be up to about 3 23-bit ulps + * before the final error is larger than 0.667 ulps. + */ + *(*float64)(unsafe.Pointer(bp)) = t + *(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(*(*Tuint64_t)(unsafe.Pointer(bp))+Uint64FromUint32(0x80000000)) & uint64(0xffffffffc0000000) + t = *(*float64)(unsafe.Pointer(bp)) + /* one step Newton iteration to 53 bits with error < 0.667 ulps */ + s = Tdouble_t(t * t) /* t*t is exact */ + r = x / s /* error <= 0.5 ulps; |r| < |t| */ + w = t + t /* t+t is exact */ + r = (r - t) / (w + r) /* r-t is exact; w+r ~= 3*t */ + t = t + Tdouble_t(t*r) /* error <= 0.5 + 0.5/3 + epsilon */ + return t +} + +var _B11 = uint32(709958130) /* B1 = (127-127.0/3-0.03306235651)*2**23 */ +var _B21 = uint32(642849266) /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */ + +func Xcbrtf(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var T, r Tdouble_t + var hx Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _ = T, hx, r + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + if hx >= uint32(0x7f800000) { /* cbrt(NaN,INF) is itself */ + return x + x + } + /* rough cbrt to 5 bits */ + if hx < uint32(0x00800000) { /* zero or subnormal? */ + if hx == uint32(0) { + return x + } /* cbrt(+-0) is itself */ + *(*float32)(unsafe.Pointer(bp)) = float32(x * Float32FromFloat32(1.6777216e+07)) + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + hx = hx/uint32(3) + _B21 + } else { + hx = hx/uint32(3) + _B11 + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x80000000) + *(*Tuint32_t)(unsafe.Pointer(bp)) |= hx + /* + * First step Newton iteration (solving t*t-x/t == 0) to 16 bits. In + * double precision so that its terms can be arranged for efficiency + * without causing overflow or underflow. + */ + T = float64(*(*float32)(unsafe.Pointer(bp))) + r = Tdouble_t(Tdouble_t(T*T) * T) + T = Tdouble_t(T*(float64(x)+float64(x)+r)) / (float64(x) + r + r) + /* + * Second step Newton iteration to 47 bits. In double precision for + * efficiency and accuracy. + */ + r = Tdouble_t(Tdouble_t(T*T) * T) + T = Tdouble_t(T*(float64(x)+float64(x)+r)) / (float64(x) + r + r) + /* rounding to 24 bits is perfect in round-to-nearest mode */ + return float32(T) +} + +func Xcbrtl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcbrt(tls, x) +} + +const DBL_EPSILON5 = 2.220446049250313e-16 + +var _toint2 = Float64FromInt32(1) / Float64FromFloat64(2.220446049250313e-16) + +func Xceil(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var y float32 + var y1, y2, v1 float64 + var y3 Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = e, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if e >= Int32FromInt32(0x3ff)+Int32FromInt32(52) || x3 == Float64FromInt32(0) { + return x3 + } + /* y = int(x) - x, where int(x) is an integer neighbor of x */ + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + y3 = x3 - _toint2 + _toint2 - x3 + } else { + y3 = x3 + _toint2 - _toint2 - x3 + } + /* special case because of non-nearest rounding modes */ + if e <= Int32FromInt32(0x3ff)-Int32FromInt32(1) { + if uint64(8) == uint64(4) { + y = float32(y3) + } else { + if uint64(8) == uint64(8) { + y1 = y3 + } else { + y2 = y3 + } + } + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + v1 = -Float64FromFloat64(0) + } else { + v1 = Float64FromInt32(1) + } + return v1 + } + if y3 < Float64FromInt32(0) { + return x3 + y3 + Float64FromInt32(1) + } + return x3 + y3 +} + +const DBL_EPSILON6 = 0 + +func Xceilf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var m Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e, m, y, y1, y2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp))>>Int32FromInt32(23)&Uint32FromInt32(0xff)) - int32(0x7f) + if e >= int32(23) { + return x3 + } + if e >= 0 { + m = Uint32FromInt32(int32(0x007fffff) >> e) + if *(*Tuint32_t)(unsafe.Pointer(bp))&m == uint32(0) { + return x3 + } + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) == uint32(0) { + *(*Tuint32_t)(unsafe.Pointer(bp)) += m + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= ^m + } else { + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + *(*float32)(unsafe.Pointer(bp)) = float32(-Float64FromFloat64(0)) + } else { + if *(*Tuint32_t)(unsafe.Pointer(bp))< %v", r) }() + } + return Xceil(tls, x) +} + +func Xcopysign(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uintptr + var _ /* ux at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = y + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (-Uint64FromUint64(1) / Uint64FromInt32(2))) + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) | *(*Tuint64_t)(unsafe.Pointer(bp + 8))&(Uint64FromUint64(1)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ux at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = y + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + *(*Tuint32_t)(unsafe.Pointer(bp)) |= *(*Tuint32_t)(unsafe.Pointer(bp + 4)) & uint32(0x80000000) + return *(*float32)(unsafe.Pointer(bp)) +} + +func Xcopysignl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcopysign(tls, x, y) +} + +func Xcos(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n uint32 + var y float32 + var y1, y2 float64 + var _ /* y at bp+0 */ [2]float64 + _, _, _, _, _ = ix, n, y, y1, y2 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* |x| ~< pi/4 */ + if ix <= uint32(0x3fe921fb) { + if ix < uint32(0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */ + /* raise inexact if x!=0 */ + if uint64(8) == uint64(4) { + y = float32(x3 + Float64FromFloat32(1.329227995784916e+36)) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } else { + y2 = float64(x3 + Float64FromFloat32(1.329227995784916e+36)) + } + } + return float64(1) + } + return X__cos(tls, x3, Float64FromInt32(0)) + } + /* cos(Inf or NaN) is NaN */ + if ix >= uint32(0x7ff00000) { + return x3 - x3 + } + /* argument reduction */ + n = Uint32FromInt32(X__rem_pio2(tls, x3, bp)) + switch n & Uint32FromInt32(3) { + case uint32(0): + return X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + case uint32(1): + return -X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + case uint32(2): + return -X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + default: + return X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + } + return r +} + +const M_PI_23 = 1.5707963267948966 + +// C documentation +// +// /* Small multiples of pi/2 rounded to double precision. */ + +var _c1pio2 = float64(Float64FromInt32(1) * Float64FromFloat64(1.5707963267948966)) /* 0x3FF921FB, 0x54442D18 */ +var _c2pio2 = float64(Float64FromInt32(2) * Float64FromFloat64(1.5707963267948966)) /* 0x400921FB, 0x54442D18 */ +var _c3pio2 = float64(Float64FromInt32(3) * Float64FromFloat64(1.5707963267948966)) /* 0x4012D97C, 0x7F3321D2 */ +var _c4pio2 = float64(Float64FromInt32(4) * Float64FromFloat64(1.5707963267948966)) /* 0x401921FB, 0x54442D18 */ + +func Xcosf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n, sign uint32 + var y float32 + var y1, y2, v1 float64 + var _ /* y at bp+0 */ float64 + _, _, _, _, _, _, _ = ix, n, sign, y, y1, y2, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + if ix <= uint32(0x3f490fda) { /* |x| ~<= pi/4 */ + if ix < uint32(0x39800000) { /* |x| < 2**-12 */ + /* raise inexact if x != 0 */ + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + return Float32FromFloat32(1) + } + return X__cosdf(tls, float64(x3)) + } + if ix <= uint32(0x407b53d1) { /* |x| ~<= 5*pi/4 */ + if ix > uint32(0x4016cbe3) { /* |x| ~> 3*pi/4 */ + if sign != 0 { + v1 = float64(x3) + _c2pio2 + } else { + v1 = float64(x3) - _c2pio2 + } + return -X__cosdf(tls, v1) + } else { + if sign != 0 { + return X__sindf(tls, float64(x3)+_c1pio2) + } else { + return X__sindf(tls, _c1pio2-float64(x3)) + } + } + } + if ix <= uint32(0x40e231d5) { /* |x| ~<= 9*pi/4 */ + if ix > uint32(0x40afeddf) { /* |x| ~> 7*pi/4 */ + if sign != 0 { + v1 = float64(x3) + _c4pio2 + } else { + v1 = float64(x3) - _c4pio2 + } + return X__cosdf(tls, v1) + } else { + if sign != 0 { + return X__sindf(tls, float64(-x3)-_c3pio2) + } else { + return X__sindf(tls, float64(x3)-_c3pio2) + } + } + } + /* cos(Inf or NaN) is NaN */ + if ix >= uint32(0x7f800000) { + return x3 - x3 + } + /* general argument reduction needed */ + n = Uint32FromInt32(X__rem_pio2f(tls, x3, bp)) + switch n & Uint32FromInt32(3) { + case uint32(0): + return X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + case uint32(1): + return X__sindf(tls, -**(**float64)(__ccgo_up(bp))) + case uint32(2): + return -X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + default: + return X__sindf(tls, **(**float64)(__ccgo_up(bp))) + } + return r +} + +const M_PI_24 = 0 + +// C documentation +// +// /* 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) +// */ +func Xcosh(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var t, y1, y2 float64 + var w Tuint32_t + var y float32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _ = t, w, y, y1, y2 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + /* |x| */ + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + x3 = *(*float64)(unsafe.Pointer(bp)) + w = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + /* |x| < log(2) */ + if w < uint32(0x3fe62e42) { + if w < Uint32FromInt32(Int32FromInt32(0x3ff00000)-Int32FromInt32(26)<log(0x1p26) then the 1/t is not needed */ + return float64(float64(0.5) * (t + Float64FromInt32(1)/t)) + } + /* |x| > log(DBL_MAX) or nan */ + /* note: the result is stored to handle overflow */ + t = X__expo2(tls, x3, float64(1)) + return t +} + +func Xcoshf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var t, y float32 + var w Tuint32_t + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = t, w, y, y1, y2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + /* |x| */ + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + x3 = *(*float32)(unsafe.Pointer(bp)) + w = *(*Tuint32_t)(unsafe.Pointer(bp)) + /* |x| < log(2) */ + if w < uint32(0x3f317217) { + if w < Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(12)< log(FLT_MAX) or nan */ + t = X__expo2f(tls, x3, Float32FromFloat32(1)) + return t +} + +func Xcoshl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcosh(tls, x) +} + +func Xcosl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcos(tls, x) +} + +var _erx = float64(0.8450629115104675) /* 0x3FEB0AC1, 0x60000000 */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +var _efx8 = float64(1.0270333367641007) /* 0x3FF06EBA, 0x8214DB69 */ +var _pp0 = float64(0.12837916709551256) /* 0x3FC06EBA, 0x8214DB68 */ +var _pp1 = -Float64FromFloat64(0.3250421072470015) /* 0xBFD4CD7D, 0x691CB913 */ +var _pp2 = -Float64FromFloat64(0.02848174957559851) /* 0xBF9D2A51, 0xDBD7194F */ +var _pp3 = -Float64FromFloat64(0.005770270296489442) /* 0xBF77A291, 0x236668E4 */ +var _pp4 = -Float64FromFloat64(2.3763016656650163e-05) /* 0xBEF8EAD6, 0x120016AC */ +var _qq1 = float64(0.39791722395915535) /* 0x3FD97779, 0xCDDADC09 */ +var _qq2 = float64(0.0650222499887673) /* 0x3FB0A54C, 0x5536CEBA */ +var _qq3 = float64(0.005081306281875766) /* 0x3F74D022, 0xC4D36B0F */ +var _qq4 = float64(0.00013249473800432164) /* 0x3F215DC9, 0x221C1A10 */ +var _qq5 = -Float64FromFloat64(3.960228278775368e-06) /* 0xBED09C43, 0x42A26120 */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +var _pa0 = -Float64FromFloat64(0.0023621185607526594) /* 0xBF6359B8, 0xBEF77538 */ +var _pa1 = float64(0.41485611868374833) /* 0x3FDA8D00, 0xAD92B34D */ +var _pa2 = -Float64FromFloat64(0.3722078760357013) /* 0xBFD7D240, 0xFBB8C3F1 */ +var _pa3 = float64(0.31834661990116175) /* 0x3FD45FCA, 0x805120E4 */ +var _pa4 = -Float64FromFloat64(0.11089469428239668) /* 0xBFBC6398, 0x3D3E28EC */ +var _pa5 = float64(0.035478304325618236) /* 0x3FA22A36, 0x599795EB */ +var _pa6 = -Float64FromFloat64(0.002166375594868791) /* 0xBF61BF38, 0x0A96073F */ +var _qa1 = float64(0.10642088040084423) /* 0x3FBB3E66, 0x18EEE323 */ +var _qa2 = float64(0.540397917702171) /* 0x3FE14AF0, 0x92EB6F33 */ +var _qa3 = float64(0.07182865441419627) /* 0x3FB2635C, 0xD99FE9A7 */ +var _qa4 = float64(0.12617121980876164) /* 0x3FC02660, 0xE763351F */ +var _qa5 = float64(0.01363708391202905) /* 0x3F8BEDC2, 0x6B51DD1C */ +var _qa6 = float64(0.011984499846799107) /* 0x3F888B54, 0x5735151D */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +var _ra0 = -Float64FromFloat64(0.009864944034847148) /* 0xBF843412, 0x600D6435 */ +var _ra1 = -Float64FromFloat64(0.6938585727071818) /* 0xBFE63416, 0xE4BA7360 */ +var _ra2 = -Float64FromFloat64(10.558626225323291) /* 0xC0251E04, 0x41B0E726 */ +var _ra3 = -Float64FromFloat64(62.375332450326006) /* 0xC04F300A, 0xE4CBA38D */ +var _ra4 = -Float64FromFloat64(162.39666946257347) /* 0xC0644CB1, 0x84282266 */ +var _ra5 = -Float64FromFloat64(184.60509290671104) /* 0xC067135C, 0xEBCCABB2 */ +var _ra6 = -Float64FromFloat64(81.2874355063066) /* 0xC0545265, 0x57E4D2F2 */ +var _ra7 = -Float64FromFloat64(9.814329344169145) /* 0xC023A0EF, 0xC69AC25C */ +var _sa1 = float64(19.651271667439257) /* 0x4033A6B9, 0xBD707687 */ +var _sa2 = float64(137.65775414351904) /* 0x4061350C, 0x526AE721 */ +var _sa3 = float64(434.56587747522923) /* 0x407B290D, 0xD58A1A71 */ +var _sa4 = float64(645.3872717332679) /* 0x40842B19, 0x21EC2868 */ +var _sa5 = float64(429.00814002756783) /* 0x407AD021, 0x57700314 */ +var _sa6 = float64(108.63500554177944) /* 0x405B28A3, 0xEE48AE2C */ +var _sa7 = float64(6.570249770319282) /* 0x401A47EF, 0x8E484A93 */ +var _sa8 = -Float64FromFloat64(0.0604244152148581) /* 0xBFAEEFF2, 0xEE749A62 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +var _rb0 = -Float64FromFloat64(0.0098649429247001) /* 0xBF843412, 0x39E86F4A */ +var _rb1 = -Float64FromFloat64(0.799283237680523) /* 0xBFE993BA, 0x70C285DE */ +var _rb2 = -Float64FromFloat64(17.757954917754752) /* 0xC031C209, 0x555F995A */ +var _rb3 = -Float64FromFloat64(160.63638485582192) /* 0xC064145D, 0x43C5ED98 */ +var _rb4 = -Float64FromFloat64(637.5664433683896) /* 0xC083EC88, 0x1375F228 */ +var _rb5 = -Float64FromFloat64(1025.0951316110772) /* 0xC0900461, 0x6A2E5992 */ +var _rb6 = -Float64FromFloat64(483.5191916086514) /* 0xC07E384E, 0x9BDC383F */ +var _sb1 = float64(30.33806074348246) /* 0x403E568B, 0x261D5190 */ +var _sb2 = float64(325.7925129965739) /* 0x40745CAE, 0x221B9F0A */ +var _sb3 = float64(1536.729586084437) /* 0x409802EB, 0x189D5118 */ +var _sb4 = float64(3199.8582195085955) /* 0x40A8FFB7, 0x688C246A */ +var _sb5 = float64(2553.0504064331644) /* 0x40A3F219, 0xCEDF3BE6 */ +var _sb6 = float64(474.52854120695537) /* 0x407DA874, 0xE79FE763 */ +var _sb7 = -Float64FromFloat64(22.44095244658582) /* 0xC03670E2, 0x42712D62 */ + +func _erfc1(tls *TLS, x float64) (r float64) { + var P, Q, s Tdouble_t + _, _, _ = P, Q, s + s = Xfabs(tls, x) - Float64FromInt32(1) + P = _pa0 + float64(s*(_pa1+float64(s*(_pa2+float64(s*(_pa3+float64(s*(_pa4+float64(s*(_pa5+float64(s*_pa6))))))))))) + Q = Float64FromInt32(1) + Tdouble_t(s*(_qa1+float64(s*(_qa2+float64(s*(_qa3+float64(s*(_qa4+float64(s*(_qa5+float64(s*_qa6))))))))))) + return Float64FromInt32(1) - _erx - P/Q +} + +func _erfc2(tls *TLS, ix Tuint32_t, x float64) (r float64) { + var R, S, s Tdouble_t + var z float64 + var v1 Tuint64_t + _, _, _, _, _ = R, S, s, z, v1 + if ix < uint32(0x3ff40000) { /* |x| < 1.25 */ + return _erfc1(tls, x) + } + x = Xfabs(tls, x) + s = Float64FromInt32(1) / float64(x*x) + if ix < uint32(0x4006db6d) { /* |x| < 1/.35 ~ 2.85714 */ + R = _ra0 + float64(s*(_ra1+float64(s*(_ra2+float64(s*(_ra3+float64(s*(_ra4+float64(s*(_ra5+float64(s*(_ra6+float64(s*_ra7))))))))))))) + S = float64(1) + float64(s*(_sa1+float64(s*(_sa2+float64(s*(_sa3+float64(s*(_sa4+float64(s*(_sa5+float64(s*(_sa6+float64(s*(_sa7+float64(s*_sa8))))))))))))))) + } else { /* |x| > 1/.35 */ + R = _rb0 + float64(s*(_rb1+float64(s*(_rb2+float64(s*(_rb3+float64(s*(_rb4+float64(s*(_rb5+float64(s*_rb6))))))))))) + S = float64(1) + float64(s*(_sb1+float64(s*(_sb2+float64(s*(_sb3+float64(s*(_sb4+float64(s*(_sb5+float64(s*(_sb6+float64(s*_sb7))))))))))))) + } + z = x + v1 = *(*Tuint64_t)(unsafe.Pointer(&z))>>Int32FromInt32(32)< %v", r1) }() + } + var ix Tuint32_t + var r, s, y, z, v1 float64 + var sign int32 + _, _, _, _, _, _, _ = ix, r, s, sign, y, z, v1 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7ff00000) { + /* erf(nan)=nan, erf(+-inf)=+-1 */ + return float64(int32(1)-int32(2)*sign) + Float64FromInt32(1)/x + } + if ix < uint32(0x3feb0000) { /* |x| < 0.84375 */ + if ix < uint32(0x3e300000) { /* |x| < 2**-28 */ + /* avoid underflow */ + return float64(float64(0.125) * (float64(Float64FromInt32(8)*x) + float64(_efx8*x))) + } + z = float64(x * x) + r = _pp0 + float64(z*(_pp1+float64(z*(_pp2+float64(z*(_pp3+float64(z*_pp4))))))) + s = float64(1) + float64(z*(_qq1+float64(z*(_qq2+float64(z*(_qq3+float64(z*(_qq4+float64(z*_qq5))))))))) + y = r / s + return x + float64(x*y) + } + if ix < uint32(0x40180000) { /* 0.84375 <= |x| < 6 */ + y = Float64FromInt32(1) - _erfc2(tls, ix, x) + } else { + y = Float64FromInt32(1) - Float64FromFloat64(2.2250738585072014e-308) + } + if sign != 0 { + v1 = -y + } else { + v1 = y + } + return v1 +} + +func Xerfc(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, y, z, v1 float64 + var sign int32 + _, _, _, _, _, _, _ = ix, r, s, sign, y, z, v1 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7ff00000) { + /* erfc(nan)=nan, erfc(+-inf)=0,2 */ + return float64(int32(2)*sign) + Float64FromInt32(1)/x + } + if ix < uint32(0x3feb0000) { /* |x| < 0.84375 */ + if ix < uint32(0x3c700000) { /* |x| < 2**-56 */ + return float64(1) - x + } + z = float64(x * x) + r = _pp0 + float64(z*(_pp1+float64(z*(_pp2+float64(z*(_pp3+float64(z*_pp4))))))) + s = float64(1) + float64(z*(_qq1+float64(z*(_qq2+float64(z*(_qq3+float64(z*(_qq4+float64(z*_qq5))))))))) + y = r / s + if sign != 0 || ix < uint32(0x3fd00000) { /* x < 1/4 */ + return float64(1) - (x + float64(x*y)) + } + return float64(0.5) - (x - float64(0.5) + float64(x*y)) + } + if ix < uint32(0x403c0000) { /* 0.84375 <= |x| < 28 */ + if sign != 0 { + v1 = Float64FromInt32(2) - _erfc2(tls, ix, x) + } else { + v1 = _erfc2(tls, ix, x) + } + return v1 + } + if sign != 0 { + v1 = Float64FromInt32(2) - Float64FromFloat64(2.2250738585072014e-308) + } else { + v1 = float64(Float64FromFloat64(2.2250738585072014e-308) * Float64FromFloat64(2.2250738585072014e-308)) + } + return v1 +} + +var _erx1 = float32(0.84506291151) /* 0x3f58560b */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +var _efx81 = float32(1.027033329) /* 0x3f8375d4 */ +var _pp01 = float32(0.12837916613) /* 0x3e0375d4 */ +var _pp11 = float32(-Float64FromFloat64(0.32504209876)) /* 0xbea66beb */ +var _pp21 = float32(-Float64FromFloat64(0.028481749818)) /* 0xbce9528f */ +var _pp31 = float32(-Float64FromFloat64(0.005770270247)) /* 0xbbbd1489 */ +var _pp41 = float32(-Float64FromFloat64(2.3763017452e-05)) /* 0xb7c756b1 */ +var _qq11 = float32(0.39791721106) /* 0x3ecbbbce */ +var _qq21 = float32(0.0650222525) /* 0x3d852a63 */ +var _qq31 = float32(0.0050813062117) /* 0x3ba68116 */ +var _qq41 = float32(0.00013249473704) /* 0x390aee49 */ +var _qq51 = float32(-Float64FromFloat64(3.9602282413e-06)) /* 0xb684e21a */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +var _pa01 = float32(-Float64FromFloat64(0.0023621185683)) /* 0xbb1acdc6 */ +var _pa11 = float32(0.41485610604) /* 0x3ed46805 */ +var _pa21 = float32(-Float64FromFloat64(0.37220788002)) /* 0xbebe9208 */ +var _pa31 = float32(0.31834661961) /* 0x3ea2fe54 */ +var _pa41 = float32(-Float64FromFloat64(0.11089469492)) /* 0xbde31cc2 */ +var _pa51 = float32(0.035478305072) /* 0x3d1151b3 */ +var _pa61 = float32(-Float64FromFloat64(0.0021663755178)) /* 0xbb0df9c0 */ +var _qa11 = float32(0.10642088205) /* 0x3dd9f331 */ +var _qa21 = float32(0.54039794207) /* 0x3f0a5785 */ +var _qa31 = float32(0.071828655899) /* 0x3d931ae7 */ +var _qa41 = float32(0.12617121637) /* 0x3e013307 */ +var _qa51 = float32(0.013637083583) /* 0x3c5f6e13 */ +var _qa61 = float32(0.011984500103) /* 0x3c445aa3 */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +var _ra01 = float32(-Float64FromFloat64(0.0098649440333)) /* 0xbc21a093 */ +var _ra11 = float32(-Float64FromFloat64(0.6938585639)) /* 0xbf31a0b7 */ +var _ra21 = float32(-Float64FromFloat64(10.558626175)) /* 0xc128f022 */ +var _ra31 = float32(-Float64FromFloat64(62.375331879)) /* 0xc2798057 */ +var _ra41 = float32(-Float64FromFloat64(162.39666748)) /* 0xc322658c */ +var _ra51 = float32(-Float64FromFloat64(184.60508728)) /* 0xc3389ae7 */ +var _ra61 = float32(-Float64FromFloat64(81.287437439)) /* 0xc2a2932b */ +var _ra71 = float32(-Float64FromFloat64(9.8143291473)) /* 0xc11d077e */ +var _sa11 = float32(19.65127182) /* 0x419d35ce */ +var _sa21 = float32(137.65776062) /* 0x4309a863 */ +var _sa31 = float32(434.56588745) /* 0x43d9486f */ +var _sa41 = float32(645.38726807) /* 0x442158c9 */ +var _sa51 = float32(429.00814819) /* 0x43d6810b */ +var _sa61 = float32(108.63500214) /* 0x42d9451f */ +var _sa71 = float32(6.5702495575) /* 0x40d23f7c */ +var _sa81 = float32(-Float64FromFloat64(0.060424413532)) /* 0xbd777f97 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +var _rb01 = float32(-Float64FromFloat64(0.009864943102)) /* 0xbc21a092 */ +var _rb11 = float32(-Float64FromFloat64(0.79928326607)) /* 0xbf4c9dd4 */ +var _rb21 = float32(-Float64FromFloat64(17.757955551)) /* 0xc18e104b */ +var _rb31 = float32(-Float64FromFloat64(160.63638306)) /* 0xc320a2ea */ +var _rb41 = float32(-Float64FromFloat64(637.56646729)) /* 0xc41f6441 */ +var _rb51 = float32(-Float64FromFloat64(1025.0950928)) /* 0xc480230b */ +var _rb61 = float32(-Float64FromFloat64(483.51919556)) /* 0xc3f1c275 */ +var _sb11 = float32(30.338060379) /* 0x41f2b459 */ +var _sb21 = float32(325.79251099) /* 0x43a2e571 */ +var _sb31 = float32(1536.7296143) /* 0x44c01759 */ +var _sb41 = float32(3199.8581543) /* 0x4547fdbb */ +var _sb51 = float32(2553.050293) /* 0x451f90ce */ +var _sb61 = float32(474.52853394) /* 0x43ed43a7 */ +var _sb71 = float32(-Float64FromFloat64(22.440952301)) /* 0xc1b38712 */ + +func _erfc11(tls *TLS, x float32) (r float32) { + var P, Q, s Tfloat_t + _, _, _ = P, Q, s + s = Xfabsf(tls, x) - Float32FromInt32(1) + P = _pa01 + float32(s*(_pa11+float32(s*(_pa21+float32(s*(_pa31+float32(s*(_pa41+float32(s*(_pa51+float32(s*_pa61))))))))))) + Q = Float32FromInt32(1) + Tfloat_t(s*(_qa11+float32(s*(_qa21+float32(s*(_qa31+float32(s*(_qa41+float32(s*(_qa51+float32(s*_qa61))))))))))) + return Float32FromInt32(1) - _erx1 - P/Q +} + +func _erfc21(tls *TLS, ix Tuint32_t, x float32) (r float32) { + var R, S, s Tfloat_t + var z float32 + var v1 Tuint32_t + _, _, _, _, _ = R, S, s, z, v1 + if ix < uint32(0x3fa00000) { /* |x| < 1.25 */ + return _erfc11(tls, x) + } + x = Xfabsf(tls, x) + s = Float32FromInt32(1) / float32(x*x) + if ix < uint32(0x4036db6d) { /* |x| < 1/0.35 */ + R = _ra01 + float32(s*(_ra11+float32(s*(_ra21+float32(s*(_ra31+float32(s*(_ra41+float32(s*(_ra51+float32(s*(_ra61+float32(s*_ra71))))))))))))) + S = Float32FromFloat32(1) + float32(s*(_sa11+float32(s*(_sa21+float32(s*(_sa31+float32(s*(_sa41+float32(s*(_sa51+float32(s*(_sa61+float32(s*(_sa71+float32(s*_sa81))))))))))))))) + } else { /* |x| >= 1/0.35 */ + R = _rb01 + float32(s*(_rb11+float32(s*(_rb21+float32(s*(_rb31+float32(s*(_rb41+float32(s*(_rb51+float32(s*_rb61))))))))))) + S = Float32FromFloat32(1) + float32(s*(_sb11+float32(s*(_sb21+float32(s*(_sb31+float32(s*(_sb41+float32(s*(_sb51+float32(s*(_sb61+float32(s*_sb71))))))))))))) + } + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + v1 = ix & uint32(0xffffe000) + z = *(*float32)(unsafe.Pointer(&v1)) + return float32(Xexpf(tls, float32(-z*z)-Float32FromFloat32(0.5625))*Xexpf(tls, float32((z-x)*(z+x))+R/S)) / x +} + +func Xerff(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, y, z, v1 float32 + var sign int32 + _, _, _, _, _, _, _ = ix, r, s, sign, y, z, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + /* erf(nan)=nan, erf(+-inf)=+-1 */ + return float32(int32(1)-int32(2)*sign) + Float32FromInt32(1)/x + } + if ix < uint32(0x3f580000) { /* |x| < 0.84375 */ + if ix < uint32(0x31800000) { /* |x| < 2**-28 */ + /*avoid underflow */ + return float32(Float32FromFloat32(0.125) * (float32(Float32FromInt32(8)*x) + float32(_efx81*x))) + } + z = float32(x * x) + r = _pp01 + float32(z*(_pp11+float32(z*(_pp21+float32(z*(_pp31+float32(z*_pp41))))))) + s = Float32FromInt32(1) + float32(z*(_qq11+float32(z*(_qq21+float32(z*(_qq31+float32(z*(_qq41+float32(z*_qq51))))))))) + y = r / s + return x + float32(x*y) + } + if ix < uint32(0x40c00000) { /* |x| < 6 */ + y = Float32FromInt32(1) - _erfc21(tls, ix, x) + } else { + y = Float32FromInt32(1) - Float32FromFloat32(7.52316384526264e-37) + } + if sign != 0 { + v1 = -y + } else { + v1 = y + } + return v1 +} + +func Xerfcf(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, y, z, v1 float32 + var sign int32 + _, _, _, _, _, _, _ = ix, r, s, sign, y, z, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + /* erfc(nan)=nan, erfc(+-inf)=0,2 */ + return float32(int32(2)*sign) + Float32FromInt32(1)/x + } + if ix < uint32(0x3f580000) { /* |x| < 0.84375 */ + if ix < uint32(0x23800000) { /* |x| < 2**-56 */ + return Float32FromFloat32(1) - x + } + z = float32(x * x) + r = _pp01 + float32(z*(_pp11+float32(z*(_pp21+float32(z*(_pp31+float32(z*_pp41))))))) + s = Float32FromFloat32(1) + float32(z*(_qq11+float32(z*(_qq21+float32(z*(_qq31+float32(z*(_qq41+float32(z*_qq51))))))))) + y = r / s + if sign != 0 || ix < uint32(0x3e800000) { /* x < 1/4 */ + return Float32FromFloat32(1) - (x + float32(x*y)) + } + return Float32FromFloat32(0.5) - (x - Float32FromFloat32(0.5) + float32(x*y)) + } + if ix < uint32(0x41e00000) { /* |x| < 28 */ + if sign != 0 { + v1 = Float32FromInt32(2) - _erfc21(tls, ix, x) + } else { + v1 = _erfc21(tls, ix, x) + } + return v1 + } + if sign != 0 { + v1 = Float32FromInt32(2) - Float32FromFloat32(7.52316384526264e-37) + } else { + v1 = float32(Float32FromFloat32(7.52316384526264e-37) * Float32FromFloat32(7.52316384526264e-37)) + } + return v1 +} + +func Xerfl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xerf(tls, x) +} + +func Xerfcl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xerfc(tls, x) +} + +const EXP2_POLY_ORDER = 5 +const EXP_POLY_ORDER = 5 +const EXP_TABLE_BITS = 7 +const EXP_USE_TOINT_NARROW = 0 +const N = 128 + +// C documentation +// +// /* Handle cases that may overflow or underflow when computing the result that +// is scale*(1+TMP) without intermediate rounding. The bit representation of +// scale is in SBITS, however it has a computed exponent that may have +// overflown into the sign bit so that needs to be adjusted before using it as +// a double. (int32_t)KI is the k used in the argument reduction and exponent +// adjustment of scale, positive k here means the result may overflow and +// negative k means the result may underflow. */ +func _specialcase(tls *TLS, tmp Tdouble_t, sbits Tuint64_t, ki Tuint64_t) (r float64) { + var hi, lo, scale, y3 Tdouble_t + var y, y1, y2, v1 float64 + _, _, _, _, _, _, _, _ = hi, lo, scale, y, y1, y2, y3, v1 + if ki&uint64(0x80000000) == uint64(0) { + /* k > 0, the exponent of scale might have overflowed by <= 460. */ + sbits = uint64(sbits - Uint64FromUint64(1009)<> int32(52)) +} + +func Xexp(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var abstop Tuint32_t + var idx, ki, sbits, top, v5 Tuint64_t + var kd, r, r2, scale, tail, tmp, z Tdouble_t + var y, v1 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abstop, idx, kd, ki, r, r2, sbits, scale, tail, tmp, top, y, z, v1, v5 + abstop = _top12(tls, x1) & uint32(0x7ff) + if abstop-_top12(tls, float64(5.551115123125783e-17)) >= _top12(tls, float64(512))-_top12(tls, float64(5.551115123125783e-17)) { + if abstop-_top12(tls, float64(5.551115123125783e-17)) >= uint32(0x80000000) { + /* Avoid spurious underflow for tiny x. */ + /* Note: 0 is common input. */ + return float64(1) + x1 + } + if abstop >= _top12(tls, float64(1024)) { + v1 = float64(-X__builtin_inff(tls)) + if *(*Tuint64_t)(unsafe.Pointer(&x1)) == *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(0) + } + if abstop >= _top12(tls, float64(X__builtin_inff(tls))) { + return float64(1) + x1 + } + if *(*Tuint64_t)(unsafe.Pointer(&x1))>>int32(63) != 0 { + return X__math_uflow(tls, uint32(0)) + } else { + return X__math_oflow(tls, uint32(0)) + } + } + /* Large x is special cased below. */ + abstop = uint32(0) + } + /* exp(x) = 2^(k/N) * exp(r), with exp(r) in [2^(-1/2N),2^(1/2N)]. */ + /* x = ln2/N*k + r, with int k and r in [-ln2/2N, ln2/2N]. */ + z = Tdouble_t(X__exp_data.Finvln2N * x1) + /* z - kd is in [-1, 1] in non-nearest rounding modes. */ + y = z + X__exp_data.Fshift + v1 = y + goto _3 +_3: + kd = v1 + v1 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v1)) + kd = kd - X__exp_data.Fshift + r = x1 + float64(kd*X__exp_data.Fnegln2hiN) + float64(kd*X__exp_data.Fnegln2loN) + /* 2^(k/N) ~= scale * (1 + tail). */ + idx = uint64(2) * (ki % Uint64FromInt32(Int32FromInt32(1)< 2^-200 and scale > 2^-739, so there + is no spurious underflow here even without fma. */ + y = scale + Tdouble_t(scale*tmp) + v1 = y + goto _7 +_7: + return v1 +} + +const HUGE = 0 + +func Xexp10(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var y float64 + var _ /* n at bp+0 */ float64 + var _ /* u at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = y + y = Xmodf(tls, x, bp) + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = **(**float64)(__ccgo_up(bp)) + /* fabs(n) < 16 without raising invalid on nan */ + if *(*Tuint64_t)(unsafe.Pointer(bp + 8))>>int32(52)&uint64(0x7ff) < Uint64FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(4)) { + if !(y != 0) { + return _p10[int32(**(**float64)(__ccgo_up(bp)))+int32(15)] + } + y = Xexp2(tls, float64(float64(3.321928094887362)*y)) + return float64(y * _p10[int32(**(**float64)(__ccgo_up(bp)))+int32(15)]) + } + return Xpow(tls, float64(10), x) +} + +var _p10 = [31]float64{ + 0: float64(1e-15), + 1: float64(1e-14), + 2: float64(1e-13), + 3: float64(1e-12), + 4: float64(1e-11), + 5: float64(1e-10), + 6: float64(1e-09), + 7: float64(1e-08), + 8: float64(1e-07), + 9: float64(1e-06), + 10: float64(1e-05), + 11: float64(0.0001), + 12: float64(0.001), + 13: float64(0.01), + 14: float64(0.1), + 15: Float64FromInt32(1), + 16: float64(10), + 17: float64(100), + 18: float64(1000), + 19: float64(10000), + 20: float64(100000), + 21: float64(1e+06), + 22: float64(1e+07), + 23: float64(1e+08), + 24: float64(1e+09), + 25: float64(1e+10), + 26: float64(1e+11), + 27: float64(1e+12), + 28: float64(1e+13), + 29: float64(1e+14), + 30: float64(1e+15), +} + +func Xpow10(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexp10(tls, x) +} + +func Xexp10f(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var y float32 + var _ /* n at bp+0 */ float32 + var _ /* u at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _ = y + y = Xmodff(tls, x, bp) + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = **(**float32)(__ccgo_up(bp)) + /* fabsf(n) < 8 without raising invalid on nan */ + if *(*Tuint32_t)(unsafe.Pointer(bp + 4))>>int32(23)&uint32(0xff) < Uint32FromInt32(Int32FromInt32(0x7f)+Int32FromInt32(3)) { + if !(y != 0) { + return _p101[int32(**(**float32)(__ccgo_up(bp)))+int32(7)] + } + y = Xexp2f(tls, float32(Float32FromFloat32(3.321928094887362)*y)) + return float32(y * _p101[int32(**(**float32)(__ccgo_up(bp)))+int32(7)]) + } + return float32(Xexp2(tls, float64(float64(3.321928094887362)*float64(x)))) +} + +var _p101 = [15]float32{ + 0: Float32FromFloat32(1e-07), + 1: Float32FromFloat32(1e-06), + 2: Float32FromFloat32(1e-05), + 3: Float32FromFloat32(0.0001), + 4: Float32FromFloat32(0.001), + 5: Float32FromFloat32(0.01), + 6: Float32FromFloat32(0.1), + 7: Float32FromInt32(1), + 8: float32(10), + 9: float32(100), + 10: float32(1000), + 11: float32(10000), + 12: float32(100000), + 13: float32(1e+06), + 14: float32(1e+07), +} + +func Xpow10f(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexp10f(tls, x) +} + +func Xexp10l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexp10(tls, x) +} + +func Xpow10l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexp10l(tls, x) +} + +// C documentation +// +// /* Handle cases that may overflow or underflow when computing the result that +// is scale*(1+TMP) without intermediate rounding. The bit representation of +// scale is in SBITS, however it has a computed exponent that may have +// overflown into the sign bit so that needs to be adjusted before using it as +// a double. (int32_t)KI is the k used in the argument reduction and exponent +// adjustment of scale, positive k here means the result may overflow and +// negative k means the result may underflow. */ +func _specialcase1(tls *TLS, tmp Tdouble_t, sbits Tuint64_t, ki Tuint64_t) (r float64) { + var hi, lo, scale, y3 Tdouble_t + var y, y1, y2, v1 float64 + _, _, _, _, _, _, _, _ = hi, lo, scale, y, y1, y2, y3, v1 + if ki&uint64(0x80000000) == uint64(0) { + /* k > 0, the exponent of scale might have overflowed by 1. */ + sbits = uint64(sbits - Uint64FromUint64(1)<> int32(52)) +} + +func Xexp2(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var abstop Tuint32_t + var idx, ki, sbits, top, v7 Tuint64_t + var kd, r, r2, scale, tail, tmp Tdouble_t + var y, v1 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abstop, idx, kd, ki, r, r2, sbits, scale, tail, tmp, top, y, v1, v7 + abstop = _top121(tls, x1) & uint32(0x7ff) + if abstop-_top121(tls, float64(5.551115123125783e-17)) >= _top121(tls, float64(512))-_top121(tls, float64(5.551115123125783e-17)) { + if abstop-_top121(tls, float64(5.551115123125783e-17)) >= uint32(0x80000000) { + /* Avoid spurious underflow for tiny x. */ + /* Note: 0 is common input. */ + return float64(1) + x1 + } + if abstop >= _top121(tls, float64(1024)) { + v1 = float64(-X__builtin_inff(tls)) + if *(*Tuint64_t)(unsafe.Pointer(&x1)) == *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(0) + } + if abstop >= _top121(tls, float64(X__builtin_inff(tls))) { + return float64(1) + x1 + } + if !(*(*Tuint64_t)(unsafe.Pointer(&x1))>>Int32FromInt32(63) != 0) { + return X__math_oflow(tls, uint32(0)) + } else { + v1 = -Float64FromFloat64(1075) + if *(*Tuint64_t)(unsafe.Pointer(&x1)) >= *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return X__math_uflow(tls, uint32(0)) + } + } + } + v1 = float64(928) + if uint64(2)**(*Tuint64_t)(unsafe.Pointer(&x1)) > uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1)) { + /* Large x is special cased below. */ + abstop = uint32(0) + } + } + /* exp2(x) = 2^(k/N) * 2^r, with 2^r in [2^(-1/2N),2^(1/2N)]. */ + /* x = k/N + r, with int k and r in [-1/2N, 1/2N]. */ + y = x1 + X__exp_data.Fexp2_shift + v1 = y + goto _5 +_5: + kd = v1 + v1 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v1)) /* k. */ + kd = kd - X__exp_data.Fexp2_shift /* k/N for int k. */ + r = x1 - kd + /* 2^(k/N) ~= scale * (1 + tail). */ + idx = uint64(2) * (ki % Uint64FromInt32(Int32FromInt32(1)< 2^-65 and scale > 2^-928, so there + is no spurious underflow here even without fma. */ + y = scale + Tdouble_t(scale*tmp) + v1 = y + goto _9 +_9: + return v1 +} + +const EXP2F_POLY_ORDER = 3 +const EXP2F_TABLE_BITS = 5 +const N1 = 32 + +/* +EXP2F_TABLE_BITS = 5 +EXP2F_POLY_ORDER = 3 + +ULP error: 0.502 (nearest rounding.) +Relative error: 1.69 * 2^-34 in [-1/64, 1/64] (before rounding.) +Wrong count: 168353 (all nearest rounding wrong results with fma.) +Non-nearest ULP error: 1 (rounded ULP error) +*/ + +func _top122(tls *TLS, x float32) (r Tuint32_t) { + return *(*Tuint32_t)(unsafe.Pointer(&x)) >> int32(20) +} + +func Xexp2f(tls *TLS, x2 float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x2=%v, (%v:)", tls, x2, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var abstop Tuint32_t + var kd, r, r2, s, xd, y2, z Tdouble_t + var ki, t Tuint64_t + var y, v1 float32 + var y1, v2 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abstop, kd, ki, r, r2, s, t, xd, y, y1, y2, z, v1, v2 + xd = float64(x2) + abstop = _top122(tls, x2) & uint32(0x7ff) + if abstop >= _top122(tls, Float32FromFloat32(128)) { + /* |x| >= 128 or x is nan. */ + v1 = -X__builtin_inff(tls) + if *(*Tuint32_t)(unsafe.Pointer(&x2)) == *(*Tuint32_t)(unsafe.Pointer(&v1)) { + return Float32FromFloat32(0) + } + if abstop >= _top122(tls, X__builtin_inff(tls)) { + return x2 + x2 + } + if x2 > Float32FromFloat32(0) { + return X__math_oflowf(tls, uint32(0)) + } + if x2 <= -Float32FromFloat32(150) { + return X__math_uflowf(tls, uint32(0)) + } + } + /* x = k/N + r with r in [-1/(2N), 1/(2N)] and int k. */ + y1 = xd + X__exp2f_data.Fshift_scaled + v2 = y1 + goto _3 +_3: + kd = v2 + v2 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v2)) + kd = kd - X__exp2f_data.Fshift_scaled /* k/N for int k. */ + r = xd - kd + /* exp2(x) = 2^(k/N) * 2^r ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */ + t = **(**Tuint64_t)(__ccgo_up(uintptr(unsafe.Pointer(&X__exp2f_data)) + uintptr(ki%Uint64FromInt32(Int32FromInt32(1)< %v", r) }() + } + return Xexp2(tls, x) +} + +const N2 = 128 + +type Texp_data = struct { + Finvln2N float64 + Fshift float64 + Fnegln2hiN float64 + Fnegln2loN float64 + Fpoly [4]float64 + Fexp2_shift float64 + Fexp2_poly [5]float64 + Ftab [256]Tuint64_t +} + +const N3 = 32 + +/* +EXP2F_TABLE_BITS = 5 +EXP2F_POLY_ORDER = 3 + +ULP error: 0.502 (nearest rounding.) +Relative error: 1.69 * 2^-34 in [-ln2/64, ln2/64] (before rounding.) +Wrong count: 170635 (all nearest rounding wrong results with fma.) +Non-nearest ULP error: 1 (rounded ULP error) +*/ + +func _top123(tls *TLS, x float32) (r Tuint32_t) { + return *(*Tuint32_t)(unsafe.Pointer(&x)) >> int32(20) +} + +func Xexpf(tls *TLS, x2 float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x2=%v, (%v:)", tls, x2, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var abstop Tuint32_t + var kd, r, r2, s, xd, y2, z Tdouble_t + var ki, t Tuint64_t + var y, v1 float32 + var y1, v2 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abstop, kd, ki, r, r2, s, t, xd, y, y1, y2, z, v1, v2 + xd = float64(x2) + abstop = _top123(tls, x2) & uint32(0x7ff) + if abstop >= _top123(tls, Float32FromFloat32(88)) { + /* |x| >= 88 or x is nan. */ + v1 = -X__builtin_inff(tls) + if *(*Tuint32_t)(unsafe.Pointer(&x2)) == *(*Tuint32_t)(unsafe.Pointer(&v1)) { + return Float32FromFloat32(0) + } + if abstop >= _top123(tls, X__builtin_inff(tls)) { + return x2 + x2 + } + if x2 > Float32FromFloat32(88.72283172607422) { /* x > log(0x1p128) ~= 88.72 */ + return X__math_oflowf(tls, uint32(0)) + } + if x2 < -Float32FromFloat32(103.97207641601562) { /* x < log(0x1p-150) ~= -103.97 */ + return X__math_uflowf(tls, uint32(0)) + } + } + /* x*N/Ln2 = k + r with r in [-1/2, 1/2] and int k. */ + z = Tdouble_t(X__exp2f_data.Finvln2_scaled * xd) + /* Round and convert z to int, the result is in [-150*N, 128*N] and + ideally ties-to-even rule is used, otherwise the magnitude of r + can be bigger which gives larger approximation error. */ + y1 = z + X__exp2f_data.Fshift + v2 = y1 + goto _3 +_3: + kd = v2 + v2 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v2)) + kd = kd - X__exp2f_data.Fshift + r = z - kd + /* exp(x) = 2^(k/N) * 2^(r/N) ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */ + t = **(**Tuint64_t)(__ccgo_up(uintptr(unsafe.Pointer(&X__exp2f_data)) + uintptr(ki%Uint64FromInt32(Int32FromInt32(1)< %v", r) }() + } + return Xexp(tls, x) +} + +var _o_threshold = float64(709.782712893384) /* 0x40862E42, 0xFEFA39EF */ +var _ln2_hi = float64(0.6931471803691238) /* 0x3fe62e42, 0xfee00000 */ +var _ln2_lo = float64(1.9082149292705877e-10) /* 0x3dea39ef, 0x35793c76 */ +var _invln2 = float64(1.4426950408889634) /* 0x3ff71547, 0x652b82fe */ +/* Scaled Q's: Qn_here = 2**n * Qn_above, for R(2*z) where z = hxs = x*x/2: */ +var _Q1 = -Float64FromFloat64(0.03333333333333313) /* BFA11111 111110F4 */ +var _Q2 = float64(0.0015873015872548146) /* 3F5A01A0 19FE5585 */ +var _Q3 = -Float64FromFloat64(7.93650757867488e-05) /* BF14CE19 9EAADBB7 */ +var _Q4 = float64(4.008217827329362e-06) /* 3ED0CFCA 86E65239 */ +var _Q5 = -Float64FromFloat64(2.0109921818362437e-07) /* BE8AFDB7 6E09C32D */ + +func Xexpm1(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, e, hfx, hi, hxs, lo, r1, t, twopk, y3 Tdouble_t + var hx Tuint32_t + var k, sign int32 + var y float32 + var y1, y2, v3 float64 + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* u at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, e, hfx, hi, hx, hxs, k, lo, r1, sign, t, twopk, y, y1, y2, y3, v1, v3 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x3 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(32) & uint64(0x7fffffff)) + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(63)) + /* filter out huge and non-finite argument */ + if hx >= uint32(0x4043687A) { /* if |x|>=56*ln2 */ + *(*float64)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 + _2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< _o_threshold { + x3 = x3 * float64(8.98846567431158e+307) + return x3 + } + } + /* argument reduction */ + if hx > uint32(0x3fd62e42) { /* if |x| > 0.5 ln2 */ + if hx < uint32(0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ + if !(sign != 0) { + hi = x3 - _ln2_hi + lo = _ln2_lo + k = int32(1) + } else { + hi = x3 + _ln2_hi + lo = -_ln2_lo + k = -int32(1) + } + } else { + if sign != 0 { + v3 = -Float64FromFloat64(0.5) + } else { + v3 = float64(0.5) + } + k = int32(float64(_invln2*x3) + v3) + t = float64(k) + hi = x3 - float64(t*_ln2_hi) /* t*ln2_hi is exact here */ + lo = Tdouble_t(t * _ln2_lo) + } + x3 = hi - lo + c = hi - x3 - lo + } else { + if hx < uint32(0x3c900000) { /* |x| < 2**-54, return x */ + if hx < uint32(0x00100000) { + if uint64(4) == uint64(4) { + y = float32(x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3)) + } else { + y2 = float64(float32(x3)) + } + } + } + return x3 + } else { + k = 0 + } + } + /* x is now in primary range */ + hfx = Tdouble_t(float64(0.5) * x3) + hxs = Tdouble_t(x3 * hfx) + r1 = float64(1) + float64(hxs*(_Q1+float64(hxs*(_Q2+float64(hxs*(_Q3+float64(hxs*(_Q4+float64(hxs*_Q5))))))))) + t = float64(3) - float64(r1*hfx) + e = Tdouble_t(hxs * ((r1 - t) / (Float64FromFloat64(6) - float64(x3*t)))) + if k == 0 { /* c is 0 */ + return x3 - (float64(x3*e) - hxs) + } + e = float64(x3*(e-c)) - c + e = e - hxs + /* exp(x) ~ 2^k (Xreduced - e + 1) */ + if k == -int32(1) { + return float64(float64(0.5)*(x3-e)) - float64(0.5) + } + if k == int32(1) { + if x3 < -Float64FromFloat64(0.25) { + return float64(-Float64FromFloat64(2) * (e - (x3 + Float64FromFloat64(0.5)))) + } + return float64(1) + float64(float64(2)*(x3-e)) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 8)) = Uint64FromInt32(Int32FromInt32(0x3ff)+k) << int32(52) /* 2^k */ + twopk = *(*float64)(unsafe.Pointer(bp + 8)) + if k < 0 || k > int32(56) { /* suffice to return exp(x)-1 */ + y3 = x3 - e + float64(1) + if k == int32(1024) { + y3 = Tdouble_t(Tdouble_t(y3*float64(2)) * float64(8.98846567431158e+307)) + } else { + y3 = Tdouble_t(y3 * twopk) + } + return y3 - float64(1) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 8)) = Uint64FromInt32(Int32FromInt32(0x3ff)-k) << int32(52) /* 2^-k */ + if k < int32(20) { + y3 = Tdouble_t((x3 - e + (Float64FromInt32(1) - *(*float64)(unsafe.Pointer(bp + 8)))) * twopk) + } else { + y3 = Tdouble_t((x3 - (e + *(*float64)(unsafe.Pointer(bp + 8))) + Float64FromInt32(1)) * twopk) + } + return y3 +} + +var _ln2_hi1 = float32(0.69313812256) /* 0x3f317180 */ +var _ln2_lo1 = float32(9.0580006145e-06) /* 0x3717f7d1 */ +var _invln21 = float32(1.4426950216) /* 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): + */ +var _Q11 = float32(-Float64FromFloat64(0.033333212137)) /* -0x888868.0p-28 */ +var _Q21 = float32(0.0015807170421) /* 0xcf3010.0p-33 */ + +func Xexpm1f(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, e, hfx, hi, hxs, lo, r1, t, twopk, y3 Tfloat_t + var hx Tuint32_t + var k, sign int32 + var y, v1 float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, e, hfx, hi, hx, hxs, k, lo, r1, sign, t, twopk, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + /* filter out huge and non-finite argument */ + if hx >= uint32(0x4195b844) { /* if |x|>=27*ln2 */ + if hx > uint32(0x7f800000) { /* NaN */ + return x3 + } + if sign != 0 { + return float32(-Int32FromInt32(1)) + } + if hx > uint32(0x42b17217) { /* x > log(FLT_MAX) */ + x3 = x3 * Float32FromFloat32(1.7014118346046923e+38) + return x3 + } + } + /* argument reduction */ + if hx > uint32(0x3eb17218) { /* if |x| > 0.5 ln2 */ + if hx < uint32(0x3F851592) { /* and |x| < 1.5 ln2 */ + if !(sign != 0) { + hi = x3 - _ln2_hi1 + lo = _ln2_lo1 + k = int32(1) + } else { + hi = x3 + _ln2_hi1 + lo = -_ln2_lo1 + k = -int32(1) + } + } else { + if sign != 0 { + v1 = -Float32FromFloat32(0.5) + } else { + v1 = Float32FromFloat32(0.5) + } + k = int32(float32(_invln21*x3) + v1) + t = float32(k) + hi = x3 - float32(t*_ln2_hi1) /* t*ln2_hi is exact here */ + lo = Tfloat_t(t * _ln2_lo1) + } + x3 = hi - lo + c = hi - x3 - lo + } else { + if hx < uint32(0x33000000) { /* when |x|<2**-25, return x */ + if hx < uint32(0x00800000) { + if uint64(4) == uint64(4) { + y = float32(x3 * x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 * x3) + } else { + y2 = float64(x3 * x3) + } + } + } + return x3 + } else { + k = 0 + } + } + /* x is now in primary range */ + hfx = Tfloat_t(Float32FromFloat32(0.5) * x3) + hxs = Tfloat_t(x3 * hfx) + r1 = Float32FromFloat32(1) + float32(hxs*(_Q11+float32(hxs*_Q21))) + t = Float32FromFloat32(3) - float32(r1*hfx) + e = Tfloat_t(hxs * ((r1 - t) / (Float32FromFloat32(6) - float32(x3*t)))) + if k == 0 { /* c is 0 */ + return x3 - (float32(x3*e) - hxs) + } + e = float32(x3*(e-c)) - c + e = e - hxs + /* exp(x) ~ 2^k (Xreduced - e + 1) */ + if k == -int32(1) { + return float32(Float32FromFloat32(0.5)*(x3-e)) - Float32FromFloat32(0.5) + } + if k == int32(1) { + if x3 < -Float32FromFloat32(0.25) { + return float32(-Float32FromFloat32(2) * (e - (x3 + Float32FromFloat32(0.5)))) + } + return Float32FromFloat32(1) + float32(Float32FromFloat32(2)*(x3-e)) + } + *(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32((int32(0x7f) + k) << int32(23)) /* 2^k */ + twopk = *(*float32)(unsafe.Pointer(bp)) + if k < 0 || k > int32(56) { /* suffice to return exp(x)-1 */ + y3 = x3 - e + Float32FromFloat32(1) + if k == int32(128) { + y3 = Tfloat_t(Tfloat_t(y3*Float32FromFloat32(2)) * Float32FromFloat32(1.7014118346046923e+38)) + } else { + y3 = Tfloat_t(y3 * twopk) + } + return y3 - Float32FromFloat32(1) + } + *(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32((int32(0x7f) - k) << int32(23)) /* 2^-k */ + if k < int32(23) { + y3 = Tfloat_t((x3 - e + (Float32FromInt32(1) - *(*float32)(unsafe.Pointer(bp)))) * twopk) + } else { + y3 = Tfloat_t((x3 - (e + *(*float32)(unsafe.Pointer(bp))) + Float32FromInt32(1)) * twopk) + } + return y3 +} + +func Xexpm1l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexpm1(tls, x) +} + +func Xfabs(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uintptr + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (-Uint64FromUint64(1) / Uint64FromInt32(2))) + return *(*float64)(unsafe.Pointer(bp)) +} + +func Xfabsf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + return *(*float32)(unsafe.Pointer(bp)) +} + +func Xfabsl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfabs(tls, x) +} + +func Xfdim(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var v5 float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _ = v1, v5 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< y { + v5 = x - y + } else { + v5 = Float64FromInt32(0) + } + return v5 +} + +func Xfdimf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint32 + var v5 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _ = v1, v5 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + } + *(*float32)(unsafe.Pointer(bp)) = y + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 +_4: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return y + } + if x > y { + v5 = x - y + } else { + v5 = Float32FromInt32(0) + } + return v5 +} + +func Xfdiml(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfdim(tls, x, y) +} + +func Xfinite(tls *TLS, x float64) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _ = v1 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + return BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _ = v1 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + return BoolInt32(v1&uint32(0x7fffffff) < uint32(0x7f800000)) +} + +const DBL_EPSILON7 = 2.220446049250313e-16 + +var _toint3 = Float64FromInt32(1) / Float64FromFloat64(2.220446049250313e-16) + +func Xfloor(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v1 int32 + var y float32 + var y1, y2 float64 + var y3 Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = e, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if e >= Int32FromInt32(0x3ff)+Int32FromInt32(52) || x3 == Float64FromInt32(0) { + return x3 + } + /* y = int(x) - x, where int(x) is an integer neighbor of x */ + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + y3 = x3 - _toint3 + _toint3 - x3 + } else { + y3 = x3 + _toint3 - _toint3 - x3 + } + /* special case because of non-nearest rounding modes */ + if e <= Int32FromInt32(0x3ff)-Int32FromInt32(1) { + if uint64(8) == uint64(4) { + y = float32(y3) + } else { + if uint64(8) == uint64(8) { + y1 = y3 + } else { + y2 = y3 + } + } + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return float64(v1) + } + if y3 > Float64FromInt32(0) { + return x3 + y3 - Float64FromInt32(1) + } + return x3 + y3 +} + +const DBL_EPSILON8 = 0 + +func Xfloorf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var m Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e, m, y, y1, y2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp))>>Int32FromInt32(23)&Uint32FromInt32(0xff)) - int32(0x7f) + if e >= int32(23) { + return x3 + } + if e >= 0 { + m = Uint32FromInt32(int32(0x007fffff) >> e) + if *(*Tuint32_t)(unsafe.Pointer(bp))&m == uint32(0) { + return x3 + } + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp)) += m + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= ^m + } else { + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) == uint32(0) { + *(*Tuint32_t)(unsafe.Pointer(bp)) = uint32(0) + } else { + if *(*Tuint32_t)(unsafe.Pointer(bp))< %v", r) }() + } + return Xfloor(tls, x) +} + +const DBL_MIN1 = 2.2250738585072014e-308 +const FLT_MIN1 = 1.1754943508222875e-38 +const ZEROINFNAN = 971 + +type Tnum = struct { + Fm Tuint64_t + Fe int32 + Fsign int32 +} + +func _normalize(tls *TLS, x float64) (r Tnum) { + var e, sign, v2 int32 + var ix Tuint64_t + var v1 float64 + _, _, _, _, _ = e, ix, sign, v1, v2 + ix = *(*Tuint64_t)(unsafe.Pointer(&x)) + e = Int32FromUint64(ix >> int32(52)) + sign = e & int32(0x800) + e = e & int32(0x7ff) + if !(e != 0) { + v1 = float64(x * float64(9.223372036854776e+18)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + e = Int32FromUint64(ix >> int32(52) & uint64(0x7ff)) + if e != 0 { + v2 = e - int32(63) + } else { + v2 = int32(0x800) + } + e = v2 + } + ix = uint64(ix & (Uint64FromUint64(1)<> int32(32) + ylo = uint64(uint32(y)) + yhi = y >> int32(32) + t1 = xlo * ylo + t2 = xlo*yhi + xhi*ylo + t3 = xhi * yhi + **(**Tuint64_t)(__ccgo_up(lo)) = t1 + t2<>Int32FromInt32(32) + BoolUint64(t1 > **(**Tuint64_t)(__ccgo_up(lo))) +} + +func Xfma(tls *TLS, x1 float64, y float64, z float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v y=%v z=%v, (%v:)", tls, x1, y, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, r float64 + var d, e, nonzero, samesign, sign, v2 int32 + var fltmin float32 + var i Tint64_t + var nx, ny, nz Tnum + var t, zhi, zlo, v1 Tuint64_t + var tiny Tdouble_t + var _ /* rhi at bp+0 */ Tuint64_t + var _ /* rlo at bp+8 */ Tuint64_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, d, e, fltmin, i, nonzero, nx, ny, nz, r, samesign, sign, t, tiny, zhi, zlo, v1, v2 + nx = _normalize(tls, x1) + ny = _normalize(tls, y) + nz = _normalize(tls, z) + if nx.Fe >= Int32FromInt32(0x7ff)-Int32FromInt32(0x3ff)-Int32FromInt32(52)-Int32FromInt32(1) || ny.Fe >= Int32FromInt32(0x7ff)-Int32FromInt32(0x3ff)-Int32FromInt32(52)-Int32FromInt32(1) { + return float64(x1*y) + z + } + if nz.Fe >= Int32FromInt32(0x7ff)-Int32FromInt32(0x3ff)-Int32FromInt32(52)-Int32FromInt32(1) { + if nz.Fe > Int32FromInt32(0x7ff)-Int32FromInt32(0x3ff)-Int32FromInt32(52)-Int32FromInt32(1) { /* z==0 */ + return float64(x1*y) + z + } + return z + } + _mul(tls, bp, bp+8, nx.Fm, ny.Fm) + /* either top 20 or 21 bits of rhi and last 2 bits of rlo are 0 */ + /* align exponents */ + e = nx.Fe + ny.Fe + d = nz.Fe - e + /* shift bits z<<=kz, r>>=kr, so kz+kr == d, set e = e+kr (== ez-kz) */ + if d > 0 { + if d < int32(64) { + zlo = nz.Fm << d + zhi = nz.Fm >> (int32(64) - d) + } else { + zlo = uint64(0) + zhi = nz.Fm + e = nz.Fe - int32(64) + d = d - int32(64) + if d == 0 { + } else { + if d < int32(64) { + **(**Tuint64_t)(__ccgo_up(bp + 8)) = **(**Tuint64_t)(__ccgo_up(bp))<<(int32(64)-d) | **(**Tuint64_t)(__ccgo_up(bp + 8))>>d | BoolUint64(!!(**(**Tuint64_t)(__ccgo_up(bp + 8))<<(Int32FromInt32(64)-d) != 0)) + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp)) >> d + } else { + **(**Tuint64_t)(__ccgo_up(bp + 8)) = uint64(1) + **(**Tuint64_t)(__ccgo_up(bp)) = uint64(0) + } + } + } + } else { + zhi = uint64(0) + d = -d + if d == 0 { + zlo = nz.Fm + } else { + if d < int32(64) { + zlo = nz.Fm>>d | BoolUint64(!!(nz.Fm<<(Int32FromInt32(64)-d) != 0)) + } else { + zlo = uint64(1) + } + } + } + /* add */ + sign = nx.Fsign ^ ny.Fsign + samesign = BoolInt32(!(sign^nz.Fsign != 0)) + nonzero = int32(1) + if samesign != 0 { + /* r += z */ + **(**Tuint64_t)(__ccgo_up(bp + 8)) = **(**Tuint64_t)(__ccgo_up(bp + 8)) + zlo + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp)) + (zhi + BoolUint64(**(**Tuint64_t)(__ccgo_up(bp + 8)) < zlo)) + } else { + /* r -= z */ + t = **(**Tuint64_t)(__ccgo_up(bp + 8)) + **(**Tuint64_t)(__ccgo_up(bp + 8)) = **(**Tuint64_t)(__ccgo_up(bp + 8)) - zlo + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp)) - zhi - BoolUint64(t < **(**Tuint64_t)(__ccgo_up(bp + 8))) + if **(**Tuint64_t)(__ccgo_up(bp))>>int32(63) != 0 { + **(**Tuint64_t)(__ccgo_up(bp + 8)) = -**(**Tuint64_t)(__ccgo_up(bp + 8)) + **(**Tuint64_t)(__ccgo_up(bp)) = -**(**Tuint64_t)(__ccgo_up(bp)) - BoolUint64(!!(**(**Tuint64_t)(__ccgo_up(bp + 8)) != 0)) + sign = BoolInt32(!(sign != 0)) + } + nonzero = BoolInt32(!!(**(**Tuint64_t)(__ccgo_up(bp)) != 0)) + } + /* set rhi to top 63bit of the result (last bit is sticky) */ + if nonzero != 0 { + e = e + int32(64) + v1 = **(**Tuint64_t)(__ccgo_up(bp)) + // __asm__( "bsr %1,%0 ; xor $63,%0" : "=r"(x) : "r"(x) ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 121, __ccgo_ts+583) + v2 = Int32FromUint64(v1) + goto _3 + _3: + d = v2 - int32(1) + /* note: d > 0 */ + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp))<>(int32(64)-d) | BoolUint64(!!(**(**Tuint64_t)(__ccgo_up(bp + 8))<>int32(1) | **(**Tuint64_t)(__ccgo_up(bp + 8))&uint64(1) + } else { + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp + 8)) << d + } + } else { + /* exact +-0 */ + return float64(x1*y) + z + } + } + e = e - d + /* convert to double */ + i = Int64FromUint64(**(**Tuint64_t)(__ccgo_up(bp))) /* i is in [1<<62,(1<<63)-1] */ + if sign != 0 { + i = -i + } + r = float64(i) /* |r| is in [0x1p62,0x1p63] */ + if e < -Int32FromInt32(1022)-Int32FromInt32(62) { + /* result is subnormal before rounding */ + if e == -Int32FromInt32(1022)-Int32FromInt32(63) { + c = float64(9.223372036854776e+18) + if sign != 0 { + c = -c + } + if r == c { + /* min normal after rounding, underflow depends + on arch behaviour which can be imitated by + a double to float conversion */ + fltmin = float32(float64(Float64FromFloat64(1.0842021401737618e-19)*Float64FromFloat32(1.1754943508222875e-38)) * r) + return float64(Float64FromFloat64(2.2250738585072014e-308) / Float64FromFloat32(1.1754943508222875e-38) * float64(fltmin)) + } + /* one bit is lost when scaled, add another top bit to + only round once at conversion if it is inexact */ + if **(**Tuint64_t)(__ccgo_up(bp))<>int32(1)|**(**Tuint64_t)(__ccgo_up(bp))&uint64(1)) | Uint64FromUint64(1)<>d | BoolUint64(!!(**(**Tuint64_t)(__ccgo_up(bp))<<(Int32FromInt32(64)-d) != 0))) << d) + if sign != 0 { + i = -i + } + r = float64(i) + } + } + return Xscalbn(tls, r, e) +} + +const DBL_MIN2 = 0 +const FLT_MIN2 = 0 + +func Xfmal(tls *TLS, x float64, y float64, z float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v z=%v, (%v:)", tls, x, y, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfma(tls, x, y, z) +} + +func Xfmax(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3, v5 uint64 + var v9 float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _ = v1, v3, v5, v9 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != Int32FromUint64(v3>>Int32FromInt32(63)) { + *(*float64)(unsafe.Pointer(bp)) = x + v5 = *(*uint64)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint64(v5>>Int32FromInt32(63)) != 0 { + v9 = y + } else { + v9 = x + } + return v9 + } + if x < y { + v9 = y + } else { + v9 = x + } + return v9 +} + +func Xfmaxf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3, v5 uint32 + var v9 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _ = v1, v3, v5, v9 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return y + } + *(*float32)(unsafe.Pointer(bp)) = y + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 +_4: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + } + /* handle signed zeroes, see C99 Annex F.9.9.2 */ + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _6 +_6: + *(*float32)(unsafe.Pointer(bp)) = y + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _8 +_8: + if Int32FromUint32(v1>>Int32FromInt32(31)) != Int32FromUint32(v3>>Int32FromInt32(31)) { + *(*float32)(unsafe.Pointer(bp)) = x + v5 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v5>>Int32FromInt32(31)) != 0 { + v9 = y + } else { + v9 = x + } + return v9 + } + if x < y { + v9 = y + } else { + v9 = x + } + return v9 +} + +func Xfmaxl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfmax(tls, x, y) +} + +func Xfmin(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3, v5 uint64 + var v9 float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _ = v1, v3, v5, v9 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != Int32FromUint64(v3>>Int32FromInt32(63)) { + *(*float64)(unsafe.Pointer(bp)) = x + v5 = *(*uint64)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint64(v5>>Int32FromInt32(63)) != 0 { + v9 = x + } else { + v9 = y + } + return v9 + } + if x < y { + v9 = x + } else { + v9 = y + } + return v9 +} + +func Xfminf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3, v5 uint32 + var v9 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _ = v1, v3, v5, v9 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return y + } + *(*float32)(unsafe.Pointer(bp)) = y + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 +_4: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + } + /* handle signed zeros, see C99 Annex F.9.9.2 */ + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _6 +_6: + *(*float32)(unsafe.Pointer(bp)) = y + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _8 +_8: + if Int32FromUint32(v1>>Int32FromInt32(31)) != Int32FromUint32(v3>>Int32FromInt32(31)) { + *(*float32)(unsafe.Pointer(bp)) = x + v5 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v5>>Int32FromInt32(31)) != 0 { + v9 = x + } else { + v9 = y + } + return v9 + } + if x < y { + v9 = x + } else { + v9 = y + } + return v9 +} + +func Xfminl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfmin(tls, x, y) +} + +func Xfmod(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ex, ey, sx int32 + var i, uxi Tuint64_t + var v1 uint64 + var v3 bool + var v6 uintptr + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* ux at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+16 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _ = ex, ey, i, sx, uxi, v1, v3, v6 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 16)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 16)) = y + ex = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(52) & uint64(0x7ff)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 16)) >> int32(52) & uint64(0x7ff)) + sx = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(63)) + /* in the followings uxi should be ux.i, but then gcc wrongly adds */ + /* float load/store to inner loops ruining performance and code size */ + uxi = *(*Tuint64_t)(unsafe.Pointer(bp + 8)) + if v3 = *(*Tuint64_t)(unsafe.Pointer(bp + 16))<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>int32(63) == uint64(0)) { + break + } + goto _4 + _4: + ; + ex = ex - 1 + i = i << uint64(1) + } + uxi = uxi << Uint64FromInt32(-ex+int32(1)) + } else { + uxi = uint64(uxi & (-Uint64FromUint64(1) >> Int32FromInt32(12))) + uxi = uint64(uxi | Uint64FromUint64(1)<>int32(63) == uint64(0)) { + break + } + goto _5 + _5: + ; + ey = ey - 1 + i = i << uint64(1) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 16)) <<= Uint64FromInt32(-ey + int32(1)) + } else { + v6 = bp + 16 + *(*Tuint64_t)(unsafe.Pointer(v6)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v6)) & (-Uint64FromUint64(1) >> Int32FromInt32(12))) + v6 = bp + 16 + *(*Tuint64_t)(unsafe.Pointer(v6)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v6)) | Uint64FromUint64(1)< ey) { + break + } + i = uxi - *(*Tuint64_t)(unsafe.Pointer(bp + 16)) + if i>>int32(63) == uint64(0) { + if i == uint64(0) { + return float64(Float64FromInt32(0) * x) + } + uxi = i + } + uxi = uxi << uint64(1) + goto _8 + _8: + ; + ex = ex - 1 + } + i = uxi - *(*Tuint64_t)(unsafe.Pointer(bp + 16)) + if i>>int32(63) == uint64(0) { + if i == uint64(0) { + return float64(Float64FromInt32(0) * x) + } + uxi = i + } + for { + if !(uxi>>int32(52) == uint64(0)) { + break + } + goto _9 + _9: + ; + uxi = uxi << uint64(1) + ex = ex - 1 + } + /* scale result */ + if ex > 0 { + uxi = uint64(uxi - Uint64FromUint64(1)<> Uint64FromInt32(-ex+int32(1)) + } + uxi = uxi | Uint64FromInt32(sx)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ex, ey int32 + var i, sx, uxi Tuint32_t + var v1 uint32 + var v3 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + var _ /* ux at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _ = ex, ey, i, sx, uxi, v1, v3 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = x + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 8)) = y + ex = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 4)) >> int32(23) & uint32(0xff)) + ey = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 8)) >> int32(23) & uint32(0xff)) + sx = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) & uint32(0x80000000) + uxi = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) + if v3 = *(*Tuint32_t)(unsafe.Pointer(bp + 8))< uint32(0x7f800000)) != 0 || ex == int32(0xff) { + return float32(x*y) / float32(x*y) + } + if uxi<>int32(31) == uint32(0)) { + break + } + goto _4 + _4: + ; + ex = ex - 1 + i = i << uint32(1) + } + uxi = uxi << Uint32FromInt32(-ex+int32(1)) + } else { + uxi = uxi & (-Uint32FromUint32(1) >> Int32FromInt32(9)) + uxi = uxi | Uint32FromUint32(1)<>int32(31) == uint32(0)) { + break + } + goto _5 + _5: + ; + ey = ey - 1 + i = i << uint32(1) + } + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) <<= Uint32FromInt32(-ey + int32(1)) + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) &= -Uint32FromUint32(1) >> Int32FromInt32(9) + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) |= Uint32FromUint32(1) << Int32FromInt32(23) + } + /* x mod y */ + for { + if !(ex > ey) { + break + } + i = uxi - *(*Tuint32_t)(unsafe.Pointer(bp + 8)) + if i>>int32(31) == uint32(0) { + if i == uint32(0) { + return float32(Float32FromInt32(0) * x) + } + uxi = i + } + uxi = uxi << uint32(1) + goto _6 + _6: + ; + ex = ex - 1 + } + i = uxi - *(*Tuint32_t)(unsafe.Pointer(bp + 8)) + if i>>int32(31) == uint32(0) { + if i == uint32(0) { + return float32(Float32FromInt32(0) * x) + } + uxi = i + } + for { + if !(uxi>>int32(23) == uint32(0)) { + break + } + goto _7 + _7: + ; + uxi = uxi << uint32(1) + ex = ex - 1 + } + /* scale result up */ + if ex > 0 { + uxi = uxi - Uint32FromUint32(1)<> Uint32FromInt32(-ex+int32(1)) + } + uxi = uxi | sx + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = uxi + return *(*float32)(unsafe.Pointer(bp + 4)) +} + +func Xfmodl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfmod(tls, x, y) +} + +func Xfrexp(tls *TLS, x float64, e uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v e=%v, (%v:)", tls, x, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ee int32 + var v1 uintptr + var _ /* y at bp+0 */ struct { + Fi [0]Tuint64_t + Fd float64 + } + _, _ = ee, v1 + *(*struct { + Fi [0]Tuint64_t + Fd float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Fd float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + ee = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if !(ee != 0) { + if x != 0 { + x = Xfrexp(tls, float64(x*float64(1.8446744073709552e+19)), e) + **(**int32)(__ccgo_up(e)) -= int32(64) + } else { + **(**int32)(__ccgo_up(e)) = 0 + } + return x + } else { + if ee == int32(0x7ff) { + return x + } + } + **(**int32)(__ccgo_up(e)) = ee - int32(0x3fe) + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & Uint64FromUint64(0x800fffffffffffff)) + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) | Uint64FromUint64(0x3fe0000000000000)) + return *(*float64)(unsafe.Pointer(bp)) +} + +func Xfrexpf(tls *TLS, x float32, e uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v e=%v, (%v:)", tls, x, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ee int32 + var v1 uintptr + var _ /* y at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _ = ee, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + ee = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + if !(ee != 0) { + if x != 0 { + x = Xfrexpf(tls, float32(float64(x)*float64(1.8446744073709552e+19)), e) + **(**int32)(__ccgo_up(e)) -= int32(64) + } else { + **(**int32)(__ccgo_up(e)) = 0 + } + return x + } else { + if ee == int32(0xff) { + return x + } + } + **(**int32)(__ccgo_up(e)) = ee - int32(0x7e) + v1 = bp + *(*Tuint32_t)(unsafe.Pointer(v1)) = Tuint32_t(uint64(*(*Tuint32_t)(unsafe.Pointer(v1))) & Uint64FromUint64(0x807fffff)) + v1 = bp + *(*Tuint32_t)(unsafe.Pointer(v1)) = Tuint32_t(uint64(*(*Tuint32_t)(unsafe.Pointer(v1))) | Uint64FromUint64(0x3f000000)) + return *(*float32)(unsafe.Pointer(bp)) +} + +func Xfrexpl(tls *TLS, x float64, e uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v e=%v, (%v:)", tls, x, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfrexp(tls, x, e) +} + +const SPLIT = 1 + +func _sq(tls *TLS, hi uintptr, lo uintptr, x float64) { + var xc, xh, xl Tdouble_t + _, _, _ = xc, xh, xl + xc = Tdouble_t(x * (Float64FromFloat64(1.34217728e+08) + Float64FromInt32(1))) + xh = x - xc + xc + xl = x - xh + **(**Tdouble_t)(__ccgo_up(hi)) = Tdouble_t(x * x) + **(**Tdouble_t)(__ccgo_up(lo)) = Tdouble_t(xh*xh) - **(**Tdouble_t)(__ccgo_up(hi)) + Tdouble_t(Tdouble_t(Float64FromInt32(2)*xh)*xl) + Tdouble_t(xl*xl) +} + +func Xhypot(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var ex, ey int32 + var ut struct { + Fi [0]Tuint64_t + Ff float64 + } + var z Tdouble_t + var v1 uintptr + var _ /* hx at bp+16 */ Tdouble_t + var _ /* hy at bp+32 */ Tdouble_t + var _ /* lx at bp+24 */ Tdouble_t + var _ /* ly at bp+40 */ Tdouble_t + var _ /* ux at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _ = ex, ey, ut, z, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = y + /* arrange |x| >= |y| */ + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (-Uint64FromUint64(1) >> Int32FromInt32(1))) + v1 = bp + 8 + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (-Uint64FromUint64(1) >> Int32FromInt32(1))) + if *(*Tuint64_t)(unsafe.Pointer(bp)) < *(*Tuint64_t)(unsafe.Pointer(bp + 8)) { + ut = **(**struct { + Fi [0]Tuint64_t + Ff float64 + })(__ccgo_up(bp)) + **(**struct { + Fi [0]Tuint64_t + Ff float64 + })(__ccgo_up(bp)) = **(**struct { + Fi [0]Tuint64_t + Ff float64 + })(__ccgo_up(bp + 8)) + **(**struct { + Fi [0]Tuint64_t + Ff float64 + })(__ccgo_up(bp + 8)) = ut + } + /* special cases */ + ex = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(52)) + x = *(*float64)(unsafe.Pointer(bp)) + y = *(*float64)(unsafe.Pointer(bp + 8)) + /* note: hypot(inf,nan) == inf */ + if ey == int32(0x7ff) { + return y + } + if ex == int32(0x7ff) || *(*Tuint64_t)(unsafe.Pointer(bp + 8)) == uint64(0) { + return x + } + /* note: hypot(x,y) ~= x + y*y/x/2 with inexact for small y/x */ + /* 64 difference is enough for ld80 double_t */ + if ex-ey > int32(64) { + return x + y + } + /* precise sqrt argument in nearest rounding mode without overflow */ + /* xh*xh must not overflow and xl*xl must not underflow in sq */ + z = Float64FromInt32(1) + if ex > Int32FromInt32(0x3ff)+Int32FromInt32(510) { + z = float64(5.260135901548374e+210) + x = x * float64(1.90109156629516e-211) + y = y * float64(1.90109156629516e-211) + } else { + if ey < Int32FromInt32(0x3ff)-Int32FromInt32(450) { + z = float64(1.90109156629516e-211) + x = x * float64(5.260135901548374e+210) + y = y * float64(5.260135901548374e+210) + } + } + _sq(tls, bp+16, bp+24, x) + _sq(tls, bp+32, bp+40, y) + return float64(z * Xsqrt(tls, **(**Tdouble_t)(__ccgo_up(bp + 40))+**(**Tdouble_t)(__ccgo_up(bp + 24))+**(**Tdouble_t)(__ccgo_up(bp + 32))+**(**Tdouble_t)(__ccgo_up(bp + 16)))) +} + +func Xhypotf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ut struct { + Fi [0]Tuint32_t + Ff float32 + } + var z Tfloat_t + var _ /* ux at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _ = ut, z + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = y + *(*Tuint32_t)(unsafe.Pointer(bp)) &= -Uint32FromUint32(1) >> Int32FromInt32(1) + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) &= -Uint32FromUint32(1) >> Int32FromInt32(1) + if *(*Tuint32_t)(unsafe.Pointer(bp)) < *(*Tuint32_t)(unsafe.Pointer(bp + 4)) { + ut = **(**struct { + Fi [0]Tuint32_t + Ff float32 + })(__ccgo_up(bp)) + **(**struct { + Fi [0]Tuint32_t + Ff float32 + })(__ccgo_up(bp)) = **(**struct { + Fi [0]Tuint32_t + Ff float32 + })(__ccgo_up(bp + 4)) + **(**struct { + Fi [0]Tuint32_t + Ff float32 + })(__ccgo_up(bp + 4)) = ut + } + x = *(*float32)(unsafe.Pointer(bp)) + y = *(*float32)(unsafe.Pointer(bp + 4)) + if *(*Tuint32_t)(unsafe.Pointer(bp + 4)) == Uint32FromInt32(Int32FromInt32(0xff)<= Uint32FromInt32(Int32FromInt32(0xff)<= Uint32FromInt32(Int32FromInt32(25)<= Uint32FromInt32((Int32FromInt32(0x7f)+Int32FromInt32(60))< %v", r) }() + } + return Xhypot(tls, x, y) +} + +func Xilogb(tls *TLS, x3 float64) (r int32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v2 int32 + var i Tuint64_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = e, i, y, y1, y2, v2 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + i = *(*Tuint64_t)(unsafe.Pointer(bp)) + e = Int32FromUint64(i >> int32(52) & uint64(0x7ff)) + if !(e != 0) { + i = i << uint64(12) + if i == uint64(0) { + if uint64(4) == uint64(4) { + y = Float32FromInt32(0) / Float32FromFloat32(0) + } else { + if uint64(4) == uint64(8) { + y1 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } else { + y2 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } + } + return -Int32FromInt32(1) - Int32FromInt32(0x7fffffff) + } + /* subnormal x */ + e = -int32(0x3ff) + for { + if !(i>>int32(63) == uint64(0)) { + break + } + goto _1 + _1: + ; + e = e - 1 + i = i << uint64(1) + } + return e + } + if e == int32(0x7ff) { + if uint64(4) == uint64(4) { + y = Float32FromInt32(0) / Float32FromFloat32(0) + } else { + if uint64(4) == uint64(8) { + y1 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } else { + y2 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } + } + if i< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v2 int32 + var i Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _ = e, i, y, y1, y2, v2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + i = *(*Tuint32_t)(unsafe.Pointer(bp)) + e = Int32FromUint32(i >> int32(23) & uint32(0xff)) + if !(e != 0) { + i = i << uint32(9) + if i == uint32(0) { + if uint64(4) == uint64(4) { + y = Float32FromInt32(0) / Float32FromFloat32(0) + } else { + if uint64(4) == uint64(8) { + y1 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } else { + y2 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } + } + return -Int32FromInt32(1) - Int32FromInt32(0x7fffffff) + } + /* subnormal x */ + e = -int32(0x7f) + for { + if !(i>>int32(31) == uint32(0)) { + break + } + goto _1 + _1: + ; + e = e - 1 + i = i << uint32(1) + } + return e + } + if e == int32(0xff) { + if uint64(4) == uint64(4) { + y = Float32FromInt32(0) / Float32FromFloat32(0) + } else { + if uint64(4) == uint64(8) { + y1 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } else { + y2 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } + } + if i< %v", r) }() + } + return Xilogb(tls, x) +} + +var _invsqrtpi = float64(0.5641895835477563) /* 0x3FE20DD7, 0x50429B6D */ +var _tpi = float64(0.6366197723675814) /* 0x3FE45F30, 0x6DC9C883 */ + +// C documentation +// +// /* common method when |x|>=2 */ +func _common(tls *TLS, ix Tuint32_t, x float64, y0 int32) (r float64) { + var c, cc, s, ss, z float64 + _, _, _, _, _ = c, cc, s, ss, z + /* + * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x-pi/4)-q0(x)*sin(x-pi/4)) + * y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x-pi/4)+q0(x)*cos(x-pi/4)) + * + * sin(x-pi/4) = (sin(x) - cos(x))/sqrt(2) + * cos(x-pi/4) = (sin(x) + cos(x))/sqrt(2) + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + */ + s = Xsin(tls, x) + c = Xcos(tls, x) + if y0 != 0 { + c = -c + } + cc = s + c + /* avoid overflow in 2*x, big ulp error when x>=0x1p1023 */ + if ix < uint32(0x7fe00000) { + ss = s - c + z = -Xcos(tls, float64(Float64FromInt32(2)*x)) + if float64(s*c) < Float64FromInt32(0) { + cc = z / ss + } else { + ss = z / cc + } + if ix < uint32(0x48000000) { + if y0 != 0 { + ss = -ss + } + cc = float64(_pzero(tls, x)*cc) - float64(_qzero(tls, x)*ss) + } + } + return float64(_invsqrtpi*cc) / Xsqrt(tls, x) +} + +// C documentation +// +// /* R0/S0 on [0, 2.00] */ + +var _R02 = float64(0.015624999999999995) /* 0x3F8FFFFF, 0xFFFFFFFD */ +var _R03 = -Float64FromFloat64(0.00018997929423885472) /* 0xBF28E6A5, 0xB61AC6E9 */ +var _R04 = float64(1.8295404953270067e-06) /* 0x3EBEB1D1, 0x0C503919 */ +var _R05 = -Float64FromFloat64(4.618326885321032e-09) /* 0xBE33D5E7, 0x73D63FCE */ +var _S01 = float64(0.015619102946489001) /* 0x3F8FFCE8, 0x82C8C2A4 */ +var _S02 = float64(0.00011692678466333745) /* 0x3F1EA6D2, 0xDD57DBF4 */ +var _S03 = float64(5.135465502073181e-07) /* 0x3EA13B54, 0xCE84D5A9 */ +var _S04 = float64(1.1661400333379e-09) /* 0x3E1408BC, 0xF4745D8F */ + +func Xj0(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, z float64 + _, _, _, _ = ix, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* j0(+-inf)=0, j0(nan)=nan */ + if ix >= uint32(0x7ff00000) { + return Float64FromInt32(1) / float64(x*x) + } + x = Xfabs(tls, x) + if ix >= uint32(0x40000000) { /* |x| >= 2 */ + /* large ulp error near zeros: 2.4, 5.52, 8.6537,.. */ + return _common(tls, ix, x, 0) + } + /* 1 - x*x/4 + x*x*R(x^2)/S(x^2) */ + if ix >= uint32(0x3f200000) { /* |x| >= 2**-13 */ + /* up to 4ulp error close to 2 */ + z = float64(x * x) + r = float64(z * (_R02 + float64(z*(_R03+float64(z*(_R04+float64(z*_R05))))))) + s = Float64FromInt32(1) + float64(z*(_S01+float64(z*(_S02+float64(z*(_S03+float64(z*_S04))))))) + return float64((Float64FromInt32(1)+x/Float64FromInt32(2))*(Float64FromInt32(1)-x/Float64FromInt32(2))) + float64(z*(r/s)) + } + /* 1 - x*x/4 */ + /* prevent underflow */ + /* inexact should be raised when x!=0, this is not done correctly */ + if ix >= uint32(0x38000000) { /* |x| >= 2**-127 */ + x = float64(float64(float64(0.25)*x) * x) + } + return Float64FromInt32(1) - x +} + +var _u00 = -Float64FromFloat64(0.07380429510868723) /* 0xBFB2E4D6, 0x99CBD01F */ +var _u01 = float64(0.17666645250918112) /* 0x3FC69D01, 0x9DE9E3FC */ +var _u02 = -Float64FromFloat64(0.01381856719455969) /* 0xBF8C4CE8, 0xB16CFA97 */ +var _u03 = float64(0.00034745343209368365) /* 0x3F36C54D, 0x20B29B6B */ +var _u04 = -Float64FromFloat64(3.8140705372436416e-06) /* 0xBECFFEA7, 0x73D25CAD */ +var _u05 = float64(1.9559013703502292e-08) /* 0x3E550057, 0x3B4EABD4 */ +var _u06 = -Float64FromFloat64(3.982051941321034e-11) /* 0xBDC5E43D, 0x693FB3C8 */ +var _v01 = float64(0.01273048348341237) /* 0x3F8A1270, 0x91C9C71A */ +var _v02 = float64(7.600686273503533e-05) /* 0x3F13ECBB, 0xF578C6C1 */ +var _v03 = float64(2.591508518404578e-07) /* 0x3E91642D, 0x7FF202FD */ +var _v04 = float64(4.4111031133267547e-10) /* 0x3DFE5018, 0x3BD6D9EF */ + +func Xy0(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u Tuint64_t + var ix, lx Tuint32_t + var u, v, z float64 + _, _, _, _, _, _ = __u, ix, lx, u, v, z + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + ix = uint32(__u >> int32(32)) + lx = uint32(__u) + /* y0(nan)=nan, y0(<0)=nan, y0(0)=-inf, y0(inf)=0 */ + if ix<>int32(31) != 0 { + return Float64FromInt32(0) / Float64FromFloat64(0) + } + if ix >= uint32(0x7ff00000) { + return Float64FromInt32(1) / x + } + if ix >= uint32(0x40000000) { /* x >= 2 */ + /* large ulp errors near zeros: 3.958, 7.086,.. */ + return _common(tls, ix, x, int32(1)) + } + /* U(x^2)/V(x^2) + (2/pi)*j0(x)*log(x) */ + if ix >= uint32(0x3e400000) { /* x >= 2**-27 */ + /* large ulp error near the first zero, x ~= 0.89 */ + z = float64(x * x) + u = _u00 + float64(z*(_u01+float64(z*(_u02+float64(z*(_u03+float64(z*(_u04+float64(z*(_u05+float64(z*_u06))))))))))) + v = float64(1) + float64(z*(_v01+float64(z*(_v02+float64(z*(_v03+float64(z*_v04))))))) + return u/v + float64(_tpi*float64(Xj0(tls, x)*Xlog(tls, x))) + } + return _u00 + float64(_tpi*Xlog(tls, x)) +} + +// C documentation +// +// /* The asymptotic expansions of pzero is +// * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. +// * For x >= 2, We approximate pzero by +// * pzero(x) = 1 + (R/S) +// * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 +// * S = 1 + pS0*s^2 + ... + pS4*s^10 +// * and +// * | pzero(x)-1-R/S | <= 2 ** ( -60.26) +// */ +var _pR8 = [6]float64{ + 1: -Float64FromFloat64(0.07031249999999004), + 2: -Float64FromFloat64(8.081670412753498), + 3: -Float64FromFloat64(257.06310567970485), + 4: -Float64FromFloat64(2485.216410094288), + 5: -Float64FromFloat64(5253.043804907295), +} +var _pS8 = [5]float64{ + 0: float64(116.53436461966818), + 1: float64(3833.7447536412183), + 2: float64(40597.857264847255), + 3: float64(116752.97256437592), + 4: float64(47627.728414673096), +} + +var _pR5 = [6]float64{ + 0: -Float64FromFloat64(1.141254646918945e-11), + 1: -Float64FromFloat64(0.07031249408735993), + 2: -Float64FromFloat64(4.159610644705878), + 3: -Float64FromFloat64(67.67476522651673), + 4: -Float64FromFloat64(331.23129964917297), + 5: -Float64FromFloat64(346.4333883656049), +} +var _pS52 = [5]float64{ + 0: float64(60.753938269230034), + 1: float64(1051.2523059570458), + 2: float64(5978.970943338558), + 3: float64(9625.445143577745), + 4: float64(2406.058159229391), +} + +var _pR3 = [6]float64{ + 0: -Float64FromFloat64(2.547046017719519e-09), + 1: -Float64FromFloat64(0.07031196163814817), + 2: -Float64FromFloat64(2.409032215495296), + 3: -Float64FromFloat64(21.96597747348831), + 4: -Float64FromFloat64(58.07917047017376), + 5: -Float64FromFloat64(31.44794705948885), +} +var _pS32 = [5]float64{ + 0: float64(35.85603380552097), + 1: float64(361.51398305030386), + 2: float64(1193.6078379211153), + 3: float64(1127.9967985690741), + 4: float64(173.58093081333575), +} + +var _pR2 = [6]float64{ + 0: -Float64FromFloat64(8.875343330325264e-08), + 1: -Float64FromFloat64(0.07030309954836247), + 2: -Float64FromFloat64(1.4507384678095299), + 3: -Float64FromFloat64(7.635696138235278), + 4: -Float64FromFloat64(11.193166886035675), + 5: -Float64FromFloat64(3.2336457935133534), +} +var _pS24 = [5]float64{ + 0: float64(22.22029975320888), + 1: float64(136.2067942182152), + 2: float64(270.4702786580835), + 3: float64(153.87539420832033), + 4: float64(14.65761769482562), +} + +func _pzero(tls *TLS, x float64) (r1 float64) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tdouble_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x40200000) { + p = uintptr(unsafe.Pointer(&_pR8)) + q = uintptr(unsafe.Pointer(&_pS8)) + } else { + if ix >= uint32(0x40122E8B) { + p = uintptr(unsafe.Pointer(&_pR5)) + q = uintptr(unsafe.Pointer(&_pS52)) + } else { + if ix >= uint32(0x4006DB6D) { + p = uintptr(unsafe.Pointer(&_pR3)) + q = uintptr(unsafe.Pointer(&_pS32)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_pR2)) + q = uintptr(unsafe.Pointer(&_pS24)) + } + } + } + z = float64(1) / float64(x*x) + r = **(**float64)(__ccgo_up(p)) + float64(z*(**(**float64)(__ccgo_up(p + 1*8))+float64(z*(**(**float64)(__ccgo_up(p + 2*8))+float64(z*(**(**float64)(__ccgo_up(p + 3*8))+float64(z*(**(**float64)(__ccgo_up(p + 4*8))+float64(z***(**float64)(__ccgo_up(p + 5*8))))))))))) + s = float64(1) + float64(z*(**(**float64)(__ccgo_up(q))+float64(z*(**(**float64)(__ccgo_up(q + 1*8))+float64(z*(**(**float64)(__ccgo_up(q + 2*8))+float64(z*(**(**float64)(__ccgo_up(q + 3*8))+float64(z***(**float64)(__ccgo_up(q + 4*8))))))))))) + return float64(1) + r/s +} + +// C documentation +// +// /* For x >= 8, the asymptotic expansions of qzero is +// * -1/8 s + 75/1024 s^3 - ..., where s = 1/x. +// * We approximate pzero by +// * qzero(x) = s*(-1.25 + (R/S)) +// * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 +// * S = 1 + qS0*s^2 + ... + qS5*s^12 +// * and +// * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) +// */ +var _qR8 = [6]float64{ + 1: float64(0.0732421874999935), + 2: float64(11.76820646822527), + 3: float64(557.6733802564019), + 4: float64(8859.197207564686), + 5: float64(37014.62677768878), +} +var _qS8 = [6]float64{ + 0: float64(163.77602689568982), + 1: float64(8098.344946564498), + 2: float64(142538.29141912048), + 3: float64(803309.2571195144), + 4: float64(840501.5798190605), + 5: -Float64FromFloat64(343899.2935378666), +} + +var _qR5 = [6]float64{ + 0: float64(1.8408596359451553e-11), + 1: float64(0.07324217666126848), + 2: float64(5.8356350896205695), + 3: float64(135.11157728644983), + 4: float64(1027.243765961641), + 5: float64(1989.9778586460538), +} +var _qS5 = [6]float64{ + 0: float64(82.77661022365378), + 1: float64(2077.81416421393), + 2: float64(18847.28877857181), + 3: float64(56751.11228949473), + 4: float64(35976.75384251145), + 5: -Float64FromFloat64(5354.342756019448), +} + +var _qR3 = [6]float64{ + 0: float64(4.377410140897386e-09), + 1: float64(0.07324111800429114), + 2: float64(3.344231375161707), + 3: float64(42.621844074541265), + 4: float64(170.8080913405656), + 5: float64(166.73394869665117), +} +var _qS32 = [6]float64{ + 0: float64(48.75887297245872), + 1: float64(709.689221056606), + 2: float64(3704.1482262011136), + 3: float64(6460.425167525689), + 4: float64(2516.3336892036896), + 5: -Float64FromFloat64(149.2474518361564), +} + +var _qR2 = [6]float64{ + 0: float64(1.5044444488698327e-07), + 1: float64(0.07322342659630793), + 2: float64(1.99819174093816), + 3: float64(14.495602934788574), + 4: float64(31.666231750478154), + 5: float64(16.252707571092927), +} +var _qS22 = [6]float64{ + 0: float64(30.36558483552192), + 1: float64(269.34811860804984), + 2: float64(844.7837575953201), + 3: float64(882.9358451124886), + 4: float64(212.66638851179883), + 5: -Float64FromFloat64(5.3109549388266695), +} + +func _qzero(tls *TLS, x float64) (r1 float64) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tdouble_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x40200000) { + p = uintptr(unsafe.Pointer(&_qR8)) + q = uintptr(unsafe.Pointer(&_qS8)) + } else { + if ix >= uint32(0x40122E8B) { + p = uintptr(unsafe.Pointer(&_qR5)) + q = uintptr(unsafe.Pointer(&_qS5)) + } else { + if ix >= uint32(0x4006DB6D) { + p = uintptr(unsafe.Pointer(&_qR3)) + q = uintptr(unsafe.Pointer(&_qS32)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_qR2)) + q = uintptr(unsafe.Pointer(&_qS22)) + } + } + } + z = float64(1) / float64(x*x) + r = **(**float64)(__ccgo_up(p)) + float64(z*(**(**float64)(__ccgo_up(p + 1*8))+float64(z*(**(**float64)(__ccgo_up(p + 2*8))+float64(z*(**(**float64)(__ccgo_up(p + 3*8))+float64(z*(**(**float64)(__ccgo_up(p + 4*8))+float64(z***(**float64)(__ccgo_up(p + 5*8))))))))))) + s = float64(1) + float64(z*(**(**float64)(__ccgo_up(q))+float64(z*(**(**float64)(__ccgo_up(q + 1*8))+float64(z*(**(**float64)(__ccgo_up(q + 2*8))+float64(z*(**(**float64)(__ccgo_up(q + 3*8))+float64(z*(**(**float64)(__ccgo_up(q + 4*8))+float64(z***(**float64)(__ccgo_up(q + 5*8))))))))))))) + return (-Float64FromFloat64(0.125) + r/s) / x +} + +var _invsqrtpi1 = float32(0.56418961287) /* 0x3f106ebb */ +var _tpi1 = float32(0.63661974669) /* 0x3f22f983 */ + +func _common1(tls *TLS, ix Tuint32_t, x float32, y0 int32) (r float32) { + var c, cc, s, ss, z float32 + _, _, _, _, _ = c, cc, s, ss, z + /* + * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) + * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) + */ + s = Xsinf(tls, x) + c = Xcosf(tls, x) + if y0 != 0 { + c = -c + } + cc = s + c + if ix < uint32(0x7f000000) { + ss = s - c + z = -Xcosf(tls, float32(Float32FromInt32(2)*x)) + if float32(s*c) < Float32FromInt32(0) { + cc = z / ss + } else { + ss = z / cc + } + if ix < uint32(0x58800000) { + if y0 != 0 { + ss = -ss + } + cc = float32(_pzerof(tls, x)*cc) - float32(_qzerof(tls, x)*ss) + } + } + return float32(_invsqrtpi1*cc) / Xsqrtf(tls, x) +} + +// C documentation +// +// /* R0/S0 on [0, 2.00] */ + +var _R021 = float32(0.015625) /* 0x3c800000 */ +var _R031 = float32(-Float64FromFloat64(0.00018997929874)) /* 0xb947352e */ +var _R041 = float32(1.8295404516e-06) /* 0x35f58e88 */ +var _R051 = float32(-Float64FromFloat64(4.6183270541e-09)) /* 0xb19eaf3c */ +var _S011 = float32(0.015619102865) /* 0x3c7fe744 */ +var _S021 = float32(0.00011692678527) /* 0x38f53697 */ +var _S031 = float32(5.1354652442e-07) /* 0x3509daa6 */ +var _S041 = float32(1.1661400734e-09) /* 0x30a045e8 */ + +func Xj0f(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, z float32 + _, _, _, _ = ix, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + return Float32FromInt32(1) / float32(x*x) + } + x = Xfabsf(tls, x) + if ix >= uint32(0x40000000) { /* |x| >= 2 */ + /* large ulp error near zeros */ + return _common1(tls, ix, x, 0) + } + if ix >= uint32(0x3a000000) { /* |x| >= 2**-11 */ + /* up to 4ulp error near 2 */ + z = float32(x * x) + r = float32(z * (_R021 + float32(z*(_R031+float32(z*(_R041+float32(z*_R051))))))) + s = Float32FromInt32(1) + float32(z*(_S011+float32(z*(_S021+float32(z*(_S031+float32(z*_S041))))))) + return float32((Float32FromInt32(1)+x/Float32FromInt32(2))*(Float32FromInt32(1)-x/Float32FromInt32(2))) + float32(z*(r/s)) + } + if ix >= uint32(0x21800000) { /* |x| >= 2**-60 */ + x = float32(float32(Float32FromFloat32(0.25)*x) * x) + } + return Float32FromInt32(1) - x +} + +var _u001 = float32(-Float64FromFloat64(0.073804296553)) /* 0xbd9726b5 */ +var _u011 = float32(0.17666645348) /* 0x3e34e80d */ +var _u021 = float32(-Float64FromFloat64(0.013818567619)) /* 0xbc626746 */ +var _u031 = float32(0.00034745343146) /* 0x39b62a69 */ +var _u041 = float32(-Float64FromFloat64(3.8140706238e-06)) /* 0xb67ff53c */ +var _u051 = float32(1.9559013964e-08) /* 0x32a802ba */ +var _u061 = float32(-Float64FromFloat64(3.982051841e-11)) /* 0xae2f21eb */ +var _v011 = float32(0.012730483897) /* 0x3c509385 */ +var _v021 = float32(7.6006865129e-05) /* 0x389f65e0 */ +var _v031 = float32(2.5915085189e-07) /* 0x348b216c */ +var _v041 = float32(4.4111031494e-10) /* 0x2ff280c2 */ + +func Xy0f(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ix Tuint32_t + var u, v, z float32 + _, _, _, _ = ix, u, v, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + if ix&uint32(0x7fffffff) == uint32(0) { + return float32(-Int32FromInt32(1)) / Float32FromFloat32(0) + } + if ix>>int32(31) != 0 { + return Float32FromInt32(0) / Float32FromFloat32(0) + } + if ix >= uint32(0x7f800000) { + return Float32FromInt32(1) / x + } + if ix >= uint32(0x40000000) { /* |x| >= 2.0 */ + /* large ulp error near zeros */ + return _common1(tls, ix, x, int32(1)) + } + if ix >= uint32(0x39000000) { /* x >= 2**-13 */ + /* large ulp error at x ~= 0.89 */ + z = float32(x * x) + u = _u001 + float32(z*(_u011+float32(z*(_u021+float32(z*(_u031+float32(z*(_u041+float32(z*(_u051+float32(z*_u061))))))))))) + v = Float32FromInt32(1) + float32(z*(_v011+float32(z*(_v021+float32(z*(_v031+float32(z*_v041))))))) + return u/v + float32(_tpi1*float32(Xj0f(tls, x)*Xlogf(tls, x))) + } + return _u001 + float32(_tpi1*Xlogf(tls, x)) +} + +// C documentation +// +// /* The asymptotic expansions of pzero is +// * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. +// * For x >= 2, We approximate pzero by +// * pzero(x) = 1 + (R/S) +// * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 +// * S = 1 + pS0*s^2 + ... + pS4*s^10 +// * and +// * | pzero(x)-1-R/S | <= 2 ** ( -60.26) +// */ +var _pR81 = [6]float32{ + 1: float32(-Float64FromFloat64(0.0703125)), + 2: float32(-Float64FromFloat64(8.0816707611)), + 3: float32(-Float64FromFloat64(257.06311035)), + 4: float32(-Float64FromFloat64(2485.2163086)), + 5: float32(-Float64FromFloat64(5253.0439453)), +} +var _pS81 = [5]float32{ + 0: float32(116.53436279), + 1: float32(3833.744873), + 2: float32(40597.855469), + 3: float32(116752.96875), + 4: float32(47627.726562), +} +var _pR51 = [6]float32{ + 0: float32(-Float64FromFloat64(1.1412546255e-11)), + 1: float32(-Float64FromFloat64(0.070312492549)), + 2: float32(-Float64FromFloat64(4.1596107483)), + 3: float32(-Float64FromFloat64(67.674766541)), + 4: float32(-Float64FromFloat64(331.23129272)), + 5: float32(-Float64FromFloat64(346.43338013)), +} +var _pS53 = [5]float32{ + 0: float32(60.753936768), + 1: float32(1051.2523193), + 2: float32(5978.9707031), + 3: float32(9625.4453125), + 4: float32(2406.0581055), +} + +var _pR31 = [6]float32{ + 0: float32(-Float64FromFloat64(2.5470459075e-09)), + 1: float32(-Float64FromFloat64(0.070311963558)), + 2: float32(-Float64FromFloat64(2.4090321064)), + 3: float32(-Float64FromFloat64(21.965976715)), + 4: float32(-Float64FromFloat64(58.079170227)), + 5: float32(-Float64FromFloat64(31.447946548)), +} +var _pS33 = [5]float32{ + 0: float32(35.856033325), + 1: float32(361.51397705), + 2: float32(1193.6077881), + 3: float32(1127.9968262), + 4: float32(173.58093262), +} + +var _pR21 = [6]float32{ + 0: float32(-Float64FromFloat64(8.8753431271e-08)), + 1: float32(-Float64FromFloat64(0.070303097367)), + 2: float32(-Float64FromFloat64(1.45073843)), + 3: float32(-Float64FromFloat64(7.6356959343)), + 4: float32(-Float64FromFloat64(11.193166733)), + 5: float32(-Float64FromFloat64(3.2336456776)), +} +var _pS25 = [5]float32{ + 0: float32(22.220300674), + 1: float32(136.20678711), + 2: float32(270.47027588), + 3: float32(153.87539673), + 4: float32(14.657617569), +} + +func _pzerof(tls *TLS, x float32) (r1 float32) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tfloat_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x41000000) { + p = uintptr(unsafe.Pointer(&_pR81)) + q = uintptr(unsafe.Pointer(&_pS81)) + } else { + if ix >= uint32(0x409173eb) { + p = uintptr(unsafe.Pointer(&_pR51)) + q = uintptr(unsafe.Pointer(&_pS53)) + } else { + if ix >= uint32(0x4036d917) { + p = uintptr(unsafe.Pointer(&_pR31)) + q = uintptr(unsafe.Pointer(&_pS33)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_pR21)) + q = uintptr(unsafe.Pointer(&_pS25)) + } + } + } + z = Float32FromFloat32(1) / float32(x*x) + r = **(**float32)(__ccgo_up(p)) + float32(z*(**(**float32)(__ccgo_up(p + 1*4))+float32(z*(**(**float32)(__ccgo_up(p + 2*4))+float32(z*(**(**float32)(__ccgo_up(p + 3*4))+float32(z*(**(**float32)(__ccgo_up(p + 4*4))+float32(z***(**float32)(__ccgo_up(p + 5*4))))))))))) + s = Float32FromFloat32(1) + float32(z*(**(**float32)(__ccgo_up(q))+float32(z*(**(**float32)(__ccgo_up(q + 1*4))+float32(z*(**(**float32)(__ccgo_up(q + 2*4))+float32(z*(**(**float32)(__ccgo_up(q + 3*4))+float32(z***(**float32)(__ccgo_up(q + 4*4))))))))))) + return Float32FromFloat32(1) + r/s +} + +// C documentation +// +// /* For x >= 8, the asymptotic expansions of qzero is +// * -1/8 s + 75/1024 s^3 - ..., where s = 1/x. +// * We approximate pzero by +// * qzero(x) = s*(-1.25 + (R/S)) +// * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 +// * S = 1 + qS0*s^2 + ... + qS5*s^12 +// * and +// * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) +// */ +var _qR81 = [6]float32{ + 1: float32(0.0732421875), + 2: float32(11.768206596), + 3: float32(557.67340088), + 4: float32(8859.1972656), + 5: float32(37014.625), +} +var _qS81 = [6]float32{ + 0: float32(163.77603149), + 1: float32(8098.3447266), + 2: float32(142538.29688), + 3: float32(803309.25), + 4: float32(840501.5625), + 5: float32(-Float64FromFloat64(343899.28125)), +} + +var _qR51 = [6]float32{ + 0: float32(1.8408595828e-11), + 1: float32(0.073242180049), + 2: float32(5.8356351852), + 3: float32(135.11157227), + 4: float32(1027.2437744), + 5: float32(1989.9779053), +} +var _qS51 = [6]float32{ + 0: float32(82.776611328), + 1: float32(2077.814209), + 2: float32(18847.289062), + 3: float32(56751.113281), + 4: float32(35976.753906), + 5: float32(-Float64FromFloat64(5354.3427734)), +} + +var _qR31 = [6]float32{ + 0: float32(4.37740999e-09), + 1: float32(0.073241114616), + 2: float32(3.3442313671), + 3: float32(42.621845245), + 4: float32(170.80809021), + 5: float32(166.73394775), +} +var _qS33 = [6]float32{ + 0: float32(48.758872986), + 1: float32(709.68920898), + 2: float32(3704.1481934), + 3: float32(6460.425293), + 4: float32(2516.3337402), + 5: float32(-Float64FromFloat64(149.24745178)), +} + +var _qR21 = [6]float32{ + 0: float32(1.5044444979e-07), + 1: float32(0.073223426938), + 2: float32(1.9981917143), + 3: float32(14.495602608), + 4: float32(31.666231155), + 5: float32(16.252708435), +} +var _qS23 = [6]float32{ + 0: float32(30.365585327), + 1: float32(269.34811401), + 2: float32(844.78375244), + 3: float32(882.93585205), + 4: float32(212.66638184), + 5: float32(-Float64FromFloat64(5.3109550476)), +} + +func _qzerof(tls *TLS, x float32) (r1 float32) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tfloat_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x41000000) { + p = uintptr(unsafe.Pointer(&_qR81)) + q = uintptr(unsafe.Pointer(&_qS81)) + } else { + if ix >= uint32(0x409173eb) { + p = uintptr(unsafe.Pointer(&_qR51)) + q = uintptr(unsafe.Pointer(&_qS51)) + } else { + if ix >= uint32(0x4036d917) { + p = uintptr(unsafe.Pointer(&_qR31)) + q = uintptr(unsafe.Pointer(&_qS33)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_qR21)) + q = uintptr(unsafe.Pointer(&_qS23)) + } + } + } + z = Float32FromFloat32(1) / float32(x*x) + r = **(**float32)(__ccgo_up(p)) + float32(z*(**(**float32)(__ccgo_up(p + 1*4))+float32(z*(**(**float32)(__ccgo_up(p + 2*4))+float32(z*(**(**float32)(__ccgo_up(p + 3*4))+float32(z*(**(**float32)(__ccgo_up(p + 4*4))+float32(z***(**float32)(__ccgo_up(p + 5*4))))))))))) + s = Float32FromFloat32(1) + float32(z*(**(**float32)(__ccgo_up(q))+float32(z*(**(**float32)(__ccgo_up(q + 1*4))+float32(z*(**(**float32)(__ccgo_up(q + 2*4))+float32(z*(**(**float32)(__ccgo_up(q + 3*4))+float32(z*(**(**float32)(__ccgo_up(q + 4*4))+float32(z***(**float32)(__ccgo_up(q + 5*4))))))))))))) + return (-Float32FromFloat32(0.125) + r/s) / x +} + +var _invsqrtpi2 = float64(0.5641895835477563) /* 0x3FE20DD7, 0x50429B6D */ +var _tpi2 = float64(0.6366197723675814) /* 0x3FE45F30, 0x6DC9C883 */ + +func _common2(tls *TLS, ix Tuint32_t, x float64, y1 int32, sign int32) (r float64) { + var c, cc, s, ss, z float64 + _, _, _, _, _ = c, cc, s, ss, z + /* + * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x-3pi/4)-q1(x)*sin(x-3pi/4)) + * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x-3pi/4)+q1(x)*cos(x-3pi/4)) + * + * sin(x-3pi/4) = -(sin(x) + cos(x))/sqrt(2) + * cos(x-3pi/4) = (sin(x) - cos(x))/sqrt(2) + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + */ + s = Xsin(tls, x) + if y1 != 0 { + s = -s + } + c = Xcos(tls, x) + cc = s - c + if ix < uint32(0x7fe00000) { + /* avoid overflow in 2*x */ + ss = -s - c + z = Xcos(tls, float64(Float64FromInt32(2)*x)) + if float64(s*c) > Float64FromInt32(0) { + cc = z / ss + } else { + ss = z / cc + } + if ix < uint32(0x48000000) { + if y1 != 0 { + ss = -ss + } + cc = float64(_pone(tls, x)*cc) - float64(_qone(tls, x)*ss) + } + } + if sign != 0 { + cc = -cc + } + return float64(_invsqrtpi2*cc) / Xsqrt(tls, x) +} + +// C documentation +// +// /* R0/S0 on [0,2] */ + +var _r00 = -Float64FromFloat64(0.0625) /* 0xBFB00000, 0x00000000 */ +var _r01 = float64(0.001407056669551897) /* 0x3F570D9F, 0x98472C61 */ +var _r02 = -Float64FromFloat64(1.599556310840356e-05) /* 0xBEF0C5C6, 0xBA169668 */ +var _r03 = float64(4.9672799960958445e-08) /* 0x3E6AAAFA, 0x46CA0BD9 */ +var _s01 = float64(0.019153759953836346) /* 0x3F939D0B, 0x12637E53 */ +var _s02 = float64(0.00018594678558863092) /* 0x3F285F56, 0xB9CDF664 */ +var _s03 = float64(1.1771846404262368e-06) /* 0x3EB3BFF8, 0x333F8498 */ +var _s04 = float64(5.0463625707621704e-09) /* 0x3E35AC88, 0xC97DFF2C */ +var _s05 = float64(1.2354227442613791e-11) /* 0x3DAB2ACF, 0xCFB97ED8 */ + +func Xj1(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, z float64 + var sign int32 + _, _, _, _, _ = ix, r, s, sign, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7ff00000) { + return Float64FromInt32(1) / float64(x*x) + } + if ix >= uint32(0x40000000) { /* |x| >= 2 */ + return _common2(tls, ix, Xfabs(tls, x), 0, sign) + } + if ix >= uint32(0x38000000) { /* |x| >= 2**-127 */ + z = float64(x * x) + r = float64(z * (_r00 + float64(z*(_r01+float64(z*(_r02+float64(z*_r03))))))) + s = Float64FromInt32(1) + float64(z*(_s01+float64(z*(_s02+float64(z*(_s03+float64(z*(_s04+float64(z*_s05))))))))) + z = r / s + } else { + /* avoid underflow, raise inexact if x!=0 */ + z = x + } + return float64((float64(0.5) + z) * x) +} + +var _U0 = [5]float64{ + 0: -Float64FromFloat64(0.19605709064623894), + 1: float64(0.05044387166398113), + 2: -Float64FromFloat64(0.0019125689587576355), + 3: float64(2.352526005616105e-05), + 4: -Float64FromFloat64(9.190991580398789e-08), +} +var _V0 = [5]float64{ + 0: float64(0.01991673182366499), + 1: float64(0.00020255258102513517), + 2: float64(1.3560880109751623e-06), + 3: float64(6.227414523646215e-09), + 4: float64(1.6655924620799208e-11), +} + +func Xy1(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u Tuint64_t + var ix, lx Tuint32_t + var u, v, z float64 + _, _, _, _, _, _ = __u, ix, lx, u, v, z + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + ix = uint32(__u >> int32(32)) + lx = uint32(__u) + /* y1(nan)=nan, y1(<0)=nan, y1(0)=-inf, y1(inf)=0 */ + if ix<>int32(31) != 0 { + return Float64FromInt32(0) / Float64FromFloat64(0) + } + if ix >= uint32(0x7ff00000) { + return Float64FromInt32(1) / x + } + if ix >= uint32(0x40000000) { /* x >= 2 */ + return _common2(tls, ix, x, int32(1), 0) + } + if ix < uint32(0x3c900000) { /* x < 2**-54 */ + return -_tpi2 / x + } + z = float64(x * x) + u = _U0[0] + float64(z*(_U0[int32(1)]+float64(z*(_U0[int32(2)]+float64(z*(_U0[int32(3)]+float64(z*_U0[int32(4)]))))))) + v = Float64FromInt32(1) + float64(z*(_V0[0]+float64(z*(_V0[int32(1)]+float64(z*(_V0[int32(2)]+float64(z*(_V0[int32(3)]+float64(z*_V0[int32(4)]))))))))) + return float64(x*(u/v)) + float64(_tpi2*(float64(Xj1(tls, x)*Xlog(tls, x))-Float64FromInt32(1)/x)) +} + +/* For x >= 8, the asymptotic expansions of pone is + * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. + * We approximate pone by + * pone(x) = 1 + (R/S) + * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 + * S = 1 + ps0*s^2 + ... + ps4*s^10 + * and + * | pone(x)-1-R/S | <= 2 ** ( -60.06) + */ + +var _pr8 = [6]float64{ + 1: float64(0.11718749999998865), + 2: float64(13.239480659307358), + 3: float64(412.05185430737856), + 4: float64(3874.7453891396053), + 5: float64(7914.479540318917), +} +var _ps8 = [5]float64{ + 0: float64(114.20737037567841), + 1: float64(3650.9308342085346), + 2: float64(36956.206026903346), + 3: float64(97602.79359349508), + 4: float64(30804.27206278888), +} + +var _pr5 = [6]float64{ + 0: float64(1.3199051955624352e-11), + 1: float64(0.1171874931906141), + 2: float64(6.802751278684329), + 3: float64(108.30818299018911), + 4: float64(517.6361395331998), + 5: float64(528.7152013633375), +} +var _ps5 = [5]float64{ + 0: float64(59.28059872211313), + 1: float64(991.4014187336144), + 2: float64(5353.26695291488), + 3: float64(7844.690317495512), + 4: float64(1504.0468881036106), +} + +var _pr3 = [6]float64{ + 0: float64(3.025039161373736e-09), + 1: float64(0.11718686556725359), + 2: float64(3.9329775003331564), + 3: float64(35.11940355916369), + 4: float64(91.05501107507813), + 5: float64(48.55906851973649), +} +var _ps3 = [5]float64{ + 0: float64(34.79130950012515), + 1: float64(336.76245874782575), + 2: float64(1046.8713997577513), + 3: float64(890.8113463982564), + 4: float64(103.78793243963928), +} + +var _pr2 = [6]float64{ + 0: float64(1.0771083010687374e-07), + 1: float64(0.11717621946268335), + 2: float64(2.368514966676088), + 3: float64(12.242610914826123), + 4: float64(17.693971127168773), + 5: float64(5.073523125888185), +} +var _ps2 = [5]float64{ + 0: float64(21.43648593638214), + 1: float64(125.29022716840275), + 2: float64(232.2764690571628), + 3: float64(117.6793732871471), + 4: float64(8.364638933716183), +} + +func _pone(tls *TLS, x float64) (r1 float64) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tdouble_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x40200000) { + p = uintptr(unsafe.Pointer(&_pr8)) + q = uintptr(unsafe.Pointer(&_ps8)) + } else { + if ix >= uint32(0x40122E8B) { + p = uintptr(unsafe.Pointer(&_pr5)) + q = uintptr(unsafe.Pointer(&_ps5)) + } else { + if ix >= uint32(0x4006DB6D) { + p = uintptr(unsafe.Pointer(&_pr3)) + q = uintptr(unsafe.Pointer(&_ps3)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_pr2)) + q = uintptr(unsafe.Pointer(&_ps2)) + } + } + } + z = float64(1) / float64(x*x) + r = **(**float64)(__ccgo_up(p)) + float64(z*(**(**float64)(__ccgo_up(p + 1*8))+float64(z*(**(**float64)(__ccgo_up(p + 2*8))+float64(z*(**(**float64)(__ccgo_up(p + 3*8))+float64(z*(**(**float64)(__ccgo_up(p + 4*8))+float64(z***(**float64)(__ccgo_up(p + 5*8))))))))))) + s = float64(1) + float64(z*(**(**float64)(__ccgo_up(q))+float64(z*(**(**float64)(__ccgo_up(q + 1*8))+float64(z*(**(**float64)(__ccgo_up(q + 2*8))+float64(z*(**(**float64)(__ccgo_up(q + 3*8))+float64(z***(**float64)(__ccgo_up(q + 4*8))))))))))) + return float64(1) + r/s +} + +/* For x >= 8, the asymptotic expansions of qone is + * 3/8 s - 105/1024 s^3 - ..., where s = 1/x. + * We approximate pone by + * qone(x) = s*(0.375 + (R/S)) + * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 + * S = 1 + qs1*s^2 + ... + qs6*s^12 + * and + * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) + */ + +var _qr8 = [6]float64{ + 1: -Float64FromFloat64(0.10253906249999271), + 2: -Float64FromFloat64(16.271753454459), + 3: -Float64FromFloat64(759.6017225139501), + 4: -Float64FromFloat64(11849.806670242959), + 5: -Float64FromFloat64(48438.512428575035), +} +var _qs8 = [6]float64{ + 0: float64(161.3953697007229), + 1: float64(7825.385999233485), + 2: float64(133875.33628724958), + 3: float64(719657.7236832409), + 4: float64(666601.2326177764), + 5: -Float64FromFloat64(294490.26430383464), +} + +var _qr5 = [6]float64{ + 0: -Float64FromFloat64(2.089799311417641e-11), + 1: -Float64FromFloat64(0.10253905024137543), + 2: -Float64FromFloat64(8.05644828123936), + 3: -Float64FromFloat64(183.66960747488838), + 4: -Float64FromFloat64(1373.1937606550816), + 5: -Float64FromFloat64(2612.4444045321566), +} +var _qs5 = [6]float64{ + 0: float64(81.27655013843358), + 1: float64(1991.7987346048596), + 2: float64(17468.48519249089), + 3: float64(49851.42709103523), + 4: float64(27948.075163891812), + 5: -Float64FromFloat64(4719.183547951285), +} + +var _qr3 = [6]float64{ + 0: -Float64FromFloat64(5.078312264617666e-09), + 1: -Float64FromFloat64(0.10253782982083709), + 2: -Float64FromFloat64(4.610115811394734), + 3: -Float64FromFloat64(57.847221656278364), + 4: -Float64FromFloat64(228.2445407376317), + 5: -Float64FromFloat64(219.21012847890933), +} +var _qs3 = [6]float64{ + 0: float64(47.66515503237295), + 1: float64(673.8651126766997), + 2: float64(3380.1528667952634), + 3: float64(5547.729097207228), + 4: float64(1903.119193388108), + 5: -Float64FromFloat64(135.20119144430734), +} + +var _qr2 = [6]float64{ + 0: -Float64FromFloat64(1.7838172751095887e-07), + 1: -Float64FromFloat64(0.10251704260798555), + 2: -Float64FromFloat64(2.7522056827818746), + 3: -Float64FromFloat64(19.663616264370372), + 4: -Float64FromFloat64(42.32531333728305), + 5: -Float64FromFloat64(21.371921170370406), +} +var _qs2 = [6]float64{ + 0: float64(29.533362906052385), + 1: float64(252.98154998219053), + 2: float64(757.5028348686454), + 3: float64(739.3932053204672), + 4: float64(155.94900333666612), + 5: -Float64FromFloat64(4.959498988226282), +} + +func _qone(tls *TLS, x float64) (r1 float64) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tdouble_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x40200000) { + p = uintptr(unsafe.Pointer(&_qr8)) + q = uintptr(unsafe.Pointer(&_qs8)) + } else { + if ix >= uint32(0x40122E8B) { + p = uintptr(unsafe.Pointer(&_qr5)) + q = uintptr(unsafe.Pointer(&_qs5)) + } else { + if ix >= uint32(0x4006DB6D) { + p = uintptr(unsafe.Pointer(&_qr3)) + q = uintptr(unsafe.Pointer(&_qs3)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_qr2)) + q = uintptr(unsafe.Pointer(&_qs2)) + } + } + } + z = float64(1) / float64(x*x) + r = **(**float64)(__ccgo_up(p)) + float64(z*(**(**float64)(__ccgo_up(p + 1*8))+float64(z*(**(**float64)(__ccgo_up(p + 2*8))+float64(z*(**(**float64)(__ccgo_up(p + 3*8))+float64(z*(**(**float64)(__ccgo_up(p + 4*8))+float64(z***(**float64)(__ccgo_up(p + 5*8))))))))))) + s = float64(1) + float64(z*(**(**float64)(__ccgo_up(q))+float64(z*(**(**float64)(__ccgo_up(q + 1*8))+float64(z*(**(**float64)(__ccgo_up(q + 2*8))+float64(z*(**(**float64)(__ccgo_up(q + 3*8))+float64(z*(**(**float64)(__ccgo_up(q + 4*8))+float64(z***(**float64)(__ccgo_up(q + 5*8))))))))))))) + return (float64(0.375) + r/s) / x +} + +var _invsqrtpi3 = float32(0.56418961287) /* 0x3f106ebb */ +var _tpi3 = float32(0.63661974669) /* 0x3f22f983 */ + +func _common3(tls *TLS, ix Tuint32_t, x float32, y1 int32, sign int32) (r float32) { + var c, cc, s, ss, z float64 + _, _, _, _, _ = c, cc, s, ss, z + s = float64(Xsinf(tls, x)) + if y1 != 0 { + s = -s + } + c = float64(Xcosf(tls, x)) + cc = s - c + if ix < uint32(0x7f000000) { + ss = -s - c + z = float64(Xcosf(tls, float32(Float32FromInt32(2)*x))) + if float64(s*c) > Float64FromInt32(0) { + cc = z / ss + } else { + ss = z / cc + } + if ix < uint32(0x58800000) { + if y1 != 0 { + ss = -ss + } + cc = float64(float64(_ponef(tls, x))*cc) - float64(float64(_qonef(tls, x))*ss) + } + } + if sign != 0 { + cc = -cc + } + return float32(float64(float64(_invsqrtpi3)*cc) / float64(Xsqrtf(tls, x))) +} + +// C documentation +// +// /* R0/S0 on [0,2] */ + +var _r001 = float32(-Float64FromFloat64(0.0625)) /* 0xbd800000 */ +var _r011 = float32(0.0014070566976) /* 0x3ab86cfd */ +var _r021 = float32(-Float64FromFloat64(1.5995563444e-05)) /* 0xb7862e36 */ +var _r031 = float32(4.9672799207e-08) /* 0x335557d2 */ +var _s011 = float32(0.019153760746) /* 0x3c9ce859 */ +var _s021 = float32(0.00018594678841) /* 0x3942fab6 */ +var _s031 = float32(1.1771846857e-06) /* 0x359dffc2 */ +var _s041 = float32(5.046362439e-09) /* 0x31ad6446 */ +var _s051 = float32(1.2354227016e-11) /* 0x2d59567e */ + +func Xj1f(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, z float32 + var sign int32 + _, _, _, _, _ = ix, r, s, sign, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + return Float32FromInt32(1) / float32(x*x) + } + if ix >= uint32(0x40000000) { /* |x| >= 2 */ + return _common3(tls, ix, Xfabsf(tls, x), 0, sign) + } + if ix >= uint32(0x39000000) { /* |x| >= 2**-13 */ + z = float32(x * x) + r = float32(z * (_r001 + float32(z*(_r011+float32(z*(_r021+float32(z*_r031))))))) + s = Float32FromInt32(1) + float32(z*(_s011+float32(z*(_s021+float32(z*(_s031+float32(z*(_s041+float32(z*_s051))))))))) + z = Float32FromFloat32(0.5) + r/s + } else { + z = Float32FromFloat32(0.5) + } + return float32(z * x) +} + +var _U01 = [5]float32{ + 0: float32(-Float64FromFloat64(0.19605709612)), + 1: float32(0.050443872809), + 2: float32(-Float64FromFloat64(0.0019125689287)), + 3: float32(2.3525259166e-05), + 4: float32(-Float64FromFloat64(9.1909917899e-08)), +} +var _V01 = [5]float32{ + 0: float32(0.019916731864), + 1: float32(0.0002025525755), + 2: float32(1.3560879779e-06), + 3: float32(6.227414584e-09), + 4: float32(1.6655924903e-11), +} + +func Xy1f(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ix Tuint32_t + var u, v, z float32 + _, _, _, _ = ix, u, v, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + if ix&uint32(0x7fffffff) == uint32(0) { + return float32(-Int32FromInt32(1)) / Float32FromFloat32(0) + } + if ix>>int32(31) != 0 { + return Float32FromInt32(0) / Float32FromFloat32(0) + } + if ix >= uint32(0x7f800000) { + return Float32FromInt32(1) / x + } + if ix >= uint32(0x40000000) { /* |x| >= 2.0 */ + return _common3(tls, ix, x, int32(1), 0) + } + if ix < uint32(0x33000000) { /* x < 2**-25 */ + return -_tpi3 / x + } + z = float32(x * x) + u = _U01[0] + float32(z*(_U01[int32(1)]+float32(z*(_U01[int32(2)]+float32(z*(_U01[int32(3)]+float32(z*_U01[int32(4)]))))))) + v = Float32FromFloat32(1) + float32(z*(_V01[0]+float32(z*(_V01[int32(1)]+float32(z*(_V01[int32(2)]+float32(z*(_V01[int32(3)]+float32(z*_V01[int32(4)]))))))))) + return float32(x*(u/v)) + float32(_tpi3*(float32(Xj1f(tls, x)*Xlogf(tls, x))-Float32FromFloat32(1)/x)) +} + +/* For x >= 8, the asymptotic expansions of pone is + * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. + * We approximate pone by + * pone(x) = 1 + (R/S) + * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 + * S = 1 + ps0*s^2 + ... + ps4*s^10 + * and + * | pone(x)-1-R/S | <= 2 ** ( -60.06) + */ + +var _pr81 = [6]float32{ + 1: float32(0.1171875), + 2: float32(13.239480972), + 3: float32(412.05184937), + 4: float32(3874.7453613), + 5: float32(7914.4794922), +} +var _ps81 = [5]float32{ + 0: float32(114.20736694), + 1: float32(3650.9309082), + 2: float32(36956.207031), + 3: float32(97602.796875), + 4: float32(30804.271484), +} + +var _pr51 = [6]float32{ + 0: float32(1.3199052094e-11), + 1: float32(0.11718749255), + 2: float32(6.8027510643), + 3: float32(108.30818176), + 4: float32(517.63616943), + 5: float32(528.71520996), +} +var _ps51 = [5]float32{ + 0: float32(59.280597687), + 1: float32(991.40142822), + 2: float32(5353.2670898), + 3: float32(7844.6904297), + 4: float32(1504.046875), +} + +var _pr31 = [6]float32{ + 0: float32(3.0250391081e-09), + 1: float32(0.1171868667), + 2: float32(3.932977438), + 3: float32(35.119403839), + 4: float32(91.055007935), + 5: float32(48.559066772), +} +var _ps31 = [5]float32{ + 0: float32(34.791309357), + 1: float32(336.76245117), + 2: float32(1046.87146), + 3: float32(890.81134033), + 4: float32(103.78793335), +} + +var _pr21 = [6]float32{ + 0: float32(1.0771083225e-07), + 1: float32(0.11717621982), + 2: float32(2.3685150146), + 3: float32(12.242610931), + 4: float32(17.693971634), + 5: float32(5.0735230446), +} +var _ps21 = [5]float32{ + 0: float32(21.436485291), + 1: float32(125.2902298), + 2: float32(232.276474), + 3: float32(117.67937469), + 4: float32(8.3646392822), +} + +func _ponef(tls *TLS, x float32) (r1 float32) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tfloat_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x41000000) { + p = uintptr(unsafe.Pointer(&_pr81)) + q = uintptr(unsafe.Pointer(&_ps81)) + } else { + if ix >= uint32(0x409173eb) { + p = uintptr(unsafe.Pointer(&_pr51)) + q = uintptr(unsafe.Pointer(&_ps51)) + } else { + if ix >= uint32(0x4036d917) { + p = uintptr(unsafe.Pointer(&_pr31)) + q = uintptr(unsafe.Pointer(&_ps31)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_pr21)) + q = uintptr(unsafe.Pointer(&_ps21)) + } + } + } + z = Float32FromFloat32(1) / float32(x*x) + r = **(**float32)(__ccgo_up(p)) + float32(z*(**(**float32)(__ccgo_up(p + 1*4))+float32(z*(**(**float32)(__ccgo_up(p + 2*4))+float32(z*(**(**float32)(__ccgo_up(p + 3*4))+float32(z*(**(**float32)(__ccgo_up(p + 4*4))+float32(z***(**float32)(__ccgo_up(p + 5*4))))))))))) + s = Float32FromFloat32(1) + float32(z*(**(**float32)(__ccgo_up(q))+float32(z*(**(**float32)(__ccgo_up(q + 1*4))+float32(z*(**(**float32)(__ccgo_up(q + 2*4))+float32(z*(**(**float32)(__ccgo_up(q + 3*4))+float32(z***(**float32)(__ccgo_up(q + 4*4))))))))))) + return Float32FromFloat32(1) + r/s +} + +/* For x >= 8, the asymptotic expansions of qone is + * 3/8 s - 105/1024 s^3 - ..., where s = 1/x. + * We approximate pone by + * qone(x) = s*(0.375 + (R/S)) + * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 + * S = 1 + qs1*s^2 + ... + qs6*s^12 + * and + * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) + */ + +var _qr81 = [6]float32{ + 1: float32(-Float64FromFloat64(0.1025390625)), + 2: float32(-Float64FromFloat64(16.271753311)), + 3: float32(-Float64FromFloat64(759.60174561)), + 4: float32(-Float64FromFloat64(11849.806641)), + 5: float32(-Float64FromFloat64(48438.511719)), +} +var _qs81 = [6]float32{ + 0: float32(161.39537048), + 1: float32(7825.3862305), + 2: float32(133875.34375), + 3: float32(719657.75), + 4: float32(666601.25), + 5: float32(-Float64FromFloat64(294490.25)), +} + +var _qr51 = [6]float32{ + 0: float32(-Float64FromFloat64(2.0897993405e-11)), + 1: float32(-Float64FromFloat64(0.1025390476)), + 2: float32(-Float64FromFloat64(8.0564479828)), + 3: float32(-Float64FromFloat64(183.66960144)), + 4: float32(-Float64FromFloat64(1373.1937256)), + 5: float32(-Float64FromFloat64(2612.4443359)), +} +var _qs51 = [6]float32{ + 0: float32(81.276550293), + 1: float32(1991.7987061), + 2: float32(17468.484375), + 3: float32(49851.425781), + 4: float32(27948.074219), + 5: float32(-Float64FromFloat64(4719.1835938)), +} + +var _qr31 = [6]float32{ + 0: float32(-Float64FromFloat64(5.0783124372e-09)), + 1: float32(-Float64FromFloat64(0.10253783315)), + 2: float32(-Float64FromFloat64(4.6101160049)), + 3: float32(-Float64FromFloat64(57.847221375)), + 4: float32(-Float64FromFloat64(228.24453735)), + 5: float32(-Float64FromFloat64(219.21012878)), +} +var _qs31 = [6]float32{ + 0: float32(47.665153503), + 1: float32(673.8651123), + 2: float32(3380.152832), + 3: float32(5547.7290039), + 4: float32(1903.1191406), + 5: float32(-Float64FromFloat64(135.20118713)), +} + +var _qr21 = [6]float32{ + 0: float32(-Float64FromFloat64(1.7838172539e-07)), + 1: float32(-Float64FromFloat64(0.10251704603)), + 2: float32(-Float64FromFloat64(2.7522056103)), + 3: float32(-Float64FromFloat64(19.66361618)), + 4: float32(-Float64FromFloat64(42.325313568)), + 5: float32(-Float64FromFloat64(21.371921539)), +} +var _qs21 = [6]float32{ + 0: float32(29.533363342), + 1: float32(252.98155212), + 2: float32(757.50280762), + 3: float32(739.39318848), + 4: float32(155.94900513), + 5: float32(-Float64FromFloat64(4.9594988823)), +} + +func _qonef(tls *TLS, x float32) (r1 float32) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tfloat_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x41000000) { + p = uintptr(unsafe.Pointer(&_qr81)) + q = uintptr(unsafe.Pointer(&_qs81)) + } else { + if ix >= uint32(0x409173eb) { + p = uintptr(unsafe.Pointer(&_qr51)) + q = uintptr(unsafe.Pointer(&_qs51)) + } else { + if ix >= uint32(0x4036d917) { + p = uintptr(unsafe.Pointer(&_qr31)) + q = uintptr(unsafe.Pointer(&_qs31)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_qr21)) + q = uintptr(unsafe.Pointer(&_qs21)) + } + } + } + z = Float32FromFloat32(1) / float32(x*x) + r = **(**float32)(__ccgo_up(p)) + float32(z*(**(**float32)(__ccgo_up(p + 1*4))+float32(z*(**(**float32)(__ccgo_up(p + 2*4))+float32(z*(**(**float32)(__ccgo_up(p + 3*4))+float32(z*(**(**float32)(__ccgo_up(p + 4*4))+float32(z***(**float32)(__ccgo_up(p + 5*4))))))))))) + s = Float32FromFloat32(1) + float32(z*(**(**float32)(__ccgo_up(q))+float32(z*(**(**float32)(__ccgo_up(q + 1*4))+float32(z*(**(**float32)(__ccgo_up(q + 2*4))+float32(z*(**(**float32)(__ccgo_up(q + 3*4))+float32(z*(**(**float32)(__ccgo_up(q + 4*4))+float32(z***(**float32)(__ccgo_up(q + 5*4))))))))))))) + return (Float32FromFloat32(0.375) + r/s) / x +} + +var _invsqrtpi4 = float64(0.5641895835477563) /* 0x3FE20DD7, 0x50429B6D */ + +func Xjn(tls *TLS, n int32, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v n=%v x=%v, (%v:)", tls, n, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u Tuint64_t + var a, b, h, nf, q0, q1, t, temp, tmp, w, z, v6 float64 + var i, k, nm1, sign int32 + var ix, lx Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __u, a, b, h, i, ix, k, lx, nf, nm1, q0, q1, sign, t, temp, tmp, w, z, v6 + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + ix = uint32(__u >> int32(32)) + lx = uint32(__u) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix|(lx|-lx)>>int32(31) > uint32(0x7ff00000) { /* nan */ + return x + } + /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) + * Thus, J(-n,x) = J(n,-x) + */ + /* nm1 = |n|-1 is used instead of |n| to handle n==INT_MIN */ + if n == 0 { + return Xj0(tls, x) + } + if n < 0 { + nm1 = -(n + int32(1)) + x = -x + sign = sign ^ int32(1) + } else { + nm1 = n - int32(1) + } + if nm1 == 0 { + return Xj1(tls, x) + } + sign = sign & n /* even n: 0, odd n: signbit(x) */ + x = Xfabs(tls, x) + if ix|lx == uint32(0) || ix == uint32(0x7ff00000) { /* if x is 0 or inf */ + b = float64(0) + } else { + if float64(nm1) < x { + /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ + if ix >= uint32(0x52d00000) { /* x > 2**302 */ + /* (x >> n**2) + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + switch nm1 & Int32FromInt32(3) { + case 0: + temp = -Xcos(tls, x) + Xsin(tls, x) + case int32(1): + temp = -Xcos(tls, x) - Xsin(tls, x) + case int32(2): + temp = Xcos(tls, x) - Xsin(tls, x) + default: + fallthrough + case int32(3): + temp = Xcos(tls, x) + Xsin(tls, x) + break + } + b = float64(_invsqrtpi4*temp) / Xsqrt(tls, x) + } else { + a = Xj0(tls, x) + b = Xj1(tls, x) + i = 0 + for { + if !(i < nm1) { + break + } + i = i + 1 + temp = b + b = float64(b*(float64(float64(2)*float64(i))/x)) - a /* avoid underflow */ + a = temp + goto _1 + _1: + } + } + } else { + if ix < uint32(0x3e100000) { /* x < 2**-29 */ + /* x is tiny, return the first Taylor expansion of J(n,x) + * J(n,x) = 1/n!*(x/2)^n - ... + */ + if nm1 > int32(32) { /* underflow */ + b = float64(0) + } else { + temp = float64(x * float64(0.5)) + b = temp + a = float64(1) + i = int32(2) + for { + if !(i <= nm1+int32(1)) { + break + } + a = a * float64(i) /* a = n! */ + b = b * temp /* b = (x/2)^n */ + goto _2 + _2: + ; + i = i + 1 + } + b = b / a + } + } else { + nf = float64(nm1) + float64(1) + w = float64(Float64FromInt32(2)*nf) / x + h = Float64FromInt32(2) / x + z = w + h + q0 = w + q1 = float64(w*z) - float64(1) + k = int32(1) + for q1 < float64(1e+09) { + k = k + int32(1) + z = z + h + tmp = float64(z*q1) - q0 + q0 = q1 + q1 = tmp + } + t = float64(0) + i = k + for { + if !(i >= 0) { + break + } + t = Float64FromInt32(1) / (float64(Float64FromInt32(2)*(float64(i)+nf))/x - t) + goto _3 + _3: + ; + i = i - 1 + } + a = t + b = float64(1) + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * Hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = float64(nf * Xlog(tls, Xfabs(tls, w))) + if tmp < float64(709.782712893384) { + i = nm1 + for { + if !(i > 0) { + break + } + temp = b + b = float64(b*float64(float64(2)*float64(i)))/x - a + a = temp + goto _4 + _4: + ; + i = i - 1 + } + } else { + i = nm1 + for { + if !(i > 0) { + break + } + temp = b + b = float64(b*float64(float64(2)*float64(i)))/x - a + a = temp + /* scale b to avoid spurious overflow */ + if b > float64(3.273390607896142e+150) { + a = a / b + t = t / b + b = float64(1) + } + goto _5 + _5: + ; + i = i - 1 + } + } + z = Xj0(tls, x) + w = Xj1(tls, x) + if Xfabs(tls, z) >= Xfabs(tls, w) { + b = float64(t*z) / b + } else { + b = float64(t*w) / a + } + } + } + } + if sign != 0 { + v6 = -b + } else { + v6 = b + } + return v6 +} + +func Xyn(tls *TLS, n int32, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v n=%v x=%v, (%v:)", tls, n, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u Tuint64_t + var a, b, temp, v1 float64 + var i, nm1, sign int32 + var ib, ix, lx Tuint32_t + _, _, _, _, _, _, _, _, _, _, _ = __u, a, b, i, ib, ix, lx, nm1, sign, temp, v1 + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + ix = uint32(__u >> int32(32)) + lx = uint32(__u) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix|(lx|-lx)>>int32(31) > uint32(0x7ff00000) { /* nan */ + return x + } + if sign != 0 && ix|lx != uint32(0) { /* x < 0 */ + return Float64FromInt32(0) / Float64FromFloat64(0) + } + if ix == uint32(0x7ff00000) { + return float64(0) + } + if n == 0 { + return Xy0(tls, x) + } + if n < 0 { + nm1 = -(n + int32(1)) + sign = n & int32(1) + } else { + nm1 = n - int32(1) + sign = 0 + } + if nm1 == 0 { + if sign != 0 { + v1 = -Xy1(tls, x) + } else { + v1 = Xy1(tls, x) + } + return v1 + } + if ix >= uint32(0x52d00000) { /* x > 2**302 */ + /* (x >> n**2) + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + switch nm1 & Int32FromInt32(3) { + case 0: + temp = -Xsin(tls, x) - Xcos(tls, x) + case int32(1): + temp = -Xsin(tls, x) + Xcos(tls, x) + case int32(2): + temp = Xsin(tls, x) + Xcos(tls, x) + default: + fallthrough + case int32(3): + temp = Xsin(tls, x) - Xcos(tls, x) + break + } + b = float64(_invsqrtpi4*temp) / Xsqrt(tls, x) + } else { + a = Xy0(tls, x) + b = Xy1(tls, x) + /* quit if b is -inf */ + ib = uint32(*(*Tuint64_t)(unsafe.Pointer(&b)) >> int32(32)) + i = 0 + for { + if !(i < nm1 && ib != uint32(0xfff00000)) { + break + } + i = i + 1 + temp = b + b = float64(float64(float64(2)*float64(i))/x*b) - a + ib = uint32(*(*Tuint64_t)(unsafe.Pointer(&b)) >> int32(32)) + a = temp + goto _2 + _2: + } + } + if sign != 0 { + v1 = -b + } else { + v1 = b + } + return v1 +} + +func Xjnf(tls *TLS, n int32, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v n=%v x=%v, (%v:)", tls, n, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, b, h, nf, q0, q1, t, temp, tmp, w, z, v6 float32 + var i, k, nm1, sign int32 + var ix Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, b, h, i, ix, k, nf, nm1, q0, q1, sign, t, temp, tmp, w, z, v6 + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix > uint32(0x7f800000) { /* nan */ + return x + } + /* J(-n,x) = J(n,-x), use |n|-1 to avoid overflow in -n */ + if n == 0 { + return Xj0f(tls, x) + } + if n < 0 { + nm1 = -(n + int32(1)) + x = -x + sign = sign ^ int32(1) + } else { + nm1 = n - int32(1) + } + if nm1 == 0 { + return Xj1f(tls, x) + } + sign = sign & n /* even n: 0, odd n: signbit(x) */ + x = Xfabsf(tls, x) + if ix == uint32(0) || ix == uint32(0x7f800000) { /* if x is 0 or inf */ + b = Float32FromFloat32(0) + } else { + if float32(nm1) < x { + /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ + a = Xj0f(tls, x) + b = Xj1f(tls, x) + i = 0 + for { + if !(i < nm1) { + break + } + i = i + 1 + temp = b + b = float32(b*(float32(Float32FromFloat32(2)*float32(i))/x)) - a + a = temp + goto _1 + _1: + } + } else { + if ix < uint32(0x35800000) { /* x < 2**-20 */ + /* x is tiny, return the first Taylor expansion of J(n,x) + * J(n,x) = 1/n!*(x/2)^n - ... + */ + if nm1 > int32(8) { /* underflow */ + nm1 = int32(8) + } + temp = float32(Float32FromFloat32(0.5) * x) + b = temp + a = Float32FromFloat32(1) + i = int32(2) + for { + if !(i <= nm1+int32(1)) { + break + } + a = a * float32(i) /* a = n! */ + b = b * temp /* b = (x/2)^n */ + goto _2 + _2: + ; + i = i + 1 + } + b = b / a + } else { + nf = float32(nm1) + Float32FromFloat32(1) + w = float32(Float32FromInt32(2)*nf) / x + h = Float32FromInt32(2) / x + z = w + h + q0 = w + q1 = float32(w*z) - Float32FromFloat32(1) + k = int32(1) + for q1 < Float32FromFloat32(10000) { + k = k + int32(1) + z = z + h + tmp = float32(z*q1) - q0 + q0 = q1 + q1 = tmp + } + t = Float32FromFloat32(0) + i = k + for { + if !(i >= 0) { + break + } + t = Float32FromFloat32(1) / (float32(Float32FromInt32(2)*(float32(i)+nf))/x - t) + goto _3 + _3: + ; + i = i - 1 + } + a = t + b = Float32FromFloat32(1) + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * Hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = float32(nf * Xlogf(tls, Xfabsf(tls, w))) + if tmp < Float32FromFloat32(88.721679688) { + i = nm1 + for { + if !(i > 0) { + break + } + temp = b + b = float32(float32(Float32FromFloat32(2)*float32(i))*b)/x - a + a = temp + goto _4 + _4: + ; + i = i - 1 + } + } else { + i = nm1 + for { + if !(i > 0) { + break + } + temp = b + b = float32(float32(Float32FromFloat32(2)*float32(i))*b)/x - a + a = temp + /* scale b to avoid spurious overflow */ + if b > Float32FromFloat32(1.152921504606847e+18) { + a = a / b + t = t / b + b = Float32FromFloat32(1) + } + goto _5 + _5: + ; + i = i - 1 + } + } + z = Xj0f(tls, x) + w = Xj1f(tls, x) + if Xfabsf(tls, z) >= Xfabsf(tls, w) { + b = float32(t*z) / b + } else { + b = float32(t*w) / a + } + } + } + } + if sign != 0 { + v6 = -b + } else { + v6 = b + } + return v6 +} + +func Xynf(tls *TLS, n int32, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v n=%v x=%v, (%v:)", tls, n, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, b, temp, v1 float32 + var i, nm1, sign int32 + var ib, ix Tuint32_t + _, _, _, _, _, _, _, _, _ = a, b, i, ib, ix, nm1, sign, temp, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix > uint32(0x7f800000) { /* nan */ + return x + } + if sign != 0 && ix != uint32(0) { /* x < 0 */ + return Float32FromInt32(0) / Float32FromFloat32(0) + } + if ix == uint32(0x7f800000) { + return Float32FromFloat32(0) + } + if n == 0 { + return Xy0f(tls, x) + } + if n < 0 { + nm1 = -(n + int32(1)) + sign = n & int32(1) + } else { + nm1 = n - int32(1) + sign = 0 + } + if nm1 == 0 { + if sign != 0 { + v1 = -Xy1f(tls, x) + } else { + v1 = Xy1f(tls, x) + } + return v1 + } + a = Xy0f(tls, x) + b = Xy1f(tls, x) + /* quit if b is -inf */ + ib = *(*Tuint32_t)(unsafe.Pointer(&b)) + i = 0 + for { + if !(i < nm1 && ib != uint32(0xff800000)) { + break + } + i = i + 1 + temp = b + b = float32(float32(Float32FromFloat32(2)*float32(i))/x*b) - a + ib = *(*Tuint32_t)(unsafe.Pointer(&b)) + a = temp + goto _2 + _2: + } + if sign != 0 { + v1 = -b + } else { + v1 = b + } + return v1 +} + +func Xldexp(tls *TLS, x float64, n int32) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbn(tls, x, n) +} + +func Xldexpf(tls *TLS, x float32, n int32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbnf(tls, x, n) +} + +func Xldexpl(tls *TLS, x float64, n int32) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbnl(tls, x, n) +} + +func Xlgamma(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgamma_r(tls, x, uintptr(unsafe.Pointer(&Xsigngam))) +} + +var _pi2 = float64(3.141592653589793) /* 0x400921FB, 0x54442D18 */ +var _a0 = float64(0.07721566490153287) /* 0x3FB3C467, 0xE37DB0C8 */ +var _a1 = float64(0.3224670334241136) /* 0x3FD4A34C, 0xC4A60FAD */ +var _a2 = float64(0.06735230105312927) /* 0x3FB13E00, 0x1A5562A7 */ +var _a3 = float64(0.020580808432516733) /* 0x3F951322, 0xAC92547B */ +var _a4 = float64(0.007385550860814029) /* 0x3F7E404F, 0xB68FEFE8 */ +var _a5 = float64(0.0028905138367341563) /* 0x3F67ADD8, 0xCCB7926B */ +var _a6 = float64(0.0011927076318336207) /* 0x3F538A94, 0x116F3F5D */ +var _a7 = float64(0.0005100697921535113) /* 0x3F40B6C6, 0x89B99C00 */ +var _a8 = float64(0.00022086279071390839) /* 0x3F2CF2EC, 0xED10E54D */ +var _a9 = float64(0.00010801156724758394) /* 0x3F1C5088, 0x987DFB07 */ +var _a10 = float64(2.5214456545125733e-05) /* 0x3EFA7074, 0x428CFA52 */ +var _a11 = float64(4.4864094961891516e-05) /* 0x3F07858E, 0x90A45837 */ +var _tc = float64(1.4616321449683622) /* 0x3FF762D8, 0x6356BE3F */ +var _tf = -Float64FromFloat64(0.12148629053584961) /* 0xBFBF19B9, 0xBCC38A42 */ +/* tt = -(tail of tf) */ +var _tt = -Float64FromFloat64(3.638676997039505e-18) /* 0xBC50C7CA, 0xA48A971F */ +var _t0 = float64(0.48383612272381005) /* 0x3FDEF72B, 0xC8EE38A2 */ +var _t1 = -Float64FromFloat64(0.1475877229945939) /* 0xBFC2E427, 0x8DC6C509 */ +var _t2 = float64(0.06462494023913339) /* 0x3FB08B42, 0x94D5419B */ +var _t3 = -Float64FromFloat64(0.032788541075985965) /* 0xBFA0C9A8, 0xDF35B713 */ +var _t4 = float64(0.01797067508118204) /* 0x3F9266E7, 0x970AF9EC */ +var _t5 = -Float64FromFloat64(0.010314224129834144) /* 0xBF851F9F, 0xBA91EC6A */ +var _t6 = float64(0.006100538702462913) /* 0x3F78FCE0, 0xE370E344 */ +var _t7 = -Float64FromFloat64(0.0036845201678113826) /* 0xBF6E2EFF, 0xB3E914D7 */ +var _t8 = float64(0.0022596478090061247) /* 0x3F6282D3, 0x2E15C915 */ +var _t9 = -Float64FromFloat64(0.0014034646998923284) /* 0xBF56FE8E, 0xBF2D1AF1 */ +var _t10 = float64(0.000881081882437654) /* 0x3F4CDF0C, 0xEF61A8E9 */ +var _t11 = -Float64FromFloat64(0.0005385953053567405) /* 0xBF41A610, 0x9C73E0EC */ +var _t12 = float64(0.00031563207090362595) /* 0x3F34AF6D, 0x6C0EBBF7 */ +var _t13 = -Float64FromFloat64(0.00031275416837512086) /* 0xBF347F24, 0xECC38C38 */ +var _t14 = float64(0.0003355291926355191) /* 0x3F35FD3E, 0xE8C2D3F4 */ +var _u0 = -Float64FromFloat64(0.07721566490153287) /* 0xBFB3C467, 0xE37DB0C8 */ +var _u1 = float64(0.6328270640250934) /* 0x3FE4401E, 0x8B005DFF */ +var _u2 = float64(1.4549225013723477) /* 0x3FF7475C, 0xD119BD6F */ +var _u3 = float64(0.9777175279633727) /* 0x3FEF4976, 0x44EA8450 */ +var _u4 = float64(0.22896372806469245) /* 0x3FCD4EAE, 0xF6010924 */ +var _u5 = float64(0.013381091853678766) /* 0x3F8B678B, 0xBF2BAB09 */ +var _v1 = float64(2.4559779371304113) /* 0x4003A5D7, 0xC2BD619C */ +var _v2 = float64(2.128489763798934) /* 0x40010725, 0xA42B18F5 */ +var _v3 = float64(0.7692851504566728) /* 0x3FE89DFB, 0xE45050AF */ +var _v4 = float64(0.10422264559336913) /* 0x3FBAAE55, 0xD6537C88 */ +var _v5 = float64(0.003217092422824239) /* 0x3F6A5ABB, 0x57D0CF61 */ +var _s0 = -Float64FromFloat64(0.07721566490153287) /* 0xBFB3C467, 0xE37DB0C8 */ +var _s1 = float64(0.21498241596060885) /* 0x3FCB848B, 0x36E20878 */ +var _s2 = float64(0.325778796408931) /* 0x3FD4D98F, 0x4F139F59 */ +var _s3 = float64(0.14635047265246445) /* 0x3FC2BB9C, 0xBEE5F2F7 */ +var _s4 = float64(0.02664227030336386) /* 0x3F9B481C, 0x7E939961 */ +var _s5 = float64(0.0018402845140733772) /* 0x3F5E26B6, 0x7368F239 */ +var _s6 = float64(3.194753265841009e-05) /* 0x3F00BFEC, 0xDD17E945 */ +var _r1 = float64(1.3920053346762105) /* 0x3FF645A7, 0x62C4AB74 */ +var _r2 = float64(0.7219355475671381) /* 0x3FE71A18, 0x93D3DCDC */ +var _r3 = float64(0.17193386563280308) /* 0x3FC601ED, 0xCCFBDF27 */ +var _r4 = float64(0.01864591917156529) /* 0x3F9317EA, 0x742ED475 */ +var _r5 = float64(0.0007779424963818936) /* 0x3F497DDA, 0xCA41A95B */ +var _r6 = float64(7.326684307446256e-06) /* 0x3EDEBAF7, 0xA5B38140 */ +var _w0 = float64(0.4189385332046727) /* 0x3FDACFE3, 0x90C97D69 */ +var _w1 = float64(0.08333333333333297) /* 0x3FB55555, 0x5555553B */ +var _w2 = -Float64FromFloat64(0.0027777777772877554) /* 0xBF66C16C, 0x16B02E5C */ +var _w3 = float64(0.0007936505586430196) /* 0x3F4A019F, 0x98CF38B6 */ +var _w4 = -Float64FromFloat64(0.00059518755745034) /* 0xBF4380CB, 0x8C0FE741 */ +var _w5 = float64(0.0008363399189962821) /* 0x3F4B67BA, 0x4CDAD5D1 */ +var _w6 = -Float64FromFloat64(0.0016309293409657527) /* 0xBF5AB89D, 0x0B9E43E4 */ + +// C documentation +// +// /* sin(pi*x) assuming x > 2^-100, if sin(pi*x)==0 the sign is arbitrary */ +func _sin_pi(tls *TLS, x float64) (r float64) { + var n int32 + _ = n + /* spurious inexact if odd int */ + x = float64(float64(2) * (float64(x*float64(0.5)) - Xfloor(tls, float64(x*float64(0.5))))) /* x mod 2.0 */ + n = int32(float64(x * Float64FromFloat64(4))) + n = (n + int32(1)) / int32(2) + x = x - float64(float32(n)*Float32FromFloat32(0.5)) + x = x * _pi2 + switch n { + default: /* case 4: */ + fallthrough + case 0: + return X__sin(tls, x, float64(0), 0) + case int32(1): + return X__cos(tls, x, float64(0)) + case int32(2): + return X__sin(tls, -x, float64(0), 0) + case int32(3): + return -X__cos(tls, x, float64(0)) + } + return r +} + +func X__lgamma_r(tls *TLS, x float64, signgamp uintptr) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v signgamp=%v, (%v:)", tls, x, signgamp, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, sign int32 + var ix Tuint32_t + var nadj, p, p1, p2, p3, q, r, t, w, y, z Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, ix, nadj, p, p1, p2, p3, q, r, sign, t, w, y, z + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + /* purge off +-inf, NaN, +-0, tiny and negative arguments */ + **(**int32)(__ccgo_up(signgamp)) = int32(1) + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if ix >= uint32(0x7ff00000) { + return float64(x * x) + } + if ix < Uint32FromInt32((Int32FromInt32(0x3ff)-Int32FromInt32(70))< float64(0) { + **(**int32)(__ccgo_up(signgamp)) = -int32(1) + } else { + t = -t + } + nadj = Xlog(tls, _pi2/Tdouble_t(t*x)) + } + /* purge off 1 and 2 */ + if (ix == uint32(0x3ff00000) || ix == uint32(0x40000000)) && uint32(*(*Tuint64_t)(unsafe.Pointer(bp))) == uint32(0) { + r = Float64FromInt32(0) + } else { + if ix < uint32(0x40000000) { + if ix <= uint32(0x3feccccc) { /* lgamma(x) = lgamma(x+1)-log(x) */ + r = -Xlog(tls, x) + if ix >= uint32(0x3FE76944) { + y = float64(1) - x + i = 0 + } else { + if ix >= uint32(0x3FCDA661) { + y = x - (_tc - Float64FromFloat64(1)) + i = int32(1) + } else { + y = x + i = int32(2) + } + } + } else { + r = float64(0) + if ix >= uint32(0x3FFBB4C3) { /* [1.7316,2] */ + y = float64(2) - x + i = 0 + } else { + if ix >= uint32(0x3FF3B4C4) { /* [1.23,1.73] */ + y = x - _tc + i = int32(1) + } else { + y = x - float64(1) + i = int32(2) + } + } + } + switch i { + case 0: + z = Tdouble_t(y * y) + p1 = _a0 + float64(z*(_a2+float64(z*(_a4+float64(z*(_a6+float64(z*(_a8+float64(z*_a10))))))))) + p2 = Tdouble_t(z * (_a1 + float64(z*(_a3+float64(z*(_a5+float64(z*(_a7+float64(z*(_a9+float64(z*_a11))))))))))) + p = Tdouble_t(y*p1) + p2 + r = r + (p - Tdouble_t(float64(0.5)*y)) + case int32(1): + z = Tdouble_t(y * y) + w = Tdouble_t(z * y) + p1 = _t0 + float64(w*(_t3+float64(w*(_t6+float64(w*(_t9+float64(w*_t12))))))) /* parallel comp */ + p2 = _t1 + float64(w*(_t4+float64(w*(_t7+float64(w*(_t10+float64(w*_t13))))))) + p3 = _t2 + float64(w*(_t5+float64(w*(_t8+float64(w*(_t11+float64(w*_t14))))))) + p = Tdouble_t(z*p1) - (_tt - float64(w*(p2+Tdouble_t(y*p3)))) + r = r + (_tf + p) + case int32(2): + p1 = Tdouble_t(y * (_u0 + float64(y*(_u1+float64(y*(_u2+float64(y*(_u3+float64(y*(_u4+float64(y*_u5))))))))))) + p2 = float64(1) + float64(y*(_v1+float64(y*(_v2+float64(y*(_v3+float64(y*(_v4+float64(y*_v5))))))))) + r = r + (float64(-Float64FromFloat64(0.5)*y) + p1/p2) + } + } else { + if ix < uint32(0x40200000) { /* x < 8.0 */ + i = int32(x) + y = x - float64(i) + p = Tdouble_t(y * (_s0 + float64(y*(_s1+float64(y*(_s2+float64(y*(_s3+float64(y*(_s4+float64(y*(_s5+float64(y*_s6))))))))))))) + q = float64(1) + float64(y*(_r1+float64(y*(_r2+float64(y*(_r3+float64(y*(_r4+float64(y*(_r5+float64(y*_r6))))))))))) + r = float64(float64(0.5)*y) + p/q + z = float64(1) /* lgamma(1+s) = log(s) + lgamma(s) */ + switch i { + case int32(7): + z = z * (y + float64(6)) /* FALLTHRU */ + fallthrough + case int32(6): + z = z * (y + float64(5)) /* FALLTHRU */ + fallthrough + case int32(5): + z = z * (y + float64(4)) /* FALLTHRU */ + fallthrough + case int32(4): + z = z * (y + float64(3)) /* FALLTHRU */ + fallthrough + case int32(3): + z = z * (y + float64(2)) /* FALLTHRU */ + r = r + Xlog(tls, z) + break + } + } else { + if ix < uint32(0x43900000) { /* 8.0 <= x < 2**58 */ + t = Xlog(tls, x) + z = float64(1) / x + y = Tdouble_t(z * z) + w = _w0 + float64(z*(_w1+float64(y*(_w2+float64(y*(_w3+float64(y*(_w4+float64(y*(_w5+float64(y*_w6))))))))))) + r = float64((x-float64(0.5))*(t-Float64FromFloat64(1))) + w + } else { /* 2**58 <= x <= inf */ + r = Tdouble_t(x * (Xlog(tls, x) - float64(1))) + } + } + } + } + if sign != 0 { + r = nadj - r + } + return r +} + +func Xlgamma_r(tls *TLS, x float64, signgamp uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v signgamp=%v, (%v:)", tls, x, signgamp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgamma_r(tls, x, signgamp) +} + +func Xlgammaf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgammaf_r(tls, x, uintptr(unsafe.Pointer(&Xsigngam))) +} + +var _pi3 = float32(3.141592741) /* 0x40490fdb */ +var _a01 = float32(0.077215664089) /* 0x3d9e233f */ +var _a12 = float32(0.32246702909) /* 0x3ea51a66 */ +var _a21 = float32(0.067352302372) /* 0x3d89f001 */ +var _a31 = float32(0.020580807701) /* 0x3ca89915 */ +var _a41 = float32(0.0073855509982) /* 0x3bf2027e */ +var _a51 = float32(0.0028905137442) /* 0x3b3d6ec6 */ +var _a61 = float32(0.0011927076848) /* 0x3a9c54a1 */ +var _a71 = float32(0.00051006977446) /* 0x3a05b634 */ +var _a81 = float32(0.00022086278477) /* 0x39679767 */ +var _a91 = float32(0.00010801156895) /* 0x38e28445 */ +var _a101 = float32(2.52144564e-05) /* 0x37d383a2 */ +var _a111 = float32(4.4864096708e-05) /* 0x383c2c75 */ +var _tc1 = float32(1.4616321325) /* 0x3fbb16c3 */ +var _tf1 = float32(-Float64FromFloat64(0.12148628384)) /* 0xbdf8cdcd */ +/* tt = -(tail of tf) */ +var _tt1 = float32(6.6971006518e-09) /* 0x31e61c52 */ +var _t01 = float32(0.48383611441) /* 0x3ef7b95e */ +var _t15 = float32(-Float64FromFloat64(0.14758771658)) /* 0xbe17213c */ +var _t21 = float32(0.064624942839) /* 0x3d845a15 */ +var _t31 = float32(-Float64FromFloat64(0.032788541168)) /* 0xbd064d47 */ +var _t41 = float32(0.017970675603) /* 0x3c93373d */ +var _t51 = float32(-Float64FromFloat64(0.010314224288)) /* 0xbc28fcfe */ +var _t61 = float32(0.0061005386524) /* 0x3bc7e707 */ +var _t71 = float32(-Float64FromFloat64(0.0036845202558)) /* 0xbb7177fe */ +var _t81 = float32(0.0022596477065) /* 0x3b141699 */ +var _t91 = float32(-Float64FromFloat64(0.0014034647029)) /* 0xbab7f476 */ +var _t101 = float32(0.00088108185446) /* 0x3a66f867 */ +var _t111 = float32(-Float64FromFloat64(0.00053859531181)) /* 0xba0d3085 */ +var _t121 = float32(0.00031563205994) /* 0x39a57b6b */ +var _t131 = float32(-Float64FromFloat64(0.00031275415677)) /* 0xb9a3f927 */ +var _t141 = float32(0.00033552918467) /* 0x39afe9f7 */ +var _u07 = float32(-Float64FromFloat64(0.077215664089)) /* 0xbd9e233f */ +var _u11 = float32(0.63282704353) /* 0x3f2200f4 */ +var _u21 = float32(1.4549225569) /* 0x3fba3ae7 */ +var _u31 = float32(0.97771751881) /* 0x3f7a4bb2 */ +var _u41 = float32(0.22896373272) /* 0x3e6a7578 */ +var _u51 = float32(0.013381091878) /* 0x3c5b3c5e */ +var _v11 = float32(2.4559779167) /* 0x401d2ebe */ +var _v21 = float32(2.1284897327) /* 0x4008392d */ +var _v31 = float32(0.76928514242) /* 0x3f44efdf */ +var _v41 = float32(0.10422264785) /* 0x3dd572af */ +var _v51 = float32(0.0032170924824) /* 0x3b52d5db */ +var _s06 = float32(-Float64FromFloat64(0.077215664089)) /* 0xbd9e233f */ +var _s11 = float32(0.21498242021) /* 0x3e5c245a */ +var _s21 = float32(0.32577878237) /* 0x3ea6cc7a */ +var _s31 = float32(0.14635047317) /* 0x3e15dce6 */ +var _s41 = float32(0.026642270386) /* 0x3cda40e4 */ +var _s51 = float32(0.0018402845599) /* 0x3af135b4 */ +var _s61 = float32(3.1947532989e-05) /* 0x3805ff67 */ +var _r11 = float32(1.3920053244) /* 0x3fb22d3b */ +var _r21 = float32(0.72193557024) /* 0x3f38d0c5 */ +var _r31 = float32(0.17193385959) /* 0x3e300f6e */ +var _r41 = float32(0.018645919859) /* 0x3c98bf54 */ +var _r51 = float32(0.00077794247773) /* 0x3a4beed6 */ +var _r61 = float32(7.3266842264e-06) /* 0x36f5d7bd */ +var _w01 = float32(0.41893854737) /* 0x3ed67f1d */ +var _w11 = float32(0.083333335817) /* 0x3daaaaab */ +var _w21 = float32(-Float64FromFloat64(0.002777777845)) /* 0xbb360b61 */ +var _w31 = float32(0.00079365057172) /* 0x3a500cfd */ +var _w41 = float32(-Float64FromFloat64(0.00059518753551)) /* 0xba1c065c */ +var _w51 = float32(0.00083633989561) /* 0x3a5b3dd2 */ +var _w61 = float32(-Float64FromFloat64(0.0016309292987)) /* 0xbad5c4e8 */ + +// C documentation +// +// /* sin(pi*x) assuming x > 2^-100, if sin(pi*x)==0 the sign is arbitrary */ +func _sin_pi1(tls *TLS, x float32) (r float32) { + var n int32 + var y Tdouble_t + _, _ = n, y + /* spurious inexact if odd int */ + x = float32(Float32FromInt32(2) * (float32(x*Float32FromFloat32(0.5)) - Xfloorf(tls, float32(x*Float32FromFloat32(0.5))))) /* x mod 2.0 */ + n = int32(float32(x * Float32FromInt32(4))) + n = (n + int32(1)) / int32(2) + y = float64(x - float32(float32(n)*Float32FromFloat32(0.5))) + y = y * float64(3.141592653589793) + switch n { + default: /* case 4: */ + fallthrough + case 0: + return X__sindf(tls, y) + case int32(1): + return X__cosdf(tls, y) + case int32(2): + return X__sindf(tls, -y) + case int32(3): + return -X__cosdf(tls, y) + } + return r +} + +func X__lgammaf_r(tls *TLS, x float32, signgamp uintptr) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v signgamp=%v, (%v:)", tls, x, signgamp, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, sign int32 + var ix Tuint32_t + var nadj, p, p1, p2, p3, q, r, t, w, y, z float32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, ix, nadj, p, p1, p2, p3, q, r, sign, t, w, y, z + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + /* purge off +-inf, NaN, +-0, tiny and negative arguments */ + **(**int32)(__ccgo_up(signgamp)) = int32(1) + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + return float32(x * x) + } + if ix < uint32(0x35000000) { /* |x| < 2**-21, return -log(|x|) */ + if sign != 0 { + **(**int32)(__ccgo_up(signgamp)) = -int32(1) + x = -x + } + return -Xlogf(tls, x) + } + if sign != 0 { + x = -x + t = _sin_pi1(tls, x) + if t == Float32FromFloat32(0) { /* -integer */ + return Float32FromFloat32(1) / (x - x) + } + if t > Float32FromFloat32(0) { + **(**int32)(__ccgo_up(signgamp)) = -int32(1) + } else { + t = -t + } + nadj = Xlogf(tls, _pi3/float32(t*x)) + } + /* purge off 1 and 2 */ + if ix == uint32(0x3f800000) || ix == uint32(0x40000000) { + r = Float32FromInt32(0) + } else { + if ix < uint32(0x40000000) { + if ix <= uint32(0x3f666666) { /* lgamma(x) = lgamma(x+1)-log(x) */ + r = -Xlogf(tls, x) + if ix >= uint32(0x3f3b4a20) { + y = Float32FromFloat32(1) - x + i = 0 + } else { + if ix >= uint32(0x3e6d3308) { + y = x - (_tc1 - Float32FromFloat32(1)) + i = int32(1) + } else { + y = x + i = int32(2) + } + } + } else { + r = Float32FromFloat32(0) + if ix >= uint32(0x3fdda618) { /* [1.7316,2] */ + y = Float32FromFloat32(2) - x + i = 0 + } else { + if ix >= uint32(0x3F9da620) { /* [1.23,1.73] */ + y = x - _tc1 + i = int32(1) + } else { + y = x - Float32FromFloat32(1) + i = int32(2) + } + } + } + switch i { + case 0: + z = float32(y * y) + p1 = _a01 + float32(z*(_a21+float32(z*(_a41+float32(z*(_a61+float32(z*(_a81+float32(z*_a101))))))))) + p2 = float32(z * (_a12 + float32(z*(_a31+float32(z*(_a51+float32(z*(_a71+float32(z*(_a91+float32(z*_a111))))))))))) + p = float32(y*p1) + p2 + r = r + (p - float32(Float32FromFloat32(0.5)*y)) + case int32(1): + z = float32(y * y) + w = float32(z * y) + p1 = _t01 + float32(w*(_t31+float32(w*(_t61+float32(w*(_t91+float32(w*_t121))))))) /* parallel comp */ + p2 = _t15 + float32(w*(_t41+float32(w*(_t71+float32(w*(_t101+float32(w*_t131))))))) + p3 = _t21 + float32(w*(_t51+float32(w*(_t81+float32(w*(_t111+float32(w*_t141))))))) + p = float32(z*p1) - (_tt1 - float32(w*(p2+float32(y*p3)))) + r = r + (_tf1 + p) + case int32(2): + p1 = float32(y * (_u07 + float32(y*(_u11+float32(y*(_u21+float32(y*(_u31+float32(y*(_u41+float32(y*_u51))))))))))) + p2 = Float32FromFloat32(1) + float32(y*(_v11+float32(y*(_v21+float32(y*(_v31+float32(y*(_v41+float32(y*_v51))))))))) + r = r + (float32(-Float32FromFloat32(0.5)*y) + p1/p2) + } + } else { + if ix < uint32(0x41000000) { /* x < 8.0 */ + i = int32(x) + y = x - float32(i) + p = float32(y * (_s06 + float32(y*(_s11+float32(y*(_s21+float32(y*(_s31+float32(y*(_s41+float32(y*(_s51+float32(y*_s61))))))))))))) + q = Float32FromFloat32(1) + float32(y*(_r11+float32(y*(_r21+float32(y*(_r31+float32(y*(_r41+float32(y*(_r51+float32(y*_r61))))))))))) + r = float32(Float32FromFloat32(0.5)*y) + p/q + z = Float32FromFloat32(1) /* lgamma(1+s) = log(s) + lgamma(s) */ + switch i { + case int32(7): + z = z * (y + Float32FromFloat32(6)) /* FALLTHRU */ + fallthrough + case int32(6): + z = z * (y + Float32FromFloat32(5)) /* FALLTHRU */ + fallthrough + case int32(5): + z = z * (y + Float32FromFloat32(4)) /* FALLTHRU */ + fallthrough + case int32(4): + z = z * (y + Float32FromFloat32(3)) /* FALLTHRU */ + fallthrough + case int32(3): + z = z * (y + Float32FromFloat32(2)) /* FALLTHRU */ + r = r + Xlogf(tls, z) + break + } + } else { + if ix < uint32(0x5c800000) { /* 8.0 <= x < 2**58 */ + t = Xlogf(tls, x) + z = Float32FromFloat32(1) / x + y = float32(z * z) + w = _w01 + float32(z*(_w11+float32(y*(_w21+float32(y*(_w31+float32(y*(_w41+float32(y*(_w51+float32(y*_w61))))))))))) + r = float32((x-Float32FromFloat32(0.5))*(t-Float32FromFloat32(1))) + w + } else { /* 2**58 <= x <= inf */ + r = float32(x * (Xlogf(tls, x) - Float32FromFloat32(1))) + } + } + } + } + if sign != 0 { + r = nadj - r + } + return r +} + +func Xlgammaf_r(tls *TLS, x float32, signgamp uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v signgamp=%v, (%v:)", tls, x, signgamp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgammaf_r(tls, x, signgamp) +} + +func X__lgammal_r(tls *TLS, x float64, sg uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v sg=%v, (%v:)", tls, x, sg, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgamma_r(tls, x, sg) +} + +func Xlgammal(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgammal_r(tls, x, uintptr(unsafe.Pointer(&Xsigngam))) +} + +func Xlgammal_r(tls *TLS, x float64, sg uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v sg=%v, (%v:)", tls, x, sg, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgammal_r(tls, x, sg) +} + +/* uses LLONG_MAX > 2^53, see comments in lrint.c */ + +func Xllrint(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xrint(tls, x)) +} + +/* uses LLONG_MAX > 2^24, see comments in lrint.c */ + +func Xllrintf(tls *TLS, x float32) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xrintf(tls, x)) +} + +func Xllrintl(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xllrint(tls, x) +} + +func Xllround(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xround(tls, x)) +} + +func Xllroundf(tls *TLS, x float32) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xroundf(tls, x)) +} + +func Xllroundl(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xroundl(tls, x)) +} + +const LOG_POLY1_ORDER = 12 +const LOG_POLY_ORDER = 6 +const LOG_TABLE_BITS = 7 +const N4 = 128 +const OFF = 4604367669032910848 + +// C documentation +// +// /* Top 16 bits of a double. */ +func _top16(tls *TLS, x float64) (r Tuint32_t) { + return uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(48)) +} + +func Xlog(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var hi, invc, kd, lo, logc, r, r2, r3, rhi, rlo, w, y1, z Tdouble_t + var i, k int32 + var ix, iz, tmp Tuint64_t + var top Tuint32_t + var y, v1, v2, v3, v4 float64 + var v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = hi, i, invc, ix, iz, k, kd, lo, logc, r, r2, r3, rhi, rlo, tmp, top, w, y, y1, z, v1, v2, v3, v4, v5 + ix = *(*Tuint64_t)(unsafe.Pointer(&x1)) + top = _top16(tls, x1) + v1 = Float64FromFloat64(1) - Float64FromFloat64(0.0625) + v2 = Float64FromFloat64(1) + Float64FromFloat64(0.064697265625) + v3 = Float64FromFloat64(1) - Float64FromFloat64(0.0625) + if ix-*(*Tuint64_t)(unsafe.Pointer(&v1)) < *(*Tuint64_t)(unsafe.Pointer(&v2))-*(*Tuint64_t)(unsafe.Pointer(&v3)) { + /* Handle close to 1.0 inputs separately. */ + /* Fix sign of zero with downward rounding when x==1. */ + if v5 = Bool(int32(WANT_ROUNDING) != 0); v5 { + v4 = float64(1) + } + if v5 && ix == *(*Tuint64_t)(unsafe.Pointer(&v4)) { + return Float64FromInt32(0) + } + r = x1 - float64(1) + r2 = Tdouble_t(r * r) + r3 = Tdouble_t(r * r2) + y1 = Tdouble_t(r3 * (**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 1*8)) + float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 2*8))) + float64(r2***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 3*8))) + float64(r3*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 4*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 5*8)))+float64(r2***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 6*8)))+float64(r3*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 7*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 8*8)))+float64(r2***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 9*8)))+float64(r3***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 10*8))))))))) + /* Worst-case error is around 0.507 ULP. */ + w = Tdouble_t(r * float64(1.34217728e+08)) + rhi = r + w - w + rlo = r - rhi + w = Tdouble_t(Tdouble_t(rhi*rhi) * **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56))) /* B[0] == -0.5. */ + hi = r + w + lo = r - hi + w + lo = lo + Tdouble_t(float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56))*rlo)*(rhi+r)) + y1 = y1 + lo + y1 = y1 + hi + y = y1 + v1 = y + goto _7 + _7: + return v1 + } + if top-uint32(0x0010) >= Uint32FromInt32(Int32FromInt32(0x7ff0)-Int32FromInt32(0x0010)) { + /* x < 0x1p-1022 or inf or nan. */ + if ix*uint64(2) == uint64(0) { + return X__math_divzero(tls, uint32(1)) + } + v1 = float64(X__builtin_inff(tls)) + if ix == *(*Tuint64_t)(unsafe.Pointer(&v1)) { /* log(inf) == inf. */ + return x1 + } + if top&uint32(0x8000) != 0 || top&uint32(0x7ff0) == uint32(0x7ff0) { + return X__math_invalid(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float64(x1 * float64(4.503599627370496e+15)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + ix = uint64(ix - Uint64FromUint64(52)<> (Int32FromInt32(52) - Int32FromInt32(LOG_TABLE_BITS)) % Uint64FromInt32(Int32FromInt32(1)<> int32(52)) /* arithmetic shift */ + iz = uint64(ix - tmp&(Uint64FromUint64(0xfff)< 0x1p-5: + 0.5 + 4.13/N + abs-poly-error*2^57 ULP (+ 0.002 ULP without fma) + Worst case error if |y| > 0x1p-4: + 0.5 + 2.06/N + abs-poly-error*2^56 ULP (+ 0.001 ULP without fma). */ + y1 = lo + Tdouble_t(r2***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16))) + Tdouble_t(Tdouble_t(r*r2)*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16 + 1*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16 + 2*8)))+float64(r2*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16 + 3*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16 + 4*8))))))) + hi + y = y1 + v1 = y + goto _11 +_11: + return v1 +} + +var _ivln10hi = float64(0.4342944818781689) /* 0x3fdbcb7b, 0x15200000 */ +var _ivln10lo = float64(2.5082946711645275e-11) /* 0x3dbb9438, 0xca9aadd5 */ +var _log10_2hi = float64(0.30102999566361177) /* 0x3FD34413, 0x509F6000 */ +var _log10_2lo = float64(3.694239077158931e-13) /* 0x3D59FEF3, 0x11F12B36 */ +var _Lg1 = float64(0.6666666666666735) /* 3FE55555 55555593 */ +var _Lg2 = float64(0.3999999999940942) /* 3FD99999 9997FA04 */ +var _Lg3 = float64(0.2857142874366239) /* 3FD24924 94229359 */ +var _Lg4 = float64(0.22222198432149784) /* 3FCC71C5 1D8E78AF */ +var _Lg5 = float64(0.1818357216161805) /* 3FC74664 96CB03DE */ +var _Lg6 = float64(0.15313837699209373) /* 3FC39A09 D078C69F */ +var _Lg7 = float64(0.14798198605116586) /* 3FC2F112 DF3E5244 */ + +func Xlog10(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, dk, f, hfsq, hi, lo, s, t1, t2, val_hi, val_lo, w, y, z Tdouble_t + var hx Tuint32_t + var k int32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, dk, f, hfsq, hi, hx, k, lo, s, t1, t2, val_hi, val_lo, w, y, z + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + k = 0 + if hx < uint32(0x00100000) || hx>>int32(31) != 0 { + if *(*Tuint64_t)(unsafe.Pointer(bp))<>int32(31) != 0 { + return (x - x) / float64(0) + } /* log(-#) = NaN */ + /* subnormal number, scale x up */ + k = k - int32(54) + x = x * float64(1.8014398509481984e+16) + *(*float64)(unsafe.Pointer(bp)) = x + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + } else { + if hx >= uint32(0x7ff00000) { + return x + } else { + if hx == uint32(0x3ff00000) && *(*Tuint64_t)(unsafe.Pointer(bp))<>Int32FromInt32(20)) - int32(0x3ff)) + hx = hx&uint32(0x000fffff) + uint32(0x3fe6a09e) + *(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(hx)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, dk, f, hfsq, hi, lo, s, t1, t2, w, z Tfloat_t + var ix Tuint32_t + var k int32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _ = R, dk, f, hfsq, hi, ix, k, lo, s, t1, t2, w, z + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) + k = 0 + if ix < uint32(0x00800000) || ix>>int32(31) != 0 { /* x < 2**-126 */ + if ix<>int32(31) != 0 { + return (x - x) / Float32FromFloat32(0) + } /* log(-#) = NaN */ + /* subnormal number, scale up x */ + k = k - int32(25) + x = x * Float32FromFloat32(3.3554432e+07) + *(*float32)(unsafe.Pointer(bp)) = x + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) + } else { + if ix >= uint32(0x7f800000) { + return x + } else { + if ix == uint32(0x3f800000) { + return Float32FromInt32(0) + } + } + } + /* reduce x into [sqrt(2)/2, sqrt(2)] */ + ix = ix + Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(0x3f3504f3)) + k = k + (Int32FromUint32(ix>>Int32FromInt32(23)) - int32(0x7f)) + ix = ix&uint32(0x007fffff) + uint32(0x3f3504f3) + *(*Tuint32_t)(unsafe.Pointer(bp)) = ix + x = *(*float32)(unsafe.Pointer(bp)) + f = x - Float32FromFloat32(1) + s = f / (Float32FromFloat32(2) + f) + z = Tfloat_t(s * s) + w = Tfloat_t(z * z) + t1 = Tfloat_t(w * (_Lg21 + float32(w*_Lg41))) + t2 = Tfloat_t(z * (_Lg11 + float32(w*_Lg31))) + R = t2 + t1 + hfsq = Tfloat_t(float32(Float32FromFloat32(0.5)*f) * f) + hi = f - hfsq + *(*float32)(unsafe.Pointer(bp)) = hi + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0xfffff000) + hi = *(*float32)(unsafe.Pointer(bp)) + lo = f - hi - hfsq + Tfloat_t(s*(hfsq+R)) + dk = float32(k) + return Tfloat_t(dk*_log10_2lo1) + Tfloat_t((lo+hi)*_ivln10lo1) + Tfloat_t(lo*_ivln10hi1) + Tfloat_t(hi*_ivln10hi1) + Tfloat_t(dk*_log10_2hi1) +} + +func Xlog10l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog10(tls, x) +} + +var _ln2_hi2 = float64(0.6931471803691238) /* 3fe62e42 fee00000 */ +var _ln2_lo2 = float64(1.9082149292705877e-10) /* 3dea39ef 35793c76 */ +var _Lg12 = float64(0.6666666666666735) /* 3FE55555 55555593 */ +var _Lg22 = float64(0.3999999999940942) /* 3FD99999 9997FA04 */ +var _Lg32 = float64(0.2857142874366239) /* 3FD24924 94229359 */ +var _Lg42 = float64(0.22222198432149784) /* 3FCC71C5 1D8E78AF */ +var _Lg51 = float64(0.1818357216161805) /* 3FC74664 96CB03DE */ +var _Lg61 = float64(0.15313837699209373) /* 3FC39A09 D078C69F */ +var _Lg71 = float64(0.14798198605116586) /* 3FC2F112 DF3E5244 */ + +func Xlog1p(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, c, dk, f, hfsq, s, t1, t2, w, z Tdouble_t + var hu, hx Tuint32_t + var k int32 + var y float32 + var y1, y2, v1 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, c, dk, f, hfsq, hu, hx, k, s, t1, t2, w, y, y1, y2, z, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + k = int32(1) + if hx < uint32(0x3fda827a) || hx>>int32(31) != 0 { /* 1+x < sqrt(2)+ */ + if hx >= uint32(0xbff00000) { /* x <= -1.0 */ + if x3 == float64(-Int32FromInt32(1)) { + return x3 / float64(0) + } /* log1p(-1) = -inf */ + return (x3 - x3) / float64(0) /* log1p(x<-1) = NaN */ + } + if hx<= uint32(0x7ff00000) { + return x3 + } + } + if k != 0 { + *(*float64)(unsafe.Pointer(bp)) = Float64FromInt32(1) + x3 + hu = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + hu = hu + Uint32FromInt32(Int32FromInt32(0x3ff00000)-Int32FromInt32(0x3fe6a09e)) + k = Int32FromUint32(hu>>Int32FromInt32(20)) - int32(0x3ff) + /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ + if k < int32(54) { + if k >= int32(2) { + v1 = Float64FromInt32(1) - (*(*float64)(unsafe.Pointer(bp)) - x3) + } else { + v1 = x3 - (*(*float64)(unsafe.Pointer(bp)) - Float64FromInt32(1)) + } + c = v1 + c = c / *(*float64)(unsafe.Pointer(bp)) + } else { + c = Float64FromInt32(0) + } + /* reduce u into [sqrt(2)/2, sqrt(2)] */ + hu = hu&uint32(0x000fffff) + uint32(0x3fe6a09e) + *(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(hu)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, c, dk, f, hfsq, s, t1, t2, w, z Tfloat_t + var iu, ix Tuint32_t + var k int32 + var y, v1 float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, c, dk, f, hfsq, iu, ix, k, s, t1, t2, w, y, y1, y2, z, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) + k = int32(1) + if ix < uint32(0x3ed413d0) || ix>>int32(31) != 0 { /* 1+x < sqrt(2)+ */ + if ix >= uint32(0xbf800000) { /* x <= -1.0 */ + if x3 == float32(-Int32FromInt32(1)) { + return x3 / Float32FromFloat32(0) + } /* log1p(-1)=+inf */ + return (x3 - x3) / Float32FromFloat32(0) /* log1p(x<-1)=NaN */ + } + if ix<= uint32(0x7f800000) { + return x3 + } + } + if k != 0 { + *(*float32)(unsafe.Pointer(bp)) = Float32FromInt32(1) + x3 + iu = *(*Tuint32_t)(unsafe.Pointer(bp)) + iu = iu + Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(0x3f3504f3)) + k = Int32FromUint32(iu>>Int32FromInt32(23)) - int32(0x7f) + /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ + if k < int32(25) { + if k >= int32(2) { + v1 = Float32FromInt32(1) - (*(*float32)(unsafe.Pointer(bp)) - x3) + } else { + v1 = x3 - (*(*float32)(unsafe.Pointer(bp)) - Float32FromInt32(1)) + } + c = v1 + c = c / *(*float32)(unsafe.Pointer(bp)) + } else { + c = Float32FromInt32(0) + } + /* reduce u into [sqrt(2)/2, sqrt(2)] */ + iu = iu&uint32(0x007fffff) + uint32(0x3f3504f3) + *(*Tuint32_t)(unsafe.Pointer(bp)) = iu + f = *(*float32)(unsafe.Pointer(bp)) - Float32FromInt32(1) + } + s = f / (Float32FromFloat32(2) + f) + z = Tfloat_t(s * s) + w = Tfloat_t(z * z) + t1 = Tfloat_t(w * (_Lg23 + float32(w*_Lg43))) + t2 = Tfloat_t(z * (_Lg13 + float32(w*_Lg33))) + R = t2 + t1 + hfsq = Tfloat_t(float32(Float32FromFloat32(0.5)*f) * f) + dk = float32(k) + return Tfloat_t(s*(hfsq+R)) + (Tfloat_t(dk*_ln2_lo3) + c) - hfsq + f + Tfloat_t(dk*_ln2_hi3) +} + +func Xlog1pl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog1p(tls, x) +} + +const LOG2_POLY1_ORDER = 11 +const LOG2_POLY_ORDER = 7 +const LOG2_TABLE_BITS = 6 +const N5 = 64 + +// C documentation +// +// /* Top 16 bits of a double. */ +func _top161(tls *TLS, x float64) (r Tuint32_t) { + return uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(48)) +} + +func Xlog2(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var hi, invc, kd, lo, logc, p, r, r2, r4, rhi, rhi1, rlo, rlo1, t1, t2, t3, y1, z Tdouble_t + var i, k int32 + var ix, iz, tmp, v6 Tuint64_t + var top Tuint32_t + var y, v1, v2, v3, v4 float64 + var v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = hi, i, invc, ix, iz, k, kd, lo, logc, p, r, r2, r4, rhi, rhi1, rlo, rlo1, t1, t2, t3, tmp, top, y, y1, z, v1, v2, v3, v4, v5, v6 + ix = *(*Tuint64_t)(unsafe.Pointer(&x1)) + top = _top161(tls, x1) + v1 = Float64FromFloat64(1) - Float64FromFloat64(0.04239702224731445) + v2 = Float64FromFloat64(1) + Float64FromFloat64(0.044274330139160156) + v3 = Float64FromFloat64(1) - Float64FromFloat64(0.04239702224731445) + if ix-*(*Tuint64_t)(unsafe.Pointer(&v1)) < *(*Tuint64_t)(unsafe.Pointer(&v2))-*(*Tuint64_t)(unsafe.Pointer(&v3)) { + /* Handle close to 1.0 inputs separately. */ + /* Fix sign of zero with downward rounding when x==1. */ + if v5 = Bool(int32(WANT_ROUNDING) != 0); v5 { + v4 = float64(1) + } + if v5 && ix == *(*Tuint64_t)(unsafe.Pointer(&v4)) { + return Float64FromInt32(0) + } + r = x1 - float64(1) + v1 = r + v6 = uint64(*(*Tuint64_t)(unsafe.Pointer(&v1)) & (-Uint64FromUint64(1) << Int32FromInt32(32))) + rhi = *(*float64)(unsafe.Pointer(&v6)) + rlo = r - rhi + hi = Tdouble_t(rhi * X__log2_data.Finvln2hi) + lo = Tdouble_t(rlo*X__log2_data.Finvln2hi) + Tdouble_t(r*X__log2_data.Finvln2lo) + r2 = Tdouble_t(r * r) /* rounding error: 0x1p-62. */ + r4 = Tdouble_t(r2 * r2) + /* Worst-case error is less than 0.54 ULP (0.55 ULP without fma). */ + p = Tdouble_t(r2 * (**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64)) + float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 1*8))))) + y1 = hi + p + lo = lo + (hi - y1 + p) + lo = lo + Tdouble_t(r4*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 2*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 3*8)))+float64(r2*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 4*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 5*8)))))+float64(r4*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 6*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 7*8)))+float64(r2*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 8*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 9*8))))))))) + y1 = y1 + lo + y = y1 + v1 = y + goto _9 + _9: + return v1 + } + if top-uint32(0x0010) >= Uint32FromInt32(Int32FromInt32(0x7ff0)-Int32FromInt32(0x0010)) { + /* x < 0x1p-1022 or inf or nan. */ + if ix*uint64(2) == uint64(0) { + return X__math_divzero(tls, uint32(1)) + } + v1 = float64(X__builtin_inff(tls)) + if ix == *(*Tuint64_t)(unsafe.Pointer(&v1)) { /* log(inf) == inf. */ + return x1 + } + if top&uint32(0x8000) != 0 || top&uint32(0x7ff0) == uint32(0x7ff0) { + return X__math_invalid(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float64(x1 * float64(4.503599627370496e+15)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + ix = uint64(ix - Uint64FromUint64(52)<> (Int32FromInt32(52) - Int32FromInt32(LOG2_TABLE_BITS)) % Uint64FromInt32(Int32FromInt32(1)<> int32(52)) /* arithmetic shift */ + iz = uint64(ix - tmp&(Uint64FromUint64(0xfff)< 0x1p-4: 0.547 ULP (0.550 ULP without fma). + ~ 0.5 + 2/N/ln2 + abs-poly-error*0x1p56 ULP (+ 0.003 ULP without fma). */ + p = **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16)) + float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 1*8))) + float64(r2*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 2*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 3*8))))) + float64(r4*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 4*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 5*8))))) + y1 = lo + Tdouble_t(r2*p) + hi + y = y1 + v1 = y + goto _15 +_15: + return v1 +} + +type Tlog2_data = struct { + Finvln2hi float64 + Finvln2lo float64 + Fpoly [6]float64 + Fpoly1 [10]float64 + Ftab [64]struct { + Finvc float64 + Flogc float64 + } + Ftab2 [64]struct { + Fchi float64 + Fclo float64 + } +} + +const LOG2F_POLY_ORDER = 4 +const LOG2F_TABLE_BITS = 4 +const N6 = 16 +const OFF1 = 1060306944 + +/* +LOG2F_TABLE_BITS = 4 +LOG2F_POLY_ORDER = 4 + +ULP error: 0.752 (nearest rounding.) +Relative error: 1.9 * 2^-26 (before rounding.) +*/ + +func Xlog2f(tls *TLS, x1 float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var i, k int32 + var invc, logc, p, r, r2, y0, y1, z Tdouble_t + var ix, iz, tmp, top Tuint32_t + var y, v1 float32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, invc, ix, iz, k, logc, p, r, r2, tmp, top, y, y0, y1, z, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x1)) + /* Fix sign of zero with downward rounding when x==1. */ + if Bool(int32(WANT_ROUNDING) != 0) && ix == uint32(0x3f800000) { + return Float32FromInt32(0) + } + if ix-uint32(0x00800000) >= Uint32FromInt32(Int32FromInt32(0x7f800000)-Int32FromInt32(0x00800000)) { + /* x < 0x1p-126 or inf or nan. */ + if ix*uint32(2) == uint32(0) { + return X__math_divzerof(tls, uint32(1)) + } + if ix == uint32(0x7f800000) { /* log2(inf) == inf. */ + return x1 + } + if ix&uint32(0x80000000) != 0 || ix*uint32(2) >= uint32(0xff000000) { + return X__math_invalidf(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float32(x1 * Float32FromFloat32(8.388608e+06)) + ix = *(*Tuint32_t)(unsafe.Pointer(&v1)) + ix = ix - Uint32FromInt32(Int32FromInt32(23)<> (Int32FromInt32(23) - Int32FromInt32(LOG2F_TABLE_BITS)) % Uint32FromInt32(Int32FromInt32(1)<> int32(23) /* arithmetic shift */ + invc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + uintptr(i)*16))).Finvc + logc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + uintptr(i)*16))).Flogc + z = float64(*(*float32)(unsafe.Pointer(&iz))) + /* log2(x) = log1p(z/c-1)/ln2 + log2(c) + k */ + r = Tdouble_t(z*invc) - Float64FromInt32(1) + y0 = logc + float64(k) + /* Pipelined polynomial evaluation to approximate log1p(r)/ln2. */ + r2 = Tdouble_t(r * r) + y1 = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + 256 + 1*8))*r) + **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + 256 + 2*8)) + y1 = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + 256))*r2) + y1 + p = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + 256 + 3*8))*r) + y0 + y1 = Tdouble_t(y1*r2) + p + y = float32(y1) + v1 = y + goto _3 +_3: + return v1 +} + +type Tlog2f_data = struct { + Ftab [16]struct { + Finvc float64 + Flogc float64 + } + Fpoly [4]float64 +} + +func Xlog2l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog2(tls, x) +} + +const N7 = 128 + +type Tlog_data = struct { + Fln2hi float64 + Fln2lo float64 + Fpoly [5]float64 + Fpoly1 [11]float64 + Ftab [128]struct { + Finvc float64 + Flogc float64 + } + Ftab2 [128]struct { + Fchi float64 + Fclo float64 + } +} + +/* +special cases: + logb(+-0) = -inf, and raise divbyzero + logb(+-inf) = +inf + logb(nan) = nan +*/ + +func Xlogb(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _ = v1 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if !(BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _ = v1 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if !(BoolInt32(v1&Uint32FromInt32(0x7fffffff) < Uint32FromInt32(0x7f800000)) != 0) { + return float32(x * x) + } + if x == Float32FromInt32(0) { + return float32(-Int32FromInt32(1)) / float32(x*x) + } + return float32(Xilogbf(tls, x)) +} + +func Xlogbl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _ = v1 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if !(BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< %v", r1) }() + } + var i, k int32 + var invc, logc, r, r2, y0, y1, z Tdouble_t + var ix, iz, tmp Tuint32_t + var y, v1 float32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, invc, ix, iz, k, logc, r, r2, tmp, y, y0, y1, z, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x1)) + /* Fix sign of zero with downward rounding when x==1. */ + if Bool(int32(WANT_ROUNDING) != 0) && ix == uint32(0x3f800000) { + return Float32FromInt32(0) + } + if ix-uint32(0x00800000) >= Uint32FromInt32(Int32FromInt32(0x7f800000)-Int32FromInt32(0x00800000)) { + /* x < 0x1p-126 or inf or nan. */ + if ix*uint32(2) == uint32(0) { + return X__math_divzerof(tls, uint32(1)) + } + if ix == uint32(0x7f800000) { /* log(inf) == inf. */ + return x1 + } + if ix&uint32(0x80000000) != 0 || ix*uint32(2) >= uint32(0xff000000) { + return X__math_invalidf(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float32(x1 * Float32FromFloat32(8.388608e+06)) + ix = *(*Tuint32_t)(unsafe.Pointer(&v1)) + ix = ix - Uint32FromInt32(Int32FromInt32(23)<> (Int32FromInt32(23) - Int32FromInt32(LOGF_TABLE_BITS)) % Uint32FromInt32(Int32FromInt32(1)<> int32(23) /* arithmetic shift */ + iz = ix - tmp&uint32(0xff800000) + invc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + uintptr(i)*16))).Finvc + logc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + uintptr(i)*16))).Flogc + z = float64(*(*float32)(unsafe.Pointer(&iz))) + /* log(x) = log1p(z/c-1) + log(c) + k*Ln2 */ + r = Tdouble_t(z*invc) - Float64FromInt32(1) + y0 = logc + Tdouble_t(float64(k)*X__logf_data.Fln2) + /* Pipelined polynomial evaluation to approximate log1p(r). */ + r2 = Tdouble_t(r * r) + y1 = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + 264 + 1*8))*r) + **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + 264 + 2*8)) + y1 = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + 264))*r2) + y1 + y1 = Tdouble_t(y1*r2) + (y0 + r) + y = float32(y1) + v1 = y + goto _3 +_3: + return v1 +} + +type Tlogf_data = struct { + Ftab [16]struct { + Finvc float64 + Flogc float64 + } + Fln2 float64 + Fpoly [3]float64 +} + +func Xlogl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog(tls, x) +} + +/* +If the result cannot be represented (overflow, nan), then +lrint raises the invalid exception. + +Otherwise if the input was not an integer then the inexact +exception is raised. + +C99 is a bit vague about whether inexact exception is +allowed to be raised when invalid is raised. +(F.9 explicitly allows spurious inexact exceptions, F.9.6.5 +does not make it clear if that rule applies to lrint, but +IEEE 754r 7.8 seems to forbid spurious inexact exception in +the ineger conversion functions) + +So we try to make sure that no spurious inexact exception is +raised in case of an overflow. + +If the bit size of long > precision of double, then there +cannot be inexact rounding in case the result overflows, +otherwise LONG_MAX and LONG_MIN can be represented exactly +as a double. +*/ + +func Xlrint(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xrint(tls, x)) +} + +/* uses LONG_MAX > 2^24, see comments in lrint.c */ + +func Xlrintf(tls *TLS, x float32) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xrintf(tls, x)) +} + +func Xlrintl(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlrint(tls, x) +} + +func Xlround(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xround(tls, x)) +} + +func Xlroundf(tls *TLS, x float32) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xroundf(tls, x)) +} + +func Xlroundl(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xroundl(tls, x)) +} + +func Xmodf(tls *TLS, x float64, iptr uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v iptr=%v, (%v:)", tls, x, iptr, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var mask Tuint64_t + var v1 uintptr + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _ = e, mask, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp))>>Int32FromInt32(52)&Uint64FromInt32(0x7ff)) - int32(0x3ff) + /* no fractional part */ + if e >= int32(52) { + **(**float64)(__ccgo_up(iptr)) = x + if e == int32(0x400) && *(*Tuint64_t)(unsafe.Pointer(bp))<> Int32FromInt32(12) >> e) + if *(*Tuint64_t)(unsafe.Pointer(bp))&mask == uint64(0) { + **(**float64)(__ccgo_up(iptr)) = x + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (Uint64FromUint64(1) << Int32FromInt32(63))) + return *(*float64)(unsafe.Pointer(bp)) + } + *(*Tuint64_t)(unsafe.Pointer(bp)) &= ^mask + **(**float64)(__ccgo_up(iptr)) = *(*float64)(unsafe.Pointer(bp)) + return x - *(*float64)(unsafe.Pointer(bp)) +} + +func Xmodff(tls *TLS, x float32, iptr uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v iptr=%v, (%v:)", tls, x, iptr, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var mask Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _ = e, mask + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp))>>Int32FromInt32(23)&Uint32FromInt32(0xff)) - int32(0x7f) + /* no fractional part */ + if e >= int32(23) { + **(**float32)(__ccgo_up(iptr)) = x + if e == int32(0x80) && *(*Tuint32_t)(unsafe.Pointer(bp))<> e) + if *(*Tuint32_t)(unsafe.Pointer(bp))&mask == uint32(0) { + **(**float32)(__ccgo_up(iptr)) = x + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x80000000) + return *(*float32)(unsafe.Pointer(bp)) + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= ^mask + **(**float32)(__ccgo_up(iptr)) = *(*float32)(unsafe.Pointer(bp)) + return x - *(*float32)(unsafe.Pointer(bp)) +} + +func Xmodfl(tls *TLS, x float64, iptr uintptr) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v iptr=%v, (%v:)", tls, x, iptr, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r float64 + var _ /* d at bp+0 */ float64 + _ = r + r = Xmodf(tls, x, bp) + **(**float64)(__ccgo_up(iptr)) = float64(**(**float64)(__ccgo_up(bp))) + return r +} + +func Xnan(tls *TLS, s uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) +} + +func Xnanf(tls *TLS, s uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__builtin_nanf(tls, __ccgo_ts) +} + +func Xnanl(tls *TLS, s uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) +} + +func Xnextafter(tls *TLS, x3 float64, y3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v y3=%v, (%v:)", tls, x3, y3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ax, ay Tuint64_t + var e int32 + var y float32 + var y1, y2 float64 + var v1, v3 uint64 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* ux at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+16 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _ = ax, ay, e, y, y1, y2, v1, v3, v5 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x3 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 16)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 16)) = y3 + *(*float64)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< ay || (*(*Tuint64_t)(unsafe.Pointer(bp + 8))^*(*Tuint64_t)(unsafe.Pointer(bp + 16)))&(Uint64FromUint64(1)<> int32(52) & uint64(0x7ff)) + /* raise overflow if ux.f is infinite and x is finite */ + if e == int32(0x7ff) { + if uint64(8) == uint64(4) { + y = float32(x3 + x3) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + x3 + } else { + y2 = x3 + x3 + } + } + } + /* raise underflow if ux.f is subnormal or zero */ + if e == 0 { + if uint64(8) == uint64(4) { + y = float32(float64(x3*x3) + float64(*(*float64)(unsafe.Pointer(bp + 8))**(*float64)(unsafe.Pointer(bp + 8)))) + } else { + if uint64(8) == uint64(8) { + y1 = float64(x3*x3) + float64(*(*float64)(unsafe.Pointer(bp + 8))**(*float64)(unsafe.Pointer(bp + 8))) + } else { + y2 = float64(x3*x3) + float64(*(*float64)(unsafe.Pointer(bp + 8))**(*float64)(unsafe.Pointer(bp + 8))) + } + } + } + return *(*float64)(unsafe.Pointer(bp + 8)) +} + +func Xnextafterf(tls *TLS, x3 float32, y3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v y3=%v, (%v:)", tls, x3, y3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ax, ay, e Tuint32_t + var y float32 + var y1, y2 float64 + var v1, v3 uint32 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + var _ /* ux at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _ = ax, ay, e, y, y1, y2, v1, v3, v5 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = x3 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 8)) = y3 + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0; !v5 { + *(*float32)(unsafe.Pointer(bp)) = y3 + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x3 + y3 + } + if *(*Tuint32_t)(unsafe.Pointer(bp + 4)) == *(*Tuint32_t)(unsafe.Pointer(bp + 8)) { + return y3 + } + ax = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) & uint32(0x7fffffff) + ay = *(*Tuint32_t)(unsafe.Pointer(bp + 8)) & uint32(0x7fffffff) + if ax == uint32(0) { + if ay == uint32(0) { + return y3 + } + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = *(*Tuint32_t)(unsafe.Pointer(bp + 8))&uint32(0x80000000) | uint32(1) + } else { + if ax > ay || (*(*Tuint32_t)(unsafe.Pointer(bp + 4))^*(*Tuint32_t)(unsafe.Pointer(bp + 8)))&uint32(0x80000000) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) - 1 + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) + 1 + } + } + e = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) & uint32(0x7f800000) + /* raise overflow if ux.f is infinite and x is finite */ + if e == uint32(0x7f800000) { + if uint64(4) == uint64(4) { + y = x3 + x3 + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + x3) + } else { + y2 = float64(x3 + x3) + } + } + } + /* raise underflow if ux.f is subnormal or zero */ + if e == uint32(0) { + if uint64(4) == uint64(4) { + y = float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 4))**(*float32)(unsafe.Pointer(bp + 4))) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 4))**(*float32)(unsafe.Pointer(bp + 4)))) + } else { + y2 = float64(float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 4))**(*float32)(unsafe.Pointer(bp + 4)))) + } + } + } + return *(*float32)(unsafe.Pointer(bp + 4)) +} + +func Xnextafterl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xnextafter(tls, x, y) +} + +func Xnexttoward(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xnextafter(tls, x, y) +} + +func Xnexttowardf(tls *TLS, x3 float32, y3 float64) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v y3=%v, (%v:)", tls, x3, y3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var e Tuint32_t + var y float32 + var y1, y2 float64 + var v1 uint32 + var v3 uint64 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + var _ /* __u at bp+8 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* ux at bp+16 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _ = e, y, y1, y2, v1, v3, v5 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 16)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 16)) = x3 + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0; !v5 { + *(*float64)(unsafe.Pointer(bp + 8)) = y3 + v3 = *(*uint64)(unsafe.Pointer(bp + 8)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) |= uint32(0x80000000) + } + } else { + if float64(x3) < y3 { + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _9 + _9: + if Int32FromUint32(v1>>Int32FromInt32(31)) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) - 1 + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) + 1 + } + } else { + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v1>>Int32FromInt32(31)) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) + 1 + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) - 1 + } + } + } + e = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) & uint32(0x7f800000) + /* raise overflow if ux.f is infinite and x is finite */ + if e == uint32(0x7f800000) { + if uint64(4) == uint64(4) { + y = x3 + x3 + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + x3) + } else { + y2 = float64(x3 + x3) + } + } + } + /* raise underflow if ux.f is subnormal or zero */ + if e == uint32(0) { + if uint64(4) == uint64(4) { + y = float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 16))**(*float32)(unsafe.Pointer(bp + 16))) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 16))**(*float32)(unsafe.Pointer(bp + 16)))) + } else { + y2 = float64(float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 16))**(*float32)(unsafe.Pointer(bp + 16)))) + } + } + } + return *(*float32)(unsafe.Pointer(bp + 16)) +} + +func Xnexttowardl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xnextafterl(tls, x, y) +} + +const OFF2 = 4604531861337669632 +const POW_LOG_POLY_ORDER = 8 +const POW_LOG_TABLE_BITS = 7 +const SIGN_BIAS = 262144 + +/* +Worst-case error: 0.54 ULP (~= ulperr_exp + 1024*Ln2*relerr_log*2^53) +relerr_log: 1.3 * 2^-68 (Relative error of log, 1.5 * 2^-68 without fma) +ulperr_exp: 0.509 ULP (ULP error of exp, 0.511 ULP without fma) +*/ + +// C documentation +// +// /* Top 12 bits of a double (sign and exponent bits). */ +func _top124(tls *TLS, x float64) (r Tuint32_t) { + return uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(52)) +} + +// C documentation +// +// /* Compute y+TAIL = log(x) where the rounded result is y and TAIL has about +// additional 15 bits precision. IX is the bit representation of x, but +// normalized in the subnormal range using the sign bit for the exponent. */ +func _log_inline(tls *TLS, ix Tuint64_t, tail uintptr) (r1 Tdouble_t) { + var ar, ar2, ar3, arhi, arhi2, hi, invc, kd, lo, lo1, lo2, lo3, lo4, logc, logctail, p, r, rhi, rlo, t1, t2, y, z, zhi, zlo Tdouble_t + var i, k int32 + var iz, tmp, v1 Tuint64_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ar, ar2, ar3, arhi, arhi2, hi, i, invc, iz, k, kd, lo, lo1, lo2, lo3, lo4, logc, logctail, p, r, rhi, rlo, t1, t2, tmp, y, z, zhi, zlo, v1 + /* x = 2^k z; where z is in range [OFF,2*OFF) and exact. + The range is split into N subintervals. + The ith subinterval contains z and c is near its center. */ + tmp = ix - uint64(OFF2) + i = Int32FromUint64(tmp >> (Int32FromInt32(52) - Int32FromInt32(POW_LOG_TABLE_BITS)) % Uint64FromInt32(Int32FromInt32(1)<> int32(52)) /* arithmetic shift */ + iz = uint64(ix - tmp&(Uint64FromUint64(0xfff)< 0, the exponent of scale might have overflowed by <= 460. */ + sbits = uint64(sbits - Uint64FromUint64(1009)<= _top124(tls, float64(512))-_top124(tls, float64(5.551115123125783e-17)) { + if abstop-_top124(tls, float64(5.551115123125783e-17)) >= uint32(0x80000000) { + /* Avoid spurious underflow for tiny x. */ + /* Note: 0 is common input. */ + one = float64(1) + x1 + if sign_bias != 0 { + v1 = -one + } else { + v1 = one + } + return v1 + } + if abstop >= _top124(tls, float64(1024)) { + /* Note: inf and nan are already handled. */ + v2 = x1 + if *(*Tuint64_t)(unsafe.Pointer(&v2))>>int32(63) != 0 { + return X__math_uflow(tls, sign_bias) + } else { + return X__math_oflow(tls, sign_bias) + } + } + /* Large x is special cased below. */ + abstop = uint32(0) + } + /* exp(x) = 2^(k/N) * exp(r), with exp(r) in [2^(-1/2N),2^(1/2N)]. */ + /* x = ln2/N*k + r, with int k and r in [-ln2/2N, ln2/2N]. */ + z = Tdouble_t(X__exp_data.Finvln2N * x1) + /* z - kd is in [-1, 1] in non-nearest rounding modes. */ + y = z + X__exp_data.Fshift + v2 = y + goto _4 +_4: + kd = v2 + v2 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v2)) + kd = kd - X__exp_data.Fshift + r = x1 + Tdouble_t(kd*X__exp_data.Fnegln2hiN) + Tdouble_t(kd*X__exp_data.Fnegln2loN) + /* The code assumes 2^-200 < |xtail| < 2^-8/N. */ + r = r + xtail + /* 2^(k/N) ~= scale * (1 + tail). */ + idx = uint64(2) * (ki % Uint64FromInt32(Int32FromInt32(1)< 2^-200 and scale > 2^-739, so there + is no spurious underflow here even without fma. */ + y = scale + Tdouble_t(scale*tmp) + v2 = y + goto _8 +_8: + return v2 +} + +// C documentation +// +// /* Returns 0 if not int, 1 if odd int, 2 if even int. The argument is +// the bit representation of a non-zero finite floating-point value. */ +func _checkint(tls *TLS, iy Tuint64_t) (r int32) { + var e int32 + _ = e + e = Int32FromUint64(iy >> int32(52) & uint64(0x7ff)) + if e < int32(0x3ff) { + return 0 + } + if e > Int32FromInt32(0x3ff)+Int32FromInt32(52) { + return int32(2) + } + if iy&(uint64(1)<<(Int32FromInt32(0x3ff)+Int32FromInt32(52)-e)-uint64(1)) != 0 { + return 0 + } + if iy&(uint64(1)<<(Int32FromInt32(0x3ff)+Int32FromInt32(52)-e)) != 0 { + return int32(1) + } + return int32(2) +} + +// C documentation +// +// /* Returns 1 if input is the bit representation of 0, infinity or nan. */ +func _zeroinfnan(tls *TLS, i Tuint64_t) (r int32) { + var v1 float64 + _ = v1 + v1 = float64(X__builtin_inff(tls)) + return BoolInt32(uint64(2)*i-uint64(1) >= uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1))-uint64(1)) +} + +func Xpow(tls *TLS, x1 float64, y1 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x1=%v y1=%v, (%v:)", tls, x1, y1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ehi, elo, hi, lhi, llo, x2, yhi, ylo Tdouble_t + var ix, iy, v16, v17 Tuint64_t + var sign_bias, topx, topy Tuint32_t + var y, v1, v2 float64 + var yint int32 + var v4 bool + var _ /* lo at bp+0 */ Tdouble_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ehi, elo, hi, ix, iy, lhi, llo, sign_bias, topx, topy, x2, y, yhi, yint, ylo, v1, v16, v17, v2, v4 + sign_bias = uint32(0) + ix = *(*Tuint64_t)(unsafe.Pointer(&x1)) + iy = *(*Tuint64_t)(unsafe.Pointer(&y1)) + topx = _top124(tls, x1) + topy = _top124(tls, y1) + if topx-uint32(0x001) >= Uint32FromInt32(Int32FromInt32(0x7ff)-Int32FromInt32(0x001)) || topy&uint32(0x7ff)-uint32(0x3be) >= Uint32FromInt32(Int32FromInt32(0x43e)-Int32FromInt32(0x3be)) { + /* Note: if |y| > 1075 * ln2 * 2^53 ~= 0x1.749p62 then pow(x,y) = inf/0 + and if |y| < 2^-54 / 1075 ~= 0x1.e7b6p-65 then pow(x,y) = +-1. */ + /* Special cases: (x < 0x1p-126 or inf or nan) or + (|y| < 0x1p-65 or |y| >= 0x1p63 or nan). */ + if _zeroinfnan(tls, iy) != 0 { + if uint64(2)*iy == uint64(0) { + return float64(1) + } + v1 = float64(1) + if ix == *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(1) + } + v1 = float64(X__builtin_inff(tls)) + if v4 = uint64(2)*ix > uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1)); !v4 { + v2 = float64(X__builtin_inff(tls)) + } + if v4 || uint64(2)*iy > uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v2)) { + return x1 + y1 + } + v1 = float64(1) + if uint64(2)*ix == uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(1) + } + v1 = float64(1) + if BoolInt32(uint64(2)*ix < uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1))) == BoolInt32(!(iy>>Int32FromInt32(63) != 0)) { + return float64(0) + } /* |x|<1 && y==inf or |x|>1 && y==-inf. */ + return float64(y1 * y1) + } + if _zeroinfnan(tls, ix) != 0 { + x2 = Tdouble_t(x1 * x1) + if ix>>int32(63) != 0 && _checkint(tls, iy) == int32(1) { + x2 = -x2 + } + /* Without the barrier some versions of clang hoist the 1/x2 and + thus division by zero exception can be signaled spuriously. */ + if iy>>int32(63) != 0 { + y = Float64FromInt32(1) / x2 + v2 = y + goto _9 + _9: + v1 = v2 + } else { + v1 = x2 + } + return v1 + } + /* Here x and y are non-zero finite. */ + if ix>>int32(63) != 0 { + /* Finite x < 0. */ + yint = _checkint(tls, iy) + if yint == 0 { + return X__math_invalid(tls, x1) + } + if yint == int32(1) { + sign_bias = Uint32FromInt32(Int32FromInt32(0x800) << Int32FromInt32(EXP_TABLE_BITS)) + } + ix = ix & uint64(0x7fffffffffffffff) + topx = topx & uint32(0x7ff) + } + if topy&uint32(0x7ff)-uint32(0x3be) >= Uint32FromInt32(Int32FromInt32(0x43e)-Int32FromInt32(0x3be)) { + /* Note: sign_bias == 0 here because y is not odd. */ + v1 = float64(1) + if ix == *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(1) + } + if topy&uint32(0x7ff) < uint32(0x3be) { + /* |y| < 2^-65, x^y ~= 1 + y*log(x). */ + if int32(WANT_ROUNDING) != 0 { + v2 = float64(1) + if ix > *(*Tuint64_t)(unsafe.Pointer(&v2)) { + v1 = float64(1) + y1 + } else { + v1 = float64(1) - y1 + } + return v1 + } else { + return float64(1) + } + } + v2 = float64(1) + if BoolInt32(ix > *(*Tuint64_t)(unsafe.Pointer(&v2))) == BoolInt32(topy < uint32(0x800)) { + v1 = X__math_oflow(tls, uint32(0)) + } else { + v1 = X__math_uflow(tls, uint32(0)) + } + return v1 + } + if topx == uint32(0) { + /* Normalize subnormal x so exponent becomes negative. */ + v1 = float64(x1 * float64(4.503599627370496e+15)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + ix = ix & uint64(0x7fffffffffffffff) + ix = uint64(ix - Uint64FromUint64(52)<> (Int32FromInt32(23) - Int32FromInt32(POWF_LOG2_TABLE_BITS)) % Uint32FromInt32(Int32FromInt32(1)<> (Int32FromInt32(23) - Int32FromInt32(POWF_SCALE_BITS)) /* arithmetic shift */ + invc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + uintptr(i)*16))).Finvc + logc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + uintptr(i)*16))).Flogc + z = float64(*(*float32)(unsafe.Pointer(&iz))) + /* log2(x) = log1p(z/c-1)/ln2 + log2(c) + k */ + r = Tdouble_t(z*invc) - Float64FromInt32(1) + y0 = logc + float64(k) + /* Pipelined polynomial evaluation to approximate log1p(r)/ln2. */ + r2 = Tdouble_t(r * r) + y = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256))*r) + **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256 + 1*8)) + p = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256 + 2*8))*r) + **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256 + 3*8)) + r4 = Tdouble_t(r2 * r2) + q = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256 + 4*8))*r) + y0 + q = Tdouble_t(p*r2) + q + y = Tdouble_t(y*r4) + q + return y +} + +// C documentation +// +// /* The output of log2 and thus the input of exp2 is either scaled by N +// (in case of fast toint intrinsics) or not. The unscaled xd must be +// in [-1021,1023], sign_bias sets the sign of the result. */ +func _exp2_inline(tls *TLS, xd Tdouble_t, sign_bias Tuint32_t) (r1 float32) { + var kd, r, r2, s, y2, z Tdouble_t + var ki, ski, t Tuint64_t + var y, v4 float32 + var y1, v1 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = kd, ki, r, r2, s, ski, t, y, y1, y2, z, v1, v4 + /* x = k/N + r with r in [-1/(2N), 1/(2N)] */ + y1 = xd + X__exp2f_data.Fshift_scaled + v1 = y1 + goto _2 +_2: + kd = v1 + v1 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v1)) + kd = kd - X__exp2f_data.Fshift_scaled /* k/N */ + r = xd - kd + /* exp2(x) = 2^(k/N) * 2^r ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */ + t = **(**Tuint64_t)(__ccgo_up(uintptr(unsafe.Pointer(&X__exp2f_data)) + uintptr(ki%Uint64FromInt32(Int32FromInt32(1)<> int32(23) & uint32(0xff)) + if e < int32(0x7f) { + return 0 + } + if e > Int32FromInt32(0x7f)+Int32FromInt32(23) { + return int32(2) + } + if iy&Uint32FromInt32(Int32FromInt32(1)<<(Int32FromInt32(0x7f)+Int32FromInt32(23)-e)-Int32FromInt32(1)) != 0 { + return 0 + } + if iy&Uint32FromInt32(Int32FromInt32(1)<<(Int32FromInt32(0x7f)+Int32FromInt32(23)-e)) != 0 { + return int32(1) + } + return int32(2) +} + +func _zeroinfnan1(tls *TLS, ix Tuint32_t) (r int32) { + return BoolInt32(uint32(2)*ix-uint32(1) >= Uint32FromUint32(2)*Uint32FromInt32(0x7f800000)-Uint32FromInt32(1)) +} + +func Xpowf(tls *TLS, x1 float32, y1 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x1=%v y1=%v, (%v:)", tls, x1, y1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ix, iy, sign_bias Tuint32_t + var logx, ylogx Tdouble_t + var x2 Tfloat_t + var y, v1, v2 float32 + var yint int32 + var v5, v6 float64 + _, _, _, _, _, _, _, _, _, _, _, _ = ix, iy, logx, sign_bias, x2, y, yint, ylogx, v1, v2, v5, v6 + sign_bias = uint32(0) + ix = *(*Tuint32_t)(unsafe.Pointer(&x1)) + iy = *(*Tuint32_t)(unsafe.Pointer(&y1)) + if ix-uint32(0x00800000) >= Uint32FromInt32(Int32FromInt32(0x7f800000)-Int32FromInt32(0x00800000)) || _zeroinfnan1(tls, iy) != 0 { + /* Either (x < 0x1p-126 or inf or nan) or (y is 0 or inf or nan). */ + if _zeroinfnan1(tls, iy) != 0 { + if uint32(2)*iy == uint32(0) { + return Float32FromFloat32(1) + } + if ix == uint32(0x3f800000) { + return Float32FromFloat32(1) + } + if uint32(2)*ix > Uint32FromUint32(2)*Uint32FromInt32(0x7f800000) || uint32(2)*iy > Uint32FromUint32(2)*Uint32FromInt32(0x7f800000) { + return x1 + y1 + } + if uint32(2)*ix == Uint32FromInt32(Int32FromInt32(2)*Int32FromInt32(0x3f800000)) { + return Float32FromFloat32(1) + } + if BoolInt32(uint32(2)*ix < Uint32FromInt32(Int32FromInt32(2)*Int32FromInt32(0x3f800000))) == BoolInt32(!(iy&Uint32FromUint32(0x80000000) != 0)) { + return Float32FromFloat32(0) + } /* |x|<1 && y==inf or |x|>1 && y==-inf. */ + return float32(y1 * y1) + } + if _zeroinfnan1(tls, ix) != 0 { + x2 = Tfloat_t(x1 * x1) + if ix&uint32(0x80000000) != 0 && _checkint1(tls, iy) == int32(1) { + x2 = -x2 + } + /* Without the barrier some versions of clang hoist the 1/x2 and + thus division by zero exception can be signaled spuriously. */ + if iy&uint32(0x80000000) != 0 { + y = Float32FromInt32(1) / x2 + v2 = y + goto _3 + _3: + v1 = v2 + } else { + v1 = x2 + } + return v1 + } + /* x and y are non-zero finite. */ + if ix&uint32(0x80000000) != 0 { + /* Finite x < 0. */ + yint = _checkint1(tls, iy) + if yint == 0 { + return X__math_invalidf(tls, x1) + } + if yint == int32(1) { + sign_bias = Uint32FromInt32(Int32FromInt32(1) << (Int32FromInt32(EXP2F_TABLE_BITS) + Int32FromInt32(11))) + } + ix = ix & uint32(0x7fffffff) + } + if ix < uint32(0x00800000) { + /* Normalize subnormal x so exponent becomes negative. */ + v1 = float32(x1 * Float32FromFloat32(8.388608e+06)) + ix = *(*Tuint32_t)(unsafe.Pointer(&v1)) + ix = ix & uint32(0x7fffffff) + ix = ix - Uint32FromInt32(Int32FromInt32(23)<>int32(47)&uint64(0xffff) >= *(*Tuint64_t)(unsafe.Pointer(&v6))>>int32(47) { + /* |y*log(x)| >= 126. */ + if ylogx > Tdouble_t(float64(127.99999995700433)*float64(Int32FromInt32(1)< %v", r) }() + } + return Xpow(tls, x, y) +} + +func Xremainder(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* q at bp+0 */ int32 + return Xremquo(tls, x, y, bp) +} + +func Xdrem(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xremainder(tls, x, y) +} + +func Xremainderf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* q at bp+0 */ int32 + return Xremquof(tls, x, y, bp) +} + +func Xdremf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xremainderf(tls, x, y) +} + +func Xremainderl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xremainder(tls, x, y) +} + +func Xremquo(tls *TLS, x float64, y float64, quo uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v quo=%v, (%v:)", tls, x, y, quo, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ex, ey, sx, sy, v10 int32 + var i, uxi Tuint64_t + var q Tuint32_t + var v1 uint64 + var v11 float64 + var v3 bool + var v6 uintptr + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* ux at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+16 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _ = ex, ey, i, q, sx, sy, uxi, v1, v10, v11, v3, v6 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 16)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 16)) = y + ex = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(52) & uint64(0x7ff)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 16)) >> int32(52) & uint64(0x7ff)) + sx = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(63)) + sy = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 16)) >> int32(63)) + uxi = *(*Tuint64_t)(unsafe.Pointer(bp + 8)) + **(**int32)(__ccgo_up(quo)) = 0 + if v3 = *(*Tuint64_t)(unsafe.Pointer(bp + 16))<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>int32(63) == uint64(0)) { + break + } + goto _4 + _4: + ; + ex = ex - 1 + i = i << uint64(1) + } + uxi = uxi << Uint64FromInt32(-ex+int32(1)) + } else { + uxi = uint64(uxi & (-Uint64FromUint64(1) >> Int32FromInt32(12))) + uxi = uint64(uxi | Uint64FromUint64(1)<>int32(63) == uint64(0)) { + break + } + goto _5 + _5: + ; + ey = ey - 1 + i = i << uint64(1) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 16)) <<= Uint64FromInt32(-ey + int32(1)) + } else { + v6 = bp + 16 + *(*Tuint64_t)(unsafe.Pointer(v6)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v6)) & (-Uint64FromUint64(1) >> Int32FromInt32(12))) + v6 = bp + 16 + *(*Tuint64_t)(unsafe.Pointer(v6)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v6)) | Uint64FromUint64(1)< ey) { + break + } + i = uxi - *(*Tuint64_t)(unsafe.Pointer(bp + 16)) + if i>>int32(63) == uint64(0) { + uxi = i + q = q + 1 + } + uxi = uxi << uint64(1) + q = q << uint32(1) + goto _8 + _8: + ; + ex = ex - 1 + } + i = uxi - *(*Tuint64_t)(unsafe.Pointer(bp + 16)) + if i>>int32(63) == uint64(0) { + uxi = i + q = q + 1 + } + if uxi == uint64(0) { + ex = -int32(60) + } else { + for { + if !(uxi>>int32(52) == uint64(0)) { + break + } + goto _9 + _9: + ; + uxi = uxi << uint64(1) + ex = ex - 1 + } + } + goto end +end: + ; + /* scale result and decide between |x| and |x|-|y| */ + if ex > 0 { + uxi = uint64(uxi - Uint64FromUint64(1)<> Uint64FromInt32(-ex+int32(1)) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 8)) = uxi + x = *(*float64)(unsafe.Pointer(bp + 8)) + if sy != 0 { + y = -y + } + if ex == ey || ex+int32(1) == ey && (float64(Float64FromInt32(2)*x) > y || float64(Float64FromInt32(2)*x) == y && q%uint32(2) != 0) { + x = x - y + q = q + 1 + } + q = q & uint32(0x7fffffff) + if sx^sy != 0 { + v10 = -Int32FromUint32(q) + } else { + v10 = Int32FromUint32(q) + } + **(**int32)(__ccgo_up(quo)) = v10 + if sx != 0 { + v11 = -x + } else { + v11 = x + } + return v11 +} + +func Xremquof(tls *TLS, x float32, y float32, quo uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v quo=%v, (%v:)", tls, x, y, quo, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ex, ey, sx, sy, v8 int32 + var i, q, uxi Tuint32_t + var v1 uint32 + var v3 bool + var v9 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + var _ /* ux at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _ = ex, ey, i, q, sx, sy, uxi, v1, v3, v8, v9 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = x + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 8)) = y + ex = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 4)) >> int32(23) & uint32(0xff)) + ey = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 8)) >> int32(23) & uint32(0xff)) + sx = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 4)) >> int32(31)) + sy = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 8)) >> int32(31)) + uxi = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) + **(**int32)(__ccgo_up(quo)) = 0 + if v3 = *(*Tuint32_t)(unsafe.Pointer(bp + 8))< uint32(0x7f800000)) != 0 || ex == int32(0xff) { + return float32(x*y) / float32(x*y) + } + if *(*Tuint32_t)(unsafe.Pointer(bp + 4))<>int32(31) == uint32(0)) { + break + } + goto _4 + _4: + ; + ex = ex - 1 + i = i << uint32(1) + } + uxi = uxi << Uint32FromInt32(-ex+int32(1)) + } else { + uxi = uxi & (-Uint32FromUint32(1) >> Int32FromInt32(9)) + uxi = uxi | Uint32FromUint32(1)<>int32(31) == uint32(0)) { + break + } + goto _5 + _5: + ; + ey = ey - 1 + i = i << uint32(1) + } + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) <<= Uint32FromInt32(-ey + int32(1)) + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) &= -Uint32FromUint32(1) >> Int32FromInt32(9) + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) |= Uint32FromUint32(1) << Int32FromInt32(23) + } + q = uint32(0) + if ex < ey { + if ex+int32(1) == ey { + goto end + } + return x + } + /* x mod y */ + for { + if !(ex > ey) { + break + } + i = uxi - *(*Tuint32_t)(unsafe.Pointer(bp + 8)) + if i>>int32(31) == uint32(0) { + uxi = i + q = q + 1 + } + uxi = uxi << uint32(1) + q = q << uint32(1) + goto _6 + _6: + ; + ex = ex - 1 + } + i = uxi - *(*Tuint32_t)(unsafe.Pointer(bp + 8)) + if i>>int32(31) == uint32(0) { + uxi = i + q = q + 1 + } + if uxi == uint32(0) { + ex = -int32(30) + } else { + for { + if !(uxi>>int32(23) == uint32(0)) { + break + } + goto _7 + _7: + ; + uxi = uxi << uint32(1) + ex = ex - 1 + } + } + goto end +end: + ; + /* scale result and decide between |x| and |x|-|y| */ + if ex > 0 { + uxi = uxi - Uint32FromUint32(1)<> Uint32FromInt32(-ex+int32(1)) + } + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = uxi + x = *(*float32)(unsafe.Pointer(bp + 4)) + if sy != 0 { + y = -y + } + if ex == ey || ex+int32(1) == ey && (float32(Float32FromInt32(2)*x) > y || float32(Float32FromInt32(2)*x) == y && q%uint32(2) != 0) { + x = x - y + q = q + 1 + } + q = q & uint32(0x7fffffff) + if sx^sy != 0 { + v8 = -Int32FromUint32(q) + } else { + v8 = Int32FromUint32(q) + } + **(**int32)(__ccgo_up(quo)) = v8 + if sx != 0 { + v9 = -x + } else { + v9 = x + } + return v9 +} + +func Xremquol(tls *TLS, x float64, y float64, quo uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v quo=%v, (%v:)", tls, x, y, quo, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xremquo(tls, x, y, quo) +} + +const DBL_EPSILON9 = 2.220446049250313e-16 + +var _toint4 = Float64FromInt32(1) / Float64FromFloat64(2.220446049250313e-16) + +func Xrint(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s int32 + var y Tdouble_t + var v1 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _ = e, s, y, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + s = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + if e >= Int32FromInt32(0x3ff)+Int32FromInt32(52) { + return x + } + if s != 0 { + y = x - _toint4 + _toint4 + } else { + y = x + _toint4 - _toint4 + } + if y == Float64FromInt32(0) { + if s != 0 { + v1 = -Float64FromFloat64(0) + } else { + v1 = Float64FromInt32(0) + } + return v1 + } + return y +} + +const DBL_EPSILON10 = 0 +const FLT_EPSILON1 = 1.1920928955078125e-07 + +var _toint5 = Float32FromInt32(1) / Float32FromFloat32(1.1920928955078125e-07) + +func Xrintf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s int32 + var y Tfloat_t + var v1 float32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _ = e, s, y, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + s = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + if e >= Int32FromInt32(0x7f)+Int32FromInt32(23) { + return x + } + if s != 0 { + y = x - _toint5 + _toint5 + } else { + y = x + _toint5 - _toint5 + } + if y == Float32FromInt32(0) { + if s != 0 { + v1 = -Float32FromFloat32(0) + } else { + v1 = Float32FromFloat32(0) + } + return v1 + } + return y +} + +const FLT_EPSILON2 = 0 + +func Xrintl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xrint(tls, x) +} + +const DBL_EPSILON11 = 2.220446049250313e-16 + +var _toint6 = Float64FromInt32(1) / Float64FromFloat64(2.220446049250313e-16) + +func Xround(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var y float32 + var y1, y2 float64 + var y3 Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _ = e, y, y1, y2, y3 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if e >= Int32FromInt32(0x3ff)+Int32FromInt32(52) { + return x3 + } + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + x3 = -x3 + } + if e < Int32FromInt32(0x3ff)-Int32FromInt32(1) { + /* raise inexact if x!=0 */ + if uint64(8) == uint64(4) { + y = float32(x3 + _toint6) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + _toint6 + } else { + y2 = float64(x3 + _toint6) + } + } + return float64(Float64FromInt32(0) * *(*float64)(unsafe.Pointer(bp))) + } + y3 = x3 + _toint6 - _toint6 - x3 + if y3 > float64(0.5) { + y3 = y3 + x3 - Float64FromInt32(1) + } else { + if y3 <= -Float64FromFloat64(0.5) { + y3 = y3 + x3 + Float64FromInt32(1) + } else { + y3 = y3 + x3 + } + } + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + y3 = -y3 + } + return y3 +} + +const DBL_EPSILON12 = 0 +const FLT_EPSILON3 = 1.1920928955078125e-07 + +var _toint7 = Float32FromInt32(1) / Float32FromFloat32(1.1920928955078125e-07) + +func Xroundf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var y float32 + var y1, y2 float64 + var y3 Tfloat_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e, y, y1, y2, y3 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + if e >= Int32FromInt32(0x7f)+Int32FromInt32(23) { + return x3 + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + x3 = -x3 + } + if e < Int32FromInt32(0x7f)-Int32FromInt32(1) { + if uint64(4) == uint64(4) { + y = x3 + _toint7 + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + _toint7) + } else { + y2 = float64(x3 + _toint7) + } + } + return float32(Float32FromInt32(0) * *(*float32)(unsafe.Pointer(bp))) + } + y3 = x3 + _toint7 - _toint7 - x3 + if y3 > Float32FromFloat32(0.5) { + y3 = y3 + x3 - Float32FromInt32(1) + } else { + if y3 <= -Float32FromFloat32(0.5) { + y3 = y3 + x3 + Float32FromInt32(1) + } else { + y3 = y3 + x3 + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + y3 = -y3 + } + return y3 +} + +const FLT_EPSILON4 = 0 + +func Xroundl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xround(tls, x) +} + +func Xscalb(tls *TLS, x float64, fn float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v fn=%v, (%v:)", tls, x, fn, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3 uint64 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _ = v1, v3, v5 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< float64(0) { + return float64(x * fn) + } else { + return x / -fn + } + } + if Xrint(tls, fn) != fn { + return (fn - fn) / (fn - fn) + } + if fn > float64(65000) { + return Xscalbn(tls, x, int32(65000)) + } + if -fn > float64(65000) { + return Xscalbn(tls, x, -int32(65000)) + } + return Xscalbn(tls, x, int32(fn)) +} + +func Xscalbf(tls *TLS, x float32, fn float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v fn=%v, (%v:)", tls, x, fn, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3 uint32 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _ = v1, v3, v5 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0; !v5 { + *(*float32)(unsafe.Pointer(bp)) = fn + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return float32(x * fn) + } + *(*float32)(unsafe.Pointer(bp)) = fn + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _7 +_7: + if !(BoolInt32(v1&Uint32FromInt32(0x7fffffff) < Uint32FromInt32(0x7f800000)) != 0) { + if fn > Float32FromFloat32(0) { + return float32(x * fn) + } else { + return x / -fn + } + } + if Xrintf(tls, fn) != fn { + return (fn - fn) / (fn - fn) + } + if fn > Float32FromFloat32(65000) { + return Xscalbnf(tls, x, int32(65000)) + } + if -fn > Float32FromFloat32(65000) { + return Xscalbnf(tls, x, -int32(65000)) + } + return Xscalbnf(tls, x, int32(fn)) +} + +func Xscalbln(tls *TLS, x float64, n int64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n > int64(INT_MAX) { + n = int64(INT_MAX) + } else { + if n < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff)) { + n = int64(-Int32FromInt32(1) - Int32FromInt32(0x7fffffff)) + } + } + return Xscalbn(tls, x, int32(n)) +} + +func Xscalblnf(tls *TLS, x float32, n int64) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n > int64(INT_MAX) { + n = int64(INT_MAX) + } else { + if n < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff)) { + n = int64(-Int32FromInt32(1) - Int32FromInt32(0x7fffffff)) + } + } + return Xscalbnf(tls, x, int32(n)) +} + +func Xscalblnl(tls *TLS, x float64, n int64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbln(tls, x, n) +} + +func Xscalbn(tls *TLS, x float64, n int32) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var y Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = y + y = x + if n > int32(1023) { + y = y * float64(8.98846567431158e+307) + n = n - int32(1023) + if n > int32(1023) { + y = y * float64(8.98846567431158e+307) + n = n - int32(1023) + if n > int32(1023) { + n = int32(1023) + } + } + } else { + if n < -int32(1022) { + /* make sure final n < -53 to avoid double + rounding in the subnormal range */ + y = y * Tdouble_t(Float64FromFloat64(2.2250738585072014e-308)*Float64FromFloat64(9.007199254740992e+15)) + n = n + (Int32FromInt32(1022) - Int32FromInt32(53)) + if n < -int32(1022) { + y = y * Tdouble_t(Float64FromFloat64(2.2250738585072014e-308)*Float64FromFloat64(9.007199254740992e+15)) + n = n + (Int32FromInt32(1022) - Int32FromInt32(53)) + if n < -int32(1022) { + n = -int32(1022) + } + } + } + } + *(*Tuint64_t)(unsafe.Pointer(bp)) = Uint64FromInt32(Int32FromInt32(0x3ff)+n) << int32(52) + x = float64(y * *(*float64)(unsafe.Pointer(bp))) + return x +} + +func Xscalbnf(tls *TLS, x float32, n int32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var y Tfloat_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _ = y + y = x + if n > int32(127) { + y = y * Float32FromFloat32(1.7014118346046923e+38) + n = n - int32(127) + if n > int32(127) { + y = y * Float32FromFloat32(1.7014118346046923e+38) + n = n - int32(127) + if n > int32(127) { + n = int32(127) + } + } + } else { + if n < -int32(126) { + y = y * Tfloat_t(Float32FromFloat32(1.1754943508222875e-38)*Float32FromFloat32(1.6777216e+07)) + n = n + (Int32FromInt32(126) - Int32FromInt32(24)) + if n < -int32(126) { + y = y * Tfloat_t(Float32FromFloat32(1.1754943508222875e-38)*Float32FromFloat32(1.6777216e+07)) + n = n + (Int32FromInt32(126) - Int32FromInt32(24)) + if n < -int32(126) { + n = -int32(126) + } + } + } + } + *(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32(Int32FromInt32(0x7f)+n) << int32(23) + x = float32(y * *(*float32)(unsafe.Pointer(bp))) + return x +} + +func Xscalbnl(tls *TLS, x float64, n int32) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbn(tls, x, n) +} + +func Xsignificand(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbn(tls, x, -Xilogb(tls, x)) +} + +func Xsignificandf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbnf(tls, x, -Xilogbf(tls, x)) +} + +func Xsin(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n uint32 + var y float32 + var y1, y2, v1 float64 + var _ /* y at bp+0 */ [2]float64 + _, _, _, _, _, _ = ix, n, y, y1, y2, v1 + /* High word of x. */ + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* |x| ~< pi/4 */ + if ix <= uint32(0x3fe921fb) { + if ix < uint32(0x3e500000) { /* |x| < 2**-26 */ + /* raise inexact if x != 0 and underflow if subnormal*/ + if uint64(8) == uint64(4) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y = float32(v1) + } else { + if uint64(8) == uint64(8) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y1 = v1 + } else { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y2 = v1 + } + } + return x3 + } + return X__sin(tls, x3, float64(0), 0) + } + /* sin(Inf or NaN) is NaN */ + if ix >= uint32(0x7ff00000) { + return x3 - x3 + } + /* argument reduction needed */ + n = Uint32FromInt32(X__rem_pio2(tls, x3, bp)) + switch n & Uint32FromInt32(3) { + case uint32(0): + return X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + case uint32(1): + return X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + case uint32(2): + return -X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + default: + return -X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + } + return r +} + +func Xsincos(tls *TLS, x3 float64, sin uintptr, cos uintptr) { + if __ccgo_strace { + trc("tls=%v x3=%v sin=%v cos=%v, (%v:)", tls, x3, sin, cos, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, s, y1, y2, v1 float64 + var ix Tuint32_t + var n uint32 + var y float32 + var _ /* y at bp+0 */ [2]float64 + _, _, _, _, _, _, _, _ = c, ix, n, s, y, y1, y2, v1 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* |x| ~< pi/4 */ + if ix <= uint32(0x3fe921fb) { + /* if |x| < 2**-27 * sqrt(2) */ + if ix < uint32(0x3e46a09e) { + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(8) == uint64(4) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y = float32(v1) + } else { + if uint64(8) == uint64(8) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y1 = v1 + } else { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y2 = v1 + } + } + **(**float64)(__ccgo_up(sin)) = x3 + **(**float64)(__ccgo_up(cos)) = float64(1) + return + } + **(**float64)(__ccgo_up(sin)) = X__sin(tls, x3, float64(0), 0) + **(**float64)(__ccgo_up(cos)) = X__cos(tls, x3, float64(0)) + return + } + /* sincos(Inf or NaN) is NaN */ + if ix >= uint32(0x7ff00000) { + v1 = x3 - x3 + **(**float64)(__ccgo_up(cos)) = v1 + **(**float64)(__ccgo_up(sin)) = v1 + return + } + /* argument reduction needed */ + n = Uint32FromInt32(X__rem_pio2(tls, x3, bp)) + s = X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + c = X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + switch n & Uint32FromInt32(3) { + case uint32(0): + **(**float64)(__ccgo_up(sin)) = s + **(**float64)(__ccgo_up(cos)) = c + case uint32(1): + **(**float64)(__ccgo_up(sin)) = c + **(**float64)(__ccgo_up(cos)) = -s + case uint32(2): + **(**float64)(__ccgo_up(sin)) = -s + **(**float64)(__ccgo_up(cos)) = -c + case uint32(3): + fallthrough + default: + **(**float64)(__ccgo_up(sin)) = -c + **(**float64)(__ccgo_up(cos)) = s + break + } +} + +const M_PI_25 = 1.5707963267948966 + +// C documentation +// +// /* Small multiples of pi/2 rounded to double precision. */ + +var _s1pio2 = float64(Float64FromInt32(1) * Float64FromFloat64(1.5707963267948966)) /* 0x3FF921FB, 0x54442D18 */ +var _s2pio2 = float64(Float64FromInt32(2) * Float64FromFloat64(1.5707963267948966)) /* 0x400921FB, 0x54442D18 */ +var _s3pio2 = float64(Float64FromInt32(3) * Float64FromFloat64(1.5707963267948966)) /* 0x4012D97C, 0x7F3321D2 */ +var _s4pio2 = float64(Float64FromInt32(4) * Float64FromFloat64(1.5707963267948966)) /* 0x401921FB, 0x54442D18 */ + +func Xsincosf(tls *TLS, x3 float32, sin uintptr, cos uintptr) { + if __ccgo_strace { + trc("tls=%v x3=%v sin=%v cos=%v, (%v:)", tls, x3, sin, cos, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, s Tfloat_t + var ix Tuint32_t + var n, sign uint32 + var y, v1 float32 + var y1, y2, v4 float64 + var _ /* y at bp+0 */ float64 + _, _, _, _, _, _, _, _, _, _ = c, ix, n, s, sign, y, y1, y2, v1, v4 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + /* |x| ~<= pi/4 */ + if ix <= uint32(0x3f490fda) { + /* |x| < 2**-12 */ + if ix < uint32(0x39800000) { + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(4) == uint64(4) { + if ix < uint32(0x00100000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y = v1 + } else { + if uint64(4) == uint64(8) { + if ix < uint32(0x00100000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y1 = float64(v1) + } else { + if ix < uint32(0x00100000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y2 = float64(v1) + } + } + **(**float32)(__ccgo_up(sin)) = x3 + **(**float32)(__ccgo_up(cos)) = Float32FromFloat32(1) + return + } + **(**float32)(__ccgo_up(sin)) = X__sindf(tls, float64(x3)) + **(**float32)(__ccgo_up(cos)) = X__cosdf(tls, float64(x3)) + return + } + /* |x| ~<= 5*pi/4 */ + if ix <= uint32(0x407b53d1) { + if ix <= uint32(0x4016cbe3) { /* |x| ~<= 3pi/4 */ + if sign != 0 { + **(**float32)(__ccgo_up(sin)) = -X__cosdf(tls, float64(x3)+_s1pio2) + **(**float32)(__ccgo_up(cos)) = X__sindf(tls, float64(x3)+_s1pio2) + } else { + **(**float32)(__ccgo_up(sin)) = X__cosdf(tls, _s1pio2-float64(x3)) + **(**float32)(__ccgo_up(cos)) = X__sindf(tls, _s1pio2-float64(x3)) + } + return + } + /* -sin(x+c) is not correct if x+c could be 0: -0 vs +0 */ + if sign != 0 { + v4 = float64(x3) + _s2pio2 + } else { + v4 = float64(x3) - _s2pio2 + } + **(**float32)(__ccgo_up(sin)) = -X__sindf(tls, v4) + if sign != 0 { + v4 = float64(x3) + _s2pio2 + } else { + v4 = float64(x3) - _s2pio2 + } + **(**float32)(__ccgo_up(cos)) = -X__cosdf(tls, v4) + return + } + /* |x| ~<= 9*pi/4 */ + if ix <= uint32(0x40e231d5) { + if ix <= uint32(0x40afeddf) { /* |x| ~<= 7*pi/4 */ + if sign != 0 { + **(**float32)(__ccgo_up(sin)) = X__cosdf(tls, float64(x3)+_s3pio2) + **(**float32)(__ccgo_up(cos)) = -X__sindf(tls, float64(x3)+_s3pio2) + } else { + **(**float32)(__ccgo_up(sin)) = -X__cosdf(tls, float64(x3)-_s3pio2) + **(**float32)(__ccgo_up(cos)) = X__sindf(tls, float64(x3)-_s3pio2) + } + return + } + if sign != 0 { + v4 = float64(x3) + _s4pio2 + } else { + v4 = float64(x3) - _s4pio2 + } + **(**float32)(__ccgo_up(sin)) = X__sindf(tls, v4) + if sign != 0 { + v4 = float64(x3) + _s4pio2 + } else { + v4 = float64(x3) - _s4pio2 + } + **(**float32)(__ccgo_up(cos)) = X__cosdf(tls, v4) + return + } + /* sin(Inf or NaN) is NaN */ + if ix >= uint32(0x7f800000) { + v1 = x3 - x3 + **(**float32)(__ccgo_up(cos)) = v1 + **(**float32)(__ccgo_up(sin)) = v1 + return + } + /* general argument reduction needed */ + n = Uint32FromInt32(X__rem_pio2f(tls, x3, bp)) + s = X__sindf(tls, **(**float64)(__ccgo_up(bp))) + c = X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + switch n & Uint32FromInt32(3) { + case uint32(0): + **(**float32)(__ccgo_up(sin)) = s + **(**float32)(__ccgo_up(cos)) = c + case uint32(1): + **(**float32)(__ccgo_up(sin)) = c + **(**float32)(__ccgo_up(cos)) = -s + case uint32(2): + **(**float32)(__ccgo_up(sin)) = -s + **(**float32)(__ccgo_up(cos)) = -c + case uint32(3): + fallthrough + default: + **(**float32)(__ccgo_up(sin)) = -c + **(**float32)(__ccgo_up(cos)) = s + break + } +} + +const M_PI_26 = 0 + +func Xsincosl(tls *TLS, x float64, sin uintptr, cos uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v sin=%v cos=%v, (%v:)", tls, x, sin, cos, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* cosd at bp+8 */ float64 + var _ /* sind at bp+0 */ float64 + Xsincos(tls, x, bp, bp+8) + **(**float64)(__ccgo_up(sin)) = float64(**(**float64)(__ccgo_up(bp))) + **(**float64)(__ccgo_up(cos)) = float64(**(**float64)(__ccgo_up(bp + 8))) +} + +const M_PI_27 = 1.5707963267948966 + +// C documentation +// +// /* Small multiples of pi/2 rounded to double precision. */ + +var _s1pio21 = float64(Float64FromInt32(1) * Float64FromFloat64(1.5707963267948966)) /* 0x3FF921FB, 0x54442D18 */ +var _s2pio21 = float64(Float64FromInt32(2) * Float64FromFloat64(1.5707963267948966)) /* 0x400921FB, 0x54442D18 */ +var _s3pio21 = float64(Float64FromInt32(3) * Float64FromFloat64(1.5707963267948966)) /* 0x4012D97C, 0x7F3321D2 */ +var _s4pio21 = float64(Float64FromInt32(4) * Float64FromFloat64(1.5707963267948966)) /* 0x401921FB, 0x54442D18 */ + +func Xsinf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n, sign int32 + var y, v1 float32 + var y1, y2, v4 float64 + var _ /* y at bp+0 */ float64 + _, _, _, _, _, _, _, _ = ix, n, sign, y, y1, y2, v1, v4 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix <= uint32(0x3f490fda) { /* |x| ~<= pi/4 */ + if ix < uint32(0x39800000) { /* |x| < 2**-12 */ + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(4) == uint64(4) { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y = v1 + } else { + if uint64(4) == uint64(8) { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y1 = float64(v1) + } else { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y2 = float64(v1) + } + } + return x3 + } + return X__sindf(tls, float64(x3)) + } + if ix <= uint32(0x407b53d1) { /* |x| ~<= 5*pi/4 */ + if ix <= uint32(0x4016cbe3) { /* |x| ~<= 3pi/4 */ + if sign != 0 { + return -X__cosdf(tls, float64(x3)+_s1pio21) + } else { + return X__cosdf(tls, float64(x3)-_s1pio21) + } + } + if sign != 0 { + v4 = -(float64(x3) + _s2pio21) + } else { + v4 = -(float64(x3) - _s2pio21) + } + return X__sindf(tls, v4) + } + if ix <= uint32(0x40e231d5) { /* |x| ~<= 9*pi/4 */ + if ix <= uint32(0x40afeddf) { /* |x| ~<= 7*pi/4 */ + if sign != 0 { + return X__cosdf(tls, float64(x3)+_s3pio21) + } else { + return -X__cosdf(tls, float64(x3)-_s3pio21) + } + } + if sign != 0 { + v4 = float64(x3) + _s4pio21 + } else { + v4 = float64(x3) - _s4pio21 + } + return X__sindf(tls, v4) + } + /* sin(Inf or NaN) is NaN */ + if ix >= uint32(0x7f800000) { + return x3 - x3 + } + /* general argument reduction needed */ + n = X__rem_pio2f(tls, x3, bp) + switch n & Int32FromInt32(3) { + case 0: + return X__sindf(tls, **(**float64)(__ccgo_up(bp))) + case int32(1): + return X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + case int32(2): + return X__sindf(tls, -**(**float64)(__ccgo_up(bp))) + default: + return -X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + } + return r +} + +const M_PI_28 = 0 + +// C documentation +// +// /* sinh(x) = (exp(x) - 1/exp(x))/2 +// * = (exp(x)-1 + (exp(x)-1)/exp(x))/2 +// * = x + x^3/6 + o(x^5) +// */ +func Xsinh(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var absx, h, t float64 + var w Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _ = absx, h, t, w + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + h = float64(0.5) + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + h = -h + } + /* |x| */ + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + absx = *(*float64)(unsafe.Pointer(bp)) + w = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + /* |x| < log(DBL_MAX) */ + if w < uint32(0x40862e42) { + t = Xexpm1(tls, absx) + if w < uint32(0x3ff00000) { + if w < Uint32FromInt32(Int32FromInt32(0x3ff00000)-Int32FromInt32(26)<log(0x1p26)+eps could be just h*exp(x) */ + return float64(h * (t + t/(t+Float64FromInt32(1)))) + } + /* |x| > log(DBL_MAX) or nan */ + /* note: the result is stored to handle overflow */ + t = X__expo2(tls, absx, float64(Float64FromInt32(2)*h)) + return t +} + +func Xsinhf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var absx, h, t float32 + var w Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _ = absx, h, t, w + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + h = float32(0.5) + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + h = -h + } + /* |x| */ + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + absx = *(*float32)(unsafe.Pointer(bp)) + w = *(*Tuint32_t)(unsafe.Pointer(bp)) + /* |x| < log(FLT_MAX) */ + if w < uint32(0x42b17217) { + t = Xexpm1f(tls, absx) + if w < uint32(0x3f800000) { + if w < Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(12)< logf(FLT_MAX) or nan */ + t = X__expo2f(tls, absx, float32(Float32FromInt32(2)*h)) + return t +} + +func Xsinhl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsinh(tls, x) +} + +func Xsinl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsin(tls, x) +} + +const FENV_SUPPORT = 1 + +// C documentation +// +// /* returns a*b*2^-32 - e, with error 0 <= e < 1. */ +func _mul32(tls *TLS, a Tuint32_t, b Tuint32_t) (r Tuint32_t) { + return uint32(uint64(a) * uint64(b) >> int32(32)) +} + +// C documentation +// +// /* returns a*b*2^-64 - e, with error 0 <= e < 3. */ +func _mul64(tls *TLS, a Tuint64_t, b Tuint64_t) (r Tuint64_t) { + var ahi, alo, bhi, blo Tuint64_t + _, _, _, _ = ahi, alo, bhi, blo + ahi = a >> int32(32) + alo = a & uint64(0xffffffff) + bhi = b >> int32(32) + blo = b & uint64(0xffffffff) + return ahi*bhi + ahi*blo>>int32(32) + alo*bhi>>int32(32) +} + +func Xsqrt(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var d, d0, d1, d2, i, ix, m, r, s, tiny, top, u Tuint64_t + var even int32 + var t, y, y1, v1 float64 + var v2 int64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = d, d0, d1, d2, even, i, ix, m, r, s, t, tiny, top, u, y, y1, v1, v2 + /* special case handling. */ + ix = *(*Tuint64_t)(unsafe.Pointer(&x1)) + top = ix >> int32(52) + if top-uint64(0x001) >= Uint64FromInt32(Int32FromInt32(0x7ff)-Int32FromInt32(0x001)) { + /* x < 0x1p-1022 or inf or nan. */ + if ix*uint64(2) == uint64(0) { + return x1 + } + if ix == uint64(0x7ff0000000000000) { + return x1 + } + if ix > uint64(0x7ff0000000000000) { + return X__math_invalid(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float64(x1 * float64(4.503599627370496e+15)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + top = ix >> int32(52) + top = top - uint64(52) + } + /* argument reduction: + x = 4^e m; with integer e, and m in [1, 4) + m: fixed point representation [2.62] + 2^e is the exponent part of the result. */ + even = Int32FromUint64(top & uint64(1)) + m = ix<> uint64(1) + } + top = (top + uint64(0x3ff)) >> int32(1) + i = ix >> Int32FromInt32(46) % uint64(128) + r = uint64(uint32(X__rsqrt_tab[i]) << int32(16)) + /* |r sqrt(m) - 1| < 0x1.fdp-9 */ + s = uint64(_mul32(tls, uint32(m>>int32(32)), uint32(r))) + /* |s/sqrt(m) - 1| < 0x1.fdp-9 */ + d = uint64(_mul32(tls, uint32(s), uint32(r))) + u = _three - d + r = uint64(_mul32(tls, uint32(r), uint32(u)) << int32(1)) + /* |r sqrt(m) - 1| < 0x1.7bp-16 */ + s = uint64(_mul32(tls, uint32(s), uint32(u)) << int32(1)) + /* |s/sqrt(m) - 1| < 0x1.7bp-16 */ + d = uint64(_mul32(tls, uint32(s), uint32(r))) + u = _three - d + r = uint64(_mul32(tls, uint32(r), uint32(u)) << int32(1)) + /* |r sqrt(m) - 1| < 0x1.3704p-29 (measured worst-case) */ + r = r << int32(32) + s = _mul64(tls, m, r) + d = _mul64(tls, s, r) + u = _three<> int32(9) + d0 = m<>int32(63) + s = s & uint64(0x000fffffffffffff) + s = s | top<=13bit table would be needed (16k). + + a newton-raphson iteration for r is + w = r*r + u = 3 - m*w + r = r*u/2 + can use a goldschmidt iteration for s at the end or + s = m*r + + first goldschmidt iteration is + s = m*r + u = 3 - s*r + r = r*u/2 + s = s*u/2 + next goldschmidt iteration is + u = 3 - s*r + r = r*u/2 + s = s*u/2 + and at the end r is not computed only s. + + they use the same amount of operations and converge at the + same quadratic rate, i.e. if + r1 sqrt(m) - 1 = e, then + r2 sqrt(m) - 1 = -3/2 e^2 - 1/2 e^3 + the advantage of goldschmidt is that the mul for s and r + are independent (computed in parallel), however it is not + "self synchronizing": it only uses the input m in the + first iteration so rounding errors accumulate. at the end + or when switching to larger precision arithmetics rounding + errors dominate so the first iteration should be used. + + the fixed point representations are + m: 2.30 r: 0.32, s: 2.30, d: 2.30, u: 2.30, three: 2.30 + and after switching to 64 bit + m: 2.62 r: 0.64, s: 2.62, d: 2.62, u: 2.62, three: 2.62 */ + +var _three = uint64(0xc0000000) + +func _mul321(tls *TLS, a Tuint32_t, b Tuint32_t) (r Tuint32_t) { + return uint32(uint64(a) * uint64(b) >> int32(32)) +} + +/* see sqrt.c for more detailed comments. */ + +func Xsqrtf(tls *TLS, x1 float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var d, d0, d1, d2, even, ey, i, ix, m, m0, m1, r, s, tiny, u Tuint32_t + var t, y, y1, v1 float32 + var v2 uint32 + var v3 int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = d, d0, d1, d2, even, ey, i, ix, m, m0, m1, r, s, t, tiny, u, y, y1, v1, v2, v3 + ix = *(*Tuint32_t)(unsafe.Pointer(&x1)) + if ix-uint32(0x00800000) >= Uint32FromInt32(Int32FromInt32(0x7f800000)-Int32FromInt32(0x00800000)) { + /* x < 0x1p-126 or inf or nan. */ + if ix*uint32(2) == uint32(0) { + return x1 + } + if ix == uint32(0x7f800000) { + return x1 + } + if ix > uint32(0x7f800000) { + return X__math_invalidf(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float32(x1 * Float32FromFloat32(8.388608e+06)) + ix = *(*Tuint32_t)(unsafe.Pointer(&v1)) + ix = ix - Uint32FromInt32(Int32FromInt32(23)<> int32(1) + ey = ey + Uint32FromInt32(Int32FromInt32(0x3f800000)>>Int32FromInt32(1)) + ey = ey & uint32(0x7f800000) + i = ix >> Int32FromInt32(17) % uint32(128) + r = uint32(X__rsqrt_tab[i]) << int32(16) + /* |r*sqrt(m) - 1| < 0x1p-8 */ + s = _mul321(tls, m, r) + /* |s/sqrt(m) - 1| < 0x1p-8 */ + d = _mul321(tls, s, r) + u = _three1 - d + r = _mul321(tls, r, u) << int32(1) + /* |r*sqrt(m) - 1| < 0x1.7bp-16 */ + s = _mul321(tls, s, u) << int32(1) + /* |s/sqrt(m) - 1| < 0x1.7bp-16 */ + d = _mul321(tls, s, r) + u = _three1 - d + s = _mul321(tls, s, u) + /* -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 */ + s = (s - uint32(1)) >> int32(6) + d0 = m<>int32(31) + s = s & uint32(0x007fffff) + s = s | ey + y1 = *(*float32)(unsafe.Pointer(&s)) + if int32(FENV_SUPPORT) != 0 { + if d2 == uint32(0) { + v3 = 0 + } else { + v3 = int32(0x01000000) + } + /* handle rounding and inexact exception. */ + tiny = Uint32FromInt32(v3) + tiny = tiny | (d1^d2)&uint32(0x80000000) + t = *(*float32)(unsafe.Pointer(&tiny)) + y = y1 + t + v1 = y + goto _5 + _5: + y1 = v1 + } + return y1 +} + +/* compute r ~ 1/sqrt(m), s ~ sqrt(m) with 2 goldschmidt iterations. */ +var _three1 = uint32(0xc0000000) + +func Xsqrtl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsqrt(tls, x) +} + +func Xtan(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n uint32 + var y float32 + var y1, y2, v1 float64 + var _ /* y at bp+0 */ [2]float64 + _, _, _, _, _, _ = ix, n, y, y1, y2, v1 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* |x| ~< pi/4 */ + if ix <= uint32(0x3fe921fb) { + if ix < uint32(0x3e400000) { /* |x| < 2**-27 */ + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(8) == uint64(4) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y = float32(v1) + } else { + if uint64(8) == uint64(8) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y1 = v1 + } else { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y2 = v1 + } + } + return x3 + } + return X__tan(tls, x3, float64(0), 0) + } + /* tan(Inf or NaN) is NaN */ + if ix >= uint32(0x7ff00000) { + return x3 - x3 + } + /* argument reduction */ + n = Uint32FromInt32(X__rem_pio2(tls, x3, bp)) + return X__tan(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], Int32FromUint32(n&uint32(1))) +} + +const M_PI_29 = 1.5707963267948966 + +// C documentation +// +// /* Small multiples of pi/2 rounded to double precision. */ + +var _t1pio2 = float64(Float64FromInt32(1) * Float64FromFloat64(1.5707963267948966)) /* 0x3FF921FB, 0x54442D18 */ +var _t2pio2 = float64(Float64FromInt32(2) * Float64FromFloat64(1.5707963267948966)) /* 0x400921FB, 0x54442D18 */ +var _t3pio2 = float64(Float64FromInt32(3) * Float64FromFloat64(1.5707963267948966)) /* 0x4012D97C, 0x7F3321D2 */ +var _t4pio2 = float64(Float64FromInt32(4) * Float64FromFloat64(1.5707963267948966)) /* 0x401921FB, 0x54442D18 */ + +func Xtanf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n, sign uint32 + var y, v1 float32 + var y1, y2, v4 float64 + var _ /* y at bp+0 */ float64 + _, _, _, _, _, _, _, _ = ix, n, sign, y, y1, y2, v1, v4 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + if ix <= uint32(0x3f490fda) { /* |x| ~<= pi/4 */ + if ix < uint32(0x39800000) { /* |x| < 2**-12 */ + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(4) == uint64(4) { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y = v1 + } else { + if uint64(4) == uint64(8) { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y1 = float64(v1) + } else { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y2 = float64(v1) + } + } + return x3 + } + return X__tandf(tls, float64(x3), 0) + } + if ix <= uint32(0x407b53d1) { /* |x| ~<= 5*pi/4 */ + if ix <= uint32(0x4016cbe3) { /* |x| ~<= 3pi/4 */ + if sign != 0 { + v4 = float64(x3) + _t1pio2 + } else { + v4 = float64(x3) - _t1pio2 + } + return X__tandf(tls, v4, int32(1)) + } else { + if sign != 0 { + v4 = float64(x3) + _t2pio2 + } else { + v4 = float64(x3) - _t2pio2 + } + return X__tandf(tls, v4, 0) + } + } + if ix <= uint32(0x40e231d5) { /* |x| ~<= 9*pi/4 */ + if ix <= uint32(0x40afeddf) { /* |x| ~<= 7*pi/4 */ + if sign != 0 { + v4 = float64(x3) + _t3pio2 + } else { + v4 = float64(x3) - _t3pio2 + } + return X__tandf(tls, v4, int32(1)) + } else { + if sign != 0 { + v4 = float64(x3) + _t4pio2 + } else { + v4 = float64(x3) - _t4pio2 + } + return X__tandf(tls, v4, 0) + } + } + /* tan(Inf or NaN) is NaN */ + if ix >= uint32(0x7f800000) { + return x3 - x3 + } + /* argument reduction */ + n = Uint32FromInt32(X__rem_pio2f(tls, x3, bp)) + return X__tandf(tls, **(**float64)(__ccgo_up(bp)), Int32FromUint32(n&uint32(1))) +} + +const M_PI_210 = 0 + +// C documentation +// +// /* tanh(x) = (exp(x) - exp(-x))/(exp(x) + exp(-x)) +// * = (exp(2*x) - 1)/(exp(2*x) - 1 + 2) +// * = (1 - exp(-2*x))/(exp(-2*x) - 1 + 2) +// */ +func Xtanh(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var sign int32 + var t, v1 Tdouble_t + var w Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _ = sign, t, w, y, y1, y2, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + /* x = |x| */ + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + x3 = *(*float64)(unsafe.Pointer(bp)) + w = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + if w > uint32(0x3fe193ea) { + /* |x| > log(3)/2 ~= 0.5493 or nan */ + if w > uint32(0x40340000) { + /* |x| > 20 or nan */ + /* note: this branch avoids raising overflow */ + t = Float64FromInt32(1) - Float64FromInt32(0)/x3 + } else { + t = Xexpm1(tls, float64(Float64FromInt32(2)*x3)) + t = Float64FromInt32(1) - Float64FromInt32(2)/(t+Float64FromInt32(2)) + } + } else { + if w > uint32(0x3fd058ae) { + /* |x| > log(5/3)/2 ~= 0.2554 */ + t = Xexpm1(tls, float64(Float64FromInt32(2)*x3)) + t = t / (t + Float64FromInt32(2)) + } else { + if w >= uint32(0x00100000) { + /* |x| >= 0x1p-1022, up to 2ulp error in [0.1,0.2554] */ + t = Xexpm1(tls, float64(float64(-Int32FromInt32(2))*x3)) + t = -t / (t + Float64FromInt32(2)) + } else { + /* |x| is subnormal */ + /* note: the branch above would not raise underflow in [0x1p-1023,0x1p-1022) */ + if uint64(4) == uint64(4) { + y = float32(x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3)) + } else { + y2 = float64(float32(x3)) + } + } + t = x3 + } + } + } + if sign != 0 { + v1 = -t + } else { + v1 = t + } + return v1 +} + +func Xtanhf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var sign int32 + var t, y, v1 float32 + var w Tuint32_t + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _ = sign, t, w, y, y1, y2, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + /* x = |x| */ + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + x3 = *(*float32)(unsafe.Pointer(bp)) + w = *(*Tuint32_t)(unsafe.Pointer(bp)) + if w > uint32(0x3f0c9f54) { + /* |x| > log(3)/2 ~= 0.5493 or nan */ + if w > uint32(0x41200000) { + /* |x| > 10 */ + t = Float32FromInt32(1) + Float32FromInt32(0)/x3 + } else { + t = Xexpm1f(tls, float32(Float32FromInt32(2)*x3)) + t = Float32FromInt32(1) - Float32FromInt32(2)/(t+Float32FromInt32(2)) + } + } else { + if w > uint32(0x3e82c578) { + /* |x| > log(5/3)/2 ~= 0.2554 */ + t = Xexpm1f(tls, float32(Float32FromInt32(2)*x3)) + t = t / (t + Float32FromInt32(2)) + } else { + if w >= uint32(0x00800000) { + /* |x| >= 0x1p-126 */ + t = Xexpm1f(tls, float32(float32(-Int32FromInt32(2))*x3)) + t = -t / (t + Float32FromInt32(2)) + } else { + /* |x| is subnormal */ + if uint64(4) == uint64(4) { + y = float32(x3 * x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 * x3) + } else { + y2 = float64(x3 * x3) + } + } + t = x3 + } + } + } + if sign != 0 { + v1 = -t + } else { + v1 = t + } + return v1 +} + +func Xtanhl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtanh(tls, x) +} + +func Xtanl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtan(tls, x) +} + +const N10 = 12 + +var _pi4 = float64(3.141592653589793) + +// C documentation +// +// /* sin(pi x) with x > 0x1p-100, if sin(pi*x)==0 the sign is arbitrary */ +func _sinpi(tls *TLS, x float64) (r float64) { + var n int32 + _ = n + /* argument reduction: x = |x| mod 2 */ + /* spurious inexact when x is odd int */ + x = float64(x * float64(0.5)) + x = float64(Float64FromInt32(2) * (x - Xfloor(tls, x))) + /* reduce x into [-.25,.25] */ + n = int32(Float64FromInt32(4) * x) + n = (n + int32(1)) / int32(2) + x = x - float64(float64(n)*float64(0.5)) + x = x * _pi4 + switch n { + default: /* case 4 */ + fallthrough + case 0: + return X__sin(tls, x, Float64FromInt32(0), 0) + case int32(1): + return X__cos(tls, x, Float64FromInt32(0)) + case int32(2): + return X__sin(tls, -x, Float64FromInt32(0), 0) + case int32(3): + return -X__cos(tls, x, Float64FromInt32(0)) + } + return r +} + +// C documentation +// +// //static const double g = 6.024680040776729583740234375; +var _gmhalf = float64(5.52468004077673) +var _Snum = [13]float64{ + 0: float64(2.353137688041076e+10), + 1: float64(4.29198036426491e+10), + 2: float64(3.571195923735567e+10), + 3: float64(1.792103442603721e+10), + 4: float64(6.039542586352028e+09), + 5: float64(1.4397204073117216e+09), + 6: float64(2.4887455786205417e+08), + 7: float64(3.1426415585400194e+07), + 8: float64(2.8763706289353725e+06), + 9: float64(186056.26539522348), + 10: float64(8071.672002365816), + 11: float64(210.82427775157936), + 12: float64(2.5066282746310002), +} +var _Sden = [13]float64{ + 1: Float64FromInt32(39916800), + 2: Float64FromInt32(120543840), + 3: Float64FromInt32(150917976), + 4: Float64FromInt32(105258076), + 5: Float64FromInt32(45995730), + 6: Float64FromInt32(13339535), + 7: Float64FromInt32(2637558), + 8: Float64FromInt32(357423), + 9: Float64FromInt32(32670), + 10: Float64FromInt32(1925), + 11: Float64FromInt32(66), + 12: Float64FromInt32(1), +} + +// C documentation +// +// /* n! for small integer n */ +var _fact = [23]float64{ + 0: Float64FromInt32(1), + 1: Float64FromInt32(1), + 2: Float64FromInt32(2), + 3: Float64FromInt32(6), + 4: Float64FromInt32(24), + 5: Float64FromInt32(120), + 6: Float64FromInt32(720), + 7: float64(5040), + 8: float64(40320), + 9: float64(362880), + 10: float64(3.6288e+06), + 11: float64(3.99168e+07), + 12: float64(4.790016e+08), + 13: float64(6.2270208e+09), + 14: float64(8.71782912e+10), + 15: float64(1.307674368e+12), + 16: float64(2.0922789888e+13), + 17: float64(3.55687428096e+14), + 18: float64(6.402373705728e+15), + 19: float64(1.21645100408832e+17), + 20: float64(2.43290200817664e+18), + 21: float64(5.109094217170944e+19), + 22: float64(1.1240007277776077e+21), +} + +// C documentation +// +// /* S(x) rational function for positive x */ +func _S(tls *TLS, x float64) (r float64) { + var den, num Tdouble_t + var i int32 + _, _, _ = den, i, num + num = Float64FromInt32(0) + den = Float64FromInt32(0) + /* to avoid overflow handle large x differently */ + if x < Float64FromInt32(8) { + i = int32(N10) + for { + if !(i >= 0) { + break + } + num = Tdouble_t(num*x) + _Snum[i] + den = Tdouble_t(den*x) + _Sden[i] + goto _1 + _1: + ; + i = i - 1 + } + } else { + i = 0 + for { + if !(i <= int32(N10)) { + break + } + num = num/x + _Snum[i] + den = den/x + _Sden[i] + goto _2 + _2: + ; + i = i + 1 + } + } + return num / den +} + +func Xtgamma(tls *TLS, x3 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var absx, y1, y2, y3, v1 float64 + var dy, r, z Tdouble_t + var ix Tuint32_t + var sign int32 + var y float32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _ = absx, dy, ix, r, sign, y, y1, y2, y3, z, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + /* special cases */ + if ix >= uint32(0x7ff00000) { + /* tgamma(nan)=nan, tgamma(inf)=inf, tgamma(-inf)=nan with invalid */ + return x3 + float64(X__builtin_inff(tls)) + } + if ix < Uint32FromInt32((Int32FromInt32(0x3ff)-Int32FromInt32(54))<= 172: tgamma(x)=inf with overflow */ + /* x =< -184: tgamma(x)=+-0 with underflow */ + if ix >= uint32(0x40670000) { /* |x| >= 184 */ + if sign != 0 { + if uint64(4) == uint64(4) { + y = float32(Float64FromFloat64(1.1754943508222875e-38) / x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(Float64FromFloat64(1.1754943508222875e-38) / x3)) + } else { + y2 = float64(float32(Float64FromFloat64(1.1754943508222875e-38) / x3)) + } + } + if float64(Xfloor(tls, x3)*float64(0.5)) == Xfloor(tls, float64(x3*float64(0.5))) { + return Float64FromInt32(0) + } + return -Float64FromFloat64(0) + } + x3 = x3 * float64(8.98846567431158e+307) + return x3 + } + if sign != 0 { + v1 = -x3 + } else { + v1 = x3 + } + absx = v1 + /* handle the error of x + g - 0.5 */ + y3 = absx + _gmhalf + if absx > _gmhalf { + dy = y3 - absx + dy = dy - _gmhalf + } else { + dy = y3 - _gmhalf + dy = dy - absx + } + z = absx - float64(0.5) + r = Tdouble_t(_S(tls, absx) * Xexp(tls, -y3)) + if x3 < Float64FromInt32(0) { + /* reflection formula for negative x */ + /* sinpi(absx) is not 0, integers are already handled */ + r = -_pi4 / float64(float64(_sinpi(tls, absx)*absx)*r) + dy = -dy + z = -z + } + r = r + Tdouble_t(Tdouble_t(dy*(_gmhalf+Float64FromFloat64(0.5)))*r)/y3 + z = Xpow(tls, y3, float64(float64(0.5)*z)) + y3 = float64(Tdouble_t(r*z) * z) + return y3 +} + +func Xtgammaf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float32(Xtgamma(tls, float64(x))) +} + +func Xtgammal(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtgamma(tls, x) +} + +func Xtrunc(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var m Tuint64_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _ = e, m, y, y1, y2 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp))>>Int32FromInt32(52)&Uint64FromInt32(0x7ff)) - int32(0x3ff) + int32(12) + if e >= Int32FromInt32(52)+Int32FromInt32(12) { + return x3 + } + if e < int32(12) { + e = int32(1) + } + m = uint64(-Uint64FromUint64(1) >> e) + if *(*Tuint64_t)(unsafe.Pointer(bp))&m == uint64(0) { + return x3 + } + if uint64(8) == uint64(4) { + y = float32(x3 + Float64FromFloat32(1.329227995784916e+36)) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } else { + y2 = float64(x3 + Float64FromFloat32(1.329227995784916e+36)) + } + } + *(*Tuint64_t)(unsafe.Pointer(bp)) &= ^m + return *(*float64)(unsafe.Pointer(bp)) +} + +func Xtruncf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var m Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e, m, y, y1, y2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp))>>Int32FromInt32(23)&Uint32FromInt32(0xff)) - int32(0x7f) + int32(9) + if e >= Int32FromInt32(23)+Int32FromInt32(9) { + return x3 + } + if e < int32(9) { + e = int32(1) + } + m = -Uint32FromUint32(1) >> e + if *(*Tuint32_t)(unsafe.Pointer(bp))&m == uint32(0) { + return x3 + } + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= ^m + return *(*float32)(unsafe.Pointer(bp)) +} + +func Xtruncl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtrunc(tls, x) +} + +var _digits = [65]int8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +func Xa64l(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d uintptr + var e int32 + var x Tuint32_t + _, _, _ = d, e, x + x = uint32(0) + e = 0 + for { + if !(e < int32(36) && **(**int8)(__ccgo_up(s)) != 0) { + break + } + d = Xstrchr(tls, uintptr(unsafe.Pointer(&_digits)), int32(**(**int8)(__ccgo_up(s)))) + if !(d != 0) { + break + } + x = x | Uint32FromInt64(int64(d)-t__predefined_ptrdiff_t(uintptr(unsafe.Pointer(&_digits))))< %v", r) }() + } + var p uintptr + var x Tuint32_t + _, _ = p, x + x = Uint32FromInt64(x0) + p = uintptr(unsafe.Pointer(&_s)) + for { + if !(x != 0) { + break + } + **(**int8)(__ccgo_up(p)) = _digits[x&uint32(63)] + goto _1 + _1: + ; + p = p + 1 + x = x >> uint32(6) + } + **(**int8)(__ccgo_up(p)) = 0 + return uintptr(unsafe.Pointer(&_s)) +} + +var _s [7]int8 + +func Xbasename(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i Tsize_t + _ = i + if !(s != 0) || !(**(**int8)(__ccgo_up(s)) != 0) { + return __ccgo_ts + 575 + } + i = _strlen(tls, s) - uint64(1) + for { + if !(i != 0 && int32(**(**int8)(__ccgo_up(s + uintptr(i)))) == int32('/')) { + break + } + **(**int8)(__ccgo_up(s + uintptr(i))) = 0 + goto _1 + _1: + ; + i = i - 1 + } + for { + if !(i != 0 && int32(**(**int8)(__ccgo_up(s + uintptr(i-uint64(1))))) != int32('/')) { + break + } + goto _2 + _2: + ; + i = i - 1 + } + return s + uintptr(i) +} + +func X__xpg_basename(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xbasename(tls, s) +} + +func Xdirname(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i Tsize_t + _ = i + if !(s != 0) || !(**(**int8)(__ccgo_up(s)) != 0) { + return __ccgo_ts + 575 + } + i = _strlen(tls, s) - uint64(1) + for { + if !(int32(**(**int8)(__ccgo_up(s + uintptr(i)))) == int32('/')) { + break + } + if !(i != 0) { + return __ccgo_ts + 587 + } + goto _1 + _1: + ; + i = i - 1 + } + for { + if !(int32(**(**int8)(__ccgo_up(s + uintptr(i)))) != int32('/')) { + break + } + if !(i != 0) { + return __ccgo_ts + 575 + } + goto _2 + _2: + ; + i = i - 1 + } + for { + if !(int32(**(**int8)(__ccgo_up(s + uintptr(i)))) == int32('/')) { + break + } + if !(i != 0) { + return __ccgo_ts + 587 + } + goto _3 + _3: + ; + i = i - 1 + } + **(**int8)(__ccgo_up(s + uintptr(i+uint64(1)))) = 0 + return s +} + +func Xffs(tls *TLS, i int32) (r int32) { + if __ccgo_strace { + trc("tls=%v i=%v, (%v:)", tls, i, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if i != 0 { + v1 = _a_ctz_l(tls, Uint64FromInt32(i)) + int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xffsl(tls *TLS, i int64) (r int32) { + if __ccgo_strace { + trc("tls=%v i=%v, (%v:)", tls, i, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if i != 0 { + v1 = _a_ctz_l(tls, Uint64FromInt64(i)) + int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xffsll(tls *TLS, i int64) (r int32) { + if __ccgo_strace { + trc("tls=%v i=%v, (%v:)", tls, i, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v3 int32 + var v2 Tuint64_t + _, _, _ = v1, v2, v3 + if i != 0 { + v2 = Uint64FromInt64(i) + // __asm__( "bsf %1,%0" : "=r"(x) : "r"(x) ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 114, __ccgo_ts+589) + v3 = Int32FromUint64(v2) + goto _4 + _4: + v1 = v3 + int32(1) + } else { + v1 = 0 + } + return v1 +} + +const MM_APPL = 8 +const MM_CONSOLE = 512 +const MM_ERROR = 2 +const MM_FIRM = 4 +const MM_HALT = 1 +const MM_HARD = 1 +const MM_INFO = 4 +const MM_NOCON = 4 +const MM_NOMSG = 1 +const MM_NOSEV = 0 +const MM_NOTOK = -1 +const MM_NRECOV = 128 +const MM_NULLMC = 0 +const MM_NULLSEV = 0 +const MM_OK = 0 +const MM_OPSYS = 32 +const MM_PRINT = 256 +const MM_RECOVER = 64 +const MM_SOFT = 2 +const MM_UTIL = 16 +const MM_WARNING = 3 + +// C documentation +// +// /* +// * If lstr is the first part of bstr, check that the next char in bstr +// * is either \0 or : +// */ +func __strcolcmp(tls *TLS, lstr uintptr, bstr uintptr) (r int32) { + var i Tsize_t + _ = i + i = uint64(0) + for **(**int8)(__ccgo_up(lstr + uintptr(i))) != 0 && **(**int8)(__ccgo_up(bstr + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(bstr + uintptr(i)))) == int32(**(**int8)(__ccgo_up(lstr + uintptr(i)))) { + i = i + 1 + } + if **(**int8)(__ccgo_up(lstr + uintptr(i))) != 0 || **(**int8)(__ccgo_up(bstr + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(bstr + uintptr(i)))) != int32(':') { + return int32(1) + } + return 0 +} + +func Xfmtmsg(tls *TLS, classification int64, label uintptr, severity int32, text uintptr, action uintptr, tag uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v classification=%v label=%v severity=%v text=%v action=%v tag=%v, (%v:)", tls, classification, label, severity, text, action, tag, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var cmsg, errstring, v1, v2, v3, v4, v5, v6, v7, v8 uintptr + var consolefd, i, ret, verb int32 + var msgs [6]uintptr + var _ /* cs at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cmsg, consolefd, errstring, i, msgs, ret, verb, v1, v2, v3, v4, v5, v6, v7, v8 + ret = 0 + verb = 0 + errstring = uintptr(MM_NULLSEV) + cmsg = Xgetenv(tls, __ccgo_ts+595) + msgs = [6]uintptr{ + 0: __ccgo_ts + 603, + 1: __ccgo_ts + 609, + 2: __ccgo_ts + 618, + 3: __ccgo_ts + 623, + 4: __ccgo_ts + 630, + 5: UintptrFromInt32(0), + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + if severity == int32(MM_HALT) { + errstring = __ccgo_ts + 634 + } else { + if severity == int32(MM_ERROR) { + errstring = __ccgo_ts + 641 + } else { + if severity == int32(MM_WARNING) { + errstring = __ccgo_ts + 649 + } else { + if severity == int32(MM_INFO) { + errstring = __ccgo_ts + 659 + } + } + } + } + if classification&int64(MM_CONSOLE) != 0 { + consolefd = Xopen(tls, __ccgo_ts+666, int32(O_WRONLY), 0) + if consolefd < 0 { + ret = int32(MM_NOCON) + } else { + if label != 0 { + v1 = label + } else { + v1 = __ccgo_ts + } + if label != 0 { + v2 = __ccgo_ts + 355 + } else { + v2 = __ccgo_ts + } + if severity != 0 { + v3 = errstring + } else { + v3 = __ccgo_ts + } + if text != 0 { + v4 = text + } else { + v4 = __ccgo_ts + } + if action != 0 { + v5 = __ccgo_ts + 679 + } else { + v5 = __ccgo_ts + } + if action != 0 { + v6 = action + } else { + v6 = __ccgo_ts + } + if action != 0 { + v7 = __ccgo_ts + 689 + } else { + v7 = __ccgo_ts + } + if tag != 0 { + v8 = tag + } else { + v8 = __ccgo_ts + } + if Xdprintf(tls, consolefd, __ccgo_ts+691, VaList(bp+16, v1, v2, v3, v4, v5, v6, v7, v8)) < int32(1) { + ret = int32(MM_NOCON) + } + Xclose(tls, consolefd) + } + } + if classification&int64(MM_PRINT) != 0 { + for cmsg != 0 && **(**int8)(__ccgo_up(cmsg)) != 0 { + i = 0 + for { + if !(msgs[i] != 0) { + break + } + if !(__strcolcmp(tls, msgs[i], cmsg) != 0) { + break + } + goto _9 + _9: + ; + i = i + 1 + } + if msgs[i] == UintptrFromInt32(0) { + //ignore MSGVERB-unrecognized component + verb = int32(0xFF) + break + } else { + verb = verb | int32(1)< %v", r) }() + } + bp := tls.Alloc(288) + defer tls.Free(288) + var res uintptr + var _ /* a at bp+0 */ Tstat + var _ /* b at bp+144 */ Tstat + _ = res + res = Xgetenv(tls, __ccgo_ts+709) + if res != 0 && **(**int8)(__ccgo_up(res)) != 0 && !(Xstat(tls, res, bp) != 0) && !(Xstat(tls, __ccgo_ts+575, bp+144) != 0) && (**(**Tstat)(__ccgo_up(bp))).Fst_dev == (**(**Tstat)(__ccgo_up(bp + 144))).Fst_dev && (**(**Tstat)(__ccgo_up(bp))).Fst_ino == (**(**Tstat)(__ccgo_up(bp + 144))).Fst_ino { + return Xstrdup(tls, res) + } + return Xgetcwd(tls, uintptr(0), uint64(0)) +} + +func X__getauxval(tls *TLS, item uint64) (r uint64) { + if __ccgo_strace { + trc("tls=%v item=%v, (%v:)", tls, item, origin(2)) + defer func() { trc("-> %v", r) }() + } + var auxv uintptr + _ = auxv + auxv = X__libc.Fauxv + if item == uint64(AT_SECURE) { + return Uint64FromInt8(X__libc.Fsecure) + } + for { + if !(**(**Tsize_t)(__ccgo_up(auxv)) != 0) { + break + } + if **(**Tsize_t)(__ccgo_up(auxv)) == item { + return **(**Tsize_t)(__ccgo_up(auxv + 1*8)) + } + goto _1 + _1: + ; + auxv = auxv + uintptr(2)*8 + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uint64(0) +} + +func Xgetauxval(tls *TLS, item uint64) (r uint64) { + if __ccgo_strace { + trc("tls=%v item=%v, (%v:)", tls, item, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__getauxval(tls, item) +} + +type Tutsname = struct { + Fsysname [65]int8 + Fnodename [65]int8 + Frelease [65]int8 + Fversion [65]int8 + Fmachine [65]int8 + Fdomainname [65]int8 +} + +func Xgetdomainname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v len1=%v, (%v:)", tls, name, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(400) + defer tls.Free(400) + var _ /* temp at bp+0 */ Tutsname + Xuname(tls, bp) + if !(len1 != 0) || _strlen(tls, bp+325) >= len1 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + Xstrcpy(tls, name, bp+325) + return 0 +} + +func Xgetentropy(tls *TLS, buffer uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v buffer=%v len1=%v, (%v:)", tls, buffer, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var pos uintptr + var ret int32 + var _ /* cs at bp+0 */ int32 + _, _ = pos, ret + ret = 0 + pos = buffer + if len1 > uint64(256) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EIO) + return -int32(1) + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + for len1 != 0 { + ret = int32(Xgetrandom(tls, pos, len1, uint32(0))) + if ret < 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EINTR) { + continue + } else { + break + } + } + pos = pos + uintptr(ret) + len1 = len1 - Uint64FromInt32(ret) + ret = 0 + } + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) + return ret +} + +func Xgethostid(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +const optpos = 0 + +type t__ucontext1 = Tucontext_t1 + +func X__getopt_msg(tls *TLS, a uintptr, b uintptr, c uintptr, l Tsize_t) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v c=%v l=%v, (%v:)", tls, a, b, c, l, origin(2)) + } + var __need_unlock, v1 int32 + var f uintptr + _, _, _ = __need_unlock, f, v1 + f = uintptr(unsafe.Pointer(&X__stderr_FILE)) + b = X__lctrans_cur(tls, b) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + _ = Xfputs(tls, a, f) >= 0 && Xfwrite(tls, b, _strlen(tls, b), uint64(1), f) != 0 && Xfwrite(tls, c, uint64(1), l, f) == l && Xputc(tls, int32('\n'), f) != 0 + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xgetopt(tls *TLS, argc int32, argv uintptr, optstring uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v argc=%v argv=%v optstring=%v, (%v:)", tls, argc, argv, optstring, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, k, l, v1 int32 + var optchar uintptr + var _ /* c at bp+0 */ Twchar_t + var _ /* d at bp+4 */ Twchar_t + _, _, _, _, _ = i, k, l, optchar, v1 + if !(Xoptind != 0) || Xoptreset != 0 { + Xoptreset = 0 + X__optpos = 0 + Xoptind = int32(1) + } + if Xoptind >= argc || !(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) != 0) { + return -int32(1) + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))))) != int32('-') { + if int32(**(**int8)(__ccgo_up(optstring))) == int32('-') { + v1 = Xoptind + Xoptind = Xoptind + 1 + Xoptarg = **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8)) + return int32(1) + } + return -int32(1) + } + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1)) != 0) { + return -int32(1) + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1))) == int32('-') && !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 2)) != 0) { + Xoptind = Xoptind + 1 + return -Int32FromInt32(1) + } + if !(X__optpos != 0) { + X__optpos = X__optpos + 1 + } + v1 = Xmbtowc(tls, bp, **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))+uintptr(X__optpos), uint64(MB_LEN_MAX)) + k = v1 + if v1 < 0 { + k = int32(1) + **(**Twchar_t)(__ccgo_up(bp)) = int32(0xfffd) /* replacement char */ + } + optchar = **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + uintptr(X__optpos) + X__optpos = X__optpos + k + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + uintptr(X__optpos))) != 0) { + Xoptind = Xoptind + 1 + X__optpos = 0 + } + if int32(**(**int8)(__ccgo_up(optstring))) == int32('-') || int32(**(**int8)(__ccgo_up(optstring))) == int32('+') { + optstring = optstring + 1 + } + i = 0 + **(**Twchar_t)(__ccgo_up(bp + 4)) = 0 + for cond := true; cond; cond = l != 0 && **(**Twchar_t)(__ccgo_up(bp + 4)) != **(**Twchar_t)(__ccgo_up(bp)) { + l = Xmbtowc(tls, bp+4, optstring+uintptr(i), uint64(MB_LEN_MAX)) + if l > 0 { + i = i + l + } else { + i = i + 1 + } + } + if **(**Twchar_t)(__ccgo_up(bp + 4)) != **(**Twchar_t)(__ccgo_up(bp)) || **(**Twchar_t)(__ccgo_up(bp)) == int32(':') { + Xoptopt = **(**Twchar_t)(__ccgo_up(bp)) + if int32(**(**int8)(__ccgo_up(optstring))) != int32(':') && Xopterr != 0 { + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), __ccgo_ts+713, optchar, Uint64FromInt32(k)) + } + return int32('?') + } + if int32(**(**int8)(__ccgo_up(optstring + uintptr(i)))) == int32(':') { + Xoptarg = uintptr(0) + if int32(**(**int8)(__ccgo_up(optstring + uintptr(i+int32(1))))) != int32(':') || X__optpos != 0 { + v1 = Xoptind + Xoptind = Xoptind + 1 + Xoptarg = **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8)) + if X__optpos != 0 { + Xoptarg = Xoptarg + uintptr(X__optpos) + } + X__optpos = 0 + } + if Xoptind > argc { + Xoptopt = **(**Twchar_t)(__ccgo_up(bp)) + if int32(**(**int8)(__ccgo_up(optstring))) == int32(':') { + return int32(':') + } + if Xopterr != 0 { + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), __ccgo_ts+737, optchar, Uint64FromInt32(k)) + } + return int32('?') + } + } + return **(**Twchar_t)(__ccgo_up(bp)) +} + +func X__posix_getopt(tls *TLS, argc int32, argv uintptr, optstring uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v argc=%v argv=%v optstring=%v, (%v:)", tls, argc, argv, optstring, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetopt(tls, argc, argv, optstring) +} + +const no_argument = 0 +const optional_argument = 2 +const required_argument = 1 + +type Toption = struct { + Fname uintptr + Fhas_arg int32 + Fflag uintptr + Fval int32 +} + +func _permute(tls *TLS, argv uintptr, dest int32, src int32) { + var av, tmp uintptr + var i int32 + _, _, _ = av, i, tmp + av = argv + tmp = **(**uintptr)(__ccgo_up(av + uintptr(src)*8)) + i = src + for { + if !(i > dest) { + break + } + **(**uintptr)(__ccgo_up(av + uintptr(i)*8)) = **(**uintptr)(__ccgo_up(av + uintptr(i-int32(1))*8)) + goto _1 + _1: + ; + i = i - 1 + } + **(**uintptr)(__ccgo_up(av + uintptr(dest)*8)) = tmp +} + +func ___getopt_long(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr, longonly int32) (r int32) { + var cnt, i, i1, resumed, ret, skipped int32 + _, _, _, _, _, _ = cnt, i, i1, resumed, ret, skipped + if !(Xoptind != 0) || Xoptreset != 0 { + Xoptreset = 0 + X__optpos = 0 + Xoptind = int32(1) + } + if Xoptind >= argc || !(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) != 0) { + return -int32(1) + } + skipped = Xoptind + if int32(**(**int8)(__ccgo_up(optstring))) != int32('+') && int32(**(**int8)(__ccgo_up(optstring))) != int32('-') { + i = Xoptind + for { + if i >= argc || !(**(**uintptr)(__ccgo_up(argv + uintptr(i)*8)) != 0) { + return -int32(1) + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(i)*8))))) == int32('-') && **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(i)*8)) + 1)) != 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + Xoptind = i + } + resumed = Xoptind + ret = ___getopt_long_core(tls, argc, argv, optstring, longopts, idx, longonly) + if resumed > skipped { + cnt = Xoptind - resumed + i1 = 0 + for { + if !(i1 < cnt) { + break + } + _permute(tls, argv, skipped, Xoptind-int32(1)) + goto _2 + _2: + ; + i1 = i1 + 1 + } + Xoptind = skipped + cnt + } + return ret +} + +func ___getopt_long_core(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr, longonly int32) (r int32) { + var arg, name, opt, start, v5 uintptr + var cnt, colon, i, j, l, match, v2 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = arg, cnt, colon, i, j, l, match, name, opt, start, v2, v5 + Xoptarg = uintptr(0) + if longopts != 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))))) == int32('-') && (longonly != 0 && **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1)) != 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1))) != int32('-') || int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1))) == int32('-') && **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 2)) != 0) { + colon = BoolInt32(int32(**(**int8)(__ccgo_up(optstring + BoolUintptr(int32(**(**int8)(__ccgo_up(optstring))) == int32('+') || int32(**(**int8)(__ccgo_up(optstring))) == int32('-'))))) == int32(':')) + start = **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + uintptr(1) + v2 = Int32FromInt32(0) + i = v2 + cnt = v2 + for { + if !((**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname != 0) { + break + } + name = (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname + opt = start + if int32(**(**int8)(__ccgo_up(opt))) == int32('-') { + opt = opt + 1 + } + for **(**int8)(__ccgo_up(opt)) != 0 && int32(**(**int8)(__ccgo_up(opt))) != int32('=') && int32(**(**int8)(__ccgo_up(opt))) == int32(**(**int8)(__ccgo_up(name))) { + name = name + 1 + opt = opt + 1 + } + if **(**int8)(__ccgo_up(opt)) != 0 && int32(**(**int8)(__ccgo_up(opt))) != int32('=') { + goto _1 + } + arg = opt + match = i + if !(**(**int8)(__ccgo_up(name)) != 0) { + cnt = int32(1) + break + } + cnt = cnt + 1 + goto _1 + _1: + ; + i = i + 1 + } + if cnt == int32(1) && longonly != 0 && int64(arg)-int64(start) == int64(Xmblen(tls, start, uint64(MB_LEN_MAX))) { + l = int32(int64(arg) - int64(start)) + i = 0 + for { + if !(**(**int8)(__ccgo_up(optstring + uintptr(i))) != 0) { + break + } + j = 0 + for { + if !(j < l && int32(**(**int8)(__ccgo_up(start + uintptr(j)))) == int32(**(**int8)(__ccgo_up(optstring + uintptr(i+j))))) { + break + } + goto _4 + _4: + ; + j = j + 1 + } + if j == l { + cnt = cnt + 1 + break + } + goto _3 + _3: + ; + i = i + 1 + } + } + if cnt == int32(1) { + i = match + opt = arg + Xoptind = Xoptind + 1 + if int32(**(**int8)(__ccgo_up(opt))) == int32('=') { + if !((**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fhas_arg != 0) { + Xoptopt = (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fval + if colon != 0 || !(Xopterr != 0) { + return int32('?') + } + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), __ccgo_ts+769, (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname, _strlen(tls, (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname)) + return int32('?') + } + Xoptarg = opt + uintptr(1) + } else { + if (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fhas_arg == int32(required_argument) { + v5 = **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + Xoptarg = v5 + if !(v5 != 0) { + Xoptopt = (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fval + if colon != 0 { + return int32(':') + } + if !(Xopterr != 0) { + return int32('?') + } + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), __ccgo_ts+737, (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname, _strlen(tls, (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname)) + return int32('?') + } + Xoptind = Xoptind + 1 + } + } + if idx != 0 { + **(**int32)(__ccgo_up(idx)) = i + } + if (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fflag != 0 { + **(**int32)(__ccgo_up((**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fflag)) = (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fval + return 0 + } + return (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fval + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1))) == int32('-') { + Xoptopt = 0 + if !(colon != 0) && Xopterr != 0 { + if cnt != 0 { + v5 = __ccgo_ts + 806 + } else { + v5 = __ccgo_ts + 713 + } + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), v5, **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))+uintptr(2), _strlen(tls, **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))+uintptr(2))) + } + Xoptind = Xoptind + 1 + return int32('?') + } + } + return Xgetopt(tls, argc, argv, optstring) +} + +func Xgetopt_long(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v argc=%v argv=%v optstring=%v longopts=%v idx=%v, (%v:)", tls, argc, argv, optstring, longopts, idx, origin(2)) + defer func() { trc("-> %v", r) }() + } + return ___getopt_long(tls, argc, argv, optstring, longopts, idx, 0) +} + +func Xgetopt_long_only(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v argc=%v argv=%v optstring=%v longopts=%v idx=%v, (%v:)", tls, argc, argv, optstring, longopts, idx, origin(2)) + defer func() { trc("-> %v", r) }() + } + return ___getopt_long(tls, argc, argv, optstring, longopts, idx, int32(1)) +} + +func Xgetpriority(tls *TLS, which int32, who Tid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v which=%v who=%v, (%v:)", tls, which, who, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + ret = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getpriority), int64(which), Int64FromUint32(who))))) + if ret < 0 { + return ret + } + return int32(20) - ret +} + +func Xgetresgid(tls *TLS, rgid uintptr, egid uintptr, sgid uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v rgid=%v egid=%v sgid=%v, (%v:)", tls, rgid, egid, sgid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_getresgid), int64(rgid), int64(egid), int64(sgid))))) +} + +func Xgetresuid(tls *TLS, ruid uintptr, euid uintptr, suid uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ruid=%v euid=%v suid=%v, (%v:)", tls, ruid, euid, suid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_getresuid), int64(ruid), int64(euid), int64(suid))))) +} + +func Xgetrlimit(tls *TLS, resource int32, rlim uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v resource=%v rlim=%v, (%v:)", tls, resource, rlim, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ret int32 + var v1 uint64 + var _ /* k_rlim at bp+0 */ [2]uint64 + _, _ = ret, v1 + ret = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_prlimit64), int64(Int32FromInt32(0)), int64(resource), int64(Int32FromInt32(0)), int64(rlim))))) + if !(ret != 0) { + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur = ^Uint64FromUint64(0) + } + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max = ^Uint64FromUint64(0) + } + } + if !(ret != 0) || **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(ENOSYS) { + return ret + } + if X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getrlimit), int64(resource), int64(bp)))) < 0 { + return -int32(1) + } + if (**(**[2]uint64)(__ccgo_up(bp)))[0] == -Uint64FromUint64(1) { + v1 = ^Uint64FromUint64(0) + } else { + v1 = (**(**[2]uint64)(__ccgo_up(bp)))[0] + } + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur = v1 + if (**(**[2]uint64)(__ccgo_up(bp)))[int32(1)] == -Uint64FromUint64(1) { + v1 = ^Uint64FromUint64(0) + } else { + v1 = (**(**[2]uint64)(__ccgo_up(bp)))[int32(1)] + } + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max = v1 + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur = ^Uint64FromUint64(0) + } + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max = ^Uint64FromUint64(0) + } + return 0 +} + +func Xgetrusage(tls *TLS, who int32, ru uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v who=%v ru=%v, (%v:)", tls, who, ru, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var dest uintptr + var r int32 + var _ /* kru at bp+0 */ [4]int64 + _, _ = dest, r + dest = ru + 32 - uintptr(Uint64FromInt32(4)*Uint64FromInt64(8)) + r = int32(X__syscall2(tls, int64(SYS_getrusage), int64(who), int64(dest))) + if !(r != 0) && Bool(uint64(8) > uint64(8)) { + Xmemcpy(tls, bp, dest, Uint64FromInt32(4)*Uint64FromInt64(8)) + (*Trusage)(unsafe.Pointer(ru)).Fru_utime = Ttimeval{ + Ftv_sec: (**(**[4]int64)(__ccgo_up(bp)))[0], + Ftv_usec: (**(**[4]int64)(__ccgo_up(bp)))[int32(1)], + } + (*Trusage)(unsafe.Pointer(ru)).Fru_stime = Ttimeval{ + Ftv_sec: (**(**[4]int64)(__ccgo_up(bp)))[int32(2)], + Ftv_usec: (**(**[4]int64)(__ccgo_up(bp)))[int32(3)], + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xgetsubopt(tls *TLS, opt uintptr, keys uintptr, val uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v opt=%v keys=%v val=%v, (%v:)", tls, opt, keys, val, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i int32 + var l Tsize_t + var s, v1, v2 uintptr + _, _, _, _, _ = i, l, s, v1, v2 + s = **(**uintptr)(__ccgo_up(opt)) + **(**uintptr)(__ccgo_up(val)) = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(opt)) = Xstrchr(tls, s, int32(',')) + if **(**uintptr)(__ccgo_up(opt)) != 0 { + v2 = opt + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1 + **(**int8)(__ccgo_up(v1)) = 0 + } else { + **(**uintptr)(__ccgo_up(opt)) = s + uintptr(_strlen(tls, s)) + } + i = 0 + for { + if !(**(**uintptr)(__ccgo_up(keys + uintptr(i)*8)) != 0) { + break + } + l = _strlen(tls, **(**uintptr)(__ccgo_up(keys + uintptr(i)*8))) + if Xstrncmp(tls, **(**uintptr)(__ccgo_up(keys + uintptr(i)*8)), s, l) != 0 { + goto _3 + } + if int32(**(**int8)(__ccgo_up(s + uintptr(l)))) == int32('=') { + **(**uintptr)(__ccgo_up(val)) = s + uintptr(l) + uintptr(1) + } else { + if **(**int8)(__ccgo_up(s + uintptr(l))) != 0 { + goto _3 + } + } + return i + goto _3 + _3: + ; + i = i + 1 + } + return -int32(1) +} + +const R = 2 +const W = 1 +const WR = 3 + +type Tioctl_compat_map = struct { + Fnew_req int32 + Fold_req int32 + Fold_size uint8 + Fdir uint8 + Fforce_align uint8 + Fnoffs uint8 + Foffsets [8]uint8 +} + +/* yields a type for a struct with original size n, with a misaligned + * timeval/timespec expanded from 32- to 64-bit. for use with ioctl + * number producing macros; only size of result is meaningful. */ + +type Tv4l2_event = struct { + Fa Tuint32_t + Fb [8]Tuint64_t + Fc [2]Tuint32_t + Fts [2]Tuint32_t + Fd [9]Tuint32_t +} + +var _compat_map = [20]Tioctl_compat_map{ + 0: { + Fnew_req: int32(SIOCGSTAMP), + Fold_req: int32(SIOCGSTAMP_OLD), + Fold_size: uint8(8), + Fdir: uint8(R), + Fnoffs: uint8(2), + Foffsets: [8]uint8{ + 1: uint8(4), + }, + }, + 1: { + Fnew_req: int32(SIOCGSTAMPNS), + Fold_req: int32(SIOCGSTAMPNS_OLD), + Fold_size: uint8(8), + Fdir: uint8(R), + Fnoffs: uint8(2), + Foffsets: [8]uint8{ + 1: uint8(4), + }, + }, + 2: { + Fnew_req: Int32FromUint64(uint64(Uint32FromUint32(2)< %v", r1) }() + } + bp := tls.Alloc(256) + defer tls.Free(256) + var ap Tva_list + var arg uintptr + var i, r int32 + var _ /* u at bp+0 */ struct { + Fbuf [0][256]int8 + Falign int64 + F__ccgo_pad2 [248]byte + } + _, _, _, _ = ap, arg, i, r + ap = va + arg = VaUintptr(&ap) + _ = ap + r = int32(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(req), int64(arg))) + if Bool(Bool(int32(SIOCGSTAMP) != int32(SIOCGSTAMP_OLD)) && req != 0) && r == -int32(ENOTTY) { + i = 0 + for { + if !(Uint64FromInt32(i) < Uint64FromInt64(400)/Uint64FromInt64(20)) { + break + } + if _compat_map[i].Fnew_req != req { + goto _1 + } + _convert_ioctl_struct(tls, uintptr(unsafe.Pointer(&_compat_map))+uintptr(i)*20, bp, arg, int32(W)) + r = int32(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(_compat_map[i].Fold_req), int64(bp))) + if r < 0 { + break + } + _convert_ioctl_struct(tls, uintptr(unsafe.Pointer(&_compat_map))+uintptr(i)*20, bp, arg, int32(R)) + break + goto _1 + _1: + ; + i = i + 1 + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xissetugid(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__libc.Fsecure) +} + +func Xlockf(tls *TLS, fd int32, op int32, size Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v op=%v size=%v, (%v:)", tls, fd, op, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* l at bp+0 */ Tflock + **(**Tflock)(__ccgo_up(bp)) = Tflock{ + Fl_type: int16(F_WRLCK), + Fl_whence: int16(1), + Fl_len: size, + } + switch op { + case int32(F_TEST): + (**(**Tflock)(__ccgo_up(bp))).Fl_type = F_RDLCK + if Xfcntl(tls, fd, int32(F_GETLK), VaList(bp+40, bp)) < 0 { + return -int32(1) + } + if int32((**(**Tflock)(__ccgo_up(bp))).Fl_type) == int32(F_UNLCK) || (**(**Tflock)(__ccgo_up(bp))).Fl_pid == Xgetpid(tls) { + return 0 + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EACCES) + return -int32(1) + case F_ULOCK: + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_UNLCK) + fallthrough + case int32(F_TLOCK): + return Xfcntl(tls, fd, int32(F_SETLK), VaList(bp+40, bp)) + case int32(F_LOCK): + return Xfcntl(tls, fd, int32(F_SETLKW), VaList(bp+40, bp)) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) +} + +const ACCOUNTING = 9 +const UTMP_FILE = "_PATH_UTMP" +const UTMP_FILENAME = "_PATH_UTMP" +const UT_HOSTSIZE = 256 +const UT_LINESIZE = 32 +const UT_NAMESIZE = 32 +const WTMP_FILE = "_PATH_WTMP" +const WTMP_FILENAME = "_PATH_WTMP" +const _PATH_UTMP = "/dev/null/utmp" +const _PATH_WTMP = "/dev/null/wtmp" +const ut_name = 0 +const utmp = 0 + +type Tlastlog = struct { + Fll_time Ttime_t + Fll_line [32]int8 + Fll_host [256]int8 +} + +func Xlogin_tty(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + Xsetsid(tls) + if Xioctl(tls, fd, int32(TIOCSCTTY), VaList(bp+8, UintptrFromInt32(0))) != 0 { + return -int32(1) + } + Xdup2(tls, fd, 0) + Xdup2(tls, fd, int32(1)) + Xdup2(tls, fd, int32(2)) + if fd > int32(2) { + Xclose(tls, fd) + } + return 0 +} + +const MNTOPT_DEFAULTS = "defaults" +const MNTOPT_NOAUTO = "noauto" +const MNTOPT_NOSUID = "nosuid" +const MNTOPT_RO = "ro" +const MNTOPT_RW = "rw" +const MNTOPT_SUID = "suid" +const MNTTYPE_IGNORE = "ignore" +const MNTTYPE_NFS = "nfs" +const MNTTYPE_SWAP = "swap" +const MOUNTED = "/etc/mtab" +const SENTINEL = 0 + +type Tmntent = struct { + Fmnt_fsname uintptr + Fmnt_dir uintptr + Fmnt_type uintptr + Fmnt_opts uintptr + Fmnt_freq int32 + Fmnt_passno int32 +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +var _internal_buf uintptr +var _internal_bufsize Tsize_t + +func Xsetmntent(tls *TLS, name uintptr, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v mode=%v, (%v:)", tls, name, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfopen(tls, name, mode) +} + +func Xendmntent(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + if f != 0 { + Xfclose(tls, f) + } + return int32(1) +} + +func _unescape_ent(tls *TLS, beg uintptr) (r uintptr) { + var cval uint8 + var dest, src, val, v1, v2 uintptr + var i int32 + _, _, _, _, _, _, _ = cval, dest, i, src, val, v1, v2 + dest = beg + src = beg + for **(**int8)(__ccgo_up(src)) != 0 { + cval = uint8(0) + if int32(**(**int8)(__ccgo_up(src))) != int32('\\') { + v1 = dest + dest = dest + 1 + v2 = src + src = src + 1 + **(**int8)(__ccgo_up(v1)) = **(**int8)(__ccgo_up(v2)) + continue + } + if int32(**(**int8)(__ccgo_up(src + 1))) == int32('\\') { + src = src + 1 + v1 = dest + dest = dest + 1 + v2 = src + src = src + 1 + **(**int8)(__ccgo_up(v1)) = **(**int8)(__ccgo_up(v2)) + continue + } + val = src + uintptr(1) + i = 0 + for { + if !(i < int32(3)) { + break + } + if int32(**(**int8)(__ccgo_up(val))) >= int32('0') && int32(**(**int8)(__ccgo_up(val))) <= int32('7') { + cval = Uint8FromInt32(int32(cval) << Int32FromInt32(3)) + v1 = val + val = val + 1 + cval = Uint8FromInt32(int32(cval) + (int32(**(**int8)(__ccgo_up(v1))) - Int32FromUint8('0'))) + } else { + break + } + goto _5 + _5: + ; + i = i + 1 + } + if cval != 0 { + v1 = dest + dest = dest + 1 + **(**int8)(__ccgo_up(v1)) = Int8FromUint8(cval) + src = val + } else { + v1 = dest + dest = dest + 1 + v2 = src + src = src + 1 + **(**int8)(__ccgo_up(v1)) = **(**int8)(__ccgo_up(v2)) + } + } + **(**int8)(__ccgo_up(dest)) = 0 + return beg +} + +func Xgetmntent_r(tls *TLS, f uintptr, mnt uintptr, linebuf uintptr, buflen int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v mnt=%v linebuf=%v buflen=%v, (%v:)", tls, f, mnt, linebuf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var i, len1 Tsize_t + var use_internal int32 + var _ /* n at bp+0 */ [8]int32 + _, _, _ = i, len1, use_internal + use_internal = BoolInt32(linebuf == uintptr(unsafe.Pointer(&_internal_buf))) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_freq = 0 + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_passno = 0 + for cond := true; cond; cond = int32(**(**int8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[0])))) == int32('#') || Uint64FromInt32((**(**[8]int32)(__ccgo_up(bp)))[int32(1)]) == len1 { + if use_internal != 0 { + Xgetline(tls, uintptr(unsafe.Pointer(&_internal_buf)), uintptr(unsafe.Pointer(&_internal_bufsize)), f) + linebuf = _internal_buf + } else { + Xfgets(tls, linebuf, buflen, f) + } + if Xfeof(tls, f) != 0 || Xferror(tls, f) != 0 { + return uintptr(0) + } + if !(Xstrchr(tls, linebuf, int32('\n')) != 0) { + Xfscanf(tls, f, __ccgo_ts+830, 0) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return uintptr(0) + } + len1 = _strlen(tls, linebuf) + if len1 > uint64(INT_MAX) { + continue + } + i = uint64(0) + for { + if !(i < Uint64FromInt64(32)/Uint64FromInt64(4)) { + break + } + (**(**[8]int32)(__ccgo_up(bp)))[i] = Int32FromUint64(len1) + goto _1 + _1: + ; + i = i + 1 + } + Xsscanf(tls, linebuf, __ccgo_ts+842, VaList(bp+40, bp, bp+uintptr(1)*4, bp+uintptr(2)*4, bp+uintptr(3)*4, bp+uintptr(4)*4, bp+uintptr(5)*4, bp+uintptr(6)*4, bp+uintptr(7)*4, mnt+32, mnt+36)) + } + **(**int8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(1)]))) = 0 + **(**int8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(3)]))) = 0 + **(**int8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(5)]))) = 0 + **(**int8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(7)]))) = 0 + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_fsname = _unescape_ent(tls, linebuf+uintptr((**(**[8]int32)(__ccgo_up(bp)))[0])) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_dir = _unescape_ent(tls, linebuf+uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(2)])) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_type = _unescape_ent(tls, linebuf+uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(4)])) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_opts = _unescape_ent(tls, linebuf+uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(6)])) + return mnt +} + +func Xgetmntent(tls *TLS, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetmntent_r(tls, f, uintptr(unsafe.Pointer(&_mnt)), uintptr(unsafe.Pointer(&_internal_buf)), 0) +} + +var _mnt Tmntent + +func Xaddmntent(tls *TLS, f uintptr, mnt uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v mnt=%v, (%v:)", tls, f, mnt, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + if Xfseek(tls, f, 0, int32(2)) != 0 { + return int32(1) + } + return BoolInt32(Xfprintf(tls, f, __ccgo_ts+897, VaList(bp+8, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_fsname, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_dir, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_type, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_opts, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_freq, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_passno)) < 0) +} + +func Xhasmntopt(tls *TLS, mnt uintptr, opt uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v mnt=%v opt=%v, (%v:)", tls, mnt, opt, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrstr(tls, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_opts, opt) +} + +type Thistory = struct { + Fchain uintptr + Fdev Tdev_t + Fino Tino_t + Flevel int32 + Fbase int32 +} + +func _do_nftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32, flags int32, h uintptr) (r1 int32) { + bp := tls.Alloc(192) + defer tls.Free(192) + var d, de, v10 uintptr + var dfd, err, r, type1, v3 int32 + var j, k, l Tsize_t + var v1 uint64 + var v8 bool + var v2 Tino_t + var _ /* lev at bp+176 */ TFTW + var _ /* new at bp+144 */ Thistory + var _ /* st at bp+0 */ Tstat + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = d, de, dfd, err, j, k, l, r, type1, v1, v10, v2, v3, v8 + l = _strlen(tls, path) + if l != 0 && int32(**(**int8)(__ccgo_up(path + uintptr(l-uint64(1))))) == int32('/') { + v1 = l - uint64(1) + } else { + v1 = l + } + j = v1 + v2 = Uint64FromInt32(0) + (**(**Tstat)(__ccgo_up(bp))).Fst_ino = v2 + (**(**Tstat)(__ccgo_up(bp))).Fst_dev = v2 + if flags&int32(FTW_PHYS) != 0 { + v3 = Xlstat(tls, path, bp) + } else { + v3 = BoolInt32(Xstat(tls, path, bp) < 0) + } + if v3 != 0 { + if !(flags&Int32FromInt32(FTW_PHYS) != 0) && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOENT) && !(Xlstat(tls, path, bp) != 0) { + type1 = int32(FTW_SLN) + } else { + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(EACCES) { + return -int32(1) + } else { + type1 = int32(FTW_NS) + } + } + } else { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFDIR) { + if flags&int32(FTW_DEPTH) != 0 { + type1 = int32(FTW_DP) + } else { + type1 = int32(FTW_D) + } + } else { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFLNK) { + if flags&int32(FTW_PHYS) != 0 { + type1 = int32(FTW_SL) + } else { + type1 = int32(FTW_SLN) + } + } else { + type1 = int32(FTW_F) + } + } + } + if flags&int32(FTW_MOUNT) != 0 && h != 0 && type1 != int32(FTW_NS) && (**(**Tstat)(__ccgo_up(bp))).Fst_dev != (*Thistory)(unsafe.Pointer(h)).Fdev { + return 0 + } + (**(**Thistory)(__ccgo_up(bp + 144))).Fchain = h + (**(**Thistory)(__ccgo_up(bp + 144))).Fdev = (**(**Tstat)(__ccgo_up(bp))).Fst_dev + (**(**Thistory)(__ccgo_up(bp + 144))).Fino = (**(**Tstat)(__ccgo_up(bp))).Fst_ino + if h != 0 { + v3 = (*Thistory)(unsafe.Pointer(h)).Flevel + int32(1) + } else { + v3 = 0 + } + (**(**Thistory)(__ccgo_up(bp + 144))).Flevel = v3 + (**(**Thistory)(__ccgo_up(bp + 144))).Fbase = Int32FromUint64(j + uint64(1)) + (**(**TFTW)(__ccgo_up(bp + 176))).Flevel = (**(**Thistory)(__ccgo_up(bp + 144))).Flevel + if h != 0 { + (**(**TFTW)(__ccgo_up(bp + 176))).Fbase = (*Thistory)(unsafe.Pointer(h)).Fbase + } else { + k = j + for { + if !(k != 0 && int32(**(**int8)(__ccgo_up(path + uintptr(k)))) == int32('/')) { + break + } + goto _5 + _5: + ; + k = k - 1 + } + for { + if !(k != 0 && int32(**(**int8)(__ccgo_up(path + uintptr(k-uint64(1))))) != int32('/')) { + break + } + goto _6 + _6: + ; + k = k - 1 + } + (**(**TFTW)(__ccgo_up(bp + 176))).Fbase = Int32FromUint64(k) + } + if type1 == int32(FTW_D) || type1 == int32(FTW_DP) { + dfd = Xopen(tls, path, O_RDONLY, 0) + err = **(**int32)(__ccgo_up(X__errno_location(tls))) + if dfd < 0 && err == int32(EACCES) { + type1 = int32(FTW_DNR) + } + if !(fd_limit != 0) { + Xclose(tls, dfd) + } + } + if v8 = !(flags&Int32FromInt32(FTW_DEPTH) != 0); v8 { + v3 = (*(*func(*TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_fn})))(tls, path, bp, type1, bp+176) + r = v3 + } + if v8 && v3 != 0 { + return r + } + for { + if !(h != 0) { + break + } + if (*Thistory)(unsafe.Pointer(h)).Fdev == (**(**Tstat)(__ccgo_up(bp))).Fst_dev && (*Thistory)(unsafe.Pointer(h)).Fino == (**(**Tstat)(__ccgo_up(bp))).Fst_ino { + return 0 + } + goto _9 + _9: + ; + h = (*Thistory)(unsafe.Pointer(h)).Fchain + } + if (type1 == int32(FTW_D) || type1 == int32(FTW_DP)) && fd_limit != 0 { + if dfd < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = err + return -int32(1) + } + d = Xfdopendir(tls, dfd) + if d != 0 { + for { + v10 = Xreaddir(tls, d) + de = v10 + if !(v10 != 0) { + break + } + if int32(**(**int8)(__ccgo_up(de + 19))) == int32('.') && (!(**(**int8)(__ccgo_up(de + 19 + 1)) != 0) || int32(**(**int8)(__ccgo_up(de + 19 + 1))) == int32('.') && !(**(**int8)(__ccgo_up(de + 19 + 2)) != 0)) { + continue + } + if _strlen(tls, de+19) >= uint64(PATH_MAX)-l { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + Xclosedir(tls, d) + return -int32(1) + } + **(**int8)(__ccgo_up(path + uintptr(j))) = int8('/') + Xstrcpy(tls, path+uintptr(j)+uintptr(1), de+19) + v3 = _do_nftw(tls, path, __ccgo_fp_fn, fd_limit-int32(1), flags, bp+144) + r = v3 + if v3 != 0 { + Xclosedir(tls, d) + return r + } + } + Xclosedir(tls, d) + } else { + Xclose(tls, dfd) + return -int32(1) + } + } + **(**int8)(__ccgo_up(path + uintptr(l))) = 0 + if v8 = flags&int32(FTW_DEPTH) != 0; v8 { + v3 = (*(*func(*TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_fn})))(tls, path, bp, type1, bp+176) + r = v3 + } + if v8 && v3 != 0 { + return r + } + return 0 +} + +type t__ccgo_fp__Xnftw_1 = func(*TLS, uintptr, uintptr, int32, uintptr) int32 + +func Xnftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v path=%v __ccgo_fp_fn=%v fd_limit=%v flags=%v, (%v:)", tls, path, __ccgo_fp_fn, fd_limit, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(4112) + defer tls.Free(4112) + var l Tsize_t + var r int32 + var _ /* cs at bp+0 */ int32 + var _ /* pathbuf at bp+4 */ [4097]int8 + _, _ = l, r + if fd_limit <= 0 { + return 0 + } + l = _strlen(tls, path) + if l > uint64(PATH_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return -int32(1) + } + Xmemcpy(tls, bp+4, path, l+uint64(1)) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + r = _do_nftw(tls, bp+4, __ccgo_fp_fn, fd_limit, flags, UintptrFromInt32(0)) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) + return r +} + +/* Nonstandard, but vastly superior to the standard functions */ + +func Xopenpty(tls *TLS, pm uintptr, ps uintptr, name uintptr, tio uintptr, ws uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v pm=%v ps=%v name=%v tio=%v ws=%v, (%v:)", tls, pm, ps, name, tio, ws, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var m, s, v1 int32 + var _ /* buf at bp+8 */ [20]int8 + var _ /* cs at bp+4 */ int32 + var _ /* n at bp+0 */ int32 + _, _, _ = m, s, v1 + **(**int32)(__ccgo_up(bp)) = 0 + m = Xopen(tls, __ccgo_ts+916, Int32FromInt32(O_RDWR)|Int32FromInt32(O_NOCTTY), 0) + if m < 0 { + return -int32(1) + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+4) + if Xioctl(tls, m, int32(TIOCSPTLCK), VaList(bp+40, bp)) != 0 || Xioctl(tls, m, Int32FromUint32(TIOCGPTN), VaList(bp+40, bp)) != 0 { + goto fail + } + if !(name != 0) { + name = bp + 8 + } + Xsnprintf(tls, name, uint64(20), __ccgo_ts+926, VaList(bp+40, **(**int32)(__ccgo_up(bp)))) + v1 = Xopen(tls, name, Int32FromInt32(O_RDWR)|Int32FromInt32(O_NOCTTY), 0) + s = v1 + if v1 < 0 { + goto fail + } + if tio != 0 { + Xtcsetattr(tls, s, TCSANOW, tio) + } + if ws != 0 { + Xioctl(tls, s, int32(TIOCSWINSZ), VaList(bp+40, ws)) + } + **(**int32)(__ccgo_up(pm)) = m + **(**int32)(__ccgo_up(ps)) = s + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 4)), uintptr(0)) + return 0 + goto fail +fail: + ; + Xclose(tls, m) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 4)), uintptr(0)) + return -int32(1) +} + +func Xptsname(tls *TLS, fd int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var err int32 + _ = err + err = X__ptsname_r(tls, fd, uintptr(unsafe.Pointer(&_buf2)), uint64(22)) + if err != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = err + return uintptr(0) + } + return uintptr(unsafe.Pointer(&_buf2)) +} + +var _buf2 [22]int8 + +func Xposix_openpt(tls *TLS, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = Xopen(tls, __ccgo_ts+916, flags, 0) + if r < 0 && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOSPC) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EAGAIN) + } + return r +} + +func Xgrantpt(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xunlockpt(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* unlock at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = 0 + return Xioctl(tls, fd, int32(TIOCSPTLCK), VaList(bp+16, bp)) +} + +func X__ptsname_r(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v, (%v:)", tls, fd, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var err, v1 int32 + var _ /* pty at bp+0 */ int32 + _, _ = err, v1 + if !(buf != 0) { + len1 = uint64(0) + } + v1 = int32(X__syscall3(tls, int64(SYS_ioctl), int64(fd), Int64FromUint32(Uint32FromUint32(TIOCGPTN)), int64(bp))) + err = v1 + if v1 != 0 { + return -err + } + if Uint64FromInt32(Xsnprintf(tls, buf, len1, __ccgo_ts+926, VaList(bp+16, **(**int32)(__ccgo_up(bp))))) >= len1 { + return int32(ERANGE) + } + return 0 +} + +func Xptsname_r(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v, (%v:)", tls, fd, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__ptsname_r(tls, fd, buf, len1) +} + +func _slash_len(tls *TLS, s uintptr) (r Tsize_t) { + var s0 uintptr + _ = s0 + s0 = s + for int32(**(**int8)(__ccgo_up(s))) == int32('/') { + s = s + 1 + } + return Uint64FromInt64(int64(s) - int64(s0)) +} + +func Xrealpath(tls *TLS, filename uintptr, resolved uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v filename=%v resolved=%v, (%v:)", tls, filename, resolved, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(8208) + defer tls.Free(8208) + var check_dir, up int32 + var cnt, l, l0, nup, p, q, v4 Tsize_t + var k Tssize_t + var z uintptr + var _ /* output at bp+4097 */ [4096]int8 + var _ /* stack at bp+0 */ [4097]int8 + _, _, _, _, _, _, _, _, _, _, _ = check_dir, cnt, k, l, l0, nup, p, q, up, z, v4 + cnt = uint64(0) + nup = uint64(0) + check_dir = 0 + if !(filename != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + l = Xstrnlen(tls, filename, uint64(4097)) + if !(l != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(0) + } + if l >= uint64(PATH_MAX) { + goto toolong + } + p = uint64(4097) - l - uint64(1) + q = uint64(0) + Xmemcpy(tls, bp+uintptr(p), filename, l+uint64(1)) + /* Main loop. Each iteration pops the next part from stack of + * remaining path components and consumes any slashes that follow. + * If not a link, it's moved to output; if a link, contents are + * pushed to the stack. */ + goto restart +restart: + ; +_3: + ; + /* If stack starts with /, the whole component is / or // + * and the output state must be reset. */ + if int32((**(**[4097]int8)(__ccgo_up(bp)))[p]) == int32('/') { + check_dir = 0 + nup = uint64(0) + q = uint64(0) + v4 = q + q = q + 1 + (**(**[4096]int8)(__ccgo_up(bp + 4097)))[v4] = int8('/') + p = p + 1 + /* Initial // is special. */ + if int32((**(**[4097]int8)(__ccgo_up(bp)))[p]) == int32('/') && int32((**(**[4097]int8)(__ccgo_up(bp)))[p+uint64(1)]) != int32('/') { + v4 = q + q = q + 1 + (**(**[4096]int8)(__ccgo_up(bp + 4097)))[v4] = int8('/') + } + goto _2 + } + z = X__strchrnul(tls, bp+uintptr(p), int32('/')) + v4 = Uint64FromInt64(int64(z) - int64(bp+uintptr(p))) + l = v4 + l0 = v4 + if !(l != 0) && !(check_dir != 0) { + goto _1 + } + /* Skip any . component but preserve check_dir status. */ + if l == uint64(1) && int32((**(**[4097]int8)(__ccgo_up(bp)))[p]) == int32('.') { + p = p + l + goto _2 + } + /* Copy next component onto output at least temporarily, to + * call readlink, but wait to advance output position until + * determining it's not a link. */ + if q != 0 && int32((**(**[4096]int8)(__ccgo_up(bp + 4097)))[q-uint64(1)]) != int32('/') { + if !(p != 0) { + goto toolong + } + p = p - 1 + v4 = p + (**(**[4097]int8)(__ccgo_up(bp)))[v4] = int8('/') + l = l + 1 + } + if q+l >= uint64(PATH_MAX) { + goto toolong + } + Xmemcpy(tls, bp+4097+uintptr(q), bp+uintptr(p), l) + (**(**[4096]int8)(__ccgo_up(bp + 4097)))[q+l] = 0 + p = p + l + up = 0 + if l0 == uint64(2) && int32((**(**[4097]int8)(__ccgo_up(bp)))[p-uint64(2)]) == int32('.') && int32((**(**[4097]int8)(__ccgo_up(bp)))[p-uint64(1)]) == int32('.') { + up = int32(1) + /* Any non-.. path components we could cancel start + * after nup repetitions of the 3-byte string "../"; + * if there are none, accumulate .. components to + * later apply to cwd, if needed. */ + if q <= uint64(3)*nup { + nup = nup + 1 + q = q + l + goto _2 + } + /* When previous components are already known to be + * directories, processing .. can skip readlink. */ + if !(check_dir != 0) { + goto skip_readlink + } + } + k = Xreadlink(tls, bp+4097, bp, p) + if Uint64FromInt64(k) == p { + goto toolong + } + if !(k != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(0) + } + if !(k < 0) { + goto _8 + } + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(EINVAL) { + return uintptr(0) + } + goto skip_readlink +skip_readlink: + ; + check_dir = 0 + if up != 0 { + for q != 0 && int32((**(**[4096]int8)(__ccgo_up(bp + 4097)))[q-uint64(1)]) != int32('/') { + q = q - 1 + } + if q > uint64(1) && (q > uint64(2) || int32((**(**[4096]int8)(__ccgo_up(bp + 4097)))[0]) != int32('/')) { + q = q - 1 + } + goto _2 + } + if l0 != 0 { + q = q + l + } + check_dir = int32((**(**[4097]int8)(__ccgo_up(bp)))[p]) + goto _2 +_8: + ; + cnt = cnt + 1 + v4 = cnt + if v4 == uint64(SYMLOOP_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ELOOP) + return uintptr(0) + } + /* If link contents end in /, strip any slashes already on + * stack to avoid /->// or //->/// or spurious toolong. */ + if int32((**(**[4097]int8)(__ccgo_up(bp)))[k-int64(1)]) == int32('/') { + for int32((**(**[4097]int8)(__ccgo_up(bp)))[p]) == int32('/') { + p = p + 1 + } + } + p = p - Uint64FromInt64(k) + Xmemmove(tls, bp+uintptr(p), bp, Uint64FromInt64(k)) + /* Skip the stack advancement in case we have a new + * absolute base path. */ + goto restart + goto _2 +_2: + ; + p = p + _slash_len(tls, bp+uintptr(p)) + goto _3 + goto _1 +_1: + ; + (**(**[4096]int8)(__ccgo_up(bp + 4097)))[q] = 0 + if int32((**(**[4096]int8)(__ccgo_up(bp + 4097)))[0]) != int32('/') { + if !(Xgetcwd(tls, bp, uint64(4097)) != 0) { + return uintptr(0) + } + l = _strlen(tls, bp) + /* Cancel any initial .. components. */ + p = uint64(0) + for { + v4 = nup + nup = nup - 1 + if !(v4 != 0) { + break + } + for l > uint64(1) && int32((**(**[4097]int8)(__ccgo_up(bp)))[l-uint64(1)]) != int32('/') { + l = l - 1 + } + if l > uint64(1) { + l = l - 1 + } + p = p + uint64(2) + if p < q { + p = p + 1 + } + } + if q-p != 0 && int32((**(**[4097]int8)(__ccgo_up(bp)))[l-uint64(1)]) != int32('/') { + v4 = l + l = l + 1 + (**(**[4097]int8)(__ccgo_up(bp)))[v4] = int8('/') + } + if l+(q-p)+uint64(1) >= uint64(PATH_MAX) { + goto toolong + } + Xmemmove(tls, bp+4097+uintptr(l), bp+4097+uintptr(p), q-p+uint64(1)) + Xmemcpy(tls, bp+4097, bp, l) + q = l + q - p + } + if resolved != 0 { + return Xmemcpy(tls, resolved, bp+4097, q+uint64(1)) + } else { + return Xstrdup(tls, bp+4097) + } + goto toolong +toolong: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return uintptr(0) +} + +func Xsetdomainname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v len1=%v, (%v:)", tls, name, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_setdomainname), int64(name), Int64FromUint64(len1))))) +} + +func Xsetpriority(tls *TLS, which int32, who Tid_t, prio int32) (r int32) { + if __ccgo_strace { + trc("tls=%v which=%v who=%v prio=%v, (%v:)", tls, which, who, prio, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_setpriority), int64(which), Int64FromUint32(who), int64(prio))))) +} + +type Tctx = struct { + Flim [2]uint64 + Fres int32 + Ferr int32 +} + +func _do_setrlimit(tls *TLS, p uintptr) { + var c uintptr + _ = c + c = p + if (*Tctx)(unsafe.Pointer(c)).Ferr > 0 { + return + } + (*Tctx)(unsafe.Pointer(c)).Ferr = int32(-X__syscall2(tls, int64(SYS_setrlimit), int64((*Tctx)(unsafe.Pointer(c)).Fres), int64(c))) +} + +func Xsetrlimit(tls *TLS, resource int32, rlim uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v resource=%v rlim=%v, (%v:)", tls, resource, rlim, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var ret int32 + var v1, v2 uint64 + var _ /* c at bp+16 */ Tctx + var _ /* tmp at bp+0 */ Trlimit + _, _, _ = ret, v1, v2 + if ^Uint64FromUint64(0) != ^Uint64FromUint64(0) { + **(**Trlimit)(__ccgo_up(bp)) = **(**Trlimit)(__ccgo_up(rlim)) + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur >= ^Uint64FromUint64(0) { + (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur = ^Uint64FromUint64(0) + } + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_max >= ^Uint64FromUint64(0) { + (**(**Trlimit)(__ccgo_up(bp))).Frlim_max = ^Uint64FromUint64(0) + } + rlim = bp + } + ret = int32(X__syscall4(tls, int64(SYS_prlimit64), int64(Int32FromInt32(0)), int64(resource), int64(rlim), int64(Int32FromInt32(0)))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur < ^Uint64FromUint64(0) { + v1 = (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur + } else { + v1 = ^Uint64FromUint64(0) + } + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max < ^Uint64FromUint64(0) { + v2 = (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max + } else { + v2 = ^Uint64FromUint64(0) + } + **(**Tctx)(__ccgo_up(bp + 16)) = Tctx{ + Flim: [2]uint64{ + 0: v1, + 1: v2, + }, + Fres: resource, + Ferr: -int32(1), + } + ___synccall(tls, __ccgo_fp(_do_setrlimit), bp+16) + if (**(**Tctx)(__ccgo_up(bp + 16))).Ferr != 0 { + if (**(**Tctx)(__ccgo_up(bp + 16))).Ferr > 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = (**(**Tctx)(__ccgo_up(bp + 16))).Ferr + } + return -int32(1) + } + return 0 +} + +func Xsyscall(tls *TLS, n int64, va uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v n=%v va=%v, (%v:)", tls, n, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, b, c, d, e, f Tsyscall_arg_t + var ap Tva_list + _, _, _, _, _, _, _ = a, ap, b, c, d, e, f + ap = va + a = VaInt64(&ap) + b = VaInt64(&ap) + c = VaInt64(&ap) + d = VaInt64(&ap) + e = VaInt64(&ap) + f = VaInt64(&ap) + _ = ap + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, n, a, b, c, d, e, f))) +} + +const AF_ALG = 38 +const AF_APPLETALK = 5 +const AF_ASH = 18 +const AF_ATMPVC = 8 +const AF_ATMSVC = 20 +const AF_AX25 = 3 +const AF_BLUETOOTH = 31 +const AF_BRIDGE = 7 +const AF_CAIF = 37 +const AF_CAN = 29 +const AF_DECnet = 12 +const AF_ECONET = 19 +const AF_FILE = 1 +const AF_IB = 27 +const AF_IEEE802154 = 36 +const AF_INET = 2 +const AF_INET6 = 10 +const AF_IPX = 4 +const AF_IRDA = 23 +const AF_ISDN = 34 +const AF_IUCV = 32 +const AF_KCM = 41 +const AF_KEY = 15 +const AF_LLC = 26 +const AF_LOCAL = 1 +const AF_MAX = 45 +const AF_MPLS = 28 +const AF_NETBEUI = 13 +const AF_NETLINK = 16 +const AF_NETROM = 6 +const AF_NFC = 39 +const AF_PACKET = 17 +const AF_PHONET = 35 +const AF_PPPOX = 24 +const AF_QIPCRTR = 42 +const AF_RDS = 21 +const AF_ROSE = 11 +const AF_ROUTE = 16 +const AF_RXRPC = 33 +const AF_SECURITY = 14 +const AF_SMC = 43 +const AF_SNA = 22 +const AF_TIPC = 30 +const AF_UNIX = 1 +const AF_UNSPEC = 0 +const AF_VSOCK = 40 +const AF_WANPIPE = 25 +const AF_X25 = 9 +const AF_XDP = 44 +const LOG_ALERT = 1 +const LOG_AUTH = 32 +const LOG_AUTHPRIV = 80 +const LOG_CONS = 2 +const LOG_CRIT = 2 +const LOG_CRON = 72 +const LOG_DAEMON = 24 +const LOG_DEBUG = 7 +const LOG_EMERG = 0 +const LOG_ERR = 3 +const LOG_FACMASK = 1016 +const LOG_FTP = 88 +const LOG_INFO = 6 +const LOG_KERN = 0 +const LOG_LOCAL0 = 128 +const LOG_LOCAL1 = 136 +const LOG_LOCAL2 = 144 +const LOG_LOCAL3 = 152 +const LOG_LOCAL4 = 160 +const LOG_LOCAL5 = 168 +const LOG_LOCAL6 = 176 +const LOG_LOCAL7 = 184 +const LOG_LPR = 48 +const LOG_MAIL = 16 +const LOG_NDELAY = 8 +const LOG_NEWS = 56 +const LOG_NFACILITIES = 24 +const LOG_NOTICE = 5 +const LOG_NOWAIT = 16 +const LOG_ODELAY = 4 +const LOG_PERROR = 32 +const LOG_PID = 1 +const LOG_PRIMASK = 7 +const LOG_SYSLOG = 40 +const LOG_USER = 8 +const LOG_UUCP = 64 +const LOG_WARNING = 4 +const MSG_BATCH = 262144 +const MSG_CMSG_CLOEXEC = 1073741824 +const MSG_CONFIRM = 2048 +const MSG_CTRUNC = 8 +const MSG_DONTROUTE = 4 +const MSG_DONTWAIT = 64 +const MSG_EOR = 128 +const MSG_ERRQUEUE = 8192 +const MSG_FASTOPEN = 536870912 +const MSG_FIN = 512 +const MSG_MORE = 32768 +const MSG_NOSIGNAL = 16384 +const MSG_OOB = 1 +const MSG_PEEK = 2 +const MSG_PROXY = 16 +const MSG_RST = 4096 +const MSG_SYN = 1024 +const MSG_TRUNC = 32 +const MSG_WAITALL = 256 +const MSG_WAITFORONE = 65536 +const MSG_ZEROCOPY = 67108864 +const PF_ALG = 38 +const PF_APPLETALK = 5 +const PF_ASH = 18 +const PF_ATMPVC = 8 +const PF_ATMSVC = 20 +const PF_AX25 = 3 +const PF_BLUETOOTH = 31 +const PF_BRIDGE = 7 +const PF_CAIF = 37 +const PF_CAN = 29 +const PF_DECnet = 12 +const PF_ECONET = 19 +const PF_FILE = 1 +const PF_IB = 27 +const PF_IEEE802154 = 36 +const PF_INET = 2 +const PF_INET6 = 10 +const PF_IPX = 4 +const PF_IRDA = 23 +const PF_ISDN = 34 +const PF_IUCV = 32 +const PF_KCM = 41 +const PF_KEY = 15 +const PF_LLC = 26 +const PF_LOCAL = 1 +const PF_MAX = 45 +const PF_MPLS = 28 +const PF_NETBEUI = 13 +const PF_NETLINK = 16 +const PF_NETROM = 6 +const PF_NFC = 39 +const PF_PACKET = 17 +const PF_PHONET = 35 +const PF_PPPOX = 24 +const PF_QIPCRTR = 42 +const PF_RDS = 21 +const PF_ROSE = 11 +const PF_ROUTE = 16 +const PF_RXRPC = 33 +const PF_SECURITY = 14 +const PF_SMC = 43 +const PF_SNA = 22 +const PF_TIPC = 30 +const PF_UNIX = 1 +const PF_UNSPEC = 0 +const PF_VSOCK = 40 +const PF_WANPIPE = 25 +const PF_X25 = 9 +const PF_XDP = 44 +const SCM_CREDENTIALS = 2 +const SCM_RIGHTS = 1 +const SCM_TIMESTAMP = 29 +const SCM_TIMESTAMPING = 37 +const SCM_TIMESTAMPING_OPT_STATS = 54 +const SCM_TIMESTAMPING_PKTINFO = 58 +const SCM_TIMESTAMPNS = 35 +const SCM_TXTIME = 61 +const SCM_WIFI_STATUS = 41 +const SHUT_RD = 0 +const SHUT_RDWR = 2 +const SHUT_WR = 1 +const SOCK_CLOEXEC = 524288 +const SOCK_DCCP = 6 +const SOCK_DGRAM = 2 +const SOCK_NONBLOCK = 2048 +const SOCK_PACKET = 10 +const SOCK_RAW = 3 +const SOCK_RDM = 4 +const SOCK_SEQPACKET = 5 +const SOCK_STREAM = 1 +const SOL_AAL = 265 +const SOL_ALG = 279 +const SOL_ATM = 264 +const SOL_BLUETOOTH = 274 +const SOL_CAIF = 278 +const SOL_DCCP = 269 +const SOL_DECNET = 261 +const SOL_ICMPV6 = 58 +const SOL_IP = 0 +const SOL_IPV6 = 41 +const SOL_IRDA = 266 +const SOL_IUCV = 277 +const SOL_KCM = 281 +const SOL_LLC = 268 +const SOL_NETBEUI = 267 +const SOL_NETLINK = 270 +const SOL_NFC = 280 +const SOL_PACKET = 263 +const SOL_PNPIPE = 275 +const SOL_PPPOL2TP = 273 +const SOL_RAW = 255 +const SOL_RDS = 276 +const SOL_RXRPC = 272 +const SOL_SOCKET = 1 +const SOL_TIPC = 271 +const SOL_TLS = 282 +const SOL_X25 = 262 +const SOL_XDP = 283 +const SOMAXCONN = 128 +const SO_ACCEPTCONN = 30 +const SO_ATTACH_BPF = 50 +const SO_ATTACH_FILTER = 26 +const SO_ATTACH_REUSEPORT_CBPF = 51 +const SO_ATTACH_REUSEPORT_EBPF = 52 +const SO_BINDTODEVICE = 25 +const SO_BINDTOIFINDEX = 62 +const SO_BPF_EXTENSIONS = 48 +const SO_BROADCAST = 6 +const SO_BSDCOMPAT = 14 +const SO_BUSY_POLL = 46 +const SO_BUSY_POLL_BUDGET = 70 +const SO_CNX_ADVICE = 53 +const SO_COOKIE = 57 +const SO_DEBUG = 1 +const SO_DETACH_BPF = 27 +const SO_DETACH_FILTER = 27 +const SO_DETACH_REUSEPORT_BPF = 68 +const SO_DOMAIN = 39 +const SO_DONTROUTE = 5 +const SO_ERROR = 4 +const SO_GET_FILTER = 26 +const SO_INCOMING_CPU = 49 +const SO_INCOMING_NAPI_ID = 56 +const SO_KEEPALIVE = 9 +const SO_LINGER = 13 +const SO_LOCK_FILTER = 44 +const SO_MARK = 36 +const SO_MAX_PACING_RATE = 47 +const SO_MEMINFO = 55 +const SO_NOFCS = 43 +const SO_NO_CHECK = 11 +const SO_OOBINLINE = 10 +const SO_PASSCRED = 16 +const SO_PASSSEC = 34 +const SO_PEEK_OFF = 42 +const SO_PEERCRED = 17 +const SO_PEERGROUPS = 59 +const SO_PEERNAME = 28 +const SO_PEERSEC = 31 +const SO_PREFER_BUSY_POLL = 69 +const SO_PRIORITY = 12 +const SO_PROTOCOL = 38 +const SO_RCVBUF = 8 +const SO_RCVBUFFORCE = 33 +const SO_RCVLOWAT = 18 +const SO_RCVTIMEO = 20 +const SO_REUSEADDR = 2 +const SO_REUSEPORT = 15 +const SO_RXQ_OVFL = 40 +const SO_SECURITY_AUTHENTICATION = 22 +const SO_SECURITY_ENCRYPTION_NETWORK = 24 +const SO_SECURITY_ENCRYPTION_TRANSPORT = 23 +const SO_SELECT_ERR_QUEUE = 45 +const SO_SNDBUF = 7 +const SO_SNDBUFFORCE = 32 +const SO_SNDLOWAT = 19 +const SO_SNDTIMEO = 21 +const SO_TIMESTAMP = 29 +const SO_TIMESTAMPING = 37 +const SO_TIMESTAMPNS = 35 +const SO_TXTIME = 61 +const SO_TYPE = 3 +const SO_WIFI_STATUS = 41 +const SO_ZEROCOPY = 60 + +type Tsocklen_t = uint32 + +type Tsa_family_t = uint16 + +type Tmsghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Tsocklen_t + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__pad1 int32 + Fmsg_control uintptr + Fmsg_controllen Tsocklen_t + F__pad2 int32 + Fmsg_flags int32 +} + +type Tcmsghdr = struct { + Fcmsg_len Tsocklen_t + F__pad1 int32 + Fcmsg_level int32 + Fcmsg_type int32 +} + +type Tlinger = struct { + Fl_onoff int32 + Fl_linger int32 +} + +type Tsockaddr = struct { + Fsa_family Tsa_family_t + Fsa_data [14]int8 +} + +type Tsockaddr_storage = struct { + Fss_family Tsa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 +} + +var _lock2 [1]int32 +var _log_ident [32]int8 +var _log_opt int32 +var _log_facility = Int32FromInt32(1) << Int32FromInt32(3) +var _log_mask = int32(0xff) +var _log_fd = -int32(1) + +func Xsetlogmask(tls *TLS, maskpri int32) (r int32) { + if __ccgo_strace { + trc("tls=%v maskpri=%v, (%v:)", tls, maskpri, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + ___lock(tls, uintptr(unsafe.Pointer(&_lock2))) + ret = _log_mask + if maskpri != 0 { + _log_mask = maskpri + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock2))) + return ret +} + +var _log_addr = struct { + Fsun_family int16 + Fsun_path [9]int8 +}{ + Fsun_family: int16(PF_LOCAL), + Fsun_path: [9]int8{'/', 'd', 'e', 'v', '/', 'l', 'o', 'g'}, +} + +func Xcloselog(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* cs at bp+0 */ int32 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + ___lock(tls, uintptr(unsafe.Pointer(&_lock2))) + Xclose(tls, _log_fd) + _log_fd = -int32(1) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock2))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) +} + +func ___openlog(tls *TLS) { + _log_fd = Xsocket(tls, int32(PF_LOCAL), Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC), 0) + if _log_fd >= 0 { + Xconnect(tls, _log_fd, uintptr(unsafe.Pointer(&_log_addr)), uint32(12)) + } +} + +func Xopenlog(tls *TLS, ident uintptr, opt int32, facility int32) { + if __ccgo_strace { + trc("tls=%v ident=%v opt=%v facility=%v, (%v:)", tls, ident, opt, facility, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var n Tsize_t + var _ /* cs at bp+0 */ int32 + _ = n + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + ___lock(tls, uintptr(unsafe.Pointer(&_lock2))) + if ident != 0 { + n = Xstrnlen(tls, ident, Uint64FromInt64(32)-Uint64FromInt32(1)) + Xmemcpy(tls, uintptr(unsafe.Pointer(&_log_ident)), ident, n) + _log_ident[n] = 0 + } else { + _log_ident[0] = 0 + } + _log_opt = opt + _log_facility = facility + if opt&int32(LOG_NDELAY) != 0 && _log_fd < 0 { + ___openlog(tls) + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock2))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) +} + +func _is_lost_conn(tls *TLS, e int32) (r int32) { + return BoolInt32(e == int32(ECONNREFUSED) || e == int32(ECONNRESET) || e == int32(ENOTCONN) || e == int32(EPIPE)) +} + +func __vsyslog(tls *TLS, priority int32, message uintptr, ap Tva_list) { + bp := tls.Alloc(1184) + defer tls.Free(1184) + var errno_save, fd, l, l2, pid, v1 int32 + var _ /* buf at bp+80 */ [1024]int8 + var _ /* hlen at bp+1104 */ int32 + var _ /* now at bp+16 */ Ttime_t + var _ /* timebuf at bp+0 */ [16]int8 + var _ /* tm at bp+24 */ Ttm + _, _, _, _, _, _ = errno_save, fd, l, l2, pid, v1 + errno_save = **(**int32)(__ccgo_up(X__errno_location(tls))) + if _log_fd < 0 { + ___openlog(tls) + } + if !(priority&Int32FromInt32(LOG_FACMASK) != 0) { + priority = priority | _log_facility + } + **(**Ttime_t)(__ccgo_up(bp + 16)) = Xtime(tls, UintptrFromInt32(0)) + Xgmtime_r(tls, bp+16, bp+24) + Xstrftime_l(tls, bp, uint64(16), __ccgo_ts+938, bp+24, uintptr(unsafe.Pointer(&X__c_locale))) + if _log_opt&int32(LOG_PID) != 0 { + v1 = Xgetpid(tls) + } else { + v1 = 0 + } + pid = v1 + l = Xsnprintf(tls, bp+80, uint64(1024), __ccgo_ts+947, VaList(bp+1120, priority, bp, bp+1104, uintptr(unsafe.Pointer(&_log_ident)), __ccgo_ts+969+BoolUintptr(!(pid != 0)), pid, __ccgo_ts+971+BoolUintptr(!(pid != 0)))) + **(**int32)(__ccgo_up(X__errno_location(tls))) = errno_save + l2 = Xvsnprintf(tls, bp+80+uintptr(l), uint64(1024)-Uint64FromInt32(l), message, ap) + if l2 >= 0 { + if Uint64FromInt32(l2) >= uint64(1024)-Uint64FromInt32(l) { + l = Int32FromUint64(Uint64FromInt64(1024) - Uint64FromInt32(1)) + } else { + l = l + l2 + } + if int32((**(**[1024]int8)(__ccgo_up(bp + 80)))[l-int32(1)]) != int32('\n') { + v1 = l + l = l + 1 + (**(**[1024]int8)(__ccgo_up(bp + 80)))[v1] = int8('\n') + } + if Xsend(tls, _log_fd, bp+80, Uint64FromInt32(l), 0) < 0 && (!(_is_lost_conn(tls, **(**int32)(__ccgo_up(X__errno_location(tls)))) != 0) || Xconnect(tls, _log_fd, uintptr(unsafe.Pointer(&_log_addr)), uint32(12)) < 0 || Xsend(tls, _log_fd, bp+80, Uint64FromInt32(l), 0) < 0) && _log_opt&int32(LOG_CONS) != 0 { + fd = Xopen(tls, __ccgo_ts+666, Int32FromInt32(O_WRONLY)|Int32FromInt32(O_NOCTTY)|Int32FromInt32(O_CLOEXEC), 0) + if fd >= 0 { + Xdprintf(tls, fd, __ccgo_ts+973, VaList(bp+1120, l-**(**int32)(__ccgo_up(bp + 1104)), bp+80+uintptr(**(**int32)(__ccgo_up(bp + 1104))))) + Xclose(tls, fd) + } + } + if _log_opt&int32(LOG_PERROR) != 0 { + Xdprintf(tls, int32(2), __ccgo_ts+973, VaList(bp+1120, l-**(**int32)(__ccgo_up(bp + 1104)), bp+80+uintptr(**(**int32)(__ccgo_up(bp + 1104))))) + } + } +} + +func ___vsyslog(tls *TLS, priority int32, message uintptr, ap Tva_list) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* cs at bp+0 */ int32 + if !(_log_mask&(Int32FromInt32(1)<<(priority&Int32FromInt32(7))) != 0) || priority & ^Int32FromInt32(0x3ff) != 0 { + return + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + ___lock(tls, uintptr(unsafe.Pointer(&_lock2))) + __vsyslog(tls, priority, message, ap) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock2))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) +} + +func Xsyslog(tls *TLS, priority int32, message uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v priority=%v message=%v va=%v, (%v:)", tls, priority, message, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + ___vsyslog(tls, priority, message, ap) + _ = ap +} + +type Tutsname1 = struct { + Fsysname [65]int8 + Fnodename [65]int8 + Frelease [65]int8 + Fversion [65]int8 + Fmachine [65]int8 + F__domainname [65]int8 +} + +func Xuname(tls *TLS, uts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v uts=%v, (%v:)", tls, uts, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_uname), int64(uts))))) +} + +func X__madvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v advice=%v, (%v:)", tls, addr, len1, advice, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_madvise), int64(addr), Int64FromUint64(len1), int64(advice))))) +} + +func Xmadvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v advice=%v, (%v:)", tls, addr, len1, advice, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__madvise(tls, addr, len1, advice) +} + +func Xmincore(tls *TLS, addr uintptr, len1 Tsize_t, vec uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v vec=%v, (%v:)", tls, addr, len1, vec, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mincore), int64(addr), Int64FromUint64(len1), int64(vec))))) +} + +func Xmlock(tls *TLS, addr uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v, (%v:)", tls, addr, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_mlock), int64(addr), Int64FromUint64(len1))))) +} + +func Xmlockall(tls *TLS, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_mlockall), int64(flags))))) +} + +const OFF_MASK = 4095 +const UNIT = 4096 + +func _dummy5(tls *TLS) { +} + +func X__mmap(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v prot=%v flags=%v fd=%v off=%v, (%v:)", tls, start, len1, prot, flags, fd, off, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int64 + _ = ret + if Uint64FromInt64(off)&(-Uint64FromUint64(0x2000)<<(Uint64FromInt32(8)*Uint64FromInt64(8)-Uint64FromInt32(1))|(Uint64FromUint64(4096)-Uint64FromInt32(1))) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(-Int32FromInt32(1)) + } + if len1 >= Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return uintptr(-Int32FromInt32(1)) + } + if flags&int32(MAP_FIXED) != 0 { + _dummy5(tls) + } + ret = X__syscall6(tls, int64(SYS_mmap), int64(start), Int64FromUint64(len1), int64(prot), int64(flags), int64(fd), off) + /* Fixup incorrect EPERM from kernel. */ + if ret == int64(-int32(EPERM)) && !(start != 0) && flags&int32(MAP_ANON) != 0 && !(flags&Int32FromInt32(MAP_FIXED) != 0) { + ret = int64(-int32(ENOMEM)) + } + return uintptr(X__syscall_ret(tls, Uint64FromInt64(ret))) +} + +func Xmmap(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v prot=%v flags=%v fd=%v off=%v, (%v:)", tls, start, len1, prot, flags, fd, off, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mmap(tls, start, len1, prot, flags, fd, off) +} + +func X__mprotect(tls *TLS, addr uintptr, len1 Tsize_t, prot int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v prot=%v, (%v:)", tls, addr, len1, prot, origin(2)) + defer func() { trc("-> %v", r) }() + } + var end, start Tsize_t + _, _ = end, start + start = uint64(addr) & Uint64FromInt32(-Int32FromInt32(PAGESIZE)) + end = uint64(addr+uintptr(len1)+UintptrFromInt32(PAGESIZE)-UintptrFromInt32(1)) & Uint64FromInt32(-Int32FromInt32(PAGESIZE)) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mprotect), Int64FromUint64(start), Int64FromUint64(end-start), int64(prot))))) +} + +func Xmprotect(tls *TLS, addr uintptr, len1 Tsize_t, prot int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v prot=%v, (%v:)", tls, addr, len1, prot, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mprotect(tls, addr, len1, prot) +} + +func _dummy6(tls *TLS) { +} + +func X__mremap(tls *TLS, old_addr uintptr, old_len Tsize_t, new_len Tsize_t, flags int32, va uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v old_addr=%v old_len=%v new_len=%v flags=%v va=%v, (%v:)", tls, old_addr, old_len, new_len, flags, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var new_addr uintptr + _, _ = ap, new_addr + new_addr = uintptr(0) + if new_len >= Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return uintptr(-Int32FromInt32(1)) + } + if flags&int32(MREMAP_FIXED) != 0 { + _dummy6(tls) + ap = va + new_addr = VaUintptr(&ap) + _ = ap + } + return uintptr(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_mremap), int64(old_addr), Int64FromUint64(old_len), Int64FromUint64(new_len), int64(flags), int64(new_addr))))) +} + +func Xmremap(tls *TLS, old_addr uintptr, old_len Tsize_t, new_len Tsize_t, flags int32, va uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v old_addr=%v old_len=%v new_len=%v flags=%v va=%v, (%v:)", tls, old_addr, old_len, new_len, flags, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mremap(tls, old_addr, old_len, new_len, flags, va) +} + +func Xmsync(tls *TLS, start uintptr, len1 Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v flags=%v, (%v:)", tls, start, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_msync), int64(start), Int64FromUint64(len1), int64(flags), 0, 0, 0)))) +} + +func Xmunlock(tls *TLS, addr uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v, (%v:)", tls, addr, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_munlock), int64(addr), Int64FromUint64(len1))))) +} + +func Xmunlockall(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall0(tls, int64(SYS_munlockall))))) +} + +func _dummy7(tls *TLS) { +} + +func X__munmap(tls *TLS, start uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v, (%v:)", tls, start, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + _dummy7(tls) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_munmap), int64(start), Int64FromUint64(len1))))) +} + +func Xmunmap(tls *TLS, start uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v, (%v:)", tls, start, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__munmap(tls, start, len1) +} + +func Xposix_madvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v advice=%v, (%v:)", tls, addr, len1, advice, origin(2)) + defer func() { trc("-> %v", r) }() + } + if advice == int32(MADV_DONTNEED) { + return 0 + } + return int32(-X__syscall3(tls, int64(SYS_madvise), int64(addr), Int64FromUint64(len1), int64(advice))) +} + +func X__shm_mapname(tls *TLS, name uintptr, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v buf=%v, (%v:)", tls, name, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p, v1 uintptr + _, _ = p, v1 + for int32(**(**int8)(__ccgo_up(name))) == int32('/') { + name = name + 1 + } + v1 = X__strchrnul(tls, name, int32('/')) + p = v1 + if **(**int8)(__ccgo_up(v1)) != 0 || p == name || int64(p)-int64(name) <= int64(2) && int32(**(**int8)(__ccgo_up(name))) == int32('.') && int32(**(**int8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) == int32('.') { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + if int64(p)-int64(name) > int64(NAME_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return uintptr(0) + } + Xmemcpy(tls, buf, __ccgo_ts+978, uint64(9)) + Xmemcpy(tls, buf+uintptr(9), name, Uint64FromInt64(int64(p)-int64(name)+int64(1))) + return buf +} + +func Xshm_open(tls *TLS, name uintptr, flag int32, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v flag=%v mode=%v, (%v:)", tls, name, flag, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(288) + defer tls.Free(288) + var fd int32 + var v1 uintptr + var _ /* buf at bp+4 */ [265]int8 + var _ /* cs at bp+0 */ int32 + _, _ = fd, v1 + v1 = X__shm_mapname(tls, name, bp+4) + name = v1 + if !(v1 != 0) { + return -int32(1) + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + fd = Xopen(tls, name, flag|int32(O_NOFOLLOW)|int32(O_CLOEXEC)|int32(O_NONBLOCK), VaList(bp+280, mode)) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) + return fd +} + +func Xshm_unlink(tls *TLS, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(272) + defer tls.Free(272) + var v1 uintptr + var _ /* buf at bp+0 */ [265]int8 + _ = v1 + v1 = X__shm_mapname(tls, name, bp) + name = v1 + if !(v1 != 0) { + return -int32(1) + } + return Xunlink(tls, name) +} + +const SA = 194 +const SB = 244 +const bittab = 0 + +func Xbtowc(tls *TLS, c int32) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var b, v3 int32 + var v1, v2 uint32 + _, _, _, _ = b, v1, v2, v3 + b = Int32FromUint8(Uint8FromInt32(c)) + if Uint32FromInt32(b) < uint32(128) { + v1 = Uint32FromInt32(b) + } else { + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v3 = int32(4) + } else { + v3 = int32(1) + } + if v3 == int32(1) && c != -int32(1) { + v2 = Uint32FromInt32(Int32FromInt32(0xdfff) & int32(int8(c))) + } else { + v2 = uint32(0xffffffff) + } + v1 = v2 + } + return v1 +} + +type Tchar16_t = uint16 + +type Tchar32_t = uint32 + +func Xc16rtomb(tls *TLS, s uintptr, c16 Tchar16_t, ps uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c16=%v ps=%v, (%v:)", tls, s, c16, ps, origin(2)) + defer func() { trc("-> %v", r) }() + } + var wc Twchar_t + var x uintptr + _, _ = wc, x + if !(ps != 0) { + ps = uintptr(unsafe.Pointer(&_internal_state)) + } + x = ps + if !(s != 0) { + if **(**uint32)(__ccgo_up(x)) != 0 { + goto ilseq + } + return uint64(1) + } + if !(**(**uint32)(__ccgo_up(x)) != 0) && uint32(c16)-uint32(0xd800) < uint32(0x400) { + **(**uint32)(__ccgo_up(x)) = Uint32FromInt32((Int32FromUint16(c16) - int32(0xd7c0)) << int32(10)) + return uint64(0) + } + if **(**uint32)(__ccgo_up(x)) != 0 { + if uint32(c16)-uint32(0xdc00) >= uint32(0x400) { + goto ilseq + } else { + wc = Int32FromUint32(**(**uint32)(__ccgo_up(x)) + uint32(c16) - uint32(0xdc00)) + } + **(**uint32)(__ccgo_up(x)) = uint32(0) + } else { + wc = Int32FromUint16(c16) + } + return Xwcrtomb(tls, s, wc, uintptr(0)) + goto ilseq +ilseq: + ; + **(**uint32)(__ccgo_up(x)) = uint32(0) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + return Uint64FromInt32(-Int32FromInt32(1)) +} + +var _internal_state uint32 + +func Xc32rtomb(tls *TLS, s uintptr, c32 Tchar32_t, ps uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c32=%v ps=%v, (%v:)", tls, s, c32, ps, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcrtomb(tls, s, Int32FromUint32(c32), ps) +} + +func Xmblen(tls *TLS, s uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmbtowc(tls, uintptr(0), s, n) +} + +func Xmbrlen(tls *TLS, s uintptr, n Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v st=%v, (%v:)", tls, s, n, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + if st != 0 { + v1 = st + } else { + v1 = uintptr(unsafe.Pointer(&_internal)) + } + return Xmbrtowc(tls, uintptr(0), s, n, v1) +} + +var _internal uint32 + +func Xmbrtoc16(tls *TLS, pc16 uintptr, s uintptr, n Tsize_t, ps uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v pc16=%v s=%v n=%v ps=%v, (%v:)", tls, pc16, s, n, ps, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var pending uintptr + var ret Tsize_t + var _ /* wc at bp+0 */ Twchar_t + _, _ = pending, ret + if !(ps != 0) { + ps = uintptr(unsafe.Pointer(&_internal_state1)) + } + pending = ps + if !(s != 0) { + return Xmbrtoc16(tls, uintptr(0), __ccgo_ts, uint64(1), ps) + } + /* mbrtowc states for partial UTF-8 characters have the high bit set; + * we use nonzero states without high bit for pending surrogates. */ + if Int32FromUint32(**(**uint32)(__ccgo_up(pending))) > 0 { + if pc16 != 0 { + **(**Tchar16_t)(__ccgo_up(pc16)) = uint16(**(**uint32)(__ccgo_up(pending))) + } + **(**uint32)(__ccgo_up(pending)) = uint32(0) + return Uint64FromInt32(-Int32FromInt32(3)) + } + ret = Xmbrtowc(tls, bp, s, n, ps) + if ret <= uint64(4) { + if **(**Twchar_t)(__ccgo_up(bp)) >= int32(0x10000) { + **(**uint32)(__ccgo_up(pending)) = Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))&int32(0x3ff) + int32(0xdc00)) + **(**Twchar_t)(__ccgo_up(bp)) = int32(0xd7c0) + **(**Twchar_t)(__ccgo_up(bp))>>Int32FromInt32(10) + } + if pc16 != 0 { + **(**Tchar16_t)(__ccgo_up(pc16)) = Uint16FromInt32(**(**Twchar_t)(__ccgo_up(bp))) + } + } + return ret +} + +var _internal_state1 uint32 + +func Xmbrtoc32(tls *TLS, pc32 uintptr, s uintptr, n Tsize_t, ps uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v pc32=%v s=%v n=%v ps=%v, (%v:)", tls, pc32, s, n, ps, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ret Tsize_t + var _ /* wc at bp+0 */ Twchar_t + _ = ret + if !(ps != 0) { + ps = uintptr(unsafe.Pointer(&_internal_state2)) + } + if !(s != 0) { + return Xmbrtoc32(tls, uintptr(0), __ccgo_ts, uint64(1), ps) + } + ret = Xmbrtowc(tls, bp, s, n, ps) + if ret <= uint64(4) && pc32 != 0 { + **(**Tchar32_t)(__ccgo_up(pc32)) = Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))) + } + return ret +} + +var _internal_state2 uint32 + +func Xmbrtowc(tls *TLS, wc uintptr, src uintptr, n Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v wc=%v src=%v n=%v st=%v, (%v:)", tls, wc, src, n, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var N Tsize_t + var c uint32 + var s, v3 uintptr + var v1 Twchar_t + var v2 int32 + var _ /* dummy at bp+0 */ Twchar_t + _, _, _, _, _, _ = N, c, s, v1, v2, v3 + s = src + N = n + if !(st != 0) { + st = uintptr(unsafe.Pointer(&_internal_state3)) + } + c = **(**uint32)(__ccgo_up(st)) + if !(s != 0) { + if c != 0 { + goto ilseq + } + return uint64(0) + } else { + if !(wc != 0) { + wc = bp + } + } + if !(n != 0) { + return Uint64FromInt32(-Int32FromInt32(2)) + } + if !(c != 0) { + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) < int32(0x80) { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + **(**Twchar_t)(__ccgo_up(wc)) = v1 + return BoolUint64(!!(v1 != 0)) + } + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v2 = int32(4) + } else { + v2 = int32(1) + } + if v2 == int32(1) { + **(**Twchar_t)(__ccgo_up(wc)) = Int32FromInt32(0xdfff) & int32(Int8FromUint8(**(**uint8)(__ccgo_up(s)))) + return Uint64FromInt32(1) + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(0xc2) > Uint32FromUint32(0xf4)-Uint32FromUint32(0xc2) { + goto ilseq + } + v3 = s + s = s + 1 + c = X__fsmu8[uint32(**(**uint8)(__ccgo_up(v3)))-uint32(0xc2)] + n = n - 1 + } + if n != 0 { + if (Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)-int32(0x10)|(Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)+Int32FromUint32(c)>>Int32FromInt32(26))) & ^Int32FromInt32(7) != 0 { + goto ilseq + } + goto loop + loop: + ; + v3 = s + s = s + 1 + c = c<= uint32(0x40) { + goto ilseq + } + goto loop + } + } + **(**uint32)(__ccgo_up(st)) = c + return Uint64FromInt32(-Int32FromInt32(2)) + goto ilseq +ilseq: + ; + **(**uint32)(__ccgo_up(st)) = uint32(0) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + return Uint64FromInt32(-Int32FromInt32(1)) +} + +var _internal_state3 uint32 + +func Xmbsinit(tls *TLS, st uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v st=%v, (%v:)", tls, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(!(st != 0) || !(**(**uint32)(__ccgo_up(st)) != 0)) +} + +func Xmbsnrtowcs(tls *TLS, wcs uintptr, src uintptr, n Tsize_t, wn Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v wcs=%v src=%v n=%v wn=%v st=%v, (%v:)", tls, wcs, src, n, wn, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(1040) + defer tls.Free(1040) + var cnt, l, n2, v1 Tsize_t + var tmp_s, ws uintptr + var v2 bool + var v3 uint64 + var _ /* s at bp+1024 */ uintptr + var _ /* wbuf at bp+0 */ [256]Twchar_t + _, _, _, _, _, _, _, _ = cnt, l, n2, tmp_s, ws, v1, v2, v3 + cnt = uint64(0) + **(**uintptr)(__ccgo_up(bp + 1024)) = **(**uintptr)(__ccgo_up(src)) + if !(wcs != 0) { + ws = bp + wn = Uint64FromInt64(1024) / Uint64FromInt64(4) + } else { + ws = wcs + } + /* making sure output buffer size is at most n/4 will ensure + * that mbsrtowcs never reads more than n input bytes. thus + * we can use mbsrtowcs as long as it's practical.. */ + for { + if v2 = **(**uintptr)(__ccgo_up(bp + 1024)) != 0 && wn != 0; v2 { + v1 = n / Uint64FromInt32(4) + n2 = v1 + } + if !(v2 && (v1 >= wn || n2 > uint64(32))) { + break + } + if n2 >= wn { + n2 = wn + } + tmp_s = **(**uintptr)(__ccgo_up(bp + 1024)) + l = Xmbsrtowcs(tls, ws, bp+1024, n2, st) + if !(l+Uint64FromInt32(1) != 0) { + cnt = l + wn = uint64(0) + break + } + if ws != bp { + ws = ws + uintptr(l)*4 + wn = wn - l + } + if **(**uintptr)(__ccgo_up(bp + 1024)) != 0 { + v3 = n - Uint64FromInt64(int64(**(**uintptr)(__ccgo_up(bp + 1024)))-int64(tmp_s)) + } else { + v3 = uint64(0) + } + n = v3 + cnt = cnt + l + } + if **(**uintptr)(__ccgo_up(bp + 1024)) != 0 { + for wn != 0 && n != 0 { + l = Xmbrtowc(tls, ws, **(**uintptr)(__ccgo_up(bp + 1024)), n, st) + if l+uint64(2) <= uint64(2) { + if !(l+Uint64FromInt32(1) != 0) { + cnt = l + break + } + if !(l != 0) { + **(**uintptr)(__ccgo_up(bp + 1024)) = uintptr(0) + break + } + /* have to roll back partial character */ + **(**uint32)(__ccgo_up(st)) = uint32(0) + break + } + **(**uintptr)(__ccgo_up(bp + 1024)) = **(**uintptr)(__ccgo_up(bp + 1024)) + uintptr(l) + n = n - l + /* safe - this loop runs fewer than sizeof(wbuf)/8 times */ + ws += 4 + wn = wn - 1 + cnt = cnt + 1 + } + } + if wcs != 0 { + **(**uintptr)(__ccgo_up(src)) = **(**uintptr)(__ccgo_up(bp + 1024)) + } + return cnt +} + +func Xmbsrtowcs(tls *TLS, ws uintptr, src uintptr, wn Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v ws=%v src=%v wn=%v st=%v, (%v:)", tls, ws, src, wn, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c, v1 uint32 + var s, v5, v6 uintptr + var wn0 Tsize_t + var v2 bool + var v3 int32 + _, _, _, _, _, _, _, _ = c, s, wn0, v1, v2, v3, v5, v6 + s = **(**uintptr)(__ccgo_up(src)) + wn0 = wn + c = uint32(0) + if v2 = st != 0; v2 { + v1 = **(**uint32)(__ccgo_up(st)) + c = v1 + } + if v2 && v1 != 0 { + if ws != 0 { + **(**uint32)(__ccgo_up(st)) = uint32(0) + goto resume + } else { + goto resume0 + } + } + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v3 = int32(4) + } else { + v3 = int32(1) + } + if v3 == int32(1) { + if !(ws != 0) { + return _strlen(tls, s) + } + for { + if !(wn != 0) { + **(**uintptr)(__ccgo_up(src)) = s + return wn0 + } + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + v5 = s + s = s + 1 + c = uint32(**(**uint8)(__ccgo_up(v5))) + v5 = ws + ws += 4 + **(**Twchar_t)(__ccgo_up(v5)) = Int32FromInt32(0xdfff) & int32(Int8FromUint32(c)) + wn = wn - 1 + goto _4 + _4: + } + **(**Twchar_t)(__ccgo_up(ws)) = 0 + **(**uintptr)(__ccgo_up(src)) = uintptr(0) + return wn0 - wn + } + if !!(ws != 0) { + goto _7 + } +_11: + ; + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(1) < uint32(0x7f) && uint64(s)%uint64(4) == uint64(0) { + for !((**(**uint32)(__ccgo_up(s))|(**(**uint32)(__ccgo_up(s))-Uint32FromInt32(0x01010101)))&Uint32FromUint32(0x80808080) != 0) { + s = s + uintptr(4) + wn = wn - uint64(4) + } + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(1) < uint32(0x7f) { + s = s + 1 + wn = wn - 1 + goto _10 + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(0xc2) > Uint32FromUint32(0xf4)-Uint32FromUint32(0xc2) { + goto _9 + } + v5 = s + s = s + 1 + c = X__fsmu8[uint32(**(**uint8)(__ccgo_up(v5)))-uint32(0xc2)] + goto resume0 +resume0: + ; + if (Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)-int32(0x10)|(Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)+Int32FromUint32(c)>>Int32FromInt32(26))) & ^Int32FromInt32(7) != 0 { + s = s - 1 + goto _9 + } + s = s + 1 + if c&(Uint32FromUint32(1)<= uint32(0x40) { + s = s - uintptr(2) + goto _9 + } + s = s + 1 + if c&(Uint32FromUint32(1)<= uint32(0x40) { + s = s - uintptr(3) + goto _9 + } + s = s + 1 + } + } + wn = wn - 1 + c = uint32(0) + goto _10 +_10: + ; + goto _11 + goto _9 +_9: + ; + goto _8 +_7: + ; +_15: + ; + if !(wn != 0) { + **(**uintptr)(__ccgo_up(src)) = s + return wn0 + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(1) < uint32(0x7f) && uint64(s)%uint64(4) == uint64(0) { + for wn >= uint64(5) && !((**(**uint32)(__ccgo_up(s))|(**(**uint32)(__ccgo_up(s))-Uint32FromInt32(0x01010101)))&Uint32FromUint32(0x80808080) != 0) { + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + wn = wn - uint64(4) + } + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(1) < uint32(0x7f) { + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + wn = wn - 1 + goto _14 + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(0xc2) > Uint32FromUint32(0xf4)-Uint32FromUint32(0xc2) { + goto _13 + } + v5 = s + s = s + 1 + c = X__fsmu8[uint32(**(**uint8)(__ccgo_up(v5)))-uint32(0xc2)] + goto resume +resume: + ; + if (Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)-int32(0x10)|(Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)+Int32FromUint32(c)>>Int32FromInt32(26))) & ^Int32FromInt32(7) != 0 { + s = s - 1 + goto _13 + } + v5 = s + s = s + 1 + c = c<= uint32(0x40) { + s = s - uintptr(2) + goto _13 + } + v5 = s + s = s + 1 + c = c<= uint32(0x40) { + s = s - uintptr(3) + goto _13 + } + v5 = s + s = s + 1 + c = c< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _s + return Xmbsrtowcs(tls, ws, bp, wn, uintptr(0)) +} + +func Xmbtowc(tls *TLS, wc uintptr, src uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v src=%v n=%v, (%v:)", tls, wc, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c uint32 + var s, v3 uintptr + var v1 Twchar_t + var v2 int32 + var _ /* dummy at bp+0 */ Twchar_t + _, _, _, _, _ = c, s, v1, v2, v3 + s = src + if !(s != 0) { + return 0 + } + if !(n != 0) { + goto ilseq + } + if !(wc != 0) { + wc = bp + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) < int32(0x80) { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + **(**Twchar_t)(__ccgo_up(wc)) = v1 + return BoolInt32(!!(v1 != 0)) + } + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v2 = int32(4) + } else { + v2 = int32(1) + } + if v2 == int32(1) { + **(**Twchar_t)(__ccgo_up(wc)) = Int32FromInt32(0xdfff) & int32(Int8FromUint8(**(**uint8)(__ccgo_up(s)))) + return Int32FromInt32(1) + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(0xc2) > Uint32FromUint32(0xf4)-Uint32FromUint32(0xc2) { + goto ilseq + } + v3 = s + s = s + 1 + c = X__fsmu8[uint32(**(**uint8)(__ccgo_up(v3)))-uint32(0xc2)] + /* Avoid excessive checks against n: If shifting the state n-1 + * times does not clear the high bit, then the value of n is + * insufficient to read a character */ + if n < uint64(4) && c<<(uint64(6)*n-uint64(6))&(Uint32FromUint32(1)<>int32(3)-int32(0x10)|(Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)+Int32FromUint32(c)>>Int32FromInt32(26))) & ^Int32FromInt32(7) != 0 { + goto ilseq + } + v3 = s + s = s + 1 + c = c<= uint32(0x40) { + goto ilseq + } + v3 = s + s = s + 1 + c = c<= uint32(0x40) { + goto ilseq + } + v3 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(wc)) = Int32FromUint32(c< %v", r) }() + } + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if !(s != 0) { + return uint64(1) + } + if Uint32FromInt32(wc) < uint32(0x80) { + **(**int8)(__ccgo_up(s)) = int8(wc) + return uint64(1) + } else { + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v1 = int32(4) + } else { + v1 = int32(1) + } + if v1 == int32(1) { + if !(Uint32FromInt32(wc)-Uint32FromInt32(0xdf80) < Uint32FromInt32(0x80)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + return Uint64FromInt32(-Int32FromInt32(1)) + } + **(**int8)(__ccgo_up(s)) = int8(wc) + return uint64(1) + } else { + if Uint32FromInt32(wc) < uint32(0x800) { + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8(int32(0xc0) | wc>>Int32FromInt32(6)) + **(**int8)(__ccgo_up(s)) = int8(int32(0x80) | wc&int32(0x3f)) + return uint64(2) + } else { + if Uint32FromInt32(wc) < uint32(0xd800) || Uint32FromInt32(wc)-uint32(0xe000) < uint32(0x2000) { + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8(int32(0xe0) | wc>>Int32FromInt32(12)) + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8(int32(0x80) | wc>>Int32FromInt32(6)&int32(0x3f)) + **(**int8)(__ccgo_up(s)) = int8(int32(0x80) | wc&int32(0x3f)) + return uint64(3) + } else { + if Uint32FromInt32(wc)-uint32(0x10000) < uint32(0x100000) { + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8(int32(0xf0) | wc>>Int32FromInt32(18)) + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8(int32(0x80) | wc>>Int32FromInt32(12)&int32(0x3f)) + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8(int32(0x80) | wc>>Int32FromInt32(6)&int32(0x3f)) + **(**int8)(__ccgo_up(s)) = int8(int32(0x80) | wc&int32(0x3f)) + return uint64(4) + } + } + } + } + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + return Uint64FromInt32(-Int32FromInt32(1)) +} + +func Xwcsnrtombs(tls *TLS, dst uintptr, wcs uintptr, wn Tsize_t, n Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dst=%v wcs=%v wn=%v n=%v st=%v, (%v:)", tls, dst, wcs, wn, n, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var cnt, l Tsize_t + var ws, v1 uintptr + var _ /* tmp at bp+0 */ [4]int8 + _, _, _, _ = cnt, l, ws, v1 + ws = **(**uintptr)(__ccgo_up(wcs)) + cnt = uint64(0) + if !(dst != 0) { + n = uint64(0) + } + for ws != 0 && wn != 0 { + if n < uint64(MB_LEN_MAX) { + v1 = bp + } else { + v1 = dst + } + l = Xwcrtomb(tls, v1, **(**Twchar_t)(__ccgo_up(ws)), uintptr(0)) + if l == Uint64FromInt32(-Int32FromInt32(1)) { + cnt = Uint64FromInt32(-Int32FromInt32(1)) + break + } + if dst != 0 { + if n < uint64(MB_LEN_MAX) { + if l > n { + break + } + Xmemcpy(tls, dst, bp, l) + } + dst = dst + uintptr(l) + n = n - l + } + if !(**(**Twchar_t)(__ccgo_up(ws)) != 0) { + ws = uintptr(0) + break + } + ws += 4 + wn = wn - 1 + cnt = cnt + l + } + if dst != 0 { + **(**uintptr)(__ccgo_up(wcs)) = ws + } + return cnt +} + +func Xwcsrtombs(tls *TLS, s uintptr, ws uintptr, n Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v ws=%v n=%v st=%v, (%v:)", tls, s, ws, n, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var N, l Tsize_t + var ws2, v2 uintptr + var _ /* buf at bp+0 */ [4]int8 + _, _, _, _ = N, l, ws2, v2 + N = n + if !(s != 0) { + n = uint64(0) + ws2 = **(**uintptr)(__ccgo_up(ws)) + for { + if !(**(**Twchar_t)(__ccgo_up(ws2)) != 0) { + break + } + if Uint32FromInt32(**(**Twchar_t)(__ccgo_up(ws2))) >= uint32(0x80) { + l = Xwcrtomb(tls, bp, **(**Twchar_t)(__ccgo_up(ws2)), uintptr(0)) + if !(l+Uint64FromInt32(1) != 0) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + n = n + l + } else { + n = n + 1 + } + goto _1 + _1: + ; + ws2 += 4 + } + return n + } + for n >= uint64(4) { + if Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))))-uint32(1) >= uint32(0x7f) { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))) != 0) { + **(**int8)(__ccgo_up(s)) = 0 + **(**uintptr)(__ccgo_up(ws)) = uintptr(0) + return N - n + } + l = Xwcrtomb(tls, s, **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))), uintptr(0)) + if !(l+Uint64FromInt32(1) != 0) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + s = s + uintptr(l) + n = n - l + } else { + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws))))) + n = n - 1 + } + **(**uintptr)(__ccgo_up(ws)) += 4 + } + for n != 0 { + if Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))))-uint32(1) >= uint32(0x7f) { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))) != 0) { + **(**int8)(__ccgo_up(s)) = 0 + **(**uintptr)(__ccgo_up(ws)) = uintptr(0) + return N - n + } + l = Xwcrtomb(tls, bp, **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))), uintptr(0)) + if !(l+Uint64FromInt32(1) != 0) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + if l > n { + return N - n + } + Xwcrtomb(tls, s, **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))), uintptr(0)) + s = s + uintptr(l) + n = n - l + } else { + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws))))) + n = n - 1 + } + **(**uintptr)(__ccgo_up(ws)) += 4 + } + return N +} + +func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v ws=%v n=%v, (%v:)", tls, s, ws, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = ws + return Xwcsrtombs(tls, s, bp, n, uintptr(0)) +} + +func Xwctob(tls *TLS, c Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if c < uint32(128) { + return Int32FromUint32(c) + } + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v1 = int32(4) + } else { + v1 = int32(1) + } + if v1 == int32(1) && c-uint32(0xdf80) < uint32(0x80) { + return Int32FromUint8(uint8(c)) + } + return -int32(1) +} + +func Xwctomb(tls *TLS, s uintptr, wc Twchar_t) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v wc=%v, (%v:)", tls, s, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(s != 0) { + return 0 + } + return Int32FromUint64(Xwcrtomb(tls, s, wc, uintptr(0))) +} + +func Xaccept(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_accept) + _ = int32(__SC_accept) + v2 = int64(fd) + v3 = int64(addr) + v4 = int64(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +type Tucred = struct { + Fpid Tpid_t + Fuid Tuid_t + Fgid Tgid_t +} + +type Tmmsghdr = struct { + Fmsg_hdr Tmsghdr + Fmsg_len uint32 +} + +func Xaccept4(tls *TLS, fd int32, addr uintptr, len1 uintptr, flg int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v flg=%v, (%v:)", tls, fd, addr, len1, flg, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var ret, v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _, _ = r, ret, v1, v2, v3, v4, v5, v6, v7, v8 + if !(flg != 0) { + return Xaccept(tls, fd, addr, len1) + } + v1 = int32(SYS_accept4) + _ = int32(__SC_accept4) + v2 = int64(fd) + v3 = int64(addr) + v4 = int64(len1) + v5 = int64(flg) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + ret = int32(X__syscall_ret(tls, Uint64FromInt64(v8))) + if ret >= 0 || **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(ENOSYS) && **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(EINVAL) { + return ret + } + if flg & ^(Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + ret = Xaccept(tls, fd, addr, len1) + if ret < 0 { + return ret + } + if flg&int32(SOCK_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if flg&int32(SOCK_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + return ret +} + +func Xbind(tls *TLS, fd int32, addr uintptr, len1 Tsocklen_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_bind) + _ = int32(__SC_bind) + v2 = int64(fd) + v3 = int64(addr) + v4 = Int64FromUint32(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func Xconnect(tls *TLS, fd int32, addr uintptr, len1 Tsocklen_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_connect) + _ = int32(__SC_connect) + v2 = int64(fd) + v3 = int64(addr) + v4 = Int64FromUint32(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +const ADD = 0 +const C_ANY = 0 +const C_CHAOS = 0 +const C_HS = 0 +const C_IN = 0 +const C_NONE = 0 +const DELETE = 0 +const FORMERR = 0 +const GETLONG = 0 +const GETSHORT = 0 +const HFIXEDSZ = 12 +const IN6ADDRSZ = 16 +const INADDRSZ = 4 +const INDIR_MASK = 192 +const INET6_ADDRSTRLEN = 46 +const INET_ADDRSTRLEN = 16 +const INT16SZ = 2 +const INT32SZ = 4 +const INT8SZ = 1 +const IN_CLASSA_HOST = 16777215 +const IN_CLASSA_MAX = 128 +const IN_CLASSA_NET = 4278190080 +const IN_CLASSA_NSHIFT = 24 +const IN_CLASSB_HOST = 65535 +const IN_CLASSB_MAX = 65536 +const IN_CLASSB_NET = 4294901760 +const IN_CLASSB_NSHIFT = 16 +const IN_CLASSC_HOST = 255 +const IN_CLASSC_NET = 4294967040 +const IN_CLASSC_NSHIFT = 8 +const IN_LOOPBACKNET = 127 +const IPPORT_RESERVED = 1024 +const IPPROTO_AH = 51 +const IPPROTO_BEETPH = 94 +const IPPROTO_COMP = 108 +const IPPROTO_DCCP = 33 +const IPPROTO_DSTOPTS = 60 +const IPPROTO_EGP = 8 +const IPPROTO_ENCAP = 98 +const IPPROTO_ESP = 50 +const IPPROTO_ETHERNET = 143 +const IPPROTO_FRAGMENT = 44 +const IPPROTO_GRE = 47 +const IPPROTO_HOPOPTS = 0 +const IPPROTO_ICMP = 1 +const IPPROTO_ICMPV6 = 58 +const IPPROTO_IDP = 22 +const IPPROTO_IGMP = 2 +const IPPROTO_IP = 0 +const IPPROTO_IPIP = 4 +const IPPROTO_IPV6 = 41 +const IPPROTO_MAX = 263 +const IPPROTO_MH = 135 +const IPPROTO_MPLS = 137 +const IPPROTO_MPTCP = 262 +const IPPROTO_MTP = 92 +const IPPROTO_NONE = 59 +const IPPROTO_PIM = 103 +const IPPROTO_PUP = 12 +const IPPROTO_RAW = 255 +const IPPROTO_ROUTING = 43 +const IPPROTO_RSVP = 46 +const IPPROTO_SCTP = 132 +const IPPROTO_TCP = 6 +const IPPROTO_TP = 29 +const IPPROTO_UDP = 17 +const IPPROTO_UDPLITE = 136 +const IPV6_2292DSTOPTS = 4 +const IPV6_2292HOPLIMIT = 8 +const IPV6_2292HOPOPTS = 3 +const IPV6_2292PKTINFO = 2 +const IPV6_2292PKTOPTIONS = 6 +const IPV6_2292RTHDR = 5 +const IPV6_ADDRFORM = 1 +const IPV6_ADDR_PREFERENCES = 72 +const IPV6_ADD_MEMBERSHIP = 20 +const IPV6_AUTHHDR = 10 +const IPV6_AUTOFLOWLABEL = 70 +const IPV6_CHECKSUM = 7 +const IPV6_DONTFRAG = 62 +const IPV6_DROP_MEMBERSHIP = 21 +const IPV6_DSTOPTS = 59 +const IPV6_FREEBIND = 78 +const IPV6_HDRINCL = 36 +const IPV6_HOPLIMIT = 52 +const IPV6_HOPOPTS = 54 +const IPV6_IPSEC_POLICY = 34 +const IPV6_JOIN_ANYCAST = 27 +const IPV6_JOIN_GROUP = 20 +const IPV6_LEAVE_ANYCAST = 28 +const IPV6_LEAVE_GROUP = 21 +const IPV6_MINHOPCOUNT = 73 +const IPV6_MTU = 24 +const IPV6_MTU_DISCOVER = 23 +const IPV6_MULTICAST_ALL = 29 +const IPV6_MULTICAST_HOPS = 18 +const IPV6_MULTICAST_IF = 17 +const IPV6_MULTICAST_LOOP = 19 +const IPV6_NEXTHOP = 9 +const IPV6_ORIGDSTADDR = 74 +const IPV6_PATHMTU = 61 +const IPV6_PKTINFO = 50 +const IPV6_PMTUDISC_DO = 2 +const IPV6_PMTUDISC_DONT = 0 +const IPV6_PMTUDISC_INTERFACE = 4 +const IPV6_PMTUDISC_OMIT = 5 +const IPV6_PMTUDISC_PROBE = 3 +const IPV6_PMTUDISC_WANT = 1 +const IPV6_PREFER_SRC_CGA = 8 +const IPV6_PREFER_SRC_COA = 4 +const IPV6_PREFER_SRC_HOME = 1024 +const IPV6_PREFER_SRC_NONCGA = 2048 +const IPV6_PREFER_SRC_PUBLIC = 2 +const IPV6_PREFER_SRC_PUBTMP_DEFAULT = 256 +const IPV6_PREFER_SRC_TMP = 1 +const IPV6_RECVDSTOPTS = 58 +const IPV6_RECVERR = 25 +const IPV6_RECVFRAGSIZE = 77 +const IPV6_RECVHOPLIMIT = 51 +const IPV6_RECVHOPOPTS = 53 +const IPV6_RECVORIGDSTADDR = 74 +const IPV6_RECVPATHMTU = 60 +const IPV6_RECVPKTINFO = 49 +const IPV6_RECVRTHDR = 56 +const IPV6_RECVTCLASS = 66 +const IPV6_ROUTER_ALERT = 22 +const IPV6_ROUTER_ALERT_ISOLATE = 30 +const IPV6_RTHDR = 57 +const IPV6_RTHDRDSTOPTS = 55 +const IPV6_RTHDR_LOOSE = 0 +const IPV6_RTHDR_STRICT = 1 +const IPV6_RTHDR_TYPE_0 = 0 +const IPV6_RXDSTOPTS = 59 +const IPV6_RXHOPOPTS = 54 +const IPV6_TCLASS = 67 +const IPV6_TRANSPARENT = 75 +const IPV6_UNICAST_HOPS = 16 +const IPV6_UNICAST_IF = 76 +const IPV6_V6ONLY = 26 +const IPV6_XFRM_POLICY = 35 +const IP_ADD_MEMBERSHIP = 35 +const IP_ADD_SOURCE_MEMBERSHIP = 39 +const IP_BIND_ADDRESS_NO_PORT = 24 +const IP_BLOCK_SOURCE = 38 +const IP_CHECKSUM = 23 +const IP_DEFAULT_MULTICAST_LOOP = 1 +const IP_DEFAULT_MULTICAST_TTL = 1 +const IP_DROP_MEMBERSHIP = 36 +const IP_DROP_SOURCE_MEMBERSHIP = 40 +const IP_FREEBIND = 15 +const IP_HDRINCL = 3 +const IP_IPSEC_POLICY = 16 +const IP_MAX_MEMBERSHIPS = 20 +const IP_MINTTL = 21 +const IP_MSFILTER = 41 +const IP_MTU = 14 +const IP_MTU_DISCOVER = 10 +const IP_MULTICAST_ALL = 49 +const IP_MULTICAST_IF = 32 +const IP_MULTICAST_LOOP = 34 +const IP_MULTICAST_TTL = 33 +const IP_NODEFRAG = 22 +const IP_OPTIONS = 4 +const IP_ORIGDSTADDR = 20 +const IP_PASSSEC = 18 +const IP_PKTINFO = 8 +const IP_PKTOPTIONS = 9 +const IP_PMTUDISC = 10 +const IP_PMTUDISC_DO = 2 +const IP_PMTUDISC_DONT = 0 +const IP_PMTUDISC_INTERFACE = 4 +const IP_PMTUDISC_OMIT = 5 +const IP_PMTUDISC_PROBE = 3 +const IP_PMTUDISC_WANT = 1 +const IP_RECVERR = 11 +const IP_RECVERR_RFC4884 = 26 +const IP_RECVFRAGSIZE = 25 +const IP_RECVOPTS = 6 +const IP_RECVORIGDSTADDR = 20 +const IP_RECVRETOPTS = 7 +const IP_RECVTOS = 13 +const IP_RECVTTL = 12 +const IP_RETOPTS = 7 +const IP_ROUTER_ALERT = 5 +const IP_TOS = 1 +const IP_TRANSPARENT = 19 +const IP_TTL = 2 +const IP_UNBLOCK_SOURCE = 37 +const IP_UNICAST_IF = 50 +const IP_XFRM_POLICY = 17 +const IQUERY = 0 +const LOCALDOMAINPARTS = 2 +const MAXCDNAME = 255 +const MAXDFLSRCH = 3 +const MAXDNAME = 1025 +const MAXDNSRCH = 6 +const MAXLABEL = 63 +const MAXNS = 3 +const MAXRESOLVSORT = 10 +const NAMESERVER_PORT = 53 +const NOERROR = 0 +const NOTAUTH = 0 +const NOTIMP = 0 +const NOTZONE = 0 +const NS_ALG_DH = 2 +const NS_ALG_DSA = 3 +const NS_ALG_DSS = 3 +const NS_ALG_EXPIRE_ONLY = 253 +const NS_ALG_MD5RSA = 1 +const NS_ALG_PRIVATE_OID = 254 +const NS_CMPRSFLGS = 192 +const NS_DEFAULTPORT = 53 +const NS_DSA_MAX_BYTES = 405 +const NS_DSA_MIN_SIZE = 213 +const NS_DSA_SIG_SIZE = 41 +const NS_HFIXEDSZ = 12 +const NS_IN6ADDRSZ = 16 +const NS_INADDRSZ = 4 +const NS_INT16SZ = 2 +const NS_INT32SZ = 4 +const NS_INT8SZ = 1 +const NS_KEY_EXTENDED_FLAGS = 4096 +const NS_KEY_NAME_ENTITY = 512 +const NS_KEY_NAME_RESERVED = 768 +const NS_KEY_NAME_TYPE = 768 +const NS_KEY_NAME_USER = 0 +const NS_KEY_NAME_ZONE = 256 +const NS_KEY_NO_AUTH = 32768 +const NS_KEY_NO_CONF = 16384 +const NS_KEY_PROT_ANY = 255 +const NS_KEY_PROT_DNSSEC = 3 +const NS_KEY_PROT_EMAIL = 2 +const NS_KEY_PROT_IPSEC = 4 +const NS_KEY_PROT_TLS = 1 +const NS_KEY_RESERVED10 = 32 +const NS_KEY_RESERVED11 = 16 +const NS_KEY_RESERVED2 = 8192 +const NS_KEY_RESERVED4 = 2048 +const NS_KEY_RESERVED5 = 1024 +const NS_KEY_RESERVED8 = 128 +const NS_KEY_RESERVED9 = 64 +const NS_KEY_RESERVED_BITMASK = 11504 +const NS_KEY_RESERVED_BITMASK2 = 65535 +const NS_KEY_SIGNATORYMASK = 15 +const NS_KEY_TYPEMASK = 49152 +const NS_KEY_TYPE_AUTH_CONF = 0 +const NS_KEY_TYPE_AUTH_ONLY = 16384 +const NS_KEY_TYPE_CONF_ONLY = 32768 +const NS_KEY_TYPE_NO_KEY = 49152 +const NS_MAXCDNAME = 255 +const NS_MAXDNAME = 1025 +const NS_MAXLABEL = 63 +const NS_MAXMSG = 65535 +const NS_MD5RSA_MAX_BASE64 = 10928 +const NS_MD5RSA_MAX_BITS = 4096 +const NS_MD5RSA_MAX_BYTES = 8195 +const NS_MD5RSA_MAX_SIZE = 512 +const NS_MD5RSA_MIN_BITS = 512 +const NS_MD5RSA_MIN_SIZE = 64 +const NS_NOTIFY_OP = 0 +const NS_NXT_BITS = 8 +const NS_NXT_MAX = 127 +const NS_OPT_DNSSEC_OK = 32768 +const NS_OPT_NSID = 3 +const NS_PACKETSZ = 512 +const NS_QFIXEDSZ = 4 +const NS_RRFIXEDSZ = 10 +const NS_SIG_ALG = 2 +const NS_SIG_EXPIR = 8 +const NS_SIG_FOOT = 16 +const NS_SIG_LABELS = 3 +const NS_SIG_OTTL = 4 +const NS_SIG_SIGNED = 12 +const NS_SIG_SIGNER = 18 +const NS_SIG_TYPE = 0 +const NS_TSIG_ALG_HMAC_MD5 = "HMAC-MD5.SIG-ALG.REG.INT" +const NS_TSIG_ERROR_FORMERR = -12 +const NS_TSIG_ERROR_NO_SPACE = -11 +const NS_TSIG_ERROR_NO_TSIG = -10 +const NS_TSIG_FUDGE = 300 +const NS_TSIG_TCP_COUNT = 100 +const NS_UPDATE_OP = 0 +const NXDOMAIN = 0 +const NXRRSET = 0 +const PACKETSZ = 512 +const PRIX16 = "X" +const PRIX32 = "X" +const PRIX8 = "X" +const PRIXFAST16 = "X" +const PRIXFAST32 = "X" +const PRIXFAST8 = "X" +const PRIXLEAST16 = "X" +const PRIXLEAST32 = "X" +const PRIXLEAST8 = "X" +const PRId16 = "d" +const PRId32 = "d" +const PRId8 = "d" +const PRIdFAST16 = "d" +const PRIdFAST32 = "d" +const PRIdFAST8 = "d" +const PRIdLEAST16 = "d" +const PRIdLEAST32 = "d" +const PRIdLEAST8 = "d" +const PRIi16 = "i" +const PRIi32 = "i" +const PRIi8 = "i" +const PRIiFAST16 = "i" +const PRIiFAST32 = "i" +const PRIiFAST8 = "i" +const PRIiLEAST16 = "i" +const PRIiLEAST32 = "i" +const PRIiLEAST8 = "i" +const PRIo16 = "o" +const PRIo32 = "o" +const PRIo8 = "o" +const PRIoFAST16 = "o" +const PRIoFAST32 = "o" +const PRIoFAST8 = "o" +const PRIoLEAST16 = "o" +const PRIoLEAST32 = "o" +const PRIoLEAST8 = "o" +const PRIu16 = "u" +const PRIu32 = "u" +const PRIu8 = "u" +const PRIuFAST16 = "u" +const PRIuFAST32 = "u" +const PRIuFAST8 = "u" +const PRIuLEAST16 = "u" +const PRIuLEAST32 = "u" +const PRIuLEAST8 = "u" +const PRIx16 = "x" +const PRIx32 = "x" +const PRIx8 = "x" +const PRIxFAST16 = "x" +const PRIxFAST32 = "x" +const PRIxFAST8 = "x" +const PRIxLEAST16 = "x" +const PRIxLEAST32 = "x" +const PRIxLEAST8 = "x" +const PUTLONG = 0 +const PUTSHORT = 0 +const QFIXEDSZ = 4 +const QUERY = 0 +const REFUSED = 0 +const RES_AAONLY = 4 +const RES_BLAST = 131072 +const RES_DEBUG = 2 +const RES_DEFAULT = 524992 +const RES_DEFNAMES = 128 +const RES_DFLRETRY = 2 +const RES_DNSRCH = 512 +const RES_EXHAUSTIVE = 1 +const RES_F_CONN = 2 +const RES_F_EDNS0ERR = 4 +const RES_F_VC = 1 +const RES_IGNTC = 32 +const RES_INIT = 1 +const RES_INSECURE1 = 1024 +const RES_INSECURE2 = 2048 +const RES_KEEPTSIG = 65536 +const RES_MAXNDOTS = 15 +const RES_MAXRETRANS = 30 +const RES_MAXRETRY = 5 +const RES_MAXTIME = 65535 +const RES_NOALIASES = 4096 +const RES_NOCHECKNAME = 32768 +const RES_NOIP6DOTINT = 524288 +const RES_PRF_ADD = 128 +const RES_PRF_ANS = 32 +const RES_PRF_AUTH = 64 +const RES_PRF_CLASS = 4 +const RES_PRF_CMD = 8 +const RES_PRF_HEAD1 = 256 +const RES_PRF_HEAD2 = 512 +const RES_PRF_HEADX = 2048 +const RES_PRF_INIT = 16384 +const RES_PRF_QUERY = 4096 +const RES_PRF_QUES = 16 +const RES_PRF_REPLY = 8192 +const RES_PRF_STATS = 1 +const RES_PRF_TTLID = 1024 +const RES_PRF_UPDATE = 2 +const RES_PRIMARY = 16 +const RES_RECURSE = 64 +const RES_ROTATE = 16384 +const RES_SNGLKUP = 2097152 +const RES_SNGLKUPREOP = 4194304 +const RES_STAYOPEN = 256 +const RES_TIMEOUT = 5 +const RES_USEBSTRING = 262144 +const RES_USEVC = 8 +const RES_USE_DNSSEC = 8388608 +const RES_USE_EDNS0 = 1048576 +const RES_USE_INET6 = 8192 +const RRFIXEDSZ = 10 +const SCNd16 = "hd" +const SCNd32 = "d" +const SCNd8 = "hhd" +const SCNdFAST16 = "d" +const SCNdFAST32 = "d" +const SCNdFAST8 = "hhd" +const SCNdLEAST16 = "hd" +const SCNdLEAST32 = "d" +const SCNdLEAST8 = "hhd" +const SCNi16 = "hi" +const SCNi32 = "i" +const SCNi8 = "hhi" +const SCNiFAST16 = "i" +const SCNiFAST32 = "i" +const SCNiFAST8 = "hhi" +const SCNiLEAST16 = "hi" +const SCNiLEAST32 = "i" +const SCNiLEAST8 = "hhi" +const SCNo16 = "ho" +const SCNo32 = "o" +const SCNo8 = "hho" +const SCNoFAST16 = "o" +const SCNoFAST32 = "o" +const SCNoFAST8 = "hho" +const SCNoLEAST16 = "ho" +const SCNoLEAST32 = "o" +const SCNoLEAST8 = "hho" +const SCNu16 = "hu" +const SCNu32 = "u" +const SCNu8 = "hhu" +const SCNuFAST16 = "u" +const SCNuFAST32 = "u" +const SCNuFAST8 = "hhu" +const SCNuLEAST16 = "hu" +const SCNuLEAST32 = "u" +const SCNuLEAST8 = "hhu" +const SCNx16 = "hx" +const SCNx32 = "x" +const SCNx8 = "hhx" +const SCNxFAST16 = "x" +const SCNxFAST32 = "x" +const SCNxFAST8 = "hhx" +const SCNxLEAST16 = "hx" +const SCNxLEAST32 = "x" +const SCNxLEAST8 = "hhx" +const SERVFAIL = 0 +const STATUS = 0 +const S_ADDT = 0 +const S_PREREQ = 0 +const S_UPDATE = 0 +const S_ZONE = 0 +const T_A = 0 +const T_A6 = 0 +const T_AAAA = 0 +const T_AFSDB = 0 +const T_ANY = 0 +const T_ATMA = 0 +const T_AVC = 0 +const T_AXFR = 0 +const T_CAA = 0 +const T_CDNSKEY = 0 +const T_CDS = 0 +const T_CNAME = 0 +const T_CSYNC = 0 +const T_DHCID = 0 +const T_DLV = 0 +const T_DNAME = 0 +const T_DNSKEY = 0 +const T_DS = 0 +const T_EID = 0 +const T_EUI48 = 0 +const T_EUI64 = 0 +const T_GID = 0 +const T_GPOS = 0 +const T_HINFO = 0 +const T_HIP = 0 +const T_IPSECKEY = 0 +const T_ISDN = 0 +const T_IXFR = 0 +const T_KEY = 0 +const T_L32 = 0 +const T_L64 = 0 +const T_LOC = 0 +const T_LP = 0 +const T_MAILA = 0 +const T_MAILB = 0 +const T_MB = 0 +const T_MD = 0 +const T_MF = 0 +const T_MG = 0 +const T_MINFO = 0 +const T_MR = 0 +const T_MX = 0 +const T_NAPTR = 0 +const T_NID = 0 +const T_NIMLOC = 0 +const T_NINFO = 0 +const T_NS = 0 +const T_NSAP = 0 +const T_NSAP_PTR = 0 +const T_NSEC = 0 +const T_NSEC3 = 0 +const T_NSEC3PARAM = 0 +const T_NULL = 0 +const T_NXT = 0 +const T_OPENPGPKEY = 0 +const T_PTR = 0 +const T_PX = 0 +const T_RKEY = 0 +const T_RP = 0 +const T_RRSIG = 0 +const T_RT = 0 +const T_SIG = 0 +const T_SMIMEA = 0 +const T_SOA = 0 +const T_SPF = 0 +const T_SRV = 0 +const T_SSHFP = 0 +const T_TA = 0 +const T_TALINK = 0 +const T_TKEY = 0 +const T_TLSA = 0 +const T_TSIG = 0 +const T_TXT = 0 +const T_UID = 0 +const T_UINFO = 0 +const T_UNSPEC = 0 +const T_URI = 0 +const T_WKS = 0 +const T_X25 = 0 +const YXDOMAIN = 0 +const YXRRSET = 0 +const _PATH_RESCONF = "/etc/resolv.conf" +const __BIND = 19950621 +const __NAMESER = 19991006 +const __PRI64 = "l" +const __PRIPTR = "l" +const __RES = 19960801 +const __UAPI_DEF_IN6_ADDR = 0 +const __UAPI_DEF_IN6_ADDR_ALT = 0 +const __UAPI_DEF_IN6_PKTINFO = 0 +const __UAPI_DEF_IN_ADDR = 0 +const __UAPI_DEF_IN_CLASS = 0 +const __UAPI_DEF_IN_IPPROTO = 0 +const __UAPI_DEF_IN_PKTINFO = 0 +const __UAPI_DEF_IP6_MTUINFO = 0 +const __UAPI_DEF_IPPROTO_V6 = 0 +const __UAPI_DEF_IPV6_MREQ = 0 +const __UAPI_DEF_IPV6_OPTIONS = 0 +const __UAPI_DEF_IP_MREQ = 0 +const __UAPI_DEF_SOCKADDR_IN = 0 +const __UAPI_DEF_SOCKADDR_IN6 = 0 +const _res = 0 + +type Tns_sect = int32 + +type ___ns_sect = int32 + +const _ns_s_qd = 0 +const _ns_s_zn = 0 +const _ns_s_an = 1 +const _ns_s_pr = 1 +const _ns_s_ns = 2 +const _ns_s_ud = 2 +const _ns_s_ar = 3 +const _ns_s_max = 4 + +type Tns_msg = struct { + F_msg uintptr + F_eom uintptr + F_id Tuint16_t + F_flags Tuint16_t + F_counts [4]Tuint16_t + F_sections [4]uintptr + F_sect Tns_sect + F_rrnum int32 + F_msg_ptr uintptr +} + +type t__ns_msg = Tns_msg + +type T_ns_flagdata = struct { + Fmask int32 + Fshift int32 +} + +type Tns_rr = struct { + Fname [1025]int8 + Ftype1 Tuint16_t + Frr_class Tuint16_t + Fttl Tuint32_t + Frdlength Tuint16_t + Frdata uintptr +} + +type t__ns_rr = Tns_rr + +type Tns_flag = int32 + +type ___ns_flag = int32 + +const _ns_f_qr = 0 +const _ns_f_opcode = 1 +const _ns_f_aa = 2 +const _ns_f_tc = 3 +const _ns_f_rd = 4 +const _ns_f_ra = 5 +const _ns_f_z = 6 +const _ns_f_ad = 7 +const _ns_f_cd = 8 +const _ns_f_rcode = 9 +const _ns_f_max = 10 + +type Tns_opcode = int32 + +type ___ns_opcode = int32 + +const _ns_o_query = 0 +const _ns_o_iquery = 1 +const _ns_o_status = 2 +const _ns_o_notify = 4 +const _ns_o_update = 5 +const _ns_o_max = 6 + +type Tns_rcode = int32 + +type ___ns_rcode = int32 + +const _ns_r_noerror = 0 +const _ns_r_formerr = 1 +const _ns_r_servfail = 2 +const _ns_r_nxdomain = 3 +const _ns_r_notimpl = 4 +const _ns_r_refused = 5 +const _ns_r_yxdomain = 6 +const _ns_r_yxrrset = 7 +const _ns_r_nxrrset = 8 +const _ns_r_notauth = 9 +const _ns_r_notzone = 10 +const _ns_r_max = 11 +const _ns_r_badvers = 16 +const _ns_r_badsig = 16 +const _ns_r_badkey = 17 +const _ns_r_badtime = 18 + +type Tns_update_operation = int32 + +type ___ns_update_operation = int32 + +const _ns_uop_delete = 0 +const _ns_uop_add = 1 +const _ns_uop_max = 2 + +type Tns_tsig_key = struct { + Fname [1025]int8 + Falg [1025]int8 + Fdata uintptr + Flen1 int32 +} + +type Tns_tcp_tsig_state = struct { + Fcounter int32 + Fkey uintptr + Fctx uintptr + Fsig [512]uint8 + Fsiglen int32 +} + +type Tns_type = int32 + +type ___ns_type = int32 + +const _ns_t_invalid = 0 +const _ns_t_a = 1 +const _ns_t_ns = 2 +const _ns_t_md = 3 +const _ns_t_mf = 4 +const _ns_t_cname = 5 +const _ns_t_soa = 6 +const _ns_t_mb = 7 +const _ns_t_mg = 8 +const _ns_t_mr = 9 +const _ns_t_null = 10 +const _ns_t_wks = 11 +const _ns_t_ptr = 12 +const _ns_t_hinfo = 13 +const _ns_t_minfo = 14 +const _ns_t_mx = 15 +const _ns_t_txt = 16 +const _ns_t_rp = 17 +const _ns_t_afsdb = 18 +const _ns_t_x25 = 19 +const _ns_t_isdn = 20 +const _ns_t_rt = 21 +const _ns_t_nsap = 22 +const _ns_t_nsap_ptr = 23 +const _ns_t_sig = 24 +const _ns_t_key = 25 +const _ns_t_px = 26 +const _ns_t_gpos = 27 +const _ns_t_aaaa = 28 +const _ns_t_loc = 29 +const _ns_t_nxt = 30 +const _ns_t_eid = 31 +const _ns_t_nimloc = 32 +const _ns_t_srv = 33 +const _ns_t_atma = 34 +const _ns_t_naptr = 35 +const _ns_t_kx = 36 +const _ns_t_cert = 37 +const _ns_t_a6 = 38 +const _ns_t_dname = 39 +const _ns_t_sink = 40 +const _ns_t_opt = 41 +const _ns_t_apl = 42 +const _ns_t_ds = 43 +const _ns_t_sshfp = 44 +const _ns_t_ipseckey = 45 +const _ns_t_rrsig = 46 +const _ns_t_nsec = 47 +const _ns_t_dnskey = 48 +const _ns_t_dhcid = 49 +const _ns_t_nsec3 = 50 +const _ns_t_nsec3param = 51 +const _ns_t_tlsa = 52 +const _ns_t_smimea = 53 +const _ns_t_hip = 55 +const _ns_t_ninfo = 56 +const _ns_t_rkey = 57 +const _ns_t_talink = 58 +const _ns_t_cds = 59 +const _ns_t_cdnskey = 60 +const _ns_t_openpgpkey = 61 +const _ns_t_csync = 62 +const _ns_t_spf = 99 +const _ns_t_uinfo = 100 +const _ns_t_uid = 101 +const _ns_t_gid = 102 +const _ns_t_unspec = 103 +const _ns_t_nid = 104 +const _ns_t_l32 = 105 +const _ns_t_l64 = 106 +const _ns_t_lp = 107 +const _ns_t_eui48 = 108 +const _ns_t_eui64 = 109 +const _ns_t_tkey = 249 +const _ns_t_tsig = 250 +const _ns_t_ixfr = 251 +const _ns_t_axfr = 252 +const _ns_t_mailb = 253 +const _ns_t_maila = 254 +const _ns_t_any = 255 +const _ns_t_zxfr = 256 +const _ns_t_uri = 256 +const _ns_t_caa = 257 +const _ns_t_avc = 258 +const _ns_t_ta = 32768 +const _ns_t_dlv = 32769 +const _ns_t_max = 65536 + +type Tns_class = int32 + +type ___ns_class = int32 + +const _ns_c_invalid = 0 +const _ns_c_in = 1 +const _ns_c_2 = 2 +const _ns_c_chaos = 3 +const _ns_c_hs = 4 +const _ns_c_none = 254 +const _ns_c_any = 255 +const _ns_c_max = 65536 + +type Tns_key_types = int32 + +type ___ns_key_types = int32 + +const _ns_kt_rsa = 1 +const _ns_kt_dh = 2 +const _ns_kt_dsa = 3 +const _ns_kt_private = 254 + +type Tns_cert_types = int32 + +type ___ns_cert_types = int32 + +const _cert_t_pkix = 1 +const _cert_t_spki = 2 +const _cert_t_pgp = 3 +const _cert_t_url = 253 +const _cert_t_oid = 254 + +type THEADER = struct { + F__ccgo0 uint32 + F__ccgo4 uint32 + F__ccgo8 uint32 +} + +type Timaxdiv_t = struct { + Fquot Tintmax_t + Frem Tintmax_t +} + +type Tin_port_t = uint16 + +type Tin_addr_t = uint32 + +type Tin_addr = struct { + Fs_addr Tin_addr_t +} + +type Tsockaddr_in = struct { + Fsin_family Tsa_family_t + Fsin_port Tin_port_t + Fsin_addr Tin_addr + Fsin_zero [8]Tuint8_t +} + +type Tin6_addr = struct { + F__in6_union struct { + F__s6_addr16 [0][8]Tuint16_t + F__s6_addr32 [0][4]Tuint32_t + F__s6_addr [16]Tuint8_t + } +} + +type Tsockaddr_in6 = struct { + Fsin6_family Tsa_family_t + Fsin6_port Tin_port_t + Fsin6_flowinfo Tuint32_t + Fsin6_addr Tin6_addr + Fsin6_scope_id Tuint32_t +} + +type Tipv6_mreq = struct { + Fipv6mr_multiaddr Tin6_addr + Fipv6mr_interface uint32 +} + +type Tip_opts = struct { + Fip_dst Tin_addr + Fip_opts [40]int8 +} + +type Tres_state = uintptr + +type t__res_state = struct { + Fretrans int32 + Fretry int32 + Foptions uint64 + Fnscount int32 + Fnsaddr_list [3]Tsockaddr_in + Fid uint16 + Fdnsrch [7]uintptr + Fdefdname [256]int8 + Fpfcode uint64 + F__ccgo392 uint32 + Fsort_list [10]struct { + Faddr Tin_addr + Fmask Tuint32_t + } + Fqhook uintptr + Frhook uintptr + Fres_h_errno int32 + F_vcsock int32 + F_flags uint32 + F_u struct { + F_ext [0]struct { + Fnscount Tuint16_t + Fnsmap [3]Tuint16_t + Fnssocks [3]int32 + Fnscount6 Tuint16_t + Fnsinit Tuint16_t + Fnsaddrs [3]uintptr + F_initstamp [2]uint32 + } + Fpad [52]int8 + F__ccgo_pad2 [4]byte + } +} + +type Tres_sym = struct { + Fnumber int32 + Fname uintptr + Fhumanname uintptr +} + +/* RFC 1035 message compression */ + +// C documentation +// +// /* label start offsets of a compressed domain name s */ +func _getoffs(tls *TLS, offs uintptr, base uintptr, s uintptr) (r int32) { + var i, v2 int32 + _, _ = i, v2 + i = 0 + for { + for Int32FromUint8(**(**uint8)(__ccgo_up(s)))&int32(0xc0) != 0 { + if Int32FromUint8(**(**uint8)(__ccgo_up(s)))&int32(0xc0) != int32(0xc0) { + return 0 + } + s = base + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(s)))&Int32FromInt32(0x3f)<= int64(0x4000) { + return 0 + } + v2 = i + i = i + 1 + **(**int16)(__ccgo_up(offs + uintptr(v2)*2)) = int16(int64(s) - int64(base)) + s = s + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(s)))+int32(1)) + goto _1 + _1: + } + return r +} + +// C documentation +// +// /* label lengths of an ascii domain name s */ +func _getlens(tls *TLS, lens uintptr, s uintptr, l int32) (r int32) { + var i, j, k, v3 int32 + _, _, _, _ = i, j, k, v3 + i = 0 + j = 0 + k = 0 + for { + for { + if !(j < l && int32(**(**int8)(__ccgo_up(s + uintptr(j)))) != int32('.')) { + break + } + goto _2 + _2: + ; + j = j + 1 + } + if Uint32FromInt32(j-k)-uint32(1) > uint32(62) { + return 0 + } + v3 = i + i = i + 1 + **(**uint8)(__ccgo_up(lens + uintptr(v3))) = Uint8FromInt32(j - k) + if j == l { + return i + } + j = j + 1 + v3 = j + k = v3 + goto _1 + _1: + } + return r +} + +// C documentation +// +// /* longest suffix match of an ascii domain with a compressed domain name dn */ +func _match(tls *TLS, offset uintptr, base uintptr, dn uintptr, end uintptr, lens uintptr, nlen int32) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var l, m, noff, o, v2 int32 + var _ /* offs at bp+0 */ [128]int16 + _, _, _, _, _ = l, m, noff, o, v2 + m = 0 + noff = _getoffs(tls, bp, base, dn) + if !(noff != 0) { + return 0 + } + for { + nlen = nlen - 1 + v2 = nlen + l = Int32FromUint8(**(**uint8)(__ccgo_up(lens + uintptr(v2)))) + noff = noff - 1 + v2 = noff + o = int32((**(**[128]int16)(__ccgo_up(bp)))[v2]) + end = end - uintptr(l) + if l != Int32FromUint8(**(**uint8)(__ccgo_up(base + uintptr(o)))) || Xmemcmp(tls, base+uintptr(o)+uintptr(1), end, Uint64FromInt32(l)) != 0 { + return m + } + **(**int32)(__ccgo_up(offset)) = o + m = m + l + if nlen != 0 { + m = m + 1 + } + if !(nlen != 0) || !(noff != 0) { + return m + } + end = end - 1 + goto _1 + _1: + } + return r +} + +func Xdn_comp(tls *TLS, src uintptr, dst uintptr, space int32, dnptrs uintptr, lastdnptr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v src=%v dst=%v space=%v dnptrs=%v lastdnptr=%v, (%v:)", tls, src, dst, space, dnptrs, lastdnptr, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var bestlen, bestoff, i, j, m, n, v3 int32 + var end, p, v8 uintptr + var l Tsize_t + var _ /* lens at bp+4 */ [127]uint8 + var _ /* offset at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = bestlen, bestoff, end, i, j, l, m, n, p, v3, v8 + m = 0 + bestlen = 0 + l = Xstrnlen(tls, src, uint64(255)) + if l != 0 && int32(**(**int8)(__ccgo_up(src + uintptr(l-uint64(1))))) == int32('.') { + l = l - 1 + } + if l > uint64(253) || space <= 0 { + return -int32(1) + } + if !(l != 0) { + **(**uint8)(__ccgo_up(dst)) = uint8(0) + return int32(1) + } + end = src + uintptr(l) + n = _getlens(tls, bp+4, src, Int32FromUint64(l)) + if !(n != 0) { + return -int32(1) + } + p = dnptrs + if p != 0 && **(**uintptr)(__ccgo_up(p)) != 0 { + p += 8 + for { + if !(**(**uintptr)(__ccgo_up(p)) != 0) { + break + } + m = _match(tls, bp, **(**uintptr)(__ccgo_up(dnptrs)), **(**uintptr)(__ccgo_up(p)), end, bp+4, n) + if m > bestlen { + bestlen = m + bestoff = **(**int32)(__ccgo_up(bp)) + if Uint64FromInt32(m) == l { + break + } + } + goto _1 + _1: + ; + p += 8 + } + } + /* encode unmatched part */ + if Uint64FromInt32(space) < l-Uint64FromInt32(bestlen)+uint64(2)+BoolUint64(Uint64FromInt32(bestlen-Int32FromInt32(1)) < l-Uint64FromInt32(1)) { + return -int32(1) + } + Xmemcpy(tls, dst+uintptr(1), src, l-Uint64FromInt32(bestlen)) + v3 = Int32FromInt32(0) + j = v3 + i = v3 + for { + if !(Uint64FromInt32(i) < l-Uint64FromInt32(bestlen)) { + break + } + **(**uint8)(__ccgo_up(dst + uintptr(i))) = (**(**[127]uint8)(__ccgo_up(bp + 4)))[j] + goto _2 + _2: + ; + v3 = j + j = j + 1 + i = i + (Int32FromUint8((**(**[127]uint8)(__ccgo_up(bp + 4)))[v3]) + int32(1)) + } + /* add tail */ + if bestlen != 0 { + v3 = i + i = i + 1 + **(**uint8)(__ccgo_up(dst + uintptr(v3))) = Uint8FromInt32(int32(0xc0) | bestoff>>int32(8)) + v3 = i + i = i + 1 + **(**uint8)(__ccgo_up(dst + uintptr(v3))) = Uint8FromInt32(bestoff) + } else { + v3 = i + i = i + 1 + **(**uint8)(__ccgo_up(dst + uintptr(v3))) = uint8(0) + } + /* save dst pointer */ + if i > int32(2) && lastdnptr != 0 && dnptrs != 0 && **(**uintptr)(__ccgo_up(dnptrs)) != 0 { + for **(**uintptr)(__ccgo_up(p)) != 0 { + p += 8 + } + if p+uintptr(1)*8 < lastdnptr { + v8 = p + p += 8 + **(**uintptr)(__ccgo_up(v8)) = dst + **(**uintptr)(__ccgo_up(p)) = uintptr(0) + } + } + return i +} + +func X__dn_expand(tls *TLS, base uintptr, end uintptr, src uintptr, dest uintptr, space int32) (r int32) { + if __ccgo_strace { + trc("tls=%v base=%v end=%v src=%v dest=%v space=%v, (%v:)", tls, base, end, src, dest, space, origin(2)) + defer func() { trc("-> %v", r) }() + } + var dbegin, dend, p, v3, v4 uintptr + var i, j, len1, v1 int32 + _, _, _, _, _, _, _, _, _ = dbegin, dend, i, j, len1, p, v1, v3, v4 + p = src + dbegin = dest + len1 = -int32(1) + if p == end || space <= 0 { + return -int32(1) + } + if space > int32(254) { + v1 = int32(254) + } else { + v1 = space + } + dend = dest + uintptr(v1) + /* detect reference loop using an iteration counter */ + i = 0 + for { + if !(int64(i) < int64(end)-int64(base)) { + break + } + /* loop invariants: p= int64(end)-int64(base) { + return -int32(1) + } + p = base + uintptr(j) + } else { + if **(**uint8)(__ccgo_up(p)) != 0 { + if dest != dbegin { + v3 = dest + dest = dest + 1 + **(**int8)(__ccgo_up(v3)) = int8('.') + } + v3 = p + p = p + 1 + j = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + if int64(j) >= int64(end)-int64(p) || int64(j) >= int64(dend)-int64(dest) { + return -int32(1) + } + for { + v1 = j + j = j - 1 + if !(v1 != 0) { + break + } + v3 = dest + dest = dest + 1 + v4 = p + p = p + 1 + **(**int8)(__ccgo_up(v3)) = Int8FromUint8(**(**uint8)(__ccgo_up(v4))) + } + } else { + **(**int8)(__ccgo_up(dest)) = 0 + if len1 < 0 { + len1 = int32(int64(p+uintptr(1)) - int64(src)) + } + return len1 + } + } + goto _2 + _2: + ; + i = i + int32(2) + } + return -int32(1) +} + +func Xdn_expand(tls *TLS, base uintptr, end uintptr, src uintptr, dest uintptr, space int32) (r int32) { + if __ccgo_strace { + trc("tls=%v base=%v end=%v src=%v dest=%v space=%v, (%v:)", tls, base, end, src, dest, space, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__dn_expand(tls, base, end, src, dest, space) +} + +func Xdn_skipname(tls *TLS, s uintptr, end uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v end=%v, (%v:)", tls, s, end, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + _ = p + p = s + for p < end { + if !(**(**uint8)(__ccgo_up(p)) != 0) { + return int32(int64(p) - int64(s) + int64(1)) + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) >= int32(192) { + if p+uintptr(1) < end { + return int32(int64(p) - int64(s) + int64(2)) + } else { + break + } + } else { + if int64(end)-int64(p) < int64(Int32FromUint8(**(**uint8)(__ccgo_up(p)))+int32(1)) { + break + } else { + p = p + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(p)))+int32(1)) + } + } + } + } + return -int32(1) +} + +const AI_ADDRCONFIG = 32 +const AI_ALL = 16 +const AI_CANONNAME = 2 +const AI_NUMERICHOST = 4 +const AI_NUMERICSERV = 1024 +const AI_PASSIVE = 1 +const AI_V4MAPPED = 8 +const EAI_AGAIN = -3 +const EAI_BADFLAGS = -1 +const EAI_FAIL = -4 +const EAI_FAMILY = -6 +const EAI_MEMORY = -10 +const EAI_NODATA = -5 +const EAI_NONAME = -2 +const EAI_OVERFLOW = -12 +const EAI_SERVICE = -8 +const EAI_SOCKTYPE = -7 +const EAI_SYSTEM = -11 +const MAXADDRS = 48 +const MAXSERVS = 2 +const NI_DGRAM = 16 +const NI_NAMEREQD = 8 +const NI_NOFQDN = 4 +const NI_NUMERICHOST = 1 +const NI_NUMERICSCOPE = 256 +const NI_NUMERICSERV = 2 + +type Taddrinfo = struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen Tsocklen_t + Fai_addr uintptr + Fai_canonname uintptr + Fai_next uintptr +} + +type Tnetent = struct { + Fn_name uintptr + Fn_aliases uintptr + Fn_addrtype int32 + Fn_net Tuint32_t +} + +type Thostent = struct { + Fh_name uintptr + Fh_aliases uintptr + Fh_addrtype int32 + Fh_length int32 + Fh_addr_list uintptr +} + +type Tservent = struct { + Fs_name uintptr + Fs_aliases uintptr + Fs_port int32 + Fs_proto uintptr +} + +type Tprotoent = struct { + Fp_name uintptr + Fp_aliases uintptr + Fp_proto int32 +} + +type Taibuf = struct { + Fai Taddrinfo + Fsa Tsa + Flock [1]int32 + Fslot int16 + Fref int16 +} + +type Taddress = struct { + Ffamily int32 + Fscopeid uint32 + Faddr [16]Tuint8_t + Fsortkey int32 +} + +type Tservice = struct { + Fport Tuint16_t + Fproto uint8 + Fsocktype uint8 +} + +type Tresolvconf = struct { + Fns [3]Taddress + Fnns uint32 + Fattempts uint32 + Fndots uint32 + Ftimeout uint32 +} + +type t__ccgo_fp__X__dns_parse_2 = func(*TLS, uintptr, int32, uintptr, int32, uintptr, int32) int32 + +func X__dns_parse(tls *TLS, r uintptr, rlen int32, __ccgo_fp_callback uintptr, ctx uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v r=%v rlen=%v __ccgo_fp_callback=%v ctx=%v, (%v:)", tls, r, rlen, __ccgo_fp_callback, ctx, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ancount, len1, qdcount, v1 int32 + var p uintptr + _, _, _, _, _ = ancount, len1, p, qdcount, v1 + if rlen < int32(12) { + return -int32(1) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(r + 3)))&int32(15) != 0 { + return 0 + } + p = r + uintptr(12) + qdcount = Int32FromUint8(**(**uint8)(__ccgo_up(r + 4)))*int32(256) + Int32FromUint8(**(**uint8)(__ccgo_up(r + 5))) + ancount = Int32FromUint8(**(**uint8)(__ccgo_up(r + 6)))*int32(256) + Int32FromUint8(**(**uint8)(__ccgo_up(r + 7))) + for { + v1 = qdcount + qdcount = qdcount - 1 + if !(v1 != 0) { + break + } + for int64(p)-int64(r) < int64(rlen) && uint32(**(**uint8)(__ccgo_up(p)))-uint32(1) < uint32(127) { + p = p + 1 + } + if p > r+uintptr(rlen)-uintptr(6) { + return -int32(1) + } + p = p + uintptr(int32(5)+BoolInt32(!!(**(**uint8)(__ccgo_up(p)) != 0))) + } + for { + v1 = ancount + ancount = ancount - 1 + if !(v1 != 0) { + break + } + for int64(p)-int64(r) < int64(rlen) && uint32(**(**uint8)(__ccgo_up(p)))-uint32(1) < uint32(127) { + p = p + 1 + } + if p > r+uintptr(rlen)-uintptr(12) { + return -int32(1) + } + p = p + uintptr(int32(1)+BoolInt32(!!(**(**uint8)(__ccgo_up(p)) != 0))) + len1 = Int32FromUint8(**(**uint8)(__ccgo_up(p + 8)))*int32(256) + Int32FromUint8(**(**uint8)(__ccgo_up(p + 9))) + if int64(len1+int32(10)) > int64(r+uintptr(rlen))-int64(p) { + return -int32(1) + } + if (*(*func(*TLS, uintptr, int32, uintptr, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_callback})))(tls, ctx, Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))), p+uintptr(10), len1, r, rlen) < 0 { + return -int32(1) + } + p = p + uintptr(int32(10)+len1) + } + return 0 +} + +type Tsa = struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte +} + +func Xsethostent(tls *TLS, x int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } +} + +func Xgethostent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xgetnetent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xendhostent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xendnetent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xendhostent(tls) +} + +func Xsetnetent(tls *TLS, x int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + Xsethostent(tls, x) +} + +const ARPD_FLUSH = 3 +const ARPD_LOOKUP = 2 +const ARPD_UPDATE = 1 +const ARPHRD_6LOWPAN = 825 +const ARPHRD_ADAPT = 264 +const ARPHRD_APPLETLK = 8 +const ARPHRD_ARCNET = 7 +const ARPHRD_ASH = 781 +const ARPHRD_ATM = 19 +const ARPHRD_AX25 = 3 +const ARPHRD_BIF = 775 +const ARPHRD_CAIF = 822 +const ARPHRD_CAN = 280 +const ARPHRD_CHAOS = 5 +const ARPHRD_CISCO = 513 +const ARPHRD_CSLIP = 257 +const ARPHRD_CSLIP6 = 259 +const ARPHRD_DDCMP = 517 +const ARPHRD_DLCI = 15 +const ARPHRD_ECONET = 782 +const ARPHRD_EETHER = 2 +const ARPHRD_ETHER = 1 +const ARPHRD_EUI64 = 27 +const ARPHRD_FCAL = 785 +const ARPHRD_FCFABRIC = 787 +const ARPHRD_FCPL = 786 +const ARPHRD_FCPP = 784 +const ARPHRD_FDDI = 774 +const ARPHRD_FRAD = 770 +const ARPHRD_HDLC = 513 +const ARPHRD_HIPPI = 780 +const ARPHRD_HWX25 = 272 +const ARPHRD_IEEE1394 = 24 +const ARPHRD_IEEE802 = 6 +const ARPHRD_IEEE80211 = 801 +const ARPHRD_IEEE80211_PRISM = 802 +const ARPHRD_IEEE80211_RADIOTAP = 803 +const ARPHRD_IEEE802154 = 804 +const ARPHRD_IEEE802154_MONITOR = 805 +const ARPHRD_IEEE802_TR = 800 +const ARPHRD_INFINIBAND = 32 +const ARPHRD_IP6GRE = 823 +const ARPHRD_IPDDP = 777 +const ARPHRD_IPGRE = 778 +const ARPHRD_IRDA = 783 +const ARPHRD_LAPB = 516 +const ARPHRD_LOCALTLK = 773 +const ARPHRD_LOOPBACK = 772 +const ARPHRD_METRICOM = 23 +const ARPHRD_NETLINK = 824 +const ARPHRD_NETROM = 0 +const ARPHRD_NONE = 65534 +const ARPHRD_PHONET = 820 +const ARPHRD_PHONET_PIPE = 821 +const ARPHRD_PIMREG = 779 +const ARPHRD_PPP = 512 +const ARPHRD_PRONET = 4 +const ARPHRD_RAWHDLC = 518 +const ARPHRD_RAWIP = 519 +const ARPHRD_ROSE = 270 +const ARPHRD_RSRVD = 260 +const ARPHRD_SIT = 776 +const ARPHRD_SKIP = 771 +const ARPHRD_SLIP = 256 +const ARPHRD_SLIP6 = 258 +const ARPHRD_TUNNEL = 768 +const ARPHRD_TUNNEL6 = 769 +const ARPHRD_VOID = 65535 +const ARPHRD_VSOCKMON = 826 +const ARPHRD_X25 = 271 +const ARPOP_InREPLY = 9 +const ARPOP_InREQUEST = 8 +const ARPOP_NAK = 10 +const ARPOP_REPLY = 2 +const ARPOP_REQUEST = 1 +const ARPOP_RREPLY = 4 +const ARPOP_RREQUEST = 3 +const ATF_COM = 2 +const ATF_DONTPUB = 64 +const ATF_MAGIC = 128 +const ATF_NETMASK = 32 +const ATF_PERM = 4 +const ATF_PUBL = 8 +const ATF_USETRAILERS = 16 +const ETHERMIN = 46 +const ETHERMTU = 1500 +const ETHERTYPE_AARP = 33011 +const ETHERTYPE_ARP = 2054 +const ETHERTYPE_AT = 32923 +const ETHERTYPE_IP = 2048 +const ETHERTYPE_IPV6 = 34525 +const ETHERTYPE_IPX = 33079 +const ETHERTYPE_LOOPBACK = 36864 +const ETHERTYPE_NTRAILER = 16 +const ETHERTYPE_PUP = 512 +const ETHERTYPE_REVARP = 32821 +const ETHERTYPE_SPRITE = 1280 +const ETHERTYPE_TRAIL = 4096 +const ETHERTYPE_VLAN = 33024 +const ETHER_ADDR_LEN = 6 +const ETHER_CRC_LEN = 4 +const ETHER_HDR_LEN = 14 +const ETHER_MAX_LEN = 1518 +const ETHER_MIN_LEN = 64 +const ETHER_TYPE_LEN = 2 +const ETH_ALEN = 6 +const ETH_DATA_LEN = 1500 +const ETH_FCS_LEN = 4 +const ETH_FRAME_LEN = 1514 +const ETH_HLEN = 14 +const ETH_MAX_MTU = 65535 +const ETH_MIN_MTU = 68 +const ETH_P_1588 = 35063 +const ETH_P_8021AD = 34984 +const ETH_P_8021AH = 35047 +const ETH_P_8021Q = 33024 +const ETH_P_80221 = 35095 +const ETH_P_802_2 = 4 +const ETH_P_802_3 = 1 +const ETH_P_802_3_MIN = 1536 +const ETH_P_802_EX1 = 34997 +const ETH_P_AARP = 33011 +const ETH_P_AF_IUCV = 64507 +const ETH_P_ALL = 3 +const ETH_P_AOE = 34978 +const ETH_P_ARCNET = 26 +const ETH_P_ARP = 2054 +const ETH_P_ATALK = 32923 +const ETH_P_ATMFATE = 34948 +const ETH_P_ATMMPOA = 34892 +const ETH_P_AX25 = 2 +const ETH_P_BATMAN = 17157 +const ETH_P_BPQ = 2303 +const ETH_P_CAIF = 247 +const ETH_P_CAN = 12 +const ETH_P_CANFD = 13 +const ETH_P_CFM = 35074 +const ETH_P_CONTROL = 22 +const ETH_P_CUST = 24582 +const ETH_P_DDCMP = 6 +const ETH_P_DEC = 24576 +const ETH_P_DIAG = 24581 +const ETH_P_DNA_DL = 24577 +const ETH_P_DNA_RC = 24578 +const ETH_P_DNA_RT = 24579 +const ETH_P_DSA = 27 +const ETH_P_DSA_8021Q = 56027 +const ETH_P_ECONET = 24 +const ETH_P_EDSA = 56026 +const ETH_P_ERSPAN = 35006 +const ETH_P_ERSPAN2 = 8939 +const ETH_P_FCOE = 35078 +const ETH_P_FIP = 35092 +const ETH_P_HDLC = 25 +const ETH_P_HSR = 35119 +const ETH_P_IBOE = 35093 +const ETH_P_IEEE802154 = 246 +const ETH_P_IEEEPUP = 2560 +const ETH_P_IEEEPUPAT = 2561 +const ETH_P_IFE = 60734 +const ETH_P_IP = 2048 +const ETH_P_IPV6 = 34525 +const ETH_P_IPX = 33079 +const ETH_P_IRDA = 23 +const ETH_P_LAT = 24580 +const ETH_P_LINK_CTL = 34924 +const ETH_P_LLDP = 35020 +const ETH_P_LOCALTALK = 9 +const ETH_P_LOOP = 96 +const ETH_P_LOOPBACK = 36864 +const ETH_P_MACSEC = 35045 +const ETH_P_MAP = 249 +const ETH_P_MOBITEX = 21 +const ETH_P_MPLS_MC = 34888 +const ETH_P_MPLS_UC = 34887 +const ETH_P_MRP = 35043 +const ETH_P_MVRP = 35061 +const ETH_P_NCSI = 35064 +const ETH_P_NSH = 35151 +const ETH_P_PAE = 34958 +const ETH_P_PAUSE = 34824 +const ETH_P_PHONET = 245 +const ETH_P_PPPTALK = 16 +const ETH_P_PPP_DISC = 34915 +const ETH_P_PPP_MP = 8 +const ETH_P_PPP_SES = 34916 +const ETH_P_PREAUTH = 35015 +const ETH_P_PRP = 35067 +const ETH_P_PUP = 512 +const ETH_P_PUPAT = 513 +const ETH_P_QINQ1 = 37120 +const ETH_P_QINQ2 = 37376 +const ETH_P_QINQ3 = 37632 +const ETH_P_RARP = 32821 +const ETH_P_SCA = 24583 +const ETH_P_SLOW = 34825 +const ETH_P_SNAP = 5 +const ETH_P_TDLS = 35085 +const ETH_P_TEB = 25944 +const ETH_P_TIPC = 35018 +const ETH_P_TRAILER = 28 +const ETH_P_TR_802_2 = 17 +const ETH_P_TSN = 8944 +const ETH_P_WAN_PPP = 7 +const ETH_P_WCCP = 34878 +const ETH_P_X25 = 2053 +const ETH_P_XDSA = 248 +const ETH_TLEN = 2 +const ETH_ZLEN = 60 +const MAX_ADDR_LEN = 7 +const __UAPI_DEF_ETHHDR = 0 + +type Tethhdr = struct { + Fh_dest [6]Tuint8_t + Fh_source [6]Tuint8_t + Fh_proto Tuint16_t +} + +type Tether_addr = struct { + Fether_addr_octet [6]Tuint8_t +} + +type Tether_header = struct { + Fether_dhost [6]Tuint8_t + Fether_shost [6]Tuint8_t + Fether_type Tuint16_t +} + +type Tarphdr = struct { + Far_hrd Tuint16_t + Far_pro Tuint16_t + Far_hln Tuint8_t + Far_pln Tuint8_t + Far_op Tuint16_t +} + +type Tarpreq = struct { + Farp_pa Tsockaddr + Farp_ha Tsockaddr + Farp_flags int32 + Farp_netmask Tsockaddr + Farp_dev [16]int8 +} + +type Tarpreq_old = struct { + Farp_pa Tsockaddr + Farp_ha Tsockaddr + Farp_flags int32 + Farp_netmask Tsockaddr +} + +type Tarpd_request = struct { + Freq uint16 + Fip Tuint32_t + Fdev uint64 + Fstamp uint64 + Fupdated uint64 + Fha [7]uint8 +} + +type Tether_arp = struct { + Fea_hdr Tarphdr + Farp_sha [6]Tuint8_t + Farp_spa [4]Tuint8_t + Farp_tha [6]Tuint8_t + Farp_tpa [4]Tuint8_t +} + +func Xether_aton_r(tls *TLS, x uintptr, p_a uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v p_a=%v, (%v:)", tls, x, p_a, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ii int32 + var n uint64 + var _ /* a at bp+0 */ Tether_addr + var _ /* y at bp+8 */ uintptr + _, _ = ii, n + ii = 0 + for { + if !(ii < int32(6)) { + break + } + if ii != 0 { + if int32(**(**int8)(__ccgo_up(x))) != int32(':') { + return uintptr(0) + } else { + x = x + 1 + } + } + n = Xstrtoul(tls, x, bp+8, int32(16)) + x = **(**uintptr)(__ccgo_up(bp + 8)) + if n > uint64(0xFF) { + return uintptr(0) + } /* bad byte */ + **(**Tuint8_t)(__ccgo_up(bp + uintptr(ii))) = uint8(n) + goto _1 + _1: + ; + ii = ii + 1 + } + if int32(**(**int8)(__ccgo_up(x))) != 0 { + return uintptr(0) + } /* bad format */ + **(**Tether_addr)(__ccgo_up(p_a)) = **(**Tether_addr)(__ccgo_up(bp)) + return p_a +} + +func Xether_aton(tls *TLS, x uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xether_aton_r(tls, x, uintptr(unsafe.Pointer(&_a))) +} + +var _a Tether_addr + +func Xether_ntoa_r(tls *TLS, p_a uintptr, x uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v p_a=%v x=%v, (%v:)", tls, p_a, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ii int32 + var y, v2 uintptr + _, _, _ = ii, y, v2 + y = x + ii = 0 + for { + if !(ii < int32(6)) { + break + } + if ii == 0 { + v2 = __ccgo_ts + 988 + } else { + v2 = __ccgo_ts + 993 + } + x = x + uintptr(Xsprintf(tls, x, v2, VaList(bp+8, Int32FromUint8(**(**Tuint8_t)(__ccgo_up(p_a + uintptr(ii))))))) + goto _1 + _1: + ; + ii = ii + 1 + } + return y +} + +func Xether_ntoa(tls *TLS, p_a uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v p_a=%v, (%v:)", tls, p_a, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xether_ntoa_r(tls, p_a, uintptr(unsafe.Pointer(&_x))) +} + +var _x [18]int8 + +func Xether_line(tls *TLS, l uintptr, e uintptr, hostname uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v l=%v e=%v hostname=%v, (%v:)", tls, l, e, hostname, origin(2)) + defer func() { trc("-> %v", r) }() + } + return -int32(1) +} + +func Xether_ntohost(tls *TLS, hostname uintptr, e uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v hostname=%v e=%v, (%v:)", tls, hostname, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + return -int32(1) +} + +func Xether_hostton(tls *TLS, hostname uintptr, e uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v hostname=%v e=%v, (%v:)", tls, hostname, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + return -int32(1) +} + +func Xfreeaddrinfo(tls *TLS, p uintptr) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + } + var b, v2 uintptr + var cnt Tsize_t + _, _, _ = b, cnt, v2 + cnt = uint64(1) + for { + if !((*Taddrinfo)(unsafe.Pointer(p)).Fai_next != 0) { + break + } + goto _1 + _1: + ; + cnt = cnt + 1 + p = (*Taddrinfo)(unsafe.Pointer(p)).Fai_next + } + b = p - uintptr(uint64(UintptrFromInt32(0))) + b = b - uintptr((*Taibuf)(unsafe.Pointer(b)).Fslot)*88 + ___lock(tls, b+76) + v2 = b + 82 + *(*int16)(unsafe.Pointer(v2)) = int16(uint64(*(*int16)(unsafe.Pointer(v2))) - cnt) + if !(*(*int16)(unsafe.Pointer(v2)) != 0) { + Xfree(tls, b) + } else { + ___unlock(tls, b+76) + } +} + +var _msgs = [252]int8{'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'f', 'l', 'a', 'g', 's', 0, 'N', 'a', 'm', 'e', ' ', 'd', 'o', 'e', 's', ' ', 'n', 'o', 't', ' ', 'r', 'e', 's', 'o', 'l', 'v', 'e', 0, 'T', 'r', 'y', ' ', 'a', 'g', 'a', 'i', 'n', 0, 'N', 'o', 'n', '-', 'r', 'e', 'c', 'o', 'v', 'e', 'r', 'a', 'b', 'l', 'e', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'N', 'a', 'm', 'e', ' ', 'h', 'a', 's', ' ', 'n', 'o', ' ', 'u', 's', 'a', 'b', 'l', 'e', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's', 0, 'U', 'n', 'r', 'e', 'c', 'o', 'g', 'n', 'i', 'z', 'e', 'd', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's', ' ', 'f', 'a', 'm', 'i', 'l', 'y', ' ', 'o', 'r', ' ', 'i', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'l', 'e', 'n', 'g', 't', 'h', 0, 'U', 'n', 'r', 'e', 'c', 'o', 'g', 'n', 'i', 'z', 'e', 'd', ' ', 's', 'o', 'c', 'k', 'e', 't', ' ', 't', 'y', 'p', 'e', 0, 'U', 'n', 'r', 'e', 'c', 'o', 'g', 'n', 'i', 'z', 'e', 'd', ' ', 's', 'e', 'r', 'v', 'i', 'c', 'e', 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'O', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0, 'S', 'y', 's', 't', 'e', 'm', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'O', 'v', 'e', 'r', 'f', 'l', 'o', 'w', 0, 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r'} + +func Xgai_strerror(tls *TLS, ecode int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ecode=%v, (%v:)", tls, ecode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + _ = s + s = uintptr(unsafe.Pointer(&_msgs)) + ecode = ecode + 1 + for { + if !(ecode != 0 && **(**int8)(__ccgo_up(s)) != 0) { + break + } + for { + if !(**(**int8)(__ccgo_up(s)) != 0) { + break + } + goto _2 + _2: + ; + s = s + 1 + } + goto _1 + _1: + ; + ecode = ecode + 1 + s = s + 1 + } + if !(**(**int8)(__ccgo_up(s)) != 0) { + s = s + 1 + } + return X__lctrans_cur(tls, s) +} + +func Xgetaddrinfo(tls *TLS, host uintptr, serv uintptr, hint uintptr, res uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v host=%v serv=%v hint=%v res=%v, (%v:)", tls, host, serv, hint, res, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(1616) + defer tls.Free(1616) + var canon_len, family, flags, i, j, k, mask, naddrs, nais, no_family, nservs, proto, r, s, saved_errno, socktype, v3 int32 + var out, outcanon uintptr + var ta [2]uintptr + var tf [2]int32 + var tl [2]Tsocklen_t + var v5 uint64 + var _ /* addrs at bp+8 */ [48]Taddress + var _ /* canon at bp+1352 */ [256]int8 + var _ /* cs at bp+1608 */ int32 + var _ /* ports at bp+0 */ [2]Tservice + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = canon_len, family, flags, i, j, k, mask, naddrs, nais, no_family, nservs, out, outcanon, proto, r, s, saved_errno, socktype, ta, tf, tl, v3, v5 + family = PF_UNSPEC + flags = 0 + proto = 0 + socktype = 0 + no_family = 0 + if !(host != 0) && !(serv != 0) { + return -int32(2) + } + if hint != 0 { + family = (*Taddrinfo)(unsafe.Pointer(hint)).Fai_family + flags = (*Taddrinfo)(unsafe.Pointer(hint)).Fai_flags + proto = (*Taddrinfo)(unsafe.Pointer(hint)).Fai_protocol + socktype = (*Taddrinfo)(unsafe.Pointer(hint)).Fai_socktype + mask = Int32FromInt32(AI_PASSIVE) | Int32FromInt32(AI_CANONNAME) | Int32FromInt32(AI_NUMERICHOST) | Int32FromInt32(AI_V4MAPPED) | Int32FromInt32(AI_ALL) | Int32FromInt32(AI_ADDRCONFIG) | Int32FromInt32(AI_NUMERICSERV) + if flags&mask != flags { + return -int32(1) + } + switch family { + case int32(PF_INET): + fallthrough + case int32(PF_INET6): + fallthrough + case PF_UNSPEC: + default: + return -int32(6) + } + } + if flags&int32(AI_ADDRCONFIG) != 0 { + tf = [2]int32{ + 0: int32(PF_INET), + 1: int32(PF_INET6), + } + ta = [2]uintptr{ + 0: uintptr(unsafe.Pointer(&_lo4)), + 1: uintptr(unsafe.Pointer(&_lo6)), + } + tl = [2]Tsocklen_t{ + 0: uint32(16), + 1: uint32(28), + } + i = 0 + for { + if !(i < int32(2)) { + break + } + if family == tf[int32(1)-i] { + goto _1 + } + s = Xsocket(tls, tf[i], Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_DGRAM), int32(IPPROTO_UDP)) + if s >= 0 { + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+1608) + r = Xconnect(tls, s, ta[i], tl[i]) + saved_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 1608)), uintptr(0)) + Xclose(tls, s) + if !(r != 0) { + goto _1 + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = saved_errno + } + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(EADDRNOTAVAIL): + fallthrough + case int32(EAFNOSUPPORT): + fallthrough + case int32(EHOSTUNREACH): + fallthrough + case int32(ENETDOWN): + fallthrough + case int32(ENETUNREACH): + default: + return -int32(11) + } + if family == tf[i] { + no_family = int32(1) + } + family = tf[int32(1)-i] + goto _1 + _1: + ; + i = i + 1 + } + } + nservs = X__lookup_serv(tls, bp, serv, proto, socktype, flags) + if nservs < 0 { + return nservs + } + naddrs = X__lookup_name(tls, bp+8, bp+1352, host, family, flags) + if naddrs < 0 { + return naddrs + } + if no_family != 0 { + return -int32(5) + } + nais = nservs * naddrs + canon_len = Int32FromUint64(_strlen(tls, bp+1352)) + out = Xcalloc(tls, uint64(1), Uint64FromInt32(nais)*uint64(88)+Uint64FromInt32(canon_len)+uint64(1)) + if !(out != 0) { + return -int32(10) + } + if canon_len != 0 { + outcanon = out + uintptr(nais)*88 + Xmemcpy(tls, outcanon, bp+1352, Uint64FromInt32(canon_len+int32(1))) + } else { + outcanon = uintptr(0) + } + v3 = Int32FromInt32(0) + i = v3 + k = v3 + for { + if !(i < naddrs) { + break + } + j = 0 + for { + if !(j < nservs) { + break + } + (**(**Taibuf)(__ccgo_up(out + uintptr(k)*88))).Fslot = int16(k) + if (**(**[48]Taddress)(__ccgo_up(bp + 8)))[i].Ffamily == int32(PF_INET) { + v5 = uint64(16) + } else { + v5 = uint64(28) + } + (**(**Taibuf)(__ccgo_up(out + uintptr(k)*88))).Fai = Taddrinfo{ + Fai_family: (**(**[48]Taddress)(__ccgo_up(bp + 8)))[i].Ffamily, + Fai_socktype: Int32FromUint8((**(**[2]Tservice)(__ccgo_up(bp)))[j].Fsocktype), + Fai_protocol: Int32FromUint8((**(**[2]Tservice)(__ccgo_up(bp)))[j].Fproto), + Fai_addrlen: uint32(v5), + Fai_addr: out + uintptr(k)*88 + 48, + Fai_canonname: outcanon, + } + if k != 0 { + (**(**Taibuf)(__ccgo_up(out + uintptr(k-int32(1))*88))).Fai.Fai_next = out + uintptr(k)*88 + } + switch (**(**[48]Taddress)(__ccgo_up(bp + 8)))[i].Ffamily { + case int32(PF_INET): + *(*Tsa_family_t)(unsafe.Pointer(out + uintptr(k)*88 + 48)) = uint16(PF_INET) + *(*Tin_port_t)(unsafe.Pointer(out + uintptr(k)*88 + 48 + 2)) = Xhtons(tls, (**(**[2]Tservice)(__ccgo_up(bp)))[j].Fport) + Xmemcpy(tls, out+uintptr(k)*88+48+4, bp+8+uintptr(i)*28+8, uint64(4)) + case int32(PF_INET6): + *(*Tsa_family_t)(unsafe.Pointer(out + uintptr(k)*88 + 48)) = uint16(PF_INET6) + *(*Tin_port_t)(unsafe.Pointer(out + uintptr(k)*88 + 48 + 2)) = Xhtons(tls, (**(**[2]Tservice)(__ccgo_up(bp)))[j].Fport) + *(*Tuint32_t)(unsafe.Pointer(out + uintptr(k)*88 + 48 + 24)) = (**(**[48]Taddress)(__ccgo_up(bp + 8)))[i].Fscopeid + Xmemcpy(tls, out+uintptr(k)*88+48+8, bp+8+uintptr(i)*28+8, uint64(16)) + break + } + goto _4 + _4: + ; + j = j + 1 + k = k + 1 + } + goto _2 + _2: + ; + i = i + 1 + } + (**(**Taibuf)(__ccgo_up(out))).Fref = int16(nais) + **(**uintptr)(__ccgo_up(res)) = out + return 0 +} + +/* Define the "an address is configured" condition for address + * families via ability to create a socket for the family plus + * routability of the loopback address for the family. */ +var _lo4 = Tsockaddr_in{ + Fsin_family: uint16(PF_INET), + Fsin_port: uint16(65535), + Fsin_addr: Tin_addr{ + Fs_addr: uint32(0x0100007f), + }, +} + +var _lo6 = Tsockaddr_in6{ + Fsin6_family: uint16(PF_INET6), + Fsin6_port: uint16(65535), + Fsin6_addr: Tin6_addr{ + F__in6_union: *(*struct { + F__s6_addr16 [0][8]Tuint16_t + F__s6_addr32 [0][4]Tuint32_t + F__s6_addr [16]Tuint8_t + })(unsafe.Pointer(&[16]Tuint8_t{ + 15: uint8(1), + })), + }, +} + +const EAI_ADDRFAMILY = -9 +const EAI_ALLDONE = -103 +const EAI_CANCELED = -101 +const EAI_IDN_ENCODE = -105 +const EAI_INPROGRESS = -100 +const EAI_INTR = -104 +const EAI_NOTCANCELED = -102 +const HOST_NOT_FOUND = 1 +const MCAST_BLOCK_SOURCE = 43 +const MCAST_EXCLUDE = 0 +const MCAST_INCLUDE = 1 +const MCAST_JOIN_GROUP = 42 +const MCAST_JOIN_SOURCE_GROUP = 46 +const MCAST_LEAVE_GROUP = 45 +const MCAST_LEAVE_SOURCE_GROUP = 47 +const MCAST_MSFILTER = 48 +const MCAST_UNBLOCK_SOURCE = 44 +const NI_MAXHOST = 255 +const NI_MAXSERV = 32 +const NO_ADDRESS = 4 +const NO_DATA = 4 +const NO_RECOVERY = 3 +const TRY_AGAIN = 2 +const h_errno = 0 + +type Tip_mreq = struct { + Fimr_multiaddr Tin_addr + Fimr_interface Tin_addr +} + +type Tip_mreqn = struct { + Fimr_multiaddr Tin_addr + Fimr_address Tin_addr + Fimr_ifindex int32 +} + +type Tip_mreq_source = struct { + Fimr_multiaddr Tin_addr + Fimr_interface Tin_addr + Fimr_sourceaddr Tin_addr +} + +type Tip_msfilter = struct { + Fimsf_multiaddr Tin_addr + Fimsf_interface Tin_addr + Fimsf_fmode Tuint32_t + Fimsf_numsrc Tuint32_t + Fimsf_slist [1]Tin_addr +} + +type Tgroup_req = struct { + Fgr_interface Tuint32_t + Fgr_group Tsockaddr_storage +} + +type Tgroup_source_req = struct { + Fgsr_interface Tuint32_t + Fgsr_group Tsockaddr_storage + Fgsr_source Tsockaddr_storage +} + +type Tgroup_filter = struct { + Fgf_interface Tuint32_t + Fgf_group Tsockaddr_storage + Fgf_fmode Tuint32_t + Fgf_numsrc Tuint32_t + Fgf_slist [1]Tsockaddr_storage +} + +type Tin_pktinfo = struct { + Fipi_ifindex int32 + Fipi_spec_dst Tin_addr + Fipi_addr Tin_addr +} + +type Tin6_pktinfo = struct { + Fipi6_addr Tin6_addr + Fipi6_ifindex uint32 +} + +type Tip6_mtuinfo = struct { + Fip6m_addr Tsockaddr_in6 + Fip6m_mtu Tuint32_t +} + +func Xgethostbyaddr(tls *TLS, a uintptr, l Tsocklen_t, af int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v a=%v l=%v af=%v, (%v:)", tls, a, l, af, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var err int32 + var size Tsize_t + var _ /* res at bp+0 */ uintptr + _, _ = err, size + size = uint64(63) + for cond := true; cond; cond = err == int32(ERANGE) { + Xfree(tls, _h) + size = size + (size + uint64(1)) + _h = Xmalloc(tls, size) + if !(_h != 0) { + **(**int32)(__ccgo_up(X__h_errno_location(tls))) = int32(NO_RECOVERY) + return uintptr(0) + } + err = Xgethostbyaddr_r(tls, a, l, af, _h, _h+UintptrFromInt32(1)*32, size-uint64(32), bp, X__h_errno_location(tls)) + } + return **(**uintptr)(__ccgo_up(bp)) +} + +var _h uintptr + +func Xgethostbyaddr_r(tls *TLS, a uintptr, l Tsocklen_t, af int32, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v l=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, a, l, af, h, buf, buflen, res, err, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var sl Tsocklen_t + var v1 uint64 + var _ /* sa at bp+0 */ struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + } + _, _, _ = i, sl, v1 + *(*struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(unsafe.Pointer(bp)) = struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + }{} + *(*uint16)(unsafe.Pointer(bp)) = Uint16FromInt32(af) + if af == int32(PF_INET6) { + v1 = uint64(28) + } else { + v1 = uint64(16) + } + sl = uint32(v1) + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + /* Load address argument into sockaddr structure */ + if af == int32(PF_INET6) && l == uint32(16) { + Xmemcpy(tls, bp+8, a, uint64(16)) + } else { + if af == int32(PF_INET) && l == uint32(4) { + Xmemcpy(tls, bp+4, a, uint64(4)) + } else { + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return int32(EINVAL) + } + } + /* Align buffer and check for space for pointers and ip address */ + i = Int32FromUint64(uint64(buf) & (Uint64FromInt64(8) - Uint64FromInt32(1))) + if !(i != 0) { + i = int32(8) + } + if buflen <= Uint64FromInt32(5)*Uint64FromInt64(8)-Uint64FromInt32(i)+uint64(l) { + return int32(ERANGE) + } + buf = buf + uintptr(uint64(8)-Uint64FromInt32(i)) + buflen = buflen - (Uint64FromInt32(5)*Uint64FromInt64(8) - Uint64FromInt32(i) + uint64(l)) + (*Thostent)(unsafe.Pointer(h)).Fh_addr_list = buf + buf = buf + uintptr(Uint64FromInt32(2)*Uint64FromInt64(8)) + (*Thostent)(unsafe.Pointer(h)).Fh_aliases = buf + buf = buf + uintptr(Uint64FromInt32(2)*Uint64FromInt64(8)) + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list)) = buf + Xmemcpy(tls, **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list)), a, uint64(l)) + buf = buf + uintptr(l) + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list + 1*8)) = uintptr(0) + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases)) = buf + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0) + switch Xgetnameinfo(tls, bp, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) { + case -int32(3): + **(**int32)(__ccgo_up(err)) = int32(TRY_AGAIN) + return int32(EAGAIN) + case -int32(12): + return int32(ERANGE) + default: + fallthrough + case -int32(4): + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return int32(EBADMSG) + case -int32(11): + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return **(**int32)(__ccgo_up(X__errno_location(tls))) + case 0: + break + } + (*Thostent)(unsafe.Pointer(h)).Fh_addrtype = af + (*Thostent)(unsafe.Pointer(h)).Fh_length = Int32FromUint32(l) + (*Thostent)(unsafe.Pointer(h)).Fh_name = **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases)) + **(**uintptr)(__ccgo_up(res)) = h + return 0 +} + +func Xgethostbyname(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgethostbyname2(tls, name, int32(PF_INET)) +} + +func Xgethostbyname2(tls *TLS, name uintptr, af int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v af=%v, (%v:)", tls, name, af, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var err int32 + var size Tsize_t + var _ /* res at bp+0 */ uintptr + _, _ = err, size + size = uint64(63) + for cond := true; cond; cond = err == int32(ERANGE) { + Xfree(tls, _h1) + size = size + (size + uint64(1)) + _h1 = Xmalloc(tls, size) + if !(_h1 != 0) { + **(**int32)(__ccgo_up(X__h_errno_location(tls))) = int32(NO_RECOVERY) + return uintptr(0) + } + err = Xgethostbyname2_r(tls, name, af, _h1, _h1+UintptrFromInt32(1)*32, size-uint64(32), bp, X__h_errno_location(tls)) + } + return **(**uintptr)(__ccgo_up(bp)) +} + +var _h1 uintptr + +func Xgethostbyname2_r(tls *TLS, name uintptr, af int32, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, name, af, h, buf, buflen, res, err, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(1600) + defer tls.Free(1600) + var align, need Tsize_t + var cnt, i, v1 int32 + var v3 uintptr + var _ /* addrs at bp+0 */ [48]Taddress + var _ /* canon at bp+1344 */ [256]int8 + _, _, _, _, _, _ = align, cnt, i, need, v1, v3 + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + cnt = X__lookup_name(tls, bp, bp+1344, name, af, int32(AI_CANONNAME)) + if cnt < 0 { + switch cnt { + case -int32(2): + **(**int32)(__ccgo_up(err)) = int32(HOST_NOT_FOUND) + return 0 + case -int32(5): + **(**int32)(__ccgo_up(err)) = int32(NO_DATA) + return 0 + case -int32(3): + **(**int32)(__ccgo_up(err)) = int32(TRY_AGAIN) + return int32(EAGAIN) + default: + fallthrough + case -int32(4): + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return int32(EBADMSG) + case -int32(11): + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return **(**int32)(__ccgo_up(X__errno_location(tls))) + } + } + (*Thostent)(unsafe.Pointer(h)).Fh_addrtype = af + if af == int32(PF_INET6) { + v1 = int32(16) + } else { + v1 = int32(4) + } + (*Thostent)(unsafe.Pointer(h)).Fh_length = v1 + /* Align buffer */ + align = -uint64(buf) & (Uint64FromInt64(8) - Uint64FromInt32(1)) + need = Uint64FromInt32(4) * Uint64FromInt64(8) + need = need + Uint64FromInt32(cnt+Int32FromInt32(1))*(uint64(8)+Uint64FromInt32((*Thostent)(unsafe.Pointer(h)).Fh_length)) + need = need + (_strlen(tls, name) + uint64(1)) + need = need + (_strlen(tls, bp+1344) + uint64(1)) + need = need + align + if need > buflen { + return int32(ERANGE) + } + buf = buf + uintptr(align) + (*Thostent)(unsafe.Pointer(h)).Fh_aliases = buf + buf = buf + uintptr(Uint64FromInt32(3)*Uint64FromInt64(8)) + (*Thostent)(unsafe.Pointer(h)).Fh_addr_list = buf + buf = buf + uintptr(Uint64FromInt32(cnt+Int32FromInt32(1))*uint64(8)) + i = 0 + for { + if !(i < cnt) { + break + } + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = buf + buf = buf + uintptr((*Thostent)(unsafe.Pointer(h)).Fh_length) + Xmemcpy(tls, **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)), bp+uintptr(i)*28+8, Uint64FromInt32((*Thostent)(unsafe.Pointer(h)).Fh_length)) + goto _2 + _2: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = uintptr(0) + v3 = buf + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases)) = v3 + (*Thostent)(unsafe.Pointer(h)).Fh_name = v3 + Xstrcpy(tls, (*Thostent)(unsafe.Pointer(h)).Fh_name, bp+1344) + buf = buf + uintptr(_strlen(tls, (*Thostent)(unsafe.Pointer(h)).Fh_name)+uint64(1)) + if Xstrcmp(tls, (*Thostent)(unsafe.Pointer(h)).Fh_name, name) != 0 { + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = buf + Xstrcpy(tls, **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)), name) + buf = buf + uintptr(_strlen(tls, **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)))+uint64(1)) + } else { + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0) + } + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 2*8)) = uintptr(0) + **(**uintptr)(__ccgo_up(res)) = h + return 0 +} + +func Xgethostbyname_r(tls *TLS, name uintptr, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, name, h, buf, buflen, res, err, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgethostbyname2_r(tls, name, int32(PF_INET), h, buf, buflen, res, err) +} + +const IFADDRS_HASH_SIZE = 64 +const IFA_ADDRESS = 1 +const IFA_BROADCAST = 4 +const IFA_LABEL = 3 +const IFA_LOCAL = 2 +const IFF_ALLMULTI = 512 +const IFF_AUTOMEDIA = 16384 +const IFF_BROADCAST = 2 +const IFF_DEBUG = 4 +const IFF_DORMANT = 131072 +const IFF_DYNAMIC = 32768 +const IFF_ECHO = 262144 +const IFF_LOOPBACK = 8 +const IFF_LOWER_UP = 65536 +const IFF_MASTER = 1024 +const IFF_MULTICAST = 4096 +const IFF_NOARP = 128 +const IFF_NOTRAILERS = 32 +const IFF_POINTOPOINT = 16 +const IFF_PORTSEL = 8192 +const IFF_PROMISC = 256 +const IFF_RUNNING = 64 +const IFF_SLAVE = 2048 +const IFF_UP = 1 +const IFF_VOLATILE = 461914 +const IFHWADDRLEN = 6 +const IFLA_ADDRESS = 1 +const IFLA_BROADCAST = 2 +const IFLA_IFNAME = 3 +const IFLA_STATS = 7 +const IFNAMSIZ = 16 +const IF_NAMESIZE = 16 +const NETLINK_ROUTE = 0 +const NLMSG_DONE = 3 +const NLMSG_ERROR = 2 +const NLMSG_NOOP = 1 +const NLMSG_OVERRUN = 4 +const NLM_F_ACK = 4 +const NLM_F_ATOMIC = 1024 +const NLM_F_DUMP = 768 +const NLM_F_MATCH = 512 +const NLM_F_MULTI = 2 +const NLM_F_REQUEST = 1 +const NLM_F_ROOT = 256 +const RTM_GETADDR = 22 +const RTM_GETLINK = 18 +const RTM_NEWADDR = 20 +const RTM_NEWLINK = 16 +const __UAPI_DEF_IF_IFCONF = 0 +const __UAPI_DEF_IF_IFMAP = 0 +const __UAPI_DEF_IF_IFNAMSIZ = 0 +const __UAPI_DEF_IF_IFREQ = 0 +const __UAPI_DEF_IF_NET_DEVICE_FLAGS = 0 +const __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO = 0 + +type Tifaddrs = struct { + Fifa_next uintptr + Fifa_name uintptr + Fifa_flags uint32 + Fifa_addr uintptr + Fifa_netmask uintptr + Fifa_ifu struct { + Fifu_dstaddr [0]uintptr + Fifu_broadaddr uintptr + } + Fifa_data uintptr +} + +type Tif_nameindex = struct { + Fif_index uint32 + Fif_name uintptr +} + +type Tifaddr = struct { + Fifa_addr Tsockaddr + Fifa_ifu struct { + Fifu_dstaddr [0]Tsockaddr + Fifu_broadaddr Tsockaddr + } + Fifa_ifp uintptr + Fifa_next uintptr +} + +type Tifmap = struct { + Fmem_start uint64 + Fmem_end uint64 + Fbase_addr uint16 + Firq uint8 + Fdma uint8 + Fport uint8 +} + +type Tifreq = struct { + Fifr_ifrn struct { + Fifrn_name [16]int8 + } + Fifr_ifru struct { + Fifru_dstaddr [0]Tsockaddr + Fifru_broadaddr [0]Tsockaddr + Fifru_netmask [0]Tsockaddr + Fifru_hwaddr [0]Tsockaddr + Fifru_flags [0]int16 + Fifru_ivalue [0]int32 + Fifru_mtu [0]int32 + Fifru_map [0]Tifmap + Fifru_slave [0][16]int8 + Fifru_newname [0][16]int8 + Fifru_data [0]uintptr + Fifru_addr Tsockaddr + F__ccgo_pad12 [8]byte + } +} + +type Tifconf = struct { + Fifc_len int32 + Fifc_ifcu struct { + Fifcu_req [0]uintptr + Fifcu_buf uintptr + } +} + +type Tnlmsghdr = struct { + Fnlmsg_len Tuint32_t + Fnlmsg_type Tuint16_t + Fnlmsg_flags Tuint16_t + Fnlmsg_seq Tuint32_t + Fnlmsg_pid Tuint32_t +} + +type Trtattr = struct { + Frta_len uint16 + Frta_type uint16 +} + +type Trtgenmsg = struct { + Frtgen_family uint8 +} + +type Tifinfomsg = struct { + Fifi_family uint8 + F__ifi_pad uint8 + Fifi_type uint16 + Fifi_index int32 + Fifi_flags uint32 + Fifi_change uint32 +} + +type Tifaddrmsg = struct { + Fifa_family Tuint8_t + Fifa_prefixlen Tuint8_t + Fifa_flags Tuint8_t + Fifa_scope Tuint8_t + Fifa_index Tuint32_t +} + +/* getifaddrs() reports hardware addresses with PF_PACKET that implies + * struct sockaddr_ll. But e.g. Infiniband socket address length is + * longer than sockaddr_ll.ssl_addr[8] can hold. Use this hack struct + * to extend ssl_addr - callers should be able to still use it. */ +type Tsockaddr_ll_hack = struct { + Fsll_family uint16 + Fsll_protocol uint16 + Fsll_ifindex int32 + Fsll_hatype uint16 + Fsll_pkttype uint8 + Fsll_halen uint8 + Fsll_addr [24]uint8 +} + +type Tsockany = struct { + Fll [0]Tsockaddr_ll_hack + Fv4 [0]Tsockaddr_in + Fv6 [0]Tsockaddr_in6 + Fsa Tsockaddr + F__ccgo_pad4 [20]byte +} + +type Tifaddrs_storage = struct { + Fifa Tifaddrs + Fhash_next uintptr + Faddr Tsockany + Fnetmask Tsockany + Fifu Tsockany + Findex uint32 + Fname [17]int8 +} + +type Tifaddrs_ctx = struct { + Ffirst uintptr + Flast uintptr + Fhash [64]uintptr +} + +func Xfreeifaddrs(tls *TLS, ifp uintptr) { + if __ccgo_strace { + trc("tls=%v ifp=%v, (%v:)", tls, ifp, origin(2)) + } + var n uintptr + _ = n + for ifp != 0 { + n = (*Tifaddrs)(unsafe.Pointer(ifp)).Fifa_next + Xfree(tls, ifp) + ifp = n + } +} + +func _copy_addr(tls *TLS, r uintptr, af int32, sa uintptr, addr uintptr, addrlen Tsize_t, ifindex int32) { + var dst uintptr + var len1 int32 + _, _ = dst, len1 + switch af { + case int32(PF_INET): + dst = sa + 4 + len1 = int32(4) + case int32(PF_INET6): + dst = sa + 8 + len1 = int32(16) + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(addr))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(addr + 1)))&int32(0xc0) == int32(0x80) || Int32FromUint8(**(**Tuint8_t)(__ccgo_up(addr))) == int32(0xff) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(addr + 1)))&int32(0xf) == int32(0x2) { + (*(*Tsockaddr_in6)(unsafe.Pointer(sa))).Fsin6_scope_id = Uint32FromInt32(ifindex) + } + default: + return + } + if addrlen < Uint64FromInt32(len1) { + return + } + (*Tsockany)(unsafe.Pointer(sa)).Fsa.Fsa_family = Uint16FromInt32(af) + Xmemcpy(tls, dst, addr, Uint64FromInt32(len1)) + **(**uintptr)(__ccgo_up(r)) = sa +} + +func _gen_netmask(tls *TLS, r uintptr, af int32, sa uintptr, prefixlen int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, v1 int32 + var _ /* addr at bp+0 */ [16]Tuint8_t + _, _ = i, v1 + **(**[16]Tuint8_t)(__ccgo_up(bp)) = [16]Tuint8_t{} + if Uint64FromInt32(prefixlen) > Uint64FromInt32(8)*Uint64FromInt64(16) { + prefixlen = Int32FromUint64(Uint64FromInt32(8) * Uint64FromInt64(16)) + } + i = prefixlen / int32(8) + Xmemset(tls, bp, int32(0xff), Uint64FromInt32(i)) + if Uint64FromInt32(i) < uint64(16) { + v1 = i + i = i + 1 + (**(**[16]Tuint8_t)(__ccgo_up(bp)))[v1] = Uint8FromInt32(int32(0xff) << (int32(8) - prefixlen%int32(8))) + } + _copy_addr(tls, r, af, sa, bp, uint64(16), 0) +} + +func _copy_lladdr(tls *TLS, r uintptr, sa uintptr, addr uintptr, addrlen Tsize_t, ifindex int32, hatype uint16) { + if addrlen > uint64(24) { + return + } + (*(*Tsockaddr_ll_hack)(unsafe.Pointer(sa))).Fsll_family = uint16(PF_PACKET) + (*(*Tsockaddr_ll_hack)(unsafe.Pointer(sa))).Fsll_ifindex = ifindex + (*(*Tsockaddr_ll_hack)(unsafe.Pointer(sa))).Fsll_hatype = hatype + (*(*Tsockaddr_ll_hack)(unsafe.Pointer(sa))).Fsll_halen = uint8(addrlen) + Xmemcpy(tls, sa+12, addr, addrlen) + **(**uintptr)(__ccgo_up(r)) = sa +} + +func _netlink_msg_to_ifaddr(tls *TLS, pctx uintptr, h uintptr) (r int32) { + var bucket uint32 + var ctx, ifa, ifi, ifs, ifs0, rta uintptr + var stats_len int32 + _, _, _, _, _, _, _, _ = bucket, ctx, ifa, ifi, ifs, ifs0, rta, stats_len + ctx = pctx + ifi = h + UintptrFromInt64(16) + ifa = h + UintptrFromInt64(16) + stats_len = 0 + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(RTM_NEWLINK) { + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(16)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + for { + if !(Uint64FromInt64(int64(h+uintptr((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len))-int64(rta)) >= uint64(4)) { + break + } + if Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_type) != int32(IFLA_STATS) { + goto _1 + } + stats_len = Int32FromUint64(uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len) - Uint64FromInt64(4)) + break + goto _1 + _1: + ; + rta = rta + uintptr((Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_len)+Int32FromInt32(3)) & ^Int32FromInt32(3)) + } + } else { + ifs0 = **(**uintptr)(__ccgo_up(ctx + 16 + uintptr((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index%uint32(IFADDRS_HASH_SIZE))*8)) + for { + if !(ifs0 != 0) { + break + } + if (*Tifaddrs_storage)(unsafe.Pointer(ifs0)).Findex == (*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index { + break + } + goto _2 + _2: + ; + ifs0 = (*Tifaddrs_storage)(unsafe.Pointer(ifs0)).Fhash_next + } + if !(ifs0 != 0) { + return 0 + } + } + ifs = Xcalloc(tls, uint64(1), uint64(200)+Uint64FromInt32(stats_len)) + if ifs == uintptr(0) { + return -int32(1) + } + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(RTM_NEWLINK) { + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Findex = Uint32FromInt32((*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_index) + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_flags = (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_flags + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(16)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + for { + if !(Uint64FromInt64(int64(h+uintptr((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len))-int64(rta)) >= uint64(4)) { + break + } + switch Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_type) { + case int32(IFLA_IFNAME): + if uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-uint64(4) < uint64(17) { + Xmemcpy(tls, ifs+176, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4)) + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name = ifs + 176 + } + case int32(IFLA_ADDRESS): + _copy_lladdr(tls, ifs+24, ifs+64, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_index, (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_type) + case int32(IFLA_BROADCAST): + _copy_lladdr(tls, ifs+40, ifs+136, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_index, (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_type) + case int32(IFLA_STATS): + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_data = ifs + UintptrFromInt32(1)*200 + Xmemcpy(tls, (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_data, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4)) + break + } + goto _3 + _3: + ; + rta = rta + uintptr((Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_len)+Int32FromInt32(3)) & ^Int32FromInt32(3)) + } + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name != 0 { + bucket = (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Findex % uint32(IFADDRS_HASH_SIZE) + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fhash_next = **(**uintptr)(__ccgo_up(ctx + 16 + uintptr(bucket)*8)) + **(**uintptr)(__ccgo_up(ctx + 16 + uintptr(bucket)*8)) = ifs + } + } else { + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name = (*Tifaddrs_storage)(unsafe.Pointer(ifs0)).Fifa.Fifa_name + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_flags = (*Tifaddrs_storage)(unsafe.Pointer(ifs0)).Fifa.Fifa_flags + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(8)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + for { + if !(Uint64FromInt64(int64(h+uintptr((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len))-int64(rta)) >= uint64(4)) { + break + } + switch Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_type) { + case int32(IFA_ADDRESS): + /* If ifa_addr is already set we, received an IFA_LOCAL before + * so treat this as destination address */ + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_addr != 0 { + _copy_addr(tls, ifs+40, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+136, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index)) + } else { + _copy_addr(tls, ifs+24, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+64, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index)) + } + case int32(IFA_BROADCAST): + _copy_addr(tls, ifs+40, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+136, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index)) + case int32(IFA_LOCAL): + /* If ifa_addr is set and we get IFA_LOCAL, assume we have + * a point-to-point network. Move address to correct field. */ + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_addr != 0 { + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifu = (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Faddr + *(*uintptr)(unsafe.Pointer(ifs + 40)) = ifs + 136 + Xmemset(tls, ifs+64, 0, uint64(36)) + } + _copy_addr(tls, ifs+24, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+64, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index)) + case int32(IFA_LABEL): + if uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-uint64(4) < uint64(17) { + Xmemcpy(tls, ifs+176, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4)) + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name = ifs + 176 + } + break + } + goto _4 + _4: + ; + rta = rta + uintptr((Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_len)+Int32FromInt32(3)) & ^Int32FromInt32(3)) + } + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_addr != 0 { + _gen_netmask(tls, ifs+32, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+100, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_prefixlen)) + } + } + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name != 0 { + if !((*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Ffirst != 0) { + (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Ffirst = ifs + } + if (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Flast != 0 { + (*Tifaddrs)(unsafe.Pointer((*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Flast)).Fifa_next = ifs + } + (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Flast = ifs + } else { + Xfree(tls, ifs) + } + return 0 +} + +func Xgetifaddrs(tls *TLS, ifap uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v ifap=%v, (%v:)", tls, ifap, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(528) + defer tls.Free(528) + var ctx uintptr + var r int32 + var _ /* _ctx at bp+0 */ Tifaddrs_ctx + _, _ = ctx, r + ctx = bp + Xmemset(tls, ctx, 0, uint64(528)) + r = X__rtnetlink_enumerate(tls, PF_UNSPEC, PF_UNSPEC, __ccgo_fp(_netlink_msg_to_ifaddr), ctx) + if r == 0 { + **(**uintptr)(__ccgo_up(ifap)) = (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Ffirst + } else { + Xfreeifaddrs(tls, (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Ffirst) + } + return r +} + +const RR_PTR = 12 + +func _itoa(tls *TLS, p uintptr, x uint32) (r uintptr) { + var v1 uintptr + _ = v1 + p = p + uintptr(Uint64FromInt32(3)*Uint64FromInt64(4)) + p = p - 1 + v1 = p + **(**int8)(__ccgo_up(v1)) = 0 + for cond := true; cond; cond = x != 0 { + p = p - 1 + v1 = p + **(**int8)(__ccgo_up(v1)) = Int8FromUint32(uint32('0') + x%uint32(10)) + x = x / uint32(10) + } + return p +} + +func _mkptr4(tls *TLS, s uintptr, ip uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + Xsprintf(tls, s, __ccgo_ts+999, VaList(bp+8, Int32FromUint8(**(**uint8)(__ccgo_up(ip + 3))), Int32FromUint8(**(**uint8)(__ccgo_up(ip + 2))), Int32FromUint8(**(**uint8)(__ccgo_up(ip + 1))), Int32FromUint8(**(**uint8)(__ccgo_up(ip))))) +} + +func _mkptr6(tls *TLS, s uintptr, ip uintptr) { + var i int32 + var v2 uintptr + _, _ = i, v2 + i = int32(15) + for { + if !(i >= 0) { + break + } + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = _xdigits[Int32FromUint8(**(**uint8)(__ccgo_up(ip + uintptr(i))))&int32(15)] + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8('.') + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = _xdigits[Int32FromUint8(**(**uint8)(__ccgo_up(ip + uintptr(i))))>>int32(4)] + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = int8('.') + goto _1 + _1: + ; + i = i - 1 + } + Xstrcpy(tls, s, __ccgo_ts+1024) +} + +var _xdigits = [17]int8{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'} + +func _reverse_hosts(tls *TLS, buf uintptr, a uintptr, scopeid uint32, family int32) { + bp := tls.Alloc(1824) + defer tls.Free(1824) + var f, p, z, v1, v2 uintptr + var v4, v5 int32 + var v7 bool + var _ /* _buf at bp+512 */ [1032]uint8 + var _ /* _f at bp+1592 */ TFILE + var _ /* atmp at bp+1544 */ [16]uint8 + var _ /* iplit at bp+1560 */ Taddress + var _ /* line at bp+0 */ [512]int8 + _, _, _, _, _, _, _, _ = f, p, z, v1, v2, v4, v5, v7 + f = X__fopen_rb_ca(tls, __ccgo_ts+1033, bp+1592, bp+512, uint64(1032)) + if !(f != 0) { + return + } + if family == int32(PF_INET) { + Xmemcpy(tls, bp+1544+uintptr(12), a, uint64(4)) + Xmemcpy(tls, bp+1544, __ccgo_ts+1044, uint64(12)) + a = bp + 1544 + } + for Xfgets(tls, bp, int32(512), f) != 0 { + v1 = Xstrchr(tls, bp, int32('#')) + p = v1 + if v1 != 0 { + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = int8('\n') + **(**int8)(__ccgo_up(p)) = Int8FromInt32(0) + } + p = bp + for { + if v7 = **(**int8)(__ccgo_up(p)) != 0; v7 { + v4 = int32(**(**int8)(__ccgo_up(p))) + v5 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _6 + _6: + } + if !(v7 && !(v5 != 0)) { + break + } + goto _3 + _3: + ; + p = p + 1 + } + if !(**(**int8)(__ccgo_up(p)) != 0) { + continue + } + v1 = p + p = p + 1 + **(**int8)(__ccgo_up(v1)) = 0 + if X__lookup_ipliteral(tls, bp+1560, bp, PF_UNSPEC) <= 0 { + continue + } + if (**(**Taddress)(__ccgo_up(bp + 1560))).Ffamily == int32(PF_INET) { + Xmemcpy(tls, bp+1560+8+uintptr(12), bp+1560+8, uint64(4)) + Xmemcpy(tls, bp+1560+8, __ccgo_ts+1044, uint64(12)) + (**(**Taddress)(__ccgo_up(bp + 1560))).Fscopeid = uint32(0) + } + if Xmemcmp(tls, a, bp+1560+8, uint64(16)) != 0 || (**(**Taddress)(__ccgo_up(bp + 1560))).Fscopeid != scopeid { + continue + } + for { + if v7 = **(**int8)(__ccgo_up(p)) != 0; v7 { + v4 = int32(**(**int8)(__ccgo_up(p))) + v5 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _12 + _12: + } + if !(v7 && v5 != 0) { + break + } + goto _9 + _9: + ; + p = p + 1 + } + z = p + for { + if v7 = **(**int8)(__ccgo_up(z)) != 0; v7 { + v4 = int32(**(**int8)(__ccgo_up(z))) + v5 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _17 + _17: + } + if !(v7 && !(v5 != 0)) { + break + } + goto _14 + _14: + ; + z = z + 1 + } + **(**int8)(__ccgo_up(z)) = 0 + if int64(z)-int64(p) < int64(256) { + Xmemcpy(tls, buf, p, Uint64FromInt64(int64(z)-int64(p)+int64(1))) + break + } + } + X__fclose_ca(tls, f) +} + +func _reverse_services(tls *TLS, buf uintptr, port int32, dgram int32) { + bp := tls.Alloc(1408) + defer tls.Free(1408) + var f, p, v1, v2 uintptr + var svport uint64 + var v4, v5 int32 + var v7 bool + var _ /* _buf at bp+136 */ [1032]uint8 + var _ /* _f at bp+1168 */ TFILE + var _ /* line at bp+0 */ [128]int8 + var _ /* z at bp+128 */ uintptr + _, _, _, _, _, _, _, _ = f, p, svport, v1, v2, v4, v5, v7 + f = X__fopen_rb_ca(tls, __ccgo_ts+1057, bp+1168, bp+136, uint64(1032)) + if !(f != 0) { + return + } + for Xfgets(tls, bp, int32(128), f) != 0 { + v1 = Xstrchr(tls, bp, int32('#')) + p = v1 + if v1 != 0 { + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = int8('\n') + **(**int8)(__ccgo_up(p)) = Int8FromInt32(0) + } + p = bp + for { + if v7 = **(**int8)(__ccgo_up(p)) != 0; v7 { + v4 = int32(**(**int8)(__ccgo_up(p))) + v5 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _6 + _6: + } + if !(v7 && !(v5 != 0)) { + break + } + goto _3 + _3: + ; + p = p + 1 + } + if !(**(**int8)(__ccgo_up(p)) != 0) { + continue + } + v1 = p + p = p + 1 + **(**int8)(__ccgo_up(v1)) = 0 + svport = Xstrtoul(tls, p, bp+128, int32(10)) + if svport != Uint64FromInt32(port) || **(**uintptr)(__ccgo_up(bp + 128)) == p { + continue + } + if dgram != 0 && Xstrncmp(tls, **(**uintptr)(__ccgo_up(bp + 128)), __ccgo_ts+1071, uint64(4)) != 0 { + continue + } + if !(dgram != 0) && Xstrncmp(tls, **(**uintptr)(__ccgo_up(bp + 128)), __ccgo_ts+1076, uint64(4)) != 0 { + continue + } + if int64(p)-t__predefined_ptrdiff_t(bp) > int64(32) { + continue + } + Xmemcpy(tls, buf, bp, Uint64FromInt64(int64(p)-t__predefined_ptrdiff_t(bp))) + break + } + X__fclose_ca(tls, f) +} + +func _dns_parse_callback(tls *TLS, c uintptr, rr int32, data uintptr, len1 int32, packet uintptr, plen int32) (r int32) { + if rr != int32(RR_PTR) { + return 0 + } + if X__dn_expand(tls, packet, packet+uintptr(plen), data, c, int32(256)) <= 0 { + **(**int8)(__ccgo_up(c)) = 0 + } + return 0 +} + +func Xgetnameinfo(tls *TLS, sa uintptr, sl Tsocklen_t, node uintptr, nodelen Tsocklen_t, serv uintptr, servlen Tsocklen_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v sa=%v sl=%v node=%v nodelen=%v serv=%v servlen=%v flags=%v, (%v:)", tls, sa, sl, node, nodelen, serv, servlen, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(976) + defer tls.Free(976) + var a, p, p1, v1 uintptr + var af, port, qlen, rlen int32 + var scopeid uint32 + var _ /* buf at bp+78 */ [256]int8 + var _ /* num at bp+334 */ [13]int8 + var _ /* ptr at bp+0 */ [78]int8 + var _ /* query at bp+347 */ [96]uint8 + var _ /* reply at bp+443 */ [512]uint8 + var _ /* tmp at bp+955 */ [17]int8 + _, _, _, _, _, _, _, _, _ = a, af, p, p1, port, qlen, rlen, scopeid, v1 + af = Int32FromUint16((*Tsockaddr)(unsafe.Pointer(sa)).Fsa_family) + switch af { + case int32(PF_INET): + a = sa + 4 + if uint64(sl) < uint64(16) { + return -int32(6) + } + _mkptr4(tls, bp, a) + scopeid = uint32(0) + case int32(PF_INET6): + a = sa + 8 + if uint64(sl) < uint64(28) { + return -int32(6) + } + if Xmemcmp(tls, a, __ccgo_ts+1044, uint64(12)) != 0 { + _mkptr6(tls, bp, a) + } else { + _mkptr4(tls, bp, a+uintptr(12)) + } + scopeid = (*Tsockaddr_in6)(unsafe.Pointer(sa)).Fsin6_scope_id + default: + return -int32(6) + } + if node != 0 && nodelen != 0 { + (**(**[256]int8)(__ccgo_up(bp + 78)))[0] = 0 + if !(flags&Int32FromInt32(NI_NUMERICHOST) != 0) { + _reverse_hosts(tls, bp+78, a, scopeid, af) + } + if !(**(**int8)(__ccgo_up(bp + 78)) != 0) && !(flags&Int32FromInt32(NI_NUMERICHOST) != 0) { + qlen = X__res_mkquery(tls, 0, bp, int32(1), int32(RR_PTR), uintptr(0), 0, uintptr(0), bp+347, int32(96)) + (**(**[96]uint8)(__ccgo_up(bp + 347)))[int32(3)] = uint8(0) /* don't need AD flag */ + rlen = X__res_send(tls, bp+347, qlen, bp+443, int32(512)) + (**(**[256]int8)(__ccgo_up(bp + 78)))[0] = 0 + if rlen > 0 { + if Uint64FromInt32(rlen) > uint64(512) { + rlen = int32(512) + } + X__dns_parse(tls, bp+443, rlen, __ccgo_fp(_dns_parse_callback), bp+78) + } + } + if !(**(**int8)(__ccgo_up(bp + 78)) != 0) { + if flags&int32(NI_NAMEREQD) != 0 { + return -int32(2) + } + Xinet_ntop(tls, af, a, bp+78, uint32(256)) + if scopeid != 0 { + p = uintptr(0) + if !(flags&Int32FromInt32(NI_NUMERICSCOPE) != 0) && (Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1)))&int32(0xc0) == int32(0x80) || Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xff) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1)))&int32(0xf) == int32(0x2)) { + p = Xif_indextoname(tls, scopeid, bp+955+uintptr(1)) + } + if !(p != 0) { + p = _itoa(tls, bp+334, scopeid) + } + p = p - 1 + v1 = p + **(**int8)(__ccgo_up(v1)) = int8('%') + Xstrcat(tls, bp+78, p) + } + } + if _strlen(tls, bp+78) >= uint64(nodelen) { + return -int32(12) + } + Xstrcpy(tls, node, bp+78) + } + if serv != 0 && servlen != 0 { + p1 = bp + 78 + port = Int32FromUint16(Xntohs(tls, (*Tsockaddr_in)(unsafe.Pointer(sa)).Fsin_port)) + (**(**[256]int8)(__ccgo_up(bp + 78)))[0] = 0 + if !(flags&Int32FromInt32(NI_NUMERICSERV) != 0) { + _reverse_services(tls, bp+78, port, flags&int32(NI_DGRAM)) + } + if !(**(**int8)(__ccgo_up(p1)) != 0) { + p1 = _itoa(tls, bp+334, Uint32FromInt32(port)) + } + if _strlen(tls, p1) >= uint64(servlen) { + return -int32(12) + } + Xstrcpy(tls, serv, p1) + } + return 0 +} + +func Xgetpeername(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_getpeername) + _ = int32(__SC_getpeername) + v2 = int64(fd) + v3 = int64(addr) + v4 = int64(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func Xgetservbyname(tls *TLS, name uintptr, prots uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v prots=%v, (%v:)", tls, name, prots, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+0 */ uintptr + if Xgetservbyname_r(tls, name, prots, uintptr(unsafe.Pointer(&_se)), uintptr(unsafe.Pointer(&_buf3)), uint64(16), bp) != 0 { + return uintptr(0) + } + return uintptr(unsafe.Pointer(&_se)) +} + +var _se Tservent + +var _buf3 [2]uintptr + +const ALIGN = 0 + +func Xgetservbyname_r(tls *TLS, name uintptr, prots uintptr, se uintptr, buf uintptr, buflen Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v prots=%v se=%v buf=%v buflen=%v res=%v, (%v:)", tls, name, prots, se, buf, buflen, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var align, cnt, proto int32 + var v1 uintptr + var _ /* end at bp+8 */ uintptr + var _ /* servs at bp+0 */ [2]Tservice + _, _, _, _ = align, cnt, proto, v1 + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + /* Don't treat numeric port number strings as service records. */ + **(**uintptr)(__ccgo_up(bp + 8)) = __ccgo_ts + Xstrtoul(tls, name, bp+8, int32(10)) + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != 0) { + return int32(ENOENT) + } + /* Align buffer */ + align = Int32FromUint64(-uint64(buf) & (Uint64FromInt64(16) - Uint64FromInt64(8) - Uint64FromInt32(1))) + if buflen < Uint64FromInt32(2)*Uint64FromInt64(8)+Uint64FromInt32(align) { + return int32(ERANGE) + } + buf = buf + uintptr(align) + if !(prots != 0) { + proto = 0 + } else { + if !(Xstrcmp(tls, prots, __ccgo_ts+1081) != 0) { + proto = int32(IPPROTO_TCP) + } else { + if !(Xstrcmp(tls, prots, __ccgo_ts+1085) != 0) { + proto = int32(IPPROTO_UDP) + } else { + return int32(EINVAL) + } + } + } + cnt = X__lookup_serv(tls, bp, name, proto, 0, 0) + if cnt < 0 { + switch cnt { + case -int32(10): + fallthrough + case -int32(11): + return int32(ENOMEM) + default: + return int32(ENOENT) + } + } + (*Tservent)(unsafe.Pointer(se)).Fs_name = name + (*Tservent)(unsafe.Pointer(se)).Fs_aliases = buf + **(**uintptr)(__ccgo_up((*Tservent)(unsafe.Pointer(se)).Fs_aliases)) = (*Tservent)(unsafe.Pointer(se)).Fs_name + **(**uintptr)(__ccgo_up((*Tservent)(unsafe.Pointer(se)).Fs_aliases + 1*8)) = uintptr(0) + (*Tservent)(unsafe.Pointer(se)).Fs_port = Int32FromUint16(Xhtons(tls, (**(**[2]Tservice)(__ccgo_up(bp)))[0].Fport)) + if Int32FromUint8((**(**[2]Tservice)(__ccgo_up(bp)))[0].Fproto) == int32(IPPROTO_TCP) { + v1 = __ccgo_ts + 1081 + } else { + v1 = __ccgo_ts + 1085 + } + (*Tservent)(unsafe.Pointer(se)).Fs_proto = v1 + **(**uintptr)(__ccgo_up(res)) = se + return 0 +} + +func Xgetsockname(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_getsockname) + _ = int32(__SC_getsockname) + v2 = int64(fd) + v3 = int64(addr) + v4 = int64(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func Xgetsockopt(tls *TLS, fd int32, level int32, optname int32, optval uintptr, optlen uintptr) (r2 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v level=%v optname=%v optval=%v optlen=%v, (%v:)", tls, fd, level, optname, optval, optlen, origin(2)) + defer func() { trc("-> %v", r2) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var r, v8 int64 + var r1, v1 int32 + var tv uintptr + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + var _ /* tv32 at bp+8 */ [2]int64 + _, _, _, _, _, _, _, _, _, _, _ = r, r1, tv, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_getsockopt) + _ = int32(__SC_getsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(optval) + v6 = int64(optlen) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + r1 = int32(v8) + if r1 == -int32(ENOPROTOOPT) { + switch level { + case int32(SOL_SOCKET): + switch optname { + case int32(SO_RCVTIMEO): + fallthrough + case int32(SO_SNDTIMEO): + if true { + break + } + if uint64(**(**Tsocklen_t)(__ccgo_up(optlen))) < uint64(16) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + if optname == int32(SO_RCVTIMEO) { + optname = int32(SO_RCVTIMEO_OLD) + } + if optname == int32(SO_SNDTIMEO) { + optname = int32(SO_SNDTIMEO_OLD) + } + *(*[1]Tsocklen_t)(unsafe.Pointer(bp)) = [1]Tsocklen_t{ + 0: uint32(16), + } + v1 = int32(SYS_getsockopt) + _ = int32(__SC_getsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(bp + 8) + v6 = int64(bp) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _18 + } + v8 = r + goto _18 + _18: + r1 = int32(v8) + if r1 < 0 { + break + } + tv = optval + (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec = (**(**[2]int64)(__ccgo_up(bp + 8)))[0] + (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec = (**(**[2]int64)(__ccgo_up(bp + 8)))[int32(1)] + **(**Tsocklen_t)(__ccgo_up(optlen)) = uint32(16) + case int32(SO_TIMESTAMP): + fallthrough + case int32(SO_TIMESTAMPNS): + if true { + break + } + if optname == int32(SO_TIMESTAMP) { + optname = int32(SO_TIMESTAMP_OLD) + } + if optname == int32(SO_TIMESTAMPNS) { + optname = int32(SO_TIMESTAMPNS_OLD) + } + v1 = int32(SYS_getsockopt) + _ = int32(__SC_getsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(optval) + v6 = int64(optlen) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _27 + } + v8 = r + goto _27 + _27: + r1 = int32(v8) + break + } + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r1))) +} + +func X__h_errno_location(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Fstack != 0) { + return uintptr(unsafe.Pointer(&Xh_errno)) + } + return uintptr(___get_tp(tls)) + 160 +} + +func Xherror(tls *TLS, msg uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v, (%v:)", tls, msg, origin(2)) + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1, v2 uintptr + _, _ = v1, v2 + if msg != 0 { + v1 = msg + } else { + v1 = __ccgo_ts + } + if msg != 0 { + v2 = __ccgo_ts + 355 + } else { + v2 = __ccgo_ts + } + Xfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), __ccgo_ts+1089, VaList(bp+8, v1, v2, Xhstrerror(tls, **(**int32)(__ccgo_up(X__h_errno_location(tls)))))) +} + +var _msgs1 = [84]int8{'H', 'o', 's', 't', ' ', 'n', 'o', 't', ' ', 'f', 'o', 'u', 'n', 'd', 0, 'T', 'r', 'y', ' ', 'a', 'g', 'a', 'i', 'n', 0, 'N', 'o', 'n', '-', 'r', 'e', 'c', 'o', 'v', 'e', 'r', 'a', 'b', 'l', 'e', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'A', 'd', 'd', 'r', 'e', 's', 's', ' ', 'n', 'o', 't', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e', 0, 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r'} + +func Xhstrerror(tls *TLS, ecode int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ecode=%v, (%v:)", tls, ecode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + _ = s + s = uintptr(unsafe.Pointer(&_msgs1)) + ecode = ecode - 1 + for { + if !(ecode != 0 && **(**int8)(__ccgo_up(s)) != 0) { + break + } + for { + if !(**(**int8)(__ccgo_up(s)) != 0) { + break + } + goto _2 + _2: + ; + s = s + 1 + } + goto _1 + _1: + ; + ecode = ecode - 1 + s = s + 1 + } + if !(**(**int8)(__ccgo_up(s)) != 0) { + s = s + 1 + } + return X__lctrans_cur(tls, s) +} + +func Xhtonl(tls *TLS, n Tuint32_t) (r Tuint32_t) { + if __ccgo_strace { + trc("tls=%v n=%v, (%v:)", tls, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var u struct { + Fc [0]int8 + Fi int32 + } + var v1 uint32 + var v2, v3 Tuint32_t + _, _, _, _ = u, v1, v2, v3 + u = *(*struct { + Fc [0]int8 + Fi int32 + })(unsafe.Pointer(&struct{ f int32 }{f: int32(1)})) + if *(*int8)(unsafe.Pointer(&u)) != 0 { + v2 = n + v3 = v2>>int32(24) | v2>>int32(8)&uint32(0xff00) | v2< %v", r) }() + } + var u struct { + Fc [0]int8 + Fi int32 + } + var v1 int32 + var v2, v3 Tuint16_t + _, _, _, _ = u, v1, v2, v3 + u = *(*struct { + Fc [0]int8 + Fi int32 + })(unsafe.Pointer(&struct{ f int32 }{f: int32(1)})) + if *(*int8)(unsafe.Pointer(&u)) != 0 { + v2 = n + v3 = Uint16FromInt32(Int32FromUint16(v2)<>int32(8)) + goto _4 + _4: + v1 = Int32FromUint16(v3) + } else { + v1 = Int32FromUint16(n) + } + return Uint16FromInt32(v1) +} + +func Xif_freenameindex(tls *TLS, idx uintptr) { + if __ccgo_strace { + trc("tls=%v idx=%v, (%v:)", tls, idx, origin(2)) + } + Xfree(tls, idx) +} + +func Xif_indextoname(tls *TLS, index uint32, name uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v index=%v name=%v, (%v:)", tls, index, name, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var fd, r, v1 int32 + var _ /* ifr at bp+0 */ Tifreq + _, _, _ = fd, r, v1 + v1 = Xsocket(tls, int32(PF_LOCAL), Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC), 0) + fd = v1 + if v1 < 0 { + return uintptr(0) + } + *(*int32)(unsafe.Pointer(bp + 16)) = Int32FromUint32(index) + r = Xioctl(tls, fd, int32(SIOCGIFNAME), VaList(bp+48, bp)) + X__syscall1(tls, int64(SYS_close), int64(fd)) + if r < 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENODEV) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENXIO) + } + return uintptr(0) + } + return Xstrncpy(tls, name, bp, uint64(IF_NAMESIZE)) +} + +type Tifnamemap = struct { + Fhash_next uint32 + Findex uint32 + Fnamelen uint8 + Fname [16]int8 +} + +type Tifnameindexctx = struct { + Fnum uint32 + Fallocated uint32 + Fstr_bytes uint32 + Flist uintptr + Fhash [64]uint32 +} + +func _netlink_msg_to_nameindex(tls *TLS, pctx uintptr, h uintptr) (r int32) { + var a Tsize_t + var bucket, index, namelen, type1 int32 + var ctx, ifa, ifi, map1, rta uintptr + var i, v2 uint32 + _, _, _, _, _, _, _, _, _, _, _, _ = a, bucket, ctx, i, ifa, ifi, index, map1, namelen, rta, type1, v2 + ctx = pctx + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(RTM_NEWLINK) { + ifi = h + UintptrFromInt64(16) + index = (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_index + type1 = int32(IFLA_IFNAME) + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(16)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + } else { + ifa = h + UintptrFromInt64(16) + index = Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index) + type1 = int32(IFA_LABEL) + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(8)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + } + for { + if !(Uint64FromInt64(int64(h+uintptr((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len))-int64(rta)) >= uint64(4)) { + break + } + if Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_type) != type1 { + goto _1 + } + namelen = Int32FromUint64(uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len) - uint64(4) - uint64(1)) + if namelen > int32(IF_NAMESIZE) { + return 0 + } + /* suppress duplicates */ + bucket = index % int32(IFADDRS_HASH_SIZE) + i = **(**uint32)(__ccgo_up(ctx + 24 + uintptr(bucket)*4)) + for i != 0 { + map1 = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist + uintptr(i-uint32(1))*28 + if (*Tifnamemap)(unsafe.Pointer(map1)).Findex == Uint32FromInt32(index) && Int32FromUint8((*Tifnamemap)(unsafe.Pointer(map1)).Fnamelen) == namelen && Xmemcmp(tls, map1+9, rta+UintptrFromInt64(4), Uint64FromInt32(namelen)) == 0 { + return 0 + } + i = (*Tifnamemap)(unsafe.Pointer(map1)).Fhash_next + } + if (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum >= (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fallocated { + if (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fallocated != 0 { + v2 = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fallocated*uint32(2) + uint32(1) + } else { + v2 = uint32(8) + } + a = uint64(v2) + if a > Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt64(28) { + return -int32(1) + } + map1 = Xrealloc(tls, (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist, a*uint64(28)) + if !(map1 != 0) { + return -int32(1) + } + (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist = map1 + (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fallocated = uint32(a) + } + map1 = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist + uintptr((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum)*28 + (*Tifnamemap)(unsafe.Pointer(map1)).Findex = Uint32FromInt32(index) + (*Tifnamemap)(unsafe.Pointer(map1)).Fnamelen = Uint8FromInt32(namelen) + Xmemcpy(tls, map1+9, rta+UintptrFromInt64(4), Uint64FromInt32(namelen)) + **(**uint32)(__ccgo_up(ctx + 8)) += Uint32FromInt32(namelen + int32(1)) + (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum + 1 + (*Tifnamemap)(unsafe.Pointer(map1)).Fhash_next = **(**uint32)(__ccgo_up(ctx + 24 + uintptr(bucket)*4)) + **(**uint32)(__ccgo_up(ctx + 24 + uintptr(bucket)*4)) = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum + return 0 + goto _1 + _1: + ; + rta = rta + uintptr((Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_len)+Int32FromInt32(3)) & ^Int32FromInt32(3)) + } + return 0 +} + +func Xif_nameindex(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(288) + defer tls.Free(288) + var ctx, d, ifs, p, s, v2 uintptr + var i int32 + var _ /* _ctx at bp+0 */ Tifnameindexctx + var _ /* cs at bp+280 */ int32 + _, _, _, _, _, _, _ = ctx, d, i, ifs, p, s, v2 + ctx = bp + ifs = uintptr(0) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+280) + Xmemset(tls, ctx, 0, uint64(280)) + if X__rtnetlink_enumerate(tls, PF_UNSPEC, int32(PF_INET), __ccgo_fp(_netlink_msg_to_nameindex), ctx) < 0 { + goto err + } + ifs = Xmalloc(tls, uint64((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum+Uint32FromInt32(1))*16+uint64((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fstr_bytes)) + if !(ifs != 0) { + goto err + } + p = ifs + uintptr((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum)*16 + UintptrFromInt32(1)*16 + i = Int32FromUint32((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum) + d = ifs + s = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist + for { + if !(i != 0) { + break + } + (*Tif_nameindex)(unsafe.Pointer(d)).Fif_index = (*Tifnamemap)(unsafe.Pointer(s)).Findex + (*Tif_nameindex)(unsafe.Pointer(d)).Fif_name = p + Xmemcpy(tls, p, s+9, uint64((*Tifnamemap)(unsafe.Pointer(s)).Fnamelen)) + p = p + uintptr((*Tifnamemap)(unsafe.Pointer(s)).Fnamelen) + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = 0 + goto _1 + _1: + ; + i = i - 1 + s += 28 + d += 16 + } + (*Tif_nameindex)(unsafe.Pointer(d)).Fif_index = uint32(0) + (*Tif_nameindex)(unsafe.Pointer(d)).Fif_name = uintptr(0) + goto err +err: + ; + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 280)), uintptr(0)) + Xfree(tls, (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOBUFS) + return ifs +} + +func Xif_nametoindex(tls *TLS, name uintptr) (r1 uint32) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var fd, r, v1 int32 + var _ /* ifr at bp+0 */ Tifreq + _, _, _ = fd, r, v1 + v1 = Xsocket(tls, int32(PF_LOCAL), Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC), 0) + fd = v1 + if v1 < 0 { + return uint32(0) + } + Xstrncpy(tls, bp, name, uint64(16)) + r = Xioctl(tls, fd, int32(SIOCGIFINDEX), VaList(bp+48, bp)) + X__syscall1(tls, int64(SYS_close), int64(fd)) + if r < 0 { + v1 = 0 + } else { + v1 = *(*int32)(unsafe.Pointer(bp + 16)) + } + return Uint32FromInt32(v1) +} + +func Xinet_addr(tls *TLS, p uintptr) (r Tin_addr_t) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* a at bp+0 */ Tin_addr + if !(X__inet_aton(tls, p, bp) != 0) { + return Uint32FromInt32(-Int32FromInt32(1)) + } + return (**(**Tin_addr)(__ccgo_up(bp))).Fs_addr +} + +func X__inet_aton(tls *TLS, s0 uintptr, dest uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s0=%v dest=%v, (%v:)", tls, s0, dest, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var d, s uintptr + var i int32 + var _ /* a at bp+0 */ [4]uint64 + var _ /* z at bp+32 */ uintptr + _, _, _ = d, i, s + s = s0 + d = dest + **(**[4]uint64)(__ccgo_up(bp)) = [4]uint64{} + i = 0 + for { + if !(i < int32(4)) { + break + } + (**(**[4]uint64)(__ccgo_up(bp)))[i] = Xstrtoul(tls, s, bp+32, 0) + if **(**uintptr)(__ccgo_up(bp + 32)) == s || **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)))) != 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32))))) != int32('.') || !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return 0 + } + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)))) != 0) { + break + } + s = **(**uintptr)(__ccgo_up(bp + 32)) + uintptr(1) + goto _1 + _1: + ; + i = i + 1 + } + if i == int32(4) { + return 0 + } + switch i { + case 0: + (**(**[4]uint64)(__ccgo_up(bp)))[int32(1)] = (**(**[4]uint64)(__ccgo_up(bp)))[0] & uint64(0xffffff) + **(**uint64)(__ccgo_up(bp)) >>= uint64(24) + fallthrough + case int32(1): + (**(**[4]uint64)(__ccgo_up(bp)))[int32(2)] = (**(**[4]uint64)(__ccgo_up(bp)))[int32(1)] & uint64(0xffff) + **(**uint64)(__ccgo_up(bp + 1*8)) >>= uint64(16) + fallthrough + case int32(2): + (**(**[4]uint64)(__ccgo_up(bp)))[int32(3)] = (**(**[4]uint64)(__ccgo_up(bp)))[int32(2)] & uint64(0xff) + **(**uint64)(__ccgo_up(bp + 2*8)) >>= uint64(8) + } + i = 0 + for { + if !(i < int32(4)) { + break + } + if (**(**[4]uint64)(__ccgo_up(bp)))[i] > uint64(255) { + return 0 + } + **(**uint8)(__ccgo_up(d + uintptr(i))) = uint8((**(**[4]uint64)(__ccgo_up(bp)))[i]) + goto _2 + _2: + ; + i = i + 1 + } + return int32(1) +} + +func Xinet_aton(tls *TLS, s0 uintptr, dest uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s0=%v dest=%v, (%v:)", tls, s0, dest, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__inet_aton(tls, s0, dest) +} + +func Xinet_network(tls *TLS, p uintptr) (r Tin_addr_t) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xntohl(tls, Xinet_addr(tls, p)) +} + +func Xinet_makeaddr(tls *TLS, n Tin_addr_t, h Tin_addr_t) (r Tin_addr) { + if __ccgo_strace { + trc("tls=%v n=%v h=%v, (%v:)", tls, n, h, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n < uint32(256) { + h = h | n< %v", r) }() + } + var h Tuint32_t + _ = h + h = in.Fs_addr + if h>>int32(24) < uint32(128) { + return h & uint32(0xffffff) + } + if h>>int32(24) < uint32(192) { + return h & uint32(0xffff) + } + return h & uint32(0xff) +} + +func Xinet_netof(tls *TLS, in Tin_addr) (r Tin_addr_t) { + if __ccgo_strace { + trc("tls=%v in=%v, (%v:)", tls, in, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h Tuint32_t + _ = h + h = in.Fs_addr + if h>>int32(24) < uint32(128) { + return h >> int32(24) + } + if h>>int32(24) < uint32(192) { + return h >> int32(16) + } + return h >> int32(8) +} + +func Xinet_ntoa(tls *TLS, _in Tin_addr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v _in=%v, (%v:)", tls, _in, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + *(*Tin_addr)(unsafe.Pointer(bp)) = _in + var a uintptr + _ = a + a = bp + Xsnprintf(tls, uintptr(unsafe.Pointer(&_buf4)), uint64(16), __ccgo_ts+1097, VaList(bp+16, Int32FromUint8(**(**uint8)(__ccgo_up(a))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 1))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 2))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 3))))) + return uintptr(unsafe.Pointer(&_buf4)) +} + +var _buf4 [16]int8 + +func Xinet_ntop(tls *TLS, af int32, a0 uintptr, s uintptr, l Tsocklen_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v af=%v a0=%v s=%v l=%v, (%v:)", tls, af, a0, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(192) + defer tls.Free(192) + var a uintptr + var best, i, j, max, v2 int32 + var v3 int8 + var _ /* buf at bp+0 */ [100]int8 + _, _, _, _, _, _, _ = a, best, i, j, max, v2, v3 + a = a0 + switch af { + case int32(PF_INET): + if Uint32FromInt32(Xsnprintf(tls, s, uint64(l), __ccgo_ts+1097, VaList(bp+112, Int32FromUint8(**(**uint8)(__ccgo_up(a))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 1))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 2))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 3)))))) < l { + return s + } + case int32(PF_INET6): + if Xmemcmp(tls, a, __ccgo_ts+1044, uint64(12)) != 0 { + Xsnprintf(tls, bp, uint64(100), __ccgo_ts+1109, VaList(bp+112, int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 1))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 2)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 3))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 4)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 5))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 6)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 7))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 8)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 9))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 10)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 11))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 12)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 13))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 14)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 15))))) + } else { + Xsnprintf(tls, bp, uint64(100), __ccgo_ts+1133, VaList(bp+112, int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 1))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 2)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 3))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 4)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 5))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 6)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 7))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 8)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 9))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 10)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 11))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 12))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 13))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 14))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 15))))) + } + /* Replace longest /(^0|:)[:0]{2,}/ with "::" */ + v2 = Int32FromInt32(0) + best = v2 + i = v2 + max = Int32FromInt32(2) + for { + if !((**(**[100]int8)(__ccgo_up(bp)))[i] != 0) { + break + } + if i != 0 && int32((**(**[100]int8)(__ccgo_up(bp)))[i]) != int32(':') { + goto _1 + } + j = Int32FromUint64(Xstrspn(tls, bp+uintptr(i), __ccgo_ts+1163)) + if j > max { + best = i + max = j + } + goto _1 + _1: + ; + i = i + 1 + } + if max > int32(3) { + v3 = Int8FromUint8(':') + (**(**[100]int8)(__ccgo_up(bp)))[best+int32(1)] = v3 + (**(**[100]int8)(__ccgo_up(bp)))[best] = v3 + Xmemmove(tls, bp+uintptr(best)+uintptr(2), bp+uintptr(best)+uintptr(max), Uint64FromInt32(i-best-max+int32(1))) + } + if _strlen(tls, bp) < uint64(l) { + Xstrcpy(tls, s, bp) + return s + } + default: + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EAFNOSUPPORT) + return uintptr(0) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOSPC) + return uintptr(0) +} + +func _hexval(tls *TLS, c uint32) (r int32) { + if c-uint32('0') < uint32(10) { + return Int32FromUint32(c - uint32('0')) + } + c = c | uint32(32) + if c-uint32('a') < uint32(6) { + return Int32FromUint32(c - uint32('a') + uint32(10)) + } + return -int32(1) +} + +func Xinet_pton(tls *TLS, af int32, s uintptr, a0 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v af=%v s=%v a0=%v, (%v:)", tls, af, s, a0, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var a, v4 uintptr + var brk, d, i, j, need_v4, v, v3, v9 int32 + var v5 bool + var _ /* ip at bp+0 */ [8]Tuint16_t + _, _, _, _, _, _, _, _, _, _, _ = a, brk, d, i, j, need_v4, v, v3, v4, v5, v9 + a = a0 + brk = -int32(1) + need_v4 = 0 + if af == int32(PF_INET) { + i = 0 + for { + if !(i < int32(4)) { + break + } + v3 = Int32FromInt32(0) + j = v3 + v = v3 + for { + if !(j < int32(3) && BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s + uintptr(j))))-uint32('0') < uint32(10)) != 0) { + break + } + v = int32(10)*v + int32(**(**int8)(__ccgo_up(s + uintptr(j)))) - int32('0') + goto _2 + _2: + ; + j = j + 1 + } + if j == 0 || j > int32(1) && int32(**(**int8)(__ccgo_up(s))) == int32('0') || v > int32(255) { + return 0 + } + **(**uint8)(__ccgo_up(a + uintptr(i))) = Uint8FromInt32(v) + if int32(**(**int8)(__ccgo_up(s + uintptr(j)))) == 0 && i == int32(3) { + return int32(1) + } + if int32(**(**int8)(__ccgo_up(s + uintptr(j)))) != int32('.') { + return 0 + } + s = s + uintptr(j+int32(1)) + goto _1 + _1: + ; + i = i + 1 + } + return 0 + } else { + if af != int32(PF_INET6) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EAFNOSUPPORT) + return -int32(1) + } + } + if v5 = int32(**(**int8)(__ccgo_up(s))) == int32(':'); v5 { + s = s + 1 + v4 = s + } + if v5 && int32(**(**int8)(__ccgo_up(v4))) != int32(':') { + return 0 + } + i = 0 + for { + if int32(**(**int8)(__ccgo_up(s))) == int32(':') && brk < 0 { + brk = i + (**(**[8]Tuint16_t)(__ccgo_up(bp)))[i&int32(7)] = uint16(0) + s = s + 1 + v4 = s + if !(**(**int8)(__ccgo_up(v4)) != 0) { + break + } + if i == int32(7) { + return 0 + } + goto _6 + } + v3 = Int32FromInt32(0) + j = v3 + v = v3 + for { + if v5 = j < int32(4); v5 { + v9 = _hexval(tls, Uint32FromInt8(**(**int8)(__ccgo_up(s + uintptr(j))))) + d = v9 + } + if !(v5 && v9 >= 0) { + break + } + v = int32(16)*v + d + goto _8 + _8: + ; + j = j + 1 + } + if j == 0 { + return 0 + } + (**(**[8]Tuint16_t)(__ccgo_up(bp)))[i&int32(7)] = Uint16FromInt32(v) + if !(**(**int8)(__ccgo_up(s + uintptr(j))) != 0) && (brk >= 0 || i == int32(7)) { + break + } + if i == int32(7) { + return 0 + } + if int32(**(**int8)(__ccgo_up(s + uintptr(j)))) != int32(':') { + if int32(**(**int8)(__ccgo_up(s + uintptr(j)))) != int32('.') || i < int32(6) && brk < 0 { + return 0 + } + need_v4 = int32(1) + i = i + 1 + (**(**[8]Tuint16_t)(__ccgo_up(bp)))[i&int32(7)] = uint16(0) + break + } + s = s + uintptr(j+int32(1)) + goto _6 + _6: + ; + i = i + 1 + } + if brk >= 0 { + Xmemmove(tls, bp+uintptr(brk)*2+uintptr(7)*2-uintptr(i)*2, bp+uintptr(brk)*2, Uint64FromInt32(int32(2)*(i+int32(1)-brk))) + j = 0 + for { + if !(j < int32(7)-i) { + break + } + (**(**[8]Tuint16_t)(__ccgo_up(bp)))[brk+j] = uint16(0) + goto _12 + _12: + ; + j = j + 1 + } + } + j = 0 + for { + if !(j < int32(8)) { + break + } + v4 = a + a = a + 1 + **(**uint8)(__ccgo_up(v4)) = Uint8FromInt32(Int32FromUint16((**(**[8]Tuint16_t)(__ccgo_up(bp)))[j]) >> int32(8)) + v4 = a + a = a + 1 + **(**uint8)(__ccgo_up(v4)) = uint8((**(**[8]Tuint16_t)(__ccgo_up(bp)))[j]) + goto _13 + _13: + ; + j = j + 1 + } + if need_v4 != 0 && Xinet_pton(tls, int32(PF_INET), s, a-uintptr(4)) <= 0 { + return 0 + } + return int32(1) +} + +func Xlisten(tls *TLS, fd int32, backlog int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v backlog=%v, (%v:)", tls, fd, backlog, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_listen) + _ = int32(__SC_listen) + v2 = int64(fd) + v3 = int64(backlog) + v4 = int64(Int32FromInt32(0)) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func X__lookup_ipliteral(tls *TLS, buf uintptr, name uintptr, family int32) (r int32) { + if __ccgo_strace { + trc("tls=%v buf=%v name=%v family=%v, (%v:)", tls, buf, name, family, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(96) + defer tls.Free(96) + var p, v1 uintptr + var scopeid uint64 + var _ /* a4 at bp+0 */ Tin_addr + var _ /* a6 at bp+4 */ Tin6_addr + var _ /* tmp at bp+20 */ [64]int8 + var _ /* z at bp+88 */ uintptr + _, _, _ = p, scopeid, v1 + if X__inet_aton(tls, name, bp) > 0 { + if family == int32(PF_INET6) { /* wrong family */ + return -int32(5) + } + Xmemcpy(tls, buf+8, bp, uint64(4)) + (**(**Taddress)(__ccgo_up(buf))).Ffamily = int32(PF_INET) + (**(**Taddress)(__ccgo_up(buf))).Fscopeid = uint32(0) + return int32(1) + } + p = Xstrchr(tls, name, int32('%')) + scopeid = uint64(0) + if p != 0 && int64(p)-int64(name) < int64(64) { + Xmemcpy(tls, bp+20, name, Uint64FromInt64(int64(p)-int64(name))) + (**(**[64]int8)(__ccgo_up(bp + 20)))[int64(p)-int64(name)] = 0 + name = bp + 20 + } + if Xinet_pton(tls, int32(PF_INET6), name, bp+4) <= 0 { + return 0 + } + if family == int32(PF_INET) { /* wrong family */ + return -int32(5) + } + Xmemcpy(tls, buf+8, bp+4, uint64(16)) + (**(**Taddress)(__ccgo_up(buf))).Ffamily = int32(PF_INET6) + if p != 0 { + p = p + 1 + v1 = p + if BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(v1)))-uint32('0') < uint32(10)) != 0 { + scopeid = Xstrtoull(tls, p, bp+88, int32(10)) + } else { + **(**uintptr)(__ccgo_up(bp + 88)) = p - uintptr(1) + } + if **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 88)))) != 0 { + if !(Int32FromUint8(**(**Tuint8_t)(__ccgo_up(bp + 4))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(bp + 4 + 1)))&int32(0xc0) == int32(0x80)) && !(Int32FromUint8(**(**Tuint8_t)(__ccgo_up(bp + 4))) == int32(0xff) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(bp + 4 + 1)))&int32(0xf) == int32(0x2)) { + return -int32(2) + } + scopeid = uint64(Xif_nametoindex(tls, p)) + if !(scopeid != 0) { + return -int32(2) + } + } + if scopeid > uint64(0xffffffff) { + return -int32(2) + } + } + (**(**Taddress)(__ccgo_up(buf))).Fscopeid = uint32(scopeid) + return int32(1) +} + +const ABUF_SIZE = 4800 +const DAS_MATCHINGLABEL = 268435456 +const DAS_MATCHINGSCOPE = 536870912 +const DAS_ORDER_SHIFT = 0 +const DAS_PREC_SHIFT = 20 +const DAS_PREFIX_SHIFT = 8 +const DAS_SCOPE_SHIFT = 16 +const DAS_USABLE = 1073741824 +const RR_A = 1 +const RR_AAAA = 28 +const RR_CNAME = 5 + +func _is_valid_hostname(tls *TLS, host uintptr) (r int32) { + var s uintptr + _ = s + if Xstrnlen(tls, host, uint64(255))-uint64(1) >= uint64(254) || Xmbstowcs(tls, uintptr(0), host, uint64(0)) == Uint64FromInt32(-Int32FromInt32(1)) { + return 0 + } + s = host + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(s))) >= int32(0x80) || Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('.') || Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('-') || Xisalnum(tls, Int32FromUint8(**(**uint8)(__ccgo_up(s)))) != 0) { + break + } + goto _1 + _1: + ; + s = s + 1 + } + return BoolInt32(!(**(**uint8)(__ccgo_up(s)) != 0)) +} + +func _name_from_null(tls *TLS, buf uintptr, name uintptr, family int32, flags int32) (r int32) { + var cnt, v1 int32 + _, _ = cnt, v1 + cnt = 0 + if name != 0 { + return 0 + } + if flags&int32(AI_PASSIVE) != 0 { + if family != int32(PF_INET6) { + v1 = cnt + cnt = cnt + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = Taddress{ + Ffamily: int32(PF_INET), + } + } + if family != int32(PF_INET) { + v1 = cnt + cnt = cnt + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = Taddress{ + Ffamily: int32(PF_INET6), + } + } + } else { + if family != int32(PF_INET6) { + v1 = cnt + cnt = cnt + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = Taddress{ + Ffamily: int32(PF_INET), + Faddr: [16]Tuint8_t{ + 0: uint8(127), + 3: uint8(1), + }, + } + } + if family != int32(PF_INET) { + v1 = cnt + cnt = cnt + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = Taddress{ + Ffamily: int32(PF_INET6), + Faddr: [16]Tuint8_t{ + 15: uint8(1), + }, + } + } + } + return cnt +} + +func _name_from_numeric(tls *TLS, buf uintptr, name uintptr, family int32) (r int32) { + return X__lookup_ipliteral(tls, buf, name, family) +} + +func _name_from_hosts(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) (r int32) { + bp := tls.Alloc(1776) + defer tls.Free(1776) + var badfam, cnt, have_canon, v5, v6, v8, v9 int32 + var f, p, z, v1, v2 uintptr + var l Tsize_t + var v11, v12 bool + var _ /* _buf at bp+512 */ [1032]uint8 + var _ /* _f at bp+1544 */ TFILE + var _ /* line at bp+0 */ [512]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = badfam, cnt, f, have_canon, l, p, z, v1, v11, v12, v2, v5, v6, v8, v9 + l = _strlen(tls, name) + cnt = 0 + badfam = 0 + have_canon = 0 + f = X__fopen_rb_ca(tls, __ccgo_ts+1033, bp+1544, bp+512, uint64(1032)) + if !(f != 0) { + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(ENOENT): + fallthrough + case int32(ENOTDIR): + fallthrough + case int32(EACCES): + return 0 + default: + return -int32(11) + } + } + for Xfgets(tls, bp, int32(512), f) != 0 && cnt < int32(MAXADDRS) { + v1 = Xstrchr(tls, bp, int32('#')) + p = v1 + if v1 != 0 { + v2 = p + p = p + 1 + **(**int8)(__ccgo_up(v2)) = int8('\n') + **(**int8)(__ccgo_up(p)) = Int8FromInt32(0) + } + p = bp + uintptr(1) + for { + v1 = Xstrstr(tls, p, name) + p = v1 + if v12 = v1 != 0; v12 { + v5 = int32(**(**int8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + ; + if v11 = !(v6 != 0); !v11 { + v8 = int32(**(**int8)(__ccgo_up(p + uintptr(l)))) + v9 = BoolInt32(v8 == int32(' ') || Uint32FromInt32(v8)-uint32('\t') < uint32(5)) + goto _10 + _10: + } + } + if !(v12 && (v11 || !(v9 != 0))) { + break + } + goto _3 + _3: + ; + p = p + 1 + } + if !(p != 0) { + continue + } + /* Isolate IP address to parse */ + p = bp + for { + if v11 = **(**int8)(__ccgo_up(p)) != 0; v11 { + v5 = int32(**(**int8)(__ccgo_up(p))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _16 + _16: + } + if !(v11 && !(v6 != 0)) { + break + } + goto _13 + _13: + ; + p = p + 1 + } + v1 = p + p = p + 1 + **(**int8)(__ccgo_up(v1)) = 0 + switch _name_from_numeric(tls, buf+uintptr(cnt)*28, bp, family) { + case int32(1): + cnt = cnt + 1 + case 0: + continue + default: + badfam = -int32(5) + break + } + if have_canon != 0 { + continue + } + /* Extract first name as canonical name */ + for { + if v11 = **(**int8)(__ccgo_up(p)) != 0; v11 { + v5 = int32(**(**int8)(__ccgo_up(p))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _22 + _22: + } + if !(v11 && v6 != 0) { + break + } + goto _19 + _19: + ; + p = p + 1 + } + z = p + for { + if v11 = **(**int8)(__ccgo_up(z)) != 0; v11 { + v5 = int32(**(**int8)(__ccgo_up(z))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _27 + _27: + } + if !(v11 && !(v6 != 0)) { + break + } + goto _24 + _24: + ; + z = z + 1 + } + **(**int8)(__ccgo_up(z)) = 0 + if _is_valid_hostname(tls, p) != 0 { + have_canon = int32(1) + Xmemcpy(tls, canon, p, Uint64FromInt64(int64(z)-int64(p)+int64(1))) + } + } + X__fclose_ca(tls, f) + if cnt != 0 { + v5 = cnt + } else { + v5 = badfam + } + return v5 +} + +type Tdpc_ctx = struct { + Faddrs uintptr + Fcanon uintptr + Fcnt int32 + Frrtype int32 +} + +func _dns_parse_callback1(tls *TLS, c uintptr, rr int32, data uintptr, len1 int32, packet uintptr, plen int32) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var ctx, v2 uintptr + var family, v1 int32 + var _ /* tmp at bp+0 */ [256]int8 + _, _, _, _ = ctx, family, v1, v2 + ctx = c + if rr == int32(RR_CNAME) { + if X__dn_expand(tls, packet, packet+uintptr(plen), data, bp, int32(256)) > 0 && _is_valid_hostname(tls, bp) != 0 { + Xstrcpy(tls, (*Tdpc_ctx)(unsafe.Pointer(ctx)).Fcanon, bp) + } + return 0 + } + if (*Tdpc_ctx)(unsafe.Pointer(ctx)).Fcnt >= int32(MAXADDRS) { + return 0 + } + if rr != (*Tdpc_ctx)(unsafe.Pointer(ctx)).Frrtype { + return 0 + } + switch rr { + case int32(RR_A): + if len1 != int32(4) { + return -int32(1) + } + family = int32(PF_INET) + case int32(RR_AAAA): + if len1 != int32(16) { + return -int32(1) + } + family = int32(PF_INET6) + break + } + (**(**Taddress)(__ccgo_up((*Tdpc_ctx)(unsafe.Pointer(ctx)).Faddrs + uintptr((*Tdpc_ctx)(unsafe.Pointer(ctx)).Fcnt)*28))).Ffamily = family + (**(**Taddress)(__ccgo_up((*Tdpc_ctx)(unsafe.Pointer(ctx)).Faddrs + uintptr((*Tdpc_ctx)(unsafe.Pointer(ctx)).Fcnt)*28))).Fscopeid = uint32(0) + v2 = ctx + 16 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + Xmemcpy(tls, (*Tdpc_ctx)(unsafe.Pointer(ctx)).Faddrs+uintptr(v1)*28+8, data, Uint64FromInt32(len1)) + return 0 +} + +func _name_from_dns(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, conf uintptr) (r int32) { + bp := tls.Alloc(10240) + defer tls.Free(10240) + var i, nq int32 + var qtypes [2]int32 + var _ /* abuf at bp+560 */ [2][4800]uint8 + var _ /* alens at bp+10200 */ [2]int32 + var _ /* ap at bp+10176 */ [2]uintptr + var _ /* ctx at bp+10208 */ Tdpc_ctx + var _ /* qbuf at bp+0 */ [2][280]uint8 + var _ /* qlens at bp+10192 */ [2]int32 + var _ /* qp at bp+10160 */ [2]uintptr + _, _, _ = i, nq, qtypes + **(**[2]uintptr)(__ccgo_up(bp + 10160)) = [2]uintptr{ + 0: bp, + 1: bp + 1*280, + } + **(**[2]uintptr)(__ccgo_up(bp + 10176)) = [2]uintptr{ + 0: bp + 560, + 1: bp + 560 + 1*4800, + } + nq = 0 + **(**Tdpc_ctx)(__ccgo_up(bp + 10208)) = Tdpc_ctx{ + Faddrs: buf, + Fcanon: canon, + } + i = 0 + for { + if !(i < int32(2)) { + break + } + if family != _afrr[i].Faf { + (**(**[2]int32)(__ccgo_up(bp + 10192)))[nq] = X__res_mkquery(tls, 0, name, int32(1), _afrr[i].Frr, uintptr(0), 0, uintptr(0), bp+uintptr(nq)*280, int32(280)) + if (**(**[2]int32)(__ccgo_up(bp + 10192)))[nq] == -int32(1) { + return 0 + } + qtypes[nq] = _afrr[i].Frr + **(**uint8)(__ccgo_up(bp + uintptr(nq)*280 + 3)) = uint8(0) /* don't need AD flag */ + /* Ensure query IDs are distinct. */ + if nq != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(bp + uintptr(nq)*280))) == Int32FromUint8(**(**uint8)(__ccgo_up(bp))) { + **(**uint8)(__ccgo_up(bp + uintptr(nq)*280)) = **(**uint8)(__ccgo_up(bp + uintptr(nq)*280)) + 1 + } + nq = nq + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + if X__res_msend_rc(tls, nq, bp+10160, bp+10192, bp+10176, bp+10200, int32(4800), conf) < 0 { + return -int32(11) + } + i = 0 + for { + if !(i < nq) { + break + } + if (**(**[2]int32)(__ccgo_up(bp + 10200)))[i] < int32(4) || Int32FromUint8(**(**uint8)(__ccgo_up(bp + 560 + uintptr(i)*4800 + 3)))&int32(15) == int32(2) { + return -int32(3) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(bp + 560 + uintptr(i)*4800 + 3)))&int32(15) == int32(3) { + return 0 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(bp + 560 + uintptr(i)*4800 + 3)))&int32(15) != 0 { + return -int32(4) + } + goto _2 + _2: + ; + i = i + 1 + } + i = nq - int32(1) + for { + if !(i >= 0) { + break + } + (**(**Tdpc_ctx)(__ccgo_up(bp + 10208))).Frrtype = qtypes[i] + if Uint64FromInt32((**(**[2]int32)(__ccgo_up(bp + 10200)))[i]) > uint64(4800) { + (**(**[2]int32)(__ccgo_up(bp + 10200)))[i] = int32(4800) + } + X__dns_parse(tls, bp+560+uintptr(i)*4800, (**(**[2]int32)(__ccgo_up(bp + 10200)))[i], __ccgo_fp(_dns_parse_callback1), bp+10208) + goto _3 + _3: + ; + i = i - 1 + } + if (**(**Tdpc_ctx)(__ccgo_up(bp + 10208))).Fcnt != 0 { + return (**(**Tdpc_ctx)(__ccgo_up(bp + 10208))).Fcnt + } + return -int32(5) +} + +var _afrr = [2]struct { + Faf int32 + Frr int32 +}{ + 0: { + Faf: int32(PF_INET6), + Frr: int32(RR_A), + }, + 1: { + Faf: int32(PF_INET), + Frr: int32(RR_AAAA), + }, +} + +func _name_from_dns_search(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) (r int32) { + bp := tls.Alloc(368) + defer tls.Free(368) + var cnt, v5, v6 int32 + var dots, l, v2 Tsize_t + var p, z uintptr + var v12 bool + var _ /* conf at bp+256 */ Tresolvconf + var _ /* search at bp+0 */ [256]int8 + _, _, _, _, _, _, _, _, _ = cnt, dots, l, p, z, v12, v2, v5, v6 + if X__get_resolv_conf(tls, bp+256, bp, uint64(256)) < 0 { + return -int32(1) + } + /* Count dots, suppress search when >=ndots or name ends in + * a dot, which is an explicit request for global scope. */ + v2 = Uint64FromInt32(0) + l = v2 + dots = v2 + for { + if !(**(**int8)(__ccgo_up(name + uintptr(l))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(name + uintptr(l)))) == int32('.') { + dots = dots + 1 + } + goto _1 + _1: + ; + l = l + 1 + } + if dots >= uint64((**(**Tresolvconf)(__ccgo_up(bp + 256))).Fndots) || int32(**(**int8)(__ccgo_up(name + uintptr(l-uint64(1))))) == int32('.') { + **(**int8)(__ccgo_up(bp)) = 0 + } + /* Strip final dot for canon, fail if multiple trailing dots. */ + if int32(**(**int8)(__ccgo_up(name + uintptr(l-uint64(1))))) == int32('.') { + l = l - 1 + } + if !(l != 0) || int32(**(**int8)(__ccgo_up(name + uintptr(l-uint64(1))))) == int32('.') { + return -int32(2) + } + /* This can never happen; the caller already checked length. */ + if l >= uint64(256) { + return -int32(2) + } + /* Name with search domain appended is setup in canon[]. This both + * provides the desired default canonical name (if the requested + * name is not a CNAME record) and serves as a buffer for passing + * the full requested name to name_from_dns. */ + Xmemcpy(tls, canon, name, l) + **(**int8)(__ccgo_up(canon + uintptr(l))) = int8('.') + p = bp + for { + if !(**(**int8)(__ccgo_up(p)) != 0) { + break + } + for { + v5 = int32(**(**int8)(__ccgo_up(p))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + if !(v6 != 0) { + break + } + goto _4 + _4: + ; + p = p + 1 + } + z = p + for { + if v12 = **(**int8)(__ccgo_up(z)) != 0; v12 { + v5 = int32(**(**int8)(__ccgo_up(z))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _11 + _11: + } + if !(v12 && !(v6 != 0)) { + break + } + goto _8 + _8: + ; + z = z + 1 + } + if z == p { + break + } + if Uint64FromInt64(int64(z)-int64(p)) < uint64(256)-l-uint64(1) { + Xmemcpy(tls, canon+uintptr(l)+uintptr(1), p, Uint64FromInt64(int64(z)-int64(p))) + **(**int8)(__ccgo_up(canon + uintptr(Uint64FromInt64(int64(z)-int64(p)+int64(1))+l))) = 0 + cnt = _name_from_dns(tls, buf, canon, canon, family, bp+256) + if cnt != 0 { + return cnt + } + } + goto _3 + _3: + ; + p = z + } + **(**int8)(__ccgo_up(canon + uintptr(l))) = 0 + return _name_from_dns(tls, buf, canon, name, family, bp+256) +} + +type Tpolicy = struct { + Faddr [16]uint8 + Flen1 uint8 + Fmask uint8 + Fprec uint8 + Flabel uint8 +} + +var _defpolicy = [6]Tpolicy{ + 0: { + Faddr: [16]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, + Flen1: uint8(15), + Fmask: uint8(0xff), + Fprec: uint8(50), + }, + 1: { + Faddr: [16]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255}, + Flen1: uint8(11), + Fmask: uint8(0xff), + Fprec: uint8(35), + Flabel: uint8(4), + }, + 2: { + Faddr: [16]uint8{' ', 2}, + Flen1: uint8(1), + Fmask: uint8(0xff), + Fprec: uint8(30), + Flabel: uint8(2), + }, + 3: { + Faddr: [16]uint8{' ', 1}, + Flen1: uint8(3), + Fmask: uint8(0xff), + Fprec: uint8(5), + Flabel: uint8(5), + }, + 4: { + Faddr: [16]uint8{252}, + Fmask: uint8(0xfe), + Fprec: uint8(3), + Flabel: uint8(13), + }, + 5: { + Faddr: [16]uint8{}, + Fprec: uint8(40), + Flabel: uint8(1), + }, +} + +func _policyof(tls *TLS, a uintptr) (r uintptr) { + var i int32 + _ = i + i = 0 + for { + if Xmemcmp(tls, a, uintptr(unsafe.Pointer(&_defpolicy))+uintptr(i)*20, uint64(_defpolicy[i].Flen1)) != 0 { + goto _1 + } + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + uintptr(_defpolicy[i].Flen1))))&Int32FromUint8(_defpolicy[i].Fmask) != Int32FromUint8(**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_defpolicy)) + uintptr(i)*20 + uintptr(_defpolicy[i].Flen1)))) { + goto _1 + } + return uintptr(unsafe.Pointer(&_defpolicy)) + uintptr(i)*20 + goto _1 + _1: + ; + i = i + 1 + } + return r +} + +func _labelof(tls *TLS, a uintptr) (r int32) { + return Int32FromUint8((*Tpolicy)(unsafe.Pointer(_policyof(tls, a))).Flabel) +} + +func _scopeof(tls *TLS, a uintptr) (r int32) { + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xff) { + return Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1))) & int32(15) + } + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1)))&int32(0xc0) == int32(0x80) { + return int32(2) + } + if **(**Tuint32_t)(__ccgo_up(a)) == uint32(0) && **(**Tuint32_t)(__ccgo_up(a + 1*4)) == uint32(0) && **(**Tuint32_t)(__ccgo_up(a + 2*4)) == uint32(0) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 12))) == 0 && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 13))) == 0 && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 14))) == 0 && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 15))) == int32(1) { + return int32(2) + } + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1)))&int32(0xc0) == int32(0xc0) { + return int32(5) + } + return int32(14) +} + +func _prefixmatch(tls *TLS, s uintptr, d uintptr) (r int32) { + var i uint32 + _ = i + i = uint32(0) + for { + if !(i < uint32(128) && !((Int32FromUint8(**(**Tuint8_t)(__ccgo_up(s + uintptr(i/uint32(8)))))^Int32FromUint8(**(**Tuint8_t)(__ccgo_up(d + uintptr(i/uint32(8))))))&(Int32FromInt32(128)>>(i%Uint32FromInt32(8))) != 0)) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + return Int32FromUint32(i) +} + +func _addrcmp(tls *TLS, _a uintptr, _b uintptr) (r int32) { + var a, b uintptr + _, _ = a, b + a = _a + b = _b + return (*Taddress)(unsafe.Pointer(b)).Fsortkey - (*Taddress)(unsafe.Pointer(a)).Fsortkey +} + +func X__lookup_name(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v buf=%v canon=%v name=%v family=%v flags=%v, (%v:)", tls, buf, canon, name, family, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(96) + defer tls.Free(96) + var cnt, dlabel, dprec, dscope, family1, fd, i, j, key, prefixlen, v1 int32 + var da, dpolicy, sa uintptr + var dalen Tsocklen_t + var l Tsize_t + var _ /* cs at bp+0 */ int32 + var _ /* da4 at bp+76 */ Tsockaddr_in + var _ /* da6 at bp+32 */ Tsockaddr_in6 + var _ /* sa4 at bp+60 */ Tsockaddr_in + var _ /* sa6 at bp+4 */ Tsockaddr_in6 + var _ /* salen at bp+92 */ Tsocklen_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cnt, da, dalen, dlabel, dpolicy, dprec, dscope, family1, fd, i, j, key, l, prefixlen, sa, v1 + cnt = 0 + **(**int8)(__ccgo_up(canon)) = 0 + if name != 0 { + /* reject empty name and check len so it fits into temp bufs */ + l = Xstrnlen(tls, name, uint64(255)) + if l-uint64(1) >= uint64(254) { + return -int32(2) + } + Xmemcpy(tls, canon, name, l+uint64(1)) + } + /* Procedurally, a request for v6 addresses with the v4-mapped + * flag set is like a request for unspecified family, followed + * by filtering of the results. */ + if flags&int32(AI_V4MAPPED) != 0 { + if family == int32(PF_INET6) { + family = PF_UNSPEC + } else { + flags = flags - int32(AI_V4MAPPED) + } + } + /* Try each backend until there's at least one result. */ + cnt = _name_from_null(tls, buf, name, family, flags) + if !(cnt != 0) { + cnt = _name_from_numeric(tls, buf, name, family) + } + if !(cnt != 0) && !(flags&Int32FromInt32(AI_NUMERICHOST) != 0) { + cnt = _name_from_hosts(tls, buf, canon, name, family) + if !(cnt != 0) { + cnt = _name_from_dns_search(tls, buf, canon, name, family) + } + } + if cnt <= 0 { + if cnt != 0 { + v1 = cnt + } else { + v1 = -int32(2) + } + return v1 + } + /* Filter/transform results for v4-mapped lookup, if requested. */ + if flags&int32(AI_V4MAPPED) != 0 { + if !(flags&Int32FromInt32(AI_ALL) != 0) { + /* If any v6 results exist, remove v4 results. */ + i = 0 + for { + if !(i < cnt && (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily != int32(PF_INET6)) { + break + } + goto _2 + _2: + ; + i = i + 1 + } + if i < cnt { + j = 0 + for { + if !(i < cnt) { + break + } + if (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily == int32(PF_INET6) { + v1 = j + j = j + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = **(**Taddress)(__ccgo_up(buf + uintptr(i)*28)) + } + goto _3 + _3: + ; + i = i + 1 + } + v1 = j + i = v1 + cnt = v1 + } + } + /* Translate any remaining v4 results to v6 */ + i = 0 + for { + if !(i < cnt) { + break + } + if (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily != int32(PF_INET) { + goto _6 + } + Xmemcpy(tls, buf+uintptr(i)*28+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4)) + Xmemcpy(tls, buf+uintptr(i)*28+8, __ccgo_ts+1044, uint64(12)) + (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily = int32(PF_INET6) + goto _6 + _6: + ; + i = i + 1 + } + } + /* No further processing is needed if there are fewer than 2 + * results or if there are only IPv4 results. */ + if cnt < int32(2) || family == int32(PF_INET) { + return cnt + } + i = 0 + for { + if !(i < cnt) { + break + } + if (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily != int32(PF_INET) { + break + } + goto _7 + _7: + ; + i = i + 1 + } + if i == cnt { + return cnt + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + /* The following implements a subset of RFC 3484/6724 destination + * address selection by generating a single 31-bit sort key for + * each address. Rules 3, 4, and 7 are omitted for having + * excessive runtime and code size cost and dubious benefit. + * So far the label/precedence table cannot be customized. */ + i = 0 + for { + if !(i < cnt) { + break + } + family1 = (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily + key = 0 + **(**Tsockaddr_in6)(__ccgo_up(bp + 4)) = Tsockaddr_in6{} + **(**Tsockaddr_in6)(__ccgo_up(bp + 32)) = Tsockaddr_in6{ + Fsin6_family: uint16(PF_INET6), + Fsin6_port: uint16(65535), + Fsin6_scope_id: (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Fscopeid, + } + **(**Tsockaddr_in)(__ccgo_up(bp + 60)) = Tsockaddr_in{} + **(**Tsockaddr_in)(__ccgo_up(bp + 76)) = Tsockaddr_in{ + Fsin_family: uint16(PF_INET), + Fsin_port: uint16(65535), + } + if family1 == int32(PF_INET6) { + Xmemcpy(tls, bp+32+8, buf+uintptr(i)*28+8, uint64(16)) + da = bp + 32 + dalen = uint32(28) + sa = bp + 4 + **(**Tsocklen_t)(__ccgo_up(bp + 92)) = uint32(28) + } else { + Xmemcpy(tls, bp+4+8, __ccgo_ts+1044, uint64(12)) + Xmemcpy(tls, bp+32+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4)) + Xmemcpy(tls, bp+32+8, __ccgo_ts+1044, uint64(12)) + Xmemcpy(tls, bp+32+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4)) + Xmemcpy(tls, bp+76+4, buf+uintptr(i)*28+8, uint64(4)) + da = bp + 76 + dalen = uint32(16) + sa = bp + 60 + **(**Tsocklen_t)(__ccgo_up(bp + 92)) = uint32(16) + } + dpolicy = _policyof(tls, bp+32+8) + dscope = _scopeof(tls, bp+32+8) + dlabel = Int32FromUint8((*Tpolicy)(unsafe.Pointer(dpolicy)).Flabel) + dprec = Int32FromUint8((*Tpolicy)(unsafe.Pointer(dpolicy)).Fprec) + prefixlen = 0 + fd = Xsocket(tls, family1, Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC), int32(IPPROTO_UDP)) + if fd >= 0 { + if !(Xconnect(tls, fd, da, dalen) != 0) { + key = key | int32(DAS_USABLE) + if !(Xgetsockname(tls, fd, sa, bp+92) != 0) { + if family1 == int32(PF_INET) { + Xmemcpy(tls, bp+4+8+uintptr(12), bp+60+4, uint64(4)) + } + if dscope == _scopeof(tls, bp+4+8) { + key = key | int32(DAS_MATCHINGSCOPE) + } + if dlabel == _labelof(tls, bp+4+8) { + key = key | int32(DAS_MATCHINGLABEL) + } + prefixlen = _prefixmatch(tls, bp+4+8, bp+32+8) + } + } + Xclose(tls, fd) + } + key = key | dprec< %v", r) }() + } + bp := tls.Alloc(1408) + defer tls.Free(1408) + var cnt, v1, v2 int32 + var f, p, v3, v4 uintptr + var l Tsize_t + var port uint64 + var v10 bool + var _ /* _buf at bp+136 */ [1032]uint8 + var _ /* _f at bp+1168 */ TFILE + var _ /* line at bp+0 */ [128]int8 + var _ /* z at bp+128 */ uintptr + _, _, _, _, _, _, _, _, _, _ = cnt, f, l, p, port, v1, v10, v2, v3, v4 + cnt = 0 + **(**uintptr)(__ccgo_up(bp + 128)) = __ccgo_ts + port = uint64(0) + switch socktype { + case int32(SOCK_STREAM): + switch proto { + case 0: + proto = int32(IPPROTO_TCP) + fallthrough + case int32(IPPROTO_TCP): + default: + return -int32(8) + } + case int32(SOCK_DGRAM): + switch proto { + case 0: + proto = int32(IPPROTO_UDP) + fallthrough + case int32(IPPROTO_UDP): + default: + return -int32(8) + } + fallthrough + case 0: + default: + if name != 0 { + return -int32(8) + } + (**(**Tservice)(__ccgo_up(buf))).Fport = uint16(0) + (**(**Tservice)(__ccgo_up(buf))).Fproto = Uint8FromInt32(proto) + (**(**Tservice)(__ccgo_up(buf))).Fsocktype = Uint8FromInt32(socktype) + return int32(1) + } + if name != 0 { + if !(**(**int8)(__ccgo_up(name)) != 0) { + return -int32(8) + } + port = Xstrtoul(tls, name, bp+128, int32(10)) + } + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 128)))) != 0) { + if port > uint64(65535) { + return -int32(8) + } + if proto != int32(IPPROTO_UDP) { + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fport = uint16(port) + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fsocktype = uint8(SOCK_STREAM) + v1 = cnt + cnt = cnt + 1 + (**(**Tservice)(__ccgo_up(buf + uintptr(v1)*4))).Fproto = uint8(IPPROTO_TCP) + } + if proto != int32(IPPROTO_TCP) { + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fport = uint16(port) + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fsocktype = uint8(SOCK_DGRAM) + v1 = cnt + cnt = cnt + 1 + (**(**Tservice)(__ccgo_up(buf + uintptr(v1)*4))).Fproto = uint8(IPPROTO_UDP) + } + return cnt + } + if flags&int32(AI_NUMERICSERV) != 0 { + return -int32(2) + } + l = _strlen(tls, name) + f = X__fopen_rb_ca(tls, __ccgo_ts+1057, bp+1168, bp+136, uint64(1032)) + if !(f != 0) { + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(ENOENT): + fallthrough + case int32(ENOTDIR): + fallthrough + case int32(EACCES): + return -int32(8) + default: + return -int32(11) + } + } + for Xfgets(tls, bp, int32(128), f) != 0 && cnt < int32(MAXSERVS) { + v3 = Xstrchr(tls, bp, int32('#')) + p = v3 + if v3 != 0 { + v4 = p + p = p + 1 + **(**int8)(__ccgo_up(v4)) = int8('\n') + **(**int8)(__ccgo_up(p)) = Int8FromInt32(0) + } + /* Find service name */ + p = bp + for { + v3 = Xstrstr(tls, p, name) + p = v3 + if !(v3 != 0) { + break + } + if v10 = p > bp; v10 { + v1 = int32(**(**int8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _9 + _9: + } + if v10 && !(v2 != 0) { + goto _5 + } + if v10 = **(**int8)(__ccgo_up(p + uintptr(l))) != 0; v10 { + v1 = int32(**(**int8)(__ccgo_up(p + uintptr(l)))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _13 + _13: + } + if v10 && !(v2 != 0) { + goto _5 + } + break + goto _5 + _5: + ; + p = p + 1 + } + if !(p != 0) { + continue + } + /* Skip past canonical name at beginning of line */ + p = bp + for { + if v10 = **(**int8)(__ccgo_up(p)) != 0; v10 { + v1 = int32(**(**int8)(__ccgo_up(p))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _18 + _18: + } + if !(v10 && !(v2 != 0)) { + break + } + goto _15 + _15: + ; + p = p + 1 + } + port = Xstrtoul(tls, p, bp+128, int32(10)) + if port > uint64(65535) || **(**uintptr)(__ccgo_up(bp + 128)) == p { + continue + } + if !(Xstrncmp(tls, **(**uintptr)(__ccgo_up(bp + 128)), __ccgo_ts+1071, uint64(4)) != 0) { + if proto == int32(IPPROTO_TCP) { + continue + } + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fport = uint16(port) + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fsocktype = uint8(SOCK_DGRAM) + v1 = cnt + cnt = cnt + 1 + (**(**Tservice)(__ccgo_up(buf + uintptr(v1)*4))).Fproto = uint8(IPPROTO_UDP) + } + if !(Xstrncmp(tls, **(**uintptr)(__ccgo_up(bp + 128)), __ccgo_ts+1076, uint64(4)) != 0) { + if proto == int32(IPPROTO_UDP) { + continue + } + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fport = uint16(port) + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fsocktype = uint8(SOCK_STREAM) + v1 = cnt + cnt = cnt + 1 + (**(**Tservice)(__ccgo_up(buf + uintptr(v1)*4))).Fproto = uint8(IPPROTO_TCP) + } + } + X__fclose_ca(tls, f) + if cnt > 0 { + v1 = cnt + } else { + v1 = -int32(8) + } + return v1 +} + +func ___netlink_enumerate(tls *TLS, fd int32, seq uint32, type1 int32, af int32, __ccgo_fp_cb uintptr, ctx uintptr) (r1 int32) { + bp := tls.Alloc(8192) + defer tls.Free(8192) + var h uintptr + var r, ret int32 + var _ /* u at bp+0 */ struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + } + _, _, _ = h, r, ret + Xmemset(tls, bp, 0, uint64(20)) + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fnlh.Fnlmsg_len = uint32(20) + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fnlh.Fnlmsg_type = Uint16FromInt32(type1) + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fnlh.Fnlmsg_flags = Uint16FromInt32(Int32FromInt32(NLM_F_ROOT) | Int32FromInt32(NLM_F_MATCH) | Int32FromInt32(NLM_F_REQUEST)) + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fnlh.Fnlmsg_seq = seq + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fg.Frtgen_family = Uint8FromInt32(af) + r = int32(Xsend(tls, fd, bp, uint64(20), 0)) + if r < 0 { + return r + } + for int32(1) != 0 { + r = int32(Xrecv(tls, fd, bp, uint64(8192), int32(MSG_DONTWAIT))) + if r <= 0 { + return -int32(1) + } + h = bp + for { + if !(Uint64FromInt64(int64(bp+uintptr(r))-int64(h)) >= uint64(16)) { + break + } + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(NLMSG_DONE) { + return 0 + } + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(NLMSG_ERROR) { + return -int32(1) + } + ret = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cb})))(tls, ctx, h) + if ret != 0 { + return ret + } + goto _1 + _1: + ; + h = h + uintptr(((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len+Uint32FromInt32(3))&Uint32FromInt32(^Int32FromInt32(3))) + } + } + return r1 +} + +type t__ccgo_fp__X__rtnetlink_enumerate_2 = func(*TLS, uintptr, uintptr) int32 + +func X__rtnetlink_enumerate(tls *TLS, link_af int32, addr_af int32, __ccgo_fp_cb uintptr, ctx uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v link_af=%v addr_af=%v __ccgo_fp_cb=%v ctx=%v, (%v:)", tls, link_af, addr_af, __ccgo_fp_cb, ctx, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var fd, r int32 + _, _ = fd, r + fd = Xsocket(tls, int32(PF_NETLINK), Int32FromInt32(SOCK_RAW)|Int32FromInt32(SOCK_CLOEXEC), NETLINK_ROUTE) + if fd < 0 { + return -int32(1) + } + r = ___netlink_enumerate(tls, fd, uint32(1), int32(RTM_GETLINK), link_af, __ccgo_fp_cb, ctx) + if !(r != 0) { + r = ___netlink_enumerate(tls, fd, uint32(2), int32(RTM_GETADDR), addr_af, __ccgo_fp_cb, ctx) + } + X__syscall1(tls, int64(SYS_close), int64(fd)) + return r +} + +func Xgetnetbyaddr(tls *TLS, net Tuint32_t, type1 int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v net=%v type1=%v, (%v:)", tls, net, type1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xgetnetbyname(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xns_get16(tls *TLS, cp uintptr) (r uint32) { + if __ccgo_strace { + trc("tls=%v cp=%v, (%v:)", tls, cp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(cp)))< %v", r) }() + } + return uint64(uint32(**(**uint8)(__ccgo_up(cp)))<> int32(8)) + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(s) +} + +func Xns_put32(tls *TLS, l uint64, cp uintptr) { + if __ccgo_strace { + trc("tls=%v l=%v cp=%v, (%v:)", tls, l, cp, origin(2)) + } + var v1 uintptr + _ = v1 + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(l >> int32(24)) + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(l >> int32(16)) + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(l >> int32(8)) + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(l) +} + +func Xns_initparse(tls *TLS, msg uintptr, msglen int32, handle uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v msg=%v msglen=%v handle=%v, (%v:)", tls, msg, msglen, handle, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var i, r int32 + _, _ = i, r + (*Tns_msg)(unsafe.Pointer(handle)).F_msg = msg + (*Tns_msg)(unsafe.Pointer(handle)).F_eom = msg + uintptr(msglen) + if msglen < (Int32FromInt32(2)+int32(_ns_s_max))*Int32FromInt32(NS_INT16SZ) { + goto bad + } + msg = msg + uintptr(2) + (*Tns_msg)(unsafe.Pointer(handle)).F_id = uint16(Xns_get16(tls, msg-uintptr(2))) + msg = msg + uintptr(2) + (*Tns_msg)(unsafe.Pointer(handle)).F_flags = uint16(Xns_get16(tls, msg-uintptr(2))) + i = 0 + for { + if !(i < int32(_ns_s_max)) { + break + } + msg = msg + uintptr(2) + **(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(i)*2)) = uint16(Xns_get16(tls, msg-uintptr(2))) + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < int32(_ns_s_max)) { + break + } + if **(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(i)*2)) != 0 { + **(**uintptr)(__ccgo_up(handle + 32 + uintptr(i)*8)) = msg + r = Xns_skiprr(tls, msg, (*Tns_msg)(unsafe.Pointer(handle)).F_eom, i, Int32FromUint16(**(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(i)*2)))) + if r < 0 { + return -int32(1) + } + msg = msg + uintptr(r) + } else { + **(**uintptr)(__ccgo_up(handle + 32 + uintptr(i)*8)) = UintptrFromInt32(0) + } + goto _2 + _2: + ; + i = i + 1 + } + if msg != (*Tns_msg)(unsafe.Pointer(handle)).F_eom { + goto bad + } + (*Tns_msg)(unsafe.Pointer(handle)).F_sect = int32(_ns_s_max) + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = -int32(1) + (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr = UintptrFromInt32(0) + return 0 + goto bad +bad: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EMSGSIZE) + return -int32(1) +} + +func Xns_skiprr(tls *TLS, ptr uintptr, eom uintptr, section Tns_sect, count int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v ptr=%v eom=%v section=%v count=%v, (%v:)", tls, ptr, eom, section, count, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var p uintptr + var r, v1 int32 + _, _, _ = p, r, v1 + p = ptr + for { + v1 = count + count = count - 1 + if !(v1 != 0) { + break + } + r = Xdn_skipname(tls, p, eom) + if r < 0 { + goto bad + } + if int64(r+Int32FromInt32(2)*Int32FromInt32(NS_INT16SZ)) > int64(eom)-int64(p) { + goto bad + } + p = p + uintptr(r+Int32FromInt32(2)*Int32FromInt32(NS_INT16SZ)) + if section != int32(_ns_s_qd) { + if int64(Int32FromInt32(NS_INT32SZ)+Int32FromInt32(NS_INT16SZ)) > int64(eom)-int64(p) { + goto bad + } + p = p + uintptr(NS_INT32SZ) + p = p + uintptr(2) + r = Int32FromUint32(Xns_get16(tls, p-uintptr(2))) + if int64(r) > int64(eom)-int64(p) { + goto bad + } + p = p + uintptr(r) + } + } + return int32(int64(p) - int64(ptr)) + goto bad +bad: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EMSGSIZE) + return -int32(1) +} + +func Xns_parserr(tls *TLS, handle uintptr, section Tns_sect, rrnum int32, rr uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v handle=%v section=%v rrnum=%v rr=%v, (%v:)", tls, handle, section, rrnum, rr, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + var v1 uintptr + _, _ = r, v1 + if section < 0 || section >= int32(_ns_s_max) { + goto bad + } + if section != (*Tns_msg)(unsafe.Pointer(handle)).F_sect { + (*Tns_msg)(unsafe.Pointer(handle)).F_sect = section + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = 0 + (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr = **(**uintptr)(__ccgo_up(handle + 32 + uintptr(section)*8)) + } + if rrnum == -int32(1) { + rrnum = (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum + } + if rrnum < 0 || rrnum >= Int32FromUint16(**(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(section)*2))) { + goto bad + } + if rrnum < (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum { + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = 0 + (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr = **(**uintptr)(__ccgo_up(handle + 32 + uintptr(section)*8)) + } + if rrnum > (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum { + r = Xns_skiprr(tls, (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr, (*Tns_msg)(unsafe.Pointer(handle)).F_eom, section, rrnum-(*Tns_msg)(unsafe.Pointer(handle)).F_rrnum) + if r < 0 { + return -int32(1) + } + **(**uintptr)(__ccgo_up(handle + 72)) += uintptr(r) + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = rrnum + } + r = Xns_name_uncompress(tls, (*Tns_msg)(unsafe.Pointer(handle)).F_msg, (*Tns_msg)(unsafe.Pointer(handle)).F_eom, (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr, rr, uint64(NS_MAXDNAME)) + if r < 0 { + return -int32(1) + } + **(**uintptr)(__ccgo_up(handle + 72)) += uintptr(r) + if int64(Int32FromInt32(2)*Int32FromInt32(NS_INT16SZ)) > int64((*Tns_msg)(unsafe.Pointer(handle)).F_eom)-int64((*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr) { + goto size + } + v1 = handle + 72 + *(*uintptr)(unsafe.Pointer(v1)) += uintptr(2) + (*Tns_rr)(unsafe.Pointer(rr)).Ftype1 = uint16(Xns_get16(tls, *(*uintptr)(unsafe.Pointer(v1))-uintptr(2))) + v1 = handle + 72 + *(*uintptr)(unsafe.Pointer(v1)) += uintptr(2) + (*Tns_rr)(unsafe.Pointer(rr)).Frr_class = uint16(Xns_get16(tls, *(*uintptr)(unsafe.Pointer(v1))-uintptr(2))) + if section != int32(_ns_s_qd) { + if int64(Int32FromInt32(NS_INT32SZ)+Int32FromInt32(NS_INT16SZ)) > int64((*Tns_msg)(unsafe.Pointer(handle)).F_eom)-int64((*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr) { + goto size + } + v1 = handle + 72 + *(*uintptr)(unsafe.Pointer(v1)) += uintptr(4) + (*Tns_rr)(unsafe.Pointer(rr)).Fttl = uint32(Xns_get32(tls, *(*uintptr)(unsafe.Pointer(v1))-uintptr(4))) + v1 = handle + 72 + *(*uintptr)(unsafe.Pointer(v1)) += uintptr(2) + (*Tns_rr)(unsafe.Pointer(rr)).Frdlength = uint16(Xns_get16(tls, *(*uintptr)(unsafe.Pointer(v1))-uintptr(2))) + if Int64FromUint16((*Tns_rr)(unsafe.Pointer(rr)).Frdlength) > int64((*Tns_msg)(unsafe.Pointer(handle)).F_eom)-int64((*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr) { + goto size + } + (*Tns_rr)(unsafe.Pointer(rr)).Frdata = (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr + **(**uintptr)(__ccgo_up(handle + 72)) += uintptr((*Tns_rr)(unsafe.Pointer(rr)).Frdlength) + } else { + (*Tns_rr)(unsafe.Pointer(rr)).Fttl = uint32(0) + (*Tns_rr)(unsafe.Pointer(rr)).Frdlength = uint16(0) + (*Tns_rr)(unsafe.Pointer(rr)).Frdata = UintptrFromInt32(0) + } + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum + 1 + if (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum > Int32FromUint16(**(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(section)*2))) { + (*Tns_msg)(unsafe.Pointer(handle)).F_sect = section + int32(1) + if (*Tns_msg)(unsafe.Pointer(handle)).F_sect == int32(_ns_s_max) { + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = -int32(1) + (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr = UintptrFromInt32(0) + } else { + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = 0 + } + } + return 0 + goto bad +bad: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENODEV) + return -int32(1) + goto size +size: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EMSGSIZE) + return -int32(1) +} + +func Xns_name_uncompress(tls *TLS, msg uintptr, eom uintptr, src uintptr, dst uintptr, dstsiz Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v msg=%v eom=%v src=%v dst=%v dstsiz=%v, (%v:)", tls, msg, eom, src, dst, dstsiz, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = Xdn_expand(tls, msg, eom, src, dst, Int32FromUint64(dstsiz)) + if r < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EMSGSIZE) + } + return r +} + +func Xntohl(tls *TLS, n Tuint32_t) (r Tuint32_t) { + if __ccgo_strace { + trc("tls=%v n=%v, (%v:)", tls, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var u struct { + Fc [0]int8 + Fi int32 + } + var v1 uint32 + var v2, v3 Tuint32_t + _, _, _, _ = u, v1, v2, v3 + u = *(*struct { + Fc [0]int8 + Fi int32 + })(unsafe.Pointer(&struct{ f int32 }{f: int32(1)})) + if *(*int8)(unsafe.Pointer(&u)) != 0 { + v2 = n + v3 = v2>>int32(24) | v2>>int32(8)&uint32(0xff00) | v2< %v", r) }() + } + var u struct { + Fc [0]int8 + Fi int32 + } + var v1 int32 + var v2, v3 Tuint16_t + _, _, _, _ = u, v1, v2, v3 + u = *(*struct { + Fc [0]int8 + Fi int32 + })(unsafe.Pointer(&struct{ f int32 }{f: int32(1)})) + if *(*int8)(unsafe.Pointer(&u)) != 0 { + v2 = n + v3 = Uint16FromInt32(Int32FromUint16(v2)<>int32(8)) + goto _4 + _4: + v1 = Int32FromUint16(v3) + } else { + v1 = Int32FromUint16(n) + } + return Uint16FromInt32(v1) +} + +/* do we really need all these?? */ + +var _idx int32 +var _protos = [239]uint8{0, 'i', 'p', 0, 1, 'i', 'c', 'm', 'p', 0, 2, 'i', 'g', 'm', 'p', 0, 3, 'g', 'g', 'p', 0, 4, 'i', 'p', 'e', 'n', 'c', 'a', 'p', 0, 5, 's', 't', 0, 6, 't', 'c', 'p', 0, 8, 'e', 'g', 'p', 0, 12, 'p', 'u', 'p', 0, 17, 'u', 'd', 'p', 0, 20, 'h', 'm', 'p', 0, 22, 'x', 'n', 's', '-', 'i', 'd', 'p', 0, 27, 'r', 'd', 'p', 0, 29, 'i', 's', 'o', '-', 't', 'p', '4', 0, '$', 'x', 't', 'p', 0, '%', 'd', 'd', 'p', 0, '&', 'i', 'd', 'p', 'r', '-', 'c', 'm', 't', 'p', 0, ')', 'i', 'p', 'v', '6', 0, '+', 'i', 'p', 'v', '6', '-', 'r', 'o', 'u', 't', 'e', 0, ',', 'i', 'p', 'v', '6', '-', 'f', 'r', 'a', 'g', 0, '-', 'i', 'd', 'r', 'p', 0, '.', 'r', 's', 'v', 'p', 0, '/', 'g', 'r', 'e', 0, '2', 'e', 's', 'p', 0, '3', 'a', 'h', 0, '9', 's', 'k', 'i', 'p', 0, ':', 'i', 'p', 'v', '6', '-', 'i', 'c', 'm', 'p', 0, ';', 'i', 'p', 'v', '6', '-', 'n', 'o', 'n', 'x', 't', 0, '<', 'i', 'p', 'v', '6', '-', 'o', 'p', 't', 's', 0, 'I', 'r', 's', 'p', 'f', 0, 'Q', 'v', 'm', 't', 'p', 0, 'Y', 'o', 's', 'p', 'f', 0, '^', 'i', 'p', 'i', 'p', 0, 'b', 'e', 'n', 'c', 'a', 'p', 0, 'g', 'p', 'i', 'm', 0, 255, 'r', 'a', 'w'} + +func Xendprotoent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + _idx = 0 +} + +func Xsetprotoent(tls *TLS, stayopen int32) { + if __ccgo_strace { + trc("tls=%v stayopen=%v, (%v:)", tls, stayopen, origin(2)) + } + _idx = 0 +} + +func Xgetprotoent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + if Uint64FromInt32(_idx) >= uint64(239) { + return UintptrFromInt32(0) + } + _p.Fp_proto = Int32FromUint8(_protos[_idx]) + _p.Fp_name = uintptr(unsafe.Pointer(&_protos)) + uintptr(_idx+int32(1)) + _p.Fp_aliases = uintptr(unsafe.Pointer(&_aliases)) + _idx = Int32FromUint64(uint64(_idx) + (_strlen(tls, _p.Fp_name) + Uint64FromInt32(2))) + return uintptr(unsafe.Pointer(&_p)) +} + +var _p Tprotoent + +var _aliases uintptr + +func Xgetprotobyname(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + _ = p + Xendprotoent(tls) + for cond := true; cond; cond = p != 0 && Xstrcmp(tls, name, (*Tprotoent)(unsafe.Pointer(p)).Fp_name) != 0 { + p = Xgetprotoent(tls) + } + return p +} + +func Xgetprotobynumber(tls *TLS, num int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v num=%v, (%v:)", tls, num, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + _ = p + Xendprotoent(tls) + for cond := true; cond; cond = p != 0 && (*Tprotoent)(unsafe.Pointer(p)).Fp_proto != num { + p = Xgetprotoent(tls) + } + return p +} + +func Xrecv(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v flags=%v, (%v:)", tls, fd, buf, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xrecvfrom(tls, fd, buf, len1, flags, uintptr(0), uintptr(0)) +} + +func Xrecvfrom(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32, addr uintptr, alen uintptr) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v flags=%v addr=%v alen=%v, (%v:)", tls, fd, buf, len1, flags, addr, alen, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_recvfrom) + _ = int32(__SC_recvfrom) + v2 = int64(fd) + v3 = int64(buf) + v4 = Int64FromUint64(len1) + v5 = int64(flags) + v6 = int64(addr) + v7 = int64(alen) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return X__syscall_ret(tls, Uint64FromInt64(v8)) +} + +func Xrecvmmsg(tls *TLS, fd int32, msgvec uintptr, vlen uint32, flags uint32, timeout uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v msgvec=%v vlen=%v flags=%v timeout=%v, (%v:)", tls, fd, msgvec, vlen, flags, timeout, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i uint32 + var mh uintptr + var v2 int32 + _, _, _ = i, mh, v2 + mh = msgvec + i = vlen + for { + if !(i != 0) { + break + } + v2 = Int32FromInt32(0) + (*Tmmsghdr)(unsafe.Pointer(mh)).Fmsg_hdr.F__pad2 = v2 + (*Tmmsghdr)(unsafe.Pointer(mh)).Fmsg_hdr.F__pad1 = v2 + goto _1 + _1: + ; + i = i - 1 + mh += 64 + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_recvmmsg), int64(fd), int64(msgvec), Int64FromUint32(vlen), Int64FromUint32(flags), int64(timeout), 0)))) +} + +func X__convert_scm_timestamps(tls *TLS, msg uintptr, csize Tsocklen_t) { + if __ccgo_strace { + trc("tls=%v msg=%v csize=%v, (%v:)", tls, msg, csize, origin(2)) + } + bp := tls.Alloc(32) + defer tls.Free(32) + var cmsg, last, v2 uintptr + var type1 int32 + var _ /* tmp at bp+0 */ int64 + var _ /* tvts at bp+8 */ [2]int64 + _, _, _, _ = cmsg, last, type1, v2 + if true { + return + } + if !((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_control != 0) || !((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen != 0) { + return + } + last = uintptr(0) + type1 = 0 + if uint64((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen) >= uint64(16) { + v2 = (*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_control + } else { + v2 = UintptrFromInt32(0) + } + cmsg = v2 + for { + if !(cmsg != 0) { + break + } + if (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_level == int32(SOL_SOCKET) { + switch (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_type { + case int32(SO_TIMESTAMP_OLD): + goto _3 + case int32(SO_TIMESTAMPNS_OLD): + goto _4 + } + goto _5 + _3: + ; + if type1 != 0 { + goto _5 + } + type1 = int32(SO_TIMESTAMP) + goto common + _4: + ; + type1 = int32(SO_TIMESTAMPNS) + goto common + common: + ; + Xmemcpy(tls, bp, cmsg+UintptrFromInt32(1)*16, uint64(8)) + (**(**[2]int64)(__ccgo_up(bp + 8)))[0] = int64(**(**int64)(__ccgo_up(bp))) + Xmemcpy(tls, bp, cmsg+UintptrFromInt32(1)*16+uintptr(8), uint64(8)) + (**(**[2]int64)(__ccgo_up(bp + 8)))[int32(1)] = int64(**(**int64)(__ccgo_up(bp))) + goto _5 + _5: + } + last = cmsg + goto _1 + _1: + ; + if uint64((*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_len) < uint64(16) || (uint64((*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_len)+uint64(8)-uint64(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))+uint64(16) >= Uint64FromInt64(int64((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_control+uintptr((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen))-int64(cmsg)) { + v2 = uintptr(0) + } else { + v2 = cmsg + uintptr((uint64((*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_len)+Uint64FromInt64(8)-Uint64FromInt32(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))) + } + cmsg = v2 + } + if !(last != 0) || !(type1 != 0) { + return + } + if (Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)) + (Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)) > uint64(csize-(*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen) { + **(**int32)(__ccgo_up(msg + 48)) |= int32(MSG_CTRUNC) + return + } + v2 = msg + 40 + *(*Tsocklen_t)(unsafe.Pointer(v2)) = Tsocklen_t(uint64(*(*Tsocklen_t)(unsafe.Pointer(v2))) + ((Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)) + (Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)))) + if uint64((*Tcmsghdr)(unsafe.Pointer(last)).Fcmsg_len) < uint64(16) || (uint64((*Tcmsghdr)(unsafe.Pointer(last)).Fcmsg_len)+uint64(8)-uint64(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))+uint64(16) >= Uint64FromInt64(int64((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_control+uintptr((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen))-int64(last)) { + v2 = uintptr(0) + } else { + v2 = last + uintptr((uint64((*Tcmsghdr)(unsafe.Pointer(last)).Fcmsg_len)+Uint64FromInt64(8)-Uint64FromInt32(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))) + } + cmsg = v2 + (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_level = int32(SOL_SOCKET) + (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_type = type1 + (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_len = uint32((Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)) + Uint64FromInt64(16)) + Xmemcpy(tls, cmsg+UintptrFromInt32(1)*16, bp+8, uint64(16)) +} + +func Xrecvmsg(tls *TLS, fd int32, msg uintptr, flags int32) (r2 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v msg=%v flags=%v, (%v:)", tls, fd, msg, flags, origin(2)) + defer func() { trc("-> %v", r2) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var orig uintptr + var orig_controllen Tsocklen_t + var r, v9 int64 + var r1 Tssize_t + var v1 int32 + var v3, v4, v5, v6, v7, v8 Tsyscall_arg_t + var _ /* h at bp+0 */ Tmsghdr + _, _, _, _, _, _, _, _, _, _, _, _ = orig, orig_controllen, r, r1, v1, v3, v4, v5, v6, v7, v8, v9 + orig_controllen = (*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen + orig = msg + if msg != 0 { + **(**Tmsghdr)(__ccgo_up(bp)) = **(**Tmsghdr)(__ccgo_up(msg)) + v1 = Int32FromInt32(0) + (**(**Tmsghdr)(__ccgo_up(bp))).F__pad2 = v1 + (**(**Tmsghdr)(__ccgo_up(bp))).F__pad1 = v1 + msg = bp + } + v1 = int32(SYS_recvmsg) + _ = int32(__SC_recvmsg) + v3 = int64(fd) + v4 = int64(msg) + v5 = int64(flags) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + v8 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v3, v4, v5, v6, v7, v8) + } else { + r = X__syscall6(tls, int64(v1), v3, v4, v5, v6, v7, v8) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v9 = r + goto _10 + } + v9 = r + goto _10 +_10: + r1 = X__syscall_ret(tls, Uint64FromInt64(v9)) + if r1 >= 0 { + X__convert_scm_timestamps(tls, msg, orig_controllen) + } + if orig != 0 { + **(**Tmsghdr)(__ccgo_up(orig)) = **(**Tmsghdr)(__ccgo_up(bp)) + } + return r1 +} + +func Xres_init(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func X__res_mkquery(tls *TLS, op int32, dname uintptr, class int32, type1 int32, data uintptr, datalen int32, newrr uintptr, buf uintptr, buflen int32) (r int32) { + if __ccgo_strace { + trc("tls=%v op=%v dname=%v class=%v type1=%v data=%v datalen=%v newrr=%v buf=%v buflen=%v, (%v:)", tls, op, dname, class, type1, data, datalen, newrr, buf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(304) + defer tls.Free(304) + var i, id, j, n int32 + var l Tsize_t + var _ /* q at bp+0 */ [280]uint8 + var _ /* ts at bp+280 */ Ttimespec + _, _, _, _, _ = i, id, j, l, n + l = Xstrnlen(tls, dname, uint64(255)) + if l != 0 && int32(**(**int8)(__ccgo_up(dname + uintptr(l-uint64(1))))) == int32('.') { + l = l - 1 + } + if l != 0 && int32(**(**int8)(__ccgo_up(dname + uintptr(l-uint64(1))))) == int32('.') { + return -int32(1) + } + n = Int32FromUint64(uint64(17) + l + BoolUint64(!!(l != 0))) + if l > uint64(253) || buflen < n || Uint32FromInt32(op) > uint32(15) || Uint32FromInt32(class) > uint32(255) || Uint32FromInt32(type1) > uint32(255) { + return -int32(1) + } + /* Construct query template - ID will be filled later */ + Xmemset(tls, bp, 0, Uint64FromInt32(n)) + (**(**[280]uint8)(__ccgo_up(bp)))[int32(2)] = Uint8FromInt32(op*int32(8) + int32(1)) + (**(**[280]uint8)(__ccgo_up(bp)))[int32(3)] = uint8(32) /* AD */ + (**(**[280]uint8)(__ccgo_up(bp)))[int32(5)] = uint8(1) + Xmemcpy(tls, bp+uintptr(13), dname, l) + i = int32(13) + for { + if !((**(**[280]uint8)(__ccgo_up(bp)))[i] != 0) { + break + } + j = i + for { + if !((**(**[280]uint8)(__ccgo_up(bp)))[j] != 0 && Int32FromUint8((**(**[280]uint8)(__ccgo_up(bp)))[j]) != int32('.')) { + break + } + goto _2 + _2: + ; + j = j + 1 + } + if Uint32FromInt32(j-i)-uint32(1) > uint32(62) { + return -int32(1) + } + (**(**[280]uint8)(__ccgo_up(bp)))[i-int32(1)] = Uint8FromInt32(j - i) + goto _1 + _1: + ; + i = j + int32(1) + } + (**(**[280]uint8)(__ccgo_up(bp)))[i+int32(1)] = Uint8FromInt32(type1) + (**(**[280]uint8)(__ccgo_up(bp)))[i+int32(3)] = Uint8FromInt32(class) + /* Make a reasonably unpredictable id */ + Xclock_gettime(tls, CLOCK_REALTIME, bp+280) + id = Int32FromUint64((Uint64FromInt64((**(**Ttimespec)(__ccgo_up(bp + 280))).Ftv_nsec) + Uint64FromInt64((**(**Ttimespec)(__ccgo_up(bp + 280))).Ftv_nsec)/uint64(65536)) & uint64(0xffff)) + (**(**[280]uint8)(__ccgo_up(bp)))[0] = Uint8FromInt32(id / int32(256)) + (**(**[280]uint8)(__ccgo_up(bp)))[int32(1)] = Uint8FromInt32(id) + Xmemcpy(tls, buf, bp, Uint64FromInt32(n)) + return n +} + +func Xres_mkquery(tls *TLS, op int32, dname uintptr, class int32, type1 int32, data uintptr, datalen int32, newrr uintptr, buf uintptr, buflen int32) (r int32) { + if __ccgo_strace { + trc("tls=%v op=%v dname=%v class=%v type1=%v data=%v datalen=%v newrr=%v buf=%v buflen=%v, (%v:)", tls, op, dname, class, type1, data, datalen, newrr, buf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__res_mkquery(tls, op, dname, class, type1, data, datalen, newrr, buf, buflen) +} + +const POLLERR = 8 +const POLLHUP = 16 +const POLLIN = 1 +const POLLMSG = 1024 +const POLLNVAL = 32 +const POLLOUT = 4 +const POLLPRI = 2 +const POLLRDBAND = 128 +const POLLRDHUP = 8192 +const POLLRDNORM = 64 +const POLLWRBAND = 512 +const POLLWRNORM = 256 +const TCP_CC_INFO = 26 +const TCP_CLOSE = 7 +const TCP_CLOSE_WAIT = 8 +const TCP_CLOSING = 11 +const TCP_CM_INQ = 36 +const TCP_CONGESTION = 13 +const TCP_CORK = 3 +const TCP_DEFER_ACCEPT = 9 +const TCP_ESTABLISHED = 1 +const TCP_FASTOPEN = 23 +const TCP_FASTOPEN_CONNECT = 30 +const TCP_FASTOPEN_KEY = 33 +const TCP_FASTOPEN_NO_COOKIE = 34 +const TCP_FIN_WAIT1 = 4 +const TCP_FIN_WAIT2 = 5 +const TCP_INFO = 11 +const TCP_INQ = 36 +const TCP_KEEPCNT = 6 +const TCP_KEEPIDLE = 4 +const TCP_KEEPINTVL = 5 +const TCP_LAST_ACK = 9 +const TCP_LINGER2 = 8 +const TCP_LISTEN = 10 +const TCP_MAXSEG = 2 +const TCP_MD5SIG = 14 +const TCP_MD5SIG_EXT = 32 +const TCP_NODELAY = 1 +const TCP_NOTSENT_LOWAT = 25 +const TCP_QUEUE_SEQ = 21 +const TCP_QUICKACK = 12 +const TCP_REPAIR = 19 +const TCP_REPAIR_OPTIONS = 22 +const TCP_REPAIR_QUEUE = 20 +const TCP_REPAIR_WINDOW = 29 +const TCP_SAVED_SYN = 28 +const TCP_SAVE_SYN = 27 +const TCP_SYNCNT = 7 +const TCP_SYN_RECV = 3 +const TCP_SYN_SENT = 2 +const TCP_THIN_DUPACK = 17 +const TCP_THIN_LINEAR_TIMEOUTS = 16 +const TCP_TIMESTAMP = 24 +const TCP_TIME_WAIT = 6 +const TCP_TX_DELAY = 37 +const TCP_ULP = 31 +const TCP_USER_TIMEOUT = 18 +const TCP_WINDOW_CLAMP = 10 +const TCP_ZEROCOPY_RECEIVE = 35 + +const _TCP_NLA_PAD = 0 +const _TCP_NLA_BUSY = 1 +const _TCP_NLA_RWND_LIMITED = 2 +const _TCP_NLA_SNDBUF_LIMITED = 3 +const _TCP_NLA_DATA_SEGS_OUT = 4 +const _TCP_NLA_TOTAL_RETRANS = 5 +const _TCP_NLA_PACING_RATE = 6 +const _TCP_NLA_DELIVERY_RATE = 7 +const _TCP_NLA_SND_CWND = 8 +const _TCP_NLA_REORDERING = 9 +const _TCP_NLA_MIN_RTT = 10 +const _TCP_NLA_RECUR_RETRANS = 11 +const _TCP_NLA_DELIVERY_RATE_APP_LMT = 12 +const _TCP_NLA_SNDQ_SIZE = 13 +const _TCP_NLA_CA_STATE = 14 +const _TCP_NLA_SND_SSTHRESH = 15 +const _TCP_NLA_DELIVERED = 16 +const _TCP_NLA_DELIVERED_CE = 17 +const _TCP_NLA_BYTES_SENT = 18 +const _TCP_NLA_BYTES_RETRANS = 19 +const _TCP_NLA_DSACK_DUPS = 20 +const _TCP_NLA_REORD_SEEN = 21 +const _TCP_NLA_SRTT = 22 +const _TCP_NLA_TIMEOUT_REHASH = 23 +const _TCP_NLA_BYTES_NOTSENT = 24 +const _TCP_NLA_EDT = 25 +const _TCP_NLA_TTL = 26 + +type Tnfds_t = uint64 + +type Tpollfd = struct { + Ffd int32 + Fevents int16 + Frevents int16 +} + +func _cleanup(tls *TLS, p uintptr) { + var i int32 + var pfd uintptr + _, _ = i, pfd + pfd = p + i = 0 + for { + if !((**(**Tpollfd)(__ccgo_up(pfd + uintptr(i)*8))).Ffd >= -int32(1)) { + break + } + if (**(**Tpollfd)(__ccgo_up(pfd + uintptr(i)*8))).Ffd >= 0 { + X__syscall1(tls, int64(SYS_close), int64((**(**Tpollfd)(__ccgo_up(pfd + uintptr(i)*8))).Ffd)) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +func _mtime(tls *TLS) (r uint64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ts at bp+0 */ Ttimespec + if Xclock_gettime(tls, int32(CLOCK_MONOTONIC), bp) < 0 && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOSYS) { + Xclock_gettime(tls, CLOCK_REALTIME, bp) + } + return Uint64FromInt64((**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec)*uint64(1000) + Uint64FromInt64((**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec/int64(1000000)) +} + +func _start_tcp(tls *TLS, pfd uintptr, family int32, sa uintptr, sl Tsocklen_t, q uintptr, ql int32) (r1 int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var fd, r int32 + var _ /* mh at bp+40 */ Tmsghdr + _, _ = fd, r + *(*[2]Tuint8_t)(unsafe.Pointer(bp + 32)) = [2]Tuint8_t{ + 0: Uint8FromInt32(ql >> int32(8)), + 1: Uint8FromInt32(ql), + } + *(*[2]Tiovec)(unsafe.Pointer(bp)) = [2]Tiovec{ + 0: { + Fiov_base: bp + 32, + Fiov_len: uint64(2), + }, + 1: { + Fiov_base: q, + Fiov_len: Uint64FromInt32(ql), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 40)) = Tmsghdr{ + Fmsg_name: sa, + Fmsg_namelen: sl, + Fmsg_iov: bp, + Fmsg_iovlen: int32(2), + } + fd = Xsocket(tls, family, Int32FromInt32(SOCK_STREAM)|Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK), 0) + (*Tpollfd)(unsafe.Pointer(pfd)).Ffd = fd + (*Tpollfd)(unsafe.Pointer(pfd)).Fevents = int16(POLLOUT) + *(*int32)(unsafe.Pointer(bp + 36)) = int32(1) + if !(Xsetsockopt(tls, fd, int32(IPPROTO_TCP), int32(TCP_FASTOPEN_CONNECT), bp+36, uint32(4)) != 0) { + r = int32(Xsendmsg(tls, fd, bp+40, Int32FromInt32(MSG_FASTOPEN)|Int32FromInt32(MSG_NOSIGNAL))) + if r == ql+int32(2) { + (*Tpollfd)(unsafe.Pointer(pfd)).Fevents = int16(POLLIN) + } + if r >= 0 { + return r + } + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EINPROGRESS) { + return 0 + } + } + r = Xconnect(tls, fd, sa, sl) + if !(r != 0) || **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EINPROGRESS) { + return 0 + } + Xclose(tls, fd) + (*Tpollfd)(unsafe.Pointer(pfd)).Ffd = -int32(1) + return -int32(1) +} + +func _step_mh(tls *TLS, mh uintptr, n Tsize_t) { + /* Adjust iovec in msghdr to skip first n bytes. */ + for (*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iovlen != 0 && n >= (*Tiovec)(unsafe.Pointer((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov)).Fiov_len { + n = n - (*Tiovec)(unsafe.Pointer((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov)).Fiov_len + (*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov += 16 + (*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iovlen = (*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iovlen - 1 + } + if !((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iovlen != 0) { + return + } + (*Tiovec)(unsafe.Pointer((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov)).Fiov_base = (*Tiovec)(unsafe.Pointer((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov)).Fiov_base + uintptr(n) + **(**Tsize_t)(__ccgo_up((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov + 8)) -= n +} + +/* Internal contract for __res_msend[_rc]: asize must be >=512, nqueries + * must be sufficiently small to be safe as VLA size. In practice it's + * either 1 or 2, anyway. */ + +func X__res_msend_rc(tls *TLS, nqueries int32, queries uintptr, qlens uintptr, answers uintptr, alens uintptr, asize int32, conf uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v nqueries=%v queries=%v qlens=%v answers=%v alens=%v asize=%v conf=%v, (%v:)", tls, nqueries, queries, qlens, answers, alens, asize, conf, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(400) + defer tls.Free(400) + var alen, attempts, family, fd, i, j, next, nns, r, rcode, retry_interval, rlen, servfail_retry, timeout, v6 int32 + var alen_buf, apos, iplit, pfd, qpos uintptr + var sl Tsocklen_t + var t0, t1, t2, v10 uint64 + var v1, v2, v3, v4 t__predefined_size_t + var v18 bool + var _ /* __cb at bp+208 */ t__ptcb + var _ /* cs at bp+200 */ int32 + var _ /* mh at bp+232 */ Tmsghdr + var _ /* mh at bp+288 */ Tmsghdr + var _ /* mh at bp+344 */ Tmsghdr + var _ /* ns at bp+116 */ [3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + } + var _ /* sa at bp+88 */ struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alen, alen_buf, apos, attempts, family, fd, i, iplit, j, next, nns, pfd, qpos, r, rcode, retry_interval, rlen, servfail_retry, sl, t0, t1, t2, timeout, v1, v10, v18, v2, v3, v4, v6 + defer func() { + Xrealloc(tls, alen_buf, 0) + Xrealloc(tls, apos, 0) + Xrealloc(tls, pfd, 0) + Xrealloc(tls, qpos, 0) + }() + *(*struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(unsafe.Pointer(bp + 88)) = struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + }{} + *(*uint16)(unsafe.Pointer(bp + 88)) = uint16(0) + **(**[3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 116)) = [3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + }{} + sl = uint32(16) + nns = 0 + family = int32(PF_INET) + v1 = Uint64FromInt32(nqueries+int32(2)) * 8 + pfd = Xrealloc(tls, pfd, v1) + v2 = Uint64FromInt32(nqueries) * 4 + qpos = Xrealloc(tls, qpos, v2) + v3 = Uint64FromInt32(nqueries) * 4 + apos = Xrealloc(tls, apos, v3) + v4 = Uint64FromInt32(nqueries) * 2 + alen_buf = Xrealloc(tls, alen_buf, v4) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+200) + timeout = Int32FromUint32(uint32(1000) * (*Tresolvconf)(unsafe.Pointer(conf)).Ftimeout) + attempts = Int32FromUint32((*Tresolvconf)(unsafe.Pointer(conf)).Fattempts) + nns = 0 + for { + if !(Uint32FromInt32(nns) < (*Tresolvconf)(unsafe.Pointer(conf)).Fnns) { + break + } + iplit = conf + uintptr(nns)*28 + if (*Taddress)(unsafe.Pointer(iplit)).Ffamily == int32(PF_INET) { + Xmemcpy(tls, bp+116+uintptr(nns)*28+4, iplit+8, uint64(4)) + (**(**[3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 116)))[nns].Fsin.Fsin_port = Xhtons(tls, uint16(53)) + (**(**[3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 116)))[nns].Fsin.Fsin_family = uint16(PF_INET) + } else { + sl = uint32(28) + Xmemcpy(tls, bp+116+uintptr(nns)*28+8, iplit+8, uint64(16)) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(nns)*28))).Fsin6_port = Xhtons(tls, uint16(53)) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(nns)*28))).Fsin6_scope_id = (*Taddress)(unsafe.Pointer(iplit)).Fscopeid + v6 = Int32FromInt32(PF_INET6) + family = v6 + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(nns)*28))).Fsin6_family = Uint16FromInt32(v6) + } + goto _5 + _5: + ; + nns = nns + 1 + } + /* Get local address and open/bind a socket */ + fd = Xsocket(tls, family, Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK), 0) + /* Handle case where system lacks IPv6 support */ + if fd < 0 && family == int32(PF_INET6) && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EAFNOSUPPORT) { + i = 0 + for { + if !(i < nns && (**(**Taddress)(__ccgo_up(conf + uintptr(nns)*28))).Ffamily == int32(PF_INET6)) { + break + } + goto _7 + _7: + ; + i = i + 1 + } + if i == nns { + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 200)), uintptr(0)) + return -int32(1) + } + fd = Xsocket(tls, int32(PF_INET), Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK), 0) + family = int32(PF_INET) + sl = uint32(16) + } + /* Convert any IPv4 addresses in a mixed environment to v4-mapped */ + if fd >= 0 && family == int32(PF_INET6) { + *(*int32)(unsafe.Pointer(bp)) = 0 + Xsetsockopt(tls, fd, int32(IPPROTO_IPV6), int32(IPV6_V6ONLY), bp, uint32(4)) + i = 0 + for { + if !(i < nns) { + break + } + if Int32FromUint16((**(**[3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 116)))[i].Fsin.Fsin_family) != int32(PF_INET) { + goto _8 + } + Xmemcpy(tls, bp+116+uintptr(i)*28+8+uintptr(12), bp+116+uintptr(i)*28+4, uint64(4)) + Xmemcpy(tls, bp+116+uintptr(i)*28+8, __ccgo_ts+1044, uint64(12)) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(i)*28))).Fsin6_family = uint16(PF_INET6) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(i)*28))).Fsin6_flowinfo = uint32(0) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(i)*28))).Fsin6_scope_id = uint32(0) + goto _8 + _8: + ; + i = i + 1 + } + } + (**(**struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 88))).Fsin.Fsin_family = Uint16FromInt32(family) + if fd < 0 || Xbind(tls, fd, bp+88, sl) < 0 { + if fd >= 0 { + Xclose(tls, fd) + } + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 200)), uintptr(0)) + return -int32(1) + } + /* Past this point, there are no errors. Each individual query will + * yield either no reply (indicated by zero length) or an answer + * packet which is up to the caller to interpret. */ + i = 0 + for { + if !(i < nqueries) { + break + } + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd = -int32(1) + goto _9 + _9: + ; + i = i + 1 + } + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), nqueries*8))).Ffd = fd + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), nqueries*8))).Fevents = int16(POLLIN) + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), (nqueries+int32(1))*8))).Ffd = -int32(2) + __pthread_cleanup_push(tls, bp+208, __ccgo_fp(_cleanup), pfd) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 200)), uintptr(0)) + Xmemset(tls, alens, 0, uint64(4)*Uint64FromInt32(nqueries)) + retry_interval = timeout / attempts + next = 0 + v10 = _mtime(tls) + t2 = v10 + t0 = v10 + t1 = t2 - Uint64FromInt32(retry_interval) + for { + if !(t2-t0 < Uint64FromInt32(timeout)) { + break + } + /* This is the loop exit condition: that all queries + * have an accepted answer. */ + i = 0 + for { + if !(i < nqueries && **(**int32)(__ccgo_up(alens + uintptr(i)*4)) > 0) { + break + } + goto _12 + _12: + ; + i = i + 1 + } + if i == nqueries { + break + } + if t2-t1 >= Uint64FromInt32(retry_interval) { + /* Query all configured namservers in parallel */ + i = 0 + for { + if !(i < nqueries) { + break + } + if !(**(**int32)(__ccgo_up(alens + uintptr(i)*4)) != 0) { + j = 0 + for { + if !(j < nns) { + break + } + Xsendto(tls, fd, **(**uintptr)(__ccgo_up(queries + uintptr(i)*8)), Uint64FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4))), int32(MSG_NOSIGNAL), bp+116+uintptr(j)*28, sl) + goto _14 + _14: + ; + j = j + 1 + } + } + goto _13 + _13: + ; + i = i + 1 + } + t1 = t2 + servfail_retry = int32(2) * nqueries + } + /* Wait for a response, or until time to retry */ + if Xpoll(tls, pfd, Uint64FromInt32(nqueries+int32(1)), Int32FromUint64(t1+Uint64FromInt32(retry_interval)-t2)) <= 0 { + goto _11 + } + for next < nqueries { + *(*[1]Tiovec)(unsafe.Pointer(bp + 8)) = [1]Tiovec{ + 0: { + Fiov_base: **(**uintptr)(__ccgo_up(answers + uintptr(next)*8)), + Fiov_len: Uint64FromInt32(asize), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 232)) = Tmsghdr{ + Fmsg_name: bp + 88, + Fmsg_namelen: sl, + Fmsg_iov: bp + 8, + Fmsg_iovlen: int32(1), + } + rlen = int32(Xrecvmsg(tls, fd, bp+232, 0)) + if rlen < 0 { + break + } + /* Ignore non-identifiable packets */ + if rlen < int32(4) { + continue + } + /* Ignore replies from addresses we didn't send to */ + j = 0 + for { + if !(j < nns && Xmemcmp(tls, bp+116+uintptr(j)*28, bp+88, uint64(sl)) != 0) { + break + } + goto _15 + _15: + ; + j = j + 1 + } + if j == nns { + continue + } + /* Find which query this answer goes with, if any */ + i = next + for { + if !(i < nqueries && (Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(next)*8))))) != Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(queries + uintptr(i)*8))))) || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(next)*8)) + 1))) != Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(queries + uintptr(i)*8)) + 1))))) { + break + } + goto _16 + _16: + ; + i = i + 1 + } + if i == nqueries { + continue + } + if **(**int32)(__ccgo_up(alens + uintptr(i)*4)) != 0 { + continue + } + /* Only accept positive or negative responses; + * retry immediately on server failure, and ignore + * all other codes such as refusal. */ + switch Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(next)*8)) + 3))) & Int32FromInt32(15) { + case 0: + fallthrough + case int32(3): + case int32(2): + if v18 = servfail_retry != 0; v18 { + v6 = servfail_retry + servfail_retry = servfail_retry - 1 + } + if v18 && v6 != 0 { + Xsendto(tls, fd, **(**uintptr)(__ccgo_up(queries + uintptr(i)*8)), Uint64FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4))), int32(MSG_NOSIGNAL), bp+116+uintptr(j)*28, sl) + } + fallthrough + default: + continue + } + /* Store answer in the right slot, or update next + * available temp slot if it's already in place. */ + **(**int32)(__ccgo_up(alens + uintptr(i)*4)) = rlen + if i == next { + for { + if !(next < nqueries && **(**int32)(__ccgo_up(alens + uintptr(next)*4)) != 0) { + break + } + goto _19 + _19: + ; + next = next + 1 + } + } else { + Xmemcpy(tls, **(**uintptr)(__ccgo_up(answers + uintptr(i)*8)), **(**uintptr)(__ccgo_up(answers + uintptr(next)*8)), Uint64FromInt32(rlen)) + } + /* Ignore further UDP if all slots full or TCP-mode */ + if next == nqueries { + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), nqueries*8))).Fevents = 0 + } + /* If answer is truncated (TC bit), fallback to TCP */ + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(i)*8)) + 2)))&int32(2) != 0 || (**(**Tmsghdr)(__ccgo_up(bp + 232))).Fmsg_flags&int32(MSG_TRUNC) != 0 { + **(**int32)(__ccgo_up(alens + uintptr(i)*4)) = -int32(1) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), uintptr(0)) + r = _start_tcp(tls, pfd+uintptr(i)*8, family, bp+116+uintptr(j)*28, sl, **(**uintptr)(__ccgo_up(queries + uintptr(i)*8)), **(**int32)(__ccgo_up(qlens + uintptr(i)*4))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 200)), uintptr(0)) + if r >= 0 { + *(*int32)(unsafe.Add(unsafe.Pointer(qpos), i*4)) = r + *(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)) = 0 + } + continue + } + } + i = 0 + for { + if !(i < nqueries) { + break + } + if int32((*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Frevents)&int32(POLLOUT) != 0 { + *(*[2]Tuint8_t)(unsafe.Pointer(bp + 52)) = [2]Tuint8_t{ + 0: Uint8FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4)) >> int32(8)), + 1: Uint8FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4))), + } + *(*[2]Tiovec)(unsafe.Pointer(bp + 24)) = [2]Tiovec{ + 0: { + Fiov_base: bp + 52, + Fiov_len: uint64(2), + }, + 1: { + Fiov_base: **(**uintptr)(__ccgo_up(queries + uintptr(i)*8)), + Fiov_len: Uint64FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4))), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 288)) = Tmsghdr{ + Fmsg_iov: bp + 24, + Fmsg_iovlen: int32(2), + } + _step_mh(tls, bp+288, Uint64FromInt32(*(*int32)(unsafe.Add(unsafe.Pointer(qpos), i*4)))) + r = int32(Xsendmsg(tls, (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd, bp+288, int32(MSG_NOSIGNAL))) + if r < 0 { + goto out + } + **(**int32)(__ccgo_up(qpos + uintptr(i)*4)) += r + if *(*int32)(unsafe.Add(unsafe.Pointer(qpos), i*4)) == **(**int32)(__ccgo_up(qlens + uintptr(i)*4))+int32(2) { + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Fevents = int16(POLLIN) + } + } + goto _20 + _20: + ; + i = i + 1 + } + i = 0 + for { + if !(i < nqueries) { + break + } + if int32((*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Frevents)&int32(POLLIN) != 0 { + *(*[2]Tiovec)(unsafe.Pointer(bp + 56)) = [2]Tiovec{ + 0: { + Fiov_base: alen_buf + uintptr(i)*2, + Fiov_len: uint64(2), + }, + 1: { + Fiov_base: **(**uintptr)(__ccgo_up(answers + uintptr(i)*8)), + Fiov_len: Uint64FromInt32(asize), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 344)) = Tmsghdr{ + Fmsg_iov: bp + 56, + Fmsg_iovlen: int32(2), + } + _step_mh(tls, bp+344, Uint64FromInt32(*(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)))) + r = int32(Xrecvmsg(tls, (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd, bp+344, 0)) + if r <= 0 { + goto out + } + **(**int32)(__ccgo_up(apos + uintptr(i)*4)) += r + if *(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)) < int32(2) { + goto _21 + } + alen = Int32FromUint8(**(**uint8)(__ccgo_up(alen_buf + uintptr(i)*2)))*int32(256) + Int32FromUint8(**(**uint8)(__ccgo_up(alen_buf + uintptr(i)*2 + 1))) + if alen < int32(13) { + goto out + } + if *(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)) < alen+int32(2) && *(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)) < asize+int32(2) { + goto _21 + } + rcode = Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(i)*8)) + 3))) & int32(15) + if rcode != 0 && rcode != int32(3) { + goto out + } + /* Storing the length here commits the accepted answer. + * Immediately close TCP socket so as not to consume + * resources we no longer need. */ + **(**int32)(__ccgo_up(alens + uintptr(i)*4)) = alen + X__syscall1(tls, int64(SYS_close), int64((*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd)) + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd = -int32(1) + } + goto _21 + _21: + ; + i = i + 1 + } + goto _11 + _11: + ; + t2 = _mtime(tls) + } + goto out +out: + ; + __pthread_cleanup_pop(tls, bp+208, int32(1)) + /* Disregard any incomplete TCP results */ + i = 0 + for { + if !(i < nqueries) { + break + } + if **(**int32)(__ccgo_up(alens + uintptr(i)*4)) < 0 { + **(**int32)(__ccgo_up(alens + uintptr(i)*4)) = 0 + } + goto _22 + _22: + ; + i = i + 1 + } + return 0 +} + +func X__res_msend(tls *TLS, nqueries int32, queries uintptr, qlens uintptr, answers uintptr, alens uintptr, asize int32) (r int32) { + if __ccgo_strace { + trc("tls=%v nqueries=%v queries=%v qlens=%v answers=%v alens=%v asize=%v, (%v:)", tls, nqueries, queries, qlens, answers, alens, asize, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(112) + defer tls.Free(112) + var _ /* conf at bp+0 */ Tresolvconf + if X__get_resolv_conf(tls, bp, uintptr(0), uint64(0)) < 0 { + return -int32(1) + } + return X__res_msend_rc(tls, nqueries, queries, qlens, answers, alens, asize, bp) +} + +func X__res_send(tls *TLS, _msg uintptr, _msglen int32, _answer uintptr, _anslen int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v _msg=%v _msglen=%v _answer=%v _anslen=%v, (%v:)", tls, _msg, _msglen, _answer, _anslen, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(544) + defer tls.Free(544) + *(*uintptr)(unsafe.Pointer(bp)) = _msg + *(*int32)(unsafe.Pointer(bp + 8)) = _msglen + *(*uintptr)(unsafe.Pointer(bp + 16)) = _answer + *(*int32)(unsafe.Pointer(bp + 24)) = _anslen + var r, v1 int32 + var _ /* buf at bp+28 */ [512]uint8 + _, _ = r, v1 + if **(**int32)(__ccgo_up(bp + 24)) < int32(512) { + r = X__res_send(tls, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), bp+28, int32(512)) + if r >= 0 { + if r < **(**int32)(__ccgo_up(bp + 24)) { + v1 = r + } else { + v1 = **(**int32)(__ccgo_up(bp + 24)) + } + Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp + 16)), bp+28, Uint64FromInt32(v1)) + } + return r + } + r = X__res_msend(tls, int32(1), bp, bp+8, bp+16, bp+24, **(**int32)(__ccgo_up(bp + 24))) + if r < 0 || !(**(**int32)(__ccgo_up(bp + 24)) != 0) { + v1 = -int32(1) + } else { + v1 = **(**int32)(__ccgo_up(bp + 24)) + } + return v1 +} + +func Xres_send(tls *TLS, _msg uintptr, _msglen int32, _answer uintptr, _anslen int32) (r int32) { + if __ccgo_strace { + trc("tls=%v _msg=%v _msglen=%v _answer=%v _anslen=%v, (%v:)", tls, _msg, _msglen, _answer, _anslen, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__res_send(tls, _msg, _msglen, _answer, _anslen) +} + +/* This is completely unused, and exists purely to satisfy broken apps. */ + +func X__res_state(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_res1)) +} + +var _res1 t__res_state + +func X__get_resolv_conf(tls *TLS, conf uintptr, search uintptr, search_sz Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v conf=%v search=%v search_sz=%v, (%v:)", tls, conf, search, search_sz, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(752) + defer tls.Free(752) + var c, nns, v1, v2 int32 + var f, p uintptr + var l Tsize_t + var x, x1, x2, v5 uint64 + var v4 bool + var _ /* _buf at bp+256 */ [256]uint8 + var _ /* _f at bp+512 */ TFILE + var _ /* line at bp+0 */ [256]int8 + var _ /* z at bp+744 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = c, f, l, nns, p, x, x1, x2, v1, v2, v4, v5 + nns = 0 + (*Tresolvconf)(unsafe.Pointer(conf)).Fndots = uint32(1) + (*Tresolvconf)(unsafe.Pointer(conf)).Ftimeout = uint32(5) + (*Tresolvconf)(unsafe.Pointer(conf)).Fattempts = uint32(2) + if search != 0 { + **(**int8)(__ccgo_up(search)) = 0 + } + f = X__fopen_rb_ca(tls, __ccgo_ts+1166, bp+512, bp+256, uint64(256)) + if !(f != 0) { + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(ENOENT): + fallthrough + case int32(ENOTDIR): + fallthrough + case int32(EACCES): + goto no_resolv_conf + default: + return -int32(1) + } + } + for Xfgets(tls, bp, int32(256), f) != 0 { + if !(Xstrchr(tls, bp, int32('\n')) != 0) && !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_EOF) != 0) { + for cond := true; cond; cond = c != int32('\n') && c != -int32(1) { + c = Xgetc(tls, f) + } + continue + } + if v4 = !(Xstrncmp(tls, bp, __ccgo_ts+1183, uint64(7)) != 0); v4 { + v1 = int32((**(**[256]int8)(__ccgo_up(bp)))[int32(7)]) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + } + if v4 && v2 != 0 { + p = Xstrstr(tls, bp, __ccgo_ts+1191) + if p != 0 && BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(p + 6)))-uint32('0') < uint32(10)) != 0 { + p = p + uintptr(6) + x = Xstrtoul(tls, p, bp+744, int32(10)) + if **(**uintptr)(__ccgo_up(bp + 744)) != p { + if x > uint64(15) { + v5 = uint64(15) + } else { + v5 = x + } + (*Tresolvconf)(unsafe.Pointer(conf)).Fndots = uint32(v5) + } + } + p = Xstrstr(tls, bp, __ccgo_ts+1198) + if p != 0 && BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(p + 9)))-uint32('0') < uint32(10)) != 0 { + p = p + uintptr(9) + x1 = Xstrtoul(tls, p, bp+744, int32(10)) + if **(**uintptr)(__ccgo_up(bp + 744)) != p { + if x1 > uint64(10) { + v5 = uint64(10) + } else { + v5 = x1 + } + (*Tresolvconf)(unsafe.Pointer(conf)).Fattempts = uint32(v5) + } + } + p = Xstrstr(tls, bp, __ccgo_ts+1208) + if p != 0 && (BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(p + 8)))-uint32('0') < uint32(10)) != 0 || int32(**(**int8)(__ccgo_up(p + 8))) == int32('.')) { + p = p + uintptr(8) + x2 = Xstrtoul(tls, p, bp+744, int32(10)) + if **(**uintptr)(__ccgo_up(bp + 744)) != p { + if x2 > uint64(60) { + v5 = uint64(60) + } else { + v5 = x2 + } + (*Tresolvconf)(unsafe.Pointer(conf)).Ftimeout = uint32(v5) + } + } + continue + } + if v4 = !(Xstrncmp(tls, bp, __ccgo_ts+1217, uint64(10)) != 0); v4 { + v1 = int32((**(**[256]int8)(__ccgo_up(bp)))[int32(10)]) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _10 + _10: + } + if v4 && v2 != 0 { + if nns >= int32(MAXNS) { + continue + } + p = bp + uintptr(11) + for { + v1 = int32(**(**int8)(__ccgo_up(p))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _15 + _15: + if !(v2 != 0) { + break + } + goto _12 + _12: + ; + p = p + 1 + } + **(**uintptr)(__ccgo_up(bp + 744)) = p + for { + if v4 = **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 744)))) != 0; v4 { + v1 = int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 744))))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _19 + _19: + } + if !(v4 && !(v2 != 0)) { + break + } + goto _16 + _16: + ; + **(**uintptr)(__ccgo_up(bp + 744)) = **(**uintptr)(__ccgo_up(bp + 744)) + 1 + } + **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 744)))) = 0 + if X__lookup_ipliteral(tls, conf+uintptr(nns)*28, p, PF_UNSPEC) > 0 { + nns = nns + 1 + } + continue + } + if !(search != 0) { + continue + } + if v4 = Xstrncmp(tls, bp, __ccgo_ts+1228, uint64(6)) != 0 && Xstrncmp(tls, bp, __ccgo_ts+1235, uint64(6)) != 0; !v4 { + v1 = int32((**(**[256]int8)(__ccgo_up(bp)))[int32(6)]) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _23 + _23: + } + if v4 || !(v2 != 0) { + continue + } + p = bp + uintptr(7) + for { + v1 = int32(**(**int8)(__ccgo_up(p))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _28 + _28: + if !(v2 != 0) { + break + } + goto _25 + _25: + ; + p = p + 1 + } + l = _strlen(tls, p) + /* This can never happen anyway with chosen buffer sizes. */ + if l >= search_sz { + continue + } + Xmemcpy(tls, search, p, l+uint64(1)) + } + X__fclose_ca(tls, f) + goto no_resolv_conf +no_resolv_conf: + ; + if !(nns != 0) { + X__lookup_ipliteral(tls, conf, __ccgo_ts+1242, PF_UNSPEC) + nns = int32(1) + } + (*Tresolvconf)(unsafe.Pointer(conf)).Fnns = Uint32FromInt32(nns) + return 0 +} + +func Xsend(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v flags=%v, (%v:)", tls, fd, buf, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsendto(tls, fd, buf, len1, flags, uintptr(0), uint32(0)) +} + +func Xsendmmsg(tls *TLS, fd int32, msgvec uintptr, vlen uint32, flags uint32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v msgvec=%v vlen=%v flags=%v, (%v:)", tls, fd, msgvec, vlen, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var i, v2 int32 + var r Tssize_t + _, _, _ = i, r, v2 + if vlen > uint32(IOV_MAX) { + vlen = uint32(IOV_MAX) + } /* This matches the kernel. */ + if !(vlen != 0) { + return 0 + } + i = 0 + for { + if !(Uint32FromInt32(i) < vlen) { + break + } + /* As an unfortunate inconsistency, the sendmmsg API uses + * unsigned int for the resulting msg_len, despite sendmsg + * returning ssize_t. However Linux limits the total bytes + * sent by sendmsg to INT_MAX, so the assignment is safe. */ + r = Xsendmsg(tls, fd, msgvec+uintptr(i)*64, Int32FromUint32(flags)) + if r < 0 { + goto error + } + (**(**Tmmsghdr)(__ccgo_up(msgvec + uintptr(i)*64))).Fmsg_len = Uint32FromInt64(r) + goto _1 + _1: + ; + i = i + 1 + } + goto error +error: + ; + if i != 0 { + v2 = i + } else { + v2 = -int32(1) + } + return v2 + return r1 +} + +func Xsendmsg(tls *TLS, fd int32, msg uintptr, flags int32) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v msg=%v flags=%v, (%v:)", tls, fd, msg, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(1120) + defer tls.Free(1120) + var c1, v3 uintptr + var r, v12 int64 + var v1 int32 + var v10, v11, v6, v7, v8, v9 Tsyscall_arg_t + var _ /* chbuf at bp+56 */ [66]Tcmsghdr + var _ /* h at bp+0 */ Tmsghdr + _, _, _, _, _, _, _, _, _, _, _ = c1, r, v1, v10, v11, v12, v3, v6, v7, v8, v9 + if msg != 0 { + **(**Tmsghdr)(__ccgo_up(bp)) = **(**Tmsghdr)(__ccgo_up(msg)) + v1 = Int32FromInt32(0) + (**(**Tmsghdr)(__ccgo_up(bp))).F__pad2 = v1 + (**(**Tmsghdr)(__ccgo_up(bp))).F__pad1 = v1 + msg = bp + if (**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_controllen != 0 { + if uint64((**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_controllen) > uint64(1056) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return int64(-int32(1)) + } + Xmemcpy(tls, bp+56, (**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_control, uint64((**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_controllen)) + (**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_control = bp + 56 + if uint64((*Tmsghdr)(unsafe.Pointer(bp)).Fmsg_controllen) >= uint64(16) { + v3 = (*Tmsghdr)(unsafe.Pointer(bp)).Fmsg_control + } else { + v3 = UintptrFromInt32(0) + } + c1 = v3 + for { + if !(c1 != 0) { + break + } + (*Tcmsghdr)(unsafe.Pointer(c1)).F__pad1 = 0 + goto _2 + _2: + ; + if uint64((*Tcmsghdr)(unsafe.Pointer(c1)).Fcmsg_len) < uint64(16) || (uint64((*Tcmsghdr)(unsafe.Pointer(c1)).Fcmsg_len)+uint64(8)-uint64(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))+uint64(16) >= Uint64FromInt64(int64((*Tmsghdr)(unsafe.Pointer(bp)).Fmsg_control+uintptr((*Tmsghdr)(unsafe.Pointer(bp)).Fmsg_controllen))-int64(c1)) { + v3 = uintptr(0) + } else { + v3 = c1 + uintptr((uint64((*Tcmsghdr)(unsafe.Pointer(c1)).Fcmsg_len)+Uint64FromInt64(8)-Uint64FromInt32(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))) + } + c1 = v3 + } + } + } + v1 = int32(SYS_sendmsg) + _ = int32(__SC_sendmsg) + v6 = int64(fd) + v7 = int64(msg) + v8 = int64(flags) + v9 = int64(Int32FromInt32(0)) + v10 = int64(Int32FromInt32(0)) + v11 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v6, v7, v8, v9, v10, v11) + } else { + r = X__syscall6(tls, int64(v1), v6, v7, v8, v9, v10, v11) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v12 = r + goto _13 + } + v12 = r + goto _13 +_13: + return X__syscall_ret(tls, Uint64FromInt64(v12)) +} + +func Xsendto(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32, addr uintptr, alen Tsocklen_t) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v flags=%v addr=%v alen=%v, (%v:)", tls, fd, buf, len1, flags, addr, alen, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_sendto) + _ = int32(__SC_sendto) + v2 = int64(fd) + v3 = int64(buf) + v4 = Int64FromUint64(len1) + v5 = int64(flags) + v6 = int64(addr) + v7 = Int64FromUint32(alen) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return X__syscall_ret(tls, Uint64FromInt64(v8)) +} + +func Xendservent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xsetservent(tls *TLS, stayopen int32) { + if __ccgo_strace { + trc("tls=%v stayopen=%v, (%v:)", tls, stayopen, origin(2)) + } +} + +func Xgetservent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xsetsockopt(tls *TLS, fd int32, level int32, optname int32, optval uintptr, optlen Tsocklen_t) (r2 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v level=%v optname=%v optval=%v optlen=%v, (%v:)", tls, fd, level, optname, optval, optlen, origin(2)) + defer func() { trc("-> %v", r2) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r, v8 int64 + var r1, v1 int32 + var s Ttime_t + var tv uintptr + var us Tsuseconds_t + var v10 uint64 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = r, r1, s, tv, us, v1, v10, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_setsockopt) + _ = int32(__SC_setsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(optval) + v6 = Int64FromUint32(optlen) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + r1 = int32(v8) + if r1 == -int32(ENOPROTOOPT) { + switch level { + case int32(SOL_SOCKET): + switch optname { + case int32(SO_RCVTIMEO): + fallthrough + case int32(SO_SNDTIMEO): + if true { + break + } + if uint64(optlen) < uint64(16) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + tv = optval + s = (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec + us = (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec + if !!((Uint64FromInt64(s)+Uint64FromUint64(0x80000000))>>Int32FromInt32(32) != 0) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } + if optname == int32(SO_RCVTIMEO) { + optname = int32(SO_RCVTIMEO_OLD) + } + if optname == int32(SO_SNDTIMEO) { + optname = int32(SO_SNDTIMEO_OLD) + } + if !((Uint64FromInt64(us)+Uint64FromUint64(0x80000000))>>Int32FromInt32(32) != 0) { + v10 = Uint64FromInt64(us) + } else { + v10 = uint64(0x7fffffff) + (0+Uint64FromInt64(us))>>int32(63) + } + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: s, + 1: int64(Int32FromUint64(v10)), + } + v1 = int32(SYS_setsockopt) + _ = int32(__SC_setsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(bp) + v6 = Int64FromUint64(Uint64FromInt32(2) * Uint64FromInt64(8)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _19 + } + v8 = r + goto _19 + _19: + r1 = int32(v8) + case int32(SO_TIMESTAMP): + fallthrough + case int32(SO_TIMESTAMPNS): + if true { + break + } + if optname == int32(SO_TIMESTAMP) { + optname = int32(SO_TIMESTAMP_OLD) + } + if optname == int32(SO_TIMESTAMPNS) { + optname = int32(SO_TIMESTAMPNS_OLD) + } + v1 = int32(SYS_setsockopt) + _ = int32(__SC_setsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(optval) + v6 = Int64FromUint32(optlen) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _28 + } + v8 = r + goto _28 + _28: + r1 = int32(v8) + break + } + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r1))) +} + +func Xshutdown(tls *TLS, fd int32, how int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v how=%v, (%v:)", tls, fd, how, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_shutdown) + _ = int32(__SC_shutdown) + v2 = int64(fd) + v3 = int64(how) + v4 = int64(Int32FromInt32(0)) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func Xsockatmark(tls *TLS, s int32) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* ret at bp+0 */ int32 + if Xioctl(tls, s, int32(SIOCATMARK), VaList(bp+16, bp)) < 0 { + return -int32(1) + } + return **(**int32)(__ccgo_up(bp)) +} + +func Xsocket(tls *TLS, domain int32, type1 int32, protocol int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v domain=%v type1=%v protocol=%v, (%v:)", tls, domain, type1, protocol, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v17, v8 int64 + var s, v1, v10 int32 + var v11, v12, v13, v14, v15, v16, v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = r, s, v1, v10, v11, v12, v13, v14, v15, v16, v17, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_socket) + _ = int32(__SC_socket) + v2 = int64(domain) + v3 = int64(type1) + v4 = int64(protocol) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + s = int32(v8) + if (s == -int32(EINVAL) || s == -int32(EPROTONOSUPPORT)) && type1&(Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK)) != 0 { + v10 = int32(SYS_socket) + _ = int32(__SC_socket) + v11 = int64(domain) + v12 = int64(type1 & ^(Int32FromInt32(SOCK_CLOEXEC) | Int32FromInt32(SOCK_NONBLOCK))) + v13 = int64(protocol) + v14 = int64(Int32FromInt32(0)) + v15 = int64(Int32FromInt32(0)) + v16 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v10), v11, v12, v13, v14, v15, v16) + } else { + r = X__syscall6(tls, int64(v10), v11, v12, v13, v14, v15, v16) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v17 = r + goto _18 + } + v17 = r + goto _18 + _18: + s = int32(v17) + if s < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(s))) + } + if type1&int32(SOCK_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(s), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if type1&int32(SOCK_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(s), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(s))) +} + +func Xsocketpair(tls *TLS, domain int32, type1 int32, protocol int32, fd uintptr) (r2 int32) { + if __ccgo_strace { + trc("tls=%v domain=%v type1=%v protocol=%v fd=%v, (%v:)", tls, domain, type1, protocol, fd, origin(2)) + defer func() { trc("-> %v", r2) }() + } + var r, v17, v8 int64 + var r1, v1, v10 int32 + var v11, v12, v13, v14, v15, v16, v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = r, r1, v1, v10, v11, v12, v13, v14, v15, v16, v17, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_socketpair) + _ = int32(__SC_socketpair) + v2 = int64(domain) + v3 = int64(type1) + v4 = int64(protocol) + v5 = int64(fd) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + r1 = int32(X__syscall_ret(tls, Uint64FromInt64(v8))) + if r1 < 0 && (**(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EINVAL) || **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EPROTONOSUPPORT)) && type1&(Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK)) != 0 { + v10 = int32(SYS_socketpair) + _ = int32(__SC_socketpair) + v11 = int64(domain) + v12 = int64(type1 & ^(Int32FromInt32(SOCK_CLOEXEC) | Int32FromInt32(SOCK_NONBLOCK))) + v13 = int64(protocol) + v14 = int64(fd) + v15 = int64(Int32FromInt32(0)) + v16 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v10), v11, v12, v13, v14, v15, v16) + } else { + r = X__syscall6(tls, int64(v10), v11, v12, v13, v14, v15, v16) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v17 = r + goto _18 + } + v17 = r + goto _18 + _18: + r1 = int32(X__syscall_ret(tls, Uint64FromInt64(v17))) + if r1 < 0 { + return r1 + } + if type1&int32(SOCK_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd))), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd + 1*4))), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if type1&int32(SOCK_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd))), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd + 1*4))), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + } + return r1 +} + +const SHADOW = "/etc/shadow" + +type Tgroup = struct { + Fgr_name uintptr + Fgr_passwd uintptr + Fgr_gid Tgid_t + Fgr_mem uintptr +} + +type Tspwd = struct { + Fsp_namp uintptr + Fsp_pwdp uintptr + Fsp_lstchg int64 + Fsp_min int64 + Fsp_max int64 + Fsp_warn int64 + Fsp_inact int64 + Fsp_expire int64 + Fsp_flag uint64 +} + +func Xfgetgrent(tls *TLS, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* nmem at bp+16 */ Tsize_t + var _ /* res at bp+0 */ uintptr + var _ /* size at bp+8 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**Tsize_t)(__ccgo_up(bp + 16)) = uint64(0) + X__getgrent_a(tls, f, uintptr(unsafe.Pointer(&_gr)), uintptr(unsafe.Pointer(&_line1)), bp+8, uintptr(unsafe.Pointer(&_mem)), bp+16, bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +var _line1 uintptr + +var _mem uintptr + +var _gr Tgroup + +func Xfgetpwent(tls *TLS, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+8 */ uintptr + var _ /* size at bp+0 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp)) = uint64(0) + X__getpwent_a(tls, f, uintptr(unsafe.Pointer(&_pw)), uintptr(unsafe.Pointer(&_line2)), bp, bp+8) + return **(**uintptr)(__ccgo_up(bp + 8)) +} + +var _line2 uintptr + +var _pw Tpasswd + +const GETGRBYGID = 3 +const GETGRBYNAME = 2 +const GETINITGR = 15 +const GETPWBYNAME = 0 +const GETPWBYUID = 1 +const GRFOUND = 1 +const GRGID = 4 +const GRMEMCNT = 5 +const GRNAMELEN = 2 +const GRPASSWDLEN = 3 +const GRVERSION = 0 +const GR_LEN = 6 +const INITGRFOUND = 1 +const INITGRNGRPS = 2 +const INITGRVERSION = 0 +const INITGR_LEN = 3 +const NSCDVERSION = 2 +const PWDIRLEN = 7 +const PWFOUND = 1 +const PWGECOSLEN = 6 +const PWGID = 5 +const PWNAMELEN = 2 +const PWPASSWDLEN = 3 +const PWSHELLLEN = 8 +const PWUID = 4 +const PWVERSION = 0 +const PW_LEN = 9 +const REQKEYLEN = 2 +const REQTYPE = 1 +const REQVERSION = 0 +const REQ_LEN = 3 + +func _itoa1(tls *TLS, p uintptr, x Tuint32_t) (r uintptr) { + var v1 uintptr + _ = v1 + // number of digits in a uint32_t + NUL + p = p + uintptr(11) + p = p - 1 + v1 = p + **(**int8)(__ccgo_up(v1)) = 0 + for cond := true; cond; cond = x != 0 { + p = p - 1 + v1 = p + **(**int8)(__ccgo_up(v1)) = Int8FromUint32(uint32('0') + x%uint32(10)) + x = x / uint32(10) + } + return p +} + +func X__getgr_a(tls *TLS, name uintptr, gid Tgid_t, gr uintptr, buf uintptr, size uintptr, mem uintptr, nmem uintptr, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v gid=%v gr=%v buf=%v size=%v mem=%v nmem=%v res=%v, (%v:)", tls, name, gid, gr, buf, size, mem, nmem, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var f, key, ptr, tmp, tmp1 uintptr + var grlist_len, len1 Tsize_t + var i, req, v10 Tint32_t + var rv, v1 int32 + var v5, v6 Tuint32_t + var _ /* cs at bp+0 */ int32 + var _ /* gidbuf at bp+28 */ [11]int8 + var _ /* groupbuf at bp+4 */ [6]Tint32_t + var _ /* name_len at bp+44 */ Tuint32_t + var _ /* swap at bp+40 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = f, grlist_len, i, key, len1, ptr, req, rv, tmp, tmp1, v1, v10, v5, v6 + rv = 0 + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + f = Xfopen(tls, __ccgo_ts+1252, __ccgo_ts+381) + if !(f != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto done + } + for { + v1 = X__getgrent_a(tls, f, gr, buf, size, mem, nmem, res) + rv = v1 + if !(!(v1 != 0) && **(**uintptr)(__ccgo_up(res)) != 0) { + break + } + if name != 0 && !(Xstrcmp(tls, name, (*Tgroup)(unsafe.Pointer(**(**uintptr)(__ccgo_up(res)))).Fgr_name) != 0) || !(name != 0) && (*Tgroup)(unsafe.Pointer(**(**uintptr)(__ccgo_up(res)))).Fgr_gid == gid { + break + } + } + Xfclose(tls, f) + if !(**(**uintptr)(__ccgo_up(res)) != 0) && (rv == 0 || rv == int32(ENOENT) || rv == int32(ENOTDIR)) { + if name != 0 { + v1 = int32(GETGRBYNAME) + } else { + v1 = int32(GETGRBYGID) + } + req = v1 + **(**[6]Tint32_t)(__ccgo_up(bp + 4)) = [6]Tint32_t{} + len1 = uint64(0) + grlist_len = uint64(0) + **(**[11]int8)(__ccgo_up(bp + 28)) = [11]int8{} + **(**int32)(__ccgo_up(bp + 40)) = 0 + if name != 0 { + key = name + } else { + if gid < uint32(0) || gid > uint32(0xffffffff) { + rv = 0 + goto done + } + key = _itoa1(tls, bp+28, gid) + } + f = X__nscd_query(tls, req, key, bp+4, uint64(24), bp+40) + if !(f != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto done + } + if !((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRFOUND)] != 0) { + rv = 0 + goto cleanup_f + } + if !((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)] != 0) || !((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)] != 0) { + rv = int32(EIO) + goto cleanup_f + } + if Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)]) > uint64(0xffffffffffffffff)-Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)]) { + rv = int32(ENOMEM) + goto cleanup_f + } + len1 = Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)] + (**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)]) + i = 0 + for { + if !(i < (**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)]) { + break + } + if Xfread(tls, bp+44, uint64(4), uint64(1), f) < uint64(1) { + if Xferror(tls, f) != 0 { + v1 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v1 = int32(EIO) + } + rv = v1 + goto cleanup_f + } + if **(**int32)(__ccgo_up(bp + 40)) != 0 { + v5 = **(**Tuint32_t)(__ccgo_up(bp + 44)) + v6 = v5>>int32(24) | v5>>int32(8)&uint32(0xff00) | v5< uint64(0xffffffffffffffff)-grlist_len || uint64(**(**Tuint32_t)(__ccgo_up(bp + 44))) > uint64(0xffffffffffffffff)-len1 { + rv = int32(ENOMEM) + goto cleanup_f + } + len1 = len1 + uint64(**(**Tuint32_t)(__ccgo_up(bp + 44))) + grlist_len = grlist_len + uint64(**(**Tuint32_t)(__ccgo_up(bp + 44))) + goto _3 + _3: + ; + i = i + 1 + } + if len1 > **(**Tsize_t)(__ccgo_up(size)) || !(**(**uintptr)(__ccgo_up(buf)) != 0) { + tmp = Xrealloc(tls, **(**uintptr)(__ccgo_up(buf)), len1) + if !(tmp != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(buf)) = tmp + **(**Tsize_t)(__ccgo_up(size)) = len1 + } + if !(Xfread(tls, **(**uintptr)(__ccgo_up(buf)), len1, uint64(1), f) != 0) { + if Xferror(tls, f) != 0 { + v1 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v1 = int32(EIO) + } + rv = v1 + goto cleanup_f + } + if Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)]+int32(1)) > **(**Tsize_t)(__ccgo_up(nmem)) { + if Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)]+int32(1)) > Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt64(8) { + rv = int32(ENOMEM) + goto cleanup_f + } + tmp1 = Xrealloc(tls, **(**uintptr)(__ccgo_up(mem)), Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)]+Int32FromInt32(1))*uint64(8)) + if !(tmp1 != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(mem)) = tmp1 + **(**Tsize_t)(__ccgo_up(nmem)) = Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)] + int32(1)) + } + if (**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)] != 0 { + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) = **(**uintptr)(__ccgo_up(buf)) + uintptr((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)]) + uintptr((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)]) + ptr = **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) + i = Int32FromInt32(0) + for { + if !(ptr != **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem))))+uintptr(grlist_len)) { + break + } + if !(**(**int8)(__ccgo_up(ptr)) != 0) { + i = i + 1 + v10 = i + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)) + uintptr(v10)*8)) = ptr + uintptr(1) + } + goto _9 + _9: + ; + ptr = ptr + 1 + } + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)) + uintptr(i)*8)) = uintptr(0) + if i != (**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)] { + rv = int32(EIO) + goto cleanup_f + } + } else { + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) = uintptr(0) + } + (*Tgroup)(unsafe.Pointer(gr)).Fgr_name = **(**uintptr)(__ccgo_up(buf)) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd = (*Tgroup)(unsafe.Pointer(gr)).Fgr_name + uintptr((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)]) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_gid = Uint32FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRGID)]) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_mem = **(**uintptr)(__ccgo_up(mem)) + if **(**int8)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd + uintptr(-Int32FromInt32(1)))) != 0 || **(**int8)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd + uintptr((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)]-int32(1)))) != 0 { + rv = int32(EIO) + goto cleanup_f + } + if name != 0 && Xstrcmp(tls, name, (*Tgroup)(unsafe.Pointer(gr)).Fgr_name) != 0 || !(name != 0) && gid != (*Tgroup)(unsafe.Pointer(gr)).Fgr_gid { + rv = int32(EIO) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(res)) = gr + goto cleanup_f + cleanup_f: + ; + Xfclose(tls, f) + goto done + } + goto done +done: + ; + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func _getgr_r(tls *TLS, name uintptr, gid Tgid_t, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i Tsize_t + var rv int32 + var _ /* cs at bp+32 */ int32 + var _ /* len at bp+8 */ Tsize_t + var _ /* line at bp+0 */ uintptr + var _ /* mem at bp+16 */ uintptr + var _ /* nmem at bp+24 */ Tsize_t + _, _ = i, rv + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + **(**Tsize_t)(__ccgo_up(bp + 24)) = uint64(0) + rv = 0 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+32) + rv = X__getgr_a(tls, name, gid, gr, bp, bp+8, bp+16, bp+24, res) + if **(**uintptr)(__ccgo_up(res)) != 0 && size < **(**Tsize_t)(__ccgo_up(bp + 8))+(**(**Tsize_t)(__ccgo_up(bp + 24))+uint64(1))*uint64(8)+uint64(32) { + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + rv = int32(ERANGE) + } + if **(**uintptr)(__ccgo_up(res)) != 0 { + buf = buf + uintptr((uint64(16)-uint64(buf))%uint64(16)) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_mem = buf + buf = buf + uintptr((**(**Tsize_t)(__ccgo_up(bp + 24))+uint64(1))*uint64(8)) + Xmemcpy(tls, buf, **(**uintptr)(__ccgo_up(bp)), **(**Tsize_t)(__ccgo_up(bp + 8))) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_name = uintptr(int64((*Tgroup)(unsafe.Pointer(gr)).Fgr_name)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd = uintptr(int64((*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + i = uint64(0) + for { + if !(**(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 16)) + uintptr(i)*8)) != 0) { + break + } + **(**uintptr)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_mem + uintptr(i)*8)) = uintptr(int64(**(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 16)) + uintptr(i)*8)))-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + goto _1 + _1: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_mem + uintptr(i)*8)) = uintptr(0) + } + Xfree(tls, **(**uintptr)(__ccgo_up(bp + 16))) + Xfree(tls, **(**uintptr)(__ccgo_up(bp))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 32)), uintptr(0)) + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func Xgetgrnam_r(tls *TLS, name uintptr, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v gr=%v buf=%v size=%v res=%v, (%v:)", tls, name, gr, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _getgr_r(tls, name, uint32(0), gr, buf, size, res) +} + +func Xgetgrgid_r(tls *TLS, gid Tgid_t, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v gid=%v gr=%v buf=%v size=%v res=%v, (%v:)", tls, gid, gr, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _getgr_r(tls, uintptr(0), gid, gr, buf, size, res) +} + +var _f1 uintptr +var _line3 uintptr +var _mem1 uintptr +var _gr1 Tgroup + +func Xsetgrent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + if _f1 != 0 { + Xfclose(tls, _f1) + } + _f1 = uintptr(0) +} + +func Xgetgrent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* nmem at bp+16 */ Tsize_t + var _ /* res at bp+0 */ uintptr + var _ /* size at bp+8 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**Tsize_t)(__ccgo_up(bp + 16)) = uint64(0) + if !(_f1 != 0) { + _f1 = Xfopen(tls, __ccgo_ts+1252, __ccgo_ts+381) + } + if !(_f1 != 0) { + return uintptr(0) + } + X__getgrent_a(tls, _f1, uintptr(unsafe.Pointer(&_gr1)), uintptr(unsafe.Pointer(&_line3)), bp+8, uintptr(unsafe.Pointer(&_mem1)), bp+16, bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xgetgrgid(tls *TLS, gid Tgid_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v gid=%v, (%v:)", tls, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* nmem at bp+16 */ Tsize_t + var _ /* res at bp+0 */ uintptr + var _ /* size at bp+8 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**Tsize_t)(__ccgo_up(bp + 16)) = uint64(0) + X__getgr_a(tls, uintptr(0), gid, uintptr(unsafe.Pointer(&_gr1)), uintptr(unsafe.Pointer(&_line3)), bp+8, uintptr(unsafe.Pointer(&_mem1)), bp+16, bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xgetgrnam(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* nmem at bp+16 */ Tsize_t + var _ /* res at bp+0 */ uintptr + var _ /* size at bp+8 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**Tsize_t)(__ccgo_up(bp + 16)) = uint64(0) + X__getgr_a(tls, name, uint32(0), uintptr(unsafe.Pointer(&_gr1)), uintptr(unsafe.Pointer(&_line3)), bp+8, uintptr(unsafe.Pointer(&_mem1)), bp+16, bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xendgrent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xsetgrent(tls) +} + +func _atou(tls *TLS, s uintptr) (r uint32) { + var x uint32 + _ = x + x = uint32(0) + for { + if !(Uint32FromInt32(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-int32('0')) < uint32(10)) { + break + } + x = uint32(10)*x + Uint32FromInt32(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-Int32FromUint8('0')) + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(s)) = **(**uintptr)(__ccgo_up(s)) + 1 + } + return x +} + +func X__getgrent_a(tls *TLS, f uintptr, gr uintptr, line uintptr, size uintptr, mem uintptr, nmem uintptr, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v gr=%v line=%v size=%v mem=%v nmem=%v res=%v, (%v:)", tls, f, gr, line, size, mem, nmem, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, v13 Tsize_t + var l, v2 Tssize_t + var mems, v4 uintptr + var rv, v3 int32 + var _ /* cs at bp+8 */ int32 + var _ /* s at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = i, l, mems, rv, v13, v2, v3, v4 + rv = 0 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+8) + for { + v2 = Xgetline(tls, line, size, f) + l = v2 + if v2 < 0 { + if Xferror(tls, f) != 0 { + v3 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v3 = 0 + } + rv = v3 + Xfree(tls, **(**uintptr)(__ccgo_up(line))) + **(**uintptr)(__ccgo_up(line)) = uintptr(0) + gr = uintptr(0) + goto end + } + **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(line)) + uintptr(l-int64(1)))) = 0 + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(line)) + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + (*Tgroup)(unsafe.Pointer(gr)).Fgr_name = v4 + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + (*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd = **(**uintptr)(__ccgo_up(bp)) + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + (*Tgroup)(unsafe.Pointer(gr)).Fgr_gid = _atou(tls, bp) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(':') { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + mems = **(**uintptr)(__ccgo_up(bp)) + break + goto _1 + _1: + } + **(**Tsize_t)(__ccgo_up(nmem)) = BoolUint64(!!(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0)) + for { + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32(',') { + **(**Tsize_t)(__ccgo_up(nmem)) = **(**Tsize_t)(__ccgo_up(nmem)) + 1 + } + goto _10 + _10: + ; + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + Xfree(tls, **(**uintptr)(__ccgo_up(mem))) + **(**uintptr)(__ccgo_up(mem)) = Xcalloc(tls, uint64(8), **(**Tsize_t)(__ccgo_up(nmem))+uint64(1)) + if !(**(**uintptr)(__ccgo_up(mem)) != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + Xfree(tls, **(**uintptr)(__ccgo_up(line))) + **(**uintptr)(__ccgo_up(line)) = uintptr(0) + gr = uintptr(0) + goto end + } + if **(**int8)(__ccgo_up(mems)) != 0 { + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) = mems + **(**uintptr)(__ccgo_up(bp)) = mems + i = Uint64FromInt32(0) + for { + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32(',') { + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + i = i + 1 + v13 = i + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)) + uintptr(v13)*8)) = **(**uintptr)(__ccgo_up(bp)) + } + goto _11 + _11: + ; + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + i = i + 1 + v13 = i + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)) + uintptr(v13)*8)) = uintptr(0) + } else { + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) = uintptr(0) + } + (*Tgroup)(unsafe.Pointer(gr)).Fgr_mem = **(**uintptr)(__ccgo_up(mem)) + goto end +end: + ; + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 8)), uintptr(0)) + **(**uintptr)(__ccgo_up(res)) = gr + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func Xgetgrouplist(tls *TLS, user uintptr, gid Tgid_t, groups uintptr, ngroups uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v user=%v gid=%v groups=%v ngroups=%v, (%v:)", tls, user, gid, groups, ngroups, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(96) + defer tls.Free(96) + var f, nscdbuf, v1 uintptr + var i, n, v9 Tssize_t + var nbytes Tsize_t + var nlim, ret, rv, v6 int32 + var v14 int64 + var v3, v4 Tuint32_t + var _ /* buf at bp+56 */ uintptr + var _ /* gr at bp+0 */ Tgroup + var _ /* mem at bp+64 */ uintptr + var _ /* nmem at bp+72 */ Tsize_t + var _ /* res at bp+32 */ uintptr + var _ /* resp at bp+44 */ [3]Tint32_t + var _ /* size at bp+80 */ Tsize_t + var _ /* swap at bp+40 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = f, i, n, nbytes, nlim, nscdbuf, ret, rv, v1, v14, v3, v4, v6, v9 + ret = -int32(1) + n = int64(1) + **(**int32)(__ccgo_up(bp + 40)) = 0 + nscdbuf = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 56)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) + **(**Tsize_t)(__ccgo_up(bp + 72)) = uint64(0) + nlim = **(**int32)(__ccgo_up(ngroups)) + if nlim >= int32(1) { + v1 = groups + groups += 4 + **(**Tgid_t)(__ccgo_up(v1)) = gid + } + f = X__nscd_query(tls, int32(GETINITGR), user, bp+44, uint64(12), bp+40) + if !(f != 0) { + goto cleanup + } + if (**(**[3]Tint32_t)(__ccgo_up(bp + 44)))[int32(INITGRFOUND)] != 0 { + nscdbuf = Xcalloc(tls, Uint64FromInt32((**(**[3]Tint32_t)(__ccgo_up(bp + 44)))[int32(INITGRNGRPS)]), uint64(4)) + if !(nscdbuf != 0) { + goto cleanup + } + nbytes = uint64(4) * Uint64FromInt32((**(**[3]Tint32_t)(__ccgo_up(bp + 44)))[int32(INITGRNGRPS)]) + if nbytes != 0 && !(Xfread(tls, nscdbuf, nbytes, uint64(1), f) != 0) { + if !(Xferror(tls, f) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EIO) + } + goto cleanup + } + if **(**int32)(__ccgo_up(bp + 40)) != 0 { + i = 0 + for { + if !(i < int64((**(**[3]Tint32_t)(__ccgo_up(bp + 44)))[int32(INITGRNGRPS)])) { + break + } + v3 = **(**Tuint32_t)(__ccgo_up(nscdbuf + uintptr(i)*4)) + v4 = v3>>int32(24) | v3>>int32(8)&uint32(0xff00) | v3< int64(nlim) { + v14 = int64(-int32(1)) + } else { + v14 = n + } + ret = int32(v14) + **(**int32)(__ccgo_up(ngroups)) = int32(n) + goto cleanup +cleanup: + ; + if f != 0 { + Xfclose(tls, f) + } + Xfree(tls, nscdbuf) + Xfree(tls, **(**uintptr)(__ccgo_up(bp + 56))) + Xfree(tls, **(**uintptr)(__ccgo_up(bp + 64))) + return ret +} + +func _itoa2(tls *TLS, p uintptr, x Tuint32_t) (r uintptr) { + var v1 uintptr + _ = v1 + // number of digits in a uint32_t + NUL + p = p + uintptr(11) + p = p - 1 + v1 = p + **(**int8)(__ccgo_up(v1)) = 0 + for cond := true; cond; cond = x != 0 { + p = p - 1 + v1 = p + **(**int8)(__ccgo_up(v1)) = Int8FromUint32(uint32('0') + x%uint32(10)) + x = x / uint32(10) + } + return p +} + +func X__getpw_a(tls *TLS, name uintptr, uid Tuid_t, pw uintptr, buf uintptr, size uintptr, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v uid=%v pw=%v buf=%v size=%v res=%v, (%v:)", tls, name, uid, pw, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var f, key, tmp uintptr + var len1 Tsize_t + var req Tint32_t + var rv, v1 int32 + var _ /* cs at bp+4 */ int32 + var _ /* passwdbuf at bp+8 */ [9]Tint32_t + var _ /* uidbuf at bp+44 */ [11]int8 + _, _, _, _, _, _, _ = f, key, len1, req, rv, tmp, v1 + rv = 0 + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+4) + f = Xfopen(tls, __ccgo_ts+1263, __ccgo_ts+381) + if !(f != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto done + } + for { + v1 = X__getpwent_a(tls, f, pw, buf, size, res) + rv = v1 + if !(!(v1 != 0) && **(**uintptr)(__ccgo_up(res)) != 0) { + break + } + if name != 0 && !(Xstrcmp(tls, name, (*Tpasswd)(unsafe.Pointer(**(**uintptr)(__ccgo_up(res)))).Fpw_name) != 0) || !(name != 0) && (*Tpasswd)(unsafe.Pointer(**(**uintptr)(__ccgo_up(res)))).Fpw_uid == uid { + break + } + } + Xfclose(tls, f) + if !(**(**uintptr)(__ccgo_up(res)) != 0) && (rv == 0 || rv == int32(ENOENT) || rv == int32(ENOTDIR)) { + if name != 0 { + v1 = GETPWBYNAME + } else { + v1 = int32(GETPWBYUID) + } + req = v1 + **(**[9]Tint32_t)(__ccgo_up(bp + 8)) = [9]Tint32_t{} + len1 = uint64(0) + **(**[11]int8)(__ccgo_up(bp + 44)) = [11]int8{} + if name != 0 { + key = name + } else { + /* uid outside of this range can't be queried with the + * nscd interface, but might happen if uid_t ever + * happens to be a larger type (this is not true as of + * now) + */ + if uid < uint32(0) || uid > uint32(0xffffffff) { + rv = 0 + goto done + } + key = _itoa2(tls, bp+44, uid) + } + *(*[1]int32)(unsafe.Pointer(bp)) = [1]int32{} + f = X__nscd_query(tls, req, key, bp+8, uint64(36), bp) + if !(f != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto done + } + if !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWFOUND)] != 0) { + rv = 0 + goto cleanup_f + } + /* A zero length response from nscd is invalid. We ignore + * invalid responses and just report an error, rather than + * trying to do something with them. + */ + if !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWNAMELEN)] != 0) || !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWPASSWDLEN)] != 0) || !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGECOSLEN)] != 0) || !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWDIRLEN)] != 0) || !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWSHELLLEN)] != 0) { + rv = int32(EIO) + goto cleanup_f + } + if Uint64FromInt32((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWNAMELEN)]|(**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWPASSWDLEN)]|(**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGECOSLEN)]|(**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWDIRLEN)]|(**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWSHELLLEN)]) >= Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt32(8) { + rv = int32(ENOMEM) + goto cleanup_f + } + len1 = Uint64FromInt32((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWNAMELEN)] + (**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWPASSWDLEN)] + (**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGECOSLEN)] + (**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWDIRLEN)] + (**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWSHELLLEN)]) + if len1 > **(**Tsize_t)(__ccgo_up(size)) || !(**(**uintptr)(__ccgo_up(buf)) != 0) { + tmp = Xrealloc(tls, **(**uintptr)(__ccgo_up(buf)), len1) + if !(tmp != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(buf)) = tmp + **(**Tsize_t)(__ccgo_up(size)) = len1 + } + if !(Xfread(tls, **(**uintptr)(__ccgo_up(buf)), len1, uint64(1), f) != 0) { + if Xferror(tls, f) != 0 { + v1 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v1 = int32(EIO) + } + rv = v1 + goto cleanup_f + } + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name = **(**uintptr)(__ccgo_up(buf)) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd = (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWNAMELEN)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos = (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWPASSWDLEN)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir = (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGECOSLEN)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell = (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWDIRLEN)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_uid = Uint32FromInt32((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWUID)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gid = Uint32FromInt32((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGID)]) + /* Don't assume that nscd made sure to null terminate strings. + * It's supposed to, but malicious nscd should be ignored + * rather than causing a crash. + */ + if **(**int8)(__ccgo_up((*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd + uintptr(-Int32FromInt32(1)))) != 0 || **(**int8)(__ccgo_up((*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos + uintptr(-Int32FromInt32(1)))) != 0 || **(**int8)(__ccgo_up((*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir + uintptr(-Int32FromInt32(1)))) != 0 || **(**int8)(__ccgo_up((*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWSHELLLEN)]-int32(1)))) != 0 { + rv = int32(EIO) + goto cleanup_f + } + if name != 0 && Xstrcmp(tls, name, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name) != 0 || !(name != 0) && uid != (*Tpasswd)(unsafe.Pointer(pw)).Fpw_uid { + rv = int32(EIO) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(res)) = pw + goto cleanup_f + cleanup_f: + ; + Xfclose(tls, f) + goto done + } + goto done +done: + ; + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 4)), uintptr(0)) + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func _getpw_r(tls *TLS, name uintptr, uid Tuid_t, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rv int32 + var _ /* cs at bp+16 */ int32 + var _ /* len at bp+8 */ Tsize_t + var _ /* line at bp+0 */ uintptr + _ = rv + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + rv = 0 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+16) + rv = X__getpw_a(tls, name, uid, pw, bp, bp+8, res) + if **(**uintptr)(__ccgo_up(res)) != 0 && size < **(**Tsize_t)(__ccgo_up(bp + 8)) { + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + rv = int32(ERANGE) + } + if **(**uintptr)(__ccgo_up(res)) != 0 { + Xmemcpy(tls, buf, **(**uintptr)(__ccgo_up(bp)), **(**Tsize_t)(__ccgo_up(bp + 8))) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_name)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + } + Xfree(tls, **(**uintptr)(__ccgo_up(bp))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 16)), uintptr(0)) + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func Xgetpwnam_r(tls *TLS, name uintptr, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v pw=%v buf=%v size=%v res=%v, (%v:)", tls, name, pw, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _getpw_r(tls, name, uint32(0), pw, buf, size, res) +} + +func Xgetpwuid_r(tls *TLS, uid Tuid_t, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v uid=%v pw=%v buf=%v size=%v res=%v, (%v:)", tls, uid, pw, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _getpw_r(tls, uintptr(0), uid, pw, buf, size, res) +} + +var _f2 uintptr +var _line4 uintptr +var _pw1 Tpasswd +var _size Tsize_t + +func Xsetpwent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + if _f2 != 0 { + Xfclose(tls, _f2) + } + _f2 = uintptr(0) +} + +func Xgetpwent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+0 */ uintptr + if !(_f2 != 0) { + _f2 = Xfopen(tls, __ccgo_ts+1263, __ccgo_ts+381) + } + if !(_f2 != 0) { + return uintptr(0) + } + X__getpwent_a(tls, _f2, uintptr(unsafe.Pointer(&_pw1)), uintptr(unsafe.Pointer(&_line4)), uintptr(unsafe.Pointer(&_size)), bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xgetpwuid(tls *TLS, uid Tuid_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v uid=%v, (%v:)", tls, uid, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+0 */ uintptr + X__getpw_a(tls, uintptr(0), uid, uintptr(unsafe.Pointer(&_pw1)), uintptr(unsafe.Pointer(&_line4)), uintptr(unsafe.Pointer(&_size)), bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xgetpwnam(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+0 */ uintptr + X__getpw_a(tls, name, uint32(0), uintptr(unsafe.Pointer(&_pw1)), uintptr(unsafe.Pointer(&_line4)), uintptr(unsafe.Pointer(&_size)), bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xendpwent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xsetpwent(tls) +} + +func _atou1(tls *TLS, s uintptr) (r uint32) { + var x uint32 + _ = x + x = uint32(0) + for { + if !(Uint32FromInt32(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-int32('0')) < uint32(10)) { + break + } + x = uint32(10)*x + Uint32FromInt32(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-Int32FromUint8('0')) + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(s)) = **(**uintptr)(__ccgo_up(s)) + 1 + } + return x +} + +func X__getpwent_a(tls *TLS, f uintptr, pw uintptr, line uintptr, size uintptr, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v pw=%v line=%v size=%v res=%v, (%v:)", tls, f, pw, line, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var l, v2 Tssize_t + var rv, v3 int32 + var v4 uintptr + var _ /* cs at bp+8 */ int32 + var _ /* s at bp+0 */ uintptr + _, _, _, _, _ = l, rv, v2, v3, v4 + rv = 0 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+8) + for { + v2 = Xgetline(tls, line, size, f) + l = v2 + if v2 < 0 { + if Xferror(tls, f) != 0 { + v3 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v3 = 0 + } + rv = v3 + Xfree(tls, **(**uintptr)(__ccgo_up(line))) + **(**uintptr)(__ccgo_up(line)) = uintptr(0) + pw = uintptr(0) + break + } + **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(line)) + uintptr(l-int64(1)))) = 0 + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(line)) + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name = v4 + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd = **(**uintptr)(__ccgo_up(bp)) + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_uid = _atou1(tls, bp) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(':') { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gid = _atou1(tls, bp) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(':') { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos = **(**uintptr)(__ccgo_up(bp)) + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir = **(**uintptr)(__ccgo_up(bp)) + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**int8)(__ccgo_up(v4)) = 0 + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell = **(**uintptr)(__ccgo_up(bp)) + break + goto _1 + _1: + } + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 8)), uintptr(0)) + **(**uintptr)(__ccgo_up(res)) = pw + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func Xsetspent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xendspent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xgetspent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xlckpwdf(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xulckpwdf(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +var _addr = struct { + Fsun_family int16 + Fsun_path [21]int8 +}{ + Fsun_family: int16(PF_LOCAL), + Fsun_path: [21]int8{'/', 'v', 'a', 'r', '/', 'r', 'u', 'n', '/', 'n', 's', 'c', 'd', '/', 's', 'o', 'c', 'k', 'e', 't'}, +} + +func X__nscd_query(tls *TLS, req Tint32_t, key uintptr, buf uintptr, len1 Tsize_t, swap uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v req=%v key=%v buf=%v len1=%v swap=%v, (%v:)", tls, req, key, buf, len1, swap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(112) + defer tls.Free(112) + var errno_save, fd int32 + var f, v1 uintptr + var i Tsize_t + var v3, v4 Tuint32_t + var _ /* msg at bp+48 */ Tmsghdr + var _ /* req_buf at bp+32 */ [3]Tint32_t + _, _, _, _, _, _, _ = errno_save, f, fd, i, v1, v3, v4 + f = uintptr(0) + **(**[3]Tint32_t)(__ccgo_up(bp + 32)) = [3]Tint32_t{ + 0: int32(NSCDVERSION), + 1: req, + 2: Int32FromUint64(Xstrnlen(tls, key, uint64(LOGIN_NAME_MAX)) + uint64(1)), + } + *(*[2]Tiovec)(unsafe.Pointer(bp)) = [2]Tiovec{ + 0: { + Fiov_base: bp + 32, + Fiov_len: uint64(12), + }, + 1: { + Fiov_base: key, + Fiov_len: _strlen(tls, key) + uint64(1), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 48)) = Tmsghdr{ + Fmsg_iov: bp, + Fmsg_iovlen: int32(2), + } + errno_save = **(**int32)(__ccgo_up(X__errno_location(tls))) + **(**int32)(__ccgo_up(swap)) = 0 + goto retry +retry: + ; + Xmemset(tls, buf, 0, len1) + **(**Tint32_t)(__ccgo_up(buf)) = int32(NSCDVERSION) + fd = Xsocket(tls, int32(PF_LOCAL), Int32FromInt32(SOCK_STREAM)|Int32FromInt32(SOCK_CLOEXEC), 0) + if fd < 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EAFNOSUPPORT) { + f = Xfopen(tls, __ccgo_ts+1275, __ccgo_ts+1285) + if f != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = errno_save + } + return f + } + return uintptr(0) + } + v1 = Xfdopen(tls, fd, __ccgo_ts+1288) + f = v1 + if !(v1 != 0) { + Xclose(tls, fd) + return uintptr(0) + } + if (**(**[3]Tint32_t)(__ccgo_up(bp + 32)))[int32(2)] > int32(LOGIN_NAME_MAX) { + return f + } + if Xconnect(tls, fd, uintptr(unsafe.Pointer(&_addr)), uint32(24)) < 0 { + /* If there isn't a running nscd we simulate a "not found" + * result and the caller is responsible for calling + * fclose on the (unconnected) socket. The value of + * errno must be left unchanged in this case. */ + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EACCES) || **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ECONNREFUSED) || **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOENT) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = errno_save + return f + } + goto error + } + if Xsendmsg(tls, fd, bp+48, int32(MSG_NOSIGNAL)) < 0 { + goto error + } + if !(Xfread(tls, buf, len1, uint64(1), f) != 0) { + /* If the VERSION entry mismatches nscd will disconnect. The + * most likely cause is that the endianness mismatched. So, we + * byteswap and try once more. (if we already swapped, just + * fail out) + */ + if Xferror(tls, f) != 0 { + goto error + } + if !(**(**int32)(__ccgo_up(swap)) != 0) { + Xfclose(tls, f) + i = uint64(0) + for { + if !(i < Uint64FromInt64(12)/Uint64FromInt64(4)) { + break + } + v3 = Uint32FromInt32((**(**[3]Tint32_t)(__ccgo_up(bp + 32)))[i]) + v4 = v3>>int32(24) | v3>>int32(8)&uint32(0xff00) | v3<>int32(24) | v3>>int32(8)&uint32(0xff00) | v3< %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var i Tsize_t + var r, v1 int32 + var v4 uintptr + _, _, _, _ = i, r, v1, v4 + Xflockfile(tls, f) + v1 = Xfprintf(tls, f, __ccgo_ts+1290, VaList(bp+8, (*Tgroup)(unsafe.Pointer(gr)).Fgr_name, (*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd, (*Tgroup)(unsafe.Pointer(gr)).Fgr_gid)) + r = v1 + if v1 < 0 { + goto done + } + if (*Tgroup)(unsafe.Pointer(gr)).Fgr_mem != 0 { + i = uint64(0) + for { + if !(**(**uintptr)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_mem + uintptr(i)*8)) != 0) { + break + } + if i != 0 { + v4 = __ccgo_ts + 1300 + } else { + v4 = __ccgo_ts + } + v1 = Xfprintf(tls, f, __ccgo_ts+1302, VaList(bp+8, v4, **(**uintptr)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_mem + uintptr(i)*8)))) + r = v1 + if v1 < 0 { + goto done + } + goto _2 + _2: + ; + i = i + 1 + } + } + r = Xfputc(tls, int32('\n'), f) + goto done +done: + ; + Xfunlockfile(tls, f) + if r < 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xputpwent(tls *TLS, pw uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v pw=%v f=%v, (%v:)", tls, pw, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var v1 int32 + _ = v1 + if Xfprintf(tls, f, __ccgo_ts+1307, VaList(bp+8, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_uid, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gid, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell)) < 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xputspent(tls *TLS, sp uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v sp=%v f=%v, (%v:)", tls, sp, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var v1, v10, v12, v14, v16, v4, v6, v8 int32 + var v11, v13, v15, v5, v7, v9 int64 + var v17 uint64 + var v2, v3 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = v1, v10, v11, v12, v13, v14, v15, v16, v17, v2, v3, v4, v5, v6, v7, v8, v9 + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_namp != 0 { + v2 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_namp + } else { + v2 = __ccgo_ts + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_pwdp != 0 { + v3 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_pwdp + } else { + v3 = __ccgo_ts + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_lstchg == int64(-int32(1)) { + v4 = 0 + } else { + v4 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_lstchg == int64(-int32(1)) { + v5 = 0 + } else { + v5 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_lstchg + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_min == int64(-int32(1)) { + v6 = 0 + } else { + v6 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_min == int64(-int32(1)) { + v7 = 0 + } else { + v7 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_min + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_max == int64(-int32(1)) { + v8 = 0 + } else { + v8 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_max == int64(-int32(1)) { + v9 = 0 + } else { + v9 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_max + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_warn == int64(-int32(1)) { + v10 = 0 + } else { + v10 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_warn == int64(-int32(1)) { + v11 = 0 + } else { + v11 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_warn + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_inact == int64(-int32(1)) { + v12 = 0 + } else { + v12 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_inact == int64(-int32(1)) { + v13 = 0 + } else { + v13 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_inact + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_expire == int64(-int32(1)) { + v14 = 0 + } else { + v14 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_expire == int64(-int32(1)) { + v15 = 0 + } else { + v15 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_expire + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_flag == Uint64FromInt32(-Int32FromInt32(1)) { + v16 = 0 + } else { + v16 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_flag == Uint64FromInt32(-Int32FromInt32(1)) { + v17 = uint64(0) + } else { + v17 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_flag + } + if Xfprintf(tls, f, __ccgo_ts+1329, VaList(bp+8, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)) < 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 +} + +func X__rand48_step(tls *TLS, xi uintptr, lc uintptr) (r Tuint64_t) { + if __ccgo_strace { + trc("tls=%v xi=%v lc=%v, (%v:)", tls, xi, lc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, x Tuint64_t + _, _ = a, x + x = uint64(uint32(**(**uint16)(__ccgo_up(xi)))|(uint32(**(**uint16)(__ccgo_up(xi + 1*2)))+0)<> int32(16)) + **(**uint16)(__ccgo_up(xi + 2*2)) = uint16(x >> int32(32)) + return x & uint64(0xffffffffffff) +} + +func Xerand48(tls *TLS, s uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* x at bp+0 */ struct { + Ff [0]float64 + Fu Tuint64_t + } + *(*struct { + Ff [0]float64 + Fu Tuint64_t + })(unsafe.Pointer(bp)) = struct { + Ff [0]float64 + Fu Tuint64_t + }{} + *(*uint64)(unsafe.Pointer(bp)) = uint64(0x3ff0000000000000) | X__rand48_step(tls, s, uintptr(unsafe.Pointer(&X__seed48))+uintptr(3)*2)< %v", r) }() + } + return Xerand48(tls, uintptr(unsafe.Pointer(&X__seed48))) +} + +func Xlcong48(tls *TLS, p uintptr) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + } + Xmemcpy(tls, uintptr(unsafe.Pointer(&X__seed48)), p, uint64(14)) +} + +func Xnrand48(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(X__rand48_step(tls, s, uintptr(unsafe.Pointer(&X__seed48))+uintptr(3)*2) >> int32(17)) +} + +func Xlrand48(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xnrand48(tls, uintptr(unsafe.Pointer(&X__seed48))) +} + +func Xjrand48(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Int32FromUint64(X__rand48_step(tls, s, uintptr(unsafe.Pointer(&X__seed48))+uintptr(3)*2) >> Int32FromInt32(16))) +} + +func Xmrand48(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xjrand48(tls, uintptr(unsafe.Pointer(&X__seed48))) +} + +var _seed Tuint64_t + +func Xsrand(tls *TLS, s uint32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + } + _seed = uint64(s - uint32(1)) +} + +func Xrand(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + _seed = uint64(6364136223846793005)*_seed + uint64(1) + return Int32FromUint64(_seed >> int32(33)) +} + +func _temper(tls *TLS, x uint32) (r uint32) { + x = x ^ x>>int32(11) + x = x ^ x<>int32(18) + return x +} + +func Xrand_r(tls *TLS, seed uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uint32 + _ = v1 + v1 = **(**uint32)(__ccgo_up(seed))*Uint32FromInt32(1103515245) + Uint32FromInt32(12345) + **(**uint32)(__ccgo_up(seed)) = v1 + return Int32FromUint32(_temper(tls, v1) / uint32(2)) +} + +/* +this code uses the same lagged fibonacci generator as the +original bsd random implementation except for the seeding +which was broken in the original +*/ + +var _init = [32]Tuint32_t{ + 1: uint32(0x5851f42d), + 2: uint32(0xc0b18ccf), + 3: uint32(0xcbb5f646), + 4: uint32(0xc7033129), + 5: uint32(0x30705b04), + 6: uint32(0x20fd5db4), + 7: uint32(0x9a8b7f78), + 8: uint32(0x502959d8), + 9: uint32(0xab894868), + 10: uint32(0x6c0356a7), + 11: uint32(0x88cdb7ff), + 12: uint32(0xb477d43f), + 13: uint32(0x70a3a52b), + 14: uint32(0xa8e4baf1), + 15: uint32(0xfd8341fc), + 16: uint32(0x8ae16fd9), + 17: uint32(0x742d2f7a), + 18: uint32(0x0d1f0796), + 19: uint32(0x76035e09), + 20: uint32(0x40f7702c), + 21: uint32(0x6fa72ca5), + 22: uint32(0xaaa84157), + 23: uint32(0x58a0df74), + 24: uint32(0xc74a0364), + 25: uint32(0xae533cc4), + 26: uint32(0x04185faf), + 27: uint32(0x6de3b115), + 28: uint32(0x0cab8628), + 29: uint32(0xf043bfa4), + 30: uint32(0x398150e9), + 31: uint32(0x37521657), +} + +var _n = int32(31) +var _i = int32(3) +var _j = int32(0) +var _x1 = uintptr(unsafe.Pointer(&_init)) + uintptr(1)*4 +var _lock3 [1]int32 + +func _lcg31(tls *TLS, x Tuint32_t) (r Tuint32_t) { + return (uint32(1103515245)*x + uint32(12345)) & uint32(0x7fffffff) +} + +func _lcg64(tls *TLS, x Tuint64_t) (r Tuint64_t) { + return uint64(6364136223846793005)*x + uint64(1) +} + +func _savestate(tls *TLS) (r uintptr) { + **(**Tuint32_t)(__ccgo_up(_x1 + uintptr(-Int32FromInt32(1))*4)) = Uint32FromInt32(_n<> int32(16)) + _i = Int32FromUint32(**(**Tuint32_t)(__ccgo_up(_x1 + uintptr(-Int32FromInt32(1))*4)) >> Int32FromInt32(8) & uint32(0xff)) + _j = Int32FromUint32(**(**Tuint32_t)(__ccgo_up(_x1 + uintptr(-Int32FromInt32(1))*4)) & uint32(0xff)) +} + +func ___srandom(tls *TLS, seed uint32) { + var k, v1 int32 + var s Tuint64_t + _, _, _ = k, s, v1 + s = uint64(seed) + if _n == 0 { + **(**Tuint32_t)(__ccgo_up(_x1)) = uint32(s) + return + } + if _n == int32(31) || _n == int32(7) { + v1 = int32(3) + } else { + v1 = int32(1) + } + _i = v1 + _j = 0 + k = 0 + for { + if !(k < _n) { + break + } + s = _lcg64(tls, s) + **(**Tuint32_t)(__ccgo_up(_x1 + uintptr(k)*4)) = uint32(s >> int32(32)) + goto _2 + _2: + ; + k = k + 1 + } + /* make sure x contains at least one odd number */ + **(**Tuint32_t)(__ccgo_up(_x1)) |= uint32(1) +} + +func Xsrandom(tls *TLS, seed uint32) { + if __ccgo_strace { + trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2)) + } + ___lock(tls, uintptr(unsafe.Pointer(&_lock3))) + ___srandom(tls, seed) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock3))) +} + +func Xinitstate(tls *TLS, seed uint32, state uintptr, size Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v seed=%v state=%v size=%v, (%v:)", tls, seed, state, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + var old uintptr + _ = old + if size < uint64(8) { + return uintptr(0) + } + ___lock(tls, uintptr(unsafe.Pointer(&_lock3))) + old = _savestate(tls) + if size < uint64(32) { + _n = 0 + } else { + if size < uint64(64) { + _n = int32(7) + } else { + if size < uint64(128) { + _n = int32(15) + } else { + if size < uint64(256) { + _n = int32(31) + } else { + _n = int32(63) + } + } + } + } + _x1 = state + uintptr(1)*4 + ___srandom(tls, seed) + _savestate(tls) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock3))) + return old +} + +func Xsetstate(tls *TLS, state uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v state=%v, (%v:)", tls, state, origin(2)) + defer func() { trc("-> %v", r) }() + } + var old uintptr + _ = old + ___lock(tls, uintptr(unsafe.Pointer(&_lock3))) + old = _savestate(tls) + _loadstate(tls, state) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock3))) + return old +} + +func Xrandom(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k int64 + var v1 Tuint32_t + var v2 int32 + _, _, _ = k, v1, v2 + ___lock(tls, uintptr(unsafe.Pointer(&_lock3))) + if _n == 0 { + v1 = _lcg31(tls, **(**Tuint32_t)(__ccgo_up(_x1))) + **(**Tuint32_t)(__ccgo_up(_x1)) = v1 + k = Int64FromUint32(v1) + goto end + } + **(**Tuint32_t)(__ccgo_up(_x1 + uintptr(_i)*4)) += **(**Tuint32_t)(__ccgo_up(_x1 + uintptr(_j)*4)) + k = Int64FromUint32(**(**Tuint32_t)(__ccgo_up(_x1 + uintptr(_i)*4)) >> int32(1)) + _i = _i + 1 + v2 = _i + if v2 == _n { + _i = 0 + } + _j = _j + 1 + v2 = _j + if v2 == _n { + _j = 0 + } + goto end +end: + ; + ___unlock(tls, uintptr(unsafe.Pointer(&_lock3))) + return k +} + +func Xseed48(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + Xmemcpy(tls, uintptr(unsafe.Pointer(&_p1)), uintptr(unsafe.Pointer(&X__seed48)), uint64(6)) + Xmemcpy(tls, uintptr(unsafe.Pointer(&X__seed48)), s, uint64(6)) + return uintptr(unsafe.Pointer(&_p1)) +} + +var _p1 [3]uint16 + +func Xsrand48(tls *TLS, seed int64) { + if __ccgo_strace { + trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*[3]uint16)(unsafe.Pointer(bp)) = [3]uint16{ + 0: uint16(0x330e), + 1: Uint16FromInt64(seed), + 2: Uint16FromInt64(seed >> int32(16)), + } + Xseed48(tls, bp) +} + +func Xexecl(tls *TLS, path uintptr, argv0 uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v argv0=%v va=%v, (%v:)", tls, path, argv0, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var argc, i int32 + var argv uintptr + var v2 t__predefined_size_t + _, _, _, _, _ = ap, argc, argv, i, v2 + defer func() { Xrealloc(tls, argv, 0) }() + ap = va + argc = int32(1) + for { + if !(VaUintptr(&ap) != 0) { + break + } + goto _1 + _1: + ; + argc = argc + 1 + } + _ = ap + v2 = Uint64FromInt32(argc+int32(1)) * 8 + argv = Xrealloc(tls, argv, v2) + ap = va + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), 0*8)) = argv0 + i = int32(1) + for { + if !(i < argc) { + break + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = VaUintptr(&ap) + goto _3 + _3: + ; + i = i + 1 + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = UintptrFromInt32(0) + _ = ap + return Xexecv(tls, path, argv) + return r +} + +func Xexecle(tls *TLS, path uintptr, argv0 uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v argv0=%v va=%v, (%v:)", tls, path, argv0, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var argc, i int32 + var argv, envp uintptr + var v2 t__predefined_size_t + _, _, _, _, _, _ = ap, argc, argv, envp, i, v2 + defer func() { Xrealloc(tls, argv, 0) }() + ap = va + argc = int32(1) + for { + if !(VaUintptr(&ap) != 0) { + break + } + goto _1 + _1: + ; + argc = argc + 1 + } + _ = ap + v2 = Uint64FromInt32(argc+int32(1)) * 8 + argv = Xrealloc(tls, argv, v2) + ap = va + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), 0*8)) = argv0 + i = int32(1) + for { + if !(i <= argc) { + break + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = VaUintptr(&ap) + goto _3 + _3: + ; + i = i + 1 + } + envp = VaUintptr(&ap) + _ = ap + return Xexecve(tls, path, argv, envp) + return r +} + +func Xexeclp(tls *TLS, file uintptr, argv0 uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v file=%v argv0=%v va=%v, (%v:)", tls, file, argv0, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var argc, i int32 + var argv uintptr + var v2 t__predefined_size_t + _, _, _, _, _ = ap, argc, argv, i, v2 + defer func() { Xrealloc(tls, argv, 0) }() + ap = va + argc = int32(1) + for { + if !(VaUintptr(&ap) != 0) { + break + } + goto _1 + _1: + ; + argc = argc + 1 + } + _ = ap + v2 = Uint64FromInt32(argc+int32(1)) * 8 + argv = Xrealloc(tls, argv, v2) + ap = va + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), 0*8)) = argv0 + i = int32(1) + for { + if !(i < argc) { + break + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = VaUintptr(&ap) + goto _3 + _3: + ; + i = i + 1 + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = UintptrFromInt32(0) + _ = ap + return Xexecvp(tls, file, argv) + return r +} + +func Xexecv(tls *TLS, path uintptr, argv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v argv=%v, (%v:)", tls, path, argv, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexecve(tls, path, argv, Xenviron) +} + +func Xexecve(tls *TLS, path uintptr, argv uintptr, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v argv=%v envp=%v, (%v:)", tls, path, argv, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* do we need to use environ if envp is null? */ + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_execve), int64(path), int64(argv), int64(envp))))) +} + +func X__execvpe(tls *TLS, file uintptr, argv uintptr, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v file=%v argv=%v envp=%v, (%v:)", tls, file, argv, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var b, p, path, z, v3 uintptr + var k, l Tsize_t + var seen_eacces int32 + var v2 t__predefined_size_t + _, _, _, _, _, _, _, _, _ = b, k, l, p, path, seen_eacces, z, v2, v3 + defer func() { Xrealloc(tls, b, 0) }() + path = Xgetenv(tls, __ccgo_ts+1378) + seen_eacces = 0 + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + if !(**(**int8)(__ccgo_up(file)) != 0) { + return -int32(1) + } + if Xstrchr(tls, file, int32('/')) != 0 { + return Xexecve(tls, file, argv, envp) + } + if !(path != 0) { + path = __ccgo_ts + 1383 + } + k = Xstrnlen(tls, file, Uint64FromInt32(Int32FromInt32(NAME_MAX)+Int32FromInt32(1))) + if k > uint64(NAME_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return -int32(1) + } + l = Xstrnlen(tls, path, Uint64FromInt32(Int32FromInt32(PATH_MAX)-Int32FromInt32(1))) + uint64(1) + p = path + for { + v2 = l + k + uint64(1) + b = Xrealloc(tls, b, v2) + z = X__strchrnul(tls, p, int32(':')) + if Uint64FromInt64(int64(z)-int64(p)) >= l { + v3 = z + z = z + 1 + if !(**(**int8)(__ccgo_up(v3)) != 0) { + break + } + goto _1 + } + Xmemcpy(tls, b, p, Uint64FromInt64(int64(z)-int64(p))) + *(*int8)(unsafe.Add(unsafe.Pointer(b), int64(z)-int64(p))) = int8('/') + Xmemcpy(tls, b+uintptr(int64(z)-int64(p))+BoolUintptr(z > p), file, k+uint64(1)) + Xexecve(tls, b, argv, envp) + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(EACCES): + seen_eacces = int32(1) + fallthrough + case int32(ENOENT): + fallthrough + case int32(ENOTDIR): + default: + return -int32(1) + } + v3 = z + z = z + 1 + if !(**(**int8)(__ccgo_up(v3)) != 0) { + break + } + goto _1 + _1: + ; + p = z + } + if seen_eacces != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EACCES) + } + return -int32(1) +} + +func Xexecvp(tls *TLS, file uintptr, argv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v file=%v argv=%v, (%v:)", tls, file, argv, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__execvpe(tls, file, argv, Xenviron) +} + +func Xexecvpe(tls *TLS, file uintptr, argv uintptr, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v file=%v argv=%v envp=%v, (%v:)", tls, file, argv, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__execvpe(tls, file, argv, envp) +} + +func Xfexecve(tls *TLS, fd int32, argv uintptr, envp uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v argv=%v envp=%v, (%v:)", tls, fd, argv, envp, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var r int32 + var _ /* buf at bp+0 */ [27]int8 + _ = r + r = int32(X__syscall5(tls, int64(SYS_execveat), int64(fd), int64(__ccgo_ts), int64(argv), int64(envp), int64(Int32FromInt32(AT_EMPTY_PATH)))) + if r != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + X__procfdname(tls, bp, Uint32FromInt32(fd)) + Xexecve(tls, bp, argv, envp) + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOENT) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EBADF) + } + return -int32(1) +} + +var _dummy_lockptr = uintptr(0) + +var _atfork_locks = [10]uintptr{ + 0: uintptr(unsafe.Pointer(&X__at_quick_exit_lockptr)), + 1: uintptr(unsafe.Pointer(&_dummy_lockptr)), + 2: uintptr(unsafe.Pointer(&X__gettext_lockptr)), + 3: uintptr(unsafe.Pointer(&X__locale_lockptr)), + 4: uintptr(unsafe.Pointer(&X__random_lockptr)), + 5: uintptr(unsafe.Pointer(&_dummy_lockptr)), + 6: uintptr(unsafe.Pointer(&X__stdio_ofl_lockptr)), + 7: uintptr(unsafe.Pointer(&X__syslog_lockptr)), + 8: uintptr(unsafe.Pointer(&X__timezone_lockptr)), + 9: uintptr(unsafe.Pointer(&_dummy_lockptr)), +} + +func _dummy8(tls *TLS, x int32) { +} + +func _dummy_0(tls *TLS) { +} + +const FDOP_CHDIR = 4 +const FDOP_CLOSE = 1 +const FDOP_DUP2 = 2 +const FDOP_FCHDIR = 5 +const FDOP_OPEN = 3 +const POSIX_SPAWN_RESETIDS = 1 +const POSIX_SPAWN_SETPGROUP = 2 +const POSIX_SPAWN_SETSCHEDPARAM = 16 +const POSIX_SPAWN_SETSCHEDULER = 32 +const POSIX_SPAWN_SETSID = 128 +const POSIX_SPAWN_SETSIGDEF = 4 +const POSIX_SPAWN_SETSIGMASK = 8 +const POSIX_SPAWN_USEVFORK = 64 + +type Tposix_spawnattr_t = struct { + F__flags int32 + F__pgrp Tpid_t + F__def Tsigset_t + F__mask Tsigset_t + F__prio int32 + F__pol int32 + F__fn uintptr + F__pad [56]int8 +} + +type Tposix_spawn_file_actions_t = struct { + F__pad0 [2]int32 + F__actions uintptr + F__pad [16]int32 +} + +type Tfdop = struct { + Fnext uintptr + Fprev uintptr + Fcmd int32 + Ffd int32 + Fsrcfd int32 + Foflag int32 + Fmode Tmode_t +} + +func Xposix_spawn_file_actions_addchdir_np(tls *TLS, fa uintptr, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v path=%v, (%v:)", tls, fa, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + op = Xmalloc(tls, uint64(40)+_strlen(tls, path)+uint64(1)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_CHDIR) + (*Tfdop)(unsafe.Pointer(op)).Ffd = -int32(1) + Xstrcpy(tls, op+36, path) + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_addclose(tls *TLS, fa uintptr, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v fd=%v, (%v:)", tls, fa, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + if fd < 0 { + return int32(EBADF) + } + op = Xmalloc(tls, uint64(40)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_CLOSE) + (*Tfdop)(unsafe.Pointer(op)).Ffd = fd + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_adddup2(tls *TLS, fa uintptr, srcfd int32, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v srcfd=%v fd=%v, (%v:)", tls, fa, srcfd, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + if srcfd < 0 || fd < 0 { + return int32(EBADF) + } + op = Xmalloc(tls, uint64(40)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_DUP2) + (*Tfdop)(unsafe.Pointer(op)).Fsrcfd = srcfd + (*Tfdop)(unsafe.Pointer(op)).Ffd = fd + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_addfchdir_np(tls *TLS, fa uintptr, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v fd=%v, (%v:)", tls, fa, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + if fd < 0 { + return int32(EBADF) + } + op = Xmalloc(tls, uint64(40)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_FCHDIR) + (*Tfdop)(unsafe.Pointer(op)).Ffd = fd + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_addopen(tls *TLS, fa uintptr, fd int32, path uintptr, flags int32, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v fd=%v path=%v flags=%v mode=%v, (%v:)", tls, fa, fd, path, flags, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + if fd < 0 { + return int32(EBADF) + } + op = Xmalloc(tls, uint64(40)+_strlen(tls, path)+uint64(1)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_OPEN) + (*Tfdop)(unsafe.Pointer(op)).Ffd = fd + (*Tfdop)(unsafe.Pointer(op)).Foflag = flags + (*Tfdop)(unsafe.Pointer(op)).Fmode = mode + Xstrcpy(tls, op+36, path) + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_destroy(tls *TLS, fa uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v, (%v:)", tls, fa, origin(2)) + defer func() { trc("-> %v", r) }() + } + var next, op uintptr + _, _ = next, op + op = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + for op != 0 { + next = (*Tfdop)(unsafe.Pointer(op)).Fnext + Xfree(tls, op) + op = next + } + return 0 +} + +func Xposix_spawn_file_actions_init(tls *TLS, fa uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v, (%v:)", tls, fa, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = uintptr(0) + return 0 +} + +func Xposix_spawnattr_destroy(tls *TLS, attr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v, (%v:)", tls, attr, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xposix_spawnattr_getflags(tls *TLS, attr uintptr, flags uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v flags=%v, (%v:)", tls, attr, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**int16)(__ccgo_up(flags)) = int16((*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__flags) + return 0 +} + +func Xposix_spawnattr_getpgroup(tls *TLS, attr uintptr, pgrp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v pgrp=%v, (%v:)", tls, attr, pgrp, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tpid_t)(__ccgo_up(pgrp)) = (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__pgrp + return 0 +} + +func Xposix_spawnattr_getsigdefault(tls *TLS, attr uintptr, def uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v def=%v, (%v:)", tls, attr, def, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tsigset_t)(__ccgo_up(def)) = (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__def + return 0 +} + +func Xposix_spawnattr_getsigmask(tls *TLS, attr uintptr, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v mask=%v, (%v:)", tls, attr, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tsigset_t)(__ccgo_up(mask)) = (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__mask + return 0 +} + +func Xposix_spawnattr_init(tls *TLS, attr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v, (%v:)", tls, attr, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tposix_spawnattr_t)(__ccgo_up(attr)) = Tposix_spawnattr_t{} + return 0 +} + +func Xposix_spawnattr_getschedparam(tls *TLS, attr uintptr, schedparam uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v schedparam=%v, (%v:)", tls, attr, schedparam, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(ENOSYS) +} + +func Xposix_spawnattr_setschedparam(tls *TLS, attr uintptr, schedparam uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v schedparam=%v, (%v:)", tls, attr, schedparam, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(ENOSYS) +} + +func Xposix_spawnattr_getschedpolicy(tls *TLS, attr uintptr, policy uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v policy=%v, (%v:)", tls, attr, policy, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(ENOSYS) +} + +func Xposix_spawnattr_setschedpolicy(tls *TLS, attr uintptr, policy int32) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v policy=%v, (%v:)", tls, attr, policy, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(ENOSYS) +} + +func Xposix_spawnattr_setflags(tls *TLS, attr uintptr, flags int16) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v flags=%v, (%v:)", tls, attr, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + var all_flags uint32 + _ = all_flags + all_flags = Uint32FromInt32(Int32FromInt32(POSIX_SPAWN_RESETIDS) | Int32FromInt32(POSIX_SPAWN_SETPGROUP) | Int32FromInt32(POSIX_SPAWN_SETSIGDEF) | Int32FromInt32(POSIX_SPAWN_SETSIGMASK) | Int32FromInt32(POSIX_SPAWN_SETSCHEDPARAM) | Int32FromInt32(POSIX_SPAWN_SETSCHEDULER) | Int32FromInt32(POSIX_SPAWN_USEVFORK) | Int32FromInt32(POSIX_SPAWN_SETSID)) + if Uint32FromInt16(flags) & ^all_flags != 0 { + return int32(EINVAL) + } + (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__flags = int32(flags) + return 0 +} + +func Xposix_spawnattr_setpgroup(tls *TLS, attr uintptr, pgrp Tpid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v pgrp=%v, (%v:)", tls, attr, pgrp, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__pgrp = pgrp + return 0 +} + +func Xposix_spawnattr_setsigdefault(tls *TLS, attr uintptr, def uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v def=%v, (%v:)", tls, attr, def, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__def = **(**Tsigset_t)(__ccgo_up(def)) + return 0 +} + +func Xposix_spawnattr_setsigmask(tls *TLS, attr uintptr, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v mask=%v, (%v:)", tls, attr, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__mask = **(**Tsigset_t)(__ccgo_up(mask)) + return 0 +} + +func Xvfork(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* vfork syscall cannot be made from C code */ + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall0(tls, int64(SYS_fork))))) +} + +func Xwait(tls *TLS, status uintptr) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v status=%v, (%v:)", tls, status, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwaitpid(tls, -Int32FromInt32(1), status, 0) +} + +func Xwaitid(tls *TLS, type1 Tidtype_t, id Tid_t, info uintptr, options int32) (r int32) { + if __ccgo_strace { + trc("tls=%v type1=%v id=%v info=%v options=%v, (%v:)", tls, type1, id, info, options, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_waitid), int64(type1), Int64FromUint32(id), int64(info), int64(options), int64(Int32FromInt32(0)), 0)))) +} + +func Xwaitpid(tls *TLS, pid Tpid_t, status uintptr, options int32) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v pid=%v status=%v options=%v, (%v:)", tls, pid, status, options, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_wait4), int64(pid), int64(status), int64(options), int64(Int32FromInt32(0)), 0, 0)))) +} + +const BRACKET = -3 +const END = 0 +const FNM_CASEFOLD = 16 +const FNM_FILE_NAME = 1 +const FNM_LEADING_DIR = 8 +const FNM_NOESCAPE = 2 +const FNM_NOMATCH = 1 +const FNM_NOSYS = -1 +const FNM_PATHNAME = 1 +const FNM_PERIOD = 4 +const QUESTION = -4 +const STAR = -5 +const UNMATCHABLE = -2 + +func _str_next(tls *TLS, str uintptr, n Tsize_t, step uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var k int32 + var _ /* wc at bp+0 */ Twchar_t + _ = k + if !(n != 0) { + **(**Tsize_t)(__ccgo_up(step)) = uint64(0) + return 0 + } + if Uint32FromInt8(**(**int8)(__ccgo_up(str))) >= uint32(128) { + k = Xmbtowc(tls, bp, str, n) + if k < 0 { + **(**Tsize_t)(__ccgo_up(step)) = uint64(1) + return -int32(1) + } + **(**Tsize_t)(__ccgo_up(step)) = Uint64FromInt32(k) + return **(**Twchar_t)(__ccgo_up(bp)) + } + **(**Tsize_t)(__ccgo_up(step)) = uint64(1) + return int32(**(**int8)(__ccgo_up(str))) +} + +func _pat_next(tls *TLS, pat uintptr, m Tsize_t, step uintptr, flags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var esc, k1, z int32 + var k Tsize_t + var _ /* wc at bp+0 */ Twchar_t + _, _, _, _ = esc, k, k1, z + esc = 0 + if !(m != 0) || !(**(**int8)(__ccgo_up(pat)) != 0) { + **(**Tsize_t)(__ccgo_up(step)) = uint64(0) + return END + } + **(**Tsize_t)(__ccgo_up(step)) = uint64(1) + if int32(**(**int8)(__ccgo_up(pat))) == int32('\\') && **(**int8)(__ccgo_up(pat + 1)) != 0 && !(flags&Int32FromInt32(FNM_NOESCAPE) != 0) { + **(**Tsize_t)(__ccgo_up(step)) = uint64(2) + pat = pat + 1 + esc = int32(1) + goto escaped + } + if int32(**(**int8)(__ccgo_up(pat))) == int32('[') { + k = uint64(1) + if k < m { + if int32(**(**int8)(__ccgo_up(pat + uintptr(k)))) == int32('^') || int32(**(**int8)(__ccgo_up(pat + uintptr(k)))) == int32('!') { + k = k + 1 + } + } + if k < m { + if int32(**(**int8)(__ccgo_up(pat + uintptr(k)))) == int32(']') { + k = k + 1 + } + } + for { + if !(k < m && **(**int8)(__ccgo_up(pat + uintptr(k))) != 0 && int32(**(**int8)(__ccgo_up(pat + uintptr(k)))) != int32(']')) { + break + } + if k+uint64(1) < m && **(**int8)(__ccgo_up(pat + uintptr(k+uint64(1)))) != 0 && int32(**(**int8)(__ccgo_up(pat + uintptr(k)))) == int32('[') && (int32(**(**int8)(__ccgo_up(pat + uintptr(k+uint64(1))))) == int32(':') || int32(**(**int8)(__ccgo_up(pat + uintptr(k+uint64(1))))) == int32('.') || int32(**(**int8)(__ccgo_up(pat + uintptr(k+uint64(1))))) == int32('=')) { + z = int32(**(**int8)(__ccgo_up(pat + uintptr(k+uint64(1))))) + k = k + uint64(2) + if k < m && **(**int8)(__ccgo_up(pat + uintptr(k))) != 0 { + k = k + 1 + } + for k < m && **(**int8)(__ccgo_up(pat + uintptr(k))) != 0 && (int32(**(**int8)(__ccgo_up(pat + uintptr(k-uint64(1))))) != z || int32(**(**int8)(__ccgo_up(pat + uintptr(k)))) != int32(']')) { + k = k + 1 + } + if k == m || !(**(**int8)(__ccgo_up(pat + uintptr(k))) != 0) { + break + } + } + goto _1 + _1: + ; + k = k + 1 + } + if k == m || !(**(**int8)(__ccgo_up(pat + uintptr(k))) != 0) { + **(**Tsize_t)(__ccgo_up(step)) = uint64(1) + return int32('[') + } + **(**Tsize_t)(__ccgo_up(step)) = k + uint64(1) + return -int32(3) + } + if int32(**(**int8)(__ccgo_up(pat))) == int32('*') { + return -int32(5) + } + if int32(**(**int8)(__ccgo_up(pat))) == int32('?') { + return -int32(4) + } + goto escaped +escaped: + ; + if Uint32FromInt8(**(**int8)(__ccgo_up(pat))) >= uint32(128) { + k1 = Xmbtowc(tls, bp, pat, m) + if k1 < 0 { + **(**Tsize_t)(__ccgo_up(step)) = uint64(0) + return -int32(2) + } + **(**Tsize_t)(__ccgo_up(step)) = Uint64FromInt32(k1 + esc) + return **(**Twchar_t)(__ccgo_up(bp)) + } + return int32(**(**int8)(__ccgo_up(pat))) +} + +func _casefold(tls *TLS, k int32) (r int32) { + var c int32 + var v1 uint32 + _, _ = c, v1 + c = Int32FromUint32(Xtowupper(tls, Uint32FromInt32(k))) + if c == k { + v1 = Xtowlower(tls, Uint32FromInt32(k)) + } else { + v1 = Uint32FromInt32(c) + } + return Int32FromUint32(v1) +} + +func _match_bracket(tls *TLS, p uintptr, k int32, kfold int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var inv, l, l1, z int32 + var p0 uintptr + var _ /* buf at bp+8 */ [16]int8 + var _ /* wc at bp+0 */ Twchar_t + var _ /* wc2 at bp+4 */ Twchar_t + _, _, _, _, _ = inv, l, l1, p0, z + inv = 0 + p = p + 1 + if int32(**(**int8)(__ccgo_up(p))) == int32('^') || int32(**(**int8)(__ccgo_up(p))) == int32('!') { + inv = int32(1) + p = p + 1 + } + if int32(**(**int8)(__ccgo_up(p))) == int32(']') { + if k == int32(']') { + return BoolInt32(!(inv != 0)) + } + p = p + 1 + } else { + if int32(**(**int8)(__ccgo_up(p))) == int32('-') { + if k == int32('-') { + return BoolInt32(!(inv != 0)) + } + p = p + 1 + } + } + **(**Twchar_t)(__ccgo_up(bp)) = int32(**(**int8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) + for { + if !(int32(**(**int8)(__ccgo_up(p))) != int32(']')) { + break + } + if int32(**(**int8)(__ccgo_up(p))) == int32('-') && int32(**(**int8)(__ccgo_up(p + 1))) != int32(']') { + l = Xmbtowc(tls, bp+4, p+uintptr(1), uint64(4)) + if l < 0 { + return 0 + } + if **(**Twchar_t)(__ccgo_up(bp)) <= **(**Twchar_t)(__ccgo_up(bp + 4)) { + if Uint32FromInt32(k)-Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))) <= Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp + 4))-**(**Twchar_t)(__ccgo_up(bp))) || Uint32FromInt32(kfold)-Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))) <= Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp + 4))-**(**Twchar_t)(__ccgo_up(bp))) { + return BoolInt32(!(inv != 0)) + } + } + p = p + uintptr(l-int32(1)) + goto _1 + } + if int32(**(**int8)(__ccgo_up(p))) == int32('[') && (int32(**(**int8)(__ccgo_up(p + 1))) == int32(':') || int32(**(**int8)(__ccgo_up(p + 1))) == int32('.') || int32(**(**int8)(__ccgo_up(p + 1))) == int32('=')) { + p0 = p + uintptr(2) + z = int32(**(**int8)(__ccgo_up(p + 1))) + p = p + uintptr(3) + for int32(**(**int8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) != z || int32(**(**int8)(__ccgo_up(p))) != int32(']') { + p = p + 1 + } + if z == int32(':') && int64(p-uintptr(1))-int64(p0) < int64(16) { + Xmemcpy(tls, bp+8, p0, Uint64FromInt64(int64(p-uintptr(1))-int64(p0))) + (**(**[16]int8)(__ccgo_up(bp + 8)))[int64(p-uintptr(1))-int64(p0)] = 0 + if Xiswctype(tls, Uint32FromInt32(k), Xwctype(tls, bp+8)) != 0 || Xiswctype(tls, Uint32FromInt32(kfold), Xwctype(tls, bp+8)) != 0 { + return BoolInt32(!(inv != 0)) + } + } + goto _1 + } + if Uint32FromInt8(**(**int8)(__ccgo_up(p))) < uint32(128) { + **(**Twchar_t)(__ccgo_up(bp)) = Int32FromUint8(Uint8FromInt8(**(**int8)(__ccgo_up(p)))) + } else { + l1 = Xmbtowc(tls, bp, p, uint64(4)) + if l1 < 0 { + return 0 + } + p = p + uintptr(l1-int32(1)) + } + if **(**Twchar_t)(__ccgo_up(bp)) == k || **(**Twchar_t)(__ccgo_up(bp)) == kfold { + return BoolInt32(!(inv != 0)) + } + goto _1 + _1: + ; + p = p + 1 + } + return inv +} + +func _fnmatch_internal(tls *TLS, pat uintptr, m Tsize_t, str uintptr, n Tsize_t, flags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, k, kfold, v2 int32 + var endpat, endstr, p, ptail, s, stail, v6 uintptr + var tailcnt Tsize_t + var v9 bool + var _ /* pinc at bp+0 */ Tsize_t + var _ /* sinc at bp+8 */ Tsize_t + _, _, _, _, _, _, _, _, _, _, _, _, _ = c, endpat, endstr, k, kfold, p, ptail, s, stail, tailcnt, v2, v6, v9 + tailcnt = uint64(0) + if flags&int32(FNM_PERIOD) != 0 { + if int32(**(**int8)(__ccgo_up(str))) == int32('.') && int32(**(**int8)(__ccgo_up(pat))) != int32('.') { + return int32(FNM_NOMATCH) + } + } + for { + v2 = _pat_next(tls, pat, m, bp, flags) + c = v2 + switch v2 { + case -int32(2): + return int32(FNM_NOMATCH) + case -int32(5): + pat = pat + 1 + m = m - 1 + default: + k = _str_next(tls, str, n, bp+8) + if k <= 0 { + if c == END { + v2 = 0 + } else { + v2 = int32(FNM_NOMATCH) + } + return v2 + } + str = str + uintptr(**(**Tsize_t)(__ccgo_up(bp + 8))) + n = n - **(**Tsize_t)(__ccgo_up(bp + 8)) + if flags&int32(FNM_CASEFOLD) != 0 { + v2 = _casefold(tls, k) + } else { + v2 = k + } + kfold = v2 + if c == -int32(3) { + if !(_match_bracket(tls, pat, k, kfold) != 0) { + return int32(FNM_NOMATCH) + } + } else { + if c != -int32(4) && k != c && kfold != c { + return int32(FNM_NOMATCH) + } + } + pat = pat + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + m = m - **(**Tsize_t)(__ccgo_up(bp)) + goto _1 + } + break + goto _1 + _1: + } + /* Compute real pat length if it was initially unknown/-1 */ + m = Xstrnlen(tls, pat, m) + endpat = pat + uintptr(m) + /* Find the last * in pat and count chars needed after it */ + v6 = pat + ptail = v6 + p = v6 + for { + if !(p < endpat) { + break + } + switch _pat_next(tls, p, Uint64FromInt64(int64(endpat)-int64(p)), bp, flags) { + case -int32(2): + return int32(FNM_NOMATCH) + case -int32(5): + tailcnt = uint64(0) + ptail = p + uintptr(1) + default: + tailcnt = tailcnt + 1 + break + } + goto _5 + _5: + ; + p = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + } + /* Past this point we need not check for UNMATCHABLE in pat, + * because all of pat has already been parsed once. */ + /* Compute real str length if it was initially unknown/-1 */ + n = Xstrnlen(tls, str, n) + endstr = str + uintptr(n) + if n < tailcnt { + return int32(FNM_NOMATCH) + } + /* Find the final tailcnt chars of str, accounting for UTF-8. + * On illegal sequences we may get it wrong, but in that case + * we necessarily have a matching failure anyway. */ + s = endstr + for { + if !(s > str && tailcnt != 0) { + break + } + if v9 = Uint32FromInt8(**(**int8)(__ccgo_up(s + uintptr(-Int32FromInt32(1))))) < uint32(128); !v9 { + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v2 = int32(4) + } else { + v2 = int32(1) + } + } + if v9 || v2 == int32(1) { + s = s - 1 + } else { + for { + s = s - 1 + v6 = s + if !(uint32(Uint8FromInt8(**(**int8)(__ccgo_up(v6))))-uint32(0x80) < uint32(0x40) && s > str) { + break + } + } + } + goto _7 + _7: + ; + tailcnt = tailcnt - 1 + } + if tailcnt != 0 { + return int32(FNM_NOMATCH) + } + stail = s + /* Check that the pat and str tails match */ + p = ptail + for { + c = _pat_next(tls, p, Uint64FromInt64(int64(endpat)-int64(p)), bp, flags) + p = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + v2 = _str_next(tls, s, Uint64FromInt64(int64(endstr)-int64(s)), bp+8) + k = v2 + if v2 <= 0 { + if c != END { + return int32(FNM_NOMATCH) + } + break + } + s = s + uintptr(**(**Tsize_t)(__ccgo_up(bp + 8))) + if flags&int32(FNM_CASEFOLD) != 0 { + v2 = _casefold(tls, k) + } else { + v2 = k + } + kfold = v2 + if c == -int32(3) { + if !(_match_bracket(tls, p-uintptr(**(**Tsize_t)(__ccgo_up(bp))), k, kfold) != 0) { + return int32(FNM_NOMATCH) + } + } else { + if c != -int32(4) && k != c && kfold != c { + return int32(FNM_NOMATCH) + } + } + goto _11 + _11: + } + /* We're all done with the tails now, so throw them out */ + endstr = stail + endpat = ptail + /* Match pattern components until there are none left */ + for pat < endpat { + p = pat + s = str + for { + c = _pat_next(tls, p, Uint64FromInt64(int64(endpat)-int64(p)), bp, flags) + p = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + /* Encountering * completes/commits a component */ + if c == -int32(5) { + pat = p + str = s + break + } + k = _str_next(tls, s, Uint64FromInt64(int64(endstr)-int64(s)), bp+8) + if !(k != 0) { + return int32(FNM_NOMATCH) + } + if flags&int32(FNM_CASEFOLD) != 0 { + v2 = _casefold(tls, k) + } else { + v2 = k + } + kfold = v2 + if c == -int32(3) { + if !(_match_bracket(tls, p-uintptr(**(**Tsize_t)(__ccgo_up(bp))), k, kfold) != 0) { + break + } + } else { + if c != -int32(4) && k != c && kfold != c { + break + } + } + s = s + uintptr(**(**Tsize_t)(__ccgo_up(bp + 8))) + goto _14 + _14: + } + if c == -int32(5) { + continue + } + /* If we failed, advance str, by 1 char if it's a valid + * char, or past all invalid bytes otherwise. */ + k = _str_next(tls, str, Uint64FromInt64(int64(endstr)-int64(str)), bp+8) + if k > 0 { + str = str + uintptr(**(**Tsize_t)(__ccgo_up(bp + 8))) + } else { + str = str + 1 + for { + if !(_str_next(tls, str, Uint64FromInt64(int64(endstr)-int64(str)), bp+8) < 0) { + break + } + goto _16 + _16: + ; + str = str + 1 + } + } + } + return 0 +} + +func Xfnmatch(tls *TLS, pat uintptr, str uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v pat=%v str=%v flags=%v, (%v:)", tls, pat, str, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, v4 int32 + var p, s uintptr + var _ /* inc at bp+0 */ Tsize_t + _, _, _, _ = c, p, s, v4 + if flags&int32(FNM_PATHNAME) != 0 { + for { + s = str + for { + if !(**(**int8)(__ccgo_up(s)) != 0 && int32(**(**int8)(__ccgo_up(s))) != int32('/')) { + break + } + goto _2 + _2: + ; + s = s + 1 + } + p = pat + for { + v4 = _pat_next(tls, p, Uint64FromInt32(-Int32FromInt32(1)), bp, flags) + c = v4 + if !(v4 != END && c != int32('/')) { + break + } + goto _3 + _3: + ; + p = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + } + if c != int32(**(**int8)(__ccgo_up(s))) && (!(**(**int8)(__ccgo_up(s)) != 0) || !(flags&Int32FromInt32(FNM_LEADING_DIR) != 0)) { + return int32(FNM_NOMATCH) + } + if _fnmatch_internal(tls, pat, Uint64FromInt64(int64(p)-int64(pat)), str, Uint64FromInt64(int64(s)-int64(str)), flags) != 0 { + return int32(FNM_NOMATCH) + } + if !(c != 0) { + return 0 + } + str = s + uintptr(1) + pat = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + goto _1 + _1: + } + } else { + if flags&int32(FNM_LEADING_DIR) != 0 { + s = str + for { + if !(**(**int8)(__ccgo_up(s)) != 0) { + break + } + if int32(**(**int8)(__ccgo_up(s))) != int32('/') { + goto _5 + } + if !(_fnmatch_internal(tls, pat, Uint64FromInt32(-Int32FromInt32(1)), str, Uint64FromInt64(int64(s)-int64(str)), flags) != 0) { + return 0 + } + goto _5 + _5: + ; + s = s + 1 + } + } + } + return _fnmatch_internal(tls, pat, Uint64FromInt32(-Int32FromInt32(1)), str, Uint64FromInt32(-Int32FromInt32(1)), flags) +} + +const GLOB_ABORTED = 2 +const GLOB_APPEND = 32 +const GLOB_DOOFFS = 8 +const GLOB_ERR = 1 +const GLOB_MARK = 2 +const GLOB_NOCHECK = 16 +const GLOB_NOESCAPE = 64 +const GLOB_NOMATCH = 3 +const GLOB_NOSORT = 4 +const GLOB_NOSPACE = 1 +const GLOB_NOSYS = 4 +const GLOB_PERIOD = 128 +const GLOB_TILDE = 4096 +const GLOB_TILDE_CHECK = 16384 + +type Tglob_t = struct { + Fgl_pathc Tsize_t + Fgl_pathv uintptr + Fgl_offs Tsize_t + F__dummy1 int32 + F__dummy2 [5]uintptr +} + +type Tmatch = struct { + Fnext uintptr +} + +func _append(tls *TLS, tail uintptr, name uintptr, len1 Tsize_t, mark int32) (r int32) { + var new1 uintptr + _ = new1 + new1 = Xmalloc(tls, uint64(8)+len1+uint64(2)) + if !(new1 != 0) { + return -int32(1) + } + (*Tmatch)(unsafe.Pointer(**(**uintptr)(__ccgo_up(tail)))).Fnext = new1 + (*Tmatch)(unsafe.Pointer(new1)).Fnext = UintptrFromInt32(0) + Xmemcpy(tls, new1+8, name, len1+uint64(1)) + if mark != 0 && len1 != 0 && int32(**(**int8)(__ccgo_up(name + uintptr(len1-uint64(1))))) != int32('/') { + *(*int8)(unsafe.Pointer(new1 + 8 + uintptr(len1))) = int8('/') + *(*int8)(unsafe.Pointer(new1 + 8 + uintptr(len1+uint64(1)))) = 0 + } + **(**uintptr)(__ccgo_up(tail)) = new1 + return 0 +} + +func _do_glob(tls *TLS, buf uintptr, pos Tsize_t, type1 int32, pat uintptr, flags int32, __ccgo_fp_errfunc uintptr, tail uintptr) (r1 int32) { + bp := tls.Alloc(144) + defer tls.Free(144) + var de, dir, p, p2, v2 uintptr + var fnm_flags, in_bracket, old_errno, overflow, r, readerr, v10, v9 int32 + var i, j, v4 Tptrdiff_t + var l, v1 Tsize_t + var saved_sep int8 + var _ /* st at bp+0 */ Tstat + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = de, dir, fnm_flags, i, in_bracket, j, l, old_errno, overflow, p, p2, r, readerr, saved_sep, v1, v10, v2, v4, v9 + /* If GLOB_MARK is unused, we don't care about type. */ + if !(type1 != 0) && !(flags&Int32FromInt32(GLOB_MARK) != 0) { + type1 = int32(DT_REG) + } + /* Special-case the remaining pattern being all slashes, in + * which case we can use caller-passed type if it's a dir. */ + if **(**int8)(__ccgo_up(pat)) != 0 && type1 != int32(DT_DIR) { + type1 = 0 + } + for pos+uint64(1) < uint64(PATH_MAX) && int32(**(**int8)(__ccgo_up(pat))) == int32('/') { + v1 = pos + pos = pos + 1 + v2 = pat + pat = pat + 1 + **(**int8)(__ccgo_up(buf + uintptr(v1))) = **(**int8)(__ccgo_up(v2)) + } + /* Consume maximal [escaped-]literal prefix of pattern, copying + * and un-escaping it to the running buffer as we go. */ + i = 0 + j = 0 + in_bracket = 0 + overflow = 0 + for { + if !(int32(**(**int8)(__ccgo_up(pat + uintptr(i)))) != int32('*') && int32(**(**int8)(__ccgo_up(pat + uintptr(i)))) != int32('?') && (!(in_bracket != 0) || int32(**(**int8)(__ccgo_up(pat + uintptr(i)))) != int32(']'))) { + break + } + if !(**(**int8)(__ccgo_up(pat + uintptr(i))) != 0) { + if overflow != 0 { + return 0 + } + pat = pat + uintptr(i) + pos = pos + Uint64FromInt64(j) + v4 = Int64FromInt32(0) + j = v4 + i = v4 + break + } else { + if int32(**(**int8)(__ccgo_up(pat + uintptr(i)))) == int32('[') { + in_bracket = int32(1) + } else { + if int32(**(**int8)(__ccgo_up(pat + uintptr(i)))) == int32('\\') && !(flags&Int32FromInt32(GLOB_NOESCAPE) != 0) { + /* Backslashes inside a bracket are (at least by + * our interpretation) non-special, so if next + * char is ']' we have a complete expression. */ + if in_bracket != 0 && int32(**(**int8)(__ccgo_up(pat + uintptr(i+int64(1))))) == int32(']') { + break + } + /* Unpaired final backslash never matches. */ + if !(**(**int8)(__ccgo_up(pat + uintptr(i+int64(1)))) != 0) { + return 0 + } + i = i + 1 + } + } + } + if int32(**(**int8)(__ccgo_up(pat + uintptr(i)))) == int32('/') { + if overflow != 0 { + return 0 + } + in_bracket = 0 + pat = pat + uintptr(i+int64(1)) + i = int64(-int32(1)) + pos = pos + Uint64FromInt64(j+int64(1)) + j = int64(-int32(1)) + } + /* Only store a character if it fits in the buffer, but if + * a potential bracket expression is open, the overflow + * must be remembered and handled later only if the bracket + * is unterminated (and thereby a literal), so as not to + * disallow long bracket expressions with short matches. */ + if pos+Uint64FromInt64(j+Int64FromInt32(1)) < uint64(PATH_MAX) { + v4 = j + j = j + 1 + **(**int8)(__ccgo_up(buf + uintptr(pos+Uint64FromInt64(v4)))) = **(**int8)(__ccgo_up(pat + uintptr(i))) + } else { + if in_bracket != 0 { + overflow = int32(1) + } else { + return 0 + } + } + /* If we consume any new components, the caller-passed type + * or dummy type from above is no longer valid. */ + type1 = 0 + goto _3 + _3: + ; + i = i + 1 + } + **(**int8)(__ccgo_up(buf + uintptr(pos))) = 0 + if !(**(**int8)(__ccgo_up(pat)) != 0) { + if flags&int32(GLOB_MARK) != 0 && (!(type1 != 0) || type1 == int32(DT_LNK)) && !(Xstat(tls, buf, bp) != 0) { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFDIR) { + type1 = int32(DT_DIR) + } else { + type1 = int32(DT_REG) + } + } + if !(type1 != 0) && Xlstat(tls, buf, bp) != 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(ENOENT) && ((*(*func(*TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_errfunc})))(tls, buf, **(**int32)(__ccgo_up(X__errno_location(tls)))) != 0 || flags&int32(GLOB_ERR) != 0) { + return int32(GLOB_ABORTED) + } + return 0 + } + if _append(tls, tail, buf, pos, BoolInt32(flags&int32(GLOB_MARK) != 0 && type1 == int32(DT_DIR))) != 0 { + return int32(GLOB_NOSPACE) + } + return 0 + } + p2 = Xstrchr(tls, pat, int32('/')) + saved_sep = int8('/') + /* Check if the '/' was escaped and, if so, remove the escape char + * so that it will not be unpaired when passed to fnmatch. */ + if p2 != 0 && !(flags&Int32FromInt32(GLOB_NOESCAPE) != 0) { + p = p2 + for { + if !(p > pat && int32(**(**int8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) == int32('\\')) { + break + } + goto _6 + _6: + ; + p = p - 1 + } + if (int64(p2)-int64(p))%int64(2) != 0 { + p2 = p2 - 1 + saved_sep = int8('\\') + } + } + if pos != 0 { + v2 = buf + } else { + v2 = __ccgo_ts + 575 + } + dir = Xopendir(tls, v2) + if !(dir != 0) { + if (*(*func(*TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_errfunc})))(tls, buf, **(**int32)(__ccgo_up(X__errno_location(tls)))) != 0 || flags&int32(GLOB_ERR) != 0 { + return int32(GLOB_ABORTED) + } + return 0 + } + old_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + for { + **(**int32)(__ccgo_up(X__errno_location(tls))) = 0 + v2 = Xreaddir(tls, dir) + de = v2 + if !(v2 != 0) { + break + } + /* Quickly skip non-directories when there's pattern left. */ + if p2 != 0 && (*Tdirent)(unsafe.Pointer(de)).Fd_type != 0 && Int32FromUint8((*Tdirent)(unsafe.Pointer(de)).Fd_type) != int32(DT_DIR) && Int32FromUint8((*Tdirent)(unsafe.Pointer(de)).Fd_type) != int32(DT_LNK) { + continue + } + l = _strlen(tls, de+19) + if l >= uint64(PATH_MAX)-pos { + continue + } + if p2 != 0 { + **(**int8)(__ccgo_up(p2)) = 0 + } + if flags&int32(GLOB_NOESCAPE) != 0 { + v9 = int32(FNM_NOESCAPE) + } else { + v9 = 0 + } + if !(flags&Int32FromInt32(GLOB_PERIOD) != 0) { + v10 = int32(FNM_PERIOD) + } else { + v10 = 0 + } + fnm_flags = v9 | v10 + if Xfnmatch(tls, pat, de+19, fnm_flags) != 0 { + continue + } + /* With GLOB_PERIOD, don't allow matching . or .. unless + * fnmatch would match them with FNM_PERIOD rules in effect. */ + if p2 != 0 && flags&int32(GLOB_PERIOD) != 0 && int32(**(**int8)(__ccgo_up(de + 19))) == int32('.') && (!(**(**int8)(__ccgo_up(de + 19 + 1)) != 0) || int32(**(**int8)(__ccgo_up(de + 19 + 1))) == int32('.') && !(**(**int8)(__ccgo_up(de + 19 + 2)) != 0)) && Xfnmatch(tls, pat, de+19, fnm_flags|int32(FNM_PERIOD)) != 0 { + continue + } + Xmemcpy(tls, buf+uintptr(pos), de+19, l+uint64(1)) + if p2 != 0 { + **(**int8)(__ccgo_up(p2)) = saved_sep + } + if p2 != 0 { + v2 = p2 + } else { + v2 = __ccgo_ts + } + r = _do_glob(tls, buf, pos+l, Int32FromUint8((*Tdirent)(unsafe.Pointer(de)).Fd_type), v2, flags, __ccgo_fp_errfunc, tail) + if r != 0 { + Xclosedir(tls, dir) + return r + } + } + readerr = **(**int32)(__ccgo_up(X__errno_location(tls))) + if p2 != 0 { + **(**int8)(__ccgo_up(p2)) = saved_sep + } + Xclosedir(tls, dir) + if readerr != 0 && ((*(*func(*TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_errfunc})))(tls, buf, **(**int32)(__ccgo_up(X__errno_location(tls)))) != 0 || flags&int32(GLOB_ERR) != 0) { + return int32(GLOB_ABORTED) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + return 0 +} + +func _ignore_err(tls *TLS, path uintptr, err int32) (r int32) { + return 0 +} + +func _freelist(tls *TLS, head uintptr) { + var match, next uintptr + _, _ = match, next + match = (*Tmatch)(unsafe.Pointer(head)).Fnext + for { + if !(match != 0) { + break + } + next = (*Tmatch)(unsafe.Pointer(match)).Fnext + Xfree(tls, match) + goto _1 + _1: + ; + match = next + } +} + +func _sort(tls *TLS, a uintptr, b uintptr) (r int32) { + return Xstrcmp(tls, **(**uintptr)(__ccgo_up(a)), **(**uintptr)(__ccgo_up(b))) +} + +func _expand_tilde(tls *TLS, pat uintptr, buf uintptr, pos uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var delim, v1 int8 + var home, name_end, p, v2 uintptr + var i, v10 Tsize_t + var v4 int32 + var _ /* pw at bp+0 */ Tpasswd + var _ /* res at bp+48 */ uintptr + _, _, _, _, _, _, _, _, _ = delim, home, i, name_end, p, v1, v10, v2, v4 + p = **(**uintptr)(__ccgo_up(pat)) + uintptr(1) + i = uint64(0) + name_end = X__strchrnul(tls, p, int32('/')) + v1 = **(**int8)(__ccgo_up(name_end)) + delim = v1 + if v1 != 0 { + v2 = name_end + name_end = name_end + 1 + **(**int8)(__ccgo_up(v2)) = 0 + } + **(**uintptr)(__ccgo_up(pat)) = name_end + if **(**int8)(__ccgo_up(p)) != 0 { + v2 = UintptrFromInt32(0) + } else { + v2 = Xgetenv(tls, __ccgo_ts+1412) + } + home = v2 + if !(home != 0) { + if **(**int8)(__ccgo_up(p)) != 0 { + v4 = Xgetpwnam_r(tls, p, bp, buf, uint64(PATH_MAX), bp+48) + } else { + v4 = Xgetpwuid_r(tls, Xgetuid(tls), bp, buf, uint64(PATH_MAX), bp+48) + } + switch v4 { + case int32(ENOMEM): + goto _5 + default: + goto _6 + case 0: + goto _7 + } + goto _8 + _5: + ; + return int32(GLOB_NOSPACE) + _7: + ; + if !!(**(**uintptr)(__ccgo_up(bp + 48)) != 0) { + goto _9 + } + _6: + ; + return int32(GLOB_NOMATCH) + _9: + ; + _8: + ; + home = (**(**Tpasswd)(__ccgo_up(bp))).Fpw_dir + } + for i < Uint64FromInt32(Int32FromInt32(PATH_MAX)-Int32FromInt32(2)) && **(**int8)(__ccgo_up(home)) != 0 { + v10 = i + i = i + 1 + v2 = home + home = home + 1 + **(**int8)(__ccgo_up(buf + uintptr(v10))) = **(**int8)(__ccgo_up(v2)) + } + if **(**int8)(__ccgo_up(home)) != 0 { + return int32(GLOB_NOMATCH) + } + v1 = delim + **(**int8)(__ccgo_up(buf + uintptr(i))) = v1 + if v1 != 0 { + i = i + 1 + v10 = i + **(**int8)(__ccgo_up(buf + uintptr(v10))) = 0 + } + **(**Tsize_t)(__ccgo_up(pos)) = i + return 0 +} + +type t__ccgo_fp__Xglob_2 = func(*TLS, uintptr, int32) int32 + +func Xglob(tls *TLS, pat uintptr, flags int32, __ccgo_fp_errfunc uintptr, g uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v pat=%v flags=%v __ccgo_fp_errfunc=%v g=%v, (%v:)", tls, pat, flags, __ccgo_fp_errfunc, g, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(4128) + defer tls.Free(4128) + var cnt, i, offs Tsize_t + var error1 int32 + var p, pathv uintptr + var v1 uint64 + var _ /* buf at bp+16 */ [4096]int8 + var _ /* head at bp+0 */ Tmatch + var _ /* pos at bp+4112 */ Tsize_t + var _ /* s at bp+4120 */ uintptr + var _ /* tail at bp+8 */ uintptr + _, _, _, _, _, _, _ = cnt, error1, i, offs, p, pathv, v1 + **(**Tmatch)(__ccgo_up(bp)) = struct { + Fnext uintptr + }{} + **(**uintptr)(__ccgo_up(bp + 8)) = bp + if flags&int32(GLOB_DOOFFS) != 0 { + v1 = (*Tglob_t)(unsafe.Pointer(g)).Fgl_offs + } else { + v1 = uint64(0) + } + offs = v1 + error1 = 0 + if !(__ccgo_fp_errfunc != 0) { + __ccgo_fp_errfunc = __ccgo_fp(_ignore_err) + } + if !(flags&Int32FromInt32(GLOB_APPEND) != 0) { + (*Tglob_t)(unsafe.Pointer(g)).Fgl_offs = offs + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc = uint64(0) + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv = UintptrFromInt32(0) + } + if **(**int8)(__ccgo_up(pat)) != 0 { + p = Xstrdup(tls, pat) + if !(p != 0) { + return int32(GLOB_NOSPACE) + } + (**(**[4096]int8)(__ccgo_up(bp + 16)))[0] = 0 + **(**Tsize_t)(__ccgo_up(bp + 4112)) = uint64(0) + **(**uintptr)(__ccgo_up(bp + 4120)) = p + if flags&(Int32FromInt32(GLOB_TILDE)|Int32FromInt32(GLOB_TILDE_CHECK)) != 0 && int32(**(**int8)(__ccgo_up(p))) == int32('~') { + error1 = _expand_tilde(tls, bp+4120, bp+16, bp+4112) + } + if !(error1 != 0) { + error1 = _do_glob(tls, bp+16, **(**Tsize_t)(__ccgo_up(bp + 4112)), 0, **(**uintptr)(__ccgo_up(bp + 4120)), flags, __ccgo_fp_errfunc, bp+8) + } + Xfree(tls, p) + } + if error1 == int32(GLOB_NOSPACE) { + _freelist(tls, bp) + return error1 + } + cnt = uint64(0) + **(**uintptr)(__ccgo_up(bp + 8)) = (**(**Tmatch)(__ccgo_up(bp))).Fnext + for { + if !(**(**uintptr)(__ccgo_up(bp + 8)) != 0) { + break + } + goto _2 + _2: + ; + **(**uintptr)(__ccgo_up(bp + 8)) = (*Tmatch)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).Fnext + cnt = cnt + 1 + } + if !(cnt != 0) { + if flags&int32(GLOB_NOCHECK) != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = bp + if _append(tls, bp+8, pat, _strlen(tls, pat), 0) != 0 { + return int32(GLOB_NOSPACE) + } + cnt = cnt + 1 + } else { + if !(error1 != 0) { + return int32(GLOB_NOMATCH) + } + } + } + if flags&int32(GLOB_APPEND) != 0 { + pathv = Xrealloc(tls, (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv, (offs+(*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc+cnt+uint64(1))*uint64(8)) + if !(pathv != 0) { + _freelist(tls, bp) + return int32(GLOB_NOSPACE) + } + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv = pathv + offs = offs + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc + } else { + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv = Xmalloc(tls, (offs+cnt+uint64(1))*uint64(8)) + if !((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv != 0) { + _freelist(tls, bp) + return int32(GLOB_NOSPACE) + } + i = uint64(0) + for { + if !(i < offs) { + break + } + **(**uintptr)(__ccgo_up((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv + uintptr(i)*8)) = UintptrFromInt32(0) + goto _3 + _3: + ; + i = i + 1 + } + } + i = uint64(0) + **(**uintptr)(__ccgo_up(bp + 8)) = (**(**Tmatch)(__ccgo_up(bp))).Fnext + for { + if !(i < cnt) { + break + } + **(**uintptr)(__ccgo_up((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv + uintptr(offs+i)*8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 8 + goto _4 + _4: + ; + **(**uintptr)(__ccgo_up(bp + 8)) = (*Tmatch)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).Fnext + i = i + 1 + } + **(**uintptr)(__ccgo_up((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv + uintptr(offs+i)*8)) = UintptrFromInt32(0) + **(**Tsize_t)(__ccgo_up(g)) += cnt + if !(flags&Int32FromInt32(GLOB_NOSORT) != 0) { + Xqsort(tls, (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv+uintptr(offs)*8, cnt, uint64(8), __ccgo_fp(_sort)) + } + return error1 +} + +func Xglobfree(tls *TLS, g uintptr) { + if __ccgo_strace { + trc("tls=%v g=%v, (%v:)", tls, g, origin(2)) + } + var i Tsize_t + _ = i + i = uint64(0) + for { + if !(i < (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc) { + break + } + Xfree(tls, **(**uintptr)(__ccgo_up((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv + uintptr((*Tglob_t)(unsafe.Pointer(g)).Fgl_offs+i)*8))-uintptr(uint64(UintptrFromInt32(0)+8))) + goto _1 + _1: + ; + i = i + 1 + } + Xfree(tls, (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv) + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc = uint64(0) + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv = UintptrFromInt32(0) +} + +const ASSERTION = -2 +const ASSERT_AT_BOL = 1 +const ASSERT_AT_BOW = 16 +const ASSERT_AT_EOL = 2 +const ASSERT_AT_EOW = 32 +const ASSERT_AT_WB = 64 +const ASSERT_AT_WB_NEG = 128 +const ASSERT_BACKREF = 256 +const ASSERT_CHAR_CLASS = 4 +const ASSERT_CHAR_CLASS_NEG = 8 +const ASSERT_LAST = 256 +const BACKREF = -4 +const COPY_MAXIMIZE_FIRST_TAG = 2 +const COPY_REMOVE_TAGS = 1 +const EMPTY1 = -1 +const MAX_NEG_CLASSES = 64 +const REG_BADBR = 10 +const REG_BADPAT = 2 +const REG_BADRPT = 13 +const REG_EBRACE = 9 +const REG_EBRACK = 7 +const REG_ECOLLATE = 3 +const REG_ECTYPE = 4 +const REG_EESCAPE = 5 +const REG_ENOSYS = -1 +const REG_EPAREN = 8 +const REG_ERANGE = 11 +const REG_ESPACE = 12 +const REG_ESUBREG = 6 +const REG_EXTENDED = 1 +const REG_ICASE = 2 +const REG_NEWLINE = 4 +const REG_NOMATCH = 1 +const REG_NOSUB = 8 +const REG_NOTBOL = 1 +const REG_NOTEOL = 2 +const REG_OK = 0 +const TAG = -3 +const TRE_CHAR_MAX = 1114111 +const TRE_MEM_BLOCK_SIZE = 1024 +const TRE_REGEX_T_FIELD = 0 +const tre_ctype = 0 +const tre_isalnum = 0 +const tre_isalpha = 0 +const tre_isblank = 0 +const tre_iscntrl = 0 +const tre_isctype = 0 +const tre_isdigit = 0 +const tre_isgraph = 0 +const tre_islower = 0 +const tre_isprint = 0 +const tre_ispunct = 0 +const tre_isspace = 0 +const tre_isupper = 0 +const tre_isxdigit = 0 +const tre_mem_alloc_impl = 0 +const tre_mem_destroy = 0 +const tre_mem_new_impl = 0 +const tre_strlen = 0 +const tre_tolower = 0 +const tre_toupper = 0 +const xcalloc = 0 +const xfree = 0 +const xmalloc = 0 +const xrealloc = 0 + +type Tregoff_t = int64 + +type Tregex_t = struct { + Fre_nsub Tsize_t + F__opaque uintptr + F__padding [4]uintptr + F__nsub2 Tsize_t + F__padding2 int8 +} + +type Tre_pattern_buffer = Tregex_t + +type Tregmatch_t = struct { + Frm_so Tregoff_t + Frm_eo Tregoff_t +} + +type Treg_errcode_t = int32 + +type Ttre_char_t = int32 + +type Ttre_cint_t = uint32 + +type Ttre_ctype_t = uint64 + +type Ttre_tnfa_transition_t = struct { + Fcode_min Ttre_cint_t + Fcode_max Ttre_cint_t + Fstate uintptr + Fstate_id int32 + Ftags uintptr + Fassertions int32 + Fu struct { + Fbackref [0]int32 + Fclass Ttre_ctype_t + } + Fneg_classes uintptr +} + +type Ttnfa_transition = Ttre_tnfa_transition_t + +type Ttre_tag_direction_t = int32 + +const _TRE_TAG_MINIMIZE = 0 +const _TRE_TAG_MAXIMIZE = 1 + +type Ttre_submatch_data = struct { + Fso_tag int32 + Feo_tag int32 + Fparents uintptr +} + +type Ttre_submatch_data_t = struct { + Fso_tag int32 + Feo_tag int32 + Fparents uintptr +} + +type Ttre_tnfa_t = struct { + Ftransitions uintptr + Fnum_transitions uint32 + Finitial uintptr + Ffinal uintptr + Fsubmatch_data uintptr + Ffirstpos_chars uintptr + Ffirst_char int32 + Fnum_submatches uint32 + Ftag_directions uintptr + Fminimal_tags uintptr + Fnum_tags int32 + Fnum_minimals int32 + Fend_tag int32 + Fnum_states int32 + Fcflags int32 + Fhave_backrefs int32 + Fhave_approx int32 +} + +type Ttnfa = Ttre_tnfa_t + +type Ttre_list_t = struct { + Fdata uintptr + Fnext uintptr +} + +type Ttre_list = Ttre_list_t + +type Ttre_mem_t = uintptr + +type Ttre_mem_struct = struct { + Fblocks uintptr + Fcurrent uintptr + Fptr uintptr + Fn Tsize_t + Ffailed int32 + Fprovided uintptr +} + +/*********************************************************************** + from tre-compile.h +***********************************************************************/ + +type Ttre_pos_and_tags_t = struct { + Fposition int32 + Fcode_min int32 + Fcode_max int32 + Ftags uintptr + Fassertions int32 + Fclass Ttre_ctype_t + Fneg_classes uintptr + Fbackref int32 +} + +/*********************************************************************** + from tre-ast.c and tre-ast.h +***********************************************************************/ + +// C documentation +// +// /* The different AST node types. */ +type Ttre_ast_type_t = int32 + +const _LITERAL = 0 +const _CATENATION = 1 +const _ITERATION = 2 +const _UNION = 3 + +/* Special subtypes of TRE_LITERAL. */ + +// C documentation +// +// /* A generic AST node. All AST nodes consist of this node on the top +// level with `obj' pointing to the actual content. */ +type Ttre_ast_node_t = struct { + Ftype1 Ttre_ast_type_t + Fobj uintptr + Fnullable int32 + Fsubmatch_id int32 + Fnum_submatches int32 + Fnum_tags int32 + Ffirstpos uintptr + Flastpos uintptr +} + +// C documentation +// +// /* A "literal" node. These are created for assertions, back references, +// tags, matching parameter settings, and all expressions that match one +// character. */ +type Ttre_literal_t = struct { + Fcode_min int64 + Fcode_max int64 + Fposition int32 + Fclass Ttre_ctype_t + Fneg_classes uintptr +} + +// C documentation +// +// /* A "catenation" node. These are created when two regexps are concatenated. +// If there are more than one subexpressions in sequence, the `left' part +// holds all but the last, and `right' part holds the last subexpression +// (catenation is left associative). */ +type Ttre_catenation_t = struct { + Fleft uintptr + Fright uintptr +} + +// C documentation +// +// /* An "iteration" node. These are created for the "*", "+", "?", and "{m,n}" +// operators. */ +type Ttre_iteration_t = struct { + Farg uintptr + Fmin int32 + Fmax int32 + F__ccgo16 uint8 +} + +// C documentation +// +// /* An "union" node. These are created for the "|" operator. */ +type Ttre_union_t = struct { + Fleft uintptr + Fright uintptr +} + +func _tre_ast_new_node(tls *TLS, mem Ttre_mem_t, type1 int32, obj uintptr) (r uintptr) { + var node uintptr + _ = node + node = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(48)) + if !(node != 0) || !(obj != 0) { + return uintptr(0) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj = obj + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 = type1 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id = -int32(1) + return node +} + +func _tre_ast_new_literal(tls *TLS, mem Ttre_mem_t, code_min int32, code_max int32, position int32) (r uintptr) { + var lit, node uintptr + _, _ = lit, node + lit = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(40)) + node = _tre_ast_new_node(tls, mem, int32(_LITERAL), lit) + if !(node != 0) { + return uintptr(0) + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64(code_min) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64(code_max) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = position + return node +} + +func _tre_ast_new_iter(tls *TLS, mem Ttre_mem_t, arg uintptr, min int32, max int32, minimal int32) (r uintptr) { + var iter, node uintptr + _, _ = iter, node + iter = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(24)) + node = _tre_ast_new_node(tls, mem, int32(_ITERATION), iter) + if !(node != 0) { + return uintptr(0) + } + (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg = arg + (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmin = min + (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmax = max + SetBitFieldPtr8Uint32(iter+16, Uint32FromInt32(minimal), 0, 0x1) + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(arg)).Fnum_submatches + return node +} + +func _tre_ast_new_union(tls *TLS, mem Ttre_mem_t, left uintptr, right uintptr) (r uintptr) { + var node, un uintptr + _, _ = node, un + if !(left != 0) { + return right + } + un = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(16)) + node = _tre_ast_new_node(tls, mem, int32(_UNION), un) + if !(node != 0) || !(right != 0) { + return uintptr(0) + } + (*Ttre_union_t)(unsafe.Pointer(un)).Fleft = left + (*Ttre_union_t)(unsafe.Pointer(un)).Fright = right + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(left)).Fnum_submatches + (*Ttre_ast_node_t)(unsafe.Pointer(right)).Fnum_submatches + return node +} + +func _tre_ast_new_catenation(tls *TLS, mem Ttre_mem_t, left uintptr, right uintptr) (r uintptr) { + var cat, node uintptr + _, _ = cat, node + if !(left != 0) { + return right + } + cat = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(16)) + node = _tre_ast_new_node(tls, mem, int32(_CATENATION), cat) + if !(node != 0) { + return uintptr(0) + } + (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft = left + (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright = right + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(left)).Fnum_submatches + (*Ttre_ast_node_t)(unsafe.Pointer(right)).Fnum_submatches + return node +} + +/*********************************************************************** + from tre-stack.c and tre-stack.h +***********************************************************************/ + +type Ttre_stack_t = struct { + Fsize int32 + Fmax_size int32 + Fincrement int32 + Fptr int32 + Fstack uintptr +} + +/*********************************************************************** + from tre-stack.c and tre-stack.h +***********************************************************************/ + +type Ttre_stack_rec = Ttre_stack_t + +/* Just to save some typing. */ + +type Ttre_stack_item = struct { + Fint_value [0]int32 + Fvoidptr_value uintptr +} + +func _tre_stack_new(tls *TLS, size int32, max_size int32, increment int32) (r uintptr) { + var s uintptr + _ = s + s = Xmalloc(tls, uint64(24)) + if s != UintptrFromInt32(0) { + (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack = Xmalloc(tls, uint64(8)*Uint64FromInt32(size)) + if (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack == UintptrFromInt32(0) { + Xfree(tls, s) + return UintptrFromInt32(0) + } + (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize = size + (*Ttre_stack_t)(unsafe.Pointer(s)).Fmax_size = max_size + (*Ttre_stack_t)(unsafe.Pointer(s)).Fincrement = increment + (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr = 0 + } + return s +} + +func _tre_stack_destroy(tls *TLS, s uintptr) { + Xfree(tls, (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack) + Xfree(tls, s) +} + +func _tre_stack_num_objects(tls *TLS, s uintptr) (r int32) { + return (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr +} + +func _tre_stack_push(tls *TLS, s uintptr, value Ttre_stack_item) (r Treg_errcode_t) { + var new_buffer uintptr + var new_size int32 + _, _ = new_buffer, new_size + if (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr < (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize { + **(**Ttre_stack_item)(__ccgo_up((*Ttre_stack_t)(unsafe.Pointer(s)).Fstack + uintptr((*Ttre_stack_t)(unsafe.Pointer(s)).Fptr)*8)) = value + (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr = (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr + 1 + } else { + if (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize >= (*Ttre_stack_t)(unsafe.Pointer(s)).Fmax_size { + return int32(REG_ESPACE) + } else { + new_size = (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize + (*Ttre_stack_t)(unsafe.Pointer(s)).Fincrement + if new_size > (*Ttre_stack_t)(unsafe.Pointer(s)).Fmax_size { + new_size = (*Ttre_stack_t)(unsafe.Pointer(s)).Fmax_size + } + new_buffer = Xrealloc(tls, (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack, uint64(8)*Uint64FromInt32(new_size)) + if new_buffer == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize = new_size + (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack = new_buffer + _tre_stack_push(tls, s, value) + } + } + return REG_OK +} + +func _tre_stack_push_int(tls *TLS, s uintptr, value int32) (r Treg_errcode_t) { + var item Ttre_stack_item + _ = item + *(*int32)(unsafe.Pointer(&item)) = value + return _tre_stack_push(tls, s, item) +} + +func _tre_stack_push_voidptr(tls *TLS, s uintptr, value uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* item at bp+0 */ Ttre_stack_item + *(*uintptr)(unsafe.Pointer(bp)) = value + return _tre_stack_push(tls, s, **(**Ttre_stack_item)(__ccgo_up(bp))) +} + +func _tre_stack_pop_int(tls *TLS, s uintptr) (r int32) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + v2 = s + 12 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + return *(*int32)(unsafe.Pointer(&**(**Ttre_stack_item)(__ccgo_up((*Ttre_stack_t)(unsafe.Pointer(s)).Fstack + uintptr(v1)*8)))) +} + +func _tre_stack_pop_voidptr(tls *TLS, s uintptr) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + v2 = s + 12 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + return *(*uintptr)(unsafe.Pointer((*Ttre_stack_t)(unsafe.Pointer(s)).Fstack + uintptr(v1)*8)) +} + +/*********************************************************************** + from tre-parse.c and tre-parse.h +***********************************************************************/ + +// C documentation +// +// /* Parse context. */ +type Ttre_parse_ctx_t = struct { + Fmem Ttre_mem_t + Fstack uintptr + Fn uintptr + Fs uintptr + Fstart uintptr + Fsubmatch_id int32 + Fposition int32 + Fmax_backref int32 + Fcflags int32 +} + +// C documentation +// +// /* Some macros for expanding \w, \s, etc. */ +var _tre_macros = [13]struct { + Fc int8 + Fexpansion uintptr +}{ + 0: { + Fc: int8('t'), + Fexpansion: __ccgo_ts + 1417, + }, + 1: { + Fc: int8('n'), + Fexpansion: __ccgo_ts + 367, + }, + 2: { + Fc: int8('r'), + Fexpansion: __ccgo_ts + 1419, + }, + 3: { + Fc: int8('f'), + Fexpansion: __ccgo_ts + 1421, + }, + 4: { + Fc: int8('a'), + Fexpansion: __ccgo_ts + 1423, + }, + 5: { + Fc: int8('e'), + Fexpansion: __ccgo_ts + 1425, + }, + 6: { + Fc: int8('w'), + Fexpansion: __ccgo_ts + 1427, + }, + 7: { + Fc: int8('W'), + Fexpansion: __ccgo_ts + 1440, + }, + 8: { + Fc: int8('s'), + Fexpansion: __ccgo_ts + 1454, + }, + 9: { + Fc: int8('S'), + Fexpansion: __ccgo_ts + 1466, + }, + 10: { + Fc: int8('d'), + Fexpansion: __ccgo_ts + 1479, + }, + 11: { + Fc: int8('D'), + Fexpansion: __ccgo_ts + 1491, + }, + 12: {}, +} + +// C documentation +// +// /* Expands a macro delimited by `regex' and `regex_end' to `buf', which +// must have at least `len' items. Sets buf[0] to zero if the there +// is no match in `tre_macros'. */ +func _tre_expand_macro(tls *TLS, s uintptr) (r uintptr) { + var i int32 + _ = i + i = 0 + for { + if !(_tre_macros[i].Fc != 0 && int32(_tre_macros[i].Fc) != int32(**(**int8)(__ccgo_up(s)))) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + return _tre_macros[i].Fexpansion +} + +func _tre_compare_lit(tls *TLS, a uintptr, b uintptr) (r int32) { + var la, lb uintptr + _, _ = la, lb + la = a + lb = b + /* assumes the range of valid code_min is < INT_MAX */ + return int32((*Ttre_literal_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(la)))).Fcode_min - (*Ttre_literal_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(lb)))).Fcode_min) +} + +type Tliterals = struct { + Fmem Ttre_mem_t + Fa uintptr + Flen1 int32 + Fcap1 int32 +} + +func _tre_new_lit(tls *TLS, p uintptr) (r uintptr) { + var a, v2 uintptr + var v1 int32 + _, _, _ = a, v1, v2 + if (*Tliterals)(unsafe.Pointer(p)).Flen1 >= (*Tliterals)(unsafe.Pointer(p)).Fcap1 { + if (*Tliterals)(unsafe.Pointer(p)).Fcap1 >= Int32FromInt32(1)< max { + return int32(REG_ERANGE) + } + s = s + uintptr(len1) + } + } + if class != 0 && (*Tneg)(unsafe.Pointer(neg)).Fnegate != 0 { + if (*Tneg)(unsafe.Pointer(neg)).Flen1 >= int32(MAX_NEG_CLASSES) { + return int32(REG_ESPACE) + } + v6 = neg + 4 + v2 = *(*int32)(unsafe.Pointer(v6)) + *(*int32)(unsafe.Pointer(v6)) = *(*int32)(unsafe.Pointer(v6)) + 1 + **(**Ttre_ctype_t)(__ccgo_up(neg + 8 + uintptr(v2)*8)) = class + } else { + lit = _tre_new_lit(tls, ls) + if !(lit != 0) { + return int32(REG_ESPACE) + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64(min) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64(max) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fclass = class + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = -int32(1) + /* Add opposite-case codepoints if REG_ICASE is present. + It seems that POSIX requires that bracket negation + should happen before case-folding, but most practical + implementations do it the other way around. Changing + the order would need efficient representation of + case-fold ranges and bracket range sets even with + simple patterns so this is ok for now. */ + if (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags&int32(REG_ICASE) != 0 && !(class != 0) { + if _add_icase_literals(tls, ls, min, max) != 0 { + return int32(REG_ESPACE) + } + } + } + goto _1 + _1: + } + return r +} + +func _parse_bracket(tls *TLS, ctx uintptr, s uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(544) + defer tls.Free(544) + var err Treg_errcode_t + var i, max, min, negmax, negmin, v1 int32 + var lit, n, nc, node uintptr + var _ /* ls at bp+0 */ Tliterals + var _ /* neg at bp+24 */ Tneg + _, _, _, _, _, _, _, _, _, _, _ = err, i, lit, max, min, n, nc, negmax, negmin, node, v1 + node = uintptr(0) + nc = uintptr(0) + (**(**Tliterals)(__ccgo_up(bp))).Fmem = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem + (**(**Tliterals)(__ccgo_up(bp))).Flen1 = 0 + (**(**Tliterals)(__ccgo_up(bp))).Fcap1 = int32(32) + (**(**Tliterals)(__ccgo_up(bp))).Fa = Xmalloc(tls, Uint64FromInt32((**(**Tliterals)(__ccgo_up(bp))).Fcap1)*uint64(8)) + if !((**(**Tliterals)(__ccgo_up(bp))).Fa != 0) { + return int32(REG_ESPACE) + } + (**(**Tneg)(__ccgo_up(bp + 24))).Flen1 = 0 + (**(**Tneg)(__ccgo_up(bp + 24))).Fnegate = BoolInt32(int32(**(**int8)(__ccgo_up(s))) == int32('^')) + if (**(**Tneg)(__ccgo_up(bp + 24))).Fnegate != 0 { + s = s + 1 + } + err = _parse_bracket_terms(tls, ctx, s, bp, bp+24) + if err != REG_OK { + goto parse_bracket_done + } + if (**(**Tneg)(__ccgo_up(bp + 24))).Fnegate != 0 { + /* + * With REG_NEWLINE, POSIX requires that newlines are not matched by + * any form of a non-matching list. + */ + if (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags&int32(REG_NEWLINE) != 0 { + lit = _tre_new_lit(tls, bp) + if !(lit != 0) { + err = int32(REG_ESPACE) + goto parse_bracket_done + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64('\n') + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64('\n') + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = -int32(1) + } + /* Sort the array if we need to negate it. */ + Xqsort(tls, (**(**Tliterals)(__ccgo_up(bp))).Fa, Uint64FromInt32((**(**Tliterals)(__ccgo_up(bp))).Flen1), uint64(8), __ccgo_fp(_tre_compare_lit)) + /* extra lit for the last negated range */ + lit = _tre_new_lit(tls, bp) + if !(lit != 0) { + err = int32(REG_ESPACE) + goto parse_bracket_done + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64(Int32FromInt32(TRE_CHAR_MAX) + Int32FromInt32(1)) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64(Int32FromInt32(TRE_CHAR_MAX) + Int32FromInt32(1)) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = -int32(1) + /* negated classes */ + if (**(**Tneg)(__ccgo_up(bp + 24))).Flen1 != 0 { + nc = X__tre_mem_alloc_impl(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, 0, UintptrFromInt32(0), 0, Uint64FromInt32((**(**Tneg)(__ccgo_up(bp + 24))).Flen1+Int32FromInt32(1))*uint64(8)) + if !(nc != 0) { + err = int32(REG_ESPACE) + goto parse_bracket_done + } + Xmemcpy(tls, nc, bp+24+8, Uint64FromInt32((**(**Tneg)(__ccgo_up(bp + 24))).Flen1)*uint64(8)) + **(**Ttre_ctype_t)(__ccgo_up(nc + uintptr((**(**Tneg)(__ccgo_up(bp + 24))).Flen1)*8)) = uint64(0) + } + } + /* Build a union of the items in the array, negated if necessary. */ + v1 = Int32FromInt32(0) + negmin = v1 + negmax = v1 + i = 0 + for { + if !(i < (**(**Tliterals)(__ccgo_up(bp))).Flen1) { + break + } + lit = **(**uintptr)(__ccgo_up((**(**Tliterals)(__ccgo_up(bp))).Fa + uintptr(i)*8)) + min = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min) + max = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max) + if (**(**Tneg)(__ccgo_up(bp + 24))).Fnegate != 0 { + if min <= negmin { + /* Overlap. */ + if max+int32(1) >= negmin { + v1 = max + int32(1) + } else { + v1 = negmin + } + negmin = v1 + goto _2 + } + negmax = min - int32(1) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64(negmin) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64(negmax) + negmin = max + int32(1) + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fneg_classes = nc + n = _tre_ast_new_node(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, int32(_LITERAL), lit) + node = _tre_ast_new_union(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, node, n) + if !(node != 0) { + err = int32(REG_ESPACE) + break + } + goto _2 + _2: + ; + i = i + 1 + } + goto parse_bracket_done +parse_bracket_done: + ; + Xfree(tls, (**(**Tliterals)(__ccgo_up(bp))).Fa) + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition + 1 + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = node + return err +} + +func _parse_dup_count(tls *TLS, s uintptr, n uintptr) (r uintptr) { + **(**int32)(__ccgo_up(n)) = -int32(1) + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return s + } + **(**int32)(__ccgo_up(n)) = 0 + for { + **(**int32)(__ccgo_up(n)) = int32(10)***(**int32)(__ccgo_up(n)) + (int32(**(**int8)(__ccgo_up(s))) - int32('0')) + s = s + 1 + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) || **(**int32)(__ccgo_up(n)) > int32(RE_DUP_MAX) { + break + } + goto _1 + _1: + } + return s +} + +func _parse_dup(tls *TLS, s uintptr, ere int32, pmin uintptr, pmax uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v4 uintptr + var v2, v3, v5 bool + var _ /* max at bp+4 */ int32 + var _ /* min at bp+0 */ int32 + _, _, _, _, _ = v1, v2, v3, v4, v5 + s = _parse_dup_count(tls, s, bp) + if int32(**(**int8)(__ccgo_up(s))) == int32(',') { + s = _parse_dup_count(tls, s+uintptr(1), bp+4) + } else { + **(**int32)(__ccgo_up(bp + 4)) = **(**int32)(__ccgo_up(bp)) + } + if v3 = **(**int32)(__ccgo_up(bp + 4)) < **(**int32)(__ccgo_up(bp)) && **(**int32)(__ccgo_up(bp + 4)) >= 0 || **(**int32)(__ccgo_up(bp + 4)) > int32(RE_DUP_MAX) || **(**int32)(__ccgo_up(bp)) > int32(RE_DUP_MAX) || **(**int32)(__ccgo_up(bp)) < 0; !v3 { + if v2 = !(ere != 0); v2 { + v1 = s + s = s + 1 + } + } + if v5 = v3 || v2 && int32(**(**int8)(__ccgo_up(v1))) != int32('\\'); !v5 { + v4 = s + s = s + 1 + } + if v5 || int32(**(**int8)(__ccgo_up(v4))) != int32('}') { + return uintptr(0) + } + **(**int32)(__ccgo_up(pmin)) = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(pmax)) = **(**int32)(__ccgo_up(bp + 4)) + return s +} + +func _hexval1(tls *TLS, c uint32) (r int32) { + if c-uint32('0') < uint32(10) { + return Int32FromUint32(c - uint32('0')) + } + c = c | uint32(32) + if c-uint32('a') < uint32(6) { + return Int32FromUint32(c - uint32('a') + uint32(10)) + } + return -int32(1) +} + +func _marksub(tls *TLS, ctx uintptr, node uintptr, subid int32) (r Treg_errcode_t) { + var n uintptr + _ = n + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id >= 0 { + n = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + if !(n != 0) { + return int32(REG_ESPACE) + } + n = _tre_ast_new_catenation(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, n, node) + if !(n != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(n)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches + node = n + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id = subid + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches + 1 + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = node + return REG_OK +} + +/* +BRE grammar: +Regex = Branch | '^' | '$' | '^$' | '^' Branch | Branch '$' | '^' Branch '$' +Branch = Atom | Branch Atom +Atom = char | quoted_char | '.' | Bracket | Atom Dup | '\(' Branch '\)' | back_ref +Dup = '*' | '\{' Count '\}' | '\{' Count ',\}' | '\{' Count ',' Count '\}' + +(leading ^ and trailing $ in a sub expr may be an anchor or literal as well) + +ERE grammar: +Regex = Branch | Regex '|' Branch +Branch = Atom | Branch Atom +Atom = char | quoted_char | '.' | Bracket | Atom Dup | '(' Regex ')' | '^' | '$' +Dup = '*' | '+' | '?' | '{' Count '}' | '{' Count ',}' | '{' Count ',' Count '}' + +(a*+?, ^*, $+, \X, {, (|a) are unspecified) +*/ + +func _parse_atom(tls *TLS, ctx uintptr, s uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, ere, i, len1, v, val, v16 int32 + var err Treg_errcode_t + var node, p, tmp1, tmp11, tmp2, tmp21, v14 uintptr + var _ /* wc at bp+0 */ Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, ere, err, i, len1, node, p, tmp1, tmp11, tmp2, tmp21, v, val, v14, v16 + ere = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags & int32(REG_EXTENDED) + switch int32(**(**int8)(__ccgo_up(s))) { + case int32('['): + goto _1 + case int32('\\'): + goto _2 + case int32('.'): + goto _3 + case int32('^'): + goto _4 + case int32('$'): + goto _5 + case int32('?'): + goto _6 + case int32('+'): + goto _7 + case int32('{'): + goto _8 + case int32('*'): + goto _9 + case int32('|'): + goto _10 + case 0: + goto _11 + default: + goto _12 + } + goto _13 +_1: + ; + return _parse_bracket(tls, ctx, s+uintptr(1)) +_2: + ; + p = _tre_expand_macro(tls, s+uintptr(1)) + if p != 0 { + /* assume \X expansion is a single atom */ + err = _parse_atom(tls, ctx, p) + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fs = s + uintptr(2) + return err + } + /* extensions: \b, \B, \<, \>, \xHH \x{HHHH} */ + s = s + 1 + v14 = s + switch int32(**(**int8)(__ccgo_up(v14))) { + case 0: + return int32(REG_EESCAPE) + case int32('b'): + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_WB), -int32(1)) + case int32('B'): + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_WB_NEG), -int32(1)) + case int32('<'): + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_BOW), -int32(1)) + case int32('>'): + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_EOW), -int32(1)) + case int32('x'): + s = s + 1 + v = 0 + len1 = int32(2) + if int32(**(**int8)(__ccgo_up(s))) == int32('{') { + len1 = int32(8) + s = s + 1 + } + i = 0 + for { + if !(i < len1 && v < int32(0x110000)) { + break + } + c = _hexval1(tls, Uint32FromInt8(**(**int8)(__ccgo_up(s + uintptr(i))))) + if c < 0 { + break + } + v = int32(16)*v + c + goto _15 + _15: + ; + i = i + 1 + } + s = s + uintptr(i) + if len1 == int32(8) { + if int32(**(**int8)(__ccgo_up(s))) != int32('}') { + return int32(REG_EBRACE) + } + s = s + 1 + } + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, v, v, v16) + s = s - 1 + case int32('{'): + fallthrough + case int32('+'): + fallthrough + case int32('?'): + /* extension: treat \+, \? as repetitions in BRE */ + /* reject repetitions after empty expression in BRE */ + if !(ere != 0) { + return int32(REG_BADRPT) + } + fallthrough + case int32('|'): + /* extension: treat \| as alternation in BRE */ + if !(ere != 0) { + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + s = s - 1 + goto end + } + /* fallthrough */ + fallthrough + default: + if !(ere != 0) && Uint32FromInt8(**(**int8)(__ccgo_up(s)))-uint32('1') < uint32(9) { + /* back reference */ + val = int32(**(**int8)(__ccgo_up(s))) - int32('0') + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(4), val, v16) + if val >= (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmax_backref { + v16 = val + } else { + v16 = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmax_backref + } + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmax_backref = v16 + } else { + /* extension: accept unknown escaped char + as a literal */ + goto parse_literal + } + } + s = s + 1 + goto _13 +_3: + ; + if (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags&int32(REG_NEWLINE) != 0 { + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + tmp1 = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, 0, Int32FromUint8('\n')-Int32FromInt32(1), v16) + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + tmp2 = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, Int32FromUint8('\n')+Int32FromInt32(1), int32(TRE_CHAR_MAX), v16) + if tmp1 != 0 && tmp2 != 0 { + node = _tre_ast_new_union(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, tmp1, tmp2) + } else { + node = uintptr(0) + } + } else { + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, 0, int32(TRE_CHAR_MAX), v16) + } + s = s + 1 + goto _13 +_4: + ; + /* '^' has a special meaning everywhere in EREs, and at beginning of BRE. */ + if !(ere != 0) && s != (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart { + goto parse_literal + } + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_BOL), -int32(1)) + s = s + 1 + goto _13 +_5: + ; + /* '$' is special everywhere in EREs, and at the end of a BRE subexpression. */ + if !(ere != 0) && **(**int8)(__ccgo_up(s + 1)) != 0 && (int32(**(**int8)(__ccgo_up(s + 1))) != int32('\\') || int32(**(**int8)(__ccgo_up(s + 2))) != int32(')') && int32(**(**int8)(__ccgo_up(s + 2))) != int32('|')) { + goto parse_literal + } + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_EOL), -int32(1)) + s = s + 1 + goto _13 +_9: + ; +_8: + ; +_7: + ; +_6: + ; + /* reject repetitions after empty expression in ERE */ + if ere != 0 { + return int32(REG_BADRPT) + } +_10: + ; + if !(ere != 0) { + goto parse_literal + } +_11: + ; + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + goto _13 +_12: + ; + goto parse_literal +parse_literal: + ; + len1 = Xmbtowc(tls, bp, s, Uint64FromInt32(-Int32FromInt32(1))) + if len1 < 0 { + return int32(REG_BADPAT) + } + if (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags&int32(REG_ICASE) != 0 && (Xiswupper(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp)))) != 0 || Xiswlower(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp)))) != 0) { + /* multiple opposite case characters are not supported */ + tmp11 = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, Int32FromUint32(Xtowupper(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))))), Int32FromUint32(Xtowupper(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))))), (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition) + tmp21 = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, Int32FromUint32(Xtowlower(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))))), Int32FromUint32(Xtowlower(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))))), (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition) + if tmp11 != 0 && tmp21 != 0 { + node = _tre_ast_new_union(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, tmp11, tmp21) + } else { + node = uintptr(0) + } + } else { + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, **(**Twchar_t)(__ccgo_up(bp)), **(**Twchar_t)(__ccgo_up(bp)), (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition) + } + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition + 1 + s = s + uintptr(len1) + goto _13 +_13: + ; + goto end +end: + ; + if !(node != 0) { + return int32(REG_ESPACE) + } + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = node + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fs = s + return REG_OK +} + +func _tre_parse(tls *TLS, ctx uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, depth, ere, subid, v2 int32 + var err, v1 Treg_errcode_t + var nbranch, nunion, s, stack, v8 uintptr + var _ /* max at bp+4 */ int32 + var _ /* min at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _ = c, depth, ere, err, nbranch, nunion, s, stack, subid, v1, v2, v8 + nbranch = uintptr(0) + nunion = uintptr(0) + ere = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags & int32(REG_EXTENDED) + s = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart + subid = 0 + depth = 0 + stack = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstack + v2 = subid + subid = subid + 1 + v1 = _tre_stack_push_int(tls, stack, v2) + err = v1 + if v1 != REG_OK { + return err + } + for { + if !(ere != 0) && int32(**(**int8)(__ccgo_up(s))) == int32('\\') && int32(**(**int8)(__ccgo_up(s + 1))) == int32('(') || ere != 0 && int32(**(**int8)(__ccgo_up(s))) == int32('(') { + v1 = _tre_stack_push_voidptr(tls, stack, nunion) + err = v1 + if v1 != REG_OK { + return err + } + v1 = _tre_stack_push_voidptr(tls, stack, nbranch) + err = v1 + if v1 != REG_OK { + return err + } + v2 = subid + subid = subid + 1 + v1 = _tre_stack_push_int(tls, stack, v2) + err = v1 + if v1 != REG_OK { + return err + } + s = s + 1 + if !(ere != 0) { + s = s + 1 + } + depth = depth + 1 + v8 = UintptrFromInt32(0) + nunion = v8 + nbranch = v8 + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart = s + goto _3 + } + if !(ere != 0) && int32(**(**int8)(__ccgo_up(s))) == int32('\\') && int32(**(**int8)(__ccgo_up(s + 1))) == int32(')') || ere != 0 && int32(**(**int8)(__ccgo_up(s))) == int32(')') && depth != 0 { + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + if !((*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn != 0) { + return int32(REG_ESPACE) + } + } else { + err = _parse_atom(tls, ctx, s) + if err != REG_OK { + return err + } + s = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fs + } + goto parse_iter + parse_iter: + ; + for { + if int32(**(**int8)(__ccgo_up(s))) != int32('\\') && int32(**(**int8)(__ccgo_up(s))) != int32('*') { + if !(ere != 0) { + break + } + if int32(**(**int8)(__ccgo_up(s))) != int32('+') && int32(**(**int8)(__ccgo_up(s))) != int32('?') && int32(**(**int8)(__ccgo_up(s))) != int32('{') { + break + } + } + if int32(**(**int8)(__ccgo_up(s))) == int32('\\') && ere != 0 { + break + } + /* extension: treat \+, \? as repetitions in BRE */ + if int32(**(**int8)(__ccgo_up(s))) == int32('\\') && int32(**(**int8)(__ccgo_up(s + 1))) != int32('+') && int32(**(**int8)(__ccgo_up(s + 1))) != int32('?') && int32(**(**int8)(__ccgo_up(s + 1))) != int32('{') { + break + } + if int32(**(**int8)(__ccgo_up(s))) == int32('\\') { + s = s + 1 + } + /* handle ^* at the start of a BRE. */ + if !(ere != 0) && s == (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart+uintptr(1) && int32(**(**int8)(__ccgo_up(s + uintptr(-Int32FromInt32(1))))) == int32('^') { + break + } + /* extension: multiple consecutive *+?{,} is unspecified, + but (a+)+ has to be supported so accepting a++ makes + sense, note however that the RE_DUP_MAX limit can be + circumvented: (a{255}){255} uses a lot of memory.. */ + if int32(**(**int8)(__ccgo_up(s))) == int32('{') { + s = _parse_dup(tls, s+uintptr(1), ere, bp, bp+4) + if !(s != 0) { + return int32(REG_BADBR) + } + } else { + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = -int32(1) + if int32(**(**int8)(__ccgo_up(s))) == int32('+') { + **(**int32)(__ccgo_up(bp)) = int32(1) + } + if int32(**(**int8)(__ccgo_up(s))) == int32('?') { + **(**int32)(__ccgo_up(bp + 4)) = int32(1) + } + s = s + 1 + } + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + } else { + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = _tre_ast_new_iter(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), 0) + } + if !((*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn != 0) { + return int32(REG_ESPACE) + } + goto _9 + _9: + } + nbranch = _tre_ast_new_catenation(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, nbranch, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn) + if ere != 0 && int32(**(**int8)(__ccgo_up(s))) == int32('|') || ere != 0 && int32(**(**int8)(__ccgo_up(s))) == int32(')') && depth != 0 || !(ere != 0) && int32(**(**int8)(__ccgo_up(s))) == int32('\\') && int32(**(**int8)(__ccgo_up(s + 1))) == int32(')') || !(ere != 0) && int32(**(**int8)(__ccgo_up(s))) == int32('\\') && int32(**(**int8)(__ccgo_up(s + 1))) == int32('|') || !(**(**int8)(__ccgo_up(s)) != 0) { + /* extension: empty branch is unspecified (), (|a), (a|) + here they are not rejected but match on empty string */ + c = int32(**(**int8)(__ccgo_up(s))) + nunion = _tre_ast_new_union(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, nunion, nbranch) + nbranch = uintptr(0) + if c == int32('\\') && int32(**(**int8)(__ccgo_up(s + 1))) == int32('|') { + s = s + uintptr(2) + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart = s + } else { + if c == int32('|') { + s = s + 1 + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart = s + } else { + if c == int32('\\') { + if !(depth != 0) { + return int32(REG_EPAREN) + } + s = s + uintptr(2) + } else { + if c == int32(')') { + s = s + 1 + } + } + depth = depth - 1 + err = _marksub(tls, ctx, nunion, _tre_stack_pop_int(tls, stack)) + if err != REG_OK { + return err + } + if !(c != 0) && depth < 0 { + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fsubmatch_id = subid + return REG_OK + } + if !(c != 0) || depth < 0 { + return int32(REG_EPAREN) + } + nbranch = _tre_stack_pop_voidptr(tls, stack) + nunion = _tre_stack_pop_voidptr(tls, stack) + goto parse_iter + } + } + } + goto _3 + _3: + } + return r +} + +/*********************************************************************** + from tre-compile.c +***********************************************************************/ + +/* + TODO: + - Fix tre_ast_to_tnfa() to recurse using a stack instead of recursive + function calls. +*/ + +/* + Algorithms to setup tags so that submatch addressing can be done. +*/ + +// C documentation +// +// /* Inserts a catenation node to the root of the tree given in `node'. +// As the left child a new tag with number `tag_id' to `node' is added, +// and the right child is the old root. */ +func _tre_add_tag_left(tls *TLS, mem Ttre_mem_t, node uintptr, tag_id int32) (r Treg_errcode_t) { + var c uintptr + _ = c + c = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(16)) + if c == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft = _tre_ast_new_literal(tls, mem, -int32(3), tag_id, -int32(1)) + if (*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_catenation_t)(unsafe.Pointer(c)).Fright = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(48)) + if (*Ttre_catenation_t)(unsafe.Pointer(c)).Fright == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fobj = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Ftype1 = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fnullable = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fsubmatch_id = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Ffirstpos = UintptrFromInt32(0) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Flastpos = UintptrFromInt32(0) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fnum_tags = 0 + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fnum_submatches = 0 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj = c + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 = int32(_CATENATION) + return REG_OK +} + +// C documentation +// +// /* Inserts a catenation node to the root of the tree given in `node'. +// As the right child a new tag with number `tag_id' to `node' is added, +// and the left child is the old root. */ +func _tre_add_tag_right(tls *TLS, mem Ttre_mem_t, node uintptr, tag_id int32) (r Treg_errcode_t) { + var c uintptr + _ = c + c = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(16)) + if c == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_catenation_t)(unsafe.Pointer(c)).Fright = _tre_ast_new_literal(tls, mem, -int32(3), tag_id, -int32(1)) + if (*Ttre_catenation_t)(unsafe.Pointer(c)).Fright == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(48)) + if (*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fobj = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Ftype1 = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fnullable = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fsubmatch_id = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Ffirstpos = UintptrFromInt32(0) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Flastpos = UintptrFromInt32(0) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fnum_tags = 0 + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fnum_submatches = 0 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj = c + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 = int32(_CATENATION) + return REG_OK +} + +type Ttre_addtags_symbol_t = int32 + +const _ADDTAGS_RECURSE = 0 +const _ADDTAGS_AFTER_ITERATION = 1 +const _ADDTAGS_AFTER_UNION_LEFT = 2 +const _ADDTAGS_AFTER_UNION_RIGHT = 3 +const _ADDTAGS_AFTER_CAT_LEFT = 4 +const _ADDTAGS_AFTER_CAT_RIGHT = 5 +const _ADDTAGS_SET_SUBMATCH_END = 6 + +type Ttre_tag_states_t = struct { + Ftag int32 + Fnext_tag int32 +} + +// C documentation +// +// /* Go through `regset' and set submatch data for submatches that are +// using this tag. */ +func _tre_purge_regset(tls *TLS, regset uintptr, tnfa uintptr, tag int32) { + var i, id, start int32 + _, _, _ = i, id, start + i = 0 + for { + if !(**(**int32)(__ccgo_up(regset + uintptr(i)*4)) >= 0) { + break + } + id = **(**int32)(__ccgo_up(regset + uintptr(i)*4)) / int32(2) + start = BoolInt32(!(**(**int32)(__ccgo_up(regset + uintptr(i)*4))%Int32FromInt32(2) != 0)) + if start != 0 { + (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(id)*16))).Fso_tag = tag + } else { + (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(id)*16))).Feo_tag = tag + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(regset)) = -int32(1) +} + +// C documentation +// +// /* Adds tags to appropriate locations in the parse tree in `tree', so that +// subexpressions marked for submatch addressing can be traced. */ +func _tre_add_tags(tls *TLS, mem Ttre_mem_t, stack uintptr, tree uintptr, tnfa uintptr) (r Treg_errcode_t) { + var added_tags, bottom, enter_tag, first_pass, i1, i2, i3, i4, i5, i6, i7, id, id1, left_tag, minimal, minimal_tag, new_tag, next_tag, num_minimals, num_tags, reserved_tag, right_tag, tag, tag_left, tag_right, v22 int32 + var cat, iter, left, left1, left2, lit, node, orig_regset, p, parents, regset, right, right1, right2, saved_states, uni uintptr + var direction Ttre_tag_direction_t + var i uint32 + var status Treg_errcode_t + var symbol Ttre_addtags_symbol_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = added_tags, bottom, cat, direction, enter_tag, first_pass, i, i1, i2, i3, i4, i5, i6, i7, id, id1, iter, left, left1, left2, left_tag, lit, minimal, minimal_tag, new_tag, next_tag, node, num_minimals, num_tags, orig_regset, p, parents, regset, reserved_tag, right, right1, right2, right_tag, saved_states, status, symbol, tag, tag_left, tag_right, uni, v22 + status = REG_OK + node = tree /* Tree node we are currently looking at. */ + bottom = _tre_stack_num_objects(tls, stack) + /* True for first pass (counting number of needed tags) */ + first_pass = BoolInt32(mem == UintptrFromInt32(0) || tnfa == UintptrFromInt32(0)) + num_tags = 0 /* Total number of tags. */ + num_minimals = 0 /* Number of special minimal tags. */ + tag = 0 /* The tag that is to be added next. */ + next_tag = int32(1) /* Stack of submatches the current submatch is + contained in. */ + minimal_tag = -int32(1) + direction = int32(_TRE_TAG_MINIMIZE) + if !(first_pass != 0) { + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fend_tag = 0 + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags)) = -int32(1) + } + regset = Xmalloc(tls, uint64(4)*uint64(((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches+Uint32FromInt32(1))*Uint32FromInt32(2))) + if regset == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + **(**int32)(__ccgo_up(regset)) = -int32(1) + orig_regset = regset + parents = Xmalloc(tls, uint64(4)*uint64((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches+Uint32FromInt32(1))) + if parents == UintptrFromInt32(0) { + Xfree(tls, regset) + return int32(REG_ESPACE) + } + **(**int32)(__ccgo_up(parents)) = -int32(1) + saved_states = Xmalloc(tls, uint64(8)*uint64((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches+Uint32FromInt32(1))) + if saved_states == UintptrFromInt32(0) { + Xfree(tls, regset) + Xfree(tls, parents) + return int32(REG_ESPACE) + } else { + i = uint32(0) + for { + if !(i <= (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches) { + break + } + (**(**Ttre_tag_states_t)(__ccgo_up(saved_states + uintptr(i)*8))).Ftag = -int32(1) + goto _1 + _1: + ; + i = i + 1 + } + } + status = _tre_stack_push_voidptr(tls, stack, node) + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + for _tre_stack_num_objects(tls, stack) > bottom { + if status != REG_OK { + break + } + symbol = _tre_stack_pop_int(tls, stack) + switch symbol { + case int32(_ADDTAGS_SET_SUBMATCH_END): + goto _2 + case int32(_ADDTAGS_RECURSE): + goto _3 + case int32(_ADDTAGS_AFTER_ITERATION): + goto _4 + case int32(_ADDTAGS_AFTER_CAT_LEFT): + goto _5 + case int32(_ADDTAGS_AFTER_CAT_RIGHT): + goto _6 + case int32(_ADDTAGS_AFTER_UNION_LEFT): + goto _7 + case int32(_ADDTAGS_AFTER_UNION_RIGHT): + goto _8 + default: + goto _9 + } + goto _10 + _2: + ; + id = _tre_stack_pop_int(tls, stack) + /* Add end of this submatch to regset. */ + i1 = 0 + for { + if !(**(**int32)(__ccgo_up(regset + uintptr(i1)*4)) >= 0) { + break + } + goto _11 + _11: + ; + i1 = i1 + 1 + } + **(**int32)(__ccgo_up(regset + uintptr(i1)*4)) = id*int32(2) + int32(1) + **(**int32)(__ccgo_up(regset + uintptr(i1+int32(1))*4)) = -int32(1) + /* Pop this submatch from the parents stack. */ + i1 = 0 + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(i1)*4)) >= 0) { + break + } + goto _12 + _12: + ; + i1 = i1 + 1 + } + **(**int32)(__ccgo_up(parents + uintptr(i1-int32(1))*4)) = -int32(1) + goto _10 + _3: + ; + node = _tre_stack_pop_voidptr(tls, stack) + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id >= 0 { + id1 = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id + /* Add start of this submatch to regset. */ + i2 = 0 + for { + if !(**(**int32)(__ccgo_up(regset + uintptr(i2)*4)) >= 0) { + break + } + goto _13 + _13: + ; + i2 = i2 + 1 + } + **(**int32)(__ccgo_up(regset + uintptr(i2)*4)) = id1 * int32(2) + **(**int32)(__ccgo_up(regset + uintptr(i2+int32(1))*4)) = -int32(1) + if !(first_pass != 0) { + i2 = 0 + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(i2)*4)) >= 0) { + break + } + goto _14 + _14: + ; + i2 = i2 + 1 + } + (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(id1)*16))).Fparents = UintptrFromInt32(0) + if i2 > 0 { + p = Xmalloc(tls, uint64(4)*Uint64FromInt32(i2+Int32FromInt32(1))) + if p == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + goto _10 + } + (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(id1)*16))).Fparents = p + i2 = 0 + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(i2)*4)) >= 0) { + break + } + **(**int32)(__ccgo_up(p + uintptr(i2)*4)) = **(**int32)(__ccgo_up(parents + uintptr(i2)*4)) + goto _15 + _15: + ; + i2 = i2 + 1 + } + **(**int32)(__ccgo_up(p + uintptr(i2)*4)) = -int32(1) + } + } + /* Add end of this submatch to regset after processing this + node. */ + status = _tre_stack_push_int(tls, stack, (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id) + if status != REG_OK { + goto _10 + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_SET_SUBMATCH_END)) + if status != REG_OK { + goto _10 + } + } + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if !((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min < Int64FromInt32(0)) || (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(4)) { + if **(**int32)(__ccgo_up(regset)) >= 0 { + /* Regset is not empty, so add a tag before the + literal or backref. */ + if !(first_pass != 0) { + status = _tre_add_tag_left(tls, mem, node, tag) + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag)*4)) = direction + if minimal_tag >= 0 { + i3 = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i3)*4)) >= 0) { + break + } + goto _16 + _16: + ; + i3 = i3 + 1 + } + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i3)*4)) = tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i3+int32(1))*4)) = minimal_tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i3+int32(2))*4)) = -int32(1) + minimal_tag = -int32(1) + num_minimals = num_minimals + 1 + } + _tre_purge_regset(tls, regset, tnfa, tag) + } else { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_tags = int32(1) + } + **(**int32)(__ccgo_up(regset)) = -int32(1) + tag = next_tag + num_tags = num_tags + 1 + next_tag = next_tag + 1 + } + } else { + } + case int32(_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + left = (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft + right = (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright + reserved_tag = -int32(1) + /* After processing right child. */ + status = _tre_stack_push_voidptr(tls, stack, node) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_CAT_RIGHT)) + if status != REG_OK { + break + } + /* Process right child. */ + status = _tre_stack_push_voidptr(tls, stack, right) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + /* After processing left child. */ + status = _tre_stack_push_int(tls, stack, next_tag+(*Ttre_ast_node_t)(unsafe.Pointer(left)).Fnum_tags) + if status != REG_OK { + break + } + if (*Ttre_ast_node_t)(unsafe.Pointer(left)).Fnum_tags > 0 && (*Ttre_ast_node_t)(unsafe.Pointer(right)).Fnum_tags > 0 { + /* Reserve the next tag to the right child. */ + reserved_tag = next_tag + next_tag = next_tag + 1 + } + status = _tre_stack_push_int(tls, stack, reserved_tag) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_CAT_LEFT)) + if status != REG_OK { + break + } + /* Process left child. */ + status = _tre_stack_push_voidptr(tls, stack, left) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + case int32(_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if first_pass != 0 { + status = _tre_stack_push_int(tls, stack, BoolInt32(**(**int32)(__ccgo_up(regset)) >= 0 || int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0)) != 0)) + if status != REG_OK { + break + } + } else { + status = _tre_stack_push_int(tls, stack, tag) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0))) + if status != REG_OK { + break + } + } + status = _tre_stack_push_voidptr(tls, stack, node) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_ITERATION)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + /* Regset is not empty, so add a tag here. */ + if **(**int32)(__ccgo_up(regset)) >= 0 || int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0)) != 0 { + if !(first_pass != 0) { + status = _tre_add_tag_left(tls, mem, node, tag) + if int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0)) != 0 { + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag)*4)) = int32(_TRE_TAG_MAXIMIZE) + } else { + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag)*4)) = direction + } + if minimal_tag >= 0 { + i4 = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i4)*4)) >= 0) { + break + } + goto _17 + _17: + ; + i4 = i4 + 1 + } + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i4)*4)) = tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i4+int32(1))*4)) = minimal_tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i4+int32(2))*4)) = -int32(1) + minimal_tag = -int32(1) + num_minimals = num_minimals + 1 + } + _tre_purge_regset(tls, regset, tnfa, tag) + } + **(**int32)(__ccgo_up(regset)) = -int32(1) + tag = next_tag + num_tags = num_tags + 1 + next_tag = next_tag + 1 + } + direction = int32(_TRE_TAG_MINIMIZE) + case int32(_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + left1 = (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft + right1 = (*Ttre_union_t)(unsafe.Pointer(uni)).Fright + if **(**int32)(__ccgo_up(regset)) >= 0 { + left_tag = next_tag + right_tag = next_tag + int32(1) + } else { + left_tag = tag + right_tag = next_tag + } + /* After processing right child. */ + status = _tre_stack_push_int(tls, stack, right_tag) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, left_tag) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, regset) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, BoolInt32(**(**int32)(__ccgo_up(regset)) >= 0)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, node) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, right1) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, left1) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_UNION_RIGHT)) + if status != REG_OK { + break + } + /* Process right child. */ + status = _tre_stack_push_voidptr(tls, stack, right1) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + /* After processing left child. */ + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_UNION_LEFT)) + if status != REG_OK { + break + } + /* Process left child. */ + status = _tre_stack_push_voidptr(tls, stack, left1) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + /* Regset is not empty, so add a tag here. */ + if **(**int32)(__ccgo_up(regset)) >= 0 { + if !(first_pass != 0) { + status = _tre_add_tag_left(tls, mem, node, tag) + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag)*4)) = direction + if minimal_tag >= 0 { + i5 = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i5)*4)) >= 0) { + break + } + goto _18 + _18: + ; + i5 = i5 + 1 + } + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i5)*4)) = tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i5+int32(1))*4)) = minimal_tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i5+int32(2))*4)) = -int32(1) + minimal_tag = -int32(1) + num_minimals = num_minimals + 1 + } + _tre_purge_regset(tls, regset, tnfa, tag) + } + **(**int32)(__ccgo_up(regset)) = -int32(1) + tag = next_tag + num_tags = num_tags + 1 + next_tag = next_tag + 1 + } + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches > 0 { + /* The next two tags are reserved for markers. */ + next_tag = next_tag + 1 + tag = next_tag + next_tag = next_tag + 1 + } + break + } + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id >= 0 { + /* Push this submatch on the parents stack. */ + i6 = 0 + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(i6)*4)) >= 0) { + break + } + goto _19 + _19: + ; + i6 = i6 + 1 + } + **(**int32)(__ccgo_up(parents + uintptr(i6)*4)) = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id + **(**int32)(__ccgo_up(parents + uintptr(i6+int32(1))*4)) = -int32(1) + } + goto _10 /* end case: ADDTAGS_RECURSE */ + _4: + ; + minimal = 0 + node = _tre_stack_pop_voidptr(tls, stack) + if first_pass != 0 { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_tags = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Farg)).Fnum_tags + _tre_stack_pop_int(tls, stack) + minimal_tag = -int32(1) + } else { + minimal = _tre_stack_pop_int(tls, stack) + enter_tag = _tre_stack_pop_int(tls, stack) + if minimal != 0 { + minimal_tag = enter_tag + } + } + if !(first_pass != 0) { + if minimal != 0 { + direction = int32(_TRE_TAG_MINIMIZE) + } else { + direction = int32(_TRE_TAG_MAXIMIZE) + } + } + goto _10 + _5: + ; + new_tag = _tre_stack_pop_int(tls, stack) + next_tag = _tre_stack_pop_int(tls, stack) + if new_tag >= 0 { + tag = new_tag + } + goto _10 + _6: + ; + node = _tre_stack_pop_voidptr(tls, stack) + if first_pass != 0 { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_tags = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fleft)).Fnum_tags + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fright)).Fnum_tags + } + goto _10 + _7: + ; + /* Lift the bottom of the `regset' array so that when processing + the right operand the items currently in the array are + invisible. The original bottom was saved at ADDTAGS_UNION and + will be restored at ADDTAGS_AFTER_UNION_RIGHT below. */ + _21: + ; + if !(**(**int32)(__ccgo_up(regset)) >= 0) { + goto _20 + } + regset += 4 + goto _21 + _20: + ; + goto _10 + _8: + ; + left2 = _tre_stack_pop_voidptr(tls, stack) + right2 = _tre_stack_pop_voidptr(tls, stack) + node = _tre_stack_pop_voidptr(tls, stack) + added_tags = _tre_stack_pop_int(tls, stack) + if first_pass != 0 { + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches > 0 { + v22 = int32(2) + } else { + v22 = 0 + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_tags = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fleft)).Fnum_tags + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fright)).Fnum_tags + added_tags + v22 + } + regset = _tre_stack_pop_voidptr(tls, stack) + tag_left = _tre_stack_pop_int(tls, stack) + tag_right = _tre_stack_pop_int(tls, stack) + /* Add tags after both children, the left child gets a smaller + tag than the right child. This guarantees that we prefer + the left child over the right child. */ + /* XXX - This is not always necessary (if the children have + tags which must be seen for every match of that child). */ + /* XXX - Check if this is the only place where tre_add_tag_right + is used. If so, use tre_add_tag_left (putting the tag before + the child as opposed after the child) and throw away + tre_add_tag_right. */ + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches > 0 { + if !(first_pass != 0) { + status = _tre_add_tag_right(tls, mem, left2, tag_left) + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag_left)*4)) = int32(_TRE_TAG_MAXIMIZE) + if status == REG_OK { + status = _tre_add_tag_right(tls, mem, right2, tag_right) + } + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag_right)*4)) = int32(_TRE_TAG_MAXIMIZE) + } + num_tags = num_tags + int32(2) + } + direction = int32(_TRE_TAG_MAXIMIZE) + goto _10 + _9: + ; + goto _10 + _10: + /* end switch(symbol) */ + } /* end while(tre_stack_num_objects(stack) > bottom) */ + if !(first_pass != 0) { + _tre_purge_regset(tls, regset, tnfa, tag) + } + if !(first_pass != 0) && minimal_tag >= 0 { + i7 = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i7)*4)) >= 0) { + break + } + goto _23 + _23: + ; + i7 = i7 + 1 + } + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i7)*4)) = tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i7+int32(1))*4)) = minimal_tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i7+int32(2))*4)) = -int32(1) + minimal_tag = -int32(1) + num_minimals = num_minimals + 1 + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fend_tag = num_tags + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags = num_tags + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_minimals = num_minimals + Xfree(tls, orig_regset) + Xfree(tls, parents) + Xfree(tls, saved_states) + return status +} + +/* + AST to TNFA compilation routines. +*/ + +type Ttre_copyast_symbol_t = int32 + +const _COPY_RECURSE = 0 +const _COPY_SET_RESULT_PTR = 1 + +/* Flags for tre_copy_ast(). */ + +func _tre_copy_ast(tls *TLS, mem Ttre_mem_t, stack uintptr, ast uintptr, flags int32, pos_add uintptr, tag_directions uintptr, copy1 uintptr, max_pos uintptr) (r Treg_errcode_t) { + var bottom, first_tag, max, min, num_copied, pos, v1 int32 + var cat, iter, lit, node, p, result, tmp, tmp1, uni uintptr + var status Treg_errcode_t + var symbol Ttre_copyast_symbol_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bottom, cat, first_tag, iter, lit, max, min, node, num_copied, p, pos, result, status, symbol, tmp, tmp1, uni, v1 + status = REG_OK + bottom = _tre_stack_num_objects(tls, stack) + num_copied = 0 + first_tag = int32(1) + result = copy1 + status = _tre_stack_push_voidptr(tls, stack, ast) + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + for status == REG_OK && _tre_stack_num_objects(tls, stack) > bottom { + if status != REG_OK { + break + } + symbol = _tre_stack_pop_int(tls, stack) + switch symbol { + case int32(_COPY_SET_RESULT_PTR): + result = _tre_stack_pop_voidptr(tls, stack) + case int32(_COPY_RECURSE): + node = _tre_stack_pop_voidptr(tls, stack) + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + pos = (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition + min = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min) + max = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max) + if !((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min < Int64FromInt32(0)) || (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(4)) { + /* XXX - e.g. [ab] has only one position but two + nodes, so we are creating holes in the state space + here. Not fatal, just wastes memory. */ + pos = pos + **(**int32)(__ccgo_up(pos_add)) + num_copied = num_copied + 1 + } else { + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(3)) && flags&int32(COPY_REMOVE_TAGS) != 0 { + /* Change this tag to empty. */ + min = -int32(1) + v1 = -Int32FromInt32(1) + pos = v1 + max = v1 + } else { + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(3)) && flags&int32(COPY_MAXIMIZE_FIRST_TAG) != 0 && first_tag != 0 { + /* Maximize the first tag. */ + **(**Ttre_tag_direction_t)(__ccgo_up(tag_directions + uintptr(max)*4)) = int32(_TRE_TAG_MAXIMIZE) + first_tag = 0 + } + } + } + **(**uintptr)(__ccgo_up(result)) = _tre_ast_new_literal(tls, mem, min, max, pos) + if **(**uintptr)(__ccgo_up(result)) == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + } else { + p = (*Ttre_ast_node_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(result)))).Fobj + (*Ttre_literal_t)(unsafe.Pointer(p)).Fclass = (*Ttre_literal_t)(unsafe.Pointer(lit)).Fclass + (*Ttre_literal_t)(unsafe.Pointer(p)).Fneg_classes = (*Ttre_literal_t)(unsafe.Pointer(lit)).Fneg_classes + } + if pos > **(**int32)(__ccgo_up(max_pos)) { + **(**int32)(__ccgo_up(max_pos)) = pos + } + case int32(_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + **(**uintptr)(__ccgo_up(result)) = _tre_ast_new_union(tls, mem, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright) + if **(**uintptr)(__ccgo_up(result)) == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + break + } + tmp = (*Ttre_ast_node_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(result)))).Fobj + result = tmp + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, tmp+8) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_SET_RESULT_PTR)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + case int32(_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + **(**uintptr)(__ccgo_up(result)) = _tre_ast_new_catenation(tls, mem, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright) + if **(**uintptr)(__ccgo_up(result)) == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + break + } + tmp1 = (*Ttre_ast_node_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(result)))).Fobj + (*Ttre_catenation_t)(unsafe.Pointer(tmp1)).Fleft = UintptrFromInt32(0) + (*Ttre_catenation_t)(unsafe.Pointer(tmp1)).Fright = UintptrFromInt32(0) + result = tmp1 + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, tmp1+8) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_SET_RESULT_PTR)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + case int32(_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + **(**uintptr)(__ccgo_up(result)) = _tre_ast_new_iter(tls, mem, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmin, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmax, int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0))) + if **(**uintptr)(__ccgo_up(result)) == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + break + } + iter = (*Ttre_ast_node_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(result)))).Fobj + result = iter + default: + break + } + break + } + } + **(**int32)(__ccgo_up(pos_add)) += num_copied + return status +} + +type Ttre_expand_ast_symbol_t = int32 + +const _EXPAND_RECURSE = 0 +const _EXPAND_AFTER_ITER = 1 + +// C documentation +// +// /* Expands each iteration node that has a finite nonzero minimum or maximum +// iteration count to a catenated sequence of copies of the node. */ +func _tre_expand_ast(tls *TLS, mem Ttre_mem_t, stack uintptr, ast uintptr, position uintptr, tag_directions uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var _status, _status1, status Treg_errcode_t + var bottom, flags, iter_depth, j, pos_add_last, pos_add_save, pos_add_total, v2 int32 + var cat, iter, iter1, lit, node, seq1, tmp, uni uintptr + var symbol Ttre_expand_ast_symbol_t + var _ /* copy at bp+16 */ uintptr + var _ /* copy at bp+24 */ uintptr + var _ /* max_pos at bp+4 */ int32 + var _ /* pos_add at bp+0 */ int32 + var _ /* seq2 at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _status, _status1, bottom, cat, flags, iter, iter1, iter_depth, j, lit, node, pos_add_last, pos_add_save, pos_add_total, seq1, status, symbol, tmp, uni, v2 + status = REG_OK + bottom = _tre_stack_num_objects(tls, stack) + **(**int32)(__ccgo_up(bp)) = 0 + pos_add_total = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + iter_depth = 0 + _status = _tre_stack_push_voidptr(tls, stack, ast) + if _status != REG_OK { + return _status + } + _status1 = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if _status1 != REG_OK { + return _status1 + } + for status == REG_OK && _tre_stack_num_objects(tls, stack) > bottom { + if status != REG_OK { + break + } + symbol = _tre_stack_pop_int(tls, stack) + node = _tre_stack_pop_voidptr(tls, stack) + switch symbol { + case int32(_EXPAND_RECURSE): + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if !((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min < Int64FromInt32(0)) || (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(4)) { + **(**int32)(__ccgo_up(lit + 16)) += **(**int32)(__ccgo_up(bp)) + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition > **(**int32)(__ccgo_up(bp + 4)) { + **(**int32)(__ccgo_up(bp + 4)) = (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition + } + } + case int32(_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + case int32(_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + case int32(_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_int(tls, stack, **(**int32)(__ccgo_up(bp))) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, node) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_AFTER_ITER)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + /* If we are going to expand this node at EXPAND_AFTER_ITER + then don't increase the `pos' fields of the nodes now, it + will get done when expanding. */ + if (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmin > int32(1) || (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmax > int32(1) { + **(**int32)(__ccgo_up(bp)) = 0 + } + iter_depth = iter_depth + 1 + default: + break + } + case int32(_EXPAND_AFTER_ITER): + iter1 = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + **(**int32)(__ccgo_up(bp)) = _tre_stack_pop_int(tls, stack) + pos_add_last = **(**int32)(__ccgo_up(bp)) + if (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmin > int32(1) || (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmax > int32(1) { + seq1 = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(bp + 8)) = UintptrFromInt32(0) + pos_add_save = **(**int32)(__ccgo_up(bp)) + /* Create a catenated sequence of copies of the node. */ + j = 0 + for { + if !(j < (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmin) { + break + } + if j+int32(1) < (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmin { + v2 = int32(COPY_REMOVE_TAGS) + } else { + v2 = int32(COPY_MAXIMIZE_FIRST_TAG) + } + /* Remove tags from all but the last copy. */ + flags = v2 + pos_add_save = **(**int32)(__ccgo_up(bp)) + status = _tre_copy_ast(tls, mem, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Farg, flags, bp, tag_directions, bp+16, bp+4) + if status != REG_OK { + return status + } + if seq1 != UintptrFromInt32(0) { + seq1 = _tre_ast_new_catenation(tls, mem, seq1, **(**uintptr)(__ccgo_up(bp + 16))) + } else { + seq1 = **(**uintptr)(__ccgo_up(bp + 16)) + } + if seq1 == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + goto _1 + _1: + ; + j = j + 1 + } + if (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmax == -int32(1) { + /* No upper limit. */ + pos_add_save = **(**int32)(__ccgo_up(bp)) + status = _tre_copy_ast(tls, mem, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Farg, 0, bp, UintptrFromInt32(0), bp+8, bp+4) + if status != REG_OK { + return status + } + **(**uintptr)(__ccgo_up(bp + 8)) = _tre_ast_new_iter(tls, mem, **(**uintptr)(__ccgo_up(bp + 8)), 0, -int32(1), 0) + if **(**uintptr)(__ccgo_up(bp + 8)) == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + } else { + j = (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmin + for { + if !(j < (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmax) { + break + } + pos_add_save = **(**int32)(__ccgo_up(bp)) + status = _tre_copy_ast(tls, mem, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Farg, 0, bp, UintptrFromInt32(0), bp+24, bp+4) + if status != REG_OK { + return status + } + if **(**uintptr)(__ccgo_up(bp + 8)) != UintptrFromInt32(0) { + **(**uintptr)(__ccgo_up(bp + 8)) = _tre_ast_new_catenation(tls, mem, **(**uintptr)(__ccgo_up(bp + 24)), **(**uintptr)(__ccgo_up(bp + 8))) + } else { + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 24)) + } + if **(**uintptr)(__ccgo_up(bp + 8)) == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + tmp = _tre_ast_new_literal(tls, mem, -int32(1), -int32(1), -int32(1)) + if tmp == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + **(**uintptr)(__ccgo_up(bp + 8)) = _tre_ast_new_union(tls, mem, tmp, **(**uintptr)(__ccgo_up(bp + 8))) + if **(**uintptr)(__ccgo_up(bp + 8)) == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + goto _3 + _3: + ; + j = j + 1 + } + } + **(**int32)(__ccgo_up(bp)) = pos_add_save + if seq1 == UintptrFromInt32(0) { + seq1 = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + if **(**uintptr)(__ccgo_up(bp + 8)) != UintptrFromInt32(0) { + seq1 = _tre_ast_new_catenation(tls, mem, seq1, **(**uintptr)(__ccgo_up(bp + 8))) + } + } + if seq1 == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj = (*Ttre_ast_node_t)(unsafe.Pointer(seq1)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 = (*Ttre_ast_node_t)(unsafe.Pointer(seq1)).Ftype1 + } + iter_depth = iter_depth - 1 + pos_add_total = pos_add_total + (**(**int32)(__ccgo_up(bp)) - pos_add_last) + if iter_depth == 0 { + **(**int32)(__ccgo_up(bp)) = pos_add_total + } + default: + break + } + } + **(**int32)(__ccgo_up(position)) += pos_add_total + /* `max_pos' should never be larger than `*position' if the above + code works, but just an extra safeguard let's make sure + `*position' is set large enough so enough memory will be + allocated for the transition table. */ + if **(**int32)(__ccgo_up(bp + 4)) > **(**int32)(__ccgo_up(position)) { + **(**int32)(__ccgo_up(position)) = **(**int32)(__ccgo_up(bp + 4)) + } + return status +} + +func _tre_set_empty(tls *TLS, mem Ttre_mem_t) (r uintptr) { + var new_set uintptr + _ = new_set + new_set = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(56)) + if new_set == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fposition = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fcode_min = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fcode_max = -int32(1) + return new_set +} + +func _tre_set_one(tls *TLS, mem Ttre_mem_t, position int32, code_min int32, code_max int32, class Ttre_ctype_t, neg_classes uintptr, backref int32) (r uintptr) { + var new_set uintptr + _ = new_set + new_set = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), Uint64FromInt64(56)*Uint64FromInt32(2)) + if new_set == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fposition = position + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fcode_min = code_min + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fcode_max = code_max + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fclass = class + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fneg_classes = neg_classes + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fbackref = backref + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + 1*56))).Fposition = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + 1*56))).Fcode_min = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + 1*56))).Fcode_max = -int32(1) + return new_set +} + +func _tre_set_union(tls *TLS, mem Ttre_mem_t, set1 uintptr, set2 uintptr, tags uintptr, assertions int32) (r uintptr) { + var i, j, num_tags, s1, s2 int32 + var new_set, new_tags uintptr + _, _, _, _, _, _, _ = i, j, new_set, new_tags, num_tags, s1, s2 + num_tags = 0 + for { + if !(tags != UintptrFromInt32(0) && **(**int32)(__ccgo_up(tags + uintptr(num_tags)*4)) >= 0) { + break + } + goto _1 + _1: + ; + num_tags = num_tags + 1 + } + s1 = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fposition >= 0) { + break + } + goto _2 + _2: + ; + s1 = s1 + 1 + } + s2 = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fposition >= 0) { + break + } + goto _3 + _3: + ; + s2 = s2 + 1 + } + new_set = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(56)*Uint64FromInt32(s1+s2+Int32FromInt32(1))) + if !(new_set != 0) { + return UintptrFromInt32(0) + } + s1 = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fposition >= 0) { + break + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fposition = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fposition + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fcode_min = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fcode_min + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fcode_max = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fcode_max + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fassertions = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fassertions | assertions + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fclass = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fclass + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fneg_classes = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fneg_classes + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fbackref = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fbackref + if (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Ftags == UintptrFromInt32(0) && tags == UintptrFromInt32(0) { + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Ftags = UintptrFromInt32(0) + } else { + i = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Ftags != UintptrFromInt32(0) && **(**int32)(__ccgo_up((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Ftags + uintptr(i)*4)) >= 0) { + break + } + goto _5 + _5: + ; + i = i + 1 + } + new_tags = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, Uint64FromInt64(4)*Uint64FromInt32(i+num_tags+Int32FromInt32(1))) + if new_tags == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + j = 0 + for { + if !(j < i) { + break + } + **(**int32)(__ccgo_up(new_tags + uintptr(j)*4)) = **(**int32)(__ccgo_up((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Ftags + uintptr(j)*4)) + goto _6 + _6: + ; + j = j + 1 + } + i = 0 + for { + if !(i < num_tags) { + break + } + **(**int32)(__ccgo_up(new_tags + uintptr(j+i)*4)) = **(**int32)(__ccgo_up(tags + uintptr(i)*4)) + goto _7 + _7: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(new_tags + uintptr(j+i)*4)) = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Ftags = new_tags + } + goto _4 + _4: + ; + s1 = s1 + 1 + } + s2 = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fposition >= 0) { + break + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fposition = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fposition + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fcode_min = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fcode_min + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fcode_max = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fcode_max + /* XXX - why not | assertions here as well? */ + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fassertions = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fassertions + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fclass = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fclass + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fneg_classes = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fneg_classes + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fbackref = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fbackref + if (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Ftags == UintptrFromInt32(0) { + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Ftags = UintptrFromInt32(0) + } else { + i = 0 + for { + if !(**(**int32)(__ccgo_up((**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Ftags + uintptr(i)*4)) >= 0) { + break + } + goto _9 + _9: + ; + i = i + 1 + } + new_tags = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(4)*Uint64FromInt32(i+Int32FromInt32(1))) + if new_tags == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + j = 0 + for { + if !(j < i) { + break + } + **(**int32)(__ccgo_up(new_tags + uintptr(j)*4)) = **(**int32)(__ccgo_up((**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Ftags + uintptr(j)*4)) + goto _10 + _10: + ; + j = j + 1 + } + **(**int32)(__ccgo_up(new_tags + uintptr(j)*4)) = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Ftags = new_tags + } + goto _8 + _8: + ; + s2 = s2 + 1 + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fposition = -int32(1) + return new_set +} + +// C documentation +// +// /* Finds the empty path through `node' which is the one that should be +// taken according to POSIX.2 rules, and adds the tags on that path to +// `tags'. `tags' may be NULL. If `num_tags_seen' is not NULL, it is +// set to the number of tags seen on the path. */ +func _tre_match_empty(tls *TLS, stack uintptr, node uintptr, tags uintptr, assertions uintptr, num_tags_seen uintptr) (r Treg_errcode_t) { + var bottom, i int32 + var cat, iter, lit, uni, v2 uintptr + var status Treg_errcode_t + _, _, _, _, _, _, _, _ = bottom, cat, i, iter, lit, status, uni, v2 + bottom = _tre_stack_num_objects(tls, stack) + status = REG_OK + if num_tags_seen != 0 { + **(**int32)(__ccgo_up(num_tags_seen)) = 0 + } + status = _tre_stack_push_voidptr(tls, stack, node) + /* Walk through the tree recursively. */ + for status == REG_OK && _tre_stack_num_objects(tls, stack) > bottom { + node = _tre_stack_pop_voidptr(tls, stack) + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + switch (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min { + case int64(-int32(3)): + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max >= 0 { + if tags != UintptrFromInt32(0) { + /* Add the tag to `tags'. */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(tags + uintptr(i)*4)) >= 0) { + break + } + if int64(**(**int32)(__ccgo_up(tags + uintptr(i)*4))) == (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if **(**int32)(__ccgo_up(tags + uintptr(i)*4)) < 0 { + **(**int32)(__ccgo_up(tags + uintptr(i)*4)) = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max) + **(**int32)(__ccgo_up(tags + uintptr(i+int32(1))*4)) = -int32(1) + } + } + if num_tags_seen != 0 { + **(**int32)(__ccgo_up(num_tags_seen)) = **(**int32)(__ccgo_up(num_tags_seen)) + 1 + } + } + case int64(-int32(2)): + if assertions != UintptrFromInt32(0) { + v2 = assertions + *(*int32)(unsafe.Pointer(v2)) = int32(int64(*(*int32)(unsafe.Pointer(v2))) | (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max) + } + case int64(-int32(1)): + default: + break + } + case int32(_UNION): + /* Subexpressions starting earlier take priority over ones + starting later, so we prefer the left subexpression over the + right subexpression. */ + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fleft)).Fnullable != 0 { + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft) + if status != REG_OK { + break + } + } else { + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fright)).Fnullable != 0 { + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright) + if status != REG_OK { + break + } + } else { + } + } + case int32(_CATENATION): + /* The path must go through both children. */ + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright) + if status != REG_OK { + break + } + case int32(_ITERATION): + /* A match with an empty string is preferred over no match at + all, so we go through the argument if possible. */ + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Fnullable != 0 { + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg) + if status != REG_OK { + break + } + } + default: + break + } + } + return status +} + +type Ttre_nfl_stack_symbol_t = int32 + +const _NFL_RECURSE = 0 +const _NFL_POST_UNION = 1 +const _NFL_POST_CATENATION = 2 +const _NFL_POST_ITERATION = 3 + +// C documentation +// +// /* Computes and fills in the fields `nullable', `firstpos', and `lastpos' for +// the nodes of the AST `tree'. */ +func _tre_compute_nfl(tls *TLS, mem Ttre_mem_t, stack uintptr, tree uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _status, _status1, _status10, _status11, _status12, _status13, _status14, _status15, _status16, _status17, _status2, _status3, _status4, _status5, _status6, _status7, _status8, _status9, status Treg_errcode_t + var bottom int32 + var cat, iter, lit, node, tags, uni uintptr + var symbol Ttre_nfl_stack_symbol_t + var _ /* assertions at bp+4 */ int32 + var _ /* num_tags at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _status, _status1, _status10, _status11, _status12, _status13, _status14, _status15, _status16, _status17, _status2, _status3, _status4, _status5, _status6, _status7, _status8, _status9, bottom, cat, iter, lit, node, status, symbol, tags, uni + bottom = _tre_stack_num_objects(tls, stack) + _status = _tre_stack_push_voidptr(tls, stack, tree) + if _status != REG_OK { + return _status + } + _status1 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status1 != REG_OK { + return _status1 + } + for _tre_stack_num_objects(tls, stack) > bottom { + symbol = _tre_stack_pop_int(tls, stack) + node = _tre_stack_pop_voidptr(tls, stack) + switch symbol { + case int32(_NFL_RECURSE): + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(4)) { + /* Back references: nullable = false, firstpos = {i}, + lastpos = {i}. */ + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = 0 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_one(tls, mem, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition, 0, int32(TRE_CHAR_MAX), uint64(0), UintptrFromInt32(0), -int32(1)) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_one(tls, mem, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition, 0, int32(TRE_CHAR_MAX), uint64(0), UintptrFromInt32(0), int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max)) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + } else { + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min < 0 { + /* Tags, empty strings, params, and zero width assertions: + nullable = true, firstpos = {}, and lastpos = {}. */ + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_empty(tls, mem) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_empty(tls, mem) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + } else { + /* Literal at position i: nullable = false, firstpos = {i}, + lastpos = {i}. */ + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = 0 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_one(tls, mem, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition, int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min), int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max), uint64(0), UintptrFromInt32(0), -int32(1)) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_one(tls, mem, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition, int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min), int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max), (*Ttre_literal_t)(unsafe.Pointer(lit)).Fclass, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fneg_classes, -int32(1)) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + } + } + case int32(_UNION): + /* Compute the attributes for the two subtrees, and after that + for this node. */ + _status2 = _tre_stack_push_voidptr(tls, stack, node) + if _status2 != REG_OK { + return _status2 + } + _status3 = _tre_stack_push_int(tls, stack, int32(_NFL_POST_UNION)) + if _status3 != REG_OK { + return _status3 + } + _status4 = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fright) + if _status4 != REG_OK { + return _status4 + } + _status5 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status5 != REG_OK { + return _status5 + } + _status6 = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fleft) + if _status6 != REG_OK { + return _status6 + } + _status7 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status7 != REG_OK { + return _status7 + } + case int32(_CATENATION): + /* Compute the attributes for the two subtrees, and after that + for this node. */ + _status8 = _tre_stack_push_voidptr(tls, stack, node) + if _status8 != REG_OK { + return _status8 + } + _status9 = _tre_stack_push_int(tls, stack, int32(_NFL_POST_CATENATION)) + if _status9 != REG_OK { + return _status9 + } + _status10 = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fright) + if _status10 != REG_OK { + return _status10 + } + _status11 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status11 != REG_OK { + return _status11 + } + _status12 = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fleft) + if _status12 != REG_OK { + return _status12 + } + _status13 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status13 != REG_OK { + return _status13 + } + case int32(_ITERATION): + /* Compute the attributes for the subtree, and after that for + this node. */ + _status14 = _tre_stack_push_voidptr(tls, stack, node) + if _status14 != REG_OK { + return _status14 + } + _status15 = _tre_stack_push_int(tls, stack, int32(_NFL_POST_ITERATION)) + if _status15 != REG_OK { + return _status15 + } + _status16 = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Farg) + if _status16 != REG_OK { + return _status16 + } + _status17 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status17 != REG_OK { + return _status17 + } + break + } + case int32(_NFL_POST_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = BoolInt32((*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fleft)).Fnullable != 0 || (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fright)).Fnullable != 0) + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_union(tls, mem, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fleft)).Ffirstpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fright)).Ffirstpos, UintptrFromInt32(0), 0) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_union(tls, mem, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fleft)).Flastpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fright)).Flastpos, UintptrFromInt32(0), 0) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + case int32(_NFL_POST_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmin == 0 || (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Fnullable != 0 { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = int32(1) + } else { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = 0 + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Ffirstpos + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Flastpos + case int32(_NFL_POST_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = BoolInt32((*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Fnullable != 0 && (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Fnullable != 0) + /* Compute firstpos. */ + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Fnullable != 0 { + /* The left side matches the empty string. Make a first pass + with tre_match_empty() to get the number of tags and + parameters. */ + status = _tre_match_empty(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft, UintptrFromInt32(0), UintptrFromInt32(0), bp) + if status != REG_OK { + return status + } + /* Allocate arrays for the tags and parameters. */ + tags = Xmalloc(tls, uint64(4)*Uint64FromInt32(**(**int32)(__ccgo_up(bp))+Int32FromInt32(1))) + if !(tags != 0) { + return int32(REG_ESPACE) + } + **(**int32)(__ccgo_up(tags)) = -int32(1) + **(**int32)(__ccgo_up(bp + 4)) = 0 + /* Second pass with tre_mach_empty() to get the list of + tags and parameters. */ + status = _tre_match_empty(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft, tags, bp+4, UintptrFromInt32(0)) + if status != REG_OK { + Xfree(tls, tags) + return status + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_union(tls, mem, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Ffirstpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Ffirstpos, tags, **(**int32)(__ccgo_up(bp + 4))) + Xfree(tls, tags) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + } else { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Ffirstpos + } + /* Compute lastpos. */ + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Fnullable != 0 { + /* The right side matches the empty string. Make a first pass + with tre_match_empty() to get the number of tags and + parameters. */ + status = _tre_match_empty(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright, UintptrFromInt32(0), UintptrFromInt32(0), bp) + if status != REG_OK { + return status + } + /* Allocate arrays for the tags and parameters. */ + tags = Xmalloc(tls, uint64(4)*Uint64FromInt32(**(**int32)(__ccgo_up(bp))+Int32FromInt32(1))) + if !(tags != 0) { + return int32(REG_ESPACE) + } + **(**int32)(__ccgo_up(tags)) = -int32(1) + **(**int32)(__ccgo_up(bp + 4)) = 0 + /* Second pass with tre_mach_empty() to get the list of + tags and parameters. */ + status = _tre_match_empty(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright, tags, bp+4, UintptrFromInt32(0)) + if status != REG_OK { + Xfree(tls, tags) + return status + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_union(tls, mem, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Flastpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Flastpos, tags, **(**int32)(__ccgo_up(bp + 4))) + Xfree(tls, tags) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + } else { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Flastpos + } + default: + break + } + } + return REG_OK +} + +// C documentation +// +// /* Adds a transition from each position in `p1' to each position in `p2'. */ +func _tre_make_trans(tls *TLS, p1 uintptr, p2 uintptr, transitions uintptr, counts uintptr, offs uintptr) (r Treg_errcode_t) { + var dup, i, j, k, l, prev_p2_pos, v1, v2 int32 + var orig_p2, trans uintptr + _, _, _, _, _, _, _, _, _, _ = dup, i, j, k, l, orig_p2, prev_p2_pos, trans, v1, v2 + orig_p2 = p2 + if transitions != UintptrFromInt32(0) { + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition >= 0 { + p2 = orig_p2 + prev_p2_pos = -int32(1) + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition >= 0 { + /* Optimization: if this position was already handled, skip it. */ + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition == prev_p2_pos { + p2 += 56 + continue + } + prev_p2_pos = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition + /* Set `trans' to point to the next unused transition from + position `p1->position'. */ + trans = transitions + uintptr(**(**int32)(__ccgo_up(offs + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition)*4)))*56 + for (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate != UintptrFromInt32(0) { + trans += 56 + } + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate == UintptrFromInt32(0) { + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans + UintptrFromInt32(1)*56)).Fstate = UintptrFromInt32(0) + } + /* Use the character ranges, assertions, etc. from `p1' for + the transition from `p1' to `p2'. */ + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fcode_min = Uint32FromInt32((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fcode_min) + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fcode_max = Uint32FromInt32((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fcode_max) + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate = transitions + uintptr(**(**int32)(__ccgo_up(offs + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition)*4)))*56 + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate_id = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fclass != 0 { + v1 = int32(ASSERT_CHAR_CLASS) + } else { + v1 = 0 + } + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes != UintptrFromInt32(0) { + v2 = int32(ASSERT_CHAR_CLASS_NEG) + } else { + v2 = 0 + } + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fassertions = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fassertions | (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fassertions | v1 | v2 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fbackref >= 0 { + *(*int32)(unsafe.Pointer(&(*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fu)) = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fbackref + **(**int32)(__ccgo_up(trans + 32)) |= int32(ASSERT_BACKREF) + } else { + *(*Ttre_ctype_t)(unsafe.Pointer(trans + 40)) = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fclass + } + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes != UintptrFromInt32(0) { + i = 0 + for { + if !(**(**Ttre_ctype_t)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes + uintptr(i)*8)) != Uint64FromInt32(0)) { + break + } + goto _3 + _3: + ; + i = i + 1 + } + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes = Xmalloc(tls, uint64(8)*Uint64FromInt32(i+Int32FromInt32(1))) + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + i = 0 + for { + if !(**(**Ttre_ctype_t)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes + uintptr(i)*8)) != Uint64FromInt32(0)) { + break + } + **(**Ttre_ctype_t)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes + uintptr(i)*8)) = **(**Ttre_ctype_t)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes + uintptr(i)*8)) + goto _4 + _4: + ; + i = i + 1 + } + **(**Ttre_ctype_t)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes + uintptr(i)*8)) = Uint64FromInt32(0) + } else { + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes = UintptrFromInt32(0) + } + /* Find out how many tags this transition has. */ + i = 0 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags + uintptr(i)*4)) >= 0 { + i = i + 1 + } + } + j = 0 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags + uintptr(j)*4)) >= 0 { + j = j + 1 + } + } + /* If we are overwriting a transition, free the old tag array. */ + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags != UintptrFromInt32(0) { + Xfree(tls, (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags) + } + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags = UintptrFromInt32(0) + /* If there were any tags, allocate an array and fill it. */ + if i+j > 0 { + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags = Xmalloc(tls, uint64(4)*Uint64FromInt32(i+j+Int32FromInt32(1))) + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags != 0) { + return int32(REG_ESPACE) + } + i = 0 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags + uintptr(i)*4)) >= 0 { + **(**int32)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags + uintptr(i)*4)) = **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags + uintptr(i)*4)) + i = i + 1 + } + } + l = i + j = 0 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags + uintptr(j)*4)) >= 0 { + /* Don't add duplicates. */ + dup = 0 + k = 0 + for { + if !(k < i) { + break + } + if **(**int32)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags + uintptr(k)*4)) == **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags + uintptr(j)*4)) { + dup = int32(1) + break + } + goto _5 + _5: + ; + k = k + 1 + } + if !(dup != 0) { + v1 = l + l = l + 1 + **(**int32)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags + uintptr(v1)*4)) = **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags + uintptr(j)*4)) + } + j = j + 1 + } + } + **(**int32)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags + uintptr(l)*4)) = -int32(1) + } + p2 += 56 + } + p1 += 56 + } + } else { + /* Compute a maximum limit for the number of transitions leaving + from each state. */ + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition >= 0 { + p2 = orig_p2 + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition >= 0 { + **(**int32)(__ccgo_up(counts + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition)*4)) = **(**int32)(__ccgo_up(counts + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition)*4)) + 1 + p2 += 56 + } + p1 += 56 + } + } + return REG_OK +} + +// C documentation +// +// /* Converts the syntax tree to a TNFA. All the transitions in the TNFA are +// labelled with one character range (there are no transitions on empty +// strings). The TNFA takes O(n^2) space in the worst case, `n' is size of +// the regexp. */ +func _tre_ast_to_tnfa(tls *TLS, node uintptr, transitions uintptr, counts uintptr, offs uintptr) (r Treg_errcode_t) { + var cat, iter, uni uintptr + var errcode Treg_errcode_t + _, _, _, _ = cat, errcode, iter, uni + errcode = REG_OK + /* XXX - recurse using a stack!. */ + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + case int32(_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + errcode = _tre_ast_to_tnfa(tls, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft, transitions, counts, offs) + if errcode != REG_OK { + return errcode + } + errcode = _tre_ast_to_tnfa(tls, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright, transitions, counts, offs) + case int32(_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + /* Add a transition from each position in cat->left->lastpos + to each position in cat->right->firstpos. */ + errcode = _tre_make_trans(tls, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Flastpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Ffirstpos, transitions, counts, offs) + if errcode != REG_OK { + return errcode + } + errcode = _tre_ast_to_tnfa(tls, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft, transitions, counts, offs) + if errcode != REG_OK { + return errcode + } + errcode = _tre_ast_to_tnfa(tls, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright, transitions, counts, offs) + case int32(_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmax == -int32(1) { + /* Add a transition from each last position in the iterated + expression to each first position. */ + errcode = _tre_make_trans(tls, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Flastpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Ffirstpos, transitions, counts, offs) + if errcode != REG_OK { + return errcode + } + } + errcode = _tre_ast_to_tnfa(tls, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg, transitions, counts, offs) + break + } + return errcode +} + +func Xregcomp(tls *TLS, preg uintptr, regex uintptr, cflags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v preg=%v regex=%v cflags=%v, (%v:)", tls, preg, regex, cflags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var add, i, j, v1 int32 + var counts, initial, offs, p, stack, submatch_data, tag_directions, tmp_ast_l, tmp_ast_r, tnfa, transitions, tree, v2 uintptr + var errcode Treg_errcode_t + var mem Ttre_mem_t + var _ /* parse_ctx at bp+0 */ Ttre_parse_ctx_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = add, counts, errcode, i, initial, j, mem, offs, p, stack, submatch_data, tag_directions, tmp_ast_l, tmp_ast_r, tnfa, transitions, tree, v1, v2 + counts = UintptrFromInt32(0) + offs = UintptrFromInt32(0) + add = 0 + tnfa = UintptrFromInt32(0) + tag_directions = UintptrFromInt32(0) + /* Allocate a stack used throughout the compilation process for various + purposes. */ + stack = _tre_stack_new(tls, int32(512), int32(1024000), int32(128)) + if !(stack != 0) { + return int32(REG_ESPACE) + } + /* Allocate a fast memory allocator. */ + mem = X__tre_mem_new_impl(tls, 0, UintptrFromInt32(0)) + if !(mem != 0) { + _tre_stack_destroy(tls, stack) + return int32(REG_ESPACE) + } + /* Parse the regexp. */ + Xmemset(tls, bp, 0, uint64(56)) + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fmem = mem + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fstack = stack + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fstart = regex + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fcflags = cflags + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fmax_backref = -int32(1) + errcode = _tre_parse(tls, bp) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + (*Tregex_t)(unsafe.Pointer(preg)).Fre_nsub = Uint64FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fsubmatch_id - int32(1)) + tree = (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fn + /* Referring to nonexistent subexpressions is illegal. */ + if (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fmax_backref > Int32FromUint64((*Tregex_t)(unsafe.Pointer(preg)).Fre_nsub) { + errcode = int32(REG_ESUBREG) + if int32(1) != 0 { + goto error_exit + } + } + /* Allocate the TNFA struct. */ + tnfa = Xcalloc(tls, uint64(1), uint64(104)) + if tnfa == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fhave_backrefs = BoolInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fmax_backref >= 0) + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fhave_approx = 0 + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches = Uint32FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fsubmatch_id) + /* Set up tags for submatch addressing. If REG_NOSUB is set and the + regexp does not have back references, this can be skipped. */ + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fhave_backrefs != 0 || !(cflags&Int32FromInt32(REG_NOSUB) != 0) { + /* Figure out how many tags we will need. */ + errcode = _tre_add_tags(tls, UintptrFromInt32(0), stack, tree, tnfa) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags > 0 { + tag_directions = Xmalloc(tls, uint64(4)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags+Int32FromInt32(1))) + if tag_directions == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions = tag_directions + Xmemset(tls, tag_directions, -int32(1), uint64(4)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags+Int32FromInt32(1))) + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags = Xcalloc(tls, uint64(Uint32FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)*uint32(2)+uint32(1)), uint64(4)) + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + submatch_data = Xcalloc(tls, uint64(Uint32FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fsubmatch_id)), uint64(16)) + if submatch_data == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data = submatch_data + errcode = _tre_add_tags(tls, mem, stack, tree, tnfa) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + } + /* Expand iteration nodes. */ + errcode = _tre_expand_ast(tls, mem, stack, tree, bp+44, tag_directions) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + /* Add a dummy node for the final state. + XXX - For certain patterns this dummy node can be optimized away, + for example "a*" or "ab*". Figure out a simple way to detect + this possibility. */ + tmp_ast_l = tree + v2 = bp + 44 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + tmp_ast_r = _tre_ast_new_literal(tls, mem, 0, 0, v1) + if tmp_ast_r == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + tree = _tre_ast_new_catenation(tls, mem, tmp_ast_l, tmp_ast_r) + if tree == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + errcode = _tre_compute_nfl(tls, mem, stack, tree) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + counts = Xmalloc(tls, uint64(4)*Uint64FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition)) + if counts == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + offs = Xmalloc(tls, uint64(4)*Uint64FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition)) + if offs == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + i = 0 + for { + if !(i < (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition) { + break + } + **(**int32)(__ccgo_up(counts + uintptr(i)*4)) = 0 + goto _3 + _3: + ; + i = i + 1 + } + _tre_ast_to_tnfa(tls, tree, UintptrFromInt32(0), counts, UintptrFromInt32(0)) + add = 0 + i = 0 + for { + if !(i < (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition) { + break + } + **(**int32)(__ccgo_up(offs + uintptr(i)*4)) = add + add = add + (**(**int32)(__ccgo_up(counts + uintptr(i)*4)) + int32(1)) + **(**int32)(__ccgo_up(counts + uintptr(i)*4)) = 0 + goto _4 + _4: + ; + i = i + 1 + } + transitions = Xcalloc(tls, uint64(Uint32FromInt32(add)+uint32(1)), uint64(56)) + if transitions == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions = transitions + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_transitions = Uint32FromInt32(add) + errcode = _tre_ast_to_tnfa(tls, tree, transitions, counts, offs) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffirstpos_chars = UintptrFromInt32(0) + p = (*Ttre_ast_node_t)(unsafe.Pointer(tree)).Ffirstpos + i = 0 + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fposition >= 0 { + i = i + 1 + p += 56 + } + initial = Xcalloc(tls, uint64(Uint32FromInt32(i)+uint32(1)), uint64(56)) + if initial == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial = initial + i = 0 + p = (*Ttre_ast_node_t)(unsafe.Pointer(tree)).Ffirstpos + for { + if !((*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fposition >= 0) { + break + } + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Fstate = transitions + uintptr(**(**int32)(__ccgo_up(offs + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fposition)*4)))*56 + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Fstate_id = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fposition + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Ftags = UintptrFromInt32(0) + /* Copy the arrays p->tags, and p->params, they are allocated + from a tre_mem object. */ + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Ftags != 0 { + j = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Ftags + uintptr(j)*4)) >= 0) { + break + } + goto _6 + _6: + ; + j = j + 1 + } + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Ftags = Xmalloc(tls, uint64(4)*Uint64FromInt32(j+Int32FromInt32(1))) + if !((**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Ftags != 0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + Xmemcpy(tls, (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Ftags, (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Ftags, uint64(4)*Uint64FromInt32(j+Int32FromInt32(1))) + } + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Fassertions = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fassertions + i = i + 1 + goto _5 + _5: + ; + p += 56 + } + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Fstate = UintptrFromInt32(0) + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_transitions = Uint32FromInt32(add) + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal = transitions + uintptr(**(**int32)(__ccgo_up(offs + uintptr((**(**Ttre_pos_and_tags_t)(__ccgo_up((*Ttre_ast_node_t)(unsafe.Pointer(tree)).Flastpos))).Fposition)*4)))*56 + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states = (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags = cflags + X__tre_mem_destroy(tls, mem) + _tre_stack_destroy(tls, stack) + Xfree(tls, counts) + Xfree(tls, offs) + (*Tregex_t)(unsafe.Pointer(preg)).F__opaque = tnfa + return REG_OK + goto error_exit +error_exit: + ; + /* Free everything that was allocated and return the error code. */ + X__tre_mem_destroy(tls, mem) + if stack != UintptrFromInt32(0) { + _tre_stack_destroy(tls, stack) + } + if counts != UintptrFromInt32(0) { + Xfree(tls, counts) + } + if offs != UintptrFromInt32(0) { + Xfree(tls, offs) + } + (*Tregex_t)(unsafe.Pointer(preg)).F__opaque = tnfa + Xregfree(tls, preg) + return errcode +} + +func Xregfree(tls *TLS, preg uintptr) { + if __ccgo_strace { + trc("tls=%v preg=%v, (%v:)", tls, preg, origin(2)) + } + var i uint32 + var tnfa, trans uintptr + _, _, _ = i, tnfa, trans + tnfa = (*Tregex_t)(unsafe.Pointer(preg)).F__opaque + if !(tnfa != 0) { + return + } + i = uint32(0) + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_transitions) { + break + } + if (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Fstate != 0 { + if (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Ftags != 0 { + Xfree(tls, (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Ftags) + } + if (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Fneg_classes != 0 { + Xfree(tls, (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Fneg_classes) + } + } + goto _1 + _1: + ; + i = i + 1 + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions != 0 { + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial != 0 { + trans = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial + for { + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate != 0) { + break + } + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags != 0 { + Xfree(tls, (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags) + } + goto _2 + _2: + ; + trans += 56 + } + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data != 0 { + i = uint32(0) + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches) { + break + } + if (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(i)*16))).Fparents != 0 { + Xfree(tls, (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(i)*16))).Fparents) + } + goto _3 + _3: + ; + i = i + 1 + } + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions != 0 { + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffirstpos_chars != 0 { + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffirstpos_chars) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags != 0 { + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags) + } + Xfree(tls, tnfa) +} + +/* Error message strings for error codes listed in `regex.h'. This list + needs to be in sync with the codes listed there, naturally. */ + +/* Converted to single string by Rich Felker to remove the need for + * data relocations at runtime, 27 Feb 2006. */ + +var _messages = [286]int8{'N', 'o', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'N', 'o', ' ', 'm', 'a', 't', 'c', 'h', 0, 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'r', 'e', 'g', 'e', 'x', 'p', 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'c', 'o', 'l', 'l', 'a', 't', 'i', 'n', 'g', ' ', 'e', 'l', 'e', 'm', 'e', 'n', 't', 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'c', 'h', 'a', 'r', 'a', 'c', 't', 'e', 'r', ' ', 'c', 'l', 'a', 's', 's', ' ', 'n', 'a', 'm', 'e', 0, 'T', 'r', 'a', 'i', 'l', 'i', 'n', 'g', ' ', 'b', 'a', 'c', 'k', 's', 'l', 'a', 's', 'h', 0, 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'b', 'a', 'c', 'k', ' ', 'r', 'e', 'f', 'e', 'r', 'e', 'n', 'c', 'e', 0, 'M', 'i', 's', 's', 'i', 'n', 'g', ' ', '\'', ']', '\'', 0, 'M', 'i', 's', 's', 'i', 'n', 'g', ' ', '\'', ')', '\'', 0, 'M', 'i', 's', 's', 'i', 'n', 'g', ' ', '\'', '}', '\'', 0, 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'c', 'o', 'n', 't', 'e', 'n', 't', 's', ' ', 'o', 'f', ' ', '{', '}', 0, 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'c', 'h', 'a', 'r', 'a', 'c', 't', 'e', 'r', ' ', 'r', 'a', 'n', 'g', 'e', 0, 'O', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0, 'R', 'e', 'p', 'e', 't', 'i', 't', 'i', 'o', 'n', ' ', 'n', 'o', 't', ' ', 'p', 'r', 'e', 'c', 'e', 'd', 'e', 'd', ' ', 'b', 'y', ' ', 'v', 'a', 'l', 'i', 'd', ' ', 'e', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', 0, 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r'} + +func Xregerror(tls *TLS, e int32, preg uintptr, buf uintptr, size Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v e=%v preg=%v buf=%v size=%v, (%v:)", tls, e, preg, buf, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var s uintptr + _ = s + s = uintptr(unsafe.Pointer(&_messages)) + for { + if !(e != 0 && **(**int8)(__ccgo_up(s)) != 0) { + break + } + goto _1 + _1: + ; + e = e - 1 + s = s + uintptr(_strlen(tls, s)+uint64(1)) + } + if !(**(**int8)(__ccgo_up(s)) != 0) { + s = s + 1 + } + s = X__lctrans_cur(tls, s) + return Uint64FromInt32(int32(1) + Xsnprintf(tls, buf, size, __ccgo_ts+15, VaList(bp+8, s))) +} + +const tre_bt_mem_alloc = 0 +const tre_bt_mem_destroy = 0 +const tre_bt_mem_new = 0 + +/*********************************************************************** + from tre-match-utils.h +***********************************************************************/ + +// C documentation +// +// /* Returns 1 if `t1' wins `t2', 0 otherwise. */ +func _tre_tag_order(tls *TLS, num_tags int32, tag_directions uintptr, t1 uintptr, t2 uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < num_tags) { + break + } + if **(**Ttre_tag_direction_t)(__ccgo_up(tag_directions + uintptr(i)*4)) == int32(_TRE_TAG_MINIMIZE) { + if **(**Tregoff_t)(__ccgo_up(t1 + uintptr(i)*8)) < **(**Tregoff_t)(__ccgo_up(t2 + uintptr(i)*8)) { + return int32(1) + } + if **(**Tregoff_t)(__ccgo_up(t1 + uintptr(i)*8)) > **(**Tregoff_t)(__ccgo_up(t2 + uintptr(i)*8)) { + return 0 + } + } else { + if **(**Tregoff_t)(__ccgo_up(t1 + uintptr(i)*8)) > **(**Tregoff_t)(__ccgo_up(t2 + uintptr(i)*8)) { + return int32(1) + } + if **(**Tregoff_t)(__ccgo_up(t1 + uintptr(i)*8)) < **(**Tregoff_t)(__ccgo_up(t2 + uintptr(i)*8)) { + return 0 + } + } + goto _1 + _1: + ; + i = i + 1 + } + /* assert(0);*/ + return 0 +} + +func _tre_neg_char_classes_match(tls *TLS, classes uintptr, wc Ttre_cint_t, icase int32) (r int32) { + for **(**Ttre_ctype_t)(__ccgo_up(classes)) != Uint64FromInt32(0) { + if !(icase != 0) && Xiswctype(tls, wc, **(**Ttre_ctype_t)(__ccgo_up(classes))) != 0 || icase != 0 && (Xiswctype(tls, Xtowupper(tls, wc), **(**Ttre_ctype_t)(__ccgo_up(classes))) != 0 || Xiswctype(tls, Xtowlower(tls, wc), **(**Ttre_ctype_t)(__ccgo_up(classes))) != 0) { + return int32(1) + } else { + classes += 8 + } + } + return 0 /* No match. */ +} + +/*********************************************************************** + from tre-match-parallel.c +***********************************************************************/ + +/* + This algorithm searches for matches basically by reading characters + in the searched string one by one, starting at the beginning. All + matching paths in the TNFA are traversed in parallel. When two or + more paths reach the same state, exactly one is chosen according to + tag ordering rules; if returning submatches is not required it does + not matter which path is chosen. + + The worst case time required for finding the leftmost and longest + match, or determining that there is no match, is always linearly + dependent on the length of the text being searched. + + This algorithm cannot handle TNFAs with back referencing nodes. + See `tre-match-backtrack.c'. +*/ + +type Ttre_tnfa_reach_t = struct { + Fstate uintptr + Ftags uintptr +} + +type Ttre_reach_pos_t = struct { + Fpos Tregoff_t + Ftags uintptr +} + +func _tre_tnfa_run_parallel(tls *TLS, tnfa uintptr, string1 uintptr, match_tags uintptr, eflags int32, match_end_ofs uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var buf, reach, reach_i, reach_next, reach_next_i, reach_pos, str_byte, tag_i, tmp_buf, tmp_iptr, tmp_tags, trans_i uintptr + var end, i, new_match, num_tags, reg_newline, reg_notbol, reg_noteol, skip, start, v18 int32 + var match_eo, pos, pos_add_next, v7 Tregoff_t + var pbytes, rbytes, tbytes, total_bytes, xbytes Tsize_t + var prev_c Ttre_char_t + var ret Treg_errcode_t + var v1 uint64 + var _ /* next_c at bp+0 */ Ttre_char_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = buf, end, i, match_eo, new_match, num_tags, pbytes, pos, pos_add_next, prev_c, rbytes, reach, reach_i, reach_next, reach_next_i, reach_pos, reg_newline, reg_notbol, reg_noteol, ret, skip, start, str_byte, tag_i, tbytes, tmp_buf, tmp_iptr, tmp_tags, total_bytes, trans_i, xbytes, v1, v18, v7 + /* State variables required by GET_NEXT_WCHAR. */ + prev_c = 0 + **(**Ttre_char_t)(__ccgo_up(bp)) = 0 + str_byte = string1 + pos = int64(-int32(1)) + pos_add_next = int64(1) + reg_notbol = eflags & int32(REG_NOTBOL) + reg_noteol = eflags & int32(REG_NOTEOL) + reg_newline = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags & int32(REG_NEWLINE) + match_eo = int64(-int32(1)) /* end offset of match (-1 if no match found yet) */ + new_match = 0 + tmp_tags = UintptrFromInt32(0) + if !(match_tags != 0) { + num_tags = 0 + } else { + num_tags = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags + } + /* Allocate memory for temporary data required for matching. This needs to + be done for every matching operation to be thread safe. This allocates + everything in a single large block with calloc(). */ + /* Ensure that tbytes and xbytes*num_states cannot overflow, and that + * they don't contribute more than 1/8 of SIZE_MAX to total_bytes. */ + if Uint64FromInt32(num_tags) > uint64(0xffffffffffffffff)/(Uint64FromInt32(8)*Uint64FromInt64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states)) { + return int32(REG_ESPACE) + } + /* Likewise check rbytes. */ + if Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states+int32(1)) > Uint64FromUint64(0xffffffffffffffff)/(Uint64FromInt32(8)*Uint64FromInt64(16)) { + return int32(REG_ESPACE) + } + /* Likewise check pbytes. */ + if Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) > Uint64FromUint64(0xffffffffffffffff)/(Uint64FromInt32(8)*Uint64FromInt64(16)) { + return int32(REG_ESPACE) + } + /* Compute the length of the block we need. */ + tbytes = uint64(8) * Uint64FromInt32(num_tags) + rbytes = uint64(16) * Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states+Int32FromInt32(1)) + pbytes = uint64(16) * Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) + xbytes = uint64(8) * Uint64FromInt32(num_tags) + total_bytes = (Uint64FromInt64(8)-Uint64FromInt32(1))*Uint64FromInt32(4) + (rbytes+xbytes*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states))*uint64(2) + tbytes + pbytes + /* Allocate the memory. */ + buf = Xcalloc(tls, total_bytes, uint64(1)) + if buf == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + /* Get the various pointers within tmp_buf (properly aligned). */ + tmp_tags = buf + tmp_buf = buf + uintptr(tbytes) + if Uint64FromInt64(int64(tmp_buf))%uint64(8) != 0 { + v1 = uint64(8) - Uint64FromInt64(int64(tmp_buf))%uint64(8) + } else { + v1 = uint64(0) + } + tmp_buf = tmp_buf + uintptr(v1) + reach_next = tmp_buf + tmp_buf = tmp_buf + uintptr(rbytes) + if Uint64FromInt64(int64(tmp_buf))%uint64(8) != 0 { + v1 = uint64(8) - Uint64FromInt64(int64(tmp_buf))%uint64(8) + } else { + v1 = uint64(0) + } + tmp_buf = tmp_buf + uintptr(v1) + reach = tmp_buf + tmp_buf = tmp_buf + uintptr(rbytes) + if Uint64FromInt64(int64(tmp_buf))%uint64(8) != 0 { + v1 = uint64(8) - Uint64FromInt64(int64(tmp_buf))%uint64(8) + } else { + v1 = uint64(0) + } + tmp_buf = tmp_buf + uintptr(v1) + reach_pos = tmp_buf + tmp_buf = tmp_buf + uintptr(pbytes) + if Uint64FromInt64(int64(tmp_buf))%uint64(8) != 0 { + v1 = uint64(8) - Uint64FromInt64(int64(tmp_buf))%uint64(8) + } else { + v1 = uint64(0) + } + tmp_buf = tmp_buf + uintptr(v1) + i = 0 + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) { + break + } + (**(**Ttre_tnfa_reach_t)(__ccgo_up(reach + uintptr(i)*16))).Ftags = tmp_buf + tmp_buf = tmp_buf + uintptr(xbytes) + (**(**Ttre_tnfa_reach_t)(__ccgo_up(reach_next + uintptr(i)*16))).Ftags = tmp_buf + tmp_buf = tmp_buf + uintptr(xbytes) + goto _5 + _5: + ; + i = i + 1 + } + i = 0 + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) { + break + } + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr(i)*16))).Fpos = int64(-int32(1)) + goto _6 + _6: + ; + i = i + 1 + } + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v7 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v7 + if v7 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + pos = 0 + reach_next_i = reach_next + for int32(1) != 0 { + /* If no match found yet, add the initial states to `reach_next'. */ + if match_eo < 0 { + trans_i = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial + for (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != UintptrFromInt32(0) { + if (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Fpos < pos { + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions != 0 && ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOL) != 0 && (pos > 0 || reg_notbol != 0) && (prev_c != int32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOL) != 0 && (**(**Ttre_char_t)(__ccgo_up(bp)) != int32('\000') || reg_noteol != 0) && (**(**Ttre_char_t)(__ccgo_up(bp)) != int32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOW) != 0 && (prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0 || !(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOW) != 0 && (!(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) || (**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB) != 0 && (pos != 0 && **(**Ttre_char_t)(__ccgo_up(bp)) != int32('\000') && BoolInt32(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) == BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB_NEG) != 0 && (pos == 0 || **(**Ttre_char_t)(__ccgo_up(bp)) == int32('\000') || BoolInt32(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) != BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0))) { + trans_i += 56 + continue + } + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + uintptr(i)*8)) = int64(-int32(1)) + goto _8 + _8: + ; + i = i + 1 + } + tag_i = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + if tag_i != 0 { + for **(**int32)(__ccgo_up(tag_i)) >= 0 { + if **(**int32)(__ccgo_up(tag_i)) < num_tags { + **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + uintptr(**(**int32)(__ccgo_up(tag_i)))*8)) = pos + } + tag_i += 4 + } + } + if (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal { + match_eo = pos + new_match = int32(1) + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i)*8)) = **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + uintptr(i)*8)) + goto _9 + _9: + ; + i = i + 1 + } + } + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Fpos = pos + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags = reach_next_i + 8 + reach_next_i += 16 + } + trans_i += 56 + } + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = UintptrFromInt32(0) + } else { + if num_tags == 0 || reach_next_i == reach_next { + /* We have found a match. */ + break + } + } + /* Check for end of string. */ + if !(**(**Ttre_char_t)(__ccgo_up(bp)) != 0) { + break + } + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v7 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v7 + if v7 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + /* Swap `reach' and `reach_next'. */ + reach_i = reach + reach = reach_next + reach_next = reach_i + /* For each state in `reach', weed out states that don't fulfill the + minimal matching conditions. */ + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_minimals != 0 && new_match != 0 { + new_match = 0 + reach_next_i = reach_next + reach_i = reach + for { + if !((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Fstate != 0) { + break + } + skip = 0 + i = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i)*4)) >= 0) { + break + } + end = **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i)*4)) + start = **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i+int32(1))*4)) + if end >= num_tags { + skip = int32(1) + break + } else { + if **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags + uintptr(start)*8)) == **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(start)*8)) && **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags + uintptr(end)*8)) < **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(end)*8)) { + skip = int32(1) + break + } + } + goto _12 + _12: + ; + i = i + int32(2) + } + if !(skip != 0) { + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Fstate + tmp_iptr = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags = tmp_iptr + reach_next_i += 16 + } + goto _11 + _11: + ; + reach_i += 16 + } + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = UintptrFromInt32(0) + /* Swap `reach' and `reach_next'. */ + reach_i = reach + reach = reach_next + reach_next = reach_i + } + /* For each state in `reach' see if there is a transition leaving with + the current input symbol to a state not yet in `reach_next', and + add the destination states to `reach_next'. */ + reach_next_i = reach_next + reach_i = reach + for { + if !((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Fstate != 0) { + break + } + trans_i = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Fstate + for { + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != 0) { + break + } + /* Does this transition match the input symbol? */ + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fcode_min <= Uint32FromInt32(prev_c) && (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fcode_max >= Uint32FromInt32(prev_c) { + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions != 0 && ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOL) != 0 && (pos > 0 || reg_notbol != 0) && (prev_c != int32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOL) != 0 && (**(**Ttre_char_t)(__ccgo_up(bp)) != int32('\000') || reg_noteol != 0) && (**(**Ttre_char_t)(__ccgo_up(bp)) != int32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOW) != 0 && (prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0 || !(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOW) != 0 && (!(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) || (**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB) != 0 && (pos != 0 && **(**Ttre_char_t)(__ccgo_up(bp)) != int32('\000') && BoolInt32(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) == BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB_NEG) != 0 && (pos == 0 || **(**Ttre_char_t)(__ccgo_up(bp)) == int32('\000') || BoolInt32(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) != BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS) != 0 && !((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&Int32FromInt32(REG_ICASE) != 0) && !(Xiswctype(tls, Uint32FromInt32(prev_c), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS) != 0 && (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_ICASE) != 0 && !(Xiswctype(tls, Xtowlower(tls, Uint32FromInt32(prev_c)), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) && !(Xiswctype(tls, Xtowupper(tls, Uint32FromInt32(prev_c)), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS_NEG) != 0 && _tre_neg_char_classes_match(tls, (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fneg_classes, Uint32FromInt32(prev_c), (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_ICASE)) != 0)) { + goto _14 + } + /* Compute the tags after this transition. */ + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(tmp_tags + uintptr(i)*8)) = **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags + uintptr(i)*8)) + goto _15 + _15: + ; + i = i + 1 + } + tag_i = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + if tag_i != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up(tag_i)) >= 0 { + if **(**int32)(__ccgo_up(tag_i)) < num_tags { + **(**Tregoff_t)(__ccgo_up(tmp_tags + uintptr(**(**int32)(__ccgo_up(tag_i)))*8)) = pos + } + tag_i += 4 + } + } + if (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Fpos < pos { + /* Found an unvisited node. */ + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + tmp_iptr = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags = tmp_tags + tmp_tags = tmp_iptr + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Fpos = pos + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags = reach_next_i + 8 + if (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal && (match_eo == int64(-int32(1)) || num_tags > 0 && **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags)) <= **(**Tregoff_t)(__ccgo_up(match_tags))) { + match_eo = pos + new_match = int32(1) + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i)*8)) = **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + uintptr(i)*8)) + goto _16 + _16: + ; + i = i + 1 + } + } + reach_next_i += 16 + } else { + /* Another path has also reached this state. We choose + the winner by examining the tag values for both + paths. */ + if _tre_tag_order(tls, num_tags, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions, tmp_tags, **(**uintptr)(__ccgo_up((**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags))) != 0 { + /* The new path wins. */ + tmp_iptr = **(**uintptr)(__ccgo_up((**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags)) + **(**uintptr)(__ccgo_up((**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags)) = tmp_tags + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal { + match_eo = pos + new_match = int32(1) + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i)*8)) = **(**Tregoff_t)(__ccgo_up(tmp_tags + uintptr(i)*8)) + goto _17 + _17: + ; + i = i + 1 + } + } + tmp_tags = tmp_iptr + } + } + } + goto _14 + _14: + ; + trans_i += 56 + } + goto _13 + _13: + ; + reach_i += 16 + } + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = UintptrFromInt32(0) + } + **(**Tregoff_t)(__ccgo_up(match_end_ofs)) = match_eo + if match_eo >= 0 { + v18 = REG_OK + } else { + v18 = int32(REG_NOMATCH) + } + ret = v18 + goto error_exit +error_exit: + ; + Xfree(tls, buf) + return ret +} + +/*********************************************************************** + from tre-match-backtrack.c +***********************************************************************/ + +/* + This matcher is for regexps that use back referencing. Regexp matching + with back referencing is an NP-complete problem on the number of back + references. The easiest way to match them is to use a backtracking + routine which basically goes through all possible paths in the TNFA + and chooses the one which results in the best (leftmost and longest) + match. This can be spectacularly expensive and may run out of stack + space, but there really is no better known generic algorithm. Quoting + Henry Spencer from comp.compilers: + + + POSIX.2 REs require longest match, which is really exciting to + implement since the obsolete ("basic") variant also includes + \. I haven't found a better way of tackling this than doing + a preliminary match using a DFA (or simulation) on a modified RE + that just replicates subREs for \, and then doing a + backtracking match to determine whether the subRE matches were + right. This can be rather slow, but I console myself with the + thought that people who use \ deserve very slow execution. + (Pun unintentional but very appropriate.) + +*/ + +type Ttre_backtrack_item_t = struct { + Fpos Tregoff_t + Fstr_byte uintptr + Fstate uintptr + Fstate_id int32 + Fnext_c int32 + Ftags uintptr +} + +type Ttre_backtrack_t = uintptr + +type Ttre_backtrack_struct = struct { + Fitem Ttre_backtrack_item_t + Fprev uintptr + Fnext uintptr +} + +func _tre_tnfa_run_backtrack(tls *TLS, tnfa uintptr, string1 uintptr, match_tags uintptr, eflags int32, match_end_ofs uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bt, empty_br_match, i, i1, i2, i3, i4, next_c_start, reg_newline, reg_notbol, reg_noteol, result, ret, v20 int32 + var bt_len, eo, match_eo, pos, pos_add_next, pos_start, so, v3 Tregoff_t + var mem Ttre_mem_t + var next_state, next_tags, pmatch, state, states_seen, str_byte, str_byte_start, tags, tmp, tmp1, trans_i, v6 uintptr + var prev_c Ttre_char_t + var s, s1, stack Ttre_backtrack_t + var _ /* next_c at bp+0 */ Ttre_char_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bt, bt_len, empty_br_match, eo, i, i1, i2, i3, i4, match_eo, mem, next_c_start, next_state, next_tags, pmatch, pos, pos_add_next, pos_start, prev_c, reg_newline, reg_notbol, reg_noteol, result, ret, s, s1, so, stack, state, states_seen, str_byte, str_byte_start, tags, tmp, tmp1, trans_i, v20, v3, v6 + /* State variables required by GET_NEXT_WCHAR. */ + prev_c = 0 + **(**Ttre_char_t)(__ccgo_up(bp)) = 0 + str_byte = string1 + pos = 0 + pos_add_next = int64(1) + reg_notbol = eflags & int32(REG_NOTBOL) + reg_noteol = eflags & int32(REG_NOTEOL) + reg_newline = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags & int32(REG_NEWLINE) + pos_start = int64(-int32(1)) + /* End offset of best match so far, or -1 if no match found yet. */ + match_eo = int64(-int32(1)) + tags = UintptrFromInt32(0) + states_seen = UintptrFromInt32(0) + /* Memory allocator to for allocating the backtracking stack. */ + mem = X__tre_mem_new_impl(tls, 0, UintptrFromInt32(0)) + pmatch = UintptrFromInt32(0) + if !(mem != 0) { + return int32(REG_ESPACE) + } + stack = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(56)) + if !(stack != 0) { + ret = int32(REG_ESPACE) + goto error_exit + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fprev = UintptrFromInt32(0) + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext = UintptrFromInt32(0) + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags != 0 { + tags = Xmalloc(tls, uint64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)) + if !(tags != 0) { + ret = int32(REG_ESPACE) + goto error_exit + } + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches != 0 { + pmatch = Xmalloc(tls, uint64(16)*uint64((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches)) + if !(pmatch != 0) { + ret = int32(REG_ESPACE) + goto error_exit + } + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states != 0 { + states_seen = Xmalloc(tls, uint64(4)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states)) + if !(states_seen != 0) { + ret = int32(REG_ESPACE) + goto error_exit + } + } + goto retry +retry: + ; + i = 0 + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(tags + uintptr(i)*8)) = int64(-int32(1)) + if match_tags != 0 { + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i)*8)) = int64(-int32(1)) + } + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) { + break + } + **(**int32)(__ccgo_up(states_seen + uintptr(i)*4)) = 0 + goto _2 + _2: + ; + i = i + 1 + } + state = UintptrFromInt32(0) + pos = pos_start + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v3 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v3 + if v3 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + pos_start = pos + next_c_start = **(**Ttre_char_t)(__ccgo_up(bp)) + str_byte_start = str_byte + /* Handle initial states. */ + next_tags = UintptrFromInt32(0) + trans_i = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial + for { + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != 0) { + break + } + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions != 0 && ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOL) != 0 && (pos > 0 || reg_notbol != 0) && (prev_c != int32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOL) != 0 && (**(**Ttre_char_t)(__ccgo_up(bp)) != int32('\000') || reg_noteol != 0) && (**(**Ttre_char_t)(__ccgo_up(bp)) != int32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOW) != 0 && (prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0 || !(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOW) != 0 && (!(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) || (**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB) != 0 && (pos != 0 && **(**Ttre_char_t)(__ccgo_up(bp)) != int32('\000') && BoolInt32(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) == BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB_NEG) != 0 && (pos == 0 || **(**Ttre_char_t)(__ccgo_up(bp)) == int32('\000') || BoolInt32(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) != BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0))) { + goto _4 + } + if state == UintptrFromInt32(0) { + /* Start from this state. */ + state = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + next_tags = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + } else { + /* Backtrack to this state. */ + if !((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext != 0) { + s = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(56)) + if !(s != 0) { + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return int32(REG_ESPACE) + } + (*Ttre_backtrack_struct)(unsafe.Pointer(s)).Fprev = stack + (*Ttre_backtrack_struct)(unsafe.Pointer(s)).Fnext = UintptrFromInt32(0) + (*Ttre_backtrack_struct)(unsafe.Pointer(s)).Fitem.Ftags = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)) + if !((*Ttre_backtrack_struct)(unsafe.Pointer(s)).Fitem.Ftags != 0) { + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return int32(REG_ESPACE) + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext = s + stack = s + } else { + stack = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fpos = pos + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstr_byte = str_byte + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate_id = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fnext_c = **(**Ttre_char_t)(__ccgo_up(bp)) + i1 = 0 + for { + if !(i1 < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(i1)*8)) = **(**Tregoff_t)(__ccgo_up(tags + uintptr(i1)*8)) + goto _5 + _5: + ; + i1 = i1 + 1 + } + tmp = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + if tmp != 0 { + for **(**int32)(__ccgo_up(tmp)) >= 0 { + v6 = tmp + tmp += 4 + **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(**(**int32)(__ccgo_up(v6)))*8)) = pos + } + } + } + goto _4 + _4: + ; + trans_i += 56 + } + if next_tags != 0 { + for { + if !(**(**int32)(__ccgo_up(next_tags)) >= 0) { + break + } + **(**Tregoff_t)(__ccgo_up(tags + uintptr(**(**int32)(__ccgo_up(next_tags)))*8)) = pos + goto _7 + _7: + ; + next_tags += 4 + } + } + if state == UintptrFromInt32(0) { + goto backtrack + } +_9: + ; + if !(int32(1) != 0) { + goto _8 + } + if state == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal { + if match_eo < pos || match_eo == pos && match_tags != 0 && _tre_tag_order(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions, tags, match_tags) != 0 { + /* This match wins the previous match. */ + match_eo = pos + if match_tags != 0 { + i2 = 0 + for { + if !(i2 < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i2)*8)) = **(**Tregoff_t)(__ccgo_up(tags + uintptr(i2)*8)) + goto _10 + _10: + ; + i2 = i2 + 1 + } + } + } + /* Our TNFAs never have transitions leaving from the final state, + so we jump right to backtracking. */ + goto backtrack + } + /* Go to the next character in the input string. */ + empty_br_match = 0 + trans_i = state + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != 0 && (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_BACKREF) != 0 { + bt = *(*int32)(unsafe.Pointer(&(*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fu)) + /* Get the substring we need to match against. Remember to + turn off REG_NOSUB temporarily. */ + _tre_fill_pmatch(tls, Uint64FromInt32(bt+int32(1)), pmatch, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags & ^Int32FromInt32(REG_NOSUB), tnfa, tags, pos) + so = (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(bt)*16))).Frm_so + eo = (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(bt)*16))).Frm_eo + bt_len = eo - so + result = Xstrncmp(tls, string1+uintptr(so), str_byte-uintptr(1), Uint64FromInt64(bt_len)) + if result == 0 { + /* Back reference matched. Check for infinite loop. */ + if bt_len == 0 { + empty_br_match = int32(1) + } + if empty_br_match != 0 && **(**int32)(__ccgo_up(states_seen + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*4)) != 0 { + goto backtrack + } + **(**int32)(__ccgo_up(states_seen + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*4)) = empty_br_match + /* Advance in input string and resync `prev_c', `next_c' + and pos. */ + str_byte = str_byte + uintptr(bt_len-int64(1)) + pos = pos + (bt_len - int64(1)) + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v3 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v3 + if v3 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + } else { + goto backtrack + } + } else { + /* Check for end of string. */ + if **(**Ttre_char_t)(__ccgo_up(bp)) == int32('\000') { + goto backtrack + } + /* Read the next character. */ + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v3 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v3 + if v3 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + } + next_state = UintptrFromInt32(0) + trans_i = state + for { + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != 0) { + break + } + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fcode_min <= Uint32FromInt32(prev_c) && (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fcode_max >= Uint32FromInt32(prev_c) { + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions != 0 && ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOL) != 0 && (pos > 0 || reg_notbol != 0) && (prev_c != int32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOL) != 0 && (**(**Ttre_char_t)(__ccgo_up(bp)) != int32('\000') || reg_noteol != 0) && (**(**Ttre_char_t)(__ccgo_up(bp)) != int32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOW) != 0 && (prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0 || !(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOW) != 0 && (!(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) || (**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB) != 0 && (pos != 0 && **(**Ttre_char_t)(__ccgo_up(bp)) != int32('\000') && BoolInt32(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) == BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB_NEG) != 0 && (pos == 0 || **(**Ttre_char_t)(__ccgo_up(bp)) == int32('\000') || BoolInt32(prev_c == int32('_') || Xiswalnum(tls, Uint32FromInt32(prev_c)) != 0) != BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == int32('_') || Xiswalnum(tls, Uint32FromInt32(**(**Ttre_char_t)(__ccgo_up(bp)))) != 0)) || ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS) != 0 && !((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&Int32FromInt32(REG_ICASE) != 0) && !(Xiswctype(tls, Uint32FromInt32(prev_c), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS) != 0 && (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_ICASE) != 0 && !(Xiswctype(tls, Xtowlower(tls, Uint32FromInt32(prev_c)), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) && !(Xiswctype(tls, Xtowupper(tls, Uint32FromInt32(prev_c)), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS_NEG) != 0 && _tre_neg_char_classes_match(tls, (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fneg_classes, Uint32FromInt32(prev_c), (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_ICASE)) != 0)) { + goto _13 + } + if next_state == UintptrFromInt32(0) { + /* First matching transition. */ + next_state = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + next_tags = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + } else { + /* Second matching transition. We may need to backtrack here + to take this transition instead of the first one, so we + push this transition in the backtracking stack so we can + jump back here if needed. */ + if !((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext != 0) { + s1 = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(56)) + if !(s1 != 0) { + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return int32(REG_ESPACE) + } + (*Ttre_backtrack_struct)(unsafe.Pointer(s1)).Fprev = stack + (*Ttre_backtrack_struct)(unsafe.Pointer(s1)).Fnext = UintptrFromInt32(0) + (*Ttre_backtrack_struct)(unsafe.Pointer(s1)).Fitem.Ftags = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)) + if !((*Ttre_backtrack_struct)(unsafe.Pointer(s1)).Fitem.Ftags != 0) { + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return int32(REG_ESPACE) + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext = s1 + stack = s1 + } else { + stack = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fpos = pos + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstr_byte = str_byte + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate_id = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fnext_c = **(**Ttre_char_t)(__ccgo_up(bp)) + i3 = 0 + for { + if !(i3 < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(i3)*8)) = **(**Tregoff_t)(__ccgo_up(tags + uintptr(i3)*8)) + goto _14 + _14: + ; + i3 = i3 + 1 + } + tmp1 = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + for { + if !(tmp1 != 0 && **(**int32)(__ccgo_up(tmp1)) >= 0) { + break + } + **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(**(**int32)(__ccgo_up(tmp1)))*8)) = pos + goto _15 + _15: + ; + tmp1 += 4 + } + } + } + goto _13 + _13: + ; + trans_i += 56 + } + if !(next_state != UintptrFromInt32(0)) { + goto _16 + } + /* Matching transitions were found. Take the first one. */ + state = next_state + /* Update the tag values. */ + if next_tags != 0 { + for **(**int32)(__ccgo_up(next_tags)) >= 0 { + v6 = next_tags + next_tags += 4 + **(**Tregoff_t)(__ccgo_up(tags + uintptr(**(**int32)(__ccgo_up(v6)))*8)) = pos + } + } + goto _17 +_16: + ; + goto backtrack +backtrack: + ; + /* A matching transition was not found. Try to backtrack. */ + if (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fprev != 0 { + if (*Ttre_tnfa_transition_t)(unsafe.Pointer((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate)).Fassertions&int32(ASSERT_BACKREF) != 0 { + **(**int32)(__ccgo_up(states_seen + uintptr((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate_id)*4)) = 0 + } + pos = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fpos + str_byte = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstr_byte + state = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate + **(**Ttre_char_t)(__ccgo_up(bp)) = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fnext_c + i4 = 0 + for { + if !(i4 < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(tags + uintptr(i4)*8)) = **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(i4)*8)) + goto _19 + _19: + ; + i4 = i4 + 1 + } + stack = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fprev + } else { + if match_eo < 0 { + /* Try starting from a later position in the input string. */ + /* Check for end of string. */ + if **(**Ttre_char_t)(__ccgo_up(bp)) == int32('\000') { + goto _8 + } + **(**Ttre_char_t)(__ccgo_up(bp)) = next_c_start + str_byte = str_byte_start + goto retry + } else { + goto _8 + } + } +_17: + ; + goto _9 +_8: + ; + if match_eo >= 0 { + v20 = REG_OK + } else { + v20 = int32(REG_NOMATCH) + } + ret = v20 + **(**Tregoff_t)(__ccgo_up(match_end_ofs)) = match_eo + goto error_exit +error_exit: + ; + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return ret +} + +/*********************************************************************** + from regexec.c +***********************************************************************/ + +// C documentation +// +// /* Fills the POSIX.2 regmatch_t array according to the TNFA tag and match +// endpoint values. */ +func _tre_fill_pmatch(tls *TLS, nmatch Tsize_t, pmatch uintptr, cflags int32, tnfa uintptr, tags uintptr, match_eo Tregoff_t) { + var i, j uint32 + var parents, submatch_data uintptr + var v1 Tregoff_t + _, _, _, _, _ = i, j, parents, submatch_data, v1 + i = uint32(0) + if match_eo >= 0 && !(cflags&Int32FromInt32(REG_NOSUB) != 0) { + /* Construct submatch offsets from the tags. */ + submatch_data = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + for i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches && uint64(i) < nmatch { + if (**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Fso_tag == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fend_tag { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = match_eo + } else { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = **(**Tregoff_t)(__ccgo_up(tags + uintptr((**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Fso_tag)*8)) + } + if (**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Feo_tag == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fend_tag { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = match_eo + } else { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = **(**Tregoff_t)(__ccgo_up(tags + uintptr((**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Feo_tag)*8)) + } + /* If either of the endpoints were not used, this submatch + was not part of the match. */ + if (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so == int64(-int32(1)) || (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo == int64(-int32(1)) { + v1 = int64(-Int32FromInt32(1)) + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = v1 + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = v1 + } + i = i + 1 + } + /* Reset all submatches that are not within all of their parent + submatches. */ + i = uint32(0) + for i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches && uint64(i) < nmatch { + if (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo == int64(-int32(1)) { + } + parents = (**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Fparents + if parents != UintptrFromInt32(0) { + j = uint32(0) + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(j)*4)) >= 0) { + break + } + if (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so < (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(**(**int32)(__ccgo_up(parents + uintptr(j)*4)))*16))).Frm_so || (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo > (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(**(**int32)(__ccgo_up(parents + uintptr(j)*4)))*16))).Frm_eo { + v1 = int64(-Int32FromInt32(1)) + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = v1 + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = v1 + } + goto _2 + _2: + ; + j = j + 1 + } + } + i = i + 1 + } + } + for uint64(i) < nmatch { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = int64(-int32(1)) + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = int64(-int32(1)) + i = i + 1 + } +} + +/* + Wrapper functions for POSIX compatible regexp matching. +*/ + +func Xregexec(tls *TLS, preg uintptr, string1 uintptr, nmatch Tsize_t, pmatch uintptr, eflags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v preg=%v string1=%v nmatch=%v pmatch=%v eflags=%v, (%v:)", tls, preg, string1, nmatch, pmatch, eflags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var status Treg_errcode_t + var tags, tnfa uintptr + var _ /* eo at bp+0 */ Tregoff_t + _, _, _ = status, tags, tnfa + tnfa = (*Tregex_t)(unsafe.Pointer(preg)).F__opaque + tags = UintptrFromInt32(0) + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_NOSUB) != 0 { + nmatch = uint64(0) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags > 0 && nmatch > uint64(0) { + tags = Xmalloc(tls, uint64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)) + if tags == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + } + /* Dispatch to the appropriate matcher. */ + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fhave_backrefs != 0 { + /* The regex has back references, use the backtracking matcher. */ + status = _tre_tnfa_run_backtrack(tls, tnfa, string1, tags, eflags, bp) + } else { + /* Exact matching, no back references, use the parallel matcher. */ + status = _tre_tnfa_run_parallel(tls, tnfa, string1, tags, eflags, bp) + } + if status == REG_OK { + /* A match was found, so fill the submatch registers. */ + _tre_fill_pmatch(tls, nmatch, pmatch, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags, tnfa, tags, **(**Tregoff_t)(__ccgo_up(bp))) + } + if tags != 0 { + Xfree(tls, tags) + } + return status +} + +/* + This memory allocator is for allocating small memory blocks efficiently + in terms of memory overhead and execution speed. The allocated blocks + cannot be freed individually, only all at once. There can be multiple + allocators, though. +*/ + +// C documentation +// +// /* Returns a new memory allocator or NULL if out of memory. */ +func X__tre_mem_new_impl(tls *TLS, provided int32, provided_block uintptr) (r Ttre_mem_t) { + if __ccgo_strace { + trc("tls=%v provided=%v provided_block=%v, (%v:)", tls, provided, provided_block, origin(2)) + defer func() { trc("-> %v", r) }() + } + var mem Ttre_mem_t + _ = mem + if provided != 0 { + mem = provided_block + Xmemset(tls, mem, 0, uint64(48)) + } else { + mem = Xcalloc(tls, uint64(1), uint64(48)) + } + if mem == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + return mem +} + +// C documentation +// +// /* Frees the memory allocator and all memory allocated with it. */ +func X__tre_mem_destroy(tls *TLS, mem Ttre_mem_t) { + if __ccgo_strace { + trc("tls=%v mem=%v, (%v:)", tls, mem, origin(2)) + } + var l, tmp uintptr + _, _ = l, tmp + l = (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fblocks + for l != UintptrFromInt32(0) { + Xfree(tls, (*Ttre_list_t)(unsafe.Pointer(l)).Fdata) + tmp = (*Ttre_list_t)(unsafe.Pointer(l)).Fnext + Xfree(tls, l) + l = tmp + } + Xfree(tls, mem) +} + +// C documentation +// +// /* Allocates a block of `size' bytes from `mem'. Returns a pointer to the +// allocated block or NULL if an underlying malloc() failed. */ +func X__tre_mem_alloc_impl(tls *TLS, mem Ttre_mem_t, provided int32, provided_block uintptr, zero int32, size Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v mem=%v provided=%v provided_block=%v zero=%v size=%v, (%v:)", tls, mem, provided, provided_block, zero, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + var block_size int32 + var l, ptr uintptr + var v1 uint64 + _, _, _, _ = block_size, l, ptr, v1 + if (*Ttre_mem_struct)(unsafe.Pointer(mem)).Ffailed != 0 { + return UintptrFromInt32(0) + } + if (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fn < size { + if provided != 0 { + if provided_block == UintptrFromInt32(0) { + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Ffailed = int32(1) + return UintptrFromInt32(0) + } + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr = provided_block + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fn = uint64(TRE_MEM_BLOCK_SIZE) + } else { + if size*uint64(8) > uint64(TRE_MEM_BLOCK_SIZE) { + block_size = Int32FromUint64(size * uint64(8)) + } else { + block_size = int32(TRE_MEM_BLOCK_SIZE) + } + l = Xmalloc(tls, uint64(16)) + if l == UintptrFromInt32(0) { + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Ffailed = int32(1) + return UintptrFromInt32(0) + } + (*Ttre_list_t)(unsafe.Pointer(l)).Fdata = Xmalloc(tls, Uint64FromInt32(block_size)) + if (*Ttre_list_t)(unsafe.Pointer(l)).Fdata == UintptrFromInt32(0) { + Xfree(tls, l) + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Ffailed = int32(1) + return UintptrFromInt32(0) + } + (*Ttre_list_t)(unsafe.Pointer(l)).Fnext = UintptrFromInt32(0) + if (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fcurrent != UintptrFromInt32(0) { + (*Ttre_list_t)(unsafe.Pointer((*Ttre_mem_struct)(unsafe.Pointer(mem)).Fcurrent)).Fnext = l + } + if (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fblocks == UintptrFromInt32(0) { + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fblocks = l + } + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fcurrent = l + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr = (*Ttre_list_t)(unsafe.Pointer(l)).Fdata + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fn = Uint64FromInt32(block_size) + } + } + /* Make sure the next pointer will be aligned. */ + if (Uint64FromInt64(int64((*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr))+size)%uint64(8) != 0 { + v1 = uint64(8) - (Uint64FromInt64(int64((*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr))+size)%uint64(8) + } else { + v1 = uint64(0) + } + size = size + v1 + /* Allocate from current block. */ + ptr = (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr + **(**uintptr)(__ccgo_up(mem + 16)) += uintptr(size) + **(**Tsize_t)(__ccgo_up(mem + 24)) -= size + /* Set to zero if needed. */ + if zero != 0 { + Xmemset(tls, ptr, 0, size) + } + return ptr +} + +const MAXSIZE = 1 +const MINSIZE = 8 + +type TACTION = int32 + +const _FIND = 0 +const _ENTER = 1 + +type TVISIT = int32 + +const _preorder = 0 +const _postorder = 1 +const _endorder = 2 +const _leaf = 3 + +type TENTRY = struct { + Fkey uintptr + Fdata uintptr +} + +type Tentry = TENTRY + +type Thsearch_data = struct { + F__tab uintptr + F__unused1 uint32 + F__unused2 uint32 +} + +type Tqelem = struct { + Fq_forw uintptr + Fq_back uintptr + Fq_data [1]int8 +} + +/* +open addressing hash table with 2^n table size +quadratic probing is used in case of hash collision +tab indices and hash are size_t +after resize fails with ENOMEM the state of tab is still usable + +with the posix api items cannot be iterated and length cannot be queried +*/ + +type t__tab = struct { + Fentries uintptr + Fmask Tsize_t + Fused Tsize_t +} + +var _htab Thsearch_data + +func _keyhash(tls *TLS, k uintptr) (r Tsize_t) { + var h Tsize_t + var p, v1 uintptr + _, _, _ = h, p, v1 + p = k + h = uint64(0) + for **(**uint8)(__ccgo_up(p)) != 0 { + v1 = p + p = p + 1 + h = uint64(31)*h + uint64(**(**uint8)(__ccgo_up(v1))) + } + return h +} + +func _resize(tls *TLS, nel Tsize_t, htab uintptr) (r int32) { + var e, newe, oldtab uintptr + var i, j, newsize, oldsize, v4 Tsize_t + _, _, _, _, _, _, _, _ = e, i, j, newe, newsize, oldsize, oldtab, v4 + oldsize = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask + uint64(1) + oldtab = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries + if nel > Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(2)+Uint64FromInt32(1) { + nel = Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(2) + Uint64FromInt32(1) + } + newsize = uint64(MINSIZE) + for { + if !(newsize < nel) { + break + } + goto _1 + _1: + ; + newsize = newsize * uint64(2) + } + (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries = Xcalloc(tls, newsize, uint64(16)) + if !((*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries != 0) { + (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries = oldtab + return 0 + } + (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask = newsize - uint64(1) + if !(oldtab != 0) { + return int32(1) + } + e = oldtab + for { + if !(e < oldtab+uintptr(oldsize)*16) { + break + } + if (*TENTRY)(unsafe.Pointer(e)).Fkey != 0 { + i = _keyhash(tls, (*TENTRY)(unsafe.Pointer(e)).Fkey) + j = Uint64FromInt32(1) + for { + newe = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries + uintptr(i&(*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask)*16 + if !((*TENTRY)(unsafe.Pointer(newe)).Fkey != 0) { + break + } + goto _3 + _3: + ; + v4 = j + j = j + 1 + i = i + v4 + } + **(**TENTRY)(__ccgo_up(newe)) = **(**TENTRY)(__ccgo_up(e)) + } + goto _2 + _2: + ; + e += 16 + } + Xfree(tls, oldtab) + return int32(1) +} + +func Xhcreate(tls *TLS, nel Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v nel=%v, (%v:)", tls, nel, origin(2)) + defer func() { trc("-> %v", r) }() + } + return ___hcreate_r(tls, nel, uintptr(unsafe.Pointer(&_htab))) +} + +func Xhdestroy(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + ___hdestroy_r(tls, uintptr(unsafe.Pointer(&_htab))) +} + +func _lookup(tls *TLS, key uintptr, hash Tsize_t, htab uintptr) (r uintptr) { + var e uintptr + var i, j, v2 Tsize_t + _, _, _, _ = e, i, j, v2 + i = hash + j = Uint64FromInt32(1) + for { + e = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries + uintptr(i&(*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask)*16 + if !((*TENTRY)(unsafe.Pointer(e)).Fkey != 0) || Xstrcmp(tls, (*TENTRY)(unsafe.Pointer(e)).Fkey, key) == 0 { + break + } + goto _1 + _1: + ; + v2 = j + j = j + 1 + i = i + v2 + } + return e +} + +func Xhsearch(tls *TLS, item TENTRY, action TACTION) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v action=%v, (%v:)", tls, item, action, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* e at bp+0 */ uintptr + ___hsearch_r(tls, item, action, bp, uintptr(unsafe.Pointer(&_htab))) + return **(**uintptr)(__ccgo_up(bp)) +} + +func ___hcreate_r(tls *TLS, nel Tsize_t, htab uintptr) (r1 int32) { + var r int32 + _ = r + (*Thsearch_data)(unsafe.Pointer(htab)).F__tab = Xcalloc(tls, uint64(1), uint64(24)) + if !((*Thsearch_data)(unsafe.Pointer(htab)).F__tab != 0) { + return 0 + } + r = _resize(tls, nel, htab) + if r == 0 { + Xfree(tls, (*Thsearch_data)(unsafe.Pointer(htab)).F__tab) + (*Thsearch_data)(unsafe.Pointer(htab)).F__tab = uintptr(0) + } + return r +} + +func ___hdestroy_r(tls *TLS, htab uintptr) { + if (*Thsearch_data)(unsafe.Pointer(htab)).F__tab != 0 { + Xfree(tls, (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries) + } + Xfree(tls, (*Thsearch_data)(unsafe.Pointer(htab)).F__tab) + (*Thsearch_data)(unsafe.Pointer(htab)).F__tab = uintptr(0) +} + +func ___hsearch_r(tls *TLS, item TENTRY, action TACTION, retval uintptr, htab uintptr) (r int32) { + var e, v2 uintptr + var hash, v1 Tsize_t + _, _, _, _ = e, hash, v1, v2 + hash = _keyhash(tls, item.Fkey) + e = _lookup(tls, item.Fkey, hash, htab) + if (*TENTRY)(unsafe.Pointer(e)).Fkey != 0 { + **(**uintptr)(__ccgo_up(retval)) = e + return int32(1) + } + if action == int32(_FIND) { + **(**uintptr)(__ccgo_up(retval)) = uintptr(0) + return 0 + } + **(**TENTRY)(__ccgo_up(e)) = item + v2 = (*Thsearch_data)(unsafe.Pointer(htab)).F__tab + 16 + *(*Tsize_t)(unsafe.Pointer(v2)) = *(*Tsize_t)(unsafe.Pointer(v2)) + 1 + v1 = *(*Tsize_t)(unsafe.Pointer(v2)) + if v1 > (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask-(*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask/uint64(4) { + if !(_resize(tls, uint64(2)*(*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fused, htab) != 0) { + (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fused = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fused - 1 + (*TENTRY)(unsafe.Pointer(e)).Fkey = uintptr(0) + **(**uintptr)(__ccgo_up(retval)) = uintptr(0) + return 0 + } + e = _lookup(tls, item.Fkey, hash, htab) + } + **(**uintptr)(__ccgo_up(retval)) = e + return int32(1) +} + +type Tnode = struct { + Fnext uintptr + Fprev uintptr +} + +func Xinsque(tls *TLS, element uintptr, pred uintptr) { + if __ccgo_strace { + trc("tls=%v element=%v pred=%v, (%v:)", tls, element, pred, origin(2)) + } + var e, p, v1 uintptr + _, _, _ = e, p, v1 + e = element + p = pred + if !(p != 0) { + v1 = UintptrFromInt32(0) + (*Tnode)(unsafe.Pointer(e)).Fprev = v1 + (*Tnode)(unsafe.Pointer(e)).Fnext = v1 + return + } + (*Tnode)(unsafe.Pointer(e)).Fnext = (*Tnode)(unsafe.Pointer(p)).Fnext + (*Tnode)(unsafe.Pointer(e)).Fprev = p + (*Tnode)(unsafe.Pointer(p)).Fnext = e + if (*Tnode)(unsafe.Pointer(e)).Fnext != 0 { + (*Tnode)(unsafe.Pointer((*Tnode)(unsafe.Pointer(e)).Fnext)).Fprev = e + } +} + +func Xremque(tls *TLS, element uintptr) { + if __ccgo_strace { + trc("tls=%v element=%v, (%v:)", tls, element, origin(2)) + } + var e uintptr + _ = e + e = element + if (*Tnode)(unsafe.Pointer(e)).Fnext != 0 { + (*Tnode)(unsafe.Pointer((*Tnode)(unsafe.Pointer(e)).Fnext)).Fprev = (*Tnode)(unsafe.Pointer(e)).Fprev + } + if (*Tnode)(unsafe.Pointer(e)).Fprev != 0 { + (*Tnode)(unsafe.Pointer((*Tnode)(unsafe.Pointer(e)).Fprev)).Fnext = (*Tnode)(unsafe.Pointer(e)).Fnext + } +} + +type t__ccgo_fp__Xlsearch_4 = func(*TLS, uintptr, uintptr) int32 + +func Xlsearch(tls *TLS, key uintptr, base uintptr, nelp uintptr, width Tsize_t, __ccgo_fp_compar uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v base=%v nelp=%v width=%v __ccgo_fp_compar=%v, (%v:)", tls, key, base, nelp, width, __ccgo_fp_compar, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i, n Tsize_t + var p uintptr + var v1 t__predefined_size_t + _, _, _, _ = i, n, p, v1 + defer func() {}() + v1 = width + p = base + n = **(**Tsize_t)(__ccgo_up(nelp)) + i = uint64(0) + for { + if !(i < n) { + break + } + if (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_compar})))(tls, key, p+uintptr(i)*uintptr(v1)) == 0 { + return p + uintptr(i)*uintptr(v1) + } + goto _2 + _2: + ; + i = i + 1 + } + **(**Tsize_t)(__ccgo_up(nelp)) = n + uint64(1) + return Xmemcpy(tls, p+uintptr(n)*uintptr(v1), key, width) +} + +type t__ccgo_fp__Xlfind_4 = func(*TLS, uintptr, uintptr) int32 + +func Xlfind(tls *TLS, key uintptr, base uintptr, nelp uintptr, width Tsize_t, __ccgo_fp_compar uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v base=%v nelp=%v width=%v __ccgo_fp_compar=%v, (%v:)", tls, key, base, nelp, width, __ccgo_fp_compar, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i, n Tsize_t + var p uintptr + var v1 t__predefined_size_t + _, _, _, _ = i, n, p, v1 + defer func() {}() + v1 = width + p = base + n = **(**Tsize_t)(__ccgo_up(nelp)) + i = uint64(0) + for { + if !(i < n) { + break + } + if (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_compar})))(tls, key, p+uintptr(i)*uintptr(v1)) == 0 { + return p + uintptr(i)*uintptr(v1) + } + goto _2 + _2: + ; + i = i + 1 + } + return uintptr(0) +} + +const MAXH = 0 + +type Tnode1 = struct { + Fkey uintptr + Fa [2]uintptr + Fh int32 +} + +type t__ccgo_fp__Xtdelete_2 = func(*TLS, uintptr, uintptr) int32 + +func Xtdelete(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v rootp=%v __ccgo_fp_cmp=%v, (%v:)", tls, key, rootp, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a [97]uintptr + var c, i, v1 int32 + var child, deleted, n, parent uintptr + _, _, _, _, _, _, _, _ = a, c, child, deleted, i, n, parent, v1 + if !(rootp != 0) { + return uintptr(0) + } + n = **(**uintptr)(__ccgo_up(rootp)) + i = 0 + /* *a[0] is an arbitrary non-null pointer that is returned when + the root node is deleted. */ + v1 = i + i = i + 1 + a[v1] = rootp + v1 = i + i = i + 1 + a[v1] = rootp + for { + if !(n != 0) { + return uintptr(0) + } + c = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, key, (*Tnode1)(unsafe.Pointer(n)).Fkey) + if !(c != 0) { + break + } + v1 = i + i = i + 1 + a[v1] = n + 8 + BoolUintptr(c > 0)*8 + n = **(**uintptr)(__ccgo_up(n + 8 + BoolUintptr(c > 0)*8)) + goto _3 + _3: + } + parent = **(**uintptr)(__ccgo_up(a[i-int32(2)])) + if **(**uintptr)(__ccgo_up(n + 8)) != 0 { + /* free the preceding node instead of the deleted one. */ + deleted = n + v1 = i + i = i + 1 + a[v1] = n + 8 + n = **(**uintptr)(__ccgo_up(n + 8)) + for **(**uintptr)(__ccgo_up(n + 8 + 1*8)) != 0 { + v1 = i + i = i + 1 + a[v1] = n + 8 + 1*8 + n = **(**uintptr)(__ccgo_up(n + 8 + 1*8)) + } + (*Tnode1)(unsafe.Pointer(deleted)).Fkey = (*Tnode1)(unsafe.Pointer(n)).Fkey + child = **(**uintptr)(__ccgo_up(n + 8)) + } else { + child = **(**uintptr)(__ccgo_up(n + 8 + 1*8)) + } + /* freed node has at most one child, move it up and rebalance. */ + Xfree(tls, n) + i = i - 1 + v1 = i + **(**uintptr)(__ccgo_up(a[v1])) = child + for { + i = i - 1 + v1 = i + if !(v1 != 0 && X__tsearch_balance(tls, a[i]) != 0) { + break + } + } + return parent +} + +type t__ccgo_fp__Xtdestroy_1 = func(*TLS, uintptr) + +func Xtdestroy(tls *TLS, root uintptr, __ccgo_fp_freekey uintptr) { + if __ccgo_strace { + trc("tls=%v root=%v __ccgo_fp_freekey=%v, (%v:)", tls, root, __ccgo_fp_freekey, origin(2)) + } + var r uintptr + _ = r + r = root + if r == uintptr(0) { + return + } + Xtdestroy(tls, **(**uintptr)(__ccgo_up(r + 8)), __ccgo_fp_freekey) + Xtdestroy(tls, **(**uintptr)(__ccgo_up(r + 8 + 1*8)), __ccgo_fp_freekey) + if __ccgo_fp_freekey != 0 { + (*(*func(*TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_freekey})))(tls, (*Tnode1)(unsafe.Pointer(r)).Fkey) + } + Xfree(tls, r) +} + +type t__ccgo_fp__Xtfind_2 = func(*TLS, uintptr, uintptr) int32 + +func Xtfind(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v rootp=%v __ccgo_fp_cmp=%v, (%v:)", tls, key, rootp, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c int32 + var n uintptr + _, _ = c, n + if !(rootp != 0) { + return uintptr(0) + } + n = **(**uintptr)(__ccgo_up(rootp)) + for { + if !(n != 0) { + break + } + c = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, key, (*Tnode1)(unsafe.Pointer(n)).Fkey) + if !(c != 0) { + break + } + n = **(**uintptr)(__ccgo_up(n + 8 + BoolUintptr(c > 0)*8)) + goto _1 + _1: + } + return n +} + +func _height(tls *TLS, n uintptr) (r int32) { + var v1 int32 + _ = v1 + if n != 0 { + v1 = (*Tnode1)(unsafe.Pointer(n)).Fh + } else { + v1 = 0 + } + return v1 +} + +func _rot(tls *TLS, p uintptr, x uintptr, dir int32) (r int32) { + var hx, hz int32 + var y, z uintptr + _, _, _, _ = hx, hz, y, z + y = **(**uintptr)(__ccgo_up(x + 8 + uintptr(dir)*8)) + z = **(**uintptr)(__ccgo_up(y + 8 + BoolUintptr(!(dir != 0))*8)) + hx = (*Tnode1)(unsafe.Pointer(x)).Fh + hz = _height(tls, z) + if hz > _height(tls, **(**uintptr)(__ccgo_up(y + 8 + uintptr(dir)*8))) { + /* + * x + * / \ dir z + * A y / * / \ --> x y + * z D /| | * / \ A B C D + * B C + */ + **(**uintptr)(__ccgo_up(x + 8 + uintptr(dir)*8)) = **(**uintptr)(__ccgo_up(z + 8 + BoolUintptr(!(dir != 0))*8)) + **(**uintptr)(__ccgo_up(y + 8 + BoolUintptr(!(dir != 0))*8)) = **(**uintptr)(__ccgo_up(z + 8 + uintptr(dir)*8)) + **(**uintptr)(__ccgo_up(z + 8 + BoolUintptr(!(dir != 0))*8)) = x + **(**uintptr)(__ccgo_up(z + 8 + uintptr(dir)*8)) = y + (*Tnode1)(unsafe.Pointer(x)).Fh = hz + (*Tnode1)(unsafe.Pointer(y)).Fh = hz + (*Tnode1)(unsafe.Pointer(z)).Fh = hz + int32(1) + } else { + /* + * x y + * / \ / * A y --> x D + * / \ / * z D A z + */ + **(**uintptr)(__ccgo_up(x + 8 + uintptr(dir)*8)) = z + **(**uintptr)(__ccgo_up(y + 8 + BoolUintptr(!(dir != 0))*8)) = x + (*Tnode1)(unsafe.Pointer(x)).Fh = hz + int32(1) + (*Tnode1)(unsafe.Pointer(y)).Fh = hz + int32(2) + z = y + } + **(**uintptr)(__ccgo_up(p)) = z + return (*Tnode1)(unsafe.Pointer(z)).Fh - hx +} + +// C documentation +// +// /* balance *p, return 0 if height is unchanged. */ +func X__tsearch_balance(tls *TLS, p uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h0, h1, old, v1 int32 + var n uintptr + _, _, _, _, _ = h0, h1, n, old, v1 + n = **(**uintptr)(__ccgo_up(p)) + h0 = _height(tls, **(**uintptr)(__ccgo_up(n + 8))) + h1 = _height(tls, **(**uintptr)(__ccgo_up(n + 8 + 1*8))) + if Uint32FromInt32(h0-h1)+uint32(1) < uint32(3) { + old = (*Tnode1)(unsafe.Pointer(n)).Fh + if h0 < h1 { + v1 = h1 + int32(1) + } else { + v1 = h0 + int32(1) + } + (*Tnode1)(unsafe.Pointer(n)).Fh = v1 + return (*Tnode1)(unsafe.Pointer(n)).Fh - old + } + return _rot(tls, p, n, BoolInt32(h0 < h1)) +} + +type t__ccgo_fp__Xtsearch_2 = func(*TLS, uintptr, uintptr) int32 + +func Xtsearch(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v rootp=%v __ccgo_fp_cmp=%v, (%v:)", tls, key, rootp, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var a [96]uintptr + var c, i, v1 int32 + var n, r, v4 uintptr + var v7 bool + _, _, _, _, _, _, _, _ = a, c, i, n, r, v1, v4, v7 + if !(rootp != 0) { + return uintptr(0) + } + n = **(**uintptr)(__ccgo_up(rootp)) + i = 0 + v1 = i + i = i + 1 + a[v1] = rootp + for { + if !(n != 0) { + break + } + c = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, key, (*Tnode1)(unsafe.Pointer(n)).Fkey) + if !(c != 0) { + return n + } + v1 = i + i = i + 1 + a[v1] = n + 8 + BoolUintptr(c > 0)*8 + n = **(**uintptr)(__ccgo_up(n + 8 + BoolUintptr(c > 0)*8)) + goto _2 + _2: + } + r = Xmalloc(tls, uint64(32)) + if !(r != 0) { + return uintptr(0) + } + (*Tnode1)(unsafe.Pointer(r)).Fkey = key + v4 = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(r + 8 + 1*8)) = v4 + **(**uintptr)(__ccgo_up(r + 8)) = v4 + (*Tnode1)(unsafe.Pointer(r)).Fh = int32(1) + /* insert new node, rebalance ancestors. */ + i = i - 1 + v1 = i + **(**uintptr)(__ccgo_up(a[v1])) = r + for { + if v7 = i != 0; v7 { + i = i - 1 + v1 = i + } + if !(v7 && X__tsearch_balance(tls, a[v1]) != 0) { + break + } + } + return r +} + +func _walk(tls *TLS, r uintptr, __ccgo_fp_action uintptr, d int32) { + if !(r != 0) { + return + } + if (*Tnode1)(unsafe.Pointer(r)).Fh == int32(1) { + (*(*func(*TLS, uintptr, TVISIT, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_action})))(tls, r, int32(_leaf), d) + } else { + (*(*func(*TLS, uintptr, TVISIT, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_action})))(tls, r, int32(_preorder), d) + _walk(tls, **(**uintptr)(__ccgo_up(r + 8)), __ccgo_fp_action, d+int32(1)) + (*(*func(*TLS, uintptr, TVISIT, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_action})))(tls, r, int32(_postorder), d) + _walk(tls, **(**uintptr)(__ccgo_up(r + 8 + 1*8)), __ccgo_fp_action, d+int32(1)) + (*(*func(*TLS, uintptr, TVISIT, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_action})))(tls, r, int32(_endorder), d) + } +} + +type t__ccgo_fp__Xtwalk_1 = func(*TLS, uintptr, int32, int32) + +func Xtwalk(tls *TLS, root uintptr, __ccgo_fp_action uintptr) { + if __ccgo_strace { + trc("tls=%v root=%v __ccgo_fp_action=%v, (%v:)", tls, root, __ccgo_fp_action, origin(2)) + } + _walk(tls, root, __ccgo_fp_action, 0) +} + +func Xpoll(tls *TLS, fds uintptr, n Tnfds_t, timeout int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fds=%v n=%v timeout=%v, (%v:)", tls, fds, n, timeout, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_poll), int64(fds), Int64FromUint64(n), int64(timeout), 0, 0, 0)))) +} + +func Xppoll(tls *TLS, fds uintptr, n Tnfds_t, to uintptr, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fds=%v n=%v to=%v mask=%v, (%v:)", tls, fds, n, to, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ns, v1, v2 int64 + var s Ttime_t + var v3 uintptr + _, _, _, _, _ = ns, s, v1, v2, v3 + if to != 0 { + v1 = (*Ttimespec)(unsafe.Pointer(to)).Ftv_sec + } else { + v1 = 0 + } + s = v1 + if to != 0 { + v2 = (*Ttimespec)(unsafe.Pointer(to)).Ftv_nsec + } else { + v2 = 0 + } + ns = v2 + if to != 0 { + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: s, + 1: ns, + } + v3 = bp + } else { + v3 = uintptr(0) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_ppoll), int64(fds), Int64FromUint64(n), int64(v3), int64(mask), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), 0)))) +} + +func Xpselect(tls *TLS, n int32, rfds uintptr, wfds uintptr, efds uintptr, ts uintptr, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v n=%v rfds=%v wfds=%v efds=%v ts=%v mask=%v, (%v:)", tls, n, rfds, wfds, efds, ts, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ns, v1, v2 int64 + var s Ttime_t + var v3 uintptr + var _ /* data at bp+16 */ [2]Tsyscall_arg_t + _, _, _, _, _ = ns, s, v1, v2, v3 + **(**[2]Tsyscall_arg_t)(__ccgo_up(bp + 16)) = [2]Tsyscall_arg_t{ + 0: Int64FromUint64(uint64(mask)), + 1: int64(Int32FromInt32(_NSIG) / Int32FromInt32(8)), + } + if ts != 0 { + v1 = (*Ttimespec)(unsafe.Pointer(ts)).Ftv_sec + } else { + v1 = 0 + } + s = v1 + if ts != 0 { + v2 = (*Ttimespec)(unsafe.Pointer(ts)).Ftv_nsec + } else { + v2 = 0 + } + ns = v2 + if ts != 0 { + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: s, + 1: ns, + } + v3 = bp + } else { + v3 = uintptr(0) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pselect6), int64(n), int64(rfds), int64(wfds), int64(efds), int64(v3), int64(bp+16))))) +} + +func Xselect(tls *TLS, n int32, rfds uintptr, wfds uintptr, efds uintptr, tv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v n=%v rfds=%v wfds=%v efds=%v tv=%v, (%v:)", tls, n, rfds, wfds, efds, tv, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var max_time, s Ttime_t + var ns, v1, v2 int64 + var us Tsuseconds_t + var v3 uintptr + _, _, _, _, _, _, _ = max_time, ns, s, us, v1, v2, v3 + if tv != 0 { + v1 = (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec + } else { + v1 = 0 + } + s = v1 + if tv != 0 { + v2 = (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec + } else { + v2 = 0 + } + us = v2 + max_time = Int64FromUint64(Uint64FromUint64(1)<<(Uint64FromInt32(8)*Uint64FromInt64(8)-Uint64FromInt32(1)) - Uint64FromInt32(1)) + if s < 0 || us < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + if us/int64(1000000) > max_time-s { + s = max_time + us = int64(999999) + ns = int64(999999999) + } else { + s = s + us/int64(1000000) + us = us % int64(1000000) + ns = us * int64(1000) + } + if tv != 0 { + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: s, + 1: us, + } + v3 = bp + } else { + v3 = uintptr(0) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_select), int64(n), int64(rfds), int64(wfds), int64(efds), int64(v3), 0)))) +} + +var _all_mask = [1]uint64{ + 0: -Uint64FromUint64(1), +} + +var _app_mask = [1]uint64{ + 0: uint64(0xfffffffc7fffffff), +} + +func X__block_all_sigs(tls *TLS, set uintptr) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_BLOCK)), int64(uintptr(unsafe.Pointer(&_all_mask))), int64(set), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) +} + +func X__block_app_sigs(tls *TLS, set uintptr) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_BLOCK)), int64(uintptr(unsafe.Pointer(&_app_mask))), int64(set), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) +} + +func X__restore_sigs(tls *TLS, set uintptr) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_SETMASK)), int64(set), int64(Int32FromInt32(0)), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) +} + +func Xgetitimer(tls *TLS, which int32, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v which=%v old=%v, (%v:)", tls, which, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var r int32 + var _ /* old32 at bp+0 */ [4]int64 + _ = r + if uint64(8) > uint64(8) { + r = int32(X__syscall2(tls, int64(SYS_getitimer), int64(which), int64(bp))) + if !(r != 0) { + (*Titimerval)(unsafe.Pointer(old)).Fit_interval.Ftv_sec = (**(**[4]int64)(__ccgo_up(bp)))[0] + (*Titimerval)(unsafe.Pointer(old)).Fit_interval.Ftv_usec = (**(**[4]int64)(__ccgo_up(bp)))[int32(1)] + (*Titimerval)(unsafe.Pointer(old)).Fit_value.Ftv_sec = (**(**[4]int64)(__ccgo_up(bp)))[int32(2)] + (*Titimerval)(unsafe.Pointer(old)).Fit_value.Ftv_usec = (**(**[4]int64)(__ccgo_up(bp)))[int32(3)] + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getitimer), int64(which), int64(old))))) +} + +func Xkill(tls *TLS, pid Tpid_t, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v pid=%v sig=%v, (%v:)", tls, pid, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_kill), int64(pid), int64(sig))))) +} + +func Xkillpg(tls *TLS, pgid Tpid_t, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v pgid=%v sig=%v, (%v:)", tls, pgid, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + if pgid < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + return Xkill(tls, -pgid, sig) +} + +func Xpsiginfo(tls *TLS, si uintptr, msg uintptr) { + if __ccgo_strace { + trc("tls=%v si=%v msg=%v, (%v:)", tls, si, msg, origin(2)) + } + Xpsignal(tls, (*Tsiginfo_t)(unsafe.Pointer(si)).Fsi_signo, msg) +} + +func Xpsignal(tls *TLS, sig int32, msg uintptr) { + if __ccgo_strace { + trc("tls=%v sig=%v msg=%v, (%v:)", tls, sig, msg, origin(2)) + } + bp := tls.Alloc(32) + defer tls.Free(32) + var __need_unlock, old_errno, old_mode, v1 int32 + var f, old_locale, s, v2, v3 uintptr + _, _, _, _, _, _, _, _, _ = __need_unlock, f, old_errno, old_locale, old_mode, s, v1, v2, v3 + f = uintptr(unsafe.Pointer(&X__stderr_FILE)) + s = Xstrsignal(tls, sig) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + /* Save stderr's orientation and encoding rule, since psignal is not + * permitted to change them. Save errno and restore it if there is no + * error since fprintf might change it even on success but psignal is + * not permitted to do so. */ + old_locale = (*TFILE)(unsafe.Pointer(f)).Flocale + old_mode = (*TFILE)(unsafe.Pointer(f)).Fmode + old_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + if msg != 0 { + v2 = msg + } else { + v2 = __ccgo_ts + } + if msg != 0 { + v3 = __ccgo_ts + 355 + } else { + v3 = __ccgo_ts + } + if Xfprintf(tls, f, __ccgo_ts+1089, VaList(bp+8, v2, v3, s)) >= 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + } + (*TFILE)(unsafe.Pointer(f)).Fmode = old_mode + (*TFILE)(unsafe.Pointer(f)).Flocale = old_locale + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xraise(tls *TLS, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v sig=%v, (%v:)", tls, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var ret int32 + var _ /* set at bp+0 */ Tsigset_t + _ = ret + X__block_app_sigs(tls, bp) + ret = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_tkill), int64((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid), int64(sig))))) + X__restore_sigs(tls, bp) + return ret +} + +/* These functions will not work, but suffice for targets where the + * kernel sigaction structure does not actually use sa_restorer. */ +func X__restore(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func X__restore_rt(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xsetitimer(tls *TLS, which int32, new1 uintptr, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v which=%v new1=%v old=%v, (%v:)", tls, which, new1, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var is, vs Ttime_t + var ius, vus int64 + var r int32 + var _ /* old32 at bp+32 */ [4]int64 + _, _, _, _, _ = is, ius, r, vs, vus + if uint64(8) > uint64(8) { + is = (*Titimerval)(unsafe.Pointer(new1)).Fit_interval.Ftv_sec + vs = (*Titimerval)(unsafe.Pointer(new1)).Fit_value.Ftv_sec + ius = (*Titimerval)(unsafe.Pointer(new1)).Fit_interval.Ftv_usec + vus = (*Titimerval)(unsafe.Pointer(new1)).Fit_value.Ftv_usec + if !!((Uint64FromInt64(is)+Uint64FromUint64(0x80000000))>>Int32FromInt32(32) != 0) || !!((Uint64FromInt64(vs)+Uint64FromUint64(0x80000000))>>Int32FromInt32(32) != 0) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } + *(*[4]int64)(unsafe.Pointer(bp)) = [4]int64{ + 0: is, + 1: ius, + 2: vs, + 3: vus, + } + r = int32(X__syscall3(tls, int64(SYS_setitimer), int64(which), int64(bp), int64(bp+32))) + if !(r != 0) && old != 0 { + (*Titimerval)(unsafe.Pointer(old)).Fit_interval.Ftv_sec = (**(**[4]int64)(__ccgo_up(bp + 32)))[0] + (*Titimerval)(unsafe.Pointer(old)).Fit_interval.Ftv_usec = (**(**[4]int64)(__ccgo_up(bp + 32)))[int32(1)] + (*Titimerval)(unsafe.Pointer(old)).Fit_value.Ftv_sec = (**(**[4]int64)(__ccgo_up(bp + 32)))[int32(2)] + (*Titimerval)(unsafe.Pointer(old)).Fit_value.Ftv_usec = (**(**[4]int64)(__ccgo_up(bp + 32)))[int32(3)] + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_setitimer), int64(which), int64(new1), int64(old))))) +} + +const __restore = 0 + +type Tk_sigaction = struct { + Fhandler uintptr + Fflags uint64 + Frestorer uintptr + Fmask [2]uint32 +} + +var _unmask_done int32 +var _handler_set [1]uint64 + +func X__get_handler_set(tls *TLS, set uintptr) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + } + Xmemcpy(tls, set, uintptr(unsafe.Pointer(&_handler_set)), uint64(8)) +} + +func X__libc_sigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v sig=%v sa=%v old=%v, (%v:)", tls, sig, sa, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var r int32 + var v1, v3 uintptr + var v2 int64 + var _ /* ksa at bp+8 */ Tk_sigaction + var _ /* ksa_old at bp+40 */ Tk_sigaction + _, _, _, _ = r, v1, v2, v3 + if sa != 0 { + if uint64(*(*uintptr)(unsafe.Pointer(sa))) > uint64(1) { + v1 = uintptr(unsafe.Pointer(&_handler_set)) + uintptr(Uint64FromInt32(sig-Int32FromInt32(1))/(Uint64FromInt32(8)*Uint64FromInt64(8)))*8 + v2 = Int64FromUint64(uint64(1) << (Uint64FromInt32(sig-Int32FromInt32(1)) % (Uint64FromInt32(8) * Uint64FromInt64(8)))) + if Uint64FromInt64(8) == Uint64FromInt64(4) { + // __asm__ __volatile__( + // + // "lock ; or %1, %0" + // : "=m"(*p) : "r"(v) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 48, __ccgo_ts+1504) + } else { + // __asm__ __volatile__( + // + // "lock ; or %1, %0" + // : "=m"(*p) : "r"(v) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 64, __ccgo_ts+1504) + } + /* If pthread_create has not yet been called, + * implementation-internal signals might not + * yet have been unblocked. They must be + * unblocked before any signal handler is + * installed, so that an application cannot + * receive an illegal sigset_t (with them + * blocked) as part of the ucontext_t passed + * to the signal handler. */ + if !(X__libc.Fthreaded != 0) && !(_unmask_done != 0) { + *(*[1]uint64)(unsafe.Pointer(bp)) = [1]uint64{ + 0: Uint64FromUint64(3) << (Int32FromInt32(32) * BoolInt32(Uint64FromInt64(8) > Uint64FromInt32(4))), + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_UNBLOCK)), int64(bp), int64(Int32FromInt32(0)), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) + _unmask_done = int32(1) + } + if !((*Tsigaction)(unsafe.Pointer(sa)).Fsa_flags&Int32FromInt32(SA_RESTART) != 0) { + // __asm__ __volatile__( + // + // "mov %1, %0 ; lock ; orl $0,(%%rsp)" + // : "=m"(*p) : "r"(x) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 88, __ccgo_ts+1504) + } + } + (**(**Tk_sigaction)(__ccgo_up(bp + 8))).Fhandler = *(*uintptr)(unsafe.Pointer(sa)) + (**(**Tk_sigaction)(__ccgo_up(bp + 8))).Fflags = Uint64FromInt32((*Tsigaction)(unsafe.Pointer(sa)).Fsa_flags) + (**(**Tk_sigaction)(__ccgo_up(bp + 8))).Fflags |= uint64(SA_RESTORER) + if (*Tsigaction)(unsafe.Pointer(sa)).Fsa_flags&int32(SA_SIGINFO) != 0 { + v1 = __ccgo_fp(X__restore_rt) + } else { + v1 = __ccgo_fp(X__restore_rt) + } + (**(**Tk_sigaction)(__ccgo_up(bp + 8))).Frestorer = v1 + Xmemcpy(tls, bp+8+24, sa+8, Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))) + } + if sa != 0 { + v1 = bp + 8 + } else { + v1 = uintptr(0) + } + if old != 0 { + v3 = bp + 40 + } else { + v3 = uintptr(0) + } + r = int32(X__syscall4(tls, int64(SYS_rt_sigaction), int64(sig), int64(v1), int64(v3), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)))) + if old != 0 && !(r != 0) { + *(*uintptr)(unsafe.Pointer(old)) = (**(**Tk_sigaction)(__ccgo_up(bp + 40))).Fhandler + (*Tsigaction)(unsafe.Pointer(old)).Fsa_flags = Int32FromUint64((**(**Tk_sigaction)(__ccgo_up(bp + 40))).Fflags) + Xmemcpy(tls, old+8, bp+40+24, Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func X__sigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v sig=%v sa=%v old=%v, (%v:)", tls, sig, sa, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r int32 + var _ /* set at bp+0 */ [1]uint64 + _ = r + if Uint32FromInt32(sig)-uint32(32) < uint32(3) || Uint32FromInt32(sig)-uint32(1) >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + /* Doing anything with the disposition of SIGABRT requires a lock, + * so that it cannot be changed while abort is terminating the + * process and so any change made by abort can't be observed. */ + if sig == int32(SIGABRT) { + X__block_all_sigs(tls, bp) + ___lock(tls, uintptr(unsafe.Pointer(&X__abort_lock))) + } + r = X__libc_sigaction(tls, sig, sa, old) + if sig == int32(SIGABRT) { + ___unlock(tls, uintptr(unsafe.Pointer(&X__abort_lock))) + X__restore_sigs(tls, bp) + } + return r +} + +func Xsigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v sig=%v sa=%v old=%v, (%v:)", tls, sig, sa, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__sigaction(tls, sig, sa, old) +} + +func Xsigaddset(tls *TLS, set uintptr, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v sig=%v, (%v:)", tls, set, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uint32 + _ = s + s = Uint32FromInt32(sig - int32(1)) + if s >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) || Uint32FromInt32(sig)-uint32(32) < uint32(3) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + **(**uint64)(__ccgo_up(set + uintptr(uint64(s/uint32(8))/uint64(8))*8)) |= uint64(1) << (uint64(s) & (Uint64FromInt32(8)*Uint64FromInt64(8) - Uint64FromInt32(1))) + return 0 +} + +func Xsigaltstack(tls *TLS, ss uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ss=%v old=%v, (%v:)", tls, ss, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + if ss != 0 { + if !((*Tstack_t)(unsafe.Pointer(ss)).Fss_flags&Int32FromInt32(SS_DISABLE) != 0) && (*Tstack_t)(unsafe.Pointer(ss)).Fss_size < uint64(MINSIGSTKSZ) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return -int32(1) + } + if (*Tstack_t)(unsafe.Pointer(ss)).Fss_flags&int32(SS_ONSTACK) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_sigaltstack), int64(ss), int64(old))))) +} + +const SST_SIZE = 8 + +func Xsigandset(tls *TLS, dest uintptr, left uintptr, right uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v dest=%v left=%v right=%v, (%v:)", tls, dest, left, right, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var d, l, r uintptr + var i uint64 + _, _, _, _ = d, i, l, r + i = uint64(0) + d = dest + l = left + r = right + for { + if !(i < Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))/Uint64FromInt64(8)) { + break + } + **(**uint64)(__ccgo_up(d + uintptr(i)*8)) = **(**uint64)(__ccgo_up(l + uintptr(i)*8)) & **(**uint64)(__ccgo_up(r + uintptr(i)*8)) + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +func Xsigdelset(tls *TLS, set uintptr, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v sig=%v, (%v:)", tls, set, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uint32 + _ = s + s = Uint32FromInt32(sig - int32(1)) + if s >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) || Uint32FromInt32(sig)-uint32(32) < uint32(3) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + **(**uint64)(__ccgo_up(set + uintptr(uint64(s/uint32(8))/uint64(8))*8)) &= ^(Uint64FromUint64(1) << (uint64(s) & (Uint64FromInt32(8)*Uint64FromInt64(8) - Uint64FromInt32(1)))) + return 0 +} + +func Xsigemptyset(tls *TLS, set uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**uint64)(__ccgo_up(set)) = uint64(0) + if Bool(uint64(8) == uint64(4)) || Bool(int32(_NSIG) > int32(65)) { + **(**uint64)(__ccgo_up(set + 1*8)) = uint64(0) + } + if Bool(uint64(8) == uint64(4)) && Bool(int32(_NSIG) > int32(65)) { + **(**uint64)(__ccgo_up(set + 2*8)) = uint64(0) + **(**uint64)(__ccgo_up(set + 3*8)) = uint64(0) + } + return 0 +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xsigfillset(tls *TLS, set uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**uint64)(__ccgo_up(set)) = uint64(0xfffffffc7fffffff) + if int32(_NSIG) > int32(65) { + **(**uint64)(__ccgo_up(set + 1*8)) = uint64(0xffffffffffffffff) + } + return 0 +} + +func Xsigisemptyset(tls *TLS, set uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i Tsize_t + _ = i + i = uint64(0) + for { + if !(i < Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))/Uint64FromInt64(8)) { + break + } + if **(**uint64)(__ccgo_up(set + uintptr(i)*8)) != 0 { + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + return int32(1) +} + +func Xsigismember(tls *TLS, set uintptr, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v sig=%v, (%v:)", tls, set, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uint32 + _ = s + s = Uint32FromInt32(sig - int32(1)) + if s >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) { + return 0 + } + return BoolInt32(!!(**(**uint64)(__ccgo_up(set + uintptr(uint64(s/uint32(8))/uint64(8))*8))&(Uint64FromUint64(1)<<(uint64(s)&(Uint64FromInt32(8)*Uint64FromInt64(8)-Uint64FromInt32(1)))) != 0)) +} + +func Xsigorset(tls *TLS, dest uintptr, left uintptr, right uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v dest=%v left=%v right=%v, (%v:)", tls, dest, left, right, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var d, l, r uintptr + var i uint64 + _, _, _, _ = d, i, l, r + i = uint64(0) + d = dest + l = left + r = right + for { + if !(i < Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))/Uint64FromInt64(8)) { + break + } + **(**uint64)(__ccgo_up(d + uintptr(i)*8)) = **(**uint64)(__ccgo_up(l + uintptr(i)*8)) | **(**uint64)(__ccgo_up(r + uintptr(i)*8)) + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +func Xsigpending(tls *TLS, set uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_rt_sigpending), int64(set), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)))))) +} + +func Xsigprocmask(tls *TLS, how int32, set uintptr, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v how=%v set=%v old=%v, (%v:)", tls, how, set, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = _pthread_sigmask(tls, how, set, old) + if !(r != 0) { + return r + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = r + return -int32(1) +} + +func Xsigqueue(tls *TLS, pid Tpid_t, sig int32, value Tsigval) (r1 int32) { + if __ccgo_strace { + trc("tls=%v pid=%v sig=%v value=%v, (%v:)", tls, pid, sig, value, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(256) + defer tls.Free(256) + var r int32 + var _ /* set at bp+128 */ Tsigset_t + var _ /* si at bp+0 */ Tsiginfo_t + _ = r + Xmemset(tls, bp, 0, uint64(128)) + (**(**Tsiginfo_t)(__ccgo_up(bp))).Fsi_signo = sig + (**(**Tsiginfo_t)(__ccgo_up(bp))).Fsi_code = -int32(1) + *(*Tsigval)(unsafe.Pointer(bp + 16 + 8)) = value + *(*Tuid_t)(unsafe.Pointer(bp + 16 + 4)) = Xgetuid(tls) + X__block_app_sigs(tls, bp+128) + *(*Tpid_t)(unsafe.Pointer(bp + 16)) = Xgetpid(tls) + r = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_rt_sigqueueinfo), int64(pid), int64(sig), int64(bp))))) + X__restore_sigs(tls, bp+128) + return r +} + +func X__libc_current_sigrtmax(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int32FromInt32(_NSIG) - Int32FromInt32(1) +} + +func X__libc_current_sigrtmin(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(35) +} + +type t__jmp_buf = [8]uint64 + +type Tjmp_buf = [1]t__jmp_buf_tag + +type t__jmp_buf_tag = struct { + F__jb t__jmp_buf + F__fl uint64 + F__ss [16]uint64 +} + +type Tsigjmp_buf = [1]t__jmp_buf_tag + +func X__sigsetjmp_tail(tls *TLS, jb uintptr, ret int32) (r int32) { + if __ccgo_strace { + trc("tls=%v jb=%v ret=%v, (%v:)", tls, jb, ret, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p, v1, v2 uintptr + _, _, _ = p, v1, v2 + p = jb + 72 + if ret != 0 { + v1 = p + } else { + v1 = uintptr(0) + } + if ret != 0 { + v2 = uintptr(0) + } else { + v2 = p + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_SETMASK)), int64(v1), int64(v2), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) + return ret +} + +func Xsigsuspend(tls *TLS, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v, (%v:)", tls, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_rt_sigsuspend), int64(mask), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), 0, 0, 0, 0)))) +} + +func _do_sigtimedwait(tls *TLS, mask uintptr, si uintptr, ts uintptr) (r int32) { + return int32(___syscall_cp(tls, int64(SYS_rt_sigtimedwait), int64(mask), int64(si), int64(ts), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), 0, 0)) +} + +func Xsigtimedwait(tls *TLS, mask uintptr, si uintptr, timeout uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v si=%v timeout=%v, (%v:)", tls, mask, si, timeout, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + for cond := true; cond; cond = ret == -int32(EINTR) { + ret = _do_sigtimedwait(tls, mask, si, timeout) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) +} + +func Xsigwait(tls *TLS, mask uintptr, sig uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v sig=%v, (%v:)", tls, mask, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* si at bp+0 */ Tsiginfo_t + if Xsigtimedwait(tls, mask, bp, uintptr(0)) < 0 { + return -int32(1) + } + **(**int32)(__ccgo_up(sig)) = (**(**Tsiginfo_t)(__ccgo_up(bp))).Fsi_signo + return 0 +} + +func Xsigwaitinfo(tls *TLS, mask uintptr, si uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v si=%v, (%v:)", tls, mask, si, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsigtimedwait(tls, mask, si, uintptr(0)) +} + +func X__fxstat(tls *TLS, ver int32, fd int32, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v fd=%v buf=%v, (%v:)", tls, ver, fd, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfstat(tls, fd, buf) +} + +func X__fxstatat(tls *TLS, ver int32, fd int32, path uintptr, buf uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v fd=%v path=%v buf=%v flag=%v, (%v:)", tls, ver, fd, path, buf, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfstatat(tls, fd, path, buf, flag) +} + +func X__lxstat(tls *TLS, ver int32, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v path=%v buf=%v, (%v:)", tls, ver, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlstat(tls, path, buf) +} + +func X__xstat(tls *TLS, ver int32, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v path=%v buf=%v, (%v:)", tls, ver, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstat(tls, path, buf) +} + +func X__xmknod(tls *TLS, ver int32, path uintptr, mode Tmode_t, dev uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v path=%v mode=%v dev=%v, (%v:)", tls, ver, path, mode, dev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmknod(tls, path, mode, **(**Tdev_t)(__ccgo_up(dev))) +} + +func X__xmknodat(tls *TLS, ver int32, fd int32, path uintptr, mode Tmode_t, dev uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v fd=%v path=%v mode=%v dev=%v, (%v:)", tls, ver, fd, path, mode, dev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmknodat(tls, fd, path, mode, **(**Tdev_t)(__ccgo_up(dev))) +} + +func Xchmod(tls *TLS, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v, (%v:)", tls, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_chmod), int64(path), Int64FromUint32(mode))))) +} + +func Xfchmod(tls *TLS, fd int32, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v mode=%v, (%v:)", tls, fd, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ret int32 + var _ /* buf at bp+0 */ [27]int8 + _ = ret + ret = int32(X__syscall2(tls, int64(SYS_fchmod), int64(fd), Int64FromUint32(mode))) + if ret != -int32(EBADF) || X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFD))) < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + X__procfdname(tls, bp, Uint32FromInt32(fd)) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_chmod), int64(bp), Int64FromUint32(mode))))) +} + +func Xfchmodat(tls *TLS, fd int32, path uintptr, mode Tmode_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v mode=%v flag=%v, (%v:)", tls, fd, path, mode, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(176) + defer tls.Free(176) + var fd2, ret, v1 int32 + var _ /* proc at bp+144 */ [27]int8 + var _ /* st at bp+0 */ Tstat + _, _, _ = fd2, ret, v1 + if !(flag != 0) { + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fchmodat), int64(fd), int64(path), Int64FromUint32(mode))))) + } + ret = int32(X__syscall4(tls, int64(SYS_fchmodat2), int64(fd), int64(path), Int64FromUint32(mode), int64(flag))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + if flag != int32(AT_SYMLINK_NOFOLLOW) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + if Xfstatat(tls, fd, path, bp, flag) != 0 { + return -int32(1) + } + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFLNK) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } + v1 = int32(X__syscall3(tls, int64(SYS_openat), int64(fd), int64(path), int64(Int32FromInt32(O_RDONLY)|Int32FromInt32(O_PATH)|Int32FromInt32(O_NOFOLLOW)|Int32FromInt32(O_NOCTTY)|Int32FromInt32(O_CLOEXEC)))) + fd2 = v1 + if v1 < 0 { + if fd2 == -int32(ELOOP) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(fd2))) + } + X__procfdname(tls, bp+144, Uint32FromInt32(fd2)) + ret = Xstat(tls, bp+144, bp) + if !(ret != 0) { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFLNK) { + ret = int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } else { + ret = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fchmodat), int64(-Int32FromInt32(100)), int64(bp+144), Int64FromUint32(mode))))) + } + } + X__syscall1(tls, int64(SYS_close), int64(fd2)) + return ret +} + +func X__fstat(tls *TLS, fd int32, st uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v st=%v, (%v:)", tls, fd, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + if fd < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EBADF)))) + } + return X__fstatat(tls, fd, __ccgo_ts, st, int32(AT_EMPTY_PATH)) +} + +func Xfstat(tls *TLS, fd int32, st uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v st=%v, (%v:)", tls, fd, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fstat(tls, fd, st) +} + +type Tstatx1 = struct { + Fstx_mask Tuint32_t + Fstx_blksize Tuint32_t + Fstx_attributes Tuint64_t + Fstx_nlink Tuint32_t + Fstx_uid Tuint32_t + Fstx_gid Tuint32_t + Fstx_mode Tuint16_t + Fpad1 Tuint16_t + Fstx_ino Tuint64_t + Fstx_size Tuint64_t + Fstx_blocks Tuint64_t + Fstx_attributes_mask Tuint64_t + Fstx_atime struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + Fpad Tint32_t + } + Fstx_btime struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + Fpad Tint32_t + } + Fstx_ctime struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + Fpad Tint32_t + } + Fstx_mtime struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + Fpad Tint32_t + } + Fstx_rdev_major Tuint32_t + Fstx_rdev_minor Tuint32_t + Fstx_dev_major Tuint32_t + Fstx_dev_minor Tuint32_t + Fspare [14]Tuint64_t +} + +func _fstatat_statx(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var ret int32 + var _ /* stx at bp+0 */ Tstatx1 + _ = ret + flag = flag | int32(AT_NO_AUTOMOUNT) + ret = int32(X__syscall5(tls, int64(SYS_statx), int64(fd), int64(path), int64(flag), int64(Int32FromInt32(0x7ff)), int64(bp))) + if ret != 0 { + return ret + } + **(**Tstat)(__ccgo_up(st)) = Tstat{ + Fst_dev: uint64(uint64((**(**Tstatx1)(__ccgo_up(bp))).Fstx_dev_major)&Uint64FromUint64(0xfffff000)<= 0 && !(**(**int8)(__ccgo_up(path)) != 0) { + ret = int32(X__syscall2(tls, int64(SYS_fstat), int64(fd), int64(bp))) + if ret == -int32(EBADF) && X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFD))) >= 0 { + ret = int32(X__syscall4(tls, int64(SYS_newfstatat), int64(fd), int64(path), int64(bp), int64(flag))) + if ret == -int32(EINVAL) { + X__procfdname(tls, bp+144, Uint32FromInt32(fd)) + ret = int32(X__syscall2(tls, int64(SYS_stat), int64(bp+144), int64(bp))) + } + } + } else { + if (fd == -int32(100) || int32(**(**int8)(__ccgo_up(path))) == int32('/')) && flag == int32(AT_SYMLINK_NOFOLLOW) { + ret = int32(X__syscall2(tls, int64(SYS_lstat), int64(path), int64(bp))) + } else { + if (fd == -int32(100) || int32(**(**int8)(__ccgo_up(path))) == int32('/')) && !(flag != 0) { + ret = int32(X__syscall2(tls, int64(SYS_stat), int64(path), int64(bp))) + } else { + ret = int32(X__syscall4(tls, int64(SYS_newfstatat), int64(fd), int64(path), int64(bp), int64(flag))) + } + } + } + if ret != 0 { + return ret + } + **(**Tstat)(__ccgo_up(st)) = Tstat{ + Fst_dev: (**(**Tkstat)(__ccgo_up(bp))).Fst_dev, + Fst_ino: (**(**Tkstat)(__ccgo_up(bp))).Fst_ino, + Fst_nlink: (**(**Tkstat)(__ccgo_up(bp))).Fst_nlink, + Fst_mode: (**(**Tkstat)(__ccgo_up(bp))).Fst_mode, + Fst_uid: (**(**Tkstat)(__ccgo_up(bp))).Fst_uid, + Fst_gid: (**(**Tkstat)(__ccgo_up(bp))).Fst_gid, + Fst_rdev: (**(**Tkstat)(__ccgo_up(bp))).Fst_rdev, + Fst_size: (**(**Tkstat)(__ccgo_up(bp))).Fst_size, + Fst_blksize: (**(**Tkstat)(__ccgo_up(bp))).Fst_blksize, + Fst_blocks: (**(**Tkstat)(__ccgo_up(bp))).Fst_blocks, + Fst_atim: Ttimespec{ + Ftv_sec: (**(**Tkstat)(__ccgo_up(bp))).Fst_atime_sec, + Ftv_nsec: (**(**Tkstat)(__ccgo_up(bp))).Fst_atime_nsec, + }, + Fst_mtim: Ttimespec{ + Ftv_sec: (**(**Tkstat)(__ccgo_up(bp))).Fst_mtime_sec, + Ftv_nsec: (**(**Tkstat)(__ccgo_up(bp))).Fst_mtime_nsec, + }, + Fst_ctim: Ttimespec{ + Ftv_sec: (**(**Tkstat)(__ccgo_up(bp))).Fst_ctime_sec, + Ftv_nsec: (**(**Tkstat)(__ccgo_up(bp))).Fst_ctime_nsec, + }, + } + return 0 +} + +func X__fstatat(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v st=%v flag=%v, (%v:)", tls, fd, path, st, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + if uint64(8) < uint64(8) { + ret = _fstatat_statx(tls, fd, path, st, flag) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + } + ret = _fstatat_kstat(tls, fd, path, st, flag) + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) +} + +func Xfstatat(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v st=%v flag=%v, (%v:)", tls, fd, path, st, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fstatat(tls, fd, path, st, flag) +} + +func Xfutimens(tls *TLS, fd int32, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v times=%v, (%v:)", tls, fd, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xutimensat(tls, fd, uintptr(0), times, 0) +} + +func X__futimesat(tls *TLS, dirfd int32, pathname uintptr, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dirfd=%v pathname=%v times=%v, (%v:)", tls, dirfd, pathname, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var v2 uintptr + var _ /* ts at bp+0 */ [2]Ttimespec + _, _ = i, v2 + if times != 0 { + i = 0 + for { + if !(i < int32(2)) { + break + } + if Uint64FromInt64((**(**Ttimeval)(__ccgo_up(times + uintptr(i)*16))).Ftv_usec) >= uint64(1000000) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + (**(**[2]Ttimespec)(__ccgo_up(bp)))[i].Ftv_sec = (**(**Ttimeval)(__ccgo_up(times + uintptr(i)*16))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[i].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(times + uintptr(i)*16))).Ftv_usec * int64(1000) + goto _1 + _1: + ; + i = i + 1 + } + } + if times != 0 { + v2 = bp + } else { + v2 = uintptr(0) + } + return Xutimensat(tls, dirfd, pathname, v2, 0) +} + +func Xfutimesat(tls *TLS, dirfd int32, pathname uintptr, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dirfd=%v pathname=%v times=%v, (%v:)", tls, dirfd, pathname, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__futimesat(tls, dirfd, pathname, times) +} + +func Xlchmod(tls *TLS, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v, (%v:)", tls, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfchmodat(tls, -int32(100), path, mode, int32(AT_SYMLINK_NOFOLLOW)) +} + +func Xlstat(tls *TLS, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v buf=%v, (%v:)", tls, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfstatat(tls, -int32(100), path, buf, int32(AT_SYMLINK_NOFOLLOW)) +} + +func Xmkdir(tls *TLS, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v, (%v:)", tls, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_mkdir), int64(path), Int64FromUint32(mode))))) +} + +func Xmkdirat(tls *TLS, fd int32, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v mode=%v, (%v:)", tls, fd, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mkdirat), int64(fd), int64(path), Int64FromUint32(mode))))) +} + +func Xmkfifo(tls *TLS, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v, (%v:)", tls, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmknod(tls, path, mode|uint32(S_IFIFO), uint64(0)) +} + +func Xmkfifoat(tls *TLS, fd int32, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v mode=%v, (%v:)", tls, fd, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmknodat(tls, fd, path, mode|uint32(S_IFIFO), uint64(0)) +} + +func Xmknod(tls *TLS, path uintptr, mode Tmode_t, dev Tdev_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v dev=%v, (%v:)", tls, path, mode, dev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mknod), int64(path), Int64FromUint32(mode), Int64FromUint64(dev))))) +} + +func Xmknodat(tls *TLS, fd int32, path uintptr, mode Tmode_t, dev Tdev_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v mode=%v dev=%v, (%v:)", tls, fd, path, mode, dev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_mknodat), int64(fd), int64(path), Int64FromUint32(mode), Int64FromUint64(dev))))) +} + +func Xstat(tls *TLS, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v buf=%v, (%v:)", tls, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfstatat(tls, -int32(100), path, buf, 0) +} + +func ___statfs(tls *TLS, path uintptr, buf uintptr) (r int32) { + **(**Tstatfs)(__ccgo_up(buf)) = Tstatfs{} + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_statfs), int64(path), int64(buf))))) +} + +func Xfstatfs(tls *TLS, fd int32, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v, (%v:)", tls, fd, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tstatfs)(__ccgo_up(buf)) = Tstatfs{} + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_fstatfs), int64(fd), int64(buf))))) +} + +func _fixup(tls *TLS, out uintptr, in uintptr) { + var v1 uint64 + _ = v1 + **(**Tstatvfs)(__ccgo_up(out)) = Tstatvfs{} + (*Tstatvfs)(unsafe.Pointer(out)).Ff_bsize = (*Tstatfs)(unsafe.Pointer(in)).Ff_bsize + if (*Tstatfs)(unsafe.Pointer(in)).Ff_frsize != 0 { + v1 = (*Tstatfs)(unsafe.Pointer(in)).Ff_frsize + } else { + v1 = (*Tstatfs)(unsafe.Pointer(in)).Ff_bsize + } + (*Tstatvfs)(unsafe.Pointer(out)).Ff_frsize = v1 + (*Tstatvfs)(unsafe.Pointer(out)).Ff_blocks = (*Tstatfs)(unsafe.Pointer(in)).Ff_blocks + (*Tstatvfs)(unsafe.Pointer(out)).Ff_bfree = (*Tstatfs)(unsafe.Pointer(in)).Ff_bfree + (*Tstatvfs)(unsafe.Pointer(out)).Ff_bavail = (*Tstatfs)(unsafe.Pointer(in)).Ff_bavail + (*Tstatvfs)(unsafe.Pointer(out)).Ff_files = (*Tstatfs)(unsafe.Pointer(in)).Ff_files + (*Tstatvfs)(unsafe.Pointer(out)).Ff_ffree = (*Tstatfs)(unsafe.Pointer(in)).Ff_ffree + (*Tstatvfs)(unsafe.Pointer(out)).Ff_favail = (*Tstatfs)(unsafe.Pointer(in)).Ff_ffree + (*Tstatvfs)(unsafe.Pointer(out)).Ff_fsid = Uint64FromInt32(**(**int32)(__ccgo_up(in + 56))) + (*Tstatvfs)(unsafe.Pointer(out)).Ff_flag = (*Tstatfs)(unsafe.Pointer(in)).Ff_flags + (*Tstatvfs)(unsafe.Pointer(out)).Ff_namemax = (*Tstatfs)(unsafe.Pointer(in)).Ff_namelen + (*Tstatvfs)(unsafe.Pointer(out)).Ff_type = uint32((*Tstatfs)(unsafe.Pointer(in)).Ff_type) +} + +func Xstatvfs(tls *TLS, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v buf=%v, (%v:)", tls, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* kbuf at bp+0 */ Tstatfs + if ___statfs(tls, path, bp) < 0 { + return -int32(1) + } + _fixup(tls, buf, bp) + return 0 +} + +func Xfstatvfs(tls *TLS, fd int32, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v, (%v:)", tls, fd, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* kbuf at bp+0 */ Tstatfs + if Xfstatfs(tls, fd, bp) < 0 { + return -int32(1) + } + _fixup(tls, buf, bp) + return 0 +} + +func Xumask(tls *TLS, mode Tmode_t) (r Tmode_t) { + if __ccgo_strace { + trc("tls=%v mode=%v, (%v:)", tls, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_umask), Int64FromUint32(mode))))) +} + +func Xutimensat(tls *TLS, fd int32, path uintptr, times uintptr, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v times=%v flags=%v, (%v:)", tls, fd, path, times, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var i, r int32 + var tv uintptr + var _ /* tmp at bp+0 */ [4]int64 + _, _, _ = i, r, tv + if times != 0 && (**(**Ttimespec)(__ccgo_up(times))).Ftv_nsec == int64(UTIME_NOW) && (**(**Ttimespec)(__ccgo_up(times + 1*16))).Ftv_nsec == int64(UTIME_NOW) { + times = uintptr(0) + } + r = int32(X__syscall4(tls, int64(SYS_utimensat), int64(fd), int64(path), int64(times), int64(flags))) + if r != -int32(ENOSYS) || flags != 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + tv = uintptr(0) + if times != 0 { + tv = bp + i = 0 + for { + if !(i < int32(2)) { + break + } + if Uint64FromInt64((**(**Ttimespec)(__ccgo_up(times + uintptr(i)*16))).Ftv_nsec) >= uint64(1000000000) { + if (**(**Ttimespec)(__ccgo_up(times + uintptr(i)*16))).Ftv_nsec == int64(UTIME_NOW) || (**(**Ttimespec)(__ccgo_up(times + uintptr(i)*16))).Ftv_nsec == int64(UTIME_OMIT) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(ENOSYS)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + (**(**[4]int64)(__ccgo_up(bp)))[int32(2)*i+0] = (**(**Ttimespec)(__ccgo_up(times + uintptr(i)*16))).Ftv_sec + (**(**[4]int64)(__ccgo_up(bp)))[int32(2)*i+int32(1)] = (**(**Ttimespec)(__ccgo_up(times + uintptr(i)*16))).Ftv_nsec / int64(1000) + goto _1 + _1: + ; + i = i + 1 + } + } + r = int32(X__syscall3(tls, int64(SYS_futimesat), int64(fd), int64(path), int64(tv))) + if r != -int32(ENOSYS) || fd != -int32(100) { + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + r = int32(X__syscall2(tls, int64(SYS_utimes), int64(path), int64(tv))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func X__fclose_ca(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*(*func(*TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fclose1})))(tls, f) +} + +func X__fdopen(tls *TLS, fd int32, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v mode=%v, (%v:)", tls, fd, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var f, v1 uintptr + var flags, v2 int32 + var _ /* wsz at bp+0 */ Twinsize + _, _, _, _ = f, flags, v1, v2 + /* Check for valid initial mode character */ + if !(Xstrchr(tls, __ccgo_ts+1521, int32(**(**int8)(__ccgo_up(mode)))) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + /* Allocate FILE+buffer or fail */ + v1 = Xmalloc(tls, Uint64FromInt64(232)+Uint64FromInt32(UNGET)+Uint64FromInt32(BUFSIZ)) + f = v1 + if !(v1 != 0) { + return uintptr(0) + } + /* Zero-fill only the struct, not the buffer */ + Xmemset(tls, f, 0, uint64(232)) + /* Impose mode restrictions */ + if !(Xstrchr(tls, mode, int32('+')) != 0) { + if int32(**(**int8)(__ccgo_up(mode))) == int32('r') { + v2 = int32(F_NOWR) + } else { + v2 = int32(F_NORD) + } + (*TFILE)(unsafe.Pointer(f)).Fflags = Uint32FromInt32(v2) + } + /* Apply close-on-exec flag */ + if Xstrchr(tls, mode, int32('e')) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + /* Set append mode on fd if opened for append */ + if int32(**(**int8)(__ccgo_up(mode))) == int32('a') { + flags = int32(X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFL)))) + if !(flags&Int32FromInt32(O_APPEND) != 0) { + X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_SETFL)), int64(flags|Int32FromInt32(O_APPEND))) + } + **(**uint32)(__ccgo_up(f)) |= uint32(F_APP) + } + (*TFILE)(unsafe.Pointer(f)).Ffd = fd + (*TFILE)(unsafe.Pointer(f)).Fbuf = f + uintptr(232) + uintptr(UNGET) + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = uint64(BUFSIZ) + /* Activate line buffered mode for terminals */ + (*TFILE)(unsafe.Pointer(f)).Flbf = -int32(1) + if !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_NOWR) != 0) && !(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TIOCGWINSZ)), int64(bp)) != 0) { + (*TFILE)(unsafe.Pointer(f)).Flbf = int32('\n') + } + /* Initialize op ptrs. No problem if some are unneeded. */ + (*TFILE)(unsafe.Pointer(f)).Fread = __ccgo_fp(X__stdio_read) + (*TFILE)(unsafe.Pointer(f)).Fwrite = __ccgo_fp(X__stdio_write) + (*TFILE)(unsafe.Pointer(f)).Fseek = __ccgo_fp(X__stdio_seek) + (*TFILE)(unsafe.Pointer(f)).Fclose1 = __ccgo_fp(X__stdio_close) + if !(X__libc.Fthreaded != 0) { + AtomicStorePInt32(f+140, -int32(1)) + } + /* Add new FILE to open file list */ + return X__ofl_add(tls, f) +} + +func Xfdopen(tls *TLS, fd int32, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v mode=%v, (%v:)", tls, fd, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fdopen(tls, fd, mode) +} + +func X__fmodeflags(tls *TLS, mode uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mode=%v, (%v:)", tls, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var flags int32 + _ = flags + if Xstrchr(tls, mode, int32('+')) != 0 { + flags = int32(O_RDWR) + } else { + if int32(**(**int8)(__ccgo_up(mode))) == int32('r') { + flags = O_RDONLY + } else { + flags = int32(O_WRONLY) + } + } + if Xstrchr(tls, mode, int32('x')) != 0 { + flags = flags | int32(O_EXCL) + } + if Xstrchr(tls, mode, int32('e')) != 0 { + flags = flags | int32(O_CLOEXEC) + } + if int32(**(**int8)(__ccgo_up(mode))) != int32('r') { + flags = flags | int32(O_CREAT) + } + if int32(**(**int8)(__ccgo_up(mode))) == int32('w') { + flags = flags | int32(O_TRUNC) + } + if int32(**(**int8)(__ccgo_up(mode))) == int32('a') { + flags = flags | int32(O_APPEND) + } + return flags +} + +func X__fopen_rb_ca(tls *TLS, filename uintptr, f uintptr, buf uintptr, len1 Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v filename=%v f=%v buf=%v len1=%v, (%v:)", tls, filename, f, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + Xmemset(tls, f, 0, uint64(232)) + (*TFILE)(unsafe.Pointer(f)).Ffd = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_open), int64(filename), int64(Int32FromInt32(O_RDONLY)|Int32FromInt32(O_CLOEXEC)|Int32FromInt32(O_LARGEFILE)))))) + if (*TFILE)(unsafe.Pointer(f)).Ffd < 0 { + return uintptr(0) + } + X__syscall3(tls, int64(SYS_fcntl), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + (*TFILE)(unsafe.Pointer(f)).Fflags = Uint32FromInt32(Int32FromInt32(F_NOWR) | Int32FromInt32(F_PERM)) + (*TFILE)(unsafe.Pointer(f)).Fbuf = buf + uintptr(UNGET) + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = len1 - uint64(UNGET) + (*TFILE)(unsafe.Pointer(f)).Fread = __ccgo_fp(X__stdio_read) + (*TFILE)(unsafe.Pointer(f)).Fseek = __ccgo_fp(X__stdio_seek) + (*TFILE)(unsafe.Pointer(f)).Fclose1 = __ccgo_fp(X__stdio_close) + AtomicStorePInt32(f+140, -int32(1)) + return f +} + +func X__overflow(tls *TLS, f uintptr, _c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v _c=%v, (%v:)", tls, f, _c, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint8 + var v2, v3 uintptr + var _ /* c at bp+0 */ uint8 + _, _, _ = v1, v2, v3 + **(**uint8)(__ccgo_up(bp)) = Uint8FromInt32(_c) + if !((*TFILE)(unsafe.Pointer(f)).Fwend != 0) && X__towrite(tls, f) != 0 { + return -int32(1) + } + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend && Int32FromUint8(**(**uint8)(__ccgo_up(bp))) != (*TFILE)(unsafe.Pointer(f)).Flbf { + v1 = **(**uint8)(__ccgo_up(bp)) + v3 = f + 40 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + **(**uint8)(__ccgo_up(v2)) = v1 + return Int32FromUint8(v1) + } + if (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, bp, uint64(1)) != uint64(1) { + return -int32(1) + } + return Int32FromUint8(**(**uint8)(__ccgo_up(bp))) +} + +func _dummy9(tls *TLS, fd int32) (r int32) { + return fd +} + +func X__stdio_close(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_close), int64(_dummy9(tls, (*TFILE)(unsafe.Pointer(f)).Ffd)))))) +} + +var _dummy_file = uintptr(0) + +func _close_file(tls *TLS, f uintptr) { + if !(f != 0) { + return + } + if AtomicLoadPInt32(f+140) >= 0 { + ___lockfile(tls, f) + } + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + (*(*func(*TLS, uintptr, Toff_t, int32) Toff_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fseek})))(tls, f, int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Frend), int32(1)) + } +} + +func X__stdio_exit(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + var f uintptr + _ = f + f = **(**uintptr)(__ccgo_up(X__ofl_lock(tls))) + for { + if !(f != 0) { + break + } + _close_file(tls, f) + goto _1 + _1: + ; + f = (*TFILE)(unsafe.Pointer(f)).Fnext + } + _close_file(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stdin_used)))) + _close_file(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stdout_used)))) + _close_file(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stderr_used)))) +} + +func X__stdio_exit_needed(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__stdio_exit(tls) +} + +func X__stdio_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v len1=%v, (%v:)", tls, f, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var cnt Tssize_t + var v1 int64 + var v2 int32 + var v3, v4 uintptr + var _ /* iov at bp+0 */ [2]Tiovec + _, _, _, _, _ = cnt, v1, v2, v3, v4 + **(**[2]Tiovec)(__ccgo_up(bp)) = [2]Tiovec{ + 0: { + Fiov_base: buf, + Fiov_len: len1 - BoolUint64(!!((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0)), + }, + 1: { + Fiov_base: (*TFILE)(unsafe.Pointer(f)).Fbuf, + Fiov_len: (*TFILE)(unsafe.Pointer(f)).Fbuf_size, + }, + } + if (**(**[2]Tiovec)(__ccgo_up(bp)))[0].Fiov_len != 0 { + v1 = X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_readv), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(bp), int64(Int32FromInt32(2))))) + } else { + v1 = X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, SYS_read, int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64((**(**[2]Tiovec)(__ccgo_up(bp)))[int32(1)].Fiov_base), Int64FromUint64((**(**[2]Tiovec)(__ccgo_up(bp)))[int32(1)].Fiov_len)))) + } + cnt = v1 + if cnt <= 0 { + if cnt != 0 { + v2 = int32(F_ERR) + } else { + v2 = int32(F_EOF) + } + **(**uint32)(__ccgo_up(f)) |= Uint32FromInt32(v2) + return uint64(0) + } + if Uint64FromInt64(cnt) <= (**(**[2]Tiovec)(__ccgo_up(bp)))[0].Fiov_len { + return Uint64FromInt64(cnt) + } + cnt = Int64FromUint64(uint64(cnt) - (**(**[2]Tiovec)(__ccgo_up(bp)))[0].Fiov_len) + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(cnt) + if (*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0 { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(buf + uintptr(len1-uint64(1)))) = **(**uint8)(__ccgo_up(v3)) + } + return len1 +} + +func X__stdio_seek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lseek(tls, (*TFILE)(unsafe.Pointer(f)).Ffd, off, whence) +} + +func X__stdio_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v len1=%v, (%v:)", tls, f, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var cnt Tssize_t + var iov, v2, v3 uintptr + var iovcnt int32 + var rem Tsize_t + var v5 uint64 + var _ /* iovs at bp+0 */ [2]Tiovec + _, _, _, _, _, _, _ = cnt, iov, iovcnt, rem, v2, v3, v5 + **(**[2]Tiovec)(__ccgo_up(bp)) = [2]Tiovec{ + 0: { + Fiov_base: (*TFILE)(unsafe.Pointer(f)).Fwbase, + Fiov_len: Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)), + }, + 1: { + Fiov_base: buf, + Fiov_len: len1, + }, + } + iov = bp + rem = (**(**Tiovec)(__ccgo_up(iov))).Fiov_len + (**(**Tiovec)(__ccgo_up(iov + 1*16))).Fiov_len + iovcnt = int32(2) + for { + cnt = X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_writev), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(iov), int64(iovcnt)))) + if Uint64FromInt64(cnt) == rem { + (*TFILE)(unsafe.Pointer(f)).Fwend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr((*TFILE)(unsafe.Pointer(f)).Fbuf_size) + v2 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fwbase = v2 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v2 + return len1 + } + if cnt < 0 { + v3 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v3 + v2 = v3 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v2 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v2 + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + if iovcnt == int32(2) { + v5 = uint64(0) + } else { + v5 = len1 - (**(**Tiovec)(__ccgo_up(iov))).Fiov_len + } + return v5 + } + rem = rem - Uint64FromInt64(cnt) + if Uint64FromInt64(cnt) > (**(**Tiovec)(__ccgo_up(iov))).Fiov_len { + cnt = Int64FromUint64(uint64(cnt) - (**(**Tiovec)(__ccgo_up(iov))).Fiov_len) + iov += 16 + iovcnt = iovcnt - 1 + } + (**(**Tiovec)(__ccgo_up(iov))).Fiov_base = (**(**Tiovec)(__ccgo_up(iov))).Fiov_base + uintptr(cnt) + (**(**Tiovec)(__ccgo_up(iov))).Fiov_len -= Uint64FromInt64(cnt) + goto _1 + _1: + } + return r +} + +func X__stdout_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v len1=%v, (%v:)", tls, f, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* wsz at bp+0 */ Twinsize + (*TFILE)(unsafe.Pointer(f)).Fwrite = __ccgo_fp(X__stdio_write) + if !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_SVB) != 0) && X__syscall3(tls, int64(SYS_ioctl), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(Int32FromInt32(TIOCGWINSZ)), int64(bp)) != 0 { + (*TFILE)(unsafe.Pointer(f)).Flbf = -int32(1) + } + return X__stdio_write(tls, f, buf, len1) +} + +func X__toread(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v2 uintptr + var v4 int32 + _, _, _ = v1, v2, v4 + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + } + v2 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v2 + v1 = v2 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NORD) != 0 { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + return -int32(1) + } + v1 = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr((*TFILE)(unsafe.Pointer(f)).Fbuf_size) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_EOF) != 0 { + v4 = -int32(1) + } else { + v4 = 0 + } + return v4 +} + +func X__toread_needs_stdio_exit(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__stdio_exit_needed(tls) +} + +func X__towrite(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NOWR) != 0 { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + return -int32(1) + } + /* Clear read buffer (easier than summoning nasal demons) */ + v1 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + /* Activate write through the buffer. */ + v1 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + (*TFILE)(unsafe.Pointer(f)).Fwend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr((*TFILE)(unsafe.Pointer(f)).Fbuf_size) + return 0 +} + +func X__towrite_needs_stdio_exit(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__stdio_exit_needed(tls) +} + +/* This function assumes it will never be called if there is already + * data buffered for reading. */ + +func X__uflow(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* c at bp+0 */ uint8 + if !(X__toread(tls, f) != 0) && (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fread})))(tls, f, bp, uint64(1)) == uint64(1) { + return Int32FromUint8(**(**uint8)(__ccgo_up(bp))) + } + return -int32(1) +} + +func Xasprintf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvasprintf(tls, s, fmt, ap) + _ = ap + return ret +} + +func Xclearerr(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + var __need_unlock, v1 int32 + _, _ = __need_unlock, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^(Int32FromInt32(F_EOF) | Int32FromInt32(F_ERR))) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xclearerr_unlocked(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + Xclearerr(tls, f) +} + +func Xdprintf(tls *TLS, fd int32, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v fmt=%v va=%v, (%v:)", tls, fd, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvdprintf(tls, fd, fmt, ap) + _ = ap + return ret +} + +const FSETLOCKING_BYCALLER = 2 +const FSETLOCKING_INTERNAL = 1 +const FSETLOCKING_QUERY = 0 + +func X_flushlbf(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xfflush(tls, uintptr(0)) +} + +func X__fsetlocking(tls *TLS, f uintptr, type1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v type1=%v, (%v:)", tls, f, type1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func X__fwriting(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32((*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NORD) != 0 || (*TFILE)(unsafe.Pointer(f)).Fwend != 0) +} + +func X__freading(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32((*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NOWR) != 0 || (*TFILE)(unsafe.Pointer(f)).Frend != 0) +} + +func X__freadable(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(!((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_NORD) != 0)) +} + +func X__fwritable(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(!((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_NOWR) != 0)) +} + +func X__flbf(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32((*TFILE)(unsafe.Pointer(f)).Flbf >= 0) +} + +func X__fbufsize(tls *TLS, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*TFILE)(unsafe.Pointer(f)).Fbuf_size +} + +func X__fpending(tls *TLS, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if (*TFILE)(unsafe.Pointer(f)).Fwend != 0 { + v1 = int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase) + } else { + v1 = 0 + } + return Uint64FromInt64(v1) +} + +func X__fpurge(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v2 uintptr + _, _ = v1, v2 + if !(f != 0) { // libbsd fpurge test fails w/o this. + return int32(1) + } + v2 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v2 + v1 = v2 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + v1 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + return 0 +} + +func Xfpurge(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fpurge(tls, f) +} + +func X__freadahead(tls *TLS, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 { + v1 = int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + } else { + v1 = 0 + } + return Uint64FromInt64(v1) +} + +func X__freadptr(tls *TLS, f uintptr, sizep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v sizep=%v, (%v:)", tls, f, sizep, origin(2)) + defer func() { trc("-> %v", r) }() + } + if (*TFILE)(unsafe.Pointer(f)).Frpos == (*TFILE)(unsafe.Pointer(f)).Frend { + return uintptr(0) + } + **(**Tsize_t)(__ccgo_up(sizep)) = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos)) + return (*TFILE)(unsafe.Pointer(f)).Frpos +} + +func X__freadptrinc(tls *TLS, f uintptr, inc Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v inc=%v, (%v:)", tls, f, inc, origin(2)) + } + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(inc) +} + +func X__fseterr(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) +} + +func _dummy10(tls *TLS, f uintptr) { +} + +func Xfclose(tls *TLS, f uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var __need_unlock, r, v1 int32 + var head uintptr + _, _, _, _ = __need_unlock, head, r, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + r = Xfflush(tls, f) + r = r | (*(*func(*TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fclose1})))(tls, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + /* Past this point, f is closed and any further explict access + * to it is undefined. However, it still exists as an entry in + * the open file list and possibly in the thread's locked files + * list, if it was closed while explicitly locked. Functions + * which process these lists must tolerate dead FILE objects + * (which necessarily have inactive buffer pointers) without + * producing any side effects. */ + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_PERM) != 0 { + return r + } + X__unlist_locked_file(tls, f) + head = X__ofl_lock(tls) + if (*TFILE)(unsafe.Pointer(f)).Fprev != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fprev)).Fnext = (*TFILE)(unsafe.Pointer(f)).Fnext + } + if (*TFILE)(unsafe.Pointer(f)).Fnext != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fnext)).Fprev = (*TFILE)(unsafe.Pointer(f)).Fprev + } + if **(**uintptr)(__ccgo_up(head)) == f { + **(**uintptr)(__ccgo_up(head)) = (*TFILE)(unsafe.Pointer(f)).Fnext + } + X__ofl_unlock(tls) + Xfree(tls, (*TFILE)(unsafe.Pointer(f)).Fgetln_buf) + Xfree(tls, f) + return r +} + +func Xfeof(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, ret, v1 int32 + _, _, _ = __need_unlock, ret, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + ret = BoolInt32(!!((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_EOF) != 0)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return ret +} + +func X_IO_feof_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfeof(tls, f) +} + +func Xfeof_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfeof(tls, f) +} + +func Xferror(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, ret, v1 int32 + _, _, _ = __need_unlock, ret, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + ret = BoolInt32(!!((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_ERR) != 0)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return ret +} + +func X_IO_ferror_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xferror(tls, f) +} + +func Xferror_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xferror(tls, f) +} + +// C documentation +// +// /* stdout.c will override this if linked */ +var _dummy11 = uintptr(0) + +func Xfflush(tls *TLS, f uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var __need_unlock, __need_unlock1, r, v2 int32 + var v4, v5 uintptr + _, _, _, _, _, _ = __need_unlock, __need_unlock1, r, v2, v4, v5 + if !(f != 0) { + r = 0 + if AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stdout_used))) != 0 { + r = r | Xfflush(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stdout_used)))) + } + if AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stderr_used))) != 0 { + r = r | Xfflush(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stderr_used)))) + } + f = **(**uintptr)(__ccgo_up(X__ofl_lock(tls))) + for { + if !(f != 0) { + break + } + if AtomicLoadPInt32(f+140) >= 0 { + v2 = ___lockfile(tls, f) + } else { + v2 = 0 + } + __need_unlock = v2 + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + r = r | Xfflush(tls, f) + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + goto _1 + _1: + ; + f = (*TFILE)(unsafe.Pointer(f)).Fnext + } + X__ofl_unlock(tls) + return r + } + if AtomicLoadPInt32(f+140) >= 0 { + v2 = ___lockfile(tls, f) + } else { + v2 = 0 + } + __need_unlock1 = v2 + /* If writing, flush output */ + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + if !((*TFILE)(unsafe.Pointer(f)).Fwpos != 0) { + if __need_unlock1 != 0 { + ___unlockfile(tls, f) + } + return -int32(1) + } + } + /* If reading, sync position, per POSIX */ + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + (*(*func(*TLS, uintptr, Toff_t, int32) Toff_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fseek})))(tls, f, int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Frend), int32(1)) + } + /* Clear read and write modes */ + v5 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v5 + v4 = v5 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v4 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v4 + v4 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v4 + (*TFILE)(unsafe.Pointer(f)).Frpos = v4 + if __need_unlock1 != 0 { + ___unlockfile(tls, f) + } + return 0 +} + +func Xfflush_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfflush(tls, f) +} + +func _locking_getc(tls *TLS, f uintptr) (r int32) { + var c, v1, v2, v4, v7, v8 int32 + var v10, v5, v6 uintptr + _, _, _, _, _, _, _, _, _ = c, v1, v10, v2, v4, v5, v6, v7, v8 + v1 = 0 + // __asm__ __volatile__ ( + // + // "lock ; cmpxchg %3, %1" + // : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 4, __ccgo_ts+1525) + v2 = v1 + goto _3 +_3: + if v2 != 0 { + ___lockfile(tls, f) + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v1 = X__uflow(tls, f) + } + c = v1 + v2 = 0 + // __asm__ __volatile__( + // + // "xchg %0, %1" + // : "=r"(v), "=m"(*p) : "0"(v) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 22, __ccgo_ts+1525) + v4 = v2 + goto _9 +_9: + if v4&int32(MAYBE_WAITERS) != 0 { + v10 = f + 140 + v7 = int32(1) + v8 = int32(1) + if v8 != 0 { + v8 = int32(FUTEX_PRIVATE) + } + if v7 < Int32FromInt32(0) { + v7 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v10), int64(Int32FromInt32(FUTEX_WAKE)|v8), int64(v7)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v10), int64(Int32FromInt32(FUTEX_WAKE)), int64(v7)) != 0 + } + return c +} + +func Xfgetc(tls *TLS, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f1=%v, (%v:)", tls, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v2, v4 int32 + var v1, v5, v6 uintptr + _, _, _, _, _, _ = l, v1, v2, v4, v5, v6 + v1 = f1 + l = AtomicLoadPInt32(v1 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if (*TFILE)(unsafe.Pointer(v1)).Frpos != (*TFILE)(unsafe.Pointer(v1)).Frend { + v6 = v1 + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = X__uflow(tls, v1) + } + v2 = v4 + goto _3 + } + v2 = _locking_getc(tls, v1) + goto _3 +_3: + return v2 +} + +func Xfgetln(tls *TLS, f uintptr, plen uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v plen=%v, (%v:)", tls, f, plen, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var __need_unlock, v1, v2 int32 + var l, v8 Tssize_t + var ret, z, v3, v4 uintptr + var v6 bool + _, _, _, _, _, _, _, _, _, _ = __need_unlock, l, ret, z, v1, v2, v3, v4, v6, v8 + ret = uintptr(0) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__uflow(tls, f) + } + Xungetc(tls, v2, f) + if v6 = (*TFILE)(unsafe.Pointer(f)).Frend != 0; v6 { + v3 = Xmemchr(tls, (*TFILE)(unsafe.Pointer(f)).Frpos, int32('\n'), Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos))) + z = v3 + } + if v6 && v3 != 0 { + ret = (*TFILE)(unsafe.Pointer(f)).Frpos + z = z + 1 + v3 = z + **(**Tsize_t)(__ccgo_up(plen)) = Uint64FromInt64(int64(v3) - int64(ret)) + (*TFILE)(unsafe.Pointer(f)).Frpos = z + } else { + *(*[1]Tsize_t)(unsafe.Pointer(bp)) = [1]Tsize_t{} + v8 = Xgetline(tls, f+168, bp, f) + l = v8 + if v8 > 0 { + **(**Tsize_t)(__ccgo_up(plen)) = Uint64FromInt64(l) + ret = (*TFILE)(unsafe.Pointer(f)).Fgetln_buf + } + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return ret +} + +func Xfgetpos(tls *TLS, f uintptr, pos uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v pos=%v, (%v:)", tls, f, pos, origin(2)) + defer func() { trc("-> %v", r) }() + } + var off Toff_t + _ = off + off = X__ftello(tls, f) + if off < 0 { + return -int32(1) + } + **(**int64)(__ccgo_up(pos)) = off + return 0 +} + +func Xfgets(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, c, v1, v4 int32 + var k Tsize_t + var p, z, v6, v7 uintptr + var v2 int64 + var v3 uint64 + var v8 int8 + _, _, _, _, _, _, _, _, _, _, _, _ = __need_unlock, c, k, p, z, v1, v2, v3, v4, v6, v7, v8 + p = s + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if n <= int32(1) { + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + if n < int32(1) { + return uintptr(0) + } + **(**int8)(__ccgo_up(s)) = 0 + return s + } + n = n - 1 + for n != 0 { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + z = Xmemchr(tls, (*TFILE)(unsafe.Pointer(f)).Frpos, int32('\n'), Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos))) + if z != 0 { + v2 = int64(z) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + int64(1) + } else { + v2 = int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + } + k = Uint64FromInt64(v2) + if k < Uint64FromInt32(n) { + v3 = k + } else { + v3 = Uint64FromInt32(n) + } + k = v3 + Xmemcpy(tls, p, (*TFILE)(unsafe.Pointer(f)).Frpos, k) + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(k) + p = p + uintptr(k) + n = Int32FromUint64(uint64(n) - k) + if z != 0 || !(n != 0) { + break + } + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v7 = f + 8 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + } else { + v4 = X__uflow(tls, f) + } + v1 = v4 + c = v1 + if v1 < 0 { + if p == s || !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_EOF) != 0) { + s = uintptr(0) + } + break + } + n = n - 1 + v8 = int8(c) + v6 = p + p = p + 1 + **(**int8)(__ccgo_up(v6)) = v8 + if int32(v8) == int32('\n') { + break + } + } + if s != 0 { + **(**int8)(__ccgo_up(p)) = 0 + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return s +} + +func Xfgets_unlocked(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfgets(tls, s, n, f) +} + +func ___fgetwc_unlocked_internal(tls *TLS, f uintptr) (r Twint_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, first, v1, v2 int32 + var l Tsize_t + var v3, v4 uintptr + var _ /* b at bp+16 */ uint8 + var _ /* st at bp+8 */ Tmbstate_t + var _ /* wc at bp+0 */ Twchar_t + _, _, _, _, _, _, _ = c, first, l, v1, v2, v3, v4 + /* Convert character from buffer if possible */ + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + l = Uint64FromInt32(Xmbtowc(tls, bp, (*TFILE)(unsafe.Pointer(f)).Frpos, Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos)))) + if l+uint64(1) >= uint64(1) { + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(l + BoolUint64(!(l != 0))) /* l==0 means 1 byte, null */ + return Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))) + } + } + /* Convert character byte-by-byte */ + **(**Tmbstate_t)(__ccgo_up(bp + 8)) = Tmbstate_t{} + first = int32(1) + for cond := true; cond; cond = l == Uint64FromInt32(-Int32FromInt32(2)) { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__uflow(tls, f) + } + v1 = v2 + c = v1 + **(**uint8)(__ccgo_up(bp + 16)) = Uint8FromInt32(v1) + if c < 0 { + if !(first != 0) { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + } + return uint32(0xffffffff) + } + l = Xmbrtowc(tls, bp, bp+16, uint64(1), bp+8) + if l == Uint64FromInt32(-Int32FromInt32(1)) { + if !(first != 0) { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + Xungetc(tls, Int32FromUint8(**(**uint8)(__ccgo_up(bp + 16))), f) + } + return uint32(0xffffffff) + } + first = 0 + } + return Uint32FromInt32(**(**Twchar_t)(__ccgo_up(bp))) +} + +func X__fgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var loc Tlocale_t + var ploc uintptr + var wc Twchar_t + _, _, _ = loc, ploc, wc + ploc = uintptr(___get_tp(tls)) + 168 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if (*TFILE)(unsafe.Pointer(f)).Fmode <= 0 { + Xfwide(tls, f, int32(1)) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = (*TFILE)(unsafe.Pointer(f)).Flocale + wc = Int32FromUint32(___fgetwc_unlocked_internal(tls, f)) + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return Uint32FromInt32(wc) +} + +func Xfgetwc(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var c Twint_t + _, _, _ = __need_unlock, c, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + c = X__fgetwc_unlocked(tls, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return c +} + +func Xfgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fgetwc_unlocked(tls, f) +} + +func Xgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fgetwc_unlocked(tls, f) +} + +func Xfgetws(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var c Twint_t + var p, v4 uintptr + _, _, _, _, _ = __need_unlock, c, p, v1, v4 + p = s + v1 = n + n = n - 1 + if !(v1 != 0) { + return s + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + for { + if !(n != 0) { + break + } + c = X__fgetwc_unlocked(tls, f) + if c == uint32(0xffffffff) { + break + } + v4 = p + p += 4 + **(**Twchar_t)(__ccgo_up(v4)) = Int32FromUint32(c) + if c == uint32('\n') { + break + } + goto _3 + _3: + ; + n = n - 1 + } + **(**Twchar_t)(__ccgo_up(p)) = 0 + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + p = s + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + if p == s { + v4 = UintptrFromInt32(0) + } else { + v4 = s + } + return v4 +} + +func Xfgetws_unlocked(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfgetws(tls, s, n, f) +} + +func Xfileno(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, fd, v1 int32 + _, _, _ = __need_unlock, fd, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + fd = (*TFILE)(unsafe.Pointer(f)).Ffd + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + if fd < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EBADF) + return -int32(1) + } + return fd +} + +func Xfileno_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfileno(tls, f) +} + +func Xflockfile(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + if !(Xftrylockfile(tls, f) != 0) { + return + } + ___lockfile(tls, f) + X__register_locked_file(tls, f, uintptr(___get_tp(tls))) +} + +type Tcookie = struct { + Fpos Tsize_t + Flen1 Tsize_t + Fsize Tsize_t + Fbuf uintptr + Fmode int32 +} + +type Tmem_FILE = struct { + Ff TFILE + Fc Tcookie + Fbuf [1032]uint8 +} + +func _mseek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var base Tssize_t + var c uintptr + var v2 Tsize_t + _, _, _ = base, c, v2 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(Uint32FromInt32(whence) > uint32(2)) { + goto _1 + } + goto fail +fail: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) +_1: + ; + *(*[3]Tsize_t)(unsafe.Pointer(bp)) = [3]Tsize_t{ + 1: (*Tcookie)(unsafe.Pointer(c)).Fpos, + 2: (*Tcookie)(unsafe.Pointer(c)).Flen1, + } + base = Int64FromUint64(**(**Tsize_t)(__ccgo_up(bp + uintptr(whence)*8))) + if off < -base || off > Int64FromUint64((*Tcookie)(unsafe.Pointer(c)).Fsize)-base { + goto fail + } + v2 = Uint64FromInt64(base + off) + (*Tcookie)(unsafe.Pointer(c)).Fpos = v2 + return Int64FromUint64(v2) +} + +func _mread(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var c uintptr + var rem Tsize_t + _, _ = c, rem + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + rem = (*Tcookie)(unsafe.Pointer(c)).Flen1 - (*Tcookie)(unsafe.Pointer(c)).Fpos + if (*Tcookie)(unsafe.Pointer(c)).Fpos > (*Tcookie)(unsafe.Pointer(c)).Flen1 { + rem = uint64(0) + } + if len1 > rem { + len1 = rem + **(**uint32)(__ccgo_up(f)) |= uint32(F_EOF) + } + Xmemcpy(tls, buf, (*Tcookie)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie)(unsafe.Pointer(c)).Fpos), len1) + **(**Tsize_t)(__ccgo_up(c)) += len1 + rem = rem - len1 + if rem > (*TFILE)(unsafe.Pointer(f)).Fbuf_size { + rem = (*TFILE)(unsafe.Pointer(f)).Fbuf_size + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(rem) + Xmemcpy(tls, (*TFILE)(unsafe.Pointer(f)).Frpos, (*Tcookie)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie)(unsafe.Pointer(c)).Fpos), rem) + **(**Tsize_t)(__ccgo_up(c)) += rem + return len1 +} + +func _mwrite(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var c uintptr + var len2, rem Tsize_t + _, _, _ = c, len2, rem + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + len2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + if len2 != 0 { + (*TFILE)(unsafe.Pointer(f)).Fwpos = (*TFILE)(unsafe.Pointer(f)).Fwbase + if _mwrite(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwpos, len2) < len2 { + return uint64(0) + } + } + if (*Tcookie)(unsafe.Pointer(c)).Fmode == int32('a') { + (*Tcookie)(unsafe.Pointer(c)).Fpos = (*Tcookie)(unsafe.Pointer(c)).Flen1 + } + rem = (*Tcookie)(unsafe.Pointer(c)).Fsize - (*Tcookie)(unsafe.Pointer(c)).Fpos + if len1 > rem { + len1 = rem + } + Xmemcpy(tls, (*Tcookie)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie)(unsafe.Pointer(c)).Fpos), buf, len1) + **(**Tsize_t)(__ccgo_up(c)) += len1 + if (*Tcookie)(unsafe.Pointer(c)).Fpos > (*Tcookie)(unsafe.Pointer(c)).Flen1 { + (*Tcookie)(unsafe.Pointer(c)).Flen1 = (*Tcookie)(unsafe.Pointer(c)).Fpos + if (*Tcookie)(unsafe.Pointer(c)).Flen1 < (*Tcookie)(unsafe.Pointer(c)).Fsize { + **(**uint8)(__ccgo_up((*Tcookie)(unsafe.Pointer(c)).Fbuf + uintptr((*Tcookie)(unsafe.Pointer(c)).Flen1))) = uint8(0) + } else { + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NORD) != 0 && (*Tcookie)(unsafe.Pointer(c)).Fsize != 0 { + **(**uint8)(__ccgo_up((*Tcookie)(unsafe.Pointer(c)).Fbuf + uintptr((*Tcookie)(unsafe.Pointer(c)).Fsize-uint64(1)))) = uint8(0) + } + } + } + return len1 +} + +func _mclose(tls *TLS, m uintptr) (r int32) { + return 0 +} + +func Xfmemopen(tls *TLS, buf uintptr, size Tsize_t, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v buf=%v size=%v mode=%v, (%v:)", tls, buf, size, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var f uintptr + var plus, v2 int32 + var v1 uint64 + var v3 Tsize_t + _, _, _, _, _ = f, plus, v1, v2, v3 + plus = BoolInt32(!!(Xstrchr(tls, mode, int32('+')) != 0)) + if !(Xstrchr(tls, __ccgo_ts+1521, int32(**(**int8)(__ccgo_up(mode)))) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + if !(buf != 0) && size > Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return uintptr(0) + } + if buf != 0 { + v1 = uint64(0) + } else { + v1 = size + } + f = Xmalloc(tls, uint64(1304)+v1) + if !(f != 0) { + return uintptr(0) + } + Xmemset(tls, f, 0, uint64(UintptrFromInt32(0)+272)) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fcookie = f + 232 + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Ffd = -int32(1) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Flbf = -int32(1) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fbuf = f + 272 + uintptr(UNGET) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fbuf_size = Uint64FromInt64(1032) - Uint64FromInt32(UNGET) + if !(buf != 0) { + buf = f + 1304 + Xmemset(tls, buf, 0, size) + } + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fbuf = buf + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fsize = size + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fmode = int32(**(**int8)(__ccgo_up(mode))) + if !(plus != 0) { + if int32(**(**int8)(__ccgo_up(mode))) == int32('r') { + v2 = int32(F_NOWR) + } else { + v2 = int32(F_NORD) + } + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fflags = Uint32FromInt32(v2) + } + if int32(**(**int8)(__ccgo_up(mode))) == int32('r') { + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Flen1 = size + } else { + if int32(**(**int8)(__ccgo_up(mode))) == int32('a') { + v3 = Xstrnlen(tls, buf, size) + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fpos = v3 + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Flen1 = v3 + } else { + if plus != 0 { + **(**uint8)(__ccgo_up((*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fbuf)) = uint8(0) + } + } + } + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fread = __ccgo_fp(_mread) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fwrite = __ccgo_fp(_mwrite) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fseek = __ccgo_fp(_mseek) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fclose1 = __ccgo_fp(_mclose) + if !(X__libc.Fthreaded != 0) { + AtomicStorePInt32(f+140, -int32(1)) + } + return X__ofl_add(tls, f) +} + +func Xfopen(tls *TLS, filename uintptr, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v filename=%v mode=%v, (%v:)", tls, filename, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var f uintptr + var fd, flags int32 + _, _, _ = f, fd, flags + /* Check for valid initial mode character */ + if !(Xstrchr(tls, __ccgo_ts+1521, int32(**(**int8)(__ccgo_up(mode)))) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + /* Compute the flags to pass to open() */ + flags = X__fmodeflags(tls, mode) + fd = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_open), int64(filename), int64(flags|Int32FromInt32(O_LARGEFILE)), int64(Int32FromInt32(0666)))))) + if fd < 0 { + return uintptr(0) + } + if flags&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + f = X__fdopen(tls, fd, mode) + if f != 0 { + return f + } + X__syscall1(tls, int64(SYS_close), int64(fd)) + return uintptr(0) +} + +type Tfcookie = struct { + Fcookie uintptr + Fiofuncs Tcookie_io_functions_t +} + +type Tcookie_FILE = struct { + Ff TFILE + Ffc Tfcookie + Fbuf [1032]uint8 +} + +func _cookieread(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var fc, v2, v3 uintptr + var len2, readlen, remain, v1 Tsize_t + var ret Tssize_t + var v4 int32 + _, _, _, _, _, _, _, _, _ = fc, len2, readlen, remain, ret, v1, v2, v3, v4 + fc = (*TFILE)(unsafe.Pointer(f)).Fcookie + ret = int64(-int32(1)) + remain = len1 + readlen = uint64(0) + len2 = len1 - BoolUint64(!!((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0)) + if !((*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fread != 0) { + goto bail + } + if len2 != 0 { + ret = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fread})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie, buf, len2) + if ret <= 0 { + goto bail + } + readlen = readlen + Uint64FromInt64(ret) + remain = remain - Uint64FromInt64(ret) + } + if !((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0) || remain > BoolUint64(!!((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0)) { + return readlen + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + ret = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fread})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie, (*TFILE)(unsafe.Pointer(f)).Frpos, (*TFILE)(unsafe.Pointer(f)).Fbuf_size) + if ret <= 0 { + goto bail + } + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Frpos + uintptr(ret) + v1 = readlen + readlen = readlen + 1 + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + **(**uint8)(__ccgo_up(buf + uintptr(v1))) = **(**uint8)(__ccgo_up(v2)) + return readlen + goto bail +bail: + ; + if ret == 0 { + v4 = int32(F_EOF) + } else { + v4 = int32(F_ERR) + } + **(**uint32)(__ccgo_up(f)) |= Uint32FromInt32(v4) + v2 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = v2 + (*TFILE)(unsafe.Pointer(f)).Frpos = v2 + return readlen +} + +func _cookiewrite(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var fc, v1, v2 uintptr + var len2 Tsize_t + var ret Tssize_t + _, _, _, _, _ = fc, len2, ret, v1, v2 + fc = (*TFILE)(unsafe.Pointer(f)).Fcookie + len2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + if !((*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fwrite != 0) { + return len1 + } + if len2 != 0 { + (*TFILE)(unsafe.Pointer(f)).Fwpos = (*TFILE)(unsafe.Pointer(f)).Fwbase + if _cookiewrite(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwpos, len2) < len2 { + return uint64(0) + } + } + ret = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fwrite})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie, buf, len1) + if ret < 0 { + v2 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v2 + v1 = v2 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + return uint64(0) + } + return Uint64FromInt64(ret) +} + +func _cookieseek(tls *TLS, f uintptr, _off Toff_t, whence int32) (r Toff_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*Toff_t)(unsafe.Pointer(bp)) = _off + var fc uintptr + var res int32 + _, _ = fc, res + fc = (*TFILE)(unsafe.Pointer(f)).Fcookie + if Uint32FromInt32(whence) > uint32(2) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) + } + if !((*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fseek != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOPNOTSUPP) + return int64(-int32(1)) + } + res = (*(*func(*TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fseek})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie, bp, whence) + if res < 0 { + return int64(res) + } + return **(**Toff_t)(__ccgo_up(bp)) +} + +func _cookieclose(tls *TLS, f uintptr) (r int32) { + var fc uintptr + _ = fc + fc = (*TFILE)(unsafe.Pointer(f)).Fcookie + if (*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fclose1 != 0 { + return (*(*func(*TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fclose1})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie) + } + return 0 +} + +func Xfopencookie(tls *TLS, cookie uintptr, mode uintptr, iofuncs Tcookie_io_functions_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v cookie=%v mode=%v iofuncs=%v, (%v:)", tls, cookie, mode, iofuncs, origin(2)) + defer func() { trc("-> %v", r) }() + } + var f, v1 uintptr + var v2 int32 + _, _, _ = f, v1, v2 + /* Check for valid initial mode character */ + if !(Xstrchr(tls, __ccgo_ts+1521, int32(**(**int8)(__ccgo_up(mode)))) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + /* Allocate FILE+fcookie+buffer or fail */ + v1 = Xmalloc(tls, uint64(1304)) + f = v1 + if !(v1 != 0) { + return uintptr(0) + } + /* Zero-fill only the struct, not the buffer */ + Xmemset(tls, f, 0, uint64(232)) + /* Impose mode restrictions */ + if !(Xstrchr(tls, mode, int32('+')) != 0) { + if int32(**(**int8)(__ccgo_up(mode))) == int32('r') { + v2 = int32(F_NOWR) + } else { + v2 = int32(F_NORD) + } + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fflags = Uint32FromInt32(v2) + } + /* Set up our fcookie */ + (*Tcookie_FILE)(unsafe.Pointer(f)).Ffc.Fcookie = cookie + (*Tcookie_FILE)(unsafe.Pointer(f)).Ffc.Fiofuncs = iofuncs + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Ffd = -int32(1) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fcookie = f + 232 + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fbuf = f + 272 + uintptr(UNGET) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fbuf_size = Uint64FromInt64(1032) - Uint64FromInt32(UNGET) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Flbf = -int32(1) + /* Initialize op ptrs. No problem if some are unneeded. */ + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fread = __ccgo_fp(_cookieread) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fwrite = __ccgo_fp(_cookiewrite) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fseek = __ccgo_fp(_cookieseek) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fclose1 = __ccgo_fp(_cookieclose) + /* Add new FILE to open file list */ + return X__ofl_add(tls, f) +} + +func Xfprintf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfprintf(tls, f, fmt, ap) + _ = ap + return ret +} + +func _locking_putc(tls *TLS, c int32, f uintptr) (r int32) { + var v1, v2, v4, v8 int32 + var v6, v7 uintptr + var v5 uint8 + _, _, _, _, _, _, _ = v1, v2, v4, v5, v6, v7, v8 + v1 = 0 + // __asm__ __volatile__ ( + // + // "lock ; cmpxchg %3, %1" + // : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 4, __ccgo_ts+1538) + v2 = v1 + goto _3 +_3: + if v2 != 0 { + ___lockfile(tls, f) + } + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v5 = Uint8FromInt32(c) + v7 = f + 40 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) + 1 + **(**uint8)(__ccgo_up(v6)) = v5 + v1 = Int32FromUint8(v5) + } else { + v1 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + c = v1 + v1 = 0 + // __asm__ __volatile__( + // + // "xchg %0, %1" + // : "=r"(v), "=m"(*p) : "0"(v) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 22, __ccgo_ts+1538) + v2 = v1 + goto _10 +_10: + if v2&int32(MAYBE_WAITERS) != 0 { + v6 = f + 140 + v4 = int32(1) + v8 = int32(1) + if v8 != 0 { + v8 = int32(FUTEX_PRIVATE) + } + if v4 < Int32FromInt32(0) { + v4 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v6), int64(Int32FromInt32(FUTEX_WAKE)|v8), int64(v4)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v6), int64(Int32FromInt32(FUTEX_WAKE)), int64(v4)) != 0 + } + return c +} + +func Xfputc(tls *TLS, c1 int32, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c1=%v f1=%v, (%v:)", tls, c1, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v1, v3, v5 int32 + var v2, v7, v8 uintptr + var v6 uint8 + _, _, _, _, _, _, _, _ = l, v1, v2, v3, v5, v6, v7, v8 + v1 = c1 + v2 = f1 + l = AtomicLoadPInt32(v2 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if Int32FromUint8(Uint8FromInt32(v1)) != (*TFILE)(unsafe.Pointer(v2)).Flbf && (*TFILE)(unsafe.Pointer(v2)).Fwpos != (*TFILE)(unsafe.Pointer(v2)).Fwend { + v6 = Uint8FromInt32(v1) + v8 = v2 + 40 + v7 = *(*uintptr)(unsafe.Pointer(v8)) + *(*uintptr)(unsafe.Pointer(v8)) = *(*uintptr)(unsafe.Pointer(v8)) + 1 + **(**uint8)(__ccgo_up(v7)) = v6 + v5 = Int32FromUint8(v6) + } else { + v5 = X__overflow(tls, v2, Int32FromUint8(Uint8FromInt32(v1))) + } + v3 = v5 + goto _4 + } + v3 = _locking_putc(tls, v1, v2) + goto _4 +_4: + return v3 +} + +func Xfputs(tls *TLS, s uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v f=%v, (%v:)", tls, s, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = _strlen(tls, s) + return BoolInt32(Xfwrite(tls, s, uint64(1), l, f) == l) - int32(1) +} + +func Xfputs_unlocked(tls *TLS, s uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v f=%v, (%v:)", tls, s, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfputs(tls, s, f) +} + +func X__fputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var l, v1 int32 + var loc Tlocale_t + var ploc, v3, v4 uintptr + var v2 uint8 + var _ /* mbc at bp+0 */ [4]int8 + _, _, _, _, _, _, _ = l, loc, ploc, v1, v2, v3, v4 + ploc = uintptr(___get_tp(tls)) + 168 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if (*TFILE)(unsafe.Pointer(f)).Fmode <= 0 { + Xfwide(tls, f, int32(1)) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = (*TFILE)(unsafe.Pointer(f)).Flocale + if BoolInt32(Uint32FromInt32(c) < uint32(128)) != 0 { + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v2 = Uint8FromInt32(c) + v4 = f + 40 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(v3)) = v2 + v1 = Int32FromUint8(v2) + } else { + v1 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + c = v1 + } else { + if (*TFILE)(unsafe.Pointer(f)).Fwpos+uintptr(MB_LEN_MAX) < (*TFILE)(unsafe.Pointer(f)).Fwend { + l = Xwctomb(tls, (*TFILE)(unsafe.Pointer(f)).Fwpos, c) + if l < 0 { + c = Int32FromUint32(0xffffffff) + } else { + **(**uintptr)(__ccgo_up(f + 40)) += uintptr(l) + } + } else { + l = Xwctomb(tls, bp, c) + if l < 0 || X__fwritex(tls, bp, Uint64FromInt32(l), f) < Uint64FromInt32(l) { + c = Int32FromUint32(0xffffffff) + } + } + } + if Uint32FromInt32(c) == uint32(0xffffffff) { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return Uint32FromInt32(c) +} + +func Xfputwc(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + _, _ = __need_unlock, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + c = Int32FromUint32(X__fputwc_unlocked(tls, c, f)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return Uint32FromInt32(c) +} + +func Xfputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fputwc_unlocked(tls, c, f) +} + +func Xputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fputwc_unlocked(tls, c, f) +} + +func Xfputws(tls *TLS, _ws uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v _ws=%v f=%v, (%v:)", tls, _ws, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(1040) + defer tls.Free(1040) + *(*uintptr)(unsafe.Pointer(bp)) = _ws + var __need_unlock, v1 int32 + var l, v2 Tsize_t + var loc Tlocale_t + var ploc uintptr + var v3 bool + var _ /* buf at bp+8 */ [1024]uint8 + _, _, _, _, _, _, _ = __need_unlock, l, loc, ploc, v1, v2, v3 + l = uint64(0) + ploc = uintptr(___get_tp(tls)) + 168 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + Xfwide(tls, f, int32(1)) + **(**Tlocale_t)(__ccgo_up(ploc)) = (*TFILE)(unsafe.Pointer(f)).Flocale + for { + if v3 = **(**uintptr)(__ccgo_up(bp)) != 0; v3 { + v2 = Xwcsrtombs(tls, bp+8, bp, uint64(1024), uintptr(0)) + l = v2 + } + if !(v3 && v2+uint64(1) > uint64(1)) { + break + } + if X__fwritex(tls, bp+8, l, f) < l { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return -int32(1) + } + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return Int32FromUint64(l) /* 0 or -1 */ +} + +func Xfputws_unlocked(tls *TLS, _ws uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v _ws=%v f=%v, (%v:)", tls, _ws, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfputws(tls, _ws, f) +} + +func Xfread(tls *TLS, destv uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v destv=%v size=%v nmemb=%v f=%v, (%v:)", tls, destv, size, nmemb, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var dest uintptr + var k, l, len1 Tsize_t + var v2 uint64 + _, _, _, _, _, _, _ = __need_unlock, dest, k, l, len1, v1, v2 + dest = destv + len1 = size * nmemb + l = len1 + if !(size != 0) { + nmemb = uint64(0) + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + /* First exhaust the buffer. */ + if Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos)) < l { + v2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos)) + } else { + v2 = l + } + k = v2 + Xmemcpy(tls, dest, (*TFILE)(unsafe.Pointer(f)).Frpos, k) + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(k) + dest = dest + uintptr(k) + l = l - k + } + /* Read the remainder directly */ + for { + if !(l != 0) { + break + } + if X__toread(tls, f) != 0 { + v2 = uint64(0) + } else { + v2 = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fread})))(tls, f, dest, l) + } + k = v2 + if !(k != 0) { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return (len1 - l) / size + } + goto _3 + _3: + ; + l = l - k + dest = dest + uintptr(k) + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return nmemb +} + +func Xfread_unlocked(tls *TLS, destv uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v destv=%v size=%v nmemb=%v f=%v, (%v:)", tls, destv, size, nmemb, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfread(tls, destv, size, nmemb, f) +} + +/* The basic idea of this implementation is to open a new FILE, + * hack the necessary parts of the new FILE into the old one, then + * close the new FILE. */ + +/* Locking IS necessary because another thread may provably hold the + * lock, via flockfile or otherwise, when freopen is called, and in that + * case, freopen cannot act until the lock is released. */ + +func Xfreopen(tls *TLS, filename uintptr, mode uintptr, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v filename=%v mode=%v f=%v, (%v:)", tls, filename, mode, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, fl, v1 int32 + var f2 uintptr + _, _, _, _ = __need_unlock, f2, fl, v1 + fl = X__fmodeflags(tls, mode) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + Xfflush(tls, f) + if !(filename != 0) { + if fl&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + fl = fl & ^(Int32FromInt32(O_CREAT) | Int32FromInt32(O_EXCL) | Int32FromInt32(O_CLOEXEC)) + if X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fcntl), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(Int32FromInt32(F_SETFL)), int64(fl)))) < 0 { + goto fail + } + } else { + f2 = Xfopen(tls, filename, mode) + if !(f2 != 0) { + goto fail + } + if (*TFILE)(unsafe.Pointer(f2)).Ffd == (*TFILE)(unsafe.Pointer(f)).Ffd { + (*TFILE)(unsafe.Pointer(f2)).Ffd = -int32(1) + } else { + if X__dup3(tls, (*TFILE)(unsafe.Pointer(f2)).Ffd, (*TFILE)(unsafe.Pointer(f)).Ffd, fl&int32(O_CLOEXEC)) < 0 { + goto fail2 + } + } + (*TFILE)(unsafe.Pointer(f)).Fflags = (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_PERM) | (*TFILE)(unsafe.Pointer(f2)).Fflags + (*TFILE)(unsafe.Pointer(f)).Fread = (*TFILE)(unsafe.Pointer(f2)).Fread + (*TFILE)(unsafe.Pointer(f)).Fwrite = (*TFILE)(unsafe.Pointer(f2)).Fwrite + (*TFILE)(unsafe.Pointer(f)).Fseek = (*TFILE)(unsafe.Pointer(f2)).Fseek + (*TFILE)(unsafe.Pointer(f)).Fclose1 = (*TFILE)(unsafe.Pointer(f2)).Fclose1 + Xfclose(tls, f2) + } + (*TFILE)(unsafe.Pointer(f)).Fmode = 0 + (*TFILE)(unsafe.Pointer(f)).Flocale = uintptr(0) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return f + goto fail2 +fail2: + ; + Xfclose(tls, f2) + goto fail +fail: + ; + Xfclose(tls, f) + return UintptrFromInt32(0) +} + +func Xfscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfscanf(tls, f, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_fscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfscanf(tls, f, fmt, va) +} + +func X__fseeko_unlocked(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v2 uintptr + _, _ = v1, v2 + /* Fail immediately for invalid whence argument. */ + if whence != int32(1) && whence != 0 && whence != int32(2) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + /* Adjust relative offset for unread data in buffer, if any. */ + if whence == int32(1) && (*TFILE)(unsafe.Pointer(f)).Frend != 0 { + off = off - (int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos)) + } + /* Flush write buffer, and report error on failure. */ + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + if !((*TFILE)(unsafe.Pointer(f)).Fwpos != 0) { + return -int32(1) + } + } + /* Leave writing mode */ + v2 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v2 + v1 = v2 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + /* Perform the underlying seek. */ + if (*(*func(*TLS, uintptr, Toff_t, int32) Toff_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fseek})))(tls, f, off, whence) < 0 { + return -int32(1) + } + /* If seek succeeded, file is seekable and we discard read buffer. */ + v1 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_EOF)) + return 0 +} + +func X__fseeko(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, result, v1 int32 + _, _, _ = __need_unlock, result, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + result = X__fseeko_unlocked(tls, f, off, whence) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return result +} + +func Xfseek(tls *TLS, f uintptr, off int64, whence int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fseeko(tls, f, off, whence) +} + +func Xfseeko(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fseeko(tls, f, off, whence) +} + +func Xfsetpos(tls *TLS, f uintptr, pos uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v pos=%v, (%v:)", tls, f, pos, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fseeko(tls, f, int64(**(**int64)(__ccgo_up(pos))), 0) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__ftello_unlocked(tls *TLS, f uintptr) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var pos Toff_t + var v1 int32 + _, _ = pos, v1 + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_APP) != 0 && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + v1 = int32(2) + } else { + v1 = int32(1) + } + pos = (*(*func(*TLS, uintptr, Toff_t, int32) Toff_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fseek})))(tls, f, 0, v1) + if pos < 0 { + return pos + } + /* Adjust for data in buffer. */ + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 { + pos = pos + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Frend)) + } else { + if (*TFILE)(unsafe.Pointer(f)).Fwbase != 0 { + pos = pos + (int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + } + } + return pos +} + +func X__ftello(tls *TLS, f uintptr) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var pos Toff_t + _, _, _ = __need_unlock, pos, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + pos = X__ftello_unlocked(tls, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return pos +} + +func Xftell(tls *TLS, f uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var pos Toff_t + _ = pos + pos = X__ftello(tls, f) + if pos > int64(0x7fffffffffffffff) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return int64(-int32(1)) + } + return pos +} + +func Xftello(tls *TLS, f uintptr) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__ftello(tls, f) +} + +func X__do_orphaned_stdio_locks(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + var f uintptr + _ = f + f = (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Fstdio_locks + for { + if !(f != 0) { + break + } + // __asm__ __volatile__( + // + // "mov %1, %0 ; lock ; orl $0,(%%rsp)" + // : "=m"(*p) : "r"(x) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 88, __ccgo_ts+1551) + goto _1 + _1: + ; + f = (*TFILE)(unsafe.Pointer(f)).Fnext_locked + } +} + +func X__unlist_locked_file(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + if (*TFILE)(unsafe.Pointer(f)).Flockcount != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fnext_locked != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fnext_locked)).Fprev_locked = (*TFILE)(unsafe.Pointer(f)).Fprev_locked + } + if (*TFILE)(unsafe.Pointer(f)).Fprev_locked != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fprev_locked)).Fnext_locked = (*TFILE)(unsafe.Pointer(f)).Fnext_locked + } else { + (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Fstdio_locks = (*TFILE)(unsafe.Pointer(f)).Fnext_locked + } + } +} + +func X__register_locked_file(tls *TLS, f uintptr, self Tpthread_t) { + if __ccgo_strace { + trc("tls=%v f=%v self=%v, (%v:)", tls, f, self, origin(2)) + } + (*TFILE)(unsafe.Pointer(f)).Flockcount = int64(1) + (*TFILE)(unsafe.Pointer(f)).Fprev_locked = uintptr(0) + (*TFILE)(unsafe.Pointer(f)).Fnext_locked = (*t__pthread)(unsafe.Pointer(self)).Fstdio_locks + if (*TFILE)(unsafe.Pointer(f)).Fnext_locked != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fnext_locked)).Fprev_locked = f + } + (*t__pthread)(unsafe.Pointer(self)).Fstdio_locks = f +} + +func Xftrylockfile(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var owner, tid, v1, v2 int32 + var self Tpthread_t + var v5 bool + _, _, _, _, _, _ = owner, self, tid, v1, v2, v5 + self = uintptr(___get_tp(tls)) + tid = (*t__pthread)(unsafe.Pointer(self)).Ftid + owner = AtomicLoadPInt32(f + 140) + if owner & ^Int32FromInt32(MAYBE_WAITERS) == tid { + if (*TFILE)(unsafe.Pointer(f)).Flockcount == int64(0x7fffffffffffffff) { + return -int32(1) + } + (*TFILE)(unsafe.Pointer(f)).Flockcount = (*TFILE)(unsafe.Pointer(f)).Flockcount + 1 + return 0 + } + if owner < 0 { + v1 = Int32FromInt32(0) + owner = v1 + AtomicStorePInt32(f+140, v1) + } + if v5 = owner != 0; !v5 { + v1 = 0 + // __asm__ __volatile__ ( + // + // "lock ; cmpxchg %3, %1" + // : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 4, __ccgo_ts+1577) + v2 = v1 + goto _4 + _4: + } + if v5 || v2 != 0 { + return -int32(1) + } + X__register_locked_file(tls, f, self) + return 0 +} + +func Xfunlockfile(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + if (*TFILE)(unsafe.Pointer(f)).Flockcount == int64(1) { + X__unlist_locked_file(tls, f) + (*TFILE)(unsafe.Pointer(f)).Flockcount = 0 + ___unlockfile(tls, f) + } else { + (*TFILE)(unsafe.Pointer(f)).Flockcount = (*TFILE)(unsafe.Pointer(f)).Flockcount - 1 + } +} + +func Xfwide(tls *TLS, f uintptr, mode int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v mode=%v, (%v:)", tls, f, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1, v3 int32 + var v2 Tlocale_t + _, _, _, _ = __need_unlock, v1, v2, v3 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if mode != 0 { + if !((*TFILE)(unsafe.Pointer(f)).Flocale != 0) { + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v3 = int32(4) + } else { + v3 = int32(1) + } + if v3 == int32(1) { + v2 = uintptr(unsafe.Pointer(&X__c_locale)) + } else { + v2 = uintptr(unsafe.Pointer(&X__c_dot_utf8_locale)) + } + (*TFILE)(unsafe.Pointer(f)).Flocale = v2 + } + if !((*TFILE)(unsafe.Pointer(f)).Fmode != 0) { + if mode > 0 { + v1 = int32(1) + } else { + v1 = -int32(1) + } + (*TFILE)(unsafe.Pointer(f)).Fmode = v1 + } + } + mode = (*TFILE)(unsafe.Pointer(f)).Fmode + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return mode +} + +func Xfwprintf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfwprintf(tls, f, fmt, ap) + _ = ap + return ret +} + +func X__fwritex(tls *TLS, s uintptr, l Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v f=%v, (%v:)", tls, s, l, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i, n Tsize_t + _, _ = i, n + i = uint64(0) + if !((*TFILE)(unsafe.Pointer(f)).Fwend != 0) && X__towrite(tls, f) != 0 { + return uint64(0) + } + if l > Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwend)-int64((*TFILE)(unsafe.Pointer(f)).Fwpos)) { + return (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, s, l) + } + if (*TFILE)(unsafe.Pointer(f)).Flbf >= 0 { + /* Match /^(.*\n|)/ */ + i = l + for { + if !(i != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(i-uint64(1))))) != int32('\n')) { + break + } + goto _1 + _1: + ; + i = i - 1 + } + if i != 0 { + n = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, s, i) + if n < i { + return n + } + s = s + uintptr(i) + l = l - i + } + } + Xmemcpy(tls, (*TFILE)(unsafe.Pointer(f)).Fwpos, s, l) + **(**uintptr)(__ccgo_up(f + 40)) += uintptr(l) + return l + i +} + +func Xfwrite(tls *TLS, src uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v src=%v size=%v nmemb=%v f=%v, (%v:)", tls, src, size, nmemb, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var k, l Tsize_t + var v2 uint64 + _, _, _, _, _ = __need_unlock, k, l, v1, v2 + l = size * nmemb + if !(size != 0) { + nmemb = uint64(0) + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + k = X__fwritex(tls, src, l, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + if k == l { + v2 = nmemb + } else { + v2 = k / size + } + return v2 +} + +func Xfwrite_unlocked(tls *TLS, src uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v src=%v size=%v nmemb=%v f=%v, (%v:)", tls, src, size, nmemb, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfwrite(tls, src, size, nmemb, f) +} + +func Xfwscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfwscanf(tls, f, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_fwscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfwscanf(tls, f, fmt, va) +} + +func _locking_getc1(tls *TLS, f uintptr) (r int32) { + var c, v1, v2, v4, v7, v8 int32 + var v10, v5, v6 uintptr + _, _, _, _, _, _, _, _, _ = c, v1, v10, v2, v4, v5, v6, v7, v8 + v1 = 0 + // __asm__ __volatile__ ( + // + // "lock ; cmpxchg %3, %1" + // : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 4, __ccgo_ts+1525) + v2 = v1 + goto _3 +_3: + if v2 != 0 { + ___lockfile(tls, f) + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v1 = X__uflow(tls, f) + } + c = v1 + v2 = 0 + // __asm__ __volatile__( + // + // "xchg %0, %1" + // : "=r"(v), "=m"(*p) : "0"(v) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 22, __ccgo_ts+1525) + v4 = v2 + goto _9 +_9: + if v4&int32(MAYBE_WAITERS) != 0 { + v10 = f + 140 + v7 = int32(1) + v8 = int32(1) + if v8 != 0 { + v8 = int32(FUTEX_PRIVATE) + } + if v7 < Int32FromInt32(0) { + v7 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v10), int64(Int32FromInt32(FUTEX_WAKE)|v8), int64(v7)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v10), int64(Int32FromInt32(FUTEX_WAKE)), int64(v7)) != 0 + } + return c +} + +func Xgetc(tls *TLS, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f1=%v, (%v:)", tls, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v2, v4 int32 + var v1, v5, v6 uintptr + _, _, _, _, _, _ = l, v1, v2, v4, v5, v6 + v1 = f1 + l = AtomicLoadPInt32(v1 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if (*TFILE)(unsafe.Pointer(v1)).Frpos != (*TFILE)(unsafe.Pointer(v1)).Frend { + v6 = v1 + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = X__uflow(tls, v1) + } + v2 = v4 + goto _3 + } + v2 = _locking_getc1(tls, v1) + goto _3 +_3: + return v2 +} + +func X_IO_getc(tls *TLS, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f1=%v, (%v:)", tls, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetc(tls, f1) +} + +func Xgetc_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + var v2, v3 uintptr + _, _, _ = v1, v2, v3 + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__uflow(tls, f) + } + return v1 +} + +func X_IO_getc_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetc_unlocked(tls, f) +} + +func Xfgetc_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetc_unlocked(tls, f) +} + +func _locking_getc2(tls *TLS, f uintptr) (r int32) { + var c, v1, v2, v4, v7, v8 int32 + var v10, v5, v6 uintptr + _, _, _, _, _, _, _, _, _ = c, v1, v10, v2, v4, v5, v6, v7, v8 + v1 = 0 + // __asm__ __volatile__ ( + // + // "lock ; cmpxchg %3, %1" + // : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 4, __ccgo_ts+1525) + v2 = v1 + goto _3 +_3: + if v2 != 0 { + ___lockfile(tls, f) + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v1 = X__uflow(tls, f) + } + c = v1 + v2 = 0 + // __asm__ __volatile__( + // + // "xchg %0, %1" + // : "=r"(v), "=m"(*p) : "0"(v) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 22, __ccgo_ts+1525) + v4 = v2 + goto _9 +_9: + if v4&int32(MAYBE_WAITERS) != 0 { + v10 = f + 140 + v7 = int32(1) + v8 = int32(1) + if v8 != 0 { + v8 = int32(FUTEX_PRIVATE) + } + if v7 < Int32FromInt32(0) { + v7 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v10), int64(Int32FromInt32(FUTEX_WAKE)|v8), int64(v7)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v10), int64(Int32FromInt32(FUTEX_WAKE)), int64(v7)) != 0 + } + return c +} + +func Xgetchar(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v2, v4 int32 + var v1, v5, v6 uintptr + _, _, _, _, _, _ = l, v1, v2, v4, v5, v6 + v1 = uintptr(unsafe.Pointer(&X__stdin_FILE)) + l = AtomicLoadPInt32(v1 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if (*TFILE)(unsafe.Pointer(v1)).Frpos != (*TFILE)(unsafe.Pointer(v1)).Frend { + v6 = v1 + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = X__uflow(tls, v1) + } + v2 = v4 + goto _3 + } + v2 = _locking_getc2(tls, v1) + goto _3 +_3: + return v2 +} + +func Xgetchar_unlocked(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + var v2, v3 uintptr + _, _, _ = v1, v2, v3 + if (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Frpos != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Frend { + v3 = uintptr(unsafe.Pointer(&X__stdin_FILE)) + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__uflow(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) + } + return v1 +} + +func Xgetdelim(tls *TLS, s uintptr, n uintptr, delim int32, f uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v delim=%v f=%v, (%v:)", tls, s, n, delim, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, c, v1, v4 int32 + var i, k, m, v11 Tsize_t + var tmp, z, v6, v7 uintptr + var v10 int8 + var v3 int64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __need_unlock, c, i, k, m, tmp, z, v1, v10, v11, v3, v4, v6, v7 + i = uint64(0) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if !(n != 0) || !(s != 0) { + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) + } + if !(**(**uintptr)(__ccgo_up(s)) != 0) { + **(**Tsize_t)(__ccgo_up(n)) = uint64(0) + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + z = Xmemchr(tls, (*TFILE)(unsafe.Pointer(f)).Frpos, delim, Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos))) + if z != 0 { + v3 = int64(z) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + int64(1) + } else { + v3 = int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + } + k = Uint64FromInt64(v3) + } else { + z = uintptr(0) + k = uint64(0) + } + if i+k >= **(**Tsize_t)(__ccgo_up(n)) { + m = i + k + uint64(2) + if !(z != 0) && m < Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt32(4) { + m = m + m/uint64(2) + } + tmp = Xrealloc(tls, **(**uintptr)(__ccgo_up(s)), m) + if !(tmp != 0) { + m = i + k + uint64(2) + tmp = Xrealloc(tls, **(**uintptr)(__ccgo_up(s)), m) + if !(tmp != 0) { + /* Copy as much as fits and ensure no + * pushback remains in the FILE buf. */ + k = **(**Tsize_t)(__ccgo_up(n)) - i + Xmemcpy(tls, **(**uintptr)(__ccgo_up(s))+uintptr(i), (*TFILE)(unsafe.Pointer(f)).Frpos, k) + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(k) + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return int64(-int32(1)) + } + } + **(**uintptr)(__ccgo_up(s)) = tmp + **(**Tsize_t)(__ccgo_up(n)) = m + } + if k != 0 { + Xmemcpy(tls, **(**uintptr)(__ccgo_up(s))+uintptr(i), (*TFILE)(unsafe.Pointer(f)).Frpos, k) + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(k) + i = i + k + } + if z != 0 { + break + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v7 = f + 8 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + } else { + v4 = X__uflow(tls, f) + } + v1 = v4 + c = v1 + if v1 == -int32(1) { + if !(i != 0) || !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_EOF) != 0) { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return int64(-int32(1)) + } + break + } + /* If the byte read by getc won't fit without growing the + * output buffer, push it back for next iteration. */ + if i+uint64(1) >= **(**Tsize_t)(__ccgo_up(n)) { + v7 = f + 8 + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) - 1 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + **(**uint8)(__ccgo_up(v6)) = Uint8FromInt32(c) + } else { + v10 = int8(c) + v11 = i + i = i + 1 + **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)) + uintptr(v11))) = v10 + if int32(v10) == delim { + break + } + } + goto _2 + _2: + } + **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)) + uintptr(i))) = 0 + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return Int64FromUint64(i) +} + +func X__getdelim(tls *TLS, s uintptr, n uintptr, delim int32, f uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v delim=%v f=%v, (%v:)", tls, s, n, delim, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetdelim(tls, s, n, delim, f) +} + +func Xgetline(tls *TLS, s uintptr, n uintptr, f uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetdelim(tls, s, n, int32('\n'), f) +} + +func Xgets(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, c, v1, v2, v3 int32 + var i, v6 Tsize_t + var v4, v5 uintptr + _, _, _, _, _, _, _, _, _ = __need_unlock, c, i, v1, v2, v3, v4, v5, v6 + i = uint64(0) + if AtomicLoadPInt32(uintptr(unsafe.Pointer(&X__stdin_FILE))+140) >= 0 { + v1 = ___lockfile(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) + } else { + v1 = 0 + } + __need_unlock = v1 + for { + if (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Frpos != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Frend { + v5 = uintptr(unsafe.Pointer(&X__stdin_FILE)) + 8 + v4 = *(*uintptr)(unsafe.Pointer(v5)) + *(*uintptr)(unsafe.Pointer(v5)) = *(*uintptr)(unsafe.Pointer(v5)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + } else { + v3 = X__uflow(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) + } + v2 = v3 + c = v2 + if !(v2 != -int32(1) && c != int32('\n')) { + break + } + v6 = i + i = i + 1 + **(**int8)(__ccgo_up(s + uintptr(v6))) = int8(c) + } + **(**int8)(__ccgo_up(s + uintptr(i))) = 0 + if c != int32('\n') && (!((*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Fflags&Uint32FromInt32(F_EOF) != 0) || !(i != 0)) { + s = uintptr(0) + } + if __need_unlock != 0 { + ___unlockfile(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) + } + return s +} + +func Xgetw(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 int32 + var _ /* x at bp+0 */ int32 + _ = v1 + if Xfread(tls, bp, uint64(4), uint64(1), f) != 0 { + v1 = **(**int32)(__ccgo_up(bp)) + } else { + v1 = -int32(1) + } + return v1 +} + +func Xgetwc(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfgetwc(tls, f) +} + +func Xgetwchar(tls *TLS) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfgetwc(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) +} + +func Xgetwchar_unlocked(tls *TLS) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetwchar(tls) +} + +var _ofl_head uintptr +var _ofl_lock [1]int32 + +func X__ofl_lock(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + ___lock(tls, uintptr(unsafe.Pointer(&_ofl_lock))) + return uintptr(unsafe.Pointer(&_ofl_head)) +} + +func X__ofl_unlock(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + ___unlock(tls, uintptr(unsafe.Pointer(&_ofl_lock))) +} + +func X__ofl_add(tls *TLS, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var head uintptr + _ = head + head = X__ofl_lock(tls) + (*TFILE)(unsafe.Pointer(f)).Fnext = **(**uintptr)(__ccgo_up(head)) + if **(**uintptr)(__ccgo_up(head)) != 0 { + (*TFILE)(unsafe.Pointer(**(**uintptr)(__ccgo_up(head)))).Fprev = f + } + **(**uintptr)(__ccgo_up(head)) = f + X__ofl_unlock(tls) + return f +} + +type Tcookie1 = struct { + Fbufp uintptr + Fsizep uintptr + Fpos Tsize_t + Fbuf uintptr + Flen1 Tsize_t + Fspace Tsize_t +} + +type Tms_FILE = struct { + Ff TFILE + Fc Tcookie1 + Fbuf [1024]uint8 +} + +func _ms_seek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var base Tssize_t + var c uintptr + var v2 Tsize_t + _, _, _ = base, c, v2 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(Uint32FromInt32(whence) > uint32(2)) { + goto _1 + } + goto fail +fail: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) +_1: + ; + *(*[3]Tsize_t)(unsafe.Pointer(bp)) = [3]Tsize_t{ + 1: (*Tcookie1)(unsafe.Pointer(c)).Fpos, + 2: (*Tcookie1)(unsafe.Pointer(c)).Flen1, + } + base = Int64FromUint64(**(**Tsize_t)(__ccgo_up(bp + uintptr(whence)*8))) + if off < -base || off > int64(0x7fffffffffffffff)-base { + goto fail + } + v2 = Uint64FromInt64(base + off) + (*Tcookie1)(unsafe.Pointer(c)).Fpos = v2 + return Int64FromUint64(v2) +} + +func _ms_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var c, newbuf, v1 uintptr + var len2 Tsize_t + _, _, _, _ = c, len2, newbuf, v1 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + len2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + if len2 != 0 { + (*TFILE)(unsafe.Pointer(f)).Fwpos = (*TFILE)(unsafe.Pointer(f)).Fwbase + if _ms_write(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwbase, len2) < len2 { + return uint64(0) + } + } + if len1+(*Tcookie1)(unsafe.Pointer(c)).Fpos >= (*Tcookie1)(unsafe.Pointer(c)).Fspace { + len2 = uint64(2)*(*Tcookie1)(unsafe.Pointer(c)).Fspace + uint64(1) | ((*Tcookie1)(unsafe.Pointer(c)).Fpos + len1 + uint64(1)) + newbuf = Xrealloc(tls, (*Tcookie1)(unsafe.Pointer(c)).Fbuf, len2) + if !(newbuf != 0) { + return uint64(0) + } + v1 = newbuf + (*Tcookie1)(unsafe.Pointer(c)).Fbuf = v1 + **(**uintptr)(__ccgo_up((*Tcookie1)(unsafe.Pointer(c)).Fbufp)) = v1 + Xmemset(tls, (*Tcookie1)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie1)(unsafe.Pointer(c)).Fspace), 0, len2-(*Tcookie1)(unsafe.Pointer(c)).Fspace) + (*Tcookie1)(unsafe.Pointer(c)).Fspace = len2 + } + Xmemcpy(tls, (*Tcookie1)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie1)(unsafe.Pointer(c)).Fpos), buf, len1) + **(**Tsize_t)(__ccgo_up(c + 16)) += len1 + if (*Tcookie1)(unsafe.Pointer(c)).Fpos >= (*Tcookie1)(unsafe.Pointer(c)).Flen1 { + (*Tcookie1)(unsafe.Pointer(c)).Flen1 = (*Tcookie1)(unsafe.Pointer(c)).Fpos + } + **(**Tsize_t)(__ccgo_up((*Tcookie1)(unsafe.Pointer(c)).Fsizep)) = (*Tcookie1)(unsafe.Pointer(c)).Fpos + return len1 +} + +func _ms_close(tls *TLS, f uintptr) (r int32) { + return 0 +} + +func Xopen_memstream(tls *TLS, bufp uintptr, sizep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v bufp=%v sizep=%v, (%v:)", tls, bufp, sizep, origin(2)) + defer func() { trc("-> %v", r) }() + } + var buf, f, v1 uintptr + var v3, v4, v5 Tsize_t + _, _, _, _, _, _ = buf, f, v1, v3, v4, v5 + v1 = Xmalloc(tls, uint64(1304)) + f = v1 + if !(v1 != 0) { + return uintptr(0) + } + v1 = Xmalloc(tls, uint64(1)) + buf = v1 + if !(v1 != 0) { + Xfree(tls, f) + return uintptr(0) + } + Xmemset(tls, f, 0, uint64(232)) + Xmemset(tls, f+232, 0, uint64(48)) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fcookie = f + 232 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fbufp = bufp + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fsizep = sizep + v5 = Uint64FromInt32(0) + **(**Tsize_t)(__ccgo_up(sizep)) = v5 + v4 = v5 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fspace = v4 + v3 = v4 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Flen1 = v3 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fpos = v3 + v1 = buf + **(**uintptr)(__ccgo_up(bufp)) = v1 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fbuf = v1 + **(**int8)(__ccgo_up(buf)) = 0 + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fflags = uint32(F_NORD) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Ffd = -int32(1) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fbuf = f + 280 + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fbuf_size = uint64(1024) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Flbf = -int32(1) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fwrite = __ccgo_fp(_ms_write) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fseek = __ccgo_fp(_ms_seek) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fclose1 = __ccgo_fp(_ms_close) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fmode = -int32(1) + if !(X__libc.Fthreaded != 0) { + AtomicStorePInt32(f+140, -int32(1)) + } + return X__ofl_add(tls, f) +} + +type Tcookie2 = struct { + Fbufp uintptr + Fsizep uintptr + Fpos Tsize_t + Fbuf uintptr + Flen1 Tsize_t + Fspace Tsize_t + Fmbs Tmbstate_t +} + +type Twms_FILE = struct { + Ff TFILE + Fc Tcookie2 + Fbuf [1]uint8 +} + +func _wms_seek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var base Tssize_t + var c uintptr + var v2 Tsize_t + _, _, _ = base, c, v2 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(Uint32FromInt32(whence) > uint32(2)) { + goto _1 + } + goto fail +fail: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) +_1: + ; + *(*[3]Tsize_t)(unsafe.Pointer(bp)) = [3]Tsize_t{ + 1: (*Tcookie2)(unsafe.Pointer(c)).Fpos, + 2: (*Tcookie2)(unsafe.Pointer(c)).Flen1, + } + base = Int64FromUint64(**(**Tsize_t)(__ccgo_up(bp + uintptr(whence)*8))) + if off < -base || off > Int64FromInt64(0x7fffffffffffffff)/Int64FromInt32(4)-base { + goto fail + } + Xmemset(tls, c+48, 0, uint64(8)) + v2 = Uint64FromInt64(base + off) + (*Tcookie2)(unsafe.Pointer(c)).Fpos = v2 + return Int64FromUint64(v2) +} + +func _wms_write(tls *TLS, f uintptr, _buf uintptr, len1 Tsize_t) (r Tsize_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _buf + var c, newbuf, v1 uintptr + var len2 Tsize_t + _, _, _, _ = c, len2, newbuf, v1 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + len2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + if len2 != 0 { + (*TFILE)(unsafe.Pointer(f)).Fwpos = (*TFILE)(unsafe.Pointer(f)).Fwbase + if _wms_write(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwbase, len2) < len2 { + return uint64(0) + } + } + if len1+(*Tcookie2)(unsafe.Pointer(c)).Fpos >= (*Tcookie2)(unsafe.Pointer(c)).Fspace { + len2 = uint64(2)*(*Tcookie2)(unsafe.Pointer(c)).Fspace + uint64(1) | ((*Tcookie2)(unsafe.Pointer(c)).Fpos + len1 + uint64(1)) + if len2 > Uint64FromInt64(Int64FromInt64(0x7fffffffffffffff)/Int64FromInt32(4)) { + return uint64(0) + } + newbuf = Xrealloc(tls, (*Tcookie2)(unsafe.Pointer(c)).Fbuf, len2*uint64(4)) + if !(newbuf != 0) { + return uint64(0) + } + v1 = newbuf + (*Tcookie2)(unsafe.Pointer(c)).Fbuf = v1 + **(**uintptr)(__ccgo_up((*Tcookie2)(unsafe.Pointer(c)).Fbufp)) = v1 + Xmemset(tls, (*Tcookie2)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie2)(unsafe.Pointer(c)).Fspace)*4, 0, uint64(4)*(len2-(*Tcookie2)(unsafe.Pointer(c)).Fspace)) + (*Tcookie2)(unsafe.Pointer(c)).Fspace = len2 + } + len2 = Xmbsnrtowcs(tls, (*Tcookie2)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie2)(unsafe.Pointer(c)).Fpos)*4, bp, len1, (*Tcookie2)(unsafe.Pointer(c)).Fspace-(*Tcookie2)(unsafe.Pointer(c)).Fpos, c+48) + if len2 == Uint64FromInt32(-Int32FromInt32(1)) { + return uint64(0) + } + **(**Tsize_t)(__ccgo_up(c + 16)) += len2 + if (*Tcookie2)(unsafe.Pointer(c)).Fpos >= (*Tcookie2)(unsafe.Pointer(c)).Flen1 { + (*Tcookie2)(unsafe.Pointer(c)).Flen1 = (*Tcookie2)(unsafe.Pointer(c)).Fpos + } + **(**Tsize_t)(__ccgo_up((*Tcookie2)(unsafe.Pointer(c)).Fsizep)) = (*Tcookie2)(unsafe.Pointer(c)).Fpos + return len1 +} + +func _wms_close(tls *TLS, f uintptr) (r int32) { + return 0 +} + +func Xopen_wmemstream(tls *TLS, bufp uintptr, sizep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v bufp=%v sizep=%v, (%v:)", tls, bufp, sizep, origin(2)) + defer func() { trc("-> %v", r) }() + } + var buf, f, v1 uintptr + var v3, v4, v5 Tsize_t + _, _, _, _, _, _ = buf, f, v1, v3, v4, v5 + v1 = Xmalloc(tls, uint64(296)) + f = v1 + if !(v1 != 0) { + return uintptr(0) + } + v1 = Xmalloc(tls, uint64(4)) + buf = v1 + if !(v1 != 0) { + Xfree(tls, f) + return uintptr(0) + } + Xmemset(tls, f, 0, uint64(232)) + Xmemset(tls, f+232, 0, uint64(56)) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fcookie = f + 232 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fbufp = bufp + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fsizep = sizep + v5 = Uint64FromInt32(0) + **(**Tsize_t)(__ccgo_up(sizep)) = v5 + v4 = v5 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fspace = v4 + v3 = v4 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Flen1 = v3 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fpos = v3 + v1 = buf + **(**uintptr)(__ccgo_up(bufp)) = v1 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fbuf = v1 + **(**Twchar_t)(__ccgo_up(buf)) = 0 + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fflags = uint32(F_NORD) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Ffd = -int32(1) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fbuf = f + 288 + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fbuf_size = uint64(0) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Flbf = -int32(1) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fwrite = __ccgo_fp(_wms_write) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fseek = __ccgo_fp(_wms_seek) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fclose1 = __ccgo_fp(_wms_close) + if !(X__libc.Fthreaded != 0) { + AtomicStorePInt32(f+140, -int32(1)) + } + Xfwide(tls, f, int32(1)) + return X__ofl_add(tls, f) +} + +func Xpclose(tls *TLS, f uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var pid Tpid_t + var r, v1 int32 + var _ /* status at bp+0 */ int32 + _, _, _ = pid, r, v1 + pid = (*TFILE)(unsafe.Pointer(f)).Fpipe_pid + Xfclose(tls, f) + for { + v1 = int32(X__syscall4(tls, int64(SYS_wait4), int64(pid), int64(bp), int64(Int32FromInt32(0)), int64(Int32FromInt32(0)))) + r = v1 + if !(v1 == -int32(EINTR)) { + break + } + } + if r < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + return **(**int32)(__ccgo_up(bp)) +} + +func Xperror(tls *TLS, msg uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v, (%v:)", tls, msg, origin(2)) + } + var __need_unlock, old_mode, v1 int32 + var errstr, f, old_locale uintptr + _, _, _, _, _, _ = __need_unlock, errstr, f, old_locale, old_mode, v1 + f = uintptr(unsafe.Pointer(&X__stderr_FILE)) + errstr = Xstrerror(tls, **(**int32)(__ccgo_up(X__errno_location(tls)))) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + /* Save stderr's orientation and encoding rule, since perror is not + * permitted to change them. */ + old_locale = (*TFILE)(unsafe.Pointer(f)).Flocale + old_mode = (*TFILE)(unsafe.Pointer(f)).Fmode + if msg != 0 && **(**int8)(__ccgo_up(msg)) != 0 { + Xfwrite(tls, msg, _strlen(tls, msg), uint64(1), f) + Xfputc(tls, int32(':'), f) + Xfputc(tls, int32(' '), f) + } + Xfwrite(tls, errstr, _strlen(tls, errstr), uint64(1), f) + Xfputc(tls, int32('\n'), f) + (*TFILE)(unsafe.Pointer(f)).Fmode = old_mode + (*TFILE)(unsafe.Pointer(f)).Flocale = old_locale + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xprintf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfprintf(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), fmt, ap) + _ = ap + return ret +} + +func _locking_putc1(tls *TLS, c int32, f uintptr) (r int32) { + var v1, v2, v4, v8 int32 + var v6, v7 uintptr + var v5 uint8 + _, _, _, _, _, _, _ = v1, v2, v4, v5, v6, v7, v8 + v1 = 0 + // __asm__ __volatile__ ( + // + // "lock ; cmpxchg %3, %1" + // : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 4, __ccgo_ts+1538) + v2 = v1 + goto _3 +_3: + if v2 != 0 { + ___lockfile(tls, f) + } + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v5 = Uint8FromInt32(c) + v7 = f + 40 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) + 1 + **(**uint8)(__ccgo_up(v6)) = v5 + v1 = Int32FromUint8(v5) + } else { + v1 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + c = v1 + v1 = 0 + // __asm__ __volatile__( + // + // "xchg %0, %1" + // : "=r"(v), "=m"(*p) : "0"(v) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 22, __ccgo_ts+1538) + v2 = v1 + goto _10 +_10: + if v2&int32(MAYBE_WAITERS) != 0 { + v6 = f + 140 + v4 = int32(1) + v8 = int32(1) + if v8 != 0 { + v8 = int32(FUTEX_PRIVATE) + } + if v4 < Int32FromInt32(0) { + v4 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v6), int64(Int32FromInt32(FUTEX_WAKE)|v8), int64(v4)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v6), int64(Int32FromInt32(FUTEX_WAKE)), int64(v4)) != 0 + } + return c +} + +func Xputc(tls *TLS, c1 int32, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c1=%v f1=%v, (%v:)", tls, c1, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v1, v3, v5 int32 + var v2, v7, v8 uintptr + var v6 uint8 + _, _, _, _, _, _, _, _ = l, v1, v2, v3, v5, v6, v7, v8 + v1 = c1 + v2 = f1 + l = AtomicLoadPInt32(v2 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if Int32FromUint8(Uint8FromInt32(v1)) != (*TFILE)(unsafe.Pointer(v2)).Flbf && (*TFILE)(unsafe.Pointer(v2)).Fwpos != (*TFILE)(unsafe.Pointer(v2)).Fwend { + v6 = Uint8FromInt32(v1) + v8 = v2 + 40 + v7 = *(*uintptr)(unsafe.Pointer(v8)) + *(*uintptr)(unsafe.Pointer(v8)) = *(*uintptr)(unsafe.Pointer(v8)) + 1 + **(**uint8)(__ccgo_up(v7)) = v6 + v5 = Int32FromUint8(v6) + } else { + v5 = X__overflow(tls, v2, Int32FromUint8(Uint8FromInt32(v1))) + } + v3 = v5 + goto _4 + } + v3 = _locking_putc1(tls, v1, v2) + goto _4 +_4: + return v3 +} + +func X_IO_putc(tls *TLS, c1 int32, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c1=%v f1=%v, (%v:)", tls, c1, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xputc(tls, c1, f1) +} + +func Xputc_unlocked(tls *TLS, c int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + var v2 uint8 + var v3, v4 uintptr + _, _, _, _ = v1, v2, v3, v4 + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v2 = Uint8FromInt32(c) + v4 = f + 40 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(v3)) = v2 + v1 = Int32FromUint8(v2) + } else { + v1 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + return v1 +} + +func X_IO_putc_unlocked(tls *TLS, c int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xputc_unlocked(tls, c, f) +} + +func Xfputc_unlocked(tls *TLS, c int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xputc_unlocked(tls, c, f) +} + +func _locking_putc2(tls *TLS, c int32, f uintptr) (r int32) { + var v1, v2, v4, v8 int32 + var v6, v7 uintptr + var v5 uint8 + _, _, _, _, _, _, _ = v1, v2, v4, v5, v6, v7, v8 + v1 = 0 + // __asm__ __volatile__ ( + // + // "lock ; cmpxchg %3, %1" + // : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 4, __ccgo_ts+1538) + v2 = v1 + goto _3 +_3: + if v2 != 0 { + ___lockfile(tls, f) + } + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v5 = Uint8FromInt32(c) + v7 = f + 40 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) + 1 + **(**uint8)(__ccgo_up(v6)) = v5 + v1 = Int32FromUint8(v5) + } else { + v1 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + c = v1 + v1 = 0 + // __asm__ __volatile__( + // + // "xchg %0, %1" + // : "=r"(v), "=m"(*p) : "0"(v) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 22, __ccgo_ts+1538) + v2 = v1 + goto _10 +_10: + if v2&int32(MAYBE_WAITERS) != 0 { + v6 = f + 140 + v4 = int32(1) + v8 = int32(1) + if v8 != 0 { + v8 = int32(FUTEX_PRIVATE) + } + if v4 < Int32FromInt32(0) { + v4 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v6), int64(Int32FromInt32(FUTEX_WAKE)|v8), int64(v4)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v6), int64(Int32FromInt32(FUTEX_WAKE)), int64(v4)) != 0 + } + return c +} + +func Xputchar(tls *TLS, c1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c1=%v, (%v:)", tls, c1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v1, v3, v5 int32 + var v2, v7, v8 uintptr + var v6 uint8 + _, _, _, _, _, _, _, _ = l, v1, v2, v3, v5, v6, v7, v8 + v1 = c1 + v2 = uintptr(unsafe.Pointer(&X__stdout_FILE)) + l = AtomicLoadPInt32(v2 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if Int32FromUint8(Uint8FromInt32(v1)) != (*TFILE)(unsafe.Pointer(v2)).Flbf && (*TFILE)(unsafe.Pointer(v2)).Fwpos != (*TFILE)(unsafe.Pointer(v2)).Fwend { + v6 = Uint8FromInt32(v1) + v8 = v2 + 40 + v7 = *(*uintptr)(unsafe.Pointer(v8)) + *(*uintptr)(unsafe.Pointer(v8)) = *(*uintptr)(unsafe.Pointer(v8)) + 1 + **(**uint8)(__ccgo_up(v7)) = v6 + v5 = Int32FromUint8(v6) + } else { + v5 = X__overflow(tls, v2, Int32FromUint8(Uint8FromInt32(v1))) + } + v3 = v5 + goto _4 + } + v3 = _locking_putc2(tls, v1, v2) + goto _4 +_4: + return v3 +} + +func Xputchar_unlocked(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + var v2 uint8 + var v3, v4 uintptr + _, _, _, _ = v1, v2, v3, v4 + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Flbf && (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Fwpos != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Fwend { + v2 = Uint8FromInt32(c) + v4 = uintptr(unsafe.Pointer(&X__stdout_FILE)) + 40 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(v3)) = v2 + v1 = Int32FromUint8(v2) + } else { + v1 = X__overflow(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), Int32FromUint8(Uint8FromInt32(c))) + } + return v1 +} + +func Xputs(tls *TLS, s uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var __need_unlock, r, v1, v2 int32 + var v3 uint8 + var v4, v5 uintptr + var v6 bool + _, _, _, _, _, _, _, _ = __need_unlock, r, v1, v2, v3, v4, v5, v6 + if AtomicLoadPInt32(uintptr(unsafe.Pointer(&X__stdout_FILE))+140) >= 0 { + v1 = ___lockfile(tls, uintptr(unsafe.Pointer(&X__stdout_FILE))) + } else { + v1 = 0 + } + __need_unlock = v1 + if v6 = Xfputs(tls, s, uintptr(unsafe.Pointer(&X__stdout_FILE))) < 0; !v6 { + if Int32FromUint8(Uint8FromInt32(Int32FromUint8('\n'))) != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Flbf && (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Fwpos != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Fwend { + v3 = Uint8FromInt32(Int32FromUint8('\n')) + v5 = uintptr(unsafe.Pointer(&X__stdout_FILE)) + 40 + v4 = *(*uintptr)(unsafe.Pointer(v5)) + *(*uintptr)(unsafe.Pointer(v5)) = *(*uintptr)(unsafe.Pointer(v5)) + 1 + **(**uint8)(__ccgo_up(v4)) = v3 + v2 = Int32FromUint8(v3) + } else { + v2 = X__overflow(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), Int32FromUint8(Uint8FromInt32(Int32FromUint8('\n')))) + } + } + r = -BoolInt32(v6 || v2 < 0) + if __need_unlock != 0 { + ___unlockfile(tls, uintptr(unsafe.Pointer(&X__stdout_FILE))) + } + return r +} + +func Xputw(tls *TLS, _x int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v _x=%v f=%v, (%v:)", tls, _x, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*int32)(unsafe.Pointer(bp)) = _x + return Int32FromUint64(Xfwrite(tls, bp, uint64(4), uint64(1), f)) - int32(1) +} + +func Xputwc(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfputwc(tls, c, f) +} + +func Xputwchar(tls *TLS, c Twchar_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfputwc(tls, c, uintptr(unsafe.Pointer(&X__stdout_FILE))) +} + +func Xputwchar_unlocked(tls *TLS, c Twchar_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xputwchar(tls, c) +} + +func Xremove(tls *TLS, path uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall1(tls, int64(SYS_unlink), int64(path))) + if r == -int32(EISDIR) { + r = int32(X__syscall1(tls, int64(SYS_rmdir), int64(path))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xrename(tls *TLS, old uintptr, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v, (%v:)", tls, old, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_rename), int64(old), int64(new1))))) +} + +func Xrewind(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + var __need_unlock, v1 int32 + _, _ = __need_unlock, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + X__fseeko_unlocked(tls, f, 0, 0) + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_ERR)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvscanf(tls, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_scanf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscanf(tls, fmt, va) +} + +func Xsetbuf(tls *TLS, f uintptr, buf uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v, (%v:)", tls, f, buf, origin(2)) + } + var v1 int32 + _ = v1 + if buf != 0 { + v1 = _IOFBF + } else { + v1 = int32(_IONBF) + } + Xsetvbuf(tls, f, buf, v1, uint64(BUFSIZ)) +} + +func Xsetbuffer(tls *TLS, f uintptr, buf uintptr, size Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v size=%v, (%v:)", tls, f, buf, size, origin(2)) + } + var v1 int32 + _ = v1 + if buf != 0 { + v1 = _IOFBF + } else { + v1 = int32(_IONBF) + } + Xsetvbuf(tls, f, buf, v1, size) +} + +func Xsetlinebuf(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + Xsetvbuf(tls, f, uintptr(0), int32(_IOLBF), uint64(0)) +} + +/* The behavior of this function is undefined except when it is the first + * operation on the stream, so the presence or absence of locking is not + * observable in a program whose behavior is defined. Thus no locking is + * performed here. No allocation of buffers is performed, but a buffer + * provided by the caller is used as long as it is suitably sized. */ + +func Xsetvbuf(tls *TLS, f uintptr, buf uintptr, type1 int32, size Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v type1=%v size=%v, (%v:)", tls, f, buf, type1, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*TFILE)(unsafe.Pointer(f)).Flbf = -int32(1) + if type1 == int32(_IONBF) { + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = uint64(0) + } else { + if type1 == int32(_IOLBF) || type1 == _IOFBF { + if buf != 0 && size >= uint64(UNGET) { + (*TFILE)(unsafe.Pointer(f)).Fbuf = buf + UintptrFromInt32(UNGET) + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = size - uint64(UNGET) + } + if type1 == int32(_IOLBF) && (*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0 { + (*TFILE)(unsafe.Pointer(f)).Flbf = int32('\n') + } + } else { + return -int32(1) + } + } + **(**uint32)(__ccgo_up(f)) |= uint32(F_SVB) + return 0 +} + +func Xsnprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v va=%v, (%v:)", tls, s, n, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvsnprintf(tls, s, n, fmt, ap) + _ = ap + return ret +} + +func Xsprintf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvsprintf(tls, s, fmt, ap) + _ = ap + return ret +} + +func Xsscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvsscanf(tls, s, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_sscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsscanf(tls, s, fmt, va) +} + +var _buf5 [8]uint8 + +func init() { + p := unsafe.Pointer(&X__stderr_FILE) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(X__stdio_close) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(X__stdio_write) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(X__stdio_seek) +} + +var _buf6 [1032]uint8 + +func init() { + p := unsafe.Pointer(&X__stdin_FILE) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(X__stdio_close) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(X__stdio_read) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(X__stdio_seek) +} + +var _buf7 [1032]uint8 + +func init() { + p := unsafe.Pointer(&X__stdout_FILE) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(X__stdio_close) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(X__stdout_write) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(X__stdio_seek) +} + +func Xswprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v va=%v, (%v:)", tls, s, n, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvswprintf(tls, s, n, fmt, ap) + _ = ap + return ret +} + +func Xswscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvswscanf(tls, s, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_swscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xswscanf(tls, s, fmt, va) +} + +const MAXTRIES = 100 + +func Xtempnam(tls *TLS, dir uintptr, pfx uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v dir=%v pfx=%v, (%v:)", tls, dir, pfx, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(4112) + defer tls.Free(4112) + var dl, l, pl Tsize_t + var r, try int32 + var _ /* s at bp+1 */ [4096]int8 + _, _, _, _, _ = dl, l, pl, r, try + if !(dir != 0) { + dir = __ccgo_ts + 1590 + } + if !(pfx != 0) { + pfx = __ccgo_ts + 1595 + } + dl = _strlen(tls, dir) + pl = _strlen(tls, pfx) + l = dl + uint64(1) + pl + uint64(1) + uint64(6) + if l >= uint64(PATH_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return uintptr(0) + } + Xmemcpy(tls, bp+1, dir, dl) + (**(**[4096]int8)(__ccgo_up(bp + 1)))[dl] = int8('/') + Xmemcpy(tls, bp+1+uintptr(dl)+uintptr(1), pfx, pl) + (**(**[4096]int8)(__ccgo_up(bp + 1)))[dl+uint64(1)+pl] = int8('_') + (**(**[4096]int8)(__ccgo_up(bp + 1)))[l] = 0 + try = 0 + for { + if !(try < int32(MAXTRIES)) { + break + } + ___randname(tls, bp+1+uintptr(l)-uintptr(6)) + *(*[1]int8)(unsafe.Pointer(bp)) = [1]int8{} + r = int32(X__syscall3(tls, int64(SYS_readlink), int64(bp+1), int64(bp), int64(Int32FromInt32(1)))) + if r == -int32(ENOENT) { + return Xstrdup(tls, bp+1) + } + goto _1 + _1: + ; + try = try + 1 + } + return uintptr(0) +} + +func Xtmpfile(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var f uintptr + var fd, try int32 + var _ /* s at bp+0 */ [20]int8 + _, _, _ = f, fd, try + **(**[20]int8)(__ccgo_up(bp)) = [20]int8{'/', 't', 'm', 'p', '/', 't', 'm', 'p', 'f', 'i', 'l', 'e', '_', 'X', 'X', 'X', 'X', 'X', 'X'} + try = 0 + for { + if !(try < int32(MAXTRIES)) { + break + } + ___randname(tls, bp+uintptr(13)) + fd = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_open), int64(bp), int64(Int32FromInt32(O_RDWR)|Int32FromInt32(O_CREAT)|Int32FromInt32(O_EXCL)|Int32FromInt32(O_LARGEFILE)), int64(Int32FromInt32(0600)))))) + if fd >= 0 { + X__syscall1(tls, int64(SYS_unlink), int64(bp)) + f = X__fdopen(tls, fd, __ccgo_ts+1600) + if !(f != 0) { + X__syscall1(tls, int64(SYS_close), int64(fd)) + } + return f + } + goto _1 + _1: + ; + try = try + 1 + } + return uintptr(0) +} + +func Xtmpnam(tls *TLS, buf uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v buf=%v, (%v:)", tls, buf, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var r, try int32 + var v2 uintptr + var _ /* s at bp+1 */ [19]int8 + _, _, _ = r, try, v2 + **(**[19]int8)(__ccgo_up(bp + 1)) = [19]int8{'/', 't', 'm', 'p', '/', 't', 'm', 'p', 'n', 'a', 'm', '_', 'X', 'X', 'X', 'X', 'X', 'X'} + try = 0 + for { + if !(try < int32(MAXTRIES)) { + break + } + ___randname(tls, bp+1+uintptr(12)) + *(*[1]int8)(unsafe.Pointer(bp)) = [1]int8{} + r = int32(X__syscall3(tls, int64(SYS_readlink), int64(bp+1), int64(bp), int64(Int32FromInt32(1)))) + if r == -int32(ENOENT) { + if buf != 0 { + v2 = buf + } else { + v2 = uintptr(unsafe.Pointer(&_internal1)) + } + return Xstrcpy(tls, v2, bp+1) + } + goto _1 + _1: + ; + try = try + 1 + } + return uintptr(0) +} + +var _internal1 [20]int8 + +func Xungetc(tls *TLS, c int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var v2, v3 uintptr + _, _, _, _ = __need_unlock, v1, v2, v3 + if c == -int32(1) { + return c + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) { + X__toread(tls, f) + } + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) || (*TFILE)(unsafe.Pointer(f)).Frpos <= (*TFILE)(unsafe.Pointer(f)).Fbuf-uintptr(UNGET) { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return -int32(1) + } + v3 = f + 8 + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) - 1 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + **(**uint8)(__ccgo_up(v2)) = Uint8FromInt32(c) + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_EOF)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return Int32FromUint8(Uint8FromInt32(c)) +} + +func Xungetwc(tls *TLS, c Twint_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var __need_unlock, l, v1 int32 + var loc Tlocale_t + var ploc, v4, v5 uintptr + var v3 bool + var _ /* mbc at bp+0 */ [4]uint8 + _, _, _, _, _, _, _, _ = __need_unlock, l, loc, ploc, v1, v3, v4, v5 + ploc = uintptr(___get_tp(tls)) + 168 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if (*TFILE)(unsafe.Pointer(f)).Fmode <= 0 { + Xfwide(tls, f, int32(1)) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = (*TFILE)(unsafe.Pointer(f)).Flocale + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) { + X__toread(tls, f) + } + if v3 = !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) || c == uint32(0xffffffff); !v3 { + v1 = Int32FromUint64(Xwcrtomb(tls, bp, Int32FromUint32(c), uintptr(0))) + l = v1 + } + if v3 || v1 < 0 || (*TFILE)(unsafe.Pointer(f)).Frpos < (*TFILE)(unsafe.Pointer(f)).Fbuf-uintptr(UNGET)+uintptr(l) { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return uint32(0xffffffff) + } + if BoolInt32(c < uint32(128)) != 0 { + v5 = f + 8 + *(*uintptr)(unsafe.Pointer(v5)) = *(*uintptr)(unsafe.Pointer(v5)) - 1 + v4 = *(*uintptr)(unsafe.Pointer(v5)) + **(**uint8)(__ccgo_up(v4)) = uint8(c) + } else { + v4 = f + 8 + *(*uintptr)(unsafe.Pointer(v4)) -= uintptr(l) + Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(v4)), bp, Uint64FromInt32(l)) + } + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_EOF)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return c +} + +func Xvasprintf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap2 Tva_list + var l int32 + var v1 uintptr + var v2 bool + _, _, _, _ = ap2, l, v1, v2 + ap2 = ap + l = Xvsnprintf(tls, uintptr(0), uint64(0), fmt, ap2) + _ = ap2 + if v2 = l < 0; !v2 { + v1 = Xmalloc(tls, uint64(Uint32FromInt32(l)+uint32(1))) + **(**uintptr)(__ccgo_up(s)) = v1 + } + if v2 || !(v1 != 0) { + return -int32(1) + } + return Xvsnprintf(tls, **(**uintptr)(__ccgo_up(s)), uint64(Uint32FromInt32(l)+uint32(1)), fmt, ap) +} + +func Xvdprintf(tls *TLS, fd int32, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v fmt=%v ap=%v, (%v:)", tls, fd, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(240) + defer tls.Free(240) + var _ /* f at bp+0 */ TFILE + **(**TFILE)(__ccgo_up(bp)) = TFILE{ + Fwrite: __ccgo_fp(X__stdio_write), + Fbuf: fmt, + Ffd: fd, + Flock: -int32(1), + Flbf: -int32(1), + } + return Xvfprintf(tls, bp, fmt, ap) +} + +const ALT_FORM = 8 +const FLAGMASK = 75913 +const GROUPED = 128 +const LDBL_EPSILON3 = 2.22044604925031308085e-16 +const LEFT_ADJ = 8192 +const MARK_POS = 2048 +const PAD_POS = 1 +const ZERO_PAD = 65536 + +const _BARE = 0 +const _LPRE = 1 +const _LLPRE = 2 +const _HPRE = 3 +const _HHPRE = 4 +const _BIGLPRE = 5 +const _ZTPRE = 6 +const _JPRE = 7 +const _STOP = 8 +const _PTR = 9 +const _INT = 10 +const _UINT = 11 +const _ULLONG = 12 +const _LONG = 13 +const _ULONG = 14 +const _SHORT = 15 +const _USHORT = 16 +const _CHAR = 17 +const _UCHAR = 18 +const _LLONG = 19 +const _SIZET = 20 +const _IMAX = 21 +const _UMAX = 22 +const _PDIFF = 23 +const _UIPTR = 24 +const _DBL = 25 +const _LDBL = 26 +const _NOARG = 27 +const _MAXSTATE = 28 + +var _states = [8][58]uint8{ + 0: { + 0: uint8(_DBL), + 2: uint8(_UINT), + 4: uint8(_DBL), + 5: uint8(_DBL), + 6: uint8(_DBL), + 11: uint8(_BIGLPRE), + 18: uint8(_PTR), + 23: uint8(_UINT), + 32: uint8(_DBL), + 34: uint8(_INT), + 35: uint8(_INT), + 36: uint8(_DBL), + 37: uint8(_DBL), + 38: uint8(_DBL), + 39: uint8(_HPRE), + 40: uint8(_INT), + 41: uint8(_JPRE), + 43: uint8(_LPRE), + 44: uint8(_NOARG), + 45: uint8(_PTR), + 46: uint8(_UINT), + 47: uint8(_UIPTR), + 50: uint8(_PTR), + 51: uint8(_ZTPRE), + 52: uint8(_UINT), + 55: uint8(_UINT), + 57: uint8(_ZTPRE), + }, + 1: { + 0: uint8(_DBL), + 4: uint8(_DBL), + 5: uint8(_DBL), + 6: uint8(_DBL), + 23: uint8(_ULONG), + 32: uint8(_DBL), + 34: uint8(_UINT), + 35: uint8(_LONG), + 36: uint8(_DBL), + 37: uint8(_DBL), + 38: uint8(_DBL), + 40: uint8(_LONG), + 43: uint8(_LLPRE), + 45: uint8(_PTR), + 46: uint8(_ULONG), + 50: uint8(_PTR), + 52: uint8(_ULONG), + 55: uint8(_ULONG), + }, + 2: { + 23: uint8(_ULLONG), + 35: uint8(_LLONG), + 40: uint8(_LLONG), + 45: uint8(_PTR), + 46: uint8(_ULLONG), + 52: uint8(_ULLONG), + 55: uint8(_ULLONG), + }, + 3: { + 23: uint8(_USHORT), + 35: uint8(_SHORT), + 39: uint8(_HHPRE), + 40: uint8(_SHORT), + 45: uint8(_PTR), + 46: uint8(_USHORT), + 52: uint8(_USHORT), + 55: uint8(_USHORT), + }, + 4: { + 23: uint8(_UCHAR), + 35: uint8(_CHAR), + 40: uint8(_CHAR), + 45: uint8(_PTR), + 46: uint8(_UCHAR), + 52: uint8(_UCHAR), + 55: uint8(_UCHAR), + }, + 5: { + 0: uint8(_LDBL), + 4: uint8(_LDBL), + 5: uint8(_LDBL), + 6: uint8(_LDBL), + 32: uint8(_LDBL), + 36: uint8(_LDBL), + 37: uint8(_LDBL), + 38: uint8(_LDBL), + 45: uint8(_PTR), + }, + 6: { + 23: uint8(_SIZET), + 35: uint8(_PDIFF), + 40: uint8(_PDIFF), + 45: uint8(_PTR), + 46: uint8(_SIZET), + 52: uint8(_SIZET), + 55: uint8(_SIZET), + }, + 7: { + 23: uint8(_UMAX), + 35: uint8(_IMAX), + 40: uint8(_IMAX), + 45: uint8(_PTR), + 46: uint8(_UMAX), + 52: uint8(_UMAX), + 55: uint8(_UMAX), + }, +} + +type Targ = struct { + Ff [0]float64 + Fp [0]uintptr + Fi Tuintmax_t +} + +func _pop_arg(tls *TLS, arg uintptr, type1 int32, ap uintptr) { + switch type1 { + case int32(_PTR): + *(*uintptr)(unsafe.Pointer(arg)) = VaUintptr(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_INT): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UINT): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUint32(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_LONG): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_ULONG): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_ULLONG): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUint64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_SHORT): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt16(int16(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_USHORT): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(Uint16FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_CHAR): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt8(int8(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_UCHAR): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(Uint8FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_LLONG): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_SIZET): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_IMAX): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UMAX): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_PDIFF): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UIPTR): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUintptr(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_DBL): + *(*float64)(unsafe.Pointer(arg)) = float64(VaFloat64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_LDBL): + *(*float64)(unsafe.Pointer(arg)) = VaFloat64(&**(**Tva_list)(__ccgo_up(ap))) + } +} + +func _out(tls *TLS, f uintptr, s uintptr, l Tsize_t) { + if !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_ERR) != 0) { + X__fwritex(tls, s, l, f) + } +} + +func _pad3(tls *TLS, f uintptr, c int8, w int32, l int32, fl int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var v1 uint64 + var _ /* pad at bp+0 */ [256]int8 + _ = v1 + if Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' '))) != 0 || l >= w { + return + } + l = w - l + if Uint64FromInt32(l) > uint64(256) { + v1 = uint64(256) + } else { + v1 = Uint64FromInt32(l) + } + Xmemset(tls, bp, int32(c), v1) + for { + if !(Uint64FromInt32(l) >= uint64(256)) { + break + } + _out(tls, f, bp, uint64(256)) + goto _2 + _2: + ; + l = Int32FromUint64(uint64(l) - Uint64FromInt64(256)) + } + _out(tls, f, bp, Uint64FromInt32(l)) +} + +var _xdigits1 = [16]int8{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'} + +func _fmt_x(tls *TLS, x Tuintmax_t, s uintptr, lower int32) (r uintptr) { + var v2 uintptr + _ = v2 + for { + if !(x != 0) { + break + } + s = s - 1 + v2 = s + **(**int8)(__ccgo_up(v2)) = int8(int32(_xdigits1[x&uint64(15)]) | lower) + goto _1 + _1: + ; + x = x >> uint64(4) + } + return s +} + +func _fmt_o(tls *TLS, x Tuintmax_t, s uintptr) (r uintptr) { + var v2 uintptr + _ = v2 + for { + if !(x != 0) { + break + } + s = s - 1 + v2 = s + **(**int8)(__ccgo_up(v2)) = Int8FromUint64(uint64('0') + x&uint64(7)) + goto _1 + _1: + ; + x = x >> uint64(3) + } + return s +} + +func _fmt_u(tls *TLS, x Tuintmax_t, s uintptr) (r uintptr) { + var y uint64 + var v2 uintptr + _, _ = y, v2 + for { + if !(x > Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)) { + break + } + s = s - 1 + v2 = s + **(**int8)(__ccgo_up(v2)) = Int8FromUint64(uint64('0') + x%uint64(10)) + goto _1 + _1: + ; + x = x / uint64(10) + } + y = x + for { + if !(y != 0) { + break + } + s = s - 1 + v2 = s + **(**int8)(__ccgo_up(v2)) = Int8FromUint64(uint64('0') + y%uint64(10)) + goto _3 + _3: + ; + y = y / uint64(10) + } + return s +} + +// C documentation +// +// /* Do not override this check. The floating point printing code below +// * depends on the float.h constants being right. If they are wrong, it +// * may overflow the stack. */ +type Tcompiler_defines_long_double_incorrectly = [1]int8 + +func _fmt_fp(tls *TLS, f uintptr, y float64, w int32, p int32, fl int32, t int32) (r1 int32) { + bp := tls.Alloc(560) + defer tls.Free(560) + var a, b, d, ebuf, estr, prefix, r, s, s1, s2, s3, s4, z, v5, v6 uintptr + var carry, carry1, rm, x2 Tuint32_t + var e, i, j, l, need, pl, re, sh, sh1, x, v7 int32 + var round, round1, small float64 + var x1 Tuint64_t + var v1 uint64 + var v36, v37, v38 int64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* big at bp+8 */ [126]Tuint32_t + var _ /* buf at bp+516 */ [22]int8 + var _ /* e2 at bp+512 */ int32 + var _ /* ebuf0 at bp+538 */ [12]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, b, carry, carry1, d, e, ebuf, estr, i, j, l, need, pl, prefix, r, re, rm, round, round1, s, s1, s2, s3, s4, sh, sh1, small, x, x1, x2, z, v1, v36, v37, v38, v5, v6, v7 + **(**int32)(__ccgo_up(bp + 512)) = 0 + prefix = __ccgo_ts + 1603 + ebuf = bp + 538 + uintptr(Uint64FromInt32(3)*Uint64FromInt64(4)) + pl = int32(1) + *(*float64)(unsafe.Pointer(bp)) = y + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if Int32FromUint64(v1>>Int32FromInt32(63)) != 0 { + y = -y + } else { + if Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))) != 0 { + prefix = prefix + uintptr(3) + } else { + if Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))) != 0 { + prefix = prefix + uintptr(6) + } else { + prefix = prefix + 1 + pl = Int32FromInt32(0) + } + } + } + *(*float64)(unsafe.Pointer(bp)) = y + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _4 +_4: + if !(BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< int32(3)+pl { + v7 = w + } else { + v7 = int32(3) + pl + } + return v7 + } + y = float64(Xfrexpl(tls, y, bp+512) * Float64FromInt32(2)) + if y != 0 { + **(**int32)(__ccgo_up(bp + 512)) = **(**int32)(__ccgo_up(bp + 512)) - 1 + } + if t|int32(32) == int32('a') { + round = Float64FromFloat64(8) + if t&int32(32) != 0 { + prefix = prefix + uintptr(9) + } + pl = pl + int32(2) + if p < 0 || p >= Int32FromInt32(LDBL_MANT_DIG)/Int32FromInt32(4)-Int32FromInt32(1) { + re = 0 + } else { + re = Int32FromInt32(LDBL_MANT_DIG)/Int32FromInt32(4) - Int32FromInt32(1) - p + } + if re != 0 { + round = round * float64(Int32FromInt32(1)<<(Int32FromInt32(LDBL_MANT_DIG)%Int32FromInt32(4))) + for { + v7 = re + re = re - 1 + if !(v7 != 0) { + break + } + round = round * Float64FromInt32(16) + } + if int32(**(**int8)(__ccgo_up(prefix))) == int32('-') { + y = -y + y = y - round + y = y + round + y = -y + } else { + y = y + round + y = y - round + } + } + if **(**int32)(__ccgo_up(bp + 512)) < 0 { + v7 = -**(**int32)(__ccgo_up(bp + 512)) + } else { + v7 = **(**int32)(__ccgo_up(bp + 512)) + } + estr = _fmt_u(tls, Uint64FromInt32(v7), ebuf) + if estr == ebuf { + estr = estr - 1 + v5 = estr + **(**int8)(__ccgo_up(v5)) = int8('0') + } + estr = estr - 1 + v5 = estr + if **(**int32)(__ccgo_up(bp + 512)) < 0 { + v7 = int32('-') + } else { + v7 = int32('+') + } + **(**int8)(__ccgo_up(v5)) = int8(v7) + estr = estr - 1 + v5 = estr + **(**int8)(__ccgo_up(v5)) = int8(t + (Int32FromUint8('p') - Int32FromUint8('a'))) + s = bp + 516 + for cond := true; cond; cond = y != 0 { + x = int32(y) + v5 = s + s = s + 1 + **(**int8)(__ccgo_up(v5)) = int8(int32(_xdigits1[x]) | t&int32(32)) + y = float64(Float64FromInt32(16) * (y - float64(x))) + if int64(s)-t__predefined_ptrdiff_t(bp+516) == int64(1) && (y != 0 || p > 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0) { + v5 = s + s = s + 1 + **(**int8)(__ccgo_up(v5)) = int8('.') + } + } + if int64(p) > int64(Int32FromInt32(INT_MAX)-Int32FromInt32(2))-(int64(ebuf)-int64(estr))-int64(pl) { + return -int32(1) + } + if p != 0 && int64(s)-t__predefined_ptrdiff_t(bp+516)-int64(2) < int64(p) { + l = int32(int64(p+Int32FromInt32(2)) + (int64(ebuf) - int64(estr))) + } else { + l = int32(int64(s) - t__predefined_ptrdiff_t(bp+516) + (int64(ebuf) - int64(estr))) + } + _pad3(tls, f, int8(' '), w, pl+l, fl) + _out(tls, f, prefix, Uint64FromInt32(pl)) + _pad3(tls, f, int8('0'), w, pl+l, Int32FromUint32(Uint32FromInt32(fl)^Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' ')))) + _out(tls, f, bp+516, Uint64FromInt64(int64(s)-t__predefined_ptrdiff_t(bp+516))) + _pad3(tls, f, int8('0'), int32(int64(l)-(int64(ebuf)-int64(estr))-(int64(s)-t__predefined_ptrdiff_t(bp+516))), 0, 0) + _out(tls, f, estr, Uint64FromInt64(int64(ebuf)-int64(estr))) + _pad3(tls, f, int8(' '), w, pl+l, Int32FromUint32(Uint32FromInt32(fl)^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + if w > pl+l { + v7 = w + } else { + v7 = pl + l + } + return v7 + } + if p < 0 { + p = int32(6) + } + if y != 0 { + y = y * Float64FromFloat64(2.68435456e+08) + **(**int32)(__ccgo_up(bp + 512)) = **(**int32)(__ccgo_up(bp + 512)) - int32(28) + } + if **(**int32)(__ccgo_up(bp + 512)) < 0 { + v6 = bp + 8 + z = v6 + v5 = v6 + r = v5 + a = v5 + } else { + v6 = bp + 8 + uintptr(Uint64FromInt64(504)/Uint64FromInt64(4))*4 - UintptrFromInt32(LDBL_MANT_DIG)*4 - UintptrFromInt32(1)*4 + z = v6 + v5 = v6 + r = v5 + a = v5 + } + for cond := true; cond; cond = y != 0 { + **(**Tuint32_t)(__ccgo_up(z)) = uint32(y) + v5 = z + z += 4 + y = float64(Float64FromInt32(1000000000) * (y - float64(**(**Tuint32_t)(__ccgo_up(v5))))) + } + for **(**int32)(__ccgo_up(bp + 512)) > 0 { + carry = uint32(0) + if int32(29) < **(**int32)(__ccgo_up(bp + 512)) { + v7 = int32(29) + } else { + v7 = **(**int32)(__ccgo_up(bp + 512)) + } + sh = v7 + d = z - uintptr(1)*4 + for { + if !(d >= a) { + break + } + x1 = uint64(**(**Tuint32_t)(__ccgo_up(d)))< a && !(**(**Tuint32_t)(__ccgo_up(z + uintptr(-Int32FromInt32(1))*4)) != 0) { + z -= 4 + } + **(**int32)(__ccgo_up(bp + 512)) = **(**int32)(__ccgo_up(bp + 512)) - sh + } + for **(**int32)(__ccgo_up(bp + 512)) < 0 { + carry1 = uint32(0) + if int32(9) < -**(**int32)(__ccgo_up(bp + 512)) { + v7 = int32(9) + } else { + v7 = -**(**int32)(__ccgo_up(bp + 512)) + } + sh1 = v7 + need = Int32FromUint32(uint32(1) + (Uint32FromInt32(p)+Uint32FromInt32(LDBL_MANT_DIG)/Uint32FromUint32(3)+uint32(8))/uint32(9)) + d = a + for { + if !(d < z) { + break + } + rm = **(**Tuint32_t)(__ccgo_up(d)) & Uint32FromInt32(int32(1)<>sh1 + carry1 + carry1 = Uint32FromInt32(Int32FromInt32(1000000000)>>sh1) * rm + goto _26 + _26: + ; + d += 4 + } + if !(**(**Tuint32_t)(__ccgo_up(a)) != 0) { + a += 4 + } + if carry1 != 0 { + v5 = z + z += 4 + **(**Tuint32_t)(__ccgo_up(v5)) = carry1 + } + /* Avoid (slow!) computation past requested precision */ + if t|int32(32) == int32('f') { + v5 = r + } else { + v5 = a + } + b = v5 + if (int64(z)-int64(b))/4 > int64(need) { + z = b + uintptr(need)*4 + } + **(**int32)(__ccgo_up(bp + 512)) = **(**int32)(__ccgo_up(bp + 512)) + sh1 + } + if a < z { + i = int32(10) + e = int32(Int64FromInt32(9) * ((int64(r) - int64(a)) / 4)) + for { + if !(**(**Tuint32_t)(__ccgo_up(a)) >= Uint32FromInt32(i)) { + break + } + goto _29 + _29: + ; + i = i * int32(10) + e = e + 1 + } + } else { + e = 0 + } + /* Perform rounding: j is precision after the radix (possibly neg) */ + j = p - BoolInt32(t|int32(32) != int32('f'))*e - BoolInt32(t|int32(32) == int32('g') && p != 0) + if int64(j) < int64(9)*((int64(z)-int64(r))/4-int64(1)) { + /* We avoid C's broken division of negative numbers */ + d = r + uintptr(1)*4 + uintptr((j+Int32FromInt32(9)*Int32FromInt32(LDBL_MAX_EXP))/Int32FromInt32(9)-Int32FromInt32(LDBL_MAX_EXP))*4 + j = j + Int32FromInt32(9)*Int32FromInt32(LDBL_MAX_EXP) + j = j % int32(9) + i = int32(10) + j = j + 1 + for { + if !(j < int32(9)) { + break + } + goto _30 + _30: + ; + i = i * int32(10) + j = j + 1 + } + x2 = **(**Tuint32_t)(__ccgo_up(d)) % Uint32FromInt32(i) + /* Are there any significant digits past j? */ + if x2 != 0 || d+uintptr(1)*4 != z { + round1 = Float64FromInt32(2) / Float64FromFloat64(2.22044604925031308085e-16) + if **(**Tuint32_t)(__ccgo_up(d))/Uint32FromInt32(i)&uint32(1) != 0 || i == int32(1000000000) && d > a && **(**Tuint32_t)(__ccgo_up(d + uintptr(-Int32FromInt32(1))*4))&uint32(1) != 0 { + round1 = round1 + Float64FromInt32(2) + } + if x2 < Uint32FromInt32(i/int32(2)) { + small = Float64FromFloat64(0.5) + } else { + if x2 == Uint32FromInt32(i/int32(2)) && d+uintptr(1)*4 == z { + small = Float64FromFloat64(1) + } else { + small = Float64FromFloat64(1.5) + } + } + if pl != 0 && int32(**(**int8)(__ccgo_up(prefix))) == int32('-') { + round1 = round1 * float64(-Int32FromInt32(1)) + small = small * float64(-Int32FromInt32(1)) + } + **(**Tuint32_t)(__ccgo_up(d)) -= x2 + /* Decide whether to round by probing round+small */ + if round1+small != round1 { + **(**Tuint32_t)(__ccgo_up(d)) = **(**Tuint32_t)(__ccgo_up(d)) + Uint32FromInt32(i) + for **(**Tuint32_t)(__ccgo_up(d)) > uint32(999999999) { + v5 = d + d -= 4 + **(**Tuint32_t)(__ccgo_up(v5)) = uint32(0) + if d < a { + a -= 4 + v5 = a + **(**Tuint32_t)(__ccgo_up(v5)) = uint32(0) + } + **(**Tuint32_t)(__ccgo_up(d)) = **(**Tuint32_t)(__ccgo_up(d)) + 1 + } + i = int32(10) + e = int32(Int64FromInt32(9) * ((int64(r) - int64(a)) / 4)) + for { + if !(**(**Tuint32_t)(__ccgo_up(a)) >= Uint32FromInt32(i)) { + break + } + goto _33 + _33: + ; + i = i * int32(10) + e = e + 1 + } + } + } + if z > d+uintptr(1)*4 { + z = d + uintptr(1)*4 + } + } + for { + if !(z > a && !(**(**Tuint32_t)(__ccgo_up(z + uintptr(-Int32FromInt32(1))*4)) != 0)) { + break + } + goto _34 + _34: + ; + z -= 4 + } + if t|int32(32) == int32('g') { + if !(p != 0) { + p = p + 1 + } + if p > e && e >= -int32(4) { + t = t - 1 + p = p - (e + int32(1)) + } else { + t = t - int32(2) + p = p - 1 + } + if !(Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0) { + /* Count trailing zeros in last place */ + if z > a && **(**Tuint32_t)(__ccgo_up(z + uintptr(-Int32FromInt32(1))*4)) != 0 { + i = int32(10) + j = Int32FromInt32(0) + for { + if !(**(**Tuint32_t)(__ccgo_up(z + uintptr(-Int32FromInt32(1))*4))%Uint32FromInt32(i) == uint32(0)) { + break + } + goto _35 + _35: + ; + i = i * int32(10) + j = j + 1 + } + } else { + j = int32(9) + } + if t|int32(32) == int32('f') { + if int64(Int32FromInt32(0)) > int64(9)*((int64(z)-int64(r))/4-int64(1))-int64(j) { + v37 = int64(Int32FromInt32(0)) + } else { + v37 = int64(9)*((int64(z)-int64(r))/4-int64(1)) - int64(j) + } + if int64(p) < v37 { + v36 = int64(p) + } else { + if int64(Int32FromInt32(0)) > int64(9)*((int64(z)-int64(r))/4-int64(1))-int64(j) { + v38 = int64(Int32FromInt32(0)) + } else { + v38 = int64(9)*((int64(z)-int64(r))/4-int64(1)) - int64(j) + } + v36 = v38 + } + p = int32(v36) + } else { + if int64(Int32FromInt32(0)) > int64(9)*((int64(z)-int64(r))/4-int64(1))+int64(e)-int64(j) { + v37 = int64(Int32FromInt32(0)) + } else { + v37 = int64(9)*((int64(z)-int64(r))/4-int64(1)) + int64(e) - int64(j) + } + if int64(p) < v37 { + v36 = int64(p) + } else { + if int64(Int32FromInt32(0)) > int64(9)*((int64(z)-int64(r))/4-int64(1))+int64(e)-int64(j) { + v38 = int64(Int32FromInt32(0)) + } else { + v38 = int64(9)*((int64(z)-int64(r))/4-int64(1)) + int64(e) - int64(j) + } + v36 = v38 + } + p = int32(v36) + } + } + } + if p > Int32FromInt32(INT_MAX)-Int32FromInt32(1)-BoolInt32(p != 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0) { + return -int32(1) + } + l = int32(1) + p + BoolInt32(p != 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0) + if t|int32(32) == int32('f') { + if e > int32(INT_MAX)-l { + return -int32(1) + } + if e > 0 { + l = l + e + } + } else { + if e < 0 { + v7 = -e + } else { + v7 = e + } + estr = _fmt_u(tls, Uint64FromInt32(v7), ebuf) + for int64(ebuf)-int64(estr) < int64(2) { + estr = estr - 1 + v5 = estr + **(**int8)(__ccgo_up(v5)) = int8('0') + } + estr = estr - 1 + v5 = estr + if e < 0 { + v7 = int32('-') + } else { + v7 = int32('+') + } + **(**int8)(__ccgo_up(v5)) = int8(v7) + estr = estr - 1 + v5 = estr + **(**int8)(__ccgo_up(v5)) = int8(t) + if int64(ebuf)-int64(estr) > int64(int32(INT_MAX)-l) { + return -int32(1) + } + l = int32(int64(l) + (int64(ebuf) - int64(estr))) + } + if l > int32(INT_MAX)-pl { + return -int32(1) + } + _pad3(tls, f, int8(' '), w, pl+l, fl) + _out(tls, f, prefix, Uint64FromInt32(pl)) + _pad3(tls, f, int8('0'), w, pl+l, Int32FromUint32(Uint32FromInt32(fl)^Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' ')))) + if t|int32(32) == int32('f') { + if a > r { + a = r + } + d = a + for { + if !(d <= r) { + break + } + s2 = _fmt_u(tls, uint64(**(**Tuint32_t)(__ccgo_up(d))), bp+516+uintptr(9)) + if d != a { + for s2 > bp+516 { + s2 = s2 - 1 + v5 = s2 + **(**int8)(__ccgo_up(v5)) = int8('0') + } + } else { + if s2 == bp+516+uintptr(9) { + s2 = s2 - 1 + v5 = s2 + **(**int8)(__ccgo_up(v5)) = int8('0') + } + } + _out(tls, f, s2, Uint64FromInt64(int64(bp+516+uintptr(9))-int64(s2))) + goto _47 + _47: + ; + d += 4 + } + if p != 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0 { + _out(tls, f, __ccgo_ts+575, uint64(1)) + } + for { + if !(d < z && p > 0) { + break + } + s3 = _fmt_u(tls, uint64(**(**Tuint32_t)(__ccgo_up(d))), bp+516+uintptr(9)) + for s3 > bp+516 { + s3 = s3 - 1 + v5 = s3 + **(**int8)(__ccgo_up(v5)) = int8('0') + } + if int32(9) < p { + v7 = int32(9) + } else { + v7 = p + } + _out(tls, f, s3, Uint64FromInt32(v7)) + goto _50 + _50: + ; + d += 4 + p = p - int32(9) + } + _pad3(tls, f, int8('0'), p+int32(9), int32(9), 0) + } else { + if z <= a { + z = a + uintptr(1)*4 + } + d = a + for { + if !(d < z && p >= 0) { + break + } + s4 = _fmt_u(tls, uint64(**(**Tuint32_t)(__ccgo_up(d))), bp+516+uintptr(9)) + if s4 == bp+516+uintptr(9) { + s4 = s4 - 1 + v5 = s4 + **(**int8)(__ccgo_up(v5)) = int8('0') + } + if d != a { + for s4 > bp+516 { + s4 = s4 - 1 + v5 = s4 + **(**int8)(__ccgo_up(v5)) = int8('0') + } + } else { + v5 = s4 + s4 = s4 + 1 + _out(tls, f, v5, uint64(1)) + if p > 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0 { + _out(tls, f, __ccgo_ts+575, uint64(1)) + } + } + if int64(bp+516+UintptrFromInt32(9))-int64(s4) < int64(p) { + v36 = int64(bp+516+UintptrFromInt32(9)) - int64(s4) + } else { + v36 = int64(p) + } + _out(tls, f, s4, Uint64FromInt64(v36)) + p = int32(int64(p) - (int64(bp+516+UintptrFromInt32(9)) - int64(s4))) + goto _53 + _53: + ; + d += 4 + } + _pad3(tls, f, int8('0'), p+int32(18), int32(18), 0) + _out(tls, f, estr, Uint64FromInt64(int64(ebuf)-int64(estr))) + } + _pad3(tls, f, int8(' '), w, pl+l, Int32FromUint32(Uint32FromInt32(fl)^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + if w > pl+l { + v7 = w + } else { + v7 = pl + l + } + return v7 +} + +func _getint(tls *TLS, s uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-uint32('0') < uint32(10)) != 0) { + break + } + if Uint32FromInt32(i) > Uint32FromInt32(INT_MAX)/Uint32FromUint32(10) || int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-int32('0') > int32(INT_MAX)-int32(10)*i { + i = -int32(1) + } else { + i = int32(10)*i + (int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(s))))) - int32('0')) + } + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(s)) = **(**uintptr)(__ccgo_up(s)) + 1 + } + return i +} + +func _printf_core(tls *TLS, f uintptr, fmt uintptr, ap uintptr, nl_arg uintptr, nl_type uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, prefix, ws, z, v8 uintptr + var argpos, cnt, l, p, pl, t, w, xp, v5, v6 int32 + var fl, l10n, ps, st uint32 + var i Tsize_t + var v31 uint64 + var v34 int64 + var v45 bool + var _ /* arg at bp+8 */ Targ + var _ /* buf at bp+16 */ [24]int8 + var _ /* mb at bp+48 */ [4]int8 + var _ /* s at bp+0 */ uintptr + var _ /* wc at bp+40 */ [2]Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, argpos, cnt, fl, i, l, l10n, p, pl, prefix, ps, st, t, w, ws, xp, z, v31, v34, v45, v5, v6, v8 + **(**uintptr)(__ccgo_up(bp)) = fmt + l10n = uint32(0) + cnt = 0 + l = 0 + for { + /* This error is only specified for snprintf, but since it's + * unspecified for other forms, do the same. Stop immediately + * on overflow; otherwise %n could produce wrong results. */ + if l > int32(INT_MAX)-cnt { + goto overflow + } + /* Update output count, end loop when fmt is exhausted */ + cnt = cnt + l + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0) { + break + } + /* Handle literal text and %% format specifiers */ + a = **(**uintptr)(__ccgo_up(bp)) + for { + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32('%')) { + break + } + goto _2 + _2: + ; + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + z = **(**uintptr)(__ccgo_up(bp)) + for { + if !(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32('%') && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1))) == int32('%')) { + break + } + goto _3 + _3: + ; + z = z + 1 + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(2) + } + if int64(z)-int64(a) > int64(int32(INT_MAX)-cnt) { + goto overflow + } + l = int32(int64(z) - int64(a)) + if f != 0 { + _out(tls, f, a, Uint64FromInt32(l)) + } + if l != 0 { + goto _1 + } + if BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1)))-uint32('0') < uint32(10)) != 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2))) == int32('$') { + l10n = uint32(1) + argpos = int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1))) - int32('0') + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(3) + } else { + argpos = -int32(1) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + /* Read modifier flags */ + fl = uint32(0) + for { + if !(Uint32FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))))-uint32(' ') < uint32(32) && (Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('\'')-Int32FromUint8(' ')))&(uint32(1)<<(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))))-int32(' '))) != 0) { + break + } + fl = fl | uint32(1)<<(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))))-int32(' ')) + goto _4 + _4: + ; + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + /* Read field width */ + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32('*') { + if BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1)))-uint32('0') < uint32(10)) != 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2))) == int32('$') { + l10n = uint32(1) + if !(f != 0) { + **(**int32)(__ccgo_up(nl_type + uintptr(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1)))-int32('0'))*4)) = int32(_INT) + w = Int32FromInt32(0) + } else { + w = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(nl_arg + uintptr(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1)))-int32('0'))*8))) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(3) + } else { + if !(l10n != 0) { + if f != 0 { + v5 = VaInt32(&**(**Tva_list)(__ccgo_up(ap))) + } else { + v5 = 0 + } + w = v5 + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } else { + goto inval + } + } + if w < 0 { + fl = fl | Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')) + w = -w + } + } else { + v5 = _getint(tls, bp) + w = v5 + if v5 < 0 { + goto overflow + } + } + /* Read precision */ + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32('.') && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1))) == int32('*') { + if BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2)))-uint32('0') < uint32(10)) != 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 3))) == int32('$') { + if !(f != 0) { + **(**int32)(__ccgo_up(nl_type + uintptr(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2)))-int32('0'))*4)) = int32(_INT) + p = Int32FromInt32(0) + } else { + p = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(nl_arg + uintptr(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2)))-int32('0'))*8))) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(4) + } else { + if !(l10n != 0) { + if f != 0 { + v5 = VaInt32(&**(**Tva_list)(__ccgo_up(ap))) + } else { + v5 = 0 + } + p = v5 + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(2) + } else { + goto inval + } + } + xp = BoolInt32(p >= 0) + } else { + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32('.') { + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + p = _getint(tls, bp) + xp = int32(1) + } else { + p = -int32(1) + xp = 0 + } + } + /* Format specifier state machine */ + st = uint32(0) + for cond := true; cond; cond = st-uint32(1) < uint32(_STOP) { + if Uint32FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))))-uint32('A') > Uint32FromInt32(Int32FromUint8('z')-Int32FromUint8('A')) { + goto inval + } + ps = st + v8 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + st = uint32(**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_states)) + uintptr(st)*58 + uintptr(int32(**(**int8)(__ccgo_up(v8)))-int32('A'))))) + } + if !(st != 0) { + goto inval + } + /* Check validity of argument type (nl/normal) */ + if st == uint32(_NOARG) { + if argpos >= 0 { + goto inval + } + } else { + if argpos >= 0 { + if !(f != 0) { + **(**int32)(__ccgo_up(nl_type + uintptr(argpos)*4)) = Int32FromUint32(st) + } else { + **(**Targ)(__ccgo_up(bp + 8)) = **(**Targ)(__ccgo_up(nl_arg + uintptr(argpos)*8)) + } + } else { + if f != 0 { + _pop_arg(tls, bp+8, Int32FromUint32(st), ap) + } else { + return 0 + } + } + } + if !(f != 0) { + goto _1 + } + /* Do not process any new directives once in error state. */ + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + return -int32(1) + } + z = bp + 16 + uintptr(24) + prefix = __ccgo_ts + 1634 + pl = 0 + t = int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(-Int32FromInt32(1))))) + /* Transform ls,lc -> S,C */ + if ps != 0 && t&int32(15) == int32(3) { + t = t & ^Int32FromInt32(32) + } + /* - and 0 flags are mutually exclusive */ + if fl&(Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))) != 0 { + fl = fl & ^(Uint32FromUint32(1) << (Int32FromUint8('0') - Int32FromUint8(' '))) + } + switch t { + case int32('n'): + goto _9 + case int32('p'): + goto _10 + case int32('X'): + goto _11 + case int32('x'): + goto _12 + case int32('o'): + goto _13 + case int32('i'): + goto _14 + case int32('d'): + goto _15 + case int32('u'): + goto _16 + case int32('c'): + goto _17 + case int32('s'): + goto _18 + case int32('m'): + goto _19 + case int32('C'): + goto _20 + case int32('S'): + goto _21 + case int32('A'): + goto _22 + case int32('G'): + goto _23 + case int32('F'): + goto _24 + case int32('E'): + goto _25 + case int32('a'): + goto _26 + case int32('g'): + goto _27 + case int32('f'): + goto _28 + case int32('e'): + goto _29 + } + goto _30 + _9: + ; + switch ps { + case uint32(_BARE): + **(**int32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = cnt + case uint32(_LPRE): + **(**int64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = int64(cnt) + case uint32(_LLPRE): + **(**int64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = int64(cnt) + case uint32(_HPRE): + **(**uint16)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = Uint16FromInt32(cnt) + case uint32(_HHPRE): + **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = Uint8FromInt32(cnt) + case uint32(_ZTPRE): + **(**Tsize_t)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = Uint64FromInt32(cnt) + case uint32(_JPRE): + **(**Tuintmax_t)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = Uint64FromInt32(cnt) + break + } + goto _1 + _10: + ; + if Uint64FromInt32(p) > Uint64FromInt32(2)*Uint64FromInt64(8) { + v31 = Uint64FromInt32(p) + } else { + v31 = Uint64FromInt32(2) * Uint64FromInt64(8) + } + p = Int32FromUint64(v31) + t = int32('x') + fl = fl | Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' ')) + _12: + ; + _11: + ; + a = _fmt_x(tls, *(*Tuintmax_t)(unsafe.Pointer(bp + 8)), z, t&int32(32)) + if *(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0 && fl&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0 { + prefix = prefix + uintptr(t>>Int32FromInt32(4)) + pl = Int32FromInt32(2) + } + if !(0 != 0) { + goto _32 + } + _13: + ; + a = _fmt_o(tls, *(*Tuintmax_t)(unsafe.Pointer(bp + 8)), z) + if fl&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0 && int64(p) < int64(z)-int64(a)+int64(1) { + p = int32(int64(z) - int64(a) + int64(1)) + } + _32: + ; + if !(0 != 0) { + goto _33 + } + _15: + ; + _14: + ; + pl = int32(1) + if *(*Tuintmax_t)(unsafe.Pointer(bp + 8)) > Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + *(*Tuintmax_t)(unsafe.Pointer(bp + 8)) = -*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) + } else { + if fl&(Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))) != 0 { + prefix = prefix + 1 + } else { + if fl&(Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))) != 0 { + prefix = prefix + uintptr(2) + } else { + pl = 0 + } + } + } + _16: + ; + a = _fmt_u(tls, *(*Tuintmax_t)(unsafe.Pointer(bp + 8)), z) + _33: + ; + if xp != 0 && p < 0 { + goto overflow + } + if xp != 0 { + fl = fl & ^(Uint32FromUint32(1) << (Int32FromUint8('0') - Int32FromUint8(' '))) + } + if !(*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0) && !(p != 0) { + a = z + goto _30 + } + if int64(p) > int64(z)-int64(a)+BoolInt64(!(*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0)) { + v34 = int64(p) + } else { + v34 = int64(z) - int64(a) + BoolInt64(!(*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0)) + } + p = int32(v34) + goto _30 + goto narrow_c + narrow_c: + ; + _17: + ; + v5 = Int32FromInt32(1) + p = v5 + v8 = z - uintptr(v5) + a = v8 + **(**int8)(__ccgo_up(v8)) = Int8FromUint64(*(*Tuintmax_t)(unsafe.Pointer(bp + 8))) + fl = fl & ^(Uint32FromUint32(1) << (Int32FromUint8('0') - Int32FromUint8(' '))) + goto _30 + _19: + ; + if !(int32(1) != 0) { + goto _37 + } + a = Xstrerror(tls, **(**int32)(__ccgo_up(X__errno_location(tls)))) + goto _38 + _37: + ; + _18: + ; + if *(*uintptr)(unsafe.Pointer(bp + 8)) != 0 { + v8 = *(*uintptr)(unsafe.Pointer(bp + 8)) + } else { + v8 = __ccgo_ts + 1644 + } + a = v8 + _38: + ; + if p < 0 { + v5 = int32(INT_MAX) + } else { + v5 = p + } + z = a + uintptr(Xstrnlen(tls, a, Uint64FromInt32(v5))) + if p < 0 && **(**int8)(__ccgo_up(z)) != 0 { + goto overflow + } + p = int32(int64(z) - int64(a)) + fl = fl & ^(Uint32FromUint32(1) << (Int32FromUint8('0') - Int32FromUint8(' '))) + goto _30 + _20: + ; + if !(*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0) { + goto narrow_c + } + (**(**[2]Twchar_t)(__ccgo_up(bp + 40)))[0] = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(bp + 8))) + (**(**[2]Twchar_t)(__ccgo_up(bp + 40)))[int32(1)] = 0 + *(*uintptr)(unsafe.Pointer(bp + 8)) = bp + 40 + p = -int32(1) + _21: + ; + ws = *(*uintptr)(unsafe.Pointer(bp + 8)) + v5 = Int32FromInt32(0) + l = v5 + i = Uint64FromInt32(v5) + for { + if v45 = i < Uint64FromInt32(p) && **(**Twchar_t)(__ccgo_up(ws)) != 0; v45 { + v8 = ws + ws += 4 + v6 = Xwctomb(tls, bp+48, **(**Twchar_t)(__ccgo_up(v8))) + l = v6 + } + if !(v45 && v6 >= 0 && Uint64FromInt32(l) <= Uint64FromInt32(p)-i) { + break + } + goto _41 + _41: + ; + i = i + Uint64FromInt32(l) + } + if l < 0 { + return -int32(1) + } + if i > uint64(INT_MAX) { + goto overflow + } + p = Int32FromUint64(i) + _pad3(tls, f, int8(' '), w, p, Int32FromUint32(fl)) + ws = *(*uintptr)(unsafe.Pointer(bp + 8)) + i = uint64(0) + for { + if v45 = i < uint64(0+Uint32FromInt32(p)) && **(**Twchar_t)(__ccgo_up(ws)) != 0; v45 { + v8 = ws + ws += 4 + v5 = Xwctomb(tls, bp+48, **(**Twchar_t)(__ccgo_up(v8))) + l = v5 + } + if !(v45 && i+Uint64FromInt32(v5) <= Uint64FromInt32(p)) { + break + } + _out(tls, f, bp+48, Uint64FromInt32(l)) + goto _46 + _46: + ; + i = i + Uint64FromInt32(l) + } + _pad3(tls, f, int8(' '), w, p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + if w > p { + v5 = w + } else { + v5 = p + } + l = v5 + goto _1 + _29: + ; + _28: + ; + _27: + ; + _26: + ; + _25: + ; + _24: + ; + _23: + ; + _22: + ; + if xp != 0 && p < 0 { + goto overflow + } + l = _fmt_fp(tls, f, *(*float64)(unsafe.Pointer(bp + 8)), w, p, Int32FromUint32(fl), t) + if l < 0 { + goto overflow + } + goto _1 + _30: + ; + if int64(p) < int64(z)-int64(a) { + p = int32(int64(z) - int64(a)) + } + if p > int32(INT_MAX)-pl { + goto overflow + } + if w < pl+p { + w = pl + p + } + if w > int32(INT_MAX)-cnt { + goto overflow + } + _pad3(tls, f, int8(' '), w, pl+p, Int32FromUint32(fl)) + _out(tls, f, prefix, Uint64FromInt32(pl)) + _pad3(tls, f, int8('0'), w, pl+p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' ')))) + _pad3(tls, f, int8('0'), p, int32(int64(z)-int64(a)), 0) + _out(tls, f, a, Uint64FromInt64(int64(z)-int64(a))) + _pad3(tls, f, int8(' '), w, pl+p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + l = w + goto _1 + _1: + } + if f != 0 { + return cnt + } + if !(l10n != 0) { + return 0 + } + i = uint64(1) + for { + if !(i <= uint64(NL_ARGMAX) && **(**int32)(__ccgo_up(nl_type + uintptr(i)*4)) != 0) { + break + } + _pop_arg(tls, nl_arg+uintptr(i)*8, **(**int32)(__ccgo_up(nl_type + uintptr(i)*4)), ap) + goto _51 + _51: + ; + i = i + 1 + } + for { + if !(i <= uint64(NL_ARGMAX) && !(**(**int32)(__ccgo_up(nl_type + uintptr(i)*4)) != 0)) { + break + } + goto _52 + _52: + ; + i = i + 1 + } + if i <= uint64(NL_ARGMAX) { + goto inval + } + return int32(1) + goto inval +inval: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + goto overflow +overflow: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return -int32(1) +} + +func Xvfprintf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(208) + defer tls.Free(208) + var __need_unlock, olderr, ret, v1 int32 + var saved_buf, v2, v3 uintptr + var _ /* ap2 at bp+0 */ Tva_list + var _ /* internal_buf at bp+128 */ [80]uint8 + var _ /* nl_arg at bp+48 */ [10]Targ + var _ /* nl_type at bp+8 */ [10]int32 + _, _, _, _, _, _, _ = __need_unlock, olderr, ret, saved_buf, v1, v2, v3 + **(**[10]int32)(__ccgo_up(bp + 8)) = [10]int32{} + saved_buf = uintptr(0) + /* the copy allows passing va_list* even if va_list is an array */ + **(**Tva_list)(__ccgo_up(bp)) = ap + if _printf_core(tls, uintptr(0), fmt, bp, bp+48, bp+8) < 0 { + _ = **(**Tva_list)(__ccgo_up(bp)) + return -int32(1) + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + olderr = Int32FromUint32((*TFILE)(unsafe.Pointer(f)).Fflags & uint32(F_ERR)) + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_ERR)) + if !((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0) { + saved_buf = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fbuf = bp + 128 + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = uint64(80) + v3 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v3 + v2 = v3 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v2 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v2 + } + if !((*TFILE)(unsafe.Pointer(f)).Fwend != 0) && X__towrite(tls, f) != 0 { + ret = -int32(1) + } else { + ret = _printf_core(tls, f, fmt, bp, bp+48, bp+8) + } + if saved_buf != 0 { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + if !((*TFILE)(unsafe.Pointer(f)).Fwpos != 0) { + ret = -int32(1) + } + (*TFILE)(unsafe.Pointer(f)).Fbuf = saved_buf + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = uint64(0) + v3 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v3 + v2 = v3 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v2 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v2 + } + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + ret = -int32(1) + } + **(**uint32)(__ccgo_up(f)) |= Uint32FromInt32(olderr) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + _ = **(**Tva_list)(__ccgo_up(bp)) + return ret +} + +const SIZE_L = 2 +const SIZE_def = 0 +const SIZE_h = -1 +const SIZE_hh = -2 +const SIZE_l = 1 +const SIZE_ll = 3 + +func _store_int(tls *TLS, dest uintptr, size int32, i uint64) { + if !(dest != 0) { + return + } + switch size { + case -int32(2): + **(**int8)(__ccgo_up(dest)) = Int8FromUint64(i) + case -int32(1): + **(**int16)(__ccgo_up(dest)) = Int16FromUint64(i) + case SIZE_def: + **(**int32)(__ccgo_up(dest)) = Int32FromUint64(i) + case int32(SIZE_l): + **(**int64)(__ccgo_up(dest)) = Int64FromUint64(i) + case int32(SIZE_ll): + **(**int64)(__ccgo_up(dest)) = Int64FromUint64(i) + break + } +} + +func _arg_n(tls *TLS, ap Tva_list, n uint32) (r uintptr) { + var ap2 Tva_list + var i uint32 + var p uintptr + _, _, _ = ap2, i, p + ap2 = ap + i = n + for { + if !(i > uint32(1)) { + break + } + _ = VaUintptr(&ap2) + goto _1 + _1: + ; + i = i - 1 + } + p = VaUintptr(&ap2) + _ = ap2 + return p +} + +func Xvfscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(288) + defer tls.Free(288) + var __need_unlock, alloc, base, c, invert, matches, size, t, width, v1, v3, v4, v6 int32 + var dest, p, s, tmp, tmp1, wcs, v10, v11, v17 uintptr + var i, k, v64 Tsize_t + var pos Toff_t + var x uint64 + var y float64 + var v59 uint32 + var _ /* scanset at bp+16 */ [257]uint8 + var _ /* st at bp+8 */ Tmbstate_t + var _ /* wc at bp+276 */ Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __need_unlock, alloc, base, c, dest, i, invert, k, matches, p, pos, s, size, t, tmp, tmp1, wcs, width, x, y, v1, v10, v11, v17, v3, v4, v59, v6, v64 + alloc = 0 + dest = UintptrFromInt32(0) + matches = 0 + pos = 0 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) { + X__toread(tls, f) + } + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) { + goto input_fail + } + p = fmt + for { + if !(**(**uint8)(__ccgo_up(p)) != 0) { + break + } + alloc = 0 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v3 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _5 + _5: + if v3 != 0 { + for { + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) + v6 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _8 + _8: + if !(v6 != 0) { + break + } + p = p + 1 + } + X__shlim(tls, f, int64(Int32FromInt32(0))) + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v1 = X__shgetc(tls, f) + } + v3 = v1 + v4 = BoolInt32(v3 == int32(' ') || Uint32FromInt32(v3)-uint32('\t') < uint32(5)) + goto _14 + _14: + if !(v4 != 0) { + break + } + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + pos = pos + ((*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf))) + goto _2 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32('%') || Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) == int32('%') { + X__shlim(tls, f, int64(Int32FromInt32(0))) + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('%') { + p = p + 1 + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + v4 = v1 + v6 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _21 + _21: + if !(v6 != 0) { + break + } + } + } else { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if c != Int32FromUint8(**(**uint8)(__ccgo_up(p))) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if c < 0 { + goto input_fail + } + goto match_fail + } + pos = pos + ((*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf))) + goto _2 + } + p = p + 1 + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('*') { + dest = uintptr(0) + p = p + 1 + } else { + if BoolInt32(uint32(**(**uint8)(__ccgo_up(p)))-uint32('0') < uint32(10)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) == int32('$') { + dest = _arg_n(tls, ap, Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(p)))-int32('0'))) + p = p + uintptr(2) + } else { + dest = VaUintptr(&ap) + } + } + width = 0 + for { + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(p)))-uint32('0') < uint32(10)) != 0) { + break + } + width = int32(10)*width + Int32FromUint8(**(**uint8)(__ccgo_up(p))) - int32('0') + goto _25 + _25: + ; + p = p + 1 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('m') { + wcs = uintptr(0) + s = uintptr(0) + alloc = BoolInt32(!!(dest != 0)) + p = p + 1 + } else { + alloc = 0 + } + size = SIZE_def + v10 = p + p = p + 1 + switch Int32FromUint8(**(**uint8)(__ccgo_up(v10))) { + case int32('h'): + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('h') { + p = p + 1 + size = -Int32FromInt32(2) + } else { + size = -int32(1) + } + case int32('l'): + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('l') { + p = p + 1 + size = Int32FromInt32(SIZE_ll) + } else { + size = int32(SIZE_l) + } + case int32('j'): + size = int32(SIZE_ll) + case int32('z'): + fallthrough + case int32('t'): + size = int32(SIZE_l) + case int32('L'): + size = int32(SIZE_L) + case int32('d'): + fallthrough + case int32('i'): + fallthrough + case int32('o'): + fallthrough + case int32('u'): + fallthrough + case int32('x'): + fallthrough + case int32('a'): + fallthrough + case int32('e'): + fallthrough + case int32('f'): + fallthrough + case int32('g'): + fallthrough + case int32('A'): + fallthrough + case int32('E'): + fallthrough + case int32('F'): + fallthrough + case int32('G'): + fallthrough + case int32('X'): + fallthrough + case int32('s'): + fallthrough + case int32('c'): + fallthrough + case int32('['): + fallthrough + case int32('S'): + fallthrough + case int32('C'): + fallthrough + case int32('p'): + fallthrough + case int32('n'): + p = p - 1 + default: + goto fmt_fail + } + t = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + /* C or S */ + if t&int32(0x2f) == int32(3) { + t = t | int32(32) + size = int32(SIZE_l) + } + switch t { + case int32('c'): + if width < int32(1) { + width = int32(1) + } + fallthrough + case int32('['): + case int32('n'): + _store_int(tls, dest, size, Uint64FromInt64(pos)) + /* do not increment match count, etc! */ + goto _2 + default: + X__shlim(tls, f, int64(Int32FromInt32(0))) + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v1 = X__shgetc(tls, f) + } + v3 = v1 + v4 = BoolInt32(v3 == int32(' ') || Uint32FromInt32(v3)-uint32('\t') < uint32(5)) + goto _32 + _32: + if !(v4 != 0) { + break + } + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + pos = pos + ((*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf))) + } + X__shlim(tls, f, int64(width)) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v1 = X__shgetc(tls, f) + } + if v1 < 0 { + goto input_fail + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + switch t { + case int32('['): + goto _36 + case int32('c'): + goto _37 + case int32('s'): + goto _38 + case int32('x'): + goto _39 + case int32('X'): + goto _40 + case int32('p'): + goto _41 + case int32('o'): + goto _42 + case int32('u'): + goto _43 + case int32('d'): + goto _44 + case int32('i'): + goto _45 + case int32('G'): + goto _46 + case int32('g'): + goto _47 + case int32('F'): + goto _48 + case int32('f'): + goto _49 + case int32('E'): + goto _50 + case int32('e'): + goto _51 + case int32('A'): + goto _52 + case int32('a'): + goto _53 + } + goto _54 + _38: + ; + _37: + ; + _36: + ; + if t == int32('c') || t == int32('s') { + Xmemset(tls, bp+16, -int32(1), uint64(257)) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[0] = uint8(0) + if t == int32('s') { + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\t')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\n')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\v')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\f')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\r')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8(' ')] = uint8(0) + } + } else { + p = p + 1 + v10 = p + if Int32FromUint8(**(**uint8)(__ccgo_up(v10))) == int32('^') { + p = p + 1 + invert = Int32FromInt32(1) + } else { + invert = 0 + } + Xmemset(tls, bp+16, invert, uint64(257)) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[0] = uint8(0) + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('-') { + p = p + 1 + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('-')] = Uint8FromInt32(Int32FromInt32(1) - invert) + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32(']') { + p = p + 1 + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8(']')] = Uint8FromInt32(Int32FromInt32(1) - invert) + } + } + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32(']')) { + break + } + if !(**(**uint8)(__ccgo_up(p)) != 0) { + goto fmt_fail + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('-') && **(**uint8)(__ccgo_up(p + 1)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) != int32(']') { + v10 = p + p = p + 1 + c = Int32FromUint8(**(**uint8)(__ccgo_up(v10 + uintptr(-Int32FromInt32(1))))) + for { + if !(c < Int32FromUint8(**(**uint8)(__ccgo_up(p)))) { + break + } + (**(**[257]uint8)(__ccgo_up(bp + 16)))[int32(1)+c] = Uint8FromInt32(int32(1) - invert) + goto _57 + _57: + ; + c = c + 1 + } + } + (**(**[257]uint8)(__ccgo_up(bp + 16)))[int32(1)+Int32FromUint8(**(**uint8)(__ccgo_up(p)))] = Uint8FromInt32(int32(1) - invert) + goto _56 + _56: + ; + p = p + 1 + } + } + wcs = uintptr(0) + s = uintptr(0) + i = uint64(0) + if t == int32('c') { + v59 = Uint32FromInt32(width) + uint32(1) + } else { + v59 = uint32(31) + } + k = uint64(v59) + if size == int32(SIZE_l) { + if alloc != 0 { + wcs = Xmalloc(tls, k*uint64(4)) + if !(wcs != 0) { + goto alloc_fail + } + } else { + wcs = dest + } + **(**Tmbstate_t)(__ccgo_up(bp + 8)) = Tmbstate_t{} + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + if !((**(**[257]uint8)(__ccgo_up(bp + 16)))[v1+int32(1)] != 0) { + break + } + *(*int8)(unsafe.Pointer(bp)) = int8(c) + switch Xmbrtowc(tls, bp+276, bp, uint64(1), bp+8) { + case Uint64FromInt32(-Int32FromInt32(1)): + goto input_fail + case Uint64FromInt32(-Int32FromInt32(2)): + continue + } + if wcs != 0 { + v64 = i + i = i + 1 + **(**Twchar_t)(__ccgo_up(wcs + uintptr(v64)*4)) = **(**Twchar_t)(__ccgo_up(bp + 276)) + } + if alloc != 0 && i == k { + k = k + (k + uint64(1)) + tmp = Xrealloc(tls, wcs, k*uint64(4)) + if !(tmp != 0) { + goto alloc_fail + } + wcs = tmp + } + } + if !(Xmbsinit(tls, bp+8) != 0) { + goto input_fail + } + } else { + if alloc != 0 { + s = Xmalloc(tls, k) + if !(s != 0) { + goto alloc_fail + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + if !((**(**[257]uint8)(__ccgo_up(bp + 16)))[v1+int32(1)] != 0) { + break + } + v64 = i + i = i + 1 + **(**int8)(__ccgo_up(s + uintptr(v64))) = int8(c) + if i == k { + k = k + (k + uint64(1)) + tmp1 = Xrealloc(tls, s, k) + if !(tmp1 != 0) { + goto alloc_fail + } + s = tmp1 + } + } + } else { + v10 = dest + s = v10 + if v10 != 0 { + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v17 = f + 8 + v11 = *(*uintptr)(unsafe.Pointer(v17)) + *(*uintptr)(unsafe.Pointer(v17)) = *(*uintptr)(unsafe.Pointer(v17)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v11))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + if !((**(**[257]uint8)(__ccgo_up(bp + 16)))[v1+int32(1)] != 0) { + break + } + v64 = i + i = i + 1 + **(**int8)(__ccgo_up(s + uintptr(v64))) = int8(c) + } + } else { + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + if !((**(**[257]uint8)(__ccgo_up(bp + 16)))[v1+int32(1)] != 0) { + break + } + } + } + } + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if !((*TFILE)(unsafe.Pointer(f)).Fshcnt+(int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) != 0) { + goto match_fail + } + if t == int32('c') && (*TFILE)(unsafe.Pointer(f)).Fshcnt+(int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) != int64(width) { + goto match_fail + } + if alloc != 0 { + if size == int32(SIZE_l) { + **(**uintptr)(__ccgo_up(dest)) = wcs + } else { + **(**uintptr)(__ccgo_up(dest)) = s + } + } + if t != int32('c') { + if wcs != 0 { + **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) = 0 + } + if s != 0 { + **(**int8)(__ccgo_up(s + uintptr(i))) = 0 + } + } + goto _54 + _41: + ; + _40: + ; + _39: + ; + base = int32(16) + goto int_common + _42: + ; + base = int32(8) + goto int_common + _44: + ; + _43: + ; + base = int32(10) + goto int_common + _45: + ; + base = 0 + goto int_common + int_common: + ; + x = X__intscan(tls, f, Uint32FromInt32(base), 0, Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)) + if !((*TFILE)(unsafe.Pointer(f)).Fshcnt+(int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) != 0) { + goto match_fail + } + if t == int32('p') && dest != 0 { + **(**uintptr)(__ccgo_up(dest)) = uintptr(x) + } else { + _store_int(tls, dest, size, x) + } + goto _54 + _53: + ; + _52: + ; + _51: + ; + _50: + ; + _49: + ; + _48: + ; + _47: + ; + _46: + ; + y = X__floatscan(tls, f, size, 0) + if !((*TFILE)(unsafe.Pointer(f)).Fshcnt+(int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) != 0) { + goto match_fail + } + if dest != 0 { + switch size { + case SIZE_def: + **(**float32)(__ccgo_up(dest)) = float32(y) + case int32(SIZE_l): + **(**float64)(__ccgo_up(dest)) = y + case int32(SIZE_L): + **(**float64)(__ccgo_up(dest)) = y + break + } + } + goto _54 + _54: + ; + pos = pos + ((*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf))) + if dest != 0 { + matches = matches + 1 + } + goto _2 + _2: + ; + p = p + 1 + } + if !(0 != 0) { + goto _80 + } + goto fmt_fail +fmt_fail: + ; + goto alloc_fail +alloc_fail: + ; + goto input_fail +input_fail: + ; + if !(matches != 0) { + matches = matches - 1 + } + goto match_fail +match_fail: + ; + if alloc != 0 { + Xfree(tls, s) + Xfree(tls, wcs) + } +_80: + ; + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return matches +} + +func X__isoc99_vfscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfscanf(tls, f, fmt, ap) +} + +var _states1 = [8][58]uint8{ + 0: { + 0: uint8(_DBL), + 2: uint8(_UINT), + 4: uint8(_DBL), + 5: uint8(_DBL), + 6: uint8(_DBL), + 11: uint8(_BIGLPRE), + 18: uint8(_PTR), + 23: uint8(_UINT), + 32: uint8(_DBL), + 34: uint8(_INT), + 35: uint8(_INT), + 36: uint8(_DBL), + 37: uint8(_DBL), + 38: uint8(_DBL), + 39: uint8(_HPRE), + 40: uint8(_INT), + 41: uint8(_JPRE), + 43: uint8(_LPRE), + 44: uint8(_NOARG), + 45: uint8(_PTR), + 46: uint8(_UINT), + 47: uint8(_UIPTR), + 50: uint8(_PTR), + 51: uint8(_ZTPRE), + 52: uint8(_UINT), + 55: uint8(_UINT), + 57: uint8(_ZTPRE), + }, + 1: { + 0: uint8(_DBL), + 4: uint8(_DBL), + 5: uint8(_DBL), + 6: uint8(_DBL), + 23: uint8(_ULONG), + 32: uint8(_DBL), + 34: uint8(_UINT), + 35: uint8(_LONG), + 36: uint8(_DBL), + 37: uint8(_DBL), + 38: uint8(_DBL), + 40: uint8(_LONG), + 43: uint8(_LLPRE), + 45: uint8(_PTR), + 46: uint8(_ULONG), + 50: uint8(_PTR), + 52: uint8(_ULONG), + 55: uint8(_ULONG), + }, + 2: { + 23: uint8(_ULLONG), + 35: uint8(_LLONG), + 40: uint8(_LLONG), + 45: uint8(_PTR), + 46: uint8(_ULLONG), + 52: uint8(_ULLONG), + 55: uint8(_ULLONG), + }, + 3: { + 23: uint8(_USHORT), + 35: uint8(_SHORT), + 39: uint8(_HHPRE), + 40: uint8(_SHORT), + 45: uint8(_PTR), + 46: uint8(_USHORT), + 52: uint8(_USHORT), + 55: uint8(_USHORT), + }, + 4: { + 23: uint8(_UCHAR), + 35: uint8(_CHAR), + 40: uint8(_CHAR), + 45: uint8(_PTR), + 46: uint8(_UCHAR), + 52: uint8(_UCHAR), + 55: uint8(_UCHAR), + }, + 5: { + 0: uint8(_LDBL), + 4: uint8(_LDBL), + 5: uint8(_LDBL), + 6: uint8(_LDBL), + 32: uint8(_LDBL), + 36: uint8(_LDBL), + 37: uint8(_LDBL), + 38: uint8(_LDBL), + 45: uint8(_PTR), + }, + 6: { + 23: uint8(_SIZET), + 35: uint8(_PDIFF), + 40: uint8(_PDIFF), + 45: uint8(_PTR), + 46: uint8(_SIZET), + 52: uint8(_SIZET), + 55: uint8(_SIZET), + }, + 7: { + 23: uint8(_UMAX), + 35: uint8(_IMAX), + 40: uint8(_IMAX), + 45: uint8(_PTR), + 46: uint8(_UMAX), + 52: uint8(_UMAX), + 55: uint8(_UMAX), + }, +} + +func _pop_arg1(tls *TLS, arg uintptr, type1 int32, ap uintptr) { + switch type1 { + case int32(_PTR): + *(*uintptr)(unsafe.Pointer(arg)) = VaUintptr(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_INT): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UINT): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUint32(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_LONG): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_ULONG): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_ULLONG): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUint64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_SHORT): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt16(int16(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_USHORT): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(Uint16FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_CHAR): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt8(int8(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_UCHAR): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(Uint8FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_LLONG): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_SIZET): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_IMAX): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UMAX): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_PDIFF): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UIPTR): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUintptr(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_DBL): + *(*float64)(unsafe.Pointer(arg)) = float64(VaFloat64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_LDBL): + *(*float64)(unsafe.Pointer(arg)) = VaFloat64(&**(**Tva_list)(__ccgo_up(ap))) + } +} + +func _out1(tls *TLS, f uintptr, s uintptr, l Tsize_t) { + var v1 Tsize_t + var v2 uintptr + _, _ = v1, v2 + for { + v1 = l + l = l - 1 + if !(v1 != 0 && !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_ERR) != 0)) { + break + } + v2 = s + s += 4 + Xfputwc(tls, **(**Twchar_t)(__ccgo_up(v2)), f) + } +} + +func _pad4(tls *TLS, f uintptr, n int32, fl int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + if Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))) != 0 || !(n != 0) || (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + return + } + Xfprintf(tls, f, __ccgo_ts+1651, VaList(bp+8, n, __ccgo_ts)) +} + +func _getint1(tls *TLS, s uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(BoolInt32(Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-uint32('0') < uint32(10)) != 0) { + break + } + if Uint32FromInt32(i) > Uint32FromInt32(INT_MAX)/Uint32FromUint32(10) || **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(s))))-int32('0') > int32(INT_MAX)-int32(10)*i { + i = -int32(1) + } else { + i = int32(10)*i + (**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))) - int32('0')) + } + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(s)) += 4 + } + return i +} + +var _sizeprefix = [24]int8{ + 0: int8('L'), + 3: int8('j'), + 4: int8('L'), + 5: int8('L'), + 6: int8('L'), + 8: int8('j'), + 14: int8('j'), + 15: int8('j'), + 20: int8('j'), + 23: int8('j'), +} + +func _wprintf_core(tls *TLS, f uintptr, fmt uintptr, ap uintptr, nl_arg uintptr, nl_type uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var a, bs, z, v8 uintptr + var argpos, cnt, i, l, p, t, w, xp, v5, v6, v7 int32 + var fl, l10n, ps, st uint32 + var v15 bool + var v9 uint64 + var _ /* arg at bp+16 */ Targ + var _ /* charfmt at bp+24 */ [16]int8 + var _ /* s at bp+8 */ uintptr + var _ /* wc at bp+40 */ Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, argpos, bs, cnt, fl, i, l, l10n, p, ps, st, t, w, xp, z, v15, v5, v6, v7, v8, v9 + **(**uintptr)(__ccgo_up(bp + 8)) = fmt + l10n = uint32(0) + cnt = 0 + l = 0 + for { + /* This error is only specified for snprintf, but since it's + * unspecified for other forms, do the same. Stop immediately + * on overflow; otherwise %n could produce wrong results. */ + if l > int32(INT_MAX)-cnt { + goto overflow + } + /* Update output count, end loop when fmt is exhausted */ + cnt = cnt + l + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != 0) { + break + } + /* Handle literal text and %% format specifiers */ + a = **(**uintptr)(__ccgo_up(bp + 8)) + for { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != 0 && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != int32('%')) { + break + } + goto _2 + _2: + ; + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + } + z = **(**uintptr)(__ccgo_up(bp + 8)) + for { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) == int32('%') && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4)) == int32('%')) { + break + } + goto _3 + _3: + ; + z += 4 + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(2)*4 + } + if (int64(z)-int64(a))/4 > int64(int32(INT_MAX)-cnt) { + goto overflow + } + l = int32((int64(z) - int64(a)) / 4) + if f != 0 { + _out1(tls, f, a, Uint64FromInt32(l)) + } + if l != 0 { + goto _1 + } + if BoolInt32(Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4)))-uint32('0') < uint32(10)) != 0 && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4)) == int32('$') { + l10n = uint32(1) + argpos = **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4)) - int32('0') + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(3)*4 + } else { + argpos = -int32(1) + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + } + /* Read modifier flags */ + fl = uint32(0) + for { + if !(Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))))-uint32(' ') < uint32(32) && (Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('\'')-Int32FromUint8(' ')))&(uint32(1)<<(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))-int32(' '))) != 0) { + break + } + fl = fl | uint32(1)<<(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))-int32(' ')) + goto _4 + _4: + ; + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + } + /* Read field width */ + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) == int32('*') { + if BoolInt32(Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4)))-uint32('0') < uint32(10)) != 0 && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4)) == int32('$') { + l10n = uint32(1) + **(**int32)(__ccgo_up(nl_type + uintptr(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4))-int32('0'))*4)) = int32(_INT) + w = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(nl_arg + uintptr(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4))-int32('0'))*8))) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(3)*4 + } else { + if !(l10n != 0) { + if f != 0 { + v5 = VaInt32(&**(**Tva_list)(__ccgo_up(ap))) + } else { + v5 = 0 + } + w = v5 + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + } else { + goto inval + } + } + if w < 0 { + fl = fl | Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')) + w = -w + } + } else { + v5 = _getint1(tls, bp+8) + w = v5 + if v5 < 0 { + goto overflow + } + } + /* Read precision */ + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) == int32('.') && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4)) == int32('*') { + if BoolInt32(Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4)))-uint32('0') < uint32(10)) != 0 && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 3*4)) == int32('$') { + **(**int32)(__ccgo_up(nl_type + uintptr(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4))-int32('0'))*4)) = int32(_INT) + p = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(nl_arg + uintptr(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4))-int32('0'))*8))) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(4)*4 + } else { + if !(l10n != 0) { + if f != 0 { + v5 = VaInt32(&**(**Tva_list)(__ccgo_up(ap))) + } else { + v5 = 0 + } + p = v5 + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(2)*4 + } else { + goto inval + } + } + xp = BoolInt32(p >= 0) + } else { + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) == int32('.') { + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + p = _getint1(tls, bp+8) + xp = int32(1) + } else { + p = -int32(1) + xp = 0 + } + } + /* Format specifier state machine */ + st = uint32(0) + for cond := true; cond; cond = st-uint32(1) < uint32(_STOP) { + if Uint32FromInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))))-uint32('A') > Uint32FromInt32(Int32FromUint8('z')-Int32FromUint8('A')) { + goto inval + } + ps = st + v8 = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + st = uint32(**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_states1)) + uintptr(st)*58 + uintptr(**(**Twchar_t)(__ccgo_up(v8))-int32('A'))))) + } + if !(st != 0) { + goto inval + } + /* Check validity of argument type (nl/normal) */ + if st == uint32(_NOARG) { + if argpos >= 0 { + goto inval + } + } else { + if argpos >= 0 { + **(**int32)(__ccgo_up(nl_type + uintptr(argpos)*4)) = Int32FromUint32(st) + **(**Targ)(__ccgo_up(bp + 16)) = **(**Targ)(__ccgo_up(nl_arg + uintptr(argpos)*8)) + } else { + if f != 0 { + _pop_arg1(tls, bp+16, Int32FromUint32(st), ap) + } else { + return 0 + } + } + } + if !(f != 0) { + goto _1 + } + /* Do not process any new directives once in error state. */ + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + return -int32(1) + } + t = **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + uintptr(-Int32FromInt32(1))*4)) + if ps != 0 && t&int32(15) == int32(3) { + t = t & ^Int32FromInt32(32) + } + switch t { + case int32('n'): + switch ps { + case uint32(_BARE): + **(**int32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = cnt + case uint32(_LPRE): + **(**int64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = int64(cnt) + case uint32(_LLPRE): + **(**int64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = int64(cnt) + case uint32(_HPRE): + **(**uint16)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = Uint16FromInt32(cnt) + case uint32(_HHPRE): + **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = Uint8FromInt32(cnt) + case uint32(_ZTPRE): + **(**Tsize_t)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = Uint64FromInt32(cnt) + case uint32(_JPRE): + **(**Tuintmax_t)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = Uint64FromInt32(cnt) + break + } + goto _1 + case int32('c'): + fallthrough + case int32('C'): + if w < int32(1) { + w = int32(1) + } + _pad4(tls, f, w-int32(1), Int32FromUint32(fl)) + if t == int32('C') { + v9 = *(*Tuintmax_t)(unsafe.Pointer(bp + 16)) + } else { + v9 = uint64(Xbtowc(tls, Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(bp + 16))))) + } + *(*Twchar_t)(unsafe.Pointer(bp)) = Int32FromUint64(v9) + _out1(tls, f, bp, uint64(1)) + _pad4(tls, f, w-int32(1), Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + l = w + goto _1 + case int32('S'): + a = *(*uintptr)(unsafe.Pointer(bp + 16)) + if p < 0 { + v5 = int32(INT_MAX) + } else { + v5 = p + } + z = a + uintptr(Xwcsnlen(tls, a, Uint64FromInt32(v5)))*4 + if p < 0 && **(**Twchar_t)(__ccgo_up(z)) != 0 { + goto overflow + } + p = int32((int64(z) - int64(a)) / 4) + if w < p { + w = p + } + _pad4(tls, f, w-p, Int32FromUint32(fl)) + _out1(tls, f, a, Uint64FromInt32(p)) + _pad4(tls, f, w-p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + l = w + goto _1 + case int32('m'): + *(*uintptr)(unsafe.Pointer(bp + 16)) = Xstrerror(tls, **(**int32)(__ccgo_up(X__errno_location(tls)))) + fallthrough + case int32('s'): + if !(*(*uintptr)(unsafe.Pointer(bp + 16)) != 0) { + *(*uintptr)(unsafe.Pointer(bp + 16)) = __ccgo_ts + 1644 + } + bs = *(*uintptr)(unsafe.Pointer(bp + 16)) + v5 = Int32FromInt32(0) + l = v5 + i = v5 + for { + if p < 0 { + v6 = int32(INT_MAX) + } else { + v6 = p + } + if v15 = l < v6; v15 { + v7 = Xmbtowc(tls, bp+40, bs, uint64(MB_LEN_MAX)) + i = v7 + } + if !(v15 && v7 > 0) { + break + } + goto _11 + _11: + ; + bs = bs + uintptr(i) + l = l + 1 + } + if i < 0 { + return -int32(1) + } + if p < 0 && **(**int8)(__ccgo_up(bs)) != 0 { + goto overflow + } + p = l + if w < p { + w = p + } + _pad4(tls, f, w-p, Int32FromUint32(fl)) + bs = *(*uintptr)(unsafe.Pointer(bp + 16)) + for { + v5 = l + l = l - 1 + if !(v5 != 0) { + break + } + i = Xmbtowc(tls, bp+40, bs, uint64(MB_LEN_MAX)) + bs = bs + uintptr(i) + _out1(tls, f, bp+40, uint64(1)) + } + _pad4(tls, f, w-p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + l = w + goto _1 + } + if xp != 0 && p < 0 { + goto overflow + } + Xsnprintf(tls, bp+24, uint64(16), __ccgo_ts+1655, VaList(bp+56, __ccgo_ts+1675+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0)), __ccgo_ts+1677+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))) != 0)), __ccgo_ts+1679+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))) != 0)), __ccgo_ts+689+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))) != 0)), __ccgo_ts+1681+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' '))) != 0)), int32(_sizeprefix[t|int32(32)-int32('a')]), t)) + switch t | Int32FromInt32(32) { + case int32('a'): + fallthrough + case int32('e'): + fallthrough + case int32('f'): + fallthrough + case int32('g'): + l = Xfprintf(tls, f, bp+24, VaList(bp+56, w, p, *(*float64)(unsafe.Pointer(bp + 16)))) + case int32('d'): + fallthrough + case int32('i'): + fallthrough + case int32('o'): + fallthrough + case int32('u'): + fallthrough + case int32('x'): + fallthrough + case int32('p'): + l = Xfprintf(tls, f, bp+24, VaList(bp+56, w, p, *(*Tuintmax_t)(unsafe.Pointer(bp + 16)))) + break + } + goto _1 + _1: + } + if f != 0 { + return cnt + } + if !(l10n != 0) { + return 0 + } + i = int32(1) + for { + if !(i <= int32(NL_ARGMAX) && **(**int32)(__ccgo_up(nl_type + uintptr(i)*4)) != 0) { + break + } + _pop_arg1(tls, nl_arg+uintptr(i)*8, **(**int32)(__ccgo_up(nl_type + uintptr(i)*4)), ap) + goto _17 + _17: + ; + i = i + 1 + } + for { + if !(i <= int32(NL_ARGMAX) && !(**(**int32)(__ccgo_up(nl_type + uintptr(i)*4)) != 0)) { + break + } + goto _18 + _18: + ; + i = i + 1 + } + if i <= int32(NL_ARGMAX) { + return -int32(1) + } + return int32(1) + goto inval +inval: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + goto overflow +overflow: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return -int32(1) +} + +func Xvfwprintf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var __need_unlock, olderr, ret, v1 int32 + var _ /* ap2 at bp+0 */ Tva_list + var _ /* nl_arg at bp+48 */ [10]Targ + var _ /* nl_type at bp+8 */ [10]int32 + _, _, _, _ = __need_unlock, olderr, ret, v1 + **(**[10]int32)(__ccgo_up(bp + 8)) = [10]int32{} + /* the copy allows passing va_list* even if va_list is an array */ + **(**Tva_list)(__ccgo_up(bp)) = ap + if _wprintf_core(tls, uintptr(0), fmt, bp, bp+48, bp+8) < 0 { + _ = **(**Tva_list)(__ccgo_up(bp)) + return -int32(1) + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + Xfwide(tls, f, int32(1)) + olderr = Int32FromUint32((*TFILE)(unsafe.Pointer(f)).Fflags & uint32(F_ERR)) + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_ERR)) + ret = _wprintf_core(tls, f, fmt, bp, bp+48, bp+8) + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + ret = -int32(1) + } + **(**uint32)(__ccgo_up(f)) |= Uint32FromInt32(olderr) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + _ = **(**Tva_list)(__ccgo_up(bp)) + return ret +} + +func _store_int1(tls *TLS, dest uintptr, size int32, i uint64) { + if !(dest != 0) { + return + } + switch size { + case -int32(2): + **(**int8)(__ccgo_up(dest)) = Int8FromUint64(i) + case -int32(1): + **(**int16)(__ccgo_up(dest)) = Int16FromUint64(i) + case SIZE_def: + **(**int32)(__ccgo_up(dest)) = Int32FromUint64(i) + case int32(SIZE_l): + **(**int64)(__ccgo_up(dest)) = Int64FromUint64(i) + case int32(SIZE_ll): + **(**int64)(__ccgo_up(dest)) = Int64FromUint64(i) + break + } +} + +func _arg_n1(tls *TLS, ap Tva_list, n uint32) (r uintptr) { + var ap2 Tva_list + var i uint32 + var p uintptr + _, _, _ = ap2, i, p + ap2 = ap + i = n + for { + if !(i > uint32(1)) { + break + } + _ = VaUintptr(&ap2) + goto _1 + _1: + ; + i = i - 1 + } + p = VaUintptr(&ap2) + _ = ap2 + return p +} + +func _in_set(tls *TLS, set uintptr, c int32) (r int32) { + var j int32 + var p, v3 uintptr + _, _, _ = j, p, v3 + p = set + if **(**Twchar_t)(__ccgo_up(p)) == int32('-') { + if c == int32('-') { + return int32(1) + } + p += 4 + } else { + if **(**Twchar_t)(__ccgo_up(p)) == int32(']') { + if c == int32(']') { + return int32(1) + } + p += 4 + } + } + for { + if !(**(**Twchar_t)(__ccgo_up(p)) != 0 && **(**Twchar_t)(__ccgo_up(p)) != int32(']')) { + break + } + if **(**Twchar_t)(__ccgo_up(p)) == int32('-') && **(**Twchar_t)(__ccgo_up(p + 1*4)) != 0 && **(**Twchar_t)(__ccgo_up(p + 1*4)) != int32(']') { + v3 = p + p += 4 + j = **(**Twchar_t)(__ccgo_up(v3 + uintptr(-Int32FromInt32(1))*4)) + for { + if !(j < **(**Twchar_t)(__ccgo_up(p))) { + break + } + if c == j { + return int32(1) + } + goto _2 + _2: + ; + j = j + 1 + } + } + if c == **(**Twchar_t)(__ccgo_up(p)) { + return int32(1) + } + goto _1 + _1: + ; + p += 4 + } + return 0 +} + +func Xvfwscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var __need_unlock, alloc, c, gotmatch, invert, l, matches, size, t, width, v1 int32 + var dest, p, s, set, tmp1, tmp2, wcs, v5, v6 uintptr + var i, k, v37 Tsize_t + var pos Toff_t + var v4 uint32 + var _ /* cnt at bp+0 */ Toff_t + var _ /* tmp at bp+8 */ [22]int8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __need_unlock, alloc, c, dest, gotmatch, i, invert, k, l, matches, p, pos, s, set, size, t, tmp1, tmp2, wcs, width, v1, v37, v4, v5, v6 + dest = UintptrFromInt32(0) + matches = 0 + pos = 0 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + Xfwide(tls, f, int32(1)) + p = fmt + for { + if !(**(**Twchar_t)(__ccgo_up(p)) != 0) { + break + } + alloc = 0 + if Xiswspace(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(p)))) != 0 { + for Xiswspace(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(p + 1*4)))) != 0 { + p += 4 + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + v1 = Int32FromUint32(v4) + c = v1 + if !(Xiswspace(tls, Uint32FromInt32(v1)) != 0) { + break + } + pos = pos + 1 + } + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 && Uint32FromInt32(c) < uint32(128) { + v6 = f + 8 + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) - 1 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + _ = **(**uint8)(__ccgo_up(v5)) + } else { + Xungetwc(tls, Uint32FromInt32(c), f) + } + goto _2 + } + if **(**Twchar_t)(__ccgo_up(p)) != int32('%') || **(**Twchar_t)(__ccgo_up(p + 1*4)) == int32('%') { + if **(**Twchar_t)(__ccgo_up(p)) == int32('%') { + p += 4 + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + v1 = Int32FromUint32(v4) + c = v1 + if !(Xiswspace(tls, Uint32FromInt32(v1)) != 0) { + break + } + pos = pos + 1 + } + } else { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + c = Int32FromUint32(v4) + } + if c != **(**Twchar_t)(__ccgo_up(p)) { + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 && Uint32FromInt32(c) < uint32(128) { + v6 = f + 8 + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) - 1 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + _ = **(**uint8)(__ccgo_up(v5)) + } else { + Xungetwc(tls, Uint32FromInt32(c), f) + } + if c < 0 { + goto input_fail + } + goto match_fail + } + pos = pos + 1 + goto _2 + } + p += 4 + if **(**Twchar_t)(__ccgo_up(p)) == int32('*') { + dest = uintptr(0) + p += 4 + } else { + if BoolInt32(Uint32FromInt32(**(**Twchar_t)(__ccgo_up(p)))-uint32('0') < uint32(10)) != 0 && **(**Twchar_t)(__ccgo_up(p + 1*4)) == int32('$') { + dest = _arg_n1(tls, ap, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(p))-int32('0'))) + p = p + uintptr(2)*4 + } else { + dest = VaUintptr(&ap) + } + } + width = 0 + for { + if !(BoolInt32(Uint32FromInt32(**(**Twchar_t)(__ccgo_up(p)))-uint32('0') < uint32(10)) != 0) { + break + } + width = int32(10)*width + **(**Twchar_t)(__ccgo_up(p)) - int32('0') + goto _18 + _18: + ; + p += 4 + } + if **(**Twchar_t)(__ccgo_up(p)) == int32('m') { + wcs = uintptr(0) + s = uintptr(0) + alloc = BoolInt32(!!(dest != 0)) + p += 4 + } else { + alloc = 0 + } + size = SIZE_def + v5 = p + p += 4 + switch **(**Twchar_t)(__ccgo_up(v5)) { + case int32('h'): + if **(**Twchar_t)(__ccgo_up(p)) == int32('h') { + p += 4 + size = -Int32FromInt32(2) + } else { + size = -int32(1) + } + case int32('l'): + if **(**Twchar_t)(__ccgo_up(p)) == int32('l') { + p += 4 + size = Int32FromInt32(SIZE_ll) + } else { + size = int32(SIZE_l) + } + case int32('j'): + size = int32(SIZE_ll) + case int32('z'): + fallthrough + case int32('t'): + size = int32(SIZE_l) + case int32('L'): + size = int32(SIZE_L) + case int32('d'): + fallthrough + case int32('i'): + fallthrough + case int32('o'): + fallthrough + case int32('u'): + fallthrough + case int32('x'): + fallthrough + case int32('a'): + fallthrough + case int32('e'): + fallthrough + case int32('f'): + fallthrough + case int32('g'): + fallthrough + case int32('A'): + fallthrough + case int32('E'): + fallthrough + case int32('F'): + fallthrough + case int32('G'): + fallthrough + case int32('X'): + fallthrough + case int32('s'): + fallthrough + case int32('c'): + fallthrough + case int32('['): + fallthrough + case int32('S'): + fallthrough + case int32('C'): + fallthrough + case int32('p'): + fallthrough + case int32('n'): + p -= 4 + default: + goto fmt_fail + } + t = **(**Twchar_t)(__ccgo_up(p)) + /* Transform S,C -> ls,lc */ + if t&int32(0x2f) == int32(3) { + size = int32(SIZE_l) + t = t | int32(32) + } + if t != int32('n') { + if t != int32('[') && t|int32(32) != int32('c') { + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + v1 = Int32FromUint32(v4) + c = v1 + if !(Xiswspace(tls, Uint32FromInt32(v1)) != 0) { + break + } + pos = pos + 1 + } + } else { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + c = Int32FromUint32(v4) + } + if c < 0 { + goto input_fail + } + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 && Uint32FromInt32(c) < uint32(128) { + v6 = f + 8 + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) - 1 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + _ = **(**uint8)(__ccgo_up(v5)) + } else { + Xungetwc(tls, Uint32FromInt32(c), f) + } + } + switch t { + case int32('n'): + _store_int1(tls, dest, size, Uint64FromInt64(pos)) + /* do not increment match count, etc! */ + goto _2 + case int32('s'): + fallthrough + case int32('c'): + fallthrough + case int32('['): + if t == int32('c') { + if width < int32(1) { + width = int32(1) + } + invert = int32(1) + set = __ccgo_ts + 1683 + } else { + if t == int32('s') { + invert = int32(1) + set = uintptr(unsafe.Pointer(&_spaces1)) + } else { + p += 4 + v5 = p + if **(**Twchar_t)(__ccgo_up(v5)) == int32('^') { + p += 4 + invert = Int32FromInt32(1) + } else { + invert = 0 + } + set = p + if **(**Twchar_t)(__ccgo_up(p)) == int32(']') { + p += 4 + } + for **(**Twchar_t)(__ccgo_up(p)) != int32(']') { + if !(**(**Twchar_t)(__ccgo_up(p)) != 0) { + goto fmt_fail + } + p += 4 + } + } + } + if size == SIZE_def { + v5 = dest + } else { + v5 = uintptr(0) + } + s = v5 + if size == int32(SIZE_l) { + v5 = dest + } else { + v5 = uintptr(0) + } + wcs = v5 + gotmatch = 0 + if width < int32(1) { + width = -int32(1) + } + i = uint64(0) + if alloc != 0 { + if t == int32('c') { + v4 = Uint32FromInt32(width) + uint32(1) + } else { + v4 = uint32(31) + } + k = uint64(v4) + if size == int32(SIZE_l) { + wcs = Xmalloc(tls, k*uint64(4)) + if !(wcs != 0) { + goto alloc_fail + } + } else { + s = Xmalloc(tls, k) + if !(s != 0) { + goto alloc_fail + } + } + } + for width != 0 { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + v1 = Int32FromUint32(v4) + c = v1 + if v1 < 0 { + break + } + if _in_set(tls, set, c) == invert { + break + } + if wcs != 0 { + v37 = i + i = i + 1 + **(**Twchar_t)(__ccgo_up(wcs + uintptr(v37)*4)) = c + if alloc != 0 && i == k { + k = k + (k + uint64(1)) + tmp1 = Xrealloc(tls, wcs, k*uint64(4)) + if !(tmp1 != 0) { + goto alloc_fail + } + wcs = tmp1 + } + } else { + if size != int32(SIZE_l) { + if s != 0 { + v5 = s + uintptr(i) + } else { + v5 = bp + 8 + } + l = Xwctomb(tls, v5, c) + if l < 0 { + goto input_fail + } + i = i + Uint64FromInt32(l) + if alloc != 0 && i > k-uint64(4) { + k = k + (k + uint64(1)) + tmp2 = Xrealloc(tls, s, k) + if !(tmp2 != 0) { + goto alloc_fail + } + s = tmp2 + } + } + } + pos = pos + 1 + width = width - BoolInt32(width > 0) + gotmatch = int32(1) + } + if width != 0 { + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 && Uint32FromInt32(c) < uint32(128) { + v6 = f + 8 + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) - 1 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + _ = **(**uint8)(__ccgo_up(v5)) + } else { + Xungetwc(tls, Uint32FromInt32(c), f) + } + if t == int32('c') || !(gotmatch != 0) { + goto match_fail + } + } + if alloc != 0 { + if size == int32(SIZE_l) { + **(**uintptr)(__ccgo_up(dest)) = wcs + } else { + **(**uintptr)(__ccgo_up(dest)) = s + } + } + if t != int32('c') { + if wcs != 0 { + **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) = 0 + } + if s != 0 { + **(**int8)(__ccgo_up(s + uintptr(i))) = 0 + } + } + case int32('d'): + fallthrough + case int32('i'): + fallthrough + case int32('o'): + fallthrough + case int32('u'): + fallthrough + case int32('x'): + fallthrough + case int32('a'): + fallthrough + case int32('e'): + fallthrough + case int32('f'): + fallthrough + case int32('g'): + fallthrough + case int32('A'): + fallthrough + case int32('E'): + fallthrough + case int32('F'): + fallthrough + case int32('G'): + fallthrough + case int32('X'): + fallthrough + case int32('p'): + if width < int32(1) { + width = 0 + } + Xsnprintf(tls, bp+8, uint64(22), __ccgo_ts+1687, VaList(bp+40, int32(1)+BoolInt32(!(dest != 0)), __ccgo_ts+1705, width, uintptr(unsafe.Pointer(&_size_pfx))+uintptr(size+int32(2))*3, t)) + **(**Toff_t)(__ccgo_up(bp)) = 0 + if dest != 0 { + v5 = dest + } else { + v5 = bp + } + if Xfscanf(tls, f, bp+8, VaList(bp+40, v5, bp)) == -int32(1) { + goto input_fail + } else { + if !(**(**Toff_t)(__ccgo_up(bp)) != 0) { + goto match_fail + } + } + pos = pos + **(**Toff_t)(__ccgo_up(bp)) + default: + goto fmt_fail + } + if dest != 0 { + matches = matches + 1 + } + goto _2 + _2: + ; + p += 4 + } + if !(0 != 0) { + goto _42 + } + goto fmt_fail +fmt_fail: + ; + goto alloc_fail +alloc_fail: + ; + goto input_fail +input_fail: + ; + if !(matches != 0) { + matches = matches - 1 + } + goto match_fail +match_fail: + ; + if alloc != 0 { + Xfree(tls, s) + Xfree(tls, wcs) + } +_42: + ; + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return matches +} + +var _size_pfx = [6][3]int8{ + 0: {'h', 'h'}, + 1: {'h'}, + 2: {}, + 3: {'l'}, + 4: {'L'}, + 5: {'l', 'l'}, +} + +var _spaces1 = [22]Twchar_t{ + 0: int32(' '), + 1: int32('\t'), + 2: int32('\n'), + 3: int32('\r'), + 4: int32(11), + 5: int32(12), + 6: int32(0x0085), + 7: int32(0x2000), + 8: int32(0x2001), + 9: int32(0x2002), + 10: int32(0x2003), + 11: int32(0x2004), + 12: int32(0x2005), + 13: int32(0x2006), + 14: int32(0x2008), + 15: int32(0x2009), + 16: int32(0x200a), + 17: int32(0x2028), + 18: int32(0x2029), + 19: int32(0x205f), + 20: int32(0x3000), +} + +func X__isoc99_vfwscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfwscanf(tls, f, fmt, ap) +} + +func Xvprintf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfprintf(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), fmt, ap) +} + +func Xvscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfscanf(tls, uintptr(unsafe.Pointer(&X__stdin_FILE)), fmt, ap) +} + +func X__isoc99_vscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvscanf(tls, fmt, ap) +} + +type Tcookie3 = struct { + Fs uintptr + Fn Tsize_t +} + +func _sn_write(tls *TLS, f uintptr, s uintptr, l Tsize_t) (r Tsize_t) { + var c, v3 uintptr + var k Tsize_t + var v1 uint64 + _, _, _, _ = c, k, v1, v3 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if (*Tcookie3)(unsafe.Pointer(c)).Fn < Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos)-int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) { + v1 = (*Tcookie3)(unsafe.Pointer(c)).Fn + } else { + v1 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + } + k = v1 + if k != 0 { + Xmemcpy(tls, (*Tcookie3)(unsafe.Pointer(c)).Fs, (*TFILE)(unsafe.Pointer(f)).Fwbase, k) + **(**uintptr)(__ccgo_up(c)) += uintptr(k) + **(**Tsize_t)(__ccgo_up(c + 8)) -= k + } + if (*Tcookie3)(unsafe.Pointer(c)).Fn < l { + v1 = (*Tcookie3)(unsafe.Pointer(c)).Fn + } else { + v1 = l + } + k = v1 + if k != 0 { + Xmemcpy(tls, (*Tcookie3)(unsafe.Pointer(c)).Fs, s, k) + **(**uintptr)(__ccgo_up(c)) += uintptr(k) + **(**Tsize_t)(__ccgo_up(c + 8)) -= k + } + **(**int8)(__ccgo_up((*Tcookie3)(unsafe.Pointer(c)).Fs)) = 0 + v3 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fwbase = v3 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v3 + /* pretend to succeed, even if we discarded extra data */ + return l +} + +func Xvsnprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v ap=%v, (%v:)", tls, s, n, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(256) + defer tls.Free(256) + var v1 uintptr + var v2 uint64 + var _ /* buf at bp+0 */ [1]uint8 + var _ /* c at bp+8 */ Tcookie3 + var _ /* dummy at bp+1 */ [1]int8 + var _ /* f at bp+24 */ TFILE + _, _ = v1, v2 + if n != 0 { + v1 = s + } else { + v1 = bp + 1 + } + if n != 0 { + v2 = n - uint64(1) + } else { + v2 = uint64(0) + } + **(**Tcookie3)(__ccgo_up(bp + 8)) = Tcookie3{ + Fs: v1, + Fn: v2, + } + **(**TFILE)(__ccgo_up(bp + 24)) = TFILE{ + Fwrite: __ccgo_fp(_sn_write), + Fbuf: bp, + Flock: -int32(1), + Flbf: -int32(1), + Fcookie: bp + 8, + } + **(**int8)(__ccgo_up((**(**Tcookie3)(__ccgo_up(bp + 8))).Fs)) = 0 + return Xvfprintf(tls, bp+24, fmt, ap) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xvsprintf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvsnprintf(tls, s, uint64(INT_MAX), fmt, ap) +} + +func _string_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var end, src uintptr + var k Tsize_t + _, _, _ = end, k, src + src = (*TFILE)(unsafe.Pointer(f)).Fcookie + k = len1 + uint64(256) + end = Xmemchr(tls, src, 0, k) + if end != 0 { + k = Uint64FromInt64(int64(end) - int64(src)) + } + if k < len1 { + len1 = k + } + Xmemcpy(tls, buf, src, len1) + (*TFILE)(unsafe.Pointer(f)).Frpos = src + uintptr(len1) + (*TFILE)(unsafe.Pointer(f)).Frend = src + uintptr(k) + (*TFILE)(unsafe.Pointer(f)).Fcookie = src + uintptr(k) + return len1 +} + +func Xvsscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(240) + defer tls.Free(240) + var _ /* f at bp+0 */ TFILE + **(**TFILE)(__ccgo_up(bp)) = TFILE{ + Fread: __ccgo_fp(_string_read), + Fbuf: s, + Flock: -int32(1), + Fcookie: s, + } + return Xvfscanf(tls, bp, fmt, ap) +} + +func X__isoc99_vsscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvsscanf(tls, s, fmt, ap) +} + +type Tcookie4 = struct { + Fws uintptr + Fl Tsize_t +} + +func _sw_write(tls *TLS, f uintptr, s uintptr, l Tsize_t) (r Tsize_t) { + var c, v3, v4 uintptr + var i, v1 int32 + var l0 Tsize_t + var v2 bool + _, _, _, _, _, _, _ = c, i, l0, v1, v2, v3, v4 + l0 = l + i = 0 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if s != (*TFILE)(unsafe.Pointer(f)).Fwbase && _sw_write(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwbase, Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos)-int64((*TFILE)(unsafe.Pointer(f)).Fwbase))) == Uint64FromInt32(-Int32FromInt32(1)) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + for { + if v2 = (*Tcookie4)(unsafe.Pointer(c)).Fl != 0 && l != 0; v2 { + v1 = Xmbtowc(tls, (*Tcookie4)(unsafe.Pointer(c)).Fws, s, l) + i = v1 + } + if !(v2 && v1 >= 0) { + break + } + if !(i != 0) { + i = int32(1) + } + s = s + uintptr(i) + l = l - Uint64FromInt32(i) + (*Tcookie4)(unsafe.Pointer(c)).Fl = (*Tcookie4)(unsafe.Pointer(c)).Fl - 1 + (*Tcookie4)(unsafe.Pointer(c)).Fws += 4 + } + **(**Twchar_t)(__ccgo_up((*Tcookie4)(unsafe.Pointer(c)).Fws)) = 0 + if i < 0 { + v4 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v4 + v3 = v4 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v3 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v3 + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + return Uint64FromInt32(i) + } + (*TFILE)(unsafe.Pointer(f)).Fwend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr((*TFILE)(unsafe.Pointer(f)).Fbuf_size) + v3 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fwbase = v3 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v3 + return l0 +} + +func Xvswprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, ap Tva_list) (r1 int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v ap=%v, (%v:)", tls, s, n, fmt, ap, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(512) + defer tls.Free(512) + var r, v1 int32 + var _ /* buf at bp+0 */ [256]uint8 + var _ /* c at bp+256 */ Tcookie4 + var _ /* f at bp+272 */ TFILE + _, _ = r, v1 + **(**Tcookie4)(__ccgo_up(bp + 256)) = Tcookie4{ + Fws: s, + Fl: n - uint64(1), + } + **(**TFILE)(__ccgo_up(bp + 272)) = TFILE{ + Fwrite: __ccgo_fp(_sw_write), + Fbuf: bp, + Fbuf_size: uint64(256), + Flock: -int32(1), + Flbf: -int32(1), + Fcookie: bp + 256, + } + if !(n != 0) { + return -int32(1) + } + r = Xvfwprintf(tls, bp+272, fmt, ap) + _sw_write(tls, bp+272, uintptr(0), uint64(0)) + if Uint64FromInt32(r) >= n { + v1 = -int32(1) + } else { + v1 = r + } + return v1 +} + +func _wstring_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var k Tsize_t + var v1, v2 uintptr + var _ /* src at bp+0 */ uintptr + _, _, _ = k, v1, v2 + **(**uintptr)(__ccgo_up(bp)) = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(**(**uintptr)(__ccgo_up(bp)) != 0) { + return uint64(0) + } + k = Xwcsrtombs(tls, (*TFILE)(unsafe.Pointer(f)).Fbuf, bp, (*TFILE)(unsafe.Pointer(f)).Fbuf_size, uintptr(0)) + if k == Uint64FromInt32(-Int32FromInt32(1)) { + v1 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + return uint64(0) + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(k) + (*TFILE)(unsafe.Pointer(f)).Fcookie = **(**uintptr)(__ccgo_up(bp)) + if !(len1 != 0) || !(k != 0) { + return uint64(0) + } + v2 = f + 8 + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up(buf)) = **(**uint8)(__ccgo_up(v1)) + return uint64(1) +} + +func Xvswscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(496) + defer tls.Free(496) + var _ /* buf at bp+0 */ [256]uint8 + var _ /* f at bp+256 */ TFILE + **(**TFILE)(__ccgo_up(bp + 256)) = TFILE{ + Fread: __ccgo_fp(_wstring_read), + Fbuf: bp, + Fbuf_size: uint64(256), + Flock: -int32(1), + Fcookie: s, + } + return Xvfwscanf(tls, bp+256, fmt, ap) +} + +func X__isoc99_vswscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvswscanf(tls, s, fmt, ap) +} + +func Xvwprintf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfwprintf(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), fmt, ap) +} + +func Xvwscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfwscanf(tls, uintptr(unsafe.Pointer(&X__stdin_FILE)), fmt, ap) +} + +func X__isoc99_vwscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvwscanf(tls, fmt, ap) +} + +func Xwprintf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvwprintf(tls, fmt, ap) + _ = ap + return ret +} + +func Xwscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvwscanf(tls, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_wscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwscanf(tls, fmt, va) +} + +func Xabs(tls *TLS, a int32) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if a > 0 { + v1 = a + } else { + v1 = -a + } + return v1 +} + +func Xatof(tls *TLS, s uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtod(tls, s, uintptr(0)) +} + +func Xatoi(tls *TLS, s uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var n, neg, v1, v2 int32 + var v4 uintptr + _, _, _, _, _ = n, neg, v1, v2, v4 + n = 0 + neg = 0 + for { + v1 = int32(**(**int8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if !(v2 != 0) { + break + } + s = s + 1 + } + switch int32(**(**int8)(__ccgo_up(s))) { + case int32('-'): + neg = int32(1) + fallthrough + case int32('+'): + s = s + 1 + } + /* Compute n as a negative number to avoid overflow on INT_MIN */ + for BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0 { + v4 = s + s = s + 1 + n = int32(10)*n - (int32(**(**int8)(__ccgo_up(v4))) - int32('0')) + } + if neg != 0 { + v1 = n + } else { + v1 = -n + } + return v1 +} + +func Xatol(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var n, v5 int64 + var neg, v1, v2 int32 + var v4 uintptr + _, _, _, _, _, _ = n, neg, v1, v2, v4, v5 + n = 0 + neg = 0 + for { + v1 = int32(**(**int8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if !(v2 != 0) { + break + } + s = s + 1 + } + switch int32(**(**int8)(__ccgo_up(s))) { + case int32('-'): + neg = int32(1) + fallthrough + case int32('+'): + s = s + 1 + } + /* Compute n as a negative number to avoid overflow on LONG_MIN */ + for BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0 { + v4 = s + s = s + 1 + n = int64(10)*n - int64(int32(**(**int8)(__ccgo_up(v4)))-Int32FromUint8('0')) + } + if neg != 0 { + v5 = n + } else { + v5 = -n + } + return v5 +} + +func Xatoll(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var n, v5 int64 + var neg, v1, v2 int32 + var v4 uintptr + _, _, _, _, _, _ = n, neg, v1, v2, v4, v5 + n = 0 + neg = 0 + for { + v1 = int32(**(**int8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if !(v2 != 0) { + break + } + s = s + 1 + } + switch int32(**(**int8)(__ccgo_up(s))) { + case int32('-'): + neg = int32(1) + fallthrough + case int32('+'): + s = s + 1 + } + /* Compute n as a negative number to avoid overflow on LLONG_MIN */ + for BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0 { + v4 = s + s = s + 1 + n = int64(10)*n - int64(int32(**(**int8)(__ccgo_up(v4)))-Int32FromUint8('0')) + } + if neg != 0 { + v5 = n + } else { + v5 = -n + } + return v5 +} + +type t__ccgo_fp__Xbsearch_4 = func(*TLS, uintptr, uintptr) int32 + +func Xbsearch(tls *TLS, key uintptr, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v base=%v nel=%v width=%v __ccgo_fp_cmp=%v, (%v:)", tls, key, base, nel, width, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var sign int32 + var try uintptr + _, _ = sign, try + for nel > uint64(0) { + try = base + uintptr(width*(nel/uint64(2))) + sign = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, key, try) + if sign < 0 { + nel = nel / uint64(2) + } else { + if sign > 0 { + base = try + uintptr(width) + nel = nel - (nel/uint64(2) + uint64(1)) + } else { + return try + } + } + } + return UintptrFromInt32(0) +} + +func Xdiv(tls *TLS, num int32, den int32) (r Tdiv_t) { + if __ccgo_strace { + trc("tls=%v num=%v den=%v, (%v:)", tls, num, den, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Tdiv_t{ + Fquot: num / den, + Frem: num % den, + } +} + +func Xecvt(tls *TLS, x float64, n int32, dp uintptr, sign uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v dp=%v sign=%v, (%v:)", tls, x, n, dp, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var i, j, v1 int32 + var _ /* tmp at bp+0 */ [32]int8 + _, _, _ = i, j, v1 + if Uint32FromInt32(n)-uint32(1) > uint32(15) { + n = int32(15) + } + Xsprintf(tls, bp, __ccgo_ts+1708, VaList(bp+40, n-int32(1), x)) + v1 = BoolInt32(int32((**(**[32]int8)(__ccgo_up(bp)))[0]) == Int32FromUint8('-')) + **(**int32)(__ccgo_up(sign)) = v1 + i = v1 + j = 0 + for { + if !(int32((**(**[32]int8)(__ccgo_up(bp)))[i]) != int32('e')) { + break + } + _buf8[j] = (**(**[32]int8)(__ccgo_up(bp)))[i] + goto _2 + _2: + ; + v1 = i + i = i + 1 + j = j + BoolInt32(int32((**(**[32]int8)(__ccgo_up(bp)))[v1]) != int32('.')) + } + _buf8[j] = 0 + **(**int32)(__ccgo_up(dp)) = Xatoi(tls, bp+uintptr(i)+uintptr(1)) + int32(1) + return uintptr(unsafe.Pointer(&_buf8)) +} + +var _buf8 [16]int8 + +func Xfcvt(tls *TLS, x float64, n int32, dp uintptr, sign uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v dp=%v sign=%v, (%v:)", tls, x, n, dp, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(1536) + defer tls.Free(1536) + var i, lz int32 + var _ /* tmp at bp+0 */ [1500]int8 + _, _ = i, lz + if Uint32FromInt32(n) > uint32(1400) { + n = int32(1400) + } + Xsprintf(tls, bp, __ccgo_ts+1713, VaList(bp+1512, n, x)) + i = BoolInt32(int32((**(**[1500]int8)(__ccgo_up(bp)))[0]) == int32('-')) + if int32((**(**[1500]int8)(__ccgo_up(bp)))[i]) == int32('0') { + lz = Int32FromUint64(Xstrspn(tls, bp+uintptr(i)+uintptr(2), __ccgo_ts+1681)) + } else { + lz = -Int32FromUint64(Xstrcspn(tls, bp+uintptr(i), __ccgo_ts+575)) + } + if n <= lz { + **(**int32)(__ccgo_up(sign)) = i + **(**int32)(__ccgo_up(dp)) = int32(1) + if Uint32FromInt32(n) > uint32(14) { + n = int32(14) + } + return __ccgo_ts + 1718 + UintptrFromInt32(14) - uintptr(n) + } + return Xecvt(tls, x, n-lz, dp, sign) +} + +func Xgcvt(tls *TLS, x float64, n int32, b uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v b=%v, (%v:)", tls, x, n, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + Xsprintf(tls, b, __ccgo_ts+1734, VaList(bp+8, n, x)) + return b +} + +func Ximaxabs(tls *TLS, a Tintmax_t) (r Tintmax_t) { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if a > 0 { + v1 = a + } else { + v1 = -a + } + return v1 +} + +func Ximaxdiv(tls *TLS, num Tintmax_t, den Tintmax_t) (r Timaxdiv_t) { + if __ccgo_strace { + trc("tls=%v num=%v den=%v, (%v:)", tls, num, den, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Timaxdiv_t{ + Fquot: num / den, + Frem: num % den, + } +} + +func Xlabs(tls *TLS, a int64) (r int64) { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if a > 0 { + v1 = a + } else { + v1 = -a + } + return v1 +} + +func Xldiv(tls *TLS, num int64, den int64) (r Tldiv_t) { + if __ccgo_strace { + trc("tls=%v num=%v den=%v, (%v:)", tls, num, den, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Tldiv_t{ + Fquot: num / den, + Frem: num % den, + } +} + +func Xllabs(tls *TLS, a int64) (r int64) { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if a > 0 { + v1 = a + } else { + v1 = -a + } + return v1 +} + +func Xlldiv(tls *TLS, num int64, den int64) (r Tlldiv_t) { + if __ccgo_strace { + trc("tls=%v num=%v den=%v, (%v:)", tls, num, den, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Tlldiv_t{ + Fquot: num / den, + Frem: num % den, + } +} + +type Tcmpfun = uintptr + +func _pntz(tls *TLS, p uintptr) (r1 int32) { + var r, v1 int32 + var v2 bool + _, _, _ = r, v1, v2 + r = _a_ctz_l(tls, **(**Tsize_t)(__ccgo_up(p))-uint64(1)) + if v2 = r != 0; !v2 { + v1 = Int32FromUint64(Uint64FromInt32(8)*Uint64FromInt64(8) + Uint64FromInt32(_a_ctz_l(tls, **(**Tsize_t)(__ccgo_up(p + 1*8))))) + r = v1 + } + if v2 || Uint64FromInt32(v1) != Uint64FromInt32(8)*Uint64FromInt64(8) { + return r + } + return 0 +} + +func _cycle(tls *TLS, width Tsize_t, ar uintptr, n int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var i int32 + var l Tsize_t + var v1 uint64 + var _ /* tmp at bp+0 */ [256]uint8 + _, _, _ = i, l, v1 + if n < int32(2) { + return + } + **(**uintptr)(__ccgo_up(ar + uintptr(n)*8)) = bp + for width != 0 { + if uint64(256) < width { + v1 = uint64(256) + } else { + v1 = width + } + l = v1 + Xmemcpy(tls, **(**uintptr)(__ccgo_up(ar + uintptr(n)*8)), **(**uintptr)(__ccgo_up(ar)), l) + i = 0 + for { + if !(i < n) { + break + } + Xmemcpy(tls, **(**uintptr)(__ccgo_up(ar + uintptr(i)*8)), **(**uintptr)(__ccgo_up(ar + uintptr(i+int32(1))*8)), l) + **(**uintptr)(__ccgo_up(ar + uintptr(i)*8)) += uintptr(l) + goto _2 + _2: + ; + i = i + 1 + } + width = width - l + } +} + +// C documentation +// +// /* shl() and shr() need n > 0 */ +func _shl(tls *TLS, p uintptr, n int32) { + if Uint64FromInt32(n) >= Uint64FromInt32(8)*Uint64FromInt64(8) { + n = Int32FromUint64(uint64(n) - Uint64FromInt32(8)*Uint64FromInt64(8)) + **(**Tsize_t)(__ccgo_up(p + 1*8)) = **(**Tsize_t)(__ccgo_up(p)) + **(**Tsize_t)(__ccgo_up(p)) = uint64(0) + } + **(**Tsize_t)(__ccgo_up(p + 1*8)) <<= Uint64FromInt32(n) + **(**Tsize_t)(__ccgo_up(p + 1*8)) |= **(**Tsize_t)(__ccgo_up(p)) >> (Uint64FromInt64(8)*Uint64FromInt32(8) - Uint64FromInt32(n)) + **(**Tsize_t)(__ccgo_up(p)) <<= Uint64FromInt32(n) +} + +func _shr(tls *TLS, p uintptr, n int32) { + if Uint64FromInt32(n) >= Uint64FromInt32(8)*Uint64FromInt64(8) { + n = Int32FromUint64(uint64(n) - Uint64FromInt32(8)*Uint64FromInt64(8)) + **(**Tsize_t)(__ccgo_up(p)) = **(**Tsize_t)(__ccgo_up(p + 1*8)) + **(**Tsize_t)(__ccgo_up(p + 1*8)) = uint64(0) + } + **(**Tsize_t)(__ccgo_up(p)) >>= Uint64FromInt32(n) + **(**Tsize_t)(__ccgo_up(p)) |= **(**Tsize_t)(__ccgo_up(p + 1*8)) << (Uint64FromInt64(8)*Uint64FromInt32(8) - Uint64FromInt32(n)) + **(**Tsize_t)(__ccgo_up(p + 1*8)) >>= Uint64FromInt32(n) +} + +func _sift(tls *TLS, head uintptr, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr, pshift int32, lp uintptr) { + bp := tls.Alloc(912) + defer tls.Free(912) + var i, v1 int32 + var lf, rt uintptr + var _ /* ar at bp+0 */ [113]uintptr + _, _, _, _ = i, lf, rt, v1 + i = int32(1) + (**(**[113]uintptr)(__ccgo_up(bp)))[0] = head + for pshift > int32(1) { + rt = head - uintptr(width) + lf = head - uintptr(width) - uintptr(**(**Tsize_t)(__ccgo_up(lp + uintptr(pshift-int32(2))*8))) + if (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, (**(**[113]uintptr)(__ccgo_up(bp)))[0], lf, arg) >= 0 && (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, (**(**[113]uintptr)(__ccgo_up(bp)))[0], rt, arg) >= 0 { + break + } + if (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, lf, rt, arg) >= 0 { + v1 = i + i = i + 1 + (**(**[113]uintptr)(__ccgo_up(bp)))[v1] = lf + head = lf + pshift = pshift - int32(1) + } else { + v1 = i + i = i + 1 + (**(**[113]uintptr)(__ccgo_up(bp)))[v1] = rt + head = rt + pshift = pshift - int32(2) + } + } + _cycle(tls, width, bp, i) +} + +func _trinkle(tls *TLS, head uintptr, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr, pp uintptr, pshift int32, trusty int32, lp uintptr) { + bp := tls.Alloc(928) + defer tls.Free(928) + var i, trail, v1 int32 + var lf, rt, stepson uintptr + var _ /* ar at bp+16 */ [113]uintptr + var _ /* p at bp+0 */ [2]Tsize_t + _, _, _, _, _, _ = i, lf, rt, stepson, trail, v1 + i = int32(1) + (**(**[2]Tsize_t)(__ccgo_up(bp)))[0] = **(**Tsize_t)(__ccgo_up(pp)) + (**(**[2]Tsize_t)(__ccgo_up(bp)))[int32(1)] = **(**Tsize_t)(__ccgo_up(pp + 1*8)) + (**(**[113]uintptr)(__ccgo_up(bp + 16)))[0] = head + for (**(**[2]Tsize_t)(__ccgo_up(bp)))[0] != uint64(1) || (**(**[2]Tsize_t)(__ccgo_up(bp)))[int32(1)] != uint64(0) { + stepson = head - uintptr(**(**Tsize_t)(__ccgo_up(lp + uintptr(pshift)*8))) + if (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, stepson, (**(**[113]uintptr)(__ccgo_up(bp + 16)))[0], arg) <= 0 { + break + } + if !(trusty != 0) && pshift > int32(1) { + rt = head - uintptr(width) + lf = head - uintptr(width) - uintptr(**(**Tsize_t)(__ccgo_up(lp + uintptr(pshift-int32(2))*8))) + if (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, rt, stepson, arg) >= 0 || (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, lf, stepson, arg) >= 0 { + break + } + } + v1 = i + i = i + 1 + (**(**[113]uintptr)(__ccgo_up(bp + 16)))[v1] = stepson + head = stepson + trail = _pntz(tls, bp) + _shr(tls, bp, trail) + pshift = pshift + trail + trusty = 0 + } + if !(trusty != 0) { + _cycle(tls, width, bp+16, i) + _sift(tls, head, width, __ccgo_fp_cmp, arg, pshift, lp) + } +} + +type t__ccgo_fp__X__qsort_r_3 = func(*TLS, uintptr, uintptr, uintptr) int32 + +func X__qsort_r(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr) { + if __ccgo_strace { + trc("tls=%v base=%v nel=%v width=%v __ccgo_fp_cmp=%v arg=%v, (%v:)", tls, base, nel, width, __ccgo_fp_cmp, arg, origin(2)) + } + bp := tls.Alloc(784) + defer tls.Free(784) + var head, high uintptr + var i, size, v2, v3 Tsize_t + var pshift, trail int32 + var _ /* lp at bp+0 */ [96]Tsize_t + var _ /* p at bp+768 */ [2]Tsize_t + _, _, _, _, _, _, _, _ = head, high, i, pshift, size, trail, v2, v3 + size = width * nel + **(**[2]Tsize_t)(__ccgo_up(bp + 768)) = [2]Tsize_t{ + 0: uint64(1), + } + pshift = int32(1) + if !(size != 0) { + return + } + head = base + high = head + uintptr(size) - uintptr(width) + /* Precompute Leonardo numbers, scaled by element width */ + v2 = width + (**(**[96]Tsize_t)(__ccgo_up(bp)))[int32(1)] = v2 + (**(**[96]Tsize_t)(__ccgo_up(bp)))[0] = v2 + i = Uint64FromInt32(2) + for { + v3 = (**(**[96]Tsize_t)(__ccgo_up(bp)))[i-uint64(2)] + (**(**[96]Tsize_t)(__ccgo_up(bp)))[i-uint64(1)] + width + (**(**[96]Tsize_t)(__ccgo_up(bp)))[i] = v3 + if !(v3 < size) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + for head < high { + if (**(**[2]Tsize_t)(__ccgo_up(bp + 768)))[0]&uint64(3) == uint64(3) { + _sift(tls, head, width, __ccgo_fp_cmp, arg, pshift, bp) + _shr(tls, bp+768, int32(2)) + pshift = pshift + int32(2) + } else { + if (**(**[96]Tsize_t)(__ccgo_up(bp)))[pshift-int32(1)] >= Uint64FromInt64(int64(high)-int64(head)) { + _trinkle(tls, head, width, __ccgo_fp_cmp, arg, bp+768, pshift, 0, bp) + } else { + _sift(tls, head, width, __ccgo_fp_cmp, arg, pshift, bp) + } + if pshift == int32(1) { + _shl(tls, bp+768, int32(1)) + pshift = 0 + } else { + _shl(tls, bp+768, pshift-int32(1)) + pshift = int32(1) + } + } + **(**Tsize_t)(__ccgo_up(bp + 768)) |= uint64(1) + head = head + uintptr(width) + } + _trinkle(tls, head, width, __ccgo_fp_cmp, arg, bp+768, pshift, 0, bp) + for pshift != int32(1) || (**(**[2]Tsize_t)(__ccgo_up(bp + 768)))[0] != uint64(1) || (**(**[2]Tsize_t)(__ccgo_up(bp + 768)))[int32(1)] != uint64(0) { + if pshift <= int32(1) { + trail = _pntz(tls, bp+768) + _shr(tls, bp+768, trail) + pshift = pshift + trail + } else { + _shl(tls, bp+768, int32(2)) + pshift = pshift - int32(2) + **(**Tsize_t)(__ccgo_up(bp + 768)) ^= uint64(7) + _shr(tls, bp+768, int32(1)) + _trinkle(tls, head-uintptr((**(**[96]Tsize_t)(__ccgo_up(bp)))[pshift])-uintptr(width), width, __ccgo_fp_cmp, arg, bp+768, pshift+int32(1), int32(1), bp) + _shl(tls, bp+768, int32(1)) + **(**Tsize_t)(__ccgo_up(bp + 768)) |= uint64(1) + _trinkle(tls, head-uintptr(width), width, __ccgo_fp_cmp, arg, bp+768, pshift, int32(1), bp) + } + head = head - uintptr(width) + } +} + +type t__ccgo_fp__Xqsort_r_3 = func(*TLS, uintptr, uintptr, uintptr) int32 + +func Xqsort_r(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr) { + if __ccgo_strace { + trc("tls=%v base=%v nel=%v width=%v __ccgo_fp_cmp=%v arg=%v, (%v:)", tls, base, nel, width, __ccgo_fp_cmp, arg, origin(2)) + } + X__qsort_r(tls, base, nel, width, __ccgo_fp_cmp, arg) +} + +func _wrapper_cmp(tls *TLS, v1 uintptr, v2 uintptr, cmp uintptr) (r int32) { + return (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{cmp})))(tls, v1, v2) +} + +type t__ccgo_fp__Xqsort_3 = func(*TLS, uintptr, uintptr) int32 + +func Xqsort(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun) { + if __ccgo_strace { + trc("tls=%v base=%v nel=%v width=%v __ccgo_fp_cmp=%v, (%v:)", tls, base, nel, width, __ccgo_fp_cmp, origin(2)) + } + X__qsort_r(tls, base, nel, width, __ccgo_fp(_wrapper_cmp), __ccgo_fp_cmp) +} + +func _strtox(tls *TLS, s uintptr, p uintptr, prec int32) (r float64) { + bp := tls.Alloc(240) + defer tls.Free(240) + var cnt Toff_t + var y float64 + var v1 uintptr + var _ /* f at bp+0 */ TFILE + _, _, _ = cnt, y, v1 + v1 = s + (*TFILE)(unsafe.Pointer(bp)).Frpos = v1 + (*TFILE)(unsafe.Pointer(bp)).Fbuf = v1 + (*TFILE)(unsafe.Pointer(bp)).Frend = uintptr(-Int32FromInt32(1)) + X__shlim(tls, bp, int64(Int32FromInt32(0))) + y = X__floatscan(tls, bp, prec, int32(1)) + cnt = (*TFILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(bp)).Frpos) - int64((*TFILE)(unsafe.Pointer(bp)).Fbuf)) + if p != 0 { + if cnt != 0 { + v1 = s + uintptr(cnt) + } else { + v1 = s + } + **(**uintptr)(__ccgo_up(p)) = v1 + } + return y +} + +func Xstrtof(tls *TLS, s uintptr, p uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float32(_strtox(tls, s, p, 0)) +} + +func Xstrtod(tls *TLS, s uintptr, p uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _strtox(tls, s, p, int32(1)) +} + +func Xstrtold(tls *TLS, s uintptr, p uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _strtox(tls, s, p, int32(2)) +} + +func _strtox1(tls *TLS, s uintptr, p uintptr, base int32, lim uint64) (r uint64) { + bp := tls.Alloc(240) + defer tls.Free(240) + var cnt Tsize_t + var y uint64 + var v1 uintptr + var _ /* f at bp+0 */ TFILE + _, _, _ = cnt, y, v1 + v1 = s + (*TFILE)(unsafe.Pointer(bp)).Frpos = v1 + (*TFILE)(unsafe.Pointer(bp)).Fbuf = v1 + (*TFILE)(unsafe.Pointer(bp)).Frend = uintptr(-Int32FromInt32(1)) + X__shlim(tls, bp, int64(Int32FromInt32(0))) + y = X__intscan(tls, bp, Uint32FromInt32(base), int32(1), lim) + if p != 0 { + cnt = Uint64FromInt64((*TFILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(bp)).Frpos) - int64((*TFILE)(unsafe.Pointer(bp)).Fbuf))) + **(**uintptr)(__ccgo_up(p)) = s + uintptr(cnt) + } + return y +} + +func Xstrtoull(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _strtox1(tls, s, p, base, Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)) +} + +func Xstrtoll(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(_strtox1(tls, s, p, base, Uint64FromInt64(-Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1)))) +} + +func Xstrtoul(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _strtox1(tls, s, p, base, uint64(Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1))) +} + +func Xstrtol(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(_strtox1(tls, s, p, base, uint64(Uint64FromUint64(0)+Uint64FromInt64(-Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1))))) +} + +func Xstrtoimax(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoll(tls, s, p, base) +} + +func Xstrtoumax(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoull(tls, s, p, base) +} + +func X__strtoimax_internal(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoimax(tls, s, p, base) +} + +func X__strtol_internal(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtol(tls, s, p, base) +} + +func X__strtoll_internal(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoll(tls, s, p, base) +} + +func X__strtoul_internal(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoul(tls, s, p, base) +} + +func X__strtoull_internal(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoull(tls, s, p, base) +} + +func X__strtoumax_internal(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoumax(tls, s, p, base) +} + +/* This read function heavily cheats. It knows: + * (1) len will always be 1 + * (2) non-ascii characters don't matter */ + +func _do_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var i Tsize_t + var wcs, v3, v4 uintptr + var v2 int32 + _, _, _, _, _ = i, wcs, v2, v3, v4 + wcs = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(**(**Twchar_t)(__ccgo_up(wcs)) != 0) { + wcs = __ccgo_ts + 1739 + } + i = uint64(0) + for { + if !(i < (*TFILE)(unsafe.Pointer(f)).Fbuf_size && **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) != 0) { + break + } + if **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) < int32(128) { + v2 = **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) + } else { + v2 = int32('@') + } + **(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(i))) = Uint8FromInt32(v2) + goto _1 + _1: + ; + i = i + 1 + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(i) + (*TFILE)(unsafe.Pointer(f)).Fcookie = wcs + uintptr(i)*4 + if i != 0 && len1 != 0 { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(buf)) = **(**uint8)(__ccgo_up(v3)) + return uint64(1) + } + return uint64(0) +} + +func _wcstox(tls *TLS, s uintptr, p uintptr, prec int32) (r float64) { + bp := tls.Alloc(304) + defer tls.Free(304) + var cnt Tsize_t + var t, v1, v2 uintptr + var y float64 + var _ /* buf at bp+0 */ [64]uint8 + var _ /* f at bp+64 */ TFILE + _, _, _, _, _ = cnt, t, y, v1, v2 + t = s + **(**TFILE)(__ccgo_up(bp + 64)) = TFILE{} + (**(**TFILE)(__ccgo_up(bp + 64))).Fflags = uint32(0) + v2 = bp + UintptrFromInt32(4) + (**(**TFILE)(__ccgo_up(bp + 64))).Fbuf = v2 + v1 = v2 + (**(**TFILE)(__ccgo_up(bp + 64))).Frend = v1 + (**(**TFILE)(__ccgo_up(bp + 64))).Frpos = v1 + (**(**TFILE)(__ccgo_up(bp + 64))).Fbuf_size = Uint64FromInt64(64) - Uint64FromInt32(4) + AtomicStorePInt32(bp+64+140, -int32(1)) + (**(**TFILE)(__ccgo_up(bp + 64))).Fread = __ccgo_fp(_do_read) + for Xiswspace(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(t)))) != 0 { + t += 4 + } + (**(**TFILE)(__ccgo_up(bp + 64))).Fcookie = t + X__shlim(tls, bp+64, int64(Int32FromInt32(0))) + y = X__floatscan(tls, bp+64, prec, int32(1)) + if p != 0 { + cnt = Uint64FromInt64((*TFILE)(unsafe.Pointer(bp+64)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(bp+64)).Frpos) - int64((*TFILE)(unsafe.Pointer(bp+64)).Fbuf))) + if cnt != 0 { + v1 = t + uintptr(cnt)*4 + } else { + v1 = s + } + **(**uintptr)(__ccgo_up(p)) = v1 + } + return y +} + +func Xwcstof(tls *TLS, s uintptr, p uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float32(_wcstox(tls, s, p, 0)) +} + +func Xwcstod(tls *TLS, s uintptr, p uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _wcstox(tls, s, p, int32(1)) +} + +func Xwcstold(tls *TLS, s uintptr, p uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _wcstox(tls, s, p, int32(2)) +} + +/* This read function heavily cheats. It knows: + * (1) len will always be 1 + * (2) non-ascii characters don't matter */ + +func _do_read1(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var i Tsize_t + var wcs, v3, v4 uintptr + var v2 int32 + _, _, _, _, _ = i, wcs, v2, v3, v4 + wcs = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(**(**Twchar_t)(__ccgo_up(wcs)) != 0) { + wcs = __ccgo_ts + 1739 + } + i = uint64(0) + for { + if !(i < (*TFILE)(unsafe.Pointer(f)).Fbuf_size && **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) != 0) { + break + } + if **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) < int32(128) { + v2 = **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) + } else { + v2 = int32('@') + } + **(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(i))) = Uint8FromInt32(v2) + goto _1 + _1: + ; + i = i + 1 + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(i) + (*TFILE)(unsafe.Pointer(f)).Fcookie = wcs + uintptr(i)*4 + if i != 0 && len1 != 0 { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(buf)) = **(**uint8)(__ccgo_up(v3)) + return uint64(1) + } + return uint64(0) +} + +func _wcstox1(tls *TLS, s uintptr, p uintptr, base int32, lim uint64) (r uint64) { + bp := tls.Alloc(304) + defer tls.Free(304) + var cnt Tsize_t + var t, v1, v2 uintptr + var y uint64 + var _ /* buf at bp+0 */ [64]uint8 + var _ /* f at bp+64 */ TFILE + _, _, _, _, _ = cnt, t, y, v1, v2 + t = s + **(**TFILE)(__ccgo_up(bp + 64)) = TFILE{} + (**(**TFILE)(__ccgo_up(bp + 64))).Fflags = uint32(0) + v2 = bp + UintptrFromInt32(4) + (**(**TFILE)(__ccgo_up(bp + 64))).Fbuf = v2 + v1 = v2 + (**(**TFILE)(__ccgo_up(bp + 64))).Frend = v1 + (**(**TFILE)(__ccgo_up(bp + 64))).Frpos = v1 + (**(**TFILE)(__ccgo_up(bp + 64))).Fbuf_size = Uint64FromInt64(64) - Uint64FromInt32(4) + AtomicStorePInt32(bp+64+140, -int32(1)) + (**(**TFILE)(__ccgo_up(bp + 64))).Fread = __ccgo_fp(_do_read1) + for Xiswspace(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(t)))) != 0 { + t += 4 + } + (**(**TFILE)(__ccgo_up(bp + 64))).Fcookie = t + X__shlim(tls, bp+64, int64(Int32FromInt32(0))) + y = X__intscan(tls, bp+64, Uint32FromInt32(base), int32(1), lim) + if p != 0 { + cnt = Uint64FromInt64((*TFILE)(unsafe.Pointer(bp+64)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(bp+64)).Frpos) - int64((*TFILE)(unsafe.Pointer(bp+64)).Fbuf))) + if cnt != 0 { + v1 = t + uintptr(cnt)*4 + } else { + v1 = s + } + **(**uintptr)(__ccgo_up(p)) = v1 + } + return y +} + +func Xwcstoull(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _wcstox1(tls, s, p, base, Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)) +} + +func Xwcstoll(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(_wcstox1(tls, s, p, base, Uint64FromInt64(-Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1)))) +} + +func Xwcstoul(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _wcstox1(tls, s, p, base, uint64(Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1))) +} + +func Xwcstol(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(_wcstox1(tls, s, p, base, uint64(Uint64FromUint64(0)+Uint64FromInt64(-Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1))))) +} + +func Xwcstoimax(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcstoll(tls, s, p, base) +} + +func Xwcstoumax(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcstoull(tls, s, p, base) +} + +func Xbcmp(tls *TLS, s1 uintptr, s2 uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v s1=%v s2=%v n=%v, (%v:)", tls, s1, s2, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmemcmp(tls, s1, s2, n) +} + +func Xbcopy(tls *TLS, s1 uintptr, s2 uintptr, n Tsize_t) { + if __ccgo_strace { + trc("tls=%v s1=%v s2=%v n=%v, (%v:)", tls, s1, s2, n, origin(2)) + } + Xmemmove(tls, s2, s1, n) +} + +func Xbzero(tls *TLS, s uintptr, n Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + } + Xmemset(tls, s, 0, n) +} + +func Xexplicit_bzero(tls *TLS, d uintptr, n Tsize_t) { + if __ccgo_strace { + trc("tls=%v d=%v n=%v, (%v:)", tls, d, n, origin(2)) + } + d = Xmemset(tls, d, 0, n) +} + +func Xindex(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrchr(tls, s, c) +} + +const ALIGN1 = -1 +const HIGHS = 0 +const ONES = 0 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xmemccpy(tls *TLS, dest uintptr, src uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v c=%v n=%v, (%v:)", tls, dest, src, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d, s, wd, ws uintptr + var k Tsize_t + var v2 uint8 + var v3 bool + _, _, _, _, _, _, _ = d, k, s, wd, ws, v2, v3 + d = dest + s = src + c = Int32FromUint8(Uint8FromInt32(c)) + if uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) == uint64(d)&(Uint64FromInt64(8)-Uint64FromInt32(1)) { + for { + if v3 = uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 && n != 0; v3 { + v2 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v2 + } + if !(v3 && Int32FromUint8(v2) != c) { + break + } + goto _1 + _1: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + if uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 { + goto tail + } + k = Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(UCHAR_MAX) * Uint64FromInt32(c) + wd = d + ws = s + for { + if !(n >= uint64(8) && !((**(**uint64)(__ccgo_up(ws))^k-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^(**(**uint64)(__ccgo_up(ws))^k) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + **(**uint64)(__ccgo_up(wd)) = **(**uint64)(__ccgo_up(ws)) + goto _4 + _4: + ; + n = n - uint64(8) + ws += 8 + wd += 8 + } + d = wd + s = ws + } + for { + if v3 = n != 0; v3 { + v2 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v2 + } + if !(v3 && Int32FromUint8(v2) != c) { + break + } + goto _5 + _5: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + goto tail +tail: + ; + if n != 0 { + return d + uintptr(1) + } + return uintptr(0) +} + +const SS = 0 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xmemchr(tls *TLS, src uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v src=%v c=%v n=%v, (%v:)", tls, src, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k Tsize_t + var s, w, v4 uintptr + _, _, _, _ = k, s, w, v4 + s = src + c = Int32FromUint8(Uint8FromInt32(c)) + for { + if !(uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 && n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != c) { + break + } + goto _1 + _1: + ; + s = s + 1 + n = n - 1 + } + if n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != c { + k = Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(UCHAR_MAX) * Uint64FromInt32(c) + w = s + for { + if !(n >= Uint64FromInt64(8) && !((**(**uint64)(__ccgo_up(w))^k-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^(**(**uint64)(__ccgo_up(w))^k) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + goto _2 + _2: + ; + w += 8 + n = n - Uint64FromInt64(8) + } + s = w + } + for { + if !(n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != c) { + break + } + goto _3 + _3: + ; + s = s + 1 + n = n - 1 + } + if n != 0 { + v4 = s + } else { + v4 = uintptr(0) + } + return v4 +} + +func Xmemcmp(tls *TLS, vl uintptr, vr uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v vl=%v vr=%v n=%v, (%v:)", tls, vl, vr, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var l, r uintptr + var v2 int32 + _, _, _ = l, r, v2 + l = vl + r = vr + for { + if !(n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r)))) { + break + } + goto _1 + _1: + ; + n = n - 1 + l = l + 1 + r = r + 1 + } + if n != 0 { + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(l))) - Int32FromUint8(**(**uint8)(__ccgo_up(r))) + } else { + v2 = 0 + } + return v2 +} + +const LS = 0 +const RS = 0 + +func Xmemcpy(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d, s, v2, v3 uintptr + var w, x Tuint32_t + _, _, _, _, _, _ = d, s, w, x, v2, v3 + d = dest + s = src + for { + if !(uint64(s)%uint64(4) != 0 && n != 0) { + break + } + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + goto _1 + _1: + ; + n = n - 1 + } + if uint64(d)%uint64(4) == uint64(0) { + for { + if !(n >= uint64(16)) { + break + } + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(0))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(4))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(4))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(8))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(8))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(12))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(12))) + goto _4 + _4: + ; + s = s + uintptr(16) + d = d + uintptr(16) + n = n - uint64(16) + } + if n&uint64(8) != 0 { + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(0))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(4))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(4))) + d = d + uintptr(8) + s = s + uintptr(8) + } + if n&uint64(4) != 0 { + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(0))) + d = d + uintptr(4) + s = s + uintptr(4) + } + if n&uint64(2) != 0 { + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + } + if n&uint64(1) != 0 { + **(**uint8)(__ccgo_up(d)) = **(**uint8)(__ccgo_up(s)) + } + return dest + } + if n >= uint64(32) { + switch uint64(d) % Uint64FromInt32(4) { + case uint64(1): + w = **(**uint32)(__ccgo_up(s)) + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + n = n - uint64(3) + for { + if !(n >= uint64(17)) { + break + } + x = **(**uint32)(__ccgo_up(s + UintptrFromInt32(1))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = w>>Int32FromInt32(24) | x<>Int32FromInt32(24) | w<>Int32FromInt32(24) | x<>Int32FromInt32(24) | w<= uint64(18)) { + break + } + x = **(**uint32)(__ccgo_up(s + UintptrFromInt32(2))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = w>>Int32FromInt32(16) | x<>Int32FromInt32(16) | w<>Int32FromInt32(16) | x<>Int32FromInt32(16) | w<= uint64(19)) { + break + } + x = **(**uint32)(__ccgo_up(s + UintptrFromInt32(3))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = w>>Int32FromInt32(8) | x<>Int32FromInt32(8) | w<>Int32FromInt32(8) | x<>Int32FromInt32(8) | w< Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + ms = ip + p0 = p + /* And with the opposite comparison */ + ip = Uint64FromInt32(-Int32FromInt32(1)) + jp = uint64(0) + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + for jp+k < l { + if Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(ip+k)))) == Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + if k == p { + jp = jp + p + k = uint64(1) + } else { + k = k + 1 + } + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(ip+k)))) < Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + if ip+uint64(1) > ms+uint64(1) { + ms = ip + } else { + p = p0 + } + /* Periodic needle? */ + if Xmemcmp(tls, n, n+uintptr(p), ms+uint64(1)) != 0 { + mem0 = uint64(0) + if ms > l-ms-uint64(1) { + v8 = ms + } else { + v8 = l - ms - uint64(1) + } + p = v8 + uint64(1) + } else { + mem0 = l - p + } + mem = uint64(0) + /* Search loop */ + for { + /* If remainder of haystack is shorter than needle, done */ + if Uint64FromInt64(int64(z)-int64(h)) < l { + return uintptr(0) + } + /* Check last byte first; advance by shift on mismatch */ + if (**(**[4]Tsize_t)(__ccgo_up(bp)))[uint64(**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1)))))/(Uint64FromInt32(8)*Uint64FromInt64(8))]&(Uint64FromInt32(1)<<(uint64(**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1)))))%(Uint64FromInt32(8)*Uint64FromInt64(8)))) != 0 { + k = l - shift[**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1))))] + if k != 0 { + if k < mem { + k = mem + } + h = h + uintptr(k) + mem = uint64(0) + goto _9 + } + } else { + h = h + uintptr(l) + mem = uint64(0) + goto _9 + } + /* Compare right half */ + if ms+uint64(1) > mem { + v8 = ms + uint64(1) + } else { + v8 = mem + } + k = v8 + for { + if !(k < l && Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(k)))) == Int32FromUint8(**(**uint8)(__ccgo_up(h + uintptr(k))))) { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if k < l { + h = h + uintptr(k-ms) + mem = uint64(0) + goto _9 + } + /* Compare left half */ + k = ms + uint64(1) + for { + if !(k > mem && Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(k-uint64(1))))) == Int32FromUint8(**(**uint8)(__ccgo_up(h + uintptr(k-uint64(1)))))) { + break + } + goto _12 + _12: + ; + k = k - 1 + } + if k <= mem { + return h + } + h = h + uintptr(p) + mem = mem0 + goto _9 + _9: + } + return r +} + +func Xmemmem(tls *TLS, h0 uintptr, k Tsize_t, n0 uintptr, l Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v h0=%v k=%v n0=%v l=%v, (%v:)", tls, h0, k, n0, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h, n uintptr + _, _ = h, n + h = h0 + n = n0 + /* Return immediately on empty needle */ + if !(l != 0) { + return h + } + /* Return immediately when needle is longer than haystack */ + if k < l { + return uintptr(0) + } + /* Use faster algorithms for short needles */ + h = Xmemchr(tls, h0, Int32FromUint8(**(**uint8)(__ccgo_up(n))), k) + if !(h != 0) || l == uint64(1) { + return h + } + k = k - Uint64FromInt64(int64(h)-int64(h0)) + if k < l { + return uintptr(0) + } + if l == uint64(2) { + return _twobyte_memmem(tls, h, k, n) + } + if l == uint64(3) { + return _threebyte_memmem(tls, h, k, n) + } + if l == uint64(4) { + return _fourbyte_memmem(tls, h, k, n) + } + return _twoway_memmem(tls, h, h+uintptr(k), n, l) +} + +const WS = 0 + +type TWT = uint64 + +func Xmemmove(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d, s, v2, v3 uintptr + var v1 Tsize_t + _, _, _, _, _ = d, s, v1, v2, v3 + d = dest + s = src + if d == s { + return d + } + if uint64(s)-uint64(d)-n <= Uint64FromInt32(-Int32FromInt32(2))*n { + return Xmemcpy(tls, d, s, n) + } + if d < s { + if uint64(s)%Uint64FromInt64(8) == uint64(d)%Uint64FromInt64(8) { + for uint64(d)%Uint64FromInt64(8) != 0 { + v1 = n + n = n - 1 + if !(v1 != 0) { + return dest + } + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = **(**int8)(__ccgo_up(v3)) + } + for { + if !(n >= Uint64FromInt64(8)) { + break + } + **(**TWT)(__ccgo_up(d)) = **(**TWT)(__ccgo_up(s)) + goto _4 + _4: + ; + n = n - Uint64FromInt64(8) + d = d + uintptr(Uint64FromInt64(8)) + s = s + uintptr(Uint64FromInt64(8)) + } + } + for { + if !(n != 0) { + break + } + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**int8)(__ccgo_up(v2)) = **(**int8)(__ccgo_up(v3)) + goto _5 + _5: + ; + n = n - 1 + } + } else { + if uint64(s)%Uint64FromInt64(8) == uint64(d)%Uint64FromInt64(8) { + for uint64(d+uintptr(n))%Uint64FromInt64(8) != 0 { + v1 = n + n = n - 1 + if !(v1 != 0) { + return dest + } + **(**int8)(__ccgo_up(d + uintptr(n))) = **(**int8)(__ccgo_up(s + uintptr(n))) + } + for n >= Uint64FromInt64(8) { + n = n - Uint64FromInt64(8) + **(**TWT)(__ccgo_up(d + uintptr(n))) = **(**TWT)(__ccgo_up(s + uintptr(n))) + } + } + for n != 0 { + n = n - 1 + **(**int8)(__ccgo_up(d + uintptr(n))) = **(**int8)(__ccgo_up(s + uintptr(n))) + } + } + return dest +} + +func Xmempcpy(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmemcpy(tls, dest, src, n) + uintptr(n) +} + +func X__memrchr(tls *TLS, m uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v m=%v c=%v n=%v, (%v:)", tls, m, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + var v1 Tsize_t + _, _ = s, v1 + s = m + c = Int32FromUint8(Uint8FromInt32(c)) + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(n)))) == c { + return s + uintptr(n) + } + } + return uintptr(0) +} + +func Xmemrchr(tls *TLS, m uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v m=%v c=%v n=%v, (%v:)", tls, m, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__memrchr(tls, m, c, n) +} + +func Xmemset(tls *TLS, dest uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v c=%v n=%v, (%v:)", tls, dest, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c32 uint32 + var c64 uint64 + var k Tsize_t + var s uintptr + _, _, _, _ = c32, c64, k, s + s = dest + /* Fill head and tail with minimal branching. Each + * conditional ensures that all the subsequently used + * offsets are well-defined and in the dest region. */ + if !(n != 0) { + return dest + } + **(**uint8)(__ccgo_up(s)) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + uintptr(n-uint64(1)))) = Uint8FromInt32(c) + if n <= uint64(2) { + return dest + } + **(**uint8)(__ccgo_up(s + 1)) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + 2)) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + uintptr(n-uint64(2)))) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + uintptr(n-uint64(3)))) = Uint8FromInt32(c) + if n <= uint64(6) { + return dest + } + **(**uint8)(__ccgo_up(s + 3)) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + uintptr(n-uint64(4)))) = Uint8FromInt32(c) + if n <= uint64(8) { + return dest + } + /* Advance pointer to align it at a 4-byte boundary, + * and truncate n to a multiple of 4. The previous code + * already took care of any head/tail that get cut off + * by the alignment. */ + k = -uint64(s) & uint64(3) + s = s + uintptr(k) + n = n - k + n = n & Uint64FromInt32(-Int32FromInt32(4)) + c32 = Uint32FromInt32(-Int32FromInt32(1)) / Uint32FromInt32(255) * uint32(Uint8FromInt32(c)) + /* In preparation to copy 32 bytes at a time, aligned on + * an 8-byte bounary, fill head/tail up to 28 bytes each. + * As in the initial byte-based head/tail fill, each + * conditional below ensures that the subsequent offsets + * are valid (e.g. !(n<=24) implies n>=28). */ + **(**uint32)(__ccgo_up(s + UintptrFromInt32(0))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(4))) = c32 + if n <= uint64(8) { + return dest + } + **(**uint32)(__ccgo_up(s + UintptrFromInt32(4))) = c32 + **(**uint32)(__ccgo_up(s + UintptrFromInt32(8))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(12))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(8))) = c32 + if n <= uint64(24) { + return dest + } + **(**uint32)(__ccgo_up(s + UintptrFromInt32(12))) = c32 + **(**uint32)(__ccgo_up(s + UintptrFromInt32(16))) = c32 + **(**uint32)(__ccgo_up(s + UintptrFromInt32(20))) = c32 + **(**uint32)(__ccgo_up(s + UintptrFromInt32(24))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(28))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(24))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(20))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(16))) = c32 + /* Align to a multiple of 8 so we can fill 64 bits at a time, + * and avoid writing the same bytes twice as much as is + * practical without introducing additional branching. */ + k = uint64(24) + uint64(s)&uint64(4) + s = s + uintptr(k) + n = n - k + /* If this loop is reached, 28 tail bytes have already been + * filled, so any remainder when n drops below 32 can be + * safely ignored. */ + c64 = uint64(c32) | uint64(c32)<= uint64(32)) { + break + } + **(**uint64)(__ccgo_up(s + UintptrFromInt32(0))) = c64 + **(**uint64)(__ccgo_up(s + UintptrFromInt32(8))) = c64 + **(**uint64)(__ccgo_up(s + UintptrFromInt32(16))) = c64 + **(**uint64)(__ccgo_up(s + UintptrFromInt32(24))) = c64 + goto _1 + _1: + ; + n = n - uint64(32) + s = s + uintptr(32) + } + return dest +} + +func Xrindex(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrrchr(tls, s, c) +} + +const ALIGN2 = 0 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__stpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v, (%v:)", tls, d, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var wd, ws, v4, v5 uintptr + var v2 int8 + _, _, _, _, _ = wd, ws, v2, v4, v5 + if uint64(s)%Uint64FromInt64(8) == uint64(d)%Uint64FromInt64(8) { + for { + if !(uint64(s)%Uint64FromInt64(8) != 0) { + break + } + v2 = **(**int8)(__ccgo_up(s)) + **(**int8)(__ccgo_up(d)) = v2 + if !(v2 != 0) { + return d + } + goto _1 + _1: + ; + s = s + 1 + d = d + 1 + } + wd = d + ws = s + for { + if !!((**(**uint64)(__ccgo_up(ws))-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^**(**uint64)(__ccgo_up(ws)) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0) { + break + } + goto _3 + _3: + ; + v4 = wd + wd += 8 + v5 = ws + ws += 8 + **(**uint64)(__ccgo_up(v4)) = **(**uint64)(__ccgo_up(v5)) + } + d = wd + s = ws + } + for { + v2 = **(**int8)(__ccgo_up(s)) + **(**int8)(__ccgo_up(d)) = v2 + if !(v2 != 0) { + break + } + goto _6 + _6: + ; + s = s + 1 + d = d + 1 + } + return d +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xstpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v, (%v:)", tls, d, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__stpcpy(tls, d, s) +} + +const ALIGN3 = -1 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__stpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var wd, ws uintptr + var v2 int8 + var v3 bool + _, _, _, _ = wd, ws, v2, v3 + if uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) == uint64(d)&(Uint64FromInt64(8)-Uint64FromInt32(1)) { + for { + if v3 = uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 && n != 0; v3 { + v2 = **(**int8)(__ccgo_up(s)) + **(**int8)(__ccgo_up(d)) = v2 + } + if !(v3 && v2 != 0) { + break + } + goto _1 + _1: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + if !(n != 0) || !(**(**int8)(__ccgo_up(s)) != 0) { + goto tail + } + wd = d + ws = s + for { + if !(n >= uint64(8) && !((**(**uint64)(__ccgo_up(ws))-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^**(**uint64)(__ccgo_up(ws)) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + **(**uint64)(__ccgo_up(wd)) = **(**uint64)(__ccgo_up(ws)) + goto _4 + _4: + ; + n = n - uint64(8) + ws += 8 + wd += 8 + } + d = wd + s = ws + } + for { + if v3 = n != 0; v3 { + v2 = **(**int8)(__ccgo_up(s)) + **(**int8)(__ccgo_up(d)) = v2 + } + if !(v3 && v2 != 0) { + break + } + goto _5 + _5: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + goto tail +tail: + ; + Xmemset(tls, d, 0, n) + return d +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xstpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__stpncpy(tls, d, s, n) +} + +func Xstrcasecmp(tls *TLS, _l uintptr, _r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v _l=%v _r=%v, (%v:)", tls, _l, _r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var l, r uintptr + _, _ = l, r + l = _l + r = _r + for { + if !(**(**uint8)(__ccgo_up(l)) != 0 && **(**uint8)(__ccgo_up(r)) != 0 && (Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r))) || Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(l)))) == Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(r)))))) { + break + } + goto _1 + _1: + ; + l = l + 1 + r = r + 1 + } + return Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(l)))) - Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(r)))) +} + +func X__strcasecmp_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v loc=%v, (%v:)", tls, l, r, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xstrcasecmp(tls, l, r) +} + +func Xstrcasecmp_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v loc=%v, (%v:)", tls, l, r, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__strcasecmp_l(tls, l, r, loc) +} + +func Xstrcasestr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v h=%v n=%v, (%v:)", tls, h, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = _strlen(tls, n) + for { + if !(**(**int8)(__ccgo_up(h)) != 0) { + break + } + if !(Xstrncasecmp(tls, h, n, l) != 0) { + return h + } + goto _1 + _1: + ; + h = h + 1 + } + return uintptr(0) +} + +func Xstrcat(tls *TLS, dest uintptr, src uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v, (%v:)", tls, dest, src, origin(2)) + defer func() { trc("-> %v", r) }() + } + Xstrcpy(tls, dest+uintptr(_strlen(tls, dest)), src) + return dest +} + +func Xstrchr(tls *TLS, s uintptr, c int32) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v1 uintptr + _, _ = r, v1 + r = X__strchrnul(tls, s, c) + if Int32FromUint8(**(**uint8)(__ccgo_up(r))) == Int32FromUint8(Uint8FromInt32(c)) { + v1 = r + } else { + v1 = uintptr(0) + } + return v1 +} + +const ALIGN4 = 0 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__strchrnul(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k Tsize_t + var w uintptr + _, _ = k, w + c = Int32FromUint8(Uint8FromInt32(c)) + if !(c != 0) { + return s + uintptr(_strlen(tls, s)) + } + for { + if !(uint64(s)%Uint64FromInt64(8) != 0) { + break + } + if !(**(**int8)(__ccgo_up(s)) != 0) || Int32FromUint8(**(**uint8)(__ccgo_up(s))) == c { + return s + } + goto _1 + _1: + ; + s = s + 1 + } + k = Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(UCHAR_MAX) * Uint64FromInt32(c) + w = s + for { + if !(!((**(**uint64)(__ccgo_up(w))-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^**(**uint64)(__ccgo_up(w)) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0) && !((**(**uint64)(__ccgo_up(w))^k-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^(**(**uint64)(__ccgo_up(w))^k) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + goto _2 + _2: + ; + w += 8 + } + s = w + for { + if !(**(**int8)(__ccgo_up(s)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != c) { + break + } + goto _3 + _3: + ; + s = s + 1 + } + return s +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xstrchrnul(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strchrnul(tls, s, c) +} + +func Xstrcmp(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + for { + if !(int32(**(**int8)(__ccgo_up(l))) == int32(**(**int8)(__ccgo_up(r))) && **(**int8)(__ccgo_up(l)) != 0) { + break + } + goto _1 + _1: + ; + l = l + 1 + r = r + 1 + } + return Int32FromUint8(**(**uint8)(__ccgo_up(l))) - Int32FromUint8(**(**uint8)(__ccgo_up(r))) +} + +func Xstrcpy(tls *TLS, dest uintptr, src uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v, (%v:)", tls, dest, src, origin(2)) + defer func() { trc("-> %v", r) }() + } + X__stpcpy(tls, dest, src) + return dest +} + +func Xstrcspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var a, v2 uintptr + var v3 bool + var _ /* byteset at bp+0 */ [4]Tsize_t + _, _, _ = a, v2, v3 + a = s + if !(**(**int8)(__ccgo_up(c)) != 0) || !(**(**int8)(__ccgo_up(c + 1)) != 0) { + return Uint64FromInt64(int64(X__strchrnul(tls, s, int32(**(**int8)(__ccgo_up(c))))) - int64(a)) + } + Xmemset(tls, bp, 0, uint64(32)) + for { + if v3 = **(**int8)(__ccgo_up(c)) != 0; v3 { + v2 = bp + uintptr(uint64(**(**uint8)(__ccgo_up(c)))/(Uint64FromInt32(8)*Uint64FromInt64(8)))*8 + *(*Tsize_t)(unsafe.Pointer(v2)) |= Uint64FromInt32(1) << (uint64(**(**uint8)(__ccgo_up(c))) % (Uint64FromInt32(8) * Uint64FromInt64(8))) + } + if !(v3 && *(*Tsize_t)(unsafe.Pointer(v2)) != 0) { + break + } + goto _1 + _1: + ; + c = c + 1 + } + for { + if !(**(**int8)(__ccgo_up(s)) != 0 && !((**(**[4]Tsize_t)(__ccgo_up(bp)))[uint64(**(**uint8)(__ccgo_up(s)))/(Uint64FromInt32(8)*Uint64FromInt64(8))]&(Uint64FromInt32(1)<<(uint64(**(**uint8)(__ccgo_up(s)))%(Uint64FromInt32(8)*Uint64FromInt64(8)))) != 0)) { + break + } + goto _4 + _4: + ; + s = s + 1 + } + return Uint64FromInt64(int64(s) - int64(a)) +} + +func Xstrdup(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d uintptr + var l Tsize_t + _, _ = d, l + l = _strlen(tls, s) + d = Xmalloc(tls, l+uint64(1)) + if !(d != 0) { + return UintptrFromInt32(0) + } + return Xmemcpy(tls, d, s, l+uint64(1)) +} + +func Xstrerror_r(tls *TLS, err int32, buf uintptr, buflen Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v err=%v buf=%v buflen=%v, (%v:)", tls, err, buf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + var msg uintptr + _, _ = l, msg + msg = Xstrerror(tls, err) + l = _strlen(tls, msg) + if l >= buflen { + if buflen != 0 { + Xmemcpy(tls, buf, msg, buflen-uint64(1)) + **(**int8)(__ccgo_up(buf + uintptr(buflen-uint64(1)))) = 0 + } + return int32(ERANGE) + } + Xmemcpy(tls, buf, msg, l+uint64(1)) + return 0 +} + +func X__xpg_strerror_r(tls *TLS, err int32, buf uintptr, buflen Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v err=%v buf=%v buflen=%v, (%v:)", tls, err, buf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrerror_r(tls, err, buf, buflen) +} + +func Xstrlcat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = Xstrnlen(tls, d, n) + if l == n { + return l + _strlen(tls, s) + } + return l + Xstrlcpy(tls, d+uintptr(l), s, n-l) +} + +const ALIGN5 = -1 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xstrlcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d0, wd, ws uintptr + var v1 Tsize_t + var v3 int8 + var v4 bool + _, _, _, _, _, _ = d0, wd, ws, v1, v3, v4 + d0 = d + v1 = n + n = n - 1 + if !(v1 != 0) { + goto finish + } + if uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) == uint64(d)&(Uint64FromInt64(8)-Uint64FromInt32(1)) { + for { + if v4 = uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 && n != 0; v4 { + v3 = **(**int8)(__ccgo_up(s)) + **(**int8)(__ccgo_up(d)) = v3 + } + if !(v4 && v3 != 0) { + break + } + goto _2 + _2: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + if n != 0 && **(**int8)(__ccgo_up(s)) != 0 { + wd = d + ws = s + for { + if !(n >= uint64(8) && !((**(**uint64)(__ccgo_up(ws))-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^**(**uint64)(__ccgo_up(ws)) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + **(**Tsize_t)(__ccgo_up(wd)) = **(**uint64)(__ccgo_up(ws)) + goto _5 + _5: + ; + n = n - uint64(8) + ws += 8 + wd += 8 + } + d = wd + s = ws + } + } + for { + if v4 = n != 0; v4 { + v3 = **(**int8)(__ccgo_up(s)) + **(**int8)(__ccgo_up(d)) = v3 + } + if !(v4 && v3 != 0) { + break + } + goto _6 + _6: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + **(**int8)(__ccgo_up(d)) = 0 + goto finish +finish: + ; + return Uint64FromInt64(int64(d)-int64(d0)) + _strlen(tls, s) + return r +} + +const ALIGN6 = 0 + +func Xstrncasecmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v _l=%v _r=%v n=%v, (%v:)", tls, _l, _r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var l, r uintptr + var v1 Tsize_t + _, _, _ = l, r, v1 + l = _l + r = _r + v1 = n + n = n - 1 + if !(v1 != 0) { + return 0 + } + for { + if !(**(**uint8)(__ccgo_up(l)) != 0 && **(**uint8)(__ccgo_up(r)) != 0 && n != 0 && (Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r))) || Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(l)))) == Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(r)))))) { + break + } + goto _2 + _2: + ; + l = l + 1 + r = r + 1 + n = n - 1 + } + return Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(l)))) - Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(r)))) +} + +func X__strncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v loc=%v, (%v:)", tls, l, r, n, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xstrncasecmp(tls, l, r, n) +} + +func Xstrncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v loc=%v, (%v:)", tls, l, r, n, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__strncasecmp_l(tls, l, r, n, loc) +} + +func Xstrncat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v1, v2 uintptr + _, _, _ = a, v1, v2 + a = d + d = d + uintptr(_strlen(tls, d)) + for n != 0 && **(**int8)(__ccgo_up(s)) != 0 { + n = n - 1 + v1 = d + d = d + 1 + v2 = s + s = s + 1 + **(**int8)(__ccgo_up(v1)) = **(**int8)(__ccgo_up(v2)) + } + v1 = d + d = d + 1 + **(**int8)(__ccgo_up(v1)) = 0 + return a +} + +func Xstrncmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v _l=%v _r=%v n=%v, (%v:)", tls, _l, _r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var l, r uintptr + var v1 Tsize_t + _, _, _ = l, r, v1 + l = _l + r = _r + v1 = n + n = n - 1 + if !(v1 != 0) { + return 0 + } + for { + if !(**(**uint8)(__ccgo_up(l)) != 0 && **(**uint8)(__ccgo_up(r)) != 0 && n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r)))) { + break + } + goto _2 + _2: + ; + l = l + 1 + r = r + 1 + n = n - 1 + } + return Int32FromUint8(**(**uint8)(__ccgo_up(l))) - Int32FromUint8(**(**uint8)(__ccgo_up(r))) +} + +func Xstrncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + X__stpncpy(tls, d, s, n) + return d +} + +func Xstrndup(tls *TLS, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d uintptr + var l Tsize_t + _, _ = d, l + l = Xstrnlen(tls, s, n) + d = Xmalloc(tls, l+uint64(1)) + if !(d != 0) { + return UintptrFromInt32(0) + } + Xmemcpy(tls, d, s, l) + **(**int8)(__ccgo_up(d + uintptr(l))) = 0 + return d +} + +func Xstrnlen(tls *TLS, s uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + var v1 uint64 + _, _ = p, v1 + p = Xmemchr(tls, s, 0, n) + if p != 0 { + v1 = Uint64FromInt64(int64(p) - int64(s)) + } else { + v1 = n + } + return v1 +} + +func Xstrpbrk(tls *TLS, s uintptr, b uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v b=%v, (%v:)", tls, s, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + s = s + uintptr(Xstrcspn(tls, s, b)) + if **(**int8)(__ccgo_up(s)) != 0 { + v1 = s + } else { + v1 = uintptr(0) + } + return v1 +} + +func Xstrrchr(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__memrchr(tls, s, c, _strlen(tls, s)+uint64(1)) +} + +func Xstrsep(tls *TLS, str uintptr, sep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v str=%v sep=%v, (%v:)", tls, str, sep, origin(2)) + defer func() { trc("-> %v", r) }() + } + var end, s, v1 uintptr + _, _, _ = end, s, v1 + s = **(**uintptr)(__ccgo_up(str)) + if !(s != 0) { + return UintptrFromInt32(0) + } + end = s + uintptr(Xstrcspn(tls, s, sep)) + if **(**int8)(__ccgo_up(end)) != 0 { + v1 = end + end = end + 1 + **(**int8)(__ccgo_up(v1)) = 0 + } else { + end = uintptr(0) + } + **(**uintptr)(__ccgo_up(str)) = end + return s +} + +var _strings = [671]int8{'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 's', 'i', 'g', 'n', 'a', 'l', 0, 'H', 'a', 'n', 'g', 'u', 'p', 0, 'I', 'n', 't', 'e', 'r', 'r', 'u', 'p', 't', 0, 'Q', 'u', 'i', 't', 0, 'I', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'i', 'n', 's', 't', 'r', 'u', 'c', 't', 'i', 'o', 'n', 0, 'T', 'r', 'a', 'c', 'e', '/', 'b', 'r', 'e', 'a', 'k', 'p', 'o', 'i', 'n', 't', ' ', 't', 'r', 'a', 'p', 0, 'A', 'b', 'o', 'r', 't', 'e', 'd', 0, 'B', 'u', 's', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'A', 'r', 'i', 't', 'h', 'm', 'e', 't', 'i', 'c', ' ', 'e', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n', 0, 'K', 'i', 'l', 'l', 'e', 'd', 0, 'U', 's', 'e', 'r', ' ', 'd', 'e', 'f', 'i', 'n', 'e', 'd', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' ', '1', 0, 'S', 'e', 'g', 'm', 'e', 'n', 't', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'a', 'u', 'l', 't', 0, 'U', 's', 'e', 'r', ' ', 'd', 'e', 'f', 'i', 'n', 'e', 'd', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' ', '2', 0, 'B', 'r', 'o', 'k', 'e', 'n', ' ', 'p', 'i', 'p', 'e', 0, 'A', 'l', 'a', 'r', 'm', ' ', 'c', 'l', 'o', 'c', 'k', 0, 'T', 'e', 'r', 'm', 'i', 'n', 'a', 't', 'e', 'd', 0, 'S', 't', 'a', 'c', 'k', ' ', 'f', 'a', 'u', 'l', 't', 0, 'C', 'h', 'i', 'l', 'd', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's', ' ', 's', 't', 'a', 't', 'u', 's', 0, 'C', 'o', 'n', 't', 'i', 'n', 'u', 'e', 'd', 0, 'S', 't', 'o', 'p', 'p', 'e', 'd', ' ', '(', 's', 'i', 'g', 'n', 'a', 'l', ')', 0, 'S', 't', 'o', 'p', 'p', 'e', 'd', 0, 'S', 't', 'o', 'p', 'p', 'e', 'd', ' ', '(', 't', 't', 'y', ' ', 'i', 'n', 'p', 'u', 't', ')', 0, 'S', 't', 'o', 'p', 'p', 'e', 'd', ' ', '(', 't', 't', 'y', ' ', 'o', 'u', 't', 'p', 'u', 't', ')', 0, 'U', 'r', 'g', 'e', 'n', 't', ' ', 'I', '/', 'O', ' ', 'c', 'o', 'n', 'd', 'i', 't', 'i', 'o', 'n', 0, 'C', 'P', 'U', ' ', 't', 'i', 'm', 'e', ' ', 'l', 'i', 'm', 'i', 't', ' ', 'e', 'x', 'c', 'e', 'e', 'd', 'e', 'd', 0, 'F', 'i', 'l', 'e', ' ', 's', 'i', 'z', 'e', ' ', 'l', 'i', 'm', 'i', 't', ' ', 'e', 'x', 'c', 'e', 'e', 'd', 'e', 'd', 0, 'V', 'i', 'r', 't', 'u', 'a', 'l', ' ', 't', 'i', 'm', 'e', 'r', ' ', 'e', 'x', 'p', 'i', 'r', 'e', 'd', 0, 'P', 'r', 'o', 'f', 'i', 'l', 'i', 'n', 'g', ' ', 't', 'i', 'm', 'e', 'r', ' ', 'e', 'x', 'p', 'i', 'r', 'e', 'd', 0, 'W', 'i', 'n', 'd', 'o', 'w', ' ', 'c', 'h', 'a', 'n', 'g', 'e', 'd', 0, 'I', '/', 'O', ' ', 'p', 'o', 's', 's', 'i', 'b', 'l', 'e', 0, 'P', 'o', 'w', 'e', 'r', ' ', 'f', 'a', 'i', 'l', 'u', 'r', 'e', 0, 'B', 'a', 'd', ' ', 's', 'y', 's', 't', 'e', 'm', ' ', 'c', 'a', 'l', 'l', 0, 'R', 'T', '3', '2', 0, 'R', 'T', '3', '3', 0, 'R', 'T', '3', '4', 0, 'R', 'T', '3', '5', 0, 'R', 'T', '3', '6', 0, 'R', 'T', '3', '7', 0, 'R', 'T', '3', '8', 0, 'R', 'T', '3', '9', 0, 'R', 'T', '4', '0', 0, 'R', 'T', '4', '1', 0, 'R', 'T', '4', '2', 0, 'R', 'T', '4', '3', 0, 'R', 'T', '4', '4', 0, 'R', 'T', '4', '5', 0, 'R', 'T', '4', '6', 0, 'R', 'T', '4', '7', 0, 'R', 'T', '4', '8', 0, 'R', 'T', '4', '9', 0, 'R', 'T', '5', '0', 0, 'R', 'T', '5', '1', 0, 'R', 'T', '5', '2', 0, 'R', 'T', '5', '3', 0, 'R', 'T', '5', '4', 0, 'R', 'T', '5', '5', 0, 'R', 'T', '5', '6', 0, 'R', 'T', '5', '7', 0, 'R', 'T', '5', '8', 0, 'R', 'T', '5', '9', 0, 'R', 'T', '6', '0', 0, 'R', 'T', '6', '1', 0, 'R', 'T', '6', '2', 0, 'R', 'T', '6', '3', 0, 'R', 'T', '6', '4'} + +func Xstrsignal(tls *TLS, signum int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v signum=%v, (%v:)", tls, signum, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + var v2 int32 + _, _ = s, v2 + s = uintptr(unsafe.Pointer(&_strings)) + signum = signum + if Uint32FromInt32(signum)-uint32(1) >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) { + signum = 0 + } + for { + v2 = signum + signum = signum - 1 + if !(v2 != 0) { + break + } + for { + if !(**(**int8)(__ccgo_up(s)) != 0) { + break + } + goto _3 + _3: + ; + s = s + 1 + } + goto _1 + _1: + ; + s = s + 1 + } + return X__lctrans_cur(tls, s) +} + +func Xstrspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var a, v3 uintptr + var v4 bool + var _ /* byteset at bp+0 */ [4]Tsize_t + _, _, _ = a, v3, v4 + a = s + **(**[4]Tsize_t)(__ccgo_up(bp)) = [4]Tsize_t{} + if !(**(**int8)(__ccgo_up(c)) != 0) { + return uint64(0) + } + if !(**(**int8)(__ccgo_up(c + 1)) != 0) { + for { + if !(int32(**(**int8)(__ccgo_up(s))) == int32(**(**int8)(__ccgo_up(c)))) { + break + } + goto _1 + _1: + ; + s = s + 1 + } + return Uint64FromInt64(int64(s) - int64(a)) + } + for { + if v4 = **(**int8)(__ccgo_up(c)) != 0; v4 { + v3 = bp + uintptr(uint64(**(**uint8)(__ccgo_up(c)))/(Uint64FromInt32(8)*Uint64FromInt64(8)))*8 + *(*Tsize_t)(unsafe.Pointer(v3)) |= Uint64FromInt32(1) << (uint64(**(**uint8)(__ccgo_up(c))) % (Uint64FromInt32(8) * Uint64FromInt64(8))) + } + if !(v4 && *(*Tsize_t)(unsafe.Pointer(v3)) != 0) { + break + } + goto _2 + _2: + ; + c = c + 1 + } + for { + if !(**(**int8)(__ccgo_up(s)) != 0 && (**(**[4]Tsize_t)(__ccgo_up(bp)))[uint64(**(**uint8)(__ccgo_up(s)))/(Uint64FromInt32(8)*Uint64FromInt64(8))]&(Uint64FromInt32(1)<<(uint64(**(**uint8)(__ccgo_up(s)))%(Uint64FromInt32(8)*Uint64FromInt64(8)))) != 0) { + break + } + goto _5 + _5: + ; + s = s + 1 + } + return Uint64FromInt64(int64(s) - int64(a)) +} + +func _twobyte_strstr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + var hw, nw Tuint16_t + var v2 uintptr + _, _, _ = hw, nw, v2 + nw = Uint16FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(n)))< Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + ms = ip + p0 = p + /* And with the opposite comparison */ + ip = Uint64FromInt32(-Int32FromInt32(1)) + jp = uint64(0) + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + for jp+k < l { + if Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(ip+k)))) == Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + if k == p { + jp = jp + p + k = uint64(1) + } else { + k = k + 1 + } + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(ip+k)))) < Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + if ip+uint64(1) > ms+uint64(1) { + ms = ip + } else { + p = p0 + } + /* Periodic needle? */ + if Xmemcmp(tls, n, n+uintptr(p), ms+uint64(1)) != 0 { + mem0 = uint64(0) + if ms > l-ms-uint64(1) { + v8 = ms + } else { + v8 = l - ms - uint64(1) + } + p = v8 + uint64(1) + } else { + mem0 = l - p + } + mem = uint64(0) + /* Initialize incremental end-of-haystack pointer */ + z = h + /* Search loop */ + for { + /* Update incremental end-of-haystack pointer */ + if Uint64FromInt64(int64(z)-int64(h)) < l { + /* Fast estimate for MAX(l,63) */ + grow = l | uint64(63) + z2 = Xmemchr(tls, z, 0, grow) + if z2 != 0 { + z = z2 + if Uint64FromInt64(int64(z)-int64(h)) < l { + return uintptr(0) + } + } else { + z = z + uintptr(grow) + } + } + /* Check last byte first; advance by shift on mismatch */ + if (**(**[4]Tsize_t)(__ccgo_up(bp)))[uint64(**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1)))))/(Uint64FromInt32(8)*Uint64FromInt64(8))]&(Uint64FromInt32(1)<<(uint64(**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1)))))%(Uint64FromInt32(8)*Uint64FromInt64(8)))) != 0 { + k = l - shift[**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1))))] + if k != 0 { + if k < mem { + k = mem + } + h = h + uintptr(k) + mem = uint64(0) + goto _9 + } + } else { + h = h + uintptr(l) + mem = uint64(0) + goto _9 + } + /* Compare right half */ + if ms+uint64(1) > mem { + v8 = ms + uint64(1) + } else { + v8 = mem + } + k = v8 + for { + if !(**(**uint8)(__ccgo_up(n + uintptr(k))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(k)))) == Int32FromUint8(**(**uint8)(__ccgo_up(h + uintptr(k))))) { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if **(**uint8)(__ccgo_up(n + uintptr(k))) != 0 { + h = h + uintptr(k-ms) + mem = uint64(0) + goto _9 + } + /* Compare left half */ + k = ms + uint64(1) + for { + if !(k > mem && Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(k-uint64(1))))) == Int32FromUint8(**(**uint8)(__ccgo_up(h + uintptr(k-uint64(1)))))) { + break + } + goto _12 + _12: + ; + k = k - 1 + } + if k <= mem { + return h + } + h = h + uintptr(p) + mem = mem0 + goto _9 + _9: + } + return r +} + +func Xstrstr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v h=%v n=%v, (%v:)", tls, h, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* Return immediately on empty needle */ + if !(**(**int8)(__ccgo_up(n)) != 0) { + return h + } + /* Use faster algorithms for short needles */ + h = Xstrchr(tls, h, int32(**(**int8)(__ccgo_up(n)))) + if !(h != 0) || !(**(**int8)(__ccgo_up(n + 1)) != 0) { + return h + } + if !(**(**int8)(__ccgo_up(h + 1)) != 0) { + return uintptr(0) + } + if !(**(**int8)(__ccgo_up(n + 2)) != 0) { + return _twobyte_strstr(tls, h, n) + } + if !(**(**int8)(__ccgo_up(h + 2)) != 0) { + return uintptr(0) + } + if !(**(**int8)(__ccgo_up(n + 3)) != 0) { + return _threebyte_strstr(tls, h, n) + } + if !(**(**int8)(__ccgo_up(h + 3)) != 0) { + return uintptr(0) + } + if !(**(**int8)(__ccgo_up(n + 4)) != 0) { + return _fourbyte_strstr(tls, h, n) + } + return _twoway_strstr(tls, h, n) +} + +func Xstrtok(tls *TLS, s uintptr, sep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v sep=%v, (%v:)", tls, s, sep, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + var v2 bool + _, _ = v1, v2 + if v2 = !(s != 0); v2 { + v1 = _p2 + s = v1 + } + if v2 && !(v1 != 0) { + return UintptrFromInt32(0) + } + s = s + uintptr(Xstrspn(tls, s, sep)) + if !(**(**int8)(__ccgo_up(s)) != 0) { + v1 = UintptrFromInt32(0) + _p2 = v1 + return v1 + } + _p2 = s + uintptr(Xstrcspn(tls, s, sep)) + if **(**int8)(__ccgo_up(_p2)) != 0 { + v1 = _p2 + _p2 = _p2 + 1 + **(**int8)(__ccgo_up(v1)) = 0 + } else { + _p2 = uintptr(0) + } + return s +} + +var _p2 uintptr + +func Xstrtok_r(tls *TLS, s uintptr, sep uintptr, p uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v sep=%v p=%v, (%v:)", tls, s, sep, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v3 uintptr + var v2 bool + _, _, _ = v1, v2, v3 + if v2 = !(s != 0); v2 { + v1 = **(**uintptr)(__ccgo_up(p)) + s = v1 + } + if v2 && !(v1 != 0) { + return UintptrFromInt32(0) + } + s = s + uintptr(Xstrspn(tls, s, sep)) + if !(**(**int8)(__ccgo_up(s)) != 0) { + v1 = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(p)) = v1 + return v1 + } + **(**uintptr)(__ccgo_up(p)) = s + uintptr(Xstrcspn(tls, s, sep)) + if **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)))) != 0 { + v3 = p + v1 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + **(**int8)(__ccgo_up(v1)) = 0 + } else { + **(**uintptr)(__ccgo_up(p)) = uintptr(0) + } + return s +} + +func Xstrverscmp(tls *TLS, l0 uintptr, r0 uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l0=%v r0=%v, (%v:)", tls, l0, r0, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var c, z int32 + var dp, i, j, v2 Tsize_t + var l, r uintptr + _, _, _, _, _, _, _, _ = c, dp, i, j, l, r, z, v2 + l = l0 + r = r0 + z = int32(1) + /* Find maximal matching prefix and track its maximal digit + * suffix and whether those digits are all zeros. */ + v2 = Uint64FromInt32(0) + i = v2 + dp = v2 + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(i)))) == Int32FromUint8(**(**uint8)(__ccgo_up(r + uintptr(i))))) { + break + } + c = Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(i)))) + if !(c != 0) { + return 0 + } + if !(BoolInt32(Uint32FromInt32(c)-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + dp = i + uint64(1) + z = Int32FromInt32(1) + } else { + if c != int32('0') { + z = 0 + } + } + goto _1 + _1: + ; + i = i + 1 + } + if Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(dp))))-int32('1')) < uint32(9) && Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(r + uintptr(dp))))-int32('1')) < uint32(9) { + /* If we're looking at non-degenerate digit sequences starting + * with nonzero digits, longest digit string is greater. */ + j = i + for { + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(l + uintptr(j))))-uint32('0') < uint32(10)) != 0) { + break + } + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(r + uintptr(j))))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return int32(1) + } + goto _3 + _3: + ; + j = j + 1 + } + if BoolInt32(uint32(**(**uint8)(__ccgo_up(r + uintptr(j))))-uint32('0') < uint32(10)) != 0 { + return -int32(1) + } + } else { + if z != 0 && dp < i && (BoolInt32(uint32(**(**uint8)(__ccgo_up(l + uintptr(i))))-uint32('0') < uint32(10)) != 0 || BoolInt32(uint32(**(**uint8)(__ccgo_up(r + uintptr(i))))-uint32('0') < uint32(10)) != 0) { + /* Otherwise, if common prefix of digit sequence is + * all zeros, digits order less than non-digits. */ + return Int32FromUint8(Uint8FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(i))))-Int32FromUint8('0'))) - Int32FromUint8(Uint8FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(r + uintptr(i))))-Int32FromUint8('0'))) + } + } + return Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(i)))) - Int32FromUint8(**(**uint8)(__ccgo_up(r + uintptr(i)))) +} + +func Xswab(tls *TLS, _src uintptr, _dest uintptr, n Tssize_t) { + if __ccgo_strace { + trc("tls=%v _src=%v _dest=%v n=%v, (%v:)", tls, _src, _dest, n, origin(2)) + } + var dest, src uintptr + _, _ = dest, src + src = _src + dest = _dest + for { + if !(n > int64(1)) { + break + } + **(**int8)(__ccgo_up(dest)) = **(**int8)(__ccgo_up(src + 1)) + **(**int8)(__ccgo_up(dest + 1)) = **(**int8)(__ccgo_up(src)) + dest = dest + uintptr(2) + src = src + uintptr(2) + goto _1 + _1: + ; + n = n - int64(2) + } +} + +func Xwcpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v, (%v:)", tls, d, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcscpy(tls, d, s) + uintptr(Xwcslen(tls, s))*4 +} + +func Xwcpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcsncpy(tls, d, s, n) + uintptr(Xwcsnlen(tls, s, n))*4 +} + +func Xwcscasecmp(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xwcsncasecmp(tls, l, r, Uint64FromInt32(-Int32FromInt32(1))) +} + +func Xwcscasecmp_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v locale=%v, (%v:)", tls, l, r, locale, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xwcscasecmp(tls, l, r) +} + +func Xwcscat(tls *TLS, dest uintptr, src uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v, (%v:)", tls, dest, src, origin(2)) + defer func() { trc("-> %v", r) }() + } + Xwcscpy(tls, dest+uintptr(Xwcslen(tls, dest))*4, src) + return dest +} + +func Xwcschr(tls *TLS, s uintptr, c Twchar_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v2 uintptr + _ = v2 + if !(c != 0) { + return s + uintptr(Xwcslen(tls, s))*4 + } + for { + if !(**(**Twchar_t)(__ccgo_up(s)) != 0 && **(**Twchar_t)(__ccgo_up(s)) != c) { + break + } + goto _1 + _1: + ; + s += 4 + } + if **(**Twchar_t)(__ccgo_up(s)) != 0 { + v2 = s + } else { + v2 = uintptr(0) + } + return v2 +} + +func Xwcscmp(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var v2 int32 + _ = v2 + for { + if !(**(**Twchar_t)(__ccgo_up(l)) == **(**Twchar_t)(__ccgo_up(r)) && **(**Twchar_t)(__ccgo_up(l)) != 0 && **(**Twchar_t)(__ccgo_up(r)) != 0) { + break + } + goto _1 + _1: + ; + l += 4 + r += 4 + } + if **(**Twchar_t)(__ccgo_up(l)) < **(**Twchar_t)(__ccgo_up(r)) { + v2 = -int32(1) + } else { + v2 = BoolInt32(**(**Twchar_t)(__ccgo_up(l)) > **(**Twchar_t)(__ccgo_up(r))) + } + return v2 +} + +func Xwcscpy(tls *TLS, d uintptr, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v, (%v:)", tls, d, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v2, v3 uintptr + var v1 Twchar_t + _, _, _, _ = a, v1, v2, v3 + a = d + for { + v2 = s + s += 4 + v1 = **(**Twchar_t)(__ccgo_up(v2)) + v3 = d + d += 4 + **(**Twchar_t)(__ccgo_up(v3)) = v1 + if !(v1 != 0) { + break + } + } + return a +} + +func Xwcscspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v2, v3 uintptr + var v1 uint64 + _, _, _, _ = a, v1, v2, v3 + if !(**(**Twchar_t)(__ccgo_up(c)) != 0) { + return Xwcslen(tls, s) + } + if !(**(**Twchar_t)(__ccgo_up(c + 1*4)) != 0) { + v3 = s + a = v3 + v2 = Xwcschr(tls, v3, **(**Twchar_t)(__ccgo_up(c))) + s = v2 + if v2 != 0 { + v1 = Uint64FromInt64((int64(s) - int64(a)) / 4) + } else { + v1 = Xwcslen(tls, a) + } + return v1 + } + a = s + for { + if !(**(**Twchar_t)(__ccgo_up(s)) != 0 && !(Xwcschr(tls, c, **(**Twchar_t)(__ccgo_up(s))) != 0)) { + break + } + goto _4 + _4: + ; + s += 4 + } + return Uint64FromInt64((int64(s) - int64(a)) / 4) +} + +func Xwcsdup(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d uintptr + var l Tsize_t + _, _ = d, l + l = Xwcslen(tls, s) + d = Xmalloc(tls, (l+uint64(1))*uint64(4)) + if !(d != 0) { + return UintptrFromInt32(0) + } + return Xwmemcpy(tls, d, s, l+uint64(1)) +} + +func Xwcslen(tls *TLS, s uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a uintptr + _ = a + a = s + for { + if !(**(**Twchar_t)(__ccgo_up(s)) != 0) { + break + } + goto _1 + _1: + ; + s += 4 + } + return Uint64FromInt64((int64(s) - int64(a)) / 4) +} + +func Xwcsncasecmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v, (%v:)", tls, l, r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var v1 Tsize_t + _ = v1 + v1 = n + n = n - 1 + if !(v1 != 0) { + return 0 + } + for { + if !(**(**Twchar_t)(__ccgo_up(l)) != 0 && **(**Twchar_t)(__ccgo_up(r)) != 0 && n != 0 && (**(**Twchar_t)(__ccgo_up(l)) == **(**Twchar_t)(__ccgo_up(r)) || Xtowlower(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(l)))) == Xtowlower(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(r)))))) { + break + } + goto _2 + _2: + ; + l += 4 + r += 4 + n = n - 1 + } + return Int32FromUint32(Xtowlower(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(l)))) - Xtowlower(tls, Uint32FromInt32(**(**Twchar_t)(__ccgo_up(r))))) +} + +func Xwcsncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, locale Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v locale=%v, (%v:)", tls, l, r, n, locale, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xwcsncasecmp(tls, l, r, n) +} + +func Xwcsncat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v1, v2 uintptr + _, _, _ = a, v1, v2 + a = d + d = d + uintptr(Xwcslen(tls, d))*4 + for n != 0 && **(**Twchar_t)(__ccgo_up(s)) != 0 { + n = n - 1 + v1 = d + d += 4 + v2 = s + s += 4 + **(**Twchar_t)(__ccgo_up(v1)) = **(**Twchar_t)(__ccgo_up(v2)) + } + v1 = d + d += 4 + **(**Twchar_t)(__ccgo_up(v1)) = 0 + return a +} + +func Xwcsncmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v, (%v:)", tls, l, r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var v2, v3 int32 + _, _ = v2, v3 + for { + if !(n != 0 && **(**Twchar_t)(__ccgo_up(l)) == **(**Twchar_t)(__ccgo_up(r)) && **(**Twchar_t)(__ccgo_up(l)) != 0 && **(**Twchar_t)(__ccgo_up(r)) != 0) { + break + } + goto _1 + _1: + ; + n = n - 1 + l += 4 + r += 4 + } + if n != 0 { + if **(**Twchar_t)(__ccgo_up(l)) < **(**Twchar_t)(__ccgo_up(r)) { + v3 = -int32(1) + } else { + v3 = BoolInt32(**(**Twchar_t)(__ccgo_up(l)) > **(**Twchar_t)(__ccgo_up(r))) + } + v2 = v3 + } else { + v2 = 0 + } + return v2 +} + +func Xwcsncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v1, v2 uintptr + _, _, _ = a, v1, v2 + a = d + for n != 0 && **(**Twchar_t)(__ccgo_up(s)) != 0 { + n = n - 1 + v1 = d + d += 4 + v2 = s + s += 4 + **(**Twchar_t)(__ccgo_up(v1)) = **(**Twchar_t)(__ccgo_up(v2)) + } + Xwmemset(tls, d, 0, n) + return a +} + +func Xwcsnlen(tls *TLS, s uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var z uintptr + _ = z + z = Xwmemchr(tls, s, 0, n) + if z != 0 { + n = Uint64FromInt64((int64(z) - int64(s)) / 4) + } + return n +} + +func Xwcspbrk(tls *TLS, s uintptr, b uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v b=%v, (%v:)", tls, s, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + s = s + uintptr(Xwcscspn(tls, s, b))*4 + if **(**Twchar_t)(__ccgo_up(s)) != 0 { + v1 = s + } else { + v1 = UintptrFromInt32(0) + } + return v1 +} + +func Xwcsrchr(tls *TLS, s uintptr, c Twchar_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p, v2 uintptr + _, _ = p, v2 + p = s + uintptr(Xwcslen(tls, s))*4 + for { + if !(p >= s && **(**Twchar_t)(__ccgo_up(p)) != c) { + break + } + goto _1 + _1: + ; + p -= 4 + } + if p >= s { + v2 = p + } else { + v2 = uintptr(0) + } + return v2 +} + +func Xwcsspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a uintptr + _ = a + a = s + for { + if !(**(**Twchar_t)(__ccgo_up(s)) != 0 && Xwcschr(tls, c, **(**Twchar_t)(__ccgo_up(s))) != 0) { + break + } + goto _1 + _1: + ; + s += 4 + } + return Uint64FromInt64((int64(s) - int64(a)) / 4) +} + +func _twoway_wcsstr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + var grow, ip, jp, k, l, mem, mem0, ms, p, p0, v2 Tsize_t + var z, z2 uintptr + var v8 uint64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = grow, ip, jp, k, l, mem, mem0, ms, p, p0, z, z2, v2, v8 + /* Computing length of needle */ + l = uint64(0) + for { + if !(**(**Twchar_t)(__ccgo_up(n + uintptr(l)*4)) != 0 && **(**Twchar_t)(__ccgo_up(h + uintptr(l)*4)) != 0) { + break + } + goto _1 + _1: + ; + l = l + 1 + } + if **(**Twchar_t)(__ccgo_up(n + uintptr(l)*4)) != 0 { + return uintptr(0) + } /* hit the end of h */ + /* Compute maximal suffix */ + ip = Uint64FromInt32(-Int32FromInt32(1)) + jp = uint64(0) + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + for jp+k < l { + if **(**Twchar_t)(__ccgo_up(n + uintptr(ip+k)*4)) == **(**Twchar_t)(__ccgo_up(n + uintptr(jp+k)*4)) { + if k == p { + jp = jp + p + k = uint64(1) + } else { + k = k + 1 + } + } else { + if **(**Twchar_t)(__ccgo_up(n + uintptr(ip+k)*4)) > **(**Twchar_t)(__ccgo_up(n + uintptr(jp+k)*4)) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + ms = ip + p0 = p + /* And with the opposite comparison */ + ip = Uint64FromInt32(-Int32FromInt32(1)) + jp = uint64(0) + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + for jp+k < l { + if **(**Twchar_t)(__ccgo_up(n + uintptr(ip+k)*4)) == **(**Twchar_t)(__ccgo_up(n + uintptr(jp+k)*4)) { + if k == p { + jp = jp + p + k = uint64(1) + } else { + k = k + 1 + } + } else { + if **(**Twchar_t)(__ccgo_up(n + uintptr(ip+k)*4)) < **(**Twchar_t)(__ccgo_up(n + uintptr(jp+k)*4)) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + if ip+uint64(1) > ms+uint64(1) { + ms = ip + } else { + p = p0 + } + /* Periodic needle? */ + if Xwmemcmp(tls, n, n+uintptr(p)*4, ms+uint64(1)) != 0 { + mem0 = uint64(0) + if ms > l-ms-uint64(1) { + v8 = ms + } else { + v8 = l - ms - uint64(1) + } + p = v8 + uint64(1) + } else { + mem0 = l - p + } + mem = uint64(0) + /* Initialize incremental end-of-haystack pointer */ + z = h + /* Search loop */ + for { + /* Update incremental end-of-haystack pointer */ + if Uint64FromInt64((int64(z)-int64(h))/4) < l { + /* Fast estimate for MIN(l,63) */ + grow = l | uint64(63) + z2 = Xwmemchr(tls, z, 0, grow) + if z2 != 0 { + z = z2 + if Uint64FromInt64((int64(z)-int64(h))/4) < l { + return uintptr(0) + } + } else { + z = z + uintptr(grow)*4 + } + } + /* Compare right half */ + if ms+uint64(1) > mem { + v8 = ms + uint64(1) + } else { + v8 = mem + } + k = v8 + for { + if !(**(**Twchar_t)(__ccgo_up(n + uintptr(k)*4)) != 0 && **(**Twchar_t)(__ccgo_up(n + uintptr(k)*4)) == **(**Twchar_t)(__ccgo_up(h + uintptr(k)*4))) { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if **(**Twchar_t)(__ccgo_up(n + uintptr(k)*4)) != 0 { + h = h + uintptr(k-ms)*4 + mem = uint64(0) + goto _9 + } + /* Compare left half */ + k = ms + uint64(1) + for { + if !(k > mem && **(**Twchar_t)(__ccgo_up(n + uintptr(k-uint64(1))*4)) == **(**Twchar_t)(__ccgo_up(h + uintptr(k-uint64(1))*4))) { + break + } + goto _12 + _12: + ; + k = k - 1 + } + if k <= mem { + return h + } + h = h + uintptr(p)*4 + mem = mem0 + goto _9 + _9: + } + return r +} + +func Xwcsstr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v h=%v n=%v, (%v:)", tls, h, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* Return immediately on empty needle or haystack */ + if !(**(**Twchar_t)(__ccgo_up(n)) != 0) { + return h + } + if !(**(**Twchar_t)(__ccgo_up(h)) != 0) { + return uintptr(0) + } + /* Use faster algorithms for short needles */ + h = Xwcschr(tls, h, **(**Twchar_t)(__ccgo_up(n))) + if !(h != 0) || !(**(**Twchar_t)(__ccgo_up(n + 1*4)) != 0) { + return h + } + if !(**(**Twchar_t)(__ccgo_up(h + 1*4)) != 0) { + return uintptr(0) + } + return _twoway_wcsstr(tls, h, n) +} + +func Xwcstok(tls *TLS, s uintptr, sep uintptr, p uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v sep=%v p=%v, (%v:)", tls, s, sep, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v3 uintptr + var v2 bool + _, _, _ = v1, v2, v3 + if v2 = !(s != 0); v2 { + v1 = **(**uintptr)(__ccgo_up(p)) + s = v1 + } + if v2 && !(v1 != 0) { + return UintptrFromInt32(0) + } + s = s + uintptr(Xwcsspn(tls, s, sep))*4 + if !(**(**Twchar_t)(__ccgo_up(s)) != 0) { + v1 = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(p)) = v1 + return v1 + } + **(**uintptr)(__ccgo_up(p)) = s + uintptr(Xwcscspn(tls, s, sep))*4 + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(p)))) != 0 { + v3 = p + v1 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) += 4 + **(**Twchar_t)(__ccgo_up(v1)) = 0 + } else { + **(**uintptr)(__ccgo_up(p)) = uintptr(0) + } + return s +} + +func Xwcswcs(tls *TLS, haystack uintptr, needle uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v haystack=%v needle=%v, (%v:)", tls, haystack, needle, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcsstr(tls, haystack, needle) +} + +func Xwmemchr(tls *TLS, s uintptr, c Twchar_t, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v n=%v, (%v:)", tls, s, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v2 uintptr + _ = v2 + for { + if !(n != 0 && **(**Twchar_t)(__ccgo_up(s)) != c) { + break + } + goto _1 + _1: + ; + n = n - 1 + s += 4 + } + if n != 0 { + v2 = s + } else { + v2 = uintptr(0) + } + return v2 +} + +func Xwmemcmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v, (%v:)", tls, l, r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var v2, v3 int32 + _, _ = v2, v3 + for { + if !(n != 0 && **(**Twchar_t)(__ccgo_up(l)) == **(**Twchar_t)(__ccgo_up(r))) { + break + } + goto _1 + _1: + ; + n = n - 1 + l += 4 + r += 4 + } + if n != 0 { + if **(**Twchar_t)(__ccgo_up(l)) < **(**Twchar_t)(__ccgo_up(r)) { + v3 = -int32(1) + } else { + v3 = BoolInt32(**(**Twchar_t)(__ccgo_up(l)) > **(**Twchar_t)(__ccgo_up(r))) + } + v2 = v3 + } else { + v2 = 0 + } + return v2 +} + +func Xwmemcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v2, v3 uintptr + var v1 Tsize_t + _, _, _, _ = a, v1, v2, v3 + a = d + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + v2 = d + d += 4 + v3 = s + s += 4 + **(**Twchar_t)(__ccgo_up(v2)) = **(**Twchar_t)(__ccgo_up(v3)) + } + return a +} + +func Xwmemmove(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d0, v3, v4 uintptr + var v1 Tsize_t + _, _, _, _ = d0, v1, v3, v4 + d0 = d + if d == s { + return d + } + if uint64(d)-uint64(s) < n*uint64(4) { + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + **(**Twchar_t)(__ccgo_up(d + uintptr(n)*4)) = **(**Twchar_t)(__ccgo_up(s + uintptr(n)*4)) + } + } else { + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + v3 = d + d += 4 + v4 = s + s += 4 + **(**Twchar_t)(__ccgo_up(v3)) = **(**Twchar_t)(__ccgo_up(v4)) + } + } + return d0 +} + +func Xwmemset(tls *TLS, d uintptr, c Twchar_t, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v c=%v n=%v, (%v:)", tls, d, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret, v2 uintptr + var v1 Tsize_t + _, _, _ = ret, v1, v2 + ret = d + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + v2 = d + d += 4 + **(**Twchar_t)(__ccgo_up(v2)) = c + } + return ret +} + +func Xmkdtemp(tls *TLS, template uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v template=%v, (%v:)", tls, template, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + var retries, v1 int32 + _, _, _ = l, retries, v1 + l = _strlen(tls, template) + retries = int32(100) + if l < uint64(6) || Xmemcmp(tls, template+uintptr(l)-uintptr(6), __ccgo_ts+1747, uint64(6)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + for { + ___randname(tls, template+uintptr(l)-uintptr(6)) + if !(Xmkdir(tls, template, uint32(0700)) != 0) { + return template + } + goto _2 + _2: + ; + retries = retries - 1 + v1 = retries + if !(v1 != 0 && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EEXIST)) { + break + } + } + Xmemcpy(tls, template+uintptr(l)-uintptr(6), __ccgo_ts+1747, uint64(6)) + return uintptr(0) +} + +func Xmkostemp(tls *TLS, template uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v flags=%v, (%v:)", tls, template, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mkostemps(tls, template, 0, flags) +} + +func X__mkostemps(tls *TLS, template uintptr, len1 int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v len1=%v flags=%v, (%v:)", tls, template, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var fd, retries, v1 int32 + var l Tsize_t + _, _, _, _ = fd, l, retries, v1 + l = _strlen(tls, template) + if l < uint64(6) || Uint64FromInt32(len1) > l-uint64(6) || Xmemcmp(tls, template+uintptr(l)-uintptr(len1)-uintptr(6), __ccgo_ts+1747, uint64(6)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + flags = flags - flags&(Int32FromInt32(03)|Int32FromInt32(O_PATH)) + retries = int32(100) + for { + ___randname(tls, template+uintptr(l)-uintptr(len1)-uintptr(6)) + v1 = Xopen(tls, template, flags|int32(O_RDWR)|int32(O_CREAT)|int32(O_EXCL), VaList(bp+8, int32(0600))) + fd = v1 + if v1 >= 0 { + return fd + } + goto _2 + _2: + ; + retries = retries - 1 + v1 = retries + if !(v1 != 0 && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EEXIST)) { + break + } + } + Xmemcpy(tls, template+uintptr(l)-uintptr(len1)-uintptr(6), __ccgo_ts+1747, uint64(6)) + return -int32(1) +} + +func Xmkostemps(tls *TLS, template uintptr, len1 int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v len1=%v flags=%v, (%v:)", tls, template, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mkostemps(tls, template, len1, flags) +} + +func Xmkstemp(tls *TLS, template uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v, (%v:)", tls, template, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mkostemps(tls, template, 0, 0) +} + +func Xmkstemps(tls *TLS, template uintptr, len1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v len1=%v, (%v:)", tls, template, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mkostemps(tls, template, len1, 0) +} + +func Xmktemp(tls *TLS, template uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v template=%v, (%v:)", tls, template, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var l Tsize_t + var retries, v1 int32 + var _ /* st at bp+0 */ Tstat + _, _, _ = l, retries, v1 + l = _strlen(tls, template) + retries = int32(100) + if l < uint64(6) || Xmemcmp(tls, template+uintptr(l)-uintptr(6), __ccgo_ts+1747, uint64(6)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + **(**int8)(__ccgo_up(template)) = 0 + return template + } + for { + ___randname(tls, template+uintptr(l)-uintptr(6)) + if Xstat(tls, template, bp) != 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(ENOENT) { + **(**int8)(__ccgo_up(template)) = 0 + } + return template + } + goto _2 + _2: + ; + retries = retries - 1 + v1 = retries + if !(v1 != 0) { + break + } + } + **(**int8)(__ccgo_up(template)) = 0 + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EEXIST) + return template +} + +func Xcfgetospeed(tls *TLS, tio uintptr) (r Tspeed_t) { + if __ccgo_strace { + trc("tls=%v tio=%v, (%v:)", tls, tio, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*Ttermios)(unsafe.Pointer(tio)).Fc_cflag & uint32(CBAUD) +} + +func Xcfgetispeed(tls *TLS, tio uintptr) (r Tspeed_t) { + if __ccgo_strace { + trc("tls=%v tio=%v, (%v:)", tls, tio, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcfgetospeed(tls, tio) +} + +func Xcfmakeraw(tls *TLS, t uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + } + **(**Ttcflag_t)(__ccgo_up(t)) &= Uint32FromInt32(^(Int32FromInt32(IGNBRK) | Int32FromInt32(BRKINT) | Int32FromInt32(PARMRK) | Int32FromInt32(ISTRIP) | Int32FromInt32(INLCR) | Int32FromInt32(IGNCR) | Int32FromInt32(ICRNL) | Int32FromInt32(IXON))) + **(**Ttcflag_t)(__ccgo_up(t + 4)) &= Uint32FromInt32(^Int32FromInt32(OPOST)) + **(**Ttcflag_t)(__ccgo_up(t + 12)) &= Uint32FromInt32(^(Int32FromInt32(ECHO) | Int32FromInt32(ECHONL) | Int32FromInt32(ICANON) | Int32FromInt32(ISIG) | Int32FromInt32(IEXTEN))) + **(**Ttcflag_t)(__ccgo_up(t + 8)) &= Uint32FromInt32(^(Int32FromInt32(CSIZE) | Int32FromInt32(PARENB))) + **(**Ttcflag_t)(__ccgo_up(t + 8)) |= uint32(CS8) + **(**Tcc_t)(__ccgo_up(t + 17 + 6)) = uint8(1) + **(**Tcc_t)(__ccgo_up(t + 17 + 5)) = uint8(0) +} + +func Xcfsetospeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) { + if __ccgo_strace { + trc("tls=%v tio=%v speed=%v, (%v:)", tls, tio, speed, origin(2)) + defer func() { trc("-> %v", r) }() + } + if speed&Uint32FromInt32(^Int32FromInt32(CBAUD)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + **(**Ttcflag_t)(__ccgo_up(tio + 8)) &= Uint32FromInt32(^Int32FromInt32(CBAUD)) + **(**Ttcflag_t)(__ccgo_up(tio + 8)) |= speed + return 0 +} + +func Xcfsetispeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) { + if __ccgo_strace { + trc("tls=%v tio=%v speed=%v, (%v:)", tls, tio, speed, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if speed != 0 { + v1 = Xcfsetospeed(tls, tio, speed) + } else { + v1 = 0 + } + return v1 +} + +func Xcfsetspeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) { + if __ccgo_strace { + trc("tls=%v tio=%v speed=%v, (%v:)", tls, tio, speed, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcfsetospeed(tls, tio, speed) +} + +func Xtcdrain(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TCSBRK)), int64(Int32FromInt32(1)), 0, 0, 0)))) +} + +func Xtcflow(tls *TLS, fd int32, action int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v action=%v, (%v:)", tls, fd, action, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + return Xioctl(tls, fd, int32(TCXONC), VaList(bp+8, action)) +} + +func Xtcflush(tls *TLS, fd int32, queue int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v queue=%v, (%v:)", tls, fd, queue, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + return Xioctl(tls, fd, int32(TCFLSH), VaList(bp+8, queue)) +} + +func Xtcgetattr(tls *TLS, fd int32, tio uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v tio=%v, (%v:)", tls, fd, tio, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + if Xioctl(tls, fd, int32(TCGETS), VaList(bp+8, tio)) != 0 { + return -int32(1) + } + return 0 +} + +func Xtcgetsid(tls *TLS, fd int32) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* sid at bp+0 */ int32 + if Xioctl(tls, fd, int32(TIOCGSID), VaList(bp+16, bp)) < 0 { + return -int32(1) + } + return **(**int32)(__ccgo_up(bp)) +} + +func Xtcgetwinsize(tls *TLS, fd int32, wsz uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v wsz=%v, (%v:)", tls, fd, wsz, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TIOCGWINSZ)), int64(wsz))))) +} + +func Xtcsendbreak(tls *TLS, fd int32, dur int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v dur=%v, (%v:)", tls, fd, dur, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + /* nonzero duration is implementation-defined, so ignore it */ + return Xioctl(tls, fd, int32(TCSBRK), VaList(bp+8, 0)) +} + +func Xtcsetattr(tls *TLS, fd int32, act int32, tio uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v act=%v tio=%v, (%v:)", tls, fd, act, tio, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + if act < 0 || act > int32(2) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + return Xioctl(tls, fd, int32(TCSETS)+act, VaList(bp+8, tio)) +} + +func Xtcsetwinsize(tls *TLS, fd int32, wsz uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v wsz=%v, (%v:)", tls, fd, wsz, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TIOCSWINSZ)), int64(wsz))))) +} + +func X__map_file(tls *TLS, pathname uintptr, size uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v pathname=%v size=%v, (%v:)", tls, pathname, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var fd int32 + var map1, v1 uintptr + var _ /* st at bp+0 */ Tstat + _, _, _ = fd, map1, v1 + map1 = uintptr(-Int32FromInt32(1)) + fd = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_open), int64(pathname), int64(Int32FromInt32(O_RDONLY)|Int32FromInt32(O_CLOEXEC)|Int32FromInt32(O_NONBLOCK)|Int32FromInt32(O_LARGEFILE)))))) + if fd < 0 { + return uintptr(0) + } + if !(X__fstat(tls, fd, bp) != 0) { + map1 = X__mmap(tls, uintptr(0), Uint64FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_size), int32(PROT_READ), int32(MAP_SHARED), fd, 0) + **(**Tsize_t)(__ccgo_up(size)) = Uint64FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_size) + } + X__syscall1(tls, int64(SYS_close), int64(fd)) + if map1 == uintptr(-Int32FromInt32(1)) { + v1 = uintptr(0) + } else { + v1 = map1 + } + return v1 +} + +func X__month_to_secs(tls *TLS, month int32, is_leap int32) (r int32) { + if __ccgo_strace { + trc("tls=%v month=%v is_leap=%v, (%v:)", tls, month, is_leap, origin(2)) + defer func() { trc("-> %v", r) }() + } + var t int32 + _ = t + t = _secs_through_month[month] + if is_leap != 0 && month >= int32(2) { + t = t + int32(86400) + } + return t +} + +var _secs_through_month = [12]int32{ + 1: Int32FromInt32(31) * Int32FromInt32(86400), + 2: Int32FromInt32(59) * Int32FromInt32(86400), + 3: Int32FromInt32(90) * Int32FromInt32(86400), + 4: Int32FromInt32(120) * Int32FromInt32(86400), + 5: Int32FromInt32(151) * Int32FromInt32(86400), + 6: Int32FromInt32(181) * Int32FromInt32(86400), + 7: Int32FromInt32(212) * Int32FromInt32(86400), + 8: Int32FromInt32(243) * Int32FromInt32(86400), + 9: Int32FromInt32(273) * Int32FromInt32(86400), + 10: Int32FromInt32(304) * Int32FromInt32(86400), + 11: Int32FromInt32(334) * Int32FromInt32(86400), +} + +const DAYS_PER_100Y = 36524 +const DAYS_PER_400Y = 146097 +const DAYS_PER_4Y = 1461 +const LEAPOCH = 951868800 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +/* 2000-03-01 (mod 400 year, immediately after feb29 */ + +func X__secs_to_tm(tls *TLS, t int64, tm uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c_cycles, leap, months, q_cycles, qc_cycles, remdays, remsecs, remyears, wday, yday int32 + var days, secs, years int64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = c_cycles, days, leap, months, q_cycles, qc_cycles, remdays, remsecs, remyears, secs, wday, yday, years + /* Reject time_t values whose year would overflow int */ + if t < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff))*Int64FromInt64(31622400) || t > Int64FromInt32(INT_MAX)*Int64FromInt64(31622400) { + return -int32(1) + } + secs = t - (Int64FromInt64(946684800) + int64(Int32FromInt32(86400)*(Int32FromInt32(31)+Int32FromInt32(29)))) + days = secs / int64(86400) + remsecs = int32(secs % int64(86400)) + if remsecs < 0 { + remsecs = remsecs + int32(86400) + days = days - 1 + } + wday = int32((int64(3) + days) % int64(7)) + if wday < 0 { + wday = wday + int32(7) + } + qc_cycles = int32(days / int64(Int32FromInt32(365)*Int32FromInt32(400)+Int32FromInt32(97))) + remdays = int32(days % int64(Int32FromInt32(365)*Int32FromInt32(400)+Int32FromInt32(97))) + if remdays < 0 { + remdays = remdays + (Int32FromInt32(365)*Int32FromInt32(400) + Int32FromInt32(97)) + qc_cycles = qc_cycles - 1 + } + c_cycles = remdays / (Int32FromInt32(365)*Int32FromInt32(100) + Int32FromInt32(24)) + if c_cycles == int32(4) { + c_cycles = c_cycles - 1 + } + remdays = remdays - c_cycles*(Int32FromInt32(365)*Int32FromInt32(100)+Int32FromInt32(24)) + q_cycles = remdays / (Int32FromInt32(365)*Int32FromInt32(4) + Int32FromInt32(1)) + if q_cycles == int32(25) { + q_cycles = q_cycles - 1 + } + remdays = remdays - q_cycles*(Int32FromInt32(365)*Int32FromInt32(4)+Int32FromInt32(1)) + remyears = remdays / int32(365) + if remyears == int32(4) { + remyears = remyears - 1 + } + remdays = remdays - remyears*int32(365) + leap = BoolInt32(!(remyears != 0) && (q_cycles != 0 || !(c_cycles != 0))) + yday = remdays + int32(31) + int32(28) + leap + if yday >= int32(365)+leap { + yday = yday - (int32(365) + leap) + } + years = int64(remyears+int32(4)*q_cycles+int32(100)*c_cycles) + int64(400)*int64(qc_cycles) + months = 0 + for { + if !(int32(_days_in_month[months]) <= remdays) { + break + } + remdays = remdays - int32(_days_in_month[months]) + goto _1 + _1: + ; + months = months + 1 + } + if months >= int32(10) { + months = months - int32(12) + years = years + 1 + } + if years+int64(100) > int64(INT_MAX) || years+int64(100) < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff)) { + return -int32(1) + } + (*Ttm)(unsafe.Pointer(tm)).Ftm_year = int32(years + int64(100)) + (*Ttm)(unsafe.Pointer(tm)).Ftm_mon = months + int32(2) + (*Ttm)(unsafe.Pointer(tm)).Ftm_mday = remdays + int32(1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_wday = wday + (*Ttm)(unsafe.Pointer(tm)).Ftm_yday = yday + (*Ttm)(unsafe.Pointer(tm)).Ftm_hour = remsecs / int32(3600) + (*Ttm)(unsafe.Pointer(tm)).Ftm_min = remsecs / int32(60) % int32(60) + (*Ttm)(unsafe.Pointer(tm)).Ftm_sec = remsecs % int32(60) + return 0 +} + +var _days_in_month = [12]int8{ + 0: int8(31), + 1: int8(30), + 2: int8(31), + 3: int8(30), + 4: int8(31), + 5: int8(31), + 6: int8(30), + 7: int8(31), + 8: int8(30), + 9: int8(31), + 10: int8(31), + 11: int8(29), +} + +func X__tm_to_secs(tls *TLS, tm uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var adj, month int32 + var t, year int64 + var _ /* is_leap at bp+0 */ int32 + _, _, _, _ = adj, month, t, year + year = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year) + month = (*Ttm)(unsafe.Pointer(tm)).Ftm_mon + if month >= int32(12) || month < 0 { + adj = month / int32(12) + month = month % int32(12) + if month < 0 { + adj = adj - 1 + month = month + int32(12) + } + year = year + int64(adj) + } + t = X__year_to_secs(tls, year, bp) + t = t + int64(X__month_to_secs(tls, month, **(**int32)(__ccgo_up(bp)))) + t = t + int64(86400)*int64((*Ttm)(unsafe.Pointer(tm)).Ftm_mday-Int32FromInt32(1)) + t = t + int64(3600)*int64((*Ttm)(unsafe.Pointer(tm)).Ftm_hour) + t = t + int64(60)*int64((*Ttm)(unsafe.Pointer(tm)).Ftm_min) + t = t + int64((*Ttm)(unsafe.Pointer(tm)).Ftm_sec) + return t +} + +var _std_name [7]int8 +var _dst_name [7]int8 + +var _dst_off int32 +var _r0 [5]int32 +var _r12 [5]int32 + +var _zi uintptr +var _trans uintptr +var _index uintptr +var _types uintptr +var _abbrevs uintptr +var _abbrevs_end uintptr +var _map_size Tsize_t + +var _old_tz_buf [32]int8 +var _old_tz = uintptr(unsafe.Pointer(&_old_tz_buf)) +var _old_tz_size = uint64(32) + +var _lock4 [1]int32 + +func _getint2(tls *TLS, p uintptr) (r int32) { + var x uint32 + _ = x + x = uint32(0) + for { + if !(Uint32FromInt32(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)))))-int32('0')) < uint32(10)) { + break + } + x = Uint32FromInt32(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)))))-int32('0')) + uint32(10)*x + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + } + return Int32FromUint32(x) +} + +func _getoff(tls *TLS, p uintptr) (r int32) { + var neg, off, v1 int32 + _, _, _ = neg, off, v1 + neg = 0 + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32('-') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + neg = int32(1) + } else { + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32('+') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + } + } + off = int32(3600) * _getint2(tls, p) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32(':') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + off = off + int32(60)*_getint2(tls, p) + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32(':') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + off = off + _getint2(tls, p) + } + } + if neg != 0 { + v1 = -off + } else { + v1 = off + } + return v1 +} + +func _getrule(tls *TLS, p uintptr, rule uintptr) { + var r, v1 int32 + _, _ = r, v1 + v1 = int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) + **(**int32)(__ccgo_up(rule)) = v1 + r = v1 + if r != int32('M') { + if r == int32('J') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + } else { + **(**int32)(__ccgo_up(rule)) = 0 + } + **(**int32)(__ccgo_up(rule + 1*4)) = _getint2(tls, p) + } else { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + **(**int32)(__ccgo_up(rule + 1*4)) = _getint2(tls, p) + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + **(**int32)(__ccgo_up(rule + 2*4)) = _getint2(tls, p) + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + **(**int32)(__ccgo_up(rule + 3*4)) = _getint2(tls, p) + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32('/') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + **(**int32)(__ccgo_up(rule + 4*4)) = _getoff(tls, p) + } else { + **(**int32)(__ccgo_up(rule + 4*4)) = int32(7200) + } +} + +func _getname(tls *TLS, d uintptr, p uintptr) { + var i, v3 int32 + _, _ = i, v3 + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32('<') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + i = 0 + for { + if !(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))) != 0 && int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i)))) != int32('>')) { + break + } + if i < int32(TZNAME_MAX) { + **(**int8)(__ccgo_up(d + uintptr(i))) = **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))) + } + goto _1 + _1: + ; + i = i + 1 + } + if **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))) != 0 { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + } + } else { + i = 0 + for { + if !(Uint32FromInt32(int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))))|int32(32)-int32('a')) < uint32(26)) { + break + } + if i < int32(TZNAME_MAX) { + **(**int8)(__ccgo_up(d + uintptr(i))) = **(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))) + } + goto _2 + _2: + ; + i = i + 1 + } + } + **(**uintptr)(__ccgo_up(p)) += uintptr(i) + if i < int32(TZNAME_MAX) { + v3 = i + } else { + v3 = int32(TZNAME_MAX) + } + **(**int8)(__ccgo_up(d + uintptr(v3))) = 0 +} + +func _zi_read32(tls *TLS, z uintptr) (r Tuint32_t) { + return uint32(**(**uint8)(__ccgo_up(z)))< Uint64FromInt32(Int32FromInt32(PATH_MAX)+Int32FromInt32(1)) { + **(**uintptr)(__ccgo_up(bp + 288)) = uintptr(unsafe.Pointer(&X__utc)) + i = Uint64FromInt32(3) + } + if i >= _old_tz_size { + _old_tz_size = _old_tz_size * uint64(2) + if i >= _old_tz_size { + _old_tz_size = i + uint64(1) + } + if _old_tz_size > Uint64FromInt32(Int32FromInt32(PATH_MAX)+Int32FromInt32(2)) { + _old_tz_size = Uint64FromInt32(Int32FromInt32(PATH_MAX) + Int32FromInt32(2)) + } + _old_tz = Xmalloc(tls, _old_tz_size) + } + if _old_tz != 0 { + Xmemcpy(tls, _old_tz, **(**uintptr)(__ccgo_up(bp + 288)), i+uint64(1)) + } + posix_form = 0 + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 288))))) != int32(':') { + **(**uintptr)(__ccgo_up(bp + 296)) = **(**uintptr)(__ccgo_up(bp + 288)) + _getname(tls, bp+308, bp+296) + if **(**uintptr)(__ccgo_up(bp + 296)) != **(**uintptr)(__ccgo_up(bp + 288)) && (int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 296))))) == int32('+') || int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 296))))) == int32('-') || BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 296)))))-uint32('0') < uint32(10)) != 0 || !(Xstrcmp(tls, bp+308, __ccgo_ts+1772) != 0) || !(Xstrcmp(tls, bp+308, __ccgo_ts+1776) != 0)) { + posix_form = int32(1) + } + } + /* Non-suid can use an absolute tzfile pathname or a relative + * pathame beginning with "."; in secure mode, only the + * standard path will be searched. */ + if !(posix_form != 0) { + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 288))))) == int32(':') { + **(**uintptr)(__ccgo_up(bp + 288)) = **(**uintptr)(__ccgo_up(bp + 288)) + 1 + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 288))))) == int32('/') || int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 288))))) == int32('.') { + if !(X__libc.Fsecure != 0) || !(Xstrcmp(tls, **(**uintptr)(__ccgo_up(bp + 288)), __ccgo_ts+1757) != 0) { + map1 = X__map_file(tls, **(**uintptr)(__ccgo_up(bp + 288)), uintptr(unsafe.Pointer(&_map_size))) + } + } else { + l = _strlen(tls, **(**uintptr)(__ccgo_up(bp + 288))) + if l <= uint64(NAME_MAX) && !(Xstrchr(tls, **(**uintptr)(__ccgo_up(bp + 288)), int32('.')) != 0) { + Xmemcpy(tls, pathname, **(**uintptr)(__ccgo_up(bp + 288)), l+uint64(1)) + **(**int8)(__ccgo_up(pathname + uintptr(l))) = 0 + try = uintptr(unsafe.Pointer(&_search)) + for { + if !(!(map1 != 0) && **(**int8)(__ccgo_up(try)) != 0) { + break + } + l = _strlen(tls, try) + Xmemcpy(tls, pathname-uintptr(l), try, l) + map1 = X__map_file(tls, pathname-uintptr(l), uintptr(unsafe.Pointer(&_map_size))) + goto _3 + _3: + ; + try = try + uintptr(l+uint64(1)) + } + } + } + if !(map1 != 0) { + **(**uintptr)(__ccgo_up(bp + 288)) = uintptr(unsafe.Pointer(&X__utc)) + } + } + if map1 != 0 && (_map_size < uint64(44) || Xmemcmp(tls, map1, __ccgo_ts+1780, uint64(4)) != 0) { + X__munmap(tls, map1, _map_size) + map1 = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 288)) = uintptr(unsafe.Pointer(&X__utc)) + } + _zi = map1 + if map1 != 0 { + scale = int32(2) + if Int32FromUint8(**(**uint8)(__ccgo_up(map1 + 4))) != int32('1') { + *(*[6]uint8)(unsafe.Pointer(bp)) = [6]uint8{ + 0: uint8(1), + 1: uint8(1), + 2: uint8(8), + 3: uint8(5), + 4: uint8(6), + 5: uint8(1), + } + skip = _zi_dotprod(tls, _zi+uintptr(20), bp, uint64(6)) + _trans = _zi + uintptr(skip) + uintptr(44) + uintptr(44) + scale = scale + 1 + } else { + _trans = _zi + uintptr(44) + } + _index = _trans + uintptr(_zi_read32(tls, _trans-uintptr(12))<> scale) + if !(n != 0) { + if alt != 0 { + **(**Tsize_t)(__ccgo_up(alt)) = uint64(0) + } + return uint64(0) + } + /* Binary search for 'most-recent rule before t'. */ + for n > uint64(1) { + m = a + n/uint64(2) + x = uint64(_zi_read32(tls, _trans+uintptr(m<> scale) + if a == n-uint64(1) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + if a == uint64(0) { + x = uint64(_zi_read32(tls, _trans)) + if scale == int32(3) { + x = x<>(m-int32(1))&int32(1) + } + return r +} + +/* Convert a POSIX DST rule plus year to seconds since epoch. */ + +func _rule_to_secs(tls *TLS, rule uintptr, year int32) (r int64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var d, days, m, n, wday, x int32 + var t int64 + var _ /* is_leap at bp+0 */ int32 + _, _, _, _, _, _, _ = d, days, m, n, t, wday, x + t = X__year_to_secs(tls, int64(year), bp) + if **(**int32)(__ccgo_up(rule)) != int32('M') { + x = **(**int32)(__ccgo_up(rule + 1*4)) + if **(**int32)(__ccgo_up(rule)) == int32('J') && (x < int32(60) || !(**(**int32)(__ccgo_up(bp)) != 0)) { + x = x - 1 + } + t = t + int64(int32(86400)*x) + } else { + m = **(**int32)(__ccgo_up(rule + 1*4)) + n = **(**int32)(__ccgo_up(rule + 2*4)) + d = **(**int32)(__ccgo_up(rule + 3*4)) + t = t + int64(X__month_to_secs(tls, m-int32(1), **(**int32)(__ccgo_up(bp)))) + wday = int32((t+int64(Int32FromInt32(4)*Int32FromInt32(86400)))%int64(Int32FromInt32(7)*Int32FromInt32(86400))) / int32(86400) + days = d - wday + if days < 0 { + days = days + int32(7) + } + if n == int32(5) && days+int32(28) >= _days_in_month1(tls, m, **(**int32)(__ccgo_up(bp))) { + n = int32(4) + } + t = t + int64(int32(86400)*(days+int32(7)*(n-int32(1)))) + } + t = t + int64(**(**int32)(__ccgo_up(rule + 4*4))) + return t +} + +/* Determine the time zone in effect for a given time in seconds since the + * epoch. It can be given in local or universal time. The results will + * indicate whether DST is in effect at the queried time, and will give both + * the GMT offset for the active zone/DST rule and the opposite DST. This + * enables a caller to efficiently adjust for the case where an explicit + * DST specification mismatches what would be in effect at the time. */ + +func X__secs_to_zone(tls *TLS, t int64, local int32, isdst uintptr, offset uintptr, oppoff uintptr, zonename uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v local=%v isdst=%v offset=%v oppoff=%v zonename=%v, (%v:)", tls, t, local, isdst, offset, oppoff, zonename, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i Tsize_t + var t0, t1, y int64 + var _ /* alt at bp+0 */ Tsize_t + _, _, _, _ = i, t0, t1, y + ___lock(tls, uintptr(unsafe.Pointer(&_lock4))) + _do_tzset(tls) + if _zi != 0 { + i = _scan_trans(tls, t, local, bp) + if i != Uint64FromInt32(-Int32FromInt32(1)) { + **(**int32)(__ccgo_up(isdst)) = Int32FromUint8(**(**uint8)(__ccgo_up(_types + uintptr(uint64(6)*i+uint64(4))))) + **(**int64)(__ccgo_up(offset)) = int64(Int32FromUint32(_zi_read32(tls, _types+uintptr(uint64(6)*i)))) + **(**uintptr)(__ccgo_up(zonename)) = _abbrevs + uintptr(**(**uint8)(__ccgo_up(_types + uintptr(uint64(6)*i+uint64(5))))) + if oppoff != 0 { + **(**int64)(__ccgo_up(oppoff)) = int64(Int32FromUint32(_zi_read32(tls, _types+uintptr(uint64(6)***(**Tsize_t)(__ccgo_up(bp)))))) + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) + return + } + } + if !(Xdaylight != 0) { + goto std + } + /* FIXME: may be broken if DST changes right at year boundary? + * Also, this could be more efficient.*/ + y = t/int64(31556952) + int64(70) + for X__year_to_secs(tls, y, uintptr(0)) > t { + y = y - 1 + } + for X__year_to_secs(tls, y+int64(1), uintptr(0)) < t { + y = y + 1 + } + t0 = _rule_to_secs(tls, uintptr(unsafe.Pointer(&_r0)), int32(y)) + t1 = _rule_to_secs(tls, uintptr(unsafe.Pointer(&_r12)), int32(y)) + if !(local != 0) { + t0 = t0 + Xtimezone + t1 = t1 + int64(_dst_off) + } + if t0 < t1 { + if t >= t0 && t < t1 { + goto dst + } + goto std + } else { + if t >= t1 && t < t0 { + goto std + } + goto dst + } + goto std +std: + ; + **(**int32)(__ccgo_up(isdst)) = 0 + **(**int64)(__ccgo_up(offset)) = -Xtimezone + if oppoff != 0 { + **(**int64)(__ccgo_up(oppoff)) = int64(-_dst_off) + } + **(**uintptr)(__ccgo_up(zonename)) = Xtzname[0] + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) + return + goto dst +dst: + ; + **(**int32)(__ccgo_up(isdst)) = int32(1) + **(**int64)(__ccgo_up(offset)) = int64(-_dst_off) + if oppoff != 0 { + **(**int64)(__ccgo_up(oppoff)) = -Xtimezone + } + **(**uintptr)(__ccgo_up(zonename)) = Xtzname[int32(1)] + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) +} + +func ___tzset(tls *TLS) { + ___lock(tls, uintptr(unsafe.Pointer(&_lock4))) + _do_tzset(tls) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) +} + +func X__tm_to_tzname(tls *TLS, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + _ = p + p = (*Ttm)(unsafe.Pointer(tm)).F__tm_zone + ___lock(tls, uintptr(unsafe.Pointer(&_lock4))) + _do_tzset(tls) + if p != uintptr(unsafe.Pointer(&X__utc)) && p != Xtzname[0] && p != Xtzname[int32(1)] && (!(_zi != 0) || uint64(p)-uint64(_abbrevs) >= Uint64FromInt64(int64(_abbrevs_end)-int64(_abbrevs))) { + p = __ccgo_ts + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) + return p +} + +func X__year_to_secs(tls *TLS, year int64, is_leap uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v year=%v is_leap=%v, (%v:)", tls, year, is_leap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var centuries, cycles, leaps, leaps1, rem, y int32 + var _ /* dummy at bp+0 */ int32 + _, _, _, _, _, _ = centuries, cycles, leaps, leaps1, rem, y + if Uint64FromInt64(year)-uint64(2) <= uint64(136) { + y = int32(year) + leaps = (y - int32(68)) >> int32(2) + if !((y-Int32FromInt32(68))&Int32FromInt32(3) != 0) { + leaps = leaps - 1 + if is_leap != 0 { + **(**int32)(__ccgo_up(is_leap)) = int32(1) + } + } else { + if is_leap != 0 { + **(**int32)(__ccgo_up(is_leap)) = 0 + } + } + return int64(int32(31536000)*(y-int32(70)) + int32(86400)*leaps) + } + if !(is_leap != 0) { + is_leap = bp + } + cycles = int32((year - int64(100)) / int64(400)) + rem = int32((year - int64(100)) % int64(400)) + if rem < 0 { + cycles = cycles - 1 + rem = rem + int32(400) + } + if !(rem != 0) { + **(**int32)(__ccgo_up(is_leap)) = int32(1) + centuries = 0 + leaps1 = 0 + } else { + if rem >= int32(200) { + if rem >= int32(300) { + centuries = int32(3) + rem = rem - int32(300) + } else { + centuries = int32(2) + rem = rem - int32(200) + } + } else { + if rem >= int32(100) { + centuries = int32(1) + rem = rem - int32(100) + } else { + centuries = 0 + } + } + if !(rem != 0) { + **(**int32)(__ccgo_up(is_leap)) = 0 + leaps1 = 0 + } else { + leaps1 = Int32FromUint32(Uint32FromInt32(rem) / uint32(4)) + rem = Int32FromUint32(uint32(rem) % Uint32FromUint32(4)) + **(**int32)(__ccgo_up(is_leap)) = BoolInt32(!(rem != 0)) + } + } + leaps1 = leaps1 + (int32(97)*cycles + int32(24)*centuries - **(**int32)(__ccgo_up(is_leap))) + return (year-int64(100))*int64(31536000) + int64(leaps1)*int64(86400) + int64(946684800) + int64(86400) +} + +func Xasctime(tls *TLS, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__asctime_r(tls, tm, uintptr(unsafe.Pointer(&_buf9))) +} + +var _buf9 [26]int8 + +func X__asctime_r(tls *TLS, tm uintptr, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v tm=%v buf=%v, (%v:)", tls, tm, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + if Xsnprintf(tls, buf, uint64(26), __ccgo_ts+1785, VaList(bp+8, X__nl_langinfo_l(tls, int32(ABDAY_1)+(*Ttm)(unsafe.Pointer(tm)).Ftm_wday, uintptr(unsafe.Pointer(&X__c_locale))), X__nl_langinfo_l(tls, int32(ABMON_1)+(*Ttm)(unsafe.Pointer(tm)).Ftm_mon, uintptr(unsafe.Pointer(&X__c_locale))), (*Ttm)(unsafe.Pointer(tm)).Ftm_mday, (*Ttm)(unsafe.Pointer(tm)).Ftm_hour, (*Ttm)(unsafe.Pointer(tm)).Ftm_min, (*Ttm)(unsafe.Pointer(tm)).Ftm_sec, int32(1900)+(*Ttm)(unsafe.Pointer(tm)).Ftm_year)) >= int32(26) { + /* ISO C requires us to use the above format string, + * even if it will not fit in the buffer. Thus asctime_r + * is _supposed_ to crash if the fields in tm are too large. + * We follow this behavior and crash "gracefully" to warn + * application developers that they may not be so lucky + * on other implementations (e.g. stack smashing..). + */ + // __asm__ __volatile__( "hlt" : : : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 108, __ccgo_ts+1817) + } + return buf +} + +func Xasctime_r(tls *TLS, tm uintptr, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v tm=%v buf=%v, (%v:)", tls, tm, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__asctime_r(tls, tm, buf) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xclock(tls *TLS) (r Tclock_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ts at bp+0 */ Ttimespec + if X__clock_gettime(tls, int32(CLOCK_PROCESS_CPUTIME_ID), bp) != 0 { + return int64(-int32(1)) + } + if (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec > Int64FromInt64(0x7fffffffffffffff)/Int64FromInt32(1000000) || (**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec/int64(1000) > int64(0x7fffffffffffffff)-int64(1000000)*(**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec { + return int64(-int32(1)) + } + return (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec*int64(1000000) + (**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec/int64(1000) +} + +func Xclock_getcpuclockid(tls *TLS, pid Tpid_t, clk uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v pid=%v clk=%v, (%v:)", tls, pid, clk, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var id Tclockid_t + var ret int32 + var _ /* ts at bp+0 */ Ttimespec + _, _ = id, ret + id = Int32FromUint32(Uint32FromInt32(-pid-Int32FromInt32(1))*uint32(8) + uint32(2)) + ret = int32(X__syscall2(tls, int64(SYS_clock_getres), int64(id), int64(bp))) + if ret == -int32(EINVAL) { + ret = -int32(ESRCH) + } + if ret != 0 { + return -ret + } + **(**Tclockid_t)(__ccgo_up(clk)) = id + return 0 +} + +func Xclock_getres(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v ts=%v, (%v:)", tls, clk, ts, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* If reaching this point, it's a 64-bit arch or time64-only + * 32-bit arch and we can get result directly into timespec. */ + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_clock_getres), int64(clk), int64(ts))))) +} + +func X__clock_gettime(tls *TLS, clk Tclockid_t, ts uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v clk=%v ts=%v, (%v:)", tls, clk, ts, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall2(tls, int64(SYS_clock_gettime), int64(clk), int64(ts))) + if r == -int32(ENOSYS) { + if clk == CLOCK_REALTIME { + X__syscall2(tls, int64(SYS_gettimeofday), int64(ts), int64(Int32FromInt32(0))) + (*Ttimespec)(unsafe.Pointer(ts)).Ftv_nsec = int64(int32((*Ttimespec)(unsafe.Pointer(ts)).Ftv_nsec) * int32(1000)) + return 0 + } + r = -int32(EINVAL) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xclock_gettime(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v ts=%v, (%v:)", tls, clk, ts, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__clock_gettime(tls, clk, ts) +} + +func X__clock_nanosleep(tls *TLS, clk Tclockid_t, flags int32, req uintptr, rem uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v flags=%v req=%v rem=%v, (%v:)", tls, clk, flags, req, rem, origin(2)) + defer func() { trc("-> %v", r) }() + } + if clk == int32(CLOCK_THREAD_CPUTIME_ID) { + return int32(EINVAL) + } + if clk == CLOCK_REALTIME && !(flags != 0) { + return int32(-___syscall_cp(tls, int64(SYS_nanosleep), int64(req), int64(rem), 0, 0, 0, 0)) + } + return int32(-___syscall_cp(tls, int64(SYS_clock_nanosleep), int64(clk), int64(flags), int64(req), int64(rem), 0, 0)) +} + +func Xclock_nanosleep(tls *TLS, clk Tclockid_t, flags int32, req uintptr, rem uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v flags=%v req=%v rem=%v, (%v:)", tls, clk, flags, req, rem, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__clock_nanosleep(tls, clk, flags, req, rem) +} + +func Xclock_settime(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v ts=%v, (%v:)", tls, clk, ts, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_clock_settime), int64(clk), int64(ts))))) +} + +func Xctime(tls *TLS, t uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + var tm uintptr + _ = tm + tm = Xlocaltime(tls, t) + if !(tm != 0) { + return uintptr(0) + } + return Xasctime(tls, tm) +} + +func Xctime_r(tls *TLS, t uintptr, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v buf=%v, (%v:)", tls, t, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var tm_p, v1 uintptr + var _ /* tm at bp+0 */ Ttm + _, _ = tm_p, v1 + tm_p = Xlocaltime_r(tls, t, bp) + if tm_p != 0 { + v1 = Xasctime_r(tls, tm_p, buf) + } else { + v1 = uintptr(0) + } + return v1 +} + +func Xdifftime(tls *TLS, t1 Ttime_t, t0 Ttime_t) (r float64) { + if __ccgo_strace { + trc("tls=%v t1=%v t0=%v, (%v:)", tls, t1, t0, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float64(t1 - t0) +} + +type Ttimeb = struct { + Ftime Ttime_t + Fmillitm uint16 + Ftimezone int16 + Fdstflag int16 +} + +func Xftime(tls *TLS, tp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v tp=%v, (%v:)", tls, tp, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 int16 + var _ /* ts at bp+0 */ Ttimespec + _ = v1 + Xclock_gettime(tls, CLOCK_REALTIME, bp) + (*Ttimeb)(unsafe.Pointer(tp)).Ftime = (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec + (*Ttimeb)(unsafe.Pointer(tp)).Fmillitm = Uint16FromInt64((**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec / int64(1000000)) + v1 = Int16FromInt32(0) + (*Ttimeb)(unsafe.Pointer(tp)).Fdstflag = v1 + (*Ttimeb)(unsafe.Pointer(tp)).Ftimezone = v1 + return 0 +} + +func Xgetdate(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(112) + defer tls.Free(112) + var datemsk, f, p, ret uintptr + var _ /* cs at bp+100 */ int32 + var _ /* fmt at bp+0 */ [100]int8 + _, _, _, _ = datemsk, f, p, ret + ret = uintptr(0) + datemsk = Xgetenv(tls, __ccgo_ts+1829) + f = uintptr(0) + _pthread_setcancelstate(tls, PTHREAD_CANCEL_DEFERRED, bp+100) + if !(datemsk != 0) { + Xgetdate_err = int32(1) + goto out + } + f = Xfopen(tls, datemsk, __ccgo_ts+381) + if !(f != 0) { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOMEM) { + Xgetdate_err = int32(6) + } else { + Xgetdate_err = int32(2) + } + goto out + } + for Xfgets(tls, bp, int32(100), f) != 0 { + p = Xstrptime(tls, s, bp, uintptr(unsafe.Pointer(&_tmbuf))) + if p != 0 && !(**(**int8)(__ccgo_up(p)) != 0) { + ret = uintptr(unsafe.Pointer(&_tmbuf)) + goto out + } + } + if Xferror(tls, f) != 0 { + Xgetdate_err = int32(5) + } else { + Xgetdate_err = int32(7) + } + goto out +out: + ; + if f != 0 { + Xfclose(tls, f) + } + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 100)), uintptr(0)) + return ret +} + +var _tmbuf Ttm + +func Xgettimeofday(tls *TLS, tv uintptr, tz uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v tv=%v tz=%v, (%v:)", tls, tv, tz, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ts at bp+0 */ Ttimespec + if !(tv != 0) { + return 0 + } + Xclock_gettime(tls, CLOCK_REALTIME, bp) + (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec = (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec + (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec = int64(int32((**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec) / int32(1000)) + return 0 +} + +func Xgmtime(tls *TLS, t uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__gmtime_r(tls, t, uintptr(unsafe.Pointer(&_tm))) +} + +var _tm Ttm + +func X__gmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + if X__secs_to_tm(tls, int64(**(**Ttime_t)(__ccgo_up(t))), tm) < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return uintptr(0) + } + (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst = 0 + (*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff = 0 + (*Ttm)(unsafe.Pointer(tm)).F__tm_zone = uintptr(unsafe.Pointer(&X__utc)) + return tm +} + +func Xgmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__gmtime_r(tls, t, tm) +} + +func Xlocaltime(tls *TLS, t uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__localtime_r(tls, t, uintptr(unsafe.Pointer(&_tm1))) +} + +var _tm1 Ttm + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__localtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* Reject time_t values whose year would overflow int because + * __secs_to_zone cannot safely handle them. */ + if int64(**(**Ttime_t)(__ccgo_up(t))) < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff))*Int64FromInt64(31622400) || int64(**(**Ttime_t)(__ccgo_up(t))) > Int64FromInt32(INT_MAX)*Int64FromInt64(31622400) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return uintptr(0) + } + X__secs_to_zone(tls, int64(**(**Ttime_t)(__ccgo_up(t))), 0, tm+32, tm+40, uintptr(0), tm+48) + if X__secs_to_tm(tls, int64(**(**Ttime_t)(__ccgo_up(t)))+(*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff, tm) < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return uintptr(0) + } + return tm +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xlocaltime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__localtime_r(tls, t, tm) +} + +func Xmktime(tls *TLS, tm uintptr) (r Ttime_t) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var t int64 + var _ /* new at bp+0 */ Ttm + var _ /* opp at bp+56 */ int64 + _ = t + t = X__tm_to_secs(tls, tm) + X__secs_to_zone(tls, t, int32(1), bp+32, bp+40, bp+56, bp+48) + if (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst >= 0 && (**(**Ttm)(__ccgo_up(bp))).Ftm_isdst != (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst { + t = t - int64(**(**int64)(__ccgo_up(bp + 56))-(**(**Ttm)(__ccgo_up(bp))).F__tm_gmtoff) + } + t = t - int64((**(**Ttm)(__ccgo_up(bp))).F__tm_gmtoff) + if t != t { + goto error + } + X__secs_to_zone(tls, t, 0, bp+32, bp+40, bp+56, bp+48) + if X__secs_to_tm(tls, t+int64((**(**Ttm)(__ccgo_up(bp))).F__tm_gmtoff), bp) < 0 { + goto error + } + **(**Ttm)(__ccgo_up(tm)) = **(**Ttm)(__ccgo_up(bp)) + return t + goto error +error: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return int64(-int32(1)) +} + +func Xnanosleep(tls *TLS, req uintptr, rem uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v req=%v rem=%v, (%v:)", tls, req, rem, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt32(-X__clock_nanosleep(tls, CLOCK_REALTIME, 0, req, rem)))) +} + +func _is_leap(tls *TLS, y int32) (r int32) { + /* Avoid overflow */ + if y > Int32FromInt32(INT_MAX)-Int32FromInt32(1900) { + y = y - int32(2000) + } + y = y + int32(1900) + return BoolInt32(!(y%Int32FromInt32(4) != 0) && (y%int32(100) != 0 || !(y%Int32FromInt32(400) != 0))) +} + +func _week_num(tls *TLS, tm uintptr) (r int32) { + var dec31, jan1, val int32 + _, _, _ = dec31, jan1, val + val = Int32FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday) + uint32(7) - (Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday)+uint32(6))%uint32(7)) / uint32(7)) + /* If 1 Jan is just 1-3 days past Monday, + * the previous week is also in this year. */ + if (Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday)+uint32(371)-Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday)-uint32(2))%uint32(7) <= uint32(2) { + val = val + 1 + } + if !(val != 0) { + val = int32(52) + /* If 31 December of prev year a Thursday, + * or Friday of a leap year, then the + * prev year has 53 weeks. */ + dec31 = Int32FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) + uint32(7) - Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday) - uint32(1)) % uint32(7)) + if dec31 == int32(4) || dec31 == int32(5) && _is_leap(tls, (*Ttm)(unsafe.Pointer(tm)).Ftm_year%int32(400)-int32(1)) != 0 { + val = val + 1 + } + } else { + if val == int32(53) { + /* If 1 January is not a Thursday, and not + * a Wednesday of a leap year, then this + * year has only 52 weeks. */ + jan1 = Int32FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) + uint32(371) - Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday)) % uint32(7)) + if jan1 != int32(4) && (jan1 != int32(3) || !(_is_leap(tls, (*Ttm)(unsafe.Pointer(tm)).Ftm_year) != 0)) { + val = int32(1) + } + } + } + return val +} + +func X__strftime_fmt_1(tls *TLS, s uintptr, l uintptr, f int32, tm uintptr, loc Tlocale_t, pad int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v f=%v tm=%v loc=%v pad=%v, (%v:)", tls, s, l, f, tm, loc, pad, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var d, fmt, v4, v5 uintptr + var def_pad, width, v1 int32 + var item Tnl_item + var val int64 + _, _, _, _, _, _, _, _, _ = d, def_pad, fmt, item, val, width, v1, v4, v5 + fmt = __ccgo_ts + 1679 + width = int32(2) + def_pad = int32('0') + switch f { + case int32('a'): + if Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) > uint32(6) { + goto string + } + item = int32(ABDAY_1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_wday + goto nl_strcat + case int32('A'): + if Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) > uint32(6) { + goto string + } + item = int32(DAY_1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_wday + goto nl_strcat + case int32('h'): + fallthrough + case int32('b'): + if Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_mon) > uint32(11) { + goto string + } + item = int32(ABMON_1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_mon + goto nl_strcat + case int32('B'): + if Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_mon) > uint32(11) { + goto string + } + item = int32(MON_1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_mon + goto nl_strcat + case int32('c'): + item = int32(D_T_FMT) + goto nl_strftime + case int32('C'): + val = (int64(1900) + int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year)) / int64(100) + goto number + case int32('e'): + def_pad = int32('_') + fallthrough + case int32('d'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_mday) + goto number + case int32('D'): + fmt = __ccgo_ts + 1837 + goto recu_strftime + case int32('F'): + fmt = __ccgo_ts + 1846 + goto recu_strftime + case int32('g'): + fallthrough + case int32('G'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year) + int64(1900) + if (*Ttm)(unsafe.Pointer(tm)).Ftm_yday < int32(3) && _week_num(tls, tm) != int32(1) { + val = val - 1 + } else { + if (*Ttm)(unsafe.Pointer(tm)).Ftm_yday > int32(360) && _week_num(tls, tm) == int32(1) { + val = val + 1 + } + } + if f == int32('g') { + val = val % int64(100) + } else { + width = int32(4) + } + goto number + case int32('H'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_hour) + goto number + case int32('l'): + def_pad = int32('_') + fallthrough + case int32('I'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_hour) + if !(val != 0) { + val = int64(12) + } else { + if val > int64(12) { + val = val - int64(12) + } + } + goto number + case int32('j'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_yday + int32(1)) + width = int32(3) + goto number + case int32('k'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_hour) + def_pad = int32('_') + goto number + case int32('m'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_mon + int32(1)) + goto number + case int32('M'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_min) + goto number + case int32('n'): + **(**Tsize_t)(__ccgo_up(l)) = uint64(1) + return __ccgo_ts + 367 + case int32('p'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_hour >= int32(12) { + v1 = int32(PM_STR) + } else { + v1 = int32(AM_STR) + } + item = v1 + goto nl_strcat + case int32('P'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_hour >= int32(12) { + v1 = int32(PM_STR) + } else { + v1 = int32(AM_STR) + } + item = v1 + fmt = X__nl_langinfo_l(tls, item, loc) + d = s + **(**Tsize_t)(__ccgo_up(l)) = uint64(0) + for { + if !(**(**int8)(__ccgo_up(fmt)) != 0) { + break + } + v4 = d + d = d + 1 + v5 = fmt + fmt = fmt + 1 + **(**int8)(__ccgo_up(v4)) = int8(Xtolower(tls, int32(**(**int8)(__ccgo_up(v5))))) + goto _3 + _3: + ; + **(**Tsize_t)(__ccgo_up(l)) = **(**Tsize_t)(__ccgo_up(l)) + 1 + } + return s + case int32('r'): + item = int32(T_FMT_AMPM) + goto nl_strftime + case int32('R'): + fmt = __ccgo_ts + 1855 + goto recu_strftime + case int32('s'): + val = X__tm_to_secs(tls, tm) - (*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff + width = int32(1) + goto number + case int32('S'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_sec) + goto number + case int32('t'): + **(**Tsize_t)(__ccgo_up(l)) = uint64(1) + return __ccgo_ts + 1417 + case int32('T'): + fmt = __ccgo_ts + 1861 + goto recu_strftime + case int32('u'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_wday != 0 { + v1 = (*Ttm)(unsafe.Pointer(tm)).Ftm_wday + } else { + v1 = int32(7) + } + val = int64(v1) + width = int32(1) + goto number + case int32('U'): + val = Int64FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday) + uint32(7) - Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday)) / uint32(7)) + goto number + case int32('W'): + val = Int64FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday) + uint32(7) - (Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday)+uint32(6))%uint32(7)) / uint32(7)) + goto number + case int32('V'): + val = int64(_week_num(tls, tm)) + goto number + case int32('w'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) + width = int32(1) + goto number + case int32('x'): + item = int32(D_FMT) + goto nl_strftime + case int32('X'): + item = int32(T_FMT) + goto nl_strftime + case int32('y'): + val = (int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year) + int64(1900)) % int64(100) + if val < 0 { + val = -val + } + goto number + case int32('Y'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year) + int64(1900) + if val >= int64(10000) { + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1870, VaList(bp+8, val))) + return s + } + width = int32(4) + goto number + case int32('z'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst < 0 { + **(**Tsize_t)(__ccgo_up(l)) = uint64(0) + return __ccgo_ts + } + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1876, VaList(bp+8, (*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff/int64(3600)*int64(100)+(*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff%int64(3600)/int64(60)))) + return s + case int32('Z'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst < 0 { + **(**Tsize_t)(__ccgo_up(l)) = uint64(0) + return __ccgo_ts + } + fmt = X__tm_to_tzname(tls, tm) + goto string + case int32('%'): + **(**Tsize_t)(__ccgo_up(l)) = uint64(1) + return __ccgo_ts + 414 + default: + return uintptr(0) + } + goto number +number: + ; + if pad != 0 { + v1 = pad + } else { + v1 = def_pad + } + switch v1 { + case int32('-'): + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1883, VaList(bp+8, val))) + case int32('_'): + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1888, VaList(bp+8, width, val))) + case int32('0'): + fallthrough + default: + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1894, VaList(bp+8, width, val))) + break + } + return s + goto nl_strcat +nl_strcat: + ; + fmt = X__nl_langinfo_l(tls, item, loc) + goto string +string: + ; + **(**Tsize_t)(__ccgo_up(l)) = _strlen(tls, fmt) + return fmt + goto nl_strftime +nl_strftime: + ; + fmt = X__nl_langinfo_l(tls, item, loc) + goto recu_strftime +recu_strftime: + ; + **(**Tsize_t)(__ccgo_up(l)) = X__strftime_l(tls, s, uint64(100), fmt, tm, loc) + if !(**(**Tsize_t)(__ccgo_up(l)) != 0) { + return uintptr(0) + } + return s +} + +func X__strftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v loc=%v, (%v:)", tls, s, n, f, tm, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var d, l, v2 Tsize_t + var pad, plus, v4 int32 + var t, v3 uintptr + var width uint64 + var v9 bool + var _ /* buf at bp+8 */ [100]int8 + var _ /* k at bp+0 */ Tsize_t + var _ /* p at bp+112 */ uintptr + _, _, _, _, _, _, _, _, _, _ = d, l, pad, plus, t, width, v2, v3, v4, v9 + l = uint64(0) + for { + if !(l < n) { + break + } + if !(**(**int8)(__ccgo_up(f)) != 0) { + **(**int8)(__ccgo_up(s + uintptr(l))) = 0 + return l + } + if int32(**(**int8)(__ccgo_up(f))) != int32('%') { + v2 = l + l = l + 1 + **(**int8)(__ccgo_up(s + uintptr(v2))) = **(**int8)(__ccgo_up(f)) + goto _1 + } + f = f + 1 + pad = 0 + if int32(**(**int8)(__ccgo_up(f))) == int32('-') || int32(**(**int8)(__ccgo_up(f))) == int32('_') || int32(**(**int8)(__ccgo_up(f))) == int32('0') { + v3 = f + f = f + 1 + pad = int32(**(**int8)(__ccgo_up(v3))) + } + v4 = BoolInt32(int32(**(**int8)(__ccgo_up(f))) == Int32FromUint8('+')) + plus = v4 + if v4 != 0 { + f = f + 1 + } + if BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(f)))-uint32('0') < uint32(10)) != 0 { + width = Xstrtoul(tls, f, bp+112, int32(10)) + } else { + width = uint64(0) + **(**uintptr)(__ccgo_up(bp + 112)) = f + } + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('C') || int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('F') || int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('G') || int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('Y') { + if !(width != 0) && **(**uintptr)(__ccgo_up(bp + 112)) != f { + width = uint64(1) + } + } else { + width = uint64(0) + } + f = **(**uintptr)(__ccgo_up(bp + 112)) + if int32(**(**int8)(__ccgo_up(f))) == int32('E') || int32(**(**int8)(__ccgo_up(f))) == int32('O') { + f = f + 1 + } + t = X__strftime_fmt_1(tls, bp+8, bp, int32(**(**int8)(__ccgo_up(f))), tm, loc, pad) + if !(t != 0) { + break + } + if width != 0 { + /* Trim off any sign and leading zeros, then + * count remaining digits to determine behavior + * for the + flag. */ + if int32(**(**int8)(__ccgo_up(t))) == int32('+') || int32(**(**int8)(__ccgo_up(t))) == int32('-') { + t = t + 1 + **(**Tsize_t)(__ccgo_up(bp)) = **(**Tsize_t)(__ccgo_up(bp)) - 1 + } + for { + if !(int32(**(**int8)(__ccgo_up(t))) == int32('0') && Uint32FromInt32(int32(**(**int8)(__ccgo_up(t + 1)))-int32('0')) < uint32(10)) { + break + } + goto _5 + _5: + ; + t = t + 1 + **(**Tsize_t)(__ccgo_up(bp)) = **(**Tsize_t)(__ccgo_up(bp)) - 1 + } + if width < **(**Tsize_t)(__ccgo_up(bp)) { + width = **(**Tsize_t)(__ccgo_up(bp)) + } + d = uint64(0) + for { + if !(Uint32FromInt32(int32(**(**int8)(__ccgo_up(t + uintptr(d))))-int32('0')) < uint32(10)) { + break + } + goto _6 + _6: + ; + d = d + 1 + } + if (*Ttm)(unsafe.Pointer(tm)).Ftm_year < -int32(1900) { + v2 = l + l = l + 1 + **(**int8)(__ccgo_up(s + uintptr(v2))) = int8('-') + width = width - 1 + } else { + if v9 = plus != 0; v9 { + if int32(**(**int8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('C') { + v4 = int32(3) + } else { + v4 = int32(5) + } + } + if v9 && d+(width-**(**Tsize_t)(__ccgo_up(bp))) >= Uint64FromInt32(v4) { + v2 = l + l = l + 1 + **(**int8)(__ccgo_up(s + uintptr(v2))) = int8('+') + width = width - 1 + } + } + for { + if !(width > **(**Tsize_t)(__ccgo_up(bp)) && l < n) { + break + } + v2 = l + l = l + 1 + **(**int8)(__ccgo_up(s + uintptr(v2))) = int8('0') + goto _11 + _11: + ; + width = width - 1 + } + } + if **(**Tsize_t)(__ccgo_up(bp)) > n-l { + **(**Tsize_t)(__ccgo_up(bp)) = n - l + } + Xmemcpy(tls, s+uintptr(l), t, **(**Tsize_t)(__ccgo_up(bp))) + l = l + **(**Tsize_t)(__ccgo_up(bp)) + goto _1 + _1: + ; + f = f + 1 + } + if n != 0 { + if l == n { + l = n - uint64(1) + } + **(**int8)(__ccgo_up(s + uintptr(l))) = 0 + } + return uint64(0) +} + +func Xstrftime(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v, (%v:)", tls, s, n, f, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strftime_l(tls, s, n, f, tm, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xstrftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v loc=%v, (%v:)", tls, s, n, f, tm, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strftime_l(tls, s, n, f, tm, loc) +} + +func Xstrptime(tls *TLS, s uintptr, f uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v f=%v tm=%v, (%v:)", tls, s, f, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var adj, i, min, neg, range1, w, want_century, v1, v2, v5, v6 int32 + var dest, ex, v9 uintptr + var len1 Tsize_t + var v8 bool + var _ /* century at bp+4 */ int32 + var _ /* dummy at bp+0 */ int32 + var _ /* new_f at bp+16 */ uintptr + var _ /* relyear at bp+8 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = adj, dest, ex, i, len1, min, neg, range1, w, want_century, v1, v2, v5, v6, v8, v9 + want_century = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = 0 + for **(**int8)(__ccgo_up(f)) != 0 { + if int32(**(**int8)(__ccgo_up(f))) != int32('%') { + v1 = int32(**(**int8)(__ccgo_up(f))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if v2 != 0 { + for { + if v8 = **(**int8)(__ccgo_up(s)) != 0; v8 { + v5 = int32(**(**int8)(__ccgo_up(s))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + } + if !(v8 && v6 != 0) { + break + } + goto _4 + _4: + ; + s = s + 1 + } + } else { + if int32(**(**int8)(__ccgo_up(s))) != int32(**(**int8)(__ccgo_up(f))) { + return uintptr(0) + } else { + s = s + 1 + } + } + f = f + 1 + continue + } + f = f + 1 + if int32(**(**int8)(__ccgo_up(f))) == int32('+') { + f = f + 1 + } + if BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(f)))-uint32('0') < uint32(10)) != 0 { + w = Int32FromUint64(Xstrtoul(tls, f, bp+16, int32(10))) + f = **(**uintptr)(__ccgo_up(bp + 16)) + } else { + w = -int32(1) + } + adj = 0 + v9 = f + f = f + 1 + switch int32(**(**int8)(__ccgo_up(v9))) { + case int32('A'): + goto _10 + case int32('a'): + goto _11 + case int32('h'): + goto _12 + case int32('B'): + goto _13 + case int32('b'): + goto _14 + case int32('c'): + goto _15 + case int32('C'): + goto _16 + case int32('e'): + goto _17 + case int32('d'): + goto _18 + case int32('D'): + goto _19 + case int32('H'): + goto _20 + case int32('I'): + goto _21 + case int32('j'): + goto _22 + case int32('m'): + goto _23 + case int32('M'): + goto _24 + case int32('t'): + goto _25 + case int32('n'): + goto _26 + case int32('p'): + goto _27 + case int32('r'): + goto _28 + case int32('R'): + goto _29 + case int32('S'): + goto _30 + case int32('T'): + goto _31 + case int32('W'): + goto _32 + case int32('U'): + goto _33 + case int32('w'): + goto _34 + case int32('x'): + goto _35 + case int32('X'): + goto _36 + case int32('y'): + goto _37 + case int32('Y'): + goto _38 + case int32('%'): + goto _39 + default: + goto _40 + } + goto _41 + _11: + ; + _10: + ; + dest = tm + 24 + min = int32(ABDAY_1) + range1 = int32(7) + goto symbolic_range + _14: + ; + _13: + ; + _12: + ; + dest = tm + 16 + min = int32(ABMON_1) + range1 = int32(12) + goto symbolic_range + _15: + ; + s = Xstrptime(tls, s, Xnl_langinfo(tls, int32(D_T_FMT)), tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _16: + ; + dest = bp + 4 + if w < 0 { + w = int32(2) + } + want_century = want_century | int32(2) + goto numeric_digits + _18: + ; + _17: + ; + dest = tm + 12 + min = int32(1) + range1 = int32(31) + goto numeric_range + _19: + ; + s = Xstrptime(tls, s, __ccgo_ts+1837, tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _20: + ; + dest = tm + 8 + min = 0 + range1 = int32(24) + goto numeric_range + _21: + ; + dest = tm + 8 + min = int32(1) + range1 = int32(12) + goto numeric_range + _22: + ; + dest = tm + 28 + min = int32(1) + range1 = int32(366) + adj = int32(1) + goto numeric_range + _23: + ; + dest = tm + 16 + min = int32(1) + range1 = int32(12) + adj = int32(1) + goto numeric_range + _24: + ; + dest = tm + 4 + min = 0 + range1 = int32(60) + goto numeric_range + _26: + ; + _25: + ; + _44: + ; + if v8 = **(**int8)(__ccgo_up(s)) != 0; v8 { + v1 = int32(**(**int8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _47 + _47: + } + if !(v8 && v2 != 0) { + goto _42 + } + goto _43 + _43: + ; + s = s + 1 + goto _44 + goto _42 + _42: + ; + goto _41 + _27: + ; + ex = Xnl_langinfo(tls, int32(AM_STR)) + len1 = _strlen(tls, ex) + if !(Xstrncasecmp(tls, s, ex, len1) != 0) { + **(**int32)(__ccgo_up(tm + 8)) %= int32(12) + s = s + uintptr(len1) + goto _41 + } + ex = Xnl_langinfo(tls, int32(PM_STR)) + len1 = _strlen(tls, ex) + if !(Xstrncasecmp(tls, s, ex, len1) != 0) { + **(**int32)(__ccgo_up(tm + 8)) %= int32(12) + **(**int32)(__ccgo_up(tm + 8)) += int32(12) + s = s + uintptr(len1) + goto _41 + } + return uintptr(0) + _28: + ; + s = Xstrptime(tls, s, Xnl_langinfo(tls, int32(T_FMT_AMPM)), tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _29: + ; + s = Xstrptime(tls, s, __ccgo_ts+1855, tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _30: + ; + dest = tm + min = 0 + range1 = int32(61) + goto numeric_range + _31: + ; + s = Xstrptime(tls, s, __ccgo_ts+1861, tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _33: + ; + _32: + ; + /* Throw away result, for now. (FIXME?) */ + dest = bp + min = 0 + range1 = int32(54) + goto numeric_range + _34: + ; + dest = tm + 24 + min = 0 + range1 = int32(7) + goto numeric_range + _35: + ; + s = Xstrptime(tls, s, Xnl_langinfo(tls, int32(D_FMT)), tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _36: + ; + s = Xstrptime(tls, s, Xnl_langinfo(tls, int32(T_FMT)), tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _37: + ; + dest = bp + 8 + w = int32(2) + want_century = want_century | int32(1) + goto numeric_digits + _38: + ; + dest = tm + 20 + if w < 0 { + w = int32(4) + } + adj = int32(1900) + want_century = 0 + goto numeric_digits + _39: + ; + v9 = s + s = s + 1 + if int32(**(**int8)(__ccgo_up(v9))) != int32('%') { + return uintptr(0) + } + goto _41 + _40: + ; + return uintptr(0) + goto numeric_range + numeric_range: + ; + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return uintptr(0) + } + **(**int32)(__ccgo_up(dest)) = 0 + i = int32(1) + for { + if !(i <= min+range1 && BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0) { + break + } + v9 = s + s = s + 1 + **(**int32)(__ccgo_up(dest)) = **(**int32)(__ccgo_up(dest))*int32(10) + int32(**(**int8)(__ccgo_up(v9))) - int32('0') + goto _50 + _50: + ; + i = i * int32(10) + } + if Uint32FromInt32(**(**int32)(__ccgo_up(dest))-min) >= Uint32FromInt32(range1) { + return uintptr(0) + } + **(**int32)(__ccgo_up(dest)) -= adj + switch int64(dest) - int64(tm) { + case Int64FromUint64(uint64(UintptrFromInt32(0) + 28)): + } + goto update + goto numeric_digits + numeric_digits: + ; + neg = 0 + if int32(**(**int8)(__ccgo_up(s))) == int32('+') { + s = s + 1 + } else { + if int32(**(**int8)(__ccgo_up(s))) == int32('-') { + neg = int32(1) + s = s + 1 + } + } + if !(BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return uintptr(0) + } + v1 = Int32FromInt32(0) + i = v1 + **(**int32)(__ccgo_up(dest)) = v1 + for { + if !(i < w && BoolInt32(Uint32FromInt8(**(**int8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0) { + break + } + v9 = s + s = s + 1 + **(**int32)(__ccgo_up(dest)) = **(**int32)(__ccgo_up(dest))*int32(10) + int32(**(**int8)(__ccgo_up(v9))) - int32('0') + goto _52 + _52: + ; + i = i + 1 + } + if neg != 0 { + **(**int32)(__ccgo_up(dest)) = -**(**int32)(__ccgo_up(dest)) + } + **(**int32)(__ccgo_up(dest)) -= adj + goto update + goto symbolic_range + symbolic_range: + ; + i = int32(2)*range1 - int32(1) + for { + if !(i >= 0) { + break + } + ex = Xnl_langinfo(tls, min+i) + len1 = _strlen(tls, ex) + if Xstrncasecmp(tls, s, ex, len1) != 0 { + goto _55 + } + s = s + uintptr(len1) + **(**int32)(__ccgo_up(dest)) = i % range1 + break + goto _55 + _55: + ; + i = i - 1 + } + if i < 0 { + return uintptr(0) + } + goto update + goto update + update: + ; + //FIXME + _41: + } + if want_century != 0 { + (*Ttm)(unsafe.Pointer(tm)).Ftm_year = **(**int32)(__ccgo_up(bp + 8)) + if want_century&int32(2) != 0 { + **(**int32)(__ccgo_up(tm + 20)) += **(**int32)(__ccgo_up(bp + 4))*int32(100) - int32(1900) + } else { + if (*Ttm)(unsafe.Pointer(tm)).Ftm_year <= int32(68) { + **(**int32)(__ccgo_up(tm + 20)) += int32(100) + } + } + } + return s +} + +func Xtime(tls *TLS, t uintptr) (r Ttime_t) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ts at bp+0 */ Ttimespec + X__clock_gettime(tls, CLOCK_REALTIME, bp) + if t != 0 { + **(**Ttime_t)(__ccgo_up(t)) = (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec + } + return (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec +} + +func Xtimegm(tls *TLS, tm uintptr) (r Ttime_t) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var t int64 + var _ /* new at bp+0 */ Ttm1 + _ = t + t = X__tm_to_secs(tls, tm) + if X__secs_to_tm(tls, t, bp) < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return int64(-int32(1)) + } + **(**Ttm1)(__ccgo_up(tm)) = **(**Ttm1)(__ccgo_up(bp)) + (*Ttm1)(unsafe.Pointer(tm)).Ftm_isdst = 0 + (*Ttm1)(unsafe.Pointer(tm)).Ftm_gmtoff = 0 + (*Ttm1)(unsafe.Pointer(tm)).Ftm_zone = uintptr(unsafe.Pointer(&X__utc)) + return t +} + +func Xtimer_delete(tls *TLS, t Ttimer_t) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + var td Tpthread_t + _ = td + if int64(t) < 0 { + td = uintptr(uint64(t) << Int32FromInt32(1)) + // __asm__ __volatile__( + // + // "mov %1, %0 ; lock ; orl $0,(%%rsp)" + // : "=m"(*p) : "r"(x) : "memory" ); + X__assert_fail(tls, __ccgo_ts+212, __ccgo_ts+247, 88, __ccgo_ts+1901) + X__syscall2(tls, int64(SYS_tkill), int64((*t__pthread)(unsafe.Pointer(td)).Ftid), int64(Int32FromInt32(SIGTIMER))) + return 0 + } + return int32(X__syscall1(tls, int64(SYS_timer_delete), int64(t))) +} + +func Xtimer_getoverrun(tls *TLS, t Ttimer_t) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + var td Tpthread_t + _ = td + if int64(t) < 0 { + td = uintptr(uint64(t) << Int32FromInt32(1)) + t = uintptr(Uint64FromInt32(AtomicLoadPInt32(td+164) & Int32FromInt32(INT_MAX))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_timer_getoverrun), int64(t))))) +} + +func Xtimer_gettime(tls *TLS, t Ttimer_t, val uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v val=%v, (%v:)", tls, t, val, origin(2)) + defer func() { trc("-> %v", r) }() + } + var td Tpthread_t + _ = td + if int64(t) < 0 { + td = uintptr(uint64(t) << Int32FromInt32(1)) + t = uintptr(Uint64FromInt32(AtomicLoadPInt32(td+164) & Int32FromInt32(INT_MAX))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_timer_gettime), int64(t), int64(val))))) +} + +func Xtimer_settime(tls *TLS, t Ttimer_t, flags int32, val uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v flags=%v val=%v old=%v, (%v:)", tls, t, flags, val, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + var td Tpthread_t + _ = td + if int64(t) < 0 { + td = uintptr(uint64(t) << Int32FromInt32(1)) + t = uintptr(Uint64FromInt32(AtomicLoadPInt32(td+164) & Int32FromInt32(INT_MAX))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_timer_settime), int64(t), int64(flags), int64(val), int64(old))))) +} + +type Ttms = struct { + Ftms_utime Tclock_t + Ftms_stime Tclock_t + Ftms_cutime Tclock_t + Ftms_cstime Tclock_t +} + +func Xtimes(tls *TLS, tms uintptr) (r Tclock_t) { + if __ccgo_strace { + trc("tls=%v tms=%v, (%v:)", tls, tms, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall1(tls, int64(SYS_times), int64(tms)) +} + +// C documentation +// +// /* There is no other implemented value than TIME_UTC; all other values +// * are considered erroneous. */ +func Xtimespec_get(tls *TLS, ts uintptr, base int32) (r int32) { + if __ccgo_strace { + trc("tls=%v ts=%v base=%v, (%v:)", tls, ts, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret, v1 int32 + _, _ = ret, v1 + if base != int32(TIME_UTC) { + return 0 + } + ret = X__clock_gettime(tls, CLOCK_REALTIME, ts) + if ret < 0 { + v1 = 0 + } else { + v1 = base + } + return v1 +} + +type Tutimbuf = struct { + Factime Ttime_t + Fmodtime Ttime_t +} + +func Xutime(tls *TLS, path uintptr, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v times=%v, (%v:)", tls, path, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1 uintptr + _ = v1 + if times != 0 { + *(*[2]Ttimespec)(unsafe.Pointer(bp)) = [2]Ttimespec{ + 0: { + Ftv_sec: (*Tutimbuf)(unsafe.Pointer(times)).Factime, + }, + 1: { + Ftv_sec: (*Tutimbuf)(unsafe.Pointer(times)).Fmodtime, + }, + } + v1 = bp + } else { + v1 = uintptr(0) + } + return Xutimensat(tls, -int32(100), path, v1, 0) +} + +func X__wcsftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v loc=%v, (%v:)", tls, s, n, f, tm, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(528) + defer tls.Free(528) + var l, v2 Tsize_t + var pad, plus, v4 int32 + var t, t_mb, v3 uintptr + var width uint64 + var _ /* buf at bp+8 */ [100]int8 + var _ /* k at bp+0 */ Tsize_t + var _ /* p at bp+512 */ uintptr + var _ /* wbuf at bp+108 */ [100]Twchar_t + _, _, _, _, _, _, _, _, _ = l, pad, plus, t, t_mb, width, v2, v3, v4 + l = uint64(0) + for { + if !(l < n) { + break + } + if !(**(**Twchar_t)(__ccgo_up(f)) != 0) { + **(**Twchar_t)(__ccgo_up(s + uintptr(l)*4)) = 0 + return l + } + if **(**Twchar_t)(__ccgo_up(f)) != int32('%') { + v2 = l + l = l + 1 + **(**Twchar_t)(__ccgo_up(s + uintptr(v2)*4)) = **(**Twchar_t)(__ccgo_up(f)) + goto _1 + } + f += 4 + pad = 0 + if **(**Twchar_t)(__ccgo_up(f)) == int32('-') || **(**Twchar_t)(__ccgo_up(f)) == int32('_') || **(**Twchar_t)(__ccgo_up(f)) == int32('0') { + v3 = f + f += 4 + pad = **(**Twchar_t)(__ccgo_up(v3)) + } + v4 = BoolInt32(**(**Twchar_t)(__ccgo_up(f)) == Int32FromUint8('+')) + plus = v4 + if v4 != 0 { + f += 4 + } + width = Xwcstoul(tls, f, bp+512, int32(10)) + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 512)))) == int32('C') || **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 512)))) == int32('F') || **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 512)))) == int32('G') || **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 512)))) == int32('Y') { + if !(width != 0) && **(**uintptr)(__ccgo_up(bp + 512)) != f { + width = uint64(1) + } + } else { + width = uint64(0) + } + f = **(**uintptr)(__ccgo_up(bp + 512)) + if **(**Twchar_t)(__ccgo_up(f)) == int32('E') || **(**Twchar_t)(__ccgo_up(f)) == int32('O') { + f += 4 + } + t_mb = X__strftime_fmt_1(tls, bp+8, bp, **(**Twchar_t)(__ccgo_up(f)), tm, loc, pad) + if !(t_mb != 0) { + break + } + **(**Tsize_t)(__ccgo_up(bp)) = Xmbstowcs(tls, bp+108, t_mb, Uint64FromInt64(400)/Uint64FromInt64(4)) + if **(**Tsize_t)(__ccgo_up(bp)) == Uint64FromInt32(-Int32FromInt32(1)) { + return uint64(0) + } + t = bp + 108 + if width != 0 { + for { + if !(**(**Twchar_t)(__ccgo_up(t)) == int32('+') || **(**Twchar_t)(__ccgo_up(t)) == int32('-') || **(**Twchar_t)(__ccgo_up(t)) == int32('0') && **(**Twchar_t)(__ccgo_up(t + 1*4)) != 0) { + break + } + goto _5 + _5: + ; + t += 4 + **(**Tsize_t)(__ccgo_up(bp)) = **(**Tsize_t)(__ccgo_up(bp)) - 1 + } + width = width - 1 + if plus != 0 && (*Ttm)(unsafe.Pointer(tm)).Ftm_year >= Int32FromInt32(10000)-Int32FromInt32(1900) { + v2 = l + l = l + 1 + **(**Twchar_t)(__ccgo_up(s + uintptr(v2)*4)) = int32('+') + } else { + if (*Ttm)(unsafe.Pointer(tm)).Ftm_year < -int32(1900) { + v2 = l + l = l + 1 + **(**Twchar_t)(__ccgo_up(s + uintptr(v2)*4)) = int32('-') + } else { + width = width + 1 + } + } + for { + if !(width > **(**Tsize_t)(__ccgo_up(bp)) && l < n) { + break + } + v2 = l + l = l + 1 + **(**Twchar_t)(__ccgo_up(s + uintptr(v2)*4)) = int32('0') + goto _8 + _8: + ; + width = width - 1 + } + } + if **(**Tsize_t)(__ccgo_up(bp)) >= n-l { + **(**Tsize_t)(__ccgo_up(bp)) = n - l + } + Xwmemcpy(tls, s+uintptr(l)*4, t, **(**Tsize_t)(__ccgo_up(bp))) + l = l + **(**Tsize_t)(__ccgo_up(bp)) + goto _1 + _1: + ; + f += 4 + } + if n != 0 { + if l == n { + l = n - uint64(1) + } + **(**Twchar_t)(__ccgo_up(s + uintptr(l)*4)) = 0 + } + return uint64(0) +} + +func Xwcsftime(tls *TLS, wcs uintptr, n Tsize_t, f uintptr, tm uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v wcs=%v n=%v f=%v tm=%v, (%v:)", tls, wcs, n, f, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wcsftime_l(tls, wcs, n, f, tm, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xwcsftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v loc=%v, (%v:)", tls, s, n, f, tm, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wcsftime_l(tls, s, n, f, tm, loc) +} + +func X_exit(tls *TLS, status int32) { + if __ccgo_strace { + trc("tls=%v status=%v, (%v:)", tls, status, origin(2)) + } + X_Exit(tls, status) +} + +func Xaccess(tls *TLS, filename uintptr, amode int32) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v amode=%v, (%v:)", tls, filename, amode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_access), int64(filename), int64(amode))))) +} + +func Xacct(tls *TLS, filename uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v, (%v:)", tls, filename, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_acct), int64(filename))))) +} + +func Xalarm(tls *TLS, seconds uint32) (r uint32) { + if __ccgo_strace { + trc("tls=%v seconds=%v, (%v:)", tls, seconds, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var _ /* it at bp+0 */ Titimerval + var _ /* old at bp+32 */ Titimerval + **(**Titimerval)(__ccgo_up(bp)) = Titimerval{ + Fit_value: Ttimeval{ + Ftv_sec: Int64FromUint32(seconds), + }, + } + **(**Titimerval)(__ccgo_up(bp + 32)) = Titimerval{} + Xsetitimer(tls, ITIMER_REAL, bp, bp+32) + return Uint32FromInt64((**(**Titimerval)(__ccgo_up(bp + 32))).Fit_value.Ftv_sec + BoolInt64(!!((**(**Titimerval)(__ccgo_up(bp + 32))).Fit_value.Ftv_usec != 0))) +} + +func Xchdir(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_chdir), int64(path))))) +} + +func Xchown(tls *TLS, path uintptr, uid Tuid_t, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v uid=%v gid=%v, (%v:)", tls, path, uid, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_chown), int64(path), Int64FromUint32(uid), Int64FromUint32(gid))))) +} + +func _dummy12(tls *TLS, fd int32) (r int32) { + return fd +} + +func Xclose(tls *TLS, fd int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + fd = _dummy12(tls, fd) + r = int32(___syscall_cp(tls, int64(SYS_close), int64(fd), 0, 0, 0, 0, 0)) + if r == -int32(EINTR) { + r = 0 + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xctermid(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + if s != 0 { + v1 = Xstrcpy(tls, s, __ccgo_ts+358) + } else { + v1 = __ccgo_ts + 358 + } + return v1 +} + +func Xdup(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_dup), int64(fd))))) +} + +func Xdup2(tls *TLS, old int32, new1 int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v, (%v:)", tls, old, new1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v1 int32 + _, _ = r, v1 + for { + v1 = int32(X__syscall2(tls, int64(SYS_dup2), int64(old), int64(new1))) + r = v1 + if !(v1 == -int32(EBUSY)) { + break + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func X__dup3(tls *TLS, old int32, new1 int32, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v flags=%v, (%v:)", tls, old, new1, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v1 int32 + _, _ = r, v1 + if old == new1 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + if flags != 0 { + for { + v1 = int32(X__syscall3(tls, int64(SYS_dup3), int64(old), int64(new1), int64(flags))) + r = v1 + if !(v1 == -int32(EBUSY)) { + break + } + } + if r != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + if flags & ^Int32FromInt32(O_CLOEXEC) != 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + } + for { + v1 = int32(X__syscall2(tls, int64(SYS_dup2), int64(old), int64(new1))) + r = v1 + if !(v1 == -int32(EBUSY)) { + break + } + } + if r >= 0 && flags&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(new1), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xdup3(tls *TLS, old int32, new1 int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v flags=%v, (%v:)", tls, old, new1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__dup3(tls, old, new1, flags) +} + +type Tctx1 = struct { + Ffd int32 + Ffilename uintptr + Famode int32 + Fp int32 +} + +func _checker(tls *TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c uintptr + var _ /* ret at bp+0 */ int32 + _ = c + c = p + if X__syscall2(tls, int64(SYS_setregid), X__syscall0(tls, int64(SYS_getegid)), int64(-Int32FromInt32(1))) != 0 || X__syscall2(tls, int64(SYS_setreuid), X__syscall0(tls, int64(SYS_geteuid)), int64(-Int32FromInt32(1))) != 0 { + X__syscall1(tls, int64(SYS_exit), int64(Int32FromInt32(1))) + } + **(**int32)(__ccgo_up(bp)) = int32(X__syscall4(tls, int64(SYS_faccessat), int64((*Tctx1)(unsafe.Pointer(c)).Ffd), int64((*Tctx1)(unsafe.Pointer(c)).Ffilename), int64((*Tctx1)(unsafe.Pointer(c)).Famode), int64(Int32FromInt32(0)))) + X__syscall3(tls, int64(SYS_write), int64((*Tctx1)(unsafe.Pointer(c)).Fp), int64(bp), Int64FromUint64(Uint64FromInt64(4))) + return 0 +} + +func Xfaccessat(tls *TLS, fd int32, filename uintptr, amode int32, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v filename=%v amode=%v flag=%v, (%v:)", tls, fd, filename, amode, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + if flag != 0 { + ret = int32(X__syscall4(tls, int64(SYS_faccessat2), int64(fd), int64(filename), int64(amode), int64(flag))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + } + if flag & ^Int32FromInt32(AT_EACCESS) != 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_faccessat), int64(fd), int64(filename), int64(amode))))) +} + +func Xfchdir(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ret int32 + var _ /* buf at bp+0 */ [27]int8 + _ = ret + ret = int32(X__syscall1(tls, int64(SYS_fchdir), int64(fd))) + if ret != -int32(EBADF) || X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFD))) < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + X__procfdname(tls, bp, Uint32FromInt32(fd)) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_chdir), int64(bp))))) +} + +func Xfchown(tls *TLS, fd int32, uid Tuid_t, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v uid=%v gid=%v, (%v:)", tls, fd, uid, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ret int32 + var _ /* buf at bp+0 */ [27]int8 + _ = ret + ret = int32(X__syscall3(tls, int64(SYS_fchown), int64(fd), Int64FromUint32(uid), Int64FromUint32(gid))) + if ret != -int32(EBADF) || X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFD))) < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + X__procfdname(tls, bp, Uint32FromInt32(fd)) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_chown), int64(bp), Int64FromUint32(uid), Int64FromUint32(gid))))) +} + +func Xfchownat(tls *TLS, fd int32, path uintptr, uid Tuid_t, gid Tgid_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v uid=%v gid=%v flag=%v, (%v:)", tls, fd, path, uid, gid, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fchownat), int64(fd), int64(path), Int64FromUint32(uid), Int64FromUint32(gid), int64(flag))))) +} + +func Xfdatasync(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_fdatasync), int64(fd), 0, 0, 0, 0, 0)))) +} + +func Xfsync(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_fsync), int64(fd), 0, 0, 0, 0, 0)))) +} + +func Xftruncate(tls *TLS, fd int32, length Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v length=%v, (%v:)", tls, fd, length, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_ftruncate), int64(fd), length)))) +} + +func Xgetcwd(tls *TLS, buf uintptr, size Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v buf=%v size=%v, (%v:)", tls, buf, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int64 + var tmp, v3 uintptr + var v1 t__predefined_size_t + var v2 int32 + _, _, _, _, _ = ret, tmp, v1, v2, v3 + defer func() { Xrealloc(tls, tmp, 0) }() + if buf != 0 { + v2 = int32(1) + } else { + v2 = int32(PATH_MAX) + } + v1 = Uint64FromInt32(v2) + tmp = Xrealloc(tls, tmp, v1) + if !(buf != 0) { + buf = tmp + size = v1 + } else { + if !(size != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + } + ret = X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getcwd), int64(buf), Int64FromUint64(size)))) + if ret < 0 { + return uintptr(0) + } + if ret == 0 || int32(**(**int8)(__ccgo_up(buf))) != int32('/') { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(0) + } + if buf == tmp { + v3 = Xstrdup(tls, buf) + } else { + v3 = buf + } + return v3 +} + +func Xgetegid(tls *TLS) (r Tgid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall0(tls, int64(SYS_getegid))) +} + +func Xgeteuid(tls *TLS) (r Tuid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall0(tls, int64(SYS_geteuid))) +} + +func Xgetgid(tls *TLS) (r Tgid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall0(tls, int64(SYS_getgid))) +} + +func Xgetgroups(tls *TLS, count int32, list uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v count=%v list=%v, (%v:)", tls, count, list, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getgroups), int64(count), int64(list))))) +} + +func Xgethostname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v len1=%v, (%v:)", tls, name, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(400) + defer tls.Free(400) + var i Tsize_t + var v2 int8 + var v3 bool + var _ /* uts at bp+0 */ Tutsname1 + _, _, _ = i, v2, v3 + if Xuname(tls, bp) != 0 { + return -int32(1) + } + if len1 > uint64(65) { + len1 = uint64(65) + } + i = uint64(0) + for { + if v3 = i < len1; v3 { + v2 = **(**int8)(__ccgo_up(bp + 65 + uintptr(i))) + **(**int8)(__ccgo_up(name + uintptr(i))) = v2 + } + if !(v3 && v2 != 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i != 0 && i == len1 { + **(**int8)(__ccgo_up(name + uintptr(i-uint64(1)))) = 0 + } + return 0 +} + +func Xgetlogin(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetenv(tls, __ccgo_ts+1914) +} + +func Xgetlogin_r(tls *TLS, name uintptr, size Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v size=%v, (%v:)", tls, name, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + var logname uintptr + _ = logname + logname = Xgetlogin(tls) + if !(logname != 0) { + return int32(ENXIO) + } /* or...? */ + if _strlen(tls, logname) >= size { + return int32(ERANGE) + } + Xstrcpy(tls, name, logname) + return 0 +} + +func Xgetpgid(tls *TLS, pid Tpid_t) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v pid=%v, (%v:)", tls, pid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_getpgid), int64(pid))))) +} + +func Xgetpgrp(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall1(tls, int64(SYS_getpgid), int64(Int32FromInt32(0)))) +} + +func Xgetpid(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall0(tls, int64(SYS_getpid))) +} + +func Xgetppid(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall0(tls, int64(SYS_getppid))) +} + +func Xgetsid(tls *TLS, pid Tpid_t) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v pid=%v, (%v:)", tls, pid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_getsid), int64(pid))))) +} + +func Xgetuid(tls *TLS) (r Tuid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall0(tls, int64(SYS_getuid))) +} + +func Xisatty(tls *TLS, fd int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r uint64 + var _ /* wsz at bp+0 */ Twinsize + _ = r + r = Uint64FromInt64(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TIOCGWINSZ)), int64(bp))))) + if r == uint64(0) { + return int32(1) + } + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(EBADF) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOTTY) + } + return 0 +} + +func Xlchown(tls *TLS, path uintptr, uid Tuid_t, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v uid=%v gid=%v, (%v:)", tls, path, uid, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_lchown), int64(path), Int64FromUint32(uid), Int64FromUint32(gid))))) +} + +func Xlink(tls *TLS, existing uintptr, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v existing=%v new1=%v, (%v:)", tls, existing, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_link), int64(existing), int64(new1))))) +} + +func Xlinkat(tls *TLS, fd1 int32, existing uintptr, fd2 int32, new1 uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd1=%v existing=%v fd2=%v new1=%v flag=%v, (%v:)", tls, fd1, existing, fd2, new1, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_linkat), int64(fd1), int64(existing), int64(fd2), int64(new1), int64(flag))))) +} + +func X__lseek(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v fd=%v offset=%v whence=%v, (%v:)", tls, fd, offset, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_lseek), int64(fd), offset, int64(whence)))) +} + +func Xlseek(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v fd=%v offset=%v whence=%v, (%v:)", tls, fd, offset, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lseek(tls, fd, offset, whence) +} + +func Xnice(tls *TLS, inc int32) (r int32) { + if __ccgo_strace { + trc("tls=%v inc=%v, (%v:)", tls, inc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var prio int32 + _ = prio + prio = inc + // Only query old priority if it can affect the result. + // This also avoids issues with integer overflow. + if inc > -Int32FromInt32(2)*Int32FromInt32(NZERO) && inc < Int32FromInt32(2)*Int32FromInt32(NZERO) { + prio = prio + Xgetpriority(tls, PRIO_PROCESS, uint32(0)) + } + if prio > Int32FromInt32(NZERO)-Int32FromInt32(1) { + prio = Int32FromInt32(NZERO) - Int32FromInt32(1) + } + if prio < -int32(NZERO) { + prio = -int32(NZERO) + } + if Xsetpriority(tls, PRIO_PROCESS, uint32(0), prio) != 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EACCES) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EPERM) + } + return -int32(1) + } else { + return prio + } + return r +} + +func Xpause(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pause), 0, 0, 0, 0, 0, 0)))) +} + +func Xpipe(tls *TLS, fd uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_pipe), int64(fd))))) +} + +func Xpipe2(tls *TLS, fd uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v flag=%v, (%v:)", tls, fd, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + if !(flag != 0) { + return Xpipe(tls, fd) + } + ret = int32(X__syscall2(tls, int64(SYS_pipe2), int64(fd), int64(flag))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + if flag & ^(Int32FromInt32(O_CLOEXEC)|Int32FromInt32(O_NONBLOCK)) != 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + ret = Xpipe(tls, fd) + if ret != 0 { + return ret + } + if flag&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd))), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd + 1*4))), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if flag&int32(O_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd))), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd + 1*4))), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + return 0 +} + +func Xposix_close(tls *TLS, fd int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v flags=%v, (%v:)", tls, fd, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xclose(tls, fd) +} + +func Xpread(tls *TLS, fd int32, buf uintptr, size Tsize_t, ofs Toff_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v size=%v ofs=%v, (%v:)", tls, fd, buf, size, ofs, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pread64), int64(fd), int64(buf), Int64FromUint64(size), ofs, 0, 0))) +} + +func Xpreadv(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v ofs=%v, (%v:)", tls, fd, iov, count, ofs, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_preadv), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), 0))) +} + +func Xpwrite(tls *TLS, fd int32, buf uintptr, size Tsize_t, ofs Toff_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v size=%v ofs=%v, (%v:)", tls, fd, buf, size, ofs, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pwrite64), int64(fd), int64(buf), Int64FromUint64(size), ofs, 0, 0))) +} + +func Xpwritev(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v ofs=%v, (%v:)", tls, fd, iov, count, ofs, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pwritev), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), 0))) +} + +func Xread(tls *TLS, fd int32, buf uintptr, count Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v count=%v, (%v:)", tls, fd, buf, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, SYS_read, int64(fd), int64(buf), Int64FromUint64(count), 0, 0, 0))) +} + +func Xreadlink(tls *TLS, path uintptr, buf uintptr, bufsize Tsize_t) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v buf=%v bufsize=%v, (%v:)", tls, path, buf, bufsize, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r int32 + var _ /* dummy at bp+0 */ [1]int8 + _ = r + if !(bufsize != 0) { + buf = bp + bufsize = uint64(1) + } + r = int32(X__syscall3(tls, int64(SYS_readlink), int64(path), int64(buf), Int64FromUint64(bufsize))) + if buf == bp && r > 0 { + r = 0 + } + return X__syscall_ret(tls, Uint64FromInt32(r)) +} + +func Xreadlinkat(tls *TLS, fd int32, path uintptr, buf uintptr, bufsize Tsize_t) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v buf=%v bufsize=%v, (%v:)", tls, fd, path, buf, bufsize, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r int32 + var _ /* dummy at bp+0 */ [1]int8 + _ = r + if !(bufsize != 0) { + buf = bp + bufsize = uint64(1) + } + r = int32(X__syscall4(tls, int64(SYS_readlinkat), int64(fd), int64(path), int64(buf), Int64FromUint64(bufsize))) + if buf == bp && r > 0 { + r = 0 + } + return X__syscall_ret(tls, Uint64FromInt32(r)) +} + +func Xreadv(tls *TLS, fd int32, iov uintptr, count int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v, (%v:)", tls, fd, iov, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_readv), int64(fd), int64(iov), int64(count), 0, 0, 0))) +} + +func Xrenameat(tls *TLS, oldfd int32, old uintptr, newfd int32, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v oldfd=%v old=%v newfd=%v new1=%v, (%v:)", tls, oldfd, old, newfd, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_renameat), int64(oldfd), int64(old), int64(newfd), int64(new1))))) +} + +func Xrmdir(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_rmdir), int64(path))))) +} + +func Xsetgid(tls *TLS, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v gid=%v, (%v:)", tls, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__setxid(tls, int32(SYS_setgid), Int32FromUint32(gid), 0, 0) +} + +func Xsetpgid(tls *TLS, pid Tpid_t, pgid Tpid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v pid=%v pgid=%v, (%v:)", tls, pid, pgid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_setpgid), int64(pid), int64(pgid))))) +} + +func Xsetpgrp(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsetpgid(tls, 0, 0) +} + +func Xsetsid(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall0(tls, int64(SYS_setsid))))) +} + +func Xsetuid(tls *TLS, uid Tuid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v uid=%v, (%v:)", tls, uid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__setxid(tls, int32(SYS_setuid), Int32FromUint32(uid), 0, 0) +} + +type Tctx2 = struct { + Fid int32 + Feid int32 + Fsid int32 + Fnr int32 + Fret int32 +} + +func _do_setxid(tls *TLS, p uintptr) { + var c uintptr + var ret int32 + _, _ = c, ret + c = p + if (*Tctx2)(unsafe.Pointer(c)).Fret < 0 { + return + } + ret = int32(X__syscall3(tls, int64((*Tctx2)(unsafe.Pointer(c)).Fnr), int64((*Tctx2)(unsafe.Pointer(c)).Fid), int64((*Tctx2)(unsafe.Pointer(c)).Feid), int64((*Tctx2)(unsafe.Pointer(c)).Fsid))) + if ret != 0 && !((*Tctx2)(unsafe.Pointer(c)).Fret != 0) { + /* If one thread fails to set ids after another has already + * succeeded, forcibly killing the process is the only safe + * thing to do. State is inconsistent and dangerous. Use + * SIGKILL because it is uncatchable. */ + X__block_all_sigs(tls, uintptr(0)) + X__syscall2(tls, int64(SYS_kill), X__syscall0(tls, int64(SYS_getpid)), int64(Int32FromInt32(SIGKILL))) + } + (*Tctx2)(unsafe.Pointer(c)).Fret = ret +} + +func X__setxid(tls *TLS, nr int32, id int32, eid int32, sid int32) (r int32) { + if __ccgo_strace { + trc("tls=%v nr=%v id=%v eid=%v sid=%v, (%v:)", tls, nr, id, eid, sid, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1 int32 + var _ /* c at bp+0 */ Tctx2 + _ = v1 + /* ret is initially nonzero so that failure of the first thread does not + * trigger the safety kill above. */ + **(**Tctx2)(__ccgo_up(bp)) = Tctx2{ + Fid: id, + Feid: eid, + Fsid: sid, + Fnr: nr, + Fret: int32(1), + } + ___synccall(tls, __ccgo_fp(_do_setxid), bp) + if (**(**Tctx2)(__ccgo_up(bp))).Fret > 0 { + v1 = -int32(EAGAIN) + } else { + v1 = (**(**Tctx2)(__ccgo_up(bp))).Fret + } + return int32(X__syscall_ret(tls, Uint64FromInt32(v1))) +} + +func Xsleep(tls *TLS, seconds uint32) (r uint32) { + if __ccgo_strace { + trc("tls=%v seconds=%v, (%v:)", tls, seconds, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* tv at bp+0 */ Ttimespec + **(**Ttimespec)(__ccgo_up(bp)) = Ttimespec{ + Ftv_sec: Int64FromUint32(seconds), + } + if Xnanosleep(tls, bp, bp) != 0 { + return Uint32FromInt64((**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec) + } + return uint32(0) +} + +func Xsymlink(tls *TLS, existing uintptr, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v existing=%v new1=%v, (%v:)", tls, existing, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_symlink), int64(existing), int64(new1))))) +} + +func Xsymlinkat(tls *TLS, existing uintptr, fd int32, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v existing=%v fd=%v new1=%v, (%v:)", tls, existing, fd, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_symlinkat), int64(existing), int64(fd), int64(new1))))) +} + +func Xsync(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__syscall0(tls, int64(SYS_sync)) +} + +func Xtcgetpgrp(tls *TLS, fd int32) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* pgrp at bp+0 */ int32 + if Xioctl(tls, fd, int32(TIOCGPGRP), VaList(bp+16, bp)) < 0 { + return -int32(1) + } + return **(**int32)(__ccgo_up(bp)) +} + +func Xtcsetpgrp(tls *TLS, fd int32, pgrp Tpid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v pgrp=%v, (%v:)", tls, fd, pgrp, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* pgrp_int at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = pgrp + return Xioctl(tls, fd, int32(TIOCSPGRP), VaList(bp+16, bp)) +} + +func Xtruncate(tls *TLS, path uintptr, length Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v length=%v, (%v:)", tls, path, length, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_truncate), int64(path), length)))) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xttyname(tls *TLS, fd int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var result, v1 int32 + _, _ = result, v1 + v1 = Xttyname_r(tls, fd, uintptr(unsafe.Pointer(&_buf10)), uint64(32)) + result = v1 + if v1 != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = result + return UintptrFromInt32(0) + } + return uintptr(unsafe.Pointer(&_buf10)) +} + +var _buf10 [32]int8 + +func Xttyname_r(tls *TLS, fd int32, name uintptr, size Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v name=%v size=%v, (%v:)", tls, fd, name, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(320) + defer tls.Free(320) + var l Tssize_t + var _ /* procname at bp+288 */ [29]int8 + var _ /* st1 at bp+0 */ Tstat + var _ /* st2 at bp+144 */ Tstat + _ = l + if !(Xisatty(tls, fd) != 0) { + return **(**int32)(__ccgo_up(X__errno_location(tls))) + } + X__procfdname(tls, bp+288, Uint32FromInt32(fd)) + l = Xreadlink(tls, bp+288, name, size) + if l < 0 { + return **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + if Uint64FromInt64(l) == size { + return int32(ERANGE) + } + } + **(**int8)(__ccgo_up(name + uintptr(l))) = 0 + if Xstat(tls, name, bp) != 0 || Xfstat(tls, fd, bp+144) != 0 { + return **(**int32)(__ccgo_up(X__errno_location(tls))) + } + if (**(**Tstat)(__ccgo_up(bp))).Fst_dev != (**(**Tstat)(__ccgo_up(bp + 144))).Fst_dev || (**(**Tstat)(__ccgo_up(bp))).Fst_ino != (**(**Tstat)(__ccgo_up(bp + 144))).Fst_ino { + return int32(ENODEV) + } + return 0 +} + +func Xualarm(tls *TLS, value uint32, interval uint32) (r uint32) { + if __ccgo_strace { + trc("tls=%v value=%v interval=%v, (%v:)", tls, value, interval, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var _ /* it at bp+0 */ Titimerval + var _ /* it_old at bp+32 */ Titimerval + **(**Titimerval)(__ccgo_up(bp)) = Titimerval{ + Fit_interval: Ttimeval{ + Ftv_usec: Int64FromUint32(interval), + }, + Fit_value: Ttimeval{ + Ftv_usec: Int64FromUint32(value), + }, + } + Xsetitimer(tls, ITIMER_REAL, bp, bp+32) + return Uint32FromInt64((**(**Titimerval)(__ccgo_up(bp + 32))).Fit_value.Ftv_sec*int64(1000000) + (**(**Titimerval)(__ccgo_up(bp + 32))).Fit_value.Ftv_usec) +} + +func Xunlink(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_unlink), int64(path))))) +} + +func Xunlinkat(tls *TLS, fd int32, path uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v flag=%v, (%v:)", tls, fd, path, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_unlinkat), int64(fd), int64(path), int64(flag))))) +} + +func Xusleep(tls *TLS, useconds uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v useconds=%v, (%v:)", tls, useconds, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* tv at bp+0 */ Ttimespec + **(**Ttimespec)(__ccgo_up(bp)) = Ttimespec{ + Ftv_sec: Int64FromUint32(useconds / uint32(1000000)), + Ftv_nsec: Int64FromUint32(useconds % uint32(1000000) * uint32(1000)), + } + return Xnanosleep(tls, bp, bp) +} + +func Xwrite(tls *TLS, fd int32, buf uintptr, count Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v count=%v, (%v:)", tls, fd, buf, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_write), int64(fd), int64(buf), Int64FromUint64(count), 0, 0, 0))) +} + +func Xwritev(tls *TLS, fd int32, iov uintptr, count int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v, (%v:)", tls, fd, iov, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_writev), int64(fd), int64(iov), int64(count), 0, 0, 0))) +} + +func __ccgo_fp(f interface{}) uintptr { + type iface [2]uintptr + return (*iface)(unsafe.Pointer(&f))[1] +} + +func __ccgo_up(n uintptr) unsafe.Pointer { + return unsafe.Pointer(&n) +} + +var X__abort_lock [1]int32 + +var X__at_quick_exit_lockptr = uintptr(unsafe.Pointer(&_lock)) + +var X__c_dot_utf8 = t__locale_map{ + Fmap1: uintptr(unsafe.Pointer(&_empty_mo)), + Fmap_size: uint64(20), + Fname: [24]int8{'C', '.', 'U', 'T', 'F', '-', '8'}, +} + +var X__c_dot_utf8_locale = t__locale_struct{ + Fcat: [6]uintptr{ + 0: uintptr(unsafe.Pointer(&X__c_dot_utf8)), + }, +} + +var X__c_locale = t__locale_struct{} + +var Xdaylight int32 + +var X__eintr_valid_flag int32 + +var Xenviron uintptr + +var X__exp2f_data = Texp2f_data{ + Ftab: [32]Tuint64_t{ + 0: uint64(0x3ff0000000000000), + 1: uint64(0x3fefd9b0d3158574), + 2: uint64(0x3fefb5586cf9890f), + 3: uint64(0x3fef9301d0125b51), + 4: uint64(0x3fef72b83c7d517b), + 5: uint64(0x3fef54873168b9aa), + 6: uint64(0x3fef387a6e756238), + 7: uint64(0x3fef1e9df51fdee1), + 8: uint64(0x3fef06fe0a31b715), + 9: uint64(0x3feef1a7373aa9cb), + 10: uint64(0x3feedea64c123422), + 11: uint64(0x3feece086061892d), + 12: uint64(0x3feebfdad5362a27), + 13: uint64(0x3feeb42b569d4f82), + 14: uint64(0x3feeab07dd485429), + 15: uint64(0x3feea47eb03a5585), + 16: uint64(0x3feea09e667f3bcd), + 17: uint64(0x3fee9f75e8ec5f74), + 18: uint64(0x3feea11473eb0187), + 19: uint64(0x3feea589994cce13), + 20: uint64(0x3feeace5422aa0db), + 21: uint64(0x3feeb737b0cdc5e5), + 22: uint64(0x3feec49182a3f090), + 23: uint64(0x3feed503b23e255d), + 24: uint64(0x3feee89f995ad3ad), + 25: uint64(0x3feeff76f2fb5e47), + 26: uint64(0x3fef199bdd85529c), + 27: uint64(0x3fef3720dcef9069), + 28: uint64(0x3fef5818dcfba487), + 29: uint64(0x3fef7c97337b9b5f), + 30: uint64(0x3fefa4afa2a490da), + 31: uint64(0x3fefd0765b6e4540), + }, + Fshift_scaled: Float64FromFloat64(6.755399441055744e+15) / float64(Int32FromInt32(1)<>Int32FromInt32(6) | Uint32FromInt32(0x0), + 31: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x1), + 32: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x2), + 33: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x3), + 34: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x4), + 35: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x5), + 36: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x6), + 37: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x7), + 38: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x8), + 39: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x9), + 40: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xa), + 41: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xb), + 42: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xc), + 43: (Uint32FromUint32(0x40)-Uint32FromInt32(0xa0))<>Int32FromInt32(6) | Uint32FromInt32(0xd), + 44: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xe), + 45: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xf), + 46: (Uint32FromUint32(0)-Uint32FromInt32(0x90))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x0), + 47: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x1), + 48: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x2), + 49: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x3), + 50: (Uint32FromUint32(0x40)-Uint32FromInt32(0x90))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x4), +} + +var X__gettext_lockptr = uintptr(unsafe.Pointer(&_lock1)) + +var X__hwcap Tsize_t + +var X__libc t__libc + +var X__libc_version = [6]int8{'1', '.', '2', '.', '5'} + +var X__locale_lock [1]int32 + +var X__locale_lockptr = uintptr(unsafe.Pointer(&X__locale_lock)) + +var X__log2_data = Tlog2_data{ + Finvln2hi: float64(1.4426950407214463), + Finvln2lo: float64(1.6751713164886512e-10), + Fpoly: [6]float64{ + 0: -Float64FromFloat64(0.7213475204444882), + 1: float64(0.4808983469629985), + 2: -Float64FromFloat64(0.36067375954075914), + 3: float64(0.2885390073180969), + 4: -Float64FromFloat64(0.2404693555628422), + 5: float64(0.2061202382173603), + }, + Fpoly1: [10]float64{ + 0: -Float64FromFloat64(0.7213475204444817), + 1: float64(0.48089834696298744), + 2: -Float64FromFloat64(0.360673760222145), + 3: float64(0.2885390081805197), + 4: -Float64FromFloat64(0.24044917405728863), + 5: float64(0.2060992861022954), + 6: -Float64FromFloat64(0.18033596705327856), + 7: float64(0.1603032746063156), + 8: -Float64FromFloat64(0.14483316576701266), + 9: float64(0.13046826811283835), + }, + Ftab: [64]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.4463276106642393), + Flogc: -Float64FromFloat64(0.5323943771486483), + }, + 1: { + Finvc: float64(1.4301675812282968), + Flogc: -Float64FromFloat64(0.516184206053822), + }, + 2: { + Finvc: float64(1.4143648676229383), + Flogc: -Float64FromFloat64(0.5001543441974263), + }, + 3: { + Finvc: float64(1.3989068970611538), + Flogc: -Float64FromFloat64(0.4842999484799293), + }, + 4: { + Finvc: float64(1.3837838957784339), + Flogc: -Float64FromFloat64(0.46861865624623533), + }, + 5: { + Finvc: float64(1.368983882697786), + Flogc: -Float64FromFloat64(0.4531054615783887), + }, + 6: { + Finvc: float64(1.3544972916324536), + Flogc: -Float64FromFloat64(0.43775750882059583), + }, + 7: { + Finvc: float64(1.3403139676437443), + Flogc: -Float64FromFloat64(0.4225709906127122), + }, + 8: { + Finvc: float64(1.3264249304188642), + Flogc: -Float64FromFloat64(0.40754302793970965), + }, + 9: { + Finvc: float64(1.3128203652112156), + Flogc: -Float64FromFloat64(0.3926695240384106), + }, + 10: { + Finvc: float64(1.299492412370217), + Flogc: -Float64FromFloat64(0.3779482100565019), + }, + 11: { + Finvc: float64(1.28643198385998), + Flogc: -Float64FromFloat64(0.36337518101890964), + }, + 12: { + Finvc: float64(1.2736319291846832), + Flogc: -Float64FromFloat64(0.3489484089425332), + }, + 13: { + Finvc: float64(1.2610838968062879), + Flogc: -Float64FromFloat64(0.33466425780738973), + }, + 14: { + Finvc: float64(1.248780314313572), + Flogc: -Float64FromFloat64(0.3205197000629596), + }, + 15: { + Finvc: float64(1.2367150450059063), + Flogc: -Float64FromFloat64(0.3065131231801388), + }, + 16: { + Finvc: float64(1.2248804968401878), + Flogc: -Float64FromFloat64(0.2926410022678283), + }, + 17: { + Finvc: float64(1.2132702353497795), + Flogc: -Float64FromFloat64(0.2789009220805383), + }, + 18: { + Finvc: float64(1.2018780785715362), + Flogc: -Float64FromFloat64(0.2652905529862437), + }, + 19: { + Finvc: float64(1.190697765061355), + Flogc: -Float64FromFloat64(0.2518072602367738), + }, + 20: { + Finvc: float64(1.1797235410550593), + Flogc: -Float64FromFloat64(0.23844881494437686), + }, + 21: { + Finvc: float64(1.1689498986205256), + Flogc: -Float64FromFloat64(0.22521309705462045), + }, + 22: { + Finvc: float64(1.158371137408455), + Flogc: -Float64FromFloat64(0.21209756102439314), + }, + 23: { + Finvc: float64(1.1479820146386086), + Flogc: -Float64FromFloat64(0.1991000395789797), + }, + 24: { + Finvc: float64(1.1377775576851088), + Flogc: -Float64FromFloat64(0.18621852970682085), + }, + 25: { + Finvc: float64(1.127753150630225), + Flogc: -Float64FromFloat64(0.17345131655361), + }, + 26: { + Finvc: float64(1.1179037012282074), + Flogc: -Float64FromFloat64(0.16079591649577196), + }, + 27: { + Finvc: float64(1.1082251967632821), + Flogc: -Float64FromFloat64(0.14825107384353942), + }, + 28: { + Finvc: float64(1.098712461056607), + Flogc: -Float64FromFloat64(0.13581387465410444), + }, + 29: { + Finvc: float64(1.0893619091634283), + Flogc: -Float64FromFloat64(0.12348332762257996), + }, + 30: { + Finvc: float64(1.0801689912316736), + Flogc: -Float64FromFloat64(0.11125703807351783), + }, + 31: { + Finvc: float64(1.071129489697672), + Flogc: -Float64FromFloat64(0.09913289918449664), + }, + 32: { + Finvc: float64(1.0622406576750423), + Flogc: -Float64FromFloat64(0.08711065531497297), + }, + 33: { + Finvc: float64(1.0534977607927976), + Flogc: -Float64FromFloat64(0.07518724771330199), + }, + 34: { + Finvc: float64(1.044897877982342), + Flogc: -Float64FromFloat64(0.06336194888240243), + }, + 35: { + Finvc: float64(1.0364370289499079), + Flogc: -Float64FromFloat64(0.0516324649456692), + }, + 36: { + Finvc: float64(1.0281122132034575), + Flogc: -Float64FromFloat64(0.039997735929773626), + }, + 37: { + Finvc: float64(1.0199202450036955), + Flogc: -Float64FromFloat64(0.028456341769015125), + }, + 38: { + Finvc: float64(1.0118577522306755), + Flogc: -Float64FromFloat64(0.017006489068080555), + }, + 39: { + Finvc: float64(1.003921649236766), + Flogc: -Float64FromFloat64(0.005646678981520381), + }, + 40: { + Finvc: float64(0.9922480467550775), + Flogc: float64(0.011227277611396858), + }, + 41: { + Finvc: float64(0.9770993366178549), + Flogc: float64(0.033422853921138085), + }, + 42: { + Finvc: float64(0.9624059787315814), + Flogc: float64(0.05528248992573026), + }, + 43: { + Finvc: float64(0.9481480598286369), + Flogc: float64(0.07681573143713649), + }, + 44: { + Finvc: float64(0.9343065931261065), + Flogc: float64(0.09803204623631245), + }, + 45: { + Finvc: float64(0.9208633936884979), + Flogc: float64(0.11894094059630334), + }, + 46: { + Finvc: float64(0.9078013641840602), + Flogc: float64(0.13955143862290242), + }, + 47: { + Finvc: float64(0.8951048181512927), + Flogc: float64(0.15987146080919956), + }, + 48: { + Finvc: float64(0.882758574260473), + Flogc: float64(0.17990916589428707), + }, + 49: { + Finvc: float64(0.8707481902241709), + Flogc: float64(0.19967252559081317), + }, + 50: { + Finvc: float64(0.8590602881746972), + Flogc: float64(0.2191687127685782), + }, + 51: { + Finvc: float64(0.8476822044336688), + Flogc: float64(0.23840459427242422), + }, + 52: { + Finvc: float64(0.8366013284053287), + Flogc: float64(0.25738780610663525), + }, + 53: { + Finvc: float64(0.8258064913621258), + Flogc: float64(0.27612433583180973), + }, + 54: { + Finvc: float64(0.8152865101579193), + Flogc: float64(0.2946209507022104), + }, + 55: { + Finvc: float64(0.8050314363208223), + Flogc: float64(0.31288297359969874), + }, + 56: { + Finvc: float64(0.7950310492640542), + Flogc: float64(0.33091689015759584), + }, + 57: { + Finvc: float64(0.7852760432487271), + Flogc: float64(0.3487282100279572), + }, + 58: { + Finvc: float64(0.7757575660314712), + Flogc: float64(0.36632223233368677), + }, + 59: { + Finvc: float64(0.7664670566588946), + Flogc: float64(0.383704309808536), + }, + 60: { + Finvc: float64(0.7573965608078645), + Flogc: float64(0.4008792246509074), + }, + 61: { + Finvc: float64(0.7485380168514022), + Flogc: float64(0.41785250494945103), + }, + 62: { + Finvc: float64(0.7398844213755009), + Flogc: float64(0.4346281724315304), + }, + 63: { + Finvc: float64(0.7314286113178112), + Flogc: float64(0.45121103315341315), + }, + }, + Ftab2: [64]struct { + Fchi float64 + Fclo float64 + }{ + 0: { + Fchi: float64(0.6914062848739648), + Fclo: float64(4.339971893418182e-17), + }, + 1: { + Fchi: float64(0.6992187580850853), + Fclo: float64(7.805593338712074e-18), + }, + 2: { + Fchi: float64(0.7070311366547563), + Fclo: float64(3.20843320369626e-17), + }, + 3: { + Fchi: float64(0.7148438556567389), + Fclo: float64(4.336491946473985e-17), + }, + 4: { + Fchi: float64(0.7226561915128084), + Fclo: float64(4.681890319761607e-17), + }, + 5: { + Fchi: float64(0.730468789763508), + Fclo: -Float64FromFloat64(1.647126642147294e-17), + }, + 6: { + Fchi: float64(0.7382812842650944), + Fclo: float64(2.0846837208642192e-17), + }, + 7: { + Fchi: float64(0.7460938437864584), + Fclo: -Float64FromFloat64(7.82131795361932e-18), + }, + 8: { + Fchi: float64(0.7539062159244969), + Fclo: -Float64FromFloat64(3.470987810015201e-17), + }, + 9: { + Fchi: float64(0.761718835645205), + Fclo: float64(1.2996798345429576e-17), + }, + 10: { + Fchi: float64(0.7695312342578777), + Fclo: -Float64FromFloat64(5.2071007285622585e-17), + }, + 11: { + Fchi: float64(0.7773438569208053), + Fclo: -Float64FromFloat64(4.513636731226183e-17), + }, + 12: { + Fchi: float64(0.7851561955110148), + Fclo: -Float64FromFloat64(2.0797044446832382e-17), + }, + 13: { + Fchi: float64(0.7929686538163826), + Fclo: -Float64FromFloat64(1.9947626198727574e-17), + }, + 14: { + Fchi: float64(0.8007813612514213), + Fclo: float64(1.472064871061342e-17), + }, + 15: { + Fchi: float64(0.8085937047812207), + Fclo: float64(5.290804109377209e-17), + }, + 16: { + Fchi: float64(0.816406173973453), + Fclo: -Float64FromFloat64(1.129659587857177e-17), + }, + 17: { + Fchi: float64(0.8242186867064328), + Fclo: float64(3.901543738154691e-17), + }, + 18: { + Fchi: float64(0.8320311501051142), + Fclo: -Float64FromFloat64(3.212482853127187e-17), + }, + 19: { + Fchi: float64(0.8398436860662717), + Fclo: float64(5.220081794706035e-18), + }, + 20: { + Fchi: float64(0.8476562221566525), + Fclo: -Float64FromFloat64(5.37416378988278e-17), + }, + 21: { + Fchi: float64(0.8554686571084844), + Fclo: float64(4.291992377471359e-18), + }, + 22: { + Fchi: float64(0.8632811779454657), + Fclo: float64(1.7319616935225806e-17), + }, + 23: { + Fchi: float64(0.8710937865301015), + Fclo: float64(1.8251073579011692e-17), + }, + 24: { + Fchi: float64(0.8789064200163806), + Fclo: float64(1.2113671810693101e-17), + }, + 25: { + Fchi: float64(0.8867188705623812), + Fclo: -Float64FromFloat64(2.431195196496269e-17), + }, + 26: { + Fchi: float64(0.894531433164887), + Fclo: -Float64FromFloat64(2.258952781769403e-17), + }, + 27: { + Fchi: float64(0.9023436779100781), + Fclo: float64(4.3322028821617186e-17), + }, + 28: { + Fchi: float64(0.9101562378188762), + Fclo: -Float64FromFloat64(5.2414676705491076e-18), + }, + 29: { + Fchi: float64(0.9179685755379005), + Fclo: -Float64FromFloat64(2.3432856904274634e-17), + }, + 30: { + Fchi: float64(0.9257810658494647), + Fclo: float64(3.9914341909758727e-17), + }, + 31: { + Fchi: float64(0.9335939394986237), + Fclo: -Float64FromFloat64(1.8218382846902827e-17), + }, + 32: { + Fchi: float64(0.9414062555172099), + Fclo: float64(4.423669374431538e-17), + }, + 33: { + Fchi: float64(0.9492189136192009), + Fclo: -Float64FromFloat64(2.6059674623550364e-17), + }, + 34: { + Fchi: float64(0.9570313243730211), + Fclo: -Float64FromFloat64(4.947019261946595e-17), + }, + 35: { + Fchi: float64(0.9648439529540691), + Fclo: -Float64FromFloat64(5.4644837229582306e-17), + }, + 36: { + Fchi: float64(0.9726564738338594), + Fclo: -Float64FromFloat64(5.4656321533328614e-17), + }, + 37: { + Fchi: float64(0.9804688208697894), + Fclo: -Float64FromFloat64(1.782581090537996e-18), + }, + 38: { + Fchi: float64(0.98828120632121), + Fclo: -Float64FromFloat64(5.2277711573086786e-18), + }, + 39: { + Fchi: float64(0.9960936700192217), + Fclo: float64(4.1586638841164565e-17), + }, + 40: { + Fchi: float64(1.007812515499802), + Fclo: float64(9.540912389137736e-17), + }, + 41: { + Fchi: float64(1.0234373952820537), + Fclo: float64(3.985821704561347e-17), + }, + 42: { + Fchi: float64(1.0390625391978199), + Fclo: -Float64FromFloat64(5.179495640960355e-18), + }, + 43: { + Fchi: float64(1.0546875982436061), + Fclo: -Float64FromFloat64(6.074512782488841e-17), + }, + 44: { + Fchi: float64(1.07031247275489), + Fclo: -Float64FromFloat64(4.853656019321416e-17), + }, + 45: { + Fchi: float64(1.0859374005459401), + Fclo: -Float64FromFloat64(1.0233609026899023e-16), + }, + 46: { + Fchi: float64(1.101562565835984), + Fclo: float64(9.714504510281668e-17), + }, + 47: { + Fchi: float64(1.1171875960464082), + Fclo: -Float64FromFloat64(5.728631491659617e-17), + }, + 48: { + Fchi: float64(1.1328125595809087), + Fclo: -Float64FromFloat64(4.3353271744463366e-17), + }, + 49: { + Fchi: float64(1.1484376438870962), + Fclo: float64(5.029455257812864e-17), + }, + 50: { + Fchi: float64(1.1640626551656426), + Fclo: -Float64FromFloat64(1.3886091944776072e-17), + }, + 51: { + Fchi: float64(1.179687381390876), + Fclo: float64(9.535864385063222e-17), + }, + 52: { + Fchi: float64(1.19531246968748), + Fclo: float64(2.5970710873556995e-17), + }, + 53: { + Fchi: float64(1.2109374417129501), + Fclo: -Float64FromFloat64(1.0412863482435496e-16), + }, + 54: { + Fchi: float64(1.2265626715770166), + Fclo: float64(1.903080930681457e-17), + }, + 55: { + Fchi: float64(1.2421875157698543), + Fclo: float64(9.884933154288451e-17), + }, + 56: { + Fchi: float64(1.2578125104996614), + Fclo: float64(2.605028401046449e-17), + }, + 57: { + Fchi: float64(1.273437549250769), + Fclo: float64(3.128070230699857e-17), + }, + 58: { + Fchi: float64(1.2890625161616944), + Fclo: -Float64FromFloat64(4.506460293510891e-17), + }, + 59: { + Fchi: float64(1.3046875156762752), + Fclo: -Float64FromFloat64(2.0874781900380847e-17), + }, + 60: { + Fchi: float64(1.3203123063212308), + Fclo: float64(8.50535702424751e-17), + }, + 61: { + Fchi: float64(1.3359374907988373), + Fclo: -Float64FromFloat64(3.99657459893118e-17), + }, + 62: { + Fchi: float64(1.351562448282023), + Fclo: float64(4.1576596545784e-17), + }, + 63: { + Fchi: float64(1.3671874254389709), + Fclo: -Float64FromFloat64(6.072295450780066e-17), + }, + }, +} + +var X__log2f_data = Tlog2f_data{ + Ftab: [16]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.398907162146528), + Flogc: -Float64FromFloat64(0.48430022186289673), + }, + 1: { + Finvc: float64(1.3403141896637998), + Flogc: -Float64FromFloat64(0.42257122959194704), + }, + 2: { + Finvc: float64(1.286432210124115), + Flogc: -Float64FromFloat64(0.3633754347673556), + }, + 3: { + Finvc: float64(1.2367150214269895), + Flogc: -Float64FromFloat64(0.30651309567405577), + }, + 4: { + Finvc: float64(1.1906977166711752), + Flogc: -Float64FromFloat64(0.25180720160537634), + }, + 5: { + Finvc: float64(1.1479821020556429), + Flogc: -Float64FromFloat64(0.19910014943794563), + }, + 6: { + Finvc: float64(1.1082251448272158), + Flogc: -Float64FromFloat64(0.14825100623281615), + }, + 7: { + Finvc: float64(1.0711297413057381), + Flogc: -Float64FromFloat64(0.09913323807318392), + }, + 8: { + Finvc: float64(1.036437278977283), + Flogc: -Float64FromFloat64(0.051632812977629436), + }, + 9: { + Finvc: float64(1), + }, + 10: { + Finvc: float64(0.9492859795739057), + Flogc: float64(0.07508531937943004), + }, + 11: { + Finvc: float64(0.8951049428609004), + Flogc: float64(0.15987125980713107), + }, + 12: { + Finvc: float64(0.8476821620351103), + Flogc: float64(0.2384046664317681), + }, + 13: { + Finvc: float64(0.8050314851692001), + Flogc: float64(0.31288288605863257), + }, + 14: { + Finvc: float64(0.7664671008843108), + Flogc: float64(0.38370422656453185), + }, + 15: { + Finvc: float64(0.731428603316328), + Flogc: float64(0.451211048935815), + }, + }, + Fpoly: [4]float64{ + 0: -Float64FromFloat64(0.36051725506874704), + 1: float64(0.4811247078767291), + 2: -Float64FromFloat64(0.7213476299867769), + 3: float64(1.4426950186867042), + }, +} + +var X__log_data = Tlog_data{ + Fln2hi: float64(0.6931471805598903), + Fln2lo: float64(5.497923018708371e-14), + Fpoly: [5]float64{ + 0: -Float64FromFloat64(0.5000000000000001), + 1: float64(0.33333333331825593), + 2: -Float64FromFloat64(0.2499999999622955), + 3: float64(0.20000304511814496), + 4: -Float64FromFloat64(0.16667054827627667), + }, + Fpoly1: [11]float64{ + 0: -Float64FromFloat64(0.5), + 1: float64(0.3333333333333352), + 2: -Float64FromFloat64(0.24999999999998432), + 3: float64(0.19999999999320328), + 4: -Float64FromFloat64(0.16666666669929706), + 5: float64(0.14285715076560868), + 6: -Float64FromFloat64(0.12499997863982555), + 7: float64(0.11110712032936046), + 8: -Float64FromFloat64(0.10000486757818193), + 9: float64(0.09181994006195467), + 10: -Float64FromFloat64(0.08328363062289341), + }, + Ftab: [128]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.4504249240398293), + Flogc: -Float64FromFloat64(0.3718565645633589), + }, + 1: { + Finvc: float64(1.442253508327276), + Flogc: -Float64FromFloat64(0.36620682668944937), + }, + 2: { + Finvc: float64(1.4341736174350004), + Flogc: -Float64FromFloat64(0.3605888069791945), + }, + 3: { + Finvc: float64(1.426183816329995), + Flogc: -Float64FromFloat64(0.3550022171419869), + }, + 4: { + Finvc: float64(1.4182825527052965), + Flogc: -Float64FromFloat64(0.34944666968829097), + }, + 5: { + Finvc: float64(1.4104682921759335), + Flogc: -Float64FromFloat64(0.3439217713603284), + }, + 6: { + Finvc: float64(1.4027396147468003), + Flogc: -Float64FromFloat64(0.3384271921261188), + }, + 7: { + Finvc: float64(1.3950954438932313), + Flogc: -Float64FromFloat64(0.332962831494342), + }, + 8: { + Finvc: float64(1.3875338232485754), + Flogc: -Float64FromFloat64(0.32752794345742586), + }, + 9: { + Finvc: float64(1.3800539211058593), + Flogc: -Float64FromFloat64(0.32212257167088865), + }, + 10: { + Finvc: float64(1.3726542695419708), + Flogc: -Float64FromFloat64(0.3167462884799761), + }, + 11: { + Finvc: float64(1.3653332798446802), + Flogc: -Float64FromFloat64(0.3113985598928366), + }, + 12: { + Finvc: float64(1.358090204587874), + Flogc: -Float64FromFloat64(0.3060794515165526), + }, + 13: { + Finvc: float64(1.3509234892132138), + Flogc: -Float64FromFloat64(0.300788424667644), + }, + 14: { + Finvc: float64(1.3438320840699889), + Flogc: -Float64FromFloat64(0.2955252968476998), + }, + 15: { + Finvc: float64(1.3368146974742003), + Flogc: -Float64FromFloat64(0.29028969275850613), + }, + 16: { + Finvc: float64(1.329870114677736), + Flogc: -Float64FromFloat64(0.2850812793277555), + }, + 17: { + Finvc: float64(1.322997339161106), + Flogc: -Float64FromFloat64(0.27989987391470095), + }, + 18: { + Finvc: float64(1.316195352741367), + Flogc: -Float64FromFloat64(0.27474526621870154), + }, + 19: { + Finvc: float64(1.3094628125672239), + Flogc: -Float64FromFloat64(0.2696169863701243), + }, + 20: { + Finvc: float64(1.3027990455471041), + Flogc: -Float64FromFloat64(0.26451506180308115), + }, + 21: { + Finvc: float64(1.2962024229438942), + Flogc: -Float64FromFloat64(0.2594387762767383), + }, + 22: { + Finvc: float64(1.2896726275815547), + Flogc: -Float64FromFloat64(0.2543884090981692), + }, + 23: { + Finvc: float64(1.2832080305745537), + Flogc: -Float64FromFloat64(0.24936321635129843), + }, + 24: { + Finvc: float64(1.276807885983376), + Flogc: -Float64FromFloat64(0.24436312405975968), + }, + 25: { + Finvc: float64(1.2704714060687552), + Flogc: -Float64FromFloat64(0.23938801747897287), + }, + 26: { + Finvc: float64(1.2641976054949482), + Flogc: -Float64FromFloat64(0.23443761696705678), + }, + 27: { + Finvc: float64(1.257985357514882), + Flogc: -Float64FromFloat64(0.22951151871518505), + }, + 28: { + Finvc: float64(1.2518337750655457), + Flogc: -Float64FromFloat64(0.2246094963439873), + }, + 29: { + Finvc: float64(1.2457421919097305), + Flogc: -Float64FromFloat64(0.21973149037705753), + }, + 30: { + Finvc: float64(1.2397094966625508), + Flogc: -Float64FromFloat64(0.2148770752847895), + }, + 31: { + Finvc: float64(1.2337348463589233), + Flogc: -Float64FromFloat64(0.210046029103637), + }, + 32: { + Finvc: float64(1.2278176973028803), + Flogc: -Float64FromFloat64(0.20523836373934046), + }, + 33: { + Finvc: float64(1.2219570190618474), + Flogc: -Float64FromFloat64(0.20045368751368642), + }, + 34: { + Finvc: float64(1.2161519732977757), + Flogc: -Float64FromFloat64(0.1956917537758045), + }, + 35: { + Finvc: float64(1.2104018095009725), + Flogc: -Float64FromFloat64(0.19095237845203883), + }, + 36: { + Finvc: float64(1.204705805718973), + Flogc: -Float64FromFloat64(0.18623539250290833), + }, + 37: { + Finvc: float64(1.1990631185441964), + Flogc: -Float64FromFloat64(0.18154051731551135), + }, + 38: { + Finvc: float64(1.1934733004462308), + Flogc: -Float64FromFloat64(0.1768677957431919), + }, + 39: { + Finvc: float64(1.1879350812847385), + Flogc: -Float64FromFloat64(0.17221657406412305), + }, + 40: { + Finvc: float64(1.1824481322833125), + Flogc: -Float64FromFloat64(0.16758697765942543), + }, + 41: { + Finvc: float64(1.1770114976921955), + Flogc: -Float64FromFloat64(0.16297859687290384), + }, + 42: { + Finvc: float64(1.1716248121809465), + Flogc: -Float64FromFloat64(0.15839151377804228), + }, + 43: { + Finvc: float64(1.1662869231674715), + Flogc: -Float64FromFloat64(0.15382513241456763), + }, + 44: { + Finvc: float64(1.1609977486762766), + Flogc: -Float64FromFloat64(0.14927976358922024), + }, + 45: { + Finvc: float64(1.1557563220795803), + Flogc: -Float64FromFloat64(0.14475495398119165), + }, + 46: { + Finvc: float64(1.1505619105480347), + Flogc: -Float64FromFloat64(0.14025044090817573), + }, + 47: { + Finvc: float64(1.1454138888505974), + Flogc: -Float64FromFloat64(0.1357660466685502), + }, + 48: { + Finvc: float64(1.140311877374656), + Flogc: -Float64FromFloat64(0.1313018016355727), + }, + 49: { + Finvc: float64(1.1352550225747513), + Flogc: -Float64FromFloat64(0.12685731518763532), + }, + 50: { + Finvc: float64(1.1302429094831266), + Flogc: -Float64FromFloat64(0.1224325737671279), + }, + 51: { + Finvc: float64(1.1252747693068048), + Flogc: -Float64FromFloat64(0.11802724521862729), + }, + 52: { + Finvc: float64(1.1203501571039876), + Flogc: -Float64FromFloat64(0.11364127671663482), + }, + 53: { + Finvc: float64(1.1154683327680124), + Flogc: -Float64FromFloat64(0.10927434611278386), + }, + 54: { + Finvc: float64(1.1106291463292157), + Flogc: -Float64FromFloat64(0.10492665324943573), + }, + 55: { + Finvc: float64(1.1058315813301596), + Flogc: -Float64FromFloat64(0.10059761422644442), + }, + 56: { + Finvc: float64(1.1010752177696026), + Flogc: -Float64FromFloat64(0.09628717309055901), + }, + 57: { + Finvc: float64(1.0963597137952512), + Flogc: -Float64FromFloat64(0.09199534069557558), + }, + 58: { + Finvc: float64(1.0916844827550398), + Flogc: -Float64FromFloat64(0.08772190036688698), + }, + 59: { + Finvc: float64(1.0870487291277784), + Flogc: -Float64FromFloat64(0.08346643613867855), + }, + 60: { + Finvc: float64(1.082452357388312), + Flogc: -Float64FromFloat64(0.07922916827544668), + }, + 61: { + Finvc: float64(1.0778948225025884), + Flogc: -Float64FromFloat64(0.0750099004750382), + }, + 62: { + Finvc: float64(1.0733751731601076), + Flogc: -Float64FromFloat64(0.07080805133352897), + }, + 63: { + Finvc: float64(1.068893585073351), + Flogc: -Float64FromFloat64(0.06662408085151128), + }, + 64: { + Finvc: float64(1.0644491706655506), + Flogc: -Float64FromFloat64(0.06245745471915143), + }, + 65: { + Finvc: float64(1.0600414846328305), + Flogc: -Float64FromFloat64(0.0583080438042316), + }, + 66: { + Finvc: float64(1.0556701316181605), + Flogc: -Float64FromFloat64(0.05417576112313327), + }, + 67: { + Finvc: float64(1.051334750556926), + Flogc: -Float64FromFloat64(0.050060547896805474), + }, + 68: { + Finvc: float64(1.0470347288442157), + Flogc: -Float64FromFloat64(0.045962101199052086), + }, + 69: { + Finvc: float64(1.0427699229652954), + Flogc: -Float64FromFloat64(0.04188056008865715), + }, + 70: { + Finvc: float64(1.0385395013738175), + Flogc: -Float64FromFloat64(0.03781540056183985), + }, + 71: { + Finvc: float64(1.034343418940345), + Flogc: -Float64FromFloat64(0.03376684757915882), + }, + 72: { + Finvc: float64(1.0301811073173315), + Flogc: -Float64FromFloat64(0.029734619131772888), + }, + 73: { + Finvc: float64(1.026052043621297), + Flogc: -Float64FromFloat64(0.025718470239212365), + }, + 74: { + Finvc: float64(1.0219561082336197), + Flogc: -Float64FromFloat64(0.021718543925430822), + }, + 75: { + Finvc: float64(1.0178926505784922), + Flogc: -Float64FromFloat64(0.01773446126981071), + }, + 76: { + Finvc: float64(1.0138614436244586), + Flogc: -Float64FromFloat64(0.013766252464051831), + }, + 77: { + Finvc: float64(1.0098620186501341), + Flogc: -Float64FromFloat64(0.009813706322574944), + }, + 78: { + Finvc: float64(1.0058938559734134), + Flogc: -Float64FromFloat64(0.005876555150052809), + }, + 79: { + Finvc: float64(1.00195696235014), + Flogc: -Float64FromFloat64(0.0019550499938532084), + }, + 80: { + Finvc: float64(0.9961089923088509), + Flogc: float64(0.0038985973556009412), + }, + 81: { + Finvc: float64(0.9884170338185201), + Flogc: float64(0.011650571286395461), + }, + 82: { + Finvc: float64(0.9808429191005297), + Flogc: float64(0.019342955478919066), + }, + 83: { + Finvc: float64(0.9733840169987446), + Flogc: float64(0.0269766014846482), + }, + 84: { + Finvc: float64(0.9660377568876556), + Flogc: float64(0.034552359728422744), + }, + 85: { + Finvc: float64(0.9588014945307369), + Flogc: float64(0.04207121767183253), + }, + 86: { + Finvc: float64(0.9516728569073111), + Flogc: float64(0.049533940950141186), + }, + 87: { + Finvc: float64(0.9446494635965822), + Flogc: float64(0.056941358295944156), + }, + 88: { + Finvc: float64(0.9377288993026223), + Flogc: float64(0.06429439168346107), + }, + 89: { + Finvc: float64(0.9309091073790681), + Flogc: float64(0.0715936354946507), + }, + 90: { + Finvc: float64(0.924187681612722), + Flogc: float64(0.07884010933776153), + }, + 91: { + Finvc: float64(0.9175626765599192), + Flogc: float64(0.08603438905970506), + }, + 92: { + Finvc: float64(0.9110320403624034), + Flogc: float64(0.09317721180013905), + }, + 93: { + Finvc: float64(0.9045935839762024), + Flogc: float64(0.10026951462748457), + }, + 94: { + Finvc: float64(0.8982456375922825), + Flogc: float64(0.10731170956330516), + }, + 95: { + Finvc: float64(0.8919860966782501), + Flogc: float64(0.11430473320717738), + }, + 96: { + Finvc: float64(0.8858131121185129), + Flogc: float64(0.12124928503033061), + }, + 97: { + Finvc: float64(0.879725075760676), + Flogc: float64(0.12814583422959913), + }, + 98: { + Finvc: float64(0.8737201372634685), + Flogc: float64(0.1349951636851756), + }, + 99: { + Finvc: float64(0.8677966405782273), + Flogc: float64(0.1417978768189414), + }, + 100: { + Finvc: float64(0.8619528050060739), + Flogc: float64(0.14855476039031146), + }, + 101: { + Finvc: float64(0.8561872354420692), + Flogc: float64(0.1552661937658968), + }, + 102: { + Finvc: float64(0.8504983927816893), + Flogc: float64(0.16193275688146969), + }, + 103: { + Finvc: float64(0.8448844572790304), + Flogc: float64(0.16855539792220497), + }, + 104: { + Finvc: float64(0.8393442741575965), + Flogc: float64(0.1751343179947753), + }, + 105: { + Finvc: float64(0.8338762249349438), + Flogc: float64(0.1816702989864325), + }, + 106: { + Finvc: float64(0.8284789320557778), + Flogc: float64(0.18816387146023317), + }, + 107: { + Finvc: float64(0.8231510800065832), + Flogc: float64(0.1946155228479256), + }, + 108: { + Finvc: float64(0.8178913903778707), + Flogc: float64(0.20102572579389744), + }, + 109: { + Finvc: float64(0.8126984007245374), + Flogc: float64(0.2073952090795501), + }, + 110: { + Finvc: float64(0.8075710029460227), + Flogc: float64(0.21372429840596396), + }, + 111: { + Finvc: float64(0.8025078881160415), + Flogc: float64(0.2200135945981856), + }, + 112: { + Finvc: float64(0.7975077379364331), + Flogc: float64(0.22626374162859975), + }, + 113: { + Finvc: float64(0.792569604966373), + Flogc: float64(0.23247494747693054), + }, + 114: { + Finvc: float64(0.7876923641254114), + Flogc: float64(0.23864766620658884), + }, + 115: { + Finvc: float64(0.7828746724940998), + Flogc: float64(0.24478265647405806), + }, + 116: { + Finvc: float64(0.7781155388790811), + Flogc: float64(0.25088025827324145), + }, + 117: { + Finvc: float64(0.7734139557869777), + Flogc: float64(0.2569408552510595), + }, + 118: { + Finvc: float64(0.7687687179914933), + Flogc: float64(0.26296511155101143), + }, + 119: { + Finvc: float64(0.7641790698041854), + Flogc: float64(0.2689531327189343), + }, + 120: { + Finvc: float64(0.7596438763692399), + Flogc: float64(0.27490553924610595), + }, + 121: { + Finvc: float64(0.7551621951078668), + Flogc: float64(0.2808227248478943), + }, + 122: { + Finvc: float64(0.7507331780216866), + Flogc: float64(0.286704979267256), + }, + 123: { + Finvc: float64(0.7463557196361751), + Flogc: float64(0.29255295645509705), + }, + 124: { + Finvc: float64(0.7420289364869653), + Flogc: float64(0.2983670386142876), + }, + 125: { + Finvc: float64(0.7377521537065876), + Flogc: float64(0.30414734587282055), + }, + 126: { + Finvc: float64(0.7335242966002608), + Flogc: float64(0.30989455774829366), + }, + 127: { + Finvc: float64(0.729344777457841), + Flogc: float64(0.31560871301871884), + }, + }, + Ftab2: [128]struct { + Fchi float64 + Fclo float64 + }{ + 0: { + Fchi: float64(0.6894531274426304), + Fclo: float64(2.60290652810535e-17), + }, + 1: { + Fchi: float64(0.6933593811533166), + Fclo: float64(5.1607448519931415e-17), + }, + 2: { + Fchi: float64(0.6972656502972674), + Fclo: float64(5.290672414887869e-17), + }, + 3: { + Fchi: float64(0.7011718886092148), + Fclo: float64(7.801030634806013e-18), + }, + 4: { + Fchi: float64(0.7050781228976939), + Fclo: -Float64FromFloat64(2.471355337688684e-17), + }, + 5: { + Fchi: float64(0.7089843887644558), + Fclo: -Float64FromFloat64(4.6413389636862956e-17), + }, + 6: { + Fchi: float64(0.7128906815542553), + Fclo: float64(3.3387408065940366e-17), + }, + 7: { + Fchi: float64(0.7167968359278303), + Fclo: -Float64FromFloat64(2.6454587338050098e-17), + }, + 8: { + Fchi: float64(0.7207031520563163), + Fclo: float64(2.4284096334522285e-17), + }, + 9: { + Fchi: float64(0.7246093683054673), + Fclo: float64(4.85782435031982e-17), + }, + 10: { + Fchi: float64(0.7285155644718035), + Fclo: -Float64FromFloat64(1.3014776598894487e-17), + }, + 11: { + Fchi: float64(0.7324219036935506), + Fclo: -Float64FromFloat64(1.0402317671225898e-17), + }, + 12: { + Fchi: float64(0.73632811474659), + Fclo: float64(3.078291427467431e-17), + }, + 13: { + Fchi: float64(0.7402343715130797), + Fclo: -Float64FromFloat64(1.4304998976623033e-17), + }, + 14: { + Fchi: float64(0.7441405900738403), + Fclo: -Float64FromFloat64(2.8625955785571303e-17), + }, + 15: { + Fchi: float64(0.7480468324364), + Fclo: float64(5.1609093535635645e-17), + }, + 16: { + Fchi: float64(0.7519531335902885), + Fclo: float64(4.423423949536319e-17), + }, + 17: { + Fchi: float64(0.7558594189116706), + Fclo: -Float64FromFloat64(4.683016762099508e-17), + }, + 18: { + Fchi: float64(0.7597656365502305), + Fclo: float64(4.466742007514772e-17), + }, + 19: { + Fchi: float64(0.7636719350887737), + Fclo: -Float64FromFloat64(4.8134498775190266e-17), + }, + 20: { + Fchi: float64(0.767578087670501), + Fclo: -Float64FromFloat64(4.3371015350542286e-17), + }, + 21: { + Fchi: float64(0.7714844396979536), + Fclo: -Float64FromFloat64(2.515644472251707e-17), + }, + 22: { + Fchi: float64(0.7753905747966752), + Fclo: -Float64FromFloat64(4.163636184961329e-17), + }, + 23: { + Fchi: float64(0.7792968686084766), + Fclo: float64(3.3837161384165165e-17), + }, + 24: { + Fchi: float64(0.783203182701066), + Fclo: float64(4.379206565056758e-17), + }, + 25: { + Fchi: float64(0.7871094109030913), + Fclo: float64(2.7322930976146396e-17), + }, + 26: { + Fchi: float64(0.7910155783031153), + Fclo: -Float64FromFloat64(5.463661225364046e-17), + }, + 27: { + Fchi: float64(0.7949218121071572), + Fclo: -Float64FromFloat64(1.4320502634189868e-17), + }, + 28: { + Fchi: float64(0.7988281031542229), + Fclo: -Float64FromFloat64(4.0766731402809024e-17), + }, + 29: { + Fchi: float64(0.8027343109146796), + Fclo: -Float64FromFloat64(4.0338264352540086e-17), + }, + 30: { + Fchi: float64(0.8066405901480322), + Fclo: float64(1.7241428071650815e-18), + }, + 31: { + Fchi: float64(0.8105469363625933), + Fclo: -Float64FromFloat64(4.5534218930924523e-17), + }, + 32: { + Fchi: float64(0.8144531571720115), + Fclo: float64(1.821216920589142e-17), + }, + 33: { + Fchi: float64(0.8183593894061396), + Fclo: float64(4.9864288025894273e-17), + }, + 34: { + Fchi: float64(0.8222656559018297), + Fclo: float64(4.335990416726689e-17), + }, + 35: { + Fchi: float64(0.8261719308006343), + Fclo: -Float64FromFloat64(5.422001471661127e-17), + }, + 36: { + Fchi: float64(0.830078177803083), + Fclo: -Float64FromFloat64(5.333603728929035e-17), + }, + 37: { + Fchi: float64(0.8339844538076674), + Fclo: -Float64FromFloat64(1.1270648442682386e-17), + }, + 38: { + Fchi: float64(0.8378905498984414), + Fclo: -Float64FromFloat64(3.165126734800398e-17), + }, + 39: { + Fchi: float64(0.8417968420618669), + Fclo: float64(1.1286283062565865e-17), + }, + 40: { + Fchi: float64(0.8457030568173808), + Fclo: float64(5.643595964448442e-18), + }, + 41: { + Fchi: float64(0.8496093725173733), + Fclo: -Float64FromFloat64(2.1687834632368187e-17), + }, + 42: { + Fchi: float64(0.8535155534462677), + Fclo: -Float64FromFloat64(2.2548234217914977e-17), + }, + 43: { + Fchi: float64(0.8574219432077146), + Fclo: float64(4.683260556353139e-17), + }, + 44: { + Fchi: float64(0.8613281129443706), + Fclo: float64(2.5148296884122795e-17), + }, + 45: { + Fchi: float64(0.8652342893532053), + Fclo: -Float64FromFloat64(8.672187570949467e-18), + }, + 46: { + Fchi: float64(0.8691405397938828), + Fclo: -Float64FromFloat64(1.2576268285559751e-17), + }, + 47: { + Fchi: float64(0.8730468608194392), + Fclo: -Float64FromFloat64(2.9930851265148e-17), + }, + 48: { + Fchi: float64(0.8769530685783117), + Fclo: float64(4.814801507681644e-17), + }, + 49: { + Fchi: float64(0.8808593488818101), + Fclo: -Float64FromFloat64(9.10549533611022e-18), + }, + 50: { + Fchi: float64(0.8847655593409667), + Fclo: -Float64FromFloat64(3.512414651620766e-17), + }, + 51: { + Fchi: float64(0.888671840226208), + Fclo: float64(3.555261815374023e-17), + }, + 52: { + Fchi: float64(0.8925780870017613), + Fclo: float64(1.692380503540994e-17), + }, + 53: { + Fchi: float64(0.8964844367374554), + Fclo: -Float64FromFloat64(1.0837881791715702e-17), + }, + 54: { + Fchi: float64(0.9003905608862683), + Fclo: float64(5.2900545724138363e-17), + }, + 55: { + Fchi: float64(0.9042968358682077), + Fclo: float64(5.3330721088784517e-17), + }, + 56: { + Fchi: float64(0.9082031671057441), + Fclo: float64(1.8640040753232978e-17), + }, + 57: { + Fchi: float64(0.9121093993305497), + Fclo: float64(4.467972832054075e-17), + }, + 58: { + Fchi: float64(0.9160155849026457), + Fclo: -Float64FromFloat64(5.216213419585033e-18), + }, + 59: { + Fchi: float64(0.9199219622862499), + Fclo: -Float64FromFloat64(2.7324731032846873e-17), + }, + 60: { + Fchi: float64(0.9238281880717143), + Fclo: -Float64FromFloat64(1.7769263393434193e-17), + }, + 61: { + Fchi: float64(0.9277343012727929), + Fclo: float64(4.943363080817441e-17), + }, + 62: { + Fchi: float64(0.9316407021562788), + Fclo: float64(4.164434042024055e-17), + }, + 63: { + Fchi: float64(0.935546825207466), + Fclo: float64(1.3011820859795741e-17), + }, + 64: { + Fchi: float64(0.9394530312562943), + Fclo: -Float64FromFloat64(2.7332907838481398e-17), + }, + 65: { + Fchi: float64(0.9433593066844669), + Fclo: float64(2.342133170803292e-17), + }, + 66: { + Fchi: float64(0.9472655994038329), + Fclo: float64(1.6478717480487438e-17), + }, + 67: { + Fchi: float64(0.9511718313032721), + Fclo: -Float64FromFloat64(5.19608290131499e-18), + }, + 68: { + Fchi: float64(0.9550781578218178), + Fclo: -Float64FromFloat64(3.5565573220579e-17), + }, + 69: { + Fchi: float64(0.9589843147339043), + Fclo: float64(2.0816772146458738e-17), + }, + 70: { + Fchi: float64(0.9628906735633685), + Fclo: -Float64FromFloat64(3.471962826146841e-18), + }, + 71: { + Fchi: float64(0.9667968893972092), + Fclo: -Float64FromFloat64(3.68646834472642e-17), + }, + 72: { + Fchi: float64(0.9707031054025779), + Fclo: -Float64FromFloat64(3.4674108076868834e-18), + }, + 73: { + Fchi: float64(0.9746094325494931), + Fclo: float64(4.598152624774392e-17), + }, + 74: { + Fchi: float64(0.9785156054582722), + Fclo: float64(4.553145752392568e-17), + }, + 75: { + Fchi: float64(0.9824218687812282), + Fclo: -Float64FromFloat64(7.811259169418978e-18), + }, + 76: { + Fchi: float64(0.9863280690752917), + Fclo: float64(2.0375615178047467e-17), + }, + 77: { + Fchi: float64(0.9902342909546034), + Fclo: -Float64FromFloat64(1.344597043422914e-17), + }, + 78: { + Fchi: float64(0.9941406780264008), + Fclo: float64(1.51853723695054e-17), + }, + 79: { + Fchi: float64(0.9980468598715558), + Fclo: -Float64FromFloat64(1.301926039598001e-17), + }, + 80: { + Fchi: float64(1.0039062067717412), + Fclo: -Float64FromFloat64(4.596120641744973e-17), + }, + 81: { + Fchi: float64(1.0117187035281372), + Fclo: -Float64FromFloat64(8.152405002665349e-17), + }, + 82: { + Fchi: float64(1.0195312424919558), + Fclo: float64(8.239927014757811e-17), + }, + 83: { + Fchi: float64(1.0273437641634193), + Fclo: float64(3.122851005327045e-17), + }, + 84: { + Fchi: float64(1.0351562274561221), + Fclo: -Float64FromFloat64(1.3010212611128995e-17), + }, + 85: { + Fchi: float64(1.0429687539123276), + Fclo: -Float64FromFloat64(5.984116688633458e-17), + }, + 86: { + Fchi: float64(1.0507812561238108), + Fclo: float64(2.860923854822335e-17), + }, + 87: { + Fchi: float64(1.0585937308350133), + Fclo: -Float64FromFloat64(1.9962944508904598e-17), + }, + 88: { + Fchi: float64(1.0664062936992642), + Fclo: float64(5.291469130309099e-17), + }, + 89: { + Fchi: float64(1.0742187309945372), + Fclo: float64(1.0321575006732523e-16), + }, + 90: { + Fchi: float64(1.082031301537134), + Fclo: float64(9.021194373419119e-17), + }, + 91: { + Fchi: float64(1.0898438063644336), + Fclo: float64(5.202798992357953e-17), + }, + 92: { + Fchi: float64(1.0976562356711468), + Fclo: float64(5.898318482500785e-17), + }, + 93: { + Fchi: float64(1.1054688179463226), + Fclo: float64(8.846377690653252e-17), + }, + 94: { + Fchi: float64(1.113281220803328), + Fclo: -Float64FromFloat64(9.529455965212574e-18), + }, + 95: { + Fchi: float64(1.1210937073167315), + Fclo: float64(6.765080709377787e-17), + }, + 96: { + Fchi: float64(1.1289062967338532), + Fclo: float64(1.0929327370933015e-16), + }, + 97: { + Fchi: float64(1.1367187631150848), + Fclo: float64(6.938570551230516e-17), + }, + 98: { + Fchi: float64(1.1445312490244826), + Fclo: float64(1.908841015045148e-17), + }, + 99: { + Fchi: float64(1.1523437096203593), + Fclo: float64(2.7744504138979832e-17), + }, + 100: { + Fchi: float64(1.1601563266482477), + Fclo: -Float64FromFloat64(1.5621964097491672e-17), + }, + 101: { + Fchi: float64(1.1679688257483505), + Fclo: -Float64FromFloat64(6.4191661495975e-17), + }, + 102: { + Fchi: float64(1.1757811754697645), + Fclo: -Float64FromFloat64(4.336465165059268e-17), + }, + 103: { + Fchi: float64(1.183593793665613), + Fclo: -Float64FromFloat64(3.8159292551356396e-17), + }, + 104: { + Fchi: float64(1.1914062331617676), + Fclo: -Float64FromFloat64(2.94933042768015e-17), + }, + 105: { + Fchi: float64(1.1992187450577771), + Fclo: -Float64FromFloat64(6.244142916351348e-17), + }, + 106: { + Fchi: float64(1.2070312971249755), + Fclo: float64(7.458644622627413e-17), + }, + 107: { + Fchi: float64(1.2148438169965134), + Fclo: float64(2.7760519266147807e-17), + }, + 108: { + Fchi: float64(1.222656225220801), + Fclo: -Float64FromFloat64(7.025106921079665e-17), + }, + 109: { + Fchi: float64(1.2304687681290862), + Fclo: float64(3.7292622364618835e-17), + }, + 110: { + Fchi: float64(1.2382812116234925), + Fclo: float64(2.2558949940652082e-17), + }, + 111: { + Fchi: float64(1.2460936706149877), + Fclo: float64(8.499368944400665e-17), + }, + 112: { + Fchi: float64(1.2539063289686938), + Fclo: float64(1.039515474644361e-17), + }, + 113: { + Fchi: float64(1.2617188367227732), + Fclo: float64(3.297262223275499e-17), + }, + 114: { + Fchi: float64(1.2695311590462317), + Fclo: float64(4.509883253594155e-17), + }, + 115: { + Fchi: float64(1.277343660657941), + Fclo: -Float64FromFloat64(7.546987371769545e-17), + }, + 116: { + Fchi: float64(1.2851561882963496), + Fclo: float64(9.454295598818184e-17), + }, + 117: { + Fchi: float64(1.2929686521915196), + Fclo: -Float64FromFloat64(7.28545609119749e-17), + }, + 118: { + Fchi: float64(1.3007813359167737), + Fclo: -Float64FromFloat64(8.934357651462802e-17), + }, + 119: { + Fchi: float64(1.3085938093753886), + Fclo: float64(8.15257059458102e-17), + }, + 120: { + Fchi: float64(1.3164063202609564), + Fclo: float64(6.946341460765881e-18), + }, + 121: { + Fchi: float64(1.3242188320313901), + Fclo: -Float64FromFloat64(7.892731380721676e-17), + }, + 122: { + Fchi: float64(1.3320311786874468), + Fclo: -Float64FromFloat64(4.3384657500713545e-17), + }, + 123: { + Fchi: float64(1.3398436880573092), + Fclo: float64(9.627577954598792e-17), + }, + 124: { + Fchi: float64(1.3476563390295309), + Fclo: float64(4.2492400590204517e-17), + }, + 125: { + Fchi: float64(1.3554687641043626), + Fclo: -Float64FromFloat64(1.0843419551446047e-16), + }, + 126: { + Fchi: float64(1.3632813590971713), + Fclo: -Float64FromFloat64(8.50172782472025e-17), + }, + 127: { + Fchi: float64(1.3710936595522603), + Fclo: -Float64FromFloat64(7.110627206162922e-17), + }, + }, +} + +var X__logf_data = Tlogf_data{ + Ftab: [16]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.398907162146528), + Flogc: -Float64FromFloat64(0.33569133332882284), + }, + 1: { + Finvc: float64(1.3403141896637998), + Flogc: -Float64FromFloat64(0.2929040563774074), + }, + 2: { + Finvc: float64(1.286432210124115), + Flogc: -Float64FromFloat64(0.2518726580937369), + }, + 3: { + Finvc: float64(1.2367150214269895), + Flogc: -Float64FromFloat64(0.21245868807117255), + }, + 4: { + Finvc: float64(1.1906977166711752), + Flogc: -Float64FromFloat64(0.17453945183745634), + }, + 5: { + Finvc: float64(1.1479821020556429), + Flogc: -Float64FromFloat64(0.1380057072319758), + }, + 6: { + Finvc: float64(1.1082251448272158), + Flogc: -Float64FromFloat64(0.10275976698545139), + }, + 7: { + Finvc: float64(1.0711297413057381), + Flogc: -Float64FromFloat64(0.06871392447020525), + }, + 8: { + Finvc: float64(1.036437278977283), + Flogc: -Float64FromFloat64(0.0357891387398228), + }, + 9: { + Finvc: float64(1), + }, + 10: { + Finvc: float64(0.9492859795739057), + Flogc: float64(0.05204517742929496), + }, + 11: { + Finvc: float64(0.8951049428609004), + Flogc: float64(0.11081431298787942), + }, + 12: { + Finvc: float64(0.8476821620351103), + Flogc: float64(0.1652495223695143), + }, + 13: { + Finvc: float64(0.8050314851692001), + Flogc: float64(0.21687389031699977), + }, + 14: { + Finvc: float64(0.7664671008843108), + Flogc: float64(0.2659635028121397), + }, + 15: { + Finvc: float64(0.731428603316328), + Flogc: float64(0.3127556664073557), + }, + }, + Fln2: float64(0.6931471805599453), + Fpoly: [3]float64{ + 0: -Float64FromFloat64(0.25089342214237154), + 1: float64(0.333456765744066), + 2: -Float64FromFloat64(0.4999997485802103), + }, +} + +var X__optpos int32 + +var Xoptreset int32 + +var X__pow_log_data = Tpow_log_data{ + Fln2hi: float64(0.6931471805598903), + Fln2lo: float64(5.497923018708371e-14), + Fpoly: [7]float64{ + 0: -Float64FromFloat64(0.5), + 1: float64(Float64FromFloat64(0.3333333333333339) * float64(-Int32FromInt32(2))), + 2: float64(-Float64FromFloat64(0.25000000000000033) * float64(-Int32FromInt32(2))), + 3: float64(Float64FromFloat64(0.1999999998830994) * Float64FromInt32(4)), + 4: float64(-Float64FromFloat64(0.16666666658719348) * Float64FromInt32(4)), + 5: float64(Float64FromFloat64(0.14286370355743763) * float64(-Int32FromInt32(8))), + 6: float64(-Float64FromFloat64(0.12500519079594427) * float64(-Int32FromInt32(8))), + }, + Ftab: [128]struct { + Finvc float64 + Fpad float64 + Flogc float64 + Flogctail float64 + }{ + 0: { + Finvc: float64(1.4140625), + Flogc: -Float64FromFloat64(0.3464667673462145), + Flogctail: float64(5.929407345889625e-15), + }, + 1: { + Finvc: float64(1.40625), + Flogc: -Float64FromFloat64(0.34092658697056777), + Flogctail: -Float64FromFloat64(2.544157440035963e-14), + }, + 2: { + Finvc: float64(1.3984375), + Flogc: -Float64FromFloat64(0.3353555419211034), + Flogctail: -Float64FromFloat64(3.443525940775045e-14), + }, + 3: { + Finvc: float64(1.390625), + Flogc: -Float64FromFloat64(0.3297532863724655), + Flogctail: -Float64FromFloat64(2.500123826022799e-15), + }, + 4: { + Finvc: float64(1.3828125), + Flogc: -Float64FromFloat64(0.32411946865420305), + Flogctail: -Float64FromFloat64(8.929337133850617e-15), + }, + 5: { + Finvc: float64(1.375), + Flogc: -Float64FromFloat64(0.31845373111855224), + Flogctail: float64(1.7625431312172662e-14), + }, + 6: { + Finvc: float64(1.3671875), + Flogc: -Float64FromFloat64(0.31275571000389846), + Flogctail: float64(1.5688303180062087e-15), + }, + 7: { + Finvc: float64(1.359375), + Flogc: -Float64FromFloat64(0.3070250352949415), + Flogctail: float64(2.9655274673691784e-14), + }, + 8: { + Finvc: float64(1.3515625), + Flogc: -Float64FromFloat64(0.3012613305781997), + Flogctail: float64(3.7923164802093147e-14), + }, + 9: { + Finvc: float64(1.34375), + Flogc: -Float64FromFloat64(0.2954642128938758), + Flogctail: float64(3.993416384387844e-14), + }, + 10: { + Finvc: float64(1.3359375), + Flogc: -Float64FromFloat64(0.28963329258306203), + Flogctail: float64(1.9352855826489123e-14), + }, + 11: { + Finvc: float64(1.3359375), + Flogc: -Float64FromFloat64(0.28963329258306203), + Flogctail: float64(1.9352855826489123e-14), + }, + 12: { + Finvc: float64(1.328125), + Flogc: -Float64FromFloat64(0.28376817313062475), + Flogctail: -Float64FromFloat64(1.9852665484979036e-14), + }, + 13: { + Finvc: float64(1.3203125), + Flogc: -Float64FromFloat64(0.27786845100342816), + Flogctail: -Float64FromFloat64(2.814323765595281e-14), + }, + 14: { + Finvc: float64(1.3125), + Flogc: -Float64FromFloat64(0.2719337154836694), + Flogctail: float64(2.7643769993528702e-14), + }, + 15: { + Finvc: float64(1.3046875), + Flogc: -Float64FromFloat64(0.2659635484970977), + Flogctail: -Float64FromFloat64(4.025092402293806e-14), + }, + 16: { + Finvc: float64(1.296875), + Flogc: -Float64FromFloat64(0.25995752443691345), + Flogctail: -Float64FromFloat64(1.2621729398885316e-14), + }, + 17: { + Finvc: float64(1.2890625), + Flogc: -Float64FromFloat64(0.25391520998095984), + Flogctail: -Float64FromFloat64(3.600176732637335e-15), + }, + 18: { + Finvc: float64(1.2890625), + Flogc: -Float64FromFloat64(0.25391520998095984), + Flogctail: -Float64FromFloat64(3.600176732637335e-15), + }, + 19: { + Finvc: float64(1.28125), + Flogc: -Float64FromFloat64(0.2478361639045943), + Flogctail: float64(1.3029797173308663e-14), + }, + 20: { + Finvc: float64(1.2734375), + Flogc: -Float64FromFloat64(0.2417199368871934), + Flogctail: float64(4.8230289429940886e-14), + }, + 21: { + Finvc: float64(1.265625), + Flogc: -Float64FromFloat64(0.23556607131274632), + Flogctail: -Float64FromFloat64(2.0592242769647135e-14), + }, + 22: { + Finvc: float64(1.2578125), + Flogc: -Float64FromFloat64(0.22937410106487732), + Flogctail: float64(3.149265065191484e-14), + }, + 23: { + Finvc: float64(1.25), + Flogc: -Float64FromFloat64(0.22314355131425145), + Flogctail: float64(4.169796584527195e-14), + }, + 24: { + Finvc: float64(1.25), + Flogc: -Float64FromFloat64(0.22314355131425145), + Flogctail: float64(4.169796584527195e-14), + }, + 25: { + Finvc: float64(1.2421875), + Flogc: -Float64FromFloat64(0.21687393830063684), + Flogctail: float64(2.2477465222466186e-14), + }, + 26: { + Finvc: float64(1.234375), + Flogc: -Float64FromFloat64(0.21056476910735), + Flogctail: float64(3.6507188831790577e-16), + }, + 27: { + Finvc: float64(1.2265625), + Flogc: -Float64FromFloat64(0.2042155414286526), + Flogctail: -Float64FromFloat64(3.827767260205414e-14), + }, + 28: { + Finvc: float64(1.2265625), + Flogc: -Float64FromFloat64(0.2042155414286526), + Flogctail: -Float64FromFloat64(3.827767260205414e-14), + }, + 29: { + Finvc: float64(1.21875), + Flogc: -Float64FromFloat64(0.19782574332987224), + Flogctail: -Float64FromFloat64(4.7641388950792196e-14), + }, + 30: { + Finvc: float64(1.2109375), + Flogc: -Float64FromFloat64(0.19139485299967873), + Flogctail: float64(4.9278276214647115e-14), + }, + 31: { + Finvc: float64(1.203125), + Flogc: -Float64FromFloat64(0.18492233849406148), + Flogctail: float64(4.9485167661250996e-14), + }, + 32: { + Finvc: float64(1.203125), + Flogc: -Float64FromFloat64(0.18492233849406148), + Flogctail: float64(4.9485167661250996e-14), + }, + 33: { + Finvc: float64(1.1953125), + Flogc: -Float64FromFloat64(0.1784076574728033), + Flogctail: -Float64FromFloat64(1.5003333854266542e-14), + }, + 34: { + Finvc: float64(1.1875), + Flogc: -Float64FromFloat64(0.17185025692663203), + Flogctail: -Float64FromFloat64(2.7194441649495324e-14), + }, + 35: { + Finvc: float64(1.1875), + Flogc: -Float64FromFloat64(0.17185025692663203), + Flogctail: -Float64FromFloat64(2.7194441649495324e-14), + }, + 36: { + Finvc: float64(1.1796875), + Flogc: -Float64FromFloat64(0.1652495728952772), + Flogctail: -Float64FromFloat64(2.99659267292569e-14), + }, + 37: { + Finvc: float64(1.171875), + Flogc: -Float64FromFloat64(0.15860503017665906), + Flogctail: float64(2.0472357800461955e-14), + }, + 38: { + Finvc: float64(1.171875), + Flogc: -Float64FromFloat64(0.15860503017665906), + Flogctail: float64(2.0472357800461955e-14), + }, + 39: { + Finvc: float64(1.1640625), + Flogc: -Float64FromFloat64(0.15191604202584585), + Flogctail: float64(3.879296723063646e-15), + }, + 40: { + Finvc: float64(1.15625), + Flogc: -Float64FromFloat64(0.1451820098444614), + Flogctail: -Float64FromFloat64(3.6506824353335045e-14), + }, + 41: { + Finvc: float64(1.1484375), + Flogc: -Float64FromFloat64(0.13840232285906495), + Flogctail: -Float64FromFloat64(5.4183331379008994e-14), + }, + 42: { + Finvc: float64(1.1484375), + Flogc: -Float64FromFloat64(0.13840232285906495), + Flogctail: -Float64FromFloat64(5.4183331379008994e-14), + }, + 43: { + Finvc: float64(1.140625), + Flogc: -Float64FromFloat64(0.131576357788731), + Flogctail: float64(1.1729485484531301e-14), + }, + 44: { + Finvc: float64(1.140625), + Flogc: -Float64FromFloat64(0.131576357788731), + Flogctail: float64(1.1729485484531301e-14), + }, + 45: { + Finvc: float64(1.1328125), + Flogc: -Float64FromFloat64(0.12470347850091912), + Flogctail: -Float64FromFloat64(3.811763084710266e-14), + }, + 46: { + Finvc: float64(1.125), + Flogc: -Float64FromFloat64(0.11778303565643), + Flogctail: float64(4.654729747598445e-14), + }, + 47: { + Finvc: float64(1.125), + Flogc: -Float64FromFloat64(0.11778303565643), + Flogctail: float64(4.654729747598445e-14), + }, + 48: { + Finvc: float64(1.1171875), + Flogc: -Float64FromFloat64(0.11081436634026431), + Flogctail: -Float64FromFloat64(2.5799991283069902e-14), + }, + 49: { + Finvc: float64(1.109375), + Flogc: -Float64FromFloat64(0.10379679368168127), + Flogctail: float64(3.7700471749674615e-14), + }, + 50: { + Finvc: float64(1.109375), + Flogc: -Float64FromFloat64(0.10379679368168127), + Flogctail: float64(3.7700471749674615e-14), + }, + 51: { + Finvc: float64(1.1015625), + Flogc: -Float64FromFloat64(0.09672962645856842), + Flogctail: float64(1.7306161136093256e-14), + }, + 52: { + Finvc: float64(1.1015625), + Flogc: -Float64FromFloat64(0.09672962645856842), + Flogctail: float64(1.7306161136093256e-14), + }, + 53: { + Finvc: float64(1.09375), + Flogc: -Float64FromFloat64(0.089612158689647), + Flogctail: -Float64FromFloat64(4.012913552726574e-14), + }, + 54: { + Finvc: float64(1.0859375), + Flogc: -Float64FromFloat64(0.08244366921110213), + Flogctail: float64(2.7541708360737882e-14), + }, + 55: { + Finvc: float64(1.0859375), + Flogc: -Float64FromFloat64(0.08244366921110213), + Flogctail: float64(2.7541708360737882e-14), + }, + 56: { + Finvc: float64(1.078125), + Flogc: -Float64FromFloat64(0.07522342123763792), + Flogctail: float64(5.0396178134370583e-14), + }, + 57: { + Finvc: float64(1.078125), + Flogc: -Float64FromFloat64(0.07522342123763792), + Flogctail: float64(5.0396178134370583e-14), + }, + 58: { + Finvc: float64(1.0703125), + Flogc: -Float64FromFloat64(0.06795066190852594), + Flogctail: float64(1.8195060030168815e-14), + }, + 59: { + Finvc: float64(1.0625), + Flogc: -Float64FromFloat64(0.06062462181648698), + Flogctail: float64(5.213620639136504e-14), + }, + 60: { + Finvc: float64(1.0625), + Flogc: -Float64FromFloat64(0.06062462181648698), + Flogctail: float64(5.213620639136504e-14), + }, + 61: { + Finvc: float64(1.0546875), + Flogc: -Float64FromFloat64(0.053244514518837605), + Flogctail: float64(2.532168943117445e-14), + }, + 62: { + Finvc: float64(1.0546875), + Flogc: -Float64FromFloat64(0.053244514518837605), + Flogctail: float64(2.532168943117445e-14), + }, + 63: { + Finvc: float64(1.046875), + Flogc: -Float64FromFloat64(0.045809536031242715), + Flogctail: -Float64FromFloat64(5.148849572685811e-14), + }, + 64: { + Finvc: float64(1.046875), + Flogc: -Float64FromFloat64(0.045809536031242715), + Flogctail: -Float64FromFloat64(5.148849572685811e-14), + }, + 65: { + Finvc: float64(1.0390625), + Flogc: -Float64FromFloat64(0.038318864302141264), + Flogctail: float64(4.6652946995830086e-15), + }, + 66: { + Finvc: float64(1.0390625), + Flogc: -Float64FromFloat64(0.038318864302141264), + Flogctail: float64(4.6652946995830086e-15), + }, + 67: { + Finvc: float64(1.03125), + Flogc: -Float64FromFloat64(0.03077165866670839), + Flogctail: -Float64FromFloat64(4.529814257790929e-14), + }, + 68: { + Finvc: float64(1.03125), + Flogc: -Float64FromFloat64(0.03077165866670839), + Flogctail: -Float64FromFloat64(4.529814257790929e-14), + }, + 69: { + Finvc: float64(1.0234375), + Flogc: -Float64FromFloat64(0.023167059281490765), + Flogctail: -Float64FromFloat64(4.361324067851568e-14), + }, + 70: { + Finvc: float64(1.015625), + Flogc: -Float64FromFloat64(0.015504186535963527), + Flogctail: -Float64FromFloat64(1.7274567499706107e-15), + }, + 71: { + Finvc: float64(1.015625), + Flogc: -Float64FromFloat64(0.015504186535963527), + Flogctail: -Float64FromFloat64(1.7274567499706107e-15), + }, + 72: { + Finvc: float64(1.0078125), + Flogc: -Float64FromFloat64(0.0077821404420319595), + Flogctail: -Float64FromFloat64(2.298941004620351e-14), + }, + 73: { + Finvc: float64(1.0078125), + Flogc: -Float64FromFloat64(0.0077821404420319595), + Flogctail: -Float64FromFloat64(2.298941004620351e-14), + }, + 74: { + Finvc: float64(1), + }, + 75: { + Finvc: float64(1), + }, + 76: { + Finvc: float64(0.9921875), + Flogc: float64(0.007843177461040796), + Flogctail: -Float64FromFloat64(1.4902732911301337e-14), + }, + 77: { + Finvc: float64(0.984375), + Flogc: float64(0.01574835696817445), + Flogctail: -Float64FromFloat64(3.527980389655325e-14), + }, + 78: { + Finvc: float64(0.9765625), + Flogc: float64(0.023716526617363343), + Flogctail: -Float64FromFloat64(4.730054772033249e-14), + }, + 79: { + Finvc: float64(0.96875), + Flogc: float64(0.03174869831457272), + Flogctail: float64(7.580310369375161e-15), + }, + 80: { + Finvc: float64(0.9609375), + Flogc: float64(0.039845908547249564), + Flogctail: -Float64FromFloat64(4.9893776716773285e-14), + }, + 81: { + Finvc: float64(0.953125), + Flogc: float64(0.048009219186383234), + Flogctail: -Float64FromFloat64(2.262629393030674e-14), + }, + 82: { + Finvc: float64(0.9453125), + Flogc: float64(0.056239718322899535), + Flogctail: -Float64FromFloat64(2.345674491018699e-14), + }, + 83: { + Finvc: float64(0.94140625), + Flogc: float64(0.06038051098892083), + Flogctail: -Float64FromFloat64(1.3352588834854848e-14), + }, + 84: { + Finvc: float64(0.93359375), + Flogc: float64(0.06871389254808946), + Flogctail: -Float64FromFloat64(3.765296820388875e-14), + }, + 85: { + Finvc: float64(0.92578125), + Flogc: float64(0.07711730334438016), + Flogctail: float64(5.1128335719851986e-14), + }, + 86: { + Finvc: float64(0.91796875), + Flogc: float64(0.08559193033545398), + Flogctail: -Float64FromFloat64(5.046674438470119e-14), + }, + 87: { + Finvc: float64(0.9140625), + Flogc: float64(0.08985632912185793), + Flogctail: float64(3.1218748807418837e-15), + }, + 88: { + Finvc: float64(0.90625), + Flogc: float64(0.09844007281321865), + Flogctail: float64(3.3871241029241416e-14), + }, + 89: { + Finvc: float64(0.8984375), + Flogc: float64(0.10709813555638448), + Flogctail: -Float64FromFloat64(1.7376727386423858e-14), + }, + 90: { + Finvc: float64(0.89453125), + Flogc: float64(0.11145544092528326), + Flogctail: float64(3.957125899799804e-14), + }, + 91: { + Finvc: float64(0.88671875), + Flogc: float64(0.12022742699821265), + Flogctail: -Float64FromFloat64(5.2849453521890294e-14), + }, + 92: { + Finvc: float64(0.8828125), + Flogc: float64(0.12464244520731427), + Flogctail: -Float64FromFloat64(3.767012502308738e-14), + }, + 93: { + Finvc: float64(0.875), + Flogc: float64(0.13353139262449076), + Flogctail: float64(3.1859736349078334e-14), + }, + 94: { + Finvc: float64(0.87109375), + Flogc: float64(0.13800567301939282), + Flogctail: float64(5.0900642926060466e-14), + }, + 95: { + Finvc: float64(0.86328125), + Flogc: float64(0.14701474296180095), + Flogctail: float64(8.710783796122478e-15), + }, + 96: { + Finvc: float64(0.859375), + Flogc: float64(0.15154989812720032), + Flogctail: float64(6.157896229122976e-16), + }, + 97: { + Finvc: float64(0.8515625), + Flogc: float64(0.16068238169043525), + Flogctail: float64(3.821577743916796e-14), + }, + 98: { + Finvc: float64(0.84765625), + Flogc: float64(0.16528009093906348), + Flogctail: float64(3.9440046718453496e-14), + }, + 99: { + Finvc: float64(0.83984375), + Flogc: float64(0.17453941635187675), + Flogctail: float64(2.2924522154618074e-14), + }, + 100: { + Finvc: float64(0.8359375), + Flogc: float64(0.17920142945774842), + Flogctail: -Float64FromFloat64(3.742530094732263e-14), + }, + 101: { + Finvc: float64(0.83203125), + Flogc: float64(0.18388527877016259), + Flogctail: -Float64FromFloat64(2.5223102140407338e-14), + }, + 102: { + Finvc: float64(0.82421875), + Flogc: float64(0.1933193110035063), + Flogctail: -Float64FromFloat64(1.0320443688698849e-14), + }, + 103: { + Finvc: float64(0.8203125), + Flogc: float64(0.19806991376208316), + Flogctail: float64(1.0634128304268335e-14), + }, + 104: { + Finvc: float64(0.8125), + Flogc: float64(0.20763936477828793), + Flogctail: -Float64FromFloat64(4.3425422595242564e-14), + }, + 105: { + Finvc: float64(0.80859375), + Flogc: float64(0.21245865121420593), + Flogctail: -Float64FromFloat64(1.2527395755711364e-14), + }, + 106: { + Finvc: float64(0.8046875), + Flogc: float64(0.21730127569003344), + Flogctail: -Float64FromFloat64(5.204008743405884e-14), + }, + 107: { + Finvc: float64(0.80078125), + Flogc: float64(0.22216746534115828), + Flogctail: -Float64FromFloat64(3.979844515951702e-15), + }, + 108: { + Finvc: float64(0.79296875), + Flogc: float64(0.2319714654378231), + Flogctail: -Float64FromFloat64(4.7955860343296286e-14), + }, + 109: { + Finvc: float64(0.7890625), + Flogc: float64(0.2369097470783572), + Flogctail: float64(5.015686013791602e-16), + }, + 110: { + Finvc: float64(0.78515625), + Flogc: float64(0.24187253642048745), + Flogctail: -Float64FromFloat64(7.252318953240293e-16), + }, + 111: { + Finvc: float64(0.78125), + Flogc: float64(0.2468600779315011), + Flogctail: float64(2.4688324156011588e-14), + }, + 112: { + Finvc: float64(0.7734375), + Flogc: float64(0.2569104137850218), + Flogctail: float64(5.465121253624792e-15), + }, + 113: { + Finvc: float64(0.76953125), + Flogc: float64(0.26197371574153294), + Flogctail: float64(4.102651071698446e-14), + }, + 114: { + Finvc: float64(0.765625), + Flogc: float64(0.2670627852490952), + Flogctail: -Float64FromFloat64(4.996736502345936e-14), + }, + 115: { + Finvc: float64(0.76171875), + Flogc: float64(0.27217788591576664), + Flogctail: float64(4.903580708156347e-14), + }, + 116: { + Finvc: float64(0.7578125), + Flogc: float64(0.27731928541618345), + Flogctail: float64(5.089628039500759e-14), + }, + 117: { + Finvc: float64(0.75390625), + Flogc: float64(0.28248725557466514), + Flogctail: float64(1.1782016386565151e-14), + }, + 118: { + Finvc: float64(0.74609375), + Flogc: float64(0.29290401643288533), + Flogctail: float64(4.727452940514406e-14), + }, + 119: { + Finvc: float64(0.7421875), + Flogc: float64(0.29815337231912054), + Flogctail: -Float64FromFloat64(4.4204083338755686e-14), + }, + 120: { + Finvc: float64(0.73828125), + Flogc: float64(0.3034304294199046), + Flogctail: float64(1.548345993498083e-14), + }, + 121: { + Finvc: float64(0.734375), + Flogc: float64(0.30873548164959175), + Flogctail: float64(2.1522127491642888e-14), + }, + 122: { + Finvc: float64(0.73046875), + Flogc: float64(0.3140688276249648), + Flogctail: float64(1.1054030169005386e-14), + }, + 123: { + Finvc: float64(0.7265625), + Flogc: float64(0.31943077076641657), + Flogctail: -Float64FromFloat64(5.534326352070679e-14), + }, + 124: { + Finvc: float64(0.72265625), + Flogc: float64(0.3248216194012912), + Flogctail: -Float64FromFloat64(5.351646604259541e-14), + }, + 125: { + Finvc: float64(0.71875), + Flogc: float64(0.33024168687052224), + Flogctail: float64(5.4612144489920215e-14), + }, + 126: { + Finvc: float64(0.71484375), + Flogc: float64(0.3356912916381134), + Flogctail: float64(2.8136969901227338e-14), + }, + 127: { + Finvc: float64(0.7109375), + Flogc: float64(0.3411707574027787), + Flogctail: -Float64FromFloat64(1.156568624616423e-14), + }, + }, +} + +var X__powf_log2_data = Tpowf_log2_data{ + Ftab: [16]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.398907162146528), + Flogc: float64(-Float64FromFloat64(0.48430022186289673) * float64(Int32FromInt32(1)<> int32(32)) + **(**int32)(__ccgo_up(expt)) = Int32FromUint32(hx>>Int32FromInt32(20) - Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(1023)) + _k) + v1 = uint64(hx&Uint32FromInt32(0xfffff)|Uint32FromInt32((Int32FromInt32(0x3ff)+Int32FromInt32(1023))<= ln(DBL_MAX)) +// * where care is needed to avoid overflow. +// * +// * The present implementation is narrowly tailored for our hyperbolic and +// * exponential functions. We assume expt is small (0 or -1), and the caller +// * has filtered out very large x, for which overflow would be inevitable. +// */ +func X__ldexp_cexp(tls *TLS, z complex128, expt int32) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v expt=%v, (%v:)", tls, z, expt, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var exp_x, scale1, scale2, x, y float64 + var half_expt int32 + var v1 Tuint64_t + var v3 [2]float64 + var _ /* ex_expt at bp+0 */ int32 + _, _, _, _, _, _, _, _ = exp_x, half_expt, scale1, scale2, x, y, v1, v3 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + exp_x = ___frexp_exp(tls, x, bp) + expt = expt + **(**int32)(__ccgo_up(bp)) + /* + * Arrange so that scale1 * scale2 == 2**expt. We use this to + * compensate for scalbn being horrendously slow. + */ + half_expt = expt / int32(2) + v1 = Uint64FromInt32((Int32FromInt32(0x3ff)+half_expt)<>Int32FromInt32(23) - Uint32FromInt32(Int32FromInt32(0x7f)+Int32FromInt32(127)) + _k1) + v1 = hx&uint32(0x7fffff) | Uint32FromInt32((Int32FromInt32(0x7f)+Int32FromInt32(127))< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var exp_x, scale1, scale2, x, y float32 + var half_expt int32 + var v1 Tuint32_t + var v3 [2]float32 + var _ /* ex_expt at bp+0 */ int32 + _, _, _, _, _, _, _, _ = exp_x, half_expt, scale1, scale2, x, y, v1, v3 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + exp_x = ___frexp_expf(tls, x, bp) + expt = expt + **(**int32)(__ccgo_up(bp)) + half_expt = expt / int32(2) + v1 = Uint32FromInt32((int32(0x7f) + half_expt) << int32(23)) + scale1 = *(*float32)(unsafe.Pointer(&v1)) + half_expt = expt - half_expt + v1 = Uint32FromInt32((int32(0x7f) + half_expt) << int32(23)) + scale2 = *(*float32)(unsafe.Pointer(&v1)) + v3 = [2]float32{ + 0: float32(float32(float32(Xcosf(tls, y)*exp_x)*scale1) * scale2), + 1: float32(float32(float32(Xsinf(tls, y)*exp_x)*scale1) * scale2), + } + return *(*complex64)(unsafe.Pointer(&v3)) +} + +func Xcabs(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xhypot(tls, Float64FromComplex128(z), +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)]) +} + +func Xcabsf(tls *TLS, z complex64) (r float32) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xhypotf(tls, Float32FromComplex64(z), +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)]) +} + +func Xcabsl(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcabs(tls, Complex128FromComplex128(z)) +} + +const M_PI_21 = 1.5707963267948966 + +// FIXME: Hull et al. "Implementing the complex arcsine and arccosine functions using exception handling" 1997 + +/* acos(z) = pi/2 - asin(z) */ + +func Xcacos(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + z = Xcasin(tls, z) + v1 = [2]float64{ + 0: float64(1.5707963267948966) - Float64FromComplex128(z), + 1: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +// FIXME + +var _float_pi_2 = float32(1.5707963267948966) + +func Xcacosf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + z = Xcasinf(tls, z) + v1 = [2]float32{ + 0: _float_pi_2 - Float32FromComplex64(z), + 1: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +const M_PI_22 = 0 + +/* acosh(z) = i acos(z) */ + +func Xcacosh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var zineg int32 + var v1 uint64 + var v3 [2]float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _ = zineg, v1, v3 + *(*float64)(unsafe.Pointer(bp)) = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + zineg = Int32FromUint64(v1 >> Int32FromInt32(63)) + z = Xcacos(tls, z) + if zineg != 0 { + v3 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v3)) + } else { + v3 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v3)) + } + return r +} + +func Xcacoshf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var zineg int32 + var v1 uint32 + var v3 [2]float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _ = zineg, v1, v3 + *(*float32)(unsafe.Pointer(bp)) = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + zineg = Int32FromUint32(v1 >> Int32FromInt32(31)) + z = Xcacosf(tls, z) + if zineg != 0 { + v3 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v3)) + } else { + v3 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v3)) + } + return r +} + +func Xcacoshl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcacosh(tls, Complex128FromComplex128(z))) +} + +func Xcacosl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcacos(tls, Complex128FromComplex128(z))) +} + +func Xcarg(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xatan2(tls, +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], Float64FromComplex128(z)) +} + +func Xcargf(tls *TLS, z complex64) (r float32) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xatan2f(tls, +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], Float32FromComplex64(z)) +} + +func Xcargl(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcarg(tls, Complex128FromComplex128(z)) +} + +// FIXME + +/* asin(z) = -i log(i z + sqrt(1 - z*z)) */ + +func Xcasin(tls *TLS, z complex128) (r1 complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, w complex128 + var x, y float64 + var v1, v2 [2]float64 + _, _, _, _, _, _ = r, w, x, y, v1, v2 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + v1 = [2]float64{ + 0: float64(1) - float64((x-y)*(x+y)), + 1: float64(float64(-Float64FromFloat64(2)*x) * y), + } + w = *(*complex128)(unsafe.Pointer(&v1)) + v1 = [2]float64{ + 0: -y, + 1: x, + } + r = Xclog(tls, *(*complex128)(unsafe.Pointer(&v1))+Xcsqrt(tls, w)) + v2 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&r)))[int32(1)], + 1: -Float64FromComplex128(r), + } + return *(*complex128)(unsafe.Pointer(&v2)) +} + +// FIXME + +func Xcasinf(tls *TLS, z complex64) (r1 complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, w complex64 + var x, y float32 + var v1, v2 [2]float32 + _, _, _, _, _, _ = r, w, x, y, v1, v2 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + v1 = [2]float32{ + 0: float32(Float64FromFloat64(1) - float64((x-y)*(x+y))), + 1: float32(float64(float64(-Float64FromFloat64(2)*float64(x)) * float64(y))), + } + w = *(*complex64)(unsafe.Pointer(&v1)) + v1 = [2]float32{ + 0: -y, + 1: x, + } + r = Xclogf(tls, *(*complex64)(unsafe.Pointer(&v1))+Xcsqrtf(tls, w)) + v2 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&r)))[int32(1)], + 1: -Float32FromComplex64(r), + } + return *(*complex64)(unsafe.Pointer(&v2)) +} + +/* asinh(z) = -i asin(i z) */ + +func Xcasinh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + z = Xcasin(tls, *(*complex128)(unsafe.Pointer(&v1))) + v1 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xcasinhf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + z = Xcasinf(tls, *(*complex64)(unsafe.Pointer(&v1))) + v1 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xcasinhl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcasinh(tls, Complex128FromComplex128(z))) +} + +func Xcasinl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcasin(tls, Complex128FromComplex128(z))) +} + +const MAXNUM = 0 +const M_PI1 = 3.141592653589793 + +var _DP1 = float64(3.141592651605606) +var _DP2 = float64(1.9841871479187034e-09) +var _DP3 = float64(1.1442377452219664e-17) + +func __redupi(tls *TLS, x float64) (r float64) { + var i int64 + var t float64 + _, _ = i, t + t = x / float64(3.141592653589793) + if t >= float64(0) { + t = t + float64(0.5) + } else { + t = t - float64(0.5) + } + i = int64(t) /* the multiple */ + t = float64(i) + t = x - float64(t*_DP1) - float64(t*_DP2) - float64(t*_DP3) + return t +} + +func Xcatan(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, t, x, x2, y float64 + var w complex128 + var v1 [2]float64 + _, _, _, _, _, _, _ = a, t, w, x, x2, y, v1 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + x2 = float64(x * x) + a = float64(1) - x2 - float64(y*y) + t = float64(float64(0.5) * Xatan2(tls, float64(float64(2)*x), a)) + w = Complex128FromFloat64(__redupi(tls, t)) + t = y - float64(1) + a = x2 + float64(t*t) + t = y + float64(1) + a = (x2 + float64(t*t)) / a + v1 = [2]float64{ + 0: Float64FromComplex128(w), + 1: float64(float64(0.25) * Xlog(tls, a)), + } + w = *(*complex128)(unsafe.Pointer(&v1)) + return w +} + +const MAXNUMF = 0 + +var _DP11 = float64(3.140625) +var _DP21 = float64(0.0009675025939941406) +var _DP31 = float64(1.5099579909783765e-07) + +var _float_pi = float32(3.141592653589793) + +func __redupif(tls *TLS, xx float32) (r float32) { + var i int64 + var t, x float32 + _, _, _ = i, t, x + x = xx + t = x / _float_pi + if t >= Float32FromFloat32(0) { + t = t + Float32FromFloat32(0.5) + } else { + t = t - Float32FromFloat32(0.5) + } + i = int64(t) /* the multiple */ + t = float32(i) + t = float32(float64(x) - float64(float64(t)*_DP11) - float64(float64(t)*_DP21) - float64(float64(t)*_DP31)) + return t +} + +func Xcatanf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, t, x, x2, y float32 + var w complex64 + var v1 [2]float32 + _, _, _, _, _, _, _ = a, t, w, x, x2, y, v1 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + x2 = float32(x * x) + a = Float32FromFloat32(1) - x2 - float32(y*y) + t = float32(Float32FromFloat32(0.5) * Xatan2f(tls, float32(Float32FromFloat32(2)*x), a)) + w = Complex64FromFloat32(__redupif(tls, t)) + t = y - Float32FromFloat32(1) + a = x2 + float32(t*t) + t = y + Float32FromFloat32(1) + a = (x2 + float32(t*t)) / a + v1 = [2]float32{ + 0: Float32FromComplex64(w), + 1: float32(Float32FromFloat32(0.25) * Xlogf(tls, a)), + } + w = *(*complex64)(unsafe.Pointer(&v1)) + return w +} + +const M_PI2 = 0 + +/* atanh = -i atan(i z) */ + +func Xcatanh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + z = Xcatan(tls, *(*complex128)(unsafe.Pointer(&v1))) + v1 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xcatanhf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + z = Xcatanf(tls, *(*complex64)(unsafe.Pointer(&v1))) + v1 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xcatanhl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcatanh(tls, Complex128FromComplex128(z))) +} + +func Xcatanl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcatan(tls, Complex128FromComplex128(z))) +} + +/* cos(z) = cosh(i z) */ + +func Xccos(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + return Xccosh(tls, *(*complex128)(unsafe.Pointer(&v1))) +} + +func Xccosf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + return Xccoshf(tls, *(*complex64)(unsafe.Pointer(&v1))) +} + +var _huge = float64(8.98846567431158e+307) + +func Xccosh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u, __u1 Tuint64_t + var h, x, y float64 + var hx, hy, ix, iy, lx, ly Tint32_t + var v1 [2]float64 + _, _, _, _, _, _, _, _, _, _, _, _ = __u, __u1, h, hx, hy, ix, iy, lx, ly, x, y, v1 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + hx = Int32FromUint64(__u >> int32(32)) + lx = Int32FromUint32(uint32(__u)) + __u1 = *(*Tuint64_t)(unsafe.Pointer(&y)) + hy = Int32FromUint64(__u1 >> int32(32)) + ly = Int32FromUint32(uint32(__u1)) + ix = int32(0x7fffffff) & hx + iy = int32(0x7fffffff) & hy + /* Handle the nearly-non-exceptional cases where x and y are finite. */ + if ix < int32(0x7ff00000) && iy < int32(0x7ff00000) { + if iy|ly == 0 { + v1 = [2]float64{ + 0: Xcosh(tls, x), + 1: float64(x * y), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + if ix < int32(0x40360000) { /* small x: normal case */ + v1 = [2]float64{ + 0: float64(Xcosh(tls, x) * Xcos(tls, y)), + 1: float64(Xsinh(tls, x) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* |x| >= 22, so cosh(x) ~= exp(|x|) */ + if ix < int32(0x40862e42) { + /* x < 710: exp(|x|) won't overflow */ + h = float64(Xexp(tls, Xfabs(tls, x)) * float64(0.5)) + v1 = [2]float64{ + 0: float64(h * Xcos(tls, y)), + 1: float64(Xcopysign(tls, h, x) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + if ix < int32(0x4096bbaa) { + /* x < 1455: scale to avoid overflow */ + v1 = [2]float64{ + 0: Xfabs(tls, x), + 1: y, + } + z = X__ldexp_cexp(tls, *(*complex128)(unsafe.Pointer(&v1)), -int32(1)) + v1 = [2]float64{ + 0: Float64FromComplex128(z), + 1: float64(+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] * Xcopysign(tls, Float64FromInt32(1), x)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + /* x >= 1455: the result always overflows */ + h = float64(_huge * x) + v1 = [2]float64{ + 0: float64(float64(h*h) * Xcos(tls, y)), + 1: float64(h * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + } + } + /* + * cosh(+-0 +- I Inf) = dNaN + I sign(d(+-0, dNaN))0. + * The sign of 0 in the result is unspecified. Choice = normally + * the same as dNaN. Raise the invalid floating-point exception. + * + * cosh(+-0 +- I NaN) = d(NaN) + I sign(d(+-0, NaN))0. + * The sign of 0 in the result is unspecified. Choice = normally + * the same as d(NaN). + */ + if ix|lx == 0 && iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: y - y, + 1: Xcopysign(tls, Float64FromInt32(0), float64(x*(y-y))), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0. + * + * cosh(NaN +- I 0) = d(NaN) + I sign(d(NaN, +-0))0. + * The sign of 0 in the result is unspecified. + */ + if iy|ly == 0 && ix >= int32(0x7ff00000) { + if hx&int32(0xfffff)|lx == 0 { + v1 = [2]float64{ + 0: float64(x * x), + 1: float64(Xcopysign(tls, Float64FromInt32(0), x) * y), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v1 = [2]float64{ + 0: float64(x * x), + 1: Xcopysign(tls, Float64FromInt32(0), float64((x+x)*y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * cosh(x +- I Inf) = dNaN + I dNaN. + * Raise the invalid floating-point exception for finite nonzero x. + * + * cosh(x + I NaN) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception for finite + * nonzero x. Choice = don't raise (except for signaling NaNs). + */ + if ix < int32(0x7ff00000) && iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: y - y, + 1: float64(x * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * cosh(+-Inf + I NaN) = +Inf + I d(NaN). + * + * cosh(+-Inf +- I Inf) = +Inf + I dNaN. + * The sign of Inf in the result is unspecified. Choice = always +. + * Raise the invalid floating-point exception. + * + * cosh(+-Inf + I y) = +Inf cos(y) +- I Inf sin(y) + */ + if ix >= int32(0x7ff00000) && hx&int32(0xfffff)|lx == 0 { + if iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: float64(x * x), + 1: float64(x * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v1 = [2]float64{ + 0: float64(float64(x*x) * Xcos(tls, y)), + 1: float64(x * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * cosh(NaN + I NaN) = d(NaN) + I d(NaN). + * + * cosh(NaN +- I Inf) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception. + * Choice = raise. + * + * cosh(NaN + I y) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception for finite + * nonzero y. Choice = don't raise (except for signaling NaNs). + */ + v1 = [2]float64{ + 0: float64(float64(x*x) * (y - y)), + 1: float64((x + x) * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +var _huge1 = float32(1.7014118346046923e+38) + +func Xccoshf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h, x, y float32 + var hx, hy, ix, iy Tint32_t + var v1 [2]float32 + _, _, _, _, _, _, _, _ = h, hx, hy, ix, iy, x, y, v1 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + hx = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(&x))) + hy = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(&y))) + ix = int32(0x7fffffff) & hx + iy = int32(0x7fffffff) & hy + if ix < int32(0x7f800000) && iy < int32(0x7f800000) { + if iy == 0 { + v1 = [2]float32{ + 0: Xcoshf(tls, x), + 1: float32(x * y), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix < int32(0x41100000) { /* small x: normal case */ + v1 = [2]float32{ + 0: float32(Xcoshf(tls, x) * Xcosf(tls, y)), + 1: float32(Xsinhf(tls, x) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + /* |x| >= 9, so cosh(x) ~= exp(|x|) */ + if ix < int32(0x42b17218) { + /* x < 88.7: expf(|x|) won't overflow */ + h = float32(Xexpf(tls, Xfabsf(tls, x)) * Float32FromFloat32(0.5)) + v1 = [2]float32{ + 0: float32(h * Xcosf(tls, y)), + 1: float32(Xcopysignf(tls, h, x) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + if ix < int32(0x4340b1e7) { + /* x < 192.7: scale to avoid overflow */ + v1 = [2]float32{ + 0: Xfabsf(tls, x), + 1: y, + } + z = X__ldexp_cexpf(tls, *(*complex64)(unsafe.Pointer(&v1)), -int32(1)) + v1 = [2]float32{ + 0: Float32FromComplex64(z), + 1: float32(+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] * Xcopysignf(tls, Float32FromInt32(1), x)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + /* x >= 192.7: the result always overflows */ + h = float32(_huge1 * x) + v1 = [2]float32{ + 0: float32(float32(h*h) * Xcosf(tls, y)), + 1: float32(h * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + } + } + if ix == 0 && iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: y - y, + 1: Xcopysignf(tls, Float32FromInt32(0), float32(x*(y-y))), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if iy == 0 && ix >= int32(0x7f800000) { + if hx&int32(0x7fffff) == 0 { + v1 = [2]float32{ + 0: float32(x * x), + 1: float32(Xcopysignf(tls, Float32FromInt32(0), x) * y), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(x * x), + 1: Xcopysignf(tls, Float32FromInt32(0), float32((x+x)*y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix < int32(0x7f800000) && iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: y - y, + 1: float32(x * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix >= int32(0x7f800000) && hx&int32(0x7fffff) == 0 { + if iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: float32(x * x), + 1: float32(x * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(float32(x*x) * Xcosf(tls, y)), + 1: float32(x * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(float32(x*x) * (y - y)), + 1: float32((x + x) * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +// C documentation +// +// //FIXME +func Xccoshl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xccosh(tls, Complex128FromComplex128(z))) +} + +func Xccosl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xccos(tls, Complex128FromComplex128(z))) +} + +var _exp_ovfl = uint32(0x40862e42) /* high bits of MAX_EXP * ln2 ~= 710 */ +var _cexp_ovfl = uint32(0x4096b8e4) /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ + +func Xcexp(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u, __u1 Tuint64_t + var exp_x, x, y float64 + var hx, hy, lx, ly Tuint32_t + var v1 [2]float64 + _, _, _, _, _, _, _, _, _, _ = __u, __u1, exp_x, hx, hy, lx, ly, x, y, v1 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + __u = *(*Tuint64_t)(unsafe.Pointer(&y)) + hy = uint32(__u >> int32(32)) + ly = uint32(__u) + hy = hy & uint32(0x7fffffff) + /* cexp(x + I 0) = exp(x) + I 0 */ + if hy|ly == uint32(0) { + v1 = [2]float64{ + 0: Xexp(tls, x), + 1: y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + __u1 = *(*Tuint64_t)(unsafe.Pointer(&x)) + hx = uint32(__u1 >> int32(32)) + lx = uint32(__u1) + /* cexp(0 + I y) = cos(y) + I sin(y) */ + if hx&uint32(0x7fffffff)|lx == uint32(0) { + v1 = [2]float64{ + 0: Xcos(tls, y), + 1: Xsin(tls, y), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + if hy >= uint32(0x7ff00000) { + if lx != uint32(0) || hx&uint32(0x7fffffff) != uint32(0x7ff00000) { + /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ + v1 = [2]float64{ + 0: y - y, + 1: y - y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + if hx&uint32(0x80000000) != 0 { + /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ + v1 = [2]float64{} + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ + v1 = [2]float64{ + 0: x, + 1: y - y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + } + } + if hx >= _exp_ovfl && hx <= _cexp_ovfl { + /* + * x is between 709.7 and 1454.3, so we must scale to avoid + * overflow in exp(x). + */ + return X__ldexp_cexp(tls, z, 0) + } else { + /* + * Cases covered here: + * - x < exp_ovfl and exp(x) won't overflow (common case) + * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 + * - x = +-Inf (generated by exp()) + * - x = NaN (spurious inexact exception from y) + */ + exp_x = Xexp(tls, x) + v1 = [2]float64{ + 0: float64(exp_x * Xcos(tls, y)), + 1: float64(exp_x * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + return r +} + +var _exp_ovfl1 = uint32(0x42b17218) /* MAX_EXP * ln2 ~= 88.722839355 */ +var _cexp_ovfl1 = uint32(0x43400074) /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */ + +func Xcexpf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var exp_x, x, y float32 + var hx, hy Tuint32_t + var v1 [2]float32 + _, _, _, _, _, _ = exp_x, hx, hy, x, y, v1 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + hy = *(*Tuint32_t)(unsafe.Pointer(&y)) + hy = hy & uint32(0x7fffffff) + /* cexp(x + I 0) = exp(x) + I 0 */ + if hy == uint32(0) { + v1 = [2]float32{ + 0: Xexpf(tls, x), + 1: y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + hx = *(*Tuint32_t)(unsafe.Pointer(&x)) + /* cexp(0 + I y) = cos(y) + I sin(y) */ + if hx&uint32(0x7fffffff) == uint32(0) { + v1 = [2]float32{ + 0: Xcosf(tls, y), + 1: Xsinf(tls, y), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if hy >= uint32(0x7f800000) { + if hx&uint32(0x7fffffff) != uint32(0x7f800000) { + /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ + v1 = [2]float32{ + 0: y - y, + 1: y - y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + if hx&uint32(0x80000000) != 0 { + /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ + v1 = [2]float32{} + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ + v1 = [2]float32{ + 0: x, + 1: y - y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + } + } + if hx >= _exp_ovfl1 && hx <= _cexp_ovfl1 { + /* + * x is between 88.7 and 192, so we must scale to avoid + * overflow in expf(x). + */ + return X__ldexp_cexpf(tls, z, 0) + } else { + /* + * Cases covered here: + * - x < exp_ovfl and exp(x) won't overflow (common case) + * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 + * - x = +-Inf (generated by exp()) + * - x = NaN (spurious inexact exception from y) + */ + exp_x = Xexpf(tls, x) + v1 = [2]float32{ + 0: float32(exp_x * Xcosf(tls, y)), + 1: float32(exp_x * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + return r +} + +// C documentation +// +// //FIXME +func Xcexpl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcexp(tls, Complex128FromComplex128(z))) +} + +func Xcimag(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] +} + +func Xcimagf(tls *TLS, z complex64) (r float32) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] +} + +func Xcimagl(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] +} + +// FIXME + +/* log(z) = log(|z|) + i arg(z) */ + +func Xclog(tls *TLS, z complex128) (r1 complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var phi, r float64 + var v1 [2]float64 + _, _, _ = phi, r, v1 + r = Xcabs(tls, z) + phi = Xcarg(tls, z) + v1 = [2]float64{ + 0: Xlog(tls, r), + 1: phi, + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +// FIXME + +func Xclogf(tls *TLS, z complex64) (r1 complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var phi, r float32 + var v1 [2]float32 + _, _, _ = phi, r, v1 + r = Xcabsf(tls, z) + phi = Xcargf(tls, z) + v1 = [2]float32{ + 0: Xlogf(tls, r), + 1: phi, + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xclogl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xclog(tls, Complex128FromComplex128(z))) +} + +func Xconj(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: Float64FromComplex128(z), + 1: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xconjf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: Float32FromComplex64(z), + 1: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xconjl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: Float64FromComplex128(z), + 1: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +/* pow(z, c) = exp(c log(z)), See C99 G.6.4.1 */ + +func Xcpow(tls *TLS, z complex128, c complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v c=%v, (%v:)", tls, z, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcexp(tls, c*Xclog(tls, z)) +} + +func Xcpowf(tls *TLS, z complex64, c complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v c=%v, (%v:)", tls, z, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcexpf(tls, c*Xclogf(tls, z)) +} + +func Xcpowl(tls *TLS, z complex128, c complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v c=%v, (%v:)", tls, z, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcpow(tls, Complex128FromComplex128(z), Complex128FromComplex128(c))) +} + +func Xcproj(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3 uint64 + var v5 bool + var v6 [2]float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _ = v1, v3, v5, v6 + *(*float64)(unsafe.Pointer(bp)) = Float64FromComplex128(z) + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3 uint32 + var v5 bool + var v6 [2]float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _ = v1, v3, v5, v6 + *(*float32)(unsafe.Pointer(bp)) = Float32FromComplex64(z) + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) == uint32(0x7f800000)) != 0; !v5 { + *(*float32)(unsafe.Pointer(bp)) = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&uint32(0x7fffffff) == uint32(0x7f800000)) != 0 { + v6 = [2]float32{ + 0: X__builtin_inff(tls), + 1: Xcopysignf(tls, float32(0), +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)]), + } + return *(*complex64)(unsafe.Pointer(&v6)) + } + return z +} + +func Xcprojl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcproj(tls, Complex128FromComplex128(z))) +} + +func Xcreal(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Float64FromComplex128(z) +} + +func Xcrealf(tls *TLS, z complex64) (r float32) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Float32FromComplex64(z) +} + +func Xcreall(tls *TLS, z complex128) (r float64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Float64FromComplex128(z) +} + +/* sin(z) = -i sinh(i z) */ + +func Xcsin(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + z = Xcsinh(tls, *(*complex128)(unsafe.Pointer(&v1))) + v1 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xcsinf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + z = Xcsinhf(tls, *(*complex64)(unsafe.Pointer(&v1))) + v1 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +var _huge2 = float64(8.98846567431158e+307) + +func Xcsinh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u, __u1 Tuint64_t + var h, x, y float64 + var hx, hy, ix, iy, lx, ly Tint32_t + var v1 [2]float64 + _, _, _, _, _, _, _, _, _, _, _, _ = __u, __u1, h, hx, hy, ix, iy, lx, ly, x, y, v1 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + hx = Int32FromUint64(__u >> int32(32)) + lx = Int32FromUint32(uint32(__u)) + __u1 = *(*Tuint64_t)(unsafe.Pointer(&y)) + hy = Int32FromUint64(__u1 >> int32(32)) + ly = Int32FromUint32(uint32(__u1)) + ix = int32(0x7fffffff) & hx + iy = int32(0x7fffffff) & hy + /* Handle the nearly-non-exceptional cases where x and y are finite. */ + if ix < int32(0x7ff00000) && iy < int32(0x7ff00000) { + if iy|ly == 0 { + v1 = [2]float64{ + 0: Xsinh(tls, x), + 1: y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + if ix < int32(0x40360000) { /* small x: normal case */ + v1 = [2]float64{ + 0: float64(Xsinh(tls, x) * Xcos(tls, y)), + 1: float64(Xcosh(tls, x) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* |x| >= 22, so cosh(x) ~= exp(|x|) */ + if ix < int32(0x40862e42) { + /* x < 710: exp(|x|) won't overflow */ + h = float64(Xexp(tls, Xfabs(tls, x)) * float64(0.5)) + v1 = [2]float64{ + 0: float64(Xcopysign(tls, h, x) * Xcos(tls, y)), + 1: float64(h * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + if ix < int32(0x4096bbaa) { + /* x < 1455: scale to avoid overflow */ + v1 = [2]float64{ + 0: Xfabs(tls, x), + 1: y, + } + z = X__ldexp_cexp(tls, *(*complex128)(unsafe.Pointer(&v1)), -int32(1)) + v1 = [2]float64{ + 0: float64(Float64FromComplex128(z) * Xcopysign(tls, Float64FromInt32(1), x)), + 1: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + /* x >= 1455: the result always overflows */ + h = float64(_huge2 * x) + v1 = [2]float64{ + 0: float64(h * Xcos(tls, y)), + 1: float64(float64(h*h) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + } + } + /* + * sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN. + * The sign of 0 in the result is unspecified. Choice = normally + * the same as dNaN. Raise the invalid floating-point exception. + * + * sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN). + * The sign of 0 in the result is unspecified. Choice = normally + * the same as d(NaN). + */ + if ix|lx == 0 && iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: Xcopysign(tls, Float64FromInt32(0), float64(x*(y-y))), + 1: y - y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * sinh(+-Inf +- I 0) = +-Inf + I +-0. + * + * sinh(NaN +- I 0) = d(NaN) + I +-0. + */ + if iy|ly == 0 && ix >= int32(0x7ff00000) { + if hx&int32(0xfffff)|lx == 0 { + v1 = [2]float64{ + 0: x, + 1: y, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v1 = [2]float64{ + 0: x, + 1: Xcopysign(tls, Float64FromInt32(0), y), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * sinh(x +- I Inf) = dNaN + I dNaN. + * Raise the invalid floating-point exception for finite nonzero x. + * + * sinh(x + I NaN) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception for finite + * nonzero x. Choice = don't raise (except for signaling NaNs). + */ + if ix < int32(0x7ff00000) && iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: y - y, + 1: float64(x * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * sinh(+-Inf + I NaN) = +-Inf + I d(NaN). + * The sign of Inf in the result is unspecified. Choice = normally + * the same as d(NaN). + * + * sinh(+-Inf +- I Inf) = +Inf + I dNaN. + * The sign of Inf in the result is unspecified. Choice = always +. + * Raise the invalid floating-point exception. + * + * sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y) + */ + if ix >= int32(0x7ff00000) && hx&int32(0xfffff)|lx == 0 { + if iy >= int32(0x7ff00000) { + v1 = [2]float64{ + 0: float64(x * x), + 1: float64(x * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v1 = [2]float64{ + 0: float64(x * Xcos(tls, y)), + 1: float64(float64(X__builtin_inff(tls)) * Xsin(tls, y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* + * sinh(NaN + I NaN) = d(NaN) + I d(NaN). + * + * sinh(NaN +- I Inf) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception. + * Choice = raise. + * + * sinh(NaN + I y) = d(NaN) + I d(NaN). + * Optionally raises the invalid floating-point exception for finite + * nonzero y. Choice = don't raise (except for signaling NaNs). + */ + v1 = [2]float64{ + 0: float64(float64(x*x) * (y - y)), + 1: float64((x + x) * (y - y)), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +var _huge3 = float32(1.7014118346046923e+38) + +func Xcsinhf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h, x, y float32 + var hx, hy, ix, iy Tint32_t + var v1 [2]float32 + _, _, _, _, _, _, _, _ = h, hx, hy, ix, iy, x, y, v1 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + hx = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(&x))) + hy = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(&y))) + ix = int32(0x7fffffff) & hx + iy = int32(0x7fffffff) & hy + if ix < int32(0x7f800000) && iy < int32(0x7f800000) { + if iy == 0 { + v1 = [2]float32{ + 0: Xsinhf(tls, x), + 1: y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix < int32(0x41100000) { /* small x: normal case */ + v1 = [2]float32{ + 0: float32(Xsinhf(tls, x) * Xcosf(tls, y)), + 1: float32(Xcoshf(tls, x) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + /* |x| >= 9, so cosh(x) ~= exp(|x|) */ + if ix < int32(0x42b17218) { + /* x < 88.7: expf(|x|) won't overflow */ + h = float32(Xexpf(tls, Xfabsf(tls, x)) * Float32FromFloat32(0.5)) + v1 = [2]float32{ + 0: float32(Xcopysignf(tls, h, x) * Xcosf(tls, y)), + 1: float32(h * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + if ix < int32(0x4340b1e7) { + /* x < 192.7: scale to avoid overflow */ + v1 = [2]float32{ + 0: Xfabsf(tls, x), + 1: y, + } + z = X__ldexp_cexpf(tls, *(*complex64)(unsafe.Pointer(&v1)), -int32(1)) + v1 = [2]float32{ + 0: float32(Float32FromComplex64(z) * Xcopysignf(tls, Float32FromInt32(1), x)), + 1: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + /* x >= 192.7: the result always overflows */ + h = float32(_huge3 * x) + v1 = [2]float32{ + 0: float32(h * Xcosf(tls, y)), + 1: float32(float32(h*h) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + } + } + if ix == 0 && iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: Xcopysignf(tls, Float32FromInt32(0), float32(x*(y-y))), + 1: y - y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if iy == 0 && ix >= int32(0x7f800000) { + if hx&int32(0x7fffff) == 0 { + v1 = [2]float32{ + 0: x, + 1: y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: x, + 1: Xcopysignf(tls, Float32FromInt32(0), y), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix < int32(0x7f800000) && iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: y - y, + 1: float32(x * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix >= int32(0x7f800000) && hx&int32(0x7fffff) == 0 { + if iy >= int32(0x7f800000) { + v1 = [2]float32{ + 0: float32(x * x), + 1: float32(x * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(x * Xcosf(tls, y)), + 1: float32(X__builtin_inff(tls) * Xsinf(tls, y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v1 = [2]float32{ + 0: float32(float32(x*x) * (y - y)), + 1: float32((x + x) * (y - y)), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +// C documentation +// +// //FIXME +func Xcsinhl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcsinh(tls, Complex128FromComplex128(z))) +} + +func Xcsinl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcsin(tls, Complex128FromComplex128(z))) +} + +const THRESH = 7.446288774449766e+307 + +/* + * gcc doesn't implement complex multiplication or division correctly, + * so we need to handle infinities specially. We turn on this pragma to + * notify conforming c99 compilers that the fast-but-incorrect code that + * gcc generates is acceptable, since the special cases have already been + * handled. + */ + +/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */ + +func Xcsqrt(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var a, b, t float64 + var result complex128 + var scale int32 + var v1 [2]float64 + var v2, v5 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _, _ = a, b, result, scale, t, v1, v2, v5 + a = Float64FromComplex128(z) + b = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + /* Handle special cases. */ + if z == Complex128FromInt32(0) { + v1 = [2]float64{ + 1: b, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + *(*float64)(unsafe.Pointer(bp)) = b + v2 = *(*uint64)(unsafe.Pointer(bp)) + goto _3 +_3: + if BoolInt32(v2&(-Uint64FromUint64(1)>>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != 0 { + v1 = [2]float64{ + 0: Xfabs(tls, b-b), + 1: Xcopysign(tls, a, b), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } else { + v1 = [2]float64{ + 0: a, + 1: Xcopysign(tls, b-b, b), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + } + /* + * The remaining special case (b is NaN) is handled just fine by + * the normal code path below. + */ + /* Scale to avoid overflow. */ + if Xfabs(tls, a) >= float64(7.446288774449766e+307) || Xfabs(tls, b) >= float64(7.446288774449766e+307) { + a = a * float64(0.25) + b = b * float64(0.25) + scale = int32(1) + } else { + scale = 0 + } + /* Algorithm 312, CACM vol 10, Oct 1967. */ + if a >= Float64FromInt32(0) { + t = Xsqrt(tls, float64((a+Xhypot(tls, a, b))*float64(0.5))) + v1 = [2]float64{ + 0: t, + 1: b / float64(Float64FromInt32(2)*t), + } + result = *(*complex128)(unsafe.Pointer(&v1)) + } else { + t = Xsqrt(tls, float64((-a+Xhypot(tls, a, b))*float64(0.5))) + v1 = [2]float64{ + 0: Xfabs(tls, b) / float64(Float64FromInt32(2)*t), + 1: Xcopysign(tls, t, b), + } + result = *(*complex128)(unsafe.Pointer(&v1)) + } + /* Rescale. */ + if scale != 0 { + result = result * Complex128FromInt32(2) + } + return result +} + +/* + * gcc doesn't implement complex multiplication or division correctly, + * so we need to handle infinities specially. We turn on this pragma to + * notify conforming c99 compilers that the fast-but-incorrect code that + * gcc generates is acceptable, since the special cases have already been + * handled. + */ + +func Xcsqrtf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var a, b float32 + var t float64 + var v1 [2]float32 + var v2, v5 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _ = a, b, t, v1, v2, v5 + a = Float32FromComplex64(z) + b = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + /* Handle special cases. */ + if z == Complex64FromInt32(0) { + v1 = [2]float32{ + 1: b, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + *(*float32)(unsafe.Pointer(bp)) = b + v2 = *(*uint32)(unsafe.Pointer(bp)) + goto _3 +_3: + if BoolInt32(v2&uint32(0x7fffffff) == uint32(0x7f800000)) != 0 { + v1 = [2]float32{ + 0: X__builtin_inff(tls), + 1: b, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + *(*float32)(unsafe.Pointer(bp)) = a + v2 = *(*uint32)(unsafe.Pointer(bp)) + goto _6 +_6: + if BoolInt32(v2&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + t = float64((b - b) / (b - b)) /* raise invalid if b is not a NaN */ + v1 = [2]float32{ + 0: a, + 1: float32(t), + } + return *(*complex64)(unsafe.Pointer(&v1)) /* return NaN + NaN i */ + } + *(*float32)(unsafe.Pointer(bp)) = a + v2 = *(*uint32)(unsafe.Pointer(bp)) + goto _9 +_9: + if BoolInt32(v2&uint32(0x7fffffff) == uint32(0x7f800000)) != 0 { + /* + * csqrtf(inf + NaN i) = inf + NaN i + * csqrtf(inf + y i) = inf + 0 i + * csqrtf(-inf + NaN i) = NaN +- inf i + * csqrtf(-inf + y i) = 0 + inf i + */ + *(*float32)(unsafe.Pointer(bp)) = a + v5 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v5>>Int32FromInt32(31)) != 0 { + v1 = [2]float32{ + 0: Xfabsf(tls, b-b), + 1: Xcopysignf(tls, a, b), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + v1 = [2]float32{ + 0: a, + 1: Xcopysignf(tls, b-b, b), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + } + /* + * The remaining special case (b is NaN) is handled just fine by + * the normal code path below. + */ + /* + * We compute t in double precision to avoid overflow and to + * provide correct rounding in nearly all cases. + * This is Algorithm 312, CACM vol 10, Oct 1967. + */ + if a >= Float32FromInt32(0) { + t = Xsqrt(tls, float64((float64(a)+Xhypot(tls, float64(a), float64(b)))*float64(0.5))) + v1 = [2]float32{ + 0: float32(t), + 1: float32(float64(b) / float64(Float64FromFloat64(2)*t)), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } else { + t = Xsqrt(tls, float64((float64(-a)+Xhypot(tls, float64(a), float64(b)))*float64(0.5))) + v1 = [2]float32{ + 0: float32(float64(Xfabsf(tls, b)) / float64(Float64FromFloat64(2)*t)), + 1: Xcopysignf(tls, float32(t), b), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + return r +} + +// C documentation +// +// //FIXME +func Xcsqrtl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xcsqrt(tls, Complex128FromComplex128(z))) +} + +/* tan(z) = -i tanh(i z) */ + +func Xctan(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float64 + _ = v1 + v1 = [2]float64{ + 0: -+(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: Float64FromComplex128(z), + } + z = Xctanh(tls, *(*complex128)(unsafe.Pointer(&v1))) + v1 = [2]float64{ + 0: +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float64FromComplex128(z), + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xctanf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 [2]float32 + _ = v1 + v1 = [2]float32{ + 0: -+(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: Float32FromComplex64(z), + } + z = Xctanhf(tls, *(*complex64)(unsafe.Pointer(&v1))) + v1 = [2]float32{ + 0: +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)], + 1: -Float32FromComplex64(z), + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +func Xctanh(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var __u1, v3 Tuint64_t + var beta, denom, exp_mx, rho, s, t, x, y, v2 float64 + var hx, ix, lx Tuint32_t + var v1 [2]float64 + var v6 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __u1, beta, denom, exp_mx, hx, ix, lx, rho, s, t, x, y, v1, v2, v3, v6 + x = Float64FromComplex128(z) + y = +(*(*[2]float64)(unsafe.Pointer(&z)))[int32(1)] + __u1 = *(*Tuint64_t)(unsafe.Pointer(&x)) + hx = uint32(__u1 >> int32(32)) + lx = uint32(__u1) + ix = hx & uint32(0x7fffffff) + /* + * ctanh(NaN + i 0) = NaN + i 0 + * + * ctanh(NaN + i y) = NaN + i NaN for y != 0 + * + * The imaginary part has the sign of x*sin(2*y), but there's no + * special effort to get this right. + * + * ctanh(+-Inf +- i Inf) = +-1 +- 0 + * + * ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite + * + * The imaginary part of the sign is unspecified. This special + * case is only needed to avoid a spurious invalid exception when + * y is infinite. + */ + if ix >= uint32(0x7ff00000) { + if ix&uint32(0xfffff)|lx != 0 { /* x is NaN */ + if y == Float64FromInt32(0) { + v2 = y + } else { + v2 = float64(x * y) + } + v1 = [2]float64{ + 0: x, + 1: v2, + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + v3 = uint64(hx-Uint32FromInt32(0x40000000))<>Int32FromInt32(1)) == Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)<= uint32(0x40360000) { /* x >= 22 */ + exp_mx = Xexp(tls, -Xfabs(tls, x)) + v1 = [2]float64{ + 0: Xcopysign(tls, Float64FromInt32(1), x), + 1: float64(float64(float64(float64(Float64FromInt32(4)*Xsin(tls, y))*Xcos(tls, y))*exp_mx) * exp_mx), + } + return *(*complex128)(unsafe.Pointer(&v1)) + } + /* Kahan's algorithm */ + t = Xtan(tls, y) + beta = float64(1) + float64(t*t) /* = 1 / cos^2(y) */ + s = Xsinh(tls, x) + rho = Xsqrt(tls, Float64FromInt32(1)+float64(s*s)) /* = cosh(x) */ + denom = Float64FromInt32(1) + float64(float64(beta*s)*s) + v1 = [2]float64{ + 0: float64(float64(beta*rho)*s) / denom, + 1: t / denom, + } + return *(*complex128)(unsafe.Pointer(&v1)) +} + +func Xctanhf(tls *TLS, z complex64) (r complex64) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var beta, denom, exp_mx, rho, s, t, x, y, v2 float32 + var hx, ix, v3 Tuint32_t + var v1 [2]float32 + var v6 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = beta, denom, exp_mx, hx, ix, rho, s, t, x, y, v1, v2, v3, v6 + x = Float32FromComplex64(z) + y = +(*(*[2]float32)(unsafe.Pointer(&z)))[int32(1)] + hx = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = hx & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + if ix&uint32(0x7fffff) != 0 { + if y == Float32FromInt32(0) { + v2 = y + } else { + v2 = float32(x * y) + } + v1 = [2]float32{ + 0: x, + 1: v2, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + v3 = hx - uint32(0x40000000) + x = *(*float32)(unsafe.Pointer(&v3)) + *(*float32)(unsafe.Pointer(bp)) = y + v6 = *(*uint32)(unsafe.Pointer(bp)) + goto _7 + _7: + if BoolInt32(v6&uint32(0x7fffffff) == uint32(0x7f800000)) != 0 { + v2 = y + } else { + v2 = float32(Xsinf(tls, y) * Xcosf(tls, y)) + } + v1 = [2]float32{ + 0: x, + 1: Xcopysignf(tls, Float32FromInt32(0), v2), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + *(*float32)(unsafe.Pointer(bp)) = y + v6 = *(*uint32)(unsafe.Pointer(bp)) + goto _9 +_9: + if !(BoolInt32(v6&Uint32FromInt32(0x7fffffff) < Uint32FromInt32(0x7f800000)) != 0) { + if ix != 0 { + v2 = y - y + } else { + v2 = x + } + v1 = [2]float32{ + 0: v2, + 1: y - y, + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + if ix >= uint32(0x41300000) { /* x >= 11 */ + exp_mx = Xexpf(tls, -Xfabsf(tls, x)) + v1 = [2]float32{ + 0: Xcopysignf(tls, Float32FromInt32(1), x), + 1: float32(float32(float32(float32(Float32FromInt32(4)*Xsinf(tls, y))*Xcosf(tls, y))*exp_mx) * exp_mx), + } + return *(*complex64)(unsafe.Pointer(&v1)) + } + t = Xtanf(tls, y) + beta = float32(float64(1) + float64(t*t)) + s = Xsinhf(tls, x) + rho = Xsqrtf(tls, Float32FromInt32(1)+float32(s*s)) + denom = Float32FromInt32(1) + float32(float32(beta*s)*s) + v1 = [2]float32{ + 0: float32(float32(beta*rho)*s) / denom, + 1: t / denom, + } + return *(*complex64)(unsafe.Pointer(&v1)) +} + +// C documentation +// +// //FIXME +func Xctanhl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xctanh(tls, Complex128FromComplex128(z))) +} + +func Xctanl(tls *TLS, z complex128) (r complex128) { + if __ccgo_strace { + trc("tls=%v z=%v, (%v:)", tls, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Complex128FromComplex128(Xctan(tls, Complex128FromComplex128(z))) +} + +const BUFSIZ = 1024 +const E2BIG = 7 +const EACCES = 13 +const EADDRINUSE = 98 +const EADDRNOTAVAIL = 99 +const EADV = 68 +const EAFNOSUPPORT = 97 +const EAGAIN = 11 +const EALREADY = 114 +const EBADE = 52 +const EBADF = 9 +const EBADFD = 77 +const EBADMSG = 74 +const EBADR = 53 +const EBADRQC = 56 +const EBADSLT = 57 +const EBFONT = 59 +const EBUSY = 16 +const ECANCELED = 125 +const ECHILD = 10 +const ECHRNG = 44 +const ECOMM = 70 +const ECONNABORTED = 103 +const ECONNREFUSED = 111 +const ECONNRESET = 104 +const EDEADLK = 35 +const EDEADLOCK = 35 +const EDESTADDRREQ = 89 +const EDOM = 33 +const EDOTDOT = 73 +const EDQUOT = 122 +const EEXIST = 17 +const EFAULT = 14 +const EFBIG = 27 +const EHOSTDOWN = 112 +const EHOSTUNREACH = 113 +const EHWPOISON = 133 +const EIDRM = 43 +const EILSEQ = 84 +const EINPROGRESS = 115 +const EINTR = 4 +const EINVAL = 22 +const EIO = 5 +const EISCONN = 106 +const EISDIR = 21 +const EISNAM = 120 +const EKEYEXPIRED = 127 +const EKEYREJECTED = 129 +const EKEYREVOKED = 128 +const EL2HLT = 51 +const EL2NSYNC = 45 +const EL3HLT = 46 +const EL3RST = 47 +const ELIBACC = 79 +const ELIBBAD = 80 +const ELIBEXEC = 83 +const ELIBMAX = 82 +const ELIBSCN = 81 +const ELNRNG = 48 +const ELOOP = 40 +const EMEDIUMTYPE = 124 +const EMFILE = 24 +const EMLINK = 31 +const EMSGSIZE = 90 +const EMULTIHOP = 72 +const ENAMETOOLONG = 36 +const ENAVAIL = 119 +const ENETDOWN = 100 +const ENETRESET = 102 +const ENETUNREACH = 101 +const ENFILE = 23 +const ENOANO = 55 +const ENOBUFS = 105 +const ENOCSI = 50 +const ENODATA = 61 +const ENODEV = 19 +const ENOENT = 2 +const ENOEXEC = 8 +const ENOKEY = 126 +const ENOLCK = 37 +const ENOLINK = 67 +const ENOMEDIUM = 123 +const ENOMEM = 12 +const ENOMSG = 42 +const ENONET = 64 +const ENOPKG = 65 +const ENOPROTOOPT = 92 +const ENOSPC = 28 +const ENOSR = 63 +const ENOSTR = 60 +const ENOSYS = 38 +const ENOTBLK = 15 +const ENOTCONN = 107 +const ENOTDIR = 20 +const ENOTEMPTY = 39 +const ENOTNAM = 118 +const ENOTRECOVERABLE = 131 +const ENOTSOCK = 88 +const ENOTSUP = 95 +const ENOTTY = 25 +const ENOTUNIQ = 76 +const ENXIO = 6 +const EOPNOTSUPP = 95 +const EOVERFLOW = 75 +const EOWNERDEAD = 130 +const EPERM = 1 +const EPFNOSUPPORT = 96 +const EPIPE = 32 +const EPROTO = 71 +const EPROTONOSUPPORT = 93 +const EPROTOTYPE = 91 +const ERANGE = 34 +const EREMCHG = 78 +const EREMOTE = 66 +const EREMOTEIO = 121 +const ERESTART = 85 +const ERFKILL = 132 +const EROFS = 30 +const ESHUTDOWN = 108 +const ESOCKTNOSUPPORT = 94 +const ESPIPE = 29 +const ESRCH = 3 +const ESRMNT = 69 +const ESTALE = 116 +const ESTRPIPE = 86 +const ETIME = 62 +const ETIMEDOUT = 110 +const ETOOMANYREFS = 109 +const ETXTBSY = 26 +const EUCLEAN = 117 +const EUNATCH = 49 +const EUSERS = 87 +const EWOULDBLOCK = 11 +const EXDEV = 18 +const EXFULL = 54 +const FILENAME_MAX = 4096 +const FOPEN_MAX = 1000 +const F_LOCK = 1 +const F_OK = 0 +const F_TEST = 3 +const F_TLOCK = 2 +const F_ULOCK = 0 +const L_ctermid = 20 +const L_tmpnam = 20 +const POSIX_CLOSE_RESTART = 0 +const P_tmpdir = "/tmp" +const R_OK = 4 +const SEEK_DATA = 3 +const SEEK_HOLE = 4 +const STDERR_FILENO = 2 +const STDIN_FILENO = 0 +const STDOUT_FILENO = 1 +const TMP_MAX = 10000 +const W_OK = 2 +const X_OK = 1 +const _CS_GNU_LIBC_VERSION = 2 +const _CS_GNU_LIBPTHREAD_VERSION = 3 +const _CS_PATH = 0 +const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS = 4 +const _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 +const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 +const _CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 +const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 +const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 +const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 +const _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 +const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 +const _CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 +const _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 +const _CS_POSIX_V6_LP64_OFF64_LIBS = 1126 +const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 +const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 +const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 +const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 +const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 +const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 1 +const _CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 +const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 +const _CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 +const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 +const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 +const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 +const _CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 +const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 +const _CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 +const _CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 +const _CS_POSIX_V7_LP64_OFF64_LIBS = 1142 +const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 +const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 +const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 +const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 +const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 +const _CS_POSIX_V7_THREADS_CFLAGS = 1150 +const _CS_POSIX_V7_THREADS_LDFLAGS = 1151 +const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS = 5 +const _CS_V6_ENV = 1148 +const _CS_V7_ENV = 1149 +const _IOFBF = 0 +const _IOLBF = 1 +const _IONBF = 2 +const _PC_2_SYMLINKS = 20 +const _PC_ALLOC_SIZE_MIN = 18 +const _PC_ASYNC_IO = 10 +const _PC_CHOWN_RESTRICTED = 6 +const _PC_FILESIZEBITS = 13 +const _PC_LINK_MAX = 0 +const _PC_MAX_CANON = 1 +const _PC_MAX_INPUT = 2 +const _PC_NAME_MAX = 3 +const _PC_NO_TRUNC = 7 +const _PC_PATH_MAX = 4 +const _PC_PIPE_BUF = 5 +const _PC_PRIO_IO = 11 +const _PC_REC_INCR_XFER_SIZE = 14 +const _PC_REC_MAX_XFER_SIZE = 15 +const _PC_REC_MIN_XFER_SIZE = 16 +const _PC_REC_XFER_ALIGN = 17 +const _PC_SOCK_MAXBUF = 12 +const _PC_SYMLINK_MAX = 19 +const _PC_SYNC_IO = 9 +const _PC_VDISABLE = 8 +const _POSIX2_C_BIND = 200809 +const _POSIX2_VERSION = 200809 +const _POSIX_ADVISORY_INFO = 200809 +const _POSIX_ASYNCHRONOUS_IO = 200809 +const _POSIX_BARRIERS = 200809 +const _POSIX_CHOWN_RESTRICTED = 1 +const _POSIX_CLOCK_SELECTION = 200809 +const _POSIX_CPUTIME = 200809 +const _POSIX_FSYNC = 200809 +const _POSIX_IPV6 = 200809 +const _POSIX_JOB_CONTROL = 1 +const _POSIX_MAPPED_FILES = 200809 +const _POSIX_MEMLOCK = 200809 +const _POSIX_MEMLOCK_RANGE = 200809 +const _POSIX_MEMORY_PROTECTION = 200809 +const _POSIX_MESSAGE_PASSING = 200809 +const _POSIX_MONOTONIC_CLOCK = 200809 +const _POSIX_NO_TRUNC = 1 +const _POSIX_RAW_SOCKETS = 200809 +const _POSIX_READER_WRITER_LOCKS = 200809 +const _POSIX_REALTIME_SIGNALS = 200809 +const _POSIX_REGEXP = 1 +const _POSIX_SAVED_IDS = 1 +const _POSIX_SEMAPHORES = 200809 +const _POSIX_SHARED_MEMORY_OBJECTS = 200809 +const _POSIX_SHELL = 1 +const _POSIX_SPAWN = 200809 +const _POSIX_SPIN_LOCKS = 200809 +const _POSIX_THREADS = 200809 +const _POSIX_THREAD_ATTR_STACKADDR = 200809 +const _POSIX_THREAD_ATTR_STACKSIZE = 200809 +const _POSIX_THREAD_CPUTIME = 200809 +const _POSIX_THREAD_PRIORITY_SCHEDULING = 200809 +const _POSIX_THREAD_PROCESS_SHARED = 200809 +const _POSIX_THREAD_SAFE_FUNCTIONS = 200809 +const _POSIX_TIMEOUTS = 200809 +const _POSIX_TIMERS = 200809 +const _POSIX_V6_LP64_OFF64 = 1 +const _POSIX_V7_LP64_OFF64 = 1 +const _POSIX_VDISABLE = 0 +const _POSIX_VERSION = 200809 +const _SC_2_CHAR_TERM = 95 +const _SC_2_C_BIND = 47 +const _SC_2_C_DEV = 48 +const _SC_2_FORT_DEV = 49 +const _SC_2_FORT_RUN = 50 +const _SC_2_LOCALEDEF = 52 +const _SC_2_PBS = 168 +const _SC_2_PBS_ACCOUNTING = 169 +const _SC_2_PBS_CHECKPOINT = 175 +const _SC_2_PBS_LOCATE = 170 +const _SC_2_PBS_MESSAGE = 171 +const _SC_2_PBS_TRACK = 172 +const _SC_2_SW_DEV = 51 +const _SC_2_UPE = 97 +const _SC_2_VERSION = 46 +const _SC_ADVISORY_INFO = 132 +const _SC_AIO_LISTIO_MAX = 23 +const _SC_AIO_MAX = 24 +const _SC_AIO_PRIO_DELTA_MAX = 25 +const _SC_ARG_MAX = 0 +const _SC_ASYNCHRONOUS_IO = 12 +const _SC_ATEXIT_MAX = 87 +const _SC_AVPHYS_PAGES = 86 +const _SC_BARRIERS = 133 +const _SC_BC_BASE_MAX = 36 +const _SC_BC_DIM_MAX = 37 +const _SC_BC_SCALE_MAX = 38 +const _SC_BC_STRING_MAX = 39 +const _SC_CHILD_MAX = 1 +const _SC_CLK_TCK = 2 +const _SC_CLOCK_SELECTION = 137 +const _SC_COLL_WEIGHTS_MAX = 40 +const _SC_CPUTIME = 138 +const _SC_DELAYTIMER_MAX = 26 +const _SC_EXPR_NEST_MAX = 42 +const _SC_FSYNC = 15 +const _SC_GETGR_R_SIZE_MAX = 69 +const _SC_GETPW_R_SIZE_MAX = 70 +const _SC_HOST_NAME_MAX = 180 +const _SC_IOV_MAX = 60 +const _SC_IPV6 = 235 +const _SC_JOB_CONTROL = 7 +const _SC_LINE_MAX = 43 +const _SC_LOGIN_NAME_MAX = 71 +const _SC_MAPPED_FILES = 16 +const _SC_MEMLOCK = 17 +const _SC_MEMLOCK_RANGE = 18 +const _SC_MEMORY_PROTECTION = 19 +const _SC_MESSAGE_PASSING = 20 +const _SC_MINSIGSTKSZ = 249 +const _SC_MONOTONIC_CLOCK = 149 +const _SC_MQ_OPEN_MAX = 27 +const _SC_MQ_PRIO_MAX = 28 +const _SC_NGROUPS_MAX = 3 +const _SC_NPROCESSORS_CONF = 83 +const _SC_NPROCESSORS_ONLN = 84 +const _SC_NZERO = 109 +const _SC_OPEN_MAX = 4 +const _SC_PAGESIZE = 30 +const _SC_PAGE_SIZE = 30 +const _SC_PASS_MAX = 88 +const _SC_PHYS_PAGES = 85 +const _SC_PRIORITIZED_IO = 13 +const _SC_PRIORITY_SCHEDULING = 10 +const _SC_RAW_SOCKETS = 236 +const _SC_READER_WRITER_LOCKS = 153 +const _SC_REALTIME_SIGNALS = 9 +const _SC_REGEXP = 155 +const _SC_RE_DUP_MAX = 44 +const _SC_RTSIG_MAX = 31 +const _SC_SAVED_IDS = 8 +const _SC_SEMAPHORES = 21 +const _SC_SEM_NSEMS_MAX = 32 +const _SC_SEM_VALUE_MAX = 33 +const _SC_SHARED_MEMORY_OBJECTS = 22 +const _SC_SHELL = 157 +const _SC_SIGQUEUE_MAX = 34 +const _SC_SIGSTKSZ = 250 +const _SC_SPAWN = 159 +const _SC_SPIN_LOCKS = 154 +const _SC_SPORADIC_SERVER = 160 +const _SC_SS_REPL_MAX = 241 +const _SC_STREAMS = 174 +const _SC_STREAM_MAX = 5 +const _SC_SYMLOOP_MAX = 173 +const _SC_SYNCHRONIZED_IO = 14 +const _SC_THREADS = 67 +const _SC_THREAD_ATTR_STACKADDR = 77 +const _SC_THREAD_ATTR_STACKSIZE = 78 +const _SC_THREAD_CPUTIME = 139 +const _SC_THREAD_DESTRUCTOR_ITERATIONS = 73 +const _SC_THREAD_KEYS_MAX = 74 +const _SC_THREAD_PRIORITY_SCHEDULING = 79 +const _SC_THREAD_PRIO_INHERIT = 80 +const _SC_THREAD_PRIO_PROTECT = 81 +const _SC_THREAD_PROCESS_SHARED = 82 +const _SC_THREAD_ROBUST_PRIO_INHERIT = 247 +const _SC_THREAD_ROBUST_PRIO_PROTECT = 248 +const _SC_THREAD_SAFE_FUNCTIONS = 68 +const _SC_THREAD_SPORADIC_SERVER = 161 +const _SC_THREAD_STACK_MIN = 75 +const _SC_THREAD_THREADS_MAX = 76 +const _SC_TIMEOUTS = 164 +const _SC_TIMERS = 11 +const _SC_TIMER_MAX = 35 +const _SC_TRACE = 181 +const _SC_TRACE_EVENT_FILTER = 182 +const _SC_TRACE_EVENT_NAME_MAX = 242 +const _SC_TRACE_INHERIT = 183 +const _SC_TRACE_LOG = 184 +const _SC_TRACE_NAME_MAX = 243 +const _SC_TRACE_SYS_MAX = 244 +const _SC_TRACE_USER_EVENT_MAX = 245 +const _SC_TTY_NAME_MAX = 72 +const _SC_TYPED_MEMORY_OBJECTS = 165 +const _SC_TZNAME_MAX = 6 +const _SC_UIO_MAXIOV = 60 +const _SC_V6_ILP32_OFF32 = 176 +const _SC_V6_ILP32_OFFBIG = 177 +const _SC_V6_LP64_OFF64 = 178 +const _SC_V6_LPBIG_OFFBIG = 179 +const _SC_V7_ILP32_OFF32 = 237 +const _SC_V7_ILP32_OFFBIG = 238 +const _SC_V7_LP64_OFF64 = 239 +const _SC_V7_LPBIG_OFFBIG = 240 +const _SC_VERSION = 29 +const _SC_XBS5_ILP32_OFF32 = 125 +const _SC_XBS5_ILP32_OFFBIG = 126 +const _SC_XBS5_LP64_OFF64 = 127 +const _SC_XBS5_LPBIG_OFFBIG = 128 +const _SC_XOPEN_CRYPT = 92 +const _SC_XOPEN_ENH_I18N = 93 +const _SC_XOPEN_LEGACY = 129 +const _SC_XOPEN_REALTIME = 130 +const _SC_XOPEN_REALTIME_THREADS = 131 +const _SC_XOPEN_SHM = 94 +const _SC_XOPEN_STREAMS = 246 +const _SC_XOPEN_UNIX = 91 +const _SC_XOPEN_VERSION = 89 +const _SC_XOPEN_XCU_VERSION = 90 +const _SC_XOPEN_XPG2 = 98 +const _SC_XOPEN_XPG3 = 99 +const _SC_XOPEN_XPG4 = 100 +const _XOPEN_ENH_I18N = 1 +const _XOPEN_UNIX = 1 +const _XOPEN_VERSION = 700 + +type Tsize_t = uint64 + +type Tssize_t = int64 + +type Toff_t = int64 + +type Tpid_t = int32 + +type Tuid_t = uint32 + +type Tgid_t = uint32 + +type Tuseconds_t = uint32 + +type Tva_list = uintptr + +type t__isoc_va_list = uintptr + +type Tfpos_t = struct { + F__lldata [0]int64 + F__align [0]float64 + F__opaque [16]uint8 +} + +type T_G_fpos64_t = Tfpos_t + +func Xconfstr(tls *TLS, name int32, buf uintptr, len1 Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v name=%v buf=%v len1=%v, (%v:)", tls, name, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var s uintptr + _ = s + s = __ccgo_ts + if !(name != 0) { + s = __ccgo_ts + 1 + } else { + if Uint32FromInt32(name) & ^Uint32FromUint32(4) != uint32(1) && Uint32FromInt32(name-int32(_CS_POSIX_V6_ILP32_OFF32_CFLAGS)) > uint32(35) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uint64(0) + } + } + // snprintf is overkill but avoid wasting code size to implement + // this completely useless function and its truncation semantics + return Uint64FromInt32(Xsnprintf(tls, buf, len1, __ccgo_ts+15, VaList(bp+8, s)) + int32(1)) +} + +const ARG_MAX = 131072 +const BC_BASE_MAX = 99 +const BC_DIM_MAX = 2048 +const BC_SCALE_MAX = 99 +const BC_STRING_MAX = 1000 +const CHARCLASS_NAME_MAX = 14 +const CHAR_BIT = 8 +const CHAR_MAX = 255 +const CHAR_MIN = 0 +const COLL_WEIGHTS_MAX = 2 +const DELAYTIMER_MAX = 2147483647 +const EXPR_NEST_MAX = 32 +const FILESIZEBITS = 64 +const HOST_NAME_MAX = 255 +const INT_MAX = 2147483647 +const INT_MIN = -2147483648 +const IOV_MAX = 1024 +const LINE_MAX = 4096 +const LLONG_MAX = 9223372036854775807 +const LLONG_MIN = -9223372036854775808 +const LOGIN_NAME_MAX = 256 +const LONG_BIT = 64 +const LONG_MAX = 9223372036854775807 +const LONG_MIN = -9223372036854775808 +const MB_LEN_MAX = 4 +const MQ_PRIO_MAX = 32768 +const NAME_MAX = 255 +const NGROUPS_MAX = 32 +const NL_ARGMAX = 9 +const NL_LANGMAX = 32 +const NL_MSGMAX = 32767 +const NL_SETMAX = 255 +const NL_TEXTMAX = 2048 +const NZERO = 20 +const PATH_MAX = 4096 +const PIPE_BUF = 4096 +const PTHREAD_DESTRUCTOR_ITERATIONS = 4 +const PTHREAD_KEYS_MAX = 128 +const PTHREAD_STACK_MIN = 2048 +const RE_DUP_MAX = 255 +const SCHAR_MAX = 127 +const SCHAR_MIN = -128 +const SEEK_CUR = 1 +const SEEK_END = 2 +const SEEK_SET = 0 +const SEM_NSEMS_MAX = 256 +const SEM_VALUE_MAX = 2147483647 +const SHRT_MAX = 32767 +const SHRT_MIN = -32768 +const SSIZE_MAX = 9223372036854775807 +const SYMLOOP_MAX = 40 +const TTY_NAME_MAX = 32 +const TZNAME_MAX = 6 +const UCHAR_MAX = 255 +const UINT_MAX = 4294967295 +const ULLONG_MAX = 18446744073709551615 +const ULONG_MAX = 18446744073709551615 +const USHRT_MAX = 65535 +const WORD_BIT = 32 +const _POSIX2_BC_BASE_MAX = 99 +const _POSIX2_BC_DIM_MAX = 2048 +const _POSIX2_BC_SCALE_MAX = 99 +const _POSIX2_BC_STRING_MAX = 1000 +const _POSIX2_CHARCLASS_NAME_MAX = 14 +const _POSIX2_COLL_WEIGHTS_MAX = 2 +const _POSIX2_EXPR_NEST_MAX = 32 +const _POSIX2_LINE_MAX = 2048 +const _POSIX2_RE_DUP_MAX = 255 +const _POSIX_AIO_LISTIO_MAX = 2 +const _POSIX_AIO_MAX = 1 +const _POSIX_ARG_MAX = 4096 +const _POSIX_CHILD_MAX = 25 +const _POSIX_CLOCKRES_MIN = 20000000 +const _POSIX_DELAYTIMER_MAX = 32 +const _POSIX_HOST_NAME_MAX = 255 +const _POSIX_LINK_MAX = 8 +const _POSIX_LOGIN_NAME_MAX = 9 +const _POSIX_MAX_CANON = 255 +const _POSIX_MAX_INPUT = 255 +const _POSIX_MQ_OPEN_MAX = 8 +const _POSIX_MQ_PRIO_MAX = 32 +const _POSIX_NAME_MAX = 14 +const _POSIX_NGROUPS_MAX = 8 +const _POSIX_OPEN_MAX = 20 +const _POSIX_PATH_MAX = 256 +const _POSIX_PIPE_BUF = 512 +const _POSIX_RE_DUP_MAX = 255 +const _POSIX_RTSIG_MAX = 8 +const _POSIX_SEM_NSEMS_MAX = 256 +const _POSIX_SEM_VALUE_MAX = 32767 +const _POSIX_SIGQUEUE_MAX = 32 +const _POSIX_SSIZE_MAX = 32767 +const _POSIX_SS_REPL_MAX = 4 +const _POSIX_STREAM_MAX = 8 +const _POSIX_SYMLINK_MAX = 255 +const _POSIX_SYMLOOP_MAX = 8 +const _POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 +const _POSIX_THREAD_KEYS_MAX = 128 +const _POSIX_THREAD_THREADS_MAX = 64 +const _POSIX_TIMER_MAX = 32 +const _POSIX_TRACE_EVENT_NAME_MAX = 30 +const _POSIX_TRACE_NAME_MAX = 8 +const _POSIX_TRACE_SYS_MAX = 8 +const _POSIX_TRACE_USER_EVENT_MAX = 32 +const _POSIX_TTY_NAME_MAX = 9 +const _POSIX_TZNAME_MAX = 6 +const _XOPEN_IOV_MAX = 16 +const _XOPEN_NAME_MAX = 255 +const _XOPEN_PATH_MAX = 1024 + +func Xfpathconf(tls *TLS, fd int32, name int32) (r int64) { + if __ccgo_strace { + trc("tls=%v fd=%v name=%v, (%v:)", tls, fd, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + if Uint64FromInt32(name) >= Uint64FromInt64(42)/Uint64FromInt64(2) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) + } + return int64(_values[name]) +} + +var _values = [21]int16{ + 0: int16(_POSIX_LINK_MAX), + 1: int16(_POSIX_MAX_CANON), + 2: int16(_POSIX_MAX_INPUT), + 3: int16(NAME_MAX), + 4: int16(PATH_MAX), + 5: int16(PIPE_BUF), + 6: int16(1), + 7: int16(1), + 9: int16(1), + 10: int16(-int32(1)), + 11: int16(-int32(1)), + 12: int16(-int32(1)), + 13: int16(FILESIZEBITS), + 14: int16(4096), + 15: int16(4096), + 16: int16(4096), + 17: int16(4096), + 18: int16(4096), + 19: int16(-int32(1)), + 20: int16(1), +} + +const SI_LOAD_SHIFT = 16 + +type Tsysinfo = struct { + Fuptime uint64 + Floads [3]uint64 + Ftotalram uint64 + Ffreeram uint64 + Fsharedram uint64 + Fbufferram uint64 + Ftotalswap uint64 + Ffreeswap uint64 + Fprocs uint16 + Fpad uint16 + Ftotalhigh uint64 + Ffreehigh uint64 + Fmem_unit uint32 + F__reserved [256]uint8 +} + +func Xget_nprocs_conf(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(Xsysconf(tls, int32(_SC_NPROCESSORS_CONF))) +} + +func Xget_nprocs(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(Xsysconf(tls, int32(_SC_NPROCESSORS_ONLN))) +} + +func Xget_phys_pages(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsysconf(tls, int32(_SC_PHYS_PAGES)) +} + +func Xget_avphys_pages(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsysconf(tls, int32(_SC_AVPHYS_PAGES)) +} + +func Xpathconf(tls *TLS, path uintptr, name int32) (r int64) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v, (%v:)", tls, path, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfpathconf(tls, -int32(1), name) +} + +const AT_BASE = 7 +const AT_BASE_PLATFORM = 24 +const AT_CLKTCK = 17 +const AT_DCACHEBSIZE = 19 +const AT_EGID = 14 +const AT_ENTRY = 9 +const AT_EUID = 12 +const AT_EXECFD = 2 +const AT_EXECFN = 31 +const AT_FLAGS = 8 +const AT_FPUCW = 18 +const AT_GID = 13 +const AT_HWCAP = 16 +const AT_HWCAP2 = 26 +const AT_ICACHEBSIZE = 20 +const AT_IGNORE = 1 +const AT_IGNOREPPC = 22 +const AT_L1D_CACHEGEOMETRY = 43 +const AT_L1D_CACHESHAPE = 35 +const AT_L1D_CACHESIZE = 42 +const AT_L1I_CACHEGEOMETRY = 41 +const AT_L1I_CACHESHAPE = 34 +const AT_L1I_CACHESIZE = 40 +const AT_L2_CACHEGEOMETRY = 45 +const AT_L2_CACHESHAPE = 36 +const AT_L2_CACHESIZE = 44 +const AT_L3_CACHEGEOMETRY = 47 +const AT_L3_CACHESHAPE = 37 +const AT_L3_CACHESIZE = 46 +const AT_MINSIGSTKSZ = 51 +const AT_NOTELF = 10 +const AT_NULL = 0 +const AT_PAGESZ = 6 +const AT_PHDR = 3 +const AT_PHENT = 4 +const AT_PHNUM = 5 +const AT_PLATFORM = 15 +const AT_RANDOM = 25 +const AT_SECURE = 23 +const AT_SYSINFO = 32 +const AT_SYSINFO_EHDR = 33 +const AT_UCACHEBSIZE = 21 +const AT_UID = 11 +const BUS_ADRALN = 1 +const BUS_ADRERR = 2 +const BUS_MCEERR_AO = 5 +const BUS_MCEERR_AR = 4 +const BUS_OBJERR = 3 +const CLD_CONTINUED = 6 +const CLD_DUMPED = 3 +const CLD_EXITED = 1 +const CLD_KILLED = 2 +const CLD_STOPPED = 5 +const CLD_TRAPPED = 4 +const DF_1_CONFALT = 8192 +const DF_1_DIRECT = 256 +const DF_1_DISPRELDNE = 32768 +const DF_1_DISPRELPND = 65536 +const DF_1_EDITED = 2097152 +const DF_1_ENDFILTEE = 16384 +const DF_1_GLOBAL = 2 +const DF_1_GLOBAUDIT = 16777216 +const DF_1_GROUP = 4 +const DF_1_IGNMULDEF = 262144 +const DF_1_INITFIRST = 32 +const DF_1_INTERPOSE = 1024 +const DF_1_LOADFLTR = 16 +const DF_1_NODEFLIB = 2048 +const DF_1_NODELETE = 8 +const DF_1_NODIRECT = 131072 +const DF_1_NODUMP = 4096 +const DF_1_NOHDR = 1048576 +const DF_1_NOKSYMS = 524288 +const DF_1_NOOPEN = 64 +const DF_1_NORELOC = 4194304 +const DF_1_NOW = 1 +const DF_1_ORIGIN = 128 +const DF_1_PIE = 134217728 +const DF_1_SINGLETON = 33554432 +const DF_1_STUB = 67108864 +const DF_1_SYMINTPOSE = 8388608 +const DF_1_TRANS = 512 +const DF_BIND_NOW = 8 +const DF_ORIGIN = 1 +const DF_P1_GROUPPERM = 2 +const DF_P1_LAZYLOAD = 1 +const DF_STATIC_TLS = 16 +const DF_SYMBOLIC = 2 +const DF_TEXTREL = 4 +const DTF_1_CONFEXP = 2 +const DTF_1_PARINIT = 1 +const DT_ADDRNUM = 11 +const DT_ADDRRNGHI = 1879047935 +const DT_ADDRRNGLO = 1879047680 +const DT_ALPHA_NUM = 1 +const DT_ALPHA_PLTRO = 1879048192 +const DT_AUDIT = 1879047932 +const DT_AUXILIARY = 2147483645 +const DT_BIND_NOW = 24 +const DT_CHECKSUM = 1879047672 +const DT_CONFIG = 1879047930 +const DT_DEBUG = 21 +const DT_DEPAUDIT = 1879047931 +const DT_ENCODING = 32 +const DT_EXTRANUM = 3 +const DT_FEATURE_1 = 1879047676 +const DT_FILTER = 2147483647 +const DT_FINI = 13 +const DT_FINI_ARRAY = 26 +const DT_FINI_ARRAYSZ = 28 +const DT_FLAGS = 30 +const DT_FLAGS_1 = 1879048187 +const DT_GNU_CONFLICT = 1879047928 +const DT_GNU_CONFLICTSZ = 1879047670 +const DT_GNU_HASH = 1879047925 +const DT_GNU_LIBLIST = 1879047929 +const DT_GNU_LIBLISTSZ = 1879047671 +const DT_GNU_PRELINKED = 1879047669 +const DT_HASH = 4 +const DT_HIOS = 1879044096 +const DT_HIPROC = 2147483647 +const DT_IA_64_NUM = 1 +const DT_IA_64_PLT_RESERVE = 1879048192 +const DT_INIT = 12 +const DT_INIT_ARRAY = 25 +const DT_INIT_ARRAYSZ = 27 +const DT_JMPREL = 23 +const DT_LOOS = 1610612749 +const DT_LOPROC = 1879048192 +const DT_MIPS_AUX_DYNAMIC = 1879048241 +const DT_MIPS_BASE_ADDRESS = 1879048198 +const DT_MIPS_COMPACT_SIZE = 1879048239 +const DT_MIPS_CONFLICT = 1879048200 +const DT_MIPS_CONFLICTNO = 1879048203 +const DT_MIPS_CXX_FLAGS = 1879048226 +const DT_MIPS_DELTA_CLASS = 1879048215 +const DT_MIPS_DELTA_CLASSSYM = 1879048224 +const DT_MIPS_DELTA_CLASSSYM_NO = 1879048225 +const DT_MIPS_DELTA_CLASS_NO = 1879048216 +const DT_MIPS_DELTA_INSTANCE = 1879048217 +const DT_MIPS_DELTA_INSTANCE_NO = 1879048218 +const DT_MIPS_DELTA_RELOC = 1879048219 +const DT_MIPS_DELTA_RELOC_NO = 1879048220 +const DT_MIPS_DELTA_SYM = 1879048221 +const DT_MIPS_DELTA_SYM_NO = 1879048222 +const DT_MIPS_DYNSTR_ALIGN = 1879048235 +const DT_MIPS_FLAGS = 1879048197 +const DT_MIPS_GOTSYM = 1879048211 +const DT_MIPS_GP_VALUE = 1879048240 +const DT_MIPS_HIDDEN_GOTIDX = 1879048231 +const DT_MIPS_HIPAGENO = 1879048212 +const DT_MIPS_ICHECKSUM = 1879048195 +const DT_MIPS_INTERFACE = 1879048234 +const DT_MIPS_INTERFACE_SIZE = 1879048236 +const DT_MIPS_IVERSION = 1879048196 +const DT_MIPS_LIBLIST = 1879048201 +const DT_MIPS_LIBLISTNO = 1879048208 +const DT_MIPS_LOCALPAGE_GOTIDX = 1879048229 +const DT_MIPS_LOCAL_GOTIDX = 1879048230 +const DT_MIPS_LOCAL_GOTNO = 1879048202 +const DT_MIPS_MSYM = 1879048199 +const DT_MIPS_NUM = 54 +const DT_MIPS_OPTIONS = 1879048233 +const DT_MIPS_PERF_SUFFIX = 1879048238 +const DT_MIPS_PIXIE_INIT = 1879048227 +const DT_MIPS_PLTGOT = 1879048242 +const DT_MIPS_PROTECTED_GOTIDX = 1879048232 +const DT_MIPS_RLD_MAP = 1879048214 +const DT_MIPS_RLD_MAP_REL = 1879048245 +const DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 1879048237 +const DT_MIPS_RLD_VERSION = 1879048193 +const DT_MIPS_RWPLT = 1879048244 +const DT_MIPS_SYMBOL_LIB = 1879048228 +const DT_MIPS_SYMTABNO = 1879048209 +const DT_MIPS_TIME_STAMP = 1879048194 +const DT_MIPS_UNREFEXTNO = 1879048210 +const DT_MOVEENT = 1879047674 +const DT_MOVESZ = 1879047675 +const DT_MOVETAB = 1879047934 +const DT_NEEDED = 1 +const DT_NIOS2_GP = 1879048194 +const DT_NULL = 0 +const DT_NUM = 38 +const DT_PLTGOT = 3 +const DT_PLTPAD = 1879047933 +const DT_PLTPADSZ = 1879047673 +const DT_PLTREL = 20 +const DT_PLTRELSZ = 2 +const DT_POSFLAG_1 = 1879047677 +const DT_PPC64_GLINK = 1879048192 +const DT_PPC64_NUM = 4 +const DT_PPC64_OPD = 1879048193 +const DT_PPC64_OPDSZ = 1879048194 +const DT_PPC64_OPT = 1879048195 +const DT_PPC_GOT = 1879048192 +const DT_PPC_NUM = 2 +const DT_PPC_OPT = 1879048193 +const DT_PREINIT_ARRAY = 32 +const DT_PREINIT_ARRAYSZ = 33 +const DT_PROCNUM = 54 +const DT_REL = 17 +const DT_RELA = 7 +const DT_RELACOUNT = 1879048185 +const DT_RELAENT = 9 +const DT_RELASZ = 8 +const DT_RELCOUNT = 1879048186 +const DT_RELENT = 19 +const DT_RELR = 36 +const DT_RELRENT = 37 +const DT_RELRSZ = 35 +const DT_RELSZ = 18 +const DT_RPATH = 15 +const DT_RUNPATH = 29 +const DT_SONAME = 14 +const DT_SPARC_NUM = 2 +const DT_SPARC_REGISTER = 1879048193 +const DT_STRSZ = 10 +const DT_STRTAB = 5 +const DT_SYMBOLIC = 16 +const DT_SYMENT = 11 +const DT_SYMINENT = 1879047679 +const DT_SYMINFO = 1879047935 +const DT_SYMINSZ = 1879047678 +const DT_SYMTAB = 6 +const DT_SYMTAB_SHNDX = 34 +const DT_TEXTREL = 22 +const DT_TLSDESC_GOT = 1879047927 +const DT_TLSDESC_PLT = 1879047926 +const DT_VALNUM = 12 +const DT_VALRNGHI = 1879047679 +const DT_VALRNGLO = 1879047424 +const DT_VERDEF = 1879048188 +const DT_VERDEFNUM = 1879048189 +const DT_VERNEED = 1879048190 +const DT_VERNEEDNUM = 1879048191 +const DT_VERSIONTAGNUM = 16 +const DT_VERSYM = 1879048176 +const EFA_PARISC_1_0 = 523 +const EFA_PARISC_1_1 = 528 +const EFA_PARISC_2_0 = 532 +const EF_ALPHA_32BIT = 1 +const EF_ALPHA_CANRELAX = 2 +const EF_ARM_ABI_FLOAT_HARD = 1024 +const EF_ARM_ABI_FLOAT_SOFT = 512 +const EF_ARM_ALIGN8 = 64 +const EF_ARM_APCS_26 = 8 +const EF_ARM_APCS_FLOAT = 16 +const EF_ARM_BE8 = 8388608 +const EF_ARM_DYNSYMSUSESEGIDX = 8 +const EF_ARM_EABIMASK = 4278190080 +const EF_ARM_EABI_UNKNOWN = 0 +const EF_ARM_EABI_VER1 = 16777216 +const EF_ARM_EABI_VER2 = 33554432 +const EF_ARM_EABI_VER3 = 50331648 +const EF_ARM_EABI_VER4 = 67108864 +const EF_ARM_EABI_VER5 = 83886080 +const EF_ARM_HASENTRY = 2 +const EF_ARM_INTERWORK = 4 +const EF_ARM_LE8 = 4194304 +const EF_ARM_MAPSYMSFIRST = 16 +const EF_ARM_MAVERICK_FLOAT = 2048 +const EF_ARM_NEW_ABI = 128 +const EF_ARM_OLD_ABI = 256 +const EF_ARM_PIC = 32 +const EF_ARM_RELEXEC = 1 +const EF_ARM_SOFT_FLOAT = 512 +const EF_ARM_SYMSARESORTED = 4 +const EF_ARM_VFP_FLOAT = 1024 +const EF_CPU32 = 8454144 +const EF_IA_64_ABI64 = 16 +const EF_IA_64_ARCH = 4278190080 +const EF_IA_64_MASKOS = 15 +const EF_LARCH_ABI_DOUBLE_FLOAT = 3 +const EF_LARCH_ABI_MODIFIER_MASK = 7 +const EF_LARCH_ABI_SINGLE_FLOAT = 2 +const EF_LARCH_ABI_SOFT_FLOAT = 1 +const EF_LARCH_OBJABI_V1 = 64 +const EF_MIPS_64BIT_WHIRL = 16 +const EF_MIPS_ABI2 = 32 +const EF_MIPS_ABI_ON32 = 64 +const EF_MIPS_ARCH = 4026531840 +const EF_MIPS_ARCH_1 = 0 +const EF_MIPS_ARCH_2 = 268435456 +const EF_MIPS_ARCH_3 = 536870912 +const EF_MIPS_ARCH_32 = 1342177280 +const EF_MIPS_ARCH_32R2 = 1879048192 +const EF_MIPS_ARCH_4 = 805306368 +const EF_MIPS_ARCH_5 = 1073741824 +const EF_MIPS_ARCH_64 = 1610612736 +const EF_MIPS_ARCH_64R2 = 2147483648 +const EF_MIPS_CPIC = 4 +const EF_MIPS_FP64 = 512 +const EF_MIPS_NAN2008 = 1024 +const EF_MIPS_NOREORDER = 1 +const EF_MIPS_PIC = 2 +const EF_MIPS_XGOT = 8 +const EF_PARISC_ARCH = 65535 +const EF_PARISC_EXT = 131072 +const EF_PARISC_LAZYSWAP = 4194304 +const EF_PARISC_LSB = 262144 +const EF_PARISC_NO_KABP = 1048576 +const EF_PARISC_TRAPNIL = 65536 +const EF_PARISC_WIDE = 524288 +const EF_PPC64_ABI = 3 +const EF_PPC_EMB = 2147483648 +const EF_PPC_RELOCATABLE = 65536 +const EF_PPC_RELOCATABLE_LIB = 32768 +const EF_SH1 = 1 +const EF_SH2 = 2 +const EF_SH2A = 13 +const EF_SH2A_NOFPU = 19 +const EF_SH2A_SH3E = 24 +const EF_SH2A_SH3_NOFPU = 22 +const EF_SH2A_SH4 = 23 +const EF_SH2A_SH4_NOFPU = 21 +const EF_SH2E = 11 +const EF_SH3 = 3 +const EF_SH3E = 8 +const EF_SH3_DSP = 5 +const EF_SH3_NOMMU = 20 +const EF_SH4 = 9 +const EF_SH4A = 12 +const EF_SH4AL_DSP = 6 +const EF_SH4A_NOFPU = 17 +const EF_SH4_NOFPU = 16 +const EF_SH4_NOMMU_NOFPU = 18 +const EF_SH_DSP = 4 +const EF_SH_MACH_MASK = 31 +const EF_SH_UNKNOWN = 0 +const EF_SPARCV9_MM = 3 +const EF_SPARCV9_PSO = 1 +const EF_SPARCV9_RMO = 2 +const EF_SPARCV9_TSO = 0 +const EF_SPARC_32PLUS = 256 +const EF_SPARC_EXT_MASK = 16776960 +const EF_SPARC_HAL_R1 = 1024 +const EF_SPARC_LEDATA = 8388608 +const EF_SPARC_SUN_US1 = 512 +const EF_SPARC_SUN_US3 = 2048 +const EI_ABIVERSION = 8 +const EI_CLASS = 4 +const EI_DATA = 5 +const EI_MAG0 = 0 +const EI_MAG1 = 1 +const EI_MAG2 = 2 +const EI_MAG3 = 3 +const EI_NIDENT = 16 +const EI_OSABI = 7 +const EI_PAD = 9 +const EI_VERSION = 6 +const ELFCLASS32 = 1 +const ELFCLASS64 = 2 +const ELFCLASSNONE = 0 +const ELFCLASSNUM = 3 +const ELFCOMPRESS_HIOS = 1879048191 +const ELFCOMPRESS_HIPROC = 2147483647 +const ELFCOMPRESS_LOOS = 1610612736 +const ELFCOMPRESS_LOPROC = 1879048192 +const ELFCOMPRESS_ZLIB = 1 +const ELFCOMPRESS_ZSTD = 2 +const ELFDATA2LSB = 1 +const ELFDATA2MSB = 2 +const ELFDATANONE = 0 +const ELFDATANUM = 3 +const ELFMAG = "\\177ELF" +const ELFMAG0 = 127 +const ELFMAG1 = 69 +const ELFMAG2 = 76 +const ELFMAG3 = 70 +const ELFOSABI_AIX = 7 +const ELFOSABI_ARM = 97 +const ELFOSABI_FREEBSD = 9 +const ELFOSABI_GNU = 3 +const ELFOSABI_HPUX = 1 +const ELFOSABI_IRIX = 8 +const ELFOSABI_LINUX = 3 +const ELFOSABI_MODESTO = 11 +const ELFOSABI_NETBSD = 2 +const ELFOSABI_NONE = 0 +const ELFOSABI_OPENBSD = 12 +const ELFOSABI_SOLARIS = 6 +const ELFOSABI_STANDALONE = 255 +const ELFOSABI_SYSV = 0 +const ELFOSABI_TRU64 = 10 +const ELF_NOTE_ABI = 1 +const ELF_NOTE_GNU = "GNU" +const ELF_NOTE_OS_FREEBSD = 3 +const ELF_NOTE_OS_GNU = 1 +const ELF_NOTE_OS_LINUX = 0 +const ELF_NOTE_OS_SOLARIS2 = 2 +const ELF_NOTE_PAGESIZE_HINT = 1 +const ELF_NOTE_SOLARIS = "SUNW Solaris" +const EM_386 = 3 +const EM_56800EX = 200 +const EM_68HC05 = 72 +const EM_68HC08 = 71 +const EM_68HC11 = 70 +const EM_68HC12 = 53 +const EM_68HC16 = 69 +const EM_68K = 4 +const EM_78KOR = 199 +const EM_8051 = 165 +const EM_860 = 7 +const EM_88K = 5 +const EM_960 = 19 +const EM_AARCH64 = 183 +const EM_ALPHA = 36902 +const EM_ALTERA_NIOS2 = 113 +const EM_AMDGPU = 224 +const EM_ARC = 45 +const EM_ARCA = 109 +const EM_ARC_A5 = 93 +const EM_ARC_COMPACT = 93 +const EM_ARC_COMPACT2 = 195 +const EM_ARM = 40 +const EM_AVR = 83 +const EM_AVR32 = 185 +const EM_BA1 = 201 +const EM_BA2 = 202 +const EM_BLACKFIN = 106 +const EM_BPF = 247 +const EM_C166 = 116 +const EM_CDP = 215 +const EM_CE = 119 +const EM_CLOUDSHIELD = 192 +const EM_COGE = 216 +const EM_COLDFIRE = 52 +const EM_COOL = 217 +const EM_COREA_1ST = 193 +const EM_COREA_2ND = 194 +const EM_CR = 103 +const EM_CR16 = 177 +const EM_CRAYNV2 = 172 +const EM_CRIS = 76 +const EM_CRX = 114 +const EM_CSKY = 252 +const EM_CSR_KALIMBA = 219 +const EM_CUDA = 190 +const EM_CYPRESS_M8C = 161 +const EM_D10V = 85 +const EM_D30V = 86 +const EM_DSP24 = 136 +const EM_DSPIC30F = 118 +const EM_DXP = 112 +const EM_ECOG16 = 176 +const EM_ECOG1X = 168 +const EM_ECOG2 = 134 +const EM_EMX16 = 212 +const EM_EMX8 = 213 +const EM_ETPU = 178 +const EM_EXCESS = 111 +const EM_F2MC16 = 104 +const EM_FAKE_ALPHA = 41 +const EM_FIREPATH = 78 +const EM_FR20 = 37 +const EM_FR30 = 84 +const EM_FT32 = 222 +const EM_FX66 = 66 +const EM_H8S = 48 +const EM_H8_300 = 46 +const EM_H8_300H = 47 +const EM_H8_500 = 49 +const EM_HUANY = 81 +const EM_IA_64 = 50 +const EM_IP2K = 101 +const EM_JAVELIN = 77 +const EM_K10M = 181 +const EM_KM32 = 210 +const EM_KMX32 = 211 +const EM_KVARC = 214 +const EM_L10M = 180 +const EM_LATTICEMICO32 = 138 +const EM_LOONGARCH = 258 +const EM_M16C = 117 +const EM_M32 = 1 +const EM_M32C = 120 +const EM_M32R = 88 +const EM_MANIK = 171 +const EM_MAX = 102 +const EM_MAXQ30 = 169 +const EM_MCHP_PIC = 204 +const EM_MCST_ELBRUS = 175 +const EM_ME16 = 59 +const EM_METAG = 174 +const EM_MICROBLAZE = 189 +const EM_MIPS = 8 +const EM_MIPS_RS3_LE = 10 +const EM_MIPS_X = 51 +const EM_MMA = 54 +const EM_MMDSP_PLUS = 160 +const EM_MMIX = 80 +const EM_MN10200 = 90 +const EM_MN10300 = 89 +const EM_MOXIE = 223 +const EM_MSP430 = 105 +const EM_NCPU = 56 +const EM_NDR1 = 57 +const EM_NDS32 = 167 +const EM_NONE = 0 +const EM_NORC = 218 +const EM_NS32K = 97 +const EM_NUM = 259 +const EM_OPEN8 = 196 +const EM_OPENRISC = 92 +const EM_OR1K = 92 +const EM_PARISC = 15 +const EM_PCP = 55 +const EM_PDSP = 63 +const EM_PJ = 91 +const EM_PPC = 20 +const EM_PPC64 = 21 +const EM_PRISM = 82 +const EM_QDSP6 = 164 +const EM_R32C = 162 +const EM_RCE = 39 +const EM_RH32 = 38 +const EM_RISCV = 243 +const EM_RL78 = 197 +const EM_RS08 = 132 +const EM_RX = 173 +const EM_S370 = 9 +const EM_S390 = 22 +const EM_SCORE7 = 135 +const EM_SEP = 108 +const EM_SE_C17 = 139 +const EM_SE_C33 = 107 +const EM_SH = 42 +const EM_SHARC = 133 +const EM_SLE9X = 179 +const EM_SNP1K = 99 +const EM_SPARC = 2 +const EM_SPARC32PLUS = 18 +const EM_SPARCV9 = 43 +const EM_ST100 = 60 +const EM_ST19 = 74 +const EM_ST200 = 100 +const EM_ST7 = 68 +const EM_ST9PLUS = 67 +const EM_STARCORE = 58 +const EM_STM8 = 186 +const EM_STXP7X = 166 +const EM_SVX = 73 +const EM_TILE64 = 187 +const EM_TILEGX = 191 +const EM_TILEPRO = 188 +const EM_TINYJ = 61 +const EM_TI_ARP32 = 143 +const EM_TI_C2000 = 141 +const EM_TI_C5500 = 142 +const EM_TI_C6000 = 140 +const EM_TI_PRU = 144 +const EM_TMM_GPP = 96 +const EM_TPC = 98 +const EM_TRICORE = 44 +const EM_TRIMEDIA = 163 +const EM_TSK3000 = 131 +const EM_UNICORE = 110 +const EM_V800 = 36 +const EM_V850 = 87 +const EM_VAX = 75 +const EM_VIDEOCORE = 95 +const EM_VIDEOCORE3 = 137 +const EM_VIDEOCORE5 = 198 +const EM_VISIUM = 221 +const EM_VPP500 = 17 +const EM_X86_64 = 62 +const EM_XCORE = 203 +const EM_XGATE = 115 +const EM_XIMO16 = 170 +const EM_XTENSA = 94 +const EM_Z80 = 220 +const EM_ZSP = 79 +const ET_CORE = 4 +const ET_DYN = 3 +const ET_EXEC = 2 +const ET_HIOS = 65279 +const ET_HIPROC = 65535 +const ET_LOOS = 65024 +const ET_LOPROC = 65280 +const ET_NONE = 0 +const ET_NUM = 5 +const ET_REL = 1 +const EV_CURRENT = 1 +const EV_NONE = 0 +const EV_NUM = 2 +const EXIT_FAILURE = 1 +const EXIT_SUCCESS = 0 +const E_MIPS_ARCH_1 = 0 +const E_MIPS_ARCH_2 = 268435456 +const E_MIPS_ARCH_3 = 536870912 +const E_MIPS_ARCH_32 = 1342177280 +const E_MIPS_ARCH_4 = 805306368 +const E_MIPS_ARCH_5 = 1073741824 +const E_MIPS_ARCH_64 = 1610612736 +const FD_SETSIZE = 1024 +const FPE_FLTDIV = 3 +const FPE_FLTINV = 7 +const FPE_FLTOVF = 4 +const FPE_FLTRES = 6 +const FPE_FLTSUB = 8 +const FPE_FLTUND = 5 +const FPE_INTDIV = 1 +const FPE_INTOVF = 2 +const GRP_COMDAT = 1 +const HWCAP2_BF16 = 16384 +const HWCAP2_BTI = 131072 +const HWCAP2_DCPODP = 1 +const HWCAP2_DGH = 32768 +const HWCAP2_FLAGM2 = 128 +const HWCAP2_FRINT = 256 +const HWCAP2_I8MM = 8192 +const HWCAP2_MTE = 262144 +const HWCAP2_RNG = 65536 +const HWCAP2_SVE2 = 2 +const HWCAP2_SVEAES = 4 +const HWCAP2_SVEBF16 = 4096 +const HWCAP2_SVEBITPERM = 16 +const HWCAP2_SVEF32MM = 1024 +const HWCAP2_SVEF64MM = 2048 +const HWCAP2_SVEI8MM = 512 +const HWCAP2_SVEPMULL = 8 +const HWCAP2_SVESHA3 = 32 +const HWCAP2_SVESM4 = 64 +const HWCAP_AES = 8 +const HWCAP_ASIMD = 2 +const HWCAP_ASIMDDP = 1048576 +const HWCAP_ASIMDFHM = 8388608 +const HWCAP_ASIMDHP = 1024 +const HWCAP_ASIMDRDM = 4096 +const HWCAP_ATOMICS = 256 +const HWCAP_CPUID = 2048 +const HWCAP_CRC32 = 128 +const HWCAP_DCPOP = 65536 +const HWCAP_DIT = 16777216 +const HWCAP_EVTSTRM = 4 +const HWCAP_FCMA = 16384 +const HWCAP_FLAGM = 134217728 +const HWCAP_FP = 1 +const HWCAP_FPHP = 512 +const HWCAP_ILRCPC = 67108864 +const HWCAP_JSCVT = 8192 +const HWCAP_LRCPC = 32768 +const HWCAP_PACA = 1073741824 +const HWCAP_PACG = 2147483648 +const HWCAP_PMULL = 16 +const HWCAP_SB = 536870912 +const HWCAP_SHA1 = 32 +const HWCAP_SHA2 = 64 +const HWCAP_SHA3 = 131072 +const HWCAP_SHA512 = 2097152 +const HWCAP_SM3 = 262144 +const HWCAP_SM4 = 524288 +const HWCAP_SSBS = 268435456 +const HWCAP_SVE = 4194304 +const HWCAP_USCAT = 33554432 +const ILL_BADSTK = 8 +const ILL_COPROC = 7 +const ILL_ILLADR = 3 +const ILL_ILLOPC = 1 +const ILL_ILLOPN = 2 +const ILL_ILLTRP = 4 +const ILL_PRVOPC = 5 +const ILL_PRVREG = 6 +const IPC_64 = 0 +const ITIMER_PROF = 2 +const ITIMER_REAL = 0 +const ITIMER_VIRTUAL = 1 +const JT_ARG_MAX = -254 +const JT_AVPHYS_PAGES = -247 +const JT_DELAYTIMER_MAX = -245 +const JT_MINSIGSTKSZ = -244 +const JT_MQ_PRIO_MAX = -253 +const JT_NPROCESSORS_CONF = -250 +const JT_NPROCESSORS_ONLN = -249 +const JT_PAGE_SIZE = -252 +const JT_PHYS_PAGES = -248 +const JT_SEM_VALUE_MAX = -251 +const JT_SIGSTKSZ = -243 +const JT_ZERO = -246 +const LITUSE_ALPHA_ADDR = 0 +const LITUSE_ALPHA_BASE = 1 +const LITUSE_ALPHA_BYTOFF = 2 +const LITUSE_ALPHA_JSR = 3 +const LITUSE_ALPHA_TLS_GD = 4 +const LITUSE_ALPHA_TLS_LDM = 5 +const LL_DELAY_LOAD = 16 +const LL_DELTA = 32 +const LL_EXACT_MATCH = 1 +const LL_EXPORTS = 8 +const LL_IGNORE_INT_VER = 2 +const LL_NONE = 0 +const LL_REQUIRE_MINOR = 4 +const MB_CUR_MAX = 0 +const MINSIGSTKSZ = 6144 +const MIPS_AFL_ASE_DSP = 1 +const MIPS_AFL_ASE_DSPR2 = 2 +const MIPS_AFL_ASE_EVA = 4 +const MIPS_AFL_ASE_MASK = 8191 +const MIPS_AFL_ASE_MCU = 8 +const MIPS_AFL_ASE_MDMX = 16 +const MIPS_AFL_ASE_MICROMIPS = 2048 +const MIPS_AFL_ASE_MIPS16 = 1024 +const MIPS_AFL_ASE_MIPS3D = 32 +const MIPS_AFL_ASE_MSA = 512 +const MIPS_AFL_ASE_MT = 64 +const MIPS_AFL_ASE_SMARTMIPS = 128 +const MIPS_AFL_ASE_VIRT = 256 +const MIPS_AFL_ASE_XPA = 4096 +const MIPS_AFL_EXT_10000 = 11 +const MIPS_AFL_EXT_3900 = 10 +const MIPS_AFL_EXT_4010 = 8 +const MIPS_AFL_EXT_4100 = 9 +const MIPS_AFL_EXT_4111 = 13 +const MIPS_AFL_EXT_4120 = 14 +const MIPS_AFL_EXT_4650 = 7 +const MIPS_AFL_EXT_5400 = 15 +const MIPS_AFL_EXT_5500 = 16 +const MIPS_AFL_EXT_5900 = 6 +const MIPS_AFL_EXT_LOONGSON_2E = 17 +const MIPS_AFL_EXT_LOONGSON_2F = 18 +const MIPS_AFL_EXT_LOONGSON_3A = 4 +const MIPS_AFL_EXT_OCTEON = 5 +const MIPS_AFL_EXT_OCTEON2 = 2 +const MIPS_AFL_EXT_OCTEONP = 3 +const MIPS_AFL_EXT_SB1 = 12 +const MIPS_AFL_EXT_XLR = 1 +const MIPS_AFL_FLAGS1_ODDSPREG = 1 +const MIPS_AFL_REG_128 = 3 +const MIPS_AFL_REG_32 = 1 +const MIPS_AFL_REG_64 = 2 +const MIPS_AFL_REG_NONE = 0 +const NT_386_IOPERM = 513 +const NT_386_TLS = 512 +const NT_ARC_V2 = 1536 +const NT_ARM_HW_BREAK = 1026 +const NT_ARM_HW_WATCH = 1027 +const NT_ARM_PACA_KEYS = 1031 +const NT_ARM_PACG_KEYS = 1032 +const NT_ARM_PAC_ENABLED_KEYS = 1034 +const NT_ARM_PAC_MASK = 1030 +const NT_ARM_SVE = 1029 +const NT_ARM_SYSTEM_CALL = 1028 +const NT_ARM_TAGGED_ADDR_CTRL = 1033 +const NT_ARM_TLS = 1025 +const NT_ARM_VFP = 1024 +const NT_ASRS = 8 +const NT_AUXV = 6 +const NT_FILE = 1179208773 +const NT_FPREGSET = 2 +const NT_GNU_ABI_TAG = 1 +const NT_GNU_BUILD_ID = 3 +const NT_GNU_GOLD_VERSION = 4 +const NT_GNU_PROPERTY_TYPE_0 = 5 +const NT_GWINDOWS = 7 +const NT_LOONGARCH_CPUCFG = 2560 +const NT_LOONGARCH_CSR = 2561 +const NT_LOONGARCH_LASX = 2563 +const NT_LOONGARCH_LBT = 2564 +const NT_LOONGARCH_LSX = 2562 +const NT_LWPSINFO = 17 +const NT_LWPSTATUS = 16 +const NT_METAG_CBUF = 1280 +const NT_METAG_RPIPE = 1281 +const NT_METAG_TLS = 1282 +const NT_MIPS_DSP = 2048 +const NT_MIPS_FP_MODE = 2049 +const NT_MIPS_MSA = 2050 +const NT_PLATFORM = 5 +const NT_PPC_DSCR = 261 +const NT_PPC_EBB = 262 +const NT_PPC_PMU = 263 +const NT_PPC_PPR = 260 +const NT_PPC_SPE = 257 +const NT_PPC_TAR = 259 +const NT_PPC_TM_CDSCR = 271 +const NT_PPC_TM_CFPR = 265 +const NT_PPC_TM_CGPR = 264 +const NT_PPC_TM_CPPR = 270 +const NT_PPC_TM_CTAR = 269 +const NT_PPC_TM_CVMX = 266 +const NT_PPC_TM_CVSX = 267 +const NT_PPC_TM_SPR = 268 +const NT_PPC_VMX = 256 +const NT_PPC_VSX = 258 +const NT_PRCRED = 14 +const NT_PRFPREG = 2 +const NT_PRFPXREG = 20 +const NT_PRPSINFO = 3 +const NT_PRSTATUS = 1 +const NT_PRXFPREG = 1189489535 +const NT_PRXREG = 4 +const NT_PSINFO = 13 +const NT_PSTATUS = 10 +const NT_RISCV_CSR = 2304 +const NT_RISCV_VECTOR = 2305 +const NT_S390_CTRS = 772 +const NT_S390_GS_BC = 780 +const NT_S390_GS_CB = 779 +const NT_S390_HIGH_GPRS = 768 +const NT_S390_LAST_BREAK = 774 +const NT_S390_PREFIX = 773 +const NT_S390_RI_CB = 781 +const NT_S390_SYSTEM_CALL = 775 +const NT_S390_TDB = 776 +const NT_S390_TIMER = 769 +const NT_S390_TODCMP = 770 +const NT_S390_TODPREG = 771 +const NT_S390_VXRS_HIGH = 778 +const NT_S390_VXRS_LOW = 777 +const NT_SIGINFO = 1397311305 +const NT_TASKSTRUCT = 4 +const NT_UTSNAME = 15 +const NT_VERSION = 1 +const NT_VMCOREDD = 1792 +const NT_X86_XSTATE = 514 +const ODK_EXCEPTIONS = 2 +const ODK_FILL = 5 +const ODK_HWAND = 7 +const ODK_HWOR = 8 +const ODK_HWPATCH = 4 +const ODK_NULL = 0 +const ODK_PAD = 3 +const ODK_REGINFO = 1 +const ODK_TAGS = 6 +const OEX_DISMISS = 524288 +const OEX_FPDBUG = 262144 +const OEX_FPU_DIV0 = 8 +const OEX_FPU_INEX = 1 +const OEX_FPU_INVAL = 16 +const OEX_FPU_MAX = 7936 +const OEX_FPU_MIN = 31 +const OEX_FPU_OFLO = 4 +const OEX_FPU_UFLO = 2 +const OEX_PAGE0 = 65536 +const OEX_PRECISEFP = 262144 +const OEX_SMM = 131072 +const OHWA0_R4KEOP_CHECKED = 1 +const OHWA1_R4KEOP_CLEAN = 2 +const OHW_R4KEOP = 1 +const OHW_R5KCVTL = 8 +const OHW_R5KEOP = 4 +const OHW_R8KPFETCH = 2 +const OPAD_POSTFIX = 2 +const OPAD_PREFIX = 1 +const OPAD_SYMBOL = 4 +const PF_ARM_ABS = 1073741824 +const PF_ARM_PI = 536870912 +const PF_ARM_SB = 268435456 +const PF_HP_CODE = 16777216 +const PF_HP_FAR_SHARED = 2097152 +const PF_HP_LAZYSWAP = 67108864 +const PF_HP_MODIFY = 33554432 +const PF_HP_NEAR_SHARED = 4194304 +const PF_HP_PAGE_SIZE = 1048576 +const PF_HP_SBP = 134217728 +const PF_IA_64_NORECOV = 2147483648 +const PF_MASKOS = 267386880 +const PF_MASKPROC = 4026531840 +const PF_MIPS_LOCAL = 268435456 +const PF_PARISC_SBP = 134217728 +const PF_R = 4 +const PF_W = 2 +const PF_X = 1 +const PN_XNUM = 65535 +const POLL_ERR = 4 +const POLL_HUP = 6 +const POLL_IN = 1 +const POLL_MSG = 3 +const POLL_OUT = 2 +const POLL_PRI = 5 +const PPC64_OPT_LOCALENTRY = 4 +const PPC64_OPT_MULTI_TOC = 2 +const PPC64_OPT_TLS = 1 +const PPC_OPT_TLS = 1 +const PRIO_MAX = 20 +const PRIO_MIN = -20 +const PRIO_PGRP = 1 +const PRIO_PROCESS = 0 +const PRIO_USER = 2 +const PT_ARM_EXIDX = 1879048193 +const PT_DYNAMIC = 2 +const PT_GNU_EH_FRAME = 1685382480 +const PT_GNU_PROPERTY = 1685382483 +const PT_GNU_RELRO = 1685382482 +const PT_GNU_STACK = 1685382481 +const PT_HIOS = 1879048191 +const PT_HIPROC = 2147483647 +const PT_HISUNW = 1879048191 +const PT_HP_CORE_COMM = 1610612740 +const PT_HP_CORE_KERNEL = 1610612739 +const PT_HP_CORE_LOADABLE = 1610612742 +const PT_HP_CORE_MMF = 1610612745 +const PT_HP_CORE_NONE = 1610612737 +const PT_HP_CORE_PROC = 1610612741 +const PT_HP_CORE_SHM = 1610612744 +const PT_HP_CORE_STACK = 1610612743 +const PT_HP_CORE_VERSION = 1610612738 +const PT_HP_FASTBIND = 1610612753 +const PT_HP_HSL_ANNOT = 1610612755 +const PT_HP_OPT_ANNOT = 1610612754 +const PT_HP_PARALLEL = 1610612752 +const PT_HP_STACK = 1610612756 +const PT_HP_TLS = 1610612736 +const PT_IA_64_ARCHEXT = 1879048192 +const PT_IA_64_HP_HSL_ANOT = 1610612755 +const PT_IA_64_HP_OPT_ANOT = 1610612754 +const PT_IA_64_HP_STACK = 1610612756 +const PT_IA_64_UNWIND = 1879048193 +const PT_INTERP = 3 +const PT_LOAD = 1 +const PT_LOOS = 1610612736 +const PT_LOPROC = 1879048192 +const PT_LOSUNW = 1879048186 +const PT_MIPS_ABIFLAGS = 1879048195 +const PT_MIPS_OPTIONS = 1879048194 +const PT_MIPS_REGINFO = 1879048192 +const PT_MIPS_RTPROC = 1879048193 +const PT_NOTE = 4 +const PT_NULL = 0 +const PT_NUM = 8 +const PT_PARISC_ARCHEXT = 1879048192 +const PT_PARISC_UNWIND = 1879048193 +const PT_PHDR = 6 +const PT_SHLIB = 5 +const PT_SUNWBSS = 1879048186 +const PT_SUNWSTACK = 1879048187 +const PT_TLS = 7 +const RAND_MAX = 2147483647 +const RHF_CORD = 4096 +const RHF_DEFAULT_DELAY_LOAD = 512 +const RHF_DELTA_C_PLUS_PLUS = 64 +const RHF_GUARANTEE_INIT = 32 +const RHF_GUARANTEE_START_INIT = 128 +const RHF_NONE = 0 +const RHF_NOTPOT = 2 +const RHF_NO_LIBRARY_REPLACEMENT = 4 +const RHF_NO_MOVE = 8 +const RHF_NO_UNRES_UNDEF = 8192 +const RHF_PIXIE = 256 +const RHF_QUICKSTART = 1 +const RHF_REQUICKSTART = 1024 +const RHF_REQUICKSTARTED = 2048 +const RHF_RLD_ORDER_SAFE = 16384 +const RHF_SGI_ONLY = 16 +const RLIMIT_AS = 9 +const RLIMIT_CORE = 4 +const RLIMIT_CPU = 0 +const RLIMIT_DATA = 2 +const RLIMIT_FSIZE = 1 +const RLIMIT_LOCKS = 10 +const RLIMIT_MEMLOCK = 8 +const RLIMIT_MSGQUEUE = 12 +const RLIMIT_NICE = 13 +const RLIMIT_NLIMITS = 16 +const RLIMIT_NOFILE = 7 +const RLIMIT_NPROC = 6 +const RLIMIT_RSS = 5 +const RLIMIT_RTPRIO = 14 +const RLIMIT_RTTIME = 15 +const RLIMIT_SIGPENDING = 11 +const RLIMIT_STACK = 3 +const RLIM_INFINITY = 18446744073709551615 +const RLIM_NLIMITS = 16 +const RLIM_SAVED_CUR = 18446744073709551615 +const RLIM_SAVED_MAX = 18446744073709551615 +const RUSAGE_CHILDREN = -1 +const RUSAGE_SELF = 0 +const RUSAGE_THREAD = 1 +const R_386_16 = 20 +const R_386_32 = 1 +const R_386_32PLT = 11 +const R_386_8 = 22 +const R_386_COPY = 5 +const R_386_GLOB_DAT = 6 +const R_386_GOT32 = 3 +const R_386_GOT32X = 43 +const R_386_GOTOFF = 9 +const R_386_GOTPC = 10 +const R_386_IRELATIVE = 42 +const R_386_JMP_SLOT = 7 +const R_386_NONE = 0 +const R_386_NUM = 44 +const R_386_PC16 = 21 +const R_386_PC32 = 2 +const R_386_PC8 = 23 +const R_386_PLT32 = 4 +const R_386_RELATIVE = 8 +const R_386_SIZE32 = 38 +const R_386_TLS_DESC = 41 +const R_386_TLS_DESC_CALL = 40 +const R_386_TLS_DTPMOD32 = 35 +const R_386_TLS_DTPOFF32 = 36 +const R_386_TLS_GD = 18 +const R_386_TLS_GD_32 = 24 +const R_386_TLS_GD_CALL = 26 +const R_386_TLS_GD_POP = 27 +const R_386_TLS_GD_PUSH = 25 +const R_386_TLS_GOTDESC = 39 +const R_386_TLS_GOTIE = 16 +const R_386_TLS_IE = 15 +const R_386_TLS_IE_32 = 33 +const R_386_TLS_LDM = 19 +const R_386_TLS_LDM_32 = 28 +const R_386_TLS_LDM_CALL = 30 +const R_386_TLS_LDM_POP = 31 +const R_386_TLS_LDM_PUSH = 29 +const R_386_TLS_LDO_32 = 32 +const R_386_TLS_LE = 17 +const R_386_TLS_LE_32 = 34 +const R_386_TLS_TPOFF = 14 +const R_386_TLS_TPOFF32 = 37 +const R_390_12 = 2 +const R_390_16 = 3 +const R_390_20 = 57 +const R_390_32 = 4 +const R_390_64 = 22 +const R_390_8 = 1 +const R_390_COPY = 9 +const R_390_GLOB_DAT = 10 +const R_390_GOT12 = 6 +const R_390_GOT16 = 15 +const R_390_GOT20 = 58 +const R_390_GOT32 = 7 +const R_390_GOT64 = 24 +const R_390_GOTENT = 26 +const R_390_GOTOFF16 = 27 +const R_390_GOTOFF32 = 13 +const R_390_GOTOFF64 = 28 +const R_390_GOTPC = 14 +const R_390_GOTPCDBL = 21 +const R_390_GOTPLT12 = 29 +const R_390_GOTPLT16 = 30 +const R_390_GOTPLT20 = 59 +const R_390_GOTPLT32 = 31 +const R_390_GOTPLT64 = 32 +const R_390_GOTPLTENT = 33 +const R_390_JMP_SLOT = 11 +const R_390_NONE = 0 +const R_390_NUM = 61 +const R_390_PC16 = 16 +const R_390_PC16DBL = 17 +const R_390_PC32 = 5 +const R_390_PC32DBL = 19 +const R_390_PC64 = 23 +const R_390_PLT16DBL = 18 +const R_390_PLT32 = 8 +const R_390_PLT32DBL = 20 +const R_390_PLT64 = 25 +const R_390_PLTOFF16 = 34 +const R_390_PLTOFF32 = 35 +const R_390_PLTOFF64 = 36 +const R_390_RELATIVE = 12 +const R_390_TLS_DTPMOD = 54 +const R_390_TLS_DTPOFF = 55 +const R_390_TLS_GD32 = 40 +const R_390_TLS_GD64 = 41 +const R_390_TLS_GDCALL = 38 +const R_390_TLS_GOTIE12 = 42 +const R_390_TLS_GOTIE20 = 60 +const R_390_TLS_GOTIE32 = 43 +const R_390_TLS_GOTIE64 = 44 +const R_390_TLS_IE32 = 47 +const R_390_TLS_IE64 = 48 +const R_390_TLS_IEENT = 49 +const R_390_TLS_LDCALL = 39 +const R_390_TLS_LDM32 = 45 +const R_390_TLS_LDM64 = 46 +const R_390_TLS_LDO32 = 52 +const R_390_TLS_LDO64 = 53 +const R_390_TLS_LE32 = 50 +const R_390_TLS_LE64 = 51 +const R_390_TLS_LOAD = 37 +const R_390_TLS_TPOFF = 56 +const R_68K_16 = 2 +const R_68K_32 = 1 +const R_68K_8 = 3 +const R_68K_COPY = 19 +const R_68K_GLOB_DAT = 20 +const R_68K_GOT16 = 8 +const R_68K_GOT16O = 11 +const R_68K_GOT32 = 7 +const R_68K_GOT32O = 10 +const R_68K_GOT8 = 9 +const R_68K_GOT8O = 12 +const R_68K_JMP_SLOT = 21 +const R_68K_NONE = 0 +const R_68K_NUM = 43 +const R_68K_PC16 = 5 +const R_68K_PC32 = 4 +const R_68K_PC8 = 6 +const R_68K_PLT16 = 14 +const R_68K_PLT16O = 17 +const R_68K_PLT32 = 13 +const R_68K_PLT32O = 16 +const R_68K_PLT8 = 15 +const R_68K_PLT8O = 18 +const R_68K_RELATIVE = 22 +const R_68K_TLS_DTPMOD32 = 40 +const R_68K_TLS_DTPREL32 = 41 +const R_68K_TLS_GD16 = 26 +const R_68K_TLS_GD32 = 25 +const R_68K_TLS_GD8 = 27 +const R_68K_TLS_IE16 = 35 +const R_68K_TLS_IE32 = 34 +const R_68K_TLS_IE8 = 36 +const R_68K_TLS_LDM16 = 29 +const R_68K_TLS_LDM32 = 28 +const R_68K_TLS_LDM8 = 30 +const R_68K_TLS_LDO16 = 32 +const R_68K_TLS_LDO32 = 31 +const R_68K_TLS_LDO8 = 33 +const R_68K_TLS_LE16 = 38 +const R_68K_TLS_LE32 = 37 +const R_68K_TLS_LE8 = 39 +const R_68K_TLS_TPREL32 = 42 +const R_AARCH64_ABS16 = 259 +const R_AARCH64_ABS32 = 258 +const R_AARCH64_ABS64 = 257 +const R_AARCH64_ADD_ABS_LO12_NC = 277 +const R_AARCH64_ADR_GOT_PAGE = 311 +const R_AARCH64_ADR_PREL_LO21 = 274 +const R_AARCH64_ADR_PREL_PG_HI21 = 275 +const R_AARCH64_ADR_PREL_PG_HI21_NC = 276 +const R_AARCH64_CALL26 = 283 +const R_AARCH64_CONDBR19 = 280 +const R_AARCH64_COPY = 1024 +const R_AARCH64_GLOB_DAT = 1025 +const R_AARCH64_GOTREL32 = 308 +const R_AARCH64_GOTREL64 = 307 +const R_AARCH64_GOT_LD_PREL19 = 309 +const R_AARCH64_JUMP26 = 282 +const R_AARCH64_JUMP_SLOT = 1026 +const R_AARCH64_LD64_GOTOFF_LO15 = 310 +const R_AARCH64_LD64_GOTPAGE_LO15 = 313 +const R_AARCH64_LD64_GOT_LO12_NC = 312 +const R_AARCH64_LDST128_ABS_LO12_NC = 299 +const R_AARCH64_LDST16_ABS_LO12_NC = 284 +const R_AARCH64_LDST32_ABS_LO12_NC = 285 +const R_AARCH64_LDST64_ABS_LO12_NC = 286 +const R_AARCH64_LDST8_ABS_LO12_NC = 278 +const R_AARCH64_LD_PREL_LO19 = 273 +const R_AARCH64_MOVW_GOTOFF_G0 = 300 +const R_AARCH64_MOVW_GOTOFF_G0_NC = 301 +const R_AARCH64_MOVW_GOTOFF_G1 = 302 +const R_AARCH64_MOVW_GOTOFF_G1_NC = 303 +const R_AARCH64_MOVW_GOTOFF_G2 = 304 +const R_AARCH64_MOVW_GOTOFF_G2_NC = 305 +const R_AARCH64_MOVW_GOTOFF_G3 = 306 +const R_AARCH64_MOVW_PREL_G0 = 287 +const R_AARCH64_MOVW_PREL_G0_NC = 288 +const R_AARCH64_MOVW_PREL_G1 = 289 +const R_AARCH64_MOVW_PREL_G1_NC = 290 +const R_AARCH64_MOVW_PREL_G2 = 291 +const R_AARCH64_MOVW_PREL_G2_NC = 292 +const R_AARCH64_MOVW_PREL_G3 = 293 +const R_AARCH64_MOVW_SABS_G0 = 270 +const R_AARCH64_MOVW_SABS_G1 = 271 +const R_AARCH64_MOVW_SABS_G2 = 272 +const R_AARCH64_MOVW_UABS_G0 = 263 +const R_AARCH64_MOVW_UABS_G0_NC = 264 +const R_AARCH64_MOVW_UABS_G1 = 265 +const R_AARCH64_MOVW_UABS_G1_NC = 266 +const R_AARCH64_MOVW_UABS_G2 = 267 +const R_AARCH64_MOVW_UABS_G2_NC = 268 +const R_AARCH64_MOVW_UABS_G3 = 269 +const R_AARCH64_NONE = 0 +const R_AARCH64_P32_ABS32 = 1 +const R_AARCH64_P32_COPY = 180 +const R_AARCH64_P32_GLOB_DAT = 181 +const R_AARCH64_P32_IRELATIVE = 188 +const R_AARCH64_P32_JUMP_SLOT = 182 +const R_AARCH64_P32_RELATIVE = 183 +const R_AARCH64_P32_TLSDESC = 187 +const R_AARCH64_P32_TLS_DTPMOD = 184 +const R_AARCH64_P32_TLS_DTPREL = 185 +const R_AARCH64_P32_TLS_TPREL = 186 +const R_AARCH64_PREL16 = 262 +const R_AARCH64_PREL32 = 261 +const R_AARCH64_PREL64 = 260 +const R_AARCH64_RELATIVE = 1027 +const R_AARCH64_TLSDESC = 1031 +const R_AARCH64_TLSDESC_ADD = 568 +const R_AARCH64_TLSDESC_ADD_LO12 = 564 +const R_AARCH64_TLSDESC_ADR_PAGE21 = 562 +const R_AARCH64_TLSDESC_ADR_PREL21 = 561 +const R_AARCH64_TLSDESC_CALL = 569 +const R_AARCH64_TLSDESC_LD64_LO12 = 563 +const R_AARCH64_TLSDESC_LDR = 567 +const R_AARCH64_TLSDESC_LD_PREL19 = 560 +const R_AARCH64_TLSDESC_OFF_G0_NC = 566 +const R_AARCH64_TLSDESC_OFF_G1 = 565 +const R_AARCH64_TLSGD_ADD_LO12_NC = 514 +const R_AARCH64_TLSGD_ADR_PAGE21 = 513 +const R_AARCH64_TLSGD_ADR_PREL21 = 512 +const R_AARCH64_TLSGD_MOVW_G0_NC = 516 +const R_AARCH64_TLSGD_MOVW_G1 = 515 +const R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 541 +const R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 542 +const R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 543 +const R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 540 +const R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 539 +const R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 528 +const R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 529 +const R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 530 +const R_AARCH64_TLSLD_ADD_LO12_NC = 519 +const R_AARCH64_TLSLD_ADR_PAGE21 = 518 +const R_AARCH64_TLSLD_ADR_PREL21 = 517 +const R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572 +const R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573 +const R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 533 +const R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 534 +const R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 535 +const R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 536 +const R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 537 +const R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 538 +const R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 531 +const R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 532 +const R_AARCH64_TLSLD_LD_PREL19 = 522 +const R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 526 +const R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 527 +const R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 524 +const R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 525 +const R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 523 +const R_AARCH64_TLSLD_MOVW_G0_NC = 521 +const R_AARCH64_TLSLD_MOVW_G1 = 520 +const R_AARCH64_TLSLE_ADD_TPREL_HI12 = 549 +const R_AARCH64_TLSLE_ADD_TPREL_LO12 = 550 +const R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 551 +const R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570 +const R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571 +const R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 554 +const R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 555 +const R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 556 +const R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 557 +const R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 558 +const R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 559 +const R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 552 +const R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 553 +const R_AARCH64_TLSLE_MOVW_TPREL_G0 = 547 +const R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 548 +const R_AARCH64_TLSLE_MOVW_TPREL_G1 = 545 +const R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 546 +const R_AARCH64_TLSLE_MOVW_TPREL_G2 = 544 +const R_AARCH64_TLS_DTPMOD = 1028 +const R_AARCH64_TLS_DTPMOD64 = 1028 +const R_AARCH64_TLS_DTPREL = 1029 +const R_AARCH64_TLS_DTPREL64 = 1029 +const R_AARCH64_TLS_TPREL = 1030 +const R_AARCH64_TLS_TPREL64 = 1030 +const R_AARCH64_TSTBR14 = 279 +const R_ALPHA_BRADDR = 7 +const R_ALPHA_COPY = 24 +const R_ALPHA_DTPMOD64 = 31 +const R_ALPHA_DTPREL16 = 36 +const R_ALPHA_DTPREL64 = 33 +const R_ALPHA_DTPRELHI = 34 +const R_ALPHA_DTPRELLO = 35 +const R_ALPHA_GLOB_DAT = 25 +const R_ALPHA_GOTDTPREL = 32 +const R_ALPHA_GOTTPREL = 37 +const R_ALPHA_GPDISP = 6 +const R_ALPHA_GPREL16 = 19 +const R_ALPHA_GPREL32 = 3 +const R_ALPHA_GPRELHIGH = 17 +const R_ALPHA_GPRELLOW = 18 +const R_ALPHA_HINT = 8 +const R_ALPHA_JMP_SLOT = 26 +const R_ALPHA_LITERAL = 4 +const R_ALPHA_LITUSE = 5 +const R_ALPHA_NONE = 0 +const R_ALPHA_NUM = 46 +const R_ALPHA_REFLONG = 1 +const R_ALPHA_REFQUAD = 2 +const R_ALPHA_RELATIVE = 27 +const R_ALPHA_SREL16 = 9 +const R_ALPHA_SREL32 = 10 +const R_ALPHA_SREL64 = 11 +const R_ALPHA_TLSGD = 29 +const R_ALPHA_TLS_GD_HI = 28 +const R_ALPHA_TLS_LDM = 30 +const R_ALPHA_TPREL16 = 41 +const R_ALPHA_TPREL64 = 38 +const R_ALPHA_TPRELHI = 39 +const R_ALPHA_TPRELLO = 40 +const R_ARM_ABS12 = 6 +const R_ARM_ABS16 = 5 +const R_ARM_ABS32 = 2 +const R_ARM_ABS32_NOI = 55 +const R_ARM_ABS8 = 8 +const R_ARM_ALU_PCREL_15_8 = 33 +const R_ARM_ALU_PCREL_23_15 = 34 +const R_ARM_ALU_PCREL_7_0 = 32 +const R_ARM_ALU_PC_G0 = 58 +const R_ARM_ALU_PC_G0_NC = 57 +const R_ARM_ALU_PC_G1 = 60 +const R_ARM_ALU_PC_G1_NC = 59 +const R_ARM_ALU_PC_G2 = 61 +const R_ARM_ALU_SBREL_19_12 = 36 +const R_ARM_ALU_SBREL_27_20 = 37 +const R_ARM_ALU_SB_G0 = 71 +const R_ARM_ALU_SB_G0_NC = 70 +const R_ARM_ALU_SB_G1 = 73 +const R_ARM_ALU_SB_G1_NC = 72 +const R_ARM_ALU_SB_G2 = 74 +const R_ARM_AMP_VCALL9 = 12 +const R_ARM_BASE_ABS = 31 +const R_ARM_CALL = 28 +const R_ARM_COPY = 20 +const R_ARM_GLOB_DAT = 21 +const R_ARM_GNU_VTENTRY = 100 +const R_ARM_GNU_VTINHERIT = 101 +const R_ARM_GOT32 = 26 +const R_ARM_GOTOFF = 24 +const R_ARM_GOTOFF12 = 98 +const R_ARM_GOTPC = 25 +const R_ARM_GOTRELAX = 99 +const R_ARM_GOT_ABS = 95 +const R_ARM_GOT_BREL12 = 97 +const R_ARM_GOT_PREL = 96 +const R_ARM_IRELATIVE = 160 +const R_ARM_JUMP24 = 29 +const R_ARM_JUMP_SLOT = 22 +const R_ARM_LDC_PC_G0 = 67 +const R_ARM_LDC_PC_G1 = 68 +const R_ARM_LDC_PC_G2 = 69 +const R_ARM_LDC_SB_G0 = 81 +const R_ARM_LDC_SB_G1 = 82 +const R_ARM_LDC_SB_G2 = 83 +const R_ARM_LDRS_PC_G0 = 64 +const R_ARM_LDRS_PC_G1 = 65 +const R_ARM_LDRS_PC_G2 = 66 +const R_ARM_LDRS_SB_G0 = 78 +const R_ARM_LDRS_SB_G1 = 79 +const R_ARM_LDRS_SB_G2 = 80 +const R_ARM_LDR_PC_G1 = 62 +const R_ARM_LDR_PC_G2 = 63 +const R_ARM_LDR_SBREL_11_0 = 35 +const R_ARM_LDR_SB_G0 = 75 +const R_ARM_LDR_SB_G1 = 76 +const R_ARM_LDR_SB_G2 = 77 +const R_ARM_ME_TOO = 128 +const R_ARM_MOVT_ABS = 44 +const R_ARM_MOVT_BREL = 85 +const R_ARM_MOVT_PREL = 46 +const R_ARM_MOVW_ABS_NC = 43 +const R_ARM_MOVW_BREL = 86 +const R_ARM_MOVW_BREL_NC = 84 +const R_ARM_MOVW_PREL_NC = 45 +const R_ARM_NONE = 0 +const R_ARM_NUM = 256 +const R_ARM_PC13 = 4 +const R_ARM_PC24 = 1 +const R_ARM_PLT32 = 27 +const R_ARM_PLT32_ABS = 94 +const R_ARM_PREL31 = 42 +const R_ARM_RABS22 = 253 +const R_ARM_RBASE = 255 +const R_ARM_REL32 = 3 +const R_ARM_REL32_NOI = 56 +const R_ARM_RELATIVE = 23 +const R_ARM_RPC24 = 254 +const R_ARM_RREL32 = 252 +const R_ARM_RSBREL32 = 250 +const R_ARM_RXPC25 = 249 +const R_ARM_SBREL31 = 39 +const R_ARM_SBREL32 = 9 +const R_ARM_TARGET1 = 38 +const R_ARM_TARGET2 = 41 +const R_ARM_THM_ABS5 = 7 +const R_ARM_THM_ALU_PREL_11_0 = 53 +const R_ARM_THM_GOT_BREL12 = 131 +const R_ARM_THM_JUMP19 = 51 +const R_ARM_THM_JUMP24 = 30 +const R_ARM_THM_JUMP6 = 52 +const R_ARM_THM_MOVT_ABS = 48 +const R_ARM_THM_MOVT_BREL = 88 +const R_ARM_THM_MOVT_PREL = 50 +const R_ARM_THM_MOVW_ABS_NC = 47 +const R_ARM_THM_MOVW_BREL = 89 +const R_ARM_THM_MOVW_BREL_NC = 87 +const R_ARM_THM_MOVW_PREL_NC = 49 +const R_ARM_THM_PC11 = 102 +const R_ARM_THM_PC12 = 54 +const R_ARM_THM_PC22 = 10 +const R_ARM_THM_PC8 = 11 +const R_ARM_THM_PC9 = 103 +const R_ARM_THM_RPC22 = 251 +const R_ARM_THM_SWI8 = 14 +const R_ARM_THM_TLS_CALL = 93 +const R_ARM_THM_TLS_DESCSEQ = 129 +const R_ARM_THM_TLS_DESCSEQ16 = 129 +const R_ARM_THM_TLS_DESCSEQ32 = 130 +const R_ARM_THM_XPC22 = 16 +const R_ARM_TLS_CALL = 91 +const R_ARM_TLS_DESC = 13 +const R_ARM_TLS_DESCSEQ = 92 +const R_ARM_TLS_DTPMOD32 = 17 +const R_ARM_TLS_DTPOFF32 = 18 +const R_ARM_TLS_GD32 = 104 +const R_ARM_TLS_GOTDESC = 90 +const R_ARM_TLS_IE12GP = 111 +const R_ARM_TLS_IE32 = 107 +const R_ARM_TLS_LDM32 = 105 +const R_ARM_TLS_LDO12 = 109 +const R_ARM_TLS_LDO32 = 106 +const R_ARM_TLS_LE12 = 110 +const R_ARM_TLS_LE32 = 108 +const R_ARM_TLS_TPOFF32 = 19 +const R_ARM_V4BX = 40 +const R_ARM_XPC25 = 15 +const R_BPF_MAP_FD = 1 +const R_BPF_NONE = 0 +const R_CKCORE_ADDR32 = 1 +const R_CKCORE_ADDRGOT = 17 +const R_CKCORE_ADDRGOT_HI16 = 36 +const R_CKCORE_ADDRGOT_LO16 = 37 +const R_CKCORE_ADDRPLT = 18 +const R_CKCORE_ADDRPLT_HI16 = 38 +const R_CKCORE_ADDRPLT_LO16 = 39 +const R_CKCORE_ADDR_HI16 = 24 +const R_CKCORE_ADDR_LO16 = 25 +const R_CKCORE_COPY = 10 +const R_CKCORE_DOFFSET_IMM18 = 44 +const R_CKCORE_DOFFSET_IMM18BY2 = 45 +const R_CKCORE_DOFFSET_IMM18BY4 = 46 +const R_CKCORE_DOFFSET_LO16 = 42 +const R_CKCORE_GLOB_DAT = 11 +const R_CKCORE_GOT12 = 30 +const R_CKCORE_GOT32 = 15 +const R_CKCORE_GOTOFF = 13 +const R_CKCORE_GOTOFF_HI16 = 28 +const R_CKCORE_GOTOFF_LO16 = 29 +const R_CKCORE_GOTPC = 14 +const R_CKCORE_GOTPC_HI16 = 26 +const R_CKCORE_GOTPC_LO16 = 27 +const R_CKCORE_GOT_HI16 = 31 +const R_CKCORE_GOT_IMM18BY4 = 48 +const R_CKCORE_GOT_LO16 = 32 +const R_CKCORE_JUMP_SLOT = 12 +const R_CKCORE_NONE = 0 +const R_CKCORE_PCREL32 = 5 +const R_CKCORE_PCRELIMM11BY2 = 3 +const R_CKCORE_PCRELIMM8BY4 = 2 +const R_CKCORE_PCRELJSR_IMM11BY2 = 6 +const R_CKCORE_PCREL_IMM10BY2 = 22 +const R_CKCORE_PCREL_IMM10BY4 = 23 +const R_CKCORE_PCREL_IMM16BY2 = 20 +const R_CKCORE_PCREL_IMM16BY4 = 21 +const R_CKCORE_PCREL_IMM18BY2 = 43 +const R_CKCORE_PCREL_IMM26BY2 = 19 +const R_CKCORE_PCREL_IMM7BY4 = 50 +const R_CKCORE_PCREL_JSR_IMM26BY2 = 40 +const R_CKCORE_PLT12 = 33 +const R_CKCORE_PLT32 = 16 +const R_CKCORE_PLT_HI16 = 34 +const R_CKCORE_PLT_IMM18BY4 = 49 +const R_CKCORE_PLT_LO16 = 35 +const R_CKCORE_RELATIVE = 9 +const R_CKCORE_TLS_DTPMOD32 = 56 +const R_CKCORE_TLS_DTPOFF32 = 57 +const R_CKCORE_TLS_GD32 = 53 +const R_CKCORE_TLS_IE32 = 52 +const R_CKCORE_TLS_LDM32 = 54 +const R_CKCORE_TLS_LDO32 = 55 +const R_CKCORE_TLS_LE32 = 51 +const R_CKCORE_TLS_TPOFF32 = 58 +const R_CKCORE_TOFFSET_LO16 = 41 +const R_CRIS_16 = 2 +const R_CRIS_16_GOT = 13 +const R_CRIS_16_GOTPLT = 15 +const R_CRIS_16_PCREL = 5 +const R_CRIS_32 = 3 +const R_CRIS_32_GOT = 14 +const R_CRIS_32_GOTPLT = 16 +const R_CRIS_32_GOTREL = 17 +const R_CRIS_32_PCREL = 6 +const R_CRIS_32_PLT_GOTREL = 18 +const R_CRIS_32_PLT_PCREL = 19 +const R_CRIS_8 = 1 +const R_CRIS_8_PCREL = 4 +const R_CRIS_COPY = 9 +const R_CRIS_GLOB_DAT = 10 +const R_CRIS_GNU_VTENTRY = 8 +const R_CRIS_GNU_VTINHERIT = 7 +const R_CRIS_JUMP_SLOT = 11 +const R_CRIS_NONE = 0 +const R_CRIS_NUM = 20 +const R_CRIS_RELATIVE = 12 +const R_IA64_COPY = 132 +const R_IA64_DIR32LSB = 37 +const R_IA64_DIR32MSB = 36 +const R_IA64_DIR64LSB = 39 +const R_IA64_DIR64MSB = 38 +const R_IA64_DTPMOD64LSB = 167 +const R_IA64_DTPMOD64MSB = 166 +const R_IA64_DTPREL14 = 177 +const R_IA64_DTPREL22 = 178 +const R_IA64_DTPREL32LSB = 181 +const R_IA64_DTPREL32MSB = 180 +const R_IA64_DTPREL64I = 179 +const R_IA64_DTPREL64LSB = 183 +const R_IA64_DTPREL64MSB = 182 +const R_IA64_FPTR32LSB = 69 +const R_IA64_FPTR32MSB = 68 +const R_IA64_FPTR64I = 67 +const R_IA64_FPTR64LSB = 71 +const R_IA64_FPTR64MSB = 70 +const R_IA64_GPREL22 = 42 +const R_IA64_GPREL32LSB = 45 +const R_IA64_GPREL32MSB = 44 +const R_IA64_GPREL64I = 43 +const R_IA64_GPREL64LSB = 47 +const R_IA64_GPREL64MSB = 46 +const R_IA64_IMM14 = 33 +const R_IA64_IMM22 = 34 +const R_IA64_IMM64 = 35 +const R_IA64_IPLTLSB = 129 +const R_IA64_IPLTMSB = 128 +const R_IA64_LDXMOV = 135 +const R_IA64_LTOFF22 = 50 +const R_IA64_LTOFF22X = 134 +const R_IA64_LTOFF64I = 51 +const R_IA64_LTOFF_DTPMOD22 = 170 +const R_IA64_LTOFF_DTPREL22 = 186 +const R_IA64_LTOFF_FPTR22 = 82 +const R_IA64_LTOFF_FPTR32LSB = 85 +const R_IA64_LTOFF_FPTR32MSB = 84 +const R_IA64_LTOFF_FPTR64I = 83 +const R_IA64_LTOFF_FPTR64LSB = 87 +const R_IA64_LTOFF_FPTR64MSB = 86 +const R_IA64_LTOFF_TPREL22 = 154 +const R_IA64_LTV32LSB = 117 +const R_IA64_LTV32MSB = 116 +const R_IA64_LTV64LSB = 119 +const R_IA64_LTV64MSB = 118 +const R_IA64_NONE = 0 +const R_IA64_PCREL21B = 73 +const R_IA64_PCREL21BI = 121 +const R_IA64_PCREL21F = 75 +const R_IA64_PCREL21M = 74 +const R_IA64_PCREL22 = 122 +const R_IA64_PCREL32LSB = 77 +const R_IA64_PCREL32MSB = 76 +const R_IA64_PCREL60B = 72 +const R_IA64_PCREL64I = 123 +const R_IA64_PCREL64LSB = 79 +const R_IA64_PCREL64MSB = 78 +const R_IA64_PLTOFF22 = 58 +const R_IA64_PLTOFF64I = 59 +const R_IA64_PLTOFF64LSB = 63 +const R_IA64_PLTOFF64MSB = 62 +const R_IA64_REL32LSB = 109 +const R_IA64_REL32MSB = 108 +const R_IA64_REL64LSB = 111 +const R_IA64_REL64MSB = 110 +const R_IA64_SECREL32LSB = 101 +const R_IA64_SECREL32MSB = 100 +const R_IA64_SECREL64LSB = 103 +const R_IA64_SECREL64MSB = 102 +const R_IA64_SEGREL32LSB = 93 +const R_IA64_SEGREL32MSB = 92 +const R_IA64_SEGREL64LSB = 95 +const R_IA64_SEGREL64MSB = 94 +const R_IA64_SUB = 133 +const R_IA64_TPREL14 = 145 +const R_IA64_TPREL22 = 146 +const R_IA64_TPREL64I = 147 +const R_IA64_TPREL64LSB = 151 +const R_IA64_TPREL64MSB = 150 +const R_LARCH_32 = 1 +const R_LARCH_32_PCREL = 99 +const R_LARCH_64 = 2 +const R_LARCH_ABS64_HI12 = 70 +const R_LARCH_ABS64_LO20 = 69 +const R_LARCH_ABS_HI20 = 67 +const R_LARCH_ABS_LO12 = 68 +const R_LARCH_ADD16 = 48 +const R_LARCH_ADD24 = 49 +const R_LARCH_ADD32 = 50 +const R_LARCH_ADD64 = 51 +const R_LARCH_ADD8 = 47 +const R_LARCH_B16 = 64 +const R_LARCH_B21 = 65 +const R_LARCH_B26 = 66 +const R_LARCH_COPY = 4 +const R_LARCH_GNU_VTENTRY = 58 +const R_LARCH_GNU_VTINHERIT = 57 +const R_LARCH_GOT64_HI12 = 82 +const R_LARCH_GOT64_LO20 = 81 +const R_LARCH_GOT64_PC_HI12 = 78 +const R_LARCH_GOT64_PC_LO20 = 77 +const R_LARCH_GOT_HI20 = 79 +const R_LARCH_GOT_LO12 = 80 +const R_LARCH_GOT_PC_HI20 = 75 +const R_LARCH_GOT_PC_LO12 = 76 +const R_LARCH_IRELATIVE = 12 +const R_LARCH_JUMP_SLOT = 5 +const R_LARCH_MARK_LA = 20 +const R_LARCH_MARK_PCREL = 21 +const R_LARCH_NONE = 0 +const R_LARCH_PCALA64_HI12 = 74 +const R_LARCH_PCALA64_LO20 = 73 +const R_LARCH_PCALA_HI20 = 71 +const R_LARCH_PCALA_LO12 = 72 +const R_LARCH_RELATIVE = 3 +const R_LARCH_RELAX = 100 +const R_LARCH_SOP_ADD = 35 +const R_LARCH_SOP_AND = 36 +const R_LARCH_SOP_ASSERT = 30 +const R_LARCH_SOP_IF_ELSE = 37 +const R_LARCH_SOP_NOT = 31 +const R_LARCH_SOP_POP_32_S_0_10_10_16_S2 = 45 +const R_LARCH_SOP_POP_32_S_0_5_10_16_S2 = 44 +const R_LARCH_SOP_POP_32_S_10_12 = 40 +const R_LARCH_SOP_POP_32_S_10_16 = 41 +const R_LARCH_SOP_POP_32_S_10_16_S2 = 42 +const R_LARCH_SOP_POP_32_S_10_5 = 38 +const R_LARCH_SOP_POP_32_S_5_20 = 43 +const R_LARCH_SOP_POP_32_U = 46 +const R_LARCH_SOP_POP_32_U_10_12 = 39 +const R_LARCH_SOP_PUSH_ABSOLUTE = 23 +const R_LARCH_SOP_PUSH_DUP = 24 +const R_LARCH_SOP_PUSH_GPREL = 25 +const R_LARCH_SOP_PUSH_PCREL = 22 +const R_LARCH_SOP_PUSH_PLT_PCREL = 29 +const R_LARCH_SOP_PUSH_TLS_GD = 28 +const R_LARCH_SOP_PUSH_TLS_GOT = 27 +const R_LARCH_SOP_PUSH_TLS_TPREL = 26 +const R_LARCH_SOP_SL = 33 +const R_LARCH_SOP_SR = 34 +const R_LARCH_SOP_SUB = 32 +const R_LARCH_SUB16 = 53 +const R_LARCH_SUB24 = 54 +const R_LARCH_SUB32 = 55 +const R_LARCH_SUB64 = 56 +const R_LARCH_SUB8 = 52 +const R_LARCH_TLS_DTPMOD32 = 6 +const R_LARCH_TLS_DTPMOD64 = 7 +const R_LARCH_TLS_DTPREL32 = 8 +const R_LARCH_TLS_DTPREL64 = 9 +const R_LARCH_TLS_GD_HI20 = 98 +const R_LARCH_TLS_GD_PC_HI20 = 97 +const R_LARCH_TLS_IE64_HI12 = 94 +const R_LARCH_TLS_IE64_LO20 = 93 +const R_LARCH_TLS_IE64_PC_HI12 = 90 +const R_LARCH_TLS_IE64_PC_LO20 = 89 +const R_LARCH_TLS_IE_HI20 = 91 +const R_LARCH_TLS_IE_LO12 = 92 +const R_LARCH_TLS_IE_PC_HI20 = 87 +const R_LARCH_TLS_IE_PC_LO12 = 88 +const R_LARCH_TLS_LD_HI20 = 96 +const R_LARCH_TLS_LD_PC_HI20 = 95 +const R_LARCH_TLS_LE64_HI12 = 86 +const R_LARCH_TLS_LE64_LO20 = 85 +const R_LARCH_TLS_LE_HI20 = 83 +const R_LARCH_TLS_LE_LO12 = 84 +const R_LARCH_TLS_TPREL32 = 10 +const R_LARCH_TLS_TPREL64 = 11 +const R_M32R_10_PCREL = 4 +const R_M32R_10_PCREL_RELA = 36 +const R_M32R_16 = 1 +const R_M32R_16_RELA = 33 +const R_M32R_18_PCREL = 5 +const R_M32R_18_PCREL_RELA = 37 +const R_M32R_24 = 3 +const R_M32R_24_RELA = 35 +const R_M32R_26_PCREL = 6 +const R_M32R_26_PCREL_RELA = 38 +const R_M32R_26_PLTREL = 49 +const R_M32R_32 = 2 +const R_M32R_32_RELA = 34 +const R_M32R_COPY = 50 +const R_M32R_GLOB_DAT = 51 +const R_M32R_GNU_VTENTRY = 12 +const R_M32R_GNU_VTINHERIT = 11 +const R_M32R_GOT16_HI_SLO = 57 +const R_M32R_GOT16_HI_ULO = 56 +const R_M32R_GOT16_LO = 58 +const R_M32R_GOT24 = 48 +const R_M32R_GOTOFF = 54 +const R_M32R_GOTOFF_HI_SLO = 63 +const R_M32R_GOTOFF_HI_ULO = 62 +const R_M32R_GOTOFF_LO = 64 +const R_M32R_GOTPC24 = 55 +const R_M32R_GOTPC_HI_SLO = 60 +const R_M32R_GOTPC_HI_ULO = 59 +const R_M32R_GOTPC_LO = 61 +const R_M32R_HI16_SLO = 8 +const R_M32R_HI16_SLO_RELA = 40 +const R_M32R_HI16_ULO = 7 +const R_M32R_HI16_ULO_RELA = 39 +const R_M32R_JMP_SLOT = 52 +const R_M32R_LO16 = 9 +const R_M32R_LO16_RELA = 41 +const R_M32R_NONE = 0 +const R_M32R_NUM = 256 +const R_M32R_REL32 = 45 +const R_M32R_RELATIVE = 53 +const R_M32R_RELA_GNU_VTENTRY = 44 +const R_M32R_RELA_GNU_VTINHERIT = 43 +const R_M32R_SDA16 = 10 +const R_M32R_SDA16_RELA = 42 +const R_MICROBLAZE_32 = 1 +const R_MICROBLAZE_32_LO = 6 +const R_MICROBLAZE_32_PCREL = 2 +const R_MICROBLAZE_32_PCREL_LO = 4 +const R_MICROBLAZE_32_SYM_OP_SYM = 10 +const R_MICROBLAZE_64 = 5 +const R_MICROBLAZE_64_NONE = 9 +const R_MICROBLAZE_64_PCREL = 3 +const R_MICROBLAZE_COPY = 21 +const R_MICROBLAZE_GLOB_DAT = 18 +const R_MICROBLAZE_GNU_VTENTRY = 12 +const R_MICROBLAZE_GNU_VTINHERIT = 11 +const R_MICROBLAZE_GOTOFF_32 = 20 +const R_MICROBLAZE_GOTOFF_64 = 19 +const R_MICROBLAZE_GOTPC_64 = 13 +const R_MICROBLAZE_GOT_64 = 14 +const R_MICROBLAZE_JUMP_SLOT = 17 +const R_MICROBLAZE_NONE = 0 +const R_MICROBLAZE_PLT_64 = 15 +const R_MICROBLAZE_REL = 16 +const R_MICROBLAZE_SRO32 = 7 +const R_MICROBLAZE_SRW32 = 8 +const R_MICROBLAZE_TLS = 22 +const R_MICROBLAZE_TLSDTPMOD32 = 25 +const R_MICROBLAZE_TLSDTPREL32 = 26 +const R_MICROBLAZE_TLSDTPREL64 = 27 +const R_MICROBLAZE_TLSGD = 23 +const R_MICROBLAZE_TLSGOTTPREL32 = 28 +const R_MICROBLAZE_TLSLD = 24 +const R_MICROBLAZE_TLSTPREL32 = 29 +const R_MIPS_16 = 1 +const R_MIPS_26 = 4 +const R_MIPS_32 = 2 +const R_MIPS_64 = 18 +const R_MIPS_ADD_IMMEDIATE = 34 +const R_MIPS_CALL16 = 11 +const R_MIPS_CALL_HI16 = 30 +const R_MIPS_CALL_LO16 = 31 +const R_MIPS_COPY = 126 +const R_MIPS_DELETE = 27 +const R_MIPS_GLOB_DAT = 51 +const R_MIPS_GOT16 = 9 +const R_MIPS_GOT_DISP = 19 +const R_MIPS_GOT_HI16 = 22 +const R_MIPS_GOT_LO16 = 23 +const R_MIPS_GOT_OFST = 21 +const R_MIPS_GOT_PAGE = 20 +const R_MIPS_GPREL16 = 7 +const R_MIPS_GPREL32 = 12 +const R_MIPS_HI16 = 5 +const R_MIPS_HIGHER = 28 +const R_MIPS_HIGHEST = 29 +const R_MIPS_INSERT_A = 25 +const R_MIPS_INSERT_B = 26 +const R_MIPS_JALR = 37 +const R_MIPS_JUMP_SLOT = 127 +const R_MIPS_LITERAL = 8 +const R_MIPS_LO16 = 6 +const R_MIPS_NONE = 0 +const R_MIPS_NUM = 128 +const R_MIPS_PC16 = 10 +const R_MIPS_PJUMP = 35 +const R_MIPS_REL16 = 33 +const R_MIPS_REL32 = 3 +const R_MIPS_RELGOT = 36 +const R_MIPS_SCN_DISP = 32 +const R_MIPS_SHIFT5 = 16 +const R_MIPS_SHIFT6 = 17 +const R_MIPS_SUB = 24 +const R_MIPS_TLS_DTPMOD32 = 38 +const R_MIPS_TLS_DTPMOD64 = 40 +const R_MIPS_TLS_DTPREL32 = 39 +const R_MIPS_TLS_DTPREL64 = 41 +const R_MIPS_TLS_DTPREL_HI16 = 44 +const R_MIPS_TLS_DTPREL_LO16 = 45 +const R_MIPS_TLS_GD = 42 +const R_MIPS_TLS_GOTTPREL = 46 +const R_MIPS_TLS_LDM = 43 +const R_MIPS_TLS_TPREL32 = 47 +const R_MIPS_TLS_TPREL64 = 48 +const R_MIPS_TLS_TPREL_HI16 = 49 +const R_MIPS_TLS_TPREL_LO16 = 50 +const R_MN10300_16 = 2 +const R_MN10300_24 = 9 +const R_MN10300_32 = 1 +const R_MN10300_8 = 3 +const R_MN10300_COPY = 20 +const R_MN10300_GLOB_DAT = 21 +const R_MN10300_GNU_VTENTRY = 8 +const R_MN10300_GNU_VTINHERIT = 7 +const R_MN10300_GOT16 = 19 +const R_MN10300_GOT24 = 18 +const R_MN10300_GOT32 = 17 +const R_MN10300_GOTOFF16 = 14 +const R_MN10300_GOTOFF24 = 13 +const R_MN10300_GOTOFF32 = 12 +const R_MN10300_GOTPC16 = 11 +const R_MN10300_GOTPC32 = 10 +const R_MN10300_JMP_SLOT = 22 +const R_MN10300_NONE = 0 +const R_MN10300_NUM = 24 +const R_MN10300_PCREL16 = 5 +const R_MN10300_PCREL32 = 4 +const R_MN10300_PCREL8 = 6 +const R_MN10300_PLT16 = 16 +const R_MN10300_PLT32 = 15 +const R_MN10300_RELATIVE = 23 +const R_NIOS2_ALIGN = 21 +const R_NIOS2_BFD_RELOC_16 = 13 +const R_NIOS2_BFD_RELOC_32 = 12 +const R_NIOS2_BFD_RELOC_8 = 14 +const R_NIOS2_CACHE_OPX = 6 +const R_NIOS2_CALL16 = 23 +const R_NIOS2_CALL26 = 4 +const R_NIOS2_CALL26_NOAT = 41 +const R_NIOS2_CALLR = 20 +const R_NIOS2_CALL_HA = 45 +const R_NIOS2_CALL_LO = 44 +const R_NIOS2_CJMP = 19 +const R_NIOS2_COPY = 36 +const R_NIOS2_GLOB_DAT = 37 +const R_NIOS2_GNU_VTENTRY = 17 +const R_NIOS2_GNU_VTINHERIT = 16 +const R_NIOS2_GOT16 = 22 +const R_NIOS2_GOTOFF = 40 +const R_NIOS2_GOTOFF_HA = 25 +const R_NIOS2_GOTOFF_LO = 24 +const R_NIOS2_GOT_HA = 43 +const R_NIOS2_GOT_LO = 42 +const R_NIOS2_GPREL = 15 +const R_NIOS2_HI16 = 9 +const R_NIOS2_HIADJ16 = 11 +const R_NIOS2_IMM5 = 5 +const R_NIOS2_IMM6 = 7 +const R_NIOS2_IMM8 = 8 +const R_NIOS2_JUMP_SLOT = 38 +const R_NIOS2_LO16 = 10 +const R_NIOS2_NONE = 0 +const R_NIOS2_PCREL16 = 3 +const R_NIOS2_PCREL_HA = 27 +const R_NIOS2_PCREL_LO = 26 +const R_NIOS2_RELATIVE = 39 +const R_NIOS2_S16 = 1 +const R_NIOS2_TLS_DTPMOD = 33 +const R_NIOS2_TLS_DTPREL = 34 +const R_NIOS2_TLS_GD16 = 28 +const R_NIOS2_TLS_IE16 = 31 +const R_NIOS2_TLS_LDM16 = 29 +const R_NIOS2_TLS_LDO16 = 30 +const R_NIOS2_TLS_LE16 = 32 +const R_NIOS2_TLS_TPREL = 35 +const R_NIOS2_U16 = 2 +const R_NIOS2_UJMP = 18 +const R_OR1K_16 = 2 +const R_OR1K_16_PCREL = 10 +const R_OR1K_32 = 1 +const R_OR1K_32_PCREL = 9 +const R_OR1K_8 = 3 +const R_OR1K_8_PCREL = 11 +const R_OR1K_COPY = 18 +const R_OR1K_GLOB_DAT = 19 +const R_OR1K_GNU_VTENTRY = 7 +const R_OR1K_GNU_VTINHERIT = 8 +const R_OR1K_GOT16 = 14 +const R_OR1K_GOTOFF_HI16 = 16 +const R_OR1K_GOTOFF_LO16 = 17 +const R_OR1K_GOTPC_HI16 = 12 +const R_OR1K_GOTPC_LO16 = 13 +const R_OR1K_HI_16_IN_INSN = 5 +const R_OR1K_INSN_REL_26 = 6 +const R_OR1K_JMP_SLOT = 20 +const R_OR1K_LO_16_IN_INSN = 4 +const R_OR1K_NONE = 0 +const R_OR1K_PLT26 = 15 +const R_OR1K_RELATIVE = 21 +const R_OR1K_TLS_DTPMOD = 34 +const R_OR1K_TLS_DTPOFF = 33 +const R_OR1K_TLS_GD_HI16 = 22 +const R_OR1K_TLS_GD_LO16 = 23 +const R_OR1K_TLS_IE_HI16 = 28 +const R_OR1K_TLS_IE_LO16 = 29 +const R_OR1K_TLS_LDM_HI16 = 24 +const R_OR1K_TLS_LDM_LO16 = 25 +const R_OR1K_TLS_LDO_HI16 = 26 +const R_OR1K_TLS_LDO_LO16 = 27 +const R_OR1K_TLS_LE_HI16 = 30 +const R_OR1K_TLS_LE_LO16 = 31 +const R_OR1K_TLS_TPOFF = 32 +const R_PARISC_COPY = 128 +const R_PARISC_DIR14DR = 84 +const R_PARISC_DIR14R = 6 +const R_PARISC_DIR14WR = 83 +const R_PARISC_DIR16DF = 87 +const R_PARISC_DIR16F = 85 +const R_PARISC_DIR16WF = 86 +const R_PARISC_DIR17F = 4 +const R_PARISC_DIR17R = 3 +const R_PARISC_DIR21L = 2 +const R_PARISC_DIR32 = 1 +const R_PARISC_DIR64 = 80 +const R_PARISC_DPREL14R = 22 +const R_PARISC_DPREL21L = 18 +const R_PARISC_EPLT = 130 +const R_PARISC_FPTR64 = 64 +const R_PARISC_GNU_VTENTRY = 232 +const R_PARISC_GNU_VTINHERIT = 233 +const R_PARISC_GPREL14DR = 92 +const R_PARISC_GPREL14R = 30 +const R_PARISC_GPREL14WR = 91 +const R_PARISC_GPREL16DF = 95 +const R_PARISC_GPREL16F = 93 +const R_PARISC_GPREL16WF = 94 +const R_PARISC_GPREL21L = 26 +const R_PARISC_GPREL64 = 88 +const R_PARISC_HIRESERVE = 255 +const R_PARISC_IPLT = 129 +const R_PARISC_LORESERVE = 128 +const R_PARISC_LTOFF14DR = 100 +const R_PARISC_LTOFF14R = 38 +const R_PARISC_LTOFF14WR = 99 +const R_PARISC_LTOFF16DF = 103 +const R_PARISC_LTOFF16F = 101 +const R_PARISC_LTOFF16WF = 102 +const R_PARISC_LTOFF21L = 34 +const R_PARISC_LTOFF64 = 96 +const R_PARISC_LTOFF_FPTR14DR = 124 +const R_PARISC_LTOFF_FPTR14R = 62 +const R_PARISC_LTOFF_FPTR14WR = 123 +const R_PARISC_LTOFF_FPTR16DF = 127 +const R_PARISC_LTOFF_FPTR16F = 125 +const R_PARISC_LTOFF_FPTR16WF = 126 +const R_PARISC_LTOFF_FPTR21L = 58 +const R_PARISC_LTOFF_FPTR32 = 57 +const R_PARISC_LTOFF_FPTR64 = 120 +const R_PARISC_LTOFF_TP14DR = 228 +const R_PARISC_LTOFF_TP14F = 167 +const R_PARISC_LTOFF_TP14R = 166 +const R_PARISC_LTOFF_TP14WR = 227 +const R_PARISC_LTOFF_TP16DF = 231 +const R_PARISC_LTOFF_TP16F = 229 +const R_PARISC_LTOFF_TP16WF = 230 +const R_PARISC_LTOFF_TP21L = 162 +const R_PARISC_LTOFF_TP64 = 224 +const R_PARISC_NONE = 0 +const R_PARISC_PCREL14DR = 76 +const R_PARISC_PCREL14R = 14 +const R_PARISC_PCREL14WR = 75 +const R_PARISC_PCREL16DF = 79 +const R_PARISC_PCREL16F = 77 +const R_PARISC_PCREL16WF = 78 +const R_PARISC_PCREL17F = 12 +const R_PARISC_PCREL17R = 11 +const R_PARISC_PCREL21L = 10 +const R_PARISC_PCREL22F = 74 +const R_PARISC_PCREL32 = 9 +const R_PARISC_PCREL64 = 72 +const R_PARISC_PLABEL14R = 70 +const R_PARISC_PLABEL21L = 66 +const R_PARISC_PLABEL32 = 65 +const R_PARISC_PLTOFF14DR = 116 +const R_PARISC_PLTOFF14R = 54 +const R_PARISC_PLTOFF14WR = 115 +const R_PARISC_PLTOFF16DF = 119 +const R_PARISC_PLTOFF16F = 117 +const R_PARISC_PLTOFF16WF = 118 +const R_PARISC_PLTOFF21L = 50 +const R_PARISC_SECREL32 = 41 +const R_PARISC_SECREL64 = 104 +const R_PARISC_SEGBASE = 48 +const R_PARISC_SEGREL32 = 49 +const R_PARISC_SEGREL64 = 112 +const R_PARISC_TLS_DTPMOD32 = 242 +const R_PARISC_TLS_DTPMOD64 = 243 +const R_PARISC_TLS_DTPOFF32 = 244 +const R_PARISC_TLS_DTPOFF64 = 245 +const R_PARISC_TLS_GD14R = 235 +const R_PARISC_TLS_GD21L = 234 +const R_PARISC_TLS_GDCALL = 236 +const R_PARISC_TLS_IE14R = 166 +const R_PARISC_TLS_IE21L = 162 +const R_PARISC_TLS_LDM14R = 238 +const R_PARISC_TLS_LDM21L = 237 +const R_PARISC_TLS_LDMCALL = 239 +const R_PARISC_TLS_LDO14R = 241 +const R_PARISC_TLS_LDO21L = 240 +const R_PARISC_TLS_LE14R = 158 +const R_PARISC_TLS_LE21L = 154 +const R_PARISC_TLS_TPREL32 = 153 +const R_PARISC_TLS_TPREL64 = 216 +const R_PARISC_TPREL14DR = 220 +const R_PARISC_TPREL14R = 158 +const R_PARISC_TPREL14WR = 219 +const R_PARISC_TPREL16DF = 223 +const R_PARISC_TPREL16F = 221 +const R_PARISC_TPREL16WF = 222 +const R_PARISC_TPREL21L = 154 +const R_PARISC_TPREL32 = 153 +const R_PARISC_TPREL64 = 216 +const R_PPC64_ADDR14 = 7 +const R_PPC64_ADDR14_BRNTAKEN = 9 +const R_PPC64_ADDR14_BRTAKEN = 8 +const R_PPC64_ADDR16 = 3 +const R_PPC64_ADDR16_DS = 56 +const R_PPC64_ADDR16_HA = 6 +const R_PPC64_ADDR16_HI = 5 +const R_PPC64_ADDR16_HIGH = 110 +const R_PPC64_ADDR16_HIGHA = 111 +const R_PPC64_ADDR16_HIGHER = 39 +const R_PPC64_ADDR16_HIGHERA = 40 +const R_PPC64_ADDR16_HIGHEST = 41 +const R_PPC64_ADDR16_HIGHESTA = 42 +const R_PPC64_ADDR16_LO = 4 +const R_PPC64_ADDR16_LO_DS = 57 +const R_PPC64_ADDR24 = 2 +const R_PPC64_ADDR30 = 37 +const R_PPC64_ADDR32 = 1 +const R_PPC64_ADDR64 = 38 +const R_PPC64_COPY = 19 +const R_PPC64_DTPMOD64 = 68 +const R_PPC64_DTPREL16 = 74 +const R_PPC64_DTPREL16_DS = 101 +const R_PPC64_DTPREL16_HA = 77 +const R_PPC64_DTPREL16_HI = 76 +const R_PPC64_DTPREL16_HIGH = 114 +const R_PPC64_DTPREL16_HIGHA = 115 +const R_PPC64_DTPREL16_HIGHER = 103 +const R_PPC64_DTPREL16_HIGHERA = 104 +const R_PPC64_DTPREL16_HIGHEST = 105 +const R_PPC64_DTPREL16_HIGHESTA = 106 +const R_PPC64_DTPREL16_LO = 75 +const R_PPC64_DTPREL16_LO_DS = 102 +const R_PPC64_DTPREL64 = 78 +const R_PPC64_GLOB_DAT = 20 +const R_PPC64_GOT16 = 14 +const R_PPC64_GOT16_DS = 58 +const R_PPC64_GOT16_HA = 17 +const R_PPC64_GOT16_HI = 16 +const R_PPC64_GOT16_LO = 15 +const R_PPC64_GOT16_LO_DS = 59 +const R_PPC64_GOT_DTPREL16_DS = 91 +const R_PPC64_GOT_DTPREL16_HA = 94 +const R_PPC64_GOT_DTPREL16_HI = 93 +const R_PPC64_GOT_DTPREL16_LO_DS = 92 +const R_PPC64_GOT_TLSGD16 = 79 +const R_PPC64_GOT_TLSGD16_HA = 82 +const R_PPC64_GOT_TLSGD16_HI = 81 +const R_PPC64_GOT_TLSGD16_LO = 80 +const R_PPC64_GOT_TLSLD16 = 83 +const R_PPC64_GOT_TLSLD16_HA = 86 +const R_PPC64_GOT_TLSLD16_HI = 85 +const R_PPC64_GOT_TLSLD16_LO = 84 +const R_PPC64_GOT_TPREL16_DS = 87 +const R_PPC64_GOT_TPREL16_HA = 90 +const R_PPC64_GOT_TPREL16_HI = 89 +const R_PPC64_GOT_TPREL16_LO_DS = 88 +const R_PPC64_IRELATIVE = 248 +const R_PPC64_JMP_IREL = 247 +const R_PPC64_JMP_SLOT = 21 +const R_PPC64_NONE = 0 +const R_PPC64_PLT16_HA = 31 +const R_PPC64_PLT16_HI = 30 +const R_PPC64_PLT16_LO = 29 +const R_PPC64_PLT16_LO_DS = 60 +const R_PPC64_PLT32 = 27 +const R_PPC64_PLT64 = 45 +const R_PPC64_PLTGOT16 = 52 +const R_PPC64_PLTGOT16_DS = 65 +const R_PPC64_PLTGOT16_HA = 55 +const R_PPC64_PLTGOT16_HI = 54 +const R_PPC64_PLTGOT16_LO = 53 +const R_PPC64_PLTGOT16_LO_DS = 66 +const R_PPC64_PLTREL32 = 28 +const R_PPC64_PLTREL64 = 46 +const R_PPC64_REL14 = 11 +const R_PPC64_REL14_BRNTAKEN = 13 +const R_PPC64_REL14_BRTAKEN = 12 +const R_PPC64_REL16 = 249 +const R_PPC64_REL16_HA = 252 +const R_PPC64_REL16_HI = 251 +const R_PPC64_REL16_LO = 250 +const R_PPC64_REL24 = 10 +const R_PPC64_REL32 = 26 +const R_PPC64_REL64 = 44 +const R_PPC64_RELATIVE = 22 +const R_PPC64_SECTOFF = 33 +const R_PPC64_SECTOFF_DS = 61 +const R_PPC64_SECTOFF_HA = 36 +const R_PPC64_SECTOFF_HI = 35 +const R_PPC64_SECTOFF_LO = 34 +const R_PPC64_SECTOFF_LO_DS = 62 +const R_PPC64_TLS = 67 +const R_PPC64_TLSGD = 107 +const R_PPC64_TLSLD = 108 +const R_PPC64_TOC = 51 +const R_PPC64_TOC16 = 47 +const R_PPC64_TOC16_DS = 63 +const R_PPC64_TOC16_HA = 50 +const R_PPC64_TOC16_HI = 49 +const R_PPC64_TOC16_LO = 48 +const R_PPC64_TOC16_LO_DS = 64 +const R_PPC64_TOCSAVE = 109 +const R_PPC64_TPREL16 = 69 +const R_PPC64_TPREL16_DS = 95 +const R_PPC64_TPREL16_HA = 72 +const R_PPC64_TPREL16_HI = 71 +const R_PPC64_TPREL16_HIGH = 112 +const R_PPC64_TPREL16_HIGHA = 113 +const R_PPC64_TPREL16_HIGHER = 97 +const R_PPC64_TPREL16_HIGHERA = 98 +const R_PPC64_TPREL16_HIGHEST = 99 +const R_PPC64_TPREL16_HIGHESTA = 100 +const R_PPC64_TPREL16_LO = 70 +const R_PPC64_TPREL16_LO_DS = 96 +const R_PPC64_TPREL64 = 73 +const R_PPC64_UADDR16 = 25 +const R_PPC64_UADDR32 = 24 +const R_PPC64_UADDR64 = 43 +const R_PPC_ADDR14 = 7 +const R_PPC_ADDR14_BRNTAKEN = 9 +const R_PPC_ADDR14_BRTAKEN = 8 +const R_PPC_ADDR16 = 3 +const R_PPC_ADDR16_HA = 6 +const R_PPC_ADDR16_HI = 5 +const R_PPC_ADDR16_LO = 4 +const R_PPC_ADDR24 = 2 +const R_PPC_ADDR32 = 1 +const R_PPC_COPY = 19 +const R_PPC_DIAB_RELSDA_HA = 185 +const R_PPC_DIAB_RELSDA_HI = 184 +const R_PPC_DIAB_RELSDA_LO = 183 +const R_PPC_DIAB_SDA21_HA = 182 +const R_PPC_DIAB_SDA21_HI = 181 +const R_PPC_DIAB_SDA21_LO = 180 +const R_PPC_DTPMOD32 = 68 +const R_PPC_DTPREL16 = 74 +const R_PPC_DTPREL16_HA = 77 +const R_PPC_DTPREL16_HI = 76 +const R_PPC_DTPREL16_LO = 75 +const R_PPC_DTPREL32 = 78 +const R_PPC_EMB_BIT_FLD = 115 +const R_PPC_EMB_MRKREF = 110 +const R_PPC_EMB_NADDR16 = 102 +const R_PPC_EMB_NADDR16_HA = 105 +const R_PPC_EMB_NADDR16_HI = 104 +const R_PPC_EMB_NADDR16_LO = 103 +const R_PPC_EMB_NADDR32 = 101 +const R_PPC_EMB_RELSDA = 116 +const R_PPC_EMB_RELSEC16 = 111 +const R_PPC_EMB_RELST_HA = 114 +const R_PPC_EMB_RELST_HI = 113 +const R_PPC_EMB_RELST_LO = 112 +const R_PPC_EMB_SDA21 = 109 +const R_PPC_EMB_SDA2I16 = 107 +const R_PPC_EMB_SDA2REL = 108 +const R_PPC_EMB_SDAI16 = 106 +const R_PPC_GLOB_DAT = 20 +const R_PPC_GOT16 = 14 +const R_PPC_GOT16_HA = 17 +const R_PPC_GOT16_HI = 16 +const R_PPC_GOT16_LO = 15 +const R_PPC_GOT_DTPREL16 = 91 +const R_PPC_GOT_DTPREL16_HA = 94 +const R_PPC_GOT_DTPREL16_HI = 93 +const R_PPC_GOT_DTPREL16_LO = 92 +const R_PPC_GOT_TLSGD16 = 79 +const R_PPC_GOT_TLSGD16_HA = 82 +const R_PPC_GOT_TLSGD16_HI = 81 +const R_PPC_GOT_TLSGD16_LO = 80 +const R_PPC_GOT_TLSLD16 = 83 +const R_PPC_GOT_TLSLD16_HA = 86 +const R_PPC_GOT_TLSLD16_HI = 85 +const R_PPC_GOT_TLSLD16_LO = 84 +const R_PPC_GOT_TPREL16 = 87 +const R_PPC_GOT_TPREL16_HA = 90 +const R_PPC_GOT_TPREL16_HI = 89 +const R_PPC_GOT_TPREL16_LO = 88 +const R_PPC_IRELATIVE = 248 +const R_PPC_JMP_SLOT = 21 +const R_PPC_LOCAL24PC = 23 +const R_PPC_NONE = 0 +const R_PPC_PLT16_HA = 31 +const R_PPC_PLT16_HI = 30 +const R_PPC_PLT16_LO = 29 +const R_PPC_PLT32 = 27 +const R_PPC_PLTREL24 = 18 +const R_PPC_PLTREL32 = 28 +const R_PPC_REL14 = 11 +const R_PPC_REL14_BRNTAKEN = 13 +const R_PPC_REL14_BRTAKEN = 12 +const R_PPC_REL16 = 249 +const R_PPC_REL16_HA = 252 +const R_PPC_REL16_HI = 251 +const R_PPC_REL16_LO = 250 +const R_PPC_REL24 = 10 +const R_PPC_REL32 = 26 +const R_PPC_RELATIVE = 22 +const R_PPC_SDAREL16 = 32 +const R_PPC_SECTOFF = 33 +const R_PPC_SECTOFF_HA = 36 +const R_PPC_SECTOFF_HI = 35 +const R_PPC_SECTOFF_LO = 34 +const R_PPC_TLS = 67 +const R_PPC_TLSGD = 95 +const R_PPC_TLSLD = 96 +const R_PPC_TOC16 = 255 +const R_PPC_TPREL16 = 69 +const R_PPC_TPREL16_HA = 72 +const R_PPC_TPREL16_HI = 71 +const R_PPC_TPREL16_LO = 70 +const R_PPC_TPREL32 = 73 +const R_PPC_UADDR16 = 25 +const R_PPC_UADDR32 = 24 +const R_RISCV_32 = 1 +const R_RISCV_32_PCREL = 57 +const R_RISCV_64 = 2 +const R_RISCV_ADD16 = 34 +const R_RISCV_ADD32 = 35 +const R_RISCV_ADD64 = 36 +const R_RISCV_ADD8 = 33 +const R_RISCV_ALIGN = 43 +const R_RISCV_BRANCH = 16 +const R_RISCV_CALL = 18 +const R_RISCV_CALL_PLT = 19 +const R_RISCV_COPY = 4 +const R_RISCV_GOT32_PCREL = 41 +const R_RISCV_GOT_HI20 = 20 +const R_RISCV_HI20 = 26 +const R_RISCV_IRELATIVE = 58 +const R_RISCV_JAL = 17 +const R_RISCV_JUMP_SLOT = 5 +const R_RISCV_LO12_I = 27 +const R_RISCV_LO12_S = 28 +const R_RISCV_NONE = 0 +const R_RISCV_PCREL_HI20 = 23 +const R_RISCV_PCREL_LO12_I = 24 +const R_RISCV_PCREL_LO12_S = 25 +const R_RISCV_PLT32 = 59 +const R_RISCV_RELATIVE = 3 +const R_RISCV_RELAX = 51 +const R_RISCV_RVC_BRANCH = 44 +const R_RISCV_RVC_JUMP = 45 +const R_RISCV_RVC_LUI = 46 +const R_RISCV_SET16 = 55 +const R_RISCV_SET32 = 56 +const R_RISCV_SET6 = 53 +const R_RISCV_SET8 = 54 +const R_RISCV_SET_ULEB128 = 60 +const R_RISCV_SUB16 = 38 +const R_RISCV_SUB32 = 39 +const R_RISCV_SUB6 = 52 +const R_RISCV_SUB64 = 40 +const R_RISCV_SUB8 = 37 +const R_RISCV_SUB_ULEB128 = 61 +const R_RISCV_TLSDESC = 12 +const R_RISCV_TLSDESC_ADD_LO12 = 64 +const R_RISCV_TLSDESC_CALL = 65 +const R_RISCV_TLSDESC_HI20 = 62 +const R_RISCV_TLSDESC_LOAD_LO12 = 63 +const R_RISCV_TLS_DTPMOD32 = 6 +const R_RISCV_TLS_DTPMOD64 = 7 +const R_RISCV_TLS_DTPREL32 = 8 +const R_RISCV_TLS_DTPREL64 = 9 +const R_RISCV_TLS_GD_HI20 = 22 +const R_RISCV_TLS_GOT_HI20 = 21 +const R_RISCV_TLS_TPREL32 = 10 +const R_RISCV_TLS_TPREL64 = 11 +const R_RISCV_TPREL_ADD = 32 +const R_RISCV_TPREL_HI20 = 29 +const R_RISCV_TPREL_LO12_I = 30 +const R_RISCV_TPREL_LO12_S = 31 +const R_SH_ALIGN = 29 +const R_SH_CODE = 30 +const R_SH_COPY = 162 +const R_SH_COUNT = 28 +const R_SH_DATA = 31 +const R_SH_DIR32 = 1 +const R_SH_DIR8BP = 7 +const R_SH_DIR8L = 9 +const R_SH_DIR8W = 8 +const R_SH_DIR8WPL = 5 +const R_SH_DIR8WPN = 3 +const R_SH_DIR8WPZ = 6 +const R_SH_FUNCDESC = 207 +const R_SH_FUNCDESC_VALUE = 208 +const R_SH_GLOB_DAT = 163 +const R_SH_GNU_VTENTRY = 35 +const R_SH_GNU_VTINHERIT = 34 +const R_SH_GOT20 = 201 +const R_SH_GOT32 = 160 +const R_SH_GOTFUNCDESC = 203 +const R_SH_GOTFUNCDEST20 = 204 +const R_SH_GOTOFF = 166 +const R_SH_GOTOFF20 = 202 +const R_SH_GOTOFFFUNCDESC = 205 +const R_SH_GOTOFFFUNCDEST20 = 206 +const R_SH_GOTPC = 167 +const R_SH_IND12W = 4 +const R_SH_JMP_SLOT = 164 +const R_SH_LABEL = 32 +const R_SH_NONE = 0 +const R_SH_NUM = 256 +const R_SH_PLT32 = 161 +const R_SH_REL32 = 2 +const R_SH_RELATIVE = 165 +const R_SH_SWITCH16 = 25 +const R_SH_SWITCH32 = 26 +const R_SH_SWITCH8 = 33 +const R_SH_TLS_DTPMOD32 = 149 +const R_SH_TLS_DTPOFF32 = 150 +const R_SH_TLS_GD_32 = 144 +const R_SH_TLS_IE_32 = 147 +const R_SH_TLS_LDO_32 = 146 +const R_SH_TLS_LD_32 = 145 +const R_SH_TLS_LE_32 = 148 +const R_SH_TLS_TPOFF32 = 151 +const R_SH_USES = 27 +const R_SPARC_10 = 30 +const R_SPARC_11 = 31 +const R_SPARC_13 = 11 +const R_SPARC_16 = 2 +const R_SPARC_22 = 10 +const R_SPARC_32 = 3 +const R_SPARC_5 = 44 +const R_SPARC_6 = 45 +const R_SPARC_64 = 32 +const R_SPARC_7 = 43 +const R_SPARC_8 = 1 +const R_SPARC_COPY = 19 +const R_SPARC_DISP16 = 5 +const R_SPARC_DISP32 = 6 +const R_SPARC_DISP64 = 46 +const R_SPARC_DISP8 = 4 +const R_SPARC_GLOB_DAT = 20 +const R_SPARC_GLOB_JMP = 42 +const R_SPARC_GNU_VTENTRY = 251 +const R_SPARC_GNU_VTINHERIT = 250 +const R_SPARC_GOT10 = 13 +const R_SPARC_GOT13 = 14 +const R_SPARC_GOT22 = 15 +const R_SPARC_GOTDATA_HIX22 = 80 +const R_SPARC_GOTDATA_LOX10 = 81 +const R_SPARC_GOTDATA_OP = 84 +const R_SPARC_GOTDATA_OP_HIX22 = 82 +const R_SPARC_GOTDATA_OP_LOX10 = 83 +const R_SPARC_H34 = 85 +const R_SPARC_H44 = 50 +const R_SPARC_HH22 = 34 +const R_SPARC_HI22 = 9 +const R_SPARC_HIPLT22 = 25 +const R_SPARC_HIX22 = 48 +const R_SPARC_HM10 = 35 +const R_SPARC_JMP_SLOT = 21 +const R_SPARC_L44 = 52 +const R_SPARC_LM22 = 36 +const R_SPARC_LO10 = 12 +const R_SPARC_LOPLT10 = 26 +const R_SPARC_LOX10 = 49 +const R_SPARC_M44 = 51 +const R_SPARC_NONE = 0 +const R_SPARC_NUM = 253 +const R_SPARC_OLO10 = 33 +const R_SPARC_PC10 = 16 +const R_SPARC_PC22 = 17 +const R_SPARC_PCPLT10 = 29 +const R_SPARC_PCPLT22 = 28 +const R_SPARC_PCPLT32 = 27 +const R_SPARC_PC_HH22 = 37 +const R_SPARC_PC_HM10 = 38 +const R_SPARC_PC_LM22 = 39 +const R_SPARC_PLT32 = 24 +const R_SPARC_PLT64 = 47 +const R_SPARC_REGISTER = 53 +const R_SPARC_RELATIVE = 22 +const R_SPARC_REV32 = 252 +const R_SPARC_SIZE32 = 86 +const R_SPARC_SIZE64 = 87 +const R_SPARC_TLS_DTPMOD32 = 74 +const R_SPARC_TLS_DTPMOD64 = 75 +const R_SPARC_TLS_DTPOFF32 = 76 +const R_SPARC_TLS_DTPOFF64 = 77 +const R_SPARC_TLS_GD_ADD = 58 +const R_SPARC_TLS_GD_CALL = 59 +const R_SPARC_TLS_GD_HI22 = 56 +const R_SPARC_TLS_GD_LO10 = 57 +const R_SPARC_TLS_IE_ADD = 71 +const R_SPARC_TLS_IE_HI22 = 67 +const R_SPARC_TLS_IE_LD = 69 +const R_SPARC_TLS_IE_LDX = 70 +const R_SPARC_TLS_IE_LO10 = 68 +const R_SPARC_TLS_LDM_ADD = 62 +const R_SPARC_TLS_LDM_CALL = 63 +const R_SPARC_TLS_LDM_HI22 = 60 +const R_SPARC_TLS_LDM_LO10 = 61 +const R_SPARC_TLS_LDO_ADD = 66 +const R_SPARC_TLS_LDO_HIX22 = 64 +const R_SPARC_TLS_LDO_LOX10 = 65 +const R_SPARC_TLS_LE_HIX22 = 72 +const R_SPARC_TLS_LE_LOX10 = 73 +const R_SPARC_TLS_TPOFF32 = 78 +const R_SPARC_TLS_TPOFF64 = 79 +const R_SPARC_UA16 = 55 +const R_SPARC_UA32 = 23 +const R_SPARC_UA64 = 54 +const R_SPARC_WDISP16 = 40 +const R_SPARC_WDISP19 = 41 +const R_SPARC_WDISP22 = 8 +const R_SPARC_WDISP30 = 7 +const R_SPARC_WPLT30 = 18 +const R_X86_64_16 = 12 +const R_X86_64_32 = 10 +const R_X86_64_32S = 11 +const R_X86_64_64 = 1 +const R_X86_64_8 = 14 +const R_X86_64_COPY = 5 +const R_X86_64_DTPMOD64 = 16 +const R_X86_64_DTPOFF32 = 21 +const R_X86_64_DTPOFF64 = 17 +const R_X86_64_GLOB_DAT = 6 +const R_X86_64_GOT32 = 3 +const R_X86_64_GOT64 = 27 +const R_X86_64_GOTOFF64 = 25 +const R_X86_64_GOTPC32 = 26 +const R_X86_64_GOTPC32_TLSDESC = 34 +const R_X86_64_GOTPC64 = 29 +const R_X86_64_GOTPCREL = 9 +const R_X86_64_GOTPCREL64 = 28 +const R_X86_64_GOTPCRELX = 41 +const R_X86_64_GOTPLT64 = 30 +const R_X86_64_GOTTPOFF = 22 +const R_X86_64_IRELATIVE = 37 +const R_X86_64_JUMP_SLOT = 7 +const R_X86_64_NONE = 0 +const R_X86_64_NUM = 43 +const R_X86_64_PC16 = 13 +const R_X86_64_PC32 = 2 +const R_X86_64_PC64 = 24 +const R_X86_64_PC8 = 15 +const R_X86_64_PLT32 = 4 +const R_X86_64_PLTOFF64 = 31 +const R_X86_64_RELATIVE = 8 +const R_X86_64_RELATIVE64 = 38 +const R_X86_64_REX_GOTPCRELX = 42 +const R_X86_64_SIZE32 = 32 +const R_X86_64_SIZE64 = 33 +const R_X86_64_TLSDESC = 36 +const R_X86_64_TLSDESC_CALL = 35 +const R_X86_64_TLSGD = 19 +const R_X86_64_TLSLD = 20 +const R_X86_64_TPOFF32 = 23 +const R_X86_64_TPOFF64 = 18 +const SA_EXPOSE_TAGBITS = 2048 +const SA_NOCLDSTOP = 1 +const SA_NOCLDWAIT = 2 +const SA_NODEFER = 1073741824 +const SA_ONSTACK = 134217728 +const SA_RESETHAND = 2147483648 +const SA_RESTART = 268435456 +const SA_RESTORER = 67108864 +const SA_SIGINFO = 4 +const SA_UNSUPPORTED = 1024 +const SCM_TIMESTAMPING_OLD = 37 +const SCM_TIMESTAMPNS_OLD = 35 +const SCM_TIMESTAMP_OLD = 29 +const SEGV_ACCERR = 2 +const SEGV_BNDERR = 3 +const SEGV_MAPERR = 1 +const SEGV_MTEAERR = 8 +const SEGV_MTESERR = 9 +const SEGV_PKUERR = 4 +const SELFMAG = 4 +const SHF_ALLOC = 2 +const SHF_ALPHA_GPREL = 268435456 +const SHF_ARM_COMDEF = 2147483648 +const SHF_ARM_ENTRYSECT = 268435456 +const SHF_COMPRESSED = 2048 +const SHF_EXCLUDE = 2147483648 +const SHF_EXECINSTR = 4 +const SHF_GROUP = 512 +const SHF_IA_64_NORECOV = 536870912 +const SHF_IA_64_SHORT = 268435456 +const SHF_INFO_LINK = 64 +const SHF_LINK_ORDER = 128 +const SHF_MASKOS = 267386880 +const SHF_MASKPROC = 4026531840 +const SHF_MERGE = 16 +const SHF_MIPS_ADDR = 1073741824 +const SHF_MIPS_GPREL = 268435456 +const SHF_MIPS_LOCAL = 67108864 +const SHF_MIPS_MERGE = 536870912 +const SHF_MIPS_NAMES = 33554432 +const SHF_MIPS_NODUPE = 16777216 +const SHF_MIPS_NOSTRIP = 134217728 +const SHF_MIPS_STRINGS = 2147483648 +const SHF_ORDERED = 1073741824 +const SHF_OS_NONCONFORMING = 256 +const SHF_PARISC_HUGE = 1073741824 +const SHF_PARISC_SBP = 2147483648 +const SHF_PARISC_SHORT = 536870912 +const SHF_STRINGS = 32 +const SHF_TLS = 1024 +const SHF_WRITE = 1 +const SHN_ABS = 65521 +const SHN_AFTER = 65281 +const SHN_BEFORE = 65280 +const SHN_COMMON = 65522 +const SHN_HIOS = 65343 +const SHN_HIPROC = 65311 +const SHN_HIRESERVE = 65535 +const SHN_LOOS = 65312 +const SHN_LOPROC = 65280 +const SHN_LORESERVE = 65280 +const SHN_MIPS_ACOMMON = 65280 +const SHN_MIPS_DATA = 65282 +const SHN_MIPS_SCOMMON = 65283 +const SHN_MIPS_SUNDEFINED = 65284 +const SHN_MIPS_TEXT = 65281 +const SHN_PARISC_ANSI_COMMON = 65280 +const SHN_PARISC_HUGE_COMMON = 65281 +const SHN_UNDEF = 0 +const SHN_XINDEX = 65535 +const SHT_ALPHA_DEBUG = 1879048193 +const SHT_ALPHA_REGINFO = 1879048194 +const SHT_ARM_ATTRIBUTES = 1879048195 +const SHT_ARM_EXIDX = 1879048193 +const SHT_ARM_PREEMPTMAP = 1879048194 +const SHT_CHECKSUM = 1879048184 +const SHT_DYNAMIC = 6 +const SHT_DYNSYM = 11 +const SHT_FINI_ARRAY = 15 +const SHT_GNU_ATTRIBUTES = 1879048181 +const SHT_GNU_HASH = 1879048182 +const SHT_GNU_LIBLIST = 1879048183 +const SHT_GNU_verdef = 1879048189 +const SHT_GNU_verneed = 1879048190 +const SHT_GNU_versym = 1879048191 +const SHT_GROUP = 17 +const SHT_HASH = 5 +const SHT_HIOS = 1879048191 +const SHT_HIPROC = 2147483647 +const SHT_HISUNW = 1879048191 +const SHT_HIUSER = 2415919103 +const SHT_IA_64_EXT = 1879048192 +const SHT_IA_64_UNWIND = 1879048193 +const SHT_INIT_ARRAY = 14 +const SHT_LOOS = 1610612736 +const SHT_LOPROC = 1879048192 +const SHT_LOSUNW = 1879048186 +const SHT_LOUSER = 2147483648 +const SHT_MIPS_AUXSYM = 1879048214 +const SHT_MIPS_CONFLICT = 1879048194 +const SHT_MIPS_CONTENT = 1879048204 +const SHT_MIPS_DEBUG = 1879048197 +const SHT_MIPS_DELTACLASS = 1879048221 +const SHT_MIPS_DELTADECL = 1879048223 +const SHT_MIPS_DELTAINST = 1879048220 +const SHT_MIPS_DELTASYM = 1879048219 +const SHT_MIPS_DENSE = 1879048211 +const SHT_MIPS_DWARF = 1879048222 +const SHT_MIPS_EH_REGION = 1879048231 +const SHT_MIPS_EVENTS = 1879048225 +const SHT_MIPS_EXTSYM = 1879048210 +const SHT_MIPS_FDESC = 1879048209 +const SHT_MIPS_GPTAB = 1879048195 +const SHT_MIPS_IFACE = 1879048203 +const SHT_MIPS_LIBLIST = 1879048192 +const SHT_MIPS_LINE = 1879048217 +const SHT_MIPS_LOCSTR = 1879048216 +const SHT_MIPS_LOCSYM = 1879048213 +const SHT_MIPS_MSYM = 1879048193 +const SHT_MIPS_OPTIONS = 1879048205 +const SHT_MIPS_OPTSYM = 1879048215 +const SHT_MIPS_PACKAGE = 1879048199 +const SHT_MIPS_PACKSYM = 1879048200 +const SHT_MIPS_PDESC = 1879048212 +const SHT_MIPS_PDR_EXCEPTION = 1879048233 +const SHT_MIPS_PIXIE = 1879048227 +const SHT_MIPS_REGINFO = 1879048198 +const SHT_MIPS_RELD = 1879048201 +const SHT_MIPS_RFDESC = 1879048218 +const SHT_MIPS_SHDR = 1879048208 +const SHT_MIPS_SYMBOL_LIB = 1879048224 +const SHT_MIPS_TRANSLATE = 1879048226 +const SHT_MIPS_UCODE = 1879048196 +const SHT_MIPS_WHIRL = 1879048230 +const SHT_MIPS_XLATE = 1879048228 +const SHT_MIPS_XLATE_DEBUG = 1879048229 +const SHT_MIPS_XLATE_OLD = 1879048232 +const SHT_NOBITS = 8 +const SHT_NOTE = 7 +const SHT_NULL = 0 +const SHT_NUM = 20 +const SHT_PARISC_DOC = 1879048194 +const SHT_PARISC_EXT = 1879048192 +const SHT_PARISC_UNWIND = 1879048193 +const SHT_PREINIT_ARRAY = 16 +const SHT_PROGBITS = 1 +const SHT_REL = 9 +const SHT_RELA = 4 +const SHT_RELR = 19 +const SHT_SHLIB = 10 +const SHT_STRTAB = 3 +const SHT_SUNW_COMDAT = 1879048187 +const SHT_SUNW_move = 1879048186 +const SHT_SUNW_syminfo = 1879048188 +const SHT_SYMTAB = 2 +const SHT_SYMTAB_SHNDX = 18 +const SIGABRT = 6 +const SIGALRM = 14 +const SIGBUS = 7 +const SIGCHLD = 17 +const SIGCONT = 18 +const SIGEV_NONE = 1 +const SIGEV_SIGNAL = 0 +const SIGEV_THREAD = 2 +const SIGEV_THREAD_ID = 4 +const SIGFPE = 8 +const SIGHUP = 1 +const SIGILL = 4 +const SIGINT = 2 +const SIGIO = 29 +const SIGIOT = 6 +const SIGKILL = 9 +const SIGPIPE = 13 +const SIGPOLL = 29 +const SIGPROF = 27 +const SIGPWR = 30 +const SIGQUIT = 3 +const SIGRTMAX = 0 +const SIGRTMIN = 0 +const SIGSEGV = 11 +const SIGSTKFLT = 16 +const SIGSTKSZ = 12288 +const SIGSTOP = 19 +const SIGSYS = 31 +const SIGTERM = 15 +const SIGTRAP = 5 +const SIGTSTP = 20 +const SIGTTIN = 21 +const SIGTTOU = 22 +const SIGUNUSED = 31 +const SIGURG = 23 +const SIGUSR1 = 10 +const SIGUSR2 = 12 +const SIGVTALRM = 26 +const SIGWINCH = 28 +const SIGXCPU = 24 +const SIGXFSZ = 25 +const SIG_BLOCK = 0 +const SIG_SETMASK = 2 +const SIG_UNBLOCK = 1 +const SIOCGSTAMPNS_OLD = 35079 +const SIOCGSTAMP_OLD = 35078 +const SI_ASYNCIO = -4 +const SI_ASYNCNL = -60 +const SI_KERNEL = 128 +const SI_MESGQ = -3 +const SI_QUEUE = -1 +const SI_SIGIO = -5 +const SI_TIMER = -2 +const SI_TKILL = -6 +const SI_USER = 0 +const SO_RCVTIMEO_OLD = 20 +const SO_SNDTIMEO_OLD = 21 +const SO_TIMESTAMPING_OLD = 37 +const SO_TIMESTAMPNS_OLD = 35 +const SO_TIMESTAMP_OLD = 29 +const SS_AUTODISARM = 2147483648 +const SS_DISABLE = 2 +const SS_FLAG_BITS = 2147483648 +const SS_ONSTACK = 1 +const STB_GLOBAL = 1 +const STB_GNU_UNIQUE = 10 +const STB_HIOS = 12 +const STB_HIPROC = 15 +const STB_LOCAL = 0 +const STB_LOOS = 10 +const STB_LOPROC = 13 +const STB_MIPS_SPLIT_COMMON = 13 +const STB_NUM = 3 +const STB_WEAK = 2 +const STN_UNDEF = 0 +const STO_ALPHA_NOPV = 128 +const STO_ALPHA_STD_GPLOAD = 136 +const STO_MIPS_DEFAULT = 0 +const STO_MIPS_HIDDEN = 2 +const STO_MIPS_INTERNAL = 1 +const STO_MIPS_PLT = 8 +const STO_MIPS_PROTECTED = 3 +const STO_MIPS_SC_ALIGN_UNUSED = 255 +const STO_PPC64_LOCAL_BIT = 5 +const STO_PPC64_LOCAL_MASK = 224 +const STT_ARM_16BIT = 15 +const STT_ARM_TFUNC = 13 +const STT_COMMON = 5 +const STT_FILE = 4 +const STT_FUNC = 2 +const STT_GNU_IFUNC = 10 +const STT_HIOS = 12 +const STT_HIPROC = 15 +const STT_HP_OPAQUE = 11 +const STT_HP_STUB = 12 +const STT_LOOS = 10 +const STT_LOPROC = 13 +const STT_NOTYPE = 0 +const STT_NUM = 7 +const STT_OBJECT = 1 +const STT_PARISC_MILLICODE = 13 +const STT_SECTION = 3 +const STT_SPARC_REGISTER = 13 +const STT_TLS = 6 +const STV_DEFAULT = 0 +const STV_HIDDEN = 2 +const STV_INTERNAL = 1 +const STV_PROTECTED = 3 +const SYMINFO_BT_LOWRESERVE = 65280 +const SYMINFO_BT_PARENT = 65534 +const SYMINFO_BT_SELF = 65535 +const SYMINFO_CURRENT = 1 +const SYMINFO_FLG_COPY = 4 +const SYMINFO_FLG_DIRECT = 1 +const SYMINFO_FLG_LAZYLOAD = 8 +const SYMINFO_FLG_PASSTHRU = 2 +const SYMINFO_NONE = 0 +const SYMINFO_NUM = 2 +const SYSCALL_MMAP2_UNIT = 4096 +const SYSCALL_RLIM_INFINITY = 18446744073709551615 +const SYS_accept = 202 +const SYS_accept4 = 242 +const SYS_acct = 89 +const SYS_add_key = 217 +const SYS_adjtimex = 171 +const SYS_bind = 200 +const SYS_bpf = 280 +const SYS_brk = 214 +const SYS_cachestat = 451 +const SYS_capget = 90 +const SYS_capset = 91 +const SYS_chdir = 49 +const SYS_chroot = 51 +const SYS_clock_adjtime = 266 +const SYS_clock_getres = 114 +const SYS_clock_gettime = 113 +const SYS_clock_nanosleep = 115 +const SYS_clock_settime = 112 +const SYS_clone = 220 +const SYS_clone3 = 435 +const SYS_close = 57 +const SYS_close_range = 436 +const SYS_connect = 203 +const SYS_copy_file_range = 285 +const SYS_delete_module = 106 +const SYS_dup = 23 +const SYS_dup3 = 24 +const SYS_epoll_create1 = 20 +const SYS_epoll_ctl = 21 +const SYS_epoll_pwait = 22 +const SYS_epoll_pwait2 = 441 +const SYS_eventfd2 = 19 +const SYS_execve = 221 +const SYS_execveat = 281 +const SYS_exit = 93 +const SYS_exit_group = 94 +const SYS_faccessat = 48 +const SYS_faccessat2 = 439 +const SYS_fadvise64 = 223 +const SYS_fallocate = 47 +const SYS_fanotify_init = 262 +const SYS_fanotify_mark = 263 +const SYS_fchdir = 50 +const SYS_fchmod = 52 +const SYS_fchmodat = 53 +const SYS_fchmodat2 = 452 +const SYS_fchown = 55 +const SYS_fchownat = 54 +const SYS_fcntl = 25 +const SYS_fdatasync = 83 +const SYS_fgetxattr = 10 +const SYS_finit_module = 273 +const SYS_flistxattr = 13 +const SYS_flock = 32 +const SYS_fremovexattr = 16 +const SYS_fsconfig = 431 +const SYS_fsetxattr = 7 +const SYS_fsmount = 432 +const SYS_fsopen = 430 +const SYS_fspick = 433 +const SYS_fstat = 80 +const SYS_fstatfs = 44 +const SYS_fsync = 82 +const SYS_ftruncate = 46 +const SYS_futex = 98 +const SYS_futex_waitv = 449 +const SYS_get_mempolicy = 236 +const SYS_get_robust_list = 100 +const SYS_getcpu = 168 +const SYS_getcwd = 17 +const SYS_getdents64 = 61 +const SYS_getegid = 177 +const SYS_geteuid = 175 +const SYS_getgid = 176 +const SYS_getgroups = 158 +const SYS_getitimer = 102 +const SYS_getpeername = 205 +const SYS_getpgid = 155 +const SYS_getpid = 172 +const SYS_getppid = 173 +const SYS_getpriority = 141 +const SYS_getrandom = 278 +const SYS_getresgid = 150 +const SYS_getresuid = 148 +const SYS_getrlimit = 163 +const SYS_getrusage = 165 +const SYS_getsid = 156 +const SYS_getsockname = 204 +const SYS_getsockopt = 209 +const SYS_gettid = 178 +const SYS_gettimeofday = 169 +const SYS_getuid = 174 +const SYS_getxattr = 8 +const SYS_init_module = 105 +const SYS_inotify_add_watch = 27 +const SYS_inotify_init1 = 26 +const SYS_inotify_rm_watch = 28 +const SYS_io_cancel = 3 +const SYS_io_destroy = 1 +const SYS_io_getevents = 4 +const SYS_io_pgetevents = 292 +const SYS_io_setup = 0 +const SYS_io_submit = 2 +const SYS_io_uring_enter = 426 +const SYS_io_uring_register = 427 +const SYS_io_uring_setup = 425 +const SYS_ioctl = 29 +const SYS_ioprio_get = 31 +const SYS_ioprio_set = 30 +const SYS_kcmp = 272 +const SYS_kexec_file_load = 294 +const SYS_kexec_load = 104 +const SYS_keyctl = 219 +const SYS_kill = 129 +const SYS_landlock_add_rule = 445 +const SYS_landlock_create_ruleset = 444 +const SYS_landlock_restrict_self = 446 +const SYS_lgetxattr = 9 +const SYS_linkat = 37 +const SYS_listen = 201 +const SYS_listxattr = 11 +const SYS_llistxattr = 12 +const SYS_lookup_dcookie = 18 +const SYS_lremovexattr = 15 +const SYS_lseek = 62 +const SYS_lsetxattr = 6 +const SYS_madvise = 233 +const SYS_mbind = 235 +const SYS_membarrier = 283 +const SYS_memfd_create = 279 +const SYS_migrate_pages = 238 +const SYS_mincore = 232 +const SYS_mkdirat = 34 +const SYS_mknodat = 33 +const SYS_mlock = 228 +const SYS_mlock2 = 284 +const SYS_mlockall = 230 +const SYS_mmap = 222 +const SYS_mount = 40 +const SYS_mount_setattr = 442 +const SYS_move_mount = 429 +const SYS_move_pages = 239 +const SYS_mprotect = 226 +const SYS_mq_getsetattr = 185 +const SYS_mq_notify = 184 +const SYS_mq_open = 180 +const SYS_mq_timedreceive = 183 +const SYS_mq_timedsend = 182 +const SYS_mq_unlink = 181 +const SYS_mremap = 216 +const SYS_msgctl = 187 +const SYS_msgget = 186 +const SYS_msgrcv = 188 +const SYS_msgsnd = 189 +const SYS_msync = 227 +const SYS_munlock = 229 +const SYS_munlockall = 231 +const SYS_munmap = 215 +const SYS_name_to_handle_at = 264 +const SYS_nanosleep = 101 +const SYS_newfstatat = 79 +const SYS_nfsservctl = 42 +const SYS_open_by_handle_at = 265 +const SYS_open_tree = 428 +const SYS_openat = 56 +const SYS_openat2 = 437 +const SYS_perf_event_open = 241 +const SYS_personality = 92 +const SYS_pidfd_getfd = 438 +const SYS_pidfd_open = 434 +const SYS_pidfd_send_signal = 424 +const SYS_pipe2 = 59 +const SYS_pivot_root = 41 +const SYS_pkey_alloc = 289 +const SYS_pkey_free = 290 +const SYS_pkey_mprotect = 288 +const SYS_ppoll = 73 +const SYS_prctl = 167 +const SYS_pread64 = 67 +const SYS_preadv = 69 +const SYS_preadv2 = 286 +const SYS_prlimit64 = 261 +const SYS_process_madvise = 440 +const SYS_process_mrelease = 448 +const SYS_process_vm_readv = 270 +const SYS_process_vm_writev = 271 +const SYS_pselect6 = 72 +const SYS_ptrace = 117 +const SYS_pwrite64 = 68 +const SYS_pwritev = 70 +const SYS_pwritev2 = 287 +const SYS_quotactl = 60 +const SYS_read = 63 +const SYS_readahead = 213 +const SYS_readlinkat = 78 +const SYS_readv = 65 +const SYS_reboot = 142 +const SYS_recvfrom = 207 +const SYS_recvmmsg = 243 +const SYS_recvmsg = 212 +const SYS_remap_file_pages = 234 +const SYS_removexattr = 14 +const SYS_renameat = 38 +const SYS_renameat2 = 276 +const SYS_request_key = 218 +const SYS_restart_syscall = 128 +const SYS_rseq = 293 +const SYS_rt_sigaction = 134 +const SYS_rt_sigpending = 136 +const SYS_rt_sigprocmask = 135 +const SYS_rt_sigqueueinfo = 138 +const SYS_rt_sigreturn = 139 +const SYS_rt_sigsuspend = 133 +const SYS_rt_sigtimedwait = 137 +const SYS_rt_tgsigqueueinfo = 240 +const SYS_sched_get_priority_max = 125 +const SYS_sched_get_priority_min = 126 +const SYS_sched_getaffinity = 123 +const SYS_sched_getattr = 275 +const SYS_sched_getparam = 121 +const SYS_sched_getscheduler = 120 +const SYS_sched_rr_get_interval = 127 +const SYS_sched_setaffinity = 122 +const SYS_sched_setattr = 274 +const SYS_sched_setparam = 118 +const SYS_sched_setscheduler = 119 +const SYS_sched_yield = 124 +const SYS_seccomp = 277 +const SYS_semctl = 191 +const SYS_semget = 190 +const SYS_semop = 193 +const SYS_semtimedop = 192 +const SYS_sendfile = 71 +const SYS_sendmmsg = 269 +const SYS_sendmsg = 211 +const SYS_sendto = 206 +const SYS_set_mempolicy = 237 +const SYS_set_mempolicy_home_node = 450 +const SYS_set_robust_list = 99 +const SYS_set_tid_address = 96 +const SYS_setdomainname = 162 +const SYS_setfsgid = 152 +const SYS_setfsuid = 151 +const SYS_setgid = 144 +const SYS_setgroups = 159 +const SYS_sethostname = 161 +const SYS_setitimer = 103 +const SYS_setns = 268 +const SYS_setpgid = 154 +const SYS_setpriority = 140 +const SYS_setregid = 143 +const SYS_setresgid = 149 +const SYS_setresuid = 147 +const SYS_setreuid = 145 +const SYS_setrlimit = 164 +const SYS_setsid = 157 +const SYS_setsockopt = 208 +const SYS_settimeofday = 170 +const SYS_setuid = 146 +const SYS_setxattr = 5 +const SYS_shmat = 196 +const SYS_shmctl = 195 +const SYS_shmdt = 197 +const SYS_shmget = 194 +const SYS_shutdown = 210 +const SYS_sigaltstack = 132 +const SYS_signalfd4 = 74 +const SYS_socket = 198 +const SYS_socketpair = 199 +const SYS_splice = 76 +const SYS_statfs = 43 +const SYS_statx = 291 +const SYS_swapoff = 225 +const SYS_swapon = 224 +const SYS_symlinkat = 36 +const SYS_sync = 81 +const SYS_sync_file_range = 84 +const SYS_syncfs = 267 +const SYS_sysinfo = 179 +const SYS_syslog = 116 +const SYS_tee = 77 +const SYS_tgkill = 131 +const SYS_timer_create = 107 +const SYS_timer_delete = 111 +const SYS_timer_getoverrun = 109 +const SYS_timer_gettime = 108 +const SYS_timer_settime = 110 +const SYS_timerfd_create = 85 +const SYS_timerfd_gettime = 87 +const SYS_timerfd_settime = 86 +const SYS_times = 153 +const SYS_tkill = 130 +const SYS_truncate = 45 +const SYS_umask = 166 +const SYS_umount2 = 39 +const SYS_uname = 160 +const SYS_unlinkat = 35 +const SYS_unshare = 97 +const SYS_userfaultfd = 282 +const SYS_utimensat = 88 +const SYS_vhangup = 58 +const SYS_vmsplice = 75 +const SYS_wait4 = 260 +const SYS_waitid = 95 +const SYS_write = 64 +const SYS_writev = 66 +const TRAP_BRANCH = 3 +const TRAP_BRKPT = 1 +const TRAP_HWBKPT = 4 +const TRAP_TRACE = 2 +const TRAP_UNK = 5 +const VER = -255 +const VER_DEF_CURRENT = 1 +const VER_DEF_NONE = 0 +const VER_DEF_NUM = 2 +const VER_FLG_BASE = 1 +const VER_FLG_WEAK = 2 +const VER_NDX_ELIMINATE = 65281 +const VER_NDX_GLOBAL = 1 +const VER_NDX_LOCAL = 0 +const VER_NDX_LORESERVE = 65280 +const VER_NEED_CURRENT = 1 +const VER_NEED_NONE = 0 +const VER_NEED_NUM = 2 +const WNOHANG = 1 +const WUNTRACED = 2 +const _NSIG = 65 +const __NR_accept = 202 +const __NR_accept4 = 242 +const __NR_acct = 89 +const __NR_add_key = 217 +const __NR_adjtimex = 171 +const __NR_bind = 200 +const __NR_bpf = 280 +const __NR_brk = 214 +const __NR_cachestat = 451 +const __NR_capget = 90 +const __NR_capset = 91 +const __NR_chdir = 49 +const __NR_chroot = 51 +const __NR_clock_adjtime = 266 +const __NR_clock_getres = 114 +const __NR_clock_gettime = 113 +const __NR_clock_nanosleep = 115 +const __NR_clock_settime = 112 +const __NR_clone = 220 +const __NR_clone3 = 435 +const __NR_close = 57 +const __NR_close_range = 436 +const __NR_connect = 203 +const __NR_copy_file_range = 285 +const __NR_delete_module = 106 +const __NR_dup = 23 +const __NR_dup3 = 24 +const __NR_epoll_create1 = 20 +const __NR_epoll_ctl = 21 +const __NR_epoll_pwait = 22 +const __NR_epoll_pwait2 = 441 +const __NR_eventfd2 = 19 +const __NR_execve = 221 +const __NR_execveat = 281 +const __NR_exit = 93 +const __NR_exit_group = 94 +const __NR_faccessat = 48 +const __NR_faccessat2 = 439 +const __NR_fadvise64 = 223 +const __NR_fallocate = 47 +const __NR_fanotify_init = 262 +const __NR_fanotify_mark = 263 +const __NR_fchdir = 50 +const __NR_fchmod = 52 +const __NR_fchmodat = 53 +const __NR_fchmodat2 = 452 +const __NR_fchown = 55 +const __NR_fchownat = 54 +const __NR_fcntl = 25 +const __NR_fdatasync = 83 +const __NR_fgetxattr = 10 +const __NR_finit_module = 273 +const __NR_flistxattr = 13 +const __NR_flock = 32 +const __NR_fremovexattr = 16 +const __NR_fsconfig = 431 +const __NR_fsetxattr = 7 +const __NR_fsmount = 432 +const __NR_fsopen = 430 +const __NR_fspick = 433 +const __NR_fstat = 80 +const __NR_fstatfs = 44 +const __NR_fsync = 82 +const __NR_ftruncate = 46 +const __NR_futex = 98 +const __NR_futex_waitv = 449 +const __NR_get_mempolicy = 236 +const __NR_get_robust_list = 100 +const __NR_getcpu = 168 +const __NR_getcwd = 17 +const __NR_getdents64 = 61 +const __NR_getegid = 177 +const __NR_geteuid = 175 +const __NR_getgid = 176 +const __NR_getgroups = 158 +const __NR_getitimer = 102 +const __NR_getpeername = 205 +const __NR_getpgid = 155 +const __NR_getpid = 172 +const __NR_getppid = 173 +const __NR_getpriority = 141 +const __NR_getrandom = 278 +const __NR_getresgid = 150 +const __NR_getresuid = 148 +const __NR_getrlimit = 163 +const __NR_getrusage = 165 +const __NR_getsid = 156 +const __NR_getsockname = 204 +const __NR_getsockopt = 209 +const __NR_gettid = 178 +const __NR_gettimeofday = 169 +const __NR_getuid = 174 +const __NR_getxattr = 8 +const __NR_init_module = 105 +const __NR_inotify_add_watch = 27 +const __NR_inotify_init1 = 26 +const __NR_inotify_rm_watch = 28 +const __NR_io_cancel = 3 +const __NR_io_destroy = 1 +const __NR_io_getevents = 4 +const __NR_io_pgetevents = 292 +const __NR_io_setup = 0 +const __NR_io_submit = 2 +const __NR_io_uring_enter = 426 +const __NR_io_uring_register = 427 +const __NR_io_uring_setup = 425 +const __NR_ioctl = 29 +const __NR_ioprio_get = 31 +const __NR_ioprio_set = 30 +const __NR_kcmp = 272 +const __NR_kexec_file_load = 294 +const __NR_kexec_load = 104 +const __NR_keyctl = 219 +const __NR_kill = 129 +const __NR_landlock_add_rule = 445 +const __NR_landlock_create_ruleset = 444 +const __NR_landlock_restrict_self = 446 +const __NR_lgetxattr = 9 +const __NR_linkat = 37 +const __NR_listen = 201 +const __NR_listxattr = 11 +const __NR_llistxattr = 12 +const __NR_lookup_dcookie = 18 +const __NR_lremovexattr = 15 +const __NR_lseek = 62 +const __NR_lsetxattr = 6 +const __NR_madvise = 233 +const __NR_mbind = 235 +const __NR_membarrier = 283 +const __NR_memfd_create = 279 +const __NR_migrate_pages = 238 +const __NR_mincore = 232 +const __NR_mkdirat = 34 +const __NR_mknodat = 33 +const __NR_mlock = 228 +const __NR_mlock2 = 284 +const __NR_mlockall = 230 +const __NR_mmap = 222 +const __NR_mount = 40 +const __NR_mount_setattr = 442 +const __NR_move_mount = 429 +const __NR_move_pages = 239 +const __NR_mprotect = 226 +const __NR_mq_getsetattr = 185 +const __NR_mq_notify = 184 +const __NR_mq_open = 180 +const __NR_mq_timedreceive = 183 +const __NR_mq_timedsend = 182 +const __NR_mq_unlink = 181 +const __NR_mremap = 216 +const __NR_msgctl = 187 +const __NR_msgget = 186 +const __NR_msgrcv = 188 +const __NR_msgsnd = 189 +const __NR_msync = 227 +const __NR_munlock = 229 +const __NR_munlockall = 231 +const __NR_munmap = 215 +const __NR_name_to_handle_at = 264 +const __NR_nanosleep = 101 +const __NR_newfstatat = 79 +const __NR_nfsservctl = 42 +const __NR_open_by_handle_at = 265 +const __NR_open_tree = 428 +const __NR_openat = 56 +const __NR_openat2 = 437 +const __NR_perf_event_open = 241 +const __NR_personality = 92 +const __NR_pidfd_getfd = 438 +const __NR_pidfd_open = 434 +const __NR_pidfd_send_signal = 424 +const __NR_pipe2 = 59 +const __NR_pivot_root = 41 +const __NR_pkey_alloc = 289 +const __NR_pkey_free = 290 +const __NR_pkey_mprotect = 288 +const __NR_ppoll = 73 +const __NR_prctl = 167 +const __NR_pread64 = 67 +const __NR_preadv = 69 +const __NR_preadv2 = 286 +const __NR_prlimit64 = 261 +const __NR_process_madvise = 440 +const __NR_process_mrelease = 448 +const __NR_process_vm_readv = 270 +const __NR_process_vm_writev = 271 +const __NR_pselect6 = 72 +const __NR_ptrace = 117 +const __NR_pwrite64 = 68 +const __NR_pwritev = 70 +const __NR_pwritev2 = 287 +const __NR_quotactl = 60 +const __NR_read = 63 +const __NR_readahead = 213 +const __NR_readlinkat = 78 +const __NR_readv = 65 +const __NR_reboot = 142 +const __NR_recvfrom = 207 +const __NR_recvmmsg = 243 +const __NR_recvmsg = 212 +const __NR_remap_file_pages = 234 +const __NR_removexattr = 14 +const __NR_renameat = 38 +const __NR_renameat2 = 276 +const __NR_request_key = 218 +const __NR_restart_syscall = 128 +const __NR_rseq = 293 +const __NR_rt_sigaction = 134 +const __NR_rt_sigpending = 136 +const __NR_rt_sigprocmask = 135 +const __NR_rt_sigqueueinfo = 138 +const __NR_rt_sigreturn = 139 +const __NR_rt_sigsuspend = 133 +const __NR_rt_sigtimedwait = 137 +const __NR_rt_tgsigqueueinfo = 240 +const __NR_sched_get_priority_max = 125 +const __NR_sched_get_priority_min = 126 +const __NR_sched_getaffinity = 123 +const __NR_sched_getattr = 275 +const __NR_sched_getparam = 121 +const __NR_sched_getscheduler = 120 +const __NR_sched_rr_get_interval = 127 +const __NR_sched_setaffinity = 122 +const __NR_sched_setattr = 274 +const __NR_sched_setparam = 118 +const __NR_sched_setscheduler = 119 +const __NR_sched_yield = 124 +const __NR_seccomp = 277 +const __NR_semctl = 191 +const __NR_semget = 190 +const __NR_semop = 193 +const __NR_semtimedop = 192 +const __NR_sendfile = 71 +const __NR_sendmmsg = 269 +const __NR_sendmsg = 211 +const __NR_sendto = 206 +const __NR_set_mempolicy = 237 +const __NR_set_mempolicy_home_node = 450 +const __NR_set_robust_list = 99 +const __NR_set_tid_address = 96 +const __NR_setdomainname = 162 +const __NR_setfsgid = 152 +const __NR_setfsuid = 151 +const __NR_setgid = 144 +const __NR_setgroups = 159 +const __NR_sethostname = 161 +const __NR_setitimer = 103 +const __NR_setns = 268 +const __NR_setpgid = 154 +const __NR_setpriority = 140 +const __NR_setregid = 143 +const __NR_setresgid = 149 +const __NR_setresuid = 147 +const __NR_setreuid = 145 +const __NR_setrlimit = 164 +const __NR_setsid = 157 +const __NR_setsockopt = 208 +const __NR_settimeofday = 170 +const __NR_setuid = 146 +const __NR_setxattr = 5 +const __NR_shmat = 196 +const __NR_shmctl = 195 +const __NR_shmdt = 197 +const __NR_shmget = 194 +const __NR_shutdown = 210 +const __NR_sigaltstack = 132 +const __NR_signalfd4 = 74 +const __NR_socket = 198 +const __NR_socketpair = 199 +const __NR_splice = 76 +const __NR_statfs = 43 +const __NR_statx = 291 +const __NR_swapoff = 225 +const __NR_swapon = 224 +const __NR_symlinkat = 36 +const __NR_sync = 81 +const __NR_sync_file_range = 84 +const __NR_syncfs = 267 +const __NR_sysinfo = 179 +const __NR_syslog = 116 +const __NR_tee = 77 +const __NR_tgkill = 131 +const __NR_timer_create = 107 +const __NR_timer_delete = 111 +const __NR_timer_getoverrun = 109 +const __NR_timer_gettime = 108 +const __NR_timer_settime = 110 +const __NR_timerfd_create = 85 +const __NR_timerfd_gettime = 87 +const __NR_timerfd_settime = 86 +const __NR_times = 153 +const __NR_tkill = 130 +const __NR_truncate = 45 +const __NR_umask = 166 +const __NR_umount2 = 39 +const __NR_uname = 160 +const __NR_unlinkat = 35 +const __NR_unshare = 97 +const __NR_userfaultfd = 282 +const __NR_utimensat = 88 +const __NR_vhangup = 58 +const __NR_vmsplice = 75 +const __NR_wait4 = 260 +const __NR_waitid = 95 +const __NR_write = 64 +const __NR_writev = 66 +const __SC_accept = 5 +const __SC_accept4 = 18 +const __SC_bind = 2 +const __SC_connect = 3 +const __SC_getpeername = 7 +const __SC_getsockname = 6 +const __SC_getsockopt = 15 +const __SC_listen = 4 +const __SC_recv = 10 +const __SC_recvfrom = 12 +const __SC_recvmmsg = 19 +const __SC_recvmsg = 17 +const __SC_send = 9 +const __SC_sendmmsg = 20 +const __SC_sendmsg = 16 +const __SC_sendto = 11 +const __SC_setsockopt = 14 +const __SC_shutdown = 13 +const __SC_socket = 1 +const __SC_socketpair = 8 +const libc = 0 + +type Ttime_t = int64 + +type Tsuseconds_t = int64 + +type Ttimeval = struct { + Ftv_sec Ttime_t + Ftv_usec Tsuseconds_t +} + +type Ttimespec = struct { + Ftv_sec Ttime_t + Ftv_nsec int64 +} + +type Tsigset_t = struct { + F__bits [16]uint64 +} + +type t__sigset_t = Tsigset_t + +type Tfd_mask = uint64 + +type Tfd_set = struct { + Ffds_bits [16]uint64 +} + +type Titimerval = struct { + Fit_interval Ttimeval + Fit_value Ttimeval +} + +type Tid_t = uint32 + +type Trlim_t = uint64 + +type Trlimit = struct { + Frlim_cur Trlim_t + Frlim_max Trlim_t +} + +type Trusage = struct { + Fru_utime Ttimeval + Fru_stime Ttimeval + Fru_maxrss int64 + Fru_ixrss int64 + Fru_idrss int64 + Fru_isrss int64 + Fru_minflt int64 + Fru_majflt int64 + Fru_nswap int64 + Fru_inblock int64 + Fru_oublock int64 + Fru_msgsnd int64 + Fru_msgrcv int64 + Fru_nsignals int64 + Fru_nvcsw int64 + Fru_nivcsw int64 + F__reserved [16]int64 +} + +type Tclock_t = int64 + +type Tpthread_t = uintptr + +type Tpthread_attr_t = struct { + F__u struct { + F__vi [0][14]int32 + F__s [0][7]uint64 + F__i [14]int32 + } +} + +type Tstack_t = struct { + Fss_sp uintptr + Fss_flags int32 + Fss_size Tsize_t +} + +type Tsigaltstack = Tstack_t + +type Tmcontext_t = struct { + F__regs [274]float64 +} + +type Tucontext_t = struct { + Fuc_flags uint64 + Fuc_link uintptr + Fuc_stack Tstack_t + Fuc_sigmask Tsigset_t + Fuc_mcontext Tmcontext_t +} + +type t__ucontext = Tucontext_t + +type Tsigval = struct { + Fsival_ptr [0]uintptr + Fsival_int int32 + F__ccgo_pad2 [4]byte +} + +type Tsiginfo_t = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + F__si_fields struct { + F__si_common [0]struct { + F__first struct { + F__timer [0]struct { + Fsi_timerid int32 + Fsi_overrun int32 + } + F__piduid struct { + Fsi_pid Tpid_t + Fsi_uid Tuid_t + } + } + F__second struct { + F__sigchld [0]struct { + Fsi_status int32 + Fsi_utime Tclock_t + Fsi_stime Tclock_t + } + Fsi_value Tsigval + F__ccgo_pad2 [16]byte + } + } + F__sigfault [0]struct { + Fsi_addr uintptr + Fsi_addr_lsb int16 + F__first struct { + Fsi_pkey [0]uint32 + F__addr_bnd struct { + Fsi_lower uintptr + Fsi_upper uintptr + } + } + } + F__sigpoll [0]struct { + Fsi_band int64 + Fsi_fd int32 + } + F__sigsys [0]struct { + Fsi_call_addr uintptr + Fsi_syscall int32 + Fsi_arch uint32 + } + F__pad [112]uint8 + } +} + +type Tsigaction = struct { + F__sa_handler struct { + Fsa_sigaction [0]uintptr + Fsa_handler uintptr + } + Fsa_mask Tsigset_t + Fsa_flags int32 + Fsa_restorer uintptr +} + +type Tsigevent = struct { + Fsigev_value Tsigval + Fsigev_signo int32 + Fsigev_notify int32 + F__sev_fields struct { + Fsigev_notify_thread_id [0]Tpid_t + F__sev_thread [0]struct { + Fsigev_notify_function uintptr + Fsigev_notify_attributes uintptr + } + F__pad [48]uint8 + } +} + +type Tsig_atomic_t = int32 + +type TElf32_Half = uint16 + +type TElf64_Half = uint16 + +type TElf32_Word = uint32 + +type TElf32_Sword = int32 + +type TElf64_Word = uint32 + +type TElf64_Sword = int32 + +type TElf32_Xword = uint64 + +type TElf32_Sxword = int64 + +type TElf64_Xword = uint64 + +type TElf64_Sxword = int64 + +type TElf32_Addr = uint32 + +type TElf64_Addr = uint64 + +type TElf32_Off = uint32 + +type TElf64_Off = uint64 + +type TElf32_Section = uint16 + +type TElf64_Section = uint16 + +type TElf32_Versym = uint16 + +type TElf64_Versym = uint16 + +type TElf32_Ehdr = struct { + Fe_ident [16]uint8 + Fe_type TElf32_Half + Fe_machine TElf32_Half + Fe_version TElf32_Word + Fe_entry TElf32_Addr + Fe_phoff TElf32_Off + Fe_shoff TElf32_Off + Fe_flags TElf32_Word + Fe_ehsize TElf32_Half + Fe_phentsize TElf32_Half + Fe_phnum TElf32_Half + Fe_shentsize TElf32_Half + Fe_shnum TElf32_Half + Fe_shstrndx TElf32_Half +} + +type TElf64_Ehdr = struct { + Fe_ident [16]uint8 + Fe_type TElf64_Half + Fe_machine TElf64_Half + Fe_version TElf64_Word + Fe_entry TElf64_Addr + Fe_phoff TElf64_Off + Fe_shoff TElf64_Off + Fe_flags TElf64_Word + Fe_ehsize TElf64_Half + Fe_phentsize TElf64_Half + Fe_phnum TElf64_Half + Fe_shentsize TElf64_Half + Fe_shnum TElf64_Half + Fe_shstrndx TElf64_Half +} + +type TElf32_Shdr = struct { + Fsh_name TElf32_Word + Fsh_type TElf32_Word + Fsh_flags TElf32_Word + Fsh_addr TElf32_Addr + Fsh_offset TElf32_Off + Fsh_size TElf32_Word + Fsh_link TElf32_Word + Fsh_info TElf32_Word + Fsh_addralign TElf32_Word + Fsh_entsize TElf32_Word +} + +type TElf64_Shdr = struct { + Fsh_name TElf64_Word + Fsh_type TElf64_Word + Fsh_flags TElf64_Xword + Fsh_addr TElf64_Addr + Fsh_offset TElf64_Off + Fsh_size TElf64_Xword + Fsh_link TElf64_Word + Fsh_info TElf64_Word + Fsh_addralign TElf64_Xword + Fsh_entsize TElf64_Xword +} + +type TElf32_Chdr = struct { + Fch_type TElf32_Word + Fch_size TElf32_Word + Fch_addralign TElf32_Word +} + +type TElf64_Chdr = struct { + Fch_type TElf64_Word + Fch_reserved TElf64_Word + Fch_size TElf64_Xword + Fch_addralign TElf64_Xword +} + +type TElf32_Sym = struct { + Fst_name TElf32_Word + Fst_value TElf32_Addr + Fst_size TElf32_Word + Fst_info uint8 + Fst_other uint8 + Fst_shndx TElf32_Section +} + +type TElf64_Sym = struct { + Fst_name TElf64_Word + Fst_info uint8 + Fst_other uint8 + Fst_shndx TElf64_Section + Fst_value TElf64_Addr + Fst_size TElf64_Xword +} + +type TElf32_Syminfo = struct { + Fsi_boundto TElf32_Half + Fsi_flags TElf32_Half +} + +type TElf64_Syminfo = struct { + Fsi_boundto TElf64_Half + Fsi_flags TElf64_Half +} + +type TElf32_Rel = struct { + Fr_offset TElf32_Addr + Fr_info TElf32_Word +} + +type TElf64_Rel = struct { + Fr_offset TElf64_Addr + Fr_info TElf64_Xword +} + +type TElf32_Rela = struct { + Fr_offset TElf32_Addr + Fr_info TElf32_Word + Fr_addend TElf32_Sword +} + +type TElf64_Rela = struct { + Fr_offset TElf64_Addr + Fr_info TElf64_Xword + Fr_addend TElf64_Sxword +} + +type TElf32_Relr = uint32 + +type TElf64_Relr = uint64 + +type TElf32_Phdr = struct { + Fp_type TElf32_Word + Fp_offset TElf32_Off + Fp_vaddr TElf32_Addr + Fp_paddr TElf32_Addr + Fp_filesz TElf32_Word + Fp_memsz TElf32_Word + Fp_flags TElf32_Word + Fp_align TElf32_Word +} + +type TElf64_Phdr = struct { + Fp_type TElf64_Word + Fp_flags TElf64_Word + Fp_offset TElf64_Off + Fp_vaddr TElf64_Addr + Fp_paddr TElf64_Addr + Fp_filesz TElf64_Xword + Fp_memsz TElf64_Xword + Fp_align TElf64_Xword +} + +type TElf32_Dyn = struct { + Fd_tag TElf32_Sword + Fd_un struct { + Fd_ptr [0]TElf32_Addr + Fd_val TElf32_Word + } +} + +type TElf64_Dyn = struct { + Fd_tag TElf64_Sxword + Fd_un struct { + Fd_ptr [0]TElf64_Addr + Fd_val TElf64_Xword + } +} + +type TElf32_Verdef = struct { + Fvd_version TElf32_Half + Fvd_flags TElf32_Half + Fvd_ndx TElf32_Half + Fvd_cnt TElf32_Half + Fvd_hash TElf32_Word + Fvd_aux TElf32_Word + Fvd_next TElf32_Word +} + +type TElf64_Verdef = struct { + Fvd_version TElf64_Half + Fvd_flags TElf64_Half + Fvd_ndx TElf64_Half + Fvd_cnt TElf64_Half + Fvd_hash TElf64_Word + Fvd_aux TElf64_Word + Fvd_next TElf64_Word +} + +type TElf32_Verdaux = struct { + Fvda_name TElf32_Word + Fvda_next TElf32_Word +} + +type TElf64_Verdaux = struct { + Fvda_name TElf64_Word + Fvda_next TElf64_Word +} + +type TElf32_Verneed = struct { + Fvn_version TElf32_Half + Fvn_cnt TElf32_Half + Fvn_file TElf32_Word + Fvn_aux TElf32_Word + Fvn_next TElf32_Word +} + +type TElf64_Verneed = struct { + Fvn_version TElf64_Half + Fvn_cnt TElf64_Half + Fvn_file TElf64_Word + Fvn_aux TElf64_Word + Fvn_next TElf64_Word +} + +type TElf32_Vernaux = struct { + Fvna_hash TElf32_Word + Fvna_flags TElf32_Half + Fvna_other TElf32_Half + Fvna_name TElf32_Word + Fvna_next TElf32_Word +} + +type TElf64_Vernaux = struct { + Fvna_hash TElf64_Word + Fvna_flags TElf64_Half + Fvna_other TElf64_Half + Fvna_name TElf64_Word + Fvna_next TElf64_Word +} + +type TElf32_auxv_t = struct { + Fa_type Tuint32_t + Fa_un struct { + Fa_val Tuint32_t + } +} + +type TElf64_auxv_t = struct { + Fa_type Tuint64_t + Fa_un struct { + Fa_val Tuint64_t + } +} + +type TElf32_Nhdr = struct { + Fn_namesz TElf32_Word + Fn_descsz TElf32_Word + Fn_type TElf32_Word +} + +type TElf64_Nhdr = struct { + Fn_namesz TElf64_Word + Fn_descsz TElf64_Word + Fn_type TElf64_Word +} + +type TElf32_Move = struct { + Fm_value TElf32_Xword + Fm_info TElf32_Word + Fm_poffset TElf32_Word + Fm_repeat TElf32_Half + Fm_stride TElf32_Half +} + +type TElf64_Move = struct { + Fm_value TElf64_Xword + Fm_info TElf64_Xword + Fm_poffset TElf64_Xword + Fm_repeat TElf64_Half + Fm_stride TElf64_Half +} + +type TElf32_gptab = struct { + Fgt_entry [0]struct { + Fgt_g_value TElf32_Word + Fgt_bytes TElf32_Word + } + Fgt_header struct { + Fgt_current_g_value TElf32_Word + Fgt_unused TElf32_Word + } +} + +type TElf32_RegInfo = struct { + Fri_gprmask TElf32_Word + Fri_cprmask [4]TElf32_Word + Fri_gp_value TElf32_Sword +} + +type TElf_Options = struct { + Fkind uint8 + Fsize uint8 + Fsection TElf32_Section + Finfo TElf32_Word +} + +type TElf_Options_Hw = struct { + Fhwp_flags1 TElf32_Word + Fhwp_flags2 TElf32_Word +} + +type TElf32_Lib = struct { + Fl_name TElf32_Word + Fl_time_stamp TElf32_Word + Fl_checksum TElf32_Word + Fl_version TElf32_Word + Fl_flags TElf32_Word +} + +type TElf64_Lib = struct { + Fl_name TElf64_Word + Fl_time_stamp TElf64_Word + Fl_checksum TElf64_Word + Fl_version TElf64_Word + Fl_flags TElf64_Word +} + +type TElf32_Conflict = uint32 + +type TElf_MIPS_ABIFlags_v0 = struct { + Fversion TElf32_Half + Fisa_level uint8 + Fisa_rev uint8 + Fgpr_size uint8 + Fcpr1_size uint8 + Fcpr2_size uint8 + Ffp_abi uint8 + Fisa_ext TElf32_Word + Fases TElf32_Word + Fflags1 TElf32_Word + Fflags2 TElf32_Word +} + +const _Val_GNU_MIPS_ABI_FP_ANY = 0 +const _Val_GNU_MIPS_ABI_FP_DOUBLE = 1 +const _Val_GNU_MIPS_ABI_FP_SINGLE = 2 +const _Val_GNU_MIPS_ABI_FP_SOFT = 3 +const _Val_GNU_MIPS_ABI_FP_OLD_64 = 4 +const _Val_GNU_MIPS_ABI_FP_XX = 5 +const _Val_GNU_MIPS_ABI_FP_64 = 6 +const _Val_GNU_MIPS_ABI_FP_64A = 7 +const _Val_GNU_MIPS_ABI_FP_MAX = 7 + +type Tsyscall_arg_t = int64 + +type Twchar_t = uint32 + +type Tdiv_t = struct { + Fquot int32 + Frem int32 +} + +type Tldiv_t = struct { + Fquot int64 + Frem int64 +} + +type Tlldiv_t = struct { + Fquot int64 + Frem int64 +} + +type t__locale_struct = struct { + Fcat [6]uintptr +} + +type Ttls_module = struct { + Fnext uintptr + Fimage uintptr + Flen1 Tsize_t + Fsize Tsize_t + Falign Tsize_t + Foffset Tsize_t +} + +type t__libc = struct { + Fcan_do_threads uint8 + Fthreaded uint8 + Fsecure uint8 + Fneed_locks int8 + Fthreads_minus_1 int32 + Fauxv uintptr + Ftls_head uintptr + Ftls_size Tsize_t + Ftls_align Tsize_t + Ftls_cnt Tsize_t + Fpage_size Tsize_t + Fglobal_locale t__locale_struct +} + +func Xsysconf(tls *TLS, name int32) (r int64) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(512) + defer tls.Free(512) + var cnt, i, v3 int32 + var mem, v1 uint64 + var val int64 + var v5 uintptr + var _ /* lim at bp+0 */ Trlimit + var _ /* set at bp+16 */ [128]uint8 + var _ /* si at bp+144 */ Tsysinfo + _, _, _, _, _, _, _ = cnt, i, mem, val, v1, v3, v5 + if Uint64FromInt32(name) >= Uint64FromInt64(502)/Uint64FromInt64(2) || !(_values1[name] != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) + } else { + if int32(_values1[name]) >= -int32(1) { + return int64(_values1[name]) + } else { + if int32(_values1[name]) < -int32(256) { + Xgetrlimit(tls, int32(_values1[name])&int32(16383), bp) + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur == ^Uint64FromUint64(0) { + return int64(-int32(1)) + } + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur > uint64(0x7fffffffffffffff) { + v1 = uint64(0x7fffffffffffffff) + } else { + v1 = (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur + } + return Int64FromUint64(v1) + } + } + } + switch Int32FromUint8(Uint8FromInt16(_values1[name])) { + case (-Int32FromInt32(256) | Int32FromInt32(1)) & Int32FromInt32(255): + return int64(200809) + case (-Int32FromInt32(256) | Int32FromInt32(2)) & Int32FromInt32(255): + return int64(ARG_MAX) + case (-Int32FromInt32(256) | Int32FromInt32(3)) & Int32FromInt32(255): + return int64(MQ_PRIO_MAX) + case (-Int32FromInt32(256) | Int32FromInt32(4)) & Int32FromInt32(255): + return Int64FromUint64(X__libc.Fpage_size) + case (-Int32FromInt32(256) | Int32FromInt32(5)) & Int32FromInt32(255): + return int64(SEM_VALUE_MAX) + case (-Int32FromInt32(256) | Int32FromInt32(11)) & Int32FromInt32(255): + return int64(DELAYTIMER_MAX) + case (-Int32FromInt32(256) | Int32FromInt32(6)) & Int32FromInt32(255): + fallthrough + case (-Int32FromInt32(256) | Int32FromInt32(7)) & Int32FromInt32(255): + **(**[128]uint8)(__ccgo_up(bp + 16)) = [128]uint8{ + 0: uint8(1), + } + X__syscall3(tls, int64(SYS_sched_getaffinity), int64(Int32FromInt32(0)), Int64FromUint64(Uint64FromInt64(128)), int64(bp+16)) + v3 = Int32FromInt32(0) + cnt = v3 + i = v3 + for { + if !(Uint64FromInt32(i) < uint64(128)) { + break + } + for { + if !((**(**[128]uint8)(__ccgo_up(bp + 16)))[i] != 0) { + break + } + goto _4 + _4: + ; + v5 = bp + 16 + uintptr(i) + *(*uint8)(unsafe.Pointer(v5)) = uint8(int32(*(*uint8)(unsafe.Pointer(v5))) & (Int32FromUint8((**(**[128]uint8)(__ccgo_up(bp + 16)))[i]) - Int32FromInt32(1))) + cnt = cnt + 1 + } + goto _2 + _2: + ; + i = i + 1 + } + return int64(cnt) + case (-Int32FromInt32(256) | Int32FromInt32(8)) & Int32FromInt32(255): + fallthrough + case (-Int32FromInt32(256) | Int32FromInt32(9)) & Int32FromInt32(255): + X__lsysinfo(tls, bp+144) + if !((**(**Tsysinfo)(__ccgo_up(bp + 144))).Fmem_unit != 0) { + (**(**Tsysinfo)(__ccgo_up(bp + 144))).Fmem_unit = uint32(1) + } + if name == int32(_SC_PHYS_PAGES) { + mem = uint64((**(**Tsysinfo)(__ccgo_up(bp + 144))).Ftotalram) + } else { + mem = uint64((**(**Tsysinfo)(__ccgo_up(bp + 144))).Ffreeram + (**(**Tsysinfo)(__ccgo_up(bp + 144))).Fbufferram) + } + mem = mem * uint64((**(**Tsysinfo)(__ccgo_up(bp + 144))).Fmem_unit) + mem = mem / X__libc.Fpage_size + if mem > uint64(0x7fffffffffffffff) { + v1 = uint64(0x7fffffffffffffff) + } else { + v1 = mem + } + return Int64FromUint64(v1) + case (-Int32FromInt32(256) | Int32FromInt32(12)) & Int32FromInt32(255): + fallthrough + case (-Int32FromInt32(256) | Int32FromInt32(13)) & Int32FromInt32(255): + val = Int64FromUint64(X__getauxval(tls, uint64(AT_MINSIGSTKSZ))) + if val < int64(MINSIGSTKSZ) { + val = int64(MINSIGSTKSZ) + } + if int32(_values1[name]) == -Int32FromInt32(256)|Int32FromInt32(13) { + val = val + int64(Int32FromInt32(SIGSTKSZ)-Int32FromInt32(MINSIGSTKSZ)) + } + return val + case (-Int32FromInt32(256) | Int32FromInt32(10)) & Int32FromInt32(255): + return 0 + } + return int64(_values1[name]) +} + +var _values1 = [251]int16{ + 0: int16(-Int32FromInt32(256) | Int32FromInt32(2)), + 1: int16(-Int32FromInt32(32768) | Int32FromInt32(RLIMIT_NPROC)), + 2: int16(100), + 3: int16(32), + 4: int16(-Int32FromInt32(32768) | Int32FromInt32(RLIMIT_NOFILE)), + 5: int16(-int32(1)), + 6: int16(TZNAME_MAX), + 7: int16(1), + 8: int16(1), + 9: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 10: int16(-int32(1)), + 11: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 12: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 13: int16(-int32(1)), + 14: int16(-int32(1)), + 15: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 16: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 17: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 18: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 19: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 20: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 21: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 22: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 23: int16(-int32(1)), + 24: int16(-int32(1)), + 25: int16(-Int32FromInt32(256) | Int32FromInt32(10)), + 26: int16(-Int32FromInt32(256) | Int32FromInt32(11)), + 27: int16(-int32(1)), + 28: int16(-Int32FromInt32(256) | Int32FromInt32(3)), + 29: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 30: int16(-Int32FromInt32(256) | Int32FromInt32(4)), + 31: int16(Int32FromInt32(_NSIG) - Int32FromInt32(1) - Int32FromInt32(31) - Int32FromInt32(3)), + 32: int16(SEM_NSEMS_MAX), + 33: int16(-Int32FromInt32(256) | Int32FromInt32(5)), + 34: int16(-int32(1)), + 35: int16(-int32(1)), + 36: int16(_POSIX2_BC_BASE_MAX), + 37: int16(_POSIX2_BC_DIM_MAX), + 38: int16(_POSIX2_BC_SCALE_MAX), + 39: int16(_POSIX2_BC_STRING_MAX), + 40: int16(COLL_WEIGHTS_MAX), + 42: int16(-int32(1)), + 43: int16(-int32(1)), + 44: int16(RE_DUP_MAX), + 46: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 47: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 48: int16(-int32(1)), + 49: int16(-int32(1)), + 50: int16(-int32(1)), + 51: int16(-int32(1)), + 52: int16(-int32(1)), + 60: int16(IOV_MAX), + 67: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 68: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 69: int16(-int32(1)), + 70: int16(-int32(1)), + 71: int16(256), + 72: int16(TTY_NAME_MAX), + 73: int16(PTHREAD_DESTRUCTOR_ITERATIONS), + 74: int16(PTHREAD_KEYS_MAX), + 75: int16(PTHREAD_STACK_MIN), + 76: int16(-int32(1)), + 77: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 78: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 79: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 80: int16(-int32(1)), + 81: int16(-int32(1)), + 82: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 83: int16(-Int32FromInt32(256) | Int32FromInt32(6)), + 84: int16(-Int32FromInt32(256) | Int32FromInt32(7)), + 85: int16(-Int32FromInt32(256) | Int32FromInt32(8)), + 86: int16(-Int32FromInt32(256) | Int32FromInt32(9)), + 87: int16(-int32(1)), + 88: int16(-int32(1)), + 89: int16(_XOPEN_VERSION), + 90: int16(_XOPEN_VERSION), + 91: int16(1), + 92: int16(-int32(1)), + 93: int16(1), + 94: int16(1), + 95: int16(-int32(1)), + 97: int16(-int32(1)), + 98: int16(-int32(1)), + 99: int16(-int32(1)), + 100: int16(-int32(1)), + 109: int16(NZERO), + 125: int16(-int32(1)), + 126: int16(-int32(1)), + 127: int16(1), + 128: int16(-int32(1)), + 129: int16(-int32(1)), + 130: int16(-int32(1)), + 131: int16(-int32(1)), + 132: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 133: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 137: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 138: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 139: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 149: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 153: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 154: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 155: int16(1), + 157: int16(1), + 159: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 160: int16(-int32(1)), + 161: int16(-int32(1)), + 164: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 165: int16(-int32(1)), + 168: int16(-int32(1)), + 169: int16(-int32(1)), + 170: int16(-int32(1)), + 171: int16(-int32(1)), + 172: int16(-int32(1)), + 173: int16(SYMLOOP_MAX), + 174: int16(-Int32FromInt32(256) | Int32FromInt32(10)), + 175: int16(-int32(1)), + 176: int16(-int32(1)), + 177: int16(-int32(1)), + 178: int16(1), + 179: int16(-int32(1)), + 180: int16(HOST_NAME_MAX), + 181: int16(-int32(1)), + 182: int16(-int32(1)), + 183: int16(-int32(1)), + 184: int16(-int32(1)), + 235: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 236: int16(-Int32FromInt32(256) | Int32FromInt32(1)), + 237: int16(-int32(1)), + 238: int16(-int32(1)), + 239: int16(1), + 240: int16(-int32(1)), + 241: int16(-int32(1)), + 242: int16(-int32(1)), + 243: int16(-int32(1)), + 244: int16(-int32(1)), + 245: int16(-int32(1)), + 246: int16(-Int32FromInt32(256) | Int32FromInt32(10)), + 247: int16(-int32(1)), + 248: int16(-int32(1)), + 249: int16(-Int32FromInt32(256) | Int32FromInt32(12)), + 250: int16(-Int32FromInt32(256) | Int32FromInt32(13)), +} + +type Tcrypt_data = struct { + Finitialized int32 + F__buf [256]uint8 +} + +func Xcrypt(tls *TLS, key uintptr, salt uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v salt=%v, (%v:)", tls, key, salt, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__crypt_r(tls, key, salt, uintptr(unsafe.Pointer(&_buf))) +} + +/* This buffer is sufficiently large for all + * currently-supported hash types. It needs to be updated if + * longer hashes are added. The cast to struct crypt_data * is + * purely to meet the public API requirements of the crypt_r + * function; the implementation of crypt_r uses the object + * purely as a char buffer. */ +var _buf [128]uint8 + +const BF_N = 16 + +type Tlocale_t = uintptr + +type TBF_word = uint32 + +type TBF_word_signed = int32 + +/* Number of Blowfish rounds, this is also hardcoded into a few places */ + +type TBF_key = [18]TBF_word + +type TBF_ctx = struct { + FPS [0][1042]TBF_word + Fs struct { + FP TBF_key + FS [4][256]TBF_word + } +} + +// C documentation +// +// /* +// * Magic IV for 64 Blowfish encryptions that we do at the end. +// * The string is "OrpheanBeholderScryDoubt" on big-endian. +// */ +var _BF_magic_w = [6]TBF_word{ + 0: uint32(0x4F727068), + 1: uint32(0x65616E42), + 2: uint32(0x65686F6C), + 3: uint32(0x64657253), + 4: uint32(0x63727944), + 5: uint32(0x6F756274), +} + +// C documentation +// +// /* +// * P-box and S-box tables initialized with digits of Pi. +// */ +var _BF_init_state = *(*TBF_ctx)(unsafe.Pointer(&struct { + FP TBF_key + FS [4][256]TBF_word +}{ + FP: TBF_key{ + 0: uint32(0x243f6a88), + 1: uint32(0x85a308d3), + 2: uint32(0x13198a2e), + 3: uint32(0x03707344), + 4: uint32(0xa4093822), + 5: uint32(0x299f31d0), + 6: uint32(0x082efa98), + 7: uint32(0xec4e6c89), + 8: uint32(0x452821e6), + 9: uint32(0x38d01377), + 10: uint32(0xbe5466cf), + 11: uint32(0x34e90c6c), + 12: uint32(0xc0ac29b7), + 13: uint32(0xc97c50dd), + 14: uint32(0x3f84d5b5), + 15: uint32(0xb5470917), + 16: uint32(0x9216d5d9), + 17: uint32(0x8979fb1b), + }, + FS: [4][256]TBF_word{ + 0: { + 0: uint32(0xd1310ba6), + 1: uint32(0x98dfb5ac), + 2: uint32(0x2ffd72db), + 3: uint32(0xd01adfb7), + 4: uint32(0xb8e1afed), + 5: uint32(0x6a267e96), + 6: uint32(0xba7c9045), + 7: uint32(0xf12c7f99), + 8: uint32(0x24a19947), + 9: uint32(0xb3916cf7), + 10: uint32(0x0801f2e2), + 11: uint32(0x858efc16), + 12: uint32(0x636920d8), + 13: uint32(0x71574e69), + 14: uint32(0xa458fea3), + 15: uint32(0xf4933d7e), + 16: uint32(0x0d95748f), + 17: uint32(0x728eb658), + 18: uint32(0x718bcd58), + 19: uint32(0x82154aee), + 20: uint32(0x7b54a41d), + 21: uint32(0xc25a59b5), + 22: uint32(0x9c30d539), + 23: uint32(0x2af26013), + 24: uint32(0xc5d1b023), + 25: uint32(0x286085f0), + 26: uint32(0xca417918), + 27: uint32(0xb8db38ef), + 28: uint32(0x8e79dcb0), + 29: uint32(0x603a180e), + 30: uint32(0x6c9e0e8b), + 31: uint32(0xb01e8a3e), + 32: uint32(0xd71577c1), + 33: uint32(0xbd314b27), + 34: uint32(0x78af2fda), + 35: uint32(0x55605c60), + 36: uint32(0xe65525f3), + 37: uint32(0xaa55ab94), + 38: uint32(0x57489862), + 39: uint32(0x63e81440), + 40: uint32(0x55ca396a), + 41: uint32(0x2aab10b6), + 42: uint32(0xb4cc5c34), + 43: uint32(0x1141e8ce), + 44: uint32(0xa15486af), + 45: uint32(0x7c72e993), + 46: uint32(0xb3ee1411), + 47: uint32(0x636fbc2a), + 48: uint32(0x2ba9c55d), + 49: uint32(0x741831f6), + 50: uint32(0xce5c3e16), + 51: uint32(0x9b87931e), + 52: uint32(0xafd6ba33), + 53: uint32(0x6c24cf5c), + 54: uint32(0x7a325381), + 55: uint32(0x28958677), + 56: uint32(0x3b8f4898), + 57: uint32(0x6b4bb9af), + 58: uint32(0xc4bfe81b), + 59: uint32(0x66282193), + 60: uint32(0x61d809cc), + 61: uint32(0xfb21a991), + 62: uint32(0x487cac60), + 63: uint32(0x5dec8032), + 64: uint32(0xef845d5d), + 65: uint32(0xe98575b1), + 66: uint32(0xdc262302), + 67: uint32(0xeb651b88), + 68: uint32(0x23893e81), + 69: uint32(0xd396acc5), + 70: uint32(0x0f6d6ff3), + 71: uint32(0x83f44239), + 72: uint32(0x2e0b4482), + 73: uint32(0xa4842004), + 74: uint32(0x69c8f04a), + 75: uint32(0x9e1f9b5e), + 76: uint32(0x21c66842), + 77: uint32(0xf6e96c9a), + 78: uint32(0x670c9c61), + 79: uint32(0xabd388f0), + 80: uint32(0x6a51a0d2), + 81: uint32(0xd8542f68), + 82: uint32(0x960fa728), + 83: uint32(0xab5133a3), + 84: uint32(0x6eef0b6c), + 85: uint32(0x137a3be4), + 86: uint32(0xba3bf050), + 87: uint32(0x7efb2a98), + 88: uint32(0xa1f1651d), + 89: uint32(0x39af0176), + 90: uint32(0x66ca593e), + 91: uint32(0x82430e88), + 92: uint32(0x8cee8619), + 93: uint32(0x456f9fb4), + 94: uint32(0x7d84a5c3), + 95: uint32(0x3b8b5ebe), + 96: uint32(0xe06f75d8), + 97: uint32(0x85c12073), + 98: uint32(0x401a449f), + 99: uint32(0x56c16aa6), + 100: uint32(0x4ed3aa62), + 101: uint32(0x363f7706), + 102: uint32(0x1bfedf72), + 103: uint32(0x429b023d), + 104: uint32(0x37d0d724), + 105: uint32(0xd00a1248), + 106: uint32(0xdb0fead3), + 107: uint32(0x49f1c09b), + 108: uint32(0x075372c9), + 109: uint32(0x80991b7b), + 110: uint32(0x25d479d8), + 111: uint32(0xf6e8def7), + 112: uint32(0xe3fe501a), + 113: uint32(0xb6794c3b), + 114: uint32(0x976ce0bd), + 115: uint32(0x04c006ba), + 116: uint32(0xc1a94fb6), + 117: uint32(0x409f60c4), + 118: uint32(0x5e5c9ec2), + 119: uint32(0x196a2463), + 120: uint32(0x68fb6faf), + 121: uint32(0x3e6c53b5), + 122: uint32(0x1339b2eb), + 123: uint32(0x3b52ec6f), + 124: uint32(0x6dfc511f), + 125: uint32(0x9b30952c), + 126: uint32(0xcc814544), + 127: uint32(0xaf5ebd09), + 128: uint32(0xbee3d004), + 129: uint32(0xde334afd), + 130: uint32(0x660f2807), + 131: uint32(0x192e4bb3), + 132: uint32(0xc0cba857), + 133: uint32(0x45c8740f), + 134: uint32(0xd20b5f39), + 135: uint32(0xb9d3fbdb), + 136: uint32(0x5579c0bd), + 137: uint32(0x1a60320a), + 138: uint32(0xd6a100c6), + 139: uint32(0x402c7279), + 140: uint32(0x679f25fe), + 141: uint32(0xfb1fa3cc), + 142: uint32(0x8ea5e9f8), + 143: uint32(0xdb3222f8), + 144: uint32(0x3c7516df), + 145: uint32(0xfd616b15), + 146: uint32(0x2f501ec8), + 147: uint32(0xad0552ab), + 148: uint32(0x323db5fa), + 149: uint32(0xfd238760), + 150: uint32(0x53317b48), + 151: uint32(0x3e00df82), + 152: uint32(0x9e5c57bb), + 153: uint32(0xca6f8ca0), + 154: uint32(0x1a87562e), + 155: uint32(0xdf1769db), + 156: uint32(0xd542a8f6), + 157: uint32(0x287effc3), + 158: uint32(0xac6732c6), + 159: uint32(0x8c4f5573), + 160: uint32(0x695b27b0), + 161: uint32(0xbbca58c8), + 162: uint32(0xe1ffa35d), + 163: uint32(0xb8f011a0), + 164: uint32(0x10fa3d98), + 165: uint32(0xfd2183b8), + 166: uint32(0x4afcb56c), + 167: uint32(0x2dd1d35b), + 168: uint32(0x9a53e479), + 169: uint32(0xb6f84565), + 170: uint32(0xd28e49bc), + 171: uint32(0x4bfb9790), + 172: uint32(0xe1ddf2da), + 173: uint32(0xa4cb7e33), + 174: uint32(0x62fb1341), + 175: uint32(0xcee4c6e8), + 176: uint32(0xef20cada), + 177: uint32(0x36774c01), + 178: uint32(0xd07e9efe), + 179: uint32(0x2bf11fb4), + 180: uint32(0x95dbda4d), + 181: uint32(0xae909198), + 182: uint32(0xeaad8e71), + 183: uint32(0x6b93d5a0), + 184: uint32(0xd08ed1d0), + 185: uint32(0xafc725e0), + 186: uint32(0x8e3c5b2f), + 187: uint32(0x8e7594b7), + 188: uint32(0x8ff6e2fb), + 189: uint32(0xf2122b64), + 190: uint32(0x8888b812), + 191: uint32(0x900df01c), + 192: uint32(0x4fad5ea0), + 193: uint32(0x688fc31c), + 194: uint32(0xd1cff191), + 195: uint32(0xb3a8c1ad), + 196: uint32(0x2f2f2218), + 197: uint32(0xbe0e1777), + 198: uint32(0xea752dfe), + 199: uint32(0x8b021fa1), + 200: uint32(0xe5a0cc0f), + 201: uint32(0xb56f74e8), + 202: uint32(0x18acf3d6), + 203: uint32(0xce89e299), + 204: uint32(0xb4a84fe0), + 205: uint32(0xfd13e0b7), + 206: uint32(0x7cc43b81), + 207: uint32(0xd2ada8d9), + 208: uint32(0x165fa266), + 209: uint32(0x80957705), + 210: uint32(0x93cc7314), + 211: uint32(0x211a1477), + 212: uint32(0xe6ad2065), + 213: uint32(0x77b5fa86), + 214: uint32(0xc75442f5), + 215: uint32(0xfb9d35cf), + 216: uint32(0xebcdaf0c), + 217: uint32(0x7b3e89a0), + 218: uint32(0xd6411bd3), + 219: uint32(0xae1e7e49), + 220: uint32(0x00250e2d), + 221: uint32(0x2071b35e), + 222: uint32(0x226800bb), + 223: uint32(0x57b8e0af), + 224: uint32(0x2464369b), + 225: uint32(0xf009b91e), + 226: uint32(0x5563911d), + 227: uint32(0x59dfa6aa), + 228: uint32(0x78c14389), + 229: uint32(0xd95a537f), + 230: uint32(0x207d5ba2), + 231: uint32(0x02e5b9c5), + 232: uint32(0x83260376), + 233: uint32(0x6295cfa9), + 234: uint32(0x11c81968), + 235: uint32(0x4e734a41), + 236: uint32(0xb3472dca), + 237: uint32(0x7b14a94a), + 238: uint32(0x1b510052), + 239: uint32(0x9a532915), + 240: uint32(0xd60f573f), + 241: uint32(0xbc9bc6e4), + 242: uint32(0x2b60a476), + 243: uint32(0x81e67400), + 244: uint32(0x08ba6fb5), + 245: uint32(0x571be91f), + 246: uint32(0xf296ec6b), + 247: uint32(0x2a0dd915), + 248: uint32(0xb6636521), + 249: uint32(0xe7b9f9b6), + 250: uint32(0xff34052e), + 251: uint32(0xc5855664), + 252: uint32(0x53b02d5d), + 253: uint32(0xa99f8fa1), + 254: uint32(0x08ba4799), + 255: uint32(0x6e85076a), + }, + 1: { + 0: uint32(0x4b7a70e9), + 1: uint32(0xb5b32944), + 2: uint32(0xdb75092e), + 3: uint32(0xc4192623), + 4: uint32(0xad6ea6b0), + 5: uint32(0x49a7df7d), + 6: uint32(0x9cee60b8), + 7: uint32(0x8fedb266), + 8: uint32(0xecaa8c71), + 9: uint32(0x699a17ff), + 10: uint32(0x5664526c), + 11: uint32(0xc2b19ee1), + 12: uint32(0x193602a5), + 13: uint32(0x75094c29), + 14: uint32(0xa0591340), + 15: uint32(0xe4183a3e), + 16: uint32(0x3f54989a), + 17: uint32(0x5b429d65), + 18: uint32(0x6b8fe4d6), + 19: uint32(0x99f73fd6), + 20: uint32(0xa1d29c07), + 21: uint32(0xefe830f5), + 22: uint32(0x4d2d38e6), + 23: uint32(0xf0255dc1), + 24: uint32(0x4cdd2086), + 25: uint32(0x8470eb26), + 26: uint32(0x6382e9c6), + 27: uint32(0x021ecc5e), + 28: uint32(0x09686b3f), + 29: uint32(0x3ebaefc9), + 30: uint32(0x3c971814), + 31: uint32(0x6b6a70a1), + 32: uint32(0x687f3584), + 33: uint32(0x52a0e286), + 34: uint32(0xb79c5305), + 35: uint32(0xaa500737), + 36: uint32(0x3e07841c), + 37: uint32(0x7fdeae5c), + 38: uint32(0x8e7d44ec), + 39: uint32(0x5716f2b8), + 40: uint32(0xb03ada37), + 41: uint32(0xf0500c0d), + 42: uint32(0xf01c1f04), + 43: uint32(0x0200b3ff), + 44: uint32(0xae0cf51a), + 45: uint32(0x3cb574b2), + 46: uint32(0x25837a58), + 47: uint32(0xdc0921bd), + 48: uint32(0xd19113f9), + 49: uint32(0x7ca92ff6), + 50: uint32(0x94324773), + 51: uint32(0x22f54701), + 52: uint32(0x3ae5e581), + 53: uint32(0x37c2dadc), + 54: uint32(0xc8b57634), + 55: uint32(0x9af3dda7), + 56: uint32(0xa9446146), + 57: uint32(0x0fd0030e), + 58: uint32(0xecc8c73e), + 59: uint32(0xa4751e41), + 60: uint32(0xe238cd99), + 61: uint32(0x3bea0e2f), + 62: uint32(0x3280bba1), + 63: uint32(0x183eb331), + 64: uint32(0x4e548b38), + 65: uint32(0x4f6db908), + 66: uint32(0x6f420d03), + 67: uint32(0xf60a04bf), + 68: uint32(0x2cb81290), + 69: uint32(0x24977c79), + 70: uint32(0x5679b072), + 71: uint32(0xbcaf89af), + 72: uint32(0xde9a771f), + 73: uint32(0xd9930810), + 74: uint32(0xb38bae12), + 75: uint32(0xdccf3f2e), + 76: uint32(0x5512721f), + 77: uint32(0x2e6b7124), + 78: uint32(0x501adde6), + 79: uint32(0x9f84cd87), + 80: uint32(0x7a584718), + 81: uint32(0x7408da17), + 82: uint32(0xbc9f9abc), + 83: uint32(0xe94b7d8c), + 84: uint32(0xec7aec3a), + 85: uint32(0xdb851dfa), + 86: uint32(0x63094366), + 87: uint32(0xc464c3d2), + 88: uint32(0xef1c1847), + 89: uint32(0x3215d908), + 90: uint32(0xdd433b37), + 91: uint32(0x24c2ba16), + 92: uint32(0x12a14d43), + 93: uint32(0x2a65c451), + 94: uint32(0x50940002), + 95: uint32(0x133ae4dd), + 96: uint32(0x71dff89e), + 97: uint32(0x10314e55), + 98: uint32(0x81ac77d6), + 99: uint32(0x5f11199b), + 100: uint32(0x043556f1), + 101: uint32(0xd7a3c76b), + 102: uint32(0x3c11183b), + 103: uint32(0x5924a509), + 104: uint32(0xf28fe6ed), + 105: uint32(0x97f1fbfa), + 106: uint32(0x9ebabf2c), + 107: uint32(0x1e153c6e), + 108: uint32(0x86e34570), + 109: uint32(0xeae96fb1), + 110: uint32(0x860e5e0a), + 111: uint32(0x5a3e2ab3), + 112: uint32(0x771fe71c), + 113: uint32(0x4e3d06fa), + 114: uint32(0x2965dcb9), + 115: uint32(0x99e71d0f), + 116: uint32(0x803e89d6), + 117: uint32(0x5266c825), + 118: uint32(0x2e4cc978), + 119: uint32(0x9c10b36a), + 120: uint32(0xc6150eba), + 121: uint32(0x94e2ea78), + 122: uint32(0xa5fc3c53), + 123: uint32(0x1e0a2df4), + 124: uint32(0xf2f74ea7), + 125: uint32(0x361d2b3d), + 126: uint32(0x1939260f), + 127: uint32(0x19c27960), + 128: uint32(0x5223a708), + 129: uint32(0xf71312b6), + 130: uint32(0xebadfe6e), + 131: uint32(0xeac31f66), + 132: uint32(0xe3bc4595), + 133: uint32(0xa67bc883), + 134: uint32(0xb17f37d1), + 135: uint32(0x018cff28), + 136: uint32(0xc332ddef), + 137: uint32(0xbe6c5aa5), + 138: uint32(0x65582185), + 139: uint32(0x68ab9802), + 140: uint32(0xeecea50f), + 141: uint32(0xdb2f953b), + 142: uint32(0x2aef7dad), + 143: uint32(0x5b6e2f84), + 144: uint32(0x1521b628), + 145: uint32(0x29076170), + 146: uint32(0xecdd4775), + 147: uint32(0x619f1510), + 148: uint32(0x13cca830), + 149: uint32(0xeb61bd96), + 150: uint32(0x0334fe1e), + 151: uint32(0xaa0363cf), + 152: uint32(0xb5735c90), + 153: uint32(0x4c70a239), + 154: uint32(0xd59e9e0b), + 155: uint32(0xcbaade14), + 156: uint32(0xeecc86bc), + 157: uint32(0x60622ca7), + 158: uint32(0x9cab5cab), + 159: uint32(0xb2f3846e), + 160: uint32(0x648b1eaf), + 161: uint32(0x19bdf0ca), + 162: uint32(0xa02369b9), + 163: uint32(0x655abb50), + 164: uint32(0x40685a32), + 165: uint32(0x3c2ab4b3), + 166: uint32(0x319ee9d5), + 167: uint32(0xc021b8f7), + 168: uint32(0x9b540b19), + 169: uint32(0x875fa099), + 170: uint32(0x95f7997e), + 171: uint32(0x623d7da8), + 172: uint32(0xf837889a), + 173: uint32(0x97e32d77), + 174: uint32(0x11ed935f), + 175: uint32(0x16681281), + 176: uint32(0x0e358829), + 177: uint32(0xc7e61fd6), + 178: uint32(0x96dedfa1), + 179: uint32(0x7858ba99), + 180: uint32(0x57f584a5), + 181: uint32(0x1b227263), + 182: uint32(0x9b83c3ff), + 183: uint32(0x1ac24696), + 184: uint32(0xcdb30aeb), + 185: uint32(0x532e3054), + 186: uint32(0x8fd948e4), + 187: uint32(0x6dbc3128), + 188: uint32(0x58ebf2ef), + 189: uint32(0x34c6ffea), + 190: uint32(0xfe28ed61), + 191: uint32(0xee7c3c73), + 192: uint32(0x5d4a14d9), + 193: uint32(0xe864b7e3), + 194: uint32(0x42105d14), + 195: uint32(0x203e13e0), + 196: uint32(0x45eee2b6), + 197: uint32(0xa3aaabea), + 198: uint32(0xdb6c4f15), + 199: uint32(0xfacb4fd0), + 200: uint32(0xc742f442), + 201: uint32(0xef6abbb5), + 202: uint32(0x654f3b1d), + 203: uint32(0x41cd2105), + 204: uint32(0xd81e799e), + 205: uint32(0x86854dc7), + 206: uint32(0xe44b476a), + 207: uint32(0x3d816250), + 208: uint32(0xcf62a1f2), + 209: uint32(0x5b8d2646), + 210: uint32(0xfc8883a0), + 211: uint32(0xc1c7b6a3), + 212: uint32(0x7f1524c3), + 213: uint32(0x69cb7492), + 214: uint32(0x47848a0b), + 215: uint32(0x5692b285), + 216: uint32(0x095bbf00), + 217: uint32(0xad19489d), + 218: uint32(0x1462b174), + 219: uint32(0x23820e00), + 220: uint32(0x58428d2a), + 221: uint32(0x0c55f5ea), + 222: uint32(0x1dadf43e), + 223: uint32(0x233f7061), + 224: uint32(0x3372f092), + 225: uint32(0x8d937e41), + 226: uint32(0xd65fecf1), + 227: uint32(0x6c223bdb), + 228: uint32(0x7cde3759), + 229: uint32(0xcbee7460), + 230: uint32(0x4085f2a7), + 231: uint32(0xce77326e), + 232: uint32(0xa6078084), + 233: uint32(0x19f8509e), + 234: uint32(0xe8efd855), + 235: uint32(0x61d99735), + 236: uint32(0xa969a7aa), + 237: uint32(0xc50c06c2), + 238: uint32(0x5a04abfc), + 239: uint32(0x800bcadc), + 240: uint32(0x9e447a2e), + 241: uint32(0xc3453484), + 242: uint32(0xfdd56705), + 243: uint32(0x0e1e9ec9), + 244: uint32(0xdb73dbd3), + 245: uint32(0x105588cd), + 246: uint32(0x675fda79), + 247: uint32(0xe3674340), + 248: uint32(0xc5c43465), + 249: uint32(0x713e38d8), + 250: uint32(0x3d28f89e), + 251: uint32(0xf16dff20), + 252: uint32(0x153e21e7), + 253: uint32(0x8fb03d4a), + 254: uint32(0xe6e39f2b), + 255: uint32(0xdb83adf7), + }, + 2: { + 0: uint32(0xe93d5a68), + 1: uint32(0x948140f7), + 2: uint32(0xf64c261c), + 3: uint32(0x94692934), + 4: uint32(0x411520f7), + 5: uint32(0x7602d4f7), + 6: uint32(0xbcf46b2e), + 7: uint32(0xd4a20068), + 8: uint32(0xd4082471), + 9: uint32(0x3320f46a), + 10: uint32(0x43b7d4b7), + 11: uint32(0x500061af), + 12: uint32(0x1e39f62e), + 13: uint32(0x97244546), + 14: uint32(0x14214f74), + 15: uint32(0xbf8b8840), + 16: uint32(0x4d95fc1d), + 17: uint32(0x96b591af), + 18: uint32(0x70f4ddd3), + 19: uint32(0x66a02f45), + 20: uint32(0xbfbc09ec), + 21: uint32(0x03bd9785), + 22: uint32(0x7fac6dd0), + 23: uint32(0x31cb8504), + 24: uint32(0x96eb27b3), + 25: uint32(0x55fd3941), + 26: uint32(0xda2547e6), + 27: uint32(0xabca0a9a), + 28: uint32(0x28507825), + 29: uint32(0x530429f4), + 30: uint32(0x0a2c86da), + 31: uint32(0xe9b66dfb), + 32: uint32(0x68dc1462), + 33: uint32(0xd7486900), + 34: uint32(0x680ec0a4), + 35: uint32(0x27a18dee), + 36: uint32(0x4f3ffea2), + 37: uint32(0xe887ad8c), + 38: uint32(0xb58ce006), + 39: uint32(0x7af4d6b6), + 40: uint32(0xaace1e7c), + 41: uint32(0xd3375fec), + 42: uint32(0xce78a399), + 43: uint32(0x406b2a42), + 44: uint32(0x20fe9e35), + 45: uint32(0xd9f385b9), + 46: uint32(0xee39d7ab), + 47: uint32(0x3b124e8b), + 48: uint32(0x1dc9faf7), + 49: uint32(0x4b6d1856), + 50: uint32(0x26a36631), + 51: uint32(0xeae397b2), + 52: uint32(0x3a6efa74), + 53: uint32(0xdd5b4332), + 54: uint32(0x6841e7f7), + 55: uint32(0xca7820fb), + 56: uint32(0xfb0af54e), + 57: uint32(0xd8feb397), + 58: uint32(0x454056ac), + 59: uint32(0xba489527), + 60: uint32(0x55533a3a), + 61: uint32(0x20838d87), + 62: uint32(0xfe6ba9b7), + 63: uint32(0xd096954b), + 64: uint32(0x55a867bc), + 65: uint32(0xa1159a58), + 66: uint32(0xcca92963), + 67: uint32(0x99e1db33), + 68: uint32(0xa62a4a56), + 69: uint32(0x3f3125f9), + 70: uint32(0x5ef47e1c), + 71: uint32(0x9029317c), + 72: uint32(0xfdf8e802), + 73: uint32(0x04272f70), + 74: uint32(0x80bb155c), + 75: uint32(0x05282ce3), + 76: uint32(0x95c11548), + 77: uint32(0xe4c66d22), + 78: uint32(0x48c1133f), + 79: uint32(0xc70f86dc), + 80: uint32(0x07f9c9ee), + 81: uint32(0x41041f0f), + 82: uint32(0x404779a4), + 83: uint32(0x5d886e17), + 84: uint32(0x325f51eb), + 85: uint32(0xd59bc0d1), + 86: uint32(0xf2bcc18f), + 87: uint32(0x41113564), + 88: uint32(0x257b7834), + 89: uint32(0x602a9c60), + 90: uint32(0xdff8e8a3), + 91: uint32(0x1f636c1b), + 92: uint32(0x0e12b4c2), + 93: uint32(0x02e1329e), + 94: uint32(0xaf664fd1), + 95: uint32(0xcad18115), + 96: uint32(0x6b2395e0), + 97: uint32(0x333e92e1), + 98: uint32(0x3b240b62), + 99: uint32(0xeebeb922), + 100: uint32(0x85b2a20e), + 101: uint32(0xe6ba0d99), + 102: uint32(0xde720c8c), + 103: uint32(0x2da2f728), + 104: uint32(0xd0127845), + 105: uint32(0x95b794fd), + 106: uint32(0x647d0862), + 107: uint32(0xe7ccf5f0), + 108: uint32(0x5449a36f), + 109: uint32(0x877d48fa), + 110: uint32(0xc39dfd27), + 111: uint32(0xf33e8d1e), + 112: uint32(0x0a476341), + 113: uint32(0x992eff74), + 114: uint32(0x3a6f6eab), + 115: uint32(0xf4f8fd37), + 116: uint32(0xa812dc60), + 117: uint32(0xa1ebddf8), + 118: uint32(0x991be14c), + 119: uint32(0xdb6e6b0d), + 120: uint32(0xc67b5510), + 121: uint32(0x6d672c37), + 122: uint32(0x2765d43b), + 123: uint32(0xdcd0e804), + 124: uint32(0xf1290dc7), + 125: uint32(0xcc00ffa3), + 126: uint32(0xb5390f92), + 127: uint32(0x690fed0b), + 128: uint32(0x667b9ffb), + 129: uint32(0xcedb7d9c), + 130: uint32(0xa091cf0b), + 131: uint32(0xd9155ea3), + 132: uint32(0xbb132f88), + 133: uint32(0x515bad24), + 134: uint32(0x7b9479bf), + 135: uint32(0x763bd6eb), + 136: uint32(0x37392eb3), + 137: uint32(0xcc115979), + 138: uint32(0x8026e297), + 139: uint32(0xf42e312d), + 140: uint32(0x6842ada7), + 141: uint32(0xc66a2b3b), + 142: uint32(0x12754ccc), + 143: uint32(0x782ef11c), + 144: uint32(0x6a124237), + 145: uint32(0xb79251e7), + 146: uint32(0x06a1bbe6), + 147: uint32(0x4bfb6350), + 148: uint32(0x1a6b1018), + 149: uint32(0x11caedfa), + 150: uint32(0x3d25bdd8), + 151: uint32(0xe2e1c3c9), + 152: uint32(0x44421659), + 153: uint32(0x0a121386), + 154: uint32(0xd90cec6e), + 155: uint32(0xd5abea2a), + 156: uint32(0x64af674e), + 157: uint32(0xda86a85f), + 158: uint32(0xbebfe988), + 159: uint32(0x64e4c3fe), + 160: uint32(0x9dbc8057), + 161: uint32(0xf0f7c086), + 162: uint32(0x60787bf8), + 163: uint32(0x6003604d), + 164: uint32(0xd1fd8346), + 165: uint32(0xf6381fb0), + 166: uint32(0x7745ae04), + 167: uint32(0xd736fccc), + 168: uint32(0x83426b33), + 169: uint32(0xf01eab71), + 170: uint32(0xb0804187), + 171: uint32(0x3c005e5f), + 172: uint32(0x77a057be), + 173: uint32(0xbde8ae24), + 174: uint32(0x55464299), + 175: uint32(0xbf582e61), + 176: uint32(0x4e58f48f), + 177: uint32(0xf2ddfda2), + 178: uint32(0xf474ef38), + 179: uint32(0x8789bdc2), + 180: uint32(0x5366f9c3), + 181: uint32(0xc8b38e74), + 182: uint32(0xb475f255), + 183: uint32(0x46fcd9b9), + 184: uint32(0x7aeb2661), + 185: uint32(0x8b1ddf84), + 186: uint32(0x846a0e79), + 187: uint32(0x915f95e2), + 188: uint32(0x466e598e), + 189: uint32(0x20b45770), + 190: uint32(0x8cd55591), + 191: uint32(0xc902de4c), + 192: uint32(0xb90bace1), + 193: uint32(0xbb8205d0), + 194: uint32(0x11a86248), + 195: uint32(0x7574a99e), + 196: uint32(0xb77f19b6), + 197: uint32(0xe0a9dc09), + 198: uint32(0x662d09a1), + 199: uint32(0xc4324633), + 200: uint32(0xe85a1f02), + 201: uint32(0x09f0be8c), + 202: uint32(0x4a99a025), + 203: uint32(0x1d6efe10), + 204: uint32(0x1ab93d1d), + 205: uint32(0x0ba5a4df), + 206: uint32(0xa186f20f), + 207: uint32(0x2868f169), + 208: uint32(0xdcb7da83), + 209: uint32(0x573906fe), + 210: uint32(0xa1e2ce9b), + 211: uint32(0x4fcd7f52), + 212: uint32(0x50115e01), + 213: uint32(0xa70683fa), + 214: uint32(0xa002b5c4), + 215: uint32(0x0de6d027), + 216: uint32(0x9af88c27), + 217: uint32(0x773f8641), + 218: uint32(0xc3604c06), + 219: uint32(0x61a806b5), + 220: uint32(0xf0177a28), + 221: uint32(0xc0f586e0), + 222: uint32(0x006058aa), + 223: uint32(0x30dc7d62), + 224: uint32(0x11e69ed7), + 225: uint32(0x2338ea63), + 226: uint32(0x53c2dd94), + 227: uint32(0xc2c21634), + 228: uint32(0xbbcbee56), + 229: uint32(0x90bcb6de), + 230: uint32(0xebfc7da1), + 231: uint32(0xce591d76), + 232: uint32(0x6f05e409), + 233: uint32(0x4b7c0188), + 234: uint32(0x39720a3d), + 235: uint32(0x7c927c24), + 236: uint32(0x86e3725f), + 237: uint32(0x724d9db9), + 238: uint32(0x1ac15bb4), + 239: uint32(0xd39eb8fc), + 240: uint32(0xed545578), + 241: uint32(0x08fca5b5), + 242: uint32(0xd83d7cd3), + 243: uint32(0x4dad0fc4), + 244: uint32(0x1e50ef5e), + 245: uint32(0xb161e6f8), + 246: uint32(0xa28514d9), + 247: uint32(0x6c51133c), + 248: uint32(0x6fd5c7e7), + 249: uint32(0x56e14ec4), + 250: uint32(0x362abfce), + 251: uint32(0xddc6c837), + 252: uint32(0xd79a3234), + 253: uint32(0x92638212), + 254: uint32(0x670efa8e), + 255: uint32(0x406000e0), + }, + 3: { + 0: uint32(0x3a39ce37), + 1: uint32(0xd3faf5cf), + 2: uint32(0xabc27737), + 3: uint32(0x5ac52d1b), + 4: uint32(0x5cb0679e), + 5: uint32(0x4fa33742), + 6: uint32(0xd3822740), + 7: uint32(0x99bc9bbe), + 8: uint32(0xd5118e9d), + 9: uint32(0xbf0f7315), + 10: uint32(0xd62d1c7e), + 11: uint32(0xc700c47b), + 12: uint32(0xb78c1b6b), + 13: uint32(0x21a19045), + 14: uint32(0xb26eb1be), + 15: uint32(0x6a366eb4), + 16: uint32(0x5748ab2f), + 17: uint32(0xbc946e79), + 18: uint32(0xc6a376d2), + 19: uint32(0x6549c2c8), + 20: uint32(0x530ff8ee), + 21: uint32(0x468dde7d), + 22: uint32(0xd5730a1d), + 23: uint32(0x4cd04dc6), + 24: uint32(0x2939bbdb), + 25: uint32(0xa9ba4650), + 26: uint32(0xac9526e8), + 27: uint32(0xbe5ee304), + 28: uint32(0xa1fad5f0), + 29: uint32(0x6a2d519a), + 30: uint32(0x63ef8ce2), + 31: uint32(0x9a86ee22), + 32: uint32(0xc089c2b8), + 33: uint32(0x43242ef6), + 34: uint32(0xa51e03aa), + 35: uint32(0x9cf2d0a4), + 36: uint32(0x83c061ba), + 37: uint32(0x9be96a4d), + 38: uint32(0x8fe51550), + 39: uint32(0xba645bd6), + 40: uint32(0x2826a2f9), + 41: uint32(0xa73a3ae1), + 42: uint32(0x4ba99586), + 43: uint32(0xef5562e9), + 44: uint32(0xc72fefd3), + 45: uint32(0xf752f7da), + 46: uint32(0x3f046f69), + 47: uint32(0x77fa0a59), + 48: uint32(0x80e4a915), + 49: uint32(0x87b08601), + 50: uint32(0x9b09e6ad), + 51: uint32(0x3b3ee593), + 52: uint32(0xe990fd5a), + 53: uint32(0x9e34d797), + 54: uint32(0x2cf0b7d9), + 55: uint32(0x022b8b51), + 56: uint32(0x96d5ac3a), + 57: uint32(0x017da67d), + 58: uint32(0xd1cf3ed6), + 59: uint32(0x7c7d2d28), + 60: uint32(0x1f9f25cf), + 61: uint32(0xadf2b89b), + 62: uint32(0x5ad6b472), + 63: uint32(0x5a88f54c), + 64: uint32(0xe029ac71), + 65: uint32(0xe019a5e6), + 66: uint32(0x47b0acfd), + 67: uint32(0xed93fa9b), + 68: uint32(0xe8d3c48d), + 69: uint32(0x283b57cc), + 70: uint32(0xf8d56629), + 71: uint32(0x79132e28), + 72: uint32(0x785f0191), + 73: uint32(0xed756055), + 74: uint32(0xf7960e44), + 75: uint32(0xe3d35e8c), + 76: uint32(0x15056dd4), + 77: uint32(0x88f46dba), + 78: uint32(0x03a16125), + 79: uint32(0x0564f0bd), + 80: uint32(0xc3eb9e15), + 81: uint32(0x3c9057a2), + 82: uint32(0x97271aec), + 83: uint32(0xa93a072a), + 84: uint32(0x1b3f6d9b), + 85: uint32(0x1e6321f5), + 86: uint32(0xf59c66fb), + 87: uint32(0x26dcf319), + 88: uint32(0x7533d928), + 89: uint32(0xb155fdf5), + 90: uint32(0x03563482), + 91: uint32(0x8aba3cbb), + 92: uint32(0x28517711), + 93: uint32(0xc20ad9f8), + 94: uint32(0xabcc5167), + 95: uint32(0xccad925f), + 96: uint32(0x4de81751), + 97: uint32(0x3830dc8e), + 98: uint32(0x379d5862), + 99: uint32(0x9320f991), + 100: uint32(0xea7a90c2), + 101: uint32(0xfb3e7bce), + 102: uint32(0x5121ce64), + 103: uint32(0x774fbe32), + 104: uint32(0xa8b6e37e), + 105: uint32(0xc3293d46), + 106: uint32(0x48de5369), + 107: uint32(0x6413e680), + 108: uint32(0xa2ae0810), + 109: uint32(0xdd6db224), + 110: uint32(0x69852dfd), + 111: uint32(0x09072166), + 112: uint32(0xb39a460a), + 113: uint32(0x6445c0dd), + 114: uint32(0x586cdecf), + 115: uint32(0x1c20c8ae), + 116: uint32(0x5bbef7dd), + 117: uint32(0x1b588d40), + 118: uint32(0xccd2017f), + 119: uint32(0x6bb4e3bb), + 120: uint32(0xdda26a7e), + 121: uint32(0x3a59ff45), + 122: uint32(0x3e350a44), + 123: uint32(0xbcb4cdd5), + 124: uint32(0x72eacea8), + 125: uint32(0xfa6484bb), + 126: uint32(0x8d6612ae), + 127: uint32(0xbf3c6f47), + 128: uint32(0xd29be463), + 129: uint32(0x542f5d9e), + 130: uint32(0xaec2771b), + 131: uint32(0xf64e6370), + 132: uint32(0x740e0d8d), + 133: uint32(0xe75b1357), + 134: uint32(0xf8721671), + 135: uint32(0xaf537d5d), + 136: uint32(0x4040cb08), + 137: uint32(0x4eb4e2cc), + 138: uint32(0x34d2466a), + 139: uint32(0x0115af84), + 140: uint32(0xe1b00428), + 141: uint32(0x95983a1d), + 142: uint32(0x06b89fb4), + 143: uint32(0xce6ea048), + 144: uint32(0x6f3f3b82), + 145: uint32(0x3520ab82), + 146: uint32(0x011a1d4b), + 147: uint32(0x277227f8), + 148: uint32(0x611560b1), + 149: uint32(0xe7933fdc), + 150: uint32(0xbb3a792b), + 151: uint32(0x344525bd), + 152: uint32(0xa08839e1), + 153: uint32(0x51ce794b), + 154: uint32(0x2f32c9b7), + 155: uint32(0xa01fbac9), + 156: uint32(0xe01cc87e), + 157: uint32(0xbcc7d1f6), + 158: uint32(0xcf0111c3), + 159: uint32(0xa1e8aac7), + 160: uint32(0x1a908749), + 161: uint32(0xd44fbd9a), + 162: uint32(0xd0dadecb), + 163: uint32(0xd50ada38), + 164: uint32(0x0339c32a), + 165: uint32(0xc6913667), + 166: uint32(0x8df9317c), + 167: uint32(0xe0b12b4f), + 168: uint32(0xf79e59b7), + 169: uint32(0x43f5bb3a), + 170: uint32(0xf2d519ff), + 171: uint32(0x27d9459c), + 172: uint32(0xbf97222c), + 173: uint32(0x15e6fc2a), + 174: uint32(0x0f91fc71), + 175: uint32(0x9b941525), + 176: uint32(0xfae59361), + 177: uint32(0xceb69ceb), + 178: uint32(0xc2a86459), + 179: uint32(0x12baa8d1), + 180: uint32(0xb6c1075e), + 181: uint32(0xe3056a0c), + 182: uint32(0x10d25065), + 183: uint32(0xcb03a442), + 184: uint32(0xe0ec6e0e), + 185: uint32(0x1698db3b), + 186: uint32(0x4c98a0be), + 187: uint32(0x3278e964), + 188: uint32(0x9f1f9532), + 189: uint32(0xe0d392df), + 190: uint32(0xd3a0342b), + 191: uint32(0x8971f21e), + 192: uint32(0x1b0a7441), + 193: uint32(0x4ba3348c), + 194: uint32(0xc5be7120), + 195: uint32(0xc37632d8), + 196: uint32(0xdf359f8d), + 197: uint32(0x9b992f2e), + 198: uint32(0xe60b6f47), + 199: uint32(0x0fe3f11d), + 200: uint32(0xe54cda54), + 201: uint32(0x1edad891), + 202: uint32(0xce6279cf), + 203: uint32(0xcd3e7e6f), + 204: uint32(0x1618b166), + 205: uint32(0xfd2c1d05), + 206: uint32(0x848fd2c5), + 207: uint32(0xf6fb2299), + 208: uint32(0xf523f357), + 209: uint32(0xa6327623), + 210: uint32(0x93a83531), + 211: uint32(0x56cccd02), + 212: uint32(0xacf08162), + 213: uint32(0x5a75ebb5), + 214: uint32(0x6e163697), + 215: uint32(0x88d273cc), + 216: uint32(0xde966292), + 217: uint32(0x81b949d0), + 218: uint32(0x4c50901b), + 219: uint32(0x71c65614), + 220: uint32(0xe6c6c7bd), + 221: uint32(0x327a140a), + 222: uint32(0x45e1d006), + 223: uint32(0xc3f27b9a), + 224: uint32(0xc9aa53fd), + 225: uint32(0x62a80f00), + 226: uint32(0xbb25bfe2), + 227: uint32(0x35bdd2f6), + 228: uint32(0x71126905), + 229: uint32(0xb2040222), + 230: uint32(0xb6cbcf7c), + 231: uint32(0xcd769c2b), + 232: uint32(0x53113ec0), + 233: uint32(0x1640e3d3), + 234: uint32(0x38abbd60), + 235: uint32(0x2547adf0), + 236: uint32(0xba38209c), + 237: uint32(0xf746ce76), + 238: uint32(0x77afa1c5), + 239: uint32(0x20756060), + 240: uint32(0x85cbfe4e), + 241: uint32(0x8ae88dd8), + 242: uint32(0x7aaaf9b0), + 243: uint32(0x4cf9aa7e), + 244: uint32(0x1948c25c), + 245: uint32(0x02fb8a8c), + 246: uint32(0x01c36ae4), + 247: uint32(0xd6ebe1f9), + 248: uint32(0x90d4f869), + 249: uint32(0xa65cdea0), + 250: uint32(0x3f09252d), + 251: uint32(0xc208e69f), + 252: uint32(0xb74e6132), + 253: uint32(0xce77e25b), + 254: uint32(0x578fdfe3), + 255: uint32(0x3ac372e6), + }, + }, +})) + +var _BF_itoa64 = [65]uint8{'.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} + +var _BF_atoi64 = [96]uint8{ + 0: uint8(64), + 1: uint8(64), + 2: uint8(64), + 3: uint8(64), + 4: uint8(64), + 5: uint8(64), + 6: uint8(64), + 7: uint8(64), + 8: uint8(64), + 9: uint8(64), + 10: uint8(64), + 11: uint8(64), + 12: uint8(64), + 13: uint8(64), + 15: uint8(1), + 16: uint8(54), + 17: uint8(55), + 18: uint8(56), + 19: uint8(57), + 20: uint8(58), + 21: uint8(59), + 22: uint8(60), + 23: uint8(61), + 24: uint8(62), + 25: uint8(63), + 26: uint8(64), + 27: uint8(64), + 28: uint8(64), + 29: uint8(64), + 30: uint8(64), + 31: uint8(64), + 32: uint8(64), + 33: uint8(2), + 34: uint8(3), + 35: uint8(4), + 36: uint8(5), + 37: uint8(6), + 38: uint8(7), + 39: uint8(8), + 40: uint8(9), + 41: uint8(10), + 42: uint8(11), + 43: uint8(12), + 44: uint8(13), + 45: uint8(14), + 46: uint8(15), + 47: uint8(16), + 48: uint8(17), + 49: uint8(18), + 50: uint8(19), + 51: uint8(20), + 52: uint8(21), + 53: uint8(22), + 54: uint8(23), + 55: uint8(24), + 56: uint8(25), + 57: uint8(26), + 58: uint8(27), + 59: uint8(64), + 60: uint8(64), + 61: uint8(64), + 62: uint8(64), + 63: uint8(64), + 64: uint8(64), + 65: uint8(28), + 66: uint8(29), + 67: uint8(30), + 68: uint8(31), + 69: uint8(32), + 70: uint8(33), + 71: uint8(34), + 72: uint8(35), + 73: uint8(36), + 74: uint8(37), + 75: uint8(38), + 76: uint8(39), + 77: uint8(40), + 78: uint8(41), + 79: uint8(42), + 80: uint8(43), + 81: uint8(44), + 82: uint8(45), + 83: uint8(46), + 84: uint8(47), + 85: uint8(48), + 86: uint8(49), + 87: uint8(50), + 88: uint8(51), + 89: uint8(52), + 90: uint8(53), + 91: uint8(64), + 92: uint8(64), + 93: uint8(64), + 94: uint8(64), + 95: uint8(64), +} + +func _BF_decode(tls *TLS, dst uintptr, src uintptr, size int32) (r int32) { + var c1, c2, c3, c4, tmp uint32 + var dptr, end, sptr, v1 uintptr + _, _, _, _, _, _, _, _, _ = c1, c2, c3, c4, dptr, end, sptr, tmp, v1 + dptr = dst + end = dptr + uintptr(size) + sptr = src + for cond := true; cond; cond = dptr < end { + v1 = sptr + sptr = sptr + 1 + tmp = uint32(**(**uint8)(__ccgo_up(v1))) + tmp = tmp - uint32(0x20) + if tmp >= uint32(0x60) { + return -int32(1) + } + tmp = uint32(_BF_atoi64[tmp]) + if tmp > uint32(63) { + return -int32(1) + } + c1 = tmp + v1 = sptr + sptr = sptr + 1 + tmp = uint32(**(**uint8)(__ccgo_up(v1))) + tmp = tmp - uint32(0x20) + if tmp >= uint32(0x60) { + return -int32(1) + } + tmp = uint32(_BF_atoi64[tmp]) + if tmp > uint32(63) { + return -int32(1) + } + c2 = tmp + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c1<>int32(4)) + if dptr >= end { + break + } + v1 = sptr + sptr = sptr + 1 + tmp = uint32(**(**uint8)(__ccgo_up(v1))) + tmp = tmp - uint32(0x20) + if tmp >= uint32(0x60) { + return -int32(1) + } + tmp = uint32(_BF_atoi64[tmp]) + if tmp > uint32(63) { + return -int32(1) + } + c3 = tmp + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c2&uint32(0x0F)<>int32(2)) + if dptr >= end { + break + } + v1 = sptr + sptr = sptr + 1 + tmp = uint32(**(**uint8)(__ccgo_up(v1))) + tmp = tmp - uint32(0x20) + if tmp >= uint32(0x60) { + return -int32(1) + } + tmp = uint32(_BF_atoi64[tmp]) + if tmp > uint32(63) { + return -int32(1) + } + c4 = tmp + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(c3&uint32(0x03)<>int32(2)] + c1 = c1 & uint32(0x03) << int32(4) + if sptr >= end { + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c1] + break + } + v1 = sptr + sptr = sptr + 1 + c2 = uint32(**(**uint8)(__ccgo_up(v1))) + c1 = c1 | c2>>int32(4) + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c1] + c1 = c2 & uint32(0x0f) << int32(2) + if sptr >= end { + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c1] + break + } + v1 = sptr + sptr = sptr + 1 + c2 = uint32(**(**uint8)(__ccgo_up(v1))) + c1 = c1 | c2>>int32(6) + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c1] + v1 = dptr + dptr = dptr + 1 + **(**uint8)(__ccgo_up(v1)) = _BF_itoa64[c2&uint32(0x3f)] + } +} + +func _BF_swap(tls *TLS, x uintptr, count int32) { + var tmp TBF_word + var v1, v2 int32 + var v4 uintptr + _, _, _, _ = tmp, v1, v2, v4 + v1 = int32(1) + if *(*uint8)(unsafe.Pointer(&v1)) != 0 { + for { + tmp = **(**TBF_word)(__ccgo_up(x)) + tmp = tmp<>Int32FromInt32(16) + v4 = x + x += 4 + **(**TBF_word)(__ccgo_up(v4)) = tmp&uint32(0x00FF00FF)<>Int32FromInt32(8)&uint32(0x00FF00FF) + goto _3 + _3: + ; + count = count - 1 + v2 = count + if !(v2 != 0) { + break + } + } + } +} + +func _BF_encrypt(tls *TLS, ctx uintptr, L TBF_word, R TBF_word, start uintptr, end uintptr) (r TBF_word) { + var i int32 + var ptr, v2 uintptr + var tmp1, tmp2, tmp3, tmp4 TBF_word + _, _, _, _, _, _, _ = i, ptr, tmp1, tmp2, tmp3, tmp4, v2 + ptr = start + for cond := true; cond; cond = ptr < end { + L = L ^ **(**TBF_word)(__ccgo_up(ctx)) + i = 0 + for { + if !(i < int32(16)) { + break + } + tmp1 = L & uint32(0xFF) + tmp2 = L >> int32(8) + tmp2 = tmp2 & uint32(0xFF) + tmp3 = L >> int32(16) + tmp3 = tmp3 & uint32(0xFF) + tmp4 = L >> int32(24) + tmp1 = **(**TBF_word)(__ccgo_up(ctx + 72 + 3*1024 + uintptr(tmp1)*4)) + tmp2 = **(**TBF_word)(__ccgo_up(ctx + 72 + 2*1024 + uintptr(tmp2)*4)) + tmp3 = **(**TBF_word)(__ccgo_up(ctx + 72 + 1*1024 + uintptr(tmp3)*4)) + tmp3 = tmp3 + **(**TBF_word)(__ccgo_up(ctx + 72 + uintptr(tmp4)*4)) + tmp3 = tmp3 ^ tmp2 + R = R ^ **(**TBF_word)(__ccgo_up(ctx + uintptr(i+int32(1))*4)) + tmp3 = tmp3 + tmp1 + R = R ^ tmp3 + tmp1 = R & uint32(0xFF) + tmp2 = R >> int32(8) + tmp2 = tmp2 & uint32(0xFF) + tmp3 = R >> int32(16) + tmp3 = tmp3 & uint32(0xFF) + tmp4 = R >> int32(24) + tmp1 = **(**TBF_word)(__ccgo_up(ctx + 72 + 3*1024 + uintptr(tmp1)*4)) + tmp2 = **(**TBF_word)(__ccgo_up(ctx + 72 + 2*1024 + uintptr(tmp2)*4)) + tmp3 = **(**TBF_word)(__ccgo_up(ctx + 72 + 1*1024 + uintptr(tmp3)*4)) + tmp3 = tmp3 + **(**TBF_word)(__ccgo_up(ctx + 72 + uintptr(tmp4)*4)) + tmp3 = tmp3 ^ tmp2 + L = L ^ **(**TBF_word)(__ccgo_up(ctx + uintptr(i+int32(1)+int32(1))*4)) + tmp3 = tmp3 + tmp1 + L = L ^ tmp3 + goto _1 + _1: + ; + i = i + int32(2) + } + tmp4 = R + R = L + L = tmp4 ^ **(**TBF_word)(__ccgo_up(ctx + uintptr(Int32FromInt32(BF_N)+Int32FromInt32(1))*4)) + v2 = ptr + ptr += 4 + **(**TBF_word)(__ccgo_up(v2)) = L + v2 = ptr + ptr += 4 + **(**TBF_word)(__ccgo_up(v2)) = R + } + return L +} + +func _BF_set_key(tls *TLS, key uintptr, expanded uintptr, initial uintptr, flags uint8) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bug, i, j uint32 + var diff, safety, sign, v1 TBF_word + var ptr uintptr + var _ /* tmp at bp+0 */ [2]TBF_word + _, _, _, _, _, _, _, _ = bug, diff, i, j, ptr, safety, sign, v1 + ptr = key + /* + * There was a sign extension bug in older revisions of this function. While + * we would have liked to simply fix the bug and move on, we have to provide + * a backwards compatibility feature (essentially the bug) for some systems and + * a safety measure for some others. The latter is needed because for certain + * multiple inputs to the buggy algorithm there exist easily found inputs to + * the correct algorithm that produce the same hash. Thus, we optionally + * deviate from the correct algorithm just enough to avoid such collisions. + * While the bug itself affected the majority of passwords containing + * characters with the 8th bit set (although only a percentage of those in a + * collision-producing way), the anti-collision safety measure affects + * only a subset of passwords containing the '\xff' character (not even all of + * those passwords, just some of them). This character is not found in valid + * UTF-8 sequences and is rarely used in popular 8-bit character encodings. + * Thus, the safety measure is unlikely to cause much annoyance, and is a + * reasonable tradeoff to use when authenticating against existing hashes that + * are not reliably known to have been computed with the correct algorithm. + * + * We use an approach that tries to minimize side-channel leaks of password + * information - that is, we mostly use fixed-cost bitwise operations instead + * of branches or table lookups. (One conditional branch based on password + * length remains. It is not part of the bug aftermath, though, and is + * difficult and possibly unreasonable to avoid given the use of C strings by + * the caller, which results in similar timing leaks anyway.) + * + * For actual implementation, we set an array index in the variable "bug" + * (0 means no bug, 1 means sign extension bug emulation) and a flag in the + * variable "safety" (bit 16 is set when the safety measure is requested). + * Valid combinations of settings are: + * + * Prefix "$2a$": bug = 0, safety = 0x10000 + * Prefix "$2b$": bug = 0, safety = 0 + * Prefix "$2x$": bug = 1, safety = 0 + * Prefix "$2y$": bug = 0, safety = 0 + */ + bug = Uint32FromInt32(Int32FromUint8(flags) & int32(1)) + safety = uint32(flags) & uint32(2) << int32(15) + v1 = Uint32FromInt32(0) + diff = v1 + sign = v1 + i = uint32(0) + for { + if !(i < Uint32FromInt32(Int32FromInt32(BF_N)+Int32FromInt32(2))) { + break + } + v1 = Uint32FromInt32(0) + (**(**[2]TBF_word)(__ccgo_up(bp)))[int32(1)] = v1 + (**(**[2]TBF_word)(__ccgo_up(bp)))[0] = v1 + j = uint32(0) + for { + if !(j < uint32(4)) { + break + } + **(**TBF_word)(__ccgo_up(bp)) <<= uint32(8) + **(**TBF_word)(__ccgo_up(bp)) |= uint32(uint8(**(**uint8)(__ccgo_up(ptr)))) /* correct */ + **(**TBF_word)(__ccgo_up(bp + 1*4)) <<= uint32(8) + **(**TBF_word)(__ccgo_up(bp + 1*4)) |= Uint32FromInt8(Int8FromUint8(**(**uint8)(__ccgo_up(ptr)))) /* bug */ + /* + * Sign extension in the first char has no effect - nothing to overwrite yet, + * and those extra 24 bits will be fully shifted out of the 32-bit word. For + * chars 2, 3, 4 in each four-char block, we set bit 7 of "sign" if sign + * extension in tmp[1] occurs. Once this flag is set, it remains set. + */ + if j != 0 { + sign = sign | (**(**[2]TBF_word)(__ccgo_up(bp)))[int32(1)]&uint32(0x80) + } + if !(**(**uint8)(__ccgo_up(ptr)) != 0) { + ptr = key + } else { + ptr = ptr + 1 + } + goto _4 + _4: + ; + j = j + 1 + } + diff = diff | ((**(**[2]TBF_word)(__ccgo_up(bp)))[0] ^ (**(**[2]TBF_word)(__ccgo_up(bp)))[int32(1)]) /* Non-zero on any differences */ + **(**TBF_word)(__ccgo_up(expanded + uintptr(i)*4)) = (**(**[2]TBF_word)(__ccgo_up(bp)))[bug] + **(**TBF_word)(__ccgo_up(initial + uintptr(i)*4)) = **(**TBF_word)(__ccgo_up(uintptr(unsafe.Pointer(&_BF_init_state)) + uintptr(i)*4)) ^ (**(**[2]TBF_word)(__ccgo_up(bp)))[bug] + goto _2 + _2: + ; + i = i + 1 + } + /* + * At this point, "diff" is zero iff the correct and buggy algorithms produced + * exactly the same result. If so and if "sign" is non-zero, which indicates + * that there was a non-benign sign extension, this means that we have a + * collision between the correctly computed hash for this password and a set of + * passwords that could be supplied to the buggy algorithm. Our safety measure + * is meant to protect from such many-buggy to one-correct collisions, by + * deviating from the correct algorithm in such cases. Let's check for this. + */ + diff = diff | diff>>int32(16) /* still zero iff exact match */ + diff = diff & uint32(0xffff) /* ditto */ + diff = diff + uint32(0xffff) /* bit 16 set iff "diff" was non-zero (on non-match) */ + sign = sign << uint32(9) /* move the non-benign sign extension flag to bit 16 */ + sign = sign & (^diff & safety) /* action needed? */ + /* + * If we have determined that we need to deviate from the correct algorithm, + * flip bit 16 in initial expanded key. (The choice of 16 is arbitrary, but + * let's stick to it now. It came out of the approach we used above, and it's + * not any worse than any other choice we could make.) + * + * It is crucial that we don't do the same to the expanded key used in the main + * Eksblowfish loop. By doing it to only one of these two, we deviate from a + * state that could be directly specified by a password to the buggy algorithm + * (and to the fully correct one as well, but that's a side-effect). + */ + **(**TBF_word)(__ccgo_up(initial)) ^= sign +} + +var _flags_by_subtype = [26]uint8{ + 0: uint8(2), + 1: uint8(4), + 23: uint8(1), + 24: uint8(4), +} + +func _BF_crypt(tls *TLS, key uintptr, setting uintptr, output uintptr, min TBF_word) (r uintptr) { + bp := tls.Alloc(4272) + defer tls.Free(4272) + var L, L1, R, count, tmp1, tmp2, tmp3, tmp4, v1 TBF_word + var done, i int32 + var ptr uintptr + var _ /* LR at bp+4264 */ [2]TBF_word + var _ /* data at bp+0 */ struct { + Fctx TBF_ctx + Fexpanded_key TBF_key + Fbinary struct { + Foutput [0][6]TBF_word + Fsalt [4]TBF_word + F__ccgo_pad2 [8]byte + } + } + _, _, _, _, _, _, _, _, _, _, _, _ = L, L1, R, count, done, i, ptr, tmp1, tmp2, tmp3, tmp4, v1 + if Int32FromUint8(**(**uint8)(__ccgo_up(setting))) != int32('$') || Int32FromUint8(**(**uint8)(__ccgo_up(setting + 1))) != int32('2') || Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(setting + 2)))-int32('a')) > uint32(25) || !(_flags_by_subtype[Int32FromUint8(**(**uint8)(__ccgo_up(setting + 2)))-int32('a')] != 0) || Int32FromUint8(**(**uint8)(__ccgo_up(setting + 3))) != int32('$') || Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(setting + 4)))-int32('0')) > uint32(1) || Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(setting + 5)))-int32('0')) > uint32(9) || Int32FromUint8(**(**uint8)(__ccgo_up(setting + 6))) != int32('$') { + return UintptrFromInt32(0) + } + count = Uint32FromInt32(1) << ((Int32FromUint8(**(**uint8)(__ccgo_up(setting + 4)))-int32('0'))*int32(10) + (Int32FromUint8(**(**uint8)(__ccgo_up(setting + 5))) - int32('0'))) + if count < min || _BF_decode(tls, bp+4240, setting+7, int32(16)) != 0 { + return UintptrFromInt32(0) + } + _BF_swap(tls, bp+4240, int32(4)) + _BF_set_key(tls, key, bp+4168, bp, _flags_by_subtype[Int32FromUint8(**(**uint8)(__ccgo_up(setting + 2)))-int32('a')]) + Xmemcpy(tls, bp+72, uintptr(unsafe.Pointer(&_BF_init_state))+72, uint64(4096)) + L = uint32(0) + R = uint32(0) + ptr = bp + for cond := true; cond; cond = int32(1) != 0 { + L = _BF_encrypt(tls, bp, L^**(**TBF_word)(__ccgo_up(bp + 4240)), R^**(**TBF_word)(__ccgo_up(bp + 4240 + 1*4)), ptr, ptr) + R = **(**TBF_word)(__ccgo_up(ptr + UintptrFromInt32(1)*4)) + ptr = ptr + uintptr(2)*4 + if ptr >= bp+uintptr(Int32FromInt32(BF_N)+Int32FromInt32(2)+Int32FromInt32(4)*Int32FromInt32(0x100))*4 { + break + } + L = _BF_encrypt(tls, bp, L^**(**TBF_word)(__ccgo_up(bp + 4240 + 2*4)), R^**(**TBF_word)(__ccgo_up(bp + 4240 + 3*4)), ptr, ptr) + R = **(**TBF_word)(__ccgo_up(ptr + UintptrFromInt32(1)*4)) + ptr = ptr + uintptr(2)*4 + } + for { + i = 0 + for { + if !(i < Int32FromInt32(BF_N)+Int32FromInt32(2)) { + break + } + **(**TBF_word)(__ccgo_up(bp + uintptr(i)*4)) ^= **(**TBF_word)(__ccgo_up(bp + 4168 + uintptr(i)*4)) + **(**TBF_word)(__ccgo_up(bp + uintptr(i+int32(1))*4)) ^= **(**TBF_word)(__ccgo_up(bp + 4168 + uintptr(i+int32(1))*4)) + goto _3 + _3: + ; + i = i + int32(2) + } + done = 0 + for cond := true; cond; cond = int32(1) != 0 { + _BF_encrypt(tls, bp, uint32(0), uint32(0), bp, bp+uintptr(Int32FromInt32(BF_N)+Int32FromInt32(2)+Int32FromInt32(4)*Int32FromInt32(0x100))*4) + if done != 0 { + break + } + done = int32(1) + tmp1 = **(**TBF_word)(__ccgo_up(bp + 4240)) + tmp2 = **(**TBF_word)(__ccgo_up(bp + 4240 + 1*4)) + tmp3 = **(**TBF_word)(__ccgo_up(bp + 4240 + 2*4)) + tmp4 = **(**TBF_word)(__ccgo_up(bp + 4240 + 3*4)) + i = 0 + for { + if !(i < int32(BF_N)) { + break + } + **(**TBF_word)(__ccgo_up(bp + uintptr(i)*4)) ^= tmp1 + **(**TBF_word)(__ccgo_up(bp + uintptr(i+int32(1))*4)) ^= tmp2 + **(**TBF_word)(__ccgo_up(bp + uintptr(i+int32(2))*4)) ^= tmp3 + **(**TBF_word)(__ccgo_up(bp + uintptr(i+int32(3))*4)) ^= tmp4 + goto _4 + _4: + ; + i = i + int32(4) + } + **(**TBF_word)(__ccgo_up(bp + 16*4)) ^= tmp1 + **(**TBF_word)(__ccgo_up(bp + 17*4)) ^= tmp2 + } + goto _2 + _2: + ; + count = count - 1 + v1 = count + if !(v1 != 0) { + break + } + } + i = 0 + for { + if !(i < int32(6)) { + break + } + L1 = _BF_magic_w[i] + (**(**[2]TBF_word)(__ccgo_up(bp + 4264)))[int32(1)] = _BF_magic_w[i+int32(1)] + count = uint32(64) + for { + L1 = _BF_encrypt(tls, bp, L1, (**(**[2]TBF_word)(__ccgo_up(bp + 4264)))[int32(1)], bp+4264, bp+4264) + goto _7 + _7: + ; + count = count - 1 + v1 = count + if !(v1 != 0) { + break + } + } + **(**TBF_word)(__ccgo_up(bp + 4240 + uintptr(i)*4)) = L1 + **(**TBF_word)(__ccgo_up(bp + 4240 + uintptr(i+int32(1))*4)) = (**(**[2]TBF_word)(__ccgo_up(bp + 4264)))[int32(1)] + goto _5 + _5: + ; + i = i + int32(2) + } + Xmemcpy(tls, output, setting, Uint64FromInt32(Int32FromInt32(7)+Int32FromInt32(22)-Int32FromInt32(1))) + **(**uint8)(__ccgo_up(output + uintptr(Int32FromInt32(7)+Int32FromInt32(22)-Int32FromInt32(1)))) = _BF_itoa64[Int32FromUint8(_BF_atoi64[Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(Int32FromInt32(7)+Int32FromInt32(22)-Int32FromInt32(1)))))-int32(0x20)])&int32(0x30)] + /* This has to be bug-compatible with the original implementation, so + * only encode 23 of the 24 bytes. :-) */ + _BF_swap(tls, bp+4240, int32(6)) + _BF_encode(tls, output+uintptr(Int32FromInt32(7)+Int32FromInt32(22)), bp+4240, int32(23)) + **(**uint8)(__ccgo_up(output + uintptr(Int32FromInt32(7)+Int32FromInt32(22)+Int32FromInt32(31)))) = uint8('\000') + return output +} + +// C documentation +// +// /* +// * Please preserve the runtime self-test. It serves two purposes at once: +// * +// * 1. We really can't afford the risk of producing incompatible hashes e.g. +// * when there's something like gcc bug 26587 again, whereas an application or +// * library integrating this code might not also integrate our external tests or +// * it might not run them after every build. Even if it does, the miscompile +// * might only occur on the production build, but not on a testing build (such +// * as because of different optimization settings). It is painful to recover +// * from incorrectly-computed hashes - merely fixing whatever broke is not +// * enough. Thus, a proactive measure like this self-test is needed. +// * +// * 2. We don't want to leave sensitive data from our actual password hash +// * computation on the stack or in registers. Previous revisions of the code +// * would do explicit cleanups, but simply running the self-test after hash +// * computation is more reliable. +// * +// * The performance cost of this quick self-test is around 0.6% at the "$2a$08" +// * setting. +// */ +func X__crypt_blowfish(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v setting=%v output=%v, (%v:)", tls, key, setting, output, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(384) + defer tls.Free(384) + var flags uint32 + var k, p, retval, test_hash, test_key, test_setting uintptr + var ok int32 + var _ /* ae at bp+96 */ TBF_key + var _ /* ai at bp+168 */ TBF_key + var _ /* buf at bp+0 */ struct { + Fs [30]uint8 + Fo [63]uint8 + } + var _ /* ye at bp+240 */ TBF_key + var _ /* yi at bp+312 */ TBF_key + _, _, _, _, _, _, _, _ = flags, k, ok, p, retval, test_hash, test_key, test_setting + test_key = __ccgo_ts + 18 + test_setting = __ccgo_ts + 28 + test_hash = uintptr(unsafe.Pointer(&_test_hashes)) + /* Hash the supplied password */ + retval = _BF_crypt(tls, key, setting, output, uint32(16)) + /* + * Do a quick self-test. It is important that we make both calls to BF_crypt() + * from the same scope such that they likely use the same stack locations, + * which makes the second call overwrite the first call's sensitive data on the + * stack and makes it more likely that any alignment related issues would be + * detected by the self-test. + */ + Xmemcpy(tls, bp, test_setting, uint64(30)) + if retval != 0 { + flags = uint32(_flags_by_subtype[Int32FromUint8(**(**uint8)(__ccgo_up(setting + 2)))-int32('a')]) + test_hash = uintptr(unsafe.Pointer(&_test_hashes)) + uintptr(flags&uint32(1))*34 + **(**uint8)(__ccgo_up(bp + 2)) = **(**uint8)(__ccgo_up(setting + 2)) + } + Xmemset(tls, bp+30, int32(0x55), uint64(63)) + **(**uint8)(__ccgo_up(bp + 30 + uintptr(Uint64FromInt64(63)-Uint64FromInt32(1)))) = uint8(0) + p = _BF_crypt(tls, test_key, bp, bp+30, uint32(1)) + ok = BoolInt32(p == bp+30 && !(Xmemcmp(tls, p, bp, Uint64FromInt32(Int32FromInt32(7)+Int32FromInt32(22))) != 0) && !(Xmemcmp(tls, p+uintptr(Int32FromInt32(7)+Int32FromInt32(22)), test_hash, Uint64FromInt32(Int32FromInt32(31)+Int32FromInt32(1)+Int32FromInt32(1)+Int32FromInt32(1))) != 0)) + k = __ccgo_ts + 58 + _BF_set_key(tls, k, bp+96, bp+168, uint8(2)) /* $2a$ */ + _BF_set_key(tls, k, bp+240, bp+312, uint8(4)) /* $2y$ */ + **(**TBF_word)(__ccgo_up(bp + 168)) ^= uint32(0x10000) /* undo the safety (for comparison) */ + ok = BoolInt32(ok != 0 && (**(**TBF_key)(__ccgo_up(bp + 168)))[0] == uint32(0xdb9c59bc) && (**(**TBF_key)(__ccgo_up(bp + 240)))[int32(17)] == uint32(0x33343500) && !(Xmemcmp(tls, bp+96, bp+240, uint64(72)) != 0) && !(Xmemcmp(tls, bp+168, bp+312, uint64(72)) != 0)) + if ok != 0 && retval != 0 { + return retval + } + return __ccgo_ts + 70 +} + +var _test_hashes = [2][34]uint8{ + 0: {'i', '1', 'D', '7', '0', '9', 'v', 'f', 'a', 'm', 'u', 'l', 'i', 'm', 'l', 'G', 'c', 'q', '0', 'q', 'q', '3', 'U', 'v', 'u', 'U', 'a', 's', 'v', 'E', 'a', 0, 'U'}, + 1: {'V', 'U', 'r', 'P', 'm', 'X', 'D', '6', 'q', '/', 'n', 'V', 'S', 'S', 'p', '7', 'p', 'N', 'D', 'h', 'C', 'R', '9', '0', '7', '1', 'I', 'f', 'I', 'R', 'e', 0, 'U'}, +} + +const _PASSWORD_EFMT1 = 95 + +type Texpanded_key = struct { + Fl [16]Tuint32_t + Fr [16]Tuint32_t +} + +var _key_shifts = [16]uint8{ + 0: uint8(1), + 1: uint8(1), + 2: uint8(2), + 3: uint8(2), + 4: uint8(2), + 5: uint8(2), + 6: uint8(2), + 7: uint8(2), + 8: uint8(1), + 9: uint8(2), + 10: uint8(2), + 11: uint8(2), + 12: uint8(2), + 13: uint8(2), + 14: uint8(2), + 15: uint8(1), +} + +var _psbox = [8][64]Tuint32_t{ + 0: { + 0: uint32(0x00808200), + 2: uint32(0x00008000), + 3: uint32(0x00808202), + 4: uint32(0x00808002), + 5: uint32(0x00008202), + 6: uint32(0x00000002), + 7: uint32(0x00008000), + 8: uint32(0x00000200), + 9: uint32(0x00808200), + 10: uint32(0x00808202), + 11: uint32(0x00000200), + 12: uint32(0x00800202), + 13: uint32(0x00808002), + 14: uint32(0x00800000), + 15: uint32(0x00000002), + 16: uint32(0x00000202), + 17: uint32(0x00800200), + 18: uint32(0x00800200), + 19: uint32(0x00008200), + 20: uint32(0x00008200), + 21: uint32(0x00808000), + 22: uint32(0x00808000), + 23: uint32(0x00800202), + 24: uint32(0x00008002), + 25: uint32(0x00800002), + 26: uint32(0x00800002), + 27: uint32(0x00008002), + 29: uint32(0x00000202), + 30: uint32(0x00008202), + 31: uint32(0x00800000), + 32: uint32(0x00008000), + 33: uint32(0x00808202), + 34: uint32(0x00000002), + 35: uint32(0x00808000), + 36: uint32(0x00808200), + 37: uint32(0x00800000), + 38: uint32(0x00800000), + 39: uint32(0x00000200), + 40: uint32(0x00808002), + 41: uint32(0x00008000), + 42: uint32(0x00008200), + 43: uint32(0x00800002), + 44: uint32(0x00000200), + 45: uint32(0x00000002), + 46: uint32(0x00800202), + 47: uint32(0x00008202), + 48: uint32(0x00808202), + 49: uint32(0x00008002), + 50: uint32(0x00808000), + 51: uint32(0x00800202), + 52: uint32(0x00800002), + 53: uint32(0x00000202), + 54: uint32(0x00008202), + 55: uint32(0x00808200), + 56: uint32(0x00000202), + 57: uint32(0x00800200), + 58: uint32(0x00800200), + 60: uint32(0x00008002), + 61: uint32(0x00008200), + 63: uint32(0x00808002), + }, + 1: { + 0: uint32(0x40084010), + 1: uint32(0x40004000), + 2: uint32(0x00004000), + 3: uint32(0x00084010), + 4: uint32(0x00080000), + 5: uint32(0x00000010), + 6: uint32(0x40080010), + 7: uint32(0x40004010), + 8: uint32(0x40000010), + 9: uint32(0x40084010), + 10: uint32(0x40084000), + 11: uint32(0x40000000), + 12: uint32(0x40004000), + 13: uint32(0x00080000), + 14: uint32(0x00000010), + 15: uint32(0x40080010), + 16: uint32(0x00084000), + 17: uint32(0x00080010), + 18: uint32(0x40004010), + 20: uint32(0x40000000), + 21: uint32(0x00004000), + 22: uint32(0x00084010), + 23: uint32(0x40080000), + 24: uint32(0x00080010), + 25: uint32(0x40000010), + 27: uint32(0x00084000), + 28: uint32(0x00004010), + 29: uint32(0x40084000), + 30: uint32(0x40080000), + 31: uint32(0x00004010), + 33: uint32(0x00084010), + 34: uint32(0x40080010), + 35: uint32(0x00080000), + 36: uint32(0x40004010), + 37: uint32(0x40080000), + 38: uint32(0x40084000), + 39: uint32(0x00004000), + 40: uint32(0x40080000), + 41: uint32(0x40004000), + 42: uint32(0x00000010), + 43: uint32(0x40084010), + 44: uint32(0x00084010), + 45: uint32(0x00000010), + 46: uint32(0x00004000), + 47: uint32(0x40000000), + 48: uint32(0x00004010), + 49: uint32(0x40084000), + 50: uint32(0x00080000), + 51: uint32(0x40000010), + 52: uint32(0x00080010), + 53: uint32(0x40004010), + 54: uint32(0x40000010), + 55: uint32(0x00080010), + 56: uint32(0x00084000), + 58: uint32(0x40004000), + 59: uint32(0x00004010), + 60: uint32(0x40000000), + 61: uint32(0x40080010), + 62: uint32(0x40084010), + 63: uint32(0x00084000), + }, + 2: { + 0: uint32(0x00000104), + 1: uint32(0x04010100), + 3: uint32(0x04010004), + 4: uint32(0x04000100), + 6: uint32(0x00010104), + 7: uint32(0x04000100), + 8: uint32(0x00010004), + 9: uint32(0x04000004), + 10: uint32(0x04000004), + 11: uint32(0x00010000), + 12: uint32(0x04010104), + 13: uint32(0x00010004), + 14: uint32(0x04010000), + 15: uint32(0x00000104), + 16: uint32(0x04000000), + 17: uint32(0x00000004), + 18: uint32(0x04010100), + 19: uint32(0x00000100), + 20: uint32(0x00010100), + 21: uint32(0x04010000), + 22: uint32(0x04010004), + 23: uint32(0x00010104), + 24: uint32(0x04000104), + 25: uint32(0x00010100), + 26: uint32(0x00010000), + 27: uint32(0x04000104), + 28: uint32(0x00000004), + 29: uint32(0x04010104), + 30: uint32(0x00000100), + 31: uint32(0x04000000), + 32: uint32(0x04010100), + 33: uint32(0x04000000), + 34: uint32(0x00010004), + 35: uint32(0x00000104), + 36: uint32(0x00010000), + 37: uint32(0x04010100), + 38: uint32(0x04000100), + 40: uint32(0x00000100), + 41: uint32(0x00010004), + 42: uint32(0x04010104), + 43: uint32(0x04000100), + 44: uint32(0x04000004), + 45: uint32(0x00000100), + 47: uint32(0x04010004), + 48: uint32(0x04000104), + 49: uint32(0x00010000), + 50: uint32(0x04000000), + 51: uint32(0x04010104), + 52: uint32(0x00000004), + 53: uint32(0x00010104), + 54: uint32(0x00010100), + 55: uint32(0x04000004), + 56: uint32(0x04010000), + 57: uint32(0x04000104), + 58: uint32(0x00000104), + 59: uint32(0x04010000), + 60: uint32(0x00010104), + 61: uint32(0x00000004), + 62: uint32(0x04010004), + 63: uint32(0x00010100), + }, + 3: { + 0: uint32(0x80401000), + 1: uint32(0x80001040), + 2: uint32(0x80001040), + 3: uint32(0x00000040), + 4: uint32(0x00401040), + 5: uint32(0x80400040), + 6: uint32(0x80400000), + 7: uint32(0x80001000), + 9: uint32(0x00401000), + 10: uint32(0x00401000), + 11: uint32(0x80401040), + 12: uint32(0x80000040), + 14: uint32(0x00400040), + 15: uint32(0x80400000), + 16: uint32(0x80000000), + 17: uint32(0x00001000), + 18: uint32(0x00400000), + 19: uint32(0x80401000), + 20: uint32(0x00000040), + 21: uint32(0x00400000), + 22: uint32(0x80001000), + 23: uint32(0x00001040), + 24: uint32(0x80400040), + 25: uint32(0x80000000), + 26: uint32(0x00001040), + 27: uint32(0x00400040), + 28: uint32(0x00001000), + 29: uint32(0x00401040), + 30: uint32(0x80401040), + 31: uint32(0x80000040), + 32: uint32(0x00400040), + 33: uint32(0x80400000), + 34: uint32(0x00401000), + 35: uint32(0x80401040), + 36: uint32(0x80000040), + 39: uint32(0x00401000), + 40: uint32(0x00001040), + 41: uint32(0x00400040), + 42: uint32(0x80400040), + 43: uint32(0x80000000), + 44: uint32(0x80401000), + 45: uint32(0x80001040), + 46: uint32(0x80001040), + 47: uint32(0x00000040), + 48: uint32(0x80401040), + 49: uint32(0x80000040), + 50: uint32(0x80000000), + 51: uint32(0x00001000), + 52: uint32(0x80400000), + 53: uint32(0x80001000), + 54: uint32(0x00401040), + 55: uint32(0x80400040), + 56: uint32(0x80001000), + 57: uint32(0x00001040), + 58: uint32(0x00400000), + 59: uint32(0x80401000), + 60: uint32(0x00000040), + 61: uint32(0x00400000), + 62: uint32(0x00001000), + 63: uint32(0x00401040), + }, + 4: { + 0: uint32(0x00000080), + 1: uint32(0x01040080), + 2: uint32(0x01040000), + 3: uint32(0x21000080), + 4: uint32(0x00040000), + 5: uint32(0x00000080), + 6: uint32(0x20000000), + 7: uint32(0x01040000), + 8: uint32(0x20040080), + 9: uint32(0x00040000), + 10: uint32(0x01000080), + 11: uint32(0x20040080), + 12: uint32(0x21000080), + 13: uint32(0x21040000), + 14: uint32(0x00040080), + 15: uint32(0x20000000), + 16: uint32(0x01000000), + 17: uint32(0x20040000), + 18: uint32(0x20040000), + 20: uint32(0x20000080), + 21: uint32(0x21040080), + 22: uint32(0x21040080), + 23: uint32(0x01000080), + 24: uint32(0x21040000), + 25: uint32(0x20000080), + 27: uint32(0x21000000), + 28: uint32(0x01040080), + 29: uint32(0x01000000), + 30: uint32(0x21000000), + 31: uint32(0x00040080), + 32: uint32(0x00040000), + 33: uint32(0x21000080), + 34: uint32(0x00000080), + 35: uint32(0x01000000), + 36: uint32(0x20000000), + 37: uint32(0x01040000), + 38: uint32(0x21000080), + 39: uint32(0x20040080), + 40: uint32(0x01000080), + 41: uint32(0x20000000), + 42: uint32(0x21040000), + 43: uint32(0x01040080), + 44: uint32(0x20040080), + 45: uint32(0x00000080), + 46: uint32(0x01000000), + 47: uint32(0x21040000), + 48: uint32(0x21040080), + 49: uint32(0x00040080), + 50: uint32(0x21000000), + 51: uint32(0x21040080), + 52: uint32(0x01040000), + 54: uint32(0x20040000), + 55: uint32(0x21000000), + 56: uint32(0x00040080), + 57: uint32(0x01000080), + 58: uint32(0x20000080), + 59: uint32(0x00040000), + 61: uint32(0x20040000), + 62: uint32(0x01040080), + 63: uint32(0x20000080), + }, + 5: { + 0: uint32(0x10000008), + 1: uint32(0x10200000), + 2: uint32(0x00002000), + 3: uint32(0x10202008), + 4: uint32(0x10200000), + 5: uint32(0x00000008), + 6: uint32(0x10202008), + 7: uint32(0x00200000), + 8: uint32(0x10002000), + 9: uint32(0x00202008), + 10: uint32(0x00200000), + 11: uint32(0x10000008), + 12: uint32(0x00200008), + 13: uint32(0x10002000), + 14: uint32(0x10000000), + 15: uint32(0x00002008), + 17: uint32(0x00200008), + 18: uint32(0x10002008), + 19: uint32(0x00002000), + 20: uint32(0x00202000), + 21: uint32(0x10002008), + 22: uint32(0x00000008), + 23: uint32(0x10200008), + 24: uint32(0x10200008), + 26: uint32(0x00202008), + 27: uint32(0x10202000), + 28: uint32(0x00002008), + 29: uint32(0x00202000), + 30: uint32(0x10202000), + 31: uint32(0x10000000), + 32: uint32(0x10002000), + 33: uint32(0x00000008), + 34: uint32(0x10200008), + 35: uint32(0x00202000), + 36: uint32(0x10202008), + 37: uint32(0x00200000), + 38: uint32(0x00002008), + 39: uint32(0x10000008), + 40: uint32(0x00200000), + 41: uint32(0x10002000), + 42: uint32(0x10000000), + 43: uint32(0x00002008), + 44: uint32(0x10000008), + 45: uint32(0x10202008), + 46: uint32(0x00202000), + 47: uint32(0x10200000), + 48: uint32(0x00202008), + 49: uint32(0x10202000), + 51: uint32(0x10200008), + 52: uint32(0x00000008), + 53: uint32(0x00002000), + 54: uint32(0x10200000), + 55: uint32(0x00202008), + 56: uint32(0x00002000), + 57: uint32(0x00200008), + 58: uint32(0x10002008), + 60: uint32(0x10202000), + 61: uint32(0x10000000), + 62: uint32(0x00200008), + 63: uint32(0x10002008), + }, + 6: { + 0: uint32(0x00100000), + 1: uint32(0x02100001), + 2: uint32(0x02000401), + 4: uint32(0x00000400), + 5: uint32(0x02000401), + 6: uint32(0x00100401), + 7: uint32(0x02100400), + 8: uint32(0x02100401), + 9: uint32(0x00100000), + 11: uint32(0x02000001), + 12: uint32(0x00000001), + 13: uint32(0x02000000), + 14: uint32(0x02100001), + 15: uint32(0x00000401), + 16: uint32(0x02000400), + 17: uint32(0x00100401), + 18: uint32(0x00100001), + 19: uint32(0x02000400), + 20: uint32(0x02000001), + 21: uint32(0x02100000), + 22: uint32(0x02100400), + 23: uint32(0x00100001), + 24: uint32(0x02100000), + 25: uint32(0x00000400), + 26: uint32(0x00000401), + 27: uint32(0x02100401), + 28: uint32(0x00100400), + 29: uint32(0x00000001), + 30: uint32(0x02000000), + 31: uint32(0x00100400), + 32: uint32(0x02000000), + 33: uint32(0x00100400), + 34: uint32(0x00100000), + 35: uint32(0x02000401), + 36: uint32(0x02000401), + 37: uint32(0x02100001), + 38: uint32(0x02100001), + 39: uint32(0x00000001), + 40: uint32(0x00100001), + 41: uint32(0x02000000), + 42: uint32(0x02000400), + 43: uint32(0x00100000), + 44: uint32(0x02100400), + 45: uint32(0x00000401), + 46: uint32(0x00100401), + 47: uint32(0x02100400), + 48: uint32(0x00000401), + 49: uint32(0x02000001), + 50: uint32(0x02100401), + 51: uint32(0x02100000), + 52: uint32(0x00100400), + 54: uint32(0x00000001), + 55: uint32(0x02100401), + 57: uint32(0x00100401), + 58: uint32(0x02100000), + 59: uint32(0x00000400), + 60: uint32(0x02000001), + 61: uint32(0x02000400), + 62: uint32(0x00000400), + 63: uint32(0x00100001), + }, + 7: { + 0: uint32(0x08000820), + 1: uint32(0x00000800), + 2: uint32(0x00020000), + 3: uint32(0x08020820), + 4: uint32(0x08000000), + 5: uint32(0x08000820), + 6: uint32(0x00000020), + 7: uint32(0x08000000), + 8: uint32(0x00020020), + 9: uint32(0x08020000), + 10: uint32(0x08020820), + 11: uint32(0x00020800), + 12: uint32(0x08020800), + 13: uint32(0x00020820), + 14: uint32(0x00000800), + 15: uint32(0x00000020), + 16: uint32(0x08020000), + 17: uint32(0x08000020), + 18: uint32(0x08000800), + 19: uint32(0x00000820), + 20: uint32(0x00020800), + 21: uint32(0x00020020), + 22: uint32(0x08020020), + 23: uint32(0x08020800), + 24: uint32(0x00000820), + 27: uint32(0x08020020), + 28: uint32(0x08000020), + 29: uint32(0x08000800), + 30: uint32(0x00020820), + 31: uint32(0x00020000), + 32: uint32(0x00020820), + 33: uint32(0x00020000), + 34: uint32(0x08020800), + 35: uint32(0x00000800), + 36: uint32(0x00000020), + 37: uint32(0x08020020), + 38: uint32(0x00000800), + 39: uint32(0x00020820), + 40: uint32(0x08000800), + 41: uint32(0x00000020), + 42: uint32(0x08000020), + 43: uint32(0x08020000), + 44: uint32(0x08020020), + 45: uint32(0x08000000), + 46: uint32(0x00020000), + 47: uint32(0x08000820), + 49: uint32(0x08020820), + 50: uint32(0x00020020), + 51: uint32(0x08000020), + 52: uint32(0x08020000), + 53: uint32(0x08000800), + 54: uint32(0x08000820), + 56: uint32(0x08020820), + 57: uint32(0x00020800), + 58: uint32(0x00020800), + 59: uint32(0x00000820), + 60: uint32(0x00000820), + 61: uint32(0x00020020), + 62: uint32(0x08000000), + 63: uint32(0x08020800), + }, +} +var _ip_maskl = [16][16]Tuint32_t{ + 0: { + 1: uint32(0x00010000), + 3: uint32(0x00010000), + 4: uint32(0x01000000), + 5: uint32(0x01010000), + 6: uint32(0x01000000), + 7: uint32(0x01010000), + 9: uint32(0x00010000), + 11: uint32(0x00010000), + 12: uint32(0x01000000), + 13: uint32(0x01010000), + 14: uint32(0x01000000), + 15: uint32(0x01010000), + }, + 1: { + 1: uint32(0x00000001), + 3: uint32(0x00000001), + 4: uint32(0x00000100), + 5: uint32(0x00000101), + 6: uint32(0x00000100), + 7: uint32(0x00000101), + 9: uint32(0x00000001), + 11: uint32(0x00000001), + 12: uint32(0x00000100), + 13: uint32(0x00000101), + 14: uint32(0x00000100), + 15: uint32(0x00000101), + }, + 2: { + 1: uint32(0x00020000), + 3: uint32(0x00020000), + 4: uint32(0x02000000), + 5: uint32(0x02020000), + 6: uint32(0x02000000), + 7: uint32(0x02020000), + 9: uint32(0x00020000), + 11: uint32(0x00020000), + 12: uint32(0x02000000), + 13: uint32(0x02020000), + 14: uint32(0x02000000), + 15: uint32(0x02020000), + }, + 3: { + 1: uint32(0x00000002), + 3: uint32(0x00000002), + 4: uint32(0x00000200), + 5: uint32(0x00000202), + 6: uint32(0x00000200), + 7: uint32(0x00000202), + 9: uint32(0x00000002), + 11: uint32(0x00000002), + 12: uint32(0x00000200), + 13: uint32(0x00000202), + 14: uint32(0x00000200), + 15: uint32(0x00000202), + }, + 4: { + 1: uint32(0x00040000), + 3: uint32(0x00040000), + 4: uint32(0x04000000), + 5: uint32(0x04040000), + 6: uint32(0x04000000), + 7: uint32(0x04040000), + 9: uint32(0x00040000), + 11: uint32(0x00040000), + 12: uint32(0x04000000), + 13: uint32(0x04040000), + 14: uint32(0x04000000), + 15: uint32(0x04040000), + }, + 5: { + 1: uint32(0x00000004), + 3: uint32(0x00000004), + 4: uint32(0x00000400), + 5: uint32(0x00000404), + 6: uint32(0x00000400), + 7: uint32(0x00000404), + 9: uint32(0x00000004), + 11: uint32(0x00000004), + 12: uint32(0x00000400), + 13: uint32(0x00000404), + 14: uint32(0x00000400), + 15: uint32(0x00000404), + }, + 6: { + 1: uint32(0x00080000), + 3: uint32(0x00080000), + 4: uint32(0x08000000), + 5: uint32(0x08080000), + 6: uint32(0x08000000), + 7: uint32(0x08080000), + 9: uint32(0x00080000), + 11: uint32(0x00080000), + 12: uint32(0x08000000), + 13: uint32(0x08080000), + 14: uint32(0x08000000), + 15: uint32(0x08080000), + }, + 7: { + 1: uint32(0x00000008), + 3: uint32(0x00000008), + 4: uint32(0x00000800), + 5: uint32(0x00000808), + 6: uint32(0x00000800), + 7: uint32(0x00000808), + 9: uint32(0x00000008), + 11: uint32(0x00000008), + 12: uint32(0x00000800), + 13: uint32(0x00000808), + 14: uint32(0x00000800), + 15: uint32(0x00000808), + }, + 8: { + 1: uint32(0x00100000), + 3: uint32(0x00100000), + 4: uint32(0x10000000), + 5: uint32(0x10100000), + 6: uint32(0x10000000), + 7: uint32(0x10100000), + 9: uint32(0x00100000), + 11: uint32(0x00100000), + 12: uint32(0x10000000), + 13: uint32(0x10100000), + 14: uint32(0x10000000), + 15: uint32(0x10100000), + }, + 9: { + 1: uint32(0x00000010), + 3: uint32(0x00000010), + 4: uint32(0x00001000), + 5: uint32(0x00001010), + 6: uint32(0x00001000), + 7: uint32(0x00001010), + 9: uint32(0x00000010), + 11: uint32(0x00000010), + 12: uint32(0x00001000), + 13: uint32(0x00001010), + 14: uint32(0x00001000), + 15: uint32(0x00001010), + }, + 10: { + 1: uint32(0x00200000), + 3: uint32(0x00200000), + 4: uint32(0x20000000), + 5: uint32(0x20200000), + 6: uint32(0x20000000), + 7: uint32(0x20200000), + 9: uint32(0x00200000), + 11: uint32(0x00200000), + 12: uint32(0x20000000), + 13: uint32(0x20200000), + 14: uint32(0x20000000), + 15: uint32(0x20200000), + }, + 11: { + 1: uint32(0x00000020), + 3: uint32(0x00000020), + 4: uint32(0x00002000), + 5: uint32(0x00002020), + 6: uint32(0x00002000), + 7: uint32(0x00002020), + 9: uint32(0x00000020), + 11: uint32(0x00000020), + 12: uint32(0x00002000), + 13: uint32(0x00002020), + 14: uint32(0x00002000), + 15: uint32(0x00002020), + }, + 12: { + 1: uint32(0x00400000), + 3: uint32(0x00400000), + 4: uint32(0x40000000), + 5: uint32(0x40400000), + 6: uint32(0x40000000), + 7: uint32(0x40400000), + 9: uint32(0x00400000), + 11: uint32(0x00400000), + 12: uint32(0x40000000), + 13: uint32(0x40400000), + 14: uint32(0x40000000), + 15: uint32(0x40400000), + }, + 13: { + 1: uint32(0x00000040), + 3: uint32(0x00000040), + 4: uint32(0x00004000), + 5: uint32(0x00004040), + 6: uint32(0x00004000), + 7: uint32(0x00004040), + 9: uint32(0x00000040), + 11: uint32(0x00000040), + 12: uint32(0x00004000), + 13: uint32(0x00004040), + 14: uint32(0x00004000), + 15: uint32(0x00004040), + }, + 14: { + 1: uint32(0x00800000), + 3: uint32(0x00800000), + 4: uint32(0x80000000), + 5: uint32(0x80800000), + 6: uint32(0x80000000), + 7: uint32(0x80800000), + 9: uint32(0x00800000), + 11: uint32(0x00800000), + 12: uint32(0x80000000), + 13: uint32(0x80800000), + 14: uint32(0x80000000), + 15: uint32(0x80800000), + }, + 15: { + 1: uint32(0x00000080), + 3: uint32(0x00000080), + 4: uint32(0x00008000), + 5: uint32(0x00008080), + 6: uint32(0x00008000), + 7: uint32(0x00008080), + 9: uint32(0x00000080), + 11: uint32(0x00000080), + 12: uint32(0x00008000), + 13: uint32(0x00008080), + 14: uint32(0x00008000), + 15: uint32(0x00008080), + }, +} +var _ip_maskr = [16][16]Tuint32_t{ + 0: { + 2: uint32(0x00010000), + 3: uint32(0x00010000), + 6: uint32(0x00010000), + 7: uint32(0x00010000), + 8: uint32(0x01000000), + 9: uint32(0x01000000), + 10: uint32(0x01010000), + 11: uint32(0x01010000), + 12: uint32(0x01000000), + 13: uint32(0x01000000), + 14: uint32(0x01010000), + 15: uint32(0x01010000), + }, + 1: { + 2: uint32(0x00000001), + 3: uint32(0x00000001), + 6: uint32(0x00000001), + 7: uint32(0x00000001), + 8: uint32(0x00000100), + 9: uint32(0x00000100), + 10: uint32(0x00000101), + 11: uint32(0x00000101), + 12: uint32(0x00000100), + 13: uint32(0x00000100), + 14: uint32(0x00000101), + 15: uint32(0x00000101), + }, + 2: { + 2: uint32(0x00020000), + 3: uint32(0x00020000), + 6: uint32(0x00020000), + 7: uint32(0x00020000), + 8: uint32(0x02000000), + 9: uint32(0x02000000), + 10: uint32(0x02020000), + 11: uint32(0x02020000), + 12: uint32(0x02000000), + 13: uint32(0x02000000), + 14: uint32(0x02020000), + 15: uint32(0x02020000), + }, + 3: { + 2: uint32(0x00000002), + 3: uint32(0x00000002), + 6: uint32(0x00000002), + 7: uint32(0x00000002), + 8: uint32(0x00000200), + 9: uint32(0x00000200), + 10: uint32(0x00000202), + 11: uint32(0x00000202), + 12: uint32(0x00000200), + 13: uint32(0x00000200), + 14: uint32(0x00000202), + 15: uint32(0x00000202), + }, + 4: { + 2: uint32(0x00040000), + 3: uint32(0x00040000), + 6: uint32(0x00040000), + 7: uint32(0x00040000), + 8: uint32(0x04000000), + 9: uint32(0x04000000), + 10: uint32(0x04040000), + 11: uint32(0x04040000), + 12: uint32(0x04000000), + 13: uint32(0x04000000), + 14: uint32(0x04040000), + 15: uint32(0x04040000), + }, + 5: { + 2: uint32(0x00000004), + 3: uint32(0x00000004), + 6: uint32(0x00000004), + 7: uint32(0x00000004), + 8: uint32(0x00000400), + 9: uint32(0x00000400), + 10: uint32(0x00000404), + 11: uint32(0x00000404), + 12: uint32(0x00000400), + 13: uint32(0x00000400), + 14: uint32(0x00000404), + 15: uint32(0x00000404), + }, + 6: { + 2: uint32(0x00080000), + 3: uint32(0x00080000), + 6: uint32(0x00080000), + 7: uint32(0x00080000), + 8: uint32(0x08000000), + 9: uint32(0x08000000), + 10: uint32(0x08080000), + 11: uint32(0x08080000), + 12: uint32(0x08000000), + 13: uint32(0x08000000), + 14: uint32(0x08080000), + 15: uint32(0x08080000), + }, + 7: { + 2: uint32(0x00000008), + 3: uint32(0x00000008), + 6: uint32(0x00000008), + 7: uint32(0x00000008), + 8: uint32(0x00000800), + 9: uint32(0x00000800), + 10: uint32(0x00000808), + 11: uint32(0x00000808), + 12: uint32(0x00000800), + 13: uint32(0x00000800), + 14: uint32(0x00000808), + 15: uint32(0x00000808), + }, + 8: { + 2: uint32(0x00100000), + 3: uint32(0x00100000), + 6: uint32(0x00100000), + 7: uint32(0x00100000), + 8: uint32(0x10000000), + 9: uint32(0x10000000), + 10: uint32(0x10100000), + 11: uint32(0x10100000), + 12: uint32(0x10000000), + 13: uint32(0x10000000), + 14: uint32(0x10100000), + 15: uint32(0x10100000), + }, + 9: { + 2: uint32(0x00000010), + 3: uint32(0x00000010), + 6: uint32(0x00000010), + 7: uint32(0x00000010), + 8: uint32(0x00001000), + 9: uint32(0x00001000), + 10: uint32(0x00001010), + 11: uint32(0x00001010), + 12: uint32(0x00001000), + 13: uint32(0x00001000), + 14: uint32(0x00001010), + 15: uint32(0x00001010), + }, + 10: { + 2: uint32(0x00200000), + 3: uint32(0x00200000), + 6: uint32(0x00200000), + 7: uint32(0x00200000), + 8: uint32(0x20000000), + 9: uint32(0x20000000), + 10: uint32(0x20200000), + 11: uint32(0x20200000), + 12: uint32(0x20000000), + 13: uint32(0x20000000), + 14: uint32(0x20200000), + 15: uint32(0x20200000), + }, + 11: { + 2: uint32(0x00000020), + 3: uint32(0x00000020), + 6: uint32(0x00000020), + 7: uint32(0x00000020), + 8: uint32(0x00002000), + 9: uint32(0x00002000), + 10: uint32(0x00002020), + 11: uint32(0x00002020), + 12: uint32(0x00002000), + 13: uint32(0x00002000), + 14: uint32(0x00002020), + 15: uint32(0x00002020), + }, + 12: { + 2: uint32(0x00400000), + 3: uint32(0x00400000), + 6: uint32(0x00400000), + 7: uint32(0x00400000), + 8: uint32(0x40000000), + 9: uint32(0x40000000), + 10: uint32(0x40400000), + 11: uint32(0x40400000), + 12: uint32(0x40000000), + 13: uint32(0x40000000), + 14: uint32(0x40400000), + 15: uint32(0x40400000), + }, + 13: { + 2: uint32(0x00000040), + 3: uint32(0x00000040), + 6: uint32(0x00000040), + 7: uint32(0x00000040), + 8: uint32(0x00004000), + 9: uint32(0x00004000), + 10: uint32(0x00004040), + 11: uint32(0x00004040), + 12: uint32(0x00004000), + 13: uint32(0x00004000), + 14: uint32(0x00004040), + 15: uint32(0x00004040), + }, + 14: { + 2: uint32(0x00800000), + 3: uint32(0x00800000), + 6: uint32(0x00800000), + 7: uint32(0x00800000), + 8: uint32(0x80000000), + 9: uint32(0x80000000), + 10: uint32(0x80800000), + 11: uint32(0x80800000), + 12: uint32(0x80000000), + 13: uint32(0x80000000), + 14: uint32(0x80800000), + 15: uint32(0x80800000), + }, + 15: { + 2: uint32(0x00000080), + 3: uint32(0x00000080), + 6: uint32(0x00000080), + 7: uint32(0x00000080), + 8: uint32(0x00008000), + 9: uint32(0x00008000), + 10: uint32(0x00008080), + 11: uint32(0x00008080), + 12: uint32(0x00008000), + 13: uint32(0x00008000), + 14: uint32(0x00008080), + 15: uint32(0x00008080), + }, +} +var _fp_maskl = [8][16]Tuint32_t{ + 0: { + 1: uint32(0x40000000), + 2: uint32(0x00400000), + 3: uint32(0x40400000), + 4: uint32(0x00004000), + 5: uint32(0x40004000), + 6: uint32(0x00404000), + 7: uint32(0x40404000), + 8: uint32(0x00000040), + 9: uint32(0x40000040), + 10: uint32(0x00400040), + 11: uint32(0x40400040), + 12: uint32(0x00004040), + 13: uint32(0x40004040), + 14: uint32(0x00404040), + 15: uint32(0x40404040), + }, + 1: { + 1: uint32(0x10000000), + 2: uint32(0x00100000), + 3: uint32(0x10100000), + 4: uint32(0x00001000), + 5: uint32(0x10001000), + 6: uint32(0x00101000), + 7: uint32(0x10101000), + 8: uint32(0x00000010), + 9: uint32(0x10000010), + 10: uint32(0x00100010), + 11: uint32(0x10100010), + 12: uint32(0x00001010), + 13: uint32(0x10001010), + 14: uint32(0x00101010), + 15: uint32(0x10101010), + }, + 2: { + 1: uint32(0x04000000), + 2: uint32(0x00040000), + 3: uint32(0x04040000), + 4: uint32(0x00000400), + 5: uint32(0x04000400), + 6: uint32(0x00040400), + 7: uint32(0x04040400), + 8: uint32(0x00000004), + 9: uint32(0x04000004), + 10: uint32(0x00040004), + 11: uint32(0x04040004), + 12: uint32(0x00000404), + 13: uint32(0x04000404), + 14: uint32(0x00040404), + 15: uint32(0x04040404), + }, + 3: { + 1: uint32(0x01000000), + 2: uint32(0x00010000), + 3: uint32(0x01010000), + 4: uint32(0x00000100), + 5: uint32(0x01000100), + 6: uint32(0x00010100), + 7: uint32(0x01010100), + 8: uint32(0x00000001), + 9: uint32(0x01000001), + 10: uint32(0x00010001), + 11: uint32(0x01010001), + 12: uint32(0x00000101), + 13: uint32(0x01000101), + 14: uint32(0x00010101), + 15: uint32(0x01010101), + }, + 4: { + 1: uint32(0x80000000), + 2: uint32(0x00800000), + 3: uint32(0x80800000), + 4: uint32(0x00008000), + 5: uint32(0x80008000), + 6: uint32(0x00808000), + 7: uint32(0x80808000), + 8: uint32(0x00000080), + 9: uint32(0x80000080), + 10: uint32(0x00800080), + 11: uint32(0x80800080), + 12: uint32(0x00008080), + 13: uint32(0x80008080), + 14: uint32(0x00808080), + 15: uint32(0x80808080), + }, + 5: { + 1: uint32(0x20000000), + 2: uint32(0x00200000), + 3: uint32(0x20200000), + 4: uint32(0x00002000), + 5: uint32(0x20002000), + 6: uint32(0x00202000), + 7: uint32(0x20202000), + 8: uint32(0x00000020), + 9: uint32(0x20000020), + 10: uint32(0x00200020), + 11: uint32(0x20200020), + 12: uint32(0x00002020), + 13: uint32(0x20002020), + 14: uint32(0x00202020), + 15: uint32(0x20202020), + }, + 6: { + 1: uint32(0x08000000), + 2: uint32(0x00080000), + 3: uint32(0x08080000), + 4: uint32(0x00000800), + 5: uint32(0x08000800), + 6: uint32(0x00080800), + 7: uint32(0x08080800), + 8: uint32(0x00000008), + 9: uint32(0x08000008), + 10: uint32(0x00080008), + 11: uint32(0x08080008), + 12: uint32(0x00000808), + 13: uint32(0x08000808), + 14: uint32(0x00080808), + 15: uint32(0x08080808), + }, + 7: { + 1: uint32(0x02000000), + 2: uint32(0x00020000), + 3: uint32(0x02020000), + 4: uint32(0x00000200), + 5: uint32(0x02000200), + 6: uint32(0x00020200), + 7: uint32(0x02020200), + 8: uint32(0x00000002), + 9: uint32(0x02000002), + 10: uint32(0x00020002), + 11: uint32(0x02020002), + 12: uint32(0x00000202), + 13: uint32(0x02000202), + 14: uint32(0x00020202), + 15: uint32(0x02020202), + }, +} +var _fp_maskr = [8][16]Tuint32_t{ + 0: { + 1: uint32(0x40000000), + 2: uint32(0x00400000), + 3: uint32(0x40400000), + 4: uint32(0x00004000), + 5: uint32(0x40004000), + 6: uint32(0x00404000), + 7: uint32(0x40404000), + 8: uint32(0x00000040), + 9: uint32(0x40000040), + 10: uint32(0x00400040), + 11: uint32(0x40400040), + 12: uint32(0x00004040), + 13: uint32(0x40004040), + 14: uint32(0x00404040), + 15: uint32(0x40404040), + }, + 1: { + 1: uint32(0x10000000), + 2: uint32(0x00100000), + 3: uint32(0x10100000), + 4: uint32(0x00001000), + 5: uint32(0x10001000), + 6: uint32(0x00101000), + 7: uint32(0x10101000), + 8: uint32(0x00000010), + 9: uint32(0x10000010), + 10: uint32(0x00100010), + 11: uint32(0x10100010), + 12: uint32(0x00001010), + 13: uint32(0x10001010), + 14: uint32(0x00101010), + 15: uint32(0x10101010), + }, + 2: { + 1: uint32(0x04000000), + 2: uint32(0x00040000), + 3: uint32(0x04040000), + 4: uint32(0x00000400), + 5: uint32(0x04000400), + 6: uint32(0x00040400), + 7: uint32(0x04040400), + 8: uint32(0x00000004), + 9: uint32(0x04000004), + 10: uint32(0x00040004), + 11: uint32(0x04040004), + 12: uint32(0x00000404), + 13: uint32(0x04000404), + 14: uint32(0x00040404), + 15: uint32(0x04040404), + }, + 3: { + 1: uint32(0x01000000), + 2: uint32(0x00010000), + 3: uint32(0x01010000), + 4: uint32(0x00000100), + 5: uint32(0x01000100), + 6: uint32(0x00010100), + 7: uint32(0x01010100), + 8: uint32(0x00000001), + 9: uint32(0x01000001), + 10: uint32(0x00010001), + 11: uint32(0x01010001), + 12: uint32(0x00000101), + 13: uint32(0x01000101), + 14: uint32(0x00010101), + 15: uint32(0x01010101), + }, + 4: { + 1: uint32(0x80000000), + 2: uint32(0x00800000), + 3: uint32(0x80800000), + 4: uint32(0x00008000), + 5: uint32(0x80008000), + 6: uint32(0x00808000), + 7: uint32(0x80808000), + 8: uint32(0x00000080), + 9: uint32(0x80000080), + 10: uint32(0x00800080), + 11: uint32(0x80800080), + 12: uint32(0x00008080), + 13: uint32(0x80008080), + 14: uint32(0x00808080), + 15: uint32(0x80808080), + }, + 5: { + 1: uint32(0x20000000), + 2: uint32(0x00200000), + 3: uint32(0x20200000), + 4: uint32(0x00002000), + 5: uint32(0x20002000), + 6: uint32(0x00202000), + 7: uint32(0x20202000), + 8: uint32(0x00000020), + 9: uint32(0x20000020), + 10: uint32(0x00200020), + 11: uint32(0x20200020), + 12: uint32(0x00002020), + 13: uint32(0x20002020), + 14: uint32(0x00202020), + 15: uint32(0x20202020), + }, + 6: { + 1: uint32(0x08000000), + 2: uint32(0x00080000), + 3: uint32(0x08080000), + 4: uint32(0x00000800), + 5: uint32(0x08000800), + 6: uint32(0x00080800), + 7: uint32(0x08080800), + 8: uint32(0x00000008), + 9: uint32(0x08000008), + 10: uint32(0x00080008), + 11: uint32(0x08080008), + 12: uint32(0x00000808), + 13: uint32(0x08000808), + 14: uint32(0x00080808), + 15: uint32(0x08080808), + }, + 7: { + 1: uint32(0x02000000), + 2: uint32(0x00020000), + 3: uint32(0x02020000), + 4: uint32(0x00000200), + 5: uint32(0x02000200), + 6: uint32(0x00020200), + 7: uint32(0x02020200), + 8: uint32(0x00000002), + 9: uint32(0x02000002), + 10: uint32(0x00020002), + 11: uint32(0x02020002), + 12: uint32(0x00000202), + 13: uint32(0x02000202), + 14: uint32(0x00020202), + 15: uint32(0x02020202), + }, +} +var _key_perm_maskl = [8][16]Tuint32_t{ + 0: { + 2: uint32(0x00000010), + 3: uint32(0x00000010), + 4: uint32(0x00001000), + 5: uint32(0x00001000), + 6: uint32(0x00001010), + 7: uint32(0x00001010), + 8: uint32(0x00100000), + 9: uint32(0x00100000), + 10: uint32(0x00100010), + 11: uint32(0x00100010), + 12: uint32(0x00101000), + 13: uint32(0x00101000), + 14: uint32(0x00101010), + 15: uint32(0x00101010), + }, + 1: { + 2: uint32(0x00000020), + 3: uint32(0x00000020), + 4: uint32(0x00002000), + 5: uint32(0x00002000), + 6: uint32(0x00002020), + 7: uint32(0x00002020), + 8: uint32(0x00200000), + 9: uint32(0x00200000), + 10: uint32(0x00200020), + 11: uint32(0x00200020), + 12: uint32(0x00202000), + 13: uint32(0x00202000), + 14: uint32(0x00202020), + 15: uint32(0x00202020), + }, + 2: { + 2: uint32(0x00000040), + 3: uint32(0x00000040), + 4: uint32(0x00004000), + 5: uint32(0x00004000), + 6: uint32(0x00004040), + 7: uint32(0x00004040), + 8: uint32(0x00400000), + 9: uint32(0x00400000), + 10: uint32(0x00400040), + 11: uint32(0x00400040), + 12: uint32(0x00404000), + 13: uint32(0x00404000), + 14: uint32(0x00404040), + 15: uint32(0x00404040), + }, + 3: { + 2: uint32(0x00000080), + 3: uint32(0x00000080), + 4: uint32(0x00008000), + 5: uint32(0x00008000), + 6: uint32(0x00008080), + 7: uint32(0x00008080), + 8: uint32(0x00800000), + 9: uint32(0x00800000), + 10: uint32(0x00800080), + 11: uint32(0x00800080), + 12: uint32(0x00808000), + 13: uint32(0x00808000), + 14: uint32(0x00808080), + 15: uint32(0x00808080), + }, + 4: { + 1: uint32(0x00000001), + 2: uint32(0x00000100), + 3: uint32(0x00000101), + 4: uint32(0x00010000), + 5: uint32(0x00010001), + 6: uint32(0x00010100), + 7: uint32(0x00010101), + 8: uint32(0x01000000), + 9: uint32(0x01000001), + 10: uint32(0x01000100), + 11: uint32(0x01000101), + 12: uint32(0x01010000), + 13: uint32(0x01010001), + 14: uint32(0x01010100), + 15: uint32(0x01010101), + }, + 5: { + 1: uint32(0x00000002), + 2: uint32(0x00000200), + 3: uint32(0x00000202), + 4: uint32(0x00020000), + 5: uint32(0x00020002), + 6: uint32(0x00020200), + 7: uint32(0x00020202), + 8: uint32(0x02000000), + 9: uint32(0x02000002), + 10: uint32(0x02000200), + 11: uint32(0x02000202), + 12: uint32(0x02020000), + 13: uint32(0x02020002), + 14: uint32(0x02020200), + 15: uint32(0x02020202), + }, + 6: { + 1: uint32(0x00000004), + 2: uint32(0x00000400), + 3: uint32(0x00000404), + 4: uint32(0x00040000), + 5: uint32(0x00040004), + 6: uint32(0x00040400), + 7: uint32(0x00040404), + 8: uint32(0x04000000), + 9: uint32(0x04000004), + 10: uint32(0x04000400), + 11: uint32(0x04000404), + 12: uint32(0x04040000), + 13: uint32(0x04040004), + 14: uint32(0x04040400), + 15: uint32(0x04040404), + }, + 7: { + 1: uint32(0x00000008), + 2: uint32(0x00000800), + 3: uint32(0x00000808), + 4: uint32(0x00080000), + 5: uint32(0x00080008), + 6: uint32(0x00080800), + 7: uint32(0x00080808), + 8: uint32(0x08000000), + 9: uint32(0x08000008), + 10: uint32(0x08000800), + 11: uint32(0x08000808), + 12: uint32(0x08080000), + 13: uint32(0x08080008), + 14: uint32(0x08080800), + 15: uint32(0x08080808), + }, +} +var _key_perm_maskr = [12][16]Tuint32_t{ + 0: { + 1: uint32(0x00000001), + 3: uint32(0x00000001), + 5: uint32(0x00000001), + 7: uint32(0x00000001), + 9: uint32(0x00000001), + 11: uint32(0x00000001), + 13: uint32(0x00000001), + 15: uint32(0x00000001), + }, + 1: { + 2: uint32(0x00100000), + 3: uint32(0x00100000), + 4: uint32(0x00001000), + 5: uint32(0x00001000), + 6: uint32(0x00101000), + 7: uint32(0x00101000), + 8: uint32(0x00000010), + 9: uint32(0x00000010), + 10: uint32(0x00100010), + 11: uint32(0x00100010), + 12: uint32(0x00001010), + 13: uint32(0x00001010), + 14: uint32(0x00101010), + 15: uint32(0x00101010), + }, + 2: { + 1: uint32(0x00000002), + 3: uint32(0x00000002), + 5: uint32(0x00000002), + 7: uint32(0x00000002), + 9: uint32(0x00000002), + 11: uint32(0x00000002), + 13: uint32(0x00000002), + 15: uint32(0x00000002), + }, + 3: { + 2: uint32(0x00200000), + 3: uint32(0x00200000), + 4: uint32(0x00002000), + 5: uint32(0x00002000), + 6: uint32(0x00202000), + 7: uint32(0x00202000), + 8: uint32(0x00000020), + 9: uint32(0x00000020), + 10: uint32(0x00200020), + 11: uint32(0x00200020), + 12: uint32(0x00002020), + 13: uint32(0x00002020), + 14: uint32(0x00202020), + 15: uint32(0x00202020), + }, + 4: { + 1: uint32(0x00000004), + 3: uint32(0x00000004), + 5: uint32(0x00000004), + 7: uint32(0x00000004), + 9: uint32(0x00000004), + 11: uint32(0x00000004), + 13: uint32(0x00000004), + 15: uint32(0x00000004), + }, + 5: { + 2: uint32(0x00400000), + 3: uint32(0x00400000), + 4: uint32(0x00004000), + 5: uint32(0x00004000), + 6: uint32(0x00404000), + 7: uint32(0x00404000), + 8: uint32(0x00000040), + 9: uint32(0x00000040), + 10: uint32(0x00400040), + 11: uint32(0x00400040), + 12: uint32(0x00004040), + 13: uint32(0x00004040), + 14: uint32(0x00404040), + 15: uint32(0x00404040), + }, + 6: { + 1: uint32(0x00000008), + 3: uint32(0x00000008), + 5: uint32(0x00000008), + 7: uint32(0x00000008), + 9: uint32(0x00000008), + 11: uint32(0x00000008), + 13: uint32(0x00000008), + 15: uint32(0x00000008), + }, + 7: { + 2: uint32(0x00800000), + 3: uint32(0x00800000), + 4: uint32(0x00008000), + 5: uint32(0x00008000), + 6: uint32(0x00808000), + 7: uint32(0x00808000), + 8: uint32(0x00000080), + 9: uint32(0x00000080), + 10: uint32(0x00800080), + 11: uint32(0x00800080), + 12: uint32(0x00008080), + 13: uint32(0x00008080), + 14: uint32(0x00808080), + 15: uint32(0x00808080), + }, + 8: { + 2: uint32(0x01000000), + 3: uint32(0x01000000), + 4: uint32(0x00010000), + 5: uint32(0x00010000), + 6: uint32(0x01010000), + 7: uint32(0x01010000), + 8: uint32(0x00000100), + 9: uint32(0x00000100), + 10: uint32(0x01000100), + 11: uint32(0x01000100), + 12: uint32(0x00010100), + 13: uint32(0x00010100), + 14: uint32(0x01010100), + 15: uint32(0x01010100), + }, + 9: { + 2: uint32(0x02000000), + 3: uint32(0x02000000), + 4: uint32(0x00020000), + 5: uint32(0x00020000), + 6: uint32(0x02020000), + 7: uint32(0x02020000), + 8: uint32(0x00000200), + 9: uint32(0x00000200), + 10: uint32(0x02000200), + 11: uint32(0x02000200), + 12: uint32(0x00020200), + 13: uint32(0x00020200), + 14: uint32(0x02020200), + 15: uint32(0x02020200), + }, + 10: { + 2: uint32(0x04000000), + 3: uint32(0x04000000), + 4: uint32(0x00040000), + 5: uint32(0x00040000), + 6: uint32(0x04040000), + 7: uint32(0x04040000), + 8: uint32(0x00000400), + 9: uint32(0x00000400), + 10: uint32(0x04000400), + 11: uint32(0x04000400), + 12: uint32(0x00040400), + 13: uint32(0x00040400), + 14: uint32(0x04040400), + 15: uint32(0x04040400), + }, + 11: { + 2: uint32(0x08000000), + 3: uint32(0x08000000), + 4: uint32(0x00080000), + 5: uint32(0x00080000), + 6: uint32(0x08080000), + 7: uint32(0x08080000), + 8: uint32(0x00000800), + 9: uint32(0x00000800), + 10: uint32(0x08000800), + 11: uint32(0x08000800), + 12: uint32(0x00080800), + 13: uint32(0x00080800), + 14: uint32(0x08080800), + 15: uint32(0x08080800), + }, +} +var _comp_maskl0 = [4][8]Tuint32_t{ + 0: { + 1: uint32(0x00020000), + 2: uint32(0x00000001), + 3: uint32(0x00020001), + 4: uint32(0x00080000), + 5: uint32(0x000a0000), + 6: uint32(0x00080001), + 7: uint32(0x000a0001), + }, + 1: { + 1: uint32(0x00001000), + 3: uint32(0x00001000), + 4: uint32(0x00000040), + 5: uint32(0x00001040), + 6: uint32(0x00000040), + 7: uint32(0x00001040), + }, + 2: { + 1: uint32(0x00400000), + 2: uint32(0x00000020), + 3: uint32(0x00400020), + 4: uint32(0x00008000), + 5: uint32(0x00408000), + 6: uint32(0x00008020), + 7: uint32(0x00408020), + }, + 3: { + 1: uint32(0x00100000), + 2: uint32(0x00000800), + 3: uint32(0x00100800), + 5: uint32(0x00100000), + 6: uint32(0x00000800), + 7: uint32(0x00100800), + }, +} +var _comp_maskr0 = [4][8]Tuint32_t{ + 0: { + 1: uint32(0x00200000), + 2: uint32(0x00020000), + 3: uint32(0x00220000), + 4: uint32(0x00000002), + 5: uint32(0x00200002), + 6: uint32(0x00020002), + 7: uint32(0x00220002), + }, + 1: { + 2: uint32(0x00100000), + 3: uint32(0x00100000), + 4: uint32(0x00000004), + 5: uint32(0x00000004), + 6: uint32(0x00100004), + 7: uint32(0x00100004), + }, + 2: { + 1: uint32(0x00004000), + 2: uint32(0x00000800), + 3: uint32(0x00004800), + 5: uint32(0x00004000), + 6: uint32(0x00000800), + 7: uint32(0x00004800), + }, + 3: { + 1: uint32(0x00400000), + 2: uint32(0x00008000), + 3: uint32(0x00408000), + 4: uint32(0x00000008), + 5: uint32(0x00400008), + 6: uint32(0x00008008), + 7: uint32(0x00408008), + }, +} +var _comp_maskl1 = [4][16]Tuint32_t{ + 0: { + 1: uint32(0x00000010), + 2: uint32(0x00004000), + 3: uint32(0x00004010), + 4: uint32(0x00040000), + 5: uint32(0x00040010), + 6: uint32(0x00044000), + 7: uint32(0x00044010), + 8: uint32(0x00000100), + 9: uint32(0x00000110), + 10: uint32(0x00004100), + 11: uint32(0x00004110), + 12: uint32(0x00040100), + 13: uint32(0x00040110), + 14: uint32(0x00044100), + 15: uint32(0x00044110), + }, + 1: { + 1: uint32(0x00800000), + 2: uint32(0x00000002), + 3: uint32(0x00800002), + 4: uint32(0x00000200), + 5: uint32(0x00800200), + 6: uint32(0x00000202), + 7: uint32(0x00800202), + 8: uint32(0x00200000), + 9: uint32(0x00a00000), + 10: uint32(0x00200002), + 11: uint32(0x00a00002), + 12: uint32(0x00200200), + 13: uint32(0x00a00200), + 14: uint32(0x00200202), + 15: uint32(0x00a00202), + }, + 2: { + 1: uint32(0x00002000), + 2: uint32(0x00000004), + 3: uint32(0x00002004), + 4: uint32(0x00000400), + 5: uint32(0x00002400), + 6: uint32(0x00000404), + 7: uint32(0x00002404), + 9: uint32(0x00002000), + 10: uint32(0x00000004), + 11: uint32(0x00002004), + 12: uint32(0x00000400), + 13: uint32(0x00002400), + 14: uint32(0x00000404), + 15: uint32(0x00002404), + }, + 3: { + 1: uint32(0x00010000), + 2: uint32(0x00000008), + 3: uint32(0x00010008), + 4: uint32(0x00000080), + 5: uint32(0x00010080), + 6: uint32(0x00000088), + 7: uint32(0x00010088), + 9: uint32(0x00010000), + 10: uint32(0x00000008), + 11: uint32(0x00010008), + 12: uint32(0x00000080), + 13: uint32(0x00010080), + 14: uint32(0x00000088), + 15: uint32(0x00010088), + }, +} +var _comp_maskr1 = [4][16]Tuint32_t{ + 0: { + 2: uint32(0x00000080), + 3: uint32(0x00000080), + 4: uint32(0x00002000), + 5: uint32(0x00002000), + 6: uint32(0x00002080), + 7: uint32(0x00002080), + 8: uint32(0x00000001), + 9: uint32(0x00000001), + 10: uint32(0x00000081), + 11: uint32(0x00000081), + 12: uint32(0x00002001), + 13: uint32(0x00002001), + 14: uint32(0x00002081), + 15: uint32(0x00002081), + }, + 1: { + 1: uint32(0x00000010), + 2: uint32(0x00800000), + 3: uint32(0x00800010), + 4: uint32(0x00010000), + 5: uint32(0x00010010), + 6: uint32(0x00810000), + 7: uint32(0x00810010), + 8: uint32(0x00000200), + 9: uint32(0x00000210), + 10: uint32(0x00800200), + 11: uint32(0x00800210), + 12: uint32(0x00010200), + 13: uint32(0x00010210), + 14: uint32(0x00810200), + 15: uint32(0x00810210), + }, + 2: { + 1: uint32(0x00000400), + 2: uint32(0x00001000), + 3: uint32(0x00001400), + 4: uint32(0x00080000), + 5: uint32(0x00080400), + 6: uint32(0x00081000), + 7: uint32(0x00081400), + 8: uint32(0x00000020), + 9: uint32(0x00000420), + 10: uint32(0x00001020), + 11: uint32(0x00001420), + 12: uint32(0x00080020), + 13: uint32(0x00080420), + 14: uint32(0x00081020), + 15: uint32(0x00081420), + }, + 3: { + 1: uint32(0x00000100), + 2: uint32(0x00040000), + 3: uint32(0x00040100), + 5: uint32(0x00000100), + 6: uint32(0x00040000), + 7: uint32(0x00040100), + 8: uint32(0x00000040), + 9: uint32(0x00000140), + 10: uint32(0x00040040), + 11: uint32(0x00040140), + 12: uint32(0x00000040), + 13: uint32(0x00000140), + 14: uint32(0x00040040), + 15: uint32(0x00040140), + }, +} + +var _ascii64 = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +/* 0000000000111111111122222222223333333333444444444455555555556666 */ +/* 0123456789012345678901234567890123456789012345678901234567890123 */ + +// C documentation +// +// /* +// * We match the behavior of UFC-crypt on systems where "char" is signed by +// * default (the majority), regardless of char's signedness on our system. +// */ +func _ascii_to_bin(tls *TLS, ch int32) (r Tuint32_t) { + var retval, sch, v1 int32 + _, _, _ = retval, sch, v1 + if ch < int32(0x80) { + v1 = ch + } else { + v1 = -(int32(0x100) - ch) + } + sch = v1 + retval = sch - int32('.') + if sch >= int32('A') { + retval = sch - (Int32FromUint8('A') - Int32FromInt32(12)) + if sch >= int32('a') { + retval = sch - (Int32FromUint8('a') - Int32FromInt32(38)) + } + } + retval = retval & int32(0x3f) + return Uint32FromInt32(retval) +} + +// C documentation +// +// /* +// * When we choose to "support" invalid salts, nevertheless disallow those +// * containing characters that would violate the passwd file format. +// */ +func _ascii_is_unsafe(tls *TLS, ch uint8) (r int32) { + return BoolInt32(!(ch != 0) || Int32FromUint8(ch) == int32('\n') || Int32FromUint8(ch) == int32(':')) +} + +func _setup_salt(tls *TLS, salt Tuint32_t) (r Tuint32_t) { + var i uint32 + var obit, saltbit, saltbits Tuint32_t + _, _, _, _ = i, obit, saltbit, saltbits + saltbits = uint32(0) + saltbit = uint32(1) + obit = uint32(0x800000) + i = uint32(0) + for { + if !(i < uint32(24)) { + break + } + if salt&saltbit != 0 { + saltbits = saltbits | obit + } + saltbit = saltbit << uint32(1) + obit = obit >> uint32(1) + goto _1 + _1: + ; + i = i + 1 + } + return saltbits +} + +func X__des_setkey(tls *TLS, key uintptr, ekey uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v ekey=%v, (%v:)", tls, key, ekey, origin(2)) + } + var i, ibit, j, round, shifts uint32 + var k0, k1, kl, kr, rawkey0, rawkey1, t0, t1, v1 Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, ibit, j, k0, k1, kl, kr, rawkey0, rawkey1, round, shifts, t0, t1, v1 + rawkey0 = uint32(**(**uint8)(__ccgo_up(key + 3))) | uint32(**(**uint8)(__ccgo_up(key + 2)))<>ibit&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_key_perm_maskl)) + uintptr(i+uint32(4))*64 + uintptr(rawkey1>>ibit&uint32(0xf))*4))) + k1 = k1 | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_key_perm_maskr)) + uintptr(j)*64 + uintptr(rawkey0>>ibit&uint32(0xf))*4)) + ibit = ibit - uint32(4) + k1 = k1 | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_key_perm_maskr)) + uintptr(j+uint32(1))*64 + uintptr(rawkey0>>ibit&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_key_perm_maskr)) + uintptr(i+uint32(8))*64 + uintptr(rawkey1>>ibit&uint32(0xf))*4))) + goto _2 + _2: + ; + i = i + 1 + ibit = ibit - uint32(4) + } + /* + * Rotate subkeys and do compression permutation. + */ + shifts = uint32(0) + round = uint32(0) + for { + if !(round < uint32(16)) { + break + } + shifts = shifts + uint32(_key_shifts[round]) + t0 = k0<>(Uint32FromInt32(28)-shifts) + t1 = k1<>(Uint32FromInt32(28)-shifts) + v1 = Uint32FromInt32(0) + kr = v1 + kl = v1 + ibit = uint32(25) + i = uint32(0) + for { + if !(i < uint32(4)) { + break + } + kl = kl | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_comp_maskl0)) + uintptr(i)*32 + uintptr(t0>>ibit&uint32(7))*4)) + kr = kr | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_comp_maskr0)) + uintptr(i)*32 + uintptr(t1>>ibit&uint32(7))*4)) + ibit = ibit - uint32(4) + kl = kl | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_comp_maskl1)) + uintptr(i)*64 + uintptr(t0>>ibit&uint32(0xf))*4)) + kr = kr | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_comp_maskr1)) + uintptr(i)*64 + uintptr(t1>>ibit&uint32(0xf))*4)) + ibit = ibit - uint32(3) + goto _5 + _5: + ; + i = i + 1 + } + **(**Tuint32_t)(__ccgo_up(ekey + uintptr(round)*4)) = kl + **(**Tuint32_t)(__ccgo_up(ekey + 64 + uintptr(round)*4)) = kr + goto _3 + _3: + ; + round = round + 1 + } +} + +// C documentation +// +// /* +// * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. +// */ +func X__do_des(tls *TLS, l_in Tuint32_t, r_in Tuint32_t, l_out uintptr, r_out uintptr, count Tuint32_t, saltbits Tuint32_t, ekey uintptr) { + if __ccgo_strace { + trc("tls=%v l_in=%v r_in=%v l_out=%v r_out=%v count=%v saltbits=%v ekey=%v, (%v:)", tls, l_in, r_in, l_out, r_out, count, saltbits, ekey, origin(2)) + } + var f, l, lo, r, r48l, r48r, ro, v1 Tuint32_t + var i, i1, ibit, ibit1, round, v4 uint32 + var kl, kr, v5 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = f, i, i1, ibit, ibit1, kl, kr, l, lo, r, r48l, r48r, ro, round, v1, v4, v5 + /* + * Do initial permutation (IP). + */ + v1 = Uint32FromInt32(0) + r = v1 + l = v1 + if l_in|r_in != 0 { + i = uint32(0) + ibit = Uint32FromInt32(28) + for { + if !(i < uint32(8)) { + break + } + l = l | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_ip_maskl)) + uintptr(i)*64 + uintptr(l_in>>ibit&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_ip_maskl)) + uintptr(i+uint32(8))*64 + uintptr(r_in>>ibit&uint32(0xf))*4))) + r = r | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_ip_maskr)) + uintptr(i)*64 + uintptr(l_in>>ibit&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_ip_maskr)) + uintptr(i+uint32(8))*64 + uintptr(r_in>>ibit&uint32(0xf))*4))) + goto _2 + _2: + ; + i = i + 1 + ibit = ibit - uint32(4) + } + } + for { + v1 = count + count = count - 1 + if !(v1 != 0) { + break + } + /* + * Do each round. + */ + round = uint32(16) + kl = ekey + kr = ekey + 64 + for { + v4 = round + round = round - 1 + if !(v4 != 0) { + break + } + /* + * Expand R to 48 bits (simulate the E-box). + */ + r48l = r&uint32(0x00000001)<>int32(9) | r&uint32(0x1f800000)>>int32(11) | r&uint32(0x01f80000)>>int32(13) | r&uint32(0x001f8000)>>int32(15) + r48r = r&uint32(0x0001f800)<>int32(31) + /* + * Do salting for crypt() and friends, and + * XOR with the permuted key. + */ + f = (r48l ^ r48r) & saltbits + v5 = kl + kl += 4 + r48l = r48l ^ (f ^ **(**Tuint32_t)(__ccgo_up(v5))) + v5 = kr + kr += 4 + r48r = r48r ^ (f ^ **(**Tuint32_t)(__ccgo_up(v5))) + /* + * Do S-box lookups (which shrink it back to 32 bits) + * and do the P-box permutation at the same time. + */ + f = **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + uintptr(r48l>>int32(18))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 1*256 + uintptr(r48l>>Int32FromInt32(12)&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 2*256 + uintptr(r48l>>Int32FromInt32(6)&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 3*256 + uintptr(r48l&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 4*256 + uintptr(r48r>>int32(18))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 5*256 + uintptr(r48r>>Int32FromInt32(12)&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 6*256 + uintptr(r48r>>Int32FromInt32(6)&uint32(0x3f))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_psbox)) + 7*256 + uintptr(r48r&uint32(0x3f))*4)) + /* + * Now that we've permuted things, complete f(). + */ + f = f ^ l + l = r + r = f + } + r = l + l = f + } + /* + * Do final permutation (inverse of IP). + */ + v1 = Uint32FromInt32(0) + ro = v1 + lo = v1 + i1 = uint32(0) + ibit1 = Uint32FromInt32(28) + for { + if !(i1 < uint32(4)) { + break + } + ro = ro | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_fp_maskr)) + uintptr(i1)*64 + uintptr(l>>ibit1&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_fp_maskr)) + uintptr(i1+uint32(4))*64 + uintptr(r>>ibit1&uint32(0xf))*4))) + ibit1 = ibit1 - uint32(4) + lo = lo | (**(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_fp_maskl)) + uintptr(i1)*64 + uintptr(l>>ibit1&uint32(0xf))*4)) | **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&_fp_maskl)) + uintptr(i1+uint32(4))*64 + uintptr(r>>ibit1&uint32(0xf))*4))) + goto _8 + _8: + ; + i1 = i1 + 1 + ibit1 = ibit1 - uint32(4) + } + **(**Tuint32_t)(__ccgo_up(l_out)) = lo + **(**Tuint32_t)(__ccgo_up(r_out)) = ro +} + +func _des_cipher(tls *TLS, in uintptr, out uintptr, count Tuint32_t, saltbits Tuint32_t, ekey uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var rawl, rawr Tuint32_t + var _ /* l_out at bp+0 */ Tuint32_t + var _ /* r_out at bp+4 */ Tuint32_t + _, _ = rawl, rawr + rawl = uint32(**(**uint8)(__ccgo_up(in + 3))) | uint32(**(**uint8)(__ccgo_up(in + 2)))<> int32(24)) + **(**uint8)(__ccgo_up(out + 1)) = uint8(**(**Tuint32_t)(__ccgo_up(bp)) >> int32(16)) + **(**uint8)(__ccgo_up(out + 2)) = uint8(**(**Tuint32_t)(__ccgo_up(bp)) >> int32(8)) + **(**uint8)(__ccgo_up(out + 3)) = uint8(**(**Tuint32_t)(__ccgo_up(bp))) + **(**uint8)(__ccgo_up(out + 4)) = uint8(**(**Tuint32_t)(__ccgo_up(bp + 4)) >> int32(24)) + **(**uint8)(__ccgo_up(out + 5)) = uint8(**(**Tuint32_t)(__ccgo_up(bp + 4)) >> int32(16)) + **(**uint8)(__ccgo_up(out + 6)) = uint8(**(**Tuint32_t)(__ccgo_up(bp + 4)) >> int32(8)) + **(**uint8)(__ccgo_up(out + 7)) = uint8(**(**Tuint32_t)(__ccgo_up(bp + 4))) +} + +func __crypt_extended_r_uut(tls *TLS, _key uintptr, _setting uintptr, output uintptr) (r uintptr) { + bp := tls.Alloc(144) + defer tls.Free(144) + var count, l, salt, value, value1 Tuint32_t + var i uint32 + var key, p, q, setting, v1, v4, v5 uintptr + var _ /* ekey at bp+0 */ Texpanded_key + var _ /* keybuf at bp+128 */ [8]uint8 + var _ /* r0 at bp+136 */ Tuint32_t + var _ /* r1 at bp+140 */ Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _ = count, i, key, l, p, q, salt, setting, value, value1, v1, v4, v5 + key = _key + setting = _setting + /* + * Copy the key, shifting each character left by one bit and padding + * with zeroes. + */ + q = bp + 128 + for q <= bp+128+uintptr(Uint64FromInt64(8)-Uint64FromInt32(1)) { + v1 = q + q = q + 1 + **(**uint8)(__ccgo_up(v1)) = Uint8FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(key))) << int32(1)) + if **(**uint8)(__ccgo_up(key)) != 0 { + key = key + 1 + } + } + X__des_setkey(tls, bp+128, bp) + if Int32FromUint8(**(**uint8)(__ccgo_up(setting))) == int32('_') { + /* + * "new"-style: + * setting - underscore, 4 chars of count, 4 chars of salt + * key - unlimited characters + */ + i = uint32(1) + count = Uint32FromInt32(0) + for { + if !(i < uint32(5)) { + break + } + value = _ascii_to_bin(tls, Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(i))))) + if Int32FromUint8(_ascii64[value]) != Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(i)))) { + return UintptrFromInt32(0) + } + count = count | value<<((i-uint32(1))*uint32(6)) + goto _2 + _2: + ; + i = i + 1 + } + if !(count != 0) { + return UintptrFromInt32(0) + } + i = uint32(5) + salt = Uint32FromInt32(0) + for { + if !(i < uint32(9)) { + break + } + value1 = _ascii_to_bin(tls, Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(i))))) + if Int32FromUint8(_ascii64[value1]) != Int32FromUint8(**(**uint8)(__ccgo_up(setting + uintptr(i)))) { + return UintptrFromInt32(0) + } + salt = salt | value1<<((i-uint32(5))*uint32(6)) + goto _3 + _3: + ; + i = i + 1 + } + for **(**uint8)(__ccgo_up(key)) != 0 { + /* + * Encrypt the key with itself. + */ + _des_cipher(tls, bp+128, bp+128, uint32(1), uint32(0), bp) + /* + * And XOR with the next 8 characters of the key. + */ + q = bp + 128 + for q <= bp+128+uintptr(Uint64FromInt64(8)-Uint64FromInt32(1)) && **(**uint8)(__ccgo_up(key)) != 0 { + v4 = q + q = q + 1 + v1 = v4 + v5 = key + key = key + 1 + *(*uint8)(unsafe.Pointer(v1)) = uint8(int32(*(*uint8)(unsafe.Pointer(v1))) ^ Int32FromUint8(**(**uint8)(__ccgo_up(v5)))<> int32(8) + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(18)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(12)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(6)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l&uint32(0x3f)] + l = **(**Tuint32_t)(__ccgo_up(bp + 136))<>Int32FromInt32(16)&uint32(0xffff) + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(18)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(12)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(6)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l&uint32(0x3f)] + l = **(**Tuint32_t)(__ccgo_up(bp + 140)) << int32(2) + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(12)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l>>Int32FromInt32(6)&uint32(0x3f)] + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = _ascii64[l&uint32(0x3f)] + **(**uint8)(__ccgo_up(p)) = uint8(0) + return output +} + +func X__crypt_des(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v setting=%v output=%v, (%v:)", tls, key, setting, output, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var p, retval, test_hash, test_key, test_setting, v1 uintptr + var _ /* test_buf at bp+0 */ [21]uint8 + _, _, _, _, _, _ = p, retval, test_hash, test_key, test_setting, v1 + test_key = __ccgo_ts + 72 + test_setting = __ccgo_ts + 93 + test_hash = __ccgo_ts + 103 + if Int32FromUint8(**(**uint8)(__ccgo_up(setting))) != int32('_') { + test_setting = __ccgo_ts + 124 + test_hash = __ccgo_ts + 127 + } + /* + * Hash the supplied password. + */ + retval = __crypt_extended_r_uut(tls, key, setting, output) + /* + * Perform a quick self-test. It is important that we make both calls + * to _crypt_extended_r_uut() from the same scope such that they likely + * use the same stack locations, which makes the second call overwrite + * the first call's sensitive data on the stack and makes it more + * likely that any alignment related issues would be detected. + */ + p = __crypt_extended_r_uut(tls, test_key, test_setting, bp) + if p != 0 && !(Xstrcmp(tls, p, test_hash) != 0) && retval != 0 { + return retval + } + if Int32FromUint8(**(**uint8)(__ccgo_up(setting))) == int32('*') { + v1 = __ccgo_ts + 141 + } else { + v1 = __ccgo_ts + 70 + } + return v1 +} + +const KEY_MAX = 30000 +const SALT_MAX = 8 + +/* public domain md5 implementation based on rfc1321 and libtomcrypt */ + +type Tmd5 = struct { + Flen1 Tuint64_t + Fh [4]Tuint32_t + Fbuf [64]Tuint8_t +} + +func _rol(tls *TLS, n Tuint32_t, k int32) (r Tuint32_t) { + return n<>(Int32FromInt32(32)-k) +} + +var _tab = [64]Tuint32_t{ + 0: uint32(0xd76aa478), + 1: uint32(0xe8c7b756), + 2: uint32(0x242070db), + 3: uint32(0xc1bdceee), + 4: uint32(0xf57c0faf), + 5: uint32(0x4787c62a), + 6: uint32(0xa8304613), + 7: uint32(0xfd469501), + 8: uint32(0x698098d8), + 9: uint32(0x8b44f7af), + 10: uint32(0xffff5bb1), + 11: uint32(0x895cd7be), + 12: uint32(0x6b901122), + 13: uint32(0xfd987193), + 14: uint32(0xa679438e), + 15: uint32(0x49b40821), + 16: uint32(0xf61e2562), + 17: uint32(0xc040b340), + 18: uint32(0x265e5a51), + 19: uint32(0xe9b6c7aa), + 20: uint32(0xd62f105d), + 21: uint32(0x02441453), + 22: uint32(0xd8a1e681), + 23: uint32(0xe7d3fbc8), + 24: uint32(0x21e1cde6), + 25: uint32(0xc33707d6), + 26: uint32(0xf4d50d87), + 27: uint32(0x455a14ed), + 28: uint32(0xa9e3e905), + 29: uint32(0xfcefa3f8), + 30: uint32(0x676f02d9), + 31: uint32(0x8d2a4c8a), + 32: uint32(0xfffa3942), + 33: uint32(0x8771f681), + 34: uint32(0x6d9d6122), + 35: uint32(0xfde5380c), + 36: uint32(0xa4beea44), + 37: uint32(0x4bdecfa9), + 38: uint32(0xf6bb4b60), + 39: uint32(0xbebfbc70), + 40: uint32(0x289b7ec6), + 41: uint32(0xeaa127fa), + 42: uint32(0xd4ef3085), + 43: uint32(0x04881d05), + 44: uint32(0xd9d4d039), + 45: uint32(0xe6db99e5), + 46: uint32(0x1fa27cf8), + 47: uint32(0xc4ac5665), + 48: uint32(0xf4292244), + 49: uint32(0x432aff97), + 50: uint32(0xab9423a7), + 51: uint32(0xfc93a039), + 52: uint32(0x655b59c3), + 53: uint32(0x8f0ccc92), + 54: uint32(0xffeff47d), + 55: uint32(0x85845dd1), + 56: uint32(0x6fa87e4f), + 57: uint32(0xfe2ce6e0), + 58: uint32(0xa3014314), + 59: uint32(0x4e0811a1), + 60: uint32(0xf7537e82), + 61: uint32(0xbd3af235), + 62: uint32(0x2ad7d2bb), + 63: uint32(0xeb86d391), +} + +func _processblock(tls *TLS, s uintptr, buf uintptr) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, b, c, d, i Tuint32_t + var _ /* W at bp+0 */ [16]Tuint32_t + _, _, _, _, _ = a, b, c, d, i + i = uint32(0) + for { + if !(i < uint32(16)) { + break + } + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] = uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(uint32(4)*i)))) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(uint32(4)*i+uint32(1))))) << int32(8) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(uint32(4)*i+uint32(2))))) << int32(16) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(uint32(4)*i+uint32(3))))) << int32(24) + goto _1 + _1: + ; + i = i + 1 + } + a = **(**Tuint32_t)(__ccgo_up(s + 8)) + b = **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) + c = **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) + d = **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) + i = uint32(0) + for i < uint32(16) { + a = a + (d ^ b&(c^d) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] + _tab[i]) + a = _rol(tls, a, int32(7)) + b + i = i + 1 + d = d + (c ^ a&(b^c) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] + _tab[i]) + d = _rol(tls, d, int32(12)) + a + i = i + 1 + c = c + (b ^ d&(a^b) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] + _tab[i]) + c = _rol(tls, c, int32(17)) + d + i = i + 1 + b = b + (a ^ c&(d^a) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[i] + _tab[i]) + b = _rol(tls, b, int32(22)) + c + i = i + 1 + } + for i < uint32(32) { + a = a + (c ^ d&(c^b) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(5)*i+uint32(1))%uint32(16)] + _tab[i]) + a = _rol(tls, a, int32(5)) + b + i = i + 1 + d = d + (b ^ c&(b^a) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(5)*i+uint32(1))%uint32(16)] + _tab[i]) + d = _rol(tls, d, int32(9)) + a + i = i + 1 + c = c + (a ^ b&(a^d) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(5)*i+uint32(1))%uint32(16)] + _tab[i]) + c = _rol(tls, c, int32(14)) + d + i = i + 1 + b = b + (d ^ a&(d^c) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(5)*i+uint32(1))%uint32(16)] + _tab[i]) + b = _rol(tls, b, int32(20)) + c + i = i + 1 + } + for i < uint32(48) { + a = a + (b ^ c ^ d + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(3)*i+uint32(5))%uint32(16)] + _tab[i]) + a = _rol(tls, a, int32(4)) + b + i = i + 1 + d = d + (a ^ b ^ c + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(3)*i+uint32(5))%uint32(16)] + _tab[i]) + d = _rol(tls, d, int32(11)) + a + i = i + 1 + c = c + (d ^ a ^ b + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(3)*i+uint32(5))%uint32(16)] + _tab[i]) + c = _rol(tls, c, int32(16)) + d + i = i + 1 + b = b + (c ^ d ^ a + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[(uint32(3)*i+uint32(5))%uint32(16)] + _tab[i]) + b = _rol(tls, b, int32(23)) + c + i = i + 1 + } + for i < uint32(64) { + a = a + (c ^ (b | ^d) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[uint32(7)*i%uint32(16)] + _tab[i]) + a = _rol(tls, a, int32(6)) + b + i = i + 1 + d = d + (b ^ (a | ^c) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[uint32(7)*i%uint32(16)] + _tab[i]) + d = _rol(tls, d, int32(10)) + a + i = i + 1 + c = c + (a ^ (d | ^b) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[uint32(7)*i%uint32(16)] + _tab[i]) + c = _rol(tls, c, int32(15)) + d + i = i + 1 + b = b + (d ^ (c | ^a) + (**(**[16]Tuint32_t)(__ccgo_up(bp)))[uint32(7)*i%uint32(16)] + _tab[i]) + b = _rol(tls, b, int32(21)) + c + i = i + 1 + } + **(**Tuint32_t)(__ccgo_up(s + 8)) += a + **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) += b + **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) += c + **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) += d +} + +func _pad(tls *TLS, s uintptr) { + var r, v1 uint32 + _, _ = r, v1 + r = uint32((*Tmd5)(unsafe.Pointer(s)).Flen1 % uint64(64)) + v1 = r + r = r + 1 + **(**Tuint8_t)(__ccgo_up(s + 24 + uintptr(v1))) = uint8(0x80) + if r > uint32(56) { + Xmemset(tls, s+24+uintptr(r), 0, uint64(uint32(64)-r)) + r = uint32(0) + _processblock(tls, s, s+24) + } + Xmemset(tls, s+24+uintptr(r), 0, uint64(uint32(56)-r)) + **(**Tuint64_t)(__ccgo_up(s)) *= uint64(8) + **(**Tuint8_t)(__ccgo_up(s + 24 + 56)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1) + **(**Tuint8_t)(__ccgo_up(s + 24 + 57)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(8)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 58)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(16)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 59)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(24)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 60)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(32)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 61)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(40)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 62)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(48)) + **(**Tuint8_t)(__ccgo_up(s + 24 + 63)) = uint8((*Tmd5)(unsafe.Pointer(s)).Flen1 >> int32(56)) + _processblock(tls, s, s+24) +} + +func _md5_init(tls *TLS, s uintptr) { + (*Tmd5)(unsafe.Pointer(s)).Flen1 = uint64(0) + **(**Tuint32_t)(__ccgo_up(s + 8)) = uint32(0x67452301) + **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) = uint32(0xefcdab89) + **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) = uint32(0x98badcfe) + **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) = uint32(0x10325476) +} + +func _md5_sum(tls *TLS, s uintptr, md uintptr) { + var i int32 + _ = i + _pad(tls, s) + i = 0 + for { + if !(i < int32(4)) { + break + } + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4))) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(1)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(8)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(2)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(16)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(3)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(24)) + goto _1 + _1: + ; + i = i + 1 + } +} + +func _md5_update(tls *TLS, s uintptr, m uintptr, len1 uint64) { + var p uintptr + var r uint32 + _, _ = p, r + p = m + r = uint32((*Tmd5)(unsafe.Pointer(s)).Flen1 % uint64(64)) + **(**Tuint64_t)(__ccgo_up(s)) += len1 + if r != 0 { + if len1 < uint64(uint32(64)-r) { + Xmemcpy(tls, s+24+uintptr(r), p, len1) + return + } + Xmemcpy(tls, s+24+uintptr(r), p, uint64(uint32(64)-r)) + len1 = len1 - uint64(uint32(64)-r) + p = p + uintptr(uint32(64)-r) + _processblock(tls, s, s+24) + } + for { + if !(len1 >= uint64(64)) { + break + } + _processblock(tls, s, p) + goto _1 + _1: + ; + len1 = len1 - uint64(64) + p = p + uintptr(64) + } + Xmemcpy(tls, s+24, p, len1) +} + +/*- + * Copyright (c) 2003 Poul-Henning Kamp + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* key limit is not part of the original design, added for DoS protection */ + +var _b64 = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +func _to64(tls *TLS, s uintptr, u uint32, n int32) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + for { + n = n - 1 + v1 = n + if !(v1 >= 0) { + break + } + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = _b64[u%uint32(64)] + u = u / uint32(64) + } + return s +} + +func _md5crypt(tls *TLS, key uintptr, setting uintptr, output uintptr) (r uintptr) { + bp := tls.Alloc(112) + defer tls.Free(112) + var i, klen, slen uint32 + var p, salt, v5 uintptr + var _ /* ctx at bp+0 */ Tmd5 + var _ /* md at bp+88 */ [16]uint8 + _, _, _, _, _, _ = i, klen, p, salt, slen, v5 + /* reject large keys */ + klen = uint32(Xstrnlen(tls, key, Uint64FromInt32(Int32FromInt32(KEY_MAX)+Int32FromInt32(1)))) + if klen > uint32(KEY_MAX) { + return uintptr(0) + } + /* setting: $1$salt$ (closing $ is optional) */ + if Xstrncmp(tls, setting, __ccgo_ts+143, uint64(3)) != 0 { + return uintptr(0) + } + salt = setting + uintptr(3) + i = uint32(0) + for { + if !(i < uint32(SALT_MAX) && **(**uint8)(__ccgo_up(salt + uintptr(i))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(salt + uintptr(i)))) != int32('$')) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + slen = i + /* md5(key salt key) */ + _md5_init(tls, bp) + _md5_update(tls, bp, key, uint64(klen)) + _md5_update(tls, bp, salt, uint64(slen)) + _md5_update(tls, bp, key, uint64(klen)) + _md5_sum(tls, bp, bp+88) + /* md5(key $1$ salt repeated-md weird-key[0]-0) */ + _md5_init(tls, bp) + _md5_update(tls, bp, key, uint64(klen)) + _md5_update(tls, bp, setting, uint64(uint32(3)+slen)) + i = klen + for { + if !(uint64(i) > uint64(16)) { + break + } + _md5_update(tls, bp, bp+88, uint64(16)) + goto _2 + _2: + ; + i = uint32(uint64(i) - Uint64FromInt64(16)) + } + _md5_update(tls, bp, bp+88, uint64(i)) + (**(**[16]uint8)(__ccgo_up(bp + 88)))[0] = uint8(0) + i = klen + for { + if !(i != 0) { + break + } + if i&uint32(1) != 0 { + _md5_update(tls, bp, bp+88, uint64(1)) + } else { + _md5_update(tls, bp, key, uint64(1)) + } + goto _3 + _3: + ; + i = i >> uint32(1) + } + _md5_sum(tls, bp, bp+88) + /* md = f(md, key, salt) iteration */ + i = uint32(0) + for { + if !(i < uint32(1000)) { + break + } + _md5_init(tls, bp) + if i%uint32(2) != 0 { + _md5_update(tls, bp, key, uint64(klen)) + } else { + _md5_update(tls, bp, bp+88, uint64(16)) + } + if i%uint32(3) != 0 { + _md5_update(tls, bp, salt, uint64(slen)) + } + if i%uint32(7) != 0 { + _md5_update(tls, bp, key, uint64(klen)) + } + if i%uint32(2) != 0 { + _md5_update(tls, bp, bp+88, uint64(16)) + } else { + _md5_update(tls, bp, key, uint64(klen)) + } + _md5_sum(tls, bp, bp+88) + goto _4 + _4: + ; + i = i + 1 + } + /* output is $1$salt$hash */ + Xmemcpy(tls, output, setting, uint64(uint32(3)+slen)) + p = output + uintptr(3) + uintptr(slen) + v5 = p + p = p + 1 + **(**uint8)(__ccgo_up(v5)) = uint8('$') + i = uint32(0) + for { + if !(i < uint32(5)) { + break + } + p = _to64(tls, p, Uint32FromInt32(Int32FromUint8((**(**[16]uint8)(__ccgo_up(bp + 88)))[**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_perm)) + uintptr(i)*3))])< %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var p, q uintptr + var _ /* testbuf at bp+0 */ [64]uint8 + _, _ = p, q + p = _md5crypt(tls, key, setting, output) + /* self test and stack cleanup */ + q = _md5crypt(tls, uintptr(unsafe.Pointer(&_testkey)), uintptr(unsafe.Pointer(&_testsetting)), bp) + if !(p != 0) || q != bp || Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_testhash)), uint64(35)) != 0 { + return __ccgo_ts + 70 + } + return p +} + +var _testkey = [18]uint8{'X', 'y', '0', '1', '@', '#', 1, 2, 128, 127, 255, 13, 10, 129, 9, ' ', '!'} + +var _testsetting = [13]uint8{'$', '1', '$', 'a', 'b', 'c', 'd', '0', '1', '2', '3', '$'} + +var _testhash = [35]uint8{'$', '1', '$', 'a', 'b', 'c', 'd', '0', '1', '2', '3', '$', '9', 'Q', 'c', 'g', '8', 'D', 'y', 'v', 'i', 'e', 'k', 'V', '3', 't', 'D', 'G', 'M', 'Z', 'y', 'n', 'J', '1'} + +func X__crypt_r(tls *TLS, key uintptr, salt uintptr, data uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v salt=%v data=%v, (%v:)", tls, key, salt, data, origin(2)) + defer func() { trc("-> %v", r) }() + } + var output uintptr + _ = output + /* Per the crypt_r API, the caller has provided a pointer to + * struct crypt_data; however, this implementation does not + * use the structure to store any internal state, and treats + * it purely as a char buffer for storing the result. */ + output = data + if Int32FromUint8(**(**uint8)(__ccgo_up(salt))) == int32('$') && **(**uint8)(__ccgo_up(salt + 1)) != 0 && **(**uint8)(__ccgo_up(salt + 2)) != 0 { + if Int32FromUint8(**(**uint8)(__ccgo_up(salt + 1))) == int32('1') && Int32FromUint8(**(**uint8)(__ccgo_up(salt + 2))) == int32('$') { + return X__crypt_md5(tls, key, salt, output) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(salt + 1))) == int32('2') && Int32FromUint8(**(**uint8)(__ccgo_up(salt + 3))) == int32('$') { + return X__crypt_blowfish(tls, key, salt, output) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(salt + 1))) == int32('5') && Int32FromUint8(**(**uint8)(__ccgo_up(salt + 2))) == int32('$') { + return X__crypt_sha256(tls, key, salt, output) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(salt + 1))) == int32('6') && Int32FromUint8(**(**uint8)(__ccgo_up(salt + 2))) == int32('$') { + return X__crypt_sha512(tls, key, salt, output) + } + } + return X__crypt_des(tls, key, salt, output) +} + +func Xcrypt_r(tls *TLS, key uintptr, salt uintptr, data uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v salt=%v data=%v, (%v:)", tls, key, salt, data, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__crypt_r(tls, key, salt, data) +} + +const KEY_MAX1 = 256 +const ROUNDS_DEFAULT = 5000 +const ROUNDS_MAX = 9999999 +const ROUNDS_MIN = 1000 +const SALT_MAX1 = 16 + +/* public domain sha256 implementation based on fips180-3 */ + +type Tsha256 = struct { + Flen1 Tuint64_t + Fh [8]Tuint32_t + Fbuf [64]Tuint8_t +} + +func _ror(tls *TLS, n Tuint32_t, k int32) (r Tuint32_t) { + return n>>k | n<<(Int32FromInt32(32)-k) +} + +var _K = [64]Tuint32_t{ + 0: uint32(0x428a2f98), + 1: uint32(0x71374491), + 2: uint32(0xb5c0fbcf), + 3: uint32(0xe9b5dba5), + 4: uint32(0x3956c25b), + 5: uint32(0x59f111f1), + 6: uint32(0x923f82a4), + 7: uint32(0xab1c5ed5), + 8: uint32(0xd807aa98), + 9: uint32(0x12835b01), + 10: uint32(0x243185be), + 11: uint32(0x550c7dc3), + 12: uint32(0x72be5d74), + 13: uint32(0x80deb1fe), + 14: uint32(0x9bdc06a7), + 15: uint32(0xc19bf174), + 16: uint32(0xe49b69c1), + 17: uint32(0xefbe4786), + 18: uint32(0x0fc19dc6), + 19: uint32(0x240ca1cc), + 20: uint32(0x2de92c6f), + 21: uint32(0x4a7484aa), + 22: uint32(0x5cb0a9dc), + 23: uint32(0x76f988da), + 24: uint32(0x983e5152), + 25: uint32(0xa831c66d), + 26: uint32(0xb00327c8), + 27: uint32(0xbf597fc7), + 28: uint32(0xc6e00bf3), + 29: uint32(0xd5a79147), + 30: uint32(0x06ca6351), + 31: uint32(0x14292967), + 32: uint32(0x27b70a85), + 33: uint32(0x2e1b2138), + 34: uint32(0x4d2c6dfc), + 35: uint32(0x53380d13), + 36: uint32(0x650a7354), + 37: uint32(0x766a0abb), + 38: uint32(0x81c2c92e), + 39: uint32(0x92722c85), + 40: uint32(0xa2bfe8a1), + 41: uint32(0xa81a664b), + 42: uint32(0xc24b8b70), + 43: uint32(0xc76c51a3), + 44: uint32(0xd192e819), + 45: uint32(0xd6990624), + 46: uint32(0xf40e3585), + 47: uint32(0x106aa070), + 48: uint32(0x19a4c116), + 49: uint32(0x1e376c08), + 50: uint32(0x2748774c), + 51: uint32(0x34b0bcb5), + 52: uint32(0x391c0cb3), + 53: uint32(0x4ed8aa4a), + 54: uint32(0x5b9cca4f), + 55: uint32(0x682e6ff3), + 56: uint32(0x748f82ee), + 57: uint32(0x78a5636f), + 58: uint32(0x84c87814), + 59: uint32(0x8cc70208), + 60: uint32(0x90befffa), + 61: uint32(0xa4506ceb), + 62: uint32(0xbef9a3f7), + 63: uint32(0xc67178f2), +} + +func _processblock1(tls *TLS, s uintptr, buf uintptr) { + bp := tls.Alloc(256) + defer tls.Free(256) + var a, b, c, d, e, f, g, h, t1, t2 Tuint32_t + var i int32 + var _ /* W at bp+0 */ [64]Tuint32_t + _, _, _, _, _, _, _, _, _, _, _ = a, b, c, d, e, f, g, h, i, t1, t2 + i = 0 + for { + if !(i < int32(16)) { + break + } + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i] = uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(4)*i)))) << int32(24) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(4)*i+int32(1))))) << int32(16) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(4)*i+int32(2))))) << int32(8) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) |= uint32(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(4)*i+int32(3))))) + goto _1 + _1: + ; + i = i + 1 + } + for { + if !(i < int32(64)) { + break + } + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i] = _ror(tls, (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(2)], int32(17)) ^ _ror(tls, (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(2)], int32(19)) ^ (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(2)]>>Int32FromInt32(10) + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(7)] + (_ror(tls, (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(15)], int32(7)) ^ _ror(tls, (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(15)], int32(18)) ^ (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(15)]>>Int32FromInt32(3)) + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i-int32(16)] + goto _2 + _2: + ; + i = i + 1 + } + a = **(**Tuint32_t)(__ccgo_up(s + 8)) + b = **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) + c = **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) + d = **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) + e = **(**Tuint32_t)(__ccgo_up(s + 8 + 4*4)) + f = **(**Tuint32_t)(__ccgo_up(s + 8 + 5*4)) + g = **(**Tuint32_t)(__ccgo_up(s + 8 + 6*4)) + h = **(**Tuint32_t)(__ccgo_up(s + 8 + 7*4)) + i = 0 + for { + if !(i < int32(64)) { + break + } + t1 = h + (_ror(tls, e, int32(6)) ^ _ror(tls, e, int32(11)) ^ _ror(tls, e, int32(25))) + (g ^ e&(f^g)) + _K[i] + (**(**[64]Tuint32_t)(__ccgo_up(bp)))[i] + t2 = _ror(tls, a, int32(2)) ^ _ror(tls, a, int32(13)) ^ _ror(tls, a, int32(22)) + (a&b | c&(a|b)) + h = g + g = f + f = e + e = d + t1 + d = c + c = b + b = a + a = t1 + t2 + goto _3 + _3: + ; + i = i + 1 + } + **(**Tuint32_t)(__ccgo_up(s + 8)) += a + **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) += b + **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) += c + **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) += d + **(**Tuint32_t)(__ccgo_up(s + 8 + 4*4)) += e + **(**Tuint32_t)(__ccgo_up(s + 8 + 5*4)) += f + **(**Tuint32_t)(__ccgo_up(s + 8 + 6*4)) += g + **(**Tuint32_t)(__ccgo_up(s + 8 + 7*4)) += h +} + +func _pad1(tls *TLS, s uintptr) { + var r, v1 uint32 + _, _ = r, v1 + r = uint32((*Tsha256)(unsafe.Pointer(s)).Flen1 % uint64(64)) + v1 = r + r = r + 1 + **(**Tuint8_t)(__ccgo_up(s + 40 + uintptr(v1))) = uint8(0x80) + if r > uint32(56) { + Xmemset(tls, s+40+uintptr(r), 0, uint64(uint32(64)-r)) + r = uint32(0) + _processblock1(tls, s, s+40) + } + Xmemset(tls, s+40+uintptr(r), 0, uint64(uint32(56)-r)) + **(**Tuint64_t)(__ccgo_up(s)) *= uint64(8) + **(**Tuint8_t)(__ccgo_up(s + 40 + 56)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(56)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 57)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(48)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 58)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(40)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 59)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(32)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 60)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(24)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 61)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(16)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 62)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1 >> int32(8)) + **(**Tuint8_t)(__ccgo_up(s + 40 + 63)) = uint8((*Tsha256)(unsafe.Pointer(s)).Flen1) + _processblock1(tls, s, s+40) +} + +func _sha256_init(tls *TLS, s uintptr) { + (*Tsha256)(unsafe.Pointer(s)).Flen1 = uint64(0) + **(**Tuint32_t)(__ccgo_up(s + 8)) = uint32(0x6a09e667) + **(**Tuint32_t)(__ccgo_up(s + 8 + 1*4)) = uint32(0xbb67ae85) + **(**Tuint32_t)(__ccgo_up(s + 8 + 2*4)) = uint32(0x3c6ef372) + **(**Tuint32_t)(__ccgo_up(s + 8 + 3*4)) = uint32(0xa54ff53a) + **(**Tuint32_t)(__ccgo_up(s + 8 + 4*4)) = uint32(0x510e527f) + **(**Tuint32_t)(__ccgo_up(s + 8 + 5*4)) = uint32(0x9b05688c) + **(**Tuint32_t)(__ccgo_up(s + 8 + 6*4)) = uint32(0x1f83d9ab) + **(**Tuint32_t)(__ccgo_up(s + 8 + 7*4)) = uint32(0x5be0cd19) +} + +func _sha256_sum(tls *TLS, s uintptr, md uintptr) { + var i int32 + _ = i + _pad1(tls, s) + i = 0 + for { + if !(i < int32(8)) { + break + } + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(24)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(1)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(16)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(2)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4)) >> int32(8)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(4)*i+int32(3)))) = uint8(**(**Tuint32_t)(__ccgo_up(s + 8 + uintptr(i)*4))) + goto _1 + _1: + ; + i = i + 1 + } +} + +func _sha256_update(tls *TLS, s uintptr, m uintptr, len1 uint64) { + var p uintptr + var r uint32 + _, _ = p, r + p = m + r = uint32((*Tsha256)(unsafe.Pointer(s)).Flen1 % uint64(64)) + **(**Tuint64_t)(__ccgo_up(s)) += len1 + if r != 0 { + if len1 < uint64(uint32(64)-r) { + Xmemcpy(tls, s+40+uintptr(r), p, len1) + return + } + Xmemcpy(tls, s+40+uintptr(r), p, uint64(uint32(64)-r)) + len1 = len1 - uint64(uint32(64)-r) + p = p + uintptr(uint32(64)-r) + _processblock1(tls, s, s+40) + } + for { + if !(len1 >= uint64(64)) { + break + } + _processblock1(tls, s, p) + goto _1 + _1: + ; + len1 = len1 - uint64(64) + p = p + uintptr(64) + } + Xmemcpy(tls, s+40, p, len1) +} + +var _b641 = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +func _to641(tls *TLS, s uintptr, u uint32, n int32) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + for { + n = n - 1 + v1 = n + if !(v1 >= 0) { + break + } + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = _b641[u%uint32(64)] + u = u / uint32(64) + } + return s +} + +/* key limit is not part of the original design, added for DoS protection. + * rounds limit has been lowered (versus the reference/spec), also for DoS + * protection. runtime is O(klen^2 + klen*rounds) */ + +// C documentation +// +// /* hash n bytes of the repeated md message digest */ +func _hashmd(tls *TLS, s uintptr, n uint32, md uintptr) { + var i uint32 + _ = i + i = n + for { + if !(i > uint32(32)) { + break + } + _sha256_update(tls, s, md, uint64(32)) + goto _1 + _1: + ; + i = i - uint32(32) + } + _sha256_update(tls, s, md, uint64(i)) +} + +func _sha256crypt(tls *TLS, key uintptr, setting uintptr, output uintptr) (r1 uintptr) { + bp := tls.Alloc(272) + defer tls.Free(272) + var i, klen, r, slen uint32 + var p, salt uintptr + var u uint64 + var _ /* ctx at bp+0 */ Tsha256 + var _ /* end at bp+224 */ uintptr + var _ /* kmd at bp+136 */ [32]uint8 + var _ /* md at bp+104 */ [32]uint8 + var _ /* rounds at bp+200 */ [20]uint8 + var _ /* smd at bp+168 */ [32]uint8 + _, _, _, _, _, _, _ = i, klen, p, r, salt, slen, u + **(**[20]uint8)(__ccgo_up(bp + 200)) = [20]uint8{} + /* reject large keys */ + klen = uint32(Xstrnlen(tls, key, Uint64FromInt32(Int32FromInt32(KEY_MAX1)+Int32FromInt32(1)))) + if klen > uint32(KEY_MAX1) { + return uintptr(0) + } + /* setting: $5$rounds=n$salt$ (rounds=n$ and closing $ are optional) */ + if Xstrncmp(tls, setting, __ccgo_ts+147, uint64(3)) != 0 { + return uintptr(0) + } + salt = setting + uintptr(3) + r = uint32(ROUNDS_DEFAULT) + if Xstrncmp(tls, salt, __ccgo_ts+151, Uint64FromInt64(8)-Uint64FromInt32(1)) == 0 { + /* + * this is a deviation from the reference: + * bad rounds setting is rejected if it is + * - empty + * - unterminated (missing '$') + * - begins with anything but a decimal digit + * the reference implementation treats these bad + * rounds as part of the salt or parse them with + * strtoul semantics which may cause problems + * including non-portable hashes that depend on + * the host's value of ULONG_MAX. + */ + salt = salt + uintptr(Uint64FromInt64(8)-Uint64FromInt32(1)) + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(salt)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return uintptr(0) + } + u = Xstrtoul(tls, salt, bp+224, int32(10)) + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 224))))) != int32('$') { + return uintptr(0) + } + salt = **(**uintptr)(__ccgo_up(bp + 224)) + uintptr(1) + if u < uint64(ROUNDS_MIN) { + r = uint32(ROUNDS_MIN) + } else { + if u > uint64(ROUNDS_MAX) { + return uintptr(0) + } else { + r = uint32(u) + } + } + /* needed when rounds is zero prefixed or out of bounds */ + Xsprintf(tls, bp+200, __ccgo_ts+159, VaList(bp+240, r)) + } + i = uint32(0) + for { + if !(i < uint32(SALT_MAX1) && **(**uint8)(__ccgo_up(salt + uintptr(i))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(salt + uintptr(i)))) != int32('$')) { + break + } + /* reject characters that interfere with /etc/shadow parsing */ + if Int32FromUint8(**(**uint8)(__ccgo_up(salt + uintptr(i)))) == int32('\n') || Int32FromUint8(**(**uint8)(__ccgo_up(salt + uintptr(i)))) == int32(':') { + return uintptr(0) + } + goto _1 + _1: + ; + i = i + 1 + } + slen = i + /* B = sha(key salt key) */ + _sha256_init(tls, bp) + _sha256_update(tls, bp, key, uint64(klen)) + _sha256_update(tls, bp, salt, uint64(slen)) + _sha256_update(tls, bp, key, uint64(klen)) + _sha256_sum(tls, bp, bp+104) + /* A = sha(key salt repeat-B alternate-B-key) */ + _sha256_init(tls, bp) + _sha256_update(tls, bp, key, uint64(klen)) + _sha256_update(tls, bp, salt, uint64(slen)) + _hashmd(tls, bp, klen, bp+104) + i = klen + for { + if !(i > uint32(0)) { + break + } + if i&uint32(1) != 0 { + _sha256_update(tls, bp, bp+104, uint64(32)) + } else { + _sha256_update(tls, bp, key, uint64(klen)) + } + goto _2 + _2: + ; + i = i >> uint32(1) + } + _sha256_sum(tls, bp, bp+104) + /* DP = sha(repeat-key), this step takes O(klen^2) time */ + _sha256_init(tls, bp) + i = uint32(0) + for { + if !(i < klen) { + break + } + _sha256_update(tls, bp, key, uint64(klen)) + goto _3 + _3: + ; + i = i + 1 + } + _sha256_sum(tls, bp, bp+136) + /* DS = sha(repeat-salt) */ + _sha256_init(tls, bp) + i = uint32(0) + for { + if !(i < Uint32FromInt32(int32(16)+Int32FromUint8((**(**[32]uint8)(__ccgo_up(bp + 104)))[0]))) { + break + } + _sha256_update(tls, bp, salt, uint64(slen)) + goto _4 + _4: + ; + i = i + 1 + } + _sha256_sum(tls, bp, bp+168) + /* iterate A = f(A,DP,DS), this step takes O(rounds*klen) time */ + i = uint32(0) + for { + if !(i < r) { + break + } + _sha256_init(tls, bp) + if i%uint32(2) != 0 { + _hashmd(tls, bp, klen, bp+136) + } else { + _sha256_update(tls, bp, bp+104, uint64(32)) + } + if i%uint32(3) != 0 { + _sha256_update(tls, bp, bp+168, uint64(slen)) + } + if i%uint32(7) != 0 { + _hashmd(tls, bp, klen, bp+136) + } + if i%uint32(2) != 0 { + _sha256_update(tls, bp, bp+104, uint64(32)) + } else { + _hashmd(tls, bp, klen, bp+136) + } + _sha256_sum(tls, bp, bp+104) + goto _5 + _5: + ; + i = i + 1 + } + /* output is $5$rounds=n$salt$hash */ + p = output + p = p + uintptr(Xsprintf(tls, p, __ccgo_ts+170, VaList(bp+240, bp+200, slen, salt))) + i = uint32(0) + for { + if !(i < uint32(10)) { + break + } + p = _to641(tls, p, Uint32FromInt32(Int32FromUint8((**(**[32]uint8)(__ccgo_up(bp + 104)))[**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_perm1)) + uintptr(i)*3))])< %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var p, q uintptr + var _ /* testbuf at bp+0 */ [128]uint8 + _, _ = p, q + p = _sha256crypt(tls, key, setting, output) + /* self test and stack cleanup */ + q = _sha256crypt(tls, uintptr(unsafe.Pointer(&_testkey1)), uintptr(unsafe.Pointer(&_testsetting1)), bp) + if !(p != 0) || q != bp || Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_testhash1)), uint64(73)) != 0 { + return __ccgo_ts + 70 + } + return p +} + +var _testkey1 = [18]uint8{'X', 'y', '0', '1', '@', '#', 1, 2, 128, 127, 255, 13, 10, 129, 9, ' ', '!'} + +var _testsetting1 = [30]uint8{'$', '5', '$', 'r', 'o', 'u', 'n', 'd', 's', '=', '1', '2', '3', '4', '$', 'a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '$'} + +var _testhash1 = [73]uint8{'$', '5', '$', 'r', 'o', 'u', 'n', 'd', 's', '=', '1', '2', '3', '4', '$', 'a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '$', '3', 'V', 'f', 'D', 'j', 'P', 't', '0', '5', 'V', 'H', 'F', 'n', '4', '7', 'C', '/', 'o', 'j', 'F', 'Z', '6', 'K', 'R', 'P', 'Y', 'r', 'O', 'j', 'j', '1', 'l', 'L', 'b', 'H', '.', 'd', 'k', 'F', '3', 'b', 'Z', '6'} + +/* public domain sha512 implementation based on fips180-3 */ +/* >=2^64 bits messages are not supported (about 2000 peta bytes) */ + +type Tsha512 = struct { + Flen1 Tuint64_t + Fh [8]Tuint64_t + Fbuf [128]Tuint8_t +} + +func _ror1(tls *TLS, n Tuint64_t, k int32) (r Tuint64_t) { + return n>>k | n<<(Int32FromInt32(64)-k) +} + +var _K1 = [80]Tuint64_t{ + 0: uint64(0x428a2f98d728ae22), + 1: uint64(0x7137449123ef65cd), + 2: uint64(0xb5c0fbcfec4d3b2f), + 3: uint64(0xe9b5dba58189dbbc), + 4: uint64(0x3956c25bf348b538), + 5: uint64(0x59f111f1b605d019), + 6: uint64(0x923f82a4af194f9b), + 7: uint64(0xab1c5ed5da6d8118), + 8: uint64(0xd807aa98a3030242), + 9: uint64(0x12835b0145706fbe), + 10: uint64(0x243185be4ee4b28c), + 11: uint64(0x550c7dc3d5ffb4e2), + 12: uint64(0x72be5d74f27b896f), + 13: uint64(0x80deb1fe3b1696b1), + 14: uint64(0x9bdc06a725c71235), + 15: uint64(0xc19bf174cf692694), + 16: uint64(0xe49b69c19ef14ad2), + 17: uint64(0xefbe4786384f25e3), + 18: uint64(0x0fc19dc68b8cd5b5), + 19: uint64(0x240ca1cc77ac9c65), + 20: uint64(0x2de92c6f592b0275), + 21: uint64(0x4a7484aa6ea6e483), + 22: uint64(0x5cb0a9dcbd41fbd4), + 23: uint64(0x76f988da831153b5), + 24: uint64(0x983e5152ee66dfab), + 25: uint64(0xa831c66d2db43210), + 26: uint64(0xb00327c898fb213f), + 27: uint64(0xbf597fc7beef0ee4), + 28: uint64(0xc6e00bf33da88fc2), + 29: uint64(0xd5a79147930aa725), + 30: uint64(0x06ca6351e003826f), + 31: uint64(0x142929670a0e6e70), + 32: uint64(0x27b70a8546d22ffc), + 33: uint64(0x2e1b21385c26c926), + 34: uint64(0x4d2c6dfc5ac42aed), + 35: uint64(0x53380d139d95b3df), + 36: uint64(0x650a73548baf63de), + 37: uint64(0x766a0abb3c77b2a8), + 38: uint64(0x81c2c92e47edaee6), + 39: uint64(0x92722c851482353b), + 40: uint64(0xa2bfe8a14cf10364), + 41: uint64(0xa81a664bbc423001), + 42: uint64(0xc24b8b70d0f89791), + 43: uint64(0xc76c51a30654be30), + 44: uint64(0xd192e819d6ef5218), + 45: uint64(0xd69906245565a910), + 46: uint64(0xf40e35855771202a), + 47: uint64(0x106aa07032bbd1b8), + 48: uint64(0x19a4c116b8d2d0c8), + 49: uint64(0x1e376c085141ab53), + 50: uint64(0x2748774cdf8eeb99), + 51: uint64(0x34b0bcb5e19b48a8), + 52: uint64(0x391c0cb3c5c95a63), + 53: uint64(0x4ed8aa4ae3418acb), + 54: uint64(0x5b9cca4f7763e373), + 55: uint64(0x682e6ff3d6b2b8a3), + 56: uint64(0x748f82ee5defb2fc), + 57: uint64(0x78a5636f43172f60), + 58: uint64(0x84c87814a1f0ab72), + 59: uint64(0x8cc702081a6439ec), + 60: uint64(0x90befffa23631e28), + 61: uint64(0xa4506cebde82bde9), + 62: uint64(0xbef9a3f7b2c67915), + 63: uint64(0xc67178f2e372532b), + 64: uint64(0xca273eceea26619c), + 65: uint64(0xd186b8c721c0c207), + 66: uint64(0xeada7dd6cde0eb1e), + 67: uint64(0xf57d4f7fee6ed178), + 68: uint64(0x06f067aa72176fba), + 69: uint64(0x0a637dc5a2c898a6), + 70: uint64(0x113f9804bef90dae), + 71: uint64(0x1b710b35131c471b), + 72: uint64(0x28db77f523047d84), + 73: uint64(0x32caab7b40c72493), + 74: uint64(0x3c9ebe0a15c9bebc), + 75: uint64(0x431d67c49c100d4c), + 76: uint64(0x4cc5d4becb3e42b6), + 77: uint64(0x597f299cfc657e2a), + 78: uint64(0x5fcb6fab3ad6faec), + 79: uint64(0x6c44198c4a475817), +} + +func _processblock2(tls *TLS, s uintptr, buf uintptr) { + bp := tls.Alloc(640) + defer tls.Free(640) + var a, b, c, d, e, f, g, h, t1, t2 Tuint64_t + var i int32 + var _ /* W at bp+0 */ [80]Tuint64_t + _, _, _, _, _, _, _, _, _, _, _ = a, b, c, d, e, f, g, h, i, t1, t2 + i = 0 + for { + if !(i < int32(16)) { + break + } + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i] = uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i)))) << int32(56) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(1))))) << int32(48) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(2))))) << int32(40) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(3))))) << int32(32) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(4))))) << int32(24) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(5))))) << int32(16) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(6))))) << int32(8) + **(**Tuint64_t)(__ccgo_up(bp + uintptr(i)*8)) |= uint64(**(**Tuint8_t)(__ccgo_up(buf + uintptr(int32(8)*i+int32(7))))) + goto _1 + _1: + ; + i = i + 1 + } + for { + if !(i < int32(80)) { + break + } + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i] = _ror1(tls, (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(2)], int32(19)) ^ _ror1(tls, (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(2)], int32(61)) ^ (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(2)]>>Int32FromInt32(6) + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(7)] + (_ror1(tls, (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(15)], int32(1)) ^ _ror1(tls, (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(15)], int32(8)) ^ (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(15)]>>Int32FromInt32(7)) + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i-int32(16)] + goto _2 + _2: + ; + i = i + 1 + } + a = **(**Tuint64_t)(__ccgo_up(s + 8)) + b = **(**Tuint64_t)(__ccgo_up(s + 8 + 1*8)) + c = **(**Tuint64_t)(__ccgo_up(s + 8 + 2*8)) + d = **(**Tuint64_t)(__ccgo_up(s + 8 + 3*8)) + e = **(**Tuint64_t)(__ccgo_up(s + 8 + 4*8)) + f = **(**Tuint64_t)(__ccgo_up(s + 8 + 5*8)) + g = **(**Tuint64_t)(__ccgo_up(s + 8 + 6*8)) + h = **(**Tuint64_t)(__ccgo_up(s + 8 + 7*8)) + i = 0 + for { + if !(i < int32(80)) { + break + } + t1 = h + (_ror1(tls, e, int32(14)) ^ _ror1(tls, e, int32(18)) ^ _ror1(tls, e, int32(41))) + (g ^ e&(f^g)) + _K1[i] + (**(**[80]Tuint64_t)(__ccgo_up(bp)))[i] + t2 = _ror1(tls, a, int32(28)) ^ _ror1(tls, a, int32(34)) ^ _ror1(tls, a, int32(39)) + (a&b | c&(a|b)) + h = g + g = f + f = e + e = d + t1 + d = c + c = b + b = a + a = t1 + t2 + goto _3 + _3: + ; + i = i + 1 + } + **(**Tuint64_t)(__ccgo_up(s + 8)) += a + **(**Tuint64_t)(__ccgo_up(s + 8 + 1*8)) += b + **(**Tuint64_t)(__ccgo_up(s + 8 + 2*8)) += c + **(**Tuint64_t)(__ccgo_up(s + 8 + 3*8)) += d + **(**Tuint64_t)(__ccgo_up(s + 8 + 4*8)) += e + **(**Tuint64_t)(__ccgo_up(s + 8 + 5*8)) += f + **(**Tuint64_t)(__ccgo_up(s + 8 + 6*8)) += g + **(**Tuint64_t)(__ccgo_up(s + 8 + 7*8)) += h +} + +func _pad2(tls *TLS, s uintptr) { + var r, v1 uint32 + _, _ = r, v1 + r = uint32((*Tsha512)(unsafe.Pointer(s)).Flen1 % uint64(128)) + v1 = r + r = r + 1 + **(**Tuint8_t)(__ccgo_up(s + 72 + uintptr(v1))) = uint8(0x80) + if r > uint32(112) { + Xmemset(tls, s+72+uintptr(r), 0, uint64(uint32(128)-r)) + r = uint32(0) + _processblock2(tls, s, s+72) + } + Xmemset(tls, s+72+uintptr(r), 0, uint64(uint32(120)-r)) + **(**Tuint64_t)(__ccgo_up(s)) *= uint64(8) + **(**Tuint8_t)(__ccgo_up(s + 72 + 120)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(56)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 121)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(48)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 122)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(40)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 123)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(32)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 124)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(24)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 125)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(16)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 126)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1 >> int32(8)) + **(**Tuint8_t)(__ccgo_up(s + 72 + 127)) = uint8((*Tsha512)(unsafe.Pointer(s)).Flen1) + _processblock2(tls, s, s+72) +} + +func _sha512_init(tls *TLS, s uintptr) { + (*Tsha512)(unsafe.Pointer(s)).Flen1 = uint64(0) + **(**Tuint64_t)(__ccgo_up(s + 8)) = uint64(0x6a09e667f3bcc908) + **(**Tuint64_t)(__ccgo_up(s + 8 + 1*8)) = uint64(0xbb67ae8584caa73b) + **(**Tuint64_t)(__ccgo_up(s + 8 + 2*8)) = uint64(0x3c6ef372fe94f82b) + **(**Tuint64_t)(__ccgo_up(s + 8 + 3*8)) = uint64(0xa54ff53a5f1d36f1) + **(**Tuint64_t)(__ccgo_up(s + 8 + 4*8)) = uint64(0x510e527fade682d1) + **(**Tuint64_t)(__ccgo_up(s + 8 + 5*8)) = uint64(0x9b05688c2b3e6c1f) + **(**Tuint64_t)(__ccgo_up(s + 8 + 6*8)) = uint64(0x1f83d9abfb41bd6b) + **(**Tuint64_t)(__ccgo_up(s + 8 + 7*8)) = uint64(0x5be0cd19137e2179) +} + +func _sha512_sum(tls *TLS, s uintptr, md uintptr) { + var i int32 + _ = i + _pad2(tls, s) + i = 0 + for { + if !(i < int32(8)) { + break + } + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(56)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(1)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(48)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(2)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(40)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(3)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(32)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(4)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(24)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(5)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(16)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(6)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8)) >> int32(8)) + **(**Tuint8_t)(__ccgo_up(md + uintptr(int32(8)*i+int32(7)))) = uint8(**(**Tuint64_t)(__ccgo_up(s + 8 + uintptr(i)*8))) + goto _1 + _1: + ; + i = i + 1 + } +} + +func _sha512_update(tls *TLS, s uintptr, m uintptr, len1 uint64) { + var p uintptr + var r uint32 + _, _ = p, r + p = m + r = uint32((*Tsha512)(unsafe.Pointer(s)).Flen1 % uint64(128)) + **(**Tuint64_t)(__ccgo_up(s)) += len1 + if r != 0 { + if len1 < uint64(uint32(128)-r) { + Xmemcpy(tls, s+72+uintptr(r), p, len1) + return + } + Xmemcpy(tls, s+72+uintptr(r), p, uint64(uint32(128)-r)) + len1 = len1 - uint64(uint32(128)-r) + p = p + uintptr(uint32(128)-r) + _processblock2(tls, s, s+72) + } + for { + if !(len1 >= uint64(128)) { + break + } + _processblock2(tls, s, p) + goto _1 + _1: + ; + len1 = len1 - uint64(128) + p = p + uintptr(128) + } + Xmemcpy(tls, s+72, p, len1) +} + +var _b642 = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +func _to642(tls *TLS, s uintptr, u uint32, n int32) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + for { + n = n - 1 + v1 = n + if !(v1 >= 0) { + break + } + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = _b642[u%uint32(64)] + u = u / uint32(64) + } + return s +} + +/* key limit is not part of the original design, added for DoS protection. + * rounds limit has been lowered (versus the reference/spec), also for DoS + * protection. runtime is O(klen^2 + klen*rounds) */ + +// C documentation +// +// /* hash n bytes of the repeated md message digest */ +func _hashmd1(tls *TLS, s uintptr, n uint32, md uintptr) { + var i uint32 + _ = i + i = n + for { + if !(i > uint32(64)) { + break + } + _sha512_update(tls, s, md, uint64(64)) + goto _1 + _1: + ; + i = i - uint32(64) + } + _sha512_update(tls, s, md, uint64(i)) +} + +func _sha512crypt(tls *TLS, key uintptr, setting uintptr, output uintptr) (r1 uintptr) { + bp := tls.Alloc(464) + defer tls.Free(464) + var i, klen, r, slen uint32 + var p, salt uintptr + var u uint64 + var _ /* ctx at bp+0 */ Tsha512 + var _ /* end at bp+416 */ uintptr + var _ /* kmd at bp+264 */ [64]uint8 + var _ /* md at bp+200 */ [64]uint8 + var _ /* rounds at bp+392 */ [20]uint8 + var _ /* smd at bp+328 */ [64]uint8 + _, _, _, _, _, _, _ = i, klen, p, r, salt, slen, u + **(**[20]uint8)(__ccgo_up(bp + 392)) = [20]uint8{} + /* reject large keys */ + i = uint32(0) + for { + if !(i <= uint32(KEY_MAX1) && **(**uint8)(__ccgo_up(key + uintptr(i))) != 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i > uint32(KEY_MAX1) { + return uintptr(0) + } + klen = i + /* setting: $6$rounds=n$salt$ (rounds=n$ and closing $ are optional) */ + if Xstrncmp(tls, setting, __ccgo_ts+181, uint64(3)) != 0 { + return uintptr(0) + } + salt = setting + uintptr(3) + r = uint32(ROUNDS_DEFAULT) + if Xstrncmp(tls, salt, __ccgo_ts+151, Uint64FromInt64(8)-Uint64FromInt32(1)) == 0 { + /* + * this is a deviation from the reference: + * bad rounds setting is rejected if it is + * - empty + * - unterminated (missing '$') + * - begins with anything but a decimal digit + * the reference implementation treats these bad + * rounds as part of the salt or parse them with + * strtoul semantics which may cause problems + * including non-portable hashes that depend on + * the host's value of ULONG_MAX. + */ + salt = salt + uintptr(Uint64FromInt64(8)-Uint64FromInt32(1)) + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(salt)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return uintptr(0) + } + u = Xstrtoul(tls, salt, bp+416, int32(10)) + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 416))))) != int32('$') { + return uintptr(0) + } + salt = **(**uintptr)(__ccgo_up(bp + 416)) + uintptr(1) + if u < uint64(ROUNDS_MIN) { + r = uint32(ROUNDS_MIN) + } else { + if u > uint64(ROUNDS_MAX) { + return uintptr(0) + } else { + r = uint32(u) + } + } + /* needed when rounds is zero prefixed or out of bounds */ + Xsprintf(tls, bp+392, __ccgo_ts+159, VaList(bp+432, r)) + } + i = uint32(0) + for { + if !(i < uint32(SALT_MAX1) && **(**uint8)(__ccgo_up(salt + uintptr(i))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(salt + uintptr(i)))) != int32('$')) { + break + } + /* reject characters that interfere with /etc/shadow parsing */ + if Int32FromUint8(**(**uint8)(__ccgo_up(salt + uintptr(i)))) == int32('\n') || Int32FromUint8(**(**uint8)(__ccgo_up(salt + uintptr(i)))) == int32(':') { + return uintptr(0) + } + goto _2 + _2: + ; + i = i + 1 + } + slen = i + /* B = sha(key salt key) */ + _sha512_init(tls, bp) + _sha512_update(tls, bp, key, uint64(klen)) + _sha512_update(tls, bp, salt, uint64(slen)) + _sha512_update(tls, bp, key, uint64(klen)) + _sha512_sum(tls, bp, bp+200) + /* A = sha(key salt repeat-B alternate-B-key) */ + _sha512_init(tls, bp) + _sha512_update(tls, bp, key, uint64(klen)) + _sha512_update(tls, bp, salt, uint64(slen)) + _hashmd1(tls, bp, klen, bp+200) + i = klen + for { + if !(i > uint32(0)) { + break + } + if i&uint32(1) != 0 { + _sha512_update(tls, bp, bp+200, uint64(64)) + } else { + _sha512_update(tls, bp, key, uint64(klen)) + } + goto _3 + _3: + ; + i = i >> uint32(1) + } + _sha512_sum(tls, bp, bp+200) + /* DP = sha(repeat-key), this step takes O(klen^2) time */ + _sha512_init(tls, bp) + i = uint32(0) + for { + if !(i < klen) { + break + } + _sha512_update(tls, bp, key, uint64(klen)) + goto _4 + _4: + ; + i = i + 1 + } + _sha512_sum(tls, bp, bp+264) + /* DS = sha(repeat-salt) */ + _sha512_init(tls, bp) + i = uint32(0) + for { + if !(i < Uint32FromInt32(int32(16)+Int32FromUint8((**(**[64]uint8)(__ccgo_up(bp + 200)))[0]))) { + break + } + _sha512_update(tls, bp, salt, uint64(slen)) + goto _5 + _5: + ; + i = i + 1 + } + _sha512_sum(tls, bp, bp+328) + /* iterate A = f(A,DP,DS), this step takes O(rounds*klen) time */ + i = uint32(0) + for { + if !(i < r) { + break + } + _sha512_init(tls, bp) + if i%uint32(2) != 0 { + _hashmd1(tls, bp, klen, bp+264) + } else { + _sha512_update(tls, bp, bp+200, uint64(64)) + } + if i%uint32(3) != 0 { + _sha512_update(tls, bp, bp+328, uint64(slen)) + } + if i%uint32(7) != 0 { + _hashmd1(tls, bp, klen, bp+264) + } + if i%uint32(2) != 0 { + _sha512_update(tls, bp, bp+200, uint64(64)) + } else { + _hashmd1(tls, bp, klen, bp+264) + } + _sha512_sum(tls, bp, bp+200) + goto _6 + _6: + ; + i = i + 1 + } + /* output is $6$rounds=n$salt$hash */ + p = output + p = p + uintptr(Xsprintf(tls, p, __ccgo_ts+185, VaList(bp+432, bp+392, slen, salt))) + i = uint32(0) + for { + if !(i < uint32(21)) { + break + } + p = _to642(tls, p, Uint32FromInt32(Int32FromUint8((**(**[64]uint8)(__ccgo_up(bp + 200)))[**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_perm2)) + uintptr(i)*3))])< %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var p, q uintptr + var _ /* testbuf at bp+0 */ [128]uint8 + _, _ = p, q + p = _sha512crypt(tls, key, setting, output) + /* self test and stack cleanup */ + q = _sha512crypt(tls, uintptr(unsafe.Pointer(&_testkey2)), uintptr(unsafe.Pointer(&_testsetting2)), bp) + if !(p != 0) || q != bp || Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&_testhash2)), uint64(116)) != 0 { + return __ccgo_ts + 70 + } + return p +} + +var _testkey2 = [18]uint8{'X', 'y', '0', '1', '@', '#', 1, 2, 128, 127, 255, 13, 10, 129, 9, ' ', '!'} + +var _testsetting2 = [30]uint8{'$', '6', '$', 'r', 'o', 'u', 'n', 'd', 's', '=', '1', '2', '3', '4', '$', 'a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '$'} + +var _testhash2 = [116]uint8{'$', '6', '$', 'r', 'o', 'u', 'n', 'd', 's', '=', '1', '2', '3', '4', '$', 'a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '$', 'B', 'C', 'p', 't', '8', 'z', 'L', 'r', 'c', '/', 'R', 'c', 'y', 'u', 'X', 'm', 'C', 'D', 'O', 'E', '1', 'A', 'L', 'q', 'M', 'X', 'B', '2', 'M', 'H', '6', 'n', '1', 'g', '8', '9', '1', 'H', 'h', 'F', 'j', '8', '.', 'w', '7', 'L', 'x', 'G', 'v', '.', 'F', 'T', 'k', 'q', 'q', '6', 'V', 'x', 'c', '/', 'k', 'm', '3', 'Y', '0', 'j', 'E', '0', 'j', '2', '4', 'j', 'Y', '5', 'P', 'I', 'v', '/', 'o', 'O', 'u', '6', 'r', 'e', 'g', '1'} + +var ___encrypt_key Texpanded_key + +func Xsetkey(tls *TLS, key uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v, (%v:)", tls, key, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, j int32 + var v3 uintptr + var _ /* bkey at bp+0 */ [8]uint8 + _, _, _ = i, j, v3 + i = 0 + for { + if !(i < int32(8)) { + break + } + (**(**[8]uint8)(__ccgo_up(bp)))[i] = uint8(0) + j = int32(7) + for { + if !(j >= 0) { + break + } + v3 = bp + uintptr(i) + *(*uint8)(unsafe.Pointer(v3)) = uint8(uint32(*(*uint8)(unsafe.Pointer(v3))) | Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(key)))&Int32FromInt32(1))<= 0) { + break + } + **(**Tuint32_t)(__ccgo_up(bp + 128 + uintptr(i)*4)) |= Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(p)))&Int32FromInt32(1)) << j + goto _2 + _2: + ; + j = j - 1 + p = p + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + key = uintptr(unsafe.Pointer(&___encrypt_key)) + if edflag != 0 { + key = bp + i = 0 + for { + if !(i < int32(16)) { + break + } + **(**Tuint32_t)(__ccgo_up(bp + uintptr(i)*4)) = **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&___encrypt_key)) + uintptr(int32(15)-i)*4)) + **(**Tuint32_t)(__ccgo_up(bp + 64 + uintptr(i)*4)) = **(**Tuint32_t)(__ccgo_up(uintptr(unsafe.Pointer(&___encrypt_key)) + 64 + uintptr(int32(15)-i)*4)) + goto _3 + _3: + ; + i = i + 1 + } + } + X__do_des(tls, (**(**[2]Tuint32_t)(__ccgo_up(bp + 128)))[0], (**(**[2]Tuint32_t)(__ccgo_up(bp + 128)))[int32(1)], bp+128, bp+128+uintptr(1)*4, uint32(1), uint32(0), key) + p = block + i = 0 + for { + if !(i < int32(2)) { + break + } + j = int32(31) + for { + if !(j >= 0) { + break + } + v6 = p + p = p + 1 + **(**uint8)(__ccgo_up(v6)) = uint8((**(**[2]Tuint32_t)(__ccgo_up(bp + 128)))[i] >> j & uint32(1)) + goto _5 + _5: + ; + j = j - 1 + } + goto _4 + _4: + ; + i = i + 1 + } +} + +var _table = [384]uint16{ + 128: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 129: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 130: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 131: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 132: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 133: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 134: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 135: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 136: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 137: Uint16FromInt32((Int32FromInt32(0x320)/Int32FromInt32(256) | Int32FromInt32(0x320)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 138: Uint16FromInt32((Int32FromInt32(0x220)/Int32FromInt32(256) | Int32FromInt32(0x220)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 139: Uint16FromInt32((Int32FromInt32(0x220)/Int32FromInt32(256) | Int32FromInt32(0x220)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 140: Uint16FromInt32((Int32FromInt32(0x220)/Int32FromInt32(256) | Int32FromInt32(0x220)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 141: Uint16FromInt32((Int32FromInt32(0x220)/Int32FromInt32(256) | Int32FromInt32(0x220)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 142: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 143: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 144: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 145: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 146: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 147: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 148: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 149: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 150: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 151: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 152: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 153: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 154: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 155: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 156: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 157: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 158: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 159: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 160: Uint16FromInt32((Int32FromInt32(0x160)/Int32FromInt32(256) | Int32FromInt32(0x160)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 161: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 162: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 163: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 164: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 165: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 166: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 167: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 168: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 169: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 170: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 171: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 172: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 173: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 174: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 175: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 176: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 177: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 178: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 179: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 180: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 181: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 182: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 183: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 184: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 185: Uint16FromInt32((Int32FromInt32(0x8d8)/Int32FromInt32(256) | Int32FromInt32(0x8d8)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 186: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 187: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 188: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 189: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 190: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 191: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 192: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 193: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 194: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 195: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 196: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 197: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 198: Uint16FromInt32((Int32FromInt32(0x8d5)/Int32FromInt32(256) | Int32FromInt32(0x8d5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 199: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 200: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 201: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 202: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 203: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 204: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 205: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 206: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 207: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 208: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 209: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 210: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 211: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 212: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 213: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 214: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 215: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 216: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 217: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 218: Uint16FromInt32((Int32FromInt32(0x8c5)/Int32FromInt32(256) | Int32FromInt32(0x8c5)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 219: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 220: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 221: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 222: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 223: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 224: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 225: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 226: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 227: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 228: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 229: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 230: Uint16FromInt32((Int32FromInt32(0x8d6)/Int32FromInt32(256) | Int32FromInt32(0x8d6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 231: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 232: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 233: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 234: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 235: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 236: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 237: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 238: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 239: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 240: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 241: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 242: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 243: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 244: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 245: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 246: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 247: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 248: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 249: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 250: Uint16FromInt32((Int32FromInt32(0x8c6)/Int32FromInt32(256) | Int32FromInt32(0x8c6)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 251: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 252: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 253: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 254: Uint16FromInt32((Int32FromInt32(0x4c0)/Int32FromInt32(256) | Int32FromInt32(0x4c0)*Int32FromInt32(256)) % Int32FromInt32(65536)), + 255: Uint16FromInt32((Int32FromInt32(0x200)/Int32FromInt32(256) | Int32FromInt32(0x200)*Int32FromInt32(256)) % Int32FromInt32(65536)), +} + +var _ptable = uintptr(unsafe.Pointer(&_table)) + uintptr(128)*2 + +func X__ctype_b_loc(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_ptable)) +} + +const CLOCKS_PER_SEC = 1000000 +const CLOCK_BOOTTIME = 7 +const CLOCK_BOOTTIME_ALARM = 9 +const CLOCK_MONOTONIC = 1 +const CLOCK_MONOTONIC_COARSE = 6 +const CLOCK_MONOTONIC_RAW = 4 +const CLOCK_PROCESS_CPUTIME_ID = 2 +const CLOCK_REALTIME = 0 +const CLOCK_REALTIME_ALARM = 8 +const CLOCK_REALTIME_COARSE = 5 +const CLOCK_SGI_CYCLE = 10 +const CLOCK_TAI = 11 +const CLOCK_THREAD_CPUTIME_ID = 3 +const C_LOCALE = 0 +const DEFAULT_GUARD_MAX = 1048576 +const DEFAULT_GUARD_SIZE = 8192 +const DEFAULT_STACK_MAX = 8388608 +const DEFAULT_STACK_SIZE = 131072 +const DTP_OFFSET = 0 +const FUTEX_CLOCK_REALTIME = 256 +const FUTEX_CMP_REQUEUE = 4 +const FUTEX_FD = 2 +const FUTEX_LOCK_PI = 6 +const FUTEX_PRIVATE = 128 +const FUTEX_REQUEUE = 3 +const FUTEX_TRYLOCK_PI = 8 +const FUTEX_UNLOCK_PI = 7 +const FUTEX_WAIT = 0 +const FUTEX_WAIT_BITSET = 9 +const FUTEX_WAKE = 1 +const FUTEX_WAKE_OP = 5 +const GAP_ABOVE_TP = 16 +const LC_ALL = 6 +const LC_ALL_MASK = 2147483647 +const LC_COLLATE = 3 +const LC_COLLATE_MASK = 8 +const LC_CTYPE = 0 +const LC_CTYPE_MASK = 1 +const LC_GLOBAL_LOCALE = -1 +const LC_MESSAGES = 5 +const LC_MESSAGES_MASK = 32 +const LC_MONETARY = 4 +const LC_MONETARY_MASK = 16 +const LC_NUMERIC = 1 +const LC_NUMERIC_MASK = 2 +const LC_TIME = 2 +const LC_TIME_MASK = 4 +const LOCALE_NAME_MAX = 23 +const MAP_ANON = 32 +const MAP_ANONYMOUS = 32 +const MAP_DENYWRITE = 2048 +const MAP_EXECUTABLE = 4096 +const MAP_FAILED = -1 +const MAP_FILE = 0 +const MAP_FIXED = 16 +const MAP_FIXED_NOREPLACE = 1048576 +const MAP_GROWSDOWN = 256 +const MAP_HUGETLB = 262144 +const MAP_HUGE_16GB = 2281701376 +const MAP_HUGE_16KB = 939524096 +const MAP_HUGE_16MB = 1610612736 +const MAP_HUGE_1GB = 2013265920 +const MAP_HUGE_1MB = 1342177280 +const MAP_HUGE_256MB = 1879048192 +const MAP_HUGE_2GB = 2080374784 +const MAP_HUGE_2MB = 1409286144 +const MAP_HUGE_32MB = 1677721600 +const MAP_HUGE_512KB = 1275068416 +const MAP_HUGE_512MB = 1946157056 +const MAP_HUGE_64KB = 1073741824 +const MAP_HUGE_8MB = 1543503872 +const MAP_HUGE_MASK = 63 +const MAP_HUGE_SHIFT = 26 +const MAP_LOCKED = 8192 +const MAP_NONBLOCK = 65536 +const MAP_NORESERVE = 16384 +const MAP_POPULATE = 32768 +const MAP_PRIVATE = 2 +const MAP_SHARED = 1 +const MAP_SHARED_VALIDATE = 3 +const MAP_STACK = 131072 +const MAP_SYNC = 524288 +const MAP_TYPE = 15 +const MCL_CURRENT = 1 +const MCL_FUTURE = 2 +const MCL_ONFAULT = 4 +const MC_PC = 0 +const MS_ASYNC = 1 +const MS_INVALIDATE = 2 +const MS_SYNC = 4 +const POSIX_MADV_DONTNEED = 4 +const POSIX_MADV_NORMAL = 0 +const POSIX_MADV_RANDOM = 1 +const POSIX_MADV_SEQUENTIAL = 2 +const POSIX_MADV_WILLNEED = 3 +const PROT_BTI = 16 +const PROT_EXEC = 4 +const PROT_GROWSDOWN = 16777216 +const PROT_GROWSUP = 33554432 +const PROT_MTE = 32 +const PROT_NONE = 0 +const PROT_READ = 1 +const PROT_WRITE = 2 +const PTHREAD_BARRIER_SERIAL_THREAD = -1 +const PTHREAD_CANCELED = -1 +const PTHREAD_CANCEL_ASYNCHRONOUS = 1 +const PTHREAD_CANCEL_DEFERRED = 0 +const PTHREAD_CANCEL_DISABLE = 1 +const PTHREAD_CANCEL_ENABLE = 0 +const PTHREAD_CANCEL_MASKED = 2 +const PTHREAD_CREATE_DETACHED = 1 +const PTHREAD_CREATE_JOINABLE = 0 +const PTHREAD_EXPLICIT_SCHED = 1 +const PTHREAD_INHERIT_SCHED = 0 +const PTHREAD_MUTEX_DEFAULT = 0 +const PTHREAD_MUTEX_ERRORCHECK = 2 +const PTHREAD_MUTEX_NORMAL = 0 +const PTHREAD_MUTEX_RECURSIVE = 1 +const PTHREAD_MUTEX_ROBUST = 1 +const PTHREAD_MUTEX_STALLED = 0 +const PTHREAD_ONCE_INIT = 0 +const PTHREAD_PRIO_INHERIT = 1 +const PTHREAD_PRIO_NONE = 0 +const PTHREAD_PRIO_PROTECT = 2 +const PTHREAD_PROCESS_PRIVATE = 0 +const PTHREAD_PROCESS_SHARED = 1 +const PTHREAD_SCOPE_PROCESS = 1 +const PTHREAD_SCOPE_SYSTEM = 0 +const SCHED_BATCH = 3 +const SCHED_DEADLINE = 6 +const SCHED_FIFO = 1 +const SCHED_IDLE = 5 +const SCHED_OTHER = 0 +const SCHED_RESET_ON_FORK = 1073741824 +const SCHED_RR = 2 +const SIGCANCEL = 33 +const SIGSYNCCALL = 34 +const SIGTIMER = 32 +const TIMER_ABSTIME = 1 +const TIME_UTC = 1 +const TP_OFFSET = 0 +const UTF8_LOCALE = 0 +const __CCGO_SIZEOF_GO_MUTEX = 8 +const __SU = 0 +const a_spin = 0 +const pthread = 0 +const tls_mod_off_t = 0 + +type Tlconv = struct { + Fdecimal_point uintptr + Fthousands_sep uintptr + Fgrouping uintptr + Fint_curr_symbol uintptr + Fcurrency_symbol uintptr + Fmon_decimal_point uintptr + Fmon_thousands_sep uintptr + Fmon_grouping uintptr + Fpositive_sign uintptr + Fnegative_sign uintptr + Fint_frac_digits uint8 + Ffrac_digits uint8 + Fp_cs_precedes uint8 + Fp_sep_by_space uint8 + Fn_cs_precedes uint8 + Fn_sep_by_space uint8 + Fp_sign_posn uint8 + Fn_sign_posn uint8 + Fint_p_cs_precedes uint8 + Fint_p_sep_by_space uint8 + Fint_n_cs_precedes uint8 + Fint_n_sep_by_space uint8 + Fint_p_sign_posn uint8 + Fint_n_sign_posn uint8 +} + +type t__locale_map = struct { + Fmap1 uintptr + Fmap_size Tsize_t + Fname [24]uint8 + Fnext uintptr +} + +type Tclockid_t = int32 + +type t__pthread = struct { + Fself uintptr + Fprev uintptr + Fnext uintptr + Fsysinfo Tuintptr_t + Ftid int32 + Ferrno_val int32 + Fdetach_state int32 + Fcancel int32 + Fcanceldisable uint8 + Fcancelasync uint8 + F__ccgo50 uint8 + Fmap_base uintptr + Fmap_size Tsize_t + Fstack uintptr + Fstack_size Tsize_t + Fguard_size Tsize_t + Fresult uintptr + Fcancelbuf uintptr + Ftsd uintptr + Frobust_list struct { + Fhead uintptr + Foff int64 + Fpending uintptr + } + Fh_errno_val int32 + Ftimer_id int32 + Flocale Tlocale_t + Fkilllock [1]int32 + Fdlerror_buf uintptr + Fstdio_locks uintptr + F__ccgo_join_mutex [1]int64 + Fcanary Tuintptr_t + Fdtv uintptr +} + +type Tpthread_once_t = int32 + +type Tpthread_key_t = uint32 + +type Tpthread_spinlock_t = int32 + +type Tpthread_mutexattr_t = struct { + F__attr uint32 +} + +type Tpthread_condattr_t = struct { + F__attr uint32 +} + +type Tpthread_barrierattr_t = struct { + F__attr uint32 +} + +type Tpthread_rwlockattr_t = struct { + F__attr [2]uint32 +} + +type Tpthread_mutex_t = struct { + F__u struct { + F__vi [0][10]int32 + F__p [0][5]uintptr + F__i [10]int32 + } +} + +type Tpthread_cond_t = struct { + F__u struct { + F__vi [0][12]int32 + F__p [0][6]uintptr + F__i [12]int32 + } +} + +type Tpthread_rwlock_t = struct { + F__u struct { + F__vi [0][14]int32 + F__p [0][7]uintptr + F__i [14]int32 + } +} + +type Tpthread_barrier_t = struct { + F__u struct { + F__vi [0][8]int32 + F__p [0][4]uintptr + F__i [8]int32 + } +} + +type Tsched_param = struct { + Fsched_priority int32 + F__reserved1 int32 + F__reserved2 [2]struct { + F__reserved1 Ttime_t + F__reserved2 int64 + } + F__reserved3 int32 +} + +type Ttimer_t = uintptr + +type Ttm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__tm_gmtoff int64 + F__tm_zone uintptr +} + +type Titimerspec = struct { + Fit_interval Ttimespec + Fit_value Ttimespec +} + +type t__ptcb = struct { + F__f uintptr + F__x uintptr + F__next uintptr +} + +type Tmode_t = uint32 + +const _DT_EXITED = 0 +const _DT_EXITING = 1 +const _DT_JOINABLE = 2 +const _DT_DETACHED = 3 + +func X__ctype_get_mb_cur_max(tls *TLS) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v1 = int32(4) + } else { + v1 = int32(1) + } + return Uint64FromInt32(v1) +} + +var _table1 = [384]Tint32_t{ + 129: int32(1), + 130: int32(2), + 131: int32(3), + 132: int32(4), + 133: int32(5), + 134: int32(6), + 135: int32(7), + 136: int32(8), + 137: int32(9), + 138: int32(10), + 139: int32(11), + 140: int32(12), + 141: int32(13), + 142: int32(14), + 143: int32(15), + 144: int32(16), + 145: int32(17), + 146: int32(18), + 147: int32(19), + 148: int32(20), + 149: int32(21), + 150: int32(22), + 151: int32(23), + 152: int32(24), + 153: int32(25), + 154: int32(26), + 155: int32(27), + 156: int32(28), + 157: int32(29), + 158: int32(30), + 159: int32(31), + 160: int32(32), + 161: int32(33), + 162: int32(34), + 163: int32(35), + 164: int32(36), + 165: int32(37), + 166: int32(38), + 167: int32(39), + 168: int32(40), + 169: int32(41), + 170: int32(42), + 171: int32(43), + 172: int32(44), + 173: int32(45), + 174: int32(46), + 175: int32(47), + 176: int32(48), + 177: int32(49), + 178: int32(50), + 179: int32(51), + 180: int32(52), + 181: int32(53), + 182: int32(54), + 183: int32(55), + 184: int32(56), + 185: int32(57), + 186: int32(58), + 187: int32(59), + 188: int32(60), + 189: int32(61), + 190: int32(62), + 191: int32(63), + 192: int32(64), + 193: int32('a'), + 194: int32('b'), + 195: int32('c'), + 196: int32('d'), + 197: int32('e'), + 198: int32('f'), + 199: int32('g'), + 200: int32('h'), + 201: int32('i'), + 202: int32('j'), + 203: int32('k'), + 204: int32('l'), + 205: int32('m'), + 206: int32('n'), + 207: int32('o'), + 208: int32('p'), + 209: int32('q'), + 210: int32('r'), + 211: int32('s'), + 212: int32('t'), + 213: int32('u'), + 214: int32('v'), + 215: int32('w'), + 216: int32('x'), + 217: int32('y'), + 218: int32('z'), + 219: int32(91), + 220: int32(92), + 221: int32(93), + 222: int32(94), + 223: int32(95), + 224: int32(96), + 225: int32('a'), + 226: int32('b'), + 227: int32('c'), + 228: int32('d'), + 229: int32('e'), + 230: int32('f'), + 231: int32('g'), + 232: int32('h'), + 233: int32('i'), + 234: int32('j'), + 235: int32('k'), + 236: int32('l'), + 237: int32('m'), + 238: int32('n'), + 239: int32('o'), + 240: int32('p'), + 241: int32('q'), + 242: int32('r'), + 243: int32('s'), + 244: int32('t'), + 245: int32('u'), + 246: int32('v'), + 247: int32('w'), + 248: int32('x'), + 249: int32('y'), + 250: int32('z'), + 251: int32(123), + 252: int32(124), + 253: int32(125), + 254: int32(126), + 255: int32(127), +} + +var _ptable1 = uintptr(unsafe.Pointer(&_table1)) + uintptr(128)*4 + +func X__ctype_tolower_loc(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_ptable1)) +} + +var _table2 = [384]Tint32_t{ + 129: int32(1), + 130: int32(2), + 131: int32(3), + 132: int32(4), + 133: int32(5), + 134: int32(6), + 135: int32(7), + 136: int32(8), + 137: int32(9), + 138: int32(10), + 139: int32(11), + 140: int32(12), + 141: int32(13), + 142: int32(14), + 143: int32(15), + 144: int32(16), + 145: int32(17), + 146: int32(18), + 147: int32(19), + 148: int32(20), + 149: int32(21), + 150: int32(22), + 151: int32(23), + 152: int32(24), + 153: int32(25), + 154: int32(26), + 155: int32(27), + 156: int32(28), + 157: int32(29), + 158: int32(30), + 159: int32(31), + 160: int32(32), + 161: int32(33), + 162: int32(34), + 163: int32(35), + 164: int32(36), + 165: int32(37), + 166: int32(38), + 167: int32(39), + 168: int32(40), + 169: int32(41), + 170: int32(42), + 171: int32(43), + 172: int32(44), + 173: int32(45), + 174: int32(46), + 175: int32(47), + 176: int32(48), + 177: int32(49), + 178: int32(50), + 179: int32(51), + 180: int32(52), + 181: int32(53), + 182: int32(54), + 183: int32(55), + 184: int32(56), + 185: int32(57), + 186: int32(58), + 187: int32(59), + 188: int32(60), + 189: int32(61), + 190: int32(62), + 191: int32(63), + 192: int32(64), + 193: int32('A'), + 194: int32('B'), + 195: int32('C'), + 196: int32('D'), + 197: int32('E'), + 198: int32('F'), + 199: int32('G'), + 200: int32('H'), + 201: int32('I'), + 202: int32('J'), + 203: int32('K'), + 204: int32('L'), + 205: int32('M'), + 206: int32('N'), + 207: int32('O'), + 208: int32('P'), + 209: int32('Q'), + 210: int32('R'), + 211: int32('S'), + 212: int32('T'), + 213: int32('U'), + 214: int32('V'), + 215: int32('W'), + 216: int32('X'), + 217: int32('Y'), + 218: int32('Z'), + 219: int32(91), + 220: int32(92), + 221: int32(93), + 222: int32(94), + 223: int32(95), + 224: int32(96), + 225: int32('A'), + 226: int32('B'), + 227: int32('C'), + 228: int32('D'), + 229: int32('E'), + 230: int32('F'), + 231: int32('G'), + 232: int32('H'), + 233: int32('I'), + 234: int32('J'), + 235: int32('K'), + 236: int32('L'), + 237: int32('M'), + 238: int32('N'), + 239: int32('O'), + 240: int32('P'), + 241: int32('Q'), + 242: int32('R'), + 243: int32('S'), + 244: int32('T'), + 245: int32('U'), + 246: int32('V'), + 247: int32('W'), + 248: int32('X'), + 249: int32('Y'), + 250: int32('Z'), + 251: int32(123), + 252: int32(124), + 253: int32(125), + 254: int32(126), + 255: int32(127), +} + +var _ptable2 = uintptr(unsafe.Pointer(&_table2)) + uintptr(128)*4 + +func X__ctype_toupper_loc(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_ptable2)) +} + +func Xisalnum(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(BoolInt32(Uint32FromInt32(c)|uint32(32)-uint32('a') < uint32(26)) != 0 || BoolInt32(Uint32FromInt32(c)-uint32('0') < uint32(10)) != 0) +} + +func X__isalnum_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisalnum(tls, c) +} + +func Xisalnum_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isalnum_l(tls, c, l) +} + +func Xisalpha(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)|uint32(32)-uint32('a') < uint32(26)) +} + +func X__isalpha_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisalpha(tls, c) +} + +func Xisalpha_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isalpha_l(tls, c, l) +} + +func Xisascii(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(!(c & ^Int32FromInt32(0x7f) != 0)) +} + +func Xisblank(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(c == int32(' ') || c == int32('\t')) +} + +func X__isblank_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisblank(tls, c) +} + +func Xisblank_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isblank_l(tls, c, l) +} + +func Xiscntrl(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c) < uint32(0x20) || c == int32(0x7f)) +} + +func X__iscntrl_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiscntrl(tls, c) +} + +func Xiscntrl_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iscntrl_l(tls, c, l) +} + +func Xisdigit(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32('0') < uint32(10)) +} + +func X__isdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisdigit(tls, c) +} + +func Xisdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isdigit_l(tls, c, l) +} + +func Xisgraph(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32(0x21) < uint32(0x5e)) +} + +func X__isgraph_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisgraph(tls, c) +} + +func Xisgraph_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isgraph_l(tls, c, l) +} + +func Xislower(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32('a') < uint32(26)) +} + +func X__islower_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xislower(tls, c) +} + +func Xislower_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__islower_l(tls, c, l) +} + +func Xisprint(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32(0x20) < uint32(0x5f)) +} + +func X__isprint_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisprint(tls, c) +} + +func Xisprint_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isprint_l(tls, c, l) +} + +func Xispunct(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(BoolInt32(Uint32FromInt32(c)-uint32(0x21) < uint32(0x5e)) != 0 && !(Xisalnum(tls, c) != 0)) +} + +func X__ispunct_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xispunct(tls, c) +} + +func Xispunct_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__ispunct_l(tls, c, l) +} + +func Xisspace(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(c == int32(' ') || Uint32FromInt32(c)-uint32('\t') < uint32(5)) +} + +func X__isspace_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisspace(tls, c) +} + +func Xisspace_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isspace_l(tls, c, l) +} + +func Xisupper(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Uint32FromInt32(c)-uint32('A') < uint32(26)) +} + +func X__isupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisupper(tls, c) +} + +func Xisupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isupper_l(tls, c, l) +} + +type Twint_t = uint32 + +type Twctype_t = uint64 + +type Twctrans_t = uintptr + +func Xiswalnum(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(BoolInt32(wc-uint32('0') < uint32(10)) != 0 || Xiswalpha(tls, wc) != 0) +} + +func X__iswalnum_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswalnum(tls, c) +} + +func Xiswalnum_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswalnum_l(tls, c, l) +} + +var _table3 = [3904]uint8{ + 0: uint8(18), + 1: uint8(17), + 2: uint8(19), + 3: uint8(20), + 4: uint8(21), + 5: uint8(22), + 6: uint8(23), + 7: uint8(24), + 8: uint8(25), + 9: uint8(26), + 10: uint8(27), + 11: uint8(28), + 12: uint8(29), + 13: uint8(30), + 14: uint8(31), + 15: uint8(32), + 16: uint8(33), + 17: uint8(17), + 18: uint8(34), + 19: uint8(35), + 20: uint8(36), + 21: uint8(17), + 22: uint8(37), + 23: uint8(38), + 24: uint8(39), + 25: uint8(40), + 26: uint8(41), + 27: uint8(42), + 28: uint8(43), + 29: uint8(44), + 30: uint8(17), + 31: uint8(45), + 32: uint8(46), + 33: uint8(47), + 34: uint8(16), + 35: uint8(16), + 36: uint8(48), + 37: uint8(16), + 38: uint8(16), + 39: uint8(16), + 40: uint8(16), + 41: uint8(16), + 42: uint8(16), + 43: uint8(16), + 44: uint8(49), + 45: uint8(50), + 46: uint8(51), + 47: uint8(16), + 48: uint8(52), + 49: uint8(53), + 50: uint8(16), + 51: uint8(16), + 52: uint8(17), + 53: uint8(17), + 54: uint8(17), + 55: uint8(17), + 56: uint8(17), + 57: uint8(17), + 58: uint8(17), + 59: uint8(17), + 60: uint8(17), + 61: uint8(17), + 62: uint8(17), + 63: uint8(17), + 64: uint8(17), + 65: uint8(17), + 66: uint8(17), + 67: uint8(17), + 68: uint8(17), + 69: uint8(17), + 70: uint8(17), + 71: uint8(17), + 72: uint8(17), + 73: uint8(17), + 74: uint8(17), + 75: uint8(17), + 76: uint8(17), + 77: uint8(54), + 78: uint8(17), + 79: uint8(17), + 80: uint8(17), + 81: uint8(17), + 82: uint8(17), + 83: uint8(17), + 84: uint8(17), + 85: uint8(17), + 86: uint8(17), + 87: uint8(17), + 88: uint8(17), + 89: uint8(17), + 90: uint8(17), + 91: uint8(17), + 92: uint8(17), + 93: uint8(17), + 94: uint8(17), + 95: uint8(17), + 96: uint8(17), + 97: uint8(17), + 98: uint8(17), + 99: uint8(17), + 100: uint8(17), + 101: uint8(17), + 102: uint8(17), + 103: uint8(17), + 104: uint8(17), + 105: uint8(17), + 106: uint8(17), + 107: uint8(17), + 108: uint8(17), + 109: uint8(17), + 110: uint8(17), + 111: uint8(17), + 112: uint8(17), + 113: uint8(17), + 114: uint8(17), + 115: uint8(17), + 116: uint8(17), + 117: uint8(17), + 118: uint8(17), + 119: uint8(17), + 120: uint8(17), + 121: uint8(17), + 122: uint8(17), + 123: uint8(17), + 124: uint8(17), + 125: uint8(17), + 126: uint8(17), + 127: uint8(17), + 128: uint8(17), + 129: uint8(17), + 130: uint8(17), + 131: uint8(17), + 132: uint8(17), + 133: uint8(17), + 134: uint8(17), + 135: uint8(17), + 136: uint8(17), + 137: uint8(17), + 138: uint8(17), + 139: uint8(17), + 140: uint8(17), + 141: uint8(17), + 142: uint8(17), + 143: uint8(17), + 144: uint8(17), + 145: uint8(17), + 146: uint8(17), + 147: uint8(17), + 148: uint8(17), + 149: uint8(17), + 150: uint8(17), + 151: uint8(17), + 152: uint8(17), + 153: uint8(17), + 154: uint8(17), + 155: uint8(17), + 156: uint8(17), + 157: uint8(17), + 158: uint8(17), + 159: uint8(55), + 160: uint8(17), + 161: uint8(17), + 162: uint8(17), + 163: uint8(17), + 164: uint8(56), + 165: uint8(17), + 166: uint8(57), + 167: uint8(58), + 168: uint8(59), + 169: uint8(60), + 170: uint8(61), + 171: uint8(62), + 172: uint8(17), + 173: uint8(17), + 174: uint8(17), + 175: uint8(17), + 176: uint8(17), + 177: uint8(17), + 178: uint8(17), + 179: uint8(17), + 180: uint8(17), + 181: uint8(17), + 182: uint8(17), + 183: uint8(17), + 184: uint8(17), + 185: uint8(17), + 186: uint8(17), + 187: uint8(17), + 188: uint8(17), + 189: uint8(17), + 190: uint8(17), + 191: uint8(17), + 192: uint8(17), + 193: uint8(17), + 194: uint8(17), + 195: uint8(17), + 196: uint8(17), + 197: uint8(17), + 198: uint8(17), + 199: uint8(17), + 200: uint8(17), + 201: uint8(17), + 202: uint8(17), + 203: uint8(17), + 204: uint8(17), + 205: uint8(17), + 206: uint8(17), + 207: uint8(17), + 208: uint8(17), + 209: uint8(17), + 210: uint8(17), + 211: uint8(17), + 212: uint8(17), + 213: uint8(17), + 214: uint8(17), + 215: uint8(63), + 216: uint8(16), + 217: uint8(16), + 218: uint8(16), + 219: uint8(16), + 220: uint8(16), + 221: uint8(16), + 222: uint8(16), + 223: uint8(16), + 224: uint8(16), + 225: uint8(16), + 226: uint8(16), + 227: uint8(16), + 228: uint8(16), + 229: uint8(16), + 230: uint8(16), + 231: uint8(16), + 232: uint8(16), + 233: uint8(16), + 234: uint8(16), + 235: uint8(16), + 236: uint8(16), + 237: uint8(16), + 238: uint8(16), + 239: uint8(16), + 240: uint8(16), + 241: uint8(16), + 242: uint8(16), + 243: uint8(16), + 244: uint8(16), + 245: uint8(16), + 246: uint8(16), + 247: uint8(16), + 248: uint8(16), + 249: uint8(17), + 250: uint8(64), + 251: uint8(65), + 252: uint8(17), + 253: uint8(66), + 254: uint8(67), + 255: uint8(68), + 256: uint8(69), + 257: uint8(70), + 258: uint8(71), + 259: uint8(72), + 260: uint8(73), + 261: uint8(74), + 262: uint8(17), + 263: uint8(75), + 264: uint8(76), + 265: uint8(77), + 266: uint8(78), + 267: uint8(79), + 268: uint8(80), + 269: uint8(81), + 270: uint8(16), + 271: uint8(82), + 272: uint8(83), + 273: uint8(84), + 274: uint8(85), + 275: uint8(86), + 276: uint8(87), + 277: uint8(88), + 278: uint8(89), + 279: uint8(90), + 280: uint8(91), + 281: uint8(92), + 282: uint8(93), + 283: uint8(16), + 284: uint8(94), + 285: uint8(95), + 286: uint8(96), + 287: uint8(16), + 288: uint8(17), + 289: uint8(17), + 290: uint8(17), + 291: uint8(97), + 292: uint8(98), + 293: uint8(99), + 294: uint8(16), + 295: uint8(16), + 296: uint8(16), + 297: uint8(16), + 298: uint8(16), + 299: uint8(16), + 300: uint8(16), + 301: uint8(16), + 302: uint8(16), + 303: uint8(16), + 304: uint8(17), + 305: uint8(17), + 306: uint8(17), + 307: uint8(17), + 308: uint8(100), + 309: uint8(16), + 310: uint8(16), + 311: uint8(16), + 312: uint8(16), + 313: uint8(16), + 314: uint8(16), + 315: uint8(16), + 316: uint8(16), + 317: uint8(16), + 318: uint8(16), + 319: uint8(16), + 320: uint8(16), + 321: uint8(16), + 322: uint8(16), + 323: uint8(16), + 324: uint8(17), + 325: uint8(17), + 326: uint8(101), + 327: uint8(16), + 328: uint8(16), + 329: uint8(16), + 330: uint8(16), + 331: uint8(16), + 332: uint8(16), + 333: uint8(16), + 334: uint8(16), + 335: uint8(16), + 336: uint8(16), + 337: uint8(16), + 338: uint8(16), + 339: uint8(16), + 340: uint8(16), + 341: uint8(16), + 342: uint8(16), + 343: uint8(16), + 344: uint8(16), + 345: uint8(16), + 346: uint8(16), + 347: uint8(16), + 348: uint8(16), + 349: uint8(16), + 350: uint8(16), + 351: uint8(16), + 352: uint8(16), + 353: uint8(16), + 354: uint8(16), + 355: uint8(16), + 356: uint8(16), + 357: uint8(16), + 358: uint8(16), + 359: uint8(16), + 360: uint8(17), + 361: uint8(17), + 362: uint8(102), + 363: uint8(103), + 364: uint8(16), + 365: uint8(16), + 366: uint8(104), + 367: uint8(105), + 368: uint8(17), + 369: uint8(17), + 370: uint8(17), + 371: uint8(17), + 372: uint8(17), + 373: uint8(17), + 374: uint8(17), + 375: uint8(17), + 376: uint8(17), + 377: uint8(17), + 378: uint8(17), + 379: uint8(17), + 380: uint8(17), + 381: uint8(17), + 382: uint8(17), + 383: uint8(17), + 384: uint8(17), + 385: uint8(17), + 386: uint8(17), + 387: uint8(17), + 388: uint8(17), + 389: uint8(17), + 390: uint8(17), + 391: uint8(106), + 392: uint8(17), + 393: uint8(17), + 394: uint8(107), + 395: uint8(16), + 396: uint8(16), + 397: uint8(16), + 398: uint8(16), + 399: uint8(16), + 400: uint8(16), + 401: uint8(16), + 402: uint8(16), + 403: uint8(16), + 404: uint8(16), + 405: uint8(16), + 406: uint8(16), + 407: uint8(16), + 408: uint8(16), + 409: uint8(16), + 410: uint8(16), + 411: uint8(16), + 412: uint8(16), + 413: uint8(16), + 414: uint8(16), + 415: uint8(16), + 416: uint8(16), + 417: uint8(16), + 418: uint8(16), + 419: uint8(16), + 420: uint8(16), + 421: uint8(16), + 422: uint8(16), + 423: uint8(16), + 424: uint8(16), + 425: uint8(16), + 426: uint8(16), + 427: uint8(16), + 428: uint8(16), + 429: uint8(16), + 430: uint8(16), + 431: uint8(16), + 432: uint8(17), + 433: uint8(108), + 434: uint8(109), + 435: uint8(16), + 436: uint8(16), + 437: uint8(16), + 438: uint8(16), + 439: uint8(16), + 440: uint8(16), + 441: uint8(16), + 442: uint8(16), + 443: uint8(16), + 444: uint8(110), + 445: uint8(16), + 446: uint8(16), + 447: uint8(16), + 448: uint8(16), + 449: uint8(16), + 450: uint8(16), + 451: uint8(16), + 452: uint8(16), + 453: uint8(16), + 454: uint8(16), + 455: uint8(16), + 456: uint8(16), + 457: uint8(16), + 458: uint8(16), + 459: uint8(16), + 460: uint8(16), + 461: uint8(16), + 462: uint8(16), + 463: uint8(16), + 464: uint8(16), + 465: uint8(16), + 466: uint8(16), + 467: uint8(16), + 468: uint8(111), + 469: uint8(112), + 470: uint8(113), + 471: uint8(114), + 472: uint8(16), + 473: uint8(16), + 474: uint8(16), + 475: uint8(16), + 476: uint8(16), + 477: uint8(16), + 478: uint8(16), + 479: uint8(16), + 480: uint8(115), + 481: uint8(116), + 482: uint8(117), + 483: uint8(16), + 484: uint8(16), + 485: uint8(16), + 486: uint8(16), + 487: uint8(16), + 488: uint8(118), + 489: uint8(119), + 490: uint8(16), + 491: uint8(16), + 492: uint8(16), + 493: uint8(16), + 494: uint8(120), + 495: uint8(16), + 496: uint8(16), + 497: uint8(121), + 498: uint8(16), + 499: uint8(16), + 500: uint8(16), + 501: uint8(16), + 502: uint8(16), + 503: uint8(16), + 504: uint8(16), + 505: uint8(16), + 506: uint8(16), + 507: uint8(16), + 508: uint8(16), + 509: uint8(16), + 510: uint8(16), + 511: uint8(16), + 544: uint8(255), + 545: uint8(255), + 546: uint8(255), + 547: uint8(255), + 548: uint8(255), + 549: uint8(255), + 550: uint8(255), + 551: uint8(255), + 552: uint8(255), + 553: uint8(255), + 554: uint8(255), + 555: uint8(255), + 556: uint8(255), + 557: uint8(255), + 558: uint8(255), + 559: uint8(255), + 560: uint8(255), + 561: uint8(255), + 562: uint8(255), + 563: uint8(255), + 564: uint8(255), + 565: uint8(255), + 566: uint8(255), + 567: uint8(255), + 568: uint8(255), + 569: uint8(255), + 570: uint8(255), + 571: uint8(255), + 572: uint8(255), + 573: uint8(255), + 574: uint8(255), + 575: uint8(255), + 584: uint8(254), + 585: uint8(255), + 586: uint8(255), + 587: uint8(7), + 588: uint8(254), + 589: uint8(255), + 590: uint8(255), + 591: uint8(7), + 597: uint8(4), + 598: uint8(32), + 599: uint8(4), + 600: uint8(255), + 601: uint8(255), + 602: uint8(127), + 603: uint8(255), + 604: uint8(255), + 605: uint8(255), + 606: uint8(127), + 607: uint8(255), + 608: uint8(255), + 609: uint8(255), + 610: uint8(255), + 611: uint8(255), + 612: uint8(255), + 613: uint8(255), + 614: uint8(255), + 615: uint8(255), + 616: uint8(255), + 617: uint8(255), + 618: uint8(255), + 619: uint8(255), + 620: uint8(255), + 621: uint8(255), + 622: uint8(255), + 623: uint8(255), + 624: uint8(255), + 625: uint8(255), + 626: uint8(255), + 627: uint8(255), + 628: uint8(255), + 629: uint8(255), + 630: uint8(255), + 631: uint8(255), + 632: uint8(195), + 633: uint8(255), + 634: uint8(3), + 636: uint8(31), + 637: uint8(80), + 648: uint8(32), + 654: uint8(223), + 655: uint8(188), + 656: uint8(64), + 657: uint8(215), + 658: uint8(255), + 659: uint8(255), + 660: uint8(251), + 661: uint8(255), + 662: uint8(255), + 663: uint8(255), + 664: uint8(255), + 665: uint8(255), + 666: uint8(255), + 667: uint8(255), + 668: uint8(255), + 669: uint8(255), + 670: uint8(191), + 671: uint8(255), + 672: uint8(255), + 673: uint8(255), + 674: uint8(255), + 675: uint8(255), + 676: uint8(255), + 677: uint8(255), + 678: uint8(255), + 679: uint8(255), + 680: uint8(255), + 681: uint8(255), + 682: uint8(255), + 683: uint8(255), + 684: uint8(255), + 685: uint8(255), + 686: uint8(255), + 687: uint8(255), + 688: uint8(3), + 689: uint8(252), + 690: uint8(255), + 691: uint8(255), + 692: uint8(255), + 693: uint8(255), + 694: uint8(255), + 695: uint8(255), + 696: uint8(255), + 697: uint8(255), + 698: uint8(255), + 699: uint8(255), + 700: uint8(255), + 701: uint8(255), + 702: uint8(255), + 703: uint8(255), + 704: uint8(255), + 705: uint8(255), + 706: uint8(255), + 707: uint8(255), + 708: uint8(255), + 709: uint8(255), + 710: uint8(254), + 711: uint8(255), + 712: uint8(255), + 713: uint8(255), + 714: uint8(127), + 715: uint8(2), + 716: uint8(255), + 717: uint8(255), + 718: uint8(255), + 719: uint8(255), + 720: uint8(255), + 721: uint8(1), + 726: uint8(255), + 727: uint8(191), + 728: uint8(182), + 730: uint8(255), + 731: uint8(255), + 732: uint8(255), + 733: uint8(135), + 734: uint8(7), + 738: uint8(255), + 739: uint8(7), + 740: uint8(255), + 741: uint8(255), + 742: uint8(255), + 743: uint8(255), + 744: uint8(255), + 745: uint8(255), + 746: uint8(255), + 747: uint8(254), + 748: uint8(255), + 749: uint8(195), + 750: uint8(255), + 751: uint8(255), + 752: uint8(255), + 753: uint8(255), + 754: uint8(255), + 755: uint8(255), + 756: uint8(255), + 757: uint8(255), + 758: uint8(255), + 759: uint8(255), + 760: uint8(255), + 761: uint8(255), + 762: uint8(239), + 763: uint8(31), + 764: uint8(254), + 765: uint8(225), + 766: uint8(255), + 767: uint8(159), + 770: uint8(255), + 771: uint8(255), + 772: uint8(255), + 773: uint8(255), + 774: uint8(255), + 775: uint8(255), + 777: uint8(224), + 778: uint8(255), + 779: uint8(255), + 780: uint8(255), + 781: uint8(255), + 782: uint8(255), + 783: uint8(255), + 784: uint8(255), + 785: uint8(255), + 786: uint8(255), + 787: uint8(255), + 788: uint8(255), + 789: uint8(255), + 790: uint8(3), + 792: uint8(255), + 793: uint8(255), + 794: uint8(255), + 795: uint8(255), + 796: uint8(255), + 797: uint8(7), + 798: uint8(48), + 799: uint8(4), + 800: uint8(255), + 801: uint8(255), + 802: uint8(255), + 803: uint8(252), + 804: uint8(255), + 805: uint8(31), + 808: uint8(255), + 809: uint8(255), + 810: uint8(255), + 811: uint8(1), + 812: uint8(255), + 813: uint8(7), + 820: uint8(255), + 821: uint8(255), + 822: uint8(223), + 823: uint8(63), + 826: uint8(240), + 827: uint8(255), + 828: uint8(248), + 829: uint8(3), + 830: uint8(255), + 831: uint8(255), + 832: uint8(255), + 833: uint8(255), + 834: uint8(255), + 835: uint8(255), + 836: uint8(255), + 837: uint8(255), + 838: uint8(255), + 839: uint8(239), + 840: uint8(255), + 841: uint8(223), + 842: uint8(225), + 843: uint8(255), + 844: uint8(207), + 845: uint8(255), + 846: uint8(254), + 847: uint8(255), + 848: uint8(239), + 849: uint8(159), + 850: uint8(249), + 851: uint8(255), + 852: uint8(255), + 853: uint8(253), + 854: uint8(197), + 855: uint8(227), + 856: uint8(159), + 857: uint8(89), + 858: uint8(128), + 859: uint8(176), + 860: uint8(207), + 861: uint8(255), + 862: uint8(3), + 863: uint8(16), + 864: uint8(238), + 865: uint8(135), + 866: uint8(249), + 867: uint8(255), + 868: uint8(255), + 869: uint8(253), + 870: uint8(109), + 871: uint8(195), + 872: uint8(135), + 873: uint8(25), + 874: uint8(2), + 875: uint8(94), + 876: uint8(192), + 877: uint8(255), + 878: uint8(63), + 880: uint8(238), + 881: uint8(191), + 882: uint8(251), + 883: uint8(255), + 884: uint8(255), + 885: uint8(253), + 886: uint8(237), + 887: uint8(227), + 888: uint8(191), + 889: uint8(27), + 890: uint8(1), + 892: uint8(207), + 893: uint8(255), + 895: uint8(30), + 896: uint8(238), + 897: uint8(159), + 898: uint8(249), + 899: uint8(255), + 900: uint8(255), + 901: uint8(253), + 902: uint8(237), + 903: uint8(227), + 904: uint8(159), + 905: uint8(25), + 906: uint8(192), + 907: uint8(176), + 908: uint8(207), + 909: uint8(255), + 910: uint8(2), + 912: uint8(236), + 913: uint8(199), + 914: uint8(61), + 915: uint8(214), + 916: uint8(24), + 917: uint8(199), + 918: uint8(255), + 919: uint8(195), + 920: uint8(199), + 921: uint8(29), + 922: uint8(129), + 924: uint8(192), + 925: uint8(255), + 928: uint8(239), + 929: uint8(223), + 930: uint8(253), + 931: uint8(255), + 932: uint8(255), + 933: uint8(253), + 934: uint8(255), + 935: uint8(227), + 936: uint8(223), + 937: uint8(29), + 938: uint8(96), + 939: uint8(7), + 940: uint8(207), + 941: uint8(255), + 944: uint8(239), + 945: uint8(223), + 946: uint8(253), + 947: uint8(255), + 948: uint8(255), + 949: uint8(253), + 950: uint8(239), + 951: uint8(227), + 952: uint8(223), + 953: uint8(29), + 954: uint8(96), + 955: uint8(64), + 956: uint8(207), + 957: uint8(255), + 958: uint8(6), + 960: uint8(239), + 961: uint8(223), + 962: uint8(253), + 963: uint8(255), + 964: uint8(255), + 965: uint8(255), + 966: uint8(255), + 967: uint8(231), + 968: uint8(223), + 969: uint8(93), + 970: uint8(240), + 971: uint8(128), + 972: uint8(207), + 973: uint8(255), + 975: uint8(252), + 976: uint8(236), + 977: uint8(255), + 978: uint8(127), + 979: uint8(252), + 980: uint8(255), + 981: uint8(255), + 982: uint8(251), + 983: uint8(47), + 984: uint8(127), + 985: uint8(128), + 986: uint8(95), + 987: uint8(255), + 988: uint8(192), + 989: uint8(255), + 990: uint8(12), + 992: uint8(254), + 993: uint8(255), + 994: uint8(255), + 995: uint8(255), + 996: uint8(255), + 997: uint8(127), + 998: uint8(255), + 999: uint8(7), + 1000: uint8(63), + 1001: uint8(32), + 1002: uint8(255), + 1003: uint8(3), + 1008: uint8(214), + 1009: uint8(247), + 1010: uint8(255), + 1011: uint8(255), + 1012: uint8(175), + 1013: uint8(255), + 1014: uint8(255), + 1015: uint8(59), + 1016: uint8(95), + 1017: uint8(32), + 1018: uint8(255), + 1019: uint8(243), + 1024: uint8(1), + 1028: uint8(255), + 1029: uint8(3), + 1032: uint8(255), + 1033: uint8(254), + 1034: uint8(255), + 1035: uint8(255), + 1036: uint8(255), + 1037: uint8(31), + 1038: uint8(254), + 1039: uint8(255), + 1040: uint8(3), + 1041: uint8(255), + 1042: uint8(255), + 1043: uint8(254), + 1044: uint8(255), + 1045: uint8(255), + 1046: uint8(255), + 1047: uint8(31), + 1056: uint8(255), + 1057: uint8(255), + 1058: uint8(255), + 1059: uint8(255), + 1060: uint8(255), + 1061: uint8(255), + 1062: uint8(127), + 1063: uint8(249), + 1064: uint8(255), + 1065: uint8(3), + 1066: uint8(255), + 1067: uint8(255), + 1068: uint8(255), + 1069: uint8(255), + 1070: uint8(255), + 1071: uint8(255), + 1072: uint8(255), + 1073: uint8(255), + 1074: uint8(255), + 1075: uint8(63), + 1076: uint8(255), + 1077: uint8(255), + 1078: uint8(255), + 1079: uint8(255), + 1080: uint8(191), + 1081: uint8(32), + 1082: uint8(255), + 1083: uint8(255), + 1084: uint8(255), + 1085: uint8(255), + 1086: uint8(255), + 1087: uint8(247), + 1088: uint8(255), + 1089: uint8(255), + 1090: uint8(255), + 1091: uint8(255), + 1092: uint8(255), + 1093: uint8(255), + 1094: uint8(255), + 1095: uint8(255), + 1096: uint8(255), + 1097: uint8(61), + 1098: uint8(127), + 1099: uint8(61), + 1100: uint8(255), + 1101: uint8(255), + 1102: uint8(255), + 1103: uint8(255), + 1104: uint8(255), + 1105: uint8(61), + 1106: uint8(255), + 1107: uint8(255), + 1108: uint8(255), + 1109: uint8(255), + 1110: uint8(61), + 1111: uint8(127), + 1112: uint8(61), + 1113: uint8(255), + 1114: uint8(127), + 1115: uint8(255), + 1116: uint8(255), + 1117: uint8(255), + 1118: uint8(255), + 1119: uint8(255), + 1120: uint8(255), + 1121: uint8(255), + 1122: uint8(61), + 1123: uint8(255), + 1124: uint8(255), + 1125: uint8(255), + 1126: uint8(255), + 1127: uint8(255), + 1128: uint8(255), + 1129: uint8(255), + 1130: uint8(255), + 1131: uint8(7), + 1136: uint8(255), + 1137: uint8(255), + 1140: uint8(255), + 1141: uint8(255), + 1142: uint8(255), + 1143: uint8(255), + 1144: uint8(255), + 1145: uint8(255), + 1146: uint8(255), + 1147: uint8(255), + 1148: uint8(255), + 1149: uint8(255), + 1150: uint8(63), + 1151: uint8(63), + 1152: uint8(254), + 1153: uint8(255), + 1154: uint8(255), + 1155: uint8(255), + 1156: uint8(255), + 1157: uint8(255), + 1158: uint8(255), + 1159: uint8(255), + 1160: uint8(255), + 1161: uint8(255), + 1162: uint8(255), + 1163: uint8(255), + 1164: uint8(255), + 1165: uint8(255), + 1166: uint8(255), + 1167: uint8(255), + 1168: uint8(255), + 1169: uint8(255), + 1170: uint8(255), + 1171: uint8(255), + 1172: uint8(255), + 1173: uint8(255), + 1174: uint8(255), + 1175: uint8(255), + 1176: uint8(255), + 1177: uint8(255), + 1178: uint8(255), + 1179: uint8(255), + 1180: uint8(255), + 1181: uint8(255), + 1182: uint8(255), + 1183: uint8(255), + 1184: uint8(255), + 1185: uint8(255), + 1186: uint8(255), + 1187: uint8(255), + 1188: uint8(255), + 1189: uint8(255), + 1190: uint8(255), + 1191: uint8(255), + 1192: uint8(255), + 1193: uint8(255), + 1194: uint8(255), + 1195: uint8(255), + 1196: uint8(255), + 1197: uint8(159), + 1198: uint8(255), + 1199: uint8(255), + 1200: uint8(254), + 1201: uint8(255), + 1202: uint8(255), + 1203: uint8(7), + 1204: uint8(255), + 1205: uint8(255), + 1206: uint8(255), + 1207: uint8(255), + 1208: uint8(255), + 1209: uint8(255), + 1210: uint8(255), + 1211: uint8(255), + 1212: uint8(255), + 1213: uint8(199), + 1214: uint8(255), + 1215: uint8(1), + 1216: uint8(255), + 1217: uint8(223), + 1218: uint8(15), + 1220: uint8(255), + 1221: uint8(255), + 1222: uint8(15), + 1224: uint8(255), + 1225: uint8(255), + 1226: uint8(15), + 1228: uint8(255), + 1229: uint8(223), + 1230: uint8(13), + 1232: uint8(255), + 1233: uint8(255), + 1234: uint8(255), + 1235: uint8(255), + 1236: uint8(255), + 1237: uint8(255), + 1238: uint8(207), + 1239: uint8(255), + 1240: uint8(255), + 1241: uint8(1), + 1242: uint8(128), + 1243: uint8(16), + 1244: uint8(255), + 1245: uint8(3), + 1250: uint8(255), + 1251: uint8(3), + 1252: uint8(255), + 1253: uint8(255), + 1254: uint8(255), + 1255: uint8(255), + 1256: uint8(255), + 1257: uint8(255), + 1258: uint8(255), + 1259: uint8(255), + 1260: uint8(255), + 1261: uint8(255), + 1262: uint8(255), + 1263: uint8(1), + 1264: uint8(255), + 1265: uint8(255), + 1266: uint8(255), + 1267: uint8(255), + 1268: uint8(255), + 1269: uint8(7), + 1270: uint8(255), + 1271: uint8(255), + 1272: uint8(255), + 1273: uint8(255), + 1274: uint8(255), + 1275: uint8(255), + 1276: uint8(255), + 1277: uint8(255), + 1278: uint8(63), + 1280: uint8(255), + 1281: uint8(255), + 1282: uint8(255), + 1283: uint8(127), + 1284: uint8(255), + 1285: uint8(15), + 1286: uint8(255), + 1287: uint8(1), + 1288: uint8(192), + 1289: uint8(255), + 1290: uint8(255), + 1291: uint8(255), + 1292: uint8(255), + 1293: uint8(63), + 1294: uint8(31), + 1296: uint8(255), + 1297: uint8(255), + 1298: uint8(255), + 1299: uint8(255), + 1300: uint8(255), + 1301: uint8(15), + 1302: uint8(255), + 1303: uint8(255), + 1304: uint8(255), + 1305: uint8(3), + 1306: uint8(255), + 1307: uint8(3), + 1312: uint8(255), + 1313: uint8(255), + 1314: uint8(255), + 1315: uint8(15), + 1316: uint8(255), + 1317: uint8(255), + 1318: uint8(255), + 1319: uint8(255), + 1320: uint8(255), + 1321: uint8(255), + 1322: uint8(255), + 1323: uint8(127), + 1324: uint8(254), + 1325: uint8(255), + 1326: uint8(31), + 1328: uint8(255), + 1329: uint8(3), + 1330: uint8(255), + 1331: uint8(3), + 1332: uint8(128), + 1344: uint8(255), + 1345: uint8(255), + 1346: uint8(255), + 1347: uint8(255), + 1348: uint8(255), + 1349: uint8(255), + 1350: uint8(239), + 1351: uint8(255), + 1352: uint8(239), + 1353: uint8(15), + 1354: uint8(255), + 1355: uint8(3), + 1360: uint8(255), + 1361: uint8(255), + 1362: uint8(255), + 1363: uint8(255), + 1364: uint8(255), + 1365: uint8(243), + 1366: uint8(255), + 1367: uint8(255), + 1368: uint8(255), + 1369: uint8(255), + 1370: uint8(255), + 1371: uint8(255), + 1372: uint8(191), + 1373: uint8(255), + 1374: uint8(3), + 1376: uint8(255), + 1377: uint8(255), + 1378: uint8(255), + 1379: uint8(255), + 1380: uint8(255), + 1381: uint8(255), + 1382: uint8(127), + 1384: uint8(255), + 1385: uint8(227), + 1386: uint8(255), + 1387: uint8(255), + 1388: uint8(255), + 1389: uint8(255), + 1390: uint8(255), + 1391: uint8(63), + 1392: uint8(255), + 1393: uint8(1), + 1394: uint8(255), + 1395: uint8(255), + 1396: uint8(255), + 1397: uint8(255), + 1398: uint8(255), + 1399: uint8(231), + 1405: uint8(222), + 1406: uint8(111), + 1407: uint8(4), + 1408: uint8(255), + 1409: uint8(255), + 1410: uint8(255), + 1411: uint8(255), + 1412: uint8(255), + 1413: uint8(255), + 1414: uint8(255), + 1415: uint8(255), + 1416: uint8(255), + 1417: uint8(255), + 1418: uint8(255), + 1419: uint8(255), + 1420: uint8(255), + 1421: uint8(255), + 1422: uint8(255), + 1423: uint8(255), + 1424: uint8(255), + 1425: uint8(255), + 1426: uint8(255), + 1427: uint8(255), + 1428: uint8(255), + 1429: uint8(255), + 1430: uint8(255), + 1431: uint8(255), + 1436: uint8(128), + 1437: uint8(255), + 1438: uint8(31), + 1440: uint8(255), + 1441: uint8(255), + 1442: uint8(63), + 1443: uint8(63), + 1444: uint8(255), + 1445: uint8(255), + 1446: uint8(255), + 1447: uint8(255), + 1448: uint8(63), + 1449: uint8(63), + 1450: uint8(255), + 1451: uint8(170), + 1452: uint8(255), + 1453: uint8(255), + 1454: uint8(255), + 1455: uint8(63), + 1456: uint8(255), + 1457: uint8(255), + 1458: uint8(255), + 1459: uint8(255), + 1460: uint8(255), + 1461: uint8(255), + 1462: uint8(223), + 1463: uint8(95), + 1464: uint8(220), + 1465: uint8(31), + 1466: uint8(207), + 1467: uint8(15), + 1468: uint8(255), + 1469: uint8(31), + 1470: uint8(220), + 1471: uint8(31), + 1486: uint8(2), + 1487: uint8(128), + 1490: uint8(255), + 1491: uint8(31), + 1504: uint8(132), + 1505: uint8(252), + 1506: uint8(47), + 1507: uint8(62), + 1508: uint8(80), + 1509: uint8(189), + 1510: uint8(255), + 1511: uint8(243), + 1512: uint8(224), + 1513: uint8(67), + 1516: uint8(255), + 1517: uint8(255), + 1518: uint8(255), + 1519: uint8(255), + 1520: uint8(255), + 1521: uint8(1), + 1558: uint8(192), + 1559: uint8(255), + 1560: uint8(255), + 1561: uint8(255), + 1562: uint8(255), + 1563: uint8(255), + 1564: uint8(255), + 1565: uint8(3), + 1568: uint8(255), + 1569: uint8(255), + 1570: uint8(255), + 1571: uint8(255), + 1572: uint8(255), + 1573: uint8(127), + 1574: uint8(255), + 1575: uint8(255), + 1576: uint8(255), + 1577: uint8(255), + 1578: uint8(255), + 1579: uint8(127), + 1580: uint8(255), + 1581: uint8(255), + 1582: uint8(255), + 1583: uint8(255), + 1584: uint8(255), + 1585: uint8(255), + 1586: uint8(255), + 1587: uint8(255), + 1588: uint8(255), + 1589: uint8(255), + 1590: uint8(255), + 1591: uint8(255), + 1592: uint8(255), + 1593: uint8(255), + 1594: uint8(255), + 1595: uint8(255), + 1596: uint8(31), + 1597: uint8(120), + 1598: uint8(12), + 1600: uint8(255), + 1601: uint8(255), + 1602: uint8(255), + 1603: uint8(255), + 1604: uint8(191), + 1605: uint8(32), + 1606: uint8(255), + 1607: uint8(255), + 1608: uint8(255), + 1609: uint8(255), + 1610: uint8(255), + 1611: uint8(255), + 1612: uint8(255), + 1613: uint8(128), + 1616: uint8(255), + 1617: uint8(255), + 1618: uint8(127), + 1620: uint8(127), + 1621: uint8(127), + 1622: uint8(127), + 1623: uint8(127), + 1624: uint8(127), + 1625: uint8(127), + 1626: uint8(127), + 1627: uint8(127), + 1628: uint8(255), + 1629: uint8(255), + 1630: uint8(255), + 1631: uint8(255), + 1637: uint8(128), + 1664: uint8(224), + 1668: uint8(254), + 1669: uint8(3), + 1670: uint8(62), + 1671: uint8(31), + 1672: uint8(254), + 1673: uint8(255), + 1674: uint8(255), + 1675: uint8(255), + 1676: uint8(255), + 1677: uint8(255), + 1678: uint8(255), + 1679: uint8(255), + 1680: uint8(255), + 1681: uint8(255), + 1682: uint8(127), + 1683: uint8(224), + 1684: uint8(254), + 1685: uint8(255), + 1686: uint8(255), + 1687: uint8(255), + 1688: uint8(255), + 1689: uint8(255), + 1690: uint8(255), + 1691: uint8(255), + 1692: uint8(255), + 1693: uint8(255), + 1694: uint8(255), + 1695: uint8(247), + 1696: uint8(224), + 1697: uint8(255), + 1698: uint8(255), + 1699: uint8(255), + 1700: uint8(255), + 1701: uint8(255), + 1702: uint8(254), + 1703: uint8(255), + 1704: uint8(255), + 1705: uint8(255), + 1706: uint8(255), + 1707: uint8(255), + 1708: uint8(255), + 1709: uint8(255), + 1710: uint8(255), + 1711: uint8(255), + 1712: uint8(255), + 1713: uint8(127), + 1716: uint8(255), + 1717: uint8(255), + 1718: uint8(255), + 1719: uint8(7), + 1726: uint8(255), + 1727: uint8(255), + 1728: uint8(255), + 1729: uint8(255), + 1730: uint8(255), + 1731: uint8(255), + 1732: uint8(255), + 1733: uint8(255), + 1734: uint8(255), + 1735: uint8(255), + 1736: uint8(255), + 1737: uint8(255), + 1738: uint8(255), + 1739: uint8(255), + 1740: uint8(255), + 1741: uint8(255), + 1742: uint8(255), + 1743: uint8(255), + 1744: uint8(255), + 1745: uint8(255), + 1746: uint8(255), + 1747: uint8(255), + 1748: uint8(255), + 1749: uint8(255), + 1750: uint8(63), + 1760: uint8(255), + 1761: uint8(255), + 1762: uint8(255), + 1763: uint8(255), + 1764: uint8(255), + 1765: uint8(255), + 1766: uint8(255), + 1767: uint8(255), + 1768: uint8(255), + 1769: uint8(255), + 1770: uint8(255), + 1771: uint8(255), + 1772: uint8(255), + 1773: uint8(255), + 1774: uint8(255), + 1775: uint8(255), + 1776: uint8(255), + 1777: uint8(255), + 1778: uint8(255), + 1779: uint8(255), + 1780: uint8(255), + 1781: uint8(255), + 1782: uint8(255), + 1783: uint8(255), + 1784: uint8(255), + 1785: uint8(255), + 1786: uint8(255), + 1787: uint8(255), + 1788: uint8(255), + 1789: uint8(255), + 1792: uint8(255), + 1793: uint8(255), + 1794: uint8(255), + 1795: uint8(255), + 1796: uint8(255), + 1797: uint8(255), + 1798: uint8(255), + 1799: uint8(255), + 1800: uint8(255), + 1801: uint8(255), + 1802: uint8(255), + 1803: uint8(255), + 1804: uint8(255), + 1805: uint8(255), + 1806: uint8(255), + 1807: uint8(255), + 1808: uint8(255), + 1809: uint8(31), + 1818: uint8(255), + 1819: uint8(255), + 1820: uint8(255), + 1821: uint8(255), + 1822: uint8(255), + 1823: uint8(63), + 1824: uint8(255), + 1825: uint8(31), + 1826: uint8(255), + 1827: uint8(255), + 1828: uint8(255), + 1829: uint8(15), + 1832: uint8(255), + 1833: uint8(255), + 1834: uint8(255), + 1835: uint8(255), + 1836: uint8(255), + 1837: uint8(127), + 1838: uint8(240), + 1839: uint8(143), + 1840: uint8(255), + 1841: uint8(255), + 1842: uint8(255), + 1843: uint8(255), + 1844: uint8(255), + 1845: uint8(255), + 1846: uint8(255), + 1847: uint8(255), + 1848: uint8(255), + 1849: uint8(255), + 1850: uint8(255), + 1851: uint8(255), + 1852: uint8(255), + 1853: uint8(255), + 1858: uint8(128), + 1859: uint8(255), + 1860: uint8(252), + 1861: uint8(255), + 1862: uint8(255), + 1863: uint8(255), + 1864: uint8(255), + 1865: uint8(255), + 1866: uint8(255), + 1867: uint8(255), + 1868: uint8(255), + 1869: uint8(255), + 1870: uint8(255), + 1871: uint8(255), + 1872: uint8(255), + 1873: uint8(249), + 1874: uint8(255), + 1875: uint8(255), + 1876: uint8(255), + 1877: uint8(255), + 1878: uint8(255), + 1879: uint8(255), + 1880: uint8(124), + 1886: uint8(128), + 1887: uint8(255), + 1888: uint8(191), + 1889: uint8(255), + 1890: uint8(255), + 1891: uint8(255), + 1892: uint8(255), + 1896: uint8(255), + 1897: uint8(255), + 1898: uint8(255), + 1899: uint8(255), + 1900: uint8(255), + 1901: uint8(255), + 1902: uint8(15), + 1904: uint8(255), + 1905: uint8(255), + 1906: uint8(255), + 1907: uint8(255), + 1908: uint8(255), + 1909: uint8(255), + 1910: uint8(255), + 1911: uint8(255), + 1912: uint8(47), + 1914: uint8(255), + 1915: uint8(3), + 1918: uint8(252), + 1919: uint8(232), + 1920: uint8(255), + 1921: uint8(255), + 1922: uint8(255), + 1923: uint8(255), + 1924: uint8(255), + 1925: uint8(7), + 1926: uint8(255), + 1927: uint8(255), + 1928: uint8(255), + 1929: uint8(255), + 1930: uint8(7), + 1932: uint8(255), + 1933: uint8(255), + 1934: uint8(255), + 1935: uint8(31), + 1936: uint8(255), + 1937: uint8(255), + 1938: uint8(255), + 1939: uint8(255), + 1940: uint8(255), + 1941: uint8(255), + 1942: uint8(247), + 1943: uint8(255), + 1945: uint8(128), + 1946: uint8(255), + 1947: uint8(3), + 1948: uint8(255), + 1949: uint8(255), + 1950: uint8(255), + 1951: uint8(127), + 1952: uint8(255), + 1953: uint8(255), + 1954: uint8(255), + 1955: uint8(255), + 1956: uint8(255), + 1957: uint8(255), + 1958: uint8(127), + 1960: uint8(255), + 1961: uint8(63), + 1962: uint8(255), + 1963: uint8(3), + 1964: uint8(255), + 1965: uint8(255), + 1966: uint8(127), + 1967: uint8(252), + 1968: uint8(255), + 1969: uint8(255), + 1970: uint8(255), + 1971: uint8(255), + 1972: uint8(255), + 1973: uint8(255), + 1974: uint8(255), + 1975: uint8(127), + 1976: uint8(5), + 1979: uint8(56), + 1980: uint8(255), + 1981: uint8(255), + 1982: uint8(60), + 1984: uint8(126), + 1985: uint8(126), + 1986: uint8(126), + 1988: uint8(127), + 1989: uint8(127), + 1990: uint8(255), + 1991: uint8(255), + 1992: uint8(255), + 1993: uint8(255), + 1994: uint8(255), + 1995: uint8(247), + 1996: uint8(255), + 1998: uint8(255), + 1999: uint8(255), + 2000: uint8(255), + 2001: uint8(255), + 2002: uint8(255), + 2003: uint8(255), + 2004: uint8(255), + 2005: uint8(255), + 2006: uint8(255), + 2007: uint8(255), + 2008: uint8(255), + 2009: uint8(255), + 2010: uint8(255), + 2011: uint8(255), + 2012: uint8(255), + 2013: uint8(7), + 2014: uint8(255), + 2015: uint8(3), + 2016: uint8(255), + 2017: uint8(255), + 2018: uint8(255), + 2019: uint8(255), + 2020: uint8(255), + 2021: uint8(255), + 2022: uint8(255), + 2023: uint8(255), + 2024: uint8(255), + 2025: uint8(255), + 2026: uint8(255), + 2027: uint8(255), + 2028: uint8(255), + 2029: uint8(255), + 2030: uint8(255), + 2031: uint8(255), + 2032: uint8(255), + 2033: uint8(255), + 2034: uint8(255), + 2035: uint8(255), + 2036: uint8(15), + 2038: uint8(255), + 2039: uint8(255), + 2040: uint8(127), + 2041: uint8(248), + 2042: uint8(255), + 2043: uint8(255), + 2044: uint8(255), + 2045: uint8(255), + 2046: uint8(255), + 2047: uint8(15), + 2048: uint8(255), + 2049: uint8(255), + 2050: uint8(255), + 2051: uint8(255), + 2052: uint8(255), + 2053: uint8(255), + 2054: uint8(255), + 2055: uint8(255), + 2056: uint8(255), + 2057: uint8(255), + 2058: uint8(255), + 2059: uint8(255), + 2060: uint8(255), + 2061: uint8(63), + 2062: uint8(255), + 2063: uint8(255), + 2064: uint8(255), + 2065: uint8(255), + 2066: uint8(255), + 2067: uint8(255), + 2068: uint8(255), + 2069: uint8(255), + 2070: uint8(255), + 2071: uint8(255), + 2072: uint8(255), + 2073: uint8(255), + 2074: uint8(255), + 2075: uint8(3), + 2080: uint8(127), + 2082: uint8(248), + 2083: uint8(224), + 2084: uint8(255), + 2085: uint8(253), + 2086: uint8(127), + 2087: uint8(95), + 2088: uint8(219), + 2089: uint8(255), + 2090: uint8(255), + 2091: uint8(255), + 2092: uint8(255), + 2093: uint8(255), + 2094: uint8(255), + 2095: uint8(255), + 2096: uint8(255), + 2097: uint8(255), + 2098: uint8(255), + 2099: uint8(255), + 2100: uint8(255), + 2101: uint8(255), + 2102: uint8(3), + 2106: uint8(248), + 2107: uint8(255), + 2108: uint8(255), + 2109: uint8(255), + 2110: uint8(255), + 2111: uint8(255), + 2112: uint8(255), + 2113: uint8(255), + 2114: uint8(255), + 2115: uint8(255), + 2116: uint8(255), + 2117: uint8(255), + 2118: uint8(255), + 2119: uint8(63), + 2122: uint8(255), + 2123: uint8(255), + 2124: uint8(255), + 2125: uint8(255), + 2126: uint8(255), + 2127: uint8(255), + 2128: uint8(255), + 2129: uint8(255), + 2130: uint8(252), + 2131: uint8(255), + 2132: uint8(255), + 2133: uint8(255), + 2134: uint8(255), + 2135: uint8(255), + 2136: uint8(255), + 2142: uint8(255), + 2143: uint8(15), + 2158: uint8(223), + 2159: uint8(255), + 2160: uint8(255), + 2161: uint8(255), + 2162: uint8(255), + 2163: uint8(255), + 2164: uint8(255), + 2165: uint8(255), + 2166: uint8(255), + 2167: uint8(255), + 2168: uint8(255), + 2169: uint8(255), + 2170: uint8(255), + 2171: uint8(255), + 2172: uint8(255), + 2173: uint8(255), + 2174: uint8(255), + 2175: uint8(31), + 2178: uint8(255), + 2179: uint8(3), + 2180: uint8(254), + 2181: uint8(255), + 2182: uint8(255), + 2183: uint8(7), + 2184: uint8(254), + 2185: uint8(255), + 2186: uint8(255), + 2187: uint8(7), + 2188: uint8(192), + 2189: uint8(255), + 2190: uint8(255), + 2191: uint8(255), + 2192: uint8(255), + 2193: uint8(255), + 2194: uint8(255), + 2195: uint8(255), + 2196: uint8(255), + 2197: uint8(255), + 2198: uint8(255), + 2199: uint8(127), + 2200: uint8(252), + 2201: uint8(252), + 2202: uint8(252), + 2203: uint8(28), + 2208: uint8(255), + 2209: uint8(239), + 2210: uint8(255), + 2211: uint8(255), + 2212: uint8(127), + 2213: uint8(255), + 2214: uint8(255), + 2215: uint8(183), + 2216: uint8(255), + 2217: uint8(63), + 2218: uint8(255), + 2219: uint8(63), + 2224: uint8(255), + 2225: uint8(255), + 2226: uint8(255), + 2227: uint8(255), + 2228: uint8(255), + 2229: uint8(255), + 2230: uint8(255), + 2231: uint8(255), + 2232: uint8(255), + 2233: uint8(255), + 2234: uint8(255), + 2235: uint8(255), + 2236: uint8(255), + 2237: uint8(255), + 2238: uint8(255), + 2239: uint8(7), + 2248: uint8(255), + 2249: uint8(255), + 2250: uint8(255), + 2251: uint8(255), + 2252: uint8(255), + 2253: uint8(255), + 2254: uint8(31), + 2288: uint8(255), + 2289: uint8(255), + 2290: uint8(255), + 2291: uint8(31), + 2292: uint8(255), + 2293: uint8(255), + 2294: uint8(255), + 2295: uint8(255), + 2296: uint8(255), + 2297: uint8(255), + 2298: uint8(1), + 2304: uint8(255), + 2305: uint8(255), + 2306: uint8(255), + 2307: uint8(255), + 2309: uint8(224), + 2310: uint8(255), + 2311: uint8(255), + 2312: uint8(255), + 2313: uint8(7), + 2314: uint8(255), + 2315: uint8(255), + 2316: uint8(255), + 2317: uint8(255), + 2318: uint8(255), + 2319: uint8(7), + 2320: uint8(255), + 2321: uint8(255), + 2322: uint8(255), + 2323: uint8(63), + 2324: uint8(255), + 2325: uint8(255), + 2326: uint8(255), + 2327: uint8(255), + 2328: uint8(15), + 2329: uint8(255), + 2330: uint8(62), + 2336: uint8(255), + 2337: uint8(255), + 2338: uint8(255), + 2339: uint8(255), + 2340: uint8(255), + 2341: uint8(255), + 2342: uint8(255), + 2343: uint8(255), + 2344: uint8(255), + 2345: uint8(255), + 2346: uint8(255), + 2347: uint8(255), + 2348: uint8(255), + 2349: uint8(255), + 2350: uint8(255), + 2351: uint8(255), + 2352: uint8(255), + 2353: uint8(255), + 2354: uint8(255), + 2355: uint8(63), + 2356: uint8(255), + 2357: uint8(3), + 2358: uint8(255), + 2359: uint8(255), + 2360: uint8(255), + 2361: uint8(255), + 2362: uint8(15), + 2363: uint8(255), + 2364: uint8(255), + 2365: uint8(255), + 2366: uint8(255), + 2367: uint8(15), + 2368: uint8(255), + 2369: uint8(255), + 2370: uint8(255), + 2371: uint8(255), + 2372: uint8(255), + 2374: uint8(255), + 2375: uint8(255), + 2376: uint8(255), + 2377: uint8(255), + 2378: uint8(255), + 2379: uint8(255), + 2380: uint8(15), + 2400: uint8(255), + 2401: uint8(255), + 2402: uint8(255), + 2403: uint8(255), + 2404: uint8(255), + 2405: uint8(255), + 2406: uint8(127), + 2408: uint8(255), + 2409: uint8(255), + 2410: uint8(63), + 2412: uint8(255), + 2432: uint8(63), + 2433: uint8(253), + 2434: uint8(255), + 2435: uint8(255), + 2436: uint8(255), + 2437: uint8(255), + 2438: uint8(191), + 2439: uint8(145), + 2440: uint8(255), + 2441: uint8(255), + 2442: uint8(63), + 2444: uint8(255), + 2445: uint8(255), + 2446: uint8(127), + 2448: uint8(255), + 2449: uint8(255), + 2450: uint8(255), + 2451: uint8(127), + 2460: uint8(255), + 2461: uint8(255), + 2462: uint8(55), + 2464: uint8(255), + 2465: uint8(255), + 2466: uint8(63), + 2468: uint8(255), + 2469: uint8(255), + 2470: uint8(255), + 2471: uint8(3), + 2480: uint8(255), + 2481: uint8(255), + 2482: uint8(255), + 2483: uint8(255), + 2484: uint8(255), + 2485: uint8(255), + 2486: uint8(255), + 2487: uint8(192), + 2496: uint8(111), + 2497: uint8(240), + 2498: uint8(239), + 2499: uint8(254), + 2500: uint8(255), + 2501: uint8(255), + 2502: uint8(63), + 2508: uint8(255), + 2509: uint8(255), + 2510: uint8(255), + 2511: uint8(31), + 2512: uint8(255), + 2513: uint8(255), + 2514: uint8(255), + 2515: uint8(31), + 2520: uint8(255), + 2521: uint8(254), + 2522: uint8(255), + 2523: uint8(255), + 2524: uint8(31), + 2528: uint8(255), + 2529: uint8(255), + 2530: uint8(255), + 2531: uint8(255), + 2532: uint8(255), + 2533: uint8(255), + 2534: uint8(63), + 2536: uint8(255), + 2537: uint8(255), + 2538: uint8(63), + 2540: uint8(255), + 2541: uint8(255), + 2542: uint8(7), + 2544: uint8(255), + 2545: uint8(255), + 2546: uint8(3), + 2560: uint8(255), + 2561: uint8(255), + 2562: uint8(255), + 2563: uint8(255), + 2564: uint8(255), + 2565: uint8(255), + 2566: uint8(255), + 2567: uint8(255), + 2568: uint8(255), + 2569: uint8(1), + 2576: uint8(255), + 2577: uint8(255), + 2578: uint8(255), + 2579: uint8(255), + 2580: uint8(255), + 2581: uint8(255), + 2582: uint8(7), + 2584: uint8(255), + 2585: uint8(255), + 2586: uint8(255), + 2587: uint8(255), + 2588: uint8(255), + 2589: uint8(255), + 2590: uint8(7), + 2592: uint8(255), + 2593: uint8(255), + 2594: uint8(255), + 2595: uint8(255), + 2596: uint8(255), + 2598: uint8(255), + 2599: uint8(3), + 2624: uint8(255), + 2625: uint8(255), + 2626: uint8(255), + 2627: uint8(31), + 2628: uint8(128), + 2630: uint8(255), + 2631: uint8(255), + 2632: uint8(63), + 2652: uint8(255), + 2653: uint8(255), + 2654: uint8(127), + 2656: uint8(255), + 2657: uint8(255), + 2658: uint8(255), + 2659: uint8(255), + 2660: uint8(255), + 2661: uint8(255), + 2662: uint8(255), + 2663: uint8(255), + 2664: uint8(63), + 2668: uint8(192), + 2669: uint8(255), + 2672: uint8(252), + 2673: uint8(255), + 2674: uint8(255), + 2675: uint8(255), + 2676: uint8(255), + 2677: uint8(255), + 2678: uint8(255), + 2679: uint8(1), + 2682: uint8(255), + 2683: uint8(255), + 2684: uint8(255), + 2685: uint8(1), + 2686: uint8(255), + 2687: uint8(3), + 2688: uint8(255), + 2689: uint8(255), + 2690: uint8(255), + 2691: uint8(255), + 2692: uint8(255), + 2693: uint8(255), + 2694: uint8(199), + 2695: uint8(255), + 2696: uint8(112), + 2698: uint8(255), + 2699: uint8(255), + 2700: uint8(255), + 2701: uint8(255), + 2702: uint8(71), + 2704: uint8(255), + 2705: uint8(255), + 2706: uint8(255), + 2707: uint8(255), + 2708: uint8(255), + 2709: uint8(255), + 2710: uint8(255), + 2711: uint8(255), + 2712: uint8(30), + 2714: uint8(255), + 2715: uint8(23), + 2720: uint8(255), + 2721: uint8(255), + 2722: uint8(251), + 2723: uint8(255), + 2724: uint8(255), + 2725: uint8(255), + 2726: uint8(159), + 2727: uint8(64), + 2736: uint8(127), + 2737: uint8(189), + 2738: uint8(255), + 2739: uint8(191), + 2740: uint8(255), + 2741: uint8(1), + 2742: uint8(255), + 2743: uint8(255), + 2744: uint8(255), + 2745: uint8(255), + 2746: uint8(255), + 2747: uint8(255), + 2748: uint8(255), + 2749: uint8(1), + 2750: uint8(255), + 2751: uint8(3), + 2752: uint8(239), + 2753: uint8(159), + 2754: uint8(249), + 2755: uint8(255), + 2756: uint8(255), + 2757: uint8(253), + 2758: uint8(237), + 2759: uint8(227), + 2760: uint8(159), + 2761: uint8(25), + 2762: uint8(129), + 2763: uint8(224), + 2764: uint8(15), + 2784: uint8(255), + 2785: uint8(255), + 2786: uint8(255), + 2787: uint8(255), + 2788: uint8(255), + 2789: uint8(255), + 2790: uint8(255), + 2791: uint8(255), + 2792: uint8(187), + 2793: uint8(7), + 2794: uint8(255), + 2795: uint8(131), + 2800: uint8(255), + 2801: uint8(255), + 2802: uint8(255), + 2803: uint8(255), + 2804: uint8(255), + 2805: uint8(255), + 2806: uint8(255), + 2807: uint8(255), + 2808: uint8(179), + 2810: uint8(255), + 2811: uint8(3), + 2832: uint8(255), + 2833: uint8(255), + 2834: uint8(255), + 2835: uint8(255), + 2836: uint8(255), + 2837: uint8(255), + 2838: uint8(63), + 2839: uint8(127), + 2843: uint8(63), + 2848: uint8(255), + 2849: uint8(255), + 2850: uint8(255), + 2851: uint8(255), + 2852: uint8(255), + 2853: uint8(255), + 2854: uint8(255), + 2855: uint8(127), + 2856: uint8(17), + 2858: uint8(255), + 2859: uint8(3), + 2864: uint8(255), + 2865: uint8(255), + 2866: uint8(255), + 2867: uint8(255), + 2868: uint8(255), + 2869: uint8(255), + 2870: uint8(63), + 2871: uint8(1), + 2872: uint8(255), + 2873: uint8(3), + 2880: uint8(255), + 2881: uint8(255), + 2882: uint8(255), + 2883: uint8(231), + 2884: uint8(255), + 2885: uint8(7), + 2886: uint8(255), + 2887: uint8(3), + 2912: uint8(255), + 2913: uint8(255), + 2914: uint8(255), + 2915: uint8(255), + 2916: uint8(255), + 2917: uint8(255), + 2918: uint8(255), + 2919: uint8(1), + 2932: uint8(255), + 2933: uint8(255), + 2934: uint8(255), + 2935: uint8(255), + 2936: uint8(255), + 2937: uint8(255), + 2938: uint8(255), + 2939: uint8(255), + 2940: uint8(255), + 2941: uint8(3), + 2943: uint8(128), + 2964: uint8(255), + 2965: uint8(252), + 2966: uint8(255), + 2967: uint8(255), + 2968: uint8(255), + 2969: uint8(255), + 2970: uint8(255), + 2971: uint8(252), + 2972: uint8(26), + 2976: uint8(255), + 2977: uint8(255), + 2978: uint8(255), + 2979: uint8(255), + 2980: uint8(255), + 2981: uint8(255), + 2982: uint8(231), + 2983: uint8(127), + 2986: uint8(255), + 2987: uint8(255), + 2988: uint8(255), + 2989: uint8(255), + 2990: uint8(255), + 2991: uint8(255), + 2992: uint8(255), + 2993: uint8(255), + 2994: uint8(255), + 2995: uint8(32), + 3000: uint8(255), + 3001: uint8(255), + 3002: uint8(255), + 3003: uint8(255), + 3004: uint8(255), + 3005: uint8(255), + 3006: uint8(255), + 3007: uint8(1), + 3008: uint8(255), + 3009: uint8(253), + 3010: uint8(255), + 3011: uint8(255), + 3012: uint8(255), + 3013: uint8(255), + 3014: uint8(127), + 3015: uint8(127), + 3016: uint8(1), + 3018: uint8(255), + 3019: uint8(3), + 3022: uint8(252), + 3023: uint8(255), + 3024: uint8(255), + 3025: uint8(255), + 3026: uint8(252), + 3027: uint8(255), + 3028: uint8(255), + 3029: uint8(254), + 3030: uint8(127), + 3040: uint8(127), + 3041: uint8(251), + 3042: uint8(255), + 3043: uint8(255), + 3044: uint8(255), + 3045: uint8(255), + 3046: uint8(127), + 3047: uint8(180), + 3048: uint8(203), + 3050: uint8(255), + 3051: uint8(3), + 3052: uint8(191), + 3053: uint8(253), + 3054: uint8(255), + 3055: uint8(255), + 3056: uint8(255), + 3057: uint8(127), + 3058: uint8(123), + 3059: uint8(1), + 3060: uint8(255), + 3061: uint8(3), + 3100: uint8(255), + 3101: uint8(255), + 3102: uint8(127), + 3104: uint8(255), + 3105: uint8(255), + 3106: uint8(255), + 3107: uint8(255), + 3108: uint8(255), + 3109: uint8(255), + 3110: uint8(255), + 3111: uint8(255), + 3112: uint8(255), + 3113: uint8(255), + 3114: uint8(255), + 3115: uint8(255), + 3116: uint8(255), + 3117: uint8(255), + 3118: uint8(255), + 3119: uint8(255), + 3120: uint8(255), + 3121: uint8(255), + 3122: uint8(255), + 3123: uint8(3), + 3136: uint8(255), + 3137: uint8(255), + 3138: uint8(255), + 3139: uint8(255), + 3140: uint8(255), + 3141: uint8(255), + 3142: uint8(255), + 3143: uint8(255), + 3144: uint8(255), + 3145: uint8(255), + 3146: uint8(255), + 3147: uint8(255), + 3148: uint8(255), + 3149: uint8(127), + 3152: uint8(255), + 3153: uint8(255), + 3154: uint8(255), + 3155: uint8(255), + 3156: uint8(255), + 3157: uint8(255), + 3158: uint8(255), + 3159: uint8(255), + 3160: uint8(255), + 3161: uint8(255), + 3162: uint8(255), + 3163: uint8(255), + 3164: uint8(255), + 3165: uint8(255), + 3166: uint8(255), + 3167: uint8(255), + 3168: uint8(255), + 3169: uint8(255), + 3170: uint8(255), + 3171: uint8(255), + 3172: uint8(255), + 3173: uint8(255), + 3174: uint8(255), + 3175: uint8(255), + 3176: uint8(15), + 3200: uint8(255), + 3201: uint8(255), + 3202: uint8(255), + 3203: uint8(255), + 3204: uint8(255), + 3205: uint8(127), + 3232: uint8(255), + 3233: uint8(255), + 3234: uint8(255), + 3235: uint8(255), + 3236: uint8(255), + 3237: uint8(255), + 3238: uint8(255), + 3239: uint8(255), + 3240: uint8(127), + 3264: uint8(255), + 3265: uint8(255), + 3266: uint8(255), + 3267: uint8(255), + 3268: uint8(255), + 3269: uint8(255), + 3270: uint8(255), + 3271: uint8(1), + 3272: uint8(255), + 3273: uint8(255), + 3274: uint8(255), + 3275: uint8(127), + 3276: uint8(255), + 3277: uint8(3), + 3290: uint8(255), + 3291: uint8(255), + 3292: uint8(255), + 3293: uint8(63), + 3296: uint8(255), + 3297: uint8(255), + 3298: uint8(255), + 3299: uint8(255), + 3300: uint8(255), + 3301: uint8(255), + 3304: uint8(15), + 3306: uint8(255), + 3307: uint8(3), + 3308: uint8(248), + 3309: uint8(255), + 3310: uint8(255), + 3311: uint8(224), + 3312: uint8(255), + 3313: uint8(255), + 3336: uint8(255), + 3337: uint8(255), + 3338: uint8(255), + 3339: uint8(255), + 3340: uint8(255), + 3341: uint8(255), + 3342: uint8(255), + 3343: uint8(255), + 3360: uint8(255), + 3361: uint8(255), + 3362: uint8(255), + 3363: uint8(255), + 3364: uint8(255), + 3365: uint8(255), + 3366: uint8(255), + 3367: uint8(255), + 3368: uint8(255), + 3369: uint8(135), + 3370: uint8(255), + 3371: uint8(255), + 3372: uint8(255), + 3373: uint8(255), + 3374: uint8(255), + 3375: uint8(255), + 3376: uint8(255), + 3377: uint8(128), + 3378: uint8(255), + 3379: uint8(255), + 3388: uint8(11), + 3392: uint8(255), + 3393: uint8(255), + 3394: uint8(255), + 3395: uint8(255), + 3396: uint8(255), + 3397: uint8(255), + 3398: uint8(255), + 3399: uint8(255), + 3400: uint8(255), + 3401: uint8(255), + 3402: uint8(255), + 3403: uint8(255), + 3404: uint8(255), + 3405: uint8(255), + 3406: uint8(255), + 3407: uint8(255), + 3408: uint8(255), + 3409: uint8(255), + 3410: uint8(255), + 3411: uint8(255), + 3412: uint8(255), + 3413: uint8(255), + 3414: uint8(255), + 3415: uint8(255), + 3416: uint8(255), + 3417: uint8(255), + 3418: uint8(255), + 3419: uint8(255), + 3420: uint8(255), + 3421: uint8(255), + 3422: uint8(255), + 3424: uint8(255), + 3425: uint8(255), + 3426: uint8(255), + 3427: uint8(255), + 3428: uint8(255), + 3429: uint8(255), + 3430: uint8(255), + 3431: uint8(255), + 3432: uint8(255), + 3433: uint8(255), + 3434: uint8(255), + 3435: uint8(255), + 3436: uint8(255), + 3437: uint8(255), + 3438: uint8(255), + 3439: uint8(255), + 3440: uint8(255), + 3441: uint8(255), + 3442: uint8(255), + 3443: uint8(255), + 3444: uint8(255), + 3445: uint8(255), + 3446: uint8(255), + 3447: uint8(255), + 3448: uint8(255), + 3449: uint8(255), + 3450: uint8(255), + 3451: uint8(255), + 3452: uint8(255), + 3453: uint8(255), + 3454: uint8(7), + 3456: uint8(255), + 3457: uint8(255), + 3458: uint8(255), + 3459: uint8(127), + 3466: uint8(7), + 3468: uint8(240), + 3470: uint8(255), + 3471: uint8(255), + 3472: uint8(255), + 3473: uint8(255), + 3474: uint8(255), + 3475: uint8(255), + 3476: uint8(255), + 3477: uint8(255), + 3478: uint8(255), + 3479: uint8(255), + 3480: uint8(255), + 3481: uint8(255), + 3482: uint8(255), + 3483: uint8(255), + 3484: uint8(255), + 3485: uint8(255), + 3486: uint8(255), + 3487: uint8(255), + 3488: uint8(255), + 3489: uint8(255), + 3490: uint8(255), + 3491: uint8(255), + 3492: uint8(255), + 3493: uint8(255), + 3494: uint8(255), + 3495: uint8(255), + 3496: uint8(255), + 3497: uint8(255), + 3498: uint8(255), + 3499: uint8(255), + 3500: uint8(255), + 3501: uint8(255), + 3502: uint8(255), + 3503: uint8(255), + 3504: uint8(255), + 3505: uint8(255), + 3506: uint8(255), + 3507: uint8(255), + 3508: uint8(255), + 3509: uint8(255), + 3510: uint8(255), + 3511: uint8(255), + 3512: uint8(255), + 3513: uint8(255), + 3514: uint8(255), + 3515: uint8(255), + 3516: uint8(255), + 3517: uint8(255), + 3518: uint8(255), + 3519: uint8(15), + 3520: uint8(255), + 3521: uint8(255), + 3522: uint8(255), + 3523: uint8(255), + 3524: uint8(255), + 3525: uint8(255), + 3526: uint8(255), + 3527: uint8(255), + 3528: uint8(255), + 3529: uint8(255), + 3530: uint8(255), + 3531: uint8(255), + 3532: uint8(255), + 3533: uint8(7), + 3534: uint8(255), + 3535: uint8(31), + 3536: uint8(255), + 3537: uint8(1), + 3538: uint8(255), + 3539: uint8(67), + 3552: uint8(255), + 3553: uint8(255), + 3554: uint8(255), + 3555: uint8(255), + 3556: uint8(255), + 3557: uint8(255), + 3558: uint8(255), + 3559: uint8(255), + 3560: uint8(255), + 3561: uint8(255), + 3562: uint8(223), + 3563: uint8(255), + 3564: uint8(255), + 3565: uint8(255), + 3566: uint8(255), + 3567: uint8(255), + 3568: uint8(255), + 3569: uint8(255), + 3570: uint8(255), + 3571: uint8(223), + 3572: uint8(100), + 3573: uint8(222), + 3574: uint8(255), + 3575: uint8(235), + 3576: uint8(239), + 3577: uint8(255), + 3578: uint8(255), + 3579: uint8(255), + 3580: uint8(255), + 3581: uint8(255), + 3582: uint8(255), + 3583: uint8(255), + 3584: uint8(191), + 3585: uint8(231), + 3586: uint8(223), + 3587: uint8(223), + 3588: uint8(255), + 3589: uint8(255), + 3590: uint8(255), + 3591: uint8(123), + 3592: uint8(95), + 3593: uint8(252), + 3594: uint8(253), + 3595: uint8(255), + 3596: uint8(255), + 3597: uint8(255), + 3598: uint8(255), + 3599: uint8(255), + 3600: uint8(255), + 3601: uint8(255), + 3602: uint8(255), + 3603: uint8(255), + 3604: uint8(255), + 3605: uint8(255), + 3606: uint8(255), + 3607: uint8(255), + 3608: uint8(255), + 3609: uint8(255), + 3610: uint8(255), + 3611: uint8(255), + 3612: uint8(255), + 3613: uint8(255), + 3614: uint8(255), + 3615: uint8(255), + 3616: uint8(255), + 3617: uint8(255), + 3618: uint8(255), + 3619: uint8(255), + 3620: uint8(255), + 3621: uint8(255), + 3622: uint8(255), + 3623: uint8(255), + 3624: uint8(255), + 3625: uint8(255), + 3626: uint8(255), + 3627: uint8(255), + 3628: uint8(255), + 3629: uint8(255), + 3630: uint8(255), + 3631: uint8(255), + 3632: uint8(255), + 3633: uint8(255), + 3634: uint8(255), + 3635: uint8(255), + 3636: uint8(63), + 3637: uint8(255), + 3638: uint8(255), + 3639: uint8(255), + 3640: uint8(253), + 3641: uint8(255), + 3642: uint8(255), + 3643: uint8(247), + 3644: uint8(255), + 3645: uint8(255), + 3646: uint8(255), + 3647: uint8(247), + 3648: uint8(255), + 3649: uint8(255), + 3650: uint8(223), + 3651: uint8(255), + 3652: uint8(255), + 3653: uint8(255), + 3654: uint8(223), + 3655: uint8(255), + 3656: uint8(255), + 3657: uint8(127), + 3658: uint8(255), + 3659: uint8(255), + 3660: uint8(255), + 3661: uint8(127), + 3662: uint8(255), + 3663: uint8(255), + 3664: uint8(255), + 3665: uint8(253), + 3666: uint8(255), + 3667: uint8(255), + 3668: uint8(255), + 3669: uint8(253), + 3670: uint8(255), + 3671: uint8(255), + 3672: uint8(247), + 3673: uint8(207), + 3674: uint8(255), + 3675: uint8(255), + 3676: uint8(255), + 3677: uint8(255), + 3678: uint8(255), + 3679: uint8(255), + 3680: uint8(127), + 3681: uint8(255), + 3682: uint8(255), + 3683: uint8(249), + 3684: uint8(219), + 3685: uint8(7), + 3712: uint8(255), + 3713: uint8(255), + 3714: uint8(255), + 3715: uint8(255), + 3716: uint8(255), + 3717: uint8(31), + 3718: uint8(128), + 3719: uint8(63), + 3720: uint8(255), + 3721: uint8(67), + 3768: uint8(255), + 3769: uint8(255), + 3770: uint8(255), + 3771: uint8(255), + 3772: uint8(255), + 3773: uint8(15), + 3774: uint8(255), + 3775: uint8(3), + 3776: uint8(255), + 3777: uint8(255), + 3778: uint8(255), + 3779: uint8(255), + 3780: uint8(255), + 3781: uint8(255), + 3782: uint8(255), + 3783: uint8(255), + 3784: uint8(255), + 3785: uint8(255), + 3786: uint8(255), + 3787: uint8(255), + 3788: uint8(255), + 3789: uint8(255), + 3790: uint8(255), + 3791: uint8(255), + 3792: uint8(255), + 3793: uint8(255), + 3794: uint8(255), + 3795: uint8(255), + 3796: uint8(255), + 3797: uint8(255), + 3798: uint8(255), + 3799: uint8(255), + 3800: uint8(31), + 3808: uint8(255), + 3809: uint8(255), + 3810: uint8(255), + 3811: uint8(255), + 3812: uint8(255), + 3813: uint8(255), + 3814: uint8(255), + 3815: uint8(255), + 3816: uint8(143), + 3817: uint8(8), + 3818: uint8(255), + 3819: uint8(3), + 3840: uint8(239), + 3841: uint8(255), + 3842: uint8(255), + 3843: uint8(255), + 3844: uint8(150), + 3845: uint8(254), + 3846: uint8(247), + 3847: uint8(10), + 3848: uint8(132), + 3849: uint8(234), + 3850: uint8(150), + 3851: uint8(170), + 3852: uint8(150), + 3853: uint8(247), + 3854: uint8(247), + 3855: uint8(94), + 3856: uint8(255), + 3857: uint8(251), + 3858: uint8(255), + 3859: uint8(15), + 3860: uint8(238), + 3861: uint8(251), + 3862: uint8(255), + 3863: uint8(15), + 3878: uint8(255), + 3879: uint8(255), + 3880: uint8(255), + 3881: uint8(3), + 3882: uint8(255), + 3883: uint8(255), + 3884: uint8(255), + 3885: uint8(3), + 3886: uint8(255), + 3887: uint8(255), + 3888: uint8(255), + 3889: uint8(3), +} + +func Xiswalpha(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if wc < uint32(0x20000) { + return Int32FromUint8(_table3[Uint32FromInt32(Int32FromUint8(_table3[wc>>int32(8)])*int32(32))+wc&uint32(255)>>int32(3)]) >> (wc & uint32(7)) & int32(1) + } + if wc < uint32(0x2fffe) { + return int32(1) + } + return 0 +} + +func X__iswalpha_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswalpha(tls, c) +} + +func Xiswalpha_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswalpha_l(tls, c, l) +} + +func Xiswblank(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisblank(tls, Int32FromUint32(wc)) +} + +func X__iswblank_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswblank(tls, c) +} + +func Xiswblank_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswblank_l(tls, c, l) +} + +func Xiswcntrl(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(wc < uint32(32) || wc-Uint32FromInt32(0x7f) < uint32(33) || wc-Uint32FromInt32(0x2028) < uint32(2) || wc-Uint32FromInt32(0xfff9) < uint32(3)) +} + +func X__iswcntrl_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswcntrl(tls, c) +} + +func Xiswcntrl_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswcntrl_l(tls, c, l) +} + +const WCTYPE_ALNUM = 1 +const WCTYPE_ALPHA = 2 +const WCTYPE_BLANK = 3 +const WCTYPE_CNTRL = 4 +const WCTYPE_DIGIT = 5 +const WCTYPE_GRAPH = 6 +const WCTYPE_LOWER = 7 +const WCTYPE_PRINT = 8 +const WCTYPE_PUNCT = 9 +const WCTYPE_SPACE = 10 +const WCTYPE_UPPER = 11 +const WCTYPE_XDIGIT = 12 + +func Xiswctype(tls *TLS, wc Twint_t, type1 Twctype_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v type1=%v, (%v:)", tls, wc, type1, origin(2)) + defer func() { trc("-> %v", r) }() + } + switch type1 { + case uint64(WCTYPE_ALNUM): + return Xiswalnum(tls, wc) + case uint64(WCTYPE_ALPHA): + return Xiswalpha(tls, wc) + case uint64(WCTYPE_BLANK): + return Xiswblank(tls, wc) + case uint64(WCTYPE_CNTRL): + return Xiswcntrl(tls, wc) + case uint64(WCTYPE_DIGIT): + return BoolInt32(wc-uint32('0') < uint32(10)) + case uint64(WCTYPE_GRAPH): + return Xiswgraph(tls, wc) + case uint64(WCTYPE_LOWER): + return Xiswlower(tls, wc) + case uint64(WCTYPE_PRINT): + return Xiswprint(tls, wc) + case uint64(WCTYPE_PUNCT): + return Xiswpunct(tls, wc) + case uint64(WCTYPE_SPACE): + return Xiswspace(tls, wc) + case uint64(WCTYPE_UPPER): + return Xiswupper(tls, wc) + case uint64(WCTYPE_XDIGIT): + return Xiswxdigit(tls, wc) + } + return 0 +} + +func Xwctype(tls *TLS, s uintptr) (r Twctype_t) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i int32 + var p uintptr + _, _ = i, p + i = int32(1) + p = uintptr(unsafe.Pointer(&_names)) + for { + if !(**(**uint8)(__ccgo_up(p)) != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == Int32FromUint8(**(**uint8)(__ccgo_up(p))) && !(Xstrcmp(tls, s, p) != 0) { + return Uint64FromInt32(i) + } + goto _1 + _1: + ; + i = i + 1 + p = p + uintptr(6) + } + return uint64(0) +} + +/* order must match! */ +var _names = [73]uint8{'a', 'l', 'n', 'u', 'm', 0, 'a', 'l', 'p', 'h', 'a', 0, 'b', 'l', 'a', 'n', 'k', 0, 'c', 'n', 't', 'r', 'l', 0, 'd', 'i', 'g', 'i', 't', 0, 'g', 'r', 'a', 'p', 'h', 0, 'l', 'o', 'w', 'e', 'r', 0, 'p', 'r', 'i', 'n', 't', 0, 'p', 'u', 'n', 'c', 't', 0, 's', 'p', 'a', 'c', 'e', 0, 'u', 'p', 'p', 'e', 'r', 0, 'x', 'd', 'i', 'g', 'i', 't'} + +func X__iswctype_l(tls *TLS, c Twint_t, t Twctype_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v t=%v l=%v, (%v:)", tls, c, t, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswctype(tls, c, t) +} + +func X__wctype_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctype_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v, (%v:)", tls, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwctype(tls, s) +} + +func Xiswctype_l(tls *TLS, c Twint_t, t Twctype_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v t=%v l=%v, (%v:)", tls, c, t, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswctype_l(tls, c, t, l) +} + +func Xwctype_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctype_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v, (%v:)", tls, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wctype_l(tls, s, l) +} + +func Xiswdigit(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(wc-uint32('0') < uint32(10)) +} + +func X__iswdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswdigit(tls, c) +} + +func Xiswdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswdigit_l(tls, c, l) +} + +func Xiswgraph(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* ISO C defines this function as: */ + return BoolInt32(!(Xiswspace(tls, wc) != 0) && Xiswprint(tls, wc) != 0) +} + +func X__iswgraph_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswgraph(tls, c) +} + +func Xiswgraph_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswgraph_l(tls, c, l) +} + +func Xiswlower(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Xtowupper(tls, wc) != wc) +} + +func X__iswlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswlower(tls, c) +} + +func Xiswlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswlower_l(tls, c, l) +} + +/* Consider all legal codepoints as printable except for: + * - C0 and C1 control characters + * - U+2028 and U+2029 (line/para break) + * - U+FFF9 through U+FFFB (interlinear annotation controls) + * The following code is optimized heavily to make hot paths for the + * expected printable characters. */ + +func Xiswprint(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if wc < uint32(0xff) { + return BoolInt32((wc+uint32(1))&uint32(0x7f) >= uint32(0x21)) + } + if wc < uint32(0x2028) || wc-uint32(0x202a) < Uint32FromInt32(Int32FromInt32(0xd800)-Int32FromInt32(0x202a)) || wc-uint32(0xe000) < Uint32FromInt32(Int32FromInt32(0xfff9)-Int32FromInt32(0xe000)) { + return int32(1) + } + if wc-uint32(0xfffc) > Uint32FromInt32(Int32FromInt32(0x10ffff)-Int32FromInt32(0xfffc)) || wc&uint32(0xfffe) == uint32(0xfffe) { + return 0 + } + return int32(1) +} + +func X__iswprint_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswprint(tls, c) +} + +func Xiswprint_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswprint_l(tls, c, l) +} + +var _table4 = [4000]uint8{ + 0: uint8(18), + 1: uint8(16), + 2: uint8(19), + 3: uint8(20), + 4: uint8(21), + 5: uint8(22), + 6: uint8(23), + 7: uint8(24), + 8: uint8(25), + 9: uint8(26), + 10: uint8(27), + 11: uint8(28), + 12: uint8(29), + 13: uint8(30), + 14: uint8(31), + 15: uint8(32), + 16: uint8(33), + 17: uint8(16), + 18: uint8(16), + 19: uint8(34), + 20: uint8(35), + 21: uint8(16), + 22: uint8(36), + 23: uint8(37), + 24: uint8(38), + 25: uint8(39), + 26: uint8(40), + 27: uint8(41), + 28: uint8(42), + 29: uint8(43), + 30: uint8(16), + 31: uint8(44), + 32: uint8(45), + 33: uint8(46), + 34: uint8(17), + 35: uint8(17), + 36: uint8(47), + 37: uint8(17), + 38: uint8(17), + 39: uint8(17), + 40: uint8(17), + 41: uint8(17), + 42: uint8(17), + 43: uint8(48), + 44: uint8(49), + 45: uint8(50), + 46: uint8(51), + 47: uint8(52), + 48: uint8(53), + 49: uint8(54), + 50: uint8(55), + 51: uint8(17), + 52: uint8(16), + 53: uint8(16), + 54: uint8(16), + 55: uint8(16), + 56: uint8(16), + 57: uint8(16), + 58: uint8(16), + 59: uint8(16), + 60: uint8(16), + 61: uint8(16), + 62: uint8(16), + 63: uint8(16), + 64: uint8(16), + 65: uint8(16), + 66: uint8(16), + 67: uint8(16), + 68: uint8(16), + 69: uint8(16), + 70: uint8(16), + 71: uint8(16), + 72: uint8(16), + 73: uint8(16), + 74: uint8(16), + 75: uint8(16), + 76: uint8(16), + 77: uint8(56), + 78: uint8(16), + 79: uint8(16), + 80: uint8(16), + 81: uint8(16), + 82: uint8(16), + 83: uint8(16), + 84: uint8(16), + 85: uint8(16), + 86: uint8(16), + 87: uint8(16), + 88: uint8(16), + 89: uint8(16), + 90: uint8(16), + 91: uint8(16), + 92: uint8(16), + 93: uint8(16), + 94: uint8(16), + 95: uint8(16), + 96: uint8(16), + 97: uint8(16), + 98: uint8(16), + 99: uint8(16), + 100: uint8(16), + 101: uint8(16), + 102: uint8(16), + 103: uint8(16), + 104: uint8(16), + 105: uint8(16), + 106: uint8(16), + 107: uint8(16), + 108: uint8(16), + 109: uint8(16), + 110: uint8(16), + 111: uint8(16), + 112: uint8(16), + 113: uint8(16), + 114: uint8(16), + 115: uint8(16), + 116: uint8(16), + 117: uint8(16), + 118: uint8(16), + 119: uint8(16), + 120: uint8(16), + 121: uint8(16), + 122: uint8(16), + 123: uint8(16), + 124: uint8(16), + 125: uint8(16), + 126: uint8(16), + 127: uint8(16), + 128: uint8(16), + 129: uint8(16), + 130: uint8(16), + 131: uint8(16), + 132: uint8(16), + 133: uint8(16), + 134: uint8(16), + 135: uint8(16), + 136: uint8(16), + 137: uint8(16), + 138: uint8(16), + 139: uint8(16), + 140: uint8(16), + 141: uint8(16), + 142: uint8(16), + 143: uint8(16), + 144: uint8(16), + 145: uint8(16), + 146: uint8(16), + 147: uint8(16), + 148: uint8(16), + 149: uint8(16), + 150: uint8(16), + 151: uint8(16), + 152: uint8(16), + 153: uint8(16), + 154: uint8(16), + 155: uint8(16), + 156: uint8(16), + 157: uint8(16), + 158: uint8(16), + 159: uint8(16), + 160: uint8(16), + 161: uint8(16), + 162: uint8(16), + 163: uint8(16), + 164: uint8(57), + 165: uint8(16), + 166: uint8(58), + 167: uint8(59), + 168: uint8(60), + 169: uint8(61), + 170: uint8(62), + 171: uint8(63), + 172: uint8(16), + 173: uint8(16), + 174: uint8(16), + 175: uint8(16), + 176: uint8(16), + 177: uint8(16), + 178: uint8(16), + 179: uint8(16), + 180: uint8(16), + 181: uint8(16), + 182: uint8(16), + 183: uint8(16), + 184: uint8(16), + 185: uint8(16), + 186: uint8(16), + 187: uint8(16), + 188: uint8(16), + 189: uint8(16), + 190: uint8(16), + 191: uint8(16), + 192: uint8(16), + 193: uint8(16), + 194: uint8(16), + 195: uint8(16), + 196: uint8(16), + 197: uint8(16), + 198: uint8(16), + 199: uint8(16), + 200: uint8(16), + 201: uint8(16), + 202: uint8(16), + 203: uint8(16), + 204: uint8(16), + 205: uint8(16), + 206: uint8(16), + 207: uint8(16), + 208: uint8(16), + 209: uint8(16), + 210: uint8(16), + 211: uint8(16), + 212: uint8(16), + 213: uint8(16), + 214: uint8(16), + 215: uint8(16), + 216: uint8(16), + 217: uint8(16), + 218: uint8(16), + 219: uint8(16), + 220: uint8(16), + 221: uint8(16), + 222: uint8(16), + 223: uint8(16), + 224: uint8(64), + 225: uint8(16), + 226: uint8(16), + 227: uint8(16), + 228: uint8(16), + 229: uint8(16), + 230: uint8(16), + 231: uint8(16), + 232: uint8(16), + 233: uint8(16), + 234: uint8(16), + 235: uint8(16), + 236: uint8(16), + 237: uint8(16), + 238: uint8(16), + 239: uint8(16), + 240: uint8(16), + 241: uint8(16), + 242: uint8(16), + 243: uint8(16), + 244: uint8(16), + 245: uint8(16), + 246: uint8(16), + 247: uint8(16), + 248: uint8(65), + 249: uint8(16), + 250: uint8(16), + 251: uint8(66), + 252: uint8(16), + 253: uint8(67), + 254: uint8(68), + 255: uint8(69), + 256: uint8(16), + 257: uint8(70), + 258: uint8(71), + 259: uint8(72), + 260: uint8(16), + 261: uint8(73), + 262: uint8(16), + 263: uint8(16), + 264: uint8(74), + 265: uint8(75), + 266: uint8(76), + 267: uint8(77), + 268: uint8(78), + 269: uint8(16), + 270: uint8(79), + 271: uint8(80), + 272: uint8(81), + 273: uint8(82), + 274: uint8(83), + 275: uint8(84), + 276: uint8(85), + 277: uint8(86), + 278: uint8(87), + 279: uint8(88), + 280: uint8(89), + 281: uint8(90), + 282: uint8(91), + 283: uint8(16), + 284: uint8(92), + 285: uint8(93), + 286: uint8(94), + 287: uint8(95), + 288: uint8(16), + 289: uint8(16), + 290: uint8(16), + 291: uint8(16), + 292: uint8(96), + 293: uint8(16), + 294: uint8(16), + 295: uint8(16), + 296: uint8(16), + 297: uint8(16), + 298: uint8(16), + 299: uint8(16), + 300: uint8(16), + 301: uint8(16), + 302: uint8(16), + 303: uint8(16), + 304: uint8(16), + 305: uint8(16), + 306: uint8(16), + 307: uint8(16), + 308: uint8(97), + 309: uint8(16), + 310: uint8(16), + 311: uint8(16), + 312: uint8(16), + 313: uint8(16), + 314: uint8(16), + 315: uint8(16), + 316: uint8(16), + 317: uint8(16), + 318: uint8(16), + 319: uint8(16), + 320: uint8(16), + 321: uint8(16), + 322: uint8(16), + 323: uint8(16), + 324: uint8(16), + 325: uint8(16), + 326: uint8(16), + 327: uint8(16), + 328: uint8(16), + 329: uint8(16), + 330: uint8(16), + 331: uint8(16), + 332: uint8(16), + 333: uint8(16), + 334: uint8(16), + 335: uint8(16), + 336: uint8(16), + 337: uint8(16), + 338: uint8(16), + 339: uint8(16), + 340: uint8(16), + 341: uint8(16), + 342: uint8(16), + 343: uint8(16), + 344: uint8(16), + 345: uint8(16), + 346: uint8(16), + 347: uint8(16), + 348: uint8(16), + 349: uint8(16), + 350: uint8(16), + 351: uint8(16), + 352: uint8(16), + 353: uint8(16), + 354: uint8(16), + 355: uint8(16), + 356: uint8(16), + 357: uint8(16), + 358: uint8(16), + 359: uint8(16), + 360: uint8(16), + 361: uint8(16), + 362: uint8(98), + 363: uint8(99), + 364: uint8(16), + 365: uint8(16), + 366: uint8(100), + 367: uint8(101), + 368: uint8(16), + 369: uint8(16), + 370: uint8(16), + 371: uint8(16), + 372: uint8(16), + 373: uint8(16), + 374: uint8(16), + 375: uint8(16), + 376: uint8(16), + 377: uint8(16), + 378: uint8(16), + 379: uint8(16), + 380: uint8(16), + 381: uint8(16), + 382: uint8(16), + 383: uint8(16), + 384: uint8(16), + 385: uint8(16), + 386: uint8(16), + 387: uint8(16), + 388: uint8(16), + 389: uint8(16), + 390: uint8(16), + 391: uint8(16), + 392: uint8(16), + 393: uint8(16), + 394: uint8(16), + 395: uint8(16), + 396: uint8(16), + 397: uint8(16), + 398: uint8(16), + 399: uint8(16), + 400: uint8(16), + 401: uint8(16), + 402: uint8(16), + 403: uint8(16), + 404: uint8(16), + 405: uint8(16), + 406: uint8(16), + 407: uint8(16), + 408: uint8(16), + 409: uint8(16), + 410: uint8(16), + 411: uint8(16), + 412: uint8(16), + 413: uint8(16), + 414: uint8(16), + 415: uint8(16), + 416: uint8(16), + 417: uint8(16), + 418: uint8(16), + 419: uint8(16), + 420: uint8(16), + 421: uint8(16), + 422: uint8(16), + 423: uint8(16), + 424: uint8(16), + 425: uint8(16), + 426: uint8(16), + 427: uint8(16), + 428: uint8(16), + 429: uint8(16), + 430: uint8(16), + 431: uint8(16), + 432: uint8(16), + 433: uint8(16), + 434: uint8(16), + 435: uint8(16), + 436: uint8(16), + 437: uint8(16), + 438: uint8(16), + 439: uint8(16), + 440: uint8(16), + 441: uint8(16), + 442: uint8(16), + 443: uint8(16), + 444: uint8(102), + 445: uint8(16), + 446: uint8(16), + 447: uint8(16), + 448: uint8(16), + 449: uint8(16), + 450: uint8(16), + 451: uint8(16), + 452: uint8(16), + 453: uint8(16), + 454: uint8(16), + 455: uint8(16), + 456: uint8(16), + 457: uint8(16), + 458: uint8(16), + 459: uint8(16), + 460: uint8(16), + 461: uint8(16), + 462: uint8(16), + 463: uint8(16), + 464: uint8(103), + 465: uint8(104), + 466: uint8(105), + 467: uint8(106), + 468: uint8(16), + 469: uint8(16), + 470: uint8(107), + 471: uint8(108), + 472: uint8(17), + 473: uint8(17), + 474: uint8(109), + 475: uint8(16), + 476: uint8(16), + 477: uint8(16), + 478: uint8(16), + 479: uint8(16), + 480: uint8(16), + 481: uint8(110), + 482: uint8(111), + 483: uint8(16), + 484: uint8(16), + 485: uint8(16), + 486: uint8(16), + 487: uint8(16), + 488: uint8(112), + 489: uint8(113), + 490: uint8(16), + 491: uint8(16), + 492: uint8(114), + 493: uint8(115), + 494: uint8(116), + 495: uint8(16), + 496: uint8(117), + 497: uint8(118), + 498: uint8(119), + 499: uint8(17), + 500: uint8(17), + 501: uint8(17), + 502: uint8(120), + 503: uint8(121), + 504: uint8(122), + 505: uint8(123), + 506: uint8(124), + 507: uint8(16), + 508: uint8(16), + 509: uint8(16), + 510: uint8(16), + 511: uint8(16), + 544: uint8(255), + 545: uint8(255), + 546: uint8(255), + 547: uint8(255), + 548: uint8(255), + 549: uint8(255), + 550: uint8(255), + 551: uint8(255), + 552: uint8(255), + 553: uint8(255), + 554: uint8(255), + 555: uint8(255), + 556: uint8(255), + 557: uint8(255), + 558: uint8(255), + 559: uint8(255), + 560: uint8(255), + 561: uint8(255), + 562: uint8(255), + 563: uint8(255), + 564: uint8(255), + 565: uint8(255), + 566: uint8(255), + 567: uint8(255), + 568: uint8(255), + 569: uint8(255), + 570: uint8(255), + 571: uint8(255), + 572: uint8(255), + 573: uint8(255), + 574: uint8(255), + 575: uint8(255), + 580: uint8(254), + 581: uint8(255), + 583: uint8(252), + 584: uint8(1), + 587: uint8(248), + 588: uint8(1), + 591: uint8(120), + 596: uint8(255), + 597: uint8(251), + 598: uint8(223), + 599: uint8(251), + 602: uint8(128), + 606: uint8(128), + 632: uint8(60), + 634: uint8(252), + 635: uint8(255), + 636: uint8(224), + 637: uint8(175), + 638: uint8(255), + 639: uint8(255), + 640: uint8(255), + 641: uint8(255), + 642: uint8(255), + 643: uint8(255), + 644: uint8(255), + 645: uint8(255), + 646: uint8(255), + 647: uint8(255), + 648: uint8(223), + 649: uint8(255), + 650: uint8(255), + 651: uint8(255), + 652: uint8(255), + 653: uint8(255), + 654: uint8(32), + 655: uint8(64), + 656: uint8(176), + 670: uint8(64), + 688: uint8(252), + 689: uint8(3), + 715: uint8(252), + 721: uint8(230), + 722: uint8(254), + 723: uint8(255), + 724: uint8(255), + 725: uint8(255), + 727: uint8(64), + 728: uint8(73), + 734: uint8(24), + 736: uint8(255), + 737: uint8(255), + 739: uint8(216), + 747: uint8(1), + 749: uint8(60), + 762: uint8(16), + 763: uint8(224), + 764: uint8(1), + 765: uint8(30), + 767: uint8(96), + 768: uint8(255), + 769: uint8(191), + 776: uint8(255), + 777: uint8(7), + 797: uint8(248), + 798: uint8(207), + 799: uint8(227), + 803: uint8(3), + 805: uint8(32), + 806: uint8(255), + 807: uint8(127), + 811: uint8(78), + 826: uint8(8), + 828: uint8(7), + 829: uint8(252), + 839: uint8(16), + 841: uint8(32), + 842: uint8(30), + 844: uint8(48), + 846: uint8(1), + 855: uint8(16), + 857: uint8(32), + 862: uint8(252), + 863: uint8(111), + 871: uint8(16), + 873: uint8(32), + 878: uint8(64), + 887: uint8(16), + 889: uint8(32), + 894: uint8(3), + 895: uint8(224), + 903: uint8(16), + 905: uint8(32), + 910: uint8(253), + 921: uint8(32), + 926: uint8(255), + 927: uint8(7), + 928: uint8(16), + 937: uint8(32), + 942: uint8(128), + 943: uint8(255), + 944: uint8(16), + 951: uint8(16), + 953: uint8(32), + 967: uint8(24), + 969: uint8(160), + 971: uint8(127), + 974: uint8(255), + 975: uint8(3), + 985: uint8(4), + 990: uint8(16), + 997: uint8(128), + 999: uint8(128), + 1000: uint8(192), + 1001: uint8(223), + 1003: uint8(12), + 1015: uint8(4), + 1017: uint8(31), + 1024: uint8(254), + 1025: uint8(255), + 1026: uint8(255), + 1027: uint8(255), + 1029: uint8(252), + 1030: uint8(255), + 1031: uint8(255), + 1040: uint8(252), + 1047: uint8(192), + 1048: uint8(255), + 1049: uint8(223), + 1050: uint8(255), + 1051: uint8(7), + 1062: uint8(128), + 1063: uint8(6), + 1065: uint8(252), + 1075: uint8(192), + 1087: uint8(8), + 1099: uint8(224), + 1100: uint8(255), + 1101: uint8(255), + 1102: uint8(255), + 1103: uint8(31), + 1106: uint8(255), + 1107: uint8(3), + 1120: uint8(1), + 1165: uint8(96), + 1168: uint8(1), + 1171: uint8(24), + 1181: uint8(56), + 1186: uint8(16), + 1190: uint8(112), + 1206: uint8(48), + 1209: uint8(254), + 1210: uint8(127), + 1211: uint8(47), + 1214: uint8(255), + 1215: uint8(3), + 1216: uint8(255), + 1217: uint8(127), + 1255: uint8(14), + 1256: uint8(49), + 1275: uint8(196), + 1276: uint8(255), + 1277: uint8(255), + 1278: uint8(255), + 1279: uint8(255), + 1283: uint8(192), + 1292: uint8(1), + 1294: uint8(224), + 1295: uint8(159), + 1300: uint8(127), + 1301: uint8(63), + 1302: uint8(255), + 1303: uint8(127), + 1318: uint8(16), + 1320: uint8(16), + 1323: uint8(252), + 1324: uint8(255), + 1325: uint8(255), + 1326: uint8(255), + 1327: uint8(31), + 1333: uint8(12), + 1340: uint8(64), + 1342: uint8(12), + 1343: uint8(240), + 1350: uint8(128), + 1351: uint8(248), + 1359: uint8(192), + 1368: uint8(255), + 1370: uint8(255), + 1371: uint8(255), + 1372: uint8(255), + 1373: uint8(33), + 1374: uint8(144), + 1375: uint8(3), + 1400: uint8(255), + 1401: uint8(255), + 1402: uint8(255), + 1403: uint8(255), + 1404: uint8(127), + 1406: uint8(224), + 1407: uint8(251), + 1431: uint8(160), + 1432: uint8(3), + 1433: uint8(224), + 1435: uint8(224), + 1437: uint8(224), + 1439: uint8(96), + 1440: uint8(128), + 1441: uint8(248), + 1442: uint8(255), + 1443: uint8(255), + 1444: uint8(255), + 1445: uint8(252), + 1446: uint8(255), + 1447: uint8(255), + 1448: uint8(255), + 1449: uint8(255), + 1450: uint8(255), + 1451: uint8(127), + 1452: uint8(223), + 1453: uint8(255), + 1454: uint8(241), + 1455: uint8(127), + 1456: uint8(255), + 1457: uint8(127), + 1460: uint8(255), + 1461: uint8(255), + 1462: uint8(255), + 1463: uint8(255), + 1466: uint8(255), + 1467: uint8(255), + 1468: uint8(255), + 1469: uint8(255), + 1470: uint8(1), + 1472: uint8(123), + 1473: uint8(3), + 1474: uint8(208), + 1475: uint8(193), + 1476: uint8(175), + 1477: uint8(66), + 1479: uint8(12), + 1480: uint8(31), + 1481: uint8(188), + 1482: uint8(255), + 1483: uint8(255), + 1489: uint8(14), + 1490: uint8(255), + 1491: uint8(255), + 1492: uint8(255), + 1493: uint8(255), + 1494: uint8(255), + 1495: uint8(255), + 1496: uint8(255), + 1497: uint8(255), + 1498: uint8(255), + 1499: uint8(255), + 1500: uint8(255), + 1501: uint8(255), + 1502: uint8(255), + 1503: uint8(255), + 1504: uint8(255), + 1505: uint8(255), + 1506: uint8(255), + 1507: uint8(255), + 1508: uint8(127), + 1512: uint8(255), + 1513: uint8(7), + 1516: uint8(255), + 1517: uint8(255), + 1518: uint8(255), + 1519: uint8(255), + 1520: uint8(255), + 1521: uint8(255), + 1522: uint8(255), + 1523: uint8(255), + 1524: uint8(255), + 1525: uint8(255), + 1526: uint8(63), + 1533: uint8(252), + 1534: uint8(255), + 1535: uint8(255), + 1536: uint8(255), + 1537: uint8(255), + 1538: uint8(255), + 1539: uint8(255), + 1540: uint8(255), + 1541: uint8(255), + 1542: uint8(255), + 1543: uint8(255), + 1544: uint8(255), + 1545: uint8(255), + 1546: uint8(255), + 1547: uint8(255), + 1548: uint8(255), + 1549: uint8(255), + 1550: uint8(207), + 1551: uint8(255), + 1552: uint8(255), + 1553: uint8(255), + 1554: uint8(63), + 1555: uint8(255), + 1556: uint8(255), + 1557: uint8(255), + 1558: uint8(255), + 1559: uint8(255), + 1560: uint8(255), + 1561: uint8(255), + 1562: uint8(255), + 1563: uint8(255), + 1564: uint8(255), + 1565: uint8(255), + 1566: uint8(255), + 1567: uint8(255), + 1596: uint8(224), + 1597: uint8(135), + 1598: uint8(3), + 1599: uint8(254), + 1614: uint8(1), + 1615: uint8(128), + 1632: uint8(255), + 1633: uint8(255), + 1634: uint8(255), + 1635: uint8(255), + 1636: uint8(255), + 1637: uint8(127), + 1638: uint8(255), + 1639: uint8(255), + 1640: uint8(255), + 1641: uint8(255), + 1648: uint8(255), + 1649: uint8(255), + 1650: uint8(255), + 1651: uint8(251), + 1652: uint8(255), + 1653: uint8(255), + 1654: uint8(255), + 1655: uint8(255), + 1656: uint8(255), + 1657: uint8(255), + 1658: uint8(255), + 1659: uint8(255), + 1660: uint8(255), + 1661: uint8(255), + 1662: uint8(15), + 1664: uint8(255), + 1665: uint8(255), + 1666: uint8(255), + 1667: uint8(255), + 1668: uint8(255), + 1669: uint8(255), + 1670: uint8(255), + 1671: uint8(255), + 1672: uint8(255), + 1673: uint8(255), + 1674: uint8(255), + 1675: uint8(255), + 1676: uint8(255), + 1677: uint8(255), + 1678: uint8(255), + 1679: uint8(255), + 1680: uint8(255), + 1681: uint8(255), + 1682: uint8(255), + 1683: uint8(255), + 1684: uint8(255), + 1685: uint8(255), + 1686: uint8(255), + 1687: uint8(255), + 1688: uint8(255), + 1689: uint8(255), + 1690: uint8(63), + 1694: uint8(255), + 1695: uint8(15), + 1696: uint8(30), + 1697: uint8(255), + 1698: uint8(255), + 1699: uint8(255), + 1700: uint8(1), + 1701: uint8(252), + 1702: uint8(193), + 1703: uint8(224), + 1715: uint8(30), + 1716: uint8(1), + 1727: uint8(8), + 1746: uint8(255), + 1747: uint8(255), + 1752: uint8(255), + 1753: uint8(255), + 1754: uint8(255), + 1755: uint8(255), + 1756: uint8(15), + 1760: uint8(255), + 1761: uint8(255), + 1762: uint8(255), + 1763: uint8(127), + 1764: uint8(255), + 1765: uint8(255), + 1766: uint8(255), + 1767: uint8(255), + 1768: uint8(255), + 1769: uint8(255), + 1770: uint8(255), + 1771: uint8(255), + 1772: uint8(255), + 1773: uint8(255), + 1774: uint8(255), + 1775: uint8(255), + 1776: uint8(255), + 1777: uint8(255), + 1778: uint8(255), + 1779: uint8(255), + 1780: uint8(255), + 1781: uint8(255), + 1782: uint8(255), + 1783: uint8(255), + 1784: uint8(255), + 1785: uint8(255), + 1786: uint8(255), + 1787: uint8(255), + 1788: uint8(255), + 1789: uint8(255), + 1790: uint8(255), + 1791: uint8(255), + 1816: uint8(255), + 1817: uint8(255), + 1818: uint8(255), + 1819: uint8(255), + 1820: uint8(255), + 1821: uint8(255), + 1822: uint8(255), + 1823: uint8(255), + 1842: uint8(255), + 1843: uint8(255), + 1844: uint8(255), + 1845: uint8(255), + 1846: uint8(255), + 1847: uint8(255), + 1848: uint8(127), + 1855: uint8(192), + 1857: uint8(224), + 1869: uint8(128), + 1870: uint8(15), + 1871: uint8(112), + 1886: uint8(255), + 1888: uint8(255), + 1889: uint8(255), + 1890: uint8(127), + 1892: uint8(3), + 1905: uint8(6), + 1920: uint8(64), + 1925: uint8(15), + 1926: uint8(255), + 1927: uint8(3), + 1934: uint8(240), + 1944: uint8(16), + 1945: uint8(192), + 1948: uint8(255), + 1949: uint8(255), + 1950: uint8(3), + 1951: uint8(23), + 1957: uint8(248), + 1962: uint8(8), + 1963: uint8(128), + 1974: uint8(8), + 1976: uint8(255), + 1977: uint8(63), + 1979: uint8(192), + 1995: uint8(240), + 1998: uint8(128), + 1999: uint8(3), + 2007: uint8(128), + 2008: uint8(2), + 2011: uint8(192), + 2014: uint8(67), + 2027: uint8(8), + 2045: uint8(56), + 2048: uint8(1), + 2111: uint8(128), + 2117: uint8(2), + 2134: uint8(252), + 2135: uint8(255), + 2136: uint8(3), + 2151: uint8(192), + 2175: uint8(48), + 2176: uint8(255), + 2177: uint8(255), + 2178: uint8(255), + 2179: uint8(3), + 2180: uint8(255), + 2181: uint8(255), + 2182: uint8(255), + 2183: uint8(255), + 2184: uint8(255), + 2185: uint8(255), + 2186: uint8(247), + 2187: uint8(255), + 2188: uint8(127), + 2189: uint8(15), + 2207: uint8(128), + 2208: uint8(254), + 2209: uint8(255), + 2211: uint8(252), + 2212: uint8(1), + 2215: uint8(248), + 2216: uint8(1), + 2219: uint8(248), + 2220: uint8(63), + 2236: uint8(127), + 2237: uint8(127), + 2239: uint8(48), + 2240: uint8(135), + 2241: uint8(255), + 2242: uint8(255), + 2243: uint8(255), + 2244: uint8(255), + 2245: uint8(255), + 2246: uint8(143), + 2247: uint8(255), + 2254: uint8(224), + 2255: uint8(255), + 2256: uint8(255), + 2257: uint8(127), + 2258: uint8(255), + 2259: uint8(15), + 2260: uint8(1), + 2266: uint8(255), + 2267: uint8(255), + 2268: uint8(255), + 2269: uint8(255), + 2270: uint8(255), + 2271: uint8(63), + 2300: uint8(255), + 2301: uint8(255), + 2302: uint8(255), + 2303: uint8(15), + 2308: uint8(15), + 2323: uint8(128), + 2330: uint8(1), + 2349: uint8(128), + 2378: uint8(128), + 2379: uint8(255), + 2382: uint8(128), + 2383: uint8(255), + 2388: uint8(128), + 2389: uint8(255), + 2399: uint8(248), + 2402: uint8(192), + 2403: uint8(143), + 2407: uint8(128), + 2423: uint8(48), + 2424: uint8(255), + 2425: uint8(255), + 2426: uint8(252), + 2427: uint8(255), + 2428: uint8(255), + 2429: uint8(255), + 2430: uint8(255), + 2431: uint8(255), + 2439: uint8(135), + 2440: uint8(255), + 2441: uint8(1), + 2442: uint8(255), + 2443: uint8(1), + 2447: uint8(224), + 2451: uint8(224), + 2457: uint8(1), + 2460: uint8(96), + 2461: uint8(248), + 2462: uint8(127), + 2471: uint8(254), + 2475: uint8(255), + 2479: uint8(255), + 2483: uint8(30), + 2485: uint8(254), + 2527: uint8(252), + 2540: uint8(255), + 2541: uint8(255), + 2542: uint8(255), + 2543: uint8(127), + 2563: uint8(224), + 2564: uint8(127), + 2568: uint8(192), + 2569: uint8(255), + 2570: uint8(255), + 2571: uint8(3), + 2600: uint8(192), + 2601: uint8(63), + 2602: uint8(252), + 2603: uint8(255), + 2604: uint8(63), + 2607: uint8(128), + 2608: uint8(3), + 2615: uint8(254), + 2616: uint8(3), + 2617: uint8(32), + 2630: uint8(24), + 2632: uint8(15), + 2638: uint8(56), + 2648: uint8(225), + 2649: uint8(63), + 2651: uint8(232), + 2652: uint8(254), + 2653: uint8(255), + 2654: uint8(31), + 2662: uint8(96), + 2663: uint8(63), + 2677: uint8(2), + 2685: uint8(6), + 2695: uint8(24), + 2697: uint8(32), + 2700: uint8(192), + 2701: uint8(31), + 2702: uint8(31), + 2728: uint8(68), + 2729: uint8(248), + 2731: uint8(104), + 2744: uint8(76), + 2775: uint8(128), + 2776: uint8(255), + 2777: uint8(255), + 2778: uint8(255), + 2791: uint8(128), + 2792: uint8(14), + 2796: uint8(255), + 2797: uint8(31), + 2806: uint8(192), + 2821: uint8(8), + 2823: uint8(252), + 2855: uint8(14), + 2877: uint8(252), + 2878: uint8(7), + 2908: uint8(5), + 2918: uint8(24), + 2919: uint8(128), + 2920: uint8(255), + 2931: uint8(223), + 2932: uint8(7), + 2951: uint8(128), + 2952: uint8(62), + 2955: uint8(252), + 2956: uint8(255), + 2957: uint8(31), + 2958: uint8(3), + 2984: uint8(52), + 2994: uint8(128), + 3038: uint8(128), + 3039: uint8(1), + 3064: uint8(255), + 3065: uint8(255), + 3066: uint8(255), + 3067: uint8(255), + 3068: uint8(255), + 3069: uint8(255), + 3070: uint8(3), + 3071: uint8(128), + 3086: uint8(31), + 3110: uint8(255), + 3111: uint8(1), + 3149: uint8(192), + 3166: uint8(63), + 3174: uint8(255), + 3175: uint8(255), + 3176: uint8(48), + 3179: uint8(248), + 3180: uint8(3), + 3216: uint8(255), + 3217: uint8(255), + 3218: uint8(255), + 3219: uint8(7), + 3260: uint8(4), + 3283: uint8(176), + 3284: uint8(15), + 3296: uint8(255), + 3297: uint8(255), + 3298: uint8(255), + 3299: uint8(255), + 3300: uint8(255), + 3301: uint8(255), + 3302: uint8(255), + 3303: uint8(255), + 3304: uint8(255), + 3305: uint8(255), + 3306: uint8(255), + 3307: uint8(255), + 3308: uint8(255), + 3309: uint8(255), + 3310: uint8(255), + 3311: uint8(255), + 3312: uint8(255), + 3313: uint8(255), + 3314: uint8(255), + 3315: uint8(255), + 3316: uint8(255), + 3317: uint8(255), + 3318: uint8(255), + 3319: uint8(255), + 3320: uint8(255), + 3321: uint8(255), + 3322: uint8(255), + 3323: uint8(255), + 3324: uint8(255), + 3325: uint8(255), + 3326: uint8(63), + 3328: uint8(255), + 3329: uint8(255), + 3330: uint8(255), + 3331: uint8(255), + 3332: uint8(127), + 3333: uint8(254), + 3334: uint8(255), + 3335: uint8(255), + 3336: uint8(255), + 3337: uint8(255), + 3338: uint8(255), + 3339: uint8(255), + 3340: uint8(255), + 3341: uint8(255), + 3342: uint8(255), + 3343: uint8(255), + 3344: uint8(255), + 3345: uint8(255), + 3346: uint8(255), + 3347: uint8(255), + 3348: uint8(255), + 3349: uint8(255), + 3350: uint8(255), + 3351: uint8(255), + 3352: uint8(255), + 3353: uint8(255), + 3354: uint8(255), + 3355: uint8(255), + 3356: uint8(255), + 3357: uint8(1), + 3360: uint8(255), + 3361: uint8(255), + 3362: uint8(255), + 3363: uint8(255), + 3364: uint8(255), + 3365: uint8(255), + 3366: uint8(255), + 3367: uint8(255), + 3368: uint8(63), + 3388: uint8(255), + 3389: uint8(255), + 3390: uint8(15), + 3392: uint8(255), + 3393: uint8(255), + 3394: uint8(255), + 3395: uint8(255), + 3396: uint8(255), + 3397: uint8(255), + 3398: uint8(255), + 3399: uint8(255), + 3400: uint8(255), + 3401: uint8(255), + 3402: uint8(127), + 3404: uint8(255), + 3405: uint8(255), + 3406: uint8(255), + 3407: uint8(1), + 3448: uint8(2), + 3451: uint8(8), + 3455: uint8(8), + 3458: uint8(32), + 3462: uint8(32), + 3465: uint8(128), + 3469: uint8(128), + 3473: uint8(2), + 3477: uint8(2), + 3480: uint8(8), + 3488: uint8(255), + 3489: uint8(255), + 3490: uint8(255), + 3491: uint8(255), + 3492: uint8(255), + 3493: uint8(255), + 3494: uint8(255), + 3495: uint8(255), + 3496: uint8(255), + 3497: uint8(255), + 3498: uint8(255), + 3499: uint8(255), + 3500: uint8(255), + 3501: uint8(255), + 3502: uint8(255), + 3503: uint8(255), + 3504: uint8(255), + 3505: uint8(15), + 3507: uint8(248), + 3508: uint8(254), + 3509: uint8(255), + 3526: uint8(127), + 3529: uint8(128), + 3581: uint8(240), + 3583: uint8(128), + 3608: uint8(128), + 3609: uint8(255), + 3610: uint8(127), + 3624: uint8(112), + 3625: uint8(7), + 3627: uint8(192), + 3662: uint8(254), + 3663: uint8(255), + 3664: uint8(255), + 3665: uint8(255), + 3666: uint8(255), + 3667: uint8(255), + 3668: uint8(255), + 3669: uint8(255), + 3670: uint8(31), + 3680: uint8(254), + 3681: uint8(255), + 3682: uint8(255), + 3683: uint8(255), + 3684: uint8(255), + 3685: uint8(255), + 3686: uint8(255), + 3687: uint8(63), + 3742: uint8(3), + 3744: uint8(255), + 3745: uint8(255), + 3746: uint8(255), + 3747: uint8(255), + 3748: uint8(255), + 3749: uint8(15), + 3750: uint8(255), + 3751: uint8(255), + 3752: uint8(255), + 3753: uint8(255), + 3754: uint8(255), + 3755: uint8(255), + 3756: uint8(255), + 3757: uint8(255), + 3758: uint8(255), + 3759: uint8(255), + 3760: uint8(255), + 3761: uint8(255), + 3762: uint8(15), + 3764: uint8(255), + 3765: uint8(127), + 3766: uint8(254), + 3767: uint8(255), + 3768: uint8(254), + 3769: uint8(255), + 3770: uint8(254), + 3771: uint8(255), + 3772: uint8(255), + 3773: uint8(255), + 3774: uint8(63), + 3776: uint8(255), + 3777: uint8(31), + 3778: uint8(255), + 3779: uint8(255), + 3780: uint8(255), + 3781: uint8(255), + 3785: uint8(252), + 3789: uint8(28), + 3793: uint8(252), + 3794: uint8(255), + 3795: uint8(255), + 3796: uint8(255), + 3797: uint8(31), + 3804: uint8(192), + 3805: uint8(255), + 3806: uint8(255), + 3807: uint8(255), + 3808: uint8(7), + 3810: uint8(255), + 3811: uint8(255), + 3812: uint8(255), + 3813: uint8(255), + 3814: uint8(255), + 3815: uint8(15), + 3816: uint8(255), + 3817: uint8(1), + 3818: uint8(3), + 3820: uint8(63), + 3840: uint8(255), + 3841: uint8(255), + 3842: uint8(255), + 3843: uint8(255), + 3844: uint8(255), + 3845: uint8(255), + 3846: uint8(255), + 3847: uint8(255), + 3848: uint8(255), + 3849: uint8(255), + 3850: uint8(255), + 3851: uint8(255), + 3852: uint8(255), + 3853: uint8(255), + 3854: uint8(255), + 3855: uint8(255), + 3856: uint8(255), + 3857: uint8(255), + 3858: uint8(255), + 3859: uint8(255), + 3860: uint8(255), + 3861: uint8(255), + 3862: uint8(255), + 3863: uint8(255), + 3864: uint8(255), + 3865: uint8(255), + 3866: uint8(63), + 3868: uint8(255), + 3869: uint8(31), + 3870: uint8(255), + 3871: uint8(7), + 3872: uint8(255), + 3873: uint8(255), + 3874: uint8(255), + 3875: uint8(255), + 3876: uint8(255), + 3877: uint8(255), + 3878: uint8(255), + 3879: uint8(255), + 3880: uint8(255), + 3881: uint8(255), + 3882: uint8(255), + 3883: uint8(255), + 3884: uint8(255), + 3885: uint8(255), + 3886: uint8(15), + 3888: uint8(255), + 3889: uint8(255), + 3890: uint8(255), + 3891: uint8(255), + 3892: uint8(255), + 3893: uint8(255), + 3894: uint8(255), + 3895: uint8(255), + 3896: uint8(255), + 3897: uint8(255), + 3898: uint8(255), + 3899: uint8(1), + 3900: uint8(255), + 3901: uint8(15), + 3904: uint8(255), + 3905: uint8(15), + 3906: uint8(255), + 3907: uint8(255), + 3908: uint8(255), + 3909: uint8(255), + 3910: uint8(255), + 3911: uint8(255), + 3912: uint8(255), + 3914: uint8(255), + 3915: uint8(3), + 3916: uint8(255), + 3917: uint8(255), + 3918: uint8(255), + 3919: uint8(255), + 3920: uint8(255), + 3922: uint8(255), + 3923: uint8(255), + 3924: uint8(255), + 3925: uint8(63), + 3936: uint8(255), + 3937: uint8(239), + 3938: uint8(255), + 3939: uint8(255), + 3940: uint8(255), + 3941: uint8(255), + 3942: uint8(255), + 3943: uint8(255), + 3944: uint8(255), + 3945: uint8(255), + 3946: uint8(255), + 3947: uint8(255), + 3948: uint8(255), + 3949: uint8(255), + 3950: uint8(123), + 3951: uint8(252), + 3952: uint8(255), + 3953: uint8(255), + 3954: uint8(255), + 3955: uint8(255), + 3956: uint8(231), + 3957: uint8(199), + 3958: uint8(255), + 3959: uint8(255), + 3960: uint8(255), + 3961: uint8(231), + 3962: uint8(255), + 3963: uint8(255), + 3964: uint8(255), + 3965: uint8(255), + 3966: uint8(255), + 3967: uint8(255), + 3968: uint8(255), + 3969: uint8(255), + 3970: uint8(255), + 3971: uint8(255), + 3972: uint8(255), + 3973: uint8(255), + 3974: uint8(255), + 3975: uint8(255), + 3976: uint8(255), + 3977: uint8(255), + 3978: uint8(15), + 3980: uint8(255), + 3981: uint8(63), + 3982: uint8(15), + 3983: uint8(7), + 3984: uint8(7), + 3986: uint8(63), +} + +func Xiswpunct(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if wc < uint32(0x20000) { + return Int32FromUint8(_table4[Uint32FromInt32(Int32FromUint8(_table4[wc>>int32(8)])*int32(32))+wc&uint32(255)>>int32(3)]) >> (wc & uint32(7)) & int32(1) + } + return 0 +} + +func X__iswpunct_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswpunct(tls, c) +} + +func Xiswpunct_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswpunct_l(tls, c, l) +} + +type Tmbstate_t = struct { + F__opaque1 uint32 + F__opaque2 uint32 +} + +type t__mbstate_t = Tmbstate_t + +/* Our definition of whitespace is the Unicode White_Space property, + * minus non-breaking spaces (U+00A0, U+2007, and U+202F) and script- + * specific characters with non-blank glyphs (U+1680 and U+180E). */ + +func Xiswspace(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(wc != 0 && Xwcschr(tls, uintptr(unsafe.Pointer(&_spaces)), wc) != 0) +} + +var _spaces = [22]Twchar_t{ + 0: uint32(' '), + 1: uint32('\t'), + 2: uint32('\n'), + 3: uint32('\r'), + 4: uint32(11), + 5: uint32(12), + 6: uint32(0x0085), + 7: uint32(0x2000), + 8: uint32(0x2001), + 9: uint32(0x2002), + 10: uint32(0x2003), + 11: uint32(0x2004), + 12: uint32(0x2005), + 13: uint32(0x2006), + 14: uint32(0x2008), + 15: uint32(0x2009), + 16: uint32(0x200a), + 17: uint32(0x2028), + 18: uint32(0x2029), + 19: uint32(0x205f), + 20: uint32(0x3000), +} + +func X__iswspace_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswspace(tls, c) +} + +func Xiswspace_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswspace_l(tls, c, l) +} + +func Xiswupper(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(Xtowlower(tls, wc) != wc) +} + +func X__iswupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswupper(tls, c) +} + +func Xiswupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswupper_l(tls, c, l) +} + +func Xiswxdigit(tls *TLS, wc Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(wc-Uint32FromUint8('0') < uint32(10) || wc|Uint32FromInt32(32)-Uint32FromUint8('a') < uint32(6)) +} + +func X__iswxdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xiswxdigit(tls, c) +} + +func Xiswxdigit_l(tls *TLS, c Twint_t, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__iswxdigit_l(tls, c, l) +} + +func Xisxdigit(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(BoolInt32(Uint32FromInt32(c)-uint32('0') < uint32(10)) != 0 || Uint32FromInt32(c)|uint32(32)-uint32('a') < uint32(6)) +} + +func X__isxdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xisxdigit(tls, c) +} + +func Xisxdigit_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__isxdigit_l(tls, c, l) +} + +// C documentation +// +// /* nonsense function that should NEVER be used! */ +func Xtoascii(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return c & int32(0x7f) +} + +func Xtolower(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + if BoolInt32(Uint32FromInt32(c)-uint32('A') < uint32(26)) != 0 { + return c | int32(32) + } + return c +} + +func X__tolower_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtolower(tls, c) +} + +func Xtolower_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__tolower_l(tls, c, l) +} + +func Xtoupper(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + if BoolInt32(Uint32FromInt32(c)-uint32('a') < uint32(26)) != 0 { + return c & int32(0x5f) + } + return c +} + +func X__toupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtoupper(tls, c) +} + +func Xtoupper_l(tls *TLS, c int32, l Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__toupper_l(tls, c, l) +} + +var _tab1 = [2666]uint8{ + 0: uint8(7), + 1: uint8(8), + 2: uint8(9), + 3: uint8(10), + 4: uint8(11), + 5: uint8(12), + 6: uint8(6), + 7: uint8(6), + 8: uint8(6), + 9: uint8(6), + 10: uint8(6), + 11: uint8(6), + 12: uint8(6), + 13: uint8(6), + 14: uint8(6), + 15: uint8(6), + 16: uint8(13), + 17: uint8(6), + 18: uint8(6), + 19: uint8(14), + 20: uint8(6), + 21: uint8(6), + 22: uint8(6), + 23: uint8(6), + 24: uint8(6), + 25: uint8(6), + 26: uint8(6), + 27: uint8(6), + 28: uint8(15), + 29: uint8(16), + 30: uint8(17), + 31: uint8(18), + 32: uint8(6), + 33: uint8(19), + 34: uint8(6), + 35: uint8(6), + 36: uint8(6), + 37: uint8(6), + 38: uint8(6), + 39: uint8(6), + 40: uint8(6), + 41: uint8(6), + 42: uint8(6), + 43: uint8(6), + 44: uint8(20), + 45: uint8(21), + 46: uint8(6), + 47: uint8(6), + 48: uint8(6), + 49: uint8(6), + 50: uint8(6), + 51: uint8(6), + 52: uint8(6), + 53: uint8(6), + 54: uint8(6), + 55: uint8(6), + 56: uint8(6), + 57: uint8(6), + 58: uint8(6), + 59: uint8(6), + 60: uint8(6), + 61: uint8(6), + 62: uint8(6), + 63: uint8(6), + 64: uint8(6), + 65: uint8(6), + 66: uint8(6), + 67: uint8(6), + 68: uint8(6), + 69: uint8(6), + 70: uint8(6), + 71: uint8(6), + 72: uint8(6), + 73: uint8(6), + 74: uint8(6), + 75: uint8(6), + 76: uint8(6), + 77: uint8(6), + 78: uint8(6), + 79: uint8(6), + 80: uint8(6), + 81: uint8(6), + 82: uint8(6), + 83: uint8(6), + 84: uint8(6), + 85: uint8(6), + 86: uint8(6), + 87: uint8(6), + 88: uint8(6), + 89: uint8(6), + 90: uint8(6), + 91: uint8(6), + 92: uint8(6), + 93: uint8(6), + 94: uint8(6), + 95: uint8(6), + 96: uint8(6), + 97: uint8(6), + 98: uint8(6), + 99: uint8(6), + 100: uint8(6), + 101: uint8(6), + 102: uint8(6), + 103: uint8(6), + 104: uint8(6), + 105: uint8(6), + 106: uint8(6), + 107: uint8(6), + 108: uint8(6), + 109: uint8(6), + 110: uint8(6), + 111: uint8(6), + 112: uint8(6), + 113: uint8(6), + 114: uint8(6), + 115: uint8(6), + 116: uint8(6), + 117: uint8(6), + 118: uint8(6), + 119: uint8(6), + 120: uint8(6), + 121: uint8(6), + 122: uint8(6), + 123: uint8(6), + 124: uint8(6), + 125: uint8(6), + 126: uint8(6), + 127: uint8(6), + 128: uint8(6), + 129: uint8(6), + 130: uint8(6), + 131: uint8(6), + 132: uint8(6), + 133: uint8(6), + 134: uint8(6), + 135: uint8(6), + 136: uint8(6), + 137: uint8(6), + 138: uint8(6), + 139: uint8(6), + 140: uint8(6), + 141: uint8(6), + 142: uint8(6), + 143: uint8(6), + 144: uint8(6), + 145: uint8(6), + 146: uint8(6), + 147: uint8(6), + 148: uint8(6), + 149: uint8(6), + 150: uint8(6), + 151: uint8(6), + 152: uint8(6), + 153: uint8(6), + 154: uint8(6), + 155: uint8(6), + 156: uint8(6), + 157: uint8(6), + 158: uint8(6), + 159: uint8(6), + 160: uint8(6), + 161: uint8(6), + 162: uint8(6), + 163: uint8(6), + 164: uint8(6), + 165: uint8(6), + 166: uint8(22), + 167: uint8(23), + 168: uint8(6), + 169: uint8(6), + 170: uint8(6), + 171: uint8(24), + 172: uint8(6), + 173: uint8(6), + 174: uint8(6), + 175: uint8(6), + 176: uint8(6), + 177: uint8(6), + 178: uint8(6), + 179: uint8(6), + 180: uint8(6), + 181: uint8(6), + 182: uint8(6), + 183: uint8(6), + 184: uint8(6), + 185: uint8(6), + 186: uint8(6), + 187: uint8(6), + 188: uint8(6), + 189: uint8(6), + 190: uint8(6), + 191: uint8(6), + 192: uint8(6), + 193: uint8(6), + 194: uint8(6), + 195: uint8(6), + 196: uint8(6), + 197: uint8(6), + 198: uint8(6), + 199: uint8(6), + 200: uint8(6), + 201: uint8(6), + 202: uint8(6), + 203: uint8(6), + 204: uint8(6), + 205: uint8(6), + 206: uint8(6), + 207: uint8(6), + 208: uint8(6), + 209: uint8(6), + 210: uint8(6), + 211: uint8(6), + 212: uint8(6), + 213: uint8(6), + 214: uint8(6), + 215: uint8(6), + 216: uint8(6), + 217: uint8(6), + 218: uint8(6), + 219: uint8(6), + 220: uint8(6), + 221: uint8(6), + 222: uint8(6), + 223: uint8(6), + 224: uint8(6), + 225: uint8(6), + 226: uint8(6), + 227: uint8(6), + 228: uint8(6), + 229: uint8(6), + 230: uint8(6), + 231: uint8(6), + 232: uint8(6), + 233: uint8(6), + 234: uint8(6), + 235: uint8(6), + 236: uint8(6), + 237: uint8(6), + 238: uint8(6), + 239: uint8(6), + 240: uint8(6), + 241: uint8(6), + 242: uint8(6), + 243: uint8(6), + 244: uint8(6), + 245: uint8(6), + 246: uint8(6), + 247: uint8(6), + 248: uint8(6), + 249: uint8(6), + 250: uint8(6), + 251: uint8(6), + 252: uint8(6), + 253: uint8(6), + 254: uint8(6), + 255: uint8(25), + 256: uint8(6), + 257: uint8(6), + 258: uint8(6), + 259: uint8(6), + 260: uint8(26), + 261: uint8(6), + 262: uint8(6), + 263: uint8(6), + 264: uint8(6), + 265: uint8(6), + 266: uint8(6), + 267: uint8(6), + 268: uint8(27), + 269: uint8(6), + 270: uint8(6), + 271: uint8(6), + 272: uint8(6), + 273: uint8(6), + 274: uint8(6), + 275: uint8(6), + 276: uint8(6), + 277: uint8(6), + 278: uint8(6), + 279: uint8(6), + 280: uint8(28), + 281: uint8(6), + 282: uint8(6), + 283: uint8(6), + 284: uint8(6), + 285: uint8(6), + 286: uint8(6), + 287: uint8(6), + 288: uint8(6), + 289: uint8(6), + 290: uint8(6), + 291: uint8(6), + 292: uint8(6), + 293: uint8(6), + 294: uint8(6), + 295: uint8(6), + 296: uint8(6), + 297: uint8(6), + 298: uint8(6), + 299: uint8(6), + 300: uint8(6), + 301: uint8(6), + 302: uint8(6), + 303: uint8(6), + 304: uint8(6), + 305: uint8(6), + 306: uint8(6), + 307: uint8(6), + 308: uint8(6), + 309: uint8(6), + 310: uint8(6), + 311: uint8(6), + 312: uint8(6), + 313: uint8(6), + 314: uint8(6), + 315: uint8(6), + 316: uint8(6), + 317: uint8(6), + 318: uint8(6), + 319: uint8(6), + 320: uint8(6), + 321: uint8(6), + 322: uint8(6), + 323: uint8(6), + 324: uint8(6), + 325: uint8(6), + 326: uint8(6), + 327: uint8(6), + 328: uint8(6), + 329: uint8(6), + 330: uint8(6), + 331: uint8(6), + 332: uint8(6), + 333: uint8(6), + 334: uint8(6), + 335: uint8(6), + 336: uint8(6), + 337: uint8(6), + 338: uint8(6), + 339: uint8(6), + 340: uint8(6), + 341: uint8(6), + 342: uint8(6), + 343: uint8(6), + 344: uint8(6), + 345: uint8(6), + 346: uint8(6), + 347: uint8(6), + 348: uint8(6), + 349: uint8(6), + 350: uint8(6), + 351: uint8(6), + 352: uint8(6), + 353: uint8(6), + 354: uint8(6), + 355: uint8(6), + 356: uint8(6), + 357: uint8(6), + 358: uint8(6), + 359: uint8(6), + 360: uint8(6), + 361: uint8(6), + 362: uint8(6), + 363: uint8(6), + 364: uint8(6), + 365: uint8(6), + 366: uint8(29), + 367: uint8(6), + 368: uint8(6), + 369: uint8(6), + 370: uint8(6), + 371: uint8(6), + 372: uint8(6), + 373: uint8(6), + 374: uint8(6), + 375: uint8(6), + 376: uint8(6), + 377: uint8(6), + 378: uint8(6), + 379: uint8(6), + 380: uint8(6), + 381: uint8(6), + 382: uint8(6), + 383: uint8(6), + 384: uint8(6), + 385: uint8(6), + 386: uint8(6), + 387: uint8(6), + 388: uint8(6), + 389: uint8(6), + 390: uint8(6), + 391: uint8(6), + 392: uint8(6), + 393: uint8(6), + 394: uint8(6), + 395: uint8(6), + 396: uint8(6), + 397: uint8(6), + 398: uint8(6), + 399: uint8(6), + 400: uint8(6), + 401: uint8(6), + 402: uint8(6), + 403: uint8(6), + 404: uint8(6), + 405: uint8(6), + 406: uint8(6), + 407: uint8(6), + 408: uint8(6), + 409: uint8(6), + 410: uint8(6), + 411: uint8(6), + 412: uint8(6), + 413: uint8(6), + 414: uint8(6), + 415: uint8(6), + 416: uint8(6), + 417: uint8(6), + 418: uint8(6), + 419: uint8(6), + 420: uint8(6), + 421: uint8(6), + 422: uint8(6), + 423: uint8(6), + 424: uint8(6), + 425: uint8(6), + 426: uint8(6), + 427: uint8(6), + 428: uint8(6), + 429: uint8(6), + 430: uint8(6), + 431: uint8(6), + 432: uint8(6), + 433: uint8(6), + 434: uint8(6), + 435: uint8(6), + 436: uint8(6), + 437: uint8(6), + 438: uint8(6), + 439: uint8(6), + 440: uint8(6), + 441: uint8(6), + 442: uint8(6), + 443: uint8(6), + 444: uint8(6), + 445: uint8(6), + 446: uint8(6), + 447: uint8(6), + 448: uint8(6), + 449: uint8(6), + 450: uint8(6), + 451: uint8(6), + 452: uint8(6), + 453: uint8(6), + 454: uint8(6), + 455: uint8(6), + 456: uint8(6), + 457: uint8(6), + 458: uint8(6), + 459: uint8(6), + 460: uint8(6), + 461: uint8(6), + 462: uint8(6), + 463: uint8(6), + 464: uint8(6), + 465: uint8(6), + 466: uint8(6), + 467: uint8(6), + 468: uint8(6), + 469: uint8(6), + 470: uint8(6), + 471: uint8(6), + 472: uint8(6), + 473: uint8(6), + 474: uint8(6), + 475: uint8(6), + 476: uint8(6), + 477: uint8(6), + 478: uint8(6), + 479: uint8(6), + 480: uint8(6), + 481: uint8(6), + 482: uint8(6), + 483: uint8(6), + 484: uint8(6), + 485: uint8(6), + 486: uint8(6), + 487: uint8(6), + 488: uint8(6), + 489: uint8(30), + 490: uint8(6), + 491: uint8(6), + 492: uint8(6), + 493: uint8(6), + 494: uint8(6), + 495: uint8(6), + 496: uint8(6), + 497: uint8(6), + 498: uint8(6), + 499: uint8(6), + 500: uint8(6), + 501: uint8(6), + 502: uint8(6), + 503: uint8(6), + 504: uint8(6), + 505: uint8(6), + 506: uint8(6), + 507: uint8(6), + 508: uint8(6), + 509: uint8(6), + 510: uint8(6), + 511: uint8(6), + 623: uint8(36), + 624: uint8(43), + 625: uint8(43), + 626: uint8(43), + 627: uint8(43), + 628: uint8(43), + 629: uint8(43), + 630: uint8(43), + 631: uint8(43), + 632: uint8(1), + 634: uint8(84), + 635: uint8(86), + 636: uint8(86), + 637: uint8(86), + 638: uint8(86), + 639: uint8(86), + 640: uint8(86), + 641: uint8(86), + 642: uint8(86), + 662: uint8(24), + 666: uint8(43), + 667: uint8(43), + 668: uint8(43), + 669: uint8(43), + 670: uint8(43), + 671: uint8(43), + 672: uint8(43), + 673: uint8(7), + 674: uint8(43), + 675: uint8(43), + 676: uint8(91), + 677: uint8(86), + 678: uint8(86), + 679: uint8(86), + 680: uint8(86), + 681: uint8(86), + 682: uint8(86), + 683: uint8(86), + 684: uint8(74), + 685: uint8(86), + 686: uint8(86), + 687: uint8(5), + 688: uint8(49), + 689: uint8(80), + 690: uint8(49), + 691: uint8(80), + 692: uint8(49), + 693: uint8(80), + 694: uint8(49), + 695: uint8(80), + 696: uint8(49), + 697: uint8(80), + 698: uint8(49), + 699: uint8(80), + 700: uint8(49), + 701: uint8(80), + 702: uint8(49), + 703: uint8(80), + 704: uint8(36), + 705: uint8(80), + 706: uint8(121), + 707: uint8(49), + 708: uint8(80), + 709: uint8(49), + 710: uint8(80), + 711: uint8(49), + 712: uint8(56), + 713: uint8(80), + 714: uint8(49), + 715: uint8(80), + 716: uint8(49), + 717: uint8(80), + 718: uint8(49), + 719: uint8(80), + 720: uint8(49), + 721: uint8(80), + 722: uint8(49), + 723: uint8(80), + 724: uint8(49), + 725: uint8(80), + 726: uint8(49), + 727: uint8(80), + 728: uint8(78), + 729: uint8(49), + 730: uint8(2), + 731: uint8(78), + 732: uint8(13), + 733: uint8(13), + 734: uint8(78), + 735: uint8(3), + 736: uint8(78), + 738: uint8(36), + 739: uint8(110), + 741: uint8(78), + 742: uint8(49), + 743: uint8(38), + 744: uint8(110), + 745: uint8(81), + 746: uint8(78), + 747: uint8(36), + 748: uint8(80), + 749: uint8(78), + 750: uint8(57), + 751: uint8(20), + 752: uint8(129), + 753: uint8(27), + 754: uint8(29), + 755: uint8(29), + 756: uint8(83), + 757: uint8(49), + 758: uint8(80), + 759: uint8(49), + 760: uint8(80), + 761: uint8(13), + 762: uint8(49), + 763: uint8(80), + 764: uint8(49), + 765: uint8(80), + 766: uint8(49), + 767: uint8(80), + 768: uint8(27), + 769: uint8(83), + 770: uint8(36), + 771: uint8(80), + 772: uint8(49), + 773: uint8(2), + 774: uint8(92), + 775: uint8(123), + 776: uint8(92), + 777: uint8(123), + 778: uint8(92), + 779: uint8(123), + 780: uint8(92), + 781: uint8(123), + 782: uint8(92), + 783: uint8(123), + 784: uint8(20), + 785: uint8(121), + 786: uint8(92), + 787: uint8(123), + 788: uint8(92), + 789: uint8(123), + 790: uint8(92), + 791: uint8(45), + 792: uint8(43), + 793: uint8(73), + 794: uint8(3), + 795: uint8(72), + 796: uint8(3), + 797: uint8(120), + 798: uint8(92), + 799: uint8(123), + 800: uint8(20), + 802: uint8(150), + 803: uint8(10), + 804: uint8(1), + 805: uint8(43), + 806: uint8(40), + 807: uint8(6), + 808: uint8(6), + 810: uint8(42), + 811: uint8(6), + 812: uint8(42), + 813: uint8(42), + 814: uint8(43), + 815: uint8(7), + 816: uint8(187), + 817: uint8(181), + 818: uint8(43), + 819: uint8(30), + 821: uint8(43), + 822: uint8(7), + 823: uint8(43), + 824: uint8(43), + 825: uint8(43), + 826: uint8(1), + 827: uint8(43), + 828: uint8(43), + 829: uint8(43), + 830: uint8(43), + 831: uint8(43), + 832: uint8(43), + 833: uint8(43), + 834: uint8(43), + 835: uint8(43), + 836: uint8(43), + 837: uint8(43), + 838: uint8(43), + 839: uint8(43), + 840: uint8(43), + 841: uint8(43), + 842: uint8(43), + 843: uint8(43), + 844: uint8(43), + 845: uint8(43), + 846: uint8(43), + 847: uint8(43), + 848: uint8(43), + 849: uint8(43), + 850: uint8(43), + 851: uint8(43), + 852: uint8(43), + 853: uint8(43), + 854: uint8(43), + 855: uint8(43), + 856: uint8(43), + 857: uint8(43), + 858: uint8(43), + 859: uint8(1), + 860: uint8(43), + 861: uint8(43), + 862: uint8(43), + 863: uint8(43), + 864: uint8(43), + 865: uint8(43), + 866: uint8(43), + 867: uint8(43), + 868: uint8(43), + 869: uint8(43), + 870: uint8(43), + 871: uint8(43), + 872: uint8(43), + 873: uint8(43), + 874: uint8(43), + 875: uint8(43), + 876: uint8(43), + 877: uint8(43), + 878: uint8(43), + 879: uint8(43), + 880: uint8(43), + 881: uint8(43), + 882: uint8(43), + 883: uint8(42), + 884: uint8(43), + 885: uint8(43), + 886: uint8(43), + 887: uint8(43), + 888: uint8(43), + 889: uint8(43), + 890: uint8(43), + 891: uint8(43), + 892: uint8(43), + 893: uint8(43), + 894: uint8(43), + 895: uint8(43), + 896: uint8(43), + 897: uint8(205), + 898: uint8(70), + 899: uint8(205), + 900: uint8(43), + 902: uint8(37), + 903: uint8(43), + 904: uint8(7), + 905: uint8(1), + 906: uint8(6), + 907: uint8(1), + 908: uint8(85), + 909: uint8(86), + 910: uint8(86), + 911: uint8(86), + 912: uint8(86), + 913: uint8(86), + 914: uint8(85), + 915: uint8(86), + 916: uint8(86), + 917: uint8(2), + 918: uint8(36), + 919: uint8(129), + 920: uint8(129), + 921: uint8(129), + 922: uint8(129), + 923: uint8(129), + 924: uint8(21), + 925: uint8(129), + 926: uint8(129), + 927: uint8(129), + 930: uint8(43), + 932: uint8(178), + 933: uint8(209), + 934: uint8(178), + 935: uint8(209), + 936: uint8(178), + 937: uint8(209), + 938: uint8(178), + 939: uint8(209), + 942: uint8(205), + 943: uint8(204), + 944: uint8(1), + 946: uint8(215), + 947: uint8(215), + 948: uint8(215), + 949: uint8(215), + 950: uint8(215), + 951: uint8(131), + 952: uint8(129), + 953: uint8(129), + 954: uint8(129), + 955: uint8(129), + 956: uint8(129), + 957: uint8(129), + 958: uint8(129), + 959: uint8(129), + 960: uint8(129), + 961: uint8(129), + 962: uint8(172), + 963: uint8(172), + 964: uint8(172), + 965: uint8(172), + 966: uint8(172), + 967: uint8(172), + 968: uint8(172), + 969: uint8(172), + 970: uint8(172), + 971: uint8(172), + 972: uint8(28), + 978: uint8(49), + 979: uint8(80), + 980: uint8(49), + 981: uint8(80), + 982: uint8(49), + 983: uint8(80), + 984: uint8(49), + 985: uint8(80), + 986: uint8(49), + 987: uint8(80), + 988: uint8(49), + 989: uint8(2), + 992: uint8(49), + 993: uint8(80), + 994: uint8(49), + 995: uint8(80), + 996: uint8(49), + 997: uint8(80), + 998: uint8(49), + 999: uint8(80), + 1000: uint8(49), + 1001: uint8(80), + 1002: uint8(49), + 1003: uint8(80), + 1004: uint8(49), + 1005: uint8(80), + 1006: uint8(49), + 1007: uint8(80), + 1008: uint8(49), + 1009: uint8(80), + 1010: uint8(78), + 1011: uint8(49), + 1012: uint8(80), + 1013: uint8(49), + 1014: uint8(80), + 1015: uint8(78), + 1016: uint8(49), + 1017: uint8(80), + 1018: uint8(49), + 1019: uint8(80), + 1020: uint8(49), + 1021: uint8(80), + 1022: uint8(49), + 1023: uint8(80), + 1024: uint8(49), + 1025: uint8(80), + 1026: uint8(49), + 1027: uint8(80), + 1028: uint8(49), + 1029: uint8(80), + 1030: uint8(49), + 1031: uint8(2), + 1032: uint8(135), + 1033: uint8(166), + 1034: uint8(135), + 1035: uint8(166), + 1036: uint8(135), + 1037: uint8(166), + 1038: uint8(135), + 1039: uint8(166), + 1040: uint8(135), + 1041: uint8(166), + 1042: uint8(135), + 1043: uint8(166), + 1044: uint8(135), + 1045: uint8(166), + 1046: uint8(135), + 1047: uint8(166), + 1048: uint8(42), + 1049: uint8(43), + 1050: uint8(43), + 1051: uint8(43), + 1052: uint8(43), + 1053: uint8(43), + 1054: uint8(43), + 1055: uint8(43), + 1056: uint8(43), + 1057: uint8(43), + 1058: uint8(43), + 1059: uint8(43), + 1060: uint8(43), + 1064: uint8(84), + 1065: uint8(86), + 1066: uint8(86), + 1067: uint8(86), + 1068: uint8(86), + 1069: uint8(86), + 1070: uint8(86), + 1071: uint8(86), + 1072: uint8(86), + 1073: uint8(86), + 1074: uint8(86), + 1075: uint8(86), + 1076: uint8(86), + 1171: uint8(84), + 1172: uint8(86), + 1173: uint8(86), + 1174: uint8(86), + 1175: uint8(86), + 1176: uint8(86), + 1177: uint8(86), + 1178: uint8(86), + 1179: uint8(86), + 1180: uint8(86), + 1181: uint8(86), + 1182: uint8(86), + 1183: uint8(86), + 1184: uint8(12), + 1186: uint8(12), + 1187: uint8(42), + 1188: uint8(43), + 1189: uint8(43), + 1190: uint8(43), + 1191: uint8(43), + 1192: uint8(43), + 1193: uint8(43), + 1194: uint8(43), + 1195: uint8(43), + 1196: uint8(43), + 1197: uint8(43), + 1198: uint8(43), + 1199: uint8(43), + 1200: uint8(43), + 1201: uint8(7), + 1202: uint8(42), + 1203: uint8(1), + 1257: uint8(42), + 1258: uint8(43), + 1259: uint8(43), + 1260: uint8(43), + 1261: uint8(43), + 1262: uint8(43), + 1263: uint8(43), + 1264: uint8(43), + 1265: uint8(43), + 1266: uint8(43), + 1267: uint8(43), + 1268: uint8(43), + 1269: uint8(43), + 1270: uint8(43), + 1271: uint8(43), + 1272: uint8(43), + 1273: uint8(43), + 1274: uint8(43), + 1275: uint8(43), + 1276: uint8(43), + 1277: uint8(43), + 1278: uint8(43), + 1279: uint8(43), + 1280: uint8(43), + 1281: uint8(43), + 1282: uint8(43), + 1283: uint8(43), + 1284: uint8(86), + 1285: uint8(86), + 1286: uint8(108), + 1287: uint8(129), + 1288: uint8(21), + 1290: uint8(43), + 1291: uint8(43), + 1292: uint8(43), + 1293: uint8(43), + 1294: uint8(43), + 1295: uint8(43), + 1296: uint8(43), + 1297: uint8(43), + 1298: uint8(43), + 1299: uint8(43), + 1300: uint8(43), + 1301: uint8(43), + 1302: uint8(43), + 1303: uint8(43), + 1304: uint8(43), + 1305: uint8(43), + 1306: uint8(43), + 1307: uint8(43), + 1308: uint8(43), + 1309: uint8(43), + 1310: uint8(43), + 1311: uint8(43), + 1312: uint8(43), + 1313: uint8(43), + 1314: uint8(43), + 1315: uint8(43), + 1316: uint8(43), + 1317: uint8(43), + 1318: uint8(43), + 1319: uint8(43), + 1320: uint8(43), + 1321: uint8(43), + 1322: uint8(43), + 1323: uint8(43), + 1324: uint8(43), + 1325: uint8(43), + 1326: uint8(43), + 1327: uint8(43), + 1328: uint8(43), + 1329: uint8(43), + 1330: uint8(43), + 1331: uint8(43), + 1332: uint8(7), + 1333: uint8(108), + 1334: uint8(3), + 1335: uint8(65), + 1336: uint8(43), + 1337: uint8(43), + 1338: uint8(86), + 1339: uint8(86), + 1340: uint8(86), + 1341: uint8(86), + 1342: uint8(86), + 1343: uint8(86), + 1344: uint8(86), + 1345: uint8(86), + 1346: uint8(86), + 1347: uint8(86), + 1348: uint8(86), + 1349: uint8(86), + 1350: uint8(86), + 1351: uint8(86), + 1352: uint8(44), + 1353: uint8(86), + 1354: uint8(43), + 1355: uint8(43), + 1356: uint8(43), + 1357: uint8(43), + 1358: uint8(43), + 1359: uint8(43), + 1360: uint8(43), + 1361: uint8(43), + 1362: uint8(43), + 1363: uint8(43), + 1364: uint8(43), + 1365: uint8(43), + 1366: uint8(43), + 1367: uint8(43), + 1368: uint8(43), + 1369: uint8(43), + 1370: uint8(43), + 1371: uint8(43), + 1372: uint8(43), + 1373: uint8(43), + 1374: uint8(43), + 1375: uint8(1), + 1416: uint8(12), + 1417: uint8(108), + 1423: uint8(6), + 1462: uint8(6), + 1463: uint8(37), + 1464: uint8(6), + 1465: uint8(37), + 1466: uint8(6), + 1467: uint8(37), + 1468: uint8(6), + 1469: uint8(37), + 1470: uint8(6), + 1471: uint8(37), + 1472: uint8(6), + 1473: uint8(37), + 1474: uint8(6), + 1475: uint8(37), + 1476: uint8(6), + 1477: uint8(37), + 1478: uint8(6), + 1479: uint8(37), + 1480: uint8(6), + 1481: uint8(37), + 1482: uint8(6), + 1483: uint8(37), + 1484: uint8(6), + 1485: uint8(37), + 1486: uint8(6), + 1487: uint8(37), + 1488: uint8(6), + 1489: uint8(37), + 1490: uint8(6), + 1491: uint8(37), + 1492: uint8(6), + 1493: uint8(37), + 1494: uint8(6), + 1495: uint8(37), + 1496: uint8(6), + 1497: uint8(37), + 1498: uint8(6), + 1499: uint8(37), + 1500: uint8(6), + 1501: uint8(37), + 1502: uint8(6), + 1503: uint8(37), + 1504: uint8(6), + 1505: uint8(37), + 1506: uint8(6), + 1507: uint8(37), + 1508: uint8(6), + 1509: uint8(37), + 1510: uint8(6), + 1511: uint8(37), + 1512: uint8(86), + 1513: uint8(122), + 1514: uint8(158), + 1515: uint8(38), + 1516: uint8(6), + 1517: uint8(37), + 1518: uint8(6), + 1519: uint8(37), + 1520: uint8(6), + 1521: uint8(37), + 1522: uint8(6), + 1523: uint8(37), + 1524: uint8(6), + 1525: uint8(37), + 1526: uint8(6), + 1527: uint8(37), + 1528: uint8(6), + 1529: uint8(37), + 1530: uint8(6), + 1531: uint8(37), + 1532: uint8(6), + 1533: uint8(37), + 1534: uint8(6), + 1535: uint8(37), + 1536: uint8(6), + 1537: uint8(37), + 1538: uint8(6), + 1539: uint8(37), + 1540: uint8(6), + 1541: uint8(37), + 1542: uint8(6), + 1543: uint8(37), + 1544: uint8(6), + 1545: uint8(37), + 1546: uint8(6), + 1547: uint8(1), + 1548: uint8(43), + 1549: uint8(43), + 1550: uint8(79), + 1551: uint8(86), + 1552: uint8(86), + 1553: uint8(44), + 1554: uint8(43), + 1555: uint8(127), + 1556: uint8(86), + 1557: uint8(86), + 1558: uint8(57), + 1559: uint8(43), + 1560: uint8(43), + 1561: uint8(85), + 1562: uint8(86), + 1563: uint8(86), + 1564: uint8(43), + 1565: uint8(43), + 1566: uint8(79), + 1567: uint8(86), + 1568: uint8(86), + 1569: uint8(44), + 1570: uint8(43), + 1571: uint8(127), + 1572: uint8(86), + 1573: uint8(86), + 1574: uint8(129), + 1575: uint8(55), + 1576: uint8(117), + 1577: uint8(91), + 1578: uint8(123), + 1579: uint8(92), + 1580: uint8(43), + 1581: uint8(43), + 1582: uint8(79), + 1583: uint8(86), + 1584: uint8(86), + 1585: uint8(2), + 1586: uint8(172), + 1587: uint8(4), + 1590: uint8(57), + 1591: uint8(43), + 1592: uint8(43), + 1593: uint8(85), + 1594: uint8(86), + 1595: uint8(86), + 1596: uint8(43), + 1597: uint8(43), + 1598: uint8(79), + 1599: uint8(86), + 1600: uint8(86), + 1601: uint8(44), + 1602: uint8(43), + 1603: uint8(43), + 1604: uint8(86), + 1605: uint8(86), + 1606: uint8(50), + 1607: uint8(19), + 1608: uint8(129), + 1609: uint8(87), + 1611: uint8(111), + 1612: uint8(129), + 1613: uint8(126), + 1614: uint8(201), + 1615: uint8(215), + 1616: uint8(126), + 1617: uint8(45), + 1618: uint8(129), + 1619: uint8(129), + 1620: uint8(14), + 1621: uint8(126), + 1622: uint8(57), + 1623: uint8(127), + 1624: uint8(111), + 1625: uint8(87), + 1627: uint8(129), + 1628: uint8(129), + 1629: uint8(126), + 1630: uint8(21), + 1632: uint8(126), + 1633: uint8(3), + 1634: uint8(43), + 1635: uint8(43), + 1636: uint8(43), + 1637: uint8(43), + 1638: uint8(43), + 1639: uint8(43), + 1640: uint8(43), + 1641: uint8(43), + 1642: uint8(43), + 1643: uint8(43), + 1644: uint8(43), + 1645: uint8(43), + 1646: uint8(7), + 1647: uint8(43), + 1648: uint8(36), + 1649: uint8(43), + 1650: uint8(151), + 1651: uint8(43), + 1652: uint8(43), + 1653: uint8(43), + 1654: uint8(43), + 1655: uint8(43), + 1656: uint8(43), + 1657: uint8(43), + 1658: uint8(43), + 1659: uint8(43), + 1660: uint8(42), + 1661: uint8(43), + 1662: uint8(43), + 1663: uint8(43), + 1664: uint8(43), + 1665: uint8(43), + 1666: uint8(86), + 1667: uint8(86), + 1668: uint8(86), + 1669: uint8(86), + 1670: uint8(86), + 1671: uint8(128), + 1672: uint8(129), + 1673: uint8(129), + 1674: uint8(129), + 1675: uint8(129), + 1676: uint8(57), + 1677: uint8(187), + 1678: uint8(42), + 1679: uint8(43), + 1680: uint8(43), + 1681: uint8(43), + 1682: uint8(43), + 1683: uint8(43), + 1684: uint8(43), + 1685: uint8(43), + 1686: uint8(43), + 1687: uint8(43), + 1688: uint8(43), + 1689: uint8(43), + 1690: uint8(43), + 1691: uint8(43), + 1692: uint8(43), + 1693: uint8(43), + 1694: uint8(43), + 1695: uint8(43), + 1696: uint8(43), + 1697: uint8(43), + 1698: uint8(43), + 1699: uint8(43), + 1700: uint8(43), + 1701: uint8(43), + 1702: uint8(43), + 1703: uint8(43), + 1704: uint8(43), + 1705: uint8(43), + 1706: uint8(43), + 1707: uint8(43), + 1708: uint8(43), + 1709: uint8(43), + 1710: uint8(43), + 1711: uint8(43), + 1712: uint8(43), + 1713: uint8(43), + 1714: uint8(43), + 1715: uint8(43), + 1716: uint8(43), + 1717: uint8(43), + 1718: uint8(43), + 1719: uint8(1), + 1720: uint8(129), + 1721: uint8(129), + 1722: uint8(129), + 1723: uint8(129), + 1724: uint8(129), + 1725: uint8(129), + 1726: uint8(129), + 1727: uint8(129), + 1728: uint8(129), + 1729: uint8(129), + 1730: uint8(129), + 1731: uint8(129), + 1732: uint8(129), + 1733: uint8(129), + 1734: uint8(129), + 1735: uint8(201), + 1736: uint8(172), + 1737: uint8(172), + 1738: uint8(172), + 1739: uint8(172), + 1740: uint8(172), + 1741: uint8(172), + 1742: uint8(172), + 1743: uint8(172), + 1744: uint8(172), + 1745: uint8(172), + 1746: uint8(172), + 1747: uint8(172), + 1748: uint8(172), + 1749: uint8(172), + 1750: uint8(172), + 1751: uint8(208), + 1752: uint8(13), + 1754: uint8(78), + 1755: uint8(49), + 1756: uint8(2), + 1757: uint8(180), + 1758: uint8(193), + 1759: uint8(193), + 1760: uint8(215), + 1761: uint8(215), + 1762: uint8(36), + 1763: uint8(80), + 1764: uint8(49), + 1765: uint8(80), + 1766: uint8(49), + 1767: uint8(80), + 1768: uint8(49), + 1769: uint8(80), + 1770: uint8(49), + 1771: uint8(80), + 1772: uint8(49), + 1773: uint8(80), + 1774: uint8(49), + 1775: uint8(80), + 1776: uint8(49), + 1777: uint8(80), + 1778: uint8(49), + 1779: uint8(80), + 1780: uint8(49), + 1781: uint8(80), + 1782: uint8(49), + 1783: uint8(80), + 1784: uint8(49), + 1785: uint8(80), + 1786: uint8(49), + 1787: uint8(80), + 1788: uint8(49), + 1789: uint8(80), + 1790: uint8(49), + 1791: uint8(80), + 1792: uint8(49), + 1793: uint8(80), + 1794: uint8(49), + 1795: uint8(80), + 1796: uint8(215), + 1797: uint8(215), + 1798: uint8(83), + 1799: uint8(193), + 1800: uint8(71), + 1801: uint8(212), + 1802: uint8(215), + 1803: uint8(215), + 1804: uint8(215), + 1805: uint8(5), + 1806: uint8(43), + 1807: uint8(43), + 1808: uint8(43), + 1809: uint8(43), + 1810: uint8(43), + 1811: uint8(43), + 1812: uint8(43), + 1813: uint8(43), + 1814: uint8(43), + 1815: uint8(43), + 1816: uint8(43), + 1817: uint8(43), + 1818: uint8(7), + 1819: uint8(1), + 1821: uint8(1), + 1913: uint8(78), + 1914: uint8(49), + 1915: uint8(80), + 1916: uint8(49), + 1917: uint8(80), + 1918: uint8(49), + 1919: uint8(80), + 1920: uint8(49), + 1921: uint8(80), + 1922: uint8(49), + 1923: uint8(80), + 1924: uint8(49), + 1925: uint8(80), + 1926: uint8(49), + 1927: uint8(80), + 1928: uint8(13), + 1934: uint8(36), + 1935: uint8(80), + 1936: uint8(49), + 1937: uint8(80), + 1938: uint8(49), + 1939: uint8(80), + 1940: uint8(49), + 1941: uint8(80), + 1942: uint8(49), + 1943: uint8(80), + 1978: uint8(43), + 1979: uint8(43), + 1980: uint8(43), + 1981: uint8(43), + 1982: uint8(43), + 1983: uint8(43), + 1984: uint8(43), + 1985: uint8(43), + 1986: uint8(43), + 1987: uint8(43), + 1988: uint8(43), + 1989: uint8(121), + 1990: uint8(92), + 1991: uint8(123), + 1992: uint8(92), + 1993: uint8(123), + 1994: uint8(79), + 1995: uint8(123), + 1996: uint8(92), + 1997: uint8(123), + 1998: uint8(92), + 1999: uint8(123), + 2000: uint8(92), + 2001: uint8(123), + 2002: uint8(92), + 2003: uint8(123), + 2004: uint8(92), + 2005: uint8(123), + 2006: uint8(92), + 2007: uint8(123), + 2008: uint8(92), + 2009: uint8(123), + 2010: uint8(92), + 2011: uint8(123), + 2012: uint8(92), + 2013: uint8(123), + 2014: uint8(92), + 2015: uint8(45), + 2016: uint8(43), + 2017: uint8(43), + 2018: uint8(121), + 2019: uint8(20), + 2020: uint8(92), + 2021: uint8(123), + 2022: uint8(92), + 2023: uint8(45), + 2024: uint8(121), + 2025: uint8(42), + 2026: uint8(92), + 2027: uint8(39), + 2028: uint8(92), + 2029: uint8(123), + 2030: uint8(92), + 2031: uint8(123), + 2032: uint8(92), + 2033: uint8(123), + 2034: uint8(164), + 2036: uint8(10), + 2037: uint8(180), + 2038: uint8(92), + 2039: uint8(123), + 2040: uint8(92), + 2041: uint8(123), + 2042: uint8(79), + 2043: uint8(3), + 2044: uint8(42), + 2045: uint8(43), + 2046: uint8(43), + 2047: uint8(43), + 2048: uint8(43), + 2049: uint8(43), + 2050: uint8(43), + 2051: uint8(43), + 2052: uint8(43), + 2053: uint8(43), + 2054: uint8(43), + 2055: uint8(43), + 2056: uint8(43), + 2057: uint8(43), + 2058: uint8(43), + 2059: uint8(43), + 2060: uint8(43), + 2061: uint8(43), + 2062: uint8(43), + 2063: uint8(1), + 2091: uint8(72), + 2101: uint8(42), + 2102: uint8(43), + 2103: uint8(43), + 2104: uint8(43), + 2105: uint8(43), + 2106: uint8(43), + 2107: uint8(43), + 2108: uint8(43), + 2109: uint8(43), + 2110: uint8(43), + 2111: uint8(43), + 2112: uint8(43), + 2113: uint8(43), + 2114: uint8(43), + 2115: uint8(43), + 2116: uint8(43), + 2117: uint8(43), + 2118: uint8(43), + 2119: uint8(43), + 2120: uint8(43), + 2121: uint8(43), + 2122: uint8(43), + 2123: uint8(43), + 2124: uint8(43), + 2125: uint8(43), + 2126: uint8(43), + 2127: uint8(43), + 2161: uint8(43), + 2162: uint8(43), + 2163: uint8(43), + 2164: uint8(43), + 2165: uint8(43), + 2166: uint8(43), + 2167: uint8(43), + 2168: uint8(43), + 2169: uint8(7), + 2171: uint8(72), + 2172: uint8(86), + 2173: uint8(86), + 2174: uint8(86), + 2175: uint8(86), + 2176: uint8(86), + 2177: uint8(86), + 2178: uint8(86), + 2179: uint8(86), + 2180: uint8(2), + 2236: uint8(43), + 2237: uint8(43), + 2238: uint8(43), + 2239: uint8(43), + 2240: uint8(43), + 2241: uint8(43), + 2242: uint8(43), + 2243: uint8(43), + 2244: uint8(43), + 2245: uint8(43), + 2246: uint8(43), + 2247: uint8(43), + 2248: uint8(43), + 2249: uint8(85), + 2250: uint8(86), + 2251: uint8(86), + 2252: uint8(86), + 2253: uint8(86), + 2254: uint8(86), + 2255: uint8(86), + 2256: uint8(86), + 2257: uint8(86), + 2258: uint8(86), + 2259: uint8(86), + 2260: uint8(86), + 2261: uint8(86), + 2262: uint8(14), + 2294: uint8(36), + 2295: uint8(43), + 2296: uint8(43), + 2297: uint8(43), + 2298: uint8(43), + 2299: uint8(43), + 2300: uint8(43), + 2301: uint8(43), + 2302: uint8(43), + 2303: uint8(43), + 2304: uint8(43), + 2305: uint8(43), + 2306: uint8(7), + 2308: uint8(86), + 2309: uint8(86), + 2310: uint8(86), + 2311: uint8(86), + 2312: uint8(86), + 2313: uint8(86), + 2314: uint8(86), + 2315: uint8(86), + 2316: uint8(86), + 2317: uint8(86), + 2318: uint8(86), + 2319: uint8(86), + 2364: uint8(36), + 2365: uint8(43), + 2366: uint8(43), + 2367: uint8(43), + 2368: uint8(43), + 2369: uint8(43), + 2370: uint8(43), + 2371: uint8(43), + 2372: uint8(43), + 2373: uint8(43), + 2374: uint8(43), + 2375: uint8(43), + 2376: uint8(43), + 2377: uint8(43), + 2378: uint8(43), + 2379: uint8(43), + 2380: uint8(43), + 2381: uint8(7), + 2386: uint8(86), + 2387: uint8(86), + 2388: uint8(86), + 2389: uint8(86), + 2390: uint8(86), + 2391: uint8(86), + 2392: uint8(86), + 2393: uint8(86), + 2394: uint8(86), + 2395: uint8(86), + 2396: uint8(86), + 2397: uint8(86), + 2398: uint8(86), + 2399: uint8(86), + 2400: uint8(86), + 2401: uint8(86), + 2402: uint8(86), + 2461: uint8(42), + 2462: uint8(43), + 2463: uint8(43), + 2464: uint8(43), + 2465: uint8(43), + 2466: uint8(43), + 2467: uint8(43), + 2468: uint8(43), + 2469: uint8(43), + 2470: uint8(43), + 2471: uint8(43), + 2472: uint8(86), + 2473: uint8(86), + 2474: uint8(86), + 2475: uint8(86), + 2476: uint8(86), + 2477: uint8(86), + 2478: uint8(86), + 2479: uint8(86), + 2480: uint8(86), + 2481: uint8(86), + 2482: uint8(14), + 2515: uint8(42), + 2516: uint8(43), + 2517: uint8(43), + 2518: uint8(43), + 2519: uint8(43), + 2520: uint8(43), + 2521: uint8(43), + 2522: uint8(43), + 2523: uint8(43), + 2524: uint8(43), + 2525: uint8(43), + 2526: uint8(86), + 2527: uint8(86), + 2528: uint8(86), + 2529: uint8(86), + 2530: uint8(86), + 2531: uint8(86), + 2532: uint8(86), + 2533: uint8(86), + 2534: uint8(86), + 2535: uint8(86), + 2536: uint8(14), + 2580: uint8(43), + 2581: uint8(43), + 2582: uint8(43), + 2583: uint8(43), + 2584: uint8(43), + 2585: uint8(43), + 2586: uint8(43), + 2587: uint8(43), + 2588: uint8(43), + 2589: uint8(43), + 2590: uint8(43), + 2591: uint8(85), + 2592: uint8(86), + 2593: uint8(86), + 2594: uint8(86), + 2595: uint8(86), + 2596: uint8(86), + 2597: uint8(86), + 2598: uint8(86), + 2599: uint8(86), + 2600: uint8(86), + 2601: uint8(86), + 2602: uint8(14), +} +var _rules = [240]int32{ + 1: int32(0x2001), + 2: -int32(0x2000), + 3: int32(0x1dbf00), + 4: int32(0x2e700), + 5: int32(0x7900), + 6: int32(0x2402), + 7: int32(0x101), + 8: -int32(0x100), + 10: int32(0x201), + 11: -int32(0x200), + 12: -int32(0xc6ff), + 13: -int32(0xe800), + 14: -int32(0x78ff), + 15: -int32(0x12c00), + 16: int32(0xc300), + 17: int32(0xd201), + 18: int32(0xce01), + 19: int32(0xcd01), + 20: int32(0x4f01), + 21: int32(0xca01), + 22: int32(0xcb01), + 23: int32(0xcf01), + 24: int32(0x6100), + 25: int32(0xd301), + 26: int32(0xd101), + 27: int32(0xa300), + 28: int32(0xd501), + 29: int32(0x8200), + 30: int32(0xd601), + 31: int32(0xda01), + 32: int32(0xd901), + 33: int32(0xdb01), + 34: int32(0x3800), + 35: int32(0x3), + 36: -int32(0x4f00), + 37: -int32(0x60ff), + 38: -int32(0x37ff), + 39: int32(0x242802), + 41: int32(0x101), + 42: -int32(0x100), + 43: -int32(0xcd00), + 44: -int32(0xda00), + 45: -int32(0x81ff), + 46: int32(0x2a2b01), + 47: -int32(0xa2ff), + 48: int32(0x2a2801), + 49: int32(0x2a3f00), + 50: -int32(0xc2ff), + 51: int32(0x4501), + 52: int32(0x4701), + 53: int32(0x2a1f00), + 54: int32(0x2a1c00), + 55: int32(0x2a1e00), + 56: -int32(0xd200), + 57: -int32(0xce00), + 58: -int32(0xca00), + 59: -int32(0xcb00), + 60: int32(0xa54f00), + 61: int32(0xa54b00), + 62: -int32(0xcf00), + 63: int32(0xa52800), + 64: int32(0xa54400), + 65: -int32(0xd100), + 66: -int32(0xd300), + 67: int32(0x29f700), + 68: int32(0xa54100), + 69: int32(0x29fd00), + 70: -int32(0xd500), + 71: -int32(0xd600), + 72: int32(0x29e700), + 73: int32(0xa54300), + 74: int32(0xa52a00), + 75: -int32(0x4500), + 76: -int32(0xd900), + 77: -int32(0x4700), + 78: -int32(0xdb00), + 79: int32(0xa51500), + 80: int32(0xa51200), + 81: int32(0x4c2402), + 83: int32(0x2001), + 84: -int32(0x2000), + 85: int32(0x101), + 86: -int32(0x100), + 87: int32(0x5400), + 88: int32(0x7401), + 89: int32(0x2601), + 90: int32(0x2501), + 91: int32(0x4001), + 92: int32(0x3f01), + 93: -int32(0x2600), + 94: -int32(0x2500), + 95: -int32(0x1f00), + 96: -int32(0x4000), + 97: -int32(0x3f00), + 98: int32(0x801), + 99: -int32(0x3e00), + 100: -int32(0x3900), + 101: -int32(0x2f00), + 102: -int32(0x3600), + 103: -int32(0x800), + 104: -int32(0x5600), + 105: -int32(0x5000), + 106: int32(0x700), + 107: -int32(0x7400), + 108: -int32(0x3bff), + 109: -int32(0x6000), + 110: -int32(0x6ff), + 111: int32(0x701a02), + 112: int32(0x101), + 113: -int32(0x100), + 114: int32(0x2001), + 115: -int32(0x2000), + 116: int32(0x5001), + 117: int32(0xf01), + 118: -int32(0xf00), + 120: int32(0x3001), + 121: -int32(0x3000), + 122: int32(0x101), + 123: -int32(0x100), + 125: int32(0xbc000), + 126: int32(0x1c6001), + 128: int32(0x97d001), + 129: int32(0x801), + 130: -int32(0x800), + 131: int32(0x8a0502), + 133: -int32(0xbbfff), + 134: -int32(0x186200), + 135: int32(0x89c200), + 136: -int32(0x182500), + 137: -int32(0x186e00), + 138: -int32(0x186d00), + 139: -int32(0x186400), + 140: -int32(0x186300), + 141: -int32(0x185c00), + 143: int32(0x8a3800), + 144: int32(0x8a0400), + 145: int32(0xee600), + 146: int32(0x101), + 147: -int32(0x100), + 149: -int32(0x3b00), + 150: -int32(0x1dbeff), + 151: int32(0x8f1d02), + 152: int32(0x800), + 153: -int32(0x7ff), + 155: int32(0x5600), + 156: -int32(0x55ff), + 157: int32(0x4a00), + 158: int32(0x6400), + 159: int32(0x8000), + 160: int32(0x7000), + 161: int32(0x7e00), + 162: int32(0x900), + 163: -int32(0x49ff), + 164: -int32(0x8ff), + 165: -int32(0x1c2500), + 166: -int32(0x63ff), + 167: -int32(0x6fff), + 168: -int32(0x7fff), + 169: -int32(0x7dff), + 170: int32(0xac0502), + 172: int32(0x1001), + 173: -int32(0x1000), + 174: int32(0x1c01), + 175: int32(0x101), + 176: -int32(0x1d5cff), + 177: -int32(0x20beff), + 178: -int32(0x2045ff), + 179: -int32(0x1c00), + 180: int32(0xb10b02), + 181: int32(0x101), + 182: -int32(0x100), + 183: int32(0x3001), + 184: -int32(0x3000), + 186: -int32(0x29f6ff), + 187: -int32(0xee5ff), + 188: -int32(0x29e6ff), + 189: -int32(0x2a2b00), + 190: -int32(0x2a2800), + 191: -int32(0x2a1bff), + 192: -int32(0x29fcff), + 193: -int32(0x2a1eff), + 194: -int32(0x2a1dff), + 195: -int32(0x2a3eff), + 197: -int32(0x1c6000), + 199: int32(0x101), + 200: -int32(0x100), + 201: int32(0xbc0c02), + 203: int32(0x101), + 204: -int32(0x100), + 205: -int32(0xa543ff), + 206: int32(0x3a001), + 207: -int32(0x8a03ff), + 208: -int32(0xa527ff), + 209: int32(0x3000), + 210: -int32(0xa54eff), + 211: -int32(0xa54aff), + 212: -int32(0xa540ff), + 213: -int32(0xa511ff), + 214: -int32(0xa529ff), + 215: -int32(0xa514ff), + 216: -int32(0x2fff), + 217: -int32(0xa542ff), + 218: -int32(0x8a37ff), + 220: -int32(0x97d000), + 221: -int32(0x3a000), + 223: int32(0x2001), + 224: -int32(0x2000), + 226: int32(0x2801), + 227: -int32(0x2800), + 229: int32(0x4001), + 230: -int32(0x4000), + 232: int32(0x2001), + 233: -int32(0x2000), + 235: int32(0x2001), + 236: -int32(0x2000), + 238: int32(0x2201), + 239: -int32(0x2200), +} +var _rulebases = [512]uint8{ + 1: uint8(6), + 2: uint8(39), + 3: uint8(81), + 4: uint8(111), + 5: uint8(119), + 16: uint8(124), + 19: uint8(127), + 28: uint8(131), + 29: uint8(142), + 30: uint8(146), + 31: uint8(151), + 33: uint8(170), + 44: uint8(180), + 45: uint8(196), + 166: uint8(198), + 167: uint8(201), + 171: uint8(219), + 255: uint8(222), + 260: uint8(225), + 268: uint8(228), + 280: uint8(231), + 366: uint8(234), + 489: uint8(237), +} +var _exceptions = [200][2]uint8{ + 0: { + 0: uint8(48), + 1: uint8(12), + }, + 1: { + 0: uint8(49), + 1: uint8(13), + }, + 2: { + 0: uint8(120), + 1: uint8(14), + }, + 3: { + 0: uint8(127), + 1: uint8(15), + }, + 4: { + 0: uint8(128), + 1: uint8(16), + }, + 5: { + 0: uint8(129), + 1: uint8(17), + }, + 6: { + 0: uint8(134), + 1: uint8(18), + }, + 7: { + 0: uint8(137), + 1: uint8(19), + }, + 8: { + 0: uint8(138), + 1: uint8(19), + }, + 9: { + 0: uint8(142), + 1: uint8(20), + }, + 10: { + 0: uint8(143), + 1: uint8(21), + }, + 11: { + 0: uint8(144), + 1: uint8(22), + }, + 12: { + 0: uint8(147), + 1: uint8(19), + }, + 13: { + 0: uint8(148), + 1: uint8(23), + }, + 14: { + 0: uint8(149), + 1: uint8(24), + }, + 15: { + 0: uint8(150), + 1: uint8(25), + }, + 16: { + 0: uint8(151), + 1: uint8(26), + }, + 17: { + 0: uint8(154), + 1: uint8(27), + }, + 18: { + 0: uint8(156), + 1: uint8(25), + }, + 19: { + 0: uint8(157), + 1: uint8(28), + }, + 20: { + 0: uint8(158), + 1: uint8(29), + }, + 21: { + 0: uint8(159), + 1: uint8(30), + }, + 22: { + 0: uint8(166), + 1: uint8(31), + }, + 23: { + 0: uint8(169), + 1: uint8(31), + }, + 24: { + 0: uint8(174), + 1: uint8(31), + }, + 25: { + 0: uint8(177), + 1: uint8(32), + }, + 26: { + 0: uint8(178), + 1: uint8(32), + }, + 27: { + 0: uint8(183), + 1: uint8(33), + }, + 28: { + 0: uint8(191), + 1: uint8(34), + }, + 29: { + 0: uint8(197), + 1: uint8(35), + }, + 30: { + 0: uint8(200), + 1: uint8(35), + }, + 31: { + 0: uint8(203), + 1: uint8(35), + }, + 32: { + 0: uint8(221), + 1: uint8(36), + }, + 33: { + 0: uint8(242), + 1: uint8(35), + }, + 34: { + 0: uint8(246), + 1: uint8(37), + }, + 35: { + 0: uint8(247), + 1: uint8(38), + }, + 36: { + 0: uint8(32), + 1: uint8(45), + }, + 37: { + 0: uint8(58), + 1: uint8(46), + }, + 38: { + 0: uint8(61), + 1: uint8(47), + }, + 39: { + 0: uint8(62), + 1: uint8(48), + }, + 40: { + 0: uint8(63), + 1: uint8(49), + }, + 41: { + 0: uint8(64), + 1: uint8(49), + }, + 42: { + 0: uint8(67), + 1: uint8(50), + }, + 43: { + 0: uint8(68), + 1: uint8(51), + }, + 44: { + 0: uint8(69), + 1: uint8(52), + }, + 45: { + 0: uint8(80), + 1: uint8(53), + }, + 46: { + 0: uint8(81), + 1: uint8(54), + }, + 47: { + 0: uint8(82), + 1: uint8(55), + }, + 48: { + 0: uint8(83), + 1: uint8(56), + }, + 49: { + 0: uint8(84), + 1: uint8(57), + }, + 50: { + 0: uint8(89), + 1: uint8(58), + }, + 51: { + 0: uint8(91), + 1: uint8(59), + }, + 52: { + 0: uint8(92), + 1: uint8(60), + }, + 53: { + 0: uint8(97), + 1: uint8(61), + }, + 54: { + 0: uint8(99), + 1: uint8(62), + }, + 55: { + 0: uint8(101), + 1: uint8(63), + }, + 56: { + 0: uint8(102), + 1: uint8(64), + }, + 57: { + 0: uint8(104), + 1: uint8(65), + }, + 58: { + 0: uint8(105), + 1: uint8(66), + }, + 59: { + 0: uint8(106), + 1: uint8(64), + }, + 60: { + 0: uint8(107), + 1: uint8(67), + }, + 61: { + 0: uint8(108), + 1: uint8(68), + }, + 62: { + 0: uint8(111), + 1: uint8(66), + }, + 63: { + 0: uint8(113), + 1: uint8(69), + }, + 64: { + 0: uint8(114), + 1: uint8(70), + }, + 65: { + 0: uint8(117), + 1: uint8(71), + }, + 66: { + 0: uint8(125), + 1: uint8(72), + }, + 67: { + 0: uint8(130), + 1: uint8(73), + }, + 68: { + 0: uint8(135), + 1: uint8(74), + }, + 69: { + 0: uint8(137), + 1: uint8(75), + }, + 70: { + 0: uint8(138), + 1: uint8(76), + }, + 71: { + 0: uint8(139), + 1: uint8(76), + }, + 72: { + 0: uint8(140), + 1: uint8(77), + }, + 73: { + 0: uint8(146), + 1: uint8(78), + }, + 74: { + 0: uint8(157), + 1: uint8(79), + }, + 75: { + 0: uint8(158), + 1: uint8(80), + }, + 76: { + 0: uint8(69), + 1: uint8(87), + }, + 77: { + 0: uint8(123), + 1: uint8(29), + }, + 78: { + 0: uint8(124), + 1: uint8(29), + }, + 79: { + 0: uint8(125), + 1: uint8(29), + }, + 80: { + 0: uint8(127), + 1: uint8(88), + }, + 81: { + 0: uint8(134), + 1: uint8(89), + }, + 82: { + 0: uint8(136), + 1: uint8(90), + }, + 83: { + 0: uint8(137), + 1: uint8(90), + }, + 84: { + 0: uint8(138), + 1: uint8(90), + }, + 85: { + 0: uint8(140), + 1: uint8(91), + }, + 86: { + 0: uint8(142), + 1: uint8(92), + }, + 87: { + 0: uint8(143), + 1: uint8(92), + }, + 88: { + 0: uint8(172), + 1: uint8(93), + }, + 89: { + 0: uint8(173), + 1: uint8(94), + }, + 90: { + 0: uint8(174), + 1: uint8(94), + }, + 91: { + 0: uint8(175), + 1: uint8(94), + }, + 92: { + 0: uint8(194), + 1: uint8(95), + }, + 93: { + 0: uint8(204), + 1: uint8(96), + }, + 94: { + 0: uint8(205), + 1: uint8(97), + }, + 95: { + 0: uint8(206), + 1: uint8(97), + }, + 96: { + 0: uint8(207), + 1: uint8(98), + }, + 97: { + 0: uint8(208), + 1: uint8(99), + }, + 98: { + 0: uint8(209), + 1: uint8(100), + }, + 99: { + 0: uint8(213), + 1: uint8(101), + }, + 100: { + 0: uint8(214), + 1: uint8(102), + }, + 101: { + 0: uint8(215), + 1: uint8(103), + }, + 102: { + 0: uint8(240), + 1: uint8(104), + }, + 103: { + 0: uint8(241), + 1: uint8(105), + }, + 104: { + 0: uint8(242), + 1: uint8(106), + }, + 105: { + 0: uint8(243), + 1: uint8(107), + }, + 106: { + 0: uint8(244), + 1: uint8(108), + }, + 107: { + 0: uint8(245), + 1: uint8(109), + }, + 108: { + 0: uint8(249), + 1: uint8(110), + }, + 109: { + 0: uint8(253), + 1: uint8(45), + }, + 110: { + 0: uint8(254), + 1: uint8(45), + }, + 111: { + 0: uint8(255), + 1: uint8(45), + }, + 112: { + 0: uint8(80), + 1: uint8(105), + }, + 113: { + 0: uint8(81), + 1: uint8(105), + }, + 114: { + 0: uint8(82), + 1: uint8(105), + }, + 115: { + 0: uint8(83), + 1: uint8(105), + }, + 116: { + 0: uint8(84), + 1: uint8(105), + }, + 117: { + 0: uint8(85), + 1: uint8(105), + }, + 118: { + 0: uint8(86), + 1: uint8(105), + }, + 119: { + 0: uint8(87), + 1: uint8(105), + }, + 120: { + 0: uint8(88), + 1: uint8(105), + }, + 121: { + 0: uint8(89), + 1: uint8(105), + }, + 122: { + 0: uint8(90), + 1: uint8(105), + }, + 123: { + 0: uint8(91), + 1: uint8(105), + }, + 124: { + 0: uint8(92), + 1: uint8(105), + }, + 125: { + 0: uint8(93), + 1: uint8(105), + }, + 126: { + 0: uint8(94), + 1: uint8(105), + }, + 127: { + 0: uint8(95), + 1: uint8(105), + }, + 128: { + 0: uint8(130), + }, + 129: { + 0: uint8(131), + }, + 130: { + 0: uint8(132), + }, + 131: { + 0: uint8(133), + }, + 132: { + 0: uint8(134), + }, + 133: { + 0: uint8(135), + }, + 134: { + 0: uint8(136), + }, + 135: { + 0: uint8(137), + }, + 136: { + 0: uint8(192), + 1: uint8(117), + }, + 137: { + 0: uint8(207), + 1: uint8(118), + }, + 138: { + 0: uint8(128), + 1: uint8(137), + }, + 139: { + 0: uint8(129), + 1: uint8(138), + }, + 140: { + 0: uint8(130), + 1: uint8(139), + }, + 141: { + 0: uint8(133), + 1: uint8(140), + }, + 142: { + 0: uint8(134), + 1: uint8(141), + }, + 143: { + 0: uint8(112), + 1: uint8(157), + }, + 144: { + 0: uint8(113), + 1: uint8(157), + }, + 145: { + 0: uint8(118), + 1: uint8(158), + }, + 146: { + 0: uint8(119), + 1: uint8(158), + }, + 147: { + 0: uint8(120), + 1: uint8(159), + }, + 148: { + 0: uint8(121), + 1: uint8(159), + }, + 149: { + 0: uint8(122), + 1: uint8(160), + }, + 150: { + 0: uint8(123), + 1: uint8(160), + }, + 151: { + 0: uint8(124), + 1: uint8(161), + }, + 152: { + 0: uint8(125), + 1: uint8(161), + }, + 153: { + 0: uint8(179), + 1: uint8(162), + }, + 154: { + 0: uint8(186), + 1: uint8(163), + }, + 155: { + 0: uint8(187), + 1: uint8(163), + }, + 156: { + 0: uint8(188), + 1: uint8(164), + }, + 157: { + 0: uint8(190), + 1: uint8(165), + }, + 158: { + 0: uint8(195), + 1: uint8(162), + }, + 159: { + 0: uint8(204), + 1: uint8(164), + }, + 160: { + 0: uint8(218), + 1: uint8(166), + }, + 161: { + 0: uint8(219), + 1: uint8(166), + }, + 162: { + 0: uint8(229), + 1: uint8(106), + }, + 163: { + 0: uint8(234), + 1: uint8(167), + }, + 164: { + 0: uint8(235), + 1: uint8(167), + }, + 165: { + 0: uint8(236), + 1: uint8(110), + }, + 166: { + 0: uint8(243), + 1: uint8(162), + }, + 167: { + 0: uint8(248), + 1: uint8(168), + }, + 168: { + 0: uint8(249), + 1: uint8(168), + }, + 169: { + 0: uint8(250), + 1: uint8(169), + }, + 170: { + 0: uint8(251), + 1: uint8(169), + }, + 171: { + 0: uint8(252), + 1: uint8(164), + }, + 172: { + 0: uint8(38), + 1: uint8(176), + }, + 173: { + 0: uint8(42), + 1: uint8(177), + }, + 174: { + 0: uint8(43), + 1: uint8(178), + }, + 175: { + 0: uint8(78), + 1: uint8(179), + }, + 176: { + 0: uint8(132), + 1: uint8(8), + }, + 177: { + 0: uint8(98), + 1: uint8(186), + }, + 178: { + 0: uint8(99), + 1: uint8(187), + }, + 179: { + 0: uint8(100), + 1: uint8(188), + }, + 180: { + 0: uint8(101), + 1: uint8(189), + }, + 181: { + 0: uint8(102), + 1: uint8(190), + }, + 182: { + 0: uint8(109), + 1: uint8(191), + }, + 183: { + 0: uint8(110), + 1: uint8(192), + }, + 184: { + 0: uint8(111), + 1: uint8(193), + }, + 185: { + 0: uint8(112), + 1: uint8(194), + }, + 186: { + 0: uint8(126), + 1: uint8(195), + }, + 187: { + 0: uint8(127), + 1: uint8(195), + }, + 188: { + 0: uint8(125), + 1: uint8(207), + }, + 189: { + 0: uint8(141), + 1: uint8(208), + }, + 190: { + 0: uint8(148), + 1: uint8(209), + }, + 191: { + 0: uint8(171), + 1: uint8(210), + }, + 192: { + 0: uint8(172), + 1: uint8(211), + }, + 193: { + 0: uint8(173), + 1: uint8(212), + }, + 194: { + 0: uint8(176), + 1: uint8(213), + }, + 195: { + 0: uint8(177), + 1: uint8(214), + }, + 196: { + 0: uint8(178), + 1: uint8(215), + }, + 197: { + 0: uint8(196), + 1: uint8(216), + }, + 198: { + 0: uint8(197), + 1: uint8(217), + }, + 199: { + 0: uint8(198), + 1: uint8(218), + }, +} + +func _casemap(tls *TLS, c uint32, dir int32) (r1 int32) { + var b, rt, try, v, x, xb, xn, y uint32 + var c0, r, rd, v1 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = b, c0, r, rd, rt, try, v, x, xb, xn, y, v1 + c0 = Int32FromUint32(c) + if c >= uint32(0x20000) { + return Int32FromUint32(c) + } + b = c >> int32(8) + c = c & uint32(255) + x = c / uint32(3) + y = c % uint32(3) + /* lookup entry in two-level base-6 table */ + v = uint32(_tab1[Uint32FromInt32(Int32FromUint8(_tab1[b])*int32(86))+x]) + v = v * Uint32FromInt32(_mt[y]) >> int32(11) % uint32(6) + /* use the bit vector out of the tables as an index into + * a block-specific set of rules and decode the rule into + * a type and a case-mapping delta. */ + r = _rules[uint32(_rulebases[b])+v] + rt = Uint32FromInt32(r & int32(255)) + rd = r >> int32(8) + /* rules 0/1 are simple lower/upper case with a delta. + * apply according to desired mapping direction. */ + if rt < uint32(2) { + return Int32FromUint32(Uint32FromInt32(c0) + Uint32FromInt32(rd)&-(rt^Uint32FromInt32(dir))) + } + /* binary search. endpoints of the binary search for + * this block are stored in the rule delta field. */ + xn = Uint32FromInt32(rd & int32(0xff)) + xb = Uint32FromInt32(rd) >> int32(8) + for xn != 0 { + try = uint32(**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_exceptions)) + uintptr(xb+xn/uint32(2))*2))) + if try == c { + r = _rules[**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_exceptions)) + uintptr(xb+xn/uint32(2))*2 + 1))] + rt = Uint32FromInt32(r & int32(255)) + rd = r >> int32(8) + if rt < uint32(2) { + return Int32FromUint32(Uint32FromInt32(c0) + Uint32FromInt32(rd)&-(rt^Uint32FromInt32(dir))) + } + /* Hard-coded for the four exceptional titlecase */ + if dir != 0 { + v1 = -int32(1) + } else { + v1 = int32(1) + } + return c0 + v1 + } else { + if try > c { + xn = xn / uint32(2) + } else { + xb = xb + xn/uint32(2) + xn = xn - xn/uint32(2) + } + } + } + return c0 +} + +var _mt = [3]int32{ + 0: int32(2048), + 1: int32(342), + 2: int32(57), +} + +func Xtowlower(tls *TLS, wc Twint_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt32(_casemap(tls, wc, 0)) +} + +func Xtowupper(tls *TLS, wc Twint_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt32(_casemap(tls, wc, int32(1))) +} + +func X__towupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtowupper(tls, c) +} + +func X__towlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtowlower(tls, c) +} + +func Xtowlower_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__towlower_l(tls, c, l) +} + +func Xtowupper_l(tls *TLS, c Twint_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__towupper_l(tls, c, l) +} + +func Xwcswidth(tls *TLS, wcs uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wcs=%v n=%v, (%v:)", tls, wcs, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k, l, v3 int32 + var v2 Tsize_t + var v4 bool + _, _, _, _, _ = k, l, v2, v3, v4 + l = 0 + k = 0 + for { + v2 = n + n = n - 1 + if v4 = v2 != 0 && **(**Twchar_t)(__ccgo_up(wcs)) != 0; v4 { + v3 = Xwcwidth(tls, **(**Twchar_t)(__ccgo_up(wcs))) + k = v3 + } + if !(v4 && v3 >= 0) { + break + } + goto _1 + _1: + ; + l = l + k + wcs += 4 + } + if k < 0 { + v3 = k + } else { + v3 = l + } + return v3 +} + +func Xwctrans(tls *TLS, class uintptr) (r Twctrans_t) { + if __ccgo_strace { + trc("tls=%v class=%v, (%v:)", tls, class, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(Xstrcmp(tls, class, __ccgo_ts+196) != 0) { + return UintptrFromInt32(1) + } + if !(Xstrcmp(tls, class, __ccgo_ts+204) != 0) { + return UintptrFromInt32(2) + } + return uintptr(0) +} + +func Xtowctrans(tls *TLS, wc Twint_t, trans Twctrans_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v wc=%v trans=%v, (%v:)", tls, wc, trans, origin(2)) + defer func() { trc("-> %v", r) }() + } + if trans == UintptrFromInt32(1) { + return Xtowupper(tls, wc) + } + if trans == UintptrFromInt32(2) { + return Xtowlower(tls, wc) + } + return wc +} + +func X__wctrans_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctrans_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v, (%v:)", tls, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwctrans(tls, s) +} + +func X__towctrans_l(tls *TLS, c Twint_t, t Twctrans_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v t=%v l=%v, (%v:)", tls, c, t, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtowctrans(tls, c, t) +} + +func Xtowctrans_l(tls *TLS, c Twint_t, t Twctrans_t, l Tlocale_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v t=%v l=%v, (%v:)", tls, c, t, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__towctrans_l(tls, c, t, l) +} + +func Xwctrans_l(tls *TLS, s uintptr, l Tlocale_t) (r Twctrans_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v, (%v:)", tls, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wctrans_l(tls, s, l) +} + +var _table5 = [2784]uint8{ + 0: uint8(16), + 1: uint8(16), + 2: uint8(16), + 3: uint8(18), + 4: uint8(19), + 5: uint8(20), + 6: uint8(21), + 7: uint8(22), + 8: uint8(23), + 9: uint8(24), + 10: uint8(25), + 11: uint8(26), + 12: uint8(27), + 13: uint8(28), + 14: uint8(29), + 15: uint8(30), + 16: uint8(31), + 17: uint8(32), + 18: uint8(16), + 19: uint8(33), + 20: uint8(16), + 21: uint8(16), + 22: uint8(16), + 23: uint8(34), + 24: uint8(35), + 25: uint8(36), + 26: uint8(37), + 27: uint8(38), + 28: uint8(39), + 29: uint8(40), + 30: uint8(16), + 31: uint8(16), + 32: uint8(41), + 33: uint8(16), + 34: uint8(16), + 35: uint8(16), + 36: uint8(16), + 37: uint8(16), + 38: uint8(16), + 39: uint8(16), + 40: uint8(16), + 41: uint8(16), + 42: uint8(16), + 43: uint8(16), + 44: uint8(42), + 45: uint8(43), + 46: uint8(16), + 47: uint8(16), + 48: uint8(44), + 49: uint8(16), + 50: uint8(16), + 51: uint8(16), + 52: uint8(16), + 53: uint8(16), + 54: uint8(16), + 55: uint8(16), + 56: uint8(16), + 57: uint8(16), + 58: uint8(16), + 59: uint8(16), + 60: uint8(16), + 61: uint8(16), + 62: uint8(16), + 63: uint8(16), + 64: uint8(16), + 65: uint8(16), + 66: uint8(16), + 67: uint8(16), + 68: uint8(16), + 69: uint8(16), + 70: uint8(16), + 71: uint8(16), + 72: uint8(16), + 73: uint8(16), + 74: uint8(16), + 75: uint8(16), + 76: uint8(16), + 77: uint8(16), + 78: uint8(16), + 79: uint8(16), + 80: uint8(16), + 81: uint8(16), + 82: uint8(16), + 83: uint8(16), + 84: uint8(16), + 85: uint8(16), + 86: uint8(16), + 87: uint8(16), + 88: uint8(16), + 89: uint8(16), + 90: uint8(16), + 91: uint8(16), + 92: uint8(16), + 93: uint8(16), + 94: uint8(16), + 95: uint8(16), + 96: uint8(16), + 97: uint8(16), + 98: uint8(16), + 99: uint8(16), + 100: uint8(16), + 101: uint8(16), + 102: uint8(16), + 103: uint8(16), + 104: uint8(16), + 105: uint8(16), + 106: uint8(16), + 107: uint8(16), + 108: uint8(16), + 109: uint8(16), + 110: uint8(16), + 111: uint8(16), + 112: uint8(16), + 113: uint8(16), + 114: uint8(16), + 115: uint8(16), + 116: uint8(16), + 117: uint8(16), + 118: uint8(16), + 119: uint8(16), + 120: uint8(16), + 121: uint8(16), + 122: uint8(16), + 123: uint8(16), + 124: uint8(16), + 125: uint8(16), + 126: uint8(16), + 127: uint8(16), + 128: uint8(16), + 129: uint8(16), + 130: uint8(16), + 131: uint8(16), + 132: uint8(16), + 133: uint8(16), + 134: uint8(16), + 135: uint8(16), + 136: uint8(16), + 137: uint8(16), + 138: uint8(16), + 139: uint8(16), + 140: uint8(16), + 141: uint8(16), + 142: uint8(16), + 143: uint8(16), + 144: uint8(16), + 145: uint8(16), + 146: uint8(16), + 147: uint8(16), + 148: uint8(16), + 149: uint8(16), + 150: uint8(16), + 151: uint8(16), + 152: uint8(16), + 153: uint8(16), + 154: uint8(16), + 155: uint8(16), + 156: uint8(16), + 157: uint8(16), + 158: uint8(16), + 159: uint8(16), + 160: uint8(16), + 161: uint8(16), + 162: uint8(16), + 163: uint8(16), + 164: uint8(16), + 165: uint8(16), + 166: uint8(45), + 167: uint8(16), + 168: uint8(46), + 169: uint8(47), + 170: uint8(48), + 171: uint8(49), + 172: uint8(16), + 173: uint8(16), + 174: uint8(16), + 175: uint8(16), + 176: uint8(16), + 177: uint8(16), + 178: uint8(16), + 179: uint8(16), + 180: uint8(16), + 181: uint8(16), + 182: uint8(16), + 183: uint8(16), + 184: uint8(16), + 185: uint8(16), + 186: uint8(16), + 187: uint8(16), + 188: uint8(16), + 189: uint8(16), + 190: uint8(16), + 191: uint8(16), + 192: uint8(16), + 193: uint8(16), + 194: uint8(16), + 195: uint8(16), + 196: uint8(16), + 197: uint8(16), + 198: uint8(16), + 199: uint8(16), + 200: uint8(16), + 201: uint8(16), + 202: uint8(16), + 203: uint8(16), + 204: uint8(16), + 205: uint8(16), + 206: uint8(16), + 207: uint8(16), + 208: uint8(16), + 209: uint8(16), + 210: uint8(16), + 211: uint8(16), + 212: uint8(16), + 213: uint8(16), + 214: uint8(16), + 215: uint8(50), + 216: uint8(16), + 217: uint8(16), + 218: uint8(16), + 219: uint8(16), + 220: uint8(16), + 221: uint8(16), + 222: uint8(16), + 223: uint8(16), + 224: uint8(16), + 225: uint8(16), + 226: uint8(16), + 227: uint8(16), + 228: uint8(16), + 229: uint8(16), + 230: uint8(16), + 231: uint8(16), + 232: uint8(16), + 233: uint8(16), + 234: uint8(16), + 235: uint8(16), + 236: uint8(16), + 237: uint8(16), + 238: uint8(16), + 239: uint8(16), + 240: uint8(16), + 241: uint8(16), + 242: uint8(16), + 243: uint8(16), + 244: uint8(16), + 245: uint8(16), + 246: uint8(16), + 247: uint8(16), + 248: uint8(16), + 249: uint8(16), + 250: uint8(16), + 251: uint8(51), + 252: uint8(16), + 253: uint8(16), + 254: uint8(52), + 255: uint8(53), + 256: uint8(16), + 257: uint8(54), + 258: uint8(55), + 259: uint8(56), + 260: uint8(16), + 261: uint8(16), + 262: uint8(16), + 263: uint8(16), + 264: uint8(16), + 265: uint8(16), + 266: uint8(57), + 267: uint8(16), + 268: uint8(16), + 269: uint8(58), + 270: uint8(16), + 271: uint8(59), + 272: uint8(60), + 273: uint8(61), + 274: uint8(62), + 275: uint8(63), + 276: uint8(64), + 277: uint8(65), + 278: uint8(66), + 279: uint8(67), + 280: uint8(68), + 281: uint8(69), + 282: uint8(70), + 283: uint8(16), + 284: uint8(71), + 285: uint8(72), + 286: uint8(73), + 287: uint8(16), + 288: uint8(16), + 289: uint8(16), + 290: uint8(16), + 291: uint8(16), + 292: uint8(16), + 293: uint8(16), + 294: uint8(16), + 295: uint8(16), + 296: uint8(16), + 297: uint8(16), + 298: uint8(16), + 299: uint8(16), + 300: uint8(16), + 301: uint8(16), + 302: uint8(16), + 303: uint8(16), + 304: uint8(16), + 305: uint8(16), + 306: uint8(16), + 307: uint8(16), + 308: uint8(74), + 309: uint8(16), + 310: uint8(16), + 311: uint8(16), + 312: uint8(16), + 313: uint8(16), + 314: uint8(16), + 315: uint8(16), + 316: uint8(16), + 317: uint8(16), + 318: uint8(16), + 319: uint8(16), + 320: uint8(16), + 321: uint8(16), + 322: uint8(16), + 323: uint8(16), + 324: uint8(16), + 325: uint8(16), + 326: uint8(16), + 327: uint8(16), + 328: uint8(16), + 329: uint8(16), + 330: uint8(16), + 331: uint8(16), + 332: uint8(16), + 333: uint8(16), + 334: uint8(16), + 335: uint8(16), + 336: uint8(16), + 337: uint8(16), + 338: uint8(16), + 339: uint8(16), + 340: uint8(16), + 341: uint8(16), + 342: uint8(16), + 343: uint8(16), + 344: uint8(16), + 345: uint8(16), + 346: uint8(16), + 347: uint8(16), + 348: uint8(16), + 349: uint8(16), + 350: uint8(16), + 351: uint8(16), + 352: uint8(16), + 353: uint8(16), + 354: uint8(16), + 355: uint8(16), + 356: uint8(16), + 357: uint8(16), + 358: uint8(16), + 359: uint8(16), + 360: uint8(16), + 361: uint8(16), + 362: uint8(75), + 363: uint8(76), + 364: uint8(16), + 365: uint8(16), + 366: uint8(16), + 367: uint8(77), + 368: uint8(16), + 369: uint8(16), + 370: uint8(16), + 371: uint8(16), + 372: uint8(16), + 373: uint8(16), + 374: uint8(16), + 375: uint8(16), + 376: uint8(16), + 377: uint8(16), + 378: uint8(16), + 379: uint8(16), + 380: uint8(16), + 381: uint8(16), + 382: uint8(16), + 383: uint8(16), + 384: uint8(16), + 385: uint8(16), + 386: uint8(16), + 387: uint8(16), + 388: uint8(16), + 389: uint8(16), + 390: uint8(16), + 391: uint8(16), + 392: uint8(16), + 393: uint8(16), + 394: uint8(16), + 395: uint8(16), + 396: uint8(16), + 397: uint8(16), + 398: uint8(16), + 399: uint8(16), + 400: uint8(16), + 401: uint8(16), + 402: uint8(16), + 403: uint8(16), + 404: uint8(16), + 405: uint8(16), + 406: uint8(16), + 407: uint8(16), + 408: uint8(16), + 409: uint8(16), + 410: uint8(16), + 411: uint8(16), + 412: uint8(16), + 413: uint8(16), + 414: uint8(16), + 415: uint8(16), + 416: uint8(16), + 417: uint8(16), + 418: uint8(16), + 419: uint8(16), + 420: uint8(16), + 421: uint8(16), + 422: uint8(16), + 423: uint8(16), + 424: uint8(16), + 425: uint8(16), + 426: uint8(16), + 427: uint8(16), + 428: uint8(16), + 429: uint8(16), + 430: uint8(16), + 431: uint8(16), + 432: uint8(16), + 433: uint8(16), + 434: uint8(16), + 435: uint8(16), + 436: uint8(16), + 437: uint8(16), + 438: uint8(16), + 439: uint8(16), + 440: uint8(16), + 441: uint8(16), + 442: uint8(16), + 443: uint8(16), + 444: uint8(78), + 445: uint8(16), + 446: uint8(16), + 447: uint8(16), + 448: uint8(16), + 449: uint8(16), + 450: uint8(16), + 451: uint8(16), + 452: uint8(16), + 453: uint8(16), + 454: uint8(16), + 455: uint8(16), + 456: uint8(16), + 457: uint8(16), + 458: uint8(16), + 459: uint8(16), + 460: uint8(16), + 461: uint8(16), + 462: uint8(16), + 463: uint8(16), + 464: uint8(16), + 465: uint8(79), + 466: uint8(80), + 467: uint8(16), + 468: uint8(16), + 469: uint8(16), + 470: uint8(16), + 471: uint8(16), + 472: uint8(16), + 473: uint8(16), + 474: uint8(81), + 475: uint8(16), + 476: uint8(16), + 477: uint8(16), + 478: uint8(16), + 479: uint8(16), + 480: uint8(82), + 481: uint8(83), + 482: uint8(84), + 483: uint8(16), + 484: uint8(16), + 485: uint8(16), + 486: uint8(16), + 487: uint8(16), + 488: uint8(85), + 489: uint8(86), + 490: uint8(16), + 491: uint8(16), + 492: uint8(16), + 493: uint8(16), + 494: uint8(16), + 495: uint8(16), + 496: uint8(16), + 497: uint8(16), + 498: uint8(16), + 499: uint8(16), + 500: uint8(16), + 501: uint8(16), + 502: uint8(16), + 503: uint8(16), + 504: uint8(16), + 505: uint8(16), + 506: uint8(16), + 507: uint8(16), + 508: uint8(16), + 509: uint8(16), + 510: uint8(16), + 511: uint8(16), + 544: uint8(255), + 545: uint8(255), + 546: uint8(255), + 547: uint8(255), + 548: uint8(255), + 549: uint8(255), + 550: uint8(255), + 551: uint8(255), + 552: uint8(255), + 553: uint8(255), + 554: uint8(255), + 555: uint8(255), + 556: uint8(255), + 557: uint8(255), + 558: uint8(255), + 559: uint8(255), + 560: uint8(255), + 561: uint8(255), + 562: uint8(255), + 563: uint8(255), + 564: uint8(255), + 565: uint8(255), + 566: uint8(255), + 567: uint8(255), + 568: uint8(255), + 569: uint8(255), + 570: uint8(255), + 571: uint8(255), + 572: uint8(255), + 573: uint8(255), + 574: uint8(255), + 575: uint8(255), + 576: uint8(255), + 577: uint8(255), + 578: uint8(255), + 579: uint8(255), + 580: uint8(255), + 581: uint8(255), + 582: uint8(255), + 583: uint8(255), + 584: uint8(255), + 585: uint8(255), + 586: uint8(255), + 587: uint8(255), + 588: uint8(255), + 589: uint8(255), + 624: uint8(248), + 625: uint8(3), + 658: uint8(254), + 659: uint8(255), + 660: uint8(255), + 661: uint8(255), + 662: uint8(255), + 663: uint8(191), + 664: uint8(182), + 672: uint8(63), + 674: uint8(255), + 675: uint8(23), + 681: uint8(248), + 682: uint8(255), + 683: uint8(255), + 686: uint8(1), + 698: uint8(192), + 699: uint8(191), + 700: uint8(159), + 701: uint8(61), + 705: uint8(128), + 706: uint8(2), + 710: uint8(255), + 711: uint8(255), + 712: uint8(255), + 713: uint8(7), + 724: uint8(192), + 725: uint8(255), + 726: uint8(1), + 733: uint8(248), + 734: uint8(15), + 735: uint8(32), + 738: uint8(192), + 739: uint8(251), + 740: uint8(239), + 741: uint8(62), + 747: uint8(14), + 762: uint8(248), + 763: uint8(255), + 764: uint8(255), + 765: uint8(255), + 766: uint8(255), + 767: uint8(255), + 768: uint8(7), + 775: uint8(20), + 776: uint8(254), + 777: uint8(33), + 778: uint8(254), + 780: uint8(12), + 784: uint8(2), + 791: uint8(16), + 792: uint8(30), + 793: uint8(32), + 796: uint8(12), + 799: uint8(64), + 800: uint8(6), + 807: uint8(16), + 808: uint8(134), + 809: uint8(57), + 810: uint8(2), + 814: uint8(35), + 816: uint8(6), + 823: uint8(16), + 824: uint8(190), + 825: uint8(33), + 828: uint8(12), + 831: uint8(252), + 832: uint8(2), + 839: uint8(144), + 840: uint8(30), + 841: uint8(32), + 842: uint8(64), + 844: uint8(12), + 848: uint8(4), + 856: uint8(1), + 857: uint8(32), + 864: uint8(17), + 871: uint8(192), + 872: uint8(193), + 873: uint8(61), + 874: uint8(96), + 876: uint8(12), + 880: uint8(2), + 887: uint8(144), + 888: uint8(64), + 889: uint8(48), + 892: uint8(12), + 896: uint8(3), + 903: uint8(24), + 904: uint8(30), + 905: uint8(32), + 908: uint8(12), + 921: uint8(4), + 922: uint8(92), + 934: uint8(242), + 935: uint8(7), + 936: uint8(128), + 937: uint8(127), + 950: uint8(242), + 951: uint8(31), + 953: uint8(63), + 963: uint8(3), + 966: uint8(160), + 967: uint8(2), + 974: uint8(254), + 975: uint8(127), + 976: uint8(223), + 977: uint8(224), + 978: uint8(255), + 979: uint8(254), + 980: uint8(255), + 981: uint8(255), + 982: uint8(255), + 983: uint8(31), + 984: uint8(64), + 997: uint8(224), + 998: uint8(253), + 999: uint8(102), + 1003: uint8(195), + 1004: uint8(1), + 1006: uint8(30), + 1008: uint8(100), + 1009: uint8(32), + 1011: uint8(32), + 1036: uint8(255), + 1037: uint8(255), + 1038: uint8(255), + 1039: uint8(255), + 1040: uint8(255), + 1041: uint8(255), + 1042: uint8(255), + 1043: uint8(255), + 1044: uint8(255), + 1045: uint8(255), + 1046: uint8(255), + 1047: uint8(255), + 1048: uint8(255), + 1049: uint8(255), + 1050: uint8(255), + 1051: uint8(255), + 1052: uint8(255), + 1053: uint8(255), + 1054: uint8(255), + 1055: uint8(255), + 1067: uint8(224), + 1090: uint8(28), + 1094: uint8(28), + 1098: uint8(12), + 1102: uint8(12), + 1110: uint8(176), + 1111: uint8(63), + 1112: uint8(64), + 1113: uint8(254), + 1114: uint8(15), + 1115: uint8(32), + 1121: uint8(120), + 1136: uint8(96), + 1141: uint8(2), + 1156: uint8(135), + 1157: uint8(1), + 1158: uint8(4), + 1159: uint8(14), + 1186: uint8(128), + 1187: uint8(9), + 1194: uint8(64), + 1195: uint8(127), + 1196: uint8(229), + 1197: uint8(31), + 1198: uint8(248), + 1199: uint8(159), + 1206: uint8(255), + 1207: uint8(127), + 1216: uint8(15), + 1222: uint8(208), + 1223: uint8(23), + 1224: uint8(4), + 1229: uint8(248), + 1230: uint8(15), + 1232: uint8(3), + 1236: uint8(60), + 1237: uint8(59), + 1244: uint8(64), + 1245: uint8(163), + 1246: uint8(3), + 1253: uint8(240), + 1254: uint8(207), + 1274: uint8(247), + 1275: uint8(255), + 1276: uint8(253), + 1277: uint8(33), + 1278: uint8(16), + 1279: uint8(3), + 1304: uint8(255), + 1305: uint8(255), + 1306: uint8(255), + 1307: uint8(255), + 1308: uint8(255), + 1309: uint8(255), + 1310: uint8(255), + 1311: uint8(251), + 1313: uint8(248), + 1317: uint8(124), + 1324: uint8(223), + 1325: uint8(255), + 1338: uint8(255), + 1339: uint8(255), + 1340: uint8(255), + 1341: uint8(255), + 1342: uint8(1), + 1373: uint8(128), + 1374: uint8(3), + 1391: uint8(128), + 1404: uint8(255), + 1405: uint8(255), + 1406: uint8(255), + 1407: uint8(255), + 1413: uint8(60), + 1427: uint8(6), + 1453: uint8(128), + 1454: uint8(247), + 1455: uint8(63), + 1459: uint8(192), + 1470: uint8(3), + 1472: uint8(68), + 1473: uint8(8), + 1476: uint8(96), + 1496: uint8(48), + 1500: uint8(255), + 1501: uint8(255), + 1502: uint8(3), + 1503: uint8(128), + 1508: uint8(192), + 1509: uint8(63), + 1512: uint8(128), + 1513: uint8(255), + 1514: uint8(3), + 1520: uint8(7), + 1526: uint8(200), + 1527: uint8(51), + 1532: uint8(32), + 1541: uint8(126), + 1542: uint8(102), + 1544: uint8(8), + 1545: uint8(16), + 1551: uint8(16), + 1558: uint8(157), + 1559: uint8(193), + 1560: uint8(2), + 1565: uint8(48), + 1566: uint8(64), + 1596: uint8(32), + 1597: uint8(33), + 1622: uint8(255), + 1623: uint8(255), + 1624: uint8(255), + 1625: uint8(255), + 1626: uint8(255), + 1627: uint8(255), + 1628: uint8(255), + 1629: uint8(255), + 1630: uint8(255), + 1631: uint8(255), + 1635: uint8(64), + 1664: uint8(255), + 1665: uint8(255), + 1668: uint8(255), + 1669: uint8(255), + 1695: uint8(128), + 1727: uint8(14), + 1759: uint8(32), + 1788: uint8(1), + 1806: uint8(192), + 1807: uint8(7), + 1824: uint8(110), + 1825: uint8(240), + 1831: uint8(135), + 1852: uint8(96), + 1860: uint8(240), + 1896: uint8(192), + 1897: uint8(255), + 1898: uint8(1), + 1920: uint8(2), + 1927: uint8(255), + 1928: uint8(127), + 1935: uint8(128), + 1936: uint8(3), + 1942: uint8(120), + 1943: uint8(38), + 1945: uint8(32), + 1952: uint8(7), + 1956: uint8(128), + 1957: uint8(239), + 1958: uint8(31), + 1966: uint8(8), + 1968: uint8(3), + 1974: uint8(192), + 1975: uint8(127), + 1977: uint8(30), + 1989: uint8(128), + 1990: uint8(211), + 1991: uint8(64), + 2011: uint8(128), + 2012: uint8(248), + 2013: uint8(7), + 2016: uint8(3), + 2023: uint8(24), + 2024: uint8(1), + 2028: uint8(192), + 2029: uint8(31), + 2030: uint8(31), + 2055: uint8(255), + 2056: uint8(92), + 2059: uint8(64), + 2070: uint8(248), + 2071: uint8(133), + 2072: uint8(13), + 2102: uint8(60), + 2103: uint8(176), + 2104: uint8(1), + 2107: uint8(48), + 2118: uint8(248), + 2119: uint8(167), + 2120: uint8(1), + 2133: uint8(40), + 2134: uint8(191), + 2147: uint8(224), + 2148: uint8(188), + 2149: uint8(15), + 2181: uint8(128), + 2182: uint8(255), + 2183: uint8(6), + 2234: uint8(240), + 2235: uint8(12), + 2236: uint8(1), + 2240: uint8(254), + 2241: uint8(7), + 2246: uint8(248), + 2247: uint8(121), + 2248: uint8(128), + 2250: uint8(126), + 2251: uint8(14), + 2257: uint8(252), + 2258: uint8(127), + 2259: uint8(3), + 2278: uint8(127), + 2279: uint8(191), + 2290: uint8(252), + 2291: uint8(255), + 2292: uint8(255), + 2293: uint8(252), + 2294: uint8(109), + 2310: uint8(126), + 2311: uint8(180), + 2312: uint8(191), + 2322: uint8(163), + 2366: uint8(24), + 2374: uint8(255), + 2375: uint8(1), + 2430: uint8(31), + 2438: uint8(127), + 2473: uint8(128), + 2481: uint8(128), + 2482: uint8(7), + 2515: uint8(96), + 2516: uint8(15), + 2540: uint8(128), + 2541: uint8(3), + 2542: uint8(248), + 2543: uint8(255), + 2544: uint8(231), + 2545: uint8(15), + 2549: uint8(60), + 2568: uint8(28), + 2592: uint8(255), + 2593: uint8(255), + 2594: uint8(255), + 2595: uint8(255), + 2596: uint8(255), + 2597: uint8(255), + 2598: uint8(127), + 2599: uint8(248), + 2600: uint8(255), + 2601: uint8(255), + 2602: uint8(255), + 2603: uint8(255), + 2604: uint8(255), + 2605: uint8(31), + 2606: uint8(32), + 2608: uint8(16), + 2611: uint8(248), + 2612: uint8(254), + 2613: uint8(255), + 2624: uint8(127), + 2625: uint8(255), + 2626: uint8(255), + 2627: uint8(249), + 2628: uint8(219), + 2629: uint8(7), + 2662: uint8(127), + 2717: uint8(240), + 2746: uint8(127), + 2760: uint8(240), + 2761: uint8(7), +} + +var _wtable = [1600]uint8{ + 0: uint8(16), + 1: uint8(16), + 2: uint8(16), + 3: uint8(16), + 4: uint8(16), + 5: uint8(16), + 6: uint8(16), + 7: uint8(16), + 8: uint8(16), + 9: uint8(16), + 10: uint8(16), + 11: uint8(16), + 12: uint8(16), + 13: uint8(16), + 14: uint8(16), + 15: uint8(16), + 16: uint8(16), + 17: uint8(18), + 18: uint8(16), + 19: uint8(16), + 20: uint8(16), + 21: uint8(16), + 22: uint8(16), + 23: uint8(16), + 24: uint8(16), + 25: uint8(16), + 26: uint8(16), + 27: uint8(16), + 28: uint8(16), + 29: uint8(16), + 30: uint8(16), + 31: uint8(16), + 32: uint8(16), + 33: uint8(16), + 34: uint8(16), + 35: uint8(19), + 36: uint8(16), + 37: uint8(20), + 38: uint8(21), + 39: uint8(22), + 40: uint8(16), + 41: uint8(16), + 42: uint8(16), + 43: uint8(23), + 44: uint8(16), + 45: uint8(16), + 46: uint8(24), + 47: uint8(25), + 48: uint8(26), + 49: uint8(27), + 50: uint8(28), + 51: uint8(17), + 52: uint8(17), + 53: uint8(17), + 54: uint8(17), + 55: uint8(17), + 56: uint8(17), + 57: uint8(17), + 58: uint8(17), + 59: uint8(17), + 60: uint8(17), + 61: uint8(17), + 62: uint8(17), + 63: uint8(17), + 64: uint8(17), + 65: uint8(17), + 66: uint8(17), + 67: uint8(17), + 68: uint8(17), + 69: uint8(17), + 70: uint8(17), + 71: uint8(17), + 72: uint8(17), + 73: uint8(17), + 74: uint8(17), + 75: uint8(17), + 76: uint8(17), + 77: uint8(29), + 78: uint8(17), + 79: uint8(17), + 80: uint8(17), + 81: uint8(17), + 82: uint8(17), + 83: uint8(17), + 84: uint8(17), + 85: uint8(17), + 86: uint8(17), + 87: uint8(17), + 88: uint8(17), + 89: uint8(17), + 90: uint8(17), + 91: uint8(17), + 92: uint8(17), + 93: uint8(17), + 94: uint8(17), + 95: uint8(17), + 96: uint8(17), + 97: uint8(17), + 98: uint8(17), + 99: uint8(17), + 100: uint8(17), + 101: uint8(17), + 102: uint8(17), + 103: uint8(17), + 104: uint8(17), + 105: uint8(17), + 106: uint8(17), + 107: uint8(17), + 108: uint8(17), + 109: uint8(17), + 110: uint8(17), + 111: uint8(17), + 112: uint8(17), + 113: uint8(17), + 114: uint8(17), + 115: uint8(17), + 116: uint8(17), + 117: uint8(17), + 118: uint8(17), + 119: uint8(17), + 120: uint8(17), + 121: uint8(17), + 122: uint8(17), + 123: uint8(17), + 124: uint8(17), + 125: uint8(17), + 126: uint8(17), + 127: uint8(17), + 128: uint8(17), + 129: uint8(17), + 130: uint8(17), + 131: uint8(17), + 132: uint8(17), + 133: uint8(17), + 134: uint8(17), + 135: uint8(17), + 136: uint8(17), + 137: uint8(17), + 138: uint8(17), + 139: uint8(17), + 140: uint8(17), + 141: uint8(17), + 142: uint8(17), + 143: uint8(17), + 144: uint8(17), + 145: uint8(17), + 146: uint8(17), + 147: uint8(17), + 148: uint8(17), + 149: uint8(17), + 150: uint8(17), + 151: uint8(17), + 152: uint8(17), + 153: uint8(17), + 154: uint8(17), + 155: uint8(17), + 156: uint8(17), + 157: uint8(17), + 158: uint8(17), + 159: uint8(17), + 160: uint8(17), + 161: uint8(17), + 162: uint8(17), + 163: uint8(17), + 164: uint8(30), + 165: uint8(16), + 166: uint8(16), + 167: uint8(16), + 168: uint8(16), + 169: uint8(31), + 170: uint8(16), + 171: uint8(16), + 172: uint8(17), + 173: uint8(17), + 174: uint8(17), + 175: uint8(17), + 176: uint8(17), + 177: uint8(17), + 178: uint8(17), + 179: uint8(17), + 180: uint8(17), + 181: uint8(17), + 182: uint8(17), + 183: uint8(17), + 184: uint8(17), + 185: uint8(17), + 186: uint8(17), + 187: uint8(17), + 188: uint8(17), + 189: uint8(17), + 190: uint8(17), + 191: uint8(17), + 192: uint8(17), + 193: uint8(17), + 194: uint8(17), + 195: uint8(17), + 196: uint8(17), + 197: uint8(17), + 198: uint8(17), + 199: uint8(17), + 200: uint8(17), + 201: uint8(17), + 202: uint8(17), + 203: uint8(17), + 204: uint8(17), + 205: uint8(17), + 206: uint8(17), + 207: uint8(17), + 208: uint8(17), + 209: uint8(17), + 210: uint8(17), + 211: uint8(17), + 212: uint8(17), + 213: uint8(17), + 214: uint8(17), + 215: uint8(32), + 216: uint8(16), + 217: uint8(16), + 218: uint8(16), + 219: uint8(16), + 220: uint8(16), + 221: uint8(16), + 222: uint8(16), + 223: uint8(16), + 224: uint8(16), + 225: uint8(16), + 226: uint8(16), + 227: uint8(16), + 228: uint8(16), + 229: uint8(16), + 230: uint8(16), + 231: uint8(16), + 232: uint8(16), + 233: uint8(16), + 234: uint8(16), + 235: uint8(16), + 236: uint8(16), + 237: uint8(16), + 238: uint8(16), + 239: uint8(16), + 240: uint8(16), + 241: uint8(16), + 242: uint8(16), + 243: uint8(16), + 244: uint8(16), + 245: uint8(16), + 246: uint8(16), + 247: uint8(16), + 248: uint8(16), + 249: uint8(17), + 250: uint8(17), + 251: uint8(16), + 252: uint8(16), + 253: uint8(16), + 254: uint8(33), + 255: uint8(34), + 256: uint8(16), + 257: uint8(16), + 258: uint8(16), + 259: uint8(16), + 260: uint8(16), + 261: uint8(16), + 262: uint8(16), + 263: uint8(16), + 264: uint8(16), + 265: uint8(16), + 266: uint8(16), + 267: uint8(16), + 268: uint8(16), + 269: uint8(16), + 270: uint8(16), + 271: uint8(16), + 272: uint8(16), + 273: uint8(16), + 274: uint8(16), + 275: uint8(16), + 276: uint8(16), + 277: uint8(16), + 278: uint8(16), + 279: uint8(16), + 280: uint8(16), + 281: uint8(16), + 282: uint8(16), + 283: uint8(16), + 284: uint8(16), + 285: uint8(16), + 286: uint8(16), + 287: uint8(16), + 288: uint8(16), + 289: uint8(16), + 290: uint8(16), + 291: uint8(16), + 292: uint8(16), + 293: uint8(16), + 294: uint8(16), + 295: uint8(16), + 296: uint8(16), + 297: uint8(16), + 298: uint8(16), + 299: uint8(16), + 300: uint8(16), + 301: uint8(16), + 302: uint8(16), + 303: uint8(16), + 304: uint8(16), + 305: uint8(16), + 306: uint8(16), + 307: uint8(16), + 308: uint8(16), + 309: uint8(16), + 310: uint8(16), + 311: uint8(16), + 312: uint8(16), + 313: uint8(16), + 314: uint8(16), + 315: uint8(16), + 316: uint8(16), + 317: uint8(16), + 318: uint8(16), + 319: uint8(16), + 320: uint8(16), + 321: uint8(16), + 322: uint8(16), + 323: uint8(16), + 324: uint8(16), + 325: uint8(16), + 326: uint8(16), + 327: uint8(16), + 328: uint8(16), + 329: uint8(16), + 330: uint8(16), + 331: uint8(16), + 332: uint8(16), + 333: uint8(16), + 334: uint8(16), + 335: uint8(16), + 336: uint8(16), + 337: uint8(16), + 338: uint8(16), + 339: uint8(16), + 340: uint8(16), + 341: uint8(16), + 342: uint8(16), + 343: uint8(16), + 344: uint8(16), + 345: uint8(16), + 346: uint8(16), + 347: uint8(16), + 348: uint8(16), + 349: uint8(16), + 350: uint8(16), + 351: uint8(16), + 352: uint8(16), + 353: uint8(16), + 354: uint8(16), + 355: uint8(16), + 356: uint8(16), + 357: uint8(16), + 358: uint8(16), + 359: uint8(16), + 360: uint8(16), + 361: uint8(16), + 362: uint8(16), + 363: uint8(16), + 364: uint8(16), + 365: uint8(16), + 366: uint8(16), + 367: uint8(35), + 368: uint8(17), + 369: uint8(17), + 370: uint8(17), + 371: uint8(17), + 372: uint8(17), + 373: uint8(17), + 374: uint8(17), + 375: uint8(17), + 376: uint8(17), + 377: uint8(17), + 378: uint8(17), + 379: uint8(17), + 380: uint8(17), + 381: uint8(17), + 382: uint8(17), + 383: uint8(17), + 384: uint8(17), + 385: uint8(17), + 386: uint8(17), + 387: uint8(17), + 388: uint8(17), + 389: uint8(17), + 390: uint8(17), + 391: uint8(36), + 392: uint8(17), + 393: uint8(17), + 394: uint8(37), + 395: uint8(16), + 396: uint8(16), + 397: uint8(16), + 398: uint8(16), + 399: uint8(16), + 400: uint8(16), + 401: uint8(16), + 402: uint8(16), + 403: uint8(16), + 404: uint8(16), + 405: uint8(16), + 406: uint8(16), + 407: uint8(16), + 408: uint8(16), + 409: uint8(16), + 410: uint8(16), + 411: uint8(16), + 412: uint8(16), + 413: uint8(16), + 414: uint8(16), + 415: uint8(16), + 416: uint8(16), + 417: uint8(16), + 418: uint8(16), + 419: uint8(16), + 420: uint8(16), + 421: uint8(16), + 422: uint8(16), + 423: uint8(16), + 424: uint8(16), + 425: uint8(16), + 426: uint8(16), + 427: uint8(16), + 428: uint8(16), + 429: uint8(16), + 430: uint8(16), + 431: uint8(16), + 432: uint8(17), + 433: uint8(38), + 434: uint8(39), + 435: uint8(16), + 436: uint8(16), + 437: uint8(16), + 438: uint8(16), + 439: uint8(16), + 440: uint8(16), + 441: uint8(16), + 442: uint8(16), + 443: uint8(16), + 444: uint8(16), + 445: uint8(16), + 446: uint8(16), + 447: uint8(16), + 448: uint8(16), + 449: uint8(16), + 450: uint8(16), + 451: uint8(16), + 452: uint8(16), + 453: uint8(16), + 454: uint8(16), + 455: uint8(16), + 456: uint8(16), + 457: uint8(16), + 458: uint8(16), + 459: uint8(16), + 460: uint8(16), + 461: uint8(16), + 462: uint8(16), + 463: uint8(16), + 464: uint8(16), + 465: uint8(16), + 466: uint8(16), + 467: uint8(16), + 468: uint8(16), + 469: uint8(16), + 470: uint8(16), + 471: uint8(16), + 472: uint8(16), + 473: uint8(16), + 474: uint8(16), + 475: uint8(16), + 476: uint8(16), + 477: uint8(16), + 478: uint8(16), + 479: uint8(16), + 480: uint8(16), + 481: uint8(16), + 482: uint8(16), + 483: uint8(16), + 484: uint8(16), + 485: uint8(16), + 486: uint8(16), + 487: uint8(16), + 488: uint8(16), + 489: uint8(16), + 490: uint8(16), + 491: uint8(16), + 492: uint8(16), + 493: uint8(16), + 494: uint8(16), + 495: uint8(16), + 496: uint8(40), + 497: uint8(41), + 498: uint8(42), + 499: uint8(43), + 500: uint8(44), + 501: uint8(45), + 502: uint8(46), + 503: uint8(47), + 504: uint8(16), + 505: uint8(48), + 506: uint8(49), + 507: uint8(16), + 508: uint8(16), + 509: uint8(16), + 510: uint8(16), + 511: uint8(16), + 544: uint8(255), + 545: uint8(255), + 546: uint8(255), + 547: uint8(255), + 548: uint8(255), + 549: uint8(255), + 550: uint8(255), + 551: uint8(255), + 552: uint8(255), + 553: uint8(255), + 554: uint8(255), + 555: uint8(255), + 556: uint8(255), + 557: uint8(255), + 558: uint8(255), + 559: uint8(255), + 560: uint8(255), + 561: uint8(255), + 562: uint8(255), + 563: uint8(255), + 564: uint8(255), + 565: uint8(255), + 566: uint8(255), + 567: uint8(255), + 568: uint8(255), + 569: uint8(255), + 570: uint8(255), + 571: uint8(255), + 572: uint8(255), + 573: uint8(255), + 574: uint8(255), + 575: uint8(255), + 576: uint8(255), + 577: uint8(255), + 578: uint8(255), + 579: uint8(255), + 580: uint8(255), + 581: uint8(255), + 582: uint8(255), + 583: uint8(255), + 584: uint8(255), + 585: uint8(255), + 586: uint8(255), + 587: uint8(255), + 611: uint8(12), + 613: uint8(6), + 637: uint8(30), + 638: uint8(9), + 671: uint8(96), + 674: uint8(48), + 681: uint8(255), + 682: uint8(15), + 687: uint8(128), + 690: uint8(8), + 692: uint8(2), + 693: uint8(12), + 695: uint8(96), + 696: uint8(48), + 697: uint8(64), + 698: uint8(16), + 701: uint8(4), + 702: uint8(44), + 703: uint8(36), + 704: uint8(32), + 705: uint8(12), + 709: uint8(1), + 713: uint8(80), + 714: uint8(184), + 722: uint8(224), + 726: uint8(1), + 727: uint8(128), + 739: uint8(24), + 746: uint8(33), + 784: uint8(255), + 785: uint8(255), + 786: uint8(255), + 787: uint8(251), + 788: uint8(255), + 789: uint8(255), + 790: uint8(255), + 791: uint8(255), + 792: uint8(255), + 793: uint8(255), + 794: uint8(255), + 795: uint8(255), + 796: uint8(255), + 797: uint8(255), + 798: uint8(15), + 800: uint8(255), + 801: uint8(255), + 802: uint8(255), + 803: uint8(255), + 804: uint8(255), + 805: uint8(255), + 806: uint8(255), + 807: uint8(255), + 808: uint8(255), + 809: uint8(255), + 810: uint8(255), + 811: uint8(255), + 812: uint8(255), + 813: uint8(255), + 814: uint8(255), + 815: uint8(255), + 816: uint8(255), + 817: uint8(255), + 818: uint8(255), + 819: uint8(255), + 820: uint8(255), + 821: uint8(255), + 822: uint8(255), + 823: uint8(255), + 824: uint8(255), + 825: uint8(255), + 826: uint8(63), + 830: uint8(255), + 831: uint8(15), + 832: uint8(255), + 833: uint8(255), + 834: uint8(255), + 835: uint8(255), + 836: uint8(255), + 837: uint8(255), + 838: uint8(255), + 839: uint8(127), + 840: uint8(254), + 841: uint8(255), + 842: uint8(255), + 843: uint8(255), + 844: uint8(255), + 845: uint8(255), + 846: uint8(255), + 847: uint8(255), + 848: uint8(255), + 849: uint8(255), + 850: uint8(127), + 851: uint8(254), + 852: uint8(255), + 853: uint8(255), + 854: uint8(255), + 855: uint8(255), + 856: uint8(255), + 857: uint8(255), + 858: uint8(255), + 859: uint8(255), + 860: uint8(255), + 861: uint8(255), + 862: uint8(255), + 863: uint8(255), + 864: uint8(224), + 865: uint8(255), + 866: uint8(255), + 867: uint8(255), + 868: uint8(255), + 869: uint8(255), + 870: uint8(254), + 871: uint8(255), + 872: uint8(255), + 873: uint8(255), + 874: uint8(255), + 875: uint8(255), + 876: uint8(255), + 877: uint8(255), + 878: uint8(255), + 879: uint8(255), + 880: uint8(255), + 881: uint8(127), + 882: uint8(255), + 883: uint8(255), + 884: uint8(255), + 885: uint8(255), + 886: uint8(255), + 887: uint8(7), + 888: uint8(255), + 889: uint8(255), + 890: uint8(255), + 891: uint8(255), + 892: uint8(15), + 894: uint8(255), + 895: uint8(255), + 896: uint8(255), + 897: uint8(255), + 898: uint8(255), + 899: uint8(127), + 900: uint8(255), + 901: uint8(255), + 902: uint8(255), + 903: uint8(255), + 904: uint8(255), + 906: uint8(255), + 907: uint8(255), + 908: uint8(255), + 909: uint8(255), + 910: uint8(255), + 911: uint8(255), + 912: uint8(255), + 913: uint8(255), + 914: uint8(255), + 915: uint8(255), + 916: uint8(255), + 917: uint8(255), + 918: uint8(255), + 919: uint8(255), + 920: uint8(255), + 921: uint8(255), + 922: uint8(255), + 923: uint8(255), + 924: uint8(255), + 925: uint8(255), + 926: uint8(255), + 927: uint8(255), + 928: uint8(255), + 929: uint8(255), + 930: uint8(255), + 931: uint8(255), + 932: uint8(255), + 933: uint8(255), + 934: uint8(255), + 935: uint8(255), + 936: uint8(255), + 937: uint8(255), + 938: uint8(255), + 939: uint8(255), + 940: uint8(255), + 941: uint8(255), + 942: uint8(255), + 943: uint8(255), + 944: uint8(255), + 945: uint8(255), + 946: uint8(255), + 947: uint8(255), + 948: uint8(255), + 949: uint8(255), + 950: uint8(255), + 951: uint8(255), + 960: uint8(255), + 961: uint8(255), + 962: uint8(255), + 963: uint8(255), + 964: uint8(255), + 965: uint8(255), + 966: uint8(255), + 967: uint8(255), + 968: uint8(255), + 969: uint8(255), + 970: uint8(255), + 971: uint8(255), + 972: uint8(255), + 973: uint8(255), + 974: uint8(255), + 975: uint8(255), + 976: uint8(255), + 977: uint8(31), + 978: uint8(255), + 979: uint8(255), + 980: uint8(255), + 981: uint8(255), + 982: uint8(255), + 983: uint8(255), + 984: uint8(127), + 1004: uint8(255), + 1005: uint8(255), + 1006: uint8(255), + 1007: uint8(31), + 1024: uint8(255), + 1025: uint8(255), + 1026: uint8(255), + 1027: uint8(255), + 1028: uint8(255), + 1029: uint8(255), + 1030: uint8(255), + 1031: uint8(255), + 1032: uint8(255), + 1033: uint8(255), + 1034: uint8(255), + 1035: uint8(255), + 1036: uint8(255), + 1037: uint8(255), + 1038: uint8(255), + 1039: uint8(255), + 1040: uint8(255), + 1041: uint8(255), + 1042: uint8(255), + 1043: uint8(255), + 1044: uint8(15), + 1058: uint8(255), + 1059: uint8(3), + 1062: uint8(255), + 1063: uint8(255), + 1064: uint8(255), + 1065: uint8(255), + 1066: uint8(247), + 1067: uint8(255), + 1068: uint8(127), + 1069: uint8(15), + 1088: uint8(254), + 1089: uint8(255), + 1090: uint8(255), + 1091: uint8(255), + 1092: uint8(255), + 1093: uint8(255), + 1094: uint8(255), + 1095: uint8(255), + 1096: uint8(255), + 1097: uint8(255), + 1098: uint8(255), + 1099: uint8(255), + 1100: uint8(1), + 1116: uint8(127), + 1148: uint8(15), + 1152: uint8(255), + 1153: uint8(255), + 1154: uint8(255), + 1155: uint8(255), + 1156: uint8(255), + 1157: uint8(255), + 1158: uint8(255), + 1159: uint8(255), + 1160: uint8(255), + 1161: uint8(255), + 1162: uint8(255), + 1163: uint8(255), + 1164: uint8(255), + 1165: uint8(255), + 1166: uint8(255), + 1167: uint8(255), + 1168: uint8(255), + 1169: uint8(255), + 1170: uint8(255), + 1171: uint8(255), + 1172: uint8(255), + 1173: uint8(255), + 1174: uint8(255), + 1175: uint8(255), + 1176: uint8(255), + 1177: uint8(255), + 1178: uint8(255), + 1179: uint8(255), + 1180: uint8(255), + 1181: uint8(255), + 1182: uint8(255), + 1184: uint8(255), + 1185: uint8(255), + 1186: uint8(255), + 1187: uint8(255), + 1188: uint8(255), + 1189: uint8(255), + 1190: uint8(255), + 1191: uint8(255), + 1192: uint8(255), + 1193: uint8(255), + 1194: uint8(255), + 1195: uint8(255), + 1196: uint8(255), + 1197: uint8(255), + 1198: uint8(255), + 1199: uint8(255), + 1200: uint8(255), + 1201: uint8(255), + 1202: uint8(255), + 1203: uint8(255), + 1204: uint8(255), + 1205: uint8(255), + 1206: uint8(255), + 1207: uint8(255), + 1208: uint8(255), + 1209: uint8(255), + 1210: uint8(255), + 1211: uint8(255), + 1212: uint8(255), + 1213: uint8(255), + 1214: uint8(7), + 1216: uint8(255), + 1217: uint8(255), + 1218: uint8(255), + 1219: uint8(127), + 1226: uint8(7), + 1228: uint8(240), + 1230: uint8(255), + 1231: uint8(255), + 1232: uint8(255), + 1233: uint8(255), + 1234: uint8(255), + 1235: uint8(255), + 1236: uint8(255), + 1237: uint8(255), + 1238: uint8(255), + 1239: uint8(255), + 1240: uint8(255), + 1241: uint8(255), + 1242: uint8(255), + 1243: uint8(255), + 1244: uint8(255), + 1245: uint8(255), + 1246: uint8(255), + 1247: uint8(255), + 1248: uint8(255), + 1249: uint8(255), + 1250: uint8(255), + 1251: uint8(255), + 1252: uint8(255), + 1253: uint8(255), + 1254: uint8(255), + 1255: uint8(255), + 1256: uint8(255), + 1257: uint8(255), + 1258: uint8(255), + 1259: uint8(255), + 1260: uint8(255), + 1261: uint8(255), + 1262: uint8(255), + 1263: uint8(255), + 1264: uint8(255), + 1265: uint8(255), + 1266: uint8(255), + 1267: uint8(255), + 1268: uint8(255), + 1269: uint8(255), + 1270: uint8(255), + 1271: uint8(255), + 1272: uint8(255), + 1273: uint8(255), + 1274: uint8(255), + 1275: uint8(255), + 1276: uint8(255), + 1277: uint8(255), + 1278: uint8(255), + 1279: uint8(15), + 1280: uint8(16), + 1305: uint8(128), + 1329: uint8(64), + 1330: uint8(254), + 1331: uint8(7), + 1344: uint8(7), + 1346: uint8(255), + 1347: uint8(255), + 1348: uint8(255), + 1349: uint8(255), + 1350: uint8(255), + 1351: uint8(15), + 1352: uint8(255), + 1353: uint8(1), + 1354: uint8(3), + 1356: uint8(63), + 1376: uint8(255), + 1377: uint8(255), + 1378: uint8(255), + 1379: uint8(255), + 1380: uint8(1), + 1381: uint8(224), + 1382: uint8(191), + 1383: uint8(255), + 1384: uint8(255), + 1385: uint8(255), + 1386: uint8(255), + 1387: uint8(255), + 1388: uint8(255), + 1389: uint8(255), + 1390: uint8(255), + 1391: uint8(223), + 1392: uint8(255), + 1393: uint8(255), + 1394: uint8(15), + 1396: uint8(255), + 1397: uint8(255), + 1398: uint8(255), + 1399: uint8(255), + 1400: uint8(255), + 1401: uint8(135), + 1402: uint8(15), + 1404: uint8(255), + 1405: uint8(255), + 1406: uint8(17), + 1407: uint8(255), + 1408: uint8(255), + 1409: uint8(255), + 1410: uint8(255), + 1411: uint8(255), + 1412: uint8(255), + 1413: uint8(255), + 1414: uint8(255), + 1415: uint8(127), + 1416: uint8(253), + 1417: uint8(255), + 1418: uint8(255), + 1419: uint8(255), + 1420: uint8(255), + 1421: uint8(255), + 1422: uint8(255), + 1423: uint8(255), + 1424: uint8(255), + 1425: uint8(255), + 1426: uint8(255), + 1427: uint8(255), + 1428: uint8(255), + 1429: uint8(255), + 1430: uint8(255), + 1431: uint8(255), + 1432: uint8(255), + 1433: uint8(255), + 1434: uint8(255), + 1435: uint8(255), + 1436: uint8(255), + 1437: uint8(255), + 1438: uint8(255), + 1439: uint8(159), + 1440: uint8(255), + 1441: uint8(255), + 1442: uint8(255), + 1443: uint8(255), + 1444: uint8(255), + 1445: uint8(255), + 1446: uint8(255), + 1447: uint8(63), + 1449: uint8(120), + 1450: uint8(255), + 1451: uint8(255), + 1452: uint8(255), + 1455: uint8(4), + 1458: uint8(96), + 1460: uint8(16), + 1471: uint8(248), + 1472: uint8(255), + 1473: uint8(255), + 1474: uint8(255), + 1475: uint8(255), + 1476: uint8(255), + 1477: uint8(255), + 1478: uint8(255), + 1479: uint8(255), + 1480: uint8(255), + 1481: uint8(255), + 1488: uint8(255), + 1489: uint8(255), + 1490: uint8(255), + 1491: uint8(255), + 1492: uint8(255), + 1493: uint8(255), + 1494: uint8(255), + 1495: uint8(255), + 1496: uint8(63), + 1497: uint8(16), + 1498: uint8(39), + 1501: uint8(24), + 1502: uint8(240), + 1503: uint8(7), + 1532: uint8(255), + 1533: uint8(15), + 1537: uint8(224), + 1538: uint8(255), + 1539: uint8(255), + 1540: uint8(255), + 1541: uint8(255), + 1542: uint8(255), + 1543: uint8(255), + 1544: uint8(255), + 1545: uint8(255), + 1546: uint8(255), + 1547: uint8(255), + 1548: uint8(255), + 1549: uint8(255), + 1550: uint8(123), + 1551: uint8(252), + 1552: uint8(255), + 1553: uint8(255), + 1554: uint8(255), + 1555: uint8(255), + 1556: uint8(231), + 1557: uint8(199), + 1558: uint8(255), + 1559: uint8(255), + 1560: uint8(255), + 1561: uint8(231), + 1562: uint8(255), + 1563: uint8(255), + 1564: uint8(255), + 1565: uint8(255), + 1566: uint8(255), + 1567: uint8(255), + 1582: uint8(15), + 1583: uint8(7), + 1584: uint8(7), + 1586: uint8(63), +} + +func Xwcwidth(tls *TLS, wc Twchar_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v, (%v:)", tls, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v2 int32 + _, _ = v1, v2 + if wc < uint32(0xff) { + if (wc+uint32(1))&uint32(0x7f) >= uint32(0x21) { + v1 = int32(1) + } else { + if wc != 0 { + v2 = -int32(1) + } else { + v2 = 0 + } + v1 = v2 + } + return v1 + } + if wc&uint32(0xfffeffff) < uint32(0xfffe) { + if Int32FromUint8(_table5[Uint32FromInt32(Int32FromUint8(_table5[wc>>int32(8)])*int32(32))+wc&uint32(255)>>int32(3)])>>(wc&uint32(7))&int32(1) != 0 { + return 0 + } + if Int32FromUint8(_wtable[Uint32FromInt32(Int32FromUint8(_wtable[wc>>int32(8)])*int32(32))+wc&uint32(255)>>int32(3)])>>(wc&uint32(7))&int32(1) != 0 { + return int32(2) + } + return int32(1) + } + if wc&uint32(0xfffe) == uint32(0xfffe) { + return -int32(1) + } + if wc-uint32(0x20000) < uint32(0x20000) { + return int32(2) + } + if wc == uint32(0xe0001) || wc-uint32(0xe0020) < uint32(0x5f) || wc-uint32(0xe0100) < uint32(0xef) { + return 0 + } + return int32(1) +} + +const d_fileno = 0 + +type Tino_t = uint64 + +type Tdirent = struct { + Fd_ino Tino_t + Fd_off Toff_t + Fd_reclen uint16 + Fd_type uint8 + Fd_name [256]uint8 +} + +func Xalphasort(tls *TLS, a uintptr, b uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrcoll(tls, **(**uintptr)(__ccgo_up(a))+19, **(**uintptr)(__ccgo_up(b))+19) +} + +type TDIR = struct { + Ftell Toff_t + Ffd int32 + Fbuf_pos int32 + Fbuf_end int32 + Flock [1]int32 + Fbuf [2048]uint8 +} + +type t__dirstream = TDIR + +func Xclosedir(tls *TLS, dir uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + ret = Xclose(tls, (*TDIR)(unsafe.Pointer(dir)).Ffd) + Xfree(tls, dir) + return ret +} + +func Xdirfd(tls *TLS, d uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v d=%v, (%v:)", tls, d, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*TDIR)(unsafe.Pointer(d)).Ffd +} + +const AT_EACCESS = 512 +const AT_FDCWD = -100 +const AT_REMOVEDIR = 512 +const AT_SYMLINK_FOLLOW = 1024 +const AT_SYMLINK_NOFOLLOW = 256 +const FD_CLOEXEC = 1 +const F_DUPFD = 0 +const F_DUPFD_CLOEXEC = 1030 +const F_GETFD = 1 +const F_GETFL = 3 +const F_GETLK = 5 +const F_GETOWN = 9 +const F_GETOWNER_UIDS = 17 +const F_GETOWN_EX = 16 +const F_GETSIG = 11 +const F_OFD_GETLK = 36 +const F_OFD_SETLK = 37 +const F_OFD_SETLKW = 38 +const F_RDLCK = 0 +const F_SETFD = 2 +const F_SETFL = 4 +const F_SETLK = 6 +const F_SETLKW = 7 +const F_SETOWN = 8 +const F_SETOWN_EX = 15 +const F_SETSIG = 10 +const F_UNLCK = 2 +const F_WRLCK = 1 +const O_ACCMODE = 2097155 +const O_APPEND = 1024 +const O_ASYNC = 8192 +const O_CLOEXEC = 524288 +const O_CREAT = 64 +const O_DIRECT = 65536 +const O_DIRECTORY = 16384 +const O_DSYNC = 4096 +const O_EXCL = 128 +const O_EXEC = 2097152 +const O_LARGEFILE = 131072 +const O_NDELAY = 2048 +const O_NOATIME = 262144 +const O_NOCTTY = 256 +const O_NOFOLLOW = 32768 +const O_NONBLOCK = 2048 +const O_PATH = 2097152 +const O_RDONLY = 0 +const O_RDWR = 2 +const O_RSYNC = 1052672 +const O_SEARCH = 2097152 +const O_SYNC = 1052672 +const O_TMPFILE = 4210688 +const O_TRUNC = 512 +const O_TTY_INIT = 0 +const O_WRONLY = 1 +const POSIX_FADV_DONTNEED = 4 +const POSIX_FADV_NOREUSE = 5 +const POSIX_FADV_NORMAL = 0 +const POSIX_FADV_RANDOM = 1 +const POSIX_FADV_SEQUENTIAL = 2 +const POSIX_FADV_WILLNEED = 3 +const S_IFBLK = 24576 +const S_IFCHR = 8192 +const S_IFDIR = 16384 +const S_IFIFO = 4096 +const S_IFLNK = 40960 +const S_IFMT = 61440 +const S_IFREG = 32768 +const S_IFSOCK = 49152 +const S_IRGRP = 32 +const S_IROTH = 4 +const S_IRUSR = 256 +const S_IRWXG = 56 +const S_IRWXO = 7 +const S_IRWXU = 448 +const S_ISGID = 1024 +const S_ISUID = 2048 +const S_ISVTX = 512 +const S_IWGRP = 16 +const S_IWOTH = 2 +const S_IWUSR = 128 +const S_IXGRP = 8 +const S_IXOTH = 1 +const S_IXUSR = 64 +const UTIME_NOW = 1073741823 +const UTIME_OMIT = 1073741822 + +type Tflock = struct { + Fl_type int16 + Fl_whence int16 + Fl_start Toff_t + Fl_len Toff_t + Fl_pid Tpid_t +} + +type Tblksize_t = int32 + +type Tnlink_t = uint32 + +type Tdev_t = uint64 + +type Tblkcnt_t = int64 + +type Tstat = struct { + Fst_dev Tdev_t + Fst_ino Tino_t + Fst_mode Tmode_t + Fst_nlink Tnlink_t + Fst_uid Tuid_t + Fst_gid Tgid_t + Fst_rdev Tdev_t + F__pad uint64 + Fst_size Toff_t + Fst_blksize Tblksize_t + F__pad2 int32 + Fst_blocks Tblkcnt_t + Fst_atim Ttimespec + Fst_mtim Ttimespec + Fst_ctim Ttimespec + F__unused [2]uint32 +} + +func Xfdopendir(tls *TLS, fd int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var dir, v1 uintptr + var _ /* st at bp+0 */ Tstat + _, _ = dir, v1 + if Xfstat(tls, fd, bp) < 0 { + return uintptr(0) + } + if Xfcntl(tls, fd, int32(F_GETFL), 0)&int32(O_PATH) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EBADF) + return uintptr(0) + } + if !((**(**Tstat)(__ccgo_up(bp))).Fst_mode&Uint32FromInt32(S_IFMT) == Uint32FromInt32(S_IFDIR)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOTDIR) + return uintptr(0) + } + v1 = Xcalloc(tls, uint64(1), uint64(2072)) + dir = v1 + if !(v1 != 0) { + return uintptr(0) + } + Xfcntl(tls, fd, int32(F_SETFD), VaList(bp+136, int32(FD_CLOEXEC))) + (*TDIR)(unsafe.Pointer(dir)).Ffd = fd + return dir +} + +const AT_EMPTY_PATH = 4096 +const AT_NO_AUTOMOUNT = 2048 +const AT_RECURSIVE = 32768 +const AT_STATX_DONT_SYNC = 16384 +const AT_STATX_FORCE_SYNC = 8192 +const AT_STATX_SYNC_AS_STAT = 0 +const AT_STATX_SYNC_TYPE = 24576 +const DN_ACCESS = 1 +const DN_ATTRIB = 32 +const DN_CREATE = 4 +const DN_DELETE = 8 +const DN_MODIFY = 2 +const DN_MULTISHOT = 2147483648 +const DN_RENAME = 16 +const DT_BLK = 6 +const DT_CHR = 2 +const DT_DIR = 4 +const DT_FIFO = 1 +const DT_LNK = 10 +const DT_REG = 8 +const DT_SOCK = 12 +const DT_UNKNOWN = 0 +const DT_WHT = 14 +const FALLOC_FL_KEEP_SIZE = 1 +const FALLOC_FL_PUNCH_HOLE = 2 +const FAPPEND = 1024 +const FASYNC = 8192 +const FFSYNC = 1052672 +const FNDELAY = 2048 +const FNONBLOCK = 2048 +const F_ADD_SEALS = 1033 +const F_CANCELLK = 1029 +const F_GETLEASE = 1025 +const F_GETPIPE_SZ = 1032 +const F_GET_FILE_RW_HINT = 1037 +const F_GET_RW_HINT = 1035 +const F_GET_SEALS = 1034 +const F_NOTIFY = 1026 +const F_OWNER_GID = 2 +const F_OWNER_PGRP = 2 +const F_OWNER_PID = 1 +const F_OWNER_TID = 0 +const F_SEAL_FUTURE_WRITE = 16 +const F_SEAL_GROW = 4 +const F_SEAL_SEAL = 1 +const F_SEAL_SHRINK = 2 +const F_SEAL_WRITE = 8 +const F_SETLEASE = 1024 +const F_SETPIPE_SZ = 1031 +const F_SET_FILE_RW_HINT = 1038 +const F_SET_RW_HINT = 1036 +const MAX_HANDLE_SZ = 128 +const RWF_WRITE_LIFE_NOT_SET = 0 +const RWH_WRITE_LIFE_EXTREME = 5 +const RWH_WRITE_LIFE_LONG = 4 +const RWH_WRITE_LIFE_MEDIUM = 3 +const RWH_WRITE_LIFE_NONE = 1 +const RWH_WRITE_LIFE_SHORT = 2 +const SPLICE_F_GIFT = 8 +const SPLICE_F_MORE = 4 +const SPLICE_F_MOVE = 1 +const SPLICE_F_NONBLOCK = 2 +const SYNC_FILE_RANGE_WAIT_AFTER = 4 +const SYNC_FILE_RANGE_WAIT_BEFORE = 1 +const SYNC_FILE_RANGE_WRITE = 2 +const alloca = 0 +const loff_t = 0 + +type Tiovec = struct { + Fiov_base uintptr + Fiov_len Tsize_t +} + +type Tfile_handle = struct { + Fhandle_bytes uint32 + Fhandle_type int32 +} + +type Tf_owner_ex = struct { + Ftype1 int32 + Fpid Tpid_t +} + +func Xopendir(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var dir, v2 uintptr + var fd, v1 int32 + _, _, _, _ = dir, fd, v1, v2 + v1 = Xopen(tls, name, Int32FromInt32(O_RDONLY)|Int32FromInt32(O_DIRECTORY)|Int32FromInt32(O_CLOEXEC), 0) + fd = v1 + if v1 < 0 { + return uintptr(0) + } + v2 = Xcalloc(tls, uint64(1), uint64(2072)) + dir = v2 + if !(v2 != 0) { + X__syscall1(tls, int64(SYS_close), int64(fd)) + return uintptr(0) + } + (*TDIR)(unsafe.Pointer(dir)).Ffd = fd + return dir +} + +type Tptrdiff_t = int64 + +type Tdirstream_buf_alignment_check = [1]uint8 + +func Xreaddir(tls *TLS, dir uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2)) + defer func() { trc("-> %v", r) }() + } + var de uintptr + var len1 int32 + _, _ = de, len1 + if (*TDIR)(unsafe.Pointer(dir)).Fbuf_pos >= (*TDIR)(unsafe.Pointer(dir)).Fbuf_end { + len1 = int32(X__syscall3(tls, int64(SYS_getdents64), int64((*TDIR)(unsafe.Pointer(dir)).Ffd), int64(dir+24), Int64FromUint64(Uint64FromInt64(2048)))) + if len1 <= 0 { + if len1 < 0 && len1 != -int32(ENOENT) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = -len1 + } + return uintptr(0) + } + (*TDIR)(unsafe.Pointer(dir)).Fbuf_end = len1 + (*TDIR)(unsafe.Pointer(dir)).Fbuf_pos = 0 + } + de = dir + 24 + uintptr((*TDIR)(unsafe.Pointer(dir)).Fbuf_pos) + **(**int32)(__ccgo_up(dir + 12)) += Int32FromUint16((*Tdirent)(unsafe.Pointer(de)).Fd_reclen) + (*TDIR)(unsafe.Pointer(dir)).Ftell = (*Tdirent)(unsafe.Pointer(de)).Fd_off + return de +} + +func Xreaddir_r(tls *TLS, dir uintptr, buf uintptr, result uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dir=%v buf=%v result=%v, (%v:)", tls, dir, buf, result, origin(2)) + defer func() { trc("-> %v", r) }() + } + var de uintptr + var errno_save, ret, v1 int32 + _, _, _, _ = de, errno_save, ret, v1 + errno_save = **(**int32)(__ccgo_up(X__errno_location(tls))) + ___lock(tls, dir+20) + **(**int32)(__ccgo_up(X__errno_location(tls))) = 0 + de = Xreaddir(tls, dir) + v1 = **(**int32)(__ccgo_up(X__errno_location(tls))) + ret = v1 + if v1 != 0 { + ___unlock(tls, dir+20) + return ret + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = errno_save + if de != 0 { + Xmemcpy(tls, buf, de, uint64((*Tdirent)(unsafe.Pointer(de)).Fd_reclen)) + } else { + buf = UintptrFromInt32(0) + } + ___unlock(tls, dir+20) + **(**uintptr)(__ccgo_up(result)) = buf + return 0 +} + +func Xrewinddir(tls *TLS, dir uintptr) { + if __ccgo_strace { + trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2)) + } + var v1 int32 + _ = v1 + ___lock(tls, dir+20) + Xlseek(tls, (*TDIR)(unsafe.Pointer(dir)).Ffd, 0, SEEK_SET) + v1 = Int32FromInt32(0) + (*TDIR)(unsafe.Pointer(dir)).Fbuf_end = v1 + (*TDIR)(unsafe.Pointer(dir)).Fbuf_pos = v1 + (*TDIR)(unsafe.Pointer(dir)).Ftell = 0 + ___unlock(tls, dir+20) +} + +type t__ccgo_fp__Xscandir_2 = func(*TLS, uintptr) int32 + +type t__ccgo_fp__Xscandir_3 = func(*TLS, uintptr, uintptr) int32 + +func Xscandir(tls *TLS, path uintptr, res uintptr, __ccgo_fp_sel uintptr, __ccgo_fp_cmp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v res=%v __ccgo_fp_sel=%v __ccgo_fp_cmp=%v, (%v:)", tls, path, res, __ccgo_fp_sel, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var cnt, len1, v2 Tsize_t + var d, de, names, tmp, v1 uintptr + var old_errno int32 + _, _, _, _, _, _, _, _, _ = cnt, d, de, len1, names, old_errno, tmp, v1, v2 + d = Xopendir(tls, path) + names = uintptr(0) + cnt = uint64(0) + len1 = uint64(0) + old_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + if !(d != 0) { + return -int32(1) + } + for { + **(**int32)(__ccgo_up(X__errno_location(tls))) = 0 + v1 = Xreaddir(tls, d) + de = v1 + if !(v1 != 0) { + break + } + if __ccgo_fp_sel != 0 && !((*(*func(*TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_sel})))(tls, de) != 0) { + continue + } + if cnt >= len1 { + len1 = uint64(2)*len1 + uint64(1) + if len1 > Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt64(8) { + break + } + tmp = Xrealloc(tls, names, len1*uint64(8)) + if !(tmp != 0) { + break + } + names = tmp + } + **(**uintptr)(__ccgo_up(names + uintptr(cnt)*8)) = Xmalloc(tls, uint64((*Tdirent)(unsafe.Pointer(de)).Fd_reclen)) + if !(**(**uintptr)(__ccgo_up(names + uintptr(cnt)*8)) != 0) { + break + } + v2 = cnt + cnt = cnt + 1 + Xmemcpy(tls, **(**uintptr)(__ccgo_up(names + uintptr(v2)*8)), de, uint64((*Tdirent)(unsafe.Pointer(de)).Fd_reclen)) + } + Xclosedir(tls, d) + if **(**int32)(__ccgo_up(X__errno_location(tls))) != 0 { + if names != 0 { + for { + v2 = cnt + cnt = cnt - 1 + if !(v2 > uint64(0)) { + break + } + Xfree(tls, **(**uintptr)(__ccgo_up(names + uintptr(cnt)*8))) + } + } + Xfree(tls, names) + return -int32(1) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + if __ccgo_fp_cmp != 0 { + Xqsort(tls, names, cnt, uint64(8), __ccgo_fp_cmp) + } + **(**uintptr)(__ccgo_up(res)) = names + return Int32FromUint64(cnt) +} + +func Xseekdir(tls *TLS, dir uintptr, off int64) { + if __ccgo_strace { + trc("tls=%v dir=%v off=%v, (%v:)", tls, dir, off, origin(2)) + } + var v1 int32 + _ = v1 + ___lock(tls, dir+20) + (*TDIR)(unsafe.Pointer(dir)).Ftell = Xlseek(tls, (*TDIR)(unsafe.Pointer(dir)).Ffd, off, SEEK_SET) + v1 = Int32FromInt32(0) + (*TDIR)(unsafe.Pointer(dir)).Fbuf_end = v1 + (*TDIR)(unsafe.Pointer(dir)).Fbuf_pos = v1 + ___unlock(tls, dir+20) +} + +func Xtelldir(tls *TLS, dir uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*TDIR)(unsafe.Pointer(dir)).Ftell +} + +func Xversionsort(tls *TLS, a uintptr, b uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrverscmp(tls, **(**uintptr)(__ccgo_up(a))+19, **(**uintptr)(__ccgo_up(b))+19) +} + +func X__reset_tls(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + var i, n Tsize_t + var mem, p uintptr + var self Tpthread_t + _, _, _, _, _ = i, mem, n, p, self + self = uintptr(___get_tp(tls)) + n = **(**Tuintptr_t)(__ccgo_up((*t__pthread)(unsafe.Pointer(self)).Fdtv)) + if n != 0 { + p = X__libc.Ftls_head + i = Uint64FromInt32(1) + for { + if !(i <= n) { + break + } + mem = uintptr(**(**Tuintptr_t)(__ccgo_up((*t__pthread)(unsafe.Pointer(self)).Fdtv + uintptr(i)*8)) - Uint64FromInt32(DTP_OFFSET)) + Xmemcpy(tls, mem, (*Ttls_module)(unsafe.Pointer(p)).Fimage, (*Ttls_module)(unsafe.Pointer(p)).Flen1) + Xmemset(tls, mem+uintptr((*Ttls_module)(unsafe.Pointer(p)).Flen1), 0, (*Ttls_module)(unsafe.Pointer(p)).Fsize-(*Ttls_module)(unsafe.Pointer(p)).Flen1) + goto _1 + _1: + ; + i = i + 1 + p = (*Ttls_module)(unsafe.Pointer(p)).Fnext + } + } +} + +func X__init_ssp(tls *TLS, entropy uintptr) { + if __ccgo_strace { + trc("tls=%v entropy=%v, (%v:)", tls, entropy, origin(2)) + } + if entropy != 0 { + Xmemcpy(tls, uintptr(unsafe.Pointer(&X__stack_chk_guard)), entropy, uint64(8)) + } else { + X__stack_chk_guard = Tuintptr_t(uintptr(unsafe.Pointer(&X__stack_chk_guard))) * uint64(1103515245) + } + /* Sacrifice 8 bits of entropy on 64bit to prevent leaking/ + * overwriting the canary via string-manipulation functions. + * The NULL byte is on the second byte so that off-by-ones can + * still be detected. Endianness is taken care of + * automatically. */ + **(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&X__stack_chk_guard)) + 1)) = uint8(0) + (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Fcanary = X__stack_chk_guard +} + +func X__stack_chk_fail(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + **(**uint8)(__ccgo_up(UintptrFromInt32(0))) = uint8(0) +} + +func X__stack_chk_fail_local(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__stack_chk_fail(tls) +} + +const L_INCR = 1 +const L_SET = 0 +const L_XTND = 2 + +func _dummy(tls *TLS, old uintptr, new1 uintptr) { +} + +func Xclearenv(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var e, v1 uintptr + _, _ = e, v1 + e = Xenviron + Xenviron = uintptr(0) + if e != 0 { + for **(**uintptr)(__ccgo_up(e)) != 0 { + v1 = e + e += 8 + X__env_rm_add(tls, **(**uintptr)(__ccgo_up(v1)), uintptr(0)) + } + } + return 0 +} + +func Xgetenv(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var e uintptr + var l Tsize_t + _, _ = e, l + l = Uint64FromInt64(int64(X__strchrnul(tls, name, int32('='))) - int64(name)) + if l != 0 && !(**(**uint8)(__ccgo_up(name + uintptr(l))) != 0) && Xenviron != 0 { + e = Xenviron + for { + if !(**(**uintptr)(__ccgo_up(e)) != 0) { + break + } + if !(Xstrncmp(tls, name, **(**uintptr)(__ccgo_up(e)), l) != 0) && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(e)) + uintptr(l)))) == int32('=') { + return **(**uintptr)(__ccgo_up(e)) + uintptr(l) + uintptr(1) + } + goto _1 + _1: + ; + e += 8 + } + } + return uintptr(0) +} + +func _dummy1(tls *TLS, old uintptr, new1 uintptr) { +} + +func X__putenv(tls *TLS, s uintptr, l Tsize_t, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v r=%v, (%v:)", tls, s, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var e, newenv, tmp, v2 uintptr + var i Tsize_t + _, _, _, _, _ = e, i, newenv, tmp, v2 + i = uint64(0) + if Xenviron != 0 { + e = Xenviron + for { + if !(**(**uintptr)(__ccgo_up(e)) != 0) { + break + } + if !(Xstrncmp(tls, s, **(**uintptr)(__ccgo_up(e)), l+uint64(1)) != 0) { + tmp = **(**uintptr)(__ccgo_up(e)) + **(**uintptr)(__ccgo_up(e)) = s + X__env_rm_add(tls, tmp, r) + return 0 + } + goto _1 + _1: + ; + e += 8 + i = i + 1 + } + } + if Xenviron == _oldenv { + newenv = Xrealloc(tls, _oldenv, uint64(8)*(i+uint64(2))) + if !(newenv != 0) { + goto oom + } + } else { + newenv = Xmalloc(tls, uint64(8)*(i+uint64(2))) + if !(newenv != 0) { + goto oom + } + if i != 0 { + Xmemcpy(tls, newenv, Xenviron, uint64(8)*i) + } + Xfree(tls, _oldenv) + } + **(**uintptr)(__ccgo_up(newenv + uintptr(i)*8)) = s + **(**uintptr)(__ccgo_up(newenv + uintptr(i+uint64(1))*8)) = uintptr(0) + v2 = newenv + _oldenv = v2 + Xenviron = v2 + if r != 0 { + X__env_rm_add(tls, uintptr(0), r) + } + return 0 + goto oom +oom: + ; + Xfree(tls, r) + return -int32(1) +} + +var _oldenv uintptr + +func Xputenv(tls *TLS, s uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = Uint64FromInt64(int64(X__strchrnul(tls, s, int32('='))) - int64(s)) + if !(l != 0) || !(**(**uint8)(__ccgo_up(s + uintptr(l))) != 0) { + return Xunsetenv(tls, s) + } + return X__putenv(tls, s, l, uintptr(0)) +} + +const L_cuserid = 20 +const NL_NMAX = 16 + +type Tcookie_io_functions_t = struct { + Fread uintptr + Fwrite uintptr + Fseek uintptr + Fclose1 uintptr +} + +type T_IO_cookie_io_functions_t = Tcookie_io_functions_t + +func Xsecure_getenv(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + if X__libc.Fsecure != 0 { + v1 = UintptrFromInt32(0) + } else { + v1 = Xgetenv(tls, name) + } + return v1 +} + +func X__env_rm_add(tls *TLS, old uintptr, new1 uintptr) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v, (%v:)", tls, old, new1, origin(2)) + } + var i, v3 Tsize_t + var t, v2 uintptr + _, _, _, _ = i, t, v2, v3 + i = uint64(0) + for { + if !(i < _env_alloced_n) { + break + } + if **(**uintptr)(__ccgo_up(_env_alloced + uintptr(i)*8)) == old { + **(**uintptr)(__ccgo_up(_env_alloced + uintptr(i)*8)) = new1 + Xfree(tls, old) + return + } else { + if !(**(**uintptr)(__ccgo_up(_env_alloced + uintptr(i)*8)) != 0) && new1 != 0 { + **(**uintptr)(__ccgo_up(_env_alloced + uintptr(i)*8)) = new1 + new1 = uintptr(0) + } + } + goto _1 + _1: + ; + i = i + 1 + } + if !(new1 != 0) { + return + } + t = Xrealloc(tls, _env_alloced, uint64(8)*(_env_alloced_n+uint64(1))) + if !(t != 0) { + return + } + v2 = t + _env_alloced = v2 + v3 = _env_alloced_n + _env_alloced_n = _env_alloced_n + 1 + **(**uintptr)(__ccgo_up(v2 + uintptr(v3)*8)) = new1 +} + +var _env_alloced uintptr + +var _env_alloced_n Tsize_t + +func Xsetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) (r int32) { + if __ccgo_strace { + trc("tls=%v var1=%v value=%v overwrite=%v, (%v:)", tls, var1, value, overwrite, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l1, l2, v1 Tsize_t + var s uintptr + var v2 bool + _, _, _, _, _ = l1, l2, s, v1, v2 + if v2 = !(var1 != 0); !v2 { + v1 = Uint64FromInt64(int64(X__strchrnul(tls, var1, int32('='))) - int64(var1)) + l1 = v1 + } + if v2 || !(v1 != 0) || **(**uint8)(__ccgo_up(var1 + uintptr(l1))) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + if !(overwrite != 0) && Xgetenv(tls, var1) != 0 { + return 0 + } + l2 = _strlen(tls, value) + s = Xmalloc(tls, l1+l2+uint64(2)) + if !(s != 0) { + return -int32(1) + } + Xmemcpy(tls, s, var1, l1) + **(**uint8)(__ccgo_up(s + uintptr(l1))) = uint8('=') + Xmemcpy(tls, s+uintptr(l1)+uintptr(1), value, l2+uint64(1)) + return X__putenv(tls, s, l1, s) +} + +func _dummy2(tls *TLS, old uintptr, new1 uintptr) { +} + +func Xunsetenv(tls *TLS, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var e, eo, v2 uintptr + var l Tsize_t + _, _, _, _ = e, eo, l, v2 + l = Uint64FromInt64(int64(X__strchrnul(tls, name, int32('='))) - int64(name)) + if !(l != 0) || **(**uint8)(__ccgo_up(name + uintptr(l))) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + if Xenviron != 0 { + e = Xenviron + eo = e + for { + if !(**(**uintptr)(__ccgo_up(e)) != 0) { + break + } + if !(Xstrncmp(tls, name, **(**uintptr)(__ccgo_up(e)), l) != 0) && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(e)) + uintptr(l)))) == int32('=') { + X__env_rm_add(tls, **(**uintptr)(__ccgo_up(e)), uintptr(0)) + } else { + if eo != e { + v2 = eo + eo += 8 + **(**uintptr)(__ccgo_up(v2)) = **(**uintptr)(__ccgo_up(e)) + } else { + eo += 8 + } + } + goto _1 + _1: + ; + e += 8 + } + if eo != e { + **(**uintptr)(__ccgo_up(eo)) = uintptr(0) + } + } + return 0 +} + +/* mips has one error code outside of the 8-bit range due to a + * historical typo, so we just remap it. */ + +type Terrmsgstr_t = struct { + Fstr0 [21]uint8 + FstrEILSEQ [22]uint8 + FstrEDOM [13]uint8 + FstrERANGE [25]uint8 + FstrENOTTY [10]uint8 + FstrEACCES [18]uint8 + FstrEPERM [24]uint8 + FstrENOENT [26]uint8 + FstrESRCH [16]uint8 + FstrEEXIST [12]uint8 + FstrEOVERFLOW [30]uint8 + FstrENOSPC [24]uint8 + FstrENOMEM [14]uint8 + FstrEBUSY [14]uint8 + FstrEINTR [24]uint8 + FstrEAGAIN [33]uint8 + FstrESPIPE [13]uint8 + FstrEXDEV [18]uint8 + FstrEROFS [22]uint8 + FstrENOTEMPTY [20]uint8 + FstrECONNRESET [25]uint8 + FstrETIMEDOUT [20]uint8 + FstrECONNREFUSED [19]uint8 + FstrEHOSTDOWN [13]uint8 + FstrEHOSTUNREACH [20]uint8 + FstrEADDRINUSE [15]uint8 + FstrEPIPE [12]uint8 + FstrEIO [10]uint8 + FstrENXIO [26]uint8 + FstrENOTBLK [22]uint8 + FstrENODEV [15]uint8 + FstrENOTDIR [16]uint8 + FstrEISDIR [15]uint8 + FstrETXTBSY [15]uint8 + FstrENOEXEC [18]uint8 + FstrEINVAL [17]uint8 + FstrE2BIG [23]uint8 + FstrELOOP [19]uint8 + FstrENAMETOOLONG [18]uint8 + FstrENFILE [30]uint8 + FstrEMFILE [30]uint8 + FstrEBADF [20]uint8 + FstrECHILD [17]uint8 + FstrEFAULT [12]uint8 + FstrEFBIG [15]uint8 + FstrEMLINK [15]uint8 + FstrENOLCK [19]uint8 + FstrEDEADLK [30]uint8 + FstrENOTRECOVERABLE [22]uint8 + FstrEOWNERDEAD [20]uint8 + FstrECANCELED [19]uint8 + FstrENOSYS [25]uint8 + FstrENOMSG [27]uint8 + FstrEIDRM [19]uint8 + FstrENOSTR [20]uint8 + FstrENODATA [18]uint8 + FstrETIME [15]uint8 + FstrENOSR [25]uint8 + FstrENOLINK [22]uint8 + FstrEPROTO [15]uint8 + FstrEBADMSG [12]uint8 + FstrEBADFD [29]uint8 + FstrENOTSOCK [13]uint8 + FstrEDESTADDRREQ [29]uint8 + FstrEMSGSIZE [18]uint8 + FstrEPROTOTYPE [31]uint8 + FstrENOPROTOOPT [23]uint8 + FstrEPROTONOSUPPORT [23]uint8 + FstrESOCKTNOSUPPORT [26]uint8 + FstrENOTSUP [14]uint8 + FstrEPFNOSUPPORT [30]uint8 + FstrEAFNOSUPPORT [41]uint8 + FstrEADDRNOTAVAIL [22]uint8 + FstrENETDOWN [16]uint8 + FstrENETUNREACH [20]uint8 + FstrENETRESET [28]uint8 + FstrECONNABORTED [19]uint8 + FstrENOBUFS [26]uint8 + FstrEISCONN [20]uint8 + FstrENOTCONN [21]uint8 + FstrESHUTDOWN [34]uint8 + FstrEALREADY [30]uint8 + FstrEINPROGRESS [22]uint8 + FstrESTALE [18]uint8 + FstrEREMOTEIO [17]uint8 + FstrEDQUOT [15]uint8 + FstrENOMEDIUM [16]uint8 + FstrEMEDIUMTYPE [18]uint8 + FstrEMULTIHOP [19]uint8 + FstrENOKEY [27]uint8 + FstrEKEYEXPIRED [16]uint8 + FstrEKEYREVOKED [21]uint8 + FstrEKEYREJECTED [28]uint8 +} + +/* mips has one error code outside of the 8-bit range due to a + * historical typo, so we just remap it. */ + +var _errmsgstr = Terrmsgstr_t{ + Fstr0: [21]uint8{'N', 'o', ' ', 'e', 'r', 'r', 'o', 'r', ' ', 'i', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n'}, + FstrEILSEQ: [22]uint8{'I', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'b', 'y', 't', 'e', ' ', 's', 'e', 'q', 'u', 'e', 'n', 'c', 'e'}, + FstrEDOM: [13]uint8{'D', 'o', 'm', 'a', 'i', 'n', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrERANGE: [25]uint8{'R', 'e', 's', 'u', 'l', 't', ' ', 'n', 'o', 't', ' ', 'r', 'e', 'p', 'r', 'e', 's', 'e', 'n', 't', 'a', 'b', 'l', 'e'}, + FstrENOTTY: [10]uint8{'N', 'o', 't', ' ', 'a', ' ', 't', 't', 'y'}, + FstrEACCES: [18]uint8{'P', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n', ' ', 'd', 'e', 'n', 'i', 'e', 'd'}, + FstrEPERM: [24]uint8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'n', 'o', 't', ' ', 'p', 'e', 'r', 'm', 'i', 't', 't', 'e', 'd'}, + FstrENOENT: [26]uint8{'N', 'o', ' ', 's', 'u', 'c', 'h', ' ', 'f', 'i', 'l', 'e', ' ', 'o', 'r', ' ', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y'}, + FstrESRCH: [16]uint8{'N', 'o', ' ', 's', 'u', 'c', 'h', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's'}, + FstrEEXIST: [12]uint8{'F', 'i', 'l', 'e', ' ', 'e', 'x', 'i', 's', 't', 's'}, + FstrEOVERFLOW: [30]uint8{'V', 'a', 'l', 'u', 'e', ' ', 't', 'o', 'o', ' ', 'l', 'a', 'r', 'g', 'e', ' ', 'f', 'o', 'r', ' ', 'd', 'a', 't', 'a', ' ', 't', 'y', 'p', 'e'}, + FstrENOSPC: [24]uint8{'N', 'o', ' ', 's', 'p', 'a', 'c', 'e', ' ', 'l', 'e', 'f', 't', ' ', 'o', 'n', ' ', 'd', 'e', 'v', 'i', 'c', 'e'}, + FstrENOMEM: [14]uint8{'O', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y'}, + FstrEBUSY: [14]uint8{'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', ' ', 'b', 'u', 's', 'y'}, + FstrEINTR: [24]uint8{'I', 'n', 't', 'e', 'r', 'r', 'u', 'p', 't', 'e', 'd', ' ', 's', 'y', 's', 't', 'e', 'm', ' ', 'c', 'a', 'l', 'l'}, + FstrEAGAIN: [33]uint8{'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', ' ', 't', 'e', 'm', 'p', 'o', 'r', 'a', 'r', 'i', 'l', 'y', ' ', 'u', 'n', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrESPIPE: [13]uint8{'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 's', 'e', 'e', 'k'}, + FstrEXDEV: [18]uint8{'C', 'r', 'o', 's', 's', '-', 'd', 'e', 'v', 'i', 'c', 'e', ' ', 'l', 'i', 'n', 'k'}, + FstrEROFS: [22]uint8{'R', 'e', 'a', 'd', '-', 'o', 'n', 'l', 'y', ' ', 'f', 'i', 'l', 'e', ' ', 's', 'y', 's', 't', 'e', 'm'}, + FstrENOTEMPTY: [20]uint8{'D', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', ' ', 'n', 'o', 't', ' ', 'e', 'm', 'p', 't', 'y'}, + FstrECONNRESET: [25]uint8{'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'r', 'e', 's', 'e', 't', ' ', 'b', 'y', ' ', 'p', 'e', 'e', 'r'}, + FstrETIMEDOUT: [20]uint8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 't', 'i', 'm', 'e', 'd', ' ', 'o', 'u', 't'}, + FstrECONNREFUSED: [19]uint8{'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'r', 'e', 'f', 'u', 's', 'e', 'd'}, + FstrEHOSTDOWN: [13]uint8{'H', 'o', 's', 't', ' ', 'i', 's', ' ', 'd', 'o', 'w', 'n'}, + FstrEHOSTUNREACH: [20]uint8{'H', 'o', 's', 't', ' ', 'i', 's', ' ', 'u', 'n', 'r', 'e', 'a', 'c', 'h', 'a', 'b', 'l', 'e'}, + FstrEADDRINUSE: [15]uint8{'A', 'd', 'd', 'r', 'e', 's', 's', ' ', 'i', 'n', ' ', 'u', 's', 'e'}, + FstrEPIPE: [12]uint8{'B', 'r', 'o', 'k', 'e', 'n', ' ', 'p', 'i', 'p', 'e'}, + FstrEIO: [10]uint8{'I', '/', 'O', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrENXIO: [26]uint8{'N', 'o', ' ', 's', 'u', 'c', 'h', ' ', 'd', 'e', 'v', 'i', 'c', 'e', ' ', 'o', 'r', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's'}, + FstrENOTBLK: [22]uint8{'B', 'l', 'o', 'c', 'k', ' ', 'd', 'e', 'v', 'i', 'c', 'e', ' ', 'r', 'e', 'q', 'u', 'i', 'r', 'e', 'd'}, + FstrENODEV: [15]uint8{'N', 'o', ' ', 's', 'u', 'c', 'h', ' ', 'd', 'e', 'v', 'i', 'c', 'e'}, + FstrENOTDIR: [16]uint8{'N', 'o', 't', ' ', 'a', ' ', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y'}, + FstrEISDIR: [15]uint8{'I', 's', ' ', 'a', ' ', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y'}, + FstrETXTBSY: [15]uint8{'T', 'e', 'x', 't', ' ', 'f', 'i', 'l', 'e', ' ', 'b', 'u', 's', 'y'}, + FstrENOEXEC: [18]uint8{'E', 'x', 'e', 'c', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrEINVAL: [17]uint8{'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'a', 'r', 'g', 'u', 'm', 'e', 'n', 't'}, + FstrE2BIG: [23]uint8{'A', 'r', 'g', 'u', 'm', 'e', 'n', 't', ' ', 'l', 'i', 's', 't', ' ', 't', 'o', 'o', ' ', 'l', 'o', 'n', 'g'}, + FstrELOOP: [19]uint8{'S', 'y', 'm', 'b', 'o', 'l', 'i', 'c', ' ', 'l', 'i', 'n', 'k', ' ', 'l', 'o', 'o', 'p'}, + FstrENAMETOOLONG: [18]uint8{'F', 'i', 'l', 'e', 'n', 'a', 'm', 'e', ' ', 't', 'o', 'o', ' ', 'l', 'o', 'n', 'g'}, + FstrENFILE: [30]uint8{'T', 'o', 'o', ' ', 'm', 'a', 'n', 'y', ' ', 'o', 'p', 'e', 'n', ' ', 'f', 'i', 'l', 'e', 's', ' ', 'i', 'n', ' ', 's', 'y', 's', 't', 'e', 'm'}, + FstrEMFILE: [30]uint8{'N', 'o', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 's', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEBADF: [20]uint8{'B', 'a', 'd', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r'}, + FstrECHILD: [17]uint8{'N', 'o', ' ', 'c', 'h', 'i', 'l', 'd', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's'}, + FstrEFAULT: [12]uint8{'B', 'a', 'd', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's'}, + FstrEFBIG: [15]uint8{'F', 'i', 'l', 'e', ' ', 't', 'o', 'o', ' ', 'l', 'a', 'r', 'g', 'e'}, + FstrEMLINK: [15]uint8{'T', 'o', 'o', ' ', 'm', 'a', 'n', 'y', ' ', 'l', 'i', 'n', 'k', 's'}, + FstrENOLCK: [19]uint8{'N', 'o', ' ', 'l', 'o', 'c', 'k', 's', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEDEADLK: [30]uint8{'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', ' ', 'd', 'e', 'a', 'd', 'l', 'o', 'c', 'k', ' ', 'w', 'o', 'u', 'l', 'd', ' ', 'o', 'c', 'c', 'u', 'r'}, + FstrENOTRECOVERABLE: [22]uint8{'S', 't', 'a', 't', 'e', ' ', 'n', 'o', 't', ' ', 'r', 'e', 'c', 'o', 'v', 'e', 'r', 'a', 'b', 'l', 'e'}, + FstrEOWNERDEAD: [20]uint8{'P', 'r', 'e', 'v', 'i', 'o', 'u', 's', ' ', 'o', 'w', 'n', 'e', 'r', ' ', 'd', 'i', 'e', 'd'}, + FstrECANCELED: [19]uint8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'c', 'a', 'n', 'c', 'e', 'l', 'e', 'd'}, + FstrENOSYS: [25]uint8{'F', 'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', 'n', 'o', 't', ' ', 'i', 'm', 'p', 'l', 'e', 'm', 'e', 'n', 't', 'e', 'd'}, + FstrENOMSG: [27]uint8{'N', 'o', ' ', 'm', 'e', 's', 's', 'a', 'g', 'e', ' ', 'o', 'f', ' ', 'd', 'e', 's', 'i', 'r', 'e', 'd', ' ', 't', 'y', 'p', 'e'}, + FstrEIDRM: [19]uint8{'I', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', ' ', 'r', 'e', 'm', 'o', 'v', 'e', 'd'}, + FstrENOSTR: [20]uint8{'D', 'e', 'v', 'i', 'c', 'e', ' ', 'n', 'o', 't', ' ', 'a', ' ', 's', 't', 'r', 'e', 'a', 'm'}, + FstrENODATA: [18]uint8{'N', 'o', ' ', 'd', 'a', 't', 'a', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrETIME: [15]uint8{'D', 'e', 'v', 'i', 'c', 'e', ' ', 't', 'i', 'm', 'e', 'o', 'u', 't'}, + FstrENOSR: [25]uint8{'O', 'u', 't', ' ', 'o', 'f', ' ', 's', 't', 'r', 'e', 'a', 'm', 's', ' ', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', 's'}, + FstrENOLINK: [22]uint8{'L', 'i', 'n', 'k', ' ', 'h', 'a', 's', ' ', 'b', 'e', 'e', 'n', ' ', 's', 'e', 'v', 'e', 'r', 'e', 'd'}, + FstrEPROTO: [15]uint8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrEBADMSG: [12]uint8{'B', 'a', 'd', ' ', 'm', 'e', 's', 's', 'a', 'g', 'e'}, + FstrEBADFD: [29]uint8{'F', 'i', 'l', 'e', ' ', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', ' ', 'i', 'n', ' ', 'b', 'a', 'd', ' ', 's', 't', 'a', 't', 'e'}, + FstrENOTSOCK: [13]uint8{'N', 'o', 't', ' ', 'a', ' ', 's', 'o', 'c', 'k', 'e', 't'}, + FstrEDESTADDRREQ: [29]uint8{'D', 'e', 's', 't', 'i', 'n', 'a', 't', 'i', 'o', 'n', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's', ' ', 'r', 'e', 'q', 'u', 'i', 'r', 'e', 'd'}, + FstrEMSGSIZE: [18]uint8{'M', 'e', 's', 's', 'a', 'g', 'e', ' ', 't', 'o', 'o', ' ', 'l', 'a', 'r', 'g', 'e'}, + FstrEPROTOTYPE: [31]uint8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'w', 'r', 'o', 'n', 'g', ' ', 't', 'y', 'p', 'e', ' ', 'f', 'o', 'r', ' ', 's', 'o', 'c', 'k', 'e', 't'}, + FstrENOPROTOOPT: [23]uint8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'n', 'o', 't', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEPROTONOSUPPORT: [23]uint8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd'}, + FstrESOCKTNOSUPPORT: [26]uint8{'S', 'o', 'c', 'k', 'e', 't', ' ', 't', 'y', 'p', 'e', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd'}, + FstrENOTSUP: [14]uint8{'N', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd'}, + FstrEPFNOSUPPORT: [30]uint8{'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', ' ', 'f', 'a', 'm', 'i', 'l', 'y', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd'}, + FstrEAFNOSUPPORT: [41]uint8{'A', 'd', 'd', 'r', 'e', 's', 's', ' ', 'f', 'a', 'm', 'i', 'l', 'y', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd', ' ', 'b', 'y', ' ', 'p', 'r', 'o', 't', 'o', 'c', 'o', 'l'}, + FstrEADDRNOTAVAIL: [22]uint8{'A', 'd', 'd', 'r', 'e', 's', 's', ' ', 'n', 'o', 't', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrENETDOWN: [16]uint8{'N', 'e', 't', 'w', 'o', 'r', 'k', ' ', 'i', 's', ' ', 'd', 'o', 'w', 'n'}, + FstrENETUNREACH: [20]uint8{'N', 'e', 't', 'w', 'o', 'r', 'k', ' ', 'u', 'n', 'r', 'e', 'a', 'c', 'h', 'a', 'b', 'l', 'e'}, + FstrENETRESET: [28]uint8{'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'r', 'e', 's', 'e', 't', ' ', 'b', 'y', ' ', 'n', 'e', 't', 'w', 'o', 'r', 'k'}, + FstrECONNABORTED: [19]uint8{'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'a', 'b', 'o', 'r', 't', 'e', 'd'}, + FstrENOBUFS: [26]uint8{'N', 'o', ' ', 'b', 'u', 'f', 'f', 'e', 'r', ' ', 's', 'p', 'a', 'c', 'e', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEISCONN: [20]uint8{'S', 'o', 'c', 'k', 'e', 't', ' ', 'i', 's', ' ', 'c', 'o', 'n', 'n', 'e', 'c', 't', 'e', 'd'}, + FstrENOTCONN: [21]uint8{'S', 'o', 'c', 'k', 'e', 't', ' ', 'n', 'o', 't', ' ', 'c', 'o', 'n', 'n', 'e', 'c', 't', 'e', 'd'}, + FstrESHUTDOWN: [34]uint8{'C', 'a', 'n', 'n', 'o', 't', ' ', 's', 'e', 'n', 'd', ' ', 'a', 'f', 't', 'e', 'r', ' ', 's', 'o', 'c', 'k', 'e', 't', ' ', 's', 'h', 'u', 't', 'd', 'o', 'w', 'n'}, + FstrEALREADY: [30]uint8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'a', 'l', 'r', 'e', 'a', 'd', 'y', ' ', 'i', 'n', ' ', 'p', 'r', 'o', 'g', 'r', 'e', 's', 's'}, + FstrEINPROGRESS: [22]uint8{'O', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'i', 'n', ' ', 'p', 'r', 'o', 'g', 'r', 'e', 's', 's'}, + FstrESTALE: [18]uint8{'S', 't', 'a', 'l', 'e', ' ', 'f', 'i', 'l', 'e', ' ', 'h', 'a', 'n', 'd', 'l', 'e'}, + FstrEREMOTEIO: [17]uint8{'R', 'e', 'm', 'o', 't', 'e', ' ', 'I', '/', 'O', ' ', 'e', 'r', 'r', 'o', 'r'}, + FstrEDQUOT: [15]uint8{'Q', 'u', 'o', 't', 'a', ' ', 'e', 'x', 'c', 'e', 'e', 'd', 'e', 'd'}, + FstrENOMEDIUM: [16]uint8{'N', 'o', ' ', 'm', 'e', 'd', 'i', 'u', 'm', ' ', 'f', 'o', 'u', 'n', 'd'}, + FstrEMEDIUMTYPE: [18]uint8{'W', 'r', 'o', 'n', 'g', ' ', 'm', 'e', 'd', 'i', 'u', 'm', ' ', 't', 'y', 'p', 'e'}, + FstrEMULTIHOP: [19]uint8{'M', 'u', 'l', 't', 'i', 'h', 'o', 'p', ' ', 'a', 't', 't', 'e', 'm', 'p', 't', 'e', 'd'}, + FstrENOKEY: [27]uint8{'R', 'e', 'q', 'u', 'i', 'r', 'e', 'd', ' ', 'k', 'e', 'y', ' ', 'n', 'o', 't', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}, + FstrEKEYEXPIRED: [16]uint8{'K', 'e', 'y', ' ', 'h', 'a', 's', ' ', 'e', 'x', 'p', 'i', 'r', 'e', 'd'}, + FstrEKEYREVOKED: [21]uint8{'K', 'e', 'y', ' ', 'h', 'a', 's', ' ', 'b', 'e', 'e', 'n', ' ', 'r', 'e', 'v', 'o', 'k', 'e', 'd'}, + FstrEKEYREJECTED: [28]uint8{'K', 'e', 'y', ' ', 'w', 'a', 's', ' ', 'r', 'e', 'j', 'e', 'c', 't', 'e', 'd', ' ', 'b', 'y', ' ', 's', 'e', 'r', 'v', 'i', 'c', 'e'}, +} + +var _errmsgidx = [132]uint16{ + 1: uint16(uint64(UintptrFromInt32(0) + 109)), + 2: uint16(uint64(UintptrFromInt32(0) + 133)), + 3: uint16(uint64(UintptrFromInt32(0) + 159)), + 4: uint16(uint64(UintptrFromInt32(0) + 269)), + 5: uint16(uint64(UintptrFromInt32(0) + 523)), + 6: uint16(uint64(UintptrFromInt32(0) + 533)), + 7: uint16(uint64(UintptrFromInt32(0) + 677)), + 8: uint16(uint64(UintptrFromInt32(0) + 642)), + 9: uint16(uint64(UintptrFromInt32(0) + 797)), + 10: uint16(uint64(UintptrFromInt32(0) + 817)), + 11: uint16(uint64(UintptrFromInt32(0) + 293)), + 12: uint16(uint64(UintptrFromInt32(0) + 241)), + 13: uint16(uint64(UintptrFromInt32(0) + 91)), + 14: uint16(uint64(UintptrFromInt32(0) + 834)), + 15: uint16(uint64(UintptrFromInt32(0) + 559)), + 16: uint16(uint64(UintptrFromInt32(0) + 255)), + 17: uint16(uint64(UintptrFromInt32(0) + 175)), + 18: uint16(uint64(UintptrFromInt32(0) + 339)), + 19: uint16(uint64(UintptrFromInt32(0) + 581)), + 20: uint16(uint64(UintptrFromInt32(0) + 596)), + 21: uint16(uint64(UintptrFromInt32(0) + 612)), + 22: uint16(uint64(UintptrFromInt32(0) + 660)), + 23: uint16(uint64(UintptrFromInt32(0) + 737)), + 24: uint16(uint64(UintptrFromInt32(0) + 767)), + 25: uint16(uint64(UintptrFromInt32(0) + 81)), + 26: uint16(uint64(UintptrFromInt32(0) + 627)), + 27: uint16(uint64(UintptrFromInt32(0) + 846)), + 28: uint16(uint64(UintptrFromInt32(0) + 217)), + 29: uint16(uint64(UintptrFromInt32(0) + 326)), + 30: uint16(uint64(UintptrFromInt32(0) + 357)), + 31: uint16(uint64(UintptrFromInt32(0) + 861)), + 32: uint16(uint64(UintptrFromInt32(0) + 511)), + 33: uint16(uint64(UintptrFromInt32(0) + 43)), + 34: uint16(uint64(UintptrFromInt32(0) + 56)), + 35: uint16(uint64(UintptrFromInt32(0) + 895)), + 36: uint16(uint64(UintptrFromInt32(0) + 719)), + 37: uint16(uint64(UintptrFromInt32(0) + 876)), + 38: uint16(uint64(UintptrFromInt32(0) + 986)), + 39: uint16(uint64(UintptrFromInt32(0) + 379)), + 40: uint16(uint64(UintptrFromInt32(0) + 700)), + 42: uint16(uint64(UintptrFromInt32(0) + 1011)), + 43: uint16(uint64(UintptrFromInt32(0) + 1038)), + 60: uint16(uint64(UintptrFromInt32(0) + 1057)), + 61: uint16(uint64(UintptrFromInt32(0) + 1077)), + 62: uint16(uint64(UintptrFromInt32(0) + 1095)), + 63: uint16(uint64(UintptrFromInt32(0) + 1110)), + 67: uint16(uint64(UintptrFromInt32(0) + 1135)), + 71: uint16(uint64(UintptrFromInt32(0) + 1157)), + 72: uint16(uint64(UintptrFromInt32(0) + 1803)), + 74: uint16(uint64(UintptrFromInt32(0) + 1172)), + 75: uint16(uint64(UintptrFromInt32(0) + 187)), + 77: uint16(uint64(UintptrFromInt32(0) + 1184)), + 84: uint16(uint64(UintptrFromInt32(0) + 21)), + 88: uint16(uint64(UintptrFromInt32(0) + 1213)), + 89: uint16(uint64(UintptrFromInt32(0) + 1226)), + 90: uint16(uint64(UintptrFromInt32(0) + 1255)), + 91: uint16(uint64(UintptrFromInt32(0) + 1273)), + 92: uint16(uint64(UintptrFromInt32(0) + 1304)), + 93: uint16(uint64(UintptrFromInt32(0) + 1327)), + 94: uint16(uint64(UintptrFromInt32(0) + 1350)), + 95: uint16(uint64(UintptrFromInt32(0) + 1376)), + 96: uint16(uint64(UintptrFromInt32(0) + 1390)), + 97: uint16(uint64(UintptrFromInt32(0) + 1420)), + 98: uint16(uint64(UintptrFromInt32(0) + 496)), + 99: uint16(uint64(UintptrFromInt32(0) + 1461)), + 100: uint16(uint64(UintptrFromInt32(0) + 1483)), + 101: uint16(uint64(UintptrFromInt32(0) + 1499)), + 102: uint16(uint64(UintptrFromInt32(0) + 1519)), + 103: uint16(uint64(UintptrFromInt32(0) + 1547)), + 104: uint16(uint64(UintptrFromInt32(0) + 399)), + 105: uint16(uint64(UintptrFromInt32(0) + 1566)), + 106: uint16(uint64(UintptrFromInt32(0) + 1592)), + 107: uint16(uint64(UintptrFromInt32(0) + 1612)), + 108: uint16(uint64(UintptrFromInt32(0) + 1633)), + 110: uint16(uint64(UintptrFromInt32(0) + 424)), + 111: uint16(uint64(UintptrFromInt32(0) + 444)), + 112: uint16(uint64(UintptrFromInt32(0) + 463)), + 113: uint16(uint64(UintptrFromInt32(0) + 476)), + 114: uint16(uint64(UintptrFromInt32(0) + 1667)), + 115: uint16(uint64(UintptrFromInt32(0) + 1697)), + 116: uint16(uint64(UintptrFromInt32(0) + 1719)), + 121: uint16(uint64(UintptrFromInt32(0) + 1737)), + 122: uint16(uint64(UintptrFromInt32(0) + 1754)), + 123: uint16(uint64(UintptrFromInt32(0) + 1769)), + 124: uint16(uint64(UintptrFromInt32(0) + 1785)), + 125: uint16(uint64(UintptrFromInt32(0) + 967)), + 126: uint16(uint64(UintptrFromInt32(0) + 1822)), + 127: uint16(uint64(UintptrFromInt32(0) + 1849)), + 128: uint16(uint64(UintptrFromInt32(0) + 1865)), + 129: uint16(uint64(UintptrFromInt32(0) + 1886)), + 130: uint16(uint64(UintptrFromInt32(0) + 947)), + 131: uint16(uint64(UintptrFromInt32(0) + 925)), +} + +func X__strerror_l(tls *TLS, e int32, loc Tlocale_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v e=%v loc=%v, (%v:)", tls, e, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + _ = s + if Uint64FromInt32(e) >= Uint64FromInt64(264)/Uint64FromInt64(2) { + e = 0 + } + s = uintptr(unsafe.Pointer(&_errmsgstr)) + uintptr(_errmsgidx[e]) + return X__lctrans(tls, s, **(**uintptr)(__ccgo_up(loc + 5*8))) +} + +func Xstrerror(tls *TLS, e int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v e=%v, (%v:)", tls, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strerror_l(tls, e, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xstrerror_l(tls *TLS, e int32, loc Tlocale_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v e=%v loc=%v, (%v:)", tls, e, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strerror_l(tls, e, loc) +} + +func X_Exit(tls *TLS, ec int32) { + if __ccgo_strace { + trc("tls=%v ec=%v, (%v:)", tls, ec, origin(2)) + } + X__syscall1(tls, int64(SYS_exit_group), int64(ec)) + for { + X__syscall1(tls, int64(SYS_exit), int64(ec)) + goto _1 + _1: + } +} + +func X__assert_fail(tls *TLS, expr uintptr, file uintptr, line int32, func1 uintptr) { + if __ccgo_strace { + trc("tls=%v expr=%v file=%v line=%v func1=%v, (%v:)", tls, expr, file, line, func1, origin(2)) + } + bp := tls.Alloc(48) + defer tls.Free(48) + Xfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), __ccgo_ts+212, VaList(bp+8, expr, file, func1, line)) + Xabort(tls) +} + +const COUNT = 32 + +var _funcs [32]uintptr +var _count int32 +var _lock [1]int32 + +func X__funcs_on_quick_exit(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + var func1 uintptr + var v1 int32 + _, _ = func1, v1 + ___lock(tls, uintptr(unsafe.Pointer(&_lock))) + for _count > 0 { + _count = _count - 1 + v1 = _count + func1 = _funcs[v1] + ___unlock(tls, uintptr(unsafe.Pointer(&_lock))) + (*(*func(*TLS))(unsafe.Pointer(&struct{ uintptr }{func1})))(tls) + ___lock(tls, uintptr(unsafe.Pointer(&_lock))) + } +} + +type t__ccgo_fp__Xat_quick_exit_0 = func(*TLS) + +func Xat_quick_exit(tls *TLS, __ccgo_fp_func uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v __ccgo_fp_func=%v, (%v:)", tls, __ccgo_fp_func, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v1 int32 + _, _ = r, v1 + r = 0 + ___lock(tls, uintptr(unsafe.Pointer(&_lock))) + if _count == int32(32) { + r = -int32(1) + } else { + v1 = _count + _count = _count + 1 + _funcs[v1] = __ccgo_fp_func + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock))) + return r +} + +func _dummy3(tls *TLS) { +} + +func Xquick_exit(tls *TLS, code int32) { + if __ccgo_strace { + trc("tls=%v code=%v, (%v:)", tls, code, origin(2)) + } + X__funcs_on_quick_exit(tls) + X_Exit(tls, code) +} + +func Xcreat(tls *TLS, filename uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v mode=%v, (%v:)", tls, filename, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + return Xopen(tls, filename, Int32FromInt32(O_CREAT)|Int32FromInt32(O_WRONLY)|Int32FromInt32(O_TRUNC), VaList(bp+8, mode)) +} + +func Xfcntl(tls *TLS, fd int32, cmd int32, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v cmd=%v va=%v, (%v:)", tls, fd, cmd, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ap Tva_list + var arg uint64 + var ret, ret1, v1 int32 + var _ /* ex at bp+0 */ Tf_owner_ex + _, _, _, _, _ = ap, arg, ret, ret1, v1 + ap = va + arg = VaUint64(&ap) + _ = ap + if cmd == int32(F_SETFL) { + arg = arg | uint64(O_LARGEFILE) + } + if cmd == int32(F_SETLKW) { + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_fcntl), int64(fd), int64(cmd), int64(uintptr(arg)), 0, 0, 0)))) + } + if cmd == int32(F_GETOWN) { + ret = int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETOWN_EX)), int64(bp))) + if ret == -int32(EINVAL) { + return int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(cmd), int64(uintptr(arg)))) + } + if ret != 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + if (**(**Tf_owner_ex)(__ccgo_up(bp))).Ftype1 == int32(F_OWNER_PGRP) { + v1 = -(**(**Tf_owner_ex)(__ccgo_up(bp))).Fpid + } else { + v1 = (**(**Tf_owner_ex)(__ccgo_up(bp))).Fpid + } + return v1 + } + if cmd == int32(F_DUPFD_CLOEXEC) { + ret1 = int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_DUPFD_CLOEXEC)), Int64FromUint64(arg))) + if ret1 != -int32(EINVAL) { + if ret1 >= 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret1), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(ret1))) + } + ret1 = int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_DUPFD_CLOEXEC)), int64(Int32FromInt32(0)))) + if ret1 != -int32(EINVAL) { + if ret1 >= 0 { + X__syscall1(tls, int64(SYS_close), int64(ret1)) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + ret1 = int32(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_DUPFD)), Int64FromUint64(arg))) + if ret1 >= 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret1), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(ret1))) + } + switch cmd { + case int32(F_SETLK): + fallthrough + case int32(F_GETLK): + fallthrough + case int32(F_GETOWN_EX): + fallthrough + case int32(F_SETOWN_EX): + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(cmd), int64(uintptr(arg)))))) + default: + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(cmd), Int64FromUint64(arg))))) + } + return r +} + +func Xopen(tls *TLS, filename uintptr, flags int32, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v flags=%v va=%v, (%v:)", tls, filename, flags, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var fd int32 + var mode Tmode_t + _, _, _ = ap, fd, mode + mode = uint32(0) + if flags&int32(O_CREAT) != 0 || flags&int32(O_TMPFILE) == int32(O_TMPFILE) { + ap = va + mode = VaUint32(&ap) + _ = ap + } + fd = int32(___syscall_cp(tls, int64(SYS_openat), int64(-Int32FromInt32(100)), int64(filename), int64(flags|Int32FromInt32(O_LARGEFILE)), Int64FromUint32(mode), 0, 0)) + if fd >= 0 && flags&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(fd))) +} + +func Xopenat(tls *TLS, fd int32, filename uintptr, flags int32, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v filename=%v flags=%v va=%v, (%v:)", tls, fd, filename, flags, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var mode Tmode_t + _, _ = ap, mode + mode = uint32(0) + if flags&int32(O_CREAT) != 0 || flags&int32(O_TMPFILE) == int32(O_TMPFILE) { + ap = va + mode = VaUint32(&ap) + _ = ap + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_openat), int64(fd), int64(filename), int64(flags|Int32FromInt32(O_LARGEFILE)), Int64FromUint32(mode), 0, 0)))) +} + +func Xposix_fadvise(tls *TLS, fd int32, base Toff_t, len1 Toff_t, advice int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v base=%v len1=%v advice=%v, (%v:)", tls, fd, base, len1, advice, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(-X__syscall4(tls, int64(SYS_fadvise64), int64(fd), base, len1, int64(advice))) +} + +func Xposix_fallocate(tls *TLS, fd int32, base Toff_t, len1 Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v base=%v len1=%v, (%v:)", tls, fd, base, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(-X__syscall4(tls, int64(SYS_fallocate), int64(fd), int64(Int32FromInt32(0)), base, len1)) +} + +const FE_ALL_EXCEPT = 31 +const FE_DIVBYZERO = 2 +const FE_DOWNWARD = 8388608 +const FE_INEXACT = 16 +const FE_INVALID = 1 +const FE_OVERFLOW = 4 +const FE_TONEAREST = 0 +const FE_TOWARDZERO = 12582912 +const FE_UNDERFLOW = 8 +const FE_UPWARD = 4194304 + +type Tfexcept_t = uint32 + +type Tfenv_t = struct { + F__fpcr uint32 + F__fpsr uint32 +} + +/* Dummy functions for archs lacking fenv implementation */ + +func Xfeclearexcept(tls *TLS, mask int32) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v, (%v:)", tls, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xferaiseexcept(tls *TLS, mask int32) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v, (%v:)", tls, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xfetestexcept(tls *TLS, mask int32) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v, (%v:)", tls, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xfegetround(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return FE_TONEAREST +} + +func X__fesetround(tls *TLS, r int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v r=%v, (%v:)", tls, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return 0 +} + +func Xfegetenv(tls *TLS, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v envp=%v, (%v:)", tls, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xfesetenv(tls *TLS, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v envp=%v, (%v:)", tls, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +const WCONTINUED = 8 +const WEXITED = 4 +const WNOWAIT = 16777216 +const WSTOPPED = 2 +const __WALL = 1073741824 +const __WCLONE = 2147483648 +const __WNOTHREAD = 536870912 + +type Tidtype_t = int32 + +const _P_ALL = 0 +const _P_PID = 1 +const _P_PGID = 2 +const _P_PIDFD = 3 +const F_APP = 128 +const F_EOF = 16 +const F_ERR = 32 +const F_NORD = 4 +const F_NOWR = 8 +const F_PERM = 1 +const F_SVB = 64 +const KMAX = 128 +const LDBL_EPSILON1 = 2.22044604925031308085e-16 +const LDBL_MAX1 = 1.79769313486231570815e+308 +const LDBL_MIN1 = 2.22507385850720138309e-308 +const LD_B1B_DIG = 2 +const LD_B1B_MAX = 254740991 +const MASK = 127 +const MAYBE_WAITERS = 1073741824 +const UNGET = 8 + +type TFILE = struct { + Fflags uint32 + Frpos uintptr + Frend uintptr + Fclose1 uintptr + Fwend uintptr + Fwpos uintptr + Fmustbezero_1 uintptr + Fwbase uintptr + Fread uintptr + Fwrite uintptr + Fseek uintptr + Fbuf uintptr + Fbuf_size Tsize_t + Fprev uintptr + Fnext uintptr + Ffd int32 + Fpipe_pid int32 + Flockcount int64 + Fmode int32 + Flock int32 + Flbf int32 + Fcookie uintptr + Foff Toff_t + Fgetln_buf uintptr + Fmustbezero_2 uintptr + Fshend uintptr + Fshlim Toff_t + Fshcnt Toff_t + Fprev_locked uintptr + Fnext_locked uintptr + Flocale uintptr +} + +type T_IO_FILE = TFILE + +func _scanexp(tls *TLS, f uintptr, pok int32) (r int64) { + var c, neg, x, v1 int32 + var y, v19 int64 + var v2, v3 uintptr + _, _, _, _, _, _, _, _ = c, neg, x, y, v1, v19, v2, v3 + neg = 0 + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if c == int32('+') || c == int32('-') { + neg = BoolInt32(c == int32('-')) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if Uint32FromInt32(c-int32('0')) >= uint32(10) && pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + } + if Uint32FromInt32(c-int32('0')) >= uint32(10) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + return -Int64FromInt64(0x7fffffffffffffff) - Int64FromInt32(1) + } + x = 0 + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) && x < Int32FromInt32(INT_MAX)/Int32FromInt32(10)) { + break + } + x = int32(10)*x + c - int32('0') + goto _7 + _7: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + y = int64(x) + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) && y < Int64FromInt64(0x7fffffffffffffff)/Int64FromInt32(100)) { + break + } + y = int64(10)*y + int64(c) - int64('0') + goto _11 + _11: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10)) { + break + } + goto _15 + _15: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if neg != 0 { + v19 = -y + } else { + v19 = y + } + return v19 +} + +func _decfloat(tls *TLS, f uintptr, c int32, bits int32, emin int32, sign int32, pok int32) (r float64) { + bp := tls.Alloc(512) + defer tls.Free(512) + var a, bitlim, denormal, e2, emax, gotdig, gotrad, i, j, k, lnz, p10, rp, rpm9, sh, z, v2, v6 int32 + var bias, frac, y float64 + var carry, carry1, carry2, t, tmp, tmp2 Tuint32_t + var dc, e10, lrp int64 + var tmp1 Tuint64_t + var v3, v4 uintptr + var _ /* x at bp+0 */ [128]Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, bias, bitlim, carry, carry1, carry2, dc, denormal, e10, e2, emax, frac, gotdig, gotrad, i, j, k, lnz, lrp, p10, rp, rpm9, sh, t, tmp, tmp1, tmp2, y, z, v2, v3, v4, v6 + lrp = 0 + dc = 0 + e10 = 0 + lnz = 0 + gotdig = 0 + gotrad = 0 + emax = -emin - bits + int32(3) + denormal = 0 + frac = Float64FromInt32(0) + bias = Float64FromInt32(0) + j = 0 + k = 0 + /* Don't let leading zeros consume buffer space */ + for { + if !(c == int32('0')) { + break + } + gotdig = int32(1) + goto _1 + _1: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + c = v2 + } + if c == int32('.') { + gotrad = int32(1) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + c = v2 + for { + if !(c == int32('0')) { + break + } + gotdig = int32(1) + lrp = lrp - 1 + goto _5 + _5: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + c = v2 + } + } + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[0] = uint32(0) + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) || c == int32('.')) { + break + } + if c == int32('.') { + if gotrad != 0 { + break + } + gotrad = int32(1) + lrp = dc + } else { + if k < Int32FromInt32(KMAX)-Int32FromInt32(3) { + dc = dc + 1 + if c != int32('0') { + lnz = int32(dc) + } + if j != 0 { + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k]*uint32(10) + Uint32FromInt32(c) - uint32('0') + } else { + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = Uint32FromInt32(c - int32('0')) + } + j = j + 1 + v2 = j + if v2 == int32(9) { + k = k + 1 + j = 0 + } + gotdig = int32(1) + } else { + dc = dc + 1 + if c != int32('0') { + lnz = (Int32FromInt32(KMAX) - Int32FromInt32(4)) * Int32FromInt32(9) + **(**Tuint32_t)(__ccgo_up(bp + uintptr(Int32FromInt32(KMAX)-Int32FromInt32(4))*4)) |= uint32(1) + } + } + } + goto _12 + _12: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + c = v2 + } + if !(gotrad != 0) { + lrp = dc + } + if gotdig != 0 && c|int32(32) == int32('e') { + e10 = _scanexp(tls, f, pok) + if e10 == -Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1) { + if pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } else { + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + e10 = 0 + } + lrp = lrp + e10 + } else { + if c >= 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + } + if !(gotdig != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + /* Handle zero specially to avoid nasty special cases later */ + if !((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0] != 0) { + return float64(float64(sign) * float64(0)) + } + /* Optimize small integers (w/no exponent) and over/under-flow */ + if lrp == dc && dc < int64(10) && (bits > int32(30) || (**(**[128]Tuint32_t)(__ccgo_up(bp)))[0]>>bits == uint32(0)) { + return float64(float64(sign) * float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0])) + } + if lrp > int64(-emin/int32(2)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return float64(float64(float64(sign)*Float64FromFloat64(1.79769313486231570815e+308)) * Float64FromFloat64(1.79769313486231570815e+308)) + } + if lrp < int64(emin-Int32FromInt32(2)*Int32FromInt32(LDBL_MANT_DIG)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return float64(float64(float64(sign)*Float64FromFloat64(2.22507385850720138309e-308)) * Float64FromFloat64(2.22507385850720138309e-308)) + } + /* Align incomplete final B1B digit */ + if j != 0 { + for { + if !(j < int32(9)) { + break + } + **(**Tuint32_t)(__ccgo_up(bp + uintptr(k)*4)) *= uint32(10) + goto _17 + _17: + ; + j = j + 1 + } + k = k + 1 + j = 0 + } + a = 0 + z = k + e2 = 0 + rp = int32(lrp) + /* Optimize small to mid-size integers (even in exp. notation) */ + if lnz < int32(9) && lnz <= rp && rp < int32(18) { + if rp == int32(9) { + return float64(float64(sign) * float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0])) + } + if rp < int32(9) { + return float64(float64(sign)*float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0])) / float64(_p10s[int32(8)-rp]) + } + bitlim = bits - int32(3)*(rp-Int32FromInt32(9)) + if bitlim > int32(30) || (**(**[128]Tuint32_t)(__ccgo_up(bp)))[0]>>bitlim == uint32(0) { + return float64(float64(float64(sign)*float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[0])) * float64(_p10s[rp-int32(10)])) + } + } + /* Drop trailing zeros */ + for { + if !!((**(**[128]Tuint32_t)(__ccgo_up(bp)))[z-int32(1)] != 0) { + break + } + goto _18 + _18: + ; + z = z - 1 + } + /* Align radix point to B1B digit boundary */ + if rp%int32(9) != 0 { + if rp >= 0 { + v2 = rp % int32(9) + } else { + v2 = rp%int32(9) + int32(9) + } + rpm9 = v2 + p10 = _p10s[int32(8)-rpm9] + carry = uint32(0) + k = a + for { + if !(k != z) { + break + } + tmp = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] % Uint32FromInt32(p10) + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k]/Uint32FromInt32(p10) + carry + carry = Uint32FromInt32(int32(1000000000)/p10) * tmp + if k == a && !((**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] != 0) { + a = (a + int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + rp = rp - int32(9) + } + goto _20 + _20: + ; + k = k + 1 + } + if carry != 0 { + v2 = z + z = z + 1 + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[v2] = carry + } + rp = rp + (int32(9) - rpm9) + } + /* Upscale until desired number of bits are left of radix point */ + for rp < Int32FromInt32(9)*Int32FromInt32(LD_B1B_DIG) || rp == Int32FromInt32(9)*Int32FromInt32(LD_B1B_DIG) && (**(**[128]Tuint32_t)(__ccgo_up(bp)))[a] < _th[0] { + carry1 = uint32(0) + e2 = e2 - int32(29) + k = (z - int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + for { + tmp1 = uint64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[k])< uint64(1000000000) { + carry1 = uint32(tmp1 / uint64(1000000000)) + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = uint32(tmp1 % uint64(1000000000)) + } else { + carry1 = uint32(0) + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] = uint32(tmp1) + } + if k == (z-int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)) && k != a && !((**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] != 0) { + z = k + } + if k == a { + break + } + goto _22 + _22: + ; + k = (k - int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + } + if carry1 != 0 { + rp = rp + int32(9) + a = (a - int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + if a == z { + z = (z - int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + **(**Tuint32_t)(__ccgo_up(bp + uintptr((z-int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)))*4)) |= (**(**[128]Tuint32_t)(__ccgo_up(bp)))[z] + } + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[a] = carry1 + } + } + /* Downscale until exactly number of bits are left of radix point */ + for { + carry2 = uint32(0) + sh = int32(1) + i = 0 + for { + if !(i < int32(LD_B1B_DIG)) { + break + } + k = (a + i) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + if k == z || (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] < _th[i] { + i = int32(LD_B1B_DIG) + break + } + if (**(**[128]Tuint32_t)(__ccgo_up(bp)))[(a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1))] > _th[i] { + break + } + goto _24 + _24: + ; + i = i + 1 + } + if i == int32(LD_B1B_DIG) && rp == Int32FromInt32(9)*Int32FromInt32(LD_B1B_DIG) { + break + } + /* FIXME: find a way to compute optimal sh */ + if rp > Int32FromInt32(9)+Int32FromInt32(9)*Int32FromInt32(LD_B1B_DIG) { + sh = int32(9) + } + e2 = e2 + sh + k = a + for { + if !(k != z) { + break + } + tmp2 = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] & Uint32FromInt32(int32(1)<>sh + carry2 + carry2 = Uint32FromInt32(Int32FromInt32(1000000000)>>sh) * tmp2 + if k == a && !((**(**[128]Tuint32_t)(__ccgo_up(bp)))[k] != 0) { + a = (a + int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + i = i - 1 + rp = rp - int32(9) + } + goto _25 + _25: + ; + k = (k + int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + } + if carry2 != 0 { + if (z+int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)) != a { + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[z] = carry2 + z = (z + int32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + } else { + **(**Tuint32_t)(__ccgo_up(bp + uintptr((z-int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)))*4)) |= uint32(1) + } + } + goto _23 + _23: + } + /* Assemble desired bits into floating point variable */ + v2 = Int32FromInt32(0) + i = v2 + y = float64(v2) + for { + if !(i < int32(LD_B1B_DIG)) { + break + } + if (a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1)) == z { + v6 = (z + Int32FromInt32(1)) & (Int32FromInt32(KMAX) - Int32FromInt32(1)) + z = v6 + (**(**[128]Tuint32_t)(__ccgo_up(bp)))[v6-int32(1)] = uint32(0) + } + y = float64(Float64FromFloat64(1e+09)*y) + float64((**(**[128]Tuint32_t)(__ccgo_up(bp)))[(a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1))]) + goto _26 + _26: + ; + i = i + 1 + } + y = y * float64(sign) + /* Limit precision for denormal results */ + if bits > int32(LDBL_MANT_DIG)+e2-emin { + bits = int32(LDBL_MANT_DIG) + e2 - emin + if bits < 0 { + bits = 0 + } + denormal = int32(1) + } + /* Calculate bias term to force rounding, move out lower bits */ + if bits < int32(LDBL_MANT_DIG) { + bias = Xcopysignl(tls, Xscalbn(tls, Float64FromInt32(1), Int32FromInt32(2)*Int32FromInt32(LDBL_MANT_DIG)-bits-int32(1)), y) + frac = Xfmodl(tls, y, Xscalbn(tls, Float64FromInt32(1), int32(LDBL_MANT_DIG)-bits)) + y = y - frac + y = y + bias + } + /* Process tail of decimal input so it can affect rounding */ + if (a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1)) != z { + t = (**(**[128]Tuint32_t)(__ccgo_up(bp)))[(a+i)&(Int32FromInt32(KMAX)-Int32FromInt32(1))] + if t < uint32(500000000) && (t != 0 || (a+i+int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)) != z) { + frac = frac + float64(float64(0.25)*float64(sign)) + } else { + if t > uint32(500000000) { + frac = frac + float64(float64(0.75)*float64(sign)) + } else { + if t == uint32(500000000) { + if (a+i+int32(1))&(Int32FromInt32(KMAX)-Int32FromInt32(1)) == z { + frac = frac + float64(float64(0.5)*float64(sign)) + } else { + frac = frac + float64(float64(0.75)*float64(sign)) + } + } + } + } + if int32(LDBL_MANT_DIG)-bits >= int32(2) && !(Xfmodl(tls, frac, Float64FromInt32(1)) != 0) { + frac = frac + 1 + } + } + y = y + frac + y = y - bias + if (e2+int32(LDBL_MANT_DIG))&int32(INT_MAX) > emax-int32(5) { + if Xfabsl(tls, y) >= Float64FromInt32(2)/Float64FromFloat64(2.22044604925031308085e-16) { + if denormal != 0 && bits == int32(LDBL_MANT_DIG)+e2-emin { + denormal = 0 + } + y = y * Float64FromFloat64(0.5) + e2 = e2 + 1 + } + if e2+int32(LDBL_MANT_DIG) > emax || denormal != 0 && frac != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + } + } + return Xscalbnl(tls, y, e2) +} + +var _th = [2]Tuint32_t{ + 0: uint32(9007199), + 1: uint32(254740991), +} + +var _p10s = [8]int32{ + 0: int32(10), + 1: int32(100), + 2: int32(1000), + 3: int32(10000), + 4: int32(100000), + 5: int32(1000000), + 6: int32(10000000), + 7: int32(100000000), +} + +func _hexfloat(tls *TLS, f uintptr, bits int32, emin int32, sign int32, pok int32) (r float64) { + var bias, scale, y float64 + var c, d, gotdig, gotrad, gottail, v1 int32 + var dc, e2, rp int64 + var x Tuint32_t + var v2, v3 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bias, c, d, dc, e2, gotdig, gotrad, gottail, rp, scale, x, y, v1, v2, v3 + x = uint32(0) + y = Float64FromInt32(0) + scale = Float64FromInt32(1) + bias = Float64FromInt32(0) + gottail = 0 + gotrad = 0 + gotdig = 0 + rp = 0 + dc = 0 + e2 = 0 + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + /* Skip leading zeros */ + for { + if !(c == int32('0')) { + break + } + gotdig = int32(1) + goto _4 + _4: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if c == int32('.') { + gotrad = int32(1) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + /* Count zeros after the radix point before significand */ + rp = 0 + for { + if !(c == int32('0')) { + break + } + gotdig = int32(1) + goto _11 + _11: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + rp = rp - 1 + } + } + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) || Uint32FromInt32(c|int32(32)-int32('a')) < uint32(6) || c == int32('.')) { + break + } + if c == int32('.') { + if gotrad != 0 { + break + } + rp = dc + gotrad = int32(1) + } else { + gotdig = int32(1) + if c > int32('9') { + d = c | int32(32) + int32(10) - int32('a') + } else { + d = c - int32('0') + } + if dc < int64(8) { + x = x*uint32(16) + Uint32FromInt32(d) + } else { + if dc < int64(Int32FromInt32(LDBL_MANT_DIG)/Int32FromInt32(4)+Int32FromInt32(1)) { + scale = scale / Float64FromInt32(16) + y = y + float64(float64(d)*scale) + } else { + if d != 0 && !(gottail != 0) { + y = y + float64(Float64FromFloat64(0.5)*scale) + gottail = int32(1) + } + } + } + dc = dc + 1 + } + goto _15 + _15: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if !(gotdig != 0) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if gotrad != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + } else { + X__shlim(tls, f, int64(Int32FromInt32(0))) + } + return float64(float64(sign) * float64(0)) + } + if !(gotrad != 0) { + rp = dc + } + for dc < int64(8) { + x = x * uint32(16) + dc = dc + 1 + } + if c|int32(32) == int32('p') { + e2 = _scanexp(tls, f, pok) + if e2 == -Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1) { + if pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } else { + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + e2 = 0 + } + } else { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + e2 = e2 + (int64(4)*rp - int64(32)) + if !(x != 0) { + return float64(float64(sign) * float64(0)) + } + if e2 > int64(-emin) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return float64(float64(float64(sign)*Float64FromFloat64(1.79769313486231570815e+308)) * Float64FromFloat64(1.79769313486231570815e+308)) + } + if e2 < int64(emin-Int32FromInt32(2)*Int32FromInt32(LDBL_MANT_DIG)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return float64(float64(float64(sign)*Float64FromFloat64(2.22507385850720138309e-308)) * Float64FromFloat64(2.22507385850720138309e-308)) + } + for x < uint32(0x80000000) { + if y >= Float64FromFloat64(0.5) { + x = x + (x + uint32(1)) + y = y + (y - Float64FromInt32(1)) + } else { + x = x + x + y = y + y + } + e2 = e2 - 1 + } + if int64(bits) > int64(32)+e2-int64(emin) { + bits = int32(int64(32) + e2 - int64(emin)) + if bits < 0 { + bits = 0 + } + } + if bits < int32(LDBL_MANT_DIG) { + bias = Xcopysignl(tls, Xscalbn(tls, Float64FromInt32(1), Int32FromInt32(32)+Int32FromInt32(LDBL_MANT_DIG)-bits-int32(1)), float64(sign)) + } + if bits < int32(32) && y != 0 && !(x&Uint32FromInt32(1) != 0) { + x = x + 1 + y = Float64FromInt32(0) + } + y = bias + float64(float64(sign)*float64(x)) + float64(float64(sign)*y) + y = y - bias + if !(y != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + } + return Xscalbnl(tls, y, int32(e2)) +} + +func X__floatscan(tls *TLS, f uintptr, prec int32, pok int32) (r float64) { + if __ccgo_strace { + trc("tls=%v f=%v prec=%v pok=%v, (%v:)", tls, f, prec, pok, origin(2)) + defer func() { trc("-> %v", r) }() + } + var bits, c, emin, sign, v1, v2, v5, v6 int32 + var i, v27 Tsize_t + var v3, v4 uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = bits, c, emin, i, sign, v1, v2, v27, v3, v4, v5, v6 + sign = int32(1) + switch prec { + case 0: + bits = int32(FLT_MANT_DIG) + emin = -int32(125) - bits + case int32(1): + bits = int32(DBL_MANT_DIG) + emin = -int32(1021) - bits + case int32(2): + bits = int32(LDBL_MANT_DIG) + emin = -int32(1021) - bits + default: + return Float64FromInt32(0) + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + v1 = v2 + c = v1 + v5 = v1 + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + if !(v6 != 0) { + break + } + } + if c == int32('+') || c == int32('-') { + sign = sign - int32(2)*BoolInt32(c == int32('-')) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + i = uint64(0) + for { + if !(i < uint64(8) && c|int32(32) == Int32FromUint8(**(**uint8)(__ccgo_up(__ccgo_ts + 247 + uintptr(i))))) { + break + } + if i < uint64(7) { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + goto _11 + _11: + ; + i = i + 1 + } + if i == uint64(3) || i == uint64(8) || i > uint64(3) && pok != 0 { + if i != uint64(8) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if pok != 0 { + for { + if !(i > uint64(3)) { + break + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + goto _15 + _15: + ; + i = i - 1 + } + } + } + return float64(float32(sign) * X__builtin_inff(tls)) + } + if !(i != 0) { + i = uint64(0) + for { + if !(i < uint64(3) && c|int32(32) == Int32FromUint8(**(**uint8)(__ccgo_up(__ccgo_ts + 256 + uintptr(i))))) { + break + } + if i < uint64(2) { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + goto _16 + _16: + ; + i = i + 1 + } + } + if i == uint64(3) { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + if v1 != int32('(') { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) + } + i = uint64(1) + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if Uint32FromInt32(c-int32('0')) < uint32(10) || Uint32FromInt32(c-int32('A')) < uint32(26) || Uint32FromInt32(c-int32('a')) < uint32(26) || c == int32('_') { + goto _23 + } + if c == int32(')') { + return float64(X__builtin_nanf(tls, __ccgo_ts)) + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if !(pok != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + for { + v27 = i + i = i - 1 + if !(v27 != 0) { + break + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) + goto _23 + _23: + ; + i = i + 1 + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) + } + if i != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + X__shlim(tls, f, int64(Int32FromInt32(0))) + return Float64FromInt32(0) + } + if c == int32('0') { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if c|int32(32) == int32('x') { + return _hexfloat(tls, f, bits, emin, sign, pok) + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + c = int32('0') + } + return _decfloat(tls, f, c, bits, emin, sign, pok) +} + +// C documentation +// +// /* Lookup table for digit values. -1==255>=36 -> invalid */ +var _table6 = [257]uint8{ + 0: Uint8FromInt32(-Int32FromInt32(1)), + 1: Uint8FromInt32(-Int32FromInt32(1)), + 2: Uint8FromInt32(-Int32FromInt32(1)), + 3: Uint8FromInt32(-Int32FromInt32(1)), + 4: Uint8FromInt32(-Int32FromInt32(1)), + 5: Uint8FromInt32(-Int32FromInt32(1)), + 6: Uint8FromInt32(-Int32FromInt32(1)), + 7: Uint8FromInt32(-Int32FromInt32(1)), + 8: Uint8FromInt32(-Int32FromInt32(1)), + 9: Uint8FromInt32(-Int32FromInt32(1)), + 10: Uint8FromInt32(-Int32FromInt32(1)), + 11: Uint8FromInt32(-Int32FromInt32(1)), + 12: Uint8FromInt32(-Int32FromInt32(1)), + 13: Uint8FromInt32(-Int32FromInt32(1)), + 14: Uint8FromInt32(-Int32FromInt32(1)), + 15: Uint8FromInt32(-Int32FromInt32(1)), + 16: Uint8FromInt32(-Int32FromInt32(1)), + 17: Uint8FromInt32(-Int32FromInt32(1)), + 18: Uint8FromInt32(-Int32FromInt32(1)), + 19: Uint8FromInt32(-Int32FromInt32(1)), + 20: Uint8FromInt32(-Int32FromInt32(1)), + 21: Uint8FromInt32(-Int32FromInt32(1)), + 22: Uint8FromInt32(-Int32FromInt32(1)), + 23: Uint8FromInt32(-Int32FromInt32(1)), + 24: Uint8FromInt32(-Int32FromInt32(1)), + 25: Uint8FromInt32(-Int32FromInt32(1)), + 26: Uint8FromInt32(-Int32FromInt32(1)), + 27: Uint8FromInt32(-Int32FromInt32(1)), + 28: Uint8FromInt32(-Int32FromInt32(1)), + 29: Uint8FromInt32(-Int32FromInt32(1)), + 30: Uint8FromInt32(-Int32FromInt32(1)), + 31: Uint8FromInt32(-Int32FromInt32(1)), + 32: Uint8FromInt32(-Int32FromInt32(1)), + 33: Uint8FromInt32(-Int32FromInt32(1)), + 34: Uint8FromInt32(-Int32FromInt32(1)), + 35: Uint8FromInt32(-Int32FromInt32(1)), + 36: Uint8FromInt32(-Int32FromInt32(1)), + 37: Uint8FromInt32(-Int32FromInt32(1)), + 38: Uint8FromInt32(-Int32FromInt32(1)), + 39: Uint8FromInt32(-Int32FromInt32(1)), + 40: Uint8FromInt32(-Int32FromInt32(1)), + 41: Uint8FromInt32(-Int32FromInt32(1)), + 42: Uint8FromInt32(-Int32FromInt32(1)), + 43: Uint8FromInt32(-Int32FromInt32(1)), + 44: Uint8FromInt32(-Int32FromInt32(1)), + 45: Uint8FromInt32(-Int32FromInt32(1)), + 46: Uint8FromInt32(-Int32FromInt32(1)), + 47: Uint8FromInt32(-Int32FromInt32(1)), + 48: Uint8FromInt32(-Int32FromInt32(1)), + 50: uint8(1), + 51: uint8(2), + 52: uint8(3), + 53: uint8(4), + 54: uint8(5), + 55: uint8(6), + 56: uint8(7), + 57: uint8(8), + 58: uint8(9), + 59: Uint8FromInt32(-Int32FromInt32(1)), + 60: Uint8FromInt32(-Int32FromInt32(1)), + 61: Uint8FromInt32(-Int32FromInt32(1)), + 62: Uint8FromInt32(-Int32FromInt32(1)), + 63: Uint8FromInt32(-Int32FromInt32(1)), + 64: Uint8FromInt32(-Int32FromInt32(1)), + 65: Uint8FromInt32(-Int32FromInt32(1)), + 66: uint8(10), + 67: uint8(11), + 68: uint8(12), + 69: uint8(13), + 70: uint8(14), + 71: uint8(15), + 72: uint8(16), + 73: uint8(17), + 74: uint8(18), + 75: uint8(19), + 76: uint8(20), + 77: uint8(21), + 78: uint8(22), + 79: uint8(23), + 80: uint8(24), + 81: uint8(25), + 82: uint8(26), + 83: uint8(27), + 84: uint8(28), + 85: uint8(29), + 86: uint8(30), + 87: uint8(31), + 88: uint8(32), + 89: uint8(33), + 90: uint8(34), + 91: uint8(35), + 92: Uint8FromInt32(-Int32FromInt32(1)), + 93: Uint8FromInt32(-Int32FromInt32(1)), + 94: Uint8FromInt32(-Int32FromInt32(1)), + 95: Uint8FromInt32(-Int32FromInt32(1)), + 96: Uint8FromInt32(-Int32FromInt32(1)), + 97: Uint8FromInt32(-Int32FromInt32(1)), + 98: uint8(10), + 99: uint8(11), + 100: uint8(12), + 101: uint8(13), + 102: uint8(14), + 103: uint8(15), + 104: uint8(16), + 105: uint8(17), + 106: uint8(18), + 107: uint8(19), + 108: uint8(20), + 109: uint8(21), + 110: uint8(22), + 111: uint8(23), + 112: uint8(24), + 113: uint8(25), + 114: uint8(26), + 115: uint8(27), + 116: uint8(28), + 117: uint8(29), + 118: uint8(30), + 119: uint8(31), + 120: uint8(32), + 121: uint8(33), + 122: uint8(34), + 123: uint8(35), + 124: Uint8FromInt32(-Int32FromInt32(1)), + 125: Uint8FromInt32(-Int32FromInt32(1)), + 126: Uint8FromInt32(-Int32FromInt32(1)), + 127: Uint8FromInt32(-Int32FromInt32(1)), + 128: Uint8FromInt32(-Int32FromInt32(1)), + 129: Uint8FromInt32(-Int32FromInt32(1)), + 130: Uint8FromInt32(-Int32FromInt32(1)), + 131: Uint8FromInt32(-Int32FromInt32(1)), + 132: Uint8FromInt32(-Int32FromInt32(1)), + 133: Uint8FromInt32(-Int32FromInt32(1)), + 134: Uint8FromInt32(-Int32FromInt32(1)), + 135: Uint8FromInt32(-Int32FromInt32(1)), + 136: Uint8FromInt32(-Int32FromInt32(1)), + 137: Uint8FromInt32(-Int32FromInt32(1)), + 138: Uint8FromInt32(-Int32FromInt32(1)), + 139: Uint8FromInt32(-Int32FromInt32(1)), + 140: Uint8FromInt32(-Int32FromInt32(1)), + 141: Uint8FromInt32(-Int32FromInt32(1)), + 142: Uint8FromInt32(-Int32FromInt32(1)), + 143: Uint8FromInt32(-Int32FromInt32(1)), + 144: Uint8FromInt32(-Int32FromInt32(1)), + 145: Uint8FromInt32(-Int32FromInt32(1)), + 146: Uint8FromInt32(-Int32FromInt32(1)), + 147: Uint8FromInt32(-Int32FromInt32(1)), + 148: Uint8FromInt32(-Int32FromInt32(1)), + 149: Uint8FromInt32(-Int32FromInt32(1)), + 150: Uint8FromInt32(-Int32FromInt32(1)), + 151: Uint8FromInt32(-Int32FromInt32(1)), + 152: Uint8FromInt32(-Int32FromInt32(1)), + 153: Uint8FromInt32(-Int32FromInt32(1)), + 154: Uint8FromInt32(-Int32FromInt32(1)), + 155: Uint8FromInt32(-Int32FromInt32(1)), + 156: Uint8FromInt32(-Int32FromInt32(1)), + 157: Uint8FromInt32(-Int32FromInt32(1)), + 158: Uint8FromInt32(-Int32FromInt32(1)), + 159: Uint8FromInt32(-Int32FromInt32(1)), + 160: Uint8FromInt32(-Int32FromInt32(1)), + 161: Uint8FromInt32(-Int32FromInt32(1)), + 162: Uint8FromInt32(-Int32FromInt32(1)), + 163: Uint8FromInt32(-Int32FromInt32(1)), + 164: Uint8FromInt32(-Int32FromInt32(1)), + 165: Uint8FromInt32(-Int32FromInt32(1)), + 166: Uint8FromInt32(-Int32FromInt32(1)), + 167: Uint8FromInt32(-Int32FromInt32(1)), + 168: Uint8FromInt32(-Int32FromInt32(1)), + 169: Uint8FromInt32(-Int32FromInt32(1)), + 170: Uint8FromInt32(-Int32FromInt32(1)), + 171: Uint8FromInt32(-Int32FromInt32(1)), + 172: Uint8FromInt32(-Int32FromInt32(1)), + 173: Uint8FromInt32(-Int32FromInt32(1)), + 174: Uint8FromInt32(-Int32FromInt32(1)), + 175: Uint8FromInt32(-Int32FromInt32(1)), + 176: Uint8FromInt32(-Int32FromInt32(1)), + 177: Uint8FromInt32(-Int32FromInt32(1)), + 178: Uint8FromInt32(-Int32FromInt32(1)), + 179: Uint8FromInt32(-Int32FromInt32(1)), + 180: Uint8FromInt32(-Int32FromInt32(1)), + 181: Uint8FromInt32(-Int32FromInt32(1)), + 182: Uint8FromInt32(-Int32FromInt32(1)), + 183: Uint8FromInt32(-Int32FromInt32(1)), + 184: Uint8FromInt32(-Int32FromInt32(1)), + 185: Uint8FromInt32(-Int32FromInt32(1)), + 186: Uint8FromInt32(-Int32FromInt32(1)), + 187: Uint8FromInt32(-Int32FromInt32(1)), + 188: Uint8FromInt32(-Int32FromInt32(1)), + 189: Uint8FromInt32(-Int32FromInt32(1)), + 190: Uint8FromInt32(-Int32FromInt32(1)), + 191: Uint8FromInt32(-Int32FromInt32(1)), + 192: Uint8FromInt32(-Int32FromInt32(1)), + 193: Uint8FromInt32(-Int32FromInt32(1)), + 194: Uint8FromInt32(-Int32FromInt32(1)), + 195: Uint8FromInt32(-Int32FromInt32(1)), + 196: Uint8FromInt32(-Int32FromInt32(1)), + 197: Uint8FromInt32(-Int32FromInt32(1)), + 198: Uint8FromInt32(-Int32FromInt32(1)), + 199: Uint8FromInt32(-Int32FromInt32(1)), + 200: Uint8FromInt32(-Int32FromInt32(1)), + 201: Uint8FromInt32(-Int32FromInt32(1)), + 202: Uint8FromInt32(-Int32FromInt32(1)), + 203: Uint8FromInt32(-Int32FromInt32(1)), + 204: Uint8FromInt32(-Int32FromInt32(1)), + 205: Uint8FromInt32(-Int32FromInt32(1)), + 206: Uint8FromInt32(-Int32FromInt32(1)), + 207: Uint8FromInt32(-Int32FromInt32(1)), + 208: Uint8FromInt32(-Int32FromInt32(1)), + 209: Uint8FromInt32(-Int32FromInt32(1)), + 210: Uint8FromInt32(-Int32FromInt32(1)), + 211: Uint8FromInt32(-Int32FromInt32(1)), + 212: Uint8FromInt32(-Int32FromInt32(1)), + 213: Uint8FromInt32(-Int32FromInt32(1)), + 214: Uint8FromInt32(-Int32FromInt32(1)), + 215: Uint8FromInt32(-Int32FromInt32(1)), + 216: Uint8FromInt32(-Int32FromInt32(1)), + 217: Uint8FromInt32(-Int32FromInt32(1)), + 218: Uint8FromInt32(-Int32FromInt32(1)), + 219: Uint8FromInt32(-Int32FromInt32(1)), + 220: Uint8FromInt32(-Int32FromInt32(1)), + 221: Uint8FromInt32(-Int32FromInt32(1)), + 222: Uint8FromInt32(-Int32FromInt32(1)), + 223: Uint8FromInt32(-Int32FromInt32(1)), + 224: Uint8FromInt32(-Int32FromInt32(1)), + 225: Uint8FromInt32(-Int32FromInt32(1)), + 226: Uint8FromInt32(-Int32FromInt32(1)), + 227: Uint8FromInt32(-Int32FromInt32(1)), + 228: Uint8FromInt32(-Int32FromInt32(1)), + 229: Uint8FromInt32(-Int32FromInt32(1)), + 230: Uint8FromInt32(-Int32FromInt32(1)), + 231: Uint8FromInt32(-Int32FromInt32(1)), + 232: Uint8FromInt32(-Int32FromInt32(1)), + 233: Uint8FromInt32(-Int32FromInt32(1)), + 234: Uint8FromInt32(-Int32FromInt32(1)), + 235: Uint8FromInt32(-Int32FromInt32(1)), + 236: Uint8FromInt32(-Int32FromInt32(1)), + 237: Uint8FromInt32(-Int32FromInt32(1)), + 238: Uint8FromInt32(-Int32FromInt32(1)), + 239: Uint8FromInt32(-Int32FromInt32(1)), + 240: Uint8FromInt32(-Int32FromInt32(1)), + 241: Uint8FromInt32(-Int32FromInt32(1)), + 242: Uint8FromInt32(-Int32FromInt32(1)), + 243: Uint8FromInt32(-Int32FromInt32(1)), + 244: Uint8FromInt32(-Int32FromInt32(1)), + 245: Uint8FromInt32(-Int32FromInt32(1)), + 246: Uint8FromInt32(-Int32FromInt32(1)), + 247: Uint8FromInt32(-Int32FromInt32(1)), + 248: Uint8FromInt32(-Int32FromInt32(1)), + 249: Uint8FromInt32(-Int32FromInt32(1)), + 250: Uint8FromInt32(-Int32FromInt32(1)), + 251: Uint8FromInt32(-Int32FromInt32(1)), + 252: Uint8FromInt32(-Int32FromInt32(1)), + 253: Uint8FromInt32(-Int32FromInt32(1)), + 254: Uint8FromInt32(-Int32FromInt32(1)), + 255: Uint8FromInt32(-Int32FromInt32(1)), + 256: Uint8FromInt32(-Int32FromInt32(1)), +} + +func X__intscan(tls *TLS, f uintptr, base uint32, pok int32, lim uint64) (r uint64) { + if __ccgo_strace { + trc("tls=%v f=%v base=%v pok=%v lim=%v, (%v:)", tls, f, base, pok, lim, origin(2)) + defer func() { trc("-> %v", r) }() + } + var bs, c, neg, v1, v2, v5, v6 int32 + var val, v3, v4 uintptr + var x uint32 + var y uint64 + _, _, _, _, _, _, _, _, _, _, _, _ = bs, c, neg, val, x, y, v1, v2, v3, v4, v5, v6 + val = uintptr(unsafe.Pointer(&_table6)) + uintptr(1) + neg = 0 + if base > uint32(36) || base == uint32(1) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uint64(0) + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__shgetc(tls, f) + } + v1 = v2 + c = v1 + v5 = v1 + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + if !(v6 != 0) { + break + } + } + if c == int32('+') || c == int32('-') { + neg = -BoolInt32(c == int32('-')) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if (base == uint32(0) || base == uint32(16)) && c == int32('0') { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if c|int32(32) == int32('x') { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + if Int32FromUint8(**(**uint8)(__ccgo_up(val + uintptr(c)))) >= int32(16) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if pok != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + } else { + X__shlim(tls, f, int64(Int32FromInt32(0))) + } + return uint64(0) + } + base = uint32(16) + } else { + if base == uint32(0) { + base = uint32(8) + } + } + } else { + if base == uint32(0) { + base = uint32(10) + } + if uint32(**(**uint8)(__ccgo_up(val + uintptr(c)))) >= base { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + X__shlim(tls, f, int64(Int32FromInt32(0))) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uint64(0) + } + } + if base == uint32(10) { + x = uint32(0) + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) && x <= Uint32FromUint32(0xffffffff)/Uint32FromInt32(10)-Uint32FromInt32(1)) { + break + } + x = x*uint32(10) + Uint32FromInt32(c-Int32FromUint8('0')) + goto _17 + _17: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + y = uint64(x) + for { + if !(Uint32FromInt32(c-int32('0')) < uint32(10) && y <= (Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1))/Uint64FromInt32(10) && uint64(10)*y <= Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)-Uint64FromInt32(c-Int32FromUint8('0'))) { + break + } + y = y*uint64(10) + Uint64FromInt32(c-Int32FromUint8('0')) + goto _21 + _21: + ; + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if Uint32FromInt32(c-int32('0')) >= uint32(10) { + goto done + } + } else { + if !(base&(base-Uint32FromInt32(1)) != 0) { + bs = Int32FromUint8(**(**uint8)(__ccgo_up(__ccgo_ts + 260 + uintptr(uint32(0x17)*base>>int32(5)&uint32(7))))) + x = uint32(0) + for { + if !(uint32(**(**uint8)(__ccgo_up(val + uintptr(c)))) < base && x <= Uint32FromUint32(0xffffffff)/Uint32FromInt32(32)) { + break + } + x = x<>bs) { + break + } + y = y<= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if y >= lim { + if !(lim&Uint64FromInt32(1) != 0) && !(neg != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return lim - uint64(1) + } else { + if y > lim { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return lim + } + } + } + return y ^ Uint64FromInt32(neg) - Uint64FromInt32(neg) +} + +func X__procfdname(tls *TLS, buf uintptr, fd uint32) { + if __ccgo_strace { + trc("tls=%v buf=%v fd=%v, (%v:)", tls, buf, fd, origin(2)) + } + var i, j, v5 uint32 + var v2 uint8 + _, _, _, _ = i, j, v2, v5 + i = uint32(0) + for { + v2 = **(**uint8)(__ccgo_up(__ccgo_ts + 269 + uintptr(i))) + **(**uint8)(__ccgo_up(buf + uintptr(i))) = v2 + if !(v2 != 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if !(fd != 0) { + **(**uint8)(__ccgo_up(buf + uintptr(i))) = uint8('0') + **(**uint8)(__ccgo_up(buf + uintptr(i+uint32(1)))) = uint8(0) + return + } + j = fd + for { + if !(j != 0) { + break + } + goto _3 + _3: + ; + j = j / uint32(10) + i = i + 1 + } + **(**uint8)(__ccgo_up(buf + uintptr(i))) = uint8(0) + for { + if !(fd != 0) { + break + } + i = i - 1 + v5 = i + **(**uint8)(__ccgo_up(buf + uintptr(v5))) = uint8(uint32('0') + fd%uint32(10)) + goto _4 + _4: + ; + fd = fd / uint32(10) + } +} + +/* The shcnt field stores the number of bytes read so far, offset by + * the value of buf-rpos at the last function call (__shlim or __shgetc), + * so that between calls the inline shcnt macro can add rpos-buf to get + * the actual count. */ + +func X__shlim(tls *TLS, f uintptr, lim Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v lim=%v, (%v:)", tls, f, lim, origin(2)) + } + (*TFILE)(unsafe.Pointer(f)).Fshlim = lim + (*TFILE)(unsafe.Pointer(f)).Fshcnt = int64((*TFILE)(unsafe.Pointer(f)).Fbuf) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + /* If lim is nonzero, rend must be a valid pointer. */ + if lim != 0 && int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos) > lim { + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frpos + uintptr(lim) + } else { + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frend + } +} + +func X__shgetc(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c, v1 int32 + var cnt Toff_t + var v2 bool + _, _, _, _ = c, cnt, v1, v2 + cnt = (*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) + if v2 = (*TFILE)(unsafe.Pointer(f)).Fshlim != 0 && cnt >= (*TFILE)(unsafe.Pointer(f)).Fshlim; !v2 { + v1 = X__uflow(tls, f) + c = v1 + } + if v2 || v1 < 0 { + (*TFILE)(unsafe.Pointer(f)).Fshcnt = int64((*TFILE)(unsafe.Pointer(f)).Fbuf) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + cnt + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frpos + (*TFILE)(unsafe.Pointer(f)).Fshlim = int64(-int32(1)) + return -int32(1) + } + cnt = cnt + 1 + if (*TFILE)(unsafe.Pointer(f)).Fshlim != 0 && int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos) > (*TFILE)(unsafe.Pointer(f)).Fshlim-cnt { + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frpos + uintptr((*TFILE)(unsafe.Pointer(f)).Fshlim-cnt) + } else { + (*TFILE)(unsafe.Pointer(f)).Fshend = (*TFILE)(unsafe.Pointer(f)).Frend + } + (*TFILE)(unsafe.Pointer(f)).Fshcnt = int64((*TFILE)(unsafe.Pointer(f)).Fbuf) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + cnt + if (*TFILE)(unsafe.Pointer(f)).Frpos <= (*TFILE)(unsafe.Pointer(f)).Fbuf { + **(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos + uintptr(-Int32FromInt32(1)))) = Uint8FromInt32(c) + } + return c +} + +func X__syscall_ret(tls *TLS, r uint64) (r1 int64) { + if __ccgo_strace { + trc("tls=%v r=%v, (%v:)", tls, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + if r > -Uint64FromUint64(4096) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = Int32FromUint64(-r) + return int64(-int32(1)) + } + return Int64FromUint64(r) +} + +type TElf_Symndx = uint32 + +type Tdl_phdr_info = struct { + Fdlpi_addr TElf64_Addr + Fdlpi_name uintptr + Fdlpi_phdr uintptr + Fdlpi_phnum TElf64_Half + Fdlpi_adds uint64 + Fdlpi_subs uint64 + Fdlpi_tls_modid Tsize_t + Fdlpi_tls_data uintptr +} + +type Tlink_map = struct { + Fl_addr TElf64_Addr + Fl_name uintptr + Fl_ld uintptr + Fl_next uintptr + Fl_prev uintptr +} + +type Tr_debug = struct { + Fr_version int32 + Fr_map uintptr + Fr_brk TElf64_Addr + Fr_state int32 + Fr_ldbase TElf64_Addr +} + +const _RT_CONSISTENT = 0 +const _RT_ADD = 1 +const _RT_DELETE = 2 +const VERSION = "1.2.5" + +const IPC_CREAT = 512 +const IPC_EXCL = 1024 +const IPC_INFO = 3 +const IPC_NOWAIT = 2048 +const IPC_RMID = 0 +const IPC_SET = 1 +const IPC_STAT = 2 +const __ipc_perm_key = 0 +const __ipc_perm_seq = 0 + +type Tkey_t = int32 + +type Tipc_perm = struct { + F__key Tkey_t + Fuid Tuid_t + Fgid Tgid_t + Fcuid Tuid_t + Fcgid Tgid_t + Fmode Tmode_t + F__seq int32 + F__pad1 int64 + F__pad2 int64 +} + +func Xftok(tls *TLS, path uintptr, id int32) (r Tkey_t) { + if __ccgo_strace { + trc("tls=%v path=%v id=%v, (%v:)", tls, path, id, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* st at bp+0 */ Tstat + if Xstat(tls, path, bp) < 0 { + return -int32(1) + } + return Int32FromUint64((**(**Tstat)(__ccgo_up(bp))).Fst_ino&Uint64FromInt32(0xffff) | (**(**Tstat)(__ccgo_up(bp))).Fst_dev&Uint64FromInt32(0xff)< %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall3(tls, int64(SYS_msgctl), int64(q), int64(cmd & ^(Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) | Int32FromInt32(IPC_64)), int64(buf))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xmsgget(tls *TLS, k Tkey_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v k=%v flag=%v, (%v:)", tls, k, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_msgget), int64(k), int64(flag))))) +} + +func Xmsgrcv(tls *TLS, q int32, m uintptr, len1 Tsize_t, type1 int64, flag int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v q=%v m=%v len1=%v type1=%v flag=%v, (%v:)", tls, q, m, len1, type1, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_msgrcv), int64(q), int64(m), Int64FromUint64(len1), type1, int64(flag), 0))) +} + +func Xmsgsnd(tls *TLS, q int32, m uintptr, len1 Tsize_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v q=%v m=%v len1=%v flag=%v, (%v:)", tls, q, m, len1, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_msgsnd), int64(q), int64(m), Int64FromUint64(len1), int64(flag), 0, 0)))) +} + +const GETALL = 13 +const GETNCNT = 14 +const GETPID = 11 +const GETVAL = 12 +const GETZCNT = 15 +const SEM_INFO = 19 +const SEM_STAT = 18 +const SEM_STAT_ANY = 20 +const SEM_UNDO = 4096 +const SETALL = 17 +const SETVAL = 16 +const _SEM_SEMUN_UNDEFINED = 1 + +type Tsemid_ds = struct { + Fsem_perm Tipc_perm + Fsem_otime Ttime_t + Fsem_ctime Ttime_t + Fsem_nsems uint16 + F__sem_nsems_pad [6]uint8 + F__unused3 int64 + F__unused4 int64 +} + +type Tseminfo = struct { + Fsemmap int32 + Fsemmni int32 + Fsemmns int32 + Fsemmnu int32 + Fsemmsl int32 + Fsemopm int32 + Fsemume int32 + Fsemusz int32 + Fsemvmx int32 + Fsemaem int32 +} + +type Tsembuf = struct { + Fsem_num uint16 + Fsem_op int16 + Fsem_flg int16 +} + +type Tsemun = struct { + Fbuf [0]uintptr + Farray [0]uintptr + Fval int32 + F__ccgo_pad3 [4]byte +} + +func Xsemctl(tls *TLS, id int32, num int32, cmd int32, va uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v id=%v num=%v cmd=%v va=%v, (%v:)", tls, id, num, cmd, va, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ap Tva_list + var r int32 + var _ /* arg at bp+0 */ Tsemun + _, _ = ap, r + *(*Tsemun)(unsafe.Pointer(bp)) = Tsemun{} + *(*int32)(unsafe.Pointer(bp)) = 0 + switch cmd & ^(Int32FromInt32(IPC_STAT) & Int32FromInt32(0x100)) { + case int32(SETVAL): + fallthrough + case int32(GETALL): + fallthrough + case int32(SETALL): + fallthrough + case int32(IPC_SET): + fallthrough + case int32(IPC_INFO): + fallthrough + case int32(SEM_INFO): + fallthrough + case Int32FromInt32(IPC_STAT) & ^(Int32FromInt32(IPC_STAT) & Int32FromInt32(0x100)): + fallthrough + case (Int32FromInt32(18) | Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) & ^(Int32FromInt32(IPC_STAT) & Int32FromInt32(0x100)): + fallthrough + case (Int32FromInt32(20) | Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) & ^(Int32FromInt32(IPC_STAT) & Int32FromInt32(0x100)): + ap = va + **(**Tsemun)(__ccgo_up(bp)) = *(*Tsemun)(unsafe.Pointer(VaOther(&ap, 8))) + _ = ap + } + r = int32(X__syscall4(tls, int64(SYS_semctl), int64(id), int64(num), int64(cmd & ^(Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) | Int32FromInt32(IPC_64)), int64(*(*uintptr)(unsafe.Pointer(bp))))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xsemget(tls *TLS, key Tkey_t, n int32, fl int32) (r int32) { + if __ccgo_strace { + trc("tls=%v key=%v n=%v fl=%v, (%v:)", tls, key, n, fl, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* The kernel uses the wrong type for the sem_nsems member + * of struct semid_ds, and thus might not check that the + * n fits in the correct (per POSIX) userspace type, so + * we have to check here. */ + if n > int32(USHRT_MAX) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_semget), int64(key), int64(n), int64(fl))))) +} + +func Xsemop(tls *TLS, id int32, buf uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v id=%v buf=%v n=%v, (%v:)", tls, id, buf, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_semop), int64(id), int64(buf), Int64FromUint64(n))))) +} + +const NO_TIME32 = 0 +const __key = 0 +const __seq = 0 + +type Tipc_perm1 = struct { + Fkey Tkey_t + Fuid Tuid_t + Fgid Tgid_t + Fcuid Tuid_t + Fcgid Tgid_t + Fmode Tmode_t + Fseq int32 + F__pad1 int64 + F__pad2 int64 +} + +type Tsemid_ds1 = struct { + Fsem_perm Tipc_perm1 + Fsem_otime Ttime_t + Fsem_ctime Ttime_t + Fsem_nsems uint16 + F__sem_nsems_pad [6]uint8 + F__unused3 int64 + F__unused4 int64 +} + +func Xsemtimedop(tls *TLS, id int32, buf uintptr, n Tsize_t, ts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v id=%v buf=%v n=%v ts=%v, (%v:)", tls, id, buf, n, ts, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_semtimedop), int64(id), int64(buf), Int64FromUint64(n), int64(ts))))) +} + +const SHMLBA = 4096 +const SHM_DEST = 512 +const SHM_EXEC = 32768 +const SHM_HUGETLB = 2048 +const SHM_HUGE_16GB = 2281701376 +const SHM_HUGE_16MB = 1610612736 +const SHM_HUGE_1GB = 2013265920 +const SHM_HUGE_1MB = 1342177280 +const SHM_HUGE_256MB = 1879048192 +const SHM_HUGE_2GB = 2080374784 +const SHM_HUGE_2MB = 1409286144 +const SHM_HUGE_32MB = 1677721600 +const SHM_HUGE_512KB = 1275068416 +const SHM_HUGE_512MB = 1946157056 +const SHM_HUGE_64KB = 1073741824 +const SHM_HUGE_8MB = 1543503872 +const SHM_HUGE_MASK = 63 +const SHM_HUGE_SHIFT = 26 +const SHM_INFO = 14 +const SHM_LOCK = 11 +const SHM_LOCKED = 1024 +const SHM_NORESERVE = 4096 +const SHM_R = 256 +const SHM_RDONLY = 4096 +const SHM_REMAP = 16384 +const SHM_RND = 8192 +const SHM_STAT = 13 +const SHM_STAT_ANY = 15 +const SHM_UNLOCK = 12 +const SHM_W = 128 + +type Tshmid_ds = struct { + Fshm_perm Tipc_perm + Fshm_segsz Tsize_t + Fshm_atime Ttime_t + Fshm_dtime Ttime_t + Fshm_ctime Ttime_t + Fshm_cpid Tpid_t + Fshm_lpid Tpid_t + Fshm_nattch uint64 + F__pad1 uint64 + F__pad2 uint64 +} + +type Tshminfo = struct { + Fshmmax uint64 + Fshmmin uint64 + Fshmmni uint64 + Fshmseg uint64 + Fshmall uint64 + F__unused [4]uint64 +} + +type Tshm_info = struct { + F__used_ids int32 + Fshm_tot uint64 + Fshm_rss uint64 + Fshm_swp uint64 + F__swap_attempts uint64 + F__swap_successes uint64 +} + +type Tshmatt_t = uint64 + +func Xshmat(tls *TLS, id int32, addr uintptr, flag int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v id=%v addr=%v flag=%v, (%v:)", tls, id, addr, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_shmat), int64(id), int64(addr), int64(flag))))) +} + +func Xshmctl(tls *TLS, id int32, cmd int32, buf uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v id=%v cmd=%v buf=%v, (%v:)", tls, id, cmd, buf, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall3(tls, int64(SYS_shmctl), int64(id), int64(cmd & ^(Int32FromInt32(IPC_STAT)&Int32FromInt32(0x100)) | Int32FromInt32(IPC_64)), int64(buf))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xshmdt(tls *TLS, addr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v, (%v:)", tls, addr, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_shmdt), int64(addr))))) +} + +func Xshmget(tls *TLS, key Tkey_t, size Tsize_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v key=%v size=%v flag=%v, (%v:)", tls, key, size, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + if size > Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + size = Uint64FromUint64(0xffffffffffffffff) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_shmget), int64(key), Int64FromUint64(size), int64(flag))))) +} + +type Tpasswd = struct { + Fpw_name uintptr + Fpw_passwd uintptr + Fpw_uid Tuid_t + Fpw_gid Tgid_t + Fpw_gecos uintptr + Fpw_dir uintptr + Fpw_shell uintptr +} + +func Xcuserid(tls *TLS, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v buf=%v, (%v:)", tls, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(2112) + defer tls.Free(2112) + var len1 Tsize_t + var _ /* ppw at bp+48 */ uintptr + var _ /* pw at bp+0 */ Tpasswd + var _ /* pwb at bp+56 */ [256]int64 + _ = len1 + if buf != 0 { + **(**uint8)(__ccgo_up(buf)) = uint8(0) + } + Xgetpwuid_r(tls, Xgeteuid(tls), bp, bp+56, uint64(2048), bp+48) + if !(**(**uintptr)(__ccgo_up(bp + 48)) != 0) { + return buf + } + len1 = Xstrnlen(tls, (**(**Tpasswd)(__ccgo_up(bp))).Fpw_name, uint64(L_cuserid)) + if len1 == uint64(L_cuserid) { + return buf + } + if !(buf != 0) { + buf = uintptr(unsafe.Pointer(&_usridbuf)) + } + Xmemcpy(tls, buf, (**(**Tpasswd)(__ccgo_up(bp))).Fpw_name, len1+uint64(1)) + return buf +} + +var _usridbuf [20]uint8 + +func Xvwarn(tls *TLS, fmt uintptr, ap Tva_list) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + Xfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), __ccgo_ts+284, VaList(bp+8, Xprogram_invocation_short_name)) + if fmt != 0 { + Xvfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), fmt, ap) + Xfputs(tls, __ccgo_ts+289, uintptr(unsafe.Pointer(&X__stderr_FILE))) + } + Xperror(tls, uintptr(0)) +} + +func Xvwarnx(tls *TLS, fmt uintptr, ap Tva_list) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + Xfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), __ccgo_ts+284, VaList(bp+8, Xprogram_invocation_short_name)) + if fmt != 0 { + Xvfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), fmt, ap) + } + Xputc(tls, int32('\n'), uintptr(unsafe.Pointer(&X__stderr_FILE))) +} + +func Xverr(tls *TLS, status int32, fmt uintptr, ap Tva_list) { + if __ccgo_strace { + trc("tls=%v status=%v fmt=%v ap=%v, (%v:)", tls, status, fmt, ap, origin(2)) + } + Xvwarn(tls, fmt, ap) + _exit(tls, status) +} + +func Xverrx(tls *TLS, status int32, fmt uintptr, ap Tva_list) { + if __ccgo_strace { + trc("tls=%v status=%v fmt=%v ap=%v, (%v:)", tls, status, fmt, ap, origin(2)) + } + Xvwarnx(tls, fmt, ap) + _exit(tls, status) +} + +func Xwarn(tls *TLS, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + Xvwarn(tls, fmt, ap) + _ = ap +} + +func Xwarnx(tls *TLS, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + Xvwarnx(tls, fmt, ap) + _ = ap +} + +func Xerr(tls *TLS, status int32, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v status=%v fmt=%v va=%v, (%v:)", tls, status, fmt, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + Xverr(tls, status, fmt, ap) + _ = ap +} + +func Xerrx(tls *TLS, status int32, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v status=%v fmt=%v va=%v, (%v:)", tls, status, fmt, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + Xverrx(tls, status, fmt, ap) + _ = ap +} + +func Xeuidaccess(tls *TLS, filename uintptr, amode int32) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v amode=%v, (%v:)", tls, filename, amode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfaccessat(tls, -int32(100), filename, amode, int32(AT_EACCESS)) +} + +func Xeaccess(tls *TLS, filename uintptr, amode int32) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v amode=%v, (%v:)", tls, filename, amode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xeuidaccess(tls, filename, amode) +} + +const FTW_CHDIR = 4 +const FTW_D = 2 +const FTW_DEPTH = 8 +const FTW_DNR = 3 +const FTW_DP = 6 +const FTW_F = 1 +const FTW_MOUNT = 2 +const FTW_NS = 4 +const FTW_PHYS = 1 +const FTW_SL = 5 +const FTW_SLN = 7 + +type TFTW = struct { + Fbase int32 + Flevel int32 +} + +type t__ccgo_fp__Xftw_1 = func(*TLS, uintptr, uintptr, int32) int32 + +func Xftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v __ccgo_fp_fn=%v fd_limit=%v, (%v:)", tls, path, __ccgo_fp_fn, fd_limit, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* The following cast assumes that calling a function with one + * argument more than it needs behaves as expected. This is + * actually undefined, but works on all real-world machines. */ + return Xnftw(tls, path, __ccgo_fp_fn, fd_limit, int32(FTW_PHYS)) +} + +const STATX_ALL = 4095 +const STATX_ATIME = 32 +const STATX_BASIC_STATS = 2047 +const STATX_BLOCKS = 1024 +const STATX_BTIME = 2048 +const STATX_CTIME = 128 +const STATX_GID = 16 +const STATX_INO = 256 +const STATX_MODE = 2 +const STATX_MTIME = 64 +const STATX_NLINK = 4 +const STATX_SIZE = 512 +const STATX_TYPE = 1 +const STATX_UID = 8 +const S_IEXEC = 64 +const S_IREAD = 256 +const S_IWRITE = 128 + +type Tstatx_timestamp = struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + F__pad Tuint32_t +} + +type Tstatx = struct { + Fstx_mask Tuint32_t + Fstx_blksize Tuint32_t + Fstx_attributes Tuint64_t + Fstx_nlink Tuint32_t + Fstx_uid Tuint32_t + Fstx_gid Tuint32_t + Fstx_mode Tuint16_t + F__pad0 [1]Tuint16_t + Fstx_ino Tuint64_t + Fstx_size Tuint64_t + Fstx_blocks Tuint64_t + Fstx_attributes_mask Tuint64_t + Fstx_atime Tstatx_timestamp + Fstx_btime Tstatx_timestamp + Fstx_ctime Tstatx_timestamp + Fstx_mtime Tstatx_timestamp + Fstx_rdev_major Tuint32_t + Fstx_rdev_minor Tuint32_t + Fstx_dev_major Tuint32_t + Fstx_dev_minor Tuint32_t + F__pad1 [14]Tuint64_t +} + +type Ttimezone = struct { + Ftz_minuteswest int32 + Ftz_dsttime int32 +} + +func Xfutimes(tls *TLS, fd int32, tv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v tv=%v, (%v:)", tls, fd, tv, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* times at bp+0 */ [2]Ttimespec + if !(tv != 0) { + return Xfutimens(tls, fd, uintptr(0)) + } + (**(**[2]Ttimespec)(__ccgo_up(bp)))[0].Ftv_sec = (**(**Ttimeval)(__ccgo_up(tv))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[0].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(tv))).Ftv_usec * int64(1000) + (**(**[2]Ttimespec)(__ccgo_up(bp)))[int32(1)].Ftv_sec = (**(**Ttimeval)(__ccgo_up(tv + 1*16))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[int32(1)].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(tv + 1*16))).Ftv_usec * int64(1000) + return Xfutimens(tls, fd, bp) +} + +const prlimit64 = 0 + +func Xgetdtablesize(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* rl at bp+0 */ Trlimit + _ = v1 + Xgetrlimit(tls, int32(RLIMIT_NOFILE), bp) + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur < uint64(INT_MAX) { + v1 = (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur + } else { + v1 = uint64(INT_MAX) + } + return Int32FromUint64(v1) +} + +func Xgetloadavg(tls *TLS, a uintptr, n int32) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v n=%v, (%v:)", tls, a, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(368) + defer tls.Free(368) + var i, v1 int32 + var _ /* si at bp+0 */ Tsysinfo + _, _ = i, v1 + if n <= 0 { + if n != 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 + } + Xsysinfo(tls, bp) + if n > int32(3) { + n = int32(3) + } + i = 0 + for { + if !(i < n) { + break + } + **(**float64)(__ccgo_up(a + uintptr(i)*8)) = float64(Float64FromFloat64(1) / float64(Int32FromInt32(1)< %v", r) }() + } + return Int32FromUint64(X__libc.Fpage_size) +} + +const B0 = 0 +const B1000000 = 4104 +const B110 = 3 +const B115200 = 4098 +const B1152000 = 4105 +const B1200 = 9 +const B134 = 4 +const B150 = 5 +const B1500000 = 4106 +const B1800 = 10 +const B19200 = 14 +const B200 = 6 +const B2000000 = 4107 +const B230400 = 4099 +const B2400 = 11 +const B2500000 = 4108 +const B300 = 7 +const B3000000 = 4109 +const B3500000 = 4110 +const B38400 = 15 +const B4000000 = 4111 +const B460800 = 4100 +const B4800 = 12 +const B50 = 1 +const B500000 = 4101 +const B57600 = 4097 +const B576000 = 4102 +const B600 = 8 +const B75 = 2 +const B921600 = 4103 +const B9600 = 13 +const BRKINT = 2 +const BS0 = 0 +const BS1 = 8192 +const BSDLY = 8192 +const CBAUD = 4111 +const CBAUDEX = 4096 +const CIBAUD = 269418496 +const CLOCAL = 2048 +const CMSPAR = 1073741824 +const CR0 = 0 +const CR1 = 512 +const CR2 = 1024 +const CR3 = 1536 +const CRDLY = 1536 +const CREAD = 128 +const CRTSCTS = 2147483648 +const CS5 = 0 +const CS6 = 16 +const CS7 = 32 +const CS8 = 48 +const CSIZE = 48 +const CSTOPB = 64 +const ECHO = 8 +const ECHOCTL = 512 +const ECHOE = 16 +const ECHOK = 32 +const ECHOKE = 2048 +const ECHONL = 64 +const ECHOPRT = 1024 +const EXTA = 14 +const EXTB = 15 +const EXTPROC = 65536 +const FF0 = 0 +const FF1 = 32768 +const FFDLY = 32768 +const FLUSHO = 4096 +const HUPCL = 1024 +const ICANON = 2 +const ICRNL = 256 +const IEXTEN = 32768 +const IGNBRK = 1 +const IGNCR = 128 +const IGNPAR = 4 +const IMAXBEL = 8192 +const INLCR = 64 +const INPCK = 16 +const ISIG = 1 +const ISTRIP = 32 +const IUCLC = 512 +const IUTF8 = 16384 +const IXANY = 2048 +const IXOFF = 4096 +const IXON = 1024 +const NCCS = 32 +const NL0 = 0 +const NL1 = 256 +const NLDLY = 256 +const NOFLSH = 128 +const OCRNL = 8 +const OFDEL = 128 +const OFILL = 64 +const OLCUC = 2 +const ONLCR = 4 +const ONLRET = 32 +const ONOCR = 16 +const OPOST = 1 +const PARENB = 256 +const PARMRK = 8 +const PARODD = 512 +const PENDIN = 16384 +const TAB0 = 0 +const TAB1 = 2048 +const TAB2 = 4096 +const TAB3 = 6144 +const TABDLY = 6144 +const TCIFLUSH = 0 +const TCIOFF = 2 +const TCIOFLUSH = 2 +const TCION = 3 +const TCOFLUSH = 1 +const TCOOFF = 0 +const TCOON = 1 +const TCSADRAIN = 1 +const TCSAFLUSH = 2 +const TCSANOW = 0 +const TOSTOP = 256 +const VDISCARD = 13 +const VEOF = 4 +const VEOL = 11 +const VEOL2 = 16 +const VERASE = 2 +const VINTR = 0 +const VKILL = 3 +const VLNEXT = 15 +const VMIN = 6 +const VQUIT = 1 +const VREPRINT = 12 +const VSTART = 8 +const VSTOP = 9 +const VSUSP = 10 +const VSWTC = 7 +const VT0 = 0 +const VT1 = 16384 +const VTDLY = 16384 +const VTIME = 5 +const VWERASE = 14 +const XCASE = 4 +const XTABS = 6144 + +type Twinsize = struct { + Fws_row uint16 + Fws_col uint16 + Fws_xpixel uint16 + Fws_ypixel uint16 +} + +type Tcc_t = uint8 + +type Tspeed_t = uint32 + +type Ttcflag_t = uint32 + +type Ttermios = struct { + Fc_iflag Ttcflag_t + Fc_oflag Ttcflag_t + Fc_cflag Ttcflag_t + Fc_lflag Ttcflag_t + Fc_line Tcc_t + Fc_cc [32]Tcc_t + F__c_ispeed Tspeed_t + F__c_ospeed Tspeed_t +} + +func Xgetpass(tls *TLS, prompt uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v prompt=%v, (%v:)", tls, prompt, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var fd, v1 int32 + var l Tssize_t + var v2 uintptr + var _ /* s at bp+0 */ Ttermios + var _ /* t at bp+60 */ Ttermios + _, _, _, _ = fd, l, v1, v2 + v1 = Xopen(tls, __ccgo_ts+292, Int32FromInt32(O_RDWR)|Int32FromInt32(O_NOCTTY)|Int32FromInt32(O_CLOEXEC), 0) + fd = v1 + if v1 < 0 { + return uintptr(0) + } + Xtcgetattr(tls, fd, bp+60) + **(**Ttermios)(__ccgo_up(bp)) = **(**Ttermios)(__ccgo_up(bp + 60)) + (**(**Ttermios)(__ccgo_up(bp + 60))).Fc_lflag &= Uint32FromInt32(^(Int32FromInt32(ECHO) | Int32FromInt32(ISIG))) + (**(**Ttermios)(__ccgo_up(bp + 60))).Fc_lflag |= uint32(ICANON) + (**(**Ttermios)(__ccgo_up(bp + 60))).Fc_iflag &= Uint32FromInt32(^(Int32FromInt32(INLCR) | Int32FromInt32(IGNCR))) + (**(**Ttermios)(__ccgo_up(bp + 60))).Fc_iflag |= uint32(ICRNL) + Xtcsetattr(tls, fd, int32(TCSAFLUSH), bp+60) + Xtcdrain(tls, fd) + Xdprintf(tls, fd, __ccgo_ts+15, VaList(bp+128, prompt)) + l = Xread(tls, fd, uintptr(unsafe.Pointer(&_password)), uint64(128)) + if l >= 0 { + if l > 0 && Int32FromUint8(_password[l-int64(1)]) == int32('\n') || Uint64FromInt64(l) == uint64(128) { + l = l - 1 + } + _password[l] = uint8(0) + } + Xtcsetattr(tls, fd, int32(TCSAFLUSH), bp) + Xdprintf(tls, fd, __ccgo_ts+301, 0) + Xclose(tls, fd) + if l < 0 { + v2 = uintptr(0) + } else { + v2 = uintptr(unsafe.Pointer(&_password)) + } + return v2 +} + +var _password [128]uint8 + +var _defshells = [18]uint8{'/', 'b', 'i', 'n', '/', 's', 'h', 10, '/', 'b', 'i', 'n', '/', 'c', 's', 'h', 10} + +var _line uintptr +var _linesize Tsize_t +var _f uintptr + +func Xendusershell(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + if _f != 0 { + Xfclose(tls, _f) + } + _f = uintptr(0) +} + +func Xsetusershell(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + if !(_f != 0) { + _f = Xfopen(tls, __ccgo_ts+303, __ccgo_ts+315) + } + if !(_f != 0) { + _f = Xfmemopen(tls, uintptr(unsafe.Pointer(&_defshells)), Uint64FromInt64(18)-Uint64FromInt32(1), __ccgo_ts+319) + } +} + +func Xgetusershell(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tssize_t + _ = l + if !(_f != 0) { + Xsetusershell(tls) + } + if !(_f != 0) { + return uintptr(0) + } + l = Xgetline(tls, uintptr(unsafe.Pointer(&_line)), uintptr(unsafe.Pointer(&_linesize)), _f) + if l <= 0 { + return uintptr(0) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(_line + uintptr(l-int64(1))))) == int32('\n') { + **(**uint8)(__ccgo_up(_line + uintptr(l-int64(1)))) = uint8(0) + } + return _line +} + +const ANYMARK = 1 +const FLUSHBAND = 4 +const FLUSHR = 1 +const FLUSHRW = 3 +const FLUSHW = 2 +const FMNAMESZ = 8 +const I_ATMARK = 21279 +const I_CANPUT = 21282 +const I_CKBAND = 21277 +const I_FDINSERT = 21264 +const I_FIND = 21259 +const I_FLUSH = 21253 +const I_FLUSHBAND = 21276 +const I_GETBAND = 21278 +const I_GETCLTIME = 21281 +const I_GETSIG = 21258 +const I_GRDOPT = 21255 +const I_GWROPT = 21268 +const I_LINK = 21260 +const I_LIST = 21269 +const I_LOOK = 21252 +const I_NREAD = 21249 +const I_PEEK = 21263 +const I_PLINK = 21270 +const I_POP = 21251 +const I_PUNLINK = 21271 +const I_PUSH = 21250 +const I_RECVFD = 21262 +const I_SENDFD = 21265 +const I_SETCLTIME = 21280 +const I_SETSIG = 21257 +const I_SRDOPT = 21254 +const I_STR = 21256 +const I_SWROPT = 21267 +const I_UNLINK = 21261 +const LASTMARK = 2 +const MORECTL = 1 +const MOREDATA = 2 +const MSG_ANY = 2 +const MSG_BAND = 4 +const MSG_HIPRI = 1 +const MUXID_ALL = -1 +const RMSGD = 1 +const RMSGN = 2 +const RNORM = 0 +const RPROTDAT = 4 +const RPROTDIS = 8 +const RPROTMASK = 28 +const RPROTNORM = 16 +const RS_HIPRI = 1 +const SNDPIPE = 2 +const SNDZERO = 1 +const S_BANDURG = 512 +const S_ERROR = 16 +const S_HANGUP = 32 +const S_HIPRI = 2 +const S_INPUT = 1 +const S_MSG = 8 +const S_OUTPUT = 4 +const S_RDBAND = 128 +const S_RDNORM = 64 +const S_WRBAND = 256 +const S_WRNORM = 4 +const __SID = 21248 + +type Tbandinfo = struct { + Fbi_pri uint8 + Fbi_flag int32 +} + +type Tstrbuf = struct { + Fmaxlen int32 + Flen1 int32 + Fbuf uintptr +} + +type Tstrpeek = struct { + Fctlbuf Tstrbuf + Fdatabuf Tstrbuf + Fflags uint32 +} + +type Tstrfdinsert = struct { + Fctlbuf Tstrbuf + Fdatabuf Tstrbuf + Fflags uint32 + Ffildes int32 + Foffset int32 +} + +type Tstrioctl = struct { + Fic_cmd int32 + Fic_timout int32 + Fic_len int32 + Fic_dp uintptr +} + +type Tstrrecvfd = struct { + Ffd int32 + Fuid int32 + Fgid int32 + F__fill [8]uint8 +} + +type Tstr_mlist = struct { + Fl_name [9]uint8 +} + +type Tstr_list = struct { + Fsl_nmods int32 + Fsl_modlist uintptr +} + +func Xisastream(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if Xfcntl(tls, fd, int32(F_GETFD), 0) < 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xlutimes(tls *TLS, filename uintptr, tv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v tv=%v, (%v:)", tls, filename, tv, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1 uintptr + var _ /* times at bp+0 */ [2]Ttimespec + _ = v1 + if tv != 0 { + (**(**[2]Ttimespec)(__ccgo_up(bp)))[0].Ftv_sec = (**(**Ttimeval)(__ccgo_up(tv))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[0].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(tv))).Ftv_usec * int64(1000) + (**(**[2]Ttimespec)(__ccgo_up(bp)))[int32(1)].Ftv_sec = (**(**Ttimeval)(__ccgo_up(tv + 1*16))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[int32(1)].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(tv + 1*16))).Ftv_usec * int64(1000) + } + if tv != 0 { + v1 = bp + } else { + v1 = uintptr(0) + } + return Xutimensat(tls, -int32(100), filename, v1, int32(AT_SYMLINK_NOFOLLOW)) +} + +const UL_GETFSIZE = 1 +const UL_SETFSIZE = 2 + +func Xulimit(tls *TLS, cmd int32, va uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v cmd=%v va=%v, (%v:)", tls, cmd, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ap Tva_list + var val int64 + var _ /* rl at bp+0 */ Trlimit + _, _ = ap, val + Xgetrlimit(tls, int32(RLIMIT_FSIZE), bp) + if cmd == int32(UL_SETFSIZE) { + ap = va + val = VaInt64(&ap) + _ = ap + (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur = uint64(512) * Uint64FromInt64(val) + if Xsetrlimit(tls, int32(RLIMIT_FSIZE), bp) != 0 { + return int64(-int32(1)) + } + } + return Int64FromUint64((**(**Trlimit)(__ccgo_up(bp))).Frlim_cur / uint64(512)) +} + +const BOOT_TIME = 2 +const DEAD_PROCESS = 8 +const EMPTY = 0 +const INIT_PROCESS = 5 +const LOGIN_PROCESS = 6 +const NEW_TIME = 3 +const OLD_TIME = 4 +const RUN_LVL = 1 +const USER_PROCESS = 7 +const e_exit = 0 +const e_termination = 0 + +type Tutmpx = struct { + Fut_type int16 + F__ut_pad1 int16 + Fut_pid Tpid_t + Fut_line [32]uint8 + Fut_id [4]uint8 + Fut_user [32]uint8 + Fut_host [256]uint8 + Fut_exit struct { + F__e_termination int16 + F__e_exit int16 + } + Fut_session int32 + F__ut_pad2 int32 + Fut_tv Ttimeval + Fut_addr_v6 [4]uint32 + F__unused [20]uint8 +} + +func Xendutxent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xsetutxent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xgetutxent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return UintptrFromInt32(0) +} + +func Xgetutxid(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return UintptrFromInt32(0) +} + +func Xgetutxline(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return UintptrFromInt32(0) +} + +func Xpututxline(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return UintptrFromInt32(0) +} + +func Xupdwtmpx(tls *TLS, f uintptr, u uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v u=%v, (%v:)", tls, f, u, origin(2)) + } +} + +func ___utmpxname(tls *TLS, f uintptr) (r int32) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOPNOTSUPP) + return -int32(1) +} + +func Xendutent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xendutxent(tls) +} + +func Xgetutent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetutxent(tls) +} + +func Xgetutid(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetutxid(tls, ut) +} + +func Xgetutline(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetutxline(tls, ut) +} + +func Xpututline(tls *TLS, ut uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ut=%v, (%v:)", tls, ut, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xpututxline(tls, ut) +} + +func Xsetutent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xsetutxent(tls) +} + +func Xupdwtmp(tls *TLS, f uintptr, u uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v u=%v, (%v:)", tls, f, u, origin(2)) + } + Xupdwtmpx(tls, f, u) +} + +const ADJ_ESTERROR = 8 +const ADJ_FREQUENCY = 2 +const ADJ_MAXERROR = 4 +const ADJ_MICRO = 4096 +const ADJ_NANO = 8192 +const ADJ_OFFSET = 1 +const ADJ_OFFSET_SINGLESHOT = 32769 +const ADJ_OFFSET_SS_READ = 40961 +const ADJ_SETOFFSET = 256 +const ADJ_STATUS = 16 +const ADJ_TAI = 128 +const ADJ_TICK = 16384 +const ADJ_TIMECONST = 32 +const MAXTC = 6 +const MOD_CLKA = 32769 +const MOD_CLKB = 16384 +const MOD_ESTERROR = 8 +const MOD_FREQUENCY = 2 +const MOD_MAXERROR = 4 +const MOD_MICRO = 4096 +const MOD_NANO = 8192 +const MOD_OFFSET = 1 +const MOD_STATUS = 16 +const MOD_TAI = 128 +const MOD_TIMECONST = 32 +const STA_CLK = 32768 +const STA_CLOCKERR = 4096 +const STA_DEL = 32 +const STA_FLL = 8 +const STA_FREQHOLD = 128 +const STA_INS = 16 +const STA_MODE = 16384 +const STA_NANO = 8192 +const STA_PLL = 1 +const STA_PPSERROR = 2048 +const STA_PPSFREQ = 2 +const STA_PPSJITTER = 512 +const STA_PPSSIGNAL = 256 +const STA_PPSTIME = 4 +const STA_PPSWANDER = 1024 +const STA_RONLY = 65280 +const STA_UNSYNC = 64 +const TIME_BAD = 5 +const TIME_DEL = 2 +const TIME_ERROR = 5 +const TIME_INS = 1 +const TIME_OK = 0 +const TIME_OOP = 3 +const TIME_WAIT = 4 + +type Tntptimeval = struct { + Ftime Ttimeval + Fmaxerror int64 + Festerror int64 +} + +type Ttimex = struct { + Fmodes uint32 + Foffset int64 + Ffreq int64 + Fmaxerror int64 + Festerror int64 + Fstatus int32 + Fconstant int64 + Fprecision int64 + Ftolerance int64 + Ftime Ttimeval + Ftick int64 + Fppsfreq int64 + Fjitter int64 + Fshift int32 + Fstabil int64 + Fjitcnt int64 + Fcalcnt int64 + Ferrcnt int64 + Fstbcnt int64 + Ftai int32 + F__padding [11]int32 +} + +func Xadjtime(tls *TLS, in uintptr, out uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v in=%v out=%v, (%v:)", tls, in, out, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(208) + defer tls.Free(208) + var v1 Tsuseconds_t + var _ /* tx at bp+0 */ Ttimex + _ = v1 + **(**Ttimex)(__ccgo_up(bp)) = Ttimex{} + if in != 0 { + if (*Ttimeval)(unsafe.Pointer(in)).Ftv_sec > int64(1000) || (*Ttimeval)(unsafe.Pointer(in)).Ftv_usec > int64(1000000000) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + (**(**Ttimex)(__ccgo_up(bp))).Foffset = (*Ttimeval)(unsafe.Pointer(in)).Ftv_sec*int64(1000000) + (*Ttimeval)(unsafe.Pointer(in)).Ftv_usec + (**(**Ttimex)(__ccgo_up(bp))).Fmodes = uint32(ADJ_OFFSET_SINGLESHOT) + } + if Xadjtimex(tls, bp) < 0 { + return -int32(1) + } + if out != 0 { + (*Ttimeval)(unsafe.Pointer(out)).Ftv_sec = (**(**Ttimex)(__ccgo_up(bp))).Foffset / int64(1000000) + v1 = (**(**Ttimex)(__ccgo_up(bp))).Foffset % Int64FromInt32(1000000) + (*Ttimeval)(unsafe.Pointer(out)).Ftv_usec = v1 + if v1 < 0 { + (*Ttimeval)(unsafe.Pointer(out)).Ftv_sec = (*Ttimeval)(unsafe.Pointer(out)).Ftv_sec - 1 + **(**Tsuseconds_t)(__ccgo_up(out + 8)) += int64(1000000) + } + } + return 0 +} + +func Xadjtimex(tls *TLS, tx uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v tx=%v, (%v:)", tls, tx, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xclock_adjtime(tls, CLOCK_REALTIME, tx) +} + +func Xbrk(tls *TLS, end uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v end=%v, (%v:)", tls, end, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(ENOMEM)))) +} + +func Xcapset(tls *TLS, a uintptr, b uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_capset), int64(a), int64(b))))) +} + +func Xcapget(tls *TLS, a uintptr, b uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_capget), int64(a), int64(b))))) +} + +func Xchroot(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_chroot), int64(path))))) +} + +type Tktimex64 = struct { + Fmodes uint32 + F__ccgo4 uint32 + Foffset int64 + Ffreq int64 + Fmaxerror int64 + Festerror int64 + Fstatus int32 + F__ccgo44 uint32 + Fconstant int64 + Fprecision int64 + Ftolerance int64 + Ftime_sec int64 + Ftime_usec int64 + Ftick int64 + Fppsfreq int64 + Fjitter int64 + Fshift int32 + F__ccgo116 uint32 + Fstabil int64 + Fjitcnt int64 + Fcalcnt int64 + Ferrcnt int64 + Fstbcnt int64 + Ftai int32 + F__padding [11]int32 +} + +type Tktimex = struct { + Fmodes uint32 + Foffset int64 + Ffreq int64 + Fmaxerror int64 + Festerror int64 + Fstatus int32 + Fconstant int64 + Fprecision int64 + Ftolerance int64 + Ftime_sec int64 + Ftime_usec int64 + Ftick int64 + Fppsfreq int64 + Fjitter int64 + Fshift int32 + Fstabil int64 + Fjitcnt int64 + Fcalcnt int64 + Ferrcnt int64 + Fstbcnt int64 + Ftai int32 + F__padding [11]int32 +} + +func Xclock_adjtime(tls *TLS, clock_id Tclockid_t, utx uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v clock_id=%v utx=%v, (%v:)", tls, clock_id, utx, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(208) + defer tls.Free(208) + var r int32 + var _ /* ktx at bp+0 */ Tktimex + _ = r + r = -int32(ENOSYS) + if uint64(8) > uint64(8) { + **(**Tktimex)(__ccgo_up(bp)) = Tktimex{ + Fmodes: (*Ttimex)(unsafe.Pointer(utx)).Fmodes, + Foffset: (*Ttimex)(unsafe.Pointer(utx)).Foffset, + Ffreq: (*Ttimex)(unsafe.Pointer(utx)).Ffreq, + Fmaxerror: (*Ttimex)(unsafe.Pointer(utx)).Fmaxerror, + Festerror: (*Ttimex)(unsafe.Pointer(utx)).Festerror, + Fstatus: (*Ttimex)(unsafe.Pointer(utx)).Fstatus, + Fconstant: (*Ttimex)(unsafe.Pointer(utx)).Fconstant, + Fprecision: (*Ttimex)(unsafe.Pointer(utx)).Fprecision, + Ftolerance: (*Ttimex)(unsafe.Pointer(utx)).Ftolerance, + Ftime_sec: (*Ttimex)(unsafe.Pointer(utx)).Ftime.Ftv_sec, + Ftime_usec: (*Ttimex)(unsafe.Pointer(utx)).Ftime.Ftv_usec, + Ftick: (*Ttimex)(unsafe.Pointer(utx)).Ftick, + Fppsfreq: (*Ttimex)(unsafe.Pointer(utx)).Fppsfreq, + Fjitter: (*Ttimex)(unsafe.Pointer(utx)).Fjitter, + Fshift: (*Ttimex)(unsafe.Pointer(utx)).Fshift, + Fstabil: (*Ttimex)(unsafe.Pointer(utx)).Fstabil, + Fjitcnt: (*Ttimex)(unsafe.Pointer(utx)).Fjitcnt, + Fcalcnt: (*Ttimex)(unsafe.Pointer(utx)).Fcalcnt, + Ferrcnt: (*Ttimex)(unsafe.Pointer(utx)).Ferrcnt, + Fstbcnt: (*Ttimex)(unsafe.Pointer(utx)).Fstbcnt, + Ftai: (*Ttimex)(unsafe.Pointer(utx)).Ftai, + } + if clock_id == CLOCK_REALTIME { + r = int32(X__syscall1(tls, int64(SYS_adjtimex), int64(bp))) + } else { + r = int32(X__syscall2(tls, int64(SYS_clock_adjtime), int64(clock_id), int64(bp))) + } + if r >= 0 { + (*Ttimex)(unsafe.Pointer(utx)).Fmodes = (**(**Tktimex)(__ccgo_up(bp))).Fmodes + (*Ttimex)(unsafe.Pointer(utx)).Foffset = (**(**Tktimex)(__ccgo_up(bp))).Foffset + (*Ttimex)(unsafe.Pointer(utx)).Ffreq = (**(**Tktimex)(__ccgo_up(bp))).Ffreq + (*Ttimex)(unsafe.Pointer(utx)).Fmaxerror = (**(**Tktimex)(__ccgo_up(bp))).Fmaxerror + (*Ttimex)(unsafe.Pointer(utx)).Festerror = (**(**Tktimex)(__ccgo_up(bp))).Festerror + (*Ttimex)(unsafe.Pointer(utx)).Fstatus = (**(**Tktimex)(__ccgo_up(bp))).Fstatus + (*Ttimex)(unsafe.Pointer(utx)).Fconstant = (**(**Tktimex)(__ccgo_up(bp))).Fconstant + (*Ttimex)(unsafe.Pointer(utx)).Fprecision = (**(**Tktimex)(__ccgo_up(bp))).Fprecision + (*Ttimex)(unsafe.Pointer(utx)).Ftolerance = (**(**Tktimex)(__ccgo_up(bp))).Ftolerance + (*Ttimex)(unsafe.Pointer(utx)).Ftime.Ftv_sec = (**(**Tktimex)(__ccgo_up(bp))).Ftime_sec + (*Ttimex)(unsafe.Pointer(utx)).Ftime.Ftv_usec = (**(**Tktimex)(__ccgo_up(bp))).Ftime_usec + (*Ttimex)(unsafe.Pointer(utx)).Ftick = (**(**Tktimex)(__ccgo_up(bp))).Ftick + (*Ttimex)(unsafe.Pointer(utx)).Fppsfreq = (**(**Tktimex)(__ccgo_up(bp))).Fppsfreq + (*Ttimex)(unsafe.Pointer(utx)).Fjitter = (**(**Tktimex)(__ccgo_up(bp))).Fjitter + (*Ttimex)(unsafe.Pointer(utx)).Fshift = (**(**Tktimex)(__ccgo_up(bp))).Fshift + (*Ttimex)(unsafe.Pointer(utx)).Fstabil = (**(**Tktimex)(__ccgo_up(bp))).Fstabil + (*Ttimex)(unsafe.Pointer(utx)).Fjitcnt = (**(**Tktimex)(__ccgo_up(bp))).Fjitcnt + (*Ttimex)(unsafe.Pointer(utx)).Fcalcnt = (**(**Tktimex)(__ccgo_up(bp))).Fcalcnt + (*Ttimex)(unsafe.Pointer(utx)).Ferrcnt = (**(**Tktimex)(__ccgo_up(bp))).Ferrcnt + (*Ttimex)(unsafe.Pointer(utx)).Fstbcnt = (**(**Tktimex)(__ccgo_up(bp))).Fstbcnt + (*Ttimex)(unsafe.Pointer(utx)).Ftai = (**(**Tktimex)(__ccgo_up(bp))).Ftai + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + if clock_id == CLOCK_REALTIME { + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_adjtimex), int64(utx))))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_clock_adjtime), int64(clock_id), int64(utx))))) +} + +func Xcopy_file_range(tls *TLS, fd_in int32, off_in uintptr, fd_out int32, off_out uintptr, len1 Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd_in=%v off_in=%v fd_out=%v off_out=%v len1=%v flags=%v, (%v:)", tls, fd_in, off_in, fd_out, off_out, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, int64(SYS_copy_file_range), int64(fd_in), int64(off_in), int64(fd_out), int64(off_out), Int64FromUint64(len1), Int64FromUint32(flags)))) +} + +const EPOLLERR = 8 +const EPOLLET = 2147483648 +const EPOLLEXCLUSIVE = 268435456 +const EPOLLHUP = 16 +const EPOLLIN = 1 +const EPOLLMSG = 1024 +const EPOLLNVAL = 32 +const EPOLLONESHOT = 1073741824 +const EPOLLOUT = 4 +const EPOLLPRI = 2 +const EPOLLRDBAND = 128 +const EPOLLRDHUP = 8192 +const EPOLLRDNORM = 64 +const EPOLLWAKEUP = 536870912 +const EPOLLWRBAND = 512 +const EPOLLWRNORM = 256 +const EPOLL_CLOEXEC = 524288 +const EPOLL_CTL_ADD = 1 +const EPOLL_CTL_DEL = 2 +const EPOLL_CTL_MOD = 3 +const EPOLL_NONBLOCK = 2048 + +type Tfsblkcnt_t = uint64 + +type Tfsfilcnt_t = uint64 + +type _EPOLL_EVENTS = int32 + +const ___EPOLL_DUMMY = 0 + +type Tepoll_data_t = struct { + Ffd [0]int32 + Fu32 [0]Tuint32_t + Fu64 [0]Tuint64_t + Fptr uintptr +} + +type Tepoll_data = Tepoll_data_t + +type Tepoll_event = struct { + Fevents Tuint32_t + Fdata Tepoll_data_t +} + +func Xepoll_create(tls *TLS, size int32) (r int32) { + if __ccgo_strace { + trc("tls=%v size=%v, (%v:)", tls, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + if size <= 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + return Xepoll_create1(tls, 0) +} + +func Xepoll_create1(tls *TLS, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall1(tls, int64(SYS_epoll_create1), int64(flags))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xepoll_ctl(tls *TLS, fd int32, op int32, fd2 int32, ev uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v op=%v fd2=%v ev=%v, (%v:)", tls, fd, op, fd2, ev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_epoll_ctl), int64(fd), int64(op), int64(fd2), int64(ev))))) +} + +func Xepoll_pwait(tls *TLS, fd int32, ev uintptr, cnt int32, to int32, sigs uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v ev=%v cnt=%v to=%v sigs=%v, (%v:)", tls, fd, ev, cnt, to, sigs, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(___syscall_cp(tls, int64(SYS_epoll_pwait), int64(fd), int64(ev), int64(cnt), int64(to), int64(sigs), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xepoll_wait(tls *TLS, fd int32, ev uintptr, cnt int32, to int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v ev=%v cnt=%v to=%v, (%v:)", tls, fd, ev, cnt, to, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xepoll_pwait(tls, fd, ev, cnt, to, uintptr(0)) +} + +const EFD_CLOEXEC = 524288 +const EFD_NONBLOCK = 2048 +const EFD_SEMAPHORE = 1 + +type Teventfd_t = uint64 + +func Xeventfd(tls *TLS, count uint32, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v count=%v flags=%v, (%v:)", tls, count, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall2(tls, int64(SYS_eventfd2), Int64FromUint32(count), int64(flags))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xeventfd_read(tls *TLS, fd int32, value uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v value=%v, (%v:)", tls, fd, value, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if uint64(8) == Uint64FromInt64(Xread(tls, fd, value, uint64(8))) { + v1 = 0 + } else { + v1 = -int32(1) + } + return v1 +} + +func Xeventfd_write(tls *TLS, fd int32, _value Teventfd_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v _value=%v, (%v:)", tls, fd, _value, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*Teventfd_t)(unsafe.Pointer(bp)) = _value + var v1 int32 + _ = v1 + if uint64(8) == Uint64FromInt64(Xwrite(tls, fd, bp, uint64(8))) { + v1 = 0 + } else { + v1 = -int32(1) + } + return v1 +} + +func Xfallocate(tls *TLS, fd int32, mode int32, base Toff_t, len1 Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v mode=%v base=%v len1=%v, (%v:)", tls, fd, mode, base, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_fallocate), int64(fd), int64(mode), base, len1)))) +} + +const FANOTIFY_METADATA_VERSION = 3 +const FAN_ACCESS = 1 +const FAN_ACCESS_PERM = 131072 +const FAN_ALLOW = 1 +const FAN_ALL_CLASS_BITS = 12 +const FAN_ALL_EVENTS = 59 +const FAN_ALL_INIT_FLAGS = 63 +const FAN_ALL_MARK_FLAGS = 255 +const FAN_ALL_OUTGOING_EVENTS = 213051 +const FAN_ALL_PERM_EVENTS = 196608 +const FAN_ATTRIB = 4 +const FAN_AUDIT = 16 +const FAN_CLASS_CONTENT = 4 +const FAN_CLASS_NOTIF = 0 +const FAN_CLASS_PRE_CONTENT = 8 +const FAN_CLOEXEC = 1 +const FAN_CLOSE = 24 +const FAN_CLOSE_NOWRITE = 16 +const FAN_CLOSE_WRITE = 8 +const FAN_CREATE = 256 +const FAN_DELETE = 512 +const FAN_DELETE_SELF = 1024 +const FAN_DENY = 2 +const FAN_DIR_MODIFY = 524288 +const FAN_ENABLE_AUDIT = 64 +const FAN_EVENT_INFO_TYPE_DFID = 3 +const FAN_EVENT_INFO_TYPE_DFID_NAME = 2 +const FAN_EVENT_INFO_TYPE_FID = 1 +const FAN_EVENT_METADATA_LEN = 0 +const FAN_EVENT_ON_CHILD = 134217728 +const FAN_MARK_ADD = 1 +const FAN_MARK_DONT_FOLLOW = 4 +const FAN_MARK_FILESYSTEM = 256 +const FAN_MARK_FLUSH = 128 +const FAN_MARK_IGNORED_MASK = 32 +const FAN_MARK_IGNORED_SURV_MODIFY = 64 +const FAN_MARK_INODE = 0 +const FAN_MARK_MOUNT = 16 +const FAN_MARK_ONLYDIR = 8 +const FAN_MARK_REMOVE = 2 +const FAN_MARK_TYPE_MASK = 272 +const FAN_MODIFY = 2 +const FAN_MOVE = 192 +const FAN_MOVED_FROM = 64 +const FAN_MOVED_TO = 128 +const FAN_MOVE_SELF = 2048 +const FAN_NOFD = -1 +const FAN_NONBLOCK = 2 +const FAN_ONDIR = 1073741824 +const FAN_OPEN = 32 +const FAN_OPEN_EXEC = 4096 +const FAN_OPEN_EXEC_PERM = 262144 +const FAN_OPEN_PERM = 65536 +const FAN_Q_OVERFLOW = 16384 +const FAN_REPORT_DFID_NAME = 3072 +const FAN_REPORT_DIR_FID = 1024 +const FAN_REPORT_FID = 512 +const FAN_REPORT_NAME = 2048 +const FAN_REPORT_TID = 256 +const FAN_UNLIMITED_MARKS = 32 +const FAN_UNLIMITED_QUEUE = 16 +const ST_APPEND = 256 +const ST_IMMUTABLE = 512 +const ST_MANDLOCK = 64 +const ST_NOATIME = 1024 +const ST_NODEV = 4 +const ST_NODIRATIME = 2048 +const ST_NOEXEC = 8 +const ST_NOSUID = 2 +const ST_RDONLY = 1 +const ST_RELATIME = 4096 +const ST_SYNCHRONOUS = 16 +const ST_WRITE = 128 + +type Tstatvfs = struct { + Ff_bsize uint64 + Ff_frsize uint64 + Ff_blocks Tfsblkcnt_t + Ff_bfree Tfsblkcnt_t + Ff_bavail Tfsblkcnt_t + Ff_files Tfsfilcnt_t + Ff_ffree Tfsfilcnt_t + Ff_favail Tfsfilcnt_t + Ff_fsid uint64 + Ff_flag uint64 + Ff_namemax uint64 + Ff_type uint32 + F__reserved [5]int32 +} + +type Tfsid_t = struct { + F__val [2]int32 +} + +type t__fsid_t = Tfsid_t + +type Tstatfs = struct { + Ff_type uint64 + Ff_bsize uint64 + Ff_blocks Tfsblkcnt_t + Ff_bfree Tfsblkcnt_t + Ff_bavail Tfsblkcnt_t + Ff_files Tfsfilcnt_t + Ff_ffree Tfsfilcnt_t + Ff_fsid Tfsid_t + Ff_namelen uint64 + Ff_frsize uint64 + Ff_flags uint64 + Ff_spare [4]uint64 +} + +type Tfanotify_event_metadata = struct { + Fevent_len uint32 + Fvers uint8 + Freserved uint8 + Fmetadata_len uint16 + Fmask uint64 + Ffd int32 + Fpid int32 +} + +type Tfanotify_event_info_header = struct { + Finfo_type uint8 + Fpad uint8 + Flen1 uint16 +} + +type Tfanotify_event_info_fid = struct { + Fhdr Tfanotify_event_info_header + Ffsid Tfsid_t +} + +type Tfanotify_response = struct { + Ffd int32 + Fresponse uint32 +} + +func Xfanotify_init(tls *TLS, flags uint32, event_f_flags uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v flags=%v event_f_flags=%v, (%v:)", tls, flags, event_f_flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_fanotify_init), Int64FromUint32(flags), Int64FromUint32(event_f_flags))))) +} + +func Xfanotify_mark(tls *TLS, fanotify_fd int32, flags uint32, mask uint64, dfd int32, pathname uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fanotify_fd=%v flags=%v mask=%v dfd=%v pathname=%v, (%v:)", tls, fanotify_fd, flags, mask, dfd, pathname, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fanotify_mark), int64(fanotify_fd), Int64FromUint32(flags), Int64FromUint64(mask), int64(dfd), int64(pathname))))) +} + +const LOCK_EX = 2 +const LOCK_NB = 4 +const LOCK_SH = 1 +const LOCK_UN = 8 + +func Xflock(tls *TLS, fd int32, op int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v op=%v, (%v:)", tls, fd, op, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_flock), int64(fd), int64(op))))) +} + +func Xgetdents(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v, (%v:)", tls, fd, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + if len1 > uint64(INT_MAX) { + len1 = uint64(INT_MAX) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_getdents64), int64(fd), int64(buf), Int64FromUint64(len1))))) +} + +const GRND_INSECURE = 4 +const GRND_NONBLOCK = 1 +const GRND_RANDOM = 2 + +func Xgetrandom(tls *TLS, buf uintptr, buflen Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v buf=%v buflen=%v flags=%v, (%v:)", tls, buf, buflen, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_getrandom), int64(buf), Int64FromUint64(buflen), Int64FromUint32(flags), 0, 0, 0))) +} + +const IN_ACCESS = 1 +const IN_ALL_EVENTS = 4095 +const IN_ATTRIB = 4 +const IN_CLOEXEC = 524288 +const IN_CLOSE = 24 +const IN_CLOSE_NOWRITE = 16 +const IN_CLOSE_WRITE = 8 +const IN_CREATE = 256 +const IN_DELETE = 512 +const IN_DELETE_SELF = 1024 +const IN_DONT_FOLLOW = 33554432 +const IN_EXCL_UNLINK = 67108864 +const IN_IGNORED = 32768 +const IN_ISDIR = 1073741824 +const IN_MASK_ADD = 536870912 +const IN_MASK_CREATE = 268435456 +const IN_MODIFY = 2 +const IN_MOVE = 192 +const IN_MOVED_FROM = 64 +const IN_MOVED_TO = 128 +const IN_MOVE_SELF = 2048 +const IN_NONBLOCK = 2048 +const IN_ONESHOT = 2147483648 +const IN_ONLYDIR = 16777216 +const IN_OPEN = 32 +const IN_Q_OVERFLOW = 16384 +const IN_UNMOUNT = 8192 + +type Tinotify_event = struct { + Fwd int32 + Fmask Tuint32_t + Fcookie Tuint32_t + Flen1 Tuint32_t +} + +func Xinotify_init(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xinotify_init1(tls, 0) +} + +func Xinotify_init1(tls *TLS, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall1(tls, int64(SYS_inotify_init1), int64(flags))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xinotify_add_watch(tls *TLS, fd int32, pathname uintptr, mask Tuint32_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v pathname=%v mask=%v, (%v:)", tls, fd, pathname, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_inotify_add_watch), int64(fd), int64(pathname), Int64FromUint32(mask))))) +} + +func Xinotify_rm_watch(tls *TLS, fd int32, wd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v wd=%v, (%v:)", tls, fd, wd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_inotify_rm_watch), int64(fd), int64(wd))))) +} + +func Xklogctl(tls *TLS, type1 int32, buf uintptr, len1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v type1=%v buf=%v len1=%v, (%v:)", tls, type1, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_syslog), int64(type1), int64(buf), int64(len1))))) +} + +const MADV_COLD = 20 +const MADV_DODUMP = 17 +const MADV_DOFORK = 11 +const MADV_DONTDUMP = 16 +const MADV_DONTFORK = 10 +const MADV_DONTNEED = 4 +const MADV_FREE = 8 +const MADV_HUGEPAGE = 14 +const MADV_HWPOISON = 100 +const MADV_KEEPONFORK = 19 +const MADV_MERGEABLE = 12 +const MADV_NOHUGEPAGE = 15 +const MADV_NORMAL = 0 +const MADV_PAGEOUT = 21 +const MADV_RANDOM = 1 +const MADV_REMOVE = 9 +const MADV_SEQUENTIAL = 2 +const MADV_SOFT_OFFLINE = 101 +const MADV_UNMERGEABLE = 13 +const MADV_WILLNEED = 3 +const MADV_WIPEONFORK = 18 +const MFD_ALLOW_SEALING = 2 +const MFD_CLOEXEC = 1 +const MFD_HUGETLB = 4 +const MLOCK_ONFAULT = 1 +const MREMAP_DONTUNMAP = 4 +const MREMAP_FIXED = 2 +const MREMAP_MAYMOVE = 1 +const _GNU_SOURCE = 1 + +func Xmemfd_create(tls *TLS, name uintptr, flags uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v flags=%v, (%v:)", tls, name, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_memfd_create), int64(name), Int64FromUint32(flags))))) +} + +func Xmlock2(tls *TLS, addr uintptr, len1 Tsize_t, flags uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v flags=%v, (%v:)", tls, addr, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + if flags == uint32(0) { + return Xmlock(tls, addr, len1) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mlock2), int64(addr), Int64FromUint64(len1), Int64FromUint32(flags))))) +} + +func Xinit_module(tls *TLS, a uintptr, b uint64, c uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v c=%v, (%v:)", tls, a, b, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_init_module), int64(a), Int64FromUint64(b), int64(c))))) +} + +func Xdelete_module(tls *TLS, a uintptr, b uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v, (%v:)", tls, a, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_delete_module), int64(a), Int64FromUint32(b))))) +} + +const BLKBSZGET = 2147488368 +const BLKBSZSET = 1073746545 +const BLKFLSBUF = 4705 +const BLKFRAGET = 4709 +const BLKFRASET = 4708 +const BLKGETSIZE = 4704 +const BLKGETSIZE64 = 2147488370 +const BLKRAGET = 4707 +const BLKRASET = 4706 +const BLKROGET = 4702 +const BLKROSET = 4701 +const BLKRRPART = 4703 +const BLKSECTGET = 4711 +const BLKSECTSET = 4710 +const BLKSSZGET = 4712 +const FIOASYNC = 21586 +const FIOCLEX = 21585 +const FIOGETOWN = 35075 +const FIONBIO = 21537 +const FIONCLEX = 21584 +const FIONREAD = 21531 +const FIOQSIZE = 21600 +const FIOSETOWN = 35073 +const MNT_DETACH = 2 +const MNT_EXPIRE = 4 +const MNT_FORCE = 1 +const MS_ACTIVE = 1073741824 +const MS_BIND = 4096 +const MS_BORN = 536870912 +const MS_DIRSYNC = 128 +const MS_I_VERSION = 8388608 +const MS_KERNMOUNT = 4194304 +const MS_LAZYTIME = 33554432 +const MS_MANDLOCK = 64 +const MS_MGC_MSK = 4294901760 +const MS_MGC_VAL = 3236757504 +const MS_MOVE = 8192 +const MS_NOATIME = 1024 +const MS_NODEV = 4 +const MS_NODIRATIME = 2048 +const MS_NOEXEC = 8 +const MS_NOREMOTELOCK = 134217728 +const MS_NOSEC = 268435456 +const MS_NOSUID = 2 +const MS_NOSYMFOLLOW = 256 +const MS_NOUSER = 2147483648 +const MS_POSIXACL = 65536 +const MS_PRIVATE = 262144 +const MS_RDONLY = 1 +const MS_REC = 16384 +const MS_RELATIME = 2097152 +const MS_REMOUNT = 32 +const MS_RMT_MASK = 41943121 +const MS_SHARED = 1048576 +const MS_SILENT = 32768 +const MS_SLAVE = 524288 +const MS_STRICTATIME = 16777216 +const MS_SYNCHRONOUS = 16 +const MS_UNBINDABLE = 131072 +const N_6PACK = 7 +const N_AX25 = 5 +const N_CAIF = 20 +const N_GIGASET_M101 = 16 +const N_GSM0710 = 21 +const N_HCI = 15 +const N_HDLC = 13 +const N_IRDA = 11 +const N_MASC = 8 +const N_MOUSE = 2 +const N_NCI = 25 +const N_NULL = 27 +const N_PPP = 3 +const N_PPS = 18 +const N_PROFIBUS_FDL = 10 +const N_R3964 = 9 +const N_SLCAN = 17 +const N_SLIP = 1 +const N_SMSBLOCK = 12 +const N_SPEAKUP = 26 +const N_STRIP = 4 +const N_SYNC_PPP = 14 +const N_TI_WL = 22 +const N_TRACEROUTER = 24 +const N_TRACESINK = 23 +const N_TTY = 0 +const N_V253 = 19 +const N_X25 = 6 +const SIOCADDDLCI = 35200 +const SIOCADDMULTI = 35121 +const SIOCADDRT = 35083 +const SIOCATMARK = 35077 +const SIOCDARP = 35155 +const SIOCDELDLCI = 35201 +const SIOCDELMULTI = 35122 +const SIOCDELRT = 35084 +const SIOCDEVPRIVATE = 35312 +const SIOCDIFADDR = 35126 +const SIOCDRARP = 35168 +const SIOCGARP = 35156 +const SIOCGIFADDR = 35093 +const SIOCGIFBR = 35136 +const SIOCGIFBRDADDR = 35097 +const SIOCGIFCONF = 35090 +const SIOCGIFCOUNT = 35128 +const SIOCGIFDSTADDR = 35095 +const SIOCGIFENCAP = 35109 +const SIOCGIFFLAGS = 35091 +const SIOCGIFHWADDR = 35111 +const SIOCGIFINDEX = 35123 +const SIOCGIFMAP = 35184 +const SIOCGIFMEM = 35103 +const SIOCGIFMETRIC = 35101 +const SIOCGIFMTU = 35105 +const SIOCGIFNAME = 35088 +const SIOCGIFNETMASK = 35099 +const SIOCGIFPFLAGS = 35125 +const SIOCGIFSLAVE = 35113 +const SIOCGIFTXQLEN = 35138 +const SIOCGPGRP = 35076 +const SIOCGRARP = 35169 +const SIOCGSTAMP = 35078 +const SIOCGSTAMPNS = 35079 +const SIOCPROTOPRIVATE = 35296 +const SIOCRTMSG = 35085 +const SIOCSARP = 35157 +const SIOCSIFADDR = 35094 +const SIOCSIFBR = 35137 +const SIOCSIFBRDADDR = 35098 +const SIOCSIFDSTADDR = 35096 +const SIOCSIFENCAP = 35110 +const SIOCSIFFLAGS = 35092 +const SIOCSIFHWADDR = 35108 +const SIOCSIFHWBROADCAST = 35127 +const SIOCSIFLINK = 35089 +const SIOCSIFMAP = 35185 +const SIOCSIFMEM = 35104 +const SIOCSIFMETRIC = 35102 +const SIOCSIFMTU = 35106 +const SIOCSIFNAME = 35107 +const SIOCSIFNETMASK = 35100 +const SIOCSIFPFLAGS = 35124 +const SIOCSIFSLAVE = 35120 +const SIOCSIFTXQLEN = 35139 +const SIOCSPGRP = 35074 +const SIOCSRARP = 35170 +const SIOGIFINDEX = 35123 +const TCFLSH = 21515 +const TCGETA = 21509 +const TCGETS = 21505 +const TCGETX = 21554 +const TCSBRK = 21513 +const TCSBRKP = 21541 +const TCSETA = 21510 +const TCSETAF = 21512 +const TCSETAW = 21511 +const TCSETS = 21506 +const TCSETSF = 21508 +const TCSETSW = 21507 +const TCSETX = 21555 +const TCSETXF = 21556 +const TCSETXW = 21557 +const TCXONC = 21514 +const TIOCCBRK = 21544 +const TIOCCONS = 21533 +const TIOCEXCL = 21516 +const TIOCGDEV = 2147767346 +const TIOCGETD = 21540 +const TIOCGEXCL = 2147767360 +const TIOCGICOUNT = 21597 +const TIOCGISO7816 = 2150126658 +const TIOCGLCKTRMIOS = 21590 +const TIOCGPGRP = 21519 +const TIOCGPKT = 2147767352 +const TIOCGPTLCK = 2147767353 +const TIOCGPTN = 2147767344 +const TIOCGPTPEER = 21569 +const TIOCGRS485 = 21550 +const TIOCGSERIAL = 21534 +const TIOCGSID = 21545 +const TIOCGSOFTCAR = 21529 +const TIOCGWINSZ = 21523 +const TIOCINQ = 21531 +const TIOCLINUX = 21532 +const TIOCMBIC = 21527 +const TIOCMBIS = 21526 +const TIOCMGET = 21525 +const TIOCMIWAIT = 21596 +const TIOCMSET = 21528 +const TIOCM_CAR = 64 +const TIOCM_CD = 64 +const TIOCM_CTS = 32 +const TIOCM_DSR = 256 +const TIOCM_DTR = 2 +const TIOCM_LE = 1 +const TIOCM_LOOP = 32768 +const TIOCM_OUT1 = 8192 +const TIOCM_OUT2 = 16384 +const TIOCM_RI = 128 +const TIOCM_RNG = 128 +const TIOCM_RTS = 4 +const TIOCM_SR = 16 +const TIOCM_ST = 8 +const TIOCNOTTY = 21538 +const TIOCNXCL = 21517 +const TIOCOUTQ = 21521 +const TIOCPKT = 21536 +const TIOCPKT_DATA = 0 +const TIOCPKT_DOSTOP = 32 +const TIOCPKT_FLUSHREAD = 1 +const TIOCPKT_FLUSHWRITE = 2 +const TIOCPKT_IOCTL = 64 +const TIOCPKT_NOSTOP = 16 +const TIOCPKT_START = 8 +const TIOCPKT_STOP = 4 +const TIOCSBRK = 21543 +const TIOCSCTTY = 21518 +const TIOCSERCONFIG = 21587 +const TIOCSERGETLSR = 21593 +const TIOCSERGETMULTI = 21594 +const TIOCSERGSTRUCT = 21592 +const TIOCSERGWILD = 21588 +const TIOCSERSETMULTI = 21595 +const TIOCSERSWILD = 21589 +const TIOCSER_TEMT = 1 +const TIOCSETD = 21539 +const TIOCSIG = 1074025526 +const TIOCSISO7816 = 3223868483 +const TIOCSLCKTRMIOS = 21591 +const TIOCSPGRP = 21520 +const TIOCSPTLCK = 1074025521 +const TIOCSRS485 = 21551 +const TIOCSSERIAL = 21535 +const TIOCSSOFTCAR = 21530 +const TIOCSTI = 21522 +const TIOCSWINSZ = 21524 +const TIOCVHANGUP = 21559 +const UMOUNT_NOFOLLOW = 8 +const _IOC_NONE = 0 +const _IOC_READ = 2 +const _IOC_WRITE = 1 + +func Xmount(tls *TLS, special uintptr, dir uintptr, fstype uintptr, flags uint64, data uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v special=%v dir=%v fstype=%v flags=%v data=%v, (%v:)", tls, special, dir, fstype, flags, data, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_mount), int64(special), int64(dir), int64(fstype), Int64FromUint64(flags), int64(data))))) +} + +func Xumount(tls *TLS, special uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v special=%v, (%v:)", tls, special, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_umount2), int64(special), int64(Int32FromInt32(0)))))) +} + +func Xumount2(tls *TLS, special uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v special=%v flags=%v, (%v:)", tls, special, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_umount2), int64(special), int64(flags))))) +} + +func Xname_to_handle_at(tls *TLS, dirfd int32, pathname uintptr, handle uintptr, mount_id uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v dirfd=%v pathname=%v handle=%v mount_id=%v flags=%v, (%v:)", tls, dirfd, pathname, handle, mount_id, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_name_to_handle_at), int64(dirfd), int64(pathname), int64(handle), int64(mount_id), int64(flags))))) +} + +func Xopen_by_handle_at(tls *TLS, mount_fd int32, handle uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v mount_fd=%v handle=%v flags=%v, (%v:)", tls, mount_fd, handle, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_open_by_handle_at), int64(mount_fd), int64(handle), int64(flags))))) +} + +const ADDR_COMPAT_LAYOUT = 2097152 +const ADDR_LIMIT_32BIT = 8388608 +const ADDR_LIMIT_3GB = 134217728 +const ADDR_NO_RANDOMIZE = 262144 +const FDPIC_FUNCPTRS = 524288 +const MMAP_PAGE_ZERO = 1048576 +const PER_BSD = 6 +const PER_HPUX = 16 +const PER_IRIX32 = 67108873 +const PER_IRIX64 = 67108875 +const PER_IRIXN32 = 67108874 +const PER_ISCR4 = 67108869 +const PER_LINUX = 0 +const PER_LINUX32 = 8 +const PER_LINUX32_3GB = 134217736 +const PER_LINUX_32BIT = 8388608 +const PER_LINUX_FDPIC = 524288 +const PER_MASK = 255 +const PER_OSF4 = 15 +const PER_OSR5 = 100663299 +const PER_RISCOS = 12 +const PER_SCOSVR3 = 117440515 +const PER_SOLARIS = 67108877 +const PER_SUNOS = 67108870 +const PER_SVR3 = 83886082 +const PER_SVR4 = 68157441 +const PER_UW7 = 68157454 +const PER_WYSEV386 = 83886084 +const PER_XENIX = 83886087 +const READ_IMPLIES_EXEC = 4194304 +const SHORT_INODE = 16777216 +const STICKY_TIMEOUTS = 67108864 +const UNAME26 = 131072 +const WHOLE_SECONDS = 33554432 + +func Xpersonality(tls *TLS, persona uint64) (r int32) { + if __ccgo_strace { + trc("tls=%v persona=%v, (%v:)", tls, persona, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_personality), Int64FromUint64(persona))))) +} + +func Xpivot_root(tls *TLS, new1 uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v new1=%v old=%v, (%v:)", tls, new1, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_pivot_root), int64(new1), int64(old))))) +} + +const PR_CAPBSET_DROP = 24 +const PR_CAPBSET_READ = 23 +const PR_CAP_AMBIENT = 47 +const PR_CAP_AMBIENT_CLEAR_ALL = 4 +const PR_CAP_AMBIENT_IS_SET = 1 +const PR_CAP_AMBIENT_LOWER = 3 +const PR_CAP_AMBIENT_RAISE = 2 +const PR_ENDIAN_BIG = 0 +const PR_ENDIAN_LITTLE = 1 +const PR_ENDIAN_PPC_LITTLE = 2 +const PR_FPEMU_NOPRINT = 1 +const PR_FPEMU_SIGFPE = 2 +const PR_FP_EXC_ASYNC = 2 +const PR_FP_EXC_DISABLED = 0 +const PR_FP_EXC_DIV = 65536 +const PR_FP_EXC_INV = 1048576 +const PR_FP_EXC_NONRECOV = 1 +const PR_FP_EXC_OVF = 131072 +const PR_FP_EXC_PRECISE = 3 +const PR_FP_EXC_RES = 524288 +const PR_FP_EXC_SW_ENABLE = 128 +const PR_FP_EXC_UND = 262144 +const PR_FP_MODE_FR = 1 +const PR_FP_MODE_FRE = 2 +const PR_GET_CHILD_SUBREAPER = 37 +const PR_GET_DUMPABLE = 3 +const PR_GET_ENDIAN = 19 +const PR_GET_FPEMU = 9 +const PR_GET_FPEXC = 11 +const PR_GET_FP_MODE = 46 +const PR_GET_IO_FLUSHER = 58 +const PR_GET_KEEPCAPS = 7 +const PR_GET_NAME = 16 +const PR_GET_NO_NEW_PRIVS = 39 +const PR_GET_PDEATHSIG = 2 +const PR_GET_SECCOMP = 21 +const PR_GET_SECUREBITS = 27 +const PR_GET_SPECULATION_CTRL = 52 +const PR_GET_TAGGED_ADDR_CTRL = 56 +const PR_GET_THP_DISABLE = 42 +const PR_GET_TID_ADDRESS = 40 +const PR_GET_TIMERSLACK = 30 +const PR_GET_TIMING = 13 +const PR_GET_TSC = 25 +const PR_GET_UNALIGN = 5 +const PR_MCE_KILL = 33 +const PR_MCE_KILL_CLEAR = 0 +const PR_MCE_KILL_DEFAULT = 2 +const PR_MCE_KILL_EARLY = 1 +const PR_MCE_KILL_GET = 34 +const PR_MCE_KILL_LATE = 0 +const PR_MCE_KILL_SET = 1 +const PR_MPX_DISABLE_MANAGEMENT = 44 +const PR_MPX_ENABLE_MANAGEMENT = 43 +const PR_MTE_TAG_MASK = 524280 +const PR_MTE_TAG_SHIFT = 3 +const PR_MTE_TCF_ASYNC = 4 +const PR_MTE_TCF_MASK = 6 +const PR_MTE_TCF_NONE = 0 +const PR_MTE_TCF_SHIFT = 1 +const PR_MTE_TCF_SYNC = 2 +const PR_PAC_APDAKEY = 4 +const PR_PAC_APDBKEY = 8 +const PR_PAC_APGAKEY = 16 +const PR_PAC_APIAKEY = 1 +const PR_PAC_APIBKEY = 2 +const PR_PAC_GET_ENABLED_KEYS = 61 +const PR_PAC_RESET_KEYS = 54 +const PR_PAC_SET_ENABLED_KEYS = 60 +const PR_SET_CHILD_SUBREAPER = 36 +const PR_SET_DUMPABLE = 4 +const PR_SET_ENDIAN = 20 +const PR_SET_FPEMU = 10 +const PR_SET_FPEXC = 12 +const PR_SET_FP_MODE = 45 +const PR_SET_IO_FLUSHER = 57 +const PR_SET_KEEPCAPS = 8 +const PR_SET_MM = 35 +const PR_SET_MM_ARG_END = 9 +const PR_SET_MM_ARG_START = 8 +const PR_SET_MM_AUXV = 12 +const PR_SET_MM_BRK = 7 +const PR_SET_MM_END_CODE = 2 +const PR_SET_MM_END_DATA = 4 +const PR_SET_MM_ENV_END = 11 +const PR_SET_MM_ENV_START = 10 +const PR_SET_MM_EXE_FILE = 13 +const PR_SET_MM_MAP = 14 +const PR_SET_MM_MAP_SIZE = 15 +const PR_SET_MM_START_BRK = 6 +const PR_SET_MM_START_CODE = 1 +const PR_SET_MM_START_DATA = 3 +const PR_SET_MM_START_STACK = 5 +const PR_SET_NAME = 15 +const PR_SET_NO_NEW_PRIVS = 38 +const PR_SET_PDEATHSIG = 1 +const PR_SET_PTRACER = 1499557217 +const PR_SET_PTRACER_ANY = 18446744073709551615 +const PR_SET_SECCOMP = 22 +const PR_SET_SECUREBITS = 28 +const PR_SET_SPECULATION_CTRL = 53 +const PR_SET_SYSCALL_USER_DISPATCH = 59 +const PR_SET_TAGGED_ADDR_CTRL = 55 +const PR_SET_THP_DISABLE = 41 +const PR_SET_TIMERSLACK = 29 +const PR_SET_TIMING = 14 +const PR_SET_TSC = 26 +const PR_SET_UNALIGN = 6 +const PR_SPEC_DISABLE = 4 +const PR_SPEC_DISABLE_NOEXEC = 16 +const PR_SPEC_ENABLE = 2 +const PR_SPEC_FORCE_DISABLE = 8 +const PR_SPEC_INDIRECT_BRANCH = 1 +const PR_SPEC_NOT_AFFECTED = 0 +const PR_SPEC_PRCTL = 1 +const PR_SPEC_STORE_BYPASS = 0 +const PR_SVE_GET_VL = 51 +const PR_SVE_SET_VL = 50 +const PR_SVE_SET_VL_ONEXEC = 262144 +const PR_SVE_VL_INHERIT = 131072 +const PR_SVE_VL_LEN_MASK = 65535 +const PR_SYS_DISPATCH_OFF = 0 +const PR_SYS_DISPATCH_ON = 1 +const PR_TAGGED_ADDR_ENABLE = 1 +const PR_TASK_PERF_EVENTS_DISABLE = 31 +const PR_TASK_PERF_EVENTS_ENABLE = 32 +const PR_TIMING_STATISTICAL = 0 +const PR_TIMING_TIMESTAMP = 1 +const PR_TSC_ENABLE = 1 +const PR_TSC_SIGSEGV = 2 +const PR_UNALIGN_NOPRINT = 1 +const PR_UNALIGN_SIGBUS = 2 +const SYSCALL_DISPATCH_FILTER_ALLOW = 0 +const SYSCALL_DISPATCH_FILTER_BLOCK = 1 + +type Tprctl_mm_map = struct { + Fstart_code Tuint64_t + Fend_code Tuint64_t + Fstart_data Tuint64_t + Fend_data Tuint64_t + Fstart_brk Tuint64_t + Fbrk Tuint64_t + Fstart_stack Tuint64_t + Farg_start Tuint64_t + Farg_end Tuint64_t + Fenv_start Tuint64_t + Fenv_end Tuint64_t + Fauxv uintptr + Fauxv_size Tuint32_t + Fexe_fd Tuint32_t +} + +func Xprctl(tls *TLS, op int32, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v op=%v va=%v, (%v:)", tls, op, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var i int32 + var x [4]uint64 + _, _, _ = ap, i, x + ap = va + i = 0 + for { + if !(i < int32(4)) { + break + } + x[i] = VaUint64(&ap) + goto _1 + _1: + ; + i = i + 1 + } + _ = ap + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_prctl), int64(op), Int64FromUint64(x[0]), Int64FromUint64(x[int32(1)]), Int64FromUint64(x[int32(2)]), Int64FromUint64(x[int32(3)]))))) +} + +const RWF_APPEND = 16 +const RWF_DSYNC = 2 +const RWF_HIPRI = 1 +const RWF_NOWAIT = 8 +const RWF_SYNC = 4 +const UIO_MAXIOV = 1024 + +func Xpreadv2(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t, flags int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v ofs=%v flags=%v, (%v:)", tls, fd, iov, count, ofs, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(flags != 0) { + if ofs == int64(-int32(1)) { + return Xreadv(tls, fd, iov, count) + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_preadv), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), 0))) + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_preadv2), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), int64(flags)))) +} + +func Xprlimit(tls *TLS, pid Tpid_t, resource int32, new_limit uintptr, old_limit uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v pid=%v resource=%v new_limit=%v old_limit=%v, (%v:)", tls, pid, resource, new_limit, old_limit, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r int32 + var _ /* tmp at bp+0 */ Trlimit + _ = r + if new_limit != 0 && Bool(^Uint64FromUint64(0) != ^Uint64FromUint64(0)) { + **(**Trlimit)(__ccgo_up(bp)) = **(**Trlimit)(__ccgo_up(new_limit)) + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur >= ^Uint64FromUint64(0) { + (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur = ^Uint64FromUint64(0) + } + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_max >= ^Uint64FromUint64(0) { + (**(**Trlimit)(__ccgo_up(bp))).Frlim_max = ^Uint64FromUint64(0) + } + new_limit = bp + } + r = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_prlimit64), int64(pid), int64(resource), int64(new_limit), int64(old_limit))))) + if !(r != 0) && old_limit != 0 && Bool(^Uint64FromUint64(0) != ^Uint64FromUint64(0)) { + if (*Trlimit)(unsafe.Pointer(old_limit)).Frlim_cur >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(old_limit)).Frlim_cur = ^Uint64FromUint64(0) + } + if (*Trlimit)(unsafe.Pointer(old_limit)).Frlim_max >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(old_limit)).Frlim_max = ^Uint64FromUint64(0) + } + } + return r +} + +func Xprocess_vm_writev(tls *TLS, pid Tpid_t, lvec uintptr, liovcnt uint64, rvec uintptr, riovcnt uint64, flags uint64) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v pid=%v lvec=%v liovcnt=%v rvec=%v riovcnt=%v flags=%v, (%v:)", tls, pid, lvec, liovcnt, rvec, riovcnt, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, int64(SYS_process_vm_writev), int64(pid), int64(lvec), Int64FromUint64(liovcnt), int64(rvec), Int64FromUint64(riovcnt), Int64FromUint64(flags)))) +} + +func Xprocess_vm_readv(tls *TLS, pid Tpid_t, lvec uintptr, liovcnt uint64, rvec uintptr, riovcnt uint64, flags uint64) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v pid=%v lvec=%v liovcnt=%v rvec=%v riovcnt=%v flags=%v, (%v:)", tls, pid, lvec, liovcnt, rvec, riovcnt, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, int64(SYS_process_vm_readv), int64(pid), int64(lvec), Int64FromUint64(liovcnt), int64(rvec), Int64FromUint64(riovcnt), Int64FromUint64(flags)))) +} + +const PTRACE_ATTACH = 16 +const PTRACE_CONT = 7 +const PTRACE_DETACH = 17 +const PTRACE_EVENT_CLONE = 3 +const PTRACE_EVENT_EXEC = 4 +const PTRACE_EVENT_EXIT = 6 +const PTRACE_EVENT_FORK = 1 +const PTRACE_EVENT_SECCOMP = 7 +const PTRACE_EVENT_STOP = 128 +const PTRACE_EVENT_VFORK = 2 +const PTRACE_EVENT_VFORK_DONE = 5 +const PTRACE_GETEVENTMSG = 16897 +const PTRACE_GETFPREGS = 14 +const PTRACE_GETFPXREGS = 18 +const PTRACE_GETREGS = 12 +const PTRACE_GETREGSET = 16900 +const PTRACE_GETSIGINFO = 16898 +const PTRACE_GETSIGMASK = 16906 +const PTRACE_GET_RSEQ_CONFIGURATION = 16911 +const PTRACE_GET_SYSCALL_INFO = 16910 +const PTRACE_INTERRUPT = 16903 +const PTRACE_KILL = 8 +const PTRACE_LISTEN = 16904 +const PTRACE_O_EXITKILL = 1048576 +const PTRACE_O_MASK = 3145983 +const PTRACE_O_SUSPEND_SECCOMP = 2097152 +const PTRACE_O_TRACECLONE = 8 +const PTRACE_O_TRACEEXEC = 16 +const PTRACE_O_TRACEEXIT = 64 +const PTRACE_O_TRACEFORK = 2 +const PTRACE_O_TRACESECCOMP = 128 +const PTRACE_O_TRACESYSGOOD = 1 +const PTRACE_O_TRACEVFORK = 4 +const PTRACE_O_TRACEVFORKDONE = 32 +const PTRACE_PEEKDATA = 2 +const PTRACE_PEEKSIGINFO = 16905 +const PTRACE_PEEKSIGINFO_SHARED = 1 +const PTRACE_PEEKTEXT = 1 +const PTRACE_PEEKUSER = 3 +const PTRACE_POKEDATA = 5 +const PTRACE_POKETEXT = 4 +const PTRACE_POKEUSER = 6 +const PTRACE_SECCOMP_GET_FILTER = 16908 +const PTRACE_SECCOMP_GET_METADATA = 16909 +const PTRACE_SEIZE = 16902 +const PTRACE_SETFPREGS = 15 +const PTRACE_SETFPXREGS = 19 +const PTRACE_SETOPTIONS = 16896 +const PTRACE_SETREGS = 13 +const PTRACE_SETREGSET = 16901 +const PTRACE_SETSIGINFO = 16899 +const PTRACE_SETSIGMASK = 16907 +const PTRACE_SINGLESTEP = 9 +const PTRACE_SYSCALL = 24 +const PTRACE_SYSCALL_INFO_ENTRY = 1 +const PTRACE_SYSCALL_INFO_EXIT = 2 +const PTRACE_SYSCALL_INFO_NONE = 0 +const PTRACE_SYSCALL_INFO_SECCOMP = 3 +const PTRACE_TRACEME = 0 +const PT_ATTACH = 16 +const PT_CONTINUE = 7 +const PT_DETACH = 17 +const PT_GETEVENTMSG = 16897 +const PT_GETFPREGS = 14 +const PT_GETFPXREGS = 18 +const PT_GETREGS = 12 +const PT_GETSIGINFO = 16898 +const PT_KILL = 8 +const PT_READ_D = 2 +const PT_READ_I = 1 +const PT_READ_U = 3 +const PT_SETFPREGS = 15 +const PT_SETFPXREGS = 19 +const PT_SETOPTIONS = 16896 +const PT_SETREGS = 13 +const PT_SETSIGINFO = 16899 +const PT_STEP = 9 +const PT_SYSCALL = 24 +const PT_TRACE_ME = 0 +const PT_WRITE_D = 5 +const PT_WRITE_I = 4 +const PT_WRITE_U = 6 + +type t__ptrace_peeksiginfo_args = struct { + Foff Tuint64_t + Fflags Tuint32_t + Fnr Tint32_t +} + +type t__ptrace_seccomp_metadata = struct { + Ffilter_off Tuint64_t + Fflags Tuint64_t +} + +type t__ptrace_syscall_info = struct { + Fop Tuint8_t + F__pad [3]Tuint8_t + Farch Tuint32_t + Finstruction_pointer Tuint64_t + Fstack_pointer Tuint64_t + F__ccgo5_24 struct { + Fexit [0]struct { + Frval Tint64_t + Fis_error Tuint8_t + } + Fseccomp [0]struct { + Fnr Tuint64_t + Fargs [6]Tuint64_t + Fret_data Tuint32_t + } + Fentry struct { + Fnr Tuint64_t + Fargs [6]Tuint64_t + } + F__ccgo_pad3 [8]byte + } +} + +type t__ptrace_rseq_configuration = struct { + Frseq_abi_pointer Tuint64_t + Frseq_abi_size Tuint32_t + Fsignature Tuint32_t + Fflags Tuint32_t + Fpad Tuint32_t +} + +func Xptrace(tls *TLS, req int32, va uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v req=%v va=%v, (%v:)", tls, req, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var addr, addr2, data uintptr + var ap Tva_list + var pid Tpid_t + var ret int64 + var _ /* result at bp+0 */ int64 + _, _, _, _, _, _ = addr, addr2, ap, data, pid, ret + addr2 = uintptr(0) + ap = va + pid = VaInt32(&ap) + addr = VaUintptr(&ap) + data = VaUintptr(&ap) + /* PTRACE_{READ,WRITE}{DATA,TEXT} (16...19) are specific to SPARC. */ + _ = ap + if Uint32FromInt32(req)-uint32(1) < uint32(3) { + data = bp + } + ret = X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_ptrace), int64(req), int64(pid), int64(addr), int64(data), int64(addr2)))) + if ret < 0 || Uint32FromInt32(req)-uint32(1) >= uint32(3) { + return ret + } + return **(**int64)(__ccgo_up(bp)) +} + +func Xpwritev2(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t, flags int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v ofs=%v flags=%v, (%v:)", tls, fd, iov, count, ofs, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(flags != 0) { + if ofs == int64(-int32(1)) { + return Xwritev(tls, fd, iov, count) + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pwritev), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), 0))) + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pwritev2), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), int64(flags)))) +} + +const GRPQUOTA = 1 +const IIF_ALL = 7 +const IIF_BGRACE = 1 +const IIF_FLAGS = 4 +const IIF_IGRACE = 2 +const MAXQUOTAS = 2 +const MAX_DQ_TIME = 604800 +const MAX_IQ_TIME = 604800 +const NR_DQHASH = 43 +const NR_DQUOTS = 256 +const QFMT_OCFS2 = 3 +const QFMT_VFS_OLD = 1 +const QFMT_VFS_V0 = 2 +const QFMT_VFS_V1 = 4 +const QIF_ALL = 63 +const QIF_BLIMITS = 1 +const QIF_BTIME = 16 +const QIF_ILIMITS = 4 +const QIF_INODES = 8 +const QIF_ITIME = 32 +const QIF_LIMITS = 5 +const QIF_SPACE = 2 +const QIF_TIMES = 48 +const QIF_USAGE = 10 +const QUOTAFILENAME = "quota" +const QUOTAGROUP = "staff" +const Q_GETFMT = 8388612 +const Q_GETINFO = 8388613 +const Q_GETQUOTA = 8388615 +const Q_QUOTAOFF = 8388611 +const Q_QUOTAON = 8388610 +const Q_SETINFO = 8388614 +const Q_SETQUOTA = 8388616 +const Q_SYNC = 8388609 +const SUBCMDMASK = 255 +const SUBCMDSHIFT = 8 +const USRQUOTA = 0 +const _LINUX_QUOTA_VERSION = 2 + +type Tdqblk = struct { + Fdqb_bhardlimit Tuint64_t + Fdqb_bsoftlimit Tuint64_t + Fdqb_curspace Tuint64_t + Fdqb_ihardlimit Tuint64_t + Fdqb_isoftlimit Tuint64_t + Fdqb_curinodes Tuint64_t + Fdqb_btime Tuint64_t + Fdqb_itime Tuint64_t + Fdqb_valid Tuint32_t +} + +type Tdqinfo = struct { + Fdqi_bgrace Tuint64_t + Fdqi_igrace Tuint64_t + Fdqi_flags Tuint32_t + Fdqi_valid Tuint32_t +} + +func Xquotactl(tls *TLS, cmd int32, special uintptr, id int32, addr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v cmd=%v special=%v id=%v addr=%v, (%v:)", tls, cmd, special, id, addr, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_quotactl), int64(cmd), int64(special), int64(id), int64(addr))))) +} + +func Xreadahead(tls *TLS, fd int32, pos Toff_t, len1 Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v pos=%v len1=%v, (%v:)", tls, fd, pos, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_readahead), int64(fd), pos, Int64FromUint64(len1)))) +} + +const RB_AUTOBOOT = 19088743 +const RB_DISABLE_CAD = 0 +const RB_ENABLE_CAD = 2309737967 +const RB_HALT_SYSTEM = 3454992675 +const RB_KEXEC = 1163412803 +const RB_POWER_OFF = 1126301404 +const RB_SW_SUSPEND = 3489725666 + +func Xreboot(tls *TLS, type1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v type1=%v, (%v:)", tls, type1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_reboot), Int64FromUint32(Uint32FromUint32(0xfee1dead)), int64(Int32FromInt32(672274793)), int64(type1))))) +} + +func Xremap_file_pages(tls *TLS, addr uintptr, size Tsize_t, prot int32, pgoff Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v size=%v prot=%v pgoff=%v flags=%v, (%v:)", tls, addr, size, prot, pgoff, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_remap_file_pages), int64(addr), Int64FromUint64(size), int64(prot), Int64FromUint64(pgoff), int64(flags))))) +} + +func Xsbrk(tls *TLS, inc Tintptr_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v inc=%v, (%v:)", tls, inc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if inc != 0 { + return uintptr(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(ENOMEM)))) + } + return uintptr(X__syscall1(tls, int64(SYS_brk), int64(Int32FromInt32(0)))) +} + +func Xsendfile(tls *TLS, out_fd int32, in_fd int32, ofs uintptr, count Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v out_fd=%v in_fd=%v ofs=%v count=%v, (%v:)", tls, out_fd, in_fd, ofs, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_sendfile), int64(out_fd), int64(in_fd), int64(ofs), Int64FromUint64(count)))) +} + +func Xsetfsgid(tls *TLS, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v gid=%v, (%v:)", tls, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_setfsgid), Int64FromUint32(gid))))) +} + +func Xsetfsuid(tls *TLS, uid Tuid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v uid=%v, (%v:)", tls, uid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_setfsuid), Int64FromUint32(uid))))) +} + +func Xsethostname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v len1=%v, (%v:)", tls, name, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_sethostname), int64(name), Int64FromUint64(len1))))) +} + +const CLONE_CHILD_CLEARTID = 2097152 +const CLONE_CHILD_SETTID = 16777216 +const CLONE_DETACHED = 4194304 +const CLONE_FILES = 1024 +const CLONE_FS = 512 +const CLONE_IO = 2147483648 +const CLONE_NEWCGROUP = 33554432 +const CLONE_NEWIPC = 134217728 +const CLONE_NEWNET = 1073741824 +const CLONE_NEWNS = 131072 +const CLONE_NEWPID = 536870912 +const CLONE_NEWTIME = 128 +const CLONE_NEWUSER = 268435456 +const CLONE_NEWUTS = 67108864 +const CLONE_PARENT = 32768 +const CLONE_PARENT_SETTID = 1048576 +const CLONE_PIDFD = 4096 +const CLONE_PTRACE = 8192 +const CLONE_SETTLS = 524288 +const CLONE_SIGHAND = 2048 +const CLONE_SYSVSEM = 262144 +const CLONE_THREAD = 65536 +const CLONE_UNTRACED = 8388608 +const CLONE_VFORK = 16384 +const CLONE_VM = 256 +const CPU_SETSIZE = 1024 +const CSIGNAL = 255 + +type Tcpu_set_t = struct { + F__bits [16]uint64 +} + +func Xsetns(tls *TLS, fd int32, nstype int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v nstype=%v, (%v:)", tls, fd, nstype, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_setns), int64(fd), int64(nstype))))) +} + +const __tm_gmtoff = 0 +const __tm_zone = 0 + +type Ttm1 = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + Ftm_gmtoff int64 + Ftm_zone uintptr +} + +func Xsettimeofday(tls *TLS, tv uintptr, tz uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v tv=%v tz=%v, (%v:)", tls, tv, tz, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + if !(tv != 0) { + return 0 + } + if Uint64FromInt64((*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec) >= uint64(1000000) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + *(*Ttimespec)(unsafe.Pointer(bp)) = Ttimespec{ + Ftv_sec: (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec, + Ftv_nsec: (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec * int64(1000), + } + return Xclock_settime(tls, CLOCK_REALTIME, bp) +} + +const SFD_CLOEXEC = 524288 +const SFD_NONBLOCK = 2048 + +type Tsignalfd_siginfo = struct { + Fssi_signo Tuint32_t + Fssi_errno Tint32_t + Fssi_code Tint32_t + Fssi_pid Tuint32_t + Fssi_uid Tuint32_t + Fssi_fd Tint32_t + Fssi_tid Tuint32_t + Fssi_band Tuint32_t + Fssi_overrun Tuint32_t + Fssi_trapno Tuint32_t + Fssi_status Tint32_t + Fssi_int Tint32_t + Fssi_ptr Tuint64_t + Fssi_utime Tuint64_t + Fssi_stime Tuint64_t + Fssi_addr Tuint64_t + Fssi_addr_lsb Tuint16_t + F__pad2 Tuint16_t + Fssi_syscall Tint32_t + Fssi_call_addr Tuint64_t + Fssi_arch Tuint32_t + F__pad [28]Tuint8_t +} + +func Xsignalfd(tls *TLS, fd int32, sigs uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v sigs=%v flags=%v, (%v:)", tls, fd, sigs, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + ret = int32(X__syscall4(tls, int64(SYS_signalfd4), int64(fd), int64(sigs), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), int64(flags))) + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) +} + +func Xsplice(tls *TLS, fd_in int32, off_in uintptr, fd_out int32, off_out uintptr, len1 Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd_in=%v off_in=%v fd_out=%v off_out=%v len1=%v flags=%v, (%v:)", tls, fd_in, off_in, fd_out, off_out, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, int64(SYS_splice), int64(fd_in), int64(off_in), int64(fd_out), int64(off_out), Int64FromUint64(len1), Int64FromUint32(flags)))) +} + +func Xstatx(tls *TLS, dirfd int32, path uintptr, flags int32, mask uint32, stx uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dirfd=%v path=%v flags=%v mask=%v stx=%v, (%v:)", tls, dirfd, path, flags, mask, stx, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var ret int32 + var _ /* st at bp+0 */ Tstat + _ = ret + ret = int32(X__syscall5(tls, int64(SYS_statx), int64(dirfd), int64(path), int64(flags), Int64FromUint32(mask), int64(stx))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + ret = Xfstatat(tls, dirfd, path, bp, flags) + if ret != 0 { + return ret + } + (*Tstatx)(unsafe.Pointer(stx)).Fstx_dev_major = uint32((**(**Tstat)(__ccgo_up(bp))).Fst_dev>>Int32FromInt32(31)>>Int32FromInt32(1)&Uint64FromUint32(0xfffff000) | (**(**Tstat)(__ccgo_up(bp))).Fst_dev>>Int32FromInt32(8)&Uint64FromInt32(0x00000fff)) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_dev_minor = uint32((**(**Tstat)(__ccgo_up(bp))).Fst_dev>>Int32FromInt32(12)&Uint64FromUint32(0xffffff00) | (**(**Tstat)(__ccgo_up(bp))).Fst_dev&Uint64FromInt32(0x000000ff)) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_ino = (**(**Tstat)(__ccgo_up(bp))).Fst_ino + (*Tstatx)(unsafe.Pointer(stx)).Fstx_mode = uint16((**(**Tstat)(__ccgo_up(bp))).Fst_mode) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_nlink = (**(**Tstat)(__ccgo_up(bp))).Fst_nlink + (*Tstatx)(unsafe.Pointer(stx)).Fstx_uid = (**(**Tstat)(__ccgo_up(bp))).Fst_uid + (*Tstatx)(unsafe.Pointer(stx)).Fstx_gid = (**(**Tstat)(__ccgo_up(bp))).Fst_gid + (*Tstatx)(unsafe.Pointer(stx)).Fstx_size = Uint64FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_size) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_blksize = Uint32FromInt32((**(**Tstat)(__ccgo_up(bp))).Fst_blksize) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_blocks = Uint64FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_blocks) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_atime.Ftv_sec = (**(**Tstat)(__ccgo_up(bp))).Fst_atim.Ftv_sec + (*Tstatx)(unsafe.Pointer(stx)).Fstx_atime.Ftv_nsec = Uint32FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_atim.Ftv_nsec) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_mtime.Ftv_sec = (**(**Tstat)(__ccgo_up(bp))).Fst_mtim.Ftv_sec + (*Tstatx)(unsafe.Pointer(stx)).Fstx_mtime.Ftv_nsec = Uint32FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_mtim.Ftv_nsec) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_ctime.Ftv_sec = (**(**Tstat)(__ccgo_up(bp))).Fst_ctim.Ftv_sec + (*Tstatx)(unsafe.Pointer(stx)).Fstx_ctime.Ftv_nsec = Uint32FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_ctim.Ftv_nsec) + (*Tstatx)(unsafe.Pointer(stx)).Fstx_btime = Tstatx_timestamp{} + (*Tstatx)(unsafe.Pointer(stx)).Fstx_mask = uint32(0x7ff) + return 0 +} + +func Xstime(tls *TLS, t uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* tv at bp+0 */ Ttimeval + **(**Ttimeval)(__ccgo_up(bp)) = Ttimeval{ + Ftv_sec: **(**Ttime_t)(__ccgo_up(t)), + } + return Xsettimeofday(tls, bp, UintptrFromInt32(0)) +} + +const SWAP_FLAG_DISCARD = 65536 +const SWAP_FLAG_PREFER = 32768 +const SWAP_FLAG_PRIO_MASK = 32767 +const SWAP_FLAG_PRIO_SHIFT = 0 + +func Xswapon(tls *TLS, path uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v flags=%v, (%v:)", tls, path, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_swapon), int64(path), int64(flags))))) +} + +func Xswapoff(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_swapoff), int64(path))))) +} + +func Xsync_file_range(tls *TLS, fd int32, pos Toff_t, len1 Toff_t, flags uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v pos=%v len1=%v flags=%v, (%v:)", tls, fd, pos, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_sync_file_range), int64(fd), pos, len1, Int64FromUint32(flags))))) +} + +func Xsyncfs(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_syncfs), int64(fd))))) +} + +func X__lsysinfo(tls *TLS, info uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v info=%v, (%v:)", tls, info, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_sysinfo), int64(info))))) +} + +func Xsysinfo(tls *TLS, info uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v info=%v, (%v:)", tls, info, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lsysinfo(tls, info) +} + +func Xtee(tls *TLS, src int32, dest int32, len1 Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v src=%v dest=%v len1=%v flags=%v, (%v:)", tls, src, dest, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_tee), int64(src), int64(dest), Int64FromUint64(len1), Int64FromUint32(flags)))) +} + +const TFD_CLOEXEC = 524288 +const TFD_NONBLOCK = 2048 +const TFD_TIMER_ABSTIME = 1 +const TFD_TIMER_CANCEL_ON_SET = 2 + +func Xtimerfd_create(tls *TLS, clockid int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v clockid=%v flags=%v, (%v:)", tls, clockid, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_timerfd_create), int64(clockid), int64(flags))))) +} + +func Xtimerfd_settime(tls *TLS, fd int32, flags int32, new1 uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v flags=%v new1=%v old=%v, (%v:)", tls, fd, flags, new1, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_timerfd_settime), int64(fd), int64(flags), int64(new1), int64(old))))) +} + +func Xtimerfd_gettime(tls *TLS, fd int32, cur uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v cur=%v, (%v:)", tls, fd, cur, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_timerfd_gettime), int64(fd), int64(cur))))) +} + +func Xunshare(tls *TLS, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_unshare), int64(flags))))) +} + +func Xutimes(tls *TLS, path uintptr, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v times=%v, (%v:)", tls, path, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__futimesat(tls, -int32(100), path, times) +} + +func Xvhangup(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall0(tls, int64(SYS_vhangup))))) +} + +func Xvmsplice(tls *TLS, fd int32, iov uintptr, cnt Tsize_t, flags uint32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v cnt=%v flags=%v, (%v:)", tls, fd, iov, cnt, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_vmsplice), int64(fd), int64(iov), Int64FromUint64(cnt), Int64FromUint32(flags)))) +} + +const ESR_MAGIC = 1163088385 +const EXTRA_MAGIC = 1163416577 +const FPSIMD_MAGIC = 1179680769 +const NSIG = 65 +const SA_NOMASK = 1073741824 +const SA_ONESHOT = 2147483648 +const SVE_MAGIC = 1398162689 +const SVE_NUM_PREGS = 16 +const SVE_NUM_ZREGS = 32 +const SVE_SIG_REGS_OFFSET = 0 +const SVE_SIG_ZREGS_OFFSET = 0 +const SVE_VL_MAX = 8192 +const SVE_VL_MIN = 16 +const SVE_VQ_BYTES = 16 +const SVE_VQ_MAX = 512 +const SVE_VQ_MIN = 1 +const SYS_SECCOMP = 1 +const SYS_USER_DISPATCH = 2 +const __ucontext = 0 + +type Tgreg_t = uint64 + +type Tgregset_t = [34]uint64 + +type Tfpregset_t = struct { + F__ccgo_align [0]uint64 + Fvregs [32][2]uint64 + Ffpsr uint32 + Ffpcr uint32 + F__ccgo_pad3 [8]byte +} + +type Tmcontext_t1 = struct { + Ffault_address uint64 + Fregs [31]uint64 + Fsp uint64 + Fpc uint64 + Fpstate uint64 + F__reserved [256]float64 +} + +type Tsigcontext = Tmcontext_t1 + +type T_aarch64_ctx = struct { + Fmagic uint32 + Fsize uint32 +} + +type Tfpsimd_context = struct { + F__ccgo_align [0]uint64 + Fhead T_aarch64_ctx + Ffpsr uint32 + Ffpcr uint32 + Fvregs [32][2]uint64 +} + +type Tesr_context = struct { + Fhead T_aarch64_ctx + Fesr uint64 +} + +type Textra_context = struct { + Fhead T_aarch64_ctx + Fdatap uint64 + Fsize uint32 + F__reserved [3]uint32 +} + +type Tsve_context = struct { + Fhead T_aarch64_ctx + Fvl uint16 + F__reserved [3]uint16 +} + +type Tucontext_t1 = struct { + Fuc_flags uint64 + Fuc_link uintptr + Fuc_stack Tstack_t + Fuc_sigmask Tsigset_t + Fuc_mcontext Tmcontext_t1 +} + +type Tucontext = Tucontext_t1 + +type Tsig_t = uintptr + +type Tsighandler_t = uintptr + +func Xwait3(tls *TLS, status uintptr, options int32, usage uintptr) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v status=%v options=%v usage=%v, (%v:)", tls, status, options, usage, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwait4(tls, -int32(1), status, options, usage) +} + +func Xwait4(tls *TLS, pid Tpid_t, status uintptr, options int32, ru uintptr) (r1 Tpid_t) { + if __ccgo_strace { + trc("tls=%v pid=%v status=%v options=%v ru=%v, (%v:)", tls, pid, status, options, ru, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var dest, v1 uintptr + var r int32 + var _ /* kru at bp+0 */ [4]int64 + _, _, _ = dest, r, v1 + if ru != 0 { + v1 = ru + 32 - uintptr(Uint64FromInt32(4)*Uint64FromInt64(8)) + } else { + v1 = uintptr(0) + } + dest = v1 + r = int32(X__syscall4(tls, int64(SYS_wait4), int64(pid), int64(status), int64(options), int64(dest))) + if r > 0 && ru != 0 && Bool(uint64(8) > uint64(8)) { + Xmemcpy(tls, bp, dest, Uint64FromInt32(4)*Uint64FromInt64(8)) + (*Trusage)(unsafe.Pointer(ru)).Fru_utime = Ttimeval{ + Ftv_sec: (**(**[4]int64)(__ccgo_up(bp)))[0], + Ftv_usec: (**(**[4]int64)(__ccgo_up(bp)))[int32(1)], + } + (*Trusage)(unsafe.Pointer(ru)).Fru_stime = Ttimeval{ + Ftv_sec: (**(**[4]int64)(__ccgo_up(bp)))[int32(2)], + Ftv_usec: (**(**[4]int64)(__ccgo_up(bp)))[int32(3)], + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +const XATTR_CREATE = 1 +const XATTR_REPLACE = 2 +const __UAPI_DEF_XATTR = 0 + +func Xgetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v value=%v size=%v, (%v:)", tls, path, name, value, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_getxattr), int64(path), int64(name), int64(value), Int64FromUint64(size)))) +} + +func Xlgetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v value=%v size=%v, (%v:)", tls, path, name, value, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_lgetxattr), int64(path), int64(name), int64(value), Int64FromUint64(size)))) +} + +func Xfgetxattr(tls *TLS, filedes int32, name uintptr, value uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v filedes=%v name=%v value=%v size=%v, (%v:)", tls, filedes, name, value, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_fgetxattr), int64(filedes), int64(name), int64(value), Int64FromUint64(size)))) +} + +func Xlistxattr(tls *TLS, path uintptr, list uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v list=%v size=%v, (%v:)", tls, path, list, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_listxattr), int64(path), int64(list), Int64FromUint64(size)))) +} + +func Xllistxattr(tls *TLS, path uintptr, list uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v list=%v size=%v, (%v:)", tls, path, list, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_llistxattr), int64(path), int64(list), Int64FromUint64(size)))) +} + +func Xflistxattr(tls *TLS, filedes int32, list uintptr, size Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v filedes=%v list=%v size=%v, (%v:)", tls, filedes, list, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_flistxattr), int64(filedes), int64(list), Int64FromUint64(size)))) +} + +func Xsetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v value=%v size=%v flags=%v, (%v:)", tls, path, name, value, size, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_setxattr), int64(path), int64(name), int64(value), Int64FromUint64(size), int64(flags))))) +} + +func Xlsetxattr(tls *TLS, path uintptr, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v value=%v size=%v flags=%v, (%v:)", tls, path, name, value, size, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_lsetxattr), int64(path), int64(name), int64(value), Int64FromUint64(size), int64(flags))))) +} + +func Xfsetxattr(tls *TLS, filedes int32, name uintptr, value uintptr, size Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v filedes=%v name=%v value=%v size=%v flags=%v, (%v:)", tls, filedes, name, value, size, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fsetxattr), int64(filedes), int64(name), int64(value), Int64FromUint64(size), int64(flags))))) +} + +func Xremovexattr(tls *TLS, path uintptr, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v, (%v:)", tls, path, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_removexattr), int64(path), int64(name))))) +} + +func Xlremovexattr(tls *TLS, path uintptr, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v name=%v, (%v:)", tls, path, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_lremovexattr), int64(path), int64(name))))) +} + +func Xfremovexattr(tls *TLS, fd int32, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v name=%v, (%v:)", tls, fd, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_fremovexattr), int64(fd), int64(name))))) +} + +func _dummy4(tls *TLS, msg uintptr, lm uintptr) (r uintptr) { + return msg +} + +func X__lctrans(tls *TLS, msg uintptr, lm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v lm=%v, (%v:)", tls, msg, lm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lctrans_impl(tls, msg, lm) +} + +func X__lctrans_cur(tls *TLS, msg uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v, (%v:)", tls, msg, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lctrans_impl(tls, msg, **(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale + 5*8))) +} + +func _swapc(tls *TLS, x Tuint32_t, c int32) (r Tuint32_t) { + var v1 uint32 + _ = v1 + if c != 0 { + v1 = x>>int32(24) | x>>int32(8)&uint32(0xff00) | x< %v", r) }() + } + var b, n, o, ol, os, t, tl, ts Tuint32_t + var mo uintptr + var sign, sw int32 + _, _, _, _, _, _, _, _, _, _, _ = b, mo, n, o, ol, os, sign, sw, t, tl, ts + mo = p + sw = Int32FromUint32(**(**Tuint32_t)(__ccgo_up(mo)) - uint32(0x950412de)) + b = uint32(0) + n = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + 2*4)), sw) + o = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + 3*4)), sw) + t = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + 4*4)), sw) + if uint64(n) >= size/uint64(4) || uint64(o) >= size-uint64(uint32(4)*n) || uint64(t) >= size-uint64(uint32(4)*n) || (o|t)%uint32(4) != 0 { + return uintptr(0) + } + o = o / uint32(4) + t = t / uint32(4) + for { + ol = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + uintptr(o+uint32(2)*(b+n/uint32(2)))*4)), sw) + os = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + uintptr(o+uint32(2)*(b+n/uint32(2))+uint32(1))*4)), sw) + if uint64(os) >= size || uint64(ol) >= size-uint64(os) || **(**uint8)(__ccgo_up(p + uintptr(os+ol))) != 0 { + return uintptr(0) + } + sign = Xstrcmp(tls, s, p+uintptr(os)) + if !(sign != 0) { + tl = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + uintptr(t+uint32(2)*(b+n/uint32(2)))*4)), sw) + ts = _swapc(tls, **(**Tuint32_t)(__ccgo_up(mo + uintptr(t+uint32(2)*(b+n/uint32(2))+uint32(1))*4)), sw) + if uint64(ts) >= size || uint64(tl) >= size-uint64(ts) || **(**uint8)(__ccgo_up(p + uintptr(ts+tl))) != 0 { + return uintptr(0) + } + return p + uintptr(ts) + } else { + if n == uint32(1) { + return uintptr(0) + } else { + if sign < 0 { + n = n / uint32(2) + } else { + b = b + n/uint32(2) + n = n - n/uint32(2) + } + } + } + goto _1 + _1: + } + return uintptr(0) +} + +const __USE_GNU_GETTEXT = 1 + +func Xbind_textdomain_codeset(tls *TLS, domainname uintptr, codeset uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v codeset=%v, (%v:)", tls, domainname, codeset, origin(2)) + defer func() { trc("-> %v", r) }() + } + if codeset != 0 && Xstrcasecmp(tls, codeset, __ccgo_ts+322) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + } + return UintptrFromInt32(0) +} + +var _empty_mo = [5]Tuint32_t{ + 0: uint32(0x950412de), + 2: Uint32FromInt32(-Int32FromInt32(1)), + 3: Uint32FromInt32(-Int32FromInt32(1)), + 4: Uint32FromInt32(-Int32FromInt32(1)), +} + +const NL_CAT_LOCALE = 1 +const NL_SETD = 1 + +type Tnl_item = int32 + +type Tnl_catd = uintptr + +func Xcatclose(tls *TLS, catd Tnl_catd) (r int32) { + if __ccgo_strace { + trc("tls=%v catd=%v, (%v:)", tls, catd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var map1 uintptr + var v1, v2 Tuint32_t + _, _, _ = map1, v1, v2 + map1 = catd + v1 = **(**Tuint32_t)(__ccgo_up(map1 + UintptrFromInt32(8))) + v2 = v1>>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v4>>int32(8)&uint32(0xff00) | v4< y { + v8 = int32(1) + } else { + v8 = 0 + } + v7 = v8 + } + return v7 +} + +func Xcatgets(tls *TLS, catd Tnl_catd, set_id int32, msg_id int32, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v catd=%v set_id=%v msg_id=%v s=%v, (%v:)", tls, catd, set_id, msg_id, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var map1, msg, msgs, set, sets, strings uintptr + var nmsgs, nsets, v1, v10, v11, v13, v14, v2, v4, v5, v7, v8 Tuint32_t + var _ /* msg_id_be at bp+4 */ Tuint32_t + var _ /* set_id_be at bp+0 */ Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = map1, msg, msgs, nmsgs, nsets, set, sets, strings, v1, v10, v11, v13, v14, v2, v4, v5, v7, v8 + map1 = catd + v1 = **(**Tuint32_t)(__ccgo_up(map1 + UintptrFromInt32(4))) + v2 = v1>>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v4>>int32(8)&uint32(0xff00) | v4<>int32(24) | v7>>int32(8)&uint32(0xff00) | v7<>int32(24) | v10>>int32(8)&uint32(0xff00) | v10<>int32(24) | v13>>int32(8)&uint32(0xff00) | v13<>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v4>>int32(8)&uint32(0xff00) | v4<>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v1>>int32(8)&uint32(0xff00) | v1<>int32(24) | v5>>int32(8)&uint32(0xff00) | v5< %v", r) }() + } + bp := tls.Alloc(4096) + defer tls.Free(4096) + var catd Tnl_catd + var i, l Tsize_t + var lang, p, path, v, z, v1 uintptr + var v2 bool + var _ /* buf at bp+0 */ [4096]uint8 + _, _, _, _, _, _, _, _, _, _ = catd, i, l, lang, p, path, v, z, v1, v2 + if Xstrchr(tls, name, int32('/')) != 0 { + return _do_catopen(tls, name) + } + if v2 = X__libc.Fsecure != 0; !v2 { + v1 = Xgetenv(tls, __ccgo_ts+328) + path = v1 + } + if v2 || !(v1 != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(-Int32FromInt32(1)) + } + if oflag != 0 { + v1 = Xnl_langinfo(tls, Int32FromInt32(LC_MESSAGES)<= uint64(4096)-i { + break + } + Xmemcpy(tls, bp+uintptr(i), v, l) + i = i + l + goto _5 + _5: + ; + p = p + 1 + } + if !(**(**uint8)(__ccgo_up(z)) != 0) && (p < z || !(i != 0)) { + break + } + if p < z { + goto _4 + } + if **(**uint8)(__ccgo_up(z)) != 0 { + z = z + 1 + } + (**(**[4096]uint8)(__ccgo_up(bp)))[i] = uint8(0) + /* Leading : or :: in NLSPATH is same as %N */ + if i != 0 { + v1 = bp + } else { + v1 = name + } + catd = _do_catopen(tls, v1) + if catd != uintptr(-Int32FromInt32(1)) { + return catd + } + goto _4 + _4: + ; + p = z + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(-Int32FromInt32(1)) +} + +const calloc = 0 +const free = 0 +const malloc = 0 +const realloc = 0 + +type Tbinding = struct { + Fnext uintptr + Fdirlen int32 + Factive int32 + Fdomainname uintptr + Fdirname uintptr +} + +var _bindings uintptr + +func _gettextdir(tls *TLS, domainname uintptr, dirlen uintptr) (r uintptr) { + var p uintptr + _ = p + p = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + for { + if !(p != 0) { + break + } + if !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(p)).Fdomainname, domainname) != 0) && AtomicLoadPInt32(p+12) != 0 { + **(**Tsize_t)(__ccgo_up(dirlen)) = Uint64FromInt32((*Tbinding)(unsafe.Pointer(p)).Fdirlen) + return (*Tbinding)(unsafe.Pointer(p)).Fdirname + } + goto _1 + _1: + ; + p = (*Tbinding)(unsafe.Pointer(p)).Fnext + } + return uintptr(0) +} + +var _lock1 [1]int32 + +func Xbindtextdomain(tls *TLS, domainname uintptr, dirname uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v dirname=%v, (%v:)", tls, domainname, dirname, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var dirlen, domlen Tsize_t + var old, p4, q, v, v2, v6 uintptr + var r, v3 int32 + _, _, _, _, _, _, _, _, _, _ = dirlen, domlen, old, p4, q, r, v, v2, v3, v6 + if !(domainname != 0) { + return uintptr(0) + } + if !(dirname != 0) { + *(*Tsize_t)(unsafe.Pointer(bp)) = uint64(0) + return _gettextdir(tls, domainname, bp) + } + domlen = Xstrnlen(tls, domainname, Uint64FromInt32(Int32FromInt32(NAME_MAX)+Int32FromInt32(1))) + dirlen = Xstrnlen(tls, dirname, uint64(PATH_MAX)) + if domlen > uint64(NAME_MAX) || dirlen >= uint64(PATH_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + ___lock(tls, uintptr(unsafe.Pointer(&_lock1))) + p4 = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + for { + if !(p4 != 0) { + break + } + if !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(p4)).Fdomainname, domainname) != 0) && !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(p4)).Fdirname, dirname) != 0) { + break + } + goto _1 + _1: + ; + p4 = (*Tbinding)(unsafe.Pointer(p4)).Fnext + } + if !(p4 != 0) { + p4 = Xcalloc(tls, uint64(32)+domlen+dirlen+uint64(2), uint64(1)) + if !(p4 != 0) { + ___unlock(tls, uintptr(unsafe.Pointer(&_lock1))) + return uintptr(0) + } + (*Tbinding)(unsafe.Pointer(p4)).Fnext = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + (*Tbinding)(unsafe.Pointer(p4)).Fdirlen = Int32FromUint64(dirlen) + (*Tbinding)(unsafe.Pointer(p4)).Fdomainname = p4 + 32 + (*Tbinding)(unsafe.Pointer(p4)).Fdirname = p4 + 32 + uintptr(domlen) + uintptr(1) + Xmemcpy(tls, (*Tbinding)(unsafe.Pointer(p4)).Fdomainname, domainname, domlen+uint64(1)) + Xmemcpy(tls, (*Tbinding)(unsafe.Pointer(p4)).Fdirname, dirname, dirlen+uint64(1)) + v2 = uintptr(unsafe.Pointer(&_bindings)) + for { + // __asm__ __volatile__ ("ldaxr %0, %1" : "=r"(v) : "Q"(*(void *volatile *)p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 41, __ccgo_ts+399) + v6 = v + goto _7 + _7: + old = v6 + if old != AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+399) + break + } + goto _5 + _5: + ; + // __asm__ __volatile__ ("stlxr %w0,%2,%1" : "=&r"(r), "=Q"(*(void *volatile *)p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 49, __ccgo_ts+399) + v3 = BoolInt32(!(r != 0)) + goto _4 + _4: + ; + if !!(v3 != 0) { + break + } + } + _ = old + goto _8 + _8: + } + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+399) + AtomicStorePInt32(p4+12, int32(1)) + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+399) + q = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + for { + if !(q != 0) { + break + } + if !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(q)).Fdomainname, domainname) != 0) && q != p4 { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+399) + AtomicStorePInt32(q+12, 0) + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+399) + } + goto _9 + _9: + ; + q = (*Tbinding)(unsafe.Pointer(q)).Fnext + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock1))) + return (*Tbinding)(unsafe.Pointer(p4)).Fdirname +} + +var _catnames = [6][12]uint8{ + 0: {'L', 'C', '_', 'C', 'T', 'Y', 'P', 'E'}, + 1: {'L', 'C', '_', 'N', 'U', 'M', 'E', 'R', 'I', 'C'}, + 2: {'L', 'C', '_', 'T', 'I', 'M', 'E'}, + 3: {'L', 'C', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E'}, + 4: {'L', 'C', '_', 'M', 'O', 'N', 'E', 'T', 'A', 'R', 'Y'}, + 5: {'L', 'C', '_', 'M', 'E', 'S', 'S', 'A', 'G', 'E', 'S'}, +} + +var _catlens = [6]uint8{ + 0: uint8(8), + 1: uint8(10), + 2: uint8(7), + 3: uint8(10), + 4: uint8(11), + 5: uint8(11), +} + +type Tmsgcat = struct { + Fnext uintptr + Fmap1 uintptr + Fmap_size Tsize_t + Fplural_rule uintptr + Fnplurals int32 + Fbinding uintptr + Flm uintptr + Fcat int32 +} + +func _dummy_gettextdomain(tls *TLS) (r uintptr) { + return __ccgo_ts + 414 +} + +func Xdcngettext(tls *TLS, domainname uintptr, msgid1 uintptr, msgid2 uintptr, n uint64, category int32) (r2 uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v msgid1=%v msgid2=%v n=%v category=%v, (%v:)", tls, domainname, msgid1, msgid2, n, category, origin(2)) + defer func() { trc("-> %v", r2) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var alt_modlen, catlen, dirlen, domlen, l, loclen, modlen, rem, v5 Tsize_t + var catname, csp, dirname, lm, loc, locname, locp, map1, modname, name, old, old_cats, p3, q, r1, rule, trans, v, v3, v8, v9 uintptr + var np, plural, v26 uint64 + var old_errno, r, v11, v12 int32 + var v6 t__predefined_size_t + var _ /* map_size at bp+0 */ Tsize_t + var _ /* z at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alt_modlen, catlen, catname, csp, dirlen, dirname, domlen, l, lm, loc, loclen, locname, locp, map1, modlen, modname, name, np, old, old_cats, old_errno, p3, plural, q, r, r1, rem, rule, trans, v, v11, v12, v26, v3, v5, v6, v8, v9 + defer func() { Xrealloc(tls, name, 0) }() + loc = (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale + old_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + /* match gnu gettext behaviour */ + if !(msgid1 != 0) { + goto notrans + } + if Uint32FromInt32(category) >= uint32(LC_ALL) { + goto notrans + } + if !(domainname != 0) { + domainname = X__gettextdomain(tls) + } + domlen = Xstrnlen(tls, domainname, Uint64FromInt32(Int32FromInt32(NAME_MAX)+Int32FromInt32(1))) + if domlen > uint64(NAME_MAX) { + goto notrans + } + q = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_bindings))) + for { + if !(q != 0) { + break + } + if !(Xstrcmp(tls, (*Tbinding)(unsafe.Pointer(q)).Fdomainname, domainname) != 0) && AtomicLoadPInt32(q+12) != 0 { + break + } + goto _1 + _1: + ; + q = (*Tbinding)(unsafe.Pointer(q)).Fnext + } + if !(q != 0) { + goto notrans + } + lm = **(**uintptr)(__ccgo_up(loc + uintptr(category)*8)) + if !!(lm != 0) { + goto _2 + } + goto notrans +notrans: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + if n == uint64(1) { + v3 = msgid1 + } else { + v3 = msgid2 + } + return v3 +_2: + ; + p3 = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_cats))) + for { + if !(p3 != 0) { + break + } + if (*Tmsgcat)(unsafe.Pointer(p3)).Fbinding == q && (*Tmsgcat)(unsafe.Pointer(p3)).Flm == lm && (*Tmsgcat)(unsafe.Pointer(p3)).Fcat == category { + break + } + goto _4 + _4: + ; + p3 = (*Tmsgcat)(unsafe.Pointer(p3)).Fnext + } + if !(p3 != 0) { + dirname = (*Tbinding)(unsafe.Pointer(q)).Fdirname + locname = lm + 16 + catname = uintptr(unsafe.Pointer(&_catnames)) + uintptr(category)*12 + dirlen = Uint64FromInt32((*Tbinding)(unsafe.Pointer(q)).Fdirlen) + loclen = _strlen(tls, locname) + catlen = uint64(_catlens[category]) + /* Logically split @mod suffix from locale name. */ + modname = Xmemchr(tls, locname, int32('@'), loclen) + if !(modname != 0) { + modname = locname + uintptr(loclen) + } + v5 = loclen - Uint64FromInt64(int64(modname)-int64(locname)) + modlen = v5 + alt_modlen = v5 + loclen = Uint64FromInt64(int64(modname) - int64(locname)) + /* Drop .charset identifier; it is not used. */ + csp = Xmemchr(tls, locname, int32('.'), loclen) + if csp != 0 { + loclen = Uint64FromInt64(int64(csp) - int64(locname)) + } + v6 = dirlen + uint64(1) + loclen + modlen + uint64(1) + catlen + uint64(1) + domlen + uint64(3) + uint64(1) + name = Xrealloc(tls, name, v6) + for { + Xsnprintf(tls, name, v6, __ccgo_ts+423, VaList(bp+24, dirname, Int32FromUint64(loclen), locname, Int32FromUint64(alt_modlen), modname, catname, domainname)) + v3 = X__map_file(tls, name, bp) + map1 = v3 + if v3 != 0 { + break + } + /* Try dropping @mod, _YY, then both. */ + if alt_modlen != 0 { + alt_modlen = uint64(0) + } else { + v3 = Xmemchr(tls, locname, int32('_'), loclen) + locp = v3 + if v3 != 0 { + loclen = Uint64FromInt64(int64(locp) - int64(locname)) + alt_modlen = modlen + } else { + break + } + } + goto _7 + _7: + } + if !(map1 != 0) { + goto notrans + } + p3 = Xcalloc(tls, uint64(64), uint64(1)) + if !(p3 != 0) { + X__munmap(tls, map1, **(**Tsize_t)(__ccgo_up(bp))) + goto notrans + } + (*Tmsgcat)(unsafe.Pointer(p3)).Fcat = category + (*Tmsgcat)(unsafe.Pointer(p3)).Fbinding = q + (*Tmsgcat)(unsafe.Pointer(p3)).Flm = lm + (*Tmsgcat)(unsafe.Pointer(p3)).Fmap1 = map1 + (*Tmsgcat)(unsafe.Pointer(p3)).Fmap_size = **(**Tsize_t)(__ccgo_up(bp)) + rule = __ccgo_ts + 445 + np = uint64(2) + r1 = X__mo_lookup(tls, (*Tmsgcat)(unsafe.Pointer(p3)).Fmap1, (*Tmsgcat)(unsafe.Pointer(p3)).Fmap_size, __ccgo_ts) + for r1 != 0 && Xstrncmp(tls, r1, __ccgo_ts+451, uint64(13)) != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = Xstrchr(tls, r1, int32('\n')) + if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { + v3 = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(1) + } else { + v3 = uintptr(0) + } + r1 = v3 + } + if r1 != 0 { + r1 = r1 + uintptr(13) + for { + v11 = Int32FromUint8(**(**uint8)(__ccgo_up(r1))) + v12 = BoolInt32(v11 == int32(' ') || Uint32FromInt32(v11)-uint32('\t') < uint32(5)) + goto _13 + _13: + if !(v12 != 0) { + break + } + r1 = r1 + 1 + } + if !(Xstrncmp(tls, r1, __ccgo_ts+465, uint64(9)) != 0) { + np = Xstrtoul(tls, r1+uintptr(9), bp+8, int32(10)) + r1 = **(**uintptr)(__ccgo_up(bp + 8)) + } + for **(**uint8)(__ccgo_up(r1)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(r1))) != int32(';') { + r1 = r1 + 1 + } + if **(**uint8)(__ccgo_up(r1)) != 0 { + r1 = r1 + 1 + for { + v11 = Int32FromUint8(**(**uint8)(__ccgo_up(r1))) + v12 = BoolInt32(v11 == int32(' ') || Uint32FromInt32(v11)-uint32('\t') < uint32(5)) + goto _16 + _16: + if !(v12 != 0) { + break + } + r1 = r1 + 1 + } + if !(Xstrncmp(tls, r1, __ccgo_ts+475, uint64(7)) != 0) { + rule = r1 + uintptr(7) + } + } + } + (*Tmsgcat)(unsafe.Pointer(p3)).Fnplurals = Int32FromUint64(np) + (*Tmsgcat)(unsafe.Pointer(p3)).Fplural_rule = rule + for { + old_cats = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_cats))) + (*Tmsgcat)(unsafe.Pointer(p3)).Fnext = old_cats + goto _25 + _25: + ; + v3 = uintptr(unsafe.Pointer(&_cats)) + for { + // __asm__ __volatile__ ("ldaxr %0, %1" : "=r"(v) : "Q"(*(void *volatile *)p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 41, __ccgo_ts+483) + v8 = v + goto _22 + _22: + old = v8 + if old != old_cats { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+483) + break + } + goto _20 + _20: + ; + // __asm__ __volatile__ ("stlxr %w0,%2,%1" : "=&r"(r), "=Q"(*(void *volatile *)p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 49, __ccgo_ts+483) + v11 = BoolInt32(!(r != 0)) + goto _19 + _19: + ; + if !!(v11 != 0) { + break + } + } + v9 = old + goto _24 + _24: + ; + if !(v9 != old_cats) { + break + } + } + } + trans = X__mo_lookup(tls, (*Tmsgcat)(unsafe.Pointer(p3)).Fmap1, (*Tmsgcat)(unsafe.Pointer(p3)).Fmap_size, msgid1) + if !(trans != 0) { + goto notrans + } + /* Non-plural-processing gettext forms pass a null pointer as + * msgid2 to request that dcngettext suppress plural processing. */ + if msgid2 != 0 && (*Tmsgcat)(unsafe.Pointer(p3)).Fnplurals != 0 { + plural = X__pleval(tls, (*Tmsgcat)(unsafe.Pointer(p3)).Fplural_rule, n) + if plural > Uint64FromInt32((*Tmsgcat)(unsafe.Pointer(p3)).Fnplurals) { + goto notrans + } + for { + v26 = plural + plural = plural - 1 + if !(v26 != 0) { + break + } + rem = (*Tmsgcat)(unsafe.Pointer(p3)).Fmap_size - Uint64FromInt64(int64(trans)-int64((*Tmsgcat)(unsafe.Pointer(p3)).Fmap1)) + l = Xstrnlen(tls, trans, rem) + if l+uint64(1) >= rem { + goto notrans + } + trans = trans + uintptr(l+uint64(1)) + } + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + return trans +} + +var _cats uintptr + +func Xdcgettext(tls *TLS, domainname uintptr, msgid uintptr, category int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v msgid=%v category=%v, (%v:)", tls, domainname, msgid, category, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdcngettext(tls, domainname, msgid, uintptr(0), uint64(1), category) +} + +func Xdngettext(tls *TLS, domainname uintptr, msgid1 uintptr, msgid2 uintptr, n uint64) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v msgid1=%v msgid2=%v n=%v, (%v:)", tls, domainname, msgid1, msgid2, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdcngettext(tls, domainname, msgid1, msgid2, n, int32(LC_MESSAGES)) +} + +func Xdgettext(tls *TLS, domainname uintptr, msgid uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v msgid=%v, (%v:)", tls, domainname, msgid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdcngettext(tls, domainname, msgid, uintptr(0), uint64(1), int32(LC_MESSAGES)) +} + +func X__duplocale(tls *TLS, old Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v old=%v, (%v:)", tls, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + var new1 Tlocale_t + _ = new1 + new1 = Xmalloc(tls, uint64(48)) + if !(new1 != 0) { + return uintptr(0) + } + if old == uintptr(-Int32FromInt32(1)) { + old = uintptr(unsafe.Pointer(&X__libc)) + 56 + } + **(**t__locale_struct)(__ccgo_up(new1)) = **(**t__locale_struct)(__ccgo_up(old)) + return new1 +} + +func Xduplocale(tls *TLS, old Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v old=%v, (%v:)", tls, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__duplocale(tls, old) +} + +func Xfreelocale(tls *TLS, l Tlocale_t) { + if __ccgo_strace { + trc("tls=%v l=%v, (%v:)", tls, l, origin(2)) + } + if X__loc_is_allocated(tls, l) != 0 { + Xfree(tls, l) + } +} + +func X__freelocale(tls *TLS, l Tlocale_t) { + if __ccgo_strace { + trc("tls=%v l=%v, (%v:)", tls, l, origin(2)) + } + Xfreelocale(tls, l) +} + +const BIG5 = 224 +const EUC_JP = 208 +const EUC_KR = 232 +const GB18030 = 216 +const GB2312 = 218 +const GBK = 217 +const ISO2022_JP = 210 +const SHIFT_JIS = 209 +const UCS2 = 204 +const UCS2BE = 196 +const UCS2LE = 197 +const US_ASCII = 199 +const UTF_16 = 202 +const UTF_16BE = 194 +const UTF_16LE = 193 +const UTF_32 = 203 +const UTF_32BE = 192 +const UTF_32LE = 195 +const UTF_8 = 200 +const WCHAR_T = 198 +const mbrtowc_utf8 = 0 +const wctomb_utf8 = 0 + +type Ticonv_t = uintptr + +/* Definitions of charmaps. Each charmap consists of: + * 1. Empty-string-terminated list of null-terminated aliases. + * 2. Special type code or number of elided quads of entries. + * 3. Character table (size determined by field 2), consisting + * of 5 bytes for every 4 characters, interpreted as 10-bit + * indices into the legacy_chars table. */ + +var _charmaps = [4907]uint8{'u', 't', 'f', '8', 0, 'c', 'h', 'a', 'r', 0, 0, 200, 'w', 'c', 'h', 'a', 'r', 't', 0, 0, 198, 'u', 'c', 's', '2', 'b', 'e', 0, 0, 196, 'u', 'c', 's', '2', 'l', 'e', 0, 0, 197, 'u', 't', 'f', '1', '6', 'b', 'e', 0, 0, 194, 'u', 't', 'f', '1', '6', 'l', 'e', 0, 0, 193, 'u', 'c', 's', '4', 'b', 'e', 0, 'u', 't', 'f', '3', '2', 'b', 'e', 0, 0, 192, 'u', 'c', 's', '4', 'l', 'e', 0, 'u', 't', 'f', '3', '2', 'l', 'e', 0, 0, 195, 'a', 's', 'c', 'i', 'i', 0, 'u', 's', 'a', 's', 'c', 'i', 'i', 0, 'i', 's', 'o', '6', '4', '6', 0, 'i', 's', 'o', '6', '4', '6', 'u', 's', 0, 0, 199, 'u', 't', 'f', '1', '6', 0, 0, 202, 'u', 'c', 's', '4', 0, 'u', 't', 'f', '3', '2', 0, 0, 203, 'u', 'c', 's', '2', 0, 0, 204, 'e', 'u', 'c', 'j', 'p', 0, 0, 208, 's', 'h', 'i', 'f', 't', 'j', 'i', 's', 0, 's', 'j', 'i', 's', 0, 'c', 'p', '9', '3', '2', 0, 0, 209, 'i', 's', 'o', '2', '0', '2', '2', 'j', 'p', 0, 0, 210, 'g', 'b', '1', '8', '0', '3', '0', 0, 0, 216, 'g', 'b', 'k', 0, 'c', 'p', '9', '3', '6', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '9', '3', '6', 0, 0, 217, 'g', 'b', '2', '3', '1', '2', 0, 0, 218, 'b', 'i', 'g', '5', 0, 'b', 'i', 'g', 'f', 'i', 'v', 'e', 0, 'c', 'p', '9', '5', '0', 0, 'b', 'i', 'g', '5', 'h', 'k', 's', 'c', 's', 0, 0, 224, 'e', 'u', 'c', 'k', 'r', 0, 'k', 's', 'c', '5', '6', '0', '1', 0, 'k', 's', 'x', '1', '0', '0', '1', 0, 'c', 'p', '9', '4', '9', 0, 0, 232, 'i', 's', 'o', '8', '8', '5', '9', '1', 0, 'l', 'a', 't', 'i', 'n', '1', 0, 0, '@', 'i', 's', 'o', '8', '8', '5', '9', '2', 0, 0, '(', 160, 16, 244, 'W', 'N', 164, 220, 244, 212, ')', 168, 'T', '5', 'U', 'V', 'n', 181, '"', 23, '\\', 176, 20, 20, 152, 'N', 180, 224, 4, 149, '_', 184, 'X', 'E', 149, 'V', 'o', 13, '6', 'W', '\\', 'I', 5, '#', 140, '@', 196, 204, 'd', 208, '1', 12, '%', 'c', 209, '2', 24, '5', 227, 140, 'C', 16, 237, 244, 211, '4', 212, 20, 'e', 205, '5', 'M', 141, 165, 'M', 'Y', 220, 't', 's', 213, '7', 'J', 133, '#', 206, '@', 228, 208, 't', 208, '9', 13, 165, 's', 209, ':', 25, 181, 227, 206, 'C', 17, 241, 4, 212, '<', 244, 24, 'e', 207, '=', 'N', 145, 165, 143, 'Y', 252, 244, 131, 21, '`', 'i', 's', 'o', '8', '8', '5', '9', '3', 0, 0, '(', 160, 144, 244, 215, '(', 164, 0, ' ', 210, ')', 168, 176, '4', 21, 'G', '.', 181, 2, 0, '\\', 176, 148, '$', 203, ',', 180, 212, '2', 210, '-', 184, 180, 'D', 'U', 'G', '/', 245, 2, '@', '\\', 192, 4, '#', 12, 0, 196, '(', 132, 208, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 0, 'D', '#', 205, '4', 212, 'x', 'd', 205, '5', 26, 'e', 163, 205, '6', 220, 132, 21, 213, '7', 224, 132, '#', 14, 0, 228, ',', 148, 208, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 0, 196, '#', 207, '<', 244, '|', 'd', 207, '=', 27, 229, 163, 207, '>', 252, 136, '%', 21, '`', 'i', 's', 'o', '8', '8', '5', '9', '4', 0, 0, '(', 160, 16, '$', 211, 'R', 164, 152, 'T', 211, ')', 168, 'T', '%', 17, 'H', '[', 181, '"', 215, '+', 176, 20, 20, 24, 'S', 180, 156, 'd', 147, '_', 184, 'X', '5', 'Q', 'H', '\\', 5, '5', 151, 'P', 0, 5, '#', 204, '0', 196, 20, 'c', 140, 'J', 12, '%', 'c', 209, '2', 20, '5', 227, 12, 'J', 16, 245, '4', 20, 'L', 212, 'T', 'c', 205, '5', 216, 156, 165, 205, '6', 220, 't', 245, 213, '7', 1, 133, '#', 206, '8', 228, 148, 'c', 206, 'J', 13, 165, 's', 209, ':', 21, 181, 227, 'N', 'J', 17, 249, 'D', 'T', 'L', 244, 212, 'c', 207, '=', 248, 160, 165, 207, '>', 252, 'x', 5, 22, '`', 'i', 's', 'o', '8', '8', '5', '9', '5', 0, 0, '(', 160, 'D', '\'', 221, 't', 212, 'U', 'g', 221, 'u', 216, 'e', 167, 221, 'v', 220, 181, 210, 157, 'w', 223, 129, 23, 158, 'x', 227, 145, 'W', 158, 'y', 231, 161, 151, 158, 'z', 235, 177, 215, 158, '{', 239, 193, 23, 159, '|', 243, 209, 'W', 159, '}', 247, 225, 151, 159, '~', 251, 241, 215, 159, 127, 255, 1, 24, 160, 128, 3, 18, 'X', 160, 129, 7, '"', 152, 160, 130, 11, '2', 216, 160, 131, 15, 'B', 24, 161, 132, 19, 'R', 'X', 161, 133, 23, 'b', 152, 161, 134, 27, 'r', 216, 161, 135, '&', 127, 8, 'b', 136, '"', 142, 'H', 'b', 137, '&', 158, 136, 'b', 138, '*', 158, 178, '"', 139, 'i', 's', 'o', '8', '8', '5', '9', '6', 0, 0, '(', 160, 0, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'b', 182, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 152, 0, 0, 0, 0, 153, 0, 148, 'i', 230, 153, 'h', 166, 169, 230, 154, 'l', 182, 233, 230, 155, 'p', 198, ')', 231, 156, 't', 214, 'i', 231, 157, 'x', 230, 169, 231, 158, '|', 246, 233, '\'', 0, 0, 0, 0, 0, 0, 127, 2, 26, 168, 160, 131, 18, 'Z', 168, 161, 135, '"', 154, 168, 162, 139, '2', 218, 168, 163, 143, 'B', 26, ')', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'i', 's', 'o', '8', '8', '5', '9', '7', 0, 0, '(', 160, 'L', 'L', 241, '(', '$', 151, 'l', 202, ')', 168, 164, 146, 216, '*', 172, 180, 2, '@', 196, 176, 196, '"', 203, ',', 138, '-', 198, 216, '-', 141, '9', 246, 216, '.', 144, 245, 18, 153, 'd', 147, 'Q', 'V', 153, 'e', 151, 'a', 150, 153, 'f', 155, 'q', 214, 153, 'g', 159, 129, 22, 154, 'h', 163, 145, 6, '@', 'i', 166, 157, 134, 'Z', 'j', 170, 173, 198, 'Z', 'k', 174, 189, 6, '[', 'l', 178, 205, 'F', '[', 'm', 182, 221, 134, '[', 'n', 186, 237, 198, '[', 'o', 190, 253, 6, '\\', 'p', 194, 13, 'G', '\\', 'q', 198, 29, 135, '\\', 'r', 202, '-', 199, '\\', 's', 206, '=', 7, 29, 0, 'i', 's', 'o', '8', '8', '5', '9', '8', 0, 0, '(', 160, 0, ' ', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 'r', 205, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 'r', 207, '.', 188, 244, 226, 11, 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, 128, 196, 'B', 14, 'I', 'd', 145, 'F', 30, 137, 'd', 146, 'J', '.', 201, 'd', 147, 'N', '>', 9, 'e', 148, 'R', 'N', 'I', 'e', 149, 'V', '^', 137, 'e', 150, 'Z', 'n', 201, '%', 0, 0, '4', 236, '0', 0, 'i', 's', 'o', '8', '8', '5', '9', '9', 0, 0, '4', 28, 'E', '#', 205, '4', 212, 'T', 'c', 205, '5', 216, 'd', 163, 205, '6', 220, 176, '4', 213, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 29, 197, '#', 207, '<', 244, 212, 'c', 207, '=', 248, 228, 163, 207, '>', 252, 180, 'D', 213, '?', 'i', 's', 'o', '8', '8', '5', '9', '1', '0', 0, 0, '(', 160, 16, '$', 17, 'H', '(', 153, 4, 211, ')', '5', 'A', 'T', 213, 'V', 'r', 181, 242, 'U', 'P', 176, 20, '4', 'Q', 'H', ')', 157, 20, 211, '-', '6', 'E', 'd', 21, 'W', 's', 'E', 12, 150, 'P', 0, 5, '#', 204, '0', 196, 20, 'c', 140, 'J', 12, '%', 'c', 209, '2', 20, '5', 227, 204, '3', 208, 244, '4', 212, '4', 212, 'T', 'c', 'M', 'W', 216, 156, 165, 205, '6', 220, 't', 227, 205, '7', 1, 133, '#', 206, '8', 228, 148, 'c', 206, 'J', 13, 165, 's', 209, ':', 21, 181, 227, 206, ';', 240, 248, 'D', 212, '<', 244, 212, 'c', 143, 'W', 248, 160, 165, 207, '>', 252, 244, 227, 143, 'L', 'i', 's', 'o', '8', '8', '5', '9', '1', '1', 0, 't', 'i', 's', '6', '2', '0', 0, 0, '(', 160, 'x', 250, ')', 168, 161, 138, ':', '*', 169, 165, 154, 'z', '*', 170, 169, 170, 186, '*', 171, 173, 186, 250, '*', 172, 177, 202, ':', '+', 173, 181, 218, 'z', '+', 174, 185, 234, 186, '+', 175, 189, 250, 250, '+', 176, 193, 10, ';', ',', 177, 197, 26, '{', ',', 178, 201, '*', 187, ',', 179, 205, ':', 251, ',', 180, 209, 'J', ';', '-', 181, 213, 'Z', '{', '-', 0, 0, 0, 0, 0, 182, 217, 'j', 187, '-', 183, 221, 'z', 251, '-', 184, 225, 138, ';', '.', 185, 229, 154, '{', '.', 186, 233, 170, 187, '.', 187, 237, 186, 251, '.', 188, 241, 202, ';', '/', 189, 0, 0, 0, 0, 0, 'i', 's', 'o', '8', '8', '5', '9', '1', '3', 0, 0, '(', 160, '\\', ',', 202, '(', 164, '`', 'l', 202, ')', 216, 164, 178, 212, '*', 172, 180, 226, 138, '1', 176, 196, '"', 203, ',', 22, 215, 'b', 203, '-', 248, 228, 194, 212, '.', 188, 244, 226, 139, '9', 4, 169, 4, 144, 'A', 196, 20, 'c', 145, 'D', 12, '%', 227, 22, 'E', ' ', 193, 132, 'R', 'M', 'U', 237, 212, 211, '4', 'C', 'U', 'c', 205, '5', 'g', 229, 244, 212, 'W', 220, 192, '%', 215, '7', 5, 173, 20, 208, 'A', 228, 148, 's', 209, 'D', 13, 165, 243, 'V', 'E', '!', 197, 148, 146, 'M', 'V', 241, 228, 211, '<', 'D', 213, 'c', 207, '=', 'h', 233, 4, 21, 'X', 252, 196, '5', 23, 197, 'i', 's', 'o', '8', '8', '5', '9', '1', '4', 0, 0, '(', 160, 212, 'k', 239, '(', 10, '-', 't', 239, ')', 3, 167, 'R', '0', 190, 9, 183, 226, 'J', '[', 249, 234, 235, 209, 'G', 251, 242, 'k', 'K', 191, 4, 251, 'k', 240, 191, 10, 31, 140, '0', 192, 192, 4, '#', 204, '0', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 'i', 'E', '#', 205, '4', 212, 'T', 'c', 'M', 192, 216, 'd', 163, 205, '6', 220, 't', 179, 214, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 'j', 197, '#', 207, '<', 244, 212, 'c', 143, 192, 248, 228, 163, 207, '>', 252, 244, 195, 214, '?', 'i', 's', 'o', '8', '8', '5', '9', '1', '5', 0, 'l', 'a', 't', 'i', 'n', '9', 0, 0, ')', '$', 151, 'R', 213, ')', 'V', 165, 162, 202, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 'r', 213, 'b', 203, '-', 's', 229, 162, 203, '.', 'G', '!', 213, 214, '/', 192, 4, '#', 204, '0', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 208, 'D', '#', 205, '4', 212, 'T', 'c', 205, '5', 216, 'd', 163, 205, '6', 220, 't', 227, 205, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 240, 196, '#', 207, '<', 244, 212, 'c', 207, '=', 248, 228, 163, 207, '>', 252, 244, 227, 207, '?', 'i', 's', 'o', '8', '8', '5', '9', '1', '6', 0, 0, '(', 160, 16, 'T', 'P', 'N', '$', 'c', '\\', 213, ')', 'V', 165, 146, 215, '*', 'n', 181, 242, 22, '\\', 176, 196, 194, 144, 'N', 'r', ']', 'l', 203, '-', 's', '5', 164, 215, '.', 'G', '!', 213, 'V', '\\', 192, 4, '#', 140, '@', 196, 24, 'd', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 16, 237, '$', 205, '4', 212, 20, 'e', 205, 'S', 'e', 'e', 163, 205, '6', 220, 'X', 180, 215, '7', 224, 132, '#', 206, '@', 228, 28, 'd', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 17, 241, '$', 207, '<', 244, 24, 'e', 15, 'T', 'f', 229, 163, 207, '>', 252, '\\', 196, 215, '?', 'c', 'p', '1', '2', '5', '0', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '0', 0, 0, ' ', '$', 3, 'P', '1', 0, 24, 's', 156, 177, 198, 0, 't', '\\', 149, 199, 'O', 'e', '%', 151, '[', 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 0, 156, 'l', 213, 199, 'P', 'i', '5', 215, '[', 160, 248, 245, 'W', 'N', 164, 16, 'd', 202, ')', 168, 164, '2', 213, '*', 172, 180, 226, 10, '\\', 176, 196, 18, 152, 'N', 180, 212, 'b', 203, '-', 184, 20, 'D', 213, '.', '7', 13, 134, 'S', '\\', 'I', 5, '#', 140, '@', 196, 204, 'd', 208, '1', 12, '%', 'c', 209, '2', 24, '5', 227, 140, 'C', 16, 237, 244, 211, '4', 212, 20, 'e', 205, '5', 'M', 141, 165, 'M', 'Y', 220, 't', 's', 213, '7', 'J', 133, '#', 206, '@', 228, 208, 't', 208, '9', 13, 165, 's', 209, ':', 25, 181, 227, 206, 'C', 17, 241, 4, 212, '<', 244, 24, 'e', 207, '=', 'N', 145, 165, 143, 'Y', 252, 244, 131, 21, '`', 'c', 'p', '1', '2', '5', '1', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '1', 0, 0, ' ', 210, 'M', 'W', 'q', 136, 24, 's', 156, 177, 198, '$', 'w', 156, 157, 199, 218, 'q', 183, 157, 'w', ' ', 'N', 'L', 177, 197, 23, 'o', 252, '0', 196, 0, 156, '|', 226, 199, '(', 170, 152, '"', 139, 160, 't', 183, '"', 'v', 164, 180, 'h', 202, ')', 209, 165, 'B', 221, '*', 172, 180, 226, 202, 'u', 176, 196, 'b', 29, 137, '.', 214, 'b', 203, '-', 31, 154, ',', 226, '.', '&', 'V', '7', 'b', 137, 223, 129, 23, 158, 'x', 227, 145, 'W', 158, 'y', 231, 161, 151, 158, 'z', 235, 177, 215, 158, '{', 239, 193, 23, 159, '|', 243, 209, 'W', 159, '}', 247, 225, 151, 159, '~', 251, 241, 215, 159, 127, 255, 1, 24, 160, 128, 3, 18, 'X', 160, 129, 7, '"', 152, 160, 130, 11, '2', 216, 160, 131, 15, 'B', 24, 161, 132, 19, 'R', 'X', 161, 133, 23, 'b', 152, 161, 134, 27, 'r', 216, 161, 135, 'c', 'p', '1', '2', '5', '2', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '2', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, '}', 'u', '\\', 149, 199, 'G', 1, ' ', 23, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 130, 157, 'l', 213, 199, 'H', 1, '0', 'W', '[', 160, 132, '"', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 162, 202, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 162, 203, '.', 188, 244, 226, 203, '/', 192, 4, '#', 204, '0', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 208, 'D', '#', 205, '4', 212, 'T', 'c', 205, '5', 216, 'd', 163, 205, '6', 220, 't', 227, 205, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 240, 196, '#', 207, '<', 244, 212, 'c', 207, '=', 248, 228, 163, 207, '>', 252, 244, 227, 207, '?', 'c', 'p', '1', '2', '5', '3', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '3', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, 0, 't', 12, 128, 199, 0, 0, 0, 0, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 0, 156, 12, 192, 199, 0, 0, 0, 0, 0, 160, ',', 198, 216, '(', 164, 148, 'b', 202, ')', 168, 164, 2, 192, '*', 172, 180, 226, 'J', 196, 176, 196, '"', 203, ',', 138, 213, 'b', 203, '-', 141, '9', 246, 216, '.', 144, 245, 18, 153, 'd', 147, 'Q', 'V', 153, 'e', 151, 'a', 150, 153, 'f', 155, 'q', 214, 153, 'g', 159, 129, 22, 154, 'h', 163, 145, 6, '@', 'i', 166, 157, 134, 'Z', 'j', 170, 173, 198, 'Z', 'k', 174, 189, 6, '[', 'l', 178, 205, 'F', '[', 'm', 182, 221, 134, '[', 'n', 186, 237, 198, '[', 'o', 190, 253, 6, '\\', 'p', 194, 13, 'G', '\\', 'q', 198, 29, 135, '\\', 'r', 202, '-', 199, '\\', 's', 206, '=', 7, 29, 0, 'c', 'p', '1', '2', '5', '4', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '4', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, '}', 'u', '\\', 149, 199, 'G', 1, 0, 0, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 130, 157, 'l', 213, 199, 'H', 1, 0, '@', '[', 160, 132, '"', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 162, 202, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 162, 203, '.', 188, 244, 226, 203, '/', 192, 4, '#', 204, '0', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 204, '4', 227, 204, '3', 28, 'E', '#', 205, '4', 212, 'T', 'c', 205, '5', 216, 'd', 163, 205, '6', 220, 176, '4', 213, '7', 224, 132, '#', 206, '8', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 236, 180, 227, 206, ';', 29, 197, '#', 207, '<', 244, 212, 'c', 207, '=', 248, 228, 163, 207, '>', 252, 180, 'D', 213, '?', 'c', 'p', '1', '2', '5', '5', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '5', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, '}', 'u', 12, 128, 199, 0, 0, 0, 0, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 130, 157, 12, 192, 199, 0, 0, 0, 0, 0, 160, 132, '"', 202, '(', '"', 151, 'b', 202, ')', 168, 164, 'r', 205, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 'r', 207, '.', 188, 244, 226, 203, '/', '/', 194, 24, 163, 140, '3', 210, 'X', 163, 141, '7', 226, 8, '@', 142, ':', 238, 200, 'c', 143, '>', 254, 8, 'd', 144, ']', 'z', 249, '%', 152, 'a', 2, 0, 0, 0, 0, 0, 0, 0, 0, 'B', 14, 'I', 'd', 145, 'F', 30, 137, 'd', 146, 'J', '.', 201, 'd', 147, 'N', '>', 9, 'e', 148, 'R', 'N', 'I', 'e', 149, 'V', '^', 137, 'e', 150, 'Z', 'n', 201, '%', 0, 0, '4', 236, '0', 0, 'c', 'p', '1', '2', '5', '6', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '6', 0, 0, ' ', '$', 'O', 'Z', '1', ']', 24, 's', 156, 177, 198, '}', 'u', ',', 169, 199, 'G', 'Q', 'z', 'i', 165, 153, 'N', 'L', 177, 197, 23, 'o', 252, '0', 196, 152, 158, 'l', 233, 199, 'H', '-', 204, 176, 166, 160, 136, ')', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 178, 233, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, '2', 230, '.', 188, 244, 226, 11, 153, 156, 150, 'i', 230, 153, 'h', 166, 169, 230, 154, 'l', 182, 233, 230, 155, 'p', 198, ')', 231, 156, 't', 214, 'i', 231, 157, 'x', 230, 169, 231, '5', '{', 242, 217, 167, 159, 127, 2, 26, 168, 160, 224, 12, '*', 14, 161, 133, 26, 'z', 232, '9', 232, 164, 163, 206, ':', 136, '&', 234, 206, ';', 138, '.', 202, 'h', 163, 244, '8', 250, 232, '=', 144, 230, 19, 233, '>', 252, '4', 236, 'p', 167, 'c', 'p', '1', '2', '5', '7', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '7', 0, 0, ' ', '$', 3, 'P', '1', 0, 24, 's', 156, 177, 198, 0, 't', 12, 128, 199, 0, 160, 226, 23, '.', 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 0, 156, 12, 192, 199, 0, 188, 18, 24, 0, 160, 0, ' ', 202, '(', 164, 0, '`', 202, ')', 216, 164, 178, 212, '*', 172, 180, 226, 138, '1', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 248, 228, 194, 212, '.', 188, 244, 226, 139, '9', 4, 169, 4, 144, 'A', 196, 20, 'c', 145, 'D', 12, '%', 227, 22, 'E', ' ', 193, 132, 'R', 'M', 'U', 237, 212, 211, '4', 'C', 'U', 'c', 205, '5', 'g', 229, 244, 212, 'W', 220, 192, '%', 215, '7', 5, 173, 20, 208, 'A', 228, 148, 's', 209, 'D', 13, 165, 243, 'V', 'E', '!', 197, 148, 146, 'M', 'V', 241, 228, 211, '<', 'D', 213, 'c', 207, '=', 'h', 233, 4, 21, 'X', 252, 196, '5', 23, '`', 'c', 'p', '1', '2', '5', '8', 0, 'w', 'i', 'n', 'd', 'o', 'w', 's', '1', '2', '5', '8', 0, 0, ' ', '$', 3, 'P', '1', ']', 24, 's', 156, 177, 198, '}', 'u', 12, 128, 199, 'G', 1, 0, 0, 0, 0, 'L', 'L', 177, 197, 23, 'o', 252, '0', 196, 130, 157, 12, 192, 199, 'H', 1, 0, '@', '[', 160, 132, '"', 202, '(', 164, 148, 'b', 202, ')', 168, 164, 162, 202, '*', 172, 180, 226, 202, '+', 176, 196, '"', 203, ',', 180, 212, 'b', 203, '-', 184, 228, 162, 203, '.', 188, 244, 226, 203, '/', 192, 4, '#', 140, '@', 196, 20, 'c', 204, '1', 200, '$', 163, 204, '2', 132, '5', 227, 204, '3', 16, 'E', 's', 216, '4', 212, 212, 'e', 205, '5', 216, 'd', 163, 205, '6', 220, 220, 'e', 216, '7', 224, 132, '#', 206, '@', 228, 148, 'c', 206, '9', 232, 164, 163, 206, ':', 133, 181, 227, 206, ';', 17, 197, 131, 216, '<', 244, 216, 'e', 207, '=', 248, 228, 163, 207, '>', 252, 224, '5', 242, '?', 'k', 'o', 'i', '8', 'r', 0, 0, ' ', '3', 211, '\\', 179, 205, '7', 227, 156, 179, 206, ';', 243, 220, 243, 214, '\\', 'w', 237, 245, 215, '`', 135, '-', 'v', 204, 'c', 163, 156, '2', 203, '.', 191, 12, 138, 204, 176, 200, 'r', 203, '=', '>', 255, 12, 244, 135, 'A', 11, '=', '4', 209, 'E', 27, '}', '4', 210, 'I', '+', 189, '4', 211, 'M', ';', 253, 't', 't', 'P', 'G', '-', 245, 212, 'T', 'W', 'm', 245, 213, 'X', 'g', 173, 'u', '*', 29, 254, 7, '`', 133, 3, 18, '8', 161, 128, 20, 30, 136, '`', 130, 10, '.', 200, '`', 131, 14, 'z', 248, ' ', 132, 17, 'J', 'X', '`', 128, 27, 'j', 'h', 224, 133, 28, 'b', 'h', 'a', 134, 253, '}', 7, '^', '}', 227, 145, '7', 159, 'x', 244, 157, 135, '^', 'z', 234, 173, 199, '^', '{', 238, 249, 247, 30, '|', 241, 201, 'W', '^', 'x', 251, 233, 'g', 222, '}', 252, 225, 'g', '_', '~', 'k', 'o', 'i', '8', 'u', 0, 0, ' ', '3', 211, '\\', 179, 205, '7', 227, 156, 179, 206, ';', 243, 220, 243, 214, '\\', 'w', 237, 245, 215, '`', 135, '-', 'v', 204, 'c', 163, 156, '2', 203, '.', 191, 12, 138, 204, 176, 200, 'r', 203, '=', '>', 255, 12, 244, 135, '"', 10, 'M', 'b', 137, 'E', 27, '}', '4', 210, 'I', 187, 184, '4', 211, 'M', ';', 253, 't', 't', 212, 'E', 'm', 221, 'u', 'T', 'W', 'm', 245, 213, 'X', 183, 168, 'u', '*', 29, 254, 7, '`', 133, 3, 18, '8', 161, 128, 20, 30, 136, '`', 130, 10, '.', 200, '`', 131, 14, 'z', 248, ' ', 132, 17, 'J', 'X', '`', 128, 27, 'j', 'h', 224, 133, 28, 'b', 'h', 'a', 134, 253, '}', 7, '^', '}', 227, 145, '7', 159, 'x', 244, 157, 135, '^', 'z', 234, 173, 199, '^', '{', 238, 249, 247, 30, '|', 241, 201, 'W', '^', 'x', 251, 233, 'g', 222, '}', 252, 225, 'g', '_', '~', 'c', 'p', '4', '3', '7', 0, 0, ' ', 199, 240, 147, 142, '8', 228, 128, 'S', 206, '9', 234, 172, 131, 206, ';', 238, 176, 'C', 'L', '1', 201, 152, 'c', 12, '=', 246, 200, 179, 'O', '>', 255, 'X', 195, 141, '(', 163, 148, 18, '2', ']', 225, 180, '3', 143, '>', 241, 'D', 163, 138, '.', 191, 192, 204, 'J', '/', 188, 132, 178, 202, '.', '`', 135, '-', '6', 205, ':', '?', 13, '5', 209, 'C', 'G', 253, 's', 209, 'K', '+', 157, 180, 205, '7', 243, 188, 's', 206, '3', 247, 204, 't', 211, 'H', 11, '}', '5', 213, 'N', 251, 172, 'u', 213, 'V', 'K', '=', 245, 209, 'F', 3, 29, 't', 214, 'X', 227, '\\', 's', 215, '\\', '{', 253, 245, 214, 179, '}', 'c', 153, 'p', 165, 21, 'W', 139, 'q', 168, 'm', 182, 154, 'm', '*', '#', 'w', 219, 202, '-', 199, 242, 178, 203, '1', 203, '|', 15, 203, 176, 160, '|', 'K', 202, ' ', 203, '2', '6', '(', 'c', 'p', '8', '5', '0', 0, 0, ' ', 199, 240, 147, 142, '8', 228, 128, 'S', 206, '9', 234, 172, 131, 206, ';', 238, 176, 'C', 'L', '1', 201, 152, 'c', 12, '=', 246, 200, 179, 'O', '>', 255, 'X', 195, 13, '>', 163, '`', 's', 13, ']', 225, 180, '3', 143, '>', 241, 'D', 163, 138, '.', 191, 184, 194, 'J', '/', 188, 132, 178, 202, '.', '`', 135, '-', '6', 205, ':', 7, '#', 12, '0', 169, 'D', 253, 's', 209, 'K', 139, 'R', 138, 205, '7', 243, 188, 's', 206, '3', 247, '<', 206, '0', 'H', 11, '}', '5', 213, 'N', 251, 172, '5', ')', 240, '@', 163, 204, '2', 200, 180, 212, 140, '3', 207, 224, '\\', 's', 215, '\\', 155, 194, 204, 214, 211, '|', 'C', 141, '4', 245, 'T', 'S', 139, '?', 222, 'h', 179, 'M', '6', 253, 't', 243, 10, '-', 173, 196, '"', 177, '/', 182, 156, 'r', 15, '.', 176, 160, 'r', 'K', '.', 179, 200, '2', '6', '(', 'c', 'p', '8', '6', '6', 0, 0, ' ', 223, 129, 23, 158, 'x', 227, 145, 'W', 158, 'y', 231, 161, 151, 158, 'z', 235, 177, 215, 158, '{', 239, 193, 23, 159, '|', 243, 209, 'W', 159, '}', 247, 225, 151, 159, '~', 251, 241, 215, 159, 127, 255, 1, 24, 160, 128, 3, 18, 'X', 160, 129, 7, '"', 152, 160, 130, 11, '2', 216, 160, 131, '`', 135, '-', '6', 205, ':', '?', 13, '5', 209, 'C', 'G', 253, 's', 209, 'K', '+', 157, 180, 205, '7', 243, 188, 's', 206, '3', 247, 204, 't', 211, 'H', 11, '}', '5', 213, 'N', 251, 172, 'u', 213, 'V', 'K', '=', 245, 209, 'F', 3, 29, 't', 214, 'X', 227, '\\', 's', 215, '\\', '{', 253, 245, 214, 15, 'B', 24, 161, 132, 19, 'R', 'X', 161, 133, 23, 'b', 152, 161, 134, 27, 'r', 216, 161, 135, 209, '}', 'H', 157, 136, 215, 149, 216, 221, 138, 176, 160, '|', 'K', 202, '&', 147, '2', '6', '(', 'i', 'b', 'm', '1', '0', '4', '7', 0, 'c', 'p', '1', '0', '4', '7', 0, 0, 1, 156, '$', '`', 200, 31, 151, '4', 226, 200, 2, 12, '4', 224, 192, 3, 16, 'D', ' ', 193, 4, 157, 20, 130, 192, '!', 24, 'd', ' ', 201, '#', 28, 't', 224, 193, 7, 128, 4, '"', 200, ' ', 132, '(', 'p', 193, 6, 136, '$', 162, 200, '"', 140, 20, '`', 192, 1, 144, 'D', 'b', 193, '$', 148, 'T', 'b', 9, 1, 152, 'd', 162, 201, '&', 20, 'T', 224, 137, 6, ' ', 128, '"', 14, '9', 224, 132, '3', 'N', '9', 231, 196, '#', 138, 11, '<', 160, 176, 2, 31, '&', 164, 163, 206, ':', 232, 180, 227, 206, ';', 236, '|', 19, 2, 9, '*', 164, 176, 131, 23, '-', 188, ' ', 12, '1', 192, 4, '3', 'L', '1', 199, 'D', 'c', 10, 11, '%', '|', 225, 195, 15, 248, '$', 163, 204, '2', 200, '4', 227, 204, '3', 204, 128, 161, 195, 8, '@', 156, 208, 131, 8, 216, 132, '!', 198, 24, 'd', 148, 'a', 198, 25, 'h', 164, 177, 202, '.', 240, 244, 227, 'O', ',', 176, 168, 177, 6, 27, 'm', 184, 241, 6, 28, 'q', 200, 161, 138, '.', 230, 224, 'b', 12, ')', 181, 248, '1', 7, 29, 'u', 216, 'q', 7, 30, 'y', 232, 17, 202, '/', 208, 'l', 225, 141, '+', 172, 140, 'R', 202, '-', 169, 156, 'b', 11, '/', 189, 248, 210, 13, '*', 175, 't', 'A', 203, '5', '{', 4, '!', 196, 16, 'D', 20, 'a', 196, 17, 'H', '$', 209, 10, '=', 246, 200, '3', 'O', '=', '}', '(', 177, 4, 19, 'M', '8', 241, 4, 20, 'Q', 'H', 145, 203, '>', 252, 228, 163, 207, '?', '\\', 220, '3', 5, 21, 'U', 'X', 'q', 5, 22, 'Y', 'h', '!', 11, '5', 214, 'H', '3', 'M', '5', '0', 196, ' ', 195, 12, '4', 212, '`', 195, 13, '8', 228, '0', 203, '6', 220, 'd', 163, 205, '\''} + +// C documentation +// +// /* Table of characters that appear in legacy 8-bit codepages, +// * limited to 1024 slots (10 bit indices). The first 256 entries +// * are elided since those characters are obviously all included. */ +var _legacy_chars = [612]uint16{ + 0: uint16(256), + 1: uint16(257), + 2: uint16(258), + 3: uint16(259), + 4: uint16(260), + 5: uint16(261), + 6: uint16(262), + 7: uint16(263), + 8: uint16(264), + 9: uint16(265), + 10: uint16(266), + 11: uint16(267), + 12: uint16(268), + 13: uint16(269), + 14: uint16(270), + 15: uint16(271), + 16: uint16(272), + 17: uint16(273), + 18: uint16(274), + 19: uint16(275), + 20: uint16(278), + 21: uint16(279), + 22: uint16(280), + 23: uint16(281), + 24: uint16(282), + 25: uint16(283), + 26: uint16(284), + 27: uint16(285), + 28: uint16(286), + 29: uint16(287), + 30: uint16(288), + 31: uint16(289), + 32: uint16(290), + 33: uint16(291), + 34: uint16(292), + 35: uint16(293), + 36: uint16(294), + 37: uint16(295), + 38: uint16(296), + 39: uint16(297), + 40: uint16(298), + 41: uint16(299), + 42: uint16(302), + 43: uint16(303), + 44: uint16(304), + 45: uint16(305), + 46: uint16(308), + 47: uint16(309), + 48: uint16(310), + 49: uint16(311), + 50: uint16(312), + 51: uint16(313), + 52: uint16(314), + 53: uint16(315), + 54: uint16(316), + 55: uint16(317), + 56: uint16(318), + 57: uint16(321), + 58: uint16(322), + 59: uint16(323), + 60: uint16(324), + 61: uint16(325), + 62: uint16(326), + 63: uint16(327), + 64: uint16(328), + 65: uint16(330), + 66: uint16(331), + 67: uint16(332), + 68: uint16(333), + 69: uint16(336), + 70: uint16(337), + 71: uint16(338), + 72: uint16(339), + 73: uint16(340), + 74: uint16(341), + 75: uint16(342), + 76: uint16(343), + 77: uint16(344), + 78: uint16(345), + 79: uint16(346), + 80: uint16(347), + 81: uint16(348), + 82: uint16(349), + 83: uint16(350), + 84: uint16(351), + 85: uint16(352), + 86: uint16(353), + 87: uint16(354), + 88: uint16(355), + 89: uint16(356), + 90: uint16(357), + 91: uint16(358), + 92: uint16(359), + 93: uint16(360), + 94: uint16(361), + 95: uint16(362), + 96: uint16(363), + 97: uint16(364), + 98: uint16(365), + 99: uint16(366), + 100: uint16(367), + 101: uint16(368), + 102: uint16(369), + 103: uint16(370), + 104: uint16(371), + 105: uint16(372), + 106: uint16(373), + 107: uint16(374), + 108: uint16(375), + 109: uint16(376), + 110: uint16(377), + 111: uint16(378), + 112: uint16(379), + 113: uint16(380), + 114: uint16(381), + 115: uint16(382), + 116: uint16(402), + 117: uint16(416), + 118: uint16(417), + 119: uint16(431), + 120: uint16(432), + 121: uint16(536), + 122: uint16(537), + 123: uint16(538), + 124: uint16(539), + 125: uint16(710), + 126: uint16(711), + 127: uint16(728), + 128: uint16(729), + 129: uint16(731), + 130: uint16(732), + 131: uint16(733), + 132: uint16(768), + 133: uint16(769), + 134: uint16(771), + 135: uint16(777), + 136: uint16(803), + 137: uint16(890), + 138: uint16(900), + 139: uint16(901), + 140: uint16(902), + 141: uint16(904), + 142: uint16(905), + 143: uint16(906), + 144: uint16(908), + 145: uint16(910), + 146: uint16(911), + 147: uint16(912), + 148: uint16(913), + 149: uint16(914), + 150: uint16(915), + 151: uint16(916), + 152: uint16(917), + 153: uint16(918), + 154: uint16(919), + 155: uint16(920), + 156: uint16(921), + 157: uint16(922), + 158: uint16(923), + 159: uint16(924), + 160: uint16(925), + 161: uint16(926), + 162: uint16(927), + 163: uint16(928), + 164: uint16(929), + 165: uint16(931), + 166: uint16(932), + 167: uint16(933), + 168: uint16(934), + 169: uint16(935), + 170: uint16(936), + 171: uint16(937), + 172: uint16(938), + 173: uint16(939), + 174: uint16(940), + 175: uint16(941), + 176: uint16(942), + 177: uint16(943), + 178: uint16(944), + 179: uint16(945), + 180: uint16(946), + 181: uint16(947), + 182: uint16(948), + 183: uint16(949), + 184: uint16(950), + 185: uint16(951), + 186: uint16(952), + 187: uint16(953), + 188: uint16(954), + 189: uint16(955), + 190: uint16(956), + 191: uint16(957), + 192: uint16(958), + 193: uint16(959), + 194: uint16(960), + 195: uint16(961), + 196: uint16(962), + 197: uint16(963), + 198: uint16(964), + 199: uint16(965), + 200: uint16(966), + 201: uint16(967), + 202: uint16(968), + 203: uint16(969), + 204: uint16(970), + 205: uint16(971), + 206: uint16(972), + 207: uint16(973), + 208: uint16(974), + 209: uint16(1025), + 210: uint16(1026), + 211: uint16(1027), + 212: uint16(1028), + 213: uint16(1029), + 214: uint16(1030), + 215: uint16(1031), + 216: uint16(1032), + 217: uint16(1033), + 218: uint16(1034), + 219: uint16(1035), + 220: uint16(1036), + 221: uint16(1038), + 222: uint16(1039), + 223: uint16(1040), + 224: uint16(1041), + 225: uint16(1042), + 226: uint16(1043), + 227: uint16(1044), + 228: uint16(1045), + 229: uint16(1046), + 230: uint16(1047), + 231: uint16(1048), + 232: uint16(1049), + 233: uint16(1050), + 234: uint16(1051), + 235: uint16(1052), + 236: uint16(1053), + 237: uint16(1054), + 238: uint16(1055), + 239: uint16(1056), + 240: uint16(1057), + 241: uint16(1058), + 242: uint16(1059), + 243: uint16(1060), + 244: uint16(1061), + 245: uint16(1062), + 246: uint16(1063), + 247: uint16(1064), + 248: uint16(1065), + 249: uint16(1066), + 250: uint16(1067), + 251: uint16(1068), + 252: uint16(1069), + 253: uint16(1070), + 254: uint16(1071), + 255: uint16(1072), + 256: uint16(1073), + 257: uint16(1074), + 258: uint16(1075), + 259: uint16(1076), + 260: uint16(1077), + 261: uint16(1078), + 262: uint16(1079), + 263: uint16(1080), + 264: uint16(1081), + 265: uint16(1082), + 266: uint16(1083), + 267: uint16(1084), + 268: uint16(1085), + 269: uint16(1086), + 270: uint16(1087), + 271: uint16(1088), + 272: uint16(1089), + 273: uint16(1090), + 274: uint16(1091), + 275: uint16(1092), + 276: uint16(1093), + 277: uint16(1094), + 278: uint16(1095), + 279: uint16(1096), + 280: uint16(1097), + 281: uint16(1098), + 282: uint16(1099), + 283: uint16(1100), + 284: uint16(1101), + 285: uint16(1102), + 286: uint16(1103), + 287: uint16(1105), + 288: uint16(1106), + 289: uint16(1107), + 290: uint16(1108), + 291: uint16(1109), + 292: uint16(1110), + 293: uint16(1111), + 294: uint16(1112), + 295: uint16(1113), + 296: uint16(1114), + 297: uint16(1115), + 298: uint16(1116), + 299: uint16(1118), + 300: uint16(1119), + 301: uint16(1168), + 302: uint16(1169), + 303: uint16(1456), + 304: uint16(1457), + 305: uint16(1458), + 306: uint16(1459), + 307: uint16(1460), + 308: uint16(1461), + 309: uint16(1462), + 310: uint16(1463), + 311: uint16(1464), + 312: uint16(1465), + 313: uint16(1467), + 314: uint16(1468), + 315: uint16(1469), + 316: uint16(1470), + 317: uint16(1471), + 318: uint16(1472), + 319: uint16(1473), + 320: uint16(1474), + 321: uint16(1475), + 322: uint16(1488), + 323: uint16(1489), + 324: uint16(1490), + 325: uint16(1491), + 326: uint16(1492), + 327: uint16(1493), + 328: uint16(1494), + 329: uint16(1495), + 330: uint16(1496), + 331: uint16(1497), + 332: uint16(1498), + 333: uint16(1499), + 334: uint16(1500), + 335: uint16(1501), + 336: uint16(1502), + 337: uint16(1503), + 338: uint16(1504), + 339: uint16(1505), + 340: uint16(1506), + 341: uint16(1507), + 342: uint16(1508), + 343: uint16(1509), + 344: uint16(1510), + 345: uint16(1511), + 346: uint16(1512), + 347: uint16(1513), + 348: uint16(1514), + 349: uint16(1520), + 350: uint16(1521), + 351: uint16(1522), + 352: uint16(1523), + 353: uint16(1524), + 354: uint16(1548), + 355: uint16(1563), + 356: uint16(1567), + 357: uint16(1569), + 358: uint16(1570), + 359: uint16(1571), + 360: uint16(1572), + 361: uint16(1573), + 362: uint16(1574), + 363: uint16(1575), + 364: uint16(1576), + 365: uint16(1577), + 366: uint16(1578), + 367: uint16(1579), + 368: uint16(1580), + 369: uint16(1581), + 370: uint16(1582), + 371: uint16(1583), + 372: uint16(1584), + 373: uint16(1585), + 374: uint16(1586), + 375: uint16(1587), + 376: uint16(1588), + 377: uint16(1589), + 378: uint16(1590), + 379: uint16(1591), + 380: uint16(1592), + 381: uint16(1593), + 382: uint16(1594), + 383: uint16(1600), + 384: uint16(1601), + 385: uint16(1602), + 386: uint16(1603), + 387: uint16(1604), + 388: uint16(1605), + 389: uint16(1606), + 390: uint16(1607), + 391: uint16(1608), + 392: uint16(1609), + 393: uint16(1610), + 394: uint16(1611), + 395: uint16(1612), + 396: uint16(1613), + 397: uint16(1614), + 398: uint16(1615), + 399: uint16(1616), + 400: uint16(1617), + 401: uint16(1618), + 402: uint16(1657), + 403: uint16(1662), + 404: uint16(1670), + 405: uint16(1672), + 406: uint16(1681), + 407: uint16(1688), + 408: uint16(1705), + 409: uint16(1711), + 410: uint16(1722), + 411: uint16(1726), + 412: uint16(1729), + 413: uint16(1746), + 414: uint16(3585), + 415: uint16(3586), + 416: uint16(3587), + 417: uint16(3588), + 418: uint16(3589), + 419: uint16(3590), + 420: uint16(3591), + 421: uint16(3592), + 422: uint16(3593), + 423: uint16(3594), + 424: uint16(3595), + 425: uint16(3596), + 426: uint16(3597), + 427: uint16(3598), + 428: uint16(3599), + 429: uint16(3600), + 430: uint16(3601), + 431: uint16(3602), + 432: uint16(3603), + 433: uint16(3604), + 434: uint16(3605), + 435: uint16(3606), + 436: uint16(3607), + 437: uint16(3608), + 438: uint16(3609), + 439: uint16(3610), + 440: uint16(3611), + 441: uint16(3612), + 442: uint16(3613), + 443: uint16(3614), + 444: uint16(3615), + 445: uint16(3616), + 446: uint16(3617), + 447: uint16(3618), + 448: uint16(3619), + 449: uint16(3620), + 450: uint16(3621), + 451: uint16(3622), + 452: uint16(3623), + 453: uint16(3624), + 454: uint16(3625), + 455: uint16(3626), + 456: uint16(3627), + 457: uint16(3628), + 458: uint16(3629), + 459: uint16(3630), + 460: uint16(3631), + 461: uint16(3632), + 462: uint16(3633), + 463: uint16(3634), + 464: uint16(3635), + 465: uint16(3636), + 466: uint16(3637), + 467: uint16(3638), + 468: uint16(3639), + 469: uint16(3640), + 470: uint16(3641), + 471: uint16(3642), + 472: uint16(3647), + 473: uint16(3648), + 474: uint16(3649), + 475: uint16(3650), + 476: uint16(3651), + 477: uint16(3652), + 478: uint16(3653), + 479: uint16(3654), + 480: uint16(3655), + 481: uint16(3656), + 482: uint16(3657), + 483: uint16(3658), + 484: uint16(3659), + 485: uint16(3660), + 486: uint16(3661), + 487: uint16(3662), + 488: uint16(3663), + 489: uint16(3664), + 490: uint16(3665), + 491: uint16(3666), + 492: uint16(3667), + 493: uint16(3668), + 494: uint16(3669), + 495: uint16(3670), + 496: uint16(3671), + 497: uint16(3672), + 498: uint16(3673), + 499: uint16(3674), + 500: uint16(3675), + 501: uint16(7682), + 502: uint16(7683), + 503: uint16(7690), + 504: uint16(7691), + 505: uint16(7710), + 506: uint16(7711), + 507: uint16(7744), + 508: uint16(7745), + 509: uint16(7766), + 510: uint16(7767), + 511: uint16(7776), + 512: uint16(7777), + 513: uint16(7786), + 514: uint16(7787), + 515: uint16(7808), + 516: uint16(7809), + 517: uint16(7810), + 518: uint16(7811), + 519: uint16(7812), + 520: uint16(7813), + 521: uint16(7922), + 522: uint16(7923), + 523: uint16(8204), + 524: uint16(8205), + 525: uint16(8206), + 526: uint16(8207), + 527: uint16(8211), + 528: uint16(8212), + 529: uint16(8213), + 530: uint16(8215), + 531: uint16(8216), + 532: uint16(8217), + 533: uint16(8218), + 534: uint16(8220), + 535: uint16(8221), + 536: uint16(8222), + 537: uint16(8224), + 538: uint16(8225), + 539: uint16(8226), + 540: uint16(8230), + 541: uint16(8240), + 542: uint16(8249), + 543: uint16(8250), + 544: uint16(8319), + 545: uint16(8359), + 546: uint16(8362), + 547: uint16(8363), + 548: uint16(8364), + 549: uint16(8367), + 550: uint16(8470), + 551: uint16(8482), + 552: uint16(8729), + 553: uint16(8730), + 554: uint16(8734), + 555: uint16(8745), + 556: uint16(8776), + 557: uint16(8801), + 558: uint16(8804), + 559: uint16(8805), + 560: uint16(8976), + 561: uint16(8992), + 562: uint16(8993), + 563: uint16(9472), + 564: uint16(9474), + 565: uint16(9484), + 566: uint16(9488), + 567: uint16(9492), + 568: uint16(9496), + 569: uint16(9500), + 570: uint16(9508), + 571: uint16(9516), + 572: uint16(9524), + 573: uint16(9532), + 574: uint16(9552), + 575: uint16(9553), + 576: uint16(9554), + 577: uint16(9555), + 578: uint16(9556), + 579: uint16(9557), + 580: uint16(9558), + 581: uint16(9559), + 582: uint16(9560), + 583: uint16(9561), + 584: uint16(9562), + 585: uint16(9563), + 586: uint16(9564), + 587: uint16(9565), + 588: uint16(9566), + 589: uint16(9567), + 590: uint16(9568), + 591: uint16(9569), + 592: uint16(9570), + 593: uint16(9571), + 594: uint16(9572), + 595: uint16(9573), + 596: uint16(9574), + 597: uint16(9575), + 598: uint16(9576), + 599: uint16(9577), + 600: uint16(9578), + 601: uint16(9579), + 602: uint16(9580), + 603: uint16(9600), + 604: uint16(9604), + 605: uint16(9608), + 606: uint16(9612), + 607: uint16(9616), + 608: uint16(9617), + 609: uint16(9618), + 610: uint16(9619), + 611: uint16(9632), +} + +var _jis0208 = [84][94]uint16{ + 0: { + 0: uint16(12288), + 1: uint16(12289), + 2: uint16(12290), + 3: uint16(65292), + 4: uint16(65294), + 5: uint16(12539), + 6: uint16(65306), + 7: uint16(65307), + 8: uint16(65311), + 9: uint16(65281), + 10: uint16(12443), + 11: uint16(12444), + 12: uint16(180), + 13: uint16(65344), + 14: uint16(168), + 15: uint16(65342), + 16: uint16(65507), + 17: uint16(65343), + 18: uint16(12541), + 19: uint16(12542), + 20: uint16(12445), + 21: uint16(12446), + 22: uint16(12291), + 23: uint16(20189), + 24: uint16(12293), + 25: uint16(12294), + 26: uint16(12295), + 27: uint16(12540), + 28: uint16(8213), + 29: uint16(8208), + 30: uint16(65295), + 31: uint16(92), + 32: uint16(12316), + 33: uint16(8214), + 34: uint16(65372), + 35: uint16(8230), + 36: uint16(8229), + 37: uint16(8216), + 38: uint16(8217), + 39: uint16(8220), + 40: uint16(8221), + 41: uint16(65288), + 42: uint16(65289), + 43: uint16(12308), + 44: uint16(12309), + 45: uint16(65339), + 46: uint16(65341), + 47: uint16(65371), + 48: uint16(65373), + 49: uint16(12296), + 50: uint16(12297), + 51: uint16(12298), + 52: uint16(12299), + 53: uint16(12300), + 54: uint16(12301), + 55: uint16(12302), + 56: uint16(12303), + 57: uint16(12304), + 58: uint16(12305), + 59: uint16(65291), + 60: uint16(8722), + 61: uint16(177), + 62: uint16(215), + 63: uint16(247), + 64: uint16(65309), + 65: uint16(8800), + 66: uint16(65308), + 67: uint16(65310), + 68: uint16(8806), + 69: uint16(8807), + 70: uint16(8734), + 71: uint16(8756), + 72: uint16(9794), + 73: uint16(9792), + 74: uint16(176), + 75: uint16(8242), + 76: uint16(8243), + 77: uint16(8451), + 78: uint16(65509), + 79: uint16(65284), + 80: uint16(162), + 81: uint16(163), + 82: uint16(65285), + 83: uint16(65283), + 84: uint16(65286), + 85: uint16(65290), + 86: uint16(65312), + 87: uint16(167), + 88: uint16(9734), + 89: uint16(9733), + 90: uint16(9675), + 91: uint16(9679), + 92: uint16(9678), + 93: uint16(9671), + }, + 1: { + 0: uint16(9670), + 1: uint16(9633), + 2: uint16(9632), + 3: uint16(9651), + 4: uint16(9650), + 5: uint16(9661), + 6: uint16(9660), + 7: uint16(8251), + 8: uint16(12306), + 9: uint16(8594), + 10: uint16(8592), + 11: uint16(8593), + 12: uint16(8595), + 13: uint16(12307), + 25: uint16(8712), + 26: uint16(8715), + 27: uint16(8838), + 28: uint16(8839), + 29: uint16(8834), + 30: uint16(8835), + 31: uint16(8746), + 32: uint16(8745), + 41: uint16(8743), + 42: uint16(8744), + 43: uint16(172), + 44: uint16(8658), + 45: uint16(8660), + 46: uint16(8704), + 47: uint16(8707), + 59: uint16(8736), + 60: uint16(8869), + 61: uint16(8978), + 62: uint16(8706), + 63: uint16(8711), + 64: uint16(8801), + 65: uint16(8786), + 66: uint16(8810), + 67: uint16(8811), + 68: uint16(8730), + 69: uint16(8765), + 70: uint16(8733), + 71: uint16(8757), + 72: uint16(8747), + 73: uint16(8748), + 81: uint16(8491), + 82: uint16(8240), + 83: uint16(9839), + 84: uint16(9837), + 85: uint16(9834), + 86: uint16(8224), + 87: uint16(8225), + 88: uint16(182), + 93: uint16(9711), + }, + 2: { + 15: uint16(65296), + 16: uint16(65297), + 17: uint16(65298), + 18: uint16(65299), + 19: uint16(65300), + 20: uint16(65301), + 21: uint16(65302), + 22: uint16(65303), + 23: uint16(65304), + 24: uint16(65305), + 32: uint16(65313), + 33: uint16(65314), + 34: uint16(65315), + 35: uint16(65316), + 36: uint16(65317), + 37: uint16(65318), + 38: uint16(65319), + 39: uint16(65320), + 40: uint16(65321), + 41: uint16(65322), + 42: uint16(65323), + 43: uint16(65324), + 44: uint16(65325), + 45: uint16(65326), + 46: uint16(65327), + 47: uint16(65328), + 48: uint16(65329), + 49: uint16(65330), + 50: uint16(65331), + 51: uint16(65332), + 52: uint16(65333), + 53: uint16(65334), + 54: uint16(65335), + 55: uint16(65336), + 56: uint16(65337), + 57: uint16(65338), + 64: uint16(65345), + 65: uint16(65346), + 66: uint16(65347), + 67: uint16(65348), + 68: uint16(65349), + 69: uint16(65350), + 70: uint16(65351), + 71: uint16(65352), + 72: uint16(65353), + 73: uint16(65354), + 74: uint16(65355), + 75: uint16(65356), + 76: uint16(65357), + 77: uint16(65358), + 78: uint16(65359), + 79: uint16(65360), + 80: uint16(65361), + 81: uint16(65362), + 82: uint16(65363), + 83: uint16(65364), + 84: uint16(65365), + 85: uint16(65366), + 86: uint16(65367), + 87: uint16(65368), + 88: uint16(65369), + 89: uint16(65370), + }, + 3: { + 0: uint16(12353), + 1: uint16(12354), + 2: uint16(12355), + 3: uint16(12356), + 4: uint16(12357), + 5: uint16(12358), + 6: uint16(12359), + 7: uint16(12360), + 8: uint16(12361), + 9: uint16(12362), + 10: uint16(12363), + 11: uint16(12364), + 12: uint16(12365), + 13: uint16(12366), + 14: uint16(12367), + 15: uint16(12368), + 16: uint16(12369), + 17: uint16(12370), + 18: uint16(12371), + 19: uint16(12372), + 20: uint16(12373), + 21: uint16(12374), + 22: uint16(12375), + 23: uint16(12376), + 24: uint16(12377), + 25: uint16(12378), + 26: uint16(12379), + 27: uint16(12380), + 28: uint16(12381), + 29: uint16(12382), + 30: uint16(12383), + 31: uint16(12384), + 32: uint16(12385), + 33: uint16(12386), + 34: uint16(12387), + 35: uint16(12388), + 36: uint16(12389), + 37: uint16(12390), + 38: uint16(12391), + 39: uint16(12392), + 40: uint16(12393), + 41: uint16(12394), + 42: uint16(12395), + 43: uint16(12396), + 44: uint16(12397), + 45: uint16(12398), + 46: uint16(12399), + 47: uint16(12400), + 48: uint16(12401), + 49: uint16(12402), + 50: uint16(12403), + 51: uint16(12404), + 52: uint16(12405), + 53: uint16(12406), + 54: uint16(12407), + 55: uint16(12408), + 56: uint16(12409), + 57: uint16(12410), + 58: uint16(12411), + 59: uint16(12412), + 60: uint16(12413), + 61: uint16(12414), + 62: uint16(12415), + 63: uint16(12416), + 64: uint16(12417), + 65: uint16(12418), + 66: uint16(12419), + 67: uint16(12420), + 68: uint16(12421), + 69: uint16(12422), + 70: uint16(12423), + 71: uint16(12424), + 72: uint16(12425), + 73: uint16(12426), + 74: uint16(12427), + 75: uint16(12428), + 76: uint16(12429), + 77: uint16(12430), + 78: uint16(12431), + 79: uint16(12432), + 80: uint16(12433), + 81: uint16(12434), + 82: uint16(12435), + }, + 4: { + 0: uint16(12449), + 1: uint16(12450), + 2: uint16(12451), + 3: uint16(12452), + 4: uint16(12453), + 5: uint16(12454), + 6: uint16(12455), + 7: uint16(12456), + 8: uint16(12457), + 9: uint16(12458), + 10: uint16(12459), + 11: uint16(12460), + 12: uint16(12461), + 13: uint16(12462), + 14: uint16(12463), + 15: uint16(12464), + 16: uint16(12465), + 17: uint16(12466), + 18: uint16(12467), + 19: uint16(12468), + 20: uint16(12469), + 21: uint16(12470), + 22: uint16(12471), + 23: uint16(12472), + 24: uint16(12473), + 25: uint16(12474), + 26: uint16(12475), + 27: uint16(12476), + 28: uint16(12477), + 29: uint16(12478), + 30: uint16(12479), + 31: uint16(12480), + 32: uint16(12481), + 33: uint16(12482), + 34: uint16(12483), + 35: uint16(12484), + 36: uint16(12485), + 37: uint16(12486), + 38: uint16(12487), + 39: uint16(12488), + 40: uint16(12489), + 41: uint16(12490), + 42: uint16(12491), + 43: uint16(12492), + 44: uint16(12493), + 45: uint16(12494), + 46: uint16(12495), + 47: uint16(12496), + 48: uint16(12497), + 49: uint16(12498), + 50: uint16(12499), + 51: uint16(12500), + 52: uint16(12501), + 53: uint16(12502), + 54: uint16(12503), + 55: uint16(12504), + 56: uint16(12505), + 57: uint16(12506), + 58: uint16(12507), + 59: uint16(12508), + 60: uint16(12509), + 61: uint16(12510), + 62: uint16(12511), + 63: uint16(12512), + 64: uint16(12513), + 65: uint16(12514), + 66: uint16(12515), + 67: uint16(12516), + 68: uint16(12517), + 69: uint16(12518), + 70: uint16(12519), + 71: uint16(12520), + 72: uint16(12521), + 73: uint16(12522), + 74: uint16(12523), + 75: uint16(12524), + 76: uint16(12525), + 77: uint16(12526), + 78: uint16(12527), + 79: uint16(12528), + 80: uint16(12529), + 81: uint16(12530), + 82: uint16(12531), + 83: uint16(12532), + 84: uint16(12533), + 85: uint16(12534), + }, + 5: { + 0: uint16(913), + 1: uint16(914), + 2: uint16(915), + 3: uint16(916), + 4: uint16(917), + 5: uint16(918), + 6: uint16(919), + 7: uint16(920), + 8: uint16(921), + 9: uint16(922), + 10: uint16(923), + 11: uint16(924), + 12: uint16(925), + 13: uint16(926), + 14: uint16(927), + 15: uint16(928), + 16: uint16(929), + 17: uint16(931), + 18: uint16(932), + 19: uint16(933), + 20: uint16(934), + 21: uint16(935), + 22: uint16(936), + 23: uint16(937), + 32: uint16(945), + 33: uint16(946), + 34: uint16(947), + 35: uint16(948), + 36: uint16(949), + 37: uint16(950), + 38: uint16(951), + 39: uint16(952), + 40: uint16(953), + 41: uint16(954), + 42: uint16(955), + 43: uint16(956), + 44: uint16(957), + 45: uint16(958), + 46: uint16(959), + 47: uint16(960), + 48: uint16(961), + 49: uint16(963), + 50: uint16(964), + 51: uint16(965), + 52: uint16(966), + 53: uint16(967), + 54: uint16(968), + 55: uint16(969), + }, + 6: { + 0: uint16(1040), + 1: uint16(1041), + 2: uint16(1042), + 3: uint16(1043), + 4: uint16(1044), + 5: uint16(1045), + 6: uint16(1025), + 7: uint16(1046), + 8: uint16(1047), + 9: uint16(1048), + 10: uint16(1049), + 11: uint16(1050), + 12: uint16(1051), + 13: uint16(1052), + 14: uint16(1053), + 15: uint16(1054), + 16: uint16(1055), + 17: uint16(1056), + 18: uint16(1057), + 19: uint16(1058), + 20: uint16(1059), + 21: uint16(1060), + 22: uint16(1061), + 23: uint16(1062), + 24: uint16(1063), + 25: uint16(1064), + 26: uint16(1065), + 27: uint16(1066), + 28: uint16(1067), + 29: uint16(1068), + 30: uint16(1069), + 31: uint16(1070), + 32: uint16(1071), + 48: uint16(1072), + 49: uint16(1073), + 50: uint16(1074), + 51: uint16(1075), + 52: uint16(1076), + 53: uint16(1077), + 54: uint16(1105), + 55: uint16(1078), + 56: uint16(1079), + 57: uint16(1080), + 58: uint16(1081), + 59: uint16(1082), + 60: uint16(1083), + 61: uint16(1084), + 62: uint16(1085), + 63: uint16(1086), + 64: uint16(1087), + 65: uint16(1088), + 66: uint16(1089), + 67: uint16(1090), + 68: uint16(1091), + 69: uint16(1092), + 70: uint16(1093), + 71: uint16(1094), + 72: uint16(1095), + 73: uint16(1096), + 74: uint16(1097), + 75: uint16(1098), + 76: uint16(1099), + 77: uint16(1100), + 78: uint16(1101), + 79: uint16(1102), + 80: uint16(1103), + }, + 7: { + 0: uint16(9472), + 1: uint16(9474), + 2: uint16(9484), + 3: uint16(9488), + 4: uint16(9496), + 5: uint16(9492), + 6: uint16(9500), + 7: uint16(9516), + 8: uint16(9508), + 9: uint16(9524), + 10: uint16(9532), + 11: uint16(9473), + 12: uint16(9475), + 13: uint16(9487), + 14: uint16(9491), + 15: uint16(9499), + 16: uint16(9495), + 17: uint16(9507), + 18: uint16(9523), + 19: uint16(9515), + 20: uint16(9531), + 21: uint16(9547), + 22: uint16(9504), + 23: uint16(9519), + 24: uint16(9512), + 25: uint16(9527), + 26: uint16(9535), + 27: uint16(9501), + 28: uint16(9520), + 29: uint16(9509), + 30: uint16(9528), + 31: uint16(9538), + }, + 8: {}, + 9: {}, + 10: {}, + 11: {}, + 12: {}, + 13: {}, + 14: {}, + 15: { + 0: uint16(20124), + 1: uint16(21782), + 2: uint16(23043), + 3: uint16(38463), + 4: uint16(21696), + 5: uint16(24859), + 6: uint16(25384), + 7: uint16(23030), + 8: uint16(36898), + 9: uint16(33909), + 10: uint16(33564), + 11: uint16(31312), + 12: uint16(24746), + 13: uint16(25569), + 14: uint16(28197), + 15: uint16(26093), + 16: uint16(33894), + 17: uint16(33446), + 18: uint16(39925), + 19: uint16(26771), + 20: uint16(22311), + 21: uint16(26017), + 22: uint16(25201), + 23: uint16(23451), + 24: uint16(22992), + 25: uint16(34427), + 26: uint16(39156), + 27: uint16(32098), + 28: uint16(32190), + 29: uint16(39822), + 30: uint16(25110), + 31: uint16(31903), + 32: uint16(34999), + 33: uint16(23433), + 34: uint16(24245), + 35: uint16(25353), + 36: uint16(26263), + 37: uint16(26696), + 38: uint16(38343), + 39: uint16(38797), + 40: uint16(26447), + 41: uint16(20197), + 42: uint16(20234), + 43: uint16(20301), + 44: uint16(20381), + 45: uint16(20553), + 46: uint16(22258), + 47: uint16(22839), + 48: uint16(22996), + 49: uint16(23041), + 50: uint16(23561), + 51: uint16(24799), + 52: uint16(24847), + 53: uint16(24944), + 54: uint16(26131), + 55: uint16(26885), + 56: uint16(28858), + 57: uint16(30031), + 58: uint16(30064), + 59: uint16(31227), + 60: uint16(32173), + 61: uint16(32239), + 62: uint16(32963), + 63: uint16(33806), + 64: uint16(34915), + 65: uint16(35586), + 66: uint16(36949), + 67: uint16(36986), + 68: uint16(21307), + 69: uint16(20117), + 70: uint16(20133), + 71: uint16(22495), + 72: uint16(32946), + 73: uint16(37057), + 74: uint16(30959), + 75: uint16(19968), + 76: uint16(22769), + 77: uint16(28322), + 78: uint16(36920), + 79: uint16(31282), + 80: uint16(33576), + 81: uint16(33419), + 82: uint16(39983), + 83: uint16(20801), + 84: uint16(21360), + 85: uint16(21693), + 86: uint16(21729), + 87: uint16(22240), + 88: uint16(23035), + 89: uint16(24341), + 90: uint16(39154), + 91: uint16(28139), + 92: uint16(32996), + 93: uint16(34093), + }, + 16: { + 0: uint16(38498), + 1: uint16(38512), + 2: uint16(38560), + 3: uint16(38907), + 4: uint16(21515), + 5: uint16(21491), + 6: uint16(23431), + 7: uint16(28879), + 8: uint16(32701), + 9: uint16(36802), + 10: uint16(38632), + 11: uint16(21359), + 12: uint16(40284), + 13: uint16(31418), + 14: uint16(19985), + 15: uint16(30867), + 16: uint16(33276), + 17: uint16(28198), + 18: uint16(22040), + 19: uint16(21764), + 20: uint16(27421), + 21: uint16(34074), + 22: uint16(39995), + 23: uint16(23013), + 24: uint16(21417), + 25: uint16(28006), + 26: uint16(29916), + 27: uint16(38287), + 28: uint16(22082), + 29: uint16(20113), + 30: uint16(36939), + 31: uint16(38642), + 32: uint16(33615), + 33: uint16(39180), + 34: uint16(21473), + 35: uint16(21942), + 36: uint16(23344), + 37: uint16(24433), + 38: uint16(26144), + 39: uint16(26355), + 40: uint16(26628), + 41: uint16(27704), + 42: uint16(27891), + 43: uint16(27945), + 44: uint16(29787), + 45: uint16(30408), + 46: uint16(31310), + 47: uint16(38964), + 48: uint16(33521), + 49: uint16(34907), + 50: uint16(35424), + 51: uint16(37613), + 52: uint16(28082), + 53: uint16(30123), + 54: uint16(30410), + 55: uint16(39365), + 56: uint16(24742), + 57: uint16(35585), + 58: uint16(36234), + 59: uint16(38322), + 60: uint16(27022), + 61: uint16(21421), + 62: uint16(20870), + 63: uint16(22290), + 64: uint16(22576), + 65: uint16(22852), + 66: uint16(23476), + 67: uint16(24310), + 68: uint16(24616), + 69: uint16(25513), + 70: uint16(25588), + 71: uint16(27839), + 72: uint16(28436), + 73: uint16(28814), + 74: uint16(28948), + 75: uint16(29017), + 76: uint16(29141), + 77: uint16(29503), + 78: uint16(32257), + 79: uint16(33398), + 80: uint16(33489), + 81: uint16(34199), + 82: uint16(36960), + 83: uint16(37467), + 84: uint16(40219), + 85: uint16(22633), + 86: uint16(26044), + 87: uint16(27738), + 88: uint16(29989), + 89: uint16(20985), + 90: uint16(22830), + 91: uint16(22885), + 92: uint16(24448), + 93: uint16(24540), + }, + 17: { + 0: uint16(25276), + 1: uint16(26106), + 2: uint16(27178), + 3: uint16(27431), + 4: uint16(27572), + 5: uint16(29579), + 6: uint16(32705), + 7: uint16(35158), + 8: uint16(40236), + 9: uint16(40206), + 10: uint16(40644), + 11: uint16(23713), + 12: uint16(27798), + 13: uint16(33659), + 14: uint16(20740), + 15: uint16(23627), + 16: uint16(25014), + 17: uint16(33222), + 18: uint16(26742), + 19: uint16(29281), + 20: uint16(20057), + 21: uint16(20474), + 22: uint16(21368), + 23: uint16(24681), + 24: uint16(28201), + 25: uint16(31311), + 26: uint16(38899), + 27: uint16(19979), + 28: uint16(21270), + 29: uint16(20206), + 30: uint16(20309), + 31: uint16(20285), + 32: uint16(20385), + 33: uint16(20339), + 34: uint16(21152), + 35: uint16(21487), + 36: uint16(22025), + 37: uint16(22799), + 38: uint16(23233), + 39: uint16(23478), + 40: uint16(23521), + 41: uint16(31185), + 42: uint16(26247), + 43: uint16(26524), + 44: uint16(26550), + 45: uint16(27468), + 46: uint16(27827), + 47: uint16(28779), + 48: uint16(29634), + 49: uint16(31117), + 50: uint16(31166), + 51: uint16(31292), + 52: uint16(31623), + 53: uint16(33457), + 54: uint16(33499), + 55: uint16(33540), + 56: uint16(33655), + 57: uint16(33775), + 58: uint16(33747), + 59: uint16(34662), + 60: uint16(35506), + 61: uint16(22057), + 62: uint16(36008), + 63: uint16(36838), + 64: uint16(36942), + 65: uint16(38686), + 66: uint16(34442), + 67: uint16(20420), + 68: uint16(23784), + 69: uint16(25105), + 70: uint16(29273), + 71: uint16(30011), + 72: uint16(33253), + 73: uint16(33469), + 74: uint16(34558), + 75: uint16(36032), + 76: uint16(38597), + 77: uint16(39187), + 78: uint16(39381), + 79: uint16(20171), + 80: uint16(20250), + 81: uint16(35299), + 82: uint16(22238), + 83: uint16(22602), + 84: uint16(22730), + 85: uint16(24315), + 86: uint16(24555), + 87: uint16(24618), + 88: uint16(24724), + 89: uint16(24674), + 90: uint16(25040), + 91: uint16(25106), + 92: uint16(25296), + 93: uint16(25913), + }, + 18: { + 0: uint16(39745), + 1: uint16(26214), + 2: uint16(26800), + 3: uint16(28023), + 4: uint16(28784), + 5: uint16(30028), + 6: uint16(30342), + 7: uint16(32117), + 8: uint16(33445), + 9: uint16(34809), + 10: uint16(38283), + 11: uint16(38542), + 12: uint16(35997), + 13: uint16(20977), + 14: uint16(21182), + 15: uint16(22806), + 16: uint16(21683), + 17: uint16(23475), + 18: uint16(23830), + 19: uint16(24936), + 20: uint16(27010), + 21: uint16(28079), + 22: uint16(30861), + 23: uint16(33995), + 24: uint16(34903), + 25: uint16(35442), + 26: uint16(37799), + 27: uint16(39608), + 28: uint16(28012), + 29: uint16(39336), + 30: uint16(34521), + 31: uint16(22435), + 32: uint16(26623), + 33: uint16(34510), + 34: uint16(37390), + 35: uint16(21123), + 36: uint16(22151), + 37: uint16(21508), + 38: uint16(24275), + 39: uint16(25313), + 40: uint16(25785), + 41: uint16(26684), + 42: uint16(26680), + 43: uint16(27579), + 44: uint16(29554), + 45: uint16(30906), + 46: uint16(31339), + 47: uint16(35226), + 48: uint16(35282), + 49: uint16(36203), + 50: uint16(36611), + 51: uint16(37101), + 52: uint16(38307), + 53: uint16(38548), + 54: uint16(38761), + 55: uint16(23398), + 56: uint16(23731), + 57: uint16(27005), + 58: uint16(38989), + 59: uint16(38990), + 60: uint16(25499), + 61: uint16(31520), + 62: uint16(27179), + 63: uint16(27263), + 64: uint16(26806), + 65: uint16(39949), + 66: uint16(28511), + 67: uint16(21106), + 68: uint16(21917), + 69: uint16(24688), + 70: uint16(25324), + 71: uint16(27963), + 72: uint16(28167), + 73: uint16(28369), + 74: uint16(33883), + 75: uint16(35088), + 76: uint16(36676), + 77: uint16(19988), + 78: uint16(39993), + 79: uint16(21494), + 80: uint16(26907), + 81: uint16(27194), + 82: uint16(38788), + 83: uint16(26666), + 84: uint16(20828), + 85: uint16(31427), + 86: uint16(33970), + 87: uint16(37340), + 88: uint16(37772), + 89: uint16(22107), + 90: uint16(40232), + 91: uint16(26658), + 92: uint16(33541), + 93: uint16(33841), + }, + 19: { + 0: uint16(31909), + 1: uint16(21000), + 2: uint16(33477), + 3: uint16(29926), + 4: uint16(20094), + 5: uint16(20355), + 6: uint16(20896), + 7: uint16(23506), + 8: uint16(21002), + 9: uint16(21208), + 10: uint16(21223), + 11: uint16(24059), + 12: uint16(21914), + 13: uint16(22570), + 14: uint16(23014), + 15: uint16(23436), + 16: uint16(23448), + 17: uint16(23515), + 18: uint16(24178), + 19: uint16(24185), + 20: uint16(24739), + 21: uint16(24863), + 22: uint16(24931), + 23: uint16(25022), + 24: uint16(25563), + 25: uint16(25954), + 26: uint16(26577), + 27: uint16(26707), + 28: uint16(26874), + 29: uint16(27454), + 30: uint16(27475), + 31: uint16(27735), + 32: uint16(28450), + 33: uint16(28567), + 34: uint16(28485), + 35: uint16(29872), + 36: uint16(29976), + 37: uint16(30435), + 38: uint16(30475), + 39: uint16(31487), + 40: uint16(31649), + 41: uint16(31777), + 42: uint16(32233), + 43: uint16(32566), + 44: uint16(32752), + 45: uint16(32925), + 46: uint16(33382), + 47: uint16(33694), + 48: uint16(35251), + 49: uint16(35532), + 50: uint16(36011), + 51: uint16(36996), + 52: uint16(37969), + 53: uint16(38291), + 54: uint16(38289), + 55: uint16(38306), + 56: uint16(38501), + 57: uint16(38867), + 58: uint16(39208), + 59: uint16(33304), + 60: uint16(20024), + 61: uint16(21547), + 62: uint16(23736), + 63: uint16(24012), + 64: uint16(29609), + 65: uint16(30284), + 66: uint16(30524), + 67: uint16(23721), + 68: uint16(32747), + 69: uint16(36107), + 70: uint16(38593), + 71: uint16(38929), + 72: uint16(38996), + 73: uint16(39000), + 74: uint16(20225), + 75: uint16(20238), + 76: uint16(21361), + 77: uint16(21916), + 78: uint16(22120), + 79: uint16(22522), + 80: uint16(22855), + 81: uint16(23305), + 82: uint16(23492), + 83: uint16(23696), + 84: uint16(24076), + 85: uint16(24190), + 86: uint16(24524), + 87: uint16(25582), + 88: uint16(26426), + 89: uint16(26071), + 90: uint16(26082), + 91: uint16(26399), + 92: uint16(26827), + 93: uint16(26820), + }, + 20: { + 0: uint16(27231), + 1: uint16(24112), + 2: uint16(27589), + 3: uint16(27671), + 4: uint16(27773), + 5: uint16(30079), + 6: uint16(31048), + 7: uint16(23395), + 8: uint16(31232), + 9: uint16(32000), + 10: uint16(24509), + 11: uint16(35215), + 12: uint16(35352), + 13: uint16(36020), + 14: uint16(36215), + 15: uint16(36556), + 16: uint16(36637), + 17: uint16(39138), + 18: uint16(39438), + 19: uint16(39740), + 20: uint16(20096), + 21: uint16(20605), + 22: uint16(20736), + 23: uint16(22931), + 24: uint16(23452), + 25: uint16(25135), + 26: uint16(25216), + 27: uint16(25836), + 28: uint16(27450), + 29: uint16(29344), + 30: uint16(30097), + 31: uint16(31047), + 32: uint16(32681), + 33: uint16(34811), + 34: uint16(35516), + 35: uint16(35696), + 36: uint16(25516), + 37: uint16(33738), + 38: uint16(38816), + 39: uint16(21513), + 40: uint16(21507), + 41: uint16(21931), + 42: uint16(26708), + 43: uint16(27224), + 44: uint16(35440), + 45: uint16(30759), + 46: uint16(26485), + 47: uint16(40653), + 48: uint16(21364), + 49: uint16(23458), + 50: uint16(33050), + 51: uint16(34384), + 52: uint16(36870), + 53: uint16(19992), + 54: uint16(20037), + 55: uint16(20167), + 56: uint16(20241), + 57: uint16(21450), + 58: uint16(21560), + 59: uint16(23470), + 60: uint16(24339), + 61: uint16(24613), + 62: uint16(25937), + 63: uint16(26429), + 64: uint16(27714), + 65: uint16(27762), + 66: uint16(27875), + 67: uint16(28792), + 68: uint16(29699), + 69: uint16(31350), + 70: uint16(31406), + 71: uint16(31496), + 72: uint16(32026), + 73: uint16(31998), + 74: uint16(32102), + 75: uint16(26087), + 76: uint16(29275), + 77: uint16(21435), + 78: uint16(23621), + 79: uint16(24040), + 80: uint16(25298), + 81: uint16(25312), + 82: uint16(25369), + 83: uint16(28192), + 84: uint16(34394), + 85: uint16(35377), + 86: uint16(36317), + 87: uint16(37624), + 88: uint16(28417), + 89: uint16(31142), + 90: uint16(39770), + 91: uint16(20136), + 92: uint16(20139), + 93: uint16(20140), + }, + 21: { + 0: uint16(20379), + 1: uint16(20384), + 2: uint16(20689), + 3: uint16(20807), + 4: uint16(31478), + 5: uint16(20849), + 6: uint16(20982), + 7: uint16(21332), + 8: uint16(21281), + 9: uint16(21375), + 10: uint16(21483), + 11: uint16(21932), + 12: uint16(22659), + 13: uint16(23777), + 14: uint16(24375), + 15: uint16(24394), + 16: uint16(24623), + 17: uint16(24656), + 18: uint16(24685), + 19: uint16(25375), + 20: uint16(25945), + 21: uint16(27211), + 22: uint16(27841), + 23: uint16(29378), + 24: uint16(29421), + 25: uint16(30703), + 26: uint16(33016), + 27: uint16(33029), + 28: uint16(33288), + 29: uint16(34126), + 30: uint16(37111), + 31: uint16(37857), + 32: uint16(38911), + 33: uint16(39255), + 34: uint16(39514), + 35: uint16(20208), + 36: uint16(20957), + 37: uint16(23597), + 38: uint16(26241), + 39: uint16(26989), + 40: uint16(23616), + 41: uint16(26354), + 42: uint16(26997), + 43: uint16(29577), + 44: uint16(26704), + 45: uint16(31873), + 46: uint16(20677), + 47: uint16(21220), + 48: uint16(22343), + 49: uint16(24062), + 50: uint16(37670), + 51: uint16(26020), + 52: uint16(27427), + 53: uint16(27453), + 54: uint16(29748), + 55: uint16(31105), + 56: uint16(31165), + 57: uint16(31563), + 58: uint16(32202), + 59: uint16(33465), + 60: uint16(33740), + 61: uint16(34943), + 62: uint16(35167), + 63: uint16(35641), + 64: uint16(36817), + 65: uint16(37329), + 66: uint16(21535), + 67: uint16(37504), + 68: uint16(20061), + 69: uint16(20534), + 70: uint16(21477), + 71: uint16(21306), + 72: uint16(29399), + 73: uint16(29590), + 74: uint16(30697), + 75: uint16(33510), + 76: uint16(36527), + 77: uint16(39366), + 78: uint16(39368), + 79: uint16(39378), + 80: uint16(20855), + 81: uint16(24858), + 82: uint16(34398), + 83: uint16(21936), + 84: uint16(31354), + 85: uint16(20598), + 86: uint16(23507), + 87: uint16(36935), + 88: uint16(38533), + 89: uint16(20018), + 90: uint16(27355), + 91: uint16(37351), + 92: uint16(23633), + 93: uint16(23624), + }, + 22: { + 0: uint16(25496), + 1: uint16(31391), + 2: uint16(27795), + 3: uint16(38772), + 4: uint16(36705), + 5: uint16(31402), + 6: uint16(29066), + 7: uint16(38536), + 8: uint16(31874), + 9: uint16(26647), + 10: uint16(32368), + 11: uint16(26705), + 12: uint16(37740), + 13: uint16(21234), + 14: uint16(21531), + 15: uint16(34219), + 16: uint16(35347), + 17: uint16(32676), + 18: uint16(36557), + 19: uint16(37089), + 20: uint16(21350), + 21: uint16(34952), + 22: uint16(31041), + 23: uint16(20418), + 24: uint16(20670), + 25: uint16(21009), + 26: uint16(20804), + 27: uint16(21843), + 28: uint16(22317), + 29: uint16(29674), + 30: uint16(22411), + 31: uint16(22865), + 32: uint16(24418), + 33: uint16(24452), + 34: uint16(24693), + 35: uint16(24950), + 36: uint16(24935), + 37: uint16(25001), + 38: uint16(25522), + 39: uint16(25658), + 40: uint16(25964), + 41: uint16(26223), + 42: uint16(26690), + 43: uint16(28179), + 44: uint16(30054), + 45: uint16(31293), + 46: uint16(31995), + 47: uint16(32076), + 48: uint16(32153), + 49: uint16(32331), + 50: uint16(32619), + 51: uint16(33550), + 52: uint16(33610), + 53: uint16(34509), + 54: uint16(35336), + 55: uint16(35427), + 56: uint16(35686), + 57: uint16(36605), + 58: uint16(38938), + 59: uint16(40335), + 60: uint16(33464), + 61: uint16(36814), + 62: uint16(39912), + 63: uint16(21127), + 64: uint16(25119), + 65: uint16(25731), + 66: uint16(28608), + 67: uint16(38553), + 68: uint16(26689), + 69: uint16(20625), + 70: uint16(27424), + 71: uint16(27770), + 72: uint16(28500), + 73: uint16(31348), + 74: uint16(32080), + 75: uint16(34880), + 76: uint16(35363), + 77: uint16(26376), + 78: uint16(20214), + 79: uint16(20537), + 80: uint16(20518), + 81: uint16(20581), + 82: uint16(20860), + 83: uint16(21048), + 84: uint16(21091), + 85: uint16(21927), + 86: uint16(22287), + 87: uint16(22533), + 88: uint16(23244), + 89: uint16(24314), + 90: uint16(25010), + 91: uint16(25080), + 92: uint16(25331), + 93: uint16(25458), + }, + 23: { + 0: uint16(26908), + 1: uint16(27177), + 2: uint16(29309), + 3: uint16(29356), + 4: uint16(29486), + 5: uint16(30740), + 6: uint16(30831), + 7: uint16(32121), + 8: uint16(30476), + 9: uint16(32937), + 10: uint16(35211), + 11: uint16(35609), + 12: uint16(36066), + 13: uint16(36562), + 14: uint16(36963), + 15: uint16(37749), + 16: uint16(38522), + 17: uint16(38997), + 18: uint16(39443), + 19: uint16(40568), + 20: uint16(20803), + 21: uint16(21407), + 22: uint16(21427), + 23: uint16(24187), + 24: uint16(24358), + 25: uint16(28187), + 26: uint16(28304), + 27: uint16(29572), + 28: uint16(29694), + 29: uint16(32067), + 30: uint16(33335), + 31: uint16(35328), + 32: uint16(35578), + 33: uint16(38480), + 34: uint16(20046), + 35: uint16(20491), + 36: uint16(21476), + 37: uint16(21628), + 38: uint16(22266), + 39: uint16(22993), + 40: uint16(23396), + 41: uint16(24049), + 42: uint16(24235), + 43: uint16(24359), + 44: uint16(25144), + 45: uint16(25925), + 46: uint16(26543), + 47: uint16(28246), + 48: uint16(29392), + 49: uint16(31946), + 50: uint16(34996), + 51: uint16(32929), + 52: uint16(32993), + 53: uint16(33776), + 54: uint16(34382), + 55: uint16(35463), + 56: uint16(36328), + 57: uint16(37431), + 58: uint16(38599), + 59: uint16(39015), + 60: uint16(40723), + 61: uint16(20116), + 62: uint16(20114), + 63: uint16(20237), + 64: uint16(21320), + 65: uint16(21577), + 66: uint16(21566), + 67: uint16(23087), + 68: uint16(24460), + 69: uint16(24481), + 70: uint16(24735), + 71: uint16(26791), + 72: uint16(27278), + 73: uint16(29786), + 74: uint16(30849), + 75: uint16(35486), + 76: uint16(35492), + 77: uint16(35703), + 78: uint16(37264), + 79: uint16(20062), + 80: uint16(39881), + 81: uint16(20132), + 82: uint16(20348), + 83: uint16(20399), + 84: uint16(20505), + 85: uint16(20502), + 86: uint16(20809), + 87: uint16(20844), + 88: uint16(21151), + 89: uint16(21177), + 90: uint16(21246), + 91: uint16(21402), + 92: uint16(21475), + 93: uint16(21521), + }, + 24: { + 0: uint16(21518), + 1: uint16(21897), + 2: uint16(22353), + 3: uint16(22434), + 4: uint16(22909), + 5: uint16(23380), + 6: uint16(23389), + 7: uint16(23439), + 8: uint16(24037), + 9: uint16(24039), + 10: uint16(24055), + 11: uint16(24184), + 12: uint16(24195), + 13: uint16(24218), + 14: uint16(24247), + 15: uint16(24344), + 16: uint16(24658), + 17: uint16(24908), + 18: uint16(25239), + 19: uint16(25304), + 20: uint16(25511), + 21: uint16(25915), + 22: uint16(26114), + 23: uint16(26179), + 24: uint16(26356), + 25: uint16(26477), + 26: uint16(26657), + 27: uint16(26775), + 28: uint16(27083), + 29: uint16(27743), + 30: uint16(27946), + 31: uint16(28009), + 32: uint16(28207), + 33: uint16(28317), + 34: uint16(30002), + 35: uint16(30343), + 36: uint16(30828), + 37: uint16(31295), + 38: uint16(31968), + 39: uint16(32005), + 40: uint16(32024), + 41: uint16(32094), + 42: uint16(32177), + 43: uint16(32789), + 44: uint16(32771), + 45: uint16(32943), + 46: uint16(32945), + 47: uint16(33108), + 48: uint16(33167), + 49: uint16(33322), + 50: uint16(33618), + 51: uint16(34892), + 52: uint16(34913), + 53: uint16(35611), + 54: uint16(36002), + 55: uint16(36092), + 56: uint16(37066), + 57: uint16(37237), + 58: uint16(37489), + 59: uint16(30783), + 60: uint16(37628), + 61: uint16(38308), + 62: uint16(38477), + 63: uint16(38917), + 64: uint16(39321), + 65: uint16(39640), + 66: uint16(40251), + 67: uint16(21083), + 68: uint16(21163), + 69: uint16(21495), + 70: uint16(21512), + 71: uint16(22741), + 72: uint16(25335), + 73: uint16(28640), + 74: uint16(35946), + 75: uint16(36703), + 76: uint16(40633), + 77: uint16(20811), + 78: uint16(21051), + 79: uint16(21578), + 80: uint16(22269), + 81: uint16(31296), + 82: uint16(37239), + 83: uint16(40288), + 84: uint16(40658), + 85: uint16(29508), + 86: uint16(28425), + 87: uint16(33136), + 88: uint16(29969), + 89: uint16(24573), + 90: uint16(24794), + 91: uint16(39592), + 92: uint16(29403), + 93: uint16(36796), + }, + 25: { + 0: uint16(27492), + 1: uint16(38915), + 2: uint16(20170), + 3: uint16(22256), + 4: uint16(22372), + 5: uint16(22718), + 6: uint16(23130), + 7: uint16(24680), + 8: uint16(25031), + 9: uint16(26127), + 10: uint16(26118), + 11: uint16(26681), + 12: uint16(26801), + 13: uint16(28151), + 14: uint16(30165), + 15: uint16(32058), + 16: uint16(33390), + 17: uint16(39746), + 18: uint16(20123), + 19: uint16(20304), + 20: uint16(21449), + 21: uint16(21766), + 22: uint16(23919), + 23: uint16(24038), + 24: uint16(24046), + 25: uint16(26619), + 26: uint16(27801), + 27: uint16(29811), + 28: uint16(30722), + 29: uint16(35408), + 30: uint16(37782), + 31: uint16(35039), + 32: uint16(22352), + 33: uint16(24231), + 34: uint16(25387), + 35: uint16(20661), + 36: uint16(20652), + 37: uint16(20877), + 38: uint16(26368), + 39: uint16(21705), + 40: uint16(22622), + 41: uint16(22971), + 42: uint16(23472), + 43: uint16(24425), + 44: uint16(25165), + 45: uint16(25505), + 46: uint16(26685), + 47: uint16(27507), + 48: uint16(28168), + 49: uint16(28797), + 50: uint16(37319), + 51: uint16(29312), + 52: uint16(30741), + 53: uint16(30758), + 54: uint16(31085), + 55: uint16(25998), + 56: uint16(32048), + 57: uint16(33756), + 58: uint16(35009), + 59: uint16(36617), + 60: uint16(38555), + 61: uint16(21092), + 62: uint16(22312), + 63: uint16(26448), + 64: uint16(32618), + 65: uint16(36001), + 66: uint16(20916), + 67: uint16(22338), + 68: uint16(38442), + 69: uint16(22586), + 70: uint16(27018), + 71: uint16(32948), + 72: uint16(21682), + 73: uint16(23822), + 74: uint16(22524), + 75: uint16(30869), + 76: uint16(40442), + 77: uint16(20316), + 78: uint16(21066), + 79: uint16(21643), + 80: uint16(25662), + 81: uint16(26152), + 82: uint16(26388), + 83: uint16(26613), + 84: uint16(31364), + 85: uint16(31574), + 86: uint16(32034), + 87: uint16(37679), + 88: uint16(26716), + 89: uint16(39853), + 90: uint16(31545), + 91: uint16(21273), + 92: uint16(20874), + 93: uint16(21047), + }, + 26: { + 0: uint16(23519), + 1: uint16(25334), + 2: uint16(25774), + 3: uint16(25830), + 4: uint16(26413), + 5: uint16(27578), + 6: uint16(34217), + 7: uint16(38609), + 8: uint16(30352), + 9: uint16(39894), + 10: uint16(25420), + 11: uint16(37638), + 12: uint16(39851), + 13: uint16(30399), + 14: uint16(26194), + 15: uint16(19977), + 16: uint16(20632), + 17: uint16(21442), + 18: uint16(23665), + 19: uint16(24808), + 20: uint16(25746), + 21: uint16(25955), + 22: uint16(26719), + 23: uint16(29158), + 24: uint16(29642), + 25: uint16(29987), + 26: uint16(31639), + 27: uint16(32386), + 28: uint16(34453), + 29: uint16(35715), + 30: uint16(36059), + 31: uint16(37240), + 32: uint16(39184), + 33: uint16(26028), + 34: uint16(26283), + 35: uint16(27531), + 36: uint16(20181), + 37: uint16(20180), + 38: uint16(20282), + 39: uint16(20351), + 40: uint16(21050), + 41: uint16(21496), + 42: uint16(21490), + 43: uint16(21987), + 44: uint16(22235), + 45: uint16(22763), + 46: uint16(22987), + 47: uint16(22985), + 48: uint16(23039), + 49: uint16(23376), + 50: uint16(23629), + 51: uint16(24066), + 52: uint16(24107), + 53: uint16(24535), + 54: uint16(24605), + 55: uint16(25351), + 56: uint16(25903), + 57: uint16(23388), + 58: uint16(26031), + 59: uint16(26045), + 60: uint16(26088), + 61: uint16(26525), + 62: uint16(27490), + 63: uint16(27515), + 64: uint16(27663), + 65: uint16(29509), + 66: uint16(31049), + 67: uint16(31169), + 68: uint16(31992), + 69: uint16(32025), + 70: uint16(32043), + 71: uint16(32930), + 72: uint16(33026), + 73: uint16(33267), + 74: uint16(35222), + 75: uint16(35422), + 76: uint16(35433), + 77: uint16(35430), + 78: uint16(35468), + 79: uint16(35566), + 80: uint16(36039), + 81: uint16(36060), + 82: uint16(38604), + 83: uint16(39164), + 84: uint16(27503), + 85: uint16(20107), + 86: uint16(20284), + 87: uint16(20365), + 88: uint16(20816), + 89: uint16(23383), + 90: uint16(23546), + 91: uint16(24904), + 92: uint16(25345), + 93: uint16(26178), + }, + 27: { + 0: uint16(27425), + 1: uint16(28363), + 2: uint16(27835), + 3: uint16(29246), + 4: uint16(29885), + 5: uint16(30164), + 6: uint16(30913), + 7: uint16(31034), + 8: uint16(32780), + 9: uint16(32819), + 10: uint16(33258), + 11: uint16(33940), + 12: uint16(36766), + 13: uint16(27728), + 14: uint16(40575), + 15: uint16(24335), + 16: uint16(35672), + 17: uint16(40235), + 18: uint16(31482), + 19: uint16(36600), + 20: uint16(23437), + 21: uint16(38635), + 22: uint16(19971), + 23: uint16(21489), + 24: uint16(22519), + 25: uint16(22833), + 26: uint16(23241), + 27: uint16(23460), + 28: uint16(24713), + 29: uint16(28287), + 30: uint16(28422), + 31: uint16(30142), + 32: uint16(36074), + 33: uint16(23455), + 34: uint16(34048), + 35: uint16(31712), + 36: uint16(20594), + 37: uint16(26612), + 38: uint16(33437), + 39: uint16(23649), + 40: uint16(34122), + 41: uint16(32286), + 42: uint16(33294), + 43: uint16(20889), + 44: uint16(23556), + 45: uint16(25448), + 46: uint16(36198), + 47: uint16(26012), + 48: uint16(29038), + 49: uint16(31038), + 50: uint16(32023), + 51: uint16(32773), + 52: uint16(35613), + 53: uint16(36554), + 54: uint16(36974), + 55: uint16(34503), + 56: uint16(37034), + 57: uint16(20511), + 58: uint16(21242), + 59: uint16(23610), + 60: uint16(26451), + 61: uint16(28796), + 62: uint16(29237), + 63: uint16(37196), + 64: uint16(37320), + 65: uint16(37675), + 66: uint16(33509), + 67: uint16(23490), + 68: uint16(24369), + 69: uint16(24825), + 70: uint16(20027), + 71: uint16(21462), + 72: uint16(23432), + 73: uint16(25163), + 74: uint16(26417), + 75: uint16(27530), + 76: uint16(29417), + 77: uint16(29664), + 78: uint16(31278), + 79: uint16(33131), + 80: uint16(36259), + 81: uint16(37202), + 82: uint16(39318), + 83: uint16(20754), + 84: uint16(21463), + 85: uint16(21610), + 86: uint16(23551), + 87: uint16(25480), + 88: uint16(27193), + 89: uint16(32172), + 90: uint16(38656), + 91: uint16(22234), + 92: uint16(21454), + 93: uint16(21608), + }, + 28: { + 0: uint16(23447), + 1: uint16(23601), + 2: uint16(24030), + 3: uint16(20462), + 4: uint16(24833), + 5: uint16(25342), + 6: uint16(27954), + 7: uint16(31168), + 8: uint16(31179), + 9: uint16(32066), + 10: uint16(32333), + 11: uint16(32722), + 12: uint16(33261), + 13: uint16(33311), + 14: uint16(33936), + 15: uint16(34886), + 16: uint16(35186), + 17: uint16(35728), + 18: uint16(36468), + 19: uint16(36655), + 20: uint16(36913), + 21: uint16(37195), + 22: uint16(37228), + 23: uint16(38598), + 24: uint16(37276), + 25: uint16(20160), + 26: uint16(20303), + 27: uint16(20805), + 28: uint16(21313), + 29: uint16(24467), + 30: uint16(25102), + 31: uint16(26580), + 32: uint16(27713), + 33: uint16(28171), + 34: uint16(29539), + 35: uint16(32294), + 36: uint16(37325), + 37: uint16(37507), + 38: uint16(21460), + 39: uint16(22809), + 40: uint16(23487), + 41: uint16(28113), + 42: uint16(31069), + 43: uint16(32302), + 44: uint16(31899), + 45: uint16(22654), + 46: uint16(29087), + 47: uint16(20986), + 48: uint16(34899), + 49: uint16(36848), + 50: uint16(20426), + 51: uint16(23803), + 52: uint16(26149), + 53: uint16(30636), + 54: uint16(31459), + 55: uint16(33308), + 56: uint16(39423), + 57: uint16(20934), + 58: uint16(24490), + 59: uint16(26092), + 60: uint16(26991), + 61: uint16(27529), + 62: uint16(28147), + 63: uint16(28310), + 64: uint16(28516), + 65: uint16(30462), + 66: uint16(32020), + 67: uint16(24033), + 68: uint16(36981), + 69: uint16(37255), + 70: uint16(38918), + 71: uint16(20966), + 72: uint16(21021), + 73: uint16(25152), + 74: uint16(26257), + 75: uint16(26329), + 76: uint16(28186), + 77: uint16(24246), + 78: uint16(32210), + 79: uint16(32626), + 80: uint16(26360), + 81: uint16(34223), + 82: uint16(34295), + 83: uint16(35576), + 84: uint16(21161), + 85: uint16(21465), + 86: uint16(22899), + 87: uint16(24207), + 88: uint16(24464), + 89: uint16(24661), + 90: uint16(37604), + 91: uint16(38500), + 92: uint16(20663), + 93: uint16(20767), + }, + 29: { + 0: uint16(21213), + 1: uint16(21280), + 2: uint16(21319), + 3: uint16(21484), + 4: uint16(21736), + 5: uint16(21830), + 6: uint16(21809), + 7: uint16(22039), + 8: uint16(22888), + 9: uint16(22974), + 10: uint16(23100), + 11: uint16(23477), + 12: uint16(23558), + 13: uint16(23567), + 14: uint16(23569), + 15: uint16(23578), + 16: uint16(24196), + 17: uint16(24202), + 18: uint16(24288), + 19: uint16(24432), + 20: uint16(25215), + 21: uint16(25220), + 22: uint16(25307), + 23: uint16(25484), + 24: uint16(25463), + 25: uint16(26119), + 26: uint16(26124), + 27: uint16(26157), + 28: uint16(26230), + 29: uint16(26494), + 30: uint16(26786), + 31: uint16(27167), + 32: uint16(27189), + 33: uint16(27836), + 34: uint16(28040), + 35: uint16(28169), + 36: uint16(28248), + 37: uint16(28988), + 38: uint16(28966), + 39: uint16(29031), + 40: uint16(30151), + 41: uint16(30465), + 42: uint16(30813), + 43: uint16(30977), + 44: uint16(31077), + 45: uint16(31216), + 46: uint16(31456), + 47: uint16(31505), + 48: uint16(31911), + 49: uint16(32057), + 50: uint16(32918), + 51: uint16(33750), + 52: uint16(33931), + 53: uint16(34121), + 54: uint16(34909), + 55: uint16(35059), + 56: uint16(35359), + 57: uint16(35388), + 58: uint16(35412), + 59: uint16(35443), + 60: uint16(35937), + 61: uint16(36062), + 62: uint16(37284), + 63: uint16(37478), + 64: uint16(37758), + 65: uint16(37912), + 66: uint16(38556), + 67: uint16(38808), + 68: uint16(19978), + 69: uint16(19976), + 70: uint16(19998), + 71: uint16(20055), + 72: uint16(20887), + 73: uint16(21104), + 74: uint16(22478), + 75: uint16(22580), + 76: uint16(22732), + 77: uint16(23330), + 78: uint16(24120), + 79: uint16(24773), + 80: uint16(25854), + 81: uint16(26465), + 82: uint16(26454), + 83: uint16(27972), + 84: uint16(29366), + 85: uint16(30067), + 86: uint16(31331), + 87: uint16(33976), + 88: uint16(35698), + 89: uint16(37304), + 90: uint16(37664), + 91: uint16(22065), + 92: uint16(22516), + 93: uint16(39166), + }, + 30: { + 0: uint16(25325), + 1: uint16(26893), + 2: uint16(27542), + 3: uint16(29165), + 4: uint16(32340), + 5: uint16(32887), + 6: uint16(33394), + 7: uint16(35302), + 8: uint16(39135), + 9: uint16(34645), + 10: uint16(36785), + 11: uint16(23611), + 12: uint16(20280), + 13: uint16(20449), + 14: uint16(20405), + 15: uint16(21767), + 16: uint16(23072), + 17: uint16(23517), + 18: uint16(23529), + 19: uint16(24515), + 20: uint16(24910), + 21: uint16(25391), + 22: uint16(26032), + 23: uint16(26187), + 24: uint16(26862), + 25: uint16(27035), + 26: uint16(28024), + 27: uint16(28145), + 28: uint16(30003), + 29: uint16(30137), + 30: uint16(30495), + 31: uint16(31070), + 32: uint16(31206), + 33: uint16(32051), + 34: uint16(33251), + 35: uint16(33455), + 36: uint16(34218), + 37: uint16(35242), + 38: uint16(35386), + 39: uint16(36523), + 40: uint16(36763), + 41: uint16(36914), + 42: uint16(37341), + 43: uint16(38663), + 44: uint16(20154), + 45: uint16(20161), + 46: uint16(20995), + 47: uint16(22645), + 48: uint16(22764), + 49: uint16(23563), + 50: uint16(29978), + 51: uint16(23613), + 52: uint16(33102), + 53: uint16(35338), + 54: uint16(36805), + 55: uint16(38499), + 56: uint16(38765), + 57: uint16(31525), + 58: uint16(35535), + 59: uint16(38920), + 60: uint16(37218), + 61: uint16(22259), + 62: uint16(21416), + 63: uint16(36887), + 64: uint16(21561), + 65: uint16(22402), + 66: uint16(24101), + 67: uint16(25512), + 68: uint16(27700), + 69: uint16(28810), + 70: uint16(30561), + 71: uint16(31883), + 72: uint16(32736), + 73: uint16(34928), + 74: uint16(36930), + 75: uint16(37204), + 76: uint16(37648), + 77: uint16(37656), + 78: uint16(38543), + 79: uint16(29790), + 80: uint16(39620), + 81: uint16(23815), + 82: uint16(23913), + 83: uint16(25968), + 84: uint16(26530), + 85: uint16(36264), + 86: uint16(38619), + 87: uint16(25454), + 88: uint16(26441), + 89: uint16(26905), + 90: uint16(33733), + 91: uint16(38935), + 92: uint16(38592), + 93: uint16(35070), + }, + 31: { + 0: uint16(28548), + 1: uint16(25722), + 2: uint16(23544), + 3: uint16(19990), + 4: uint16(28716), + 5: uint16(30045), + 6: uint16(26159), + 7: uint16(20932), + 8: uint16(21046), + 9: uint16(21218), + 10: uint16(22995), + 11: uint16(24449), + 12: uint16(24615), + 13: uint16(25104), + 14: uint16(25919), + 15: uint16(25972), + 16: uint16(26143), + 17: uint16(26228), + 18: uint16(26866), + 19: uint16(26646), + 20: uint16(27491), + 21: uint16(28165), + 22: uint16(29298), + 23: uint16(29983), + 24: uint16(30427), + 25: uint16(31934), + 26: uint16(32854), + 27: uint16(22768), + 28: uint16(35069), + 29: uint16(35199), + 30: uint16(35488), + 31: uint16(35475), + 32: uint16(35531), + 33: uint16(36893), + 34: uint16(37266), + 35: uint16(38738), + 36: uint16(38745), + 37: uint16(25993), + 38: uint16(31246), + 39: uint16(33030), + 40: uint16(38587), + 41: uint16(24109), + 42: uint16(24796), + 43: uint16(25114), + 44: uint16(26021), + 45: uint16(26132), + 46: uint16(26512), + 47: uint16(30707), + 48: uint16(31309), + 49: uint16(31821), + 50: uint16(32318), + 51: uint16(33034), + 52: uint16(36012), + 53: uint16(36196), + 54: uint16(36321), + 55: uint16(36447), + 56: uint16(30889), + 57: uint16(20999), + 58: uint16(25305), + 59: uint16(25509), + 60: uint16(25666), + 61: uint16(25240), + 62: uint16(35373), + 63: uint16(31363), + 64: uint16(31680), + 65: uint16(35500), + 66: uint16(38634), + 67: uint16(32118), + 68: uint16(33292), + 69: uint16(34633), + 70: uint16(20185), + 71: uint16(20808), + 72: uint16(21315), + 73: uint16(21344), + 74: uint16(23459), + 75: uint16(23554), + 76: uint16(23574), + 77: uint16(24029), + 78: uint16(25126), + 79: uint16(25159), + 80: uint16(25776), + 81: uint16(26643), + 82: uint16(26676), + 83: uint16(27849), + 84: uint16(27973), + 85: uint16(27927), + 86: uint16(26579), + 87: uint16(28508), + 88: uint16(29006), + 89: uint16(29053), + 90: uint16(26059), + 91: uint16(31359), + 92: uint16(31661), + 93: uint16(32218), + }, + 32: { + 0: uint16(32330), + 1: uint16(32680), + 2: uint16(33146), + 3: uint16(33307), + 4: uint16(33337), + 5: uint16(34214), + 6: uint16(35438), + 7: uint16(36046), + 8: uint16(36341), + 9: uint16(36984), + 10: uint16(36983), + 11: uint16(37549), + 12: uint16(37521), + 13: uint16(38275), + 14: uint16(39854), + 15: uint16(21069), + 16: uint16(21892), + 17: uint16(28472), + 18: uint16(28982), + 19: uint16(20840), + 20: uint16(31109), + 21: uint16(32341), + 22: uint16(33203), + 23: uint16(31950), + 24: uint16(22092), + 25: uint16(22609), + 26: uint16(23720), + 27: uint16(25514), + 28: uint16(26366), + 29: uint16(26365), + 30: uint16(26970), + 31: uint16(29401), + 32: uint16(30095), + 33: uint16(30094), + 34: uint16(30990), + 35: uint16(31062), + 36: uint16(31199), + 37: uint16(31895), + 38: uint16(32032), + 39: uint16(32068), + 40: uint16(34311), + 41: uint16(35380), + 42: uint16(38459), + 43: uint16(36961), + 44: uint16(40736), + 45: uint16(20711), + 46: uint16(21109), + 47: uint16(21452), + 48: uint16(21474), + 49: uint16(20489), + 50: uint16(21930), + 51: uint16(22766), + 52: uint16(22863), + 53: uint16(29245), + 54: uint16(23435), + 55: uint16(23652), + 56: uint16(21277), + 57: uint16(24803), + 58: uint16(24819), + 59: uint16(25436), + 60: uint16(25475), + 61: uint16(25407), + 62: uint16(25531), + 63: uint16(25805), + 64: uint16(26089), + 65: uint16(26361), + 66: uint16(24035), + 67: uint16(27085), + 68: uint16(27133), + 69: uint16(28437), + 70: uint16(29157), + 71: uint16(20105), + 72: uint16(30185), + 73: uint16(30456), + 74: uint16(31379), + 75: uint16(31967), + 76: uint16(32207), + 77: uint16(32156), + 78: uint16(32865), + 79: uint16(33609), + 80: uint16(33624), + 81: uint16(33900), + 82: uint16(33980), + 83: uint16(34299), + 84: uint16(35013), + 85: uint16(36208), + 86: uint16(36865), + 87: uint16(36973), + 88: uint16(37783), + 89: uint16(38684), + 90: uint16(39442), + 91: uint16(20687), + 92: uint16(22679), + 93: uint16(24974), + }, + 33: { + 0: uint16(33235), + 1: uint16(34101), + 2: uint16(36104), + 3: uint16(36896), + 4: uint16(20419), + 5: uint16(20596), + 6: uint16(21063), + 7: uint16(21363), + 8: uint16(24687), + 9: uint16(25417), + 10: uint16(26463), + 11: uint16(28204), + 12: uint16(36275), + 13: uint16(36895), + 14: uint16(20439), + 15: uint16(23646), + 16: uint16(36042), + 17: uint16(26063), + 18: uint16(32154), + 19: uint16(21330), + 20: uint16(34966), + 21: uint16(20854), + 22: uint16(25539), + 23: uint16(23384), + 24: uint16(23403), + 25: uint16(23562), + 26: uint16(25613), + 27: uint16(26449), + 28: uint16(36956), + 29: uint16(20182), + 30: uint16(22810), + 31: uint16(22826), + 32: uint16(27760), + 33: uint16(35409), + 34: uint16(21822), + 35: uint16(22549), + 36: uint16(22949), + 37: uint16(24816), + 38: uint16(25171), + 39: uint16(26561), + 40: uint16(33333), + 41: uint16(26965), + 42: uint16(38464), + 43: uint16(39364), + 44: uint16(39464), + 45: uint16(20307), + 46: uint16(22534), + 47: uint16(23550), + 48: uint16(32784), + 49: uint16(23729), + 50: uint16(24111), + 51: uint16(24453), + 52: uint16(24608), + 53: uint16(24907), + 54: uint16(25140), + 55: uint16(26367), + 56: uint16(27888), + 57: uint16(28382), + 58: uint16(32974), + 59: uint16(33151), + 60: uint16(33492), + 61: uint16(34955), + 62: uint16(36024), + 63: uint16(36864), + 64: uint16(36910), + 65: uint16(38538), + 66: uint16(40667), + 67: uint16(39899), + 68: uint16(20195), + 69: uint16(21488), + 70: uint16(22823), + 71: uint16(31532), + 72: uint16(37261), + 73: uint16(38988), + 74: uint16(40441), + 75: uint16(28381), + 76: uint16(28711), + 77: uint16(21331), + 78: uint16(21828), + 79: uint16(23429), + 80: uint16(25176), + 81: uint16(25246), + 82: uint16(25299), + 83: uint16(27810), + 84: uint16(28655), + 85: uint16(29730), + 86: uint16(35351), + 87: uint16(37944), + 88: uint16(28609), + 89: uint16(35582), + 90: uint16(33592), + 91: uint16(20967), + 92: uint16(34552), + 93: uint16(21482), + }, + 34: { + 0: uint16(21481), + 1: uint16(20294), + 2: uint16(36948), + 3: uint16(36784), + 4: uint16(22890), + 5: uint16(33073), + 6: uint16(24061), + 7: uint16(31466), + 8: uint16(36799), + 9: uint16(26842), + 10: uint16(35895), + 11: uint16(29432), + 12: uint16(40008), + 13: uint16(27197), + 14: uint16(35504), + 15: uint16(20025), + 16: uint16(21336), + 17: uint16(22022), + 18: uint16(22374), + 19: uint16(25285), + 20: uint16(25506), + 21: uint16(26086), + 22: uint16(27470), + 23: uint16(28129), + 24: uint16(28251), + 25: uint16(28845), + 26: uint16(30701), + 27: uint16(31471), + 28: uint16(31658), + 29: uint16(32187), + 30: uint16(32829), + 31: uint16(32966), + 32: uint16(34507), + 33: uint16(35477), + 34: uint16(37723), + 35: uint16(22243), + 36: uint16(22727), + 37: uint16(24382), + 38: uint16(26029), + 39: uint16(26262), + 40: uint16(27264), + 41: uint16(27573), + 42: uint16(30007), + 43: uint16(35527), + 44: uint16(20516), + 45: uint16(30693), + 46: uint16(22320), + 47: uint16(24347), + 48: uint16(24677), + 49: uint16(26234), + 50: uint16(27744), + 51: uint16(30196), + 52: uint16(31258), + 53: uint16(32622), + 54: uint16(33268), + 55: uint16(34584), + 56: uint16(36933), + 57: uint16(39347), + 58: uint16(31689), + 59: uint16(30044), + 60: uint16(31481), + 61: uint16(31569), + 62: uint16(33988), + 63: uint16(36880), + 64: uint16(31209), + 65: uint16(31378), + 66: uint16(33590), + 67: uint16(23265), + 68: uint16(30528), + 69: uint16(20013), + 70: uint16(20210), + 71: uint16(23449), + 72: uint16(24544), + 73: uint16(25277), + 74: uint16(26172), + 75: uint16(26609), + 76: uint16(27880), + 77: uint16(34411), + 78: uint16(34935), + 79: uint16(35387), + 80: uint16(37198), + 81: uint16(37619), + 82: uint16(39376), + 83: uint16(27159), + 84: uint16(28710), + 85: uint16(29482), + 86: uint16(33511), + 87: uint16(33879), + 88: uint16(36015), + 89: uint16(19969), + 90: uint16(20806), + 91: uint16(20939), + 92: uint16(21899), + 93: uint16(23541), + }, + 35: { + 0: uint16(24086), + 1: uint16(24115), + 2: uint16(24193), + 3: uint16(24340), + 4: uint16(24373), + 5: uint16(24427), + 6: uint16(24500), + 7: uint16(25074), + 8: uint16(25361), + 9: uint16(26274), + 10: uint16(26397), + 11: uint16(28526), + 12: uint16(29266), + 13: uint16(30010), + 14: uint16(30522), + 15: uint16(32884), + 16: uint16(33081), + 17: uint16(33144), + 18: uint16(34678), + 19: uint16(35519), + 20: uint16(35548), + 21: uint16(36229), + 22: uint16(36339), + 23: uint16(37530), + 24: uint16(38263), + 25: uint16(38914), + 26: uint16(40165), + 27: uint16(21189), + 28: uint16(25431), + 29: uint16(30452), + 30: uint16(26389), + 31: uint16(27784), + 32: uint16(29645), + 33: uint16(36035), + 34: uint16(37806), + 35: uint16(38515), + 36: uint16(27941), + 37: uint16(22684), + 38: uint16(26894), + 39: uint16(27084), + 40: uint16(36861), + 41: uint16(37786), + 42: uint16(30171), + 43: uint16(36890), + 44: uint16(22618), + 45: uint16(26626), + 46: uint16(25524), + 47: uint16(27131), + 48: uint16(20291), + 49: uint16(28460), + 50: uint16(26584), + 51: uint16(36795), + 52: uint16(34086), + 53: uint16(32180), + 54: uint16(37716), + 55: uint16(26943), + 56: uint16(28528), + 57: uint16(22378), + 58: uint16(22775), + 59: uint16(23340), + 60: uint16(32044), + 61: uint16(29226), + 62: uint16(21514), + 63: uint16(37347), + 64: uint16(40372), + 65: uint16(20141), + 66: uint16(20302), + 67: uint16(20572), + 68: uint16(20597), + 69: uint16(21059), + 70: uint16(35998), + 71: uint16(21576), + 72: uint16(22564), + 73: uint16(23450), + 74: uint16(24093), + 75: uint16(24213), + 76: uint16(24237), + 77: uint16(24311), + 78: uint16(24351), + 79: uint16(24716), + 80: uint16(25269), + 81: uint16(25402), + 82: uint16(25552), + 83: uint16(26799), + 84: uint16(27712), + 85: uint16(30855), + 86: uint16(31118), + 87: uint16(31243), + 88: uint16(32224), + 89: uint16(33351), + 90: uint16(35330), + 91: uint16(35558), + 92: uint16(36420), + 93: uint16(36883), + }, + 36: { + 0: uint16(37048), + 1: uint16(37165), + 2: uint16(37336), + 3: uint16(40718), + 4: uint16(27877), + 5: uint16(25688), + 6: uint16(25826), + 7: uint16(25973), + 8: uint16(28404), + 9: uint16(30340), + 10: uint16(31515), + 11: uint16(36969), + 12: uint16(37841), + 13: uint16(28346), + 14: uint16(21746), + 15: uint16(24505), + 16: uint16(25764), + 17: uint16(36685), + 18: uint16(36845), + 19: uint16(37444), + 20: uint16(20856), + 21: uint16(22635), + 22: uint16(22825), + 23: uint16(23637), + 24: uint16(24215), + 25: uint16(28155), + 26: uint16(32399), + 27: uint16(29980), + 28: uint16(36028), + 29: uint16(36578), + 30: uint16(39003), + 31: uint16(28857), + 32: uint16(20253), + 33: uint16(27583), + 34: uint16(28593), + 35: uint16(30000), + 36: uint16(38651), + 37: uint16(20814), + 38: uint16(21520), + 39: uint16(22581), + 40: uint16(22615), + 41: uint16(22956), + 42: uint16(23648), + 43: uint16(24466), + 44: uint16(26007), + 45: uint16(26460), + 46: uint16(28193), + 47: uint16(30331), + 48: uint16(33759), + 49: uint16(36077), + 50: uint16(36884), + 51: uint16(37117), + 52: uint16(37709), + 53: uint16(30757), + 54: uint16(30778), + 55: uint16(21162), + 56: uint16(24230), + 57: uint16(22303), + 58: uint16(22900), + 59: uint16(24594), + 60: uint16(20498), + 61: uint16(20826), + 62: uint16(20908), + 63: uint16(20941), + 64: uint16(20992), + 65: uint16(21776), + 66: uint16(22612), + 67: uint16(22616), + 68: uint16(22871), + 69: uint16(23445), + 70: uint16(23798), + 71: uint16(23947), + 72: uint16(24764), + 73: uint16(25237), + 74: uint16(25645), + 75: uint16(26481), + 76: uint16(26691), + 77: uint16(26812), + 78: uint16(26847), + 79: uint16(30423), + 80: uint16(28120), + 81: uint16(28271), + 82: uint16(28059), + 83: uint16(28783), + 84: uint16(29128), + 85: uint16(24403), + 86: uint16(30168), + 87: uint16(31095), + 88: uint16(31561), + 89: uint16(31572), + 90: uint16(31570), + 91: uint16(31958), + 92: uint16(32113), + 93: uint16(21040), + }, + 37: { + 0: uint16(33891), + 1: uint16(34153), + 2: uint16(34276), + 3: uint16(35342), + 4: uint16(35588), + 5: uint16(35910), + 6: uint16(36367), + 7: uint16(36867), + 8: uint16(36879), + 9: uint16(37913), + 10: uint16(38518), + 11: uint16(38957), + 12: uint16(39472), + 13: uint16(38360), + 14: uint16(20685), + 15: uint16(21205), + 16: uint16(21516), + 17: uint16(22530), + 18: uint16(23566), + 19: uint16(24999), + 20: uint16(25758), + 21: uint16(27934), + 22: uint16(30643), + 23: uint16(31461), + 24: uint16(33012), + 25: uint16(33796), + 26: uint16(36947), + 27: uint16(37509), + 28: uint16(23776), + 29: uint16(40199), + 30: uint16(21311), + 31: uint16(24471), + 32: uint16(24499), + 33: uint16(28060), + 34: uint16(29305), + 35: uint16(30563), + 36: uint16(31167), + 37: uint16(31716), + 38: uint16(27602), + 39: uint16(29420), + 40: uint16(35501), + 41: uint16(26627), + 42: uint16(27233), + 43: uint16(20984), + 44: uint16(31361), + 45: uint16(26932), + 46: uint16(23626), + 47: uint16(40182), + 48: uint16(33515), + 49: uint16(23493), + 50: uint16(37193), + 51: uint16(28702), + 52: uint16(22136), + 53: uint16(23663), + 54: uint16(24775), + 55: uint16(25958), + 56: uint16(27788), + 57: uint16(35930), + 58: uint16(36929), + 59: uint16(38931), + 60: uint16(21585), + 61: uint16(26311), + 62: uint16(37389), + 63: uint16(22856), + 64: uint16(37027), + 65: uint16(20869), + 66: uint16(20045), + 67: uint16(20970), + 68: uint16(34201), + 69: uint16(35598), + 70: uint16(28760), + 71: uint16(25466), + 72: uint16(37707), + 73: uint16(26978), + 74: uint16(39348), + 75: uint16(32260), + 76: uint16(30071), + 77: uint16(21335), + 78: uint16(26976), + 79: uint16(36575), + 80: uint16(38627), + 81: uint16(27741), + 82: uint16(20108), + 83: uint16(23612), + 84: uint16(24336), + 85: uint16(36841), + 86: uint16(21250), + 87: uint16(36049), + 88: uint16(32905), + 89: uint16(34425), + 90: uint16(24319), + 91: uint16(26085), + 92: uint16(20083), + 93: uint16(20837), + }, + 38: { + 0: uint16(22914), + 1: uint16(23615), + 2: uint16(38894), + 3: uint16(20219), + 4: uint16(22922), + 5: uint16(24525), + 6: uint16(35469), + 7: uint16(28641), + 8: uint16(31152), + 9: uint16(31074), + 10: uint16(23527), + 11: uint16(33905), + 12: uint16(29483), + 13: uint16(29105), + 14: uint16(24180), + 15: uint16(24565), + 16: uint16(25467), + 17: uint16(25754), + 18: uint16(29123), + 19: uint16(31896), + 20: uint16(20035), + 21: uint16(24316), + 22: uint16(20043), + 23: uint16(22492), + 24: uint16(22178), + 25: uint16(24745), + 26: uint16(28611), + 27: uint16(32013), + 28: uint16(33021), + 29: uint16(33075), + 30: uint16(33215), + 31: uint16(36786), + 32: uint16(35223), + 33: uint16(34468), + 34: uint16(24052), + 35: uint16(25226), + 36: uint16(25773), + 37: uint16(35207), + 38: uint16(26487), + 39: uint16(27874), + 40: uint16(27966), + 41: uint16(29750), + 42: uint16(30772), + 43: uint16(23110), + 44: uint16(32629), + 45: uint16(33453), + 46: uint16(39340), + 47: uint16(20467), + 48: uint16(24259), + 49: uint16(25309), + 50: uint16(25490), + 51: uint16(25943), + 52: uint16(26479), + 53: uint16(30403), + 54: uint16(29260), + 55: uint16(32972), + 56: uint16(32954), + 57: uint16(36649), + 58: uint16(37197), + 59: uint16(20493), + 60: uint16(22521), + 61: uint16(23186), + 62: uint16(26757), + 63: uint16(26995), + 64: uint16(29028), + 65: uint16(29437), + 66: uint16(36023), + 67: uint16(22770), + 68: uint16(36064), + 69: uint16(38506), + 70: uint16(36889), + 71: uint16(34687), + 72: uint16(31204), + 73: uint16(30695), + 74: uint16(33833), + 75: uint16(20271), + 76: uint16(21093), + 77: uint16(21338), + 78: uint16(25293), + 79: uint16(26575), + 80: uint16(27850), + 81: uint16(30333), + 82: uint16(31636), + 83: uint16(31893), + 84: uint16(33334), + 85: uint16(34180), + 86: uint16(36843), + 87: uint16(26333), + 88: uint16(28448), + 89: uint16(29190), + 90: uint16(32283), + 91: uint16(33707), + 92: uint16(39361), + 93: uint16(40614), + }, + 39: { + 0: uint16(20989), + 1: uint16(31665), + 2: uint16(30834), + 3: uint16(31672), + 4: uint16(32903), + 5: uint16(31560), + 6: uint16(27368), + 7: uint16(24161), + 8: uint16(32908), + 9: uint16(30033), + 10: uint16(30048), + 11: uint16(20843), + 12: uint16(37474), + 13: uint16(28300), + 14: uint16(30330), + 15: uint16(37271), + 16: uint16(39658), + 17: uint16(20240), + 18: uint16(32624), + 19: uint16(25244), + 20: uint16(31567), + 21: uint16(38309), + 22: uint16(40169), + 23: uint16(22138), + 24: uint16(22617), + 25: uint16(34532), + 26: uint16(38588), + 27: uint16(20276), + 28: uint16(21028), + 29: uint16(21322), + 30: uint16(21453), + 31: uint16(21467), + 32: uint16(24070), + 33: uint16(25644), + 34: uint16(26001), + 35: uint16(26495), + 36: uint16(27710), + 37: uint16(27726), + 38: uint16(29256), + 39: uint16(29359), + 40: uint16(29677), + 41: uint16(30036), + 42: uint16(32321), + 43: uint16(33324), + 44: uint16(34281), + 45: uint16(36009), + 46: uint16(31684), + 47: uint16(37318), + 48: uint16(29033), + 49: uint16(38930), + 50: uint16(39151), + 51: uint16(25405), + 52: uint16(26217), + 53: uint16(30058), + 54: uint16(30436), + 55: uint16(30928), + 56: uint16(34115), + 57: uint16(34542), + 58: uint16(21290), + 59: uint16(21329), + 60: uint16(21542), + 61: uint16(22915), + 62: uint16(24199), + 63: uint16(24444), + 64: uint16(24754), + 65: uint16(25161), + 66: uint16(25209), + 67: uint16(25259), + 68: uint16(26000), + 69: uint16(27604), + 70: uint16(27852), + 71: uint16(30130), + 72: uint16(30382), + 73: uint16(30865), + 74: uint16(31192), + 75: uint16(32203), + 76: uint16(32631), + 77: uint16(32933), + 78: uint16(34987), + 79: uint16(35513), + 80: uint16(36027), + 81: uint16(36991), + 82: uint16(38750), + 83: uint16(39131), + 84: uint16(27147), + 85: uint16(31800), + 86: uint16(20633), + 87: uint16(23614), + 88: uint16(24494), + 89: uint16(26503), + 90: uint16(27608), + 91: uint16(29749), + 92: uint16(30473), + 93: uint16(32654), + }, + 40: { + 0: uint16(40763), + 1: uint16(26570), + 2: uint16(31255), + 3: uint16(21305), + 4: uint16(30091), + 5: uint16(39661), + 6: uint16(24422), + 7: uint16(33181), + 8: uint16(33777), + 9: uint16(32920), + 10: uint16(24380), + 11: uint16(24517), + 12: uint16(30050), + 13: uint16(31558), + 14: uint16(36924), + 15: uint16(26727), + 16: uint16(23019), + 17: uint16(23195), + 18: uint16(32016), + 19: uint16(30334), + 20: uint16(35628), + 21: uint16(20469), + 22: uint16(24426), + 23: uint16(27161), + 24: uint16(27703), + 25: uint16(28418), + 26: uint16(29922), + 27: uint16(31080), + 28: uint16(34920), + 29: uint16(35413), + 30: uint16(35961), + 31: uint16(24287), + 32: uint16(25551), + 33: uint16(30149), + 34: uint16(31186), + 35: uint16(33495), + 36: uint16(37672), + 37: uint16(37618), + 38: uint16(33948), + 39: uint16(34541), + 40: uint16(39981), + 41: uint16(21697), + 42: uint16(24428), + 43: uint16(25996), + 44: uint16(27996), + 45: uint16(28693), + 46: uint16(36007), + 47: uint16(36051), + 48: uint16(38971), + 49: uint16(25935), + 50: uint16(29942), + 51: uint16(19981), + 52: uint16(20184), + 53: uint16(22496), + 54: uint16(22827), + 55: uint16(23142), + 56: uint16(23500), + 57: uint16(20904), + 58: uint16(24067), + 59: uint16(24220), + 60: uint16(24598), + 61: uint16(25206), + 62: uint16(25975), + 63: uint16(26023), + 64: uint16(26222), + 65: uint16(28014), + 66: uint16(29238), + 67: uint16(31526), + 68: uint16(33104), + 69: uint16(33178), + 70: uint16(33433), + 71: uint16(35676), + 72: uint16(36000), + 73: uint16(36070), + 74: uint16(36212), + 75: uint16(38428), + 76: uint16(38468), + 77: uint16(20398), + 78: uint16(25771), + 79: uint16(27494), + 80: uint16(33310), + 81: uint16(33889), + 82: uint16(34154), + 83: uint16(37096), + 84: uint16(23553), + 85: uint16(26963), + 86: uint16(39080), + 87: uint16(33914), + 88: uint16(34135), + 89: uint16(20239), + 90: uint16(21103), + 91: uint16(24489), + 92: uint16(24133), + 93: uint16(26381), + }, + 41: { + 0: uint16(31119), + 1: uint16(33145), + 2: uint16(35079), + 3: uint16(35206), + 4: uint16(28149), + 5: uint16(24343), + 6: uint16(25173), + 7: uint16(27832), + 8: uint16(20175), + 9: uint16(29289), + 10: uint16(39826), + 11: uint16(20998), + 12: uint16(21563), + 13: uint16(22132), + 14: uint16(22707), + 15: uint16(24996), + 16: uint16(25198), + 17: uint16(28954), + 18: uint16(22894), + 19: uint16(31881), + 20: uint16(31966), + 21: uint16(32027), + 22: uint16(38640), + 23: uint16(25991), + 24: uint16(32862), + 25: uint16(19993), + 26: uint16(20341), + 27: uint16(20853), + 28: uint16(22592), + 29: uint16(24163), + 30: uint16(24179), + 31: uint16(24330), + 32: uint16(26564), + 33: uint16(20006), + 34: uint16(34109), + 35: uint16(38281), + 36: uint16(38491), + 37: uint16(31859), + 38: uint16(38913), + 39: uint16(20731), + 40: uint16(22721), + 41: uint16(30294), + 42: uint16(30887), + 43: uint16(21029), + 44: uint16(30629), + 45: uint16(34065), + 46: uint16(31622), + 47: uint16(20559), + 48: uint16(22793), + 49: uint16(29255), + 50: uint16(31687), + 51: uint16(32232), + 52: uint16(36794), + 53: uint16(36820), + 54: uint16(36941), + 55: uint16(20415), + 56: uint16(21193), + 57: uint16(23081), + 58: uint16(24321), + 59: uint16(38829), + 60: uint16(20445), + 61: uint16(33303), + 62: uint16(37610), + 63: uint16(22275), + 64: uint16(25429), + 65: uint16(27497), + 66: uint16(29995), + 67: uint16(35036), + 68: uint16(36628), + 69: uint16(31298), + 70: uint16(21215), + 71: uint16(22675), + 72: uint16(24917), + 73: uint16(25098), + 74: uint16(26286), + 75: uint16(27597), + 76: uint16(31807), + 77: uint16(33769), + 78: uint16(20515), + 79: uint16(20472), + 80: uint16(21253), + 81: uint16(21574), + 82: uint16(22577), + 83: uint16(22857), + 84: uint16(23453), + 85: uint16(23792), + 86: uint16(23791), + 87: uint16(23849), + 88: uint16(24214), + 89: uint16(25265), + 90: uint16(25447), + 91: uint16(25918), + 92: uint16(26041), + 93: uint16(26379), + }, + 42: { + 0: uint16(27861), + 1: uint16(27873), + 2: uint16(28921), + 3: uint16(30770), + 4: uint16(32299), + 5: uint16(32990), + 6: uint16(33459), + 7: uint16(33804), + 8: uint16(34028), + 9: uint16(34562), + 10: uint16(35090), + 11: uint16(35370), + 12: uint16(35914), + 13: uint16(37030), + 14: uint16(37586), + 15: uint16(39165), + 16: uint16(40179), + 17: uint16(40300), + 18: uint16(20047), + 19: uint16(20129), + 20: uint16(20621), + 21: uint16(21078), + 22: uint16(22346), + 23: uint16(22952), + 24: uint16(24125), + 25: uint16(24536), + 26: uint16(24537), + 27: uint16(25151), + 28: uint16(26292), + 29: uint16(26395), + 30: uint16(26576), + 31: uint16(26834), + 32: uint16(20882), + 33: uint16(32033), + 34: uint16(32938), + 35: uint16(33192), + 36: uint16(35584), + 37: uint16(35980), + 38: uint16(36031), + 39: uint16(37502), + 40: uint16(38450), + 41: uint16(21536), + 42: uint16(38956), + 43: uint16(21271), + 44: uint16(20693), + 45: uint16(21340), + 46: uint16(22696), + 47: uint16(25778), + 48: uint16(26420), + 49: uint16(29287), + 50: uint16(30566), + 51: uint16(31302), + 52: uint16(37350), + 53: uint16(21187), + 54: uint16(27809), + 55: uint16(27526), + 56: uint16(22528), + 57: uint16(24140), + 58: uint16(22868), + 59: uint16(26412), + 60: uint16(32763), + 61: uint16(20961), + 62: uint16(30406), + 63: uint16(25705), + 64: uint16(30952), + 65: uint16(39764), + 66: uint16(40635), + 67: uint16(22475), + 68: uint16(22969), + 69: uint16(26151), + 70: uint16(26522), + 71: uint16(27598), + 72: uint16(21737), + 73: uint16(27097), + 74: uint16(24149), + 75: uint16(33180), + 76: uint16(26517), + 77: uint16(39850), + 78: uint16(26622), + 79: uint16(40018), + 80: uint16(26717), + 81: uint16(20134), + 82: uint16(20451), + 83: uint16(21448), + 84: uint16(25273), + 85: uint16(26411), + 86: uint16(27819), + 87: uint16(36804), + 88: uint16(20397), + 89: uint16(32365), + 90: uint16(40639), + 91: uint16(19975), + 92: uint16(24930), + 93: uint16(28288), + }, + 43: { + 0: uint16(28459), + 1: uint16(34067), + 2: uint16(21619), + 3: uint16(26410), + 4: uint16(39749), + 5: uint16(24051), + 6: uint16(31637), + 7: uint16(23724), + 8: uint16(23494), + 9: uint16(34588), + 10: uint16(28234), + 11: uint16(34001), + 12: uint16(31252), + 13: uint16(33032), + 14: uint16(22937), + 15: uint16(31885), + 16: uint16(27665), + 17: uint16(30496), + 18: uint16(21209), + 19: uint16(22818), + 20: uint16(28961), + 21: uint16(29279), + 22: uint16(30683), + 23: uint16(38695), + 24: uint16(40289), + 25: uint16(26891), + 26: uint16(23167), + 27: uint16(23064), + 28: uint16(20901), + 29: uint16(21517), + 30: uint16(21629), + 31: uint16(26126), + 32: uint16(30431), + 33: uint16(36855), + 34: uint16(37528), + 35: uint16(40180), + 36: uint16(23018), + 37: uint16(29277), + 38: uint16(28357), + 39: uint16(20813), + 40: uint16(26825), + 41: uint16(32191), + 42: uint16(32236), + 43: uint16(38754), + 44: uint16(40634), + 45: uint16(25720), + 46: uint16(27169), + 47: uint16(33538), + 48: uint16(22916), + 49: uint16(23391), + 50: uint16(27611), + 51: uint16(29467), + 52: uint16(30450), + 53: uint16(32178), + 54: uint16(32791), + 55: uint16(33945), + 56: uint16(20786), + 57: uint16(26408), + 58: uint16(40665), + 59: uint16(30446), + 60: uint16(26466), + 61: uint16(21247), + 62: uint16(39173), + 63: uint16(23588), + 64: uint16(25147), + 65: uint16(31870), + 66: uint16(36016), + 67: uint16(21839), + 68: uint16(24758), + 69: uint16(32011), + 70: uint16(38272), + 71: uint16(21249), + 72: uint16(20063), + 73: uint16(20918), + 74: uint16(22812), + 75: uint16(29242), + 76: uint16(32822), + 77: uint16(37326), + 78: uint16(24357), + 79: uint16(30690), + 80: uint16(21380), + 81: uint16(24441), + 82: uint16(32004), + 83: uint16(34220), + 84: uint16(35379), + 85: uint16(36493), + 86: uint16(38742), + 87: uint16(26611), + 88: uint16(34222), + 89: uint16(37971), + 90: uint16(24841), + 91: uint16(24840), + 92: uint16(27833), + 93: uint16(30290), + }, + 44: { + 0: uint16(35565), + 1: uint16(36664), + 2: uint16(21807), + 3: uint16(20305), + 4: uint16(20778), + 5: uint16(21191), + 6: uint16(21451), + 7: uint16(23461), + 8: uint16(24189), + 9: uint16(24736), + 10: uint16(24962), + 11: uint16(25558), + 12: uint16(26377), + 13: uint16(26586), + 14: uint16(28263), + 15: uint16(28044), + 16: uint16(29494), + 17: uint16(29495), + 18: uint16(30001), + 19: uint16(31056), + 20: uint16(35029), + 21: uint16(35480), + 22: uint16(36938), + 23: uint16(37009), + 24: uint16(37109), + 25: uint16(38596), + 26: uint16(34701), + 27: uint16(22805), + 28: uint16(20104), + 29: uint16(20313), + 30: uint16(19982), + 31: uint16(35465), + 32: uint16(36671), + 33: uint16(38928), + 34: uint16(20653), + 35: uint16(24188), + 36: uint16(22934), + 37: uint16(23481), + 38: uint16(24248), + 39: uint16(25562), + 40: uint16(25594), + 41: uint16(25793), + 42: uint16(26332), + 43: uint16(26954), + 44: uint16(27096), + 45: uint16(27915), + 46: uint16(28342), + 47: uint16(29076), + 48: uint16(29992), + 49: uint16(31407), + 50: uint16(32650), + 51: uint16(32768), + 52: uint16(33865), + 53: uint16(33993), + 54: uint16(35201), + 55: uint16(35617), + 56: uint16(36362), + 57: uint16(36965), + 58: uint16(38525), + 59: uint16(39178), + 60: uint16(24958), + 61: uint16(25233), + 62: uint16(27442), + 63: uint16(27779), + 64: uint16(28020), + 65: uint16(32716), + 66: uint16(32764), + 67: uint16(28096), + 68: uint16(32645), + 69: uint16(34746), + 70: uint16(35064), + 71: uint16(26469), + 72: uint16(33713), + 73: uint16(38972), + 74: uint16(38647), + 75: uint16(27931), + 76: uint16(32097), + 77: uint16(33853), + 78: uint16(37226), + 79: uint16(20081), + 80: uint16(21365), + 81: uint16(23888), + 82: uint16(27396), + 83: uint16(28651), + 84: uint16(34253), + 85: uint16(34349), + 86: uint16(35239), + 87: uint16(21033), + 88: uint16(21519), + 89: uint16(23653), + 90: uint16(26446), + 91: uint16(26792), + 92: uint16(29702), + 93: uint16(29827), + }, + 45: { + 0: uint16(30178), + 1: uint16(35023), + 2: uint16(35041), + 3: uint16(37324), + 4: uint16(38626), + 5: uint16(38520), + 6: uint16(24459), + 7: uint16(29575), + 8: uint16(31435), + 9: uint16(33870), + 10: uint16(25504), + 11: uint16(30053), + 12: uint16(21129), + 13: uint16(27969), + 14: uint16(28316), + 15: uint16(29705), + 16: uint16(30041), + 17: uint16(30827), + 18: uint16(31890), + 19: uint16(38534), + 20: uint16(31452), + 21: uint16(40845), + 22: uint16(20406), + 23: uint16(24942), + 24: uint16(26053), + 25: uint16(34396), + 26: uint16(20102), + 27: uint16(20142), + 28: uint16(20698), + 29: uint16(20001), + 30: uint16(20940), + 31: uint16(23534), + 32: uint16(26009), + 33: uint16(26753), + 34: uint16(28092), + 35: uint16(29471), + 36: uint16(30274), + 37: uint16(30637), + 38: uint16(31260), + 39: uint16(31975), + 40: uint16(33391), + 41: uint16(35538), + 42: uint16(36988), + 43: uint16(37327), + 44: uint16(38517), + 45: uint16(38936), + 46: uint16(21147), + 47: uint16(32209), + 48: uint16(20523), + 49: uint16(21400), + 50: uint16(26519), + 51: uint16(28107), + 52: uint16(29136), + 53: uint16(29747), + 54: uint16(33256), + 55: uint16(36650), + 56: uint16(38563), + 57: uint16(40023), + 58: uint16(40607), + 59: uint16(29792), + 60: uint16(22593), + 61: uint16(28057), + 62: uint16(32047), + 63: uint16(39006), + 64: uint16(20196), + 65: uint16(20278), + 66: uint16(20363), + 67: uint16(20919), + 68: uint16(21169), + 69: uint16(23994), + 70: uint16(24604), + 71: uint16(29618), + 72: uint16(31036), + 73: uint16(33491), + 74: uint16(37428), + 75: uint16(38583), + 76: uint16(38646), + 77: uint16(38666), + 78: uint16(40599), + 79: uint16(40802), + 80: uint16(26278), + 81: uint16(27508), + 82: uint16(21015), + 83: uint16(21155), + 84: uint16(28872), + 85: uint16(35010), + 86: uint16(24265), + 87: uint16(24651), + 88: uint16(24976), + 89: uint16(28451), + 90: uint16(29001), + 91: uint16(31806), + 92: uint16(32244), + 93: uint16(32879), + }, + 46: { + 0: uint16(34030), + 1: uint16(36899), + 2: uint16(37676), + 3: uint16(21570), + 4: uint16(39791), + 5: uint16(27347), + 6: uint16(28809), + 7: uint16(36034), + 8: uint16(36335), + 9: uint16(38706), + 10: uint16(21172), + 11: uint16(23105), + 12: uint16(24266), + 13: uint16(24324), + 14: uint16(26391), + 15: uint16(27004), + 16: uint16(27028), + 17: uint16(28010), + 18: uint16(28431), + 19: uint16(29282), + 20: uint16(29436), + 21: uint16(31725), + 22: uint16(32769), + 23: uint16(32894), + 24: uint16(34635), + 25: uint16(37070), + 26: uint16(20845), + 27: uint16(40595), + 28: uint16(31108), + 29: uint16(32907), + 30: uint16(37682), + 31: uint16(35542), + 32: uint16(20525), + 33: uint16(21644), + 34: uint16(35441), + 35: uint16(27498), + 36: uint16(36036), + 37: uint16(33031), + 38: uint16(24785), + 39: uint16(26528), + 40: uint16(40434), + 41: uint16(20121), + 42: uint16(20120), + 43: uint16(39952), + 44: uint16(35435), + 45: uint16(34241), + 46: uint16(34152), + 47: uint16(26880), + 48: uint16(28286), + 49: uint16(30871), + 50: uint16(33109), + }, + 47: { + 0: uint16(24332), + 1: uint16(19984), + 2: uint16(19989), + 3: uint16(20010), + 4: uint16(20017), + 5: uint16(20022), + 6: uint16(20028), + 7: uint16(20031), + 8: uint16(20034), + 9: uint16(20054), + 10: uint16(20056), + 11: uint16(20098), + 12: uint16(20101), + 13: uint16(35947), + 14: uint16(20106), + 15: uint16(33298), + 16: uint16(24333), + 17: uint16(20110), + 18: uint16(20126), + 19: uint16(20127), + 20: uint16(20128), + 21: uint16(20130), + 22: uint16(20144), + 23: uint16(20147), + 24: uint16(20150), + 25: uint16(20174), + 26: uint16(20173), + 27: uint16(20164), + 28: uint16(20166), + 29: uint16(20162), + 30: uint16(20183), + 31: uint16(20190), + 32: uint16(20205), + 33: uint16(20191), + 34: uint16(20215), + 35: uint16(20233), + 36: uint16(20314), + 37: uint16(20272), + 38: uint16(20315), + 39: uint16(20317), + 40: uint16(20311), + 41: uint16(20295), + 42: uint16(20342), + 43: uint16(20360), + 44: uint16(20367), + 45: uint16(20376), + 46: uint16(20347), + 47: uint16(20329), + 48: uint16(20336), + 49: uint16(20369), + 50: uint16(20335), + 51: uint16(20358), + 52: uint16(20374), + 53: uint16(20760), + 54: uint16(20436), + 55: uint16(20447), + 56: uint16(20430), + 57: uint16(20440), + 58: uint16(20443), + 59: uint16(20433), + 60: uint16(20442), + 61: uint16(20432), + 62: uint16(20452), + 63: uint16(20453), + 64: uint16(20506), + 65: uint16(20520), + 66: uint16(20500), + 67: uint16(20522), + 68: uint16(20517), + 69: uint16(20485), + 70: uint16(20252), + 71: uint16(20470), + 72: uint16(20513), + 73: uint16(20521), + 74: uint16(20524), + 75: uint16(20478), + 76: uint16(20463), + 77: uint16(20497), + 78: uint16(20486), + 79: uint16(20547), + 80: uint16(20551), + 81: uint16(26371), + 82: uint16(20565), + 83: uint16(20560), + 84: uint16(20552), + 85: uint16(20570), + 86: uint16(20566), + 87: uint16(20588), + 88: uint16(20600), + 89: uint16(20608), + 90: uint16(20634), + 91: uint16(20613), + 92: uint16(20660), + 93: uint16(20658), + }, + 48: { + 0: uint16(20681), + 1: uint16(20682), + 2: uint16(20659), + 3: uint16(20674), + 4: uint16(20694), + 5: uint16(20702), + 6: uint16(20709), + 7: uint16(20717), + 8: uint16(20707), + 9: uint16(20718), + 10: uint16(20729), + 11: uint16(20725), + 12: uint16(20745), + 13: uint16(20737), + 14: uint16(20738), + 15: uint16(20758), + 16: uint16(20757), + 17: uint16(20756), + 18: uint16(20762), + 19: uint16(20769), + 20: uint16(20794), + 21: uint16(20791), + 22: uint16(20796), + 23: uint16(20795), + 24: uint16(20799), + 25: uint16(20800), + 26: uint16(20818), + 27: uint16(20812), + 28: uint16(20820), + 29: uint16(20834), + 30: uint16(31480), + 31: uint16(20841), + 32: uint16(20842), + 33: uint16(20846), + 34: uint16(20864), + 35: uint16(20866), + 36: uint16(22232), + 37: uint16(20876), + 38: uint16(20873), + 39: uint16(20879), + 40: uint16(20881), + 41: uint16(20883), + 42: uint16(20885), + 43: uint16(20886), + 44: uint16(20900), + 45: uint16(20902), + 46: uint16(20898), + 47: uint16(20905), + 48: uint16(20906), + 49: uint16(20907), + 50: uint16(20915), + 51: uint16(20913), + 52: uint16(20914), + 53: uint16(20912), + 54: uint16(20917), + 55: uint16(20925), + 56: uint16(20933), + 57: uint16(20937), + 58: uint16(20955), + 59: uint16(20960), + 60: uint16(34389), + 61: uint16(20969), + 62: uint16(20973), + 63: uint16(20976), + 64: uint16(20981), + 65: uint16(20990), + 66: uint16(20996), + 67: uint16(21003), + 68: uint16(21012), + 69: uint16(21006), + 70: uint16(21031), + 71: uint16(21034), + 72: uint16(21038), + 73: uint16(21043), + 74: uint16(21049), + 75: uint16(21071), + 76: uint16(21060), + 77: uint16(21067), + 78: uint16(21068), + 79: uint16(21086), + 80: uint16(21076), + 81: uint16(21098), + 82: uint16(21108), + 83: uint16(21097), + 84: uint16(21107), + 85: uint16(21119), + 86: uint16(21117), + 87: uint16(21133), + 88: uint16(21140), + 89: uint16(21138), + 90: uint16(21105), + 91: uint16(21128), + 92: uint16(21137), + 93: uint16(36776), + }, + 49: { + 0: uint16(36775), + 1: uint16(21164), + 2: uint16(21165), + 3: uint16(21180), + 4: uint16(21173), + 5: uint16(21185), + 6: uint16(21197), + 7: uint16(21207), + 8: uint16(21214), + 9: uint16(21219), + 10: uint16(21222), + 11: uint16(39149), + 12: uint16(21216), + 13: uint16(21235), + 14: uint16(21237), + 15: uint16(21240), + 16: uint16(21241), + 17: uint16(21254), + 18: uint16(21256), + 19: uint16(30008), + 20: uint16(21261), + 21: uint16(21264), + 22: uint16(21263), + 23: uint16(21269), + 24: uint16(21274), + 25: uint16(21283), + 26: uint16(21295), + 27: uint16(21297), + 28: uint16(21299), + 29: uint16(21304), + 30: uint16(21312), + 31: uint16(21318), + 32: uint16(21317), + 33: uint16(19991), + 34: uint16(21321), + 35: uint16(21325), + 36: uint16(20950), + 37: uint16(21342), + 38: uint16(21353), + 39: uint16(21358), + 40: uint16(22808), + 41: uint16(21371), + 42: uint16(21367), + 43: uint16(21378), + 44: uint16(21398), + 45: uint16(21408), + 46: uint16(21414), + 47: uint16(21413), + 48: uint16(21422), + 49: uint16(21424), + 50: uint16(21430), + 51: uint16(21443), + 52: uint16(31762), + 53: uint16(38617), + 54: uint16(21471), + 55: uint16(26364), + 56: uint16(29166), + 57: uint16(21486), + 58: uint16(21480), + 59: uint16(21485), + 60: uint16(21498), + 61: uint16(21505), + 62: uint16(21565), + 63: uint16(21568), + 64: uint16(21548), + 65: uint16(21549), + 66: uint16(21564), + 67: uint16(21550), + 68: uint16(21558), + 69: uint16(21545), + 70: uint16(21533), + 71: uint16(21582), + 72: uint16(21647), + 73: uint16(21621), + 74: uint16(21646), + 75: uint16(21599), + 76: uint16(21617), + 77: uint16(21623), + 78: uint16(21616), + 79: uint16(21650), + 80: uint16(21627), + 81: uint16(21632), + 82: uint16(21622), + 83: uint16(21636), + 84: uint16(21648), + 85: uint16(21638), + 86: uint16(21703), + 87: uint16(21666), + 88: uint16(21688), + 89: uint16(21669), + 90: uint16(21676), + 91: uint16(21700), + 92: uint16(21704), + 93: uint16(21672), + }, + 50: { + 0: uint16(21675), + 1: uint16(21698), + 2: uint16(21668), + 3: uint16(21694), + 4: uint16(21692), + 5: uint16(21720), + 6: uint16(21733), + 7: uint16(21734), + 8: uint16(21775), + 9: uint16(21780), + 10: uint16(21757), + 11: uint16(21742), + 12: uint16(21741), + 13: uint16(21754), + 14: uint16(21730), + 15: uint16(21817), + 16: uint16(21824), + 17: uint16(21859), + 18: uint16(21836), + 19: uint16(21806), + 20: uint16(21852), + 21: uint16(21829), + 22: uint16(21846), + 23: uint16(21847), + 24: uint16(21816), + 25: uint16(21811), + 26: uint16(21853), + 27: uint16(21913), + 28: uint16(21888), + 29: uint16(21679), + 30: uint16(21898), + 31: uint16(21919), + 32: uint16(21883), + 33: uint16(21886), + 34: uint16(21912), + 35: uint16(21918), + 36: uint16(21934), + 37: uint16(21884), + 38: uint16(21891), + 39: uint16(21929), + 40: uint16(21895), + 41: uint16(21928), + 42: uint16(21978), + 43: uint16(21957), + 44: uint16(21983), + 45: uint16(21956), + 46: uint16(21980), + 47: uint16(21988), + 48: uint16(21972), + 49: uint16(22036), + 50: uint16(22007), + 51: uint16(22038), + 52: uint16(22014), + 53: uint16(22013), + 54: uint16(22043), + 55: uint16(22009), + 56: uint16(22094), + 57: uint16(22096), + 58: uint16(29151), + 59: uint16(22068), + 60: uint16(22070), + 61: uint16(22066), + 62: uint16(22072), + 63: uint16(22123), + 64: uint16(22116), + 65: uint16(22063), + 66: uint16(22124), + 67: uint16(22122), + 68: uint16(22150), + 69: uint16(22144), + 70: uint16(22154), + 71: uint16(22176), + 72: uint16(22164), + 73: uint16(22159), + 74: uint16(22181), + 75: uint16(22190), + 76: uint16(22198), + 77: uint16(22196), + 78: uint16(22210), + 79: uint16(22204), + 80: uint16(22209), + 81: uint16(22211), + 82: uint16(22208), + 83: uint16(22216), + 84: uint16(22222), + 85: uint16(22225), + 86: uint16(22227), + 87: uint16(22231), + 88: uint16(22254), + 89: uint16(22265), + 90: uint16(22272), + 91: uint16(22271), + 92: uint16(22276), + 93: uint16(22281), + }, + 51: { + 0: uint16(22280), + 1: uint16(22283), + 2: uint16(22285), + 3: uint16(22291), + 4: uint16(22296), + 5: uint16(22294), + 6: uint16(21959), + 7: uint16(22300), + 8: uint16(22310), + 9: uint16(22327), + 10: uint16(22328), + 11: uint16(22350), + 12: uint16(22331), + 13: uint16(22336), + 14: uint16(22351), + 15: uint16(22377), + 16: uint16(22464), + 17: uint16(22408), + 18: uint16(22369), + 19: uint16(22399), + 20: uint16(22409), + 21: uint16(22419), + 22: uint16(22432), + 23: uint16(22451), + 24: uint16(22436), + 25: uint16(22442), + 26: uint16(22448), + 27: uint16(22467), + 28: uint16(22470), + 29: uint16(22484), + 30: uint16(22482), + 31: uint16(22483), + 32: uint16(22538), + 33: uint16(22486), + 34: uint16(22499), + 35: uint16(22539), + 36: uint16(22553), + 37: uint16(22557), + 38: uint16(22642), + 39: uint16(22561), + 40: uint16(22626), + 41: uint16(22603), + 42: uint16(22640), + 43: uint16(27584), + 44: uint16(22610), + 45: uint16(22589), + 46: uint16(22649), + 47: uint16(22661), + 48: uint16(22713), + 49: uint16(22687), + 50: uint16(22699), + 51: uint16(22714), + 52: uint16(22750), + 53: uint16(22715), + 54: uint16(22712), + 55: uint16(22702), + 56: uint16(22725), + 57: uint16(22739), + 58: uint16(22737), + 59: uint16(22743), + 60: uint16(22745), + 61: uint16(22744), + 62: uint16(22757), + 63: uint16(22748), + 64: uint16(22756), + 65: uint16(22751), + 66: uint16(22767), + 67: uint16(22778), + 68: uint16(22777), + 69: uint16(22779), + 70: uint16(22780), + 71: uint16(22781), + 72: uint16(22786), + 73: uint16(22794), + 74: uint16(22800), + 75: uint16(22811), + 76: uint16(26790), + 77: uint16(22821), + 78: uint16(22828), + 79: uint16(22829), + 80: uint16(22834), + 81: uint16(22840), + 82: uint16(22846), + 83: uint16(31442), + 84: uint16(22869), + 85: uint16(22864), + 86: uint16(22862), + 87: uint16(22874), + 88: uint16(22872), + 89: uint16(22882), + 90: uint16(22880), + 91: uint16(22887), + 92: uint16(22892), + 93: uint16(22889), + }, + 52: { + 0: uint16(22904), + 1: uint16(22913), + 2: uint16(22941), + 3: uint16(20318), + 4: uint16(20395), + 5: uint16(22947), + 6: uint16(22962), + 7: uint16(22982), + 8: uint16(23016), + 9: uint16(23004), + 10: uint16(22925), + 11: uint16(23001), + 12: uint16(23002), + 13: uint16(23077), + 14: uint16(23071), + 15: uint16(23057), + 16: uint16(23068), + 17: uint16(23049), + 18: uint16(23066), + 19: uint16(23104), + 20: uint16(23148), + 21: uint16(23113), + 22: uint16(23093), + 23: uint16(23094), + 24: uint16(23138), + 25: uint16(23146), + 26: uint16(23194), + 27: uint16(23228), + 28: uint16(23230), + 29: uint16(23243), + 30: uint16(23234), + 31: uint16(23229), + 32: uint16(23267), + 33: uint16(23255), + 34: uint16(23270), + 35: uint16(23273), + 36: uint16(23254), + 37: uint16(23290), + 38: uint16(23291), + 39: uint16(23308), + 40: uint16(23307), + 41: uint16(23318), + 42: uint16(23346), + 43: uint16(23248), + 44: uint16(23338), + 45: uint16(23350), + 46: uint16(23358), + 47: uint16(23363), + 48: uint16(23365), + 49: uint16(23360), + 50: uint16(23377), + 51: uint16(23381), + 52: uint16(23386), + 53: uint16(23387), + 54: uint16(23397), + 55: uint16(23401), + 56: uint16(23408), + 57: uint16(23411), + 58: uint16(23413), + 59: uint16(23416), + 60: uint16(25992), + 61: uint16(23418), + 62: uint16(23424), + 63: uint16(23427), + 64: uint16(23462), + 65: uint16(23480), + 66: uint16(23491), + 67: uint16(23495), + 68: uint16(23497), + 69: uint16(23508), + 70: uint16(23504), + 71: uint16(23524), + 72: uint16(23526), + 73: uint16(23522), + 74: uint16(23518), + 75: uint16(23525), + 76: uint16(23531), + 77: uint16(23536), + 78: uint16(23542), + 79: uint16(23539), + 80: uint16(23557), + 81: uint16(23559), + 82: uint16(23560), + 83: uint16(23565), + 84: uint16(23571), + 85: uint16(23584), + 86: uint16(23586), + 87: uint16(23592), + 88: uint16(23608), + 89: uint16(23609), + 90: uint16(23617), + 91: uint16(23622), + 92: uint16(23630), + 93: uint16(23635), + }, + 53: { + 0: uint16(23632), + 1: uint16(23631), + 2: uint16(23409), + 3: uint16(23660), + 4: uint16(23662), + 5: uint16(20066), + 6: uint16(23670), + 7: uint16(23673), + 8: uint16(23692), + 9: uint16(23697), + 10: uint16(23700), + 11: uint16(22939), + 12: uint16(23723), + 13: uint16(23739), + 14: uint16(23734), + 15: uint16(23740), + 16: uint16(23735), + 17: uint16(23749), + 18: uint16(23742), + 19: uint16(23751), + 20: uint16(23769), + 21: uint16(23785), + 22: uint16(23805), + 23: uint16(23802), + 24: uint16(23789), + 25: uint16(23948), + 26: uint16(23786), + 27: uint16(23819), + 28: uint16(23829), + 29: uint16(23831), + 30: uint16(23900), + 31: uint16(23839), + 32: uint16(23835), + 33: uint16(23825), + 34: uint16(23828), + 35: uint16(23842), + 36: uint16(23834), + 37: uint16(23833), + 38: uint16(23832), + 39: uint16(23884), + 40: uint16(23890), + 41: uint16(23886), + 42: uint16(23883), + 43: uint16(23916), + 44: uint16(23923), + 45: uint16(23926), + 46: uint16(23943), + 47: uint16(23940), + 48: uint16(23938), + 49: uint16(23970), + 50: uint16(23965), + 51: uint16(23980), + 52: uint16(23982), + 53: uint16(23997), + 54: uint16(23952), + 55: uint16(23991), + 56: uint16(23996), + 57: uint16(24009), + 58: uint16(24013), + 59: uint16(24019), + 60: uint16(24018), + 61: uint16(24022), + 62: uint16(24027), + 63: uint16(24043), + 64: uint16(24050), + 65: uint16(24053), + 66: uint16(24075), + 67: uint16(24090), + 68: uint16(24089), + 69: uint16(24081), + 70: uint16(24091), + 71: uint16(24118), + 72: uint16(24119), + 73: uint16(24132), + 74: uint16(24131), + 75: uint16(24128), + 76: uint16(24142), + 77: uint16(24151), + 78: uint16(24148), + 79: uint16(24159), + 80: uint16(24162), + 81: uint16(24164), + 82: uint16(24135), + 83: uint16(24181), + 84: uint16(24182), + 85: uint16(24186), + 86: uint16(40636), + 87: uint16(24191), + 88: uint16(24224), + 89: uint16(24257), + 90: uint16(24258), + 91: uint16(24264), + 92: uint16(24272), + 93: uint16(24271), + }, + 54: { + 0: uint16(24278), + 1: uint16(24291), + 2: uint16(24285), + 3: uint16(24282), + 4: uint16(24283), + 5: uint16(24290), + 6: uint16(24289), + 7: uint16(24296), + 8: uint16(24297), + 9: uint16(24300), + 10: uint16(24305), + 11: uint16(24307), + 12: uint16(24304), + 13: uint16(24308), + 14: uint16(24312), + 15: uint16(24318), + 16: uint16(24323), + 17: uint16(24329), + 18: uint16(24413), + 19: uint16(24412), + 20: uint16(24331), + 21: uint16(24337), + 22: uint16(24342), + 23: uint16(24361), + 24: uint16(24365), + 25: uint16(24376), + 26: uint16(24385), + 27: uint16(24392), + 28: uint16(24396), + 29: uint16(24398), + 30: uint16(24367), + 31: uint16(24401), + 32: uint16(24406), + 33: uint16(24407), + 34: uint16(24409), + 35: uint16(24417), + 36: uint16(24429), + 37: uint16(24435), + 38: uint16(24439), + 39: uint16(24451), + 40: uint16(24450), + 41: uint16(24447), + 42: uint16(24458), + 43: uint16(24456), + 44: uint16(24465), + 45: uint16(24455), + 46: uint16(24478), + 47: uint16(24473), + 48: uint16(24472), + 49: uint16(24480), + 50: uint16(24488), + 51: uint16(24493), + 52: uint16(24508), + 53: uint16(24534), + 54: uint16(24571), + 55: uint16(24548), + 56: uint16(24568), + 57: uint16(24561), + 58: uint16(24541), + 59: uint16(24755), + 60: uint16(24575), + 61: uint16(24609), + 62: uint16(24672), + 63: uint16(24601), + 64: uint16(24592), + 65: uint16(24617), + 66: uint16(24590), + 67: uint16(24625), + 68: uint16(24603), + 69: uint16(24597), + 70: uint16(24619), + 71: uint16(24614), + 72: uint16(24591), + 73: uint16(24634), + 74: uint16(24666), + 75: uint16(24641), + 76: uint16(24682), + 77: uint16(24695), + 78: uint16(24671), + 79: uint16(24650), + 80: uint16(24646), + 81: uint16(24653), + 82: uint16(24675), + 83: uint16(24643), + 84: uint16(24676), + 85: uint16(24642), + 86: uint16(24684), + 87: uint16(24683), + 88: uint16(24665), + 89: uint16(24705), + 90: uint16(24717), + 91: uint16(24807), + 92: uint16(24707), + 93: uint16(24730), + }, + 55: { + 0: uint16(24708), + 1: uint16(24731), + 2: uint16(24726), + 3: uint16(24727), + 4: uint16(24722), + 5: uint16(24743), + 6: uint16(24715), + 7: uint16(24801), + 8: uint16(24760), + 9: uint16(24800), + 10: uint16(24787), + 11: uint16(24756), + 12: uint16(24560), + 13: uint16(24765), + 14: uint16(24774), + 15: uint16(24757), + 16: uint16(24792), + 17: uint16(24909), + 18: uint16(24853), + 19: uint16(24838), + 20: uint16(24822), + 21: uint16(24823), + 22: uint16(24832), + 23: uint16(24820), + 24: uint16(24826), + 25: uint16(24835), + 26: uint16(24865), + 27: uint16(24827), + 28: uint16(24817), + 29: uint16(24845), + 30: uint16(24846), + 31: uint16(24903), + 32: uint16(24894), + 33: uint16(24872), + 34: uint16(24871), + 35: uint16(24906), + 36: uint16(24895), + 37: uint16(24892), + 38: uint16(24876), + 39: uint16(24884), + 40: uint16(24893), + 41: uint16(24898), + 42: uint16(24900), + 43: uint16(24947), + 44: uint16(24951), + 45: uint16(24920), + 46: uint16(24921), + 47: uint16(24922), + 48: uint16(24939), + 49: uint16(24948), + 50: uint16(24943), + 51: uint16(24933), + 52: uint16(24945), + 53: uint16(24927), + 54: uint16(24925), + 55: uint16(24915), + 56: uint16(24949), + 57: uint16(24985), + 58: uint16(24982), + 59: uint16(24967), + 60: uint16(25004), + 61: uint16(24980), + 62: uint16(24986), + 63: uint16(24970), + 64: uint16(24977), + 65: uint16(25003), + 66: uint16(25006), + 67: uint16(25036), + 68: uint16(25034), + 69: uint16(25033), + 70: uint16(25079), + 71: uint16(25032), + 72: uint16(25027), + 73: uint16(25030), + 74: uint16(25018), + 75: uint16(25035), + 76: uint16(32633), + 77: uint16(25037), + 78: uint16(25062), + 79: uint16(25059), + 80: uint16(25078), + 81: uint16(25082), + 82: uint16(25076), + 83: uint16(25087), + 84: uint16(25085), + 85: uint16(25084), + 86: uint16(25086), + 87: uint16(25088), + 88: uint16(25096), + 89: uint16(25097), + 90: uint16(25101), + 91: uint16(25100), + 92: uint16(25108), + 93: uint16(25115), + }, + 56: { + 0: uint16(25118), + 1: uint16(25121), + 2: uint16(25130), + 3: uint16(25134), + 4: uint16(25136), + 5: uint16(25138), + 6: uint16(25139), + 7: uint16(25153), + 8: uint16(25166), + 9: uint16(25182), + 10: uint16(25187), + 11: uint16(25179), + 12: uint16(25184), + 13: uint16(25192), + 14: uint16(25212), + 15: uint16(25218), + 16: uint16(25225), + 17: uint16(25214), + 18: uint16(25234), + 19: uint16(25235), + 20: uint16(25238), + 21: uint16(25300), + 22: uint16(25219), + 23: uint16(25236), + 24: uint16(25303), + 25: uint16(25297), + 26: uint16(25275), + 27: uint16(25295), + 28: uint16(25343), + 29: uint16(25286), + 30: uint16(25812), + 31: uint16(25288), + 32: uint16(25308), + 33: uint16(25292), + 34: uint16(25290), + 35: uint16(25282), + 36: uint16(25287), + 37: uint16(25243), + 38: uint16(25289), + 39: uint16(25356), + 40: uint16(25326), + 41: uint16(25329), + 42: uint16(25383), + 43: uint16(25346), + 44: uint16(25352), + 45: uint16(25327), + 46: uint16(25333), + 47: uint16(25424), + 48: uint16(25406), + 49: uint16(25421), + 50: uint16(25628), + 51: uint16(25423), + 52: uint16(25494), + 53: uint16(25486), + 54: uint16(25472), + 55: uint16(25515), + 56: uint16(25462), + 57: uint16(25507), + 58: uint16(25487), + 59: uint16(25481), + 60: uint16(25503), + 61: uint16(25525), + 62: uint16(25451), + 63: uint16(25449), + 64: uint16(25534), + 65: uint16(25577), + 66: uint16(25536), + 67: uint16(25542), + 68: uint16(25571), + 69: uint16(25545), + 70: uint16(25554), + 71: uint16(25590), + 72: uint16(25540), + 73: uint16(25622), + 74: uint16(25652), + 75: uint16(25606), + 76: uint16(25619), + 77: uint16(25638), + 78: uint16(25654), + 79: uint16(25885), + 80: uint16(25623), + 81: uint16(25640), + 82: uint16(25615), + 83: uint16(25703), + 84: uint16(25711), + 85: uint16(25718), + 86: uint16(25678), + 87: uint16(25898), + 88: uint16(25749), + 89: uint16(25747), + 90: uint16(25765), + 91: uint16(25769), + 92: uint16(25736), + 93: uint16(25788), + }, + 57: { + 0: uint16(25818), + 1: uint16(25810), + 2: uint16(25797), + 3: uint16(25799), + 4: uint16(25787), + 5: uint16(25816), + 6: uint16(25794), + 7: uint16(25841), + 8: uint16(25831), + 9: uint16(33289), + 10: uint16(25824), + 11: uint16(25825), + 12: uint16(25260), + 13: uint16(25827), + 14: uint16(25839), + 15: uint16(25900), + 16: uint16(25846), + 17: uint16(25844), + 18: uint16(25842), + 19: uint16(25850), + 20: uint16(25856), + 21: uint16(25853), + 22: uint16(25880), + 23: uint16(25884), + 24: uint16(25861), + 25: uint16(25892), + 26: uint16(25891), + 27: uint16(25899), + 28: uint16(25908), + 29: uint16(25909), + 30: uint16(25911), + 31: uint16(25910), + 32: uint16(25912), + 33: uint16(30027), + 34: uint16(25928), + 35: uint16(25942), + 36: uint16(25941), + 37: uint16(25933), + 38: uint16(25944), + 39: uint16(25950), + 40: uint16(25949), + 41: uint16(25970), + 42: uint16(25976), + 43: uint16(25986), + 44: uint16(25987), + 45: uint16(35722), + 46: uint16(26011), + 47: uint16(26015), + 48: uint16(26027), + 49: uint16(26039), + 50: uint16(26051), + 51: uint16(26054), + 52: uint16(26049), + 53: uint16(26052), + 54: uint16(26060), + 55: uint16(26066), + 56: uint16(26075), + 57: uint16(26073), + 58: uint16(26080), + 59: uint16(26081), + 60: uint16(26097), + 61: uint16(26482), + 62: uint16(26122), + 63: uint16(26115), + 64: uint16(26107), + 65: uint16(26483), + 66: uint16(26165), + 67: uint16(26166), + 68: uint16(26164), + 69: uint16(26140), + 70: uint16(26191), + 71: uint16(26180), + 72: uint16(26185), + 73: uint16(26177), + 74: uint16(26206), + 75: uint16(26205), + 76: uint16(26212), + 77: uint16(26215), + 78: uint16(26216), + 79: uint16(26207), + 80: uint16(26210), + 81: uint16(26224), + 82: uint16(26243), + 83: uint16(26248), + 84: uint16(26254), + 85: uint16(26249), + 86: uint16(26244), + 87: uint16(26264), + 88: uint16(26269), + 89: uint16(26305), + 90: uint16(26297), + 91: uint16(26313), + 92: uint16(26302), + 93: uint16(26300), + }, + 58: { + 0: uint16(26308), + 1: uint16(26296), + 2: uint16(26326), + 3: uint16(26330), + 4: uint16(26336), + 5: uint16(26175), + 6: uint16(26342), + 7: uint16(26345), + 8: uint16(26352), + 9: uint16(26357), + 10: uint16(26359), + 11: uint16(26383), + 12: uint16(26390), + 13: uint16(26398), + 14: uint16(26406), + 15: uint16(26407), + 16: uint16(38712), + 17: uint16(26414), + 18: uint16(26431), + 19: uint16(26422), + 20: uint16(26433), + 21: uint16(26424), + 22: uint16(26423), + 23: uint16(26438), + 24: uint16(26462), + 25: uint16(26464), + 26: uint16(26457), + 27: uint16(26467), + 28: uint16(26468), + 29: uint16(26505), + 30: uint16(26480), + 31: uint16(26537), + 32: uint16(26492), + 33: uint16(26474), + 34: uint16(26508), + 35: uint16(26507), + 36: uint16(26534), + 37: uint16(26529), + 38: uint16(26501), + 39: uint16(26551), + 40: uint16(26607), + 41: uint16(26548), + 42: uint16(26604), + 43: uint16(26547), + 44: uint16(26601), + 45: uint16(26552), + 46: uint16(26596), + 47: uint16(26590), + 48: uint16(26589), + 49: uint16(26594), + 50: uint16(26606), + 51: uint16(26553), + 52: uint16(26574), + 53: uint16(26566), + 54: uint16(26599), + 55: uint16(27292), + 56: uint16(26654), + 57: uint16(26694), + 58: uint16(26665), + 59: uint16(26688), + 60: uint16(26701), + 61: uint16(26674), + 62: uint16(26702), + 63: uint16(26803), + 64: uint16(26667), + 65: uint16(26713), + 66: uint16(26723), + 67: uint16(26743), + 68: uint16(26751), + 69: uint16(26783), + 70: uint16(26767), + 71: uint16(26797), + 72: uint16(26772), + 73: uint16(26781), + 74: uint16(26779), + 75: uint16(26755), + 76: uint16(27310), + 77: uint16(26809), + 78: uint16(26740), + 79: uint16(26805), + 80: uint16(26784), + 81: uint16(26810), + 82: uint16(26895), + 83: uint16(26765), + 84: uint16(26750), + 85: uint16(26881), + 86: uint16(26826), + 87: uint16(26888), + 88: uint16(26840), + 89: uint16(26914), + 90: uint16(26918), + 91: uint16(26849), + 92: uint16(26892), + 93: uint16(26829), + }, + 59: { + 0: uint16(26836), + 1: uint16(26855), + 2: uint16(26837), + 3: uint16(26934), + 4: uint16(26898), + 5: uint16(26884), + 6: uint16(26839), + 7: uint16(26851), + 8: uint16(26917), + 9: uint16(26873), + 10: uint16(26848), + 11: uint16(26863), + 12: uint16(26920), + 13: uint16(26922), + 14: uint16(26906), + 15: uint16(26915), + 16: uint16(26913), + 17: uint16(26822), + 18: uint16(27001), + 19: uint16(26999), + 20: uint16(26972), + 21: uint16(27000), + 22: uint16(26987), + 23: uint16(26964), + 24: uint16(27006), + 25: uint16(26990), + 26: uint16(26937), + 27: uint16(26996), + 28: uint16(26941), + 29: uint16(26969), + 30: uint16(26928), + 31: uint16(26977), + 32: uint16(26974), + 33: uint16(26973), + 34: uint16(27009), + 35: uint16(26986), + 36: uint16(27058), + 37: uint16(27054), + 38: uint16(27088), + 39: uint16(27071), + 40: uint16(27073), + 41: uint16(27091), + 42: uint16(27070), + 43: uint16(27086), + 44: uint16(23528), + 45: uint16(27082), + 46: uint16(27101), + 47: uint16(27067), + 48: uint16(27075), + 49: uint16(27047), + 50: uint16(27182), + 51: uint16(27025), + 52: uint16(27040), + 53: uint16(27036), + 54: uint16(27029), + 55: uint16(27060), + 56: uint16(27102), + 57: uint16(27112), + 58: uint16(27138), + 59: uint16(27163), + 60: uint16(27135), + 61: uint16(27402), + 62: uint16(27129), + 63: uint16(27122), + 64: uint16(27111), + 65: uint16(27141), + 66: uint16(27057), + 67: uint16(27166), + 68: uint16(27117), + 69: uint16(27156), + 70: uint16(27115), + 71: uint16(27146), + 72: uint16(27154), + 73: uint16(27329), + 74: uint16(27171), + 75: uint16(27155), + 76: uint16(27204), + 77: uint16(27148), + 78: uint16(27250), + 79: uint16(27190), + 80: uint16(27256), + 81: uint16(27207), + 82: uint16(27234), + 83: uint16(27225), + 84: uint16(27238), + 85: uint16(27208), + 86: uint16(27192), + 87: uint16(27170), + 88: uint16(27280), + 89: uint16(27277), + 90: uint16(27296), + 91: uint16(27268), + 92: uint16(27298), + 93: uint16(27299), + }, + 60: { + 0: uint16(27287), + 1: uint16(34327), + 2: uint16(27323), + 3: uint16(27331), + 4: uint16(27330), + 5: uint16(27320), + 6: uint16(27315), + 7: uint16(27308), + 8: uint16(27358), + 9: uint16(27345), + 10: uint16(27359), + 11: uint16(27306), + 12: uint16(27354), + 13: uint16(27370), + 14: uint16(27387), + 15: uint16(27397), + 16: uint16(34326), + 17: uint16(27386), + 18: uint16(27410), + 19: uint16(27414), + 20: uint16(39729), + 21: uint16(27423), + 22: uint16(27448), + 23: uint16(27447), + 24: uint16(30428), + 25: uint16(27449), + 26: uint16(39150), + 27: uint16(27463), + 28: uint16(27459), + 29: uint16(27465), + 30: uint16(27472), + 31: uint16(27481), + 32: uint16(27476), + 33: uint16(27483), + 34: uint16(27487), + 35: uint16(27489), + 36: uint16(27512), + 37: uint16(27513), + 38: uint16(27519), + 39: uint16(27520), + 40: uint16(27524), + 41: uint16(27523), + 42: uint16(27533), + 43: uint16(27544), + 44: uint16(27541), + 45: uint16(27550), + 46: uint16(27556), + 47: uint16(27562), + 48: uint16(27563), + 49: uint16(27567), + 50: uint16(27570), + 51: uint16(27569), + 52: uint16(27571), + 53: uint16(27575), + 54: uint16(27580), + 55: uint16(27590), + 56: uint16(27595), + 57: uint16(27603), + 58: uint16(27615), + 59: uint16(27628), + 60: uint16(27627), + 61: uint16(27635), + 62: uint16(27631), + 63: uint16(40638), + 64: uint16(27656), + 65: uint16(27667), + 66: uint16(27668), + 67: uint16(27675), + 68: uint16(27684), + 69: uint16(27683), + 70: uint16(27742), + 71: uint16(27733), + 72: uint16(27746), + 73: uint16(27754), + 74: uint16(27778), + 75: uint16(27789), + 76: uint16(27802), + 77: uint16(27777), + 78: uint16(27803), + 79: uint16(27774), + 80: uint16(27752), + 81: uint16(27763), + 82: uint16(27794), + 83: uint16(27792), + 84: uint16(27844), + 85: uint16(27889), + 86: uint16(27859), + 87: uint16(27837), + 88: uint16(27863), + 89: uint16(27845), + 90: uint16(27869), + 91: uint16(27822), + 92: uint16(27825), + 93: uint16(27838), + }, + 61: { + 0: uint16(27834), + 1: uint16(27867), + 2: uint16(27887), + 3: uint16(27865), + 4: uint16(27882), + 5: uint16(27935), + 6: uint16(34893), + 7: uint16(27958), + 8: uint16(27947), + 9: uint16(27965), + 10: uint16(27960), + 11: uint16(27929), + 12: uint16(27957), + 13: uint16(27955), + 14: uint16(27922), + 15: uint16(27916), + 16: uint16(28003), + 17: uint16(28051), + 18: uint16(28004), + 19: uint16(27994), + 20: uint16(28025), + 21: uint16(27993), + 22: uint16(28046), + 23: uint16(28053), + 24: uint16(28644), + 25: uint16(28037), + 26: uint16(28153), + 27: uint16(28181), + 28: uint16(28170), + 29: uint16(28085), + 30: uint16(28103), + 31: uint16(28134), + 32: uint16(28088), + 33: uint16(28102), + 34: uint16(28140), + 35: uint16(28126), + 36: uint16(28108), + 37: uint16(28136), + 38: uint16(28114), + 39: uint16(28101), + 40: uint16(28154), + 41: uint16(28121), + 42: uint16(28132), + 43: uint16(28117), + 44: uint16(28138), + 45: uint16(28142), + 46: uint16(28205), + 47: uint16(28270), + 48: uint16(28206), + 49: uint16(28185), + 50: uint16(28274), + 51: uint16(28255), + 52: uint16(28222), + 53: uint16(28195), + 54: uint16(28267), + 55: uint16(28203), + 56: uint16(28278), + 57: uint16(28237), + 58: uint16(28191), + 59: uint16(28227), + 60: uint16(28218), + 61: uint16(28238), + 62: uint16(28196), + 63: uint16(28415), + 64: uint16(28189), + 65: uint16(28216), + 66: uint16(28290), + 67: uint16(28330), + 68: uint16(28312), + 69: uint16(28361), + 70: uint16(28343), + 71: uint16(28371), + 72: uint16(28349), + 73: uint16(28335), + 74: uint16(28356), + 75: uint16(28338), + 76: uint16(28372), + 77: uint16(28373), + 78: uint16(28303), + 79: uint16(28325), + 80: uint16(28354), + 81: uint16(28319), + 82: uint16(28481), + 83: uint16(28433), + 84: uint16(28748), + 85: uint16(28396), + 86: uint16(28408), + 87: uint16(28414), + 88: uint16(28479), + 89: uint16(28402), + 90: uint16(28465), + 91: uint16(28399), + 92: uint16(28466), + 93: uint16(28364), + }, + 62: { + 0: uint16(28478), + 1: uint16(28435), + 2: uint16(28407), + 3: uint16(28550), + 4: uint16(28538), + 5: uint16(28536), + 6: uint16(28545), + 7: uint16(28544), + 8: uint16(28527), + 9: uint16(28507), + 10: uint16(28659), + 11: uint16(28525), + 12: uint16(28546), + 13: uint16(28540), + 14: uint16(28504), + 15: uint16(28558), + 16: uint16(28561), + 17: uint16(28610), + 18: uint16(28518), + 19: uint16(28595), + 20: uint16(28579), + 21: uint16(28577), + 22: uint16(28580), + 23: uint16(28601), + 24: uint16(28614), + 25: uint16(28586), + 26: uint16(28639), + 27: uint16(28629), + 28: uint16(28652), + 29: uint16(28628), + 30: uint16(28632), + 31: uint16(28657), + 32: uint16(28654), + 33: uint16(28635), + 34: uint16(28681), + 35: uint16(28683), + 36: uint16(28666), + 37: uint16(28689), + 38: uint16(28673), + 39: uint16(28687), + 40: uint16(28670), + 41: uint16(28699), + 42: uint16(28698), + 43: uint16(28532), + 44: uint16(28701), + 45: uint16(28696), + 46: uint16(28703), + 47: uint16(28720), + 48: uint16(28734), + 49: uint16(28722), + 50: uint16(28753), + 51: uint16(28771), + 52: uint16(28825), + 53: uint16(28818), + 54: uint16(28847), + 55: uint16(28913), + 56: uint16(28844), + 57: uint16(28856), + 58: uint16(28851), + 59: uint16(28846), + 60: uint16(28895), + 61: uint16(28875), + 62: uint16(28893), + 63: uint16(28889), + 64: uint16(28937), + 65: uint16(28925), + 66: uint16(28956), + 67: uint16(28953), + 68: uint16(29029), + 69: uint16(29013), + 70: uint16(29064), + 71: uint16(29030), + 72: uint16(29026), + 73: uint16(29004), + 74: uint16(29014), + 75: uint16(29036), + 76: uint16(29071), + 77: uint16(29179), + 78: uint16(29060), + 79: uint16(29077), + 80: uint16(29096), + 81: uint16(29100), + 82: uint16(29143), + 83: uint16(29113), + 84: uint16(29118), + 85: uint16(29138), + 86: uint16(29129), + 87: uint16(29140), + 88: uint16(29134), + 89: uint16(29152), + 90: uint16(29164), + 91: uint16(29159), + 92: uint16(29173), + 93: uint16(29180), + }, + 63: { + 0: uint16(29177), + 1: uint16(29183), + 2: uint16(29197), + 3: uint16(29200), + 4: uint16(29211), + 5: uint16(29224), + 6: uint16(29229), + 7: uint16(29228), + 8: uint16(29232), + 9: uint16(29234), + 10: uint16(29243), + 11: uint16(29244), + 12: uint16(29247), + 13: uint16(29248), + 14: uint16(29254), + 15: uint16(29259), + 16: uint16(29272), + 17: uint16(29300), + 18: uint16(29310), + 19: uint16(29314), + 20: uint16(29313), + 21: uint16(29319), + 22: uint16(29330), + 23: uint16(29334), + 24: uint16(29346), + 25: uint16(29351), + 26: uint16(29369), + 27: uint16(29362), + 28: uint16(29379), + 29: uint16(29382), + 30: uint16(29380), + 31: uint16(29390), + 32: uint16(29394), + 33: uint16(29410), + 34: uint16(29408), + 35: uint16(29409), + 36: uint16(29433), + 37: uint16(29431), + 38: uint16(20495), + 39: uint16(29463), + 40: uint16(29450), + 41: uint16(29468), + 42: uint16(29462), + 43: uint16(29469), + 44: uint16(29492), + 45: uint16(29487), + 46: uint16(29481), + 47: uint16(29477), + 48: uint16(29502), + 49: uint16(29518), + 50: uint16(29519), + 51: uint16(40664), + 52: uint16(29527), + 53: uint16(29546), + 54: uint16(29544), + 55: uint16(29552), + 56: uint16(29560), + 57: uint16(29557), + 58: uint16(29563), + 59: uint16(29562), + 60: uint16(29640), + 61: uint16(29619), + 62: uint16(29646), + 63: uint16(29627), + 64: uint16(29632), + 65: uint16(29669), + 66: uint16(29678), + 67: uint16(29662), + 68: uint16(29858), + 69: uint16(29701), + 70: uint16(29807), + 71: uint16(29733), + 72: uint16(29688), + 73: uint16(29746), + 74: uint16(29754), + 75: uint16(29781), + 76: uint16(29759), + 77: uint16(29791), + 78: uint16(29785), + 79: uint16(29761), + 80: uint16(29788), + 81: uint16(29801), + 82: uint16(29808), + 83: uint16(29795), + 84: uint16(29802), + 85: uint16(29814), + 86: uint16(29822), + 87: uint16(29835), + 88: uint16(29854), + 89: uint16(29863), + 90: uint16(29898), + 91: uint16(29903), + 92: uint16(29908), + 93: uint16(29681), + }, + 64: { + 0: uint16(29920), + 1: uint16(29923), + 2: uint16(29927), + 3: uint16(29929), + 4: uint16(29934), + 5: uint16(29938), + 6: uint16(29936), + 7: uint16(29937), + 8: uint16(29944), + 9: uint16(29943), + 10: uint16(29956), + 11: uint16(29955), + 12: uint16(29957), + 13: uint16(29964), + 14: uint16(29966), + 15: uint16(29965), + 16: uint16(29973), + 17: uint16(29971), + 18: uint16(29982), + 19: uint16(29990), + 20: uint16(29996), + 21: uint16(30012), + 22: uint16(30020), + 23: uint16(30029), + 24: uint16(30026), + 25: uint16(30025), + 26: uint16(30043), + 27: uint16(30022), + 28: uint16(30042), + 29: uint16(30057), + 30: uint16(30052), + 31: uint16(30055), + 32: uint16(30059), + 33: uint16(30061), + 34: uint16(30072), + 35: uint16(30070), + 36: uint16(30086), + 37: uint16(30087), + 38: uint16(30068), + 39: uint16(30090), + 40: uint16(30089), + 41: uint16(30082), + 42: uint16(30100), + 43: uint16(30106), + 44: uint16(30109), + 45: uint16(30117), + 46: uint16(30115), + 47: uint16(30146), + 48: uint16(30131), + 49: uint16(30147), + 50: uint16(30133), + 51: uint16(30141), + 52: uint16(30136), + 53: uint16(30140), + 54: uint16(30129), + 55: uint16(30157), + 56: uint16(30154), + 57: uint16(30162), + 58: uint16(30169), + 59: uint16(30179), + 60: uint16(30174), + 61: uint16(30206), + 62: uint16(30207), + 63: uint16(30204), + 64: uint16(30209), + 65: uint16(30192), + 66: uint16(30202), + 67: uint16(30194), + 68: uint16(30195), + 69: uint16(30219), + 70: uint16(30221), + 71: uint16(30217), + 72: uint16(30239), + 73: uint16(30247), + 74: uint16(30240), + 75: uint16(30241), + 76: uint16(30242), + 77: uint16(30244), + 78: uint16(30260), + 79: uint16(30256), + 80: uint16(30267), + 81: uint16(30279), + 82: uint16(30280), + 83: uint16(30278), + 84: uint16(30300), + 85: uint16(30296), + 86: uint16(30305), + 87: uint16(30306), + 88: uint16(30312), + 89: uint16(30313), + 90: uint16(30314), + 91: uint16(30311), + 92: uint16(30316), + 93: uint16(30320), + }, + 65: { + 0: uint16(30322), + 1: uint16(30326), + 2: uint16(30328), + 3: uint16(30332), + 4: uint16(30336), + 5: uint16(30339), + 6: uint16(30344), + 7: uint16(30347), + 8: uint16(30350), + 9: uint16(30358), + 10: uint16(30355), + 11: uint16(30361), + 12: uint16(30362), + 13: uint16(30384), + 14: uint16(30388), + 15: uint16(30392), + 16: uint16(30393), + 17: uint16(30394), + 18: uint16(30402), + 19: uint16(30413), + 20: uint16(30422), + 21: uint16(30418), + 22: uint16(30430), + 23: uint16(30433), + 24: uint16(30437), + 25: uint16(30439), + 26: uint16(30442), + 27: uint16(34351), + 28: uint16(30459), + 29: uint16(30472), + 30: uint16(30471), + 31: uint16(30468), + 32: uint16(30505), + 33: uint16(30500), + 34: uint16(30494), + 35: uint16(30501), + 36: uint16(30502), + 37: uint16(30491), + 38: uint16(30519), + 39: uint16(30520), + 40: uint16(30535), + 41: uint16(30554), + 42: uint16(30568), + 43: uint16(30571), + 44: uint16(30555), + 45: uint16(30565), + 46: uint16(30591), + 47: uint16(30590), + 48: uint16(30585), + 49: uint16(30606), + 50: uint16(30603), + 51: uint16(30609), + 52: uint16(30624), + 53: uint16(30622), + 54: uint16(30640), + 55: uint16(30646), + 56: uint16(30649), + 57: uint16(30655), + 58: uint16(30652), + 59: uint16(30653), + 60: uint16(30651), + 61: uint16(30663), + 62: uint16(30669), + 63: uint16(30679), + 64: uint16(30682), + 65: uint16(30684), + 66: uint16(30691), + 67: uint16(30702), + 68: uint16(30716), + 69: uint16(30732), + 70: uint16(30738), + 71: uint16(31014), + 72: uint16(30752), + 73: uint16(31018), + 74: uint16(30789), + 75: uint16(30862), + 76: uint16(30836), + 77: uint16(30854), + 78: uint16(30844), + 79: uint16(30874), + 80: uint16(30860), + 81: uint16(30883), + 82: uint16(30901), + 83: uint16(30890), + 84: uint16(30895), + 85: uint16(30929), + 86: uint16(30918), + 87: uint16(30923), + 88: uint16(30932), + 89: uint16(30910), + 90: uint16(30908), + 91: uint16(30917), + 92: uint16(30922), + 93: uint16(30956), + }, + 66: { + 0: uint16(30951), + 1: uint16(30938), + 2: uint16(30973), + 3: uint16(30964), + 4: uint16(30983), + 5: uint16(30994), + 6: uint16(30993), + 7: uint16(31001), + 8: uint16(31020), + 9: uint16(31019), + 10: uint16(31040), + 11: uint16(31072), + 12: uint16(31063), + 13: uint16(31071), + 14: uint16(31066), + 15: uint16(31061), + 16: uint16(31059), + 17: uint16(31098), + 18: uint16(31103), + 19: uint16(31114), + 20: uint16(31133), + 21: uint16(31143), + 22: uint16(40779), + 23: uint16(31146), + 24: uint16(31150), + 25: uint16(31155), + 26: uint16(31161), + 27: uint16(31162), + 28: uint16(31177), + 29: uint16(31189), + 30: uint16(31207), + 31: uint16(31212), + 32: uint16(31201), + 33: uint16(31203), + 34: uint16(31240), + 35: uint16(31245), + 36: uint16(31256), + 37: uint16(31257), + 38: uint16(31264), + 39: uint16(31263), + 40: uint16(31104), + 41: uint16(31281), + 42: uint16(31291), + 43: uint16(31294), + 44: uint16(31287), + 45: uint16(31299), + 46: uint16(31319), + 47: uint16(31305), + 48: uint16(31329), + 49: uint16(31330), + 50: uint16(31337), + 51: uint16(40861), + 52: uint16(31344), + 53: uint16(31353), + 54: uint16(31357), + 55: uint16(31368), + 56: uint16(31383), + 57: uint16(31381), + 58: uint16(31384), + 59: uint16(31382), + 60: uint16(31401), + 61: uint16(31432), + 62: uint16(31408), + 63: uint16(31414), + 64: uint16(31429), + 65: uint16(31428), + 66: uint16(31423), + 67: uint16(36995), + 68: uint16(31431), + 69: uint16(31434), + 70: uint16(31437), + 71: uint16(31439), + 72: uint16(31445), + 73: uint16(31443), + 74: uint16(31449), + 75: uint16(31450), + 76: uint16(31453), + 77: uint16(31457), + 78: uint16(31458), + 79: uint16(31462), + 80: uint16(31469), + 81: uint16(31472), + 82: uint16(31490), + 83: uint16(31503), + 84: uint16(31498), + 85: uint16(31494), + 86: uint16(31539), + 87: uint16(31512), + 88: uint16(31513), + 89: uint16(31518), + 90: uint16(31541), + 91: uint16(31528), + 92: uint16(31542), + 93: uint16(31568), + }, + 67: { + 0: uint16(31610), + 1: uint16(31492), + 2: uint16(31565), + 3: uint16(31499), + 4: uint16(31564), + 5: uint16(31557), + 6: uint16(31605), + 7: uint16(31589), + 8: uint16(31604), + 9: uint16(31591), + 10: uint16(31600), + 11: uint16(31601), + 12: uint16(31596), + 13: uint16(31598), + 14: uint16(31645), + 15: uint16(31640), + 16: uint16(31647), + 17: uint16(31629), + 18: uint16(31644), + 19: uint16(31642), + 20: uint16(31627), + 21: uint16(31634), + 22: uint16(31631), + 23: uint16(31581), + 24: uint16(31641), + 25: uint16(31691), + 26: uint16(31681), + 27: uint16(31692), + 28: uint16(31695), + 29: uint16(31668), + 30: uint16(31686), + 31: uint16(31709), + 32: uint16(31721), + 33: uint16(31761), + 34: uint16(31764), + 35: uint16(31718), + 36: uint16(31717), + 37: uint16(31840), + 38: uint16(31744), + 39: uint16(31751), + 40: uint16(31763), + 41: uint16(31731), + 42: uint16(31735), + 43: uint16(31767), + 44: uint16(31757), + 45: uint16(31734), + 46: uint16(31779), + 47: uint16(31783), + 48: uint16(31786), + 49: uint16(31775), + 50: uint16(31799), + 51: uint16(31787), + 52: uint16(31805), + 53: uint16(31820), + 54: uint16(31811), + 55: uint16(31828), + 56: uint16(31823), + 57: uint16(31808), + 58: uint16(31824), + 59: uint16(31832), + 60: uint16(31839), + 61: uint16(31844), + 62: uint16(31830), + 63: uint16(31845), + 64: uint16(31852), + 65: uint16(31861), + 66: uint16(31875), + 67: uint16(31888), + 68: uint16(31908), + 69: uint16(31917), + 70: uint16(31906), + 71: uint16(31915), + 72: uint16(31905), + 73: uint16(31912), + 74: uint16(31923), + 75: uint16(31922), + 76: uint16(31921), + 77: uint16(31918), + 78: uint16(31929), + 79: uint16(31933), + 80: uint16(31936), + 81: uint16(31941), + 82: uint16(31938), + 83: uint16(31960), + 84: uint16(31954), + 85: uint16(31964), + 86: uint16(31970), + 87: uint16(39739), + 88: uint16(31983), + 89: uint16(31986), + 90: uint16(31988), + 91: uint16(31990), + 92: uint16(31994), + 93: uint16(32006), + }, + 68: { + 0: uint16(32002), + 1: uint16(32028), + 2: uint16(32021), + 3: uint16(32010), + 4: uint16(32069), + 5: uint16(32075), + 6: uint16(32046), + 7: uint16(32050), + 8: uint16(32063), + 9: uint16(32053), + 10: uint16(32070), + 11: uint16(32115), + 12: uint16(32086), + 13: uint16(32078), + 14: uint16(32114), + 15: uint16(32104), + 16: uint16(32110), + 17: uint16(32079), + 18: uint16(32099), + 19: uint16(32147), + 20: uint16(32137), + 21: uint16(32091), + 22: uint16(32143), + 23: uint16(32125), + 24: uint16(32155), + 25: uint16(32186), + 26: uint16(32174), + 27: uint16(32163), + 28: uint16(32181), + 29: uint16(32199), + 30: uint16(32189), + 31: uint16(32171), + 32: uint16(32317), + 33: uint16(32162), + 34: uint16(32175), + 35: uint16(32220), + 36: uint16(32184), + 37: uint16(32159), + 38: uint16(32176), + 39: uint16(32216), + 40: uint16(32221), + 41: uint16(32228), + 42: uint16(32222), + 43: uint16(32251), + 44: uint16(32242), + 45: uint16(32225), + 46: uint16(32261), + 47: uint16(32266), + 48: uint16(32291), + 49: uint16(32289), + 50: uint16(32274), + 51: uint16(32305), + 52: uint16(32287), + 53: uint16(32265), + 54: uint16(32267), + 55: uint16(32290), + 56: uint16(32326), + 57: uint16(32358), + 58: uint16(32315), + 59: uint16(32309), + 60: uint16(32313), + 61: uint16(32323), + 62: uint16(32311), + 63: uint16(32306), + 64: uint16(32314), + 65: uint16(32359), + 66: uint16(32349), + 67: uint16(32342), + 68: uint16(32350), + 69: uint16(32345), + 70: uint16(32346), + 71: uint16(32377), + 72: uint16(32362), + 73: uint16(32361), + 74: uint16(32380), + 75: uint16(32379), + 76: uint16(32387), + 77: uint16(32213), + 78: uint16(32381), + 79: uint16(36782), + 80: uint16(32383), + 81: uint16(32392), + 82: uint16(32393), + 83: uint16(32396), + 84: uint16(32402), + 85: uint16(32400), + 86: uint16(32403), + 87: uint16(32404), + 88: uint16(32406), + 89: uint16(32398), + 90: uint16(32411), + 91: uint16(32412), + 92: uint16(32568), + 93: uint16(32570), + }, + 69: { + 0: uint16(32581), + 1: uint16(32588), + 2: uint16(32589), + 3: uint16(32590), + 4: uint16(32592), + 5: uint16(32593), + 6: uint16(32597), + 7: uint16(32596), + 8: uint16(32600), + 9: uint16(32607), + 10: uint16(32608), + 11: uint16(32616), + 12: uint16(32617), + 13: uint16(32615), + 14: uint16(32632), + 15: uint16(32642), + 16: uint16(32646), + 17: uint16(32643), + 18: uint16(32648), + 19: uint16(32647), + 20: uint16(32652), + 21: uint16(32660), + 22: uint16(32670), + 23: uint16(32669), + 24: uint16(32666), + 25: uint16(32675), + 26: uint16(32687), + 27: uint16(32690), + 28: uint16(32697), + 29: uint16(32686), + 30: uint16(32694), + 31: uint16(32696), + 32: uint16(35697), + 33: uint16(32709), + 34: uint16(32710), + 35: uint16(32714), + 36: uint16(32725), + 37: uint16(32724), + 38: uint16(32737), + 39: uint16(32742), + 40: uint16(32745), + 41: uint16(32755), + 42: uint16(32761), + 43: uint16(39132), + 44: uint16(32774), + 45: uint16(32772), + 46: uint16(32779), + 47: uint16(32786), + 48: uint16(32792), + 49: uint16(32793), + 50: uint16(32796), + 51: uint16(32801), + 52: uint16(32808), + 53: uint16(32831), + 54: uint16(32827), + 55: uint16(32842), + 56: uint16(32838), + 57: uint16(32850), + 58: uint16(32856), + 59: uint16(32858), + 60: uint16(32863), + 61: uint16(32866), + 62: uint16(32872), + 63: uint16(32883), + 64: uint16(32882), + 65: uint16(32880), + 66: uint16(32886), + 67: uint16(32889), + 68: uint16(32893), + 69: uint16(32895), + 70: uint16(32900), + 71: uint16(32902), + 72: uint16(32901), + 73: uint16(32923), + 74: uint16(32915), + 75: uint16(32922), + 76: uint16(32941), + 77: uint16(20880), + 78: uint16(32940), + 79: uint16(32987), + 80: uint16(32997), + 81: uint16(32985), + 82: uint16(32989), + 83: uint16(32964), + 84: uint16(32986), + 85: uint16(32982), + 86: uint16(33033), + 87: uint16(33007), + 88: uint16(33009), + 89: uint16(33051), + 90: uint16(33065), + 91: uint16(33059), + 92: uint16(33071), + 93: uint16(33099), + }, + 70: { + 0: uint16(38539), + 1: uint16(33094), + 2: uint16(33086), + 3: uint16(33107), + 4: uint16(33105), + 5: uint16(33020), + 6: uint16(33137), + 7: uint16(33134), + 8: uint16(33125), + 9: uint16(33126), + 10: uint16(33140), + 11: uint16(33155), + 12: uint16(33160), + 13: uint16(33162), + 14: uint16(33152), + 15: uint16(33154), + 16: uint16(33184), + 17: uint16(33173), + 18: uint16(33188), + 19: uint16(33187), + 20: uint16(33119), + 21: uint16(33171), + 22: uint16(33193), + 23: uint16(33200), + 24: uint16(33205), + 25: uint16(33214), + 26: uint16(33208), + 27: uint16(33213), + 28: uint16(33216), + 29: uint16(33218), + 30: uint16(33210), + 31: uint16(33225), + 32: uint16(33229), + 33: uint16(33233), + 34: uint16(33241), + 35: uint16(33240), + 36: uint16(33224), + 37: uint16(33242), + 38: uint16(33247), + 39: uint16(33248), + 40: uint16(33255), + 41: uint16(33274), + 42: uint16(33275), + 43: uint16(33278), + 44: uint16(33281), + 45: uint16(33282), + 46: uint16(33285), + 47: uint16(33287), + 48: uint16(33290), + 49: uint16(33293), + 50: uint16(33296), + 51: uint16(33302), + 52: uint16(33321), + 53: uint16(33323), + 54: uint16(33336), + 55: uint16(33331), + 56: uint16(33344), + 57: uint16(33369), + 58: uint16(33368), + 59: uint16(33373), + 60: uint16(33370), + 61: uint16(33375), + 62: uint16(33380), + 63: uint16(33378), + 64: uint16(33384), + 65: uint16(33386), + 66: uint16(33387), + 67: uint16(33326), + 68: uint16(33393), + 69: uint16(33399), + 70: uint16(33400), + 71: uint16(33406), + 72: uint16(33421), + 73: uint16(33426), + 74: uint16(33451), + 75: uint16(33439), + 76: uint16(33467), + 77: uint16(33452), + 78: uint16(33505), + 79: uint16(33507), + 80: uint16(33503), + 81: uint16(33490), + 82: uint16(33524), + 83: uint16(33523), + 84: uint16(33530), + 85: uint16(33683), + 86: uint16(33539), + 87: uint16(33531), + 88: uint16(33529), + 89: uint16(33502), + 90: uint16(33542), + 91: uint16(33500), + 92: uint16(33545), + 93: uint16(33497), + }, + 71: { + 0: uint16(33589), + 1: uint16(33588), + 2: uint16(33558), + 3: uint16(33586), + 4: uint16(33585), + 5: uint16(33600), + 6: uint16(33593), + 7: uint16(33616), + 8: uint16(33605), + 9: uint16(33583), + 10: uint16(33579), + 11: uint16(33559), + 12: uint16(33560), + 13: uint16(33669), + 14: uint16(33690), + 15: uint16(33706), + 16: uint16(33695), + 17: uint16(33698), + 18: uint16(33686), + 19: uint16(33571), + 20: uint16(33678), + 21: uint16(33671), + 22: uint16(33674), + 23: uint16(33660), + 24: uint16(33717), + 25: uint16(33651), + 26: uint16(33653), + 27: uint16(33696), + 28: uint16(33673), + 29: uint16(33704), + 30: uint16(33780), + 31: uint16(33811), + 32: uint16(33771), + 33: uint16(33742), + 34: uint16(33789), + 35: uint16(33795), + 36: uint16(33752), + 37: uint16(33803), + 38: uint16(33729), + 39: uint16(33783), + 40: uint16(33799), + 41: uint16(33760), + 42: uint16(33778), + 43: uint16(33805), + 44: uint16(33826), + 45: uint16(33824), + 46: uint16(33725), + 47: uint16(33848), + 48: uint16(34054), + 49: uint16(33787), + 50: uint16(33901), + 51: uint16(33834), + 52: uint16(33852), + 53: uint16(34138), + 54: uint16(33924), + 55: uint16(33911), + 56: uint16(33899), + 57: uint16(33965), + 58: uint16(33902), + 59: uint16(33922), + 60: uint16(33897), + 61: uint16(33862), + 62: uint16(33836), + 63: uint16(33903), + 64: uint16(33913), + 65: uint16(33845), + 66: uint16(33994), + 67: uint16(33890), + 68: uint16(33977), + 69: uint16(33983), + 70: uint16(33951), + 71: uint16(34009), + 72: uint16(33997), + 73: uint16(33979), + 74: uint16(34010), + 75: uint16(34000), + 76: uint16(33985), + 77: uint16(33990), + 78: uint16(34006), + 79: uint16(33953), + 80: uint16(34081), + 81: uint16(34047), + 82: uint16(34036), + 83: uint16(34071), + 84: uint16(34072), + 85: uint16(34092), + 86: uint16(34079), + 87: uint16(34069), + 88: uint16(34068), + 89: uint16(34044), + 90: uint16(34112), + 91: uint16(34147), + 92: uint16(34136), + 93: uint16(34120), + }, + 72: { + 0: uint16(34113), + 1: uint16(34306), + 2: uint16(34123), + 3: uint16(34133), + 4: uint16(34176), + 5: uint16(34212), + 6: uint16(34184), + 7: uint16(34193), + 8: uint16(34186), + 9: uint16(34216), + 10: uint16(34157), + 11: uint16(34196), + 12: uint16(34203), + 13: uint16(34282), + 14: uint16(34183), + 15: uint16(34204), + 16: uint16(34167), + 17: uint16(34174), + 18: uint16(34192), + 19: uint16(34249), + 20: uint16(34234), + 21: uint16(34255), + 22: uint16(34233), + 23: uint16(34256), + 24: uint16(34261), + 25: uint16(34269), + 26: uint16(34277), + 27: uint16(34268), + 28: uint16(34297), + 29: uint16(34314), + 30: uint16(34323), + 31: uint16(34315), + 32: uint16(34302), + 33: uint16(34298), + 34: uint16(34310), + 35: uint16(34338), + 36: uint16(34330), + 37: uint16(34352), + 38: uint16(34367), + 39: uint16(34381), + 40: uint16(20053), + 41: uint16(34388), + 42: uint16(34399), + 43: uint16(34407), + 44: uint16(34417), + 45: uint16(34451), + 46: uint16(34467), + 47: uint16(34473), + 48: uint16(34474), + 49: uint16(34443), + 50: uint16(34444), + 51: uint16(34486), + 52: uint16(34479), + 53: uint16(34500), + 54: uint16(34502), + 55: uint16(34480), + 56: uint16(34505), + 57: uint16(34851), + 58: uint16(34475), + 59: uint16(34516), + 60: uint16(34526), + 61: uint16(34537), + 62: uint16(34540), + 63: uint16(34527), + 64: uint16(34523), + 65: uint16(34543), + 66: uint16(34578), + 67: uint16(34566), + 68: uint16(34568), + 69: uint16(34560), + 70: uint16(34563), + 71: uint16(34555), + 72: uint16(34577), + 73: uint16(34569), + 74: uint16(34573), + 75: uint16(34553), + 76: uint16(34570), + 77: uint16(34612), + 78: uint16(34623), + 79: uint16(34615), + 80: uint16(34619), + 81: uint16(34597), + 82: uint16(34601), + 83: uint16(34586), + 84: uint16(34656), + 85: uint16(34655), + 86: uint16(34680), + 87: uint16(34636), + 88: uint16(34638), + 89: uint16(34676), + 90: uint16(34647), + 91: uint16(34664), + 92: uint16(34670), + 93: uint16(34649), + }, + 73: { + 0: uint16(34643), + 1: uint16(34659), + 2: uint16(34666), + 3: uint16(34821), + 4: uint16(34722), + 5: uint16(34719), + 6: uint16(34690), + 7: uint16(34735), + 8: uint16(34763), + 9: uint16(34749), + 10: uint16(34752), + 11: uint16(34768), + 12: uint16(38614), + 13: uint16(34731), + 14: uint16(34756), + 15: uint16(34739), + 16: uint16(34759), + 17: uint16(34758), + 18: uint16(34747), + 19: uint16(34799), + 20: uint16(34802), + 21: uint16(34784), + 22: uint16(34831), + 23: uint16(34829), + 24: uint16(34814), + 25: uint16(34806), + 26: uint16(34807), + 27: uint16(34830), + 28: uint16(34770), + 29: uint16(34833), + 30: uint16(34838), + 31: uint16(34837), + 32: uint16(34850), + 33: uint16(34849), + 34: uint16(34865), + 35: uint16(34870), + 36: uint16(34873), + 37: uint16(34855), + 38: uint16(34875), + 39: uint16(34884), + 40: uint16(34882), + 41: uint16(34898), + 42: uint16(34905), + 43: uint16(34910), + 44: uint16(34914), + 45: uint16(34923), + 46: uint16(34945), + 47: uint16(34942), + 48: uint16(34974), + 49: uint16(34933), + 50: uint16(34941), + 51: uint16(34997), + 52: uint16(34930), + 53: uint16(34946), + 54: uint16(34967), + 55: uint16(34962), + 56: uint16(34990), + 57: uint16(34969), + 58: uint16(34978), + 59: uint16(34957), + 60: uint16(34980), + 61: uint16(34992), + 62: uint16(35007), + 63: uint16(34993), + 64: uint16(35011), + 65: uint16(35012), + 66: uint16(35028), + 67: uint16(35032), + 68: uint16(35033), + 69: uint16(35037), + 70: uint16(35065), + 71: uint16(35074), + 72: uint16(35068), + 73: uint16(35060), + 74: uint16(35048), + 75: uint16(35058), + 76: uint16(35076), + 77: uint16(35084), + 78: uint16(35082), + 79: uint16(35091), + 80: uint16(35139), + 81: uint16(35102), + 82: uint16(35109), + 83: uint16(35114), + 84: uint16(35115), + 85: uint16(35137), + 86: uint16(35140), + 87: uint16(35131), + 88: uint16(35126), + 89: uint16(35128), + 90: uint16(35148), + 91: uint16(35101), + 92: uint16(35168), + 93: uint16(35166), + }, + 74: { + 0: uint16(35174), + 1: uint16(35172), + 2: uint16(35181), + 3: uint16(35178), + 4: uint16(35183), + 5: uint16(35188), + 6: uint16(35191), + 7: uint16(35198), + 8: uint16(35203), + 9: uint16(35208), + 10: uint16(35210), + 11: uint16(35219), + 12: uint16(35224), + 13: uint16(35233), + 14: uint16(35241), + 15: uint16(35238), + 16: uint16(35244), + 17: uint16(35247), + 18: uint16(35250), + 19: uint16(35258), + 20: uint16(35261), + 21: uint16(35263), + 22: uint16(35264), + 23: uint16(35290), + 24: uint16(35292), + 25: uint16(35293), + 26: uint16(35303), + 27: uint16(35316), + 28: uint16(35320), + 29: uint16(35331), + 30: uint16(35350), + 31: uint16(35344), + 32: uint16(35340), + 33: uint16(35355), + 34: uint16(35357), + 35: uint16(35365), + 36: uint16(35382), + 37: uint16(35393), + 38: uint16(35419), + 39: uint16(35410), + 40: uint16(35398), + 41: uint16(35400), + 42: uint16(35452), + 43: uint16(35437), + 44: uint16(35436), + 45: uint16(35426), + 46: uint16(35461), + 47: uint16(35458), + 48: uint16(35460), + 49: uint16(35496), + 50: uint16(35489), + 51: uint16(35473), + 52: uint16(35493), + 53: uint16(35494), + 54: uint16(35482), + 55: uint16(35491), + 56: uint16(35524), + 57: uint16(35533), + 58: uint16(35522), + 59: uint16(35546), + 60: uint16(35563), + 61: uint16(35571), + 62: uint16(35559), + 63: uint16(35556), + 64: uint16(35569), + 65: uint16(35604), + 66: uint16(35552), + 67: uint16(35554), + 68: uint16(35575), + 69: uint16(35550), + 70: uint16(35547), + 71: uint16(35596), + 72: uint16(35591), + 73: uint16(35610), + 74: uint16(35553), + 75: uint16(35606), + 76: uint16(35600), + 77: uint16(35607), + 78: uint16(35616), + 79: uint16(35635), + 80: uint16(38827), + 81: uint16(35622), + 82: uint16(35627), + 83: uint16(35646), + 84: uint16(35624), + 85: uint16(35649), + 86: uint16(35660), + 87: uint16(35663), + 88: uint16(35662), + 89: uint16(35657), + 90: uint16(35670), + 91: uint16(35675), + 92: uint16(35674), + 93: uint16(35691), + }, + 75: { + 0: uint16(35679), + 1: uint16(35692), + 2: uint16(35695), + 3: uint16(35700), + 4: uint16(35709), + 5: uint16(35712), + 6: uint16(35724), + 7: uint16(35726), + 8: uint16(35730), + 9: uint16(35731), + 10: uint16(35734), + 11: uint16(35737), + 12: uint16(35738), + 13: uint16(35898), + 14: uint16(35905), + 15: uint16(35903), + 16: uint16(35912), + 17: uint16(35916), + 18: uint16(35918), + 19: uint16(35920), + 20: uint16(35925), + 21: uint16(35938), + 22: uint16(35948), + 23: uint16(35960), + 24: uint16(35962), + 25: uint16(35970), + 26: uint16(35977), + 27: uint16(35973), + 28: uint16(35978), + 29: uint16(35981), + 30: uint16(35982), + 31: uint16(35988), + 32: uint16(35964), + 33: uint16(35992), + 34: uint16(25117), + 35: uint16(36013), + 36: uint16(36010), + 37: uint16(36029), + 38: uint16(36018), + 39: uint16(36019), + 40: uint16(36014), + 41: uint16(36022), + 42: uint16(36040), + 43: uint16(36033), + 44: uint16(36068), + 45: uint16(36067), + 46: uint16(36058), + 47: uint16(36093), + 48: uint16(36090), + 49: uint16(36091), + 50: uint16(36100), + 51: uint16(36101), + 52: uint16(36106), + 53: uint16(36103), + 54: uint16(36111), + 55: uint16(36109), + 56: uint16(36112), + 57: uint16(40782), + 58: uint16(36115), + 59: uint16(36045), + 60: uint16(36116), + 61: uint16(36118), + 62: uint16(36199), + 63: uint16(36205), + 64: uint16(36209), + 65: uint16(36211), + 66: uint16(36225), + 67: uint16(36249), + 68: uint16(36290), + 69: uint16(36286), + 70: uint16(36282), + 71: uint16(36303), + 72: uint16(36314), + 73: uint16(36310), + 74: uint16(36300), + 75: uint16(36315), + 76: uint16(36299), + 77: uint16(36330), + 78: uint16(36331), + 79: uint16(36319), + 80: uint16(36323), + 81: uint16(36348), + 82: uint16(36360), + 83: uint16(36361), + 84: uint16(36351), + 85: uint16(36381), + 86: uint16(36382), + 87: uint16(36368), + 88: uint16(36383), + 89: uint16(36418), + 90: uint16(36405), + 91: uint16(36400), + 92: uint16(36404), + 93: uint16(36426), + }, + 76: { + 0: uint16(36423), + 1: uint16(36425), + 2: uint16(36428), + 3: uint16(36432), + 4: uint16(36424), + 5: uint16(36441), + 6: uint16(36452), + 7: uint16(36448), + 8: uint16(36394), + 9: uint16(36451), + 10: uint16(36437), + 11: uint16(36470), + 12: uint16(36466), + 13: uint16(36476), + 14: uint16(36481), + 15: uint16(36487), + 16: uint16(36485), + 17: uint16(36484), + 18: uint16(36491), + 19: uint16(36490), + 20: uint16(36499), + 21: uint16(36497), + 22: uint16(36500), + 23: uint16(36505), + 24: uint16(36522), + 25: uint16(36513), + 26: uint16(36524), + 27: uint16(36528), + 28: uint16(36550), + 29: uint16(36529), + 30: uint16(36542), + 31: uint16(36549), + 32: uint16(36552), + 33: uint16(36555), + 34: uint16(36571), + 35: uint16(36579), + 36: uint16(36604), + 37: uint16(36603), + 38: uint16(36587), + 39: uint16(36606), + 40: uint16(36618), + 41: uint16(36613), + 42: uint16(36629), + 43: uint16(36626), + 44: uint16(36633), + 45: uint16(36627), + 46: uint16(36636), + 47: uint16(36639), + 48: uint16(36635), + 49: uint16(36620), + 50: uint16(36646), + 51: uint16(36659), + 52: uint16(36667), + 53: uint16(36665), + 54: uint16(36677), + 55: uint16(36674), + 56: uint16(36670), + 57: uint16(36684), + 58: uint16(36681), + 59: uint16(36678), + 60: uint16(36686), + 61: uint16(36695), + 62: uint16(36700), + 63: uint16(36706), + 64: uint16(36707), + 65: uint16(36708), + 66: uint16(36764), + 67: uint16(36767), + 68: uint16(36771), + 69: uint16(36781), + 70: uint16(36783), + 71: uint16(36791), + 72: uint16(36826), + 73: uint16(36837), + 74: uint16(36834), + 75: uint16(36842), + 76: uint16(36847), + 77: uint16(36999), + 78: uint16(36852), + 79: uint16(36869), + 80: uint16(36857), + 81: uint16(36858), + 82: uint16(36881), + 83: uint16(36885), + 84: uint16(36897), + 85: uint16(36877), + 86: uint16(36894), + 87: uint16(36886), + 88: uint16(36875), + 89: uint16(36903), + 90: uint16(36918), + 91: uint16(36917), + 92: uint16(36921), + 93: uint16(36856), + }, + 77: { + 0: uint16(36943), + 1: uint16(36944), + 2: uint16(36945), + 3: uint16(36946), + 4: uint16(36878), + 5: uint16(36937), + 6: uint16(36926), + 7: uint16(36950), + 8: uint16(36952), + 9: uint16(36958), + 10: uint16(36968), + 11: uint16(36975), + 12: uint16(36982), + 13: uint16(38568), + 14: uint16(36978), + 15: uint16(36994), + 16: uint16(36989), + 17: uint16(36993), + 18: uint16(36992), + 19: uint16(37002), + 20: uint16(37001), + 21: uint16(37007), + 22: uint16(37032), + 23: uint16(37039), + 24: uint16(37041), + 25: uint16(37045), + 26: uint16(37090), + 27: uint16(37092), + 28: uint16(25160), + 29: uint16(37083), + 30: uint16(37122), + 31: uint16(37138), + 32: uint16(37145), + 33: uint16(37170), + 34: uint16(37168), + 35: uint16(37194), + 36: uint16(37206), + 37: uint16(37208), + 38: uint16(37219), + 39: uint16(37221), + 40: uint16(37225), + 41: uint16(37235), + 42: uint16(37234), + 43: uint16(37259), + 44: uint16(37257), + 45: uint16(37250), + 46: uint16(37282), + 47: uint16(37291), + 48: uint16(37295), + 49: uint16(37290), + 50: uint16(37301), + 51: uint16(37300), + 52: uint16(37306), + 53: uint16(37312), + 54: uint16(37313), + 55: uint16(37321), + 56: uint16(37323), + 57: uint16(37328), + 58: uint16(37334), + 59: uint16(37343), + 60: uint16(37345), + 61: uint16(37339), + 62: uint16(37372), + 63: uint16(37365), + 64: uint16(37366), + 65: uint16(37406), + 66: uint16(37375), + 67: uint16(37396), + 68: uint16(37420), + 69: uint16(37397), + 70: uint16(37393), + 71: uint16(37470), + 72: uint16(37463), + 73: uint16(37445), + 74: uint16(37449), + 75: uint16(37476), + 76: uint16(37448), + 77: uint16(37525), + 78: uint16(37439), + 79: uint16(37451), + 80: uint16(37456), + 81: uint16(37532), + 82: uint16(37526), + 83: uint16(37523), + 84: uint16(37531), + 85: uint16(37466), + 86: uint16(37583), + 87: uint16(37561), + 88: uint16(37559), + 89: uint16(37609), + 90: uint16(37647), + 91: uint16(37626), + 92: uint16(37700), + 93: uint16(37678), + }, + 78: { + 0: uint16(37657), + 1: uint16(37666), + 2: uint16(37658), + 3: uint16(37667), + 4: uint16(37690), + 5: uint16(37685), + 6: uint16(37691), + 7: uint16(37724), + 8: uint16(37728), + 9: uint16(37756), + 10: uint16(37742), + 11: uint16(37718), + 12: uint16(37808), + 13: uint16(37804), + 14: uint16(37805), + 15: uint16(37780), + 16: uint16(37817), + 17: uint16(37846), + 18: uint16(37847), + 19: uint16(37864), + 20: uint16(37861), + 21: uint16(37848), + 22: uint16(37827), + 23: uint16(37853), + 24: uint16(37840), + 25: uint16(37832), + 26: uint16(37860), + 27: uint16(37914), + 28: uint16(37908), + 29: uint16(37907), + 30: uint16(37891), + 31: uint16(37895), + 32: uint16(37904), + 33: uint16(37942), + 34: uint16(37931), + 35: uint16(37941), + 36: uint16(37921), + 37: uint16(37946), + 38: uint16(37953), + 39: uint16(37970), + 40: uint16(37956), + 41: uint16(37979), + 42: uint16(37984), + 43: uint16(37986), + 44: uint16(37982), + 45: uint16(37994), + 46: uint16(37417), + 47: uint16(38000), + 48: uint16(38005), + 49: uint16(38007), + 50: uint16(38013), + 51: uint16(37978), + 52: uint16(38012), + 53: uint16(38014), + 54: uint16(38017), + 55: uint16(38015), + 56: uint16(38274), + 57: uint16(38279), + 58: uint16(38282), + 59: uint16(38292), + 60: uint16(38294), + 61: uint16(38296), + 62: uint16(38297), + 63: uint16(38304), + 64: uint16(38312), + 65: uint16(38311), + 66: uint16(38317), + 67: uint16(38332), + 68: uint16(38331), + 69: uint16(38329), + 70: uint16(38334), + 71: uint16(38346), + 72: uint16(28662), + 73: uint16(38339), + 74: uint16(38349), + 75: uint16(38348), + 76: uint16(38357), + 77: uint16(38356), + 78: uint16(38358), + 79: uint16(38364), + 80: uint16(38369), + 81: uint16(38373), + 82: uint16(38370), + 83: uint16(38433), + 84: uint16(38440), + 85: uint16(38446), + 86: uint16(38447), + 87: uint16(38466), + 88: uint16(38476), + 89: uint16(38479), + 90: uint16(38475), + 91: uint16(38519), + 92: uint16(38492), + 93: uint16(38494), + }, + 79: { + 0: uint16(38493), + 1: uint16(38495), + 2: uint16(38502), + 3: uint16(38514), + 4: uint16(38508), + 5: uint16(38541), + 6: uint16(38552), + 7: uint16(38549), + 8: uint16(38551), + 9: uint16(38570), + 10: uint16(38567), + 11: uint16(38577), + 12: uint16(38578), + 13: uint16(38576), + 14: uint16(38580), + 15: uint16(38582), + 16: uint16(38584), + 17: uint16(38585), + 18: uint16(38606), + 19: uint16(38603), + 20: uint16(38601), + 21: uint16(38605), + 22: uint16(35149), + 23: uint16(38620), + 24: uint16(38669), + 25: uint16(38613), + 26: uint16(38649), + 27: uint16(38660), + 28: uint16(38662), + 29: uint16(38664), + 30: uint16(38675), + 31: uint16(38670), + 32: uint16(38673), + 33: uint16(38671), + 34: uint16(38678), + 35: uint16(38681), + 36: uint16(38692), + 37: uint16(38698), + 38: uint16(38704), + 39: uint16(38713), + 40: uint16(38717), + 41: uint16(38718), + 42: uint16(38724), + 43: uint16(38726), + 44: uint16(38728), + 45: uint16(38722), + 46: uint16(38729), + 47: uint16(38748), + 48: uint16(38752), + 49: uint16(38756), + 50: uint16(38758), + 51: uint16(38760), + 52: uint16(21202), + 53: uint16(38763), + 54: uint16(38769), + 55: uint16(38777), + 56: uint16(38789), + 57: uint16(38780), + 58: uint16(38785), + 59: uint16(38778), + 60: uint16(38790), + 61: uint16(38795), + 62: uint16(38799), + 63: uint16(38800), + 64: uint16(38812), + 65: uint16(38824), + 66: uint16(38822), + 67: uint16(38819), + 68: uint16(38835), + 69: uint16(38836), + 70: uint16(38851), + 71: uint16(38854), + 72: uint16(38856), + 73: uint16(38859), + 74: uint16(38876), + 75: uint16(38893), + 76: uint16(40783), + 77: uint16(38898), + 78: uint16(31455), + 79: uint16(38902), + 80: uint16(38901), + 81: uint16(38927), + 82: uint16(38924), + 83: uint16(38968), + 84: uint16(38948), + 85: uint16(38945), + 86: uint16(38967), + 87: uint16(38973), + 88: uint16(38982), + 89: uint16(38991), + 90: uint16(38987), + 91: uint16(39019), + 92: uint16(39023), + 93: uint16(39024), + }, + 80: { + 0: uint16(39025), + 1: uint16(39028), + 2: uint16(39027), + 3: uint16(39082), + 4: uint16(39087), + 5: uint16(39089), + 6: uint16(39094), + 7: uint16(39108), + 8: uint16(39107), + 9: uint16(39110), + 10: uint16(39145), + 11: uint16(39147), + 12: uint16(39171), + 13: uint16(39177), + 14: uint16(39186), + 15: uint16(39188), + 16: uint16(39192), + 17: uint16(39201), + 18: uint16(39197), + 19: uint16(39198), + 20: uint16(39204), + 21: uint16(39200), + 22: uint16(39212), + 23: uint16(39214), + 24: uint16(39229), + 25: uint16(39230), + 26: uint16(39234), + 27: uint16(39241), + 28: uint16(39237), + 29: uint16(39248), + 30: uint16(39243), + 31: uint16(39249), + 32: uint16(39250), + 33: uint16(39244), + 34: uint16(39253), + 35: uint16(39319), + 36: uint16(39320), + 37: uint16(39333), + 38: uint16(39341), + 39: uint16(39342), + 40: uint16(39356), + 41: uint16(39391), + 42: uint16(39387), + 43: uint16(39389), + 44: uint16(39384), + 45: uint16(39377), + 46: uint16(39405), + 47: uint16(39406), + 48: uint16(39409), + 49: uint16(39410), + 50: uint16(39419), + 51: uint16(39416), + 52: uint16(39425), + 53: uint16(39439), + 54: uint16(39429), + 55: uint16(39394), + 56: uint16(39449), + 57: uint16(39467), + 58: uint16(39479), + 59: uint16(39493), + 60: uint16(39490), + 61: uint16(39488), + 62: uint16(39491), + 63: uint16(39486), + 64: uint16(39509), + 65: uint16(39501), + 66: uint16(39515), + 67: uint16(39511), + 68: uint16(39519), + 69: uint16(39522), + 70: uint16(39525), + 71: uint16(39524), + 72: uint16(39529), + 73: uint16(39531), + 74: uint16(39530), + 75: uint16(39597), + 76: uint16(39600), + 77: uint16(39612), + 78: uint16(39616), + 79: uint16(39631), + 80: uint16(39633), + 81: uint16(39635), + 82: uint16(39636), + 83: uint16(39646), + 84: uint16(39647), + 85: uint16(39650), + 86: uint16(39651), + 87: uint16(39654), + 88: uint16(39663), + 89: uint16(39659), + 90: uint16(39662), + 91: uint16(39668), + 92: uint16(39665), + 93: uint16(39671), + }, + 81: { + 0: uint16(39675), + 1: uint16(39686), + 2: uint16(39704), + 3: uint16(39706), + 4: uint16(39711), + 5: uint16(39714), + 6: uint16(39715), + 7: uint16(39717), + 8: uint16(39719), + 9: uint16(39720), + 10: uint16(39721), + 11: uint16(39722), + 12: uint16(39726), + 13: uint16(39727), + 14: uint16(39730), + 15: uint16(39748), + 16: uint16(39747), + 17: uint16(39759), + 18: uint16(39757), + 19: uint16(39758), + 20: uint16(39761), + 21: uint16(39768), + 22: uint16(39796), + 23: uint16(39827), + 24: uint16(39811), + 25: uint16(39825), + 26: uint16(39830), + 27: uint16(39831), + 28: uint16(39839), + 29: uint16(39840), + 30: uint16(39848), + 31: uint16(39860), + 32: uint16(39872), + 33: uint16(39882), + 34: uint16(39865), + 35: uint16(39878), + 36: uint16(39887), + 37: uint16(39889), + 38: uint16(39890), + 39: uint16(39907), + 40: uint16(39906), + 41: uint16(39908), + 42: uint16(39892), + 43: uint16(39905), + 44: uint16(39994), + 45: uint16(39922), + 46: uint16(39921), + 47: uint16(39920), + 48: uint16(39957), + 49: uint16(39956), + 50: uint16(39945), + 51: uint16(39955), + 52: uint16(39948), + 53: uint16(39942), + 54: uint16(39944), + 55: uint16(39954), + 56: uint16(39946), + 57: uint16(39940), + 58: uint16(39982), + 59: uint16(39963), + 60: uint16(39973), + 61: uint16(39972), + 62: uint16(39969), + 63: uint16(39984), + 64: uint16(40007), + 65: uint16(39986), + 66: uint16(40006), + 67: uint16(39998), + 68: uint16(40026), + 69: uint16(40032), + 70: uint16(40039), + 71: uint16(40054), + 72: uint16(40056), + 73: uint16(40167), + 74: uint16(40172), + 75: uint16(40176), + 76: uint16(40201), + 77: uint16(40200), + 78: uint16(40171), + 79: uint16(40195), + 80: uint16(40198), + 81: uint16(40234), + 82: uint16(40230), + 83: uint16(40367), + 84: uint16(40227), + 85: uint16(40223), + 86: uint16(40260), + 87: uint16(40213), + 88: uint16(40210), + 89: uint16(40257), + 90: uint16(40255), + 91: uint16(40254), + 92: uint16(40262), + 93: uint16(40264), + }, + 82: { + 0: uint16(40285), + 1: uint16(40286), + 2: uint16(40292), + 3: uint16(40273), + 4: uint16(40272), + 5: uint16(40281), + 6: uint16(40306), + 7: uint16(40329), + 8: uint16(40327), + 9: uint16(40363), + 10: uint16(40303), + 11: uint16(40314), + 12: uint16(40346), + 13: uint16(40356), + 14: uint16(40361), + 15: uint16(40370), + 16: uint16(40388), + 17: uint16(40385), + 18: uint16(40379), + 19: uint16(40376), + 20: uint16(40378), + 21: uint16(40390), + 22: uint16(40399), + 23: uint16(40386), + 24: uint16(40409), + 25: uint16(40403), + 26: uint16(40440), + 27: uint16(40422), + 28: uint16(40429), + 29: uint16(40431), + 30: uint16(40445), + 31: uint16(40474), + 32: uint16(40475), + 33: uint16(40478), + 34: uint16(40565), + 35: uint16(40569), + 36: uint16(40573), + 37: uint16(40577), + 38: uint16(40584), + 39: uint16(40587), + 40: uint16(40588), + 41: uint16(40594), + 42: uint16(40597), + 43: uint16(40593), + 44: uint16(40605), + 45: uint16(40613), + 46: uint16(40617), + 47: uint16(40632), + 48: uint16(40618), + 49: uint16(40621), + 50: uint16(38753), + 51: uint16(40652), + 52: uint16(40654), + 53: uint16(40655), + 54: uint16(40656), + 55: uint16(40660), + 56: uint16(40668), + 57: uint16(40670), + 58: uint16(40669), + 59: uint16(40672), + 60: uint16(40677), + 61: uint16(40680), + 62: uint16(40687), + 63: uint16(40692), + 64: uint16(40694), + 65: uint16(40695), + 66: uint16(40697), + 67: uint16(40699), + 68: uint16(40700), + 69: uint16(40701), + 70: uint16(40711), + 71: uint16(40712), + 72: uint16(30391), + 73: uint16(40725), + 74: uint16(40737), + 75: uint16(40748), + 76: uint16(40766), + 77: uint16(40778), + 78: uint16(40786), + 79: uint16(40788), + 80: uint16(40803), + 81: uint16(40799), + 82: uint16(40800), + 83: uint16(40801), + 84: uint16(40806), + 85: uint16(40807), + 86: uint16(40812), + 87: uint16(40810), + 88: uint16(40823), + 89: uint16(40818), + 90: uint16(40822), + 91: uint16(40853), + 92: uint16(40860), + 93: uint16(40864), + }, + 83: { + 0: uint16(22575), + 1: uint16(27079), + 2: uint16(36953), + 3: uint16(29796), + 4: uint16(20956), + 5: uint16(29081), + }, +} + +var _gb18030 = [126][190]uint16{ + 0: { + 0: uint16(19970), + 1: uint16(19972), + 2: uint16(19973), + 3: uint16(19974), + 4: uint16(19983), + 5: uint16(19986), + 6: uint16(19991), + 7: uint16(19999), + 8: uint16(20000), + 9: uint16(20001), + 10: uint16(20003), + 11: uint16(20006), + 12: uint16(20009), + 13: uint16(20014), + 14: uint16(20015), + 15: uint16(20017), + 16: uint16(20019), + 17: uint16(20021), + 18: uint16(20023), + 19: uint16(20028), + 20: uint16(20032), + 21: uint16(20033), + 22: uint16(20034), + 23: uint16(20036), + 24: uint16(20038), + 25: uint16(20042), + 26: uint16(20049), + 27: uint16(20053), + 28: uint16(20055), + 29: uint16(20058), + 30: uint16(20059), + 31: uint16(20066), + 32: uint16(20067), + 33: uint16(20068), + 34: uint16(20069), + 35: uint16(20071), + 36: uint16(20072), + 37: uint16(20074), + 38: uint16(20075), + 39: uint16(20076), + 40: uint16(20077), + 41: uint16(20078), + 42: uint16(20079), + 43: uint16(20082), + 44: uint16(20084), + 45: uint16(20085), + 46: uint16(20086), + 47: uint16(20087), + 48: uint16(20088), + 49: uint16(20089), + 50: uint16(20090), + 51: uint16(20091), + 52: uint16(20092), + 53: uint16(20093), + 54: uint16(20095), + 55: uint16(20096), + 56: uint16(20097), + 57: uint16(20098), + 58: uint16(20099), + 59: uint16(20100), + 60: uint16(20101), + 61: uint16(20103), + 62: uint16(20106), + 63: uint16(20112), + 64: uint16(20118), + 65: uint16(20119), + 66: uint16(20121), + 67: uint16(20124), + 68: uint16(20125), + 69: uint16(20126), + 70: uint16(20131), + 71: uint16(20138), + 72: uint16(20143), + 73: uint16(20144), + 74: uint16(20145), + 75: uint16(20148), + 76: uint16(20150), + 77: uint16(20151), + 78: uint16(20152), + 79: uint16(20153), + 80: uint16(20156), + 81: uint16(20157), + 82: uint16(20158), + 83: uint16(20168), + 84: uint16(20172), + 85: uint16(20175), + 86: uint16(20176), + 87: uint16(20178), + 88: uint16(20186), + 89: uint16(20187), + 90: uint16(20188), + 91: uint16(20192), + 92: uint16(20194), + 93: uint16(20198), + 94: uint16(20199), + 95: uint16(20201), + 96: uint16(20205), + 97: uint16(20206), + 98: uint16(20207), + 99: uint16(20209), + 100: uint16(20212), + 101: uint16(20216), + 102: uint16(20217), + 103: uint16(20218), + 104: uint16(20220), + 105: uint16(20222), + 106: uint16(20224), + 107: uint16(20226), + 108: uint16(20227), + 109: uint16(20228), + 110: uint16(20229), + 111: uint16(20230), + 112: uint16(20231), + 113: uint16(20232), + 114: uint16(20235), + 115: uint16(20236), + 116: uint16(20242), + 117: uint16(20243), + 118: uint16(20244), + 119: uint16(20245), + 120: uint16(20246), + 121: uint16(20252), + 122: uint16(20253), + 123: uint16(20257), + 124: uint16(20259), + 125: uint16(20264), + 126: uint16(20265), + 127: uint16(20268), + 128: uint16(20269), + 129: uint16(20270), + 130: uint16(20273), + 131: uint16(20275), + 132: uint16(20277), + 133: uint16(20279), + 134: uint16(20281), + 135: uint16(20283), + 136: uint16(20286), + 137: uint16(20287), + 138: uint16(20288), + 139: uint16(20289), + 140: uint16(20290), + 141: uint16(20292), + 142: uint16(20293), + 143: uint16(20295), + 144: uint16(20296), + 145: uint16(20297), + 146: uint16(20298), + 147: uint16(20299), + 148: uint16(20300), + 149: uint16(20306), + 150: uint16(20308), + 151: uint16(20310), + 152: uint16(20321), + 153: uint16(20322), + 154: uint16(20326), + 155: uint16(20328), + 156: uint16(20330), + 157: uint16(20331), + 158: uint16(20333), + 159: uint16(20334), + 160: uint16(20337), + 161: uint16(20338), + 162: uint16(20341), + 163: uint16(20343), + 164: uint16(20344), + 165: uint16(20345), + 166: uint16(20346), + 167: uint16(20349), + 168: uint16(20352), + 169: uint16(20353), + 170: uint16(20354), + 171: uint16(20357), + 172: uint16(20358), + 173: uint16(20359), + 174: uint16(20362), + 175: uint16(20364), + 176: uint16(20366), + 177: uint16(20368), + 178: uint16(20370), + 179: uint16(20371), + 180: uint16(20373), + 181: uint16(20374), + 182: uint16(20376), + 183: uint16(20377), + 184: uint16(20378), + 185: uint16(20380), + 186: uint16(20382), + 187: uint16(20383), + 188: uint16(20385), + 189: uint16(20386), + }, + 1: { + 0: uint16(20388), + 1: uint16(20395), + 2: uint16(20397), + 3: uint16(20400), + 4: uint16(20401), + 5: uint16(20402), + 6: uint16(20403), + 7: uint16(20404), + 8: uint16(20406), + 9: uint16(20407), + 10: uint16(20408), + 11: uint16(20409), + 12: uint16(20410), + 13: uint16(20411), + 14: uint16(20412), + 15: uint16(20413), + 16: uint16(20414), + 17: uint16(20416), + 18: uint16(20417), + 19: uint16(20418), + 20: uint16(20422), + 21: uint16(20423), + 22: uint16(20424), + 23: uint16(20425), + 24: uint16(20427), + 25: uint16(20428), + 26: uint16(20429), + 27: uint16(20434), + 28: uint16(20435), + 29: uint16(20436), + 30: uint16(20437), + 31: uint16(20438), + 32: uint16(20441), + 33: uint16(20443), + 34: uint16(20448), + 35: uint16(20450), + 36: uint16(20452), + 37: uint16(20453), + 38: uint16(20455), + 39: uint16(20459), + 40: uint16(20460), + 41: uint16(20464), + 42: uint16(20466), + 43: uint16(20468), + 44: uint16(20469), + 45: uint16(20470), + 46: uint16(20471), + 47: uint16(20473), + 48: uint16(20475), + 49: uint16(20476), + 50: uint16(20477), + 51: uint16(20479), + 52: uint16(20480), + 53: uint16(20481), + 54: uint16(20482), + 55: uint16(20483), + 56: uint16(20484), + 57: uint16(20485), + 58: uint16(20486), + 59: uint16(20487), + 60: uint16(20488), + 61: uint16(20489), + 62: uint16(20490), + 63: uint16(20491), + 64: uint16(20494), + 65: uint16(20496), + 66: uint16(20497), + 67: uint16(20499), + 68: uint16(20501), + 69: uint16(20502), + 70: uint16(20503), + 71: uint16(20507), + 72: uint16(20509), + 73: uint16(20510), + 74: uint16(20512), + 75: uint16(20514), + 76: uint16(20515), + 77: uint16(20516), + 78: uint16(20519), + 79: uint16(20523), + 80: uint16(20527), + 81: uint16(20528), + 82: uint16(20529), + 83: uint16(20530), + 84: uint16(20531), + 85: uint16(20532), + 86: uint16(20533), + 87: uint16(20534), + 88: uint16(20535), + 89: uint16(20536), + 90: uint16(20537), + 91: uint16(20539), + 92: uint16(20541), + 93: uint16(20543), + 94: uint16(20544), + 95: uint16(20545), + 96: uint16(20546), + 97: uint16(20548), + 98: uint16(20549), + 99: uint16(20550), + 100: uint16(20553), + 101: uint16(20554), + 102: uint16(20555), + 103: uint16(20557), + 104: uint16(20560), + 105: uint16(20561), + 106: uint16(20562), + 107: uint16(20563), + 108: uint16(20564), + 109: uint16(20566), + 110: uint16(20567), + 111: uint16(20568), + 112: uint16(20569), + 113: uint16(20571), + 114: uint16(20573), + 115: uint16(20574), + 116: uint16(20575), + 117: uint16(20576), + 118: uint16(20577), + 119: uint16(20578), + 120: uint16(20579), + 121: uint16(20580), + 122: uint16(20582), + 123: uint16(20583), + 124: uint16(20584), + 125: uint16(20585), + 126: uint16(20586), + 127: uint16(20587), + 128: uint16(20589), + 129: uint16(20590), + 130: uint16(20591), + 131: uint16(20592), + 132: uint16(20593), + 133: uint16(20594), + 134: uint16(20595), + 135: uint16(20596), + 136: uint16(20597), + 137: uint16(20600), + 138: uint16(20601), + 139: uint16(20602), + 140: uint16(20604), + 141: uint16(20605), + 142: uint16(20609), + 143: uint16(20610), + 144: uint16(20611), + 145: uint16(20612), + 146: uint16(20614), + 147: uint16(20615), + 148: uint16(20617), + 149: uint16(20618), + 150: uint16(20619), + 151: uint16(20620), + 152: uint16(20622), + 153: uint16(20623), + 154: uint16(20624), + 155: uint16(20625), + 156: uint16(20626), + 157: uint16(20627), + 158: uint16(20628), + 159: uint16(20629), + 160: uint16(20630), + 161: uint16(20631), + 162: uint16(20632), + 163: uint16(20633), + 164: uint16(20634), + 165: uint16(20635), + 166: uint16(20636), + 167: uint16(20637), + 168: uint16(20638), + 169: uint16(20639), + 170: uint16(20640), + 171: uint16(20641), + 172: uint16(20642), + 173: uint16(20644), + 174: uint16(20646), + 175: uint16(20650), + 176: uint16(20651), + 177: uint16(20653), + 178: uint16(20654), + 179: uint16(20655), + 180: uint16(20656), + 181: uint16(20657), + 182: uint16(20659), + 183: uint16(20660), + 184: uint16(20661), + 185: uint16(20662), + 186: uint16(20663), + 187: uint16(20664), + 188: uint16(20665), + 189: uint16(20668), + }, + 2: { + 0: uint16(20669), + 1: uint16(20670), + 2: uint16(20671), + 3: uint16(20672), + 4: uint16(20673), + 5: uint16(20674), + 6: uint16(20675), + 7: uint16(20676), + 8: uint16(20677), + 9: uint16(20678), + 10: uint16(20679), + 11: uint16(20680), + 12: uint16(20681), + 13: uint16(20682), + 14: uint16(20683), + 15: uint16(20684), + 16: uint16(20685), + 17: uint16(20686), + 18: uint16(20688), + 19: uint16(20689), + 20: uint16(20690), + 21: uint16(20691), + 22: uint16(20692), + 23: uint16(20693), + 24: uint16(20695), + 25: uint16(20696), + 26: uint16(20697), + 27: uint16(20699), + 28: uint16(20700), + 29: uint16(20701), + 30: uint16(20702), + 31: uint16(20703), + 32: uint16(20704), + 33: uint16(20705), + 34: uint16(20706), + 35: uint16(20707), + 36: uint16(20708), + 37: uint16(20709), + 38: uint16(20712), + 39: uint16(20713), + 40: uint16(20714), + 41: uint16(20715), + 42: uint16(20719), + 43: uint16(20720), + 44: uint16(20721), + 45: uint16(20722), + 46: uint16(20724), + 47: uint16(20726), + 48: uint16(20727), + 49: uint16(20728), + 50: uint16(20729), + 51: uint16(20730), + 52: uint16(20732), + 53: uint16(20733), + 54: uint16(20734), + 55: uint16(20735), + 56: uint16(20736), + 57: uint16(20737), + 58: uint16(20738), + 59: uint16(20739), + 60: uint16(20740), + 61: uint16(20741), + 62: uint16(20744), + 63: uint16(20745), + 64: uint16(20746), + 65: uint16(20748), + 66: uint16(20749), + 67: uint16(20750), + 68: uint16(20751), + 69: uint16(20752), + 70: uint16(20753), + 71: uint16(20755), + 72: uint16(20756), + 73: uint16(20757), + 74: uint16(20758), + 75: uint16(20759), + 76: uint16(20760), + 77: uint16(20761), + 78: uint16(20762), + 79: uint16(20763), + 80: uint16(20764), + 81: uint16(20765), + 82: uint16(20766), + 83: uint16(20767), + 84: uint16(20768), + 85: uint16(20770), + 86: uint16(20771), + 87: uint16(20772), + 88: uint16(20773), + 89: uint16(20774), + 90: uint16(20775), + 91: uint16(20776), + 92: uint16(20777), + 93: uint16(20778), + 94: uint16(20779), + 95: uint16(20780), + 96: uint16(20781), + 97: uint16(20782), + 98: uint16(20783), + 99: uint16(20784), + 100: uint16(20785), + 101: uint16(20786), + 102: uint16(20787), + 103: uint16(20788), + 104: uint16(20789), + 105: uint16(20790), + 106: uint16(20791), + 107: uint16(20792), + 108: uint16(20793), + 109: uint16(20794), + 110: uint16(20795), + 111: uint16(20796), + 112: uint16(20797), + 113: uint16(20798), + 114: uint16(20802), + 115: uint16(20807), + 116: uint16(20810), + 117: uint16(20812), + 118: uint16(20814), + 119: uint16(20815), + 120: uint16(20816), + 121: uint16(20818), + 122: uint16(20819), + 123: uint16(20823), + 124: uint16(20824), + 125: uint16(20825), + 126: uint16(20827), + 127: uint16(20829), + 128: uint16(20830), + 129: uint16(20831), + 130: uint16(20832), + 131: uint16(20833), + 132: uint16(20835), + 133: uint16(20836), + 134: uint16(20838), + 135: uint16(20839), + 136: uint16(20841), + 137: uint16(20842), + 138: uint16(20847), + 139: uint16(20850), + 140: uint16(20858), + 141: uint16(20862), + 142: uint16(20863), + 143: uint16(20867), + 144: uint16(20868), + 145: uint16(20870), + 146: uint16(20871), + 147: uint16(20874), + 148: uint16(20875), + 149: uint16(20878), + 150: uint16(20879), + 151: uint16(20880), + 152: uint16(20881), + 153: uint16(20883), + 154: uint16(20884), + 155: uint16(20888), + 156: uint16(20890), + 157: uint16(20893), + 158: uint16(20894), + 159: uint16(20895), + 160: uint16(20897), + 161: uint16(20899), + 162: uint16(20902), + 163: uint16(20903), + 164: uint16(20904), + 165: uint16(20905), + 166: uint16(20906), + 167: uint16(20909), + 168: uint16(20910), + 169: uint16(20916), + 170: uint16(20920), + 171: uint16(20921), + 172: uint16(20922), + 173: uint16(20926), + 174: uint16(20927), + 175: uint16(20929), + 176: uint16(20930), + 177: uint16(20931), + 178: uint16(20933), + 179: uint16(20936), + 180: uint16(20938), + 181: uint16(20941), + 182: uint16(20942), + 183: uint16(20944), + 184: uint16(20946), + 185: uint16(20947), + 186: uint16(20948), + 187: uint16(20949), + 188: uint16(20950), + 189: uint16(20951), + }, + 3: { + 0: uint16(20952), + 1: uint16(20953), + 2: uint16(20954), + 3: uint16(20956), + 4: uint16(20958), + 5: uint16(20959), + 6: uint16(20962), + 7: uint16(20963), + 8: uint16(20965), + 9: uint16(20966), + 10: uint16(20967), + 11: uint16(20968), + 12: uint16(20969), + 13: uint16(20970), + 14: uint16(20972), + 15: uint16(20974), + 16: uint16(20977), + 17: uint16(20978), + 18: uint16(20980), + 19: uint16(20983), + 20: uint16(20990), + 21: uint16(20996), + 22: uint16(20997), + 23: uint16(21001), + 24: uint16(21003), + 25: uint16(21004), + 26: uint16(21007), + 27: uint16(21008), + 28: uint16(21011), + 29: uint16(21012), + 30: uint16(21013), + 31: uint16(21020), + 32: uint16(21022), + 33: uint16(21023), + 34: uint16(21025), + 35: uint16(21026), + 36: uint16(21027), + 37: uint16(21029), + 38: uint16(21030), + 39: uint16(21031), + 40: uint16(21034), + 41: uint16(21036), + 42: uint16(21039), + 43: uint16(21041), + 44: uint16(21042), + 45: uint16(21044), + 46: uint16(21045), + 47: uint16(21052), + 48: uint16(21054), + 49: uint16(21060), + 50: uint16(21061), + 51: uint16(21062), + 52: uint16(21063), + 53: uint16(21064), + 54: uint16(21065), + 55: uint16(21067), + 56: uint16(21070), + 57: uint16(21071), + 58: uint16(21074), + 59: uint16(21075), + 60: uint16(21077), + 61: uint16(21079), + 62: uint16(21080), + 63: uint16(21081), + 64: uint16(21082), + 65: uint16(21083), + 66: uint16(21085), + 67: uint16(21087), + 68: uint16(21088), + 69: uint16(21090), + 70: uint16(21091), + 71: uint16(21092), + 72: uint16(21094), + 73: uint16(21096), + 74: uint16(21099), + 75: uint16(21100), + 76: uint16(21101), + 77: uint16(21102), + 78: uint16(21104), + 79: uint16(21105), + 80: uint16(21107), + 81: uint16(21108), + 82: uint16(21109), + 83: uint16(21110), + 84: uint16(21111), + 85: uint16(21112), + 86: uint16(21113), + 87: uint16(21114), + 88: uint16(21115), + 89: uint16(21116), + 90: uint16(21118), + 91: uint16(21120), + 92: uint16(21123), + 93: uint16(21124), + 94: uint16(21125), + 95: uint16(21126), + 96: uint16(21127), + 97: uint16(21129), + 98: uint16(21130), + 99: uint16(21131), + 100: uint16(21132), + 101: uint16(21133), + 102: uint16(21134), + 103: uint16(21135), + 104: uint16(21137), + 105: uint16(21138), + 106: uint16(21140), + 107: uint16(21141), + 108: uint16(21142), + 109: uint16(21143), + 110: uint16(21144), + 111: uint16(21145), + 112: uint16(21146), + 113: uint16(21148), + 114: uint16(21156), + 115: uint16(21157), + 116: uint16(21158), + 117: uint16(21159), + 118: uint16(21166), + 119: uint16(21167), + 120: uint16(21168), + 121: uint16(21172), + 122: uint16(21173), + 123: uint16(21174), + 124: uint16(21175), + 125: uint16(21176), + 126: uint16(21177), + 127: uint16(21178), + 128: uint16(21179), + 129: uint16(21180), + 130: uint16(21181), + 131: uint16(21184), + 132: uint16(21185), + 133: uint16(21186), + 134: uint16(21188), + 135: uint16(21189), + 136: uint16(21190), + 137: uint16(21192), + 138: uint16(21194), + 139: uint16(21196), + 140: uint16(21197), + 141: uint16(21198), + 142: uint16(21199), + 143: uint16(21201), + 144: uint16(21203), + 145: uint16(21204), + 146: uint16(21205), + 147: uint16(21207), + 148: uint16(21209), + 149: uint16(21210), + 150: uint16(21211), + 151: uint16(21212), + 152: uint16(21213), + 153: uint16(21214), + 154: uint16(21216), + 155: uint16(21217), + 156: uint16(21218), + 157: uint16(21219), + 158: uint16(21221), + 159: uint16(21222), + 160: uint16(21223), + 161: uint16(21224), + 162: uint16(21225), + 163: uint16(21226), + 164: uint16(21227), + 165: uint16(21228), + 166: uint16(21229), + 167: uint16(21230), + 168: uint16(21231), + 169: uint16(21233), + 170: uint16(21234), + 171: uint16(21235), + 172: uint16(21236), + 173: uint16(21237), + 174: uint16(21238), + 175: uint16(21239), + 176: uint16(21240), + 177: uint16(21243), + 178: uint16(21244), + 179: uint16(21245), + 180: uint16(21249), + 181: uint16(21250), + 182: uint16(21251), + 183: uint16(21252), + 184: uint16(21255), + 185: uint16(21257), + 186: uint16(21258), + 187: uint16(21259), + 188: uint16(21260), + 189: uint16(21262), + }, + 4: { + 0: uint16(21265), + 1: uint16(21266), + 2: uint16(21267), + 3: uint16(21268), + 4: uint16(21272), + 5: uint16(21275), + 6: uint16(21276), + 7: uint16(21278), + 8: uint16(21279), + 9: uint16(21282), + 10: uint16(21284), + 11: uint16(21285), + 12: uint16(21287), + 13: uint16(21288), + 14: uint16(21289), + 15: uint16(21291), + 16: uint16(21292), + 17: uint16(21293), + 18: uint16(21295), + 19: uint16(21296), + 20: uint16(21297), + 21: uint16(21298), + 22: uint16(21299), + 23: uint16(21300), + 24: uint16(21301), + 25: uint16(21302), + 26: uint16(21303), + 27: uint16(21304), + 28: uint16(21308), + 29: uint16(21309), + 30: uint16(21312), + 31: uint16(21314), + 32: uint16(21316), + 33: uint16(21318), + 34: uint16(21323), + 35: uint16(21324), + 36: uint16(21325), + 37: uint16(21328), + 38: uint16(21332), + 39: uint16(21336), + 40: uint16(21337), + 41: uint16(21339), + 42: uint16(21341), + 43: uint16(21349), + 44: uint16(21352), + 45: uint16(21354), + 46: uint16(21356), + 47: uint16(21357), + 48: uint16(21362), + 49: uint16(21366), + 50: uint16(21369), + 51: uint16(21371), + 52: uint16(21372), + 53: uint16(21373), + 54: uint16(21374), + 55: uint16(21376), + 56: uint16(21377), + 57: uint16(21379), + 58: uint16(21383), + 59: uint16(21384), + 60: uint16(21386), + 61: uint16(21390), + 62: uint16(21391), + 63: uint16(21392), + 64: uint16(21393), + 65: uint16(21394), + 66: uint16(21395), + 67: uint16(21396), + 68: uint16(21398), + 69: uint16(21399), + 70: uint16(21401), + 71: uint16(21403), + 72: uint16(21404), + 73: uint16(21406), + 74: uint16(21408), + 75: uint16(21409), + 76: uint16(21412), + 77: uint16(21415), + 78: uint16(21418), + 79: uint16(21419), + 80: uint16(21420), + 81: uint16(21421), + 82: uint16(21423), + 83: uint16(21424), + 84: uint16(21425), + 85: uint16(21426), + 86: uint16(21427), + 87: uint16(21428), + 88: uint16(21429), + 89: uint16(21431), + 90: uint16(21432), + 91: uint16(21433), + 92: uint16(21434), + 93: uint16(21436), + 94: uint16(21437), + 95: uint16(21438), + 96: uint16(21440), + 97: uint16(21443), + 98: uint16(21444), + 99: uint16(21445), + 100: uint16(21446), + 101: uint16(21447), + 102: uint16(21454), + 103: uint16(21455), + 104: uint16(21456), + 105: uint16(21458), + 106: uint16(21459), + 107: uint16(21461), + 108: uint16(21466), + 109: uint16(21468), + 110: uint16(21469), + 111: uint16(21470), + 112: uint16(21473), + 113: uint16(21474), + 114: uint16(21479), + 115: uint16(21492), + 116: uint16(21498), + 117: uint16(21502), + 118: uint16(21503), + 119: uint16(21504), + 120: uint16(21506), + 121: uint16(21509), + 122: uint16(21511), + 123: uint16(21515), + 124: uint16(21524), + 125: uint16(21528), + 126: uint16(21529), + 127: uint16(21530), + 128: uint16(21532), + 129: uint16(21538), + 130: uint16(21540), + 131: uint16(21541), + 132: uint16(21546), + 133: uint16(21552), + 134: uint16(21555), + 135: uint16(21558), + 136: uint16(21559), + 137: uint16(21562), + 138: uint16(21565), + 139: uint16(21567), + 140: uint16(21569), + 141: uint16(21570), + 142: uint16(21572), + 143: uint16(21573), + 144: uint16(21575), + 145: uint16(21577), + 146: uint16(21580), + 147: uint16(21581), + 148: uint16(21582), + 149: uint16(21583), + 150: uint16(21585), + 151: uint16(21594), + 152: uint16(21597), + 153: uint16(21598), + 154: uint16(21599), + 155: uint16(21600), + 156: uint16(21601), + 157: uint16(21603), + 158: uint16(21605), + 159: uint16(21607), + 160: uint16(21609), + 161: uint16(21610), + 162: uint16(21611), + 163: uint16(21612), + 164: uint16(21613), + 165: uint16(21614), + 166: uint16(21615), + 167: uint16(21616), + 168: uint16(21620), + 169: uint16(21625), + 170: uint16(21626), + 171: uint16(21630), + 172: uint16(21631), + 173: uint16(21633), + 174: uint16(21635), + 175: uint16(21637), + 176: uint16(21639), + 177: uint16(21640), + 178: uint16(21641), + 179: uint16(21642), + 180: uint16(21645), + 181: uint16(21649), + 182: uint16(21651), + 183: uint16(21655), + 184: uint16(21656), + 185: uint16(21660), + 186: uint16(21662), + 187: uint16(21663), + 188: uint16(21664), + 189: uint16(21665), + }, + 5: { + 0: uint16(21666), + 1: uint16(21669), + 2: uint16(21678), + 3: uint16(21680), + 4: uint16(21682), + 5: uint16(21685), + 6: uint16(21686), + 7: uint16(21687), + 8: uint16(21689), + 9: uint16(21690), + 10: uint16(21692), + 11: uint16(21694), + 12: uint16(21699), + 13: uint16(21701), + 14: uint16(21706), + 15: uint16(21707), + 16: uint16(21718), + 17: uint16(21720), + 18: uint16(21723), + 19: uint16(21728), + 20: uint16(21729), + 21: uint16(21730), + 22: uint16(21731), + 23: uint16(21732), + 24: uint16(21739), + 25: uint16(21740), + 26: uint16(21743), + 27: uint16(21744), + 28: uint16(21745), + 29: uint16(21748), + 30: uint16(21749), + 31: uint16(21750), + 32: uint16(21751), + 33: uint16(21752), + 34: uint16(21753), + 35: uint16(21755), + 36: uint16(21758), + 37: uint16(21760), + 38: uint16(21762), + 39: uint16(21763), + 40: uint16(21764), + 41: uint16(21765), + 42: uint16(21768), + 43: uint16(21770), + 44: uint16(21771), + 45: uint16(21772), + 46: uint16(21773), + 47: uint16(21774), + 48: uint16(21778), + 49: uint16(21779), + 50: uint16(21781), + 51: uint16(21782), + 52: uint16(21783), + 53: uint16(21784), + 54: uint16(21785), + 55: uint16(21786), + 56: uint16(21788), + 57: uint16(21789), + 58: uint16(21790), + 59: uint16(21791), + 60: uint16(21793), + 61: uint16(21797), + 62: uint16(21798), + 63: uint16(21800), + 64: uint16(21801), + 65: uint16(21803), + 66: uint16(21805), + 67: uint16(21810), + 68: uint16(21812), + 69: uint16(21813), + 70: uint16(21814), + 71: uint16(21816), + 72: uint16(21817), + 73: uint16(21818), + 74: uint16(21819), + 75: uint16(21821), + 76: uint16(21824), + 77: uint16(21826), + 78: uint16(21829), + 79: uint16(21831), + 80: uint16(21832), + 81: uint16(21835), + 82: uint16(21836), + 83: uint16(21837), + 84: uint16(21838), + 85: uint16(21839), + 86: uint16(21841), + 87: uint16(21842), + 88: uint16(21843), + 89: uint16(21844), + 90: uint16(21847), + 91: uint16(21848), + 92: uint16(21849), + 93: uint16(21850), + 94: uint16(21851), + 95: uint16(21853), + 96: uint16(21854), + 97: uint16(21855), + 98: uint16(21856), + 99: uint16(21858), + 100: uint16(21859), + 101: uint16(21864), + 102: uint16(21865), + 103: uint16(21867), + 104: uint16(21871), + 105: uint16(21872), + 106: uint16(21873), + 107: uint16(21874), + 108: uint16(21875), + 109: uint16(21876), + 110: uint16(21881), + 111: uint16(21882), + 112: uint16(21885), + 113: uint16(21887), + 114: uint16(21893), + 115: uint16(21894), + 116: uint16(21900), + 117: uint16(21901), + 118: uint16(21902), + 119: uint16(21904), + 120: uint16(21906), + 121: uint16(21907), + 122: uint16(21909), + 123: uint16(21910), + 124: uint16(21911), + 125: uint16(21914), + 126: uint16(21915), + 127: uint16(21918), + 128: uint16(21920), + 129: uint16(21921), + 130: uint16(21922), + 131: uint16(21923), + 132: uint16(21924), + 133: uint16(21925), + 134: uint16(21926), + 135: uint16(21928), + 136: uint16(21929), + 137: uint16(21930), + 138: uint16(21931), + 139: uint16(21932), + 140: uint16(21933), + 141: uint16(21934), + 142: uint16(21935), + 143: uint16(21936), + 144: uint16(21938), + 145: uint16(21940), + 146: uint16(21942), + 147: uint16(21944), + 148: uint16(21946), + 149: uint16(21948), + 150: uint16(21951), + 151: uint16(21952), + 152: uint16(21953), + 153: uint16(21954), + 154: uint16(21955), + 155: uint16(21958), + 156: uint16(21959), + 157: uint16(21960), + 158: uint16(21962), + 159: uint16(21963), + 160: uint16(21966), + 161: uint16(21967), + 162: uint16(21968), + 163: uint16(21973), + 164: uint16(21975), + 165: uint16(21976), + 166: uint16(21977), + 167: uint16(21978), + 168: uint16(21979), + 169: uint16(21982), + 170: uint16(21984), + 171: uint16(21986), + 172: uint16(21991), + 173: uint16(21993), + 174: uint16(21997), + 175: uint16(21998), + 176: uint16(22000), + 177: uint16(22001), + 178: uint16(22004), + 179: uint16(22006), + 180: uint16(22008), + 181: uint16(22009), + 182: uint16(22010), + 183: uint16(22011), + 184: uint16(22012), + 185: uint16(22015), + 186: uint16(22018), + 187: uint16(22019), + 188: uint16(22020), + 189: uint16(22021), + }, + 6: { + 0: uint16(22022), + 1: uint16(22023), + 2: uint16(22026), + 3: uint16(22027), + 4: uint16(22029), + 5: uint16(22032), + 6: uint16(22033), + 7: uint16(22034), + 8: uint16(22035), + 9: uint16(22036), + 10: uint16(22037), + 11: uint16(22038), + 12: uint16(22039), + 13: uint16(22041), + 14: uint16(22042), + 15: uint16(22044), + 16: uint16(22045), + 17: uint16(22048), + 18: uint16(22049), + 19: uint16(22050), + 20: uint16(22053), + 21: uint16(22054), + 22: uint16(22056), + 23: uint16(22057), + 24: uint16(22058), + 25: uint16(22059), + 26: uint16(22062), + 27: uint16(22063), + 28: uint16(22064), + 29: uint16(22067), + 30: uint16(22069), + 31: uint16(22071), + 32: uint16(22072), + 33: uint16(22074), + 34: uint16(22076), + 35: uint16(22077), + 36: uint16(22078), + 37: uint16(22080), + 38: uint16(22081), + 39: uint16(22082), + 40: uint16(22083), + 41: uint16(22084), + 42: uint16(22085), + 43: uint16(22086), + 44: uint16(22087), + 45: uint16(22088), + 46: uint16(22089), + 47: uint16(22090), + 48: uint16(22091), + 49: uint16(22095), + 50: uint16(22096), + 51: uint16(22097), + 52: uint16(22098), + 53: uint16(22099), + 54: uint16(22101), + 55: uint16(22102), + 56: uint16(22106), + 57: uint16(22107), + 58: uint16(22109), + 59: uint16(22110), + 60: uint16(22111), + 61: uint16(22112), + 62: uint16(22113), + 63: uint16(22115), + 64: uint16(22117), + 65: uint16(22118), + 66: uint16(22119), + 67: uint16(22125), + 68: uint16(22126), + 69: uint16(22127), + 70: uint16(22128), + 71: uint16(22130), + 72: uint16(22131), + 73: uint16(22132), + 74: uint16(22133), + 75: uint16(22135), + 76: uint16(22136), + 77: uint16(22137), + 78: uint16(22138), + 79: uint16(22141), + 80: uint16(22142), + 81: uint16(22143), + 82: uint16(22144), + 83: uint16(22145), + 84: uint16(22146), + 85: uint16(22147), + 86: uint16(22148), + 87: uint16(22151), + 88: uint16(22152), + 89: uint16(22153), + 90: uint16(22154), + 91: uint16(22155), + 92: uint16(22156), + 93: uint16(22157), + 94: uint16(22160), + 95: uint16(22161), + 96: uint16(22162), + 97: uint16(22164), + 98: uint16(22165), + 99: uint16(22166), + 100: uint16(22167), + 101: uint16(22168), + 102: uint16(22169), + 103: uint16(22170), + 104: uint16(22171), + 105: uint16(22172), + 106: uint16(22173), + 107: uint16(22174), + 108: uint16(22175), + 109: uint16(22176), + 110: uint16(22177), + 111: uint16(22178), + 112: uint16(22180), + 113: uint16(22181), + 114: uint16(22182), + 115: uint16(22183), + 116: uint16(22184), + 117: uint16(22185), + 118: uint16(22186), + 119: uint16(22187), + 120: uint16(22188), + 121: uint16(22189), + 122: uint16(22190), + 123: uint16(22192), + 124: uint16(22193), + 125: uint16(22194), + 126: uint16(22195), + 127: uint16(22196), + 128: uint16(22197), + 129: uint16(22198), + 130: uint16(22200), + 131: uint16(22201), + 132: uint16(22202), + 133: uint16(22203), + 134: uint16(22205), + 135: uint16(22206), + 136: uint16(22207), + 137: uint16(22208), + 138: uint16(22209), + 139: uint16(22210), + 140: uint16(22211), + 141: uint16(22212), + 142: uint16(22213), + 143: uint16(22214), + 144: uint16(22215), + 145: uint16(22216), + 146: uint16(22217), + 147: uint16(22219), + 148: uint16(22220), + 149: uint16(22221), + 150: uint16(22222), + 151: uint16(22223), + 152: uint16(22224), + 153: uint16(22225), + 154: uint16(22226), + 155: uint16(22227), + 156: uint16(22229), + 157: uint16(22230), + 158: uint16(22232), + 159: uint16(22233), + 160: uint16(22236), + 161: uint16(22243), + 162: uint16(22245), + 163: uint16(22246), + 164: uint16(22247), + 165: uint16(22248), + 166: uint16(22249), + 167: uint16(22250), + 168: uint16(22252), + 169: uint16(22254), + 170: uint16(22255), + 171: uint16(22258), + 172: uint16(22259), + 173: uint16(22262), + 174: uint16(22263), + 175: uint16(22264), + 176: uint16(22267), + 177: uint16(22268), + 178: uint16(22272), + 179: uint16(22273), + 180: uint16(22274), + 181: uint16(22277), + 182: uint16(22279), + 183: uint16(22283), + 184: uint16(22284), + 185: uint16(22285), + 186: uint16(22286), + 187: uint16(22287), + 188: uint16(22288), + 189: uint16(22289), + }, + 7: { + 0: uint16(22290), + 1: uint16(22291), + 2: uint16(22292), + 3: uint16(22293), + 4: uint16(22294), + 5: uint16(22295), + 6: uint16(22296), + 7: uint16(22297), + 8: uint16(22298), + 9: uint16(22299), + 10: uint16(22301), + 11: uint16(22302), + 12: uint16(22304), + 13: uint16(22305), + 14: uint16(22306), + 15: uint16(22308), + 16: uint16(22309), + 17: uint16(22310), + 18: uint16(22311), + 19: uint16(22315), + 20: uint16(22321), + 21: uint16(22322), + 22: uint16(22324), + 23: uint16(22325), + 24: uint16(22326), + 25: uint16(22327), + 26: uint16(22328), + 27: uint16(22332), + 28: uint16(22333), + 29: uint16(22335), + 30: uint16(22337), + 31: uint16(22339), + 32: uint16(22340), + 33: uint16(22341), + 34: uint16(22342), + 35: uint16(22344), + 36: uint16(22345), + 37: uint16(22347), + 38: uint16(22354), + 39: uint16(22355), + 40: uint16(22356), + 41: uint16(22357), + 42: uint16(22358), + 43: uint16(22360), + 44: uint16(22361), + 45: uint16(22370), + 46: uint16(22371), + 47: uint16(22373), + 48: uint16(22375), + 49: uint16(22380), + 50: uint16(22382), + 51: uint16(22384), + 52: uint16(22385), + 53: uint16(22386), + 54: uint16(22388), + 55: uint16(22389), + 56: uint16(22392), + 57: uint16(22393), + 58: uint16(22394), + 59: uint16(22397), + 60: uint16(22398), + 61: uint16(22399), + 62: uint16(22400), + 63: uint16(22401), + 64: uint16(22407), + 65: uint16(22408), + 66: uint16(22409), + 67: uint16(22410), + 68: uint16(22413), + 69: uint16(22414), + 70: uint16(22415), + 71: uint16(22416), + 72: uint16(22417), + 73: uint16(22420), + 74: uint16(22421), + 75: uint16(22422), + 76: uint16(22423), + 77: uint16(22424), + 78: uint16(22425), + 79: uint16(22426), + 80: uint16(22428), + 81: uint16(22429), + 82: uint16(22430), + 83: uint16(22431), + 84: uint16(22437), + 85: uint16(22440), + 86: uint16(22442), + 87: uint16(22444), + 88: uint16(22447), + 89: uint16(22448), + 90: uint16(22449), + 91: uint16(22451), + 92: uint16(22453), + 93: uint16(22454), + 94: uint16(22455), + 95: uint16(22457), + 96: uint16(22458), + 97: uint16(22459), + 98: uint16(22460), + 99: uint16(22461), + 100: uint16(22462), + 101: uint16(22463), + 102: uint16(22464), + 103: uint16(22465), + 104: uint16(22468), + 105: uint16(22469), + 106: uint16(22470), + 107: uint16(22471), + 108: uint16(22472), + 109: uint16(22473), + 110: uint16(22474), + 111: uint16(22476), + 112: uint16(22477), + 113: uint16(22480), + 114: uint16(22481), + 115: uint16(22483), + 116: uint16(22486), + 117: uint16(22487), + 118: uint16(22491), + 119: uint16(22492), + 120: uint16(22494), + 121: uint16(22497), + 122: uint16(22498), + 123: uint16(22499), + 124: uint16(22501), + 125: uint16(22502), + 126: uint16(22503), + 127: uint16(22504), + 128: uint16(22505), + 129: uint16(22506), + 130: uint16(22507), + 131: uint16(22508), + 132: uint16(22510), + 133: uint16(22512), + 134: uint16(22513), + 135: uint16(22514), + 136: uint16(22515), + 137: uint16(22517), + 138: uint16(22518), + 139: uint16(22519), + 140: uint16(22523), + 141: uint16(22524), + 142: uint16(22526), + 143: uint16(22527), + 144: uint16(22529), + 145: uint16(22531), + 146: uint16(22532), + 147: uint16(22533), + 148: uint16(22536), + 149: uint16(22537), + 150: uint16(22538), + 151: uint16(22540), + 152: uint16(22542), + 153: uint16(22543), + 154: uint16(22544), + 155: uint16(22546), + 156: uint16(22547), + 157: uint16(22548), + 158: uint16(22550), + 159: uint16(22551), + 160: uint16(22552), + 161: uint16(22554), + 162: uint16(22555), + 163: uint16(22556), + 164: uint16(22557), + 165: uint16(22559), + 166: uint16(22562), + 167: uint16(22563), + 168: uint16(22565), + 169: uint16(22566), + 170: uint16(22567), + 171: uint16(22568), + 172: uint16(22569), + 173: uint16(22571), + 174: uint16(22572), + 175: uint16(22573), + 176: uint16(22574), + 177: uint16(22575), + 178: uint16(22577), + 179: uint16(22578), + 180: uint16(22579), + 181: uint16(22580), + 182: uint16(22582), + 183: uint16(22583), + 184: uint16(22584), + 185: uint16(22585), + 186: uint16(22586), + 187: uint16(22587), + 188: uint16(22588), + 189: uint16(22589), + }, + 8: { + 0: uint16(22590), + 1: uint16(22591), + 2: uint16(22592), + 3: uint16(22593), + 4: uint16(22594), + 5: uint16(22595), + 6: uint16(22597), + 7: uint16(22598), + 8: uint16(22599), + 9: uint16(22600), + 10: uint16(22601), + 11: uint16(22602), + 12: uint16(22603), + 13: uint16(22606), + 14: uint16(22607), + 15: uint16(22608), + 16: uint16(22610), + 17: uint16(22611), + 18: uint16(22613), + 19: uint16(22614), + 20: uint16(22615), + 21: uint16(22617), + 22: uint16(22618), + 23: uint16(22619), + 24: uint16(22620), + 25: uint16(22621), + 26: uint16(22623), + 27: uint16(22624), + 28: uint16(22625), + 29: uint16(22626), + 30: uint16(22627), + 31: uint16(22628), + 32: uint16(22630), + 33: uint16(22631), + 34: uint16(22632), + 35: uint16(22633), + 36: uint16(22634), + 37: uint16(22637), + 38: uint16(22638), + 39: uint16(22639), + 40: uint16(22640), + 41: uint16(22641), + 42: uint16(22642), + 43: uint16(22643), + 44: uint16(22644), + 45: uint16(22645), + 46: uint16(22646), + 47: uint16(22647), + 48: uint16(22648), + 49: uint16(22649), + 50: uint16(22650), + 51: uint16(22651), + 52: uint16(22652), + 53: uint16(22653), + 54: uint16(22655), + 55: uint16(22658), + 56: uint16(22660), + 57: uint16(22662), + 58: uint16(22663), + 59: uint16(22664), + 60: uint16(22666), + 61: uint16(22667), + 62: uint16(22668), + 63: uint16(22669), + 64: uint16(22670), + 65: uint16(22671), + 66: uint16(22672), + 67: uint16(22673), + 68: uint16(22676), + 69: uint16(22677), + 70: uint16(22678), + 71: uint16(22679), + 72: uint16(22680), + 73: uint16(22683), + 74: uint16(22684), + 75: uint16(22685), + 76: uint16(22688), + 77: uint16(22689), + 78: uint16(22690), + 79: uint16(22691), + 80: uint16(22692), + 81: uint16(22693), + 82: uint16(22694), + 83: uint16(22695), + 84: uint16(22698), + 85: uint16(22699), + 86: uint16(22700), + 87: uint16(22701), + 88: uint16(22702), + 89: uint16(22703), + 90: uint16(22704), + 91: uint16(22705), + 92: uint16(22706), + 93: uint16(22707), + 94: uint16(22708), + 95: uint16(22709), + 96: uint16(22710), + 97: uint16(22711), + 98: uint16(22712), + 99: uint16(22713), + 100: uint16(22714), + 101: uint16(22715), + 102: uint16(22717), + 103: uint16(22718), + 104: uint16(22719), + 105: uint16(22720), + 106: uint16(22722), + 107: uint16(22723), + 108: uint16(22724), + 109: uint16(22726), + 110: uint16(22727), + 111: uint16(22728), + 112: uint16(22729), + 113: uint16(22730), + 114: uint16(22731), + 115: uint16(22732), + 116: uint16(22733), + 117: uint16(22734), + 118: uint16(22735), + 119: uint16(22736), + 120: uint16(22738), + 121: uint16(22739), + 122: uint16(22740), + 123: uint16(22742), + 124: uint16(22743), + 125: uint16(22744), + 126: uint16(22745), + 127: uint16(22746), + 128: uint16(22747), + 129: uint16(22748), + 130: uint16(22749), + 131: uint16(22750), + 132: uint16(22751), + 133: uint16(22752), + 134: uint16(22753), + 135: uint16(22754), + 136: uint16(22755), + 137: uint16(22757), + 138: uint16(22758), + 139: uint16(22759), + 140: uint16(22760), + 141: uint16(22761), + 142: uint16(22762), + 143: uint16(22765), + 144: uint16(22767), + 145: uint16(22769), + 146: uint16(22770), + 147: uint16(22772), + 148: uint16(22773), + 149: uint16(22775), + 150: uint16(22776), + 151: uint16(22778), + 152: uint16(22779), + 153: uint16(22780), + 154: uint16(22781), + 155: uint16(22782), + 156: uint16(22783), + 157: uint16(22784), + 158: uint16(22785), + 159: uint16(22787), + 160: uint16(22789), + 161: uint16(22790), + 162: uint16(22792), + 163: uint16(22793), + 164: uint16(22794), + 165: uint16(22795), + 166: uint16(22796), + 167: uint16(22798), + 168: uint16(22800), + 169: uint16(22801), + 170: uint16(22802), + 171: uint16(22803), + 172: uint16(22807), + 173: uint16(22808), + 174: uint16(22811), + 175: uint16(22813), + 176: uint16(22814), + 177: uint16(22816), + 178: uint16(22817), + 179: uint16(22818), + 180: uint16(22819), + 181: uint16(22822), + 182: uint16(22824), + 183: uint16(22828), + 184: uint16(22832), + 185: uint16(22834), + 186: uint16(22835), + 187: uint16(22837), + 188: uint16(22838), + 189: uint16(22843), + }, + 9: { + 0: uint16(22845), + 1: uint16(22846), + 2: uint16(22847), + 3: uint16(22848), + 4: uint16(22851), + 5: uint16(22853), + 6: uint16(22854), + 7: uint16(22858), + 8: uint16(22860), + 9: uint16(22861), + 10: uint16(22864), + 11: uint16(22866), + 12: uint16(22867), + 13: uint16(22873), + 14: uint16(22875), + 15: uint16(22876), + 16: uint16(22877), + 17: uint16(22878), + 18: uint16(22879), + 19: uint16(22881), + 20: uint16(22883), + 21: uint16(22884), + 22: uint16(22886), + 23: uint16(22887), + 24: uint16(22888), + 25: uint16(22889), + 26: uint16(22890), + 27: uint16(22891), + 28: uint16(22892), + 29: uint16(22893), + 30: uint16(22894), + 31: uint16(22895), + 32: uint16(22896), + 33: uint16(22897), + 34: uint16(22898), + 35: uint16(22901), + 36: uint16(22903), + 37: uint16(22906), + 38: uint16(22907), + 39: uint16(22908), + 40: uint16(22910), + 41: uint16(22911), + 42: uint16(22912), + 43: uint16(22917), + 44: uint16(22921), + 45: uint16(22923), + 46: uint16(22924), + 47: uint16(22926), + 48: uint16(22927), + 49: uint16(22928), + 50: uint16(22929), + 51: uint16(22932), + 52: uint16(22933), + 53: uint16(22936), + 54: uint16(22938), + 55: uint16(22939), + 56: uint16(22940), + 57: uint16(22941), + 58: uint16(22943), + 59: uint16(22944), + 60: uint16(22945), + 61: uint16(22946), + 62: uint16(22950), + 63: uint16(22951), + 64: uint16(22956), + 65: uint16(22957), + 66: uint16(22960), + 67: uint16(22961), + 68: uint16(22963), + 69: uint16(22964), + 70: uint16(22965), + 71: uint16(22966), + 72: uint16(22967), + 73: uint16(22968), + 74: uint16(22970), + 75: uint16(22972), + 76: uint16(22973), + 77: uint16(22975), + 78: uint16(22976), + 79: uint16(22977), + 80: uint16(22978), + 81: uint16(22979), + 82: uint16(22980), + 83: uint16(22981), + 84: uint16(22983), + 85: uint16(22984), + 86: uint16(22985), + 87: uint16(22988), + 88: uint16(22989), + 89: uint16(22990), + 90: uint16(22991), + 91: uint16(22997), + 92: uint16(22998), + 93: uint16(23001), + 94: uint16(23003), + 95: uint16(23006), + 96: uint16(23007), + 97: uint16(23008), + 98: uint16(23009), + 99: uint16(23010), + 100: uint16(23012), + 101: uint16(23014), + 102: uint16(23015), + 103: uint16(23017), + 104: uint16(23018), + 105: uint16(23019), + 106: uint16(23021), + 107: uint16(23022), + 108: uint16(23023), + 109: uint16(23024), + 110: uint16(23025), + 111: uint16(23026), + 112: uint16(23027), + 113: uint16(23028), + 114: uint16(23029), + 115: uint16(23030), + 116: uint16(23031), + 117: uint16(23032), + 118: uint16(23034), + 119: uint16(23036), + 120: uint16(23037), + 121: uint16(23038), + 122: uint16(23040), + 123: uint16(23042), + 124: uint16(23050), + 125: uint16(23051), + 126: uint16(23053), + 127: uint16(23054), + 128: uint16(23055), + 129: uint16(23056), + 130: uint16(23058), + 131: uint16(23060), + 132: uint16(23061), + 133: uint16(23062), + 134: uint16(23063), + 135: uint16(23065), + 136: uint16(23066), + 137: uint16(23067), + 138: uint16(23069), + 139: uint16(23070), + 140: uint16(23073), + 141: uint16(23074), + 142: uint16(23076), + 143: uint16(23078), + 144: uint16(23079), + 145: uint16(23080), + 146: uint16(23082), + 147: uint16(23083), + 148: uint16(23084), + 149: uint16(23085), + 150: uint16(23086), + 151: uint16(23087), + 152: uint16(23088), + 153: uint16(23091), + 154: uint16(23093), + 155: uint16(23095), + 156: uint16(23096), + 157: uint16(23097), + 158: uint16(23098), + 159: uint16(23099), + 160: uint16(23101), + 161: uint16(23102), + 162: uint16(23103), + 163: uint16(23105), + 164: uint16(23106), + 165: uint16(23107), + 166: uint16(23108), + 167: uint16(23109), + 168: uint16(23111), + 169: uint16(23112), + 170: uint16(23115), + 171: uint16(23116), + 172: uint16(23117), + 173: uint16(23118), + 174: uint16(23119), + 175: uint16(23120), + 176: uint16(23121), + 177: uint16(23122), + 178: uint16(23123), + 179: uint16(23124), + 180: uint16(23126), + 181: uint16(23127), + 182: uint16(23128), + 183: uint16(23129), + 184: uint16(23131), + 185: uint16(23132), + 186: uint16(23133), + 187: uint16(23134), + 188: uint16(23135), + 189: uint16(23136), + }, + 10: { + 0: uint16(23137), + 1: uint16(23139), + 2: uint16(23140), + 3: uint16(23141), + 4: uint16(23142), + 5: uint16(23144), + 6: uint16(23145), + 7: uint16(23147), + 8: uint16(23148), + 9: uint16(23149), + 10: uint16(23150), + 11: uint16(23151), + 12: uint16(23152), + 13: uint16(23153), + 14: uint16(23154), + 15: uint16(23155), + 16: uint16(23160), + 17: uint16(23161), + 18: uint16(23163), + 19: uint16(23164), + 20: uint16(23165), + 21: uint16(23166), + 22: uint16(23168), + 23: uint16(23169), + 24: uint16(23170), + 25: uint16(23171), + 26: uint16(23172), + 27: uint16(23173), + 28: uint16(23174), + 29: uint16(23175), + 30: uint16(23176), + 31: uint16(23177), + 32: uint16(23178), + 33: uint16(23179), + 34: uint16(23180), + 35: uint16(23181), + 36: uint16(23182), + 37: uint16(23183), + 38: uint16(23184), + 39: uint16(23185), + 40: uint16(23187), + 41: uint16(23188), + 42: uint16(23189), + 43: uint16(23190), + 44: uint16(23191), + 45: uint16(23192), + 46: uint16(23193), + 47: uint16(23196), + 48: uint16(23197), + 49: uint16(23198), + 50: uint16(23199), + 51: uint16(23200), + 52: uint16(23201), + 53: uint16(23202), + 54: uint16(23203), + 55: uint16(23204), + 56: uint16(23205), + 57: uint16(23206), + 58: uint16(23207), + 59: uint16(23208), + 60: uint16(23209), + 61: uint16(23211), + 62: uint16(23212), + 63: uint16(23213), + 64: uint16(23214), + 65: uint16(23215), + 66: uint16(23216), + 67: uint16(23217), + 68: uint16(23220), + 69: uint16(23222), + 70: uint16(23223), + 71: uint16(23225), + 72: uint16(23226), + 73: uint16(23227), + 74: uint16(23228), + 75: uint16(23229), + 76: uint16(23231), + 77: uint16(23232), + 78: uint16(23235), + 79: uint16(23236), + 80: uint16(23237), + 81: uint16(23238), + 82: uint16(23239), + 83: uint16(23240), + 84: uint16(23242), + 85: uint16(23243), + 86: uint16(23245), + 87: uint16(23246), + 88: uint16(23247), + 89: uint16(23248), + 90: uint16(23249), + 91: uint16(23251), + 92: uint16(23253), + 93: uint16(23255), + 94: uint16(23257), + 95: uint16(23258), + 96: uint16(23259), + 97: uint16(23261), + 98: uint16(23262), + 99: uint16(23263), + 100: uint16(23266), + 101: uint16(23268), + 102: uint16(23269), + 103: uint16(23271), + 104: uint16(23272), + 105: uint16(23274), + 106: uint16(23276), + 107: uint16(23277), + 108: uint16(23278), + 109: uint16(23279), + 110: uint16(23280), + 111: uint16(23282), + 112: uint16(23283), + 113: uint16(23284), + 114: uint16(23285), + 115: uint16(23286), + 116: uint16(23287), + 117: uint16(23288), + 118: uint16(23289), + 119: uint16(23290), + 120: uint16(23291), + 121: uint16(23292), + 122: uint16(23293), + 123: uint16(23294), + 124: uint16(23295), + 125: uint16(23296), + 126: uint16(23297), + 127: uint16(23298), + 128: uint16(23299), + 129: uint16(23300), + 130: uint16(23301), + 131: uint16(23302), + 132: uint16(23303), + 133: uint16(23304), + 134: uint16(23306), + 135: uint16(23307), + 136: uint16(23308), + 137: uint16(23309), + 138: uint16(23310), + 139: uint16(23311), + 140: uint16(23312), + 141: uint16(23313), + 142: uint16(23314), + 143: uint16(23315), + 144: uint16(23316), + 145: uint16(23317), + 146: uint16(23320), + 147: uint16(23321), + 148: uint16(23322), + 149: uint16(23323), + 150: uint16(23324), + 151: uint16(23325), + 152: uint16(23326), + 153: uint16(23327), + 154: uint16(23328), + 155: uint16(23329), + 156: uint16(23330), + 157: uint16(23331), + 158: uint16(23332), + 159: uint16(23333), + 160: uint16(23334), + 161: uint16(23335), + 162: uint16(23336), + 163: uint16(23337), + 164: uint16(23338), + 165: uint16(23339), + 166: uint16(23340), + 167: uint16(23341), + 168: uint16(23342), + 169: uint16(23343), + 170: uint16(23344), + 171: uint16(23345), + 172: uint16(23347), + 173: uint16(23349), + 174: uint16(23350), + 175: uint16(23352), + 176: uint16(23353), + 177: uint16(23354), + 178: uint16(23355), + 179: uint16(23356), + 180: uint16(23357), + 181: uint16(23358), + 182: uint16(23359), + 183: uint16(23361), + 184: uint16(23362), + 185: uint16(23363), + 186: uint16(23364), + 187: uint16(23365), + 188: uint16(23366), + 189: uint16(23367), + }, + 11: { + 0: uint16(23368), + 1: uint16(23369), + 2: uint16(23370), + 3: uint16(23371), + 4: uint16(23372), + 5: uint16(23373), + 6: uint16(23374), + 7: uint16(23375), + 8: uint16(23378), + 9: uint16(23382), + 10: uint16(23390), + 11: uint16(23392), + 12: uint16(23393), + 13: uint16(23399), + 14: uint16(23400), + 15: uint16(23403), + 16: uint16(23405), + 17: uint16(23406), + 18: uint16(23407), + 19: uint16(23410), + 20: uint16(23412), + 21: uint16(23414), + 22: uint16(23415), + 23: uint16(23416), + 24: uint16(23417), + 25: uint16(23419), + 26: uint16(23420), + 27: uint16(23422), + 28: uint16(23423), + 29: uint16(23426), + 30: uint16(23430), + 31: uint16(23434), + 32: uint16(23437), + 33: uint16(23438), + 34: uint16(23440), + 35: uint16(23441), + 36: uint16(23442), + 37: uint16(23444), + 38: uint16(23446), + 39: uint16(23455), + 40: uint16(23463), + 41: uint16(23464), + 42: uint16(23465), + 43: uint16(23468), + 44: uint16(23469), + 45: uint16(23470), + 46: uint16(23471), + 47: uint16(23473), + 48: uint16(23474), + 49: uint16(23479), + 50: uint16(23482), + 51: uint16(23483), + 52: uint16(23484), + 53: uint16(23488), + 54: uint16(23489), + 55: uint16(23491), + 56: uint16(23496), + 57: uint16(23497), + 58: uint16(23498), + 59: uint16(23499), + 60: uint16(23501), + 61: uint16(23502), + 62: uint16(23503), + 63: uint16(23505), + 64: uint16(23508), + 65: uint16(23509), + 66: uint16(23510), + 67: uint16(23511), + 68: uint16(23512), + 69: uint16(23513), + 70: uint16(23514), + 71: uint16(23515), + 72: uint16(23516), + 73: uint16(23520), + 74: uint16(23522), + 75: uint16(23523), + 76: uint16(23526), + 77: uint16(23527), + 78: uint16(23529), + 79: uint16(23530), + 80: uint16(23531), + 81: uint16(23532), + 82: uint16(23533), + 83: uint16(23535), + 84: uint16(23537), + 85: uint16(23538), + 86: uint16(23539), + 87: uint16(23540), + 88: uint16(23541), + 89: uint16(23542), + 90: uint16(23543), + 91: uint16(23549), + 92: uint16(23550), + 93: uint16(23552), + 94: uint16(23554), + 95: uint16(23555), + 96: uint16(23557), + 97: uint16(23559), + 98: uint16(23560), + 99: uint16(23563), + 100: uint16(23564), + 101: uint16(23565), + 102: uint16(23566), + 103: uint16(23568), + 104: uint16(23570), + 105: uint16(23571), + 106: uint16(23575), + 107: uint16(23577), + 108: uint16(23579), + 109: uint16(23582), + 110: uint16(23583), + 111: uint16(23584), + 112: uint16(23585), + 113: uint16(23587), + 114: uint16(23590), + 115: uint16(23592), + 116: uint16(23593), + 117: uint16(23594), + 118: uint16(23595), + 119: uint16(23597), + 120: uint16(23598), + 121: uint16(23599), + 122: uint16(23600), + 123: uint16(23602), + 124: uint16(23603), + 125: uint16(23605), + 126: uint16(23606), + 127: uint16(23607), + 128: uint16(23619), + 129: uint16(23620), + 130: uint16(23622), + 131: uint16(23623), + 132: uint16(23628), + 133: uint16(23629), + 134: uint16(23634), + 135: uint16(23635), + 136: uint16(23636), + 137: uint16(23638), + 138: uint16(23639), + 139: uint16(23640), + 140: uint16(23642), + 141: uint16(23643), + 142: uint16(23644), + 143: uint16(23645), + 144: uint16(23647), + 145: uint16(23650), + 146: uint16(23652), + 147: uint16(23655), + 148: uint16(23656), + 149: uint16(23657), + 150: uint16(23658), + 151: uint16(23659), + 152: uint16(23660), + 153: uint16(23661), + 154: uint16(23664), + 155: uint16(23666), + 156: uint16(23667), + 157: uint16(23668), + 158: uint16(23669), + 159: uint16(23670), + 160: uint16(23671), + 161: uint16(23672), + 162: uint16(23675), + 163: uint16(23676), + 164: uint16(23677), + 165: uint16(23678), + 166: uint16(23680), + 167: uint16(23683), + 168: uint16(23684), + 169: uint16(23685), + 170: uint16(23686), + 171: uint16(23687), + 172: uint16(23689), + 173: uint16(23690), + 174: uint16(23691), + 175: uint16(23694), + 176: uint16(23695), + 177: uint16(23698), + 178: uint16(23699), + 179: uint16(23701), + 180: uint16(23709), + 181: uint16(23710), + 182: uint16(23711), + 183: uint16(23712), + 184: uint16(23713), + 185: uint16(23716), + 186: uint16(23717), + 187: uint16(23718), + 188: uint16(23719), + 189: uint16(23720), + }, + 12: { + 0: uint16(23722), + 1: uint16(23726), + 2: uint16(23727), + 3: uint16(23728), + 4: uint16(23730), + 5: uint16(23732), + 6: uint16(23734), + 7: uint16(23737), + 8: uint16(23738), + 9: uint16(23739), + 10: uint16(23740), + 11: uint16(23742), + 12: uint16(23744), + 13: uint16(23746), + 14: uint16(23747), + 15: uint16(23749), + 16: uint16(23750), + 17: uint16(23751), + 18: uint16(23752), + 19: uint16(23753), + 20: uint16(23754), + 21: uint16(23756), + 22: uint16(23757), + 23: uint16(23758), + 24: uint16(23759), + 25: uint16(23760), + 26: uint16(23761), + 27: uint16(23763), + 28: uint16(23764), + 29: uint16(23765), + 30: uint16(23766), + 31: uint16(23767), + 32: uint16(23768), + 33: uint16(23770), + 34: uint16(23771), + 35: uint16(23772), + 36: uint16(23773), + 37: uint16(23774), + 38: uint16(23775), + 39: uint16(23776), + 40: uint16(23778), + 41: uint16(23779), + 42: uint16(23783), + 43: uint16(23785), + 44: uint16(23787), + 45: uint16(23788), + 46: uint16(23790), + 47: uint16(23791), + 48: uint16(23793), + 49: uint16(23794), + 50: uint16(23795), + 51: uint16(23796), + 52: uint16(23797), + 53: uint16(23798), + 54: uint16(23799), + 55: uint16(23800), + 56: uint16(23801), + 57: uint16(23802), + 58: uint16(23804), + 59: uint16(23805), + 60: uint16(23806), + 61: uint16(23807), + 62: uint16(23808), + 63: uint16(23809), + 64: uint16(23812), + 65: uint16(23813), + 66: uint16(23816), + 67: uint16(23817), + 68: uint16(23818), + 69: uint16(23819), + 70: uint16(23820), + 71: uint16(23821), + 72: uint16(23823), + 73: uint16(23824), + 74: uint16(23825), + 75: uint16(23826), + 76: uint16(23827), + 77: uint16(23829), + 78: uint16(23831), + 79: uint16(23832), + 80: uint16(23833), + 81: uint16(23834), + 82: uint16(23836), + 83: uint16(23837), + 84: uint16(23839), + 85: uint16(23840), + 86: uint16(23841), + 87: uint16(23842), + 88: uint16(23843), + 89: uint16(23845), + 90: uint16(23848), + 91: uint16(23850), + 92: uint16(23851), + 93: uint16(23852), + 94: uint16(23855), + 95: uint16(23856), + 96: uint16(23857), + 97: uint16(23858), + 98: uint16(23859), + 99: uint16(23861), + 100: uint16(23862), + 101: uint16(23863), + 102: uint16(23864), + 103: uint16(23865), + 104: uint16(23866), + 105: uint16(23867), + 106: uint16(23868), + 107: uint16(23871), + 108: uint16(23872), + 109: uint16(23873), + 110: uint16(23874), + 111: uint16(23875), + 112: uint16(23876), + 113: uint16(23877), + 114: uint16(23878), + 115: uint16(23880), + 116: uint16(23881), + 117: uint16(23885), + 118: uint16(23886), + 119: uint16(23887), + 120: uint16(23888), + 121: uint16(23889), + 122: uint16(23890), + 123: uint16(23891), + 124: uint16(23892), + 125: uint16(23893), + 126: uint16(23894), + 127: uint16(23895), + 128: uint16(23897), + 129: uint16(23898), + 130: uint16(23900), + 131: uint16(23902), + 132: uint16(23903), + 133: uint16(23904), + 134: uint16(23905), + 135: uint16(23906), + 136: uint16(23907), + 137: uint16(23908), + 138: uint16(23909), + 139: uint16(23910), + 140: uint16(23911), + 141: uint16(23912), + 142: uint16(23914), + 143: uint16(23917), + 144: uint16(23918), + 145: uint16(23920), + 146: uint16(23921), + 147: uint16(23922), + 148: uint16(23923), + 149: uint16(23925), + 150: uint16(23926), + 151: uint16(23927), + 152: uint16(23928), + 153: uint16(23929), + 154: uint16(23930), + 155: uint16(23931), + 156: uint16(23932), + 157: uint16(23933), + 158: uint16(23934), + 159: uint16(23935), + 160: uint16(23936), + 161: uint16(23937), + 162: uint16(23939), + 163: uint16(23940), + 164: uint16(23941), + 165: uint16(23942), + 166: uint16(23943), + 167: uint16(23944), + 168: uint16(23945), + 169: uint16(23946), + 170: uint16(23947), + 171: uint16(23948), + 172: uint16(23949), + 173: uint16(23950), + 174: uint16(23951), + 175: uint16(23952), + 176: uint16(23953), + 177: uint16(23954), + 178: uint16(23955), + 179: uint16(23956), + 180: uint16(23957), + 181: uint16(23958), + 182: uint16(23959), + 183: uint16(23960), + 184: uint16(23962), + 185: uint16(23963), + 186: uint16(23964), + 187: uint16(23966), + 188: uint16(23967), + 189: uint16(23968), + }, + 13: { + 0: uint16(23969), + 1: uint16(23970), + 2: uint16(23971), + 3: uint16(23972), + 4: uint16(23973), + 5: uint16(23974), + 6: uint16(23975), + 7: uint16(23976), + 8: uint16(23977), + 9: uint16(23978), + 10: uint16(23979), + 11: uint16(23980), + 12: uint16(23981), + 13: uint16(23982), + 14: uint16(23983), + 15: uint16(23984), + 16: uint16(23985), + 17: uint16(23986), + 18: uint16(23987), + 19: uint16(23988), + 20: uint16(23989), + 21: uint16(23990), + 22: uint16(23992), + 23: uint16(23993), + 24: uint16(23994), + 25: uint16(23995), + 26: uint16(23996), + 27: uint16(23997), + 28: uint16(23998), + 29: uint16(23999), + 30: uint16(24000), + 31: uint16(24001), + 32: uint16(24002), + 33: uint16(24003), + 34: uint16(24004), + 35: uint16(24006), + 36: uint16(24007), + 37: uint16(24008), + 38: uint16(24009), + 39: uint16(24010), + 40: uint16(24011), + 41: uint16(24012), + 42: uint16(24014), + 43: uint16(24015), + 44: uint16(24016), + 45: uint16(24017), + 46: uint16(24018), + 47: uint16(24019), + 48: uint16(24020), + 49: uint16(24021), + 50: uint16(24022), + 51: uint16(24023), + 52: uint16(24024), + 53: uint16(24025), + 54: uint16(24026), + 55: uint16(24028), + 56: uint16(24031), + 57: uint16(24032), + 58: uint16(24035), + 59: uint16(24036), + 60: uint16(24042), + 61: uint16(24044), + 62: uint16(24045), + 63: uint16(24048), + 64: uint16(24053), + 65: uint16(24054), + 66: uint16(24056), + 67: uint16(24057), + 68: uint16(24058), + 69: uint16(24059), + 70: uint16(24060), + 71: uint16(24063), + 72: uint16(24064), + 73: uint16(24068), + 74: uint16(24071), + 75: uint16(24073), + 76: uint16(24074), + 77: uint16(24075), + 78: uint16(24077), + 79: uint16(24078), + 80: uint16(24082), + 81: uint16(24083), + 82: uint16(24087), + 83: uint16(24094), + 84: uint16(24095), + 85: uint16(24096), + 86: uint16(24097), + 87: uint16(24098), + 88: uint16(24099), + 89: uint16(24100), + 90: uint16(24101), + 91: uint16(24104), + 92: uint16(24105), + 93: uint16(24106), + 94: uint16(24107), + 95: uint16(24108), + 96: uint16(24111), + 97: uint16(24112), + 98: uint16(24114), + 99: uint16(24115), + 100: uint16(24116), + 101: uint16(24117), + 102: uint16(24118), + 103: uint16(24121), + 104: uint16(24122), + 105: uint16(24126), + 106: uint16(24127), + 107: uint16(24128), + 108: uint16(24129), + 109: uint16(24131), + 110: uint16(24134), + 111: uint16(24135), + 112: uint16(24136), + 113: uint16(24137), + 114: uint16(24138), + 115: uint16(24139), + 116: uint16(24141), + 117: uint16(24142), + 118: uint16(24143), + 119: uint16(24144), + 120: uint16(24145), + 121: uint16(24146), + 122: uint16(24147), + 123: uint16(24150), + 124: uint16(24151), + 125: uint16(24152), + 126: uint16(24153), + 127: uint16(24154), + 128: uint16(24156), + 129: uint16(24157), + 130: uint16(24159), + 131: uint16(24160), + 132: uint16(24163), + 133: uint16(24164), + 134: uint16(24165), + 135: uint16(24166), + 136: uint16(24167), + 137: uint16(24168), + 138: uint16(24169), + 139: uint16(24170), + 140: uint16(24171), + 141: uint16(24172), + 142: uint16(24173), + 143: uint16(24174), + 144: uint16(24175), + 145: uint16(24176), + 146: uint16(24177), + 147: uint16(24181), + 148: uint16(24183), + 149: uint16(24185), + 150: uint16(24190), + 151: uint16(24193), + 152: uint16(24194), + 153: uint16(24195), + 154: uint16(24197), + 155: uint16(24200), + 156: uint16(24201), + 157: uint16(24204), + 158: uint16(24205), + 159: uint16(24206), + 160: uint16(24210), + 161: uint16(24216), + 162: uint16(24219), + 163: uint16(24221), + 164: uint16(24225), + 165: uint16(24226), + 166: uint16(24227), + 167: uint16(24228), + 168: uint16(24232), + 169: uint16(24233), + 170: uint16(24234), + 171: uint16(24235), + 172: uint16(24236), + 173: uint16(24238), + 174: uint16(24239), + 175: uint16(24240), + 176: uint16(24241), + 177: uint16(24242), + 178: uint16(24244), + 179: uint16(24250), + 180: uint16(24251), + 181: uint16(24252), + 182: uint16(24253), + 183: uint16(24255), + 184: uint16(24256), + 185: uint16(24257), + 186: uint16(24258), + 187: uint16(24259), + 188: uint16(24260), + 189: uint16(24261), + }, + 14: { + 0: uint16(24262), + 1: uint16(24263), + 2: uint16(24264), + 3: uint16(24267), + 4: uint16(24268), + 5: uint16(24269), + 6: uint16(24270), + 7: uint16(24271), + 8: uint16(24272), + 9: uint16(24276), + 10: uint16(24277), + 11: uint16(24279), + 12: uint16(24280), + 13: uint16(24281), + 14: uint16(24282), + 15: uint16(24284), + 16: uint16(24285), + 17: uint16(24286), + 18: uint16(24287), + 19: uint16(24288), + 20: uint16(24289), + 21: uint16(24290), + 22: uint16(24291), + 23: uint16(24292), + 24: uint16(24293), + 25: uint16(24294), + 26: uint16(24295), + 27: uint16(24297), + 28: uint16(24299), + 29: uint16(24300), + 30: uint16(24301), + 31: uint16(24302), + 32: uint16(24303), + 33: uint16(24304), + 34: uint16(24305), + 35: uint16(24306), + 36: uint16(24307), + 37: uint16(24309), + 38: uint16(24312), + 39: uint16(24313), + 40: uint16(24315), + 41: uint16(24316), + 42: uint16(24317), + 43: uint16(24325), + 44: uint16(24326), + 45: uint16(24327), + 46: uint16(24329), + 47: uint16(24332), + 48: uint16(24333), + 49: uint16(24334), + 50: uint16(24336), + 51: uint16(24338), + 52: uint16(24340), + 53: uint16(24342), + 54: uint16(24345), + 55: uint16(24346), + 56: uint16(24348), + 57: uint16(24349), + 58: uint16(24350), + 59: uint16(24353), + 60: uint16(24354), + 61: uint16(24355), + 62: uint16(24356), + 63: uint16(24360), + 64: uint16(24363), + 65: uint16(24364), + 66: uint16(24366), + 67: uint16(24368), + 68: uint16(24370), + 69: uint16(24371), + 70: uint16(24372), + 71: uint16(24373), + 72: uint16(24374), + 73: uint16(24375), + 74: uint16(24376), + 75: uint16(24379), + 76: uint16(24381), + 77: uint16(24382), + 78: uint16(24383), + 79: uint16(24385), + 80: uint16(24386), + 81: uint16(24387), + 82: uint16(24388), + 83: uint16(24389), + 84: uint16(24390), + 85: uint16(24391), + 86: uint16(24392), + 87: uint16(24393), + 88: uint16(24394), + 89: uint16(24395), + 90: uint16(24396), + 91: uint16(24397), + 92: uint16(24398), + 93: uint16(24399), + 94: uint16(24401), + 95: uint16(24404), + 96: uint16(24409), + 97: uint16(24410), + 98: uint16(24411), + 99: uint16(24412), + 100: uint16(24414), + 101: uint16(24415), + 102: uint16(24416), + 103: uint16(24419), + 104: uint16(24421), + 105: uint16(24423), + 106: uint16(24424), + 107: uint16(24427), + 108: uint16(24430), + 109: uint16(24431), + 110: uint16(24434), + 111: uint16(24436), + 112: uint16(24437), + 113: uint16(24438), + 114: uint16(24440), + 115: uint16(24442), + 116: uint16(24445), + 117: uint16(24446), + 118: uint16(24447), + 119: uint16(24451), + 120: uint16(24454), + 121: uint16(24461), + 122: uint16(24462), + 123: uint16(24463), + 124: uint16(24465), + 125: uint16(24467), + 126: uint16(24468), + 127: uint16(24470), + 128: uint16(24474), + 129: uint16(24475), + 130: uint16(24477), + 131: uint16(24478), + 132: uint16(24479), + 133: uint16(24480), + 134: uint16(24482), + 135: uint16(24483), + 136: uint16(24484), + 137: uint16(24485), + 138: uint16(24486), + 139: uint16(24487), + 140: uint16(24489), + 141: uint16(24491), + 142: uint16(24492), + 143: uint16(24495), + 144: uint16(24496), + 145: uint16(24497), + 146: uint16(24498), + 147: uint16(24499), + 148: uint16(24500), + 149: uint16(24502), + 150: uint16(24504), + 151: uint16(24505), + 152: uint16(24506), + 153: uint16(24507), + 154: uint16(24510), + 155: uint16(24511), + 156: uint16(24512), + 157: uint16(24513), + 158: uint16(24514), + 159: uint16(24519), + 160: uint16(24520), + 161: uint16(24522), + 162: uint16(24523), + 163: uint16(24526), + 164: uint16(24531), + 165: uint16(24532), + 166: uint16(24533), + 167: uint16(24538), + 168: uint16(24539), + 169: uint16(24540), + 170: uint16(24542), + 171: uint16(24543), + 172: uint16(24546), + 173: uint16(24547), + 174: uint16(24549), + 175: uint16(24550), + 176: uint16(24552), + 177: uint16(24553), + 178: uint16(24556), + 179: uint16(24559), + 180: uint16(24560), + 181: uint16(24562), + 182: uint16(24563), + 183: uint16(24564), + 184: uint16(24566), + 185: uint16(24567), + 186: uint16(24569), + 187: uint16(24570), + 188: uint16(24572), + 189: uint16(24583), + }, + 15: { + 0: uint16(24584), + 1: uint16(24585), + 2: uint16(24587), + 3: uint16(24588), + 4: uint16(24592), + 5: uint16(24593), + 6: uint16(24595), + 7: uint16(24599), + 8: uint16(24600), + 9: uint16(24602), + 10: uint16(24606), + 11: uint16(24607), + 12: uint16(24610), + 13: uint16(24611), + 14: uint16(24612), + 15: uint16(24620), + 16: uint16(24621), + 17: uint16(24622), + 18: uint16(24624), + 19: uint16(24625), + 20: uint16(24626), + 21: uint16(24627), + 22: uint16(24628), + 23: uint16(24630), + 24: uint16(24631), + 25: uint16(24632), + 26: uint16(24633), + 27: uint16(24634), + 28: uint16(24637), + 29: uint16(24638), + 30: uint16(24640), + 31: uint16(24644), + 32: uint16(24645), + 33: uint16(24646), + 34: uint16(24647), + 35: uint16(24648), + 36: uint16(24649), + 37: uint16(24650), + 38: uint16(24652), + 39: uint16(24654), + 40: uint16(24655), + 41: uint16(24657), + 42: uint16(24659), + 43: uint16(24660), + 44: uint16(24662), + 45: uint16(24663), + 46: uint16(24664), + 47: uint16(24667), + 48: uint16(24668), + 49: uint16(24670), + 50: uint16(24671), + 51: uint16(24672), + 52: uint16(24673), + 53: uint16(24677), + 54: uint16(24678), + 55: uint16(24686), + 56: uint16(24689), + 57: uint16(24690), + 58: uint16(24692), + 59: uint16(24693), + 60: uint16(24695), + 61: uint16(24702), + 62: uint16(24704), + 63: uint16(24705), + 64: uint16(24706), + 65: uint16(24709), + 66: uint16(24710), + 67: uint16(24711), + 68: uint16(24712), + 69: uint16(24714), + 70: uint16(24715), + 71: uint16(24718), + 72: uint16(24719), + 73: uint16(24720), + 74: uint16(24721), + 75: uint16(24723), + 76: uint16(24725), + 77: uint16(24727), + 78: uint16(24728), + 79: uint16(24729), + 80: uint16(24732), + 81: uint16(24734), + 82: uint16(24737), + 83: uint16(24738), + 84: uint16(24740), + 85: uint16(24741), + 86: uint16(24743), + 87: uint16(24745), + 88: uint16(24746), + 89: uint16(24750), + 90: uint16(24752), + 91: uint16(24755), + 92: uint16(24757), + 93: uint16(24758), + 94: uint16(24759), + 95: uint16(24761), + 96: uint16(24762), + 97: uint16(24765), + 98: uint16(24766), + 99: uint16(24767), + 100: uint16(24768), + 101: uint16(24769), + 102: uint16(24770), + 103: uint16(24771), + 104: uint16(24772), + 105: uint16(24775), + 106: uint16(24776), + 107: uint16(24777), + 108: uint16(24780), + 109: uint16(24781), + 110: uint16(24782), + 111: uint16(24783), + 112: uint16(24784), + 113: uint16(24786), + 114: uint16(24787), + 115: uint16(24788), + 116: uint16(24790), + 117: uint16(24791), + 118: uint16(24793), + 119: uint16(24795), + 120: uint16(24798), + 121: uint16(24801), + 122: uint16(24802), + 123: uint16(24803), + 124: uint16(24804), + 125: uint16(24805), + 126: uint16(24810), + 127: uint16(24817), + 128: uint16(24818), + 129: uint16(24821), + 130: uint16(24823), + 131: uint16(24824), + 132: uint16(24827), + 133: uint16(24828), + 134: uint16(24829), + 135: uint16(24830), + 136: uint16(24831), + 137: uint16(24834), + 138: uint16(24835), + 139: uint16(24836), + 140: uint16(24837), + 141: uint16(24839), + 142: uint16(24842), + 143: uint16(24843), + 144: uint16(24844), + 145: uint16(24848), + 146: uint16(24849), + 147: uint16(24850), + 148: uint16(24851), + 149: uint16(24852), + 150: uint16(24854), + 151: uint16(24855), + 152: uint16(24856), + 153: uint16(24857), + 154: uint16(24859), + 155: uint16(24860), + 156: uint16(24861), + 157: uint16(24862), + 158: uint16(24865), + 159: uint16(24866), + 160: uint16(24869), + 161: uint16(24872), + 162: uint16(24873), + 163: uint16(24874), + 164: uint16(24876), + 165: uint16(24877), + 166: uint16(24878), + 167: uint16(24879), + 168: uint16(24880), + 169: uint16(24881), + 170: uint16(24882), + 171: uint16(24883), + 172: uint16(24884), + 173: uint16(24885), + 174: uint16(24886), + 175: uint16(24887), + 176: uint16(24888), + 177: uint16(24889), + 178: uint16(24890), + 179: uint16(24891), + 180: uint16(24892), + 181: uint16(24893), + 182: uint16(24894), + 183: uint16(24896), + 184: uint16(24897), + 185: uint16(24898), + 186: uint16(24899), + 187: uint16(24900), + 188: uint16(24901), + 189: uint16(24902), + }, + 16: { + 0: uint16(24903), + 1: uint16(24905), + 2: uint16(24907), + 3: uint16(24909), + 4: uint16(24911), + 5: uint16(24912), + 6: uint16(24914), + 7: uint16(24915), + 8: uint16(24916), + 9: uint16(24918), + 10: uint16(24919), + 11: uint16(24920), + 12: uint16(24921), + 13: uint16(24922), + 14: uint16(24923), + 15: uint16(24924), + 16: uint16(24926), + 17: uint16(24927), + 18: uint16(24928), + 19: uint16(24929), + 20: uint16(24931), + 21: uint16(24932), + 22: uint16(24933), + 23: uint16(24934), + 24: uint16(24937), + 25: uint16(24938), + 26: uint16(24939), + 27: uint16(24940), + 28: uint16(24941), + 29: uint16(24942), + 30: uint16(24943), + 31: uint16(24945), + 32: uint16(24946), + 33: uint16(24947), + 34: uint16(24948), + 35: uint16(24950), + 36: uint16(24952), + 37: uint16(24953), + 38: uint16(24954), + 39: uint16(24955), + 40: uint16(24956), + 41: uint16(24957), + 42: uint16(24958), + 43: uint16(24959), + 44: uint16(24960), + 45: uint16(24961), + 46: uint16(24962), + 47: uint16(24963), + 48: uint16(24964), + 49: uint16(24965), + 50: uint16(24966), + 51: uint16(24967), + 52: uint16(24968), + 53: uint16(24969), + 54: uint16(24970), + 55: uint16(24972), + 56: uint16(24973), + 57: uint16(24975), + 58: uint16(24976), + 59: uint16(24977), + 60: uint16(24978), + 61: uint16(24979), + 62: uint16(24981), + 63: uint16(24982), + 64: uint16(24983), + 65: uint16(24984), + 66: uint16(24985), + 67: uint16(24986), + 68: uint16(24987), + 69: uint16(24988), + 70: uint16(24990), + 71: uint16(24991), + 72: uint16(24992), + 73: uint16(24993), + 74: uint16(24994), + 75: uint16(24995), + 76: uint16(24996), + 77: uint16(24997), + 78: uint16(24998), + 79: uint16(25002), + 80: uint16(25003), + 81: uint16(25005), + 82: uint16(25006), + 83: uint16(25007), + 84: uint16(25008), + 85: uint16(25009), + 86: uint16(25010), + 87: uint16(25011), + 88: uint16(25012), + 89: uint16(25013), + 90: uint16(25014), + 91: uint16(25016), + 92: uint16(25017), + 93: uint16(25018), + 94: uint16(25019), + 95: uint16(25020), + 96: uint16(25021), + 97: uint16(25023), + 98: uint16(25024), + 99: uint16(25025), + 100: uint16(25027), + 101: uint16(25028), + 102: uint16(25029), + 103: uint16(25030), + 104: uint16(25031), + 105: uint16(25033), + 106: uint16(25036), + 107: uint16(25037), + 108: uint16(25038), + 109: uint16(25039), + 110: uint16(25040), + 111: uint16(25043), + 112: uint16(25045), + 113: uint16(25046), + 114: uint16(25047), + 115: uint16(25048), + 116: uint16(25049), + 117: uint16(25050), + 118: uint16(25051), + 119: uint16(25052), + 120: uint16(25053), + 121: uint16(25054), + 122: uint16(25055), + 123: uint16(25056), + 124: uint16(25057), + 125: uint16(25058), + 126: uint16(25059), + 127: uint16(25060), + 128: uint16(25061), + 129: uint16(25063), + 130: uint16(25064), + 131: uint16(25065), + 132: uint16(25066), + 133: uint16(25067), + 134: uint16(25068), + 135: uint16(25069), + 136: uint16(25070), + 137: uint16(25071), + 138: uint16(25072), + 139: uint16(25073), + 140: uint16(25074), + 141: uint16(25075), + 142: uint16(25076), + 143: uint16(25078), + 144: uint16(25079), + 145: uint16(25080), + 146: uint16(25081), + 147: uint16(25082), + 148: uint16(25083), + 149: uint16(25084), + 150: uint16(25085), + 151: uint16(25086), + 152: uint16(25088), + 153: uint16(25089), + 154: uint16(25090), + 155: uint16(25091), + 156: uint16(25092), + 157: uint16(25093), + 158: uint16(25095), + 159: uint16(25097), + 160: uint16(25107), + 161: uint16(25108), + 162: uint16(25113), + 163: uint16(25116), + 164: uint16(25117), + 165: uint16(25118), + 166: uint16(25120), + 167: uint16(25123), + 168: uint16(25126), + 169: uint16(25127), + 170: uint16(25128), + 171: uint16(25129), + 172: uint16(25131), + 173: uint16(25133), + 174: uint16(25135), + 175: uint16(25136), + 176: uint16(25137), + 177: uint16(25138), + 178: uint16(25141), + 179: uint16(25142), + 180: uint16(25144), + 181: uint16(25145), + 182: uint16(25146), + 183: uint16(25147), + 184: uint16(25148), + 185: uint16(25154), + 186: uint16(25156), + 187: uint16(25157), + 188: uint16(25158), + 189: uint16(25162), + }, + 17: { + 0: uint16(25167), + 1: uint16(25168), + 2: uint16(25173), + 3: uint16(25174), + 4: uint16(25175), + 5: uint16(25177), + 6: uint16(25178), + 7: uint16(25180), + 8: uint16(25181), + 9: uint16(25182), + 10: uint16(25183), + 11: uint16(25184), + 12: uint16(25185), + 13: uint16(25186), + 14: uint16(25188), + 15: uint16(25189), + 16: uint16(25192), + 17: uint16(25201), + 18: uint16(25202), + 19: uint16(25204), + 20: uint16(25205), + 21: uint16(25207), + 22: uint16(25208), + 23: uint16(25210), + 24: uint16(25211), + 25: uint16(25213), + 26: uint16(25217), + 27: uint16(25218), + 28: uint16(25219), + 29: uint16(25221), + 30: uint16(25222), + 31: uint16(25223), + 32: uint16(25224), + 33: uint16(25227), + 34: uint16(25228), + 35: uint16(25229), + 36: uint16(25230), + 37: uint16(25231), + 38: uint16(25232), + 39: uint16(25236), + 40: uint16(25241), + 41: uint16(25244), + 42: uint16(25245), + 43: uint16(25246), + 44: uint16(25251), + 45: uint16(25254), + 46: uint16(25255), + 47: uint16(25257), + 48: uint16(25258), + 49: uint16(25261), + 50: uint16(25262), + 51: uint16(25263), + 52: uint16(25264), + 53: uint16(25266), + 54: uint16(25267), + 55: uint16(25268), + 56: uint16(25270), + 57: uint16(25271), + 58: uint16(25272), + 59: uint16(25274), + 60: uint16(25278), + 61: uint16(25280), + 62: uint16(25281), + 63: uint16(25283), + 64: uint16(25291), + 65: uint16(25295), + 66: uint16(25297), + 67: uint16(25301), + 68: uint16(25309), + 69: uint16(25310), + 70: uint16(25312), + 71: uint16(25313), + 72: uint16(25316), + 73: uint16(25322), + 74: uint16(25323), + 75: uint16(25328), + 76: uint16(25330), + 77: uint16(25333), + 78: uint16(25336), + 79: uint16(25337), + 80: uint16(25338), + 81: uint16(25339), + 82: uint16(25344), + 83: uint16(25347), + 84: uint16(25348), + 85: uint16(25349), + 86: uint16(25350), + 87: uint16(25354), + 88: uint16(25355), + 89: uint16(25356), + 90: uint16(25357), + 91: uint16(25359), + 92: uint16(25360), + 93: uint16(25362), + 94: uint16(25363), + 95: uint16(25364), + 96: uint16(25365), + 97: uint16(25367), + 98: uint16(25368), + 99: uint16(25369), + 100: uint16(25372), + 101: uint16(25382), + 102: uint16(25383), + 103: uint16(25385), + 104: uint16(25388), + 105: uint16(25389), + 106: uint16(25390), + 107: uint16(25392), + 108: uint16(25393), + 109: uint16(25395), + 110: uint16(25396), + 111: uint16(25397), + 112: uint16(25398), + 113: uint16(25399), + 114: uint16(25400), + 115: uint16(25403), + 116: uint16(25404), + 117: uint16(25406), + 118: uint16(25407), + 119: uint16(25408), + 120: uint16(25409), + 121: uint16(25412), + 122: uint16(25415), + 123: uint16(25416), + 124: uint16(25418), + 125: uint16(25425), + 126: uint16(25426), + 127: uint16(25427), + 128: uint16(25428), + 129: uint16(25430), + 130: uint16(25431), + 131: uint16(25432), + 132: uint16(25433), + 133: uint16(25434), + 134: uint16(25435), + 135: uint16(25436), + 136: uint16(25437), + 137: uint16(25440), + 138: uint16(25444), + 139: uint16(25445), + 140: uint16(25446), + 141: uint16(25448), + 142: uint16(25450), + 143: uint16(25451), + 144: uint16(25452), + 145: uint16(25455), + 146: uint16(25456), + 147: uint16(25458), + 148: uint16(25459), + 149: uint16(25460), + 150: uint16(25461), + 151: uint16(25464), + 152: uint16(25465), + 153: uint16(25468), + 154: uint16(25469), + 155: uint16(25470), + 156: uint16(25471), + 157: uint16(25473), + 158: uint16(25475), + 159: uint16(25476), + 160: uint16(25477), + 161: uint16(25478), + 162: uint16(25483), + 163: uint16(25485), + 164: uint16(25489), + 165: uint16(25491), + 166: uint16(25492), + 167: uint16(25493), + 168: uint16(25495), + 169: uint16(25497), + 170: uint16(25498), + 171: uint16(25499), + 172: uint16(25500), + 173: uint16(25501), + 174: uint16(25502), + 175: uint16(25503), + 176: uint16(25505), + 177: uint16(25508), + 178: uint16(25510), + 179: uint16(25515), + 180: uint16(25519), + 181: uint16(25521), + 182: uint16(25522), + 183: uint16(25525), + 184: uint16(25526), + 185: uint16(25529), + 186: uint16(25531), + 187: uint16(25533), + 188: uint16(25535), + 189: uint16(25536), + }, + 18: { + 0: uint16(25537), + 1: uint16(25538), + 2: uint16(25539), + 3: uint16(25541), + 4: uint16(25543), + 5: uint16(25544), + 6: uint16(25546), + 7: uint16(25547), + 8: uint16(25548), + 9: uint16(25553), + 10: uint16(25555), + 11: uint16(25556), + 12: uint16(25557), + 13: uint16(25559), + 14: uint16(25560), + 15: uint16(25561), + 16: uint16(25562), + 17: uint16(25563), + 18: uint16(25564), + 19: uint16(25565), + 20: uint16(25567), + 21: uint16(25570), + 22: uint16(25572), + 23: uint16(25573), + 24: uint16(25574), + 25: uint16(25575), + 26: uint16(25576), + 27: uint16(25579), + 28: uint16(25580), + 29: uint16(25582), + 30: uint16(25583), + 31: uint16(25584), + 32: uint16(25585), + 33: uint16(25587), + 34: uint16(25589), + 35: uint16(25591), + 36: uint16(25593), + 37: uint16(25594), + 38: uint16(25595), + 39: uint16(25596), + 40: uint16(25598), + 41: uint16(25603), + 42: uint16(25604), + 43: uint16(25606), + 44: uint16(25607), + 45: uint16(25608), + 46: uint16(25609), + 47: uint16(25610), + 48: uint16(25613), + 49: uint16(25614), + 50: uint16(25617), + 51: uint16(25618), + 52: uint16(25621), + 53: uint16(25622), + 54: uint16(25623), + 55: uint16(25624), + 56: uint16(25625), + 57: uint16(25626), + 58: uint16(25629), + 59: uint16(25631), + 60: uint16(25634), + 61: uint16(25635), + 62: uint16(25636), + 63: uint16(25637), + 64: uint16(25639), + 65: uint16(25640), + 66: uint16(25641), + 67: uint16(25643), + 68: uint16(25646), + 69: uint16(25647), + 70: uint16(25648), + 71: uint16(25649), + 72: uint16(25650), + 73: uint16(25651), + 74: uint16(25653), + 75: uint16(25654), + 76: uint16(25655), + 77: uint16(25656), + 78: uint16(25657), + 79: uint16(25659), + 80: uint16(25660), + 81: uint16(25662), + 82: uint16(25664), + 83: uint16(25666), + 84: uint16(25667), + 85: uint16(25673), + 86: uint16(25675), + 87: uint16(25676), + 88: uint16(25677), + 89: uint16(25678), + 90: uint16(25679), + 91: uint16(25680), + 92: uint16(25681), + 93: uint16(25683), + 94: uint16(25685), + 95: uint16(25686), + 96: uint16(25687), + 97: uint16(25689), + 98: uint16(25690), + 99: uint16(25691), + 100: uint16(25692), + 101: uint16(25693), + 102: uint16(25695), + 103: uint16(25696), + 104: uint16(25697), + 105: uint16(25698), + 106: uint16(25699), + 107: uint16(25700), + 108: uint16(25701), + 109: uint16(25702), + 110: uint16(25704), + 111: uint16(25706), + 112: uint16(25707), + 113: uint16(25708), + 114: uint16(25710), + 115: uint16(25711), + 116: uint16(25712), + 117: uint16(25713), + 118: uint16(25714), + 119: uint16(25715), + 120: uint16(25716), + 121: uint16(25717), + 122: uint16(25718), + 123: uint16(25719), + 124: uint16(25723), + 125: uint16(25724), + 126: uint16(25725), + 127: uint16(25726), + 128: uint16(25727), + 129: uint16(25728), + 130: uint16(25729), + 131: uint16(25731), + 132: uint16(25734), + 133: uint16(25736), + 134: uint16(25737), + 135: uint16(25738), + 136: uint16(25739), + 137: uint16(25740), + 138: uint16(25741), + 139: uint16(25742), + 140: uint16(25743), + 141: uint16(25744), + 142: uint16(25747), + 143: uint16(25748), + 144: uint16(25751), + 145: uint16(25752), + 146: uint16(25754), + 147: uint16(25755), + 148: uint16(25756), + 149: uint16(25757), + 150: uint16(25759), + 151: uint16(25760), + 152: uint16(25761), + 153: uint16(25762), + 154: uint16(25763), + 155: uint16(25765), + 156: uint16(25766), + 157: uint16(25767), + 158: uint16(25768), + 159: uint16(25770), + 160: uint16(25771), + 161: uint16(25775), + 162: uint16(25777), + 163: uint16(25778), + 164: uint16(25779), + 165: uint16(25780), + 166: uint16(25782), + 167: uint16(25785), + 168: uint16(25787), + 169: uint16(25789), + 170: uint16(25790), + 171: uint16(25791), + 172: uint16(25793), + 173: uint16(25795), + 174: uint16(25796), + 175: uint16(25798), + 176: uint16(25799), + 177: uint16(25800), + 178: uint16(25801), + 179: uint16(25802), + 180: uint16(25803), + 181: uint16(25804), + 182: uint16(25807), + 183: uint16(25809), + 184: uint16(25811), + 185: uint16(25812), + 186: uint16(25813), + 187: uint16(25814), + 188: uint16(25817), + 189: uint16(25818), + }, + 19: { + 0: uint16(25819), + 1: uint16(25820), + 2: uint16(25821), + 3: uint16(25823), + 4: uint16(25824), + 5: uint16(25825), + 6: uint16(25827), + 7: uint16(25829), + 8: uint16(25831), + 9: uint16(25832), + 10: uint16(25833), + 11: uint16(25834), + 12: uint16(25835), + 13: uint16(25836), + 14: uint16(25837), + 15: uint16(25838), + 16: uint16(25839), + 17: uint16(25840), + 18: uint16(25841), + 19: uint16(25842), + 20: uint16(25843), + 21: uint16(25844), + 22: uint16(25845), + 23: uint16(25846), + 24: uint16(25847), + 25: uint16(25848), + 26: uint16(25849), + 27: uint16(25850), + 28: uint16(25851), + 29: uint16(25852), + 30: uint16(25853), + 31: uint16(25854), + 32: uint16(25855), + 33: uint16(25857), + 34: uint16(25858), + 35: uint16(25859), + 36: uint16(25860), + 37: uint16(25861), + 38: uint16(25862), + 39: uint16(25863), + 40: uint16(25864), + 41: uint16(25866), + 42: uint16(25867), + 43: uint16(25868), + 44: uint16(25869), + 45: uint16(25870), + 46: uint16(25871), + 47: uint16(25872), + 48: uint16(25873), + 49: uint16(25875), + 50: uint16(25876), + 51: uint16(25877), + 52: uint16(25878), + 53: uint16(25879), + 54: uint16(25881), + 55: uint16(25882), + 56: uint16(25883), + 57: uint16(25884), + 58: uint16(25885), + 59: uint16(25886), + 60: uint16(25887), + 61: uint16(25888), + 62: uint16(25889), + 63: uint16(25890), + 64: uint16(25891), + 65: uint16(25892), + 66: uint16(25894), + 67: uint16(25895), + 68: uint16(25896), + 69: uint16(25897), + 70: uint16(25898), + 71: uint16(25900), + 72: uint16(25901), + 73: uint16(25904), + 74: uint16(25905), + 75: uint16(25906), + 76: uint16(25907), + 77: uint16(25911), + 78: uint16(25914), + 79: uint16(25916), + 80: uint16(25917), + 81: uint16(25920), + 82: uint16(25921), + 83: uint16(25922), + 84: uint16(25923), + 85: uint16(25924), + 86: uint16(25926), + 87: uint16(25927), + 88: uint16(25930), + 89: uint16(25931), + 90: uint16(25933), + 91: uint16(25934), + 92: uint16(25936), + 93: uint16(25938), + 94: uint16(25939), + 95: uint16(25940), + 96: uint16(25943), + 97: uint16(25944), + 98: uint16(25946), + 99: uint16(25948), + 100: uint16(25951), + 101: uint16(25952), + 102: uint16(25953), + 103: uint16(25956), + 104: uint16(25957), + 105: uint16(25959), + 106: uint16(25960), + 107: uint16(25961), + 108: uint16(25962), + 109: uint16(25965), + 110: uint16(25966), + 111: uint16(25967), + 112: uint16(25969), + 113: uint16(25971), + 114: uint16(25973), + 115: uint16(25974), + 116: uint16(25976), + 117: uint16(25977), + 118: uint16(25978), + 119: uint16(25979), + 120: uint16(25980), + 121: uint16(25981), + 122: uint16(25982), + 123: uint16(25983), + 124: uint16(25984), + 125: uint16(25985), + 126: uint16(25986), + 127: uint16(25987), + 128: uint16(25988), + 129: uint16(25989), + 130: uint16(25990), + 131: uint16(25992), + 132: uint16(25993), + 133: uint16(25994), + 134: uint16(25997), + 135: uint16(25998), + 136: uint16(25999), + 137: uint16(26002), + 138: uint16(26004), + 139: uint16(26005), + 140: uint16(26006), + 141: uint16(26008), + 142: uint16(26010), + 143: uint16(26013), + 144: uint16(26014), + 145: uint16(26016), + 146: uint16(26018), + 147: uint16(26019), + 148: uint16(26022), + 149: uint16(26024), + 150: uint16(26026), + 151: uint16(26028), + 152: uint16(26030), + 153: uint16(26033), + 154: uint16(26034), + 155: uint16(26035), + 156: uint16(26036), + 157: uint16(26037), + 158: uint16(26038), + 159: uint16(26039), + 160: uint16(26040), + 161: uint16(26042), + 162: uint16(26043), + 163: uint16(26046), + 164: uint16(26047), + 165: uint16(26048), + 166: uint16(26050), + 167: uint16(26055), + 168: uint16(26056), + 169: uint16(26057), + 170: uint16(26058), + 171: uint16(26061), + 172: uint16(26064), + 173: uint16(26065), + 174: uint16(26067), + 175: uint16(26068), + 176: uint16(26069), + 177: uint16(26072), + 178: uint16(26073), + 179: uint16(26074), + 180: uint16(26075), + 181: uint16(26076), + 182: uint16(26077), + 183: uint16(26078), + 184: uint16(26079), + 185: uint16(26081), + 186: uint16(26083), + 187: uint16(26084), + 188: uint16(26090), + 189: uint16(26091), + }, + 20: { + 0: uint16(26098), + 1: uint16(26099), + 2: uint16(26100), + 3: uint16(26101), + 4: uint16(26104), + 5: uint16(26105), + 6: uint16(26107), + 7: uint16(26108), + 8: uint16(26109), + 9: uint16(26110), + 10: uint16(26111), + 11: uint16(26113), + 12: uint16(26116), + 13: uint16(26117), + 14: uint16(26119), + 15: uint16(26120), + 16: uint16(26121), + 17: uint16(26123), + 18: uint16(26125), + 19: uint16(26128), + 20: uint16(26129), + 21: uint16(26130), + 22: uint16(26134), + 23: uint16(26135), + 24: uint16(26136), + 25: uint16(26138), + 26: uint16(26139), + 27: uint16(26140), + 28: uint16(26142), + 29: uint16(26145), + 30: uint16(26146), + 31: uint16(26147), + 32: uint16(26148), + 33: uint16(26150), + 34: uint16(26153), + 35: uint16(26154), + 36: uint16(26155), + 37: uint16(26156), + 38: uint16(26158), + 39: uint16(26160), + 40: uint16(26162), + 41: uint16(26163), + 42: uint16(26167), + 43: uint16(26168), + 44: uint16(26169), + 45: uint16(26170), + 46: uint16(26171), + 47: uint16(26173), + 48: uint16(26175), + 49: uint16(26176), + 50: uint16(26178), + 51: uint16(26180), + 52: uint16(26181), + 53: uint16(26182), + 54: uint16(26183), + 55: uint16(26184), + 56: uint16(26185), + 57: uint16(26186), + 58: uint16(26189), + 59: uint16(26190), + 60: uint16(26192), + 61: uint16(26193), + 62: uint16(26200), + 63: uint16(26201), + 64: uint16(26203), + 65: uint16(26204), + 66: uint16(26205), + 67: uint16(26206), + 68: uint16(26208), + 69: uint16(26210), + 70: uint16(26211), + 71: uint16(26213), + 72: uint16(26215), + 73: uint16(26217), + 74: uint16(26218), + 75: uint16(26219), + 76: uint16(26220), + 77: uint16(26221), + 78: uint16(26225), + 79: uint16(26226), + 80: uint16(26227), + 81: uint16(26229), + 82: uint16(26232), + 83: uint16(26233), + 84: uint16(26235), + 85: uint16(26236), + 86: uint16(26237), + 87: uint16(26239), + 88: uint16(26240), + 89: uint16(26241), + 90: uint16(26243), + 91: uint16(26245), + 92: uint16(26246), + 93: uint16(26248), + 94: uint16(26249), + 95: uint16(26250), + 96: uint16(26251), + 97: uint16(26253), + 98: uint16(26254), + 99: uint16(26255), + 100: uint16(26256), + 101: uint16(26258), + 102: uint16(26259), + 103: uint16(26260), + 104: uint16(26261), + 105: uint16(26264), + 106: uint16(26265), + 107: uint16(26266), + 108: uint16(26267), + 109: uint16(26268), + 110: uint16(26270), + 111: uint16(26271), + 112: uint16(26272), + 113: uint16(26273), + 114: uint16(26274), + 115: uint16(26275), + 116: uint16(26276), + 117: uint16(26277), + 118: uint16(26278), + 119: uint16(26281), + 120: uint16(26282), + 121: uint16(26283), + 122: uint16(26284), + 123: uint16(26285), + 124: uint16(26287), + 125: uint16(26288), + 126: uint16(26289), + 127: uint16(26290), + 128: uint16(26291), + 129: uint16(26293), + 130: uint16(26294), + 131: uint16(26295), + 132: uint16(26296), + 133: uint16(26298), + 134: uint16(26299), + 135: uint16(26300), + 136: uint16(26301), + 137: uint16(26303), + 138: uint16(26304), + 139: uint16(26305), + 140: uint16(26306), + 141: uint16(26307), + 142: uint16(26308), + 143: uint16(26309), + 144: uint16(26310), + 145: uint16(26311), + 146: uint16(26312), + 147: uint16(26313), + 148: uint16(26314), + 149: uint16(26315), + 150: uint16(26316), + 151: uint16(26317), + 152: uint16(26318), + 153: uint16(26319), + 154: uint16(26320), + 155: uint16(26321), + 156: uint16(26322), + 157: uint16(26323), + 158: uint16(26324), + 159: uint16(26325), + 160: uint16(26326), + 161: uint16(26327), + 162: uint16(26328), + 163: uint16(26330), + 164: uint16(26334), + 165: uint16(26335), + 166: uint16(26336), + 167: uint16(26337), + 168: uint16(26338), + 169: uint16(26339), + 170: uint16(26340), + 171: uint16(26341), + 172: uint16(26343), + 173: uint16(26344), + 174: uint16(26346), + 175: uint16(26347), + 176: uint16(26348), + 177: uint16(26349), + 178: uint16(26350), + 179: uint16(26351), + 180: uint16(26353), + 181: uint16(26357), + 182: uint16(26358), + 183: uint16(26360), + 184: uint16(26362), + 185: uint16(26363), + 186: uint16(26365), + 187: uint16(26369), + 188: uint16(26370), + 189: uint16(26371), + }, + 21: { + 0: uint16(26372), + 1: uint16(26373), + 2: uint16(26374), + 3: uint16(26375), + 4: uint16(26380), + 5: uint16(26382), + 6: uint16(26383), + 7: uint16(26385), + 8: uint16(26386), + 9: uint16(26387), + 10: uint16(26390), + 11: uint16(26392), + 12: uint16(26393), + 13: uint16(26394), + 14: uint16(26396), + 15: uint16(26398), + 16: uint16(26400), + 17: uint16(26401), + 18: uint16(26402), + 19: uint16(26403), + 20: uint16(26404), + 21: uint16(26405), + 22: uint16(26407), + 23: uint16(26409), + 24: uint16(26414), + 25: uint16(26416), + 26: uint16(26418), + 27: uint16(26419), + 28: uint16(26422), + 29: uint16(26423), + 30: uint16(26424), + 31: uint16(26425), + 32: uint16(26427), + 33: uint16(26428), + 34: uint16(26430), + 35: uint16(26431), + 36: uint16(26433), + 37: uint16(26436), + 38: uint16(26437), + 39: uint16(26439), + 40: uint16(26442), + 41: uint16(26443), + 42: uint16(26445), + 43: uint16(26450), + 44: uint16(26452), + 45: uint16(26453), + 46: uint16(26455), + 47: uint16(26456), + 48: uint16(26457), + 49: uint16(26458), + 50: uint16(26459), + 51: uint16(26461), + 52: uint16(26466), + 53: uint16(26467), + 54: uint16(26468), + 55: uint16(26470), + 56: uint16(26471), + 57: uint16(26475), + 58: uint16(26476), + 59: uint16(26478), + 60: uint16(26481), + 61: uint16(26484), + 62: uint16(26486), + 63: uint16(26488), + 64: uint16(26489), + 65: uint16(26490), + 66: uint16(26491), + 67: uint16(26493), + 68: uint16(26496), + 69: uint16(26498), + 70: uint16(26499), + 71: uint16(26501), + 72: uint16(26502), + 73: uint16(26504), + 74: uint16(26506), + 75: uint16(26508), + 76: uint16(26509), + 77: uint16(26510), + 78: uint16(26511), + 79: uint16(26513), + 80: uint16(26514), + 81: uint16(26515), + 82: uint16(26516), + 83: uint16(26518), + 84: uint16(26521), + 85: uint16(26523), + 86: uint16(26527), + 87: uint16(26528), + 88: uint16(26529), + 89: uint16(26532), + 90: uint16(26534), + 91: uint16(26537), + 92: uint16(26540), + 93: uint16(26542), + 94: uint16(26545), + 95: uint16(26546), + 96: uint16(26548), + 97: uint16(26553), + 98: uint16(26554), + 99: uint16(26555), + 100: uint16(26556), + 101: uint16(26557), + 102: uint16(26558), + 103: uint16(26559), + 104: uint16(26560), + 105: uint16(26562), + 106: uint16(26565), + 107: uint16(26566), + 108: uint16(26567), + 109: uint16(26568), + 110: uint16(26569), + 111: uint16(26570), + 112: uint16(26571), + 113: uint16(26572), + 114: uint16(26573), + 115: uint16(26574), + 116: uint16(26581), + 117: uint16(26582), + 118: uint16(26583), + 119: uint16(26587), + 120: uint16(26591), + 121: uint16(26593), + 122: uint16(26595), + 123: uint16(26596), + 124: uint16(26598), + 125: uint16(26599), + 126: uint16(26600), + 127: uint16(26602), + 128: uint16(26603), + 129: uint16(26605), + 130: uint16(26606), + 131: uint16(26610), + 132: uint16(26613), + 133: uint16(26614), + 134: uint16(26615), + 135: uint16(26616), + 136: uint16(26617), + 137: uint16(26618), + 138: uint16(26619), + 139: uint16(26620), + 140: uint16(26622), + 141: uint16(26625), + 142: uint16(26626), + 143: uint16(26627), + 144: uint16(26628), + 145: uint16(26630), + 146: uint16(26637), + 147: uint16(26640), + 148: uint16(26642), + 149: uint16(26644), + 150: uint16(26645), + 151: uint16(26648), + 152: uint16(26649), + 153: uint16(26650), + 154: uint16(26651), + 155: uint16(26652), + 156: uint16(26654), + 157: uint16(26655), + 158: uint16(26656), + 159: uint16(26658), + 160: uint16(26659), + 161: uint16(26660), + 162: uint16(26661), + 163: uint16(26662), + 164: uint16(26663), + 165: uint16(26664), + 166: uint16(26667), + 167: uint16(26668), + 168: uint16(26669), + 169: uint16(26670), + 170: uint16(26671), + 171: uint16(26672), + 172: uint16(26673), + 173: uint16(26676), + 174: uint16(26677), + 175: uint16(26678), + 176: uint16(26682), + 177: uint16(26683), + 178: uint16(26687), + 179: uint16(26695), + 180: uint16(26699), + 181: uint16(26701), + 182: uint16(26703), + 183: uint16(26706), + 184: uint16(26710), + 185: uint16(26711), + 186: uint16(26712), + 187: uint16(26713), + 188: uint16(26714), + 189: uint16(26715), + }, + 22: { + 0: uint16(26716), + 1: uint16(26717), + 2: uint16(26718), + 3: uint16(26719), + 4: uint16(26730), + 5: uint16(26732), + 6: uint16(26733), + 7: uint16(26734), + 8: uint16(26735), + 9: uint16(26736), + 10: uint16(26737), + 11: uint16(26738), + 12: uint16(26739), + 13: uint16(26741), + 14: uint16(26744), + 15: uint16(26745), + 16: uint16(26746), + 17: uint16(26747), + 18: uint16(26748), + 19: uint16(26749), + 20: uint16(26750), + 21: uint16(26751), + 22: uint16(26752), + 23: uint16(26754), + 24: uint16(26756), + 25: uint16(26759), + 26: uint16(26760), + 27: uint16(26761), + 28: uint16(26762), + 29: uint16(26763), + 30: uint16(26764), + 31: uint16(26765), + 32: uint16(26766), + 33: uint16(26768), + 34: uint16(26769), + 35: uint16(26770), + 36: uint16(26772), + 37: uint16(26773), + 38: uint16(26774), + 39: uint16(26776), + 40: uint16(26777), + 41: uint16(26778), + 42: uint16(26779), + 43: uint16(26780), + 44: uint16(26781), + 45: uint16(26782), + 46: uint16(26783), + 47: uint16(26784), + 48: uint16(26785), + 49: uint16(26787), + 50: uint16(26788), + 51: uint16(26789), + 52: uint16(26793), + 53: uint16(26794), + 54: uint16(26795), + 55: uint16(26796), + 56: uint16(26798), + 57: uint16(26801), + 58: uint16(26802), + 59: uint16(26804), + 60: uint16(26806), + 61: uint16(26807), + 62: uint16(26808), + 63: uint16(26809), + 64: uint16(26810), + 65: uint16(26811), + 66: uint16(26812), + 67: uint16(26813), + 68: uint16(26814), + 69: uint16(26815), + 70: uint16(26817), + 71: uint16(26819), + 72: uint16(26820), + 73: uint16(26821), + 74: uint16(26822), + 75: uint16(26823), + 76: uint16(26824), + 77: uint16(26826), + 78: uint16(26828), + 79: uint16(26830), + 80: uint16(26831), + 81: uint16(26832), + 82: uint16(26833), + 83: uint16(26835), + 84: uint16(26836), + 85: uint16(26838), + 86: uint16(26839), + 87: uint16(26841), + 88: uint16(26843), + 89: uint16(26844), + 90: uint16(26845), + 91: uint16(26846), + 92: uint16(26847), + 93: uint16(26849), + 94: uint16(26850), + 95: uint16(26852), + 96: uint16(26853), + 97: uint16(26854), + 98: uint16(26855), + 99: uint16(26856), + 100: uint16(26857), + 101: uint16(26858), + 102: uint16(26859), + 103: uint16(26860), + 104: uint16(26861), + 105: uint16(26863), + 106: uint16(26866), + 107: uint16(26867), + 108: uint16(26868), + 109: uint16(26870), + 110: uint16(26871), + 111: uint16(26872), + 112: uint16(26875), + 113: uint16(26877), + 114: uint16(26878), + 115: uint16(26879), + 116: uint16(26880), + 117: uint16(26882), + 118: uint16(26883), + 119: uint16(26884), + 120: uint16(26886), + 121: uint16(26887), + 122: uint16(26888), + 123: uint16(26889), + 124: uint16(26890), + 125: uint16(26892), + 126: uint16(26895), + 127: uint16(26897), + 128: uint16(26899), + 129: uint16(26900), + 130: uint16(26901), + 131: uint16(26902), + 132: uint16(26903), + 133: uint16(26904), + 134: uint16(26905), + 135: uint16(26906), + 136: uint16(26907), + 137: uint16(26908), + 138: uint16(26909), + 139: uint16(26910), + 140: uint16(26913), + 141: uint16(26914), + 142: uint16(26915), + 143: uint16(26917), + 144: uint16(26918), + 145: uint16(26919), + 146: uint16(26920), + 147: uint16(26921), + 148: uint16(26922), + 149: uint16(26923), + 150: uint16(26924), + 151: uint16(26926), + 152: uint16(26927), + 153: uint16(26929), + 154: uint16(26930), + 155: uint16(26931), + 156: uint16(26933), + 157: uint16(26934), + 158: uint16(26935), + 159: uint16(26936), + 160: uint16(26938), + 161: uint16(26939), + 162: uint16(26940), + 163: uint16(26942), + 164: uint16(26944), + 165: uint16(26945), + 166: uint16(26947), + 167: uint16(26948), + 168: uint16(26949), + 169: uint16(26950), + 170: uint16(26951), + 171: uint16(26952), + 172: uint16(26953), + 173: uint16(26954), + 174: uint16(26955), + 175: uint16(26956), + 176: uint16(26957), + 177: uint16(26958), + 178: uint16(26959), + 179: uint16(26960), + 180: uint16(26961), + 181: uint16(26962), + 182: uint16(26963), + 183: uint16(26965), + 184: uint16(26966), + 185: uint16(26968), + 186: uint16(26969), + 187: uint16(26971), + 188: uint16(26972), + 189: uint16(26975), + }, + 23: { + 0: uint16(26977), + 1: uint16(26978), + 2: uint16(26980), + 3: uint16(26981), + 4: uint16(26983), + 5: uint16(26984), + 6: uint16(26985), + 7: uint16(26986), + 8: uint16(26988), + 9: uint16(26989), + 10: uint16(26991), + 11: uint16(26992), + 12: uint16(26994), + 13: uint16(26995), + 14: uint16(26996), + 15: uint16(26997), + 16: uint16(26998), + 17: uint16(27002), + 18: uint16(27003), + 19: uint16(27005), + 20: uint16(27006), + 21: uint16(27007), + 22: uint16(27009), + 23: uint16(27011), + 24: uint16(27013), + 25: uint16(27018), + 26: uint16(27019), + 27: uint16(27020), + 28: uint16(27022), + 29: uint16(27023), + 30: uint16(27024), + 31: uint16(27025), + 32: uint16(27026), + 33: uint16(27027), + 34: uint16(27030), + 35: uint16(27031), + 36: uint16(27033), + 37: uint16(27034), + 38: uint16(27037), + 39: uint16(27038), + 40: uint16(27039), + 41: uint16(27040), + 42: uint16(27041), + 43: uint16(27042), + 44: uint16(27043), + 45: uint16(27044), + 46: uint16(27045), + 47: uint16(27046), + 48: uint16(27049), + 49: uint16(27050), + 50: uint16(27052), + 51: uint16(27054), + 52: uint16(27055), + 53: uint16(27056), + 54: uint16(27058), + 55: uint16(27059), + 56: uint16(27061), + 57: uint16(27062), + 58: uint16(27064), + 59: uint16(27065), + 60: uint16(27066), + 61: uint16(27068), + 62: uint16(27069), + 63: uint16(27070), + 64: uint16(27071), + 65: uint16(27072), + 66: uint16(27074), + 67: uint16(27075), + 68: uint16(27076), + 69: uint16(27077), + 70: uint16(27078), + 71: uint16(27079), + 72: uint16(27080), + 73: uint16(27081), + 74: uint16(27083), + 75: uint16(27085), + 76: uint16(27087), + 77: uint16(27089), + 78: uint16(27090), + 79: uint16(27091), + 80: uint16(27093), + 81: uint16(27094), + 82: uint16(27095), + 83: uint16(27096), + 84: uint16(27097), + 85: uint16(27098), + 86: uint16(27100), + 87: uint16(27101), + 88: uint16(27102), + 89: uint16(27105), + 90: uint16(27106), + 91: uint16(27107), + 92: uint16(27108), + 93: uint16(27109), + 94: uint16(27110), + 95: uint16(27111), + 96: uint16(27112), + 97: uint16(27113), + 98: uint16(27114), + 99: uint16(27115), + 100: uint16(27116), + 101: uint16(27118), + 102: uint16(27119), + 103: uint16(27120), + 104: uint16(27121), + 105: uint16(27123), + 106: uint16(27124), + 107: uint16(27125), + 108: uint16(27126), + 109: uint16(27127), + 110: uint16(27128), + 111: uint16(27129), + 112: uint16(27130), + 113: uint16(27131), + 114: uint16(27132), + 115: uint16(27134), + 116: uint16(27136), + 117: uint16(27137), + 118: uint16(27138), + 119: uint16(27139), + 120: uint16(27140), + 121: uint16(27141), + 122: uint16(27142), + 123: uint16(27143), + 124: uint16(27144), + 125: uint16(27145), + 126: uint16(27147), + 127: uint16(27148), + 128: uint16(27149), + 129: uint16(27150), + 130: uint16(27151), + 131: uint16(27152), + 132: uint16(27153), + 133: uint16(27154), + 134: uint16(27155), + 135: uint16(27156), + 136: uint16(27157), + 137: uint16(27158), + 138: uint16(27161), + 139: uint16(27162), + 140: uint16(27163), + 141: uint16(27164), + 142: uint16(27165), + 143: uint16(27166), + 144: uint16(27168), + 145: uint16(27170), + 146: uint16(27171), + 147: uint16(27172), + 148: uint16(27173), + 149: uint16(27174), + 150: uint16(27175), + 151: uint16(27177), + 152: uint16(27179), + 153: uint16(27180), + 154: uint16(27181), + 155: uint16(27182), + 156: uint16(27184), + 157: uint16(27186), + 158: uint16(27187), + 159: uint16(27188), + 160: uint16(27190), + 161: uint16(27191), + 162: uint16(27192), + 163: uint16(27193), + 164: uint16(27194), + 165: uint16(27195), + 166: uint16(27196), + 167: uint16(27199), + 168: uint16(27200), + 169: uint16(27201), + 170: uint16(27202), + 171: uint16(27203), + 172: uint16(27205), + 173: uint16(27206), + 174: uint16(27208), + 175: uint16(27209), + 176: uint16(27210), + 177: uint16(27211), + 178: uint16(27212), + 179: uint16(27213), + 180: uint16(27214), + 181: uint16(27215), + 182: uint16(27217), + 183: uint16(27218), + 184: uint16(27219), + 185: uint16(27220), + 186: uint16(27221), + 187: uint16(27222), + 188: uint16(27223), + 189: uint16(27226), + }, + 24: { + 0: uint16(27228), + 1: uint16(27229), + 2: uint16(27230), + 3: uint16(27231), + 4: uint16(27232), + 5: uint16(27234), + 6: uint16(27235), + 7: uint16(27236), + 8: uint16(27238), + 9: uint16(27239), + 10: uint16(27240), + 11: uint16(27241), + 12: uint16(27242), + 13: uint16(27243), + 14: uint16(27244), + 15: uint16(27245), + 16: uint16(27246), + 17: uint16(27247), + 18: uint16(27248), + 19: uint16(27250), + 20: uint16(27251), + 21: uint16(27252), + 22: uint16(27253), + 23: uint16(27254), + 24: uint16(27255), + 25: uint16(27256), + 26: uint16(27258), + 27: uint16(27259), + 28: uint16(27261), + 29: uint16(27262), + 30: uint16(27263), + 31: uint16(27265), + 32: uint16(27266), + 33: uint16(27267), + 34: uint16(27269), + 35: uint16(27270), + 36: uint16(27271), + 37: uint16(27272), + 38: uint16(27273), + 39: uint16(27274), + 40: uint16(27275), + 41: uint16(27276), + 42: uint16(27277), + 43: uint16(27279), + 44: uint16(27282), + 45: uint16(27283), + 46: uint16(27284), + 47: uint16(27285), + 48: uint16(27286), + 49: uint16(27288), + 50: uint16(27289), + 51: uint16(27290), + 52: uint16(27291), + 53: uint16(27292), + 54: uint16(27293), + 55: uint16(27294), + 56: uint16(27295), + 57: uint16(27297), + 58: uint16(27298), + 59: uint16(27299), + 60: uint16(27300), + 61: uint16(27301), + 62: uint16(27302), + 63: uint16(27303), + 64: uint16(27304), + 65: uint16(27306), + 66: uint16(27309), + 67: uint16(27310), + 68: uint16(27311), + 69: uint16(27312), + 70: uint16(27313), + 71: uint16(27314), + 72: uint16(27315), + 73: uint16(27316), + 74: uint16(27317), + 75: uint16(27318), + 76: uint16(27319), + 77: uint16(27320), + 78: uint16(27321), + 79: uint16(27322), + 80: uint16(27323), + 81: uint16(27324), + 82: uint16(27325), + 83: uint16(27326), + 84: uint16(27327), + 85: uint16(27328), + 86: uint16(27329), + 87: uint16(27330), + 88: uint16(27331), + 89: uint16(27332), + 90: uint16(27333), + 91: uint16(27334), + 92: uint16(27335), + 93: uint16(27336), + 94: uint16(27337), + 95: uint16(27338), + 96: uint16(27339), + 97: uint16(27340), + 98: uint16(27341), + 99: uint16(27342), + 100: uint16(27343), + 101: uint16(27344), + 102: uint16(27345), + 103: uint16(27346), + 104: uint16(27347), + 105: uint16(27348), + 106: uint16(27349), + 107: uint16(27350), + 108: uint16(27351), + 109: uint16(27352), + 110: uint16(27353), + 111: uint16(27354), + 112: uint16(27355), + 113: uint16(27356), + 114: uint16(27357), + 115: uint16(27358), + 116: uint16(27359), + 117: uint16(27360), + 118: uint16(27361), + 119: uint16(27362), + 120: uint16(27363), + 121: uint16(27364), + 122: uint16(27365), + 123: uint16(27366), + 124: uint16(27367), + 125: uint16(27368), + 126: uint16(27369), + 127: uint16(27370), + 128: uint16(27371), + 129: uint16(27372), + 130: uint16(27373), + 131: uint16(27374), + 132: uint16(27375), + 133: uint16(27376), + 134: uint16(27377), + 135: uint16(27378), + 136: uint16(27379), + 137: uint16(27380), + 138: uint16(27381), + 139: uint16(27382), + 140: uint16(27383), + 141: uint16(27384), + 142: uint16(27385), + 143: uint16(27386), + 144: uint16(27387), + 145: uint16(27388), + 146: uint16(27389), + 147: uint16(27390), + 148: uint16(27391), + 149: uint16(27392), + 150: uint16(27393), + 151: uint16(27394), + 152: uint16(27395), + 153: uint16(27396), + 154: uint16(27397), + 155: uint16(27398), + 156: uint16(27399), + 157: uint16(27400), + 158: uint16(27401), + 159: uint16(27402), + 160: uint16(27403), + 161: uint16(27404), + 162: uint16(27405), + 163: uint16(27406), + 164: uint16(27407), + 165: uint16(27408), + 166: uint16(27409), + 167: uint16(27410), + 168: uint16(27411), + 169: uint16(27412), + 170: uint16(27413), + 171: uint16(27414), + 172: uint16(27415), + 173: uint16(27416), + 174: uint16(27417), + 175: uint16(27418), + 176: uint16(27419), + 177: uint16(27420), + 178: uint16(27421), + 179: uint16(27422), + 180: uint16(27423), + 181: uint16(27429), + 182: uint16(27430), + 183: uint16(27432), + 184: uint16(27433), + 185: uint16(27434), + 186: uint16(27435), + 187: uint16(27436), + 188: uint16(27437), + 189: uint16(27438), + }, + 25: { + 0: uint16(27439), + 1: uint16(27440), + 2: uint16(27441), + 3: uint16(27443), + 4: uint16(27444), + 5: uint16(27445), + 6: uint16(27446), + 7: uint16(27448), + 8: uint16(27451), + 9: uint16(27452), + 10: uint16(27453), + 11: uint16(27455), + 12: uint16(27456), + 13: uint16(27457), + 14: uint16(27458), + 15: uint16(27460), + 16: uint16(27461), + 17: uint16(27464), + 18: uint16(27466), + 19: uint16(27467), + 20: uint16(27469), + 21: uint16(27470), + 22: uint16(27471), + 23: uint16(27472), + 24: uint16(27473), + 25: uint16(27474), + 26: uint16(27475), + 27: uint16(27476), + 28: uint16(27477), + 29: uint16(27478), + 30: uint16(27479), + 31: uint16(27480), + 32: uint16(27482), + 33: uint16(27483), + 34: uint16(27484), + 35: uint16(27485), + 36: uint16(27486), + 37: uint16(27487), + 38: uint16(27488), + 39: uint16(27489), + 40: uint16(27496), + 41: uint16(27497), + 42: uint16(27499), + 43: uint16(27500), + 44: uint16(27501), + 45: uint16(27502), + 46: uint16(27503), + 47: uint16(27504), + 48: uint16(27505), + 49: uint16(27506), + 50: uint16(27507), + 51: uint16(27508), + 52: uint16(27509), + 53: uint16(27510), + 54: uint16(27511), + 55: uint16(27512), + 56: uint16(27514), + 57: uint16(27517), + 58: uint16(27518), + 59: uint16(27519), + 60: uint16(27520), + 61: uint16(27525), + 62: uint16(27528), + 63: uint16(27532), + 64: uint16(27534), + 65: uint16(27535), + 66: uint16(27536), + 67: uint16(27537), + 68: uint16(27540), + 69: uint16(27541), + 70: uint16(27543), + 71: uint16(27544), + 72: uint16(27545), + 73: uint16(27548), + 74: uint16(27549), + 75: uint16(27550), + 76: uint16(27551), + 77: uint16(27552), + 78: uint16(27554), + 79: uint16(27555), + 80: uint16(27556), + 81: uint16(27557), + 82: uint16(27558), + 83: uint16(27559), + 84: uint16(27560), + 85: uint16(27561), + 86: uint16(27563), + 87: uint16(27564), + 88: uint16(27565), + 89: uint16(27566), + 90: uint16(27567), + 91: uint16(27568), + 92: uint16(27569), + 93: uint16(27570), + 94: uint16(27574), + 95: uint16(27576), + 96: uint16(27577), + 97: uint16(27578), + 98: uint16(27579), + 99: uint16(27580), + 100: uint16(27581), + 101: uint16(27582), + 102: uint16(27584), + 103: uint16(27587), + 104: uint16(27588), + 105: uint16(27590), + 106: uint16(27591), + 107: uint16(27592), + 108: uint16(27593), + 109: uint16(27594), + 110: uint16(27596), + 111: uint16(27598), + 112: uint16(27600), + 113: uint16(27601), + 114: uint16(27608), + 115: uint16(27610), + 116: uint16(27612), + 117: uint16(27613), + 118: uint16(27614), + 119: uint16(27615), + 120: uint16(27616), + 121: uint16(27618), + 122: uint16(27619), + 123: uint16(27620), + 124: uint16(27621), + 125: uint16(27622), + 126: uint16(27623), + 127: uint16(27624), + 128: uint16(27625), + 129: uint16(27628), + 130: uint16(27629), + 131: uint16(27630), + 132: uint16(27632), + 133: uint16(27633), + 134: uint16(27634), + 135: uint16(27636), + 136: uint16(27638), + 137: uint16(27639), + 138: uint16(27640), + 139: uint16(27642), + 140: uint16(27643), + 141: uint16(27644), + 142: uint16(27646), + 143: uint16(27647), + 144: uint16(27648), + 145: uint16(27649), + 146: uint16(27650), + 147: uint16(27651), + 148: uint16(27652), + 149: uint16(27656), + 150: uint16(27657), + 151: uint16(27658), + 152: uint16(27659), + 153: uint16(27660), + 154: uint16(27662), + 155: uint16(27666), + 156: uint16(27671), + 157: uint16(27676), + 158: uint16(27677), + 159: uint16(27678), + 160: uint16(27680), + 161: uint16(27683), + 162: uint16(27685), + 163: uint16(27691), + 164: uint16(27692), + 165: uint16(27693), + 166: uint16(27697), + 167: uint16(27699), + 168: uint16(27702), + 169: uint16(27703), + 170: uint16(27705), + 171: uint16(27706), + 172: uint16(27707), + 173: uint16(27708), + 174: uint16(27710), + 175: uint16(27711), + 176: uint16(27715), + 177: uint16(27716), + 178: uint16(27717), + 179: uint16(27720), + 180: uint16(27723), + 181: uint16(27724), + 182: uint16(27725), + 183: uint16(27726), + 184: uint16(27727), + 185: uint16(27729), + 186: uint16(27730), + 187: uint16(27731), + 188: uint16(27734), + 189: uint16(27736), + }, + 26: { + 0: uint16(27737), + 1: uint16(27738), + 2: uint16(27746), + 3: uint16(27747), + 4: uint16(27749), + 5: uint16(27750), + 6: uint16(27751), + 7: uint16(27755), + 8: uint16(27756), + 9: uint16(27757), + 10: uint16(27758), + 11: uint16(27759), + 12: uint16(27761), + 13: uint16(27763), + 14: uint16(27765), + 15: uint16(27767), + 16: uint16(27768), + 17: uint16(27770), + 18: uint16(27771), + 19: uint16(27772), + 20: uint16(27775), + 21: uint16(27776), + 22: uint16(27780), + 23: uint16(27783), + 24: uint16(27786), + 25: uint16(27787), + 26: uint16(27789), + 27: uint16(27790), + 28: uint16(27793), + 29: uint16(27794), + 30: uint16(27797), + 31: uint16(27798), + 32: uint16(27799), + 33: uint16(27800), + 34: uint16(27802), + 35: uint16(27804), + 36: uint16(27805), + 37: uint16(27806), + 38: uint16(27808), + 39: uint16(27810), + 40: uint16(27816), + 41: uint16(27820), + 42: uint16(27823), + 43: uint16(27824), + 44: uint16(27828), + 45: uint16(27829), + 46: uint16(27830), + 47: uint16(27831), + 48: uint16(27834), + 49: uint16(27840), + 50: uint16(27841), + 51: uint16(27842), + 52: uint16(27843), + 53: uint16(27846), + 54: uint16(27847), + 55: uint16(27848), + 56: uint16(27851), + 57: uint16(27853), + 58: uint16(27854), + 59: uint16(27855), + 60: uint16(27857), + 61: uint16(27858), + 62: uint16(27864), + 63: uint16(27865), + 64: uint16(27866), + 65: uint16(27868), + 66: uint16(27869), + 67: uint16(27871), + 68: uint16(27876), + 69: uint16(27878), + 70: uint16(27879), + 71: uint16(27881), + 72: uint16(27884), + 73: uint16(27885), + 74: uint16(27890), + 75: uint16(27892), + 76: uint16(27897), + 77: uint16(27903), + 78: uint16(27904), + 79: uint16(27906), + 80: uint16(27907), + 81: uint16(27909), + 82: uint16(27910), + 83: uint16(27912), + 84: uint16(27913), + 85: uint16(27914), + 86: uint16(27917), + 87: uint16(27919), + 88: uint16(27920), + 89: uint16(27921), + 90: uint16(27923), + 91: uint16(27924), + 92: uint16(27925), + 93: uint16(27926), + 94: uint16(27928), + 95: uint16(27932), + 96: uint16(27933), + 97: uint16(27935), + 98: uint16(27936), + 99: uint16(27937), + 100: uint16(27938), + 101: uint16(27939), + 102: uint16(27940), + 103: uint16(27942), + 104: uint16(27944), + 105: uint16(27945), + 106: uint16(27948), + 107: uint16(27949), + 108: uint16(27951), + 109: uint16(27952), + 110: uint16(27956), + 111: uint16(27958), + 112: uint16(27959), + 113: uint16(27960), + 114: uint16(27962), + 115: uint16(27967), + 116: uint16(27968), + 117: uint16(27970), + 118: uint16(27972), + 119: uint16(27977), + 120: uint16(27980), + 121: uint16(27984), + 122: uint16(27989), + 123: uint16(27990), + 124: uint16(27991), + 125: uint16(27992), + 126: uint16(27995), + 127: uint16(27997), + 128: uint16(27999), + 129: uint16(28001), + 130: uint16(28002), + 131: uint16(28004), + 132: uint16(28005), + 133: uint16(28007), + 134: uint16(28008), + 135: uint16(28011), + 136: uint16(28012), + 137: uint16(28013), + 138: uint16(28016), + 139: uint16(28017), + 140: uint16(28018), + 141: uint16(28019), + 142: uint16(28021), + 143: uint16(28022), + 144: uint16(28025), + 145: uint16(28026), + 146: uint16(28027), + 147: uint16(28029), + 148: uint16(28030), + 149: uint16(28031), + 150: uint16(28032), + 151: uint16(28033), + 152: uint16(28035), + 153: uint16(28036), + 154: uint16(28038), + 155: uint16(28039), + 156: uint16(28042), + 157: uint16(28043), + 158: uint16(28045), + 159: uint16(28047), + 160: uint16(28048), + 161: uint16(28050), + 162: uint16(28054), + 163: uint16(28055), + 164: uint16(28056), + 165: uint16(28057), + 166: uint16(28058), + 167: uint16(28060), + 168: uint16(28066), + 169: uint16(28069), + 170: uint16(28076), + 171: uint16(28077), + 172: uint16(28080), + 173: uint16(28081), + 174: uint16(28083), + 175: uint16(28084), + 176: uint16(28086), + 177: uint16(28087), + 178: uint16(28089), + 179: uint16(28090), + 180: uint16(28091), + 181: uint16(28092), + 182: uint16(28093), + 183: uint16(28094), + 184: uint16(28097), + 185: uint16(28098), + 186: uint16(28099), + 187: uint16(28104), + 188: uint16(28105), + 189: uint16(28106), + }, + 27: { + 0: uint16(28109), + 1: uint16(28110), + 2: uint16(28111), + 3: uint16(28112), + 4: uint16(28114), + 5: uint16(28115), + 6: uint16(28116), + 7: uint16(28117), + 8: uint16(28119), + 9: uint16(28122), + 10: uint16(28123), + 11: uint16(28124), + 12: uint16(28127), + 13: uint16(28130), + 14: uint16(28131), + 15: uint16(28133), + 16: uint16(28135), + 17: uint16(28136), + 18: uint16(28137), + 19: uint16(28138), + 20: uint16(28141), + 21: uint16(28143), + 22: uint16(28144), + 23: uint16(28146), + 24: uint16(28148), + 25: uint16(28149), + 26: uint16(28150), + 27: uint16(28152), + 28: uint16(28154), + 29: uint16(28157), + 30: uint16(28158), + 31: uint16(28159), + 32: uint16(28160), + 33: uint16(28161), + 34: uint16(28162), + 35: uint16(28163), + 36: uint16(28164), + 37: uint16(28166), + 38: uint16(28167), + 39: uint16(28168), + 40: uint16(28169), + 41: uint16(28171), + 42: uint16(28175), + 43: uint16(28178), + 44: uint16(28179), + 45: uint16(28181), + 46: uint16(28184), + 47: uint16(28185), + 48: uint16(28187), + 49: uint16(28188), + 50: uint16(28190), + 51: uint16(28191), + 52: uint16(28194), + 53: uint16(28198), + 54: uint16(28199), + 55: uint16(28200), + 56: uint16(28202), + 57: uint16(28204), + 58: uint16(28206), + 59: uint16(28208), + 60: uint16(28209), + 61: uint16(28211), + 62: uint16(28213), + 63: uint16(28214), + 64: uint16(28215), + 65: uint16(28217), + 66: uint16(28219), + 67: uint16(28220), + 68: uint16(28221), + 69: uint16(28222), + 70: uint16(28223), + 71: uint16(28224), + 72: uint16(28225), + 73: uint16(28226), + 74: uint16(28229), + 75: uint16(28230), + 76: uint16(28231), + 77: uint16(28232), + 78: uint16(28233), + 79: uint16(28234), + 80: uint16(28235), + 81: uint16(28236), + 82: uint16(28239), + 83: uint16(28240), + 84: uint16(28241), + 85: uint16(28242), + 86: uint16(28245), + 87: uint16(28247), + 88: uint16(28249), + 89: uint16(28250), + 90: uint16(28252), + 91: uint16(28253), + 92: uint16(28254), + 93: uint16(28256), + 94: uint16(28257), + 95: uint16(28258), + 96: uint16(28259), + 97: uint16(28260), + 98: uint16(28261), + 99: uint16(28262), + 100: uint16(28263), + 101: uint16(28264), + 102: uint16(28265), + 103: uint16(28266), + 104: uint16(28268), + 105: uint16(28269), + 106: uint16(28271), + 107: uint16(28272), + 108: uint16(28273), + 109: uint16(28274), + 110: uint16(28275), + 111: uint16(28276), + 112: uint16(28277), + 113: uint16(28278), + 114: uint16(28279), + 115: uint16(28280), + 116: uint16(28281), + 117: uint16(28282), + 118: uint16(28283), + 119: uint16(28284), + 120: uint16(28285), + 121: uint16(28288), + 122: uint16(28289), + 123: uint16(28290), + 124: uint16(28292), + 125: uint16(28295), + 126: uint16(28296), + 127: uint16(28298), + 128: uint16(28299), + 129: uint16(28300), + 130: uint16(28301), + 131: uint16(28302), + 132: uint16(28305), + 133: uint16(28306), + 134: uint16(28307), + 135: uint16(28308), + 136: uint16(28309), + 137: uint16(28310), + 138: uint16(28311), + 139: uint16(28313), + 140: uint16(28314), + 141: uint16(28315), + 142: uint16(28317), + 143: uint16(28318), + 144: uint16(28320), + 145: uint16(28321), + 146: uint16(28323), + 147: uint16(28324), + 148: uint16(28326), + 149: uint16(28328), + 150: uint16(28329), + 151: uint16(28331), + 152: uint16(28332), + 153: uint16(28333), + 154: uint16(28334), + 155: uint16(28336), + 156: uint16(28339), + 157: uint16(28341), + 158: uint16(28344), + 159: uint16(28345), + 160: uint16(28348), + 161: uint16(28350), + 162: uint16(28351), + 163: uint16(28352), + 164: uint16(28355), + 165: uint16(28356), + 166: uint16(28357), + 167: uint16(28358), + 168: uint16(28360), + 169: uint16(28361), + 170: uint16(28362), + 171: uint16(28364), + 172: uint16(28365), + 173: uint16(28366), + 174: uint16(28368), + 175: uint16(28370), + 176: uint16(28374), + 177: uint16(28376), + 178: uint16(28377), + 179: uint16(28379), + 180: uint16(28380), + 181: uint16(28381), + 182: uint16(28387), + 183: uint16(28391), + 184: uint16(28394), + 185: uint16(28395), + 186: uint16(28396), + 187: uint16(28397), + 188: uint16(28398), + 189: uint16(28399), + }, + 28: { + 0: uint16(28400), + 1: uint16(28401), + 2: uint16(28402), + 3: uint16(28403), + 4: uint16(28405), + 5: uint16(28406), + 6: uint16(28407), + 7: uint16(28408), + 8: uint16(28410), + 9: uint16(28411), + 10: uint16(28412), + 11: uint16(28413), + 12: uint16(28414), + 13: uint16(28415), + 14: uint16(28416), + 15: uint16(28417), + 16: uint16(28419), + 17: uint16(28420), + 18: uint16(28421), + 19: uint16(28423), + 20: uint16(28424), + 21: uint16(28426), + 22: uint16(28427), + 23: uint16(28428), + 24: uint16(28429), + 25: uint16(28430), + 26: uint16(28432), + 27: uint16(28433), + 28: uint16(28434), + 29: uint16(28438), + 30: uint16(28439), + 31: uint16(28440), + 32: uint16(28441), + 33: uint16(28442), + 34: uint16(28443), + 35: uint16(28444), + 36: uint16(28445), + 37: uint16(28446), + 38: uint16(28447), + 39: uint16(28449), + 40: uint16(28450), + 41: uint16(28451), + 42: uint16(28453), + 43: uint16(28454), + 44: uint16(28455), + 45: uint16(28456), + 46: uint16(28460), + 47: uint16(28462), + 48: uint16(28464), + 49: uint16(28466), + 50: uint16(28468), + 51: uint16(28469), + 52: uint16(28471), + 53: uint16(28472), + 54: uint16(28473), + 55: uint16(28474), + 56: uint16(28475), + 57: uint16(28476), + 58: uint16(28477), + 59: uint16(28479), + 60: uint16(28480), + 61: uint16(28481), + 62: uint16(28482), + 63: uint16(28483), + 64: uint16(28484), + 65: uint16(28485), + 66: uint16(28488), + 67: uint16(28489), + 68: uint16(28490), + 69: uint16(28492), + 70: uint16(28494), + 71: uint16(28495), + 72: uint16(28496), + 73: uint16(28497), + 74: uint16(28498), + 75: uint16(28499), + 76: uint16(28500), + 77: uint16(28501), + 78: uint16(28502), + 79: uint16(28503), + 80: uint16(28505), + 81: uint16(28506), + 82: uint16(28507), + 83: uint16(28509), + 84: uint16(28511), + 85: uint16(28512), + 86: uint16(28513), + 87: uint16(28515), + 88: uint16(28516), + 89: uint16(28517), + 90: uint16(28519), + 91: uint16(28520), + 92: uint16(28521), + 93: uint16(28522), + 94: uint16(28523), + 95: uint16(28524), + 96: uint16(28527), + 97: uint16(28528), + 98: uint16(28529), + 99: uint16(28531), + 100: uint16(28533), + 101: uint16(28534), + 102: uint16(28535), + 103: uint16(28537), + 104: uint16(28539), + 105: uint16(28541), + 106: uint16(28542), + 107: uint16(28543), + 108: uint16(28544), + 109: uint16(28545), + 110: uint16(28546), + 111: uint16(28547), + 112: uint16(28549), + 113: uint16(28550), + 114: uint16(28551), + 115: uint16(28554), + 116: uint16(28555), + 117: uint16(28559), + 118: uint16(28560), + 119: uint16(28561), + 120: uint16(28562), + 121: uint16(28563), + 122: uint16(28564), + 123: uint16(28565), + 124: uint16(28566), + 125: uint16(28567), + 126: uint16(28568), + 127: uint16(28569), + 128: uint16(28570), + 129: uint16(28571), + 130: uint16(28573), + 131: uint16(28574), + 132: uint16(28575), + 133: uint16(28576), + 134: uint16(28578), + 135: uint16(28579), + 136: uint16(28580), + 137: uint16(28581), + 138: uint16(28582), + 139: uint16(28584), + 140: uint16(28585), + 141: uint16(28586), + 142: uint16(28587), + 143: uint16(28588), + 144: uint16(28589), + 145: uint16(28590), + 146: uint16(28591), + 147: uint16(28592), + 148: uint16(28593), + 149: uint16(28594), + 150: uint16(28596), + 151: uint16(28597), + 152: uint16(28599), + 153: uint16(28600), + 154: uint16(28602), + 155: uint16(28603), + 156: uint16(28604), + 157: uint16(28605), + 158: uint16(28606), + 159: uint16(28607), + 160: uint16(28609), + 161: uint16(28611), + 162: uint16(28612), + 163: uint16(28613), + 164: uint16(28614), + 165: uint16(28615), + 166: uint16(28616), + 167: uint16(28618), + 168: uint16(28619), + 169: uint16(28620), + 170: uint16(28621), + 171: uint16(28622), + 172: uint16(28623), + 173: uint16(28624), + 174: uint16(28627), + 175: uint16(28628), + 176: uint16(28629), + 177: uint16(28630), + 178: uint16(28631), + 179: uint16(28632), + 180: uint16(28633), + 181: uint16(28634), + 182: uint16(28635), + 183: uint16(28636), + 184: uint16(28637), + 185: uint16(28639), + 186: uint16(28642), + 187: uint16(28643), + 188: uint16(28644), + 189: uint16(28645), + }, + 29: { + 0: uint16(28646), + 1: uint16(28647), + 2: uint16(28648), + 3: uint16(28649), + 4: uint16(28650), + 5: uint16(28651), + 6: uint16(28652), + 7: uint16(28653), + 8: uint16(28656), + 9: uint16(28657), + 10: uint16(28658), + 11: uint16(28659), + 12: uint16(28660), + 13: uint16(28661), + 14: uint16(28662), + 15: uint16(28663), + 16: uint16(28664), + 17: uint16(28665), + 18: uint16(28666), + 19: uint16(28667), + 20: uint16(28668), + 21: uint16(28669), + 22: uint16(28670), + 23: uint16(28671), + 24: uint16(28672), + 25: uint16(28673), + 26: uint16(28674), + 27: uint16(28675), + 28: uint16(28676), + 29: uint16(28677), + 30: uint16(28678), + 31: uint16(28679), + 32: uint16(28680), + 33: uint16(28681), + 34: uint16(28682), + 35: uint16(28683), + 36: uint16(28684), + 37: uint16(28685), + 38: uint16(28686), + 39: uint16(28687), + 40: uint16(28688), + 41: uint16(28690), + 42: uint16(28691), + 43: uint16(28692), + 44: uint16(28693), + 45: uint16(28694), + 46: uint16(28695), + 47: uint16(28696), + 48: uint16(28697), + 49: uint16(28700), + 50: uint16(28701), + 51: uint16(28702), + 52: uint16(28703), + 53: uint16(28704), + 54: uint16(28705), + 55: uint16(28706), + 56: uint16(28708), + 57: uint16(28709), + 58: uint16(28710), + 59: uint16(28711), + 60: uint16(28712), + 61: uint16(28713), + 62: uint16(28714), + 63: uint16(28715), + 64: uint16(28716), + 65: uint16(28717), + 66: uint16(28718), + 67: uint16(28719), + 68: uint16(28720), + 69: uint16(28721), + 70: uint16(28722), + 71: uint16(28723), + 72: uint16(28724), + 73: uint16(28726), + 74: uint16(28727), + 75: uint16(28728), + 76: uint16(28730), + 77: uint16(28731), + 78: uint16(28732), + 79: uint16(28733), + 80: uint16(28734), + 81: uint16(28735), + 82: uint16(28736), + 83: uint16(28737), + 84: uint16(28738), + 85: uint16(28739), + 86: uint16(28740), + 87: uint16(28741), + 88: uint16(28742), + 89: uint16(28743), + 90: uint16(28744), + 91: uint16(28745), + 92: uint16(28746), + 93: uint16(28747), + 94: uint16(28749), + 95: uint16(28750), + 96: uint16(28752), + 97: uint16(28753), + 98: uint16(28754), + 99: uint16(28755), + 100: uint16(28756), + 101: uint16(28757), + 102: uint16(28758), + 103: uint16(28759), + 104: uint16(28760), + 105: uint16(28761), + 106: uint16(28762), + 107: uint16(28763), + 108: uint16(28764), + 109: uint16(28765), + 110: uint16(28767), + 111: uint16(28768), + 112: uint16(28769), + 113: uint16(28770), + 114: uint16(28771), + 115: uint16(28772), + 116: uint16(28773), + 117: uint16(28774), + 118: uint16(28775), + 119: uint16(28776), + 120: uint16(28777), + 121: uint16(28778), + 122: uint16(28782), + 123: uint16(28785), + 124: uint16(28786), + 125: uint16(28787), + 126: uint16(28788), + 127: uint16(28791), + 128: uint16(28793), + 129: uint16(28794), + 130: uint16(28795), + 131: uint16(28797), + 132: uint16(28801), + 133: uint16(28802), + 134: uint16(28803), + 135: uint16(28804), + 136: uint16(28806), + 137: uint16(28807), + 138: uint16(28808), + 139: uint16(28811), + 140: uint16(28812), + 141: uint16(28813), + 142: uint16(28815), + 143: uint16(28816), + 144: uint16(28817), + 145: uint16(28819), + 146: uint16(28823), + 147: uint16(28824), + 148: uint16(28826), + 149: uint16(28827), + 150: uint16(28830), + 151: uint16(28831), + 152: uint16(28832), + 153: uint16(28833), + 154: uint16(28834), + 155: uint16(28835), + 156: uint16(28836), + 157: uint16(28837), + 158: uint16(28838), + 159: uint16(28839), + 160: uint16(28840), + 161: uint16(28841), + 162: uint16(28842), + 163: uint16(28848), + 164: uint16(28850), + 165: uint16(28852), + 166: uint16(28853), + 167: uint16(28854), + 168: uint16(28858), + 169: uint16(28862), + 170: uint16(28863), + 171: uint16(28868), + 172: uint16(28869), + 173: uint16(28870), + 174: uint16(28871), + 175: uint16(28873), + 176: uint16(28875), + 177: uint16(28876), + 178: uint16(28877), + 179: uint16(28878), + 180: uint16(28879), + 181: uint16(28880), + 182: uint16(28881), + 183: uint16(28882), + 184: uint16(28883), + 185: uint16(28884), + 186: uint16(28885), + 187: uint16(28886), + 188: uint16(28887), + 189: uint16(28890), + }, + 30: { + 0: uint16(28892), + 1: uint16(28893), + 2: uint16(28894), + 3: uint16(28896), + 4: uint16(28897), + 5: uint16(28898), + 6: uint16(28899), + 7: uint16(28901), + 8: uint16(28906), + 9: uint16(28910), + 10: uint16(28912), + 11: uint16(28913), + 12: uint16(28914), + 13: uint16(28915), + 14: uint16(28916), + 15: uint16(28917), + 16: uint16(28918), + 17: uint16(28920), + 18: uint16(28922), + 19: uint16(28923), + 20: uint16(28924), + 21: uint16(28926), + 22: uint16(28927), + 23: uint16(28928), + 24: uint16(28929), + 25: uint16(28930), + 26: uint16(28931), + 27: uint16(28932), + 28: uint16(28933), + 29: uint16(28934), + 30: uint16(28935), + 31: uint16(28936), + 32: uint16(28939), + 33: uint16(28940), + 34: uint16(28941), + 35: uint16(28942), + 36: uint16(28943), + 37: uint16(28945), + 38: uint16(28946), + 39: uint16(28948), + 40: uint16(28951), + 41: uint16(28955), + 42: uint16(28956), + 43: uint16(28957), + 44: uint16(28958), + 45: uint16(28959), + 46: uint16(28960), + 47: uint16(28961), + 48: uint16(28962), + 49: uint16(28963), + 50: uint16(28964), + 51: uint16(28965), + 52: uint16(28967), + 53: uint16(28968), + 54: uint16(28969), + 55: uint16(28970), + 56: uint16(28971), + 57: uint16(28972), + 58: uint16(28973), + 59: uint16(28974), + 60: uint16(28978), + 61: uint16(28979), + 62: uint16(28980), + 63: uint16(28981), + 64: uint16(28983), + 65: uint16(28984), + 66: uint16(28985), + 67: uint16(28986), + 68: uint16(28987), + 69: uint16(28988), + 70: uint16(28989), + 71: uint16(28990), + 72: uint16(28991), + 73: uint16(28992), + 74: uint16(28993), + 75: uint16(28994), + 76: uint16(28995), + 77: uint16(28996), + 78: uint16(28998), + 79: uint16(28999), + 80: uint16(29000), + 81: uint16(29001), + 82: uint16(29003), + 83: uint16(29005), + 84: uint16(29007), + 85: uint16(29008), + 86: uint16(29009), + 87: uint16(29010), + 88: uint16(29011), + 89: uint16(29012), + 90: uint16(29013), + 91: uint16(29014), + 92: uint16(29015), + 93: uint16(29016), + 94: uint16(29017), + 95: uint16(29018), + 96: uint16(29019), + 97: uint16(29021), + 98: uint16(29023), + 99: uint16(29024), + 100: uint16(29025), + 101: uint16(29026), + 102: uint16(29027), + 103: uint16(29029), + 104: uint16(29033), + 105: uint16(29034), + 106: uint16(29035), + 107: uint16(29036), + 108: uint16(29037), + 109: uint16(29039), + 110: uint16(29040), + 111: uint16(29041), + 112: uint16(29044), + 113: uint16(29045), + 114: uint16(29046), + 115: uint16(29047), + 116: uint16(29049), + 117: uint16(29051), + 118: uint16(29052), + 119: uint16(29054), + 120: uint16(29055), + 121: uint16(29056), + 122: uint16(29057), + 123: uint16(29058), + 124: uint16(29059), + 125: uint16(29061), + 126: uint16(29062), + 127: uint16(29063), + 128: uint16(29064), + 129: uint16(29065), + 130: uint16(29067), + 131: uint16(29068), + 132: uint16(29069), + 133: uint16(29070), + 134: uint16(29072), + 135: uint16(29073), + 136: uint16(29074), + 137: uint16(29075), + 138: uint16(29077), + 139: uint16(29078), + 140: uint16(29079), + 141: uint16(29082), + 142: uint16(29083), + 143: uint16(29084), + 144: uint16(29085), + 145: uint16(29086), + 146: uint16(29089), + 147: uint16(29090), + 148: uint16(29091), + 149: uint16(29092), + 150: uint16(29093), + 151: uint16(29094), + 152: uint16(29095), + 153: uint16(29097), + 154: uint16(29098), + 155: uint16(29099), + 156: uint16(29101), + 157: uint16(29102), + 158: uint16(29103), + 159: uint16(29104), + 160: uint16(29105), + 161: uint16(29106), + 162: uint16(29108), + 163: uint16(29110), + 164: uint16(29111), + 165: uint16(29112), + 166: uint16(29114), + 167: uint16(29115), + 168: uint16(29116), + 169: uint16(29117), + 170: uint16(29118), + 171: uint16(29119), + 172: uint16(29120), + 173: uint16(29121), + 174: uint16(29122), + 175: uint16(29124), + 176: uint16(29125), + 177: uint16(29126), + 178: uint16(29127), + 179: uint16(29128), + 180: uint16(29129), + 181: uint16(29130), + 182: uint16(29131), + 183: uint16(29132), + 184: uint16(29133), + 185: uint16(29135), + 186: uint16(29136), + 187: uint16(29137), + 188: uint16(29138), + 189: uint16(29139), + }, + 31: { + 0: uint16(29142), + 1: uint16(29143), + 2: uint16(29144), + 3: uint16(29145), + 4: uint16(29146), + 5: uint16(29147), + 6: uint16(29148), + 7: uint16(29149), + 8: uint16(29150), + 9: uint16(29151), + 10: uint16(29153), + 11: uint16(29154), + 12: uint16(29155), + 13: uint16(29156), + 14: uint16(29158), + 15: uint16(29160), + 16: uint16(29161), + 17: uint16(29162), + 18: uint16(29163), + 19: uint16(29164), + 20: uint16(29165), + 21: uint16(29167), + 22: uint16(29168), + 23: uint16(29169), + 24: uint16(29170), + 25: uint16(29171), + 26: uint16(29172), + 27: uint16(29173), + 28: uint16(29174), + 29: uint16(29175), + 30: uint16(29176), + 31: uint16(29178), + 32: uint16(29179), + 33: uint16(29180), + 34: uint16(29181), + 35: uint16(29182), + 36: uint16(29183), + 37: uint16(29184), + 38: uint16(29185), + 39: uint16(29186), + 40: uint16(29187), + 41: uint16(29188), + 42: uint16(29189), + 43: uint16(29191), + 44: uint16(29192), + 45: uint16(29193), + 46: uint16(29194), + 47: uint16(29195), + 48: uint16(29196), + 49: uint16(29197), + 50: uint16(29198), + 51: uint16(29199), + 52: uint16(29200), + 53: uint16(29201), + 54: uint16(29202), + 55: uint16(29203), + 56: uint16(29204), + 57: uint16(29205), + 58: uint16(29206), + 59: uint16(29207), + 60: uint16(29208), + 61: uint16(29209), + 62: uint16(29210), + 63: uint16(29211), + 64: uint16(29212), + 65: uint16(29214), + 66: uint16(29215), + 67: uint16(29216), + 68: uint16(29217), + 69: uint16(29218), + 70: uint16(29219), + 71: uint16(29220), + 72: uint16(29221), + 73: uint16(29222), + 74: uint16(29223), + 75: uint16(29225), + 76: uint16(29227), + 77: uint16(29229), + 78: uint16(29230), + 79: uint16(29231), + 80: uint16(29234), + 81: uint16(29235), + 82: uint16(29236), + 83: uint16(29242), + 84: uint16(29244), + 85: uint16(29246), + 86: uint16(29248), + 87: uint16(29249), + 88: uint16(29250), + 89: uint16(29251), + 90: uint16(29252), + 91: uint16(29253), + 92: uint16(29254), + 93: uint16(29257), + 94: uint16(29258), + 95: uint16(29259), + 96: uint16(29262), + 97: uint16(29263), + 98: uint16(29264), + 99: uint16(29265), + 100: uint16(29267), + 101: uint16(29268), + 102: uint16(29269), + 103: uint16(29271), + 104: uint16(29272), + 105: uint16(29274), + 106: uint16(29276), + 107: uint16(29278), + 108: uint16(29280), + 109: uint16(29283), + 110: uint16(29284), + 111: uint16(29285), + 112: uint16(29288), + 113: uint16(29290), + 114: uint16(29291), + 115: uint16(29292), + 116: uint16(29293), + 117: uint16(29296), + 118: uint16(29297), + 119: uint16(29299), + 120: uint16(29300), + 121: uint16(29302), + 122: uint16(29303), + 123: uint16(29304), + 124: uint16(29307), + 125: uint16(29308), + 126: uint16(29309), + 127: uint16(29314), + 128: uint16(29315), + 129: uint16(29317), + 130: uint16(29318), + 131: uint16(29319), + 132: uint16(29320), + 133: uint16(29321), + 134: uint16(29324), + 135: uint16(29326), + 136: uint16(29328), + 137: uint16(29329), + 138: uint16(29331), + 139: uint16(29332), + 140: uint16(29333), + 141: uint16(29334), + 142: uint16(29335), + 143: uint16(29336), + 144: uint16(29337), + 145: uint16(29338), + 146: uint16(29339), + 147: uint16(29340), + 148: uint16(29341), + 149: uint16(29342), + 150: uint16(29344), + 151: uint16(29345), + 152: uint16(29346), + 153: uint16(29347), + 154: uint16(29348), + 155: uint16(29349), + 156: uint16(29350), + 157: uint16(29351), + 158: uint16(29352), + 159: uint16(29353), + 160: uint16(29354), + 161: uint16(29355), + 162: uint16(29358), + 163: uint16(29361), + 164: uint16(29362), + 165: uint16(29363), + 166: uint16(29365), + 167: uint16(29370), + 168: uint16(29371), + 169: uint16(29372), + 170: uint16(29373), + 171: uint16(29374), + 172: uint16(29375), + 173: uint16(29376), + 174: uint16(29381), + 175: uint16(29382), + 176: uint16(29383), + 177: uint16(29385), + 178: uint16(29386), + 179: uint16(29387), + 180: uint16(29388), + 181: uint16(29391), + 182: uint16(29393), + 183: uint16(29395), + 184: uint16(29396), + 185: uint16(29397), + 186: uint16(29398), + 187: uint16(29400), + 188: uint16(29402), + 189: uint16(29403), + }, + 32: { + 0: uint16(58566), + 1: uint16(58567), + 2: uint16(58568), + 3: uint16(58569), + 4: uint16(58570), + 5: uint16(58571), + 6: uint16(58572), + 7: uint16(58573), + 8: uint16(58574), + 9: uint16(58575), + 10: uint16(58576), + 11: uint16(58577), + 12: uint16(58578), + 13: uint16(58579), + 14: uint16(58580), + 15: uint16(58581), + 16: uint16(58582), + 17: uint16(58583), + 18: uint16(58584), + 19: uint16(58585), + 20: uint16(58586), + 21: uint16(58587), + 22: uint16(58588), + 23: uint16(58589), + 24: uint16(58590), + 25: uint16(58591), + 26: uint16(58592), + 27: uint16(58593), + 28: uint16(58594), + 29: uint16(58595), + 30: uint16(58596), + 31: uint16(58597), + 32: uint16(58598), + 33: uint16(58599), + 34: uint16(58600), + 35: uint16(58601), + 36: uint16(58602), + 37: uint16(58603), + 38: uint16(58604), + 39: uint16(58605), + 40: uint16(58606), + 41: uint16(58607), + 42: uint16(58608), + 43: uint16(58609), + 44: uint16(58610), + 45: uint16(58611), + 46: uint16(58612), + 47: uint16(58613), + 48: uint16(58614), + 49: uint16(58615), + 50: uint16(58616), + 51: uint16(58617), + 52: uint16(58618), + 53: uint16(58619), + 54: uint16(58620), + 55: uint16(58621), + 56: uint16(58622), + 57: uint16(58623), + 58: uint16(58624), + 59: uint16(58625), + 60: uint16(58626), + 61: uint16(58627), + 62: uint16(58628), + 63: uint16(58629), + 64: uint16(58630), + 65: uint16(58631), + 66: uint16(58632), + 67: uint16(58633), + 68: uint16(58634), + 69: uint16(58635), + 70: uint16(58636), + 71: uint16(58637), + 72: uint16(58638), + 73: uint16(58639), + 74: uint16(58640), + 75: uint16(58641), + 76: uint16(58642), + 77: uint16(58643), + 78: uint16(58644), + 79: uint16(58645), + 80: uint16(58646), + 81: uint16(58647), + 82: uint16(58648), + 83: uint16(58649), + 84: uint16(58650), + 85: uint16(58651), + 86: uint16(58652), + 87: uint16(58653), + 88: uint16(58654), + 89: uint16(58655), + 90: uint16(58656), + 91: uint16(58657), + 92: uint16(58658), + 93: uint16(58659), + 94: uint16(58660), + 95: uint16(58661), + 96: uint16(12288), + 97: uint16(12289), + 98: uint16(12290), + 99: uint16(183), + 100: uint16(713), + 101: uint16(711), + 102: uint16(168), + 103: uint16(12291), + 104: uint16(12293), + 105: uint16(8212), + 106: uint16(65374), + 107: uint16(8214), + 108: uint16(8230), + 109: uint16(8216), + 110: uint16(8217), + 111: uint16(8220), + 112: uint16(8221), + 113: uint16(12308), + 114: uint16(12309), + 115: uint16(12296), + 116: uint16(12297), + 117: uint16(12298), + 118: uint16(12299), + 119: uint16(12300), + 120: uint16(12301), + 121: uint16(12302), + 122: uint16(12303), + 123: uint16(12310), + 124: uint16(12311), + 125: uint16(12304), + 126: uint16(12305), + 127: uint16(177), + 128: uint16(215), + 129: uint16(247), + 130: uint16(8758), + 131: uint16(8743), + 132: uint16(8744), + 133: uint16(8721), + 134: uint16(8719), + 135: uint16(8746), + 136: uint16(8745), + 137: uint16(8712), + 138: uint16(8759), + 139: uint16(8730), + 140: uint16(8869), + 141: uint16(8741), + 142: uint16(8736), + 143: uint16(8978), + 144: uint16(8857), + 145: uint16(8747), + 146: uint16(8750), + 147: uint16(8801), + 148: uint16(8780), + 149: uint16(8776), + 150: uint16(8765), + 151: uint16(8733), + 152: uint16(8800), + 153: uint16(8814), + 154: uint16(8815), + 155: uint16(8804), + 156: uint16(8805), + 157: uint16(8734), + 158: uint16(8757), + 159: uint16(8756), + 160: uint16(9794), + 161: uint16(9792), + 162: uint16(176), + 163: uint16(8242), + 164: uint16(8243), + 165: uint16(8451), + 166: uint16(65284), + 167: uint16(164), + 168: uint16(65504), + 169: uint16(65505), + 170: uint16(8240), + 171: uint16(167), + 172: uint16(8470), + 173: uint16(9734), + 174: uint16(9733), + 175: uint16(9675), + 176: uint16(9679), + 177: uint16(9678), + 178: uint16(9671), + 179: uint16(9670), + 180: uint16(9633), + 181: uint16(9632), + 182: uint16(9651), + 183: uint16(9650), + 184: uint16(8251), + 185: uint16(8594), + 186: uint16(8592), + 187: uint16(8593), + 188: uint16(8595), + 189: uint16(12307), + }, + 33: { + 0: uint16(58662), + 1: uint16(58663), + 2: uint16(58664), + 3: uint16(58665), + 4: uint16(58666), + 5: uint16(58667), + 6: uint16(58668), + 7: uint16(58669), + 8: uint16(58670), + 9: uint16(58671), + 10: uint16(58672), + 11: uint16(58673), + 12: uint16(58674), + 13: uint16(58675), + 14: uint16(58676), + 15: uint16(58677), + 16: uint16(58678), + 17: uint16(58679), + 18: uint16(58680), + 19: uint16(58681), + 20: uint16(58682), + 21: uint16(58683), + 22: uint16(58684), + 23: uint16(58685), + 24: uint16(58686), + 25: uint16(58687), + 26: uint16(58688), + 27: uint16(58689), + 28: uint16(58690), + 29: uint16(58691), + 30: uint16(58692), + 31: uint16(58693), + 32: uint16(58694), + 33: uint16(58695), + 34: uint16(58696), + 35: uint16(58697), + 36: uint16(58698), + 37: uint16(58699), + 38: uint16(58700), + 39: uint16(58701), + 40: uint16(58702), + 41: uint16(58703), + 42: uint16(58704), + 43: uint16(58705), + 44: uint16(58706), + 45: uint16(58707), + 46: uint16(58708), + 47: uint16(58709), + 48: uint16(58710), + 49: uint16(58711), + 50: uint16(58712), + 51: uint16(58713), + 52: uint16(58714), + 53: uint16(58715), + 54: uint16(58716), + 55: uint16(58717), + 56: uint16(58718), + 57: uint16(58719), + 58: uint16(58720), + 59: uint16(58721), + 60: uint16(58722), + 61: uint16(58723), + 62: uint16(58724), + 63: uint16(58725), + 64: uint16(58726), + 65: uint16(58727), + 66: uint16(58728), + 67: uint16(58729), + 68: uint16(58730), + 69: uint16(58731), + 70: uint16(58732), + 71: uint16(58733), + 72: uint16(58734), + 73: uint16(58735), + 74: uint16(58736), + 75: uint16(58737), + 76: uint16(58738), + 77: uint16(58739), + 78: uint16(58740), + 79: uint16(58741), + 80: uint16(58742), + 81: uint16(58743), + 82: uint16(58744), + 83: uint16(58745), + 84: uint16(58746), + 85: uint16(58747), + 86: uint16(58748), + 87: uint16(58749), + 88: uint16(58750), + 89: uint16(58751), + 90: uint16(58752), + 91: uint16(58753), + 92: uint16(58754), + 93: uint16(58755), + 94: uint16(58756), + 95: uint16(58757), + 96: uint16(8560), + 97: uint16(8561), + 98: uint16(8562), + 99: uint16(8563), + 100: uint16(8564), + 101: uint16(8565), + 102: uint16(8566), + 103: uint16(8567), + 104: uint16(8568), + 105: uint16(8569), + 106: uint16(59238), + 107: uint16(59239), + 108: uint16(59240), + 109: uint16(59241), + 110: uint16(59242), + 111: uint16(59243), + 112: uint16(9352), + 113: uint16(9353), + 114: uint16(9354), + 115: uint16(9355), + 116: uint16(9356), + 117: uint16(9357), + 118: uint16(9358), + 119: uint16(9359), + 120: uint16(9360), + 121: uint16(9361), + 122: uint16(9362), + 123: uint16(9363), + 124: uint16(9364), + 125: uint16(9365), + 126: uint16(9366), + 127: uint16(9367), + 128: uint16(9368), + 129: uint16(9369), + 130: uint16(9370), + 131: uint16(9371), + 132: uint16(9332), + 133: uint16(9333), + 134: uint16(9334), + 135: uint16(9335), + 136: uint16(9336), + 137: uint16(9337), + 138: uint16(9338), + 139: uint16(9339), + 140: uint16(9340), + 141: uint16(9341), + 142: uint16(9342), + 143: uint16(9343), + 144: uint16(9344), + 145: uint16(9345), + 146: uint16(9346), + 147: uint16(9347), + 148: uint16(9348), + 149: uint16(9349), + 150: uint16(9350), + 151: uint16(9351), + 152: uint16(9312), + 153: uint16(9313), + 154: uint16(9314), + 155: uint16(9315), + 156: uint16(9316), + 157: uint16(9317), + 158: uint16(9318), + 159: uint16(9319), + 160: uint16(9320), + 161: uint16(9321), + 162: uint16(8364), + 163: uint16(59245), + 164: uint16(12832), + 165: uint16(12833), + 166: uint16(12834), + 167: uint16(12835), + 168: uint16(12836), + 169: uint16(12837), + 170: uint16(12838), + 171: uint16(12839), + 172: uint16(12840), + 173: uint16(12841), + 174: uint16(59246), + 175: uint16(59247), + 176: uint16(8544), + 177: uint16(8545), + 178: uint16(8546), + 179: uint16(8547), + 180: uint16(8548), + 181: uint16(8549), + 182: uint16(8550), + 183: uint16(8551), + 184: uint16(8552), + 185: uint16(8553), + 186: uint16(8554), + 187: uint16(8555), + 188: uint16(59248), + 189: uint16(59249), + }, + 34: { + 0: uint16(58758), + 1: uint16(58759), + 2: uint16(58760), + 3: uint16(58761), + 4: uint16(58762), + 5: uint16(58763), + 6: uint16(58764), + 7: uint16(58765), + 8: uint16(58766), + 9: uint16(58767), + 10: uint16(58768), + 11: uint16(58769), + 12: uint16(58770), + 13: uint16(58771), + 14: uint16(58772), + 15: uint16(58773), + 16: uint16(58774), + 17: uint16(58775), + 18: uint16(58776), + 19: uint16(58777), + 20: uint16(58778), + 21: uint16(58779), + 22: uint16(58780), + 23: uint16(58781), + 24: uint16(58782), + 25: uint16(58783), + 26: uint16(58784), + 27: uint16(58785), + 28: uint16(58786), + 29: uint16(58787), + 30: uint16(58788), + 31: uint16(58789), + 32: uint16(58790), + 33: uint16(58791), + 34: uint16(58792), + 35: uint16(58793), + 36: uint16(58794), + 37: uint16(58795), + 38: uint16(58796), + 39: uint16(58797), + 40: uint16(58798), + 41: uint16(58799), + 42: uint16(58800), + 43: uint16(58801), + 44: uint16(58802), + 45: uint16(58803), + 46: uint16(58804), + 47: uint16(58805), + 48: uint16(58806), + 49: uint16(58807), + 50: uint16(58808), + 51: uint16(58809), + 52: uint16(58810), + 53: uint16(58811), + 54: uint16(58812), + 55: uint16(58813), + 56: uint16(58814), + 57: uint16(58815), + 58: uint16(58816), + 59: uint16(58817), + 60: uint16(58818), + 61: uint16(58819), + 62: uint16(58820), + 63: uint16(58821), + 64: uint16(58822), + 65: uint16(58823), + 66: uint16(58824), + 67: uint16(58825), + 68: uint16(58826), + 69: uint16(58827), + 70: uint16(58828), + 71: uint16(58829), + 72: uint16(58830), + 73: uint16(58831), + 74: uint16(58832), + 75: uint16(58833), + 76: uint16(58834), + 77: uint16(58835), + 78: uint16(58836), + 79: uint16(58837), + 80: uint16(58838), + 81: uint16(58839), + 82: uint16(58840), + 83: uint16(58841), + 84: uint16(58842), + 85: uint16(58843), + 86: uint16(58844), + 87: uint16(58845), + 88: uint16(58846), + 89: uint16(58847), + 90: uint16(58848), + 91: uint16(58849), + 92: uint16(58850), + 93: uint16(58851), + 94: uint16(58852), + 95: uint16(58853), + 96: uint16(65281), + 97: uint16(65282), + 98: uint16(65283), + 99: uint16(65509), + 100: uint16(65285), + 101: uint16(65286), + 102: uint16(65287), + 103: uint16(65288), + 104: uint16(65289), + 105: uint16(65290), + 106: uint16(65291), + 107: uint16(65292), + 108: uint16(65293), + 109: uint16(65294), + 110: uint16(65295), + 111: uint16(65296), + 112: uint16(65297), + 113: uint16(65298), + 114: uint16(65299), + 115: uint16(65300), + 116: uint16(65301), + 117: uint16(65302), + 118: uint16(65303), + 119: uint16(65304), + 120: uint16(65305), + 121: uint16(65306), + 122: uint16(65307), + 123: uint16(65308), + 124: uint16(65309), + 125: uint16(65310), + 126: uint16(65311), + 127: uint16(65312), + 128: uint16(65313), + 129: uint16(65314), + 130: uint16(65315), + 131: uint16(65316), + 132: uint16(65317), + 133: uint16(65318), + 134: uint16(65319), + 135: uint16(65320), + 136: uint16(65321), + 137: uint16(65322), + 138: uint16(65323), + 139: uint16(65324), + 140: uint16(65325), + 141: uint16(65326), + 142: uint16(65327), + 143: uint16(65328), + 144: uint16(65329), + 145: uint16(65330), + 146: uint16(65331), + 147: uint16(65332), + 148: uint16(65333), + 149: uint16(65334), + 150: uint16(65335), + 151: uint16(65336), + 152: uint16(65337), + 153: uint16(65338), + 154: uint16(65339), + 155: uint16(65340), + 156: uint16(65341), + 157: uint16(65342), + 158: uint16(65343), + 159: uint16(65344), + 160: uint16(65345), + 161: uint16(65346), + 162: uint16(65347), + 163: uint16(65348), + 164: uint16(65349), + 165: uint16(65350), + 166: uint16(65351), + 167: uint16(65352), + 168: uint16(65353), + 169: uint16(65354), + 170: uint16(65355), + 171: uint16(65356), + 172: uint16(65357), + 173: uint16(65358), + 174: uint16(65359), + 175: uint16(65360), + 176: uint16(65361), + 177: uint16(65362), + 178: uint16(65363), + 179: uint16(65364), + 180: uint16(65365), + 181: uint16(65366), + 182: uint16(65367), + 183: uint16(65368), + 184: uint16(65369), + 185: uint16(65370), + 186: uint16(65371), + 187: uint16(65372), + 188: uint16(65373), + 189: uint16(65507), + }, + 35: { + 0: uint16(58854), + 1: uint16(58855), + 2: uint16(58856), + 3: uint16(58857), + 4: uint16(58858), + 5: uint16(58859), + 6: uint16(58860), + 7: uint16(58861), + 8: uint16(58862), + 9: uint16(58863), + 10: uint16(58864), + 11: uint16(58865), + 12: uint16(58866), + 13: uint16(58867), + 14: uint16(58868), + 15: uint16(58869), + 16: uint16(58870), + 17: uint16(58871), + 18: uint16(58872), + 19: uint16(58873), + 20: uint16(58874), + 21: uint16(58875), + 22: uint16(58876), + 23: uint16(58877), + 24: uint16(58878), + 25: uint16(58879), + 26: uint16(58880), + 27: uint16(58881), + 28: uint16(58882), + 29: uint16(58883), + 30: uint16(58884), + 31: uint16(58885), + 32: uint16(58886), + 33: uint16(58887), + 34: uint16(58888), + 35: uint16(58889), + 36: uint16(58890), + 37: uint16(58891), + 38: uint16(58892), + 39: uint16(58893), + 40: uint16(58894), + 41: uint16(58895), + 42: uint16(58896), + 43: uint16(58897), + 44: uint16(58898), + 45: uint16(58899), + 46: uint16(58900), + 47: uint16(58901), + 48: uint16(58902), + 49: uint16(58903), + 50: uint16(58904), + 51: uint16(58905), + 52: uint16(58906), + 53: uint16(58907), + 54: uint16(58908), + 55: uint16(58909), + 56: uint16(58910), + 57: uint16(58911), + 58: uint16(58912), + 59: uint16(58913), + 60: uint16(58914), + 61: uint16(58915), + 62: uint16(58916), + 63: uint16(58917), + 64: uint16(58918), + 65: uint16(58919), + 66: uint16(58920), + 67: uint16(58921), + 68: uint16(58922), + 69: uint16(58923), + 70: uint16(58924), + 71: uint16(58925), + 72: uint16(58926), + 73: uint16(58927), + 74: uint16(58928), + 75: uint16(58929), + 76: uint16(58930), + 77: uint16(58931), + 78: uint16(58932), + 79: uint16(58933), + 80: uint16(58934), + 81: uint16(58935), + 82: uint16(58936), + 83: uint16(58937), + 84: uint16(58938), + 85: uint16(58939), + 86: uint16(58940), + 87: uint16(58941), + 88: uint16(58942), + 89: uint16(58943), + 90: uint16(58944), + 91: uint16(58945), + 92: uint16(58946), + 93: uint16(58947), + 94: uint16(58948), + 95: uint16(58949), + 96: uint16(12353), + 97: uint16(12354), + 98: uint16(12355), + 99: uint16(12356), + 100: uint16(12357), + 101: uint16(12358), + 102: uint16(12359), + 103: uint16(12360), + 104: uint16(12361), + 105: uint16(12362), + 106: uint16(12363), + 107: uint16(12364), + 108: uint16(12365), + 109: uint16(12366), + 110: uint16(12367), + 111: uint16(12368), + 112: uint16(12369), + 113: uint16(12370), + 114: uint16(12371), + 115: uint16(12372), + 116: uint16(12373), + 117: uint16(12374), + 118: uint16(12375), + 119: uint16(12376), + 120: uint16(12377), + 121: uint16(12378), + 122: uint16(12379), + 123: uint16(12380), + 124: uint16(12381), + 125: uint16(12382), + 126: uint16(12383), + 127: uint16(12384), + 128: uint16(12385), + 129: uint16(12386), + 130: uint16(12387), + 131: uint16(12388), + 132: uint16(12389), + 133: uint16(12390), + 134: uint16(12391), + 135: uint16(12392), + 136: uint16(12393), + 137: uint16(12394), + 138: uint16(12395), + 139: uint16(12396), + 140: uint16(12397), + 141: uint16(12398), + 142: uint16(12399), + 143: uint16(12400), + 144: uint16(12401), + 145: uint16(12402), + 146: uint16(12403), + 147: uint16(12404), + 148: uint16(12405), + 149: uint16(12406), + 150: uint16(12407), + 151: uint16(12408), + 152: uint16(12409), + 153: uint16(12410), + 154: uint16(12411), + 155: uint16(12412), + 156: uint16(12413), + 157: uint16(12414), + 158: uint16(12415), + 159: uint16(12416), + 160: uint16(12417), + 161: uint16(12418), + 162: uint16(12419), + 163: uint16(12420), + 164: uint16(12421), + 165: uint16(12422), + 166: uint16(12423), + 167: uint16(12424), + 168: uint16(12425), + 169: uint16(12426), + 170: uint16(12427), + 171: uint16(12428), + 172: uint16(12429), + 173: uint16(12430), + 174: uint16(12431), + 175: uint16(12432), + 176: uint16(12433), + 177: uint16(12434), + 178: uint16(12435), + 179: uint16(59250), + 180: uint16(59251), + 181: uint16(59252), + 182: uint16(59253), + 183: uint16(59254), + 184: uint16(59255), + 185: uint16(59256), + 186: uint16(59257), + 187: uint16(59258), + 188: uint16(59259), + 189: uint16(59260), + }, + 36: { + 0: uint16(58950), + 1: uint16(58951), + 2: uint16(58952), + 3: uint16(58953), + 4: uint16(58954), + 5: uint16(58955), + 6: uint16(58956), + 7: uint16(58957), + 8: uint16(58958), + 9: uint16(58959), + 10: uint16(58960), + 11: uint16(58961), + 12: uint16(58962), + 13: uint16(58963), + 14: uint16(58964), + 15: uint16(58965), + 16: uint16(58966), + 17: uint16(58967), + 18: uint16(58968), + 19: uint16(58969), + 20: uint16(58970), + 21: uint16(58971), + 22: uint16(58972), + 23: uint16(58973), + 24: uint16(58974), + 25: uint16(58975), + 26: uint16(58976), + 27: uint16(58977), + 28: uint16(58978), + 29: uint16(58979), + 30: uint16(58980), + 31: uint16(58981), + 32: uint16(58982), + 33: uint16(58983), + 34: uint16(58984), + 35: uint16(58985), + 36: uint16(58986), + 37: uint16(58987), + 38: uint16(58988), + 39: uint16(58989), + 40: uint16(58990), + 41: uint16(58991), + 42: uint16(58992), + 43: uint16(58993), + 44: uint16(58994), + 45: uint16(58995), + 46: uint16(58996), + 47: uint16(58997), + 48: uint16(58998), + 49: uint16(58999), + 50: uint16(59000), + 51: uint16(59001), + 52: uint16(59002), + 53: uint16(59003), + 54: uint16(59004), + 55: uint16(59005), + 56: uint16(59006), + 57: uint16(59007), + 58: uint16(59008), + 59: uint16(59009), + 60: uint16(59010), + 61: uint16(59011), + 62: uint16(59012), + 63: uint16(59013), + 64: uint16(59014), + 65: uint16(59015), + 66: uint16(59016), + 67: uint16(59017), + 68: uint16(59018), + 69: uint16(59019), + 70: uint16(59020), + 71: uint16(59021), + 72: uint16(59022), + 73: uint16(59023), + 74: uint16(59024), + 75: uint16(59025), + 76: uint16(59026), + 77: uint16(59027), + 78: uint16(59028), + 79: uint16(59029), + 80: uint16(59030), + 81: uint16(59031), + 82: uint16(59032), + 83: uint16(59033), + 84: uint16(59034), + 85: uint16(59035), + 86: uint16(59036), + 87: uint16(59037), + 88: uint16(59038), + 89: uint16(59039), + 90: uint16(59040), + 91: uint16(59041), + 92: uint16(59042), + 93: uint16(59043), + 94: uint16(59044), + 95: uint16(59045), + 96: uint16(12449), + 97: uint16(12450), + 98: uint16(12451), + 99: uint16(12452), + 100: uint16(12453), + 101: uint16(12454), + 102: uint16(12455), + 103: uint16(12456), + 104: uint16(12457), + 105: uint16(12458), + 106: uint16(12459), + 107: uint16(12460), + 108: uint16(12461), + 109: uint16(12462), + 110: uint16(12463), + 111: uint16(12464), + 112: uint16(12465), + 113: uint16(12466), + 114: uint16(12467), + 115: uint16(12468), + 116: uint16(12469), + 117: uint16(12470), + 118: uint16(12471), + 119: uint16(12472), + 120: uint16(12473), + 121: uint16(12474), + 122: uint16(12475), + 123: uint16(12476), + 124: uint16(12477), + 125: uint16(12478), + 126: uint16(12479), + 127: uint16(12480), + 128: uint16(12481), + 129: uint16(12482), + 130: uint16(12483), + 131: uint16(12484), + 132: uint16(12485), + 133: uint16(12486), + 134: uint16(12487), + 135: uint16(12488), + 136: uint16(12489), + 137: uint16(12490), + 138: uint16(12491), + 139: uint16(12492), + 140: uint16(12493), + 141: uint16(12494), + 142: uint16(12495), + 143: uint16(12496), + 144: uint16(12497), + 145: uint16(12498), + 146: uint16(12499), + 147: uint16(12500), + 148: uint16(12501), + 149: uint16(12502), + 150: uint16(12503), + 151: uint16(12504), + 152: uint16(12505), + 153: uint16(12506), + 154: uint16(12507), + 155: uint16(12508), + 156: uint16(12509), + 157: uint16(12510), + 158: uint16(12511), + 159: uint16(12512), + 160: uint16(12513), + 161: uint16(12514), + 162: uint16(12515), + 163: uint16(12516), + 164: uint16(12517), + 165: uint16(12518), + 166: uint16(12519), + 167: uint16(12520), + 168: uint16(12521), + 169: uint16(12522), + 170: uint16(12523), + 171: uint16(12524), + 172: uint16(12525), + 173: uint16(12526), + 174: uint16(12527), + 175: uint16(12528), + 176: uint16(12529), + 177: uint16(12530), + 178: uint16(12531), + 179: uint16(12532), + 180: uint16(12533), + 181: uint16(12534), + 182: uint16(59261), + 183: uint16(59262), + 184: uint16(59263), + 185: uint16(59264), + 186: uint16(59265), + 187: uint16(59266), + 188: uint16(59267), + 189: uint16(59268), + }, + 37: { + 0: uint16(59046), + 1: uint16(59047), + 2: uint16(59048), + 3: uint16(59049), + 4: uint16(59050), + 5: uint16(59051), + 6: uint16(59052), + 7: uint16(59053), + 8: uint16(59054), + 9: uint16(59055), + 10: uint16(59056), + 11: uint16(59057), + 12: uint16(59058), + 13: uint16(59059), + 14: uint16(59060), + 15: uint16(59061), + 16: uint16(59062), + 17: uint16(59063), + 18: uint16(59064), + 19: uint16(59065), + 20: uint16(59066), + 21: uint16(59067), + 22: uint16(59068), + 23: uint16(59069), + 24: uint16(59070), + 25: uint16(59071), + 26: uint16(59072), + 27: uint16(59073), + 28: uint16(59074), + 29: uint16(59075), + 30: uint16(59076), + 31: uint16(59077), + 32: uint16(59078), + 33: uint16(59079), + 34: uint16(59080), + 35: uint16(59081), + 36: uint16(59082), + 37: uint16(59083), + 38: uint16(59084), + 39: uint16(59085), + 40: uint16(59086), + 41: uint16(59087), + 42: uint16(59088), + 43: uint16(59089), + 44: uint16(59090), + 45: uint16(59091), + 46: uint16(59092), + 47: uint16(59093), + 48: uint16(59094), + 49: uint16(59095), + 50: uint16(59096), + 51: uint16(59097), + 52: uint16(59098), + 53: uint16(59099), + 54: uint16(59100), + 55: uint16(59101), + 56: uint16(59102), + 57: uint16(59103), + 58: uint16(59104), + 59: uint16(59105), + 60: uint16(59106), + 61: uint16(59107), + 62: uint16(59108), + 63: uint16(59109), + 64: uint16(59110), + 65: uint16(59111), + 66: uint16(59112), + 67: uint16(59113), + 68: uint16(59114), + 69: uint16(59115), + 70: uint16(59116), + 71: uint16(59117), + 72: uint16(59118), + 73: uint16(59119), + 74: uint16(59120), + 75: uint16(59121), + 76: uint16(59122), + 77: uint16(59123), + 78: uint16(59124), + 79: uint16(59125), + 80: uint16(59126), + 81: uint16(59127), + 82: uint16(59128), + 83: uint16(59129), + 84: uint16(59130), + 85: uint16(59131), + 86: uint16(59132), + 87: uint16(59133), + 88: uint16(59134), + 89: uint16(59135), + 90: uint16(59136), + 91: uint16(59137), + 92: uint16(59138), + 93: uint16(59139), + 94: uint16(59140), + 95: uint16(59141), + 96: uint16(913), + 97: uint16(914), + 98: uint16(915), + 99: uint16(916), + 100: uint16(917), + 101: uint16(918), + 102: uint16(919), + 103: uint16(920), + 104: uint16(921), + 105: uint16(922), + 106: uint16(923), + 107: uint16(924), + 108: uint16(925), + 109: uint16(926), + 110: uint16(927), + 111: uint16(928), + 112: uint16(929), + 113: uint16(931), + 114: uint16(932), + 115: uint16(933), + 116: uint16(934), + 117: uint16(935), + 118: uint16(936), + 119: uint16(937), + 120: uint16(59269), + 121: uint16(59270), + 122: uint16(59271), + 123: uint16(59272), + 124: uint16(59273), + 125: uint16(59274), + 126: uint16(59275), + 127: uint16(59276), + 128: uint16(945), + 129: uint16(946), + 130: uint16(947), + 131: uint16(948), + 132: uint16(949), + 133: uint16(950), + 134: uint16(951), + 135: uint16(952), + 136: uint16(953), + 137: uint16(954), + 138: uint16(955), + 139: uint16(956), + 140: uint16(957), + 141: uint16(958), + 142: uint16(959), + 143: uint16(960), + 144: uint16(961), + 145: uint16(963), + 146: uint16(964), + 147: uint16(965), + 148: uint16(966), + 149: uint16(967), + 150: uint16(968), + 151: uint16(969), + 152: uint16(59277), + 153: uint16(59278), + 154: uint16(59279), + 155: uint16(59280), + 156: uint16(59281), + 157: uint16(59282), + 158: uint16(59283), + 159: uint16(65077), + 160: uint16(65078), + 161: uint16(65081), + 162: uint16(65082), + 163: uint16(65087), + 164: uint16(65088), + 165: uint16(65085), + 166: uint16(65086), + 167: uint16(65089), + 168: uint16(65090), + 169: uint16(65091), + 170: uint16(65092), + 171: uint16(59284), + 172: uint16(59285), + 173: uint16(65083), + 174: uint16(65084), + 175: uint16(65079), + 176: uint16(65080), + 177: uint16(65073), + 178: uint16(59286), + 179: uint16(65075), + 180: uint16(65076), + 181: uint16(59287), + 182: uint16(59288), + 183: uint16(59289), + 184: uint16(59290), + 185: uint16(59291), + 186: uint16(59292), + 187: uint16(59293), + 188: uint16(59294), + 189: uint16(59295), + }, + 38: { + 0: uint16(59142), + 1: uint16(59143), + 2: uint16(59144), + 3: uint16(59145), + 4: uint16(59146), + 5: uint16(59147), + 6: uint16(59148), + 7: uint16(59149), + 8: uint16(59150), + 9: uint16(59151), + 10: uint16(59152), + 11: uint16(59153), + 12: uint16(59154), + 13: uint16(59155), + 14: uint16(59156), + 15: uint16(59157), + 16: uint16(59158), + 17: uint16(59159), + 18: uint16(59160), + 19: uint16(59161), + 20: uint16(59162), + 21: uint16(59163), + 22: uint16(59164), + 23: uint16(59165), + 24: uint16(59166), + 25: uint16(59167), + 26: uint16(59168), + 27: uint16(59169), + 28: uint16(59170), + 29: uint16(59171), + 30: uint16(59172), + 31: uint16(59173), + 32: uint16(59174), + 33: uint16(59175), + 34: uint16(59176), + 35: uint16(59177), + 36: uint16(59178), + 37: uint16(59179), + 38: uint16(59180), + 39: uint16(59181), + 40: uint16(59182), + 41: uint16(59183), + 42: uint16(59184), + 43: uint16(59185), + 44: uint16(59186), + 45: uint16(59187), + 46: uint16(59188), + 47: uint16(59189), + 48: uint16(59190), + 49: uint16(59191), + 50: uint16(59192), + 51: uint16(59193), + 52: uint16(59194), + 53: uint16(59195), + 54: uint16(59196), + 55: uint16(59197), + 56: uint16(59198), + 57: uint16(59199), + 58: uint16(59200), + 59: uint16(59201), + 60: uint16(59202), + 61: uint16(59203), + 62: uint16(59204), + 63: uint16(59205), + 64: uint16(59206), + 65: uint16(59207), + 66: uint16(59208), + 67: uint16(59209), + 68: uint16(59210), + 69: uint16(59211), + 70: uint16(59212), + 71: uint16(59213), + 72: uint16(59214), + 73: uint16(59215), + 74: uint16(59216), + 75: uint16(59217), + 76: uint16(59218), + 77: uint16(59219), + 78: uint16(59220), + 79: uint16(59221), + 80: uint16(59222), + 81: uint16(59223), + 82: uint16(59224), + 83: uint16(59225), + 84: uint16(59226), + 85: uint16(59227), + 86: uint16(59228), + 87: uint16(59229), + 88: uint16(59230), + 89: uint16(59231), + 90: uint16(59232), + 91: uint16(59233), + 92: uint16(59234), + 93: uint16(59235), + 94: uint16(59236), + 95: uint16(59237), + 96: uint16(1040), + 97: uint16(1041), + 98: uint16(1042), + 99: uint16(1043), + 100: uint16(1044), + 101: uint16(1045), + 102: uint16(1025), + 103: uint16(1046), + 104: uint16(1047), + 105: uint16(1048), + 106: uint16(1049), + 107: uint16(1050), + 108: uint16(1051), + 109: uint16(1052), + 110: uint16(1053), + 111: uint16(1054), + 112: uint16(1055), + 113: uint16(1056), + 114: uint16(1057), + 115: uint16(1058), + 116: uint16(1059), + 117: uint16(1060), + 118: uint16(1061), + 119: uint16(1062), + 120: uint16(1063), + 121: uint16(1064), + 122: uint16(1065), + 123: uint16(1066), + 124: uint16(1067), + 125: uint16(1068), + 126: uint16(1069), + 127: uint16(1070), + 128: uint16(1071), + 129: uint16(59296), + 130: uint16(59297), + 131: uint16(59298), + 132: uint16(59299), + 133: uint16(59300), + 134: uint16(59301), + 135: uint16(59302), + 136: uint16(59303), + 137: uint16(59304), + 138: uint16(59305), + 139: uint16(59306), + 140: uint16(59307), + 141: uint16(59308), + 142: uint16(59309), + 143: uint16(59310), + 144: uint16(1072), + 145: uint16(1073), + 146: uint16(1074), + 147: uint16(1075), + 148: uint16(1076), + 149: uint16(1077), + 150: uint16(1105), + 151: uint16(1078), + 152: uint16(1079), + 153: uint16(1080), + 154: uint16(1081), + 155: uint16(1082), + 156: uint16(1083), + 157: uint16(1084), + 158: uint16(1085), + 159: uint16(1086), + 160: uint16(1087), + 161: uint16(1088), + 162: uint16(1089), + 163: uint16(1090), + 164: uint16(1091), + 165: uint16(1092), + 166: uint16(1093), + 167: uint16(1094), + 168: uint16(1095), + 169: uint16(1096), + 170: uint16(1097), + 171: uint16(1098), + 172: uint16(1099), + 173: uint16(1100), + 174: uint16(1101), + 175: uint16(1102), + 176: uint16(1103), + 177: uint16(59311), + 178: uint16(59312), + 179: uint16(59313), + 180: uint16(59314), + 181: uint16(59315), + 182: uint16(59316), + 183: uint16(59317), + 184: uint16(59318), + 185: uint16(59319), + 186: uint16(59320), + 187: uint16(59321), + 188: uint16(59322), + 189: uint16(59323), + }, + 39: { + 0: uint16(714), + 1: uint16(715), + 2: uint16(729), + 3: uint16(8211), + 4: uint16(8213), + 5: uint16(8229), + 6: uint16(8245), + 7: uint16(8453), + 8: uint16(8457), + 9: uint16(8598), + 10: uint16(8599), + 11: uint16(8600), + 12: uint16(8601), + 13: uint16(8725), + 14: uint16(8735), + 15: uint16(8739), + 16: uint16(8786), + 17: uint16(8806), + 18: uint16(8807), + 19: uint16(8895), + 20: uint16(9552), + 21: uint16(9553), + 22: uint16(9554), + 23: uint16(9555), + 24: uint16(9556), + 25: uint16(9557), + 26: uint16(9558), + 27: uint16(9559), + 28: uint16(9560), + 29: uint16(9561), + 30: uint16(9562), + 31: uint16(9563), + 32: uint16(9564), + 33: uint16(9565), + 34: uint16(9566), + 35: uint16(9567), + 36: uint16(9568), + 37: uint16(9569), + 38: uint16(9570), + 39: uint16(9571), + 40: uint16(9572), + 41: uint16(9573), + 42: uint16(9574), + 43: uint16(9575), + 44: uint16(9576), + 45: uint16(9577), + 46: uint16(9578), + 47: uint16(9579), + 48: uint16(9580), + 49: uint16(9581), + 50: uint16(9582), + 51: uint16(9583), + 52: uint16(9584), + 53: uint16(9585), + 54: uint16(9586), + 55: uint16(9587), + 56: uint16(9601), + 57: uint16(9602), + 58: uint16(9603), + 59: uint16(9604), + 60: uint16(9605), + 61: uint16(9606), + 62: uint16(9607), + 63: uint16(9608), + 64: uint16(9609), + 65: uint16(9610), + 66: uint16(9611), + 67: uint16(9612), + 68: uint16(9613), + 69: uint16(9614), + 70: uint16(9615), + 71: uint16(9619), + 72: uint16(9620), + 73: uint16(9621), + 74: uint16(9660), + 75: uint16(9661), + 76: uint16(9698), + 77: uint16(9699), + 78: uint16(9700), + 79: uint16(9701), + 80: uint16(9737), + 81: uint16(8853), + 82: uint16(12306), + 83: uint16(12317), + 84: uint16(12318), + 85: uint16(59324), + 86: uint16(59325), + 87: uint16(59326), + 88: uint16(59327), + 89: uint16(59328), + 90: uint16(59329), + 91: uint16(59330), + 92: uint16(59331), + 93: uint16(59332), + 94: uint16(59333), + 95: uint16(59334), + 96: uint16(257), + 97: uint16(225), + 98: uint16(462), + 99: uint16(224), + 100: uint16(275), + 101: uint16(233), + 102: uint16(283), + 103: uint16(232), + 104: uint16(299), + 105: uint16(237), + 106: uint16(464), + 107: uint16(236), + 108: uint16(333), + 109: uint16(243), + 110: uint16(466), + 111: uint16(242), + 112: uint16(363), + 113: uint16(250), + 114: uint16(468), + 115: uint16(249), + 116: uint16(470), + 117: uint16(472), + 118: uint16(474), + 119: uint16(476), + 120: uint16(252), + 121: uint16(234), + 122: uint16(593), + 123: uint16(59335), + 124: uint16(324), + 125: uint16(328), + 126: uint16(505), + 127: uint16(609), + 128: uint16(59337), + 129: uint16(59338), + 130: uint16(59339), + 131: uint16(59340), + 132: uint16(12549), + 133: uint16(12550), + 134: uint16(12551), + 135: uint16(12552), + 136: uint16(12553), + 137: uint16(12554), + 138: uint16(12555), + 139: uint16(12556), + 140: uint16(12557), + 141: uint16(12558), + 142: uint16(12559), + 143: uint16(12560), + 144: uint16(12561), + 145: uint16(12562), + 146: uint16(12563), + 147: uint16(12564), + 148: uint16(12565), + 149: uint16(12566), + 150: uint16(12567), + 151: uint16(12568), + 152: uint16(12569), + 153: uint16(12570), + 154: uint16(12571), + 155: uint16(12572), + 156: uint16(12573), + 157: uint16(12574), + 158: uint16(12575), + 159: uint16(12576), + 160: uint16(12577), + 161: uint16(12578), + 162: uint16(12579), + 163: uint16(12580), + 164: uint16(12581), + 165: uint16(12582), + 166: uint16(12583), + 167: uint16(12584), + 168: uint16(12585), + 169: uint16(59341), + 170: uint16(59342), + 171: uint16(59343), + 172: uint16(59344), + 173: uint16(59345), + 174: uint16(59346), + 175: uint16(59347), + 176: uint16(59348), + 177: uint16(59349), + 178: uint16(59350), + 179: uint16(59351), + 180: uint16(59352), + 181: uint16(59353), + 182: uint16(59354), + 183: uint16(59355), + 184: uint16(59356), + 185: uint16(59357), + 186: uint16(59358), + 187: uint16(59359), + 188: uint16(59360), + 189: uint16(59361), + }, + 40: { + 0: uint16(12321), + 1: uint16(12322), + 2: uint16(12323), + 3: uint16(12324), + 4: uint16(12325), + 5: uint16(12326), + 6: uint16(12327), + 7: uint16(12328), + 8: uint16(12329), + 9: uint16(12963), + 10: uint16(13198), + 11: uint16(13199), + 12: uint16(13212), + 13: uint16(13213), + 14: uint16(13214), + 15: uint16(13217), + 16: uint16(13252), + 17: uint16(13262), + 18: uint16(13265), + 19: uint16(13266), + 20: uint16(13269), + 21: uint16(65072), + 22: uint16(65506), + 23: uint16(65508), + 24: uint16(59362), + 25: uint16(8481), + 26: uint16(12849), + 27: uint16(59363), + 28: uint16(8208), + 29: uint16(59364), + 30: uint16(59365), + 31: uint16(59366), + 32: uint16(12540), + 33: uint16(12443), + 34: uint16(12444), + 35: uint16(12541), + 36: uint16(12542), + 37: uint16(12294), + 38: uint16(12445), + 39: uint16(12446), + 40: uint16(65097), + 41: uint16(65098), + 42: uint16(65099), + 43: uint16(65100), + 44: uint16(65101), + 45: uint16(65102), + 46: uint16(65103), + 47: uint16(65104), + 48: uint16(65105), + 49: uint16(65106), + 50: uint16(65108), + 51: uint16(65109), + 52: uint16(65110), + 53: uint16(65111), + 54: uint16(65113), + 55: uint16(65114), + 56: uint16(65115), + 57: uint16(65116), + 58: uint16(65117), + 59: uint16(65118), + 60: uint16(65119), + 61: uint16(65120), + 62: uint16(65121), + 63: uint16(65122), + 64: uint16(65123), + 65: uint16(65124), + 66: uint16(65125), + 67: uint16(65126), + 68: uint16(65128), + 69: uint16(65129), + 70: uint16(65130), + 71: uint16(65131), + 72: uint16(12350), + 73: uint16(12272), + 74: uint16(12273), + 75: uint16(12274), + 76: uint16(12275), + 77: uint16(12276), + 78: uint16(12277), + 79: uint16(12278), + 80: uint16(12279), + 81: uint16(12280), + 82: uint16(12281), + 83: uint16(12282), + 84: uint16(12283), + 85: uint16(12295), + 86: uint16(59380), + 87: uint16(59381), + 88: uint16(59382), + 89: uint16(59383), + 90: uint16(59384), + 91: uint16(59385), + 92: uint16(59386), + 93: uint16(59387), + 94: uint16(59388), + 95: uint16(59389), + 96: uint16(59390), + 97: uint16(59391), + 98: uint16(59392), + 99: uint16(9472), + 100: uint16(9473), + 101: uint16(9474), + 102: uint16(9475), + 103: uint16(9476), + 104: uint16(9477), + 105: uint16(9478), + 106: uint16(9479), + 107: uint16(9480), + 108: uint16(9481), + 109: uint16(9482), + 110: uint16(9483), + 111: uint16(9484), + 112: uint16(9485), + 113: uint16(9486), + 114: uint16(9487), + 115: uint16(9488), + 116: uint16(9489), + 117: uint16(9490), + 118: uint16(9491), + 119: uint16(9492), + 120: uint16(9493), + 121: uint16(9494), + 122: uint16(9495), + 123: uint16(9496), + 124: uint16(9497), + 125: uint16(9498), + 126: uint16(9499), + 127: uint16(9500), + 128: uint16(9501), + 129: uint16(9502), + 130: uint16(9503), + 131: uint16(9504), + 132: uint16(9505), + 133: uint16(9506), + 134: uint16(9507), + 135: uint16(9508), + 136: uint16(9509), + 137: uint16(9510), + 138: uint16(9511), + 139: uint16(9512), + 140: uint16(9513), + 141: uint16(9514), + 142: uint16(9515), + 143: uint16(9516), + 144: uint16(9517), + 145: uint16(9518), + 146: uint16(9519), + 147: uint16(9520), + 148: uint16(9521), + 149: uint16(9522), + 150: uint16(9523), + 151: uint16(9524), + 152: uint16(9525), + 153: uint16(9526), + 154: uint16(9527), + 155: uint16(9528), + 156: uint16(9529), + 157: uint16(9530), + 158: uint16(9531), + 159: uint16(9532), + 160: uint16(9533), + 161: uint16(9534), + 162: uint16(9535), + 163: uint16(9536), + 164: uint16(9537), + 165: uint16(9538), + 166: uint16(9539), + 167: uint16(9540), + 168: uint16(9541), + 169: uint16(9542), + 170: uint16(9543), + 171: uint16(9544), + 172: uint16(9545), + 173: uint16(9546), + 174: uint16(9547), + 175: uint16(59393), + 176: uint16(59394), + 177: uint16(59395), + 178: uint16(59396), + 179: uint16(59397), + 180: uint16(59398), + 181: uint16(59399), + 182: uint16(59400), + 183: uint16(59401), + 184: uint16(59402), + 185: uint16(59403), + 186: uint16(59404), + 187: uint16(59405), + 188: uint16(59406), + 189: uint16(59407), + }, + 41: { + 0: uint16(29404), + 1: uint16(29405), + 2: uint16(29407), + 3: uint16(29410), + 4: uint16(29411), + 5: uint16(29412), + 6: uint16(29413), + 7: uint16(29414), + 8: uint16(29415), + 9: uint16(29418), + 10: uint16(29419), + 11: uint16(29429), + 12: uint16(29430), + 13: uint16(29433), + 14: uint16(29437), + 15: uint16(29438), + 16: uint16(29439), + 17: uint16(29440), + 18: uint16(29442), + 19: uint16(29444), + 20: uint16(29445), + 21: uint16(29446), + 22: uint16(29447), + 23: uint16(29448), + 24: uint16(29449), + 25: uint16(29451), + 26: uint16(29452), + 27: uint16(29453), + 28: uint16(29455), + 29: uint16(29456), + 30: uint16(29457), + 31: uint16(29458), + 32: uint16(29460), + 33: uint16(29464), + 34: uint16(29465), + 35: uint16(29466), + 36: uint16(29471), + 37: uint16(29472), + 38: uint16(29475), + 39: uint16(29476), + 40: uint16(29478), + 41: uint16(29479), + 42: uint16(29480), + 43: uint16(29485), + 44: uint16(29487), + 45: uint16(29488), + 46: uint16(29490), + 47: uint16(29491), + 48: uint16(29493), + 49: uint16(29494), + 50: uint16(29498), + 51: uint16(29499), + 52: uint16(29500), + 53: uint16(29501), + 54: uint16(29504), + 55: uint16(29505), + 56: uint16(29506), + 57: uint16(29507), + 58: uint16(29508), + 59: uint16(29509), + 60: uint16(29510), + 61: uint16(29511), + 62: uint16(29512), + 63: uint16(29513), + 64: uint16(29514), + 65: uint16(29515), + 66: uint16(29516), + 67: uint16(29518), + 68: uint16(29519), + 69: uint16(29521), + 70: uint16(29523), + 71: uint16(29524), + 72: uint16(29525), + 73: uint16(29526), + 74: uint16(29528), + 75: uint16(29529), + 76: uint16(29530), + 77: uint16(29531), + 78: uint16(29532), + 79: uint16(29533), + 80: uint16(29534), + 81: uint16(29535), + 82: uint16(29537), + 83: uint16(29538), + 84: uint16(29539), + 85: uint16(29540), + 86: uint16(29541), + 87: uint16(29542), + 88: uint16(29543), + 89: uint16(29544), + 90: uint16(29545), + 91: uint16(29546), + 92: uint16(29547), + 93: uint16(29550), + 94: uint16(29552), + 95: uint16(29553), + 96: uint16(57344), + 97: uint16(57345), + 98: uint16(57346), + 99: uint16(57347), + 100: uint16(57348), + 101: uint16(57349), + 102: uint16(57350), + 103: uint16(57351), + 104: uint16(57352), + 105: uint16(57353), + 106: uint16(57354), + 107: uint16(57355), + 108: uint16(57356), + 109: uint16(57357), + 110: uint16(57358), + 111: uint16(57359), + 112: uint16(57360), + 113: uint16(57361), + 114: uint16(57362), + 115: uint16(57363), + 116: uint16(57364), + 117: uint16(57365), + 118: uint16(57366), + 119: uint16(57367), + 120: uint16(57368), + 121: uint16(57369), + 122: uint16(57370), + 123: uint16(57371), + 124: uint16(57372), + 125: uint16(57373), + 126: uint16(57374), + 127: uint16(57375), + 128: uint16(57376), + 129: uint16(57377), + 130: uint16(57378), + 131: uint16(57379), + 132: uint16(57380), + 133: uint16(57381), + 134: uint16(57382), + 135: uint16(57383), + 136: uint16(57384), + 137: uint16(57385), + 138: uint16(57386), + 139: uint16(57387), + 140: uint16(57388), + 141: uint16(57389), + 142: uint16(57390), + 143: uint16(57391), + 144: uint16(57392), + 145: uint16(57393), + 146: uint16(57394), + 147: uint16(57395), + 148: uint16(57396), + 149: uint16(57397), + 150: uint16(57398), + 151: uint16(57399), + 152: uint16(57400), + 153: uint16(57401), + 154: uint16(57402), + 155: uint16(57403), + 156: uint16(57404), + 157: uint16(57405), + 158: uint16(57406), + 159: uint16(57407), + 160: uint16(57408), + 161: uint16(57409), + 162: uint16(57410), + 163: uint16(57411), + 164: uint16(57412), + 165: uint16(57413), + 166: uint16(57414), + 167: uint16(57415), + 168: uint16(57416), + 169: uint16(57417), + 170: uint16(57418), + 171: uint16(57419), + 172: uint16(57420), + 173: uint16(57421), + 174: uint16(57422), + 175: uint16(57423), + 176: uint16(57424), + 177: uint16(57425), + 178: uint16(57426), + 179: uint16(57427), + 180: uint16(57428), + 181: uint16(57429), + 182: uint16(57430), + 183: uint16(57431), + 184: uint16(57432), + 185: uint16(57433), + 186: uint16(57434), + 187: uint16(57435), + 188: uint16(57436), + 189: uint16(57437), + }, + 42: { + 0: uint16(29554), + 1: uint16(29555), + 2: uint16(29556), + 3: uint16(29557), + 4: uint16(29558), + 5: uint16(29559), + 6: uint16(29560), + 7: uint16(29561), + 8: uint16(29562), + 9: uint16(29563), + 10: uint16(29564), + 11: uint16(29565), + 12: uint16(29567), + 13: uint16(29568), + 14: uint16(29569), + 15: uint16(29570), + 16: uint16(29571), + 17: uint16(29573), + 18: uint16(29574), + 19: uint16(29576), + 20: uint16(29578), + 21: uint16(29580), + 22: uint16(29581), + 23: uint16(29583), + 24: uint16(29584), + 25: uint16(29586), + 26: uint16(29587), + 27: uint16(29588), + 28: uint16(29589), + 29: uint16(29591), + 30: uint16(29592), + 31: uint16(29593), + 32: uint16(29594), + 33: uint16(29596), + 34: uint16(29597), + 35: uint16(29598), + 36: uint16(29600), + 37: uint16(29601), + 38: uint16(29603), + 39: uint16(29604), + 40: uint16(29605), + 41: uint16(29606), + 42: uint16(29607), + 43: uint16(29608), + 44: uint16(29610), + 45: uint16(29612), + 46: uint16(29613), + 47: uint16(29617), + 48: uint16(29620), + 49: uint16(29621), + 50: uint16(29622), + 51: uint16(29624), + 52: uint16(29625), + 53: uint16(29628), + 54: uint16(29629), + 55: uint16(29630), + 56: uint16(29631), + 57: uint16(29633), + 58: uint16(29635), + 59: uint16(29636), + 60: uint16(29637), + 61: uint16(29638), + 62: uint16(29639), + 63: uint16(29643), + 64: uint16(29644), + 65: uint16(29646), + 66: uint16(29650), + 67: uint16(29651), + 68: uint16(29652), + 69: uint16(29653), + 70: uint16(29654), + 71: uint16(29655), + 72: uint16(29656), + 73: uint16(29658), + 74: uint16(29659), + 75: uint16(29660), + 76: uint16(29661), + 77: uint16(29663), + 78: uint16(29665), + 79: uint16(29666), + 80: uint16(29667), + 81: uint16(29668), + 82: uint16(29670), + 83: uint16(29672), + 84: uint16(29674), + 85: uint16(29675), + 86: uint16(29676), + 87: uint16(29678), + 88: uint16(29679), + 89: uint16(29680), + 90: uint16(29681), + 91: uint16(29683), + 92: uint16(29684), + 93: uint16(29685), + 94: uint16(29686), + 95: uint16(29687), + 96: uint16(57438), + 97: uint16(57439), + 98: uint16(57440), + 99: uint16(57441), + 100: uint16(57442), + 101: uint16(57443), + 102: uint16(57444), + 103: uint16(57445), + 104: uint16(57446), + 105: uint16(57447), + 106: uint16(57448), + 107: uint16(57449), + 108: uint16(57450), + 109: uint16(57451), + 110: uint16(57452), + 111: uint16(57453), + 112: uint16(57454), + 113: uint16(57455), + 114: uint16(57456), + 115: uint16(57457), + 116: uint16(57458), + 117: uint16(57459), + 118: uint16(57460), + 119: uint16(57461), + 120: uint16(57462), + 121: uint16(57463), + 122: uint16(57464), + 123: uint16(57465), + 124: uint16(57466), + 125: uint16(57467), + 126: uint16(57468), + 127: uint16(57469), + 128: uint16(57470), + 129: uint16(57471), + 130: uint16(57472), + 131: uint16(57473), + 132: uint16(57474), + 133: uint16(57475), + 134: uint16(57476), + 135: uint16(57477), + 136: uint16(57478), + 137: uint16(57479), + 138: uint16(57480), + 139: uint16(57481), + 140: uint16(57482), + 141: uint16(57483), + 142: uint16(57484), + 143: uint16(57485), + 144: uint16(57486), + 145: uint16(57487), + 146: uint16(57488), + 147: uint16(57489), + 148: uint16(57490), + 149: uint16(57491), + 150: uint16(57492), + 151: uint16(57493), + 152: uint16(57494), + 153: uint16(57495), + 154: uint16(57496), + 155: uint16(57497), + 156: uint16(57498), + 157: uint16(57499), + 158: uint16(57500), + 159: uint16(57501), + 160: uint16(57502), + 161: uint16(57503), + 162: uint16(57504), + 163: uint16(57505), + 164: uint16(57506), + 165: uint16(57507), + 166: uint16(57508), + 167: uint16(57509), + 168: uint16(57510), + 169: uint16(57511), + 170: uint16(57512), + 171: uint16(57513), + 172: uint16(57514), + 173: uint16(57515), + 174: uint16(57516), + 175: uint16(57517), + 176: uint16(57518), + 177: uint16(57519), + 178: uint16(57520), + 179: uint16(57521), + 180: uint16(57522), + 181: uint16(57523), + 182: uint16(57524), + 183: uint16(57525), + 184: uint16(57526), + 185: uint16(57527), + 186: uint16(57528), + 187: uint16(57529), + 188: uint16(57530), + 189: uint16(57531), + }, + 43: { + 0: uint16(29688), + 1: uint16(29689), + 2: uint16(29690), + 3: uint16(29691), + 4: uint16(29692), + 5: uint16(29693), + 6: uint16(29694), + 7: uint16(29695), + 8: uint16(29696), + 9: uint16(29697), + 10: uint16(29698), + 11: uint16(29700), + 12: uint16(29703), + 13: uint16(29704), + 14: uint16(29707), + 15: uint16(29708), + 16: uint16(29709), + 17: uint16(29710), + 18: uint16(29713), + 19: uint16(29714), + 20: uint16(29715), + 21: uint16(29716), + 22: uint16(29717), + 23: uint16(29718), + 24: uint16(29719), + 25: uint16(29720), + 26: uint16(29721), + 27: uint16(29724), + 28: uint16(29725), + 29: uint16(29726), + 30: uint16(29727), + 31: uint16(29728), + 32: uint16(29729), + 33: uint16(29731), + 34: uint16(29732), + 35: uint16(29735), + 36: uint16(29737), + 37: uint16(29739), + 38: uint16(29741), + 39: uint16(29743), + 40: uint16(29745), + 41: uint16(29746), + 42: uint16(29751), + 43: uint16(29752), + 44: uint16(29753), + 45: uint16(29754), + 46: uint16(29755), + 47: uint16(29757), + 48: uint16(29758), + 49: uint16(29759), + 50: uint16(29760), + 51: uint16(29762), + 52: uint16(29763), + 53: uint16(29764), + 54: uint16(29765), + 55: uint16(29766), + 56: uint16(29767), + 57: uint16(29768), + 58: uint16(29769), + 59: uint16(29770), + 60: uint16(29771), + 61: uint16(29772), + 62: uint16(29773), + 63: uint16(29774), + 64: uint16(29775), + 65: uint16(29776), + 66: uint16(29777), + 67: uint16(29778), + 68: uint16(29779), + 69: uint16(29780), + 70: uint16(29782), + 71: uint16(29784), + 72: uint16(29789), + 73: uint16(29792), + 74: uint16(29793), + 75: uint16(29794), + 76: uint16(29795), + 77: uint16(29796), + 78: uint16(29797), + 79: uint16(29798), + 80: uint16(29799), + 81: uint16(29800), + 82: uint16(29801), + 83: uint16(29802), + 84: uint16(29803), + 85: uint16(29804), + 86: uint16(29806), + 87: uint16(29807), + 88: uint16(29809), + 89: uint16(29810), + 90: uint16(29811), + 91: uint16(29812), + 92: uint16(29813), + 93: uint16(29816), + 94: uint16(29817), + 95: uint16(29818), + 96: uint16(57532), + 97: uint16(57533), + 98: uint16(57534), + 99: uint16(57535), + 100: uint16(57536), + 101: uint16(57537), + 102: uint16(57538), + 103: uint16(57539), + 104: uint16(57540), + 105: uint16(57541), + 106: uint16(57542), + 107: uint16(57543), + 108: uint16(57544), + 109: uint16(57545), + 110: uint16(57546), + 111: uint16(57547), + 112: uint16(57548), + 113: uint16(57549), + 114: uint16(57550), + 115: uint16(57551), + 116: uint16(57552), + 117: uint16(57553), + 118: uint16(57554), + 119: uint16(57555), + 120: uint16(57556), + 121: uint16(57557), + 122: uint16(57558), + 123: uint16(57559), + 124: uint16(57560), + 125: uint16(57561), + 126: uint16(57562), + 127: uint16(57563), + 128: uint16(57564), + 129: uint16(57565), + 130: uint16(57566), + 131: uint16(57567), + 132: uint16(57568), + 133: uint16(57569), + 134: uint16(57570), + 135: uint16(57571), + 136: uint16(57572), + 137: uint16(57573), + 138: uint16(57574), + 139: uint16(57575), + 140: uint16(57576), + 141: uint16(57577), + 142: uint16(57578), + 143: uint16(57579), + 144: uint16(57580), + 145: uint16(57581), + 146: uint16(57582), + 147: uint16(57583), + 148: uint16(57584), + 149: uint16(57585), + 150: uint16(57586), + 151: uint16(57587), + 152: uint16(57588), + 153: uint16(57589), + 154: uint16(57590), + 155: uint16(57591), + 156: uint16(57592), + 157: uint16(57593), + 158: uint16(57594), + 159: uint16(57595), + 160: uint16(57596), + 161: uint16(57597), + 162: uint16(57598), + 163: uint16(57599), + 164: uint16(57600), + 165: uint16(57601), + 166: uint16(57602), + 167: uint16(57603), + 168: uint16(57604), + 169: uint16(57605), + 170: uint16(57606), + 171: uint16(57607), + 172: uint16(57608), + 173: uint16(57609), + 174: uint16(57610), + 175: uint16(57611), + 176: uint16(57612), + 177: uint16(57613), + 178: uint16(57614), + 179: uint16(57615), + 180: uint16(57616), + 181: uint16(57617), + 182: uint16(57618), + 183: uint16(57619), + 184: uint16(57620), + 185: uint16(57621), + 186: uint16(57622), + 187: uint16(57623), + 188: uint16(57624), + 189: uint16(57625), + }, + 44: { + 0: uint16(29819), + 1: uint16(29820), + 2: uint16(29821), + 3: uint16(29823), + 4: uint16(29826), + 5: uint16(29828), + 6: uint16(29829), + 7: uint16(29830), + 8: uint16(29832), + 9: uint16(29833), + 10: uint16(29834), + 11: uint16(29836), + 12: uint16(29837), + 13: uint16(29839), + 14: uint16(29841), + 15: uint16(29842), + 16: uint16(29843), + 17: uint16(29844), + 18: uint16(29845), + 19: uint16(29846), + 20: uint16(29847), + 21: uint16(29848), + 22: uint16(29849), + 23: uint16(29850), + 24: uint16(29851), + 25: uint16(29853), + 26: uint16(29855), + 27: uint16(29856), + 28: uint16(29857), + 29: uint16(29858), + 30: uint16(29859), + 31: uint16(29860), + 32: uint16(29861), + 33: uint16(29862), + 34: uint16(29866), + 35: uint16(29867), + 36: uint16(29868), + 37: uint16(29869), + 38: uint16(29870), + 39: uint16(29871), + 40: uint16(29872), + 41: uint16(29873), + 42: uint16(29874), + 43: uint16(29875), + 44: uint16(29876), + 45: uint16(29877), + 46: uint16(29878), + 47: uint16(29879), + 48: uint16(29880), + 49: uint16(29881), + 50: uint16(29883), + 51: uint16(29884), + 52: uint16(29885), + 53: uint16(29886), + 54: uint16(29887), + 55: uint16(29888), + 56: uint16(29889), + 57: uint16(29890), + 58: uint16(29891), + 59: uint16(29892), + 60: uint16(29893), + 61: uint16(29894), + 62: uint16(29895), + 63: uint16(29896), + 64: uint16(29897), + 65: uint16(29898), + 66: uint16(29899), + 67: uint16(29900), + 68: uint16(29901), + 69: uint16(29902), + 70: uint16(29903), + 71: uint16(29904), + 72: uint16(29905), + 73: uint16(29907), + 74: uint16(29908), + 75: uint16(29909), + 76: uint16(29910), + 77: uint16(29911), + 78: uint16(29912), + 79: uint16(29913), + 80: uint16(29914), + 81: uint16(29915), + 82: uint16(29917), + 83: uint16(29919), + 84: uint16(29921), + 85: uint16(29925), + 86: uint16(29927), + 87: uint16(29928), + 88: uint16(29929), + 89: uint16(29930), + 90: uint16(29931), + 91: uint16(29932), + 92: uint16(29933), + 93: uint16(29936), + 94: uint16(29937), + 95: uint16(29938), + 96: uint16(57626), + 97: uint16(57627), + 98: uint16(57628), + 99: uint16(57629), + 100: uint16(57630), + 101: uint16(57631), + 102: uint16(57632), + 103: uint16(57633), + 104: uint16(57634), + 105: uint16(57635), + 106: uint16(57636), + 107: uint16(57637), + 108: uint16(57638), + 109: uint16(57639), + 110: uint16(57640), + 111: uint16(57641), + 112: uint16(57642), + 113: uint16(57643), + 114: uint16(57644), + 115: uint16(57645), + 116: uint16(57646), + 117: uint16(57647), + 118: uint16(57648), + 119: uint16(57649), + 120: uint16(57650), + 121: uint16(57651), + 122: uint16(57652), + 123: uint16(57653), + 124: uint16(57654), + 125: uint16(57655), + 126: uint16(57656), + 127: uint16(57657), + 128: uint16(57658), + 129: uint16(57659), + 130: uint16(57660), + 131: uint16(57661), + 132: uint16(57662), + 133: uint16(57663), + 134: uint16(57664), + 135: uint16(57665), + 136: uint16(57666), + 137: uint16(57667), + 138: uint16(57668), + 139: uint16(57669), + 140: uint16(57670), + 141: uint16(57671), + 142: uint16(57672), + 143: uint16(57673), + 144: uint16(57674), + 145: uint16(57675), + 146: uint16(57676), + 147: uint16(57677), + 148: uint16(57678), + 149: uint16(57679), + 150: uint16(57680), + 151: uint16(57681), + 152: uint16(57682), + 153: uint16(57683), + 154: uint16(57684), + 155: uint16(57685), + 156: uint16(57686), + 157: uint16(57687), + 158: uint16(57688), + 159: uint16(57689), + 160: uint16(57690), + 161: uint16(57691), + 162: uint16(57692), + 163: uint16(57693), + 164: uint16(57694), + 165: uint16(57695), + 166: uint16(57696), + 167: uint16(57697), + 168: uint16(57698), + 169: uint16(57699), + 170: uint16(57700), + 171: uint16(57701), + 172: uint16(57702), + 173: uint16(57703), + 174: uint16(57704), + 175: uint16(57705), + 176: uint16(57706), + 177: uint16(57707), + 178: uint16(57708), + 179: uint16(57709), + 180: uint16(57710), + 181: uint16(57711), + 182: uint16(57712), + 183: uint16(57713), + 184: uint16(57714), + 185: uint16(57715), + 186: uint16(57716), + 187: uint16(57717), + 188: uint16(57718), + 189: uint16(57719), + }, + 45: { + 0: uint16(29939), + 1: uint16(29941), + 2: uint16(29944), + 3: uint16(29945), + 4: uint16(29946), + 5: uint16(29947), + 6: uint16(29948), + 7: uint16(29949), + 8: uint16(29950), + 9: uint16(29952), + 10: uint16(29953), + 11: uint16(29954), + 12: uint16(29955), + 13: uint16(29957), + 14: uint16(29958), + 15: uint16(29959), + 16: uint16(29960), + 17: uint16(29961), + 18: uint16(29962), + 19: uint16(29963), + 20: uint16(29964), + 21: uint16(29966), + 22: uint16(29968), + 23: uint16(29970), + 24: uint16(29972), + 25: uint16(29973), + 26: uint16(29974), + 27: uint16(29975), + 28: uint16(29979), + 29: uint16(29981), + 30: uint16(29982), + 31: uint16(29984), + 32: uint16(29985), + 33: uint16(29986), + 34: uint16(29987), + 35: uint16(29988), + 36: uint16(29990), + 37: uint16(29991), + 38: uint16(29994), + 39: uint16(29998), + 40: uint16(30004), + 41: uint16(30006), + 42: uint16(30009), + 43: uint16(30012), + 44: uint16(30013), + 45: uint16(30015), + 46: uint16(30017), + 47: uint16(30018), + 48: uint16(30019), + 49: uint16(30020), + 50: uint16(30022), + 51: uint16(30023), + 52: uint16(30025), + 53: uint16(30026), + 54: uint16(30029), + 55: uint16(30032), + 56: uint16(30033), + 57: uint16(30034), + 58: uint16(30035), + 59: uint16(30037), + 60: uint16(30038), + 61: uint16(30039), + 62: uint16(30040), + 63: uint16(30045), + 64: uint16(30046), + 65: uint16(30047), + 66: uint16(30048), + 67: uint16(30049), + 68: uint16(30050), + 69: uint16(30051), + 70: uint16(30052), + 71: uint16(30055), + 72: uint16(30056), + 73: uint16(30057), + 74: uint16(30059), + 75: uint16(30060), + 76: uint16(30061), + 77: uint16(30062), + 78: uint16(30063), + 79: uint16(30064), + 80: uint16(30065), + 81: uint16(30067), + 82: uint16(30069), + 83: uint16(30070), + 84: uint16(30071), + 85: uint16(30074), + 86: uint16(30075), + 87: uint16(30076), + 88: uint16(30077), + 89: uint16(30078), + 90: uint16(30080), + 91: uint16(30081), + 92: uint16(30082), + 93: uint16(30084), + 94: uint16(30085), + 95: uint16(30087), + 96: uint16(57720), + 97: uint16(57721), + 98: uint16(57722), + 99: uint16(57723), + 100: uint16(57724), + 101: uint16(57725), + 102: uint16(57726), + 103: uint16(57727), + 104: uint16(57728), + 105: uint16(57729), + 106: uint16(57730), + 107: uint16(57731), + 108: uint16(57732), + 109: uint16(57733), + 110: uint16(57734), + 111: uint16(57735), + 112: uint16(57736), + 113: uint16(57737), + 114: uint16(57738), + 115: uint16(57739), + 116: uint16(57740), + 117: uint16(57741), + 118: uint16(57742), + 119: uint16(57743), + 120: uint16(57744), + 121: uint16(57745), + 122: uint16(57746), + 123: uint16(57747), + 124: uint16(57748), + 125: uint16(57749), + 126: uint16(57750), + 127: uint16(57751), + 128: uint16(57752), + 129: uint16(57753), + 130: uint16(57754), + 131: uint16(57755), + 132: uint16(57756), + 133: uint16(57757), + 134: uint16(57758), + 135: uint16(57759), + 136: uint16(57760), + 137: uint16(57761), + 138: uint16(57762), + 139: uint16(57763), + 140: uint16(57764), + 141: uint16(57765), + 142: uint16(57766), + 143: uint16(57767), + 144: uint16(57768), + 145: uint16(57769), + 146: uint16(57770), + 147: uint16(57771), + 148: uint16(57772), + 149: uint16(57773), + 150: uint16(57774), + 151: uint16(57775), + 152: uint16(57776), + 153: uint16(57777), + 154: uint16(57778), + 155: uint16(57779), + 156: uint16(57780), + 157: uint16(57781), + 158: uint16(57782), + 159: uint16(57783), + 160: uint16(57784), + 161: uint16(57785), + 162: uint16(57786), + 163: uint16(57787), + 164: uint16(57788), + 165: uint16(57789), + 166: uint16(57790), + 167: uint16(57791), + 168: uint16(57792), + 169: uint16(57793), + 170: uint16(57794), + 171: uint16(57795), + 172: uint16(57796), + 173: uint16(57797), + 174: uint16(57798), + 175: uint16(57799), + 176: uint16(57800), + 177: uint16(57801), + 178: uint16(57802), + 179: uint16(57803), + 180: uint16(57804), + 181: uint16(57805), + 182: uint16(57806), + 183: uint16(57807), + 184: uint16(57808), + 185: uint16(57809), + 186: uint16(57810), + 187: uint16(57811), + 188: uint16(57812), + 189: uint16(57813), + }, + 46: { + 0: uint16(30088), + 1: uint16(30089), + 2: uint16(30090), + 3: uint16(30092), + 4: uint16(30093), + 5: uint16(30094), + 6: uint16(30096), + 7: uint16(30099), + 8: uint16(30101), + 9: uint16(30104), + 10: uint16(30107), + 11: uint16(30108), + 12: uint16(30110), + 13: uint16(30114), + 14: uint16(30118), + 15: uint16(30119), + 16: uint16(30120), + 17: uint16(30121), + 18: uint16(30122), + 19: uint16(30125), + 20: uint16(30134), + 21: uint16(30135), + 22: uint16(30138), + 23: uint16(30139), + 24: uint16(30143), + 25: uint16(30144), + 26: uint16(30145), + 27: uint16(30150), + 28: uint16(30155), + 29: uint16(30156), + 30: uint16(30158), + 31: uint16(30159), + 32: uint16(30160), + 33: uint16(30161), + 34: uint16(30163), + 35: uint16(30167), + 36: uint16(30169), + 37: uint16(30170), + 38: uint16(30172), + 39: uint16(30173), + 40: uint16(30175), + 41: uint16(30176), + 42: uint16(30177), + 43: uint16(30181), + 44: uint16(30185), + 45: uint16(30188), + 46: uint16(30189), + 47: uint16(30190), + 48: uint16(30191), + 49: uint16(30194), + 50: uint16(30195), + 51: uint16(30197), + 52: uint16(30198), + 53: uint16(30199), + 54: uint16(30200), + 55: uint16(30202), + 56: uint16(30203), + 57: uint16(30205), + 58: uint16(30206), + 59: uint16(30210), + 60: uint16(30212), + 61: uint16(30214), + 62: uint16(30215), + 63: uint16(30216), + 64: uint16(30217), + 65: uint16(30219), + 66: uint16(30221), + 67: uint16(30222), + 68: uint16(30223), + 69: uint16(30225), + 70: uint16(30226), + 71: uint16(30227), + 72: uint16(30228), + 73: uint16(30230), + 74: uint16(30234), + 75: uint16(30236), + 76: uint16(30237), + 77: uint16(30238), + 78: uint16(30241), + 79: uint16(30243), + 80: uint16(30247), + 81: uint16(30248), + 82: uint16(30252), + 83: uint16(30254), + 84: uint16(30255), + 85: uint16(30257), + 86: uint16(30258), + 87: uint16(30262), + 88: uint16(30263), + 89: uint16(30265), + 90: uint16(30266), + 91: uint16(30267), + 92: uint16(30269), + 93: uint16(30273), + 94: uint16(30274), + 95: uint16(30276), + 96: uint16(57814), + 97: uint16(57815), + 98: uint16(57816), + 99: uint16(57817), + 100: uint16(57818), + 101: uint16(57819), + 102: uint16(57820), + 103: uint16(57821), + 104: uint16(57822), + 105: uint16(57823), + 106: uint16(57824), + 107: uint16(57825), + 108: uint16(57826), + 109: uint16(57827), + 110: uint16(57828), + 111: uint16(57829), + 112: uint16(57830), + 113: uint16(57831), + 114: uint16(57832), + 115: uint16(57833), + 116: uint16(57834), + 117: uint16(57835), + 118: uint16(57836), + 119: uint16(57837), + 120: uint16(57838), + 121: uint16(57839), + 122: uint16(57840), + 123: uint16(57841), + 124: uint16(57842), + 125: uint16(57843), + 126: uint16(57844), + 127: uint16(57845), + 128: uint16(57846), + 129: uint16(57847), + 130: uint16(57848), + 131: uint16(57849), + 132: uint16(57850), + 133: uint16(57851), + 134: uint16(57852), + 135: uint16(57853), + 136: uint16(57854), + 137: uint16(57855), + 138: uint16(57856), + 139: uint16(57857), + 140: uint16(57858), + 141: uint16(57859), + 142: uint16(57860), + 143: uint16(57861), + 144: uint16(57862), + 145: uint16(57863), + 146: uint16(57864), + 147: uint16(57865), + 148: uint16(57866), + 149: uint16(57867), + 150: uint16(57868), + 151: uint16(57869), + 152: uint16(57870), + 153: uint16(57871), + 154: uint16(57872), + 155: uint16(57873), + 156: uint16(57874), + 157: uint16(57875), + 158: uint16(57876), + 159: uint16(57877), + 160: uint16(57878), + 161: uint16(57879), + 162: uint16(57880), + 163: uint16(57881), + 164: uint16(57882), + 165: uint16(57883), + 166: uint16(57884), + 167: uint16(57885), + 168: uint16(57886), + 169: uint16(57887), + 170: uint16(57888), + 171: uint16(57889), + 172: uint16(57890), + 173: uint16(57891), + 174: uint16(57892), + 175: uint16(57893), + 176: uint16(57894), + 177: uint16(57895), + 178: uint16(57896), + 179: uint16(57897), + 180: uint16(57898), + 181: uint16(57899), + 182: uint16(57900), + 183: uint16(57901), + 184: uint16(57902), + 185: uint16(57903), + 186: uint16(57904), + 187: uint16(57905), + 188: uint16(57906), + 189: uint16(57907), + }, + 47: { + 0: uint16(30277), + 1: uint16(30278), + 2: uint16(30279), + 3: uint16(30280), + 4: uint16(30281), + 5: uint16(30282), + 6: uint16(30283), + 7: uint16(30286), + 8: uint16(30287), + 9: uint16(30288), + 10: uint16(30289), + 11: uint16(30290), + 12: uint16(30291), + 13: uint16(30293), + 14: uint16(30295), + 15: uint16(30296), + 16: uint16(30297), + 17: uint16(30298), + 18: uint16(30299), + 19: uint16(30301), + 20: uint16(30303), + 21: uint16(30304), + 22: uint16(30305), + 23: uint16(30306), + 24: uint16(30308), + 25: uint16(30309), + 26: uint16(30310), + 27: uint16(30311), + 28: uint16(30312), + 29: uint16(30313), + 30: uint16(30314), + 31: uint16(30316), + 32: uint16(30317), + 33: uint16(30318), + 34: uint16(30320), + 35: uint16(30321), + 36: uint16(30322), + 37: uint16(30323), + 38: uint16(30324), + 39: uint16(30325), + 40: uint16(30326), + 41: uint16(30327), + 42: uint16(30329), + 43: uint16(30330), + 44: uint16(30332), + 45: uint16(30335), + 46: uint16(30336), + 47: uint16(30337), + 48: uint16(30339), + 49: uint16(30341), + 50: uint16(30345), + 51: uint16(30346), + 52: uint16(30348), + 53: uint16(30349), + 54: uint16(30351), + 55: uint16(30352), + 56: uint16(30354), + 57: uint16(30356), + 58: uint16(30357), + 59: uint16(30359), + 60: uint16(30360), + 61: uint16(30362), + 62: uint16(30363), + 63: uint16(30364), + 64: uint16(30365), + 65: uint16(30366), + 66: uint16(30367), + 67: uint16(30368), + 68: uint16(30369), + 69: uint16(30370), + 70: uint16(30371), + 71: uint16(30373), + 72: uint16(30374), + 73: uint16(30375), + 74: uint16(30376), + 75: uint16(30377), + 76: uint16(30378), + 77: uint16(30379), + 78: uint16(30380), + 79: uint16(30381), + 80: uint16(30383), + 81: uint16(30384), + 82: uint16(30387), + 83: uint16(30389), + 84: uint16(30390), + 85: uint16(30391), + 86: uint16(30392), + 87: uint16(30393), + 88: uint16(30394), + 89: uint16(30395), + 90: uint16(30396), + 91: uint16(30397), + 92: uint16(30398), + 93: uint16(30400), + 94: uint16(30401), + 95: uint16(30403), + 96: uint16(21834), + 97: uint16(38463), + 98: uint16(22467), + 99: uint16(25384), + 100: uint16(21710), + 101: uint16(21769), + 102: uint16(21696), + 103: uint16(30353), + 104: uint16(30284), + 105: uint16(34108), + 106: uint16(30702), + 107: uint16(33406), + 108: uint16(30861), + 109: uint16(29233), + 110: uint16(38552), + 111: uint16(38797), + 112: uint16(27688), + 113: uint16(23433), + 114: uint16(20474), + 115: uint16(25353), + 116: uint16(26263), + 117: uint16(23736), + 118: uint16(33018), + 119: uint16(26696), + 120: uint16(32942), + 121: uint16(26114), + 122: uint16(30414), + 123: uint16(20985), + 124: uint16(25942), + 125: uint16(29100), + 126: uint16(32753), + 127: uint16(34948), + 128: uint16(20658), + 129: uint16(22885), + 130: uint16(25034), + 131: uint16(28595), + 132: uint16(33453), + 133: uint16(25420), + 134: uint16(25170), + 135: uint16(21485), + 136: uint16(21543), + 137: uint16(31494), + 138: uint16(20843), + 139: uint16(30116), + 140: uint16(24052), + 141: uint16(25300), + 142: uint16(36299), + 143: uint16(38774), + 144: uint16(25226), + 145: uint16(32793), + 146: uint16(22365), + 147: uint16(38712), + 148: uint16(32610), + 149: uint16(29240), + 150: uint16(30333), + 151: uint16(26575), + 152: uint16(30334), + 153: uint16(25670), + 154: uint16(20336), + 155: uint16(36133), + 156: uint16(25308), + 157: uint16(31255), + 158: uint16(26001), + 159: uint16(29677), + 160: uint16(25644), + 161: uint16(25203), + 162: uint16(33324), + 163: uint16(39041), + 164: uint16(26495), + 165: uint16(29256), + 166: uint16(25198), + 167: uint16(25292), + 168: uint16(20276), + 169: uint16(29923), + 170: uint16(21322), + 171: uint16(21150), + 172: uint16(32458), + 173: uint16(37030), + 174: uint16(24110), + 175: uint16(26758), + 176: uint16(27036), + 177: uint16(33152), + 178: uint16(32465), + 179: uint16(26834), + 180: uint16(30917), + 181: uint16(34444), + 182: uint16(38225), + 183: uint16(20621), + 184: uint16(35876), + 185: uint16(33502), + 186: uint16(32990), + 187: uint16(21253), + 188: uint16(35090), + 189: uint16(21093), + }, + 48: { + 0: uint16(30404), + 1: uint16(30407), + 2: uint16(30409), + 3: uint16(30411), + 4: uint16(30412), + 5: uint16(30419), + 6: uint16(30421), + 7: uint16(30425), + 8: uint16(30426), + 9: uint16(30428), + 10: uint16(30429), + 11: uint16(30430), + 12: uint16(30432), + 13: uint16(30433), + 14: uint16(30434), + 15: uint16(30435), + 16: uint16(30436), + 17: uint16(30438), + 18: uint16(30439), + 19: uint16(30440), + 20: uint16(30441), + 21: uint16(30442), + 22: uint16(30443), + 23: uint16(30444), + 24: uint16(30445), + 25: uint16(30448), + 26: uint16(30451), + 27: uint16(30453), + 28: uint16(30454), + 29: uint16(30455), + 30: uint16(30458), + 31: uint16(30459), + 32: uint16(30461), + 33: uint16(30463), + 34: uint16(30464), + 35: uint16(30466), + 36: uint16(30467), + 37: uint16(30469), + 38: uint16(30470), + 39: uint16(30474), + 40: uint16(30476), + 41: uint16(30478), + 42: uint16(30479), + 43: uint16(30480), + 44: uint16(30481), + 45: uint16(30482), + 46: uint16(30483), + 47: uint16(30484), + 48: uint16(30485), + 49: uint16(30486), + 50: uint16(30487), + 51: uint16(30488), + 52: uint16(30491), + 53: uint16(30492), + 54: uint16(30493), + 55: uint16(30494), + 56: uint16(30497), + 57: uint16(30499), + 58: uint16(30500), + 59: uint16(30501), + 60: uint16(30503), + 61: uint16(30506), + 62: uint16(30507), + 63: uint16(30508), + 64: uint16(30510), + 65: uint16(30512), + 66: uint16(30513), + 67: uint16(30514), + 68: uint16(30515), + 69: uint16(30516), + 70: uint16(30521), + 71: uint16(30523), + 72: uint16(30525), + 73: uint16(30526), + 74: uint16(30527), + 75: uint16(30530), + 76: uint16(30532), + 77: uint16(30533), + 78: uint16(30534), + 79: uint16(30536), + 80: uint16(30537), + 81: uint16(30538), + 82: uint16(30539), + 83: uint16(30540), + 84: uint16(30541), + 85: uint16(30542), + 86: uint16(30543), + 87: uint16(30546), + 88: uint16(30547), + 89: uint16(30548), + 90: uint16(30549), + 91: uint16(30550), + 92: uint16(30551), + 93: uint16(30552), + 94: uint16(30553), + 95: uint16(30556), + 96: uint16(34180), + 97: uint16(38649), + 98: uint16(20445), + 99: uint16(22561), + 100: uint16(39281), + 101: uint16(23453), + 102: uint16(25265), + 103: uint16(25253), + 104: uint16(26292), + 105: uint16(35961), + 106: uint16(40077), + 107: uint16(29190), + 108: uint16(26479), + 109: uint16(30865), + 110: uint16(24754), + 111: uint16(21329), + 112: uint16(21271), + 113: uint16(36744), + 114: uint16(32972), + 115: uint16(36125), + 116: uint16(38049), + 117: uint16(20493), + 118: uint16(29384), + 119: uint16(22791), + 120: uint16(24811), + 121: uint16(28953), + 122: uint16(34987), + 123: uint16(22868), + 124: uint16(33519), + 125: uint16(26412), + 126: uint16(31528), + 127: uint16(23849), + 128: uint16(32503), + 129: uint16(29997), + 130: uint16(27893), + 131: uint16(36454), + 132: uint16(36856), + 133: uint16(36924), + 134: uint16(40763), + 135: uint16(27604), + 136: uint16(37145), + 137: uint16(31508), + 138: uint16(24444), + 139: uint16(30887), + 140: uint16(34006), + 141: uint16(34109), + 142: uint16(27605), + 143: uint16(27609), + 144: uint16(27606), + 145: uint16(24065), + 146: uint16(24199), + 147: uint16(30201), + 148: uint16(38381), + 149: uint16(25949), + 150: uint16(24330), + 151: uint16(24517), + 152: uint16(36767), + 153: uint16(22721), + 154: uint16(33218), + 155: uint16(36991), + 156: uint16(38491), + 157: uint16(38829), + 158: uint16(36793), + 159: uint16(32534), + 160: uint16(36140), + 161: uint16(25153), + 162: uint16(20415), + 163: uint16(21464), + 164: uint16(21342), + 165: uint16(36776), + 166: uint16(36777), + 167: uint16(36779), + 168: uint16(36941), + 169: uint16(26631), + 170: uint16(24426), + 171: uint16(33176), + 172: uint16(34920), + 173: uint16(40150), + 174: uint16(24971), + 175: uint16(21035), + 176: uint16(30250), + 177: uint16(24428), + 178: uint16(25996), + 179: uint16(28626), + 180: uint16(28392), + 181: uint16(23486), + 182: uint16(25672), + 183: uint16(20853), + 184: uint16(20912), + 185: uint16(26564), + 186: uint16(19993), + 187: uint16(31177), + 188: uint16(39292), + 189: uint16(28851), + }, + 49: { + 0: uint16(30557), + 1: uint16(30558), + 2: uint16(30559), + 3: uint16(30560), + 4: uint16(30564), + 5: uint16(30567), + 6: uint16(30569), + 7: uint16(30570), + 8: uint16(30573), + 9: uint16(30574), + 10: uint16(30575), + 11: uint16(30576), + 12: uint16(30577), + 13: uint16(30578), + 14: uint16(30579), + 15: uint16(30580), + 16: uint16(30581), + 17: uint16(30582), + 18: uint16(30583), + 19: uint16(30584), + 20: uint16(30586), + 21: uint16(30587), + 22: uint16(30588), + 23: uint16(30593), + 24: uint16(30594), + 25: uint16(30595), + 26: uint16(30598), + 27: uint16(30599), + 28: uint16(30600), + 29: uint16(30601), + 30: uint16(30602), + 31: uint16(30603), + 32: uint16(30607), + 33: uint16(30608), + 34: uint16(30611), + 35: uint16(30612), + 36: uint16(30613), + 37: uint16(30614), + 38: uint16(30615), + 39: uint16(30616), + 40: uint16(30617), + 41: uint16(30618), + 42: uint16(30619), + 43: uint16(30620), + 44: uint16(30621), + 45: uint16(30622), + 46: uint16(30625), + 47: uint16(30627), + 48: uint16(30628), + 49: uint16(30630), + 50: uint16(30632), + 51: uint16(30635), + 52: uint16(30637), + 53: uint16(30638), + 54: uint16(30639), + 55: uint16(30641), + 56: uint16(30642), + 57: uint16(30644), + 58: uint16(30646), + 59: uint16(30647), + 60: uint16(30648), + 61: uint16(30649), + 62: uint16(30650), + 63: uint16(30652), + 64: uint16(30654), + 65: uint16(30656), + 66: uint16(30657), + 67: uint16(30658), + 68: uint16(30659), + 69: uint16(30660), + 70: uint16(30661), + 71: uint16(30662), + 72: uint16(30663), + 73: uint16(30664), + 74: uint16(30665), + 75: uint16(30666), + 76: uint16(30667), + 77: uint16(30668), + 78: uint16(30670), + 79: uint16(30671), + 80: uint16(30672), + 81: uint16(30673), + 82: uint16(30674), + 83: uint16(30675), + 84: uint16(30676), + 85: uint16(30677), + 86: uint16(30678), + 87: uint16(30680), + 88: uint16(30681), + 89: uint16(30682), + 90: uint16(30685), + 91: uint16(30686), + 92: uint16(30687), + 93: uint16(30688), + 94: uint16(30689), + 95: uint16(30692), + 96: uint16(30149), + 97: uint16(24182), + 98: uint16(29627), + 99: uint16(33760), + 100: uint16(25773), + 101: uint16(25320), + 102: uint16(38069), + 103: uint16(27874), + 104: uint16(21338), + 105: uint16(21187), + 106: uint16(25615), + 107: uint16(38082), + 108: uint16(31636), + 109: uint16(20271), + 110: uint16(24091), + 111: uint16(33334), + 112: uint16(33046), + 113: uint16(33162), + 114: uint16(28196), + 115: uint16(27850), + 116: uint16(39539), + 117: uint16(25429), + 118: uint16(21340), + 119: uint16(21754), + 120: uint16(34917), + 121: uint16(22496), + 122: uint16(19981), + 123: uint16(24067), + 124: uint16(27493), + 125: uint16(31807), + 126: uint16(37096), + 127: uint16(24598), + 128: uint16(25830), + 129: uint16(29468), + 130: uint16(35009), + 131: uint16(26448), + 132: uint16(25165), + 133: uint16(36130), + 134: uint16(30572), + 135: uint16(36393), + 136: uint16(37319), + 137: uint16(24425), + 138: uint16(33756), + 139: uint16(34081), + 140: uint16(39184), + 141: uint16(21442), + 142: uint16(34453), + 143: uint16(27531), + 144: uint16(24813), + 145: uint16(24808), + 146: uint16(28799), + 147: uint16(33485), + 148: uint16(33329), + 149: uint16(20179), + 150: uint16(27815), + 151: uint16(34255), + 152: uint16(25805), + 153: uint16(31961), + 154: uint16(27133), + 155: uint16(26361), + 156: uint16(33609), + 157: uint16(21397), + 158: uint16(31574), + 159: uint16(20391), + 160: uint16(20876), + 161: uint16(27979), + 162: uint16(23618), + 163: uint16(36461), + 164: uint16(25554), + 165: uint16(21449), + 166: uint16(33580), + 167: uint16(33590), + 168: uint16(26597), + 169: uint16(30900), + 170: uint16(25661), + 171: uint16(23519), + 172: uint16(23700), + 173: uint16(24046), + 174: uint16(35815), + 175: uint16(25286), + 176: uint16(26612), + 177: uint16(35962), + 178: uint16(25600), + 179: uint16(25530), + 180: uint16(34633), + 181: uint16(39307), + 182: uint16(35863), + 183: uint16(32544), + 184: uint16(38130), + 185: uint16(20135), + 186: uint16(38416), + 187: uint16(39076), + 188: uint16(26124), + 189: uint16(29462), + }, + 50: { + 0: uint16(30694), + 1: uint16(30696), + 2: uint16(30698), + 3: uint16(30703), + 4: uint16(30704), + 5: uint16(30705), + 6: uint16(30706), + 7: uint16(30708), + 8: uint16(30709), + 9: uint16(30711), + 10: uint16(30713), + 11: uint16(30714), + 12: uint16(30715), + 13: uint16(30716), + 14: uint16(30723), + 15: uint16(30724), + 16: uint16(30725), + 17: uint16(30726), + 18: uint16(30727), + 19: uint16(30728), + 20: uint16(30730), + 21: uint16(30731), + 22: uint16(30734), + 23: uint16(30735), + 24: uint16(30736), + 25: uint16(30739), + 26: uint16(30741), + 27: uint16(30745), + 28: uint16(30747), + 29: uint16(30750), + 30: uint16(30752), + 31: uint16(30753), + 32: uint16(30754), + 33: uint16(30756), + 34: uint16(30760), + 35: uint16(30762), + 36: uint16(30763), + 37: uint16(30766), + 38: uint16(30767), + 39: uint16(30769), + 40: uint16(30770), + 41: uint16(30771), + 42: uint16(30773), + 43: uint16(30774), + 44: uint16(30781), + 45: uint16(30783), + 46: uint16(30785), + 47: uint16(30786), + 48: uint16(30787), + 49: uint16(30788), + 50: uint16(30790), + 51: uint16(30792), + 52: uint16(30793), + 53: uint16(30794), + 54: uint16(30795), + 55: uint16(30797), + 56: uint16(30799), + 57: uint16(30801), + 58: uint16(30803), + 59: uint16(30804), + 60: uint16(30808), + 61: uint16(30809), + 62: uint16(30810), + 63: uint16(30811), + 64: uint16(30812), + 65: uint16(30814), + 66: uint16(30815), + 67: uint16(30816), + 68: uint16(30817), + 69: uint16(30818), + 70: uint16(30819), + 71: uint16(30820), + 72: uint16(30821), + 73: uint16(30822), + 74: uint16(30823), + 75: uint16(30824), + 76: uint16(30825), + 77: uint16(30831), + 78: uint16(30832), + 79: uint16(30833), + 80: uint16(30834), + 81: uint16(30835), + 82: uint16(30836), + 83: uint16(30837), + 84: uint16(30838), + 85: uint16(30840), + 86: uint16(30841), + 87: uint16(30842), + 88: uint16(30843), + 89: uint16(30845), + 90: uint16(30846), + 91: uint16(30847), + 92: uint16(30848), + 93: uint16(30849), + 94: uint16(30850), + 95: uint16(30851), + 96: uint16(22330), + 97: uint16(23581), + 98: uint16(24120), + 99: uint16(38271), + 100: uint16(20607), + 101: uint16(32928), + 102: uint16(21378), + 103: uint16(25950), + 104: uint16(30021), + 105: uint16(21809), + 106: uint16(20513), + 107: uint16(36229), + 108: uint16(25220), + 109: uint16(38046), + 110: uint16(26397), + 111: uint16(22066), + 112: uint16(28526), + 113: uint16(24034), + 114: uint16(21557), + 115: uint16(28818), + 116: uint16(36710), + 117: uint16(25199), + 118: uint16(25764), + 119: uint16(25507), + 120: uint16(24443), + 121: uint16(28552), + 122: uint16(37108), + 123: uint16(33251), + 124: uint16(36784), + 125: uint16(23576), + 126: uint16(26216), + 127: uint16(24561), + 128: uint16(27785), + 129: uint16(38472), + 130: uint16(36225), + 131: uint16(34924), + 132: uint16(25745), + 133: uint16(31216), + 134: uint16(22478), + 135: uint16(27225), + 136: uint16(25104), + 137: uint16(21576), + 138: uint16(20056), + 139: uint16(31243), + 140: uint16(24809), + 141: uint16(28548), + 142: uint16(35802), + 143: uint16(25215), + 144: uint16(36894), + 145: uint16(39563), + 146: uint16(31204), + 147: uint16(21507), + 148: uint16(30196), + 149: uint16(25345), + 150: uint16(21273), + 151: uint16(27744), + 152: uint16(36831), + 153: uint16(24347), + 154: uint16(39536), + 155: uint16(32827), + 156: uint16(40831), + 157: uint16(20360), + 158: uint16(23610), + 159: uint16(36196), + 160: uint16(32709), + 161: uint16(26021), + 162: uint16(28861), + 163: uint16(20805), + 164: uint16(20914), + 165: uint16(34411), + 166: uint16(23815), + 167: uint16(23456), + 168: uint16(25277), + 169: uint16(37228), + 170: uint16(30068), + 171: uint16(36364), + 172: uint16(31264), + 173: uint16(24833), + 174: uint16(31609), + 175: uint16(20167), + 176: uint16(32504), + 177: uint16(30597), + 178: uint16(19985), + 179: uint16(33261), + 180: uint16(21021), + 181: uint16(20986), + 182: uint16(27249), + 183: uint16(21416), + 184: uint16(36487), + 185: uint16(38148), + 186: uint16(38607), + 187: uint16(28353), + 188: uint16(38500), + 189: uint16(26970), + }, + 51: { + 0: uint16(30852), + 1: uint16(30853), + 2: uint16(30854), + 3: uint16(30856), + 4: uint16(30858), + 5: uint16(30859), + 6: uint16(30863), + 7: uint16(30864), + 8: uint16(30866), + 9: uint16(30868), + 10: uint16(30869), + 11: uint16(30870), + 12: uint16(30873), + 13: uint16(30877), + 14: uint16(30878), + 15: uint16(30880), + 16: uint16(30882), + 17: uint16(30884), + 18: uint16(30886), + 19: uint16(30888), + 20: uint16(30889), + 21: uint16(30890), + 22: uint16(30891), + 23: uint16(30892), + 24: uint16(30893), + 25: uint16(30894), + 26: uint16(30895), + 27: uint16(30901), + 28: uint16(30902), + 29: uint16(30903), + 30: uint16(30904), + 31: uint16(30906), + 32: uint16(30907), + 33: uint16(30908), + 34: uint16(30909), + 35: uint16(30911), + 36: uint16(30912), + 37: uint16(30914), + 38: uint16(30915), + 39: uint16(30916), + 40: uint16(30918), + 41: uint16(30919), + 42: uint16(30920), + 43: uint16(30924), + 44: uint16(30925), + 45: uint16(30926), + 46: uint16(30927), + 47: uint16(30929), + 48: uint16(30930), + 49: uint16(30931), + 50: uint16(30934), + 51: uint16(30935), + 52: uint16(30936), + 53: uint16(30938), + 54: uint16(30939), + 55: uint16(30940), + 56: uint16(30941), + 57: uint16(30942), + 58: uint16(30943), + 59: uint16(30944), + 60: uint16(30945), + 61: uint16(30946), + 62: uint16(30947), + 63: uint16(30948), + 64: uint16(30949), + 65: uint16(30950), + 66: uint16(30951), + 67: uint16(30953), + 68: uint16(30954), + 69: uint16(30955), + 70: uint16(30957), + 71: uint16(30958), + 72: uint16(30959), + 73: uint16(30960), + 74: uint16(30961), + 75: uint16(30963), + 76: uint16(30965), + 77: uint16(30966), + 78: uint16(30968), + 79: uint16(30969), + 80: uint16(30971), + 81: uint16(30972), + 82: uint16(30973), + 83: uint16(30974), + 84: uint16(30975), + 85: uint16(30976), + 86: uint16(30978), + 87: uint16(30979), + 88: uint16(30980), + 89: uint16(30982), + 90: uint16(30983), + 91: uint16(30984), + 92: uint16(30985), + 93: uint16(30986), + 94: uint16(30987), + 95: uint16(30988), + 96: uint16(30784), + 97: uint16(20648), + 98: uint16(30679), + 99: uint16(25616), + 100: uint16(35302), + 101: uint16(22788), + 102: uint16(25571), + 103: uint16(24029), + 104: uint16(31359), + 105: uint16(26941), + 106: uint16(20256), + 107: uint16(33337), + 108: uint16(21912), + 109: uint16(20018), + 110: uint16(30126), + 111: uint16(31383), + 112: uint16(24162), + 113: uint16(24202), + 114: uint16(38383), + 115: uint16(21019), + 116: uint16(21561), + 117: uint16(28810), + 118: uint16(25462), + 119: uint16(38180), + 120: uint16(22402), + 121: uint16(26149), + 122: uint16(26943), + 123: uint16(37255), + 124: uint16(21767), + 125: uint16(28147), + 126: uint16(32431), + 127: uint16(34850), + 128: uint16(25139), + 129: uint16(32496), + 130: uint16(30133), + 131: uint16(33576), + 132: uint16(30913), + 133: uint16(38604), + 134: uint16(36766), + 135: uint16(24904), + 136: uint16(29943), + 137: uint16(35789), + 138: uint16(27492), + 139: uint16(21050), + 140: uint16(36176), + 141: uint16(27425), + 142: uint16(32874), + 143: uint16(33905), + 144: uint16(22257), + 145: uint16(21254), + 146: uint16(20174), + 147: uint16(19995), + 148: uint16(20945), + 149: uint16(31895), + 150: uint16(37259), + 151: uint16(31751), + 152: uint16(20419), + 153: uint16(36479), + 154: uint16(31713), + 155: uint16(31388), + 156: uint16(25703), + 157: uint16(23828), + 158: uint16(20652), + 159: uint16(33030), + 160: uint16(30209), + 161: uint16(31929), + 162: uint16(28140), + 163: uint16(32736), + 164: uint16(26449), + 165: uint16(23384), + 166: uint16(23544), + 167: uint16(30923), + 168: uint16(25774), + 169: uint16(25619), + 170: uint16(25514), + 171: uint16(25387), + 172: uint16(38169), + 173: uint16(25645), + 174: uint16(36798), + 175: uint16(31572), + 176: uint16(30249), + 177: uint16(25171), + 178: uint16(22823), + 179: uint16(21574), + 180: uint16(27513), + 181: uint16(20643), + 182: uint16(25140), + 183: uint16(24102), + 184: uint16(27526), + 185: uint16(20195), + 186: uint16(36151), + 187: uint16(34955), + 188: uint16(24453), + 189: uint16(36910), + }, + 52: { + 0: uint16(30989), + 1: uint16(30990), + 2: uint16(30991), + 3: uint16(30992), + 4: uint16(30993), + 5: uint16(30994), + 6: uint16(30996), + 7: uint16(30997), + 8: uint16(30998), + 9: uint16(30999), + 10: uint16(31000), + 11: uint16(31001), + 12: uint16(31002), + 13: uint16(31003), + 14: uint16(31004), + 15: uint16(31005), + 16: uint16(31007), + 17: uint16(31008), + 18: uint16(31009), + 19: uint16(31010), + 20: uint16(31011), + 21: uint16(31013), + 22: uint16(31014), + 23: uint16(31015), + 24: uint16(31016), + 25: uint16(31017), + 26: uint16(31018), + 27: uint16(31019), + 28: uint16(31020), + 29: uint16(31021), + 30: uint16(31022), + 31: uint16(31023), + 32: uint16(31024), + 33: uint16(31025), + 34: uint16(31026), + 35: uint16(31027), + 36: uint16(31029), + 37: uint16(31030), + 38: uint16(31031), + 39: uint16(31032), + 40: uint16(31033), + 41: uint16(31037), + 42: uint16(31039), + 43: uint16(31042), + 44: uint16(31043), + 45: uint16(31044), + 46: uint16(31045), + 47: uint16(31047), + 48: uint16(31050), + 49: uint16(31051), + 50: uint16(31052), + 51: uint16(31053), + 52: uint16(31054), + 53: uint16(31055), + 54: uint16(31056), + 55: uint16(31057), + 56: uint16(31058), + 57: uint16(31060), + 58: uint16(31061), + 59: uint16(31064), + 60: uint16(31065), + 61: uint16(31073), + 62: uint16(31075), + 63: uint16(31076), + 64: uint16(31078), + 65: uint16(31081), + 66: uint16(31082), + 67: uint16(31083), + 68: uint16(31084), + 69: uint16(31086), + 70: uint16(31088), + 71: uint16(31089), + 72: uint16(31090), + 73: uint16(31091), + 74: uint16(31092), + 75: uint16(31093), + 76: uint16(31094), + 77: uint16(31097), + 78: uint16(31099), + 79: uint16(31100), + 80: uint16(31101), + 81: uint16(31102), + 82: uint16(31103), + 83: uint16(31106), + 84: uint16(31107), + 85: uint16(31110), + 86: uint16(31111), + 87: uint16(31112), + 88: uint16(31113), + 89: uint16(31115), + 90: uint16(31116), + 91: uint16(31117), + 92: uint16(31118), + 93: uint16(31120), + 94: uint16(31121), + 95: uint16(31122), + 96: uint16(24608), + 97: uint16(32829), + 98: uint16(25285), + 99: uint16(20025), + 100: uint16(21333), + 101: uint16(37112), + 102: uint16(25528), + 103: uint16(32966), + 104: uint16(26086), + 105: uint16(27694), + 106: uint16(20294), + 107: uint16(24814), + 108: uint16(28129), + 109: uint16(35806), + 110: uint16(24377), + 111: uint16(34507), + 112: uint16(24403), + 113: uint16(25377), + 114: uint16(20826), + 115: uint16(33633), + 116: uint16(26723), + 117: uint16(20992), + 118: uint16(25443), + 119: uint16(36424), + 120: uint16(20498), + 121: uint16(23707), + 122: uint16(31095), + 123: uint16(23548), + 124: uint16(21040), + 125: uint16(31291), + 126: uint16(24764), + 127: uint16(36947), + 128: uint16(30423), + 129: uint16(24503), + 130: uint16(24471), + 131: uint16(30340), + 132: uint16(36460), + 133: uint16(28783), + 134: uint16(30331), + 135: uint16(31561), + 136: uint16(30634), + 137: uint16(20979), + 138: uint16(37011), + 139: uint16(22564), + 140: uint16(20302), + 141: uint16(28404), + 142: uint16(36842), + 143: uint16(25932), + 144: uint16(31515), + 145: uint16(29380), + 146: uint16(28068), + 147: uint16(32735), + 148: uint16(23265), + 149: uint16(25269), + 150: uint16(24213), + 151: uint16(22320), + 152: uint16(33922), + 153: uint16(31532), + 154: uint16(24093), + 155: uint16(24351), + 156: uint16(36882), + 157: uint16(32532), + 158: uint16(39072), + 159: uint16(25474), + 160: uint16(28359), + 161: uint16(30872), + 162: uint16(28857), + 163: uint16(20856), + 164: uint16(38747), + 165: uint16(22443), + 166: uint16(30005), + 167: uint16(20291), + 168: uint16(30008), + 169: uint16(24215), + 170: uint16(24806), + 171: uint16(22880), + 172: uint16(28096), + 173: uint16(27583), + 174: uint16(30857), + 175: uint16(21500), + 176: uint16(38613), + 177: uint16(20939), + 178: uint16(20993), + 179: uint16(25481), + 180: uint16(21514), + 181: uint16(38035), + 182: uint16(35843), + 183: uint16(36300), + 184: uint16(29241), + 185: uint16(30879), + 186: uint16(34678), + 187: uint16(36845), + 188: uint16(35853), + 189: uint16(21472), + }, + 53: { + 0: uint16(31123), + 1: uint16(31124), + 2: uint16(31125), + 3: uint16(31126), + 4: uint16(31127), + 5: uint16(31128), + 6: uint16(31129), + 7: uint16(31131), + 8: uint16(31132), + 9: uint16(31133), + 10: uint16(31134), + 11: uint16(31135), + 12: uint16(31136), + 13: uint16(31137), + 14: uint16(31138), + 15: uint16(31139), + 16: uint16(31140), + 17: uint16(31141), + 18: uint16(31142), + 19: uint16(31144), + 20: uint16(31145), + 21: uint16(31146), + 22: uint16(31147), + 23: uint16(31148), + 24: uint16(31149), + 25: uint16(31150), + 26: uint16(31151), + 27: uint16(31152), + 28: uint16(31153), + 29: uint16(31154), + 30: uint16(31156), + 31: uint16(31157), + 32: uint16(31158), + 33: uint16(31159), + 34: uint16(31160), + 35: uint16(31164), + 36: uint16(31167), + 37: uint16(31170), + 38: uint16(31172), + 39: uint16(31173), + 40: uint16(31175), + 41: uint16(31176), + 42: uint16(31178), + 43: uint16(31180), + 44: uint16(31182), + 45: uint16(31183), + 46: uint16(31184), + 47: uint16(31187), + 48: uint16(31188), + 49: uint16(31190), + 50: uint16(31191), + 51: uint16(31193), + 52: uint16(31194), + 53: uint16(31195), + 54: uint16(31196), + 55: uint16(31197), + 56: uint16(31198), + 57: uint16(31200), + 58: uint16(31201), + 59: uint16(31202), + 60: uint16(31205), + 61: uint16(31208), + 62: uint16(31210), + 63: uint16(31212), + 64: uint16(31214), + 65: uint16(31217), + 66: uint16(31218), + 67: uint16(31219), + 68: uint16(31220), + 69: uint16(31221), + 70: uint16(31222), + 71: uint16(31223), + 72: uint16(31225), + 73: uint16(31226), + 74: uint16(31228), + 75: uint16(31230), + 76: uint16(31231), + 77: uint16(31233), + 78: uint16(31236), + 79: uint16(31237), + 80: uint16(31239), + 81: uint16(31240), + 82: uint16(31241), + 83: uint16(31242), + 84: uint16(31244), + 85: uint16(31247), + 86: uint16(31248), + 87: uint16(31249), + 88: uint16(31250), + 89: uint16(31251), + 90: uint16(31253), + 91: uint16(31254), + 92: uint16(31256), + 93: uint16(31257), + 94: uint16(31259), + 95: uint16(31260), + 96: uint16(19969), + 97: uint16(30447), + 98: uint16(21486), + 99: uint16(38025), + 100: uint16(39030), + 101: uint16(40718), + 102: uint16(38189), + 103: uint16(23450), + 104: uint16(35746), + 105: uint16(20002), + 106: uint16(19996), + 107: uint16(20908), + 108: uint16(33891), + 109: uint16(25026), + 110: uint16(21160), + 111: uint16(26635), + 112: uint16(20375), + 113: uint16(24683), + 114: uint16(20923), + 115: uint16(27934), + 116: uint16(20828), + 117: uint16(25238), + 118: uint16(26007), + 119: uint16(38497), + 120: uint16(35910), + 121: uint16(36887), + 122: uint16(30168), + 123: uint16(37117), + 124: uint16(30563), + 125: uint16(27602), + 126: uint16(29322), + 127: uint16(29420), + 128: uint16(35835), + 129: uint16(22581), + 130: uint16(30585), + 131: uint16(36172), + 132: uint16(26460), + 133: uint16(38208), + 134: uint16(32922), + 135: uint16(24230), + 136: uint16(28193), + 137: uint16(22930), + 138: uint16(31471), + 139: uint16(30701), + 140: uint16(38203), + 141: uint16(27573), + 142: uint16(26029), + 143: uint16(32526), + 144: uint16(22534), + 145: uint16(20817), + 146: uint16(38431), + 147: uint16(23545), + 148: uint16(22697), + 149: uint16(21544), + 150: uint16(36466), + 151: uint16(25958), + 152: uint16(39039), + 153: uint16(22244), + 154: uint16(38045), + 155: uint16(30462), + 156: uint16(36929), + 157: uint16(25479), + 158: uint16(21702), + 159: uint16(22810), + 160: uint16(22842), + 161: uint16(22427), + 162: uint16(36530), + 163: uint16(26421), + 164: uint16(36346), + 165: uint16(33333), + 166: uint16(21057), + 167: uint16(24816), + 168: uint16(22549), + 169: uint16(34558), + 170: uint16(23784), + 171: uint16(40517), + 172: uint16(20420), + 173: uint16(39069), + 174: uint16(35769), + 175: uint16(23077), + 176: uint16(24694), + 177: uint16(21380), + 178: uint16(25212), + 179: uint16(36943), + 180: uint16(37122), + 181: uint16(39295), + 182: uint16(24681), + 183: uint16(32780), + 184: uint16(20799), + 185: uint16(32819), + 186: uint16(23572), + 187: uint16(39285), + 188: uint16(27953), + 189: uint16(20108), + }, + 54: { + 0: uint16(31261), + 1: uint16(31263), + 2: uint16(31265), + 3: uint16(31266), + 4: uint16(31268), + 5: uint16(31269), + 6: uint16(31270), + 7: uint16(31271), + 8: uint16(31272), + 9: uint16(31273), + 10: uint16(31274), + 11: uint16(31275), + 12: uint16(31276), + 13: uint16(31277), + 14: uint16(31278), + 15: uint16(31279), + 16: uint16(31280), + 17: uint16(31281), + 18: uint16(31282), + 19: uint16(31284), + 20: uint16(31285), + 21: uint16(31286), + 22: uint16(31288), + 23: uint16(31290), + 24: uint16(31294), + 25: uint16(31296), + 26: uint16(31297), + 27: uint16(31298), + 28: uint16(31299), + 29: uint16(31300), + 30: uint16(31301), + 31: uint16(31303), + 32: uint16(31304), + 33: uint16(31305), + 34: uint16(31306), + 35: uint16(31307), + 36: uint16(31308), + 37: uint16(31309), + 38: uint16(31310), + 39: uint16(31311), + 40: uint16(31312), + 41: uint16(31314), + 42: uint16(31315), + 43: uint16(31316), + 44: uint16(31317), + 45: uint16(31318), + 46: uint16(31320), + 47: uint16(31321), + 48: uint16(31322), + 49: uint16(31323), + 50: uint16(31324), + 51: uint16(31325), + 52: uint16(31326), + 53: uint16(31327), + 54: uint16(31328), + 55: uint16(31329), + 56: uint16(31330), + 57: uint16(31331), + 58: uint16(31332), + 59: uint16(31333), + 60: uint16(31334), + 61: uint16(31335), + 62: uint16(31336), + 63: uint16(31337), + 64: uint16(31338), + 65: uint16(31339), + 66: uint16(31340), + 67: uint16(31341), + 68: uint16(31342), + 69: uint16(31343), + 70: uint16(31345), + 71: uint16(31346), + 72: uint16(31347), + 73: uint16(31349), + 74: uint16(31355), + 75: uint16(31356), + 76: uint16(31357), + 77: uint16(31358), + 78: uint16(31362), + 79: uint16(31365), + 80: uint16(31367), + 81: uint16(31369), + 82: uint16(31370), + 83: uint16(31371), + 84: uint16(31372), + 85: uint16(31374), + 86: uint16(31375), + 87: uint16(31376), + 88: uint16(31379), + 89: uint16(31380), + 90: uint16(31385), + 91: uint16(31386), + 92: uint16(31387), + 93: uint16(31390), + 94: uint16(31393), + 95: uint16(31394), + 96: uint16(36144), + 97: uint16(21457), + 98: uint16(32602), + 99: uint16(31567), + 100: uint16(20240), + 101: uint16(20047), + 102: uint16(38400), + 103: uint16(27861), + 104: uint16(29648), + 105: uint16(34281), + 106: uint16(24070), + 107: uint16(30058), + 108: uint16(32763), + 109: uint16(27146), + 110: uint16(30718), + 111: uint16(38034), + 112: uint16(32321), + 113: uint16(20961), + 114: uint16(28902), + 115: uint16(21453), + 116: uint16(36820), + 117: uint16(33539), + 118: uint16(36137), + 119: uint16(29359), + 120: uint16(39277), + 121: uint16(27867), + 122: uint16(22346), + 123: uint16(33459), + 124: uint16(26041), + 125: uint16(32938), + 126: uint16(25151), + 127: uint16(38450), + 128: uint16(22952), + 129: uint16(20223), + 130: uint16(35775), + 131: uint16(32442), + 132: uint16(25918), + 133: uint16(33778), + 134: uint16(38750), + 135: uint16(21857), + 136: uint16(39134), + 137: uint16(32933), + 138: uint16(21290), + 139: uint16(35837), + 140: uint16(21536), + 141: uint16(32954), + 142: uint16(24223), + 143: uint16(27832), + 144: uint16(36153), + 145: uint16(33452), + 146: uint16(37210), + 147: uint16(21545), + 148: uint16(27675), + 149: uint16(20998), + 150: uint16(32439), + 151: uint16(22367), + 152: uint16(28954), + 153: uint16(27774), + 154: uint16(31881), + 155: uint16(22859), + 156: uint16(20221), + 157: uint16(24575), + 158: uint16(24868), + 159: uint16(31914), + 160: uint16(20016), + 161: uint16(23553), + 162: uint16(26539), + 163: uint16(34562), + 164: uint16(23792), + 165: uint16(38155), + 166: uint16(39118), + 167: uint16(30127), + 168: uint16(28925), + 169: uint16(36898), + 170: uint16(20911), + 171: uint16(32541), + 172: uint16(35773), + 173: uint16(22857), + 174: uint16(20964), + 175: uint16(20315), + 176: uint16(21542), + 177: uint16(22827), + 178: uint16(25975), + 179: uint16(32932), + 180: uint16(23413), + 181: uint16(25206), + 182: uint16(25282), + 183: uint16(36752), + 184: uint16(24133), + 185: uint16(27679), + 186: uint16(31526), + 187: uint16(20239), + 188: uint16(20440), + 189: uint16(26381), + }, + 55: { + 0: uint16(31395), + 1: uint16(31396), + 2: uint16(31399), + 3: uint16(31401), + 4: uint16(31402), + 5: uint16(31403), + 6: uint16(31406), + 7: uint16(31407), + 8: uint16(31408), + 9: uint16(31409), + 10: uint16(31410), + 11: uint16(31412), + 12: uint16(31413), + 13: uint16(31414), + 14: uint16(31415), + 15: uint16(31416), + 16: uint16(31417), + 17: uint16(31418), + 18: uint16(31419), + 19: uint16(31420), + 20: uint16(31421), + 21: uint16(31422), + 22: uint16(31424), + 23: uint16(31425), + 24: uint16(31426), + 25: uint16(31427), + 26: uint16(31428), + 27: uint16(31429), + 28: uint16(31430), + 29: uint16(31431), + 30: uint16(31432), + 31: uint16(31433), + 32: uint16(31434), + 33: uint16(31436), + 34: uint16(31437), + 35: uint16(31438), + 36: uint16(31439), + 37: uint16(31440), + 38: uint16(31441), + 39: uint16(31442), + 40: uint16(31443), + 41: uint16(31444), + 42: uint16(31445), + 43: uint16(31447), + 44: uint16(31448), + 45: uint16(31450), + 46: uint16(31451), + 47: uint16(31452), + 48: uint16(31453), + 49: uint16(31457), + 50: uint16(31458), + 51: uint16(31460), + 52: uint16(31463), + 53: uint16(31464), + 54: uint16(31465), + 55: uint16(31466), + 56: uint16(31467), + 57: uint16(31468), + 58: uint16(31470), + 59: uint16(31472), + 60: uint16(31473), + 61: uint16(31474), + 62: uint16(31475), + 63: uint16(31476), + 64: uint16(31477), + 65: uint16(31478), + 66: uint16(31479), + 67: uint16(31480), + 68: uint16(31483), + 69: uint16(31484), + 70: uint16(31486), + 71: uint16(31488), + 72: uint16(31489), + 73: uint16(31490), + 74: uint16(31493), + 75: uint16(31495), + 76: uint16(31497), + 77: uint16(31500), + 78: uint16(31501), + 79: uint16(31502), + 80: uint16(31504), + 81: uint16(31506), + 82: uint16(31507), + 83: uint16(31510), + 84: uint16(31511), + 85: uint16(31512), + 86: uint16(31514), + 87: uint16(31516), + 88: uint16(31517), + 89: uint16(31519), + 90: uint16(31521), + 91: uint16(31522), + 92: uint16(31523), + 93: uint16(31527), + 94: uint16(31529), + 95: uint16(31533), + 96: uint16(28014), + 97: uint16(28074), + 98: uint16(31119), + 99: uint16(34993), + 100: uint16(24343), + 101: uint16(29995), + 102: uint16(25242), + 103: uint16(36741), + 104: uint16(20463), + 105: uint16(37340), + 106: uint16(26023), + 107: uint16(33071), + 108: uint16(33105), + 109: uint16(24220), + 110: uint16(33104), + 111: uint16(36212), + 112: uint16(21103), + 113: uint16(35206), + 114: uint16(36171), + 115: uint16(22797), + 116: uint16(20613), + 117: uint16(20184), + 118: uint16(38428), + 119: uint16(29238), + 120: uint16(33145), + 121: uint16(36127), + 122: uint16(23500), + 123: uint16(35747), + 124: uint16(38468), + 125: uint16(22919), + 126: uint16(32538), + 127: uint16(21648), + 128: uint16(22134), + 129: uint16(22030), + 130: uint16(35813), + 131: uint16(25913), + 132: uint16(27010), + 133: uint16(38041), + 134: uint16(30422), + 135: uint16(28297), + 136: uint16(24178), + 137: uint16(29976), + 138: uint16(26438), + 139: uint16(26577), + 140: uint16(31487), + 141: uint16(32925), + 142: uint16(36214), + 143: uint16(24863), + 144: uint16(31174), + 145: uint16(25954), + 146: uint16(36195), + 147: uint16(20872), + 148: uint16(21018), + 149: uint16(38050), + 150: uint16(32568), + 151: uint16(32923), + 152: uint16(32434), + 153: uint16(23703), + 154: uint16(28207), + 155: uint16(26464), + 156: uint16(31705), + 157: uint16(30347), + 158: uint16(39640), + 159: uint16(33167), + 160: uint16(32660), + 161: uint16(31957), + 162: uint16(25630), + 163: uint16(38224), + 164: uint16(31295), + 165: uint16(21578), + 166: uint16(21733), + 167: uint16(27468), + 168: uint16(25601), + 169: uint16(25096), + 170: uint16(40509), + 171: uint16(33011), + 172: uint16(30105), + 173: uint16(21106), + 174: uint16(38761), + 175: uint16(33883), + 176: uint16(26684), + 177: uint16(34532), + 178: uint16(38401), + 179: uint16(38548), + 180: uint16(38124), + 181: uint16(20010), + 182: uint16(21508), + 183: uint16(32473), + 184: uint16(26681), + 185: uint16(36319), + 186: uint16(32789), + 187: uint16(26356), + 188: uint16(24218), + 189: uint16(32697), + }, + 56: { + 0: uint16(31535), + 1: uint16(31536), + 2: uint16(31538), + 3: uint16(31540), + 4: uint16(31541), + 5: uint16(31542), + 6: uint16(31543), + 7: uint16(31545), + 8: uint16(31547), + 9: uint16(31549), + 10: uint16(31551), + 11: uint16(31552), + 12: uint16(31553), + 13: uint16(31554), + 14: uint16(31555), + 15: uint16(31556), + 16: uint16(31558), + 17: uint16(31560), + 18: uint16(31562), + 19: uint16(31565), + 20: uint16(31566), + 21: uint16(31571), + 22: uint16(31573), + 23: uint16(31575), + 24: uint16(31577), + 25: uint16(31580), + 26: uint16(31582), + 27: uint16(31583), + 28: uint16(31585), + 29: uint16(31587), + 30: uint16(31588), + 31: uint16(31589), + 32: uint16(31590), + 33: uint16(31591), + 34: uint16(31592), + 35: uint16(31593), + 36: uint16(31594), + 37: uint16(31595), + 38: uint16(31596), + 39: uint16(31597), + 40: uint16(31599), + 41: uint16(31600), + 42: uint16(31603), + 43: uint16(31604), + 44: uint16(31606), + 45: uint16(31608), + 46: uint16(31610), + 47: uint16(31612), + 48: uint16(31613), + 49: uint16(31615), + 50: uint16(31617), + 51: uint16(31618), + 52: uint16(31619), + 53: uint16(31620), + 54: uint16(31622), + 55: uint16(31623), + 56: uint16(31624), + 57: uint16(31625), + 58: uint16(31626), + 59: uint16(31627), + 60: uint16(31628), + 61: uint16(31630), + 62: uint16(31631), + 63: uint16(31633), + 64: uint16(31634), + 65: uint16(31635), + 66: uint16(31638), + 67: uint16(31640), + 68: uint16(31641), + 69: uint16(31642), + 70: uint16(31643), + 71: uint16(31646), + 72: uint16(31647), + 73: uint16(31648), + 74: uint16(31651), + 75: uint16(31652), + 76: uint16(31653), + 77: uint16(31662), + 78: uint16(31663), + 79: uint16(31664), + 80: uint16(31666), + 81: uint16(31667), + 82: uint16(31669), + 83: uint16(31670), + 84: uint16(31671), + 85: uint16(31673), + 86: uint16(31674), + 87: uint16(31675), + 88: uint16(31676), + 89: uint16(31677), + 90: uint16(31678), + 91: uint16(31679), + 92: uint16(31680), + 93: uint16(31682), + 94: uint16(31683), + 95: uint16(31684), + 96: uint16(22466), + 97: uint16(32831), + 98: uint16(26775), + 99: uint16(24037), + 100: uint16(25915), + 101: uint16(21151), + 102: uint16(24685), + 103: uint16(40858), + 104: uint16(20379), + 105: uint16(36524), + 106: uint16(20844), + 107: uint16(23467), + 108: uint16(24339), + 109: uint16(24041), + 110: uint16(27742), + 111: uint16(25329), + 112: uint16(36129), + 113: uint16(20849), + 114: uint16(38057), + 115: uint16(21246), + 116: uint16(27807), + 117: uint16(33503), + 118: uint16(29399), + 119: uint16(22434), + 120: uint16(26500), + 121: uint16(36141), + 122: uint16(22815), + 123: uint16(36764), + 124: uint16(33735), + 125: uint16(21653), + 126: uint16(31629), + 127: uint16(20272), + 128: uint16(27837), + 129: uint16(23396), + 130: uint16(22993), + 131: uint16(40723), + 132: uint16(21476), + 133: uint16(34506), + 134: uint16(39592), + 135: uint16(35895), + 136: uint16(32929), + 137: uint16(25925), + 138: uint16(39038), + 139: uint16(22266), + 140: uint16(38599), + 141: uint16(21038), + 142: uint16(29916), + 143: uint16(21072), + 144: uint16(23521), + 145: uint16(25346), + 146: uint16(35074), + 147: uint16(20054), + 148: uint16(25296), + 149: uint16(24618), + 150: uint16(26874), + 151: uint16(20851), + 152: uint16(23448), + 153: uint16(20896), + 154: uint16(35266), + 155: uint16(31649), + 156: uint16(39302), + 157: uint16(32592), + 158: uint16(24815), + 159: uint16(28748), + 160: uint16(36143), + 161: uint16(20809), + 162: uint16(24191), + 163: uint16(36891), + 164: uint16(29808), + 165: uint16(35268), + 166: uint16(22317), + 167: uint16(30789), + 168: uint16(24402), + 169: uint16(40863), + 170: uint16(38394), + 171: uint16(36712), + 172: uint16(39740), + 173: uint16(35809), + 174: uint16(30328), + 175: uint16(26690), + 176: uint16(26588), + 177: uint16(36330), + 178: uint16(36149), + 179: uint16(21053), + 180: uint16(36746), + 181: uint16(28378), + 182: uint16(26829), + 183: uint16(38149), + 184: uint16(37101), + 185: uint16(22269), + 186: uint16(26524), + 187: uint16(35065), + 188: uint16(36807), + 189: uint16(21704), + }, + 57: { + 0: uint16(31685), + 1: uint16(31688), + 2: uint16(31689), + 3: uint16(31690), + 4: uint16(31691), + 5: uint16(31693), + 6: uint16(31694), + 7: uint16(31695), + 8: uint16(31696), + 9: uint16(31698), + 10: uint16(31700), + 11: uint16(31701), + 12: uint16(31702), + 13: uint16(31703), + 14: uint16(31704), + 15: uint16(31707), + 16: uint16(31708), + 17: uint16(31710), + 18: uint16(31711), + 19: uint16(31712), + 20: uint16(31714), + 21: uint16(31715), + 22: uint16(31716), + 23: uint16(31719), + 24: uint16(31720), + 25: uint16(31721), + 26: uint16(31723), + 27: uint16(31724), + 28: uint16(31725), + 29: uint16(31727), + 30: uint16(31728), + 31: uint16(31730), + 32: uint16(31731), + 33: uint16(31732), + 34: uint16(31733), + 35: uint16(31734), + 36: uint16(31736), + 37: uint16(31737), + 38: uint16(31738), + 39: uint16(31739), + 40: uint16(31741), + 41: uint16(31743), + 42: uint16(31744), + 43: uint16(31745), + 44: uint16(31746), + 45: uint16(31747), + 46: uint16(31748), + 47: uint16(31749), + 48: uint16(31750), + 49: uint16(31752), + 50: uint16(31753), + 51: uint16(31754), + 52: uint16(31757), + 53: uint16(31758), + 54: uint16(31760), + 55: uint16(31761), + 56: uint16(31762), + 57: uint16(31763), + 58: uint16(31764), + 59: uint16(31765), + 60: uint16(31767), + 61: uint16(31768), + 62: uint16(31769), + 63: uint16(31770), + 64: uint16(31771), + 65: uint16(31772), + 66: uint16(31773), + 67: uint16(31774), + 68: uint16(31776), + 69: uint16(31777), + 70: uint16(31778), + 71: uint16(31779), + 72: uint16(31780), + 73: uint16(31781), + 74: uint16(31784), + 75: uint16(31785), + 76: uint16(31787), + 77: uint16(31788), + 78: uint16(31789), + 79: uint16(31790), + 80: uint16(31791), + 81: uint16(31792), + 82: uint16(31793), + 83: uint16(31794), + 84: uint16(31795), + 85: uint16(31796), + 86: uint16(31797), + 87: uint16(31798), + 88: uint16(31799), + 89: uint16(31801), + 90: uint16(31802), + 91: uint16(31803), + 92: uint16(31804), + 93: uint16(31805), + 94: uint16(31806), + 95: uint16(31810), + 96: uint16(39608), + 97: uint16(23401), + 98: uint16(28023), + 99: uint16(27686), + 100: uint16(20133), + 101: uint16(23475), + 102: uint16(39559), + 103: uint16(37219), + 104: uint16(25000), + 105: uint16(37039), + 106: uint16(38889), + 107: uint16(21547), + 108: uint16(28085), + 109: uint16(23506), + 110: uint16(20989), + 111: uint16(21898), + 112: uint16(32597), + 113: uint16(32752), + 114: uint16(25788), + 115: uint16(25421), + 116: uint16(26097), + 117: uint16(25022), + 118: uint16(24717), + 119: uint16(28938), + 120: uint16(27735), + 121: uint16(27721), + 122: uint16(22831), + 123: uint16(26477), + 124: uint16(33322), + 125: uint16(22741), + 126: uint16(22158), + 127: uint16(35946), + 128: uint16(27627), + 129: uint16(37085), + 130: uint16(22909), + 131: uint16(32791), + 132: uint16(21495), + 133: uint16(28009), + 134: uint16(21621), + 135: uint16(21917), + 136: uint16(33655), + 137: uint16(33743), + 138: uint16(26680), + 139: uint16(31166), + 140: uint16(21644), + 141: uint16(20309), + 142: uint16(21512), + 143: uint16(30418), + 144: uint16(35977), + 145: uint16(38402), + 146: uint16(27827), + 147: uint16(28088), + 148: uint16(36203), + 149: uint16(35088), + 150: uint16(40548), + 151: uint16(36154), + 152: uint16(22079), + 153: uint16(40657), + 154: uint16(30165), + 155: uint16(24456), + 156: uint16(29408), + 157: uint16(24680), + 158: uint16(21756), + 159: uint16(20136), + 160: uint16(27178), + 161: uint16(34913), + 162: uint16(24658), + 163: uint16(36720), + 164: uint16(21700), + 165: uint16(28888), + 166: uint16(34425), + 167: uint16(40511), + 168: uint16(27946), + 169: uint16(23439), + 170: uint16(24344), + 171: uint16(32418), + 172: uint16(21897), + 173: uint16(20399), + 174: uint16(29492), + 175: uint16(21564), + 176: uint16(21402), + 177: uint16(20505), + 178: uint16(21518), + 179: uint16(21628), + 180: uint16(20046), + 181: uint16(24573), + 182: uint16(29786), + 183: uint16(22774), + 184: uint16(33899), + 185: uint16(32993), + 186: uint16(34676), + 187: uint16(29392), + 188: uint16(31946), + 189: uint16(28246), + }, + 58: { + 0: uint16(31811), + 1: uint16(31812), + 2: uint16(31813), + 3: uint16(31814), + 4: uint16(31815), + 5: uint16(31816), + 6: uint16(31817), + 7: uint16(31818), + 8: uint16(31819), + 9: uint16(31820), + 10: uint16(31822), + 11: uint16(31823), + 12: uint16(31824), + 13: uint16(31825), + 14: uint16(31826), + 15: uint16(31827), + 16: uint16(31828), + 17: uint16(31829), + 18: uint16(31830), + 19: uint16(31831), + 20: uint16(31832), + 21: uint16(31833), + 22: uint16(31834), + 23: uint16(31835), + 24: uint16(31836), + 25: uint16(31837), + 26: uint16(31838), + 27: uint16(31839), + 28: uint16(31840), + 29: uint16(31841), + 30: uint16(31842), + 31: uint16(31843), + 32: uint16(31844), + 33: uint16(31845), + 34: uint16(31846), + 35: uint16(31847), + 36: uint16(31848), + 37: uint16(31849), + 38: uint16(31850), + 39: uint16(31851), + 40: uint16(31852), + 41: uint16(31853), + 42: uint16(31854), + 43: uint16(31855), + 44: uint16(31856), + 45: uint16(31857), + 46: uint16(31858), + 47: uint16(31861), + 48: uint16(31862), + 49: uint16(31863), + 50: uint16(31864), + 51: uint16(31865), + 52: uint16(31866), + 53: uint16(31870), + 54: uint16(31871), + 55: uint16(31872), + 56: uint16(31873), + 57: uint16(31874), + 58: uint16(31875), + 59: uint16(31876), + 60: uint16(31877), + 61: uint16(31878), + 62: uint16(31879), + 63: uint16(31880), + 64: uint16(31882), + 65: uint16(31883), + 66: uint16(31884), + 67: uint16(31885), + 68: uint16(31886), + 69: uint16(31887), + 70: uint16(31888), + 71: uint16(31891), + 72: uint16(31892), + 73: uint16(31894), + 74: uint16(31897), + 75: uint16(31898), + 76: uint16(31899), + 77: uint16(31904), + 78: uint16(31905), + 79: uint16(31907), + 80: uint16(31910), + 81: uint16(31911), + 82: uint16(31912), + 83: uint16(31913), + 84: uint16(31915), + 85: uint16(31916), + 86: uint16(31917), + 87: uint16(31919), + 88: uint16(31920), + 89: uint16(31924), + 90: uint16(31925), + 91: uint16(31926), + 92: uint16(31927), + 93: uint16(31928), + 94: uint16(31930), + 95: uint16(31931), + 96: uint16(24359), + 97: uint16(34382), + 98: uint16(21804), + 99: uint16(25252), + 100: uint16(20114), + 101: uint16(27818), + 102: uint16(25143), + 103: uint16(33457), + 104: uint16(21719), + 105: uint16(21326), + 106: uint16(29502), + 107: uint16(28369), + 108: uint16(30011), + 109: uint16(21010), + 110: uint16(21270), + 111: uint16(35805), + 112: uint16(27088), + 113: uint16(24458), + 114: uint16(24576), + 115: uint16(28142), + 116: uint16(22351), + 117: uint16(27426), + 118: uint16(29615), + 119: uint16(26707), + 120: uint16(36824), + 121: uint16(32531), + 122: uint16(25442), + 123: uint16(24739), + 124: uint16(21796), + 125: uint16(30186), + 126: uint16(35938), + 127: uint16(28949), + 128: uint16(28067), + 129: uint16(23462), + 130: uint16(24187), + 131: uint16(33618), + 132: uint16(24908), + 133: uint16(40644), + 134: uint16(30970), + 135: uint16(34647), + 136: uint16(31783), + 137: uint16(30343), + 138: uint16(20976), + 139: uint16(24822), + 140: uint16(29004), + 141: uint16(26179), + 142: uint16(24140), + 143: uint16(24653), + 144: uint16(35854), + 145: uint16(28784), + 146: uint16(25381), + 147: uint16(36745), + 148: uint16(24509), + 149: uint16(24674), + 150: uint16(34516), + 151: uint16(22238), + 152: uint16(27585), + 153: uint16(24724), + 154: uint16(24935), + 155: uint16(21321), + 156: uint16(24800), + 157: uint16(26214), + 158: uint16(36159), + 159: uint16(31229), + 160: uint16(20250), + 161: uint16(28905), + 162: uint16(27719), + 163: uint16(35763), + 164: uint16(35826), + 165: uint16(32472), + 166: uint16(33636), + 167: uint16(26127), + 168: uint16(23130), + 169: uint16(39746), + 170: uint16(27985), + 171: uint16(28151), + 172: uint16(35905), + 173: uint16(27963), + 174: uint16(20249), + 175: uint16(28779), + 176: uint16(33719), + 177: uint16(25110), + 178: uint16(24785), + 179: uint16(38669), + 180: uint16(36135), + 181: uint16(31096), + 182: uint16(20987), + 183: uint16(22334), + 184: uint16(22522), + 185: uint16(26426), + 186: uint16(30072), + 187: uint16(31293), + 188: uint16(31215), + 189: uint16(31637), + }, + 59: { + 0: uint16(31935), + 1: uint16(31936), + 2: uint16(31938), + 3: uint16(31939), + 4: uint16(31940), + 5: uint16(31942), + 6: uint16(31945), + 7: uint16(31947), + 8: uint16(31950), + 9: uint16(31951), + 10: uint16(31952), + 11: uint16(31953), + 12: uint16(31954), + 13: uint16(31955), + 14: uint16(31956), + 15: uint16(31960), + 16: uint16(31962), + 17: uint16(31963), + 18: uint16(31965), + 19: uint16(31966), + 20: uint16(31969), + 21: uint16(31970), + 22: uint16(31971), + 23: uint16(31972), + 24: uint16(31973), + 25: uint16(31974), + 26: uint16(31975), + 27: uint16(31977), + 28: uint16(31978), + 29: uint16(31979), + 30: uint16(31980), + 31: uint16(31981), + 32: uint16(31982), + 33: uint16(31984), + 34: uint16(31985), + 35: uint16(31986), + 36: uint16(31987), + 37: uint16(31988), + 38: uint16(31989), + 39: uint16(31990), + 40: uint16(31991), + 41: uint16(31993), + 42: uint16(31994), + 43: uint16(31996), + 44: uint16(31997), + 45: uint16(31998), + 46: uint16(31999), + 47: uint16(32000), + 48: uint16(32001), + 49: uint16(32002), + 50: uint16(32003), + 51: uint16(32004), + 52: uint16(32005), + 53: uint16(32006), + 54: uint16(32007), + 55: uint16(32008), + 56: uint16(32009), + 57: uint16(32011), + 58: uint16(32012), + 59: uint16(32013), + 60: uint16(32014), + 61: uint16(32015), + 62: uint16(32016), + 63: uint16(32017), + 64: uint16(32018), + 65: uint16(32019), + 66: uint16(32020), + 67: uint16(32021), + 68: uint16(32022), + 69: uint16(32023), + 70: uint16(32024), + 71: uint16(32025), + 72: uint16(32026), + 73: uint16(32027), + 74: uint16(32028), + 75: uint16(32029), + 76: uint16(32030), + 77: uint16(32031), + 78: uint16(32033), + 79: uint16(32035), + 80: uint16(32036), + 81: uint16(32037), + 82: uint16(32038), + 83: uint16(32040), + 84: uint16(32041), + 85: uint16(32042), + 86: uint16(32044), + 87: uint16(32045), + 88: uint16(32046), + 89: uint16(32048), + 90: uint16(32049), + 91: uint16(32050), + 92: uint16(32051), + 93: uint16(32052), + 94: uint16(32053), + 95: uint16(32054), + 96: uint16(32908), + 97: uint16(39269), + 98: uint16(36857), + 99: uint16(28608), + 100: uint16(35749), + 101: uint16(40481), + 102: uint16(23020), + 103: uint16(32489), + 104: uint16(32521), + 105: uint16(21513), + 106: uint16(26497), + 107: uint16(26840), + 108: uint16(36753), + 109: uint16(31821), + 110: uint16(38598), + 111: uint16(21450), + 112: uint16(24613), + 113: uint16(30142), + 114: uint16(27762), + 115: uint16(21363), + 116: uint16(23241), + 117: uint16(32423), + 118: uint16(25380), + 119: uint16(20960), + 120: uint16(33034), + 121: uint16(24049), + 122: uint16(34015), + 123: uint16(25216), + 124: uint16(20864), + 125: uint16(23395), + 126: uint16(20238), + 127: uint16(31085), + 128: uint16(21058), + 129: uint16(24760), + 130: uint16(27982), + 131: uint16(23492), + 132: uint16(23490), + 133: uint16(35745), + 134: uint16(35760), + 135: uint16(26082), + 136: uint16(24524), + 137: uint16(38469), + 138: uint16(22931), + 139: uint16(32487), + 140: uint16(32426), + 141: uint16(22025), + 142: uint16(26551), + 143: uint16(22841), + 144: uint16(20339), + 145: uint16(23478), + 146: uint16(21152), + 147: uint16(33626), + 148: uint16(39050), + 149: uint16(36158), + 150: uint16(30002), + 151: uint16(38078), + 152: uint16(20551), + 153: uint16(31292), + 154: uint16(20215), + 155: uint16(26550), + 156: uint16(39550), + 157: uint16(23233), + 158: uint16(27516), + 159: uint16(30417), + 160: uint16(22362), + 161: uint16(23574), + 162: uint16(31546), + 163: uint16(38388), + 164: uint16(29006), + 165: uint16(20860), + 166: uint16(32937), + 167: uint16(33392), + 168: uint16(22904), + 169: uint16(32516), + 170: uint16(33575), + 171: uint16(26816), + 172: uint16(26604), + 173: uint16(30897), + 174: uint16(30839), + 175: uint16(25315), + 176: uint16(25441), + 177: uint16(31616), + 178: uint16(20461), + 179: uint16(21098), + 180: uint16(20943), + 181: uint16(33616), + 182: uint16(27099), + 183: uint16(37492), + 184: uint16(36341), + 185: uint16(36145), + 186: uint16(35265), + 187: uint16(38190), + 188: uint16(31661), + 189: uint16(20214), + }, + 60: { + 0: uint16(32055), + 1: uint16(32056), + 2: uint16(32057), + 3: uint16(32058), + 4: uint16(32059), + 5: uint16(32060), + 6: uint16(32061), + 7: uint16(32062), + 8: uint16(32063), + 9: uint16(32064), + 10: uint16(32065), + 11: uint16(32066), + 12: uint16(32067), + 13: uint16(32068), + 14: uint16(32069), + 15: uint16(32070), + 16: uint16(32071), + 17: uint16(32072), + 18: uint16(32073), + 19: uint16(32074), + 20: uint16(32075), + 21: uint16(32076), + 22: uint16(32077), + 23: uint16(32078), + 24: uint16(32079), + 25: uint16(32080), + 26: uint16(32081), + 27: uint16(32082), + 28: uint16(32083), + 29: uint16(32084), + 30: uint16(32085), + 31: uint16(32086), + 32: uint16(32087), + 33: uint16(32088), + 34: uint16(32089), + 35: uint16(32090), + 36: uint16(32091), + 37: uint16(32092), + 38: uint16(32093), + 39: uint16(32094), + 40: uint16(32095), + 41: uint16(32096), + 42: uint16(32097), + 43: uint16(32098), + 44: uint16(32099), + 45: uint16(32100), + 46: uint16(32101), + 47: uint16(32102), + 48: uint16(32103), + 49: uint16(32104), + 50: uint16(32105), + 51: uint16(32106), + 52: uint16(32107), + 53: uint16(32108), + 54: uint16(32109), + 55: uint16(32111), + 56: uint16(32112), + 57: uint16(32113), + 58: uint16(32114), + 59: uint16(32115), + 60: uint16(32116), + 61: uint16(32117), + 62: uint16(32118), + 63: uint16(32120), + 64: uint16(32121), + 65: uint16(32122), + 66: uint16(32123), + 67: uint16(32124), + 68: uint16(32125), + 69: uint16(32126), + 70: uint16(32127), + 71: uint16(32128), + 72: uint16(32129), + 73: uint16(32130), + 74: uint16(32131), + 75: uint16(32132), + 76: uint16(32133), + 77: uint16(32134), + 78: uint16(32135), + 79: uint16(32136), + 80: uint16(32137), + 81: uint16(32138), + 82: uint16(32139), + 83: uint16(32140), + 84: uint16(32141), + 85: uint16(32142), + 86: uint16(32143), + 87: uint16(32144), + 88: uint16(32145), + 89: uint16(32146), + 90: uint16(32147), + 91: uint16(32148), + 92: uint16(32149), + 93: uint16(32150), + 94: uint16(32151), + 95: uint16(32152), + 96: uint16(20581), + 97: uint16(33328), + 98: uint16(21073), + 99: uint16(39279), + 100: uint16(28176), + 101: uint16(28293), + 102: uint16(28071), + 103: uint16(24314), + 104: uint16(20725), + 105: uint16(23004), + 106: uint16(23558), + 107: uint16(27974), + 108: uint16(27743), + 109: uint16(30086), + 110: uint16(33931), + 111: uint16(26728), + 112: uint16(22870), + 113: uint16(35762), + 114: uint16(21280), + 115: uint16(37233), + 116: uint16(38477), + 117: uint16(34121), + 118: uint16(26898), + 119: uint16(30977), + 120: uint16(28966), + 121: uint16(33014), + 122: uint16(20132), + 123: uint16(37066), + 124: uint16(27975), + 125: uint16(39556), + 126: uint16(23047), + 127: uint16(22204), + 128: uint16(25605), + 129: uint16(38128), + 130: uint16(30699), + 131: uint16(20389), + 132: uint16(33050), + 133: uint16(29409), + 134: uint16(35282), + 135: uint16(39290), + 136: uint16(32564), + 137: uint16(32478), + 138: uint16(21119), + 139: uint16(25945), + 140: uint16(37237), + 141: uint16(36735), + 142: uint16(36739), + 143: uint16(21483), + 144: uint16(31382), + 145: uint16(25581), + 146: uint16(25509), + 147: uint16(30342), + 148: uint16(31224), + 149: uint16(34903), + 150: uint16(38454), + 151: uint16(25130), + 152: uint16(21163), + 153: uint16(33410), + 154: uint16(26708), + 155: uint16(26480), + 156: uint16(25463), + 157: uint16(30571), + 158: uint16(31469), + 159: uint16(27905), + 160: uint16(32467), + 161: uint16(35299), + 162: uint16(22992), + 163: uint16(25106), + 164: uint16(34249), + 165: uint16(33445), + 166: uint16(30028), + 167: uint16(20511), + 168: uint16(20171), + 169: uint16(30117), + 170: uint16(35819), + 171: uint16(23626), + 172: uint16(24062), + 173: uint16(31563), + 174: uint16(26020), + 175: uint16(37329), + 176: uint16(20170), + 177: uint16(27941), + 178: uint16(35167), + 179: uint16(32039), + 180: uint16(38182), + 181: uint16(20165), + 182: uint16(35880), + 183: uint16(36827), + 184: uint16(38771), + 185: uint16(26187), + 186: uint16(31105), + 187: uint16(36817), + 188: uint16(28908), + 189: uint16(28024), + }, + 61: { + 0: uint16(32153), + 1: uint16(32154), + 2: uint16(32155), + 3: uint16(32156), + 4: uint16(32157), + 5: uint16(32158), + 6: uint16(32159), + 7: uint16(32160), + 8: uint16(32161), + 9: uint16(32162), + 10: uint16(32163), + 11: uint16(32164), + 12: uint16(32165), + 13: uint16(32167), + 14: uint16(32168), + 15: uint16(32169), + 16: uint16(32170), + 17: uint16(32171), + 18: uint16(32172), + 19: uint16(32173), + 20: uint16(32175), + 21: uint16(32176), + 22: uint16(32177), + 23: uint16(32178), + 24: uint16(32179), + 25: uint16(32180), + 26: uint16(32181), + 27: uint16(32182), + 28: uint16(32183), + 29: uint16(32184), + 30: uint16(32185), + 31: uint16(32186), + 32: uint16(32187), + 33: uint16(32188), + 34: uint16(32189), + 35: uint16(32190), + 36: uint16(32191), + 37: uint16(32192), + 38: uint16(32193), + 39: uint16(32194), + 40: uint16(32195), + 41: uint16(32196), + 42: uint16(32197), + 43: uint16(32198), + 44: uint16(32199), + 45: uint16(32200), + 46: uint16(32201), + 47: uint16(32202), + 48: uint16(32203), + 49: uint16(32204), + 50: uint16(32205), + 51: uint16(32206), + 52: uint16(32207), + 53: uint16(32208), + 54: uint16(32209), + 55: uint16(32210), + 56: uint16(32211), + 57: uint16(32212), + 58: uint16(32213), + 59: uint16(32214), + 60: uint16(32215), + 61: uint16(32216), + 62: uint16(32217), + 63: uint16(32218), + 64: uint16(32219), + 65: uint16(32220), + 66: uint16(32221), + 67: uint16(32222), + 68: uint16(32223), + 69: uint16(32224), + 70: uint16(32225), + 71: uint16(32226), + 72: uint16(32227), + 73: uint16(32228), + 74: uint16(32229), + 75: uint16(32230), + 76: uint16(32231), + 77: uint16(32232), + 78: uint16(32233), + 79: uint16(32234), + 80: uint16(32235), + 81: uint16(32236), + 82: uint16(32237), + 83: uint16(32238), + 84: uint16(32239), + 85: uint16(32240), + 86: uint16(32241), + 87: uint16(32242), + 88: uint16(32243), + 89: uint16(32244), + 90: uint16(32245), + 91: uint16(32246), + 92: uint16(32247), + 93: uint16(32248), + 94: uint16(32249), + 95: uint16(32250), + 96: uint16(23613), + 97: uint16(21170), + 98: uint16(33606), + 99: uint16(20834), + 100: uint16(33550), + 101: uint16(30555), + 102: uint16(26230), + 103: uint16(40120), + 104: uint16(20140), + 105: uint16(24778), + 106: uint16(31934), + 107: uint16(31923), + 108: uint16(32463), + 109: uint16(20117), + 110: uint16(35686), + 111: uint16(26223), + 112: uint16(39048), + 113: uint16(38745), + 114: uint16(22659), + 115: uint16(25964), + 116: uint16(38236), + 117: uint16(24452), + 118: uint16(30153), + 119: uint16(38742), + 120: uint16(31455), + 121: uint16(31454), + 122: uint16(20928), + 123: uint16(28847), + 124: uint16(31384), + 125: uint16(25578), + 126: uint16(31350), + 127: uint16(32416), + 128: uint16(29590), + 129: uint16(38893), + 130: uint16(20037), + 131: uint16(28792), + 132: uint16(20061), + 133: uint16(37202), + 134: uint16(21417), + 135: uint16(25937), + 136: uint16(26087), + 137: uint16(33276), + 138: uint16(33285), + 139: uint16(21646), + 140: uint16(23601), + 141: uint16(30106), + 142: uint16(38816), + 143: uint16(25304), + 144: uint16(29401), + 145: uint16(30141), + 146: uint16(23621), + 147: uint16(39545), + 148: uint16(33738), + 149: uint16(23616), + 150: uint16(21632), + 151: uint16(30697), + 152: uint16(20030), + 153: uint16(27822), + 154: uint16(32858), + 155: uint16(25298), + 156: uint16(25454), + 157: uint16(24040), + 158: uint16(20855), + 159: uint16(36317), + 160: uint16(36382), + 161: uint16(38191), + 162: uint16(20465), + 163: uint16(21477), + 164: uint16(24807), + 165: uint16(28844), + 166: uint16(21095), + 167: uint16(25424), + 168: uint16(40515), + 169: uint16(23071), + 170: uint16(20518), + 171: uint16(30519), + 172: uint16(21367), + 173: uint16(32482), + 174: uint16(25733), + 175: uint16(25899), + 176: uint16(25225), + 177: uint16(25496), + 178: uint16(20500), + 179: uint16(29237), + 180: uint16(35273), + 181: uint16(20915), + 182: uint16(35776), + 183: uint16(32477), + 184: uint16(22343), + 185: uint16(33740), + 186: uint16(38055), + 187: uint16(20891), + 188: uint16(21531), + 189: uint16(23803), + }, + 62: { + 0: uint16(32251), + 1: uint16(32252), + 2: uint16(32253), + 3: uint16(32254), + 4: uint16(32255), + 5: uint16(32256), + 6: uint16(32257), + 7: uint16(32258), + 8: uint16(32259), + 9: uint16(32260), + 10: uint16(32261), + 11: uint16(32262), + 12: uint16(32263), + 13: uint16(32264), + 14: uint16(32265), + 15: uint16(32266), + 16: uint16(32267), + 17: uint16(32268), + 18: uint16(32269), + 19: uint16(32270), + 20: uint16(32271), + 21: uint16(32272), + 22: uint16(32273), + 23: uint16(32274), + 24: uint16(32275), + 25: uint16(32276), + 26: uint16(32277), + 27: uint16(32278), + 28: uint16(32279), + 29: uint16(32280), + 30: uint16(32281), + 31: uint16(32282), + 32: uint16(32283), + 33: uint16(32284), + 34: uint16(32285), + 35: uint16(32286), + 36: uint16(32287), + 37: uint16(32288), + 38: uint16(32289), + 39: uint16(32290), + 40: uint16(32291), + 41: uint16(32292), + 42: uint16(32293), + 43: uint16(32294), + 44: uint16(32295), + 45: uint16(32296), + 46: uint16(32297), + 47: uint16(32298), + 48: uint16(32299), + 49: uint16(32300), + 50: uint16(32301), + 51: uint16(32302), + 52: uint16(32303), + 53: uint16(32304), + 54: uint16(32305), + 55: uint16(32306), + 56: uint16(32307), + 57: uint16(32308), + 58: uint16(32309), + 59: uint16(32310), + 60: uint16(32311), + 61: uint16(32312), + 62: uint16(32313), + 63: uint16(32314), + 64: uint16(32316), + 65: uint16(32317), + 66: uint16(32318), + 67: uint16(32319), + 68: uint16(32320), + 69: uint16(32322), + 70: uint16(32323), + 71: uint16(32324), + 72: uint16(32325), + 73: uint16(32326), + 74: uint16(32328), + 75: uint16(32329), + 76: uint16(32330), + 77: uint16(32331), + 78: uint16(32332), + 79: uint16(32333), + 80: uint16(32334), + 81: uint16(32335), + 82: uint16(32336), + 83: uint16(32337), + 84: uint16(32338), + 85: uint16(32339), + 86: uint16(32340), + 87: uint16(32341), + 88: uint16(32342), + 89: uint16(32343), + 90: uint16(32344), + 91: uint16(32345), + 92: uint16(32346), + 93: uint16(32347), + 94: uint16(32348), + 95: uint16(32349), + 96: uint16(20426), + 97: uint16(31459), + 98: uint16(27994), + 99: uint16(37089), + 100: uint16(39567), + 101: uint16(21888), + 102: uint16(21654), + 103: uint16(21345), + 104: uint16(21679), + 105: uint16(24320), + 106: uint16(25577), + 107: uint16(26999), + 108: uint16(20975), + 109: uint16(24936), + 110: uint16(21002), + 111: uint16(22570), + 112: uint16(21208), + 113: uint16(22350), + 114: uint16(30733), + 115: uint16(30475), + 116: uint16(24247), + 117: uint16(24951), + 118: uint16(31968), + 119: uint16(25179), + 120: uint16(25239), + 121: uint16(20130), + 122: uint16(28821), + 123: uint16(32771), + 124: uint16(25335), + 125: uint16(28900), + 126: uint16(38752), + 127: uint16(22391), + 128: uint16(33499), + 129: uint16(26607), + 130: uint16(26869), + 131: uint16(30933), + 132: uint16(39063), + 133: uint16(31185), + 134: uint16(22771), + 135: uint16(21683), + 136: uint16(21487), + 137: uint16(28212), + 138: uint16(20811), + 139: uint16(21051), + 140: uint16(23458), + 141: uint16(35838), + 142: uint16(32943), + 143: uint16(21827), + 144: uint16(22438), + 145: uint16(24691), + 146: uint16(22353), + 147: uint16(21549), + 148: uint16(31354), + 149: uint16(24656), + 150: uint16(23380), + 151: uint16(25511), + 152: uint16(25248), + 153: uint16(21475), + 154: uint16(25187), + 155: uint16(23495), + 156: uint16(26543), + 157: uint16(21741), + 158: uint16(31391), + 159: uint16(33510), + 160: uint16(37239), + 161: uint16(24211), + 162: uint16(35044), + 163: uint16(22840), + 164: uint16(22446), + 165: uint16(25358), + 166: uint16(36328), + 167: uint16(33007), + 168: uint16(22359), + 169: uint16(31607), + 170: uint16(20393), + 171: uint16(24555), + 172: uint16(23485), + 173: uint16(27454), + 174: uint16(21281), + 175: uint16(31568), + 176: uint16(29378), + 177: uint16(26694), + 178: uint16(30719), + 179: uint16(30518), + 180: uint16(26103), + 181: uint16(20917), + 182: uint16(20111), + 183: uint16(30420), + 184: uint16(23743), + 185: uint16(31397), + 186: uint16(33909), + 187: uint16(22862), + 188: uint16(39745), + 189: uint16(20608), + }, + 63: { + 0: uint16(32350), + 1: uint16(32351), + 2: uint16(32352), + 3: uint16(32353), + 4: uint16(32354), + 5: uint16(32355), + 6: uint16(32356), + 7: uint16(32357), + 8: uint16(32358), + 9: uint16(32359), + 10: uint16(32360), + 11: uint16(32361), + 12: uint16(32362), + 13: uint16(32363), + 14: uint16(32364), + 15: uint16(32365), + 16: uint16(32366), + 17: uint16(32367), + 18: uint16(32368), + 19: uint16(32369), + 20: uint16(32370), + 21: uint16(32371), + 22: uint16(32372), + 23: uint16(32373), + 24: uint16(32374), + 25: uint16(32375), + 26: uint16(32376), + 27: uint16(32377), + 28: uint16(32378), + 29: uint16(32379), + 30: uint16(32380), + 31: uint16(32381), + 32: uint16(32382), + 33: uint16(32383), + 34: uint16(32384), + 35: uint16(32385), + 36: uint16(32387), + 37: uint16(32388), + 38: uint16(32389), + 39: uint16(32390), + 40: uint16(32391), + 41: uint16(32392), + 42: uint16(32393), + 43: uint16(32394), + 44: uint16(32395), + 45: uint16(32396), + 46: uint16(32397), + 47: uint16(32398), + 48: uint16(32399), + 49: uint16(32400), + 50: uint16(32401), + 51: uint16(32402), + 52: uint16(32403), + 53: uint16(32404), + 54: uint16(32405), + 55: uint16(32406), + 56: uint16(32407), + 57: uint16(32408), + 58: uint16(32409), + 59: uint16(32410), + 60: uint16(32412), + 61: uint16(32413), + 62: uint16(32414), + 63: uint16(32430), + 64: uint16(32436), + 65: uint16(32443), + 66: uint16(32444), + 67: uint16(32470), + 68: uint16(32484), + 69: uint16(32492), + 70: uint16(32505), + 71: uint16(32522), + 72: uint16(32528), + 73: uint16(32542), + 74: uint16(32567), + 75: uint16(32569), + 76: uint16(32571), + 77: uint16(32572), + 78: uint16(32573), + 79: uint16(32574), + 80: uint16(32575), + 81: uint16(32576), + 82: uint16(32577), + 83: uint16(32579), + 84: uint16(32582), + 85: uint16(32583), + 86: uint16(32584), + 87: uint16(32585), + 88: uint16(32586), + 89: uint16(32587), + 90: uint16(32588), + 91: uint16(32589), + 92: uint16(32590), + 93: uint16(32591), + 94: uint16(32594), + 95: uint16(32595), + 96: uint16(39304), + 97: uint16(24871), + 98: uint16(28291), + 99: uint16(22372), + 100: uint16(26118), + 101: uint16(25414), + 102: uint16(22256), + 103: uint16(25324), + 104: uint16(25193), + 105: uint16(24275), + 106: uint16(38420), + 107: uint16(22403), + 108: uint16(25289), + 109: uint16(21895), + 110: uint16(34593), + 111: uint16(33098), + 112: uint16(36771), + 113: uint16(21862), + 114: uint16(33713), + 115: uint16(26469), + 116: uint16(36182), + 117: uint16(34013), + 118: uint16(23146), + 119: uint16(26639), + 120: uint16(25318), + 121: uint16(31726), + 122: uint16(38417), + 123: uint16(20848), + 124: uint16(28572), + 125: uint16(35888), + 126: uint16(25597), + 127: uint16(35272), + 128: uint16(25042), + 129: uint16(32518), + 130: uint16(28866), + 131: uint16(28389), + 132: uint16(29701), + 133: uint16(27028), + 134: uint16(29436), + 135: uint16(24266), + 136: uint16(37070), + 137: uint16(26391), + 138: uint16(28010), + 139: uint16(25438), + 140: uint16(21171), + 141: uint16(29282), + 142: uint16(32769), + 143: uint16(20332), + 144: uint16(23013), + 145: uint16(37226), + 146: uint16(28889), + 147: uint16(28061), + 148: uint16(21202), + 149: uint16(20048), + 150: uint16(38647), + 151: uint16(38253), + 152: uint16(34174), + 153: uint16(30922), + 154: uint16(32047), + 155: uint16(20769), + 156: uint16(22418), + 157: uint16(25794), + 158: uint16(32907), + 159: uint16(31867), + 160: uint16(27882), + 161: uint16(26865), + 162: uint16(26974), + 163: uint16(20919), + 164: uint16(21400), + 165: uint16(26792), + 166: uint16(29313), + 167: uint16(40654), + 168: uint16(31729), + 169: uint16(29432), + 170: uint16(31163), + 171: uint16(28435), + 172: uint16(29702), + 173: uint16(26446), + 174: uint16(37324), + 175: uint16(40100), + 176: uint16(31036), + 177: uint16(33673), + 178: uint16(33620), + 179: uint16(21519), + 180: uint16(26647), + 181: uint16(20029), + 182: uint16(21385), + 183: uint16(21169), + 184: uint16(30782), + 185: uint16(21382), + 186: uint16(21033), + 187: uint16(20616), + 188: uint16(20363), + 189: uint16(20432), + }, + 64: { + 0: uint16(32598), + 1: uint16(32601), + 2: uint16(32603), + 3: uint16(32604), + 4: uint16(32605), + 5: uint16(32606), + 6: uint16(32608), + 7: uint16(32611), + 8: uint16(32612), + 9: uint16(32613), + 10: uint16(32614), + 11: uint16(32615), + 12: uint16(32619), + 13: uint16(32620), + 14: uint16(32621), + 15: uint16(32623), + 16: uint16(32624), + 17: uint16(32627), + 18: uint16(32629), + 19: uint16(32630), + 20: uint16(32631), + 21: uint16(32632), + 22: uint16(32634), + 23: uint16(32635), + 24: uint16(32636), + 25: uint16(32637), + 26: uint16(32639), + 27: uint16(32640), + 28: uint16(32642), + 29: uint16(32643), + 30: uint16(32644), + 31: uint16(32645), + 32: uint16(32646), + 33: uint16(32647), + 34: uint16(32648), + 35: uint16(32649), + 36: uint16(32651), + 37: uint16(32653), + 38: uint16(32655), + 39: uint16(32656), + 40: uint16(32657), + 41: uint16(32658), + 42: uint16(32659), + 43: uint16(32661), + 44: uint16(32662), + 45: uint16(32663), + 46: uint16(32664), + 47: uint16(32665), + 48: uint16(32667), + 49: uint16(32668), + 50: uint16(32672), + 51: uint16(32674), + 52: uint16(32675), + 53: uint16(32677), + 54: uint16(32678), + 55: uint16(32680), + 56: uint16(32681), + 57: uint16(32682), + 58: uint16(32683), + 59: uint16(32684), + 60: uint16(32685), + 61: uint16(32686), + 62: uint16(32689), + 63: uint16(32691), + 64: uint16(32692), + 65: uint16(32693), + 66: uint16(32694), + 67: uint16(32695), + 68: uint16(32698), + 69: uint16(32699), + 70: uint16(32702), + 71: uint16(32704), + 72: uint16(32706), + 73: uint16(32707), + 74: uint16(32708), + 75: uint16(32710), + 76: uint16(32711), + 77: uint16(32712), + 78: uint16(32713), + 79: uint16(32715), + 80: uint16(32717), + 81: uint16(32719), + 82: uint16(32720), + 83: uint16(32721), + 84: uint16(32722), + 85: uint16(32723), + 86: uint16(32726), + 87: uint16(32727), + 88: uint16(32729), + 89: uint16(32730), + 90: uint16(32731), + 91: uint16(32732), + 92: uint16(32733), + 93: uint16(32734), + 94: uint16(32738), + 95: uint16(32739), + 96: uint16(30178), + 97: uint16(31435), + 98: uint16(31890), + 99: uint16(27813), + 100: uint16(38582), + 101: uint16(21147), + 102: uint16(29827), + 103: uint16(21737), + 104: uint16(20457), + 105: uint16(32852), + 106: uint16(33714), + 107: uint16(36830), + 108: uint16(38256), + 109: uint16(24265), + 110: uint16(24604), + 111: uint16(28063), + 112: uint16(24088), + 113: uint16(25947), + 114: uint16(33080), + 115: uint16(38142), + 116: uint16(24651), + 117: uint16(28860), + 118: uint16(32451), + 119: uint16(31918), + 120: uint16(20937), + 121: uint16(26753), + 122: uint16(31921), + 123: uint16(33391), + 124: uint16(20004), + 125: uint16(36742), + 126: uint16(37327), + 127: uint16(26238), + 128: uint16(20142), + 129: uint16(35845), + 130: uint16(25769), + 131: uint16(32842), + 132: uint16(20698), + 133: uint16(30103), + 134: uint16(29134), + 135: uint16(23525), + 136: uint16(36797), + 137: uint16(28518), + 138: uint16(20102), + 139: uint16(25730), + 140: uint16(38243), + 141: uint16(24278), + 142: uint16(26009), + 143: uint16(21015), + 144: uint16(35010), + 145: uint16(28872), + 146: uint16(21155), + 147: uint16(29454), + 148: uint16(29747), + 149: uint16(26519), + 150: uint16(30967), + 151: uint16(38678), + 152: uint16(20020), + 153: uint16(37051), + 154: uint16(40158), + 155: uint16(28107), + 156: uint16(20955), + 157: uint16(36161), + 158: uint16(21533), + 159: uint16(25294), + 160: uint16(29618), + 161: uint16(33777), + 162: uint16(38646), + 163: uint16(40836), + 164: uint16(38083), + 165: uint16(20278), + 166: uint16(32666), + 167: uint16(20940), + 168: uint16(28789), + 169: uint16(38517), + 170: uint16(23725), + 171: uint16(39046), + 172: uint16(21478), + 173: uint16(20196), + 174: uint16(28316), + 175: uint16(29705), + 176: uint16(27060), + 177: uint16(30827), + 178: uint16(39311), + 179: uint16(30041), + 180: uint16(21016), + 181: uint16(30244), + 182: uint16(27969), + 183: uint16(26611), + 184: uint16(20845), + 185: uint16(40857), + 186: uint16(32843), + 187: uint16(21657), + 188: uint16(31548), + 189: uint16(31423), + }, + 65: { + 0: uint16(32740), + 1: uint16(32743), + 2: uint16(32744), + 3: uint16(32746), + 4: uint16(32747), + 5: uint16(32748), + 6: uint16(32749), + 7: uint16(32751), + 8: uint16(32754), + 9: uint16(32756), + 10: uint16(32757), + 11: uint16(32758), + 12: uint16(32759), + 13: uint16(32760), + 14: uint16(32761), + 15: uint16(32762), + 16: uint16(32765), + 17: uint16(32766), + 18: uint16(32767), + 19: uint16(32770), + 20: uint16(32775), + 21: uint16(32776), + 22: uint16(32777), + 23: uint16(32778), + 24: uint16(32782), + 25: uint16(32783), + 26: uint16(32785), + 27: uint16(32787), + 28: uint16(32794), + 29: uint16(32795), + 30: uint16(32797), + 31: uint16(32798), + 32: uint16(32799), + 33: uint16(32801), + 34: uint16(32803), + 35: uint16(32804), + 36: uint16(32811), + 37: uint16(32812), + 38: uint16(32813), + 39: uint16(32814), + 40: uint16(32815), + 41: uint16(32816), + 42: uint16(32818), + 43: uint16(32820), + 44: uint16(32825), + 45: uint16(32826), + 46: uint16(32828), + 47: uint16(32830), + 48: uint16(32832), + 49: uint16(32833), + 50: uint16(32836), + 51: uint16(32837), + 52: uint16(32839), + 53: uint16(32840), + 54: uint16(32841), + 55: uint16(32846), + 56: uint16(32847), + 57: uint16(32848), + 58: uint16(32849), + 59: uint16(32851), + 60: uint16(32853), + 61: uint16(32854), + 62: uint16(32855), + 63: uint16(32857), + 64: uint16(32859), + 65: uint16(32860), + 66: uint16(32861), + 67: uint16(32862), + 68: uint16(32863), + 69: uint16(32864), + 70: uint16(32865), + 71: uint16(32866), + 72: uint16(32867), + 73: uint16(32868), + 74: uint16(32869), + 75: uint16(32870), + 76: uint16(32871), + 77: uint16(32872), + 78: uint16(32875), + 79: uint16(32876), + 80: uint16(32877), + 81: uint16(32878), + 82: uint16(32879), + 83: uint16(32880), + 84: uint16(32882), + 85: uint16(32883), + 86: uint16(32884), + 87: uint16(32885), + 88: uint16(32886), + 89: uint16(32887), + 90: uint16(32888), + 91: uint16(32889), + 92: uint16(32890), + 93: uint16(32891), + 94: uint16(32892), + 95: uint16(32893), + 96: uint16(38534), + 97: uint16(22404), + 98: uint16(25314), + 99: uint16(38471), + 100: uint16(27004), + 101: uint16(23044), + 102: uint16(25602), + 103: uint16(31699), + 104: uint16(28431), + 105: uint16(38475), + 106: uint16(33446), + 107: uint16(21346), + 108: uint16(39045), + 109: uint16(24208), + 110: uint16(28809), + 111: uint16(25523), + 112: uint16(21348), + 113: uint16(34383), + 114: uint16(40065), + 115: uint16(40595), + 116: uint16(30860), + 117: uint16(38706), + 118: uint16(36335), + 119: uint16(36162), + 120: uint16(40575), + 121: uint16(28510), + 122: uint16(31108), + 123: uint16(24405), + 124: uint16(38470), + 125: uint16(25134), + 126: uint16(39540), + 127: uint16(21525), + 128: uint16(38109), + 129: uint16(20387), + 130: uint16(26053), + 131: uint16(23653), + 132: uint16(23649), + 133: uint16(32533), + 134: uint16(34385), + 135: uint16(27695), + 136: uint16(24459), + 137: uint16(29575), + 138: uint16(28388), + 139: uint16(32511), + 140: uint16(23782), + 141: uint16(25371), + 142: uint16(23402), + 143: uint16(28390), + 144: uint16(21365), + 145: uint16(20081), + 146: uint16(25504), + 147: uint16(30053), + 148: uint16(25249), + 149: uint16(36718), + 150: uint16(20262), + 151: uint16(20177), + 152: uint16(27814), + 153: uint16(32438), + 154: uint16(35770), + 155: uint16(33821), + 156: uint16(34746), + 157: uint16(32599), + 158: uint16(36923), + 159: uint16(38179), + 160: uint16(31657), + 161: uint16(39585), + 162: uint16(35064), + 163: uint16(33853), + 164: uint16(27931), + 165: uint16(39558), + 166: uint16(32476), + 167: uint16(22920), + 168: uint16(40635), + 169: uint16(29595), + 170: uint16(30721), + 171: uint16(34434), + 172: uint16(39532), + 173: uint16(39554), + 174: uint16(22043), + 175: uint16(21527), + 176: uint16(22475), + 177: uint16(20080), + 178: uint16(40614), + 179: uint16(21334), + 180: uint16(36808), + 181: uint16(33033), + 182: uint16(30610), + 183: uint16(39314), + 184: uint16(34542), + 185: uint16(28385), + 186: uint16(34067), + 187: uint16(26364), + 188: uint16(24930), + 189: uint16(28459), + }, + 66: { + 0: uint16(32894), + 1: uint16(32897), + 2: uint16(32898), + 3: uint16(32901), + 4: uint16(32904), + 5: uint16(32906), + 6: uint16(32909), + 7: uint16(32910), + 8: uint16(32911), + 9: uint16(32912), + 10: uint16(32913), + 11: uint16(32914), + 12: uint16(32916), + 13: uint16(32917), + 14: uint16(32919), + 15: uint16(32921), + 16: uint16(32926), + 17: uint16(32931), + 18: uint16(32934), + 19: uint16(32935), + 20: uint16(32936), + 21: uint16(32940), + 22: uint16(32944), + 23: uint16(32947), + 24: uint16(32949), + 25: uint16(32950), + 26: uint16(32952), + 27: uint16(32953), + 28: uint16(32955), + 29: uint16(32965), + 30: uint16(32967), + 31: uint16(32968), + 32: uint16(32969), + 33: uint16(32970), + 34: uint16(32971), + 35: uint16(32975), + 36: uint16(32976), + 37: uint16(32977), + 38: uint16(32978), + 39: uint16(32979), + 40: uint16(32980), + 41: uint16(32981), + 42: uint16(32984), + 43: uint16(32991), + 44: uint16(32992), + 45: uint16(32994), + 46: uint16(32995), + 47: uint16(32998), + 48: uint16(33006), + 49: uint16(33013), + 50: uint16(33015), + 51: uint16(33017), + 52: uint16(33019), + 53: uint16(33022), + 54: uint16(33023), + 55: uint16(33024), + 56: uint16(33025), + 57: uint16(33027), + 58: uint16(33028), + 59: uint16(33029), + 60: uint16(33031), + 61: uint16(33032), + 62: uint16(33035), + 63: uint16(33036), + 64: uint16(33045), + 65: uint16(33047), + 66: uint16(33049), + 67: uint16(33051), + 68: uint16(33052), + 69: uint16(33053), + 70: uint16(33055), + 71: uint16(33056), + 72: uint16(33057), + 73: uint16(33058), + 74: uint16(33059), + 75: uint16(33060), + 76: uint16(33061), + 77: uint16(33062), + 78: uint16(33063), + 79: uint16(33064), + 80: uint16(33065), + 81: uint16(33066), + 82: uint16(33067), + 83: uint16(33069), + 84: uint16(33070), + 85: uint16(33072), + 86: uint16(33075), + 87: uint16(33076), + 88: uint16(33077), + 89: uint16(33079), + 90: uint16(33081), + 91: uint16(33082), + 92: uint16(33083), + 93: uint16(33084), + 94: uint16(33085), + 95: uint16(33087), + 96: uint16(35881), + 97: uint16(33426), + 98: uint16(33579), + 99: uint16(30450), + 100: uint16(27667), + 101: uint16(24537), + 102: uint16(33725), + 103: uint16(29483), + 104: uint16(33541), + 105: uint16(38170), + 106: uint16(27611), + 107: uint16(30683), + 108: uint16(38086), + 109: uint16(21359), + 110: uint16(33538), + 111: uint16(20882), + 112: uint16(24125), + 113: uint16(35980), + 114: uint16(36152), + 115: uint16(20040), + 116: uint16(29611), + 117: uint16(26522), + 118: uint16(26757), + 119: uint16(37238), + 120: uint16(38665), + 121: uint16(29028), + 122: uint16(27809), + 123: uint16(30473), + 124: uint16(23186), + 125: uint16(38209), + 126: uint16(27599), + 127: uint16(32654), + 128: uint16(26151), + 129: uint16(23504), + 130: uint16(22969), + 131: uint16(23194), + 132: uint16(38376), + 133: uint16(38391), + 134: uint16(20204), + 135: uint16(33804), + 136: uint16(33945), + 137: uint16(27308), + 138: uint16(30431), + 139: uint16(38192), + 140: uint16(29467), + 141: uint16(26790), + 142: uint16(23391), + 143: uint16(30511), + 144: uint16(37274), + 145: uint16(38753), + 146: uint16(31964), + 147: uint16(36855), + 148: uint16(35868), + 149: uint16(24357), + 150: uint16(31859), + 151: uint16(31192), + 152: uint16(35269), + 153: uint16(27852), + 154: uint16(34588), + 155: uint16(23494), + 156: uint16(24130), + 157: uint16(26825), + 158: uint16(30496), + 159: uint16(32501), + 160: uint16(20885), + 161: uint16(20813), + 162: uint16(21193), + 163: uint16(23081), + 164: uint16(32517), + 165: uint16(38754), + 166: uint16(33495), + 167: uint16(25551), + 168: uint16(30596), + 169: uint16(34256), + 170: uint16(31186), + 171: uint16(28218), + 172: uint16(24217), + 173: uint16(22937), + 174: uint16(34065), + 175: uint16(28781), + 176: uint16(27665), + 177: uint16(25279), + 178: uint16(30399), + 179: uint16(25935), + 180: uint16(24751), + 181: uint16(38397), + 182: uint16(26126), + 183: uint16(34719), + 184: uint16(40483), + 185: uint16(38125), + 186: uint16(21517), + 187: uint16(21629), + 188: uint16(35884), + 189: uint16(25720), + }, + 67: { + 0: uint16(33088), + 1: uint16(33089), + 2: uint16(33090), + 3: uint16(33091), + 4: uint16(33092), + 5: uint16(33093), + 6: uint16(33095), + 7: uint16(33097), + 8: uint16(33101), + 9: uint16(33102), + 10: uint16(33103), + 11: uint16(33106), + 12: uint16(33110), + 13: uint16(33111), + 14: uint16(33112), + 15: uint16(33115), + 16: uint16(33116), + 17: uint16(33117), + 18: uint16(33118), + 19: uint16(33119), + 20: uint16(33121), + 21: uint16(33122), + 22: uint16(33123), + 23: uint16(33124), + 24: uint16(33126), + 25: uint16(33128), + 26: uint16(33130), + 27: uint16(33131), + 28: uint16(33132), + 29: uint16(33135), + 30: uint16(33138), + 31: uint16(33139), + 32: uint16(33141), + 33: uint16(33142), + 34: uint16(33143), + 35: uint16(33144), + 36: uint16(33153), + 37: uint16(33155), + 38: uint16(33156), + 39: uint16(33157), + 40: uint16(33158), + 41: uint16(33159), + 42: uint16(33161), + 43: uint16(33163), + 44: uint16(33164), + 45: uint16(33165), + 46: uint16(33166), + 47: uint16(33168), + 48: uint16(33170), + 49: uint16(33171), + 50: uint16(33172), + 51: uint16(33173), + 52: uint16(33174), + 53: uint16(33175), + 54: uint16(33177), + 55: uint16(33178), + 56: uint16(33182), + 57: uint16(33183), + 58: uint16(33184), + 59: uint16(33185), + 60: uint16(33186), + 61: uint16(33188), + 62: uint16(33189), + 63: uint16(33191), + 64: uint16(33193), + 65: uint16(33195), + 66: uint16(33196), + 67: uint16(33197), + 68: uint16(33198), + 69: uint16(33199), + 70: uint16(33200), + 71: uint16(33201), + 72: uint16(33202), + 73: uint16(33204), + 74: uint16(33205), + 75: uint16(33206), + 76: uint16(33207), + 77: uint16(33208), + 78: uint16(33209), + 79: uint16(33212), + 80: uint16(33213), + 81: uint16(33214), + 82: uint16(33215), + 83: uint16(33220), + 84: uint16(33221), + 85: uint16(33223), + 86: uint16(33224), + 87: uint16(33225), + 88: uint16(33227), + 89: uint16(33229), + 90: uint16(33230), + 91: uint16(33231), + 92: uint16(33232), + 93: uint16(33233), + 94: uint16(33234), + 95: uint16(33235), + 96: uint16(25721), + 97: uint16(34321), + 98: uint16(27169), + 99: uint16(33180), + 100: uint16(30952), + 101: uint16(25705), + 102: uint16(39764), + 103: uint16(25273), + 104: uint16(26411), + 105: uint16(33707), + 106: uint16(22696), + 107: uint16(40664), + 108: uint16(27819), + 109: uint16(28448), + 110: uint16(23518), + 111: uint16(38476), + 112: uint16(35851), + 113: uint16(29279), + 114: uint16(26576), + 115: uint16(25287), + 116: uint16(29281), + 117: uint16(20137), + 118: uint16(22982), + 119: uint16(27597), + 120: uint16(22675), + 121: uint16(26286), + 122: uint16(24149), + 123: uint16(21215), + 124: uint16(24917), + 125: uint16(26408), + 126: uint16(30446), + 127: uint16(30566), + 128: uint16(29287), + 129: uint16(31302), + 130: uint16(25343), + 131: uint16(21738), + 132: uint16(21584), + 133: uint16(38048), + 134: uint16(37027), + 135: uint16(23068), + 136: uint16(32435), + 137: uint16(27670), + 138: uint16(20035), + 139: uint16(22902), + 140: uint16(32784), + 141: uint16(22856), + 142: uint16(21335), + 143: uint16(30007), + 144: uint16(38590), + 145: uint16(22218), + 146: uint16(25376), + 147: uint16(33041), + 148: uint16(24700), + 149: uint16(38393), + 150: uint16(28118), + 151: uint16(21602), + 152: uint16(39297), + 153: uint16(20869), + 154: uint16(23273), + 155: uint16(33021), + 156: uint16(22958), + 157: uint16(38675), + 158: uint16(20522), + 159: uint16(27877), + 160: uint16(23612), + 161: uint16(25311), + 162: uint16(20320), + 163: uint16(21311), + 164: uint16(33147), + 165: uint16(36870), + 166: uint16(28346), + 167: uint16(34091), + 168: uint16(25288), + 169: uint16(24180), + 170: uint16(30910), + 171: uint16(25781), + 172: uint16(25467), + 173: uint16(24565), + 174: uint16(23064), + 175: uint16(37247), + 176: uint16(40479), + 177: uint16(23615), + 178: uint16(25423), + 179: uint16(32834), + 180: uint16(23421), + 181: uint16(21870), + 182: uint16(38218), + 183: uint16(38221), + 184: uint16(28037), + 185: uint16(24744), + 186: uint16(26592), + 187: uint16(29406), + 188: uint16(20957), + 189: uint16(23425), + }, + 68: { + 0: uint16(33236), + 1: uint16(33237), + 2: uint16(33238), + 3: uint16(33239), + 4: uint16(33240), + 5: uint16(33241), + 6: uint16(33242), + 7: uint16(33243), + 8: uint16(33244), + 9: uint16(33245), + 10: uint16(33246), + 11: uint16(33247), + 12: uint16(33248), + 13: uint16(33249), + 14: uint16(33250), + 15: uint16(33252), + 16: uint16(33253), + 17: uint16(33254), + 18: uint16(33256), + 19: uint16(33257), + 20: uint16(33259), + 21: uint16(33262), + 22: uint16(33263), + 23: uint16(33264), + 24: uint16(33265), + 25: uint16(33266), + 26: uint16(33269), + 27: uint16(33270), + 28: uint16(33271), + 29: uint16(33272), + 30: uint16(33273), + 31: uint16(33274), + 32: uint16(33277), + 33: uint16(33279), + 34: uint16(33283), + 35: uint16(33287), + 36: uint16(33288), + 37: uint16(33289), + 38: uint16(33290), + 39: uint16(33291), + 40: uint16(33294), + 41: uint16(33295), + 42: uint16(33297), + 43: uint16(33299), + 44: uint16(33301), + 45: uint16(33302), + 46: uint16(33303), + 47: uint16(33304), + 48: uint16(33305), + 49: uint16(33306), + 50: uint16(33309), + 51: uint16(33312), + 52: uint16(33316), + 53: uint16(33317), + 54: uint16(33318), + 55: uint16(33319), + 56: uint16(33321), + 57: uint16(33326), + 58: uint16(33330), + 59: uint16(33338), + 60: uint16(33340), + 61: uint16(33341), + 62: uint16(33343), + 63: uint16(33344), + 64: uint16(33345), + 65: uint16(33346), + 66: uint16(33347), + 67: uint16(33349), + 68: uint16(33350), + 69: uint16(33352), + 70: uint16(33354), + 71: uint16(33356), + 72: uint16(33357), + 73: uint16(33358), + 74: uint16(33360), + 75: uint16(33361), + 76: uint16(33362), + 77: uint16(33363), + 78: uint16(33364), + 79: uint16(33365), + 80: uint16(33366), + 81: uint16(33367), + 82: uint16(33369), + 83: uint16(33371), + 84: uint16(33372), + 85: uint16(33373), + 86: uint16(33374), + 87: uint16(33376), + 88: uint16(33377), + 89: uint16(33378), + 90: uint16(33379), + 91: uint16(33380), + 92: uint16(33381), + 93: uint16(33382), + 94: uint16(33383), + 95: uint16(33385), + 96: uint16(25319), + 97: uint16(27870), + 98: uint16(29275), + 99: uint16(25197), + 100: uint16(38062), + 101: uint16(32445), + 102: uint16(33043), + 103: uint16(27987), + 104: uint16(20892), + 105: uint16(24324), + 106: uint16(22900), + 107: uint16(21162), + 108: uint16(24594), + 109: uint16(22899), + 110: uint16(26262), + 111: uint16(34384), + 112: uint16(30111), + 113: uint16(25386), + 114: uint16(25062), + 115: uint16(31983), + 116: uint16(35834), + 117: uint16(21734), + 118: uint16(27431), + 119: uint16(40485), + 120: uint16(27572), + 121: uint16(34261), + 122: uint16(21589), + 123: uint16(20598), + 124: uint16(27812), + 125: uint16(21866), + 126: uint16(36276), + 127: uint16(29228), + 128: uint16(24085), + 129: uint16(24597), + 130: uint16(29750), + 131: uint16(25293), + 132: uint16(25490), + 133: uint16(29260), + 134: uint16(24472), + 135: uint16(28227), + 136: uint16(27966), + 137: uint16(25856), + 138: uint16(28504), + 139: uint16(30424), + 140: uint16(30928), + 141: uint16(30460), + 142: uint16(30036), + 143: uint16(21028), + 144: uint16(21467), + 145: uint16(20051), + 146: uint16(24222), + 147: uint16(26049), + 148: uint16(32810), + 149: uint16(32982), + 150: uint16(25243), + 151: uint16(21638), + 152: uint16(21032), + 153: uint16(28846), + 154: uint16(34957), + 155: uint16(36305), + 156: uint16(27873), + 157: uint16(21624), + 158: uint16(32986), + 159: uint16(22521), + 160: uint16(35060), + 161: uint16(36180), + 162: uint16(38506), + 163: uint16(37197), + 164: uint16(20329), + 165: uint16(27803), + 166: uint16(21943), + 167: uint16(30406), + 168: uint16(30768), + 169: uint16(25256), + 170: uint16(28921), + 171: uint16(28558), + 172: uint16(24429), + 173: uint16(34028), + 174: uint16(26842), + 175: uint16(30844), + 176: uint16(31735), + 177: uint16(33192), + 178: uint16(26379), + 179: uint16(40527), + 180: uint16(25447), + 181: uint16(30896), + 182: uint16(22383), + 183: uint16(30738), + 184: uint16(38713), + 185: uint16(25209), + 186: uint16(25259), + 187: uint16(21128), + 188: uint16(29749), + 189: uint16(27607), + }, + 69: { + 0: uint16(33386), + 1: uint16(33387), + 2: uint16(33388), + 3: uint16(33389), + 4: uint16(33393), + 5: uint16(33397), + 6: uint16(33398), + 7: uint16(33399), + 8: uint16(33400), + 9: uint16(33403), + 10: uint16(33404), + 11: uint16(33408), + 12: uint16(33409), + 13: uint16(33411), + 14: uint16(33413), + 15: uint16(33414), + 16: uint16(33415), + 17: uint16(33417), + 18: uint16(33420), + 19: uint16(33424), + 20: uint16(33427), + 21: uint16(33428), + 22: uint16(33429), + 23: uint16(33430), + 24: uint16(33434), + 25: uint16(33435), + 26: uint16(33438), + 27: uint16(33440), + 28: uint16(33442), + 29: uint16(33443), + 30: uint16(33447), + 31: uint16(33458), + 32: uint16(33461), + 33: uint16(33462), + 34: uint16(33466), + 35: uint16(33467), + 36: uint16(33468), + 37: uint16(33471), + 38: uint16(33472), + 39: uint16(33474), + 40: uint16(33475), + 41: uint16(33477), + 42: uint16(33478), + 43: uint16(33481), + 44: uint16(33488), + 45: uint16(33494), + 46: uint16(33497), + 47: uint16(33498), + 48: uint16(33501), + 49: uint16(33506), + 50: uint16(33511), + 51: uint16(33512), + 52: uint16(33513), + 53: uint16(33514), + 54: uint16(33516), + 55: uint16(33517), + 56: uint16(33518), + 57: uint16(33520), + 58: uint16(33522), + 59: uint16(33523), + 60: uint16(33525), + 61: uint16(33526), + 62: uint16(33528), + 63: uint16(33530), + 64: uint16(33532), + 65: uint16(33533), + 66: uint16(33534), + 67: uint16(33535), + 68: uint16(33536), + 69: uint16(33546), + 70: uint16(33547), + 71: uint16(33549), + 72: uint16(33552), + 73: uint16(33554), + 74: uint16(33555), + 75: uint16(33558), + 76: uint16(33560), + 77: uint16(33561), + 78: uint16(33565), + 79: uint16(33566), + 80: uint16(33567), + 81: uint16(33568), + 82: uint16(33569), + 83: uint16(33570), + 84: uint16(33571), + 85: uint16(33572), + 86: uint16(33573), + 87: uint16(33574), + 88: uint16(33577), + 89: uint16(33578), + 90: uint16(33582), + 91: uint16(33584), + 92: uint16(33586), + 93: uint16(33591), + 94: uint16(33595), + 95: uint16(33597), + 96: uint16(21860), + 97: uint16(33086), + 98: uint16(30130), + 99: uint16(30382), + 100: uint16(21305), + 101: uint16(30174), + 102: uint16(20731), + 103: uint16(23617), + 104: uint16(35692), + 105: uint16(31687), + 106: uint16(20559), + 107: uint16(29255), + 108: uint16(39575), + 109: uint16(39128), + 110: uint16(28418), + 111: uint16(29922), + 112: uint16(31080), + 113: uint16(25735), + 114: uint16(30629), + 115: uint16(25340), + 116: uint16(39057), + 117: uint16(36139), + 118: uint16(21697), + 119: uint16(32856), + 120: uint16(20050), + 121: uint16(22378), + 122: uint16(33529), + 123: uint16(33805), + 124: uint16(24179), + 125: uint16(20973), + 126: uint16(29942), + 127: uint16(35780), + 128: uint16(23631), + 129: uint16(22369), + 130: uint16(27900), + 131: uint16(39047), + 132: uint16(23110), + 133: uint16(30772), + 134: uint16(39748), + 135: uint16(36843), + 136: uint16(31893), + 137: uint16(21078), + 138: uint16(25169), + 139: uint16(38138), + 140: uint16(20166), + 141: uint16(33670), + 142: uint16(33889), + 143: uint16(33769), + 144: uint16(33970), + 145: uint16(22484), + 146: uint16(26420), + 147: uint16(22275), + 148: uint16(26222), + 149: uint16(28006), + 150: uint16(35889), + 151: uint16(26333), + 152: uint16(28689), + 153: uint16(26399), + 154: uint16(27450), + 155: uint16(26646), + 156: uint16(25114), + 157: uint16(22971), + 158: uint16(19971), + 159: uint16(20932), + 160: uint16(28422), + 161: uint16(26578), + 162: uint16(27791), + 163: uint16(20854), + 164: uint16(26827), + 165: uint16(22855), + 166: uint16(27495), + 167: uint16(30054), + 168: uint16(23822), + 169: uint16(33040), + 170: uint16(40784), + 171: uint16(26071), + 172: uint16(31048), + 173: uint16(31041), + 174: uint16(39569), + 175: uint16(36215), + 176: uint16(23682), + 177: uint16(20062), + 178: uint16(20225), + 179: uint16(21551), + 180: uint16(22865), + 181: uint16(30732), + 182: uint16(22120), + 183: uint16(27668), + 184: uint16(36804), + 185: uint16(24323), + 186: uint16(27773), + 187: uint16(27875), + 188: uint16(35755), + 189: uint16(25488), + }, + 70: { + 0: uint16(33598), + 1: uint16(33599), + 2: uint16(33601), + 3: uint16(33602), + 4: uint16(33604), + 5: uint16(33605), + 6: uint16(33608), + 7: uint16(33610), + 8: uint16(33611), + 9: uint16(33612), + 10: uint16(33613), + 11: uint16(33614), + 12: uint16(33619), + 13: uint16(33621), + 14: uint16(33622), + 15: uint16(33623), + 16: uint16(33624), + 17: uint16(33625), + 18: uint16(33629), + 19: uint16(33634), + 20: uint16(33648), + 21: uint16(33649), + 22: uint16(33650), + 23: uint16(33651), + 24: uint16(33652), + 25: uint16(33653), + 26: uint16(33654), + 27: uint16(33657), + 28: uint16(33658), + 29: uint16(33662), + 30: uint16(33663), + 31: uint16(33664), + 32: uint16(33665), + 33: uint16(33666), + 34: uint16(33667), + 35: uint16(33668), + 36: uint16(33671), + 37: uint16(33672), + 38: uint16(33674), + 39: uint16(33675), + 40: uint16(33676), + 41: uint16(33677), + 42: uint16(33679), + 43: uint16(33680), + 44: uint16(33681), + 45: uint16(33684), + 46: uint16(33685), + 47: uint16(33686), + 48: uint16(33687), + 49: uint16(33689), + 50: uint16(33690), + 51: uint16(33693), + 52: uint16(33695), + 53: uint16(33697), + 54: uint16(33698), + 55: uint16(33699), + 56: uint16(33700), + 57: uint16(33701), + 58: uint16(33702), + 59: uint16(33703), + 60: uint16(33708), + 61: uint16(33709), + 62: uint16(33710), + 63: uint16(33711), + 64: uint16(33717), + 65: uint16(33723), + 66: uint16(33726), + 67: uint16(33727), + 68: uint16(33730), + 69: uint16(33731), + 70: uint16(33732), + 71: uint16(33734), + 72: uint16(33736), + 73: uint16(33737), + 74: uint16(33739), + 75: uint16(33741), + 76: uint16(33742), + 77: uint16(33744), + 78: uint16(33745), + 79: uint16(33746), + 80: uint16(33747), + 81: uint16(33749), + 82: uint16(33751), + 83: uint16(33753), + 84: uint16(33754), + 85: uint16(33755), + 86: uint16(33758), + 87: uint16(33762), + 88: uint16(33763), + 89: uint16(33764), + 90: uint16(33766), + 91: uint16(33767), + 92: uint16(33768), + 93: uint16(33771), + 94: uint16(33772), + 95: uint16(33773), + 96: uint16(24688), + 97: uint16(27965), + 98: uint16(29301), + 99: uint16(25190), + 100: uint16(38030), + 101: uint16(38085), + 102: uint16(21315), + 103: uint16(36801), + 104: uint16(31614), + 105: uint16(20191), + 106: uint16(35878), + 107: uint16(20094), + 108: uint16(40660), + 109: uint16(38065), + 110: uint16(38067), + 111: uint16(21069), + 112: uint16(28508), + 113: uint16(36963), + 114: uint16(27973), + 115: uint16(35892), + 116: uint16(22545), + 117: uint16(23884), + 118: uint16(27424), + 119: uint16(27465), + 120: uint16(26538), + 121: uint16(21595), + 122: uint16(33108), + 123: uint16(32652), + 124: uint16(22681), + 125: uint16(34103), + 126: uint16(24378), + 127: uint16(25250), + 128: uint16(27207), + 129: uint16(38201), + 130: uint16(25970), + 131: uint16(24708), + 132: uint16(26725), + 133: uint16(30631), + 134: uint16(20052), + 135: uint16(20392), + 136: uint16(24039), + 137: uint16(38808), + 138: uint16(25772), + 139: uint16(32728), + 140: uint16(23789), + 141: uint16(20431), + 142: uint16(31373), + 143: uint16(20999), + 144: uint16(33540), + 145: uint16(19988), + 146: uint16(24623), + 147: uint16(31363), + 148: uint16(38054), + 149: uint16(20405), + 150: uint16(20146), + 151: uint16(31206), + 152: uint16(29748), + 153: uint16(21220), + 154: uint16(33465), + 155: uint16(25810), + 156: uint16(31165), + 157: uint16(23517), + 158: uint16(27777), + 159: uint16(38738), + 160: uint16(36731), + 161: uint16(27682), + 162: uint16(20542), + 163: uint16(21375), + 164: uint16(28165), + 165: uint16(25806), + 166: uint16(26228), + 167: uint16(27696), + 168: uint16(24773), + 169: uint16(39031), + 170: uint16(35831), + 171: uint16(24198), + 172: uint16(29756), + 173: uint16(31351), + 174: uint16(31179), + 175: uint16(19992), + 176: uint16(37041), + 177: uint16(29699), + 178: uint16(27714), + 179: uint16(22234), + 180: uint16(37195), + 181: uint16(27845), + 182: uint16(36235), + 183: uint16(21306), + 184: uint16(34502), + 185: uint16(26354), + 186: uint16(36527), + 187: uint16(23624), + 188: uint16(39537), + 189: uint16(28192), + }, + 71: { + 0: uint16(33774), + 1: uint16(33775), + 2: uint16(33779), + 3: uint16(33780), + 4: uint16(33781), + 5: uint16(33782), + 6: uint16(33783), + 7: uint16(33786), + 8: uint16(33787), + 9: uint16(33788), + 10: uint16(33790), + 11: uint16(33791), + 12: uint16(33792), + 13: uint16(33794), + 14: uint16(33797), + 15: uint16(33799), + 16: uint16(33800), + 17: uint16(33801), + 18: uint16(33802), + 19: uint16(33808), + 20: uint16(33810), + 21: uint16(33811), + 22: uint16(33812), + 23: uint16(33813), + 24: uint16(33814), + 25: uint16(33815), + 26: uint16(33817), + 27: uint16(33818), + 28: uint16(33819), + 29: uint16(33822), + 30: uint16(33823), + 31: uint16(33824), + 32: uint16(33825), + 33: uint16(33826), + 34: uint16(33827), + 35: uint16(33833), + 36: uint16(33834), + 37: uint16(33835), + 38: uint16(33836), + 39: uint16(33837), + 40: uint16(33838), + 41: uint16(33839), + 42: uint16(33840), + 43: uint16(33842), + 44: uint16(33843), + 45: uint16(33844), + 46: uint16(33845), + 47: uint16(33846), + 48: uint16(33847), + 49: uint16(33849), + 50: uint16(33850), + 51: uint16(33851), + 52: uint16(33854), + 53: uint16(33855), + 54: uint16(33856), + 55: uint16(33857), + 56: uint16(33858), + 57: uint16(33859), + 58: uint16(33860), + 59: uint16(33861), + 60: uint16(33863), + 61: uint16(33864), + 62: uint16(33865), + 63: uint16(33866), + 64: uint16(33867), + 65: uint16(33868), + 66: uint16(33869), + 67: uint16(33870), + 68: uint16(33871), + 69: uint16(33872), + 70: uint16(33874), + 71: uint16(33875), + 72: uint16(33876), + 73: uint16(33877), + 74: uint16(33878), + 75: uint16(33880), + 76: uint16(33885), + 77: uint16(33886), + 78: uint16(33887), + 79: uint16(33888), + 80: uint16(33890), + 81: uint16(33892), + 82: uint16(33893), + 83: uint16(33894), + 84: uint16(33895), + 85: uint16(33896), + 86: uint16(33898), + 87: uint16(33902), + 88: uint16(33903), + 89: uint16(33904), + 90: uint16(33906), + 91: uint16(33908), + 92: uint16(33911), + 93: uint16(33913), + 94: uint16(33915), + 95: uint16(33916), + 96: uint16(21462), + 97: uint16(23094), + 98: uint16(40843), + 99: uint16(36259), + 100: uint16(21435), + 101: uint16(22280), + 102: uint16(39079), + 103: uint16(26435), + 104: uint16(37275), + 105: uint16(27849), + 106: uint16(20840), + 107: uint16(30154), + 108: uint16(25331), + 109: uint16(29356), + 110: uint16(21048), + 111: uint16(21149), + 112: uint16(32570), + 113: uint16(28820), + 114: uint16(30264), + 115: uint16(21364), + 116: uint16(40522), + 117: uint16(27063), + 118: uint16(30830), + 119: uint16(38592), + 120: uint16(35033), + 121: uint16(32676), + 122: uint16(28982), + 123: uint16(29123), + 124: uint16(20873), + 125: uint16(26579), + 126: uint16(29924), + 127: uint16(22756), + 128: uint16(25880), + 129: uint16(22199), + 130: uint16(35753), + 131: uint16(39286), + 132: uint16(25200), + 133: uint16(32469), + 134: uint16(24825), + 135: uint16(28909), + 136: uint16(22764), + 137: uint16(20161), + 138: uint16(20154), + 139: uint16(24525), + 140: uint16(38887), + 141: uint16(20219), + 142: uint16(35748), + 143: uint16(20995), + 144: uint16(22922), + 145: uint16(32427), + 146: uint16(25172), + 147: uint16(20173), + 148: uint16(26085), + 149: uint16(25102), + 150: uint16(33592), + 151: uint16(33993), + 152: uint16(33635), + 153: uint16(34701), + 154: uint16(29076), + 155: uint16(28342), + 156: uint16(23481), + 157: uint16(32466), + 158: uint16(20887), + 159: uint16(25545), + 160: uint16(26580), + 161: uint16(32905), + 162: uint16(33593), + 163: uint16(34837), + 164: uint16(20754), + 165: uint16(23418), + 166: uint16(22914), + 167: uint16(36785), + 168: uint16(20083), + 169: uint16(27741), + 170: uint16(20837), + 171: uint16(35109), + 172: uint16(36719), + 173: uint16(38446), + 174: uint16(34122), + 175: uint16(29790), + 176: uint16(38160), + 177: uint16(38384), + 178: uint16(28070), + 179: uint16(33509), + 180: uint16(24369), + 181: uint16(25746), + 182: uint16(27922), + 183: uint16(33832), + 184: uint16(33134), + 185: uint16(40131), + 186: uint16(22622), + 187: uint16(36187), + 188: uint16(19977), + 189: uint16(21441), + }, + 72: { + 0: uint16(33917), + 1: uint16(33918), + 2: uint16(33919), + 3: uint16(33920), + 4: uint16(33921), + 5: uint16(33923), + 6: uint16(33924), + 7: uint16(33925), + 8: uint16(33926), + 9: uint16(33930), + 10: uint16(33933), + 11: uint16(33935), + 12: uint16(33936), + 13: uint16(33937), + 14: uint16(33938), + 15: uint16(33939), + 16: uint16(33940), + 17: uint16(33941), + 18: uint16(33942), + 19: uint16(33944), + 20: uint16(33946), + 21: uint16(33947), + 22: uint16(33949), + 23: uint16(33950), + 24: uint16(33951), + 25: uint16(33952), + 26: uint16(33954), + 27: uint16(33955), + 28: uint16(33956), + 29: uint16(33957), + 30: uint16(33958), + 31: uint16(33959), + 32: uint16(33960), + 33: uint16(33961), + 34: uint16(33962), + 35: uint16(33963), + 36: uint16(33964), + 37: uint16(33965), + 38: uint16(33966), + 39: uint16(33968), + 40: uint16(33969), + 41: uint16(33971), + 42: uint16(33973), + 43: uint16(33974), + 44: uint16(33975), + 45: uint16(33979), + 46: uint16(33980), + 47: uint16(33982), + 48: uint16(33984), + 49: uint16(33986), + 50: uint16(33987), + 51: uint16(33989), + 52: uint16(33990), + 53: uint16(33991), + 54: uint16(33992), + 55: uint16(33995), + 56: uint16(33996), + 57: uint16(33998), + 58: uint16(33999), + 59: uint16(34002), + 60: uint16(34004), + 61: uint16(34005), + 62: uint16(34007), + 63: uint16(34008), + 64: uint16(34009), + 65: uint16(34010), + 66: uint16(34011), + 67: uint16(34012), + 68: uint16(34014), + 69: uint16(34017), + 70: uint16(34018), + 71: uint16(34020), + 72: uint16(34023), + 73: uint16(34024), + 74: uint16(34025), + 75: uint16(34026), + 76: uint16(34027), + 77: uint16(34029), + 78: uint16(34030), + 79: uint16(34031), + 80: uint16(34033), + 81: uint16(34034), + 82: uint16(34035), + 83: uint16(34036), + 84: uint16(34037), + 85: uint16(34038), + 86: uint16(34039), + 87: uint16(34040), + 88: uint16(34041), + 89: uint16(34042), + 90: uint16(34043), + 91: uint16(34045), + 92: uint16(34046), + 93: uint16(34048), + 94: uint16(34049), + 95: uint16(34050), + 96: uint16(20254), + 97: uint16(25955), + 98: uint16(26705), + 99: uint16(21971), + 100: uint16(20007), + 101: uint16(25620), + 102: uint16(39578), + 103: uint16(25195), + 104: uint16(23234), + 105: uint16(29791), + 106: uint16(33394), + 107: uint16(28073), + 108: uint16(26862), + 109: uint16(20711), + 110: uint16(33678), + 111: uint16(30722), + 112: uint16(26432), + 113: uint16(21049), + 114: uint16(27801), + 115: uint16(32433), + 116: uint16(20667), + 117: uint16(21861), + 118: uint16(29022), + 119: uint16(31579), + 120: uint16(26194), + 121: uint16(29642), + 122: uint16(33515), + 123: uint16(26441), + 124: uint16(23665), + 125: uint16(21024), + 126: uint16(29053), + 127: uint16(34923), + 128: uint16(38378), + 129: uint16(38485), + 130: uint16(25797), + 131: uint16(36193), + 132: uint16(33203), + 133: uint16(21892), + 134: uint16(27733), + 135: uint16(25159), + 136: uint16(32558), + 137: uint16(22674), + 138: uint16(20260), + 139: uint16(21830), + 140: uint16(36175), + 141: uint16(26188), + 142: uint16(19978), + 143: uint16(23578), + 144: uint16(35059), + 145: uint16(26786), + 146: uint16(25422), + 147: uint16(31245), + 148: uint16(28903), + 149: uint16(33421), + 150: uint16(21242), + 151: uint16(38902), + 152: uint16(23569), + 153: uint16(21736), + 154: uint16(37045), + 155: uint16(32461), + 156: uint16(22882), + 157: uint16(36170), + 158: uint16(34503), + 159: uint16(33292), + 160: uint16(33293), + 161: uint16(36198), + 162: uint16(25668), + 163: uint16(23556), + 164: uint16(24913), + 165: uint16(28041), + 166: uint16(31038), + 167: uint16(35774), + 168: uint16(30775), + 169: uint16(30003), + 170: uint16(21627), + 171: uint16(20280), + 172: uint16(36523), + 173: uint16(28145), + 174: uint16(23072), + 175: uint16(32453), + 176: uint16(31070), + 177: uint16(27784), + 178: uint16(23457), + 179: uint16(23158), + 180: uint16(29978), + 181: uint16(32958), + 182: uint16(24910), + 183: uint16(28183), + 184: uint16(22768), + 185: uint16(29983), + 186: uint16(29989), + 187: uint16(29298), + 188: uint16(21319), + 189: uint16(32499), + }, + 73: { + 0: uint16(34051), + 1: uint16(34052), + 2: uint16(34053), + 3: uint16(34054), + 4: uint16(34055), + 5: uint16(34056), + 6: uint16(34057), + 7: uint16(34058), + 8: uint16(34059), + 9: uint16(34061), + 10: uint16(34062), + 11: uint16(34063), + 12: uint16(34064), + 13: uint16(34066), + 14: uint16(34068), + 15: uint16(34069), + 16: uint16(34070), + 17: uint16(34072), + 18: uint16(34073), + 19: uint16(34075), + 20: uint16(34076), + 21: uint16(34077), + 22: uint16(34078), + 23: uint16(34080), + 24: uint16(34082), + 25: uint16(34083), + 26: uint16(34084), + 27: uint16(34085), + 28: uint16(34086), + 29: uint16(34087), + 30: uint16(34088), + 31: uint16(34089), + 32: uint16(34090), + 33: uint16(34093), + 34: uint16(34094), + 35: uint16(34095), + 36: uint16(34096), + 37: uint16(34097), + 38: uint16(34098), + 39: uint16(34099), + 40: uint16(34100), + 41: uint16(34101), + 42: uint16(34102), + 43: uint16(34110), + 44: uint16(34111), + 45: uint16(34112), + 46: uint16(34113), + 47: uint16(34114), + 48: uint16(34116), + 49: uint16(34117), + 50: uint16(34118), + 51: uint16(34119), + 52: uint16(34123), + 53: uint16(34124), + 54: uint16(34125), + 55: uint16(34126), + 56: uint16(34127), + 57: uint16(34128), + 58: uint16(34129), + 59: uint16(34130), + 60: uint16(34131), + 61: uint16(34132), + 62: uint16(34133), + 63: uint16(34135), + 64: uint16(34136), + 65: uint16(34138), + 66: uint16(34139), + 67: uint16(34140), + 68: uint16(34141), + 69: uint16(34143), + 70: uint16(34144), + 71: uint16(34145), + 72: uint16(34146), + 73: uint16(34147), + 74: uint16(34149), + 75: uint16(34150), + 76: uint16(34151), + 77: uint16(34153), + 78: uint16(34154), + 79: uint16(34155), + 80: uint16(34156), + 81: uint16(34157), + 82: uint16(34158), + 83: uint16(34159), + 84: uint16(34160), + 85: uint16(34161), + 86: uint16(34163), + 87: uint16(34165), + 88: uint16(34166), + 89: uint16(34167), + 90: uint16(34168), + 91: uint16(34172), + 92: uint16(34173), + 93: uint16(34175), + 94: uint16(34176), + 95: uint16(34177), + 96: uint16(30465), + 97: uint16(30427), + 98: uint16(21097), + 99: uint16(32988), + 100: uint16(22307), + 101: uint16(24072), + 102: uint16(22833), + 103: uint16(29422), + 104: uint16(26045), + 105: uint16(28287), + 106: uint16(35799), + 107: uint16(23608), + 108: uint16(34417), + 109: uint16(21313), + 110: uint16(30707), + 111: uint16(25342), + 112: uint16(26102), + 113: uint16(20160), + 114: uint16(39135), + 115: uint16(34432), + 116: uint16(23454), + 117: uint16(35782), + 118: uint16(21490), + 119: uint16(30690), + 120: uint16(20351), + 121: uint16(23630), + 122: uint16(39542), + 123: uint16(22987), + 124: uint16(24335), + 125: uint16(31034), + 126: uint16(22763), + 127: uint16(19990), + 128: uint16(26623), + 129: uint16(20107), + 130: uint16(25325), + 131: uint16(35475), + 132: uint16(36893), + 133: uint16(21183), + 134: uint16(26159), + 135: uint16(21980), + 136: uint16(22124), + 137: uint16(36866), + 138: uint16(20181), + 139: uint16(20365), + 140: uint16(37322), + 141: uint16(39280), + 142: uint16(27663), + 143: uint16(24066), + 144: uint16(24643), + 145: uint16(23460), + 146: uint16(35270), + 147: uint16(35797), + 148: uint16(25910), + 149: uint16(25163), + 150: uint16(39318), + 151: uint16(23432), + 152: uint16(23551), + 153: uint16(25480), + 154: uint16(21806), + 155: uint16(21463), + 156: uint16(30246), + 157: uint16(20861), + 158: uint16(34092), + 159: uint16(26530), + 160: uint16(26803), + 161: uint16(27530), + 162: uint16(25234), + 163: uint16(36755), + 164: uint16(21460), + 165: uint16(33298), + 166: uint16(28113), + 167: uint16(30095), + 168: uint16(20070), + 169: uint16(36174), + 170: uint16(23408), + 171: uint16(29087), + 172: uint16(34223), + 173: uint16(26257), + 174: uint16(26329), + 175: uint16(32626), + 176: uint16(34560), + 177: uint16(40653), + 178: uint16(40736), + 179: uint16(23646), + 180: uint16(26415), + 181: uint16(36848), + 182: uint16(26641), + 183: uint16(26463), + 184: uint16(25101), + 185: uint16(31446), + 186: uint16(22661), + 187: uint16(24246), + 188: uint16(25968), + 189: uint16(28465), + }, + 74: { + 0: uint16(34178), + 1: uint16(34179), + 2: uint16(34182), + 3: uint16(34184), + 4: uint16(34185), + 5: uint16(34186), + 6: uint16(34187), + 7: uint16(34188), + 8: uint16(34189), + 9: uint16(34190), + 10: uint16(34192), + 11: uint16(34193), + 12: uint16(34194), + 13: uint16(34195), + 14: uint16(34196), + 15: uint16(34197), + 16: uint16(34198), + 17: uint16(34199), + 18: uint16(34200), + 19: uint16(34201), + 20: uint16(34202), + 21: uint16(34205), + 22: uint16(34206), + 23: uint16(34207), + 24: uint16(34208), + 25: uint16(34209), + 26: uint16(34210), + 27: uint16(34211), + 28: uint16(34213), + 29: uint16(34214), + 30: uint16(34215), + 31: uint16(34217), + 32: uint16(34219), + 33: uint16(34220), + 34: uint16(34221), + 35: uint16(34225), + 36: uint16(34226), + 37: uint16(34227), + 38: uint16(34228), + 39: uint16(34229), + 40: uint16(34230), + 41: uint16(34232), + 42: uint16(34234), + 43: uint16(34235), + 44: uint16(34236), + 45: uint16(34237), + 46: uint16(34238), + 47: uint16(34239), + 48: uint16(34240), + 49: uint16(34242), + 50: uint16(34243), + 51: uint16(34244), + 52: uint16(34245), + 53: uint16(34246), + 54: uint16(34247), + 55: uint16(34248), + 56: uint16(34250), + 57: uint16(34251), + 58: uint16(34252), + 59: uint16(34253), + 60: uint16(34254), + 61: uint16(34257), + 62: uint16(34258), + 63: uint16(34260), + 64: uint16(34262), + 65: uint16(34263), + 66: uint16(34264), + 67: uint16(34265), + 68: uint16(34266), + 69: uint16(34267), + 70: uint16(34269), + 71: uint16(34270), + 72: uint16(34271), + 73: uint16(34272), + 74: uint16(34273), + 75: uint16(34274), + 76: uint16(34275), + 77: uint16(34277), + 78: uint16(34278), + 79: uint16(34279), + 80: uint16(34280), + 81: uint16(34282), + 82: uint16(34283), + 83: uint16(34284), + 84: uint16(34285), + 85: uint16(34286), + 86: uint16(34287), + 87: uint16(34288), + 88: uint16(34289), + 89: uint16(34290), + 90: uint16(34291), + 91: uint16(34292), + 92: uint16(34293), + 93: uint16(34294), + 94: uint16(34295), + 95: uint16(34296), + 96: uint16(24661), + 97: uint16(21047), + 98: uint16(32781), + 99: uint16(25684), + 100: uint16(34928), + 101: uint16(29993), + 102: uint16(24069), + 103: uint16(26643), + 104: uint16(25332), + 105: uint16(38684), + 106: uint16(21452), + 107: uint16(29245), + 108: uint16(35841), + 109: uint16(27700), + 110: uint16(30561), + 111: uint16(31246), + 112: uint16(21550), + 113: uint16(30636), + 114: uint16(39034), + 115: uint16(33308), + 116: uint16(35828), + 117: uint16(30805), + 118: uint16(26388), + 119: uint16(28865), + 120: uint16(26031), + 121: uint16(25749), + 122: uint16(22070), + 123: uint16(24605), + 124: uint16(31169), + 125: uint16(21496), + 126: uint16(19997), + 127: uint16(27515), + 128: uint16(32902), + 129: uint16(23546), + 130: uint16(21987), + 131: uint16(22235), + 132: uint16(20282), + 133: uint16(20284), + 134: uint16(39282), + 135: uint16(24051), + 136: uint16(26494), + 137: uint16(32824), + 138: uint16(24578), + 139: uint16(39042), + 140: uint16(36865), + 141: uint16(23435), + 142: uint16(35772), + 143: uint16(35829), + 144: uint16(25628), + 145: uint16(33368), + 146: uint16(25822), + 147: uint16(22013), + 148: uint16(33487), + 149: uint16(37221), + 150: uint16(20439), + 151: uint16(32032), + 152: uint16(36895), + 153: uint16(31903), + 154: uint16(20723), + 155: uint16(22609), + 156: uint16(28335), + 157: uint16(23487), + 158: uint16(35785), + 159: uint16(32899), + 160: uint16(37240), + 161: uint16(33948), + 162: uint16(31639), + 163: uint16(34429), + 164: uint16(38539), + 165: uint16(38543), + 166: uint16(32485), + 167: uint16(39635), + 168: uint16(30862), + 169: uint16(23681), + 170: uint16(31319), + 171: uint16(36930), + 172: uint16(38567), + 173: uint16(31071), + 174: uint16(23385), + 175: uint16(25439), + 176: uint16(31499), + 177: uint16(34001), + 178: uint16(26797), + 179: uint16(21766), + 180: uint16(32553), + 181: uint16(29712), + 182: uint16(32034), + 183: uint16(38145), + 184: uint16(25152), + 185: uint16(22604), + 186: uint16(20182), + 187: uint16(23427), + 188: uint16(22905), + 189: uint16(22612), + }, + 75: { + 0: uint16(34297), + 1: uint16(34298), + 2: uint16(34300), + 3: uint16(34301), + 4: uint16(34302), + 5: uint16(34304), + 6: uint16(34305), + 7: uint16(34306), + 8: uint16(34307), + 9: uint16(34308), + 10: uint16(34310), + 11: uint16(34311), + 12: uint16(34312), + 13: uint16(34313), + 14: uint16(34314), + 15: uint16(34315), + 16: uint16(34316), + 17: uint16(34317), + 18: uint16(34318), + 19: uint16(34319), + 20: uint16(34320), + 21: uint16(34322), + 22: uint16(34323), + 23: uint16(34324), + 24: uint16(34325), + 25: uint16(34327), + 26: uint16(34328), + 27: uint16(34329), + 28: uint16(34330), + 29: uint16(34331), + 30: uint16(34332), + 31: uint16(34333), + 32: uint16(34334), + 33: uint16(34335), + 34: uint16(34336), + 35: uint16(34337), + 36: uint16(34338), + 37: uint16(34339), + 38: uint16(34340), + 39: uint16(34341), + 40: uint16(34342), + 41: uint16(34344), + 42: uint16(34346), + 43: uint16(34347), + 44: uint16(34348), + 45: uint16(34349), + 46: uint16(34350), + 47: uint16(34351), + 48: uint16(34352), + 49: uint16(34353), + 50: uint16(34354), + 51: uint16(34355), + 52: uint16(34356), + 53: uint16(34357), + 54: uint16(34358), + 55: uint16(34359), + 56: uint16(34361), + 57: uint16(34362), + 58: uint16(34363), + 59: uint16(34365), + 60: uint16(34366), + 61: uint16(34367), + 62: uint16(34368), + 63: uint16(34369), + 64: uint16(34370), + 65: uint16(34371), + 66: uint16(34372), + 67: uint16(34373), + 68: uint16(34374), + 69: uint16(34375), + 70: uint16(34376), + 71: uint16(34377), + 72: uint16(34378), + 73: uint16(34379), + 74: uint16(34380), + 75: uint16(34386), + 76: uint16(34387), + 77: uint16(34389), + 78: uint16(34390), + 79: uint16(34391), + 80: uint16(34392), + 81: uint16(34393), + 82: uint16(34395), + 83: uint16(34396), + 84: uint16(34397), + 85: uint16(34399), + 86: uint16(34400), + 87: uint16(34401), + 88: uint16(34403), + 89: uint16(34404), + 90: uint16(34405), + 91: uint16(34406), + 92: uint16(34407), + 93: uint16(34408), + 94: uint16(34409), + 95: uint16(34410), + 96: uint16(29549), + 97: uint16(25374), + 98: uint16(36427), + 99: uint16(36367), + 100: uint16(32974), + 101: uint16(33492), + 102: uint16(25260), + 103: uint16(21488), + 104: uint16(27888), + 105: uint16(37214), + 106: uint16(22826), + 107: uint16(24577), + 108: uint16(27760), + 109: uint16(22349), + 110: uint16(25674), + 111: uint16(36138), + 112: uint16(30251), + 113: uint16(28393), + 114: uint16(22363), + 115: uint16(27264), + 116: uint16(30192), + 117: uint16(28525), + 118: uint16(35885), + 119: uint16(35848), + 120: uint16(22374), + 121: uint16(27631), + 122: uint16(34962), + 123: uint16(30899), + 124: uint16(25506), + 125: uint16(21497), + 126: uint16(28845), + 127: uint16(27748), + 128: uint16(22616), + 129: uint16(25642), + 130: uint16(22530), + 131: uint16(26848), + 132: uint16(33179), + 133: uint16(21776), + 134: uint16(31958), + 135: uint16(20504), + 136: uint16(36538), + 137: uint16(28108), + 138: uint16(36255), + 139: uint16(28907), + 140: uint16(25487), + 141: uint16(28059), + 142: uint16(28372), + 143: uint16(32486), + 144: uint16(33796), + 145: uint16(26691), + 146: uint16(36867), + 147: uint16(28120), + 148: uint16(38518), + 149: uint16(35752), + 150: uint16(22871), + 151: uint16(29305), + 152: uint16(34276), + 153: uint16(33150), + 154: uint16(30140), + 155: uint16(35466), + 156: uint16(26799), + 157: uint16(21076), + 158: uint16(36386), + 159: uint16(38161), + 160: uint16(25552), + 161: uint16(39064), + 162: uint16(36420), + 163: uint16(21884), + 164: uint16(20307), + 165: uint16(26367), + 166: uint16(22159), + 167: uint16(24789), + 168: uint16(28053), + 169: uint16(21059), + 170: uint16(23625), + 171: uint16(22825), + 172: uint16(28155), + 173: uint16(22635), + 174: uint16(30000), + 175: uint16(29980), + 176: uint16(24684), + 177: uint16(33300), + 178: uint16(33094), + 179: uint16(25361), + 180: uint16(26465), + 181: uint16(36834), + 182: uint16(30522), + 183: uint16(36339), + 184: uint16(36148), + 185: uint16(38081), + 186: uint16(24086), + 187: uint16(21381), + 188: uint16(21548), + 189: uint16(28867), + }, + 76: { + 0: uint16(34413), + 1: uint16(34415), + 2: uint16(34416), + 3: uint16(34418), + 4: uint16(34419), + 5: uint16(34420), + 6: uint16(34421), + 7: uint16(34422), + 8: uint16(34423), + 9: uint16(34424), + 10: uint16(34435), + 11: uint16(34436), + 12: uint16(34437), + 13: uint16(34438), + 14: uint16(34439), + 15: uint16(34440), + 16: uint16(34441), + 17: uint16(34446), + 18: uint16(34447), + 19: uint16(34448), + 20: uint16(34449), + 21: uint16(34450), + 22: uint16(34452), + 23: uint16(34454), + 24: uint16(34455), + 25: uint16(34456), + 26: uint16(34457), + 27: uint16(34458), + 28: uint16(34459), + 29: uint16(34462), + 30: uint16(34463), + 31: uint16(34464), + 32: uint16(34465), + 33: uint16(34466), + 34: uint16(34469), + 35: uint16(34470), + 36: uint16(34475), + 37: uint16(34477), + 38: uint16(34478), + 39: uint16(34482), + 40: uint16(34483), + 41: uint16(34487), + 42: uint16(34488), + 43: uint16(34489), + 44: uint16(34491), + 45: uint16(34492), + 46: uint16(34493), + 47: uint16(34494), + 48: uint16(34495), + 49: uint16(34497), + 50: uint16(34498), + 51: uint16(34499), + 52: uint16(34501), + 53: uint16(34504), + 54: uint16(34508), + 55: uint16(34509), + 56: uint16(34514), + 57: uint16(34515), + 58: uint16(34517), + 59: uint16(34518), + 60: uint16(34519), + 61: uint16(34522), + 62: uint16(34524), + 63: uint16(34525), + 64: uint16(34528), + 65: uint16(34529), + 66: uint16(34530), + 67: uint16(34531), + 68: uint16(34533), + 69: uint16(34534), + 70: uint16(34535), + 71: uint16(34536), + 72: uint16(34538), + 73: uint16(34539), + 74: uint16(34540), + 75: uint16(34543), + 76: uint16(34549), + 77: uint16(34550), + 78: uint16(34551), + 79: uint16(34554), + 80: uint16(34555), + 81: uint16(34556), + 82: uint16(34557), + 83: uint16(34559), + 84: uint16(34561), + 85: uint16(34564), + 86: uint16(34565), + 87: uint16(34566), + 88: uint16(34571), + 89: uint16(34572), + 90: uint16(34574), + 91: uint16(34575), + 92: uint16(34576), + 93: uint16(34577), + 94: uint16(34580), + 95: uint16(34582), + 96: uint16(27712), + 97: uint16(24311), + 98: uint16(20572), + 99: uint16(20141), + 100: uint16(24237), + 101: uint16(25402), + 102: uint16(33351), + 103: uint16(36890), + 104: uint16(26704), + 105: uint16(37230), + 106: uint16(30643), + 107: uint16(21516), + 108: uint16(38108), + 109: uint16(24420), + 110: uint16(31461), + 111: uint16(26742), + 112: uint16(25413), + 113: uint16(31570), + 114: uint16(32479), + 115: uint16(30171), + 116: uint16(20599), + 117: uint16(25237), + 118: uint16(22836), + 119: uint16(36879), + 120: uint16(20984), + 121: uint16(31171), + 122: uint16(31361), + 123: uint16(22270), + 124: uint16(24466), + 125: uint16(36884), + 126: uint16(28034), + 127: uint16(23648), + 128: uint16(22303), + 129: uint16(21520), + 130: uint16(20820), + 131: uint16(28237), + 132: uint16(22242), + 133: uint16(25512), + 134: uint16(39059), + 135: uint16(33151), + 136: uint16(34581), + 137: uint16(35114), + 138: uint16(36864), + 139: uint16(21534), + 140: uint16(23663), + 141: uint16(33216), + 142: uint16(25302), + 143: uint16(25176), + 144: uint16(33073), + 145: uint16(40501), + 146: uint16(38464), + 147: uint16(39534), + 148: uint16(39548), + 149: uint16(26925), + 150: uint16(22949), + 151: uint16(25299), + 152: uint16(21822), + 153: uint16(25366), + 154: uint16(21703), + 155: uint16(34521), + 156: uint16(27964), + 157: uint16(23043), + 158: uint16(29926), + 159: uint16(34972), + 160: uint16(27498), + 161: uint16(22806), + 162: uint16(35916), + 163: uint16(24367), + 164: uint16(28286), + 165: uint16(29609), + 166: uint16(39037), + 167: uint16(20024), + 168: uint16(28919), + 169: uint16(23436), + 170: uint16(30871), + 171: uint16(25405), + 172: uint16(26202), + 173: uint16(30358), + 174: uint16(24779), + 175: uint16(23451), + 176: uint16(23113), + 177: uint16(19975), + 178: uint16(33109), + 179: uint16(27754), + 180: uint16(29579), + 181: uint16(20129), + 182: uint16(26505), + 183: uint16(32593), + 184: uint16(24448), + 185: uint16(26106), + 186: uint16(26395), + 187: uint16(24536), + 188: uint16(22916), + 189: uint16(23041), + }, + 77: { + 0: uint16(34585), + 1: uint16(34587), + 2: uint16(34589), + 3: uint16(34591), + 4: uint16(34592), + 5: uint16(34596), + 6: uint16(34598), + 7: uint16(34599), + 8: uint16(34600), + 9: uint16(34602), + 10: uint16(34603), + 11: uint16(34604), + 12: uint16(34605), + 13: uint16(34607), + 14: uint16(34608), + 15: uint16(34610), + 16: uint16(34611), + 17: uint16(34613), + 18: uint16(34614), + 19: uint16(34616), + 20: uint16(34617), + 21: uint16(34618), + 22: uint16(34620), + 23: uint16(34621), + 24: uint16(34624), + 25: uint16(34625), + 26: uint16(34626), + 27: uint16(34627), + 28: uint16(34628), + 29: uint16(34629), + 30: uint16(34630), + 31: uint16(34634), + 32: uint16(34635), + 33: uint16(34637), + 34: uint16(34639), + 35: uint16(34640), + 36: uint16(34641), + 37: uint16(34642), + 38: uint16(34644), + 39: uint16(34645), + 40: uint16(34646), + 41: uint16(34648), + 42: uint16(34650), + 43: uint16(34651), + 44: uint16(34652), + 45: uint16(34653), + 46: uint16(34654), + 47: uint16(34655), + 48: uint16(34657), + 49: uint16(34658), + 50: uint16(34662), + 51: uint16(34663), + 52: uint16(34664), + 53: uint16(34665), + 54: uint16(34666), + 55: uint16(34667), + 56: uint16(34668), + 57: uint16(34669), + 58: uint16(34671), + 59: uint16(34673), + 60: uint16(34674), + 61: uint16(34675), + 62: uint16(34677), + 63: uint16(34679), + 64: uint16(34680), + 65: uint16(34681), + 66: uint16(34682), + 67: uint16(34687), + 68: uint16(34688), + 69: uint16(34689), + 70: uint16(34692), + 71: uint16(34694), + 72: uint16(34695), + 73: uint16(34697), + 74: uint16(34698), + 75: uint16(34700), + 76: uint16(34702), + 77: uint16(34703), + 78: uint16(34704), + 79: uint16(34705), + 80: uint16(34706), + 81: uint16(34708), + 82: uint16(34709), + 83: uint16(34710), + 84: uint16(34712), + 85: uint16(34713), + 86: uint16(34714), + 87: uint16(34715), + 88: uint16(34716), + 89: uint16(34717), + 90: uint16(34718), + 91: uint16(34720), + 92: uint16(34721), + 93: uint16(34722), + 94: uint16(34723), + 95: uint16(34724), + 96: uint16(24013), + 97: uint16(24494), + 98: uint16(21361), + 99: uint16(38886), + 100: uint16(36829), + 101: uint16(26693), + 102: uint16(22260), + 103: uint16(21807), + 104: uint16(24799), + 105: uint16(20026), + 106: uint16(28493), + 107: uint16(32500), + 108: uint16(33479), + 109: uint16(33806), + 110: uint16(22996), + 111: uint16(20255), + 112: uint16(20266), + 113: uint16(23614), + 114: uint16(32428), + 115: uint16(26410), + 116: uint16(34074), + 117: uint16(21619), + 118: uint16(30031), + 119: uint16(32963), + 120: uint16(21890), + 121: uint16(39759), + 122: uint16(20301), + 123: uint16(28205), + 124: uint16(35859), + 125: uint16(23561), + 126: uint16(24944), + 127: uint16(21355), + 128: uint16(30239), + 129: uint16(28201), + 130: uint16(34442), + 131: uint16(25991), + 132: uint16(38395), + 133: uint16(32441), + 134: uint16(21563), + 135: uint16(31283), + 136: uint16(32010), + 137: uint16(38382), + 138: uint16(21985), + 139: uint16(32705), + 140: uint16(29934), + 141: uint16(25373), + 142: uint16(34583), + 143: uint16(28065), + 144: uint16(31389), + 145: uint16(25105), + 146: uint16(26017), + 147: uint16(21351), + 148: uint16(25569), + 149: uint16(27779), + 150: uint16(24043), + 151: uint16(21596), + 152: uint16(38056), + 153: uint16(20044), + 154: uint16(27745), + 155: uint16(35820), + 156: uint16(23627), + 157: uint16(26080), + 158: uint16(33436), + 159: uint16(26791), + 160: uint16(21566), + 161: uint16(21556), + 162: uint16(27595), + 163: uint16(27494), + 164: uint16(20116), + 165: uint16(25410), + 166: uint16(21320), + 167: uint16(33310), + 168: uint16(20237), + 169: uint16(20398), + 170: uint16(22366), + 171: uint16(25098), + 172: uint16(38654), + 173: uint16(26212), + 174: uint16(29289), + 175: uint16(21247), + 176: uint16(21153), + 177: uint16(24735), + 178: uint16(35823), + 179: uint16(26132), + 180: uint16(29081), + 181: uint16(26512), + 182: uint16(35199), + 183: uint16(30802), + 184: uint16(30717), + 185: uint16(26224), + 186: uint16(22075), + 187: uint16(21560), + 188: uint16(38177), + 189: uint16(29306), + }, + 78: { + 0: uint16(34725), + 1: uint16(34726), + 2: uint16(34727), + 3: uint16(34729), + 4: uint16(34730), + 5: uint16(34734), + 6: uint16(34736), + 7: uint16(34737), + 8: uint16(34738), + 9: uint16(34740), + 10: uint16(34742), + 11: uint16(34743), + 12: uint16(34744), + 13: uint16(34745), + 14: uint16(34747), + 15: uint16(34748), + 16: uint16(34750), + 17: uint16(34751), + 18: uint16(34753), + 19: uint16(34754), + 20: uint16(34755), + 21: uint16(34756), + 22: uint16(34757), + 23: uint16(34759), + 24: uint16(34760), + 25: uint16(34761), + 26: uint16(34764), + 27: uint16(34765), + 28: uint16(34766), + 29: uint16(34767), + 30: uint16(34768), + 31: uint16(34772), + 32: uint16(34773), + 33: uint16(34774), + 34: uint16(34775), + 35: uint16(34776), + 36: uint16(34777), + 37: uint16(34778), + 38: uint16(34780), + 39: uint16(34781), + 40: uint16(34782), + 41: uint16(34783), + 42: uint16(34785), + 43: uint16(34786), + 44: uint16(34787), + 45: uint16(34788), + 46: uint16(34790), + 47: uint16(34791), + 48: uint16(34792), + 49: uint16(34793), + 50: uint16(34795), + 51: uint16(34796), + 52: uint16(34797), + 53: uint16(34799), + 54: uint16(34800), + 55: uint16(34801), + 56: uint16(34802), + 57: uint16(34803), + 58: uint16(34804), + 59: uint16(34805), + 60: uint16(34806), + 61: uint16(34807), + 62: uint16(34808), + 63: uint16(34810), + 64: uint16(34811), + 65: uint16(34812), + 66: uint16(34813), + 67: uint16(34815), + 68: uint16(34816), + 69: uint16(34817), + 70: uint16(34818), + 71: uint16(34820), + 72: uint16(34821), + 73: uint16(34822), + 74: uint16(34823), + 75: uint16(34824), + 76: uint16(34825), + 77: uint16(34827), + 78: uint16(34828), + 79: uint16(34829), + 80: uint16(34830), + 81: uint16(34831), + 82: uint16(34832), + 83: uint16(34833), + 84: uint16(34834), + 85: uint16(34836), + 86: uint16(34839), + 87: uint16(34840), + 88: uint16(34841), + 89: uint16(34842), + 90: uint16(34844), + 91: uint16(34845), + 92: uint16(34846), + 93: uint16(34847), + 94: uint16(34848), + 95: uint16(34851), + 96: uint16(31232), + 97: uint16(24687), + 98: uint16(24076), + 99: uint16(24713), + 100: uint16(33181), + 101: uint16(22805), + 102: uint16(24796), + 103: uint16(29060), + 104: uint16(28911), + 105: uint16(28330), + 106: uint16(27728), + 107: uint16(29312), + 108: uint16(27268), + 109: uint16(34989), + 110: uint16(24109), + 111: uint16(20064), + 112: uint16(23219), + 113: uint16(21916), + 114: uint16(38115), + 115: uint16(27927), + 116: uint16(31995), + 117: uint16(38553), + 118: uint16(25103), + 119: uint16(32454), + 120: uint16(30606), + 121: uint16(34430), + 122: uint16(21283), + 123: uint16(38686), + 124: uint16(36758), + 125: uint16(26247), + 126: uint16(23777), + 127: uint16(20384), + 128: uint16(29421), + 129: uint16(19979), + 130: uint16(21414), + 131: uint16(22799), + 132: uint16(21523), + 133: uint16(25472), + 134: uint16(38184), + 135: uint16(20808), + 136: uint16(20185), + 137: uint16(40092), + 138: uint16(32420), + 139: uint16(21688), + 140: uint16(36132), + 141: uint16(34900), + 142: uint16(33335), + 143: uint16(38386), + 144: uint16(28046), + 145: uint16(24358), + 146: uint16(23244), + 147: uint16(26174), + 148: uint16(38505), + 149: uint16(29616), + 150: uint16(29486), + 151: uint16(21439), + 152: uint16(33146), + 153: uint16(39301), + 154: uint16(32673), + 155: uint16(23466), + 156: uint16(38519), + 157: uint16(38480), + 158: uint16(32447), + 159: uint16(30456), + 160: uint16(21410), + 161: uint16(38262), + 162: uint16(39321), + 163: uint16(31665), + 164: uint16(35140), + 165: uint16(28248), + 166: uint16(20065), + 167: uint16(32724), + 168: uint16(31077), + 169: uint16(35814), + 170: uint16(24819), + 171: uint16(21709), + 172: uint16(20139), + 173: uint16(39033), + 174: uint16(24055), + 175: uint16(27233), + 176: uint16(20687), + 177: uint16(21521), + 178: uint16(35937), + 179: uint16(33831), + 180: uint16(30813), + 181: uint16(38660), + 182: uint16(21066), + 183: uint16(21742), + 184: uint16(22179), + 185: uint16(38144), + 186: uint16(28040), + 187: uint16(23477), + 188: uint16(28102), + 189: uint16(26195), + }, + 79: { + 0: uint16(34852), + 1: uint16(34853), + 2: uint16(34854), + 3: uint16(34855), + 4: uint16(34856), + 5: uint16(34857), + 6: uint16(34858), + 7: uint16(34859), + 8: uint16(34860), + 9: uint16(34861), + 10: uint16(34862), + 11: uint16(34863), + 12: uint16(34864), + 13: uint16(34865), + 14: uint16(34867), + 15: uint16(34868), + 16: uint16(34869), + 17: uint16(34870), + 18: uint16(34871), + 19: uint16(34872), + 20: uint16(34874), + 21: uint16(34875), + 22: uint16(34877), + 23: uint16(34878), + 24: uint16(34879), + 25: uint16(34881), + 26: uint16(34882), + 27: uint16(34883), + 28: uint16(34886), + 29: uint16(34887), + 30: uint16(34888), + 31: uint16(34889), + 32: uint16(34890), + 33: uint16(34891), + 34: uint16(34894), + 35: uint16(34895), + 36: uint16(34896), + 37: uint16(34897), + 38: uint16(34898), + 39: uint16(34899), + 40: uint16(34901), + 41: uint16(34902), + 42: uint16(34904), + 43: uint16(34906), + 44: uint16(34907), + 45: uint16(34908), + 46: uint16(34909), + 47: uint16(34910), + 48: uint16(34911), + 49: uint16(34912), + 50: uint16(34918), + 51: uint16(34919), + 52: uint16(34922), + 53: uint16(34925), + 54: uint16(34927), + 55: uint16(34929), + 56: uint16(34931), + 57: uint16(34932), + 58: uint16(34933), + 59: uint16(34934), + 60: uint16(34936), + 61: uint16(34937), + 62: uint16(34938), + 63: uint16(34939), + 64: uint16(34940), + 65: uint16(34944), + 66: uint16(34947), + 67: uint16(34950), + 68: uint16(34951), + 69: uint16(34953), + 70: uint16(34954), + 71: uint16(34956), + 72: uint16(34958), + 73: uint16(34959), + 74: uint16(34960), + 75: uint16(34961), + 76: uint16(34963), + 77: uint16(34964), + 78: uint16(34965), + 79: uint16(34967), + 80: uint16(34968), + 81: uint16(34969), + 82: uint16(34970), + 83: uint16(34971), + 84: uint16(34973), + 85: uint16(34974), + 86: uint16(34975), + 87: uint16(34976), + 88: uint16(34977), + 89: uint16(34979), + 90: uint16(34981), + 91: uint16(34982), + 92: uint16(34983), + 93: uint16(34984), + 94: uint16(34985), + 95: uint16(34986), + 96: uint16(23567), + 97: uint16(23389), + 98: uint16(26657), + 99: uint16(32918), + 100: uint16(21880), + 101: uint16(31505), + 102: uint16(25928), + 103: uint16(26964), + 104: uint16(20123), + 105: uint16(27463), + 106: uint16(34638), + 107: uint16(38795), + 108: uint16(21327), + 109: uint16(25375), + 110: uint16(25658), + 111: uint16(37034), + 112: uint16(26012), + 113: uint16(32961), + 114: uint16(35856), + 115: uint16(20889), + 116: uint16(26800), + 117: uint16(21368), + 118: uint16(34809), + 119: uint16(25032), + 120: uint16(27844), + 121: uint16(27899), + 122: uint16(35874), + 123: uint16(23633), + 124: uint16(34218), + 125: uint16(33455), + 126: uint16(38156), + 127: uint16(27427), + 128: uint16(36763), + 129: uint16(26032), + 130: uint16(24571), + 131: uint16(24515), + 132: uint16(20449), + 133: uint16(34885), + 134: uint16(26143), + 135: uint16(33125), + 136: uint16(29481), + 137: uint16(24826), + 138: uint16(20852), + 139: uint16(21009), + 140: uint16(22411), + 141: uint16(24418), + 142: uint16(37026), + 143: uint16(34892), + 144: uint16(37266), + 145: uint16(24184), + 146: uint16(26447), + 147: uint16(24615), + 148: uint16(22995), + 149: uint16(20804), + 150: uint16(20982), + 151: uint16(33016), + 152: uint16(21256), + 153: uint16(27769), + 154: uint16(38596), + 155: uint16(29066), + 156: uint16(20241), + 157: uint16(20462), + 158: uint16(32670), + 159: uint16(26429), + 160: uint16(21957), + 161: uint16(38152), + 162: uint16(31168), + 163: uint16(34966), + 164: uint16(32483), + 165: uint16(22687), + 166: uint16(25100), + 167: uint16(38656), + 168: uint16(34394), + 169: uint16(22040), + 170: uint16(39035), + 171: uint16(24464), + 172: uint16(35768), + 173: uint16(33988), + 174: uint16(37207), + 175: uint16(21465), + 176: uint16(26093), + 177: uint16(24207), + 178: uint16(30044), + 179: uint16(24676), + 180: uint16(32110), + 181: uint16(23167), + 182: uint16(32490), + 183: uint16(32493), + 184: uint16(36713), + 185: uint16(21927), + 186: uint16(23459), + 187: uint16(24748), + 188: uint16(26059), + 189: uint16(29572), + }, + 80: { + 0: uint16(34988), + 1: uint16(34990), + 2: uint16(34991), + 3: uint16(34992), + 4: uint16(34994), + 5: uint16(34995), + 6: uint16(34996), + 7: uint16(34997), + 8: uint16(34998), + 9: uint16(35000), + 10: uint16(35001), + 11: uint16(35002), + 12: uint16(35003), + 13: uint16(35005), + 14: uint16(35006), + 15: uint16(35007), + 16: uint16(35008), + 17: uint16(35011), + 18: uint16(35012), + 19: uint16(35015), + 20: uint16(35016), + 21: uint16(35018), + 22: uint16(35019), + 23: uint16(35020), + 24: uint16(35021), + 25: uint16(35023), + 26: uint16(35024), + 27: uint16(35025), + 28: uint16(35027), + 29: uint16(35030), + 30: uint16(35031), + 31: uint16(35034), + 32: uint16(35035), + 33: uint16(35036), + 34: uint16(35037), + 35: uint16(35038), + 36: uint16(35040), + 37: uint16(35041), + 38: uint16(35046), + 39: uint16(35047), + 40: uint16(35049), + 41: uint16(35050), + 42: uint16(35051), + 43: uint16(35052), + 44: uint16(35053), + 45: uint16(35054), + 46: uint16(35055), + 47: uint16(35058), + 48: uint16(35061), + 49: uint16(35062), + 50: uint16(35063), + 51: uint16(35066), + 52: uint16(35067), + 53: uint16(35069), + 54: uint16(35071), + 55: uint16(35072), + 56: uint16(35073), + 57: uint16(35075), + 58: uint16(35076), + 59: uint16(35077), + 60: uint16(35078), + 61: uint16(35079), + 62: uint16(35080), + 63: uint16(35081), + 64: uint16(35083), + 65: uint16(35084), + 66: uint16(35085), + 67: uint16(35086), + 68: uint16(35087), + 69: uint16(35089), + 70: uint16(35092), + 71: uint16(35093), + 72: uint16(35094), + 73: uint16(35095), + 74: uint16(35096), + 75: uint16(35100), + 76: uint16(35101), + 77: uint16(35102), + 78: uint16(35103), + 79: uint16(35104), + 80: uint16(35106), + 81: uint16(35107), + 82: uint16(35108), + 83: uint16(35110), + 84: uint16(35111), + 85: uint16(35112), + 86: uint16(35113), + 87: uint16(35116), + 88: uint16(35117), + 89: uint16(35118), + 90: uint16(35119), + 91: uint16(35121), + 92: uint16(35122), + 93: uint16(35123), + 94: uint16(35125), + 95: uint16(35127), + 96: uint16(36873), + 97: uint16(30307), + 98: uint16(30505), + 99: uint16(32474), + 100: uint16(38772), + 101: uint16(34203), + 102: uint16(23398), + 103: uint16(31348), + 104: uint16(38634), + 105: uint16(34880), + 106: uint16(21195), + 107: uint16(29071), + 108: uint16(24490), + 109: uint16(26092), + 110: uint16(35810), + 111: uint16(23547), + 112: uint16(39535), + 113: uint16(24033), + 114: uint16(27529), + 115: uint16(27739), + 116: uint16(35757), + 117: uint16(35759), + 118: uint16(36874), + 119: uint16(36805), + 120: uint16(21387), + 121: uint16(25276), + 122: uint16(40486), + 123: uint16(40493), + 124: uint16(21568), + 125: uint16(20011), + 126: uint16(33469), + 127: uint16(29273), + 128: uint16(34460), + 129: uint16(23830), + 130: uint16(34905), + 131: uint16(28079), + 132: uint16(38597), + 133: uint16(21713), + 134: uint16(20122), + 135: uint16(35766), + 136: uint16(28937), + 137: uint16(21693), + 138: uint16(38409), + 139: uint16(28895), + 140: uint16(28153), + 141: uint16(30416), + 142: uint16(20005), + 143: uint16(30740), + 144: uint16(34578), + 145: uint16(23721), + 146: uint16(24310), + 147: uint16(35328), + 148: uint16(39068), + 149: uint16(38414), + 150: uint16(28814), + 151: uint16(27839), + 152: uint16(22852), + 153: uint16(25513), + 154: uint16(30524), + 155: uint16(34893), + 156: uint16(28436), + 157: uint16(33395), + 158: uint16(22576), + 159: uint16(29141), + 160: uint16(21388), + 161: uint16(30746), + 162: uint16(38593), + 163: uint16(21761), + 164: uint16(24422), + 165: uint16(28976), + 166: uint16(23476), + 167: uint16(35866), + 168: uint16(39564), + 169: uint16(27523), + 170: uint16(22830), + 171: uint16(40495), + 172: uint16(31207), + 173: uint16(26472), + 174: uint16(25196), + 175: uint16(20335), + 176: uint16(30113), + 177: uint16(32650), + 178: uint16(27915), + 179: uint16(38451), + 180: uint16(27687), + 181: uint16(20208), + 182: uint16(30162), + 183: uint16(20859), + 184: uint16(26679), + 185: uint16(28478), + 186: uint16(36992), + 187: uint16(33136), + 188: uint16(22934), + 189: uint16(29814), + }, + 81: { + 0: uint16(35128), + 1: uint16(35129), + 2: uint16(35130), + 3: uint16(35131), + 4: uint16(35132), + 5: uint16(35133), + 6: uint16(35134), + 7: uint16(35135), + 8: uint16(35136), + 9: uint16(35138), + 10: uint16(35139), + 11: uint16(35141), + 12: uint16(35142), + 13: uint16(35143), + 14: uint16(35144), + 15: uint16(35145), + 16: uint16(35146), + 17: uint16(35147), + 18: uint16(35148), + 19: uint16(35149), + 20: uint16(35150), + 21: uint16(35151), + 22: uint16(35152), + 23: uint16(35153), + 24: uint16(35154), + 25: uint16(35155), + 26: uint16(35156), + 27: uint16(35157), + 28: uint16(35158), + 29: uint16(35159), + 30: uint16(35160), + 31: uint16(35161), + 32: uint16(35162), + 33: uint16(35163), + 34: uint16(35164), + 35: uint16(35165), + 36: uint16(35168), + 37: uint16(35169), + 38: uint16(35170), + 39: uint16(35171), + 40: uint16(35172), + 41: uint16(35173), + 42: uint16(35175), + 43: uint16(35176), + 44: uint16(35177), + 45: uint16(35178), + 46: uint16(35179), + 47: uint16(35180), + 48: uint16(35181), + 49: uint16(35182), + 50: uint16(35183), + 51: uint16(35184), + 52: uint16(35185), + 53: uint16(35186), + 54: uint16(35187), + 55: uint16(35188), + 56: uint16(35189), + 57: uint16(35190), + 58: uint16(35191), + 59: uint16(35192), + 60: uint16(35193), + 61: uint16(35194), + 62: uint16(35196), + 63: uint16(35197), + 64: uint16(35198), + 65: uint16(35200), + 66: uint16(35202), + 67: uint16(35204), + 68: uint16(35205), + 69: uint16(35207), + 70: uint16(35208), + 71: uint16(35209), + 72: uint16(35210), + 73: uint16(35211), + 74: uint16(35212), + 75: uint16(35213), + 76: uint16(35214), + 77: uint16(35215), + 78: uint16(35216), + 79: uint16(35217), + 80: uint16(35218), + 81: uint16(35219), + 82: uint16(35220), + 83: uint16(35221), + 84: uint16(35222), + 85: uint16(35223), + 86: uint16(35224), + 87: uint16(35225), + 88: uint16(35226), + 89: uint16(35227), + 90: uint16(35228), + 91: uint16(35229), + 92: uint16(35230), + 93: uint16(35231), + 94: uint16(35232), + 95: uint16(35233), + 96: uint16(25671), + 97: uint16(23591), + 98: uint16(36965), + 99: uint16(31377), + 100: uint16(35875), + 101: uint16(23002), + 102: uint16(21676), + 103: uint16(33280), + 104: uint16(33647), + 105: uint16(35201), + 106: uint16(32768), + 107: uint16(26928), + 108: uint16(22094), + 109: uint16(32822), + 110: uint16(29239), + 111: uint16(37326), + 112: uint16(20918), + 113: uint16(20063), + 114: uint16(39029), + 115: uint16(25494), + 116: uint16(19994), + 117: uint16(21494), + 118: uint16(26355), + 119: uint16(33099), + 120: uint16(22812), + 121: uint16(28082), + 122: uint16(19968), + 123: uint16(22777), + 124: uint16(21307), + 125: uint16(25558), + 126: uint16(38129), + 127: uint16(20381), + 128: uint16(20234), + 129: uint16(34915), + 130: uint16(39056), + 131: uint16(22839), + 132: uint16(36951), + 133: uint16(31227), + 134: uint16(20202), + 135: uint16(33008), + 136: uint16(30097), + 137: uint16(27778), + 138: uint16(23452), + 139: uint16(23016), + 140: uint16(24413), + 141: uint16(26885), + 142: uint16(34433), + 143: uint16(20506), + 144: uint16(24050), + 145: uint16(20057), + 146: uint16(30691), + 147: uint16(20197), + 148: uint16(33402), + 149: uint16(25233), + 150: uint16(26131), + 151: uint16(37009), + 152: uint16(23673), + 153: uint16(20159), + 154: uint16(24441), + 155: uint16(33222), + 156: uint16(36920), + 157: uint16(32900), + 158: uint16(30123), + 159: uint16(20134), + 160: uint16(35028), + 161: uint16(24847), + 162: uint16(27589), + 163: uint16(24518), + 164: uint16(20041), + 165: uint16(30410), + 166: uint16(28322), + 167: uint16(35811), + 168: uint16(35758), + 169: uint16(35850), + 170: uint16(35793), + 171: uint16(24322), + 172: uint16(32764), + 173: uint16(32716), + 174: uint16(32462), + 175: uint16(33589), + 176: uint16(33643), + 177: uint16(22240), + 178: uint16(27575), + 179: uint16(38899), + 180: uint16(38452), + 181: uint16(23035), + 182: uint16(21535), + 183: uint16(38134), + 184: uint16(28139), + 185: uint16(23493), + 186: uint16(39278), + 187: uint16(23609), + 188: uint16(24341), + 189: uint16(38544), + }, + 82: { + 0: uint16(35234), + 1: uint16(35235), + 2: uint16(35236), + 3: uint16(35237), + 4: uint16(35238), + 5: uint16(35239), + 6: uint16(35240), + 7: uint16(35241), + 8: uint16(35242), + 9: uint16(35243), + 10: uint16(35244), + 11: uint16(35245), + 12: uint16(35246), + 13: uint16(35247), + 14: uint16(35248), + 15: uint16(35249), + 16: uint16(35250), + 17: uint16(35251), + 18: uint16(35252), + 19: uint16(35253), + 20: uint16(35254), + 21: uint16(35255), + 22: uint16(35256), + 23: uint16(35257), + 24: uint16(35258), + 25: uint16(35259), + 26: uint16(35260), + 27: uint16(35261), + 28: uint16(35262), + 29: uint16(35263), + 30: uint16(35264), + 31: uint16(35267), + 32: uint16(35277), + 33: uint16(35283), + 34: uint16(35284), + 35: uint16(35285), + 36: uint16(35287), + 37: uint16(35288), + 38: uint16(35289), + 39: uint16(35291), + 40: uint16(35293), + 41: uint16(35295), + 42: uint16(35296), + 43: uint16(35297), + 44: uint16(35298), + 45: uint16(35300), + 46: uint16(35303), + 47: uint16(35304), + 48: uint16(35305), + 49: uint16(35306), + 50: uint16(35308), + 51: uint16(35309), + 52: uint16(35310), + 53: uint16(35312), + 54: uint16(35313), + 55: uint16(35314), + 56: uint16(35316), + 57: uint16(35317), + 58: uint16(35318), + 59: uint16(35319), + 60: uint16(35320), + 61: uint16(35321), + 62: uint16(35322), + 63: uint16(35323), + 64: uint16(35324), + 65: uint16(35325), + 66: uint16(35326), + 67: uint16(35327), + 68: uint16(35329), + 69: uint16(35330), + 70: uint16(35331), + 71: uint16(35332), + 72: uint16(35333), + 73: uint16(35334), + 74: uint16(35336), + 75: uint16(35337), + 76: uint16(35338), + 77: uint16(35339), + 78: uint16(35340), + 79: uint16(35341), + 80: uint16(35342), + 81: uint16(35343), + 82: uint16(35344), + 83: uint16(35345), + 84: uint16(35346), + 85: uint16(35347), + 86: uint16(35348), + 87: uint16(35349), + 88: uint16(35350), + 89: uint16(35351), + 90: uint16(35352), + 91: uint16(35353), + 92: uint16(35354), + 93: uint16(35355), + 94: uint16(35356), + 95: uint16(35357), + 96: uint16(21360), + 97: uint16(33521), + 98: uint16(27185), + 99: uint16(23156), + 100: uint16(40560), + 101: uint16(24212), + 102: uint16(32552), + 103: uint16(33721), + 104: uint16(33828), + 105: uint16(33829), + 106: uint16(33639), + 107: uint16(34631), + 108: uint16(36814), + 109: uint16(36194), + 110: uint16(30408), + 111: uint16(24433), + 112: uint16(39062), + 113: uint16(30828), + 114: uint16(26144), + 115: uint16(21727), + 116: uint16(25317), + 117: uint16(20323), + 118: uint16(33219), + 119: uint16(30152), + 120: uint16(24248), + 121: uint16(38605), + 122: uint16(36362), + 123: uint16(34553), + 124: uint16(21647), + 125: uint16(27891), + 126: uint16(28044), + 127: uint16(27704), + 128: uint16(24703), + 129: uint16(21191), + 130: uint16(29992), + 131: uint16(24189), + 132: uint16(20248), + 133: uint16(24736), + 134: uint16(24551), + 135: uint16(23588), + 136: uint16(30001), + 137: uint16(37038), + 138: uint16(38080), + 139: uint16(29369), + 140: uint16(27833), + 141: uint16(28216), + 142: uint16(37193), + 143: uint16(26377), + 144: uint16(21451), + 145: uint16(21491), + 146: uint16(20305), + 147: uint16(37321), + 148: uint16(35825), + 149: uint16(21448), + 150: uint16(24188), + 151: uint16(36802), + 152: uint16(28132), + 153: uint16(20110), + 154: uint16(30402), + 155: uint16(27014), + 156: uint16(34398), + 157: uint16(24858), + 158: uint16(33286), + 159: uint16(20313), + 160: uint16(20446), + 161: uint16(36926), + 162: uint16(40060), + 163: uint16(24841), + 164: uint16(28189), + 165: uint16(28180), + 166: uint16(38533), + 167: uint16(20104), + 168: uint16(23089), + 169: uint16(38632), + 170: uint16(19982), + 171: uint16(23679), + 172: uint16(31161), + 173: uint16(23431), + 174: uint16(35821), + 175: uint16(32701), + 176: uint16(29577), + 177: uint16(22495), + 178: uint16(33419), + 179: uint16(37057), + 180: uint16(21505), + 181: uint16(36935), + 182: uint16(21947), + 183: uint16(23786), + 184: uint16(24481), + 185: uint16(24840), + 186: uint16(27442), + 187: uint16(29425), + 188: uint16(32946), + 189: uint16(35465), + }, + 83: { + 0: uint16(35358), + 1: uint16(35359), + 2: uint16(35360), + 3: uint16(35361), + 4: uint16(35362), + 5: uint16(35363), + 6: uint16(35364), + 7: uint16(35365), + 8: uint16(35366), + 9: uint16(35367), + 10: uint16(35368), + 11: uint16(35369), + 12: uint16(35370), + 13: uint16(35371), + 14: uint16(35372), + 15: uint16(35373), + 16: uint16(35374), + 17: uint16(35375), + 18: uint16(35376), + 19: uint16(35377), + 20: uint16(35378), + 21: uint16(35379), + 22: uint16(35380), + 23: uint16(35381), + 24: uint16(35382), + 25: uint16(35383), + 26: uint16(35384), + 27: uint16(35385), + 28: uint16(35386), + 29: uint16(35387), + 30: uint16(35388), + 31: uint16(35389), + 32: uint16(35391), + 33: uint16(35392), + 34: uint16(35393), + 35: uint16(35394), + 36: uint16(35395), + 37: uint16(35396), + 38: uint16(35397), + 39: uint16(35398), + 40: uint16(35399), + 41: uint16(35401), + 42: uint16(35402), + 43: uint16(35403), + 44: uint16(35404), + 45: uint16(35405), + 46: uint16(35406), + 47: uint16(35407), + 48: uint16(35408), + 49: uint16(35409), + 50: uint16(35410), + 51: uint16(35411), + 52: uint16(35412), + 53: uint16(35413), + 54: uint16(35414), + 55: uint16(35415), + 56: uint16(35416), + 57: uint16(35417), + 58: uint16(35418), + 59: uint16(35419), + 60: uint16(35420), + 61: uint16(35421), + 62: uint16(35422), + 63: uint16(35423), + 64: uint16(35424), + 65: uint16(35425), + 66: uint16(35426), + 67: uint16(35427), + 68: uint16(35428), + 69: uint16(35429), + 70: uint16(35430), + 71: uint16(35431), + 72: uint16(35432), + 73: uint16(35433), + 74: uint16(35434), + 75: uint16(35435), + 76: uint16(35436), + 77: uint16(35437), + 78: uint16(35438), + 79: uint16(35439), + 80: uint16(35440), + 81: uint16(35441), + 82: uint16(35442), + 83: uint16(35443), + 84: uint16(35444), + 85: uint16(35445), + 86: uint16(35446), + 87: uint16(35447), + 88: uint16(35448), + 89: uint16(35450), + 90: uint16(35451), + 91: uint16(35452), + 92: uint16(35453), + 93: uint16(35454), + 94: uint16(35455), + 95: uint16(35456), + 96: uint16(28020), + 97: uint16(23507), + 98: uint16(35029), + 99: uint16(39044), + 100: uint16(35947), + 101: uint16(39533), + 102: uint16(40499), + 103: uint16(28170), + 104: uint16(20900), + 105: uint16(20803), + 106: uint16(22435), + 107: uint16(34945), + 108: uint16(21407), + 109: uint16(25588), + 110: uint16(36757), + 111: uint16(22253), + 112: uint16(21592), + 113: uint16(22278), + 114: uint16(29503), + 115: uint16(28304), + 116: uint16(32536), + 117: uint16(36828), + 118: uint16(33489), + 119: uint16(24895), + 120: uint16(24616), + 121: uint16(38498), + 122: uint16(26352), + 123: uint16(32422), + 124: uint16(36234), + 125: uint16(36291), + 126: uint16(38053), + 127: uint16(23731), + 128: uint16(31908), + 129: uint16(26376), + 130: uint16(24742), + 131: uint16(38405), + 132: uint16(32792), + 133: uint16(20113), + 134: uint16(37095), + 135: uint16(21248), + 136: uint16(38504), + 137: uint16(20801), + 138: uint16(36816), + 139: uint16(34164), + 140: uint16(37213), + 141: uint16(26197), + 142: uint16(38901), + 143: uint16(23381), + 144: uint16(21277), + 145: uint16(30776), + 146: uint16(26434), + 147: uint16(26685), + 148: uint16(21705), + 149: uint16(28798), + 150: uint16(23472), + 151: uint16(36733), + 152: uint16(20877), + 153: uint16(22312), + 154: uint16(21681), + 155: uint16(25874), + 156: uint16(26242), + 157: uint16(36190), + 158: uint16(36163), + 159: uint16(33039), + 160: uint16(33900), + 161: uint16(36973), + 162: uint16(31967), + 163: uint16(20991), + 164: uint16(34299), + 165: uint16(26531), + 166: uint16(26089), + 167: uint16(28577), + 168: uint16(34468), + 169: uint16(36481), + 170: uint16(22122), + 171: uint16(36896), + 172: uint16(30338), + 173: uint16(28790), + 174: uint16(29157), + 175: uint16(36131), + 176: uint16(25321), + 177: uint16(21017), + 178: uint16(27901), + 179: uint16(36156), + 180: uint16(24590), + 181: uint16(22686), + 182: uint16(24974), + 183: uint16(26366), + 184: uint16(36192), + 185: uint16(25166), + 186: uint16(21939), + 187: uint16(28195), + 188: uint16(26413), + 189: uint16(36711), + }, + 84: { + 0: uint16(35457), + 1: uint16(35458), + 2: uint16(35459), + 3: uint16(35460), + 4: uint16(35461), + 5: uint16(35462), + 6: uint16(35463), + 7: uint16(35464), + 8: uint16(35467), + 9: uint16(35468), + 10: uint16(35469), + 11: uint16(35470), + 12: uint16(35471), + 13: uint16(35472), + 14: uint16(35473), + 15: uint16(35474), + 16: uint16(35476), + 17: uint16(35477), + 18: uint16(35478), + 19: uint16(35479), + 20: uint16(35480), + 21: uint16(35481), + 22: uint16(35482), + 23: uint16(35483), + 24: uint16(35484), + 25: uint16(35485), + 26: uint16(35486), + 27: uint16(35487), + 28: uint16(35488), + 29: uint16(35489), + 30: uint16(35490), + 31: uint16(35491), + 32: uint16(35492), + 33: uint16(35493), + 34: uint16(35494), + 35: uint16(35495), + 36: uint16(35496), + 37: uint16(35497), + 38: uint16(35498), + 39: uint16(35499), + 40: uint16(35500), + 41: uint16(35501), + 42: uint16(35502), + 43: uint16(35503), + 44: uint16(35504), + 45: uint16(35505), + 46: uint16(35506), + 47: uint16(35507), + 48: uint16(35508), + 49: uint16(35509), + 50: uint16(35510), + 51: uint16(35511), + 52: uint16(35512), + 53: uint16(35513), + 54: uint16(35514), + 55: uint16(35515), + 56: uint16(35516), + 57: uint16(35517), + 58: uint16(35518), + 59: uint16(35519), + 60: uint16(35520), + 61: uint16(35521), + 62: uint16(35522), + 63: uint16(35523), + 64: uint16(35524), + 65: uint16(35525), + 66: uint16(35526), + 67: uint16(35527), + 68: uint16(35528), + 69: uint16(35529), + 70: uint16(35530), + 71: uint16(35531), + 72: uint16(35532), + 73: uint16(35533), + 74: uint16(35534), + 75: uint16(35535), + 76: uint16(35536), + 77: uint16(35537), + 78: uint16(35538), + 79: uint16(35539), + 80: uint16(35540), + 81: uint16(35541), + 82: uint16(35542), + 83: uint16(35543), + 84: uint16(35544), + 85: uint16(35545), + 86: uint16(35546), + 87: uint16(35547), + 88: uint16(35548), + 89: uint16(35549), + 90: uint16(35550), + 91: uint16(35551), + 92: uint16(35552), + 93: uint16(35553), + 94: uint16(35554), + 95: uint16(35555), + 96: uint16(38113), + 97: uint16(38392), + 98: uint16(30504), + 99: uint16(26629), + 100: uint16(27048), + 101: uint16(21643), + 102: uint16(20045), + 103: uint16(28856), + 104: uint16(35784), + 105: uint16(25688), + 106: uint16(25995), + 107: uint16(23429), + 108: uint16(31364), + 109: uint16(20538), + 110: uint16(23528), + 111: uint16(30651), + 112: uint16(27617), + 113: uint16(35449), + 114: uint16(31896), + 115: uint16(27838), + 116: uint16(30415), + 117: uint16(26025), + 118: uint16(36759), + 119: uint16(23853), + 120: uint16(23637), + 121: uint16(34360), + 122: uint16(26632), + 123: uint16(21344), + 124: uint16(25112), + 125: uint16(31449), + 126: uint16(28251), + 127: uint16(32509), + 128: uint16(27167), + 129: uint16(31456), + 130: uint16(24432), + 131: uint16(28467), + 132: uint16(24352), + 133: uint16(25484), + 134: uint16(28072), + 135: uint16(26454), + 136: uint16(19976), + 137: uint16(24080), + 138: uint16(36134), + 139: uint16(20183), + 140: uint16(32960), + 141: uint16(30260), + 142: uint16(38556), + 143: uint16(25307), + 144: uint16(26157), + 145: uint16(25214), + 146: uint16(27836), + 147: uint16(36213), + 148: uint16(29031), + 149: uint16(32617), + 150: uint16(20806), + 151: uint16(32903), + 152: uint16(21484), + 153: uint16(36974), + 154: uint16(25240), + 155: uint16(21746), + 156: uint16(34544), + 157: uint16(36761), + 158: uint16(32773), + 159: uint16(38167), + 160: uint16(34071), + 161: uint16(36825), + 162: uint16(27993), + 163: uint16(29645), + 164: uint16(26015), + 165: uint16(30495), + 166: uint16(29956), + 167: uint16(30759), + 168: uint16(33275), + 169: uint16(36126), + 170: uint16(38024), + 171: uint16(20390), + 172: uint16(26517), + 173: uint16(30137), + 174: uint16(35786), + 175: uint16(38663), + 176: uint16(25391), + 177: uint16(38215), + 178: uint16(38453), + 179: uint16(33976), + 180: uint16(25379), + 181: uint16(30529), + 182: uint16(24449), + 183: uint16(29424), + 184: uint16(20105), + 185: uint16(24596), + 186: uint16(25972), + 187: uint16(25327), + 188: uint16(27491), + 189: uint16(25919), + }, + 85: { + 0: uint16(35556), + 1: uint16(35557), + 2: uint16(35558), + 3: uint16(35559), + 4: uint16(35560), + 5: uint16(35561), + 6: uint16(35562), + 7: uint16(35563), + 8: uint16(35564), + 9: uint16(35565), + 10: uint16(35566), + 11: uint16(35567), + 12: uint16(35568), + 13: uint16(35569), + 14: uint16(35570), + 15: uint16(35571), + 16: uint16(35572), + 17: uint16(35573), + 18: uint16(35574), + 19: uint16(35575), + 20: uint16(35576), + 21: uint16(35577), + 22: uint16(35578), + 23: uint16(35579), + 24: uint16(35580), + 25: uint16(35581), + 26: uint16(35582), + 27: uint16(35583), + 28: uint16(35584), + 29: uint16(35585), + 30: uint16(35586), + 31: uint16(35587), + 32: uint16(35588), + 33: uint16(35589), + 34: uint16(35590), + 35: uint16(35592), + 36: uint16(35593), + 37: uint16(35594), + 38: uint16(35595), + 39: uint16(35596), + 40: uint16(35597), + 41: uint16(35598), + 42: uint16(35599), + 43: uint16(35600), + 44: uint16(35601), + 45: uint16(35602), + 46: uint16(35603), + 47: uint16(35604), + 48: uint16(35605), + 49: uint16(35606), + 50: uint16(35607), + 51: uint16(35608), + 52: uint16(35609), + 53: uint16(35610), + 54: uint16(35611), + 55: uint16(35612), + 56: uint16(35613), + 57: uint16(35614), + 58: uint16(35615), + 59: uint16(35616), + 60: uint16(35617), + 61: uint16(35618), + 62: uint16(35619), + 63: uint16(35620), + 64: uint16(35621), + 65: uint16(35623), + 66: uint16(35624), + 67: uint16(35625), + 68: uint16(35626), + 69: uint16(35627), + 70: uint16(35628), + 71: uint16(35629), + 72: uint16(35630), + 73: uint16(35631), + 74: uint16(35632), + 75: uint16(35633), + 76: uint16(35634), + 77: uint16(35635), + 78: uint16(35636), + 79: uint16(35637), + 80: uint16(35638), + 81: uint16(35639), + 82: uint16(35640), + 83: uint16(35641), + 84: uint16(35642), + 85: uint16(35643), + 86: uint16(35644), + 87: uint16(35645), + 88: uint16(35646), + 89: uint16(35647), + 90: uint16(35648), + 91: uint16(35649), + 92: uint16(35650), + 93: uint16(35651), + 94: uint16(35652), + 95: uint16(35653), + 96: uint16(24103), + 97: uint16(30151), + 98: uint16(37073), + 99: uint16(35777), + 100: uint16(33437), + 101: uint16(26525), + 102: uint16(25903), + 103: uint16(21553), + 104: uint16(34584), + 105: uint16(30693), + 106: uint16(32930), + 107: uint16(33026), + 108: uint16(27713), + 109: uint16(20043), + 110: uint16(32455), + 111: uint16(32844), + 112: uint16(30452), + 113: uint16(26893), + 114: uint16(27542), + 115: uint16(25191), + 116: uint16(20540), + 117: uint16(20356), + 118: uint16(22336), + 119: uint16(25351), + 120: uint16(27490), + 121: uint16(36286), + 122: uint16(21482), + 123: uint16(26088), + 124: uint16(32440), + 125: uint16(24535), + 126: uint16(25370), + 127: uint16(25527), + 128: uint16(33267), + 129: uint16(33268), + 130: uint16(32622), + 131: uint16(24092), + 132: uint16(23769), + 133: uint16(21046), + 134: uint16(26234), + 135: uint16(31209), + 136: uint16(31258), + 137: uint16(36136), + 138: uint16(28825), + 139: uint16(30164), + 140: uint16(28382), + 141: uint16(27835), + 142: uint16(31378), + 143: uint16(20013), + 144: uint16(30405), + 145: uint16(24544), + 146: uint16(38047), + 147: uint16(34935), + 148: uint16(32456), + 149: uint16(31181), + 150: uint16(32959), + 151: uint16(37325), + 152: uint16(20210), + 153: uint16(20247), + 154: uint16(33311), + 155: uint16(21608), + 156: uint16(24030), + 157: uint16(27954), + 158: uint16(35788), + 159: uint16(31909), + 160: uint16(36724), + 161: uint16(32920), + 162: uint16(24090), + 163: uint16(21650), + 164: uint16(30385), + 165: uint16(23449), + 166: uint16(26172), + 167: uint16(39588), + 168: uint16(29664), + 169: uint16(26666), + 170: uint16(34523), + 171: uint16(26417), + 172: uint16(29482), + 173: uint16(35832), + 174: uint16(35803), + 175: uint16(36880), + 176: uint16(31481), + 177: uint16(28891), + 178: uint16(29038), + 179: uint16(25284), + 180: uint16(30633), + 181: uint16(22065), + 182: uint16(20027), + 183: uint16(33879), + 184: uint16(26609), + 185: uint16(21161), + 186: uint16(34496), + 187: uint16(36142), + 188: uint16(38136), + 189: uint16(31569), + }, + 86: { + 0: uint16(35654), + 1: uint16(35655), + 2: uint16(35656), + 3: uint16(35657), + 4: uint16(35658), + 5: uint16(35659), + 6: uint16(35660), + 7: uint16(35661), + 8: uint16(35662), + 9: uint16(35663), + 10: uint16(35664), + 11: uint16(35665), + 12: uint16(35666), + 13: uint16(35667), + 14: uint16(35668), + 15: uint16(35669), + 16: uint16(35670), + 17: uint16(35671), + 18: uint16(35672), + 19: uint16(35673), + 20: uint16(35674), + 21: uint16(35675), + 22: uint16(35676), + 23: uint16(35677), + 24: uint16(35678), + 25: uint16(35679), + 26: uint16(35680), + 27: uint16(35681), + 28: uint16(35682), + 29: uint16(35683), + 30: uint16(35684), + 31: uint16(35685), + 32: uint16(35687), + 33: uint16(35688), + 34: uint16(35689), + 35: uint16(35690), + 36: uint16(35691), + 37: uint16(35693), + 38: uint16(35694), + 39: uint16(35695), + 40: uint16(35696), + 41: uint16(35697), + 42: uint16(35698), + 43: uint16(35699), + 44: uint16(35700), + 45: uint16(35701), + 46: uint16(35702), + 47: uint16(35703), + 48: uint16(35704), + 49: uint16(35705), + 50: uint16(35706), + 51: uint16(35707), + 52: uint16(35708), + 53: uint16(35709), + 54: uint16(35710), + 55: uint16(35711), + 56: uint16(35712), + 57: uint16(35713), + 58: uint16(35714), + 59: uint16(35715), + 60: uint16(35716), + 61: uint16(35717), + 62: uint16(35718), + 63: uint16(35719), + 64: uint16(35720), + 65: uint16(35721), + 66: uint16(35722), + 67: uint16(35723), + 68: uint16(35724), + 69: uint16(35725), + 70: uint16(35726), + 71: uint16(35727), + 72: uint16(35728), + 73: uint16(35729), + 74: uint16(35730), + 75: uint16(35731), + 76: uint16(35732), + 77: uint16(35733), + 78: uint16(35734), + 79: uint16(35735), + 80: uint16(35736), + 81: uint16(35737), + 82: uint16(35738), + 83: uint16(35739), + 84: uint16(35740), + 85: uint16(35741), + 86: uint16(35742), + 87: uint16(35743), + 88: uint16(35756), + 89: uint16(35761), + 90: uint16(35771), + 91: uint16(35783), + 92: uint16(35792), + 93: uint16(35818), + 94: uint16(35849), + 95: uint16(35870), + 96: uint16(20303), + 97: uint16(27880), + 98: uint16(31069), + 99: uint16(39547), + 100: uint16(25235), + 101: uint16(29226), + 102: uint16(25341), + 103: uint16(19987), + 104: uint16(30742), + 105: uint16(36716), + 106: uint16(25776), + 107: uint16(36186), + 108: uint16(31686), + 109: uint16(26729), + 110: uint16(24196), + 111: uint16(35013), + 112: uint16(22918), + 113: uint16(25758), + 114: uint16(22766), + 115: uint16(29366), + 116: uint16(26894), + 117: uint16(38181), + 118: uint16(36861), + 119: uint16(36184), + 120: uint16(22368), + 121: uint16(32512), + 122: uint16(35846), + 123: uint16(20934), + 124: uint16(25417), + 125: uint16(25305), + 126: uint16(21331), + 127: uint16(26700), + 128: uint16(29730), + 129: uint16(33537), + 130: uint16(37196), + 131: uint16(21828), + 132: uint16(30528), + 133: uint16(28796), + 134: uint16(27978), + 135: uint16(20857), + 136: uint16(21672), + 137: uint16(36164), + 138: uint16(23039), + 139: uint16(28363), + 140: uint16(28100), + 141: uint16(23388), + 142: uint16(32043), + 143: uint16(20180), + 144: uint16(31869), + 145: uint16(28371), + 146: uint16(23376), + 147: uint16(33258), + 148: uint16(28173), + 149: uint16(23383), + 150: uint16(39683), + 151: uint16(26837), + 152: uint16(36394), + 153: uint16(23447), + 154: uint16(32508), + 155: uint16(24635), + 156: uint16(32437), + 157: uint16(37049), + 158: uint16(36208), + 159: uint16(22863), + 160: uint16(25549), + 161: uint16(31199), + 162: uint16(36275), + 163: uint16(21330), + 164: uint16(26063), + 165: uint16(31062), + 166: uint16(35781), + 167: uint16(38459), + 168: uint16(32452), + 169: uint16(38075), + 170: uint16(32386), + 171: uint16(22068), + 172: uint16(37257), + 173: uint16(26368), + 174: uint16(32618), + 175: uint16(23562), + 176: uint16(36981), + 177: uint16(26152), + 178: uint16(24038), + 179: uint16(20304), + 180: uint16(26590), + 181: uint16(20570), + 182: uint16(20316), + 183: uint16(22352), + 184: uint16(24231), + 185: uint16(59408), + 186: uint16(59409), + 187: uint16(59410), + 188: uint16(59411), + 189: uint16(59412), + }, + 87: { + 0: uint16(35896), + 1: uint16(35897), + 2: uint16(35898), + 3: uint16(35899), + 4: uint16(35900), + 5: uint16(35901), + 6: uint16(35902), + 7: uint16(35903), + 8: uint16(35904), + 9: uint16(35906), + 10: uint16(35907), + 11: uint16(35908), + 12: uint16(35909), + 13: uint16(35912), + 14: uint16(35914), + 15: uint16(35915), + 16: uint16(35917), + 17: uint16(35918), + 18: uint16(35919), + 19: uint16(35920), + 20: uint16(35921), + 21: uint16(35922), + 22: uint16(35923), + 23: uint16(35924), + 24: uint16(35926), + 25: uint16(35927), + 26: uint16(35928), + 27: uint16(35929), + 28: uint16(35931), + 29: uint16(35932), + 30: uint16(35933), + 31: uint16(35934), + 32: uint16(35935), + 33: uint16(35936), + 34: uint16(35939), + 35: uint16(35940), + 36: uint16(35941), + 37: uint16(35942), + 38: uint16(35943), + 39: uint16(35944), + 40: uint16(35945), + 41: uint16(35948), + 42: uint16(35949), + 43: uint16(35950), + 44: uint16(35951), + 45: uint16(35952), + 46: uint16(35953), + 47: uint16(35954), + 48: uint16(35956), + 49: uint16(35957), + 50: uint16(35958), + 51: uint16(35959), + 52: uint16(35963), + 53: uint16(35964), + 54: uint16(35965), + 55: uint16(35966), + 56: uint16(35967), + 57: uint16(35968), + 58: uint16(35969), + 59: uint16(35971), + 60: uint16(35972), + 61: uint16(35974), + 62: uint16(35975), + 63: uint16(35976), + 64: uint16(35979), + 65: uint16(35981), + 66: uint16(35982), + 67: uint16(35983), + 68: uint16(35984), + 69: uint16(35985), + 70: uint16(35986), + 71: uint16(35987), + 72: uint16(35989), + 73: uint16(35990), + 74: uint16(35991), + 75: uint16(35993), + 76: uint16(35994), + 77: uint16(35995), + 78: uint16(35996), + 79: uint16(35997), + 80: uint16(35998), + 81: uint16(35999), + 82: uint16(36000), + 83: uint16(36001), + 84: uint16(36002), + 85: uint16(36003), + 86: uint16(36004), + 87: uint16(36005), + 88: uint16(36006), + 89: uint16(36007), + 90: uint16(36008), + 91: uint16(36009), + 92: uint16(36010), + 93: uint16(36011), + 94: uint16(36012), + 95: uint16(36013), + 96: uint16(20109), + 97: uint16(19980), + 98: uint16(20800), + 99: uint16(19984), + 100: uint16(24319), + 101: uint16(21317), + 102: uint16(19989), + 103: uint16(20120), + 104: uint16(19998), + 105: uint16(39730), + 106: uint16(23404), + 107: uint16(22121), + 108: uint16(20008), + 109: uint16(31162), + 110: uint16(20031), + 111: uint16(21269), + 112: uint16(20039), + 113: uint16(22829), + 114: uint16(29243), + 115: uint16(21358), + 116: uint16(27664), + 117: uint16(22239), + 118: uint16(32996), + 119: uint16(39319), + 120: uint16(27603), + 121: uint16(30590), + 122: uint16(40727), + 123: uint16(20022), + 124: uint16(20127), + 125: uint16(40720), + 126: uint16(20060), + 127: uint16(20073), + 128: uint16(20115), + 129: uint16(33416), + 130: uint16(23387), + 131: uint16(21868), + 132: uint16(22031), + 133: uint16(20164), + 134: uint16(21389), + 135: uint16(21405), + 136: uint16(21411), + 137: uint16(21413), + 138: uint16(21422), + 139: uint16(38757), + 140: uint16(36189), + 141: uint16(21274), + 142: uint16(21493), + 143: uint16(21286), + 144: uint16(21294), + 145: uint16(21310), + 146: uint16(36188), + 147: uint16(21350), + 148: uint16(21347), + 149: uint16(20994), + 150: uint16(21000), + 151: uint16(21006), + 152: uint16(21037), + 153: uint16(21043), + 154: uint16(21055), + 155: uint16(21056), + 156: uint16(21068), + 157: uint16(21086), + 158: uint16(21089), + 159: uint16(21084), + 160: uint16(33967), + 161: uint16(21117), + 162: uint16(21122), + 163: uint16(21121), + 164: uint16(21136), + 165: uint16(21139), + 166: uint16(20866), + 167: uint16(32596), + 168: uint16(20155), + 169: uint16(20163), + 170: uint16(20169), + 171: uint16(20162), + 172: uint16(20200), + 173: uint16(20193), + 174: uint16(20203), + 175: uint16(20190), + 176: uint16(20251), + 177: uint16(20211), + 178: uint16(20258), + 179: uint16(20324), + 180: uint16(20213), + 181: uint16(20261), + 182: uint16(20263), + 183: uint16(20233), + 184: uint16(20267), + 185: uint16(20318), + 186: uint16(20327), + 187: uint16(25912), + 188: uint16(20314), + 189: uint16(20317), + }, + 88: { + 0: uint16(36014), + 1: uint16(36015), + 2: uint16(36016), + 3: uint16(36017), + 4: uint16(36018), + 5: uint16(36019), + 6: uint16(36020), + 7: uint16(36021), + 8: uint16(36022), + 9: uint16(36023), + 10: uint16(36024), + 11: uint16(36025), + 12: uint16(36026), + 13: uint16(36027), + 14: uint16(36028), + 15: uint16(36029), + 16: uint16(36030), + 17: uint16(36031), + 18: uint16(36032), + 19: uint16(36033), + 20: uint16(36034), + 21: uint16(36035), + 22: uint16(36036), + 23: uint16(36037), + 24: uint16(36038), + 25: uint16(36039), + 26: uint16(36040), + 27: uint16(36041), + 28: uint16(36042), + 29: uint16(36043), + 30: uint16(36044), + 31: uint16(36045), + 32: uint16(36046), + 33: uint16(36047), + 34: uint16(36048), + 35: uint16(36049), + 36: uint16(36050), + 37: uint16(36051), + 38: uint16(36052), + 39: uint16(36053), + 40: uint16(36054), + 41: uint16(36055), + 42: uint16(36056), + 43: uint16(36057), + 44: uint16(36058), + 45: uint16(36059), + 46: uint16(36060), + 47: uint16(36061), + 48: uint16(36062), + 49: uint16(36063), + 50: uint16(36064), + 51: uint16(36065), + 52: uint16(36066), + 53: uint16(36067), + 54: uint16(36068), + 55: uint16(36069), + 56: uint16(36070), + 57: uint16(36071), + 58: uint16(36072), + 59: uint16(36073), + 60: uint16(36074), + 61: uint16(36075), + 62: uint16(36076), + 63: uint16(36077), + 64: uint16(36078), + 65: uint16(36079), + 66: uint16(36080), + 67: uint16(36081), + 68: uint16(36082), + 69: uint16(36083), + 70: uint16(36084), + 71: uint16(36085), + 72: uint16(36086), + 73: uint16(36087), + 74: uint16(36088), + 75: uint16(36089), + 76: uint16(36090), + 77: uint16(36091), + 78: uint16(36092), + 79: uint16(36093), + 80: uint16(36094), + 81: uint16(36095), + 82: uint16(36096), + 83: uint16(36097), + 84: uint16(36098), + 85: uint16(36099), + 86: uint16(36100), + 87: uint16(36101), + 88: uint16(36102), + 89: uint16(36103), + 90: uint16(36104), + 91: uint16(36105), + 92: uint16(36106), + 93: uint16(36107), + 94: uint16(36108), + 95: uint16(36109), + 96: uint16(20319), + 97: uint16(20311), + 98: uint16(20274), + 99: uint16(20285), + 100: uint16(20342), + 101: uint16(20340), + 102: uint16(20369), + 103: uint16(20361), + 104: uint16(20355), + 105: uint16(20367), + 106: uint16(20350), + 107: uint16(20347), + 108: uint16(20394), + 109: uint16(20348), + 110: uint16(20396), + 111: uint16(20372), + 112: uint16(20454), + 113: uint16(20456), + 114: uint16(20458), + 115: uint16(20421), + 116: uint16(20442), + 117: uint16(20451), + 118: uint16(20444), + 119: uint16(20433), + 120: uint16(20447), + 121: uint16(20472), + 122: uint16(20521), + 123: uint16(20556), + 124: uint16(20467), + 125: uint16(20524), + 126: uint16(20495), + 127: uint16(20526), + 128: uint16(20525), + 129: uint16(20478), + 130: uint16(20508), + 131: uint16(20492), + 132: uint16(20517), + 133: uint16(20520), + 134: uint16(20606), + 135: uint16(20547), + 136: uint16(20565), + 137: uint16(20552), + 138: uint16(20558), + 139: uint16(20588), + 140: uint16(20603), + 141: uint16(20645), + 142: uint16(20647), + 143: uint16(20649), + 144: uint16(20666), + 145: uint16(20694), + 146: uint16(20742), + 147: uint16(20717), + 148: uint16(20716), + 149: uint16(20710), + 150: uint16(20718), + 151: uint16(20743), + 152: uint16(20747), + 153: uint16(20189), + 154: uint16(27709), + 155: uint16(20312), + 156: uint16(20325), + 157: uint16(20430), + 158: uint16(40864), + 159: uint16(27718), + 160: uint16(31860), + 161: uint16(20846), + 162: uint16(24061), + 163: uint16(40649), + 164: uint16(39320), + 165: uint16(20865), + 166: uint16(22804), + 167: uint16(21241), + 168: uint16(21261), + 169: uint16(35335), + 170: uint16(21264), + 171: uint16(20971), + 172: uint16(22809), + 173: uint16(20821), + 174: uint16(20128), + 175: uint16(20822), + 176: uint16(20147), + 177: uint16(34926), + 178: uint16(34980), + 179: uint16(20149), + 180: uint16(33044), + 181: uint16(35026), + 182: uint16(31104), + 183: uint16(23348), + 184: uint16(34819), + 185: uint16(32696), + 186: uint16(20907), + 187: uint16(20913), + 188: uint16(20925), + 189: uint16(20924), + }, + 89: { + 0: uint16(36110), + 1: uint16(36111), + 2: uint16(36112), + 3: uint16(36113), + 4: uint16(36114), + 5: uint16(36115), + 6: uint16(36116), + 7: uint16(36117), + 8: uint16(36118), + 9: uint16(36119), + 10: uint16(36120), + 11: uint16(36121), + 12: uint16(36122), + 13: uint16(36123), + 14: uint16(36124), + 15: uint16(36128), + 16: uint16(36177), + 17: uint16(36178), + 18: uint16(36183), + 19: uint16(36191), + 20: uint16(36197), + 21: uint16(36200), + 22: uint16(36201), + 23: uint16(36202), + 24: uint16(36204), + 25: uint16(36206), + 26: uint16(36207), + 27: uint16(36209), + 28: uint16(36210), + 29: uint16(36216), + 30: uint16(36217), + 31: uint16(36218), + 32: uint16(36219), + 33: uint16(36220), + 34: uint16(36221), + 35: uint16(36222), + 36: uint16(36223), + 37: uint16(36224), + 38: uint16(36226), + 39: uint16(36227), + 40: uint16(36230), + 41: uint16(36231), + 42: uint16(36232), + 43: uint16(36233), + 44: uint16(36236), + 45: uint16(36237), + 46: uint16(36238), + 47: uint16(36239), + 48: uint16(36240), + 49: uint16(36242), + 50: uint16(36243), + 51: uint16(36245), + 52: uint16(36246), + 53: uint16(36247), + 54: uint16(36248), + 55: uint16(36249), + 56: uint16(36250), + 57: uint16(36251), + 58: uint16(36252), + 59: uint16(36253), + 60: uint16(36254), + 61: uint16(36256), + 62: uint16(36257), + 63: uint16(36258), + 64: uint16(36260), + 65: uint16(36261), + 66: uint16(36262), + 67: uint16(36263), + 68: uint16(36264), + 69: uint16(36265), + 70: uint16(36266), + 71: uint16(36267), + 72: uint16(36268), + 73: uint16(36269), + 74: uint16(36270), + 75: uint16(36271), + 76: uint16(36272), + 77: uint16(36274), + 78: uint16(36278), + 79: uint16(36279), + 80: uint16(36281), + 81: uint16(36283), + 82: uint16(36285), + 83: uint16(36288), + 84: uint16(36289), + 85: uint16(36290), + 86: uint16(36293), + 87: uint16(36295), + 88: uint16(36296), + 89: uint16(36297), + 90: uint16(36298), + 91: uint16(36301), + 92: uint16(36304), + 93: uint16(36306), + 94: uint16(36307), + 95: uint16(36308), + 96: uint16(20935), + 97: uint16(20886), + 98: uint16(20898), + 99: uint16(20901), + 100: uint16(35744), + 101: uint16(35750), + 102: uint16(35751), + 103: uint16(35754), + 104: uint16(35764), + 105: uint16(35765), + 106: uint16(35767), + 107: uint16(35778), + 108: uint16(35779), + 109: uint16(35787), + 110: uint16(35791), + 111: uint16(35790), + 112: uint16(35794), + 113: uint16(35795), + 114: uint16(35796), + 115: uint16(35798), + 116: uint16(35800), + 117: uint16(35801), + 118: uint16(35804), + 119: uint16(35807), + 120: uint16(35808), + 121: uint16(35812), + 122: uint16(35816), + 123: uint16(35817), + 124: uint16(35822), + 125: uint16(35824), + 126: uint16(35827), + 127: uint16(35830), + 128: uint16(35833), + 129: uint16(35836), + 130: uint16(35839), + 131: uint16(35840), + 132: uint16(35842), + 133: uint16(35844), + 134: uint16(35847), + 135: uint16(35852), + 136: uint16(35855), + 137: uint16(35857), + 138: uint16(35858), + 139: uint16(35860), + 140: uint16(35861), + 141: uint16(35862), + 142: uint16(35865), + 143: uint16(35867), + 144: uint16(35864), + 145: uint16(35869), + 146: uint16(35871), + 147: uint16(35872), + 148: uint16(35873), + 149: uint16(35877), + 150: uint16(35879), + 151: uint16(35882), + 152: uint16(35883), + 153: uint16(35886), + 154: uint16(35887), + 155: uint16(35890), + 156: uint16(35891), + 157: uint16(35893), + 158: uint16(35894), + 159: uint16(21353), + 160: uint16(21370), + 161: uint16(38429), + 162: uint16(38434), + 163: uint16(38433), + 164: uint16(38449), + 165: uint16(38442), + 166: uint16(38461), + 167: uint16(38460), + 168: uint16(38466), + 169: uint16(38473), + 170: uint16(38484), + 171: uint16(38495), + 172: uint16(38503), + 173: uint16(38508), + 174: uint16(38514), + 175: uint16(38516), + 176: uint16(38536), + 177: uint16(38541), + 178: uint16(38551), + 179: uint16(38576), + 180: uint16(37015), + 181: uint16(37019), + 182: uint16(37021), + 183: uint16(37017), + 184: uint16(37036), + 185: uint16(37025), + 186: uint16(37044), + 187: uint16(37043), + 188: uint16(37046), + 189: uint16(37050), + }, + 90: { + 0: uint16(36309), + 1: uint16(36312), + 2: uint16(36313), + 3: uint16(36316), + 4: uint16(36320), + 5: uint16(36321), + 6: uint16(36322), + 7: uint16(36325), + 8: uint16(36326), + 9: uint16(36327), + 10: uint16(36329), + 11: uint16(36333), + 12: uint16(36334), + 13: uint16(36336), + 14: uint16(36337), + 15: uint16(36338), + 16: uint16(36340), + 17: uint16(36342), + 18: uint16(36348), + 19: uint16(36350), + 20: uint16(36351), + 21: uint16(36352), + 22: uint16(36353), + 23: uint16(36354), + 24: uint16(36355), + 25: uint16(36356), + 26: uint16(36358), + 27: uint16(36359), + 28: uint16(36360), + 29: uint16(36363), + 30: uint16(36365), + 31: uint16(36366), + 32: uint16(36368), + 33: uint16(36369), + 34: uint16(36370), + 35: uint16(36371), + 36: uint16(36373), + 37: uint16(36374), + 38: uint16(36375), + 39: uint16(36376), + 40: uint16(36377), + 41: uint16(36378), + 42: uint16(36379), + 43: uint16(36380), + 44: uint16(36384), + 45: uint16(36385), + 46: uint16(36388), + 47: uint16(36389), + 48: uint16(36390), + 49: uint16(36391), + 50: uint16(36392), + 51: uint16(36395), + 52: uint16(36397), + 53: uint16(36400), + 54: uint16(36402), + 55: uint16(36403), + 56: uint16(36404), + 57: uint16(36406), + 58: uint16(36407), + 59: uint16(36408), + 60: uint16(36411), + 61: uint16(36412), + 62: uint16(36414), + 63: uint16(36415), + 64: uint16(36419), + 65: uint16(36421), + 66: uint16(36422), + 67: uint16(36428), + 68: uint16(36429), + 69: uint16(36430), + 70: uint16(36431), + 71: uint16(36432), + 72: uint16(36435), + 73: uint16(36436), + 74: uint16(36437), + 75: uint16(36438), + 76: uint16(36439), + 77: uint16(36440), + 78: uint16(36442), + 79: uint16(36443), + 80: uint16(36444), + 81: uint16(36445), + 82: uint16(36446), + 83: uint16(36447), + 84: uint16(36448), + 85: uint16(36449), + 86: uint16(36450), + 87: uint16(36451), + 88: uint16(36452), + 89: uint16(36453), + 90: uint16(36455), + 91: uint16(36456), + 92: uint16(36458), + 93: uint16(36459), + 94: uint16(36462), + 95: uint16(36465), + 96: uint16(37048), + 97: uint16(37040), + 98: uint16(37071), + 99: uint16(37061), + 100: uint16(37054), + 101: uint16(37072), + 102: uint16(37060), + 103: uint16(37063), + 104: uint16(37075), + 105: uint16(37094), + 106: uint16(37090), + 107: uint16(37084), + 108: uint16(37079), + 109: uint16(37083), + 110: uint16(37099), + 111: uint16(37103), + 112: uint16(37118), + 113: uint16(37124), + 114: uint16(37154), + 115: uint16(37150), + 116: uint16(37155), + 117: uint16(37169), + 118: uint16(37167), + 119: uint16(37177), + 120: uint16(37187), + 121: uint16(37190), + 122: uint16(21005), + 123: uint16(22850), + 124: uint16(21154), + 125: uint16(21164), + 126: uint16(21165), + 127: uint16(21182), + 128: uint16(21759), + 129: uint16(21200), + 130: uint16(21206), + 131: uint16(21232), + 132: uint16(21471), + 133: uint16(29166), + 134: uint16(30669), + 135: uint16(24308), + 136: uint16(20981), + 137: uint16(20988), + 138: uint16(39727), + 139: uint16(21430), + 140: uint16(24321), + 141: uint16(30042), + 142: uint16(24047), + 143: uint16(22348), + 144: uint16(22441), + 145: uint16(22433), + 146: uint16(22654), + 147: uint16(22716), + 148: uint16(22725), + 149: uint16(22737), + 150: uint16(22313), + 151: uint16(22316), + 152: uint16(22314), + 153: uint16(22323), + 154: uint16(22329), + 155: uint16(22318), + 156: uint16(22319), + 157: uint16(22364), + 158: uint16(22331), + 159: uint16(22338), + 160: uint16(22377), + 161: uint16(22405), + 162: uint16(22379), + 163: uint16(22406), + 164: uint16(22396), + 165: uint16(22395), + 166: uint16(22376), + 167: uint16(22381), + 168: uint16(22390), + 169: uint16(22387), + 170: uint16(22445), + 171: uint16(22436), + 172: uint16(22412), + 173: uint16(22450), + 174: uint16(22479), + 175: uint16(22439), + 176: uint16(22452), + 177: uint16(22419), + 178: uint16(22432), + 179: uint16(22485), + 180: uint16(22488), + 181: uint16(22490), + 182: uint16(22489), + 183: uint16(22482), + 184: uint16(22456), + 185: uint16(22516), + 186: uint16(22511), + 187: uint16(22520), + 188: uint16(22500), + 189: uint16(22493), + }, + 91: { + 0: uint16(36467), + 1: uint16(36469), + 2: uint16(36471), + 3: uint16(36472), + 4: uint16(36473), + 5: uint16(36474), + 6: uint16(36475), + 7: uint16(36477), + 8: uint16(36478), + 9: uint16(36480), + 10: uint16(36482), + 11: uint16(36483), + 12: uint16(36484), + 13: uint16(36486), + 14: uint16(36488), + 15: uint16(36489), + 16: uint16(36490), + 17: uint16(36491), + 18: uint16(36492), + 19: uint16(36493), + 20: uint16(36494), + 21: uint16(36497), + 22: uint16(36498), + 23: uint16(36499), + 24: uint16(36501), + 25: uint16(36502), + 26: uint16(36503), + 27: uint16(36504), + 28: uint16(36505), + 29: uint16(36506), + 30: uint16(36507), + 31: uint16(36509), + 32: uint16(36511), + 33: uint16(36512), + 34: uint16(36513), + 35: uint16(36514), + 36: uint16(36515), + 37: uint16(36516), + 38: uint16(36517), + 39: uint16(36518), + 40: uint16(36519), + 41: uint16(36520), + 42: uint16(36521), + 43: uint16(36522), + 44: uint16(36525), + 45: uint16(36526), + 46: uint16(36528), + 47: uint16(36529), + 48: uint16(36531), + 49: uint16(36532), + 50: uint16(36533), + 51: uint16(36534), + 52: uint16(36535), + 53: uint16(36536), + 54: uint16(36537), + 55: uint16(36539), + 56: uint16(36540), + 57: uint16(36541), + 58: uint16(36542), + 59: uint16(36543), + 60: uint16(36544), + 61: uint16(36545), + 62: uint16(36546), + 63: uint16(36547), + 64: uint16(36548), + 65: uint16(36549), + 66: uint16(36550), + 67: uint16(36551), + 68: uint16(36552), + 69: uint16(36553), + 70: uint16(36554), + 71: uint16(36555), + 72: uint16(36556), + 73: uint16(36557), + 74: uint16(36559), + 75: uint16(36560), + 76: uint16(36561), + 77: uint16(36562), + 78: uint16(36563), + 79: uint16(36564), + 80: uint16(36565), + 81: uint16(36566), + 82: uint16(36567), + 83: uint16(36568), + 84: uint16(36569), + 85: uint16(36570), + 86: uint16(36571), + 87: uint16(36572), + 88: uint16(36573), + 89: uint16(36574), + 90: uint16(36575), + 91: uint16(36576), + 92: uint16(36577), + 93: uint16(36578), + 94: uint16(36579), + 95: uint16(36580), + 96: uint16(22539), + 97: uint16(22541), + 98: uint16(22525), + 99: uint16(22509), + 100: uint16(22528), + 101: uint16(22558), + 102: uint16(22553), + 103: uint16(22596), + 104: uint16(22560), + 105: uint16(22629), + 106: uint16(22636), + 107: uint16(22657), + 108: uint16(22665), + 109: uint16(22682), + 110: uint16(22656), + 111: uint16(39336), + 112: uint16(40729), + 113: uint16(25087), + 114: uint16(33401), + 115: uint16(33405), + 116: uint16(33407), + 117: uint16(33423), + 118: uint16(33418), + 119: uint16(33448), + 120: uint16(33412), + 121: uint16(33422), + 122: uint16(33425), + 123: uint16(33431), + 124: uint16(33433), + 125: uint16(33451), + 126: uint16(33464), + 127: uint16(33470), + 128: uint16(33456), + 129: uint16(33480), + 130: uint16(33482), + 131: uint16(33507), + 132: uint16(33432), + 133: uint16(33463), + 134: uint16(33454), + 135: uint16(33483), + 136: uint16(33484), + 137: uint16(33473), + 138: uint16(33449), + 139: uint16(33460), + 140: uint16(33441), + 141: uint16(33450), + 142: uint16(33439), + 143: uint16(33476), + 144: uint16(33486), + 145: uint16(33444), + 146: uint16(33505), + 147: uint16(33545), + 148: uint16(33527), + 149: uint16(33508), + 150: uint16(33551), + 151: uint16(33543), + 152: uint16(33500), + 153: uint16(33524), + 154: uint16(33490), + 155: uint16(33496), + 156: uint16(33548), + 157: uint16(33531), + 158: uint16(33491), + 159: uint16(33553), + 160: uint16(33562), + 161: uint16(33542), + 162: uint16(33556), + 163: uint16(33557), + 164: uint16(33504), + 165: uint16(33493), + 166: uint16(33564), + 167: uint16(33617), + 168: uint16(33627), + 169: uint16(33628), + 170: uint16(33544), + 171: uint16(33682), + 172: uint16(33596), + 173: uint16(33588), + 174: uint16(33585), + 175: uint16(33691), + 176: uint16(33630), + 177: uint16(33583), + 178: uint16(33615), + 179: uint16(33607), + 180: uint16(33603), + 181: uint16(33631), + 182: uint16(33600), + 183: uint16(33559), + 184: uint16(33632), + 185: uint16(33581), + 186: uint16(33594), + 187: uint16(33587), + 188: uint16(33638), + 189: uint16(33637), + }, + 92: { + 0: uint16(36581), + 1: uint16(36582), + 2: uint16(36583), + 3: uint16(36584), + 4: uint16(36585), + 5: uint16(36586), + 6: uint16(36587), + 7: uint16(36588), + 8: uint16(36589), + 9: uint16(36590), + 10: uint16(36591), + 11: uint16(36592), + 12: uint16(36593), + 13: uint16(36594), + 14: uint16(36595), + 15: uint16(36596), + 16: uint16(36597), + 17: uint16(36598), + 18: uint16(36599), + 19: uint16(36600), + 20: uint16(36601), + 21: uint16(36602), + 22: uint16(36603), + 23: uint16(36604), + 24: uint16(36605), + 25: uint16(36606), + 26: uint16(36607), + 27: uint16(36608), + 28: uint16(36609), + 29: uint16(36610), + 30: uint16(36611), + 31: uint16(36612), + 32: uint16(36613), + 33: uint16(36614), + 34: uint16(36615), + 35: uint16(36616), + 36: uint16(36617), + 37: uint16(36618), + 38: uint16(36619), + 39: uint16(36620), + 40: uint16(36621), + 41: uint16(36622), + 42: uint16(36623), + 43: uint16(36624), + 44: uint16(36625), + 45: uint16(36626), + 46: uint16(36627), + 47: uint16(36628), + 48: uint16(36629), + 49: uint16(36630), + 50: uint16(36631), + 51: uint16(36632), + 52: uint16(36633), + 53: uint16(36634), + 54: uint16(36635), + 55: uint16(36636), + 56: uint16(36637), + 57: uint16(36638), + 58: uint16(36639), + 59: uint16(36640), + 60: uint16(36641), + 61: uint16(36642), + 62: uint16(36643), + 63: uint16(36644), + 64: uint16(36645), + 65: uint16(36646), + 66: uint16(36647), + 67: uint16(36648), + 68: uint16(36649), + 69: uint16(36650), + 70: uint16(36651), + 71: uint16(36652), + 72: uint16(36653), + 73: uint16(36654), + 74: uint16(36655), + 75: uint16(36656), + 76: uint16(36657), + 77: uint16(36658), + 78: uint16(36659), + 79: uint16(36660), + 80: uint16(36661), + 81: uint16(36662), + 82: uint16(36663), + 83: uint16(36664), + 84: uint16(36665), + 85: uint16(36666), + 86: uint16(36667), + 87: uint16(36668), + 88: uint16(36669), + 89: uint16(36670), + 90: uint16(36671), + 91: uint16(36672), + 92: uint16(36673), + 93: uint16(36674), + 94: uint16(36675), + 95: uint16(36676), + 96: uint16(33640), + 97: uint16(33563), + 98: uint16(33641), + 99: uint16(33644), + 100: uint16(33642), + 101: uint16(33645), + 102: uint16(33646), + 103: uint16(33712), + 104: uint16(33656), + 105: uint16(33715), + 106: uint16(33716), + 107: uint16(33696), + 108: uint16(33706), + 109: uint16(33683), + 110: uint16(33692), + 111: uint16(33669), + 112: uint16(33660), + 113: uint16(33718), + 114: uint16(33705), + 115: uint16(33661), + 116: uint16(33720), + 117: uint16(33659), + 118: uint16(33688), + 119: uint16(33694), + 120: uint16(33704), + 121: uint16(33722), + 122: uint16(33724), + 123: uint16(33729), + 124: uint16(33793), + 125: uint16(33765), + 126: uint16(33752), + 127: uint16(22535), + 128: uint16(33816), + 129: uint16(33803), + 130: uint16(33757), + 131: uint16(33789), + 132: uint16(33750), + 133: uint16(33820), + 134: uint16(33848), + 135: uint16(33809), + 136: uint16(33798), + 137: uint16(33748), + 138: uint16(33759), + 139: uint16(33807), + 140: uint16(33795), + 141: uint16(33784), + 142: uint16(33785), + 143: uint16(33770), + 144: uint16(33733), + 145: uint16(33728), + 146: uint16(33830), + 147: uint16(33776), + 148: uint16(33761), + 149: uint16(33884), + 150: uint16(33873), + 151: uint16(33882), + 152: uint16(33881), + 153: uint16(33907), + 154: uint16(33927), + 155: uint16(33928), + 156: uint16(33914), + 157: uint16(33929), + 158: uint16(33912), + 159: uint16(33852), + 160: uint16(33862), + 161: uint16(33897), + 162: uint16(33910), + 163: uint16(33932), + 164: uint16(33934), + 165: uint16(33841), + 166: uint16(33901), + 167: uint16(33985), + 168: uint16(33997), + 169: uint16(34000), + 170: uint16(34022), + 171: uint16(33981), + 172: uint16(34003), + 173: uint16(33994), + 174: uint16(33983), + 175: uint16(33978), + 176: uint16(34016), + 177: uint16(33953), + 178: uint16(33977), + 179: uint16(33972), + 180: uint16(33943), + 181: uint16(34021), + 182: uint16(34019), + 183: uint16(34060), + 184: uint16(29965), + 185: uint16(34104), + 186: uint16(34032), + 187: uint16(34105), + 188: uint16(34079), + 189: uint16(34106), + }, + 93: { + 0: uint16(36677), + 1: uint16(36678), + 2: uint16(36679), + 3: uint16(36680), + 4: uint16(36681), + 5: uint16(36682), + 6: uint16(36683), + 7: uint16(36684), + 8: uint16(36685), + 9: uint16(36686), + 10: uint16(36687), + 11: uint16(36688), + 12: uint16(36689), + 13: uint16(36690), + 14: uint16(36691), + 15: uint16(36692), + 16: uint16(36693), + 17: uint16(36694), + 18: uint16(36695), + 19: uint16(36696), + 20: uint16(36697), + 21: uint16(36698), + 22: uint16(36699), + 23: uint16(36700), + 24: uint16(36701), + 25: uint16(36702), + 26: uint16(36703), + 27: uint16(36704), + 28: uint16(36705), + 29: uint16(36706), + 30: uint16(36707), + 31: uint16(36708), + 32: uint16(36709), + 33: uint16(36714), + 34: uint16(36736), + 35: uint16(36748), + 36: uint16(36754), + 37: uint16(36765), + 38: uint16(36768), + 39: uint16(36769), + 40: uint16(36770), + 41: uint16(36772), + 42: uint16(36773), + 43: uint16(36774), + 44: uint16(36775), + 45: uint16(36778), + 46: uint16(36780), + 47: uint16(36781), + 48: uint16(36782), + 49: uint16(36783), + 50: uint16(36786), + 51: uint16(36787), + 52: uint16(36788), + 53: uint16(36789), + 54: uint16(36791), + 55: uint16(36792), + 56: uint16(36794), + 57: uint16(36795), + 58: uint16(36796), + 59: uint16(36799), + 60: uint16(36800), + 61: uint16(36803), + 62: uint16(36806), + 63: uint16(36809), + 64: uint16(36810), + 65: uint16(36811), + 66: uint16(36812), + 67: uint16(36813), + 68: uint16(36815), + 69: uint16(36818), + 70: uint16(36822), + 71: uint16(36823), + 72: uint16(36826), + 73: uint16(36832), + 74: uint16(36833), + 75: uint16(36835), + 76: uint16(36839), + 77: uint16(36844), + 78: uint16(36847), + 79: uint16(36849), + 80: uint16(36850), + 81: uint16(36852), + 82: uint16(36853), + 83: uint16(36854), + 84: uint16(36858), + 85: uint16(36859), + 86: uint16(36860), + 87: uint16(36862), + 88: uint16(36863), + 89: uint16(36871), + 90: uint16(36872), + 91: uint16(36876), + 92: uint16(36878), + 93: uint16(36883), + 94: uint16(36885), + 95: uint16(36888), + 96: uint16(34134), + 97: uint16(34107), + 98: uint16(34047), + 99: uint16(34044), + 100: uint16(34137), + 101: uint16(34120), + 102: uint16(34152), + 103: uint16(34148), + 104: uint16(34142), + 105: uint16(34170), + 106: uint16(30626), + 107: uint16(34115), + 108: uint16(34162), + 109: uint16(34171), + 110: uint16(34212), + 111: uint16(34216), + 112: uint16(34183), + 113: uint16(34191), + 114: uint16(34169), + 115: uint16(34222), + 116: uint16(34204), + 117: uint16(34181), + 118: uint16(34233), + 119: uint16(34231), + 120: uint16(34224), + 121: uint16(34259), + 122: uint16(34241), + 123: uint16(34268), + 124: uint16(34303), + 125: uint16(34343), + 126: uint16(34309), + 127: uint16(34345), + 128: uint16(34326), + 129: uint16(34364), + 130: uint16(24318), + 131: uint16(24328), + 132: uint16(22844), + 133: uint16(22849), + 134: uint16(32823), + 135: uint16(22869), + 136: uint16(22874), + 137: uint16(22872), + 138: uint16(21263), + 139: uint16(23586), + 140: uint16(23589), + 141: uint16(23596), + 142: uint16(23604), + 143: uint16(25164), + 144: uint16(25194), + 145: uint16(25247), + 146: uint16(25275), + 147: uint16(25290), + 148: uint16(25306), + 149: uint16(25303), + 150: uint16(25326), + 151: uint16(25378), + 152: uint16(25334), + 153: uint16(25401), + 154: uint16(25419), + 155: uint16(25411), + 156: uint16(25517), + 157: uint16(25590), + 158: uint16(25457), + 159: uint16(25466), + 160: uint16(25486), + 161: uint16(25524), + 162: uint16(25453), + 163: uint16(25516), + 164: uint16(25482), + 165: uint16(25449), + 166: uint16(25518), + 167: uint16(25532), + 168: uint16(25586), + 169: uint16(25592), + 170: uint16(25568), + 171: uint16(25599), + 172: uint16(25540), + 173: uint16(25566), + 174: uint16(25550), + 175: uint16(25682), + 176: uint16(25542), + 177: uint16(25534), + 178: uint16(25669), + 179: uint16(25665), + 180: uint16(25611), + 181: uint16(25627), + 182: uint16(25632), + 183: uint16(25612), + 184: uint16(25638), + 185: uint16(25633), + 186: uint16(25694), + 187: uint16(25732), + 188: uint16(25709), + 189: uint16(25750), + }, + 94: { + 0: uint16(36889), + 1: uint16(36892), + 2: uint16(36899), + 3: uint16(36900), + 4: uint16(36901), + 5: uint16(36903), + 6: uint16(36904), + 7: uint16(36905), + 8: uint16(36906), + 9: uint16(36907), + 10: uint16(36908), + 11: uint16(36912), + 12: uint16(36913), + 13: uint16(36914), + 14: uint16(36915), + 15: uint16(36916), + 16: uint16(36919), + 17: uint16(36921), + 18: uint16(36922), + 19: uint16(36925), + 20: uint16(36927), + 21: uint16(36928), + 22: uint16(36931), + 23: uint16(36933), + 24: uint16(36934), + 25: uint16(36936), + 26: uint16(36937), + 27: uint16(36938), + 28: uint16(36939), + 29: uint16(36940), + 30: uint16(36942), + 31: uint16(36948), + 32: uint16(36949), + 33: uint16(36950), + 34: uint16(36953), + 35: uint16(36954), + 36: uint16(36956), + 37: uint16(36957), + 38: uint16(36958), + 39: uint16(36959), + 40: uint16(36960), + 41: uint16(36961), + 42: uint16(36964), + 43: uint16(36966), + 44: uint16(36967), + 45: uint16(36969), + 46: uint16(36970), + 47: uint16(36971), + 48: uint16(36972), + 49: uint16(36975), + 50: uint16(36976), + 51: uint16(36977), + 52: uint16(36978), + 53: uint16(36979), + 54: uint16(36982), + 55: uint16(36983), + 56: uint16(36984), + 57: uint16(36985), + 58: uint16(36986), + 59: uint16(36987), + 60: uint16(36988), + 61: uint16(36990), + 62: uint16(36993), + 63: uint16(36996), + 64: uint16(36997), + 65: uint16(36998), + 66: uint16(36999), + 67: uint16(37001), + 68: uint16(37002), + 69: uint16(37004), + 70: uint16(37005), + 71: uint16(37006), + 72: uint16(37007), + 73: uint16(37008), + 74: uint16(37010), + 75: uint16(37012), + 76: uint16(37014), + 77: uint16(37016), + 78: uint16(37018), + 79: uint16(37020), + 80: uint16(37022), + 81: uint16(37023), + 82: uint16(37024), + 83: uint16(37028), + 84: uint16(37029), + 85: uint16(37031), + 86: uint16(37032), + 87: uint16(37033), + 88: uint16(37035), + 89: uint16(37037), + 90: uint16(37042), + 91: uint16(37047), + 92: uint16(37052), + 93: uint16(37053), + 94: uint16(37055), + 95: uint16(37056), + 96: uint16(25722), + 97: uint16(25783), + 98: uint16(25784), + 99: uint16(25753), + 100: uint16(25786), + 101: uint16(25792), + 102: uint16(25808), + 103: uint16(25815), + 104: uint16(25828), + 105: uint16(25826), + 106: uint16(25865), + 107: uint16(25893), + 108: uint16(25902), + 109: uint16(24331), + 110: uint16(24530), + 111: uint16(29977), + 112: uint16(24337), + 113: uint16(21343), + 114: uint16(21489), + 115: uint16(21501), + 116: uint16(21481), + 117: uint16(21480), + 118: uint16(21499), + 119: uint16(21522), + 120: uint16(21526), + 121: uint16(21510), + 122: uint16(21579), + 123: uint16(21586), + 124: uint16(21587), + 125: uint16(21588), + 126: uint16(21590), + 127: uint16(21571), + 128: uint16(21537), + 129: uint16(21591), + 130: uint16(21593), + 131: uint16(21539), + 132: uint16(21554), + 133: uint16(21634), + 134: uint16(21652), + 135: uint16(21623), + 136: uint16(21617), + 137: uint16(21604), + 138: uint16(21658), + 139: uint16(21659), + 140: uint16(21636), + 141: uint16(21622), + 142: uint16(21606), + 143: uint16(21661), + 144: uint16(21712), + 145: uint16(21677), + 146: uint16(21698), + 147: uint16(21684), + 148: uint16(21714), + 149: uint16(21671), + 150: uint16(21670), + 151: uint16(21715), + 152: uint16(21716), + 153: uint16(21618), + 154: uint16(21667), + 155: uint16(21717), + 156: uint16(21691), + 157: uint16(21695), + 158: uint16(21708), + 159: uint16(21721), + 160: uint16(21722), + 161: uint16(21724), + 162: uint16(21673), + 163: uint16(21674), + 164: uint16(21668), + 165: uint16(21725), + 166: uint16(21711), + 167: uint16(21726), + 168: uint16(21787), + 169: uint16(21735), + 170: uint16(21792), + 171: uint16(21757), + 172: uint16(21780), + 173: uint16(21747), + 174: uint16(21794), + 175: uint16(21795), + 176: uint16(21775), + 177: uint16(21777), + 178: uint16(21799), + 179: uint16(21802), + 180: uint16(21863), + 181: uint16(21903), + 182: uint16(21941), + 183: uint16(21833), + 184: uint16(21869), + 185: uint16(21825), + 186: uint16(21845), + 187: uint16(21823), + 188: uint16(21840), + 189: uint16(21820), + }, + 95: { + 0: uint16(37058), + 1: uint16(37059), + 2: uint16(37062), + 3: uint16(37064), + 4: uint16(37065), + 5: uint16(37067), + 6: uint16(37068), + 7: uint16(37069), + 8: uint16(37074), + 9: uint16(37076), + 10: uint16(37077), + 11: uint16(37078), + 12: uint16(37080), + 13: uint16(37081), + 14: uint16(37082), + 15: uint16(37086), + 16: uint16(37087), + 17: uint16(37088), + 18: uint16(37091), + 19: uint16(37092), + 20: uint16(37093), + 21: uint16(37097), + 22: uint16(37098), + 23: uint16(37100), + 24: uint16(37102), + 25: uint16(37104), + 26: uint16(37105), + 27: uint16(37106), + 28: uint16(37107), + 29: uint16(37109), + 30: uint16(37110), + 31: uint16(37111), + 32: uint16(37113), + 33: uint16(37114), + 34: uint16(37115), + 35: uint16(37116), + 36: uint16(37119), + 37: uint16(37120), + 38: uint16(37121), + 39: uint16(37123), + 40: uint16(37125), + 41: uint16(37126), + 42: uint16(37127), + 43: uint16(37128), + 44: uint16(37129), + 45: uint16(37130), + 46: uint16(37131), + 47: uint16(37132), + 48: uint16(37133), + 49: uint16(37134), + 50: uint16(37135), + 51: uint16(37136), + 52: uint16(37137), + 53: uint16(37138), + 54: uint16(37139), + 55: uint16(37140), + 56: uint16(37141), + 57: uint16(37142), + 58: uint16(37143), + 59: uint16(37144), + 60: uint16(37146), + 61: uint16(37147), + 62: uint16(37148), + 63: uint16(37149), + 64: uint16(37151), + 65: uint16(37152), + 66: uint16(37153), + 67: uint16(37156), + 68: uint16(37157), + 69: uint16(37158), + 70: uint16(37159), + 71: uint16(37160), + 72: uint16(37161), + 73: uint16(37162), + 74: uint16(37163), + 75: uint16(37164), + 76: uint16(37165), + 77: uint16(37166), + 78: uint16(37168), + 79: uint16(37170), + 80: uint16(37171), + 81: uint16(37172), + 82: uint16(37173), + 83: uint16(37174), + 84: uint16(37175), + 85: uint16(37176), + 86: uint16(37178), + 87: uint16(37179), + 88: uint16(37180), + 89: uint16(37181), + 90: uint16(37182), + 91: uint16(37183), + 92: uint16(37184), + 93: uint16(37185), + 94: uint16(37186), + 95: uint16(37188), + 96: uint16(21815), + 97: uint16(21846), + 98: uint16(21877), + 99: uint16(21878), + 100: uint16(21879), + 101: uint16(21811), + 102: uint16(21808), + 103: uint16(21852), + 104: uint16(21899), + 105: uint16(21970), + 106: uint16(21891), + 107: uint16(21937), + 108: uint16(21945), + 109: uint16(21896), + 110: uint16(21889), + 111: uint16(21919), + 112: uint16(21886), + 113: uint16(21974), + 114: uint16(21905), + 115: uint16(21883), + 116: uint16(21983), + 117: uint16(21949), + 118: uint16(21950), + 119: uint16(21908), + 120: uint16(21913), + 121: uint16(21994), + 122: uint16(22007), + 123: uint16(21961), + 124: uint16(22047), + 125: uint16(21969), + 126: uint16(21995), + 127: uint16(21996), + 128: uint16(21972), + 129: uint16(21990), + 130: uint16(21981), + 131: uint16(21956), + 132: uint16(21999), + 133: uint16(21989), + 134: uint16(22002), + 135: uint16(22003), + 136: uint16(21964), + 137: uint16(21965), + 138: uint16(21992), + 139: uint16(22005), + 140: uint16(21988), + 141: uint16(36756), + 142: uint16(22046), + 143: uint16(22024), + 144: uint16(22028), + 145: uint16(22017), + 146: uint16(22052), + 147: uint16(22051), + 148: uint16(22014), + 149: uint16(22016), + 150: uint16(22055), + 151: uint16(22061), + 152: uint16(22104), + 153: uint16(22073), + 154: uint16(22103), + 155: uint16(22060), + 156: uint16(22093), + 157: uint16(22114), + 158: uint16(22105), + 159: uint16(22108), + 160: uint16(22092), + 161: uint16(22100), + 162: uint16(22150), + 163: uint16(22116), + 164: uint16(22129), + 165: uint16(22123), + 166: uint16(22139), + 167: uint16(22140), + 168: uint16(22149), + 169: uint16(22163), + 170: uint16(22191), + 171: uint16(22228), + 172: uint16(22231), + 173: uint16(22237), + 174: uint16(22241), + 175: uint16(22261), + 176: uint16(22251), + 177: uint16(22265), + 178: uint16(22271), + 179: uint16(22276), + 180: uint16(22282), + 181: uint16(22281), + 182: uint16(22300), + 183: uint16(24079), + 184: uint16(24089), + 185: uint16(24084), + 186: uint16(24081), + 187: uint16(24113), + 188: uint16(24123), + 189: uint16(24124), + }, + 96: { + 0: uint16(37189), + 1: uint16(37191), + 2: uint16(37192), + 3: uint16(37201), + 4: uint16(37203), + 5: uint16(37204), + 6: uint16(37205), + 7: uint16(37206), + 8: uint16(37208), + 9: uint16(37209), + 10: uint16(37211), + 11: uint16(37212), + 12: uint16(37215), + 13: uint16(37216), + 14: uint16(37222), + 15: uint16(37223), + 16: uint16(37224), + 17: uint16(37227), + 18: uint16(37229), + 19: uint16(37235), + 20: uint16(37242), + 21: uint16(37243), + 22: uint16(37244), + 23: uint16(37248), + 24: uint16(37249), + 25: uint16(37250), + 26: uint16(37251), + 27: uint16(37252), + 28: uint16(37254), + 29: uint16(37256), + 30: uint16(37258), + 31: uint16(37262), + 32: uint16(37263), + 33: uint16(37267), + 34: uint16(37268), + 35: uint16(37269), + 36: uint16(37270), + 37: uint16(37271), + 38: uint16(37272), + 39: uint16(37273), + 40: uint16(37276), + 41: uint16(37277), + 42: uint16(37278), + 43: uint16(37279), + 44: uint16(37280), + 45: uint16(37281), + 46: uint16(37284), + 47: uint16(37285), + 48: uint16(37286), + 49: uint16(37287), + 50: uint16(37288), + 51: uint16(37289), + 52: uint16(37291), + 53: uint16(37292), + 54: uint16(37296), + 55: uint16(37297), + 56: uint16(37298), + 57: uint16(37299), + 58: uint16(37302), + 59: uint16(37303), + 60: uint16(37304), + 61: uint16(37305), + 62: uint16(37307), + 63: uint16(37308), + 64: uint16(37309), + 65: uint16(37310), + 66: uint16(37311), + 67: uint16(37312), + 68: uint16(37313), + 69: uint16(37314), + 70: uint16(37315), + 71: uint16(37316), + 72: uint16(37317), + 73: uint16(37318), + 74: uint16(37320), + 75: uint16(37323), + 76: uint16(37328), + 77: uint16(37330), + 78: uint16(37331), + 79: uint16(37332), + 80: uint16(37333), + 81: uint16(37334), + 82: uint16(37335), + 83: uint16(37336), + 84: uint16(37337), + 85: uint16(37338), + 86: uint16(37339), + 87: uint16(37341), + 88: uint16(37342), + 89: uint16(37343), + 90: uint16(37344), + 91: uint16(37345), + 92: uint16(37346), + 93: uint16(37347), + 94: uint16(37348), + 95: uint16(37349), + 96: uint16(24119), + 97: uint16(24132), + 98: uint16(24148), + 99: uint16(24155), + 100: uint16(24158), + 101: uint16(24161), + 102: uint16(23692), + 103: uint16(23674), + 104: uint16(23693), + 105: uint16(23696), + 106: uint16(23702), + 107: uint16(23688), + 108: uint16(23704), + 109: uint16(23705), + 110: uint16(23697), + 111: uint16(23706), + 112: uint16(23708), + 113: uint16(23733), + 114: uint16(23714), + 115: uint16(23741), + 116: uint16(23724), + 117: uint16(23723), + 118: uint16(23729), + 119: uint16(23715), + 120: uint16(23745), + 121: uint16(23735), + 122: uint16(23748), + 123: uint16(23762), + 124: uint16(23780), + 125: uint16(23755), + 126: uint16(23781), + 127: uint16(23810), + 128: uint16(23811), + 129: uint16(23847), + 130: uint16(23846), + 131: uint16(23854), + 132: uint16(23844), + 133: uint16(23838), + 134: uint16(23814), + 135: uint16(23835), + 136: uint16(23896), + 137: uint16(23870), + 138: uint16(23860), + 139: uint16(23869), + 140: uint16(23916), + 141: uint16(23899), + 142: uint16(23919), + 143: uint16(23901), + 144: uint16(23915), + 145: uint16(23883), + 146: uint16(23882), + 147: uint16(23913), + 148: uint16(23924), + 149: uint16(23938), + 150: uint16(23961), + 151: uint16(23965), + 152: uint16(35955), + 153: uint16(23991), + 154: uint16(24005), + 155: uint16(24435), + 156: uint16(24439), + 157: uint16(24450), + 158: uint16(24455), + 159: uint16(24457), + 160: uint16(24460), + 161: uint16(24469), + 162: uint16(24473), + 163: uint16(24476), + 164: uint16(24488), + 165: uint16(24493), + 166: uint16(24501), + 167: uint16(24508), + 168: uint16(34914), + 169: uint16(24417), + 170: uint16(29357), + 171: uint16(29360), + 172: uint16(29364), + 173: uint16(29367), + 174: uint16(29368), + 175: uint16(29379), + 176: uint16(29377), + 177: uint16(29390), + 178: uint16(29389), + 179: uint16(29394), + 180: uint16(29416), + 181: uint16(29423), + 182: uint16(29417), + 183: uint16(29426), + 184: uint16(29428), + 185: uint16(29431), + 186: uint16(29441), + 187: uint16(29427), + 188: uint16(29443), + 189: uint16(29434), + }, + 97: { + 0: uint16(37350), + 1: uint16(37351), + 2: uint16(37352), + 3: uint16(37353), + 4: uint16(37354), + 5: uint16(37355), + 6: uint16(37356), + 7: uint16(37357), + 8: uint16(37358), + 9: uint16(37359), + 10: uint16(37360), + 11: uint16(37361), + 12: uint16(37362), + 13: uint16(37363), + 14: uint16(37364), + 15: uint16(37365), + 16: uint16(37366), + 17: uint16(37367), + 18: uint16(37368), + 19: uint16(37369), + 20: uint16(37370), + 21: uint16(37371), + 22: uint16(37372), + 23: uint16(37373), + 24: uint16(37374), + 25: uint16(37375), + 26: uint16(37376), + 27: uint16(37377), + 28: uint16(37378), + 29: uint16(37379), + 30: uint16(37380), + 31: uint16(37381), + 32: uint16(37382), + 33: uint16(37383), + 34: uint16(37384), + 35: uint16(37385), + 36: uint16(37386), + 37: uint16(37387), + 38: uint16(37388), + 39: uint16(37389), + 40: uint16(37390), + 41: uint16(37391), + 42: uint16(37392), + 43: uint16(37393), + 44: uint16(37394), + 45: uint16(37395), + 46: uint16(37396), + 47: uint16(37397), + 48: uint16(37398), + 49: uint16(37399), + 50: uint16(37400), + 51: uint16(37401), + 52: uint16(37402), + 53: uint16(37403), + 54: uint16(37404), + 55: uint16(37405), + 56: uint16(37406), + 57: uint16(37407), + 58: uint16(37408), + 59: uint16(37409), + 60: uint16(37410), + 61: uint16(37411), + 62: uint16(37412), + 63: uint16(37413), + 64: uint16(37414), + 65: uint16(37415), + 66: uint16(37416), + 67: uint16(37417), + 68: uint16(37418), + 69: uint16(37419), + 70: uint16(37420), + 71: uint16(37421), + 72: uint16(37422), + 73: uint16(37423), + 74: uint16(37424), + 75: uint16(37425), + 76: uint16(37426), + 77: uint16(37427), + 78: uint16(37428), + 79: uint16(37429), + 80: uint16(37430), + 81: uint16(37431), + 82: uint16(37432), + 83: uint16(37433), + 84: uint16(37434), + 85: uint16(37435), + 86: uint16(37436), + 87: uint16(37437), + 88: uint16(37438), + 89: uint16(37439), + 90: uint16(37440), + 91: uint16(37441), + 92: uint16(37442), + 93: uint16(37443), + 94: uint16(37444), + 95: uint16(37445), + 96: uint16(29435), + 97: uint16(29463), + 98: uint16(29459), + 99: uint16(29473), + 100: uint16(29450), + 101: uint16(29470), + 102: uint16(29469), + 103: uint16(29461), + 104: uint16(29474), + 105: uint16(29497), + 106: uint16(29477), + 107: uint16(29484), + 108: uint16(29496), + 109: uint16(29489), + 110: uint16(29520), + 111: uint16(29517), + 112: uint16(29527), + 113: uint16(29536), + 114: uint16(29548), + 115: uint16(29551), + 116: uint16(29566), + 117: uint16(33307), + 118: uint16(22821), + 119: uint16(39143), + 120: uint16(22820), + 121: uint16(22786), + 122: uint16(39267), + 123: uint16(39271), + 124: uint16(39272), + 125: uint16(39273), + 126: uint16(39274), + 127: uint16(39275), + 128: uint16(39276), + 129: uint16(39284), + 130: uint16(39287), + 131: uint16(39293), + 132: uint16(39296), + 133: uint16(39300), + 134: uint16(39303), + 135: uint16(39306), + 136: uint16(39309), + 137: uint16(39312), + 138: uint16(39313), + 139: uint16(39315), + 140: uint16(39316), + 141: uint16(39317), + 142: uint16(24192), + 143: uint16(24209), + 144: uint16(24203), + 145: uint16(24214), + 146: uint16(24229), + 147: uint16(24224), + 148: uint16(24249), + 149: uint16(24245), + 150: uint16(24254), + 151: uint16(24243), + 152: uint16(36179), + 153: uint16(24274), + 154: uint16(24273), + 155: uint16(24283), + 156: uint16(24296), + 157: uint16(24298), + 158: uint16(33210), + 159: uint16(24516), + 160: uint16(24521), + 161: uint16(24534), + 162: uint16(24527), + 163: uint16(24579), + 164: uint16(24558), + 165: uint16(24580), + 166: uint16(24545), + 167: uint16(24548), + 168: uint16(24574), + 169: uint16(24581), + 170: uint16(24582), + 171: uint16(24554), + 172: uint16(24557), + 173: uint16(24568), + 174: uint16(24601), + 175: uint16(24629), + 176: uint16(24614), + 177: uint16(24603), + 178: uint16(24591), + 179: uint16(24589), + 180: uint16(24617), + 181: uint16(24619), + 182: uint16(24586), + 183: uint16(24639), + 184: uint16(24609), + 185: uint16(24696), + 186: uint16(24697), + 187: uint16(24699), + 188: uint16(24698), + 189: uint16(24642), + }, + 98: { + 0: uint16(37446), + 1: uint16(37447), + 2: uint16(37448), + 3: uint16(37449), + 4: uint16(37450), + 5: uint16(37451), + 6: uint16(37452), + 7: uint16(37453), + 8: uint16(37454), + 9: uint16(37455), + 10: uint16(37456), + 11: uint16(37457), + 12: uint16(37458), + 13: uint16(37459), + 14: uint16(37460), + 15: uint16(37461), + 16: uint16(37462), + 17: uint16(37463), + 18: uint16(37464), + 19: uint16(37465), + 20: uint16(37466), + 21: uint16(37467), + 22: uint16(37468), + 23: uint16(37469), + 24: uint16(37470), + 25: uint16(37471), + 26: uint16(37472), + 27: uint16(37473), + 28: uint16(37474), + 29: uint16(37475), + 30: uint16(37476), + 31: uint16(37477), + 32: uint16(37478), + 33: uint16(37479), + 34: uint16(37480), + 35: uint16(37481), + 36: uint16(37482), + 37: uint16(37483), + 38: uint16(37484), + 39: uint16(37485), + 40: uint16(37486), + 41: uint16(37487), + 42: uint16(37488), + 43: uint16(37489), + 44: uint16(37490), + 45: uint16(37491), + 46: uint16(37493), + 47: uint16(37494), + 48: uint16(37495), + 49: uint16(37496), + 50: uint16(37497), + 51: uint16(37498), + 52: uint16(37499), + 53: uint16(37500), + 54: uint16(37501), + 55: uint16(37502), + 56: uint16(37503), + 57: uint16(37504), + 58: uint16(37505), + 59: uint16(37506), + 60: uint16(37507), + 61: uint16(37508), + 62: uint16(37509), + 63: uint16(37510), + 64: uint16(37511), + 65: uint16(37512), + 66: uint16(37513), + 67: uint16(37514), + 68: uint16(37515), + 69: uint16(37516), + 70: uint16(37517), + 71: uint16(37519), + 72: uint16(37520), + 73: uint16(37521), + 74: uint16(37522), + 75: uint16(37523), + 76: uint16(37524), + 77: uint16(37525), + 78: uint16(37526), + 79: uint16(37527), + 80: uint16(37528), + 81: uint16(37529), + 82: uint16(37530), + 83: uint16(37531), + 84: uint16(37532), + 85: uint16(37533), + 86: uint16(37534), + 87: uint16(37535), + 88: uint16(37536), + 89: uint16(37537), + 90: uint16(37538), + 91: uint16(37539), + 92: uint16(37540), + 93: uint16(37541), + 94: uint16(37542), + 95: uint16(37543), + 96: uint16(24682), + 97: uint16(24701), + 98: uint16(24726), + 99: uint16(24730), + 100: uint16(24749), + 101: uint16(24733), + 102: uint16(24707), + 103: uint16(24722), + 104: uint16(24716), + 105: uint16(24731), + 106: uint16(24812), + 107: uint16(24763), + 108: uint16(24753), + 109: uint16(24797), + 110: uint16(24792), + 111: uint16(24774), + 112: uint16(24794), + 113: uint16(24756), + 114: uint16(24864), + 115: uint16(24870), + 116: uint16(24853), + 117: uint16(24867), + 118: uint16(24820), + 119: uint16(24832), + 120: uint16(24846), + 121: uint16(24875), + 122: uint16(24906), + 123: uint16(24949), + 124: uint16(25004), + 125: uint16(24980), + 126: uint16(24999), + 127: uint16(25015), + 128: uint16(25044), + 129: uint16(25077), + 130: uint16(24541), + 131: uint16(38579), + 132: uint16(38377), + 133: uint16(38379), + 134: uint16(38385), + 135: uint16(38387), + 136: uint16(38389), + 137: uint16(38390), + 138: uint16(38396), + 139: uint16(38398), + 140: uint16(38403), + 141: uint16(38404), + 142: uint16(38406), + 143: uint16(38408), + 144: uint16(38410), + 145: uint16(38411), + 146: uint16(38412), + 147: uint16(38413), + 148: uint16(38415), + 149: uint16(38418), + 150: uint16(38421), + 151: uint16(38422), + 152: uint16(38423), + 153: uint16(38425), + 154: uint16(38426), + 155: uint16(20012), + 156: uint16(29247), + 157: uint16(25109), + 158: uint16(27701), + 159: uint16(27732), + 160: uint16(27740), + 161: uint16(27722), + 162: uint16(27811), + 163: uint16(27781), + 164: uint16(27792), + 165: uint16(27796), + 166: uint16(27788), + 167: uint16(27752), + 168: uint16(27753), + 169: uint16(27764), + 170: uint16(27766), + 171: uint16(27782), + 172: uint16(27817), + 173: uint16(27856), + 174: uint16(27860), + 175: uint16(27821), + 176: uint16(27895), + 177: uint16(27896), + 178: uint16(27889), + 179: uint16(27863), + 180: uint16(27826), + 181: uint16(27872), + 182: uint16(27862), + 183: uint16(27898), + 184: uint16(27883), + 185: uint16(27886), + 186: uint16(27825), + 187: uint16(27859), + 188: uint16(27887), + 189: uint16(27902), + }, + 99: { + 0: uint16(37544), + 1: uint16(37545), + 2: uint16(37546), + 3: uint16(37547), + 4: uint16(37548), + 5: uint16(37549), + 6: uint16(37551), + 7: uint16(37552), + 8: uint16(37553), + 9: uint16(37554), + 10: uint16(37555), + 11: uint16(37556), + 12: uint16(37557), + 13: uint16(37558), + 14: uint16(37559), + 15: uint16(37560), + 16: uint16(37561), + 17: uint16(37562), + 18: uint16(37563), + 19: uint16(37564), + 20: uint16(37565), + 21: uint16(37566), + 22: uint16(37567), + 23: uint16(37568), + 24: uint16(37569), + 25: uint16(37570), + 26: uint16(37571), + 27: uint16(37572), + 28: uint16(37573), + 29: uint16(37574), + 30: uint16(37575), + 31: uint16(37577), + 32: uint16(37578), + 33: uint16(37579), + 34: uint16(37580), + 35: uint16(37581), + 36: uint16(37582), + 37: uint16(37583), + 38: uint16(37584), + 39: uint16(37585), + 40: uint16(37586), + 41: uint16(37587), + 42: uint16(37588), + 43: uint16(37589), + 44: uint16(37590), + 45: uint16(37591), + 46: uint16(37592), + 47: uint16(37593), + 48: uint16(37594), + 49: uint16(37595), + 50: uint16(37596), + 51: uint16(37597), + 52: uint16(37598), + 53: uint16(37599), + 54: uint16(37600), + 55: uint16(37601), + 56: uint16(37602), + 57: uint16(37603), + 58: uint16(37604), + 59: uint16(37605), + 60: uint16(37606), + 61: uint16(37607), + 62: uint16(37608), + 63: uint16(37609), + 64: uint16(37610), + 65: uint16(37611), + 66: uint16(37612), + 67: uint16(37613), + 68: uint16(37614), + 69: uint16(37615), + 70: uint16(37616), + 71: uint16(37617), + 72: uint16(37618), + 73: uint16(37619), + 74: uint16(37620), + 75: uint16(37621), + 76: uint16(37622), + 77: uint16(37623), + 78: uint16(37624), + 79: uint16(37625), + 80: uint16(37626), + 81: uint16(37627), + 82: uint16(37628), + 83: uint16(37629), + 84: uint16(37630), + 85: uint16(37631), + 86: uint16(37632), + 87: uint16(37633), + 88: uint16(37634), + 89: uint16(37635), + 90: uint16(37636), + 91: uint16(37637), + 92: uint16(37638), + 93: uint16(37639), + 94: uint16(37640), + 95: uint16(37641), + 96: uint16(27961), + 97: uint16(27943), + 98: uint16(27916), + 99: uint16(27971), + 100: uint16(27976), + 101: uint16(27911), + 102: uint16(27908), + 103: uint16(27929), + 104: uint16(27918), + 105: uint16(27947), + 106: uint16(27981), + 107: uint16(27950), + 108: uint16(27957), + 109: uint16(27930), + 110: uint16(27983), + 111: uint16(27986), + 112: uint16(27988), + 113: uint16(27955), + 114: uint16(28049), + 115: uint16(28015), + 116: uint16(28062), + 117: uint16(28064), + 118: uint16(27998), + 119: uint16(28051), + 120: uint16(28052), + 121: uint16(27996), + 122: uint16(28000), + 123: uint16(28028), + 124: uint16(28003), + 125: uint16(28186), + 126: uint16(28103), + 127: uint16(28101), + 128: uint16(28126), + 129: uint16(28174), + 130: uint16(28095), + 131: uint16(28128), + 132: uint16(28177), + 133: uint16(28134), + 134: uint16(28125), + 135: uint16(28121), + 136: uint16(28182), + 137: uint16(28075), + 138: uint16(28172), + 139: uint16(28078), + 140: uint16(28203), + 141: uint16(28270), + 142: uint16(28238), + 143: uint16(28267), + 144: uint16(28338), + 145: uint16(28255), + 146: uint16(28294), + 147: uint16(28243), + 148: uint16(28244), + 149: uint16(28210), + 150: uint16(28197), + 151: uint16(28228), + 152: uint16(28383), + 153: uint16(28337), + 154: uint16(28312), + 155: uint16(28384), + 156: uint16(28461), + 157: uint16(28386), + 158: uint16(28325), + 159: uint16(28327), + 160: uint16(28349), + 161: uint16(28347), + 162: uint16(28343), + 163: uint16(28375), + 164: uint16(28340), + 165: uint16(28367), + 166: uint16(28303), + 167: uint16(28354), + 168: uint16(28319), + 169: uint16(28514), + 170: uint16(28486), + 171: uint16(28487), + 172: uint16(28452), + 173: uint16(28437), + 174: uint16(28409), + 175: uint16(28463), + 176: uint16(28470), + 177: uint16(28491), + 178: uint16(28532), + 179: uint16(28458), + 180: uint16(28425), + 181: uint16(28457), + 182: uint16(28553), + 183: uint16(28557), + 184: uint16(28556), + 185: uint16(28536), + 186: uint16(28530), + 187: uint16(28540), + 188: uint16(28538), + 189: uint16(28625), + }, + 100: { + 0: uint16(37642), + 1: uint16(37643), + 2: uint16(37644), + 3: uint16(37645), + 4: uint16(37646), + 5: uint16(37647), + 6: uint16(37648), + 7: uint16(37649), + 8: uint16(37650), + 9: uint16(37651), + 10: uint16(37652), + 11: uint16(37653), + 12: uint16(37654), + 13: uint16(37655), + 14: uint16(37656), + 15: uint16(37657), + 16: uint16(37658), + 17: uint16(37659), + 18: uint16(37660), + 19: uint16(37661), + 20: uint16(37662), + 21: uint16(37663), + 22: uint16(37664), + 23: uint16(37665), + 24: uint16(37666), + 25: uint16(37667), + 26: uint16(37668), + 27: uint16(37669), + 28: uint16(37670), + 29: uint16(37671), + 30: uint16(37672), + 31: uint16(37673), + 32: uint16(37674), + 33: uint16(37675), + 34: uint16(37676), + 35: uint16(37677), + 36: uint16(37678), + 37: uint16(37679), + 38: uint16(37680), + 39: uint16(37681), + 40: uint16(37682), + 41: uint16(37683), + 42: uint16(37684), + 43: uint16(37685), + 44: uint16(37686), + 45: uint16(37687), + 46: uint16(37688), + 47: uint16(37689), + 48: uint16(37690), + 49: uint16(37691), + 50: uint16(37692), + 51: uint16(37693), + 52: uint16(37695), + 53: uint16(37696), + 54: uint16(37697), + 55: uint16(37698), + 56: uint16(37699), + 57: uint16(37700), + 58: uint16(37701), + 59: uint16(37702), + 60: uint16(37703), + 61: uint16(37704), + 62: uint16(37705), + 63: uint16(37706), + 64: uint16(37707), + 65: uint16(37708), + 66: uint16(37709), + 67: uint16(37710), + 68: uint16(37711), + 69: uint16(37712), + 70: uint16(37713), + 71: uint16(37714), + 72: uint16(37715), + 73: uint16(37716), + 74: uint16(37717), + 75: uint16(37718), + 76: uint16(37719), + 77: uint16(37720), + 78: uint16(37721), + 79: uint16(37722), + 80: uint16(37723), + 81: uint16(37724), + 82: uint16(37725), + 83: uint16(37726), + 84: uint16(37727), + 85: uint16(37728), + 86: uint16(37729), + 87: uint16(37730), + 88: uint16(37731), + 89: uint16(37732), + 90: uint16(37733), + 91: uint16(37734), + 92: uint16(37735), + 93: uint16(37736), + 94: uint16(37737), + 95: uint16(37739), + 96: uint16(28617), + 97: uint16(28583), + 98: uint16(28601), + 99: uint16(28598), + 100: uint16(28610), + 101: uint16(28641), + 102: uint16(28654), + 103: uint16(28638), + 104: uint16(28640), + 105: uint16(28655), + 106: uint16(28698), + 107: uint16(28707), + 108: uint16(28699), + 109: uint16(28729), + 110: uint16(28725), + 111: uint16(28751), + 112: uint16(28766), + 113: uint16(23424), + 114: uint16(23428), + 115: uint16(23445), + 116: uint16(23443), + 117: uint16(23461), + 118: uint16(23480), + 119: uint16(29999), + 120: uint16(39582), + 121: uint16(25652), + 122: uint16(23524), + 123: uint16(23534), + 124: uint16(35120), + 125: uint16(23536), + 126: uint16(36423), + 127: uint16(35591), + 128: uint16(36790), + 129: uint16(36819), + 130: uint16(36821), + 131: uint16(36837), + 132: uint16(36846), + 133: uint16(36836), + 134: uint16(36841), + 135: uint16(36838), + 136: uint16(36851), + 137: uint16(36840), + 138: uint16(36869), + 139: uint16(36868), + 140: uint16(36875), + 141: uint16(36902), + 142: uint16(36881), + 143: uint16(36877), + 144: uint16(36886), + 145: uint16(36897), + 146: uint16(36917), + 147: uint16(36918), + 148: uint16(36909), + 149: uint16(36911), + 150: uint16(36932), + 151: uint16(36945), + 152: uint16(36946), + 153: uint16(36944), + 154: uint16(36968), + 155: uint16(36952), + 156: uint16(36962), + 157: uint16(36955), + 158: uint16(26297), + 159: uint16(36980), + 160: uint16(36989), + 161: uint16(36994), + 162: uint16(37000), + 163: uint16(36995), + 164: uint16(37003), + 165: uint16(24400), + 166: uint16(24407), + 167: uint16(24406), + 168: uint16(24408), + 169: uint16(23611), + 170: uint16(21675), + 171: uint16(23632), + 172: uint16(23641), + 173: uint16(23409), + 174: uint16(23651), + 175: uint16(23654), + 176: uint16(32700), + 177: uint16(24362), + 178: uint16(24361), + 179: uint16(24365), + 180: uint16(33396), + 181: uint16(24380), + 182: uint16(39739), + 183: uint16(23662), + 184: uint16(22913), + 185: uint16(22915), + 186: uint16(22925), + 187: uint16(22953), + 188: uint16(22954), + 189: uint16(22947), + }, + 101: { + 0: uint16(37740), + 1: uint16(37741), + 2: uint16(37742), + 3: uint16(37743), + 4: uint16(37744), + 5: uint16(37745), + 6: uint16(37746), + 7: uint16(37747), + 8: uint16(37748), + 9: uint16(37749), + 10: uint16(37750), + 11: uint16(37751), + 12: uint16(37752), + 13: uint16(37753), + 14: uint16(37754), + 15: uint16(37755), + 16: uint16(37756), + 17: uint16(37757), + 18: uint16(37758), + 19: uint16(37759), + 20: uint16(37760), + 21: uint16(37761), + 22: uint16(37762), + 23: uint16(37763), + 24: uint16(37764), + 25: uint16(37765), + 26: uint16(37766), + 27: uint16(37767), + 28: uint16(37768), + 29: uint16(37769), + 30: uint16(37770), + 31: uint16(37771), + 32: uint16(37772), + 33: uint16(37773), + 34: uint16(37774), + 35: uint16(37776), + 36: uint16(37777), + 37: uint16(37778), + 38: uint16(37779), + 39: uint16(37780), + 40: uint16(37781), + 41: uint16(37782), + 42: uint16(37783), + 43: uint16(37784), + 44: uint16(37785), + 45: uint16(37786), + 46: uint16(37787), + 47: uint16(37788), + 48: uint16(37789), + 49: uint16(37790), + 50: uint16(37791), + 51: uint16(37792), + 52: uint16(37793), + 53: uint16(37794), + 54: uint16(37795), + 55: uint16(37796), + 56: uint16(37797), + 57: uint16(37798), + 58: uint16(37799), + 59: uint16(37800), + 60: uint16(37801), + 61: uint16(37802), + 62: uint16(37803), + 63: uint16(37804), + 64: uint16(37805), + 65: uint16(37806), + 66: uint16(37807), + 67: uint16(37808), + 68: uint16(37809), + 69: uint16(37810), + 70: uint16(37811), + 71: uint16(37812), + 72: uint16(37813), + 73: uint16(37814), + 74: uint16(37815), + 75: uint16(37816), + 76: uint16(37817), + 77: uint16(37818), + 78: uint16(37819), + 79: uint16(37820), + 80: uint16(37821), + 81: uint16(37822), + 82: uint16(37823), + 83: uint16(37824), + 84: uint16(37825), + 85: uint16(37826), + 86: uint16(37827), + 87: uint16(37828), + 88: uint16(37829), + 89: uint16(37830), + 90: uint16(37831), + 91: uint16(37832), + 92: uint16(37833), + 93: uint16(37835), + 94: uint16(37836), + 95: uint16(37837), + 96: uint16(22935), + 97: uint16(22986), + 98: uint16(22955), + 99: uint16(22942), + 100: uint16(22948), + 101: uint16(22994), + 102: uint16(22962), + 103: uint16(22959), + 104: uint16(22999), + 105: uint16(22974), + 106: uint16(23045), + 107: uint16(23046), + 108: uint16(23005), + 109: uint16(23048), + 110: uint16(23011), + 111: uint16(23000), + 112: uint16(23033), + 113: uint16(23052), + 114: uint16(23049), + 115: uint16(23090), + 116: uint16(23092), + 117: uint16(23057), + 118: uint16(23075), + 119: uint16(23059), + 120: uint16(23104), + 121: uint16(23143), + 122: uint16(23114), + 123: uint16(23125), + 124: uint16(23100), + 125: uint16(23138), + 126: uint16(23157), + 127: uint16(33004), + 128: uint16(23210), + 129: uint16(23195), + 130: uint16(23159), + 131: uint16(23162), + 132: uint16(23230), + 133: uint16(23275), + 134: uint16(23218), + 135: uint16(23250), + 136: uint16(23252), + 137: uint16(23224), + 138: uint16(23264), + 139: uint16(23267), + 140: uint16(23281), + 141: uint16(23254), + 142: uint16(23270), + 143: uint16(23256), + 144: uint16(23260), + 145: uint16(23305), + 146: uint16(23319), + 147: uint16(23318), + 148: uint16(23346), + 149: uint16(23351), + 150: uint16(23360), + 151: uint16(23573), + 152: uint16(23580), + 153: uint16(23386), + 154: uint16(23397), + 155: uint16(23411), + 156: uint16(23377), + 157: uint16(23379), + 158: uint16(23394), + 159: uint16(39541), + 160: uint16(39543), + 161: uint16(39544), + 162: uint16(39546), + 163: uint16(39551), + 164: uint16(39549), + 165: uint16(39552), + 166: uint16(39553), + 167: uint16(39557), + 168: uint16(39560), + 169: uint16(39562), + 170: uint16(39568), + 171: uint16(39570), + 172: uint16(39571), + 173: uint16(39574), + 174: uint16(39576), + 175: uint16(39579), + 176: uint16(39580), + 177: uint16(39581), + 178: uint16(39583), + 179: uint16(39584), + 180: uint16(39586), + 181: uint16(39587), + 182: uint16(39589), + 183: uint16(39591), + 184: uint16(32415), + 185: uint16(32417), + 186: uint16(32419), + 187: uint16(32421), + 188: uint16(32424), + 189: uint16(32425), + }, + 102: { + 0: uint16(37838), + 1: uint16(37839), + 2: uint16(37840), + 3: uint16(37841), + 4: uint16(37842), + 5: uint16(37843), + 6: uint16(37844), + 7: uint16(37845), + 8: uint16(37847), + 9: uint16(37848), + 10: uint16(37849), + 11: uint16(37850), + 12: uint16(37851), + 13: uint16(37852), + 14: uint16(37853), + 15: uint16(37854), + 16: uint16(37855), + 17: uint16(37856), + 18: uint16(37857), + 19: uint16(37858), + 20: uint16(37859), + 21: uint16(37860), + 22: uint16(37861), + 23: uint16(37862), + 24: uint16(37863), + 25: uint16(37864), + 26: uint16(37865), + 27: uint16(37866), + 28: uint16(37867), + 29: uint16(37868), + 30: uint16(37869), + 31: uint16(37870), + 32: uint16(37871), + 33: uint16(37872), + 34: uint16(37873), + 35: uint16(37874), + 36: uint16(37875), + 37: uint16(37876), + 38: uint16(37877), + 39: uint16(37878), + 40: uint16(37879), + 41: uint16(37880), + 42: uint16(37881), + 43: uint16(37882), + 44: uint16(37883), + 45: uint16(37884), + 46: uint16(37885), + 47: uint16(37886), + 48: uint16(37887), + 49: uint16(37888), + 50: uint16(37889), + 51: uint16(37890), + 52: uint16(37891), + 53: uint16(37892), + 54: uint16(37893), + 55: uint16(37894), + 56: uint16(37895), + 57: uint16(37896), + 58: uint16(37897), + 59: uint16(37898), + 60: uint16(37899), + 61: uint16(37900), + 62: uint16(37901), + 63: uint16(37902), + 64: uint16(37903), + 65: uint16(37904), + 66: uint16(37905), + 67: uint16(37906), + 68: uint16(37907), + 69: uint16(37908), + 70: uint16(37909), + 71: uint16(37910), + 72: uint16(37911), + 73: uint16(37912), + 74: uint16(37913), + 75: uint16(37914), + 76: uint16(37915), + 77: uint16(37916), + 78: uint16(37917), + 79: uint16(37918), + 80: uint16(37919), + 81: uint16(37920), + 82: uint16(37921), + 83: uint16(37922), + 84: uint16(37923), + 85: uint16(37924), + 86: uint16(37925), + 87: uint16(37926), + 88: uint16(37927), + 89: uint16(37928), + 90: uint16(37929), + 91: uint16(37930), + 92: uint16(37931), + 93: uint16(37932), + 94: uint16(37933), + 95: uint16(37934), + 96: uint16(32429), + 97: uint16(32432), + 98: uint16(32446), + 99: uint16(32448), + 100: uint16(32449), + 101: uint16(32450), + 102: uint16(32457), + 103: uint16(32459), + 104: uint16(32460), + 105: uint16(32464), + 106: uint16(32468), + 107: uint16(32471), + 108: uint16(32475), + 109: uint16(32480), + 110: uint16(32481), + 111: uint16(32488), + 112: uint16(32491), + 113: uint16(32494), + 114: uint16(32495), + 115: uint16(32497), + 116: uint16(32498), + 117: uint16(32525), + 118: uint16(32502), + 119: uint16(32506), + 120: uint16(32507), + 121: uint16(32510), + 122: uint16(32513), + 123: uint16(32514), + 124: uint16(32515), + 125: uint16(32519), + 126: uint16(32520), + 127: uint16(32523), + 128: uint16(32524), + 129: uint16(32527), + 130: uint16(32529), + 131: uint16(32530), + 132: uint16(32535), + 133: uint16(32537), + 134: uint16(32540), + 135: uint16(32539), + 136: uint16(32543), + 137: uint16(32545), + 138: uint16(32546), + 139: uint16(32547), + 140: uint16(32548), + 141: uint16(32549), + 142: uint16(32550), + 143: uint16(32551), + 144: uint16(32554), + 145: uint16(32555), + 146: uint16(32556), + 147: uint16(32557), + 148: uint16(32559), + 149: uint16(32560), + 150: uint16(32561), + 151: uint16(32562), + 152: uint16(32563), + 153: uint16(32565), + 154: uint16(24186), + 155: uint16(30079), + 156: uint16(24027), + 157: uint16(30014), + 158: uint16(37013), + 159: uint16(29582), + 160: uint16(29585), + 161: uint16(29614), + 162: uint16(29602), + 163: uint16(29599), + 164: uint16(29647), + 165: uint16(29634), + 166: uint16(29649), + 167: uint16(29623), + 168: uint16(29619), + 169: uint16(29632), + 170: uint16(29641), + 171: uint16(29640), + 172: uint16(29669), + 173: uint16(29657), + 174: uint16(39036), + 175: uint16(29706), + 176: uint16(29673), + 177: uint16(29671), + 178: uint16(29662), + 179: uint16(29626), + 180: uint16(29682), + 181: uint16(29711), + 182: uint16(29738), + 183: uint16(29787), + 184: uint16(29734), + 185: uint16(29733), + 186: uint16(29736), + 187: uint16(29744), + 188: uint16(29742), + 189: uint16(29740), + }, + 103: { + 0: uint16(37935), + 1: uint16(37936), + 2: uint16(37937), + 3: uint16(37938), + 4: uint16(37939), + 5: uint16(37940), + 6: uint16(37941), + 7: uint16(37942), + 8: uint16(37943), + 9: uint16(37944), + 10: uint16(37945), + 11: uint16(37946), + 12: uint16(37947), + 13: uint16(37948), + 14: uint16(37949), + 15: uint16(37951), + 16: uint16(37952), + 17: uint16(37953), + 18: uint16(37954), + 19: uint16(37955), + 20: uint16(37956), + 21: uint16(37957), + 22: uint16(37958), + 23: uint16(37959), + 24: uint16(37960), + 25: uint16(37961), + 26: uint16(37962), + 27: uint16(37963), + 28: uint16(37964), + 29: uint16(37965), + 30: uint16(37966), + 31: uint16(37967), + 32: uint16(37968), + 33: uint16(37969), + 34: uint16(37970), + 35: uint16(37971), + 36: uint16(37972), + 37: uint16(37973), + 38: uint16(37974), + 39: uint16(37975), + 40: uint16(37976), + 41: uint16(37977), + 42: uint16(37978), + 43: uint16(37979), + 44: uint16(37980), + 45: uint16(37981), + 46: uint16(37982), + 47: uint16(37983), + 48: uint16(37984), + 49: uint16(37985), + 50: uint16(37986), + 51: uint16(37987), + 52: uint16(37988), + 53: uint16(37989), + 54: uint16(37990), + 55: uint16(37991), + 56: uint16(37992), + 57: uint16(37993), + 58: uint16(37994), + 59: uint16(37996), + 60: uint16(37997), + 61: uint16(37998), + 62: uint16(37999), + 63: uint16(38000), + 64: uint16(38001), + 65: uint16(38002), + 66: uint16(38003), + 67: uint16(38004), + 68: uint16(38005), + 69: uint16(38006), + 70: uint16(38007), + 71: uint16(38008), + 72: uint16(38009), + 73: uint16(38010), + 74: uint16(38011), + 75: uint16(38012), + 76: uint16(38013), + 77: uint16(38014), + 78: uint16(38015), + 79: uint16(38016), + 80: uint16(38017), + 81: uint16(38018), + 82: uint16(38019), + 83: uint16(38020), + 84: uint16(38033), + 85: uint16(38038), + 86: uint16(38040), + 87: uint16(38087), + 88: uint16(38095), + 89: uint16(38099), + 90: uint16(38100), + 91: uint16(38106), + 92: uint16(38118), + 93: uint16(38139), + 94: uint16(38172), + 95: uint16(38176), + 96: uint16(29723), + 97: uint16(29722), + 98: uint16(29761), + 99: uint16(29788), + 100: uint16(29783), + 101: uint16(29781), + 102: uint16(29785), + 103: uint16(29815), + 104: uint16(29805), + 105: uint16(29822), + 106: uint16(29852), + 107: uint16(29838), + 108: uint16(29824), + 109: uint16(29825), + 110: uint16(29831), + 111: uint16(29835), + 112: uint16(29854), + 113: uint16(29864), + 114: uint16(29865), + 115: uint16(29840), + 116: uint16(29863), + 117: uint16(29906), + 118: uint16(29882), + 119: uint16(38890), + 120: uint16(38891), + 121: uint16(38892), + 122: uint16(26444), + 123: uint16(26451), + 124: uint16(26462), + 125: uint16(26440), + 126: uint16(26473), + 127: uint16(26533), + 128: uint16(26503), + 129: uint16(26474), + 130: uint16(26483), + 131: uint16(26520), + 132: uint16(26535), + 133: uint16(26485), + 134: uint16(26536), + 135: uint16(26526), + 136: uint16(26541), + 137: uint16(26507), + 138: uint16(26487), + 139: uint16(26492), + 140: uint16(26608), + 141: uint16(26633), + 142: uint16(26584), + 143: uint16(26634), + 144: uint16(26601), + 145: uint16(26544), + 146: uint16(26636), + 147: uint16(26585), + 148: uint16(26549), + 149: uint16(26586), + 150: uint16(26547), + 151: uint16(26589), + 152: uint16(26624), + 153: uint16(26563), + 154: uint16(26552), + 155: uint16(26594), + 156: uint16(26638), + 157: uint16(26561), + 158: uint16(26621), + 159: uint16(26674), + 160: uint16(26675), + 161: uint16(26720), + 162: uint16(26721), + 163: uint16(26702), + 164: uint16(26722), + 165: uint16(26692), + 166: uint16(26724), + 167: uint16(26755), + 168: uint16(26653), + 169: uint16(26709), + 170: uint16(26726), + 171: uint16(26689), + 172: uint16(26727), + 173: uint16(26688), + 174: uint16(26686), + 175: uint16(26698), + 176: uint16(26697), + 177: uint16(26665), + 178: uint16(26805), + 179: uint16(26767), + 180: uint16(26740), + 181: uint16(26743), + 182: uint16(26771), + 183: uint16(26731), + 184: uint16(26818), + 185: uint16(26990), + 186: uint16(26876), + 187: uint16(26911), + 188: uint16(26912), + 189: uint16(26873), + }, + 104: { + 0: uint16(38183), + 1: uint16(38195), + 2: uint16(38205), + 3: uint16(38211), + 4: uint16(38216), + 5: uint16(38219), + 6: uint16(38229), + 7: uint16(38234), + 8: uint16(38240), + 9: uint16(38254), + 10: uint16(38260), + 11: uint16(38261), + 12: uint16(38263), + 13: uint16(38264), + 14: uint16(38265), + 15: uint16(38266), + 16: uint16(38267), + 17: uint16(38268), + 18: uint16(38269), + 19: uint16(38270), + 20: uint16(38272), + 21: uint16(38273), + 22: uint16(38274), + 23: uint16(38275), + 24: uint16(38276), + 25: uint16(38277), + 26: uint16(38278), + 27: uint16(38279), + 28: uint16(38280), + 29: uint16(38281), + 30: uint16(38282), + 31: uint16(38283), + 32: uint16(38284), + 33: uint16(38285), + 34: uint16(38286), + 35: uint16(38287), + 36: uint16(38288), + 37: uint16(38289), + 38: uint16(38290), + 39: uint16(38291), + 40: uint16(38292), + 41: uint16(38293), + 42: uint16(38294), + 43: uint16(38295), + 44: uint16(38296), + 45: uint16(38297), + 46: uint16(38298), + 47: uint16(38299), + 48: uint16(38300), + 49: uint16(38301), + 50: uint16(38302), + 51: uint16(38303), + 52: uint16(38304), + 53: uint16(38305), + 54: uint16(38306), + 55: uint16(38307), + 56: uint16(38308), + 57: uint16(38309), + 58: uint16(38310), + 59: uint16(38311), + 60: uint16(38312), + 61: uint16(38313), + 62: uint16(38314), + 63: uint16(38315), + 64: uint16(38316), + 65: uint16(38317), + 66: uint16(38318), + 67: uint16(38319), + 68: uint16(38320), + 69: uint16(38321), + 70: uint16(38322), + 71: uint16(38323), + 72: uint16(38324), + 73: uint16(38325), + 74: uint16(38326), + 75: uint16(38327), + 76: uint16(38328), + 77: uint16(38329), + 78: uint16(38330), + 79: uint16(38331), + 80: uint16(38332), + 81: uint16(38333), + 82: uint16(38334), + 83: uint16(38335), + 84: uint16(38336), + 85: uint16(38337), + 86: uint16(38338), + 87: uint16(38339), + 88: uint16(38340), + 89: uint16(38341), + 90: uint16(38342), + 91: uint16(38343), + 92: uint16(38344), + 93: uint16(38345), + 94: uint16(38346), + 95: uint16(38347), + 96: uint16(26916), + 97: uint16(26864), + 98: uint16(26891), + 99: uint16(26881), + 100: uint16(26967), + 101: uint16(26851), + 102: uint16(26896), + 103: uint16(26993), + 104: uint16(26937), + 105: uint16(26976), + 106: uint16(26946), + 107: uint16(26973), + 108: uint16(27012), + 109: uint16(26987), + 110: uint16(27008), + 111: uint16(27032), + 112: uint16(27000), + 113: uint16(26932), + 114: uint16(27084), + 115: uint16(27015), + 116: uint16(27016), + 117: uint16(27086), + 118: uint16(27017), + 119: uint16(26982), + 120: uint16(26979), + 121: uint16(27001), + 122: uint16(27035), + 123: uint16(27047), + 124: uint16(27067), + 125: uint16(27051), + 126: uint16(27053), + 127: uint16(27092), + 128: uint16(27057), + 129: uint16(27073), + 130: uint16(27082), + 131: uint16(27103), + 132: uint16(27029), + 133: uint16(27104), + 134: uint16(27021), + 135: uint16(27135), + 136: uint16(27183), + 137: uint16(27117), + 138: uint16(27159), + 139: uint16(27160), + 140: uint16(27237), + 141: uint16(27122), + 142: uint16(27204), + 143: uint16(27198), + 144: uint16(27296), + 145: uint16(27216), + 146: uint16(27227), + 147: uint16(27189), + 148: uint16(27278), + 149: uint16(27257), + 150: uint16(27197), + 151: uint16(27176), + 152: uint16(27224), + 153: uint16(27260), + 154: uint16(27281), + 155: uint16(27280), + 156: uint16(27305), + 157: uint16(27287), + 158: uint16(27307), + 159: uint16(29495), + 160: uint16(29522), + 161: uint16(27521), + 162: uint16(27522), + 163: uint16(27527), + 164: uint16(27524), + 165: uint16(27538), + 166: uint16(27539), + 167: uint16(27533), + 168: uint16(27546), + 169: uint16(27547), + 170: uint16(27553), + 171: uint16(27562), + 172: uint16(36715), + 173: uint16(36717), + 174: uint16(36721), + 175: uint16(36722), + 176: uint16(36723), + 177: uint16(36725), + 178: uint16(36726), + 179: uint16(36728), + 180: uint16(36727), + 181: uint16(36729), + 182: uint16(36730), + 183: uint16(36732), + 184: uint16(36734), + 185: uint16(36737), + 186: uint16(36738), + 187: uint16(36740), + 188: uint16(36743), + 189: uint16(36747), + }, + 105: { + 0: uint16(38348), + 1: uint16(38349), + 2: uint16(38350), + 3: uint16(38351), + 4: uint16(38352), + 5: uint16(38353), + 6: uint16(38354), + 7: uint16(38355), + 8: uint16(38356), + 9: uint16(38357), + 10: uint16(38358), + 11: uint16(38359), + 12: uint16(38360), + 13: uint16(38361), + 14: uint16(38362), + 15: uint16(38363), + 16: uint16(38364), + 17: uint16(38365), + 18: uint16(38366), + 19: uint16(38367), + 20: uint16(38368), + 21: uint16(38369), + 22: uint16(38370), + 23: uint16(38371), + 24: uint16(38372), + 25: uint16(38373), + 26: uint16(38374), + 27: uint16(38375), + 28: uint16(38380), + 29: uint16(38399), + 30: uint16(38407), + 31: uint16(38419), + 32: uint16(38424), + 33: uint16(38427), + 34: uint16(38430), + 35: uint16(38432), + 36: uint16(38435), + 37: uint16(38436), + 38: uint16(38437), + 39: uint16(38438), + 40: uint16(38439), + 41: uint16(38440), + 42: uint16(38441), + 43: uint16(38443), + 44: uint16(38444), + 45: uint16(38445), + 46: uint16(38447), + 47: uint16(38448), + 48: uint16(38455), + 49: uint16(38456), + 50: uint16(38457), + 51: uint16(38458), + 52: uint16(38462), + 53: uint16(38465), + 54: uint16(38467), + 55: uint16(38474), + 56: uint16(38478), + 57: uint16(38479), + 58: uint16(38481), + 59: uint16(38482), + 60: uint16(38483), + 61: uint16(38486), + 62: uint16(38487), + 63: uint16(38488), + 64: uint16(38489), + 65: uint16(38490), + 66: uint16(38492), + 67: uint16(38493), + 68: uint16(38494), + 69: uint16(38496), + 70: uint16(38499), + 71: uint16(38501), + 72: uint16(38502), + 73: uint16(38507), + 74: uint16(38509), + 75: uint16(38510), + 76: uint16(38511), + 77: uint16(38512), + 78: uint16(38513), + 79: uint16(38515), + 80: uint16(38520), + 81: uint16(38521), + 82: uint16(38522), + 83: uint16(38523), + 84: uint16(38524), + 85: uint16(38525), + 86: uint16(38526), + 87: uint16(38527), + 88: uint16(38528), + 89: uint16(38529), + 90: uint16(38530), + 91: uint16(38531), + 92: uint16(38532), + 93: uint16(38535), + 94: uint16(38537), + 95: uint16(38538), + 96: uint16(36749), + 97: uint16(36750), + 98: uint16(36751), + 99: uint16(36760), + 100: uint16(36762), + 101: uint16(36558), + 102: uint16(25099), + 103: uint16(25111), + 104: uint16(25115), + 105: uint16(25119), + 106: uint16(25122), + 107: uint16(25121), + 108: uint16(25125), + 109: uint16(25124), + 110: uint16(25132), + 111: uint16(33255), + 112: uint16(29935), + 113: uint16(29940), + 114: uint16(29951), + 115: uint16(29967), + 116: uint16(29969), + 117: uint16(29971), + 118: uint16(25908), + 119: uint16(26094), + 120: uint16(26095), + 121: uint16(26096), + 122: uint16(26122), + 123: uint16(26137), + 124: uint16(26482), + 125: uint16(26115), + 126: uint16(26133), + 127: uint16(26112), + 128: uint16(28805), + 129: uint16(26359), + 130: uint16(26141), + 131: uint16(26164), + 132: uint16(26161), + 133: uint16(26166), + 134: uint16(26165), + 135: uint16(32774), + 136: uint16(26207), + 137: uint16(26196), + 138: uint16(26177), + 139: uint16(26191), + 140: uint16(26198), + 141: uint16(26209), + 142: uint16(26199), + 143: uint16(26231), + 144: uint16(26244), + 145: uint16(26252), + 146: uint16(26279), + 147: uint16(26269), + 148: uint16(26302), + 149: uint16(26331), + 150: uint16(26332), + 151: uint16(26342), + 152: uint16(26345), + 153: uint16(36146), + 154: uint16(36147), + 155: uint16(36150), + 156: uint16(36155), + 157: uint16(36157), + 158: uint16(36160), + 159: uint16(36165), + 160: uint16(36166), + 161: uint16(36168), + 162: uint16(36169), + 163: uint16(36167), + 164: uint16(36173), + 165: uint16(36181), + 166: uint16(36185), + 167: uint16(35271), + 168: uint16(35274), + 169: uint16(35275), + 170: uint16(35276), + 171: uint16(35278), + 172: uint16(35279), + 173: uint16(35280), + 174: uint16(35281), + 175: uint16(29294), + 176: uint16(29343), + 177: uint16(29277), + 178: uint16(29286), + 179: uint16(29295), + 180: uint16(29310), + 181: uint16(29311), + 182: uint16(29316), + 183: uint16(29323), + 184: uint16(29325), + 185: uint16(29327), + 186: uint16(29330), + 187: uint16(25352), + 188: uint16(25394), + 189: uint16(25520), + }, + 106: { + 0: uint16(38540), + 1: uint16(38542), + 2: uint16(38545), + 3: uint16(38546), + 4: uint16(38547), + 5: uint16(38549), + 6: uint16(38550), + 7: uint16(38554), + 8: uint16(38555), + 9: uint16(38557), + 10: uint16(38558), + 11: uint16(38559), + 12: uint16(38560), + 13: uint16(38561), + 14: uint16(38562), + 15: uint16(38563), + 16: uint16(38564), + 17: uint16(38565), + 18: uint16(38566), + 19: uint16(38568), + 20: uint16(38569), + 21: uint16(38570), + 22: uint16(38571), + 23: uint16(38572), + 24: uint16(38573), + 25: uint16(38574), + 26: uint16(38575), + 27: uint16(38577), + 28: uint16(38578), + 29: uint16(38580), + 30: uint16(38581), + 31: uint16(38583), + 32: uint16(38584), + 33: uint16(38586), + 34: uint16(38587), + 35: uint16(38591), + 36: uint16(38594), + 37: uint16(38595), + 38: uint16(38600), + 39: uint16(38602), + 40: uint16(38603), + 41: uint16(38608), + 42: uint16(38609), + 43: uint16(38611), + 44: uint16(38612), + 45: uint16(38614), + 46: uint16(38615), + 47: uint16(38616), + 48: uint16(38617), + 49: uint16(38618), + 50: uint16(38619), + 51: uint16(38620), + 52: uint16(38621), + 53: uint16(38622), + 54: uint16(38623), + 55: uint16(38625), + 56: uint16(38626), + 57: uint16(38627), + 58: uint16(38628), + 59: uint16(38629), + 60: uint16(38630), + 61: uint16(38631), + 62: uint16(38635), + 63: uint16(38636), + 64: uint16(38637), + 65: uint16(38638), + 66: uint16(38640), + 67: uint16(38641), + 68: uint16(38642), + 69: uint16(38644), + 70: uint16(38645), + 71: uint16(38648), + 72: uint16(38650), + 73: uint16(38651), + 74: uint16(38652), + 75: uint16(38653), + 76: uint16(38655), + 77: uint16(38658), + 78: uint16(38659), + 79: uint16(38661), + 80: uint16(38666), + 81: uint16(38667), + 82: uint16(38668), + 83: uint16(38672), + 84: uint16(38673), + 85: uint16(38674), + 86: uint16(38676), + 87: uint16(38677), + 88: uint16(38679), + 89: uint16(38680), + 90: uint16(38681), + 91: uint16(38682), + 92: uint16(38683), + 93: uint16(38685), + 94: uint16(38687), + 95: uint16(38688), + 96: uint16(25663), + 97: uint16(25816), + 98: uint16(32772), + 99: uint16(27626), + 100: uint16(27635), + 101: uint16(27645), + 102: uint16(27637), + 103: uint16(27641), + 104: uint16(27653), + 105: uint16(27655), + 106: uint16(27654), + 107: uint16(27661), + 108: uint16(27669), + 109: uint16(27672), + 110: uint16(27673), + 111: uint16(27674), + 112: uint16(27681), + 113: uint16(27689), + 114: uint16(27684), + 115: uint16(27690), + 116: uint16(27698), + 117: uint16(25909), + 118: uint16(25941), + 119: uint16(25963), + 120: uint16(29261), + 121: uint16(29266), + 122: uint16(29270), + 123: uint16(29232), + 124: uint16(34402), + 125: uint16(21014), + 126: uint16(32927), + 127: uint16(32924), + 128: uint16(32915), + 129: uint16(32956), + 130: uint16(26378), + 131: uint16(32957), + 132: uint16(32945), + 133: uint16(32939), + 134: uint16(32941), + 135: uint16(32948), + 136: uint16(32951), + 137: uint16(32999), + 138: uint16(33000), + 139: uint16(33001), + 140: uint16(33002), + 141: uint16(32987), + 142: uint16(32962), + 143: uint16(32964), + 144: uint16(32985), + 145: uint16(32973), + 146: uint16(32983), + 147: uint16(26384), + 148: uint16(32989), + 149: uint16(33003), + 150: uint16(33009), + 151: uint16(33012), + 152: uint16(33005), + 153: uint16(33037), + 154: uint16(33038), + 155: uint16(33010), + 156: uint16(33020), + 157: uint16(26389), + 158: uint16(33042), + 159: uint16(35930), + 160: uint16(33078), + 161: uint16(33054), + 162: uint16(33068), + 163: uint16(33048), + 164: uint16(33074), + 165: uint16(33096), + 166: uint16(33100), + 167: uint16(33107), + 168: uint16(33140), + 169: uint16(33113), + 170: uint16(33114), + 171: uint16(33137), + 172: uint16(33120), + 173: uint16(33129), + 174: uint16(33148), + 175: uint16(33149), + 176: uint16(33133), + 177: uint16(33127), + 178: uint16(22605), + 179: uint16(23221), + 180: uint16(33160), + 181: uint16(33154), + 182: uint16(33169), + 183: uint16(28373), + 184: uint16(33187), + 185: uint16(33194), + 186: uint16(33228), + 187: uint16(26406), + 188: uint16(33226), + 189: uint16(33211), + }, + 107: { + 0: uint16(38689), + 1: uint16(38690), + 2: uint16(38691), + 3: uint16(38692), + 4: uint16(38693), + 5: uint16(38694), + 6: uint16(38695), + 7: uint16(38696), + 8: uint16(38697), + 9: uint16(38699), + 10: uint16(38700), + 11: uint16(38702), + 12: uint16(38703), + 13: uint16(38705), + 14: uint16(38707), + 15: uint16(38708), + 16: uint16(38709), + 17: uint16(38710), + 18: uint16(38711), + 19: uint16(38714), + 20: uint16(38715), + 21: uint16(38716), + 22: uint16(38717), + 23: uint16(38719), + 24: uint16(38720), + 25: uint16(38721), + 26: uint16(38722), + 27: uint16(38723), + 28: uint16(38724), + 29: uint16(38725), + 30: uint16(38726), + 31: uint16(38727), + 32: uint16(38728), + 33: uint16(38729), + 34: uint16(38730), + 35: uint16(38731), + 36: uint16(38732), + 37: uint16(38733), + 38: uint16(38734), + 39: uint16(38735), + 40: uint16(38736), + 41: uint16(38737), + 42: uint16(38740), + 43: uint16(38741), + 44: uint16(38743), + 45: uint16(38744), + 46: uint16(38746), + 47: uint16(38748), + 48: uint16(38749), + 49: uint16(38751), + 50: uint16(38755), + 51: uint16(38756), + 52: uint16(38758), + 53: uint16(38759), + 54: uint16(38760), + 55: uint16(38762), + 56: uint16(38763), + 57: uint16(38764), + 58: uint16(38765), + 59: uint16(38766), + 60: uint16(38767), + 61: uint16(38768), + 62: uint16(38769), + 63: uint16(38770), + 64: uint16(38773), + 65: uint16(38775), + 66: uint16(38776), + 67: uint16(38777), + 68: uint16(38778), + 69: uint16(38779), + 70: uint16(38781), + 71: uint16(38782), + 72: uint16(38783), + 73: uint16(38784), + 74: uint16(38785), + 75: uint16(38786), + 76: uint16(38787), + 77: uint16(38788), + 78: uint16(38790), + 79: uint16(38791), + 80: uint16(38792), + 81: uint16(38793), + 82: uint16(38794), + 83: uint16(38796), + 84: uint16(38798), + 85: uint16(38799), + 86: uint16(38800), + 87: uint16(38803), + 88: uint16(38805), + 89: uint16(38806), + 90: uint16(38807), + 91: uint16(38809), + 92: uint16(38810), + 93: uint16(38811), + 94: uint16(38812), + 95: uint16(38813), + 96: uint16(33217), + 97: uint16(33190), + 98: uint16(27428), + 99: uint16(27447), + 100: uint16(27449), + 101: uint16(27459), + 102: uint16(27462), + 103: uint16(27481), + 104: uint16(39121), + 105: uint16(39122), + 106: uint16(39123), + 107: uint16(39125), + 108: uint16(39129), + 109: uint16(39130), + 110: uint16(27571), + 111: uint16(24384), + 112: uint16(27586), + 113: uint16(35315), + 114: uint16(26000), + 115: uint16(40785), + 116: uint16(26003), + 117: uint16(26044), + 118: uint16(26054), + 119: uint16(26052), + 120: uint16(26051), + 121: uint16(26060), + 122: uint16(26062), + 123: uint16(26066), + 124: uint16(26070), + 125: uint16(28800), + 126: uint16(28828), + 127: uint16(28822), + 128: uint16(28829), + 129: uint16(28859), + 130: uint16(28864), + 131: uint16(28855), + 132: uint16(28843), + 133: uint16(28849), + 134: uint16(28904), + 135: uint16(28874), + 136: uint16(28944), + 137: uint16(28947), + 138: uint16(28950), + 139: uint16(28975), + 140: uint16(28977), + 141: uint16(29043), + 142: uint16(29020), + 143: uint16(29032), + 144: uint16(28997), + 145: uint16(29042), + 146: uint16(29002), + 147: uint16(29048), + 148: uint16(29050), + 149: uint16(29080), + 150: uint16(29107), + 151: uint16(29109), + 152: uint16(29096), + 153: uint16(29088), + 154: uint16(29152), + 155: uint16(29140), + 156: uint16(29159), + 157: uint16(29177), + 158: uint16(29213), + 159: uint16(29224), + 160: uint16(28780), + 161: uint16(28952), + 162: uint16(29030), + 163: uint16(29113), + 164: uint16(25150), + 165: uint16(25149), + 166: uint16(25155), + 167: uint16(25160), + 168: uint16(25161), + 169: uint16(31035), + 170: uint16(31040), + 171: uint16(31046), + 172: uint16(31049), + 173: uint16(31067), + 174: uint16(31068), + 175: uint16(31059), + 176: uint16(31066), + 177: uint16(31074), + 178: uint16(31063), + 179: uint16(31072), + 180: uint16(31087), + 181: uint16(31079), + 182: uint16(31098), + 183: uint16(31109), + 184: uint16(31114), + 185: uint16(31130), + 186: uint16(31143), + 187: uint16(31155), + 188: uint16(24529), + 189: uint16(24528), + }, + 108: { + 0: uint16(38814), + 1: uint16(38815), + 2: uint16(38817), + 3: uint16(38818), + 4: uint16(38820), + 5: uint16(38821), + 6: uint16(38822), + 7: uint16(38823), + 8: uint16(38824), + 9: uint16(38825), + 10: uint16(38826), + 11: uint16(38828), + 12: uint16(38830), + 13: uint16(38832), + 14: uint16(38833), + 15: uint16(38835), + 16: uint16(38837), + 17: uint16(38838), + 18: uint16(38839), + 19: uint16(38840), + 20: uint16(38841), + 21: uint16(38842), + 22: uint16(38843), + 23: uint16(38844), + 24: uint16(38845), + 25: uint16(38846), + 26: uint16(38847), + 27: uint16(38848), + 28: uint16(38849), + 29: uint16(38850), + 30: uint16(38851), + 31: uint16(38852), + 32: uint16(38853), + 33: uint16(38854), + 34: uint16(38855), + 35: uint16(38856), + 36: uint16(38857), + 37: uint16(38858), + 38: uint16(38859), + 39: uint16(38860), + 40: uint16(38861), + 41: uint16(38862), + 42: uint16(38863), + 43: uint16(38864), + 44: uint16(38865), + 45: uint16(38866), + 46: uint16(38867), + 47: uint16(38868), + 48: uint16(38869), + 49: uint16(38870), + 50: uint16(38871), + 51: uint16(38872), + 52: uint16(38873), + 53: uint16(38874), + 54: uint16(38875), + 55: uint16(38876), + 56: uint16(38877), + 57: uint16(38878), + 58: uint16(38879), + 59: uint16(38880), + 60: uint16(38881), + 61: uint16(38882), + 62: uint16(38883), + 63: uint16(38884), + 64: uint16(38885), + 65: uint16(38888), + 66: uint16(38894), + 67: uint16(38895), + 68: uint16(38896), + 69: uint16(38897), + 70: uint16(38898), + 71: uint16(38900), + 72: uint16(38903), + 73: uint16(38904), + 74: uint16(38905), + 75: uint16(38906), + 76: uint16(38907), + 77: uint16(38908), + 78: uint16(38909), + 79: uint16(38910), + 80: uint16(38911), + 81: uint16(38912), + 82: uint16(38913), + 83: uint16(38914), + 84: uint16(38915), + 85: uint16(38916), + 86: uint16(38917), + 87: uint16(38918), + 88: uint16(38919), + 89: uint16(38920), + 90: uint16(38921), + 91: uint16(38922), + 92: uint16(38923), + 93: uint16(38924), + 94: uint16(38925), + 95: uint16(38926), + 96: uint16(24636), + 97: uint16(24669), + 98: uint16(24666), + 99: uint16(24679), + 100: uint16(24641), + 101: uint16(24665), + 102: uint16(24675), + 103: uint16(24747), + 104: uint16(24838), + 105: uint16(24845), + 106: uint16(24925), + 107: uint16(25001), + 108: uint16(24989), + 109: uint16(25035), + 110: uint16(25041), + 111: uint16(25094), + 112: uint16(32896), + 113: uint16(32895), + 114: uint16(27795), + 115: uint16(27894), + 116: uint16(28156), + 117: uint16(30710), + 118: uint16(30712), + 119: uint16(30720), + 120: uint16(30729), + 121: uint16(30743), + 122: uint16(30744), + 123: uint16(30737), + 124: uint16(26027), + 125: uint16(30765), + 126: uint16(30748), + 127: uint16(30749), + 128: uint16(30777), + 129: uint16(30778), + 130: uint16(30779), + 131: uint16(30751), + 132: uint16(30780), + 133: uint16(30757), + 134: uint16(30764), + 135: uint16(30755), + 136: uint16(30761), + 137: uint16(30798), + 138: uint16(30829), + 139: uint16(30806), + 140: uint16(30807), + 141: uint16(30758), + 142: uint16(30800), + 143: uint16(30791), + 144: uint16(30796), + 145: uint16(30826), + 146: uint16(30875), + 147: uint16(30867), + 148: uint16(30874), + 149: uint16(30855), + 150: uint16(30876), + 151: uint16(30881), + 152: uint16(30883), + 153: uint16(30898), + 154: uint16(30905), + 155: uint16(30885), + 156: uint16(30932), + 157: uint16(30937), + 158: uint16(30921), + 159: uint16(30956), + 160: uint16(30962), + 161: uint16(30981), + 162: uint16(30964), + 163: uint16(30995), + 164: uint16(31012), + 165: uint16(31006), + 166: uint16(31028), + 167: uint16(40859), + 168: uint16(40697), + 169: uint16(40699), + 170: uint16(40700), + 171: uint16(30449), + 172: uint16(30468), + 173: uint16(30477), + 174: uint16(30457), + 175: uint16(30471), + 176: uint16(30472), + 177: uint16(30490), + 178: uint16(30498), + 179: uint16(30489), + 180: uint16(30509), + 181: uint16(30502), + 182: uint16(30517), + 183: uint16(30520), + 184: uint16(30544), + 185: uint16(30545), + 186: uint16(30535), + 187: uint16(30531), + 188: uint16(30554), + 189: uint16(30568), + }, + 109: { + 0: uint16(38927), + 1: uint16(38928), + 2: uint16(38929), + 3: uint16(38930), + 4: uint16(38931), + 5: uint16(38932), + 6: uint16(38933), + 7: uint16(38934), + 8: uint16(38935), + 9: uint16(38936), + 10: uint16(38937), + 11: uint16(38938), + 12: uint16(38939), + 13: uint16(38940), + 14: uint16(38941), + 15: uint16(38942), + 16: uint16(38943), + 17: uint16(38944), + 18: uint16(38945), + 19: uint16(38946), + 20: uint16(38947), + 21: uint16(38948), + 22: uint16(38949), + 23: uint16(38950), + 24: uint16(38951), + 25: uint16(38952), + 26: uint16(38953), + 27: uint16(38954), + 28: uint16(38955), + 29: uint16(38956), + 30: uint16(38957), + 31: uint16(38958), + 32: uint16(38959), + 33: uint16(38960), + 34: uint16(38961), + 35: uint16(38962), + 36: uint16(38963), + 37: uint16(38964), + 38: uint16(38965), + 39: uint16(38966), + 40: uint16(38967), + 41: uint16(38968), + 42: uint16(38969), + 43: uint16(38970), + 44: uint16(38971), + 45: uint16(38972), + 46: uint16(38973), + 47: uint16(38974), + 48: uint16(38975), + 49: uint16(38976), + 50: uint16(38977), + 51: uint16(38978), + 52: uint16(38979), + 53: uint16(38980), + 54: uint16(38981), + 55: uint16(38982), + 56: uint16(38983), + 57: uint16(38984), + 58: uint16(38985), + 59: uint16(38986), + 60: uint16(38987), + 61: uint16(38988), + 62: uint16(38989), + 63: uint16(38990), + 64: uint16(38991), + 65: uint16(38992), + 66: uint16(38993), + 67: uint16(38994), + 68: uint16(38995), + 69: uint16(38996), + 70: uint16(38997), + 71: uint16(38998), + 72: uint16(38999), + 73: uint16(39000), + 74: uint16(39001), + 75: uint16(39002), + 76: uint16(39003), + 77: uint16(39004), + 78: uint16(39005), + 79: uint16(39006), + 80: uint16(39007), + 81: uint16(39008), + 82: uint16(39009), + 83: uint16(39010), + 84: uint16(39011), + 85: uint16(39012), + 86: uint16(39013), + 87: uint16(39014), + 88: uint16(39015), + 89: uint16(39016), + 90: uint16(39017), + 91: uint16(39018), + 92: uint16(39019), + 93: uint16(39020), + 94: uint16(39021), + 95: uint16(39022), + 96: uint16(30562), + 97: uint16(30565), + 98: uint16(30591), + 99: uint16(30605), + 100: uint16(30589), + 101: uint16(30592), + 102: uint16(30604), + 103: uint16(30609), + 104: uint16(30623), + 105: uint16(30624), + 106: uint16(30640), + 107: uint16(30645), + 108: uint16(30653), + 109: uint16(30010), + 110: uint16(30016), + 111: uint16(30030), + 112: uint16(30027), + 113: uint16(30024), + 114: uint16(30043), + 115: uint16(30066), + 116: uint16(30073), + 117: uint16(30083), + 118: uint16(32600), + 119: uint16(32609), + 120: uint16(32607), + 121: uint16(35400), + 122: uint16(32616), + 123: uint16(32628), + 124: uint16(32625), + 125: uint16(32633), + 126: uint16(32641), + 127: uint16(32638), + 128: uint16(30413), + 129: uint16(30437), + 130: uint16(34866), + 131: uint16(38021), + 132: uint16(38022), + 133: uint16(38023), + 134: uint16(38027), + 135: uint16(38026), + 136: uint16(38028), + 137: uint16(38029), + 138: uint16(38031), + 139: uint16(38032), + 140: uint16(38036), + 141: uint16(38039), + 142: uint16(38037), + 143: uint16(38042), + 144: uint16(38043), + 145: uint16(38044), + 146: uint16(38051), + 147: uint16(38052), + 148: uint16(38059), + 149: uint16(38058), + 150: uint16(38061), + 151: uint16(38060), + 152: uint16(38063), + 153: uint16(38064), + 154: uint16(38066), + 155: uint16(38068), + 156: uint16(38070), + 157: uint16(38071), + 158: uint16(38072), + 159: uint16(38073), + 160: uint16(38074), + 161: uint16(38076), + 162: uint16(38077), + 163: uint16(38079), + 164: uint16(38084), + 165: uint16(38088), + 166: uint16(38089), + 167: uint16(38090), + 168: uint16(38091), + 169: uint16(38092), + 170: uint16(38093), + 171: uint16(38094), + 172: uint16(38096), + 173: uint16(38097), + 174: uint16(38098), + 175: uint16(38101), + 176: uint16(38102), + 177: uint16(38103), + 178: uint16(38105), + 179: uint16(38104), + 180: uint16(38107), + 181: uint16(38110), + 182: uint16(38111), + 183: uint16(38112), + 184: uint16(38114), + 185: uint16(38116), + 186: uint16(38117), + 187: uint16(38119), + 188: uint16(38120), + 189: uint16(38122), + }, + 110: { + 0: uint16(39023), + 1: uint16(39024), + 2: uint16(39025), + 3: uint16(39026), + 4: uint16(39027), + 5: uint16(39028), + 6: uint16(39051), + 7: uint16(39054), + 8: uint16(39058), + 9: uint16(39061), + 10: uint16(39065), + 11: uint16(39075), + 12: uint16(39080), + 13: uint16(39081), + 14: uint16(39082), + 15: uint16(39083), + 16: uint16(39084), + 17: uint16(39085), + 18: uint16(39086), + 19: uint16(39087), + 20: uint16(39088), + 21: uint16(39089), + 22: uint16(39090), + 23: uint16(39091), + 24: uint16(39092), + 25: uint16(39093), + 26: uint16(39094), + 27: uint16(39095), + 28: uint16(39096), + 29: uint16(39097), + 30: uint16(39098), + 31: uint16(39099), + 32: uint16(39100), + 33: uint16(39101), + 34: uint16(39102), + 35: uint16(39103), + 36: uint16(39104), + 37: uint16(39105), + 38: uint16(39106), + 39: uint16(39107), + 40: uint16(39108), + 41: uint16(39109), + 42: uint16(39110), + 43: uint16(39111), + 44: uint16(39112), + 45: uint16(39113), + 46: uint16(39114), + 47: uint16(39115), + 48: uint16(39116), + 49: uint16(39117), + 50: uint16(39119), + 51: uint16(39120), + 52: uint16(39124), + 53: uint16(39126), + 54: uint16(39127), + 55: uint16(39131), + 56: uint16(39132), + 57: uint16(39133), + 58: uint16(39136), + 59: uint16(39137), + 60: uint16(39138), + 61: uint16(39139), + 62: uint16(39140), + 63: uint16(39141), + 64: uint16(39142), + 65: uint16(39145), + 66: uint16(39146), + 67: uint16(39147), + 68: uint16(39148), + 69: uint16(39149), + 70: uint16(39150), + 71: uint16(39151), + 72: uint16(39152), + 73: uint16(39153), + 74: uint16(39154), + 75: uint16(39155), + 76: uint16(39156), + 77: uint16(39157), + 78: uint16(39158), + 79: uint16(39159), + 80: uint16(39160), + 81: uint16(39161), + 82: uint16(39162), + 83: uint16(39163), + 84: uint16(39164), + 85: uint16(39165), + 86: uint16(39166), + 87: uint16(39167), + 88: uint16(39168), + 89: uint16(39169), + 90: uint16(39170), + 91: uint16(39171), + 92: uint16(39172), + 93: uint16(39173), + 94: uint16(39174), + 95: uint16(39175), + 96: uint16(38121), + 97: uint16(38123), + 98: uint16(38126), + 99: uint16(38127), + 100: uint16(38131), + 101: uint16(38132), + 102: uint16(38133), + 103: uint16(38135), + 104: uint16(38137), + 105: uint16(38140), + 106: uint16(38141), + 107: uint16(38143), + 108: uint16(38147), + 109: uint16(38146), + 110: uint16(38150), + 111: uint16(38151), + 112: uint16(38153), + 113: uint16(38154), + 114: uint16(38157), + 115: uint16(38158), + 116: uint16(38159), + 117: uint16(38162), + 118: uint16(38163), + 119: uint16(38164), + 120: uint16(38165), + 121: uint16(38166), + 122: uint16(38168), + 123: uint16(38171), + 124: uint16(38173), + 125: uint16(38174), + 126: uint16(38175), + 127: uint16(38178), + 128: uint16(38186), + 129: uint16(38187), + 130: uint16(38185), + 131: uint16(38188), + 132: uint16(38193), + 133: uint16(38194), + 134: uint16(38196), + 135: uint16(38198), + 136: uint16(38199), + 137: uint16(38200), + 138: uint16(38204), + 139: uint16(38206), + 140: uint16(38207), + 141: uint16(38210), + 142: uint16(38197), + 143: uint16(38212), + 144: uint16(38213), + 145: uint16(38214), + 146: uint16(38217), + 147: uint16(38220), + 148: uint16(38222), + 149: uint16(38223), + 150: uint16(38226), + 151: uint16(38227), + 152: uint16(38228), + 153: uint16(38230), + 154: uint16(38231), + 155: uint16(38232), + 156: uint16(38233), + 157: uint16(38235), + 158: uint16(38238), + 159: uint16(38239), + 160: uint16(38237), + 161: uint16(38241), + 162: uint16(38242), + 163: uint16(38244), + 164: uint16(38245), + 165: uint16(38246), + 166: uint16(38247), + 167: uint16(38248), + 168: uint16(38249), + 169: uint16(38250), + 170: uint16(38251), + 171: uint16(38252), + 172: uint16(38255), + 173: uint16(38257), + 174: uint16(38258), + 175: uint16(38259), + 176: uint16(38202), + 177: uint16(30695), + 178: uint16(30700), + 179: uint16(38601), + 180: uint16(31189), + 181: uint16(31213), + 182: uint16(31203), + 183: uint16(31211), + 184: uint16(31238), + 185: uint16(23879), + 186: uint16(31235), + 187: uint16(31234), + 188: uint16(31262), + 189: uint16(31252), + }, + 111: { + 0: uint16(39176), + 1: uint16(39177), + 2: uint16(39178), + 3: uint16(39179), + 4: uint16(39180), + 5: uint16(39182), + 6: uint16(39183), + 7: uint16(39185), + 8: uint16(39186), + 9: uint16(39187), + 10: uint16(39188), + 11: uint16(39189), + 12: uint16(39190), + 13: uint16(39191), + 14: uint16(39192), + 15: uint16(39193), + 16: uint16(39194), + 17: uint16(39195), + 18: uint16(39196), + 19: uint16(39197), + 20: uint16(39198), + 21: uint16(39199), + 22: uint16(39200), + 23: uint16(39201), + 24: uint16(39202), + 25: uint16(39203), + 26: uint16(39204), + 27: uint16(39205), + 28: uint16(39206), + 29: uint16(39207), + 30: uint16(39208), + 31: uint16(39209), + 32: uint16(39210), + 33: uint16(39211), + 34: uint16(39212), + 35: uint16(39213), + 36: uint16(39215), + 37: uint16(39216), + 38: uint16(39217), + 39: uint16(39218), + 40: uint16(39219), + 41: uint16(39220), + 42: uint16(39221), + 43: uint16(39222), + 44: uint16(39223), + 45: uint16(39224), + 46: uint16(39225), + 47: uint16(39226), + 48: uint16(39227), + 49: uint16(39228), + 50: uint16(39229), + 51: uint16(39230), + 52: uint16(39231), + 53: uint16(39232), + 54: uint16(39233), + 55: uint16(39234), + 56: uint16(39235), + 57: uint16(39236), + 58: uint16(39237), + 59: uint16(39238), + 60: uint16(39239), + 61: uint16(39240), + 62: uint16(39241), + 63: uint16(39242), + 64: uint16(39243), + 65: uint16(39244), + 66: uint16(39245), + 67: uint16(39246), + 68: uint16(39247), + 69: uint16(39248), + 70: uint16(39249), + 71: uint16(39250), + 72: uint16(39251), + 73: uint16(39254), + 74: uint16(39255), + 75: uint16(39256), + 76: uint16(39257), + 77: uint16(39258), + 78: uint16(39259), + 79: uint16(39260), + 80: uint16(39261), + 81: uint16(39262), + 82: uint16(39263), + 83: uint16(39264), + 84: uint16(39265), + 85: uint16(39266), + 86: uint16(39268), + 87: uint16(39270), + 88: uint16(39283), + 89: uint16(39288), + 90: uint16(39289), + 91: uint16(39291), + 92: uint16(39294), + 93: uint16(39298), + 94: uint16(39299), + 95: uint16(39305), + 96: uint16(31289), + 97: uint16(31287), + 98: uint16(31313), + 99: uint16(40655), + 100: uint16(39333), + 101: uint16(31344), + 102: uint16(30344), + 103: uint16(30350), + 104: uint16(30355), + 105: uint16(30361), + 106: uint16(30372), + 107: uint16(29918), + 108: uint16(29920), + 109: uint16(29996), + 110: uint16(40480), + 111: uint16(40482), + 112: uint16(40488), + 113: uint16(40489), + 114: uint16(40490), + 115: uint16(40491), + 116: uint16(40492), + 117: uint16(40498), + 118: uint16(40497), + 119: uint16(40502), + 120: uint16(40504), + 121: uint16(40503), + 122: uint16(40505), + 123: uint16(40506), + 124: uint16(40510), + 125: uint16(40513), + 126: uint16(40514), + 127: uint16(40516), + 128: uint16(40518), + 129: uint16(40519), + 130: uint16(40520), + 131: uint16(40521), + 132: uint16(40523), + 133: uint16(40524), + 134: uint16(40526), + 135: uint16(40529), + 136: uint16(40533), + 137: uint16(40535), + 138: uint16(40538), + 139: uint16(40539), + 140: uint16(40540), + 141: uint16(40542), + 142: uint16(40547), + 143: uint16(40550), + 144: uint16(40551), + 145: uint16(40552), + 146: uint16(40553), + 147: uint16(40554), + 148: uint16(40555), + 149: uint16(40556), + 150: uint16(40561), + 151: uint16(40557), + 152: uint16(40563), + 153: uint16(30098), + 154: uint16(30100), + 155: uint16(30102), + 156: uint16(30112), + 157: uint16(30109), + 158: uint16(30124), + 159: uint16(30115), + 160: uint16(30131), + 161: uint16(30132), + 162: uint16(30136), + 163: uint16(30148), + 164: uint16(30129), + 165: uint16(30128), + 166: uint16(30147), + 167: uint16(30146), + 168: uint16(30166), + 169: uint16(30157), + 170: uint16(30179), + 171: uint16(30184), + 172: uint16(30182), + 173: uint16(30180), + 174: uint16(30187), + 175: uint16(30183), + 176: uint16(30211), + 177: uint16(30193), + 178: uint16(30204), + 179: uint16(30207), + 180: uint16(30224), + 181: uint16(30208), + 182: uint16(30213), + 183: uint16(30220), + 184: uint16(30231), + 185: uint16(30218), + 186: uint16(30245), + 187: uint16(30232), + 188: uint16(30229), + 189: uint16(30233), + }, + 112: { + 0: uint16(39308), + 1: uint16(39310), + 2: uint16(39322), + 3: uint16(39323), + 4: uint16(39324), + 5: uint16(39325), + 6: uint16(39326), + 7: uint16(39327), + 8: uint16(39328), + 9: uint16(39329), + 10: uint16(39330), + 11: uint16(39331), + 12: uint16(39332), + 13: uint16(39334), + 14: uint16(39335), + 15: uint16(39337), + 16: uint16(39338), + 17: uint16(39339), + 18: uint16(39340), + 19: uint16(39341), + 20: uint16(39342), + 21: uint16(39343), + 22: uint16(39344), + 23: uint16(39345), + 24: uint16(39346), + 25: uint16(39347), + 26: uint16(39348), + 27: uint16(39349), + 28: uint16(39350), + 29: uint16(39351), + 30: uint16(39352), + 31: uint16(39353), + 32: uint16(39354), + 33: uint16(39355), + 34: uint16(39356), + 35: uint16(39357), + 36: uint16(39358), + 37: uint16(39359), + 38: uint16(39360), + 39: uint16(39361), + 40: uint16(39362), + 41: uint16(39363), + 42: uint16(39364), + 43: uint16(39365), + 44: uint16(39366), + 45: uint16(39367), + 46: uint16(39368), + 47: uint16(39369), + 48: uint16(39370), + 49: uint16(39371), + 50: uint16(39372), + 51: uint16(39373), + 52: uint16(39374), + 53: uint16(39375), + 54: uint16(39376), + 55: uint16(39377), + 56: uint16(39378), + 57: uint16(39379), + 58: uint16(39380), + 59: uint16(39381), + 60: uint16(39382), + 61: uint16(39383), + 62: uint16(39384), + 63: uint16(39385), + 64: uint16(39386), + 65: uint16(39387), + 66: uint16(39388), + 67: uint16(39389), + 68: uint16(39390), + 69: uint16(39391), + 70: uint16(39392), + 71: uint16(39393), + 72: uint16(39394), + 73: uint16(39395), + 74: uint16(39396), + 75: uint16(39397), + 76: uint16(39398), + 77: uint16(39399), + 78: uint16(39400), + 79: uint16(39401), + 80: uint16(39402), + 81: uint16(39403), + 82: uint16(39404), + 83: uint16(39405), + 84: uint16(39406), + 85: uint16(39407), + 86: uint16(39408), + 87: uint16(39409), + 88: uint16(39410), + 89: uint16(39411), + 90: uint16(39412), + 91: uint16(39413), + 92: uint16(39414), + 93: uint16(39415), + 94: uint16(39416), + 95: uint16(39417), + 96: uint16(30235), + 97: uint16(30268), + 98: uint16(30242), + 99: uint16(30240), + 100: uint16(30272), + 101: uint16(30253), + 102: uint16(30256), + 103: uint16(30271), + 104: uint16(30261), + 105: uint16(30275), + 106: uint16(30270), + 107: uint16(30259), + 108: uint16(30285), + 109: uint16(30302), + 110: uint16(30292), + 111: uint16(30300), + 112: uint16(30294), + 113: uint16(30315), + 114: uint16(30319), + 115: uint16(32714), + 116: uint16(31462), + 117: uint16(31352), + 118: uint16(31353), + 119: uint16(31360), + 120: uint16(31366), + 121: uint16(31368), + 122: uint16(31381), + 123: uint16(31398), + 124: uint16(31392), + 125: uint16(31404), + 126: uint16(31400), + 127: uint16(31405), + 128: uint16(31411), + 129: uint16(34916), + 130: uint16(34921), + 131: uint16(34930), + 132: uint16(34941), + 133: uint16(34943), + 134: uint16(34946), + 135: uint16(34978), + 136: uint16(35014), + 137: uint16(34999), + 138: uint16(35004), + 139: uint16(35017), + 140: uint16(35042), + 141: uint16(35022), + 142: uint16(35043), + 143: uint16(35045), + 144: uint16(35057), + 145: uint16(35098), + 146: uint16(35068), + 147: uint16(35048), + 148: uint16(35070), + 149: uint16(35056), + 150: uint16(35105), + 151: uint16(35097), + 152: uint16(35091), + 153: uint16(35099), + 154: uint16(35082), + 155: uint16(35124), + 156: uint16(35115), + 157: uint16(35126), + 158: uint16(35137), + 159: uint16(35174), + 160: uint16(35195), + 161: uint16(30091), + 162: uint16(32997), + 163: uint16(30386), + 164: uint16(30388), + 165: uint16(30684), + 166: uint16(32786), + 167: uint16(32788), + 168: uint16(32790), + 169: uint16(32796), + 170: uint16(32800), + 171: uint16(32802), + 172: uint16(32805), + 173: uint16(32806), + 174: uint16(32807), + 175: uint16(32809), + 176: uint16(32808), + 177: uint16(32817), + 178: uint16(32779), + 179: uint16(32821), + 180: uint16(32835), + 181: uint16(32838), + 182: uint16(32845), + 183: uint16(32850), + 184: uint16(32873), + 185: uint16(32881), + 186: uint16(35203), + 187: uint16(39032), + 188: uint16(39040), + 189: uint16(39043), + }, + 113: { + 0: uint16(39418), + 1: uint16(39419), + 2: uint16(39420), + 3: uint16(39421), + 4: uint16(39422), + 5: uint16(39423), + 6: uint16(39424), + 7: uint16(39425), + 8: uint16(39426), + 9: uint16(39427), + 10: uint16(39428), + 11: uint16(39429), + 12: uint16(39430), + 13: uint16(39431), + 14: uint16(39432), + 15: uint16(39433), + 16: uint16(39434), + 17: uint16(39435), + 18: uint16(39436), + 19: uint16(39437), + 20: uint16(39438), + 21: uint16(39439), + 22: uint16(39440), + 23: uint16(39441), + 24: uint16(39442), + 25: uint16(39443), + 26: uint16(39444), + 27: uint16(39445), + 28: uint16(39446), + 29: uint16(39447), + 30: uint16(39448), + 31: uint16(39449), + 32: uint16(39450), + 33: uint16(39451), + 34: uint16(39452), + 35: uint16(39453), + 36: uint16(39454), + 37: uint16(39455), + 38: uint16(39456), + 39: uint16(39457), + 40: uint16(39458), + 41: uint16(39459), + 42: uint16(39460), + 43: uint16(39461), + 44: uint16(39462), + 45: uint16(39463), + 46: uint16(39464), + 47: uint16(39465), + 48: uint16(39466), + 49: uint16(39467), + 50: uint16(39468), + 51: uint16(39469), + 52: uint16(39470), + 53: uint16(39471), + 54: uint16(39472), + 55: uint16(39473), + 56: uint16(39474), + 57: uint16(39475), + 58: uint16(39476), + 59: uint16(39477), + 60: uint16(39478), + 61: uint16(39479), + 62: uint16(39480), + 63: uint16(39481), + 64: uint16(39482), + 65: uint16(39483), + 66: uint16(39484), + 67: uint16(39485), + 68: uint16(39486), + 69: uint16(39487), + 70: uint16(39488), + 71: uint16(39489), + 72: uint16(39490), + 73: uint16(39491), + 74: uint16(39492), + 75: uint16(39493), + 76: uint16(39494), + 77: uint16(39495), + 78: uint16(39496), + 79: uint16(39497), + 80: uint16(39498), + 81: uint16(39499), + 82: uint16(39500), + 83: uint16(39501), + 84: uint16(39502), + 85: uint16(39503), + 86: uint16(39504), + 87: uint16(39505), + 88: uint16(39506), + 89: uint16(39507), + 90: uint16(39508), + 91: uint16(39509), + 92: uint16(39510), + 93: uint16(39511), + 94: uint16(39512), + 95: uint16(39513), + 96: uint16(39049), + 97: uint16(39052), + 98: uint16(39053), + 99: uint16(39055), + 100: uint16(39060), + 101: uint16(39066), + 102: uint16(39067), + 103: uint16(39070), + 104: uint16(39071), + 105: uint16(39073), + 106: uint16(39074), + 107: uint16(39077), + 108: uint16(39078), + 109: uint16(34381), + 110: uint16(34388), + 111: uint16(34412), + 112: uint16(34414), + 113: uint16(34431), + 114: uint16(34426), + 115: uint16(34428), + 116: uint16(34427), + 117: uint16(34472), + 118: uint16(34445), + 119: uint16(34443), + 120: uint16(34476), + 121: uint16(34461), + 122: uint16(34471), + 123: uint16(34467), + 124: uint16(34474), + 125: uint16(34451), + 126: uint16(34473), + 127: uint16(34486), + 128: uint16(34500), + 129: uint16(34485), + 130: uint16(34510), + 131: uint16(34480), + 132: uint16(34490), + 133: uint16(34481), + 134: uint16(34479), + 135: uint16(34505), + 136: uint16(34511), + 137: uint16(34484), + 138: uint16(34537), + 139: uint16(34545), + 140: uint16(34546), + 141: uint16(34541), + 142: uint16(34547), + 143: uint16(34512), + 144: uint16(34579), + 145: uint16(34526), + 146: uint16(34548), + 147: uint16(34527), + 148: uint16(34520), + 149: uint16(34513), + 150: uint16(34563), + 151: uint16(34567), + 152: uint16(34552), + 153: uint16(34568), + 154: uint16(34570), + 155: uint16(34573), + 156: uint16(34569), + 157: uint16(34595), + 158: uint16(34619), + 159: uint16(34590), + 160: uint16(34597), + 161: uint16(34606), + 162: uint16(34586), + 163: uint16(34622), + 164: uint16(34632), + 165: uint16(34612), + 166: uint16(34609), + 167: uint16(34601), + 168: uint16(34615), + 169: uint16(34623), + 170: uint16(34690), + 171: uint16(34594), + 172: uint16(34685), + 173: uint16(34686), + 174: uint16(34683), + 175: uint16(34656), + 176: uint16(34672), + 177: uint16(34636), + 178: uint16(34670), + 179: uint16(34699), + 180: uint16(34643), + 181: uint16(34659), + 182: uint16(34684), + 183: uint16(34660), + 184: uint16(34649), + 185: uint16(34661), + 186: uint16(34707), + 187: uint16(34735), + 188: uint16(34728), + 189: uint16(34770), + }, + 114: { + 0: uint16(39514), + 1: uint16(39515), + 2: uint16(39516), + 3: uint16(39517), + 4: uint16(39518), + 5: uint16(39519), + 6: uint16(39520), + 7: uint16(39521), + 8: uint16(39522), + 9: uint16(39523), + 10: uint16(39524), + 11: uint16(39525), + 12: uint16(39526), + 13: uint16(39527), + 14: uint16(39528), + 15: uint16(39529), + 16: uint16(39530), + 17: uint16(39531), + 18: uint16(39538), + 19: uint16(39555), + 20: uint16(39561), + 21: uint16(39565), + 22: uint16(39566), + 23: uint16(39572), + 24: uint16(39573), + 25: uint16(39577), + 26: uint16(39590), + 27: uint16(39593), + 28: uint16(39594), + 29: uint16(39595), + 30: uint16(39596), + 31: uint16(39597), + 32: uint16(39598), + 33: uint16(39599), + 34: uint16(39602), + 35: uint16(39603), + 36: uint16(39604), + 37: uint16(39605), + 38: uint16(39609), + 39: uint16(39611), + 40: uint16(39613), + 41: uint16(39614), + 42: uint16(39615), + 43: uint16(39619), + 44: uint16(39620), + 45: uint16(39622), + 46: uint16(39623), + 47: uint16(39624), + 48: uint16(39625), + 49: uint16(39626), + 50: uint16(39629), + 51: uint16(39630), + 52: uint16(39631), + 53: uint16(39632), + 54: uint16(39634), + 55: uint16(39636), + 56: uint16(39637), + 57: uint16(39638), + 58: uint16(39639), + 59: uint16(39641), + 60: uint16(39642), + 61: uint16(39643), + 62: uint16(39644), + 63: uint16(39645), + 64: uint16(39646), + 65: uint16(39648), + 66: uint16(39650), + 67: uint16(39651), + 68: uint16(39652), + 69: uint16(39653), + 70: uint16(39655), + 71: uint16(39656), + 72: uint16(39657), + 73: uint16(39658), + 74: uint16(39660), + 75: uint16(39662), + 76: uint16(39664), + 77: uint16(39665), + 78: uint16(39666), + 79: uint16(39667), + 80: uint16(39668), + 81: uint16(39669), + 82: uint16(39670), + 83: uint16(39671), + 84: uint16(39672), + 85: uint16(39674), + 86: uint16(39676), + 87: uint16(39677), + 88: uint16(39678), + 89: uint16(39679), + 90: uint16(39680), + 91: uint16(39681), + 92: uint16(39682), + 93: uint16(39684), + 94: uint16(39685), + 95: uint16(39686), + 96: uint16(34758), + 97: uint16(34696), + 98: uint16(34693), + 99: uint16(34733), + 100: uint16(34711), + 101: uint16(34691), + 102: uint16(34731), + 103: uint16(34789), + 104: uint16(34732), + 105: uint16(34741), + 106: uint16(34739), + 107: uint16(34763), + 108: uint16(34771), + 109: uint16(34749), + 110: uint16(34769), + 111: uint16(34752), + 112: uint16(34762), + 113: uint16(34779), + 114: uint16(34794), + 115: uint16(34784), + 116: uint16(34798), + 117: uint16(34838), + 118: uint16(34835), + 119: uint16(34814), + 120: uint16(34826), + 121: uint16(34843), + 122: uint16(34849), + 123: uint16(34873), + 124: uint16(34876), + 125: uint16(32566), + 126: uint16(32578), + 127: uint16(32580), + 128: uint16(32581), + 129: uint16(33296), + 130: uint16(31482), + 131: uint16(31485), + 132: uint16(31496), + 133: uint16(31491), + 134: uint16(31492), + 135: uint16(31509), + 136: uint16(31498), + 137: uint16(31531), + 138: uint16(31503), + 139: uint16(31559), + 140: uint16(31544), + 141: uint16(31530), + 142: uint16(31513), + 143: uint16(31534), + 144: uint16(31537), + 145: uint16(31520), + 146: uint16(31525), + 147: uint16(31524), + 148: uint16(31539), + 149: uint16(31550), + 150: uint16(31518), + 151: uint16(31576), + 152: uint16(31578), + 153: uint16(31557), + 154: uint16(31605), + 155: uint16(31564), + 156: uint16(31581), + 157: uint16(31584), + 158: uint16(31598), + 159: uint16(31611), + 160: uint16(31586), + 161: uint16(31602), + 162: uint16(31601), + 163: uint16(31632), + 164: uint16(31654), + 165: uint16(31655), + 166: uint16(31672), + 167: uint16(31660), + 168: uint16(31645), + 169: uint16(31656), + 170: uint16(31621), + 171: uint16(31658), + 172: uint16(31644), + 173: uint16(31650), + 174: uint16(31659), + 175: uint16(31668), + 176: uint16(31697), + 177: uint16(31681), + 178: uint16(31692), + 179: uint16(31709), + 180: uint16(31706), + 181: uint16(31717), + 182: uint16(31718), + 183: uint16(31722), + 184: uint16(31756), + 185: uint16(31742), + 186: uint16(31740), + 187: uint16(31759), + 188: uint16(31766), + 189: uint16(31755), + }, + 115: { + 0: uint16(39687), + 1: uint16(39689), + 2: uint16(39690), + 3: uint16(39691), + 4: uint16(39692), + 5: uint16(39693), + 6: uint16(39694), + 7: uint16(39696), + 8: uint16(39697), + 9: uint16(39698), + 10: uint16(39700), + 11: uint16(39701), + 12: uint16(39702), + 13: uint16(39703), + 14: uint16(39704), + 15: uint16(39705), + 16: uint16(39706), + 17: uint16(39707), + 18: uint16(39708), + 19: uint16(39709), + 20: uint16(39710), + 21: uint16(39712), + 22: uint16(39713), + 23: uint16(39714), + 24: uint16(39716), + 25: uint16(39717), + 26: uint16(39718), + 27: uint16(39719), + 28: uint16(39720), + 29: uint16(39721), + 30: uint16(39722), + 31: uint16(39723), + 32: uint16(39724), + 33: uint16(39725), + 34: uint16(39726), + 35: uint16(39728), + 36: uint16(39729), + 37: uint16(39731), + 38: uint16(39732), + 39: uint16(39733), + 40: uint16(39734), + 41: uint16(39735), + 42: uint16(39736), + 43: uint16(39737), + 44: uint16(39738), + 45: uint16(39741), + 46: uint16(39742), + 47: uint16(39743), + 48: uint16(39744), + 49: uint16(39750), + 50: uint16(39754), + 51: uint16(39755), + 52: uint16(39756), + 53: uint16(39758), + 54: uint16(39760), + 55: uint16(39762), + 56: uint16(39763), + 57: uint16(39765), + 58: uint16(39766), + 59: uint16(39767), + 60: uint16(39768), + 61: uint16(39769), + 62: uint16(39770), + 63: uint16(39771), + 64: uint16(39772), + 65: uint16(39773), + 66: uint16(39774), + 67: uint16(39775), + 68: uint16(39776), + 69: uint16(39777), + 70: uint16(39778), + 71: uint16(39779), + 72: uint16(39780), + 73: uint16(39781), + 74: uint16(39782), + 75: uint16(39783), + 76: uint16(39784), + 77: uint16(39785), + 78: uint16(39786), + 79: uint16(39787), + 80: uint16(39788), + 81: uint16(39789), + 82: uint16(39790), + 83: uint16(39791), + 84: uint16(39792), + 85: uint16(39793), + 86: uint16(39794), + 87: uint16(39795), + 88: uint16(39796), + 89: uint16(39797), + 90: uint16(39798), + 91: uint16(39799), + 92: uint16(39800), + 93: uint16(39801), + 94: uint16(39802), + 95: uint16(39803), + 96: uint16(31775), + 97: uint16(31786), + 98: uint16(31782), + 99: uint16(31800), + 100: uint16(31809), + 101: uint16(31808), + 102: uint16(33278), + 103: uint16(33281), + 104: uint16(33282), + 105: uint16(33284), + 106: uint16(33260), + 107: uint16(34884), + 108: uint16(33313), + 109: uint16(33314), + 110: uint16(33315), + 111: uint16(33325), + 112: uint16(33327), + 113: uint16(33320), + 114: uint16(33323), + 115: uint16(33336), + 116: uint16(33339), + 117: uint16(33331), + 118: uint16(33332), + 119: uint16(33342), + 120: uint16(33348), + 121: uint16(33353), + 122: uint16(33355), + 123: uint16(33359), + 124: uint16(33370), + 125: uint16(33375), + 126: uint16(33384), + 127: uint16(34942), + 128: uint16(34949), + 129: uint16(34952), + 130: uint16(35032), + 131: uint16(35039), + 132: uint16(35166), + 133: uint16(32669), + 134: uint16(32671), + 135: uint16(32679), + 136: uint16(32687), + 137: uint16(32688), + 138: uint16(32690), + 139: uint16(31868), + 140: uint16(25929), + 141: uint16(31889), + 142: uint16(31901), + 143: uint16(31900), + 144: uint16(31902), + 145: uint16(31906), + 146: uint16(31922), + 147: uint16(31932), + 148: uint16(31933), + 149: uint16(31937), + 150: uint16(31943), + 151: uint16(31948), + 152: uint16(31949), + 153: uint16(31944), + 154: uint16(31941), + 155: uint16(31959), + 156: uint16(31976), + 157: uint16(33390), + 158: uint16(26280), + 159: uint16(32703), + 160: uint16(32718), + 161: uint16(32725), + 162: uint16(32741), + 163: uint16(32737), + 164: uint16(32742), + 165: uint16(32745), + 166: uint16(32750), + 167: uint16(32755), + 168: uint16(31992), + 169: uint16(32119), + 170: uint16(32166), + 171: uint16(32174), + 172: uint16(32327), + 173: uint16(32411), + 174: uint16(40632), + 175: uint16(40628), + 176: uint16(36211), + 177: uint16(36228), + 178: uint16(36244), + 179: uint16(36241), + 180: uint16(36273), + 181: uint16(36199), + 182: uint16(36205), + 183: uint16(35911), + 184: uint16(35913), + 185: uint16(37194), + 186: uint16(37200), + 187: uint16(37198), + 188: uint16(37199), + 189: uint16(37220), + }, + 116: { + 0: uint16(39804), + 1: uint16(39805), + 2: uint16(39806), + 3: uint16(39807), + 4: uint16(39808), + 5: uint16(39809), + 6: uint16(39810), + 7: uint16(39811), + 8: uint16(39812), + 9: uint16(39813), + 10: uint16(39814), + 11: uint16(39815), + 12: uint16(39816), + 13: uint16(39817), + 14: uint16(39818), + 15: uint16(39819), + 16: uint16(39820), + 17: uint16(39821), + 18: uint16(39822), + 19: uint16(39823), + 20: uint16(39824), + 21: uint16(39825), + 22: uint16(39826), + 23: uint16(39827), + 24: uint16(39828), + 25: uint16(39829), + 26: uint16(39830), + 27: uint16(39831), + 28: uint16(39832), + 29: uint16(39833), + 30: uint16(39834), + 31: uint16(39835), + 32: uint16(39836), + 33: uint16(39837), + 34: uint16(39838), + 35: uint16(39839), + 36: uint16(39840), + 37: uint16(39841), + 38: uint16(39842), + 39: uint16(39843), + 40: uint16(39844), + 41: uint16(39845), + 42: uint16(39846), + 43: uint16(39847), + 44: uint16(39848), + 45: uint16(39849), + 46: uint16(39850), + 47: uint16(39851), + 48: uint16(39852), + 49: uint16(39853), + 50: uint16(39854), + 51: uint16(39855), + 52: uint16(39856), + 53: uint16(39857), + 54: uint16(39858), + 55: uint16(39859), + 56: uint16(39860), + 57: uint16(39861), + 58: uint16(39862), + 59: uint16(39863), + 60: uint16(39864), + 61: uint16(39865), + 62: uint16(39866), + 63: uint16(39867), + 64: uint16(39868), + 65: uint16(39869), + 66: uint16(39870), + 67: uint16(39871), + 68: uint16(39872), + 69: uint16(39873), + 70: uint16(39874), + 71: uint16(39875), + 72: uint16(39876), + 73: uint16(39877), + 74: uint16(39878), + 75: uint16(39879), + 76: uint16(39880), + 77: uint16(39881), + 78: uint16(39882), + 79: uint16(39883), + 80: uint16(39884), + 81: uint16(39885), + 82: uint16(39886), + 83: uint16(39887), + 84: uint16(39888), + 85: uint16(39889), + 86: uint16(39890), + 87: uint16(39891), + 88: uint16(39892), + 89: uint16(39893), + 90: uint16(39894), + 91: uint16(39895), + 92: uint16(39896), + 93: uint16(39897), + 94: uint16(39898), + 95: uint16(39899), + 96: uint16(37218), + 97: uint16(37217), + 98: uint16(37232), + 99: uint16(37225), + 100: uint16(37231), + 101: uint16(37245), + 102: uint16(37246), + 103: uint16(37234), + 104: uint16(37236), + 105: uint16(37241), + 106: uint16(37260), + 107: uint16(37253), + 108: uint16(37264), + 109: uint16(37261), + 110: uint16(37265), + 111: uint16(37282), + 112: uint16(37283), + 113: uint16(37290), + 114: uint16(37293), + 115: uint16(37294), + 116: uint16(37295), + 117: uint16(37301), + 118: uint16(37300), + 119: uint16(37306), + 120: uint16(35925), + 121: uint16(40574), + 122: uint16(36280), + 123: uint16(36331), + 124: uint16(36357), + 125: uint16(36441), + 126: uint16(36457), + 127: uint16(36277), + 128: uint16(36287), + 129: uint16(36284), + 130: uint16(36282), + 131: uint16(36292), + 132: uint16(36310), + 133: uint16(36311), + 134: uint16(36314), + 135: uint16(36318), + 136: uint16(36302), + 137: uint16(36303), + 138: uint16(36315), + 139: uint16(36294), + 140: uint16(36332), + 141: uint16(36343), + 142: uint16(36344), + 143: uint16(36323), + 144: uint16(36345), + 145: uint16(36347), + 146: uint16(36324), + 147: uint16(36361), + 148: uint16(36349), + 149: uint16(36372), + 150: uint16(36381), + 151: uint16(36383), + 152: uint16(36396), + 153: uint16(36398), + 154: uint16(36387), + 155: uint16(36399), + 156: uint16(36410), + 157: uint16(36416), + 158: uint16(36409), + 159: uint16(36405), + 160: uint16(36413), + 161: uint16(36401), + 162: uint16(36425), + 163: uint16(36417), + 164: uint16(36418), + 165: uint16(36433), + 166: uint16(36434), + 167: uint16(36426), + 168: uint16(36464), + 169: uint16(36470), + 170: uint16(36476), + 171: uint16(36463), + 172: uint16(36468), + 173: uint16(36485), + 174: uint16(36495), + 175: uint16(36500), + 176: uint16(36496), + 177: uint16(36508), + 178: uint16(36510), + 179: uint16(35960), + 180: uint16(35970), + 181: uint16(35978), + 182: uint16(35973), + 183: uint16(35992), + 184: uint16(35988), + 185: uint16(26011), + 186: uint16(35286), + 187: uint16(35294), + 188: uint16(35290), + 189: uint16(35292), + }, + 117: { + 0: uint16(39900), + 1: uint16(39901), + 2: uint16(39902), + 3: uint16(39903), + 4: uint16(39904), + 5: uint16(39905), + 6: uint16(39906), + 7: uint16(39907), + 8: uint16(39908), + 9: uint16(39909), + 10: uint16(39910), + 11: uint16(39911), + 12: uint16(39912), + 13: uint16(39913), + 14: uint16(39914), + 15: uint16(39915), + 16: uint16(39916), + 17: uint16(39917), + 18: uint16(39918), + 19: uint16(39919), + 20: uint16(39920), + 21: uint16(39921), + 22: uint16(39922), + 23: uint16(39923), + 24: uint16(39924), + 25: uint16(39925), + 26: uint16(39926), + 27: uint16(39927), + 28: uint16(39928), + 29: uint16(39929), + 30: uint16(39930), + 31: uint16(39931), + 32: uint16(39932), + 33: uint16(39933), + 34: uint16(39934), + 35: uint16(39935), + 36: uint16(39936), + 37: uint16(39937), + 38: uint16(39938), + 39: uint16(39939), + 40: uint16(39940), + 41: uint16(39941), + 42: uint16(39942), + 43: uint16(39943), + 44: uint16(39944), + 45: uint16(39945), + 46: uint16(39946), + 47: uint16(39947), + 48: uint16(39948), + 49: uint16(39949), + 50: uint16(39950), + 51: uint16(39951), + 52: uint16(39952), + 53: uint16(39953), + 54: uint16(39954), + 55: uint16(39955), + 56: uint16(39956), + 57: uint16(39957), + 58: uint16(39958), + 59: uint16(39959), + 60: uint16(39960), + 61: uint16(39961), + 62: uint16(39962), + 63: uint16(39963), + 64: uint16(39964), + 65: uint16(39965), + 66: uint16(39966), + 67: uint16(39967), + 68: uint16(39968), + 69: uint16(39969), + 70: uint16(39970), + 71: uint16(39971), + 72: uint16(39972), + 73: uint16(39973), + 74: uint16(39974), + 75: uint16(39975), + 76: uint16(39976), + 77: uint16(39977), + 78: uint16(39978), + 79: uint16(39979), + 80: uint16(39980), + 81: uint16(39981), + 82: uint16(39982), + 83: uint16(39983), + 84: uint16(39984), + 85: uint16(39985), + 86: uint16(39986), + 87: uint16(39987), + 88: uint16(39988), + 89: uint16(39989), + 90: uint16(39990), + 91: uint16(39991), + 92: uint16(39992), + 93: uint16(39993), + 94: uint16(39994), + 95: uint16(39995), + 96: uint16(35301), + 97: uint16(35307), + 98: uint16(35311), + 99: uint16(35390), + 100: uint16(35622), + 101: uint16(38739), + 102: uint16(38633), + 103: uint16(38643), + 104: uint16(38639), + 105: uint16(38662), + 106: uint16(38657), + 107: uint16(38664), + 108: uint16(38671), + 109: uint16(38670), + 110: uint16(38698), + 111: uint16(38701), + 112: uint16(38704), + 113: uint16(38718), + 114: uint16(40832), + 115: uint16(40835), + 116: uint16(40837), + 117: uint16(40838), + 118: uint16(40839), + 119: uint16(40840), + 120: uint16(40841), + 121: uint16(40842), + 122: uint16(40844), + 123: uint16(40702), + 124: uint16(40715), + 125: uint16(40717), + 126: uint16(38585), + 127: uint16(38588), + 128: uint16(38589), + 129: uint16(38606), + 130: uint16(38610), + 131: uint16(30655), + 132: uint16(38624), + 133: uint16(37518), + 134: uint16(37550), + 135: uint16(37576), + 136: uint16(37694), + 137: uint16(37738), + 138: uint16(37834), + 139: uint16(37775), + 140: uint16(37950), + 141: uint16(37995), + 142: uint16(40063), + 143: uint16(40066), + 144: uint16(40069), + 145: uint16(40070), + 146: uint16(40071), + 147: uint16(40072), + 148: uint16(31267), + 149: uint16(40075), + 150: uint16(40078), + 151: uint16(40080), + 152: uint16(40081), + 153: uint16(40082), + 154: uint16(40084), + 155: uint16(40085), + 156: uint16(40090), + 157: uint16(40091), + 158: uint16(40094), + 159: uint16(40095), + 160: uint16(40096), + 161: uint16(40097), + 162: uint16(40098), + 163: uint16(40099), + 164: uint16(40101), + 165: uint16(40102), + 166: uint16(40103), + 167: uint16(40104), + 168: uint16(40105), + 169: uint16(40107), + 170: uint16(40109), + 171: uint16(40110), + 172: uint16(40112), + 173: uint16(40113), + 174: uint16(40114), + 175: uint16(40115), + 176: uint16(40116), + 177: uint16(40117), + 178: uint16(40118), + 179: uint16(40119), + 180: uint16(40122), + 181: uint16(40123), + 182: uint16(40124), + 183: uint16(40125), + 184: uint16(40132), + 185: uint16(40133), + 186: uint16(40134), + 187: uint16(40135), + 188: uint16(40138), + 189: uint16(40139), + }, + 118: { + 0: uint16(39996), + 1: uint16(39997), + 2: uint16(39998), + 3: uint16(39999), + 4: uint16(40000), + 5: uint16(40001), + 6: uint16(40002), + 7: uint16(40003), + 8: uint16(40004), + 9: uint16(40005), + 10: uint16(40006), + 11: uint16(40007), + 12: uint16(40008), + 13: uint16(40009), + 14: uint16(40010), + 15: uint16(40011), + 16: uint16(40012), + 17: uint16(40013), + 18: uint16(40014), + 19: uint16(40015), + 20: uint16(40016), + 21: uint16(40017), + 22: uint16(40018), + 23: uint16(40019), + 24: uint16(40020), + 25: uint16(40021), + 26: uint16(40022), + 27: uint16(40023), + 28: uint16(40024), + 29: uint16(40025), + 30: uint16(40026), + 31: uint16(40027), + 32: uint16(40028), + 33: uint16(40029), + 34: uint16(40030), + 35: uint16(40031), + 36: uint16(40032), + 37: uint16(40033), + 38: uint16(40034), + 39: uint16(40035), + 40: uint16(40036), + 41: uint16(40037), + 42: uint16(40038), + 43: uint16(40039), + 44: uint16(40040), + 45: uint16(40041), + 46: uint16(40042), + 47: uint16(40043), + 48: uint16(40044), + 49: uint16(40045), + 50: uint16(40046), + 51: uint16(40047), + 52: uint16(40048), + 53: uint16(40049), + 54: uint16(40050), + 55: uint16(40051), + 56: uint16(40052), + 57: uint16(40053), + 58: uint16(40054), + 59: uint16(40055), + 60: uint16(40056), + 61: uint16(40057), + 62: uint16(40058), + 63: uint16(40059), + 64: uint16(40061), + 65: uint16(40062), + 66: uint16(40064), + 67: uint16(40067), + 68: uint16(40068), + 69: uint16(40073), + 70: uint16(40074), + 71: uint16(40076), + 72: uint16(40079), + 73: uint16(40083), + 74: uint16(40086), + 75: uint16(40087), + 76: uint16(40088), + 77: uint16(40089), + 78: uint16(40093), + 79: uint16(40106), + 80: uint16(40108), + 81: uint16(40111), + 82: uint16(40121), + 83: uint16(40126), + 84: uint16(40127), + 85: uint16(40128), + 86: uint16(40129), + 87: uint16(40130), + 88: uint16(40136), + 89: uint16(40137), + 90: uint16(40145), + 91: uint16(40146), + 92: uint16(40154), + 93: uint16(40155), + 94: uint16(40160), + 95: uint16(40161), + 96: uint16(40140), + 97: uint16(40141), + 98: uint16(40142), + 99: uint16(40143), + 100: uint16(40144), + 101: uint16(40147), + 102: uint16(40148), + 103: uint16(40149), + 104: uint16(40151), + 105: uint16(40152), + 106: uint16(40153), + 107: uint16(40156), + 108: uint16(40157), + 109: uint16(40159), + 110: uint16(40162), + 111: uint16(38780), + 112: uint16(38789), + 113: uint16(38801), + 114: uint16(38802), + 115: uint16(38804), + 116: uint16(38831), + 117: uint16(38827), + 118: uint16(38819), + 119: uint16(38834), + 120: uint16(38836), + 121: uint16(39601), + 122: uint16(39600), + 123: uint16(39607), + 124: uint16(40536), + 125: uint16(39606), + 126: uint16(39610), + 127: uint16(39612), + 128: uint16(39617), + 129: uint16(39616), + 130: uint16(39621), + 131: uint16(39618), + 132: uint16(39627), + 133: uint16(39628), + 134: uint16(39633), + 135: uint16(39749), + 136: uint16(39747), + 137: uint16(39751), + 138: uint16(39753), + 139: uint16(39752), + 140: uint16(39757), + 141: uint16(39761), + 142: uint16(39144), + 143: uint16(39181), + 144: uint16(39214), + 145: uint16(39253), + 146: uint16(39252), + 147: uint16(39647), + 148: uint16(39649), + 149: uint16(39654), + 150: uint16(39663), + 151: uint16(39659), + 152: uint16(39675), + 153: uint16(39661), + 154: uint16(39673), + 155: uint16(39688), + 156: uint16(39695), + 157: uint16(39699), + 158: uint16(39711), + 159: uint16(39715), + 160: uint16(40637), + 161: uint16(40638), + 162: uint16(32315), + 163: uint16(40578), + 164: uint16(40583), + 165: uint16(40584), + 166: uint16(40587), + 167: uint16(40594), + 168: uint16(37846), + 169: uint16(40605), + 170: uint16(40607), + 171: uint16(40667), + 172: uint16(40668), + 173: uint16(40669), + 174: uint16(40672), + 175: uint16(40671), + 176: uint16(40674), + 177: uint16(40681), + 178: uint16(40679), + 179: uint16(40677), + 180: uint16(40682), + 181: uint16(40687), + 182: uint16(40738), + 183: uint16(40748), + 184: uint16(40751), + 185: uint16(40761), + 186: uint16(40759), + 187: uint16(40765), + 188: uint16(40766), + 189: uint16(40772), + }, + 119: { + 0: uint16(40163), + 1: uint16(40164), + 2: uint16(40165), + 3: uint16(40166), + 4: uint16(40167), + 5: uint16(40168), + 6: uint16(40169), + 7: uint16(40170), + 8: uint16(40171), + 9: uint16(40172), + 10: uint16(40173), + 11: uint16(40174), + 12: uint16(40175), + 13: uint16(40176), + 14: uint16(40177), + 15: uint16(40178), + 16: uint16(40179), + 17: uint16(40180), + 18: uint16(40181), + 19: uint16(40182), + 20: uint16(40183), + 21: uint16(40184), + 22: uint16(40185), + 23: uint16(40186), + 24: uint16(40187), + 25: uint16(40188), + 26: uint16(40189), + 27: uint16(40190), + 28: uint16(40191), + 29: uint16(40192), + 30: uint16(40193), + 31: uint16(40194), + 32: uint16(40195), + 33: uint16(40196), + 34: uint16(40197), + 35: uint16(40198), + 36: uint16(40199), + 37: uint16(40200), + 38: uint16(40201), + 39: uint16(40202), + 40: uint16(40203), + 41: uint16(40204), + 42: uint16(40205), + 43: uint16(40206), + 44: uint16(40207), + 45: uint16(40208), + 46: uint16(40209), + 47: uint16(40210), + 48: uint16(40211), + 49: uint16(40212), + 50: uint16(40213), + 51: uint16(40214), + 52: uint16(40215), + 53: uint16(40216), + 54: uint16(40217), + 55: uint16(40218), + 56: uint16(40219), + 57: uint16(40220), + 58: uint16(40221), + 59: uint16(40222), + 60: uint16(40223), + 61: uint16(40224), + 62: uint16(40225), + 63: uint16(40226), + 64: uint16(40227), + 65: uint16(40228), + 66: uint16(40229), + 67: uint16(40230), + 68: uint16(40231), + 69: uint16(40232), + 70: uint16(40233), + 71: uint16(40234), + 72: uint16(40235), + 73: uint16(40236), + 74: uint16(40237), + 75: uint16(40238), + 76: uint16(40239), + 77: uint16(40240), + 78: uint16(40241), + 79: uint16(40242), + 80: uint16(40243), + 81: uint16(40244), + 82: uint16(40245), + 83: uint16(40246), + 84: uint16(40247), + 85: uint16(40248), + 86: uint16(40249), + 87: uint16(40250), + 88: uint16(40251), + 89: uint16(40252), + 90: uint16(40253), + 91: uint16(40254), + 92: uint16(40255), + 93: uint16(40256), + 94: uint16(40257), + 95: uint16(40258), + 96: uint16(57908), + 97: uint16(57909), + 98: uint16(57910), + 99: uint16(57911), + 100: uint16(57912), + 101: uint16(57913), + 102: uint16(57914), + 103: uint16(57915), + 104: uint16(57916), + 105: uint16(57917), + 106: uint16(57918), + 107: uint16(57919), + 108: uint16(57920), + 109: uint16(57921), + 110: uint16(57922), + 111: uint16(57923), + 112: uint16(57924), + 113: uint16(57925), + 114: uint16(57926), + 115: uint16(57927), + 116: uint16(57928), + 117: uint16(57929), + 118: uint16(57930), + 119: uint16(57931), + 120: uint16(57932), + 121: uint16(57933), + 122: uint16(57934), + 123: uint16(57935), + 124: uint16(57936), + 125: uint16(57937), + 126: uint16(57938), + 127: uint16(57939), + 128: uint16(57940), + 129: uint16(57941), + 130: uint16(57942), + 131: uint16(57943), + 132: uint16(57944), + 133: uint16(57945), + 134: uint16(57946), + 135: uint16(57947), + 136: uint16(57948), + 137: uint16(57949), + 138: uint16(57950), + 139: uint16(57951), + 140: uint16(57952), + 141: uint16(57953), + 142: uint16(57954), + 143: uint16(57955), + 144: uint16(57956), + 145: uint16(57957), + 146: uint16(57958), + 147: uint16(57959), + 148: uint16(57960), + 149: uint16(57961), + 150: uint16(57962), + 151: uint16(57963), + 152: uint16(57964), + 153: uint16(57965), + 154: uint16(57966), + 155: uint16(57967), + 156: uint16(57968), + 157: uint16(57969), + 158: uint16(57970), + 159: uint16(57971), + 160: uint16(57972), + 161: uint16(57973), + 162: uint16(57974), + 163: uint16(57975), + 164: uint16(57976), + 165: uint16(57977), + 166: uint16(57978), + 167: uint16(57979), + 168: uint16(57980), + 169: uint16(57981), + 170: uint16(57982), + 171: uint16(57983), + 172: uint16(57984), + 173: uint16(57985), + 174: uint16(57986), + 175: uint16(57987), + 176: uint16(57988), + 177: uint16(57989), + 178: uint16(57990), + 179: uint16(57991), + 180: uint16(57992), + 181: uint16(57993), + 182: uint16(57994), + 183: uint16(57995), + 184: uint16(57996), + 185: uint16(57997), + 186: uint16(57998), + 187: uint16(57999), + 188: uint16(58000), + 189: uint16(58001), + }, + 120: { + 0: uint16(40259), + 1: uint16(40260), + 2: uint16(40261), + 3: uint16(40262), + 4: uint16(40263), + 5: uint16(40264), + 6: uint16(40265), + 7: uint16(40266), + 8: uint16(40267), + 9: uint16(40268), + 10: uint16(40269), + 11: uint16(40270), + 12: uint16(40271), + 13: uint16(40272), + 14: uint16(40273), + 15: uint16(40274), + 16: uint16(40275), + 17: uint16(40276), + 18: uint16(40277), + 19: uint16(40278), + 20: uint16(40279), + 21: uint16(40280), + 22: uint16(40281), + 23: uint16(40282), + 24: uint16(40283), + 25: uint16(40284), + 26: uint16(40285), + 27: uint16(40286), + 28: uint16(40287), + 29: uint16(40288), + 30: uint16(40289), + 31: uint16(40290), + 32: uint16(40291), + 33: uint16(40292), + 34: uint16(40293), + 35: uint16(40294), + 36: uint16(40295), + 37: uint16(40296), + 38: uint16(40297), + 39: uint16(40298), + 40: uint16(40299), + 41: uint16(40300), + 42: uint16(40301), + 43: uint16(40302), + 44: uint16(40303), + 45: uint16(40304), + 46: uint16(40305), + 47: uint16(40306), + 48: uint16(40307), + 49: uint16(40308), + 50: uint16(40309), + 51: uint16(40310), + 52: uint16(40311), + 53: uint16(40312), + 54: uint16(40313), + 55: uint16(40314), + 56: uint16(40315), + 57: uint16(40316), + 58: uint16(40317), + 59: uint16(40318), + 60: uint16(40319), + 61: uint16(40320), + 62: uint16(40321), + 63: uint16(40322), + 64: uint16(40323), + 65: uint16(40324), + 66: uint16(40325), + 67: uint16(40326), + 68: uint16(40327), + 69: uint16(40328), + 70: uint16(40329), + 71: uint16(40330), + 72: uint16(40331), + 73: uint16(40332), + 74: uint16(40333), + 75: uint16(40334), + 76: uint16(40335), + 77: uint16(40336), + 78: uint16(40337), + 79: uint16(40338), + 80: uint16(40339), + 81: uint16(40340), + 82: uint16(40341), + 83: uint16(40342), + 84: uint16(40343), + 85: uint16(40344), + 86: uint16(40345), + 87: uint16(40346), + 88: uint16(40347), + 89: uint16(40348), + 90: uint16(40349), + 91: uint16(40350), + 92: uint16(40351), + 93: uint16(40352), + 94: uint16(40353), + 95: uint16(40354), + 96: uint16(58002), + 97: uint16(58003), + 98: uint16(58004), + 99: uint16(58005), + 100: uint16(58006), + 101: uint16(58007), + 102: uint16(58008), + 103: uint16(58009), + 104: uint16(58010), + 105: uint16(58011), + 106: uint16(58012), + 107: uint16(58013), + 108: uint16(58014), + 109: uint16(58015), + 110: uint16(58016), + 111: uint16(58017), + 112: uint16(58018), + 113: uint16(58019), + 114: uint16(58020), + 115: uint16(58021), + 116: uint16(58022), + 117: uint16(58023), + 118: uint16(58024), + 119: uint16(58025), + 120: uint16(58026), + 121: uint16(58027), + 122: uint16(58028), + 123: uint16(58029), + 124: uint16(58030), + 125: uint16(58031), + 126: uint16(58032), + 127: uint16(58033), + 128: uint16(58034), + 129: uint16(58035), + 130: uint16(58036), + 131: uint16(58037), + 132: uint16(58038), + 133: uint16(58039), + 134: uint16(58040), + 135: uint16(58041), + 136: uint16(58042), + 137: uint16(58043), + 138: uint16(58044), + 139: uint16(58045), + 140: uint16(58046), + 141: uint16(58047), + 142: uint16(58048), + 143: uint16(58049), + 144: uint16(58050), + 145: uint16(58051), + 146: uint16(58052), + 147: uint16(58053), + 148: uint16(58054), + 149: uint16(58055), + 150: uint16(58056), + 151: uint16(58057), + 152: uint16(58058), + 153: uint16(58059), + 154: uint16(58060), + 155: uint16(58061), + 156: uint16(58062), + 157: uint16(58063), + 158: uint16(58064), + 159: uint16(58065), + 160: uint16(58066), + 161: uint16(58067), + 162: uint16(58068), + 163: uint16(58069), + 164: uint16(58070), + 165: uint16(58071), + 166: uint16(58072), + 167: uint16(58073), + 168: uint16(58074), + 169: uint16(58075), + 170: uint16(58076), + 171: uint16(58077), + 172: uint16(58078), + 173: uint16(58079), + 174: uint16(58080), + 175: uint16(58081), + 176: uint16(58082), + 177: uint16(58083), + 178: uint16(58084), + 179: uint16(58085), + 180: uint16(58086), + 181: uint16(58087), + 182: uint16(58088), + 183: uint16(58089), + 184: uint16(58090), + 185: uint16(58091), + 186: uint16(58092), + 187: uint16(58093), + 188: uint16(58094), + 189: uint16(58095), + }, + 121: { + 0: uint16(40355), + 1: uint16(40356), + 2: uint16(40357), + 3: uint16(40358), + 4: uint16(40359), + 5: uint16(40360), + 6: uint16(40361), + 7: uint16(40362), + 8: uint16(40363), + 9: uint16(40364), + 10: uint16(40365), + 11: uint16(40366), + 12: uint16(40367), + 13: uint16(40368), + 14: uint16(40369), + 15: uint16(40370), + 16: uint16(40371), + 17: uint16(40372), + 18: uint16(40373), + 19: uint16(40374), + 20: uint16(40375), + 21: uint16(40376), + 22: uint16(40377), + 23: uint16(40378), + 24: uint16(40379), + 25: uint16(40380), + 26: uint16(40381), + 27: uint16(40382), + 28: uint16(40383), + 29: uint16(40384), + 30: uint16(40385), + 31: uint16(40386), + 32: uint16(40387), + 33: uint16(40388), + 34: uint16(40389), + 35: uint16(40390), + 36: uint16(40391), + 37: uint16(40392), + 38: uint16(40393), + 39: uint16(40394), + 40: uint16(40395), + 41: uint16(40396), + 42: uint16(40397), + 43: uint16(40398), + 44: uint16(40399), + 45: uint16(40400), + 46: uint16(40401), + 47: uint16(40402), + 48: uint16(40403), + 49: uint16(40404), + 50: uint16(40405), + 51: uint16(40406), + 52: uint16(40407), + 53: uint16(40408), + 54: uint16(40409), + 55: uint16(40410), + 56: uint16(40411), + 57: uint16(40412), + 58: uint16(40413), + 59: uint16(40414), + 60: uint16(40415), + 61: uint16(40416), + 62: uint16(40417), + 63: uint16(40418), + 64: uint16(40419), + 65: uint16(40420), + 66: uint16(40421), + 67: uint16(40422), + 68: uint16(40423), + 69: uint16(40424), + 70: uint16(40425), + 71: uint16(40426), + 72: uint16(40427), + 73: uint16(40428), + 74: uint16(40429), + 75: uint16(40430), + 76: uint16(40431), + 77: uint16(40432), + 78: uint16(40433), + 79: uint16(40434), + 80: uint16(40435), + 81: uint16(40436), + 82: uint16(40437), + 83: uint16(40438), + 84: uint16(40439), + 85: uint16(40440), + 86: uint16(40441), + 87: uint16(40442), + 88: uint16(40443), + 89: uint16(40444), + 90: uint16(40445), + 91: uint16(40446), + 92: uint16(40447), + 93: uint16(40448), + 94: uint16(40449), + 95: uint16(40450), + 96: uint16(58096), + 97: uint16(58097), + 98: uint16(58098), + 99: uint16(58099), + 100: uint16(58100), + 101: uint16(58101), + 102: uint16(58102), + 103: uint16(58103), + 104: uint16(58104), + 105: uint16(58105), + 106: uint16(58106), + 107: uint16(58107), + 108: uint16(58108), + 109: uint16(58109), + 110: uint16(58110), + 111: uint16(58111), + 112: uint16(58112), + 113: uint16(58113), + 114: uint16(58114), + 115: uint16(58115), + 116: uint16(58116), + 117: uint16(58117), + 118: uint16(58118), + 119: uint16(58119), + 120: uint16(58120), + 121: uint16(58121), + 122: uint16(58122), + 123: uint16(58123), + 124: uint16(58124), + 125: uint16(58125), + 126: uint16(58126), + 127: uint16(58127), + 128: uint16(58128), + 129: uint16(58129), + 130: uint16(58130), + 131: uint16(58131), + 132: uint16(58132), + 133: uint16(58133), + 134: uint16(58134), + 135: uint16(58135), + 136: uint16(58136), + 137: uint16(58137), + 138: uint16(58138), + 139: uint16(58139), + 140: uint16(58140), + 141: uint16(58141), + 142: uint16(58142), + 143: uint16(58143), + 144: uint16(58144), + 145: uint16(58145), + 146: uint16(58146), + 147: uint16(58147), + 148: uint16(58148), + 149: uint16(58149), + 150: uint16(58150), + 151: uint16(58151), + 152: uint16(58152), + 153: uint16(58153), + 154: uint16(58154), + 155: uint16(58155), + 156: uint16(58156), + 157: uint16(58157), + 158: uint16(58158), + 159: uint16(58159), + 160: uint16(58160), + 161: uint16(58161), + 162: uint16(58162), + 163: uint16(58163), + 164: uint16(58164), + 165: uint16(58165), + 166: uint16(58166), + 167: uint16(58167), + 168: uint16(58168), + 169: uint16(58169), + 170: uint16(58170), + 171: uint16(58171), + 172: uint16(58172), + 173: uint16(58173), + 174: uint16(58174), + 175: uint16(58175), + 176: uint16(58176), + 177: uint16(58177), + 178: uint16(58178), + 179: uint16(58179), + 180: uint16(58180), + 181: uint16(58181), + 182: uint16(58182), + 183: uint16(58183), + 184: uint16(58184), + 185: uint16(58185), + 186: uint16(58186), + 187: uint16(58187), + 188: uint16(58188), + 189: uint16(58189), + }, + 122: { + 0: uint16(40451), + 1: uint16(40452), + 2: uint16(40453), + 3: uint16(40454), + 4: uint16(40455), + 5: uint16(40456), + 6: uint16(40457), + 7: uint16(40458), + 8: uint16(40459), + 9: uint16(40460), + 10: uint16(40461), + 11: uint16(40462), + 12: uint16(40463), + 13: uint16(40464), + 14: uint16(40465), + 15: uint16(40466), + 16: uint16(40467), + 17: uint16(40468), + 18: uint16(40469), + 19: uint16(40470), + 20: uint16(40471), + 21: uint16(40472), + 22: uint16(40473), + 23: uint16(40474), + 24: uint16(40475), + 25: uint16(40476), + 26: uint16(40477), + 27: uint16(40478), + 28: uint16(40484), + 29: uint16(40487), + 30: uint16(40494), + 31: uint16(40496), + 32: uint16(40500), + 33: uint16(40507), + 34: uint16(40508), + 35: uint16(40512), + 36: uint16(40525), + 37: uint16(40528), + 38: uint16(40530), + 39: uint16(40531), + 40: uint16(40532), + 41: uint16(40534), + 42: uint16(40537), + 43: uint16(40541), + 44: uint16(40543), + 45: uint16(40544), + 46: uint16(40545), + 47: uint16(40546), + 48: uint16(40549), + 49: uint16(40558), + 50: uint16(40559), + 51: uint16(40562), + 52: uint16(40564), + 53: uint16(40565), + 54: uint16(40566), + 55: uint16(40567), + 56: uint16(40568), + 57: uint16(40569), + 58: uint16(40570), + 59: uint16(40571), + 60: uint16(40572), + 61: uint16(40573), + 62: uint16(40576), + 63: uint16(40577), + 64: uint16(40579), + 65: uint16(40580), + 66: uint16(40581), + 67: uint16(40582), + 68: uint16(40585), + 69: uint16(40586), + 70: uint16(40588), + 71: uint16(40589), + 72: uint16(40590), + 73: uint16(40591), + 74: uint16(40592), + 75: uint16(40593), + 76: uint16(40596), + 77: uint16(40597), + 78: uint16(40598), + 79: uint16(40599), + 80: uint16(40600), + 81: uint16(40601), + 82: uint16(40602), + 83: uint16(40603), + 84: uint16(40604), + 85: uint16(40606), + 86: uint16(40608), + 87: uint16(40609), + 88: uint16(40610), + 89: uint16(40611), + 90: uint16(40612), + 91: uint16(40613), + 92: uint16(40615), + 93: uint16(40616), + 94: uint16(40617), + 95: uint16(40618), + 96: uint16(58190), + 97: uint16(58191), + 98: uint16(58192), + 99: uint16(58193), + 100: uint16(58194), + 101: uint16(58195), + 102: uint16(58196), + 103: uint16(58197), + 104: uint16(58198), + 105: uint16(58199), + 106: uint16(58200), + 107: uint16(58201), + 108: uint16(58202), + 109: uint16(58203), + 110: uint16(58204), + 111: uint16(58205), + 112: uint16(58206), + 113: uint16(58207), + 114: uint16(58208), + 115: uint16(58209), + 116: uint16(58210), + 117: uint16(58211), + 118: uint16(58212), + 119: uint16(58213), + 120: uint16(58214), + 121: uint16(58215), + 122: uint16(58216), + 123: uint16(58217), + 124: uint16(58218), + 125: uint16(58219), + 126: uint16(58220), + 127: uint16(58221), + 128: uint16(58222), + 129: uint16(58223), + 130: uint16(58224), + 131: uint16(58225), + 132: uint16(58226), + 133: uint16(58227), + 134: uint16(58228), + 135: uint16(58229), + 136: uint16(58230), + 137: uint16(58231), + 138: uint16(58232), + 139: uint16(58233), + 140: uint16(58234), + 141: uint16(58235), + 142: uint16(58236), + 143: uint16(58237), + 144: uint16(58238), + 145: uint16(58239), + 146: uint16(58240), + 147: uint16(58241), + 148: uint16(58242), + 149: uint16(58243), + 150: uint16(58244), + 151: uint16(58245), + 152: uint16(58246), + 153: uint16(58247), + 154: uint16(58248), + 155: uint16(58249), + 156: uint16(58250), + 157: uint16(58251), + 158: uint16(58252), + 159: uint16(58253), + 160: uint16(58254), + 161: uint16(58255), + 162: uint16(58256), + 163: uint16(58257), + 164: uint16(58258), + 165: uint16(58259), + 166: uint16(58260), + 167: uint16(58261), + 168: uint16(58262), + 169: uint16(58263), + 170: uint16(58264), + 171: uint16(58265), + 172: uint16(58266), + 173: uint16(58267), + 174: uint16(58268), + 175: uint16(58269), + 176: uint16(58270), + 177: uint16(58271), + 178: uint16(58272), + 179: uint16(58273), + 180: uint16(58274), + 181: uint16(58275), + 182: uint16(58276), + 183: uint16(58277), + 184: uint16(58278), + 185: uint16(58279), + 186: uint16(58280), + 187: uint16(58281), + 188: uint16(58282), + 189: uint16(58283), + }, + 123: { + 0: uint16(40619), + 1: uint16(40620), + 2: uint16(40621), + 3: uint16(40622), + 4: uint16(40623), + 5: uint16(40624), + 6: uint16(40625), + 7: uint16(40626), + 8: uint16(40627), + 9: uint16(40629), + 10: uint16(40630), + 11: uint16(40631), + 12: uint16(40633), + 13: uint16(40634), + 14: uint16(40636), + 15: uint16(40639), + 16: uint16(40640), + 17: uint16(40641), + 18: uint16(40642), + 19: uint16(40643), + 20: uint16(40645), + 21: uint16(40646), + 22: uint16(40647), + 23: uint16(40648), + 24: uint16(40650), + 25: uint16(40651), + 26: uint16(40652), + 27: uint16(40656), + 28: uint16(40658), + 29: uint16(40659), + 30: uint16(40661), + 31: uint16(40662), + 32: uint16(40663), + 33: uint16(40665), + 34: uint16(40666), + 35: uint16(40670), + 36: uint16(40673), + 37: uint16(40675), + 38: uint16(40676), + 39: uint16(40678), + 40: uint16(40680), + 41: uint16(40683), + 42: uint16(40684), + 43: uint16(40685), + 44: uint16(40686), + 45: uint16(40688), + 46: uint16(40689), + 47: uint16(40690), + 48: uint16(40691), + 49: uint16(40692), + 50: uint16(40693), + 51: uint16(40694), + 52: uint16(40695), + 53: uint16(40696), + 54: uint16(40698), + 55: uint16(40701), + 56: uint16(40703), + 57: uint16(40704), + 58: uint16(40705), + 59: uint16(40706), + 60: uint16(40707), + 61: uint16(40708), + 62: uint16(40709), + 63: uint16(40710), + 64: uint16(40711), + 65: uint16(40712), + 66: uint16(40713), + 67: uint16(40714), + 68: uint16(40716), + 69: uint16(40719), + 70: uint16(40721), + 71: uint16(40722), + 72: uint16(40724), + 73: uint16(40725), + 74: uint16(40726), + 75: uint16(40728), + 76: uint16(40730), + 77: uint16(40731), + 78: uint16(40732), + 79: uint16(40733), + 80: uint16(40734), + 81: uint16(40735), + 82: uint16(40737), + 83: uint16(40739), + 84: uint16(40740), + 85: uint16(40741), + 86: uint16(40742), + 87: uint16(40743), + 88: uint16(40744), + 89: uint16(40745), + 90: uint16(40746), + 91: uint16(40747), + 92: uint16(40749), + 93: uint16(40750), + 94: uint16(40752), + 95: uint16(40753), + 96: uint16(58284), + 97: uint16(58285), + 98: uint16(58286), + 99: uint16(58287), + 100: uint16(58288), + 101: uint16(58289), + 102: uint16(58290), + 103: uint16(58291), + 104: uint16(58292), + 105: uint16(58293), + 106: uint16(58294), + 107: uint16(58295), + 108: uint16(58296), + 109: uint16(58297), + 110: uint16(58298), + 111: uint16(58299), + 112: uint16(58300), + 113: uint16(58301), + 114: uint16(58302), + 115: uint16(58303), + 116: uint16(58304), + 117: uint16(58305), + 118: uint16(58306), + 119: uint16(58307), + 120: uint16(58308), + 121: uint16(58309), + 122: uint16(58310), + 123: uint16(58311), + 124: uint16(58312), + 125: uint16(58313), + 126: uint16(58314), + 127: uint16(58315), + 128: uint16(58316), + 129: uint16(58317), + 130: uint16(58318), + 131: uint16(58319), + 132: uint16(58320), + 133: uint16(58321), + 134: uint16(58322), + 135: uint16(58323), + 136: uint16(58324), + 137: uint16(58325), + 138: uint16(58326), + 139: uint16(58327), + 140: uint16(58328), + 141: uint16(58329), + 142: uint16(58330), + 143: uint16(58331), + 144: uint16(58332), + 145: uint16(58333), + 146: uint16(58334), + 147: uint16(58335), + 148: uint16(58336), + 149: uint16(58337), + 150: uint16(58338), + 151: uint16(58339), + 152: uint16(58340), + 153: uint16(58341), + 154: uint16(58342), + 155: uint16(58343), + 156: uint16(58344), + 157: uint16(58345), + 158: uint16(58346), + 159: uint16(58347), + 160: uint16(58348), + 161: uint16(58349), + 162: uint16(58350), + 163: uint16(58351), + 164: uint16(58352), + 165: uint16(58353), + 166: uint16(58354), + 167: uint16(58355), + 168: uint16(58356), + 169: uint16(58357), + 170: uint16(58358), + 171: uint16(58359), + 172: uint16(58360), + 173: uint16(58361), + 174: uint16(58362), + 175: uint16(58363), + 176: uint16(58364), + 177: uint16(58365), + 178: uint16(58366), + 179: uint16(58367), + 180: uint16(58368), + 181: uint16(58369), + 182: uint16(58370), + 183: uint16(58371), + 184: uint16(58372), + 185: uint16(58373), + 186: uint16(58374), + 187: uint16(58375), + 188: uint16(58376), + 189: uint16(58377), + }, + 124: { + 0: uint16(40754), + 1: uint16(40755), + 2: uint16(40756), + 3: uint16(40757), + 4: uint16(40758), + 5: uint16(40760), + 6: uint16(40762), + 7: uint16(40764), + 8: uint16(40767), + 9: uint16(40768), + 10: uint16(40769), + 11: uint16(40770), + 12: uint16(40771), + 13: uint16(40773), + 14: uint16(40774), + 15: uint16(40775), + 16: uint16(40776), + 17: uint16(40777), + 18: uint16(40778), + 19: uint16(40779), + 20: uint16(40780), + 21: uint16(40781), + 22: uint16(40782), + 23: uint16(40783), + 24: uint16(40786), + 25: uint16(40787), + 26: uint16(40788), + 27: uint16(40789), + 28: uint16(40790), + 29: uint16(40791), + 30: uint16(40792), + 31: uint16(40793), + 32: uint16(40794), + 33: uint16(40795), + 34: uint16(40796), + 35: uint16(40797), + 36: uint16(40798), + 37: uint16(40799), + 38: uint16(40800), + 39: uint16(40801), + 40: uint16(40802), + 41: uint16(40803), + 42: uint16(40804), + 43: uint16(40805), + 44: uint16(40806), + 45: uint16(40807), + 46: uint16(40808), + 47: uint16(40809), + 48: uint16(40810), + 49: uint16(40811), + 50: uint16(40812), + 51: uint16(40813), + 52: uint16(40814), + 53: uint16(40815), + 54: uint16(40816), + 55: uint16(40817), + 56: uint16(40818), + 57: uint16(40819), + 58: uint16(40820), + 59: uint16(40821), + 60: uint16(40822), + 61: uint16(40823), + 62: uint16(40824), + 63: uint16(40825), + 64: uint16(40826), + 65: uint16(40827), + 66: uint16(40828), + 67: uint16(40829), + 68: uint16(40830), + 69: uint16(40833), + 70: uint16(40834), + 71: uint16(40845), + 72: uint16(40846), + 73: uint16(40847), + 74: uint16(40848), + 75: uint16(40849), + 76: uint16(40850), + 77: uint16(40851), + 78: uint16(40852), + 79: uint16(40853), + 80: uint16(40854), + 81: uint16(40855), + 82: uint16(40856), + 83: uint16(40860), + 84: uint16(40861), + 85: uint16(40862), + 86: uint16(40865), + 87: uint16(40866), + 88: uint16(40867), + 89: uint16(40868), + 90: uint16(40869), + 91: uint16(63788), + 92: uint16(63865), + 93: uint16(63893), + 94: uint16(63975), + 95: uint16(63985), + 96: uint16(58378), + 97: uint16(58379), + 98: uint16(58380), + 99: uint16(58381), + 100: uint16(58382), + 101: uint16(58383), + 102: uint16(58384), + 103: uint16(58385), + 104: uint16(58386), + 105: uint16(58387), + 106: uint16(58388), + 107: uint16(58389), + 108: uint16(58390), + 109: uint16(58391), + 110: uint16(58392), + 111: uint16(58393), + 112: uint16(58394), + 113: uint16(58395), + 114: uint16(58396), + 115: uint16(58397), + 116: uint16(58398), + 117: uint16(58399), + 118: uint16(58400), + 119: uint16(58401), + 120: uint16(58402), + 121: uint16(58403), + 122: uint16(58404), + 123: uint16(58405), + 124: uint16(58406), + 125: uint16(58407), + 126: uint16(58408), + 127: uint16(58409), + 128: uint16(58410), + 129: uint16(58411), + 130: uint16(58412), + 131: uint16(58413), + 132: uint16(58414), + 133: uint16(58415), + 134: uint16(58416), + 135: uint16(58417), + 136: uint16(58418), + 137: uint16(58419), + 138: uint16(58420), + 139: uint16(58421), + 140: uint16(58422), + 141: uint16(58423), + 142: uint16(58424), + 143: uint16(58425), + 144: uint16(58426), + 145: uint16(58427), + 146: uint16(58428), + 147: uint16(58429), + 148: uint16(58430), + 149: uint16(58431), + 150: uint16(58432), + 151: uint16(58433), + 152: uint16(58434), + 153: uint16(58435), + 154: uint16(58436), + 155: uint16(58437), + 156: uint16(58438), + 157: uint16(58439), + 158: uint16(58440), + 159: uint16(58441), + 160: uint16(58442), + 161: uint16(58443), + 162: uint16(58444), + 163: uint16(58445), + 164: uint16(58446), + 165: uint16(58447), + 166: uint16(58448), + 167: uint16(58449), + 168: uint16(58450), + 169: uint16(58451), + 170: uint16(58452), + 171: uint16(58453), + 172: uint16(58454), + 173: uint16(58455), + 174: uint16(58456), + 175: uint16(58457), + 176: uint16(58458), + 177: uint16(58459), + 178: uint16(58460), + 179: uint16(58461), + 180: uint16(58462), + 181: uint16(58463), + 182: uint16(58464), + 183: uint16(58465), + 184: uint16(58466), + 185: uint16(58467), + 186: uint16(58468), + 187: uint16(58469), + 188: uint16(58470), + 189: uint16(58471), + }, + 125: { + 0: uint16(64012), + 1: uint16(64013), + 2: uint16(64014), + 3: uint16(64015), + 4: uint16(64017), + 5: uint16(64019), + 6: uint16(64020), + 7: uint16(64024), + 8: uint16(64031), + 9: uint16(64032), + 10: uint16(64033), + 11: uint16(64035), + 12: uint16(64036), + 13: uint16(64039), + 14: uint16(64040), + 15: uint16(64041), + 16: uint16(11905), + 17: uint16(59414), + 18: uint16(59415), + 19: uint16(59416), + 20: uint16(11908), + 21: uint16(13427), + 22: uint16(13383), + 23: uint16(11912), + 24: uint16(11915), + 25: uint16(59422), + 26: uint16(13726), + 27: uint16(13850), + 28: uint16(13838), + 29: uint16(11916), + 30: uint16(11927), + 31: uint16(14702), + 32: uint16(14616), + 33: uint16(59430), + 34: uint16(14799), + 35: uint16(14815), + 36: uint16(14963), + 37: uint16(14800), + 38: uint16(59435), + 39: uint16(59436), + 40: uint16(15182), + 41: uint16(15470), + 42: uint16(15584), + 43: uint16(11943), + 44: uint16(59441), + 45: uint16(59442), + 46: uint16(11946), + 47: uint16(16470), + 48: uint16(16735), + 49: uint16(11950), + 50: uint16(17207), + 51: uint16(11955), + 52: uint16(11958), + 53: uint16(11959), + 54: uint16(59451), + 55: uint16(17329), + 56: uint16(17324), + 57: uint16(11963), + 58: uint16(17373), + 59: uint16(17622), + 60: uint16(18017), + 61: uint16(17996), + 62: uint16(59459), + 63: uint16(18211), + 64: uint16(18217), + 65: uint16(18300), + 66: uint16(18317), + 67: uint16(11978), + 68: uint16(18759), + 69: uint16(18810), + 70: uint16(18813), + 71: uint16(18818), + 72: uint16(18819), + 73: uint16(18821), + 74: uint16(18822), + 75: uint16(18847), + 76: uint16(18843), + 77: uint16(18871), + 78: uint16(18870), + 79: uint16(59476), + 80: uint16(59477), + 81: uint16(19619), + 82: uint16(19615), + 83: uint16(19616), + 84: uint16(19617), + 85: uint16(19575), + 86: uint16(19618), + 87: uint16(19731), + 88: uint16(19732), + 89: uint16(19733), + 90: uint16(19734), + 91: uint16(19735), + 92: uint16(19736), + 93: uint16(19737), + 94: uint16(19886), + 95: uint16(59492), + 96: uint16(58472), + 97: uint16(58473), + 98: uint16(58474), + 99: uint16(58475), + 100: uint16(58476), + 101: uint16(58477), + 102: uint16(58478), + 103: uint16(58479), + 104: uint16(58480), + 105: uint16(58481), + 106: uint16(58482), + 107: uint16(58483), + 108: uint16(58484), + 109: uint16(58485), + 110: uint16(58486), + 111: uint16(58487), + 112: uint16(58488), + 113: uint16(58489), + 114: uint16(58490), + 115: uint16(58491), + 116: uint16(58492), + 117: uint16(58493), + 118: uint16(58494), + 119: uint16(58495), + 120: uint16(58496), + 121: uint16(58497), + 122: uint16(58498), + 123: uint16(58499), + 124: uint16(58500), + 125: uint16(58501), + 126: uint16(58502), + 127: uint16(58503), + 128: uint16(58504), + 129: uint16(58505), + 130: uint16(58506), + 131: uint16(58507), + 132: uint16(58508), + 133: uint16(58509), + 134: uint16(58510), + 135: uint16(58511), + 136: uint16(58512), + 137: uint16(58513), + 138: uint16(58514), + 139: uint16(58515), + 140: uint16(58516), + 141: uint16(58517), + 142: uint16(58518), + 143: uint16(58519), + 144: uint16(58520), + 145: uint16(58521), + 146: uint16(58522), + 147: uint16(58523), + 148: uint16(58524), + 149: uint16(58525), + 150: uint16(58526), + 151: uint16(58527), + 152: uint16(58528), + 153: uint16(58529), + 154: uint16(58530), + 155: uint16(58531), + 156: uint16(58532), + 157: uint16(58533), + 158: uint16(58534), + 159: uint16(58535), + 160: uint16(58536), + 161: uint16(58537), + 162: uint16(58538), + 163: uint16(58539), + 164: uint16(58540), + 165: uint16(58541), + 166: uint16(58542), + 167: uint16(58543), + 168: uint16(58544), + 169: uint16(58545), + 170: uint16(58546), + 171: uint16(58547), + 172: uint16(58548), + 173: uint16(58549), + 174: uint16(58550), + 175: uint16(58551), + 176: uint16(58552), + 177: uint16(58553), + 178: uint16(58554), + 179: uint16(58555), + 180: uint16(58556), + 181: uint16(58557), + 182: uint16(58558), + 183: uint16(58559), + 184: uint16(58560), + 185: uint16(58561), + 186: uint16(58562), + 187: uint16(58563), + 188: uint16(58564), + 189: uint16(58565), + }, +} + +var _big5 = [89][157]uint16{ + 0: { + 0: uint16(12288), + 1: uint16(65292), + 2: uint16(12289), + 3: uint16(12290), + 4: uint16(65294), + 5: uint16(8231), + 6: uint16(65307), + 7: uint16(65306), + 8: uint16(65311), + 9: uint16(65281), + 10: uint16(65072), + 11: uint16(8230), + 12: uint16(8229), + 13: uint16(65104), + 14: uint16(65105), + 15: uint16(65106), + 16: uint16(183), + 17: uint16(65108), + 18: uint16(65109), + 19: uint16(65110), + 20: uint16(65111), + 21: uint16(65372), + 22: uint16(8211), + 23: uint16(65073), + 24: uint16(8212), + 25: uint16(65075), + 26: uint16(9588), + 27: uint16(65076), + 28: uint16(65103), + 29: uint16(65288), + 30: uint16(65289), + 31: uint16(65077), + 32: uint16(65078), + 33: uint16(65371), + 34: uint16(65373), + 35: uint16(65079), + 36: uint16(65080), + 37: uint16(12308), + 38: uint16(12309), + 39: uint16(65081), + 40: uint16(65082), + 41: uint16(12304), + 42: uint16(12305), + 43: uint16(65083), + 44: uint16(65084), + 45: uint16(12298), + 46: uint16(12299), + 47: uint16(65085), + 48: uint16(65086), + 49: uint16(12296), + 50: uint16(12297), + 51: uint16(65087), + 52: uint16(65088), + 53: uint16(12300), + 54: uint16(12301), + 55: uint16(65089), + 56: uint16(65090), + 57: uint16(12302), + 58: uint16(12303), + 59: uint16(65091), + 60: uint16(65092), + 61: uint16(65113), + 62: uint16(65114), + 63: uint16(65115), + 64: uint16(65116), + 65: uint16(65117), + 66: uint16(65118), + 67: uint16(8216), + 68: uint16(8217), + 69: uint16(8220), + 70: uint16(8221), + 71: uint16(12317), + 72: uint16(12318), + 73: uint16(8245), + 74: uint16(8242), + 75: uint16(65283), + 76: uint16(65286), + 77: uint16(65290), + 78: uint16(8251), + 79: uint16(167), + 80: uint16(12291), + 81: uint16(9675), + 82: uint16(9679), + 83: uint16(9651), + 84: uint16(9650), + 85: uint16(9678), + 86: uint16(9734), + 87: uint16(9733), + 88: uint16(9671), + 89: uint16(9670), + 90: uint16(9633), + 91: uint16(9632), + 92: uint16(9661), + 93: uint16(9660), + 94: uint16(12963), + 95: uint16(8453), + 96: uint16(175), + 97: uint16(65507), + 98: uint16(65343), + 99: uint16(717), + 100: uint16(65097), + 101: uint16(65098), + 102: uint16(65101), + 103: uint16(65102), + 104: uint16(65099), + 105: uint16(65100), + 106: uint16(65119), + 107: uint16(65120), + 108: uint16(65121), + 109: uint16(65291), + 110: uint16(65293), + 111: uint16(215), + 112: uint16(247), + 113: uint16(177), + 114: uint16(8730), + 115: uint16(65308), + 116: uint16(65310), + 117: uint16(65309), + 118: uint16(8806), + 119: uint16(8807), + 120: uint16(8800), + 121: uint16(8734), + 122: uint16(8786), + 123: uint16(8801), + 124: uint16(65122), + 125: uint16(65123), + 126: uint16(65124), + 127: uint16(65125), + 128: uint16(65126), + 129: uint16(65374), + 130: uint16(8745), + 131: uint16(8746), + 132: uint16(8869), + 133: uint16(8736), + 134: uint16(8735), + 135: uint16(8895), + 136: uint16(13266), + 137: uint16(13265), + 138: uint16(8747), + 139: uint16(8750), + 140: uint16(8757), + 141: uint16(8756), + 142: uint16(9792), + 143: uint16(9794), + 144: uint16(8853), + 145: uint16(8857), + 146: uint16(8593), + 147: uint16(8595), + 148: uint16(8592), + 149: uint16(8594), + 150: uint16(8598), + 151: uint16(8599), + 152: uint16(8601), + 153: uint16(8600), + 154: uint16(8741), + 155: uint16(8739), + 156: uint16(65295), + }, + 1: { + 0: uint16(65340), + 1: uint16(8725), + 2: uint16(65128), + 3: uint16(65284), + 4: uint16(65509), + 5: uint16(12306), + 6: uint16(65504), + 7: uint16(65505), + 8: uint16(65285), + 9: uint16(65312), + 10: uint16(8451), + 11: uint16(8457), + 12: uint16(65129), + 13: uint16(65130), + 14: uint16(65131), + 15: uint16(13269), + 16: uint16(13212), + 17: uint16(13213), + 18: uint16(13214), + 19: uint16(13262), + 20: uint16(13217), + 21: uint16(13198), + 22: uint16(13199), + 23: uint16(13252), + 24: uint16(176), + 25: uint16(20825), + 26: uint16(20827), + 27: uint16(20830), + 28: uint16(20829), + 29: uint16(20833), + 30: uint16(20835), + 31: uint16(21991), + 32: uint16(29929), + 33: uint16(31950), + 34: uint16(9601), + 35: uint16(9602), + 36: uint16(9603), + 37: uint16(9604), + 38: uint16(9605), + 39: uint16(9606), + 40: uint16(9607), + 41: uint16(9608), + 42: uint16(9615), + 43: uint16(9614), + 44: uint16(9613), + 45: uint16(9612), + 46: uint16(9611), + 47: uint16(9610), + 48: uint16(9609), + 49: uint16(9532), + 50: uint16(9524), + 51: uint16(9516), + 52: uint16(9508), + 53: uint16(9500), + 54: uint16(9620), + 55: uint16(9472), + 56: uint16(9474), + 57: uint16(9621), + 58: uint16(9484), + 59: uint16(9488), + 60: uint16(9492), + 61: uint16(9496), + 62: uint16(9581), + 63: uint16(9582), + 64: uint16(9584), + 65: uint16(9583), + 66: uint16(9552), + 67: uint16(9566), + 68: uint16(9578), + 69: uint16(9569), + 70: uint16(9698), + 71: uint16(9699), + 72: uint16(9701), + 73: uint16(9700), + 74: uint16(9585), + 75: uint16(9586), + 76: uint16(9587), + 77: uint16(65296), + 78: uint16(65297), + 79: uint16(65298), + 80: uint16(65299), + 81: uint16(65300), + 82: uint16(65301), + 83: uint16(65302), + 84: uint16(65303), + 85: uint16(65304), + 86: uint16(65305), + 87: uint16(8544), + 88: uint16(8545), + 89: uint16(8546), + 90: uint16(8547), + 91: uint16(8548), + 92: uint16(8549), + 93: uint16(8550), + 94: uint16(8551), + 95: uint16(8552), + 96: uint16(8553), + 97: uint16(12321), + 98: uint16(12322), + 99: uint16(12323), + 100: uint16(12324), + 101: uint16(12325), + 102: uint16(12326), + 103: uint16(12327), + 104: uint16(12328), + 105: uint16(12329), + 106: uint16(21313), + 107: uint16(21316), + 108: uint16(21317), + 109: uint16(65313), + 110: uint16(65314), + 111: uint16(65315), + 112: uint16(65316), + 113: uint16(65317), + 114: uint16(65318), + 115: uint16(65319), + 116: uint16(65320), + 117: uint16(65321), + 118: uint16(65322), + 119: uint16(65323), + 120: uint16(65324), + 121: uint16(65325), + 122: uint16(65326), + 123: uint16(65327), + 124: uint16(65328), + 125: uint16(65329), + 126: uint16(65330), + 127: uint16(65331), + 128: uint16(65332), + 129: uint16(65333), + 130: uint16(65334), + 131: uint16(65335), + 132: uint16(65336), + 133: uint16(65337), + 134: uint16(65338), + 135: uint16(65345), + 136: uint16(65346), + 137: uint16(65347), + 138: uint16(65348), + 139: uint16(65349), + 140: uint16(65350), + 141: uint16(65351), + 142: uint16(65352), + 143: uint16(65353), + 144: uint16(65354), + 145: uint16(65355), + 146: uint16(65356), + 147: uint16(65357), + 148: uint16(65358), + 149: uint16(65359), + 150: uint16(65360), + 151: uint16(65361), + 152: uint16(65362), + 153: uint16(65363), + 154: uint16(65364), + 155: uint16(65365), + 156: uint16(65366), + }, + 2: { + 0: uint16(65367), + 1: uint16(65368), + 2: uint16(65369), + 3: uint16(65370), + 4: uint16(913), + 5: uint16(914), + 6: uint16(915), + 7: uint16(916), + 8: uint16(917), + 9: uint16(918), + 10: uint16(919), + 11: uint16(920), + 12: uint16(921), + 13: uint16(922), + 14: uint16(923), + 15: uint16(924), + 16: uint16(925), + 17: uint16(926), + 18: uint16(927), + 19: uint16(928), + 20: uint16(929), + 21: uint16(931), + 22: uint16(932), + 23: uint16(933), + 24: uint16(934), + 25: uint16(935), + 26: uint16(936), + 27: uint16(937), + 28: uint16(945), + 29: uint16(946), + 30: uint16(947), + 31: uint16(948), + 32: uint16(949), + 33: uint16(950), + 34: uint16(951), + 35: uint16(952), + 36: uint16(953), + 37: uint16(954), + 38: uint16(955), + 39: uint16(956), + 40: uint16(957), + 41: uint16(958), + 42: uint16(959), + 43: uint16(960), + 44: uint16(961), + 45: uint16(963), + 46: uint16(964), + 47: uint16(965), + 48: uint16(966), + 49: uint16(967), + 50: uint16(968), + 51: uint16(969), + 52: uint16(12549), + 53: uint16(12550), + 54: uint16(12551), + 55: uint16(12552), + 56: uint16(12553), + 57: uint16(12554), + 58: uint16(12555), + 59: uint16(12556), + 60: uint16(12557), + 61: uint16(12558), + 62: uint16(12559), + 63: uint16(12560), + 64: uint16(12561), + 65: uint16(12562), + 66: uint16(12563), + 67: uint16(12564), + 68: uint16(12565), + 69: uint16(12566), + 70: uint16(12567), + 71: uint16(12568), + 72: uint16(12569), + 73: uint16(12570), + 74: uint16(12571), + 75: uint16(12572), + 76: uint16(12573), + 77: uint16(12574), + 78: uint16(12575), + 79: uint16(12576), + 80: uint16(12577), + 81: uint16(12578), + 82: uint16(12579), + 83: uint16(12580), + 84: uint16(12581), + 85: uint16(12582), + 86: uint16(12583), + 87: uint16(12584), + 88: uint16(12585), + 89: uint16(729), + 90: uint16(713), + 91: uint16(714), + 92: uint16(711), + 93: uint16(715), + 94: uint16(9216), + 95: uint16(9217), + 96: uint16(9218), + 97: uint16(9219), + 98: uint16(9220), + 99: uint16(9221), + 100: uint16(9222), + 101: uint16(9223), + 102: uint16(9224), + 103: uint16(9225), + 104: uint16(9226), + 105: uint16(9227), + 106: uint16(9228), + 107: uint16(9229), + 108: uint16(9230), + 109: uint16(9231), + 110: uint16(9232), + 111: uint16(9233), + 112: uint16(9234), + 113: uint16(9235), + 114: uint16(9236), + 115: uint16(9237), + 116: uint16(9238), + 117: uint16(9239), + 118: uint16(9240), + 119: uint16(9241), + 120: uint16(9242), + 121: uint16(9243), + 122: uint16(9244), + 123: uint16(9245), + 124: uint16(9246), + 125: uint16(9247), + 126: uint16(9249), + 127: uint16(8364), + }, + 3: { + 0: uint16(19968), + 1: uint16(20057), + 2: uint16(19969), + 3: uint16(19971), + 4: uint16(20035), + 5: uint16(20061), + 6: uint16(20102), + 7: uint16(20108), + 8: uint16(20154), + 9: uint16(20799), + 10: uint16(20837), + 11: uint16(20843), + 12: uint16(20960), + 13: uint16(20992), + 14: uint16(20993), + 15: uint16(21147), + 16: uint16(21269), + 17: uint16(21313), + 18: uint16(21340), + 19: uint16(21448), + 20: uint16(19977), + 21: uint16(19979), + 22: uint16(19976), + 23: uint16(19978), + 24: uint16(20011), + 25: uint16(20024), + 26: uint16(20961), + 27: uint16(20037), + 28: uint16(20040), + 29: uint16(20063), + 30: uint16(20062), + 31: uint16(20110), + 32: uint16(20129), + 33: uint16(20800), + 34: uint16(20995), + 35: uint16(21242), + 36: uint16(21315), + 37: uint16(21449), + 38: uint16(21475), + 39: uint16(22303), + 40: uint16(22763), + 41: uint16(22805), + 42: uint16(22823), + 43: uint16(22899), + 44: uint16(23376), + 45: uint16(23377), + 46: uint16(23379), + 47: uint16(23544), + 48: uint16(23567), + 49: uint16(23586), + 50: uint16(23608), + 51: uint16(23665), + 52: uint16(24029), + 53: uint16(24037), + 54: uint16(24049), + 55: uint16(24050), + 56: uint16(24051), + 57: uint16(24062), + 58: uint16(24178), + 59: uint16(24318), + 60: uint16(24331), + 61: uint16(24339), + 62: uint16(25165), + 63: uint16(19985), + 64: uint16(19984), + 65: uint16(19981), + 66: uint16(20013), + 67: uint16(20016), + 68: uint16(20025), + 69: uint16(20043), + 70: uint16(23609), + 71: uint16(20104), + 72: uint16(20113), + 73: uint16(20117), + 74: uint16(20114), + 75: uint16(20116), + 76: uint16(20130), + 77: uint16(20161), + 78: uint16(20160), + 79: uint16(20163), + 80: uint16(20166), + 81: uint16(20167), + 82: uint16(20173), + 83: uint16(20170), + 84: uint16(20171), + 85: uint16(20164), + 86: uint16(20803), + 87: uint16(20801), + 88: uint16(20839), + 89: uint16(20845), + 90: uint16(20846), + 91: uint16(20844), + 92: uint16(20887), + 93: uint16(20982), + 94: uint16(20998), + 95: uint16(20999), + 96: uint16(21000), + 97: uint16(21243), + 98: uint16(21246), + 99: uint16(21247), + 100: uint16(21270), + 101: uint16(21305), + 102: uint16(21320), + 103: uint16(21319), + 104: uint16(21317), + 105: uint16(21342), + 106: uint16(21380), + 107: uint16(21451), + 108: uint16(21450), + 109: uint16(21453), + 110: uint16(22764), + 111: uint16(22825), + 112: uint16(22827), + 113: uint16(22826), + 114: uint16(22829), + 115: uint16(23380), + 116: uint16(23569), + 117: uint16(23588), + 118: uint16(23610), + 119: uint16(23663), + 120: uint16(24052), + 121: uint16(24187), + 122: uint16(24319), + 123: uint16(24340), + 124: uint16(24341), + 125: uint16(24515), + 126: uint16(25096), + 127: uint16(25142), + 128: uint16(25163), + 129: uint16(25166), + 130: uint16(25903), + 131: uint16(25991), + 132: uint16(26007), + 133: uint16(26020), + 134: uint16(26041), + 135: uint16(26085), + 136: uint16(26352), + 137: uint16(26376), + 138: uint16(26408), + 139: uint16(27424), + 140: uint16(27490), + 141: uint16(27513), + 142: uint16(27595), + 143: uint16(27604), + 144: uint16(27611), + 145: uint16(27663), + 146: uint16(27700), + 147: uint16(28779), + 148: uint16(29226), + 149: uint16(29238), + 150: uint16(29243), + 151: uint16(29255), + 152: uint16(29273), + 153: uint16(29275), + 154: uint16(29356), + 155: uint16(29579), + 156: uint16(19993), + }, + 4: { + 0: uint16(19990), + 1: uint16(19989), + 2: uint16(19988), + 3: uint16(19992), + 4: uint16(20027), + 5: uint16(20045), + 6: uint16(20047), + 7: uint16(20046), + 8: uint16(20197), + 9: uint16(20184), + 10: uint16(20180), + 11: uint16(20181), + 12: uint16(20182), + 13: uint16(20183), + 14: uint16(20195), + 15: uint16(20196), + 16: uint16(20185), + 17: uint16(20190), + 18: uint16(20805), + 19: uint16(20804), + 20: uint16(20873), + 21: uint16(20874), + 22: uint16(20908), + 23: uint16(20985), + 24: uint16(20986), + 25: uint16(20984), + 26: uint16(21002), + 27: uint16(21152), + 28: uint16(21151), + 29: uint16(21253), + 30: uint16(21254), + 31: uint16(21271), + 32: uint16(21277), + 33: uint16(20191), + 34: uint16(21322), + 35: uint16(21321), + 36: uint16(21345), + 37: uint16(21344), + 38: uint16(21359), + 39: uint16(21358), + 40: uint16(21435), + 41: uint16(21487), + 42: uint16(21476), + 43: uint16(21491), + 44: uint16(21484), + 45: uint16(21486), + 46: uint16(21481), + 47: uint16(21480), + 48: uint16(21500), + 49: uint16(21496), + 50: uint16(21493), + 51: uint16(21483), + 52: uint16(21478), + 53: uint16(21482), + 54: uint16(21490), + 55: uint16(21489), + 56: uint16(21488), + 57: uint16(21477), + 58: uint16(21485), + 59: uint16(21499), + 60: uint16(22235), + 61: uint16(22234), + 62: uint16(22806), + 63: uint16(22830), + 64: uint16(22833), + 65: uint16(22900), + 66: uint16(22902), + 67: uint16(23381), + 68: uint16(23427), + 69: uint16(23612), + 70: uint16(24040), + 71: uint16(24039), + 72: uint16(24038), + 73: uint16(24066), + 74: uint16(24067), + 75: uint16(24179), + 76: uint16(24188), + 77: uint16(24321), + 78: uint16(24344), + 79: uint16(24343), + 80: uint16(24517), + 81: uint16(25098), + 82: uint16(25171), + 83: uint16(25172), + 84: uint16(25170), + 85: uint16(25169), + 86: uint16(26021), + 87: uint16(26086), + 88: uint16(26414), + 89: uint16(26412), + 90: uint16(26410), + 91: uint16(26411), + 92: uint16(26413), + 93: uint16(27491), + 94: uint16(27597), + 95: uint16(27665), + 96: uint16(27664), + 97: uint16(27704), + 98: uint16(27713), + 99: uint16(27712), + 100: uint16(27710), + 101: uint16(29359), + 102: uint16(29572), + 103: uint16(29577), + 104: uint16(29916), + 105: uint16(29926), + 106: uint16(29976), + 107: uint16(29983), + 108: uint16(29992), + 109: uint16(29993), + 110: uint16(30000), + 111: uint16(30001), + 112: uint16(30002), + 113: uint16(30003), + 114: uint16(30091), + 115: uint16(30333), + 116: uint16(30382), + 117: uint16(30399), + 118: uint16(30446), + 119: uint16(30683), + 120: uint16(30690), + 121: uint16(30707), + 122: uint16(31034), + 123: uint16(31166), + 124: uint16(31348), + 125: uint16(31435), + 126: uint16(19998), + 127: uint16(19999), + 128: uint16(20050), + 129: uint16(20051), + 130: uint16(20073), + 131: uint16(20121), + 132: uint16(20132), + 133: uint16(20134), + 134: uint16(20133), + 135: uint16(20223), + 136: uint16(20233), + 137: uint16(20249), + 138: uint16(20234), + 139: uint16(20245), + 140: uint16(20237), + 141: uint16(20240), + 142: uint16(20241), + 143: uint16(20239), + 144: uint16(20210), + 145: uint16(20214), + 146: uint16(20219), + 147: uint16(20208), + 148: uint16(20211), + 149: uint16(20221), + 150: uint16(20225), + 151: uint16(20235), + 152: uint16(20809), + 153: uint16(20807), + 154: uint16(20806), + 155: uint16(20808), + 156: uint16(20840), + }, + 5: { + 0: uint16(20849), + 1: uint16(20877), + 2: uint16(20912), + 3: uint16(21015), + 4: uint16(21009), + 5: uint16(21010), + 6: uint16(21006), + 7: uint16(21014), + 8: uint16(21155), + 9: uint16(21256), + 10: uint16(21281), + 11: uint16(21280), + 12: uint16(21360), + 13: uint16(21361), + 14: uint16(21513), + 15: uint16(21519), + 16: uint16(21516), + 17: uint16(21514), + 18: uint16(21520), + 19: uint16(21505), + 20: uint16(21515), + 21: uint16(21508), + 22: uint16(21521), + 23: uint16(21517), + 24: uint16(21512), + 25: uint16(21507), + 26: uint16(21518), + 27: uint16(21510), + 28: uint16(21522), + 29: uint16(22240), + 30: uint16(22238), + 31: uint16(22237), + 32: uint16(22323), + 33: uint16(22320), + 34: uint16(22312), + 35: uint16(22317), + 36: uint16(22316), + 37: uint16(22319), + 38: uint16(22313), + 39: uint16(22809), + 40: uint16(22810), + 41: uint16(22839), + 42: uint16(22840), + 43: uint16(22916), + 44: uint16(22904), + 45: uint16(22915), + 46: uint16(22909), + 47: uint16(22905), + 48: uint16(22914), + 49: uint16(22913), + 50: uint16(23383), + 51: uint16(23384), + 52: uint16(23431), + 53: uint16(23432), + 54: uint16(23429), + 55: uint16(23433), + 56: uint16(23546), + 57: uint16(23574), + 58: uint16(23673), + 59: uint16(24030), + 60: uint16(24070), + 61: uint16(24182), + 62: uint16(24180), + 63: uint16(24335), + 64: uint16(24347), + 65: uint16(24537), + 66: uint16(24534), + 67: uint16(25102), + 68: uint16(25100), + 69: uint16(25101), + 70: uint16(25104), + 71: uint16(25187), + 72: uint16(25179), + 73: uint16(25176), + 74: uint16(25910), + 75: uint16(26089), + 76: uint16(26088), + 77: uint16(26092), + 78: uint16(26093), + 79: uint16(26354), + 80: uint16(26355), + 81: uint16(26377), + 82: uint16(26429), + 83: uint16(26420), + 84: uint16(26417), + 85: uint16(26421), + 86: uint16(27425), + 87: uint16(27492), + 88: uint16(27515), + 89: uint16(27670), + 90: uint16(27741), + 91: uint16(27735), + 92: uint16(27737), + 93: uint16(27743), + 94: uint16(27744), + 95: uint16(27728), + 96: uint16(27733), + 97: uint16(27745), + 98: uint16(27739), + 99: uint16(27725), + 100: uint16(27726), + 101: uint16(28784), + 102: uint16(29279), + 103: uint16(29277), + 104: uint16(30334), + 105: uint16(31481), + 106: uint16(31859), + 107: uint16(31992), + 108: uint16(32566), + 109: uint16(32650), + 110: uint16(32701), + 111: uint16(32769), + 112: uint16(32771), + 113: uint16(32780), + 114: uint16(32786), + 115: uint16(32819), + 116: uint16(32895), + 117: uint16(32905), + 118: uint16(32907), + 119: uint16(32908), + 120: uint16(33251), + 121: uint16(33258), + 122: uint16(33267), + 123: uint16(33276), + 124: uint16(33292), + 125: uint16(33307), + 126: uint16(33311), + 127: uint16(33390), + 128: uint16(33394), + 129: uint16(33406), + 130: uint16(34411), + 131: uint16(34880), + 132: uint16(34892), + 133: uint16(34915), + 134: uint16(35199), + 135: uint16(38433), + 136: uint16(20018), + 137: uint16(20136), + 138: uint16(20301), + 139: uint16(20303), + 140: uint16(20295), + 141: uint16(20311), + 142: uint16(20318), + 143: uint16(20276), + 144: uint16(20315), + 145: uint16(20309), + 146: uint16(20272), + 147: uint16(20304), + 148: uint16(20305), + 149: uint16(20285), + 150: uint16(20282), + 151: uint16(20280), + 152: uint16(20291), + 153: uint16(20308), + 154: uint16(20284), + 155: uint16(20294), + 156: uint16(20323), + }, + 6: { + 0: uint16(20316), + 1: uint16(20320), + 2: uint16(20271), + 3: uint16(20302), + 4: uint16(20278), + 5: uint16(20313), + 6: uint16(20317), + 7: uint16(20296), + 8: uint16(20314), + 9: uint16(20812), + 10: uint16(20811), + 11: uint16(20813), + 12: uint16(20853), + 13: uint16(20918), + 14: uint16(20919), + 15: uint16(21029), + 16: uint16(21028), + 17: uint16(21033), + 18: uint16(21034), + 19: uint16(21032), + 20: uint16(21163), + 21: uint16(21161), + 22: uint16(21162), + 23: uint16(21164), + 24: uint16(21283), + 25: uint16(21363), + 26: uint16(21365), + 27: uint16(21533), + 28: uint16(21549), + 29: uint16(21534), + 30: uint16(21566), + 31: uint16(21542), + 32: uint16(21582), + 33: uint16(21543), + 34: uint16(21574), + 35: uint16(21571), + 36: uint16(21555), + 37: uint16(21576), + 38: uint16(21570), + 39: uint16(21531), + 40: uint16(21545), + 41: uint16(21578), + 42: uint16(21561), + 43: uint16(21563), + 44: uint16(21560), + 45: uint16(21550), + 46: uint16(21557), + 47: uint16(21558), + 48: uint16(21536), + 49: uint16(21564), + 50: uint16(21568), + 51: uint16(21553), + 52: uint16(21547), + 53: uint16(21535), + 54: uint16(21548), + 55: uint16(22250), + 56: uint16(22256), + 57: uint16(22244), + 58: uint16(22251), + 59: uint16(22346), + 60: uint16(22353), + 61: uint16(22336), + 62: uint16(22349), + 63: uint16(22343), + 64: uint16(22350), + 65: uint16(22334), + 66: uint16(22352), + 67: uint16(22351), + 68: uint16(22331), + 69: uint16(22767), + 70: uint16(22846), + 71: uint16(22941), + 72: uint16(22930), + 73: uint16(22952), + 74: uint16(22942), + 75: uint16(22947), + 76: uint16(22937), + 77: uint16(22934), + 78: uint16(22925), + 79: uint16(22948), + 80: uint16(22931), + 81: uint16(22922), + 82: uint16(22949), + 83: uint16(23389), + 84: uint16(23388), + 85: uint16(23386), + 86: uint16(23387), + 87: uint16(23436), + 88: uint16(23435), + 89: uint16(23439), + 90: uint16(23596), + 91: uint16(23616), + 92: uint16(23617), + 93: uint16(23615), + 94: uint16(23614), + 95: uint16(23696), + 96: uint16(23697), + 97: uint16(23700), + 98: uint16(23692), + 99: uint16(24043), + 100: uint16(24076), + 101: uint16(24207), + 102: uint16(24199), + 103: uint16(24202), + 104: uint16(24311), + 105: uint16(24324), + 106: uint16(24351), + 107: uint16(24420), + 108: uint16(24418), + 109: uint16(24439), + 110: uint16(24441), + 111: uint16(24536), + 112: uint16(24524), + 113: uint16(24535), + 114: uint16(24525), + 115: uint16(24561), + 116: uint16(24555), + 117: uint16(24568), + 118: uint16(24554), + 119: uint16(25106), + 120: uint16(25105), + 121: uint16(25220), + 122: uint16(25239), + 123: uint16(25238), + 124: uint16(25216), + 125: uint16(25206), + 126: uint16(25225), + 127: uint16(25197), + 128: uint16(25226), + 129: uint16(25212), + 130: uint16(25214), + 131: uint16(25209), + 132: uint16(25203), + 133: uint16(25234), + 134: uint16(25199), + 135: uint16(25240), + 136: uint16(25198), + 137: uint16(25237), + 138: uint16(25235), + 139: uint16(25233), + 140: uint16(25222), + 141: uint16(25913), + 142: uint16(25915), + 143: uint16(25912), + 144: uint16(26097), + 145: uint16(26356), + 146: uint16(26463), + 147: uint16(26446), + 148: uint16(26447), + 149: uint16(26448), + 150: uint16(26449), + 151: uint16(26460), + 152: uint16(26454), + 153: uint16(26462), + 154: uint16(26441), + 155: uint16(26438), + 156: uint16(26464), + }, + 7: { + 0: uint16(26451), + 1: uint16(26455), + 2: uint16(27493), + 3: uint16(27599), + 4: uint16(27714), + 5: uint16(27742), + 6: uint16(27801), + 7: uint16(27777), + 8: uint16(27784), + 9: uint16(27785), + 10: uint16(27781), + 11: uint16(27803), + 12: uint16(27754), + 13: uint16(27770), + 14: uint16(27792), + 15: uint16(27760), + 16: uint16(27788), + 17: uint16(27752), + 18: uint16(27798), + 19: uint16(27794), + 20: uint16(27773), + 21: uint16(27779), + 22: uint16(27762), + 23: uint16(27774), + 24: uint16(27764), + 25: uint16(27782), + 26: uint16(27766), + 27: uint16(27789), + 28: uint16(27796), + 29: uint16(27800), + 30: uint16(27778), + 31: uint16(28790), + 32: uint16(28796), + 33: uint16(28797), + 34: uint16(28792), + 35: uint16(29282), + 36: uint16(29281), + 37: uint16(29280), + 38: uint16(29380), + 39: uint16(29378), + 40: uint16(29590), + 41: uint16(29996), + 42: uint16(29995), + 43: uint16(30007), + 44: uint16(30008), + 45: uint16(30338), + 46: uint16(30447), + 47: uint16(30691), + 48: uint16(31169), + 49: uint16(31168), + 50: uint16(31167), + 51: uint16(31350), + 52: uint16(31995), + 53: uint16(32597), + 54: uint16(32918), + 55: uint16(32915), + 56: uint16(32925), + 57: uint16(32920), + 58: uint16(32923), + 59: uint16(32922), + 60: uint16(32946), + 61: uint16(33391), + 62: uint16(33426), + 63: uint16(33419), + 64: uint16(33421), + 65: uint16(35211), + 66: uint16(35282), + 67: uint16(35328), + 68: uint16(35895), + 69: uint16(35910), + 70: uint16(35925), + 71: uint16(35997), + 72: uint16(36196), + 73: uint16(36208), + 74: uint16(36275), + 75: uint16(36523), + 76: uint16(36554), + 77: uint16(36763), + 78: uint16(36784), + 79: uint16(36802), + 80: uint16(36806), + 81: uint16(36805), + 82: uint16(36804), + 83: uint16(24033), + 84: uint16(37009), + 85: uint16(37026), + 86: uint16(37034), + 87: uint16(37030), + 88: uint16(37027), + 89: uint16(37193), + 90: uint16(37318), + 91: uint16(37324), + 92: uint16(38450), + 93: uint16(38446), + 94: uint16(38449), + 95: uint16(38442), + 96: uint16(38444), + 97: uint16(20006), + 98: uint16(20054), + 99: uint16(20083), + 100: uint16(20107), + 101: uint16(20123), + 102: uint16(20126), + 103: uint16(20139), + 104: uint16(20140), + 105: uint16(20335), + 106: uint16(20381), + 107: uint16(20365), + 108: uint16(20339), + 109: uint16(20351), + 110: uint16(20332), + 111: uint16(20379), + 112: uint16(20363), + 113: uint16(20358), + 114: uint16(20355), + 115: uint16(20336), + 116: uint16(20341), + 117: uint16(20360), + 118: uint16(20329), + 119: uint16(20347), + 120: uint16(20374), + 121: uint16(20350), + 122: uint16(20367), + 123: uint16(20369), + 124: uint16(20346), + 125: uint16(20820), + 126: uint16(20818), + 127: uint16(20821), + 128: uint16(20841), + 129: uint16(20855), + 130: uint16(20854), + 131: uint16(20856), + 132: uint16(20925), + 133: uint16(20989), + 134: uint16(21051), + 135: uint16(21048), + 136: uint16(21047), + 137: uint16(21050), + 138: uint16(21040), + 139: uint16(21038), + 140: uint16(21046), + 141: uint16(21057), + 142: uint16(21182), + 143: uint16(21179), + 144: uint16(21330), + 145: uint16(21332), + 146: uint16(21331), + 147: uint16(21329), + 148: uint16(21350), + 149: uint16(21367), + 150: uint16(21368), + 151: uint16(21369), + 152: uint16(21462), + 153: uint16(21460), + 154: uint16(21463), + 155: uint16(21619), + 156: uint16(21621), + }, + 8: { + 0: uint16(21654), + 1: uint16(21624), + 2: uint16(21653), + 3: uint16(21632), + 4: uint16(21627), + 5: uint16(21623), + 6: uint16(21636), + 7: uint16(21650), + 8: uint16(21638), + 9: uint16(21628), + 10: uint16(21648), + 11: uint16(21617), + 12: uint16(21622), + 13: uint16(21644), + 14: uint16(21658), + 15: uint16(21602), + 16: uint16(21608), + 17: uint16(21643), + 18: uint16(21629), + 19: uint16(21646), + 20: uint16(22266), + 21: uint16(22403), + 22: uint16(22391), + 23: uint16(22378), + 24: uint16(22377), + 25: uint16(22369), + 26: uint16(22374), + 27: uint16(22372), + 28: uint16(22396), + 29: uint16(22812), + 30: uint16(22857), + 31: uint16(22855), + 32: uint16(22856), + 33: uint16(22852), + 34: uint16(22868), + 35: uint16(22974), + 36: uint16(22971), + 37: uint16(22996), + 38: uint16(22969), + 39: uint16(22958), + 40: uint16(22993), + 41: uint16(22982), + 42: uint16(22992), + 43: uint16(22989), + 44: uint16(22987), + 45: uint16(22995), + 46: uint16(22986), + 47: uint16(22959), + 48: uint16(22963), + 49: uint16(22994), + 50: uint16(22981), + 51: uint16(23391), + 52: uint16(23396), + 53: uint16(23395), + 54: uint16(23447), + 55: uint16(23450), + 56: uint16(23448), + 57: uint16(23452), + 58: uint16(23449), + 59: uint16(23451), + 60: uint16(23578), + 61: uint16(23624), + 62: uint16(23621), + 63: uint16(23622), + 64: uint16(23735), + 65: uint16(23713), + 66: uint16(23736), + 67: uint16(23721), + 68: uint16(23723), + 69: uint16(23729), + 70: uint16(23731), + 71: uint16(24088), + 72: uint16(24090), + 73: uint16(24086), + 74: uint16(24085), + 75: uint16(24091), + 76: uint16(24081), + 77: uint16(24184), + 78: uint16(24218), + 79: uint16(24215), + 80: uint16(24220), + 81: uint16(24213), + 82: uint16(24214), + 83: uint16(24310), + 84: uint16(24358), + 85: uint16(24359), + 86: uint16(24361), + 87: uint16(24448), + 88: uint16(24449), + 89: uint16(24447), + 90: uint16(24444), + 91: uint16(24541), + 92: uint16(24544), + 93: uint16(24573), + 94: uint16(24565), + 95: uint16(24575), + 96: uint16(24591), + 97: uint16(24596), + 98: uint16(24623), + 99: uint16(24629), + 100: uint16(24598), + 101: uint16(24618), + 102: uint16(24597), + 103: uint16(24609), + 104: uint16(24615), + 105: uint16(24617), + 106: uint16(24619), + 107: uint16(24603), + 108: uint16(25110), + 109: uint16(25109), + 110: uint16(25151), + 111: uint16(25150), + 112: uint16(25152), + 113: uint16(25215), + 114: uint16(25289), + 115: uint16(25292), + 116: uint16(25284), + 117: uint16(25279), + 118: uint16(25282), + 119: uint16(25273), + 120: uint16(25298), + 121: uint16(25307), + 122: uint16(25259), + 123: uint16(25299), + 124: uint16(25300), + 125: uint16(25291), + 126: uint16(25288), + 127: uint16(25256), + 128: uint16(25277), + 129: uint16(25276), + 130: uint16(25296), + 131: uint16(25305), + 132: uint16(25287), + 133: uint16(25293), + 134: uint16(25269), + 135: uint16(25306), + 136: uint16(25265), + 137: uint16(25304), + 138: uint16(25302), + 139: uint16(25303), + 140: uint16(25286), + 141: uint16(25260), + 142: uint16(25294), + 143: uint16(25918), + 144: uint16(26023), + 145: uint16(26044), + 146: uint16(26106), + 147: uint16(26132), + 148: uint16(26131), + 149: uint16(26124), + 150: uint16(26118), + 151: uint16(26114), + 152: uint16(26126), + 153: uint16(26112), + 154: uint16(26127), + 155: uint16(26133), + 156: uint16(26122), + }, + 9: { + 0: uint16(26119), + 1: uint16(26381), + 2: uint16(26379), + 3: uint16(26477), + 4: uint16(26507), + 5: uint16(26517), + 6: uint16(26481), + 7: uint16(26524), + 8: uint16(26483), + 9: uint16(26487), + 10: uint16(26503), + 11: uint16(26525), + 12: uint16(26519), + 13: uint16(26479), + 14: uint16(26480), + 15: uint16(26495), + 16: uint16(26505), + 17: uint16(26494), + 18: uint16(26512), + 19: uint16(26485), + 20: uint16(26522), + 21: uint16(26515), + 22: uint16(26492), + 23: uint16(26474), + 24: uint16(26482), + 25: uint16(27427), + 26: uint16(27494), + 27: uint16(27495), + 28: uint16(27519), + 29: uint16(27667), + 30: uint16(27675), + 31: uint16(27875), + 32: uint16(27880), + 33: uint16(27891), + 34: uint16(27825), + 35: uint16(27852), + 36: uint16(27877), + 37: uint16(27827), + 38: uint16(27837), + 39: uint16(27838), + 40: uint16(27836), + 41: uint16(27874), + 42: uint16(27819), + 43: uint16(27861), + 44: uint16(27859), + 45: uint16(27832), + 46: uint16(27844), + 47: uint16(27833), + 48: uint16(27841), + 49: uint16(27822), + 50: uint16(27863), + 51: uint16(27845), + 52: uint16(27889), + 53: uint16(27839), + 54: uint16(27835), + 55: uint16(27873), + 56: uint16(27867), + 57: uint16(27850), + 58: uint16(27820), + 59: uint16(27887), + 60: uint16(27868), + 61: uint16(27862), + 62: uint16(27872), + 63: uint16(28821), + 64: uint16(28814), + 65: uint16(28818), + 66: uint16(28810), + 67: uint16(28825), + 68: uint16(29228), + 69: uint16(29229), + 70: uint16(29240), + 71: uint16(29256), + 72: uint16(29287), + 73: uint16(29289), + 74: uint16(29376), + 75: uint16(29390), + 76: uint16(29401), + 77: uint16(29399), + 78: uint16(29392), + 79: uint16(29609), + 80: uint16(29608), + 81: uint16(29599), + 82: uint16(29611), + 83: uint16(29605), + 84: uint16(30013), + 85: uint16(30109), + 86: uint16(30105), + 87: uint16(30106), + 88: uint16(30340), + 89: uint16(30402), + 90: uint16(30450), + 91: uint16(30452), + 92: uint16(30693), + 93: uint16(30717), + 94: uint16(31038), + 95: uint16(31040), + 96: uint16(31041), + 97: uint16(31177), + 98: uint16(31176), + 99: uint16(31354), + 100: uint16(31353), + 101: uint16(31482), + 102: uint16(31998), + 103: uint16(32596), + 104: uint16(32652), + 105: uint16(32651), + 106: uint16(32773), + 107: uint16(32954), + 108: uint16(32933), + 109: uint16(32930), + 110: uint16(32945), + 111: uint16(32929), + 112: uint16(32939), + 113: uint16(32937), + 114: uint16(32948), + 115: uint16(32938), + 116: uint16(32943), + 117: uint16(33253), + 118: uint16(33278), + 119: uint16(33293), + 120: uint16(33459), + 121: uint16(33437), + 122: uint16(33433), + 123: uint16(33453), + 124: uint16(33469), + 125: uint16(33439), + 126: uint16(33465), + 127: uint16(33457), + 128: uint16(33452), + 129: uint16(33445), + 130: uint16(33455), + 131: uint16(33464), + 132: uint16(33443), + 133: uint16(33456), + 134: uint16(33470), + 135: uint16(33463), + 136: uint16(34382), + 137: uint16(34417), + 138: uint16(21021), + 139: uint16(34920), + 140: uint16(36555), + 141: uint16(36814), + 142: uint16(36820), + 143: uint16(36817), + 144: uint16(37045), + 145: uint16(37048), + 146: uint16(37041), + 147: uint16(37046), + 148: uint16(37319), + 149: uint16(37329), + 150: uint16(38263), + 151: uint16(38272), + 152: uint16(38428), + 153: uint16(38464), + 154: uint16(38463), + 155: uint16(38459), + 156: uint16(38468), + }, + 10: { + 0: uint16(38466), + 1: uint16(38585), + 2: uint16(38632), + 3: uint16(38738), + 4: uint16(38750), + 5: uint16(20127), + 6: uint16(20141), + 7: uint16(20142), + 8: uint16(20449), + 9: uint16(20405), + 10: uint16(20399), + 11: uint16(20415), + 12: uint16(20448), + 13: uint16(20433), + 14: uint16(20431), + 15: uint16(20445), + 16: uint16(20419), + 17: uint16(20406), + 18: uint16(20440), + 19: uint16(20447), + 20: uint16(20426), + 21: uint16(20439), + 22: uint16(20398), + 23: uint16(20432), + 24: uint16(20420), + 25: uint16(20418), + 26: uint16(20442), + 27: uint16(20430), + 28: uint16(20446), + 29: uint16(20407), + 30: uint16(20823), + 31: uint16(20882), + 32: uint16(20881), + 33: uint16(20896), + 34: uint16(21070), + 35: uint16(21059), + 36: uint16(21066), + 37: uint16(21069), + 38: uint16(21068), + 39: uint16(21067), + 40: uint16(21063), + 41: uint16(21191), + 42: uint16(21193), + 43: uint16(21187), + 44: uint16(21185), + 45: uint16(21261), + 46: uint16(21335), + 47: uint16(21371), + 48: uint16(21402), + 49: uint16(21467), + 50: uint16(21676), + 51: uint16(21696), + 52: uint16(21672), + 53: uint16(21710), + 54: uint16(21705), + 55: uint16(21688), + 56: uint16(21670), + 57: uint16(21683), + 58: uint16(21703), + 59: uint16(21698), + 60: uint16(21693), + 61: uint16(21674), + 62: uint16(21697), + 63: uint16(21700), + 64: uint16(21704), + 65: uint16(21679), + 66: uint16(21675), + 67: uint16(21681), + 68: uint16(21691), + 69: uint16(21673), + 70: uint16(21671), + 71: uint16(21695), + 72: uint16(22271), + 73: uint16(22402), + 74: uint16(22411), + 75: uint16(22432), + 76: uint16(22435), + 77: uint16(22434), + 78: uint16(22478), + 79: uint16(22446), + 80: uint16(22419), + 81: uint16(22869), + 82: uint16(22865), + 83: uint16(22863), + 84: uint16(22862), + 85: uint16(22864), + 86: uint16(23004), + 87: uint16(23000), + 88: uint16(23039), + 89: uint16(23011), + 90: uint16(23016), + 91: uint16(23043), + 92: uint16(23013), + 93: uint16(23018), + 94: uint16(23002), + 95: uint16(23014), + 96: uint16(23041), + 97: uint16(23035), + 98: uint16(23401), + 99: uint16(23459), + 100: uint16(23462), + 101: uint16(23460), + 102: uint16(23458), + 103: uint16(23461), + 104: uint16(23553), + 105: uint16(23630), + 106: uint16(23631), + 107: uint16(23629), + 108: uint16(23627), + 109: uint16(23769), + 110: uint16(23762), + 111: uint16(24055), + 112: uint16(24093), + 113: uint16(24101), + 114: uint16(24095), + 115: uint16(24189), + 116: uint16(24224), + 117: uint16(24230), + 118: uint16(24314), + 119: uint16(24328), + 120: uint16(24365), + 121: uint16(24421), + 122: uint16(24456), + 123: uint16(24453), + 124: uint16(24458), + 125: uint16(24459), + 126: uint16(24455), + 127: uint16(24460), + 128: uint16(24457), + 129: uint16(24594), + 130: uint16(24605), + 131: uint16(24608), + 132: uint16(24613), + 133: uint16(24590), + 134: uint16(24616), + 135: uint16(24653), + 136: uint16(24688), + 137: uint16(24680), + 138: uint16(24674), + 139: uint16(24646), + 140: uint16(24643), + 141: uint16(24684), + 142: uint16(24683), + 143: uint16(24682), + 144: uint16(24676), + 145: uint16(25153), + 146: uint16(25308), + 147: uint16(25366), + 148: uint16(25353), + 149: uint16(25340), + 150: uint16(25325), + 151: uint16(25345), + 152: uint16(25326), + 153: uint16(25341), + 154: uint16(25351), + 155: uint16(25329), + 156: uint16(25335), + }, + 11: { + 0: uint16(25327), + 1: uint16(25324), + 2: uint16(25342), + 3: uint16(25332), + 4: uint16(25361), + 5: uint16(25346), + 6: uint16(25919), + 7: uint16(25925), + 8: uint16(26027), + 9: uint16(26045), + 10: uint16(26082), + 11: uint16(26149), + 12: uint16(26157), + 13: uint16(26144), + 14: uint16(26151), + 15: uint16(26159), + 16: uint16(26143), + 17: uint16(26152), + 18: uint16(26161), + 19: uint16(26148), + 20: uint16(26359), + 21: uint16(26623), + 22: uint16(26579), + 23: uint16(26609), + 24: uint16(26580), + 25: uint16(26576), + 26: uint16(26604), + 27: uint16(26550), + 28: uint16(26543), + 29: uint16(26613), + 30: uint16(26601), + 31: uint16(26607), + 32: uint16(26564), + 33: uint16(26577), + 34: uint16(26548), + 35: uint16(26586), + 36: uint16(26597), + 37: uint16(26552), + 38: uint16(26575), + 39: uint16(26590), + 40: uint16(26611), + 41: uint16(26544), + 42: uint16(26585), + 43: uint16(26594), + 44: uint16(26589), + 45: uint16(26578), + 46: uint16(27498), + 47: uint16(27523), + 48: uint16(27526), + 49: uint16(27573), + 50: uint16(27602), + 51: uint16(27607), + 52: uint16(27679), + 53: uint16(27849), + 54: uint16(27915), + 55: uint16(27954), + 56: uint16(27946), + 57: uint16(27969), + 58: uint16(27941), + 59: uint16(27916), + 60: uint16(27953), + 61: uint16(27934), + 62: uint16(27927), + 63: uint16(27963), + 64: uint16(27965), + 65: uint16(27966), + 66: uint16(27958), + 67: uint16(27931), + 68: uint16(27893), + 69: uint16(27961), + 70: uint16(27943), + 71: uint16(27960), + 72: uint16(27945), + 73: uint16(27950), + 74: uint16(27957), + 75: uint16(27918), + 76: uint16(27947), + 77: uint16(28843), + 78: uint16(28858), + 79: uint16(28851), + 80: uint16(28844), + 81: uint16(28847), + 82: uint16(28845), + 83: uint16(28856), + 84: uint16(28846), + 85: uint16(28836), + 86: uint16(29232), + 87: uint16(29298), + 88: uint16(29295), + 89: uint16(29300), + 90: uint16(29417), + 91: uint16(29408), + 92: uint16(29409), + 93: uint16(29623), + 94: uint16(29642), + 95: uint16(29627), + 96: uint16(29618), + 97: uint16(29645), + 98: uint16(29632), + 99: uint16(29619), + 100: uint16(29978), + 101: uint16(29997), + 102: uint16(30031), + 103: uint16(30028), + 104: uint16(30030), + 105: uint16(30027), + 106: uint16(30123), + 107: uint16(30116), + 108: uint16(30117), + 109: uint16(30114), + 110: uint16(30115), + 111: uint16(30328), + 112: uint16(30342), + 113: uint16(30343), + 114: uint16(30344), + 115: uint16(30408), + 116: uint16(30406), + 117: uint16(30403), + 118: uint16(30405), + 119: uint16(30465), + 120: uint16(30457), + 121: uint16(30456), + 122: uint16(30473), + 123: uint16(30475), + 124: uint16(30462), + 125: uint16(30460), + 126: uint16(30471), + 127: uint16(30684), + 128: uint16(30722), + 129: uint16(30740), + 130: uint16(30732), + 131: uint16(30733), + 132: uint16(31046), + 133: uint16(31049), + 134: uint16(31048), + 135: uint16(31047), + 136: uint16(31161), + 137: uint16(31162), + 138: uint16(31185), + 139: uint16(31186), + 140: uint16(31179), + 141: uint16(31359), + 142: uint16(31361), + 143: uint16(31487), + 144: uint16(31485), + 145: uint16(31869), + 146: uint16(32002), + 147: uint16(32005), + 148: uint16(32000), + 149: uint16(32009), + 150: uint16(32007), + 151: uint16(32004), + 152: uint16(32006), + 153: uint16(32568), + 154: uint16(32654), + 155: uint16(32703), + 156: uint16(32772), + }, + 12: { + 0: uint16(32784), + 1: uint16(32781), + 2: uint16(32785), + 3: uint16(32822), + 4: uint16(32982), + 5: uint16(32997), + 6: uint16(32986), + 7: uint16(32963), + 8: uint16(32964), + 9: uint16(32972), + 10: uint16(32993), + 11: uint16(32987), + 12: uint16(32974), + 13: uint16(32990), + 14: uint16(32996), + 15: uint16(32989), + 16: uint16(33268), + 17: uint16(33314), + 18: uint16(33511), + 19: uint16(33539), + 20: uint16(33541), + 21: uint16(33507), + 22: uint16(33499), + 23: uint16(33510), + 24: uint16(33540), + 25: uint16(33509), + 26: uint16(33538), + 27: uint16(33545), + 28: uint16(33490), + 29: uint16(33495), + 30: uint16(33521), + 31: uint16(33537), + 32: uint16(33500), + 33: uint16(33492), + 34: uint16(33489), + 35: uint16(33502), + 36: uint16(33491), + 37: uint16(33503), + 38: uint16(33519), + 39: uint16(33542), + 40: uint16(34384), + 41: uint16(34425), + 42: uint16(34427), + 43: uint16(34426), + 44: uint16(34893), + 45: uint16(34923), + 46: uint16(35201), + 47: uint16(35284), + 48: uint16(35336), + 49: uint16(35330), + 50: uint16(35331), + 51: uint16(35998), + 52: uint16(36000), + 53: uint16(36212), + 54: uint16(36211), + 55: uint16(36276), + 56: uint16(36557), + 57: uint16(36556), + 58: uint16(36848), + 59: uint16(36838), + 60: uint16(36834), + 61: uint16(36842), + 62: uint16(36837), + 63: uint16(36845), + 64: uint16(36843), + 65: uint16(36836), + 66: uint16(36840), + 67: uint16(37066), + 68: uint16(37070), + 69: uint16(37057), + 70: uint16(37059), + 71: uint16(37195), + 72: uint16(37194), + 73: uint16(37325), + 74: uint16(38274), + 75: uint16(38480), + 76: uint16(38475), + 77: uint16(38476), + 78: uint16(38477), + 79: uint16(38754), + 80: uint16(38761), + 81: uint16(38859), + 82: uint16(38893), + 83: uint16(38899), + 84: uint16(38913), + 85: uint16(39080), + 86: uint16(39131), + 87: uint16(39135), + 88: uint16(39318), + 89: uint16(39321), + 90: uint16(20056), + 91: uint16(20147), + 92: uint16(20492), + 93: uint16(20493), + 94: uint16(20515), + 95: uint16(20463), + 96: uint16(20518), + 97: uint16(20517), + 98: uint16(20472), + 99: uint16(20521), + 100: uint16(20502), + 101: uint16(20486), + 102: uint16(20540), + 103: uint16(20511), + 104: uint16(20506), + 105: uint16(20498), + 106: uint16(20497), + 107: uint16(20474), + 108: uint16(20480), + 109: uint16(20500), + 110: uint16(20520), + 111: uint16(20465), + 112: uint16(20513), + 113: uint16(20491), + 114: uint16(20505), + 115: uint16(20504), + 116: uint16(20467), + 117: uint16(20462), + 118: uint16(20525), + 119: uint16(20522), + 120: uint16(20478), + 121: uint16(20523), + 122: uint16(20489), + 123: uint16(20860), + 124: uint16(20900), + 125: uint16(20901), + 126: uint16(20898), + 127: uint16(20941), + 128: uint16(20940), + 129: uint16(20934), + 130: uint16(20939), + 131: uint16(21078), + 132: uint16(21084), + 133: uint16(21076), + 134: uint16(21083), + 135: uint16(21085), + 136: uint16(21290), + 137: uint16(21375), + 138: uint16(21407), + 139: uint16(21405), + 140: uint16(21471), + 141: uint16(21736), + 142: uint16(21776), + 143: uint16(21761), + 144: uint16(21815), + 145: uint16(21756), + 146: uint16(21733), + 147: uint16(21746), + 148: uint16(21766), + 149: uint16(21754), + 150: uint16(21780), + 151: uint16(21737), + 152: uint16(21741), + 153: uint16(21729), + 154: uint16(21769), + 155: uint16(21742), + 156: uint16(21738), + }, + 13: { + 0: uint16(21734), + 1: uint16(21799), + 2: uint16(21767), + 3: uint16(21757), + 4: uint16(21775), + 5: uint16(22275), + 6: uint16(22276), + 7: uint16(22466), + 8: uint16(22484), + 9: uint16(22475), + 10: uint16(22467), + 11: uint16(22537), + 12: uint16(22799), + 13: uint16(22871), + 14: uint16(22872), + 15: uint16(22874), + 16: uint16(23057), + 17: uint16(23064), + 18: uint16(23068), + 19: uint16(23071), + 20: uint16(23067), + 21: uint16(23059), + 22: uint16(23020), + 23: uint16(23072), + 24: uint16(23075), + 25: uint16(23081), + 26: uint16(23077), + 27: uint16(23052), + 28: uint16(23049), + 29: uint16(23403), + 30: uint16(23640), + 31: uint16(23472), + 32: uint16(23475), + 33: uint16(23478), + 34: uint16(23476), + 35: uint16(23470), + 36: uint16(23477), + 37: uint16(23481), + 38: uint16(23480), + 39: uint16(23556), + 40: uint16(23633), + 41: uint16(23637), + 42: uint16(23632), + 43: uint16(23789), + 44: uint16(23805), + 45: uint16(23803), + 46: uint16(23786), + 47: uint16(23784), + 48: uint16(23792), + 49: uint16(23798), + 50: uint16(23809), + 51: uint16(23796), + 52: uint16(24046), + 53: uint16(24109), + 54: uint16(24107), + 55: uint16(24235), + 56: uint16(24237), + 57: uint16(24231), + 58: uint16(24369), + 59: uint16(24466), + 60: uint16(24465), + 61: uint16(24464), + 62: uint16(24665), + 63: uint16(24675), + 64: uint16(24677), + 65: uint16(24656), + 66: uint16(24661), + 67: uint16(24685), + 68: uint16(24681), + 69: uint16(24687), + 70: uint16(24708), + 71: uint16(24735), + 72: uint16(24730), + 73: uint16(24717), + 74: uint16(24724), + 75: uint16(24716), + 76: uint16(24709), + 77: uint16(24726), + 78: uint16(25159), + 79: uint16(25331), + 80: uint16(25352), + 81: uint16(25343), + 82: uint16(25422), + 83: uint16(25406), + 84: uint16(25391), + 85: uint16(25429), + 86: uint16(25410), + 87: uint16(25414), + 88: uint16(25423), + 89: uint16(25417), + 90: uint16(25402), + 91: uint16(25424), + 92: uint16(25405), + 93: uint16(25386), + 94: uint16(25387), + 95: uint16(25384), + 96: uint16(25421), + 97: uint16(25420), + 98: uint16(25928), + 99: uint16(25929), + 100: uint16(26009), + 101: uint16(26049), + 102: uint16(26053), + 103: uint16(26178), + 104: uint16(26185), + 105: uint16(26191), + 106: uint16(26179), + 107: uint16(26194), + 108: uint16(26188), + 109: uint16(26181), + 110: uint16(26177), + 111: uint16(26360), + 112: uint16(26388), + 113: uint16(26389), + 114: uint16(26391), + 115: uint16(26657), + 116: uint16(26680), + 117: uint16(26696), + 118: uint16(26694), + 119: uint16(26707), + 120: uint16(26681), + 121: uint16(26690), + 122: uint16(26708), + 123: uint16(26665), + 124: uint16(26803), + 125: uint16(26647), + 126: uint16(26700), + 127: uint16(26705), + 128: uint16(26685), + 129: uint16(26612), + 130: uint16(26704), + 131: uint16(26688), + 132: uint16(26684), + 133: uint16(26691), + 134: uint16(26666), + 135: uint16(26693), + 136: uint16(26643), + 137: uint16(26648), + 138: uint16(26689), + 139: uint16(27530), + 140: uint16(27529), + 141: uint16(27575), + 142: uint16(27683), + 143: uint16(27687), + 144: uint16(27688), + 145: uint16(27686), + 146: uint16(27684), + 147: uint16(27888), + 148: uint16(28010), + 149: uint16(28053), + 150: uint16(28040), + 151: uint16(28039), + 152: uint16(28006), + 153: uint16(28024), + 154: uint16(28023), + 155: uint16(27993), + 156: uint16(28051), + }, + 14: { + 0: uint16(28012), + 1: uint16(28041), + 2: uint16(28014), + 3: uint16(27994), + 4: uint16(28020), + 5: uint16(28009), + 6: uint16(28044), + 7: uint16(28042), + 8: uint16(28025), + 9: uint16(28037), + 10: uint16(28005), + 11: uint16(28052), + 12: uint16(28874), + 13: uint16(28888), + 14: uint16(28900), + 15: uint16(28889), + 16: uint16(28872), + 17: uint16(28879), + 18: uint16(29241), + 19: uint16(29305), + 20: uint16(29436), + 21: uint16(29433), + 22: uint16(29437), + 23: uint16(29432), + 24: uint16(29431), + 25: uint16(29574), + 26: uint16(29677), + 27: uint16(29705), + 28: uint16(29678), + 29: uint16(29664), + 30: uint16(29674), + 31: uint16(29662), + 32: uint16(30036), + 33: uint16(30045), + 34: uint16(30044), + 35: uint16(30042), + 36: uint16(30041), + 37: uint16(30142), + 38: uint16(30149), + 39: uint16(30151), + 40: uint16(30130), + 41: uint16(30131), + 42: uint16(30141), + 43: uint16(30140), + 44: uint16(30137), + 45: uint16(30146), + 46: uint16(30136), + 47: uint16(30347), + 48: uint16(30384), + 49: uint16(30410), + 50: uint16(30413), + 51: uint16(30414), + 52: uint16(30505), + 53: uint16(30495), + 54: uint16(30496), + 55: uint16(30504), + 56: uint16(30697), + 57: uint16(30768), + 58: uint16(30759), + 59: uint16(30776), + 60: uint16(30749), + 61: uint16(30772), + 62: uint16(30775), + 63: uint16(30757), + 64: uint16(30765), + 65: uint16(30752), + 66: uint16(30751), + 67: uint16(30770), + 68: uint16(31061), + 69: uint16(31056), + 70: uint16(31072), + 71: uint16(31071), + 72: uint16(31062), + 73: uint16(31070), + 74: uint16(31069), + 75: uint16(31063), + 76: uint16(31066), + 77: uint16(31204), + 78: uint16(31203), + 79: uint16(31207), + 80: uint16(31199), + 81: uint16(31206), + 82: uint16(31209), + 83: uint16(31192), + 84: uint16(31364), + 85: uint16(31368), + 86: uint16(31449), + 87: uint16(31494), + 88: uint16(31505), + 89: uint16(31881), + 90: uint16(32033), + 91: uint16(32023), + 92: uint16(32011), + 93: uint16(32010), + 94: uint16(32032), + 95: uint16(32034), + 96: uint16(32020), + 97: uint16(32016), + 98: uint16(32021), + 99: uint16(32026), + 100: uint16(32028), + 101: uint16(32013), + 102: uint16(32025), + 103: uint16(32027), + 104: uint16(32570), + 105: uint16(32607), + 106: uint16(32660), + 107: uint16(32709), + 108: uint16(32705), + 109: uint16(32774), + 110: uint16(32792), + 111: uint16(32789), + 112: uint16(32793), + 113: uint16(32791), + 114: uint16(32829), + 115: uint16(32831), + 116: uint16(33009), + 117: uint16(33026), + 118: uint16(33008), + 119: uint16(33029), + 120: uint16(33005), + 121: uint16(33012), + 122: uint16(33030), + 123: uint16(33016), + 124: uint16(33011), + 125: uint16(33032), + 126: uint16(33021), + 127: uint16(33034), + 128: uint16(33020), + 129: uint16(33007), + 130: uint16(33261), + 131: uint16(33260), + 132: uint16(33280), + 133: uint16(33296), + 134: uint16(33322), + 135: uint16(33323), + 136: uint16(33320), + 137: uint16(33324), + 138: uint16(33467), + 139: uint16(33579), + 140: uint16(33618), + 141: uint16(33620), + 142: uint16(33610), + 143: uint16(33592), + 144: uint16(33616), + 145: uint16(33609), + 146: uint16(33589), + 147: uint16(33588), + 148: uint16(33615), + 149: uint16(33586), + 150: uint16(33593), + 151: uint16(33590), + 152: uint16(33559), + 153: uint16(33600), + 154: uint16(33585), + 155: uint16(33576), + 156: uint16(33603), + }, + 15: { + 0: uint16(34388), + 1: uint16(34442), + 2: uint16(34474), + 3: uint16(34451), + 4: uint16(34468), + 5: uint16(34473), + 6: uint16(34444), + 7: uint16(34467), + 8: uint16(34460), + 9: uint16(34928), + 10: uint16(34935), + 11: uint16(34945), + 12: uint16(34946), + 13: uint16(34941), + 14: uint16(34937), + 15: uint16(35352), + 16: uint16(35344), + 17: uint16(35342), + 18: uint16(35340), + 19: uint16(35349), + 20: uint16(35338), + 21: uint16(35351), + 22: uint16(35347), + 23: uint16(35350), + 24: uint16(35343), + 25: uint16(35345), + 26: uint16(35912), + 27: uint16(35962), + 28: uint16(35961), + 29: uint16(36001), + 30: uint16(36002), + 31: uint16(36215), + 32: uint16(36524), + 33: uint16(36562), + 34: uint16(36564), + 35: uint16(36559), + 36: uint16(36785), + 37: uint16(36865), + 38: uint16(36870), + 39: uint16(36855), + 40: uint16(36864), + 41: uint16(36858), + 42: uint16(36852), + 43: uint16(36867), + 44: uint16(36861), + 45: uint16(36869), + 46: uint16(36856), + 47: uint16(37013), + 48: uint16(37089), + 49: uint16(37085), + 50: uint16(37090), + 51: uint16(37202), + 52: uint16(37197), + 53: uint16(37196), + 54: uint16(37336), + 55: uint16(37341), + 56: uint16(37335), + 57: uint16(37340), + 58: uint16(37337), + 59: uint16(38275), + 60: uint16(38498), + 61: uint16(38499), + 62: uint16(38497), + 63: uint16(38491), + 64: uint16(38493), + 65: uint16(38500), + 66: uint16(38488), + 67: uint16(38494), + 68: uint16(38587), + 69: uint16(39138), + 70: uint16(39340), + 71: uint16(39592), + 72: uint16(39640), + 73: uint16(39717), + 74: uint16(39730), + 75: uint16(39740), + 76: uint16(20094), + 77: uint16(20602), + 78: uint16(20605), + 79: uint16(20572), + 80: uint16(20551), + 81: uint16(20547), + 82: uint16(20556), + 83: uint16(20570), + 84: uint16(20553), + 85: uint16(20581), + 86: uint16(20598), + 87: uint16(20558), + 88: uint16(20565), + 89: uint16(20597), + 90: uint16(20596), + 91: uint16(20599), + 92: uint16(20559), + 93: uint16(20495), + 94: uint16(20591), + 95: uint16(20589), + 96: uint16(20828), + 97: uint16(20885), + 98: uint16(20976), + 99: uint16(21098), + 100: uint16(21103), + 101: uint16(21202), + 102: uint16(21209), + 103: uint16(21208), + 104: uint16(21205), + 105: uint16(21264), + 106: uint16(21263), + 107: uint16(21273), + 108: uint16(21311), + 109: uint16(21312), + 110: uint16(21310), + 111: uint16(21443), + 112: uint16(26364), + 113: uint16(21830), + 114: uint16(21866), + 115: uint16(21862), + 116: uint16(21828), + 117: uint16(21854), + 118: uint16(21857), + 119: uint16(21827), + 120: uint16(21834), + 121: uint16(21809), + 122: uint16(21846), + 123: uint16(21839), + 124: uint16(21845), + 125: uint16(21807), + 126: uint16(21860), + 127: uint16(21816), + 128: uint16(21806), + 129: uint16(21852), + 130: uint16(21804), + 131: uint16(21859), + 132: uint16(21811), + 133: uint16(21825), + 134: uint16(21847), + 135: uint16(22280), + 136: uint16(22283), + 137: uint16(22281), + 138: uint16(22495), + 139: uint16(22533), + 140: uint16(22538), + 141: uint16(22534), + 142: uint16(22496), + 143: uint16(22500), + 144: uint16(22522), + 145: uint16(22530), + 146: uint16(22581), + 147: uint16(22519), + 148: uint16(22521), + 149: uint16(22816), + 150: uint16(22882), + 151: uint16(23094), + 152: uint16(23105), + 153: uint16(23113), + 154: uint16(23142), + 155: uint16(23146), + 156: uint16(23104), + }, + 16: { + 0: uint16(23100), + 1: uint16(23138), + 2: uint16(23130), + 3: uint16(23110), + 4: uint16(23114), + 5: uint16(23408), + 6: uint16(23495), + 7: uint16(23493), + 8: uint16(23492), + 9: uint16(23490), + 10: uint16(23487), + 11: uint16(23494), + 12: uint16(23561), + 13: uint16(23560), + 14: uint16(23559), + 15: uint16(23648), + 16: uint16(23644), + 17: uint16(23645), + 18: uint16(23815), + 19: uint16(23814), + 20: uint16(23822), + 21: uint16(23835), + 22: uint16(23830), + 23: uint16(23842), + 24: uint16(23825), + 25: uint16(23849), + 26: uint16(23828), + 27: uint16(23833), + 28: uint16(23844), + 29: uint16(23847), + 30: uint16(23831), + 31: uint16(24034), + 32: uint16(24120), + 33: uint16(24118), + 34: uint16(24115), + 35: uint16(24119), + 36: uint16(24247), + 37: uint16(24248), + 38: uint16(24246), + 39: uint16(24245), + 40: uint16(24254), + 41: uint16(24373), + 42: uint16(24375), + 43: uint16(24407), + 44: uint16(24428), + 45: uint16(24425), + 46: uint16(24427), + 47: uint16(24471), + 48: uint16(24473), + 49: uint16(24478), + 50: uint16(24472), + 51: uint16(24481), + 52: uint16(24480), + 53: uint16(24476), + 54: uint16(24703), + 55: uint16(24739), + 56: uint16(24713), + 57: uint16(24736), + 58: uint16(24744), + 59: uint16(24779), + 60: uint16(24756), + 61: uint16(24806), + 62: uint16(24765), + 63: uint16(24773), + 64: uint16(24763), + 65: uint16(24757), + 66: uint16(24796), + 67: uint16(24764), + 68: uint16(24792), + 69: uint16(24789), + 70: uint16(24774), + 71: uint16(24799), + 72: uint16(24760), + 73: uint16(24794), + 74: uint16(24775), + 75: uint16(25114), + 76: uint16(25115), + 77: uint16(25160), + 78: uint16(25504), + 79: uint16(25511), + 80: uint16(25458), + 81: uint16(25494), + 82: uint16(25506), + 83: uint16(25509), + 84: uint16(25463), + 85: uint16(25447), + 86: uint16(25496), + 87: uint16(25514), + 88: uint16(25457), + 89: uint16(25513), + 90: uint16(25481), + 91: uint16(25475), + 92: uint16(25499), + 93: uint16(25451), + 94: uint16(25512), + 95: uint16(25476), + 96: uint16(25480), + 97: uint16(25497), + 98: uint16(25505), + 99: uint16(25516), + 100: uint16(25490), + 101: uint16(25487), + 102: uint16(25472), + 103: uint16(25467), + 104: uint16(25449), + 105: uint16(25448), + 106: uint16(25466), + 107: uint16(25949), + 108: uint16(25942), + 109: uint16(25937), + 110: uint16(25945), + 111: uint16(25943), + 112: uint16(21855), + 113: uint16(25935), + 114: uint16(25944), + 115: uint16(25941), + 116: uint16(25940), + 117: uint16(26012), + 118: uint16(26011), + 119: uint16(26028), + 120: uint16(26063), + 121: uint16(26059), + 122: uint16(26060), + 123: uint16(26062), + 124: uint16(26205), + 125: uint16(26202), + 126: uint16(26212), + 127: uint16(26216), + 128: uint16(26214), + 129: uint16(26206), + 130: uint16(26361), + 131: uint16(21207), + 132: uint16(26395), + 133: uint16(26753), + 134: uint16(26799), + 135: uint16(26786), + 136: uint16(26771), + 137: uint16(26805), + 138: uint16(26751), + 139: uint16(26742), + 140: uint16(26801), + 141: uint16(26791), + 142: uint16(26775), + 143: uint16(26800), + 144: uint16(26755), + 145: uint16(26820), + 146: uint16(26797), + 147: uint16(26758), + 148: uint16(26757), + 149: uint16(26772), + 150: uint16(26781), + 151: uint16(26792), + 152: uint16(26783), + 153: uint16(26785), + 154: uint16(26754), + 155: uint16(27442), + 156: uint16(27578), + }, + 17: { + 0: uint16(27627), + 1: uint16(27628), + 2: uint16(27691), + 3: uint16(28046), + 4: uint16(28092), + 5: uint16(28147), + 6: uint16(28121), + 7: uint16(28082), + 8: uint16(28129), + 9: uint16(28108), + 10: uint16(28132), + 11: uint16(28155), + 12: uint16(28154), + 13: uint16(28165), + 14: uint16(28103), + 15: uint16(28107), + 16: uint16(28079), + 17: uint16(28113), + 18: uint16(28078), + 19: uint16(28126), + 20: uint16(28153), + 21: uint16(28088), + 22: uint16(28151), + 23: uint16(28149), + 24: uint16(28101), + 25: uint16(28114), + 26: uint16(28186), + 27: uint16(28085), + 28: uint16(28122), + 29: uint16(28139), + 30: uint16(28120), + 31: uint16(28138), + 32: uint16(28145), + 33: uint16(28142), + 34: uint16(28136), + 35: uint16(28102), + 36: uint16(28100), + 37: uint16(28074), + 38: uint16(28140), + 39: uint16(28095), + 40: uint16(28134), + 41: uint16(28921), + 42: uint16(28937), + 43: uint16(28938), + 44: uint16(28925), + 45: uint16(28911), + 46: uint16(29245), + 47: uint16(29309), + 48: uint16(29313), + 49: uint16(29468), + 50: uint16(29467), + 51: uint16(29462), + 52: uint16(29459), + 53: uint16(29465), + 54: uint16(29575), + 55: uint16(29701), + 56: uint16(29706), + 57: uint16(29699), + 58: uint16(29702), + 59: uint16(29694), + 60: uint16(29709), + 61: uint16(29920), + 62: uint16(29942), + 63: uint16(29943), + 64: uint16(29980), + 65: uint16(29986), + 66: uint16(30053), + 67: uint16(30054), + 68: uint16(30050), + 69: uint16(30064), + 70: uint16(30095), + 71: uint16(30164), + 72: uint16(30165), + 73: uint16(30133), + 74: uint16(30154), + 75: uint16(30157), + 76: uint16(30350), + 77: uint16(30420), + 78: uint16(30418), + 79: uint16(30427), + 80: uint16(30519), + 81: uint16(30526), + 82: uint16(30524), + 83: uint16(30518), + 84: uint16(30520), + 85: uint16(30522), + 86: uint16(30827), + 87: uint16(30787), + 88: uint16(30798), + 89: uint16(31077), + 90: uint16(31080), + 91: uint16(31085), + 92: uint16(31227), + 93: uint16(31378), + 94: uint16(31381), + 95: uint16(31520), + 96: uint16(31528), + 97: uint16(31515), + 98: uint16(31532), + 99: uint16(31526), + 100: uint16(31513), + 101: uint16(31518), + 102: uint16(31534), + 103: uint16(31890), + 104: uint16(31895), + 105: uint16(31893), + 106: uint16(32070), + 107: uint16(32067), + 108: uint16(32113), + 109: uint16(32046), + 110: uint16(32057), + 111: uint16(32060), + 112: uint16(32064), + 113: uint16(32048), + 114: uint16(32051), + 115: uint16(32068), + 116: uint16(32047), + 117: uint16(32066), + 118: uint16(32050), + 119: uint16(32049), + 120: uint16(32573), + 121: uint16(32670), + 122: uint16(32666), + 123: uint16(32716), + 124: uint16(32718), + 125: uint16(32722), + 126: uint16(32796), + 127: uint16(32842), + 128: uint16(32838), + 129: uint16(33071), + 130: uint16(33046), + 131: uint16(33059), + 132: uint16(33067), + 133: uint16(33065), + 134: uint16(33072), + 135: uint16(33060), + 136: uint16(33282), + 137: uint16(33333), + 138: uint16(33335), + 139: uint16(33334), + 140: uint16(33337), + 141: uint16(33678), + 142: uint16(33694), + 143: uint16(33688), + 144: uint16(33656), + 145: uint16(33698), + 146: uint16(33686), + 147: uint16(33725), + 148: uint16(33707), + 149: uint16(33682), + 150: uint16(33674), + 151: uint16(33683), + 152: uint16(33673), + 153: uint16(33696), + 154: uint16(33655), + 155: uint16(33659), + 156: uint16(33660), + }, + 18: { + 0: uint16(33670), + 1: uint16(33703), + 2: uint16(34389), + 3: uint16(24426), + 4: uint16(34503), + 5: uint16(34496), + 6: uint16(34486), + 7: uint16(34500), + 8: uint16(34485), + 9: uint16(34502), + 10: uint16(34507), + 11: uint16(34481), + 12: uint16(34479), + 13: uint16(34505), + 14: uint16(34899), + 15: uint16(34974), + 16: uint16(34952), + 17: uint16(34987), + 18: uint16(34962), + 19: uint16(34966), + 20: uint16(34957), + 21: uint16(34955), + 22: uint16(35219), + 23: uint16(35215), + 24: uint16(35370), + 25: uint16(35357), + 26: uint16(35363), + 27: uint16(35365), + 28: uint16(35377), + 29: uint16(35373), + 30: uint16(35359), + 31: uint16(35355), + 32: uint16(35362), + 33: uint16(35913), + 34: uint16(35930), + 35: uint16(36009), + 36: uint16(36012), + 37: uint16(36011), + 38: uint16(36008), + 39: uint16(36010), + 40: uint16(36007), + 41: uint16(36199), + 42: uint16(36198), + 43: uint16(36286), + 44: uint16(36282), + 45: uint16(36571), + 46: uint16(36575), + 47: uint16(36889), + 48: uint16(36877), + 49: uint16(36890), + 50: uint16(36887), + 51: uint16(36899), + 52: uint16(36895), + 53: uint16(36893), + 54: uint16(36880), + 55: uint16(36885), + 56: uint16(36894), + 57: uint16(36896), + 58: uint16(36879), + 59: uint16(36898), + 60: uint16(36886), + 61: uint16(36891), + 62: uint16(36884), + 63: uint16(37096), + 64: uint16(37101), + 65: uint16(37117), + 66: uint16(37207), + 67: uint16(37326), + 68: uint16(37365), + 69: uint16(37350), + 70: uint16(37347), + 71: uint16(37351), + 72: uint16(37357), + 73: uint16(37353), + 74: uint16(38281), + 75: uint16(38506), + 76: uint16(38517), + 77: uint16(38515), + 78: uint16(38520), + 79: uint16(38512), + 80: uint16(38516), + 81: uint16(38518), + 82: uint16(38519), + 83: uint16(38508), + 84: uint16(38592), + 85: uint16(38634), + 86: uint16(38633), + 87: uint16(31456), + 88: uint16(31455), + 89: uint16(38914), + 90: uint16(38915), + 91: uint16(39770), + 92: uint16(40165), + 93: uint16(40565), + 94: uint16(40575), + 95: uint16(40613), + 96: uint16(40635), + 97: uint16(20642), + 98: uint16(20621), + 99: uint16(20613), + 100: uint16(20633), + 101: uint16(20625), + 102: uint16(20608), + 103: uint16(20630), + 104: uint16(20632), + 105: uint16(20634), + 106: uint16(26368), + 107: uint16(20977), + 108: uint16(21106), + 109: uint16(21108), + 110: uint16(21109), + 111: uint16(21097), + 112: uint16(21214), + 113: uint16(21213), + 114: uint16(21211), + 115: uint16(21338), + 116: uint16(21413), + 117: uint16(21883), + 118: uint16(21888), + 119: uint16(21927), + 120: uint16(21884), + 121: uint16(21898), + 122: uint16(21917), + 123: uint16(21912), + 124: uint16(21890), + 125: uint16(21916), + 126: uint16(21930), + 127: uint16(21908), + 128: uint16(21895), + 129: uint16(21899), + 130: uint16(21891), + 131: uint16(21939), + 132: uint16(21934), + 133: uint16(21919), + 134: uint16(21822), + 135: uint16(21938), + 136: uint16(21914), + 137: uint16(21947), + 138: uint16(21932), + 139: uint16(21937), + 140: uint16(21886), + 141: uint16(21897), + 142: uint16(21931), + 143: uint16(21913), + 144: uint16(22285), + 145: uint16(22575), + 146: uint16(22570), + 147: uint16(22580), + 148: uint16(22564), + 149: uint16(22576), + 150: uint16(22577), + 151: uint16(22561), + 152: uint16(22557), + 153: uint16(22560), + 154: uint16(22777), + 155: uint16(22778), + 156: uint16(22880), + }, + 19: { + 0: uint16(23159), + 1: uint16(23194), + 2: uint16(23167), + 3: uint16(23186), + 4: uint16(23195), + 5: uint16(23207), + 6: uint16(23411), + 7: uint16(23409), + 8: uint16(23506), + 9: uint16(23500), + 10: uint16(23507), + 11: uint16(23504), + 12: uint16(23562), + 13: uint16(23563), + 14: uint16(23601), + 15: uint16(23884), + 16: uint16(23888), + 17: uint16(23860), + 18: uint16(23879), + 19: uint16(24061), + 20: uint16(24133), + 21: uint16(24125), + 22: uint16(24128), + 23: uint16(24131), + 24: uint16(24190), + 25: uint16(24266), + 26: uint16(24257), + 27: uint16(24258), + 28: uint16(24260), + 29: uint16(24380), + 30: uint16(24429), + 31: uint16(24489), + 32: uint16(24490), + 33: uint16(24488), + 34: uint16(24785), + 35: uint16(24801), + 36: uint16(24754), + 37: uint16(24758), + 38: uint16(24800), + 39: uint16(24860), + 40: uint16(24867), + 41: uint16(24826), + 42: uint16(24853), + 43: uint16(24816), + 44: uint16(24827), + 45: uint16(24820), + 46: uint16(24936), + 47: uint16(24817), + 48: uint16(24846), + 49: uint16(24822), + 50: uint16(24841), + 51: uint16(24832), + 52: uint16(24850), + 53: uint16(25119), + 54: uint16(25161), + 55: uint16(25507), + 56: uint16(25484), + 57: uint16(25551), + 58: uint16(25536), + 59: uint16(25577), + 60: uint16(25545), + 61: uint16(25542), + 62: uint16(25549), + 63: uint16(25554), + 64: uint16(25571), + 65: uint16(25552), + 66: uint16(25569), + 67: uint16(25558), + 68: uint16(25581), + 69: uint16(25582), + 70: uint16(25462), + 71: uint16(25588), + 72: uint16(25578), + 73: uint16(25563), + 74: uint16(25682), + 75: uint16(25562), + 76: uint16(25593), + 77: uint16(25950), + 78: uint16(25958), + 79: uint16(25954), + 80: uint16(25955), + 81: uint16(26001), + 82: uint16(26000), + 83: uint16(26031), + 84: uint16(26222), + 85: uint16(26224), + 86: uint16(26228), + 87: uint16(26230), + 88: uint16(26223), + 89: uint16(26257), + 90: uint16(26234), + 91: uint16(26238), + 92: uint16(26231), + 93: uint16(26366), + 94: uint16(26367), + 95: uint16(26399), + 96: uint16(26397), + 97: uint16(26874), + 98: uint16(26837), + 99: uint16(26848), + 100: uint16(26840), + 101: uint16(26839), + 102: uint16(26885), + 103: uint16(26847), + 104: uint16(26869), + 105: uint16(26862), + 106: uint16(26855), + 107: uint16(26873), + 108: uint16(26834), + 109: uint16(26866), + 110: uint16(26851), + 111: uint16(26827), + 112: uint16(26829), + 113: uint16(26893), + 114: uint16(26898), + 115: uint16(26894), + 116: uint16(26825), + 117: uint16(26842), + 118: uint16(26990), + 119: uint16(26875), + 120: uint16(27454), + 121: uint16(27450), + 122: uint16(27453), + 123: uint16(27544), + 124: uint16(27542), + 125: uint16(27580), + 126: uint16(27631), + 127: uint16(27694), + 128: uint16(27695), + 129: uint16(27692), + 130: uint16(28207), + 131: uint16(28216), + 132: uint16(28244), + 133: uint16(28193), + 134: uint16(28210), + 135: uint16(28263), + 136: uint16(28234), + 137: uint16(28192), + 138: uint16(28197), + 139: uint16(28195), + 140: uint16(28187), + 141: uint16(28251), + 142: uint16(28248), + 143: uint16(28196), + 144: uint16(28246), + 145: uint16(28270), + 146: uint16(28205), + 147: uint16(28198), + 148: uint16(28271), + 149: uint16(28212), + 150: uint16(28237), + 151: uint16(28218), + 152: uint16(28204), + 153: uint16(28227), + 154: uint16(28189), + 155: uint16(28222), + 156: uint16(28363), + }, + 20: { + 0: uint16(28297), + 1: uint16(28185), + 2: uint16(28238), + 3: uint16(28259), + 4: uint16(28228), + 5: uint16(28274), + 6: uint16(28265), + 7: uint16(28255), + 8: uint16(28953), + 9: uint16(28954), + 10: uint16(28966), + 11: uint16(28976), + 12: uint16(28961), + 13: uint16(28982), + 14: uint16(29038), + 15: uint16(28956), + 16: uint16(29260), + 17: uint16(29316), + 18: uint16(29312), + 19: uint16(29494), + 20: uint16(29477), + 21: uint16(29492), + 22: uint16(29481), + 23: uint16(29754), + 24: uint16(29738), + 25: uint16(29747), + 26: uint16(29730), + 27: uint16(29733), + 28: uint16(29749), + 29: uint16(29750), + 30: uint16(29748), + 31: uint16(29743), + 32: uint16(29723), + 33: uint16(29734), + 34: uint16(29736), + 35: uint16(29989), + 36: uint16(29990), + 37: uint16(30059), + 38: uint16(30058), + 39: uint16(30178), + 40: uint16(30171), + 41: uint16(30179), + 42: uint16(30169), + 43: uint16(30168), + 44: uint16(30174), + 45: uint16(30176), + 46: uint16(30331), + 47: uint16(30332), + 48: uint16(30358), + 49: uint16(30355), + 50: uint16(30388), + 51: uint16(30428), + 52: uint16(30543), + 53: uint16(30701), + 54: uint16(30813), + 55: uint16(30828), + 56: uint16(30831), + 57: uint16(31245), + 58: uint16(31240), + 59: uint16(31243), + 60: uint16(31237), + 61: uint16(31232), + 62: uint16(31384), + 63: uint16(31383), + 64: uint16(31382), + 65: uint16(31461), + 66: uint16(31459), + 67: uint16(31561), + 68: uint16(31574), + 69: uint16(31558), + 70: uint16(31568), + 71: uint16(31570), + 72: uint16(31572), + 73: uint16(31565), + 74: uint16(31563), + 75: uint16(31567), + 76: uint16(31569), + 77: uint16(31903), + 78: uint16(31909), + 79: uint16(32094), + 80: uint16(32080), + 81: uint16(32104), + 82: uint16(32085), + 83: uint16(32043), + 84: uint16(32110), + 85: uint16(32114), + 86: uint16(32097), + 87: uint16(32102), + 88: uint16(32098), + 89: uint16(32112), + 90: uint16(32115), + 91: uint16(21892), + 92: uint16(32724), + 93: uint16(32725), + 94: uint16(32779), + 95: uint16(32850), + 96: uint16(32901), + 97: uint16(33109), + 98: uint16(33108), + 99: uint16(33099), + 100: uint16(33105), + 101: uint16(33102), + 102: uint16(33081), + 103: uint16(33094), + 104: uint16(33086), + 105: uint16(33100), + 106: uint16(33107), + 107: uint16(33140), + 108: uint16(33298), + 109: uint16(33308), + 110: uint16(33769), + 111: uint16(33795), + 112: uint16(33784), + 113: uint16(33805), + 114: uint16(33760), + 115: uint16(33733), + 116: uint16(33803), + 117: uint16(33729), + 118: uint16(33775), + 119: uint16(33777), + 120: uint16(33780), + 121: uint16(33879), + 122: uint16(33802), + 123: uint16(33776), + 124: uint16(33804), + 125: uint16(33740), + 126: uint16(33789), + 127: uint16(33778), + 128: uint16(33738), + 129: uint16(33848), + 130: uint16(33806), + 131: uint16(33796), + 132: uint16(33756), + 133: uint16(33799), + 134: uint16(33748), + 135: uint16(33759), + 136: uint16(34395), + 137: uint16(34527), + 138: uint16(34521), + 139: uint16(34541), + 140: uint16(34516), + 141: uint16(34523), + 142: uint16(34532), + 143: uint16(34512), + 144: uint16(34526), + 145: uint16(34903), + 146: uint16(35009), + 147: uint16(35010), + 148: uint16(34993), + 149: uint16(35203), + 150: uint16(35222), + 151: uint16(35387), + 152: uint16(35424), + 153: uint16(35413), + 154: uint16(35422), + 155: uint16(35388), + 156: uint16(35393), + }, + 21: { + 0: uint16(35412), + 1: uint16(35419), + 2: uint16(35408), + 3: uint16(35398), + 4: uint16(35380), + 5: uint16(35386), + 6: uint16(35382), + 7: uint16(35414), + 8: uint16(35937), + 9: uint16(35970), + 10: uint16(36015), + 11: uint16(36028), + 12: uint16(36019), + 13: uint16(36029), + 14: uint16(36033), + 15: uint16(36027), + 16: uint16(36032), + 17: uint16(36020), + 18: uint16(36023), + 19: uint16(36022), + 20: uint16(36031), + 21: uint16(36024), + 22: uint16(36234), + 23: uint16(36229), + 24: uint16(36225), + 25: uint16(36302), + 26: uint16(36317), + 27: uint16(36299), + 28: uint16(36314), + 29: uint16(36305), + 30: uint16(36300), + 31: uint16(36315), + 32: uint16(36294), + 33: uint16(36603), + 34: uint16(36600), + 35: uint16(36604), + 36: uint16(36764), + 37: uint16(36910), + 38: uint16(36917), + 39: uint16(36913), + 40: uint16(36920), + 41: uint16(36914), + 42: uint16(36918), + 43: uint16(37122), + 44: uint16(37109), + 45: uint16(37129), + 46: uint16(37118), + 47: uint16(37219), + 48: uint16(37221), + 49: uint16(37327), + 50: uint16(37396), + 51: uint16(37397), + 52: uint16(37411), + 53: uint16(37385), + 54: uint16(37406), + 55: uint16(37389), + 56: uint16(37392), + 57: uint16(37383), + 58: uint16(37393), + 59: uint16(38292), + 60: uint16(38287), + 61: uint16(38283), + 62: uint16(38289), + 63: uint16(38291), + 64: uint16(38290), + 65: uint16(38286), + 66: uint16(38538), + 67: uint16(38542), + 68: uint16(38539), + 69: uint16(38525), + 70: uint16(38533), + 71: uint16(38534), + 72: uint16(38541), + 73: uint16(38514), + 74: uint16(38532), + 75: uint16(38593), + 76: uint16(38597), + 77: uint16(38596), + 78: uint16(38598), + 79: uint16(38599), + 80: uint16(38639), + 81: uint16(38642), + 82: uint16(38860), + 83: uint16(38917), + 84: uint16(38918), + 85: uint16(38920), + 86: uint16(39143), + 87: uint16(39146), + 88: uint16(39151), + 89: uint16(39145), + 90: uint16(39154), + 91: uint16(39149), + 92: uint16(39342), + 93: uint16(39341), + 94: uint16(40643), + 95: uint16(40653), + 96: uint16(40657), + 97: uint16(20098), + 98: uint16(20653), + 99: uint16(20661), + 100: uint16(20658), + 101: uint16(20659), + 102: uint16(20677), + 103: uint16(20670), + 104: uint16(20652), + 105: uint16(20663), + 106: uint16(20667), + 107: uint16(20655), + 108: uint16(20679), + 109: uint16(21119), + 110: uint16(21111), + 111: uint16(21117), + 112: uint16(21215), + 113: uint16(21222), + 114: uint16(21220), + 115: uint16(21218), + 116: uint16(21219), + 117: uint16(21295), + 118: uint16(21983), + 119: uint16(21992), + 120: uint16(21971), + 121: uint16(21990), + 122: uint16(21966), + 123: uint16(21980), + 124: uint16(21959), + 125: uint16(21969), + 126: uint16(21987), + 127: uint16(21988), + 128: uint16(21999), + 129: uint16(21978), + 130: uint16(21985), + 131: uint16(21957), + 132: uint16(21958), + 133: uint16(21989), + 134: uint16(21961), + 135: uint16(22290), + 136: uint16(22291), + 137: uint16(22622), + 138: uint16(22609), + 139: uint16(22616), + 140: uint16(22615), + 141: uint16(22618), + 142: uint16(22612), + 143: uint16(22635), + 144: uint16(22604), + 145: uint16(22637), + 146: uint16(22602), + 147: uint16(22626), + 148: uint16(22610), + 149: uint16(22603), + 150: uint16(22887), + 151: uint16(23233), + 152: uint16(23241), + 153: uint16(23244), + 154: uint16(23230), + 155: uint16(23229), + 156: uint16(23228), + }, + 22: { + 0: uint16(23219), + 1: uint16(23234), + 2: uint16(23218), + 3: uint16(23913), + 4: uint16(23919), + 5: uint16(24140), + 6: uint16(24185), + 7: uint16(24265), + 8: uint16(24264), + 9: uint16(24338), + 10: uint16(24409), + 11: uint16(24492), + 12: uint16(24494), + 13: uint16(24858), + 14: uint16(24847), + 15: uint16(24904), + 16: uint16(24863), + 17: uint16(24819), + 18: uint16(24859), + 19: uint16(24825), + 20: uint16(24833), + 21: uint16(24840), + 22: uint16(24910), + 23: uint16(24908), + 24: uint16(24900), + 25: uint16(24909), + 26: uint16(24894), + 27: uint16(24884), + 28: uint16(24871), + 29: uint16(24845), + 30: uint16(24838), + 31: uint16(24887), + 32: uint16(25121), + 33: uint16(25122), + 34: uint16(25619), + 35: uint16(25662), + 36: uint16(25630), + 37: uint16(25642), + 38: uint16(25645), + 39: uint16(25661), + 40: uint16(25644), + 41: uint16(25615), + 42: uint16(25628), + 43: uint16(25620), + 44: uint16(25613), + 45: uint16(25654), + 46: uint16(25622), + 47: uint16(25623), + 48: uint16(25606), + 49: uint16(25964), + 50: uint16(26015), + 51: uint16(26032), + 52: uint16(26263), + 53: uint16(26249), + 54: uint16(26247), + 55: uint16(26248), + 56: uint16(26262), + 57: uint16(26244), + 58: uint16(26264), + 59: uint16(26253), + 60: uint16(26371), + 61: uint16(27028), + 62: uint16(26989), + 63: uint16(26970), + 64: uint16(26999), + 65: uint16(26976), + 66: uint16(26964), + 67: uint16(26997), + 68: uint16(26928), + 69: uint16(27010), + 70: uint16(26954), + 71: uint16(26984), + 72: uint16(26987), + 73: uint16(26974), + 74: uint16(26963), + 75: uint16(27001), + 76: uint16(27014), + 77: uint16(26973), + 78: uint16(26979), + 79: uint16(26971), + 80: uint16(27463), + 81: uint16(27506), + 82: uint16(27584), + 83: uint16(27583), + 84: uint16(27603), + 85: uint16(27645), + 86: uint16(28322), + 87: uint16(28335), + 88: uint16(28371), + 89: uint16(28342), + 90: uint16(28354), + 91: uint16(28304), + 92: uint16(28317), + 93: uint16(28359), + 94: uint16(28357), + 95: uint16(28325), + 96: uint16(28312), + 97: uint16(28348), + 98: uint16(28346), + 99: uint16(28331), + 100: uint16(28369), + 101: uint16(28310), + 102: uint16(28316), + 103: uint16(28356), + 104: uint16(28372), + 105: uint16(28330), + 106: uint16(28327), + 107: uint16(28340), + 108: uint16(29006), + 109: uint16(29017), + 110: uint16(29033), + 111: uint16(29028), + 112: uint16(29001), + 113: uint16(29031), + 114: uint16(29020), + 115: uint16(29036), + 116: uint16(29030), + 117: uint16(29004), + 118: uint16(29029), + 119: uint16(29022), + 120: uint16(28998), + 121: uint16(29032), + 122: uint16(29014), + 123: uint16(29242), + 124: uint16(29266), + 125: uint16(29495), + 126: uint16(29509), + 127: uint16(29503), + 128: uint16(29502), + 129: uint16(29807), + 130: uint16(29786), + 131: uint16(29781), + 132: uint16(29791), + 133: uint16(29790), + 134: uint16(29761), + 135: uint16(29759), + 136: uint16(29785), + 137: uint16(29787), + 138: uint16(29788), + 139: uint16(30070), + 140: uint16(30072), + 141: uint16(30208), + 142: uint16(30192), + 143: uint16(30209), + 144: uint16(30194), + 145: uint16(30193), + 146: uint16(30202), + 147: uint16(30207), + 148: uint16(30196), + 149: uint16(30195), + 150: uint16(30430), + 151: uint16(30431), + 152: uint16(30555), + 153: uint16(30571), + 154: uint16(30566), + 155: uint16(30558), + 156: uint16(30563), + }, + 23: { + 0: uint16(30585), + 1: uint16(30570), + 2: uint16(30572), + 3: uint16(30556), + 4: uint16(30565), + 5: uint16(30568), + 6: uint16(30562), + 7: uint16(30702), + 8: uint16(30862), + 9: uint16(30896), + 10: uint16(30871), + 11: uint16(30872), + 12: uint16(30860), + 13: uint16(30857), + 14: uint16(30844), + 15: uint16(30865), + 16: uint16(30867), + 17: uint16(30847), + 18: uint16(31098), + 19: uint16(31103), + 20: uint16(31105), + 21: uint16(33836), + 22: uint16(31165), + 23: uint16(31260), + 24: uint16(31258), + 25: uint16(31264), + 26: uint16(31252), + 27: uint16(31263), + 28: uint16(31262), + 29: uint16(31391), + 30: uint16(31392), + 31: uint16(31607), + 32: uint16(31680), + 33: uint16(31584), + 34: uint16(31598), + 35: uint16(31591), + 36: uint16(31921), + 37: uint16(31923), + 38: uint16(31925), + 39: uint16(32147), + 40: uint16(32121), + 41: uint16(32145), + 42: uint16(32129), + 43: uint16(32143), + 44: uint16(32091), + 45: uint16(32622), + 46: uint16(32617), + 47: uint16(32618), + 48: uint16(32626), + 49: uint16(32681), + 50: uint16(32680), + 51: uint16(32676), + 52: uint16(32854), + 53: uint16(32856), + 54: uint16(32902), + 55: uint16(32900), + 56: uint16(33137), + 57: uint16(33136), + 58: uint16(33144), + 59: uint16(33125), + 60: uint16(33134), + 61: uint16(33139), + 62: uint16(33131), + 63: uint16(33145), + 64: uint16(33146), + 65: uint16(33126), + 66: uint16(33285), + 67: uint16(33351), + 68: uint16(33922), + 69: uint16(33911), + 70: uint16(33853), + 71: uint16(33841), + 72: uint16(33909), + 73: uint16(33894), + 74: uint16(33899), + 75: uint16(33865), + 76: uint16(33900), + 77: uint16(33883), + 78: uint16(33852), + 79: uint16(33845), + 80: uint16(33889), + 81: uint16(33891), + 82: uint16(33897), + 83: uint16(33901), + 84: uint16(33862), + 85: uint16(34398), + 86: uint16(34396), + 87: uint16(34399), + 88: uint16(34553), + 89: uint16(34579), + 90: uint16(34568), + 91: uint16(34567), + 92: uint16(34560), + 93: uint16(34558), + 94: uint16(34555), + 95: uint16(34562), + 96: uint16(34563), + 97: uint16(34566), + 98: uint16(34570), + 99: uint16(34905), + 100: uint16(35039), + 101: uint16(35028), + 102: uint16(35033), + 103: uint16(35036), + 104: uint16(35032), + 105: uint16(35037), + 106: uint16(35041), + 107: uint16(35018), + 108: uint16(35029), + 109: uint16(35026), + 110: uint16(35228), + 111: uint16(35299), + 112: uint16(35435), + 113: uint16(35442), + 114: uint16(35443), + 115: uint16(35430), + 116: uint16(35433), + 117: uint16(35440), + 118: uint16(35463), + 119: uint16(35452), + 120: uint16(35427), + 121: uint16(35488), + 122: uint16(35441), + 123: uint16(35461), + 124: uint16(35437), + 125: uint16(35426), + 126: uint16(35438), + 127: uint16(35436), + 128: uint16(35449), + 129: uint16(35451), + 130: uint16(35390), + 131: uint16(35432), + 132: uint16(35938), + 133: uint16(35978), + 134: uint16(35977), + 135: uint16(36042), + 136: uint16(36039), + 137: uint16(36040), + 138: uint16(36036), + 139: uint16(36018), + 140: uint16(36035), + 141: uint16(36034), + 142: uint16(36037), + 143: uint16(36321), + 144: uint16(36319), + 145: uint16(36328), + 146: uint16(36335), + 147: uint16(36339), + 148: uint16(36346), + 149: uint16(36330), + 150: uint16(36324), + 151: uint16(36326), + 152: uint16(36530), + 153: uint16(36611), + 154: uint16(36617), + 155: uint16(36606), + 156: uint16(36618), + }, + 24: { + 0: uint16(36767), + 1: uint16(36786), + 2: uint16(36939), + 3: uint16(36938), + 4: uint16(36947), + 5: uint16(36930), + 6: uint16(36948), + 7: uint16(36924), + 8: uint16(36949), + 9: uint16(36944), + 10: uint16(36935), + 11: uint16(36943), + 12: uint16(36942), + 13: uint16(36941), + 14: uint16(36945), + 15: uint16(36926), + 16: uint16(36929), + 17: uint16(37138), + 18: uint16(37143), + 19: uint16(37228), + 20: uint16(37226), + 21: uint16(37225), + 22: uint16(37321), + 23: uint16(37431), + 24: uint16(37463), + 25: uint16(37432), + 26: uint16(37437), + 27: uint16(37440), + 28: uint16(37438), + 29: uint16(37467), + 30: uint16(37451), + 31: uint16(37476), + 32: uint16(37457), + 33: uint16(37428), + 34: uint16(37449), + 35: uint16(37453), + 36: uint16(37445), + 37: uint16(37433), + 38: uint16(37439), + 39: uint16(37466), + 40: uint16(38296), + 41: uint16(38552), + 42: uint16(38548), + 43: uint16(38549), + 44: uint16(38605), + 45: uint16(38603), + 46: uint16(38601), + 47: uint16(38602), + 48: uint16(38647), + 49: uint16(38651), + 50: uint16(38649), + 51: uint16(38646), + 52: uint16(38742), + 53: uint16(38772), + 54: uint16(38774), + 55: uint16(38928), + 56: uint16(38929), + 57: uint16(38931), + 58: uint16(38922), + 59: uint16(38930), + 60: uint16(38924), + 61: uint16(39164), + 62: uint16(39156), + 63: uint16(39165), + 64: uint16(39166), + 65: uint16(39347), + 66: uint16(39345), + 67: uint16(39348), + 68: uint16(39649), + 69: uint16(40169), + 70: uint16(40578), + 71: uint16(40718), + 72: uint16(40723), + 73: uint16(40736), + 74: uint16(20711), + 75: uint16(20718), + 76: uint16(20709), + 77: uint16(20694), + 78: uint16(20717), + 79: uint16(20698), + 80: uint16(20693), + 81: uint16(20687), + 82: uint16(20689), + 83: uint16(20721), + 84: uint16(20686), + 85: uint16(20713), + 86: uint16(20834), + 87: uint16(20979), + 88: uint16(21123), + 89: uint16(21122), + 90: uint16(21297), + 91: uint16(21421), + 92: uint16(22014), + 93: uint16(22016), + 94: uint16(22043), + 95: uint16(22039), + 96: uint16(22013), + 97: uint16(22036), + 98: uint16(22022), + 99: uint16(22025), + 100: uint16(22029), + 101: uint16(22030), + 102: uint16(22007), + 103: uint16(22038), + 104: uint16(22047), + 105: uint16(22024), + 106: uint16(22032), + 107: uint16(22006), + 108: uint16(22296), + 109: uint16(22294), + 110: uint16(22645), + 111: uint16(22654), + 112: uint16(22659), + 113: uint16(22675), + 114: uint16(22666), + 115: uint16(22649), + 116: uint16(22661), + 117: uint16(22653), + 118: uint16(22781), + 119: uint16(22821), + 120: uint16(22818), + 121: uint16(22820), + 122: uint16(22890), + 123: uint16(22889), + 124: uint16(23265), + 125: uint16(23270), + 126: uint16(23273), + 127: uint16(23255), + 128: uint16(23254), + 129: uint16(23256), + 130: uint16(23267), + 131: uint16(23413), + 132: uint16(23518), + 133: uint16(23527), + 134: uint16(23521), + 135: uint16(23525), + 136: uint16(23526), + 137: uint16(23528), + 138: uint16(23522), + 139: uint16(23524), + 140: uint16(23519), + 141: uint16(23565), + 142: uint16(23650), + 143: uint16(23940), + 144: uint16(23943), + 145: uint16(24155), + 146: uint16(24163), + 147: uint16(24149), + 148: uint16(24151), + 149: uint16(24148), + 150: uint16(24275), + 151: uint16(24278), + 152: uint16(24330), + 153: uint16(24390), + 154: uint16(24432), + 155: uint16(24505), + 156: uint16(24903), + }, + 25: { + 0: uint16(24895), + 1: uint16(24907), + 2: uint16(24951), + 3: uint16(24930), + 4: uint16(24931), + 5: uint16(24927), + 6: uint16(24922), + 7: uint16(24920), + 8: uint16(24949), + 9: uint16(25130), + 10: uint16(25735), + 11: uint16(25688), + 12: uint16(25684), + 13: uint16(25764), + 14: uint16(25720), + 15: uint16(25695), + 16: uint16(25722), + 17: uint16(25681), + 18: uint16(25703), + 19: uint16(25652), + 20: uint16(25709), + 21: uint16(25723), + 22: uint16(25970), + 23: uint16(26017), + 24: uint16(26071), + 25: uint16(26070), + 26: uint16(26274), + 27: uint16(26280), + 28: uint16(26269), + 29: uint16(27036), + 30: uint16(27048), + 31: uint16(27029), + 32: uint16(27073), + 33: uint16(27054), + 34: uint16(27091), + 35: uint16(27083), + 36: uint16(27035), + 37: uint16(27063), + 38: uint16(27067), + 39: uint16(27051), + 40: uint16(27060), + 41: uint16(27088), + 42: uint16(27085), + 43: uint16(27053), + 44: uint16(27084), + 45: uint16(27046), + 46: uint16(27075), + 47: uint16(27043), + 48: uint16(27465), + 49: uint16(27468), + 50: uint16(27699), + 51: uint16(28467), + 52: uint16(28436), + 53: uint16(28414), + 54: uint16(28435), + 55: uint16(28404), + 56: uint16(28457), + 57: uint16(28478), + 58: uint16(28448), + 59: uint16(28460), + 60: uint16(28431), + 61: uint16(28418), + 62: uint16(28450), + 63: uint16(28415), + 64: uint16(28399), + 65: uint16(28422), + 66: uint16(28465), + 67: uint16(28472), + 68: uint16(28466), + 69: uint16(28451), + 70: uint16(28437), + 71: uint16(28459), + 72: uint16(28463), + 73: uint16(28552), + 74: uint16(28458), + 75: uint16(28396), + 76: uint16(28417), + 77: uint16(28402), + 78: uint16(28364), + 79: uint16(28407), + 80: uint16(29076), + 81: uint16(29081), + 82: uint16(29053), + 83: uint16(29066), + 84: uint16(29060), + 85: uint16(29074), + 86: uint16(29246), + 87: uint16(29330), + 88: uint16(29334), + 89: uint16(29508), + 90: uint16(29520), + 91: uint16(29796), + 92: uint16(29795), + 93: uint16(29802), + 94: uint16(29808), + 95: uint16(29805), + 96: uint16(29956), + 97: uint16(30097), + 98: uint16(30247), + 99: uint16(30221), + 100: uint16(30219), + 101: uint16(30217), + 102: uint16(30227), + 103: uint16(30433), + 104: uint16(30435), + 105: uint16(30596), + 106: uint16(30589), + 107: uint16(30591), + 108: uint16(30561), + 109: uint16(30913), + 110: uint16(30879), + 111: uint16(30887), + 112: uint16(30899), + 113: uint16(30889), + 114: uint16(30883), + 115: uint16(31118), + 116: uint16(31119), + 117: uint16(31117), + 118: uint16(31278), + 119: uint16(31281), + 120: uint16(31402), + 121: uint16(31401), + 122: uint16(31469), + 123: uint16(31471), + 124: uint16(31649), + 125: uint16(31637), + 126: uint16(31627), + 127: uint16(31605), + 128: uint16(31639), + 129: uint16(31645), + 130: uint16(31636), + 131: uint16(31631), + 132: uint16(31672), + 133: uint16(31623), + 134: uint16(31620), + 135: uint16(31929), + 136: uint16(31933), + 137: uint16(31934), + 138: uint16(32187), + 139: uint16(32176), + 140: uint16(32156), + 141: uint16(32189), + 142: uint16(32190), + 143: uint16(32160), + 144: uint16(32202), + 145: uint16(32180), + 146: uint16(32178), + 147: uint16(32177), + 148: uint16(32186), + 149: uint16(32162), + 150: uint16(32191), + 151: uint16(32181), + 152: uint16(32184), + 153: uint16(32173), + 154: uint16(32210), + 155: uint16(32199), + 156: uint16(32172), + }, + 26: { + 0: uint16(32624), + 1: uint16(32736), + 2: uint16(32737), + 3: uint16(32735), + 4: uint16(32862), + 5: uint16(32858), + 6: uint16(32903), + 7: uint16(33104), + 8: uint16(33152), + 9: uint16(33167), + 10: uint16(33160), + 11: uint16(33162), + 12: uint16(33151), + 13: uint16(33154), + 14: uint16(33255), + 15: uint16(33274), + 16: uint16(33287), + 17: uint16(33300), + 18: uint16(33310), + 19: uint16(33355), + 20: uint16(33993), + 21: uint16(33983), + 22: uint16(33990), + 23: uint16(33988), + 24: uint16(33945), + 25: uint16(33950), + 26: uint16(33970), + 27: uint16(33948), + 28: uint16(33995), + 29: uint16(33976), + 30: uint16(33984), + 31: uint16(34003), + 32: uint16(33936), + 33: uint16(33980), + 34: uint16(34001), + 35: uint16(33994), + 36: uint16(34623), + 37: uint16(34588), + 38: uint16(34619), + 39: uint16(34594), + 40: uint16(34597), + 41: uint16(34612), + 42: uint16(34584), + 43: uint16(34645), + 44: uint16(34615), + 45: uint16(34601), + 46: uint16(35059), + 47: uint16(35074), + 48: uint16(35060), + 49: uint16(35065), + 50: uint16(35064), + 51: uint16(35069), + 52: uint16(35048), + 53: uint16(35098), + 54: uint16(35055), + 55: uint16(35494), + 56: uint16(35468), + 57: uint16(35486), + 58: uint16(35491), + 59: uint16(35469), + 60: uint16(35489), + 61: uint16(35475), + 62: uint16(35492), + 63: uint16(35498), + 64: uint16(35493), + 65: uint16(35496), + 66: uint16(35480), + 67: uint16(35473), + 68: uint16(35482), + 69: uint16(35495), + 70: uint16(35946), + 71: uint16(35981), + 72: uint16(35980), + 73: uint16(36051), + 74: uint16(36049), + 75: uint16(36050), + 76: uint16(36203), + 77: uint16(36249), + 78: uint16(36245), + 79: uint16(36348), + 80: uint16(36628), + 81: uint16(36626), + 82: uint16(36629), + 83: uint16(36627), + 84: uint16(36771), + 85: uint16(36960), + 86: uint16(36952), + 87: uint16(36956), + 88: uint16(36963), + 89: uint16(36953), + 90: uint16(36958), + 91: uint16(36962), + 92: uint16(36957), + 93: uint16(36955), + 94: uint16(37145), + 95: uint16(37144), + 96: uint16(37150), + 97: uint16(37237), + 98: uint16(37240), + 99: uint16(37239), + 100: uint16(37236), + 101: uint16(37496), + 102: uint16(37504), + 103: uint16(37509), + 104: uint16(37528), + 105: uint16(37526), + 106: uint16(37499), + 107: uint16(37523), + 108: uint16(37532), + 109: uint16(37544), + 110: uint16(37500), + 111: uint16(37521), + 112: uint16(38305), + 113: uint16(38312), + 114: uint16(38313), + 115: uint16(38307), + 116: uint16(38309), + 117: uint16(38308), + 118: uint16(38553), + 119: uint16(38556), + 120: uint16(38555), + 121: uint16(38604), + 122: uint16(38610), + 123: uint16(38656), + 124: uint16(38780), + 125: uint16(38789), + 126: uint16(38902), + 127: uint16(38935), + 128: uint16(38936), + 129: uint16(39087), + 130: uint16(39089), + 131: uint16(39171), + 132: uint16(39173), + 133: uint16(39180), + 134: uint16(39177), + 135: uint16(39361), + 136: uint16(39599), + 137: uint16(39600), + 138: uint16(39654), + 139: uint16(39745), + 140: uint16(39746), + 141: uint16(40180), + 142: uint16(40182), + 143: uint16(40179), + 144: uint16(40636), + 145: uint16(40763), + 146: uint16(40778), + 147: uint16(20740), + 148: uint16(20736), + 149: uint16(20731), + 150: uint16(20725), + 151: uint16(20729), + 152: uint16(20738), + 153: uint16(20744), + 154: uint16(20745), + 155: uint16(20741), + 156: uint16(20956), + }, + 27: { + 0: uint16(21127), + 1: uint16(21128), + 2: uint16(21129), + 3: uint16(21133), + 4: uint16(21130), + 5: uint16(21232), + 6: uint16(21426), + 7: uint16(22062), + 8: uint16(22075), + 9: uint16(22073), + 10: uint16(22066), + 11: uint16(22079), + 12: uint16(22068), + 13: uint16(22057), + 14: uint16(22099), + 15: uint16(22094), + 16: uint16(22103), + 17: uint16(22132), + 18: uint16(22070), + 19: uint16(22063), + 20: uint16(22064), + 21: uint16(22656), + 22: uint16(22687), + 23: uint16(22686), + 24: uint16(22707), + 25: uint16(22684), + 26: uint16(22702), + 27: uint16(22697), + 28: uint16(22694), + 29: uint16(22893), + 30: uint16(23305), + 31: uint16(23291), + 32: uint16(23307), + 33: uint16(23285), + 34: uint16(23308), + 35: uint16(23304), + 36: uint16(23534), + 37: uint16(23532), + 38: uint16(23529), + 39: uint16(23531), + 40: uint16(23652), + 41: uint16(23653), + 42: uint16(23965), + 43: uint16(23956), + 44: uint16(24162), + 45: uint16(24159), + 46: uint16(24161), + 47: uint16(24290), + 48: uint16(24282), + 49: uint16(24287), + 50: uint16(24285), + 51: uint16(24291), + 52: uint16(24288), + 53: uint16(24392), + 54: uint16(24433), + 55: uint16(24503), + 56: uint16(24501), + 57: uint16(24950), + 58: uint16(24935), + 59: uint16(24942), + 60: uint16(24925), + 61: uint16(24917), + 62: uint16(24962), + 63: uint16(24956), + 64: uint16(24944), + 65: uint16(24939), + 66: uint16(24958), + 67: uint16(24999), + 68: uint16(24976), + 69: uint16(25003), + 70: uint16(24974), + 71: uint16(25004), + 72: uint16(24986), + 73: uint16(24996), + 74: uint16(24980), + 75: uint16(25006), + 76: uint16(25134), + 77: uint16(25705), + 78: uint16(25711), + 79: uint16(25721), + 80: uint16(25758), + 81: uint16(25778), + 82: uint16(25736), + 83: uint16(25744), + 84: uint16(25776), + 85: uint16(25765), + 86: uint16(25747), + 87: uint16(25749), + 88: uint16(25769), + 89: uint16(25746), + 90: uint16(25774), + 91: uint16(25773), + 92: uint16(25771), + 93: uint16(25754), + 94: uint16(25772), + 95: uint16(25753), + 96: uint16(25762), + 97: uint16(25779), + 98: uint16(25973), + 99: uint16(25975), + 100: uint16(25976), + 101: uint16(26286), + 102: uint16(26283), + 103: uint16(26292), + 104: uint16(26289), + 105: uint16(27171), + 106: uint16(27167), + 107: uint16(27112), + 108: uint16(27137), + 109: uint16(27166), + 110: uint16(27161), + 111: uint16(27133), + 112: uint16(27169), + 113: uint16(27155), + 114: uint16(27146), + 115: uint16(27123), + 116: uint16(27138), + 117: uint16(27141), + 118: uint16(27117), + 119: uint16(27153), + 120: uint16(27472), + 121: uint16(27470), + 122: uint16(27556), + 123: uint16(27589), + 124: uint16(27590), + 125: uint16(28479), + 126: uint16(28540), + 127: uint16(28548), + 128: uint16(28497), + 129: uint16(28518), + 130: uint16(28500), + 131: uint16(28550), + 132: uint16(28525), + 133: uint16(28507), + 134: uint16(28536), + 135: uint16(28526), + 136: uint16(28558), + 137: uint16(28538), + 138: uint16(28528), + 139: uint16(28516), + 140: uint16(28567), + 141: uint16(28504), + 142: uint16(28373), + 143: uint16(28527), + 144: uint16(28512), + 145: uint16(28511), + 146: uint16(29087), + 147: uint16(29100), + 148: uint16(29105), + 149: uint16(29096), + 150: uint16(29270), + 151: uint16(29339), + 152: uint16(29518), + 153: uint16(29527), + 154: uint16(29801), + 155: uint16(29835), + 156: uint16(29827), + }, + 28: { + 0: uint16(29822), + 1: uint16(29824), + 2: uint16(30079), + 3: uint16(30240), + 4: uint16(30249), + 5: uint16(30239), + 6: uint16(30244), + 7: uint16(30246), + 8: uint16(30241), + 9: uint16(30242), + 10: uint16(30362), + 11: uint16(30394), + 12: uint16(30436), + 13: uint16(30606), + 14: uint16(30599), + 15: uint16(30604), + 16: uint16(30609), + 17: uint16(30603), + 18: uint16(30923), + 19: uint16(30917), + 20: uint16(30906), + 21: uint16(30922), + 22: uint16(30910), + 23: uint16(30933), + 24: uint16(30908), + 25: uint16(30928), + 26: uint16(31295), + 27: uint16(31292), + 28: uint16(31296), + 29: uint16(31293), + 30: uint16(31287), + 31: uint16(31291), + 32: uint16(31407), + 33: uint16(31406), + 34: uint16(31661), + 35: uint16(31665), + 36: uint16(31684), + 37: uint16(31668), + 38: uint16(31686), + 39: uint16(31687), + 40: uint16(31681), + 41: uint16(31648), + 42: uint16(31692), + 43: uint16(31946), + 44: uint16(32224), + 45: uint16(32244), + 46: uint16(32239), + 47: uint16(32251), + 48: uint16(32216), + 49: uint16(32236), + 50: uint16(32221), + 51: uint16(32232), + 52: uint16(32227), + 53: uint16(32218), + 54: uint16(32222), + 55: uint16(32233), + 56: uint16(32158), + 57: uint16(32217), + 58: uint16(32242), + 59: uint16(32249), + 60: uint16(32629), + 61: uint16(32631), + 62: uint16(32687), + 63: uint16(32745), + 64: uint16(32806), + 65: uint16(33179), + 66: uint16(33180), + 67: uint16(33181), + 68: uint16(33184), + 69: uint16(33178), + 70: uint16(33176), + 71: uint16(34071), + 72: uint16(34109), + 73: uint16(34074), + 74: uint16(34030), + 75: uint16(34092), + 76: uint16(34093), + 77: uint16(34067), + 78: uint16(34065), + 79: uint16(34083), + 80: uint16(34081), + 81: uint16(34068), + 82: uint16(34028), + 83: uint16(34085), + 84: uint16(34047), + 85: uint16(34054), + 86: uint16(34690), + 87: uint16(34676), + 88: uint16(34678), + 89: uint16(34656), + 90: uint16(34662), + 91: uint16(34680), + 92: uint16(34664), + 93: uint16(34649), + 94: uint16(34647), + 95: uint16(34636), + 96: uint16(34643), + 97: uint16(34907), + 98: uint16(34909), + 99: uint16(35088), + 100: uint16(35079), + 101: uint16(35090), + 102: uint16(35091), + 103: uint16(35093), + 104: uint16(35082), + 105: uint16(35516), + 106: uint16(35538), + 107: uint16(35527), + 108: uint16(35524), + 109: uint16(35477), + 110: uint16(35531), + 111: uint16(35576), + 112: uint16(35506), + 113: uint16(35529), + 114: uint16(35522), + 115: uint16(35519), + 116: uint16(35504), + 117: uint16(35542), + 118: uint16(35533), + 119: uint16(35510), + 120: uint16(35513), + 121: uint16(35547), + 122: uint16(35916), + 123: uint16(35918), + 124: uint16(35948), + 125: uint16(36064), + 126: uint16(36062), + 127: uint16(36070), + 128: uint16(36068), + 129: uint16(36076), + 130: uint16(36077), + 131: uint16(36066), + 132: uint16(36067), + 133: uint16(36060), + 134: uint16(36074), + 135: uint16(36065), + 136: uint16(36205), + 137: uint16(36255), + 138: uint16(36259), + 139: uint16(36395), + 140: uint16(36368), + 141: uint16(36381), + 142: uint16(36386), + 143: uint16(36367), + 144: uint16(36393), + 145: uint16(36383), + 146: uint16(36385), + 147: uint16(36382), + 148: uint16(36538), + 149: uint16(36637), + 150: uint16(36635), + 151: uint16(36639), + 152: uint16(36649), + 153: uint16(36646), + 154: uint16(36650), + 155: uint16(36636), + 156: uint16(36638), + }, + 29: { + 0: uint16(36645), + 1: uint16(36969), + 2: uint16(36974), + 3: uint16(36968), + 4: uint16(36973), + 5: uint16(36983), + 6: uint16(37168), + 7: uint16(37165), + 8: uint16(37159), + 9: uint16(37169), + 10: uint16(37255), + 11: uint16(37257), + 12: uint16(37259), + 13: uint16(37251), + 14: uint16(37573), + 15: uint16(37563), + 16: uint16(37559), + 17: uint16(37610), + 18: uint16(37548), + 19: uint16(37604), + 20: uint16(37569), + 21: uint16(37555), + 22: uint16(37564), + 23: uint16(37586), + 24: uint16(37575), + 25: uint16(37616), + 26: uint16(37554), + 27: uint16(38317), + 28: uint16(38321), + 29: uint16(38660), + 30: uint16(38662), + 31: uint16(38663), + 32: uint16(38665), + 33: uint16(38752), + 34: uint16(38797), + 35: uint16(38795), + 36: uint16(38799), + 37: uint16(38945), + 38: uint16(38955), + 39: uint16(38940), + 40: uint16(39091), + 41: uint16(39178), + 42: uint16(39187), + 43: uint16(39186), + 44: uint16(39192), + 45: uint16(39389), + 46: uint16(39376), + 47: uint16(39391), + 48: uint16(39387), + 49: uint16(39377), + 50: uint16(39381), + 51: uint16(39378), + 52: uint16(39385), + 53: uint16(39607), + 54: uint16(39662), + 55: uint16(39663), + 56: uint16(39719), + 57: uint16(39749), + 58: uint16(39748), + 59: uint16(39799), + 60: uint16(39791), + 61: uint16(40198), + 62: uint16(40201), + 63: uint16(40195), + 64: uint16(40617), + 65: uint16(40638), + 66: uint16(40654), + 67: uint16(22696), + 68: uint16(40786), + 69: uint16(20754), + 70: uint16(20760), + 71: uint16(20756), + 72: uint16(20752), + 73: uint16(20757), + 74: uint16(20864), + 75: uint16(20906), + 76: uint16(20957), + 77: uint16(21137), + 78: uint16(21139), + 79: uint16(21235), + 80: uint16(22105), + 81: uint16(22123), + 82: uint16(22137), + 83: uint16(22121), + 84: uint16(22116), + 85: uint16(22136), + 86: uint16(22122), + 87: uint16(22120), + 88: uint16(22117), + 89: uint16(22129), + 90: uint16(22127), + 91: uint16(22124), + 92: uint16(22114), + 93: uint16(22134), + 94: uint16(22721), + 95: uint16(22718), + 96: uint16(22727), + 97: uint16(22725), + 98: uint16(22894), + 99: uint16(23325), + 100: uint16(23348), + 101: uint16(23416), + 102: uint16(23536), + 103: uint16(23566), + 104: uint16(24394), + 105: uint16(25010), + 106: uint16(24977), + 107: uint16(25001), + 108: uint16(24970), + 109: uint16(25037), + 110: uint16(25014), + 111: uint16(25022), + 112: uint16(25034), + 113: uint16(25032), + 114: uint16(25136), + 115: uint16(25797), + 116: uint16(25793), + 117: uint16(25803), + 118: uint16(25787), + 119: uint16(25788), + 120: uint16(25818), + 121: uint16(25796), + 122: uint16(25799), + 123: uint16(25794), + 124: uint16(25805), + 125: uint16(25791), + 126: uint16(25810), + 127: uint16(25812), + 128: uint16(25790), + 129: uint16(25972), + 130: uint16(26310), + 131: uint16(26313), + 132: uint16(26297), + 133: uint16(26308), + 134: uint16(26311), + 135: uint16(26296), + 136: uint16(27197), + 137: uint16(27192), + 138: uint16(27194), + 139: uint16(27225), + 140: uint16(27243), + 141: uint16(27224), + 142: uint16(27193), + 143: uint16(27204), + 144: uint16(27234), + 145: uint16(27233), + 146: uint16(27211), + 147: uint16(27207), + 148: uint16(27189), + 149: uint16(27231), + 150: uint16(27208), + 151: uint16(27481), + 152: uint16(27511), + 153: uint16(27653), + 154: uint16(28610), + 155: uint16(28593), + 156: uint16(28577), + }, + 30: { + 0: uint16(28611), + 1: uint16(28580), + 2: uint16(28609), + 3: uint16(28583), + 4: uint16(28595), + 5: uint16(28608), + 6: uint16(28601), + 7: uint16(28598), + 8: uint16(28582), + 9: uint16(28576), + 10: uint16(28596), + 11: uint16(29118), + 12: uint16(29129), + 13: uint16(29136), + 14: uint16(29138), + 15: uint16(29128), + 16: uint16(29141), + 17: uint16(29113), + 18: uint16(29134), + 19: uint16(29145), + 20: uint16(29148), + 21: uint16(29123), + 22: uint16(29124), + 23: uint16(29544), + 24: uint16(29852), + 25: uint16(29859), + 26: uint16(29848), + 27: uint16(29855), + 28: uint16(29854), + 29: uint16(29922), + 30: uint16(29964), + 31: uint16(29965), + 32: uint16(30260), + 33: uint16(30264), + 34: uint16(30266), + 35: uint16(30439), + 36: uint16(30437), + 37: uint16(30624), + 38: uint16(30622), + 39: uint16(30623), + 40: uint16(30629), + 41: uint16(30952), + 42: uint16(30938), + 43: uint16(30956), + 44: uint16(30951), + 45: uint16(31142), + 46: uint16(31309), + 47: uint16(31310), + 48: uint16(31302), + 49: uint16(31308), + 50: uint16(31307), + 51: uint16(31418), + 52: uint16(31705), + 53: uint16(31761), + 54: uint16(31689), + 55: uint16(31716), + 56: uint16(31707), + 57: uint16(31713), + 58: uint16(31721), + 59: uint16(31718), + 60: uint16(31957), + 61: uint16(31958), + 62: uint16(32266), + 63: uint16(32273), + 64: uint16(32264), + 65: uint16(32283), + 66: uint16(32291), + 67: uint16(32286), + 68: uint16(32285), + 69: uint16(32265), + 70: uint16(32272), + 71: uint16(32633), + 72: uint16(32690), + 73: uint16(32752), + 74: uint16(32753), + 75: uint16(32750), + 76: uint16(32808), + 77: uint16(33203), + 78: uint16(33193), + 79: uint16(33192), + 80: uint16(33275), + 81: uint16(33288), + 82: uint16(33368), + 83: uint16(33369), + 84: uint16(34122), + 85: uint16(34137), + 86: uint16(34120), + 87: uint16(34152), + 88: uint16(34153), + 89: uint16(34115), + 90: uint16(34121), + 91: uint16(34157), + 92: uint16(34154), + 93: uint16(34142), + 94: uint16(34691), + 95: uint16(34719), + 96: uint16(34718), + 97: uint16(34722), + 98: uint16(34701), + 99: uint16(34913), + 100: uint16(35114), + 101: uint16(35122), + 102: uint16(35109), + 103: uint16(35115), + 104: uint16(35105), + 105: uint16(35242), + 106: uint16(35238), + 107: uint16(35558), + 108: uint16(35578), + 109: uint16(35563), + 110: uint16(35569), + 111: uint16(35584), + 112: uint16(35548), + 113: uint16(35559), + 114: uint16(35566), + 115: uint16(35582), + 116: uint16(35585), + 117: uint16(35586), + 118: uint16(35575), + 119: uint16(35565), + 120: uint16(35571), + 121: uint16(35574), + 122: uint16(35580), + 123: uint16(35947), + 124: uint16(35949), + 125: uint16(35987), + 126: uint16(36084), + 127: uint16(36420), + 128: uint16(36401), + 129: uint16(36404), + 130: uint16(36418), + 131: uint16(36409), + 132: uint16(36405), + 133: uint16(36667), + 134: uint16(36655), + 135: uint16(36664), + 136: uint16(36659), + 137: uint16(36776), + 138: uint16(36774), + 139: uint16(36981), + 140: uint16(36980), + 141: uint16(36984), + 142: uint16(36978), + 143: uint16(36988), + 144: uint16(36986), + 145: uint16(37172), + 146: uint16(37266), + 147: uint16(37664), + 148: uint16(37686), + 149: uint16(37624), + 150: uint16(37683), + 151: uint16(37679), + 152: uint16(37666), + 153: uint16(37628), + 154: uint16(37675), + 155: uint16(37636), + 156: uint16(37658), + }, + 31: { + 0: uint16(37648), + 1: uint16(37670), + 2: uint16(37665), + 3: uint16(37653), + 4: uint16(37678), + 5: uint16(37657), + 6: uint16(38331), + 7: uint16(38567), + 8: uint16(38568), + 9: uint16(38570), + 10: uint16(38613), + 11: uint16(38670), + 12: uint16(38673), + 13: uint16(38678), + 14: uint16(38669), + 15: uint16(38675), + 16: uint16(38671), + 17: uint16(38747), + 18: uint16(38748), + 19: uint16(38758), + 20: uint16(38808), + 21: uint16(38960), + 22: uint16(38968), + 23: uint16(38971), + 24: uint16(38967), + 25: uint16(38957), + 26: uint16(38969), + 27: uint16(38948), + 28: uint16(39184), + 29: uint16(39208), + 30: uint16(39198), + 31: uint16(39195), + 32: uint16(39201), + 33: uint16(39194), + 34: uint16(39405), + 35: uint16(39394), + 36: uint16(39409), + 37: uint16(39608), + 38: uint16(39612), + 39: uint16(39675), + 40: uint16(39661), + 41: uint16(39720), + 42: uint16(39825), + 43: uint16(40213), + 44: uint16(40227), + 45: uint16(40230), + 46: uint16(40232), + 47: uint16(40210), + 48: uint16(40219), + 49: uint16(40664), + 50: uint16(40660), + 51: uint16(40845), + 52: uint16(40860), + 53: uint16(20778), + 54: uint16(20767), + 55: uint16(20769), + 56: uint16(20786), + 57: uint16(21237), + 58: uint16(22158), + 59: uint16(22144), + 60: uint16(22160), + 61: uint16(22149), + 62: uint16(22151), + 63: uint16(22159), + 64: uint16(22741), + 65: uint16(22739), + 66: uint16(22737), + 67: uint16(22734), + 68: uint16(23344), + 69: uint16(23338), + 70: uint16(23332), + 71: uint16(23418), + 72: uint16(23607), + 73: uint16(23656), + 74: uint16(23996), + 75: uint16(23994), + 76: uint16(23997), + 77: uint16(23992), + 78: uint16(24171), + 79: uint16(24396), + 80: uint16(24509), + 81: uint16(25033), + 82: uint16(25026), + 83: uint16(25031), + 84: uint16(25062), + 85: uint16(25035), + 86: uint16(25138), + 87: uint16(25140), + 88: uint16(25806), + 89: uint16(25802), + 90: uint16(25816), + 91: uint16(25824), + 92: uint16(25840), + 93: uint16(25830), + 94: uint16(25836), + 95: uint16(25841), + 96: uint16(25826), + 97: uint16(25837), + 98: uint16(25986), + 99: uint16(25987), + 100: uint16(26329), + 101: uint16(26326), + 102: uint16(27264), + 103: uint16(27284), + 104: uint16(27268), + 105: uint16(27298), + 106: uint16(27292), + 107: uint16(27355), + 108: uint16(27299), + 109: uint16(27262), + 110: uint16(27287), + 111: uint16(27280), + 112: uint16(27296), + 113: uint16(27484), + 114: uint16(27566), + 115: uint16(27610), + 116: uint16(27656), + 117: uint16(28632), + 118: uint16(28657), + 119: uint16(28639), + 120: uint16(28640), + 121: uint16(28635), + 122: uint16(28644), + 123: uint16(28651), + 124: uint16(28655), + 125: uint16(28544), + 126: uint16(28652), + 127: uint16(28641), + 128: uint16(28649), + 129: uint16(28629), + 130: uint16(28654), + 131: uint16(28656), + 132: uint16(29159), + 133: uint16(29151), + 134: uint16(29166), + 135: uint16(29158), + 136: uint16(29157), + 137: uint16(29165), + 138: uint16(29164), + 139: uint16(29172), + 140: uint16(29152), + 141: uint16(29237), + 142: uint16(29254), + 143: uint16(29552), + 144: uint16(29554), + 145: uint16(29865), + 146: uint16(29872), + 147: uint16(29862), + 148: uint16(29864), + 149: uint16(30278), + 150: uint16(30274), + 151: uint16(30284), + 152: uint16(30442), + 153: uint16(30643), + 154: uint16(30634), + 155: uint16(30640), + 156: uint16(30636), + }, + 32: { + 0: uint16(30631), + 1: uint16(30637), + 2: uint16(30703), + 3: uint16(30967), + 4: uint16(30970), + 5: uint16(30964), + 6: uint16(30959), + 7: uint16(30977), + 8: uint16(31143), + 9: uint16(31146), + 10: uint16(31319), + 11: uint16(31423), + 12: uint16(31751), + 13: uint16(31757), + 14: uint16(31742), + 15: uint16(31735), + 16: uint16(31756), + 17: uint16(31712), + 18: uint16(31968), + 19: uint16(31964), + 20: uint16(31966), + 21: uint16(31970), + 22: uint16(31967), + 23: uint16(31961), + 24: uint16(31965), + 25: uint16(32302), + 26: uint16(32318), + 27: uint16(32326), + 28: uint16(32311), + 29: uint16(32306), + 30: uint16(32323), + 31: uint16(32299), + 32: uint16(32317), + 33: uint16(32305), + 34: uint16(32325), + 35: uint16(32321), + 36: uint16(32308), + 37: uint16(32313), + 38: uint16(32328), + 39: uint16(32309), + 40: uint16(32319), + 41: uint16(32303), + 42: uint16(32580), + 43: uint16(32755), + 44: uint16(32764), + 45: uint16(32881), + 46: uint16(32882), + 47: uint16(32880), + 48: uint16(32879), + 49: uint16(32883), + 50: uint16(33222), + 51: uint16(33219), + 52: uint16(33210), + 53: uint16(33218), + 54: uint16(33216), + 55: uint16(33215), + 56: uint16(33213), + 57: uint16(33225), + 58: uint16(33214), + 59: uint16(33256), + 60: uint16(33289), + 61: uint16(33393), + 62: uint16(34218), + 63: uint16(34180), + 64: uint16(34174), + 65: uint16(34204), + 66: uint16(34193), + 67: uint16(34196), + 68: uint16(34223), + 69: uint16(34203), + 70: uint16(34183), + 71: uint16(34216), + 72: uint16(34186), + 73: uint16(34407), + 74: uint16(34752), + 75: uint16(34769), + 76: uint16(34739), + 77: uint16(34770), + 78: uint16(34758), + 79: uint16(34731), + 80: uint16(34747), + 81: uint16(34746), + 82: uint16(34760), + 83: uint16(34763), + 84: uint16(35131), + 85: uint16(35126), + 86: uint16(35140), + 87: uint16(35128), + 88: uint16(35133), + 89: uint16(35244), + 90: uint16(35598), + 91: uint16(35607), + 92: uint16(35609), + 93: uint16(35611), + 94: uint16(35594), + 95: uint16(35616), + 96: uint16(35613), + 97: uint16(35588), + 98: uint16(35600), + 99: uint16(35905), + 100: uint16(35903), + 101: uint16(35955), + 102: uint16(36090), + 103: uint16(36093), + 104: uint16(36092), + 105: uint16(36088), + 106: uint16(36091), + 107: uint16(36264), + 108: uint16(36425), + 109: uint16(36427), + 110: uint16(36424), + 111: uint16(36426), + 112: uint16(36676), + 113: uint16(36670), + 114: uint16(36674), + 115: uint16(36677), + 116: uint16(36671), + 117: uint16(36991), + 118: uint16(36989), + 119: uint16(36996), + 120: uint16(36993), + 121: uint16(36994), + 122: uint16(36992), + 123: uint16(37177), + 124: uint16(37283), + 125: uint16(37278), + 126: uint16(37276), + 127: uint16(37709), + 128: uint16(37762), + 129: uint16(37672), + 130: uint16(37749), + 131: uint16(37706), + 132: uint16(37733), + 133: uint16(37707), + 134: uint16(37656), + 135: uint16(37758), + 136: uint16(37740), + 137: uint16(37723), + 138: uint16(37744), + 139: uint16(37722), + 140: uint16(37716), + 141: uint16(38346), + 142: uint16(38347), + 143: uint16(38348), + 144: uint16(38344), + 145: uint16(38342), + 146: uint16(38577), + 147: uint16(38584), + 148: uint16(38614), + 149: uint16(38684), + 150: uint16(38686), + 151: uint16(38816), + 152: uint16(38867), + 153: uint16(38982), + 154: uint16(39094), + 155: uint16(39221), + 156: uint16(39425), + }, + 33: { + 0: uint16(39423), + 1: uint16(39854), + 2: uint16(39851), + 3: uint16(39850), + 4: uint16(39853), + 5: uint16(40251), + 6: uint16(40255), + 7: uint16(40587), + 8: uint16(40655), + 9: uint16(40670), + 10: uint16(40668), + 11: uint16(40669), + 12: uint16(40667), + 13: uint16(40766), + 14: uint16(40779), + 15: uint16(21474), + 16: uint16(22165), + 17: uint16(22190), + 18: uint16(22745), + 19: uint16(22744), + 20: uint16(23352), + 21: uint16(24413), + 22: uint16(25059), + 23: uint16(25139), + 24: uint16(25844), + 25: uint16(25842), + 26: uint16(25854), + 27: uint16(25862), + 28: uint16(25850), + 29: uint16(25851), + 30: uint16(25847), + 31: uint16(26039), + 32: uint16(26332), + 33: uint16(26406), + 34: uint16(27315), + 35: uint16(27308), + 36: uint16(27331), + 37: uint16(27323), + 38: uint16(27320), + 39: uint16(27330), + 40: uint16(27310), + 41: uint16(27311), + 42: uint16(27487), + 43: uint16(27512), + 44: uint16(27567), + 45: uint16(28681), + 46: uint16(28683), + 47: uint16(28670), + 48: uint16(28678), + 49: uint16(28666), + 50: uint16(28689), + 51: uint16(28687), + 52: uint16(29179), + 53: uint16(29180), + 54: uint16(29182), + 55: uint16(29176), + 56: uint16(29559), + 57: uint16(29557), + 58: uint16(29863), + 59: uint16(29887), + 60: uint16(29973), + 61: uint16(30294), + 62: uint16(30296), + 63: uint16(30290), + 64: uint16(30653), + 65: uint16(30655), + 66: uint16(30651), + 67: uint16(30652), + 68: uint16(30990), + 69: uint16(31150), + 70: uint16(31329), + 71: uint16(31330), + 72: uint16(31328), + 73: uint16(31428), + 74: uint16(31429), + 75: uint16(31787), + 76: uint16(31783), + 77: uint16(31786), + 78: uint16(31774), + 79: uint16(31779), + 80: uint16(31777), + 81: uint16(31975), + 82: uint16(32340), + 83: uint16(32341), + 84: uint16(32350), + 85: uint16(32346), + 86: uint16(32353), + 87: uint16(32338), + 88: uint16(32345), + 89: uint16(32584), + 90: uint16(32761), + 91: uint16(32763), + 92: uint16(32887), + 93: uint16(32886), + 94: uint16(33229), + 95: uint16(33231), + 96: uint16(33290), + 97: uint16(34255), + 98: uint16(34217), + 99: uint16(34253), + 100: uint16(34256), + 101: uint16(34249), + 102: uint16(34224), + 103: uint16(34234), + 104: uint16(34233), + 105: uint16(34214), + 106: uint16(34799), + 107: uint16(34796), + 108: uint16(34802), + 109: uint16(34784), + 110: uint16(35206), + 111: uint16(35250), + 112: uint16(35316), + 113: uint16(35624), + 114: uint16(35641), + 115: uint16(35628), + 116: uint16(35627), + 117: uint16(35920), + 118: uint16(36101), + 119: uint16(36441), + 120: uint16(36451), + 121: uint16(36454), + 122: uint16(36452), + 123: uint16(36447), + 124: uint16(36437), + 125: uint16(36544), + 126: uint16(36681), + 127: uint16(36685), + 128: uint16(36999), + 129: uint16(36995), + 130: uint16(37000), + 131: uint16(37291), + 132: uint16(37292), + 133: uint16(37328), + 134: uint16(37780), + 135: uint16(37770), + 136: uint16(37782), + 137: uint16(37794), + 138: uint16(37811), + 139: uint16(37806), + 140: uint16(37804), + 141: uint16(37808), + 142: uint16(37784), + 143: uint16(37786), + 144: uint16(37783), + 145: uint16(38356), + 146: uint16(38358), + 147: uint16(38352), + 148: uint16(38357), + 149: uint16(38626), + 150: uint16(38620), + 151: uint16(38617), + 152: uint16(38619), + 153: uint16(38622), + 154: uint16(38692), + 155: uint16(38819), + 156: uint16(38822), + }, + 34: { + 0: uint16(38829), + 1: uint16(38905), + 2: uint16(38989), + 3: uint16(38991), + 4: uint16(38988), + 5: uint16(38990), + 6: uint16(38995), + 7: uint16(39098), + 8: uint16(39230), + 9: uint16(39231), + 10: uint16(39229), + 11: uint16(39214), + 12: uint16(39333), + 13: uint16(39438), + 14: uint16(39617), + 15: uint16(39683), + 16: uint16(39686), + 17: uint16(39759), + 18: uint16(39758), + 19: uint16(39757), + 20: uint16(39882), + 21: uint16(39881), + 22: uint16(39933), + 23: uint16(39880), + 24: uint16(39872), + 25: uint16(40273), + 26: uint16(40285), + 27: uint16(40288), + 28: uint16(40672), + 29: uint16(40725), + 30: uint16(40748), + 31: uint16(20787), + 32: uint16(22181), + 33: uint16(22750), + 34: uint16(22751), + 35: uint16(22754), + 36: uint16(23541), + 37: uint16(40848), + 38: uint16(24300), + 39: uint16(25074), + 40: uint16(25079), + 41: uint16(25078), + 42: uint16(25077), + 43: uint16(25856), + 44: uint16(25871), + 45: uint16(26336), + 46: uint16(26333), + 47: uint16(27365), + 48: uint16(27357), + 49: uint16(27354), + 50: uint16(27347), + 51: uint16(28699), + 52: uint16(28703), + 53: uint16(28712), + 54: uint16(28698), + 55: uint16(28701), + 56: uint16(28693), + 57: uint16(28696), + 58: uint16(29190), + 59: uint16(29197), + 60: uint16(29272), + 61: uint16(29346), + 62: uint16(29560), + 63: uint16(29562), + 64: uint16(29885), + 65: uint16(29898), + 66: uint16(29923), + 67: uint16(30087), + 68: uint16(30086), + 69: uint16(30303), + 70: uint16(30305), + 71: uint16(30663), + 72: uint16(31001), + 73: uint16(31153), + 74: uint16(31339), + 75: uint16(31337), + 76: uint16(31806), + 77: uint16(31807), + 78: uint16(31800), + 79: uint16(31805), + 80: uint16(31799), + 81: uint16(31808), + 82: uint16(32363), + 83: uint16(32365), + 84: uint16(32377), + 85: uint16(32361), + 86: uint16(32362), + 87: uint16(32645), + 88: uint16(32371), + 89: uint16(32694), + 90: uint16(32697), + 91: uint16(32696), + 92: uint16(33240), + 93: uint16(34281), + 94: uint16(34269), + 95: uint16(34282), + 96: uint16(34261), + 97: uint16(34276), + 98: uint16(34277), + 99: uint16(34295), + 100: uint16(34811), + 101: uint16(34821), + 102: uint16(34829), + 103: uint16(34809), + 104: uint16(34814), + 105: uint16(35168), + 106: uint16(35167), + 107: uint16(35158), + 108: uint16(35166), + 109: uint16(35649), + 110: uint16(35676), + 111: uint16(35672), + 112: uint16(35657), + 113: uint16(35674), + 114: uint16(35662), + 115: uint16(35663), + 116: uint16(35654), + 117: uint16(35673), + 118: uint16(36104), + 119: uint16(36106), + 120: uint16(36476), + 121: uint16(36466), + 122: uint16(36487), + 123: uint16(36470), + 124: uint16(36460), + 125: uint16(36474), + 126: uint16(36468), + 127: uint16(36692), + 128: uint16(36686), + 129: uint16(36781), + 130: uint16(37002), + 131: uint16(37003), + 132: uint16(37297), + 133: uint16(37294), + 134: uint16(37857), + 135: uint16(37841), + 136: uint16(37855), + 137: uint16(37827), + 138: uint16(37832), + 139: uint16(37852), + 140: uint16(37853), + 141: uint16(37846), + 142: uint16(37858), + 143: uint16(37837), + 144: uint16(37848), + 145: uint16(37860), + 146: uint16(37847), + 147: uint16(37864), + 148: uint16(38364), + 149: uint16(38580), + 150: uint16(38627), + 151: uint16(38698), + 152: uint16(38695), + 153: uint16(38753), + 154: uint16(38876), + 155: uint16(38907), + 156: uint16(39006), + }, + 35: { + 0: uint16(39000), + 1: uint16(39003), + 2: uint16(39100), + 3: uint16(39237), + 4: uint16(39241), + 5: uint16(39446), + 6: uint16(39449), + 7: uint16(39693), + 8: uint16(39912), + 9: uint16(39911), + 10: uint16(39894), + 11: uint16(39899), + 12: uint16(40329), + 13: uint16(40289), + 14: uint16(40306), + 15: uint16(40298), + 16: uint16(40300), + 17: uint16(40594), + 18: uint16(40599), + 19: uint16(40595), + 20: uint16(40628), + 21: uint16(21240), + 22: uint16(22184), + 23: uint16(22199), + 24: uint16(22198), + 25: uint16(22196), + 26: uint16(22204), + 27: uint16(22756), + 28: uint16(23360), + 29: uint16(23363), + 30: uint16(23421), + 31: uint16(23542), + 32: uint16(24009), + 33: uint16(25080), + 34: uint16(25082), + 35: uint16(25880), + 36: uint16(25876), + 37: uint16(25881), + 38: uint16(26342), + 39: uint16(26407), + 40: uint16(27372), + 41: uint16(28734), + 42: uint16(28720), + 43: uint16(28722), + 44: uint16(29200), + 45: uint16(29563), + 46: uint16(29903), + 47: uint16(30306), + 48: uint16(30309), + 49: uint16(31014), + 50: uint16(31018), + 51: uint16(31020), + 52: uint16(31019), + 53: uint16(31431), + 54: uint16(31478), + 55: uint16(31820), + 56: uint16(31811), + 57: uint16(31821), + 58: uint16(31983), + 59: uint16(31984), + 60: uint16(36782), + 61: uint16(32381), + 62: uint16(32380), + 63: uint16(32386), + 64: uint16(32588), + 65: uint16(32768), + 66: uint16(33242), + 67: uint16(33382), + 68: uint16(34299), + 69: uint16(34297), + 70: uint16(34321), + 71: uint16(34298), + 72: uint16(34310), + 73: uint16(34315), + 74: uint16(34311), + 75: uint16(34314), + 76: uint16(34836), + 77: uint16(34837), + 78: uint16(35172), + 79: uint16(35258), + 80: uint16(35320), + 81: uint16(35696), + 82: uint16(35692), + 83: uint16(35686), + 84: uint16(35695), + 85: uint16(35679), + 86: uint16(35691), + 87: uint16(36111), + 88: uint16(36109), + 89: uint16(36489), + 90: uint16(36481), + 91: uint16(36485), + 92: uint16(36482), + 93: uint16(37300), + 94: uint16(37323), + 95: uint16(37912), + 96: uint16(37891), + 97: uint16(37885), + 98: uint16(38369), + 99: uint16(38704), + 100: uint16(39108), + 101: uint16(39250), + 102: uint16(39249), + 103: uint16(39336), + 104: uint16(39467), + 105: uint16(39472), + 106: uint16(39479), + 107: uint16(39477), + 108: uint16(39955), + 109: uint16(39949), + 110: uint16(40569), + 111: uint16(40629), + 112: uint16(40680), + 113: uint16(40751), + 114: uint16(40799), + 115: uint16(40803), + 116: uint16(40801), + 117: uint16(20791), + 118: uint16(20792), + 119: uint16(22209), + 120: uint16(22208), + 121: uint16(22210), + 122: uint16(22804), + 123: uint16(23660), + 124: uint16(24013), + 125: uint16(25084), + 126: uint16(25086), + 127: uint16(25885), + 128: uint16(25884), + 129: uint16(26005), + 130: uint16(26345), + 131: uint16(27387), + 132: uint16(27396), + 133: uint16(27386), + 134: uint16(27570), + 135: uint16(28748), + 136: uint16(29211), + 137: uint16(29351), + 138: uint16(29910), + 139: uint16(29908), + 140: uint16(30313), + 141: uint16(30675), + 142: uint16(31824), + 143: uint16(32399), + 144: uint16(32396), + 145: uint16(32700), + 146: uint16(34327), + 147: uint16(34349), + 148: uint16(34330), + 149: uint16(34851), + 150: uint16(34850), + 151: uint16(34849), + 152: uint16(34847), + 153: uint16(35178), + 154: uint16(35180), + 155: uint16(35261), + 156: uint16(35700), + }, + 36: { + 0: uint16(35703), + 1: uint16(35709), + 2: uint16(36115), + 3: uint16(36490), + 4: uint16(36493), + 5: uint16(36491), + 6: uint16(36703), + 7: uint16(36783), + 8: uint16(37306), + 9: uint16(37934), + 10: uint16(37939), + 11: uint16(37941), + 12: uint16(37946), + 13: uint16(37944), + 14: uint16(37938), + 15: uint16(37931), + 16: uint16(38370), + 17: uint16(38712), + 18: uint16(38713), + 19: uint16(38706), + 20: uint16(38911), + 21: uint16(39015), + 22: uint16(39013), + 23: uint16(39255), + 24: uint16(39493), + 25: uint16(39491), + 26: uint16(39488), + 27: uint16(39486), + 28: uint16(39631), + 29: uint16(39764), + 30: uint16(39761), + 31: uint16(39981), + 32: uint16(39973), + 33: uint16(40367), + 34: uint16(40372), + 35: uint16(40386), + 36: uint16(40376), + 37: uint16(40605), + 38: uint16(40687), + 39: uint16(40729), + 40: uint16(40796), + 41: uint16(40806), + 42: uint16(40807), + 43: uint16(20796), + 44: uint16(20795), + 45: uint16(22216), + 46: uint16(22218), + 47: uint16(22217), + 48: uint16(23423), + 49: uint16(24020), + 50: uint16(24018), + 51: uint16(24398), + 52: uint16(25087), + 53: uint16(25892), + 54: uint16(27402), + 55: uint16(27489), + 56: uint16(28753), + 57: uint16(28760), + 58: uint16(29568), + 59: uint16(29924), + 60: uint16(30090), + 61: uint16(30318), + 62: uint16(30316), + 63: uint16(31155), + 64: uint16(31840), + 65: uint16(31839), + 66: uint16(32894), + 67: uint16(32893), + 68: uint16(33247), + 69: uint16(35186), + 70: uint16(35183), + 71: uint16(35324), + 72: uint16(35712), + 73: uint16(36118), + 74: uint16(36119), + 75: uint16(36497), + 76: uint16(36499), + 77: uint16(36705), + 78: uint16(37192), + 79: uint16(37956), + 80: uint16(37969), + 81: uint16(37970), + 82: uint16(38717), + 83: uint16(38718), + 84: uint16(38851), + 85: uint16(38849), + 86: uint16(39019), + 87: uint16(39253), + 88: uint16(39509), + 89: uint16(39501), + 90: uint16(39634), + 91: uint16(39706), + 92: uint16(40009), + 93: uint16(39985), + 94: uint16(39998), + 95: uint16(39995), + 96: uint16(40403), + 97: uint16(40407), + 98: uint16(40756), + 99: uint16(40812), + 100: uint16(40810), + 101: uint16(40852), + 102: uint16(22220), + 103: uint16(24022), + 104: uint16(25088), + 105: uint16(25891), + 106: uint16(25899), + 107: uint16(25898), + 108: uint16(26348), + 109: uint16(27408), + 110: uint16(29914), + 111: uint16(31434), + 112: uint16(31844), + 113: uint16(31843), + 114: uint16(31845), + 115: uint16(32403), + 116: uint16(32406), + 117: uint16(32404), + 118: uint16(33250), + 119: uint16(34360), + 120: uint16(34367), + 121: uint16(34865), + 122: uint16(35722), + 123: uint16(37008), + 124: uint16(37007), + 125: uint16(37987), + 126: uint16(37984), + 127: uint16(37988), + 128: uint16(38760), + 129: uint16(39023), + 130: uint16(39260), + 131: uint16(39514), + 132: uint16(39515), + 133: uint16(39511), + 134: uint16(39635), + 135: uint16(39636), + 136: uint16(39633), + 137: uint16(40020), + 138: uint16(40023), + 139: uint16(40022), + 140: uint16(40421), + 141: uint16(40607), + 142: uint16(40692), + 143: uint16(22225), + 144: uint16(22761), + 145: uint16(25900), + 146: uint16(28766), + 147: uint16(30321), + 148: uint16(30322), + 149: uint16(30679), + 150: uint16(32592), + 151: uint16(32648), + 152: uint16(34870), + 153: uint16(34873), + 154: uint16(34914), + 155: uint16(35731), + 156: uint16(35730), + }, + 37: { + 0: uint16(35734), + 1: uint16(33399), + 2: uint16(36123), + 3: uint16(37312), + 4: uint16(37994), + 5: uint16(38722), + 6: uint16(38728), + 7: uint16(38724), + 8: uint16(38854), + 9: uint16(39024), + 10: uint16(39519), + 11: uint16(39714), + 12: uint16(39768), + 13: uint16(40031), + 14: uint16(40441), + 15: uint16(40442), + 16: uint16(40572), + 17: uint16(40573), + 18: uint16(40711), + 19: uint16(40823), + 20: uint16(40818), + 21: uint16(24307), + 22: uint16(27414), + 23: uint16(28771), + 24: uint16(31852), + 25: uint16(31854), + 26: uint16(34875), + 27: uint16(35264), + 28: uint16(36513), + 29: uint16(37313), + 30: uint16(38002), + 31: uint16(38000), + 32: uint16(39025), + 33: uint16(39262), + 34: uint16(39638), + 35: uint16(39715), + 36: uint16(40652), + 37: uint16(28772), + 38: uint16(30682), + 39: uint16(35738), + 40: uint16(38007), + 41: uint16(38857), + 42: uint16(39522), + 43: uint16(39525), + 44: uint16(32412), + 45: uint16(35740), + 46: uint16(36522), + 47: uint16(37317), + 48: uint16(38013), + 49: uint16(38014), + 50: uint16(38012), + 51: uint16(40055), + 52: uint16(40056), + 53: uint16(40695), + 54: uint16(35924), + 55: uint16(38015), + 56: uint16(40474), + 57: uint16(29224), + 58: uint16(39530), + 59: uint16(39729), + 60: uint16(40475), + 61: uint16(40478), + 62: uint16(31858), + 63: uint16(9312), + 64: uint16(9313), + 65: uint16(9314), + 66: uint16(9315), + 67: uint16(9316), + 68: uint16(9317), + 69: uint16(9318), + 70: uint16(9319), + 71: uint16(9320), + 72: uint16(9321), + 73: uint16(9332), + 74: uint16(9333), + 75: uint16(9334), + 76: uint16(9335), + 77: uint16(9336), + 78: uint16(9337), + 79: uint16(9338), + 80: uint16(9339), + 81: uint16(9340), + 82: uint16(9341), + 83: uint16(8560), + 84: uint16(8561), + 85: uint16(8562), + 86: uint16(8563), + 87: uint16(8564), + 88: uint16(8565), + 89: uint16(8566), + 90: uint16(8567), + 91: uint16(8568), + 92: uint16(8569), + 93: uint16(20022), + 94: uint16(20031), + 95: uint16(20101), + 96: uint16(20128), + 97: uint16(20866), + 98: uint16(20886), + 99: uint16(20907), + 100: uint16(21241), + 101: uint16(21304), + 102: uint16(21353), + 103: uint16(21430), + 104: uint16(22794), + 105: uint16(23424), + 106: uint16(24027), + 107: uint16(24186), + 108: uint16(24191), + 109: uint16(24308), + 110: uint16(24400), + 111: uint16(24417), + 112: uint16(25908), + 113: uint16(26080), + 114: uint16(30098), + 115: uint16(30326), + 116: uint16(36789), + 117: uint16(38582), + 118: uint16(168), + 119: uint16(710), + 120: uint16(12541), + 121: uint16(12542), + 122: uint16(12445), + 123: uint16(12446), + 126: uint16(12293), + 127: uint16(12294), + 128: uint16(12295), + 129: uint16(12540), + 130: uint16(65339), + 131: uint16(65341), + 132: uint16(10045), + 133: uint16(12353), + 134: uint16(12354), + 135: uint16(12355), + 136: uint16(12356), + 137: uint16(12357), + 138: uint16(12358), + 139: uint16(12359), + 140: uint16(12360), + 141: uint16(12361), + 142: uint16(12362), + 143: uint16(12363), + 144: uint16(12364), + 145: uint16(12365), + 146: uint16(12366), + 147: uint16(12367), + 148: uint16(12368), + 149: uint16(12369), + 150: uint16(12370), + 151: uint16(12371), + 152: uint16(12372), + 153: uint16(12373), + 154: uint16(12374), + 155: uint16(12375), + 156: uint16(12376), + }, + 38: { + 0: uint16(12377), + 1: uint16(12378), + 2: uint16(12379), + 3: uint16(12380), + 4: uint16(12381), + 5: uint16(12382), + 6: uint16(12383), + 7: uint16(12384), + 8: uint16(12385), + 9: uint16(12386), + 10: uint16(12387), + 11: uint16(12388), + 12: uint16(12389), + 13: uint16(12390), + 14: uint16(12391), + 15: uint16(12392), + 16: uint16(12393), + 17: uint16(12394), + 18: uint16(12395), + 19: uint16(12396), + 20: uint16(12397), + 21: uint16(12398), + 22: uint16(12399), + 23: uint16(12400), + 24: uint16(12401), + 25: uint16(12402), + 26: uint16(12403), + 27: uint16(12404), + 28: uint16(12405), + 29: uint16(12406), + 30: uint16(12407), + 31: uint16(12408), + 32: uint16(12409), + 33: uint16(12410), + 34: uint16(12411), + 35: uint16(12412), + 36: uint16(12413), + 37: uint16(12414), + 38: uint16(12415), + 39: uint16(12416), + 40: uint16(12417), + 41: uint16(12418), + 42: uint16(12419), + 43: uint16(12420), + 44: uint16(12421), + 45: uint16(12422), + 46: uint16(12423), + 47: uint16(12424), + 48: uint16(12425), + 49: uint16(12426), + 50: uint16(12427), + 51: uint16(12428), + 52: uint16(12429), + 53: uint16(12430), + 54: uint16(12431), + 55: uint16(12432), + 56: uint16(12433), + 57: uint16(12434), + 58: uint16(12435), + 59: uint16(12449), + 60: uint16(12450), + 61: uint16(12451), + 62: uint16(12452), + 63: uint16(12453), + 64: uint16(12454), + 65: uint16(12455), + 66: uint16(12456), + 67: uint16(12457), + 68: uint16(12458), + 69: uint16(12459), + 70: uint16(12460), + 71: uint16(12461), + 72: uint16(12462), + 73: uint16(12463), + 74: uint16(12464), + 75: uint16(12465), + 76: uint16(12466), + 77: uint16(12467), + 78: uint16(12468), + 79: uint16(12469), + 80: uint16(12470), + 81: uint16(12471), + 82: uint16(12472), + 83: uint16(12473), + 84: uint16(12474), + 85: uint16(12475), + 86: uint16(12476), + 87: uint16(12477), + 88: uint16(12478), + 89: uint16(12479), + 90: uint16(12480), + 91: uint16(12481), + 92: uint16(12482), + 93: uint16(12483), + 94: uint16(12484), + 95: uint16(12485), + 96: uint16(12486), + 97: uint16(12487), + 98: uint16(12488), + 99: uint16(12489), + 100: uint16(12490), + 101: uint16(12491), + 102: uint16(12492), + 103: uint16(12493), + 104: uint16(12494), + 105: uint16(12495), + 106: uint16(12496), + 107: uint16(12497), + 108: uint16(12498), + 109: uint16(12499), + 110: uint16(12500), + 111: uint16(12501), + 112: uint16(12502), + 113: uint16(12503), + 114: uint16(12504), + 115: uint16(12505), + 116: uint16(12506), + 117: uint16(12507), + 118: uint16(12508), + 119: uint16(12509), + 120: uint16(12510), + 121: uint16(12511), + 122: uint16(12512), + 123: uint16(12513), + 124: uint16(12514), + 125: uint16(12515), + 126: uint16(12516), + 127: uint16(12517), + 128: uint16(12518), + 129: uint16(12519), + 130: uint16(12520), + 131: uint16(12521), + 132: uint16(12522), + 133: uint16(12523), + 134: uint16(12524), + 135: uint16(12525), + 136: uint16(12526), + 137: uint16(12527), + 138: uint16(12528), + 139: uint16(12529), + 140: uint16(12530), + 141: uint16(12531), + 142: uint16(12532), + 143: uint16(12533), + 144: uint16(12534), + 145: uint16(1040), + 146: uint16(1041), + 147: uint16(1042), + 148: uint16(1043), + 149: uint16(1044), + 150: uint16(1045), + 151: uint16(1025), + 152: uint16(1046), + 153: uint16(1047), + 154: uint16(1048), + 155: uint16(1049), + 156: uint16(1050), + }, + 39: { + 0: uint16(1051), + 1: uint16(1052), + 2: uint16(1053), + 3: uint16(1054), + 4: uint16(1055), + 5: uint16(1056), + 6: uint16(1057), + 7: uint16(1058), + 8: uint16(1059), + 9: uint16(1060), + 10: uint16(1061), + 11: uint16(1062), + 12: uint16(1063), + 13: uint16(1064), + 14: uint16(1065), + 15: uint16(1066), + 16: uint16(1067), + 17: uint16(1068), + 18: uint16(1069), + 19: uint16(1070), + 20: uint16(1071), + 21: uint16(1072), + 22: uint16(1073), + 23: uint16(1074), + 24: uint16(1075), + 25: uint16(1076), + 26: uint16(1077), + 27: uint16(1105), + 28: uint16(1078), + 29: uint16(1079), + 30: uint16(1080), + 31: uint16(1081), + 32: uint16(1082), + 33: uint16(1083), + 34: uint16(1084), + 35: uint16(1085), + 36: uint16(1086), + 37: uint16(1087), + 38: uint16(1088), + 39: uint16(1089), + 40: uint16(1090), + 41: uint16(1091), + 42: uint16(1092), + 43: uint16(1093), + 44: uint16(1094), + 45: uint16(1095), + 46: uint16(1096), + 47: uint16(1097), + 48: uint16(1098), + 49: uint16(1099), + 50: uint16(1100), + 51: uint16(1101), + 52: uint16(1102), + 53: uint16(1103), + 54: uint16(8679), + 55: uint16(8632), + 56: uint16(8633), + 57: uint16(12751), + 58: uint16(204), + 59: uint16(20058), + 60: uint16(138), + 61: uint16(20994), + 62: uint16(17553), + 63: uint16(40880), + 64: uint16(20872), + 65: uint16(40881), + 66: uint16(30215), + 107: uint16(65506), + 108: uint16(65508), + 109: uint16(65287), + 110: uint16(65282), + 111: uint16(12849), + 112: uint16(8470), + 113: uint16(8481), + 114: uint16(12443), + 115: uint16(12444), + 116: uint16(11904), + 117: uint16(11908), + 118: uint16(11910), + 119: uint16(11911), + 120: uint16(11912), + 121: uint16(11914), + 122: uint16(11916), + 123: uint16(11917), + 124: uint16(11925), + 125: uint16(11932), + 126: uint16(11933), + 127: uint16(11941), + 128: uint16(11943), + 129: uint16(11946), + 130: uint16(11948), + 131: uint16(11950), + 132: uint16(11958), + 133: uint16(11964), + 134: uint16(11966), + 135: uint16(11974), + 136: uint16(11978), + 137: uint16(11980), + 138: uint16(11981), + 139: uint16(11983), + 140: uint16(11990), + 141: uint16(11991), + 142: uint16(11998), + 143: uint16(12003), + 147: uint16(643), + 148: uint16(592), + 149: uint16(603), + 150: uint16(596), + 151: uint16(629), + 152: uint16(339), + 153: uint16(248), + 154: uint16(331), + 155: uint16(650), + 156: uint16(618), + }, + 40: { + 0: uint16(20034), + 1: uint16(20060), + 2: uint16(20981), + 3: uint16(21274), + 4: uint16(21378), + 5: uint16(19975), + 6: uint16(19980), + 7: uint16(20039), + 8: uint16(20109), + 9: uint16(22231), + 10: uint16(64012), + 11: uint16(23662), + 12: uint16(24435), + 13: uint16(19983), + 14: uint16(20871), + 15: uint16(19982), + 16: uint16(20014), + 17: uint16(20115), + 18: uint16(20162), + 19: uint16(20169), + 20: uint16(20168), + 21: uint16(20888), + 22: uint16(21244), + 23: uint16(21356), + 24: uint16(21433), + 25: uint16(22304), + 26: uint16(22787), + 27: uint16(22828), + 28: uint16(23568), + 29: uint16(24063), + 30: uint16(26081), + 31: uint16(27571), + 32: uint16(27596), + 33: uint16(27668), + 34: uint16(29247), + 35: uint16(20017), + 36: uint16(20028), + 37: uint16(20200), + 38: uint16(20188), + 39: uint16(20201), + 40: uint16(20193), + 41: uint16(20189), + 42: uint16(20186), + 43: uint16(21004), + 44: uint16(21276), + 45: uint16(21324), + 46: uint16(22306), + 47: uint16(22307), + 48: uint16(22807), + 49: uint16(22831), + 50: uint16(23425), + 51: uint16(23428), + 52: uint16(23570), + 53: uint16(23611), + 54: uint16(23668), + 55: uint16(23667), + 56: uint16(24068), + 57: uint16(24192), + 58: uint16(24194), + 59: uint16(24521), + 60: uint16(25097), + 61: uint16(25168), + 62: uint16(27669), + 63: uint16(27702), + 64: uint16(27715), + 65: uint16(27711), + 66: uint16(27707), + 67: uint16(29358), + 68: uint16(29360), + 69: uint16(29578), + 70: uint16(31160), + 71: uint16(32906), + 72: uint16(38430), + 73: uint16(20238), + 74: uint16(20248), + 75: uint16(20268), + 76: uint16(20213), + 77: uint16(20244), + 78: uint16(20209), + 79: uint16(20224), + 80: uint16(20215), + 81: uint16(20232), + 82: uint16(20253), + 83: uint16(20226), + 84: uint16(20229), + 85: uint16(20258), + 86: uint16(20243), + 87: uint16(20228), + 88: uint16(20212), + 89: uint16(20242), + 90: uint16(20913), + 91: uint16(21011), + 92: uint16(21001), + 93: uint16(21008), + 94: uint16(21158), + 95: uint16(21282), + 96: uint16(21279), + 97: uint16(21325), + 98: uint16(21386), + 99: uint16(21511), + 100: uint16(22241), + 101: uint16(22239), + 102: uint16(22318), + 103: uint16(22314), + 104: uint16(22324), + 105: uint16(22844), + 106: uint16(22912), + 107: uint16(22908), + 108: uint16(22917), + 109: uint16(22907), + 110: uint16(22910), + 111: uint16(22903), + 112: uint16(22911), + 113: uint16(23382), + 114: uint16(23573), + 115: uint16(23589), + 116: uint16(23676), + 117: uint16(23674), + 118: uint16(23675), + 119: uint16(23678), + 120: uint16(24031), + 121: uint16(24181), + 122: uint16(24196), + 123: uint16(24322), + 124: uint16(24346), + 125: uint16(24436), + 126: uint16(24533), + 127: uint16(24532), + 128: uint16(24527), + 129: uint16(25180), + 130: uint16(25182), + 131: uint16(25188), + 132: uint16(25185), + 133: uint16(25190), + 134: uint16(25186), + 135: uint16(25177), + 136: uint16(25184), + 137: uint16(25178), + 138: uint16(25189), + 139: uint16(26095), + 140: uint16(26094), + 141: uint16(26430), + 142: uint16(26425), + 143: uint16(26424), + 144: uint16(26427), + 145: uint16(26426), + 146: uint16(26431), + 147: uint16(26428), + 148: uint16(26419), + 149: uint16(27672), + 150: uint16(27718), + 151: uint16(27730), + 152: uint16(27740), + 153: uint16(27727), + 154: uint16(27722), + 155: uint16(27732), + 156: uint16(27723), + }, + 41: { + 0: uint16(27724), + 1: uint16(28785), + 2: uint16(29278), + 3: uint16(29364), + 4: uint16(29365), + 5: uint16(29582), + 6: uint16(29994), + 7: uint16(30335), + 8: uint16(31349), + 9: uint16(32593), + 10: uint16(33400), + 11: uint16(33404), + 12: uint16(33408), + 13: uint16(33405), + 14: uint16(33407), + 15: uint16(34381), + 16: uint16(35198), + 17: uint16(37017), + 18: uint16(37015), + 19: uint16(37016), + 20: uint16(37019), + 21: uint16(37012), + 22: uint16(38434), + 23: uint16(38436), + 24: uint16(38432), + 25: uint16(38435), + 26: uint16(20310), + 27: uint16(20283), + 28: uint16(20322), + 29: uint16(20297), + 30: uint16(20307), + 31: uint16(20324), + 32: uint16(20286), + 33: uint16(20327), + 34: uint16(20306), + 35: uint16(20319), + 36: uint16(20289), + 37: uint16(20312), + 38: uint16(20269), + 39: uint16(20275), + 40: uint16(20287), + 41: uint16(20321), + 42: uint16(20879), + 43: uint16(20921), + 44: uint16(21020), + 45: uint16(21022), + 46: uint16(21025), + 47: uint16(21165), + 48: uint16(21166), + 49: uint16(21257), + 50: uint16(21347), + 51: uint16(21362), + 52: uint16(21390), + 53: uint16(21391), + 54: uint16(21552), + 55: uint16(21559), + 56: uint16(21546), + 57: uint16(21588), + 58: uint16(21573), + 59: uint16(21529), + 60: uint16(21532), + 61: uint16(21541), + 62: uint16(21528), + 63: uint16(21565), + 64: uint16(21583), + 65: uint16(21569), + 66: uint16(21544), + 67: uint16(21540), + 68: uint16(21575), + 69: uint16(22254), + 70: uint16(22247), + 71: uint16(22245), + 72: uint16(22337), + 73: uint16(22341), + 74: uint16(22348), + 75: uint16(22345), + 76: uint16(22347), + 77: uint16(22354), + 78: uint16(22790), + 79: uint16(22848), + 80: uint16(22950), + 81: uint16(22936), + 82: uint16(22944), + 83: uint16(22935), + 84: uint16(22926), + 85: uint16(22946), + 86: uint16(22928), + 87: uint16(22927), + 88: uint16(22951), + 89: uint16(22945), + 90: uint16(23438), + 91: uint16(23442), + 92: uint16(23592), + 93: uint16(23594), + 94: uint16(23693), + 95: uint16(23695), + 96: uint16(23688), + 97: uint16(23691), + 98: uint16(23689), + 99: uint16(23698), + 100: uint16(23690), + 101: uint16(23686), + 102: uint16(23699), + 103: uint16(23701), + 104: uint16(24032), + 105: uint16(24074), + 106: uint16(24078), + 107: uint16(24203), + 108: uint16(24201), + 109: uint16(24204), + 110: uint16(24200), + 111: uint16(24205), + 112: uint16(24325), + 113: uint16(24349), + 114: uint16(24440), + 115: uint16(24438), + 116: uint16(24530), + 117: uint16(24529), + 118: uint16(24528), + 119: uint16(24557), + 120: uint16(24552), + 121: uint16(24558), + 122: uint16(24563), + 123: uint16(24545), + 124: uint16(24548), + 125: uint16(24547), + 126: uint16(24570), + 127: uint16(24559), + 128: uint16(24567), + 129: uint16(24571), + 130: uint16(24576), + 131: uint16(24564), + 132: uint16(25146), + 133: uint16(25219), + 134: uint16(25228), + 135: uint16(25230), + 136: uint16(25231), + 137: uint16(25236), + 138: uint16(25223), + 139: uint16(25201), + 140: uint16(25211), + 141: uint16(25210), + 142: uint16(25200), + 143: uint16(25217), + 144: uint16(25224), + 145: uint16(25207), + 146: uint16(25213), + 147: uint16(25202), + 148: uint16(25204), + 149: uint16(25911), + 150: uint16(26096), + 151: uint16(26100), + 152: uint16(26099), + 153: uint16(26098), + 154: uint16(26101), + 155: uint16(26437), + 156: uint16(26439), + }, + 42: { + 0: uint16(26457), + 1: uint16(26453), + 2: uint16(26444), + 3: uint16(26440), + 4: uint16(26461), + 5: uint16(26445), + 6: uint16(26458), + 7: uint16(26443), + 8: uint16(27600), + 9: uint16(27673), + 10: uint16(27674), + 11: uint16(27768), + 12: uint16(27751), + 13: uint16(27755), + 14: uint16(27780), + 15: uint16(27787), + 16: uint16(27791), + 17: uint16(27761), + 18: uint16(27759), + 19: uint16(27753), + 20: uint16(27802), + 21: uint16(27757), + 22: uint16(27783), + 23: uint16(27797), + 24: uint16(27804), + 25: uint16(27750), + 26: uint16(27763), + 27: uint16(27749), + 28: uint16(27771), + 29: uint16(27790), + 30: uint16(28788), + 31: uint16(28794), + 32: uint16(29283), + 33: uint16(29375), + 34: uint16(29373), + 35: uint16(29379), + 36: uint16(29382), + 37: uint16(29377), + 38: uint16(29370), + 39: uint16(29381), + 40: uint16(29589), + 41: uint16(29591), + 42: uint16(29587), + 43: uint16(29588), + 44: uint16(29586), + 45: uint16(30010), + 46: uint16(30009), + 47: uint16(30100), + 48: uint16(30101), + 49: uint16(30337), + 50: uint16(31037), + 51: uint16(32820), + 52: uint16(32917), + 53: uint16(32921), + 54: uint16(32912), + 55: uint16(32914), + 56: uint16(32924), + 57: uint16(33424), + 58: uint16(33423), + 59: uint16(33413), + 60: uint16(33422), + 61: uint16(33425), + 62: uint16(33427), + 63: uint16(33418), + 64: uint16(33411), + 65: uint16(33412), + 66: uint16(35960), + 67: uint16(36809), + 68: uint16(36799), + 69: uint16(37023), + 70: uint16(37025), + 71: uint16(37029), + 72: uint16(37022), + 73: uint16(37031), + 74: uint16(37024), + 75: uint16(38448), + 76: uint16(38440), + 77: uint16(38447), + 78: uint16(38445), + 79: uint16(20019), + 80: uint16(20376), + 81: uint16(20348), + 82: uint16(20357), + 83: uint16(20349), + 84: uint16(20352), + 85: uint16(20359), + 86: uint16(20342), + 87: uint16(20340), + 88: uint16(20361), + 89: uint16(20356), + 90: uint16(20343), + 91: uint16(20300), + 92: uint16(20375), + 93: uint16(20330), + 94: uint16(20378), + 95: uint16(20345), + 96: uint16(20353), + 97: uint16(20344), + 98: uint16(20368), + 99: uint16(20380), + 100: uint16(20372), + 101: uint16(20382), + 102: uint16(20370), + 103: uint16(20354), + 104: uint16(20373), + 105: uint16(20331), + 106: uint16(20334), + 107: uint16(20894), + 108: uint16(20924), + 109: uint16(20926), + 110: uint16(21045), + 111: uint16(21042), + 112: uint16(21043), + 113: uint16(21062), + 114: uint16(21041), + 115: uint16(21180), + 116: uint16(21258), + 117: uint16(21259), + 118: uint16(21308), + 119: uint16(21394), + 120: uint16(21396), + 121: uint16(21639), + 122: uint16(21631), + 123: uint16(21633), + 124: uint16(21649), + 125: uint16(21634), + 126: uint16(21640), + 127: uint16(21611), + 128: uint16(21626), + 129: uint16(21630), + 130: uint16(21605), + 131: uint16(21612), + 132: uint16(21620), + 133: uint16(21606), + 134: uint16(21645), + 135: uint16(21615), + 136: uint16(21601), + 137: uint16(21600), + 138: uint16(21656), + 139: uint16(21603), + 140: uint16(21607), + 141: uint16(21604), + 142: uint16(22263), + 143: uint16(22265), + 144: uint16(22383), + 145: uint16(22386), + 146: uint16(22381), + 147: uint16(22379), + 148: uint16(22385), + 149: uint16(22384), + 150: uint16(22390), + 151: uint16(22400), + 152: uint16(22389), + 153: uint16(22395), + 154: uint16(22387), + 155: uint16(22388), + 156: uint16(22370), + }, + 43: { + 0: uint16(22376), + 1: uint16(22397), + 2: uint16(22796), + 3: uint16(22853), + 4: uint16(22965), + 5: uint16(22970), + 6: uint16(22991), + 7: uint16(22990), + 8: uint16(22962), + 9: uint16(22988), + 10: uint16(22977), + 11: uint16(22966), + 12: uint16(22972), + 13: uint16(22979), + 14: uint16(22998), + 15: uint16(22961), + 16: uint16(22973), + 17: uint16(22976), + 18: uint16(22984), + 19: uint16(22964), + 20: uint16(22983), + 21: uint16(23394), + 22: uint16(23397), + 23: uint16(23443), + 24: uint16(23445), + 25: uint16(23620), + 26: uint16(23623), + 27: uint16(23726), + 28: uint16(23716), + 29: uint16(23712), + 30: uint16(23733), + 31: uint16(23727), + 32: uint16(23720), + 33: uint16(23724), + 34: uint16(23711), + 35: uint16(23715), + 36: uint16(23725), + 37: uint16(23714), + 38: uint16(23722), + 39: uint16(23719), + 40: uint16(23709), + 41: uint16(23717), + 42: uint16(23734), + 43: uint16(23728), + 44: uint16(23718), + 45: uint16(24087), + 46: uint16(24084), + 47: uint16(24089), + 48: uint16(24360), + 49: uint16(24354), + 50: uint16(24355), + 51: uint16(24356), + 52: uint16(24404), + 53: uint16(24450), + 54: uint16(24446), + 55: uint16(24445), + 56: uint16(24542), + 57: uint16(24549), + 58: uint16(24621), + 59: uint16(24614), + 60: uint16(24601), + 61: uint16(24626), + 62: uint16(24587), + 63: uint16(24628), + 64: uint16(24586), + 65: uint16(24599), + 66: uint16(24627), + 67: uint16(24602), + 68: uint16(24606), + 69: uint16(24620), + 70: uint16(24610), + 71: uint16(24589), + 72: uint16(24592), + 73: uint16(24622), + 74: uint16(24595), + 75: uint16(24593), + 76: uint16(24588), + 77: uint16(24585), + 78: uint16(24604), + 79: uint16(25108), + 80: uint16(25149), + 81: uint16(25261), + 82: uint16(25268), + 83: uint16(25297), + 84: uint16(25278), + 85: uint16(25258), + 86: uint16(25270), + 87: uint16(25290), + 88: uint16(25262), + 89: uint16(25267), + 90: uint16(25263), + 91: uint16(25275), + 92: uint16(25257), + 93: uint16(25264), + 94: uint16(25272), + 95: uint16(25917), + 96: uint16(26024), + 97: uint16(26043), + 98: uint16(26121), + 99: uint16(26108), + 100: uint16(26116), + 101: uint16(26130), + 102: uint16(26120), + 103: uint16(26107), + 104: uint16(26115), + 105: uint16(26123), + 106: uint16(26125), + 107: uint16(26117), + 108: uint16(26109), + 109: uint16(26129), + 110: uint16(26128), + 111: uint16(26358), + 112: uint16(26378), + 113: uint16(26501), + 114: uint16(26476), + 115: uint16(26510), + 116: uint16(26514), + 117: uint16(26486), + 118: uint16(26491), + 119: uint16(26520), + 120: uint16(26502), + 121: uint16(26500), + 122: uint16(26484), + 123: uint16(26509), + 124: uint16(26508), + 125: uint16(26490), + 126: uint16(26527), + 127: uint16(26513), + 128: uint16(26521), + 129: uint16(26499), + 130: uint16(26493), + 131: uint16(26497), + 132: uint16(26488), + 133: uint16(26489), + 134: uint16(26516), + 135: uint16(27429), + 136: uint16(27520), + 137: uint16(27518), + 138: uint16(27614), + 139: uint16(27677), + 140: uint16(27795), + 141: uint16(27884), + 142: uint16(27883), + 143: uint16(27886), + 144: uint16(27865), + 145: uint16(27830), + 146: uint16(27860), + 147: uint16(27821), + 148: uint16(27879), + 149: uint16(27831), + 150: uint16(27856), + 151: uint16(27842), + 152: uint16(27834), + 153: uint16(27843), + 154: uint16(27846), + 155: uint16(27885), + 156: uint16(27890), + }, + 44: { + 0: uint16(27858), + 1: uint16(27869), + 2: uint16(27828), + 3: uint16(27786), + 4: uint16(27805), + 5: uint16(27776), + 6: uint16(27870), + 7: uint16(27840), + 8: uint16(27952), + 9: uint16(27853), + 10: uint16(27847), + 11: uint16(27824), + 12: uint16(27897), + 13: uint16(27855), + 14: uint16(27881), + 15: uint16(27857), + 16: uint16(28820), + 17: uint16(28824), + 18: uint16(28805), + 19: uint16(28819), + 20: uint16(28806), + 21: uint16(28804), + 22: uint16(28817), + 23: uint16(28822), + 24: uint16(28802), + 25: uint16(28826), + 26: uint16(28803), + 27: uint16(29290), + 28: uint16(29398), + 29: uint16(29387), + 30: uint16(29400), + 31: uint16(29385), + 32: uint16(29404), + 33: uint16(29394), + 34: uint16(29396), + 35: uint16(29402), + 36: uint16(29388), + 37: uint16(29393), + 38: uint16(29604), + 39: uint16(29601), + 40: uint16(29613), + 41: uint16(29606), + 42: uint16(29602), + 43: uint16(29600), + 44: uint16(29612), + 45: uint16(29597), + 46: uint16(29917), + 47: uint16(29928), + 48: uint16(30015), + 49: uint16(30016), + 50: uint16(30014), + 51: uint16(30092), + 52: uint16(30104), + 53: uint16(30383), + 54: uint16(30451), + 55: uint16(30449), + 56: uint16(30448), + 57: uint16(30453), + 58: uint16(30712), + 59: uint16(30716), + 60: uint16(30713), + 61: uint16(30715), + 62: uint16(30714), + 63: uint16(30711), + 64: uint16(31042), + 65: uint16(31039), + 66: uint16(31173), + 67: uint16(31352), + 68: uint16(31355), + 69: uint16(31483), + 70: uint16(31861), + 71: uint16(31997), + 72: uint16(32821), + 73: uint16(32911), + 74: uint16(32942), + 75: uint16(32931), + 76: uint16(32952), + 77: uint16(32949), + 78: uint16(32941), + 79: uint16(33312), + 80: uint16(33440), + 81: uint16(33472), + 82: uint16(33451), + 83: uint16(33434), + 84: uint16(33432), + 85: uint16(33435), + 86: uint16(33461), + 87: uint16(33447), + 88: uint16(33454), + 89: uint16(33468), + 90: uint16(33438), + 91: uint16(33466), + 92: uint16(33460), + 93: uint16(33448), + 94: uint16(33441), + 95: uint16(33449), + 96: uint16(33474), + 97: uint16(33444), + 98: uint16(33475), + 99: uint16(33462), + 100: uint16(33442), + 101: uint16(34416), + 102: uint16(34415), + 103: uint16(34413), + 104: uint16(34414), + 105: uint16(35926), + 106: uint16(36818), + 107: uint16(36811), + 108: uint16(36819), + 109: uint16(36813), + 110: uint16(36822), + 111: uint16(36821), + 112: uint16(36823), + 113: uint16(37042), + 114: uint16(37044), + 115: uint16(37039), + 116: uint16(37043), + 117: uint16(37040), + 118: uint16(38457), + 119: uint16(38461), + 120: uint16(38460), + 121: uint16(38458), + 122: uint16(38467), + 123: uint16(20429), + 124: uint16(20421), + 125: uint16(20435), + 126: uint16(20402), + 127: uint16(20425), + 128: uint16(20427), + 129: uint16(20417), + 130: uint16(20436), + 131: uint16(20444), + 132: uint16(20441), + 133: uint16(20411), + 134: uint16(20403), + 135: uint16(20443), + 136: uint16(20423), + 137: uint16(20438), + 138: uint16(20410), + 139: uint16(20416), + 140: uint16(20409), + 141: uint16(20460), + 142: uint16(21060), + 143: uint16(21065), + 144: uint16(21184), + 145: uint16(21186), + 146: uint16(21309), + 147: uint16(21372), + 148: uint16(21399), + 149: uint16(21398), + 150: uint16(21401), + 151: uint16(21400), + 152: uint16(21690), + 153: uint16(21665), + 154: uint16(21677), + 155: uint16(21669), + 156: uint16(21711), + }, + 45: { + 0: uint16(21699), + 1: uint16(33549), + 2: uint16(21687), + 3: uint16(21678), + 4: uint16(21718), + 5: uint16(21686), + 6: uint16(21701), + 7: uint16(21702), + 8: uint16(21664), + 9: uint16(21616), + 10: uint16(21692), + 11: uint16(21666), + 12: uint16(21694), + 13: uint16(21618), + 14: uint16(21726), + 15: uint16(21680), + 16: uint16(22453), + 17: uint16(22430), + 18: uint16(22431), + 19: uint16(22436), + 20: uint16(22412), + 21: uint16(22423), + 22: uint16(22429), + 23: uint16(22427), + 24: uint16(22420), + 25: uint16(22424), + 26: uint16(22415), + 27: uint16(22425), + 28: uint16(22437), + 29: uint16(22426), + 30: uint16(22421), + 31: uint16(22772), + 32: uint16(22797), + 33: uint16(22867), + 34: uint16(23009), + 35: uint16(23006), + 36: uint16(23022), + 37: uint16(23040), + 38: uint16(23025), + 39: uint16(23005), + 40: uint16(23034), + 41: uint16(23037), + 42: uint16(23036), + 43: uint16(23030), + 44: uint16(23012), + 45: uint16(23026), + 46: uint16(23031), + 47: uint16(23003), + 48: uint16(23017), + 49: uint16(23027), + 50: uint16(23029), + 51: uint16(23008), + 52: uint16(23038), + 53: uint16(23028), + 54: uint16(23021), + 55: uint16(23464), + 56: uint16(23628), + 57: uint16(23760), + 58: uint16(23768), + 59: uint16(23756), + 60: uint16(23767), + 61: uint16(23755), + 62: uint16(23771), + 63: uint16(23774), + 64: uint16(23770), + 65: uint16(23753), + 66: uint16(23751), + 67: uint16(23754), + 68: uint16(23766), + 69: uint16(23763), + 70: uint16(23764), + 71: uint16(23759), + 72: uint16(23752), + 73: uint16(23750), + 74: uint16(23758), + 75: uint16(23775), + 76: uint16(23800), + 77: uint16(24057), + 78: uint16(24097), + 79: uint16(24098), + 80: uint16(24099), + 81: uint16(24096), + 82: uint16(24100), + 83: uint16(24240), + 84: uint16(24228), + 85: uint16(24226), + 86: uint16(24219), + 87: uint16(24227), + 88: uint16(24229), + 89: uint16(24327), + 90: uint16(24366), + 91: uint16(24406), + 92: uint16(24454), + 93: uint16(24631), + 94: uint16(24633), + 95: uint16(24660), + 96: uint16(24690), + 97: uint16(24670), + 98: uint16(24645), + 99: uint16(24659), + 100: uint16(24647), + 101: uint16(24649), + 102: uint16(24667), + 103: uint16(24652), + 104: uint16(24640), + 105: uint16(24642), + 106: uint16(24671), + 107: uint16(24612), + 108: uint16(24644), + 109: uint16(24664), + 110: uint16(24678), + 111: uint16(24686), + 112: uint16(25154), + 113: uint16(25155), + 114: uint16(25295), + 115: uint16(25357), + 116: uint16(25355), + 117: uint16(25333), + 118: uint16(25358), + 119: uint16(25347), + 120: uint16(25323), + 121: uint16(25337), + 122: uint16(25359), + 123: uint16(25356), + 124: uint16(25336), + 125: uint16(25334), + 126: uint16(25344), + 127: uint16(25363), + 128: uint16(25364), + 129: uint16(25338), + 130: uint16(25365), + 131: uint16(25339), + 132: uint16(25328), + 133: uint16(25921), + 134: uint16(25923), + 135: uint16(26026), + 136: uint16(26047), + 137: uint16(26166), + 138: uint16(26145), + 139: uint16(26162), + 140: uint16(26165), + 141: uint16(26140), + 142: uint16(26150), + 143: uint16(26146), + 144: uint16(26163), + 145: uint16(26155), + 146: uint16(26170), + 147: uint16(26141), + 148: uint16(26164), + 149: uint16(26169), + 150: uint16(26158), + 151: uint16(26383), + 152: uint16(26384), + 153: uint16(26561), + 154: uint16(26610), + 155: uint16(26568), + 156: uint16(26554), + }, + 46: { + 0: uint16(26588), + 1: uint16(26555), + 2: uint16(26616), + 3: uint16(26584), + 4: uint16(26560), + 5: uint16(26551), + 6: uint16(26565), + 7: uint16(26603), + 8: uint16(26596), + 9: uint16(26591), + 10: uint16(26549), + 11: uint16(26573), + 12: uint16(26547), + 13: uint16(26615), + 14: uint16(26614), + 15: uint16(26606), + 16: uint16(26595), + 17: uint16(26562), + 18: uint16(26553), + 19: uint16(26574), + 20: uint16(26599), + 21: uint16(26608), + 22: uint16(26546), + 23: uint16(26620), + 24: uint16(26566), + 25: uint16(26605), + 26: uint16(26572), + 27: uint16(26542), + 28: uint16(26598), + 29: uint16(26587), + 30: uint16(26618), + 31: uint16(26569), + 32: uint16(26570), + 33: uint16(26563), + 34: uint16(26602), + 35: uint16(26571), + 36: uint16(27432), + 37: uint16(27522), + 38: uint16(27524), + 39: uint16(27574), + 40: uint16(27606), + 41: uint16(27608), + 42: uint16(27616), + 43: uint16(27680), + 44: uint16(27681), + 45: uint16(27944), + 46: uint16(27956), + 47: uint16(27949), + 48: uint16(27935), + 49: uint16(27964), + 50: uint16(27967), + 51: uint16(27922), + 52: uint16(27914), + 53: uint16(27866), + 54: uint16(27955), + 55: uint16(27908), + 56: uint16(27929), + 57: uint16(27962), + 58: uint16(27930), + 59: uint16(27921), + 60: uint16(27904), + 61: uint16(27933), + 62: uint16(27970), + 63: uint16(27905), + 64: uint16(27928), + 65: uint16(27959), + 66: uint16(27907), + 67: uint16(27919), + 68: uint16(27968), + 69: uint16(27911), + 70: uint16(27936), + 71: uint16(27948), + 72: uint16(27912), + 73: uint16(27938), + 74: uint16(27913), + 75: uint16(27920), + 76: uint16(28855), + 77: uint16(28831), + 78: uint16(28862), + 79: uint16(28849), + 80: uint16(28848), + 81: uint16(28833), + 82: uint16(28852), + 83: uint16(28853), + 84: uint16(28841), + 85: uint16(29249), + 86: uint16(29257), + 87: uint16(29258), + 88: uint16(29292), + 89: uint16(29296), + 90: uint16(29299), + 91: uint16(29294), + 92: uint16(29386), + 93: uint16(29412), + 94: uint16(29416), + 95: uint16(29419), + 96: uint16(29407), + 97: uint16(29418), + 98: uint16(29414), + 99: uint16(29411), + 100: uint16(29573), + 101: uint16(29644), + 102: uint16(29634), + 103: uint16(29640), + 104: uint16(29637), + 105: uint16(29625), + 106: uint16(29622), + 107: uint16(29621), + 108: uint16(29620), + 109: uint16(29675), + 110: uint16(29631), + 111: uint16(29639), + 112: uint16(29630), + 113: uint16(29635), + 114: uint16(29638), + 115: uint16(29624), + 116: uint16(29643), + 117: uint16(29932), + 118: uint16(29934), + 119: uint16(29998), + 120: uint16(30023), + 121: uint16(30024), + 122: uint16(30119), + 123: uint16(30122), + 124: uint16(30329), + 125: uint16(30404), + 126: uint16(30472), + 127: uint16(30467), + 128: uint16(30468), + 129: uint16(30469), + 130: uint16(30474), + 131: uint16(30455), + 132: uint16(30459), + 133: uint16(30458), + 134: uint16(30695), + 135: uint16(30696), + 136: uint16(30726), + 137: uint16(30737), + 138: uint16(30738), + 139: uint16(30725), + 140: uint16(30736), + 141: uint16(30735), + 142: uint16(30734), + 143: uint16(30729), + 144: uint16(30723), + 145: uint16(30739), + 146: uint16(31050), + 147: uint16(31052), + 148: uint16(31051), + 149: uint16(31045), + 150: uint16(31044), + 151: uint16(31189), + 152: uint16(31181), + 153: uint16(31183), + 154: uint16(31190), + 155: uint16(31182), + 156: uint16(31360), + }, + 47: { + 0: uint16(31358), + 1: uint16(31441), + 2: uint16(31488), + 3: uint16(31489), + 4: uint16(31866), + 5: uint16(31864), + 6: uint16(31865), + 7: uint16(31871), + 8: uint16(31872), + 9: uint16(31873), + 10: uint16(32003), + 11: uint16(32008), + 12: uint16(32001), + 13: uint16(32600), + 14: uint16(32657), + 15: uint16(32653), + 16: uint16(32702), + 17: uint16(32775), + 18: uint16(32782), + 19: uint16(32783), + 20: uint16(32788), + 21: uint16(32823), + 22: uint16(32984), + 23: uint16(32967), + 24: uint16(32992), + 25: uint16(32977), + 26: uint16(32968), + 27: uint16(32962), + 28: uint16(32976), + 29: uint16(32965), + 30: uint16(32995), + 31: uint16(32985), + 32: uint16(32988), + 33: uint16(32970), + 34: uint16(32981), + 35: uint16(32969), + 36: uint16(32975), + 37: uint16(32983), + 38: uint16(32998), + 39: uint16(32973), + 40: uint16(33279), + 41: uint16(33313), + 42: uint16(33428), + 43: uint16(33497), + 44: uint16(33534), + 45: uint16(33529), + 46: uint16(33543), + 47: uint16(33512), + 48: uint16(33536), + 49: uint16(33493), + 50: uint16(33594), + 51: uint16(33515), + 52: uint16(33494), + 53: uint16(33524), + 54: uint16(33516), + 55: uint16(33505), + 56: uint16(33522), + 57: uint16(33525), + 58: uint16(33548), + 59: uint16(33531), + 60: uint16(33526), + 61: uint16(33520), + 62: uint16(33514), + 63: uint16(33508), + 64: uint16(33504), + 65: uint16(33530), + 66: uint16(33523), + 67: uint16(33517), + 68: uint16(34423), + 69: uint16(34420), + 70: uint16(34428), + 71: uint16(34419), + 72: uint16(34881), + 73: uint16(34894), + 74: uint16(34919), + 75: uint16(34922), + 76: uint16(34921), + 77: uint16(35283), + 78: uint16(35332), + 79: uint16(35335), + 80: uint16(36210), + 81: uint16(36835), + 82: uint16(36833), + 83: uint16(36846), + 84: uint16(36832), + 85: uint16(37105), + 86: uint16(37053), + 87: uint16(37055), + 88: uint16(37077), + 89: uint16(37061), + 90: uint16(37054), + 91: uint16(37063), + 92: uint16(37067), + 93: uint16(37064), + 94: uint16(37332), + 95: uint16(37331), + 96: uint16(38484), + 97: uint16(38479), + 98: uint16(38481), + 99: uint16(38483), + 100: uint16(38474), + 101: uint16(38478), + 102: uint16(20510), + 103: uint16(20485), + 104: uint16(20487), + 105: uint16(20499), + 106: uint16(20514), + 107: uint16(20528), + 108: uint16(20507), + 109: uint16(20469), + 110: uint16(20468), + 111: uint16(20531), + 112: uint16(20535), + 113: uint16(20524), + 114: uint16(20470), + 115: uint16(20471), + 116: uint16(20503), + 117: uint16(20508), + 118: uint16(20512), + 119: uint16(20519), + 120: uint16(20533), + 121: uint16(20527), + 122: uint16(20529), + 123: uint16(20494), + 124: uint16(20826), + 125: uint16(20884), + 126: uint16(20883), + 127: uint16(20938), + 128: uint16(20932), + 129: uint16(20933), + 130: uint16(20936), + 131: uint16(20942), + 132: uint16(21089), + 133: uint16(21082), + 134: uint16(21074), + 135: uint16(21086), + 136: uint16(21087), + 137: uint16(21077), + 138: uint16(21090), + 139: uint16(21197), + 140: uint16(21262), + 141: uint16(21406), + 142: uint16(21798), + 143: uint16(21730), + 144: uint16(21783), + 145: uint16(21778), + 146: uint16(21735), + 147: uint16(21747), + 148: uint16(21732), + 149: uint16(21786), + 150: uint16(21759), + 151: uint16(21764), + 152: uint16(21768), + 153: uint16(21739), + 154: uint16(21777), + 155: uint16(21765), + 156: uint16(21745), + }, + 48: { + 0: uint16(21770), + 1: uint16(21755), + 2: uint16(21751), + 3: uint16(21752), + 4: uint16(21728), + 5: uint16(21774), + 6: uint16(21763), + 7: uint16(21771), + 8: uint16(22273), + 9: uint16(22274), + 10: uint16(22476), + 11: uint16(22578), + 12: uint16(22485), + 13: uint16(22482), + 14: uint16(22458), + 15: uint16(22470), + 16: uint16(22461), + 17: uint16(22460), + 18: uint16(22456), + 19: uint16(22454), + 20: uint16(22463), + 21: uint16(22471), + 22: uint16(22480), + 23: uint16(22457), + 24: uint16(22465), + 25: uint16(22798), + 26: uint16(22858), + 27: uint16(23065), + 28: uint16(23062), + 29: uint16(23085), + 30: uint16(23086), + 31: uint16(23061), + 32: uint16(23055), + 33: uint16(23063), + 34: uint16(23050), + 35: uint16(23070), + 36: uint16(23091), + 37: uint16(23404), + 38: uint16(23463), + 39: uint16(23469), + 40: uint16(23468), + 41: uint16(23555), + 42: uint16(23638), + 43: uint16(23636), + 44: uint16(23788), + 45: uint16(23807), + 46: uint16(23790), + 47: uint16(23793), + 48: uint16(23799), + 49: uint16(23808), + 50: uint16(23801), + 51: uint16(24105), + 52: uint16(24104), + 53: uint16(24232), + 54: uint16(24238), + 55: uint16(24234), + 56: uint16(24236), + 57: uint16(24371), + 58: uint16(24368), + 59: uint16(24423), + 60: uint16(24669), + 61: uint16(24666), + 62: uint16(24679), + 63: uint16(24641), + 64: uint16(24738), + 65: uint16(24712), + 66: uint16(24704), + 67: uint16(24722), + 68: uint16(24705), + 69: uint16(24733), + 70: uint16(24707), + 71: uint16(24725), + 72: uint16(24731), + 73: uint16(24727), + 74: uint16(24711), + 75: uint16(24732), + 76: uint16(24718), + 77: uint16(25113), + 78: uint16(25158), + 79: uint16(25330), + 80: uint16(25360), + 81: uint16(25430), + 82: uint16(25388), + 83: uint16(25412), + 84: uint16(25413), + 85: uint16(25398), + 86: uint16(25411), + 87: uint16(25572), + 88: uint16(25401), + 89: uint16(25419), + 90: uint16(25418), + 91: uint16(25404), + 92: uint16(25385), + 93: uint16(25409), + 94: uint16(25396), + 95: uint16(25432), + 96: uint16(25428), + 97: uint16(25433), + 98: uint16(25389), + 99: uint16(25415), + 100: uint16(25395), + 101: uint16(25434), + 102: uint16(25425), + 103: uint16(25400), + 104: uint16(25431), + 105: uint16(25408), + 106: uint16(25416), + 107: uint16(25930), + 108: uint16(25926), + 109: uint16(26054), + 110: uint16(26051), + 111: uint16(26052), + 112: uint16(26050), + 113: uint16(26186), + 114: uint16(26207), + 115: uint16(26183), + 116: uint16(26193), + 117: uint16(26386), + 118: uint16(26387), + 119: uint16(26655), + 120: uint16(26650), + 121: uint16(26697), + 122: uint16(26674), + 123: uint16(26675), + 124: uint16(26683), + 125: uint16(26699), + 126: uint16(26703), + 127: uint16(26646), + 128: uint16(26673), + 129: uint16(26652), + 130: uint16(26677), + 131: uint16(26667), + 132: uint16(26669), + 133: uint16(26671), + 134: uint16(26702), + 135: uint16(26692), + 136: uint16(26676), + 137: uint16(26653), + 138: uint16(26642), + 139: uint16(26644), + 140: uint16(26662), + 141: uint16(26664), + 142: uint16(26670), + 143: uint16(26701), + 144: uint16(26682), + 145: uint16(26661), + 146: uint16(26656), + 147: uint16(27436), + 148: uint16(27439), + 149: uint16(27437), + 150: uint16(27441), + 151: uint16(27444), + 152: uint16(27501), + 153: uint16(32898), + 154: uint16(27528), + 155: uint16(27622), + 156: uint16(27620), + }, + 49: { + 0: uint16(27624), + 1: uint16(27619), + 2: uint16(27618), + 3: uint16(27623), + 4: uint16(27685), + 5: uint16(28026), + 6: uint16(28003), + 7: uint16(28004), + 8: uint16(28022), + 9: uint16(27917), + 10: uint16(28001), + 11: uint16(28050), + 12: uint16(27992), + 13: uint16(28002), + 14: uint16(28013), + 15: uint16(28015), + 16: uint16(28049), + 17: uint16(28045), + 18: uint16(28143), + 19: uint16(28031), + 20: uint16(28038), + 21: uint16(27998), + 22: uint16(28007), + 23: uint16(28000), + 24: uint16(28055), + 25: uint16(28016), + 26: uint16(28028), + 27: uint16(27999), + 28: uint16(28034), + 29: uint16(28056), + 30: uint16(27951), + 31: uint16(28008), + 32: uint16(28043), + 33: uint16(28030), + 34: uint16(28032), + 35: uint16(28036), + 36: uint16(27926), + 37: uint16(28035), + 38: uint16(28027), + 39: uint16(28029), + 40: uint16(28021), + 41: uint16(28048), + 42: uint16(28892), + 43: uint16(28883), + 44: uint16(28881), + 45: uint16(28893), + 46: uint16(28875), + 47: uint16(32569), + 48: uint16(28898), + 49: uint16(28887), + 50: uint16(28882), + 51: uint16(28894), + 52: uint16(28896), + 53: uint16(28884), + 54: uint16(28877), + 55: uint16(28869), + 56: uint16(28870), + 57: uint16(28871), + 58: uint16(28890), + 59: uint16(28878), + 60: uint16(28897), + 61: uint16(29250), + 62: uint16(29304), + 63: uint16(29303), + 64: uint16(29302), + 65: uint16(29440), + 66: uint16(29434), + 67: uint16(29428), + 68: uint16(29438), + 69: uint16(29430), + 70: uint16(29427), + 71: uint16(29435), + 72: uint16(29441), + 73: uint16(29651), + 74: uint16(29657), + 75: uint16(29669), + 76: uint16(29654), + 77: uint16(29628), + 78: uint16(29671), + 79: uint16(29667), + 80: uint16(29673), + 81: uint16(29660), + 82: uint16(29650), + 83: uint16(29659), + 84: uint16(29652), + 85: uint16(29661), + 86: uint16(29658), + 87: uint16(29655), + 88: uint16(29656), + 89: uint16(29672), + 90: uint16(29918), + 91: uint16(29919), + 92: uint16(29940), + 93: uint16(29941), + 94: uint16(29985), + 95: uint16(30043), + 96: uint16(30047), + 97: uint16(30128), + 98: uint16(30145), + 99: uint16(30139), + 100: uint16(30148), + 101: uint16(30144), + 102: uint16(30143), + 103: uint16(30134), + 104: uint16(30138), + 105: uint16(30346), + 106: uint16(30409), + 107: uint16(30493), + 108: uint16(30491), + 109: uint16(30480), + 110: uint16(30483), + 111: uint16(30482), + 112: uint16(30499), + 113: uint16(30481), + 114: uint16(30485), + 115: uint16(30489), + 116: uint16(30490), + 117: uint16(30498), + 118: uint16(30503), + 119: uint16(30755), + 120: uint16(30764), + 121: uint16(30754), + 122: uint16(30773), + 123: uint16(30767), + 124: uint16(30760), + 125: uint16(30766), + 126: uint16(30763), + 127: uint16(30753), + 128: uint16(30761), + 129: uint16(30771), + 130: uint16(30762), + 131: uint16(30769), + 132: uint16(31060), + 133: uint16(31067), + 134: uint16(31055), + 135: uint16(31068), + 136: uint16(31059), + 137: uint16(31058), + 138: uint16(31057), + 139: uint16(31211), + 140: uint16(31212), + 141: uint16(31200), + 142: uint16(31214), + 143: uint16(31213), + 144: uint16(31210), + 145: uint16(31196), + 146: uint16(31198), + 147: uint16(31197), + 148: uint16(31366), + 149: uint16(31369), + 150: uint16(31365), + 151: uint16(31371), + 152: uint16(31372), + 153: uint16(31370), + 154: uint16(31367), + 155: uint16(31448), + 156: uint16(31504), + }, + 50: { + 0: uint16(31492), + 1: uint16(31507), + 2: uint16(31493), + 3: uint16(31503), + 4: uint16(31496), + 5: uint16(31498), + 6: uint16(31502), + 7: uint16(31497), + 8: uint16(31506), + 9: uint16(31876), + 10: uint16(31889), + 11: uint16(31882), + 12: uint16(31884), + 13: uint16(31880), + 14: uint16(31885), + 15: uint16(31877), + 16: uint16(32030), + 17: uint16(32029), + 18: uint16(32017), + 19: uint16(32014), + 20: uint16(32024), + 21: uint16(32022), + 22: uint16(32019), + 23: uint16(32031), + 24: uint16(32018), + 25: uint16(32015), + 26: uint16(32012), + 27: uint16(32604), + 28: uint16(32609), + 29: uint16(32606), + 30: uint16(32608), + 31: uint16(32605), + 32: uint16(32603), + 33: uint16(32662), + 34: uint16(32658), + 35: uint16(32707), + 36: uint16(32706), + 37: uint16(32704), + 38: uint16(32790), + 39: uint16(32830), + 40: uint16(32825), + 41: uint16(33018), + 42: uint16(33010), + 43: uint16(33017), + 44: uint16(33013), + 45: uint16(33025), + 46: uint16(33019), + 47: uint16(33024), + 48: uint16(33281), + 49: uint16(33327), + 50: uint16(33317), + 51: uint16(33587), + 52: uint16(33581), + 53: uint16(33604), + 54: uint16(33561), + 55: uint16(33617), + 56: uint16(33573), + 57: uint16(33622), + 58: uint16(33599), + 59: uint16(33601), + 60: uint16(33574), + 61: uint16(33564), + 62: uint16(33570), + 63: uint16(33602), + 64: uint16(33614), + 65: uint16(33563), + 66: uint16(33578), + 67: uint16(33544), + 68: uint16(33596), + 69: uint16(33613), + 70: uint16(33558), + 71: uint16(33572), + 72: uint16(33568), + 73: uint16(33591), + 74: uint16(33583), + 75: uint16(33577), + 76: uint16(33607), + 77: uint16(33605), + 78: uint16(33612), + 79: uint16(33619), + 80: uint16(33566), + 81: uint16(33580), + 82: uint16(33611), + 83: uint16(33575), + 84: uint16(33608), + 85: uint16(34387), + 86: uint16(34386), + 87: uint16(34466), + 88: uint16(34472), + 89: uint16(34454), + 90: uint16(34445), + 91: uint16(34449), + 92: uint16(34462), + 93: uint16(34439), + 94: uint16(34455), + 95: uint16(34438), + 96: uint16(34443), + 97: uint16(34458), + 98: uint16(34437), + 99: uint16(34469), + 100: uint16(34457), + 101: uint16(34465), + 102: uint16(34471), + 103: uint16(34453), + 104: uint16(34456), + 105: uint16(34446), + 106: uint16(34461), + 107: uint16(34448), + 108: uint16(34452), + 109: uint16(34883), + 110: uint16(34884), + 111: uint16(34925), + 112: uint16(34933), + 113: uint16(34934), + 114: uint16(34930), + 115: uint16(34944), + 116: uint16(34929), + 117: uint16(34943), + 118: uint16(34927), + 119: uint16(34947), + 120: uint16(34942), + 121: uint16(34932), + 122: uint16(34940), + 123: uint16(35346), + 124: uint16(35911), + 125: uint16(35927), + 126: uint16(35963), + 127: uint16(36004), + 128: uint16(36003), + 129: uint16(36214), + 130: uint16(36216), + 131: uint16(36277), + 132: uint16(36279), + 133: uint16(36278), + 134: uint16(36561), + 135: uint16(36563), + 136: uint16(36862), + 137: uint16(36853), + 138: uint16(36866), + 139: uint16(36863), + 140: uint16(36859), + 141: uint16(36868), + 142: uint16(36860), + 143: uint16(36854), + 144: uint16(37078), + 145: uint16(37088), + 146: uint16(37081), + 147: uint16(37082), + 148: uint16(37091), + 149: uint16(37087), + 150: uint16(37093), + 151: uint16(37080), + 152: uint16(37083), + 153: uint16(37079), + 154: uint16(37084), + 155: uint16(37092), + 156: uint16(37200), + }, + 51: { + 0: uint16(37198), + 1: uint16(37199), + 2: uint16(37333), + 3: uint16(37346), + 4: uint16(37338), + 5: uint16(38492), + 6: uint16(38495), + 7: uint16(38588), + 8: uint16(39139), + 9: uint16(39647), + 10: uint16(39727), + 11: uint16(20095), + 12: uint16(20592), + 13: uint16(20586), + 14: uint16(20577), + 15: uint16(20574), + 16: uint16(20576), + 17: uint16(20563), + 18: uint16(20555), + 19: uint16(20573), + 20: uint16(20594), + 21: uint16(20552), + 22: uint16(20557), + 23: uint16(20545), + 24: uint16(20571), + 25: uint16(20554), + 26: uint16(20578), + 27: uint16(20501), + 28: uint16(20549), + 29: uint16(20575), + 30: uint16(20585), + 31: uint16(20587), + 32: uint16(20579), + 33: uint16(20580), + 34: uint16(20550), + 35: uint16(20544), + 36: uint16(20590), + 37: uint16(20595), + 38: uint16(20567), + 39: uint16(20561), + 40: uint16(20944), + 41: uint16(21099), + 42: uint16(21101), + 43: uint16(21100), + 44: uint16(21102), + 45: uint16(21206), + 46: uint16(21203), + 47: uint16(21293), + 48: uint16(21404), + 49: uint16(21877), + 50: uint16(21878), + 51: uint16(21820), + 52: uint16(21837), + 53: uint16(21840), + 54: uint16(21812), + 55: uint16(21802), + 56: uint16(21841), + 57: uint16(21858), + 58: uint16(21814), + 59: uint16(21813), + 60: uint16(21808), + 61: uint16(21842), + 62: uint16(21829), + 63: uint16(21772), + 64: uint16(21810), + 65: uint16(21861), + 66: uint16(21838), + 67: uint16(21817), + 68: uint16(21832), + 69: uint16(21805), + 70: uint16(21819), + 71: uint16(21824), + 72: uint16(21835), + 73: uint16(22282), + 74: uint16(22279), + 75: uint16(22523), + 76: uint16(22548), + 77: uint16(22498), + 78: uint16(22518), + 79: uint16(22492), + 80: uint16(22516), + 81: uint16(22528), + 82: uint16(22509), + 83: uint16(22525), + 84: uint16(22536), + 85: uint16(22520), + 86: uint16(22539), + 87: uint16(22515), + 88: uint16(22479), + 89: uint16(22535), + 90: uint16(22510), + 91: uint16(22499), + 92: uint16(22514), + 93: uint16(22501), + 94: uint16(22508), + 95: uint16(22497), + 96: uint16(22542), + 97: uint16(22524), + 98: uint16(22544), + 99: uint16(22503), + 100: uint16(22529), + 101: uint16(22540), + 102: uint16(22513), + 103: uint16(22505), + 104: uint16(22512), + 105: uint16(22541), + 106: uint16(22532), + 107: uint16(22876), + 108: uint16(23136), + 109: uint16(23128), + 110: uint16(23125), + 111: uint16(23143), + 112: uint16(23134), + 113: uint16(23096), + 114: uint16(23093), + 115: uint16(23149), + 116: uint16(23120), + 117: uint16(23135), + 118: uint16(23141), + 119: uint16(23148), + 120: uint16(23123), + 121: uint16(23140), + 122: uint16(23127), + 123: uint16(23107), + 124: uint16(23133), + 125: uint16(23122), + 126: uint16(23108), + 127: uint16(23131), + 128: uint16(23112), + 129: uint16(23182), + 130: uint16(23102), + 131: uint16(23117), + 132: uint16(23097), + 133: uint16(23116), + 134: uint16(23152), + 135: uint16(23145), + 136: uint16(23111), + 137: uint16(23121), + 138: uint16(23126), + 139: uint16(23106), + 140: uint16(23132), + 141: uint16(23410), + 142: uint16(23406), + 143: uint16(23489), + 144: uint16(23488), + 145: uint16(23641), + 146: uint16(23838), + 147: uint16(23819), + 148: uint16(23837), + 149: uint16(23834), + 150: uint16(23840), + 151: uint16(23820), + 152: uint16(23848), + 153: uint16(23821), + 154: uint16(23846), + 155: uint16(23845), + 156: uint16(23823), + }, + 52: { + 0: uint16(23856), + 1: uint16(23826), + 2: uint16(23843), + 3: uint16(23839), + 4: uint16(23854), + 5: uint16(24126), + 6: uint16(24116), + 7: uint16(24241), + 8: uint16(24244), + 9: uint16(24249), + 10: uint16(24242), + 11: uint16(24243), + 12: uint16(24374), + 13: uint16(24376), + 14: uint16(24475), + 15: uint16(24470), + 16: uint16(24479), + 17: uint16(24714), + 18: uint16(24720), + 19: uint16(24710), + 20: uint16(24766), + 21: uint16(24752), + 22: uint16(24762), + 23: uint16(24787), + 24: uint16(24788), + 25: uint16(24783), + 26: uint16(24804), + 27: uint16(24793), + 28: uint16(24797), + 29: uint16(24776), + 30: uint16(24753), + 31: uint16(24795), + 32: uint16(24759), + 33: uint16(24778), + 34: uint16(24767), + 35: uint16(24771), + 36: uint16(24781), + 37: uint16(24768), + 38: uint16(25394), + 39: uint16(25445), + 40: uint16(25482), + 41: uint16(25474), + 42: uint16(25469), + 43: uint16(25533), + 44: uint16(25502), + 45: uint16(25517), + 46: uint16(25501), + 47: uint16(25495), + 48: uint16(25515), + 49: uint16(25486), + 50: uint16(25455), + 51: uint16(25479), + 52: uint16(25488), + 53: uint16(25454), + 54: uint16(25519), + 55: uint16(25461), + 56: uint16(25500), + 57: uint16(25453), + 58: uint16(25518), + 59: uint16(25468), + 60: uint16(25508), + 61: uint16(25403), + 62: uint16(25503), + 63: uint16(25464), + 64: uint16(25477), + 65: uint16(25473), + 66: uint16(25489), + 67: uint16(25485), + 68: uint16(25456), + 69: uint16(25939), + 70: uint16(26061), + 71: uint16(26213), + 72: uint16(26209), + 73: uint16(26203), + 74: uint16(26201), + 75: uint16(26204), + 76: uint16(26210), + 77: uint16(26392), + 78: uint16(26745), + 79: uint16(26759), + 80: uint16(26768), + 81: uint16(26780), + 82: uint16(26733), + 83: uint16(26734), + 84: uint16(26798), + 85: uint16(26795), + 86: uint16(26966), + 87: uint16(26735), + 88: uint16(26787), + 89: uint16(26796), + 90: uint16(26793), + 91: uint16(26741), + 92: uint16(26740), + 93: uint16(26802), + 94: uint16(26767), + 95: uint16(26743), + 96: uint16(26770), + 97: uint16(26748), + 98: uint16(26731), + 99: uint16(26738), + 100: uint16(26794), + 101: uint16(26752), + 102: uint16(26737), + 103: uint16(26750), + 104: uint16(26779), + 105: uint16(26774), + 106: uint16(26763), + 107: uint16(26784), + 108: uint16(26761), + 109: uint16(26788), + 110: uint16(26744), + 111: uint16(26747), + 112: uint16(26769), + 113: uint16(26764), + 114: uint16(26762), + 115: uint16(26749), + 116: uint16(27446), + 117: uint16(27443), + 118: uint16(27447), + 119: uint16(27448), + 120: uint16(27537), + 121: uint16(27535), + 122: uint16(27533), + 123: uint16(27534), + 124: uint16(27532), + 125: uint16(27690), + 126: uint16(28096), + 127: uint16(28075), + 128: uint16(28084), + 129: uint16(28083), + 130: uint16(28276), + 131: uint16(28076), + 132: uint16(28137), + 133: uint16(28130), + 134: uint16(28087), + 135: uint16(28150), + 136: uint16(28116), + 137: uint16(28160), + 138: uint16(28104), + 139: uint16(28128), + 140: uint16(28127), + 141: uint16(28118), + 142: uint16(28094), + 143: uint16(28133), + 144: uint16(28124), + 145: uint16(28125), + 146: uint16(28123), + 147: uint16(28148), + 148: uint16(28106), + 149: uint16(28093), + 150: uint16(28141), + 151: uint16(28144), + 152: uint16(28090), + 153: uint16(28117), + 154: uint16(28098), + 155: uint16(28111), + 156: uint16(28105), + }, + 53: { + 0: uint16(28112), + 1: uint16(28146), + 2: uint16(28115), + 3: uint16(28157), + 4: uint16(28119), + 5: uint16(28109), + 6: uint16(28131), + 7: uint16(28091), + 8: uint16(28922), + 9: uint16(28941), + 10: uint16(28919), + 11: uint16(28951), + 12: uint16(28916), + 13: uint16(28940), + 14: uint16(28912), + 15: uint16(28932), + 16: uint16(28915), + 17: uint16(28944), + 18: uint16(28924), + 19: uint16(28927), + 20: uint16(28934), + 21: uint16(28947), + 22: uint16(28928), + 23: uint16(28920), + 24: uint16(28918), + 25: uint16(28939), + 26: uint16(28930), + 27: uint16(28942), + 28: uint16(29310), + 29: uint16(29307), + 30: uint16(29308), + 31: uint16(29311), + 32: uint16(29469), + 33: uint16(29463), + 34: uint16(29447), + 35: uint16(29457), + 36: uint16(29464), + 37: uint16(29450), + 38: uint16(29448), + 39: uint16(29439), + 40: uint16(29455), + 41: uint16(29470), + 42: uint16(29576), + 43: uint16(29686), + 44: uint16(29688), + 45: uint16(29685), + 46: uint16(29700), + 47: uint16(29697), + 48: uint16(29693), + 49: uint16(29703), + 50: uint16(29696), + 51: uint16(29690), + 52: uint16(29692), + 53: uint16(29695), + 54: uint16(29708), + 55: uint16(29707), + 56: uint16(29684), + 57: uint16(29704), + 58: uint16(30052), + 59: uint16(30051), + 60: uint16(30158), + 61: uint16(30162), + 62: uint16(30159), + 63: uint16(30155), + 64: uint16(30156), + 65: uint16(30161), + 66: uint16(30160), + 67: uint16(30351), + 68: uint16(30345), + 69: uint16(30419), + 70: uint16(30521), + 71: uint16(30511), + 72: uint16(30509), + 73: uint16(30513), + 74: uint16(30514), + 75: uint16(30516), + 76: uint16(30515), + 77: uint16(30525), + 78: uint16(30501), + 79: uint16(30523), + 80: uint16(30517), + 81: uint16(30792), + 82: uint16(30802), + 83: uint16(30793), + 84: uint16(30797), + 85: uint16(30794), + 86: uint16(30796), + 87: uint16(30758), + 88: uint16(30789), + 89: uint16(30800), + 90: uint16(31076), + 91: uint16(31079), + 92: uint16(31081), + 93: uint16(31082), + 94: uint16(31075), + 95: uint16(31083), + 96: uint16(31073), + 97: uint16(31163), + 98: uint16(31226), + 99: uint16(31224), + 100: uint16(31222), + 101: uint16(31223), + 102: uint16(31375), + 103: uint16(31380), + 104: uint16(31376), + 105: uint16(31541), + 106: uint16(31559), + 107: uint16(31540), + 108: uint16(31525), + 109: uint16(31536), + 110: uint16(31522), + 111: uint16(31524), + 112: uint16(31539), + 113: uint16(31512), + 114: uint16(31530), + 115: uint16(31517), + 116: uint16(31537), + 117: uint16(31531), + 118: uint16(31533), + 119: uint16(31535), + 120: uint16(31538), + 121: uint16(31544), + 122: uint16(31514), + 123: uint16(31523), + 124: uint16(31892), + 125: uint16(31896), + 126: uint16(31894), + 127: uint16(31907), + 128: uint16(32053), + 129: uint16(32061), + 130: uint16(32056), + 131: uint16(32054), + 132: uint16(32058), + 133: uint16(32069), + 134: uint16(32044), + 135: uint16(32041), + 136: uint16(32065), + 137: uint16(32071), + 138: uint16(32062), + 139: uint16(32063), + 140: uint16(32074), + 141: uint16(32059), + 142: uint16(32040), + 143: uint16(32611), + 144: uint16(32661), + 145: uint16(32668), + 146: uint16(32669), + 147: uint16(32667), + 148: uint16(32714), + 149: uint16(32715), + 150: uint16(32717), + 151: uint16(32720), + 152: uint16(32721), + 153: uint16(32711), + 154: uint16(32719), + 155: uint16(32713), + 156: uint16(32799), + }, + 54: { + 0: uint16(32798), + 1: uint16(32795), + 2: uint16(32839), + 3: uint16(32835), + 4: uint16(32840), + 5: uint16(33048), + 6: uint16(33061), + 7: uint16(33049), + 8: uint16(33051), + 9: uint16(33069), + 10: uint16(33055), + 11: uint16(33068), + 12: uint16(33054), + 13: uint16(33057), + 14: uint16(33045), + 15: uint16(33063), + 16: uint16(33053), + 17: uint16(33058), + 18: uint16(33297), + 19: uint16(33336), + 20: uint16(33331), + 21: uint16(33338), + 22: uint16(33332), + 23: uint16(33330), + 24: uint16(33396), + 25: uint16(33680), + 26: uint16(33699), + 27: uint16(33704), + 28: uint16(33677), + 29: uint16(33658), + 30: uint16(33651), + 31: uint16(33700), + 32: uint16(33652), + 33: uint16(33679), + 34: uint16(33665), + 35: uint16(33685), + 36: uint16(33689), + 37: uint16(33653), + 38: uint16(33684), + 39: uint16(33705), + 40: uint16(33661), + 41: uint16(33667), + 42: uint16(33676), + 43: uint16(33693), + 44: uint16(33691), + 45: uint16(33706), + 46: uint16(33675), + 47: uint16(33662), + 48: uint16(33701), + 49: uint16(33711), + 50: uint16(33672), + 51: uint16(33687), + 52: uint16(33712), + 53: uint16(33663), + 54: uint16(33702), + 55: uint16(33671), + 56: uint16(33710), + 57: uint16(33654), + 58: uint16(33690), + 59: uint16(34393), + 60: uint16(34390), + 61: uint16(34495), + 62: uint16(34487), + 63: uint16(34498), + 64: uint16(34497), + 65: uint16(34501), + 66: uint16(34490), + 67: uint16(34480), + 68: uint16(34504), + 69: uint16(34489), + 70: uint16(34483), + 71: uint16(34488), + 72: uint16(34508), + 73: uint16(34484), + 74: uint16(34491), + 75: uint16(34492), + 76: uint16(34499), + 77: uint16(34493), + 78: uint16(34494), + 79: uint16(34898), + 80: uint16(34953), + 81: uint16(34965), + 82: uint16(34984), + 83: uint16(34978), + 84: uint16(34986), + 85: uint16(34970), + 86: uint16(34961), + 87: uint16(34977), + 88: uint16(34975), + 89: uint16(34968), + 90: uint16(34983), + 91: uint16(34969), + 92: uint16(34971), + 93: uint16(34967), + 94: uint16(34980), + 95: uint16(34988), + 96: uint16(34956), + 97: uint16(34963), + 98: uint16(34958), + 99: uint16(35202), + 100: uint16(35286), + 101: uint16(35289), + 102: uint16(35285), + 103: uint16(35376), + 104: uint16(35367), + 105: uint16(35372), + 106: uint16(35358), + 107: uint16(35897), + 108: uint16(35899), + 109: uint16(35932), + 110: uint16(35933), + 111: uint16(35965), + 112: uint16(36005), + 113: uint16(36221), + 114: uint16(36219), + 115: uint16(36217), + 116: uint16(36284), + 117: uint16(36290), + 118: uint16(36281), + 119: uint16(36287), + 120: uint16(36289), + 121: uint16(36568), + 122: uint16(36574), + 123: uint16(36573), + 124: uint16(36572), + 125: uint16(36567), + 126: uint16(36576), + 127: uint16(36577), + 128: uint16(36900), + 129: uint16(36875), + 130: uint16(36881), + 131: uint16(36892), + 132: uint16(36876), + 133: uint16(36897), + 134: uint16(37103), + 135: uint16(37098), + 136: uint16(37104), + 137: uint16(37108), + 138: uint16(37106), + 139: uint16(37107), + 140: uint16(37076), + 141: uint16(37099), + 142: uint16(37100), + 143: uint16(37097), + 144: uint16(37206), + 145: uint16(37208), + 146: uint16(37210), + 147: uint16(37203), + 148: uint16(37205), + 149: uint16(37356), + 150: uint16(37364), + 151: uint16(37361), + 152: uint16(37363), + 153: uint16(37368), + 154: uint16(37348), + 155: uint16(37369), + 156: uint16(37354), + }, + 55: { + 0: uint16(37355), + 1: uint16(37367), + 2: uint16(37352), + 3: uint16(37358), + 4: uint16(38266), + 5: uint16(38278), + 6: uint16(38280), + 7: uint16(38524), + 8: uint16(38509), + 9: uint16(38507), + 10: uint16(38513), + 11: uint16(38511), + 12: uint16(38591), + 13: uint16(38762), + 14: uint16(38916), + 15: uint16(39141), + 16: uint16(39319), + 17: uint16(20635), + 18: uint16(20629), + 19: uint16(20628), + 20: uint16(20638), + 21: uint16(20619), + 22: uint16(20643), + 23: uint16(20611), + 24: uint16(20620), + 25: uint16(20622), + 26: uint16(20637), + 27: uint16(20584), + 28: uint16(20636), + 29: uint16(20626), + 30: uint16(20610), + 31: uint16(20615), + 32: uint16(20831), + 33: uint16(20948), + 34: uint16(21266), + 35: uint16(21265), + 36: uint16(21412), + 37: uint16(21415), + 38: uint16(21905), + 39: uint16(21928), + 40: uint16(21925), + 41: uint16(21933), + 42: uint16(21879), + 43: uint16(22085), + 44: uint16(21922), + 45: uint16(21907), + 46: uint16(21896), + 47: uint16(21903), + 48: uint16(21941), + 49: uint16(21889), + 50: uint16(21923), + 51: uint16(21906), + 52: uint16(21924), + 53: uint16(21885), + 54: uint16(21900), + 55: uint16(21926), + 56: uint16(21887), + 57: uint16(21909), + 58: uint16(21921), + 59: uint16(21902), + 60: uint16(22284), + 61: uint16(22569), + 62: uint16(22583), + 63: uint16(22553), + 64: uint16(22558), + 65: uint16(22567), + 66: uint16(22563), + 67: uint16(22568), + 68: uint16(22517), + 69: uint16(22600), + 70: uint16(22565), + 71: uint16(22556), + 72: uint16(22555), + 73: uint16(22579), + 74: uint16(22591), + 75: uint16(22582), + 76: uint16(22574), + 77: uint16(22585), + 78: uint16(22584), + 79: uint16(22573), + 80: uint16(22572), + 81: uint16(22587), + 82: uint16(22881), + 83: uint16(23215), + 84: uint16(23188), + 85: uint16(23199), + 86: uint16(23162), + 87: uint16(23202), + 88: uint16(23198), + 89: uint16(23160), + 90: uint16(23206), + 91: uint16(23164), + 92: uint16(23205), + 93: uint16(23212), + 94: uint16(23189), + 95: uint16(23214), + 96: uint16(23095), + 97: uint16(23172), + 98: uint16(23178), + 99: uint16(23191), + 100: uint16(23171), + 101: uint16(23179), + 102: uint16(23209), + 103: uint16(23163), + 104: uint16(23165), + 105: uint16(23180), + 106: uint16(23196), + 107: uint16(23183), + 108: uint16(23187), + 109: uint16(23197), + 110: uint16(23530), + 111: uint16(23501), + 112: uint16(23499), + 113: uint16(23508), + 114: uint16(23505), + 115: uint16(23498), + 116: uint16(23502), + 117: uint16(23564), + 118: uint16(23600), + 119: uint16(23863), + 120: uint16(23875), + 121: uint16(23915), + 122: uint16(23873), + 123: uint16(23883), + 124: uint16(23871), + 125: uint16(23861), + 126: uint16(23889), + 127: uint16(23886), + 128: uint16(23893), + 129: uint16(23859), + 130: uint16(23866), + 131: uint16(23890), + 132: uint16(23869), + 133: uint16(23857), + 134: uint16(23897), + 135: uint16(23874), + 136: uint16(23865), + 137: uint16(23881), + 138: uint16(23864), + 139: uint16(23868), + 140: uint16(23858), + 141: uint16(23862), + 142: uint16(23872), + 143: uint16(23877), + 144: uint16(24132), + 145: uint16(24129), + 146: uint16(24408), + 147: uint16(24486), + 148: uint16(24485), + 149: uint16(24491), + 150: uint16(24777), + 151: uint16(24761), + 152: uint16(24780), + 153: uint16(24802), + 154: uint16(24782), + 155: uint16(24772), + 156: uint16(24852), + }, + 56: { + 0: uint16(24818), + 1: uint16(24842), + 2: uint16(24854), + 3: uint16(24837), + 4: uint16(24821), + 5: uint16(24851), + 6: uint16(24824), + 7: uint16(24828), + 8: uint16(24830), + 9: uint16(24769), + 10: uint16(24835), + 11: uint16(24856), + 12: uint16(24861), + 13: uint16(24848), + 14: uint16(24831), + 15: uint16(24836), + 16: uint16(24843), + 17: uint16(25162), + 18: uint16(25492), + 19: uint16(25521), + 20: uint16(25520), + 21: uint16(25550), + 22: uint16(25573), + 23: uint16(25576), + 24: uint16(25583), + 25: uint16(25539), + 26: uint16(25757), + 27: uint16(25587), + 28: uint16(25546), + 29: uint16(25568), + 30: uint16(25590), + 31: uint16(25557), + 32: uint16(25586), + 33: uint16(25589), + 34: uint16(25697), + 35: uint16(25567), + 36: uint16(25534), + 37: uint16(25565), + 38: uint16(25564), + 39: uint16(25540), + 40: uint16(25560), + 41: uint16(25555), + 42: uint16(25538), + 43: uint16(25543), + 44: uint16(25548), + 45: uint16(25547), + 46: uint16(25544), + 47: uint16(25584), + 48: uint16(25559), + 49: uint16(25561), + 50: uint16(25906), + 51: uint16(25959), + 52: uint16(25962), + 53: uint16(25956), + 54: uint16(25948), + 55: uint16(25960), + 56: uint16(25957), + 57: uint16(25996), + 58: uint16(26013), + 59: uint16(26014), + 60: uint16(26030), + 61: uint16(26064), + 62: uint16(26066), + 63: uint16(26236), + 64: uint16(26220), + 65: uint16(26235), + 66: uint16(26240), + 67: uint16(26225), + 68: uint16(26233), + 69: uint16(26218), + 70: uint16(26226), + 71: uint16(26369), + 72: uint16(26892), + 73: uint16(26835), + 74: uint16(26884), + 75: uint16(26844), + 76: uint16(26922), + 77: uint16(26860), + 78: uint16(26858), + 79: uint16(26865), + 80: uint16(26895), + 81: uint16(26838), + 82: uint16(26871), + 83: uint16(26859), + 84: uint16(26852), + 85: uint16(26870), + 86: uint16(26899), + 87: uint16(26896), + 88: uint16(26867), + 89: uint16(26849), + 90: uint16(26887), + 91: uint16(26828), + 92: uint16(26888), + 93: uint16(26992), + 94: uint16(26804), + 95: uint16(26897), + 96: uint16(26863), + 97: uint16(26822), + 98: uint16(26900), + 99: uint16(26872), + 100: uint16(26832), + 101: uint16(26877), + 102: uint16(26876), + 103: uint16(26856), + 104: uint16(26891), + 105: uint16(26890), + 106: uint16(26903), + 107: uint16(26830), + 108: uint16(26824), + 109: uint16(26845), + 110: uint16(26846), + 111: uint16(26854), + 112: uint16(26868), + 113: uint16(26833), + 114: uint16(26886), + 115: uint16(26836), + 116: uint16(26857), + 117: uint16(26901), + 118: uint16(26917), + 119: uint16(26823), + 120: uint16(27449), + 121: uint16(27451), + 122: uint16(27455), + 123: uint16(27452), + 124: uint16(27540), + 125: uint16(27543), + 126: uint16(27545), + 127: uint16(27541), + 128: uint16(27581), + 129: uint16(27632), + 130: uint16(27634), + 131: uint16(27635), + 132: uint16(27696), + 133: uint16(28156), + 134: uint16(28230), + 135: uint16(28231), + 136: uint16(28191), + 137: uint16(28233), + 138: uint16(28296), + 139: uint16(28220), + 140: uint16(28221), + 141: uint16(28229), + 142: uint16(28258), + 143: uint16(28203), + 144: uint16(28223), + 145: uint16(28225), + 146: uint16(28253), + 147: uint16(28275), + 148: uint16(28188), + 149: uint16(28211), + 150: uint16(28235), + 151: uint16(28224), + 152: uint16(28241), + 153: uint16(28219), + 154: uint16(28163), + 155: uint16(28206), + 156: uint16(28254), + }, + 57: { + 0: uint16(28264), + 1: uint16(28252), + 2: uint16(28257), + 3: uint16(28209), + 4: uint16(28200), + 5: uint16(28256), + 6: uint16(28273), + 7: uint16(28267), + 8: uint16(28217), + 9: uint16(28194), + 10: uint16(28208), + 11: uint16(28243), + 12: uint16(28261), + 13: uint16(28199), + 14: uint16(28280), + 15: uint16(28260), + 16: uint16(28279), + 17: uint16(28245), + 18: uint16(28281), + 19: uint16(28242), + 20: uint16(28262), + 21: uint16(28213), + 22: uint16(28214), + 23: uint16(28250), + 24: uint16(28960), + 25: uint16(28958), + 26: uint16(28975), + 27: uint16(28923), + 28: uint16(28974), + 29: uint16(28977), + 30: uint16(28963), + 31: uint16(28965), + 32: uint16(28962), + 33: uint16(28978), + 34: uint16(28959), + 35: uint16(28968), + 36: uint16(28986), + 37: uint16(28955), + 38: uint16(29259), + 39: uint16(29274), + 40: uint16(29320), + 41: uint16(29321), + 42: uint16(29318), + 43: uint16(29317), + 44: uint16(29323), + 45: uint16(29458), + 46: uint16(29451), + 47: uint16(29488), + 48: uint16(29474), + 49: uint16(29489), + 50: uint16(29491), + 51: uint16(29479), + 52: uint16(29490), + 53: uint16(29485), + 54: uint16(29478), + 55: uint16(29475), + 56: uint16(29493), + 57: uint16(29452), + 58: uint16(29742), + 59: uint16(29740), + 60: uint16(29744), + 61: uint16(29739), + 62: uint16(29718), + 63: uint16(29722), + 64: uint16(29729), + 65: uint16(29741), + 66: uint16(29745), + 67: uint16(29732), + 68: uint16(29731), + 69: uint16(29725), + 70: uint16(29737), + 71: uint16(29728), + 72: uint16(29746), + 73: uint16(29947), + 74: uint16(29999), + 75: uint16(30063), + 76: uint16(30060), + 77: uint16(30183), + 78: uint16(30170), + 79: uint16(30177), + 80: uint16(30182), + 81: uint16(30173), + 82: uint16(30175), + 83: uint16(30180), + 84: uint16(30167), + 85: uint16(30357), + 86: uint16(30354), + 87: uint16(30426), + 88: uint16(30534), + 89: uint16(30535), + 90: uint16(30532), + 91: uint16(30541), + 92: uint16(30533), + 93: uint16(30538), + 94: uint16(30542), + 95: uint16(30539), + 96: uint16(30540), + 97: uint16(30686), + 98: uint16(30700), + 99: uint16(30816), + 100: uint16(30820), + 101: uint16(30821), + 102: uint16(30812), + 103: uint16(30829), + 104: uint16(30833), + 105: uint16(30826), + 106: uint16(30830), + 107: uint16(30832), + 108: uint16(30825), + 109: uint16(30824), + 110: uint16(30814), + 111: uint16(30818), + 112: uint16(31092), + 113: uint16(31091), + 114: uint16(31090), + 115: uint16(31088), + 116: uint16(31234), + 117: uint16(31242), + 118: uint16(31235), + 119: uint16(31244), + 120: uint16(31236), + 121: uint16(31385), + 122: uint16(31462), + 123: uint16(31460), + 124: uint16(31562), + 125: uint16(31547), + 126: uint16(31556), + 127: uint16(31560), + 128: uint16(31564), + 129: uint16(31566), + 130: uint16(31552), + 131: uint16(31576), + 132: uint16(31557), + 133: uint16(31906), + 134: uint16(31902), + 135: uint16(31912), + 136: uint16(31905), + 137: uint16(32088), + 138: uint16(32111), + 139: uint16(32099), + 140: uint16(32083), + 141: uint16(32086), + 142: uint16(32103), + 143: uint16(32106), + 144: uint16(32079), + 145: uint16(32109), + 146: uint16(32092), + 147: uint16(32107), + 148: uint16(32082), + 149: uint16(32084), + 150: uint16(32105), + 151: uint16(32081), + 152: uint16(32095), + 153: uint16(32078), + 154: uint16(32574), + 155: uint16(32575), + 156: uint16(32613), + }, + 58: { + 0: uint16(32614), + 1: uint16(32674), + 2: uint16(32672), + 3: uint16(32673), + 4: uint16(32727), + 5: uint16(32849), + 6: uint16(32847), + 7: uint16(32848), + 8: uint16(33022), + 9: uint16(32980), + 10: uint16(33091), + 11: uint16(33098), + 12: uint16(33106), + 13: uint16(33103), + 14: uint16(33095), + 15: uint16(33085), + 16: uint16(33101), + 17: uint16(33082), + 18: uint16(33254), + 19: uint16(33262), + 20: uint16(33271), + 21: uint16(33272), + 22: uint16(33273), + 23: uint16(33284), + 24: uint16(33340), + 25: uint16(33341), + 26: uint16(33343), + 27: uint16(33397), + 28: uint16(33595), + 29: uint16(33743), + 30: uint16(33785), + 31: uint16(33827), + 32: uint16(33728), + 33: uint16(33768), + 34: uint16(33810), + 35: uint16(33767), + 36: uint16(33764), + 37: uint16(33788), + 38: uint16(33782), + 39: uint16(33808), + 40: uint16(33734), + 41: uint16(33736), + 42: uint16(33771), + 43: uint16(33763), + 44: uint16(33727), + 45: uint16(33793), + 46: uint16(33757), + 47: uint16(33765), + 48: uint16(33752), + 49: uint16(33791), + 50: uint16(33761), + 51: uint16(33739), + 52: uint16(33742), + 53: uint16(33750), + 54: uint16(33781), + 55: uint16(33737), + 56: uint16(33801), + 57: uint16(33807), + 58: uint16(33758), + 59: uint16(33809), + 60: uint16(33798), + 61: uint16(33730), + 62: uint16(33779), + 63: uint16(33749), + 64: uint16(33786), + 65: uint16(33735), + 66: uint16(33745), + 67: uint16(33770), + 68: uint16(33811), + 69: uint16(33731), + 70: uint16(33772), + 71: uint16(33774), + 72: uint16(33732), + 73: uint16(33787), + 74: uint16(33751), + 75: uint16(33762), + 76: uint16(33819), + 77: uint16(33755), + 78: uint16(33790), + 79: uint16(34520), + 80: uint16(34530), + 81: uint16(34534), + 82: uint16(34515), + 83: uint16(34531), + 84: uint16(34522), + 85: uint16(34538), + 86: uint16(34525), + 87: uint16(34539), + 88: uint16(34524), + 89: uint16(34540), + 90: uint16(34537), + 91: uint16(34519), + 92: uint16(34536), + 93: uint16(34513), + 94: uint16(34888), + 95: uint16(34902), + 96: uint16(34901), + 97: uint16(35002), + 98: uint16(35031), + 99: uint16(35001), + 100: uint16(35000), + 101: uint16(35008), + 102: uint16(35006), + 103: uint16(34998), + 104: uint16(35004), + 105: uint16(34999), + 106: uint16(35005), + 107: uint16(34994), + 108: uint16(35073), + 109: uint16(35017), + 110: uint16(35221), + 111: uint16(35224), + 112: uint16(35223), + 113: uint16(35293), + 114: uint16(35290), + 115: uint16(35291), + 116: uint16(35406), + 117: uint16(35405), + 118: uint16(35385), + 119: uint16(35417), + 120: uint16(35392), + 121: uint16(35415), + 122: uint16(35416), + 123: uint16(35396), + 124: uint16(35397), + 125: uint16(35410), + 126: uint16(35400), + 127: uint16(35409), + 128: uint16(35402), + 129: uint16(35404), + 130: uint16(35407), + 131: uint16(35935), + 132: uint16(35969), + 133: uint16(35968), + 134: uint16(36026), + 135: uint16(36030), + 136: uint16(36016), + 137: uint16(36025), + 138: uint16(36021), + 139: uint16(36228), + 140: uint16(36224), + 141: uint16(36233), + 142: uint16(36312), + 143: uint16(36307), + 144: uint16(36301), + 145: uint16(36295), + 146: uint16(36310), + 147: uint16(36316), + 148: uint16(36303), + 149: uint16(36309), + 150: uint16(36313), + 151: uint16(36296), + 152: uint16(36311), + 153: uint16(36293), + 154: uint16(36591), + 155: uint16(36599), + 156: uint16(36602), + }, + 59: { + 0: uint16(36601), + 1: uint16(36582), + 2: uint16(36590), + 3: uint16(36581), + 4: uint16(36597), + 5: uint16(36583), + 6: uint16(36584), + 7: uint16(36598), + 8: uint16(36587), + 9: uint16(36593), + 10: uint16(36588), + 11: uint16(36596), + 12: uint16(36585), + 13: uint16(36909), + 14: uint16(36916), + 15: uint16(36911), + 16: uint16(37126), + 17: uint16(37164), + 18: uint16(37124), + 19: uint16(37119), + 20: uint16(37116), + 21: uint16(37128), + 22: uint16(37113), + 23: uint16(37115), + 24: uint16(37121), + 25: uint16(37120), + 26: uint16(37127), + 27: uint16(37125), + 28: uint16(37123), + 29: uint16(37217), + 30: uint16(37220), + 31: uint16(37215), + 32: uint16(37218), + 33: uint16(37216), + 34: uint16(37377), + 35: uint16(37386), + 36: uint16(37413), + 37: uint16(37379), + 38: uint16(37402), + 39: uint16(37414), + 40: uint16(37391), + 41: uint16(37388), + 42: uint16(37376), + 43: uint16(37394), + 44: uint16(37375), + 45: uint16(37373), + 46: uint16(37382), + 47: uint16(37380), + 48: uint16(37415), + 49: uint16(37378), + 50: uint16(37404), + 51: uint16(37412), + 52: uint16(37401), + 53: uint16(37399), + 54: uint16(37381), + 55: uint16(37398), + 56: uint16(38267), + 57: uint16(38285), + 58: uint16(38284), + 59: uint16(38288), + 60: uint16(38535), + 61: uint16(38526), + 62: uint16(38536), + 63: uint16(38537), + 64: uint16(38531), + 65: uint16(38528), + 66: uint16(38594), + 67: uint16(38600), + 68: uint16(38595), + 69: uint16(38641), + 70: uint16(38640), + 71: uint16(38764), + 72: uint16(38768), + 73: uint16(38766), + 74: uint16(38919), + 75: uint16(39081), + 76: uint16(39147), + 77: uint16(40166), + 78: uint16(40697), + 79: uint16(20099), + 80: uint16(20100), + 81: uint16(20150), + 82: uint16(20669), + 83: uint16(20671), + 84: uint16(20678), + 85: uint16(20654), + 86: uint16(20676), + 87: uint16(20682), + 88: uint16(20660), + 89: uint16(20680), + 90: uint16(20674), + 91: uint16(20656), + 92: uint16(20673), + 93: uint16(20666), + 94: uint16(20657), + 95: uint16(20683), + 96: uint16(20681), + 97: uint16(20662), + 98: uint16(20664), + 99: uint16(20951), + 100: uint16(21114), + 101: uint16(21112), + 102: uint16(21115), + 103: uint16(21116), + 104: uint16(21955), + 105: uint16(21979), + 106: uint16(21964), + 107: uint16(21968), + 108: uint16(21963), + 109: uint16(21962), + 110: uint16(21981), + 111: uint16(21952), + 112: uint16(21972), + 113: uint16(21956), + 114: uint16(21993), + 115: uint16(21951), + 116: uint16(21970), + 117: uint16(21901), + 118: uint16(21967), + 119: uint16(21973), + 120: uint16(21986), + 121: uint16(21974), + 122: uint16(21960), + 123: uint16(22002), + 124: uint16(21965), + 125: uint16(21977), + 126: uint16(21954), + 127: uint16(22292), + 128: uint16(22611), + 129: uint16(22632), + 130: uint16(22628), + 131: uint16(22607), + 132: uint16(22605), + 133: uint16(22601), + 134: uint16(22639), + 135: uint16(22613), + 136: uint16(22606), + 137: uint16(22621), + 138: uint16(22617), + 139: uint16(22629), + 140: uint16(22619), + 141: uint16(22589), + 142: uint16(22627), + 143: uint16(22641), + 144: uint16(22780), + 145: uint16(23239), + 146: uint16(23236), + 147: uint16(23243), + 148: uint16(23226), + 149: uint16(23224), + 150: uint16(23217), + 151: uint16(23221), + 152: uint16(23216), + 153: uint16(23231), + 154: uint16(23240), + 155: uint16(23227), + 156: uint16(23238), + }, + 60: { + 0: uint16(23223), + 1: uint16(23232), + 2: uint16(23242), + 3: uint16(23220), + 4: uint16(23222), + 5: uint16(23245), + 6: uint16(23225), + 7: uint16(23184), + 8: uint16(23510), + 9: uint16(23512), + 10: uint16(23513), + 11: uint16(23583), + 12: uint16(23603), + 13: uint16(23921), + 14: uint16(23907), + 15: uint16(23882), + 16: uint16(23909), + 17: uint16(23922), + 18: uint16(23916), + 19: uint16(23902), + 20: uint16(23912), + 21: uint16(23911), + 22: uint16(23906), + 23: uint16(24048), + 24: uint16(24143), + 25: uint16(24142), + 26: uint16(24138), + 27: uint16(24141), + 28: uint16(24139), + 29: uint16(24261), + 30: uint16(24268), + 31: uint16(24262), + 32: uint16(24267), + 33: uint16(24263), + 34: uint16(24384), + 35: uint16(24495), + 36: uint16(24493), + 37: uint16(24823), + 38: uint16(24905), + 39: uint16(24906), + 40: uint16(24875), + 41: uint16(24901), + 42: uint16(24886), + 43: uint16(24882), + 44: uint16(24878), + 45: uint16(24902), + 46: uint16(24879), + 47: uint16(24911), + 48: uint16(24873), + 49: uint16(24896), + 50: uint16(25120), + 51: uint16(37224), + 52: uint16(25123), + 53: uint16(25125), + 54: uint16(25124), + 55: uint16(25541), + 56: uint16(25585), + 57: uint16(25579), + 58: uint16(25616), + 59: uint16(25618), + 60: uint16(25609), + 61: uint16(25632), + 62: uint16(25636), + 63: uint16(25651), + 64: uint16(25667), + 65: uint16(25631), + 66: uint16(25621), + 67: uint16(25624), + 68: uint16(25657), + 69: uint16(25655), + 70: uint16(25634), + 71: uint16(25635), + 72: uint16(25612), + 73: uint16(25638), + 74: uint16(25648), + 75: uint16(25640), + 76: uint16(25665), + 77: uint16(25653), + 78: uint16(25647), + 79: uint16(25610), + 80: uint16(25626), + 81: uint16(25664), + 82: uint16(25637), + 83: uint16(25639), + 84: uint16(25611), + 85: uint16(25575), + 86: uint16(25627), + 87: uint16(25646), + 88: uint16(25633), + 89: uint16(25614), + 90: uint16(25967), + 91: uint16(26002), + 92: uint16(26067), + 93: uint16(26246), + 94: uint16(26252), + 95: uint16(26261), + 96: uint16(26256), + 97: uint16(26251), + 98: uint16(26250), + 99: uint16(26265), + 100: uint16(26260), + 101: uint16(26232), + 102: uint16(26400), + 103: uint16(26982), + 104: uint16(26975), + 105: uint16(26936), + 106: uint16(26958), + 107: uint16(26978), + 108: uint16(26993), + 109: uint16(26943), + 110: uint16(26949), + 111: uint16(26986), + 112: uint16(26937), + 113: uint16(26946), + 114: uint16(26967), + 115: uint16(26969), + 116: uint16(27002), + 117: uint16(26952), + 118: uint16(26953), + 119: uint16(26933), + 120: uint16(26988), + 121: uint16(26931), + 122: uint16(26941), + 123: uint16(26981), + 124: uint16(26864), + 125: uint16(27000), + 126: uint16(26932), + 127: uint16(26985), + 128: uint16(26944), + 129: uint16(26991), + 130: uint16(26948), + 131: uint16(26998), + 132: uint16(26968), + 133: uint16(26945), + 134: uint16(26996), + 135: uint16(26956), + 136: uint16(26939), + 137: uint16(26955), + 138: uint16(26935), + 139: uint16(26972), + 140: uint16(26959), + 141: uint16(26961), + 142: uint16(26930), + 143: uint16(26962), + 144: uint16(26927), + 145: uint16(27003), + 146: uint16(26940), + 147: uint16(27462), + 148: uint16(27461), + 149: uint16(27459), + 150: uint16(27458), + 151: uint16(27464), + 152: uint16(27457), + 153: uint16(27547), + 154: uint16(64013), + 155: uint16(27643), + 156: uint16(27644), + }, + 61: { + 0: uint16(27641), + 1: uint16(27639), + 2: uint16(27640), + 3: uint16(28315), + 4: uint16(28374), + 5: uint16(28360), + 6: uint16(28303), + 7: uint16(28352), + 8: uint16(28319), + 9: uint16(28307), + 10: uint16(28308), + 11: uint16(28320), + 12: uint16(28337), + 13: uint16(28345), + 14: uint16(28358), + 15: uint16(28370), + 16: uint16(28349), + 17: uint16(28353), + 18: uint16(28318), + 19: uint16(28361), + 20: uint16(28343), + 21: uint16(28336), + 22: uint16(28365), + 23: uint16(28326), + 24: uint16(28367), + 25: uint16(28338), + 26: uint16(28350), + 27: uint16(28355), + 28: uint16(28380), + 29: uint16(28376), + 30: uint16(28313), + 31: uint16(28306), + 32: uint16(28302), + 33: uint16(28301), + 34: uint16(28324), + 35: uint16(28321), + 36: uint16(28351), + 37: uint16(28339), + 38: uint16(28368), + 39: uint16(28362), + 40: uint16(28311), + 41: uint16(28334), + 42: uint16(28323), + 43: uint16(28999), + 44: uint16(29012), + 45: uint16(29010), + 46: uint16(29027), + 47: uint16(29024), + 48: uint16(28993), + 49: uint16(29021), + 50: uint16(29026), + 51: uint16(29042), + 52: uint16(29048), + 53: uint16(29034), + 54: uint16(29025), + 55: uint16(28994), + 56: uint16(29016), + 57: uint16(28995), + 58: uint16(29003), + 59: uint16(29040), + 60: uint16(29023), + 61: uint16(29008), + 62: uint16(29011), + 63: uint16(28996), + 64: uint16(29005), + 65: uint16(29018), + 66: uint16(29263), + 67: uint16(29325), + 68: uint16(29324), + 69: uint16(29329), + 70: uint16(29328), + 71: uint16(29326), + 72: uint16(29500), + 73: uint16(29506), + 74: uint16(29499), + 75: uint16(29498), + 76: uint16(29504), + 77: uint16(29514), + 78: uint16(29513), + 79: uint16(29764), + 80: uint16(29770), + 81: uint16(29771), + 82: uint16(29778), + 83: uint16(29777), + 84: uint16(29783), + 85: uint16(29760), + 86: uint16(29775), + 87: uint16(29776), + 88: uint16(29774), + 89: uint16(29762), + 90: uint16(29766), + 91: uint16(29773), + 92: uint16(29780), + 93: uint16(29921), + 94: uint16(29951), + 95: uint16(29950), + 96: uint16(29949), + 97: uint16(29981), + 98: uint16(30073), + 99: uint16(30071), + 100: uint16(27011), + 101: uint16(30191), + 102: uint16(30223), + 103: uint16(30211), + 104: uint16(30199), + 105: uint16(30206), + 106: uint16(30204), + 107: uint16(30201), + 108: uint16(30200), + 109: uint16(30224), + 110: uint16(30203), + 111: uint16(30198), + 112: uint16(30189), + 113: uint16(30197), + 114: uint16(30205), + 115: uint16(30361), + 116: uint16(30389), + 117: uint16(30429), + 118: uint16(30549), + 119: uint16(30559), + 120: uint16(30560), + 121: uint16(30546), + 122: uint16(30550), + 123: uint16(30554), + 124: uint16(30569), + 125: uint16(30567), + 126: uint16(30548), + 127: uint16(30553), + 128: uint16(30573), + 129: uint16(30688), + 130: uint16(30855), + 131: uint16(30874), + 132: uint16(30868), + 133: uint16(30863), + 134: uint16(30852), + 135: uint16(30869), + 136: uint16(30853), + 137: uint16(30854), + 138: uint16(30881), + 139: uint16(30851), + 140: uint16(30841), + 141: uint16(30873), + 142: uint16(30848), + 143: uint16(30870), + 144: uint16(30843), + 145: uint16(31100), + 146: uint16(31106), + 147: uint16(31101), + 148: uint16(31097), + 149: uint16(31249), + 150: uint16(31256), + 151: uint16(31257), + 152: uint16(31250), + 153: uint16(31255), + 154: uint16(31253), + 155: uint16(31266), + 156: uint16(31251), + }, + 62: { + 0: uint16(31259), + 1: uint16(31248), + 2: uint16(31395), + 3: uint16(31394), + 4: uint16(31390), + 5: uint16(31467), + 6: uint16(31590), + 7: uint16(31588), + 8: uint16(31597), + 9: uint16(31604), + 10: uint16(31593), + 11: uint16(31602), + 12: uint16(31589), + 13: uint16(31603), + 14: uint16(31601), + 15: uint16(31600), + 16: uint16(31585), + 17: uint16(31608), + 18: uint16(31606), + 19: uint16(31587), + 20: uint16(31922), + 21: uint16(31924), + 22: uint16(31919), + 23: uint16(32136), + 24: uint16(32134), + 25: uint16(32128), + 26: uint16(32141), + 27: uint16(32127), + 28: uint16(32133), + 29: uint16(32122), + 30: uint16(32142), + 31: uint16(32123), + 32: uint16(32131), + 33: uint16(32124), + 34: uint16(32140), + 35: uint16(32148), + 36: uint16(32132), + 37: uint16(32125), + 38: uint16(32146), + 39: uint16(32621), + 40: uint16(32619), + 41: uint16(32615), + 42: uint16(32616), + 43: uint16(32620), + 44: uint16(32678), + 45: uint16(32677), + 46: uint16(32679), + 47: uint16(32731), + 48: uint16(32732), + 49: uint16(32801), + 50: uint16(33124), + 51: uint16(33120), + 52: uint16(33143), + 53: uint16(33116), + 54: uint16(33129), + 55: uint16(33115), + 56: uint16(33122), + 57: uint16(33138), + 58: uint16(26401), + 59: uint16(33118), + 60: uint16(33142), + 61: uint16(33127), + 62: uint16(33135), + 63: uint16(33092), + 64: uint16(33121), + 65: uint16(33309), + 66: uint16(33353), + 67: uint16(33348), + 68: uint16(33344), + 69: uint16(33346), + 70: uint16(33349), + 71: uint16(34033), + 72: uint16(33855), + 73: uint16(33878), + 74: uint16(33910), + 75: uint16(33913), + 76: uint16(33935), + 77: uint16(33933), + 78: uint16(33893), + 79: uint16(33873), + 80: uint16(33856), + 81: uint16(33926), + 82: uint16(33895), + 83: uint16(33840), + 84: uint16(33869), + 85: uint16(33917), + 86: uint16(33882), + 87: uint16(33881), + 88: uint16(33908), + 89: uint16(33907), + 90: uint16(33885), + 91: uint16(34055), + 92: uint16(33886), + 93: uint16(33847), + 94: uint16(33850), + 95: uint16(33844), + 96: uint16(33914), + 97: uint16(33859), + 98: uint16(33912), + 99: uint16(33842), + 100: uint16(33861), + 101: uint16(33833), + 102: uint16(33753), + 103: uint16(33867), + 104: uint16(33839), + 105: uint16(33858), + 106: uint16(33837), + 107: uint16(33887), + 108: uint16(33904), + 109: uint16(33849), + 110: uint16(33870), + 111: uint16(33868), + 112: uint16(33874), + 113: uint16(33903), + 114: uint16(33989), + 115: uint16(33934), + 116: uint16(33851), + 117: uint16(33863), + 118: uint16(33846), + 119: uint16(33843), + 120: uint16(33896), + 121: uint16(33918), + 122: uint16(33860), + 123: uint16(33835), + 124: uint16(33888), + 125: uint16(33876), + 126: uint16(33902), + 127: uint16(33872), + 128: uint16(34571), + 129: uint16(34564), + 130: uint16(34551), + 131: uint16(34572), + 132: uint16(34554), + 133: uint16(34518), + 134: uint16(34549), + 135: uint16(34637), + 136: uint16(34552), + 137: uint16(34574), + 138: uint16(34569), + 139: uint16(34561), + 140: uint16(34550), + 141: uint16(34573), + 142: uint16(34565), + 143: uint16(35030), + 144: uint16(35019), + 145: uint16(35021), + 146: uint16(35022), + 147: uint16(35038), + 148: uint16(35035), + 149: uint16(35034), + 150: uint16(35020), + 151: uint16(35024), + 152: uint16(35205), + 153: uint16(35227), + 154: uint16(35295), + 155: uint16(35301), + 156: uint16(35300), + }, + 63: { + 0: uint16(35297), + 1: uint16(35296), + 2: uint16(35298), + 3: uint16(35292), + 4: uint16(35302), + 5: uint16(35446), + 6: uint16(35462), + 7: uint16(35455), + 8: uint16(35425), + 9: uint16(35391), + 10: uint16(35447), + 11: uint16(35458), + 12: uint16(35460), + 13: uint16(35445), + 14: uint16(35459), + 15: uint16(35457), + 16: uint16(35444), + 17: uint16(35450), + 18: uint16(35900), + 19: uint16(35915), + 20: uint16(35914), + 21: uint16(35941), + 22: uint16(35940), + 23: uint16(35942), + 24: uint16(35974), + 25: uint16(35972), + 26: uint16(35973), + 27: uint16(36044), + 28: uint16(36200), + 29: uint16(36201), + 30: uint16(36241), + 31: uint16(36236), + 32: uint16(36238), + 33: uint16(36239), + 34: uint16(36237), + 35: uint16(36243), + 36: uint16(36244), + 37: uint16(36240), + 38: uint16(36242), + 39: uint16(36336), + 40: uint16(36320), + 41: uint16(36332), + 42: uint16(36337), + 43: uint16(36334), + 44: uint16(36304), + 45: uint16(36329), + 46: uint16(36323), + 47: uint16(36322), + 48: uint16(36327), + 49: uint16(36338), + 50: uint16(36331), + 51: uint16(36340), + 52: uint16(36614), + 53: uint16(36607), + 54: uint16(36609), + 55: uint16(36608), + 56: uint16(36613), + 57: uint16(36615), + 58: uint16(36616), + 59: uint16(36610), + 60: uint16(36619), + 61: uint16(36946), + 62: uint16(36927), + 63: uint16(36932), + 64: uint16(36937), + 65: uint16(36925), + 66: uint16(37136), + 67: uint16(37133), + 68: uint16(37135), + 69: uint16(37137), + 70: uint16(37142), + 71: uint16(37140), + 72: uint16(37131), + 73: uint16(37134), + 74: uint16(37230), + 75: uint16(37231), + 76: uint16(37448), + 77: uint16(37458), + 78: uint16(37424), + 79: uint16(37434), + 80: uint16(37478), + 81: uint16(37427), + 82: uint16(37477), + 83: uint16(37470), + 84: uint16(37507), + 85: uint16(37422), + 86: uint16(37450), + 87: uint16(37446), + 88: uint16(37485), + 89: uint16(37484), + 90: uint16(37455), + 91: uint16(37472), + 92: uint16(37479), + 93: uint16(37487), + 94: uint16(37430), + 95: uint16(37473), + 96: uint16(37488), + 97: uint16(37425), + 98: uint16(37460), + 99: uint16(37475), + 100: uint16(37456), + 101: uint16(37490), + 102: uint16(37454), + 103: uint16(37459), + 104: uint16(37452), + 105: uint16(37462), + 106: uint16(37426), + 107: uint16(38303), + 108: uint16(38300), + 109: uint16(38302), + 110: uint16(38299), + 111: uint16(38546), + 112: uint16(38547), + 113: uint16(38545), + 114: uint16(38551), + 115: uint16(38606), + 116: uint16(38650), + 117: uint16(38653), + 118: uint16(38648), + 119: uint16(38645), + 120: uint16(38771), + 121: uint16(38775), + 122: uint16(38776), + 123: uint16(38770), + 124: uint16(38927), + 125: uint16(38925), + 126: uint16(38926), + 127: uint16(39084), + 128: uint16(39158), + 129: uint16(39161), + 130: uint16(39343), + 131: uint16(39346), + 132: uint16(39344), + 133: uint16(39349), + 134: uint16(39597), + 135: uint16(39595), + 136: uint16(39771), + 137: uint16(40170), + 138: uint16(40173), + 139: uint16(40167), + 140: uint16(40576), + 141: uint16(40701), + 142: uint16(20710), + 143: uint16(20692), + 144: uint16(20695), + 145: uint16(20712), + 146: uint16(20723), + 147: uint16(20699), + 148: uint16(20714), + 149: uint16(20701), + 150: uint16(20708), + 151: uint16(20691), + 152: uint16(20716), + 153: uint16(20720), + 154: uint16(20719), + 155: uint16(20707), + 156: uint16(20704), + }, + 64: { + 0: uint16(20952), + 1: uint16(21120), + 2: uint16(21121), + 3: uint16(21225), + 4: uint16(21227), + 5: uint16(21296), + 6: uint16(21420), + 7: uint16(22055), + 8: uint16(22037), + 9: uint16(22028), + 10: uint16(22034), + 11: uint16(22012), + 12: uint16(22031), + 13: uint16(22044), + 14: uint16(22017), + 15: uint16(22035), + 16: uint16(22018), + 17: uint16(22010), + 18: uint16(22045), + 19: uint16(22020), + 20: uint16(22015), + 21: uint16(22009), + 22: uint16(22665), + 23: uint16(22652), + 24: uint16(22672), + 25: uint16(22680), + 26: uint16(22662), + 27: uint16(22657), + 28: uint16(22655), + 29: uint16(22644), + 30: uint16(22667), + 31: uint16(22650), + 32: uint16(22663), + 33: uint16(22673), + 34: uint16(22670), + 35: uint16(22646), + 36: uint16(22658), + 37: uint16(22664), + 38: uint16(22651), + 39: uint16(22676), + 40: uint16(22671), + 41: uint16(22782), + 42: uint16(22891), + 43: uint16(23260), + 44: uint16(23278), + 45: uint16(23269), + 46: uint16(23253), + 47: uint16(23274), + 48: uint16(23258), + 49: uint16(23277), + 50: uint16(23275), + 51: uint16(23283), + 52: uint16(23266), + 53: uint16(23264), + 54: uint16(23259), + 55: uint16(23276), + 56: uint16(23262), + 57: uint16(23261), + 58: uint16(23257), + 59: uint16(23272), + 60: uint16(23263), + 61: uint16(23415), + 62: uint16(23520), + 63: uint16(23523), + 64: uint16(23651), + 65: uint16(23938), + 66: uint16(23936), + 67: uint16(23933), + 68: uint16(23942), + 69: uint16(23930), + 70: uint16(23937), + 71: uint16(23927), + 72: uint16(23946), + 73: uint16(23945), + 74: uint16(23944), + 75: uint16(23934), + 76: uint16(23932), + 77: uint16(23949), + 78: uint16(23929), + 79: uint16(23935), + 80: uint16(24152), + 81: uint16(24153), + 82: uint16(24147), + 83: uint16(24280), + 84: uint16(24273), + 85: uint16(24279), + 86: uint16(24270), + 87: uint16(24284), + 88: uint16(24277), + 89: uint16(24281), + 90: uint16(24274), + 91: uint16(24276), + 92: uint16(24388), + 93: uint16(24387), + 94: uint16(24431), + 95: uint16(24502), + 96: uint16(24876), + 97: uint16(24872), + 98: uint16(24897), + 99: uint16(24926), + 100: uint16(24945), + 101: uint16(24947), + 102: uint16(24914), + 103: uint16(24915), + 104: uint16(24946), + 105: uint16(24940), + 106: uint16(24960), + 107: uint16(24948), + 108: uint16(24916), + 109: uint16(24954), + 110: uint16(24923), + 111: uint16(24933), + 112: uint16(24891), + 113: uint16(24938), + 114: uint16(24929), + 115: uint16(24918), + 116: uint16(25129), + 117: uint16(25127), + 118: uint16(25131), + 119: uint16(25643), + 120: uint16(25677), + 121: uint16(25691), + 122: uint16(25693), + 123: uint16(25716), + 124: uint16(25718), + 125: uint16(25714), + 126: uint16(25715), + 127: uint16(25725), + 128: uint16(25717), + 129: uint16(25702), + 130: uint16(25766), + 131: uint16(25678), + 132: uint16(25730), + 133: uint16(25694), + 134: uint16(25692), + 135: uint16(25675), + 136: uint16(25683), + 137: uint16(25696), + 138: uint16(25680), + 139: uint16(25727), + 140: uint16(25663), + 141: uint16(25708), + 142: uint16(25707), + 143: uint16(25689), + 144: uint16(25701), + 145: uint16(25719), + 146: uint16(25971), + 147: uint16(26016), + 148: uint16(26273), + 149: uint16(26272), + 150: uint16(26271), + 151: uint16(26373), + 152: uint16(26372), + 153: uint16(26402), + 154: uint16(27057), + 155: uint16(27062), + 156: uint16(27081), + }, + 65: { + 0: uint16(27040), + 1: uint16(27086), + 2: uint16(27030), + 3: uint16(27056), + 4: uint16(27052), + 5: uint16(27068), + 6: uint16(27025), + 7: uint16(27033), + 8: uint16(27022), + 9: uint16(27047), + 10: uint16(27021), + 11: uint16(27049), + 12: uint16(27070), + 13: uint16(27055), + 14: uint16(27071), + 15: uint16(27076), + 16: uint16(27069), + 17: uint16(27044), + 18: uint16(27092), + 19: uint16(27065), + 20: uint16(27082), + 21: uint16(27034), + 22: uint16(27087), + 23: uint16(27059), + 24: uint16(27027), + 25: uint16(27050), + 26: uint16(27041), + 27: uint16(27038), + 28: uint16(27097), + 29: uint16(27031), + 30: uint16(27024), + 31: uint16(27074), + 32: uint16(27061), + 33: uint16(27045), + 34: uint16(27078), + 35: uint16(27466), + 36: uint16(27469), + 37: uint16(27467), + 38: uint16(27550), + 39: uint16(27551), + 40: uint16(27552), + 41: uint16(27587), + 42: uint16(27588), + 43: uint16(27646), + 44: uint16(28366), + 45: uint16(28405), + 46: uint16(28401), + 47: uint16(28419), + 48: uint16(28453), + 49: uint16(28408), + 50: uint16(28471), + 51: uint16(28411), + 52: uint16(28462), + 53: uint16(28425), + 54: uint16(28494), + 55: uint16(28441), + 56: uint16(28442), + 57: uint16(28455), + 58: uint16(28440), + 59: uint16(28475), + 60: uint16(28434), + 61: uint16(28397), + 62: uint16(28426), + 63: uint16(28470), + 64: uint16(28531), + 65: uint16(28409), + 66: uint16(28398), + 67: uint16(28461), + 68: uint16(28480), + 69: uint16(28464), + 70: uint16(28476), + 71: uint16(28469), + 72: uint16(28395), + 73: uint16(28423), + 74: uint16(28430), + 75: uint16(28483), + 76: uint16(28421), + 77: uint16(28413), + 78: uint16(28406), + 79: uint16(28473), + 80: uint16(28444), + 81: uint16(28412), + 82: uint16(28474), + 83: uint16(28447), + 84: uint16(28429), + 85: uint16(28446), + 86: uint16(28424), + 87: uint16(28449), + 88: uint16(29063), + 89: uint16(29072), + 90: uint16(29065), + 91: uint16(29056), + 92: uint16(29061), + 93: uint16(29058), + 94: uint16(29071), + 95: uint16(29051), + 96: uint16(29062), + 97: uint16(29057), + 98: uint16(29079), + 99: uint16(29252), + 100: uint16(29267), + 101: uint16(29335), + 102: uint16(29333), + 103: uint16(29331), + 104: uint16(29507), + 105: uint16(29517), + 106: uint16(29521), + 107: uint16(29516), + 108: uint16(29794), + 109: uint16(29811), + 110: uint16(29809), + 111: uint16(29813), + 112: uint16(29810), + 113: uint16(29799), + 114: uint16(29806), + 115: uint16(29952), + 116: uint16(29954), + 117: uint16(29955), + 118: uint16(30077), + 119: uint16(30096), + 120: uint16(30230), + 121: uint16(30216), + 122: uint16(30220), + 123: uint16(30229), + 124: uint16(30225), + 125: uint16(30218), + 126: uint16(30228), + 127: uint16(30392), + 128: uint16(30593), + 129: uint16(30588), + 130: uint16(30597), + 131: uint16(30594), + 132: uint16(30574), + 133: uint16(30592), + 134: uint16(30575), + 135: uint16(30590), + 136: uint16(30595), + 137: uint16(30898), + 138: uint16(30890), + 139: uint16(30900), + 140: uint16(30893), + 141: uint16(30888), + 142: uint16(30846), + 143: uint16(30891), + 144: uint16(30878), + 145: uint16(30885), + 146: uint16(30880), + 147: uint16(30892), + 148: uint16(30882), + 149: uint16(30884), + 150: uint16(31128), + 151: uint16(31114), + 152: uint16(31115), + 153: uint16(31126), + 154: uint16(31125), + 155: uint16(31124), + 156: uint16(31123), + }, + 66: { + 0: uint16(31127), + 1: uint16(31112), + 2: uint16(31122), + 3: uint16(31120), + 4: uint16(31275), + 5: uint16(31306), + 6: uint16(31280), + 7: uint16(31279), + 8: uint16(31272), + 9: uint16(31270), + 10: uint16(31400), + 11: uint16(31403), + 12: uint16(31404), + 13: uint16(31470), + 14: uint16(31624), + 15: uint16(31644), + 16: uint16(31626), + 17: uint16(31633), + 18: uint16(31632), + 19: uint16(31638), + 20: uint16(31629), + 21: uint16(31628), + 22: uint16(31643), + 23: uint16(31630), + 24: uint16(31621), + 25: uint16(31640), + 26: uint16(21124), + 27: uint16(31641), + 28: uint16(31652), + 29: uint16(31618), + 30: uint16(31931), + 31: uint16(31935), + 32: uint16(31932), + 33: uint16(31930), + 34: uint16(32167), + 35: uint16(32183), + 36: uint16(32194), + 37: uint16(32163), + 38: uint16(32170), + 39: uint16(32193), + 40: uint16(32192), + 41: uint16(32197), + 42: uint16(32157), + 43: uint16(32206), + 44: uint16(32196), + 45: uint16(32198), + 46: uint16(32203), + 47: uint16(32204), + 48: uint16(32175), + 49: uint16(32185), + 50: uint16(32150), + 51: uint16(32188), + 52: uint16(32159), + 53: uint16(32166), + 54: uint16(32174), + 55: uint16(32169), + 56: uint16(32161), + 57: uint16(32201), + 58: uint16(32627), + 59: uint16(32738), + 60: uint16(32739), + 61: uint16(32741), + 62: uint16(32734), + 63: uint16(32804), + 64: uint16(32861), + 65: uint16(32860), + 66: uint16(33161), + 67: uint16(33158), + 68: uint16(33155), + 69: uint16(33159), + 70: uint16(33165), + 71: uint16(33164), + 72: uint16(33163), + 73: uint16(33301), + 74: uint16(33943), + 75: uint16(33956), + 76: uint16(33953), + 77: uint16(33951), + 78: uint16(33978), + 79: uint16(33998), + 80: uint16(33986), + 81: uint16(33964), + 82: uint16(33966), + 83: uint16(33963), + 84: uint16(33977), + 85: uint16(33972), + 86: uint16(33985), + 87: uint16(33997), + 88: uint16(33962), + 89: uint16(33946), + 90: uint16(33969), + 91: uint16(34000), + 92: uint16(33949), + 93: uint16(33959), + 94: uint16(33979), + 95: uint16(33954), + 96: uint16(33940), + 97: uint16(33991), + 98: uint16(33996), + 99: uint16(33947), + 100: uint16(33961), + 101: uint16(33967), + 102: uint16(33960), + 103: uint16(34006), + 104: uint16(33944), + 105: uint16(33974), + 106: uint16(33999), + 107: uint16(33952), + 108: uint16(34007), + 109: uint16(34004), + 110: uint16(34002), + 111: uint16(34011), + 112: uint16(33968), + 113: uint16(33937), + 114: uint16(34401), + 115: uint16(34611), + 116: uint16(34595), + 117: uint16(34600), + 118: uint16(34667), + 119: uint16(34624), + 120: uint16(34606), + 121: uint16(34590), + 122: uint16(34593), + 123: uint16(34585), + 124: uint16(34587), + 125: uint16(34627), + 126: uint16(34604), + 127: uint16(34625), + 128: uint16(34622), + 129: uint16(34630), + 130: uint16(34592), + 131: uint16(34610), + 132: uint16(34602), + 133: uint16(34605), + 134: uint16(34620), + 135: uint16(34578), + 136: uint16(34618), + 137: uint16(34609), + 138: uint16(34613), + 139: uint16(34626), + 140: uint16(34598), + 141: uint16(34599), + 142: uint16(34616), + 143: uint16(34596), + 144: uint16(34586), + 145: uint16(34608), + 146: uint16(34577), + 147: uint16(35063), + 148: uint16(35047), + 149: uint16(35057), + 150: uint16(35058), + 151: uint16(35066), + 152: uint16(35070), + 153: uint16(35054), + 154: uint16(35068), + 155: uint16(35062), + 156: uint16(35067), + }, + 67: { + 0: uint16(35056), + 1: uint16(35052), + 2: uint16(35051), + 3: uint16(35229), + 4: uint16(35233), + 5: uint16(35231), + 6: uint16(35230), + 7: uint16(35305), + 8: uint16(35307), + 9: uint16(35304), + 10: uint16(35499), + 11: uint16(35481), + 12: uint16(35467), + 13: uint16(35474), + 14: uint16(35471), + 15: uint16(35478), + 16: uint16(35901), + 17: uint16(35944), + 18: uint16(35945), + 19: uint16(36053), + 20: uint16(36047), + 21: uint16(36055), + 22: uint16(36246), + 23: uint16(36361), + 24: uint16(36354), + 25: uint16(36351), + 26: uint16(36365), + 27: uint16(36349), + 28: uint16(36362), + 29: uint16(36355), + 30: uint16(36359), + 31: uint16(36358), + 32: uint16(36357), + 33: uint16(36350), + 34: uint16(36352), + 35: uint16(36356), + 36: uint16(36624), + 37: uint16(36625), + 38: uint16(36622), + 39: uint16(36621), + 40: uint16(37155), + 41: uint16(37148), + 42: uint16(37152), + 43: uint16(37154), + 44: uint16(37151), + 45: uint16(37149), + 46: uint16(37146), + 47: uint16(37156), + 48: uint16(37153), + 49: uint16(37147), + 50: uint16(37242), + 51: uint16(37234), + 52: uint16(37241), + 53: uint16(37235), + 54: uint16(37541), + 55: uint16(37540), + 56: uint16(37494), + 57: uint16(37531), + 58: uint16(37498), + 59: uint16(37536), + 60: uint16(37524), + 61: uint16(37546), + 62: uint16(37517), + 63: uint16(37542), + 64: uint16(37530), + 65: uint16(37547), + 66: uint16(37497), + 67: uint16(37527), + 68: uint16(37503), + 69: uint16(37539), + 70: uint16(37614), + 71: uint16(37518), + 72: uint16(37506), + 73: uint16(37525), + 74: uint16(37538), + 75: uint16(37501), + 76: uint16(37512), + 77: uint16(37537), + 78: uint16(37514), + 79: uint16(37510), + 80: uint16(37516), + 81: uint16(37529), + 82: uint16(37543), + 83: uint16(37502), + 84: uint16(37511), + 85: uint16(37545), + 86: uint16(37533), + 87: uint16(37515), + 88: uint16(37421), + 89: uint16(38558), + 90: uint16(38561), + 91: uint16(38655), + 92: uint16(38744), + 93: uint16(38781), + 94: uint16(38778), + 95: uint16(38782), + 96: uint16(38787), + 97: uint16(38784), + 98: uint16(38786), + 99: uint16(38779), + 100: uint16(38788), + 101: uint16(38785), + 102: uint16(38783), + 103: uint16(38862), + 104: uint16(38861), + 105: uint16(38934), + 106: uint16(39085), + 107: uint16(39086), + 108: uint16(39170), + 109: uint16(39168), + 110: uint16(39175), + 111: uint16(39325), + 112: uint16(39324), + 113: uint16(39363), + 114: uint16(39353), + 115: uint16(39355), + 116: uint16(39354), + 117: uint16(39362), + 118: uint16(39357), + 119: uint16(39367), + 120: uint16(39601), + 121: uint16(39651), + 122: uint16(39655), + 123: uint16(39742), + 124: uint16(39743), + 125: uint16(39776), + 126: uint16(39777), + 127: uint16(39775), + 128: uint16(40177), + 129: uint16(40178), + 130: uint16(40181), + 131: uint16(40615), + 132: uint16(20735), + 133: uint16(20739), + 134: uint16(20784), + 135: uint16(20728), + 136: uint16(20742), + 137: uint16(20743), + 138: uint16(20726), + 139: uint16(20734), + 140: uint16(20747), + 141: uint16(20748), + 142: uint16(20733), + 143: uint16(20746), + 144: uint16(21131), + 145: uint16(21132), + 146: uint16(21233), + 147: uint16(21231), + 148: uint16(22088), + 149: uint16(22082), + 150: uint16(22092), + 151: uint16(22069), + 152: uint16(22081), + 153: uint16(22090), + 154: uint16(22089), + 155: uint16(22086), + 156: uint16(22104), + }, + 68: { + 0: uint16(22106), + 1: uint16(22080), + 2: uint16(22067), + 3: uint16(22077), + 4: uint16(22060), + 5: uint16(22078), + 6: uint16(22072), + 7: uint16(22058), + 8: uint16(22074), + 9: uint16(22298), + 10: uint16(22699), + 11: uint16(22685), + 12: uint16(22705), + 13: uint16(22688), + 14: uint16(22691), + 15: uint16(22703), + 16: uint16(22700), + 17: uint16(22693), + 18: uint16(22689), + 19: uint16(22783), + 20: uint16(23295), + 21: uint16(23284), + 22: uint16(23293), + 23: uint16(23287), + 24: uint16(23286), + 25: uint16(23299), + 26: uint16(23288), + 27: uint16(23298), + 28: uint16(23289), + 29: uint16(23297), + 30: uint16(23303), + 31: uint16(23301), + 32: uint16(23311), + 33: uint16(23655), + 34: uint16(23961), + 35: uint16(23959), + 36: uint16(23967), + 37: uint16(23954), + 38: uint16(23970), + 39: uint16(23955), + 40: uint16(23957), + 41: uint16(23968), + 42: uint16(23964), + 43: uint16(23969), + 44: uint16(23962), + 45: uint16(23966), + 46: uint16(24169), + 47: uint16(24157), + 48: uint16(24160), + 49: uint16(24156), + 50: uint16(32243), + 51: uint16(24283), + 52: uint16(24286), + 53: uint16(24289), + 54: uint16(24393), + 55: uint16(24498), + 56: uint16(24971), + 57: uint16(24963), + 58: uint16(24953), + 59: uint16(25009), + 60: uint16(25008), + 61: uint16(24994), + 62: uint16(24969), + 63: uint16(24987), + 64: uint16(24979), + 65: uint16(25007), + 66: uint16(25005), + 67: uint16(24991), + 68: uint16(24978), + 69: uint16(25002), + 70: uint16(24993), + 71: uint16(24973), + 72: uint16(24934), + 73: uint16(25011), + 74: uint16(25133), + 75: uint16(25710), + 76: uint16(25712), + 77: uint16(25750), + 78: uint16(25760), + 79: uint16(25733), + 80: uint16(25751), + 81: uint16(25756), + 82: uint16(25743), + 83: uint16(25739), + 84: uint16(25738), + 85: uint16(25740), + 86: uint16(25763), + 87: uint16(25759), + 88: uint16(25704), + 89: uint16(25777), + 90: uint16(25752), + 91: uint16(25974), + 92: uint16(25978), + 93: uint16(25977), + 94: uint16(25979), + 95: uint16(26034), + 96: uint16(26035), + 97: uint16(26293), + 98: uint16(26288), + 99: uint16(26281), + 100: uint16(26290), + 101: uint16(26295), + 102: uint16(26282), + 103: uint16(26287), + 104: uint16(27136), + 105: uint16(27142), + 106: uint16(27159), + 107: uint16(27109), + 108: uint16(27128), + 109: uint16(27157), + 110: uint16(27121), + 111: uint16(27108), + 112: uint16(27168), + 113: uint16(27135), + 114: uint16(27116), + 115: uint16(27106), + 116: uint16(27163), + 117: uint16(27165), + 118: uint16(27134), + 119: uint16(27175), + 120: uint16(27122), + 121: uint16(27118), + 122: uint16(27156), + 123: uint16(27127), + 124: uint16(27111), + 125: uint16(27200), + 126: uint16(27144), + 127: uint16(27110), + 128: uint16(27131), + 129: uint16(27149), + 130: uint16(27132), + 131: uint16(27115), + 132: uint16(27145), + 133: uint16(27140), + 134: uint16(27160), + 135: uint16(27173), + 136: uint16(27151), + 137: uint16(27126), + 138: uint16(27174), + 139: uint16(27143), + 140: uint16(27124), + 141: uint16(27158), + 142: uint16(27473), + 143: uint16(27557), + 144: uint16(27555), + 145: uint16(27554), + 146: uint16(27558), + 147: uint16(27649), + 148: uint16(27648), + 149: uint16(27647), + 150: uint16(27650), + 151: uint16(28481), + 152: uint16(28454), + 153: uint16(28542), + 154: uint16(28551), + 155: uint16(28614), + 156: uint16(28562), + }, + 69: { + 0: uint16(28557), + 1: uint16(28553), + 2: uint16(28556), + 3: uint16(28514), + 4: uint16(28495), + 5: uint16(28549), + 6: uint16(28506), + 7: uint16(28566), + 8: uint16(28534), + 9: uint16(28524), + 10: uint16(28546), + 11: uint16(28501), + 12: uint16(28530), + 13: uint16(28498), + 14: uint16(28496), + 15: uint16(28503), + 16: uint16(28564), + 17: uint16(28563), + 18: uint16(28509), + 19: uint16(28416), + 20: uint16(28513), + 21: uint16(28523), + 22: uint16(28541), + 23: uint16(28519), + 24: uint16(28560), + 25: uint16(28499), + 26: uint16(28555), + 27: uint16(28521), + 28: uint16(28543), + 29: uint16(28565), + 30: uint16(28515), + 31: uint16(28535), + 32: uint16(28522), + 33: uint16(28539), + 34: uint16(29106), + 35: uint16(29103), + 36: uint16(29083), + 37: uint16(29104), + 38: uint16(29088), + 39: uint16(29082), + 40: uint16(29097), + 41: uint16(29109), + 42: uint16(29085), + 43: uint16(29093), + 44: uint16(29086), + 45: uint16(29092), + 46: uint16(29089), + 47: uint16(29098), + 48: uint16(29084), + 49: uint16(29095), + 50: uint16(29107), + 51: uint16(29336), + 52: uint16(29338), + 53: uint16(29528), + 54: uint16(29522), + 55: uint16(29534), + 56: uint16(29535), + 57: uint16(29536), + 58: uint16(29533), + 59: uint16(29531), + 60: uint16(29537), + 61: uint16(29530), + 62: uint16(29529), + 63: uint16(29538), + 64: uint16(29831), + 65: uint16(29833), + 66: uint16(29834), + 67: uint16(29830), + 68: uint16(29825), + 69: uint16(29821), + 70: uint16(29829), + 71: uint16(29832), + 72: uint16(29820), + 73: uint16(29817), + 74: uint16(29960), + 75: uint16(29959), + 76: uint16(30078), + 77: uint16(30245), + 78: uint16(30238), + 79: uint16(30233), + 80: uint16(30237), + 81: uint16(30236), + 82: uint16(30243), + 83: uint16(30234), + 84: uint16(30248), + 85: uint16(30235), + 86: uint16(30364), + 87: uint16(30365), + 88: uint16(30366), + 89: uint16(30363), + 90: uint16(30605), + 91: uint16(30607), + 92: uint16(30601), + 93: uint16(30600), + 94: uint16(30925), + 95: uint16(30907), + 96: uint16(30927), + 97: uint16(30924), + 98: uint16(30929), + 99: uint16(30926), + 100: uint16(30932), + 101: uint16(30920), + 102: uint16(30915), + 103: uint16(30916), + 104: uint16(30921), + 105: uint16(31130), + 106: uint16(31137), + 107: uint16(31136), + 108: uint16(31132), + 109: uint16(31138), + 110: uint16(31131), + 111: uint16(27510), + 112: uint16(31289), + 113: uint16(31410), + 114: uint16(31412), + 115: uint16(31411), + 116: uint16(31671), + 117: uint16(31691), + 118: uint16(31678), + 119: uint16(31660), + 120: uint16(31694), + 121: uint16(31663), + 122: uint16(31673), + 123: uint16(31690), + 124: uint16(31669), + 125: uint16(31941), + 126: uint16(31944), + 127: uint16(31948), + 128: uint16(31947), + 129: uint16(32247), + 130: uint16(32219), + 131: uint16(32234), + 132: uint16(32231), + 133: uint16(32215), + 134: uint16(32225), + 135: uint16(32259), + 136: uint16(32250), + 137: uint16(32230), + 138: uint16(32246), + 139: uint16(32241), + 140: uint16(32240), + 141: uint16(32238), + 142: uint16(32223), + 143: uint16(32630), + 144: uint16(32684), + 145: uint16(32688), + 146: uint16(32685), + 147: uint16(32749), + 148: uint16(32747), + 149: uint16(32746), + 150: uint16(32748), + 151: uint16(32742), + 152: uint16(32744), + 153: uint16(32868), + 154: uint16(32871), + 155: uint16(33187), + 156: uint16(33183), + }, + 70: { + 0: uint16(33182), + 1: uint16(33173), + 2: uint16(33186), + 3: uint16(33177), + 4: uint16(33175), + 5: uint16(33302), + 6: uint16(33359), + 7: uint16(33363), + 8: uint16(33362), + 9: uint16(33360), + 10: uint16(33358), + 11: uint16(33361), + 12: uint16(34084), + 13: uint16(34107), + 14: uint16(34063), + 15: uint16(34048), + 16: uint16(34089), + 17: uint16(34062), + 18: uint16(34057), + 19: uint16(34061), + 20: uint16(34079), + 21: uint16(34058), + 22: uint16(34087), + 23: uint16(34076), + 24: uint16(34043), + 25: uint16(34091), + 26: uint16(34042), + 27: uint16(34056), + 28: uint16(34060), + 29: uint16(34036), + 30: uint16(34090), + 31: uint16(34034), + 32: uint16(34069), + 33: uint16(34039), + 34: uint16(34027), + 35: uint16(34035), + 36: uint16(34044), + 37: uint16(34066), + 38: uint16(34026), + 39: uint16(34025), + 40: uint16(34070), + 41: uint16(34046), + 42: uint16(34088), + 43: uint16(34077), + 44: uint16(34094), + 45: uint16(34050), + 46: uint16(34045), + 47: uint16(34078), + 48: uint16(34038), + 49: uint16(34097), + 50: uint16(34086), + 51: uint16(34023), + 52: uint16(34024), + 53: uint16(34032), + 54: uint16(34031), + 55: uint16(34041), + 56: uint16(34072), + 57: uint16(34080), + 58: uint16(34096), + 59: uint16(34059), + 60: uint16(34073), + 61: uint16(34095), + 62: uint16(34402), + 63: uint16(34646), + 64: uint16(34659), + 65: uint16(34660), + 66: uint16(34679), + 67: uint16(34785), + 68: uint16(34675), + 69: uint16(34648), + 70: uint16(34644), + 71: uint16(34651), + 72: uint16(34642), + 73: uint16(34657), + 74: uint16(34650), + 75: uint16(34641), + 76: uint16(34654), + 77: uint16(34669), + 78: uint16(34666), + 79: uint16(34640), + 80: uint16(34638), + 81: uint16(34655), + 82: uint16(34653), + 83: uint16(34671), + 84: uint16(34668), + 85: uint16(34682), + 86: uint16(34670), + 87: uint16(34652), + 88: uint16(34661), + 89: uint16(34639), + 90: uint16(34683), + 91: uint16(34677), + 92: uint16(34658), + 93: uint16(34663), + 94: uint16(34665), + 95: uint16(34906), + 96: uint16(35077), + 97: uint16(35084), + 98: uint16(35092), + 99: uint16(35083), + 100: uint16(35095), + 101: uint16(35096), + 102: uint16(35097), + 103: uint16(35078), + 104: uint16(35094), + 105: uint16(35089), + 106: uint16(35086), + 107: uint16(35081), + 108: uint16(35234), + 109: uint16(35236), + 110: uint16(35235), + 111: uint16(35309), + 112: uint16(35312), + 113: uint16(35308), + 114: uint16(35535), + 115: uint16(35526), + 116: uint16(35512), + 117: uint16(35539), + 118: uint16(35537), + 119: uint16(35540), + 120: uint16(35541), + 121: uint16(35515), + 122: uint16(35543), + 123: uint16(35518), + 124: uint16(35520), + 125: uint16(35525), + 126: uint16(35544), + 127: uint16(35523), + 128: uint16(35514), + 129: uint16(35517), + 130: uint16(35545), + 131: uint16(35902), + 132: uint16(35917), + 133: uint16(35983), + 134: uint16(36069), + 135: uint16(36063), + 136: uint16(36057), + 137: uint16(36072), + 138: uint16(36058), + 139: uint16(36061), + 140: uint16(36071), + 141: uint16(36256), + 142: uint16(36252), + 143: uint16(36257), + 144: uint16(36251), + 145: uint16(36384), + 146: uint16(36387), + 147: uint16(36389), + 148: uint16(36388), + 149: uint16(36398), + 150: uint16(36373), + 151: uint16(36379), + 152: uint16(36374), + 153: uint16(36369), + 154: uint16(36377), + 155: uint16(36390), + 156: uint16(36391), + }, + 71: { + 0: uint16(36372), + 1: uint16(36370), + 2: uint16(36376), + 3: uint16(36371), + 4: uint16(36380), + 5: uint16(36375), + 6: uint16(36378), + 7: uint16(36652), + 8: uint16(36644), + 9: uint16(36632), + 10: uint16(36634), + 11: uint16(36640), + 12: uint16(36643), + 13: uint16(36630), + 14: uint16(36631), + 15: uint16(36979), + 16: uint16(36976), + 17: uint16(36975), + 18: uint16(36967), + 19: uint16(36971), + 20: uint16(37167), + 21: uint16(37163), + 22: uint16(37161), + 23: uint16(37162), + 24: uint16(37170), + 25: uint16(37158), + 26: uint16(37166), + 27: uint16(37253), + 28: uint16(37254), + 29: uint16(37258), + 30: uint16(37249), + 31: uint16(37250), + 32: uint16(37252), + 33: uint16(37248), + 34: uint16(37584), + 35: uint16(37571), + 36: uint16(37572), + 37: uint16(37568), + 38: uint16(37593), + 39: uint16(37558), + 40: uint16(37583), + 41: uint16(37617), + 42: uint16(37599), + 43: uint16(37592), + 44: uint16(37609), + 45: uint16(37591), + 46: uint16(37597), + 47: uint16(37580), + 48: uint16(37615), + 49: uint16(37570), + 50: uint16(37608), + 51: uint16(37578), + 52: uint16(37576), + 53: uint16(37582), + 54: uint16(37606), + 55: uint16(37581), + 56: uint16(37589), + 57: uint16(37577), + 58: uint16(37600), + 59: uint16(37598), + 60: uint16(37607), + 61: uint16(37585), + 62: uint16(37587), + 63: uint16(37557), + 64: uint16(37601), + 65: uint16(37574), + 66: uint16(37556), + 67: uint16(38268), + 68: uint16(38316), + 69: uint16(38315), + 70: uint16(38318), + 71: uint16(38320), + 72: uint16(38564), + 73: uint16(38562), + 74: uint16(38611), + 75: uint16(38661), + 76: uint16(38664), + 77: uint16(38658), + 78: uint16(38746), + 79: uint16(38794), + 80: uint16(38798), + 81: uint16(38792), + 82: uint16(38864), + 83: uint16(38863), + 84: uint16(38942), + 85: uint16(38941), + 86: uint16(38950), + 87: uint16(38953), + 88: uint16(38952), + 89: uint16(38944), + 90: uint16(38939), + 91: uint16(38951), + 92: uint16(39090), + 93: uint16(39176), + 94: uint16(39162), + 95: uint16(39185), + 96: uint16(39188), + 97: uint16(39190), + 98: uint16(39191), + 99: uint16(39189), + 100: uint16(39388), + 101: uint16(39373), + 102: uint16(39375), + 103: uint16(39379), + 104: uint16(39380), + 105: uint16(39374), + 106: uint16(39369), + 107: uint16(39382), + 108: uint16(39384), + 109: uint16(39371), + 110: uint16(39383), + 111: uint16(39372), + 112: uint16(39603), + 113: uint16(39660), + 114: uint16(39659), + 115: uint16(39667), + 116: uint16(39666), + 117: uint16(39665), + 118: uint16(39750), + 119: uint16(39747), + 120: uint16(39783), + 121: uint16(39796), + 122: uint16(39793), + 123: uint16(39782), + 124: uint16(39798), + 125: uint16(39797), + 126: uint16(39792), + 127: uint16(39784), + 128: uint16(39780), + 129: uint16(39788), + 130: uint16(40188), + 131: uint16(40186), + 132: uint16(40189), + 133: uint16(40191), + 134: uint16(40183), + 135: uint16(40199), + 136: uint16(40192), + 137: uint16(40185), + 138: uint16(40187), + 139: uint16(40200), + 140: uint16(40197), + 141: uint16(40196), + 142: uint16(40579), + 143: uint16(40659), + 144: uint16(40719), + 145: uint16(40720), + 146: uint16(20764), + 147: uint16(20755), + 148: uint16(20759), + 149: uint16(20762), + 150: uint16(20753), + 151: uint16(20958), + 152: uint16(21300), + 153: uint16(21473), + 154: uint16(22128), + 155: uint16(22112), + 156: uint16(22126), + }, + 72: { + 0: uint16(22131), + 1: uint16(22118), + 2: uint16(22115), + 3: uint16(22125), + 4: uint16(22130), + 5: uint16(22110), + 6: uint16(22135), + 7: uint16(22300), + 8: uint16(22299), + 9: uint16(22728), + 10: uint16(22717), + 11: uint16(22729), + 12: uint16(22719), + 13: uint16(22714), + 14: uint16(22722), + 15: uint16(22716), + 16: uint16(22726), + 17: uint16(23319), + 18: uint16(23321), + 19: uint16(23323), + 20: uint16(23329), + 21: uint16(23316), + 22: uint16(23315), + 23: uint16(23312), + 24: uint16(23318), + 25: uint16(23336), + 26: uint16(23322), + 27: uint16(23328), + 28: uint16(23326), + 29: uint16(23535), + 30: uint16(23980), + 31: uint16(23985), + 32: uint16(23977), + 33: uint16(23975), + 34: uint16(23989), + 35: uint16(23984), + 36: uint16(23982), + 37: uint16(23978), + 38: uint16(23976), + 39: uint16(23986), + 40: uint16(23981), + 41: uint16(23983), + 42: uint16(23988), + 43: uint16(24167), + 44: uint16(24168), + 45: uint16(24166), + 46: uint16(24175), + 47: uint16(24297), + 48: uint16(24295), + 49: uint16(24294), + 50: uint16(24296), + 51: uint16(24293), + 52: uint16(24395), + 53: uint16(24508), + 54: uint16(24989), + 55: uint16(25000), + 56: uint16(24982), + 57: uint16(25029), + 58: uint16(25012), + 59: uint16(25030), + 60: uint16(25025), + 61: uint16(25036), + 62: uint16(25018), + 63: uint16(25023), + 64: uint16(25016), + 65: uint16(24972), + 66: uint16(25815), + 67: uint16(25814), + 68: uint16(25808), + 69: uint16(25807), + 70: uint16(25801), + 71: uint16(25789), + 72: uint16(25737), + 73: uint16(25795), + 74: uint16(25819), + 75: uint16(25843), + 76: uint16(25817), + 77: uint16(25907), + 78: uint16(25983), + 79: uint16(25980), + 80: uint16(26018), + 81: uint16(26312), + 82: uint16(26302), + 83: uint16(26304), + 84: uint16(26314), + 85: uint16(26315), + 86: uint16(26319), + 87: uint16(26301), + 88: uint16(26299), + 89: uint16(26298), + 90: uint16(26316), + 91: uint16(26403), + 92: uint16(27188), + 93: uint16(27238), + 94: uint16(27209), + 95: uint16(27239), + 96: uint16(27186), + 97: uint16(27240), + 98: uint16(27198), + 99: uint16(27229), + 100: uint16(27245), + 101: uint16(27254), + 102: uint16(27227), + 103: uint16(27217), + 104: uint16(27176), + 105: uint16(27226), + 106: uint16(27195), + 107: uint16(27199), + 108: uint16(27201), + 109: uint16(27242), + 110: uint16(27236), + 111: uint16(27216), + 112: uint16(27215), + 113: uint16(27220), + 114: uint16(27247), + 115: uint16(27241), + 116: uint16(27232), + 117: uint16(27196), + 118: uint16(27230), + 119: uint16(27222), + 120: uint16(27221), + 121: uint16(27213), + 122: uint16(27214), + 123: uint16(27206), + 124: uint16(27477), + 125: uint16(27476), + 126: uint16(27478), + 127: uint16(27559), + 128: uint16(27562), + 129: uint16(27563), + 130: uint16(27592), + 131: uint16(27591), + 132: uint16(27652), + 133: uint16(27651), + 134: uint16(27654), + 135: uint16(28589), + 136: uint16(28619), + 137: uint16(28579), + 138: uint16(28615), + 139: uint16(28604), + 140: uint16(28622), + 141: uint16(28616), + 142: uint16(28510), + 143: uint16(28612), + 144: uint16(28605), + 145: uint16(28574), + 146: uint16(28618), + 147: uint16(28584), + 148: uint16(28676), + 149: uint16(28581), + 150: uint16(28590), + 151: uint16(28602), + 152: uint16(28588), + 153: uint16(28586), + 154: uint16(28623), + 155: uint16(28607), + 156: uint16(28600), + }, + 73: { + 0: uint16(28578), + 1: uint16(28617), + 2: uint16(28587), + 3: uint16(28621), + 4: uint16(28591), + 5: uint16(28594), + 6: uint16(28592), + 7: uint16(29125), + 8: uint16(29122), + 9: uint16(29119), + 10: uint16(29112), + 11: uint16(29142), + 12: uint16(29120), + 13: uint16(29121), + 14: uint16(29131), + 15: uint16(29140), + 16: uint16(29130), + 17: uint16(29127), + 18: uint16(29135), + 19: uint16(29117), + 20: uint16(29144), + 21: uint16(29116), + 22: uint16(29126), + 23: uint16(29146), + 24: uint16(29147), + 25: uint16(29341), + 26: uint16(29342), + 27: uint16(29545), + 28: uint16(29542), + 29: uint16(29543), + 30: uint16(29548), + 31: uint16(29541), + 32: uint16(29547), + 33: uint16(29546), + 34: uint16(29823), + 35: uint16(29850), + 36: uint16(29856), + 37: uint16(29844), + 38: uint16(29842), + 39: uint16(29845), + 40: uint16(29857), + 41: uint16(29963), + 42: uint16(30080), + 43: uint16(30255), + 44: uint16(30253), + 45: uint16(30257), + 46: uint16(30269), + 47: uint16(30259), + 48: uint16(30268), + 49: uint16(30261), + 50: uint16(30258), + 51: uint16(30256), + 52: uint16(30395), + 53: uint16(30438), + 54: uint16(30618), + 55: uint16(30621), + 56: uint16(30625), + 57: uint16(30620), + 58: uint16(30619), + 59: uint16(30626), + 60: uint16(30627), + 61: uint16(30613), + 62: uint16(30617), + 63: uint16(30615), + 64: uint16(30941), + 65: uint16(30953), + 66: uint16(30949), + 67: uint16(30954), + 68: uint16(30942), + 69: uint16(30947), + 70: uint16(30939), + 71: uint16(30945), + 72: uint16(30946), + 73: uint16(30957), + 74: uint16(30943), + 75: uint16(30944), + 76: uint16(31140), + 77: uint16(31300), + 78: uint16(31304), + 79: uint16(31303), + 80: uint16(31414), + 81: uint16(31416), + 82: uint16(31413), + 83: uint16(31409), + 84: uint16(31415), + 85: uint16(31710), + 86: uint16(31715), + 87: uint16(31719), + 88: uint16(31709), + 89: uint16(31701), + 90: uint16(31717), + 91: uint16(31706), + 92: uint16(31720), + 93: uint16(31737), + 94: uint16(31700), + 95: uint16(31722), + 96: uint16(31714), + 97: uint16(31708), + 98: uint16(31723), + 99: uint16(31704), + 100: uint16(31711), + 101: uint16(31954), + 102: uint16(31956), + 103: uint16(31959), + 104: uint16(31952), + 105: uint16(31953), + 106: uint16(32274), + 107: uint16(32289), + 108: uint16(32279), + 109: uint16(32268), + 110: uint16(32287), + 111: uint16(32288), + 112: uint16(32275), + 113: uint16(32270), + 114: uint16(32284), + 115: uint16(32277), + 116: uint16(32282), + 117: uint16(32290), + 118: uint16(32267), + 119: uint16(32271), + 120: uint16(32278), + 121: uint16(32269), + 122: uint16(32276), + 123: uint16(32293), + 124: uint16(32292), + 125: uint16(32579), + 126: uint16(32635), + 127: uint16(32636), + 128: uint16(32634), + 129: uint16(32689), + 130: uint16(32751), + 131: uint16(32810), + 132: uint16(32809), + 133: uint16(32876), + 134: uint16(33201), + 135: uint16(33190), + 136: uint16(33198), + 137: uint16(33209), + 138: uint16(33205), + 139: uint16(33195), + 140: uint16(33200), + 141: uint16(33196), + 142: uint16(33204), + 143: uint16(33202), + 144: uint16(33207), + 145: uint16(33191), + 146: uint16(33266), + 147: uint16(33365), + 148: uint16(33366), + 149: uint16(33367), + 150: uint16(34134), + 151: uint16(34117), + 152: uint16(34155), + 153: uint16(34125), + 154: uint16(34131), + 155: uint16(34145), + 156: uint16(34136), + }, + 74: { + 0: uint16(34112), + 1: uint16(34118), + 2: uint16(34148), + 3: uint16(34113), + 4: uint16(34146), + 5: uint16(34116), + 6: uint16(34129), + 7: uint16(34119), + 8: uint16(34147), + 9: uint16(34110), + 10: uint16(34139), + 11: uint16(34161), + 12: uint16(34126), + 13: uint16(34158), + 14: uint16(34165), + 15: uint16(34133), + 16: uint16(34151), + 17: uint16(34144), + 18: uint16(34188), + 19: uint16(34150), + 20: uint16(34141), + 21: uint16(34132), + 22: uint16(34149), + 23: uint16(34156), + 24: uint16(34403), + 25: uint16(34405), + 26: uint16(34404), + 27: uint16(34715), + 28: uint16(34703), + 29: uint16(34711), + 30: uint16(34707), + 31: uint16(34706), + 32: uint16(34696), + 33: uint16(34689), + 34: uint16(34710), + 35: uint16(34712), + 36: uint16(34681), + 37: uint16(34695), + 38: uint16(34723), + 39: uint16(34693), + 40: uint16(34704), + 41: uint16(34705), + 42: uint16(34717), + 43: uint16(34692), + 44: uint16(34708), + 45: uint16(34716), + 46: uint16(34714), + 47: uint16(34697), + 48: uint16(35102), + 49: uint16(35110), + 50: uint16(35120), + 51: uint16(35117), + 52: uint16(35118), + 53: uint16(35111), + 54: uint16(35121), + 55: uint16(35106), + 56: uint16(35113), + 57: uint16(35107), + 58: uint16(35119), + 59: uint16(35116), + 60: uint16(35103), + 61: uint16(35313), + 62: uint16(35552), + 63: uint16(35554), + 64: uint16(35570), + 65: uint16(35572), + 66: uint16(35573), + 67: uint16(35549), + 68: uint16(35604), + 69: uint16(35556), + 70: uint16(35551), + 71: uint16(35568), + 72: uint16(35528), + 73: uint16(35550), + 74: uint16(35553), + 75: uint16(35560), + 76: uint16(35583), + 77: uint16(35567), + 78: uint16(35579), + 79: uint16(35985), + 80: uint16(35986), + 81: uint16(35984), + 82: uint16(36085), + 83: uint16(36078), + 84: uint16(36081), + 85: uint16(36080), + 86: uint16(36083), + 87: uint16(36204), + 88: uint16(36206), + 89: uint16(36261), + 90: uint16(36263), + 91: uint16(36403), + 92: uint16(36414), + 93: uint16(36408), + 94: uint16(36416), + 95: uint16(36421), + 96: uint16(36406), + 97: uint16(36412), + 98: uint16(36413), + 99: uint16(36417), + 100: uint16(36400), + 101: uint16(36415), + 102: uint16(36541), + 103: uint16(36662), + 104: uint16(36654), + 105: uint16(36661), + 106: uint16(36658), + 107: uint16(36665), + 108: uint16(36663), + 109: uint16(36660), + 110: uint16(36982), + 111: uint16(36985), + 112: uint16(36987), + 113: uint16(36998), + 114: uint16(37114), + 115: uint16(37171), + 116: uint16(37173), + 117: uint16(37174), + 118: uint16(37267), + 119: uint16(37264), + 120: uint16(37265), + 121: uint16(37261), + 122: uint16(37263), + 123: uint16(37671), + 124: uint16(37662), + 125: uint16(37640), + 126: uint16(37663), + 127: uint16(37638), + 128: uint16(37647), + 129: uint16(37754), + 130: uint16(37688), + 131: uint16(37692), + 132: uint16(37659), + 133: uint16(37667), + 134: uint16(37650), + 135: uint16(37633), + 136: uint16(37702), + 137: uint16(37677), + 138: uint16(37646), + 139: uint16(37645), + 140: uint16(37579), + 141: uint16(37661), + 142: uint16(37626), + 143: uint16(37669), + 144: uint16(37651), + 145: uint16(37625), + 146: uint16(37623), + 147: uint16(37684), + 148: uint16(37634), + 149: uint16(37668), + 150: uint16(37631), + 151: uint16(37673), + 152: uint16(37689), + 153: uint16(37685), + 154: uint16(37674), + 155: uint16(37652), + 156: uint16(37644), + }, + 75: { + 0: uint16(37643), + 1: uint16(37630), + 2: uint16(37641), + 3: uint16(37632), + 4: uint16(37627), + 5: uint16(37654), + 6: uint16(38332), + 7: uint16(38349), + 8: uint16(38334), + 9: uint16(38329), + 10: uint16(38330), + 11: uint16(38326), + 12: uint16(38335), + 13: uint16(38325), + 14: uint16(38333), + 15: uint16(38569), + 16: uint16(38612), + 17: uint16(38667), + 18: uint16(38674), + 19: uint16(38672), + 20: uint16(38809), + 21: uint16(38807), + 22: uint16(38804), + 23: uint16(38896), + 24: uint16(38904), + 25: uint16(38965), + 26: uint16(38959), + 27: uint16(38962), + 28: uint16(39204), + 29: uint16(39199), + 30: uint16(39207), + 31: uint16(39209), + 32: uint16(39326), + 33: uint16(39406), + 34: uint16(39404), + 35: uint16(39397), + 36: uint16(39396), + 37: uint16(39408), + 38: uint16(39395), + 39: uint16(39402), + 40: uint16(39401), + 41: uint16(39399), + 42: uint16(39609), + 43: uint16(39615), + 44: uint16(39604), + 45: uint16(39611), + 46: uint16(39670), + 47: uint16(39674), + 48: uint16(39673), + 49: uint16(39671), + 50: uint16(39731), + 51: uint16(39808), + 52: uint16(39813), + 53: uint16(39815), + 54: uint16(39804), + 55: uint16(39806), + 56: uint16(39803), + 57: uint16(39810), + 58: uint16(39827), + 59: uint16(39826), + 60: uint16(39824), + 61: uint16(39802), + 62: uint16(39829), + 63: uint16(39805), + 64: uint16(39816), + 65: uint16(40229), + 66: uint16(40215), + 67: uint16(40224), + 68: uint16(40222), + 69: uint16(40212), + 70: uint16(40233), + 71: uint16(40221), + 72: uint16(40216), + 73: uint16(40226), + 74: uint16(40208), + 75: uint16(40217), + 76: uint16(40223), + 77: uint16(40584), + 78: uint16(40582), + 79: uint16(40583), + 80: uint16(40622), + 81: uint16(40621), + 82: uint16(40661), + 83: uint16(40662), + 84: uint16(40698), + 85: uint16(40722), + 86: uint16(40765), + 87: uint16(20774), + 88: uint16(20773), + 89: uint16(20770), + 90: uint16(20772), + 91: uint16(20768), + 92: uint16(20777), + 93: uint16(21236), + 94: uint16(22163), + 95: uint16(22156), + 96: uint16(22157), + 97: uint16(22150), + 98: uint16(22148), + 99: uint16(22147), + 100: uint16(22142), + 101: uint16(22146), + 102: uint16(22143), + 103: uint16(22145), + 104: uint16(22742), + 105: uint16(22740), + 106: uint16(22735), + 107: uint16(22738), + 108: uint16(23341), + 109: uint16(23333), + 110: uint16(23346), + 111: uint16(23331), + 112: uint16(23340), + 113: uint16(23335), + 114: uint16(23334), + 115: uint16(23343), + 116: uint16(23342), + 117: uint16(23419), + 118: uint16(23537), + 119: uint16(23538), + 120: uint16(23991), + 121: uint16(24172), + 122: uint16(24170), + 123: uint16(24510), + 124: uint16(24507), + 125: uint16(25027), + 126: uint16(25013), + 127: uint16(25020), + 128: uint16(25063), + 129: uint16(25056), + 130: uint16(25061), + 131: uint16(25060), + 132: uint16(25064), + 133: uint16(25054), + 134: uint16(25839), + 135: uint16(25833), + 136: uint16(25827), + 137: uint16(25835), + 138: uint16(25828), + 139: uint16(25832), + 140: uint16(25985), + 141: uint16(25984), + 142: uint16(26038), + 143: uint16(26074), + 144: uint16(26322), + 145: uint16(27277), + 146: uint16(27286), + 147: uint16(27265), + 148: uint16(27301), + 149: uint16(27273), + 150: uint16(27295), + 151: uint16(27291), + 152: uint16(27297), + 153: uint16(27294), + 154: uint16(27271), + 155: uint16(27283), + 156: uint16(27278), + }, + 76: { + 0: uint16(27285), + 1: uint16(27267), + 2: uint16(27304), + 3: uint16(27300), + 4: uint16(27281), + 5: uint16(27263), + 6: uint16(27302), + 7: uint16(27290), + 8: uint16(27269), + 9: uint16(27276), + 10: uint16(27282), + 11: uint16(27483), + 12: uint16(27565), + 13: uint16(27657), + 14: uint16(28620), + 15: uint16(28585), + 16: uint16(28660), + 17: uint16(28628), + 18: uint16(28643), + 19: uint16(28636), + 20: uint16(28653), + 21: uint16(28647), + 22: uint16(28646), + 23: uint16(28638), + 24: uint16(28658), + 25: uint16(28637), + 26: uint16(28642), + 27: uint16(28648), + 28: uint16(29153), + 29: uint16(29169), + 30: uint16(29160), + 31: uint16(29170), + 32: uint16(29156), + 33: uint16(29168), + 34: uint16(29154), + 35: uint16(29555), + 36: uint16(29550), + 37: uint16(29551), + 38: uint16(29847), + 39: uint16(29874), + 40: uint16(29867), + 41: uint16(29840), + 42: uint16(29866), + 43: uint16(29869), + 44: uint16(29873), + 45: uint16(29861), + 46: uint16(29871), + 47: uint16(29968), + 48: uint16(29969), + 49: uint16(29970), + 50: uint16(29967), + 51: uint16(30084), + 52: uint16(30275), + 53: uint16(30280), + 54: uint16(30281), + 55: uint16(30279), + 56: uint16(30372), + 57: uint16(30441), + 58: uint16(30645), + 59: uint16(30635), + 60: uint16(30642), + 61: uint16(30647), + 62: uint16(30646), + 63: uint16(30644), + 64: uint16(30641), + 65: uint16(30632), + 66: uint16(30704), + 67: uint16(30963), + 68: uint16(30973), + 69: uint16(30978), + 70: uint16(30971), + 71: uint16(30972), + 72: uint16(30962), + 73: uint16(30981), + 74: uint16(30969), + 75: uint16(30974), + 76: uint16(30980), + 77: uint16(31147), + 78: uint16(31144), + 79: uint16(31324), + 80: uint16(31323), + 81: uint16(31318), + 82: uint16(31320), + 83: uint16(31316), + 84: uint16(31322), + 85: uint16(31422), + 86: uint16(31424), + 87: uint16(31425), + 88: uint16(31749), + 89: uint16(31759), + 90: uint16(31730), + 91: uint16(31744), + 92: uint16(31743), + 93: uint16(31739), + 94: uint16(31758), + 95: uint16(31732), + 96: uint16(31755), + 97: uint16(31731), + 98: uint16(31746), + 99: uint16(31753), + 100: uint16(31747), + 101: uint16(31745), + 102: uint16(31736), + 103: uint16(31741), + 104: uint16(31750), + 105: uint16(31728), + 106: uint16(31729), + 107: uint16(31760), + 108: uint16(31754), + 109: uint16(31976), + 110: uint16(32301), + 111: uint16(32316), + 112: uint16(32322), + 113: uint16(32307), + 114: uint16(38984), + 115: uint16(32312), + 116: uint16(32298), + 117: uint16(32329), + 118: uint16(32320), + 119: uint16(32327), + 120: uint16(32297), + 121: uint16(32332), + 122: uint16(32304), + 123: uint16(32315), + 124: uint16(32310), + 125: uint16(32324), + 126: uint16(32314), + 127: uint16(32581), + 128: uint16(32639), + 129: uint16(32638), + 130: uint16(32637), + 131: uint16(32756), + 132: uint16(32754), + 133: uint16(32812), + 134: uint16(33211), + 135: uint16(33220), + 136: uint16(33228), + 137: uint16(33226), + 138: uint16(33221), + 139: uint16(33223), + 140: uint16(33212), + 141: uint16(33257), + 142: uint16(33371), + 143: uint16(33370), + 144: uint16(33372), + 145: uint16(34179), + 146: uint16(34176), + 147: uint16(34191), + 148: uint16(34215), + 149: uint16(34197), + 150: uint16(34208), + 151: uint16(34187), + 152: uint16(34211), + 153: uint16(34171), + 154: uint16(34212), + 155: uint16(34202), + 156: uint16(34206), + }, + 77: { + 0: uint16(34167), + 1: uint16(34172), + 2: uint16(34185), + 3: uint16(34209), + 4: uint16(34170), + 5: uint16(34168), + 6: uint16(34135), + 7: uint16(34190), + 8: uint16(34198), + 9: uint16(34182), + 10: uint16(34189), + 11: uint16(34201), + 12: uint16(34205), + 13: uint16(34177), + 14: uint16(34210), + 15: uint16(34178), + 16: uint16(34184), + 17: uint16(34181), + 18: uint16(34169), + 19: uint16(34166), + 20: uint16(34200), + 21: uint16(34192), + 22: uint16(34207), + 23: uint16(34408), + 24: uint16(34750), + 25: uint16(34730), + 26: uint16(34733), + 27: uint16(34757), + 28: uint16(34736), + 29: uint16(34732), + 30: uint16(34745), + 31: uint16(34741), + 32: uint16(34748), + 33: uint16(34734), + 34: uint16(34761), + 35: uint16(34755), + 36: uint16(34754), + 37: uint16(34764), + 38: uint16(34743), + 39: uint16(34735), + 40: uint16(34756), + 41: uint16(34762), + 42: uint16(34740), + 43: uint16(34742), + 44: uint16(34751), + 45: uint16(34744), + 46: uint16(34749), + 47: uint16(34782), + 48: uint16(34738), + 49: uint16(35125), + 50: uint16(35123), + 51: uint16(35132), + 52: uint16(35134), + 53: uint16(35137), + 54: uint16(35154), + 55: uint16(35127), + 56: uint16(35138), + 57: uint16(35245), + 58: uint16(35247), + 59: uint16(35246), + 60: uint16(35314), + 61: uint16(35315), + 62: uint16(35614), + 63: uint16(35608), + 64: uint16(35606), + 65: uint16(35601), + 66: uint16(35589), + 67: uint16(35595), + 68: uint16(35618), + 69: uint16(35599), + 70: uint16(35602), + 71: uint16(35605), + 72: uint16(35591), + 73: uint16(35597), + 74: uint16(35592), + 75: uint16(35590), + 76: uint16(35612), + 77: uint16(35603), + 78: uint16(35610), + 79: uint16(35919), + 80: uint16(35952), + 81: uint16(35954), + 82: uint16(35953), + 83: uint16(35951), + 84: uint16(35989), + 85: uint16(35988), + 86: uint16(36089), + 87: uint16(36207), + 88: uint16(36430), + 89: uint16(36429), + 90: uint16(36435), + 91: uint16(36432), + 92: uint16(36428), + 93: uint16(36423), + 94: uint16(36675), + 95: uint16(36672), + 96: uint16(36997), + 97: uint16(36990), + 98: uint16(37176), + 99: uint16(37274), + 100: uint16(37282), + 101: uint16(37275), + 102: uint16(37273), + 103: uint16(37279), + 104: uint16(37281), + 105: uint16(37277), + 106: uint16(37280), + 107: uint16(37793), + 108: uint16(37763), + 109: uint16(37807), + 110: uint16(37732), + 111: uint16(37718), + 112: uint16(37703), + 113: uint16(37756), + 114: uint16(37720), + 115: uint16(37724), + 116: uint16(37750), + 117: uint16(37705), + 118: uint16(37712), + 119: uint16(37713), + 120: uint16(37728), + 121: uint16(37741), + 122: uint16(37775), + 123: uint16(37708), + 124: uint16(37738), + 125: uint16(37753), + 126: uint16(37719), + 127: uint16(37717), + 128: uint16(37714), + 129: uint16(37711), + 130: uint16(37745), + 131: uint16(37751), + 132: uint16(37755), + 133: uint16(37729), + 134: uint16(37726), + 135: uint16(37731), + 136: uint16(37735), + 137: uint16(37760), + 138: uint16(37710), + 139: uint16(37721), + 140: uint16(38343), + 141: uint16(38336), + 142: uint16(38345), + 143: uint16(38339), + 144: uint16(38341), + 145: uint16(38327), + 146: uint16(38574), + 147: uint16(38576), + 148: uint16(38572), + 149: uint16(38688), + 150: uint16(38687), + 151: uint16(38680), + 152: uint16(38685), + 153: uint16(38681), + 154: uint16(38810), + 155: uint16(38817), + 156: uint16(38812), + }, + 78: { + 0: uint16(38814), + 1: uint16(38813), + 2: uint16(38869), + 3: uint16(38868), + 4: uint16(38897), + 5: uint16(38977), + 6: uint16(38980), + 7: uint16(38986), + 8: uint16(38985), + 9: uint16(38981), + 10: uint16(38979), + 11: uint16(39205), + 12: uint16(39211), + 13: uint16(39212), + 14: uint16(39210), + 15: uint16(39219), + 16: uint16(39218), + 17: uint16(39215), + 18: uint16(39213), + 19: uint16(39217), + 20: uint16(39216), + 21: uint16(39320), + 22: uint16(39331), + 23: uint16(39329), + 24: uint16(39426), + 25: uint16(39418), + 26: uint16(39412), + 27: uint16(39415), + 28: uint16(39417), + 29: uint16(39416), + 30: uint16(39414), + 31: uint16(39419), + 32: uint16(39421), + 33: uint16(39422), + 34: uint16(39420), + 35: uint16(39427), + 36: uint16(39614), + 37: uint16(39678), + 38: uint16(39677), + 39: uint16(39681), + 40: uint16(39676), + 41: uint16(39752), + 42: uint16(39834), + 43: uint16(39848), + 44: uint16(39838), + 45: uint16(39835), + 46: uint16(39846), + 47: uint16(39841), + 48: uint16(39845), + 49: uint16(39844), + 50: uint16(39814), + 51: uint16(39842), + 52: uint16(39840), + 53: uint16(39855), + 54: uint16(40243), + 55: uint16(40257), + 56: uint16(40295), + 57: uint16(40246), + 58: uint16(40238), + 59: uint16(40239), + 60: uint16(40241), + 61: uint16(40248), + 62: uint16(40240), + 63: uint16(40261), + 64: uint16(40258), + 65: uint16(40259), + 66: uint16(40254), + 67: uint16(40247), + 68: uint16(40256), + 69: uint16(40253), + 70: uint16(32757), + 71: uint16(40237), + 72: uint16(40586), + 73: uint16(40585), + 74: uint16(40589), + 75: uint16(40624), + 76: uint16(40648), + 77: uint16(40666), + 78: uint16(40699), + 79: uint16(40703), + 80: uint16(40740), + 81: uint16(40739), + 82: uint16(40738), + 83: uint16(40788), + 84: uint16(40864), + 85: uint16(20785), + 86: uint16(20781), + 87: uint16(20782), + 88: uint16(22168), + 89: uint16(22172), + 90: uint16(22167), + 91: uint16(22170), + 92: uint16(22173), + 93: uint16(22169), + 94: uint16(22896), + 95: uint16(23356), + 96: uint16(23657), + 97: uint16(23658), + 98: uint16(24000), + 99: uint16(24173), + 100: uint16(24174), + 101: uint16(25048), + 102: uint16(25055), + 103: uint16(25069), + 104: uint16(25070), + 105: uint16(25073), + 106: uint16(25066), + 107: uint16(25072), + 108: uint16(25067), + 109: uint16(25046), + 110: uint16(25065), + 111: uint16(25855), + 112: uint16(25860), + 113: uint16(25853), + 114: uint16(25848), + 115: uint16(25857), + 116: uint16(25859), + 117: uint16(25852), + 118: uint16(26004), + 119: uint16(26075), + 120: uint16(26330), + 121: uint16(26331), + 122: uint16(26328), + 123: uint16(27333), + 124: uint16(27321), + 125: uint16(27325), + 126: uint16(27361), + 127: uint16(27334), + 128: uint16(27322), + 129: uint16(27318), + 130: uint16(27319), + 131: uint16(27335), + 132: uint16(27316), + 133: uint16(27309), + 134: uint16(27486), + 135: uint16(27593), + 136: uint16(27659), + 137: uint16(28679), + 138: uint16(28684), + 139: uint16(28685), + 140: uint16(28673), + 141: uint16(28677), + 142: uint16(28692), + 143: uint16(28686), + 144: uint16(28671), + 145: uint16(28672), + 146: uint16(28667), + 147: uint16(28710), + 148: uint16(28668), + 149: uint16(28663), + 150: uint16(28682), + 151: uint16(29185), + 152: uint16(29183), + 153: uint16(29177), + 154: uint16(29187), + 155: uint16(29181), + 156: uint16(29558), + }, + 79: { + 0: uint16(29880), + 1: uint16(29888), + 2: uint16(29877), + 3: uint16(29889), + 4: uint16(29886), + 5: uint16(29878), + 6: uint16(29883), + 7: uint16(29890), + 8: uint16(29972), + 9: uint16(29971), + 10: uint16(30300), + 11: uint16(30308), + 12: uint16(30297), + 13: uint16(30288), + 14: uint16(30291), + 15: uint16(30295), + 16: uint16(30298), + 17: uint16(30374), + 18: uint16(30397), + 19: uint16(30444), + 20: uint16(30658), + 21: uint16(30650), + 22: uint16(30975), + 23: uint16(30988), + 24: uint16(30995), + 25: uint16(30996), + 26: uint16(30985), + 27: uint16(30992), + 28: uint16(30994), + 29: uint16(30993), + 30: uint16(31149), + 31: uint16(31148), + 32: uint16(31327), + 33: uint16(31772), + 34: uint16(31785), + 35: uint16(31769), + 36: uint16(31776), + 37: uint16(31775), + 38: uint16(31789), + 39: uint16(31773), + 40: uint16(31782), + 41: uint16(31784), + 42: uint16(31778), + 43: uint16(31781), + 44: uint16(31792), + 45: uint16(32348), + 46: uint16(32336), + 47: uint16(32342), + 48: uint16(32355), + 49: uint16(32344), + 50: uint16(32354), + 51: uint16(32351), + 52: uint16(32337), + 53: uint16(32352), + 54: uint16(32343), + 55: uint16(32339), + 56: uint16(32693), + 57: uint16(32691), + 58: uint16(32759), + 59: uint16(32760), + 60: uint16(32885), + 61: uint16(33233), + 62: uint16(33234), + 63: uint16(33232), + 64: uint16(33375), + 65: uint16(33374), + 66: uint16(34228), + 67: uint16(34246), + 68: uint16(34240), + 69: uint16(34243), + 70: uint16(34242), + 71: uint16(34227), + 72: uint16(34229), + 73: uint16(34237), + 74: uint16(34247), + 75: uint16(34244), + 76: uint16(34239), + 77: uint16(34251), + 78: uint16(34254), + 79: uint16(34248), + 80: uint16(34245), + 81: uint16(34225), + 82: uint16(34230), + 83: uint16(34258), + 84: uint16(34340), + 85: uint16(34232), + 86: uint16(34231), + 87: uint16(34238), + 88: uint16(34409), + 89: uint16(34791), + 90: uint16(34790), + 91: uint16(34786), + 92: uint16(34779), + 93: uint16(34795), + 94: uint16(34794), + 95: uint16(34789), + 96: uint16(34783), + 97: uint16(34803), + 98: uint16(34788), + 99: uint16(34772), + 100: uint16(34780), + 101: uint16(34771), + 102: uint16(34797), + 103: uint16(34776), + 104: uint16(34787), + 105: uint16(34724), + 106: uint16(34775), + 107: uint16(34777), + 108: uint16(34817), + 109: uint16(34804), + 110: uint16(34792), + 111: uint16(34781), + 112: uint16(35155), + 113: uint16(35147), + 114: uint16(35151), + 115: uint16(35148), + 116: uint16(35142), + 117: uint16(35152), + 118: uint16(35153), + 119: uint16(35145), + 120: uint16(35626), + 121: uint16(35623), + 122: uint16(35619), + 123: uint16(35635), + 124: uint16(35632), + 125: uint16(35637), + 126: uint16(35655), + 127: uint16(35631), + 128: uint16(35644), + 129: uint16(35646), + 130: uint16(35633), + 131: uint16(35621), + 132: uint16(35639), + 133: uint16(35622), + 134: uint16(35638), + 135: uint16(35630), + 136: uint16(35620), + 137: uint16(35643), + 138: uint16(35645), + 139: uint16(35642), + 140: uint16(35906), + 141: uint16(35957), + 142: uint16(35993), + 143: uint16(35992), + 144: uint16(35991), + 145: uint16(36094), + 146: uint16(36100), + 147: uint16(36098), + 148: uint16(36096), + 149: uint16(36444), + 150: uint16(36450), + 151: uint16(36448), + 152: uint16(36439), + 153: uint16(36438), + 154: uint16(36446), + 155: uint16(36453), + 156: uint16(36455), + }, + 80: { + 0: uint16(36443), + 1: uint16(36442), + 2: uint16(36449), + 3: uint16(36445), + 4: uint16(36457), + 5: uint16(36436), + 6: uint16(36678), + 7: uint16(36679), + 8: uint16(36680), + 9: uint16(36683), + 10: uint16(37160), + 11: uint16(37178), + 12: uint16(37179), + 13: uint16(37182), + 14: uint16(37288), + 15: uint16(37285), + 16: uint16(37287), + 17: uint16(37295), + 18: uint16(37290), + 19: uint16(37813), + 20: uint16(37772), + 21: uint16(37778), + 22: uint16(37815), + 23: uint16(37787), + 24: uint16(37789), + 25: uint16(37769), + 26: uint16(37799), + 27: uint16(37774), + 28: uint16(37802), + 29: uint16(37790), + 30: uint16(37798), + 31: uint16(37781), + 32: uint16(37768), + 33: uint16(37785), + 34: uint16(37791), + 35: uint16(37773), + 36: uint16(37809), + 37: uint16(37777), + 38: uint16(37810), + 39: uint16(37796), + 40: uint16(37800), + 41: uint16(37812), + 42: uint16(37795), + 43: uint16(37797), + 44: uint16(38354), + 45: uint16(38355), + 46: uint16(38353), + 47: uint16(38579), + 48: uint16(38615), + 49: uint16(38618), + 50: uint16(24002), + 51: uint16(38623), + 52: uint16(38616), + 53: uint16(38621), + 54: uint16(38691), + 55: uint16(38690), + 56: uint16(38693), + 57: uint16(38828), + 58: uint16(38830), + 59: uint16(38824), + 60: uint16(38827), + 61: uint16(38820), + 62: uint16(38826), + 63: uint16(38818), + 64: uint16(38821), + 65: uint16(38871), + 66: uint16(38873), + 67: uint16(38870), + 68: uint16(38872), + 69: uint16(38906), + 70: uint16(38992), + 71: uint16(38993), + 72: uint16(38994), + 73: uint16(39096), + 74: uint16(39233), + 75: uint16(39228), + 76: uint16(39226), + 77: uint16(39439), + 78: uint16(39435), + 79: uint16(39433), + 80: uint16(39437), + 81: uint16(39428), + 82: uint16(39441), + 83: uint16(39434), + 84: uint16(39429), + 85: uint16(39431), + 86: uint16(39430), + 87: uint16(39616), + 88: uint16(39644), + 89: uint16(39688), + 90: uint16(39684), + 91: uint16(39685), + 92: uint16(39721), + 93: uint16(39733), + 94: uint16(39754), + 95: uint16(39756), + 96: uint16(39755), + 97: uint16(39879), + 98: uint16(39878), + 99: uint16(39875), + 100: uint16(39871), + 101: uint16(39873), + 102: uint16(39861), + 103: uint16(39864), + 104: uint16(39891), + 105: uint16(39862), + 106: uint16(39876), + 107: uint16(39865), + 108: uint16(39869), + 109: uint16(40284), + 110: uint16(40275), + 111: uint16(40271), + 112: uint16(40266), + 113: uint16(40283), + 114: uint16(40267), + 115: uint16(40281), + 116: uint16(40278), + 117: uint16(40268), + 118: uint16(40279), + 119: uint16(40274), + 120: uint16(40276), + 121: uint16(40287), + 122: uint16(40280), + 123: uint16(40282), + 124: uint16(40590), + 125: uint16(40588), + 126: uint16(40671), + 127: uint16(40705), + 128: uint16(40704), + 129: uint16(40726), + 130: uint16(40741), + 131: uint16(40747), + 132: uint16(40746), + 133: uint16(40745), + 134: uint16(40744), + 135: uint16(40780), + 136: uint16(40789), + 137: uint16(20788), + 138: uint16(20789), + 139: uint16(21142), + 140: uint16(21239), + 141: uint16(21428), + 142: uint16(22187), + 143: uint16(22189), + 144: uint16(22182), + 145: uint16(22183), + 146: uint16(22186), + 147: uint16(22188), + 148: uint16(22746), + 149: uint16(22749), + 150: uint16(22747), + 151: uint16(22802), + 152: uint16(23357), + 153: uint16(23358), + 154: uint16(23359), + 155: uint16(24003), + 156: uint16(24176), + }, + 81: { + 0: uint16(24511), + 1: uint16(25083), + 2: uint16(25863), + 3: uint16(25872), + 4: uint16(25869), + 5: uint16(25865), + 6: uint16(25868), + 7: uint16(25870), + 8: uint16(25988), + 9: uint16(26078), + 10: uint16(26077), + 11: uint16(26334), + 12: uint16(27367), + 13: uint16(27360), + 14: uint16(27340), + 15: uint16(27345), + 16: uint16(27353), + 17: uint16(27339), + 18: uint16(27359), + 19: uint16(27356), + 20: uint16(27344), + 21: uint16(27371), + 22: uint16(27343), + 23: uint16(27341), + 24: uint16(27358), + 25: uint16(27488), + 26: uint16(27568), + 27: uint16(27660), + 28: uint16(28697), + 29: uint16(28711), + 30: uint16(28704), + 31: uint16(28694), + 32: uint16(28715), + 33: uint16(28705), + 34: uint16(28706), + 35: uint16(28707), + 36: uint16(28713), + 37: uint16(28695), + 38: uint16(28708), + 39: uint16(28700), + 40: uint16(28714), + 41: uint16(29196), + 42: uint16(29194), + 43: uint16(29191), + 44: uint16(29186), + 45: uint16(29189), + 46: uint16(29349), + 47: uint16(29350), + 48: uint16(29348), + 49: uint16(29347), + 50: uint16(29345), + 51: uint16(29899), + 52: uint16(29893), + 53: uint16(29879), + 54: uint16(29891), + 55: uint16(29974), + 56: uint16(30304), + 57: uint16(30665), + 58: uint16(30666), + 59: uint16(30660), + 60: uint16(30705), + 61: uint16(31005), + 62: uint16(31003), + 63: uint16(31009), + 64: uint16(31004), + 65: uint16(30999), + 66: uint16(31006), + 67: uint16(31152), + 68: uint16(31335), + 69: uint16(31336), + 70: uint16(31795), + 71: uint16(31804), + 72: uint16(31801), + 73: uint16(31788), + 74: uint16(31803), + 75: uint16(31980), + 76: uint16(31978), + 77: uint16(32374), + 78: uint16(32373), + 79: uint16(32376), + 80: uint16(32368), + 81: uint16(32375), + 82: uint16(32367), + 83: uint16(32378), + 84: uint16(32370), + 85: uint16(32372), + 86: uint16(32360), + 87: uint16(32587), + 88: uint16(32586), + 89: uint16(32643), + 90: uint16(32646), + 91: uint16(32695), + 92: uint16(32765), + 93: uint16(32766), + 94: uint16(32888), + 95: uint16(33239), + 96: uint16(33237), + 97: uint16(33380), + 98: uint16(33377), + 99: uint16(33379), + 100: uint16(34283), + 101: uint16(34289), + 102: uint16(34285), + 103: uint16(34265), + 104: uint16(34273), + 105: uint16(34280), + 106: uint16(34266), + 107: uint16(34263), + 108: uint16(34284), + 109: uint16(34290), + 110: uint16(34296), + 111: uint16(34264), + 112: uint16(34271), + 113: uint16(34275), + 114: uint16(34268), + 115: uint16(34257), + 116: uint16(34288), + 117: uint16(34278), + 118: uint16(34287), + 119: uint16(34270), + 120: uint16(34274), + 121: uint16(34816), + 122: uint16(34810), + 123: uint16(34819), + 124: uint16(34806), + 125: uint16(34807), + 126: uint16(34825), + 127: uint16(34828), + 128: uint16(34827), + 129: uint16(34822), + 130: uint16(34812), + 131: uint16(34824), + 132: uint16(34815), + 133: uint16(34826), + 134: uint16(34818), + 135: uint16(35170), + 136: uint16(35162), + 137: uint16(35163), + 138: uint16(35159), + 139: uint16(35169), + 140: uint16(35164), + 141: uint16(35160), + 142: uint16(35165), + 143: uint16(35161), + 144: uint16(35208), + 145: uint16(35255), + 146: uint16(35254), + 147: uint16(35318), + 148: uint16(35664), + 149: uint16(35656), + 150: uint16(35658), + 151: uint16(35648), + 152: uint16(35667), + 153: uint16(35670), + 154: uint16(35668), + 155: uint16(35659), + 156: uint16(35669), + }, + 82: { + 0: uint16(35665), + 1: uint16(35650), + 2: uint16(35666), + 3: uint16(35671), + 4: uint16(35907), + 5: uint16(35959), + 6: uint16(35958), + 7: uint16(35994), + 8: uint16(36102), + 9: uint16(36103), + 10: uint16(36105), + 11: uint16(36268), + 12: uint16(36266), + 13: uint16(36269), + 14: uint16(36267), + 15: uint16(36461), + 16: uint16(36472), + 17: uint16(36467), + 18: uint16(36458), + 19: uint16(36463), + 20: uint16(36475), + 21: uint16(36546), + 22: uint16(36690), + 23: uint16(36689), + 24: uint16(36687), + 25: uint16(36688), + 26: uint16(36691), + 27: uint16(36788), + 28: uint16(37184), + 29: uint16(37183), + 30: uint16(37296), + 31: uint16(37293), + 32: uint16(37854), + 33: uint16(37831), + 34: uint16(37839), + 35: uint16(37826), + 36: uint16(37850), + 37: uint16(37840), + 38: uint16(37881), + 39: uint16(37868), + 40: uint16(37836), + 41: uint16(37849), + 42: uint16(37801), + 43: uint16(37862), + 44: uint16(37834), + 45: uint16(37844), + 46: uint16(37870), + 47: uint16(37859), + 48: uint16(37845), + 49: uint16(37828), + 50: uint16(37838), + 51: uint16(37824), + 52: uint16(37842), + 53: uint16(37863), + 54: uint16(38269), + 55: uint16(38362), + 56: uint16(38363), + 57: uint16(38625), + 58: uint16(38697), + 59: uint16(38699), + 60: uint16(38700), + 61: uint16(38696), + 62: uint16(38694), + 63: uint16(38835), + 64: uint16(38839), + 65: uint16(38838), + 66: uint16(38877), + 67: uint16(38878), + 68: uint16(38879), + 69: uint16(39004), + 70: uint16(39001), + 71: uint16(39005), + 72: uint16(38999), + 73: uint16(39103), + 74: uint16(39101), + 75: uint16(39099), + 76: uint16(39102), + 77: uint16(39240), + 78: uint16(39239), + 79: uint16(39235), + 80: uint16(39334), + 81: uint16(39335), + 82: uint16(39450), + 83: uint16(39445), + 84: uint16(39461), + 85: uint16(39453), + 86: uint16(39460), + 87: uint16(39451), + 88: uint16(39458), + 89: uint16(39456), + 90: uint16(39463), + 91: uint16(39459), + 92: uint16(39454), + 93: uint16(39452), + 94: uint16(39444), + 95: uint16(39618), + 96: uint16(39691), + 97: uint16(39690), + 98: uint16(39694), + 99: uint16(39692), + 100: uint16(39735), + 101: uint16(39914), + 102: uint16(39915), + 103: uint16(39904), + 104: uint16(39902), + 105: uint16(39908), + 106: uint16(39910), + 107: uint16(39906), + 108: uint16(39920), + 109: uint16(39892), + 110: uint16(39895), + 111: uint16(39916), + 112: uint16(39900), + 113: uint16(39897), + 114: uint16(39909), + 115: uint16(39893), + 116: uint16(39905), + 117: uint16(39898), + 118: uint16(40311), + 119: uint16(40321), + 120: uint16(40330), + 121: uint16(40324), + 122: uint16(40328), + 123: uint16(40305), + 124: uint16(40320), + 125: uint16(40312), + 126: uint16(40326), + 127: uint16(40331), + 128: uint16(40332), + 129: uint16(40317), + 130: uint16(40299), + 131: uint16(40308), + 132: uint16(40309), + 133: uint16(40304), + 134: uint16(40297), + 135: uint16(40325), + 136: uint16(40307), + 137: uint16(40315), + 138: uint16(40322), + 139: uint16(40303), + 140: uint16(40313), + 141: uint16(40319), + 142: uint16(40327), + 143: uint16(40296), + 144: uint16(40596), + 145: uint16(40593), + 146: uint16(40640), + 147: uint16(40700), + 148: uint16(40749), + 149: uint16(40768), + 150: uint16(40769), + 151: uint16(40781), + 152: uint16(40790), + 153: uint16(40791), + 154: uint16(40792), + 155: uint16(21303), + 156: uint16(22194), + }, + 83: { + 0: uint16(22197), + 1: uint16(22195), + 2: uint16(22755), + 3: uint16(23365), + 4: uint16(24006), + 5: uint16(24007), + 6: uint16(24302), + 7: uint16(24303), + 8: uint16(24512), + 9: uint16(24513), + 10: uint16(25081), + 11: uint16(25879), + 12: uint16(25878), + 13: uint16(25877), + 14: uint16(25875), + 15: uint16(26079), + 16: uint16(26344), + 17: uint16(26339), + 18: uint16(26340), + 19: uint16(27379), + 20: uint16(27376), + 21: uint16(27370), + 22: uint16(27368), + 23: uint16(27385), + 24: uint16(27377), + 25: uint16(27374), + 26: uint16(27375), + 27: uint16(28732), + 28: uint16(28725), + 29: uint16(28719), + 30: uint16(28727), + 31: uint16(28724), + 32: uint16(28721), + 33: uint16(28738), + 34: uint16(28728), + 35: uint16(28735), + 36: uint16(28730), + 37: uint16(28729), + 38: uint16(28736), + 39: uint16(28731), + 40: uint16(28723), + 41: uint16(28737), + 42: uint16(29203), + 43: uint16(29204), + 44: uint16(29352), + 45: uint16(29565), + 46: uint16(29564), + 47: uint16(29882), + 48: uint16(30379), + 49: uint16(30378), + 50: uint16(30398), + 51: uint16(30445), + 52: uint16(30668), + 53: uint16(30670), + 54: uint16(30671), + 55: uint16(30669), + 56: uint16(30706), + 57: uint16(31013), + 58: uint16(31011), + 59: uint16(31015), + 60: uint16(31016), + 61: uint16(31012), + 62: uint16(31017), + 63: uint16(31154), + 64: uint16(31342), + 65: uint16(31340), + 66: uint16(31341), + 67: uint16(31479), + 68: uint16(31817), + 69: uint16(31816), + 70: uint16(31818), + 71: uint16(31815), + 72: uint16(31813), + 73: uint16(31982), + 74: uint16(32379), + 75: uint16(32382), + 76: uint16(32385), + 77: uint16(32384), + 78: uint16(32698), + 79: uint16(32767), + 80: uint16(32889), + 81: uint16(33243), + 82: uint16(33241), + 83: uint16(33291), + 84: uint16(33384), + 85: uint16(33385), + 86: uint16(34338), + 87: uint16(34303), + 88: uint16(34305), + 89: uint16(34302), + 90: uint16(34331), + 91: uint16(34304), + 92: uint16(34294), + 93: uint16(34308), + 94: uint16(34313), + 95: uint16(34309), + 96: uint16(34316), + 97: uint16(34301), + 98: uint16(34841), + 99: uint16(34832), + 100: uint16(34833), + 101: uint16(34839), + 102: uint16(34835), + 103: uint16(34838), + 104: uint16(35171), + 105: uint16(35174), + 106: uint16(35257), + 107: uint16(35319), + 108: uint16(35680), + 109: uint16(35690), + 110: uint16(35677), + 111: uint16(35688), + 112: uint16(35683), + 113: uint16(35685), + 114: uint16(35687), + 115: uint16(35693), + 116: uint16(36270), + 117: uint16(36486), + 118: uint16(36488), + 119: uint16(36484), + 120: uint16(36697), + 121: uint16(36694), + 122: uint16(36695), + 123: uint16(36693), + 124: uint16(36696), + 125: uint16(36698), + 126: uint16(37005), + 127: uint16(37187), + 128: uint16(37185), + 129: uint16(37303), + 130: uint16(37301), + 131: uint16(37298), + 132: uint16(37299), + 133: uint16(37899), + 134: uint16(37907), + 135: uint16(37883), + 136: uint16(37920), + 137: uint16(37903), + 138: uint16(37908), + 139: uint16(37886), + 140: uint16(37909), + 141: uint16(37904), + 142: uint16(37928), + 143: uint16(37913), + 144: uint16(37901), + 145: uint16(37877), + 146: uint16(37888), + 147: uint16(37879), + 148: uint16(37895), + 149: uint16(37902), + 150: uint16(37910), + 151: uint16(37906), + 152: uint16(37882), + 153: uint16(37897), + 154: uint16(37880), + 155: uint16(37898), + 156: uint16(37887), + }, + 84: { + 0: uint16(37884), + 1: uint16(37900), + 2: uint16(37878), + 3: uint16(37905), + 4: uint16(37894), + 5: uint16(38366), + 6: uint16(38368), + 7: uint16(38367), + 8: uint16(38702), + 9: uint16(38703), + 10: uint16(38841), + 11: uint16(38843), + 12: uint16(38909), + 13: uint16(38910), + 14: uint16(39008), + 15: uint16(39010), + 16: uint16(39011), + 17: uint16(39007), + 18: uint16(39105), + 19: uint16(39106), + 20: uint16(39248), + 21: uint16(39246), + 22: uint16(39257), + 23: uint16(39244), + 24: uint16(39243), + 25: uint16(39251), + 26: uint16(39474), + 27: uint16(39476), + 28: uint16(39473), + 29: uint16(39468), + 30: uint16(39466), + 31: uint16(39478), + 32: uint16(39465), + 33: uint16(39470), + 34: uint16(39480), + 35: uint16(39469), + 36: uint16(39623), + 37: uint16(39626), + 38: uint16(39622), + 39: uint16(39696), + 40: uint16(39698), + 41: uint16(39697), + 42: uint16(39947), + 43: uint16(39944), + 44: uint16(39927), + 45: uint16(39941), + 46: uint16(39954), + 47: uint16(39928), + 48: uint16(40000), + 49: uint16(39943), + 50: uint16(39950), + 51: uint16(39942), + 52: uint16(39959), + 53: uint16(39956), + 54: uint16(39945), + 55: uint16(40351), + 56: uint16(40345), + 57: uint16(40356), + 58: uint16(40349), + 59: uint16(40338), + 60: uint16(40344), + 61: uint16(40336), + 62: uint16(40347), + 63: uint16(40352), + 64: uint16(40340), + 65: uint16(40348), + 66: uint16(40362), + 67: uint16(40343), + 68: uint16(40353), + 69: uint16(40346), + 70: uint16(40354), + 71: uint16(40360), + 72: uint16(40350), + 73: uint16(40355), + 74: uint16(40383), + 75: uint16(40361), + 76: uint16(40342), + 77: uint16(40358), + 78: uint16(40359), + 79: uint16(40601), + 80: uint16(40603), + 81: uint16(40602), + 82: uint16(40677), + 83: uint16(40676), + 84: uint16(40679), + 85: uint16(40678), + 86: uint16(40752), + 87: uint16(40750), + 88: uint16(40795), + 89: uint16(40800), + 90: uint16(40798), + 91: uint16(40797), + 92: uint16(40793), + 93: uint16(40849), + 94: uint16(20794), + 95: uint16(20793), + 96: uint16(21144), + 97: uint16(21143), + 98: uint16(22211), + 99: uint16(22205), + 100: uint16(22206), + 101: uint16(23368), + 102: uint16(23367), + 103: uint16(24011), + 104: uint16(24015), + 105: uint16(24305), + 106: uint16(25085), + 107: uint16(25883), + 108: uint16(27394), + 109: uint16(27388), + 110: uint16(27395), + 111: uint16(27384), + 112: uint16(27392), + 113: uint16(28739), + 114: uint16(28740), + 115: uint16(28746), + 116: uint16(28744), + 117: uint16(28745), + 118: uint16(28741), + 119: uint16(28742), + 120: uint16(29213), + 121: uint16(29210), + 122: uint16(29209), + 123: uint16(29566), + 124: uint16(29975), + 125: uint16(30314), + 126: uint16(30672), + 127: uint16(31021), + 128: uint16(31025), + 129: uint16(31023), + 130: uint16(31828), + 131: uint16(31827), + 132: uint16(31986), + 133: uint16(32394), + 134: uint16(32391), + 135: uint16(32392), + 136: uint16(32395), + 137: uint16(32390), + 138: uint16(32397), + 139: uint16(32589), + 140: uint16(32699), + 141: uint16(32816), + 142: uint16(33245), + 143: uint16(34328), + 144: uint16(34346), + 145: uint16(34342), + 146: uint16(34335), + 147: uint16(34339), + 148: uint16(34332), + 149: uint16(34329), + 150: uint16(34343), + 151: uint16(34350), + 152: uint16(34337), + 153: uint16(34336), + 154: uint16(34345), + 155: uint16(34334), + 156: uint16(34341), + }, + 85: { + 0: uint16(34857), + 1: uint16(34845), + 2: uint16(34843), + 3: uint16(34848), + 4: uint16(34852), + 5: uint16(34844), + 6: uint16(34859), + 7: uint16(34890), + 8: uint16(35181), + 9: uint16(35177), + 10: uint16(35182), + 11: uint16(35179), + 12: uint16(35322), + 13: uint16(35705), + 14: uint16(35704), + 15: uint16(35653), + 16: uint16(35706), + 17: uint16(35707), + 18: uint16(36112), + 19: uint16(36116), + 20: uint16(36271), + 21: uint16(36494), + 22: uint16(36492), + 23: uint16(36702), + 24: uint16(36699), + 25: uint16(36701), + 26: uint16(37190), + 27: uint16(37188), + 28: uint16(37189), + 29: uint16(37305), + 30: uint16(37951), + 31: uint16(37947), + 32: uint16(37942), + 33: uint16(37929), + 34: uint16(37949), + 35: uint16(37948), + 36: uint16(37936), + 37: uint16(37945), + 38: uint16(37930), + 39: uint16(37943), + 40: uint16(37932), + 41: uint16(37952), + 42: uint16(37937), + 43: uint16(38373), + 44: uint16(38372), + 45: uint16(38371), + 46: uint16(38709), + 47: uint16(38714), + 48: uint16(38847), + 49: uint16(38881), + 50: uint16(39012), + 51: uint16(39113), + 52: uint16(39110), + 53: uint16(39104), + 54: uint16(39256), + 55: uint16(39254), + 56: uint16(39481), + 57: uint16(39485), + 58: uint16(39494), + 59: uint16(39492), + 60: uint16(39490), + 61: uint16(39489), + 62: uint16(39482), + 63: uint16(39487), + 64: uint16(39629), + 65: uint16(39701), + 66: uint16(39703), + 67: uint16(39704), + 68: uint16(39702), + 69: uint16(39738), + 70: uint16(39762), + 71: uint16(39979), + 72: uint16(39965), + 73: uint16(39964), + 74: uint16(39980), + 75: uint16(39971), + 76: uint16(39976), + 77: uint16(39977), + 78: uint16(39972), + 79: uint16(39969), + 80: uint16(40375), + 81: uint16(40374), + 82: uint16(40380), + 83: uint16(40385), + 84: uint16(40391), + 85: uint16(40394), + 86: uint16(40399), + 87: uint16(40382), + 88: uint16(40389), + 89: uint16(40387), + 90: uint16(40379), + 91: uint16(40373), + 92: uint16(40398), + 93: uint16(40377), + 94: uint16(40378), + 95: uint16(40364), + 96: uint16(40392), + 97: uint16(40369), + 98: uint16(40365), + 99: uint16(40396), + 100: uint16(40371), + 101: uint16(40397), + 102: uint16(40370), + 103: uint16(40570), + 104: uint16(40604), + 105: uint16(40683), + 106: uint16(40686), + 107: uint16(40685), + 108: uint16(40731), + 109: uint16(40728), + 110: uint16(40730), + 111: uint16(40753), + 112: uint16(40782), + 113: uint16(40805), + 114: uint16(40804), + 115: uint16(40850), + 116: uint16(20153), + 117: uint16(22214), + 118: uint16(22213), + 119: uint16(22219), + 120: uint16(22897), + 121: uint16(23371), + 122: uint16(23372), + 123: uint16(24021), + 124: uint16(24017), + 125: uint16(24306), + 126: uint16(25889), + 127: uint16(25888), + 128: uint16(25894), + 129: uint16(25890), + 130: uint16(27403), + 131: uint16(27400), + 132: uint16(27401), + 133: uint16(27661), + 134: uint16(28757), + 135: uint16(28758), + 136: uint16(28759), + 137: uint16(28754), + 138: uint16(29214), + 139: uint16(29215), + 140: uint16(29353), + 141: uint16(29567), + 142: uint16(29912), + 143: uint16(29909), + 144: uint16(29913), + 145: uint16(29911), + 146: uint16(30317), + 147: uint16(30381), + 148: uint16(31029), + 149: uint16(31156), + 150: uint16(31344), + 151: uint16(31345), + 152: uint16(31831), + 153: uint16(31836), + 154: uint16(31833), + 155: uint16(31835), + 156: uint16(31834), + }, + 86: { + 0: uint16(31988), + 1: uint16(31985), + 2: uint16(32401), + 3: uint16(32591), + 4: uint16(32647), + 5: uint16(33246), + 6: uint16(33387), + 7: uint16(34356), + 8: uint16(34357), + 9: uint16(34355), + 10: uint16(34348), + 11: uint16(34354), + 12: uint16(34358), + 13: uint16(34860), + 14: uint16(34856), + 15: uint16(34854), + 16: uint16(34858), + 17: uint16(34853), + 18: uint16(35185), + 19: uint16(35263), + 20: uint16(35262), + 21: uint16(35323), + 22: uint16(35710), + 23: uint16(35716), + 24: uint16(35714), + 25: uint16(35718), + 26: uint16(35717), + 27: uint16(35711), + 28: uint16(36117), + 29: uint16(36501), + 30: uint16(36500), + 31: uint16(36506), + 32: uint16(36498), + 33: uint16(36496), + 34: uint16(36502), + 35: uint16(36503), + 36: uint16(36704), + 37: uint16(36706), + 38: uint16(37191), + 39: uint16(37964), + 40: uint16(37968), + 41: uint16(37962), + 42: uint16(37963), + 43: uint16(37967), + 44: uint16(37959), + 45: uint16(37957), + 46: uint16(37960), + 47: uint16(37961), + 48: uint16(37958), + 49: uint16(38719), + 50: uint16(38883), + 51: uint16(39018), + 52: uint16(39017), + 53: uint16(39115), + 54: uint16(39252), + 55: uint16(39259), + 56: uint16(39502), + 57: uint16(39507), + 58: uint16(39508), + 59: uint16(39500), + 60: uint16(39503), + 61: uint16(39496), + 62: uint16(39498), + 63: uint16(39497), + 64: uint16(39506), + 65: uint16(39504), + 66: uint16(39632), + 67: uint16(39705), + 68: uint16(39723), + 69: uint16(39739), + 70: uint16(39766), + 71: uint16(39765), + 72: uint16(40006), + 73: uint16(40008), + 74: uint16(39999), + 75: uint16(40004), + 76: uint16(39993), + 77: uint16(39987), + 78: uint16(40001), + 79: uint16(39996), + 80: uint16(39991), + 81: uint16(39988), + 82: uint16(39986), + 83: uint16(39997), + 84: uint16(39990), + 85: uint16(40411), + 86: uint16(40402), + 87: uint16(40414), + 88: uint16(40410), + 89: uint16(40395), + 90: uint16(40400), + 91: uint16(40412), + 92: uint16(40401), + 93: uint16(40415), + 94: uint16(40425), + 95: uint16(40409), + 96: uint16(40408), + 97: uint16(40406), + 98: uint16(40437), + 99: uint16(40405), + 100: uint16(40413), + 101: uint16(40630), + 102: uint16(40688), + 103: uint16(40757), + 104: uint16(40755), + 105: uint16(40754), + 106: uint16(40770), + 107: uint16(40811), + 108: uint16(40853), + 109: uint16(40866), + 110: uint16(20797), + 111: uint16(21145), + 112: uint16(22760), + 113: uint16(22759), + 114: uint16(22898), + 115: uint16(23373), + 116: uint16(24024), + 117: uint16(34863), + 118: uint16(24399), + 119: uint16(25089), + 120: uint16(25091), + 121: uint16(25092), + 122: uint16(25897), + 123: uint16(25893), + 124: uint16(26006), + 125: uint16(26347), + 126: uint16(27409), + 127: uint16(27410), + 128: uint16(27407), + 129: uint16(27594), + 130: uint16(28763), + 131: uint16(28762), + 132: uint16(29218), + 133: uint16(29570), + 134: uint16(29569), + 135: uint16(29571), + 136: uint16(30320), + 137: uint16(30676), + 138: uint16(31847), + 139: uint16(31846), + 140: uint16(32405), + 141: uint16(33388), + 142: uint16(34362), + 143: uint16(34368), + 144: uint16(34361), + 145: uint16(34364), + 146: uint16(34353), + 147: uint16(34363), + 148: uint16(34366), + 149: uint16(34864), + 150: uint16(34866), + 151: uint16(34862), + 152: uint16(34867), + 153: uint16(35190), + 154: uint16(35188), + 155: uint16(35187), + 156: uint16(35326), + }, + 87: { + 0: uint16(35724), + 1: uint16(35726), + 2: uint16(35723), + 3: uint16(35720), + 4: uint16(35909), + 5: uint16(36121), + 6: uint16(36504), + 7: uint16(36708), + 8: uint16(36707), + 9: uint16(37308), + 10: uint16(37986), + 11: uint16(37973), + 12: uint16(37981), + 13: uint16(37975), + 14: uint16(37982), + 15: uint16(38852), + 16: uint16(38853), + 17: uint16(38912), + 18: uint16(39510), + 19: uint16(39513), + 20: uint16(39710), + 21: uint16(39711), + 22: uint16(39712), + 23: uint16(40018), + 24: uint16(40024), + 25: uint16(40016), + 26: uint16(40010), + 27: uint16(40013), + 28: uint16(40011), + 29: uint16(40021), + 30: uint16(40025), + 31: uint16(40012), + 32: uint16(40014), + 33: uint16(40443), + 34: uint16(40439), + 35: uint16(40431), + 36: uint16(40419), + 37: uint16(40427), + 38: uint16(40440), + 39: uint16(40420), + 40: uint16(40438), + 41: uint16(40417), + 42: uint16(40430), + 43: uint16(40422), + 44: uint16(40434), + 45: uint16(40432), + 46: uint16(40418), + 47: uint16(40428), + 48: uint16(40436), + 49: uint16(40435), + 50: uint16(40424), + 51: uint16(40429), + 52: uint16(40642), + 53: uint16(40656), + 54: uint16(40690), + 55: uint16(40691), + 56: uint16(40710), + 57: uint16(40732), + 58: uint16(40760), + 59: uint16(40759), + 60: uint16(40758), + 61: uint16(40771), + 62: uint16(40783), + 63: uint16(40817), + 64: uint16(40816), + 65: uint16(40814), + 66: uint16(40815), + 67: uint16(22227), + 68: uint16(22221), + 69: uint16(23374), + 70: uint16(23661), + 71: uint16(25901), + 72: uint16(26349), + 73: uint16(26350), + 74: uint16(27411), + 75: uint16(28767), + 76: uint16(28769), + 77: uint16(28765), + 78: uint16(28768), + 79: uint16(29219), + 80: uint16(29915), + 81: uint16(29925), + 82: uint16(30677), + 83: uint16(31032), + 84: uint16(31159), + 85: uint16(31158), + 86: uint16(31850), + 87: uint16(32407), + 88: uint16(32649), + 89: uint16(33389), + 90: uint16(34371), + 91: uint16(34872), + 92: uint16(34871), + 93: uint16(34869), + 94: uint16(34891), + 95: uint16(35732), + 96: uint16(35733), + 97: uint16(36510), + 98: uint16(36511), + 99: uint16(36512), + 100: uint16(36509), + 101: uint16(37310), + 102: uint16(37309), + 103: uint16(37314), + 104: uint16(37995), + 105: uint16(37992), + 106: uint16(37993), + 107: uint16(38629), + 108: uint16(38726), + 109: uint16(38723), + 110: uint16(38727), + 111: uint16(38855), + 112: uint16(38885), + 113: uint16(39518), + 114: uint16(39637), + 115: uint16(39769), + 116: uint16(40035), + 117: uint16(40039), + 118: uint16(40038), + 119: uint16(40034), + 120: uint16(40030), + 121: uint16(40032), + 122: uint16(40450), + 123: uint16(40446), + 124: uint16(40455), + 125: uint16(40451), + 126: uint16(40454), + 127: uint16(40453), + 128: uint16(40448), + 129: uint16(40449), + 130: uint16(40457), + 131: uint16(40447), + 132: uint16(40445), + 133: uint16(40452), + 134: uint16(40608), + 135: uint16(40734), + 136: uint16(40774), + 137: uint16(40820), + 138: uint16(40821), + 139: uint16(40822), + 140: uint16(22228), + 141: uint16(25902), + 142: uint16(26040), + 143: uint16(27416), + 144: uint16(27417), + 145: uint16(27415), + 146: uint16(27418), + 147: uint16(28770), + 148: uint16(29222), + 149: uint16(29354), + 150: uint16(30680), + 151: uint16(30681), + 152: uint16(31033), + 153: uint16(31849), + 154: uint16(31851), + 155: uint16(31990), + 156: uint16(32410), + }, + 88: { + 0: uint16(32408), + 1: uint16(32411), + 2: uint16(32409), + 3: uint16(33248), + 4: uint16(33249), + 5: uint16(34374), + 6: uint16(34375), + 7: uint16(34376), + 8: uint16(35193), + 9: uint16(35194), + 10: uint16(35196), + 11: uint16(35195), + 12: uint16(35327), + 13: uint16(35736), + 14: uint16(35737), + 15: uint16(36517), + 16: uint16(36516), + 17: uint16(36515), + 18: uint16(37998), + 19: uint16(37997), + 20: uint16(37999), + 21: uint16(38001), + 22: uint16(38003), + 23: uint16(38729), + 24: uint16(39026), + 25: uint16(39263), + 26: uint16(40040), + 27: uint16(40046), + 28: uint16(40045), + 29: uint16(40459), + 30: uint16(40461), + 31: uint16(40464), + 32: uint16(40463), + 33: uint16(40466), + 34: uint16(40465), + 35: uint16(40609), + 36: uint16(40693), + 37: uint16(40713), + 38: uint16(40775), + 39: uint16(40824), + 40: uint16(40827), + 41: uint16(40826), + 42: uint16(40825), + 43: uint16(22302), + 44: uint16(28774), + 45: uint16(31855), + 46: uint16(34876), + 47: uint16(36274), + 48: uint16(36518), + 49: uint16(37315), + 50: uint16(38004), + 51: uint16(38008), + 52: uint16(38006), + 53: uint16(38005), + 54: uint16(39520), + 55: uint16(40052), + 56: uint16(40051), + 57: uint16(40049), + 58: uint16(40053), + 59: uint16(40468), + 60: uint16(40467), + 61: uint16(40694), + 62: uint16(40714), + 63: uint16(40868), + 64: uint16(28776), + 65: uint16(28773), + 66: uint16(31991), + 67: uint16(34410), + 68: uint16(34878), + 69: uint16(34877), + 70: uint16(34879), + 71: uint16(35742), + 72: uint16(35996), + 73: uint16(36521), + 74: uint16(36553), + 75: uint16(38731), + 76: uint16(39027), + 77: uint16(39028), + 78: uint16(39116), + 79: uint16(39265), + 80: uint16(39339), + 81: uint16(39524), + 82: uint16(39526), + 83: uint16(39527), + 84: uint16(39716), + 85: uint16(40469), + 86: uint16(40471), + 87: uint16(40776), + 88: uint16(25095), + 89: uint16(27422), + 90: uint16(29223), + 91: uint16(34380), + 92: uint16(36520), + 93: uint16(38018), + 94: uint16(38016), + 95: uint16(38017), + 96: uint16(39529), + 97: uint16(39528), + 98: uint16(39726), + 99: uint16(40473), + 100: uint16(29225), + 101: uint16(34379), + 102: uint16(35743), + 103: uint16(38019), + 104: uint16(40057), + 105: uint16(40631), + 106: uint16(30325), + 107: uint16(39531), + 108: uint16(40058), + 109: uint16(40477), + 110: uint16(28777), + 111: uint16(28778), + 112: uint16(40612), + 113: uint16(40830), + 114: uint16(40777), + 115: uint16(40856), + 116: uint16(30849), + 117: uint16(37561), + 118: uint16(35023), + 119: uint16(22715), + 120: uint16(24658), + 121: uint16(31911), + 122: uint16(23290), + 123: uint16(9556), + 124: uint16(9574), + 125: uint16(9559), + 126: uint16(9568), + 127: uint16(9580), + 128: uint16(9571), + 129: uint16(9562), + 130: uint16(9577), + 131: uint16(9565), + 132: uint16(9554), + 133: uint16(9572), + 134: uint16(9557), + 135: uint16(9566), + 136: uint16(9578), + 137: uint16(9569), + 138: uint16(9560), + 139: uint16(9575), + 140: uint16(9563), + 141: uint16(9555), + 142: uint16(9573), + 143: uint16(9558), + 144: uint16(9567), + 145: uint16(9579), + 146: uint16(9570), + 147: uint16(9561), + 148: uint16(9576), + 149: uint16(9564), + 150: uint16(9553), + 151: uint16(9552), + 152: uint16(9581), + 153: uint16(9582), + 154: uint16(9584), + 155: uint16(9583), + 156: uint16(9619), + }, +} + +var _hkscs = [5172]uint16{ + 0: uint16(17392), + 1: uint16(19506), + 2: uint16(17923), + 3: uint16(17830), + 4: uint16(17784), + 5: uint16(29287), + 6: uint16(19831), + 7: uint16(17843), + 8: uint16(31921), + 9: uint16(19682), + 10: uint16(31941), + 11: uint16(15253), + 12: uint16(18230), + 13: uint16(18244), + 14: uint16(19527), + 15: uint16(19520), + 16: uint16(17087), + 17: uint16(13847), + 18: uint16(29522), + 19: uint16(28299), + 20: uint16(28882), + 21: uint16(19543), + 22: uint16(41809), + 23: uint16(18255), + 24: uint16(17882), + 25: uint16(19589), + 26: uint16(31852), + 27: uint16(19719), + 28: uint16(19108), + 29: uint16(18081), + 30: uint16(27427), + 31: uint16(29221), + 32: uint16(23124), + 33: uint16(6755), + 34: uint16(15878), + 35: uint16(16225), + 36: uint16(26189), + 37: uint16(22267), + 39: uint16(32149), + 40: uint16(22813), + 41: uint16(35769), + 42: uint16(15860), + 43: uint16(38708), + 44: uint16(31727), + 45: uint16(23515), + 46: uint16(7518), + 47: uint16(23204), + 48: uint16(13861), + 49: uint16(40624), + 50: uint16(23249), + 51: uint16(23479), + 52: uint16(23804), + 53: uint16(26478), + 54: uint16(34195), + 55: uint16(39237), + 56: uint16(29793), + 57: uint16(29853), + 58: uint16(14453), + 59: uint16(7507), + 60: uint16(13982), + 61: uint16(24609), + 62: uint16(16108), + 63: uint16(22750), + 64: uint16(15093), + 65: uint16(31484), + 66: uint16(40855), + 67: uint16(16737), + 68: uint16(35085), + 69: uint16(12778), + 70: uint16(2698), + 71: uint16(12894), + 72: uint16(17162), + 73: uint16(33924), + 74: uint16(40854), + 75: uint16(37935), + 76: uint16(18736), + 77: uint16(34323), + 78: uint16(22678), + 79: uint16(38730), + 80: uint16(37400), + 81: uint16(31184), + 82: uint16(31282), + 83: uint16(26208), + 84: uint16(27177), + 85: uint16(34973), + 86: uint16(29772), + 87: uint16(31685), + 88: uint16(26498), + 89: uint16(31276), + 90: uint16(21071), + 91: uint16(36934), + 92: uint16(13542), + 93: uint16(29636), + 94: uint16(23993), + 95: uint16(29894), + 96: uint16(40903), + 97: uint16(22451), + 98: uint16(18735), + 99: uint16(21580), + 100: uint16(16689), + 101: uint16(13966), + 102: uint16(22552), + 103: uint16(31346), + 104: uint16(31589), + 105: uint16(35727), + 106: uint16(18094), + 107: uint16(28296), + 108: uint16(16769), + 109: uint16(23961), + 110: uint16(31662), + 111: uint16(9404), + 112: uint16(40904), + 113: uint16(9409), + 114: uint16(9417), + 115: uint16(9420), + 116: uint16(40905), + 117: uint16(34052), + 118: uint16(13755), + 119: uint16(16564), + 120: uint16(40906), + 121: uint16(17633), + 122: uint16(44543), + 123: uint16(25281), + 124: uint16(28782), + 125: uint16(40907), + 157: uint16(12736), + 158: uint16(12737), + 159: uint16(12738), + 160: uint16(12739), + 161: uint16(12740), + 162: uint16(268), + 163: uint16(12741), + 164: uint16(209), + 165: uint16(205), + 166: uint16(12742), + 167: uint16(12743), + 168: uint16(203), + 169: uint16(8168), + 170: uint16(12744), + 171: uint16(202), + 172: uint16(12745), + 173: uint16(12746), + 174: uint16(12747), + 175: uint16(12748), + 176: uint16(270), + 177: uint16(12749), + 178: uint16(12750), + 179: uint16(256), + 180: uint16(193), + 181: uint16(461), + 182: uint16(192), + 183: uint16(274), + 184: uint16(201), + 185: uint16(282), + 186: uint16(200), + 187: uint16(332), + 188: uint16(211), + 189: uint16(465), + 190: uint16(210), + 191: uint16(56320), + 192: uint16(7870), + 193: uint16(56324), + 194: uint16(7872), + 195: uint16(202), + 196: uint16(257), + 197: uint16(225), + 198: uint16(462), + 199: uint16(224), + 200: uint16(593), + 201: uint16(275), + 202: uint16(233), + 203: uint16(283), + 204: uint16(232), + 205: uint16(299), + 206: uint16(237), + 207: uint16(464), + 208: uint16(236), + 209: uint16(333), + 210: uint16(243), + 211: uint16(466), + 212: uint16(242), + 213: uint16(363), + 214: uint16(250), + 215: uint16(468), + 216: uint16(249), + 217: uint16(470), + 218: uint16(472), + 219: uint16(474), + 220: uint16(476), + 221: uint16(252), + 222: uint16(56328), + 223: uint16(7871), + 224: uint16(56332), + 225: uint16(7873), + 226: uint16(234), + 227: uint16(609), + 228: uint16(9178), + 229: uint16(9179), + 314: uint16(41897), + 315: uint16(4421), + 317: uint16(25866), + 320: uint16(20029), + 321: uint16(28381), + 322: uint16(40270), + 323: uint16(37343), + 326: uint16(30517), + 327: uint16(25745), + 328: uint16(20250), + 329: uint16(20264), + 330: uint16(20392), + 331: uint16(20822), + 332: uint16(20852), + 333: uint16(20892), + 334: uint16(20964), + 335: uint16(21153), + 336: uint16(21160), + 337: uint16(21307), + 338: uint16(21326), + 339: uint16(21457), + 340: uint16(21464), + 341: uint16(22242), + 342: uint16(22768), + 343: uint16(22788), + 344: uint16(22791), + 345: uint16(22834), + 346: uint16(22836), + 347: uint16(23398), + 348: uint16(23454), + 349: uint16(23455), + 350: uint16(23706), + 351: uint16(24198), + 352: uint16(24635), + 353: uint16(25993), + 354: uint16(26622), + 355: uint16(26628), + 356: uint16(26725), + 357: uint16(27982), + 358: uint16(28860), + 359: uint16(30005), + 360: uint16(32420), + 361: uint16(32428), + 362: uint16(32442), + 363: uint16(32455), + 364: uint16(32463), + 365: uint16(32479), + 366: uint16(32518), + 367: uint16(32567), + 368: uint16(33402), + 369: uint16(33487), + 370: uint16(33647), + 371: uint16(35270), + 372: uint16(35774), + 373: uint16(35810), + 374: uint16(36710), + 375: uint16(36711), + 376: uint16(36718), + 377: uint16(29713), + 378: uint16(31996), + 379: uint16(32205), + 380: uint16(26950), + 381: uint16(31433), + 382: uint16(21031), + 387: uint16(37260), + 388: uint16(30904), + 389: uint16(37214), + 390: uint16(32956), + 392: uint16(36107), + 393: uint16(33014), + 394: uint16(2535), + 397: uint16(32927), + 398: uint16(40647), + 399: uint16(19661), + 400: uint16(40393), + 401: uint16(40460), + 402: uint16(19518), + 403: uint16(40438), + 404: uint16(28686), + 405: uint16(40458), + 406: uint16(41267), + 407: uint16(13761), + 409: uint16(28314), + 410: uint16(33342), + 411: uint16(29977), + 413: uint16(18705), + 414: uint16(39532), + 415: uint16(39567), + 416: uint16(40857), + 417: uint16(31111), + 418: uint16(33900), + 419: uint16(7626), + 420: uint16(1488), + 421: uint16(10982), + 422: uint16(20004), + 423: uint16(20097), + 424: uint16(20096), + 425: uint16(20103), + 426: uint16(20159), + 427: uint16(20203), + 428: uint16(20279), + 429: uint16(13388), + 430: uint16(20413), + 431: uint16(15944), + 432: uint16(20483), + 433: uint16(20616), + 434: uint16(13437), + 435: uint16(13459), + 436: uint16(13477), + 437: uint16(20870), + 438: uint16(22789), + 439: uint16(20955), + 440: uint16(20988), + 441: uint16(20997), + 442: uint16(20105), + 443: uint16(21113), + 444: uint16(21136), + 445: uint16(21287), + 446: uint16(13767), + 447: uint16(21417), + 448: uint16(13649), + 449: uint16(21424), + 450: uint16(13651), + 451: uint16(21442), + 452: uint16(21539), + 453: uint16(13677), + 454: uint16(13682), + 455: uint16(13953), + 456: uint16(21651), + 457: uint16(21667), + 458: uint16(21684), + 459: uint16(21689), + 460: uint16(21712), + 461: uint16(21743), + 462: uint16(21784), + 463: uint16(21795), + 464: uint16(21800), + 465: uint16(13720), + 466: uint16(21823), + 467: uint16(13733), + 468: uint16(13759), + 469: uint16(21975), + 470: uint16(13765), + 471: uint16(32132), + 472: uint16(21797), + 474: uint16(3138), + 475: uint16(3349), + 476: uint16(20779), + 477: uint16(21904), + 478: uint16(11462), + 479: uint16(14828), + 480: uint16(833), + 481: uint16(36422), + 482: uint16(19896), + 483: uint16(38117), + 484: uint16(16467), + 485: uint16(32958), + 486: uint16(30586), + 487: uint16(11320), + 488: uint16(14900), + 489: uint16(18389), + 490: uint16(33117), + 491: uint16(27122), + 492: uint16(19946), + 493: uint16(25821), + 494: uint16(3452), + 495: uint16(4020), + 496: uint16(3285), + 497: uint16(4340), + 498: uint16(25741), + 499: uint16(36478), + 500: uint16(3734), + 501: uint16(3083), + 502: uint16(3940), + 503: uint16(11433), + 504: uint16(33366), + 505: uint16(17619), + 507: uint16(3398), + 508: uint16(39501), + 509: uint16(33001), + 510: uint16(18420), + 511: uint16(20135), + 512: uint16(11458), + 513: uint16(39602), + 514: uint16(14951), + 515: uint16(38388), + 516: uint16(16365), + 517: uint16(13574), + 518: uint16(21191), + 519: uint16(38868), + 520: uint16(30920), + 521: uint16(11588), + 522: uint16(40302), + 523: uint16(38933), + 525: uint16(17369), + 526: uint16(24741), + 527: uint16(25780), + 528: uint16(21731), + 529: uint16(11596), + 530: uint16(11210), + 531: uint16(4215), + 532: uint16(14843), + 533: uint16(4207), + 534: uint16(26330), + 535: uint16(26390), + 536: uint16(31136), + 537: uint16(25834), + 538: uint16(20562), + 539: uint16(3139), + 540: uint16(36456), + 541: uint16(8609), + 542: uint16(35660), + 543: uint16(1841), + 545: uint16(18443), + 546: uint16(425), + 547: uint16(16378), + 548: uint16(22643), + 549: uint16(11661), + 551: uint16(17864), + 552: uint16(1276), + 553: uint16(24727), + 554: uint16(3916), + 555: uint16(3478), + 556: uint16(21881), + 557: uint16(16571), + 558: uint16(17338), + 560: uint16(19124), + 561: uint16(10854), + 562: uint16(4253), + 563: uint16(33194), + 564: uint16(39157), + 565: uint16(3484), + 566: uint16(25465), + 567: uint16(14846), + 568: uint16(10101), + 569: uint16(36288), + 570: uint16(22177), + 571: uint16(25724), + 572: uint16(15939), + 574: uint16(42497), + 575: uint16(3593), + 576: uint16(10959), + 577: uint16(11465), + 579: uint16(4296), + 580: uint16(14786), + 581: uint16(14738), + 582: uint16(14854), + 583: uint16(33435), + 584: uint16(13688), + 585: uint16(24137), + 586: uint16(8391), + 587: uint16(22098), + 588: uint16(3889), + 589: uint16(11442), + 590: uint16(38688), + 591: uint16(13500), + 592: uint16(27709), + 593: uint16(20027), + 596: uint16(30068), + 597: uint16(11915), + 598: uint16(8712), + 599: uint16(42587), + 600: uint16(36045), + 601: uint16(3706), + 602: uint16(3124), + 603: uint16(26652), + 604: uint16(32659), + 605: uint16(4303), + 606: uint16(10243), + 607: uint16(10553), + 608: uint16(13819), + 609: uint16(20963), + 610: uint16(3724), + 611: uint16(3981), + 612: uint16(3754), + 613: uint16(16275), + 614: uint16(3888), + 615: uint16(3399), + 616: uint16(4431), + 617: uint16(3660), + 619: uint16(3755), + 620: uint16(2985), + 621: uint16(3400), + 622: uint16(4288), + 623: uint16(4413), + 624: uint16(16377), + 625: uint16(9878), + 626: uint16(25650), + 627: uint16(4013), + 628: uint16(13300), + 629: uint16(30265), + 630: uint16(11214), + 631: uint16(3454), + 632: uint16(3455), + 633: uint16(11345), + 634: uint16(11349), + 635: uint16(14872), + 636: uint16(3736), + 637: uint16(4295), + 638: uint16(3886), + 639: uint16(42546), + 640: uint16(27472), + 641: uint16(36050), + 642: uint16(36249), + 643: uint16(36042), + 644: uint16(38314), + 645: uint16(21708), + 646: uint16(33476), + 647: uint16(21945), + 649: uint16(40643), + 650: uint16(39974), + 651: uint16(39606), + 652: uint16(30558), + 653: uint16(11758), + 654: uint16(28992), + 655: uint16(33133), + 656: uint16(33004), + 657: uint16(23580), + 658: uint16(25970), + 659: uint16(33076), + 660: uint16(14231), + 661: uint16(21343), + 662: uint16(32957), + 663: uint16(37302), + 664: uint16(3834), + 665: uint16(3599), + 666: uint16(3703), + 667: uint16(3835), + 668: uint16(13789), + 669: uint16(19947), + 670: uint16(13833), + 671: uint16(3286), + 672: uint16(22191), + 673: uint16(10165), + 674: uint16(4297), + 675: uint16(3600), + 676: uint16(3704), + 677: uint16(4216), + 678: uint16(4424), + 679: uint16(33287), + 680: uint16(5205), + 681: uint16(3705), + 682: uint16(20048), + 683: uint16(11684), + 684: uint16(23124), + 685: uint16(4125), + 686: uint16(4126), + 687: uint16(4341), + 688: uint16(4342), + 689: uint16(22428), + 690: uint16(3601), + 691: uint16(30356), + 692: uint16(33485), + 693: uint16(4021), + 694: uint16(3707), + 695: uint16(20862), + 696: uint16(14083), + 697: uint16(4022), + 698: uint16(4480), + 699: uint16(21208), + 700: uint16(41661), + 701: uint16(18906), + 702: uint16(6202), + 703: uint16(16759), + 704: uint16(33404), + 705: uint16(22681), + 706: uint16(21096), + 707: uint16(13850), + 708: uint16(22333), + 709: uint16(31666), + 710: uint16(23400), + 711: uint16(18432), + 712: uint16(19244), + 713: uint16(40743), + 714: uint16(18919), + 715: uint16(39967), + 716: uint16(39821), + 717: uint16(23412), + 718: uint16(12605), + 719: uint16(22011), + 720: uint16(13810), + 721: uint16(22153), + 722: uint16(20008), + 723: uint16(22786), + 724: uint16(7105), + 725: uint16(63608), + 726: uint16(38737), + 727: uint16(134), + 728: uint16(20059), + 729: uint16(20155), + 730: uint16(13630), + 731: uint16(23587), + 732: uint16(24401), + 733: uint16(24516), + 734: uint16(14586), + 735: uint16(25164), + 736: uint16(25909), + 737: uint16(27514), + 738: uint16(27701), + 739: uint16(27706), + 740: uint16(28780), + 741: uint16(29227), + 742: uint16(20012), + 743: uint16(29357), + 744: uint16(18665), + 745: uint16(32594), + 746: uint16(31035), + 747: uint16(31993), + 748: uint16(32595), + 749: uint16(25194), + 750: uint16(13505), + 752: uint16(25419), + 753: uint16(32770), + 754: uint16(32896), + 755: uint16(26130), + 756: uint16(26961), + 757: uint16(21341), + 758: uint16(34916), + 759: uint16(35265), + 760: uint16(30898), + 761: uint16(35744), + 762: uint16(36125), + 763: uint16(38021), + 764: uint16(38264), + 765: uint16(38271), + 766: uint16(38376), + 767: uint16(36367), + 768: uint16(38886), + 769: uint16(39029), + 770: uint16(39118), + 771: uint16(39134), + 772: uint16(39267), + 773: uint16(38928), + 774: uint16(40060), + 775: uint16(40479), + 776: uint16(40644), + 777: uint16(27503), + 778: uint16(63751), + 779: uint16(20023), + 780: uint16(135), + 781: uint16(38429), + 782: uint16(25143), + 783: uint16(38050), + 785: uint16(20539), + 786: uint16(28158), + 787: uint16(40051), + 788: uint16(40870), + 789: uint16(15817), + 790: uint16(34959), + 791: uint16(16718), + 792: uint16(28791), + 793: uint16(23797), + 794: uint16(19232), + 795: uint16(20941), + 796: uint16(13657), + 797: uint16(23856), + 798: uint16(24866), + 799: uint16(35378), + 800: uint16(36775), + 801: uint16(37366), + 802: uint16(29073), + 803: uint16(26393), + 804: uint16(29626), + 805: uint16(12929), + 806: uint16(41223), + 807: uint16(15499), + 808: uint16(6528), + 809: uint16(19216), + 810: uint16(30948), + 811: uint16(29698), + 812: uint16(20910), + 813: uint16(34575), + 814: uint16(16393), + 815: uint16(27235), + 816: uint16(41658), + 817: uint16(16931), + 818: uint16(34319), + 819: uint16(2671), + 820: uint16(31274), + 821: uint16(39239), + 822: uint16(35562), + 823: uint16(38741), + 824: uint16(28749), + 825: uint16(21284), + 826: uint16(8318), + 827: uint16(37876), + 828: uint16(30425), + 829: uint16(35299), + 830: uint16(40871), + 831: uint16(30685), + 832: uint16(20131), + 833: uint16(20464), + 834: uint16(20668), + 835: uint16(20015), + 836: uint16(20247), + 837: uint16(40872), + 838: uint16(21556), + 839: uint16(32139), + 840: uint16(22674), + 841: uint16(22736), + 842: uint16(7606), + 843: uint16(24210), + 844: uint16(24217), + 845: uint16(24514), + 846: uint16(10002), + 847: uint16(25995), + 848: uint16(13305), + 849: uint16(26905), + 850: uint16(27203), + 851: uint16(15459), + 852: uint16(27903), + 854: uint16(29184), + 855: uint16(17669), + 856: uint16(29580), + 857: uint16(16091), + 858: uint16(18963), + 859: uint16(23317), + 860: uint16(29881), + 861: uint16(35715), + 862: uint16(23716), + 863: uint16(22165), + 864: uint16(31379), + 865: uint16(31724), + 866: uint16(31939), + 867: uint16(32364), + 868: uint16(33528), + 869: uint16(34199), + 870: uint16(40873), + 871: uint16(34960), + 872: uint16(40874), + 873: uint16(36537), + 874: uint16(40875), + 875: uint16(36815), + 876: uint16(34143), + 877: uint16(39392), + 878: uint16(37409), + 879: uint16(40876), + 880: uint16(36281), + 881: uint16(5183), + 882: uint16(16497), + 883: uint16(17058), + 884: uint16(23066), + 888: uint16(39016), + 889: uint16(26475), + 890: uint16(17014), + 891: uint16(22333), + 893: uint16(34262), + 894: uint16(18811), + 895: uint16(33471), + 896: uint16(28941), + 897: uint16(19585), + 898: uint16(28020), + 899: uint16(23931), + 900: uint16(27413), + 901: uint16(28606), + 902: uint16(40877), + 903: uint16(40878), + 904: uint16(23446), + 905: uint16(40879), + 906: uint16(26343), + 907: uint16(32347), + 908: uint16(28247), + 909: uint16(31178), + 910: uint16(15752), + 911: uint16(17603), + 912: uint16(12886), + 913: uint16(10134), + 914: uint16(17306), + 915: uint16(17718), + 917: uint16(23765), + 918: uint16(15130), + 919: uint16(35577), + 920: uint16(23672), + 921: uint16(15634), + 922: uint16(13649), + 923: uint16(23928), + 924: uint16(40882), + 925: uint16(29015), + 926: uint16(17752), + 927: uint16(16620), + 928: uint16(7715), + 929: uint16(19575), + 930: uint16(14712), + 931: uint16(13386), + 932: uint16(420), + 933: uint16(27713), + 934: uint16(35532), + 935: uint16(20404), + 936: uint16(569), + 937: uint16(22975), + 938: uint16(33132), + 939: uint16(38998), + 940: uint16(39162), + 941: uint16(24379), + 942: uint16(2975), + 944: uint16(8641), + 945: uint16(35181), + 946: uint16(16642), + 947: uint16(18107), + 948: uint16(36985), + 949: uint16(16135), + 950: uint16(40883), + 951: uint16(41397), + 952: uint16(16632), + 953: uint16(14294), + 954: uint16(18167), + 955: uint16(27718), + 956: uint16(16764), + 957: uint16(34482), + 958: uint16(29695), + 959: uint16(17773), + 960: uint16(14548), + 961: uint16(21658), + 962: uint16(17761), + 963: uint16(17691), + 964: uint16(19849), + 965: uint16(19579), + 966: uint16(19830), + 967: uint16(17898), + 968: uint16(16328), + 969: uint16(19215), + 970: uint16(13921), + 971: uint16(17630), + 972: uint16(17597), + 973: uint16(16877), + 974: uint16(23870), + 975: uint16(23880), + 976: uint16(23894), + 977: uint16(15868), + 978: uint16(14351), + 979: uint16(23972), + 980: uint16(23993), + 981: uint16(14368), + 982: uint16(14392), + 983: uint16(24130), + 984: uint16(24253), + 985: uint16(24357), + 986: uint16(24451), + 987: uint16(14600), + 988: uint16(14612), + 989: uint16(14655), + 990: uint16(14669), + 991: uint16(24791), + 992: uint16(24893), + 993: uint16(23781), + 994: uint16(14729), + 995: uint16(25015), + 996: uint16(25017), + 997: uint16(25039), + 998: uint16(14776), + 999: uint16(25132), + 1000: uint16(25232), + 1001: uint16(25317), + 1002: uint16(25368), + 1003: uint16(14840), + 1004: uint16(22193), + 1005: uint16(14851), + 1006: uint16(25570), + 1007: uint16(25595), + 1008: uint16(25607), + 1009: uint16(25690), + 1010: uint16(14923), + 1011: uint16(25792), + 1012: uint16(23829), + 1013: uint16(22049), + 1014: uint16(40863), + 1015: uint16(14999), + 1016: uint16(25990), + 1017: uint16(15037), + 1018: uint16(26111), + 1019: uint16(26195), + 1020: uint16(15090), + 1021: uint16(26258), + 1022: uint16(15138), + 1023: uint16(26390), + 1024: uint16(15170), + 1025: uint16(26532), + 1026: uint16(26624), + 1027: uint16(15192), + 1028: uint16(26698), + 1029: uint16(26756), + 1030: uint16(15218), + 1031: uint16(15217), + 1032: uint16(15227), + 1033: uint16(26889), + 1034: uint16(26947), + 1035: uint16(29276), + 1036: uint16(26980), + 1037: uint16(27039), + 1038: uint16(27013), + 1039: uint16(15292), + 1040: uint16(27094), + 1041: uint16(15325), + 1042: uint16(27237), + 1043: uint16(27252), + 1044: uint16(27249), + 1045: uint16(27266), + 1046: uint16(15340), + 1047: uint16(27289), + 1048: uint16(15346), + 1049: uint16(27307), + 1050: uint16(27317), + 1051: uint16(27348), + 1052: uint16(27382), + 1053: uint16(27521), + 1054: uint16(27585), + 1055: uint16(27626), + 1056: uint16(27765), + 1057: uint16(27818), + 1058: uint16(15563), + 1059: uint16(27906), + 1060: uint16(27910), + 1061: uint16(27942), + 1062: uint16(28033), + 1063: uint16(15599), + 1064: uint16(28068), + 1065: uint16(28081), + 1066: uint16(28181), + 1067: uint16(28184), + 1068: uint16(28201), + 1069: uint16(28294), + 1070: uint16(35264), + 1071: uint16(28347), + 1072: uint16(28386), + 1073: uint16(28378), + 1074: uint16(40831), + 1075: uint16(28392), + 1076: uint16(28393), + 1077: uint16(28452), + 1078: uint16(28468), + 1079: uint16(15686), + 1080: uint16(16193), + 1081: uint16(28545), + 1082: uint16(28606), + 1083: uint16(15722), + 1084: uint16(15733), + 1085: uint16(29111), + 1086: uint16(23705), + 1087: uint16(15754), + 1088: uint16(28716), + 1089: uint16(15761), + 1090: uint16(28752), + 1091: uint16(28756), + 1092: uint16(28783), + 1093: uint16(28799), + 1094: uint16(28809), + 1095: uint16(805), + 1096: uint16(17345), + 1097: uint16(13809), + 1098: uint16(3800), + 1099: uint16(16087), + 1100: uint16(22462), + 1101: uint16(28371), + 1102: uint16(28990), + 1103: uint16(22496), + 1104: uint16(13902), + 1105: uint16(27042), + 1106: uint16(35817), + 1107: uint16(23412), + 1108: uint16(31305), + 1109: uint16(22753), + 1110: uint16(38105), + 1111: uint16(31333), + 1112: uint16(31357), + 1113: uint16(22956), + 1114: uint16(31419), + 1115: uint16(31408), + 1116: uint16(31426), + 1117: uint16(31427), + 1118: uint16(29137), + 1119: uint16(25741), + 1120: uint16(16842), + 1121: uint16(31450), + 1122: uint16(31453), + 1123: uint16(31466), + 1124: uint16(16879), + 1125: uint16(21682), + 1126: uint16(23553), + 1127: uint16(31499), + 1128: uint16(31573), + 1129: uint16(31529), + 1130: uint16(21262), + 1131: uint16(23806), + 1132: uint16(31650), + 1133: uint16(31599), + 1134: uint16(33692), + 1135: uint16(23476), + 1136: uint16(27775), + 1137: uint16(31696), + 1138: uint16(33825), + 1139: uint16(31634), + 1141: uint16(23840), + 1142: uint16(15789), + 1143: uint16(23653), + 1144: uint16(33938), + 1145: uint16(31738), + 1147: uint16(31797), + 1148: uint16(23745), + 1149: uint16(31812), + 1150: uint16(31875), + 1151: uint16(18562), + 1152: uint16(31910), + 1153: uint16(26237), + 1154: uint16(17784), + 1155: uint16(31945), + 1156: uint16(31943), + 1157: uint16(31974), + 1158: uint16(31860), + 1159: uint16(31987), + 1160: uint16(31989), + 1162: uint16(32359), + 1163: uint16(17693), + 1164: uint16(28228), + 1165: uint16(32093), + 1166: uint16(28374), + 1167: uint16(29837), + 1168: uint16(32137), + 1169: uint16(32171), + 1170: uint16(28981), + 1171: uint16(32179), + 1173: uint16(16471), + 1174: uint16(24617), + 1175: uint16(32228), + 1176: uint16(15635), + 1177: uint16(32245), + 1178: uint16(6137), + 1179: uint16(32229), + 1180: uint16(33645), + 1182: uint16(24865), + 1183: uint16(24922), + 1184: uint16(32366), + 1185: uint16(32402), + 1186: uint16(17195), + 1187: uint16(37996), + 1188: uint16(32295), + 1189: uint16(32576), + 1190: uint16(32577), + 1191: uint16(32583), + 1192: uint16(31030), + 1193: uint16(25296), + 1194: uint16(39393), + 1195: uint16(32663), + 1196: uint16(25425), + 1197: uint16(32675), + 1198: uint16(5729), + 1199: uint16(104), + 1200: uint16(17756), + 1201: uint16(14182), + 1202: uint16(17667), + 1203: uint16(33594), + 1204: uint16(32762), + 1205: uint16(25737), + 1207: uint16(32776), + 1208: uint16(32797), + 1210: uint16(32815), + 1211: uint16(41095), + 1212: uint16(27843), + 1213: uint16(32827), + 1214: uint16(32828), + 1215: uint16(32865), + 1216: uint16(10004), + 1217: uint16(18825), + 1218: uint16(26150), + 1219: uint16(15843), + 1220: uint16(26344), + 1221: uint16(26405), + 1222: uint16(32935), + 1223: uint16(35400), + 1224: uint16(33031), + 1225: uint16(33050), + 1226: uint16(22704), + 1227: uint16(9974), + 1228: uint16(27775), + 1229: uint16(25752), + 1230: uint16(20408), + 1231: uint16(25831), + 1232: uint16(5258), + 1233: uint16(33304), + 1234: uint16(6238), + 1235: uint16(27219), + 1236: uint16(19045), + 1237: uint16(19093), + 1238: uint16(17530), + 1239: uint16(33321), + 1240: uint16(2829), + 1241: uint16(27218), + 1242: uint16(15742), + 1243: uint16(20473), + 1244: uint16(5373), + 1245: uint16(34018), + 1246: uint16(33634), + 1247: uint16(27402), + 1248: uint16(18855), + 1249: uint16(13616), + 1250: uint16(6003), + 1251: uint16(15864), + 1252: uint16(33450), + 1253: uint16(26907), + 1254: uint16(63892), + 1255: uint16(16859), + 1256: uint16(34123), + 1257: uint16(33488), + 1258: uint16(33562), + 1259: uint16(3606), + 1260: uint16(6068), + 1261: uint16(14017), + 1262: uint16(12669), + 1263: uint16(13658), + 1264: uint16(33403), + 1265: uint16(33506), + 1266: uint16(33560), + 1267: uint16(16011), + 1268: uint16(28067), + 1269: uint16(27397), + 1270: uint16(27543), + 1271: uint16(13774), + 1272: uint16(15807), + 1273: uint16(33565), + 1274: uint16(21996), + 1275: uint16(33669), + 1276: uint16(17675), + 1277: uint16(28069), + 1278: uint16(33708), + 1280: uint16(33747), + 1281: uint16(13438), + 1282: uint16(28372), + 1283: uint16(27223), + 1284: uint16(34138), + 1285: uint16(13462), + 1286: uint16(28226), + 1287: uint16(12015), + 1288: uint16(33880), + 1289: uint16(23524), + 1290: uint16(33905), + 1291: uint16(15827), + 1292: uint16(17636), + 1293: uint16(27303), + 1294: uint16(33866), + 1295: uint16(15541), + 1296: uint16(31064), + 1298: uint16(27542), + 1299: uint16(28279), + 1300: uint16(28227), + 1301: uint16(34014), + 1303: uint16(33681), + 1304: uint16(17568), + 1305: uint16(33939), + 1306: uint16(34020), + 1307: uint16(23697), + 1308: uint16(16960), + 1309: uint16(23744), + 1310: uint16(17731), + 1311: uint16(34100), + 1312: uint16(23282), + 1313: uint16(28313), + 1314: uint16(17703), + 1315: uint16(34163), + 1316: uint16(17686), + 1317: uint16(26559), + 1318: uint16(34326), + 1319: uint16(34341), + 1320: uint16(34363), + 1321: uint16(34241), + 1322: uint16(28808), + 1323: uint16(34306), + 1324: uint16(5506), + 1325: uint16(28877), + 1326: uint16(63922), + 1327: uint16(17770), + 1328: uint16(34344), + 1329: uint16(13896), + 1330: uint16(6306), + 1331: uint16(21495), + 1332: uint16(29594), + 1333: uint16(34430), + 1334: uint16(34673), + 1335: uint16(41208), + 1336: uint16(34798), + 1337: uint16(11303), + 1338: uint16(34737), + 1339: uint16(34778), + 1340: uint16(34831), + 1341: uint16(22113), + 1342: uint16(34412), + 1343: uint16(26710), + 1344: uint16(17935), + 1345: uint16(34885), + 1346: uint16(34886), + 1347: uint16(30176), + 1348: uint16(15801), + 1349: uint16(30180), + 1350: uint16(34910), + 1351: uint16(34972), + 1352: uint16(18011), + 1353: uint16(34996), + 1354: uint16(34997), + 1355: uint16(25537), + 1356: uint16(35013), + 1357: uint16(30583), + 1358: uint16(30479), + 1359: uint16(35207), + 1360: uint16(35210), + 1363: uint16(35239), + 1364: uint16(35260), + 1365: uint16(35365), + 1366: uint16(35303), + 1367: uint16(31012), + 1368: uint16(31421), + 1369: uint16(35484), + 1370: uint16(30611), + 1371: uint16(37374), + 1372: uint16(35472), + 1373: uint16(31321), + 1374: uint16(31465), + 1375: uint16(31546), + 1376: uint16(16271), + 1377: uint16(18195), + 1378: uint16(31544), + 1379: uint16(29052), + 1380: uint16(35596), + 1381: uint16(35615), + 1382: uint16(21552), + 1383: uint16(21861), + 1384: uint16(35647), + 1385: uint16(35660), + 1386: uint16(35661), + 1387: uint16(35497), + 1388: uint16(19066), + 1389: uint16(35728), + 1390: uint16(35739), + 1391: uint16(35503), + 1392: uint16(5855), + 1393: uint16(17941), + 1394: uint16(34895), + 1395: uint16(35995), + 1396: uint16(32084), + 1397: uint16(32143), + 1398: uint16(63956), + 1399: uint16(14117), + 1400: uint16(32083), + 1401: uint16(36054), + 1402: uint16(32152), + 1403: uint16(32189), + 1404: uint16(36114), + 1405: uint16(36099), + 1406: uint16(6416), + 1407: uint16(36059), + 1408: uint16(28764), + 1409: uint16(36113), + 1410: uint16(19657), + 1411: uint16(16080), + 1413: uint16(36265), + 1414: uint16(32770), + 1415: uint16(4116), + 1416: uint16(18826), + 1417: uint16(15228), + 1418: uint16(33212), + 1419: uint16(28940), + 1420: uint16(31463), + 1421: uint16(36525), + 1422: uint16(36534), + 1423: uint16(36547), + 1424: uint16(37588), + 1425: uint16(36633), + 1426: uint16(36653), + 1427: uint16(33637), + 1428: uint16(33810), + 1429: uint16(36773), + 1430: uint16(37635), + 1431: uint16(41631), + 1432: uint16(2640), + 1433: uint16(36787), + 1434: uint16(18730), + 1435: uint16(35294), + 1436: uint16(34109), + 1437: uint16(15803), + 1438: uint16(24312), + 1439: uint16(12898), + 1440: uint16(36857), + 1441: uint16(40980), + 1442: uint16(34492), + 1443: uint16(34049), + 1444: uint16(8997), + 1445: uint16(14720), + 1446: uint16(28375), + 1447: uint16(36919), + 1448: uint16(34108), + 1449: uint16(31422), + 1450: uint16(36961), + 1451: uint16(34156), + 1452: uint16(34315), + 1453: uint16(37032), + 1454: uint16(34579), + 1455: uint16(37060), + 1456: uint16(34534), + 1457: uint16(37038), + 1459: uint16(37223), + 1460: uint16(15088), + 1461: uint16(37289), + 1462: uint16(37316), + 1463: uint16(31916), + 1464: uint16(35123), + 1465: uint16(7817), + 1466: uint16(37390), + 1467: uint16(27807), + 1468: uint16(37441), + 1469: uint16(37474), + 1470: uint16(21945), + 1472: uint16(35526), + 1473: uint16(15515), + 1474: uint16(35596), + 1475: uint16(21979), + 1476: uint16(3377), + 1477: uint16(37676), + 1478: uint16(37739), + 1479: uint16(35553), + 1480: uint16(35819), + 1481: uint16(28815), + 1482: uint16(23235), + 1483: uint16(35554), + 1484: uint16(35557), + 1485: uint16(18789), + 1486: uint16(37444), + 1487: uint16(35820), + 1488: uint16(35897), + 1489: uint16(35839), + 1490: uint16(37747), + 1491: uint16(37979), + 1492: uint16(36540), + 1493: uint16(38277), + 1494: uint16(38310), + 1495: uint16(37926), + 1496: uint16(38304), + 1497: uint16(28662), + 1498: uint16(17081), + 1499: uint16(9850), + 1500: uint16(34520), + 1501: uint16(4732), + 1502: uint16(15918), + 1503: uint16(18911), + 1504: uint16(27676), + 1505: uint16(38523), + 1506: uint16(38550), + 1507: uint16(16748), + 1508: uint16(38563), + 1509: uint16(28373), + 1510: uint16(25050), + 1511: uint16(38582), + 1512: uint16(30965), + 1513: uint16(35552), + 1514: uint16(38589), + 1515: uint16(21452), + 1516: uint16(18849), + 1517: uint16(27832), + 1518: uint16(628), + 1519: uint16(25616), + 1520: uint16(37039), + 1521: uint16(37093), + 1522: uint16(19153), + 1523: uint16(6421), + 1524: uint16(13066), + 1525: uint16(38705), + 1526: uint16(34370), + 1527: uint16(38710), + 1528: uint16(18959), + 1529: uint16(17725), + 1530: uint16(17797), + 1531: uint16(19177), + 1532: uint16(28789), + 1533: uint16(23361), + 1534: uint16(38683), + 1536: uint16(37333), + 1537: uint16(38743), + 1538: uint16(23370), + 1539: uint16(37355), + 1540: uint16(38751), + 1541: uint16(37925), + 1542: uint16(20688), + 1543: uint16(12471), + 1544: uint16(12476), + 1545: uint16(38793), + 1546: uint16(38815), + 1547: uint16(38833), + 1548: uint16(38846), + 1549: uint16(38848), + 1550: uint16(38866), + 1551: uint16(38880), + 1552: uint16(21612), + 1553: uint16(38894), + 1554: uint16(29724), + 1555: uint16(37939), + 1557: uint16(38901), + 1558: uint16(37917), + 1559: uint16(31098), + 1560: uint16(19153), + 1561: uint16(38964), + 1562: uint16(38963), + 1563: uint16(38987), + 1564: uint16(39014), + 1565: uint16(15118), + 1566: uint16(29045), + 1567: uint16(15697), + 1568: uint16(1584), + 1569: uint16(16732), + 1570: uint16(22278), + 1571: uint16(39114), + 1572: uint16(39095), + 1573: uint16(39112), + 1574: uint16(39111), + 1575: uint16(19199), + 1576: uint16(27943), + 1577: uint16(5843), + 1578: uint16(21936), + 1579: uint16(39137), + 1580: uint16(39142), + 1581: uint16(39148), + 1582: uint16(37752), + 1583: uint16(39225), + 1584: uint16(18985), + 1585: uint16(19314), + 1586: uint16(38999), + 1587: uint16(39173), + 1588: uint16(39413), + 1589: uint16(39436), + 1590: uint16(39483), + 1591: uint16(39440), + 1592: uint16(39512), + 1593: uint16(22309), + 1594: uint16(14020), + 1595: uint16(37041), + 1596: uint16(39893), + 1597: uint16(39648), + 1598: uint16(39650), + 1599: uint16(39685), + 1600: uint16(39668), + 1601: uint16(19470), + 1602: uint16(39700), + 1603: uint16(39725), + 1604: uint16(34304), + 1605: uint16(20532), + 1606: uint16(39732), + 1607: uint16(27048), + 1608: uint16(14531), + 1609: uint16(12413), + 1610: uint16(39760), + 1611: uint16(39744), + 1612: uint16(40254), + 1613: uint16(23109), + 1614: uint16(6243), + 1615: uint16(39822), + 1616: uint16(16971), + 1617: uint16(39938), + 1618: uint16(39935), + 1619: uint16(39948), + 1620: uint16(40552), + 1621: uint16(40404), + 1622: uint16(40887), + 1623: uint16(41362), + 1624: uint16(41387), + 1625: uint16(41185), + 1626: uint16(41251), + 1627: uint16(41439), + 1628: uint16(40318), + 1629: uint16(40323), + 1630: uint16(41268), + 1631: uint16(40462), + 1632: uint16(26760), + 1633: uint16(40388), + 1634: uint16(8539), + 1635: uint16(41363), + 1636: uint16(41504), + 1637: uint16(6459), + 1638: uint16(41523), + 1639: uint16(40249), + 1640: uint16(41145), + 1641: uint16(41652), + 1642: uint16(40592), + 1643: uint16(40597), + 1644: uint16(40606), + 1645: uint16(40610), + 1646: uint16(19764), + 1647: uint16(40618), + 1648: uint16(40623), + 1649: uint16(17252), + 1650: uint16(40641), + 1651: uint16(15200), + 1652: uint16(14821), + 1653: uint16(15645), + 1654: uint16(20274), + 1655: uint16(14270), + 1656: uint16(35883), + 1657: uint16(40706), + 1658: uint16(40712), + 1659: uint16(19350), + 1660: uint16(37924), + 1661: uint16(28066), + 1662: uint16(40727), + 1664: uint16(40761), + 1665: uint16(22175), + 1666: uint16(22154), + 1667: uint16(40773), + 1668: uint16(39352), + 1669: uint16(37003), + 1670: uint16(38898), + 1671: uint16(33919), + 1672: uint16(40802), + 1673: uint16(40809), + 1674: uint16(31452), + 1675: uint16(40846), + 1676: uint16(29206), + 1677: uint16(19390), + 1678: uint16(18805), + 1679: uint16(18875), + 1680: uint16(29047), + 1681: uint16(18936), + 1682: uint16(17224), + 1683: uint16(19025), + 1684: uint16(29598), + 1685: uint16(35802), + 1686: uint16(6394), + 1687: uint16(31135), + 1688: uint16(35198), + 1689: uint16(36406), + 1690: uint16(37737), + 1691: uint16(37875), + 1692: uint16(35396), + 1693: uint16(37612), + 1694: uint16(37761), + 1695: uint16(37835), + 1696: uint16(35180), + 1697: uint16(17593), + 1698: uint16(29207), + 1699: uint16(16107), + 1700: uint16(30578), + 1701: uint16(31299), + 1702: uint16(28880), + 1703: uint16(17523), + 1704: uint16(17400), + 1705: uint16(29054), + 1706: uint16(6127), + 1707: uint16(28835), + 1708: uint16(6334), + 1709: uint16(13721), + 1710: uint16(16071), + 1711: uint16(6277), + 1712: uint16(21551), + 1713: uint16(6136), + 1714: uint16(14114), + 1715: uint16(5883), + 1716: uint16(6201), + 1717: uint16(14049), + 1718: uint16(6004), + 1719: uint16(6353), + 1720: uint16(24395), + 1721: uint16(14115), + 1722: uint16(5824), + 1723: uint16(22363), + 1724: uint16(18981), + 1725: uint16(5118), + 1726: uint16(4776), + 1727: uint16(5062), + 1728: uint16(5302), + 1729: uint16(34051), + 1730: uint16(13990), + 1732: uint16(33877), + 1733: uint16(18836), + 1734: uint16(29029), + 1735: uint16(15921), + 1736: uint16(21852), + 1737: uint16(16123), + 1738: uint16(28754), + 1739: uint16(17652), + 1740: uint16(14062), + 1741: uint16(39325), + 1742: uint16(28454), + 1743: uint16(26617), + 1744: uint16(14131), + 1745: uint16(15381), + 1746: uint16(15847), + 1747: uint16(22636), + 1748: uint16(6434), + 1749: uint16(26640), + 1750: uint16(16471), + 1751: uint16(14143), + 1752: uint16(16609), + 1753: uint16(16523), + 1754: uint16(16655), + 1755: uint16(27681), + 1756: uint16(21707), + 1757: uint16(22174), + 1758: uint16(26289), + 1759: uint16(22162), + 1760: uint16(4063), + 1761: uint16(2984), + 1762: uint16(3597), + 1763: uint16(37830), + 1764: uint16(35603), + 1765: uint16(37788), + 1766: uint16(20216), + 1767: uint16(20779), + 1768: uint16(14361), + 1769: uint16(17462), + 1770: uint16(20156), + 1771: uint16(1125), + 1772: uint16(895), + 1773: uint16(20299), + 1774: uint16(20362), + 1775: uint16(22097), + 1776: uint16(23144), + 1777: uint16(427), + 1778: uint16(971), + 1779: uint16(14745), + 1780: uint16(778), + 1781: uint16(1044), + 1782: uint16(13365), + 1783: uint16(20265), + 1784: uint16(704), + 1785: uint16(36531), + 1786: uint16(629), + 1787: uint16(35546), + 1788: uint16(524), + 1789: uint16(20120), + 1790: uint16(20685), + 1791: uint16(20749), + 1792: uint16(20386), + 1793: uint16(20227), + 1794: uint16(18958), + 1795: uint16(16010), + 1796: uint16(20290), + 1797: uint16(20526), + 1798: uint16(20588), + 1799: uint16(20609), + 1800: uint16(20428), + 1801: uint16(20453), + 1802: uint16(20568), + 1803: uint16(20732), + 1808: uint16(28278), + 1809: uint16(13717), + 1810: uint16(15929), + 1811: uint16(16063), + 1812: uint16(28018), + 1813: uint16(6276), + 1814: uint16(16009), + 1815: uint16(20904), + 1816: uint16(20931), + 1817: uint16(1504), + 1818: uint16(17629), + 1819: uint16(1187), + 1820: uint16(1170), + 1821: uint16(1169), + 1822: uint16(36218), + 1823: uint16(35484), + 1824: uint16(1806), + 1825: uint16(21081), + 1826: uint16(21156), + 1827: uint16(2163), + 1828: uint16(21217), + 1830: uint16(18042), + 1831: uint16(29068), + 1832: uint16(17292), + 1833: uint16(3104), + 1834: uint16(18860), + 1835: uint16(4324), + 1836: uint16(27089), + 1837: uint16(3613), + 1839: uint16(16094), + 1840: uint16(29849), + 1841: uint16(29716), + 1842: uint16(29782), + 1843: uint16(29592), + 1844: uint16(19342), + 1845: uint16(19132), + 1846: uint16(16525), + 1847: uint16(21456), + 1848: uint16(13700), + 1849: uint16(29199), + 1850: uint16(16585), + 1851: uint16(21940), + 1852: uint16(837), + 1853: uint16(21709), + 1854: uint16(3014), + 1855: uint16(22301), + 1856: uint16(37469), + 1857: uint16(38644), + 1858: uint16(37734), + 1859: uint16(22493), + 1860: uint16(22413), + 1861: uint16(22399), + 1862: uint16(13886), + 1863: uint16(22731), + 1864: uint16(23193), + 1865: uint16(35398), + 1866: uint16(5882), + 1867: uint16(5999), + 1868: uint16(5904), + 1869: uint16(23084), + 1870: uint16(22968), + 1871: uint16(37519), + 1872: uint16(23166), + 1873: uint16(23247), + 1874: uint16(23058), + 1875: uint16(22854), + 1876: uint16(6643), + 1877: uint16(6241), + 1878: uint16(17045), + 1879: uint16(14069), + 1880: uint16(27909), + 1881: uint16(29763), + 1882: uint16(23073), + 1883: uint16(24195), + 1884: uint16(23169), + 1885: uint16(35799), + 1886: uint16(1043), + 1887: uint16(37856), + 1888: uint16(29836), + 1889: uint16(4867), + 1890: uint16(28933), + 1891: uint16(18802), + 1892: uint16(37896), + 1893: uint16(35323), + 1894: uint16(37821), + 1895: uint16(14240), + 1896: uint16(23582), + 1897: uint16(23710), + 1898: uint16(24158), + 1899: uint16(24136), + 1900: uint16(6550), + 1901: uint16(6524), + 1902: uint16(15086), + 1903: uint16(24269), + 1904: uint16(23375), + 1905: uint16(6403), + 1906: uint16(6404), + 1907: uint16(14081), + 1908: uint16(6304), + 1909: uint16(14045), + 1910: uint16(5886), + 1911: uint16(14035), + 1912: uint16(33066), + 1913: uint16(35399), + 1914: uint16(7610), + 1915: uint16(13426), + 1916: uint16(35240), + 1917: uint16(24332), + 1918: uint16(24334), + 1919: uint16(6439), + 1920: uint16(6059), + 1921: uint16(23147), + 1922: uint16(5947), + 1923: uint16(23364), + 1924: uint16(34324), + 1925: uint16(30205), + 1926: uint16(34912), + 1927: uint16(24702), + 1928: uint16(10336), + 1929: uint16(9771), + 1930: uint16(24539), + 1931: uint16(16056), + 1932: uint16(9647), + 1933: uint16(9662), + 1934: uint16(37000), + 1935: uint16(28531), + 1936: uint16(25024), + 1937: uint16(62), + 1938: uint16(70), + 1939: uint16(9755), + 1940: uint16(24985), + 1941: uint16(24984), + 1942: uint16(24693), + 1943: uint16(11419), + 1944: uint16(11527), + 1945: uint16(18132), + 1946: uint16(37197), + 1947: uint16(25713), + 1948: uint16(18021), + 1949: uint16(11114), + 1950: uint16(14889), + 1951: uint16(11042), + 1952: uint16(13392), + 1953: uint16(39146), + 1954: uint16(11896), + 1955: uint16(25399), + 1956: uint16(42075), + 1957: uint16(25782), + 1958: uint16(25393), + 1959: uint16(25553), + 1960: uint16(18915), + 1961: uint16(11623), + 1962: uint16(25252), + 1963: uint16(11425), + 1964: uint16(25659), + 1965: uint16(25963), + 1966: uint16(26994), + 1967: uint16(15348), + 1968: uint16(12430), + 1969: uint16(12973), + 1970: uint16(18825), + 1971: uint16(12971), + 1972: uint16(21773), + 1973: uint16(13024), + 1974: uint16(6361), + 1975: uint16(37951), + 1976: uint16(26318), + 1977: uint16(12937), + 1978: uint16(12723), + 1979: uint16(15072), + 1980: uint16(16784), + 1981: uint16(21892), + 1982: uint16(35618), + 1983: uint16(21903), + 1984: uint16(5884), + 1985: uint16(21851), + 1986: uint16(21541), + 1987: uint16(30958), + 1988: uint16(12547), + 1989: uint16(6186), + 1990: uint16(12852), + 1991: uint16(13412), + 1992: uint16(12815), + 1993: uint16(12674), + 1994: uint16(17097), + 1995: uint16(26254), + 1996: uint16(27940), + 1997: uint16(26219), + 1998: uint16(19347), + 1999: uint16(26160), + 2000: uint16(30832), + 2001: uint16(7659), + 2002: uint16(26211), + 2003: uint16(13010), + 2004: uint16(13025), + 2005: uint16(26142), + 2006: uint16(22642), + 2007: uint16(14545), + 2008: uint16(14394), + 2009: uint16(14268), + 2010: uint16(15257), + 2011: uint16(14242), + 2012: uint16(13310), + 2013: uint16(29904), + 2014: uint16(15254), + 2015: uint16(26511), + 2016: uint16(17962), + 2017: uint16(26806), + 2018: uint16(26654), + 2019: uint16(15300), + 2020: uint16(27326), + 2021: uint16(14435), + 2022: uint16(14293), + 2023: uint16(17543), + 2024: uint16(27187), + 2025: uint16(27218), + 2026: uint16(27337), + 2027: uint16(27397), + 2028: uint16(6418), + 2029: uint16(25873), + 2030: uint16(26776), + 2031: uint16(27212), + 2032: uint16(15319), + 2033: uint16(27258), + 2034: uint16(27479), + 2035: uint16(16320), + 2036: uint16(15514), + 2037: uint16(37792), + 2038: uint16(37618), + 2039: uint16(35818), + 2040: uint16(35531), + 2041: uint16(37513), + 2042: uint16(32798), + 2043: uint16(35292), + 2044: uint16(37991), + 2045: uint16(28069), + 2046: uint16(28427), + 2047: uint16(18924), + 2049: uint16(16255), + 2050: uint16(15759), + 2051: uint16(28164), + 2052: uint16(16444), + 2053: uint16(23101), + 2054: uint16(28170), + 2055: uint16(22599), + 2056: uint16(27940), + 2057: uint16(30786), + 2058: uint16(28987), + 2059: uint16(17178), + 2060: uint16(17014), + 2061: uint16(28913), + 2062: uint16(29264), + 2063: uint16(29319), + 2064: uint16(29332), + 2065: uint16(18319), + 2066: uint16(18213), + 2067: uint16(20857), + 2068: uint16(19108), + 2069: uint16(1515), + 2070: uint16(29818), + 2071: uint16(16120), + 2072: uint16(13919), + 2073: uint16(19018), + 2074: uint16(18711), + 2075: uint16(24545), + 2076: uint16(16134), + 2077: uint16(16049), + 2078: uint16(19167), + 2079: uint16(35875), + 2080: uint16(16181), + 2081: uint16(24743), + 2082: uint16(16115), + 2083: uint16(29900), + 2084: uint16(29756), + 2085: uint16(37767), + 2086: uint16(29751), + 2087: uint16(17567), + 2088: uint16(28138), + 2089: uint16(17745), + 2090: uint16(30083), + 2091: uint16(16227), + 2092: uint16(19673), + 2093: uint16(19718), + 2094: uint16(16216), + 2095: uint16(30037), + 2096: uint16(30323), + 2097: uint16(42438), + 2098: uint16(15129), + 2099: uint16(29800), + 2100: uint16(35532), + 2101: uint16(18859), + 2102: uint16(18830), + 2103: uint16(15099), + 2104: uint16(15821), + 2105: uint16(19022), + 2106: uint16(16127), + 2107: uint16(18885), + 2108: uint16(18675), + 2109: uint16(37370), + 2110: uint16(22322), + 2111: uint16(37698), + 2112: uint16(35555), + 2113: uint16(6244), + 2114: uint16(20703), + 2115: uint16(21025), + 2116: uint16(20967), + 2117: uint16(30584), + 2118: uint16(12850), + 2119: uint16(30478), + 2120: uint16(30479), + 2121: uint16(30587), + 2122: uint16(18071), + 2123: uint16(14209), + 2124: uint16(14942), + 2125: uint16(18672), + 2126: uint16(29752), + 2127: uint16(29851), + 2128: uint16(16063), + 2129: uint16(19130), + 2130: uint16(19143), + 2131: uint16(16584), + 2132: uint16(19094), + 2133: uint16(25006), + 2134: uint16(37639), + 2135: uint16(21889), + 2136: uint16(30750), + 2137: uint16(30861), + 2138: uint16(30856), + 2139: uint16(30930), + 2140: uint16(29648), + 2141: uint16(31065), + 2142: uint16(30529), + 2143: uint16(22243), + 2144: uint16(16654), + 2146: uint16(33942), + 2147: uint16(31141), + 2148: uint16(27181), + 2149: uint16(16122), + 2150: uint16(31290), + 2151: uint16(31220), + 2152: uint16(16750), + 2153: uint16(5862), + 2154: uint16(16690), + 2155: uint16(37429), + 2156: uint16(31217), + 2157: uint16(3404), + 2158: uint16(18828), + 2159: uint16(665), + 2160: uint16(15802), + 2161: uint16(5998), + 2162: uint16(13719), + 2163: uint16(21867), + 2164: uint16(13680), + 2165: uint16(13994), + 2166: uint16(468), + 2167: uint16(3085), + 2168: uint16(31458), + 2169: uint16(23129), + 2170: uint16(9973), + 2171: uint16(23215), + 2172: uint16(23196), + 2173: uint16(23053), + 2174: uint16(603), + 2175: uint16(30960), + 2176: uint16(23082), + 2177: uint16(23494), + 2178: uint16(31486), + 2179: uint16(16889), + 2180: uint16(31837), + 2181: uint16(31853), + 2182: uint16(16913), + 2183: uint16(23475), + 2184: uint16(24252), + 2185: uint16(24230), + 2186: uint16(31949), + 2187: uint16(18937), + 2188: uint16(6064), + 2189: uint16(31886), + 2190: uint16(31868), + 2191: uint16(31918), + 2192: uint16(27314), + 2193: uint16(32220), + 2194: uint16(32263), + 2195: uint16(32211), + 2196: uint16(32590), + 2197: uint16(25185), + 2198: uint16(24924), + 2199: uint16(31560), + 2200: uint16(32151), + 2201: uint16(24194), + 2202: uint16(17002), + 2203: uint16(27509), + 2204: uint16(2326), + 2205: uint16(26582), + 2206: uint16(78), + 2207: uint16(13775), + 2208: uint16(22468), + 2209: uint16(25618), + 2210: uint16(25592), + 2211: uint16(18786), + 2212: uint16(32733), + 2213: uint16(31527), + 2214: uint16(2092), + 2215: uint16(23273), + 2216: uint16(23875), + 2217: uint16(31500), + 2218: uint16(24078), + 2219: uint16(39398), + 2220: uint16(34373), + 2221: uint16(39523), + 2222: uint16(27164), + 2223: uint16(13375), + 2224: uint16(14818), + 2225: uint16(18935), + 2226: uint16(26029), + 2227: uint16(39455), + 2228: uint16(26016), + 2229: uint16(33920), + 2230: uint16(28967), + 2231: uint16(27857), + 2232: uint16(17642), + 2233: uint16(33079), + 2234: uint16(17410), + 2235: uint16(32966), + 2236: uint16(33033), + 2237: uint16(33090), + 2238: uint16(26548), + 2239: uint16(39107), + 2240: uint16(27202), + 2241: uint16(33378), + 2242: uint16(33381), + 2243: uint16(27217), + 2244: uint16(33875), + 2245: uint16(28071), + 2246: uint16(34320), + 2247: uint16(29211), + 2248: uint16(23174), + 2249: uint16(16767), + 2250: uint16(6208), + 2251: uint16(23339), + 2252: uint16(6305), + 2253: uint16(23268), + 2254: uint16(6360), + 2255: uint16(34464), + 2256: uint16(63932), + 2257: uint16(15759), + 2258: uint16(34861), + 2259: uint16(29730), + 2260: uint16(23042), + 2261: uint16(34926), + 2262: uint16(20293), + 2263: uint16(34951), + 2264: uint16(35007), + 2265: uint16(35046), + 2266: uint16(35173), + 2267: uint16(35149), + 2268: uint16(22147), + 2269: uint16(35156), + 2270: uint16(30597), + 2271: uint16(30596), + 2272: uint16(35829), + 2273: uint16(35801), + 2274: uint16(35740), + 2275: uint16(35321), + 2276: uint16(16045), + 2277: uint16(33955), + 2278: uint16(18165), + 2279: uint16(18127), + 2280: uint16(14322), + 2281: uint16(35389), + 2282: uint16(35356), + 2283: uint16(37960), + 2284: uint16(24397), + 2285: uint16(37419), + 2286: uint16(17028), + 2287: uint16(26068), + 2288: uint16(28969), + 2289: uint16(28868), + 2290: uint16(6213), + 2291: uint16(40301), + 2292: uint16(35999), + 2293: uint16(36073), + 2294: uint16(32220), + 2295: uint16(22938), + 2296: uint16(30659), + 2297: uint16(23024), + 2298: uint16(17262), + 2299: uint16(14036), + 2300: uint16(36394), + 2301: uint16(36519), + 2302: uint16(19465), + 2303: uint16(36656), + 2304: uint16(36682), + 2305: uint16(17140), + 2306: uint16(27736), + 2307: uint16(28603), + 2308: uint16(8993), + 2309: uint16(18587), + 2310: uint16(28537), + 2311: uint16(28299), + 2312: uint16(6106), + 2313: uint16(39913), + 2314: uint16(14005), + 2315: uint16(18735), + 2316: uint16(37051), + 2318: uint16(21873), + 2319: uint16(18694), + 2320: uint16(37307), + 2321: uint16(37892), + 2322: uint16(35403), + 2323: uint16(16482), + 2324: uint16(35580), + 2325: uint16(37927), + 2326: uint16(35869), + 2327: uint16(35899), + 2328: uint16(34021), + 2329: uint16(35371), + 2330: uint16(38297), + 2331: uint16(38311), + 2332: uint16(38295), + 2333: uint16(38294), + 2334: uint16(36148), + 2335: uint16(29765), + 2336: uint16(16066), + 2337: uint16(18687), + 2338: uint16(19010), + 2339: uint16(17386), + 2340: uint16(16103), + 2341: uint16(12837), + 2342: uint16(38543), + 2343: uint16(36583), + 2344: uint16(36454), + 2345: uint16(36453), + 2346: uint16(16076), + 2347: uint16(18925), + 2348: uint16(19064), + 2349: uint16(16366), + 2350: uint16(29714), + 2351: uint16(29803), + 2352: uint16(16124), + 2353: uint16(38721), + 2354: uint16(37040), + 2355: uint16(26695), + 2356: uint16(18973), + 2357: uint16(37011), + 2358: uint16(22495), + 2360: uint16(37736), + 2361: uint16(35209), + 2362: uint16(35878), + 2363: uint16(35631), + 2364: uint16(25534), + 2365: uint16(37562), + 2366: uint16(23313), + 2367: uint16(35689), + 2368: uint16(18748), + 2369: uint16(29689), + 2370: uint16(16923), + 2371: uint16(38811), + 2372: uint16(38769), + 2373: uint16(39224), + 2374: uint16(3878), + 2375: uint16(24001), + 2376: uint16(35781), + 2377: uint16(19122), + 2378: uint16(38943), + 2379: uint16(38106), + 2380: uint16(37622), + 2381: uint16(38359), + 2382: uint16(37349), + 2383: uint16(17600), + 2384: uint16(35664), + 2385: uint16(19047), + 2386: uint16(35684), + 2387: uint16(39132), + 2388: uint16(35397), + 2389: uint16(16128), + 2390: uint16(37418), + 2391: uint16(18725), + 2392: uint16(33812), + 2393: uint16(39227), + 2394: uint16(39245), + 2395: uint16(31494), + 2396: uint16(15869), + 2397: uint16(39323), + 2398: uint16(19311), + 2399: uint16(39338), + 2400: uint16(39516), + 2401: uint16(35685), + 2402: uint16(22728), + 2403: uint16(27279), + 2404: uint16(39457), + 2405: uint16(23294), + 2406: uint16(39471), + 2407: uint16(39153), + 2408: uint16(19344), + 2409: uint16(39240), + 2410: uint16(39356), + 2411: uint16(19389), + 2412: uint16(19351), + 2413: uint16(37757), + 2414: uint16(22642), + 2415: uint16(4866), + 2416: uint16(22562), + 2417: uint16(18872), + 2418: uint16(5352), + 2419: uint16(30788), + 2420: uint16(10015), + 2421: uint16(15800), + 2422: uint16(26821), + 2423: uint16(15741), + 2424: uint16(37976), + 2425: uint16(14631), + 2426: uint16(24912), + 2427: uint16(10113), + 2428: uint16(10603), + 2429: uint16(24839), + 2430: uint16(40015), + 2431: uint16(40019), + 2432: uint16(40059), + 2433: uint16(39989), + 2434: uint16(39952), + 2435: uint16(39807), + 2436: uint16(39887), + 2437: uint16(40493), + 2438: uint16(39839), + 2439: uint16(41461), + 2440: uint16(41214), + 2441: uint16(40225), + 2442: uint16(19630), + 2443: uint16(16644), + 2444: uint16(40472), + 2445: uint16(19632), + 2446: uint16(40204), + 2447: uint16(41396), + 2448: uint16(41197), + 2449: uint16(41203), + 2450: uint16(39215), + 2451: uint16(40357), + 2452: uint16(33981), + 2453: uint16(28178), + 2454: uint16(28639), + 2455: uint16(27522), + 2456: uint16(34300), + 2457: uint16(17715), + 2458: uint16(28068), + 2459: uint16(28292), + 2460: uint16(28144), + 2461: uint16(33824), + 2462: uint16(34286), + 2463: uint16(28160), + 2464: uint16(14295), + 2465: uint16(24676), + 2466: uint16(31202), + 2467: uint16(13724), + 2468: uint16(13888), + 2469: uint16(18733), + 2470: uint16(18910), + 2471: uint16(15714), + 2472: uint16(37851), + 2473: uint16(37566), + 2474: uint16(37704), + 2475: uint16(703), + 2476: uint16(30905), + 2477: uint16(37495), + 2478: uint16(37965), + 2479: uint16(20452), + 2480: uint16(13376), + 2481: uint16(36964), + 2482: uint16(21853), + 2483: uint16(30781), + 2484: uint16(30804), + 2485: uint16(30902), + 2486: uint16(30795), + 2487: uint16(5975), + 2488: uint16(12745), + 2489: uint16(18753), + 2490: uint16(13978), + 2491: uint16(20338), + 2492: uint16(28634), + 2493: uint16(28633), + 2495: uint16(28702), + 2496: uint16(21524), + 2497: uint16(16821), + 2498: uint16(22459), + 2499: uint16(22771), + 2500: uint16(22410), + 2501: uint16(40214), + 2502: uint16(22487), + 2503: uint16(28980), + 2504: uint16(13487), + 2505: uint16(16812), + 2506: uint16(29163), + 2507: uint16(27712), + 2508: uint16(20375), + 2510: uint16(6069), + 2511: uint16(35401), + 2512: uint16(24844), + 2513: uint16(23246), + 2514: uint16(23051), + 2515: uint16(17084), + 2516: uint16(17544), + 2517: uint16(14124), + 2518: uint16(19323), + 2519: uint16(35324), + 2520: uint16(37819), + 2521: uint16(37816), + 2522: uint16(6358), + 2523: uint16(3869), + 2524: uint16(33906), + 2525: uint16(27840), + 2526: uint16(5139), + 2527: uint16(17146), + 2528: uint16(11302), + 2529: uint16(17345), + 2530: uint16(22932), + 2531: uint16(15799), + 2532: uint16(26433), + 2533: uint16(32168), + 2534: uint16(24923), + 2535: uint16(24740), + 2536: uint16(18873), + 2537: uint16(18827), + 2538: uint16(35322), + 2539: uint16(37605), + 2540: uint16(29666), + 2541: uint16(16105), + 2542: uint16(29876), + 2543: uint16(35683), + 2544: uint16(6303), + 2545: uint16(16097), + 2546: uint16(19123), + 2547: uint16(27352), + 2548: uint16(29683), + 2549: uint16(29691), + 2550: uint16(16086), + 2551: uint16(19006), + 2552: uint16(19092), + 2553: uint16(6105), + 2554: uint16(19046), + 2555: uint16(935), + 2556: uint16(5156), + 2557: uint16(18917), + 2558: uint16(29768), + 2559: uint16(18710), + 2560: uint16(28837), + 2561: uint16(18806), + 2562: uint16(37508), + 2563: uint16(29670), + 2564: uint16(37727), + 2565: uint16(1278), + 2566: uint16(37681), + 2567: uint16(35534), + 2568: uint16(35350), + 2569: uint16(37766), + 2570: uint16(35815), + 2571: uint16(21973), + 2572: uint16(18741), + 2573: uint16(35458), + 2574: uint16(29035), + 2575: uint16(18755), + 2576: uint16(3327), + 2577: uint16(22180), + 2578: uint16(1562), + 2579: uint16(3051), + 2580: uint16(3256), + 2581: uint16(21762), + 2582: uint16(31172), + 2583: uint16(6138), + 2584: uint16(32254), + 2585: uint16(5826), + 2586: uint16(19024), + 2587: uint16(6226), + 2588: uint16(17710), + 2589: uint16(37889), + 2590: uint16(14090), + 2591: uint16(35520), + 2592: uint16(18861), + 2593: uint16(22960), + 2594: uint16(6335), + 2595: uint16(6275), + 2596: uint16(29828), + 2597: uint16(23201), + 2598: uint16(14050), + 2599: uint16(15707), + 2600: uint16(14000), + 2601: uint16(37471), + 2602: uint16(23161), + 2603: uint16(35457), + 2604: uint16(6242), + 2605: uint16(37748), + 2606: uint16(15565), + 2607: uint16(2740), + 2608: uint16(19094), + 2609: uint16(14730), + 2610: uint16(20724), + 2611: uint16(15721), + 2612: uint16(15692), + 2613: uint16(5020), + 2614: uint16(29045), + 2615: uint16(17147), + 2616: uint16(33304), + 2617: uint16(28175), + 2618: uint16(37092), + 2619: uint16(17643), + 2620: uint16(27991), + 2621: uint16(32335), + 2622: uint16(28775), + 2623: uint16(27823), + 2624: uint16(15574), + 2625: uint16(16365), + 2626: uint16(15917), + 2627: uint16(28162), + 2628: uint16(28428), + 2629: uint16(15727), + 2630: uint16(1013), + 2631: uint16(30033), + 2632: uint16(14012), + 2633: uint16(13512), + 2634: uint16(18048), + 2635: uint16(16090), + 2636: uint16(18545), + 2637: uint16(22980), + 2638: uint16(37486), + 2639: uint16(18750), + 2640: uint16(36673), + 2641: uint16(35868), + 2642: uint16(27584), + 2643: uint16(22546), + 2644: uint16(22472), + 2645: uint16(14038), + 2646: uint16(5202), + 2647: uint16(28926), + 2648: uint16(17250), + 2649: uint16(19057), + 2650: uint16(12259), + 2651: uint16(4784), + 2652: uint16(9149), + 2653: uint16(26809), + 2654: uint16(26983), + 2655: uint16(5016), + 2656: uint16(13541), + 2657: uint16(31732), + 2658: uint16(14047), + 2659: uint16(35459), + 2660: uint16(14294), + 2661: uint16(13306), + 2662: uint16(19615), + 2663: uint16(27162), + 2664: uint16(13997), + 2665: uint16(27831), + 2666: uint16(33854), + 2667: uint16(17631), + 2668: uint16(17614), + 2669: uint16(27942), + 2670: uint16(27985), + 2671: uint16(27778), + 2672: uint16(28638), + 2673: uint16(28439), + 2674: uint16(28937), + 2675: uint16(33597), + 2676: uint16(5946), + 2677: uint16(33773), + 2678: uint16(27776), + 2679: uint16(28755), + 2680: uint16(6107), + 2681: uint16(22921), + 2682: uint16(23170), + 2683: uint16(6067), + 2684: uint16(23137), + 2685: uint16(23153), + 2686: uint16(6405), + 2687: uint16(16892), + 2688: uint16(14125), + 2689: uint16(23023), + 2690: uint16(5948), + 2691: uint16(14023), + 2692: uint16(29070), + 2693: uint16(37776), + 2694: uint16(26266), + 2695: uint16(17061), + 2696: uint16(23150), + 2697: uint16(23083), + 2698: uint16(17043), + 2699: uint16(27179), + 2700: uint16(16121), + 2701: uint16(30518), + 2702: uint16(17499), + 2703: uint16(17098), + 2704: uint16(28957), + 2705: uint16(16985), + 2706: uint16(35297), + 2707: uint16(20400), + 2708: uint16(27944), + 2709: uint16(23746), + 2710: uint16(17614), + 2711: uint16(32333), + 2712: uint16(17341), + 2713: uint16(27148), + 2714: uint16(16982), + 2715: uint16(4868), + 2716: uint16(28838), + 2717: uint16(28979), + 2718: uint16(17385), + 2719: uint16(15781), + 2720: uint16(27871), + 2721: uint16(63525), + 2722: uint16(19023), + 2723: uint16(32357), + 2724: uint16(23019), + 2725: uint16(23855), + 2726: uint16(15859), + 2727: uint16(24412), + 2728: uint16(19037), + 2729: uint16(6111), + 2730: uint16(32164), + 2731: uint16(33830), + 2732: uint16(21637), + 2733: uint16(15098), + 2734: uint16(13056), + 2735: uint16(532), + 2736: uint16(22398), + 2737: uint16(2261), + 2738: uint16(1561), + 2739: uint16(16357), + 2740: uint16(8094), + 2741: uint16(41654), + 2742: uint16(28675), + 2743: uint16(37211), + 2744: uint16(23920), + 2745: uint16(29583), + 2746: uint16(31955), + 2747: uint16(35417), + 2748: uint16(37920), + 2749: uint16(20424), + 2750: uint16(32743), + 2751: uint16(29389), + 2752: uint16(29456), + 2753: uint16(31476), + 2754: uint16(29496), + 2755: uint16(29497), + 2756: uint16(22262), + 2757: uint16(29505), + 2758: uint16(29512), + 2759: uint16(16041), + 2760: uint16(31512), + 2761: uint16(36972), + 2762: uint16(29173), + 2763: uint16(18674), + 2764: uint16(29665), + 2765: uint16(33270), + 2766: uint16(16074), + 2767: uint16(30476), + 2768: uint16(16081), + 2769: uint16(27810), + 2770: uint16(22269), + 2771: uint16(29721), + 2772: uint16(29726), + 2773: uint16(29727), + 2774: uint16(16098), + 2775: uint16(16112), + 2776: uint16(16116), + 2777: uint16(16122), + 2778: uint16(29907), + 2779: uint16(16142), + 2780: uint16(16211), + 2781: uint16(30018), + 2782: uint16(30061), + 2783: uint16(30066), + 2784: uint16(30093), + 2785: uint16(16252), + 2786: uint16(30152), + 2787: uint16(30172), + 2788: uint16(16320), + 2789: uint16(30285), + 2790: uint16(16343), + 2791: uint16(30324), + 2792: uint16(16348), + 2793: uint16(30330), + 2794: uint16(20316), + 2795: uint16(29064), + 2796: uint16(22051), + 2797: uint16(35200), + 2798: uint16(22633), + 2799: uint16(16413), + 2800: uint16(30531), + 2801: uint16(16441), + 2802: uint16(26465), + 2803: uint16(16453), + 2804: uint16(13787), + 2805: uint16(30616), + 2806: uint16(16490), + 2807: uint16(16495), + 2808: uint16(23646), + 2809: uint16(30654), + 2810: uint16(30667), + 2811: uint16(22770), + 2812: uint16(30744), + 2813: uint16(28857), + 2814: uint16(30748), + 2815: uint16(16552), + 2816: uint16(30777), + 2817: uint16(30791), + 2818: uint16(30801), + 2819: uint16(30822), + 2820: uint16(33864), + 2821: uint16(21813), + 2822: uint16(31027), + 2823: uint16(26627), + 2824: uint16(31026), + 2825: uint16(16643), + 2826: uint16(16649), + 2827: uint16(31121), + 2828: uint16(31129), + 2829: uint16(36795), + 2830: uint16(31238), + 2831: uint16(36796), + 2832: uint16(16743), + 2833: uint16(31377), + 2834: uint16(16818), + 2835: uint16(31420), + 2836: uint16(33401), + 2837: uint16(16836), + 2838: uint16(31439), + 2839: uint16(31451), + 2840: uint16(16847), + 2841: uint16(20001), + 2842: uint16(31586), + 2843: uint16(31596), + 2844: uint16(31611), + 2845: uint16(31762), + 2846: uint16(31771), + 2847: uint16(16992), + 2848: uint16(17018), + 2849: uint16(31867), + 2850: uint16(31900), + 2851: uint16(17036), + 2852: uint16(31928), + 2853: uint16(17044), + 2854: uint16(31981), + 2855: uint16(36755), + 2856: uint16(28864), + 2857: uint16(3279), + 2858: uint16(32207), + 2859: uint16(32212), + 2860: uint16(32208), + 2861: uint16(32253), + 2862: uint16(32686), + 2863: uint16(32692), + 2864: uint16(29343), + 2865: uint16(17303), + 2866: uint16(32800), + 2867: uint16(32805), + 2868: uint16(31545), + 2869: uint16(32814), + 2870: uint16(32817), + 2871: uint16(32852), + 2872: uint16(15820), + 2873: uint16(22452), + 2874: uint16(28832), + 2875: uint16(32951), + 2876: uint16(33001), + 2877: uint16(17389), + 2878: uint16(33036), + 2879: uint16(29482), + 2880: uint16(33038), + 2881: uint16(33042), + 2882: uint16(30048), + 2883: uint16(33044), + 2884: uint16(17409), + 2885: uint16(15161), + 2886: uint16(33110), + 2887: uint16(33113), + 2888: uint16(33114), + 2889: uint16(17427), + 2890: uint16(22586), + 2891: uint16(33148), + 2892: uint16(33156), + 2893: uint16(17445), + 2894: uint16(33171), + 2895: uint16(17453), + 2896: uint16(33189), + 2897: uint16(22511), + 2898: uint16(33217), + 2899: uint16(33252), + 2900: uint16(33364), + 2901: uint16(17551), + 2902: uint16(33446), + 2903: uint16(33398), + 2904: uint16(33482), + 2905: uint16(33496), + 2906: uint16(33535), + 2907: uint16(17584), + 2908: uint16(33623), + 2909: uint16(38505), + 2910: uint16(27018), + 2911: uint16(33797), + 2912: uint16(28917), + 2913: uint16(33892), + 2914: uint16(24803), + 2915: uint16(33928), + 2916: uint16(17668), + 2917: uint16(33982), + 2918: uint16(34017), + 2919: uint16(34040), + 2920: uint16(34064), + 2921: uint16(34104), + 2922: uint16(34130), + 2923: uint16(17723), + 2924: uint16(34159), + 2925: uint16(34160), + 2926: uint16(34272), + 2927: uint16(17783), + 2928: uint16(34418), + 2929: uint16(34450), + 2930: uint16(34482), + 2931: uint16(34543), + 2932: uint16(38469), + 2933: uint16(34699), + 2934: uint16(17926), + 2935: uint16(17943), + 2936: uint16(34990), + 2937: uint16(35071), + 2938: uint16(35108), + 2939: uint16(35143), + 2940: uint16(35217), + 2941: uint16(31079), + 2942: uint16(35369), + 2943: uint16(35384), + 2944: uint16(35476), + 2945: uint16(35508), + 2946: uint16(35921), + 2947: uint16(36052), + 2948: uint16(36082), + 2949: uint16(36124), + 2950: uint16(18328), + 2951: uint16(22623), + 2952: uint16(36291), + 2953: uint16(18413), + 2954: uint16(20206), + 2955: uint16(36410), + 2956: uint16(21976), + 2957: uint16(22356), + 2958: uint16(36465), + 2959: uint16(22005), + 2960: uint16(36528), + 2961: uint16(18487), + 2962: uint16(36558), + 2963: uint16(36578), + 2964: uint16(36580), + 2965: uint16(36589), + 2966: uint16(36594), + 2967: uint16(36791), + 2968: uint16(36801), + 2969: uint16(36810), + 2970: uint16(36812), + 2971: uint16(36915), + 2972: uint16(39364), + 2973: uint16(18605), + 2974: uint16(39136), + 2975: uint16(37395), + 2976: uint16(18718), + 2977: uint16(37416), + 2978: uint16(37464), + 2979: uint16(37483), + 2980: uint16(37553), + 2981: uint16(37550), + 2982: uint16(37567), + 2983: uint16(37603), + 2984: uint16(37611), + 2985: uint16(37619), + 2986: uint16(37620), + 2987: uint16(37629), + 2988: uint16(37699), + 2989: uint16(37764), + 2990: uint16(37805), + 2991: uint16(18757), + 2992: uint16(18769), + 2993: uint16(40639), + 2994: uint16(37911), + 2995: uint16(21249), + 2996: uint16(37917), + 2997: uint16(37933), + 2998: uint16(37950), + 2999: uint16(18794), + 3000: uint16(37972), + 3001: uint16(38009), + 3002: uint16(38189), + 3003: uint16(38306), + 3004: uint16(18855), + 3005: uint16(38388), + 3006: uint16(38451), + 3007: uint16(18917), + 3008: uint16(26528), + 3009: uint16(18980), + 3010: uint16(38720), + 3011: uint16(18997), + 3012: uint16(38834), + 3013: uint16(38850), + 3014: uint16(22100), + 3015: uint16(19172), + 3016: uint16(24808), + 3017: uint16(39097), + 3018: uint16(19225), + 3019: uint16(39153), + 3020: uint16(22596), + 3021: uint16(39182), + 3022: uint16(39193), + 3023: uint16(20916), + 3024: uint16(39196), + 3025: uint16(39223), + 3026: uint16(39234), + 3027: uint16(39261), + 3028: uint16(39266), + 3029: uint16(19312), + 3030: uint16(39365), + 3031: uint16(19357), + 3032: uint16(39484), + 3033: uint16(39695), + 3034: uint16(31363), + 3035: uint16(39785), + 3036: uint16(39809), + 3037: uint16(39901), + 3038: uint16(39921), + 3039: uint16(39924), + 3040: uint16(19565), + 3041: uint16(39968), + 3042: uint16(14191), + 3043: uint16(7106), + 3044: uint16(40265), + 3045: uint16(39994), + 3046: uint16(40702), + 3047: uint16(22096), + 3048: uint16(40339), + 3049: uint16(40381), + 3050: uint16(40384), + 3051: uint16(40444), + 3052: uint16(38134), + 3053: uint16(36790), + 3054: uint16(40571), + 3055: uint16(40620), + 3056: uint16(40625), + 3057: uint16(40637), + 3058: uint16(40646), + 3059: uint16(38108), + 3060: uint16(40674), + 3061: uint16(40689), + 3062: uint16(40696), + 3063: uint16(31432), + 3064: uint16(40772), + 3065: uint16(148), + 3066: uint16(695), + 3067: uint16(928), + 3068: uint16(26906), + 3069: uint16(38083), + 3070: uint16(22956), + 3071: uint16(1239), + 3072: uint16(22592), + 3073: uint16(38081), + 3074: uint16(14265), + 3075: uint16(1493), + 3076: uint16(1557), + 3077: uint16(1654), + 3078: uint16(5818), + 3079: uint16(22359), + 3080: uint16(29043), + 3081: uint16(2754), + 3082: uint16(2765), + 3083: uint16(3007), + 3084: uint16(21610), + 3085: uint16(63547), + 3086: uint16(3019), + 3087: uint16(21662), + 3088: uint16(3067), + 3089: uint16(3131), + 3090: uint16(3155), + 3091: uint16(3173), + 3092: uint16(3196), + 3093: uint16(24807), + 3094: uint16(3213), + 3095: uint16(22138), + 3096: uint16(3253), + 3097: uint16(3293), + 3098: uint16(3309), + 3099: uint16(3439), + 3100: uint16(3506), + 3101: uint16(3528), + 3102: uint16(26965), + 3103: uint16(39983), + 3104: uint16(34725), + 3105: uint16(3588), + 3106: uint16(3598), + 3107: uint16(3799), + 3108: uint16(3984), + 3109: uint16(3885), + 3110: uint16(3699), + 3111: uint16(23584), + 3112: uint16(4028), + 3113: uint16(24075), + 3114: uint16(4188), + 3115: uint16(4175), + 3116: uint16(4214), + 3117: uint16(26398), + 3118: uint16(4219), + 3119: uint16(4232), + 3120: uint16(4246), + 3121: uint16(13895), + 3122: uint16(4287), + 3123: uint16(4307), + 3124: uint16(4399), + 3125: uint16(4411), + 3126: uint16(21348), + 3127: uint16(33965), + 3128: uint16(4835), + 3129: uint16(4981), + 3130: uint16(4918), + 3131: uint16(35713), + 3132: uint16(5495), + 3133: uint16(5657), + 3134: uint16(6083), + 3135: uint16(6087), + 3136: uint16(20088), + 3137: uint16(28859), + 3138: uint16(6189), + 3139: uint16(6506), + 3140: uint16(6701), + 3141: uint16(6725), + 3142: uint16(7210), + 3143: uint16(7280), + 3144: uint16(7340), + 3145: uint16(7880), + 3146: uint16(25283), + 3147: uint16(7893), + 3148: uint16(7957), + 3149: uint16(29080), + 3150: uint16(26709), + 3151: uint16(8261), + 3152: uint16(27113), + 3153: uint16(14024), + 3154: uint16(8828), + 3155: uint16(9175), + 3156: uint16(9210), + 3157: uint16(10026), + 3158: uint16(10353), + 3159: uint16(10575), + 3160: uint16(33533), + 3161: uint16(10599), + 3162: uint16(10643), + 3163: uint16(10965), + 3164: uint16(35237), + 3165: uint16(10984), + 3166: uint16(36768), + 3167: uint16(11022), + 3168: uint16(38840), + 3169: uint16(11071), + 3170: uint16(38983), + 3171: uint16(39613), + 3172: uint16(11340), + 3174: uint16(11400), + 3175: uint16(11447), + 3176: uint16(23528), + 3177: uint16(11528), + 3178: uint16(11538), + 3179: uint16(11703), + 3180: uint16(11669), + 3181: uint16(11842), + 3182: uint16(12148), + 3183: uint16(12236), + 3184: uint16(12339), + 3185: uint16(12390), + 3186: uint16(13087), + 3187: uint16(13278), + 3188: uint16(24497), + 3189: uint16(26184), + 3190: uint16(26303), + 3191: uint16(31353), + 3192: uint16(13671), + 3193: uint16(13811), + 3195: uint16(18874), + 3197: uint16(13850), + 3198: uint16(14102), + 3200: uint16(838), + 3201: uint16(22709), + 3202: uint16(26382), + 3203: uint16(26904), + 3204: uint16(15015), + 3205: uint16(30295), + 3206: uint16(24546), + 3207: uint16(15889), + 3208: uint16(16057), + 3209: uint16(30206), + 3210: uint16(8346), + 3211: uint16(18640), + 3212: uint16(19128), + 3213: uint16(16665), + 3214: uint16(35482), + 3215: uint16(17134), + 3216: uint16(17165), + 3217: uint16(16443), + 3218: uint16(17204), + 3219: uint16(17302), + 3220: uint16(19013), + 3221: uint16(1482), + 3222: uint16(20946), + 3223: uint16(1553), + 3224: uint16(22943), + 3225: uint16(7848), + 3226: uint16(15294), + 3227: uint16(15615), + 3228: uint16(17412), + 3229: uint16(17622), + 3230: uint16(22408), + 3231: uint16(18036), + 3232: uint16(14747), + 3233: uint16(18223), + 3234: uint16(34280), + 3235: uint16(39369), + 3236: uint16(14178), + 3237: uint16(8643), + 3238: uint16(35678), + 3239: uint16(35662), + 3241: uint16(18450), + 3242: uint16(18683), + 3243: uint16(18965), + 3244: uint16(29193), + 3245: uint16(19136), + 3246: uint16(3192), + 3247: uint16(22885), + 3248: uint16(20133), + 3249: uint16(20358), + 3250: uint16(1913), + 3251: uint16(36570), + 3252: uint16(20524), + 3253: uint16(21135), + 3254: uint16(22335), + 3255: uint16(29041), + 3256: uint16(21145), + 3257: uint16(21529), + 3258: uint16(16202), + 3259: uint16(19111), + 3260: uint16(21948), + 3261: uint16(21574), + 3262: uint16(21614), + 3263: uint16(27474), + 3265: uint16(13427), + 3266: uint16(21823), + 3267: uint16(30258), + 3268: uint16(21854), + 3269: uint16(18200), + 3270: uint16(21858), + 3271: uint16(21862), + 3272: uint16(22471), + 3273: uint16(18751), + 3274: uint16(22621), + 3275: uint16(20582), + 3276: uint16(13563), + 3277: uint16(13260), + 3279: uint16(22787), + 3280: uint16(18300), + 3281: uint16(35144), + 3282: uint16(23214), + 3283: uint16(23433), + 3284: uint16(23558), + 3285: uint16(7568), + 3286: uint16(22433), + 3287: uint16(29009), + 3289: uint16(24834), + 3290: uint16(31762), + 3291: uint16(36950), + 3292: uint16(25010), + 3293: uint16(20378), + 3294: uint16(35682), + 3295: uint16(25602), + 3296: uint16(25674), + 3297: uint16(23899), + 3298: uint16(27639), + 3300: uint16(25732), + 3301: uint16(6428), + 3302: uint16(35562), + 3303: uint16(18934), + 3304: uint16(25736), + 3305: uint16(16367), + 3306: uint16(25874), + 3307: uint16(19392), + 3308: uint16(26047), + 3309: uint16(26293), + 3310: uint16(10011), + 3311: uint16(37989), + 3312: uint16(22497), + 3313: uint16(24981), + 3314: uint16(23079), + 3315: uint16(63693), + 3317: uint16(22201), + 3318: uint16(17697), + 3319: uint16(26364), + 3320: uint16(20074), + 3321: uint16(18740), + 3322: uint16(38486), + 3323: uint16(28047), + 3324: uint16(27837), + 3325: uint16(13848), + 3326: uint16(35191), + 3327: uint16(26521), + 3328: uint16(26734), + 3329: uint16(25617), + 3330: uint16(26718), + 3332: uint16(26823), + 3333: uint16(31554), + 3334: uint16(37056), + 3335: uint16(2577), + 3336: uint16(26918), + 3338: uint16(26937), + 3339: uint16(31301), + 3341: uint16(27130), + 3342: uint16(39462), + 3343: uint16(27181), + 3344: uint16(13919), + 3345: uint16(25705), + 3346: uint16(33), + 3347: uint16(31107), + 3348: uint16(27188), + 3349: uint16(27483), + 3350: uint16(23852), + 3351: uint16(13593), + 3353: uint16(27549), + 3354: uint16(18128), + 3355: uint16(27812), + 3356: uint16(30011), + 3357: uint16(34917), + 3358: uint16(28078), + 3359: uint16(22710), + 3360: uint16(14108), + 3361: uint16(9613), + 3362: uint16(28747), + 3363: uint16(29133), + 3364: uint16(15444), + 3365: uint16(29312), + 3366: uint16(29317), + 3367: uint16(37505), + 3368: uint16(8570), + 3369: uint16(29323), + 3370: uint16(37680), + 3371: uint16(29414), + 3372: uint16(18896), + 3373: uint16(27705), + 3374: uint16(38047), + 3375: uint16(29776), + 3376: uint16(3832), + 3377: uint16(34855), + 3378: uint16(35061), + 3379: uint16(10534), + 3380: uint16(33907), + 3381: uint16(6065), + 3382: uint16(28344), + 3383: uint16(18986), + 3384: uint16(6176), + 3385: uint16(14756), + 3386: uint16(14009), + 3389: uint16(17727), + 3390: uint16(26294), + 3391: uint16(40109), + 3392: uint16(39076), + 3393: uint16(35139), + 3394: uint16(30668), + 3395: uint16(30808), + 3396: uint16(22230), + 3397: uint16(16607), + 3398: uint16(5642), + 3399: uint16(14753), + 3400: uint16(14127), + 3401: uint16(33000), + 3402: uint16(5061), + 3403: uint16(29101), + 3404: uint16(33638), + 3405: uint16(31197), + 3406: uint16(37288), + 3408: uint16(19639), + 3409: uint16(28847), + 3410: uint16(35243), + 3411: uint16(31229), + 3412: uint16(31242), + 3413: uint16(31499), + 3414: uint16(32102), + 3415: uint16(16762), + 3416: uint16(31555), + 3417: uint16(31102), + 3418: uint16(32777), + 3419: uint16(28597), + 3420: uint16(41695), + 3421: uint16(27139), + 3422: uint16(33560), + 3423: uint16(21410), + 3424: uint16(28167), + 3425: uint16(37823), + 3426: uint16(26678), + 3427: uint16(38749), + 3428: uint16(33135), + 3429: uint16(32803), + 3430: uint16(27061), + 3431: uint16(5101), + 3432: uint16(12847), + 3433: uint16(32840), + 3434: uint16(23941), + 3435: uint16(35888), + 3436: uint16(32899), + 3437: uint16(22293), + 3438: uint16(38947), + 3439: uint16(35145), + 3440: uint16(23979), + 3441: uint16(18824), + 3442: uint16(26046), + 3443: uint16(27093), + 3444: uint16(21458), + 3445: uint16(19109), + 3446: uint16(16257), + 3447: uint16(15377), + 3448: uint16(26422), + 3449: uint16(32912), + 3450: uint16(33012), + 3451: uint16(33070), + 3452: uint16(8097), + 3453: uint16(33103), + 3454: uint16(33161), + 3455: uint16(33199), + 3456: uint16(33306), + 3457: uint16(33542), + 3458: uint16(33583), + 3459: uint16(33674), + 3460: uint16(13770), + 3461: uint16(33896), + 3462: uint16(34474), + 3463: uint16(18682), + 3464: uint16(25574), + 3465: uint16(35158), + 3466: uint16(30728), + 3467: uint16(37461), + 3468: uint16(35256), + 3469: uint16(17394), + 3470: uint16(35303), + 3471: uint16(17375), + 3472: uint16(35304), + 3473: uint16(35654), + 3474: uint16(35796), + 3475: uint16(23032), + 3476: uint16(35849), + 3478: uint16(36805), + 3479: uint16(37100), + 3481: uint16(37136), + 3482: uint16(37180), + 3483: uint16(15863), + 3484: uint16(37214), + 3485: uint16(19146), + 3486: uint16(36816), + 3487: uint16(29327), + 3488: uint16(22155), + 3489: uint16(38119), + 3490: uint16(38377), + 3491: uint16(38320), + 3492: uint16(38328), + 3493: uint16(38706), + 3494: uint16(39121), + 3495: uint16(39241), + 3496: uint16(39274), + 3497: uint16(39363), + 3498: uint16(39464), + 3499: uint16(39694), + 3500: uint16(40282), + 3501: uint16(40347), + 3502: uint16(32415), + 3503: uint16(40696), + 3504: uint16(40739), + 3505: uint16(19620), + 3506: uint16(38215), + 3507: uint16(41619), + 3508: uint16(29090), + 3509: uint16(41727), + 3510: uint16(19857), + 3511: uint16(36882), + 3512: uint16(42443), + 3513: uint16(19868), + 3514: uint16(3228), + 3515: uint16(36798), + 3516: uint16(21953), + 3517: uint16(36794), + 3518: uint16(9392), + 3519: uint16(36793), + 3520: uint16(19091), + 3521: uint16(17673), + 3522: uint16(32383), + 3523: uint16(28502), + 3524: uint16(27313), + 3525: uint16(20202), + 3526: uint16(13540), + 3527: uint16(35628), + 3528: uint16(30877), + 3529: uint16(14138), + 3530: uint16(36480), + 3531: uint16(6133), + 3532: uint16(32804), + 3533: uint16(35692), + 3534: uint16(35737), + 3535: uint16(31294), + 3536: uint16(26287), + 3537: uint16(15851), + 3538: uint16(30293), + 3539: uint16(15543), + 3540: uint16(22069), + 3541: uint16(22870), + 3542: uint16(20122), + 3543: uint16(24193), + 3544: uint16(25176), + 3545: uint16(22207), + 3546: uint16(3693), + 3547: uint16(36366), + 3548: uint16(23405), + 3549: uint16(16008), + 3550: uint16(19614), + 3551: uint16(25566), + 3553: uint16(6134), + 3554: uint16(6267), + 3555: uint16(25904), + 3556: uint16(22061), + 3557: uint16(23626), + 3558: uint16(21530), + 3559: uint16(21265), + 3560: uint16(15814), + 3561: uint16(40344), + 3562: uint16(19581), + 3563: uint16(22050), + 3564: uint16(22046), + 3565: uint16(32585), + 3566: uint16(24280), + 3567: uint16(22901), + 3568: uint16(15680), + 3569: uint16(34672), + 3570: uint16(19996), + 3571: uint16(4074), + 3572: uint16(3401), + 3573: uint16(14010), + 3574: uint16(33047), + 3575: uint16(40286), + 3576: uint16(36120), + 3577: uint16(30267), + 3578: uint16(40005), + 3579: uint16(30286), + 3580: uint16(30649), + 3581: uint16(37701), + 3582: uint16(21554), + 3583: uint16(33096), + 3584: uint16(33527), + 3585: uint16(22053), + 3586: uint16(33074), + 3587: uint16(33816), + 3588: uint16(32957), + 3589: uint16(21994), + 3590: uint16(31074), + 3591: uint16(22083), + 3592: uint16(21526), + 3593: uint16(3741), + 3594: uint16(13774), + 3595: uint16(22021), + 3596: uint16(22001), + 3597: uint16(26353), + 3598: uint16(33506), + 3599: uint16(13869), + 3600: uint16(30004), + 3601: uint16(22000), + 3602: uint16(21946), + 3603: uint16(21655), + 3604: uint16(21874), + 3605: uint16(3137), + 3606: uint16(3222), + 3607: uint16(24272), + 3608: uint16(20808), + 3609: uint16(3702), + 3610: uint16(11362), + 3611: uint16(3746), + 3612: uint16(40619), + 3613: uint16(32090), + 3614: uint16(21982), + 3615: uint16(4213), + 3616: uint16(25245), + 3617: uint16(38765), + 3618: uint16(21652), + 3619: uint16(36045), + 3620: uint16(29174), + 3621: uint16(37238), + 3622: uint16(25596), + 3623: uint16(25529), + 3624: uint16(25598), + 3625: uint16(21865), + 3626: uint16(11075), + 3627: uint16(40050), + 3628: uint16(11955), + 3629: uint16(20890), + 3630: uint16(13535), + 3631: uint16(3495), + 3632: uint16(20903), + 3633: uint16(21581), + 3634: uint16(21790), + 3635: uint16(21779), + 3636: uint16(30310), + 3637: uint16(36397), + 3638: uint16(26762), + 3639: uint16(30129), + 3640: uint16(32950), + 3641: uint16(34820), + 3642: uint16(34694), + 3643: uint16(35015), + 3644: uint16(33206), + 3645: uint16(33820), + 3646: uint16(4289), + 3647: uint16(17644), + 3648: uint16(29444), + 3649: uint16(18182), + 3650: uint16(23440), + 3651: uint16(33547), + 3652: uint16(26771), + 3653: uint16(22139), + 3654: uint16(9972), + 3655: uint16(32047), + 3656: uint16(16803), + 3657: uint16(32115), + 3658: uint16(28368), + 3659: uint16(29366), + 3660: uint16(37232), + 3661: uint16(4569), + 3662: uint16(37384), + 3663: uint16(15612), + 3664: uint16(42665), + 3665: uint16(3756), + 3666: uint16(3833), + 3667: uint16(29286), + 3668: uint16(7330), + 3669: uint16(18254), + 3670: uint16(20418), + 3671: uint16(32761), + 3672: uint16(4075), + 3673: uint16(16634), + 3674: uint16(40029), + 3675: uint16(25887), + 3676: uint16(11680), + 3677: uint16(18675), + 3678: uint16(18400), + 3679: uint16(40316), + 3680: uint16(4076), + 3681: uint16(3594), + 3683: uint16(30115), + 3684: uint16(4077), + 3686: uint16(24648), + 3687: uint16(4487), + 3688: uint16(29091), + 3689: uint16(32398), + 3690: uint16(40272), + 3691: uint16(19994), + 3692: uint16(19972), + 3693: uint16(13687), + 3694: uint16(23309), + 3695: uint16(27826), + 3696: uint16(21351), + 3697: uint16(13996), + 3698: uint16(14812), + 3699: uint16(21373), + 3700: uint16(13989), + 3701: uint16(17944), + 3702: uint16(22682), + 3703: uint16(19310), + 3704: uint16(33325), + 3705: uint16(21579), + 3706: uint16(22442), + 3707: uint16(23189), + 3708: uint16(2425), + 3710: uint16(14930), + 3711: uint16(9317), + 3712: uint16(29556), + 3713: uint16(40620), + 3714: uint16(19721), + 3715: uint16(39917), + 3716: uint16(15614), + 3717: uint16(40752), + 3718: uint16(19547), + 3719: uint16(20393), + 3720: uint16(38302), + 3721: uint16(40926), + 3722: uint16(33884), + 3723: uint16(15798), + 3724: uint16(29362), + 3725: uint16(26547), + 3726: uint16(14112), + 3727: uint16(25390), + 3728: uint16(32037), + 3729: uint16(16119), + 3730: uint16(15916), + 3731: uint16(14890), + 3732: uint16(36872), + 3733: uint16(21196), + 3734: uint16(15988), + 3735: uint16(13946), + 3736: uint16(17897), + 3737: uint16(1166), + 3738: uint16(30272), + 3739: uint16(23280), + 3740: uint16(3766), + 3741: uint16(30842), + 3742: uint16(32558), + 3743: uint16(22695), + 3744: uint16(16575), + 3745: uint16(22140), + 3746: uint16(39819), + 3747: uint16(23924), + 3748: uint16(30292), + 3749: uint16(42036), + 3750: uint16(40581), + 3751: uint16(19681), + 3753: uint16(14331), + 3754: uint16(24857), + 3755: uint16(12506), + 3756: uint16(17394), + 3758: uint16(22109), + 3759: uint16(4777), + 3760: uint16(22439), + 3761: uint16(18787), + 3762: uint16(40454), + 3763: uint16(21044), + 3764: uint16(28846), + 3765: uint16(13741), + 3767: uint16(40316), + 3768: uint16(31830), + 3769: uint16(39737), + 3770: uint16(22494), + 3771: uint16(5996), + 3772: uint16(23635), + 3773: uint16(25811), + 3774: uint16(38096), + 3775: uint16(25397), + 3776: uint16(29028), + 3777: uint16(34477), + 3778: uint16(3368), + 3779: uint16(27938), + 3780: uint16(19170), + 3781: uint16(3441), + 3783: uint16(20990), + 3784: uint16(7951), + 3785: uint16(23950), + 3786: uint16(38659), + 3787: uint16(7633), + 3788: uint16(40577), + 3789: uint16(36940), + 3790: uint16(31519), + 3791: uint16(39682), + 3792: uint16(23761), + 3793: uint16(31651), + 3794: uint16(25192), + 3795: uint16(25397), + 3796: uint16(39679), + 3797: uint16(31695), + 3798: uint16(39722), + 3799: uint16(31870), + 3801: uint16(31810), + 3802: uint16(31878), + 3803: uint16(39957), + 3804: uint16(31740), + 3805: uint16(39689), + 3807: uint16(39963), + 3808: uint16(18750), + 3809: uint16(40794), + 3810: uint16(21875), + 3811: uint16(23491), + 3812: uint16(20477), + 3813: uint16(40600), + 3814: uint16(20466), + 3815: uint16(21088), + 3816: uint16(15878), + 3817: uint16(21201), + 3818: uint16(22375), + 3819: uint16(20566), + 3820: uint16(22967), + 3821: uint16(24082), + 3822: uint16(38856), + 3823: uint16(40363), + 3824: uint16(36700), + 3825: uint16(21609), + 3826: uint16(38836), + 3827: uint16(39232), + 3828: uint16(38842), + 3829: uint16(21292), + 3830: uint16(24880), + 3831: uint16(26924), + 3832: uint16(21466), + 3833: uint16(39946), + 3834: uint16(40194), + 3835: uint16(19515), + 3836: uint16(38465), + 3837: uint16(27008), + 3838: uint16(20646), + 3839: uint16(30022), + 3840: uint16(5997), + 3841: uint16(39386), + 3842: uint16(21107), + 3844: uint16(37209), + 3845: uint16(38529), + 3846: uint16(37212), + 3848: uint16(37201), + 3849: uint16(36503), + 3850: uint16(25471), + 3851: uint16(27939), + 3852: uint16(27338), + 3853: uint16(22033), + 3854: uint16(37262), + 3855: uint16(30074), + 3856: uint16(25221), + 3857: uint16(1020), + 3858: uint16(29519), + 3859: uint16(31856), + 3860: uint16(23585), + 3861: uint16(15613), + 3863: uint16(18713), + 3864: uint16(30422), + 3865: uint16(39837), + 3866: uint16(20010), + 3867: uint16(3284), + 3868: uint16(33726), + 3869: uint16(34882), + 3871: uint16(23626), + 3872: uint16(27072), + 3874: uint16(22394), + 3875: uint16(21023), + 3876: uint16(24053), + 3877: uint16(20174), + 3878: uint16(27697), + 3879: uint16(498), + 3880: uint16(20281), + 3881: uint16(21660), + 3882: uint16(21722), + 3883: uint16(21146), + 3884: uint16(36226), + 3885: uint16(13822), + 3887: uint16(13811), + 3889: uint16(27474), + 3890: uint16(37244), + 3891: uint16(40869), + 3892: uint16(39831), + 3893: uint16(38958), + 3894: uint16(39092), + 3895: uint16(39610), + 3896: uint16(40616), + 3897: uint16(40580), + 3898: uint16(29050), + 3899: uint16(31508), + 3901: uint16(27642), + 3902: uint16(34840), + 3903: uint16(32632), + 3905: uint16(22048), + 3906: uint16(42570), + 3907: uint16(36471), + 3908: uint16(40787), + 3910: uint16(36308), + 3911: uint16(36431), + 3912: uint16(40476), + 3913: uint16(36353), + 3914: uint16(25218), + 3915: uint16(33661), + 3916: uint16(36392), + 3917: uint16(36469), + 3918: uint16(31443), + 3919: uint16(19063), + 3920: uint16(31294), + 3921: uint16(30936), + 3922: uint16(27882), + 3923: uint16(35431), + 3924: uint16(30215), + 3925: uint16(35418), + 3926: uint16(40742), + 3927: uint16(27854), + 3928: uint16(34774), + 3929: uint16(30147), + 3930: uint16(41650), + 3931: uint16(30803), + 3932: uint16(63552), + 3933: uint16(36108), + 3934: uint16(29410), + 3935: uint16(29553), + 3936: uint16(35629), + 3937: uint16(29442), + 3938: uint16(29937), + 3939: uint16(36075), + 3940: uint16(19131), + 3941: uint16(34351), + 3942: uint16(24506), + 3943: uint16(34976), + 3944: uint16(17591), + 3946: uint16(6203), + 3947: uint16(28165), + 3949: uint16(35454), + 3950: uint16(9499), + 3952: uint16(24829), + 3953: uint16(30311), + 3954: uint16(39639), + 3955: uint16(40260), + 3956: uint16(37742), + 3957: uint16(39823), + 3958: uint16(34805), + 3961: uint16(36087), + 3962: uint16(29484), + 3963: uint16(38689), + 3964: uint16(39856), + 3965: uint16(13782), + 3966: uint16(29362), + 3967: uint16(19463), + 3968: uint16(31825), + 3969: uint16(39242), + 3970: uint16(24921), + 3971: uint16(24921), + 3972: uint16(19460), + 3973: uint16(40598), + 3974: uint16(24957), + 3976: uint16(22367), + 3977: uint16(24943), + 3978: uint16(25254), + 3979: uint16(25145), + 3981: uint16(14940), + 3982: uint16(25058), + 3983: uint16(21418), + 3984: uint16(13301), + 3985: uint16(25444), + 3986: uint16(26626), + 3987: uint16(13778), + 3988: uint16(23895), + 3989: uint16(35778), + 3990: uint16(36826), + 3991: uint16(36409), + 3993: uint16(20697), + 3994: uint16(7494), + 3995: uint16(30982), + 3996: uint16(21298), + 3997: uint16(38456), + 3998: uint16(3899), + 3999: uint16(16485), + 4001: uint16(30718), + 4003: uint16(31938), + 4004: uint16(24346), + 4005: uint16(31962), + 4006: uint16(31277), + 4007: uint16(32870), + 4008: uint16(32867), + 4009: uint16(32077), + 4010: uint16(29957), + 4011: uint16(29938), + 4012: uint16(35220), + 4013: uint16(33306), + 4014: uint16(26380), + 4015: uint16(32866), + 4016: uint16(29830), + 4017: uint16(32859), + 4018: uint16(29936), + 4019: uint16(33027), + 4020: uint16(30500), + 4021: uint16(35209), + 4022: uint16(26572), + 4023: uint16(30035), + 4024: uint16(28369), + 4025: uint16(34729), + 4026: uint16(34766), + 4027: uint16(33224), + 4028: uint16(34700), + 4029: uint16(35401), + 4030: uint16(36013), + 4031: uint16(35651), + 4032: uint16(30507), + 4033: uint16(29944), + 4034: uint16(34010), + 4035: uint16(13877), + 4036: uint16(27058), + 4037: uint16(36262), + 4039: uint16(35241), + 4041: uint16(28089), + 4042: uint16(34753), + 4043: uint16(16401), + 4044: uint16(29927), + 4045: uint16(15835), + 4046: uint16(29046), + 4047: uint16(24740), + 4048: uint16(24988), + 4049: uint16(15569), + 4051: uint16(24695), + 4053: uint16(32625), + 4054: uint16(35629), + 4056: uint16(24809), + 4057: uint16(19326), + 4058: uint16(21024), + 4059: uint16(15384), + 4060: uint16(15559), + 4061: uint16(24279), + 4062: uint16(30294), + 4063: uint16(21809), + 4064: uint16(6468), + 4065: uint16(4862), + 4066: uint16(39171), + 4067: uint16(28124), + 4068: uint16(28845), + 4069: uint16(23745), + 4070: uint16(25005), + 4071: uint16(35343), + 4072: uint16(13943), + 4073: uint16(238), + 4074: uint16(26694), + 4075: uint16(20238), + 4076: uint16(17762), + 4077: uint16(23327), + 4078: uint16(25420), + 4079: uint16(40784), + 4080: uint16(40614), + 4081: uint16(25195), + 4082: uint16(1351), + 4083: uint16(37595), + 4084: uint16(1503), + 4085: uint16(16325), + 4086: uint16(34124), + 4087: uint16(17077), + 4088: uint16(29679), + 4089: uint16(20917), + 4090: uint16(13897), + 4091: uint16(18754), + 4092: uint16(35300), + 4093: uint16(37700), + 4094: uint16(6619), + 4095: uint16(33518), + 4096: uint16(15560), + 4097: uint16(30780), + 4098: uint16(26436), + 4099: uint16(25311), + 4100: uint16(18739), + 4101: uint16(35242), + 4102: uint16(672), + 4103: uint16(27571), + 4104: uint16(4869), + 4105: uint16(20395), + 4106: uint16(9453), + 4107: uint16(20488), + 4108: uint16(27945), + 4109: uint16(31364), + 4110: uint16(13824), + 4111: uint16(19121), + 4112: uint16(9491), + 4114: uint16(894), + 4115: uint16(24484), + 4116: uint16(896), + 4117: uint16(839), + 4118: uint16(28379), + 4119: uint16(1055), + 4121: uint16(20737), + 4122: uint16(13434), + 4123: uint16(20750), + 4124: uint16(39020), + 4125: uint16(14147), + 4126: uint16(33814), + 4127: uint16(18852), + 4128: uint16(1159), + 4129: uint16(20832), + 4130: uint16(13236), + 4131: uint16(20842), + 4132: uint16(3071), + 4133: uint16(8444), + 4134: uint16(741), + 4135: uint16(9520), + 4136: uint16(1422), + 4137: uint16(12851), + 4138: uint16(6531), + 4139: uint16(23426), + 4140: uint16(34685), + 4141: uint16(1459), + 4142: uint16(15513), + 4143: uint16(20914), + 4144: uint16(20920), + 4145: uint16(40244), + 4146: uint16(20937), + 4147: uint16(20943), + 4148: uint16(20945), + 4149: uint16(15580), + 4150: uint16(20947), + 4151: uint16(19110), + 4152: uint16(20915), + 4153: uint16(20962), + 4154: uint16(21314), + 4155: uint16(20973), + 4156: uint16(33741), + 4157: uint16(26942), + 4158: uint16(14125), + 4159: uint16(24443), + 4160: uint16(21003), + 4161: uint16(21030), + 4162: uint16(21052), + 4163: uint16(21173), + 4164: uint16(21079), + 4165: uint16(21140), + 4166: uint16(21177), + 4167: uint16(21189), + 4168: uint16(31765), + 4169: uint16(34114), + 4170: uint16(21216), + 4171: uint16(34317), + 4172: uint16(27411), + 4174: uint16(35550), + 4175: uint16(21833), + 4176: uint16(28377), + 4177: uint16(16256), + 4178: uint16(2388), + 4179: uint16(16364), + 4180: uint16(21299), + 4182: uint16(3042), + 4183: uint16(27851), + 4184: uint16(5926), + 4185: uint16(26651), + 4186: uint16(29653), + 4187: uint16(24650), + 4188: uint16(16042), + 4189: uint16(14540), + 4190: uint16(5864), + 4191: uint16(29149), + 4192: uint16(17570), + 4193: uint16(21357), + 4194: uint16(21364), + 4195: uint16(34475), + 4196: uint16(21374), + 4198: uint16(5526), + 4199: uint16(5651), + 4200: uint16(30694), + 4201: uint16(21395), + 4202: uint16(35483), + 4203: uint16(21408), + 4204: uint16(21419), + 4205: uint16(21422), + 4206: uint16(29607), + 4207: uint16(22386), + 4208: uint16(16217), + 4209: uint16(29596), + 4210: uint16(21441), + 4211: uint16(21445), + 4212: uint16(27721), + 4213: uint16(20041), + 4214: uint16(22526), + 4215: uint16(21465), + 4216: uint16(15019), + 4217: uint16(2959), + 4218: uint16(21472), + 4219: uint16(16363), + 4220: uint16(11683), + 4221: uint16(21494), + 4222: uint16(3191), + 4223: uint16(21523), + 4224: uint16(28793), + 4225: uint16(21803), + 4226: uint16(26199), + 4227: uint16(27995), + 4228: uint16(21613), + 4229: uint16(27475), + 4230: uint16(3444), + 4231: uint16(21853), + 4232: uint16(21647), + 4233: uint16(21668), + 4234: uint16(18342), + 4235: uint16(5901), + 4236: uint16(3805), + 4237: uint16(15796), + 4238: uint16(3405), + 4239: uint16(35260), + 4240: uint16(9880), + 4241: uint16(21831), + 4242: uint16(19693), + 4243: uint16(21551), + 4244: uint16(29719), + 4245: uint16(21894), + 4246: uint16(21929), + 4248: uint16(6359), + 4249: uint16(16442), + 4250: uint16(17746), + 4251: uint16(17461), + 4252: uint16(26291), + 4253: uint16(4276), + 4254: uint16(22071), + 4255: uint16(26317), + 4256: uint16(12938), + 4257: uint16(26276), + 4258: uint16(26285), + 4259: uint16(22093), + 4260: uint16(22095), + 4261: uint16(30961), + 4262: uint16(22257), + 4263: uint16(38791), + 4264: uint16(21502), + 4265: uint16(22272), + 4266: uint16(22255), + 4267: uint16(22253), + 4268: uint16(35686), + 4269: uint16(13859), + 4270: uint16(4687), + 4271: uint16(22342), + 4272: uint16(16805), + 4273: uint16(27758), + 4274: uint16(28811), + 4275: uint16(22338), + 4276: uint16(14001), + 4277: uint16(27774), + 4278: uint16(22502), + 4279: uint16(5142), + 4280: uint16(22531), + 4281: uint16(5204), + 4282: uint16(17251), + 4283: uint16(22566), + 4284: uint16(19445), + 4285: uint16(22620), + 4286: uint16(22698), + 4287: uint16(13665), + 4288: uint16(22752), + 4289: uint16(22748), + 4290: uint16(4668), + 4291: uint16(22779), + 4292: uint16(23551), + 4293: uint16(22339), + 4294: uint16(41296), + 4295: uint16(17016), + 4296: uint16(37843), + 4297: uint16(13729), + 4298: uint16(22815), + 4299: uint16(26790), + 4300: uint16(14019), + 4301: uint16(28249), + 4302: uint16(5694), + 4303: uint16(23076), + 4304: uint16(21843), + 4305: uint16(5778), + 4306: uint16(34053), + 4307: uint16(22985), + 4308: uint16(3406), + 4309: uint16(27777), + 4310: uint16(27946), + 4311: uint16(6108), + 4312: uint16(23001), + 4313: uint16(6139), + 4314: uint16(6066), + 4315: uint16(28070), + 4316: uint16(28017), + 4317: uint16(6184), + 4318: uint16(5845), + 4319: uint16(23033), + 4320: uint16(28229), + 4321: uint16(23211), + 4322: uint16(23139), + 4323: uint16(14054), + 4324: uint16(18857), + 4326: uint16(14088), + 4327: uint16(23190), + 4328: uint16(29797), + 4329: uint16(23251), + 4330: uint16(28577), + 4331: uint16(9556), + 4332: uint16(15749), + 4333: uint16(6417), + 4334: uint16(14130), + 4335: uint16(5816), + 4336: uint16(24195), + 4337: uint16(21200), + 4338: uint16(23414), + 4339: uint16(25992), + 4340: uint16(23420), + 4341: uint16(31246), + 4342: uint16(16388), + 4343: uint16(18525), + 4344: uint16(516), + 4345: uint16(23509), + 4346: uint16(24928), + 4347: uint16(6708), + 4348: uint16(22988), + 4349: uint16(1445), + 4350: uint16(23539), + 4351: uint16(23453), + 4352: uint16(19728), + 4353: uint16(23557), + 4354: uint16(6980), + 4355: uint16(23571), + 4356: uint16(29646), + 4357: uint16(23572), + 4358: uint16(7333), + 4359: uint16(27432), + 4360: uint16(23625), + 4361: uint16(18653), + 4362: uint16(23685), + 4363: uint16(23785), + 4364: uint16(23791), + 4365: uint16(23947), + 4366: uint16(7673), + 4367: uint16(7735), + 4368: uint16(23824), + 4369: uint16(23832), + 4370: uint16(23878), + 4371: uint16(7844), + 4372: uint16(23738), + 4373: uint16(24023), + 4374: uint16(33532), + 4375: uint16(14381), + 4376: uint16(18689), + 4377: uint16(8265), + 4378: uint16(8563), + 4379: uint16(33415), + 4380: uint16(14390), + 4381: uint16(15298), + 4382: uint16(24110), + 4383: uint16(27274), + 4385: uint16(24186), + 4386: uint16(17596), + 4387: uint16(3283), + 4388: uint16(21414), + 4389: uint16(20151), + 4391: uint16(21416), + 4392: uint16(6001), + 4393: uint16(24073), + 4394: uint16(24308), + 4395: uint16(33922), + 4396: uint16(24313), + 4397: uint16(24315), + 4398: uint16(14496), + 4399: uint16(24316), + 4400: uint16(26686), + 4401: uint16(37915), + 4402: uint16(24333), + 4403: uint16(449), + 4404: uint16(63636), + 4405: uint16(15070), + 4406: uint16(18606), + 4407: uint16(4922), + 4408: uint16(24378), + 4409: uint16(26760), + 4410: uint16(9168), + 4412: uint16(9329), + 4413: uint16(24419), + 4414: uint16(38845), + 4415: uint16(28270), + 4416: uint16(24434), + 4417: uint16(37696), + 4418: uint16(35382), + 4419: uint16(24487), + 4420: uint16(23990), + 4421: uint16(15711), + 4422: uint16(21072), + 4423: uint16(8042), + 4424: uint16(28920), + 4425: uint16(9832), + 4426: uint16(37334), + 4427: uint16(670), + 4428: uint16(35369), + 4429: uint16(24625), + 4430: uint16(26245), + 4431: uint16(6263), + 4432: uint16(14691), + 4433: uint16(15815), + 4434: uint16(13881), + 4435: uint16(22416), + 4436: uint16(10164), + 4437: uint16(31089), + 4438: uint16(15936), + 4439: uint16(24734), + 4441: uint16(24755), + 4442: uint16(18818), + 4443: uint16(18831), + 4444: uint16(31315), + 4445: uint16(29860), + 4446: uint16(20705), + 4447: uint16(23200), + 4448: uint16(24932), + 4449: uint16(33828), + 4450: uint16(24898), + 4451: uint16(63654), + 4452: uint16(28370), + 4453: uint16(24961), + 4454: uint16(20980), + 4455: uint16(1622), + 4456: uint16(24967), + 4457: uint16(23466), + 4458: uint16(16311), + 4459: uint16(10335), + 4460: uint16(25043), + 4461: uint16(35741), + 4462: uint16(39261), + 4463: uint16(25040), + 4464: uint16(14642), + 4465: uint16(10624), + 4466: uint16(10433), + 4467: uint16(24611), + 4468: uint16(24924), + 4469: uint16(25886), + 4470: uint16(25483), + 4471: uint16(280), + 4472: uint16(25285), + 4473: uint16(6000), + 4474: uint16(25301), + 4475: uint16(11789), + 4476: uint16(25452), + 4477: uint16(18911), + 4478: uint16(14871), + 4479: uint16(25656), + 4480: uint16(25592), + 4481: uint16(5006), + 4482: uint16(6140), + 4484: uint16(28554), + 4485: uint16(11830), + 4486: uint16(38932), + 4487: uint16(16524), + 4488: uint16(22301), + 4489: uint16(25825), + 4490: uint16(25829), + 4491: uint16(38011), + 4492: uint16(14950), + 4493: uint16(25658), + 4494: uint16(14935), + 4495: uint16(25933), + 4496: uint16(28438), + 4497: uint16(18984), + 4498: uint16(18979), + 4499: uint16(25989), + 4500: uint16(25965), + 4501: uint16(25951), + 4502: uint16(12414), + 4503: uint16(26037), + 4504: uint16(18752), + 4505: uint16(19255), + 4506: uint16(26065), + 4507: uint16(16600), + 4508: uint16(6185), + 4509: uint16(26080), + 4510: uint16(26083), + 4511: uint16(24543), + 4512: uint16(13312), + 4513: uint16(26136), + 4514: uint16(12791), + 4515: uint16(12792), + 4516: uint16(26180), + 4517: uint16(12708), + 4518: uint16(12709), + 4519: uint16(26187), + 4520: uint16(3701), + 4521: uint16(26215), + 4522: uint16(20966), + 4523: uint16(26227), + 4525: uint16(7741), + 4526: uint16(12849), + 4527: uint16(34292), + 4528: uint16(12744), + 4529: uint16(21267), + 4530: uint16(30661), + 4531: uint16(10487), + 4532: uint16(39332), + 4533: uint16(26370), + 4534: uint16(17308), + 4535: uint16(18977), + 4536: uint16(15147), + 4537: uint16(27130), + 4538: uint16(14274), + 4540: uint16(26471), + 4541: uint16(26466), + 4542: uint16(16845), + 4543: uint16(37101), + 4544: uint16(26583), + 4545: uint16(17641), + 4546: uint16(26658), + 4547: uint16(28240), + 4548: uint16(37436), + 4549: uint16(26625), + 4550: uint16(13286), + 4551: uint16(28064), + 4552: uint16(26717), + 4553: uint16(13423), + 4554: uint16(27105), + 4555: uint16(27147), + 4556: uint16(35551), + 4557: uint16(26995), + 4558: uint16(26819), + 4559: uint16(13773), + 4560: uint16(26881), + 4561: uint16(26880), + 4562: uint16(15666), + 4563: uint16(14849), + 4564: uint16(13884), + 4565: uint16(15232), + 4566: uint16(26540), + 4567: uint16(26977), + 4568: uint16(35402), + 4569: uint16(17148), + 4570: uint16(26934), + 4571: uint16(27032), + 4572: uint16(15265), + 4573: uint16(969), + 4574: uint16(33635), + 4575: uint16(20624), + 4576: uint16(27129), + 4577: uint16(13913), + 4578: uint16(8490), + 4579: uint16(27205), + 4580: uint16(14083), + 4581: uint16(27293), + 4582: uint16(15347), + 4583: uint16(26545), + 4584: uint16(27336), + 4585: uint16(37276), + 4586: uint16(15373), + 4587: uint16(27421), + 4588: uint16(2339), + 4589: uint16(24798), + 4590: uint16(27445), + 4591: uint16(27508), + 4592: uint16(10189), + 4593: uint16(28341), + 4594: uint16(15067), + 4595: uint16(949), + 4596: uint16(6488), + 4597: uint16(14144), + 4598: uint16(21537), + 4599: uint16(15194), + 4600: uint16(27617), + 4601: uint16(16124), + 4602: uint16(27612), + 4603: uint16(27703), + 4604: uint16(9355), + 4605: uint16(18673), + 4606: uint16(27473), + 4607: uint16(27738), + 4608: uint16(33318), + 4609: uint16(27769), + 4610: uint16(15804), + 4611: uint16(17605), + 4612: uint16(15805), + 4613: uint16(16804), + 4614: uint16(18700), + 4615: uint16(18688), + 4616: uint16(15561), + 4617: uint16(14053), + 4618: uint16(15595), + 4619: uint16(3378), + 4620: uint16(39811), + 4621: uint16(12793), + 4622: uint16(9361), + 4623: uint16(32655), + 4624: uint16(26679), + 4625: uint16(27941), + 4626: uint16(28065), + 4627: uint16(28139), + 4628: uint16(28054), + 4629: uint16(27996), + 4630: uint16(28284), + 4631: uint16(28420), + 4632: uint16(18815), + 4633: uint16(16517), + 4634: uint16(28274), + 4635: uint16(34099), + 4636: uint16(28532), + 4637: uint16(20935), + 4640: uint16(33838), + 4641: uint16(35617), + 4643: uint16(15919), + 4644: uint16(29779), + 4645: uint16(16258), + 4646: uint16(31180), + 4647: uint16(28239), + 4648: uint16(23185), + 4649: uint16(12363), + 4650: uint16(28664), + 4651: uint16(14093), + 4652: uint16(28573), + 4653: uint16(15920), + 4654: uint16(28410), + 4655: uint16(5271), + 4656: uint16(16445), + 4657: uint16(17749), + 4658: uint16(37872), + 4659: uint16(28484), + 4660: uint16(28508), + 4661: uint16(15694), + 4662: uint16(28532), + 4663: uint16(37232), + 4664: uint16(15675), + 4665: uint16(28575), + 4666: uint16(16708), + 4667: uint16(28627), + 4668: uint16(16529), + 4669: uint16(16725), + 4670: uint16(16441), + 4671: uint16(16368), + 4672: uint16(16308), + 4673: uint16(16703), + 4674: uint16(20959), + 4675: uint16(16726), + 4676: uint16(16727), + 4677: uint16(16704), + 4678: uint16(25053), + 4679: uint16(28747), + 4680: uint16(28798), + 4681: uint16(28839), + 4682: uint16(28801), + 4683: uint16(28876), + 4684: uint16(28885), + 4685: uint16(28886), + 4686: uint16(28895), + 4687: uint16(16644), + 4688: uint16(15848), + 4689: uint16(29108), + 4690: uint16(29078), + 4691: uint16(17015), + 4692: uint16(28971), + 4693: uint16(28997), + 4694: uint16(23176), + 4695: uint16(29002), + 4697: uint16(23708), + 4698: uint16(17253), + 4699: uint16(29007), + 4700: uint16(37730), + 4701: uint16(17089), + 4702: uint16(28972), + 4703: uint16(17498), + 4704: uint16(18983), + 4705: uint16(18978), + 4706: uint16(29114), + 4707: uint16(35816), + 4708: uint16(28861), + 4709: uint16(29198), + 4710: uint16(37954), + 4711: uint16(29205), + 4712: uint16(22801), + 4713: uint16(37955), + 4714: uint16(29220), + 4715: uint16(37697), + 4716: uint16(22021), + 4717: uint16(29230), + 4718: uint16(29248), + 4719: uint16(18804), + 4720: uint16(26813), + 4721: uint16(29269), + 4722: uint16(29271), + 4723: uint16(15957), + 4724: uint16(12356), + 4725: uint16(26637), + 4726: uint16(28477), + 4727: uint16(29314), + 4729: uint16(29483), + 4730: uint16(18467), + 4731: uint16(34859), + 4732: uint16(18669), + 4733: uint16(34820), + 4734: uint16(29480), + 4735: uint16(29486), + 4736: uint16(29647), + 4737: uint16(29610), + 4738: uint16(3130), + 4739: uint16(27182), + 4740: uint16(29641), + 4741: uint16(29769), + 4742: uint16(16866), + 4743: uint16(5863), + 4744: uint16(18980), + 4745: uint16(26147), + 4746: uint16(14021), + 4747: uint16(18871), + 4748: uint16(18829), + 4749: uint16(18939), + 4750: uint16(29687), + 4751: uint16(29717), + 4752: uint16(26883), + 4753: uint16(18982), + 4754: uint16(29753), + 4755: uint16(1475), + 4756: uint16(16087), + 4758: uint16(10413), + 4759: uint16(29792), + 4760: uint16(36530), + 4761: uint16(29767), + 4762: uint16(29668), + 4763: uint16(29814), + 4764: uint16(33721), + 4765: uint16(29804), + 4766: uint16(14128), + 4767: uint16(29812), + 4768: uint16(37873), + 4769: uint16(27180), + 4770: uint16(29826), + 4771: uint16(18771), + 4772: uint16(19084), + 4773: uint16(16735), + 4774: uint16(19065), + 4775: uint16(35727), + 4776: uint16(23366), + 4777: uint16(35843), + 4778: uint16(6302), + 4779: uint16(29896), + 4780: uint16(6536), + 4781: uint16(29966), + 4783: uint16(29982), + 4784: uint16(36569), + 4785: uint16(6731), + 4786: uint16(23511), + 4787: uint16(36524), + 4788: uint16(37765), + 4789: uint16(30029), + 4790: uint16(30026), + 4791: uint16(30055), + 4792: uint16(30062), + 4793: uint16(20354), + 4794: uint16(16132), + 4795: uint16(19731), + 4796: uint16(30094), + 4797: uint16(29789), + 4798: uint16(30110), + 4799: uint16(30132), + 4800: uint16(30210), + 4801: uint16(30252), + 4802: uint16(30289), + 4803: uint16(30287), + 4804: uint16(30319), + 4805: uint16(30326), + 4806: uint16(25589), + 4807: uint16(30352), + 4808: uint16(33263), + 4809: uint16(14328), + 4810: uint16(26897), + 4811: uint16(26894), + 4812: uint16(30369), + 4813: uint16(30373), + 4814: uint16(30391), + 4815: uint16(30412), + 4816: uint16(28575), + 4817: uint16(33890), + 4818: uint16(20637), + 4819: uint16(20861), + 4820: uint16(7708), + 4821: uint16(30494), + 4822: uint16(30502), + 4823: uint16(30528), + 4824: uint16(25775), + 4825: uint16(21024), + 4826: uint16(30552), + 4827: uint16(12972), + 4828: uint16(30639), + 4829: uint16(35172), + 4830: uint16(35176), + 4831: uint16(5825), + 4832: uint16(30708), + 4834: uint16(4982), + 4835: uint16(18962), + 4836: uint16(26826), + 4837: uint16(30895), + 4838: uint16(30919), + 4839: uint16(30931), + 4840: uint16(38565), + 4841: uint16(31022), + 4842: uint16(21984), + 4843: uint16(30935), + 4844: uint16(31028), + 4845: uint16(30897), + 4846: uint16(30220), + 4847: uint16(36792), + 4848: uint16(34948), + 4849: uint16(35627), + 4850: uint16(24707), + 4851: uint16(9756), + 4852: uint16(31110), + 4853: uint16(35072), + 4854: uint16(26882), + 4855: uint16(31104), + 4856: uint16(22615), + 4857: uint16(31133), + 4858: uint16(31545), + 4859: uint16(31036), + 4860: uint16(31145), + 4861: uint16(28202), + 4862: uint16(28966), + 4863: uint16(16040), + 4864: uint16(31174), + 4865: uint16(37133), + 4866: uint16(31188), + 4867: uint16(1312), + 4868: uint16(17503), + 4869: uint16(21007), + 4870: uint16(47234), + 4871: uint16(248), + 4872: uint16(16384), + 4873: uint16(43296), + 4874: uint16(1102), + 4877: uint16(2868), + 4878: uint16(1), + 4886: uint16(3072), + 4887: uint16(64), + 4891: uint16(1024), + 4892: uint16(88), + 4893: uint16(60), + 4896: uint16(23680), + 4897: uint16(56493), + 4898: uint16(48115), + 4899: uint16(17353), + 4900: uint16(60910), + 4901: uint16(4004), + 4902: uint16(49446), + 4903: uint16(30363), + 4904: uint16(61426), + 4905: uint16(64478), + 4906: uint16(63482), + 4907: uint16(12815), + 4908: uint16(44868), + 4909: uint16(61438), + 4910: uint16(65277), + 4911: uint16(24593), + 4912: uint16(176), + 4913: uint16(8448), + 4914: uint16(33049), + 4915: uint16(4128), + 4916: uint16(43144), + 4917: uint16(8544), + 4918: uint16(9321), + 4919: uint16(17408), + 4920: uint16(50313), + 4922: uint16(16387), + 4923: uint16(53), + 4924: uint16(33859), + 4925: uint16(20785), + 4926: uint16(26771), + 4927: uint16(514), + 4933: uint16(16384), + 4934: uint16(256), + 4935: uint16(44160), + 4936: uint16(33380), + 4937: uint16(35904), + 4938: uint16(37025), + 4939: uint16(20484), + 4940: uint16(54368), + 4941: uint16(53760), + 4942: uint16(6186), + 4943: uint16(26781), + 4944: uint16(38709), + 4945: uint16(55375), + 4946: uint16(8440), + 4947: uint16(33476), + 4948: uint16(10268), + 4949: uint16(30082), + 4950: uint16(660), + 4951: uint16(16440), + 4952: uint16(41376), + 4953: uint16(4293), + 4954: uint16(19825), + 4955: uint16(3524), + 4956: uint16(47512), + 4957: uint16(23390), + 4958: uint16(17153), + 4959: uint16(39327), + 4960: uint16(30723), + 4961: uint16(57888), + 4962: uint16(2079), + 4963: uint16(393), + 4964: uint16(16585), + 4965: uint16(775), + 4966: uint16(39437), + 4967: uint16(21136), + 4968: uint16(20433), + 4969: uint16(892), + 4970: uint16(8450), + 4971: uint16(49184), + 4972: uint16(4974), + 4973: uint16(46467), + 4974: uint16(62939), + 4975: uint16(30693), + 4976: uint16(20368), + 4977: uint16(39447), + 4978: uint16(5942), + 4979: uint16(12), + 4980: uint16(47726), + 4981: uint16(12041), + 4982: uint16(21600), + 4983: uint16(7680), + 4984: uint16(26744), + 4985: uint16(28706), + 4986: uint16(40534), + 4987: uint16(62245), + 4988: uint16(46990), + 4989: uint16(2839), + 4990: uint16(59119), + 4991: uint16(6007), + 4992: uint16(7003), + 4993: uint16(4289), + 4994: uint16(36248), + 4995: uint16(6162), + 4996: uint16(53174), + 4997: uint16(12545), + 4998: uint16(6770), + 4999: uint16(11355), + 5000: uint16(49334), + 5001: uint16(57888), + 5002: uint16(23747), + 5003: uint16(7042), + 5004: uint16(56032), + 5005: uint16(34254), + 5006: uint16(16598), + 5007: uint16(21673), + 5008: uint16(53259), + 5009: uint16(18447), + 5010: uint16(16452), + 5011: uint16(2320), + 5012: uint16(16596), + 5013: uint16(15278), + 5014: uint16(7780), + 5015: uint16(11076), + 5016: uint16(2071), + 5017: uint16(33414), + 5018: uint16(6198), + 5019: uint16(35232), + 5020: uint16(40167), + 5021: uint16(2139), + 5022: uint16(900), + 5023: uint16(55810), + 5024: uint16(60560), + 5025: uint16(34779), + 5026: uint16(49029), + 5027: uint16(44450), + 5028: uint16(36509), + 5029: uint16(39069), + 5030: uint16(9504), + 5031: uint16(70), + 5032: uint16(40774), + 5033: uint16(58239), + 5034: uint16(51669), + 5035: uint16(62596), + 5036: uint16(19926), + 5037: uint16(58118), + 5038: uint16(6326), + 5039: uint16(2322), + 5041: uint16(1024), + 5043: uint16(32), + 5045: uint16(512), + 5050: uint16(8192), + 5057: uint16(8), + 5058: uint16(36352), + 5059: uint16(28280), + 5060: uint16(16223), + 5061: uint16(56702), + 5062: uint16(63293), + 5063: uint16(39932), + 5064: uint16(44796), + 5065: uint16(65490), + 5066: uint16(27535), + 5067: uint16(59377), + 5068: uint16(47807), + 5069: uint16(28334), + 5070: uint16(61207), + 5071: uint16(42972), + 5072: uint16(46654), + 5073: uint16(30645), + 5074: uint16(37577), + 5075: uint16(42455), + 5076: uint16(19126), + 5077: uint16(39790), + 5078: uint16(33209), + 5079: uint16(26445), + 5080: uint16(21758), + 5081: uint16(39921), + 5082: uint16(65122), + 5083: uint16(21103), + 5084: uint16(14039), + 5085: uint16(49150), + 5086: uint16(17705), + 5087: uint16(63873), + 5088: uint16(26045), + 5089: uint16(17062), + 5090: uint16(57), + 5091: uint16(16896), + 5092: uint16(36704), + 5093: uint16(37888), + 5094: uint16(16448), + 5095: uint16(45010), + 5096: uint16(53719), + 5097: uint16(219), + 5098: uint16(39072), + 5099: uint16(31666), + 5100: uint16(20998), + 5101: uint16(38944), + 5102: uint16(51222), + 5103: uint16(2365), + 5105: uint16(1), + 5107: uint16(2561), + 5108: uint16(2226), + 5109: uint16(128), + 5111: uint16(34820), + 5112: uint16(5152), + 5113: uint16(19472), + 5115: uint16(4), + 5116: uint16(17569), + 5117: uint16(16), + 5118: uint16(321), + 5119: uint16(2048), + 5120: uint16(61504), + 5121: uint16(20447), + 5122: uint16(22582), + 5123: uint16(62961), + 5124: uint16(32949), + 5125: uint16(26613), + 5126: uint16(16512), + 5127: uint16(20480), + 5128: uint16(16718), + 5129: uint16(33992), + 5130: uint16(23040), + 5131: uint16(55392), + 5132: uint16(11009), + 5133: uint16(20481), + 5134: uint16(5793), + 5135: uint16(16580), + 5136: uint16(28402), + 5137: uint16(44049), + 5138: uint16(14624), + 5139: uint16(49348), + 5140: uint16(1800), + 5141: uint16(2316), + 5142: uint16(38552), + 5143: uint16(39876), + 5144: uint16(7184), + 5145: uint16(27800), + 5146: uint16(10886), + 5147: uint16(422), + 5148: uint16(4422), + 5149: uint16(58733), + 5150: uint16(50379), + 5151: uint16(37568), + 5152: uint16(8464), + 5153: uint16(4630), + 5154: uint16(29341), + 5155: uint16(27124), + 5156: uint16(5902), + 5157: uint16(41514), + 5158: uint16(62593), + 5159: uint16(123), + 5160: uint16(41992), + 5161: uint16(36875), + 5162: uint16(11280), + 5163: uint16(14796), + 5164: uint16(330), + 5165: uint16(5872), + 5166: uint16(2571), + 5167: uint16(3136), + 5168: uint16(59933), + 5169: uint16(17420), + 5170: uint16(17678), + 5171: uint16(2), +} + +var _ksc = [93][94]uint16{ + 0: { + 0: uint16(12288), + 1: uint16(12289), + 2: uint16(12290), + 3: uint16(183), + 4: uint16(8229), + 5: uint16(8230), + 6: uint16(168), + 7: uint16(12291), + 8: uint16(173), + 9: uint16(8213), + 10: uint16(8741), + 11: uint16(65340), + 12: uint16(8764), + 13: uint16(8216), + 14: uint16(8217), + 15: uint16(8220), + 16: uint16(8221), + 17: uint16(12308), + 18: uint16(12309), + 19: uint16(12296), + 20: uint16(12297), + 21: uint16(12298), + 22: uint16(12299), + 23: uint16(12300), + 24: uint16(12301), + 25: uint16(12302), + 26: uint16(12303), + 27: uint16(12304), + 28: uint16(12305), + 29: uint16(177), + 30: uint16(215), + 31: uint16(247), + 32: uint16(8800), + 33: uint16(8804), + 34: uint16(8805), + 35: uint16(8734), + 36: uint16(8756), + 37: uint16(176), + 38: uint16(8242), + 39: uint16(8243), + 40: uint16(8451), + 41: uint16(8491), + 42: uint16(65504), + 43: uint16(65505), + 44: uint16(65509), + 45: uint16(9794), + 46: uint16(9792), + 47: uint16(8736), + 48: uint16(8869), + 49: uint16(8978), + 50: uint16(8706), + 51: uint16(8711), + 52: uint16(8801), + 53: uint16(8786), + 54: uint16(167), + 55: uint16(8251), + 56: uint16(9734), + 57: uint16(9733), + 58: uint16(9675), + 59: uint16(9679), + 60: uint16(9678), + 61: uint16(9671), + 62: uint16(9670), + 63: uint16(9633), + 64: uint16(9632), + 65: uint16(9651), + 66: uint16(9650), + 67: uint16(9661), + 68: uint16(9660), + 69: uint16(8594), + 70: uint16(8592), + 71: uint16(8593), + 72: uint16(8595), + 73: uint16(8596), + 74: uint16(12307), + 75: uint16(8810), + 76: uint16(8811), + 77: uint16(8730), + 78: uint16(8765), + 79: uint16(8733), + 80: uint16(8757), + 81: uint16(8747), + 82: uint16(8748), + 83: uint16(8712), + 84: uint16(8715), + 85: uint16(8838), + 86: uint16(8839), + 87: uint16(8834), + 88: uint16(8835), + 89: uint16(8746), + 90: uint16(8745), + 91: uint16(8743), + 92: uint16(8744), + 93: uint16(65506), + }, + 1: { + 0: uint16(8658), + 1: uint16(8660), + 2: uint16(8704), + 3: uint16(8707), + 4: uint16(180), + 5: uint16(65374), + 6: uint16(711), + 7: uint16(728), + 8: uint16(733), + 9: uint16(730), + 10: uint16(729), + 11: uint16(184), + 12: uint16(731), + 13: uint16(161), + 14: uint16(191), + 15: uint16(720), + 16: uint16(8750), + 17: uint16(8721), + 18: uint16(8719), + 19: uint16(164), + 20: uint16(8457), + 21: uint16(8240), + 22: uint16(9665), + 23: uint16(9664), + 24: uint16(9655), + 25: uint16(9654), + 26: uint16(9828), + 27: uint16(9824), + 28: uint16(9825), + 29: uint16(9829), + 30: uint16(9831), + 31: uint16(9827), + 32: uint16(8857), + 33: uint16(9672), + 34: uint16(9635), + 35: uint16(9680), + 36: uint16(9681), + 37: uint16(9618), + 38: uint16(9636), + 39: uint16(9637), + 40: uint16(9640), + 41: uint16(9639), + 42: uint16(9638), + 43: uint16(9641), + 44: uint16(9832), + 45: uint16(9743), + 46: uint16(9742), + 47: uint16(9756), + 48: uint16(9758), + 49: uint16(182), + 50: uint16(8224), + 51: uint16(8225), + 52: uint16(8597), + 53: uint16(8599), + 54: uint16(8601), + 55: uint16(8598), + 56: uint16(8600), + 57: uint16(9837), + 58: uint16(9833), + 59: uint16(9834), + 60: uint16(9836), + 61: uint16(12927), + 62: uint16(12828), + 63: uint16(8470), + 64: uint16(13255), + 65: uint16(8482), + 66: uint16(13250), + 67: uint16(13272), + 68: uint16(8481), + 69: uint16(8364), + 70: uint16(174), + }, + 2: { + 0: uint16(65281), + 1: uint16(65282), + 2: uint16(65283), + 3: uint16(65284), + 4: uint16(65285), + 5: uint16(65286), + 6: uint16(65287), + 7: uint16(65288), + 8: uint16(65289), + 9: uint16(65290), + 10: uint16(65291), + 11: uint16(65292), + 12: uint16(65293), + 13: uint16(65294), + 14: uint16(65295), + 15: uint16(65296), + 16: uint16(65297), + 17: uint16(65298), + 18: uint16(65299), + 19: uint16(65300), + 20: uint16(65301), + 21: uint16(65302), + 22: uint16(65303), + 23: uint16(65304), + 24: uint16(65305), + 25: uint16(65306), + 26: uint16(65307), + 27: uint16(65308), + 28: uint16(65309), + 29: uint16(65310), + 30: uint16(65311), + 31: uint16(65312), + 32: uint16(65313), + 33: uint16(65314), + 34: uint16(65315), + 35: uint16(65316), + 36: uint16(65317), + 37: uint16(65318), + 38: uint16(65319), + 39: uint16(65320), + 40: uint16(65321), + 41: uint16(65322), + 42: uint16(65323), + 43: uint16(65324), + 44: uint16(65325), + 45: uint16(65326), + 46: uint16(65327), + 47: uint16(65328), + 48: uint16(65329), + 49: uint16(65330), + 50: uint16(65331), + 51: uint16(65332), + 52: uint16(65333), + 53: uint16(65334), + 54: uint16(65335), + 55: uint16(65336), + 56: uint16(65337), + 57: uint16(65338), + 58: uint16(65339), + 59: uint16(65510), + 60: uint16(65341), + 61: uint16(65342), + 62: uint16(65343), + 63: uint16(65344), + 64: uint16(65345), + 65: uint16(65346), + 66: uint16(65347), + 67: uint16(65348), + 68: uint16(65349), + 69: uint16(65350), + 70: uint16(65351), + 71: uint16(65352), + 72: uint16(65353), + 73: uint16(65354), + 74: uint16(65355), + 75: uint16(65356), + 76: uint16(65357), + 77: uint16(65358), + 78: uint16(65359), + 79: uint16(65360), + 80: uint16(65361), + 81: uint16(65362), + 82: uint16(65363), + 83: uint16(65364), + 84: uint16(65365), + 85: uint16(65366), + 86: uint16(65367), + 87: uint16(65368), + 88: uint16(65369), + 89: uint16(65370), + 90: uint16(65371), + 91: uint16(65372), + 92: uint16(65373), + 93: uint16(65507), + }, + 3: { + 0: uint16(12593), + 1: uint16(12594), + 2: uint16(12595), + 3: uint16(12596), + 4: uint16(12597), + 5: uint16(12598), + 6: uint16(12599), + 7: uint16(12600), + 8: uint16(12601), + 9: uint16(12602), + 10: uint16(12603), + 11: uint16(12604), + 12: uint16(12605), + 13: uint16(12606), + 14: uint16(12607), + 15: uint16(12608), + 16: uint16(12609), + 17: uint16(12610), + 18: uint16(12611), + 19: uint16(12612), + 20: uint16(12613), + 21: uint16(12614), + 22: uint16(12615), + 23: uint16(12616), + 24: uint16(12617), + 25: uint16(12618), + 26: uint16(12619), + 27: uint16(12620), + 28: uint16(12621), + 29: uint16(12622), + 30: uint16(12623), + 31: uint16(12624), + 32: uint16(12625), + 33: uint16(12626), + 34: uint16(12627), + 35: uint16(12628), + 36: uint16(12629), + 37: uint16(12630), + 38: uint16(12631), + 39: uint16(12632), + 40: uint16(12633), + 41: uint16(12634), + 42: uint16(12635), + 43: uint16(12636), + 44: uint16(12637), + 45: uint16(12638), + 46: uint16(12639), + 47: uint16(12640), + 48: uint16(12641), + 49: uint16(12642), + 50: uint16(12643), + 51: uint16(12644), + 52: uint16(12645), + 53: uint16(12646), + 54: uint16(12647), + 55: uint16(12648), + 56: uint16(12649), + 57: uint16(12650), + 58: uint16(12651), + 59: uint16(12652), + 60: uint16(12653), + 61: uint16(12654), + 62: uint16(12655), + 63: uint16(12656), + 64: uint16(12657), + 65: uint16(12658), + 66: uint16(12659), + 67: uint16(12660), + 68: uint16(12661), + 69: uint16(12662), + 70: uint16(12663), + 71: uint16(12664), + 72: uint16(12665), + 73: uint16(12666), + 74: uint16(12667), + 75: uint16(12668), + 76: uint16(12669), + 77: uint16(12670), + 78: uint16(12671), + 79: uint16(12672), + 80: uint16(12673), + 81: uint16(12674), + 82: uint16(12675), + 83: uint16(12676), + 84: uint16(12677), + 85: uint16(12678), + 86: uint16(12679), + 87: uint16(12680), + 88: uint16(12681), + 89: uint16(12682), + 90: uint16(12683), + 91: uint16(12684), + 92: uint16(12685), + 93: uint16(12686), + }, + 4: { + 0: uint16(8560), + 1: uint16(8561), + 2: uint16(8562), + 3: uint16(8563), + 4: uint16(8564), + 5: uint16(8565), + 6: uint16(8566), + 7: uint16(8567), + 8: uint16(8568), + 9: uint16(8569), + 15: uint16(8544), + 16: uint16(8545), + 17: uint16(8546), + 18: uint16(8547), + 19: uint16(8548), + 20: uint16(8549), + 21: uint16(8550), + 22: uint16(8551), + 23: uint16(8552), + 24: uint16(8553), + 32: uint16(913), + 33: uint16(914), + 34: uint16(915), + 35: uint16(916), + 36: uint16(917), + 37: uint16(918), + 38: uint16(919), + 39: uint16(920), + 40: uint16(921), + 41: uint16(922), + 42: uint16(923), + 43: uint16(924), + 44: uint16(925), + 45: uint16(926), + 46: uint16(927), + 47: uint16(928), + 48: uint16(929), + 49: uint16(931), + 50: uint16(932), + 51: uint16(933), + 52: uint16(934), + 53: uint16(935), + 54: uint16(936), + 55: uint16(937), + 64: uint16(945), + 65: uint16(946), + 66: uint16(947), + 67: uint16(948), + 68: uint16(949), + 69: uint16(950), + 70: uint16(951), + 71: uint16(952), + 72: uint16(953), + 73: uint16(954), + 74: uint16(955), + 75: uint16(956), + 76: uint16(957), + 77: uint16(958), + 78: uint16(959), + 79: uint16(960), + 80: uint16(961), + 81: uint16(963), + 82: uint16(964), + 83: uint16(965), + 84: uint16(966), + 85: uint16(967), + 86: uint16(968), + 87: uint16(969), + }, + 5: { + 0: uint16(9472), + 1: uint16(9474), + 2: uint16(9484), + 3: uint16(9488), + 4: uint16(9496), + 5: uint16(9492), + 6: uint16(9500), + 7: uint16(9516), + 8: uint16(9508), + 9: uint16(9524), + 10: uint16(9532), + 11: uint16(9473), + 12: uint16(9475), + 13: uint16(9487), + 14: uint16(9491), + 15: uint16(9499), + 16: uint16(9495), + 17: uint16(9507), + 18: uint16(9523), + 19: uint16(9515), + 20: uint16(9531), + 21: uint16(9547), + 22: uint16(9504), + 23: uint16(9519), + 24: uint16(9512), + 25: uint16(9527), + 26: uint16(9535), + 27: uint16(9501), + 28: uint16(9520), + 29: uint16(9509), + 30: uint16(9528), + 31: uint16(9538), + 32: uint16(9490), + 33: uint16(9489), + 34: uint16(9498), + 35: uint16(9497), + 36: uint16(9494), + 37: uint16(9493), + 38: uint16(9486), + 39: uint16(9485), + 40: uint16(9502), + 41: uint16(9503), + 42: uint16(9505), + 43: uint16(9506), + 44: uint16(9510), + 45: uint16(9511), + 46: uint16(9513), + 47: uint16(9514), + 48: uint16(9517), + 49: uint16(9518), + 50: uint16(9521), + 51: uint16(9522), + 52: uint16(9525), + 53: uint16(9526), + 54: uint16(9529), + 55: uint16(9530), + 56: uint16(9533), + 57: uint16(9534), + 58: uint16(9536), + 59: uint16(9537), + 60: uint16(9539), + 61: uint16(9540), + 62: uint16(9541), + 63: uint16(9542), + 64: uint16(9543), + 65: uint16(9544), + 66: uint16(9545), + 67: uint16(9546), + }, + 6: { + 0: uint16(13205), + 1: uint16(13206), + 2: uint16(13207), + 3: uint16(8467), + 4: uint16(13208), + 5: uint16(13252), + 6: uint16(13219), + 7: uint16(13220), + 8: uint16(13221), + 9: uint16(13222), + 10: uint16(13209), + 11: uint16(13210), + 12: uint16(13211), + 13: uint16(13212), + 14: uint16(13213), + 15: uint16(13214), + 16: uint16(13215), + 17: uint16(13216), + 18: uint16(13217), + 19: uint16(13218), + 20: uint16(13258), + 21: uint16(13197), + 22: uint16(13198), + 23: uint16(13199), + 24: uint16(13263), + 25: uint16(13192), + 26: uint16(13193), + 27: uint16(13256), + 28: uint16(13223), + 29: uint16(13224), + 30: uint16(13232), + 31: uint16(13233), + 32: uint16(13234), + 33: uint16(13235), + 34: uint16(13236), + 35: uint16(13237), + 36: uint16(13238), + 37: uint16(13239), + 38: uint16(13240), + 39: uint16(13241), + 40: uint16(13184), + 41: uint16(13185), + 42: uint16(13186), + 43: uint16(13187), + 44: uint16(13188), + 45: uint16(13242), + 46: uint16(13243), + 47: uint16(13244), + 48: uint16(13245), + 49: uint16(13246), + 50: uint16(13247), + 51: uint16(13200), + 52: uint16(13201), + 53: uint16(13202), + 54: uint16(13203), + 55: uint16(13204), + 56: uint16(8486), + 57: uint16(13248), + 58: uint16(13249), + 59: uint16(13194), + 60: uint16(13195), + 61: uint16(13196), + 62: uint16(13270), + 63: uint16(13253), + 64: uint16(13229), + 65: uint16(13230), + 66: uint16(13231), + 67: uint16(13275), + 68: uint16(13225), + 69: uint16(13226), + 70: uint16(13227), + 71: uint16(13228), + 72: uint16(13277), + 73: uint16(13264), + 74: uint16(13267), + 75: uint16(13251), + 76: uint16(13257), + 77: uint16(13276), + 78: uint16(13254), + }, + 7: { + 0: uint16(198), + 1: uint16(208), + 2: uint16(170), + 3: uint16(294), + 5: uint16(306), + 7: uint16(319), + 8: uint16(321), + 9: uint16(216), + 10: uint16(338), + 11: uint16(186), + 12: uint16(222), + 13: uint16(358), + 14: uint16(330), + 16: uint16(12896), + 17: uint16(12897), + 18: uint16(12898), + 19: uint16(12899), + 20: uint16(12900), + 21: uint16(12901), + 22: uint16(12902), + 23: uint16(12903), + 24: uint16(12904), + 25: uint16(12905), + 26: uint16(12906), + 27: uint16(12907), + 28: uint16(12908), + 29: uint16(12909), + 30: uint16(12910), + 31: uint16(12911), + 32: uint16(12912), + 33: uint16(12913), + 34: uint16(12914), + 35: uint16(12915), + 36: uint16(12916), + 37: uint16(12917), + 38: uint16(12918), + 39: uint16(12919), + 40: uint16(12920), + 41: uint16(12921), + 42: uint16(12922), + 43: uint16(12923), + 44: uint16(9424), + 45: uint16(9425), + 46: uint16(9426), + 47: uint16(9427), + 48: uint16(9428), + 49: uint16(9429), + 50: uint16(9430), + 51: uint16(9431), + 52: uint16(9432), + 53: uint16(9433), + 54: uint16(9434), + 55: uint16(9435), + 56: uint16(9436), + 57: uint16(9437), + 58: uint16(9438), + 59: uint16(9439), + 60: uint16(9440), + 61: uint16(9441), + 62: uint16(9442), + 63: uint16(9443), + 64: uint16(9444), + 65: uint16(9445), + 66: uint16(9446), + 67: uint16(9447), + 68: uint16(9448), + 69: uint16(9449), + 70: uint16(9312), + 71: uint16(9313), + 72: uint16(9314), + 73: uint16(9315), + 74: uint16(9316), + 75: uint16(9317), + 76: uint16(9318), + 77: uint16(9319), + 78: uint16(9320), + 79: uint16(9321), + 80: uint16(9322), + 81: uint16(9323), + 82: uint16(9324), + 83: uint16(9325), + 84: uint16(9326), + 85: uint16(189), + 86: uint16(8531), + 87: uint16(8532), + 88: uint16(188), + 89: uint16(190), + 90: uint16(8539), + 91: uint16(8540), + 92: uint16(8541), + 93: uint16(8542), + }, + 8: { + 0: uint16(230), + 1: uint16(273), + 2: uint16(240), + 3: uint16(295), + 4: uint16(305), + 5: uint16(307), + 6: uint16(312), + 7: uint16(320), + 8: uint16(322), + 9: uint16(248), + 10: uint16(339), + 11: uint16(223), + 12: uint16(254), + 13: uint16(359), + 14: uint16(331), + 15: uint16(329), + 16: uint16(12800), + 17: uint16(12801), + 18: uint16(12802), + 19: uint16(12803), + 20: uint16(12804), + 21: uint16(12805), + 22: uint16(12806), + 23: uint16(12807), + 24: uint16(12808), + 25: uint16(12809), + 26: uint16(12810), + 27: uint16(12811), + 28: uint16(12812), + 29: uint16(12813), + 30: uint16(12814), + 31: uint16(12815), + 32: uint16(12816), + 33: uint16(12817), + 34: uint16(12818), + 35: uint16(12819), + 36: uint16(12820), + 37: uint16(12821), + 38: uint16(12822), + 39: uint16(12823), + 40: uint16(12824), + 41: uint16(12825), + 42: uint16(12826), + 43: uint16(12827), + 44: uint16(9372), + 45: uint16(9373), + 46: uint16(9374), + 47: uint16(9375), + 48: uint16(9376), + 49: uint16(9377), + 50: uint16(9378), + 51: uint16(9379), + 52: uint16(9380), + 53: uint16(9381), + 54: uint16(9382), + 55: uint16(9383), + 56: uint16(9384), + 57: uint16(9385), + 58: uint16(9386), + 59: uint16(9387), + 60: uint16(9388), + 61: uint16(9389), + 62: uint16(9390), + 63: uint16(9391), + 64: uint16(9392), + 65: uint16(9393), + 66: uint16(9394), + 67: uint16(9395), + 68: uint16(9396), + 69: uint16(9397), + 70: uint16(9332), + 71: uint16(9333), + 72: uint16(9334), + 73: uint16(9335), + 74: uint16(9336), + 75: uint16(9337), + 76: uint16(9338), + 77: uint16(9339), + 78: uint16(9340), + 79: uint16(9341), + 80: uint16(9342), + 81: uint16(9343), + 82: uint16(9344), + 83: uint16(9345), + 84: uint16(9346), + 85: uint16(185), + 86: uint16(178), + 87: uint16(179), + 88: uint16(8308), + 89: uint16(8319), + 90: uint16(8321), + 91: uint16(8322), + 92: uint16(8323), + 93: uint16(8324), + }, + 9: { + 0: uint16(12353), + 1: uint16(12354), + 2: uint16(12355), + 3: uint16(12356), + 4: uint16(12357), + 5: uint16(12358), + 6: uint16(12359), + 7: uint16(12360), + 8: uint16(12361), + 9: uint16(12362), + 10: uint16(12363), + 11: uint16(12364), + 12: uint16(12365), + 13: uint16(12366), + 14: uint16(12367), + 15: uint16(12368), + 16: uint16(12369), + 17: uint16(12370), + 18: uint16(12371), + 19: uint16(12372), + 20: uint16(12373), + 21: uint16(12374), + 22: uint16(12375), + 23: uint16(12376), + 24: uint16(12377), + 25: uint16(12378), + 26: uint16(12379), + 27: uint16(12380), + 28: uint16(12381), + 29: uint16(12382), + 30: uint16(12383), + 31: uint16(12384), + 32: uint16(12385), + 33: uint16(12386), + 34: uint16(12387), + 35: uint16(12388), + 36: uint16(12389), + 37: uint16(12390), + 38: uint16(12391), + 39: uint16(12392), + 40: uint16(12393), + 41: uint16(12394), + 42: uint16(12395), + 43: uint16(12396), + 44: uint16(12397), + 45: uint16(12398), + 46: uint16(12399), + 47: uint16(12400), + 48: uint16(12401), + 49: uint16(12402), + 50: uint16(12403), + 51: uint16(12404), + 52: uint16(12405), + 53: uint16(12406), + 54: uint16(12407), + 55: uint16(12408), + 56: uint16(12409), + 57: uint16(12410), + 58: uint16(12411), + 59: uint16(12412), + 60: uint16(12413), + 61: uint16(12414), + 62: uint16(12415), + 63: uint16(12416), + 64: uint16(12417), + 65: uint16(12418), + 66: uint16(12419), + 67: uint16(12420), + 68: uint16(12421), + 69: uint16(12422), + 70: uint16(12423), + 71: uint16(12424), + 72: uint16(12425), + 73: uint16(12426), + 74: uint16(12427), + 75: uint16(12428), + 76: uint16(12429), + 77: uint16(12430), + 78: uint16(12431), + 79: uint16(12432), + 80: uint16(12433), + 81: uint16(12434), + 82: uint16(12435), + }, + 10: { + 0: uint16(12449), + 1: uint16(12450), + 2: uint16(12451), + 3: uint16(12452), + 4: uint16(12453), + 5: uint16(12454), + 6: uint16(12455), + 7: uint16(12456), + 8: uint16(12457), + 9: uint16(12458), + 10: uint16(12459), + 11: uint16(12460), + 12: uint16(12461), + 13: uint16(12462), + 14: uint16(12463), + 15: uint16(12464), + 16: uint16(12465), + 17: uint16(12466), + 18: uint16(12467), + 19: uint16(12468), + 20: uint16(12469), + 21: uint16(12470), + 22: uint16(12471), + 23: uint16(12472), + 24: uint16(12473), + 25: uint16(12474), + 26: uint16(12475), + 27: uint16(12476), + 28: uint16(12477), + 29: uint16(12478), + 30: uint16(12479), + 31: uint16(12480), + 32: uint16(12481), + 33: uint16(12482), + 34: uint16(12483), + 35: uint16(12484), + 36: uint16(12485), + 37: uint16(12486), + 38: uint16(12487), + 39: uint16(12488), + 40: uint16(12489), + 41: uint16(12490), + 42: uint16(12491), + 43: uint16(12492), + 44: uint16(12493), + 45: uint16(12494), + 46: uint16(12495), + 47: uint16(12496), + 48: uint16(12497), + 49: uint16(12498), + 50: uint16(12499), + 51: uint16(12500), + 52: uint16(12501), + 53: uint16(12502), + 54: uint16(12503), + 55: uint16(12504), + 56: uint16(12505), + 57: uint16(12506), + 58: uint16(12507), + 59: uint16(12508), + 60: uint16(12509), + 61: uint16(12510), + 62: uint16(12511), + 63: uint16(12512), + 64: uint16(12513), + 65: uint16(12514), + 66: uint16(12515), + 67: uint16(12516), + 68: uint16(12517), + 69: uint16(12518), + 70: uint16(12519), + 71: uint16(12520), + 72: uint16(12521), + 73: uint16(12522), + 74: uint16(12523), + 75: uint16(12524), + 76: uint16(12525), + 77: uint16(12526), + 78: uint16(12527), + 79: uint16(12528), + 80: uint16(12529), + 81: uint16(12530), + 82: uint16(12531), + 83: uint16(12532), + 84: uint16(12533), + 85: uint16(12534), + }, + 11: { + 0: uint16(1040), + 1: uint16(1041), + 2: uint16(1042), + 3: uint16(1043), + 4: uint16(1044), + 5: uint16(1045), + 6: uint16(1025), + 7: uint16(1046), + 8: uint16(1047), + 9: uint16(1048), + 10: uint16(1049), + 11: uint16(1050), + 12: uint16(1051), + 13: uint16(1052), + 14: uint16(1053), + 15: uint16(1054), + 16: uint16(1055), + 17: uint16(1056), + 18: uint16(1057), + 19: uint16(1058), + 20: uint16(1059), + 21: uint16(1060), + 22: uint16(1061), + 23: uint16(1062), + 24: uint16(1063), + 25: uint16(1064), + 26: uint16(1065), + 27: uint16(1066), + 28: uint16(1067), + 29: uint16(1068), + 30: uint16(1069), + 31: uint16(1070), + 32: uint16(1071), + 48: uint16(1072), + 49: uint16(1073), + 50: uint16(1074), + 51: uint16(1075), + 52: uint16(1076), + 53: uint16(1077), + 54: uint16(1105), + 55: uint16(1078), + 56: uint16(1079), + 57: uint16(1080), + 58: uint16(1081), + 59: uint16(1082), + 60: uint16(1083), + 61: uint16(1084), + 62: uint16(1085), + 63: uint16(1086), + 64: uint16(1087), + 65: uint16(1088), + 66: uint16(1089), + 67: uint16(1090), + 68: uint16(1091), + 69: uint16(1092), + 70: uint16(1093), + 71: uint16(1094), + 72: uint16(1095), + 73: uint16(1096), + 74: uint16(1097), + 75: uint16(1098), + 76: uint16(1099), + 77: uint16(1100), + 78: uint16(1101), + 79: uint16(1102), + 80: uint16(1103), + }, + 12: {}, + 13: {}, + 14: {}, + 15: { + 0: uint16(44032), + 1: uint16(44033), + 2: uint16(44036), + 3: uint16(44039), + 4: uint16(44040), + 5: uint16(44041), + 6: uint16(44042), + 7: uint16(44048), + 8: uint16(44049), + 9: uint16(44050), + 10: uint16(44051), + 11: uint16(44052), + 12: uint16(44053), + 13: uint16(44054), + 14: uint16(44055), + 15: uint16(44057), + 16: uint16(44058), + 17: uint16(44059), + 18: uint16(44060), + 19: uint16(44061), + 20: uint16(44064), + 21: uint16(44068), + 22: uint16(44076), + 23: uint16(44077), + 24: uint16(44079), + 25: uint16(44080), + 26: uint16(44081), + 27: uint16(44088), + 28: uint16(44089), + 29: uint16(44092), + 30: uint16(44096), + 31: uint16(44107), + 32: uint16(44109), + 33: uint16(44116), + 34: uint16(44120), + 35: uint16(44124), + 36: uint16(44144), + 37: uint16(44145), + 38: uint16(44148), + 39: uint16(44151), + 40: uint16(44152), + 41: uint16(44154), + 42: uint16(44160), + 43: uint16(44161), + 44: uint16(44163), + 45: uint16(44164), + 46: uint16(44165), + 47: uint16(44166), + 48: uint16(44169), + 49: uint16(44170), + 50: uint16(44171), + 51: uint16(44172), + 52: uint16(44176), + 53: uint16(44180), + 54: uint16(44188), + 55: uint16(44189), + 56: uint16(44191), + 57: uint16(44192), + 58: uint16(44193), + 59: uint16(44200), + 60: uint16(44201), + 61: uint16(44202), + 62: uint16(44204), + 63: uint16(44207), + 64: uint16(44208), + 65: uint16(44216), + 66: uint16(44217), + 67: uint16(44219), + 68: uint16(44220), + 69: uint16(44221), + 70: uint16(44225), + 71: uint16(44228), + 72: uint16(44232), + 73: uint16(44236), + 74: uint16(44245), + 75: uint16(44247), + 76: uint16(44256), + 77: uint16(44257), + 78: uint16(44260), + 79: uint16(44263), + 80: uint16(44264), + 81: uint16(44266), + 82: uint16(44268), + 83: uint16(44271), + 84: uint16(44272), + 85: uint16(44273), + 86: uint16(44275), + 87: uint16(44277), + 88: uint16(44278), + 89: uint16(44284), + 90: uint16(44285), + 91: uint16(44288), + 92: uint16(44292), + 93: uint16(44294), + }, + 16: { + 0: uint16(44300), + 1: uint16(44301), + 2: uint16(44303), + 3: uint16(44305), + 4: uint16(44312), + 5: uint16(44316), + 6: uint16(44320), + 7: uint16(44329), + 8: uint16(44332), + 9: uint16(44333), + 10: uint16(44340), + 11: uint16(44341), + 12: uint16(44344), + 13: uint16(44348), + 14: uint16(44356), + 15: uint16(44357), + 16: uint16(44359), + 17: uint16(44361), + 18: uint16(44368), + 19: uint16(44372), + 20: uint16(44376), + 21: uint16(44385), + 22: uint16(44387), + 23: uint16(44396), + 24: uint16(44397), + 25: uint16(44400), + 26: uint16(44403), + 27: uint16(44404), + 28: uint16(44405), + 29: uint16(44406), + 30: uint16(44411), + 31: uint16(44412), + 32: uint16(44413), + 33: uint16(44415), + 34: uint16(44417), + 35: uint16(44418), + 36: uint16(44424), + 37: uint16(44425), + 38: uint16(44428), + 39: uint16(44432), + 40: uint16(44444), + 41: uint16(44445), + 42: uint16(44452), + 43: uint16(44471), + 44: uint16(44480), + 45: uint16(44481), + 46: uint16(44484), + 47: uint16(44488), + 48: uint16(44496), + 49: uint16(44497), + 50: uint16(44499), + 51: uint16(44508), + 52: uint16(44512), + 53: uint16(44516), + 54: uint16(44536), + 55: uint16(44537), + 56: uint16(44540), + 57: uint16(44543), + 58: uint16(44544), + 59: uint16(44545), + 60: uint16(44552), + 61: uint16(44553), + 62: uint16(44555), + 63: uint16(44557), + 64: uint16(44564), + 65: uint16(44592), + 66: uint16(44593), + 67: uint16(44596), + 68: uint16(44599), + 69: uint16(44600), + 70: uint16(44602), + 71: uint16(44608), + 72: uint16(44609), + 73: uint16(44611), + 74: uint16(44613), + 75: uint16(44614), + 76: uint16(44618), + 77: uint16(44620), + 78: uint16(44621), + 79: uint16(44622), + 80: uint16(44624), + 81: uint16(44628), + 82: uint16(44630), + 83: uint16(44636), + 84: uint16(44637), + 85: uint16(44639), + 86: uint16(44640), + 87: uint16(44641), + 88: uint16(44645), + 89: uint16(44648), + 90: uint16(44649), + 91: uint16(44652), + 92: uint16(44656), + 93: uint16(44664), + }, + 17: { + 0: uint16(44665), + 1: uint16(44667), + 2: uint16(44668), + 3: uint16(44669), + 4: uint16(44676), + 5: uint16(44677), + 6: uint16(44684), + 7: uint16(44732), + 8: uint16(44733), + 9: uint16(44734), + 10: uint16(44736), + 11: uint16(44740), + 12: uint16(44748), + 13: uint16(44749), + 14: uint16(44751), + 15: uint16(44752), + 16: uint16(44753), + 17: uint16(44760), + 18: uint16(44761), + 19: uint16(44764), + 20: uint16(44776), + 21: uint16(44779), + 22: uint16(44781), + 23: uint16(44788), + 24: uint16(44792), + 25: uint16(44796), + 26: uint16(44807), + 27: uint16(44808), + 28: uint16(44813), + 29: uint16(44816), + 30: uint16(44844), + 31: uint16(44845), + 32: uint16(44848), + 33: uint16(44850), + 34: uint16(44852), + 35: uint16(44860), + 36: uint16(44861), + 37: uint16(44863), + 38: uint16(44865), + 39: uint16(44866), + 40: uint16(44867), + 41: uint16(44872), + 42: uint16(44873), + 43: uint16(44880), + 44: uint16(44892), + 45: uint16(44893), + 46: uint16(44900), + 47: uint16(44901), + 48: uint16(44921), + 49: uint16(44928), + 50: uint16(44932), + 51: uint16(44936), + 52: uint16(44944), + 53: uint16(44945), + 54: uint16(44949), + 55: uint16(44956), + 56: uint16(44984), + 57: uint16(44985), + 58: uint16(44988), + 59: uint16(44992), + 60: uint16(44999), + 61: uint16(45000), + 62: uint16(45001), + 63: uint16(45003), + 64: uint16(45005), + 65: uint16(45006), + 66: uint16(45012), + 67: uint16(45020), + 68: uint16(45032), + 69: uint16(45033), + 70: uint16(45040), + 71: uint16(45041), + 72: uint16(45044), + 73: uint16(45048), + 74: uint16(45056), + 75: uint16(45057), + 76: uint16(45060), + 77: uint16(45068), + 78: uint16(45072), + 79: uint16(45076), + 80: uint16(45084), + 81: uint16(45085), + 82: uint16(45096), + 83: uint16(45124), + 84: uint16(45125), + 85: uint16(45128), + 86: uint16(45130), + 87: uint16(45132), + 88: uint16(45134), + 89: uint16(45139), + 90: uint16(45140), + 91: uint16(45141), + 92: uint16(45143), + 93: uint16(45145), + }, + 18: { + 0: uint16(45149), + 1: uint16(45180), + 2: uint16(45181), + 3: uint16(45184), + 4: uint16(45188), + 5: uint16(45196), + 6: uint16(45197), + 7: uint16(45199), + 8: uint16(45201), + 9: uint16(45208), + 10: uint16(45209), + 11: uint16(45210), + 12: uint16(45212), + 13: uint16(45215), + 14: uint16(45216), + 15: uint16(45217), + 16: uint16(45218), + 17: uint16(45224), + 18: uint16(45225), + 19: uint16(45227), + 20: uint16(45228), + 21: uint16(45229), + 22: uint16(45230), + 23: uint16(45231), + 24: uint16(45233), + 25: uint16(45235), + 26: uint16(45236), + 27: uint16(45237), + 28: uint16(45240), + 29: uint16(45244), + 30: uint16(45252), + 31: uint16(45253), + 32: uint16(45255), + 33: uint16(45256), + 34: uint16(45257), + 35: uint16(45264), + 36: uint16(45265), + 37: uint16(45268), + 38: uint16(45272), + 39: uint16(45280), + 40: uint16(45285), + 41: uint16(45320), + 42: uint16(45321), + 43: uint16(45323), + 44: uint16(45324), + 45: uint16(45328), + 46: uint16(45330), + 47: uint16(45331), + 48: uint16(45336), + 49: uint16(45337), + 50: uint16(45339), + 51: uint16(45340), + 52: uint16(45341), + 53: uint16(45347), + 54: uint16(45348), + 55: uint16(45349), + 56: uint16(45352), + 57: uint16(45356), + 58: uint16(45364), + 59: uint16(45365), + 60: uint16(45367), + 61: uint16(45368), + 62: uint16(45369), + 63: uint16(45376), + 64: uint16(45377), + 65: uint16(45380), + 66: uint16(45384), + 67: uint16(45392), + 68: uint16(45393), + 69: uint16(45396), + 70: uint16(45397), + 71: uint16(45400), + 72: uint16(45404), + 73: uint16(45408), + 74: uint16(45432), + 75: uint16(45433), + 76: uint16(45436), + 77: uint16(45440), + 78: uint16(45442), + 79: uint16(45448), + 80: uint16(45449), + 81: uint16(45451), + 82: uint16(45453), + 83: uint16(45458), + 84: uint16(45459), + 85: uint16(45460), + 86: uint16(45464), + 87: uint16(45468), + 88: uint16(45480), + 89: uint16(45516), + 90: uint16(45520), + 91: uint16(45524), + 92: uint16(45532), + 93: uint16(45533), + }, + 19: { + 0: uint16(45535), + 1: uint16(45544), + 2: uint16(45545), + 3: uint16(45548), + 4: uint16(45552), + 5: uint16(45561), + 6: uint16(45563), + 7: uint16(45565), + 8: uint16(45572), + 9: uint16(45573), + 10: uint16(45576), + 11: uint16(45579), + 12: uint16(45580), + 13: uint16(45588), + 14: uint16(45589), + 15: uint16(45591), + 16: uint16(45593), + 17: uint16(45600), + 18: uint16(45620), + 19: uint16(45628), + 20: uint16(45656), + 21: uint16(45660), + 22: uint16(45664), + 23: uint16(45672), + 24: uint16(45673), + 25: uint16(45684), + 26: uint16(45685), + 27: uint16(45692), + 28: uint16(45700), + 29: uint16(45701), + 30: uint16(45705), + 31: uint16(45712), + 32: uint16(45713), + 33: uint16(45716), + 34: uint16(45720), + 35: uint16(45721), + 36: uint16(45722), + 37: uint16(45728), + 38: uint16(45729), + 39: uint16(45731), + 40: uint16(45733), + 41: uint16(45734), + 42: uint16(45738), + 43: uint16(45740), + 44: uint16(45744), + 45: uint16(45748), + 46: uint16(45768), + 47: uint16(45769), + 48: uint16(45772), + 49: uint16(45776), + 50: uint16(45778), + 51: uint16(45784), + 52: uint16(45785), + 53: uint16(45787), + 54: uint16(45789), + 55: uint16(45794), + 56: uint16(45796), + 57: uint16(45797), + 58: uint16(45798), + 59: uint16(45800), + 60: uint16(45803), + 61: uint16(45804), + 62: uint16(45805), + 63: uint16(45806), + 64: uint16(45807), + 65: uint16(45811), + 66: uint16(45812), + 67: uint16(45813), + 68: uint16(45815), + 69: uint16(45816), + 70: uint16(45817), + 71: uint16(45818), + 72: uint16(45819), + 73: uint16(45823), + 74: uint16(45824), + 75: uint16(45825), + 76: uint16(45828), + 77: uint16(45832), + 78: uint16(45840), + 79: uint16(45841), + 80: uint16(45843), + 81: uint16(45844), + 82: uint16(45845), + 83: uint16(45852), + 84: uint16(45908), + 85: uint16(45909), + 86: uint16(45910), + 87: uint16(45912), + 88: uint16(45915), + 89: uint16(45916), + 90: uint16(45918), + 91: uint16(45919), + 92: uint16(45924), + 93: uint16(45925), + }, + 20: { + 0: uint16(45927), + 1: uint16(45929), + 2: uint16(45931), + 3: uint16(45934), + 4: uint16(45936), + 5: uint16(45937), + 6: uint16(45940), + 7: uint16(45944), + 8: uint16(45952), + 9: uint16(45953), + 10: uint16(45955), + 11: uint16(45956), + 12: uint16(45957), + 13: uint16(45964), + 14: uint16(45968), + 15: uint16(45972), + 16: uint16(45984), + 17: uint16(45985), + 18: uint16(45992), + 19: uint16(45996), + 20: uint16(46020), + 21: uint16(46021), + 22: uint16(46024), + 23: uint16(46027), + 24: uint16(46028), + 25: uint16(46030), + 26: uint16(46032), + 27: uint16(46036), + 28: uint16(46037), + 29: uint16(46039), + 30: uint16(46041), + 31: uint16(46043), + 32: uint16(46045), + 33: uint16(46048), + 34: uint16(46052), + 35: uint16(46056), + 36: uint16(46076), + 37: uint16(46096), + 38: uint16(46104), + 39: uint16(46108), + 40: uint16(46112), + 41: uint16(46120), + 42: uint16(46121), + 43: uint16(46123), + 44: uint16(46132), + 45: uint16(46160), + 46: uint16(46161), + 47: uint16(46164), + 48: uint16(46168), + 49: uint16(46176), + 50: uint16(46177), + 51: uint16(46179), + 52: uint16(46181), + 53: uint16(46188), + 54: uint16(46208), + 55: uint16(46216), + 56: uint16(46237), + 57: uint16(46244), + 58: uint16(46248), + 59: uint16(46252), + 60: uint16(46261), + 61: uint16(46263), + 62: uint16(46265), + 63: uint16(46272), + 64: uint16(46276), + 65: uint16(46280), + 66: uint16(46288), + 67: uint16(46293), + 68: uint16(46300), + 69: uint16(46301), + 70: uint16(46304), + 71: uint16(46307), + 72: uint16(46308), + 73: uint16(46310), + 74: uint16(46316), + 75: uint16(46317), + 76: uint16(46319), + 77: uint16(46321), + 78: uint16(46328), + 79: uint16(46356), + 80: uint16(46357), + 81: uint16(46360), + 82: uint16(46363), + 83: uint16(46364), + 84: uint16(46372), + 85: uint16(46373), + 86: uint16(46375), + 87: uint16(46376), + 88: uint16(46377), + 89: uint16(46378), + 90: uint16(46384), + 91: uint16(46385), + 92: uint16(46388), + 93: uint16(46392), + }, + 21: { + 0: uint16(46400), + 1: uint16(46401), + 2: uint16(46403), + 3: uint16(46404), + 4: uint16(46405), + 5: uint16(46411), + 6: uint16(46412), + 7: uint16(46413), + 8: uint16(46416), + 9: uint16(46420), + 10: uint16(46428), + 11: uint16(46429), + 12: uint16(46431), + 13: uint16(46432), + 14: uint16(46433), + 15: uint16(46496), + 16: uint16(46497), + 17: uint16(46500), + 18: uint16(46504), + 19: uint16(46506), + 20: uint16(46507), + 21: uint16(46512), + 22: uint16(46513), + 23: uint16(46515), + 24: uint16(46516), + 25: uint16(46517), + 26: uint16(46523), + 27: uint16(46524), + 28: uint16(46525), + 29: uint16(46528), + 30: uint16(46532), + 31: uint16(46540), + 32: uint16(46541), + 33: uint16(46543), + 34: uint16(46544), + 35: uint16(46545), + 36: uint16(46552), + 37: uint16(46572), + 38: uint16(46608), + 39: uint16(46609), + 40: uint16(46612), + 41: uint16(46616), + 42: uint16(46629), + 43: uint16(46636), + 44: uint16(46644), + 45: uint16(46664), + 46: uint16(46692), + 47: uint16(46696), + 48: uint16(46748), + 49: uint16(46749), + 50: uint16(46752), + 51: uint16(46756), + 52: uint16(46763), + 53: uint16(46764), + 54: uint16(46769), + 55: uint16(46804), + 56: uint16(46832), + 57: uint16(46836), + 58: uint16(46840), + 59: uint16(46848), + 60: uint16(46849), + 61: uint16(46853), + 62: uint16(46888), + 63: uint16(46889), + 64: uint16(46892), + 65: uint16(46895), + 66: uint16(46896), + 67: uint16(46904), + 68: uint16(46905), + 69: uint16(46907), + 70: uint16(46916), + 71: uint16(46920), + 72: uint16(46924), + 73: uint16(46932), + 74: uint16(46933), + 75: uint16(46944), + 76: uint16(46948), + 77: uint16(46952), + 78: uint16(46960), + 79: uint16(46961), + 80: uint16(46963), + 81: uint16(46965), + 82: uint16(46972), + 83: uint16(46973), + 84: uint16(46976), + 85: uint16(46980), + 86: uint16(46988), + 87: uint16(46989), + 88: uint16(46991), + 89: uint16(46992), + 90: uint16(46993), + 91: uint16(46994), + 92: uint16(46998), + 93: uint16(46999), + }, + 22: { + 0: uint16(47000), + 1: uint16(47001), + 2: uint16(47004), + 3: uint16(47008), + 4: uint16(47016), + 5: uint16(47017), + 6: uint16(47019), + 7: uint16(47020), + 8: uint16(47021), + 9: uint16(47028), + 10: uint16(47029), + 11: uint16(47032), + 12: uint16(47047), + 13: uint16(47049), + 14: uint16(47084), + 15: uint16(47085), + 16: uint16(47088), + 17: uint16(47092), + 18: uint16(47100), + 19: uint16(47101), + 20: uint16(47103), + 21: uint16(47104), + 22: uint16(47105), + 23: uint16(47111), + 24: uint16(47112), + 25: uint16(47113), + 26: uint16(47116), + 27: uint16(47120), + 28: uint16(47128), + 29: uint16(47129), + 30: uint16(47131), + 31: uint16(47133), + 32: uint16(47140), + 33: uint16(47141), + 34: uint16(47144), + 35: uint16(47148), + 36: uint16(47156), + 37: uint16(47157), + 38: uint16(47159), + 39: uint16(47160), + 40: uint16(47161), + 41: uint16(47168), + 42: uint16(47172), + 43: uint16(47185), + 44: uint16(47187), + 45: uint16(47196), + 46: uint16(47197), + 47: uint16(47200), + 48: uint16(47204), + 49: uint16(47212), + 50: uint16(47213), + 51: uint16(47215), + 52: uint16(47217), + 53: uint16(47224), + 54: uint16(47228), + 55: uint16(47245), + 56: uint16(47272), + 57: uint16(47280), + 58: uint16(47284), + 59: uint16(47288), + 60: uint16(47296), + 61: uint16(47297), + 62: uint16(47299), + 63: uint16(47301), + 64: uint16(47308), + 65: uint16(47312), + 66: uint16(47316), + 67: uint16(47325), + 68: uint16(47327), + 69: uint16(47329), + 70: uint16(47336), + 71: uint16(47337), + 72: uint16(47340), + 73: uint16(47344), + 74: uint16(47352), + 75: uint16(47353), + 76: uint16(47355), + 77: uint16(47357), + 78: uint16(47364), + 79: uint16(47384), + 80: uint16(47392), + 81: uint16(47420), + 82: uint16(47421), + 83: uint16(47424), + 84: uint16(47428), + 85: uint16(47436), + 86: uint16(47439), + 87: uint16(47441), + 88: uint16(47448), + 89: uint16(47449), + 90: uint16(47452), + 91: uint16(47456), + 92: uint16(47464), + 93: uint16(47465), + }, + 23: { + 0: uint16(47467), + 1: uint16(47469), + 2: uint16(47476), + 3: uint16(47477), + 4: uint16(47480), + 5: uint16(47484), + 6: uint16(47492), + 7: uint16(47493), + 8: uint16(47495), + 9: uint16(47497), + 10: uint16(47498), + 11: uint16(47501), + 12: uint16(47502), + 13: uint16(47532), + 14: uint16(47533), + 15: uint16(47536), + 16: uint16(47540), + 17: uint16(47548), + 18: uint16(47549), + 19: uint16(47551), + 20: uint16(47553), + 21: uint16(47560), + 22: uint16(47561), + 23: uint16(47564), + 24: uint16(47566), + 25: uint16(47567), + 26: uint16(47568), + 27: uint16(47569), + 28: uint16(47570), + 29: uint16(47576), + 30: uint16(47577), + 31: uint16(47579), + 32: uint16(47581), + 33: uint16(47582), + 34: uint16(47585), + 35: uint16(47587), + 36: uint16(47588), + 37: uint16(47589), + 38: uint16(47592), + 39: uint16(47596), + 40: uint16(47604), + 41: uint16(47605), + 42: uint16(47607), + 43: uint16(47608), + 44: uint16(47609), + 45: uint16(47610), + 46: uint16(47616), + 47: uint16(47617), + 48: uint16(47624), + 49: uint16(47637), + 50: uint16(47672), + 51: uint16(47673), + 52: uint16(47676), + 53: uint16(47680), + 54: uint16(47682), + 55: uint16(47688), + 56: uint16(47689), + 57: uint16(47691), + 58: uint16(47693), + 59: uint16(47694), + 60: uint16(47699), + 61: uint16(47700), + 62: uint16(47701), + 63: uint16(47704), + 64: uint16(47708), + 65: uint16(47716), + 66: uint16(47717), + 67: uint16(47719), + 68: uint16(47720), + 69: uint16(47721), + 70: uint16(47728), + 71: uint16(47729), + 72: uint16(47732), + 73: uint16(47736), + 74: uint16(47747), + 75: uint16(47748), + 76: uint16(47749), + 77: uint16(47751), + 78: uint16(47756), + 79: uint16(47784), + 80: uint16(47785), + 81: uint16(47787), + 82: uint16(47788), + 83: uint16(47792), + 84: uint16(47794), + 85: uint16(47800), + 86: uint16(47801), + 87: uint16(47803), + 88: uint16(47805), + 89: uint16(47812), + 90: uint16(47816), + 91: uint16(47832), + 92: uint16(47833), + 93: uint16(47868), + }, + 24: { + 0: uint16(47872), + 1: uint16(47876), + 2: uint16(47885), + 3: uint16(47887), + 4: uint16(47889), + 5: uint16(47896), + 6: uint16(47900), + 7: uint16(47904), + 8: uint16(47913), + 9: uint16(47915), + 10: uint16(47924), + 11: uint16(47925), + 12: uint16(47926), + 13: uint16(47928), + 14: uint16(47931), + 15: uint16(47932), + 16: uint16(47933), + 17: uint16(47934), + 18: uint16(47940), + 19: uint16(47941), + 20: uint16(47943), + 21: uint16(47945), + 22: uint16(47949), + 23: uint16(47951), + 24: uint16(47952), + 25: uint16(47956), + 26: uint16(47960), + 27: uint16(47969), + 28: uint16(47971), + 29: uint16(47980), + 30: uint16(48008), + 31: uint16(48012), + 32: uint16(48016), + 33: uint16(48036), + 34: uint16(48040), + 35: uint16(48044), + 36: uint16(48052), + 37: uint16(48055), + 38: uint16(48064), + 39: uint16(48068), + 40: uint16(48072), + 41: uint16(48080), + 42: uint16(48083), + 43: uint16(48120), + 44: uint16(48121), + 45: uint16(48124), + 46: uint16(48127), + 47: uint16(48128), + 48: uint16(48130), + 49: uint16(48136), + 50: uint16(48137), + 51: uint16(48139), + 52: uint16(48140), + 53: uint16(48141), + 54: uint16(48143), + 55: uint16(48145), + 56: uint16(48148), + 57: uint16(48149), + 58: uint16(48150), + 59: uint16(48151), + 60: uint16(48152), + 61: uint16(48155), + 62: uint16(48156), + 63: uint16(48157), + 64: uint16(48158), + 65: uint16(48159), + 66: uint16(48164), + 67: uint16(48165), + 68: uint16(48167), + 69: uint16(48169), + 70: uint16(48173), + 71: uint16(48176), + 72: uint16(48177), + 73: uint16(48180), + 74: uint16(48184), + 75: uint16(48192), + 76: uint16(48193), + 77: uint16(48195), + 78: uint16(48196), + 79: uint16(48197), + 80: uint16(48201), + 81: uint16(48204), + 82: uint16(48205), + 83: uint16(48208), + 84: uint16(48221), + 85: uint16(48260), + 86: uint16(48261), + 87: uint16(48264), + 88: uint16(48267), + 89: uint16(48268), + 90: uint16(48270), + 91: uint16(48276), + 92: uint16(48277), + 93: uint16(48279), + }, + 25: { + 0: uint16(48281), + 1: uint16(48282), + 2: uint16(48288), + 3: uint16(48289), + 4: uint16(48292), + 5: uint16(48295), + 6: uint16(48296), + 7: uint16(48304), + 8: uint16(48305), + 9: uint16(48307), + 10: uint16(48308), + 11: uint16(48309), + 12: uint16(48316), + 13: uint16(48317), + 14: uint16(48320), + 15: uint16(48324), + 16: uint16(48333), + 17: uint16(48335), + 18: uint16(48336), + 19: uint16(48337), + 20: uint16(48341), + 21: uint16(48344), + 22: uint16(48348), + 23: uint16(48372), + 24: uint16(48373), + 25: uint16(48374), + 26: uint16(48376), + 27: uint16(48380), + 28: uint16(48388), + 29: uint16(48389), + 30: uint16(48391), + 31: uint16(48393), + 32: uint16(48400), + 33: uint16(48404), + 34: uint16(48420), + 35: uint16(48428), + 36: uint16(48448), + 37: uint16(48456), + 38: uint16(48457), + 39: uint16(48460), + 40: uint16(48464), + 41: uint16(48472), + 42: uint16(48473), + 43: uint16(48484), + 44: uint16(48488), + 45: uint16(48512), + 46: uint16(48513), + 47: uint16(48516), + 48: uint16(48519), + 49: uint16(48520), + 50: uint16(48521), + 51: uint16(48522), + 52: uint16(48528), + 53: uint16(48529), + 54: uint16(48531), + 55: uint16(48533), + 56: uint16(48537), + 57: uint16(48538), + 58: uint16(48540), + 59: uint16(48548), + 60: uint16(48560), + 61: uint16(48568), + 62: uint16(48596), + 63: uint16(48597), + 64: uint16(48600), + 65: uint16(48604), + 66: uint16(48617), + 67: uint16(48624), + 68: uint16(48628), + 69: uint16(48632), + 70: uint16(48640), + 71: uint16(48643), + 72: uint16(48645), + 73: uint16(48652), + 74: uint16(48653), + 75: uint16(48656), + 76: uint16(48660), + 77: uint16(48668), + 78: uint16(48669), + 79: uint16(48671), + 80: uint16(48708), + 81: uint16(48709), + 82: uint16(48712), + 83: uint16(48716), + 84: uint16(48718), + 85: uint16(48724), + 86: uint16(48725), + 87: uint16(48727), + 88: uint16(48729), + 89: uint16(48730), + 90: uint16(48731), + 91: uint16(48736), + 92: uint16(48737), + 93: uint16(48740), + }, + 26: { + 0: uint16(48744), + 1: uint16(48746), + 2: uint16(48752), + 3: uint16(48753), + 4: uint16(48755), + 5: uint16(48756), + 6: uint16(48757), + 7: uint16(48763), + 8: uint16(48764), + 9: uint16(48765), + 10: uint16(48768), + 11: uint16(48772), + 12: uint16(48780), + 13: uint16(48781), + 14: uint16(48783), + 15: uint16(48784), + 16: uint16(48785), + 17: uint16(48792), + 18: uint16(48793), + 19: uint16(48808), + 20: uint16(48848), + 21: uint16(48849), + 22: uint16(48852), + 23: uint16(48855), + 24: uint16(48856), + 25: uint16(48864), + 26: uint16(48867), + 27: uint16(48868), + 28: uint16(48869), + 29: uint16(48876), + 30: uint16(48897), + 31: uint16(48904), + 32: uint16(48905), + 33: uint16(48920), + 34: uint16(48921), + 35: uint16(48923), + 36: uint16(48924), + 37: uint16(48925), + 38: uint16(48960), + 39: uint16(48961), + 40: uint16(48964), + 41: uint16(48968), + 42: uint16(48976), + 43: uint16(48977), + 44: uint16(48981), + 45: uint16(49044), + 46: uint16(49072), + 47: uint16(49093), + 48: uint16(49100), + 49: uint16(49101), + 50: uint16(49104), + 51: uint16(49108), + 52: uint16(49116), + 53: uint16(49119), + 54: uint16(49121), + 55: uint16(49212), + 56: uint16(49233), + 57: uint16(49240), + 58: uint16(49244), + 59: uint16(49248), + 60: uint16(49256), + 61: uint16(49257), + 62: uint16(49296), + 63: uint16(49297), + 64: uint16(49300), + 65: uint16(49304), + 66: uint16(49312), + 67: uint16(49313), + 68: uint16(49315), + 69: uint16(49317), + 70: uint16(49324), + 71: uint16(49325), + 72: uint16(49327), + 73: uint16(49328), + 74: uint16(49331), + 75: uint16(49332), + 76: uint16(49333), + 77: uint16(49334), + 78: uint16(49340), + 79: uint16(49341), + 80: uint16(49343), + 81: uint16(49344), + 82: uint16(49345), + 83: uint16(49349), + 84: uint16(49352), + 85: uint16(49353), + 86: uint16(49356), + 87: uint16(49360), + 88: uint16(49368), + 89: uint16(49369), + 90: uint16(49371), + 91: uint16(49372), + 92: uint16(49373), + 93: uint16(49380), + }, + 27: { + 0: uint16(49381), + 1: uint16(49384), + 2: uint16(49388), + 3: uint16(49396), + 4: uint16(49397), + 5: uint16(49399), + 6: uint16(49401), + 7: uint16(49408), + 8: uint16(49412), + 9: uint16(49416), + 10: uint16(49424), + 11: uint16(49429), + 12: uint16(49436), + 13: uint16(49437), + 14: uint16(49438), + 15: uint16(49439), + 16: uint16(49440), + 17: uint16(49443), + 18: uint16(49444), + 19: uint16(49446), + 20: uint16(49447), + 21: uint16(49452), + 22: uint16(49453), + 23: uint16(49455), + 24: uint16(49456), + 25: uint16(49457), + 26: uint16(49462), + 27: uint16(49464), + 28: uint16(49465), + 29: uint16(49468), + 30: uint16(49472), + 31: uint16(49480), + 32: uint16(49481), + 33: uint16(49483), + 34: uint16(49484), + 35: uint16(49485), + 36: uint16(49492), + 37: uint16(49493), + 38: uint16(49496), + 39: uint16(49500), + 40: uint16(49508), + 41: uint16(49509), + 42: uint16(49511), + 43: uint16(49512), + 44: uint16(49513), + 45: uint16(49520), + 46: uint16(49524), + 47: uint16(49528), + 48: uint16(49541), + 49: uint16(49548), + 50: uint16(49549), + 51: uint16(49550), + 52: uint16(49552), + 53: uint16(49556), + 54: uint16(49558), + 55: uint16(49564), + 56: uint16(49565), + 57: uint16(49567), + 58: uint16(49569), + 59: uint16(49573), + 60: uint16(49576), + 61: uint16(49577), + 62: uint16(49580), + 63: uint16(49584), + 64: uint16(49597), + 65: uint16(49604), + 66: uint16(49608), + 67: uint16(49612), + 68: uint16(49620), + 69: uint16(49623), + 70: uint16(49624), + 71: uint16(49632), + 72: uint16(49636), + 73: uint16(49640), + 74: uint16(49648), + 75: uint16(49649), + 76: uint16(49651), + 77: uint16(49660), + 78: uint16(49661), + 79: uint16(49664), + 80: uint16(49668), + 81: uint16(49676), + 82: uint16(49677), + 83: uint16(49679), + 84: uint16(49681), + 85: uint16(49688), + 86: uint16(49689), + 87: uint16(49692), + 88: uint16(49695), + 89: uint16(49696), + 90: uint16(49704), + 91: uint16(49705), + 92: uint16(49707), + 93: uint16(49709), + }, + 28: { + 0: uint16(49711), + 1: uint16(49713), + 2: uint16(49714), + 3: uint16(49716), + 4: uint16(49736), + 5: uint16(49744), + 6: uint16(49745), + 7: uint16(49748), + 8: uint16(49752), + 9: uint16(49760), + 10: uint16(49765), + 11: uint16(49772), + 12: uint16(49773), + 13: uint16(49776), + 14: uint16(49780), + 15: uint16(49788), + 16: uint16(49789), + 17: uint16(49791), + 18: uint16(49793), + 19: uint16(49800), + 20: uint16(49801), + 21: uint16(49808), + 22: uint16(49816), + 23: uint16(49819), + 24: uint16(49821), + 25: uint16(49828), + 26: uint16(49829), + 27: uint16(49832), + 28: uint16(49836), + 29: uint16(49837), + 30: uint16(49844), + 31: uint16(49845), + 32: uint16(49847), + 33: uint16(49849), + 34: uint16(49884), + 35: uint16(49885), + 36: uint16(49888), + 37: uint16(49891), + 38: uint16(49892), + 39: uint16(49899), + 40: uint16(49900), + 41: uint16(49901), + 42: uint16(49903), + 43: uint16(49905), + 44: uint16(49910), + 45: uint16(49912), + 46: uint16(49913), + 47: uint16(49915), + 48: uint16(49916), + 49: uint16(49920), + 50: uint16(49928), + 51: uint16(49929), + 52: uint16(49932), + 53: uint16(49933), + 54: uint16(49939), + 55: uint16(49940), + 56: uint16(49941), + 57: uint16(49944), + 58: uint16(49948), + 59: uint16(49956), + 60: uint16(49957), + 61: uint16(49960), + 62: uint16(49961), + 63: uint16(49989), + 64: uint16(50024), + 65: uint16(50025), + 66: uint16(50028), + 67: uint16(50032), + 68: uint16(50034), + 69: uint16(50040), + 70: uint16(50041), + 71: uint16(50044), + 72: uint16(50045), + 73: uint16(50052), + 74: uint16(50056), + 75: uint16(50060), + 76: uint16(50112), + 77: uint16(50136), + 78: uint16(50137), + 79: uint16(50140), + 80: uint16(50143), + 81: uint16(50144), + 82: uint16(50146), + 83: uint16(50152), + 84: uint16(50153), + 85: uint16(50157), + 86: uint16(50164), + 87: uint16(50165), + 88: uint16(50168), + 89: uint16(50184), + 90: uint16(50192), + 91: uint16(50212), + 92: uint16(50220), + 93: uint16(50224), + }, + 29: { + 0: uint16(50228), + 1: uint16(50236), + 2: uint16(50237), + 3: uint16(50248), + 4: uint16(50276), + 5: uint16(50277), + 6: uint16(50280), + 7: uint16(50284), + 8: uint16(50292), + 9: uint16(50293), + 10: uint16(50297), + 11: uint16(50304), + 12: uint16(50324), + 13: uint16(50332), + 14: uint16(50360), + 15: uint16(50364), + 16: uint16(50409), + 17: uint16(50416), + 18: uint16(50417), + 19: uint16(50420), + 20: uint16(50424), + 21: uint16(50426), + 22: uint16(50431), + 23: uint16(50432), + 24: uint16(50433), + 25: uint16(50444), + 26: uint16(50448), + 27: uint16(50452), + 28: uint16(50460), + 29: uint16(50472), + 30: uint16(50473), + 31: uint16(50476), + 32: uint16(50480), + 33: uint16(50488), + 34: uint16(50489), + 35: uint16(50491), + 36: uint16(50493), + 37: uint16(50500), + 38: uint16(50501), + 39: uint16(50504), + 40: uint16(50505), + 41: uint16(50506), + 42: uint16(50508), + 43: uint16(50509), + 44: uint16(50510), + 45: uint16(50515), + 46: uint16(50516), + 47: uint16(50517), + 48: uint16(50519), + 49: uint16(50520), + 50: uint16(50521), + 51: uint16(50525), + 52: uint16(50526), + 53: uint16(50528), + 54: uint16(50529), + 55: uint16(50532), + 56: uint16(50536), + 57: uint16(50544), + 58: uint16(50545), + 59: uint16(50547), + 60: uint16(50548), + 61: uint16(50549), + 62: uint16(50556), + 63: uint16(50557), + 64: uint16(50560), + 65: uint16(50564), + 66: uint16(50567), + 67: uint16(50572), + 68: uint16(50573), + 69: uint16(50575), + 70: uint16(50577), + 71: uint16(50581), + 72: uint16(50583), + 73: uint16(50584), + 74: uint16(50588), + 75: uint16(50592), + 76: uint16(50601), + 77: uint16(50612), + 78: uint16(50613), + 79: uint16(50616), + 80: uint16(50617), + 81: uint16(50619), + 82: uint16(50620), + 83: uint16(50621), + 84: uint16(50622), + 85: uint16(50628), + 86: uint16(50629), + 87: uint16(50630), + 88: uint16(50631), + 89: uint16(50632), + 90: uint16(50633), + 91: uint16(50634), + 92: uint16(50636), + 93: uint16(50638), + }, + 30: { + 0: uint16(50640), + 1: uint16(50641), + 2: uint16(50644), + 3: uint16(50648), + 4: uint16(50656), + 5: uint16(50657), + 6: uint16(50659), + 7: uint16(50661), + 8: uint16(50668), + 9: uint16(50669), + 10: uint16(50670), + 11: uint16(50672), + 12: uint16(50676), + 13: uint16(50678), + 14: uint16(50679), + 15: uint16(50684), + 16: uint16(50685), + 17: uint16(50686), + 18: uint16(50687), + 19: uint16(50688), + 20: uint16(50689), + 21: uint16(50693), + 22: uint16(50694), + 23: uint16(50695), + 24: uint16(50696), + 25: uint16(50700), + 26: uint16(50704), + 27: uint16(50712), + 28: uint16(50713), + 29: uint16(50715), + 30: uint16(50716), + 31: uint16(50724), + 32: uint16(50725), + 33: uint16(50728), + 34: uint16(50732), + 35: uint16(50733), + 36: uint16(50734), + 37: uint16(50736), + 38: uint16(50739), + 39: uint16(50740), + 40: uint16(50741), + 41: uint16(50743), + 42: uint16(50745), + 43: uint16(50747), + 44: uint16(50752), + 45: uint16(50753), + 46: uint16(50756), + 47: uint16(50760), + 48: uint16(50768), + 49: uint16(50769), + 50: uint16(50771), + 51: uint16(50772), + 52: uint16(50773), + 53: uint16(50780), + 54: uint16(50781), + 55: uint16(50784), + 56: uint16(50796), + 57: uint16(50799), + 58: uint16(50801), + 59: uint16(50808), + 60: uint16(50809), + 61: uint16(50812), + 62: uint16(50816), + 63: uint16(50824), + 64: uint16(50825), + 65: uint16(50827), + 66: uint16(50829), + 67: uint16(50836), + 68: uint16(50837), + 69: uint16(50840), + 70: uint16(50844), + 71: uint16(50852), + 72: uint16(50853), + 73: uint16(50855), + 74: uint16(50857), + 75: uint16(50864), + 76: uint16(50865), + 77: uint16(50868), + 78: uint16(50872), + 79: uint16(50873), + 80: uint16(50874), + 81: uint16(50880), + 82: uint16(50881), + 83: uint16(50883), + 84: uint16(50885), + 85: uint16(50892), + 86: uint16(50893), + 87: uint16(50896), + 88: uint16(50900), + 89: uint16(50908), + 90: uint16(50909), + 91: uint16(50912), + 92: uint16(50913), + 93: uint16(50920), + }, + 31: { + 0: uint16(50921), + 1: uint16(50924), + 2: uint16(50928), + 3: uint16(50936), + 4: uint16(50937), + 5: uint16(50941), + 6: uint16(50948), + 7: uint16(50949), + 8: uint16(50952), + 9: uint16(50956), + 10: uint16(50964), + 11: uint16(50965), + 12: uint16(50967), + 13: uint16(50969), + 14: uint16(50976), + 15: uint16(50977), + 16: uint16(50980), + 17: uint16(50984), + 18: uint16(50992), + 19: uint16(50993), + 20: uint16(50995), + 21: uint16(50997), + 22: uint16(50999), + 23: uint16(51004), + 24: uint16(51005), + 25: uint16(51008), + 26: uint16(51012), + 27: uint16(51018), + 28: uint16(51020), + 29: uint16(51021), + 30: uint16(51023), + 31: uint16(51025), + 32: uint16(51026), + 33: uint16(51027), + 34: uint16(51028), + 35: uint16(51029), + 36: uint16(51030), + 37: uint16(51031), + 38: uint16(51032), + 39: uint16(51036), + 40: uint16(51040), + 41: uint16(51048), + 42: uint16(51051), + 43: uint16(51060), + 44: uint16(51061), + 45: uint16(51064), + 46: uint16(51068), + 47: uint16(51069), + 48: uint16(51070), + 49: uint16(51075), + 50: uint16(51076), + 51: uint16(51077), + 52: uint16(51079), + 53: uint16(51080), + 54: uint16(51081), + 55: uint16(51082), + 56: uint16(51086), + 57: uint16(51088), + 58: uint16(51089), + 59: uint16(51092), + 60: uint16(51094), + 61: uint16(51095), + 62: uint16(51096), + 63: uint16(51098), + 64: uint16(51104), + 65: uint16(51105), + 66: uint16(51107), + 67: uint16(51108), + 68: uint16(51109), + 69: uint16(51110), + 70: uint16(51116), + 71: uint16(51117), + 72: uint16(51120), + 73: uint16(51124), + 74: uint16(51132), + 75: uint16(51133), + 76: uint16(51135), + 77: uint16(51136), + 78: uint16(51137), + 79: uint16(51144), + 80: uint16(51145), + 81: uint16(51148), + 82: uint16(51150), + 83: uint16(51152), + 84: uint16(51160), + 85: uint16(51165), + 86: uint16(51172), + 87: uint16(51176), + 88: uint16(51180), + 89: uint16(51200), + 90: uint16(51201), + 91: uint16(51204), + 92: uint16(51208), + 93: uint16(51210), + }, + 32: { + 0: uint16(51216), + 1: uint16(51217), + 2: uint16(51219), + 3: uint16(51221), + 4: uint16(51222), + 5: uint16(51228), + 6: uint16(51229), + 7: uint16(51232), + 8: uint16(51236), + 9: uint16(51244), + 10: uint16(51245), + 11: uint16(51247), + 12: uint16(51249), + 13: uint16(51256), + 14: uint16(51260), + 15: uint16(51264), + 16: uint16(51272), + 17: uint16(51273), + 18: uint16(51276), + 19: uint16(51277), + 20: uint16(51284), + 21: uint16(51312), + 22: uint16(51313), + 23: uint16(51316), + 24: uint16(51320), + 25: uint16(51322), + 26: uint16(51328), + 27: uint16(51329), + 28: uint16(51331), + 29: uint16(51333), + 30: uint16(51334), + 31: uint16(51335), + 32: uint16(51339), + 33: uint16(51340), + 34: uint16(51341), + 35: uint16(51348), + 36: uint16(51357), + 37: uint16(51359), + 38: uint16(51361), + 39: uint16(51368), + 40: uint16(51388), + 41: uint16(51389), + 42: uint16(51396), + 43: uint16(51400), + 44: uint16(51404), + 45: uint16(51412), + 46: uint16(51413), + 47: uint16(51415), + 48: uint16(51417), + 49: uint16(51424), + 50: uint16(51425), + 51: uint16(51428), + 52: uint16(51445), + 53: uint16(51452), + 54: uint16(51453), + 55: uint16(51456), + 56: uint16(51460), + 57: uint16(51461), + 58: uint16(51462), + 59: uint16(51468), + 60: uint16(51469), + 61: uint16(51471), + 62: uint16(51473), + 63: uint16(51480), + 64: uint16(51500), + 65: uint16(51508), + 66: uint16(51536), + 67: uint16(51537), + 68: uint16(51540), + 69: uint16(51544), + 70: uint16(51552), + 71: uint16(51553), + 72: uint16(51555), + 73: uint16(51564), + 74: uint16(51568), + 75: uint16(51572), + 76: uint16(51580), + 77: uint16(51592), + 78: uint16(51593), + 79: uint16(51596), + 80: uint16(51600), + 81: uint16(51608), + 82: uint16(51609), + 83: uint16(51611), + 84: uint16(51613), + 85: uint16(51648), + 86: uint16(51649), + 87: uint16(51652), + 88: uint16(51655), + 89: uint16(51656), + 90: uint16(51658), + 91: uint16(51664), + 92: uint16(51665), + 93: uint16(51667), + }, + 33: { + 0: uint16(51669), + 1: uint16(51670), + 2: uint16(51673), + 3: uint16(51674), + 4: uint16(51676), + 5: uint16(51677), + 6: uint16(51680), + 7: uint16(51682), + 8: uint16(51684), + 9: uint16(51687), + 10: uint16(51692), + 11: uint16(51693), + 12: uint16(51695), + 13: uint16(51696), + 14: uint16(51697), + 15: uint16(51704), + 16: uint16(51705), + 17: uint16(51708), + 18: uint16(51712), + 19: uint16(51720), + 20: uint16(51721), + 21: uint16(51723), + 22: uint16(51724), + 23: uint16(51725), + 24: uint16(51732), + 25: uint16(51736), + 26: uint16(51753), + 27: uint16(51788), + 28: uint16(51789), + 29: uint16(51792), + 30: uint16(51796), + 31: uint16(51804), + 32: uint16(51805), + 33: uint16(51807), + 34: uint16(51808), + 35: uint16(51809), + 36: uint16(51816), + 37: uint16(51837), + 38: uint16(51844), + 39: uint16(51864), + 40: uint16(51900), + 41: uint16(51901), + 42: uint16(51904), + 43: uint16(51908), + 44: uint16(51916), + 45: uint16(51917), + 46: uint16(51919), + 47: uint16(51921), + 48: uint16(51923), + 49: uint16(51928), + 50: uint16(51929), + 51: uint16(51936), + 52: uint16(51948), + 53: uint16(51956), + 54: uint16(51976), + 55: uint16(51984), + 56: uint16(51988), + 57: uint16(51992), + 58: uint16(52000), + 59: uint16(52001), + 60: uint16(52033), + 61: uint16(52040), + 62: uint16(52041), + 63: uint16(52044), + 64: uint16(52048), + 65: uint16(52056), + 66: uint16(52057), + 67: uint16(52061), + 68: uint16(52068), + 69: uint16(52088), + 70: uint16(52089), + 71: uint16(52124), + 72: uint16(52152), + 73: uint16(52180), + 74: uint16(52196), + 75: uint16(52199), + 76: uint16(52201), + 77: uint16(52236), + 78: uint16(52237), + 79: uint16(52240), + 80: uint16(52244), + 81: uint16(52252), + 82: uint16(52253), + 83: uint16(52257), + 84: uint16(52258), + 85: uint16(52263), + 86: uint16(52264), + 87: uint16(52265), + 88: uint16(52268), + 89: uint16(52270), + 90: uint16(52272), + 91: uint16(52280), + 92: uint16(52281), + 93: uint16(52283), + }, + 34: { + 0: uint16(52284), + 1: uint16(52285), + 2: uint16(52286), + 3: uint16(52292), + 4: uint16(52293), + 5: uint16(52296), + 6: uint16(52300), + 7: uint16(52308), + 8: uint16(52309), + 9: uint16(52311), + 10: uint16(52312), + 11: uint16(52313), + 12: uint16(52320), + 13: uint16(52324), + 14: uint16(52326), + 15: uint16(52328), + 16: uint16(52336), + 17: uint16(52341), + 18: uint16(52376), + 19: uint16(52377), + 20: uint16(52380), + 21: uint16(52384), + 22: uint16(52392), + 23: uint16(52393), + 24: uint16(52395), + 25: uint16(52396), + 26: uint16(52397), + 27: uint16(52404), + 28: uint16(52405), + 29: uint16(52408), + 30: uint16(52412), + 31: uint16(52420), + 32: uint16(52421), + 33: uint16(52423), + 34: uint16(52425), + 35: uint16(52432), + 36: uint16(52436), + 37: uint16(52452), + 38: uint16(52460), + 39: uint16(52464), + 40: uint16(52481), + 41: uint16(52488), + 42: uint16(52489), + 43: uint16(52492), + 44: uint16(52496), + 45: uint16(52504), + 46: uint16(52505), + 47: uint16(52507), + 48: uint16(52509), + 49: uint16(52516), + 50: uint16(52520), + 51: uint16(52524), + 52: uint16(52537), + 53: uint16(52572), + 54: uint16(52576), + 55: uint16(52580), + 56: uint16(52588), + 57: uint16(52589), + 58: uint16(52591), + 59: uint16(52593), + 60: uint16(52600), + 61: uint16(52616), + 62: uint16(52628), + 63: uint16(52629), + 64: uint16(52632), + 65: uint16(52636), + 66: uint16(52644), + 67: uint16(52645), + 68: uint16(52647), + 69: uint16(52649), + 70: uint16(52656), + 71: uint16(52676), + 72: uint16(52684), + 73: uint16(52688), + 74: uint16(52712), + 75: uint16(52716), + 76: uint16(52720), + 77: uint16(52728), + 78: uint16(52729), + 79: uint16(52731), + 80: uint16(52733), + 81: uint16(52740), + 82: uint16(52744), + 83: uint16(52748), + 84: uint16(52756), + 85: uint16(52761), + 86: uint16(52768), + 87: uint16(52769), + 88: uint16(52772), + 89: uint16(52776), + 90: uint16(52784), + 91: uint16(52785), + 92: uint16(52787), + 93: uint16(52789), + }, + 35: { + 0: uint16(52824), + 1: uint16(52825), + 2: uint16(52828), + 3: uint16(52831), + 4: uint16(52832), + 5: uint16(52833), + 6: uint16(52840), + 7: uint16(52841), + 8: uint16(52843), + 9: uint16(52845), + 10: uint16(52852), + 11: uint16(52853), + 12: uint16(52856), + 13: uint16(52860), + 14: uint16(52868), + 15: uint16(52869), + 16: uint16(52871), + 17: uint16(52873), + 18: uint16(52880), + 19: uint16(52881), + 20: uint16(52884), + 21: uint16(52888), + 22: uint16(52896), + 23: uint16(52897), + 24: uint16(52899), + 25: uint16(52900), + 26: uint16(52901), + 27: uint16(52908), + 28: uint16(52909), + 29: uint16(52929), + 30: uint16(52964), + 31: uint16(52965), + 32: uint16(52968), + 33: uint16(52971), + 34: uint16(52972), + 35: uint16(52980), + 36: uint16(52981), + 37: uint16(52983), + 38: uint16(52984), + 39: uint16(52985), + 40: uint16(52992), + 41: uint16(52993), + 42: uint16(52996), + 43: uint16(53000), + 44: uint16(53008), + 45: uint16(53009), + 46: uint16(53011), + 47: uint16(53013), + 48: uint16(53020), + 49: uint16(53024), + 50: uint16(53028), + 51: uint16(53036), + 52: uint16(53037), + 53: uint16(53039), + 54: uint16(53040), + 55: uint16(53041), + 56: uint16(53048), + 57: uint16(53076), + 58: uint16(53077), + 59: uint16(53080), + 60: uint16(53084), + 61: uint16(53092), + 62: uint16(53093), + 63: uint16(53095), + 64: uint16(53097), + 65: uint16(53104), + 66: uint16(53105), + 67: uint16(53108), + 68: uint16(53112), + 69: uint16(53120), + 70: uint16(53125), + 71: uint16(53132), + 72: uint16(53153), + 73: uint16(53160), + 74: uint16(53168), + 75: uint16(53188), + 76: uint16(53216), + 77: uint16(53217), + 78: uint16(53220), + 79: uint16(53224), + 80: uint16(53232), + 81: uint16(53233), + 82: uint16(53235), + 83: uint16(53237), + 84: uint16(53244), + 85: uint16(53248), + 86: uint16(53252), + 87: uint16(53265), + 88: uint16(53272), + 89: uint16(53293), + 90: uint16(53300), + 91: uint16(53301), + 92: uint16(53304), + 93: uint16(53308), + }, + 36: { + 0: uint16(53316), + 1: uint16(53317), + 2: uint16(53319), + 3: uint16(53321), + 4: uint16(53328), + 5: uint16(53332), + 6: uint16(53336), + 7: uint16(53344), + 8: uint16(53356), + 9: uint16(53357), + 10: uint16(53360), + 11: uint16(53364), + 12: uint16(53372), + 13: uint16(53373), + 14: uint16(53377), + 15: uint16(53412), + 16: uint16(53413), + 17: uint16(53416), + 18: uint16(53420), + 19: uint16(53428), + 20: uint16(53429), + 21: uint16(53431), + 22: uint16(53433), + 23: uint16(53440), + 24: uint16(53441), + 25: uint16(53444), + 26: uint16(53448), + 27: uint16(53449), + 28: uint16(53456), + 29: uint16(53457), + 30: uint16(53459), + 31: uint16(53460), + 32: uint16(53461), + 33: uint16(53468), + 34: uint16(53469), + 35: uint16(53472), + 36: uint16(53476), + 37: uint16(53484), + 38: uint16(53485), + 39: uint16(53487), + 40: uint16(53488), + 41: uint16(53489), + 42: uint16(53496), + 43: uint16(53517), + 44: uint16(53552), + 45: uint16(53553), + 46: uint16(53556), + 47: uint16(53560), + 48: uint16(53562), + 49: uint16(53568), + 50: uint16(53569), + 51: uint16(53571), + 52: uint16(53572), + 53: uint16(53573), + 54: uint16(53580), + 55: uint16(53581), + 56: uint16(53584), + 57: uint16(53588), + 58: uint16(53596), + 59: uint16(53597), + 60: uint16(53599), + 61: uint16(53601), + 62: uint16(53608), + 63: uint16(53612), + 64: uint16(53628), + 65: uint16(53636), + 66: uint16(53640), + 67: uint16(53664), + 68: uint16(53665), + 69: uint16(53668), + 70: uint16(53672), + 71: uint16(53680), + 72: uint16(53681), + 73: uint16(53683), + 74: uint16(53685), + 75: uint16(53690), + 76: uint16(53692), + 77: uint16(53696), + 78: uint16(53720), + 79: uint16(53748), + 80: uint16(53752), + 81: uint16(53767), + 82: uint16(53769), + 83: uint16(53776), + 84: uint16(53804), + 85: uint16(53805), + 86: uint16(53808), + 87: uint16(53812), + 88: uint16(53820), + 89: uint16(53821), + 90: uint16(53823), + 91: uint16(53825), + 92: uint16(53832), + 93: uint16(53852), + }, + 37: { + 0: uint16(53860), + 1: uint16(53888), + 2: uint16(53889), + 3: uint16(53892), + 4: uint16(53896), + 5: uint16(53904), + 6: uint16(53905), + 7: uint16(53909), + 8: uint16(53916), + 9: uint16(53920), + 10: uint16(53924), + 11: uint16(53932), + 12: uint16(53937), + 13: uint16(53944), + 14: uint16(53945), + 15: uint16(53948), + 16: uint16(53951), + 17: uint16(53952), + 18: uint16(53954), + 19: uint16(53960), + 20: uint16(53961), + 21: uint16(53963), + 22: uint16(53972), + 23: uint16(53976), + 24: uint16(53980), + 25: uint16(53988), + 26: uint16(53989), + 27: uint16(54000), + 28: uint16(54001), + 29: uint16(54004), + 30: uint16(54008), + 31: uint16(54016), + 32: uint16(54017), + 33: uint16(54019), + 34: uint16(54021), + 35: uint16(54028), + 36: uint16(54029), + 37: uint16(54030), + 38: uint16(54032), + 39: uint16(54036), + 40: uint16(54038), + 41: uint16(54044), + 42: uint16(54045), + 43: uint16(54047), + 44: uint16(54048), + 45: uint16(54049), + 46: uint16(54053), + 47: uint16(54056), + 48: uint16(54057), + 49: uint16(54060), + 50: uint16(54064), + 51: uint16(54072), + 52: uint16(54073), + 53: uint16(54075), + 54: uint16(54076), + 55: uint16(54077), + 56: uint16(54084), + 57: uint16(54085), + 58: uint16(54140), + 59: uint16(54141), + 60: uint16(54144), + 61: uint16(54148), + 62: uint16(54156), + 63: uint16(54157), + 64: uint16(54159), + 65: uint16(54160), + 66: uint16(54161), + 67: uint16(54168), + 68: uint16(54169), + 69: uint16(54172), + 70: uint16(54176), + 71: uint16(54184), + 72: uint16(54185), + 73: uint16(54187), + 74: uint16(54189), + 75: uint16(54196), + 76: uint16(54200), + 77: uint16(54204), + 78: uint16(54212), + 79: uint16(54213), + 80: uint16(54216), + 81: uint16(54217), + 82: uint16(54224), + 83: uint16(54232), + 84: uint16(54241), + 85: uint16(54243), + 86: uint16(54252), + 87: uint16(54253), + 88: uint16(54256), + 89: uint16(54260), + 90: uint16(54268), + 91: uint16(54269), + 92: uint16(54271), + 93: uint16(54273), + }, + 38: { + 0: uint16(54280), + 1: uint16(54301), + 2: uint16(54336), + 3: uint16(54340), + 4: uint16(54364), + 5: uint16(54368), + 6: uint16(54372), + 7: uint16(54381), + 8: uint16(54383), + 9: uint16(54392), + 10: uint16(54393), + 11: uint16(54396), + 12: uint16(54399), + 13: uint16(54400), + 14: uint16(54402), + 15: uint16(54408), + 16: uint16(54409), + 17: uint16(54411), + 18: uint16(54413), + 19: uint16(54420), + 20: uint16(54441), + 21: uint16(54476), + 22: uint16(54480), + 23: uint16(54484), + 24: uint16(54492), + 25: uint16(54495), + 26: uint16(54504), + 27: uint16(54508), + 28: uint16(54512), + 29: uint16(54520), + 30: uint16(54523), + 31: uint16(54525), + 32: uint16(54532), + 33: uint16(54536), + 34: uint16(54540), + 35: uint16(54548), + 36: uint16(54549), + 37: uint16(54551), + 38: uint16(54588), + 39: uint16(54589), + 40: uint16(54592), + 41: uint16(54596), + 42: uint16(54604), + 43: uint16(54605), + 44: uint16(54607), + 45: uint16(54609), + 46: uint16(54616), + 47: uint16(54617), + 48: uint16(54620), + 49: uint16(54624), + 50: uint16(54629), + 51: uint16(54632), + 52: uint16(54633), + 53: uint16(54635), + 54: uint16(54637), + 55: uint16(54644), + 56: uint16(54645), + 57: uint16(54648), + 58: uint16(54652), + 59: uint16(54660), + 60: uint16(54661), + 61: uint16(54663), + 62: uint16(54664), + 63: uint16(54665), + 64: uint16(54672), + 65: uint16(54693), + 66: uint16(54728), + 67: uint16(54729), + 68: uint16(54732), + 69: uint16(54736), + 70: uint16(54738), + 71: uint16(54744), + 72: uint16(54745), + 73: uint16(54747), + 74: uint16(54749), + 75: uint16(54756), + 76: uint16(54757), + 77: uint16(54760), + 78: uint16(54764), + 79: uint16(54772), + 80: uint16(54773), + 81: uint16(54775), + 82: uint16(54777), + 83: uint16(54784), + 84: uint16(54785), + 85: uint16(54788), + 86: uint16(54792), + 87: uint16(54800), + 88: uint16(54801), + 89: uint16(54803), + 90: uint16(54804), + 91: uint16(54805), + 92: uint16(54812), + 93: uint16(54816), + }, + 39: { + 0: uint16(54820), + 1: uint16(54829), + 2: uint16(54840), + 3: uint16(54841), + 4: uint16(54844), + 5: uint16(54848), + 6: uint16(54853), + 7: uint16(54856), + 8: uint16(54857), + 9: uint16(54859), + 10: uint16(54861), + 11: uint16(54865), + 12: uint16(54868), + 13: uint16(54869), + 14: uint16(54872), + 15: uint16(54876), + 16: uint16(54887), + 17: uint16(54889), + 18: uint16(54896), + 19: uint16(54897), + 20: uint16(54900), + 21: uint16(54915), + 22: uint16(54917), + 23: uint16(54924), + 24: uint16(54925), + 25: uint16(54928), + 26: uint16(54932), + 27: uint16(54941), + 28: uint16(54943), + 29: uint16(54945), + 30: uint16(54952), + 31: uint16(54956), + 32: uint16(54960), + 33: uint16(54969), + 34: uint16(54971), + 35: uint16(54980), + 36: uint16(54981), + 37: uint16(54984), + 38: uint16(54988), + 39: uint16(54993), + 40: uint16(54996), + 41: uint16(54999), + 42: uint16(55001), + 43: uint16(55008), + 44: uint16(55012), + 45: uint16(55016), + 46: uint16(55024), + 47: uint16(55029), + 48: uint16(55036), + 49: uint16(55037), + 50: uint16(55040), + 51: uint16(55044), + 52: uint16(55057), + 53: uint16(55064), + 54: uint16(55065), + 55: uint16(55068), + 56: uint16(55072), + 57: uint16(55080), + 58: uint16(55081), + 59: uint16(55083), + 60: uint16(55085), + 61: uint16(55092), + 62: uint16(55093), + 63: uint16(55096), + 64: uint16(55100), + 65: uint16(55108), + 66: uint16(55111), + 67: uint16(55113), + 68: uint16(55120), + 69: uint16(55121), + 70: uint16(55124), + 71: uint16(55126), + 72: uint16(55127), + 73: uint16(55128), + 74: uint16(55129), + 75: uint16(55136), + 76: uint16(55137), + 77: uint16(55139), + 78: uint16(55141), + 79: uint16(55145), + 80: uint16(55148), + 81: uint16(55152), + 82: uint16(55156), + 83: uint16(55164), + 84: uint16(55165), + 85: uint16(55169), + 86: uint16(55176), + 87: uint16(55177), + 88: uint16(55180), + 89: uint16(55184), + 90: uint16(55192), + 91: uint16(55193), + 92: uint16(55195), + 93: uint16(55197), + }, + 40: {}, + 41: { + 0: uint16(20285), + 1: uint16(20339), + 2: uint16(20551), + 3: uint16(20729), + 4: uint16(21152), + 5: uint16(21487), + 6: uint16(21621), + 7: uint16(21733), + 8: uint16(22025), + 9: uint16(23233), + 10: uint16(23478), + 11: uint16(26247), + 12: uint16(26550), + 13: uint16(26551), + 14: uint16(26607), + 15: uint16(27468), + 16: uint16(29634), + 17: uint16(30146), + 18: uint16(31292), + 19: uint16(33499), + 20: uint16(33540), + 21: uint16(34903), + 22: uint16(34952), + 23: uint16(35382), + 24: uint16(36040), + 25: uint16(36303), + 26: uint16(36603), + 27: uint16(36838), + 28: uint16(39381), + 29: uint16(21051), + 30: uint16(21364), + 31: uint16(21508), + 32: uint16(24682), + 33: uint16(24932), + 34: uint16(27580), + 35: uint16(29647), + 36: uint16(33050), + 37: uint16(35258), + 38: uint16(35282), + 39: uint16(38307), + 40: uint16(20355), + 41: uint16(21002), + 42: uint16(22718), + 43: uint16(22904), + 44: uint16(23014), + 45: uint16(24178), + 46: uint16(24185), + 47: uint16(25031), + 48: uint16(25536), + 49: uint16(26438), + 50: uint16(26604), + 51: uint16(26751), + 52: uint16(28567), + 53: uint16(30286), + 54: uint16(30475), + 55: uint16(30965), + 56: uint16(31240), + 57: uint16(31487), + 58: uint16(31777), + 59: uint16(32925), + 60: uint16(33390), + 61: uint16(33393), + 62: uint16(35563), + 63: uint16(38291), + 64: uint16(20075), + 65: uint16(21917), + 66: uint16(26359), + 67: uint16(28212), + 68: uint16(30883), + 69: uint16(31469), + 70: uint16(33883), + 71: uint16(35088), + 72: uint16(34638), + 73: uint16(38824), + 74: uint16(21208), + 75: uint16(22350), + 76: uint16(22570), + 77: uint16(23884), + 78: uint16(24863), + 79: uint16(25022), + 80: uint16(25121), + 81: uint16(25954), + 82: uint16(26577), + 83: uint16(27204), + 84: uint16(28187), + 85: uint16(29976), + 86: uint16(30131), + 87: uint16(30435), + 88: uint16(30640), + 89: uint16(32058), + 90: uint16(37039), + 91: uint16(37969), + 92: uint16(37970), + 93: uint16(40853), + }, + 42: { + 0: uint16(21283), + 1: uint16(23724), + 2: uint16(30002), + 3: uint16(32987), + 4: uint16(37440), + 5: uint16(38296), + 6: uint16(21083), + 7: uint16(22536), + 8: uint16(23004), + 9: uint16(23713), + 10: uint16(23831), + 11: uint16(24247), + 12: uint16(24378), + 13: uint16(24394), + 14: uint16(24951), + 15: uint16(27743), + 16: uint16(30074), + 17: uint16(30086), + 18: uint16(31968), + 19: uint16(32115), + 20: uint16(32177), + 21: uint16(32652), + 22: uint16(33108), + 23: uint16(33313), + 24: uint16(34193), + 25: uint16(35137), + 26: uint16(35611), + 27: uint16(37628), + 28: uint16(38477), + 29: uint16(40007), + 30: uint16(20171), + 31: uint16(20215), + 32: uint16(20491), + 33: uint16(20977), + 34: uint16(22607), + 35: uint16(24887), + 36: uint16(24894), + 37: uint16(24936), + 38: uint16(25913), + 39: uint16(27114), + 40: uint16(28433), + 41: uint16(30117), + 42: uint16(30342), + 43: uint16(30422), + 44: uint16(31623), + 45: uint16(33445), + 46: uint16(33995), + 47: uint16(63744), + 48: uint16(37799), + 49: uint16(38283), + 50: uint16(21888), + 51: uint16(23458), + 52: uint16(22353), + 53: uint16(63745), + 54: uint16(31923), + 55: uint16(32697), + 56: uint16(37301), + 57: uint16(20520), + 58: uint16(21435), + 59: uint16(23621), + 60: uint16(24040), + 61: uint16(25298), + 62: uint16(25454), + 63: uint16(25818), + 64: uint16(25831), + 65: uint16(28192), + 66: uint16(28844), + 67: uint16(31067), + 68: uint16(36317), + 69: uint16(36382), + 70: uint16(63746), + 71: uint16(36989), + 72: uint16(37445), + 73: uint16(37624), + 74: uint16(20094), + 75: uint16(20214), + 76: uint16(20581), + 77: uint16(24062), + 78: uint16(24314), + 79: uint16(24838), + 80: uint16(26967), + 81: uint16(33137), + 82: uint16(34388), + 83: uint16(36423), + 84: uint16(37749), + 85: uint16(39467), + 86: uint16(20062), + 87: uint16(20625), + 88: uint16(26480), + 89: uint16(26688), + 90: uint16(20745), + 91: uint16(21133), + 92: uint16(21138), + 93: uint16(27298), + }, + 43: { + 0: uint16(30652), + 1: uint16(37392), + 2: uint16(40660), + 3: uint16(21163), + 4: uint16(24623), + 5: uint16(36850), + 6: uint16(20552), + 7: uint16(25001), + 8: uint16(25581), + 9: uint16(25802), + 10: uint16(26684), + 11: uint16(27268), + 12: uint16(28608), + 13: uint16(33160), + 14: uint16(35233), + 15: uint16(38548), + 16: uint16(22533), + 17: uint16(29309), + 18: uint16(29356), + 19: uint16(29956), + 20: uint16(32121), + 21: uint16(32365), + 22: uint16(32937), + 23: uint16(35211), + 24: uint16(35700), + 25: uint16(36963), + 26: uint16(40273), + 27: uint16(25225), + 28: uint16(27770), + 29: uint16(28500), + 30: uint16(32080), + 31: uint16(32570), + 32: uint16(35363), + 33: uint16(20860), + 34: uint16(24906), + 35: uint16(31645), + 36: uint16(35609), + 37: uint16(37463), + 38: uint16(37772), + 39: uint16(20140), + 40: uint16(20435), + 41: uint16(20510), + 42: uint16(20670), + 43: uint16(20742), + 44: uint16(21185), + 45: uint16(21197), + 46: uint16(21375), + 47: uint16(22384), + 48: uint16(22659), + 49: uint16(24218), + 50: uint16(24465), + 51: uint16(24950), + 52: uint16(25004), + 53: uint16(25806), + 54: uint16(25964), + 55: uint16(26223), + 56: uint16(26299), + 57: uint16(26356), + 58: uint16(26775), + 59: uint16(28039), + 60: uint16(28805), + 61: uint16(28913), + 62: uint16(29855), + 63: uint16(29861), + 64: uint16(29898), + 65: uint16(30169), + 66: uint16(30828), + 67: uint16(30956), + 68: uint16(31455), + 69: uint16(31478), + 70: uint16(32069), + 71: uint16(32147), + 72: uint16(32789), + 73: uint16(32831), + 74: uint16(33051), + 75: uint16(33686), + 76: uint16(35686), + 77: uint16(36629), + 78: uint16(36885), + 79: uint16(37857), + 80: uint16(38915), + 81: uint16(38968), + 82: uint16(39514), + 83: uint16(39912), + 84: uint16(20418), + 85: uint16(21843), + 86: uint16(22586), + 87: uint16(22865), + 88: uint16(23395), + 89: uint16(23622), + 90: uint16(24760), + 91: uint16(25106), + 92: uint16(26690), + 93: uint16(26800), + }, + 44: { + 0: uint16(26856), + 1: uint16(28330), + 2: uint16(30028), + 3: uint16(30328), + 4: uint16(30926), + 5: uint16(31293), + 6: uint16(31995), + 7: uint16(32363), + 8: uint16(32380), + 9: uint16(35336), + 10: uint16(35489), + 11: uint16(35903), + 12: uint16(38542), + 13: uint16(40388), + 14: uint16(21476), + 15: uint16(21481), + 16: uint16(21578), + 17: uint16(21617), + 18: uint16(22266), + 19: uint16(22993), + 20: uint16(23396), + 21: uint16(23611), + 22: uint16(24235), + 23: uint16(25335), + 24: uint16(25911), + 25: uint16(25925), + 26: uint16(25970), + 27: uint16(26272), + 28: uint16(26543), + 29: uint16(27073), + 30: uint16(27837), + 31: uint16(30204), + 32: uint16(30352), + 33: uint16(30590), + 34: uint16(31295), + 35: uint16(32660), + 36: uint16(32771), + 37: uint16(32929), + 38: uint16(33167), + 39: uint16(33510), + 40: uint16(33533), + 41: uint16(33776), + 42: uint16(34241), + 43: uint16(34865), + 44: uint16(34996), + 45: uint16(35493), + 46: uint16(63747), + 47: uint16(36764), + 48: uint16(37678), + 49: uint16(38599), + 50: uint16(39015), + 51: uint16(39640), + 52: uint16(40723), + 53: uint16(21741), + 54: uint16(26011), + 55: uint16(26354), + 56: uint16(26767), + 57: uint16(31296), + 58: uint16(35895), + 59: uint16(40288), + 60: uint16(22256), + 61: uint16(22372), + 62: uint16(23825), + 63: uint16(26118), + 64: uint16(26801), + 65: uint16(26829), + 66: uint16(28414), + 67: uint16(29736), + 68: uint16(34974), + 69: uint16(39908), + 70: uint16(27752), + 71: uint16(63748), + 72: uint16(39592), + 73: uint16(20379), + 74: uint16(20844), + 75: uint16(20849), + 76: uint16(21151), + 77: uint16(23380), + 78: uint16(24037), + 79: uint16(24656), + 80: uint16(24685), + 81: uint16(25329), + 82: uint16(25511), + 83: uint16(25915), + 84: uint16(29657), + 85: uint16(31354), + 86: uint16(34467), + 87: uint16(36002), + 88: uint16(38799), + 89: uint16(20018), + 90: uint16(23521), + 91: uint16(25096), + 92: uint16(26524), + 93: uint16(29916), + }, + 45: { + 0: uint16(31185), + 1: uint16(33747), + 2: uint16(35463), + 3: uint16(35506), + 4: uint16(36328), + 5: uint16(36942), + 6: uint16(37707), + 7: uint16(38982), + 8: uint16(24275), + 9: uint16(27112), + 10: uint16(34303), + 11: uint16(37101), + 12: uint16(63749), + 13: uint16(20896), + 14: uint16(23448), + 15: uint16(23532), + 16: uint16(24931), + 17: uint16(26874), + 18: uint16(27454), + 19: uint16(28748), + 20: uint16(29743), + 21: uint16(29912), + 22: uint16(31649), + 23: uint16(32592), + 24: uint16(33733), + 25: uint16(35264), + 26: uint16(36011), + 27: uint16(38364), + 28: uint16(39208), + 29: uint16(21038), + 30: uint16(24669), + 31: uint16(25324), + 32: uint16(36866), + 33: uint16(20362), + 34: uint16(20809), + 35: uint16(21281), + 36: uint16(22745), + 37: uint16(24291), + 38: uint16(26336), + 39: uint16(27960), + 40: uint16(28826), + 41: uint16(29378), + 42: uint16(29654), + 43: uint16(31568), + 44: uint16(33009), + 45: uint16(37979), + 46: uint16(21350), + 47: uint16(25499), + 48: uint16(32619), + 49: uint16(20054), + 50: uint16(20608), + 51: uint16(22602), + 52: uint16(22750), + 53: uint16(24618), + 54: uint16(24871), + 55: uint16(25296), + 56: uint16(27088), + 57: uint16(39745), + 58: uint16(23439), + 59: uint16(32024), + 60: uint16(32945), + 61: uint16(36703), + 62: uint16(20132), + 63: uint16(20689), + 64: uint16(21676), + 65: uint16(21932), + 66: uint16(23308), + 67: uint16(23968), + 68: uint16(24039), + 69: uint16(25898), + 70: uint16(25934), + 71: uint16(26657), + 72: uint16(27211), + 73: uint16(29409), + 74: uint16(30350), + 75: uint16(30703), + 76: uint16(32094), + 77: uint16(32761), + 78: uint16(33184), + 79: uint16(34126), + 80: uint16(34527), + 81: uint16(36611), + 82: uint16(36686), + 83: uint16(37066), + 84: uint16(39171), + 85: uint16(39509), + 86: uint16(39851), + 87: uint16(19992), + 88: uint16(20037), + 89: uint16(20061), + 90: uint16(20167), + 91: uint16(20465), + 92: uint16(20855), + 93: uint16(21246), + }, + 46: { + 0: uint16(21312), + 1: uint16(21475), + 2: uint16(21477), + 3: uint16(21646), + 4: uint16(22036), + 5: uint16(22389), + 6: uint16(22434), + 7: uint16(23495), + 8: uint16(23943), + 9: uint16(24272), + 10: uint16(25084), + 11: uint16(25304), + 12: uint16(25937), + 13: uint16(26552), + 14: uint16(26601), + 15: uint16(27083), + 16: uint16(27472), + 17: uint16(27590), + 18: uint16(27628), + 19: uint16(27714), + 20: uint16(28317), + 21: uint16(28792), + 22: uint16(29399), + 23: uint16(29590), + 24: uint16(29699), + 25: uint16(30655), + 26: uint16(30697), + 27: uint16(31350), + 28: uint16(32127), + 29: uint16(32777), + 30: uint16(33276), + 31: uint16(33285), + 32: uint16(33290), + 33: uint16(33503), + 34: uint16(34914), + 35: uint16(35635), + 36: uint16(36092), + 37: uint16(36544), + 38: uint16(36881), + 39: uint16(37041), + 40: uint16(37476), + 41: uint16(37558), + 42: uint16(39378), + 43: uint16(39493), + 44: uint16(40169), + 45: uint16(40407), + 46: uint16(40860), + 47: uint16(22283), + 48: uint16(23616), + 49: uint16(33738), + 50: uint16(38816), + 51: uint16(38827), + 52: uint16(40628), + 53: uint16(21531), + 54: uint16(31384), + 55: uint16(32676), + 56: uint16(35033), + 57: uint16(36557), + 58: uint16(37089), + 59: uint16(22528), + 60: uint16(23624), + 61: uint16(25496), + 62: uint16(31391), + 63: uint16(23470), + 64: uint16(24339), + 65: uint16(31353), + 66: uint16(31406), + 67: uint16(33422), + 68: uint16(36524), + 69: uint16(20518), + 70: uint16(21048), + 71: uint16(21240), + 72: uint16(21367), + 73: uint16(22280), + 74: uint16(25331), + 75: uint16(25458), + 76: uint16(27402), + 77: uint16(28099), + 78: uint16(30519), + 79: uint16(21413), + 80: uint16(29527), + 81: uint16(34152), + 82: uint16(36470), + 83: uint16(38357), + 84: uint16(26426), + 85: uint16(27331), + 86: uint16(28528), + 87: uint16(35437), + 88: uint16(36556), + 89: uint16(39243), + 90: uint16(63750), + 91: uint16(26231), + 92: uint16(27512), + 93: uint16(36020), + }, + 47: { + 0: uint16(39740), + 1: uint16(63751), + 2: uint16(21483), + 3: uint16(22317), + 4: uint16(22862), + 5: uint16(25542), + 6: uint16(27131), + 7: uint16(29674), + 8: uint16(30789), + 9: uint16(31418), + 10: uint16(31429), + 11: uint16(31998), + 12: uint16(33909), + 13: uint16(35215), + 14: uint16(36211), + 15: uint16(36917), + 16: uint16(38312), + 17: uint16(21243), + 18: uint16(22343), + 19: uint16(30023), + 20: uint16(31584), + 21: uint16(33740), + 22: uint16(37406), + 23: uint16(63752), + 24: uint16(27224), + 25: uint16(20811), + 26: uint16(21067), + 27: uint16(21127), + 28: uint16(25119), + 29: uint16(26840), + 30: uint16(26997), + 31: uint16(38553), + 32: uint16(20677), + 33: uint16(21156), + 34: uint16(21220), + 35: uint16(25027), + 36: uint16(26020), + 37: uint16(26681), + 38: uint16(27135), + 39: uint16(29822), + 40: uint16(31563), + 41: uint16(33465), + 42: uint16(33771), + 43: uint16(35250), + 44: uint16(35641), + 45: uint16(36817), + 46: uint16(39241), + 47: uint16(63753), + 48: uint16(20170), + 49: uint16(22935), + 50: uint16(25810), + 51: uint16(26129), + 52: uint16(27278), + 53: uint16(29748), + 54: uint16(31105), + 55: uint16(31165), + 56: uint16(33449), + 57: uint16(34942), + 58: uint16(34943), + 59: uint16(35167), + 60: uint16(63754), + 61: uint16(37670), + 62: uint16(20235), + 63: uint16(21450), + 64: uint16(24613), + 65: uint16(25201), + 66: uint16(27762), + 67: uint16(32026), + 68: uint16(32102), + 69: uint16(20120), + 70: uint16(20834), + 71: uint16(30684), + 72: uint16(32943), + 73: uint16(20225), + 74: uint16(20238), + 75: uint16(20854), + 76: uint16(20864), + 77: uint16(21980), + 78: uint16(22120), + 79: uint16(22331), + 80: uint16(22522), + 81: uint16(22524), + 82: uint16(22804), + 83: uint16(22855), + 84: uint16(22931), + 85: uint16(23492), + 86: uint16(23696), + 87: uint16(23822), + 88: uint16(24049), + 89: uint16(24190), + 90: uint16(24524), + 91: uint16(25216), + 92: uint16(26071), + 93: uint16(26083), + }, + 48: { + 0: uint16(26398), + 1: uint16(26399), + 2: uint16(26462), + 3: uint16(26827), + 4: uint16(26820), + 5: uint16(27231), + 6: uint16(27450), + 7: uint16(27683), + 8: uint16(27773), + 9: uint16(27778), + 10: uint16(28103), + 11: uint16(29592), + 12: uint16(29734), + 13: uint16(29738), + 14: uint16(29826), + 15: uint16(29859), + 16: uint16(30072), + 17: uint16(30079), + 18: uint16(30849), + 19: uint16(30959), + 20: uint16(31041), + 21: uint16(31047), + 22: uint16(31048), + 23: uint16(31098), + 24: uint16(31637), + 25: uint16(32000), + 26: uint16(32186), + 27: uint16(32648), + 28: uint16(32774), + 29: uint16(32813), + 30: uint16(32908), + 31: uint16(35352), + 32: uint16(35663), + 33: uint16(35912), + 34: uint16(36215), + 35: uint16(37665), + 36: uint16(37668), + 37: uint16(39138), + 38: uint16(39249), + 39: uint16(39438), + 40: uint16(39439), + 41: uint16(39525), + 42: uint16(40594), + 43: uint16(32202), + 44: uint16(20342), + 45: uint16(21513), + 46: uint16(25326), + 47: uint16(26708), + 48: uint16(37329), + 49: uint16(21931), + 50: uint16(20794), + 51: uint16(63755), + 52: uint16(63756), + 53: uint16(23068), + 54: uint16(25062), + 55: uint16(63757), + 56: uint16(25295), + 57: uint16(25343), + 58: uint16(63758), + 59: uint16(63759), + 60: uint16(63760), + 61: uint16(63761), + 62: uint16(63762), + 63: uint16(63763), + 64: uint16(37027), + 65: uint16(63764), + 66: uint16(63765), + 67: uint16(63766), + 68: uint16(63767), + 69: uint16(63768), + 70: uint16(35582), + 71: uint16(63769), + 72: uint16(63770), + 73: uint16(63771), + 74: uint16(63772), + 75: uint16(26262), + 76: uint16(63773), + 77: uint16(29014), + 78: uint16(63774), + 79: uint16(63775), + 80: uint16(38627), + 81: uint16(63776), + 82: uint16(25423), + 83: uint16(25466), + 84: uint16(21335), + 85: uint16(63777), + 86: uint16(26511), + 87: uint16(26976), + 88: uint16(28275), + 89: uint16(63778), + 90: uint16(30007), + 91: uint16(63779), + 92: uint16(63780), + 93: uint16(63781), + }, + 49: { + 0: uint16(32013), + 1: uint16(63782), + 2: uint16(63783), + 3: uint16(34930), + 4: uint16(22218), + 5: uint16(23064), + 6: uint16(63784), + 7: uint16(63785), + 8: uint16(63786), + 9: uint16(63787), + 10: uint16(63788), + 11: uint16(20035), + 12: uint16(63789), + 13: uint16(20839), + 14: uint16(22856), + 15: uint16(26608), + 16: uint16(32784), + 17: uint16(63790), + 18: uint16(22899), + 19: uint16(24180), + 20: uint16(25754), + 21: uint16(31178), + 22: uint16(24565), + 23: uint16(24684), + 24: uint16(25288), + 25: uint16(25467), + 26: uint16(23527), + 27: uint16(23511), + 28: uint16(21162), + 29: uint16(63791), + 30: uint16(22900), + 31: uint16(24361), + 32: uint16(24594), + 33: uint16(63792), + 34: uint16(63793), + 35: uint16(63794), + 36: uint16(29785), + 37: uint16(63795), + 38: uint16(63796), + 39: uint16(63797), + 40: uint16(63798), + 41: uint16(63799), + 42: uint16(63800), + 43: uint16(39377), + 44: uint16(63801), + 45: uint16(63802), + 46: uint16(63803), + 47: uint16(63804), + 48: uint16(63805), + 49: uint16(63806), + 50: uint16(63807), + 51: uint16(63808), + 52: uint16(63809), + 53: uint16(63810), + 54: uint16(63811), + 55: uint16(28611), + 56: uint16(63812), + 57: uint16(63813), + 58: uint16(33215), + 59: uint16(36786), + 60: uint16(24817), + 61: uint16(63814), + 62: uint16(63815), + 63: uint16(33126), + 64: uint16(63816), + 65: uint16(63817), + 66: uint16(23615), + 67: uint16(63818), + 68: uint16(63819), + 69: uint16(63820), + 70: uint16(63821), + 71: uint16(63822), + 72: uint16(63823), + 73: uint16(63824), + 74: uint16(63825), + 75: uint16(23273), + 76: uint16(35365), + 77: uint16(26491), + 78: uint16(32016), + 79: uint16(63826), + 80: uint16(63827), + 81: uint16(63828), + 82: uint16(63829), + 83: uint16(63830), + 84: uint16(63831), + 85: uint16(33021), + 86: uint16(63832), + 87: uint16(63833), + 88: uint16(23612), + 89: uint16(27877), + 90: uint16(21311), + 91: uint16(28346), + 92: uint16(22810), + 93: uint16(33590), + }, + 50: { + 0: uint16(20025), + 1: uint16(20150), + 2: uint16(20294), + 3: uint16(21934), + 4: uint16(22296), + 5: uint16(22727), + 6: uint16(24406), + 7: uint16(26039), + 8: uint16(26086), + 9: uint16(27264), + 10: uint16(27573), + 11: uint16(28237), + 12: uint16(30701), + 13: uint16(31471), + 14: uint16(31774), + 15: uint16(32222), + 16: uint16(34507), + 17: uint16(34962), + 18: uint16(37170), + 19: uint16(37723), + 20: uint16(25787), + 21: uint16(28606), + 22: uint16(29562), + 23: uint16(30136), + 24: uint16(36948), + 25: uint16(21846), + 26: uint16(22349), + 27: uint16(25018), + 28: uint16(25812), + 29: uint16(26311), + 30: uint16(28129), + 31: uint16(28251), + 32: uint16(28525), + 33: uint16(28601), + 34: uint16(30192), + 35: uint16(32835), + 36: uint16(33213), + 37: uint16(34113), + 38: uint16(35203), + 39: uint16(35527), + 40: uint16(35674), + 41: uint16(37663), + 42: uint16(27795), + 43: uint16(30035), + 44: uint16(31572), + 45: uint16(36367), + 46: uint16(36957), + 47: uint16(21776), + 48: uint16(22530), + 49: uint16(22616), + 50: uint16(24162), + 51: uint16(25095), + 52: uint16(25758), + 53: uint16(26848), + 54: uint16(30070), + 55: uint16(31958), + 56: uint16(34739), + 57: uint16(40680), + 58: uint16(20195), + 59: uint16(22408), + 60: uint16(22382), + 61: uint16(22823), + 62: uint16(23565), + 63: uint16(23729), + 64: uint16(24118), + 65: uint16(24453), + 66: uint16(25140), + 67: uint16(25825), + 68: uint16(29619), + 69: uint16(33274), + 70: uint16(34955), + 71: uint16(36024), + 72: uint16(38538), + 73: uint16(40667), + 74: uint16(23429), + 75: uint16(24503), + 76: uint16(24755), + 77: uint16(20498), + 78: uint16(20992), + 79: uint16(21040), + 80: uint16(22294), + 81: uint16(22581), + 82: uint16(22615), + 83: uint16(23566), + 84: uint16(23648), + 85: uint16(23798), + 86: uint16(23947), + 87: uint16(24230), + 88: uint16(24466), + 89: uint16(24764), + 90: uint16(25361), + 91: uint16(25481), + 92: uint16(25623), + 93: uint16(26691), + }, + 51: { + 0: uint16(26873), + 1: uint16(27330), + 2: uint16(28120), + 3: uint16(28193), + 4: uint16(28372), + 5: uint16(28644), + 6: uint16(29182), + 7: uint16(30428), + 8: uint16(30585), + 9: uint16(31153), + 10: uint16(31291), + 11: uint16(33796), + 12: uint16(35241), + 13: uint16(36077), + 14: uint16(36339), + 15: uint16(36424), + 16: uint16(36867), + 17: uint16(36884), + 18: uint16(36947), + 19: uint16(37117), + 20: uint16(37709), + 21: uint16(38518), + 22: uint16(38876), + 23: uint16(27602), + 24: uint16(28678), + 25: uint16(29272), + 26: uint16(29346), + 27: uint16(29544), + 28: uint16(30563), + 29: uint16(31167), + 30: uint16(31716), + 31: uint16(32411), + 32: uint16(35712), + 33: uint16(22697), + 34: uint16(24775), + 35: uint16(25958), + 36: uint16(26109), + 37: uint16(26302), + 38: uint16(27788), + 39: uint16(28958), + 40: uint16(29129), + 41: uint16(35930), + 42: uint16(38931), + 43: uint16(20077), + 44: uint16(31361), + 45: uint16(20189), + 46: uint16(20908), + 47: uint16(20941), + 48: uint16(21205), + 49: uint16(21516), + 50: uint16(24999), + 51: uint16(26481), + 52: uint16(26704), + 53: uint16(26847), + 54: uint16(27934), + 55: uint16(28540), + 56: uint16(30140), + 57: uint16(30643), + 58: uint16(31461), + 59: uint16(33012), + 60: uint16(33891), + 61: uint16(37509), + 62: uint16(20828), + 63: uint16(26007), + 64: uint16(26460), + 65: uint16(26515), + 66: uint16(30168), + 67: uint16(31431), + 68: uint16(33651), + 69: uint16(63834), + 70: uint16(35910), + 71: uint16(36887), + 72: uint16(38957), + 73: uint16(23663), + 74: uint16(33216), + 75: uint16(33434), + 76: uint16(36929), + 77: uint16(36975), + 78: uint16(37389), + 79: uint16(24471), + 80: uint16(23965), + 81: uint16(27225), + 82: uint16(29128), + 83: uint16(30331), + 84: uint16(31561), + 85: uint16(34276), + 86: uint16(35588), + 87: uint16(37159), + 88: uint16(39472), + 89: uint16(21895), + 90: uint16(25078), + 91: uint16(63835), + 92: uint16(30313), + 93: uint16(32645), + }, + 52: { + 0: uint16(34367), + 1: uint16(34746), + 2: uint16(35064), + 3: uint16(37007), + 4: uint16(63836), + 5: uint16(27931), + 6: uint16(28889), + 7: uint16(29662), + 8: uint16(32097), + 9: uint16(33853), + 10: uint16(63837), + 11: uint16(37226), + 12: uint16(39409), + 13: uint16(63838), + 14: uint16(20098), + 15: uint16(21365), + 16: uint16(27396), + 17: uint16(27410), + 18: uint16(28734), + 19: uint16(29211), + 20: uint16(34349), + 21: uint16(40478), + 22: uint16(21068), + 23: uint16(36771), + 24: uint16(23888), + 25: uint16(25829), + 26: uint16(25900), + 27: uint16(27414), + 28: uint16(28651), + 29: uint16(31811), + 30: uint16(32412), + 31: uint16(34253), + 32: uint16(35172), + 33: uint16(35261), + 34: uint16(25289), + 35: uint16(33240), + 36: uint16(34847), + 37: uint16(24266), + 38: uint16(26391), + 39: uint16(28010), + 40: uint16(29436), + 41: uint16(29701), + 42: uint16(29807), + 43: uint16(34690), + 44: uint16(37086), + 45: uint16(20358), + 46: uint16(23821), + 47: uint16(24480), + 48: uint16(33802), + 49: uint16(20919), + 50: uint16(25504), + 51: uint16(30053), + 52: uint16(20142), + 53: uint16(20486), + 54: uint16(20841), + 55: uint16(20937), + 56: uint16(26753), + 57: uint16(27153), + 58: uint16(31918), + 59: uint16(31921), + 60: uint16(31975), + 61: uint16(33391), + 62: uint16(35538), + 63: uint16(36635), + 64: uint16(37327), + 65: uint16(20406), + 66: uint16(20791), + 67: uint16(21237), + 68: uint16(21570), + 69: uint16(24300), + 70: uint16(24942), + 71: uint16(25150), + 72: uint16(26053), + 73: uint16(27354), + 74: uint16(28670), + 75: uint16(31018), + 76: uint16(34268), + 77: uint16(34851), + 78: uint16(38317), + 79: uint16(39522), + 80: uint16(39530), + 81: uint16(40599), + 82: uint16(40654), + 83: uint16(21147), + 84: uint16(26310), + 85: uint16(27511), + 86: uint16(28701), + 87: uint16(31019), + 88: uint16(36706), + 89: uint16(38722), + 90: uint16(24976), + 91: uint16(25088), + 92: uint16(25891), + 93: uint16(28451), + }, + 53: { + 0: uint16(29001), + 1: uint16(29833), + 2: uint16(32244), + 3: uint16(32879), + 4: uint16(34030), + 5: uint16(36646), + 6: uint16(36899), + 7: uint16(37706), + 8: uint16(20925), + 9: uint16(21015), + 10: uint16(21155), + 11: uint16(27916), + 12: uint16(28872), + 13: uint16(35010), + 14: uint16(24265), + 15: uint16(25986), + 16: uint16(27566), + 17: uint16(28610), + 18: uint16(31806), + 19: uint16(29557), + 20: uint16(20196), + 21: uint16(20278), + 22: uint16(22265), + 23: uint16(63839), + 24: uint16(23738), + 25: uint16(23994), + 26: uint16(24604), + 27: uint16(29618), + 28: uint16(31533), + 29: uint16(32666), + 30: uint16(32718), + 31: uint16(32838), + 32: uint16(36894), + 33: uint16(37428), + 34: uint16(38646), + 35: uint16(38728), + 36: uint16(38936), + 37: uint16(40801), + 38: uint16(20363), + 39: uint16(28583), + 40: uint16(31150), + 41: uint16(37300), + 42: uint16(38583), + 43: uint16(21214), + 44: uint16(63840), + 45: uint16(25736), + 46: uint16(25796), + 47: uint16(27347), + 48: uint16(28510), + 49: uint16(28696), + 50: uint16(29200), + 51: uint16(30439), + 52: uint16(32769), + 53: uint16(34310), + 54: uint16(34396), + 55: uint16(36335), + 56: uint16(36613), + 57: uint16(38706), + 58: uint16(39791), + 59: uint16(40442), + 60: uint16(40565), + 61: uint16(30860), + 62: uint16(31103), + 63: uint16(32160), + 64: uint16(33737), + 65: uint16(37636), + 66: uint16(40575), + 67: uint16(40595), + 68: uint16(35542), + 69: uint16(22751), + 70: uint16(24324), + 71: uint16(26407), + 72: uint16(28711), + 73: uint16(29903), + 74: uint16(31840), + 75: uint16(32894), + 76: uint16(20769), + 77: uint16(28712), + 78: uint16(29282), + 79: uint16(30922), + 80: uint16(36034), + 81: uint16(36058), + 82: uint16(36084), + 83: uint16(38647), + 84: uint16(20102), + 85: uint16(20698), + 86: uint16(23534), + 87: uint16(24278), + 88: uint16(26009), + 89: uint16(29134), + 90: uint16(30274), + 91: uint16(30637), + 92: uint16(32842), + 93: uint16(34044), + }, + 54: { + 0: uint16(36988), + 1: uint16(39719), + 2: uint16(40845), + 3: uint16(22744), + 4: uint16(23105), + 5: uint16(23650), + 6: uint16(27155), + 7: uint16(28122), + 8: uint16(28431), + 9: uint16(30267), + 10: uint16(32047), + 11: uint16(32311), + 12: uint16(34078), + 13: uint16(35128), + 14: uint16(37860), + 15: uint16(38475), + 16: uint16(21129), + 17: uint16(26066), + 18: uint16(26611), + 19: uint16(27060), + 20: uint16(27969), + 21: uint16(28316), + 22: uint16(28687), + 23: uint16(29705), + 24: uint16(29792), + 25: uint16(30041), + 26: uint16(30244), + 27: uint16(30827), + 28: uint16(35628), + 29: uint16(39006), + 30: uint16(20845), + 31: uint16(25134), + 32: uint16(38520), + 33: uint16(20374), + 34: uint16(20523), + 35: uint16(23833), + 36: uint16(28138), + 37: uint16(32184), + 38: uint16(36650), + 39: uint16(24459), + 40: uint16(24900), + 41: uint16(26647), + 42: uint16(63841), + 43: uint16(38534), + 44: uint16(21202), + 45: uint16(32907), + 46: uint16(20956), + 47: uint16(20940), + 48: uint16(26974), + 49: uint16(31260), + 50: uint16(32190), + 51: uint16(33777), + 52: uint16(38517), + 53: uint16(20442), + 54: uint16(21033), + 55: uint16(21400), + 56: uint16(21519), + 57: uint16(21774), + 58: uint16(23653), + 59: uint16(24743), + 60: uint16(26446), + 61: uint16(26792), + 62: uint16(28012), + 63: uint16(29313), + 64: uint16(29432), + 65: uint16(29702), + 66: uint16(29827), + 67: uint16(63842), + 68: uint16(30178), + 69: uint16(31852), + 70: uint16(32633), + 71: uint16(32696), + 72: uint16(33673), + 73: uint16(35023), + 74: uint16(35041), + 75: uint16(37324), + 76: uint16(37328), + 77: uint16(38626), + 78: uint16(39881), + 79: uint16(21533), + 80: uint16(28542), + 81: uint16(29136), + 82: uint16(29848), + 83: uint16(34298), + 84: uint16(36522), + 85: uint16(38563), + 86: uint16(40023), + 87: uint16(40607), + 88: uint16(26519), + 89: uint16(28107), + 90: uint16(29747), + 91: uint16(33256), + 92: uint16(38678), + 93: uint16(30764), + }, + 55: { + 0: uint16(31435), + 1: uint16(31520), + 2: uint16(31890), + 3: uint16(25705), + 4: uint16(29802), + 5: uint16(30194), + 6: uint16(30908), + 7: uint16(30952), + 8: uint16(39340), + 9: uint16(39764), + 10: uint16(40635), + 11: uint16(23518), + 12: uint16(24149), + 13: uint16(28448), + 14: uint16(33180), + 15: uint16(33707), + 16: uint16(37000), + 17: uint16(19975), + 18: uint16(21325), + 19: uint16(23081), + 20: uint16(24018), + 21: uint16(24398), + 22: uint16(24930), + 23: uint16(25405), + 24: uint16(26217), + 25: uint16(26364), + 26: uint16(28415), + 27: uint16(28459), + 28: uint16(28771), + 29: uint16(30622), + 30: uint16(33836), + 31: uint16(34067), + 32: uint16(34875), + 33: uint16(36627), + 34: uint16(39237), + 35: uint16(39995), + 36: uint16(21788), + 37: uint16(25273), + 38: uint16(26411), + 39: uint16(27819), + 40: uint16(33545), + 41: uint16(35178), + 42: uint16(38778), + 43: uint16(20129), + 44: uint16(22916), + 45: uint16(24536), + 46: uint16(24537), + 47: uint16(26395), + 48: uint16(32178), + 49: uint16(32596), + 50: uint16(33426), + 51: uint16(33579), + 52: uint16(33725), + 53: uint16(36638), + 54: uint16(37017), + 55: uint16(22475), + 56: uint16(22969), + 57: uint16(23186), + 58: uint16(23504), + 59: uint16(26151), + 60: uint16(26522), + 61: uint16(26757), + 62: uint16(27599), + 63: uint16(29028), + 64: uint16(32629), + 65: uint16(36023), + 66: uint16(36067), + 67: uint16(36993), + 68: uint16(39749), + 69: uint16(33032), + 70: uint16(35978), + 71: uint16(38476), + 72: uint16(39488), + 73: uint16(40613), + 74: uint16(23391), + 75: uint16(27667), + 76: uint16(29467), + 77: uint16(30450), + 78: uint16(30431), + 79: uint16(33804), + 80: uint16(20906), + 81: uint16(35219), + 82: uint16(20813), + 83: uint16(20885), + 84: uint16(21193), + 85: uint16(26825), + 86: uint16(27796), + 87: uint16(30468), + 88: uint16(30496), + 89: uint16(32191), + 90: uint16(32236), + 91: uint16(38754), + 92: uint16(40629), + 93: uint16(28357), + }, + 56: { + 0: uint16(34065), + 1: uint16(20901), + 2: uint16(21517), + 3: uint16(21629), + 4: uint16(26126), + 5: uint16(26269), + 6: uint16(26919), + 7: uint16(28319), + 8: uint16(30399), + 9: uint16(30609), + 10: uint16(33559), + 11: uint16(33986), + 12: uint16(34719), + 13: uint16(37225), + 14: uint16(37528), + 15: uint16(40180), + 16: uint16(34946), + 17: uint16(20398), + 18: uint16(20882), + 19: uint16(21215), + 20: uint16(22982), + 21: uint16(24125), + 22: uint16(24917), + 23: uint16(25720), + 24: uint16(25721), + 25: uint16(26286), + 26: uint16(26576), + 27: uint16(27169), + 28: uint16(27597), + 29: uint16(27611), + 30: uint16(29279), + 31: uint16(29281), + 32: uint16(29761), + 33: uint16(30520), + 34: uint16(30683), + 35: uint16(32791), + 36: uint16(33468), + 37: uint16(33541), + 38: uint16(35584), + 39: uint16(35624), + 40: uint16(35980), + 41: uint16(26408), + 42: uint16(27792), + 43: uint16(29287), + 44: uint16(30446), + 45: uint16(30566), + 46: uint16(31302), + 47: uint16(40361), + 48: uint16(27519), + 49: uint16(27794), + 50: uint16(22818), + 51: uint16(26406), + 52: uint16(33945), + 53: uint16(21359), + 54: uint16(22675), + 55: uint16(22937), + 56: uint16(24287), + 57: uint16(25551), + 58: uint16(26164), + 59: uint16(26483), + 60: uint16(28218), + 61: uint16(29483), + 62: uint16(31447), + 63: uint16(33495), + 64: uint16(37672), + 65: uint16(21209), + 66: uint16(24043), + 67: uint16(25006), + 68: uint16(25035), + 69: uint16(25098), + 70: uint16(25287), + 71: uint16(25771), + 72: uint16(26080), + 73: uint16(26969), + 74: uint16(27494), + 75: uint16(27595), + 76: uint16(28961), + 77: uint16(29687), + 78: uint16(30045), + 79: uint16(32326), + 80: uint16(33310), + 81: uint16(33538), + 82: uint16(34154), + 83: uint16(35491), + 84: uint16(36031), + 85: uint16(38695), + 86: uint16(40289), + 87: uint16(22696), + 88: uint16(40664), + 89: uint16(20497), + 90: uint16(21006), + 91: uint16(21563), + 92: uint16(21839), + 93: uint16(25991), + }, + 57: { + 0: uint16(27766), + 1: uint16(32010), + 2: uint16(32011), + 3: uint16(32862), + 4: uint16(34442), + 5: uint16(38272), + 6: uint16(38639), + 7: uint16(21247), + 8: uint16(27797), + 9: uint16(29289), + 10: uint16(21619), + 11: uint16(23194), + 12: uint16(23614), + 13: uint16(23883), + 14: uint16(24396), + 15: uint16(24494), + 16: uint16(26410), + 17: uint16(26806), + 18: uint16(26979), + 19: uint16(28220), + 20: uint16(28228), + 21: uint16(30473), + 22: uint16(31859), + 23: uint16(32654), + 24: uint16(34183), + 25: uint16(35598), + 26: uint16(36855), + 27: uint16(38753), + 28: uint16(40692), + 29: uint16(23735), + 30: uint16(24758), + 31: uint16(24845), + 32: uint16(25003), + 33: uint16(25935), + 34: uint16(26107), + 35: uint16(26108), + 36: uint16(27665), + 37: uint16(27887), + 38: uint16(29599), + 39: uint16(29641), + 40: uint16(32225), + 41: uint16(38292), + 42: uint16(23494), + 43: uint16(34588), + 44: uint16(35600), + 45: uint16(21085), + 46: uint16(21338), + 47: uint16(25293), + 48: uint16(25615), + 49: uint16(25778), + 50: uint16(26420), + 51: uint16(27192), + 52: uint16(27850), + 53: uint16(29632), + 54: uint16(29854), + 55: uint16(31636), + 56: uint16(31893), + 57: uint16(32283), + 58: uint16(33162), + 59: uint16(33334), + 60: uint16(34180), + 61: uint16(36843), + 62: uint16(38649), + 63: uint16(39361), + 64: uint16(20276), + 65: uint16(21322), + 66: uint16(21453), + 67: uint16(21467), + 68: uint16(25292), + 69: uint16(25644), + 70: uint16(25856), + 71: uint16(26001), + 72: uint16(27075), + 73: uint16(27886), + 74: uint16(28504), + 75: uint16(29677), + 76: uint16(30036), + 77: uint16(30242), + 78: uint16(30436), + 79: uint16(30460), + 80: uint16(30928), + 81: uint16(30971), + 82: uint16(31020), + 83: uint16(32070), + 84: uint16(33324), + 85: uint16(34784), + 86: uint16(36820), + 87: uint16(38930), + 88: uint16(39151), + 89: uint16(21187), + 90: uint16(25300), + 91: uint16(25765), + 92: uint16(28196), + 93: uint16(28497), + }, + 58: { + 0: uint16(30332), + 1: uint16(36299), + 2: uint16(37297), + 3: uint16(37474), + 4: uint16(39662), + 5: uint16(39747), + 6: uint16(20515), + 7: uint16(20621), + 8: uint16(22346), + 9: uint16(22952), + 10: uint16(23592), + 11: uint16(24135), + 12: uint16(24439), + 13: uint16(25151), + 14: uint16(25918), + 15: uint16(26041), + 16: uint16(26049), + 17: uint16(26121), + 18: uint16(26507), + 19: uint16(27036), + 20: uint16(28354), + 21: uint16(30917), + 22: uint16(32033), + 23: uint16(32938), + 24: uint16(33152), + 25: uint16(33323), + 26: uint16(33459), + 27: uint16(33953), + 28: uint16(34444), + 29: uint16(35370), + 30: uint16(35607), + 31: uint16(37030), + 32: uint16(38450), + 33: uint16(40848), + 34: uint16(20493), + 35: uint16(20467), + 36: uint16(63843), + 37: uint16(22521), + 38: uint16(24472), + 39: uint16(25308), + 40: uint16(25490), + 41: uint16(26479), + 42: uint16(28227), + 43: uint16(28953), + 44: uint16(30403), + 45: uint16(32972), + 46: uint16(32986), + 47: uint16(35060), + 48: uint16(35061), + 49: uint16(35097), + 50: uint16(36064), + 51: uint16(36649), + 52: uint16(37197), + 53: uint16(38506), + 54: uint16(20271), + 55: uint16(20336), + 56: uint16(24091), + 57: uint16(26575), + 58: uint16(26658), + 59: uint16(30333), + 60: uint16(30334), + 61: uint16(39748), + 62: uint16(24161), + 63: uint16(27146), + 64: uint16(29033), + 65: uint16(29140), + 66: uint16(30058), + 67: uint16(63844), + 68: uint16(32321), + 69: uint16(34115), + 70: uint16(34281), + 71: uint16(39132), + 72: uint16(20240), + 73: uint16(31567), + 74: uint16(32624), + 75: uint16(38309), + 76: uint16(20961), + 77: uint16(24070), + 78: uint16(26805), + 79: uint16(27710), + 80: uint16(27726), + 81: uint16(27867), + 82: uint16(29359), + 83: uint16(31684), + 84: uint16(33539), + 85: uint16(27861), + 86: uint16(29754), + 87: uint16(20731), + 88: uint16(21128), + 89: uint16(22721), + 90: uint16(25816), + 91: uint16(27287), + 92: uint16(29863), + 93: uint16(30294), + }, + 59: { + 0: uint16(30887), + 1: uint16(34327), + 2: uint16(38370), + 3: uint16(38713), + 4: uint16(63845), + 5: uint16(21342), + 6: uint16(24321), + 7: uint16(35722), + 8: uint16(36776), + 9: uint16(36783), + 10: uint16(37002), + 11: uint16(21029), + 12: uint16(30629), + 13: uint16(40009), + 14: uint16(40712), + 15: uint16(19993), + 16: uint16(20482), + 17: uint16(20853), + 18: uint16(23643), + 19: uint16(24183), + 20: uint16(26142), + 21: uint16(26170), + 22: uint16(26564), + 23: uint16(26821), + 24: uint16(28851), + 25: uint16(29953), + 26: uint16(30149), + 27: uint16(31177), + 28: uint16(31453), + 29: uint16(36647), + 30: uint16(39200), + 31: uint16(39432), + 32: uint16(20445), + 33: uint16(22561), + 34: uint16(22577), + 35: uint16(23542), + 36: uint16(26222), + 37: uint16(27493), + 38: uint16(27921), + 39: uint16(28282), + 40: uint16(28541), + 41: uint16(29668), + 42: uint16(29995), + 43: uint16(33769), + 44: uint16(35036), + 45: uint16(35091), + 46: uint16(35676), + 47: uint16(36628), + 48: uint16(20239), + 49: uint16(20693), + 50: uint16(21264), + 51: uint16(21340), + 52: uint16(23443), + 53: uint16(24489), + 54: uint16(26381), + 55: uint16(31119), + 56: uint16(33145), + 57: uint16(33583), + 58: uint16(34068), + 59: uint16(35079), + 60: uint16(35206), + 61: uint16(36665), + 62: uint16(36667), + 63: uint16(39333), + 64: uint16(39954), + 65: uint16(26412), + 66: uint16(20086), + 67: uint16(20472), + 68: uint16(22857), + 69: uint16(23553), + 70: uint16(23791), + 71: uint16(23792), + 72: uint16(25447), + 73: uint16(26834), + 74: uint16(28925), + 75: uint16(29090), + 76: uint16(29739), + 77: uint16(32299), + 78: uint16(34028), + 79: uint16(34562), + 80: uint16(36898), + 81: uint16(37586), + 82: uint16(40179), + 83: uint16(19981), + 84: uint16(20184), + 85: uint16(20463), + 86: uint16(20613), + 87: uint16(21078), + 88: uint16(21103), + 89: uint16(21542), + 90: uint16(21648), + 91: uint16(22496), + 92: uint16(22827), + 93: uint16(23142), + }, + 60: { + 0: uint16(23386), + 1: uint16(23413), + 2: uint16(23500), + 3: uint16(24220), + 4: uint16(63846), + 5: uint16(25206), + 6: uint16(25975), + 7: uint16(26023), + 8: uint16(28014), + 9: uint16(28325), + 10: uint16(29238), + 11: uint16(31526), + 12: uint16(31807), + 13: uint16(32566), + 14: uint16(33104), + 15: uint16(33105), + 16: uint16(33178), + 17: uint16(33344), + 18: uint16(33433), + 19: uint16(33705), + 20: uint16(35331), + 21: uint16(36000), + 22: uint16(36070), + 23: uint16(36091), + 24: uint16(36212), + 25: uint16(36282), + 26: uint16(37096), + 27: uint16(37340), + 28: uint16(38428), + 29: uint16(38468), + 30: uint16(39385), + 31: uint16(40167), + 32: uint16(21271), + 33: uint16(20998), + 34: uint16(21545), + 35: uint16(22132), + 36: uint16(22707), + 37: uint16(22868), + 38: uint16(22894), + 39: uint16(24575), + 40: uint16(24996), + 41: uint16(25198), + 42: uint16(26128), + 43: uint16(27774), + 44: uint16(28954), + 45: uint16(30406), + 46: uint16(31881), + 47: uint16(31966), + 48: uint16(32027), + 49: uint16(33452), + 50: uint16(36033), + 51: uint16(38640), + 52: uint16(63847), + 53: uint16(20315), + 54: uint16(24343), + 55: uint16(24447), + 56: uint16(25282), + 57: uint16(23849), + 58: uint16(26379), + 59: uint16(26842), + 60: uint16(30844), + 61: uint16(32323), + 62: uint16(40300), + 63: uint16(19989), + 64: uint16(20633), + 65: uint16(21269), + 66: uint16(21290), + 67: uint16(21329), + 68: uint16(22915), + 69: uint16(23138), + 70: uint16(24199), + 71: uint16(24754), + 72: uint16(24970), + 73: uint16(25161), + 74: uint16(25209), + 75: uint16(26000), + 76: uint16(26503), + 77: uint16(27047), + 78: uint16(27604), + 79: uint16(27606), + 80: uint16(27607), + 81: uint16(27608), + 82: uint16(27832), + 83: uint16(63848), + 84: uint16(29749), + 85: uint16(30202), + 86: uint16(30738), + 87: uint16(30865), + 88: uint16(31189), + 89: uint16(31192), + 90: uint16(31875), + 91: uint16(32203), + 92: uint16(32737), + 93: uint16(32933), + }, + 61: { + 0: uint16(33086), + 1: uint16(33218), + 2: uint16(33778), + 3: uint16(34586), + 4: uint16(35048), + 5: uint16(35513), + 6: uint16(35692), + 7: uint16(36027), + 8: uint16(37145), + 9: uint16(38750), + 10: uint16(39131), + 11: uint16(40763), + 12: uint16(22188), + 13: uint16(23338), + 14: uint16(24428), + 15: uint16(25996), + 16: uint16(27315), + 17: uint16(27567), + 18: uint16(27996), + 19: uint16(28657), + 20: uint16(28693), + 21: uint16(29277), + 22: uint16(29613), + 23: uint16(36007), + 24: uint16(36051), + 25: uint16(38971), + 26: uint16(24977), + 27: uint16(27703), + 28: uint16(32856), + 29: uint16(39425), + 30: uint16(20045), + 31: uint16(20107), + 32: uint16(20123), + 33: uint16(20181), + 34: uint16(20282), + 35: uint16(20284), + 36: uint16(20351), + 37: uint16(20447), + 38: uint16(20735), + 39: uint16(21490), + 40: uint16(21496), + 41: uint16(21766), + 42: uint16(21987), + 43: uint16(22235), + 44: uint16(22763), + 45: uint16(22882), + 46: uint16(23057), + 47: uint16(23531), + 48: uint16(23546), + 49: uint16(23556), + 50: uint16(24051), + 51: uint16(24107), + 52: uint16(24473), + 53: uint16(24605), + 54: uint16(25448), + 55: uint16(26012), + 56: uint16(26031), + 57: uint16(26614), + 58: uint16(26619), + 59: uint16(26797), + 60: uint16(27515), + 61: uint16(27801), + 62: uint16(27863), + 63: uint16(28195), + 64: uint16(28681), + 65: uint16(29509), + 66: uint16(30722), + 67: uint16(31038), + 68: uint16(31040), + 69: uint16(31072), + 70: uint16(31169), + 71: uint16(31721), + 72: uint16(32023), + 73: uint16(32114), + 74: uint16(32902), + 75: uint16(33293), + 76: uint16(33678), + 77: uint16(34001), + 78: uint16(34503), + 79: uint16(35039), + 80: uint16(35408), + 81: uint16(35422), + 82: uint16(35613), + 83: uint16(36060), + 84: uint16(36198), + 85: uint16(36781), + 86: uint16(37034), + 87: uint16(39164), + 88: uint16(39391), + 89: uint16(40605), + 90: uint16(21066), + 91: uint16(63849), + 92: uint16(26388), + 93: uint16(63850), + }, + 62: { + 0: uint16(20632), + 1: uint16(21034), + 2: uint16(23665), + 3: uint16(25955), + 4: uint16(27733), + 5: uint16(29642), + 6: uint16(29987), + 7: uint16(30109), + 8: uint16(31639), + 9: uint16(33948), + 10: uint16(37240), + 11: uint16(38704), + 12: uint16(20087), + 13: uint16(25746), + 14: uint16(27578), + 15: uint16(29022), + 16: uint16(34217), + 17: uint16(19977), + 18: uint16(63851), + 19: uint16(26441), + 20: uint16(26862), + 21: uint16(28183), + 22: uint16(33439), + 23: uint16(34072), + 24: uint16(34923), + 25: uint16(25591), + 26: uint16(28545), + 27: uint16(37394), + 28: uint16(39087), + 29: uint16(19978), + 30: uint16(20663), + 31: uint16(20687), + 32: uint16(20767), + 33: uint16(21830), + 34: uint16(21930), + 35: uint16(22039), + 36: uint16(23360), + 37: uint16(23577), + 38: uint16(23776), + 39: uint16(24120), + 40: uint16(24202), + 41: uint16(24224), + 42: uint16(24258), + 43: uint16(24819), + 44: uint16(26705), + 45: uint16(27233), + 46: uint16(28248), + 47: uint16(29245), + 48: uint16(29248), + 49: uint16(29376), + 50: uint16(30456), + 51: uint16(31077), + 52: uint16(31665), + 53: uint16(32724), + 54: uint16(35059), + 55: uint16(35316), + 56: uint16(35443), + 57: uint16(35937), + 58: uint16(36062), + 59: uint16(38684), + 60: uint16(22622), + 61: uint16(29885), + 62: uint16(36093), + 63: uint16(21959), + 64: uint16(63852), + 65: uint16(31329), + 66: uint16(32034), + 67: uint16(33394), + 68: uint16(29298), + 69: uint16(29983), + 70: uint16(29989), + 71: uint16(63853), + 72: uint16(31513), + 73: uint16(22661), + 74: uint16(22779), + 75: uint16(23996), + 76: uint16(24207), + 77: uint16(24246), + 78: uint16(24464), + 79: uint16(24661), + 80: uint16(25234), + 81: uint16(25471), + 82: uint16(25933), + 83: uint16(26257), + 84: uint16(26329), + 85: uint16(26360), + 86: uint16(26646), + 87: uint16(26866), + 88: uint16(29312), + 89: uint16(29790), + 90: uint16(31598), + 91: uint16(32110), + 92: uint16(32214), + 93: uint16(32626), + }, + 63: { + 0: uint16(32997), + 1: uint16(33298), + 2: uint16(34223), + 3: uint16(35199), + 4: uint16(35475), + 5: uint16(36893), + 6: uint16(37604), + 7: uint16(40653), + 8: uint16(40736), + 9: uint16(22805), + 10: uint16(22893), + 11: uint16(24109), + 12: uint16(24796), + 13: uint16(26132), + 14: uint16(26227), + 15: uint16(26512), + 16: uint16(27728), + 17: uint16(28101), + 18: uint16(28511), + 19: uint16(30707), + 20: uint16(30889), + 21: uint16(33990), + 22: uint16(37323), + 23: uint16(37675), + 24: uint16(20185), + 25: uint16(20682), + 26: uint16(20808), + 27: uint16(21892), + 28: uint16(23307), + 29: uint16(23459), + 30: uint16(25159), + 31: uint16(25982), + 32: uint16(26059), + 33: uint16(28210), + 34: uint16(29053), + 35: uint16(29697), + 36: uint16(29764), + 37: uint16(29831), + 38: uint16(29887), + 39: uint16(30316), + 40: uint16(31146), + 41: uint16(32218), + 42: uint16(32341), + 43: uint16(32680), + 44: uint16(33146), + 45: uint16(33203), + 46: uint16(33337), + 47: uint16(34330), + 48: uint16(34796), + 49: uint16(35445), + 50: uint16(36323), + 51: uint16(36984), + 52: uint16(37521), + 53: uint16(37925), + 54: uint16(39245), + 55: uint16(39854), + 56: uint16(21352), + 57: uint16(23633), + 58: uint16(26964), + 59: uint16(27844), + 60: uint16(27945), + 61: uint16(28203), + 62: uint16(33292), + 63: uint16(34203), + 64: uint16(35131), + 65: uint16(35373), + 66: uint16(35498), + 67: uint16(38634), + 68: uint16(40807), + 69: uint16(21089), + 70: uint16(26297), + 71: uint16(27570), + 72: uint16(32406), + 73: uint16(34814), + 74: uint16(36109), + 75: uint16(38275), + 76: uint16(38493), + 77: uint16(25885), + 78: uint16(28041), + 79: uint16(29166), + 80: uint16(63854), + 81: uint16(22478), + 82: uint16(22995), + 83: uint16(23468), + 84: uint16(24615), + 85: uint16(24826), + 86: uint16(25104), + 87: uint16(26143), + 88: uint16(26207), + 89: uint16(29481), + 90: uint16(29689), + 91: uint16(30427), + 92: uint16(30465), + 93: uint16(31596), + }, + 64: { + 0: uint16(32854), + 1: uint16(32882), + 2: uint16(33125), + 3: uint16(35488), + 4: uint16(37266), + 5: uint16(19990), + 6: uint16(21218), + 7: uint16(27506), + 8: uint16(27927), + 9: uint16(31237), + 10: uint16(31545), + 11: uint16(32048), + 12: uint16(63855), + 13: uint16(36016), + 14: uint16(21484), + 15: uint16(22063), + 16: uint16(22609), + 17: uint16(23477), + 18: uint16(23567), + 19: uint16(23569), + 20: uint16(24034), + 21: uint16(25152), + 22: uint16(25475), + 23: uint16(25620), + 24: uint16(26157), + 25: uint16(26803), + 26: uint16(27836), + 27: uint16(28040), + 28: uint16(28335), + 29: uint16(28703), + 30: uint16(28836), + 31: uint16(29138), + 32: uint16(29990), + 33: uint16(30095), + 34: uint16(30094), + 35: uint16(30233), + 36: uint16(31505), + 37: uint16(31712), + 38: uint16(31787), + 39: uint16(32032), + 40: uint16(32057), + 41: uint16(34092), + 42: uint16(34157), + 43: uint16(34311), + 44: uint16(35380), + 45: uint16(36877), + 46: uint16(36961), + 47: uint16(37045), + 48: uint16(37559), + 49: uint16(38902), + 50: uint16(39479), + 51: uint16(20439), + 52: uint16(23660), + 53: uint16(26463), + 54: uint16(28049), + 55: uint16(31903), + 56: uint16(32396), + 57: uint16(35606), + 58: uint16(36118), + 59: uint16(36895), + 60: uint16(23403), + 61: uint16(24061), + 62: uint16(25613), + 63: uint16(33984), + 64: uint16(36956), + 65: uint16(39137), + 66: uint16(29575), + 67: uint16(23435), + 68: uint16(24730), + 69: uint16(26494), + 70: uint16(28126), + 71: uint16(35359), + 72: uint16(35494), + 73: uint16(36865), + 74: uint16(38924), + 75: uint16(21047), + 76: uint16(63856), + 77: uint16(28753), + 78: uint16(30862), + 79: uint16(37782), + 80: uint16(34928), + 81: uint16(37335), + 82: uint16(20462), + 83: uint16(21463), + 84: uint16(22013), + 85: uint16(22234), + 86: uint16(22402), + 87: uint16(22781), + 88: uint16(23234), + 89: uint16(23432), + 90: uint16(23723), + 91: uint16(23744), + 92: uint16(24101), + 93: uint16(24833), + }, + 65: { + 0: uint16(25101), + 1: uint16(25163), + 2: uint16(25480), + 3: uint16(25628), + 4: uint16(25910), + 5: uint16(25976), + 6: uint16(27193), + 7: uint16(27530), + 8: uint16(27700), + 9: uint16(27929), + 10: uint16(28465), + 11: uint16(29159), + 12: uint16(29417), + 13: uint16(29560), + 14: uint16(29703), + 15: uint16(29874), + 16: uint16(30246), + 17: uint16(30561), + 18: uint16(31168), + 19: uint16(31319), + 20: uint16(31466), + 21: uint16(31929), + 22: uint16(32143), + 23: uint16(32172), + 24: uint16(32353), + 25: uint16(32670), + 26: uint16(33065), + 27: uint16(33585), + 28: uint16(33936), + 29: uint16(34010), + 30: uint16(34282), + 31: uint16(34966), + 32: uint16(35504), + 33: uint16(35728), + 34: uint16(36664), + 35: uint16(36930), + 36: uint16(36995), + 37: uint16(37228), + 38: uint16(37526), + 39: uint16(37561), + 40: uint16(38539), + 41: uint16(38567), + 42: uint16(38568), + 43: uint16(38614), + 44: uint16(38656), + 45: uint16(38920), + 46: uint16(39318), + 47: uint16(39635), + 48: uint16(39706), + 49: uint16(21460), + 50: uint16(22654), + 51: uint16(22809), + 52: uint16(23408), + 53: uint16(23487), + 54: uint16(28113), + 55: uint16(28506), + 56: uint16(29087), + 57: uint16(29729), + 58: uint16(29881), + 59: uint16(32901), + 60: uint16(33789), + 61: uint16(24033), + 62: uint16(24455), + 63: uint16(24490), + 64: uint16(24642), + 65: uint16(26092), + 66: uint16(26642), + 67: uint16(26991), + 68: uint16(27219), + 69: uint16(27529), + 70: uint16(27957), + 71: uint16(28147), + 72: uint16(29667), + 73: uint16(30462), + 74: uint16(30636), + 75: uint16(31565), + 76: uint16(32020), + 77: uint16(33059), + 78: uint16(33308), + 79: uint16(33600), + 80: uint16(34036), + 81: uint16(34147), + 82: uint16(35426), + 83: uint16(35524), + 84: uint16(37255), + 85: uint16(37662), + 86: uint16(38918), + 87: uint16(39348), + 88: uint16(25100), + 89: uint16(34899), + 90: uint16(36848), + 91: uint16(37477), + 92: uint16(23815), + 93: uint16(23847), + }, + 66: { + 0: uint16(23913), + 1: uint16(29791), + 2: uint16(33181), + 3: uint16(34664), + 4: uint16(28629), + 5: uint16(25342), + 6: uint16(32722), + 7: uint16(35126), + 8: uint16(35186), + 9: uint16(19998), + 10: uint16(20056), + 11: uint16(20711), + 12: uint16(21213), + 13: uint16(21319), + 14: uint16(25215), + 15: uint16(26119), + 16: uint16(32361), + 17: uint16(34821), + 18: uint16(38494), + 19: uint16(20365), + 20: uint16(21273), + 21: uint16(22070), + 22: uint16(22987), + 23: uint16(23204), + 24: uint16(23608), + 25: uint16(23630), + 26: uint16(23629), + 27: uint16(24066), + 28: uint16(24337), + 29: uint16(24643), + 30: uint16(26045), + 31: uint16(26159), + 32: uint16(26178), + 33: uint16(26558), + 34: uint16(26612), + 35: uint16(29468), + 36: uint16(30690), + 37: uint16(31034), + 38: uint16(32709), + 39: uint16(33940), + 40: uint16(33997), + 41: uint16(35222), + 42: uint16(35430), + 43: uint16(35433), + 44: uint16(35553), + 45: uint16(35925), + 46: uint16(35962), + 47: uint16(22516), + 48: uint16(23508), + 49: uint16(24335), + 50: uint16(24687), + 51: uint16(25325), + 52: uint16(26893), + 53: uint16(27542), + 54: uint16(28252), + 55: uint16(29060), + 56: uint16(31698), + 57: uint16(34645), + 58: uint16(35672), + 59: uint16(36606), + 60: uint16(39135), + 61: uint16(39166), + 62: uint16(20280), + 63: uint16(20353), + 64: uint16(20449), + 65: uint16(21627), + 66: uint16(23072), + 67: uint16(23480), + 68: uint16(24892), + 69: uint16(26032), + 70: uint16(26216), + 71: uint16(29180), + 72: uint16(30003), + 73: uint16(31070), + 74: uint16(32051), + 75: uint16(33102), + 76: uint16(33251), + 77: uint16(33688), + 78: uint16(34218), + 79: uint16(34254), + 80: uint16(34563), + 81: uint16(35338), + 82: uint16(36523), + 83: uint16(36763), + 84: uint16(63857), + 85: uint16(36805), + 86: uint16(22833), + 87: uint16(23460), + 88: uint16(23526), + 89: uint16(24713), + 90: uint16(23529), + 91: uint16(23563), + 92: uint16(24515), + 93: uint16(27777), + }, + 67: { + 0: uint16(63858), + 1: uint16(28145), + 2: uint16(28683), + 3: uint16(29978), + 4: uint16(33455), + 5: uint16(35574), + 6: uint16(20160), + 7: uint16(21313), + 8: uint16(63859), + 9: uint16(38617), + 10: uint16(27663), + 11: uint16(20126), + 12: uint16(20420), + 13: uint16(20818), + 14: uint16(21854), + 15: uint16(23077), + 16: uint16(23784), + 17: uint16(25105), + 18: uint16(29273), + 19: uint16(33469), + 20: uint16(33706), + 21: uint16(34558), + 22: uint16(34905), + 23: uint16(35357), + 24: uint16(38463), + 25: uint16(38597), + 26: uint16(39187), + 27: uint16(40201), + 28: uint16(40285), + 29: uint16(22538), + 30: uint16(23731), + 31: uint16(23997), + 32: uint16(24132), + 33: uint16(24801), + 34: uint16(24853), + 35: uint16(25569), + 36: uint16(27138), + 37: uint16(28197), + 38: uint16(37122), + 39: uint16(37716), + 40: uint16(38990), + 41: uint16(39952), + 42: uint16(40823), + 43: uint16(23433), + 44: uint16(23736), + 45: uint16(25353), + 46: uint16(26191), + 47: uint16(26696), + 48: uint16(30524), + 49: uint16(38593), + 50: uint16(38797), + 51: uint16(38996), + 52: uint16(39839), + 53: uint16(26017), + 54: uint16(35585), + 55: uint16(36555), + 56: uint16(38332), + 57: uint16(21813), + 58: uint16(23721), + 59: uint16(24022), + 60: uint16(24245), + 61: uint16(26263), + 62: uint16(30284), + 63: uint16(33780), + 64: uint16(38343), + 65: uint16(22739), + 66: uint16(25276), + 67: uint16(29390), + 68: uint16(40232), + 69: uint16(20208), + 70: uint16(22830), + 71: uint16(24591), + 72: uint16(26171), + 73: uint16(27523), + 74: uint16(31207), + 75: uint16(40230), + 76: uint16(21395), + 77: uint16(21696), + 78: uint16(22467), + 79: uint16(23830), + 80: uint16(24859), + 81: uint16(26326), + 82: uint16(28079), + 83: uint16(30861), + 84: uint16(33406), + 85: uint16(38552), + 86: uint16(38724), + 87: uint16(21380), + 88: uint16(25212), + 89: uint16(25494), + 90: uint16(28082), + 91: uint16(32266), + 92: uint16(33099), + 93: uint16(38989), + }, + 68: { + 0: uint16(27387), + 1: uint16(32588), + 2: uint16(40367), + 3: uint16(40474), + 4: uint16(20063), + 5: uint16(20539), + 6: uint16(20918), + 7: uint16(22812), + 8: uint16(24825), + 9: uint16(25590), + 10: uint16(26928), + 11: uint16(29242), + 12: uint16(32822), + 13: uint16(63860), + 14: uint16(37326), + 15: uint16(24369), + 16: uint16(63861), + 17: uint16(63862), + 18: uint16(32004), + 19: uint16(33509), + 20: uint16(33903), + 21: uint16(33979), + 22: uint16(34277), + 23: uint16(36493), + 24: uint16(63863), + 25: uint16(20335), + 26: uint16(63864), + 27: uint16(63865), + 28: uint16(22756), + 29: uint16(23363), + 30: uint16(24665), + 31: uint16(25562), + 32: uint16(25880), + 33: uint16(25965), + 34: uint16(26264), + 35: uint16(63866), + 36: uint16(26954), + 37: uint16(27171), + 38: uint16(27915), + 39: uint16(28673), + 40: uint16(29036), + 41: uint16(30162), + 42: uint16(30221), + 43: uint16(31155), + 44: uint16(31344), + 45: uint16(63867), + 46: uint16(32650), + 47: uint16(63868), + 48: uint16(35140), + 49: uint16(63869), + 50: uint16(35731), + 51: uint16(37312), + 52: uint16(38525), + 53: uint16(63870), + 54: uint16(39178), + 55: uint16(22276), + 56: uint16(24481), + 57: uint16(26044), + 58: uint16(28417), + 59: uint16(30208), + 60: uint16(31142), + 61: uint16(35486), + 62: uint16(39341), + 63: uint16(39770), + 64: uint16(40812), + 65: uint16(20740), + 66: uint16(25014), + 67: uint16(25233), + 68: uint16(27277), + 69: uint16(33222), + 70: uint16(20547), + 71: uint16(22576), + 72: uint16(24422), + 73: uint16(28937), + 74: uint16(35328), + 75: uint16(35578), + 76: uint16(23420), + 77: uint16(34326), + 78: uint16(20474), + 79: uint16(20796), + 80: uint16(22196), + 81: uint16(22852), + 82: uint16(25513), + 83: uint16(28153), + 84: uint16(23978), + 85: uint16(26989), + 86: uint16(20870), + 87: uint16(20104), + 88: uint16(20313), + 89: uint16(63871), + 90: uint16(63872), + 91: uint16(63873), + 92: uint16(22914), + 93: uint16(63874), + }, + 69: { + 0: uint16(63875), + 1: uint16(27487), + 2: uint16(27741), + 3: uint16(63876), + 4: uint16(29877), + 5: uint16(30998), + 6: uint16(63877), + 7: uint16(33287), + 8: uint16(33349), + 9: uint16(33593), + 10: uint16(36671), + 11: uint16(36701), + 12: uint16(63878), + 13: uint16(39192), + 14: uint16(63879), + 15: uint16(63880), + 16: uint16(63881), + 17: uint16(20134), + 18: uint16(63882), + 19: uint16(22495), + 20: uint16(24441), + 21: uint16(26131), + 22: uint16(63883), + 23: uint16(63884), + 24: uint16(30123), + 25: uint16(32377), + 26: uint16(35695), + 27: uint16(63885), + 28: uint16(36870), + 29: uint16(39515), + 30: uint16(22181), + 31: uint16(22567), + 32: uint16(23032), + 33: uint16(23071), + 34: uint16(23476), + 35: uint16(63886), + 36: uint16(24310), + 37: uint16(63887), + 38: uint16(63888), + 39: uint16(25424), + 40: uint16(25403), + 41: uint16(63889), + 42: uint16(26941), + 43: uint16(27783), + 44: uint16(27839), + 45: uint16(28046), + 46: uint16(28051), + 47: uint16(28149), + 48: uint16(28436), + 49: uint16(63890), + 50: uint16(28895), + 51: uint16(28982), + 52: uint16(29017), + 53: uint16(63891), + 54: uint16(29123), + 55: uint16(29141), + 56: uint16(63892), + 57: uint16(30799), + 58: uint16(30831), + 59: uint16(63893), + 60: uint16(31605), + 61: uint16(32227), + 62: uint16(63894), + 63: uint16(32303), + 64: uint16(63895), + 65: uint16(34893), + 66: uint16(36575), + 67: uint16(63896), + 68: uint16(63897), + 69: uint16(63898), + 70: uint16(37467), + 71: uint16(63899), + 72: uint16(40182), + 73: uint16(63900), + 74: uint16(63901), + 75: uint16(63902), + 76: uint16(24709), + 77: uint16(28037), + 78: uint16(63903), + 79: uint16(29105), + 80: uint16(63904), + 81: uint16(63905), + 82: uint16(38321), + 83: uint16(21421), + 84: uint16(63906), + 85: uint16(63907), + 86: uint16(63908), + 87: uint16(26579), + 88: uint16(63909), + 89: uint16(28814), + 90: uint16(28976), + 91: uint16(29744), + 92: uint16(33398), + 93: uint16(33490), + }, + 70: { + 0: uint16(63910), + 1: uint16(38331), + 2: uint16(39653), + 3: uint16(40573), + 4: uint16(26308), + 5: uint16(63911), + 6: uint16(29121), + 7: uint16(33865), + 8: uint16(63912), + 9: uint16(63913), + 10: uint16(22603), + 11: uint16(63914), + 12: uint16(63915), + 13: uint16(23992), + 14: uint16(24433), + 15: uint16(63916), + 16: uint16(26144), + 17: uint16(26254), + 18: uint16(27001), + 19: uint16(27054), + 20: uint16(27704), + 21: uint16(27891), + 22: uint16(28214), + 23: uint16(28481), + 24: uint16(28634), + 25: uint16(28699), + 26: uint16(28719), + 27: uint16(29008), + 28: uint16(29151), + 29: uint16(29552), + 30: uint16(63917), + 31: uint16(29787), + 32: uint16(63918), + 33: uint16(29908), + 34: uint16(30408), + 35: uint16(31310), + 36: uint16(32403), + 37: uint16(63919), + 38: uint16(63920), + 39: uint16(33521), + 40: uint16(35424), + 41: uint16(36814), + 42: uint16(63921), + 43: uint16(37704), + 44: uint16(63922), + 45: uint16(38681), + 46: uint16(63923), + 47: uint16(63924), + 48: uint16(20034), + 49: uint16(20522), + 50: uint16(63925), + 51: uint16(21000), + 52: uint16(21473), + 53: uint16(26355), + 54: uint16(27757), + 55: uint16(28618), + 56: uint16(29450), + 57: uint16(30591), + 58: uint16(31330), + 59: uint16(33454), + 60: uint16(34269), + 61: uint16(34306), + 62: uint16(63926), + 63: uint16(35028), + 64: uint16(35427), + 65: uint16(35709), + 66: uint16(35947), + 67: uint16(63927), + 68: uint16(37555), + 69: uint16(63928), + 70: uint16(38675), + 71: uint16(38928), + 72: uint16(20116), + 73: uint16(20237), + 74: uint16(20425), + 75: uint16(20658), + 76: uint16(21320), + 77: uint16(21566), + 78: uint16(21555), + 79: uint16(21978), + 80: uint16(22626), + 81: uint16(22714), + 82: uint16(22887), + 83: uint16(23067), + 84: uint16(23524), + 85: uint16(24735), + 86: uint16(63929), + 87: uint16(25034), + 88: uint16(25942), + 89: uint16(26111), + 90: uint16(26212), + 91: uint16(26791), + 92: uint16(27738), + 93: uint16(28595), + }, + 71: { + 0: uint16(28879), + 1: uint16(29100), + 2: uint16(29522), + 3: uint16(31613), + 4: uint16(34568), + 5: uint16(35492), + 6: uint16(39986), + 7: uint16(40711), + 8: uint16(23627), + 9: uint16(27779), + 10: uint16(29508), + 11: uint16(29577), + 12: uint16(37434), + 13: uint16(28331), + 14: uint16(29797), + 15: uint16(30239), + 16: uint16(31337), + 17: uint16(32277), + 18: uint16(34314), + 19: uint16(20800), + 20: uint16(22725), + 21: uint16(25793), + 22: uint16(29934), + 23: uint16(29973), + 24: uint16(30320), + 25: uint16(32705), + 26: uint16(37013), + 27: uint16(38605), + 28: uint16(39252), + 29: uint16(28198), + 30: uint16(29926), + 31: uint16(31401), + 32: uint16(31402), + 33: uint16(33253), + 34: uint16(34521), + 35: uint16(34680), + 36: uint16(35355), + 37: uint16(23113), + 38: uint16(23436), + 39: uint16(23451), + 40: uint16(26785), + 41: uint16(26880), + 42: uint16(28003), + 43: uint16(29609), + 44: uint16(29715), + 45: uint16(29740), + 46: uint16(30871), + 47: uint16(32233), + 48: uint16(32747), + 49: uint16(33048), + 50: uint16(33109), + 51: uint16(33694), + 52: uint16(35916), + 53: uint16(38446), + 54: uint16(38929), + 55: uint16(26352), + 56: uint16(24448), + 57: uint16(26106), + 58: uint16(26505), + 59: uint16(27754), + 60: uint16(29579), + 61: uint16(20525), + 62: uint16(23043), + 63: uint16(27498), + 64: uint16(30702), + 65: uint16(22806), + 66: uint16(23916), + 67: uint16(24013), + 68: uint16(29477), + 69: uint16(30031), + 70: uint16(63930), + 71: uint16(63931), + 72: uint16(20709), + 73: uint16(20985), + 74: uint16(22575), + 75: uint16(22829), + 76: uint16(22934), + 77: uint16(23002), + 78: uint16(23525), + 79: uint16(63932), + 80: uint16(63933), + 81: uint16(23970), + 82: uint16(25303), + 83: uint16(25622), + 84: uint16(25747), + 85: uint16(25854), + 86: uint16(63934), + 87: uint16(26332), + 88: uint16(63935), + 89: uint16(27208), + 90: uint16(63936), + 91: uint16(29183), + 92: uint16(29796), + 93: uint16(63937), + }, + 72: { + 0: uint16(31368), + 1: uint16(31407), + 2: uint16(32327), + 3: uint16(32350), + 4: uint16(32768), + 5: uint16(33136), + 6: uint16(63938), + 7: uint16(34799), + 8: uint16(35201), + 9: uint16(35616), + 10: uint16(36953), + 11: uint16(63939), + 12: uint16(36992), + 13: uint16(39250), + 14: uint16(24958), + 15: uint16(27442), + 16: uint16(28020), + 17: uint16(32287), + 18: uint16(35109), + 19: uint16(36785), + 20: uint16(20433), + 21: uint16(20653), + 22: uint16(20887), + 23: uint16(21191), + 24: uint16(22471), + 25: uint16(22665), + 26: uint16(23481), + 27: uint16(24248), + 28: uint16(24898), + 29: uint16(27029), + 30: uint16(28044), + 31: uint16(28263), + 32: uint16(28342), + 33: uint16(29076), + 34: uint16(29794), + 35: uint16(29992), + 36: uint16(29996), + 37: uint16(32883), + 38: uint16(33592), + 39: uint16(33993), + 40: uint16(36362), + 41: uint16(37780), + 42: uint16(37854), + 43: uint16(63940), + 44: uint16(20110), + 45: uint16(20305), + 46: uint16(20598), + 47: uint16(20778), + 48: uint16(21448), + 49: uint16(21451), + 50: uint16(21491), + 51: uint16(23431), + 52: uint16(23507), + 53: uint16(23588), + 54: uint16(24858), + 55: uint16(24962), + 56: uint16(26100), + 57: uint16(29275), + 58: uint16(29591), + 59: uint16(29760), + 60: uint16(30402), + 61: uint16(31056), + 62: uint16(31121), + 63: uint16(31161), + 64: uint16(32006), + 65: uint16(32701), + 66: uint16(33419), + 67: uint16(34261), + 68: uint16(34398), + 69: uint16(36802), + 70: uint16(36935), + 71: uint16(37109), + 72: uint16(37354), + 73: uint16(38533), + 74: uint16(38632), + 75: uint16(38633), + 76: uint16(21206), + 77: uint16(24423), + 78: uint16(26093), + 79: uint16(26161), + 80: uint16(26671), + 81: uint16(29020), + 82: uint16(31286), + 83: uint16(37057), + 84: uint16(38922), + 85: uint16(20113), + 86: uint16(63941), + 87: uint16(27218), + 88: uint16(27550), + 89: uint16(28560), + 90: uint16(29065), + 91: uint16(32792), + 92: uint16(33464), + 93: uint16(34131), + }, + 73: { + 0: uint16(36939), + 1: uint16(38549), + 2: uint16(38642), + 3: uint16(38907), + 4: uint16(34074), + 5: uint16(39729), + 6: uint16(20112), + 7: uint16(29066), + 8: uint16(38596), + 9: uint16(20803), + 10: uint16(21407), + 11: uint16(21729), + 12: uint16(22291), + 13: uint16(22290), + 14: uint16(22435), + 15: uint16(23195), + 16: uint16(23236), + 17: uint16(23491), + 18: uint16(24616), + 19: uint16(24895), + 20: uint16(25588), + 21: uint16(27781), + 22: uint16(27961), + 23: uint16(28274), + 24: uint16(28304), + 25: uint16(29232), + 26: uint16(29503), + 27: uint16(29783), + 28: uint16(33489), + 29: uint16(34945), + 30: uint16(36677), + 31: uint16(36960), + 32: uint16(63942), + 33: uint16(38498), + 34: uint16(39000), + 35: uint16(40219), + 36: uint16(26376), + 37: uint16(36234), + 38: uint16(37470), + 39: uint16(20301), + 40: uint16(20553), + 41: uint16(20702), + 42: uint16(21361), + 43: uint16(22285), + 44: uint16(22996), + 45: uint16(23041), + 46: uint16(23561), + 47: uint16(24944), + 48: uint16(26256), + 49: uint16(28205), + 50: uint16(29234), + 51: uint16(29771), + 52: uint16(32239), + 53: uint16(32963), + 54: uint16(33806), + 55: uint16(33894), + 56: uint16(34111), + 57: uint16(34655), + 58: uint16(34907), + 59: uint16(35096), + 60: uint16(35586), + 61: uint16(36949), + 62: uint16(38859), + 63: uint16(39759), + 64: uint16(20083), + 65: uint16(20369), + 66: uint16(20754), + 67: uint16(20842), + 68: uint16(63943), + 69: uint16(21807), + 70: uint16(21929), + 71: uint16(23418), + 72: uint16(23461), + 73: uint16(24188), + 74: uint16(24189), + 75: uint16(24254), + 76: uint16(24736), + 77: uint16(24799), + 78: uint16(24840), + 79: uint16(24841), + 80: uint16(25540), + 81: uint16(25912), + 82: uint16(26377), + 83: uint16(63944), + 84: uint16(26580), + 85: uint16(26586), + 86: uint16(63945), + 87: uint16(26977), + 88: uint16(26978), + 89: uint16(27833), + 90: uint16(27943), + 91: uint16(63946), + 92: uint16(28216), + 93: uint16(63947), + }, + 74: { + 0: uint16(28641), + 1: uint16(29494), + 2: uint16(29495), + 3: uint16(63948), + 4: uint16(29788), + 5: uint16(30001), + 6: uint16(63949), + 7: uint16(30290), + 8: uint16(63950), + 9: uint16(63951), + 10: uint16(32173), + 11: uint16(33278), + 12: uint16(33848), + 13: uint16(35029), + 14: uint16(35480), + 15: uint16(35547), + 16: uint16(35565), + 17: uint16(36400), + 18: uint16(36418), + 19: uint16(36938), + 20: uint16(36926), + 21: uint16(36986), + 22: uint16(37193), + 23: uint16(37321), + 24: uint16(37742), + 25: uint16(63952), + 26: uint16(63953), + 27: uint16(22537), + 28: uint16(63954), + 29: uint16(27603), + 30: uint16(32905), + 31: uint16(32946), + 32: uint16(63955), + 33: uint16(63956), + 34: uint16(20801), + 35: uint16(22891), + 36: uint16(23609), + 37: uint16(63957), + 38: uint16(63958), + 39: uint16(28516), + 40: uint16(29607), + 41: uint16(32996), + 42: uint16(36103), + 43: uint16(63959), + 44: uint16(37399), + 45: uint16(38287), + 46: uint16(63960), + 47: uint16(63961), + 48: uint16(63962), + 49: uint16(63963), + 50: uint16(32895), + 51: uint16(25102), + 52: uint16(28700), + 53: uint16(32104), + 54: uint16(34701), + 55: uint16(63964), + 56: uint16(22432), + 57: uint16(24681), + 58: uint16(24903), + 59: uint16(27575), + 60: uint16(35518), + 61: uint16(37504), + 62: uint16(38577), + 63: uint16(20057), + 64: uint16(21535), + 65: uint16(28139), + 66: uint16(34093), + 67: uint16(38512), + 68: uint16(38899), + 69: uint16(39150), + 70: uint16(25558), + 71: uint16(27875), + 72: uint16(37009), + 73: uint16(20957), + 74: uint16(25033), + 75: uint16(33210), + 76: uint16(40441), + 77: uint16(20381), + 78: uint16(20506), + 79: uint16(20736), + 80: uint16(23452), + 81: uint16(24847), + 82: uint16(25087), + 83: uint16(25836), + 84: uint16(26885), + 85: uint16(27589), + 86: uint16(30097), + 87: uint16(30691), + 88: uint16(32681), + 89: uint16(33380), + 90: uint16(34191), + 91: uint16(34811), + 92: uint16(34915), + 93: uint16(35516), + }, + 75: { + 0: uint16(35696), + 1: uint16(37291), + 2: uint16(20108), + 3: uint16(20197), + 4: uint16(20234), + 5: uint16(63965), + 6: uint16(63966), + 7: uint16(22839), + 8: uint16(23016), + 9: uint16(63967), + 10: uint16(24050), + 11: uint16(24347), + 12: uint16(24411), + 13: uint16(24609), + 14: uint16(63968), + 15: uint16(63969), + 16: uint16(63970), + 17: uint16(63971), + 18: uint16(29246), + 19: uint16(29669), + 20: uint16(63972), + 21: uint16(30064), + 22: uint16(30157), + 23: uint16(63973), + 24: uint16(31227), + 25: uint16(63974), + 26: uint16(32780), + 27: uint16(32819), + 28: uint16(32900), + 29: uint16(33505), + 30: uint16(33617), + 31: uint16(63975), + 32: uint16(63976), + 33: uint16(36029), + 34: uint16(36019), + 35: uint16(36999), + 36: uint16(63977), + 37: uint16(63978), + 38: uint16(39156), + 39: uint16(39180), + 40: uint16(63979), + 41: uint16(63980), + 42: uint16(28727), + 43: uint16(30410), + 44: uint16(32714), + 45: uint16(32716), + 46: uint16(32764), + 47: uint16(35610), + 48: uint16(20154), + 49: uint16(20161), + 50: uint16(20995), + 51: uint16(21360), + 52: uint16(63981), + 53: uint16(21693), + 54: uint16(22240), + 55: uint16(23035), + 56: uint16(23493), + 57: uint16(24341), + 58: uint16(24525), + 59: uint16(28270), + 60: uint16(63982), + 61: uint16(63983), + 62: uint16(32106), + 63: uint16(33589), + 64: uint16(63984), + 65: uint16(34451), + 66: uint16(35469), + 67: uint16(63985), + 68: uint16(38765), + 69: uint16(38775), + 70: uint16(63986), + 71: uint16(63987), + 72: uint16(19968), + 73: uint16(20314), + 74: uint16(20350), + 75: uint16(22777), + 76: uint16(26085), + 77: uint16(28322), + 78: uint16(36920), + 79: uint16(37808), + 80: uint16(39353), + 81: uint16(20219), + 82: uint16(22764), + 83: uint16(22922), + 84: uint16(23001), + 85: uint16(24641), + 86: uint16(63988), + 87: uint16(63989), + 88: uint16(31252), + 89: uint16(63990), + 90: uint16(33615), + 91: uint16(36035), + 92: uint16(20837), + 93: uint16(21316), + }, + 76: { + 0: uint16(63991), + 1: uint16(63992), + 2: uint16(63993), + 3: uint16(20173), + 4: uint16(21097), + 5: uint16(23381), + 6: uint16(33471), + 7: uint16(20180), + 8: uint16(21050), + 9: uint16(21672), + 10: uint16(22985), + 11: uint16(23039), + 12: uint16(23376), + 13: uint16(23383), + 14: uint16(23388), + 15: uint16(24675), + 16: uint16(24904), + 17: uint16(28363), + 18: uint16(28825), + 19: uint16(29038), + 20: uint16(29574), + 21: uint16(29943), + 22: uint16(30133), + 23: uint16(30913), + 24: uint16(32043), + 25: uint16(32773), + 26: uint16(33258), + 27: uint16(33576), + 28: uint16(34071), + 29: uint16(34249), + 30: uint16(35566), + 31: uint16(36039), + 32: uint16(38604), + 33: uint16(20316), + 34: uint16(21242), + 35: uint16(22204), + 36: uint16(26027), + 37: uint16(26152), + 38: uint16(28796), + 39: uint16(28856), + 40: uint16(29237), + 41: uint16(32189), + 42: uint16(33421), + 43: uint16(37196), + 44: uint16(38592), + 45: uint16(40306), + 46: uint16(23409), + 47: uint16(26855), + 48: uint16(27544), + 49: uint16(28538), + 50: uint16(30430), + 51: uint16(23697), + 52: uint16(26283), + 53: uint16(28507), + 54: uint16(31668), + 55: uint16(31786), + 56: uint16(34870), + 57: uint16(38620), + 58: uint16(19976), + 59: uint16(20183), + 60: uint16(21280), + 61: uint16(22580), + 62: uint16(22715), + 63: uint16(22767), + 64: uint16(22892), + 65: uint16(23559), + 66: uint16(24115), + 67: uint16(24196), + 68: uint16(24373), + 69: uint16(25484), + 70: uint16(26290), + 71: uint16(26454), + 72: uint16(27167), + 73: uint16(27299), + 74: uint16(27404), + 75: uint16(28479), + 76: uint16(29254), + 77: uint16(63994), + 78: uint16(29520), + 79: uint16(29835), + 80: uint16(31456), + 81: uint16(31911), + 82: uint16(33144), + 83: uint16(33247), + 84: uint16(33255), + 85: uint16(33674), + 86: uint16(33900), + 87: uint16(34083), + 88: uint16(34196), + 89: uint16(34255), + 90: uint16(35037), + 91: uint16(36115), + 92: uint16(37292), + 93: uint16(38263), + }, + 77: { + 0: uint16(38556), + 1: uint16(20877), + 2: uint16(21705), + 3: uint16(22312), + 4: uint16(23472), + 5: uint16(25165), + 6: uint16(26448), + 7: uint16(26685), + 8: uint16(26771), + 9: uint16(28221), + 10: uint16(28371), + 11: uint16(28797), + 12: uint16(32289), + 13: uint16(35009), + 14: uint16(36001), + 15: uint16(36617), + 16: uint16(40779), + 17: uint16(40782), + 18: uint16(29229), + 19: uint16(31631), + 20: uint16(35533), + 21: uint16(37658), + 22: uint16(20295), + 23: uint16(20302), + 24: uint16(20786), + 25: uint16(21632), + 26: uint16(22992), + 27: uint16(24213), + 28: uint16(25269), + 29: uint16(26485), + 30: uint16(26990), + 31: uint16(27159), + 32: uint16(27822), + 33: uint16(28186), + 34: uint16(29401), + 35: uint16(29482), + 36: uint16(30141), + 37: uint16(31672), + 38: uint16(32053), + 39: uint16(33511), + 40: uint16(33785), + 41: uint16(33879), + 42: uint16(34295), + 43: uint16(35419), + 44: uint16(36015), + 45: uint16(36487), + 46: uint16(36889), + 47: uint16(37048), + 48: uint16(38606), + 49: uint16(40799), + 50: uint16(21219), + 51: uint16(21514), + 52: uint16(23265), + 53: uint16(23490), + 54: uint16(25688), + 55: uint16(25973), + 56: uint16(28404), + 57: uint16(29380), + 58: uint16(63995), + 59: uint16(30340), + 60: uint16(31309), + 61: uint16(31515), + 62: uint16(31821), + 63: uint16(32318), + 64: uint16(32735), + 65: uint16(33659), + 66: uint16(35627), + 67: uint16(36042), + 68: uint16(36196), + 69: uint16(36321), + 70: uint16(36447), + 71: uint16(36842), + 72: uint16(36857), + 73: uint16(36969), + 74: uint16(37841), + 75: uint16(20291), + 76: uint16(20346), + 77: uint16(20659), + 78: uint16(20840), + 79: uint16(20856), + 80: uint16(21069), + 81: uint16(21098), + 82: uint16(22625), + 83: uint16(22652), + 84: uint16(22880), + 85: uint16(23560), + 86: uint16(23637), + 87: uint16(24283), + 88: uint16(24731), + 89: uint16(25136), + 90: uint16(26643), + 91: uint16(27583), + 92: uint16(27656), + 93: uint16(28593), + }, + 78: { + 0: uint16(29006), + 1: uint16(29728), + 2: uint16(30000), + 3: uint16(30008), + 4: uint16(30033), + 5: uint16(30322), + 6: uint16(31564), + 7: uint16(31627), + 8: uint16(31661), + 9: uint16(31686), + 10: uint16(32399), + 11: uint16(35438), + 12: uint16(36670), + 13: uint16(36681), + 14: uint16(37439), + 15: uint16(37523), + 16: uint16(37666), + 17: uint16(37931), + 18: uint16(38651), + 19: uint16(39002), + 20: uint16(39019), + 21: uint16(39198), + 22: uint16(20999), + 23: uint16(25130), + 24: uint16(25240), + 25: uint16(27993), + 26: uint16(30308), + 27: uint16(31434), + 28: uint16(31680), + 29: uint16(32118), + 30: uint16(21344), + 31: uint16(23742), + 32: uint16(24215), + 33: uint16(28472), + 34: uint16(28857), + 35: uint16(31896), + 36: uint16(38673), + 37: uint16(39822), + 38: uint16(40670), + 39: uint16(25509), + 40: uint16(25722), + 41: uint16(34678), + 42: uint16(19969), + 43: uint16(20117), + 44: uint16(20141), + 45: uint16(20572), + 46: uint16(20597), + 47: uint16(21576), + 48: uint16(22979), + 49: uint16(23450), + 50: uint16(24128), + 51: uint16(24237), + 52: uint16(24311), + 53: uint16(24449), + 54: uint16(24773), + 55: uint16(25402), + 56: uint16(25919), + 57: uint16(25972), + 58: uint16(26060), + 59: uint16(26230), + 60: uint16(26232), + 61: uint16(26622), + 62: uint16(26984), + 63: uint16(27273), + 64: uint16(27491), + 65: uint16(27712), + 66: uint16(28096), + 67: uint16(28136), + 68: uint16(28191), + 69: uint16(28254), + 70: uint16(28702), + 71: uint16(28833), + 72: uint16(29582), + 73: uint16(29693), + 74: uint16(30010), + 75: uint16(30555), + 76: uint16(30855), + 77: uint16(31118), + 78: uint16(31243), + 79: uint16(31357), + 80: uint16(31934), + 81: uint16(32142), + 82: uint16(33351), + 83: uint16(35330), + 84: uint16(35562), + 85: uint16(35998), + 86: uint16(37165), + 87: uint16(37194), + 88: uint16(37336), + 89: uint16(37478), + 90: uint16(37580), + 91: uint16(37664), + 92: uint16(38662), + 93: uint16(38742), + }, + 79: { + 0: uint16(38748), + 1: uint16(38914), + 2: uint16(40718), + 3: uint16(21046), + 4: uint16(21137), + 5: uint16(21884), + 6: uint16(22564), + 7: uint16(24093), + 8: uint16(24351), + 9: uint16(24716), + 10: uint16(25552), + 11: uint16(26799), + 12: uint16(28639), + 13: uint16(31085), + 14: uint16(31532), + 15: uint16(33229), + 16: uint16(34234), + 17: uint16(35069), + 18: uint16(35576), + 19: uint16(36420), + 20: uint16(37261), + 21: uint16(38500), + 22: uint16(38555), + 23: uint16(38717), + 24: uint16(38988), + 25: uint16(40778), + 26: uint16(20430), + 27: uint16(20806), + 28: uint16(20939), + 29: uint16(21161), + 30: uint16(22066), + 31: uint16(24340), + 32: uint16(24427), + 33: uint16(25514), + 34: uint16(25805), + 35: uint16(26089), + 36: uint16(26177), + 37: uint16(26362), + 38: uint16(26361), + 39: uint16(26397), + 40: uint16(26781), + 41: uint16(26839), + 42: uint16(27133), + 43: uint16(28437), + 44: uint16(28526), + 45: uint16(29031), + 46: uint16(29157), + 47: uint16(29226), + 48: uint16(29866), + 49: uint16(30522), + 50: uint16(31062), + 51: uint16(31066), + 52: uint16(31199), + 53: uint16(31264), + 54: uint16(31381), + 55: uint16(31895), + 56: uint16(31967), + 57: uint16(32068), + 58: uint16(32368), + 59: uint16(32903), + 60: uint16(34299), + 61: uint16(34468), + 62: uint16(35412), + 63: uint16(35519), + 64: uint16(36249), + 65: uint16(36481), + 66: uint16(36896), + 67: uint16(36973), + 68: uint16(37347), + 69: uint16(38459), + 70: uint16(38613), + 71: uint16(40165), + 72: uint16(26063), + 73: uint16(31751), + 74: uint16(36275), + 75: uint16(37827), + 76: uint16(23384), + 77: uint16(23562), + 78: uint16(21330), + 79: uint16(25305), + 80: uint16(29469), + 81: uint16(20519), + 82: uint16(23447), + 83: uint16(24478), + 84: uint16(24752), + 85: uint16(24939), + 86: uint16(26837), + 87: uint16(28121), + 88: uint16(29742), + 89: uint16(31278), + 90: uint16(32066), + 91: uint16(32156), + 92: uint16(32305), + 93: uint16(33131), + }, + 80: { + 0: uint16(36394), + 1: uint16(36405), + 2: uint16(37758), + 3: uint16(37912), + 4: uint16(20304), + 5: uint16(22352), + 6: uint16(24038), + 7: uint16(24231), + 8: uint16(25387), + 9: uint16(32618), + 10: uint16(20027), + 11: uint16(20303), + 12: uint16(20367), + 13: uint16(20570), + 14: uint16(23005), + 15: uint16(32964), + 16: uint16(21610), + 17: uint16(21608), + 18: uint16(22014), + 19: uint16(22863), + 20: uint16(23449), + 21: uint16(24030), + 22: uint16(24282), + 23: uint16(26205), + 24: uint16(26417), + 25: uint16(26609), + 26: uint16(26666), + 27: uint16(27880), + 28: uint16(27954), + 29: uint16(28234), + 30: uint16(28557), + 31: uint16(28855), + 32: uint16(29664), + 33: uint16(30087), + 34: uint16(31820), + 35: uint16(32002), + 36: uint16(32044), + 37: uint16(32162), + 38: uint16(33311), + 39: uint16(34523), + 40: uint16(35387), + 41: uint16(35461), + 42: uint16(36208), + 43: uint16(36490), + 44: uint16(36659), + 45: uint16(36913), + 46: uint16(37198), + 47: uint16(37202), + 48: uint16(37956), + 49: uint16(39376), + 50: uint16(31481), + 51: uint16(31909), + 52: uint16(20426), + 53: uint16(20737), + 54: uint16(20934), + 55: uint16(22472), + 56: uint16(23535), + 57: uint16(23803), + 58: uint16(26201), + 59: uint16(27197), + 60: uint16(27994), + 61: uint16(28310), + 62: uint16(28652), + 63: uint16(28940), + 64: uint16(30063), + 65: uint16(31459), + 66: uint16(34850), + 67: uint16(36897), + 68: uint16(36981), + 69: uint16(38603), + 70: uint16(39423), + 71: uint16(33537), + 72: uint16(20013), + 73: uint16(20210), + 74: uint16(34886), + 75: uint16(37325), + 76: uint16(21373), + 77: uint16(27355), + 78: uint16(26987), + 79: uint16(27713), + 80: uint16(33914), + 81: uint16(22686), + 82: uint16(24974), + 83: uint16(26366), + 84: uint16(25327), + 85: uint16(28893), + 86: uint16(29969), + 87: uint16(30151), + 88: uint16(32338), + 89: uint16(33976), + 90: uint16(35657), + 91: uint16(36104), + 92: uint16(20043), + 93: uint16(21482), + }, + 81: { + 0: uint16(21675), + 1: uint16(22320), + 2: uint16(22336), + 3: uint16(24535), + 4: uint16(25345), + 5: uint16(25351), + 6: uint16(25711), + 7: uint16(25903), + 8: uint16(26088), + 9: uint16(26234), + 10: uint16(26525), + 11: uint16(26547), + 12: uint16(27490), + 13: uint16(27744), + 14: uint16(27802), + 15: uint16(28460), + 16: uint16(30693), + 17: uint16(30757), + 18: uint16(31049), + 19: uint16(31063), + 20: uint16(32025), + 21: uint16(32930), + 22: uint16(33026), + 23: uint16(33267), + 24: uint16(33437), + 25: uint16(33463), + 26: uint16(34584), + 27: uint16(35468), + 28: uint16(63996), + 29: uint16(36100), + 30: uint16(36286), + 31: uint16(36978), + 32: uint16(30452), + 33: uint16(31257), + 34: uint16(31287), + 35: uint16(32340), + 36: uint16(32887), + 37: uint16(21767), + 38: uint16(21972), + 39: uint16(22645), + 40: uint16(25391), + 41: uint16(25634), + 42: uint16(26185), + 43: uint16(26187), + 44: uint16(26733), + 45: uint16(27035), + 46: uint16(27524), + 47: uint16(27941), + 48: uint16(28337), + 49: uint16(29645), + 50: uint16(29800), + 51: uint16(29857), + 52: uint16(30043), + 53: uint16(30137), + 54: uint16(30433), + 55: uint16(30494), + 56: uint16(30603), + 57: uint16(31206), + 58: uint16(32265), + 59: uint16(32285), + 60: uint16(33275), + 61: uint16(34095), + 62: uint16(34967), + 63: uint16(35386), + 64: uint16(36049), + 65: uint16(36587), + 66: uint16(36784), + 67: uint16(36914), + 68: uint16(37805), + 69: uint16(38499), + 70: uint16(38515), + 71: uint16(38663), + 72: uint16(20356), + 73: uint16(21489), + 74: uint16(23018), + 75: uint16(23241), + 76: uint16(24089), + 77: uint16(26702), + 78: uint16(29894), + 79: uint16(30142), + 80: uint16(31209), + 81: uint16(31378), + 82: uint16(33187), + 83: uint16(34541), + 84: uint16(36074), + 85: uint16(36300), + 86: uint16(36845), + 87: uint16(26015), + 88: uint16(26389), + 89: uint16(63997), + 90: uint16(22519), + 91: uint16(28503), + 92: uint16(32221), + 93: uint16(36655), + }, + 82: { + 0: uint16(37878), + 1: uint16(38598), + 2: uint16(24501), + 3: uint16(25074), + 4: uint16(28548), + 5: uint16(19988), + 6: uint16(20376), + 7: uint16(20511), + 8: uint16(21449), + 9: uint16(21983), + 10: uint16(23919), + 11: uint16(24046), + 12: uint16(27425), + 13: uint16(27492), + 14: uint16(30923), + 15: uint16(31642), + 16: uint16(63998), + 17: uint16(36425), + 18: uint16(36554), + 19: uint16(36974), + 20: uint16(25417), + 21: uint16(25662), + 22: uint16(30528), + 23: uint16(31364), + 24: uint16(37679), + 25: uint16(38015), + 26: uint16(40810), + 27: uint16(25776), + 28: uint16(28591), + 29: uint16(29158), + 30: uint16(29864), + 31: uint16(29914), + 32: uint16(31428), + 33: uint16(31762), + 34: uint16(32386), + 35: uint16(31922), + 36: uint16(32408), + 37: uint16(35738), + 38: uint16(36106), + 39: uint16(38013), + 40: uint16(39184), + 41: uint16(39244), + 42: uint16(21049), + 43: uint16(23519), + 44: uint16(25830), + 45: uint16(26413), + 46: uint16(32046), + 47: uint16(20717), + 48: uint16(21443), + 49: uint16(22649), + 50: uint16(24920), + 51: uint16(24921), + 52: uint16(25082), + 53: uint16(26028), + 54: uint16(31449), + 55: uint16(35730), + 56: uint16(35734), + 57: uint16(20489), + 58: uint16(20513), + 59: uint16(21109), + 60: uint16(21809), + 61: uint16(23100), + 62: uint16(24288), + 63: uint16(24432), + 64: uint16(24884), + 65: uint16(25950), + 66: uint16(26124), + 67: uint16(26166), + 68: uint16(26274), + 69: uint16(27085), + 70: uint16(28356), + 71: uint16(28466), + 72: uint16(29462), + 73: uint16(30241), + 74: uint16(31379), + 75: uint16(33081), + 76: uint16(33369), + 77: uint16(33750), + 78: uint16(33980), + 79: uint16(20661), + 80: uint16(22512), + 81: uint16(23488), + 82: uint16(23528), + 83: uint16(24425), + 84: uint16(25505), + 85: uint16(30758), + 86: uint16(32181), + 87: uint16(33756), + 88: uint16(34081), + 89: uint16(37319), + 90: uint16(37365), + 91: uint16(20874), + 92: uint16(26613), + 93: uint16(31574), + }, + 83: { + 0: uint16(36012), + 1: uint16(20932), + 2: uint16(22971), + 3: uint16(24765), + 4: uint16(34389), + 5: uint16(20508), + 6: uint16(63999), + 7: uint16(21076), + 8: uint16(23610), + 9: uint16(24957), + 10: uint16(25114), + 11: uint16(25299), + 12: uint16(25842), + 13: uint16(26021), + 14: uint16(28364), + 15: uint16(30240), + 16: uint16(33034), + 17: uint16(36448), + 18: uint16(38495), + 19: uint16(38587), + 20: uint16(20191), + 21: uint16(21315), + 22: uint16(21912), + 23: uint16(22825), + 24: uint16(24029), + 25: uint16(25797), + 26: uint16(27849), + 27: uint16(28154), + 28: uint16(29588), + 29: uint16(31359), + 30: uint16(33307), + 31: uint16(34214), + 32: uint16(36068), + 33: uint16(36368), + 34: uint16(36983), + 35: uint16(37351), + 36: uint16(38369), + 37: uint16(38433), + 38: uint16(38854), + 39: uint16(20984), + 40: uint16(21746), + 41: uint16(21894), + 42: uint16(24505), + 43: uint16(25764), + 44: uint16(28552), + 45: uint16(32180), + 46: uint16(36639), + 47: uint16(36685), + 48: uint16(37941), + 49: uint16(20681), + 50: uint16(23574), + 51: uint16(27838), + 52: uint16(28155), + 53: uint16(29979), + 54: uint16(30651), + 55: uint16(31805), + 56: uint16(31844), + 57: uint16(35449), + 58: uint16(35522), + 59: uint16(22558), + 60: uint16(22974), + 61: uint16(24086), + 62: uint16(25463), + 63: uint16(29266), + 64: uint16(30090), + 65: uint16(30571), + 66: uint16(35548), + 67: uint16(36028), + 68: uint16(36626), + 69: uint16(24307), + 70: uint16(26228), + 71: uint16(28152), + 72: uint16(32893), + 73: uint16(33729), + 74: uint16(35531), + 75: uint16(38737), + 76: uint16(39894), + 77: uint16(64000), + 78: uint16(21059), + 79: uint16(26367), + 80: uint16(28053), + 81: uint16(28399), + 82: uint16(32224), + 83: uint16(35558), + 84: uint16(36910), + 85: uint16(36958), + 86: uint16(39636), + 87: uint16(21021), + 88: uint16(21119), + 89: uint16(21736), + 90: uint16(24980), + 91: uint16(25220), + 92: uint16(25307), + 93: uint16(26786), + }, + 84: { + 0: uint16(26898), + 1: uint16(26970), + 2: uint16(27189), + 3: uint16(28818), + 4: uint16(28966), + 5: uint16(30813), + 6: uint16(30977), + 7: uint16(30990), + 8: uint16(31186), + 9: uint16(31245), + 10: uint16(32918), + 11: uint16(33400), + 12: uint16(33493), + 13: uint16(33609), + 14: uint16(34121), + 15: uint16(35970), + 16: uint16(36229), + 17: uint16(37218), + 18: uint16(37259), + 19: uint16(37294), + 20: uint16(20419), + 21: uint16(22225), + 22: uint16(29165), + 23: uint16(30679), + 24: uint16(34560), + 25: uint16(35320), + 26: uint16(23544), + 27: uint16(24534), + 28: uint16(26449), + 29: uint16(37032), + 30: uint16(21474), + 31: uint16(22618), + 32: uint16(23541), + 33: uint16(24740), + 34: uint16(24961), + 35: uint16(25696), + 36: uint16(32317), + 37: uint16(32880), + 38: uint16(34085), + 39: uint16(37507), + 40: uint16(25774), + 41: uint16(20652), + 42: uint16(23828), + 43: uint16(26368), + 44: uint16(22684), + 45: uint16(25277), + 46: uint16(25512), + 47: uint16(26894), + 48: uint16(27000), + 49: uint16(27166), + 50: uint16(28267), + 51: uint16(30394), + 52: uint16(31179), + 53: uint16(33467), + 54: uint16(33833), + 55: uint16(35535), + 56: uint16(36264), + 57: uint16(36861), + 58: uint16(37138), + 59: uint16(37195), + 60: uint16(37276), + 61: uint16(37648), + 62: uint16(37656), + 63: uint16(37786), + 64: uint16(38619), + 65: uint16(39478), + 66: uint16(39949), + 67: uint16(19985), + 68: uint16(30044), + 69: uint16(31069), + 70: uint16(31482), + 71: uint16(31569), + 72: uint16(31689), + 73: uint16(32302), + 74: uint16(33988), + 75: uint16(36441), + 76: uint16(36468), + 77: uint16(36600), + 78: uint16(36880), + 79: uint16(26149), + 80: uint16(26943), + 81: uint16(29763), + 82: uint16(20986), + 83: uint16(26414), + 84: uint16(40668), + 85: uint16(20805), + 86: uint16(24544), + 87: uint16(27798), + 88: uint16(34802), + 89: uint16(34909), + 90: uint16(34935), + 91: uint16(24756), + 92: uint16(33205), + 93: uint16(33795), + }, + 85: { + 0: uint16(36101), + 1: uint16(21462), + 2: uint16(21561), + 3: uint16(22068), + 4: uint16(23094), + 5: uint16(23601), + 6: uint16(28810), + 7: uint16(32736), + 8: uint16(32858), + 9: uint16(33030), + 10: uint16(33261), + 11: uint16(36259), + 12: uint16(37257), + 13: uint16(39519), + 14: uint16(40434), + 15: uint16(20596), + 16: uint16(20164), + 17: uint16(21408), + 18: uint16(24827), + 19: uint16(28204), + 20: uint16(23652), + 21: uint16(20360), + 22: uint16(20516), + 23: uint16(21988), + 24: uint16(23769), + 25: uint16(24159), + 26: uint16(24677), + 27: uint16(26772), + 28: uint16(27835), + 29: uint16(28100), + 30: uint16(29118), + 31: uint16(30164), + 32: uint16(30196), + 33: uint16(30305), + 34: uint16(31258), + 35: uint16(31305), + 36: uint16(32199), + 37: uint16(32251), + 38: uint16(32622), + 39: uint16(33268), + 40: uint16(34473), + 41: uint16(36636), + 42: uint16(38601), + 43: uint16(39347), + 44: uint16(40786), + 45: uint16(21063), + 46: uint16(21189), + 47: uint16(39149), + 48: uint16(35242), + 49: uint16(19971), + 50: uint16(26578), + 51: uint16(28422), + 52: uint16(20405), + 53: uint16(23522), + 54: uint16(26517), + 55: uint16(27784), + 56: uint16(28024), + 57: uint16(29723), + 58: uint16(30759), + 59: uint16(37341), + 60: uint16(37756), + 61: uint16(34756), + 62: uint16(31204), + 63: uint16(31281), + 64: uint16(24555), + 65: uint16(20182), + 66: uint16(21668), + 67: uint16(21822), + 68: uint16(22702), + 69: uint16(22949), + 70: uint16(24816), + 71: uint16(25171), + 72: uint16(25302), + 73: uint16(26422), + 74: uint16(26965), + 75: uint16(33333), + 76: uint16(38464), + 77: uint16(39345), + 78: uint16(39389), + 79: uint16(20524), + 80: uint16(21331), + 81: uint16(21828), + 82: uint16(22396), + 83: uint16(64001), + 84: uint16(25176), + 85: uint16(64002), + 86: uint16(25826), + 87: uint16(26219), + 88: uint16(26589), + 89: uint16(28609), + 90: uint16(28655), + 91: uint16(29730), + 92: uint16(29752), + 93: uint16(35351), + }, + 86: { + 0: uint16(37944), + 1: uint16(21585), + 2: uint16(22022), + 3: uint16(22374), + 4: uint16(24392), + 5: uint16(24986), + 6: uint16(27470), + 7: uint16(28760), + 8: uint16(28845), + 9: uint16(32187), + 10: uint16(35477), + 11: uint16(22890), + 12: uint16(33067), + 13: uint16(25506), + 14: uint16(30472), + 15: uint16(32829), + 16: uint16(36010), + 17: uint16(22612), + 18: uint16(25645), + 19: uint16(27067), + 20: uint16(23445), + 21: uint16(24081), + 22: uint16(28271), + 23: uint16(64003), + 24: uint16(34153), + 25: uint16(20812), + 26: uint16(21488), + 27: uint16(22826), + 28: uint16(24608), + 29: uint16(24907), + 30: uint16(27526), + 31: uint16(27760), + 32: uint16(27888), + 33: uint16(31518), + 34: uint16(32974), + 35: uint16(33492), + 36: uint16(36294), + 37: uint16(37040), + 38: uint16(39089), + 39: uint16(64004), + 40: uint16(25799), + 41: uint16(28580), + 42: uint16(25745), + 43: uint16(25860), + 44: uint16(20814), + 45: uint16(21520), + 46: uint16(22303), + 47: uint16(35342), + 48: uint16(24927), + 49: uint16(26742), + 50: uint16(64005), + 51: uint16(30171), + 52: uint16(31570), + 53: uint16(32113), + 54: uint16(36890), + 55: uint16(22534), + 56: uint16(27084), + 57: uint16(33151), + 58: uint16(35114), + 59: uint16(36864), + 60: uint16(38969), + 61: uint16(20600), + 62: uint16(22871), + 63: uint16(22956), + 64: uint16(25237), + 65: uint16(36879), + 66: uint16(39722), + 67: uint16(24925), + 68: uint16(29305), + 69: uint16(38358), + 70: uint16(22369), + 71: uint16(23110), + 72: uint16(24052), + 73: uint16(25226), + 74: uint16(25773), + 75: uint16(25850), + 76: uint16(26487), + 77: uint16(27874), + 78: uint16(27966), + 79: uint16(29228), + 80: uint16(29750), + 81: uint16(30772), + 82: uint16(32631), + 83: uint16(33453), + 84: uint16(36315), + 85: uint16(38935), + 86: uint16(21028), + 87: uint16(22338), + 88: uint16(26495), + 89: uint16(29256), + 90: uint16(29923), + 91: uint16(36009), + 92: uint16(36774), + 93: uint16(37393), + }, + 87: { + 0: uint16(38442), + 1: uint16(20843), + 2: uint16(21485), + 3: uint16(25420), + 4: uint16(20329), + 5: uint16(21764), + 6: uint16(24726), + 7: uint16(25943), + 8: uint16(27803), + 9: uint16(28031), + 10: uint16(29260), + 11: uint16(29437), + 12: uint16(31255), + 13: uint16(35207), + 14: uint16(35997), + 15: uint16(24429), + 16: uint16(28558), + 17: uint16(28921), + 18: uint16(33192), + 19: uint16(24846), + 20: uint16(20415), + 21: uint16(20559), + 22: uint16(25153), + 23: uint16(29255), + 24: uint16(31687), + 25: uint16(32232), + 26: uint16(32745), + 27: uint16(36941), + 28: uint16(38829), + 29: uint16(39449), + 30: uint16(36022), + 31: uint16(22378), + 32: uint16(24179), + 33: uint16(26544), + 34: uint16(33805), + 35: uint16(35413), + 36: uint16(21536), + 37: uint16(23318), + 38: uint16(24163), + 39: uint16(24290), + 40: uint16(24330), + 41: uint16(25987), + 42: uint16(32954), + 43: uint16(34109), + 44: uint16(38281), + 45: uint16(38491), + 46: uint16(20296), + 47: uint16(21253), + 48: uint16(21261), + 49: uint16(21263), + 50: uint16(21638), + 51: uint16(21754), + 52: uint16(22275), + 53: uint16(24067), + 54: uint16(24598), + 55: uint16(25243), + 56: uint16(25265), + 57: uint16(25429), + 58: uint16(64006), + 59: uint16(27873), + 60: uint16(28006), + 61: uint16(30129), + 62: uint16(30770), + 63: uint16(32990), + 64: uint16(33071), + 65: uint16(33502), + 66: uint16(33889), + 67: uint16(33970), + 68: uint16(34957), + 69: uint16(35090), + 70: uint16(36875), + 71: uint16(37610), + 72: uint16(39165), + 73: uint16(39825), + 74: uint16(24133), + 75: uint16(26292), + 76: uint16(26333), + 77: uint16(28689), + 78: uint16(29190), + 79: uint16(64007), + 80: uint16(20469), + 81: uint16(21117), + 82: uint16(24426), + 83: uint16(24915), + 84: uint16(26451), + 85: uint16(27161), + 86: uint16(28418), + 87: uint16(29922), + 88: uint16(31080), + 89: uint16(34920), + 90: uint16(35961), + 91: uint16(39111), + 92: uint16(39108), + 93: uint16(39491), + }, + 88: { + 0: uint16(21697), + 1: uint16(31263), + 2: uint16(26963), + 3: uint16(35575), + 4: uint16(35914), + 5: uint16(39080), + 6: uint16(39342), + 7: uint16(24444), + 8: uint16(25259), + 9: uint16(30130), + 10: uint16(30382), + 11: uint16(34987), + 12: uint16(36991), + 13: uint16(38466), + 14: uint16(21305), + 15: uint16(24380), + 16: uint16(24517), + 17: uint16(27852), + 18: uint16(29644), + 19: uint16(30050), + 20: uint16(30091), + 21: uint16(31558), + 22: uint16(33534), + 23: uint16(39325), + 24: uint16(20047), + 25: uint16(36924), + 26: uint16(19979), + 27: uint16(20309), + 28: uint16(21414), + 29: uint16(22799), + 30: uint16(24264), + 31: uint16(26160), + 32: uint16(27827), + 33: uint16(29781), + 34: uint16(33655), + 35: uint16(34662), + 36: uint16(36032), + 37: uint16(36944), + 38: uint16(38686), + 39: uint16(39957), + 40: uint16(22737), + 41: uint16(23416), + 42: uint16(34384), + 43: uint16(35604), + 44: uint16(40372), + 45: uint16(23506), + 46: uint16(24680), + 47: uint16(24717), + 48: uint16(26097), + 49: uint16(27735), + 50: uint16(28450), + 51: uint16(28579), + 52: uint16(28698), + 53: uint16(32597), + 54: uint16(32752), + 55: uint16(38289), + 56: uint16(38290), + 57: uint16(38480), + 58: uint16(38867), + 59: uint16(21106), + 60: uint16(36676), + 61: uint16(20989), + 62: uint16(21547), + 63: uint16(21688), + 64: uint16(21859), + 65: uint16(21898), + 66: uint16(27323), + 67: uint16(28085), + 68: uint16(32216), + 69: uint16(33382), + 70: uint16(37532), + 71: uint16(38519), + 72: uint16(40569), + 73: uint16(21512), + 74: uint16(21704), + 75: uint16(30418), + 76: uint16(34532), + 77: uint16(38308), + 78: uint16(38356), + 79: uint16(38492), + 80: uint16(20130), + 81: uint16(20233), + 82: uint16(23022), + 83: uint16(23270), + 84: uint16(24055), + 85: uint16(24658), + 86: uint16(25239), + 87: uint16(26477), + 88: uint16(26689), + 89: uint16(27782), + 90: uint16(28207), + 91: uint16(32568), + 92: uint16(32923), + 93: uint16(33322), + }, + 89: { + 0: uint16(64008), + 1: uint16(64009), + 2: uint16(38917), + 3: uint16(20133), + 4: uint16(20565), + 5: uint16(21683), + 6: uint16(22419), + 7: uint16(22874), + 8: uint16(23401), + 9: uint16(23475), + 10: uint16(25032), + 11: uint16(26999), + 12: uint16(28023), + 13: uint16(28707), + 14: uint16(34809), + 15: uint16(35299), + 16: uint16(35442), + 17: uint16(35559), + 18: uint16(36994), + 19: uint16(39405), + 20: uint16(39608), + 21: uint16(21182), + 22: uint16(26680), + 23: uint16(20502), + 24: uint16(24184), + 25: uint16(26447), + 26: uint16(33607), + 27: uint16(34892), + 28: uint16(20139), + 29: uint16(21521), + 30: uint16(22190), + 31: uint16(29670), + 32: uint16(37141), + 33: uint16(38911), + 34: uint16(39177), + 35: uint16(39255), + 36: uint16(39321), + 37: uint16(22099), + 38: uint16(22687), + 39: uint16(34395), + 40: uint16(35377), + 41: uint16(25010), + 42: uint16(27382), + 43: uint16(29563), + 44: uint16(36562), + 45: uint16(27463), + 46: uint16(38570), + 47: uint16(39511), + 48: uint16(22869), + 49: uint16(29184), + 50: uint16(36203), + 51: uint16(38761), + 52: uint16(20436), + 53: uint16(23796), + 54: uint16(24358), + 55: uint16(25080), + 56: uint16(26203), + 57: uint16(27883), + 58: uint16(28843), + 59: uint16(29572), + 60: uint16(29625), + 61: uint16(29694), + 62: uint16(30505), + 63: uint16(30541), + 64: uint16(32067), + 65: uint16(32098), + 66: uint16(32291), + 67: uint16(33335), + 68: uint16(34898), + 69: uint16(64010), + 70: uint16(36066), + 71: uint16(37449), + 72: uint16(39023), + 73: uint16(23377), + 74: uint16(31348), + 75: uint16(34880), + 76: uint16(38913), + 77: uint16(23244), + 78: uint16(20448), + 79: uint16(21332), + 80: uint16(22846), + 81: uint16(23805), + 82: uint16(25406), + 83: uint16(28025), + 84: uint16(29433), + 85: uint16(33029), + 86: uint16(33031), + 87: uint16(33698), + 88: uint16(37583), + 89: uint16(38960), + 90: uint16(20136), + 91: uint16(20804), + 92: uint16(21009), + 93: uint16(22411), + }, + 90: { + 0: uint16(24418), + 1: uint16(27842), + 2: uint16(28366), + 3: uint16(28677), + 4: uint16(28752), + 5: uint16(28847), + 6: uint16(29074), + 7: uint16(29673), + 8: uint16(29801), + 9: uint16(33610), + 10: uint16(34722), + 11: uint16(34913), + 12: uint16(36872), + 13: uint16(37026), + 14: uint16(37795), + 15: uint16(39336), + 16: uint16(20846), + 17: uint16(24407), + 18: uint16(24800), + 19: uint16(24935), + 20: uint16(26291), + 21: uint16(34137), + 22: uint16(36426), + 23: uint16(37295), + 24: uint16(38795), + 25: uint16(20046), + 26: uint16(20114), + 27: uint16(21628), + 28: uint16(22741), + 29: uint16(22778), + 30: uint16(22909), + 31: uint16(23733), + 32: uint16(24359), + 33: uint16(25142), + 34: uint16(25160), + 35: uint16(26122), + 36: uint16(26215), + 37: uint16(27627), + 38: uint16(28009), + 39: uint16(28111), + 40: uint16(28246), + 41: uint16(28408), + 42: uint16(28564), + 43: uint16(28640), + 44: uint16(28649), + 45: uint16(28765), + 46: uint16(29392), + 47: uint16(29733), + 48: uint16(29786), + 49: uint16(29920), + 50: uint16(30355), + 51: uint16(31068), + 52: uint16(31946), + 53: uint16(32286), + 54: uint16(32993), + 55: uint16(33446), + 56: uint16(33899), + 57: uint16(33983), + 58: uint16(34382), + 59: uint16(34399), + 60: uint16(34676), + 61: uint16(35703), + 62: uint16(35946), + 63: uint16(37804), + 64: uint16(38912), + 65: uint16(39013), + 66: uint16(24785), + 67: uint16(25110), + 68: uint16(37239), + 69: uint16(23130), + 70: uint16(26127), + 71: uint16(28151), + 72: uint16(28222), + 73: uint16(29759), + 74: uint16(39746), + 75: uint16(24573), + 76: uint16(24794), + 77: uint16(31503), + 78: uint16(21700), + 79: uint16(24344), + 80: uint16(27742), + 81: uint16(27859), + 82: uint16(27946), + 83: uint16(28888), + 84: uint16(32005), + 85: uint16(34425), + 86: uint16(35340), + 87: uint16(40251), + 88: uint16(21270), + 89: uint16(21644), + 90: uint16(23301), + 91: uint16(27194), + 92: uint16(28779), + 93: uint16(30069), + }, + 91: { + 0: uint16(31117), + 1: uint16(31166), + 2: uint16(33457), + 3: uint16(33775), + 4: uint16(35441), + 5: uint16(35649), + 6: uint16(36008), + 7: uint16(38772), + 8: uint16(64011), + 9: uint16(25844), + 10: uint16(25899), + 11: uint16(30906), + 12: uint16(30907), + 13: uint16(31339), + 14: uint16(20024), + 15: uint16(21914), + 16: uint16(22864), + 17: uint16(23462), + 18: uint16(24187), + 19: uint16(24739), + 20: uint16(25563), + 21: uint16(27489), + 22: uint16(26213), + 23: uint16(26707), + 24: uint16(28185), + 25: uint16(29029), + 26: uint16(29872), + 27: uint16(32008), + 28: uint16(36996), + 29: uint16(39529), + 30: uint16(39973), + 31: uint16(27963), + 32: uint16(28369), + 33: uint16(29502), + 34: uint16(35905), + 35: uint16(38346), + 36: uint16(20976), + 37: uint16(24140), + 38: uint16(24488), + 39: uint16(24653), + 40: uint16(24822), + 41: uint16(24880), + 42: uint16(24908), + 43: uint16(26179), + 44: uint16(26180), + 45: uint16(27045), + 46: uint16(27841), + 47: uint16(28255), + 48: uint16(28361), + 49: uint16(28514), + 50: uint16(29004), + 51: uint16(29852), + 52: uint16(30343), + 53: uint16(31681), + 54: uint16(31783), + 55: uint16(33618), + 56: uint16(34647), + 57: uint16(36945), + 58: uint16(38541), + 59: uint16(40643), + 60: uint16(21295), + 61: uint16(22238), + 62: uint16(24315), + 63: uint16(24458), + 64: uint16(24674), + 65: uint16(24724), + 66: uint16(25079), + 67: uint16(26214), + 68: uint16(26371), + 69: uint16(27292), + 70: uint16(28142), + 71: uint16(28590), + 72: uint16(28784), + 73: uint16(29546), + 74: uint16(32362), + 75: uint16(33214), + 76: uint16(33588), + 77: uint16(34516), + 78: uint16(35496), + 79: uint16(36036), + 80: uint16(21123), + 81: uint16(29554), + 82: uint16(23446), + 83: uint16(27243), + 84: uint16(37892), + 85: uint16(21742), + 86: uint16(22150), + 87: uint16(23389), + 88: uint16(25928), + 89: uint16(25989), + 90: uint16(26313), + 91: uint16(26783), + 92: uint16(28045), + 93: uint16(28102), + }, + 92: { + 0: uint16(29243), + 1: uint16(32948), + 2: uint16(37237), + 3: uint16(39501), + 4: uint16(20399), + 5: uint16(20505), + 6: uint16(21402), + 7: uint16(21518), + 8: uint16(21564), + 9: uint16(21897), + 10: uint16(21957), + 11: uint16(24127), + 12: uint16(24460), + 13: uint16(26429), + 14: uint16(29030), + 15: uint16(29661), + 16: uint16(36869), + 17: uint16(21211), + 18: uint16(21235), + 19: uint16(22628), + 20: uint16(22734), + 21: uint16(28932), + 22: uint16(29071), + 23: uint16(29179), + 24: uint16(34224), + 25: uint16(35347), + 26: uint16(26248), + 27: uint16(34216), + 28: uint16(21927), + 29: uint16(26244), + 30: uint16(29002), + 31: uint16(33841), + 32: uint16(21321), + 33: uint16(21913), + 34: uint16(27585), + 35: uint16(24409), + 36: uint16(24509), + 37: uint16(25582), + 38: uint16(26249), + 39: uint16(28999), + 40: uint16(35569), + 41: uint16(36637), + 42: uint16(40638), + 43: uint16(20241), + 44: uint16(25658), + 45: uint16(28875), + 46: uint16(30054), + 47: uint16(34407), + 48: uint16(24676), + 49: uint16(35662), + 50: uint16(40440), + 51: uint16(20807), + 52: uint16(20982), + 53: uint16(21256), + 54: uint16(27958), + 55: uint16(33016), + 56: uint16(40657), + 57: uint16(26133), + 58: uint16(27427), + 59: uint16(28824), + 60: uint16(30165), + 61: uint16(21507), + 62: uint16(23673), + 63: uint16(32007), + 64: uint16(35350), + 65: uint16(27424), + 66: uint16(27453), + 67: uint16(27462), + 68: uint16(21560), + 69: uint16(24688), + 70: uint16(27965), + 71: uint16(32725), + 72: uint16(33288), + 73: uint16(20694), + 74: uint16(20958), + 75: uint16(21916), + 76: uint16(22123), + 77: uint16(22221), + 78: uint16(23020), + 79: uint16(23305), + 80: uint16(24076), + 81: uint16(24985), + 82: uint16(24984), + 83: uint16(25137), + 84: uint16(26206), + 85: uint16(26342), + 86: uint16(29081), + 87: uint16(29113), + 88: uint16(29114), + 89: uint16(29351), + 90: uint16(31143), + 91: uint16(31232), + 92: uint16(32690), + 93: uint16(35440), + }, +} + +var _rev_jis = [6879]uint16{ + 0: uint16(31), + 1: uint16(80), + 2: uint16(81), + 3: uint16(87), + 4: uint16(14), + 5: uint16(299), + 6: uint16(74), + 7: uint16(61), + 8: uint16(12), + 9: uint16(344), + 10: uint16(62), + 11: uint16(63), + 12: uint16(1280), + 13: uint16(1281), + 14: uint16(1282), + 15: uint16(1283), + 16: uint16(1284), + 17: uint16(1285), + 18: uint16(1286), + 19: uint16(1287), + 20: uint16(1288), + 21: uint16(1289), + 22: uint16(1290), + 23: uint16(1291), + 24: uint16(1292), + 25: uint16(1293), + 26: uint16(1294), + 27: uint16(1295), + 28: uint16(1296), + 29: uint16(1297), + 30: uint16(1298), + 31: uint16(1299), + 32: uint16(1300), + 33: uint16(1301), + 34: uint16(1302), + 35: uint16(1303), + 36: uint16(1312), + 37: uint16(1313), + 38: uint16(1314), + 39: uint16(1315), + 40: uint16(1316), + 41: uint16(1317), + 42: uint16(1318), + 43: uint16(1319), + 44: uint16(1320), + 45: uint16(1321), + 46: uint16(1322), + 47: uint16(1323), + 48: uint16(1324), + 49: uint16(1325), + 50: uint16(1326), + 51: uint16(1327), + 52: uint16(1328), + 53: uint16(1329), + 54: uint16(1330), + 55: uint16(1331), + 56: uint16(1332), + 57: uint16(1333), + 58: uint16(1334), + 59: uint16(1335), + 60: uint16(1542), + 61: uint16(1536), + 62: uint16(1537), + 63: uint16(1538), + 64: uint16(1539), + 65: uint16(1540), + 66: uint16(1541), + 67: uint16(1543), + 68: uint16(1544), + 69: uint16(1545), + 70: uint16(1546), + 71: uint16(1547), + 72: uint16(1548), + 73: uint16(1549), + 74: uint16(1550), + 75: uint16(1551), + 76: uint16(1552), + 77: uint16(1553), + 78: uint16(1554), + 79: uint16(1555), + 80: uint16(1556), + 81: uint16(1557), + 82: uint16(1558), + 83: uint16(1559), + 84: uint16(1560), + 85: uint16(1561), + 86: uint16(1562), + 87: uint16(1563), + 88: uint16(1564), + 89: uint16(1565), + 90: uint16(1566), + 91: uint16(1567), + 92: uint16(1568), + 93: uint16(1584), + 94: uint16(1585), + 95: uint16(1586), + 96: uint16(1587), + 97: uint16(1588), + 98: uint16(1589), + 99: uint16(1591), + 100: uint16(1592), + 101: uint16(1593), + 102: uint16(1594), + 103: uint16(1595), + 104: uint16(1596), + 105: uint16(1597), + 106: uint16(1598), + 107: uint16(1599), + 108: uint16(1600), + 109: uint16(1601), + 110: uint16(1602), + 111: uint16(1603), + 112: uint16(1604), + 113: uint16(1605), + 114: uint16(1606), + 115: uint16(1607), + 116: uint16(1608), + 117: uint16(1609), + 118: uint16(1610), + 119: uint16(1611), + 120: uint16(1612), + 121: uint16(1613), + 122: uint16(1614), + 123: uint16(1615), + 124: uint16(1616), + 125: uint16(1590), + 126: uint16(29), + 127: uint16(28), + 128: uint16(33), + 129: uint16(37), + 130: uint16(38), + 131: uint16(39), + 132: uint16(40), + 133: uint16(342), + 134: uint16(343), + 135: uint16(36), + 136: uint16(35), + 137: uint16(338), + 138: uint16(75), + 139: uint16(76), + 140: uint16(263), + 141: uint16(77), + 142: uint16(337), + 143: uint16(266), + 144: uint16(267), + 145: uint16(265), + 146: uint16(268), + 147: uint16(300), + 148: uint16(301), + 149: uint16(302), + 150: uint16(318), + 151: uint16(303), + 152: uint16(319), + 153: uint16(281), + 154: uint16(282), + 155: uint16(60), + 156: uint16(324), + 157: uint16(326), + 158: uint16(70), + 159: uint16(315), + 160: uint16(297), + 161: uint16(298), + 162: uint16(288), + 163: uint16(287), + 164: uint16(328), + 165: uint16(329), + 166: uint16(71), + 167: uint16(327), + 168: uint16(325), + 169: uint16(321), + 170: uint16(65), + 171: uint16(320), + 172: uint16(68), + 173: uint16(69), + 174: uint16(322), + 175: uint16(323), + 176: uint16(285), + 177: uint16(286), + 178: uint16(283), + 179: uint16(284), + 180: uint16(316), + 181: uint16(317), + 182: uint16(1792), + 183: uint16(1803), + 184: uint16(1793), + 185: uint16(1804), + 186: uint16(1794), + 187: uint16(1805), + 188: uint16(1795), + 189: uint16(1806), + 190: uint16(1797), + 191: uint16(1808), + 192: uint16(1796), + 193: uint16(1807), + 194: uint16(1798), + 195: uint16(1819), + 196: uint16(1814), + 197: uint16(1809), + 198: uint16(1800), + 199: uint16(1821), + 200: uint16(1816), + 201: uint16(1811), + 202: uint16(1799), + 203: uint16(1815), + 204: uint16(1820), + 205: uint16(1810), + 206: uint16(1801), + 207: uint16(1817), + 208: uint16(1822), + 209: uint16(1812), + 210: uint16(1802), + 211: uint16(1818), + 212: uint16(1823), + 213: uint16(1813), + 214: uint16(258), + 215: uint16(257), + 216: uint16(260), + 217: uint16(259), + 218: uint16(262), + 219: uint16(261), + 220: uint16(256), + 221: uint16(93), + 222: uint16(90), + 223: uint16(92), + 224: uint16(91), + 225: uint16(349), + 226: uint16(89), + 227: uint16(88), + 228: uint16(73), + 229: uint16(72), + 230: uint16(341), + 231: uint16(340), + 232: uint16(339), + 234: uint16(1), + 235: uint16(2), + 236: uint16(22), + 237: uint16(24), + 238: uint16(25), + 239: uint16(26), + 240: uint16(49), + 241: uint16(50), + 242: uint16(51), + 243: uint16(52), + 244: uint16(53), + 245: uint16(54), + 246: uint16(55), + 247: uint16(56), + 248: uint16(57), + 249: uint16(58), + 250: uint16(264), + 251: uint16(269), + 252: uint16(43), + 253: uint16(44), + 254: uint16(32), + 255: uint16(768), + 256: uint16(769), + 257: uint16(770), + 258: uint16(771), + 259: uint16(772), + 260: uint16(773), + 261: uint16(774), + 262: uint16(775), + 263: uint16(776), + 264: uint16(777), + 265: uint16(778), + 266: uint16(779), + 267: uint16(780), + 268: uint16(781), + 269: uint16(782), + 270: uint16(783), + 271: uint16(784), + 272: uint16(785), + 273: uint16(786), + 274: uint16(787), + 275: uint16(788), + 276: uint16(789), + 277: uint16(790), + 278: uint16(791), + 279: uint16(792), + 280: uint16(793), + 281: uint16(794), + 282: uint16(795), + 283: uint16(796), + 284: uint16(797), + 285: uint16(798), + 286: uint16(799), + 287: uint16(800), + 288: uint16(801), + 289: uint16(802), + 290: uint16(803), + 291: uint16(804), + 292: uint16(805), + 293: uint16(806), + 294: uint16(807), + 295: uint16(808), + 296: uint16(809), + 297: uint16(810), + 298: uint16(811), + 299: uint16(812), + 300: uint16(813), + 301: uint16(814), + 302: uint16(815), + 303: uint16(816), + 304: uint16(817), + 305: uint16(818), + 306: uint16(819), + 307: uint16(820), + 308: uint16(821), + 309: uint16(822), + 310: uint16(823), + 311: uint16(824), + 312: uint16(825), + 313: uint16(826), + 314: uint16(827), + 315: uint16(828), + 316: uint16(829), + 317: uint16(830), + 318: uint16(831), + 319: uint16(832), + 320: uint16(833), + 321: uint16(834), + 322: uint16(835), + 323: uint16(836), + 324: uint16(837), + 325: uint16(838), + 326: uint16(839), + 327: uint16(840), + 328: uint16(841), + 329: uint16(842), + 330: uint16(843), + 331: uint16(844), + 332: uint16(845), + 333: uint16(846), + 334: uint16(847), + 335: uint16(848), + 336: uint16(849), + 337: uint16(850), + 338: uint16(10), + 339: uint16(11), + 340: uint16(20), + 341: uint16(21), + 342: uint16(1024), + 343: uint16(1025), + 344: uint16(1026), + 345: uint16(1027), + 346: uint16(1028), + 347: uint16(1029), + 348: uint16(1030), + 349: uint16(1031), + 350: uint16(1032), + 351: uint16(1033), + 352: uint16(1034), + 353: uint16(1035), + 354: uint16(1036), + 355: uint16(1037), + 356: uint16(1038), + 357: uint16(1039), + 358: uint16(1040), + 359: uint16(1041), + 360: uint16(1042), + 361: uint16(1043), + 362: uint16(1044), + 363: uint16(1045), + 364: uint16(1046), + 365: uint16(1047), + 366: uint16(1048), + 367: uint16(1049), + 368: uint16(1050), + 369: uint16(1051), + 370: uint16(1052), + 371: uint16(1053), + 372: uint16(1054), + 373: uint16(1055), + 374: uint16(1056), + 375: uint16(1057), + 376: uint16(1058), + 377: uint16(1059), + 378: uint16(1060), + 379: uint16(1061), + 380: uint16(1062), + 381: uint16(1063), + 382: uint16(1064), + 383: uint16(1065), + 384: uint16(1066), + 385: uint16(1067), + 386: uint16(1068), + 387: uint16(1069), + 388: uint16(1070), + 389: uint16(1071), + 390: uint16(1072), + 391: uint16(1073), + 392: uint16(1074), + 393: uint16(1075), + 394: uint16(1076), + 395: uint16(1077), + 396: uint16(1078), + 397: uint16(1079), + 398: uint16(1080), + 399: uint16(1081), + 400: uint16(1082), + 401: uint16(1083), + 402: uint16(1084), + 403: uint16(1085), + 404: uint16(1086), + 405: uint16(1087), + 406: uint16(1088), + 407: uint16(1089), + 408: uint16(1090), + 409: uint16(1091), + 410: uint16(1092), + 411: uint16(1093), + 412: uint16(1094), + 413: uint16(1095), + 414: uint16(1096), + 415: uint16(1097), + 416: uint16(1098), + 417: uint16(1099), + 418: uint16(1100), + 419: uint16(1101), + 420: uint16(1102), + 421: uint16(1103), + 422: uint16(1104), + 423: uint16(1105), + 424: uint16(1106), + 425: uint16(1107), + 426: uint16(1108), + 427: uint16(1109), + 428: uint16(5), + 429: uint16(27), + 430: uint16(18), + 431: uint16(19), + 432: uint16(3915), + 433: uint16(8793), + 434: uint16(6934), + 435: uint16(10843), + 436: uint16(7493), + 437: uint16(6671), + 438: uint16(7492), + 439: uint16(4379), + 440: uint16(10291), + 441: uint16(11294), + 442: uint16(12033), + 443: uint16(4110), + 444: uint16(4685), + 445: uint16(12034), + 446: uint16(7939), + 447: uint16(12577), + 448: uint16(5173), + 449: uint16(10521), + 450: uint16(7494), + 451: uint16(11549), + 452: uint16(10529), + 453: uint16(12035), + 454: uint16(8773), + 455: uint16(12036), + 456: uint16(5465), + 457: uint16(12037), + 458: uint16(4924), + 459: uint16(8719), + 460: uint16(6982), + 461: uint16(12038), + 462: uint16(12039), + 463: uint16(12040), + 464: uint16(9748), + 465: uint16(5174), + 466: uint16(9750), + 467: uint16(9538), + 468: uint16(5922), + 469: uint16(10770), + 470: uint16(18472), + 471: uint16(12041), + 472: uint16(7495), + 473: uint16(12042), + 474: uint16(4372), + 475: uint16(5444), + 476: uint16(5967), + 477: uint16(11080), + 478: uint16(13573), + 479: uint16(11343), + 480: uint16(9564), + 481: uint16(4868), + 482: uint16(5140), + 483: uint16(12043), + 484: uint16(12044), + 485: uint16(11546), + 486: uint16(11292), + 487: uint16(8263), + 488: uint16(12046), + 489: uint16(6741), + 490: uint16(9554), + 491: uint16(12049), + 492: uint16(4125), + 493: uint16(5950), + 494: uint16(5949), + 495: uint16(3909), + 496: uint16(11818), + 497: uint16(11817), + 498: uint16(6418), + 499: uint16(3840), + 500: uint16(12050), + 501: uint16(12051), + 502: uint16(12052), + 503: uint16(10771), + 504: uint16(12053), + 505: uint16(5969), + 506: uint16(3910), + 507: uint16(10833), + 508: uint16(5211), + 509: uint16(5212), + 510: uint16(5213), + 511: uint16(9025), + 512: uint16(11547), + 513: uint16(12054), + 514: uint16(12055), + 515: uint16(12056), + 516: uint16(7724), + 517: uint16(7193), + 518: uint16(7725), + 519: uint16(12061), + 520: uint16(12059), + 521: uint16(12060), + 522: uint16(5175), + 523: uint16(6402), + 524: uint16(4431), + 525: uint16(12058), + 526: uint16(12057), + 527: uint16(10504), + 528: uint16(6693), + 529: uint16(6692), + 530: uint16(8477), + 531: uint16(12062), + 532: uint16(10292), + 533: uint16(8006), + 534: uint16(23), + 535: uint16(12063), + 536: uint16(12065), + 537: uint16(8516), + 538: uint16(11584), + 539: uint16(3881), + 540: uint16(12064), + 541: uint16(4381), + 542: uint16(5411), + 543: uint16(8774), + 544: uint16(5710), + 545: uint16(12066), + 546: uint16(9731), + 547: uint16(4938), + 548: uint16(12067), + 549: uint16(3882), + 550: uint16(5951), + 551: uint16(4939), + 552: uint16(10329), + 553: uint16(10001), + 554: uint16(5176), + 555: uint16(4432), + 556: uint16(12102), + 557: uint16(9248), + 558: uint16(9803), + 559: uint16(12069), + 560: uint16(10011), + 561: uint16(11585), + 562: uint16(7692), + 563: uint16(6694), + 564: uint16(6742), + 565: uint16(4383), + 566: uint16(9008), + 567: uint16(8705), + 568: uint16(12073), + 569: uint16(3883), + 570: uint16(9026), + 571: uint16(7194), + 572: uint16(6419), + 573: uint16(11267), + 574: uint16(8493), + 575: uint16(4382), + 576: uint16(12072), + 577: uint16(11293), + 578: uint16(12068), + 579: uint16(12070), + 580: uint16(6477), + 581: uint16(12071), + 582: uint16(13315), + 583: uint16(12079), + 584: uint16(12082), + 585: uint16(12080), + 586: uint16(4385), + 587: uint16(10522), + 588: uint16(12074), + 589: uint16(12078), + 590: uint16(5970), + 591: uint16(6695), + 592: uint16(4869), + 593: uint16(12083), + 594: uint16(12075), + 595: uint16(11586), + 596: uint16(6743), + 597: uint16(12076), + 598: uint16(12081), + 599: uint16(12084), + 600: uint16(12077), + 601: uint16(5376), + 602: uint16(3884), + 603: uint16(5377), + 604: uint16(4384), + 605: uint16(13316), + 606: uint16(10840), + 607: uint16(10317), + 608: uint16(5971), + 609: uint16(7694), + 610: uint16(11542), + 611: uint16(10551), + 612: uint16(5655), + 613: uint16(8452), + 614: uint16(4419), + 615: uint16(7218), + 616: uint16(12088), + 617: uint16(12093), + 618: uint16(12091), + 619: uint16(12086), + 620: uint16(8462), + 621: uint16(12089), + 622: uint16(12092), + 623: uint16(12090), + 624: uint16(10556), + 625: uint16(12087), + 626: uint16(7693), + 627: uint16(10834), + 628: uint16(12094), + 629: uint16(12095), + 630: uint16(7171), + 631: uint16(12108), + 632: uint16(9775), + 633: uint16(10261), + 634: uint16(12103), + 635: uint16(10575), + 636: uint16(4373), + 637: uint16(12107), + 638: uint16(12101), + 639: uint16(12110), + 640: uint16(8241), + 641: uint16(5923), + 642: uint16(9787), + 643: uint16(16166), + 644: uint16(12109), + 645: uint16(9276), + 646: uint16(12098), + 647: uint16(5973), + 648: uint16(5972), + 649: uint16(12096), + 650: uint16(6969), + 651: uint16(12104), + 652: uint16(10574), + 653: uint16(8748), + 654: uint16(12100), + 655: uint16(5712), + 656: uint16(12097), + 657: uint16(12105), + 658: uint16(12099), + 659: uint16(11568), + 660: uint16(12106), + 661: uint16(11808), + 662: uint16(5445), + 663: uint16(5711), + 664: uint16(12111), + 665: uint16(12112), + 666: uint16(12116), + 667: uint16(3885), + 668: uint16(10543), + 669: uint16(12115), + 670: uint16(12114), + 671: uint16(12118), + 672: uint16(12117), + 673: uint16(9027), + 674: uint16(5713), + 675: uint16(12119), + 676: uint16(6948), + 677: uint16(8453), + 678: uint16(9028), + 679: uint16(5461), + 680: uint16(12120), + 681: uint16(5141), + 682: uint16(12121), + 683: uint16(12123), + 684: uint16(10772), + 685: uint16(5701), + 686: uint16(6672), + 687: uint16(10070), + 688: uint16(12122), + 689: uint16(6436), + 690: uint16(11298), + 691: uint16(12125), + 692: uint16(12290), + 693: uint16(12124), + 694: uint16(6435), + 695: uint16(7260), + 696: uint16(5656), + 697: uint16(12291), + 698: uint16(5422), + 699: uint16(12288), + 700: uint16(12289), + 701: uint16(9486), + 702: uint16(8283), + 703: uint16(5378), + 704: uint16(10796), + 705: uint16(12292), + 706: uint16(11548), + 707: uint16(12293), + 708: uint16(12296), + 709: uint16(12294), + 710: uint16(8237), + 711: uint16(12295), + 712: uint16(12297), + 713: uint16(12299), + 714: uint16(12298), + 715: uint16(10535), + 716: uint16(5142), + 717: uint16(12301), + 718: uint16(12302), + 719: uint16(4366), + 720: uint16(12300), + 721: uint16(6995), + 722: uint16(12305), + 723: uint16(12304), + 724: uint16(12303), + 725: uint16(12085), + 726: uint16(12306), + 727: uint16(7261), + 728: uint16(12307), + 729: uint16(11268), + 730: uint16(11064), + 731: uint16(12309), + 732: uint16(12308), + 733: uint16(12311), + 734: uint16(12310), + 735: uint16(12312), + 736: uint16(12313), + 737: uint16(3923), + 738: uint16(5908), + 739: uint16(5658), + 740: uint16(7195), + 741: uint16(8794), + 742: uint16(5379), + 743: uint16(8007), + 744: uint16(5974), + 745: uint16(6221), + 746: uint16(12315), + 747: uint16(11047), + 748: uint16(9253), + 749: uint16(6744), + 750: uint16(12314), + 751: uint16(12316), + 752: uint16(9277), + 753: uint16(4692), + 754: uint16(12317), + 755: uint16(9565), + 756: uint16(8211), + 757: uint16(12319), + 758: uint16(12320), + 759: uint16(9995), + 760: uint16(5975), + 761: uint16(11802), + 762: uint16(12321), + 763: uint16(5381), + 764: uint16(10523), + 765: uint16(8469), + 766: uint16(5456), + 767: uint16(9236), + 768: uint16(5714), + 769: uint16(12322), + 770: uint16(12323), + 771: uint16(9537), + 772: uint16(4158), + 773: uint16(12326), + 774: uint16(6492), + 775: uint16(12325), + 776: uint16(6437), + 777: uint16(12327), + 778: uint16(17741), + 779: uint16(12328), + 780: uint16(10784), + 781: uint16(12329), + 782: uint16(12330), + 783: uint16(12331), + 784: uint16(7496), + 785: uint16(6955), + 786: uint16(4870), + 787: uint16(12334), + 788: uint16(12332), + 789: uint16(11036), + 790: uint16(12333), + 791: uint16(10297), + 792: uint16(12335), + 793: uint16(12336), + 794: uint16(12337), + 795: uint16(9278), + 796: uint16(12341), + 797: uint16(12339), + 798: uint16(12340), + 799: uint16(12338), + 800: uint16(6466), + 801: uint16(12342), + 802: uint16(11081), + 803: uint16(11587), + 804: uint16(12343), + 805: uint16(7943), + 806: uint16(12344), + 807: uint16(7225), + 808: uint16(12345), + 809: uint16(8795), + 810: uint16(11550), + 811: uint16(9279), + 812: uint16(12580), + 813: uint16(12346), + 814: uint16(21252), + 815: uint16(5412), + 816: uint16(12347), + 817: uint16(10813), + 818: uint16(7239), + 819: uint16(8539), + 820: uint16(12349), + 821: uint16(9539), + 822: uint16(12350), + 823: uint16(12351), + 824: uint16(4621), + 825: uint16(12352), + 826: uint16(5382), + 827: uint16(9515), + 828: uint16(4185), + 829: uint16(7215), + 830: uint16(9984), + 831: uint16(12353), + 832: uint16(9280), + 833: uint16(7726), + 834: uint16(12354), + 835: uint16(10507), + 836: uint16(7993), + 837: uint16(4865), + 838: uint16(4872), + 839: uint16(12355), + 840: uint16(12357), + 841: uint16(5657), + 842: uint16(12356), + 843: uint16(11602), + 844: uint16(7240), + 845: uint16(10012), + 846: uint16(10539), + 847: uint16(12358), + 848: uint16(11351), + 849: uint16(12359), + 850: uint16(12360), + 851: uint16(9309), + 852: uint16(12361), + 853: uint16(7944), + 854: uint16(6493), + 855: uint16(5715), + 856: uint16(12362), + 857: uint16(6696), + 858: uint16(6222), + 859: uint16(9029), + 860: uint16(12364), + 861: uint16(8454), + 862: uint16(6478), + 863: uint16(12365), + 864: uint16(12366), + 865: uint16(8207), + 866: uint16(12363), + 867: uint16(12368), + 868: uint16(10773), + 869: uint16(6211), + 870: uint16(12367), + 871: uint16(5716), + 872: uint16(6461), + 873: uint16(9804), + 874: uint16(12371), + 875: uint16(12369), + 876: uint16(10330), + 877: uint16(7497), + 878: uint16(12378), + 879: uint16(4675), + 880: uint16(12372), + 881: uint16(12370), + 882: uint16(8238), + 883: uint16(12374), + 884: uint16(12373), + 885: uint16(4643), + 886: uint16(5695), + 887: uint16(12379), + 888: uint16(11532), + 889: uint16(12375), + 890: uint16(12380), + 891: uint16(12377), + 892: uint16(12376), + 893: uint16(11566), + 894: uint16(5976), + 895: uint16(4386), + 896: uint16(11603), + 897: uint16(7252), + 898: uint16(9271), + 899: uint16(6212), + 900: uint16(12545), + 901: uint16(12546), + 902: uint16(11588), + 903: uint16(11786), + 904: uint16(12548), + 905: uint16(5977), + 906: uint16(12547), + 907: uint16(4622), + 908: uint16(12549), + 909: uint16(10805), + 910: uint16(8987), + 911: uint16(11269), + 912: uint16(10552), + 913: uint16(12550), + 914: uint16(20276), + 915: uint16(9487), + 916: uint16(12551), + 917: uint16(4873), + 918: uint16(11026), + 919: uint16(7424), + 920: uint16(12552), + 921: uint16(10566), + 922: uint16(12556), + 923: uint16(7945), + 924: uint16(12553), + 925: uint16(5423), + 926: uint16(12554), + 927: uint16(4874), + 928: uint16(5645), + 929: uint16(12557), + 930: uint16(12558), + 931: uint16(12559), + 932: uint16(12560), + 933: uint16(6970), + 934: uint16(5978), + 935: uint16(11069), + 936: uint16(11079), + 937: uint16(9558), + 938: uint16(10576), + 939: uint16(12561), + 940: uint16(12562), + 941: uint16(12564), + 942: uint16(12566), + 943: uint16(12565), + 944: uint16(12567), + 945: uint16(4380), + 946: uint16(10795), + 947: uint16(6491), + 948: uint16(12568), + 949: uint16(8248), + 950: uint16(7425), + 951: uint16(5384), + 952: uint16(12569), + 953: uint16(10042), + 954: uint16(12570), + 955: uint16(12571), + 956: uint16(12572), + 957: uint16(12573), + 958: uint16(10243), + 959: uint16(5447), + 960: uint16(3908), + 961: uint16(9502), + 962: uint16(12574), + 963: uint16(7196), + 964: uint16(8008), + 965: uint16(12576), + 966: uint16(12575), + 967: uint16(7426), + 968: uint16(5952), + 969: uint16(12578), + 970: uint16(10013), + 971: uint16(12579), + 972: uint16(10043), + 973: uint16(8467), + 974: uint16(8525), + 975: uint16(5383), + 976: uint16(9549), + 977: uint16(8720), + 978: uint16(9805), + 979: uint16(10797), + 980: uint16(12581), + 981: uint16(8009), + 982: uint16(5652), + 983: uint16(12582), + 984: uint16(12583), + 985: uint16(4107), + 986: uint16(3924), + 987: uint16(4940), + 988: uint16(8455), + 989: uint16(5168), + 990: uint16(11344), + 991: uint16(12586), + 992: uint16(4374), + 993: uint16(12585), + 994: uint16(5385), + 995: uint16(12587), + 996: uint16(11088), + 997: uint16(12588), + 998: uint16(11569), + 999: uint16(5979), + 1000: uint16(5909), + 1001: uint16(12589), + 1002: uint16(12591), + 1003: uint16(12590), + 1004: uint16(7742), + 1005: uint16(4120), + 1006: uint16(4157), + 1007: uint16(12592), + 1008: uint16(12593), + 1009: uint16(5910), + 1010: uint16(12594), + 1011: uint16(5197), + 1012: uint16(6673), + 1013: uint16(12595), + 1014: uint16(10835), + 1015: uint16(6420), + 1016: uint16(5177), + 1017: uint16(11270), + 1018: uint16(8239), + 1019: uint16(10014), + 1020: uint16(7004), + 1021: uint16(7206), + 1022: uint16(6983), + 1023: uint16(6996), + 1024: uint16(7253), + 1025: uint16(10015), + 1026: uint16(12598), + 1027: uint16(4130), + 1028: uint16(8240), + 1029: uint16(5980), + 1030: uint16(5924), + 1031: uint16(5446), + 1032: uint16(12602), + 1033: uint16(8704), + 1034: uint16(8541), + 1035: uint16(5386), + 1036: uint16(7427), + 1037: uint16(12603), + 1038: uint16(12601), + 1039: uint16(4387), + 1040: uint16(8517), + 1041: uint16(6935), + 1042: uint16(6698), + 1043: uint16(4101), + 1044: uint16(4687), + 1045: uint16(6213), + 1046: uint16(6697), + 1047: uint16(12604), + 1048: uint16(12605), + 1049: uint16(5160), + 1050: uint16(4645), + 1051: uint16(6214), + 1052: uint16(5159), + 1053: uint16(9022), + 1054: uint16(4100), + 1055: uint16(9488), + 1056: uint16(11037), + 1057: uint16(6144), + 1058: uint16(11352), + 1059: uint16(9254), + 1060: uint16(5981), + 1061: uint16(5646), + 1062: uint16(12614), + 1063: uint16(5442), + 1064: uint16(10793), + 1065: uint16(10044), + 1066: uint16(12613), + 1067: uint16(4925), + 1068: uint16(12608), + 1069: uint16(12609), + 1070: uint16(12611), + 1071: uint16(12612), + 1072: uint16(5178), + 1073: uint16(7744), + 1074: uint16(10508), + 1075: uint16(12610), + 1076: uint16(12606), + 1077: uint16(5954), + 1078: uint16(12607), + 1079: uint16(11779), + 1080: uint16(10577), + 1081: uint16(9031), + 1082: uint16(5953), + 1083: uint16(6223), + 1084: uint16(12615), + 1085: uint16(9532), + 1086: uint16(12619), + 1087: uint16(7005), + 1088: uint16(6997), + 1089: uint16(12622), + 1090: uint16(12620), + 1091: uint16(11010), + 1092: uint16(12617), + 1093: uint16(12626), + 1094: uint16(12621), + 1095: uint16(12624), + 1096: uint16(5925), + 1097: uint16(11038), + 1098: uint16(12625), + 1099: uint16(12627), + 1100: uint16(12629), + 1101: uint16(6479), + 1102: uint16(11809), + 1103: uint16(12618), + 1104: uint16(12616), + 1105: uint16(12628), + 1106: uint16(12623), + 1107: uint16(12631), + 1108: uint16(12802), + 1109: uint16(12633), + 1110: uint16(12637), + 1111: uint16(12800), + 1112: uint16(12634), + 1113: uint16(12829), + 1114: uint16(6472), + 1115: uint16(4624), + 1116: uint16(12632), + 1117: uint16(12804), + 1118: uint16(3925), + 1119: uint16(12803), + 1120: uint16(3844), + 1121: uint16(10281), + 1122: uint16(12801), + 1123: uint16(12635), + 1124: uint16(12630), + 1125: uint16(12636), + 1126: uint16(6439), + 1127: uint16(12805), + 1128: uint16(3926), + 1129: uint16(12814), + 1130: uint16(12806), + 1131: uint16(12807), + 1132: uint16(7428), + 1133: uint16(10824), + 1134: uint16(12812), + 1135: uint16(12811), + 1136: uint16(9230), + 1137: uint16(12813), + 1138: uint16(12810), + 1139: uint16(4115), + 1140: uint16(6421), + 1141: uint16(7695), + 1142: uint16(12808), + 1143: uint16(9281), + 1144: uint16(12809), + 1145: uint16(3841), + 1146: uint16(12819), + 1147: uint16(11266), + 1148: uint16(7430), + 1149: uint16(12825), + 1150: uint16(12824), + 1151: uint16(12815), + 1152: uint16(8482), + 1153: uint16(12816), + 1154: uint16(8526), + 1155: uint16(12821), + 1156: uint16(7429), + 1157: uint16(12818), + 1158: uint16(11075), + 1159: uint16(5659), + 1160: uint16(12822), + 1161: uint16(12823), + 1162: uint16(12820), + 1163: uint16(12826), + 1164: uint16(12817), + 1165: uint16(12832), + 1166: uint16(12837), + 1167: uint16(12833), + 1168: uint16(12828), + 1169: uint16(12838), + 1170: uint16(8208), + 1171: uint16(12840), + 1172: uint16(6145), + 1173: uint16(12830), + 1174: uint16(8796), + 1175: uint16(12834), + 1176: uint16(12827), + 1177: uint16(4876), + 1178: uint16(4941), + 1179: uint16(4676), + 1180: uint16(12835), + 1181: uint16(12831), + 1182: uint16(5717), + 1183: uint16(12841), + 1184: uint16(12839), + 1185: uint16(8242), + 1186: uint16(5161), + 1187: uint16(5387), + 1188: uint16(12836), + 1189: uint16(5459), + 1190: uint16(4131), + 1191: uint16(12845), + 1192: uint16(12843), + 1193: uint16(13062), + 1194: uint16(12848), + 1195: uint16(12842), + 1196: uint16(12846), + 1197: uint16(12844), + 1198: uint16(6699), + 1199: uint16(12847), + 1200: uint16(12850), + 1201: uint16(12855), + 1202: uint16(12853), + 1203: uint16(12852), + 1204: uint16(8721), + 1205: uint16(4388), + 1206: uint16(12849), + 1207: uint16(12851), + 1208: uint16(7431), + 1209: uint16(4114), + 1210: uint16(12854), + 1211: uint16(4413), + 1212: uint16(12865), + 1213: uint16(7515), + 1214: uint16(12861), + 1215: uint16(12859), + 1216: uint16(12860), + 1217: uint16(12862), + 1218: uint16(4124), + 1219: uint16(8216), + 1220: uint16(12856), + 1221: uint16(12857), + 1222: uint16(4697), + 1223: uint16(12864), + 1224: uint16(4942), + 1225: uint16(12867), + 1226: uint16(12863), + 1227: uint16(12866), + 1228: uint16(10509), + 1229: uint16(9524), + 1230: uint16(10007), + 1231: uint16(12869), + 1232: uint16(12868), + 1233: uint16(4644), + 1234: uint16(12870), + 1235: uint16(12873), + 1236: uint16(12872), + 1237: uint16(12871), + 1238: uint16(9752), + 1239: uint16(12874), + 1240: uint16(12875), + 1241: uint16(12877), + 1242: uint16(12876), + 1243: uint16(12879), + 1244: uint16(12882), + 1245: uint16(12880), + 1246: uint16(12878), + 1247: uint16(12881), + 1248: uint16(12883), + 1249: uint16(12884), + 1250: uint16(12885), + 1251: uint16(12886), + 1252: uint16(12887), + 1253: uint16(12324), + 1254: uint16(7003), + 1255: uint16(6700), + 1256: uint16(4434), + 1257: uint16(3927), + 1258: uint16(8739), + 1259: uint16(12888), + 1260: uint16(6403), + 1261: uint16(3886), + 1262: uint16(7741), + 1263: uint16(12889), + 1264: uint16(5926), + 1265: uint16(6224), + 1266: uint16(12891), + 1267: uint16(12890), + 1268: uint16(10559), + 1269: uint16(12892), + 1270: uint16(13056), + 1271: uint16(12893), + 1272: uint16(13057), + 1273: uint16(13058), + 1274: uint16(5718), + 1275: uint16(4159), + 1276: uint16(13059), + 1277: uint16(13061), + 1278: uint16(13060), + 1279: uint16(13063), + 1280: uint16(9273), + 1281: uint16(13064), + 1282: uint16(3860), + 1283: uint16(6462), + 1284: uint16(5660), + 1285: uint16(8750), + 1286: uint16(13065), + 1287: uint16(13066), + 1288: uint16(13068), + 1289: uint16(13069), + 1290: uint16(6467), + 1291: uint16(5424), + 1292: uint16(10774), + 1293: uint16(13067), + 1294: uint16(13070), + 1295: uint16(6432), + 1296: uint16(6146), + 1297: uint16(13074), + 1298: uint16(6404), + 1299: uint16(8722), + 1300: uint16(13071), + 1301: uint16(9017), + 1302: uint16(13075), + 1303: uint16(7745), + 1304: uint16(13073), + 1305: uint16(13076), + 1306: uint16(5662), + 1307: uint16(13077), + 1308: uint16(13078), + 1309: uint16(6147), + 1310: uint16(4639), + 1311: uint16(13080), + 1312: uint16(13081), + 1313: uint16(13082), + 1314: uint16(13079), + 1315: uint16(13072), + 1316: uint16(13083), + 1317: uint16(13084), + 1318: uint16(10819), + 1319: uint16(7498), + 1320: uint16(13086), + 1321: uint16(13087), + 1322: uint16(13085), + 1323: uint16(13089), + 1324: uint16(9751), + 1325: uint16(3911), + 1326: uint16(10293), + 1327: uint16(13090), + 1328: uint16(7516), + 1329: uint16(6936), + 1330: uint16(9788), + 1331: uint16(4943), + 1332: uint16(6474), + 1333: uint16(10808), + 1334: uint16(9489), + 1335: uint16(5719), + 1336: uint16(8494), + 1337: uint16(13088), + 1338: uint16(13091), + 1339: uint16(8483), + 1340: uint16(13092), + 1341: uint16(13093), + 1342: uint16(13095), + 1343: uint16(9032), + 1344: uint16(4877), + 1345: uint16(21248), + 1346: uint16(4160), + 1347: uint16(10578), + 1348: uint16(7499), + 1349: uint16(9255), + 1350: uint16(6469), + 1351: uint16(13101), + 1352: uint16(10524), + 1353: uint16(11580), + 1354: uint16(4435), + 1355: uint16(13097), + 1356: uint16(8217), + 1357: uint16(13100), + 1358: uint16(9282), + 1359: uint16(9256), + 1360: uint16(9283), + 1361: uint16(10008), + 1362: uint16(9004), + 1363: uint16(6440), + 1364: uint16(13096), + 1365: uint16(4181), + 1366: uint16(9237), + 1367: uint16(13098), + 1368: uint16(13094), + 1369: uint16(7727), + 1370: uint16(13102), + 1371: uint16(7213), + 1372: uint16(5388), + 1373: uint16(13103), + 1374: uint16(10567), + 1375: uint16(8284), + 1376: uint16(8997), + 1377: uint16(13105), + 1378: uint16(10798), + 1379: uint16(13106), + 1380: uint16(13111), + 1381: uint16(10510), + 1382: uint16(13110), + 1383: uint16(13104), + 1384: uint16(13107), + 1385: uint16(13109), + 1386: uint16(6405), + 1387: uint16(10536), + 1388: uint16(13112), + 1389: uint16(8740), + 1390: uint16(4436), + 1391: uint16(7500), + 1392: uint16(13114), + 1393: uint16(13113), + 1394: uint16(6215), + 1395: uint16(13115), + 1396: uint16(13117), + 1397: uint16(13116), + 1398: uint16(13119), + 1399: uint16(13108), + 1400: uint16(13121), + 1401: uint16(13120), + 1402: uint16(13118), + 1403: uint16(6701), + 1404: uint16(7728), + 1405: uint16(8243), + 1406: uint16(13122), + 1407: uint16(7963), + 1408: uint16(3916), + 1409: uint16(9795), + 1410: uint16(9018), + 1411: uint16(13124), + 1412: uint16(13123), + 1413: uint16(13125), + 1414: uint16(13126), + 1415: uint16(13127), + 1416: uint16(13128), + 1417: uint16(10544), + 1418: uint16(13129), + 1419: uint16(4389), + 1420: uint16(13130), + 1421: uint16(11291), + 1422: uint16(4623), + 1423: uint16(12584), + 1424: uint16(7207), + 1425: uint16(8478), + 1426: uint16(13131), + 1427: uint16(11082), + 1428: uint16(11027), + 1429: uint16(13133), + 1430: uint16(8518), + 1431: uint16(9238), + 1432: uint16(8479), + 1433: uint16(10294), + 1434: uint16(13134), + 1435: uint16(13135), + 1436: uint16(4186), + 1437: uint16(6937), + 1438: uint16(13136), + 1439: uint16(3887), + 1440: uint16(13137), + 1441: uint16(13138), + 1442: uint16(4161), + 1443: uint16(4944), + 1444: uint16(9535), + 1445: uint16(10579), + 1446: uint16(13142), + 1447: uint16(8244), + 1448: uint16(13141), + 1449: uint16(5663), + 1450: uint16(10810), + 1451: uint16(13140), + 1452: uint16(9284), + 1453: uint16(13144), + 1454: uint16(13143), + 1455: uint16(13146), + 1456: uint16(13145), + 1457: uint16(4187), + 1458: uint16(13147), + 1459: uint16(7432), + 1460: uint16(13149), + 1461: uint16(8708), + 1462: uint16(13148), + 1463: uint16(10514), + 1464: uint16(7254), + 1465: uint16(9274), + 1466: uint16(13312), + 1467: uint16(6148), + 1468: uint16(13313), + 1469: uint16(9728), + 1470: uint16(10045), + 1471: uint16(11056), + 1472: uint16(9732), + 1473: uint16(13322), + 1474: uint16(5143), + 1475: uint16(11300), + 1476: uint16(11022), + 1477: uint16(13579), + 1478: uint16(13314), + 1479: uint16(13317), + 1480: uint16(8484), + 1481: uint16(10775), + 1482: uint16(9257), + 1483: uint16(13318), + 1484: uint16(10820), + 1485: uint16(6441), + 1486: uint16(7433), + 1487: uint16(13319), + 1488: uint16(6703), + 1489: uint16(6702), + 1490: uint16(3864), + 1491: uint16(5927), + 1492: uint16(7946), + 1493: uint16(3888), + 1494: uint16(13323), + 1495: uint16(13324), + 1496: uint16(13321), + 1497: uint16(4119), + 1498: uint16(4878), + 1499: uint16(13320), + 1500: uint16(11044), + 1501: uint16(10256), + 1502: uint16(3847), + 1503: uint16(3928), + 1504: uint16(6704), + 1505: uint16(3889), + 1506: uint16(3842), + 1507: uint16(13329), + 1508: uint16(13327), + 1509: uint16(11035), + 1510: uint16(13330), + 1511: uint16(13328), + 1512: uint16(13326), + 1513: uint16(7696), + 1514: uint16(13325), + 1515: uint16(10553), + 1516: uint16(5955), + 1517: uint16(13334), + 1518: uint16(13335), + 1519: uint16(7434), + 1520: uint16(13331), + 1521: uint16(11787), + 1522: uint16(9771), + 1523: uint16(13333), + 1524: uint16(6406), + 1525: uint16(13336), + 1526: uint16(10295), + 1527: uint16(13337), + 1528: uint16(13332), + 1529: uint16(11034), + 1530: uint16(9789), + 1531: uint16(13338), + 1532: uint16(10257), + 1533: uint16(13339), + 1534: uint16(13343), + 1535: uint16(13340), + 1536: uint16(4390), + 1537: uint16(13342), + 1538: uint16(6938), + 1539: uint16(13341), + 1540: uint16(5720), + 1541: uint16(13355), + 1542: uint16(13348), + 1543: uint16(13345), + 1544: uint16(8771), + 1545: uint16(13344), + 1546: uint16(13346), + 1547: uint16(13347), + 1548: uint16(13349), + 1549: uint16(13350), + 1550: uint16(4945), + 1551: uint16(13352), + 1552: uint16(13351), + 1553: uint16(13353), + 1554: uint16(7501), + 1555: uint16(13356), + 1556: uint16(9019), + 1557: uint16(4132), + 1558: uint16(13354), + 1559: uint16(13357), + 1560: uint16(13358), + 1561: uint16(13361), + 1562: uint16(13359), + 1563: uint16(13360), + 1564: uint16(6705), + 1565: uint16(13362), + 1566: uint16(6149), + 1567: uint16(13363), + 1568: uint16(6745), + 1569: uint16(8471), + 1570: uint16(13364), + 1571: uint16(13365), + 1572: uint16(6713), + 1573: uint16(6150), + 1574: uint16(11057), + 1575: uint16(5127), + 1576: uint16(5928), + 1577: uint16(13366), + 1578: uint16(4663), + 1579: uint16(13367), + 1580: uint16(8472), + 1581: uint16(13368), + 1582: uint16(13570), + 1583: uint16(13369), + 1584: uint16(13370), + 1585: uint16(13371), + 1586: uint16(13373), + 1587: uint16(13374), + 1588: uint16(13375), + 1589: uint16(8527), + 1590: uint16(4102), + 1591: uint16(6984), + 1592: uint16(3873), + 1593: uint16(8246), + 1594: uint16(4879), + 1595: uint16(6932), + 1596: uint16(6151), + 1597: uint16(9285), + 1598: uint16(7168), + 1599: uint16(4880), + 1600: uint16(8775), + 1601: uint16(9033), + 1602: uint16(3863), + 1603: uint16(5144), + 1604: uint16(10580), + 1605: uint16(6945), + 1606: uint16(5169), + 1607: uint16(8010), + 1608: uint16(6939), + 1609: uint16(11271), + 1610: uint16(13376), + 1611: uint16(5179), + 1612: uint16(6442), + 1613: uint16(4625), + 1614: uint16(4162), + 1615: uint16(7435), + 1616: uint16(4391), + 1617: uint16(13377), + 1618: uint16(11301), + 1619: uint16(7208), + 1620: uint16(6979), + 1621: uint16(13378), + 1622: uint16(4946), + 1623: uint16(9521), + 1624: uint16(11016), + 1625: uint16(13379), + 1626: uint16(13380), + 1627: uint16(10296), + 1628: uint16(13382), + 1629: uint16(4871), + 1630: uint16(5462), + 1631: uint16(13381), + 1632: uint16(4881), + 1633: uint16(7697), + 1634: uint16(13386), + 1635: uint16(6656), + 1636: uint16(4392), + 1637: uint16(13385), + 1638: uint16(13383), + 1639: uint16(13387), + 1640: uint16(13384), + 1641: uint16(9738), + 1642: uint16(15148), + 1643: uint16(7698), + 1644: uint16(13388), + 1645: uint16(11551), + 1646: uint16(13389), + 1647: uint16(13391), + 1648: uint16(8797), + 1649: uint16(13390), + 1650: uint16(7938), + 1651: uint16(6746), + 1652: uint16(8495), + 1653: uint16(6998), + 1654: uint16(10324), + 1655: uint16(8011), + 1656: uint16(6956), + 1657: uint16(13392), + 1658: uint16(7436), + 1659: uint16(13393), + 1660: uint16(13394), + 1661: uint16(3890), + 1662: uint16(8473), + 1663: uint16(7729), + 1664: uint16(13395), + 1665: uint16(9490), + 1666: uint16(7437), + 1667: uint16(7438), + 1668: uint16(13396), + 1669: uint16(8012), + 1670: uint16(7439), + 1671: uint16(13397), + 1672: uint16(13398), + 1673: uint16(11071), + 1674: uint16(13399), + 1675: uint16(5413), + 1676: uint16(7169), + 1677: uint16(13400), + 1678: uint16(13401), + 1679: uint16(6971), + 1680: uint16(7691), + 1681: uint16(9555), + 1682: uint16(7731), + 1683: uint16(10071), + 1684: uint16(9729), + 1685: uint16(5416), + 1686: uint16(13402), + 1687: uint16(5198), + 1688: uint16(13403), + 1689: uint16(5469), + 1690: uint16(9518), + 1691: uint16(4367), + 1692: uint16(6706), + 1693: uint16(13404), + 1694: uint16(13569), + 1695: uint16(13568), + 1696: uint16(5468), + 1697: uint16(13405), + 1698: uint16(9239), + 1699: uint16(8463), + 1700: uint16(9258), + 1701: uint16(6951), + 1702: uint16(8247), + 1703: uint16(11353), + 1704: uint16(13571), + 1705: uint16(13572), + 1706: uint16(9525), + 1707: uint16(6674), + 1708: uint16(13574), + 1709: uint16(13575), + 1710: uint16(13576), + 1711: uint16(4947), + 1712: uint16(13577), + 1713: uint16(13578), + 1714: uint16(4363), + 1715: uint16(8218), + 1716: uint16(4931), + 1717: uint16(13580), + 1718: uint16(11015), + 1719: uint16(8497), + 1720: uint16(4664), + 1721: uint16(13582), + 1722: uint16(13584), + 1723: uint16(4926), + 1724: uint16(13581), + 1725: uint16(13583), + 1726: uint16(13586), + 1727: uint16(13585), + 1728: uint16(13587), + 1729: uint16(13588), + 1730: uint16(9500), + 1731: uint16(5389), + 1732: uint16(4420), + 1733: uint16(13589), + 1734: uint16(13594), + 1735: uint16(13592), + 1736: uint16(10582), + 1737: uint16(10581), + 1738: uint16(9286), + 1739: uint16(13591), + 1740: uint16(7219), + 1741: uint16(13590), + 1742: uint16(7761), + 1743: uint16(13595), + 1744: uint16(6473), + 1745: uint16(13601), + 1746: uint16(13602), + 1747: uint16(13596), + 1748: uint16(4626), + 1749: uint16(13597), + 1750: uint16(13606), + 1751: uint16(13605), + 1752: uint16(13604), + 1753: uint16(13600), + 1754: uint16(13599), + 1755: uint16(13603), + 1756: uint16(10583), + 1757: uint16(13610), + 1758: uint16(13607), + 1759: uint16(13609), + 1760: uint16(11345), + 1761: uint16(13608), + 1762: uint16(13598), + 1763: uint16(7762), + 1764: uint16(13611), + 1765: uint16(6422), + 1766: uint16(13612), + 1767: uint16(13613), + 1768: uint16(13616), + 1769: uint16(13615), + 1770: uint16(13614), + 1771: uint16(9287), + 1772: uint16(13593), + 1773: uint16(13622), + 1774: uint16(13618), + 1775: uint16(13617), + 1776: uint16(13619), + 1777: uint16(13620), + 1778: uint16(13623), + 1779: uint16(11589), + 1780: uint16(13624), + 1781: uint16(13621), + 1782: uint16(13625), + 1783: uint16(4927), + 1784: uint16(13626), + 1785: uint16(13628), + 1786: uint16(13627), + 1787: uint16(13629), + 1788: uint16(13630), + 1789: uint16(8013), + 1790: uint16(7170), + 1791: uint16(7235), + 1792: uint16(8258), + 1793: uint16(6152), + 1794: uint16(6423), + 1795: uint16(6153), + 1796: uint16(5199), + 1797: uint16(13631), + 1798: uint16(6424), + 1799: uint16(5929), + 1800: uint16(13632), + 1801: uint16(11013), + 1802: uint16(9762), + 1803: uint16(13633), + 1804: uint16(6154), + 1805: uint16(4875), + 1806: uint16(8710), + 1807: uint16(5425), + 1808: uint16(6707), + 1809: uint16(10298), + 1810: uint16(10016), + 1811: uint16(13634), + 1812: uint16(4948), + 1813: uint16(13637), + 1814: uint16(8960), + 1815: uint16(13636), + 1816: uint16(13635), + 1817: uint16(13638), + 1818: uint16(9034), + 1819: uint16(7746), + 1820: uint16(6708), + 1821: uint16(7977), + 1822: uint16(8498), + 1823: uint16(5121), + 1824: uint16(8961), + 1825: uint16(13639), + 1826: uint16(13640), + 1827: uint16(7502), + 1828: uint16(10776), + 1829: uint16(13643), + 1830: uint16(13642), + 1831: uint16(13641), + 1832: uint16(10332), + 1833: uint16(13650), + 1834: uint16(10809), + 1835: uint16(13644), + 1836: uint16(13646), + 1837: uint16(10826), + 1838: uint16(13645), + 1839: uint16(13647), + 1840: uint16(9991), + 1841: uint16(13648), + 1842: uint16(10525), + 1843: uint16(13649), + 1844: uint16(4882), + 1845: uint16(10526), + 1846: uint16(9742), + 1847: uint16(13651), + 1848: uint16(13652), + 1849: uint16(6155), + 1850: uint16(4883), + 1851: uint16(13653), + 1852: uint16(5911), + 1853: uint16(11299), + 1854: uint16(11272), + 1855: uint16(4949), + 1856: uint16(13655), + 1857: uint16(8962), + 1858: uint16(6156), + 1859: uint16(7440), + 1860: uint16(10046), + 1861: uint16(7441), + 1862: uint16(7255), + 1863: uint16(9035), + 1864: uint16(10584), + 1865: uint16(9240), + 1866: uint16(6157), + 1867: uint16(10299), + 1868: uint16(13656), + 1869: uint16(9272), + 1870: uint16(6433), + 1871: uint16(5930), + 1872: uint16(9036), + 1873: uint16(3874), + 1874: uint16(7245), + 1875: uint16(6158), + 1876: uint16(11302), + 1877: uint16(13657), + 1878: uint16(13658), + 1879: uint16(9776), + 1880: uint16(13659), + 1881: uint16(11606), + 1882: uint16(11788), + 1883: uint16(13661), + 1884: uint16(13660), + 1885: uint16(4646), + 1886: uint16(13824), + 1887: uint16(13827), + 1888: uint16(13828), + 1889: uint16(13826), + 1890: uint16(10271), + 1891: uint16(7442), + 1892: uint16(13830), + 1893: uint16(13829), + 1894: uint16(13825), + 1895: uint16(13831), + 1896: uint16(13832), + 1897: uint16(13833), + 1898: uint16(13836), + 1899: uint16(13834), + 1900: uint16(13835), + 1901: uint16(13837), + 1902: uint16(4163), + 1903: uint16(9037), + 1904: uint16(13838), + 1905: uint16(5721), + 1906: uint16(4437), + 1907: uint16(9749), + 1908: uint16(13839), + 1909: uint16(9562), + 1910: uint16(10554), + 1911: uint16(13840), + 1912: uint16(11789), + 1913: uint16(13841), + 1914: uint16(10527), + 1915: uint16(13844), + 1916: uint16(12032), + 1917: uint16(12048), + 1918: uint16(6927), + 1919: uint16(9556), + 1920: uint16(13845), + 1921: uint16(5180), + 1922: uint16(8963), + 1923: uint16(3929), + 1924: uint16(13846), + 1925: uint16(10501), + 1926: uint16(6159), + 1927: uint16(8751), + 1928: uint16(9038), + 1929: uint16(11086), + 1930: uint16(5912), + 1931: uint16(5931), + 1932: uint16(13847), + 1933: uint16(13848), + 1934: uint16(13854), + 1935: uint16(6980), + 1936: uint16(8964), + 1937: uint16(5390), + 1938: uint16(13849), + 1939: uint16(10250), + 1940: uint16(8741), + 1941: uint16(13850), + 1942: uint16(13851), + 1943: uint16(5391), + 1944: uint16(13852), + 1945: uint16(13853), + 1946: uint16(13855), + 1947: uint16(9301), + 1948: uint16(13856), + 1949: uint16(13857), + 1950: uint16(13858), + 1951: uint16(13843), + 1952: uint16(13842), + 1953: uint16(13859), + 1954: uint16(5664), + 1955: uint16(10246), + 1956: uint16(6443), + 1957: uint16(10262), + 1958: uint16(8965), + 1959: uint16(10282), + 1960: uint16(13860), + 1961: uint16(7443), + 1962: uint16(4133), + 1963: uint16(13861), + 1964: uint16(13862), + 1965: uint16(11089), + 1966: uint16(10047), + 1967: uint16(13865), + 1968: uint16(4188), + 1969: uint16(7947), + 1970: uint16(13864), + 1971: uint16(13863), + 1972: uint16(5665), + 1973: uint16(8499), + 1974: uint16(13869), + 1975: uint16(13867), + 1976: uint16(13866), + 1977: uint16(11526), + 1978: uint16(5956), + 1979: uint16(7256), + 1980: uint16(13868), + 1981: uint16(9259), + 1982: uint16(7197), + 1983: uint16(9503), + 1984: uint16(13872), + 1985: uint16(13871), + 1986: uint16(13870), + 1987: uint16(13873), + 1988: uint16(5957), + 1989: uint16(13874), + 1990: uint16(10331), + 1991: uint16(7226), + 1992: uint16(13875), + 1993: uint16(10072), + 1994: uint16(9504), + 1995: uint16(8966), + 1996: uint16(9231), + 1997: uint16(13876), + 1998: uint16(5130), + 1999: uint16(7699), + 2000: uint16(10251), + 2001: uint16(4950), + 2002: uint16(9733), + 2003: uint16(13877), + 2004: uint16(6709), + 2005: uint16(10777), + 2006: uint16(10778), + 2007: uint16(4189), + 2008: uint16(13882), + 2009: uint16(8776), + 2010: uint16(13879), + 2011: uint16(4438), + 2012: uint16(14092), + 2013: uint16(13881), + 2014: uint16(9743), + 2015: uint16(13880), + 2016: uint16(13878), + 2017: uint16(6233), + 2018: uint16(13884), + 2019: uint16(13890), + 2020: uint16(13896), + 2021: uint16(13888), + 2022: uint16(9275), + 2023: uint16(13893), + 2024: uint16(10300), + 2025: uint16(13887), + 2026: uint16(13892), + 2027: uint16(11590), + 2028: uint16(6710), + 2029: uint16(8500), + 2030: uint16(13885), + 2031: uint16(5181), + 2032: uint16(13895), + 2033: uint16(7948), + 2034: uint16(4164), + 2035: uint16(13889), + 2036: uint16(4439), + 2037: uint16(13894), + 2038: uint16(5392), + 2039: uint16(13891), + 2040: uint16(13897), + 2041: uint16(13899), + 2042: uint16(13909), + 2043: uint16(13907), + 2044: uint16(13904), + 2045: uint16(13903), + 2046: uint16(11607), + 2047: uint16(13905), + 2048: uint16(5393), + 2049: uint16(6160), + 2050: uint16(7257), + 2051: uint16(13912), + 2052: uint16(13898), + 2053: uint16(13902), + 2054: uint16(13886), + 2055: uint16(4441), + 2056: uint16(13906), + 2057: uint16(13908), + 2058: uint16(8752), + 2059: uint16(6407), + 2060: uint16(4375), + 2061: uint16(13900), + 2062: uint16(13911), + 2063: uint16(13910), + 2064: uint16(5394), + 2065: uint16(8456), + 2066: uint16(4677), + 2067: uint16(5666), + 2068: uint16(13901), + 2069: uint16(13913), + 2070: uint16(13916), + 2071: uint16(14080), + 2072: uint16(6940), + 2073: uint16(14086), + 2074: uint16(9039), + 2075: uint16(13914), + 2076: uint16(14084), + 2077: uint16(4440), + 2078: uint16(14082), + 2079: uint16(14083), + 2080: uint16(13917), + 2081: uint16(14081), + 2082: uint16(5958), + 2083: uint16(11273), + 2084: uint16(4884), + 2085: uint16(4152), + 2086: uint16(14085), + 2087: uint16(9753), + 2088: uint16(3852), + 2089: uint16(10048), + 2090: uint16(13883), + 2091: uint16(14091), + 2092: uint16(14095), + 2093: uint16(11076), + 2094: uint16(14088), + 2095: uint16(9288), + 2096: uint16(14093), + 2097: uint16(7503), + 2098: uint16(14094), + 2099: uint16(9526), + 2100: uint16(11814), + 2101: uint16(14090), + 2102: uint16(14096), + 2103: uint16(6234), + 2104: uint16(7978), + 2105: uint16(3891), + 2106: uint16(14089), + 2107: uint16(14087), + 2108: uint16(8249), + 2109: uint16(13915), + 2110: uint16(6675), + 2111: uint16(8485), + 2112: uint16(14108), + 2113: uint16(8250), + 2114: uint16(14103), + 2115: uint16(14100), + 2116: uint16(14101), + 2117: uint16(6981), + 2118: uint16(14104), + 2119: uint16(14107), + 2120: uint16(14102), + 2121: uint16(7172), + 2122: uint16(14105), + 2123: uint16(14099), + 2124: uint16(11099), + 2125: uint16(11098), + 2126: uint16(14109), + 2127: uint16(14110), + 2128: uint16(3892), + 2129: uint16(14098), + 2130: uint16(5457), + 2131: uint16(3845), + 2132: uint16(4885), + 2133: uint16(14106), + 2134: uint16(14114), + 2135: uint16(14113), + 2136: uint16(14118), + 2137: uint16(14119), + 2138: uint16(14117), + 2139: uint16(14120), + 2140: uint16(14112), + 2141: uint16(14116), + 2142: uint16(14121), + 2143: uint16(14122), + 2144: uint16(14111), + 2145: uint16(6747), + 2146: uint16(14115), + 2147: uint16(8501), + 2148: uint16(6161), + 2149: uint16(14097), + 2150: uint16(7700), + 2151: uint16(14135), + 2152: uint16(10568), + 2153: uint16(14125), + 2154: uint16(14126), + 2155: uint16(14127), + 2156: uint16(14134), + 2157: uint16(14133), + 2158: uint16(10844), + 2159: uint16(4886), + 2160: uint16(14131), + 2161: uint16(5668), + 2162: uint16(4627), + 2163: uint16(14128), + 2164: uint16(11543), + 2165: uint16(14130), + 2166: uint16(3893), + 2167: uint16(14132), + 2168: uint16(14123), + 2169: uint16(14129), + 2170: uint16(14136), + 2171: uint16(5667), + 2172: uint16(14124), + 2173: uint16(11324), + 2174: uint16(11274), + 2175: uint16(14139), + 2176: uint16(14143), + 2177: uint16(8285), + 2178: uint16(11608), + 2179: uint16(14144), + 2180: uint16(14141), + 2181: uint16(14138), + 2182: uint16(14137), + 2183: uint16(14142), + 2184: uint16(10511), + 2185: uint16(9491), + 2186: uint16(5669), + 2187: uint16(14145), + 2188: uint16(14140), + 2189: uint16(14146), + 2190: uint16(5722), + 2191: uint16(4368), + 2192: uint16(14154), + 2193: uint16(4887), + 2194: uint16(14152), + 2195: uint16(14153), + 2196: uint16(6408), + 2197: uint16(14151), + 2198: uint16(14149), + 2199: uint16(14148), + 2200: uint16(14155), + 2201: uint16(14147), + 2202: uint16(14157), + 2203: uint16(4442), + 2204: uint16(14159), + 2205: uint16(14158), + 2206: uint16(8967), + 2207: uint16(14162), + 2208: uint16(14160), + 2209: uint16(14150), + 2210: uint16(5723), + 2211: uint16(14161), + 2212: uint16(14165), + 2213: uint16(14164), + 2214: uint16(14166), + 2215: uint16(14163), + 2216: uint16(14167), + 2217: uint16(14168), + 2218: uint16(14169), + 2219: uint16(10569), + 2220: uint16(14171), + 2221: uint16(14170), + 2222: uint16(7198), + 2223: uint16(7949), + 2224: uint16(4421), + 2225: uint16(4443), + 2226: uint16(14172), + 2227: uint16(3870), + 2228: uint16(7979), + 2229: uint16(14173), + 2230: uint16(19234), + 2231: uint16(14336), + 2232: uint16(5696), + 2233: uint16(14337), + 2234: uint16(8014), + 2235: uint16(14338), + 2236: uint16(14339), + 2237: uint16(5145), + 2238: uint16(14340), + 2239: uint16(14341), + 2240: uint16(14342), + 2241: uint16(8502), + 2242: uint16(5932), + 2243: uint16(11072), + 2244: uint16(10779), + 2245: uint16(7241), + 2246: uint16(14343), + 2247: uint16(8015), + 2248: uint16(19740), + 2249: uint16(10049), + 2250: uint16(6985), + 2251: uint16(6444), + 2252: uint16(14344), + 2253: uint16(8486), + 2254: uint16(10502), + 2255: uint16(8528), + 2256: uint16(14347), + 2257: uint16(14345), + 2258: uint16(14348), + 2259: uint16(14346), + 2260: uint16(14349), + 2261: uint16(10512), + 2262: uint16(3862), + 2263: uint16(10301), + 2264: uint16(10050), + 2265: uint16(14350), + 2266: uint16(14353), + 2267: uint16(7444), + 2268: uint16(5146), + 2269: uint16(14351), + 2270: uint16(14358), + 2271: uint16(7445), + 2272: uint16(14352), + 2273: uint16(9763), + 2274: uint16(11325), + 2275: uint16(14354), + 2276: uint16(14355), + 2277: uint16(14359), + 2278: uint16(9289), + 2279: uint16(14356), + 2280: uint16(6162), + 2281: uint16(7997), + 2282: uint16(14373), + 2283: uint16(10003), + 2284: uint16(8529), + 2285: uint16(10051), + 2286: uint16(14604), + 2287: uint16(10585), + 2288: uint16(9040), + 2289: uint16(10836), + 2290: uint16(14362), + 2291: uint16(4352), + 2292: uint16(8777), + 2293: uint16(14371), + 2294: uint16(8723), + 2295: uint16(14365), + 2296: uint16(14372), + 2297: uint16(14367), + 2298: uint16(14374), + 2299: uint16(14370), + 2300: uint16(14369), + 2301: uint16(9806), + 2302: uint16(14363), + 2303: uint16(4444), + 2304: uint16(14361), + 2305: uint16(5200), + 2306: uint16(8530), + 2307: uint16(14357), + 2308: uint16(14360), + 2309: uint16(6163), + 2310: uint16(7994), + 2311: uint16(7446), + 2312: uint16(14368), + 2313: uint16(9777), + 2314: uint16(5201), + 2315: uint16(4647), + 2316: uint16(4678), + 2317: uint16(7680), + 2318: uint16(14376), + 2319: uint16(14381), + 2320: uint16(14377), + 2321: uint16(5724), + 2322: uint16(14382), + 2323: uint16(6657), + 2324: uint16(6216), + 2325: uint16(7173), + 2326: uint16(14364), + 2327: uint16(6748), + 2328: uint16(14379), + 2329: uint16(6711), + 2330: uint16(14380), + 2331: uint16(3875), + 2332: uint16(14375), + 2333: uint16(8968), + 2334: uint16(5202), + 2335: uint16(5395), + 2336: uint16(14378), + 2337: uint16(3846), + 2338: uint16(6434), + 2339: uint16(7701), + 2340: uint16(9041), + 2341: uint16(10035), + 2342: uint16(14384), + 2343: uint16(8253), + 2344: uint16(8457), + 2345: uint16(6666), + 2346: uint16(14385), + 2347: uint16(14387), + 2348: uint16(14383), + 2349: uint16(10560), + 2350: uint16(8988), + 2351: uint16(8251), + 2352: uint16(10586), + 2353: uint16(6957), + 2354: uint16(14399), + 2355: uint16(14398), + 2356: uint16(7767), + 2357: uint16(5725), + 2358: uint16(14392), + 2359: uint16(7448), + 2360: uint16(9543), + 2361: uint16(9744), + 2362: uint16(14390), + 2363: uint16(8252), + 2364: uint16(6999), + 2365: uint16(14395), + 2366: uint16(7447), + 2367: uint16(14389), + 2368: uint16(14394), + 2369: uint16(9778), + 2370: uint16(14388), + 2371: uint16(5632), + 2372: uint16(4668), + 2373: uint16(14396), + 2374: uint16(11530), + 2375: uint16(6445), + 2376: uint16(8724), + 2377: uint16(14393), + 2378: uint16(7995), + 2379: uint16(6164), + 2380: uint16(7747), + 2381: uint16(4165), + 2382: uint16(8219), + 2383: uint16(14391), + 2384: uint16(5156), + 2385: uint16(5670), + 2386: uint16(9006), + 2387: uint16(14397), + 2388: uint16(8254), + 2389: uint16(14400), + 2390: uint16(14402), + 2391: uint16(8470), + 2392: uint16(14408), + 2393: uint16(14403), + 2394: uint16(14405), + 2395: uint16(10272), + 2396: uint16(9042), + 2397: uint16(14406), + 2398: uint16(11275), + 2399: uint16(11303), + 2400: uint16(4888), + 2401: uint16(3853), + 2402: uint16(14404), + 2403: uint16(14401), + 2404: uint16(4951), + 2405: uint16(4166), + 2406: uint16(14407), + 2407: uint16(11304), + 2408: uint16(14411), + 2409: uint16(8474), + 2410: uint16(14418), + 2411: uint16(14412), + 2412: uint16(14409), + 2413: uint16(14416), + 2414: uint16(14386), + 2415: uint16(14413), + 2416: uint16(14417), + 2417: uint16(10017), + 2418: uint16(9290), + 2419: uint16(14410), + 2420: uint16(14414), + 2421: uint16(5671), + 2422: uint16(6480), + 2423: uint16(7996), + 2424: uint16(14422), + 2425: uint16(9221), + 2426: uint16(14419), + 2427: uint16(10815), + 2428: uint16(14420), + 2429: uint16(14421), + 2430: uint16(11053), + 2431: uint16(7937), + 2432: uint16(5697), + 2433: uint16(14428), + 2434: uint16(6676), + 2435: uint16(14425), + 2436: uint16(14424), + 2437: uint16(9745), + 2438: uint16(9492), + 2439: uint16(9232), + 2440: uint16(14426), + 2441: uint16(14427), + 2442: uint16(10318), + 2443: uint16(9764), + 2444: uint16(6658), + 2445: uint16(8016), + 2446: uint16(10799), + 2447: uint16(4648), + 2448: uint16(14596), + 2449: uint16(14429), + 2450: uint16(11305), + 2451: uint16(14598), + 2452: uint16(14594), + 2453: uint16(14595), + 2454: uint16(8255), + 2455: uint16(14593), + 2456: uint16(14366), + 2457: uint16(14597), + 2458: uint16(14592), + 2459: uint16(14602), + 2460: uint16(14603), + 2461: uint16(9222), + 2462: uint16(14605), + 2463: uint16(6659), + 2464: uint16(14600), + 2465: uint16(5147), + 2466: uint16(14606), + 2467: uint16(14599), + 2468: uint16(14610), + 2469: uint16(14609), + 2470: uint16(14608), + 2471: uint16(14611), + 2472: uint16(14613), + 2473: uint16(7504), + 2474: uint16(14612), + 2475: uint16(14616), + 2476: uint16(14614), + 2477: uint16(14615), + 2478: uint16(14415), + 2479: uint16(14618), + 2480: uint16(14617), + 2481: uint16(14423), + 2482: uint16(14619), + 2483: uint16(14607), + 2484: uint16(6712), + 2485: uint16(14620), + 2486: uint16(14621), + 2487: uint16(14623), + 2488: uint16(14622), + 2489: uint16(14624), + 2490: uint16(4445), + 2491: uint16(6165), + 2492: uint16(10587), + 2493: uint16(7950), + 2494: uint16(5933), + 2495: uint16(14626), + 2496: uint16(14629), + 2497: uint16(10289), + 2498: uint16(5182), + 2499: uint16(14628), + 2500: uint16(14627), + 2501: uint16(9779), + 2502: uint16(14630), + 2503: uint16(5396), + 2504: uint16(14632), + 2505: uint16(14631), + 2506: uint16(4889), + 2507: uint16(6677), + 2508: uint16(9527), + 2509: uint16(5672), + 2510: uint16(7763), + 2511: uint16(14633), + 2512: uint16(7951), + 2513: uint16(9223), + 2514: uint16(10302), + 2515: uint16(14634), + 2516: uint16(14635), + 2517: uint16(14636), + 2518: uint16(10519), + 2519: uint16(13372), + 2520: uint16(7973), + 2521: uint16(10283), + 2522: uint16(6455), + 2523: uint16(10052), + 2524: uint16(10018), + 2525: uint16(9260), + 2526: uint16(11552), + 2527: uint16(14638), + 2528: uint16(6959), + 2529: uint16(14639), + 2530: uint16(3861), + 2531: uint16(5427), + 2532: uint16(7980), + 2533: uint16(10303), + 2534: uint16(14640), + 2535: uint16(6689), + 2536: uint16(8742), + 2537: uint16(6714), + 2538: uint16(7702), + 2539: uint16(14641), + 2540: uint16(10588), + 2541: uint16(4182), + 2542: uint16(6715), + 2543: uint16(14644), + 2544: uint16(14642), + 2545: uint16(14645), + 2546: uint16(11544), + 2547: uint16(14643), + 2548: uint16(8026), + 2549: uint16(14646), + 2550: uint16(8465), + 2551: uint16(14647), + 2552: uint16(4953), + 2553: uint16(14649), + 2554: uint16(14648), + 2555: uint16(14650), + 2556: uint16(14651), + 2557: uint16(4954), + 2558: uint16(9563), + 2559: uint16(8725), + 2560: uint16(5195), + 2561: uint16(6716), + 2562: uint16(8256), + 2563: uint16(7227), + 2564: uint16(3855), + 2565: uint16(14652), + 2566: uint16(4353), + 2567: uint16(14656), + 2568: uint16(6166), + 2569: uint16(14655), + 2570: uint16(6410), + 2571: uint16(7449), + 2572: uint16(14654), + 2573: uint16(7450), + 2574: uint16(11039), + 2575: uint16(6409), + 2576: uint16(3894), + 2577: uint16(7981), + 2578: uint16(14661), + 2579: uint16(7952), + 2580: uint16(4134), + 2581: uint16(7220), + 2582: uint16(10821), + 2583: uint16(6481), + 2584: uint16(7451), + 2585: uint16(7942), + 2586: uint16(14660), + 2587: uint16(14658), + 2588: uint16(14659), + 2589: uint16(8778), + 2590: uint16(14853), + 2591: uint16(14665), + 2592: uint16(6749), + 2593: uint16(6167), + 2594: uint16(14663), + 2595: uint16(14664), + 2596: uint16(7703), + 2597: uint16(14662), + 2598: uint16(6670), + 2599: uint16(14667), + 2600: uint16(14666), + 2601: uint16(14671), + 2602: uint16(14672), + 2603: uint16(14668), + 2604: uint16(4609), + 2605: uint16(14669), + 2606: uint16(14670), + 2607: uint16(10036), + 2608: uint16(10304), + 2609: uint16(5673), + 2610: uint16(14673), + 2611: uint16(7953), + 2612: uint16(7452), + 2613: uint16(8753), + 2614: uint16(5414), + 2615: uint16(14674), + 2616: uint16(14678), + 2617: uint16(4394), + 2618: uint16(14675), + 2619: uint16(14677), + 2620: uint16(14676), + 2621: uint16(7242), + 2622: uint16(8743), + 2623: uint16(3876), + 2624: uint16(14679), + 2625: uint16(14680), + 2626: uint16(8969), + 2627: uint16(11600), + 2628: uint16(6690), + 2629: uint16(10570), + 2630: uint16(10780), + 2631: uint16(14849), + 2632: uint16(14682), + 2633: uint16(14685), + 2634: uint16(14684), + 2635: uint16(14681), + 2636: uint16(14848), + 2637: uint16(9533), + 2638: uint16(14683), + 2639: uint16(14850), + 2640: uint16(7243), + 2641: uint16(14851), + 2642: uint16(11306), + 2643: uint16(9815), + 2644: uint16(14852), + 2645: uint16(14854), + 2646: uint16(14855), + 2647: uint16(14856), + 2648: uint16(5417), + 2649: uint16(4135), + 2650: uint16(6168), + 2651: uint16(14857), + 2652: uint16(14858), + 2653: uint16(7248), + 2654: uint16(8257), + 2655: uint16(12599), + 2656: uint16(8221), + 2657: uint16(8220), + 2658: uint16(8503), + 2659: uint16(6438), + 2660: uint16(12113), + 2661: uint16(5709), + 2662: uint16(11276), + 2663: uint16(10589), + 2664: uint16(10333), + 2665: uint16(14859), + 2666: uint16(6482), + 2667: uint16(8990), + 2668: uint16(14860), + 2669: uint16(11790), + 2670: uint16(10781), + 2671: uint16(8970), + 2672: uint16(14861), + 2673: uint16(4955), + 2674: uint16(14862), + 2675: uint16(14863), + 2676: uint16(11065), + 2677: uint16(11011), + 2678: uint16(10837), + 2679: uint16(10811), + 2680: uint16(6660), + 2681: uint16(14865), + 2682: uint16(6986), + 2683: uint16(10800), + 2684: uint16(14867), + 2685: uint16(14870), + 2686: uint16(14869), + 2687: uint16(4952), + 2688: uint16(5183), + 2689: uint16(14866), + 2690: uint16(14868), + 2691: uint16(14871), + 2692: uint16(7768), + 2693: uint16(11354), + 2694: uint16(3880), + 2695: uint16(6463), + 2696: uint16(8475), + 2697: uint16(6972), + 2698: uint16(7506), + 2699: uint16(14874), + 2700: uint16(9261), + 2701: uint16(14872), + 2702: uint16(8458), + 2703: uint16(14873), + 2704: uint16(7505), + 2705: uint16(11068), + 2706: uint16(14875), + 2707: uint16(14876), + 2708: uint16(11335), + 2709: uint16(14881), + 2710: uint16(6169), + 2711: uint16(9780), + 2712: uint16(14878), + 2713: uint16(9291), + 2714: uint16(14653), + 2715: uint16(14657), + 2716: uint16(5166), + 2717: uint16(9766), + 2718: uint16(14880), + 2719: uint16(7453), + 2720: uint16(10019), + 2721: uint16(14886), + 2722: uint16(10073), + 2723: uint16(14877), + 2724: uint16(14883), + 2725: uint16(14882), + 2726: uint16(7982), + 2727: uint16(10828), + 2728: uint16(11570), + 2729: uint16(10822), + 2730: uint16(4395), + 2731: uint16(6717), + 2732: uint16(11815), + 2733: uint16(14885), + 2734: uint16(7764), + 2735: uint16(14884), + 2736: uint16(14879), + 2737: uint16(5934), + 2738: uint16(14891), + 2739: uint16(14889), + 2740: uint16(4396), + 2741: uint16(14887), + 2742: uint16(14893), + 2743: uint16(14899), + 2744: uint16(8487), + 2745: uint16(10528), + 2746: uint16(14901), + 2747: uint16(10241), + 2748: uint16(14900), + 2749: uint16(9807), + 2750: uint16(10782), + 2751: uint16(4890), + 2752: uint16(8022), + 2753: uint16(7199), + 2754: uint16(9010), + 2755: uint16(11277), + 2756: uint16(14896), + 2757: uint16(14895), + 2758: uint16(14897), + 2759: uint16(14894), + 2760: uint16(14902), + 2761: uint16(14892), + 2762: uint16(14890), + 2763: uint16(14898), + 2764: uint16(14888), + 2765: uint16(8779), + 2766: uint16(11095), + 2767: uint16(6949), + 2768: uint16(6483), + 2769: uint16(6425), + 2770: uint16(10830), + 2771: uint16(4640), + 2772: uint16(9005), + 2773: uint16(9513), + 2774: uint16(4136), + 2775: uint16(8017), + 2776: uint16(7955), + 2777: uint16(5641), + 2778: uint16(14904), + 2779: uint16(6170), + 2780: uint16(4699), + 2781: uint16(14906), + 2782: uint16(4691), + 2783: uint16(14912), + 2784: uint16(14909), + 2785: uint16(8018), + 2786: uint16(4650), + 2787: uint16(6411), + 2788: uint16(4649), + 2789: uint16(6446), + 2790: uint16(14907), + 2791: uint16(5700), + 2792: uint16(5674), + 2793: uint16(9292), + 2794: uint16(14905), + 2795: uint16(3877), + 2796: uint16(14908), + 2797: uint16(14910), + 2798: uint16(5420), + 2799: uint16(5643), + 2800: uint16(4891), + 2801: uint16(5162), + 2802: uint16(14913), + 2803: uint16(6488), + 2804: uint16(10832), + 2805: uint16(6678), + 2806: uint16(14914), + 2807: uint16(10255), + 2808: uint16(14926), + 2809: uint16(4370), + 2810: uint16(14915), + 2811: uint16(14932), + 2812: uint16(14916), + 2813: uint16(11553), + 2814: uint16(14923), + 2815: uint16(9790), + 2816: uint16(14931), + 2817: uint16(14918), + 2818: uint16(3859), + 2819: uint16(14920), + 2820: uint16(6171), + 2821: uint16(14922), + 2822: uint16(14921), + 2823: uint16(14917), + 2824: uint16(14928), + 2825: uint16(7454), + 2826: uint16(13132), + 2827: uint16(5959), + 2828: uint16(11355), + 2829: uint16(14919), + 2830: uint16(9043), + 2831: uint16(4610), + 2832: uint16(6412), + 2833: uint16(14911), + 2834: uint16(14927), + 2835: uint16(4672), + 2836: uint16(14925), + 2837: uint16(14929), + 2838: uint16(9293), + 2839: uint16(4957), + 2840: uint16(15121), + 2841: uint16(11048), + 2842: uint16(14934), + 2843: uint16(4956), + 2844: uint16(14941), + 2845: uint16(10783), + 2846: uint16(15104), + 2847: uint16(15106), + 2848: uint16(15110), + 2849: uint16(14936), + 2850: uint16(8713), + 2851: uint16(9294), + 2852: uint16(15114), + 2853: uint16(14939), + 2854: uint16(15111), + 2855: uint16(15105), + 2856: uint16(7704), + 2857: uint16(15115), + 2858: uint16(7954), + 2859: uint16(15113), + 2860: uint16(4892), + 2861: uint16(11823), + 2862: uint16(14933), + 2863: uint16(15109), + 2864: uint16(3895), + 2865: uint16(14935), + 2866: uint16(11033), + 2867: uint16(14940), + 2868: uint16(7681), + 2869: uint16(8998), + 2870: uint16(14930), + 2871: uint16(15108), + 2872: uint16(7769), + 2873: uint16(15118), + 2874: uint16(4688), + 2875: uint16(5888), + 2876: uint16(15120), + 2877: uint16(14937), + 2878: uint16(15119), + 2879: uint16(15112), + 2880: uint16(14938), + 2881: uint16(15116), + 2882: uint16(15117), + 2883: uint16(15134), + 2884: uint16(9517), + 2885: uint16(15107), + 2886: uint16(15130), + 2887: uint16(15132), + 2888: uint16(9015), + 2889: uint16(11307), + 2890: uint16(10325), + 2891: uint16(15127), + 2892: uint16(8489), + 2893: uint16(15133), + 2894: uint16(8222), + 2895: uint16(15124), + 2896: uint16(15137), + 2897: uint16(15136), + 2898: uint16(9550), + 2899: uint16(15135), + 2900: uint16(9545), + 2901: uint16(15139), + 2902: uint16(15126), + 2903: uint16(5415), + 2904: uint16(15129), + 2905: uint16(7228), + 2906: uint16(9791), + 2907: uint16(15131), + 2908: uint16(5418), + 2909: uint16(15123), + 2910: uint16(15125), + 2911: uint16(15122), + 2912: uint16(11791), + 2913: uint16(4665), + 2914: uint16(15128), + 2915: uint16(15138), + 2916: uint16(4628), + 2917: uint16(6470), + 2918: uint16(4156), + 2919: uint16(15155), + 2920: uint16(11792), + 2921: uint16(15158), + 2922: uint16(7705), + 2923: uint16(15157), + 2924: uint16(15156), + 2925: uint16(15153), + 2926: uint16(15141), + 2927: uint16(15170), + 2928: uint16(15140), + 2929: uint16(15159), + 2930: uint16(15151), + 2931: uint16(15146), + 2932: uint16(15143), + 2933: uint16(15144), + 2934: uint16(15152), + 2935: uint16(21249), + 2936: uint16(15149), + 2937: uint16(6172), + 2938: uint16(8999), + 2939: uint16(8259), + 2940: uint16(15147), + 2941: uint16(15142), + 2942: uint16(15145), + 2943: uint16(11308), + 2944: uint16(10825), + 2945: uint16(15150), + 2946: uint16(15160), + 2947: uint16(15168), + 2948: uint16(15161), + 2949: uint16(15174), + 2950: uint16(15172), + 2951: uint16(15167), + 2952: uint16(15166), + 2953: uint16(9007), + 2954: uint16(8260), + 2955: uint16(15164), + 2956: uint16(15162), + 2957: uint16(15169), + 2958: uint16(15175), + 2959: uint16(10068), + 2960: uint16(15181), + 2961: uint16(15176), + 2962: uint16(15179), + 2963: uint16(15173), + 2964: uint16(8787), + 2965: uint16(10263), + 2966: uint16(15163), + 2967: uint16(15171), + 2968: uint16(7455), + 2969: uint16(11054), + 2970: uint16(15191), + 2971: uint16(15178), + 2972: uint16(5889), + 2973: uint16(4354), + 2974: uint16(4670), + 2975: uint16(15154), + 2976: uint16(7456), + 2977: uint16(15183), + 2978: uint16(15190), + 2979: uint16(7000), + 2980: uint16(4689), + 2981: uint16(8717), + 2982: uint16(15180), + 2983: uint16(15185), + 2984: uint16(15189), + 2985: uint16(5397), + 2986: uint16(5163), + 2987: uint16(15187), + 2988: uint16(5120), + 2989: uint16(9514), + 2990: uint16(15186), + 2991: uint16(15188), + 2992: uint16(15182), + 2993: uint16(15184), + 2994: uint16(4671), + 2995: uint16(8744), + 2996: uint16(15195), + 2997: uint16(15193), + 2998: uint16(5960), + 2999: uint16(15192), + 3000: uint16(15360), + 3001: uint16(14903), + 3002: uint16(15194), + 3003: uint16(15196), + 3004: uint16(15197), + 3005: uint16(15371), + 3006: uint16(15367), + 3007: uint16(14924), + 3008: uint16(15366), + 3009: uint16(15365), + 3010: uint16(15362), + 3011: uint16(15177), + 3012: uint16(15364), + 3013: uint16(15363), + 3014: uint16(15369), + 3015: uint16(11781), + 3016: uint16(15372), + 3017: uint16(5466), + 3018: uint16(15368), + 3019: uint16(15370), + 3020: uint16(9990), + 3021: uint16(15373), + 3022: uint16(15377), + 3023: uint16(15374), + 3024: uint16(11346), + 3025: uint16(15375), + 3026: uint16(15165), + 3027: uint16(15378), + 3028: uint16(15379), + 3029: uint16(4116), + 3030: uint16(15381), + 3031: uint16(5702), + 3032: uint16(6912), + 3033: uint16(5428), + 3034: uint16(4355), + 3035: uint16(11326), + 3036: uint16(15383), + 3037: uint16(15382), + 3038: uint16(15385), + 3039: uint16(5148), + 3040: uint16(5429), + 3041: uint16(4893), + 3042: uint16(15388), + 3043: uint16(15387), + 3044: uint16(15389), + 3045: uint16(4397), + 3046: uint16(8726), + 3047: uint16(15390), + 3048: uint16(4894), + 3049: uint16(15392), + 3050: uint16(15391), + 3051: uint16(15393), + 3052: uint16(15394), + 3053: uint16(15395), + 3054: uint16(6718), + 3055: uint16(7956), + 3056: uint16(6400), + 3057: uint16(10319), + 3058: uint16(10561), + 3059: uint16(11811), + 3060: uint16(6740), + 3061: uint16(6447), + 3062: uint16(11601), + 3063: uint16(15396), + 3064: uint16(15397), + 3065: uint16(6719), + 3066: uint16(15398), + 3067: uint16(15399), + 3068: uint16(15401), + 3069: uint16(15400), + 3070: uint16(10807), + 3071: uint16(7229), + 3072: uint16(6987), + 3073: uint16(6691), + 3074: uint16(15402), + 3075: uint16(15404), + 3076: uint16(7682), + 3077: uint16(15403), + 3078: uint16(15405), + 3079: uint16(15406), + 3080: uint16(15407), + 3081: uint16(15408), + 3082: uint16(15409), + 3083: uint16(15411), + 3084: uint16(15410), + 3085: uint16(15412), + 3086: uint16(4356), + 3087: uint16(8745), + 3088: uint16(15413), + 3089: uint16(6661), + 3090: uint16(4651), + 3091: uint16(15414), + 3092: uint16(9249), + 3093: uint16(13099), + 3094: uint16(5122), + 3095: uint16(15415), + 3096: uint16(15416), + 3097: uint16(10571), + 3098: uint16(10823), + 3099: uint16(9510), + 3100: uint16(15417), + 3101: uint16(10053), + 3102: uint16(10074), + 3103: uint16(11058), + 3104: uint16(15418), + 3105: uint16(15420), + 3106: uint16(15419), + 3107: uint16(15422), + 3108: uint16(15421), + 3109: uint16(15424), + 3110: uint16(6720), + 3111: uint16(11024), + 3112: uint16(15425), + 3113: uint16(15426), + 3114: uint16(5123), + 3115: uint16(15427), + 3116: uint16(15429), + 3117: uint16(15428), + 3118: uint16(7748), + 3119: uint16(10264), + 3120: uint16(4137), + 3121: uint16(10020), + 3122: uint16(9044), + 3123: uint16(7200), + 3124: uint16(5184), + 3125: uint16(10021), + 3126: uint16(6925), + 3127: uint16(15431), + 3128: uint16(4895), + 3129: uint16(4183), + 3130: uint16(9553), + 3131: uint16(15430), + 3132: uint16(6173), + 3133: uint16(8754), + 3134: uint16(15432), + 3135: uint16(15440), + 3136: uint16(15433), + 3137: uint16(8480), + 3138: uint16(5185), + 3139: uint16(15441), + 3140: uint16(5703), + 3141: uint16(5124), + 3142: uint16(15439), + 3143: uint16(15437), + 3144: uint16(15434), + 3145: uint16(11327), + 3146: uint16(8991), + 3147: uint16(9528), + 3148: uint16(15435), + 3149: uint16(15443), + 3150: uint16(15442), + 3151: uint16(5634), + 3152: uint16(4364), + 3153: uint16(6426), + 3154: uint16(15436), + 3155: uint16(15438), + 3156: uint16(10806), + 3157: uint16(8531), + 3158: uint16(10838), + 3159: uint16(15451), + 3160: uint16(15452), + 3161: uint16(4398), + 3162: uint16(10503), + 3163: uint16(11100), + 3164: uint16(15616), + 3165: uint16(6914), + 3166: uint16(7457), + 3167: uint16(15447), + 3168: uint16(15453), + 3169: uint16(4167), + 3170: uint16(5398), + 3171: uint16(15444), + 3172: uint16(15449), + 3173: uint16(8019), + 3174: uint16(9808), + 3175: uint16(10054), + 3176: uint16(15446), + 3177: uint16(10752), + 3178: uint16(15448), + 3179: uint16(15619), + 3180: uint16(15617), + 3181: uint16(15450), + 3182: uint16(10753), + 3183: uint16(9767), + 3184: uint16(5186), + 3185: uint16(9220), + 3186: uint16(8780), + 3187: uint16(15620), + 3188: uint16(15618), + 3189: uint16(8504), + 3190: uint16(15445), + 3191: uint16(4138), + 3192: uint16(11309), + 3193: uint16(15631), + 3194: uint16(15630), + 3195: uint16(8021), + 3196: uint16(15627), + 3197: uint16(11339), + 3198: uint16(9493), + 3199: uint16(15621), + 3200: uint16(8996), + 3201: uint16(4139), + 3202: uint16(6174), + 3203: uint16(15624), + 3204: uint16(7174), + 3205: uint16(15629), + 3206: uint16(15628), + 3207: uint16(15623), + 3208: uint16(15626), + 3209: uint16(4679), + 3210: uint16(15625), + 3211: uint16(9768), + 3212: uint16(11533), + 3213: uint16(7507), + 3214: uint16(8020), + 3215: uint16(15637), + 3216: uint16(15635), + 3217: uint16(10284), + 3218: uint16(15632), + 3219: uint16(15634), + 3220: uint16(4121), + 3221: uint16(6175), + 3222: uint16(11793), + 3223: uint16(4636), + 3224: uint16(10305), + 3225: uint16(11328), + 3226: uint16(4611), + 3227: uint16(7706), + 3228: uint16(15636), + 3229: uint16(15641), + 3230: uint16(7458), + 3231: uint16(11279), + 3232: uint16(15638), + 3233: uint16(15633), + 3234: uint16(15639), + 3235: uint16(11581), + 3236: uint16(9298), + 3237: uint16(9505), + 3238: uint16(4629), + 3239: uint16(4148), + 3240: uint16(15645), + 3241: uint16(15648), + 3242: uint16(11554), + 3243: uint16(11331), + 3244: uint16(15655), + 3245: uint16(15649), + 3246: uint16(15646), + 3247: uint16(11571), + 3248: uint16(15652), + 3249: uint16(7209), + 3250: uint16(15654), + 3251: uint16(15659), + 3252: uint16(9296), + 3253: uint16(15657), + 3254: uint16(15651), + 3255: uint16(8727), + 3256: uint16(15658), + 3257: uint16(15647), + 3258: uint16(15653), + 3259: uint16(15660), + 3260: uint16(3931), + 3261: uint16(15650), + 3262: uint16(15661), + 3263: uint16(7707), + 3264: uint16(7230), + 3265: uint16(10500), + 3266: uint16(6413), + 3267: uint16(15642), + 3268: uint16(15656), + 3269: uint16(9241), + 3270: uint16(7957), + 3271: uint16(4680), + 3272: uint16(6448), + 3273: uint16(7459), + 3274: uint16(15644), + 3275: uint16(7201), + 3276: uint16(5675), + 3277: uint16(15643), + 3278: uint16(15665), + 3279: uint16(7244), + 3280: uint16(5913), + 3281: uint16(15680), + 3282: uint16(15674), + 3283: uint16(5203), + 3284: uint16(9262), + 3285: uint16(15669), + 3286: uint16(15678), + 3287: uint16(3854), + 3288: uint16(4113), + 3289: uint16(4376), + 3290: uint16(15671), + 3291: uint16(8459), + 3292: uint16(15662), + 3293: uint16(15664), + 3294: uint16(6176), + 3295: uint16(15681), + 3296: uint16(15676), + 3297: uint16(15668), + 3298: uint16(15675), + 3299: uint16(11018), + 3300: uint16(15673), + 3301: uint16(15677), + 3302: uint16(5935), + 3303: uint16(7460), + 3304: uint16(8728), + 3305: uint16(15667), + 3306: uint16(11278), + 3307: uint16(15670), + 3308: uint16(15663), + 3309: uint16(9297), + 3310: uint16(15666), + 3311: uint16(15672), + 3312: uint16(11824), + 3313: uint16(6941), + 3314: uint16(10845), + 3315: uint16(15682), + 3316: uint16(9997), + 3317: uint16(15694), + 3318: uint16(5914), + 3319: uint16(7231), + 3320: uint16(15684), + 3321: uint16(11534), + 3322: uint16(6177), + 3323: uint16(15697), + 3324: uint16(3917), + 3325: uint16(15695), + 3326: uint16(15683), + 3327: uint16(15689), + 3328: uint16(15691), + 3329: uint16(11310), + 3330: uint16(15686), + 3331: uint16(9229), + 3332: uint16(15688), + 3333: uint16(15696), + 3334: uint16(15690), + 3335: uint16(11046), + 3336: uint16(15685), + 3337: uint16(6913), + 3338: uint16(15709), + 3339: uint16(4681), + 3340: uint16(15687), + 3341: uint16(15692), + 3342: uint16(15693), + 3343: uint16(8523), + 3344: uint16(8505), + 3345: uint16(15701), + 3346: uint16(15707), + 3347: uint16(15705), + 3348: uint16(9224), + 3349: uint16(15874), + 3350: uint16(15702), + 3351: uint16(15703), + 3352: uint16(15679), + 3353: uint16(5208), + 3354: uint16(10265), + 3355: uint16(6942), + 3356: uint16(6230), + 3357: uint16(11794), + 3358: uint16(15699), + 3359: uint16(15873), + 3360: uint16(4168), + 3361: uint16(8261), + 3362: uint16(9816), + 3363: uint16(4896), + 3364: uint16(11609), + 3365: uint16(11008), + 3366: uint16(9009), + 3367: uint16(15706), + 3368: uint16(15708), + 3369: uint16(8209), + 3370: uint16(15872), + 3371: uint16(15704), + 3372: uint16(15698), + 3373: uint16(4898), + 3374: uint16(5704), + 3375: uint16(15886), + 3376: uint16(15881), + 3377: uint16(8023), + 3378: uint16(4674), + 3379: uint16(7232), + 3380: uint16(15890), + 3381: uint16(15883), + 3382: uint16(8971), + 3383: uint16(15880), + 3384: uint16(9016), + 3385: uint16(15915), + 3386: uint16(15877), + 3387: uint16(15876), + 3388: uint16(15885), + 3389: uint16(15879), + 3390: uint16(15878), + 3391: uint16(15884), + 3392: uint16(7936), + 3393: uint16(15875), + 3394: uint16(15887), + 3395: uint16(15888), + 3396: uint16(4897), + 3397: uint16(15893), + 3398: uint16(15892), + 3399: uint16(15894), + 3400: uint16(15897), + 3401: uint16(9250), + 3402: uint16(15891), + 3403: uint16(15895), + 3404: uint16(5698), + 3405: uint16(8536), + 3406: uint16(15889), + 3407: uint16(9754), + 3408: uint16(15896), + 3409: uint16(15901), + 3410: uint16(15899), + 3411: uint16(15902), + 3412: uint16(15905), + 3413: uint16(15898), + 3414: uint16(6217), + 3415: uint16(9735), + 3416: uint16(15640), + 3417: uint16(11347), + 3418: uint16(15900), + 3419: uint16(15904), + 3420: uint16(8532), + 3421: uint16(15903), + 3422: uint16(15882), + 3423: uint16(20040), + 3424: uint16(15908), + 3425: uint16(15912), + 3426: uint16(15910), + 3427: uint16(15906), + 3428: uint16(15907), + 3429: uint16(15911), + 3430: uint16(15909), + 3431: uint16(10285), + 3432: uint16(15917), + 3433: uint16(15914), + 3434: uint16(15913), + 3435: uint16(15916), + 3436: uint16(9523), + 3437: uint16(15918), + 3438: uint16(8788), + 3439: uint16(8524), + 3440: uint16(7940), + 3441: uint16(15919), + 3442: uint16(15921), + 3443: uint16(15920), + 3444: uint16(15700), + 3445: uint16(15922), + 3446: uint16(9542), + 3447: uint16(15923), + 3448: uint16(4399), + 3449: uint16(9299), + 3450: uint16(4612), + 3451: uint16(5187), + 3452: uint16(6973), + 3453: uint16(6449), + 3454: uint16(11782), + 3455: uint16(7749), + 3456: uint16(4169), + 3457: uint16(15925), + 3458: uint16(15924), + 3459: uint16(15928), + 3460: uint16(8729), + 3461: uint16(15931), + 3462: uint16(15926), + 3463: uint16(15930), + 3464: uint16(15929), + 3465: uint16(9247), + 3466: uint16(3896), + 3467: uint16(11604), + 3468: uint16(15933), + 3469: uint16(4103), + 3470: uint16(15935), + 3471: uint16(15934), + 3472: uint16(15932), + 3473: uint16(15927), + 3474: uint16(10754), + 3475: uint16(15937), + 3476: uint16(15936), + 3477: uint16(4170), + 3478: uint16(15939), + 3479: uint16(10513), + 3480: uint16(15938), + 3481: uint16(11028), + 3482: uint16(7462), + 3483: uint16(8210), + 3484: uint16(7461), + 3485: uint16(11610), + 3486: uint16(15945), + 3487: uint16(8024), + 3488: uint16(15941), + 3489: uint16(15946), + 3490: uint16(4171), + 3491: uint16(15944), + 3492: uint16(9792), + 3493: uint16(15940), + 3494: uint16(15943), + 3495: uint16(7463), + 3496: uint16(10032), + 3497: uint16(15947), + 3498: uint16(6960), + 3499: uint16(8025), + 3500: uint16(15950), + 3501: uint16(15942), + 3502: uint16(5638), + 3503: uint16(15948), + 3504: uint16(11311), + 3505: uint16(15951), + 3506: uint16(21253), + 3507: uint16(7214), + 3508: uint16(15952), + 3509: uint16(15953), + 3510: uint16(9741), + 3511: uint16(15955), + 3512: uint16(15956), + 3513: uint16(9746), + 3514: uint16(9300), + 3515: uint16(15958), + 3516: uint16(15960), + 3517: uint16(11572), + 3518: uint16(15957), + 3519: uint16(15959), + 3520: uint16(4172), + 3521: uint16(15954), + 3522: uint16(12858), + 3523: uint16(15961), + 3524: uint16(8262), + 3525: uint16(6679), + 3526: uint16(15963), + 3527: uint16(15962), + 3528: uint16(7683), + 3529: uint16(12600), + 3530: uint16(15964), + 3531: uint16(16128), + 3532: uint16(15949), + 3533: uint16(15965), + 3534: uint16(16129), + 3535: uint16(9817), + 3536: uint16(16130), + 3537: uint16(16131), + 3538: uint16(16132), + 3539: uint16(16133), + 3540: uint16(9021), + 3541: uint16(16135), + 3542: uint16(16134), + 3543: uint16(16136), + 3544: uint16(16137), + 3545: uint16(6974), + 3546: uint16(10306), + 3547: uint16(11083), + 3548: uint16(16138), + 3549: uint16(16139), + 3550: uint16(8245), + 3551: uint16(6915), + 3552: uint16(16140), + 3553: uint16(16141), + 3554: uint16(16142), + 3555: uint16(10545), + 3556: uint16(10022), + 3557: uint16(16143), + 3558: uint16(9782), + 3559: uint16(8972), + 3560: uint16(16144), + 3561: uint16(4422), + 3562: uint16(5196), + 3563: uint16(11045), + 3564: uint16(11029), + 3565: uint16(4371), + 3566: uint16(11795), + 3567: uint16(10801), + 3568: uint16(10505), + 3569: uint16(7958), + 3570: uint16(16145), + 3571: uint16(9506), + 3572: uint16(5890), + 3573: uint16(16146), + 3574: uint16(6451), + 3575: uint16(16148), + 3576: uint16(16147), + 3577: uint16(16149), + 3578: uint16(16150), + 3579: uint16(16151), + 3580: uint16(5149), + 3581: uint16(16152), + 3582: uint16(16153), + 3583: uint16(5891), + 3584: uint16(10023), + 3585: uint16(16155), + 3586: uint16(7508), + 3587: uint16(16154), + 3588: uint16(5399), + 3589: uint16(16156), + 3590: uint16(16158), + 3591: uint16(16157), + 3592: uint16(16159), + 3593: uint16(5936), + 3594: uint16(16160), + 3595: uint16(5448), + 3596: uint16(8223), + 3597: uint16(6236), + 3598: uint16(16162), + 3599: uint16(16163), + 3600: uint16(16161), + 3601: uint16(6988), + 3602: uint16(9511), + 3603: uint16(5400), + 3604: uint16(16165), + 3605: uint16(8715), + 3606: uint16(16164), + 3607: uint16(11796), + 3608: uint16(9793), + 3609: uint16(16168), + 3610: uint16(16170), + 3611: uint16(16167), + 3612: uint16(11059), + 3613: uint16(16169), + 3614: uint16(16171), + 3615: uint16(11555), + 3616: uint16(16175), + 3617: uint16(16174), + 3618: uint16(8789), + 3619: uint16(9740), + 3620: uint16(5892), + 3621: uint16(16173), + 3622: uint16(16172), + 3623: uint16(11280), + 3624: uint16(11281), + 3625: uint16(16176), + 3626: uint16(4173), + 3627: uint16(6229), + 3628: uint16(6721), + 3629: uint16(16177), + 3630: uint16(16178), + 3631: uint16(16180), + 3632: uint16(7202), + 3633: uint16(16182), + 3634: uint16(16181), + 3635: uint16(16183), + 3636: uint16(4652), + 3637: uint16(16185), + 3638: uint16(16184), + 3639: uint16(16187), + 3640: uint16(16186), + 3641: uint16(5915), + 3642: uint16(11527), + 3643: uint16(5419), + 3644: uint16(4357), + 3645: uint16(5449), + 3646: uint16(4928), + 3647: uint16(11591), + 3648: uint16(16189), + 3649: uint16(16191), + 3650: uint16(16192), + 3651: uint16(4400), + 3652: uint16(16188), + 3653: uint16(6680), + 3654: uint16(8992), + 3655: uint16(16190), + 3656: uint16(16195), + 3657: uint16(6989), + 3658: uint16(16193), + 3659: uint16(5661), + 3660: uint16(10024), + 3661: uint16(16194), + 3662: uint16(16221), + 3663: uint16(16200), + 3664: uint16(5916), + 3665: uint16(5188), + 3666: uint16(16197), + 3667: uint16(11356), + 3668: uint16(11535), + 3669: uint16(8533), + 3670: uint16(16199), + 3671: uint16(16201), + 3672: uint16(11573), + 3673: uint16(5430), + 3674: uint16(10075), + 3675: uint16(9769), + 3676: uint16(16202), + 3677: uint16(16204), + 3678: uint16(16207), + 3679: uint16(16203), + 3680: uint16(16206), + 3681: uint16(5961), + 3682: uint16(4140), + 3683: uint16(16208), + 3684: uint16(7759), + 3685: uint16(16205), + 3686: uint16(11579), + 3687: uint16(16211), + 3688: uint16(21251), + 3689: uint16(16209), + 3690: uint16(16212), + 3691: uint16(16198), + 3692: uint16(16210), + 3693: uint16(6427), + 3694: uint16(16213), + 3695: uint16(16214), + 3696: uint16(11357), + 3697: uint16(16215), + 3698: uint16(16216), + 3699: uint16(16196), + 3700: uint16(16217), + 3701: uint16(4899), + 3702: uint16(6916), + 3703: uint16(16218), + 3704: uint16(16219), + 3705: uint16(16220), + 3706: uint16(4122), + 3707: uint16(16384), + 3708: uint16(10266), + 3709: uint16(16385), + 3710: uint16(4867), + 3711: uint16(16386), + 3712: uint16(16387), + 3713: uint16(16388), + 3714: uint16(16390), + 3715: uint16(16391), + 3716: uint16(16389), + 3717: uint16(10290), + 3718: uint16(16393), + 3719: uint16(16392), + 3720: uint16(16395), + 3721: uint16(16394), + 3722: uint16(16396), + 3723: uint16(16397), + 3724: uint16(16399), + 3725: uint16(16398), + 3726: uint16(6232), + 3727: uint16(16401), + 3728: uint16(16400), + 3729: uint16(4900), + 3730: uint16(7730), + 3731: uint16(9243), + 3732: uint16(16402), + 3733: uint16(7959), + 3734: uint16(6681), + 3735: uint16(4184), + 3736: uint16(16403), + 3737: uint16(11312), + 3738: uint16(10562), + 3739: uint16(16404), + 3740: uint16(9251), + 3741: uint16(11282), + 3742: uint16(6178), + 3743: uint16(7708), + 3744: uint16(8746), + 3745: uint16(12563), + 3746: uint16(8973), + 3747: uint16(4423), + 3748: uint16(16405), + 3749: uint16(16406), + 3750: uint16(16411), + 3751: uint16(16409), + 3752: uint16(16408), + 3753: uint16(14625), + 3754: uint16(4613), + 3755: uint16(16407), + 3756: uint16(3897), + 3757: uint16(9993), + 3758: uint16(10025), + 3759: uint16(11536), + 3760: uint16(16412), + 3761: uint16(16410), + 3762: uint16(8763), + 3763: uint16(7941), + 3764: uint16(9994), + 3765: uint16(10252), + 3766: uint16(16414), + 3767: uint16(11531), + 3768: uint16(5676), + 3769: uint16(16415), + 3770: uint16(16413), + 3771: uint16(10037), + 3772: uint16(16416), + 3773: uint16(16417), + 3774: uint16(3898), + 3775: uint16(7509), + 3776: uint16(16422), + 3777: uint16(16419), + 3778: uint16(9548), + 3779: uint16(16418), + 3780: uint16(5125), + 3781: uint16(16425), + 3782: uint16(16420), + 3783: uint16(16421), + 3784: uint16(16424), + 3785: uint16(16423), + 3786: uint16(10244), + 3787: uint16(8225), + 3788: uint16(8224), + 3789: uint16(5150), + 3790: uint16(16426), + 3791: uint16(16427), + 3792: uint16(16428), + 3793: uint16(16430), + 3794: uint16(16429), + 3795: uint16(4149), + 3796: uint16(16438), + 3797: uint16(10055), + 3798: uint16(16432), + 3799: uint16(16434), + 3800: uint16(16436), + 3801: uint16(7709), + 3802: uint16(16437), + 3803: uint16(16435), + 3804: uint16(6943), + 3805: uint16(16431), + 3806: uint16(16433), + 3807: uint16(10273), + 3808: uint16(7464), + 3809: uint16(16440), + 3810: uint16(16439), + 3811: uint16(16441), + 3812: uint16(6917), + 3813: uint16(6414), + 3814: uint16(9302), + 3815: uint16(16442), + 3816: uint16(9002), + 3817: uint16(16444), + 3818: uint16(11520), + 3819: uint16(16443), + 3820: uint16(8264), + 3821: uint16(16449), + 3822: uint16(16451), + 3823: uint16(16452), + 3824: uint16(8755), + 3825: uint16(16450), + 3826: uint16(16447), + 3827: uint16(16445), + 3828: uint16(16446), + 3829: uint16(16448), + 3830: uint16(16455), + 3831: uint16(16453), + 3832: uint16(16454), + 3833: uint16(16456), + 3834: uint16(16458), + 3835: uint16(16459), + 3836: uint16(16460), + 3837: uint16(16461), + 3838: uint16(16457), + 3839: uint16(16463), + 3840: uint16(16462), + 3841: uint16(16464), + 3842: uint16(11556), + 3843: uint16(16467), + 3844: uint16(16465), + 3845: uint16(16466), + 3846: uint16(4929), + 3847: uint16(11101), + 3848: uint16(10537), + 3849: uint16(16469), + 3850: uint16(16468), + 3851: uint16(16470), + 3852: uint16(16471), + 3853: uint16(16475), + 3854: uint16(16472), + 3855: uint16(16473), + 3856: uint16(16474), + 3857: uint16(16476), + 3858: uint16(16477), + 3859: uint16(16640), + 3860: uint16(16641), + 3861: uint16(16642), + 3862: uint16(9998), + 3863: uint16(9263), + 3864: uint16(16643), + 3865: uint16(9809), + 3866: uint16(10259), + 3867: uint16(16644), + 3868: uint16(16645), + 3869: uint16(9225), + 3870: uint16(4614), + 3871: uint16(6179), + 3872: uint16(16646), + 3873: uint16(16647), + 3874: uint16(16648), + 3875: uint16(6664), + 3876: uint16(16650), + 3877: uint16(16649), + 3878: uint16(16651), + 3879: uint16(16652), + 3880: uint16(10056), + 3881: uint16(16653), + 3882: uint16(16654), + 3883: uint16(21064), + 3884: uint16(16655), + 3885: uint16(16656), + 3886: uint16(16657), + 3887: uint16(6669), + 3888: uint16(16658), + 3889: uint16(9781), + 3890: uint16(10814), + 3891: uint16(4141), + 3892: uint16(4150), + 3893: uint16(16659), + 3894: uint16(16661), + 3895: uint16(16660), + 3896: uint16(9295), + 3897: uint16(7960), + 3898: uint16(15384), + 3899: uint16(16662), + 3900: uint16(11040), + 3901: uint16(16663), + 3902: uint16(4901), + 3903: uint16(10038), + 3904: uint16(16664), + 3905: uint16(16665), + 3906: uint16(16666), + 3907: uint16(11067), + 3908: uint16(11060), + 3909: uint16(8989), + 3910: uint16(8265), + 3911: uint16(16668), + 3912: uint16(7233), + 3913: uint16(7465), + 3914: uint16(16671), + 3915: uint16(16670), + 3916: uint16(16669), + 3917: uint16(10076), + 3918: uint16(4902), + 3919: uint16(5896), + 3920: uint16(16677), + 3921: uint16(16674), + 3922: uint16(7710), + 3923: uint16(11025), + 3924: uint16(16673), + 3925: uint16(16675), + 3926: uint16(16676), + 3927: uint16(16672), + 3928: uint16(16678), + 3929: uint16(16679), + 3930: uint16(8974), + 3931: uint16(4930), + 3932: uint16(8772), + 3933: uint16(16680), + 3934: uint16(16681), + 3935: uint16(16684), + 3936: uint16(7750), + 3937: uint16(9507), + 3938: uint16(16685), + 3939: uint16(10802), + 3940: uint16(16682), + 3941: uint16(16683), + 3942: uint16(16688), + 3943: uint16(16687), + 3944: uint16(16686), + 3945: uint16(16690), + 3946: uint16(16689), + 3947: uint16(16691), + 3948: uint16(16693), + 3949: uint16(16692), + 3950: uint16(10540), + 3951: uint16(7221), + 3952: uint16(11557), + 3953: uint16(16694), + 3954: uint16(9494), + 3955: uint16(16695), + 3956: uint16(16696), + 3957: uint16(16700), + 3958: uint16(16698), + 3959: uint16(16699), + 3960: uint16(16697), + 3961: uint16(16701), + 3962: uint16(16702), + 3963: uint16(16703), + 3964: uint16(16704), + 3965: uint16(11030), + 3966: uint16(16705), + 3967: uint16(11087), + 3968: uint16(16706), + 3969: uint16(8749), + 3970: uint16(9801), + 3971: uint16(5450), + 3972: uint16(8730), + 3973: uint16(16707), + 3974: uint16(5401), + 3975: uint16(7983), + 3976: uint16(16708), + 3977: uint16(6428), + 3978: uint16(16709), + 3979: uint16(16710), + 3980: uint16(5893), + 3981: uint16(6452), + 3982: uint16(16712), + 3983: uint16(9269), + 3984: uint16(6453), + 3985: uint16(5165), + 3986: uint16(10755), + 3987: uint16(9770), + 3988: uint16(9270), + 3989: uint16(6203), + 3990: uint16(16714), + 3991: uint16(7466), + 3992: uint16(11537), + 3993: uint16(6180), + 3994: uint16(5894), + 3995: uint16(9986), + 3996: uint16(16716), + 3997: uint16(16718), + 3998: uint16(5962), + 3999: uint16(16717), + 4000: uint16(9045), + 4001: uint16(16720), + 4002: uint16(4630), + 4003: uint16(16715), + 4004: uint16(10057), + 4005: uint16(4111), + 4006: uint16(6475), + 4007: uint16(11825), + 4008: uint16(16719), + 4009: uint16(16721), + 4010: uint16(10538), + 4011: uint16(7992), + 4012: uint16(16723), + 4013: uint16(16724), + 4014: uint16(16722), + 4015: uint16(4653), + 4016: uint16(16730), + 4017: uint16(16729), + 4018: uint16(6918), + 4019: uint16(16731), + 4020: uint16(16726), + 4021: uint16(16732), + 4022: uint16(16727), + 4023: uint16(10039), + 4024: uint16(16725), + 4025: uint16(16728), + 4026: uint16(16897), + 4027: uint16(16896), + 4028: uint16(10816), + 4029: uint16(16733), + 4030: uint16(3914), + 4031: uint16(16899), + 4032: uint16(16898), + 4033: uint16(7467), + 4034: uint16(16900), + 4035: uint16(8226), + 4036: uint16(16902), + 4037: uint16(16901), + 4038: uint16(16903), + 4039: uint16(16711), + 4040: uint16(16713), + 4041: uint16(16905), + 4042: uint16(16904), + 4043: uint16(6919), + 4044: uint16(11592), + 4045: uint16(6961), + 4046: uint16(16906), + 4047: uint16(5654), + 4048: uint16(5151), + 4049: uint16(5126), + 4050: uint16(6722), + 4051: uint16(11283), + 4052: uint16(16912), + 4053: uint16(16911), + 4054: uint16(8227), + 4055: uint16(16908), + 4056: uint16(16910), + 4057: uint16(7210), + 4058: uint16(7711), + 4059: uint16(16909), + 4060: uint16(16907), + 4061: uint16(9737), + 4062: uint16(7468), + 4063: uint16(10267), + 4064: uint16(6454), + 4065: uint16(9303), + 4066: uint16(16913), + 4067: uint16(16914), + 4068: uint16(16936), + 4069: uint16(5431), + 4070: uint16(11804), + 4071: uint16(8212), + 4072: uint16(16915), + 4073: uint16(4401), + 4074: uint16(9046), + 4075: uint16(10496), + 4076: uint16(16916), + 4077: uint16(5209), + 4078: uint16(16917), + 4079: uint16(16919), + 4080: uint16(16920), + 4081: uint16(9736), + 4082: uint16(16921), + 4083: uint16(16922), + 4084: uint16(16923), + 4085: uint16(5432), + 4086: uint16(4402), + 4087: uint16(9508), + 4088: uint16(7175), + 4089: uint16(6723), + 4090: uint16(16924), + 4091: uint16(7176), + 4092: uint16(4393), + 4093: uint16(10274), + 4094: uint16(16925), + 4095: uint16(10058), + 4096: uint16(8228), + 4097: uint16(16928), + 4098: uint16(16929), + 4099: uint16(9800), + 4100: uint16(7712), + 4101: uint16(16926), + 4102: uint16(8768), + 4103: uint16(16927), + 4104: uint16(7469), + 4105: uint16(3899), + 4106: uint16(5128), + 4107: uint16(16930), + 4108: uint16(9047), + 4109: uint16(16931), + 4110: uint16(7974), + 4111: uint16(11020), + 4112: uint16(10242), + 4113: uint16(16932), + 4114: uint16(16933), + 4115: uint16(8756), + 4116: uint16(11558), + 4117: uint16(16935), + 4118: uint16(16934), + 4119: uint16(6990), + 4120: uint16(16937), + 4121: uint16(3919), + 4122: uint16(16940), + 4123: uint16(16938), + 4124: uint16(4403), + 4125: uint16(5677), + 4126: uint16(16939), + 4127: uint16(6181), + 4128: uint16(6225), + 4129: uint16(10565), + 4130: uint16(16941), + 4131: uint16(10803), + 4132: uint16(16943), + 4133: uint16(7984), + 4134: uint16(4142), + 4135: uint16(4377), + 4136: uint16(3851), + 4137: uint16(16942), + 4138: uint16(16944), + 4139: uint16(16945), + 4140: uint16(7510), + 4141: uint16(16946), + 4142: uint16(4654), + 4143: uint16(16948), + 4144: uint16(5705), + 4145: uint16(5189), + 4146: uint16(16949), + 4147: uint16(5460), + 4148: uint16(16950), + 4149: uint16(8027), + 4150: uint16(9516), + 4151: uint16(7999), + 4152: uint16(6484), + 4153: uint16(16951), + 4154: uint16(8769), + 4155: uint16(8266), + 4156: uint16(16953), + 4157: uint16(16955), + 4158: uint16(16952), + 4159: uint16(16954), + 4160: uint16(5633), + 4161: uint16(16956), + 4162: uint16(5637), + 4163: uint16(5190), + 4164: uint16(11313), + 4165: uint16(16958), + 4166: uint16(16959), + 4167: uint16(4109), + 4168: uint16(16962), + 4169: uint16(4693), + 4170: uint16(16961), + 4171: uint16(16960), + 4172: uint16(16964), + 4173: uint16(16957), + 4174: uint16(16965), + 4175: uint16(11528), + 4176: uint16(16966), + 4177: uint16(16967), + 4178: uint16(13139), + 4179: uint16(16969), + 4180: uint16(16968), + 4181: uint16(16970), + 4182: uint16(16971), + 4183: uint16(11540), + 4184: uint16(16972), + 4185: uint16(20302), + 4186: uint16(7470), + 4187: uint16(16973), + 4188: uint16(16974), + 4189: uint16(7222), + 4190: uint16(9495), + 4191: uint16(16975), + 4192: uint16(8711), + 4193: uint16(16976), + 4194: uint16(8731), + 4195: uint16(16977), + 4196: uint16(5380), + 4197: uint16(12318), + 4198: uint16(8764), + 4199: uint16(6930), + 4200: uint16(4903), + 4201: uint16(16978), + 4202: uint16(17153), + 4203: uint16(16981), + 4204: uint16(5191), + 4205: uint16(16980), + 4206: uint16(17155), + 4207: uint16(16979), + 4208: uint16(7471), + 4209: uint16(16983), + 4210: uint16(16984), + 4211: uint16(9226), + 4212: uint16(16985), + 4213: uint16(4669), + 4214: uint16(7737), + 4215: uint16(10307), + 4216: uint16(16987), + 4217: uint16(8519), + 4218: uint16(16982), + 4219: uint16(16986), + 4220: uint16(16988), + 4221: uint16(6490), + 4222: uint16(17157), + 4223: uint16(10253), + 4224: uint16(9989), + 4225: uint16(9304), + 4226: uint16(5433), + 4227: uint16(17156), + 4228: uint16(17154), + 4229: uint16(10004), + 4230: uint16(16989), + 4231: uint16(8765), + 4232: uint16(9306), + 4233: uint16(9305), + 4234: uint16(6485), + 4235: uint16(17175), + 4236: uint16(17159), + 4237: uint16(17161), + 4238: uint16(17164), + 4239: uint16(17165), + 4240: uint16(17162), + 4241: uint16(17163), + 4242: uint16(17160), + 4243: uint16(17158), + 4244: uint16(17152), + 4245: uint16(10542), + 4246: uint16(4404), + 4247: uint16(17172), + 4248: uint16(17169), + 4249: uint16(17174), + 4250: uint16(17173), + 4251: uint16(9810), + 4252: uint16(11014), + 4253: uint16(6682), + 4254: uint16(17167), + 4255: uint16(17176), + 4256: uint16(17171), + 4257: uint16(17170), + 4258: uint16(17166), + 4259: uint16(17168), + 4260: uint16(4904), + 4261: uint16(8732), + 4262: uint16(8028), + 4263: uint16(9985), + 4264: uint16(17181), + 4265: uint16(9987), + 4266: uint16(8000), + 4267: uint16(17178), + 4268: uint16(10030), + 4269: uint16(17182), + 4270: uint16(10546), + 4271: uint16(8762), + 4272: uint16(17177), + 4273: uint16(17179), + 4274: uint16(17180), + 4275: uint16(17183), + 4276: uint16(6947), + 4277: uint16(9509), + 4278: uint16(17188), + 4279: uint16(17187), + 4280: uint16(17184), + 4281: uint16(11797), + 4282: uint16(17193), + 4283: uint16(17197), + 4284: uint16(17194), + 4285: uint16(17190), + 4286: uint16(17191), + 4287: uint16(17196), + 4288: uint16(17185), + 4289: uint16(12596), + 4290: uint16(17192), + 4291: uint16(17186), + 4292: uint16(17195), + 4293: uint16(17201), + 4294: uint16(4905), + 4295: uint16(17198), + 4296: uint16(17199), + 4297: uint16(17200), + 4298: uint16(17203), + 4299: uint16(17202), + 4300: uint16(10069), + 4301: uint16(17204), + 4302: uint16(11611), + 4303: uint16(10572), + 4304: uint16(17209), + 4305: uint16(17206), + 4306: uint16(17205), + 4307: uint16(7985), + 4308: uint16(17208), + 4309: uint16(17210), + 4310: uint16(17207), + 4311: uint16(17214), + 4312: uint16(17211), + 4313: uint16(17212), + 4314: uint16(17189), + 4315: uint16(17213), + 4316: uint16(17215), + 4317: uint16(17216), + 4318: uint16(10533), + 4319: uint16(17217), + 4320: uint16(11073), + 4321: uint16(5421), + 4322: uint16(5640), + 4323: uint16(17218), + 4324: uint16(10515), + 4325: uint16(7751), + 4326: uint16(11023), + 4327: uint16(17219), + 4328: uint16(11538), + 4329: uint16(9811), + 4330: uint16(8229), + 4331: uint16(9747), + 4332: uint16(7212), + 4333: uint16(3871), + 4334: uint16(17224), + 4335: uint16(17222), + 4336: uint16(17220), + 4337: uint16(4864), + 4338: uint16(7472), + 4339: uint16(17225), + 4340: uint16(17223), + 4341: uint16(17221), + 4342: uint16(17229), + 4343: uint16(17228), + 4344: uint16(17227), + 4345: uint16(17226), + 4346: uint16(17230), + 4347: uint16(17231), + 4348: uint16(7961), + 4349: uint16(17232), + 4350: uint16(17234), + 4351: uint16(17233), + 4352: uint16(5937), + 4353: uint16(8215), + 4354: uint16(17236), + 4355: uint16(9307), + 4356: uint16(17235), + 4357: uint16(17237), + 4358: uint16(10516), + 4359: uint16(8267), + 4360: uint16(6182), + 4361: uint16(17238), + 4362: uint16(11559), + 4363: uint16(17240), + 4364: uint16(17241), + 4365: uint16(17242), + 4366: uint16(17243), + 4367: uint16(6724), + 4368: uint16(17244), + 4369: uint16(5678), + 4370: uint16(5193), + 4371: uint16(5129), + 4372: uint16(17408), + 4373: uint16(11090), + 4374: uint16(6183), + 4375: uint16(17245), + 4376: uint16(17411), + 4377: uint16(11077), + 4378: uint16(9755), + 4379: uint16(10258), + 4380: uint16(7234), + 4381: uint16(17410), + 4382: uint16(6962), + 4383: uint16(6184), + 4384: uint16(6725), + 4385: uint16(5192), + 4386: uint16(10517), + 4387: uint16(17409), + 4388: uint16(8230), + 4389: uint16(10785), + 4390: uint16(6486), + 4391: uint16(6726), + 4392: uint16(9020), + 4393: uint16(17414), + 4394: uint16(11582), + 4395: uint16(6456), + 4396: uint16(17415), + 4397: uint16(7713), + 4398: uint16(17417), + 4399: uint16(7473), + 4400: uint16(6415), + 4401: uint16(17416), + 4402: uint16(7177), + 4403: uint16(5917), + 4404: uint16(8231), + 4405: uint16(17412), + 4406: uint16(17418), + 4407: uint16(17413), + 4408: uint16(5679), + 4409: uint16(17421), + 4410: uint16(17425), + 4411: uint16(5706), + 4412: uint16(17420), + 4413: uint16(17429), + 4414: uint16(6185), + 4415: uint16(11340), + 4416: uint16(3867), + 4417: uint16(17426), + 4418: uint16(5194), + 4419: uint16(17423), + 4420: uint16(17424), + 4421: uint16(9308), + 4422: uint16(17422), + 4423: uint16(17419), + 4424: uint16(4615), + 4425: uint16(8003), + 4426: uint16(5895), + 4427: uint16(17431), + 4428: uint16(17428), + 4429: uint16(17430), + 4430: uint16(17427), + 4431: uint16(5680), + 4432: uint16(8466), + 4433: uint16(17432), + 4434: uint16(8269), + 4435: uint16(17445), + 4436: uint16(17441), + 4437: uint16(17435), + 4438: uint16(17439), + 4439: uint16(7001), + 4440: uint16(3900), + 4441: uint16(17434), + 4442: uint16(17442), + 4443: uint16(17446), + 4444: uint16(6186), + 4445: uint16(11061), + 4446: uint16(9013), + 4447: uint16(17436), + 4448: uint16(17444), + 4449: uint16(17433), + 4450: uint16(8733), + 4451: uint16(17438), + 4452: uint16(3868), + 4453: uint16(11049), + 4454: uint16(17437), + 4455: uint16(5434), + 4456: uint16(10059), + 4457: uint16(8268), + 4458: uint16(11567), + 4459: uint16(7246), + 4460: uint16(17485), + 4461: uint16(17447), + 4462: uint16(8029), + 4463: uint16(17443), + 4464: uint16(17448), + 4465: uint16(17450), + 4466: uint16(9048), + 4467: uint16(17453), + 4468: uint16(17449), + 4469: uint16(10547), + 4470: uint16(4906), + 4471: uint16(11050), + 4472: uint16(3901), + 4473: uint16(17452), + 4474: uint16(11612), + 4475: uint16(17451), + 4476: uint16(4174), + 4477: uint16(9547), + 4478: uint16(17454), + 4479: uint16(17461), + 4480: uint16(17455), + 4481: uint16(17462), + 4482: uint16(17458), + 4483: uint16(9818), + 4484: uint16(6953), + 4485: uint16(17460), + 4486: uint16(17457), + 4487: uint16(17463), + 4488: uint16(17456), + 4489: uint16(7203), + 4490: uint16(10756), + 4491: uint16(7211), + 4492: uint16(17459), + 4493: uint16(17471), + 4494: uint16(17467), + 4495: uint16(17470), + 4496: uint16(17468), + 4497: uint16(17472), + 4498: uint16(17466), + 4499: uint16(17440), + 4500: uint16(7986), + 4501: uint16(10026), + 4502: uint16(17469), + 4503: uint16(17464), + 4504: uint16(8192), + 4505: uint16(5681), + 4506: uint16(7178), + 4507: uint16(7684), + 4508: uint16(8213), + 4509: uint16(17475), + 4510: uint16(17477), + 4511: uint16(17478), + 4512: uint16(17474), + 4513: uint16(17476), + 4514: uint16(17465), + 4515: uint16(17473), + 4516: uint16(17481), + 4517: uint16(17480), + 4518: uint16(10841), + 4519: uint16(5642), + 4520: uint16(17479), + 4521: uint16(17483), + 4522: uint16(17482), + 4523: uint16(17486), + 4524: uint16(17488), + 4525: uint16(6683), + 4526: uint16(17484), + 4527: uint16(17489), + 4528: uint16(17490), + 4529: uint16(17491), + 4530: uint16(17497), + 4531: uint16(9242), + 4532: uint16(17493), + 4533: uint16(17492), + 4534: uint16(17494), + 4535: uint16(17495), + 4536: uint16(17496), + 4537: uint16(17498), + 4538: uint16(17499), + 4539: uint16(4907), + 4540: uint16(17500), + 4541: uint16(17501), + 4542: uint16(17664), + 4543: uint16(17665), + 4544: uint16(17666), + 4545: uint16(17667), + 4546: uint16(17668), + 4547: uint16(17669), + 4548: uint16(17671), + 4549: uint16(17670), + 4550: uint16(17672), + 4551: uint16(17673), + 4552: uint16(17674), + 4553: uint16(17677), + 4554: uint16(17675), + 4555: uint16(17676), + 4556: uint16(6464), + 4557: uint16(5682), + 4558: uint16(8757), + 4559: uint16(10002), + 4560: uint16(7247), + 4561: uint16(9772), + 4562: uint16(10060), + 4563: uint16(17678), + 4564: uint16(14156), + 4565: uint16(17679), + 4566: uint16(17681), + 4567: uint16(11332), + 4568: uint16(17680), + 4569: uint16(17683), + 4570: uint16(17682), + 4571: uint16(11314), + 4572: uint16(17684), + 4573: uint16(10077), + 4574: uint16(17685), + 4575: uint16(17688), + 4576: uint16(17687), + 4577: uint16(17686), + 4578: uint16(17689), + 4579: uint16(5649), + 4580: uint16(8193), + 4581: uint16(5152), + 4582: uint16(17693), + 4583: uint16(17690), + 4584: uint16(17691), + 4585: uint16(17694), + 4586: uint16(17695), + 4587: uint16(17692), + 4588: uint16(4104), + 4589: uint16(4358), + 4590: uint16(17697), + 4591: uint16(17698), + 4592: uint16(17699), + 4593: uint16(11329), + 4594: uint16(7179), + 4595: uint16(17701), + 4596: uint16(17700), + 4597: uint16(7752), + 4598: uint16(17702), + 4599: uint16(17703), + 4600: uint16(17704), + 4601: uint16(4932), + 4602: uint16(4908), + 4603: uint16(17705), + 4604: uint16(17706), + 4605: uint16(10812), + 4606: uint16(11330), + 4607: uint16(11315), + 4608: uint16(11798), + 4609: uint16(6188), + 4610: uint16(17709), + 4611: uint16(6963), + 4612: uint16(17708), + 4613: uint16(17710), + 4614: uint16(6920), + 4615: uint16(8496), + 4616: uint16(17711), + 4617: uint16(6187), + 4618: uint16(11062), + 4619: uint16(17712), + 4620: uint16(17713), + 4621: uint16(17714), + 4622: uint16(17715), + 4623: uint16(17716), + 4624: uint16(6921), + 4625: uint16(11084), + 4626: uint16(17718), + 4627: uint16(8734), + 4628: uint16(17717), + 4629: uint16(17720), + 4630: uint16(17719), + 4631: uint16(17721), + 4632: uint16(7962), + 4633: uint16(17722), + 4634: uint16(17723), + 4635: uint16(10520), + 4636: uint16(17724), + 4637: uint16(8270), + 4638: uint16(17725), + 4639: uint16(17726), + 4640: uint16(11613), + 4641: uint16(17729), + 4642: uint16(17728), + 4643: uint16(17727), + 4644: uint16(8975), + 4645: uint16(17730), + 4646: uint16(7685), + 4647: uint16(17731), + 4648: uint16(17732), + 4649: uint16(11799), + 4650: uint16(17733), + 4651: uint16(17734), + 4652: uint16(17736), + 4653: uint16(17735), + 4654: uint16(9988), + 4655: uint16(9560), + 4656: uint16(11805), + 4657: uint16(9992), + 4658: uint16(17738), + 4659: uint16(7474), + 4660: uint16(10249), + 4661: uint16(17739), + 4662: uint16(17737), + 4663: uint16(4909), + 4664: uint16(5939), + 4665: uint16(6727), + 4666: uint16(10061), + 4667: uint16(5897), + 4668: uint16(10786), + 4669: uint16(17742), + 4670: uint16(17740), + 4671: uint16(6189), + 4672: uint16(6190), + 4673: uint16(3912), + 4674: uint16(6471), + 4675: uint16(9784), + 4676: uint16(3902), + 4677: uint16(17747), + 4678: uint16(8735), + 4679: uint16(9783), + 4680: uint16(8506), + 4681: uint16(17749), + 4682: uint16(17745), + 4683: uint16(17748), + 4684: uint16(17743), + 4685: uint16(17746), + 4686: uint16(10757), + 4687: uint16(5940), + 4688: uint16(3932), + 4689: uint16(17744), + 4690: uint16(17751), + 4691: uint16(17752), + 4692: uint16(9496), + 4693: uint16(5402), + 4694: uint16(17925), + 4695: uint16(9756), + 4696: uint16(6728), + 4697: uint16(5403), + 4698: uint16(7975), + 4699: uint16(11813), + 4700: uint16(11021), + 4701: uint16(17750), + 4702: uint16(7987), + 4703: uint16(5170), + 4704: uint16(17753), + 4705: uint16(17755), + 4706: uint16(17754), + 4707: uint16(17756), + 4708: uint16(8709), + 4709: uint16(9757), + 4710: uint16(8976), + 4711: uint16(17922), + 4712: uint16(17921), + 4713: uint16(17757), + 4714: uint16(7732), + 4715: uint16(10308), + 4716: uint16(17924), + 4717: uint16(17923), + 4718: uint16(6191), + 4719: uint16(11826), + 4720: uint16(17940), + 4721: uint16(17928), + 4722: uint16(17929), + 4723: uint16(6991), + 4724: uint16(17927), + 4725: uint16(6231), + 4726: uint16(17926), + 4727: uint16(17930), + 4728: uint16(8977), + 4729: uint16(10497), + 4730: uint16(8194), + 4731: uint16(8507), + 4732: uint16(17934), + 4733: uint16(17935), + 4734: uint16(17931), + 4735: uint16(17932), + 4736: uint16(17933), + 4737: uint16(6192), + 4738: uint16(17941), + 4739: uint16(17937), + 4740: uint16(10309), + 4741: uint16(10827), + 4742: uint16(10247), + 4743: uint16(17936), + 4744: uint16(17939), + 4745: uint16(17938), + 4746: uint16(10787), + 4747: uint16(17942), + 4748: uint16(17943), + 4749: uint16(8214), + 4750: uint16(17944), + 4751: uint16(17946), + 4752: uint16(17950), + 4753: uint16(17947), + 4754: uint16(17945), + 4755: uint16(9758), + 4756: uint16(17948), + 4757: uint16(17949), + 4758: uint16(4369), + 4759: uint16(17956), + 4760: uint16(17951), + 4761: uint16(17952), + 4762: uint16(17953), + 4763: uint16(8448), + 4764: uint16(17955), + 4765: uint16(17954), + 4766: uint16(17957), + 4767: uint16(17958), + 4768: uint16(17959), + 4769: uint16(7714), + 4770: uint16(4424), + 4771: uint16(17960), + 4772: uint16(11574), + 4773: uint16(6922), + 4774: uint16(7180), + 4775: uint16(6729), + 4776: uint16(8758), + 4777: uint16(17961), + 4778: uint16(17962), + 4779: uint16(4112), + 4780: uint16(17963), + 4781: uint16(17964), + 4782: uint16(17965), + 4783: uint16(17966), + 4784: uint16(17967), + 4785: uint16(5404), + 4786: uint16(14601), + 4787: uint16(17968), + 4788: uint16(8004), + 4789: uint16(17969), + 4790: uint16(6954), + 4791: uint16(17970), + 4792: uint16(12047), + 4793: uint16(17971), + 4794: uint16(10557), + 4795: uint16(4923), + 4796: uint16(8195), + 4797: uint16(7223), + 4798: uint16(10320), + 4799: uint16(7181), + 4800: uint16(17972), + 4801: uint16(6193), + 4802: uint16(17973), + 4803: uint16(10027), + 4804: uint16(17987), + 4805: uint16(17975), + 4806: uint16(8488), + 4807: uint16(9812), + 4808: uint16(5918), + 4809: uint16(17974), + 4810: uint16(8196), + 4811: uint16(17976), + 4812: uint16(9049), + 4813: uint16(17978), + 4814: uint16(17977), + 4815: uint16(17980), + 4816: uint16(17979), + 4817: uint16(17981), + 4818: uint16(17983), + 4819: uint16(17982), + 4820: uint16(4910), + 4821: uint16(17984), + 4822: uint16(17985), + 4823: uint16(17986), + 4824: uint16(6416), + 4825: uint16(11560), + 4826: uint16(17988), + 4827: uint16(7686), + 4828: uint16(4175), + 4829: uint16(17989), + 4830: uint16(17990), + 4831: uint16(17991), + 4832: uint16(3921), + 4833: uint16(17992), + 4834: uint16(17993), + 4835: uint16(10310), + 4836: uint16(6950), + 4837: uint16(17995), + 4838: uint16(4616), + 4839: uint16(3857), + 4840: uint16(17994), + 4841: uint16(17997), + 4842: uint16(9773), + 4843: uint16(7715), + 4844: uint16(4405), + 4845: uint16(10758), + 4846: uint16(5692), + 4847: uint16(5435), + 4848: uint16(17996), + 4849: uint16(4425), + 4850: uint16(4866), + 4851: uint16(4176), + 4852: uint16(18001), + 4853: uint16(11593), + 4854: uint16(8508), + 4855: uint16(10275), + 4856: uint16(18013), + 4857: uint16(4406), + 4858: uint16(18011), + 4859: uint16(18009), + 4860: uint16(18000), + 4861: uint16(17998), + 4862: uint16(17999), + 4863: uint16(6978), + 4864: uint16(5451), + 4865: uint16(8790), + 4866: uint16(9520), + 4867: uint16(4144), + 4868: uint16(18003), + 4869: uint16(18002), + 4870: uint16(18008), + 4871: uint16(18004), + 4872: uint16(18007), + 4873: uint16(11055), + 4874: uint16(18006), + 4875: uint16(4407), + 4876: uint16(4700), + 4877: uint16(18010), + 4878: uint16(18012), + 4879: uint16(5683), + 4880: uint16(18178), + 4881: uint16(18187), + 4882: uint16(18188), + 4883: uint16(3850), + 4884: uint16(18195), + 4885: uint16(3920), + 4886: uint16(18186), + 4887: uint16(18185), + 4888: uint16(18180), + 4889: uint16(18179), + 4890: uint16(18177), + 4891: uint16(18176), + 4892: uint16(8770), + 4893: uint16(8538), + 4894: uint16(18182), + 4895: uint16(18181), + 4896: uint16(18184), + 4897: uint16(8271), + 4898: uint16(5684), + 4899: uint16(4128), + 4900: uint16(18183), + 4901: uint16(6194), + 4902: uint16(8272), + 4903: uint16(18201), + 4904: uint16(18202), + 4905: uint16(4408), + 4906: uint16(4365), + 4907: uint16(18199), + 4908: uint16(18189), + 4909: uint16(18197), + 4910: uint16(18204), + 4911: uint16(18198), + 4912: uint16(18196), + 4913: uint16(18005), + 4914: uint16(18194), + 4915: uint16(18190), + 4916: uint16(4911), + 4917: uint16(18192), + 4918: uint16(18203), + 4919: uint16(18193), + 4920: uint16(18205), + 4921: uint16(18191), + 4922: uint16(9819), + 4923: uint16(11336), + 4924: uint16(18200), + 4925: uint16(18222), + 4926: uint16(18214), + 4927: uint16(7770), + 4928: uint16(5157), + 4929: uint16(5436), + 4930: uint16(18209), + 4931: uint16(4410), + 4932: uint16(7475), + 4933: uint16(18212), + 4934: uint16(6457), + 4935: uint16(9264), + 4936: uint16(18217), + 4937: uint16(10573), + 4938: uint16(18208), + 4939: uint16(4409), + 4940: uint16(5941), + 4941: uint16(10248), + 4942: uint16(18218), + 4943: uint16(18206), + 4944: uint16(18215), + 4945: uint16(18225), + 4946: uint16(18210), + 4947: uint16(18211), + 4948: uint16(9497), + 4949: uint16(18216), + 4950: uint16(18213), + 4951: uint16(10759), + 4952: uint16(18219), + 4953: uint16(3903), + 4954: uint16(18207), + 4955: uint16(18221), + 4956: uint16(18220), + 4957: uint16(9802), + 4958: uint16(18227), + 4959: uint16(18238), + 4960: uint16(4701), + 4961: uint16(18241), + 4962: uint16(18223), + 4963: uint16(18228), + 4964: uint16(11341), + 4965: uint16(18237), + 4966: uint16(11316), + 4967: uint16(11529), + 4968: uint16(8791), + 4969: uint16(4682), + 4970: uint16(10321), + 4971: uint16(18243), + 4972: uint16(9472), + 4973: uint16(3856), + 4974: uint16(18236), + 4975: uint16(18232), + 4976: uint16(8273), + 4977: uint16(18226), + 4978: uint16(18234), + 4979: uint16(18239), + 4980: uint16(9739), + 4981: uint16(3849), + 4982: uint16(18231), + 4983: uint16(18240), + 4984: uint16(10327), + 4985: uint16(18235), + 4986: uint16(18230), + 4987: uint16(7476), + 4988: uint16(7182), + 4989: uint16(6923), + 4990: uint16(11063), + 4991: uint16(10278), + 4992: uint16(18246), + 4993: uint16(18255), + 4994: uint16(18233), + 4995: uint16(4694), + 4996: uint16(7511), + 4997: uint16(18244), + 4998: uint16(18249), + 4999: uint16(8274), + 5000: uint16(18245), + 5001: uint16(18252), + 5002: uint16(8766), + 5003: uint16(18253), + 5004: uint16(11317), + 5005: uint16(18242), + 5006: uint16(4631), + 5007: uint16(18248), + 5008: uint16(18251), + 5009: uint16(11019), + 5010: uint16(18254), + 5011: uint16(18247), + 5012: uint16(18250), + 5013: uint16(10760), + 5014: uint16(11776), + 5015: uint16(18258), + 5016: uint16(18265), + 5017: uint16(18257), + 5018: uint16(6946), + 5019: uint16(18224), + 5020: uint16(10541), + 5021: uint16(11009), + 5022: uint16(18264), + 5023: uint16(18263), + 5024: uint16(18259), + 5025: uint16(18260), + 5026: uint16(4117), + 5027: uint16(18262), + 5028: uint16(18256), + 5029: uint16(9012), + 5030: uint16(18261), + 5031: uint16(3933), + 5032: uint16(8449), + 5033: uint16(10530), + 5034: uint16(18266), + 5035: uint16(18432), + 5036: uint16(10040), + 5037: uint16(18269), + 5038: uint16(7477), + 5039: uint16(6952), + 5040: uint16(18434), + 5041: uint16(5405), + 5042: uint16(18435), + 5043: uint16(10328), + 5044: uint16(18268), + 5045: uint16(18229), + 5046: uint16(18267), + 5047: uint16(11822), + 5048: uint16(9473), + 5049: uint16(10322), + 5050: uint16(18442), + 5051: uint16(18448), + 5052: uint16(18449), + 5053: uint16(18436), + 5054: uint16(9813), + 5055: uint16(18446), + 5056: uint16(18438), + 5057: uint16(18440), + 5058: uint16(18450), + 5059: uint16(18439), + 5060: uint16(18443), + 5061: uint16(4177), + 5062: uint16(9540), + 5063: uint16(18444), + 5064: uint16(18447), + 5065: uint16(18437), + 5066: uint16(8197), + 5067: uint16(18441), + 5068: uint16(6662), + 5069: uint16(7716), + 5070: uint16(5647), + 5071: uint16(11091), + 5072: uint16(11096), + 5073: uint16(7249), + 5074: uint16(18454), + 5075: uint16(18452), + 5076: uint16(11821), + 5077: uint16(18451), + 5078: uint16(11348), + 5079: uint16(18453), + 5080: uint16(18455), + 5081: uint16(18456), + 5082: uint16(18459), + 5083: uint16(18457), + 5084: uint16(9474), + 5085: uint16(18458), + 5086: uint16(10028), + 5087: uint16(18445), + 5088: uint16(7250), + 5089: uint16(18460), + 5090: uint16(18465), + 5091: uint16(8275), + 5092: uint16(18464), + 5093: uint16(18433), + 5094: uint16(18466), + 5095: uint16(8232), + 5096: uint16(18461), + 5097: uint16(18463), + 5098: uint16(18462), + 5099: uint16(15376), + 5100: uint16(15361), + 5101: uint16(18468), + 5102: uint16(18467), + 5103: uint16(11349), + 5104: uint16(16667), + 5105: uint16(18469), + 5106: uint16(18470), + 5107: uint16(18471), + 5108: uint16(5942), + 5109: uint16(5171), + 5110: uint16(18473), + 5111: uint16(12348), + 5112: uint16(5204), + 5113: uint16(11545), + 5114: uint16(5458), + 5115: uint16(18474), + 5116: uint16(18475), + 5117: uint16(8781), + 5118: uint16(18476), + 5119: uint16(9561), + 5120: uint16(3865), + 5121: uint16(4418), + 5122: uint16(18481), + 5123: uint16(18482), + 5124: uint16(18477), + 5125: uint16(6684), + 5126: uint16(18478), + 5127: uint16(9761), + 5128: uint16(18479), + 5129: uint16(18480), + 5130: uint16(18490), + 5131: uint16(18484), + 5132: uint16(18487), + 5133: uint16(18483), + 5134: uint16(18485), + 5135: uint16(18486), + 5136: uint16(6967), + 5137: uint16(18488), + 5138: uint16(8736), + 5139: uint16(5685), + 5140: uint16(4641), + 5141: uint16(18491), + 5142: uint16(4638), + 5143: uint16(18496), + 5144: uint16(18492), + 5145: uint16(18495), + 5146: uint16(10009), + 5147: uint16(18493), + 5148: uint16(18494), + 5149: uint16(10279), + 5150: uint16(10041), + 5151: uint16(18497), + 5152: uint16(8540), + 5153: uint16(18507), + 5154: uint16(18503), + 5155: uint16(4426), + 5156: uint16(18501), + 5157: uint16(10761), + 5158: uint16(18502), + 5159: uint16(18499), + 5160: uint16(18500), + 5161: uint16(18505), + 5162: uint16(18508), + 5163: uint16(18506), + 5164: uint16(18504), + 5165: uint16(18498), + 5166: uint16(8759), + 5167: uint16(18515), + 5168: uint16(11017), + 5169: uint16(18513), + 5170: uint16(18514), + 5171: uint16(18509), + 5172: uint16(18511), + 5173: uint16(18512), + 5174: uint16(18510), + 5175: uint16(8005), + 5176: uint16(11800), + 5177: uint16(18519), + 5178: uint16(18520), + 5179: uint16(18688), + 5180: uint16(7689), + 5181: uint16(18522), + 5182: uint16(18525), + 5183: uint16(18517), + 5184: uint16(18516), + 5185: uint16(18689), + 5186: uint16(4411), + 5187: uint16(18523), + 5188: uint16(18690), + 5189: uint16(18524), + 5190: uint16(18521), + 5191: uint16(8978), + 5192: uint16(18518), + 5193: uint16(9799), + 5194: uint16(18694), + 5195: uint16(11290), + 5196: uint16(18693), + 5197: uint16(18692), + 5198: uint16(18701), + 5199: uint16(18695), + 5200: uint16(18703), + 5201: uint16(11333), + 5202: uint16(18706), + 5203: uint16(18697), + 5204: uint16(18698), + 5205: uint16(18702), + 5206: uint16(18705), + 5207: uint16(18704), + 5208: uint16(18696), + 5209: uint16(18699), + 5210: uint16(18716), + 5211: uint16(18709), + 5212: uint16(18707), + 5213: uint16(18708), + 5214: uint16(18713), + 5215: uint16(18714), + 5216: uint16(4617), + 5217: uint16(5153), + 5218: uint16(18712), + 5219: uint16(18691), + 5220: uint16(18711), + 5221: uint16(18715), + 5222: uint16(18710), + 5223: uint16(18717), + 5224: uint16(18719), + 5225: uint16(18718), + 5226: uint16(18721), + 5227: uint16(18720), + 5228: uint16(18489), + 5229: uint16(18725), + 5230: uint16(18722), + 5231: uint16(18723), + 5232: uint16(18724), + 5233: uint16(18726), + 5234: uint16(5707), + 5235: uint16(18728), + 5236: uint16(18727), + 5237: uint16(7183), + 5238: uint16(6195), + 5239: uint16(15622), + 5240: uint16(18729), + 5241: uint16(7216), + 5242: uint16(4632), + 5243: uint16(18730), + 5244: uint16(4145), + 5245: uint16(7478), + 5246: uint16(18731), + 5247: uint16(6196), + 5248: uint16(18732), + 5249: uint16(3904), + 5250: uint16(10268), + 5251: uint16(18733), + 5252: uint16(7753), + 5253: uint16(18740), + 5254: uint16(18737), + 5255: uint16(8782), + 5256: uint16(18738), + 5257: uint16(18735), + 5258: uint16(5437), + 5259: uint16(18734), + 5260: uint16(18741), + 5261: uint16(5653), + 5262: uint16(8509), + 5263: uint16(18747), + 5264: uint16(18743), + 5265: uint16(8468), + 5266: uint16(18742), + 5267: uint16(18745), + 5268: uint16(18736), + 5269: uint16(18746), + 5270: uint16(18748), + 5271: uint16(10062), + 5272: uint16(18744), + 5273: uint16(18749), + 5274: uint16(18751), + 5275: uint16(5938), + 5276: uint16(18739), + 5277: uint16(3872), + 5278: uint16(18750), + 5279: uint16(6458), + 5280: uint16(11605), + 5281: uint16(18752), + 5282: uint16(18753), + 5283: uint16(8276), + 5284: uint16(11521), + 5285: uint16(18754), + 5286: uint16(11284), + 5287: uint16(18755), + 5288: uint16(18756), + 5289: uint16(10563), + 5290: uint16(18757), + 5291: uint16(6431), + 5292: uint16(11522), + 5293: uint16(18762), + 5294: uint16(18763), + 5295: uint16(7479), + 5296: uint16(18761), + 5297: uint16(11334), + 5298: uint16(18758), + 5299: uint16(18760), + 5300: uint16(7964), + 5301: uint16(7773), + 5302: uint16(18759), + 5303: uint16(18764), + 5304: uint16(10498), + 5305: uint16(18766), + 5306: uint16(18765), + 5307: uint16(4683), + 5308: uint16(10762), + 5309: uint16(18767), + 5310: uint16(18779), + 5311: uint16(18769), + 5312: uint16(18770), + 5313: uint16(18771), + 5314: uint16(18772), + 5315: uint16(18776), + 5316: uint16(18777), + 5317: uint16(18775), + 5318: uint16(18773), + 5319: uint16(18768), + 5320: uint16(18774), + 5321: uint16(18778), + 5322: uint16(20246), + 5323: uint16(4359), + 5324: uint16(18781), + 5325: uint16(5438), + 5326: uint16(18780), + 5327: uint16(18945), + 5328: uint16(18944), + 5329: uint16(18947), + 5330: uint16(18946), + 5331: uint16(18948), + 5332: uint16(7184), + 5333: uint16(18949), + 5334: uint16(18950), + 5335: uint16(18951), + 5336: uint16(7965), + 5337: uint16(11318), + 5338: uint16(18952), + 5339: uint16(10499), + 5340: uint16(9765), + 5341: uint16(18953), + 5342: uint16(18954), + 5343: uint16(5898), + 5344: uint16(5131), + 5345: uint16(18955), + 5346: uint16(6730), + 5347: uint16(9760), + 5348: uint16(18956), + 5349: uint16(4655), + 5350: uint16(18957), + 5351: uint16(18959), + 5352: uint16(11350), + 5353: uint16(18958), + 5354: uint16(7717), + 5355: uint16(18960), + 5356: uint16(18961), + 5357: uint16(18962), + 5358: uint16(4912), + 5359: uint16(18963), + 5360: uint16(18964), + 5361: uint16(18965), + 5362: uint16(18966), + 5363: uint16(4656), + 5364: uint16(18967), + 5365: uint16(18968), + 5366: uint16(18969), + 5367: uint16(4433), + 5368: uint16(7687), + 5369: uint16(18970), + 5370: uint16(18971), + 5371: uint16(18972), + 5372: uint16(5919), + 5373: uint16(9050), + 5374: uint16(18973), + 5375: uint16(5686), + 5376: uint16(7733), + 5377: uint16(18976), + 5378: uint16(9475), + 5379: uint16(18975), + 5380: uint16(5648), + 5381: uint16(18974), + 5382: uint16(8534), + 5383: uint16(5132), + 5384: uint16(18977), + 5385: uint16(18978), + 5386: uint16(7480), + 5387: uint16(5708), + 5388: uint16(18979), + 5389: uint16(10763), + 5390: uint16(7998), + 5391: uint16(5205), + 5392: uint16(11092), + 5393: uint16(8233), + 5394: uint16(18980), + 5395: uint16(7718), + 5396: uint16(8783), + 5397: uint16(7481), + 5398: uint16(18981), + 5399: uint16(18984), + 5400: uint16(18985), + 5401: uint16(6429), + 5402: uint16(8481), + 5403: uint16(18983), + 5404: uint16(7482), + 5405: uint16(10269), + 5406: uint16(18982), + 5407: uint16(6731), + 5408: uint16(4146), + 5409: uint16(18989), + 5410: uint16(5687), + 5411: uint16(6733), + 5412: uint16(6732), + 5413: uint16(11820), + 5414: uint16(18988), + 5415: uint16(18987), + 5416: uint16(8198), + 5417: uint16(5164), + 5418: uint16(11810), + 5419: uint16(4633), + 5420: uint16(7483), + 5421: uint16(18986), + 5422: uint16(18991), + 5423: uint16(18992), + 5424: uint16(18990), + 5425: uint16(5943), + 5426: uint16(11295), + 5427: uint16(6734), + 5428: uint16(9734), + 5429: uint16(18995), + 5430: uint16(7967), + 5431: uint16(8737), + 5432: uint16(11285), + 5433: uint16(18998), + 5434: uint16(5963), + 5435: uint16(7966), + 5436: uint16(18994), + 5437: uint16(18999), + 5438: uint16(5964), + 5439: uint16(18996), + 5440: uint16(18997), + 5441: uint16(18993), + 5442: uint16(8001), + 5443: uint16(9512), + 5444: uint16(8718), + 5445: uint16(4412), + 5446: uint16(10063), + 5447: uint16(5154), + 5448: uint16(8979), + 5449: uint16(19002), + 5450: uint16(19000), + 5451: uint16(8747), + 5452: uint16(7968), + 5453: uint16(4913), + 5454: uint16(19001), + 5455: uint16(7738), + 5456: uint16(11561), + 5457: uint16(11807), + 5458: uint16(19003), + 5459: uint16(19014), + 5460: uint16(8980), + 5461: uint16(19013), + 5462: uint16(19010), + 5463: uint16(19018), + 5464: uint16(19011), + 5465: uint16(19007), + 5466: uint16(9051), + 5467: uint16(19006), + 5468: uint16(19004), + 5469: uint16(11264), + 5470: uint16(6735), + 5471: uint16(19008), + 5472: uint16(19005), + 5473: uint16(19012), + 5474: uint16(7251), + 5475: uint16(5920), + 5476: uint16(8537), + 5477: uint16(10788), + 5478: uint16(4153), + 5479: uint16(3905), + 5480: uint16(9476), + 5481: uint16(19016), + 5482: uint16(19015), + 5483: uint16(9541), + 5484: uint16(19020), + 5485: uint16(19009), + 5486: uint16(19019), + 5487: uint16(19021), + 5488: uint16(5899), + 5489: uint16(19017), + 5490: uint16(6197), + 5491: uint16(6964), + 5492: uint16(19022), + 5493: uint16(11319), + 5494: uint16(19025), + 5495: uint16(19028), + 5496: uint16(19026), + 5497: uint16(10260), + 5498: uint16(19023), + 5499: uint16(5439), + 5500: uint16(19027), + 5501: uint16(19029), + 5502: uint16(19033), + 5503: uint16(19030), + 5504: uint16(19032), + 5505: uint16(19031), + 5506: uint16(19034), + 5507: uint16(6928), + 5508: uint16(19036), + 5509: uint16(19035), + 5510: uint16(10311), + 5511: uint16(19200), + 5512: uint16(5688), + 5513: uint16(19037), + 5514: uint16(19201), + 5515: uint16(19202), + 5516: uint16(5155), + 5517: uint16(17696), + 5518: uint16(7512), + 5519: uint16(19203), + 5520: uint16(5965), + 5521: uint16(19204), + 5522: uint16(19205), + 5523: uint16(6685), + 5524: uint16(14637), + 5525: uint16(19206), + 5526: uint16(19207), + 5527: uint16(7185), + 5528: uint16(19208), + 5529: uint16(19209), + 5530: uint16(19210), + 5531: uint16(19211), + 5532: uint16(19212), + 5533: uint16(8714), + 5534: uint16(19213), + 5535: uint16(19215), + 5536: uint16(19214), + 5537: uint16(9477), + 5538: uint16(19216), + 5539: uint16(10764), + 5540: uint16(19217), + 5541: uint16(19218), + 5542: uint16(19219), + 5543: uint16(19220), + 5544: uint16(9529), + 5545: uint16(7484), + 5546: uint16(19221), + 5547: uint16(6218), + 5548: uint16(12045), + 5549: uint16(19222), + 5550: uint16(19223), + 5551: uint16(10270), + 5552: uint16(19224), + 5553: uint16(19232), + 5554: uint16(19225), + 5555: uint16(19227), + 5556: uint16(19226), + 5557: uint16(19228), + 5558: uint16(10789), + 5559: uint16(19229), + 5560: uint16(19230), + 5561: uint16(19231), + 5562: uint16(19233), + 5563: uint16(4620), + 5564: uint16(9030), + 5565: uint16(10312), + 5566: uint16(6465), + 5567: uint16(6198), + 5568: uint16(10286), + 5569: uint16(4414), + 5570: uint16(10029), + 5571: uint16(19236), + 5572: uint16(4914), + 5573: uint16(7988), + 5574: uint16(19235), + 5575: uint16(19240), + 5576: uint16(8792), + 5577: uint16(11074), + 5578: uint16(19238), + 5579: uint16(19239), + 5580: uint16(5133), + 5581: uint16(19241), + 5582: uint16(9794), + 5583: uint16(8510), + 5584: uint16(10064), + 5585: uint16(9244), + 5586: uint16(19237), + 5587: uint16(10790), + 5588: uint16(4427), + 5589: uint16(19243), + 5590: uint16(11783), + 5591: uint16(8993), + 5592: uint16(11812), + 5593: uint16(6736), + 5594: uint16(19242), + 5595: uint16(8464), + 5596: uint16(19259), + 5597: uint16(8199), + 5598: uint16(9559), + 5599: uint16(10287), + 5600: uint16(19246), + 5601: uint16(6686), + 5602: uint16(6737), + 5603: uint16(7485), + 5604: uint16(9796), + 5605: uint16(5900), + 5606: uint16(19245), + 5607: uint16(19244), + 5608: uint16(10313), + 5609: uint16(6944), + 5610: uint16(9265), + 5611: uint16(19248), + 5612: uint16(19249), + 5613: uint16(6199), + 5614: uint16(19247), + 5615: uint16(19250), + 5616: uint16(19251), + 5617: uint16(19253), + 5618: uint16(8450), + 5619: uint16(19252), + 5620: uint16(4933), + 5621: uint16(19255), + 5622: uint16(19254), + 5623: uint16(19256), + 5624: uint16(19258), + 5625: uint16(19260), + 5626: uint16(19261), + 5627: uint16(7989), + 5628: uint16(6958), + 5629: uint16(19262), + 5630: uint16(4657), + 5631: uint16(19263), + 5632: uint16(8277), + 5633: uint16(19264), + 5634: uint16(19265), + 5635: uint16(10314), + 5636: uint16(5134), + 5637: uint16(19266), + 5638: uint16(8981), + 5639: uint16(4154), + 5640: uint16(19267), + 5641: uint16(6992), + 5642: uint16(7765), + 5643: uint16(8460), + 5644: uint16(19270), + 5645: uint16(19269), + 5646: uint16(19268), + 5647: uint16(19276), + 5648: uint16(19274), + 5649: uint16(19271), + 5650: uint16(19273), + 5651: uint16(19272), + 5652: uint16(19275), + 5653: uint16(5206), + 5654: uint16(19279), + 5655: uint16(7990), + 5656: uint16(19280), + 5657: uint16(5944), + 5658: uint16(19277), + 5659: uint16(19278), + 5660: uint16(11784), + 5661: uint16(8982), + 5662: uint16(8200), + 5663: uint16(19281), + 5664: uint16(19284), + 5665: uint16(19282), + 5666: uint16(19283), + 5667: uint16(11320), + 5668: uint16(9478), + 5669: uint16(19287), + 5670: uint16(19285), + 5671: uint16(19286), + 5672: uint16(19288), + 5673: uint16(19464), + 5674: uint16(19291), + 5675: uint16(19292), + 5676: uint16(19290), + 5677: uint16(19289), + 5678: uint16(9052), + 5679: uint16(19456), + 5680: uint16(19460), + 5681: uint16(19457), + 5682: uint16(19293), + 5683: uint16(19458), + 5684: uint16(19459), + 5685: uint16(19466), + 5686: uint16(19461), + 5687: uint16(7991), + 5688: uint16(19463), + 5689: uint16(19465), + 5690: uint16(19462), + 5691: uint16(19468), + 5692: uint16(7186), + 5693: uint16(19467), + 5694: uint16(19469), + 5695: uint16(19470), + 5696: uint16(19473), + 5697: uint16(19472), + 5698: uint16(19471), + 5699: uint16(19475), + 5700: uint16(19474), + 5701: uint16(11093), + 5702: uint16(19477), + 5703: uint16(19476), + 5704: uint16(19478), + 5705: uint16(19479), + 5706: uint16(19481), + 5707: uint16(19480), + 5708: uint16(7719), + 5709: uint16(19482), + 5710: uint16(5452), + 5711: uint16(19483), + 5712: uint16(19485), + 5713: uint16(19486), + 5714: uint16(19487), + 5715: uint16(19484), + 5716: uint16(19488), + 5717: uint16(6965), + 5718: uint16(19489), + 5719: uint16(5135), + 5720: uint16(5650), + 5721: uint16(5901), + 5722: uint16(19490), + 5723: uint16(9551), + 5724: uint16(9245), + 5725: uint16(19491), + 5726: uint16(19494), + 5727: uint16(6931), + 5728: uint16(19493), + 5729: uint16(19492), + 5730: uint16(5689), + 5731: uint16(19495), + 5732: uint16(4658), + 5733: uint16(19497), + 5734: uint16(6459), + 5735: uint16(19496), + 5736: uint16(19505), + 5737: uint16(19499), + 5738: uint16(19501), + 5739: uint16(10564), + 5740: uint16(19498), + 5741: uint16(19500), + 5742: uint16(19504), + 5743: uint16(19502), + 5744: uint16(5136), + 5745: uint16(19503), + 5746: uint16(19506), + 5747: uint16(9785), + 5748: uint16(11575), + 5749: uint16(7187), + 5750: uint16(19507), + 5751: uint16(11265), + 5752: uint16(19509), + 5753: uint16(19508), + 5754: uint16(19512), + 5755: uint16(11296), + 5756: uint16(19511), + 5757: uint16(4684), + 5758: uint16(19510), + 5759: uint16(19515), + 5760: uint16(19514), + 5761: uint16(19513), + 5762: uint16(9233), + 5763: uint16(19516), + 5764: uint16(19517), + 5765: uint16(19518), + 5766: uint16(6219), + 5767: uint16(5636), + 5768: uint16(19519), + 5769: uint16(19520), + 5770: uint16(19521), + 5771: uint16(7720), + 5772: uint16(19522), + 5773: uint16(6924), + 5774: uint16(19523), + 5775: uint16(19524), + 5776: uint16(12544), + 5777: uint16(12381), + 5778: uint16(19525), + 5779: uint16(17487), + 5780: uint16(19526), + 5781: uint16(8707), + 5782: uint16(7690), + 5783: uint16(9759), + 5784: uint16(19527), + 5785: uint16(10548), + 5786: uint16(9011), + 5787: uint16(6237), + 5788: uint16(8712), + 5789: uint16(4105), + 5790: uint16(10839), + 5791: uint16(7734), + 5792: uint16(5693), + 5793: uint16(5440), + 5794: uint16(10549), + 5795: uint16(19528), + 5796: uint16(19530), + 5797: uint16(19529), + 5798: uint16(4415), + 5799: uint16(9557), + 5800: uint16(19531), + 5801: uint16(9814), + 5802: uint16(9234), + 5803: uint16(19532), + 5804: uint16(7217), + 5805: uint16(19534), + 5806: uint16(11041), + 5807: uint16(19549), + 5808: uint16(19536), + 5809: uint16(19537), + 5810: uint16(9000), + 5811: uint16(8511), + 5812: uint16(8278), + 5813: uint16(9479), + 5814: uint16(19535), + 5815: uint16(5172), + 5816: uint16(19544), + 5817: uint16(19541), + 5818: uint16(19716), + 5819: uint16(9480), + 5820: uint16(8767), + 5821: uint16(19538), + 5822: uint16(9053), + 5823: uint16(9266), + 5824: uint16(19539), + 5825: uint16(19543), + 5826: uint16(7743), + 5827: uint16(9798), + 5828: uint16(9003), + 5829: uint16(7969), + 5830: uint16(19542), + 5831: uint16(8461), + 5832: uint16(8451), + 5833: uint16(19540), + 5834: uint16(3848), + 5835: uint16(11777), + 5836: uint16(19545), + 5837: uint16(8512), + 5838: uint16(7188), + 5839: uint16(7721), + 5840: uint16(19547), + 5841: uint16(19546), + 5842: uint16(3918), + 5843: uint16(19548), + 5844: uint16(10254), + 5845: uint16(19718), + 5846: uint16(9530), + 5847: uint16(7754), + 5848: uint16(8760), + 5849: uint16(5463), + 5850: uint16(19717), + 5851: uint16(11286), + 5852: uint16(4126), + 5853: uint16(10550), + 5854: uint16(4416), + 5855: uint16(19712), + 5856: uint16(19713), + 5857: uint16(19714), + 5858: uint16(19715), + 5859: uint16(9498), + 5860: uint16(8706), + 5861: uint16(3906), + 5862: uint16(19719), + 5863: uint16(19720), + 5864: uint16(21250), + 5865: uint16(8476), + 5866: uint16(19721), + 5867: uint16(4178), + 5868: uint16(8235), + 5869: uint16(5902), + 5870: uint16(11321), + 5871: uint16(19722), + 5872: uint16(9227), + 5873: uint16(8279), + 5874: uint16(6966), + 5875: uint16(19723), + 5876: uint16(19726), + 5877: uint16(7236), + 5878: uint16(19724), + 5879: uint16(8202), + 5880: uint16(8201), + 5881: uint16(3907), + 5882: uint16(11562), + 5883: uint16(19728), + 5884: uint16(10065), + 5885: uint16(19730), + 5886: uint16(19729), + 5887: uint16(19727), + 5888: uint16(16963), + 5889: uint16(4915), + 5890: uint16(19533), + 5891: uint16(19732), + 5892: uint16(19731), + 5893: uint16(19733), + 5894: uint16(11287), + 5895: uint16(9536), + 5896: uint16(10765), + 5897: uint16(19734), + 5898: uint16(6968), + 5899: uint16(19735), + 5900: uint16(19736), + 5901: uint16(19737), + 5902: uint16(9216), + 5903: uint16(3913), + 5904: uint16(6200), + 5905: uint16(11801), + 5906: uint16(19741), + 5907: uint16(5651), + 5908: uint16(19738), + 5909: uint16(19739), + 5910: uint16(10323), + 5911: uint16(4659), + 5912: uint16(11288), + 5913: uint16(5406), + 5914: uint16(9267), + 5915: uint16(19742), + 5916: uint16(19743), + 5917: uint16(19744), + 5918: uint16(9217), + 5919: uint16(19746), + 5920: uint16(19745), + 5921: uint16(9522), + 5922: uint16(19747), + 5923: uint16(7189), + 5924: uint16(6975), + 5925: uint16(9786), + 5926: uint16(8784), + 5927: uint16(6993), + 5928: uint16(7755), + 5929: uint16(19748), + 5930: uint16(19749), + 5931: uint16(7740), + 5932: uint16(19750), + 5933: uint16(19751), + 5934: uint16(19752), + 5935: uint16(11342), + 5936: uint16(7190), + 5937: uint16(19754), + 5938: uint16(19753), + 5939: uint16(6201), + 5940: uint16(6226), + 5941: uint16(6687), + 5942: uint16(19757), + 5943: uint16(7237), + 5944: uint16(19756), + 5945: uint16(19755), + 5946: uint16(8520), + 5947: uint16(5966), + 5948: uint16(7970), + 5949: uint16(9999), + 5950: uint16(7192), + 5951: uint16(19758), + 5952: uint16(7486), + 5953: uint16(19761), + 5954: uint16(19759), + 5955: uint16(19760), + 5956: uint16(19763), + 5957: uint16(19762), + 5958: uint16(7513), + 5959: uint16(19764), + 5960: uint16(19765), + 5961: uint16(19766), + 5962: uint16(10031), + 5963: uint16(6450), + 5964: uint16(6976), + 5965: uint16(19767), + 5966: uint16(19768), + 5967: uint16(11523), + 5968: uint16(7204), + 5969: uint16(11085), + 5970: uint16(11563), + 5971: uint16(19769), + 5972: uint16(5441), + 5973: uint16(19770), + 5974: uint16(9218), + 5975: uint16(19773), + 5976: uint16(4695), + 5977: uint16(7722), + 5978: uint16(19771), + 5979: uint16(19772), + 5980: uint16(9023), + 5981: uint16(10804), + 5982: uint16(5467), + 5983: uint16(19775), + 5984: uint16(19776), + 5985: uint16(19774), + 5986: uint16(19778), + 5987: uint16(9534), + 5988: uint16(4642), + 5989: uint16(19782), + 5990: uint16(19779), + 5991: uint16(19781), + 5992: uint16(19777), + 5993: uint16(20014), + 5994: uint16(19780), + 5995: uint16(11594), + 5996: uint16(5945), + 5997: uint16(19790), + 5998: uint16(9235), + 5999: uint16(19785), + 6000: uint16(19788), + 6001: uint16(19786), + 6002: uint16(19791), + 6003: uint16(19792), + 6004: uint16(19784), + 6005: uint16(19797), + 6006: uint16(4179), + 6007: uint16(19783), + 6008: uint16(9996), + 6009: uint16(19787), + 6010: uint16(7487), + 6011: uint16(6202), + 6012: uint16(10791), + 6013: uint16(5443), + 6014: uint16(7205), + 6015: uint16(9499), + 6016: uint16(8204), + 6017: uint16(19795), + 6018: uint16(19789), + 6019: uint16(19794), + 6020: uint16(11042), + 6021: uint16(8983), + 6022: uint16(19796), + 6023: uint16(19793), + 6024: uint16(8203), + 6025: uint16(19800), + 6026: uint16(19799), + 6027: uint16(19798), + 6028: uint16(10766), + 6029: uint16(7258), + 6030: uint16(19801), + 6031: uint16(10558), + 6032: uint16(4147), + 6033: uint16(10277), + 6034: uint16(8785), + 6035: uint16(5207), + 6036: uint16(19803), + 6037: uint16(6204), + 6038: uint16(6667), + 6039: uint16(19802), + 6040: uint16(7756), + 6041: uint16(7757), + 6042: uint16(19968), + 6043: uint16(19970), + 6044: uint16(7514), + 6045: uint16(19969), + 6046: uint16(19971), + 6047: uint16(5426), + 6048: uint16(10276), + 6049: uint16(6977), + 6050: uint16(11778), + 6051: uint16(19805), + 6052: uint16(6487), + 6053: uint16(11806), + 6054: uint16(19973), + 6055: uint16(19972), + 6056: uint16(19974), + 6057: uint16(19804), + 6058: uint16(9544), + 6059: uint16(9268), + 6060: uint16(9014), + 6061: uint16(19979), + 6062: uint16(8738), + 6063: uint16(19975), + 6064: uint16(19976), + 6065: uint16(5644), + 6066: uint16(19978), + 6067: uint16(5903), + 6068: uint16(19977), + 6069: uint16(7488), + 6070: uint16(4696), + 6071: uint16(19983), + 6072: uint16(6430), + 6073: uint16(8280), + 6074: uint16(9001), + 6075: uint16(4634), + 6076: uint16(19981), + 6077: uint16(19982), + 6078: uint16(8994), + 6079: uint16(19980), + 6080: uint16(19984), + 6081: uint16(19990), + 6082: uint16(19993), + 6083: uint16(19992), + 6084: uint16(9228), + 6085: uint16(19985), + 6086: uint16(19986), + 6087: uint16(19989), + 6088: uint16(19991), + 6089: uint16(5407), + 6090: uint16(19994), + 6091: uint16(19988), + 6092: uint16(19987), + 6093: uint16(19998), + 6094: uint16(19999), + 6095: uint16(20000), + 6096: uint16(19997), + 6097: uint16(19996), + 6098: uint16(7489), + 6099: uint16(9481), + 6100: uint16(19995), + 6101: uint16(20004), + 6102: uint16(20002), + 6103: uint16(20003), + 6104: uint16(20001), + 6105: uint16(8535), + 6106: uint16(20005), + 6107: uint16(20006), + 6108: uint16(20008), + 6109: uint16(4916), + 6110: uint16(20007), + 6111: uint16(11097), + 6112: uint16(20019), + 6113: uint16(20009), + 6114: uint16(20012), + 6115: uint16(20010), + 6116: uint16(20011), + 6117: uint16(20013), + 6118: uint16(20015), + 6119: uint16(20016), + 6120: uint16(20017), + 6121: uint16(20020), + 6122: uint16(20018), + 6123: uint16(20021), + 6124: uint16(20023), + 6125: uint16(20022), + 6126: uint16(8984), + 6127: uint16(11078), + 6128: uint16(20024), + 6129: uint16(8205), + 6130: uint16(20025), + 6131: uint16(10531), + 6132: uint16(20026), + 6133: uint16(4618), + 6134: uint16(4123), + 6135: uint16(4918), + 6136: uint16(4917), + 6137: uint16(20027), + 6138: uint16(20028), + 6139: uint16(20029), + 6140: uint16(20030), + 6141: uint16(20031), + 6142: uint16(4919), + 6143: uint16(4660), + 6144: uint16(6205), + 6145: uint16(10005), + 6146: uint16(20033), + 6147: uint16(20032), + 6148: uint16(20034), + 6149: uint16(4155), + 6150: uint16(20037), + 6151: uint16(20036), + 6152: uint16(20035), + 6153: uint16(20038), + 6154: uint16(20041), + 6155: uint16(3878), + 6156: uint16(20039), + 6157: uint16(20043), + 6158: uint16(20042), + 6159: uint16(20045), + 6160: uint16(20044), + 6161: uint16(20046), + 6162: uint16(9485), + 6163: uint16(20047), + 6164: uint16(20048), + 6165: uint16(20050), + 6166: uint16(20049), + 6167: uint16(10315), + 6168: uint16(20051), + 6169: uint16(20052), + 6170: uint16(6468), + 6171: uint16(20053), + 6172: uint16(20054), + 6173: uint16(10792), + 6174: uint16(8234), + 6175: uint16(3843), + 6176: uint16(8490), + 6177: uint16(20055), + 6178: uint16(10316), + 6179: uint16(20058), + 6180: uint16(20056), + 6181: uint16(6206), + 6182: uint16(20057), + 6183: uint16(5921), + 6184: uint16(10532), + 6185: uint16(20060), + 6186: uint16(20224), + 6187: uint16(20061), + 6188: uint16(20225), + 6189: uint16(4096), + 6190: uint16(7735), + 6191: uint16(7259), + 6192: uint16(4920), + 6193: uint16(20226), + 6194: uint16(9797), + 6195: uint16(20228), + 6196: uint16(4097), + 6197: uint16(20227), + 6198: uint16(8995), + 6199: uint16(11564), + 6200: uint16(9482), + 6201: uint16(20059), + 6202: uint16(11525), + 6203: uint16(5904), + 6204: uint16(11322), + 6205: uint16(5464), + 6206: uint16(11539), + 6207: uint16(5639), + 6208: uint16(8513), + 6209: uint16(17920), + 6210: uint16(20229), + 6211: uint16(4619), + 6212: uint16(7758), + 6213: uint16(4661), + 6214: uint16(20231), + 6215: uint16(20232), + 6216: uint16(20230), + 6217: uint16(5699), + 6218: uint16(6460), + 6219: uint16(7490), + 6220: uint16(4098), + 6221: uint16(11576), + 6222: uint16(20234), + 6223: uint16(19725), + 6224: uint16(20233), + 6225: uint16(20237), + 6226: uint16(20235), + 6227: uint16(20236), + 6228: uint16(20238), + 6229: uint16(20239), + 6230: uint16(11595), + 6231: uint16(20240), + 6232: uint16(20241), + 6233: uint16(7976), + 6234: uint16(10010), + 6235: uint16(7772), + 6236: uint16(4934), + 6237: uint16(11289), + 6238: uint16(4428), + 6239: uint16(7191), + 6240: uint16(5946), + 6241: uint16(20244), + 6242: uint16(20243), + 6243: uint16(6738), + 6244: uint16(20245), + 6245: uint16(20242), + 6246: uint16(6663), + 6247: uint16(20249), + 6248: uint16(18700), + 6249: uint16(12597), + 6250: uint16(7766), + 6251: uint16(20247), + 6252: uint16(11524), + 6253: uint16(9552), + 6254: uint16(4106), + 6255: uint16(8002), + 6256: uint16(6933), + 6257: uint16(10518), + 6258: uint16(4127), + 6259: uint16(11596), + 6260: uint16(11338), + 6261: uint16(20250), + 6262: uint16(9252), + 6263: uint16(7002), + 6264: uint16(20251), + 6265: uint16(20252), + 6266: uint16(7723), + 6267: uint16(20253), + 6268: uint16(11597), + 6269: uint16(20248), + 6270: uint16(20255), + 6271: uint16(20257), + 6272: uint16(20256), + 6273: uint16(20254), + 6274: uint16(20258), + 6275: uint16(20259), + 6276: uint16(8281), + 6277: uint16(4417), + 6278: uint16(20260), + 6279: uint16(11031), + 6280: uint16(20261), + 6281: uint16(20262), + 6282: uint16(11785), + 6283: uint16(14864), + 6284: uint16(20263), + 6285: uint16(20264), + 6286: uint16(20265), + 6287: uint16(20269), + 6288: uint16(20266), + 6289: uint16(20267), + 6290: uint16(20268), + 6291: uint16(20270), + 6292: uint16(7971), + 6293: uint16(11094), + 6294: uint16(7972), + 6295: uint16(20271), + 6296: uint16(10066), + 6297: uint16(20272), + 6298: uint16(21042), + 6299: uint16(11051), + 6300: uint16(20273), + 6301: uint16(20274), + 6302: uint16(20275), + 6303: uint16(4662), + 6304: uint16(20277), + 6305: uint16(7736), + 6306: uint16(20278), + 6307: uint16(5635), + 6308: uint16(20279), + 6309: uint16(20283), + 6310: uint16(20281), + 6311: uint16(20282), + 6312: uint16(4690), + 6313: uint16(20280), + 6314: uint16(20284), + 6315: uint16(20285), + 6316: uint16(3879), + 6317: uint16(20286), + 6318: uint16(20287), + 6319: uint16(7491), + 6320: uint16(20288), + 6321: uint16(5158), + 6322: uint16(20291), + 6323: uint16(20290), + 6324: uint16(20289), + 6325: uint16(19024), + 6326: uint16(10555), + 6327: uint16(20292), + 6328: uint16(20293), + 6329: uint16(20294), + 6330: uint16(20295), + 6331: uint16(20296), + 6332: uint16(20297), + 6333: uint16(4921), + 6334: uint16(20298), + 6335: uint16(20299), + 6336: uint16(9730), + 6337: uint16(20301), + 6338: uint16(4378), + 6339: uint16(20304), + 6340: uint16(20303), + 6341: uint16(4099), + 6342: uint16(5408), + 6343: uint16(10534), + 6344: uint16(8985), + 6345: uint16(6401), + 6346: uint16(6207), + 6347: uint16(7238), + 6348: uint16(7739), + 6349: uint16(20306), + 6350: uint16(20305), + 6351: uint16(11297), + 6352: uint16(4935), + 6353: uint16(10033), + 6354: uint16(9531), + 6355: uint16(7771), + 6356: uint16(11565), + 6357: uint16(5690), + 6358: uint16(20309), + 6359: uint16(20308), + 6360: uint16(10794), + 6361: uint16(9483), + 6362: uint16(4143), + 6363: uint16(20310), + 6364: uint16(20307), + 6365: uint16(10288), + 6366: uint16(11337), + 6367: uint16(20311), + 6368: uint16(20312), + 6369: uint16(20314), + 6370: uint16(8521), + 6371: uint16(4666), + 6372: uint16(4667), + 6373: uint16(20313), + 6374: uint16(4936), + 6375: uint16(5905), + 6376: uint16(4937), + 6377: uint16(9246), + 6378: uint16(11583), + 6379: uint16(5947), + 6380: uint16(20315), + 6381: uint16(20316), + 6382: uint16(20317), + 6383: uint16(20480), + 6384: uint16(20482), + 6385: uint16(20481), + 6386: uint16(10326), + 6387: uint16(20483), + 6388: uint16(20484), + 6389: uint16(20485), + 6390: uint16(20486), + 6391: uint16(20488), + 6392: uint16(20487), + 6393: uint16(20489), + 6394: uint16(10067), + 6395: uint16(17707), + 6396: uint16(7688), + 6397: uint16(5137), + 6398: uint16(20490), + 6399: uint16(20491), + 6400: uint16(12555), + 6401: uint16(15386), + 6402: uint16(10034), + 6403: uint16(3930), + 6404: uint16(3866), + 6405: uint16(6739), + 6406: uint16(10767), + 6407: uint16(7517), + 6408: uint16(20492), + 6409: uint16(11070), + 6410: uint16(20493), + 6411: uint16(11323), + 6412: uint16(4129), + 6413: uint16(6688), + 6414: uint16(20494), + 6415: uint16(4429), + 6416: uint16(20495), + 6417: uint16(20496), + 6418: uint16(20498), + 6419: uint16(20499), + 6420: uint16(20501), + 6421: uint16(20497), + 6422: uint16(20500), + 6423: uint16(4922), + 6424: uint16(20502), + 6425: uint16(20503), + 6426: uint16(20504), + 6427: uint16(20505), + 6428: uint16(20506), + 6429: uint16(20508), + 6430: uint16(20507), + 6431: uint16(20510), + 6432: uint16(20513), + 6433: uint16(20509), + 6434: uint16(20511), + 6435: uint16(20512), + 6436: uint16(20514), + 6437: uint16(5409), + 6438: uint16(6994), + 6439: uint16(20515), + 6440: uint16(20516), + 6441: uint16(6208), + 6442: uint16(20517), + 6443: uint16(4637), + 6444: uint16(9774), + 6445: uint16(20518), + 6446: uint16(20519), + 6447: uint16(8761), + 6448: uint16(9546), + 6449: uint16(20520), + 6450: uint16(9820), + 6451: uint16(8491), + 6452: uint16(4151), + 6453: uint16(5453), + 6454: uint16(5454), + 6455: uint16(8786), + 6456: uint16(20525), + 6457: uint16(5455), + 6458: uint16(4430), + 6459: uint16(20524), + 6460: uint16(20522), + 6461: uint16(20523), + 6462: uint16(20521), + 6463: uint16(20535), + 6464: uint16(20526), + 6465: uint16(20527), + 6466: uint16(20528), + 6467: uint16(20529), + 6468: uint16(20531), + 6469: uint16(20530), + 6470: uint16(7224), + 6471: uint16(20532), + 6472: uint16(20534), + 6473: uint16(5138), + 6474: uint16(20533), + 6475: uint16(8282), + 6476: uint16(5906), + 6477: uint16(20536), + 6478: uint16(8492), + 6479: uint16(20537), + 6480: uint16(9484), + 6481: uint16(20538), + 6482: uint16(20543), + 6483: uint16(20541), + 6484: uint16(20540), + 6485: uint16(20542), + 6486: uint16(20539), + 6487: uint16(20545), + 6488: uint16(20544), + 6489: uint16(20547), + 6490: uint16(5410), + 6491: uint16(20546), + 6492: uint16(20548), + 6493: uint16(20549), + 6494: uint16(20551), + 6495: uint16(20550), + 6496: uint16(20552), + 6497: uint16(20554), + 6498: uint16(20553), + 6499: uint16(6235), + 6500: uint16(20555), + 6501: uint16(20556), + 6502: uint16(4635), + 6503: uint16(20557), + 6504: uint16(20558), + 6505: uint16(7760), + 6506: uint16(20559), + 6507: uint16(20560), + 6508: uint16(20561), + 6509: uint16(20562), + 6510: uint16(6209), + 6511: uint16(20563), + 6512: uint16(20564), + 6513: uint16(20565), + 6514: uint16(20566), + 6515: uint16(20567), + 6516: uint16(10000), + 6517: uint16(20569), + 6518: uint16(10245), + 6519: uint16(20570), + 6520: uint16(20568), + 6521: uint16(20572), + 6522: uint16(20571), + 6523: uint16(20573), + 6524: uint16(20736), + 6525: uint16(20737), + 6526: uint16(20738), + 6527: uint16(20739), + 6528: uint16(20740), + 6529: uint16(20741), + 6530: uint16(20742), + 6531: uint16(20743), + 6532: uint16(20744), + 6533: uint16(20745), + 6534: uint16(20746), + 6535: uint16(20747), + 6536: uint16(20748), + 6537: uint16(20749), + 6538: uint16(15380), + 6539: uint16(20750), + 6540: uint16(17239), + 6541: uint16(5139), + 6542: uint16(4608), + 6543: uint16(6417), + 6544: uint16(20752), + 6545: uint16(20751), + 6546: uint16(11012), + 6547: uint16(20754), + 6548: uint16(20755), + 6549: uint16(20753), + 6550: uint16(20756), + 6551: uint16(10817), + 6552: uint16(20757), + 6553: uint16(5210), + 6554: uint16(11780), + 6555: uint16(20758), + 6556: uint16(20760), + 6557: uint16(3869), + 6558: uint16(20761), + 6559: uint16(10506), + 6560: uint16(20759), + 6561: uint16(20762), + 6562: uint16(20763), + 6563: uint16(20764), + 6564: uint16(20765), + 6565: uint16(20766), + 6566: uint16(10829), + 6567: uint16(6668), + 6568: uint16(6489), + 6569: uint16(8206), + 6570: uint16(20767), + 6571: uint16(20770), + 6572: uint16(20768), + 6573: uint16(20771), + 6574: uint16(5968), + 6575: uint16(20769), + 6576: uint16(20772), + 6577: uint16(20773), + 6578: uint16(20774), + 6579: uint16(20778), + 6580: uint16(6665), + 6581: uint16(8515), + 6582: uint16(20779), + 6583: uint16(20776), + 6584: uint16(20775), + 6585: uint16(20777), + 6586: uint16(5694), + 6587: uint16(20783), + 6588: uint16(20782), + 6589: uint16(20781), + 6590: uint16(3858), + 6591: uint16(20793), + 6592: uint16(20789), + 6593: uint16(20790), + 6594: uint16(20786), + 6595: uint16(20792), + 6596: uint16(20788), + 6597: uint16(4673), + 6598: uint16(11819), + 6599: uint16(20791), + 6600: uint16(20787), + 6601: uint16(20785), + 6602: uint16(20784), + 6603: uint16(20795), + 6604: uint16(20798), + 6605: uint16(20797), + 6606: uint16(20796), + 6607: uint16(10280), + 6608: uint16(20794), + 6609: uint16(3922), + 6610: uint16(20799), + 6611: uint16(20801), + 6612: uint16(4686), + 6613: uint16(20780), + 6614: uint16(4118), + 6615: uint16(20803), + 6616: uint16(20802), + 6617: uint16(20800), + 6618: uint16(8716), + 6619: uint16(10831), + 6620: uint16(11577), + 6621: uint16(20804), + 6622: uint16(20805), + 6623: uint16(20806), + 6624: uint16(20807), + 6625: uint16(20808), + 6626: uint16(8986), + 6627: uint16(20809), + 6628: uint16(10006), + 6629: uint16(20814), + 6630: uint16(20810), + 6631: uint16(20811), + 6632: uint16(10768), + 6633: uint16(11043), + 6634: uint16(9519), + 6635: uint16(20815), + 6636: uint16(20816), + 6637: uint16(9501), + 6638: uint16(20813), + 6639: uint16(20812), + 6640: uint16(4361), + 6641: uint16(20824), + 6642: uint16(20823), + 6643: uint16(4180), + 6644: uint16(20821), + 6645: uint16(20820), + 6646: uint16(20818), + 6647: uint16(4698), + 6648: uint16(20817), + 6649: uint16(6929), + 6650: uint16(4360), + 6651: uint16(6210), + 6652: uint16(20827), + 6653: uint16(20826), + 6654: uint16(20825), + 6655: uint16(20822), + 6656: uint16(20828), + 6657: uint16(20829), + 6658: uint16(20996), + 6659: uint16(20995), + 6660: uint16(20997), + 6661: uint16(4108), + 6662: uint16(20992), + 6663: uint16(20993), + 6664: uint16(6227), + 6665: uint16(11032), + 6666: uint16(20994), + 6667: uint16(10769), + 6668: uint16(21002), + 6669: uint16(20998), + 6670: uint16(21003), + 6671: uint16(21000), + 6672: uint16(20999), + 6673: uint16(5691), + 6674: uint16(21004), + 6675: uint16(21005), + 6676: uint16(21006), + 6677: uint16(21001), + 6678: uint16(20819), + 6679: uint16(21007), + 6680: uint16(9024), + 6681: uint16(21011), + 6682: uint16(21012), + 6683: uint16(21010), + 6684: uint16(21009), + 6685: uint16(21015), + 6686: uint16(21008), + 6687: uint16(21013), + 6688: uint16(21014), + 6689: uint16(21017), + 6690: uint16(21016), + 6691: uint16(21019), + 6692: uint16(21020), + 6693: uint16(21021), + 6694: uint16(11816), + 6695: uint16(21018), + 6696: uint16(8522), + 6697: uint16(6476), + 6698: uint16(21022), + 6699: uint16(21023), + 6700: uint16(21024), + 6701: uint16(21025), + 6702: uint16(21026), + 6703: uint16(5907), + 6704: uint16(21027), + 6705: uint16(21028), + 6706: uint16(6926), + 6707: uint16(21029), + 6708: uint16(21030), + 6709: uint16(21031), + 6710: uint16(21032), + 6711: uint16(21035), + 6712: uint16(21033), + 6713: uint16(11803), + 6714: uint16(21034), + 6715: uint16(11598), + 6716: uint16(21036), + 6717: uint16(11578), + 6718: uint16(21037), + 6719: uint16(9821), + 6720: uint16(21038), + 6721: uint16(21040), + 6722: uint16(21041), + 6723: uint16(21039), + 6724: uint16(6220), + 6725: uint16(11052), + 6726: uint16(10818), + 6727: uint16(13654), + 6728: uint16(15423), + 6729: uint16(10842), + 6730: uint16(4362), + 6731: uint16(21043), + 6732: uint16(5167), + 6733: uint16(21044), + 6734: uint16(21045), + 6735: uint16(21046), + 6736: uint16(6228), + 6737: uint16(21047), + 6738: uint16(16179), + 6739: uint16(11066), + 6740: uint16(8514), + 6741: uint16(21048), + 6742: uint16(21050), + 6743: uint16(21049), + 6744: uint16(21051), + 6745: uint16(21052), + 6746: uint16(21053), + 6747: uint16(21054), + 6748: uint16(21055), + 6749: uint16(21056), + 6750: uint16(21057), + 6751: uint16(21058), + 6752: uint16(21059), + 6753: uint16(21060), + 6754: uint16(21061), + 6755: uint16(21062), + 6756: uint16(21063), + 6757: uint16(9219), + 6758: uint16(5948), + 6759: uint16(21065), + 6760: uint16(8236), + 6761: uint16(21066), + 6762: uint16(21067), + 6763: uint16(10240), + 6764: uint16(21068), + 6765: uint16(21069), + 6766: uint16(16918), + 6767: uint16(19257), + 6768: uint16(20300), + 6769: uint16(21070), + 6770: uint16(21071), + 6771: uint16(21073), + 6772: uint16(21074), + 6773: uint16(21075), + 6774: uint16(11599), + 6775: uint16(21072), + 6776: uint16(21076), + 6777: uint16(21077), + 6778: uint16(21079), + 6779: uint16(21078), + 6780: uint16(21081), + 6781: uint16(21082), + 6782: uint16(21080), + 6783: uint16(11541), + 6784: uint16(21083), + 6785: uint16(21084), + 6786: uint16(16947), + 6787: uint16(21085), + 6788: uint16(9), + 6789: uint16(83), + 6790: uint16(79), + 6791: uint16(82), + 6792: uint16(84), + 6793: uint16(41), + 6794: uint16(42), + 6795: uint16(85), + 6796: uint16(59), + 6797: uint16(3), + 6798: uint16(4), + 6799: uint16(30), + 6800: uint16(527), + 6801: uint16(528), + 6802: uint16(529), + 6803: uint16(530), + 6804: uint16(531), + 6805: uint16(532), + 6806: uint16(533), + 6807: uint16(534), + 6808: uint16(535), + 6809: uint16(536), + 6810: uint16(6), + 6811: uint16(7), + 6812: uint16(66), + 6813: uint16(64), + 6814: uint16(67), + 6815: uint16(8), + 6816: uint16(86), + 6817: uint16(544), + 6818: uint16(545), + 6819: uint16(546), + 6820: uint16(547), + 6821: uint16(548), + 6822: uint16(549), + 6823: uint16(550), + 6824: uint16(551), + 6825: uint16(552), + 6826: uint16(553), + 6827: uint16(554), + 6828: uint16(555), + 6829: uint16(556), + 6830: uint16(557), + 6831: uint16(558), + 6832: uint16(559), + 6833: uint16(560), + 6834: uint16(561), + 6835: uint16(562), + 6836: uint16(563), + 6837: uint16(564), + 6838: uint16(565), + 6839: uint16(566), + 6840: uint16(567), + 6841: uint16(568), + 6842: uint16(569), + 6843: uint16(45), + 6844: uint16(46), + 6845: uint16(15), + 6846: uint16(17), + 6847: uint16(13), + 6848: uint16(576), + 6849: uint16(577), + 6850: uint16(578), + 6851: uint16(579), + 6852: uint16(580), + 6853: uint16(581), + 6854: uint16(582), + 6855: uint16(583), + 6856: uint16(584), + 6857: uint16(585), + 6858: uint16(586), + 6859: uint16(587), + 6860: uint16(588), + 6861: uint16(589), + 6862: uint16(590), + 6863: uint16(591), + 6864: uint16(592), + 6865: uint16(593), + 6866: uint16(594), + 6867: uint16(595), + 6868: uint16(596), + 6869: uint16(597), + 6870: uint16(598), + 6871: uint16(599), + 6872: uint16(600), + 6873: uint16(601), + 6874: uint16(47), + 6875: uint16(34), + 6876: uint16(48), + 6877: uint16(16), + 6878: uint16(78), +} + +func _fuzzycmp(tls *TLS, a uintptr, b uintptr) (r int32) { + for { + if !(**(**uint8)(__ccgo_up(a)) != 0 && **(**uint8)(__ccgo_up(b)) != 0) { + break + } + for **(**uint8)(__ccgo_up(a)) != 0 && uint32(**(**uint8)(__ccgo_up(a)))|uint32(32)-uint32('a') > uint32(26) && Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(a)))-int32('0')) > uint32(10) { + a = a + 1 + } + if uint32(**(**uint8)(__ccgo_up(a)))|uint32(32) != uint32(**(**uint8)(__ccgo_up(b))) { + return int32(1) + } + goto _1 + _1: + ; + a = a + 1 + b = b + 1 + } + return BoolInt32(Int32FromUint8(**(**uint8)(__ccgo_up(a))) != Int32FromUint8(**(**uint8)(__ccgo_up(b)))) +} + +func _find_charmap(tls *TLS, name uintptr) (r Tsize_t) { + var s uintptr + _ = s + if !(**(**uint8)(__ccgo_up(name)) != 0) { + name = uintptr(unsafe.Pointer(&_charmaps)) + } /* "utf8" */ + s = uintptr(unsafe.Pointer(&_charmaps)) + for { + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + if !(_fuzzycmp(tls, name, s) != 0) { + for { + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + goto _2 + _2: + ; + s = s + uintptr(_strlen(tls, s)+uint64(1)) + } + return Uint64FromInt64(int64(s+uintptr(1)) - t__predefined_ptrdiff_t(uintptr(unsafe.Pointer(&_charmaps)))) + } + s = s + uintptr(_strlen(tls, s)+uint64(1)) + if !(**(**uint8)(__ccgo_up(s)) != 0) { + if Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) > int32(0200) { + s = s + uintptr(2) + } else { + s = s + uintptr(uint32(2)+(uint32(64)-uint32(**(**uint8)(__ccgo_up(s + 1))))*uint32(5)) + } + } + goto _1 + _1: + } + return Uint64FromInt32(-Int32FromInt32(1)) +} + +type Tstateful_cd = struct { + Fbase_cd Ticonv_t + Fstate uint32 +} + +func _combine_to_from(tls *TLS, t Tsize_t, f Tsize_t) (r Ticonv_t) { + return uintptr(f<> int32(16) +} + +func _extract_to(tls *TLS, cd Ticonv_t) (r Tsize_t) { + return uint64(cd) >> int32(1) & uint64(0x7fff) +} + +func Xiconv_open(tls *TLS, to uintptr, from uintptr) (r Ticonv_t) { + if __ccgo_strace { + trc("tls=%v to=%v from=%v, (%v:)", tls, to, from, origin(2)) + defer func() { trc("-> %v", r) }() + } + var cd Ticonv_t + var f, t, v1, v2 Tsize_t + var scd uintptr + var v3 bool + _, _, _, _, _, _, _ = cd, f, scd, t, v1, v2, v3 + v1 = _find_charmap(tls, to) + t = v1 + if v3 = v1 == Uint64FromInt32(-Int32FromInt32(1)); !v3 { + v2 = _find_charmap(tls, from) + f = v2 + } + if v3 || v2 == Uint64FromInt32(-Int32FromInt32(1)) || Int32FromUint8(_charmaps[t]) >= int32(0330) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(-Int32FromInt32(1)) + } + cd = _combine_to_from(tls, t, f) + switch Int32FromUint8(_charmaps[f]) { + case int32(UTF_16): + fallthrough + case int32(UTF_32): + fallthrough + case int32(UCS2): + fallthrough + case int32(ISO2022_JP): + scd = Xmalloc(tls, uint64(16)) + if !(scd != 0) { + return uintptr(-Int32FromInt32(1)) + } + (*Tstateful_cd)(unsafe.Pointer(scd)).Fbase_cd = cd + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(0) + cd = scd + } + return cd +} + +func _get_16(tls *TLS, s uintptr, e int32) (r uint32) { + e = e & int32(1) + return Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(e))))<> int32(8)) + **(**uint8)(__ccgo_up(s + uintptr(int32(1)-e))) = uint8(c) +} + +func _get_32(tls *TLS, s uintptr, e int32) (r uint32) { + e = e & int32(3) + return (uint32(**(**uint8)(__ccgo_up(s + uintptr(e))))+0)<> int32(24)) + **(**uint8)(__ccgo_up(s + uintptr(e^int32(1)))) = uint8(c >> int32(16)) + **(**uint8)(__ccgo_up(s + uintptr(e^int32(2)))) = uint8(c >> int32(8)) + **(**uint8)(__ccgo_up(s + uintptr(e^int32(3)))) = uint8(c) +} + +/* Adapt as needed */ + +func _legacy_map(tls *TLS, map1 uintptr, c uint32) (r uint32) { + var x, v1 uint32 + _, _ = x, v1 + if c < Uint32FromInt32(int32(4)*Int32FromUint8(**(**uint8)(__ccgo_up(map1 + uintptr(-Int32FromInt32(1)))))) { + return c + } + x = c - Uint32FromInt32(int32(4)*Int32FromUint8(**(**uint8)(__ccgo_up(map1 + uintptr(-Int32FromInt32(1)))))) + x = Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(map1 + uintptr(x*uint32(5)/uint32(4)))))>>(uint32(2)*x%uint32(8)) | Int32FromUint8(**(**uint8)(__ccgo_up(map1 + uintptr(x*uint32(5)/uint32(4)+uint32(1)))))<<(uint32(8)-uint32(2)*x%uint32(8))&int32(1023)) + if x < uint32(256) { + v1 = x + } else { + v1 = uint32(_legacy_chars[x-uint32(256)]) + } + return v1 +} + +func _uni_to_jis(tls *TLS, c uint32) (r uint32) { + var b, d, i, j, nel uint32 + _, _, _, _, _ = b, d, i, j, nel + nel = uint32(Uint64FromInt64(13758) / Uint64FromInt64(2)) + b = uint32(0) + for { + i = nel / uint32(2) + j = uint32(_rev_jis[b+i]) + d = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_jis0208)) + uintptr(j/uint32(256))*188 + uintptr(j%uint32(256))*2))) + if d == c { + return j + uint32(0x2121) + } else { + if nel == uint32(1) { + return uint32(0) + } else { + if c < d { + nel = nel / uint32(2) + } else { + b = b + i + nel = nel - nel/uint32(2) + } + } + } + goto _1 + _1: + } + return r +} + +func Xiconv(tls *TLS, cd Ticonv_t, in uintptr, inb uintptr, out uintptr, outb uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v cd=%v in=%v inb=%v out=%v outb=%v, (%v:)", tls, cd, in, inb, out, outb, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var c, d, from, to, v62 uint32 + var err, i, i1, j, j1, v25, v26, v27 int32 + var k, l, tmplen, tmpx, x Tsize_t + var loc Tlocale_t + var map1, ploc, scd, tomap, v54, v55 uintptr + var totype, type1 uint8 + var _ /* ptmp at bp+48 */ uintptr + var _ /* st at bp+24 */ Tmbstate_t + var _ /* tmp at bp+40 */ struct { + Fwc [0][2]Twchar_t + Fc [8]uint8 + } + var _ /* tmp at bp+56 */ [4]uint8 + var _ /* wc at bp+32 */ Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, d, err, from, i, i1, j, j1, k, l, loc, map1, ploc, scd, tmplen, tmpx, to, tomap, totype, type1, x, v25, v26, v27, v54, v55, v62 + x = uint64(0) + scd = uintptr(0) + if !(uint64(cd)&Uint64FromInt32(1) != 0) { + scd = cd + cd = (*Tstateful_cd)(unsafe.Pointer(scd)).Fbase_cd + } + to = uint32(_extract_to(tls, cd)) + from = uint32(_extract_from(tls, cd)) + map1 = uintptr(unsafe.Pointer(&_charmaps)) + uintptr(from) + uintptr(1) + tomap = uintptr(unsafe.Pointer(&_charmaps)) + uintptr(to) + uintptr(1) + **(**Tmbstate_t)(__ccgo_up(bp + 24)) = Tmbstate_t{} + type1 = **(**uint8)(__ccgo_up(map1 + uintptr(-Int32FromInt32(1)))) + totype = **(**uint8)(__ccgo_up(tomap + uintptr(-Int32FromInt32(1)))) + ploc = uintptr(___get_tp(tls)) + 152 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if !(in != 0) || !(**(**uintptr)(__ccgo_up(in)) != 0) || !(**(**Tsize_t)(__ccgo_up(inb)) != 0) { + return uint64(0) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = uintptr(unsafe.Pointer(&X__c_dot_utf8_locale)) + for { + if !(**(**Tsize_t)(__ccgo_up(inb)) != 0) { + break + } + c = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in))))) + l = uint64(1) + switch Int32FromUint8(type1) { + case int32(UTF_8): + goto _2 + case int32(US_ASCII): + goto _3 + case int32(WCHAR_T): + goto _4 + case int32(UTF_32LE): + goto _5 + case int32(UTF_32BE): + goto _6 + case int32(UTF_16LE): + goto _7 + case int32(UTF_16BE): + goto _8 + case int32(UCS2LE): + goto _9 + case int32(UCS2BE): + goto _10 + case int32(UTF_16): + goto _11 + case int32(UCS2): + goto _12 + case int32(UTF_32): + goto _13 + case int32(SHIFT_JIS): + goto _14 + case int32(EUC_JP): + goto _15 + case int32(ISO2022_JP): + goto _16 + case int32(GB2312): + goto _17 + case int32(GBK): + goto _18 + case int32(GB18030): + goto _19 + case int32(BIG5): + goto _20 + case int32(EUC_KR): + goto _21 + default: + goto _22 + } + goto _23 + _2: + ; + if c < uint32(128) { + goto _23 + } + l = Xmbrtowc(tls, bp+32, **(**uintptr)(__ccgo_up(in)), **(**Tsize_t)(__ccgo_up(inb)), bp+24) + if l == Uint64FromInt32(-Int32FromInt32(1)) { + goto ilseq + } + if l == Uint64FromInt32(-Int32FromInt32(2)) { + goto starved + } + c = **(**Twchar_t)(__ccgo_up(bp + 32)) + goto _23 + _3: + ; + if c >= uint32(128) { + goto ilseq + } + goto _23 + _4: + ; + l = uint64(4) + if **(**Tsize_t)(__ccgo_up(inb)) < l { + goto starved + } + c = **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(in)))) + if !(0 != 0) { + goto _24 + } + _6: + ; + _5: + ; + l = uint64(4) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(4) { + goto starved + } + c = _get_32(tls, **(**uintptr)(__ccgo_up(in)), Int32FromUint8(type1)) + _24: + ; + if c-uint32(0xd800) < uint32(0x800) || c >= uint32(0x110000) { + goto ilseq + } + goto _23 + _10: + ; + _9: + ; + _8: + ; + _7: + ; + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + c = _get_16(tls, **(**uintptr)(__ccgo_up(in)), Int32FromUint8(type1)) + if c-Uint32FromInt32(0xdc00) < uint32(0x400) { + goto ilseq + } + if c-Uint32FromInt32(0xd800) < uint32(0x400) { + if Uint32FromInt32(Int32FromUint8(type1)-int32(UCS2BE)) < uint32(2) { + goto ilseq + } + l = uint64(4) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(4) { + goto starved + } + d = _get_16(tls, **(**uintptr)(__ccgo_up(in))+UintptrFromInt32(2), Int32FromUint8(type1)) + if d-Uint32FromInt32(0xdc00) >= uint32(0x400) { + goto ilseq + } + c = (c-uint32(0xd7c0))< uint32(127) { + d = d - 1 + } + d = d - uint32(64) + } else { + if d-uint32(159) <= Uint32FromInt32(Int32FromInt32(252)-Int32FromInt32(159)) { + c = c + 1 + d = d - uint32(159) + } + } + if c >= uint32(84) { + goto ilseq + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_jis0208)) + uintptr(c)*188 + uintptr(d)*2))) + if !(c != 0) { + goto ilseq + } + goto _23 + _15: + ; + if c < uint32(128) { + goto _23 + } + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + if c == uint32(0x8e) { + c = d + if c-uint32(0xa1) > Uint32FromInt32(Int32FromInt32(0xdf)-Int32FromInt32(0xa1)) { + goto ilseq + } + c = c + Uint32FromInt32(Int32FromInt32(0xff61)-Int32FromInt32(0xa1)) + goto _23 + } + c = c - uint32(0xa1) + d = d - uint32(0xa1) + if c >= uint32(84) || d >= uint32(94) { + goto ilseq + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_jis0208)) + uintptr(c)*188 + uintptr(d)*2))) + if !(c != 0) { + goto ilseq + } + goto _23 + _16: + ; + if c >= uint32(128) { + goto ilseq + } + if c == uint32('\033') { + l = uint64(3) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(3) { + goto starved + } + c = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(2)))) + if c != uint32('(') && c != uint32('$') { + goto ilseq + } + switch Uint32FromInt32(Int32FromInt32(128)*BoolInt32(c == Uint32FromUint8('$'))) + d { + case uint32('B'): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(0) + goto _1 + case uint32('J'): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(1) + goto _1 + case uint32('I'): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(4) + goto _1 + case Uint32FromInt32(Int32FromInt32(128) + Int32FromUint8('@')): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(2) + goto _1 + case Uint32FromInt32(Int32FromInt32(128) + Int32FromUint8('B')): + (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate = uint32(3) + goto _1 + } + goto ilseq + } + switch (*Tstateful_cd)(unsafe.Pointer(scd)).Fstate { + case uint32(1): + if c == uint32('\\') { + c = uint32(0xa5) + } + if c == uint32('~') { + c = uint32(0x203e) + } + case uint32(2): + fallthrough + case uint32(3): + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + c = c - uint32(0x21) + d = d - uint32(0x21) + if c >= uint32(84) || d >= uint32(94) { + goto ilseq + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_jis0208)) + uintptr(c)*188 + uintptr(d)*2))) + if !(c != 0) { + goto ilseq + } + case uint32(4): + if c-uint32(0x60) < uint32(0x1f) { + goto ilseq + } + if c-uint32(0x21) < uint32(0x5e) { + c = c + Uint32FromInt32(Int32FromInt32(0xff61)-Int32FromInt32(0x21)) + } + break + } + goto _23 + _17: + ; + if c < uint32(128) { + goto _23 + } + if c < uint32(0xa1) { + goto ilseq + } + _18: + ; + if c == uint32(128) { + c = uint32(0x20ac) + goto _23 + } + _19: + ; + if c < uint32(128) { + goto _23 + } + c = c - uint32(0x81) + if c >= uint32(126) { + goto ilseq + } + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + if d < uint32(0xa1) && Int32FromUint8(type1) == int32(GB2312) { + goto ilseq + } + if d-uint32(0x40) >= uint32(191) || d == uint32(127) { + if d-uint32('0') > uint32(9) || Int32FromUint8(type1) != int32(GB18030) { + goto ilseq + } + l = uint64(4) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(4) { + goto starved + } + c = (uint32(10)*c + d - uint32('0')) * uint32(1260) + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(2)))) + if d-uint32(0x81) > uint32(126) { + goto ilseq + } + c = c + uint32(10)*(d-uint32(0x81)) + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(3)))) + if d-uint32('0') > uint32(9) { + goto ilseq + } + c = c + (d - uint32('0')) + c = c + uint32(128) + d = uint32(0) + for { + if !(d <= c) { + break + } + k = uint64(0) + i = 0 + for { + if !(i < int32(126)) { + break + } + j = 0 + for { + if !(j < int32(190)) { + break + } + if uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_gb18030)) + uintptr(i)*380 + uintptr(j)*2)))-d <= c-d { + k = k + 1 + } + goto _31 + _31: + ; + j = j + 1 + } + goto _30 + _30: + ; + i = i + 1 + } + d = c + uint32(1) + c = uint32(uint64(c) + k) + goto _29 + _29: + } + goto _23 + } + d = d - uint32(0x40) + if d > uint32(63) { + d = d - 1 + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_gb18030)) + uintptr(c)*380 + uintptr(d)*2))) + goto _23 + _20: + ; + if c < uint32(128) { + goto _23 + } + l = uint64(2) + if **(**Tsize_t)(__ccgo_up(inb)) < uint64(2) { + goto starved + } + d = uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(in)) + UintptrFromInt32(1)))) + if d-uint32(0x40) >= Uint32FromInt32(Int32FromInt32(0xff)-Int32FromInt32(0x40)) || d-uint32(0x7f) < Uint32FromInt32(Int32FromInt32(0xa1)-Int32FromInt32(0x7f)) { + goto ilseq + } + d = d - uint32(0x40) + if d > uint32(0x3e) { + d = d - uint32(0x22) + } + if c-uint32(0xa1) >= Uint32FromInt32(Int32FromInt32(0xfa)-Int32FromInt32(0xa1)) { + if c-uint32(0x87) >= Uint32FromInt32(Int32FromInt32(0xff)-Int32FromInt32(0x87)) { + goto ilseq + } + if c < uint32(0xa1) { + c = c - uint32(0x87) + } else { + c = c - Uint32FromInt32(Int32FromInt32(0x87)+(Int32FromInt32(0xfa)-Int32FromInt32(0xa1))) + } + c = Uint32FromInt32(Int32FromUint16(_hkscs[uint32(4867)+(c*uint32(157)+d)/uint32(16)])>>((c*uint32(157)+d)%uint32(16))%int32(2)< **(**Tsize_t)(__ccgo_up(outb)) { + goto toobig + } + if tmpx != 0 { + x = x + 1 + } + Xmemcpy(tls, **(**uintptr)(__ccgo_up(out)), bp+40, tmplen) + **(**uintptr)(__ccgo_up(out)) += uintptr(tmplen) + **(**Tsize_t)(__ccgo_up(outb)) -= tmplen + goto _1 + } + if !(c != 0) { + goto ilseq + } + goto _23 + } + c = c - uint32(0xa1) + c = Uint32FromInt32(Int32FromUint16(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_big5)) + uintptr(c)*314 + uintptr(d)*2))) | BoolInt32(c == uint32(0x27) && (d == uint32(0x3a) || d == uint32(0x3c) || d == uint32(0x42)))<= uint32(93) || d >= uint32(94) { + c = c + Uint32FromInt32(Int32FromInt32(0xa1)-Int32FromInt32(0x81)) + d = d + uint32(0xa1) + if c >= uint32(93) || c >= Uint32FromInt32(Int32FromInt32(0xc6)-Int32FromInt32(0x81)) && d > uint32(0x52) { + goto ilseq + } + if d-uint32('A') < uint32(26) { + d = d - uint32('A') + } else { + if d-uint32('a') < uint32(26) { + d = d - uint32('a') + uint32(26) + } else { + if d-uint32(0x81) < Uint32FromInt32(Int32FromInt32(0xff)-Int32FromInt32(0x81)) { + d = d - uint32(0x81) + uint32(52) + } else { + goto ilseq + } + } + } + if c < uint32(0x20) { + c = uint32(178)*c + d + } else { + c = Uint32FromInt32(Int32FromInt32(178)*Int32FromInt32(0x20)) + uint32(84)*(c-uint32(0x20)) + d + } + c = c + uint32(0xac00) + d = uint32(0xac00) + for { + if !(d <= c) { + break + } + k = uint64(0) + i1 = 0 + for { + if !(i1 < int32(93)) { + break + } + j1 = 0 + for { + if !(j1 < int32(94)) { + break + } + if uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_ksc)) + uintptr(i1)*188 + uintptr(j1)*2)))-d <= c-d { + k = k + 1 + } + goto _34 + _34: + ; + j1 = j1 + 1 + } + goto _33 + _33: + ; + i1 = i1 + 1 + } + d = c + uint32(1) + c = uint32(uint64(c) + k) + goto _32 + _32: + } + goto _23 + } + c = uint32(**(**uint16)(__ccgo_up(uintptr(unsafe.Pointer(&_ksc)) + uintptr(c)*188 + uintptr(d)*2))) + if !(c != 0) { + goto ilseq + } + goto _23 + _22: + ; + if !(c != 0) { + goto _23 + } + c = _legacy_map(tls, map1, c) + if !(c != 0) { + goto ilseq + } + _23: + ; + switch Int32FromUint8(totype) { + case int32(WCHAR_T): + goto _35 + case int32(UTF_8): + goto _36 + case int32(US_ASCII): + goto _37 + default: + goto _38 + case int32(SHIFT_JIS): + goto _39 + case int32(EUC_JP): + goto _40 + case int32(ISO2022_JP): + goto _41 + case int32(UCS2): + goto _42 + case int32(UTF_16LE): + goto _43 + case int32(UTF_16BE): + goto _44 + case int32(UTF_16): + goto _45 + case int32(UCS2LE): + goto _46 + case int32(UCS2BE): + goto _47 + case int32(UTF_32): + goto _48 + case int32(UTF_32LE): + goto _49 + case int32(UTF_32BE): + goto _50 + } + goto _51 + _35: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(4) { + goto toobig + } + **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(out)))) = c + **(**uintptr)(__ccgo_up(out)) += uintptr(4) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(4) + goto _51 + _36: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(4) { + k = Uint64FromInt32(Xwctomb(tls, bp+56, c)) + if **(**Tsize_t)(__ccgo_up(outb)) < k { + goto toobig + } + Xmemcpy(tls, **(**uintptr)(__ccgo_up(out)), bp+56, k) + } else { + k = Uint64FromInt32(Xwctomb(tls, **(**uintptr)(__ccgo_up(out)), c)) + } + **(**uintptr)(__ccgo_up(out)) += uintptr(k) + **(**Tsize_t)(__ccgo_up(outb)) -= k + goto _51 + _37: + ; + if !(c > uint32(0x7f)) { + goto _52 + } + goto subst + subst: + ; + x = x + 1 + c = Uint32FromUint8('*') + _52: + ; + _38: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(1) { + goto toobig + } + if !(c < uint32(256) && c == _legacy_map(tls, tomap, c)) { + goto _53 + } + goto revout + revout: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(1) { + goto toobig + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8(c) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(1) + goto _51 + _53: + ; + d = c + c = Uint32FromInt32(int32(4) * Int32FromUint8(totype)) + for { + if !(c < uint32(256)) { + break + } + if d == _legacy_map(tls, tomap, c) { + goto revout + } + goto _56 + _56: + ; + c = c + 1 + } + goto subst + _39: + ; + if c < uint32(128) { + goto revout + } + if c == uint32(0xa5) { + x = x + 1 + c = uint32('\\') + goto revout + } + if c == uint32(0x203e) { + x = x + 1 + c = uint32('~') + goto revout + } + if c-uint32(0xff61) <= Uint32FromInt32(Int32FromInt32(0xdf)-Int32FromInt32(0xa1)) { + c = c + Uint32FromInt32(Int32FromInt32(0xa1)-Int32FromInt32(0xff61)) + goto revout + } + c = _uni_to_jis(tls, c) + if !(c != 0) { + goto subst + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(2) { + goto toobig + } + d = c % uint32(256) + c = c / uint32(256) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + if c < uint32(95) { + v25 = int32(112) + } else { + v25 = int32(176) + } + **(**uint8)(__ccgo_up(v54)) = uint8((c+uint32(1))/uint32(2) + Uint32FromInt32(v25)) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + if c%uint32(2) != 0 { + v62 = d + uint32(31) + d/uint32(96) + } else { + v62 = d + uint32(126) + } + **(**uint8)(__ccgo_up(v54)) = uint8(v62) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(2) + goto _51 + _40: + ; + if c < uint32(128) { + goto revout + } + if c-uint32(0xff61) <= Uint32FromInt32(Int32FromInt32(0xdf)-Int32FromInt32(0xa1)) { + c = c + Uint32FromInt32(Int32FromInt32(0x0e00)+Int32FromInt32(0x21)-Int32FromInt32(0xff61)) + } else { + c = _uni_to_jis(tls, c) + } + if !(c != 0) { + goto subst + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(2) { + goto toobig + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8(c/uint32(256) + uint32(0x80)) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8(c%uint32(256) + uint32(0x80)) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(2) + goto _51 + _41: + ; + if c < uint32(128) { + goto revout + } + if c-uint32(0xff61) <= Uint32FromInt32(Int32FromInt32(0xdf)-Int32FromInt32(0xa1)) || c == uint32(0xa5) || c == uint32(0x203e) { + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(7) { + goto toobig + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('\033') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('(') + if c == uint32(0xa5) { + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('J') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('\\') + } else { + if c == uint32(0x203e) { + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('J') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('~') + } else { + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('I') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8(c - uint32(0xff61) + uint32(0x21)) + } + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('\033') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('(') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('B') + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(7) + goto _51 + } + c = _uni_to_jis(tls, c) + if !(c != 0) { + goto subst + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(8) { + goto toobig + } + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('\033') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('$') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('B') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8(c / uint32(256)) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8(c % uint32(256)) + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('\033') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('(') + v55 = out + v54 = *(*uintptr)(unsafe.Pointer(v55)) + *(*uintptr)(unsafe.Pointer(v55)) = *(*uintptr)(unsafe.Pointer(v55)) + 1 + **(**uint8)(__ccgo_up(v54)) = uint8('B') + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(8) + goto _51 + _42: + ; + totype = uint8(UCS2BE) + _47: + ; + _46: + ; + _45: + ; + _44: + ; + _43: + ; + if c < uint32(0x10000) || Uint32FromInt32(Int32FromUint8(totype)-int32(UCS2BE)) < uint32(2) { + if c >= uint32(0x10000) { + c = uint32(0xFFFD) + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(2) { + goto toobig + } + _put_16(tls, **(**uintptr)(__ccgo_up(out)), c, Int32FromUint8(totype)) + **(**uintptr)(__ccgo_up(out)) += uintptr(2) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(2) + goto _51 + } + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(4) { + goto toobig + } + c = c - uint32(0x10000) + _put_16(tls, **(**uintptr)(__ccgo_up(out)), c>>int32(10)|uint32(0xd800), Int32FromUint8(totype)) + _put_16(tls, **(**uintptr)(__ccgo_up(out))+UintptrFromInt32(2), c&uint32(0x3ff)|uint32(0xdc00), Int32FromUint8(totype)) + **(**uintptr)(__ccgo_up(out)) += uintptr(4) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(4) + goto _51 + _48: + ; + totype = uint8(UTF_32BE) + _50: + ; + _49: + ; + if **(**Tsize_t)(__ccgo_up(outb)) < uint64(4) { + goto toobig + } + _put_32(tls, **(**uintptr)(__ccgo_up(out)), c, Int32FromUint8(totype)) + **(**uintptr)(__ccgo_up(out)) += uintptr(4) + **(**Tsize_t)(__ccgo_up(outb)) -= uint64(4) + goto _51 + _51: + ; + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(in)) += uintptr(l) + **(**Tsize_t)(__ccgo_up(inb)) -= l + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return x + goto ilseq +ilseq: + ; + err = int32(EILSEQ) + x = Uint64FromInt32(-Int32FromInt32(1)) + goto end + goto toobig +toobig: + ; + err = int32(E2BIG) + x = Uint64FromInt32(-Int32FromInt32(1)) + goto end + goto starved +starved: + ; + err = int32(EINVAL) + x = Uint64FromInt32(-Int32FromInt32(1)) + goto end +end: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = err + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return x +} + +func Xiconv_close(tls *TLS, cd Ticonv_t) (r int32) { + if __ccgo_strace { + trc("tls=%v cd=%v, (%v:)", tls, cd, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(uint64(cd)&Uint64FromInt32(1) != 0) { + Xfree(tls, cd) + } + return 0 +} + +var _c_time = [316]uint8{'S', 'u', 'n', 0, 'M', 'o', 'n', 0, 'T', 'u', 'e', 0, 'W', 'e', 'd', 0, 'T', 'h', 'u', 0, 'F', 'r', 'i', 0, 'S', 'a', 't', 0, 'S', 'u', 'n', 'd', 'a', 'y', 0, 'M', 'o', 'n', 'd', 'a', 'y', 0, 'T', 'u', 'e', 's', 'd', 'a', 'y', 0, 'W', 'e', 'd', 'n', 'e', 's', 'd', 'a', 'y', 0, 'T', 'h', 'u', 'r', 's', 'd', 'a', 'y', 0, 'F', 'r', 'i', 'd', 'a', 'y', 0, 'S', 'a', 't', 'u', 'r', 'd', 'a', 'y', 0, 'J', 'a', 'n', 0, 'F', 'e', 'b', 0, 'M', 'a', 'r', 0, 'A', 'p', 'r', 0, 'M', 'a', 'y', 0, 'J', 'u', 'n', 0, 'J', 'u', 'l', 0, 'A', 'u', 'g', 0, 'S', 'e', 'p', 0, 'O', 'c', 't', 0, 'N', 'o', 'v', 0, 'D', 'e', 'c', 0, 'J', 'a', 'n', 'u', 'a', 'r', 'y', 0, 'F', 'e', 'b', 'r', 'u', 'a', 'r', 'y', 0, 'M', 'a', 'r', 'c', 'h', 0, 'A', 'p', 'r', 'i', 'l', 0, 'M', 'a', 'y', 0, 'J', 'u', 'n', 'e', 0, 'J', 'u', 'l', 'y', 0, 'A', 'u', 'g', 'u', 's', 't', 0, 'S', 'e', 'p', 't', 'e', 'm', 'b', 'e', 'r', 0, 'O', 'c', 't', 'o', 'b', 'e', 'r', 0, 'N', 'o', 'v', 'e', 'm', 'b', 'e', 'r', 0, 'D', 'e', 'c', 'e', 'm', 'b', 'e', 'r', 0, 'A', 'M', 0, 'P', 'M', 0, '%', 'a', ' ', '%', 'b', ' ', '%', 'e', ' ', '%', 'T', ' ', '%', 'Y', 0, '%', 'm', '/', '%', 'd', '/', '%', 'y', 0, '%', 'H', ':', '%', 'M', ':', '%', 'S', 0, '%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p', 0, 0, 0, '%', 'm', '/', '%', 'd', '/', '%', 'y', 0, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, '%', 'a', ' ', '%', 'b', ' ', '%', 'e', ' ', '%', 'T', ' ', '%', 'Y', 0, '%', 'H', ':', '%', 'M', ':', '%', 'S'} + +var _c_messages = [19]uint8{'^', '[', 'y', 'Y', ']', 0, '^', '[', 'n', 'N', ']', 0, 'y', 'e', 's', 0, 'n', 'o'} +var _c_numeric = [3]uint8{'.'} + +func X__nl_langinfo_l(tls *TLS, item Tnl_item, loc Tlocale_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v loc=%v, (%v:)", tls, item, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var cat, idx int32 + var str, v1 uintptr + _, _, _, _ = cat, idx, str, v1 + cat = item >> int32(16) + idx = item & int32(65535) + if item == int32(CODESET) { + if **(**uintptr)(__ccgo_up(loc)) != 0 { + v1 = __ccgo_ts + 322 + } else { + v1 = __ccgo_ts + 516 + } + return v1 + } + /* _NL_LOCALE_NAME extension */ + if idx == int32(65535) && cat < int32(LC_ALL) { + if **(**uintptr)(__ccgo_up(loc + uintptr(cat)*8)) != 0 { + v1 = **(**uintptr)(__ccgo_up(loc + uintptr(cat)*8)) + 16 + } else { + v1 = __ccgo_ts + 522 + } + return v1 + } + switch cat { + case int32(LC_NUMERIC): + if idx > int32(1) { + return __ccgo_ts + } + str = uintptr(unsafe.Pointer(&_c_numeric)) + case int32(LC_TIME): + if idx > int32(0x31) { + return __ccgo_ts + } + str = uintptr(unsafe.Pointer(&_c_time)) + case int32(LC_MONETARY): + if idx > 0 { + return __ccgo_ts + } + str = __ccgo_ts + case int32(LC_MESSAGES): + if idx > int32(3) { + return __ccgo_ts + } + str = uintptr(unsafe.Pointer(&_c_messages)) + default: + return __ccgo_ts + } + for { + if !(idx != 0) { + break + } + for { + if !(**(**uint8)(__ccgo_up(str)) != 0) { + break + } + goto _4 + _4: + ; + str = str + 1 + } + goto _3 + _3: + ; + idx = idx - 1 + str = str + 1 + } + if cat != int32(LC_NUMERIC) && **(**uint8)(__ccgo_up(str)) != 0 { + str = X__lctrans(tls, str, **(**uintptr)(__ccgo_up(loc + uintptr(cat)*8))) + } + return str +} + +func X__nl_langinfo(tls *TLS, item Tnl_item) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v, (%v:)", tls, item, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__nl_langinfo_l(tls, item, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xnl_langinfo(tls *TLS, item Tnl_item) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v, (%v:)", tls, item, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__nl_langinfo(tls, item) +} + +func Xnl_langinfo_l(tls *TLS, item Tnl_item, loc Tlocale_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v loc=%v, (%v:)", tls, item, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__nl_langinfo_l(tls, item, loc) +} + +func X__lctrans_impl(tls *TLS, msg uintptr, lm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v lm=%v, (%v:)", tls, msg, lm, origin(2)) + defer func() { trc("-> %v", r) }() + } + var trans, v1 uintptr + _, _ = trans, v1 + trans = uintptr(0) + if lm != 0 { + trans = X__mo_lookup(tls, (*t__locale_map)(unsafe.Pointer(lm)).Fmap1, (*t__locale_map)(unsafe.Pointer(lm)).Fmap_size, msg) + } + if trans != 0 { + v1 = trans + } else { + v1 = msg + } + return v1 +} + +var _envvars = [6][12]uint8{ + 0: {'L', 'C', '_', 'C', 'T', 'Y', 'P', 'E'}, + 1: {'L', 'C', '_', 'N', 'U', 'M', 'E', 'R', 'I', 'C'}, + 2: {'L', 'C', '_', 'T', 'I', 'M', 'E'}, + 3: {'L', 'C', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E'}, + 4: {'L', 'C', '_', 'M', 'O', 'N', 'E', 'T', 'A', 'R', 'Y'}, + 5: {'L', 'C', '_', 'M', 'E', 'S', 'S', 'A', 'G', 'E', 'S'}, +} + +func X__get_locale(tls *TLS, cat int32, val uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v cat=%v val=%v, (%v:)", tls, cat, val, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(272) + defer tls.Free(272) + var builtin int32 + var l, n Tsize_t + var map1, new1, p, path, z, v1, v2, v4, v6 uintptr + var v3, v5, v7 bool + var _ /* buf at bp+0 */ [256]uint8 + var _ /* map_size at bp+256 */ Tsize_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = builtin, l, map1, n, new1, p, path, z, v1, v2, v3, v4, v5, v6, v7 + new1 = uintptr(0) + path = uintptr(0) + if !(**(**uint8)(__ccgo_up(val)) != 0) { + v1 = Xgetenv(tls, __ccgo_ts+524) + val = v1 + if v3 = v1 != 0 && **(**uint8)(__ccgo_up(val)) != 0; !v3 { + v2 = Xgetenv(tls, uintptr(unsafe.Pointer(&_envvars))+uintptr(cat)*12) + val = v2 + } + if v5 = v3 || v2 != 0 && **(**uint8)(__ccgo_up(val)) != 0; !v5 { + v4 = Xgetenv(tls, __ccgo_ts+336) + val = v4 + } + if v7 = v5 || v4 != 0 && **(**uint8)(__ccgo_up(val)) != 0; !v7 { + v6 = __ccgo_ts + 531 + val = v6 + } + _ = v7 || v6 != 0 + } + /* Limit name length and forbid leading dot or any slashes. */ + n = uint64(0) + for { + if !(n < uint64(LOCALE_NAME_MAX) && **(**uint8)(__ccgo_up(val + uintptr(n))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(val + uintptr(n)))) != int32('/')) { + break + } + goto _8 + _8: + ; + n = n + 1 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(val))) == int32('.') || **(**uint8)(__ccgo_up(val + uintptr(n))) != 0 { + val = __ccgo_ts + 531 + } + builtin = BoolInt32(Int32FromUint8(**(**uint8)(__ccgo_up(val))) == int32('C') && !(**(**uint8)(__ccgo_up(val + 1)) != 0) || !(Xstrcmp(tls, val, __ccgo_ts+531) != 0) || !(Xstrcmp(tls, val, __ccgo_ts+539) != 0)) + if builtin != 0 { + if cat == LC_CTYPE && Int32FromUint8(**(**uint8)(__ccgo_up(val + 1))) == int32('.') { + return uintptr(unsafe.Pointer(&X__c_dot_utf8)) + } + return uintptr(0) + } + p = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_loc_head))) + for { + if !(p != 0) { + break + } + if !(Xstrcmp(tls, val, p+16) != 0) { + return p + } + goto _9 + _9: + ; + p = (*t__locale_map)(unsafe.Pointer(p)).Fnext + } + if !(X__libc.Fsecure != 0) { + path = Xgetenv(tls, __ccgo_ts+545) + } + /* FIXME: add a default path? */ + if path != 0 { + for { + if !(**(**uint8)(__ccgo_up(path)) != 0) { + break + } + z = X__strchrnul(tls, path, int32(':')) + l = Uint64FromInt64(int64(z) - int64(path)) + if l >= uint64(256)-n-uint64(2) { + goto _10 + } + Xmemcpy(tls, bp, path, l) + (**(**[256]uint8)(__ccgo_up(bp)))[l] = uint8('/') + Xmemcpy(tls, bp+uintptr(l)+uintptr(1), val, n) + (**(**[256]uint8)(__ccgo_up(bp)))[l+uint64(1)+n] = uint8(0) + map1 = X__map_file(tls, bp, bp+256) + if map1 != 0 { + new1 = Xmalloc(tls, uint64(48)) + if !(new1 != 0) { + X__munmap(tls, map1, **(**Tsize_t)(__ccgo_up(bp + 256))) + break + } + (*t__locale_map)(unsafe.Pointer(new1)).Fmap1 = map1 + (*t__locale_map)(unsafe.Pointer(new1)).Fmap_size = **(**Tsize_t)(__ccgo_up(bp + 256)) + Xmemcpy(tls, new1+16, val, n) + **(**uint8)(__ccgo_up(new1 + 16 + uintptr(n))) = uint8(0) + (*t__locale_map)(unsafe.Pointer(new1)).Fnext = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_loc_head))) + AtomicStorePUintptr(uintptr(unsafe.Pointer(&_loc_head)), new1) + break + } + goto _10 + _10: + ; + path = z + BoolUintptr(!!(**(**uint8)(__ccgo_up(z)) != 0)) + } + } + /* If no locale definition was found, make a locale map + * object anyway to store the name, which is kept for the + * sake of being able to do message translations at the + * application level. */ + if v3 = !(new1 != 0); v3 { + v1 = Xmalloc(tls, uint64(48)) + new1 = v1 + } + if v3 && v1 != 0 { + (*t__locale_map)(unsafe.Pointer(new1)).Fmap1 = X__c_dot_utf8.Fmap1 + (*t__locale_map)(unsafe.Pointer(new1)).Fmap_size = X__c_dot_utf8.Fmap_size + Xmemcpy(tls, new1+16, val, n) + **(**uint8)(__ccgo_up(new1 + 16 + uintptr(n))) = uint8(0) + (*t__locale_map)(unsafe.Pointer(new1)).Fnext = AtomicLoadPUintptr(uintptr(unsafe.Pointer(&_loc_head))) + AtomicStorePUintptr(uintptr(unsafe.Pointer(&_loc_head)), new1) + } + /* For LC_CTYPE, never return a null pointer unless the + * requested name was "C" or "POSIX". */ + if !(new1 != 0) && cat == LC_CTYPE { + new1 = uintptr(unsafe.Pointer(&X__c_dot_utf8)) + } + return new1 +} + +var _loc_head uintptr + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +var _posix_lconv = Tlconv{ + Fdecimal_point: __ccgo_ts + 558, + Fthousands_sep: __ccgo_ts, + Fgrouping: __ccgo_ts, + Fint_curr_symbol: __ccgo_ts, + Fcurrency_symbol: __ccgo_ts, + Fmon_decimal_point: __ccgo_ts, + Fmon_thousands_sep: __ccgo_ts, + Fmon_grouping: __ccgo_ts, + Fpositive_sign: __ccgo_ts, + Fnegative_sign: __ccgo_ts, + Fint_frac_digits: uint8(CHAR_MAX), + Ffrac_digits: uint8(CHAR_MAX), + Fp_cs_precedes: uint8(CHAR_MAX), + Fp_sep_by_space: uint8(CHAR_MAX), + Fn_cs_precedes: uint8(CHAR_MAX), + Fn_sep_by_space: uint8(CHAR_MAX), + Fp_sign_posn: uint8(CHAR_MAX), + Fn_sign_posn: uint8(CHAR_MAX), + Fint_p_cs_precedes: uint8(CHAR_MAX), + Fint_p_sep_by_space: uint8(CHAR_MAX), + Fint_n_cs_precedes: uint8(CHAR_MAX), + Fint_n_sep_by_space: uint8(CHAR_MAX), + Fint_p_sign_posn: uint8(CHAR_MAX), + Fint_n_sign_posn: uint8(CHAR_MAX), +} + +func Xlocaleconv(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_posix_lconv)) +} + +var _default_locale_init_done int32 +var _default_locale t__locale_struct +var _default_ctype_locale t__locale_struct + +func X__loc_is_allocated(tls *TLS, loc Tlocale_t) (r int32) { + if __ccgo_strace { + trc("tls=%v loc=%v, (%v:)", tls, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(loc != 0 && loc != uintptr(unsafe.Pointer(&X__c_locale)) && loc != uintptr(unsafe.Pointer(&X__c_dot_utf8_locale)) && loc != uintptr(unsafe.Pointer(&_default_locale)) && loc != uintptr(unsafe.Pointer(&_default_ctype_locale))) +} + +func _do_newlocale(tls *TLS, mask int32, name uintptr, loc Tlocale_t) (r Tlocale_t) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i, i1 int32 + var v2, v3 uintptr + var v5 Tlocale_t + var _ /* tmp at bp+0 */ t__locale_struct + _, _, _, _, _ = i, i1, v2, v3, v5 + i = 0 + for { + if !(i < int32(LC_ALL)) { + break + } + if !(mask&(Int32FromInt32(1)< %v", r) }() + } + ___lock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + loc = _do_newlocale(tls, mask, name, loc) + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + return loc +} + +func Xnewlocale(tls *TLS, mask int32, name uintptr, loc Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v mask=%v name=%v loc=%v, (%v:)", tls, mask, name, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__newlocale(tls, mask, name, loc) +} + +/* +grammar: + +Start = Expr ';' +Expr = Or | Or '?' Expr ':' Expr +Or = And | Or '||' And +And = Eq | And '&&' Eq +Eq = Rel | Eq '==' Rel | Eq '!=' Rel +Rel = Add | Rel '<=' Add | Rel '>=' Add | Rel '<' Add | Rel '>' Add +Add = Mul | Add '+' Mul | Add '-' Mul +Mul = Prim | Mul '*' Prim | Mul '/' Prim | Mul '%' Prim +Prim = '(' Expr ')' | '!' Prim | decimal | 'n' + +internals: + +recursive descent expression evaluator with stack depth limit. +for binary operators an operator-precedence parser is used. +eval* functions store the result of the parsed subexpression +and return a pointer to the next non-space character. +*/ + +type Tst = struct { + Fr uint64 + Fn uint64 + Fop int32 +} + +func _skipspace(tls *TLS, s uintptr) (r uintptr) { + var v1, v2 int32 + _, _ = v1, v2 + for { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if !(v2 != 0) { + break + } + s = s + 1 + } + return s +} + +func _evalprim(tls *TLS, st uintptr, s uintptr, d int32) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 int32 + var _ /* e at bp+0 */ uintptr + _ = v1 + d = d - 1 + v1 = d + if v1 < 0 { + return __ccgo_ts + } + s = _skipspace(tls, s) + if BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0 { + (*Tst)(unsafe.Pointer(st)).Fr = Xstrtoul(tls, s, bp, int32(10)) + if **(**uintptr)(__ccgo_up(bp)) == s || (*Tst)(unsafe.Pointer(st)).Fr == Uint64FromInt32(-Int32FromInt32(1)) { + return __ccgo_ts + } + return _skipspace(tls, **(**uintptr)(__ccgo_up(bp))) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('n') { + (*Tst)(unsafe.Pointer(st)).Fr = (*Tst)(unsafe.Pointer(st)).Fn + return _skipspace(tls, s+uintptr(1)) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('(') { + s = _evalexpr(tls, st, s+uintptr(1), d) + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32(')') { + return __ccgo_ts + } + return _skipspace(tls, s+uintptr(1)) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('!') { + s = _evalprim(tls, st, s+uintptr(1), d) + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(!((*Tst)(unsafe.Pointer(st)).Fr != 0)) + return s + } + return __ccgo_ts +} + +func _binop(tls *TLS, st uintptr, op int32, left uint64) (r int32) { + var a, b uint64 + _, _ = a, b + a = left + b = (*Tst)(unsafe.Pointer(st)).Fr + switch op { + case 0: + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a != 0 || b != 0) + return 0 + case int32(1): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a != 0 && b != 0) + return 0 + case int32(2): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a == b) + return 0 + case int32(3): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a != b) + return 0 + case int32(4): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a >= b) + return 0 + case int32(5): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a <= b) + return 0 + case int32(6): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a > b) + return 0 + case int32(7): + (*Tst)(unsafe.Pointer(st)).Fr = BoolUint64(a < b) + return 0 + case int32(8): + (*Tst)(unsafe.Pointer(st)).Fr = a + b + return 0 + case int32(9): + (*Tst)(unsafe.Pointer(st)).Fr = a - b + return 0 + case int32(10): + (*Tst)(unsafe.Pointer(st)).Fr = a * b + return 0 + case int32(11): + if b != 0 { + (*Tst)(unsafe.Pointer(st)).Fr = a % b + return 0 + } + return int32(1) + case int32(12): + if b != 0 { + (*Tst)(unsafe.Pointer(st)).Fr = a / b + return 0 + } + return int32(1) + } + return int32(1) +} + +func _parseop(tls *TLS, st uintptr, s uintptr) (r uintptr) { + var i int32 + _ = i + i = 0 + for { + if !(i < int32(11)) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == Int32FromUint8(_opch[i]) { + /* note: >,< are accepted with or without = */ + if i < int32(6) && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) == Int32FromUint8(_opch2[i]) { + (*Tst)(unsafe.Pointer(st)).Fop = i + return s + uintptr(2) + } + if i >= int32(4) { + (*Tst)(unsafe.Pointer(st)).Fop = i + int32(2) + return s + uintptr(1) + } + break + } + goto _1 + _1: + ; + i = i + 1 + } + (*Tst)(unsafe.Pointer(st)).Fop = int32(13) + return s +} + +var _opch = [11]uint8{'|', '&', '=', '!', '>', '<', '+', '-', '*', '%', '/'} + +var _opch2 = [6]uint8{'|', '&', '=', '=', '=', '='} + +func _evalbinop(tls *TLS, st uintptr, s uintptr, minprec int32, d int32) (r uintptr) { + var left uint64 + var op int32 + _, _ = left, op + d = d - 1 + s = _evalprim(tls, st, s, d) + s = _parseop(tls, st, s) + for { + /* + st->r (left hand side value) and st->op are now set, + get the right hand side or back out if op has low prec, + if op was missing then prec[op]==0 + */ + op = (*Tst)(unsafe.Pointer(st)).Fop + if Int32FromUint8(_prec[op]) <= minprec { + return s + } + left = (*Tst)(unsafe.Pointer(st)).Fr + s = _evalbinop(tls, st, s, Int32FromUint8(_prec[op]), d) + if _binop(tls, st, op, left) != 0 { + return __ccgo_ts + } + goto _1 + _1: + } + return r +} + +var _prec = [14]uint8{ + 0: uint8(1), + 1: uint8(2), + 2: uint8(3), + 3: uint8(3), + 4: uint8(4), + 5: uint8(4), + 6: uint8(4), + 7: uint8(4), + 8: uint8(5), + 9: uint8(5), + 10: uint8(6), + 11: uint8(6), + 12: uint8(6), +} + +func _evalexpr(tls *TLS, st uintptr, s uintptr, d int32) (r uintptr) { + var a, b, v2 uint64 + var v1 int32 + _, _, _, _ = a, b, v1, v2 + d = d - 1 + v1 = d + if v1 < 0 { + return __ccgo_ts + } + s = _evalbinop(tls, st, s, 0, d) + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('?') { + return s + } + a = (*Tst)(unsafe.Pointer(st)).Fr + s = _evalexpr(tls, st, s+uintptr(1), d) + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32(':') { + return __ccgo_ts + } + b = (*Tst)(unsafe.Pointer(st)).Fr + s = _evalexpr(tls, st, s+uintptr(1), d) + if a != 0 { + v2 = b + } else { + v2 = (*Tst)(unsafe.Pointer(st)).Fr + } + (*Tst)(unsafe.Pointer(st)).Fr = v2 + return s +} + +func X__pleval(tls *TLS, s uintptr, n uint64) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1 uint64 + var _ /* st at bp+0 */ Tst + _ = v1 + (**(**Tst)(__ccgo_up(bp))).Fn = n + s = _evalexpr(tls, bp, s, int32(100)) + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32(';') { + v1 = (**(**Tst)(__ccgo_up(bp))).Fr + } else { + v1 = Uint64FromInt32(-Int32FromInt32(1)) + } + return v1 +} + +var _buf1 [144]uint8 + +func Xsetlocale(tls *TLS, cat int32, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v cat=%v name=%v, (%v:)", tls, cat, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var i, same int32 + var l Tsize_t + var lm, lm1, p, part1, ret, s, z, v3 uintptr + var _ /* part at bp+48 */ [24]uint8 + var _ /* tmp_locale at bp+0 */ t__locale_struct + _, _, _, _, _, _, _, _, _, _, _ = i, l, lm, lm1, p, part1, ret, s, same, z, v3 + if Uint32FromInt32(cat) > uint32(LC_ALL) { + return uintptr(0) + } + ___lock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + /* For LC_ALL, setlocale is required to return a string which + * encodes the current setting for all categories. The format of + * this string is unspecified, and only the following code, which + * performs both the serialization and deserialization, depends + * on the format, so it can easily be changed if needed. */ + if cat == int32(LC_ALL) { + if name != 0 { + **(**[24]uint8)(__ccgo_up(bp + 48)) = [24]uint8{'C', '.', 'U', 'T', 'F', '-', '8'} + p = name + i = 0 + for { + if !(i < int32(LC_ALL)) { + break + } + z = X__strchrnul(tls, p, int32(';')) + if int64(z)-int64(p) <= int64(LOCALE_NAME_MAX) { + Xmemcpy(tls, bp+48, p, Uint64FromInt64(int64(z)-int64(p))) + (**(**[24]uint8)(__ccgo_up(bp + 48)))[int64(z)-int64(p)] = uint8(0) + if **(**uint8)(__ccgo_up(z)) != 0 { + p = z + uintptr(1) + } + } + lm = X__get_locale(tls, i, bp+48) + if lm == uintptr(-Int32FromInt32(1)) { + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + return uintptr(0) + } + **(**uintptr)(__ccgo_up(bp + uintptr(i)*8)) = lm + goto _1 + _1: + ; + i = i + 1 + } + X__libc.Fglobal_locale = **(**t__locale_struct)(__ccgo_up(bp)) + } + s = uintptr(unsafe.Pointer(&_buf1)) + same = 0 + i = 0 + for { + if !(i < int32(LC_ALL)) { + break + } + lm1 = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&X__libc)) + 56 + uintptr(i)*8)) + if lm1 == **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&X__libc)) + 56)) { + same = same + 1 + } + if lm1 != 0 { + v3 = lm1 + 16 + } else { + v3 = __ccgo_ts + 522 + } + part1 = v3 + l = _strlen(tls, part1) + Xmemcpy(tls, s, part1, l) + **(**uint8)(__ccgo_up(s + uintptr(l))) = uint8(';') + s = s + uintptr(l+uint64(1)) + goto _2 + _2: + ; + i = i + 1 + } + s = s - 1 + v3 = s + **(**uint8)(__ccgo_up(v3)) = uint8(0) + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + if same == int32(LC_ALL) { + v3 = part1 + } else { + v3 = uintptr(unsafe.Pointer(&_buf1)) + } + return v3 + } + if name != 0 { + lm = X__get_locale(tls, cat, name) + if lm == uintptr(-Int32FromInt32(1)) { + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + return uintptr(0) + } + **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&X__libc)) + 56 + uintptr(cat)*8)) = lm + } else { + lm = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&X__libc)) + 56 + uintptr(cat)*8)) + } + if lm != 0 { + v3 = lm + 16 + } else { + v3 = __ccgo_ts + 522 + } + ret = v3 + ___unlock(tls, uintptr(unsafe.Pointer(&X__locale_lock))) + return ret +} + +func X__strcoll_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v loc=%v, (%v:)", tls, l, r, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xstrcmp(tls, l, r) +} + +func Xstrcoll(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__strcoll_l(tls, l, r, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xstrcoll_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v loc=%v, (%v:)", tls, l, r, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__strcoll_l(tls, l, r, loc) +} + +func _vstrfmon_l(tls *TLS, s uintptr, n Tsize_t, loc Tlocale_t, fmt uintptr, ap Tva_list) (r Tssize_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var fill, fw, intl, left, lp, negpar, nogrp, nosym, rp, w int32 + var l Tsize_t + var s0, v5, v6 uintptr + var x float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = fill, fw, intl, l, left, lp, negpar, nogrp, nosym, rp, s0, w, x, v5, v6 + s0 = s +_3: + ; + if !(n != 0 && **(**uint8)(__ccgo_up(fmt)) != 0) { + goto _1 + } + if !(Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) != int32('%')) { + goto _4 + } + goto literal +literal: + ; + v5 = s + s = s + 1 + v6 = fmt + fmt = fmt + 1 + **(**uint8)(__ccgo_up(v5)) = **(**uint8)(__ccgo_up(v6)) + n = n - 1 + goto _2 +_4: + ; + fmt = fmt + 1 + if Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) == int32('%') { + goto literal + } + fill = int32(' ') + nogrp = 0 + negpar = 0 + nosym = 0 + left = 0 + for { + switch Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) { + case int32('='): + fmt = fmt + 1 + v5 = fmt + fill = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + goto _7 + case int32('^'): + nogrp = int32(1) + goto _7 + case int32('('): + negpar = int32(1) + fallthrough + case int32('+'): + goto _7 + case int32('!'): + nosym = int32(1) + goto _7 + case int32('-'): + left = int32(1) + goto _7 + } + break + goto _7 + _7: + ; + fmt = fmt + 1 + } + fw = 0 + for { + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(fmt)))-uint32('0') < uint32(10)) != 0) { + break + } + fw = int32(10)*fw + (Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) - int32('0')) + goto _9 + _9: + ; + fmt = fmt + 1 + } + lp = 0 + rp = int32(2) + if Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) == int32('#') { + lp = 0 + fmt = fmt + 1 + for { + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(fmt)))-uint32('0') < uint32(10)) != 0) { + break + } + lp = int32(10)*lp + (Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) - int32('0')) + goto _10 + _10: + ; + fmt = fmt + 1 + } + } + if Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) == int32('.') { + rp = 0 + fmt = fmt + 1 + for { + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(fmt)))-uint32('0') < uint32(10)) != 0) { + break + } + rp = int32(10)*rp + (Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) - int32('0')) + goto _11 + _11: + ; + fmt = fmt + 1 + } + } + v5 = fmt + fmt = fmt + 1 + intl = BoolInt32(Int32FromUint8(**(**uint8)(__ccgo_up(v5))) == int32('i')) + w = lp + int32(1) + rp + if !(left != 0) && fw > w { + w = fw + } + x = VaFloat64(&ap) + l = Uint64FromInt32(Xsnprintf(tls, s, n, __ccgo_ts+560, VaList(bp+8, w, rp, x))) + if l >= n { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(E2BIG) + return int64(-int32(1)) + } + s = s + uintptr(l) + n = n - l + goto _2 +_2: + ; + goto _3 + goto _1 +_1: + ; + return int64(s) - int64(s0) +} + +func Xstrfmon_l(tls *TLS, s uintptr, n Tsize_t, loc Tlocale_t, fmt uintptr, va uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v loc=%v fmt=%v va=%v, (%v:)", tls, s, n, loc, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret Tssize_t + _, _ = ap, ret + ap = va + ret = _vstrfmon_l(tls, s, n, loc, fmt, ap) + _ = ap + return ret +} + +func Xstrfmon(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v va=%v, (%v:)", tls, s, n, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret Tssize_t + _, _ = ap, ret + ap = va + ret = _vstrfmon_l(tls, s, n, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale, fmt, ap) + _ = ap + return ret +} + +func Xstrtof_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtof(tls, s, p) +} + +func Xstrtod_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtod(tls, s, p) +} + +func Xstrtold_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtold(tls, s, p) +} + +func X__strtod_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtod_l(tls, s, p, l) +} + +func X__strtof_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtof_l(tls, s, p, l) +} + +func X__strtold_l(tls *TLS, s uintptr, p uintptr, l Tlocale_t) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v l=%v, (%v:)", tls, s, p, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtold_l(tls, s, p, l) +} + +// C documentation +// +// /* collate only by code points */ +func X__strxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v loc=%v, (%v:)", tls, dest, src, n, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = _strlen(tls, src) + if n > l { + Xstrcpy(tls, dest, src) + } + return l +} + +func Xstrxfrm(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strxfrm_l(tls, dest, src, n, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +// C documentation +// +// /* collate only by code points */ +func Xstrxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v loc=%v, (%v:)", tls, dest, src, n, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strxfrm_l(tls, dest, src, n, loc) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +var _current_domain uintptr + +func X__gettextdomain(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + if _current_domain != 0 { + v1 = _current_domain + } else { + v1 = __ccgo_ts + 414 + } + return v1 +} + +func Xtextdomain(tls *TLS, domainname uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v domainname=%v, (%v:)", tls, domainname, origin(2)) + defer func() { trc("-> %v", r) }() + } + var domlen Tsize_t + _ = domlen + if !(domainname != 0) { + return X__gettextdomain(tls) + } + domlen = _strlen(tls, domainname) + if domlen > uint64(NAME_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + if !(_current_domain != 0) { + _current_domain = Xmalloc(tls, Uint64FromInt32(Int32FromInt32(NAME_MAX)+Int32FromInt32(1))) + if !(_current_domain != 0) { + return uintptr(0) + } + } + Xmemcpy(tls, _current_domain, domainname, domlen+uint64(1)) + return _current_domain +} + +func Xgettext(tls *TLS, msgid uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msgid=%v, (%v:)", tls, msgid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdgettext(tls, uintptr(0), msgid) +} + +func Xngettext(tls *TLS, msgid1 uintptr, msgid2 uintptr, n uint64) (r uintptr) { + if __ccgo_strace { + trc("tls=%v msgid1=%v msgid2=%v n=%v, (%v:)", tls, msgid1, msgid2, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xdngettext(tls, uintptr(0), msgid1, msgid2, n) +} + +func X__uselocale(tls *TLS, new1 Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v new1=%v, (%v:)", tls, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var global, old, v1 Tlocale_t + var self Tpthread_t + _, _, _, _ = global, old, self, v1 + self = uintptr(___get_tp(tls)) + old = (*t__pthread)(unsafe.Pointer(self)).Flocale + global = uintptr(unsafe.Pointer(&X__libc)) + 56 + if new1 != 0 { + if new1 == uintptr(-Int32FromInt32(1)) { + v1 = global + } else { + v1 = new1 + } + (*t__pthread)(unsafe.Pointer(self)).Flocale = v1 + } + if old == global { + v1 = uintptr(-Int32FromInt32(1)) + } else { + v1 = old + } + return v1 +} + +func Xuselocale(tls *TLS, new1 Tlocale_t) (r Tlocale_t) { + if __ccgo_strace { + trc("tls=%v new1=%v, (%v:)", tls, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__uselocale(tls, new1) +} + +// C documentation +// +// /* FIXME: stub */ +func X__wcscoll_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v locale=%v, (%v:)", tls, l, r, locale, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xwcscmp(tls, l, r) +} + +func Xwcscoll(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__wcscoll_l(tls, l, r, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +// C documentation +// +// /* FIXME: stub */ +func Xwcscoll_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v locale=%v, (%v:)", tls, l, r, locale, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__wcscoll_l(tls, l, r, locale) +} + +// C documentation +// +// /* collate only by code points */ +func X__wcsxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v loc=%v, (%v:)", tls, dest, src, n, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = Xwcslen(tls, src) + if l < n { + Xwmemcpy(tls, dest, src, l+uint64(1)) + } else { + if n != 0 { + Xwmemcpy(tls, dest, src, n-uint64(1)) + **(**Twchar_t)(__ccgo_up(dest + uintptr(n-uint64(1))*4)) = uint32(0) + } + } + return l +} + +func Xwcsxfrm(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wcsxfrm_l(tls, dest, src, n, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +// C documentation +// +// /* collate only by code points */ +func Xwcsxfrm_l(tls *TLS, dest uintptr, src uintptr, n Tsize_t, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v loc=%v, (%v:)", tls, dest, src, n, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wcsxfrm_l(tls, dest, src, n, loc) +} + +func Xreallocarray(tls *TLS, ptr uintptr, m Tsize_t, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ptr=%v m=%v n=%v, (%v:)", tls, ptr, m, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n != 0 && m > Uint64FromInt32(-Int32FromInt32(1))/n { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return uintptr(0) + } + return Xrealloc(tls, ptr, m*n) +} + +const LDBL_EPSILON2 = 0 +const LDBL_MAX2 = 0 +const LDBL_MIN2 = 0 + +var _C1 = float64(0.0416666666666666) /* 0x3FA55555, 0x5555554C */ +var _C2 = -Float64FromFloat64(0.001388888888887411) /* 0xBF56C16C, 0x16C15177 */ +var _C3 = float64(2.480158728947673e-05) /* 0x3EFA01A0, 0x19CB1590 */ +var _C4 = -Float64FromFloat64(2.7557314351390663e-07) /* 0xBE927E4F, 0x809C52AD */ +var _C5 = float64(2.087572321298175e-09) /* 0x3E21EE9E, 0xBDB4B1C4 */ +var _C6 = -Float64FromFloat64(1.1359647557788195e-11) /* 0xBDA8FAE9, 0xBE8838D4 */ + +func X__cos(tls *TLS, x float64, y float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var hz, r, w, z Tdouble_t + _, _, _, _ = hz, r, w, z + z = Tdouble_t(x * x) + w = Tdouble_t(z * z) + r = Tdouble_t(z*(_C1+float64(z*(_C2+float64(z*_C3))))) + Tdouble_t(Tdouble_t(w*w)*(_C4+float64(z*(_C5+float64(z*_C6))))) + hz = Tdouble_t(float64(0.5) * z) + w = float64(1) - hz + return w + (Float64FromFloat64(1) - w - hz + (Tdouble_t(z*r) - Tdouble_t(x*y))) +} + +// C documentation +// +// /* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */ + +var _C0 = -Float64FromFloat64(0.499999997251031) /* -0.499999997251031003120 */ +var _C11 = float64(0.04166662332373906) /* 0.0416666233237390631894 */ +var _C21 = -Float64FromFloat64(0.001388676377460993) /* -0.00138867637746099294692 */ +var _C31 = float64(2.439044879627741e-05) /* 0.0000243904487962774090654 */ + +func X__cosdf(tls *TLS, x float64) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, w, z Tdouble_t + _, _, _ = r, w, z + /* Try to optimize for parallel evaluation as in __tandf.c. */ + z = Tdouble_t(x * x) + w = Tdouble_t(z * z) + r = _C21 + float64(z*_C31) + return float32(float64(1) + float64(z*_C0) + float64(w*_C11) + float64(Tdouble_t(w*z)*r)) +} + +// C documentation +// +// /* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */ +var _k2 = int32(2043) +var _kln22 = float64(1416.0996898839683) + +// C documentation +// +// /* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */ +func X__expo2(tls *TLS, x float64, sign float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v sign=%v, (%v:)", tls, x, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + var scale float64 + var v1 Tuint64_t + _, _ = scale, v1 + /* note that k is odd and scale*scale overflows */ + v1 = uint64(Uint32FromInt32(Int32FromInt32(0x3ff)+_k2/Int32FromInt32(2))< log(FLT_MIN) */ +var _k3 = int32(235) +var _kln23 = Float32FromFloat32(162.88958740234375) + +// C documentation +// +// /* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */ +func X__expo2f(tls *TLS, x float32, sign float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v sign=%v, (%v:)", tls, x, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + var scale float32 + var v1 Tuint32_t + _, _ = scale, v1 + /* note that k is odd and scale*scale overflows */ + v1 = Uint32FromInt32(Int32FromInt32(0x7f)+_k3/Int32FromInt32(2)) << int32(23) + scale = *(*float32)(unsafe.Pointer(&v1)) + /* exp(x - k ln2) * 2**(k-1) */ + /* in directed rounding correct sign before rounding or overflow is important */ + return float32(float32(Xexpf(tls, x-_kln23)*float32(sign*scale)) * scale) +} + +func X__fpclassify(tls *TLS, x float64) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v1 int32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _ = e, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if !(e != 0) { + if *(*Tuint64_t)(unsafe.Pointer(bp))< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v1 int32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _ = e, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + if !(e != 0) { + if *(*Tuint32_t)(unsafe.Pointer(bp))< %v", r) }() + } + return X__fpclassify(tls, x) +} + +const pio2_hi = 0 +const pio2_lo = 0 + +func X__math_divzero(tls *TLS, sign Tuint32_t) (r float64) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + var y, v1, v2 float64 + _, _, _ = y, v1, v2 + if sign != 0 { + v1 = -Float64FromFloat64(1) + } else { + v1 = float64(1) + } + y = v1 + v2 = y + goto _3 +_3: + return v2 / float64(0) +} + +func X__math_divzerof(tls *TLS, sign Tuint32_t) (r float32) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + var y, v1, v2 float32 + _, _, _ = y, v1, v2 + if sign != 0 { + v1 = -Float32FromFloat32(1) + } else { + v1 = Float32FromFloat32(1) + } + y = v1 + v2 = y + goto _3 +_3: + return v2 / Float32FromFloat32(0) +} + +func X__math_invalid(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (x - x) / (x - x) +} + +func X__math_invalidf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (x - x) / (x - x) +} + +func X__math_oflow(tls *TLS, sign Tuint32_t) (r float64) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__math_xflow(tls, sign, float64(3.105036184601418e+231)) +} + +func X__math_oflowf(tls *TLS, sign Tuint32_t) (r float32) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__math_xflowf(tls, sign, Float32FromFloat32(1.5845632502852868e+29)) +} + +func X__math_uflow(tls *TLS, sign Tuint32_t) (r float64) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__math_xflow(tls, sign, float64(1.2882297539194267e-231)) +} + +func X__math_uflowf(tls *TLS, sign Tuint32_t) (r float32) { + if __ccgo_strace { + trc("tls=%v sign=%v, (%v:)", tls, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__math_xflowf(tls, sign, Float32FromFloat32(2.524354896707238e-29)) +} + +func X__math_xflow(tls *TLS, sign Tuint32_t, y2 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v sign=%v y2=%v, (%v:)", tls, sign, y2, origin(2)) + defer func() { trc("-> %v", r) }() + } + var y, y1, v1, v2, v4 float64 + _, _, _, _, _ = y, y1, v1, v2, v4 + if sign != 0 { + v1 = -y2 + } else { + v1 = y2 + } + y1 = v1 + v2 = y1 + goto _3 +_3: + y = float64(v2 * y2) + v4 = y + goto _5 +_5: + return v4 +} + +func X__math_xflowf(tls *TLS, sign Tuint32_t, y2 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v sign=%v y2=%v, (%v:)", tls, sign, y2, origin(2)) + defer func() { trc("-> %v", r) }() + } + var y, y1, v1, v2, v4 float32 + _, _, _, _, _ = y, y1, v1, v2, v4 + if sign != 0 { + v1 = -y2 + } else { + v1 = y2 + } + y1 = v1 + v2 = y1 + goto _3 +_3: + y = float32(v2 * y2) + v4 = y + goto _5 +_5: + return v4 +} + +const DBL_EPSILON1 = 2.220446049250313e-16 +const EPS = 0 + +// C documentation +// +// /* +// * 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) +// */ + +var _toint = Float64FromFloat64(1.5) / Float64FromFloat64(2.220446049250313e-16) +var _pio4 = float64(0.7853981633974483) +var _invpio2 = float64(0.6366197723675814) /* 0x3FE45F30, 0x6DC9C883 */ +var _pio2_1 = float64(1.5707963267341256) /* 0x3FF921FB, 0x54400000 */ +var _pio2_1t = float64(6.077100506506192e-11) /* 0x3DD0B461, 0x1A626331 */ +var _pio2_2 = float64(6.077100506303966e-11) /* 0x3DD0B461, 0x1A600000 */ +var _pio2_2t = float64(2.0222662487959506e-21) /* 0x3BA3198A, 0x2E037073 */ +var _pio2_3 = float64(2.0222662487111665e-21) /* 0x3BA3198A, 0x2E000000 */ +var _pio2_3t = float64(8.4784276603689e-32) /* 0x397B839A, 0x252049C1 */ + +// C documentation +// +// /* caller must handle the case when reduction is not needed: |x| ~<= pi/4 */ +func X__rem_pio2(tls *TLS, x float64, y uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var ex, ey, i, n, sign int32 + var fn, r, t, w, z Tdouble_t + var ix Tuint32_t + var v2 float64 + var _ /* tx at bp+8 */ [3]float64 + var _ /* ty at bp+32 */ [2]float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _ = ex, ey, fn, i, ix, n, r, sign, t, w, z, v2 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if ix <= uint32(0x400f6a7a) { /* |x| ~<= 5pi/4 */ + if ix&uint32(0xfffff) == uint32(0x921fb) { /* |x| ~= pi/2 or 2pi/2 */ + goto medium + } /* cancellation -- use medium case */ + if ix <= uint32(0x4002d97c) { /* |x| ~<= 3pi/4 */ + if !(sign != 0) { + z = x - _pio2_1 /* one round good to 85 bits */ + **(**float64)(__ccgo_up(y)) = z - _pio2_1t + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) - _pio2_1t + return int32(1) + } else { + z = x + _pio2_1 + **(**float64)(__ccgo_up(y)) = z + _pio2_1t + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) + _pio2_1t + return -int32(1) + } + } else { + if !(sign != 0) { + z = x - float64(Float64FromInt32(2)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z - Tdouble_t(Float64FromInt32(2)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) - Tdouble_t(Float64FromInt32(2)*_pio2_1t) + return int32(2) + } else { + z = x + float64(Float64FromInt32(2)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z + Tdouble_t(Float64FromInt32(2)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) + Tdouble_t(Float64FromInt32(2)*_pio2_1t) + return -int32(2) + } + } + } + if ix <= uint32(0x401c463b) { /* |x| ~<= 9pi/4 */ + if ix <= uint32(0x4015fdbc) { /* |x| ~<= 7pi/4 */ + if ix == uint32(0x4012d97c) { /* |x| ~= 3pi/2 */ + goto medium + } + if !(sign != 0) { + z = x - float64(Float64FromInt32(3)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z - Tdouble_t(Float64FromInt32(3)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) - Tdouble_t(Float64FromInt32(3)*_pio2_1t) + return int32(3) + } else { + z = x + float64(Float64FromInt32(3)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z + Tdouble_t(Float64FromInt32(3)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) + Tdouble_t(Float64FromInt32(3)*_pio2_1t) + return -int32(3) + } + } else { + if ix == uint32(0x401921fb) { /* |x| ~= 4pi/2 */ + goto medium + } + if !(sign != 0) { + z = x - float64(Float64FromInt32(4)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z - Tdouble_t(Float64FromInt32(4)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) - Tdouble_t(Float64FromInt32(4)*_pio2_1t) + return int32(4) + } else { + z = x + float64(Float64FromInt32(4)*_pio2_1) + **(**float64)(__ccgo_up(y)) = z + Tdouble_t(Float64FromInt32(4)*_pio2_1t) + **(**float64)(__ccgo_up(y + 1*8)) = z - **(**float64)(__ccgo_up(y)) + Tdouble_t(Float64FromInt32(4)*_pio2_1t) + return -int32(4) + } + } + } + if !(ix < uint32(0x413921fb)) { + goto _1 + } /* |x| ~< 2^20*(pi/2), medium size */ + goto medium +medium: + ; + /* rint(x/(pi/2)) */ + fn = Tdouble_t(x*_invpio2) + _toint - _toint + n = int32(fn) + r = x - float64(fn*_pio2_1) + w = Tdouble_t(fn * _pio2_1t) /* 1st round, good to 85 bits */ + /* Matters with directed rounding. */ + if r-w < -_pio4 { + n = n - 1 + fn = fn - 1 + r = x - float64(fn*_pio2_1) + w = Tdouble_t(fn * _pio2_1t) + } else { + if r-w > _pio4 { + n = n + 1 + fn = fn + 1 + r = x - float64(fn*_pio2_1) + w = Tdouble_t(fn * _pio2_1t) + } + } + **(**float64)(__ccgo_up(y)) = r - w + *(*float64)(unsafe.Pointer(bp)) = **(**float64)(__ccgo_up(y)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + ex = Int32FromUint32(ix >> int32(20)) + if ex-ey > int32(16) { /* 2nd round, good to 118 bits */ + t = r + w = Tdouble_t(fn * _pio2_2) + r = t - w + w = Tdouble_t(fn*_pio2_2t) - (t - r - w) + **(**float64)(__ccgo_up(y)) = r - w + *(*float64)(unsafe.Pointer(bp)) = **(**float64)(__ccgo_up(y)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if ex-ey > int32(49) { /* 3rd round, good to 151 bits, covers all cases */ + t = r + w = Tdouble_t(fn * _pio2_3) + r = t - w + w = Tdouble_t(fn*_pio2_3t) - (t - r - w) + **(**float64)(__ccgo_up(y)) = r - w + } + } + **(**float64)(__ccgo_up(y + 1*8)) = r - **(**float64)(__ccgo_up(y)) - w + return n +_1: + ; + /* + * all other (large) arguments + */ + if ix >= uint32(0x7ff00000) { /* x is inf or NaN */ + v2 = x - x + **(**float64)(__ccgo_up(y + 1*8)) = v2 + **(**float64)(__ccgo_up(y)) = v2 + return 0 + } + /* set z = scalbn(|x|,-ilogb(x)+23) */ + *(*float64)(unsafe.Pointer(bp)) = x + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) >> Int32FromInt32(12) + *(*Tuint64_t)(unsafe.Pointer(bp)) |= Uint64FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(23)) << Int32FromInt32(52) + z = *(*float64)(unsafe.Pointer(bp)) + i = 0 + for { + if !(i < int32(2)) { + break + } + (**(**[3]float64)(__ccgo_up(bp + 8)))[i] = float64(int32(z)) + z = Tdouble_t((z - (**(**[3]float64)(__ccgo_up(bp + 8)))[i]) * float64(1.6777216e+07)) + goto _3 + _3: + ; + i = i + 1 + } + (**(**[3]float64)(__ccgo_up(bp + 8)))[i] = z + /* skip zero terms, first term is non-zero */ + for (**(**[3]float64)(__ccgo_up(bp + 8)))[i] == float64(0) { + i = i - 1 + } + n = X__rem_pio2_large(tls, bp+8, bp+32, Int32FromUint32(ix>>Int32FromInt32(20))-(Int32FromInt32(0x3ff)+Int32FromInt32(23)), i+int32(1), int32(1)) + if sign != 0 { + **(**float64)(__ccgo_up(y)) = -(**(**[2]float64)(__ccgo_up(bp + 32)))[0] + **(**float64)(__ccgo_up(y + 1*8)) = -(**(**[2]float64)(__ccgo_up(bp + 32)))[int32(1)] + return -n + } + **(**float64)(__ccgo_up(y)) = (**(**[2]float64)(__ccgo_up(bp + 32)))[0] + **(**float64)(__ccgo_up(y + 1*8)) = (**(**[2]float64)(__ccgo_up(bp + 32)))[int32(1)] + return n +} + +const DBL_EPSILON2 = 0 + +var _init_jk = [4]int32{ + 0: int32(3), + 1: int32(4), + 2: int32(4), + 3: int32(6), +} /* initial value for jk */ + +// C documentation +// +// /* +// * 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. +// */ +var _ipio2 = [66]Tint32_t{ + 0: int32(0xA2F983), + 1: int32(0x6E4E44), + 2: int32(0x1529FC), + 3: int32(0x2757D1), + 4: int32(0xF534DD), + 5: int32(0xC0DB62), + 6: int32(0x95993C), + 7: int32(0x439041), + 8: int32(0xFE5163), + 9: int32(0xABDEBB), + 10: int32(0xC561B7), + 11: int32(0x246E3A), + 12: int32(0x424DD2), + 13: int32(0xE00649), + 14: int32(0x2EEA09), + 15: int32(0xD1921C), + 16: int32(0xFE1DEB), + 17: int32(0x1CB129), + 18: int32(0xA73EE8), + 19: int32(0x8235F5), + 20: int32(0x2EBB44), + 21: int32(0x84E99C), + 22: int32(0x7026B4), + 23: int32(0x5F7E41), + 24: int32(0x3991D6), + 25: int32(0x398353), + 26: int32(0x39F49C), + 27: int32(0x845F8B), + 28: int32(0xBDF928), + 29: int32(0x3B1FF8), + 30: int32(0x97FFDE), + 31: int32(0x05980F), + 32: int32(0xEF2F11), + 33: int32(0x8B5A0A), + 34: int32(0x6D1F6D), + 35: int32(0x367ECF), + 36: int32(0x27CB09), + 37: int32(0xB74F46), + 38: int32(0x3F669E), + 39: int32(0x5FEA2D), + 40: int32(0x7527BA), + 41: int32(0xC7EBE5), + 42: int32(0xF17B3D), + 43: int32(0x0739F7), + 44: int32(0x8A5292), + 45: int32(0xEA6BFB), + 46: int32(0x5FB11F), + 47: int32(0x8D5D08), + 48: int32(0x560330), + 49: int32(0x46FC7B), + 50: int32(0x6BABF0), + 51: int32(0xCFBC20), + 52: int32(0x9AF436), + 53: int32(0x1DA9E3), + 54: int32(0x91615E), + 55: int32(0xE61B08), + 56: int32(0x659985), + 57: int32(0x5F14A0), + 58: int32(0x68408D), + 59: int32(0xFFD880), + 60: int32(0x4D7327), + 61: int32(0x310606), + 62: int32(0x1556CA), + 63: int32(0x73A8C9), + 64: int32(0x60E27B), + 65: int32(0xC08C6B), +} + +var _PIo2 = [8]float64{ + 0: float64(1.570796251296997), + 1: float64(7.549789415861596e-08), + 2: float64(5.390302529957765e-15), + 3: float64(3.282003415807913e-22), + 4: float64(1.270655753080676e-29), + 5: float64(1.2293330898111133e-36), + 6: float64(2.7337005381646456e-44), + 7: float64(2.1674168387780482e-51), +} + +func X__rem_pio2_large(tls *TLS, x uintptr, y uintptr, e0 int32, nx int32, prec int32) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v e0=%v nx=%v prec=%v, (%v:)", tls, x, y, e0, nx, prec, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(240) + defer tls.Free(240) + var carry, i, ih, j, jk, jp, jv, jx, jz, k, m, n, q0 Tint32_t + var f, q [20]float64 + var fw, z, v2 float64 + var _ /* fq at bp+80 */ [20]float64 + var _ /* iq at bp+0 */ [20]Tint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = carry, f, fw, i, ih, j, jk, jp, jv, jx, jz, k, m, n, q, q0, z, v2 + /* initialize jk*/ + jk = _init_jk[prec] + jp = jk + /* determine jx,jv,q0, note that 3>q0 */ + jx = nx - int32(1) + jv = (e0 - int32(3)) / int32(24) + if jv < 0 { + jv = 0 + } + q0 = e0 - int32(24)*(jv+int32(1)) + /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ + j = jv - jx + m = jx + jk + i = 0 + for { + if !(i <= m) { + break + } + if j < 0 { + v2 = float64(0) + } else { + v2 = float64(_ipio2[j]) + } + f[i] = v2 + goto _1 + _1: + ; + i = i + 1 + j = j + 1 + } + /* compute q[0],q[1],...q[jk] */ + i = 0 + for { + if !(i <= jk) { + break + } + j = 0 + fw = Float64FromFloat64(0) + for { + if !(j <= jx) { + break + } + fw = fw + float64(**(**float64)(__ccgo_up(x + uintptr(j)*8))*f[jx+i-j]) + goto _4 + _4: + ; + j = j + 1 + } + q[i] = fw + goto _3 + _3: + ; + i = i + 1 + } + jz = jk + goto recompute +recompute: + ; + /* distill q[] into iq[] reversingly */ + i = 0 + j = jz + z = q[jz] + for { + if !(j > 0) { + break + } + fw = float64(int32(float64(Float64FromFloat64(5.960464477539063e-08) * z))) + (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] = int32(z - float64(Float64FromFloat64(1.6777216e+07)*fw)) + z = q[j-int32(1)] + fw + goto _5 + _5: + ; + i = i + 1 + j = j - 1 + } + /* compute n */ + z = Xscalbn(tls, z, q0) /* actual value of z */ + z = z - float64(float64(8)*Xfloor(tls, float64(z*float64(0.125)))) /* trim off integer >= 8 */ + n = int32(z) + z = z - float64(n) + ih = 0 + if q0 > 0 { /* need iq[jz-1] to determine n */ + i = (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz-int32(1)] >> (int32(24) - q0) + n = n + i + **(**Tint32_t)(__ccgo_up(bp + uintptr(jz-int32(1))*4)) -= i << (int32(24) - q0) + ih = (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz-int32(1)] >> (int32(23) - q0) + } else { + if q0 == 0 { + ih = (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz-int32(1)] >> int32(23) + } else { + if z >= float64(0.5) { + ih = int32(2) + } + } + } + if ih > 0 { /* q > 0.5 */ + n = n + int32(1) + carry = 0 + i = 0 + for { + if !(i < jz) { + break + } /* compute 1-q */ + j = (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] + if carry == 0 { + if j != 0 { + carry = int32(1) + (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] = int32(0x1000000) - j + } + } else { + (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] = int32(0xffffff) - j + } + goto _6 + _6: + ; + i = i + 1 + } + if q0 > 0 { /* rare case: chance is 1 in 12 */ + switch q0 { + case int32(1): + **(**Tint32_t)(__ccgo_up(bp + uintptr(jz-int32(1))*4)) &= int32(0x7fffff) + case int32(2): + **(**Tint32_t)(__ccgo_up(bp + uintptr(jz-int32(1))*4)) &= int32(0x3fffff) + break + } + } + if ih == int32(2) { + z = float64(1) - z + if carry != 0 { + z = z - Xscalbn(tls, float64(1), q0) + } + } + } + /* check if recomputation is needed */ + if z == float64(0) { + j = 0 + i = jz - int32(1) + for { + if !(i >= jk) { + break + } + j = j | (**(**[20]Tint32_t)(__ccgo_up(bp)))[i] + goto _7 + _7: + ; + i = i - 1 + } + if j == 0 { /* need recomputation */ + k = int32(1) + for { + if !((**(**[20]Tint32_t)(__ccgo_up(bp)))[jk-k] == 0) { + break + } + goto _8 + _8: + ; + k = k + 1 + } /* k = no. of terms needed */ + i = jz + int32(1) + for { + if !(i <= jz+k) { + break + } /* add q[jz+1] to q[jz+k] */ + f[jx+i] = float64(_ipio2[jv+i]) + j = 0 + fw = Float64FromFloat64(0) + for { + if !(j <= jx) { + break + } + fw = fw + float64(**(**float64)(__ccgo_up(x + uintptr(j)*8))*f[jx+i-j]) + goto _10 + _10: + ; + j = j + 1 + } + q[i] = fw + goto _9 + _9: + ; + i = i + 1 + } + jz = jz + k + goto recompute + } + } + /* chop off zero terms */ + if z == float64(0) { + jz = jz - int32(1) + q0 = q0 - int32(24) + for (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz] == 0 { + jz = jz - 1 + q0 = q0 - int32(24) + } + } else { /* break z into 24-bit if necessary */ + z = Xscalbn(tls, z, -q0) + if z >= float64(1.6777216e+07) { + fw = float64(int32(float64(Float64FromFloat64(5.960464477539063e-08) * z))) + (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz] = int32(z - float64(Float64FromFloat64(1.6777216e+07)*fw)) + jz = jz + int32(1) + q0 = q0 + int32(24) + (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz] = int32(fw) + } else { + (**(**[20]Tint32_t)(__ccgo_up(bp)))[jz] = int32(z) + } + } + /* convert integer "bit" chunk to floating-point value */ + fw = Xscalbn(tls, float64(1), q0) + i = jz + for { + if !(i >= 0) { + break + } + q[i] = float64(fw * float64((**(**[20]Tint32_t)(__ccgo_up(bp)))[i])) + fw = fw * float64(5.960464477539063e-08) + goto _11 + _11: + ; + i = i - 1 + } + /* compute PIo2[0,...,jp]*q[jz,...,0] */ + i = jz + for { + if !(i >= 0) { + break + } + fw = float64(0) + k = Int32FromInt32(0) + for { + if !(k <= jp && k <= jz-i) { + break + } + fw = fw + float64(_PIo2[k]*q[i+k]) + goto _13 + _13: + ; + k = k + 1 + } + (**(**[20]float64)(__ccgo_up(bp + 80)))[jz-i] = fw + goto _12 + _12: + ; + i = i - 1 + } + /* compress fq[] into y[] */ + switch prec { + case 0: + goto _14 + case int32(2): + goto _15 + case int32(1): + goto _16 + case int32(3): + goto _17 + } + goto _18 +_14: + ; + fw = float64(0) + i = jz + for { + if !(i >= 0) { + break + } + fw = fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + goto _19 + _19: + ; + i = i - 1 + } + if ih == 0 { + v2 = fw + } else { + v2 = -fw + } + **(**float64)(__ccgo_up(y)) = v2 + goto _18 +_16: + ; +_15: + ; + fw = float64(0) + i = jz + for { + if !(i >= 0) { + break + } + fw = fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + goto _21 + _21: + ; + i = i - 1 + } + // TODO: drop excess precision here once double_t is used + fw = fw + if ih == 0 { + v2 = fw + } else { + v2 = -fw + } + **(**float64)(__ccgo_up(y)) = v2 + fw = (**(**[20]float64)(__ccgo_up(bp + 80)))[0] - fw + i = int32(1) + for { + if !(i <= jz) { + break + } + fw = fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + goto _23 + _23: + ; + i = i + 1 + } + if ih == 0 { + v2 = fw + } else { + v2 = -fw + } + **(**float64)(__ccgo_up(y + 1*8)) = v2 + goto _18 +_17: + ; /* painful */ + i = jz +_27: + ; + if !(i > 0) { + goto _25 + } + fw = (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + **(**float64)(__ccgo_up(bp + 80 + uintptr(i)*8)) += (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] - fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] = fw + goto _26 +_26: + ; + i = i - 1 + goto _27 + goto _25 +_25: + ; + i = jz + for { + if !(i > int32(1)) { + break + } + fw = (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + **(**float64)(__ccgo_up(bp + 80 + uintptr(i)*8)) += (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] - fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i-int32(1)] = fw + goto _28 + _28: + ; + i = i - 1 + } + fw = float64(0) + i = jz + for { + if !(i >= int32(2)) { + break + } + fw = fw + (**(**[20]float64)(__ccgo_up(bp + 80)))[i] + goto _29 + _29: + ; + i = i - 1 + } + if ih == 0 { + **(**float64)(__ccgo_up(y)) = (**(**[20]float64)(__ccgo_up(bp + 80)))[0] + **(**float64)(__ccgo_up(y + 1*8)) = (**(**[20]float64)(__ccgo_up(bp + 80)))[int32(1)] + **(**float64)(__ccgo_up(y + 2*8)) = fw + } else { + **(**float64)(__ccgo_up(y)) = -(**(**[20]float64)(__ccgo_up(bp + 80)))[0] + **(**float64)(__ccgo_up(y + 1*8)) = -(**(**[20]float64)(__ccgo_up(bp + 80)))[int32(1)] + **(**float64)(__ccgo_up(y + 2*8)) = -fw + } +_18: + ; + return n & int32(7) +} + +const DBL_EPSILON3 = 2.220446049250313e-16 + +// C documentation +// +// /* +// * invpio2: 53 bits of 2/pi +// * pio2_1: first 25 bits of pi/2 +// * pio2_1t: pi/2 - pio2_1 +// */ + +var _toint1 = Float64FromFloat64(1.5) / Float64FromFloat64(2.220446049250313e-16) +var _pio41 = float64(0.7853981852531433) +var _invpio21 = float64(0.6366197723675814) /* 0x3FE45F30, 0x6DC9C883 */ +var _pio2_11 = float64(1.5707963109016418) /* 0x3FF921FB, 0x50000000 */ +var _pio2_1t1 = float64(1.5893254773528196e-08) /* 0x3E5110b4, 0x611A6263 */ + +func X__rem_pio2f(tls *TLS, x float32, y uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var e0, n, sign int32 + var fn Tdouble_t + var ix Tuint32_t + var _ /* tx at bp+8 */ [1]float64 + var _ /* ty at bp+16 */ [1]float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e0, fn, ix, n, sign + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + /* 25+53 bit pi is good enough for medium size */ + if ix < uint32(0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */ + /* Use a specialized rint() to get fn. */ + fn = Tdouble_t(float64(x)*_invpio21) + _toint1 - _toint1 + n = int32(fn) + **(**float64)(__ccgo_up(y)) = float64(x) - Tdouble_t(fn*_pio2_11) - Tdouble_t(fn*_pio2_1t1) + /* Matters with directed rounding. */ + if **(**float64)(__ccgo_up(y)) < -_pio41 { + n = n - 1 + fn = fn - 1 + **(**float64)(__ccgo_up(y)) = float64(x) - Tdouble_t(fn*_pio2_11) - Tdouble_t(fn*_pio2_1t1) + } else { + if **(**float64)(__ccgo_up(y)) > _pio41 { + n = n + 1 + fn = fn + 1 + **(**float64)(__ccgo_up(y)) = float64(x) - Tdouble_t(fn*_pio2_11) - Tdouble_t(fn*_pio2_1t1) + } + } + return n + } + if ix >= uint32(0x7f800000) { /* x is inf or NaN */ + **(**float64)(__ccgo_up(y)) = float64(x - x) + return 0 + } + /* scale x into [2^23, 2^24-1] */ + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + e0 = Int32FromUint32(ix>>Int32FromInt32(23) - Uint32FromInt32(Int32FromInt32(0x7f)+Int32FromInt32(23))) /* e0 = ilogb(|x|)-23, positive */ + *(*Tuint32_t)(unsafe.Pointer(bp)) = ix - Uint32FromInt32(e0< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* y at bp+0 */ struct { + Fi [0]Tuint64_t + Fd float64 + } + *(*struct { + Fi [0]Tuint64_t + Fd float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Fd float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + return Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) +} + +// C documentation +// +// // FIXME: macro in math.h +func X__signbitf(tls *TLS, x float32) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* y at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + return Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) +} + +func X__signbitl(tls *TLS, x float64) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__signbit(tls, x) +} + +var _S1 = -Float64FromFloat64(0.16666666666666632) /* 0xBFC55555, 0x55555549 */ +var _S2 = float64(0.00833333333332249) /* 0x3F811111, 0x1110F8A6 */ +var _S3 = -Float64FromFloat64(0.0001984126982985795) /* 0xBF2A01A0, 0x19C161D5 */ +var _S4 = float64(2.7557313707070068e-06) /* 0x3EC71DE3, 0x57B1FE7D */ +var _S5 = -Float64FromFloat64(2.5050760253406863e-08) /* 0xBE5AE5E6, 0x8A2B9CEB */ +var _S6 = float64(1.58969099521155e-10) /* 0x3DE5D93A, 0x5ACFD57C */ + +func X__sin(tls *TLS, x float64, y float64, iy int32) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v iy=%v, (%v:)", tls, x, y, iy, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v, w, z Tdouble_t + _, _, _, _ = r, v, w, z + z = Tdouble_t(x * x) + w = Tdouble_t(z * z) + r = _S2 + float64(z*(_S3+float64(z*_S4))) + float64(Tdouble_t(z*w)*(_S5+float64(z*_S6))) + v = Tdouble_t(z * x) + if iy == 0 { + return x + float64(v*(_S1+float64(z*r))) + } else { + return x - (Tdouble_t(z*(float64(Float64FromFloat64(0.5)*y)-float64(v*r))) - y - Tdouble_t(v*_S1)) + } + return r1 +} + +// C documentation +// +// /* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */ + +var _S11 = -Float64FromFloat64(0.16666666641626524) /* -0.166666666416265235595 */ +var _S21 = float64(0.008333329385889463) /* 0.0083333293858894631756 */ +var _S31 = -Float64FromFloat64(0.00019839334836096632) /* -0.000198393348360966317347 */ +var _S41 = float64(2.718311493989822e-06) /* 0.0000027183114939898219064 */ + +func X__sindf(tls *TLS, x float64) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, s, w, z Tdouble_t + _, _, _, _ = r, s, w, z + /* Try to optimize for parallel evaluation as in __tandf.c. */ + z = Tdouble_t(x * x) + w = Tdouble_t(z * z) + r = _S31 + float64(z*_S41) + s = Tdouble_t(z * x) + return float32(x + float64(s*(_S11+float64(z*_S21))) + float64(Tdouble_t(s*w)*r)) +} + +var _T = [13]float64{ + 0: float64(0.3333333333333341), + 1: float64(0.13333333333320124), + 2: float64(0.05396825397622605), + 3: float64(0.021869488294859542), + 4: float64(0.0088632398235993), + 5: float64(0.0035920791075913124), + 6: float64(0.0014562094543252903), + 7: float64(0.0005880412408202641), + 8: float64(0.0002464631348184699), + 9: float64(7.817944429395571e-05), + 10: float64(7.140724913826082e-05), + 11: -Float64FromFloat64(1.8558637485527546e-05), + 12: float64(2.590730518636337e-05), +} +var _pio42 = float64(0.7853981633974483) /* 3FE921FB, 54442D18 */ +var _pio4lo = float64(3.061616997868383e-17) /* 3C81A626, 33145C07 */ + +func X__tan(tls *TLS, x float64, y float64, odd int32) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v odd=%v, (%v:)", tls, x, y, odd, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var a, r, s, v, w, z, v1 Tdouble_t + var a0, w0 float64 + var big, sign int32 + var hx Tuint32_t + var v2 Tuint64_t + _, _, _, _, _, _, _, _, _, _, _, _, _ = a, a0, big, hx, r, s, sign, v, w, w0, z, v1, v2 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + big = BoolInt32(hx&uint32(0x7fffffff) >= uint32(0x3FE59428)) /* |x| >= 0.6744 */ + if big != 0 { + sign = Int32FromUint32(hx >> int32(31)) + if sign != 0 { + x = -x + y = -y + } + x = _pio42 - x + (_pio4lo - y) + y = float64(0) + } + z = Tdouble_t(x * x) + w = Tdouble_t(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[int32(1)] + float64(w*(_T[int32(3)]+float64(w*(_T[int32(5)]+float64(w*(_T[int32(7)]+float64(w*(_T[int32(9)]+float64(w*_T[int32(11)]))))))))) + v = Tdouble_t(z * (_T[int32(2)] + float64(w*(_T[int32(4)]+float64(w*(_T[int32(6)]+float64(w*(_T[int32(8)]+float64(w*(_T[int32(10)]+float64(w*_T[int32(12)]))))))))))) + s = Tdouble_t(z * x) + r = y + float64(z*(Tdouble_t(s*(r+v))+y)) + float64(s*_T[0]) + w = x + r + if big != 0 { + s = float64(int32(1) - int32(2)*odd) + v = s - Tdouble_t(float64(2)*(x+(r-Tdouble_t(w*w)/(w+s)))) + if sign != 0 { + v1 = -v + } else { + v1 = v + } + return v1 + } + if !(odd != 0) { + return w + } + /* -1.0/(x+r) has up to 2ulp error, so compute it accurately */ + w0 = w + v2 = *(*Tuint64_t)(unsafe.Pointer(&w0))>>Int32FromInt32(32)<>Int32FromInt32(32)< %v", r1) }() + } + var r, s, t, u, w, z Tdouble_t + var v1 float64 + _, _, _, _, _, _, _ = r, s, t, u, w, z, v1 + z = Tdouble_t(x * x) + /* + * Split up the polynomial into small independent terms to give + * opportunities for parallel evaluation. The chosen splitting is + * micro-optimized for Athlons (XP, X64). It costs 2 multiplications + * relative to Horner's method on sequential machines. + * + * We add the small terms from lowest degree up for efficiency on + * non-sequential machines (the lowest degree terms tend to be ready + * earlier). Apart from this, we don't care about order of + * operations, and don't need to to care since we have precision to + * spare. However, the chosen splitting is good for accuracy too, + * and would give results as accurate as Horner's method if the + * small terms were added from highest degree down. + */ + r = _T1[int32(4)] + float64(z*_T1[int32(5)]) + t = _T1[int32(2)] + float64(z*_T1[int32(3)]) + w = Tdouble_t(z * z) + s = Tdouble_t(z * x) + u = _T1[0] + float64(z*_T1[int32(1)]) + r = x + float64(s*u) + float64(Tdouble_t(s*w)*(t+Tdouble_t(w*r))) + if odd != 0 { + v1 = -Float64FromFloat64(1) / r + } else { + v1 = r + } + return float32(v1) +} + +var _pio2_hi = float64(1.5707963267948966) /* 0x3FF921FB, 0x54442D18 */ +var _pio2_lo = float64(6.123233995736766e-17) /* 0x3C91A626, 0x33145C07 */ +var _pS0 = float64(0.16666666666666666) /* 0x3FC55555, 0x55555555 */ +var _pS1 = -Float64FromFloat64(0.3255658186224009) /* 0xBFD4D612, 0x03EB6F7D */ +var _pS2 = float64(0.20121253213486293) /* 0x3FC9C155, 0x0E884455 */ +var _pS3 = -Float64FromFloat64(0.04005553450067941) /* 0xBFA48228, 0xB5688F3B */ +var _pS4 = float64(0.0007915349942898145) /* 0x3F49EFE0, 0x7501B288 */ +var _pS5 = float64(3.479331075960212e-05) /* 0x3F023DE1, 0x0DFDF709 */ +var _qS1 = -Float64FromFloat64(2.403394911734414) /* 0xC0033A27, 0x1C8A2D4B */ +var _qS2 = float64(2.0209457602335057) /* 0x40002AE5, 0x9C598AC8 */ +var _qS3 = -Float64FromFloat64(0.6882839716054533) /* 0xBFE6066C, 0x1B8D0159 */ +var _qS4 = float64(0.07703815055590194) /* 0x3FB3B8C5, 0xB12E9282 */ + +func _R(tls *TLS, z float64) (r float64) { + var p, q Tdouble_t + _, _ = p, q + p = Tdouble_t(z * (_pS0 + float64(z*(_pS1+float64(z*(_pS2+float64(z*(_pS3+float64(z*(_pS4+float64(z*_pS5))))))))))) + q = float64(1) + float64(z*(_qS1+float64(z*(_qS2+float64(z*(_qS3+float64(z*_qS4))))))) + return p / q +} + +func Xacos(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c, df, s, w, z float64 + var hx, ix, lx Tuint32_t + var v1 Tuint64_t + _, _, _, _, _, _, _, _, _ = c, df, hx, ix, lx, s, w, z, v1 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = hx & uint32(0x7fffffff) + /* |x| >= 1 or nan */ + if ix >= uint32(0x3ff00000) { + lx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x))) + if ix-uint32(0x3ff00000)|lx == uint32(0) { + /* acos(1)=0, acos(-1)=pi */ + if hx>>int32(31) != 0 { + return float64(Float64FromInt32(2)*_pio2_hi) + Float64FromFloat32(7.52316384526264e-37) + } + return Float64FromInt32(0) + } + return Float64FromInt32(0) / (x - x) + } + /* |x| < 0.5 */ + if ix < uint32(0x3fe00000) { + if ix <= uint32(0x3c600000) { /* |x| < 2**-57 */ + return _pio2_hi + Float64FromFloat32(7.52316384526264e-37) + } + return _pio2_hi - (x - (_pio2_lo - float64(x*_R(tls, float64(x*x))))) + } + /* x < -0.5 */ + if hx>>int32(31) != 0 { + z = float64((float64(1) + x) * float64(0.5)) + s = Xsqrt(tls, z) + w = float64(_R(tls, z)*s) - _pio2_lo + return float64(Float64FromInt32(2) * (_pio2_hi - (s + w))) + } + /* x > 0.5 */ + z = float64((float64(1) - x) * float64(0.5)) + s = Xsqrt(tls, z) + df = s + v1 = *(*Tuint64_t)(unsafe.Pointer(&df))>>Int32FromInt32(32)< %v", r) }() + } + var c, df, s, w, z float32 + var hx, ix, v1 Tuint32_t + _, _, _, _, _, _, _, _ = c, df, hx, ix, s, w, z, v1 + hx = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = hx & uint32(0x7fffffff) + /* |x| >= 1 or nan */ + if ix >= uint32(0x3f800000) { + if ix == uint32(0x3f800000) { + if hx>>int32(31) != 0 { + return float32(Float32FromInt32(2)*_pio2_hi1) + Float32FromFloat32(7.52316384526264e-37) + } + return Float32FromInt32(0) + } + return Float32FromInt32(0) / (x - x) + } + /* |x| < 0.5 */ + if ix < uint32(0x3f000000) { + if ix <= uint32(0x32800000) { /* |x| < 2**-26 */ + return _pio2_hi1 + Float32FromFloat32(7.52316384526264e-37) + } + return _pio2_hi1 - (x - (_pio2_lo1 - float32(x*_R1(tls, float32(x*x))))) + } + /* x < -0.5 */ + if hx>>int32(31) != 0 { + z = float32((Float32FromInt32(1) + x) * Float32FromFloat32(0.5)) + s = Xsqrtf(tls, z) + w = float32(_R1(tls, z)*s) - _pio2_lo1 + return float32(Float32FromInt32(2) * (_pio2_hi1 - (s + w))) + } + /* x > 0.5 */ + z = float32((Float32FromInt32(1) - x) * Float32FromFloat32(0.5)) + s = Xsqrtf(tls, z) + hx = *(*Tuint32_t)(unsafe.Pointer(&s)) + v1 = hx & uint32(0xfffff000) + df = *(*float32)(unsafe.Pointer(&v1)) + c = (z - float32(df*df)) / (s + df) + w = float32(_R1(tls, z)*s) + c + return float32(Float32FromInt32(2) * (df + w)) +} + +// C documentation +// +// /* acosh(x) = log(x + sqrt(x*x-1)) */ +func Xacosh(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e uint32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = e + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + e = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + /* x < 1 domain error is handled in the called functions */ + if e < Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(1)) { + /* |x| < 2, up to 2ulp error in [1,1.125] */ + return Xlog1p(tls, x-Float64FromInt32(1)+Xsqrt(tls, float64((x-Float64FromInt32(1))*(x-Float64FromInt32(1)))+float64(Float64FromInt32(2)*(x-Float64FromInt32(1))))) + } + if e < Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(26)) { + /* |x| < 0x1p26 */ + return Xlog(tls, float64(Float64FromInt32(2)*x)-Float64FromInt32(1)/(x+Xsqrt(tls, float64(x*x)-Float64FromInt32(1)))) + } + /* |x| >= 0x1p26 or nan */ + return Xlog(tls, x) + float64(0.6931471805599453) +} + +// C documentation +// +// /* acosh(x) = log(x + sqrt(x*x-1)) */ +func Xacoshf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var a Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _ = a + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + a = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + if a < Uint32FromInt32(Int32FromInt32(0x3f800000)+Int32FromInt32(1)<= 0x1p12 or x <= -2 or nan */ + return Xlogf(tls, x) + Float32FromFloat32(0.6931471805599453) +} + +func Xacoshl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xacosh(tls, x) +} + +func Xacosl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xacos(tls, x) +} + +var _pio2_hi2 = float64(1.5707963267948966) /* 0x3FF921FB, 0x54442D18 */ +var _pio2_lo2 = float64(6.123233995736766e-17) /* 0x3C91A626, 0x33145C07 */ +/* coefficients for R(x^2) */ +var _pS02 = float64(0.16666666666666666) /* 0x3FC55555, 0x55555555 */ +var _pS12 = -Float64FromFloat64(0.3255658186224009) /* 0xBFD4D612, 0x03EB6F7D */ +var _pS22 = float64(0.20121253213486293) /* 0x3FC9C155, 0x0E884455 */ +var _pS31 = -Float64FromFloat64(0.04005553450067941) /* 0xBFA48228, 0xB5688F3B */ +var _pS41 = float64(0.0007915349942898145) /* 0x3F49EFE0, 0x7501B288 */ +var _pS51 = float64(3.479331075960212e-05) /* 0x3F023DE1, 0x0DFDF709 */ +var _qS12 = -Float64FromFloat64(2.403394911734414) /* 0xC0033A27, 0x1C8A2D4B */ +var _qS21 = float64(2.0209457602335057) /* 0x40002AE5, 0x9C598AC8 */ +var _qS31 = -Float64FromFloat64(0.6882839716054533) /* 0xBFE6066C, 0x1B8D0159 */ +var _qS41 = float64(0.07703815055590194) /* 0x3FB3B8C5, 0xB12E9282 */ + +func _R2(tls *TLS, z float64) (r float64) { + var p, q Tdouble_t + _, _ = p, q + p = Tdouble_t(z * (_pS02 + float64(z*(_pS12+float64(z*(_pS22+float64(z*(_pS31+float64(z*(_pS41+float64(z*_pS51))))))))))) + q = float64(1) + float64(z*(_qS12+float64(z*(_qS21+float64(z*(_qS31+float64(z*_qS41))))))) + return p / q +} + +func Xasin(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var c, f, r, s, z float64 + var hx, ix, lx Tuint32_t + var v1 Tuint64_t + _, _, _, _, _, _, _, _, _ = c, f, hx, ix, lx, r, s, z, v1 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = hx & uint32(0x7fffffff) + /* |x| >= 1 or nan */ + if ix >= uint32(0x3ff00000) { + lx = uint32(*(*Tuint64_t)(unsafe.Pointer(&x))) + if ix-uint32(0x3ff00000)|lx == uint32(0) { + /* asin(1) = +-pi/2 with inexact */ + return float64(x*_pio2_hi2) + Float64FromFloat32(7.52316384526264e-37) + } + return Float64FromInt32(0) / (x - x) + } + /* |x| < 0.5 */ + if ix < uint32(0x3fe00000) { + /* if 0x1p-1022 <= |x| < 0x1p-26, avoid raising underflow */ + if ix < uint32(0x3e500000) && ix >= uint32(0x00100000) { + return x + } + return x + float64(x*_R2(tls, float64(x*x))) + } + /* 1 > |x| >= 0.5 */ + z = float64((Float64FromInt32(1) - Xfabs(tls, x)) * float64(0.5)) + s = Xsqrt(tls, z) + r = _R2(tls, z) + if ix >= uint32(0x3fef3333) { /* if |x| > 0.975 */ + x = _pio2_hi2 - (float64(Float64FromInt32(2)*(s+float64(s*r))) - _pio2_lo2) + } else { + /* f+c = sqrt(z) */ + f = s + v1 = *(*Tuint64_t)(unsafe.Pointer(&f))>>Int32FromInt32(32)<>int32(31) != 0 { + return -x + } + return x +} + +var _pio2 = float64(1.5707963267948966) + +/* coefficients for R(x^2) */ +var _pS03 = float32(0.16666586697) +var _pS13 = float32(-Float64FromFloat64(0.042743422091)) +var _pS23 = float32(-Float64FromFloat64(0.008656363003)) +var _qS13 = float32(-Float64FromFloat64(0.7066296339)) + +func _R3(tls *TLS, z float32) (r float32) { + var p, q Tfloat_t + _, _ = p, q + p = Tfloat_t(z * (_pS03 + float32(z*(_pS13+float32(z*_pS23))))) + q = Float32FromFloat32(1) + float32(z*_qS13) + return p / q +} + +func Xasinf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var hx, ix Tuint32_t + var s float64 + var z float32 + _, _, _, _ = hx, ix, s, z + hx = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = hx & uint32(0x7fffffff) + if ix >= uint32(0x3f800000) { /* |x| >= 1 */ + if ix == uint32(0x3f800000) { /* |x| == 1 */ + return float32(float64(float64(x)*_pio2) + Float64FromFloat32(7.52316384526264e-37)) + } /* asin(+-1) = +-pi/2 with inexact */ + return Float32FromInt32(0) / (x - x) /* asin(|x|>1) is NaN */ + } + if ix < uint32(0x3f000000) { /* |x| < 0.5 */ + /* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */ + if ix < uint32(0x39800000) && ix >= uint32(0x00800000) { + return x + } + return x + float32(x*_R3(tls, float32(x*x))) + } + /* 1 > |x| >= 0.5 */ + z = float32((Float32FromInt32(1) - Xfabsf(tls, x)) * Float32FromFloat32(0.5)) + s = Xsqrt(tls, float64(z)) + x = float32(_pio2 - float64(Float64FromInt32(2)*(s+float64(s*float64(_R3(tls, z)))))) + if hx>>int32(31) != 0 { + return -x + } + return x +} + +// C documentation +// +// /* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ +func Xasinh(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s uint32 + var y float32 + var y1, y2, v1 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = e, s, y, y1, y2, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + s = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + /* |x| */ + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + x3 = *(*float64)(unsafe.Pointer(bp)) + if e >= Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(26)) { + /* |x| >= 0x1p26 or inf or nan */ + x3 = Xlog(tls, x3) + float64(0.6931471805599453) + } else { + if e >= Uint32FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(1)) { + /* |x| >= 2 */ + x3 = Xlog(tls, float64(Float64FromInt32(2)*x3)+Float64FromInt32(1)/(Xsqrt(tls, float64(x3*x3)+Float64FromInt32(1))+x3)) + } else { + if e >= Uint32FromInt32(Int32FromInt32(0x3ff)-Int32FromInt32(26)) { + /* |x| >= 0x1p-26, up to 1.6ulp error in [0.125,0.5] */ + x3 = Xlog1p(tls, x3+float64(x3*x3)/(Xsqrt(tls, float64(x3*x3)+Float64FromInt32(1))+Float64FromInt32(1))) + } else { + /* |x| < 0x1p-26, raise inexact if x != 0 */ + if uint64(8) == uint64(4) { + y = float32(x3 + Float64FromFloat32(1.329227995784916e+36)) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } else { + y2 = float64(x3 + Float64FromFloat32(1.329227995784916e+36)) + } + } + } + } + } + if s != 0 { + v1 = -x3 + } else { + v1 = x3 + } + return v1 +} + +// C documentation +// +// /* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ +func Xasinhf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i Tuint32_t + var s uint32 + var y, v1 float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _ = i, s, y, y1, y2, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + i = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + s = *(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31) + /* |x| */ + *(*Tuint32_t)(unsafe.Pointer(bp)) = i + x3 = *(*float32)(unsafe.Pointer(bp)) + if i >= Uint32FromInt32(Int32FromInt32(0x3f800000)+Int32FromInt32(12)<= 0x1p12 or inf or nan */ + x3 = Xlogf(tls, x3) + Float32FromFloat32(0.6931471805599453) + } else { + if i >= Uint32FromInt32(Int32FromInt32(0x3f800000)+Int32FromInt32(1)<= 2 */ + x3 = Xlogf(tls, float32(Float32FromInt32(2)*x3)+Float32FromInt32(1)/(Xsqrtf(tls, float32(x3*x3)+Float32FromInt32(1))+x3)) + } else { + if i >= Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(12)<= 0x1p-12, up to 1.6ulp error in [0.125,0.5] */ + x3 = Xlog1pf(tls, x3+float32(x3*x3)/(Xsqrtf(tls, float32(x3*x3)+Float32FromInt32(1))+Float32FromInt32(1))) + } else { + /* |x| < 0x1p-12, raise inexact if x!=0 */ + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + } + } + } + if s != 0 { + v1 = -x3 + } else { + v1 = x3 + } + return v1 +} + +func Xasinhl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xasinh(tls, x) +} + +func Xasinl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xasin(tls, x) +} + +var _atanhi = [4]float64{ + 0: float64(0.4636476090008061), + 1: float64(0.7853981633974483), + 2: float64(0.982793723247329), + 3: float64(1.5707963267948966), +} + +var _atanlo = [4]float64{ + 0: float64(2.2698777452961687e-17), + 1: float64(3.061616997868383e-17), + 2: float64(1.3903311031230998e-17), + 3: float64(6.123233995736766e-17), +} + +var _aT = [11]float64{ + 0: float64(0.3333333333333293), + 1: -Float64FromFloat64(0.19999999999876483), + 2: float64(0.14285714272503466), + 3: -Float64FromFloat64(0.11111110405462356), + 4: float64(0.09090887133436507), + 5: -Float64FromFloat64(0.0769187620504483), + 6: float64(0.06661073137387531), + 7: -Float64FromFloat64(0.058335701337905735), + 8: float64(0.049768779946159324), + 9: -Float64FromFloat64(0.036531572744216916), + 10: float64(0.016285820115365782), +} + +func Xatan(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var id int32 + var ix, sign Tuint32_t + var s1, s2, w, z, v3 Tdouble_t + var y float32 + var y1, y2 float64 + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _, _, _, _, _, _ = id, ix, s1, s2, sign, w, y, y1, y2, z, v1, v3 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x44100000) { /* if |x| >= 2^66 */ + *(*float64)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 + _2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var __u1, __u2 Tuint64_t + var ix, iy, lx, ly, m Tuint32_t + var z, v6 float64 + var v1, v3 uint64 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _, _, _, _, _, _ = __u1, __u2, ix, iy, lx, ly, m, z, v1, v3, v5, v6 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<> int32(32)) + lx = uint32(__u1) + __u2 = *(*Tuint64_t)(unsafe.Pointer(&y)) + iy = uint32(__u2 >> int32(32)) + ly = uint32(__u2) + if ix-uint32(0x3ff00000)|lx == uint32(0) { /* x = 1.0 */ + return Xatan(tls, y) + } + m = iy>>Int32FromInt32(31)&uint32(1) | ix>>Int32FromInt32(30)&uint32(2) /* 2*sign(x)+sign(y) */ + ix = ix & uint32(0x7fffffff) + iy = iy & uint32(0x7fffffff) + /* when y = 0 */ + if iy|ly == uint32(0) { + switch m { + case uint32(0): + fallthrough + case uint32(1): + return y /* atan(+-0,+anything)=+-0 */ + case uint32(2): + return _pi /* atan(+0,-anything) = pi */ + case uint32(3): + return -_pi /* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if ix|lx == uint32(0) { + if m&uint32(1) != 0 { + v6 = -_pi / Float64FromInt32(2) + } else { + v6 = _pi / Float64FromInt32(2) + } + return v6 + } + /* when x is INF */ + if ix == uint32(0x7ff00000) { + if iy == uint32(0x7ff00000) { + switch m { + case uint32(0): + return _pi / Float64FromInt32(4) /* atan(+INF,+INF) */ + case uint32(1): + return -_pi / Float64FromInt32(4) /* atan(-INF,+INF) */ + case uint32(2): + return float64(Float64FromInt32(3)*_pi) / Float64FromInt32(4) /* atan(+INF,-INF) */ + case uint32(3): + return float64(float64(-Int32FromInt32(3))*_pi) / Float64FromInt32(4) /* atan(-INF,-INF) */ + } + } else { + switch m { + case uint32(0): + return float64(0) /* atan(+...,+INF) */ + case uint32(1): + return -Float64FromFloat64(0) /* atan(-...,+INF) */ + case uint32(2): + return _pi /* atan(+...,-INF) */ + case uint32(3): + return -_pi /* atan(-...,-INF) */ + } + } + } + /* |y/x| > 0x1p64 */ + if ix+Uint32FromInt32(Int32FromInt32(64)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix, iy, m Tuint32_t + var z, v6 float32 + var v1, v3 uint32 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _, _, _ = ix, iy, m, z, v1, v3, v5, v6 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0; !v5 { + *(*float32)(unsafe.Pointer(bp)) = y + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + y + } + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + iy = *(*Tuint32_t)(unsafe.Pointer(&y)) + if ix == uint32(0x3f800000) { /* x=1.0 */ + return Xatanf(tls, y) + } + m = iy>>Int32FromInt32(31)&uint32(1) | ix>>Int32FromInt32(30)&uint32(2) /* 2*sign(x)+sign(y) */ + ix = ix & uint32(0x7fffffff) + iy = iy & uint32(0x7fffffff) + /* when y = 0 */ + if iy == uint32(0) { + switch m { + case uint32(0): + fallthrough + case uint32(1): + return y /* atan(+-0,+anything)=+-0 */ + case uint32(2): + return _pi1 /* atan(+0,-anything) = pi */ + case uint32(3): + return -_pi1 /* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if ix == uint32(0) { + if m&uint32(1) != 0 { + v6 = -_pi1 / Float32FromInt32(2) + } else { + v6 = _pi1 / Float32FromInt32(2) + } + return v6 + } + /* when x is INF */ + if ix == uint32(0x7f800000) { + if iy == uint32(0x7f800000) { + switch m { + case uint32(0): + return _pi1 / Float32FromInt32(4) /* atan(+INF,+INF) */ + case uint32(1): + return -_pi1 / Float32FromInt32(4) /* atan(-INF,+INF) */ + case uint32(2): + return float32(Float32FromInt32(3)*_pi1) / Float32FromInt32(4) /*atan(+INF,-INF)*/ + case uint32(3): + return float32(float32(-Int32FromInt32(3))*_pi1) / Float32FromInt32(4) /*atan(-INF,-INF)*/ + } + } else { + switch m { + case uint32(0): + return Float32FromFloat32(0) /* atan(+...,+INF) */ + case uint32(1): + return -Float32FromFloat32(0) /* atan(-...,+INF) */ + case uint32(2): + return _pi1 /* atan(+...,-INF) */ + case uint32(3): + return -_pi1 /* atan(-...,-INF) */ + } + } + } + /* |y/x| > 0x1p26 */ + if ix+Uint32FromInt32(Int32FromInt32(26)< %v", r) }() + } + return Xatan2(tls, y, x) +} + +var _atanhi1 = [4]float32{ + 0: float32(0.46364760399), + 1: float32(0.78539812565), + 2: float32(0.98279368877), + 3: float32(1.5707962513), +} + +var _atanlo1 = [4]float32{ + 0: float32(5.012158244e-09), + 1: float32(3.7748947079e-08), + 2: float32(3.447321717e-08), + 3: float32(7.5497894159e-08), +} + +var _aT1 = [5]float32{ + 0: float32(0.33333328366), + 1: float32(-Float64FromFloat64(0.19999158382)), + 2: float32(0.14253635705), + 3: float32(-Float64FromFloat64(0.10648017377)), + 4: float32(0.061687607318), +} + +func Xatanf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var id int32 + var ix, sign Tuint32_t + var s1, s2, w, z, v3 Tfloat_t + var y float32 + var y1, y2 float64 + var v1 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _, _, _, _, _, _, _ = id, ix, s1, s2, sign, w, y, y1, y2, z, v1, v3 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x4c800000) { /* if |x| >= 2**26 */ + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 + _2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x3 + } + z = _atanhi1[int32(3)] + Float32FromFloat32(7.52316384526264e-37) + if sign != 0 { + v3 = -z + } else { + v3 = z + } + return v3 + } + if ix < uint32(0x3ee00000) { /* |x| < 0.4375 */ + if ix < uint32(0x39800000) { /* |x| < 2**-12 */ + if ix < uint32(0x00800000) { + /* raise underflow for subnormal x */ + if uint64(4) == uint64(4) { + y = float32(x3 * x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 * x3) + } else { + y2 = float64(x3 * x3) + } + } + } + return x3 + } + id = -int32(1) + } else { + x3 = Xfabsf(tls, x3) + if ix < uint32(0x3f980000) { /* |x| < 1.1875 */ + if ix < uint32(0x3f300000) { /* 7/16 <= |x| < 11/16 */ + id = 0 + x3 = (float32(Float32FromFloat32(2)*x3) - Float32FromFloat32(1)) / (Float32FromFloat32(2) + x3) + } else { /* 11/16 <= |x| < 19/16 */ + id = int32(1) + x3 = (x3 - Float32FromFloat32(1)) / (x3 + Float32FromFloat32(1)) + } + } else { + if ix < uint32(0x401c0000) { /* |x| < 2.4375 */ + id = int32(2) + x3 = (x3 - Float32FromFloat32(1.5)) / (Float32FromFloat32(1) + float32(Float32FromFloat32(1.5)*x3)) + } else { /* 2.4375 <= |x| < 2**26 */ + id = int32(3) + x3 = -Float32FromFloat32(1) / x3 + } + } + } + /* end of argument reduction */ + z = Tfloat_t(x3 * x3) + w = Tfloat_t(z * z) + /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ + s1 = Tfloat_t(z * (_aT1[0] + float32(w*(_aT1[int32(2)]+float32(w*_aT1[int32(4)]))))) + s2 = Tfloat_t(w * (_aT1[int32(1)] + float32(w*_aT1[int32(3)]))) + if id < 0 { + return x3 - float32(x3*(s1+s2)) + } + z = _atanhi1[id] - (float32(x3*(s1+s2)) - _atanlo1[id] - x3) + if sign != 0 { + v3 = -z + } else { + v3 = z + } + return v3 +} + +// C documentation +// +// /* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ +func Xatanh(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s uint32 + var y float32 + var y1, y2 float64 + var y3, v1 Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _ = e, s, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + s = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + /* |x| */ + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + y3 = *(*float64)(unsafe.Pointer(bp)) + if e < Uint32FromInt32(Int32FromInt32(0x3ff)-Int32FromInt32(1)) { + if e < Uint32FromInt32(Int32FromInt32(0x3ff)-Int32FromInt32(32)) { + /* handle underflow */ + if e == uint32(0) { + if uint64(4) == uint64(4) { + y = float32(y3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(y3)) + } else { + y2 = float64(float32(y3)) + } + } + } + } else { + /* |x| < 0.5, up to 1.7ulp error */ + y3 = Tdouble_t(float64(0.5) * Xlog1p(tls, Tdouble_t(Float64FromInt32(2)*y3)+Tdouble_t(Tdouble_t(Float64FromInt32(2)*y3)*y3)/(Float64FromInt32(1)-y3))) + } + } else { + /* avoid overflow */ + y3 = Tdouble_t(float64(0.5) * Xlog1p(tls, float64(Float64FromInt32(2)*(y3/(Float64FromInt32(1)-y3))))) + } + if s != 0 { + v1 = -y3 + } else { + v1 = y3 + } + return v1 +} + +// C documentation +// +// /* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */ +func Xatanhf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var s uint32 + var y float32 + var y1, y2 float64 + var y3, v1 Tfloat_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _ = s, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + s = *(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31) + /* |x| */ + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + y3 = *(*float32)(unsafe.Pointer(bp)) + if *(*Tuint32_t)(unsafe.Pointer(bp)) < Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(1)< %v", r) }() + } + return Xatanh(tls, x) +} + +func Xatanl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xatan(tls, x) +} + +var _B1 = uint32(715094163) /* B1 = (1023-1023/3-0.03306235651)*2**20 */ +var _B2 = uint32(696219795) /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */ + +// C documentation +// +// /* |1/cbrt(x) - p(x)| < 2**-23.5 (~[-7.93e-8, 7.929e-8]). */ + +var _P0 = float64(1.87595182427177) /* 0x3ffe03e6, 0x0f61e692 */ +var _P1 = -Float64FromFloat64(1.8849797954337717) /* 0xbffe28e0, 0x92f02420 */ +var _P2 = float64(1.6214297201053545) /* 0x3ff9f160, 0x4a49d6c2 */ +var _P3 = -Float64FromFloat64(0.758397934778766) /* 0xbfe844cb, 0xbee751d9 */ +var _P4 = float64(0.14599619288661245) /* 0x3fc2b000, 0xd4e4edd7 */ + +func Xcbrt(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var hx Tuint32_t + var r, s, t, w Tdouble_t + var v1 uintptr + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = hx, r, s, t, w, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if hx >= uint32(0x7ff00000) { /* cbrt(NaN,INF) is itself */ + return x + x + } + /* + * Rough cbrt to 5 bits: + * cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3) + * where e is integral and >= 0, m is real and in [0, 1), and "/" and + * "%" are integer division and modulus with rounding towards minus + * infinity. The RHS is always >= the LHS and has a maximum relative + * error of about 1 in 16. Adding a bias of -0.03306235651 to the + * (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE + * floating point representation, for finite positive normal values, + * ordinary integer divison of the value in bits magically gives + * almost exactly the RHS of the above provided we first subtract the + * exponent bias (1023 for doubles) and later add it back. We do the + * subtraction virtually to keep e >= 0 so that ordinary integer + * division rounds towards minus infinity; this is also efficient. + */ + if hx < uint32(0x00100000) { /* zero or subnormal? */ + *(*float64)(unsafe.Pointer(bp)) = float64(x * float64(1.8014398509481984e+16)) + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if hx == uint32(0) { + return x + } /* cbrt(0) is itself */ + hx = hx/uint32(3) + _B2 + } else { + hx = hx/uint32(3) + _B1 + } + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (Uint64FromUint64(1) << Int32FromInt32(63))) + *(*Tuint64_t)(unsafe.Pointer(bp)) |= uint64(hx) << int32(32) + t = *(*float64)(unsafe.Pointer(bp)) + /* + * New cbrt to 23 bits: + * cbrt(x) = t*cbrt(x/t**3) ~= t*P(t**3/x) + * where P(r) is a polynomial of degree 4 that approximates 1/cbrt(r) + * to within 2**-23.5 when |r - 1| < 1/10. The rough approximation + * has produced t such than |t/cbrt(x) - 1| ~< 1/32, and cubing this + * gives us bounds for r = t**3/x. + * + * Try to optimize for parallel evaluation as in __tanf.c. + */ + r = Tdouble_t(Tdouble_t(t*t) * (t / x)) + t = Tdouble_t(t * (_P0 + float64(r*(_P1+float64(r*_P2))) + float64(Tdouble_t(Tdouble_t(r*r)*r)*(_P3+float64(r*_P4))))) + /* + * Round t away from zero to 23 bits (sloppily except for ensuring that + * the result is larger in magnitude than cbrt(x) but not much more than + * 2 23-bit ulps larger). With rounding towards zero, the error bound + * would be ~5/6 instead of ~4/6. With a maximum error of 2 23-bit ulps + * in the rounded t, the infinite-precision error in the Newton + * approximation barely affects third digit in the final error + * 0.667; the error in the rounded t can be up to about 3 23-bit ulps + * before the final error is larger than 0.667 ulps. + */ + *(*float64)(unsafe.Pointer(bp)) = t + *(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(*(*Tuint64_t)(unsafe.Pointer(bp))+Uint64FromUint32(0x80000000)) & uint64(0xffffffffc0000000) + t = *(*float64)(unsafe.Pointer(bp)) + /* one step Newton iteration to 53 bits with error < 0.667 ulps */ + s = Tdouble_t(t * t) /* t*t is exact */ + r = x / s /* error <= 0.5 ulps; |r| < |t| */ + w = t + t /* t+t is exact */ + r = (r - t) / (w + r) /* r-t is exact; w+r ~= 3*t */ + t = t + Tdouble_t(t*r) /* error <= 0.5 + 0.5/3 + epsilon */ + return t +} + +var _B11 = uint32(709958130) /* B1 = (127-127.0/3-0.03306235651)*2**23 */ +var _B21 = uint32(642849266) /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */ + +func Xcbrtf(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var T, r Tdouble_t + var hx Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _ = T, hx, r + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + if hx >= uint32(0x7f800000) { /* cbrt(NaN,INF) is itself */ + return x + x + } + /* rough cbrt to 5 bits */ + if hx < uint32(0x00800000) { /* zero or subnormal? */ + if hx == uint32(0) { + return x + } /* cbrt(+-0) is itself */ + *(*float32)(unsafe.Pointer(bp)) = float32(x * Float32FromFloat32(1.6777216e+07)) + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + hx = hx/uint32(3) + _B21 + } else { + hx = hx/uint32(3) + _B11 + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x80000000) + *(*Tuint32_t)(unsafe.Pointer(bp)) |= hx + /* + * First step Newton iteration (solving t*t-x/t == 0) to 16 bits. In + * double precision so that its terms can be arranged for efficiency + * without causing overflow or underflow. + */ + T = float64(*(*float32)(unsafe.Pointer(bp))) + r = Tdouble_t(Tdouble_t(T*T) * T) + T = Tdouble_t(T*(float64(x)+float64(x)+r)) / (float64(x) + r + r) + /* + * Second step Newton iteration to 47 bits. In double precision for + * efficiency and accuracy. + */ + r = Tdouble_t(Tdouble_t(T*T) * T) + T = Tdouble_t(T*(float64(x)+float64(x)+r)) / (float64(x) + r + r) + /* rounding to 24 bits is perfect in round-to-nearest mode */ + return float32(T) +} + +func Xcbrtl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcbrt(tls, x) +} + +const DBL_EPSILON5 = 2.220446049250313e-16 + +var _toint2 = Float64FromInt32(1) / Float64FromFloat64(2.220446049250313e-16) + +func Xceil(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var y float32 + var y1, y2, v1 float64 + var y3 Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = e, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if e >= Int32FromInt32(0x3ff)+Int32FromInt32(52) || x3 == Float64FromInt32(0) { + return x3 + } + /* y = int(x) - x, where int(x) is an integer neighbor of x */ + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + y3 = x3 - _toint2 + _toint2 - x3 + } else { + y3 = x3 + _toint2 - _toint2 - x3 + } + /* special case because of non-nearest rounding modes */ + if e <= Int32FromInt32(0x3ff)-Int32FromInt32(1) { + if uint64(8) == uint64(4) { + y = float32(y3) + } else { + if uint64(8) == uint64(8) { + y1 = y3 + } else { + y2 = y3 + } + } + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + v1 = -Float64FromFloat64(0) + } else { + v1 = Float64FromInt32(1) + } + return v1 + } + if y3 < Float64FromInt32(0) { + return x3 + y3 + Float64FromInt32(1) + } + return x3 + y3 +} + +const DBL_EPSILON6 = 0 + +func Xceilf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var m Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e, m, y, y1, y2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp))>>Int32FromInt32(23)&Uint32FromInt32(0xff)) - int32(0x7f) + if e >= int32(23) { + return x3 + } + if e >= 0 { + m = Uint32FromInt32(int32(0x007fffff) >> e) + if *(*Tuint32_t)(unsafe.Pointer(bp))&m == uint32(0) { + return x3 + } + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) == uint32(0) { + *(*Tuint32_t)(unsafe.Pointer(bp)) += m + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= ^m + } else { + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + *(*float32)(unsafe.Pointer(bp)) = float32(-Float64FromFloat64(0)) + } else { + if *(*Tuint32_t)(unsafe.Pointer(bp))< %v", r) }() + } + return Xceil(tls, x) +} + +func Xcopysign(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uintptr + var _ /* ux at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = y + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (-Uint64FromUint64(1) / Uint64FromInt32(2))) + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) | *(*Tuint64_t)(unsafe.Pointer(bp + 8))&(Uint64FromUint64(1)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ux at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = y + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + *(*Tuint32_t)(unsafe.Pointer(bp)) |= *(*Tuint32_t)(unsafe.Pointer(bp + 4)) & uint32(0x80000000) + return *(*float32)(unsafe.Pointer(bp)) +} + +func Xcopysignl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcopysign(tls, x, y) +} + +func Xcos(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n uint32 + var y float32 + var y1, y2 float64 + var _ /* y at bp+0 */ [2]float64 + _, _, _, _, _ = ix, n, y, y1, y2 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* |x| ~< pi/4 */ + if ix <= uint32(0x3fe921fb) { + if ix < uint32(0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */ + /* raise inexact if x!=0 */ + if uint64(8) == uint64(4) { + y = float32(x3 + Float64FromFloat32(1.329227995784916e+36)) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } else { + y2 = float64(x3 + Float64FromFloat32(1.329227995784916e+36)) + } + } + return float64(1) + } + return X__cos(tls, x3, Float64FromInt32(0)) + } + /* cos(Inf or NaN) is NaN */ + if ix >= uint32(0x7ff00000) { + return x3 - x3 + } + /* argument reduction */ + n = Uint32FromInt32(X__rem_pio2(tls, x3, bp)) + switch n & Uint32FromInt32(3) { + case uint32(0): + return X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + case uint32(1): + return -X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + case uint32(2): + return -X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + default: + return X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + } + return r +} + +const M_PI_23 = 1.5707963267948966 + +// C documentation +// +// /* Small multiples of pi/2 rounded to double precision. */ + +var _c1pio2 = float64(Float64FromInt32(1) * Float64FromFloat64(1.5707963267948966)) /* 0x3FF921FB, 0x54442D18 */ +var _c2pio2 = float64(Float64FromInt32(2) * Float64FromFloat64(1.5707963267948966)) /* 0x400921FB, 0x54442D18 */ +var _c3pio2 = float64(Float64FromInt32(3) * Float64FromFloat64(1.5707963267948966)) /* 0x4012D97C, 0x7F3321D2 */ +var _c4pio2 = float64(Float64FromInt32(4) * Float64FromFloat64(1.5707963267948966)) /* 0x401921FB, 0x54442D18 */ + +func Xcosf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n, sign uint32 + var y float32 + var y1, y2, v1 float64 + var _ /* y at bp+0 */ float64 + _, _, _, _, _, _, _ = ix, n, sign, y, y1, y2, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + if ix <= uint32(0x3f490fda) { /* |x| ~<= pi/4 */ + if ix < uint32(0x39800000) { /* |x| < 2**-12 */ + /* raise inexact if x != 0 */ + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + return Float32FromFloat32(1) + } + return X__cosdf(tls, float64(x3)) + } + if ix <= uint32(0x407b53d1) { /* |x| ~<= 5*pi/4 */ + if ix > uint32(0x4016cbe3) { /* |x| ~> 3*pi/4 */ + if sign != 0 { + v1 = float64(x3) + _c2pio2 + } else { + v1 = float64(x3) - _c2pio2 + } + return -X__cosdf(tls, v1) + } else { + if sign != 0 { + return X__sindf(tls, float64(x3)+_c1pio2) + } else { + return X__sindf(tls, _c1pio2-float64(x3)) + } + } + } + if ix <= uint32(0x40e231d5) { /* |x| ~<= 9*pi/4 */ + if ix > uint32(0x40afeddf) { /* |x| ~> 7*pi/4 */ + if sign != 0 { + v1 = float64(x3) + _c4pio2 + } else { + v1 = float64(x3) - _c4pio2 + } + return X__cosdf(tls, v1) + } else { + if sign != 0 { + return X__sindf(tls, float64(-x3)-_c3pio2) + } else { + return X__sindf(tls, float64(x3)-_c3pio2) + } + } + } + /* cos(Inf or NaN) is NaN */ + if ix >= uint32(0x7f800000) { + return x3 - x3 + } + /* general argument reduction needed */ + n = Uint32FromInt32(X__rem_pio2f(tls, x3, bp)) + switch n & Uint32FromInt32(3) { + case uint32(0): + return X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + case uint32(1): + return X__sindf(tls, -**(**float64)(__ccgo_up(bp))) + case uint32(2): + return -X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + default: + return X__sindf(tls, **(**float64)(__ccgo_up(bp))) + } + return r +} + +const M_PI_24 = 0 + +// C documentation +// +// /* 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) +// */ +func Xcosh(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var t, y1, y2 float64 + var w Tuint32_t + var y float32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _ = t, w, y, y1, y2 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + /* |x| */ + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + x3 = *(*float64)(unsafe.Pointer(bp)) + w = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + /* |x| < log(2) */ + if w < uint32(0x3fe62e42) { + if w < Uint32FromInt32(Int32FromInt32(0x3ff00000)-Int32FromInt32(26)<log(0x1p26) then the 1/t is not needed */ + return float64(float64(0.5) * (t + Float64FromInt32(1)/t)) + } + /* |x| > log(DBL_MAX) or nan */ + /* note: the result is stored to handle overflow */ + t = X__expo2(tls, x3, float64(1)) + return t +} + +func Xcoshf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var t, y float32 + var w Tuint32_t + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = t, w, y, y1, y2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + /* |x| */ + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + x3 = *(*float32)(unsafe.Pointer(bp)) + w = *(*Tuint32_t)(unsafe.Pointer(bp)) + /* |x| < log(2) */ + if w < uint32(0x3f317217) { + if w < Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(12)< log(FLT_MAX) or nan */ + t = X__expo2f(tls, x3, Float32FromFloat32(1)) + return t +} + +func Xcoshl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcosh(tls, x) +} + +func Xcosl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcos(tls, x) +} + +var _erx = float64(0.8450629115104675) /* 0x3FEB0AC1, 0x60000000 */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +var _efx8 = float64(1.0270333367641007) /* 0x3FF06EBA, 0x8214DB69 */ +var _pp0 = float64(0.12837916709551256) /* 0x3FC06EBA, 0x8214DB68 */ +var _pp1 = -Float64FromFloat64(0.3250421072470015) /* 0xBFD4CD7D, 0x691CB913 */ +var _pp2 = -Float64FromFloat64(0.02848174957559851) /* 0xBF9D2A51, 0xDBD7194F */ +var _pp3 = -Float64FromFloat64(0.005770270296489442) /* 0xBF77A291, 0x236668E4 */ +var _pp4 = -Float64FromFloat64(2.3763016656650163e-05) /* 0xBEF8EAD6, 0x120016AC */ +var _qq1 = float64(0.39791722395915535) /* 0x3FD97779, 0xCDDADC09 */ +var _qq2 = float64(0.0650222499887673) /* 0x3FB0A54C, 0x5536CEBA */ +var _qq3 = float64(0.005081306281875766) /* 0x3F74D022, 0xC4D36B0F */ +var _qq4 = float64(0.00013249473800432164) /* 0x3F215DC9, 0x221C1A10 */ +var _qq5 = -Float64FromFloat64(3.960228278775368e-06) /* 0xBED09C43, 0x42A26120 */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +var _pa0 = -Float64FromFloat64(0.0023621185607526594) /* 0xBF6359B8, 0xBEF77538 */ +var _pa1 = float64(0.41485611868374833) /* 0x3FDA8D00, 0xAD92B34D */ +var _pa2 = -Float64FromFloat64(0.3722078760357013) /* 0xBFD7D240, 0xFBB8C3F1 */ +var _pa3 = float64(0.31834661990116175) /* 0x3FD45FCA, 0x805120E4 */ +var _pa4 = -Float64FromFloat64(0.11089469428239668) /* 0xBFBC6398, 0x3D3E28EC */ +var _pa5 = float64(0.035478304325618236) /* 0x3FA22A36, 0x599795EB */ +var _pa6 = -Float64FromFloat64(0.002166375594868791) /* 0xBF61BF38, 0x0A96073F */ +var _qa1 = float64(0.10642088040084423) /* 0x3FBB3E66, 0x18EEE323 */ +var _qa2 = float64(0.540397917702171) /* 0x3FE14AF0, 0x92EB6F33 */ +var _qa3 = float64(0.07182865441419627) /* 0x3FB2635C, 0xD99FE9A7 */ +var _qa4 = float64(0.12617121980876164) /* 0x3FC02660, 0xE763351F */ +var _qa5 = float64(0.01363708391202905) /* 0x3F8BEDC2, 0x6B51DD1C */ +var _qa6 = float64(0.011984499846799107) /* 0x3F888B54, 0x5735151D */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +var _ra0 = -Float64FromFloat64(0.009864944034847148) /* 0xBF843412, 0x600D6435 */ +var _ra1 = -Float64FromFloat64(0.6938585727071818) /* 0xBFE63416, 0xE4BA7360 */ +var _ra2 = -Float64FromFloat64(10.558626225323291) /* 0xC0251E04, 0x41B0E726 */ +var _ra3 = -Float64FromFloat64(62.375332450326006) /* 0xC04F300A, 0xE4CBA38D */ +var _ra4 = -Float64FromFloat64(162.39666946257347) /* 0xC0644CB1, 0x84282266 */ +var _ra5 = -Float64FromFloat64(184.60509290671104) /* 0xC067135C, 0xEBCCABB2 */ +var _ra6 = -Float64FromFloat64(81.2874355063066) /* 0xC0545265, 0x57E4D2F2 */ +var _ra7 = -Float64FromFloat64(9.814329344169145) /* 0xC023A0EF, 0xC69AC25C */ +var _sa1 = float64(19.651271667439257) /* 0x4033A6B9, 0xBD707687 */ +var _sa2 = float64(137.65775414351904) /* 0x4061350C, 0x526AE721 */ +var _sa3 = float64(434.56587747522923) /* 0x407B290D, 0xD58A1A71 */ +var _sa4 = float64(645.3872717332679) /* 0x40842B19, 0x21EC2868 */ +var _sa5 = float64(429.00814002756783) /* 0x407AD021, 0x57700314 */ +var _sa6 = float64(108.63500554177944) /* 0x405B28A3, 0xEE48AE2C */ +var _sa7 = float64(6.570249770319282) /* 0x401A47EF, 0x8E484A93 */ +var _sa8 = -Float64FromFloat64(0.0604244152148581) /* 0xBFAEEFF2, 0xEE749A62 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +var _rb0 = -Float64FromFloat64(0.0098649429247001) /* 0xBF843412, 0x39E86F4A */ +var _rb1 = -Float64FromFloat64(0.799283237680523) /* 0xBFE993BA, 0x70C285DE */ +var _rb2 = -Float64FromFloat64(17.757954917754752) /* 0xC031C209, 0x555F995A */ +var _rb3 = -Float64FromFloat64(160.63638485582192) /* 0xC064145D, 0x43C5ED98 */ +var _rb4 = -Float64FromFloat64(637.5664433683896) /* 0xC083EC88, 0x1375F228 */ +var _rb5 = -Float64FromFloat64(1025.0951316110772) /* 0xC0900461, 0x6A2E5992 */ +var _rb6 = -Float64FromFloat64(483.5191916086514) /* 0xC07E384E, 0x9BDC383F */ +var _sb1 = float64(30.33806074348246) /* 0x403E568B, 0x261D5190 */ +var _sb2 = float64(325.7925129965739) /* 0x40745CAE, 0x221B9F0A */ +var _sb3 = float64(1536.729586084437) /* 0x409802EB, 0x189D5118 */ +var _sb4 = float64(3199.8582195085955) /* 0x40A8FFB7, 0x688C246A */ +var _sb5 = float64(2553.0504064331644) /* 0x40A3F219, 0xCEDF3BE6 */ +var _sb6 = float64(474.52854120695537) /* 0x407DA874, 0xE79FE763 */ +var _sb7 = -Float64FromFloat64(22.44095244658582) /* 0xC03670E2, 0x42712D62 */ + +func _erfc1(tls *TLS, x float64) (r float64) { + var P, Q, s Tdouble_t + _, _, _ = P, Q, s + s = Xfabs(tls, x) - Float64FromInt32(1) + P = _pa0 + float64(s*(_pa1+float64(s*(_pa2+float64(s*(_pa3+float64(s*(_pa4+float64(s*(_pa5+float64(s*_pa6))))))))))) + Q = Float64FromInt32(1) + Tdouble_t(s*(_qa1+float64(s*(_qa2+float64(s*(_qa3+float64(s*(_qa4+float64(s*(_qa5+float64(s*_qa6))))))))))) + return Float64FromInt32(1) - _erx - P/Q +} + +func _erfc2(tls *TLS, ix Tuint32_t, x float64) (r float64) { + var R, S, s Tdouble_t + var z float64 + var v1 Tuint64_t + _, _, _, _, _ = R, S, s, z, v1 + if ix < uint32(0x3ff40000) { /* |x| < 1.25 */ + return _erfc1(tls, x) + } + x = Xfabs(tls, x) + s = Float64FromInt32(1) / float64(x*x) + if ix < uint32(0x4006db6d) { /* |x| < 1/.35 ~ 2.85714 */ + R = _ra0 + float64(s*(_ra1+float64(s*(_ra2+float64(s*(_ra3+float64(s*(_ra4+float64(s*(_ra5+float64(s*(_ra6+float64(s*_ra7))))))))))))) + S = float64(1) + float64(s*(_sa1+float64(s*(_sa2+float64(s*(_sa3+float64(s*(_sa4+float64(s*(_sa5+float64(s*(_sa6+float64(s*(_sa7+float64(s*_sa8))))))))))))))) + } else { /* |x| > 1/.35 */ + R = _rb0 + float64(s*(_rb1+float64(s*(_rb2+float64(s*(_rb3+float64(s*(_rb4+float64(s*(_rb5+float64(s*_rb6))))))))))) + S = float64(1) + float64(s*(_sb1+float64(s*(_sb2+float64(s*(_sb3+float64(s*(_sb4+float64(s*(_sb5+float64(s*(_sb6+float64(s*_sb7))))))))))))) + } + z = x + v1 = *(*Tuint64_t)(unsafe.Pointer(&z))>>Int32FromInt32(32)< %v", r1) }() + } + var ix Tuint32_t + var r, s, y, z, v1 float64 + var sign int32 + _, _, _, _, _, _, _ = ix, r, s, sign, y, z, v1 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7ff00000) { + /* erf(nan)=nan, erf(+-inf)=+-1 */ + return float64(int32(1)-int32(2)*sign) + Float64FromInt32(1)/x + } + if ix < uint32(0x3feb0000) { /* |x| < 0.84375 */ + if ix < uint32(0x3e300000) { /* |x| < 2**-28 */ + /* avoid underflow */ + return float64(float64(0.125) * (float64(Float64FromInt32(8)*x) + float64(_efx8*x))) + } + z = float64(x * x) + r = _pp0 + float64(z*(_pp1+float64(z*(_pp2+float64(z*(_pp3+float64(z*_pp4))))))) + s = float64(1) + float64(z*(_qq1+float64(z*(_qq2+float64(z*(_qq3+float64(z*(_qq4+float64(z*_qq5))))))))) + y = r / s + return x + float64(x*y) + } + if ix < uint32(0x40180000) { /* 0.84375 <= |x| < 6 */ + y = Float64FromInt32(1) - _erfc2(tls, ix, x) + } else { + y = Float64FromInt32(1) - Float64FromFloat64(2.2250738585072014e-308) + } + if sign != 0 { + v1 = -y + } else { + v1 = y + } + return v1 +} + +func Xerfc(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, y, z, v1 float64 + var sign int32 + _, _, _, _, _, _, _ = ix, r, s, sign, y, z, v1 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7ff00000) { + /* erfc(nan)=nan, erfc(+-inf)=0,2 */ + return float64(int32(2)*sign) + Float64FromInt32(1)/x + } + if ix < uint32(0x3feb0000) { /* |x| < 0.84375 */ + if ix < uint32(0x3c700000) { /* |x| < 2**-56 */ + return float64(1) - x + } + z = float64(x * x) + r = _pp0 + float64(z*(_pp1+float64(z*(_pp2+float64(z*(_pp3+float64(z*_pp4))))))) + s = float64(1) + float64(z*(_qq1+float64(z*(_qq2+float64(z*(_qq3+float64(z*(_qq4+float64(z*_qq5))))))))) + y = r / s + if sign != 0 || ix < uint32(0x3fd00000) { /* x < 1/4 */ + return float64(1) - (x + float64(x*y)) + } + return float64(0.5) - (x - float64(0.5) + float64(x*y)) + } + if ix < uint32(0x403c0000) { /* 0.84375 <= |x| < 28 */ + if sign != 0 { + v1 = Float64FromInt32(2) - _erfc2(tls, ix, x) + } else { + v1 = _erfc2(tls, ix, x) + } + return v1 + } + if sign != 0 { + v1 = Float64FromInt32(2) - Float64FromFloat64(2.2250738585072014e-308) + } else { + v1 = float64(Float64FromFloat64(2.2250738585072014e-308) * Float64FromFloat64(2.2250738585072014e-308)) + } + return v1 +} + +var _erx1 = float32(0.84506291151) /* 0x3f58560b */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +var _efx81 = float32(1.027033329) /* 0x3f8375d4 */ +var _pp01 = float32(0.12837916613) /* 0x3e0375d4 */ +var _pp11 = float32(-Float64FromFloat64(0.32504209876)) /* 0xbea66beb */ +var _pp21 = float32(-Float64FromFloat64(0.028481749818)) /* 0xbce9528f */ +var _pp31 = float32(-Float64FromFloat64(0.005770270247)) /* 0xbbbd1489 */ +var _pp41 = float32(-Float64FromFloat64(2.3763017452e-05)) /* 0xb7c756b1 */ +var _qq11 = float32(0.39791721106) /* 0x3ecbbbce */ +var _qq21 = float32(0.0650222525) /* 0x3d852a63 */ +var _qq31 = float32(0.0050813062117) /* 0x3ba68116 */ +var _qq41 = float32(0.00013249473704) /* 0x390aee49 */ +var _qq51 = float32(-Float64FromFloat64(3.9602282413e-06)) /* 0xb684e21a */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +var _pa01 = float32(-Float64FromFloat64(0.0023621185683)) /* 0xbb1acdc6 */ +var _pa11 = float32(0.41485610604) /* 0x3ed46805 */ +var _pa21 = float32(-Float64FromFloat64(0.37220788002)) /* 0xbebe9208 */ +var _pa31 = float32(0.31834661961) /* 0x3ea2fe54 */ +var _pa41 = float32(-Float64FromFloat64(0.11089469492)) /* 0xbde31cc2 */ +var _pa51 = float32(0.035478305072) /* 0x3d1151b3 */ +var _pa61 = float32(-Float64FromFloat64(0.0021663755178)) /* 0xbb0df9c0 */ +var _qa11 = float32(0.10642088205) /* 0x3dd9f331 */ +var _qa21 = float32(0.54039794207) /* 0x3f0a5785 */ +var _qa31 = float32(0.071828655899) /* 0x3d931ae7 */ +var _qa41 = float32(0.12617121637) /* 0x3e013307 */ +var _qa51 = float32(0.013637083583) /* 0x3c5f6e13 */ +var _qa61 = float32(0.011984500103) /* 0x3c445aa3 */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +var _ra01 = float32(-Float64FromFloat64(0.0098649440333)) /* 0xbc21a093 */ +var _ra11 = float32(-Float64FromFloat64(0.6938585639)) /* 0xbf31a0b7 */ +var _ra21 = float32(-Float64FromFloat64(10.558626175)) /* 0xc128f022 */ +var _ra31 = float32(-Float64FromFloat64(62.375331879)) /* 0xc2798057 */ +var _ra41 = float32(-Float64FromFloat64(162.39666748)) /* 0xc322658c */ +var _ra51 = float32(-Float64FromFloat64(184.60508728)) /* 0xc3389ae7 */ +var _ra61 = float32(-Float64FromFloat64(81.287437439)) /* 0xc2a2932b */ +var _ra71 = float32(-Float64FromFloat64(9.8143291473)) /* 0xc11d077e */ +var _sa11 = float32(19.65127182) /* 0x419d35ce */ +var _sa21 = float32(137.65776062) /* 0x4309a863 */ +var _sa31 = float32(434.56588745) /* 0x43d9486f */ +var _sa41 = float32(645.38726807) /* 0x442158c9 */ +var _sa51 = float32(429.00814819) /* 0x43d6810b */ +var _sa61 = float32(108.63500214) /* 0x42d9451f */ +var _sa71 = float32(6.5702495575) /* 0x40d23f7c */ +var _sa81 = float32(-Float64FromFloat64(0.060424413532)) /* 0xbd777f97 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +var _rb01 = float32(-Float64FromFloat64(0.009864943102)) /* 0xbc21a092 */ +var _rb11 = float32(-Float64FromFloat64(0.79928326607)) /* 0xbf4c9dd4 */ +var _rb21 = float32(-Float64FromFloat64(17.757955551)) /* 0xc18e104b */ +var _rb31 = float32(-Float64FromFloat64(160.63638306)) /* 0xc320a2ea */ +var _rb41 = float32(-Float64FromFloat64(637.56646729)) /* 0xc41f6441 */ +var _rb51 = float32(-Float64FromFloat64(1025.0950928)) /* 0xc480230b */ +var _rb61 = float32(-Float64FromFloat64(483.51919556)) /* 0xc3f1c275 */ +var _sb11 = float32(30.338060379) /* 0x41f2b459 */ +var _sb21 = float32(325.79251099) /* 0x43a2e571 */ +var _sb31 = float32(1536.7296143) /* 0x44c01759 */ +var _sb41 = float32(3199.8581543) /* 0x4547fdbb */ +var _sb51 = float32(2553.050293) /* 0x451f90ce */ +var _sb61 = float32(474.52853394) /* 0x43ed43a7 */ +var _sb71 = float32(-Float64FromFloat64(22.440952301)) /* 0xc1b38712 */ + +func _erfc11(tls *TLS, x float32) (r float32) { + var P, Q, s Tfloat_t + _, _, _ = P, Q, s + s = Xfabsf(tls, x) - Float32FromInt32(1) + P = _pa01 + float32(s*(_pa11+float32(s*(_pa21+float32(s*(_pa31+float32(s*(_pa41+float32(s*(_pa51+float32(s*_pa61))))))))))) + Q = Float32FromInt32(1) + Tfloat_t(s*(_qa11+float32(s*(_qa21+float32(s*(_qa31+float32(s*(_qa41+float32(s*(_qa51+float32(s*_qa61))))))))))) + return Float32FromInt32(1) - _erx1 - P/Q +} + +func _erfc21(tls *TLS, ix Tuint32_t, x float32) (r float32) { + var R, S, s Tfloat_t + var z float32 + var v1 Tuint32_t + _, _, _, _, _ = R, S, s, z, v1 + if ix < uint32(0x3fa00000) { /* |x| < 1.25 */ + return _erfc11(tls, x) + } + x = Xfabsf(tls, x) + s = Float32FromInt32(1) / float32(x*x) + if ix < uint32(0x4036db6d) { /* |x| < 1/0.35 */ + R = _ra01 + float32(s*(_ra11+float32(s*(_ra21+float32(s*(_ra31+float32(s*(_ra41+float32(s*(_ra51+float32(s*(_ra61+float32(s*_ra71))))))))))))) + S = Float32FromFloat32(1) + float32(s*(_sa11+float32(s*(_sa21+float32(s*(_sa31+float32(s*(_sa41+float32(s*(_sa51+float32(s*(_sa61+float32(s*(_sa71+float32(s*_sa81))))))))))))))) + } else { /* |x| >= 1/0.35 */ + R = _rb01 + float32(s*(_rb11+float32(s*(_rb21+float32(s*(_rb31+float32(s*(_rb41+float32(s*(_rb51+float32(s*_rb61))))))))))) + S = Float32FromFloat32(1) + float32(s*(_sb11+float32(s*(_sb21+float32(s*(_sb31+float32(s*(_sb41+float32(s*(_sb51+float32(s*(_sb61+float32(s*_sb71))))))))))))) + } + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + v1 = ix & uint32(0xffffe000) + z = *(*float32)(unsafe.Pointer(&v1)) + return float32(Xexpf(tls, float32(-z*z)-Float32FromFloat32(0.5625))*Xexpf(tls, float32((z-x)*(z+x))+R/S)) / x +} + +func Xerff(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, y, z, v1 float32 + var sign int32 + _, _, _, _, _, _, _ = ix, r, s, sign, y, z, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + /* erf(nan)=nan, erf(+-inf)=+-1 */ + return float32(int32(1)-int32(2)*sign) + Float32FromInt32(1)/x + } + if ix < uint32(0x3f580000) { /* |x| < 0.84375 */ + if ix < uint32(0x31800000) { /* |x| < 2**-28 */ + /*avoid underflow */ + return float32(Float32FromFloat32(0.125) * (float32(Float32FromInt32(8)*x) + float32(_efx81*x))) + } + z = float32(x * x) + r = _pp01 + float32(z*(_pp11+float32(z*(_pp21+float32(z*(_pp31+float32(z*_pp41))))))) + s = Float32FromInt32(1) + float32(z*(_qq11+float32(z*(_qq21+float32(z*(_qq31+float32(z*(_qq41+float32(z*_qq51))))))))) + y = r / s + return x + float32(x*y) + } + if ix < uint32(0x40c00000) { /* |x| < 6 */ + y = Float32FromInt32(1) - _erfc21(tls, ix, x) + } else { + y = Float32FromInt32(1) - Float32FromFloat32(7.52316384526264e-37) + } + if sign != 0 { + v1 = -y + } else { + v1 = y + } + return v1 +} + +func Xerfcf(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, y, z, v1 float32 + var sign int32 + _, _, _, _, _, _, _ = ix, r, s, sign, y, z, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + /* erfc(nan)=nan, erfc(+-inf)=0,2 */ + return float32(int32(2)*sign) + Float32FromInt32(1)/x + } + if ix < uint32(0x3f580000) { /* |x| < 0.84375 */ + if ix < uint32(0x23800000) { /* |x| < 2**-56 */ + return Float32FromFloat32(1) - x + } + z = float32(x * x) + r = _pp01 + float32(z*(_pp11+float32(z*(_pp21+float32(z*(_pp31+float32(z*_pp41))))))) + s = Float32FromFloat32(1) + float32(z*(_qq11+float32(z*(_qq21+float32(z*(_qq31+float32(z*(_qq41+float32(z*_qq51))))))))) + y = r / s + if sign != 0 || ix < uint32(0x3e800000) { /* x < 1/4 */ + return Float32FromFloat32(1) - (x + float32(x*y)) + } + return Float32FromFloat32(0.5) - (x - Float32FromFloat32(0.5) + float32(x*y)) + } + if ix < uint32(0x41e00000) { /* |x| < 28 */ + if sign != 0 { + v1 = Float32FromInt32(2) - _erfc21(tls, ix, x) + } else { + v1 = _erfc21(tls, ix, x) + } + return v1 + } + if sign != 0 { + v1 = Float32FromInt32(2) - Float32FromFloat32(7.52316384526264e-37) + } else { + v1 = float32(Float32FromFloat32(7.52316384526264e-37) * Float32FromFloat32(7.52316384526264e-37)) + } + return v1 +} + +func Xerfl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xerf(tls, x) +} + +func Xerfcl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xerfc(tls, x) +} + +const EXP2_POLY_ORDER = 5 +const EXP_POLY_ORDER = 5 +const EXP_TABLE_BITS = 7 +const EXP_USE_TOINT_NARROW = 0 +const N = 128 + +// C documentation +// +// /* Handle cases that may overflow or underflow when computing the result that +// is scale*(1+TMP) without intermediate rounding. The bit representation of +// scale is in SBITS, however it has a computed exponent that may have +// overflown into the sign bit so that needs to be adjusted before using it as +// a double. (int32_t)KI is the k used in the argument reduction and exponent +// adjustment of scale, positive k here means the result may overflow and +// negative k means the result may underflow. */ +func _specialcase(tls *TLS, tmp Tdouble_t, sbits Tuint64_t, ki Tuint64_t) (r float64) { + var hi, lo, scale, y3 Tdouble_t + var y, y1, y2, v1 float64 + _, _, _, _, _, _, _, _ = hi, lo, scale, y, y1, y2, y3, v1 + if ki&uint64(0x80000000) == uint64(0) { + /* k > 0, the exponent of scale might have overflowed by <= 460. */ + sbits = uint64(sbits - Uint64FromUint64(1009)<> int32(52)) +} + +func Xexp(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var abstop Tuint32_t + var idx, ki, sbits, top, v5 Tuint64_t + var kd, r, r2, scale, tail, tmp, z Tdouble_t + var y, v1 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abstop, idx, kd, ki, r, r2, sbits, scale, tail, tmp, top, y, z, v1, v5 + abstop = _top12(tls, x1) & uint32(0x7ff) + if abstop-_top12(tls, float64(5.551115123125783e-17)) >= _top12(tls, float64(512))-_top12(tls, float64(5.551115123125783e-17)) { + if abstop-_top12(tls, float64(5.551115123125783e-17)) >= uint32(0x80000000) { + /* Avoid spurious underflow for tiny x. */ + /* Note: 0 is common input. */ + return float64(1) + x1 + } + if abstop >= _top12(tls, float64(1024)) { + v1 = float64(-X__builtin_inff(tls)) + if *(*Tuint64_t)(unsafe.Pointer(&x1)) == *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(0) + } + if abstop >= _top12(tls, float64(X__builtin_inff(tls))) { + return float64(1) + x1 + } + if *(*Tuint64_t)(unsafe.Pointer(&x1))>>int32(63) != 0 { + return X__math_uflow(tls, uint32(0)) + } else { + return X__math_oflow(tls, uint32(0)) + } + } + /* Large x is special cased below. */ + abstop = uint32(0) + } + /* exp(x) = 2^(k/N) * exp(r), with exp(r) in [2^(-1/2N),2^(1/2N)]. */ + /* x = ln2/N*k + r, with int k and r in [-ln2/2N, ln2/2N]. */ + z = Tdouble_t(X__exp_data.Finvln2N * x1) + /* z - kd is in [-1, 1] in non-nearest rounding modes. */ + y = z + X__exp_data.Fshift + v1 = y + goto _3 +_3: + kd = v1 + v1 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v1)) + kd = kd - X__exp_data.Fshift + r = x1 + float64(kd*X__exp_data.Fnegln2hiN) + float64(kd*X__exp_data.Fnegln2loN) + /* 2^(k/N) ~= scale * (1 + tail). */ + idx = uint64(2) * (ki % Uint64FromInt32(Int32FromInt32(1)< 2^-200 and scale > 2^-739, so there + is no spurious underflow here even without fma. */ + y = scale + Tdouble_t(scale*tmp) + v1 = y + goto _7 +_7: + return v1 +} + +const HUGE = 0 + +func Xexp10(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var y float64 + var _ /* n at bp+0 */ float64 + var _ /* u at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = y + y = Xmodf(tls, x, bp) + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = **(**float64)(__ccgo_up(bp)) + /* fabs(n) < 16 without raising invalid on nan */ + if *(*Tuint64_t)(unsafe.Pointer(bp + 8))>>int32(52)&uint64(0x7ff) < Uint64FromInt32(Int32FromInt32(0x3ff)+Int32FromInt32(4)) { + if !(y != 0) { + return _p10[int32(**(**float64)(__ccgo_up(bp)))+int32(15)] + } + y = Xexp2(tls, float64(float64(3.321928094887362)*y)) + return float64(y * _p10[int32(**(**float64)(__ccgo_up(bp)))+int32(15)]) + } + return Xpow(tls, float64(10), x) +} + +var _p10 = [31]float64{ + 0: float64(1e-15), + 1: float64(1e-14), + 2: float64(1e-13), + 3: float64(1e-12), + 4: float64(1e-11), + 5: float64(1e-10), + 6: float64(1e-09), + 7: float64(1e-08), + 8: float64(1e-07), + 9: float64(1e-06), + 10: float64(1e-05), + 11: float64(0.0001), + 12: float64(0.001), + 13: float64(0.01), + 14: float64(0.1), + 15: Float64FromInt32(1), + 16: float64(10), + 17: float64(100), + 18: float64(1000), + 19: float64(10000), + 20: float64(100000), + 21: float64(1e+06), + 22: float64(1e+07), + 23: float64(1e+08), + 24: float64(1e+09), + 25: float64(1e+10), + 26: float64(1e+11), + 27: float64(1e+12), + 28: float64(1e+13), + 29: float64(1e+14), + 30: float64(1e+15), +} + +func Xpow10(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexp10(tls, x) +} + +func Xexp10f(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var y float32 + var _ /* n at bp+0 */ float32 + var _ /* u at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _ = y + y = Xmodff(tls, x, bp) + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = **(**float32)(__ccgo_up(bp)) + /* fabsf(n) < 8 without raising invalid on nan */ + if *(*Tuint32_t)(unsafe.Pointer(bp + 4))>>int32(23)&uint32(0xff) < Uint32FromInt32(Int32FromInt32(0x7f)+Int32FromInt32(3)) { + if !(y != 0) { + return _p101[int32(**(**float32)(__ccgo_up(bp)))+int32(7)] + } + y = Xexp2f(tls, float32(Float32FromFloat32(3.321928094887362)*y)) + return float32(y * _p101[int32(**(**float32)(__ccgo_up(bp)))+int32(7)]) + } + return float32(Xexp2(tls, float64(float64(3.321928094887362)*float64(x)))) +} + +var _p101 = [15]float32{ + 0: Float32FromFloat32(1e-07), + 1: Float32FromFloat32(1e-06), + 2: Float32FromFloat32(1e-05), + 3: Float32FromFloat32(0.0001), + 4: Float32FromFloat32(0.001), + 5: Float32FromFloat32(0.01), + 6: Float32FromFloat32(0.1), + 7: Float32FromInt32(1), + 8: float32(10), + 9: float32(100), + 10: float32(1000), + 11: float32(10000), + 12: float32(100000), + 13: float32(1e+06), + 14: float32(1e+07), +} + +func Xpow10f(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexp10f(tls, x) +} + +func Xexp10l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexp10(tls, x) +} + +func Xpow10l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexp10l(tls, x) +} + +// C documentation +// +// /* Handle cases that may overflow or underflow when computing the result that +// is scale*(1+TMP) without intermediate rounding. The bit representation of +// scale is in SBITS, however it has a computed exponent that may have +// overflown into the sign bit so that needs to be adjusted before using it as +// a double. (int32_t)KI is the k used in the argument reduction and exponent +// adjustment of scale, positive k here means the result may overflow and +// negative k means the result may underflow. */ +func _specialcase1(tls *TLS, tmp Tdouble_t, sbits Tuint64_t, ki Tuint64_t) (r float64) { + var hi, lo, scale, y3 Tdouble_t + var y, y1, y2, v1 float64 + _, _, _, _, _, _, _, _ = hi, lo, scale, y, y1, y2, y3, v1 + if ki&uint64(0x80000000) == uint64(0) { + /* k > 0, the exponent of scale might have overflowed by 1. */ + sbits = uint64(sbits - Uint64FromUint64(1)<> int32(52)) +} + +func Xexp2(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var abstop Tuint32_t + var idx, ki, sbits, top, v7 Tuint64_t + var kd, r, r2, scale, tail, tmp Tdouble_t + var y, v1 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abstop, idx, kd, ki, r, r2, sbits, scale, tail, tmp, top, y, v1, v7 + abstop = _top121(tls, x1) & uint32(0x7ff) + if abstop-_top121(tls, float64(5.551115123125783e-17)) >= _top121(tls, float64(512))-_top121(tls, float64(5.551115123125783e-17)) { + if abstop-_top121(tls, float64(5.551115123125783e-17)) >= uint32(0x80000000) { + /* Avoid spurious underflow for tiny x. */ + /* Note: 0 is common input. */ + return float64(1) + x1 + } + if abstop >= _top121(tls, float64(1024)) { + v1 = float64(-X__builtin_inff(tls)) + if *(*Tuint64_t)(unsafe.Pointer(&x1)) == *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(0) + } + if abstop >= _top121(tls, float64(X__builtin_inff(tls))) { + return float64(1) + x1 + } + if !(*(*Tuint64_t)(unsafe.Pointer(&x1))>>Int32FromInt32(63) != 0) { + return X__math_oflow(tls, uint32(0)) + } else { + v1 = -Float64FromFloat64(1075) + if *(*Tuint64_t)(unsafe.Pointer(&x1)) >= *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return X__math_uflow(tls, uint32(0)) + } + } + } + v1 = float64(928) + if uint64(2)**(*Tuint64_t)(unsafe.Pointer(&x1)) > uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1)) { + /* Large x is special cased below. */ + abstop = uint32(0) + } + } + /* exp2(x) = 2^(k/N) * 2^r, with 2^r in [2^(-1/2N),2^(1/2N)]. */ + /* x = k/N + r, with int k and r in [-1/2N, 1/2N]. */ + y = x1 + X__exp_data.Fexp2_shift + v1 = y + goto _5 +_5: + kd = v1 + v1 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v1)) /* k. */ + kd = kd - X__exp_data.Fexp2_shift /* k/N for int k. */ + r = x1 - kd + /* 2^(k/N) ~= scale * (1 + tail). */ + idx = uint64(2) * (ki % Uint64FromInt32(Int32FromInt32(1)< 2^-65 and scale > 2^-928, so there + is no spurious underflow here even without fma. */ + y = scale + Tdouble_t(scale*tmp) + v1 = y + goto _9 +_9: + return v1 +} + +const EXP2F_POLY_ORDER = 3 +const EXP2F_TABLE_BITS = 5 +const N1 = 32 + +/* +EXP2F_TABLE_BITS = 5 +EXP2F_POLY_ORDER = 3 + +ULP error: 0.502 (nearest rounding.) +Relative error: 1.69 * 2^-34 in [-1/64, 1/64] (before rounding.) +Wrong count: 168353 (all nearest rounding wrong results with fma.) +Non-nearest ULP error: 1 (rounded ULP error) +*/ + +func _top122(tls *TLS, x float32) (r Tuint32_t) { + return *(*Tuint32_t)(unsafe.Pointer(&x)) >> int32(20) +} + +func Xexp2f(tls *TLS, x2 float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x2=%v, (%v:)", tls, x2, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var abstop Tuint32_t + var kd, r, r2, s, xd, y2, z Tdouble_t + var ki, t Tuint64_t + var y, v1 float32 + var y1, v2 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abstop, kd, ki, r, r2, s, t, xd, y, y1, y2, z, v1, v2 + xd = float64(x2) + abstop = _top122(tls, x2) & uint32(0x7ff) + if abstop >= _top122(tls, Float32FromFloat32(128)) { + /* |x| >= 128 or x is nan. */ + v1 = -X__builtin_inff(tls) + if *(*Tuint32_t)(unsafe.Pointer(&x2)) == *(*Tuint32_t)(unsafe.Pointer(&v1)) { + return Float32FromFloat32(0) + } + if abstop >= _top122(tls, X__builtin_inff(tls)) { + return x2 + x2 + } + if x2 > Float32FromFloat32(0) { + return X__math_oflowf(tls, uint32(0)) + } + if x2 <= -Float32FromFloat32(150) { + return X__math_uflowf(tls, uint32(0)) + } + } + /* x = k/N + r with r in [-1/(2N), 1/(2N)] and int k. */ + y1 = xd + X__exp2f_data.Fshift_scaled + v2 = y1 + goto _3 +_3: + kd = v2 + v2 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v2)) + kd = kd - X__exp2f_data.Fshift_scaled /* k/N for int k. */ + r = xd - kd + /* exp2(x) = 2^(k/N) * 2^r ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */ + t = **(**Tuint64_t)(__ccgo_up(uintptr(unsafe.Pointer(&X__exp2f_data)) + uintptr(ki%Uint64FromInt32(Int32FromInt32(1)< %v", r) }() + } + return Xexp2(tls, x) +} + +const N2 = 128 + +type Texp_data = struct { + Finvln2N float64 + Fshift float64 + Fnegln2hiN float64 + Fnegln2loN float64 + Fpoly [4]float64 + Fexp2_shift float64 + Fexp2_poly [5]float64 + Ftab [256]Tuint64_t +} + +const N3 = 32 + +/* +EXP2F_TABLE_BITS = 5 +EXP2F_POLY_ORDER = 3 + +ULP error: 0.502 (nearest rounding.) +Relative error: 1.69 * 2^-34 in [-ln2/64, ln2/64] (before rounding.) +Wrong count: 170635 (all nearest rounding wrong results with fma.) +Non-nearest ULP error: 1 (rounded ULP error) +*/ + +func _top123(tls *TLS, x float32) (r Tuint32_t) { + return *(*Tuint32_t)(unsafe.Pointer(&x)) >> int32(20) +} + +func Xexpf(tls *TLS, x2 float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x2=%v, (%v:)", tls, x2, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var abstop Tuint32_t + var kd, r, r2, s, xd, y2, z Tdouble_t + var ki, t Tuint64_t + var y, v1 float32 + var y1, v2 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = abstop, kd, ki, r, r2, s, t, xd, y, y1, y2, z, v1, v2 + xd = float64(x2) + abstop = _top123(tls, x2) & uint32(0x7ff) + if abstop >= _top123(tls, Float32FromFloat32(88)) { + /* |x| >= 88 or x is nan. */ + v1 = -X__builtin_inff(tls) + if *(*Tuint32_t)(unsafe.Pointer(&x2)) == *(*Tuint32_t)(unsafe.Pointer(&v1)) { + return Float32FromFloat32(0) + } + if abstop >= _top123(tls, X__builtin_inff(tls)) { + return x2 + x2 + } + if x2 > Float32FromFloat32(88.72283172607422) { /* x > log(0x1p128) ~= 88.72 */ + return X__math_oflowf(tls, uint32(0)) + } + if x2 < -Float32FromFloat32(103.97207641601562) { /* x < log(0x1p-150) ~= -103.97 */ + return X__math_uflowf(tls, uint32(0)) + } + } + /* x*N/Ln2 = k + r with r in [-1/2, 1/2] and int k. */ + z = Tdouble_t(X__exp2f_data.Finvln2_scaled * xd) + /* Round and convert z to int, the result is in [-150*N, 128*N] and + ideally ties-to-even rule is used, otherwise the magnitude of r + can be bigger which gives larger approximation error. */ + y1 = z + X__exp2f_data.Fshift + v2 = y1 + goto _3 +_3: + kd = v2 + v2 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v2)) + kd = kd - X__exp2f_data.Fshift + r = z - kd + /* exp(x) = 2^(k/N) * 2^(r/N) ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */ + t = **(**Tuint64_t)(__ccgo_up(uintptr(unsafe.Pointer(&X__exp2f_data)) + uintptr(ki%Uint64FromInt32(Int32FromInt32(1)< %v", r) }() + } + return Xexp(tls, x) +} + +var _o_threshold = float64(709.782712893384) /* 0x40862E42, 0xFEFA39EF */ +var _ln2_hi = float64(0.6931471803691238) /* 0x3fe62e42, 0xfee00000 */ +var _ln2_lo = float64(1.9082149292705877e-10) /* 0x3dea39ef, 0x35793c76 */ +var _invln2 = float64(1.4426950408889634) /* 0x3ff71547, 0x652b82fe */ +/* Scaled Q's: Qn_here = 2**n * Qn_above, for R(2*z) where z = hxs = x*x/2: */ +var _Q1 = -Float64FromFloat64(0.03333333333333313) /* BFA11111 111110F4 */ +var _Q2 = float64(0.0015873015872548146) /* 3F5A01A0 19FE5585 */ +var _Q3 = -Float64FromFloat64(7.93650757867488e-05) /* BF14CE19 9EAADBB7 */ +var _Q4 = float64(4.008217827329362e-06) /* 3ED0CFCA 86E65239 */ +var _Q5 = -Float64FromFloat64(2.0109921818362437e-07) /* BE8AFDB7 6E09C32D */ + +func Xexpm1(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, e, hfx, hi, hxs, lo, r1, t, twopk, y3 Tdouble_t + var hx Tuint32_t + var k, sign int32 + var y float32 + var y1, y2, v3 float64 + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* u at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, e, hfx, hi, hx, hxs, k, lo, r1, sign, t, twopk, y, y1, y2, y3, v1, v3 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x3 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(32) & uint64(0x7fffffff)) + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(63)) + /* filter out huge and non-finite argument */ + if hx >= uint32(0x4043687A) { /* if |x|>=56*ln2 */ + *(*float64)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 + _2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< _o_threshold { + x3 = x3 * float64(8.98846567431158e+307) + return x3 + } + } + /* argument reduction */ + if hx > uint32(0x3fd62e42) { /* if |x| > 0.5 ln2 */ + if hx < uint32(0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ + if !(sign != 0) { + hi = x3 - _ln2_hi + lo = _ln2_lo + k = int32(1) + } else { + hi = x3 + _ln2_hi + lo = -_ln2_lo + k = -int32(1) + } + } else { + if sign != 0 { + v3 = -Float64FromFloat64(0.5) + } else { + v3 = float64(0.5) + } + k = int32(float64(_invln2*x3) + v3) + t = float64(k) + hi = x3 - float64(t*_ln2_hi) /* t*ln2_hi is exact here */ + lo = Tdouble_t(t * _ln2_lo) + } + x3 = hi - lo + c = hi - x3 - lo + } else { + if hx < uint32(0x3c900000) { /* |x| < 2**-54, return x */ + if hx < uint32(0x00100000) { + if uint64(4) == uint64(4) { + y = float32(x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3)) + } else { + y2 = float64(float32(x3)) + } + } + } + return x3 + } else { + k = 0 + } + } + /* x is now in primary range */ + hfx = Tdouble_t(float64(0.5) * x3) + hxs = Tdouble_t(x3 * hfx) + r1 = float64(1) + float64(hxs*(_Q1+float64(hxs*(_Q2+float64(hxs*(_Q3+float64(hxs*(_Q4+float64(hxs*_Q5))))))))) + t = float64(3) - float64(r1*hfx) + e = Tdouble_t(hxs * ((r1 - t) / (Float64FromFloat64(6) - float64(x3*t)))) + if k == 0 { /* c is 0 */ + return x3 - (float64(x3*e) - hxs) + } + e = float64(x3*(e-c)) - c + e = e - hxs + /* exp(x) ~ 2^k (Xreduced - e + 1) */ + if k == -int32(1) { + return float64(float64(0.5)*(x3-e)) - float64(0.5) + } + if k == int32(1) { + if x3 < -Float64FromFloat64(0.25) { + return float64(-Float64FromFloat64(2) * (e - (x3 + Float64FromFloat64(0.5)))) + } + return float64(1) + float64(float64(2)*(x3-e)) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 8)) = Uint64FromInt32(Int32FromInt32(0x3ff)+k) << int32(52) /* 2^k */ + twopk = *(*float64)(unsafe.Pointer(bp + 8)) + if k < 0 || k > int32(56) { /* suffice to return exp(x)-1 */ + y3 = x3 - e + float64(1) + if k == int32(1024) { + y3 = Tdouble_t(Tdouble_t(y3*float64(2)) * float64(8.98846567431158e+307)) + } else { + y3 = Tdouble_t(y3 * twopk) + } + return y3 - float64(1) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 8)) = Uint64FromInt32(Int32FromInt32(0x3ff)-k) << int32(52) /* 2^-k */ + if k < int32(20) { + y3 = Tdouble_t((x3 - e + (Float64FromInt32(1) - *(*float64)(unsafe.Pointer(bp + 8)))) * twopk) + } else { + y3 = Tdouble_t((x3 - (e + *(*float64)(unsafe.Pointer(bp + 8))) + Float64FromInt32(1)) * twopk) + } + return y3 +} + +var _ln2_hi1 = float32(0.69313812256) /* 0x3f317180 */ +var _ln2_lo1 = float32(9.0580006145e-06) /* 0x3717f7d1 */ +var _invln21 = float32(1.4426950216) /* 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): + */ +var _Q11 = float32(-Float64FromFloat64(0.033333212137)) /* -0x888868.0p-28 */ +var _Q21 = float32(0.0015807170421) /* 0xcf3010.0p-33 */ + +func Xexpm1f(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, e, hfx, hi, hxs, lo, r1, t, twopk, y3 Tfloat_t + var hx Tuint32_t + var k, sign int32 + var y, v1 float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, e, hfx, hi, hx, hxs, k, lo, r1, sign, t, twopk, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + /* filter out huge and non-finite argument */ + if hx >= uint32(0x4195b844) { /* if |x|>=27*ln2 */ + if hx > uint32(0x7f800000) { /* NaN */ + return x3 + } + if sign != 0 { + return float32(-Int32FromInt32(1)) + } + if hx > uint32(0x42b17217) { /* x > log(FLT_MAX) */ + x3 = x3 * Float32FromFloat32(1.7014118346046923e+38) + return x3 + } + } + /* argument reduction */ + if hx > uint32(0x3eb17218) { /* if |x| > 0.5 ln2 */ + if hx < uint32(0x3F851592) { /* and |x| < 1.5 ln2 */ + if !(sign != 0) { + hi = x3 - _ln2_hi1 + lo = _ln2_lo1 + k = int32(1) + } else { + hi = x3 + _ln2_hi1 + lo = -_ln2_lo1 + k = -int32(1) + } + } else { + if sign != 0 { + v1 = -Float32FromFloat32(0.5) + } else { + v1 = Float32FromFloat32(0.5) + } + k = int32(float32(_invln21*x3) + v1) + t = float32(k) + hi = x3 - float32(t*_ln2_hi1) /* t*ln2_hi is exact here */ + lo = Tfloat_t(t * _ln2_lo1) + } + x3 = hi - lo + c = hi - x3 - lo + } else { + if hx < uint32(0x33000000) { /* when |x|<2**-25, return x */ + if hx < uint32(0x00800000) { + if uint64(4) == uint64(4) { + y = float32(x3 * x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 * x3) + } else { + y2 = float64(x3 * x3) + } + } + } + return x3 + } else { + k = 0 + } + } + /* x is now in primary range */ + hfx = Tfloat_t(Float32FromFloat32(0.5) * x3) + hxs = Tfloat_t(x3 * hfx) + r1 = Float32FromFloat32(1) + float32(hxs*(_Q11+float32(hxs*_Q21))) + t = Float32FromFloat32(3) - float32(r1*hfx) + e = Tfloat_t(hxs * ((r1 - t) / (Float32FromFloat32(6) - float32(x3*t)))) + if k == 0 { /* c is 0 */ + return x3 - (float32(x3*e) - hxs) + } + e = float32(x3*(e-c)) - c + e = e - hxs + /* exp(x) ~ 2^k (Xreduced - e + 1) */ + if k == -int32(1) { + return float32(Float32FromFloat32(0.5)*(x3-e)) - Float32FromFloat32(0.5) + } + if k == int32(1) { + if x3 < -Float32FromFloat32(0.25) { + return float32(-Float32FromFloat32(2) * (e - (x3 + Float32FromFloat32(0.5)))) + } + return Float32FromFloat32(1) + float32(Float32FromFloat32(2)*(x3-e)) + } + *(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32((int32(0x7f) + k) << int32(23)) /* 2^k */ + twopk = *(*float32)(unsafe.Pointer(bp)) + if k < 0 || k > int32(56) { /* suffice to return exp(x)-1 */ + y3 = x3 - e + Float32FromFloat32(1) + if k == int32(128) { + y3 = Tfloat_t(Tfloat_t(y3*Float32FromFloat32(2)) * Float32FromFloat32(1.7014118346046923e+38)) + } else { + y3 = Tfloat_t(y3 * twopk) + } + return y3 - Float32FromFloat32(1) + } + *(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32((int32(0x7f) - k) << int32(23)) /* 2^-k */ + if k < int32(23) { + y3 = Tfloat_t((x3 - e + (Float32FromInt32(1) - *(*float32)(unsafe.Pointer(bp)))) * twopk) + } else { + y3 = Tfloat_t((x3 - (e + *(*float32)(unsafe.Pointer(bp))) + Float32FromInt32(1)) * twopk) + } + return y3 +} + +func Xexpm1l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexpm1(tls, x) +} + +func Xfabs(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uintptr + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (-Uint64FromUint64(1) / Uint64FromInt32(2))) + return *(*float64)(unsafe.Pointer(bp)) +} + +func Xfabsf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + return *(*float32)(unsafe.Pointer(bp)) +} + +func Xfabsl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfabs(tls, x) +} + +func Xfdim(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var v5 float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _ = v1, v5 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< y { + v5 = x - y + } else { + v5 = Float64FromInt32(0) + } + return v5 +} + +func Xfdimf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint32 + var v5 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _ = v1, v5 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + } + *(*float32)(unsafe.Pointer(bp)) = y + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 +_4: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return y + } + if x > y { + v5 = x - y + } else { + v5 = Float32FromInt32(0) + } + return v5 +} + +func Xfdiml(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfdim(tls, x, y) +} + +func Xfinite(tls *TLS, x float64) (r int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _ = v1 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + return BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _ = v1 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + return BoolInt32(v1&uint32(0x7fffffff) < uint32(0x7f800000)) +} + +const DBL_EPSILON7 = 2.220446049250313e-16 + +var _toint3 = Float64FromInt32(1) / Float64FromFloat64(2.220446049250313e-16) + +func Xfloor(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v1 int32 + var y float32 + var y1, y2 float64 + var y3 Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = e, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if e >= Int32FromInt32(0x3ff)+Int32FromInt32(52) || x3 == Float64FromInt32(0) { + return x3 + } + /* y = int(x) - x, where int(x) is an integer neighbor of x */ + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + y3 = x3 - _toint3 + _toint3 - x3 + } else { + y3 = x3 + _toint3 - _toint3 - x3 + } + /* special case because of non-nearest rounding modes */ + if e <= Int32FromInt32(0x3ff)-Int32FromInt32(1) { + if uint64(8) == uint64(4) { + y = float32(y3) + } else { + if uint64(8) == uint64(8) { + y1 = y3 + } else { + y2 = y3 + } + } + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return float64(v1) + } + if y3 > Float64FromInt32(0) { + return x3 + y3 - Float64FromInt32(1) + } + return x3 + y3 +} + +const DBL_EPSILON8 = 0 + +func Xfloorf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var m Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e, m, y, y1, y2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp))>>Int32FromInt32(23)&Uint32FromInt32(0xff)) - int32(0x7f) + if e >= int32(23) { + return x3 + } + if e >= 0 { + m = Uint32FromInt32(int32(0x007fffff) >> e) + if *(*Tuint32_t)(unsafe.Pointer(bp))&m == uint32(0) { + return x3 + } + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp)) += m + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= ^m + } else { + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) == uint32(0) { + *(*Tuint32_t)(unsafe.Pointer(bp)) = uint32(0) + } else { + if *(*Tuint32_t)(unsafe.Pointer(bp))< %v", r) }() + } + return Xfloor(tls, x) +} + +const DBL_MIN1 = 2.2250738585072014e-308 +const FLT_MIN1 = 1.1754943508222875e-38 +const ZEROINFNAN = 971 + +type Tnum = struct { + Fm Tuint64_t + Fe int32 + Fsign int32 +} + +func _normalize(tls *TLS, x float64) (r Tnum) { + var e, sign, v2 int32 + var ix Tuint64_t + var v1 float64 + _, _, _, _, _ = e, ix, sign, v1, v2 + ix = *(*Tuint64_t)(unsafe.Pointer(&x)) + e = Int32FromUint64(ix >> int32(52)) + sign = e & int32(0x800) + e = e & int32(0x7ff) + if !(e != 0) { + v1 = float64(x * float64(9.223372036854776e+18)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + e = Int32FromUint64(ix >> int32(52) & uint64(0x7ff)) + if e != 0 { + v2 = e - int32(63) + } else { + v2 = int32(0x800) + } + e = v2 + } + ix = uint64(ix & (Uint64FromUint64(1)<> int32(32) + ylo = uint64(uint32(y)) + yhi = y >> int32(32) + t1 = xlo * ylo + t2 = xlo*yhi + xhi*ylo + t3 = xhi * yhi + **(**Tuint64_t)(__ccgo_up(lo)) = t1 + t2<>Int32FromInt32(32) + BoolUint64(t1 > **(**Tuint64_t)(__ccgo_up(lo))) +} + +func Xfma(tls *TLS, x1 float64, y float64, z float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v y=%v z=%v, (%v:)", tls, x1, y, z, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, r float64 + var d, e, nonzero, samesign, sign, v2 int32 + var fltmin float32 + var i Tint64_t + var nx, ny, nz Tnum + var t, zhi, zlo, v1 Tuint64_t + var tiny Tdouble_t + var _ /* rhi at bp+0 */ Tuint64_t + var _ /* rlo at bp+8 */ Tuint64_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, d, e, fltmin, i, nonzero, nx, ny, nz, r, samesign, sign, t, tiny, zhi, zlo, v1, v2 + nx = _normalize(tls, x1) + ny = _normalize(tls, y) + nz = _normalize(tls, z) + if nx.Fe >= Int32FromInt32(0x7ff)-Int32FromInt32(0x3ff)-Int32FromInt32(52)-Int32FromInt32(1) || ny.Fe >= Int32FromInt32(0x7ff)-Int32FromInt32(0x3ff)-Int32FromInt32(52)-Int32FromInt32(1) { + return float64(x1*y) + z + } + if nz.Fe >= Int32FromInt32(0x7ff)-Int32FromInt32(0x3ff)-Int32FromInt32(52)-Int32FromInt32(1) { + if nz.Fe > Int32FromInt32(0x7ff)-Int32FromInt32(0x3ff)-Int32FromInt32(52)-Int32FromInt32(1) { /* z==0 */ + return float64(x1*y) + z + } + return z + } + _mul(tls, bp, bp+8, nx.Fm, ny.Fm) + /* either top 20 or 21 bits of rhi and last 2 bits of rlo are 0 */ + /* align exponents */ + e = nx.Fe + ny.Fe + d = nz.Fe - e + /* shift bits z<<=kz, r>>=kr, so kz+kr == d, set e = e+kr (== ez-kz) */ + if d > 0 { + if d < int32(64) { + zlo = nz.Fm << d + zhi = nz.Fm >> (int32(64) - d) + } else { + zlo = uint64(0) + zhi = nz.Fm + e = nz.Fe - int32(64) + d = d - int32(64) + if d == 0 { + } else { + if d < int32(64) { + **(**Tuint64_t)(__ccgo_up(bp + 8)) = **(**Tuint64_t)(__ccgo_up(bp))<<(int32(64)-d) | **(**Tuint64_t)(__ccgo_up(bp + 8))>>d | BoolUint64(!!(**(**Tuint64_t)(__ccgo_up(bp + 8))<<(Int32FromInt32(64)-d) != 0)) + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp)) >> d + } else { + **(**Tuint64_t)(__ccgo_up(bp + 8)) = uint64(1) + **(**Tuint64_t)(__ccgo_up(bp)) = uint64(0) + } + } + } + } else { + zhi = uint64(0) + d = -d + if d == 0 { + zlo = nz.Fm + } else { + if d < int32(64) { + zlo = nz.Fm>>d | BoolUint64(!!(nz.Fm<<(Int32FromInt32(64)-d) != 0)) + } else { + zlo = uint64(1) + } + } + } + /* add */ + sign = nx.Fsign ^ ny.Fsign + samesign = BoolInt32(!(sign^nz.Fsign != 0)) + nonzero = int32(1) + if samesign != 0 { + /* r += z */ + **(**Tuint64_t)(__ccgo_up(bp + 8)) = **(**Tuint64_t)(__ccgo_up(bp + 8)) + zlo + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp)) + (zhi + BoolUint64(**(**Tuint64_t)(__ccgo_up(bp + 8)) < zlo)) + } else { + /* r -= z */ + t = **(**Tuint64_t)(__ccgo_up(bp + 8)) + **(**Tuint64_t)(__ccgo_up(bp + 8)) = **(**Tuint64_t)(__ccgo_up(bp + 8)) - zlo + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp)) - zhi - BoolUint64(t < **(**Tuint64_t)(__ccgo_up(bp + 8))) + if **(**Tuint64_t)(__ccgo_up(bp))>>int32(63) != 0 { + **(**Tuint64_t)(__ccgo_up(bp + 8)) = -**(**Tuint64_t)(__ccgo_up(bp + 8)) + **(**Tuint64_t)(__ccgo_up(bp)) = -**(**Tuint64_t)(__ccgo_up(bp)) - BoolUint64(!!(**(**Tuint64_t)(__ccgo_up(bp + 8)) != 0)) + sign = BoolInt32(!(sign != 0)) + } + nonzero = BoolInt32(!!(**(**Tuint64_t)(__ccgo_up(bp)) != 0)) + } + /* set rhi to top 63bit of the result (last bit is sticky) */ + if nonzero != 0 { + e = e + int32(64) + v1 = **(**Tuint64_t)(__ccgo_up(bp)) + // __asm__("clz %0, %1" : "=r"(x) : "r"(x)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 80, __ccgo_ts+566) + v2 = Int32FromUint64(v1) + goto _3 + _3: + d = v2 - int32(1) + /* note: d > 0 */ + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp))<>(int32(64)-d) | BoolUint64(!!(**(**Tuint64_t)(__ccgo_up(bp + 8))<>int32(1) | **(**Tuint64_t)(__ccgo_up(bp + 8))&uint64(1) + } else { + **(**Tuint64_t)(__ccgo_up(bp)) = **(**Tuint64_t)(__ccgo_up(bp + 8)) << d + } + } else { + /* exact +-0 */ + return float64(x1*y) + z + } + } + e = e - d + /* convert to double */ + i = Int64FromUint64(**(**Tuint64_t)(__ccgo_up(bp))) /* i is in [1<<62,(1<<63)-1] */ + if sign != 0 { + i = -i + } + r = float64(i) /* |r| is in [0x1p62,0x1p63] */ + if e < -Int32FromInt32(1022)-Int32FromInt32(62) { + /* result is subnormal before rounding */ + if e == -Int32FromInt32(1022)-Int32FromInt32(63) { + c = float64(9.223372036854776e+18) + if sign != 0 { + c = -c + } + if r == c { + /* min normal after rounding, underflow depends + on arch behaviour which can be imitated by + a double to float conversion */ + fltmin = float32(float64(Float64FromFloat64(1.0842021401737618e-19)*Float64FromFloat32(1.1754943508222875e-38)) * r) + return float64(Float64FromFloat64(2.2250738585072014e-308) / Float64FromFloat32(1.1754943508222875e-38) * float64(fltmin)) + } + /* one bit is lost when scaled, add another top bit to + only round once at conversion if it is inexact */ + if **(**Tuint64_t)(__ccgo_up(bp))<>int32(1)|**(**Tuint64_t)(__ccgo_up(bp))&uint64(1)) | Uint64FromUint64(1)<>d | BoolUint64(!!(**(**Tuint64_t)(__ccgo_up(bp))<<(Int32FromInt32(64)-d) != 0))) << d) + if sign != 0 { + i = -i + } + r = float64(i) + } + } + return Xscalbn(tls, r, e) +} + +const DBL_MIN2 = 0 +const FLT_MIN2 = 0 + +func Xfmal(tls *TLS, x float64, y float64, z float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v z=%v, (%v:)", tls, x, y, z, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfma(tls, x, y, z) +} + +func Xfmax(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3, v5 uint64 + var v9 float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _ = v1, v3, v5, v9 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != Int32FromUint64(v3>>Int32FromInt32(63)) { + *(*float64)(unsafe.Pointer(bp)) = x + v5 = *(*uint64)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint64(v5>>Int32FromInt32(63)) != 0 { + v9 = y + } else { + v9 = x + } + return v9 + } + if x < y { + v9 = y + } else { + v9 = x + } + return v9 +} + +func Xfmaxf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3, v5 uint32 + var v9 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _ = v1, v3, v5, v9 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return y + } + *(*float32)(unsafe.Pointer(bp)) = y + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 +_4: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + } + /* handle signed zeroes, see C99 Annex F.9.9.2 */ + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _6 +_6: + *(*float32)(unsafe.Pointer(bp)) = y + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _8 +_8: + if Int32FromUint32(v1>>Int32FromInt32(31)) != Int32FromUint32(v3>>Int32FromInt32(31)) { + *(*float32)(unsafe.Pointer(bp)) = x + v5 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v5>>Int32FromInt32(31)) != 0 { + v9 = y + } else { + v9 = x + } + return v9 + } + if x < y { + v9 = y + } else { + v9 = x + } + return v9 +} + +func Xfmaxl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfmax(tls, x, y) +} + +func Xfmin(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3, v5 uint64 + var v9 float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _ = v1, v3, v5, v9 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != Int32FromUint64(v3>>Int32FromInt32(63)) { + *(*float64)(unsafe.Pointer(bp)) = x + v5 = *(*uint64)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint64(v5>>Int32FromInt32(63)) != 0 { + v9 = x + } else { + v9 = y + } + return v9 + } + if x < y { + v9 = x + } else { + v9 = y + } + return v9 +} + +func Xfminf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3, v5 uint32 + var v9 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _ = v1, v3, v5, v9 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return y + } + *(*float32)(unsafe.Pointer(bp)) = y + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 +_4: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + } + /* handle signed zeros, see C99 Annex F.9.9.2 */ + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _6 +_6: + *(*float32)(unsafe.Pointer(bp)) = y + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _8 +_8: + if Int32FromUint32(v1>>Int32FromInt32(31)) != Int32FromUint32(v3>>Int32FromInt32(31)) { + *(*float32)(unsafe.Pointer(bp)) = x + v5 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v5>>Int32FromInt32(31)) != 0 { + v9 = x + } else { + v9 = y + } + return v9 + } + if x < y { + v9 = x + } else { + v9 = y + } + return v9 +} + +func Xfminl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfmin(tls, x, y) +} + +func Xfmod(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ex, ey, sx int32 + var i, uxi Tuint64_t + var v1 uint64 + var v3 bool + var v6 uintptr + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* ux at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+16 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _ = ex, ey, i, sx, uxi, v1, v3, v6 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 16)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 16)) = y + ex = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(52) & uint64(0x7ff)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 16)) >> int32(52) & uint64(0x7ff)) + sx = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(63)) + /* in the followings uxi should be ux.i, but then gcc wrongly adds */ + /* float load/store to inner loops ruining performance and code size */ + uxi = *(*Tuint64_t)(unsafe.Pointer(bp + 8)) + if v3 = *(*Tuint64_t)(unsafe.Pointer(bp + 16))<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>int32(63) == uint64(0)) { + break + } + goto _4 + _4: + ; + ex = ex - 1 + i = i << uint64(1) + } + uxi = uxi << Uint64FromInt32(-ex+int32(1)) + } else { + uxi = uint64(uxi & (-Uint64FromUint64(1) >> Int32FromInt32(12))) + uxi = uint64(uxi | Uint64FromUint64(1)<>int32(63) == uint64(0)) { + break + } + goto _5 + _5: + ; + ey = ey - 1 + i = i << uint64(1) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 16)) <<= Uint64FromInt32(-ey + int32(1)) + } else { + v6 = bp + 16 + *(*Tuint64_t)(unsafe.Pointer(v6)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v6)) & (-Uint64FromUint64(1) >> Int32FromInt32(12))) + v6 = bp + 16 + *(*Tuint64_t)(unsafe.Pointer(v6)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v6)) | Uint64FromUint64(1)< ey) { + break + } + i = uxi - *(*Tuint64_t)(unsafe.Pointer(bp + 16)) + if i>>int32(63) == uint64(0) { + if i == uint64(0) { + return float64(Float64FromInt32(0) * x) + } + uxi = i + } + uxi = uxi << uint64(1) + goto _8 + _8: + ; + ex = ex - 1 + } + i = uxi - *(*Tuint64_t)(unsafe.Pointer(bp + 16)) + if i>>int32(63) == uint64(0) { + if i == uint64(0) { + return float64(Float64FromInt32(0) * x) + } + uxi = i + } + for { + if !(uxi>>int32(52) == uint64(0)) { + break + } + goto _9 + _9: + ; + uxi = uxi << uint64(1) + ex = ex - 1 + } + /* scale result */ + if ex > 0 { + uxi = uint64(uxi - Uint64FromUint64(1)<> Uint64FromInt32(-ex+int32(1)) + } + uxi = uxi | Uint64FromInt32(sx)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ex, ey int32 + var i, sx, uxi Tuint32_t + var v1 uint32 + var v3 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + var _ /* ux at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _ = ex, ey, i, sx, uxi, v1, v3 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = x + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 8)) = y + ex = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 4)) >> int32(23) & uint32(0xff)) + ey = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 8)) >> int32(23) & uint32(0xff)) + sx = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) & uint32(0x80000000) + uxi = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) + if v3 = *(*Tuint32_t)(unsafe.Pointer(bp + 8))< uint32(0x7f800000)) != 0 || ex == int32(0xff) { + return float32(x*y) / float32(x*y) + } + if uxi<>int32(31) == uint32(0)) { + break + } + goto _4 + _4: + ; + ex = ex - 1 + i = i << uint32(1) + } + uxi = uxi << Uint32FromInt32(-ex+int32(1)) + } else { + uxi = uxi & (-Uint32FromUint32(1) >> Int32FromInt32(9)) + uxi = uxi | Uint32FromUint32(1)<>int32(31) == uint32(0)) { + break + } + goto _5 + _5: + ; + ey = ey - 1 + i = i << uint32(1) + } + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) <<= Uint32FromInt32(-ey + int32(1)) + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) &= -Uint32FromUint32(1) >> Int32FromInt32(9) + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) |= Uint32FromUint32(1) << Int32FromInt32(23) + } + /* x mod y */ + for { + if !(ex > ey) { + break + } + i = uxi - *(*Tuint32_t)(unsafe.Pointer(bp + 8)) + if i>>int32(31) == uint32(0) { + if i == uint32(0) { + return float32(Float32FromInt32(0) * x) + } + uxi = i + } + uxi = uxi << uint32(1) + goto _6 + _6: + ; + ex = ex - 1 + } + i = uxi - *(*Tuint32_t)(unsafe.Pointer(bp + 8)) + if i>>int32(31) == uint32(0) { + if i == uint32(0) { + return float32(Float32FromInt32(0) * x) + } + uxi = i + } + for { + if !(uxi>>int32(23) == uint32(0)) { + break + } + goto _7 + _7: + ; + uxi = uxi << uint32(1) + ex = ex - 1 + } + /* scale result up */ + if ex > 0 { + uxi = uxi - Uint32FromUint32(1)<> Uint32FromInt32(-ex+int32(1)) + } + uxi = uxi | sx + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = uxi + return *(*float32)(unsafe.Pointer(bp + 4)) +} + +func Xfmodl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfmod(tls, x, y) +} + +func Xfrexp(tls *TLS, x float64, e uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v e=%v, (%v:)", tls, x, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ee int32 + var v1 uintptr + var _ /* y at bp+0 */ struct { + Fi [0]Tuint64_t + Fd float64 + } + _, _ = ee, v1 + *(*struct { + Fi [0]Tuint64_t + Fd float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Fd float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + ee = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if !(ee != 0) { + if x != 0 { + x = Xfrexp(tls, float64(x*float64(1.8446744073709552e+19)), e) + **(**int32)(__ccgo_up(e)) -= int32(64) + } else { + **(**int32)(__ccgo_up(e)) = 0 + } + return x + } else { + if ee == int32(0x7ff) { + return x + } + } + **(**int32)(__ccgo_up(e)) = ee - int32(0x3fe) + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & Uint64FromUint64(0x800fffffffffffff)) + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) | Uint64FromUint64(0x3fe0000000000000)) + return *(*float64)(unsafe.Pointer(bp)) +} + +func Xfrexpf(tls *TLS, x float32, e uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v e=%v, (%v:)", tls, x, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ee int32 + var v1 uintptr + var _ /* y at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _ = ee, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + ee = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + if !(ee != 0) { + if x != 0 { + x = Xfrexpf(tls, float32(float64(x)*float64(1.8446744073709552e+19)), e) + **(**int32)(__ccgo_up(e)) -= int32(64) + } else { + **(**int32)(__ccgo_up(e)) = 0 + } + return x + } else { + if ee == int32(0xff) { + return x + } + } + **(**int32)(__ccgo_up(e)) = ee - int32(0x7e) + v1 = bp + *(*Tuint32_t)(unsafe.Pointer(v1)) = Tuint32_t(uint64(*(*Tuint32_t)(unsafe.Pointer(v1))) & Uint64FromUint64(0x807fffff)) + v1 = bp + *(*Tuint32_t)(unsafe.Pointer(v1)) = Tuint32_t(uint64(*(*Tuint32_t)(unsafe.Pointer(v1))) | Uint64FromUint64(0x3f000000)) + return *(*float32)(unsafe.Pointer(bp)) +} + +func Xfrexpl(tls *TLS, x float64, e uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v e=%v, (%v:)", tls, x, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfrexp(tls, x, e) +} + +const SPLIT = 1 + +func _sq(tls *TLS, hi uintptr, lo uintptr, x float64) { + var xc, xh, xl Tdouble_t + _, _, _ = xc, xh, xl + xc = Tdouble_t(x * (Float64FromFloat64(1.34217728e+08) + Float64FromInt32(1))) + xh = x - xc + xc + xl = x - xh + **(**Tdouble_t)(__ccgo_up(hi)) = Tdouble_t(x * x) + **(**Tdouble_t)(__ccgo_up(lo)) = Tdouble_t(xh*xh) - **(**Tdouble_t)(__ccgo_up(hi)) + Tdouble_t(Tdouble_t(Float64FromInt32(2)*xh)*xl) + Tdouble_t(xl*xl) +} + +func Xhypot(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var ex, ey int32 + var ut struct { + Fi [0]Tuint64_t + Ff float64 + } + var z Tdouble_t + var v1 uintptr + var _ /* hx at bp+16 */ Tdouble_t + var _ /* hy at bp+32 */ Tdouble_t + var _ /* lx at bp+24 */ Tdouble_t + var _ /* ly at bp+40 */ Tdouble_t + var _ /* ux at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _ = ex, ey, ut, z, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = y + /* arrange |x| >= |y| */ + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (-Uint64FromUint64(1) >> Int32FromInt32(1))) + v1 = bp + 8 + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (-Uint64FromUint64(1) >> Int32FromInt32(1))) + if *(*Tuint64_t)(unsafe.Pointer(bp)) < *(*Tuint64_t)(unsafe.Pointer(bp + 8)) { + ut = **(**struct { + Fi [0]Tuint64_t + Ff float64 + })(__ccgo_up(bp)) + **(**struct { + Fi [0]Tuint64_t + Ff float64 + })(__ccgo_up(bp)) = **(**struct { + Fi [0]Tuint64_t + Ff float64 + })(__ccgo_up(bp + 8)) + **(**struct { + Fi [0]Tuint64_t + Ff float64 + })(__ccgo_up(bp + 8)) = ut + } + /* special cases */ + ex = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(52)) + x = *(*float64)(unsafe.Pointer(bp)) + y = *(*float64)(unsafe.Pointer(bp + 8)) + /* note: hypot(inf,nan) == inf */ + if ey == int32(0x7ff) { + return y + } + if ex == int32(0x7ff) || *(*Tuint64_t)(unsafe.Pointer(bp + 8)) == uint64(0) { + return x + } + /* note: hypot(x,y) ~= x + y*y/x/2 with inexact for small y/x */ + /* 64 difference is enough for ld80 double_t */ + if ex-ey > int32(64) { + return x + y + } + /* precise sqrt argument in nearest rounding mode without overflow */ + /* xh*xh must not overflow and xl*xl must not underflow in sq */ + z = Float64FromInt32(1) + if ex > Int32FromInt32(0x3ff)+Int32FromInt32(510) { + z = float64(5.260135901548374e+210) + x = x * float64(1.90109156629516e-211) + y = y * float64(1.90109156629516e-211) + } else { + if ey < Int32FromInt32(0x3ff)-Int32FromInt32(450) { + z = float64(1.90109156629516e-211) + x = x * float64(5.260135901548374e+210) + y = y * float64(5.260135901548374e+210) + } + } + _sq(tls, bp+16, bp+24, x) + _sq(tls, bp+32, bp+40, y) + return float64(z * Xsqrt(tls, **(**Tdouble_t)(__ccgo_up(bp + 40))+**(**Tdouble_t)(__ccgo_up(bp + 24))+**(**Tdouble_t)(__ccgo_up(bp + 32))+**(**Tdouble_t)(__ccgo_up(bp + 16)))) +} + +func Xhypotf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ut struct { + Fi [0]Tuint32_t + Ff float32 + } + var z Tfloat_t + var _ /* ux at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _ = ut, z + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = y + *(*Tuint32_t)(unsafe.Pointer(bp)) &= -Uint32FromUint32(1) >> Int32FromInt32(1) + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) &= -Uint32FromUint32(1) >> Int32FromInt32(1) + if *(*Tuint32_t)(unsafe.Pointer(bp)) < *(*Tuint32_t)(unsafe.Pointer(bp + 4)) { + ut = **(**struct { + Fi [0]Tuint32_t + Ff float32 + })(__ccgo_up(bp)) + **(**struct { + Fi [0]Tuint32_t + Ff float32 + })(__ccgo_up(bp)) = **(**struct { + Fi [0]Tuint32_t + Ff float32 + })(__ccgo_up(bp + 4)) + **(**struct { + Fi [0]Tuint32_t + Ff float32 + })(__ccgo_up(bp + 4)) = ut + } + x = *(*float32)(unsafe.Pointer(bp)) + y = *(*float32)(unsafe.Pointer(bp + 4)) + if *(*Tuint32_t)(unsafe.Pointer(bp + 4)) == Uint32FromInt32(Int32FromInt32(0xff)<= Uint32FromInt32(Int32FromInt32(0xff)<= Uint32FromInt32(Int32FromInt32(25)<= Uint32FromInt32((Int32FromInt32(0x7f)+Int32FromInt32(60))< %v", r) }() + } + return Xhypot(tls, x, y) +} + +func Xilogb(tls *TLS, x3 float64) (r int32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v2 int32 + var i Tuint64_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = e, i, y, y1, y2, v2 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + i = *(*Tuint64_t)(unsafe.Pointer(bp)) + e = Int32FromUint64(i >> int32(52) & uint64(0x7ff)) + if !(e != 0) { + i = i << uint64(12) + if i == uint64(0) { + if uint64(4) == uint64(4) { + y = Float32FromInt32(0) / Float32FromFloat32(0) + } else { + if uint64(4) == uint64(8) { + y1 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } else { + y2 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } + } + return -Int32FromInt32(1) - Int32FromInt32(0x7fffffff) + } + /* subnormal x */ + e = -int32(0x3ff) + for { + if !(i>>int32(63) == uint64(0)) { + break + } + goto _1 + _1: + ; + e = e - 1 + i = i << uint64(1) + } + return e + } + if e == int32(0x7ff) { + if uint64(4) == uint64(4) { + y = Float32FromInt32(0) / Float32FromFloat32(0) + } else { + if uint64(4) == uint64(8) { + y1 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } else { + y2 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } + } + if i< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, v2 int32 + var i Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _ = e, i, y, y1, y2, v2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + i = *(*Tuint32_t)(unsafe.Pointer(bp)) + e = Int32FromUint32(i >> int32(23) & uint32(0xff)) + if !(e != 0) { + i = i << uint32(9) + if i == uint32(0) { + if uint64(4) == uint64(4) { + y = Float32FromInt32(0) / Float32FromFloat32(0) + } else { + if uint64(4) == uint64(8) { + y1 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } else { + y2 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } + } + return -Int32FromInt32(1) - Int32FromInt32(0x7fffffff) + } + /* subnormal x */ + e = -int32(0x7f) + for { + if !(i>>int32(31) == uint32(0)) { + break + } + goto _1 + _1: + ; + e = e - 1 + i = i << uint32(1) + } + return e + } + if e == int32(0xff) { + if uint64(4) == uint64(4) { + y = Float32FromInt32(0) / Float32FromFloat32(0) + } else { + if uint64(4) == uint64(8) { + y1 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } else { + y2 = float64(Float32FromInt32(0) / Float32FromFloat32(0)) + } + } + if i< %v", r) }() + } + return Xilogb(tls, x) +} + +var _invsqrtpi = float64(0.5641895835477563) /* 0x3FE20DD7, 0x50429B6D */ +var _tpi = float64(0.6366197723675814) /* 0x3FE45F30, 0x6DC9C883 */ + +// C documentation +// +// /* common method when |x|>=2 */ +func _common(tls *TLS, ix Tuint32_t, x float64, y0 int32) (r float64) { + var c, cc, s, ss, z float64 + _, _, _, _, _ = c, cc, s, ss, z + /* + * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x-pi/4)-q0(x)*sin(x-pi/4)) + * y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x-pi/4)+q0(x)*cos(x-pi/4)) + * + * sin(x-pi/4) = (sin(x) - cos(x))/sqrt(2) + * cos(x-pi/4) = (sin(x) + cos(x))/sqrt(2) + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + */ + s = Xsin(tls, x) + c = Xcos(tls, x) + if y0 != 0 { + c = -c + } + cc = s + c + /* avoid overflow in 2*x, big ulp error when x>=0x1p1023 */ + if ix < uint32(0x7fe00000) { + ss = s - c + z = -Xcos(tls, float64(Float64FromInt32(2)*x)) + if float64(s*c) < Float64FromInt32(0) { + cc = z / ss + } else { + ss = z / cc + } + if ix < uint32(0x48000000) { + if y0 != 0 { + ss = -ss + } + cc = float64(_pzero(tls, x)*cc) - float64(_qzero(tls, x)*ss) + } + } + return float64(_invsqrtpi*cc) / Xsqrt(tls, x) +} + +// C documentation +// +// /* R0/S0 on [0, 2.00] */ + +var _R02 = float64(0.015624999999999995) /* 0x3F8FFFFF, 0xFFFFFFFD */ +var _R03 = -Float64FromFloat64(0.00018997929423885472) /* 0xBF28E6A5, 0xB61AC6E9 */ +var _R04 = float64(1.8295404953270067e-06) /* 0x3EBEB1D1, 0x0C503919 */ +var _R05 = -Float64FromFloat64(4.618326885321032e-09) /* 0xBE33D5E7, 0x73D63FCE */ +var _S01 = float64(0.015619102946489001) /* 0x3F8FFCE8, 0x82C8C2A4 */ +var _S02 = float64(0.00011692678466333745) /* 0x3F1EA6D2, 0xDD57DBF4 */ +var _S03 = float64(5.135465502073181e-07) /* 0x3EA13B54, 0xCE84D5A9 */ +var _S04 = float64(1.1661400333379e-09) /* 0x3E1408BC, 0xF4745D8F */ + +func Xj0(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, z float64 + _, _, _, _ = ix, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* j0(+-inf)=0, j0(nan)=nan */ + if ix >= uint32(0x7ff00000) { + return Float64FromInt32(1) / float64(x*x) + } + x = Xfabs(tls, x) + if ix >= uint32(0x40000000) { /* |x| >= 2 */ + /* large ulp error near zeros: 2.4, 5.52, 8.6537,.. */ + return _common(tls, ix, x, 0) + } + /* 1 - x*x/4 + x*x*R(x^2)/S(x^2) */ + if ix >= uint32(0x3f200000) { /* |x| >= 2**-13 */ + /* up to 4ulp error close to 2 */ + z = float64(x * x) + r = float64(z * (_R02 + float64(z*(_R03+float64(z*(_R04+float64(z*_R05))))))) + s = Float64FromInt32(1) + float64(z*(_S01+float64(z*(_S02+float64(z*(_S03+float64(z*_S04))))))) + return float64((Float64FromInt32(1)+x/Float64FromInt32(2))*(Float64FromInt32(1)-x/Float64FromInt32(2))) + float64(z*(r/s)) + } + /* 1 - x*x/4 */ + /* prevent underflow */ + /* inexact should be raised when x!=0, this is not done correctly */ + if ix >= uint32(0x38000000) { /* |x| >= 2**-127 */ + x = float64(float64(float64(0.25)*x) * x) + } + return Float64FromInt32(1) - x +} + +var _u00 = -Float64FromFloat64(0.07380429510868723) /* 0xBFB2E4D6, 0x99CBD01F */ +var _u01 = float64(0.17666645250918112) /* 0x3FC69D01, 0x9DE9E3FC */ +var _u02 = -Float64FromFloat64(0.01381856719455969) /* 0xBF8C4CE8, 0xB16CFA97 */ +var _u03 = float64(0.00034745343209368365) /* 0x3F36C54D, 0x20B29B6B */ +var _u04 = -Float64FromFloat64(3.8140705372436416e-06) /* 0xBECFFEA7, 0x73D25CAD */ +var _u05 = float64(1.9559013703502292e-08) /* 0x3E550057, 0x3B4EABD4 */ +var _u06 = -Float64FromFloat64(3.982051941321034e-11) /* 0xBDC5E43D, 0x693FB3C8 */ +var _v01 = float64(0.01273048348341237) /* 0x3F8A1270, 0x91C9C71A */ +var _v02 = float64(7.600686273503533e-05) /* 0x3F13ECBB, 0xF578C6C1 */ +var _v03 = float64(2.591508518404578e-07) /* 0x3E91642D, 0x7FF202FD */ +var _v04 = float64(4.4111031133267547e-10) /* 0x3DFE5018, 0x3BD6D9EF */ + +func Xy0(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u Tuint64_t + var ix, lx Tuint32_t + var u, v, z float64 + _, _, _, _, _, _ = __u, ix, lx, u, v, z + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + ix = uint32(__u >> int32(32)) + lx = uint32(__u) + /* y0(nan)=nan, y0(<0)=nan, y0(0)=-inf, y0(inf)=0 */ + if ix<>int32(31) != 0 { + return Float64FromInt32(0) / Float64FromFloat64(0) + } + if ix >= uint32(0x7ff00000) { + return Float64FromInt32(1) / x + } + if ix >= uint32(0x40000000) { /* x >= 2 */ + /* large ulp errors near zeros: 3.958, 7.086,.. */ + return _common(tls, ix, x, int32(1)) + } + /* U(x^2)/V(x^2) + (2/pi)*j0(x)*log(x) */ + if ix >= uint32(0x3e400000) { /* x >= 2**-27 */ + /* large ulp error near the first zero, x ~= 0.89 */ + z = float64(x * x) + u = _u00 + float64(z*(_u01+float64(z*(_u02+float64(z*(_u03+float64(z*(_u04+float64(z*(_u05+float64(z*_u06))))))))))) + v = float64(1) + float64(z*(_v01+float64(z*(_v02+float64(z*(_v03+float64(z*_v04))))))) + return u/v + float64(_tpi*float64(Xj0(tls, x)*Xlog(tls, x))) + } + return _u00 + float64(_tpi*Xlog(tls, x)) +} + +// C documentation +// +// /* The asymptotic expansions of pzero is +// * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. +// * For x >= 2, We approximate pzero by +// * pzero(x) = 1 + (R/S) +// * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 +// * S = 1 + pS0*s^2 + ... + pS4*s^10 +// * and +// * | pzero(x)-1-R/S | <= 2 ** ( -60.26) +// */ +var _pR8 = [6]float64{ + 1: -Float64FromFloat64(0.07031249999999004), + 2: -Float64FromFloat64(8.081670412753498), + 3: -Float64FromFloat64(257.06310567970485), + 4: -Float64FromFloat64(2485.216410094288), + 5: -Float64FromFloat64(5253.043804907295), +} +var _pS8 = [5]float64{ + 0: float64(116.53436461966818), + 1: float64(3833.7447536412183), + 2: float64(40597.857264847255), + 3: float64(116752.97256437592), + 4: float64(47627.728414673096), +} + +var _pR5 = [6]float64{ + 0: -Float64FromFloat64(1.141254646918945e-11), + 1: -Float64FromFloat64(0.07031249408735993), + 2: -Float64FromFloat64(4.159610644705878), + 3: -Float64FromFloat64(67.67476522651673), + 4: -Float64FromFloat64(331.23129964917297), + 5: -Float64FromFloat64(346.4333883656049), +} +var _pS52 = [5]float64{ + 0: float64(60.753938269230034), + 1: float64(1051.2523059570458), + 2: float64(5978.970943338558), + 3: float64(9625.445143577745), + 4: float64(2406.058159229391), +} + +var _pR3 = [6]float64{ + 0: -Float64FromFloat64(2.547046017719519e-09), + 1: -Float64FromFloat64(0.07031196163814817), + 2: -Float64FromFloat64(2.409032215495296), + 3: -Float64FromFloat64(21.96597747348831), + 4: -Float64FromFloat64(58.07917047017376), + 5: -Float64FromFloat64(31.44794705948885), +} +var _pS32 = [5]float64{ + 0: float64(35.85603380552097), + 1: float64(361.51398305030386), + 2: float64(1193.6078379211153), + 3: float64(1127.9967985690741), + 4: float64(173.58093081333575), +} + +var _pR2 = [6]float64{ + 0: -Float64FromFloat64(8.875343330325264e-08), + 1: -Float64FromFloat64(0.07030309954836247), + 2: -Float64FromFloat64(1.4507384678095299), + 3: -Float64FromFloat64(7.635696138235278), + 4: -Float64FromFloat64(11.193166886035675), + 5: -Float64FromFloat64(3.2336457935133534), +} +var _pS24 = [5]float64{ + 0: float64(22.22029975320888), + 1: float64(136.2067942182152), + 2: float64(270.4702786580835), + 3: float64(153.87539420832033), + 4: float64(14.65761769482562), +} + +func _pzero(tls *TLS, x float64) (r1 float64) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tdouble_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x40200000) { + p = uintptr(unsafe.Pointer(&_pR8)) + q = uintptr(unsafe.Pointer(&_pS8)) + } else { + if ix >= uint32(0x40122E8B) { + p = uintptr(unsafe.Pointer(&_pR5)) + q = uintptr(unsafe.Pointer(&_pS52)) + } else { + if ix >= uint32(0x4006DB6D) { + p = uintptr(unsafe.Pointer(&_pR3)) + q = uintptr(unsafe.Pointer(&_pS32)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_pR2)) + q = uintptr(unsafe.Pointer(&_pS24)) + } + } + } + z = float64(1) / float64(x*x) + r = **(**float64)(__ccgo_up(p)) + float64(z*(**(**float64)(__ccgo_up(p + 1*8))+float64(z*(**(**float64)(__ccgo_up(p + 2*8))+float64(z*(**(**float64)(__ccgo_up(p + 3*8))+float64(z*(**(**float64)(__ccgo_up(p + 4*8))+float64(z***(**float64)(__ccgo_up(p + 5*8))))))))))) + s = float64(1) + float64(z*(**(**float64)(__ccgo_up(q))+float64(z*(**(**float64)(__ccgo_up(q + 1*8))+float64(z*(**(**float64)(__ccgo_up(q + 2*8))+float64(z*(**(**float64)(__ccgo_up(q + 3*8))+float64(z***(**float64)(__ccgo_up(q + 4*8))))))))))) + return float64(1) + r/s +} + +// C documentation +// +// /* For x >= 8, the asymptotic expansions of qzero is +// * -1/8 s + 75/1024 s^3 - ..., where s = 1/x. +// * We approximate pzero by +// * qzero(x) = s*(-1.25 + (R/S)) +// * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 +// * S = 1 + qS0*s^2 + ... + qS5*s^12 +// * and +// * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) +// */ +var _qR8 = [6]float64{ + 1: float64(0.0732421874999935), + 2: float64(11.76820646822527), + 3: float64(557.6733802564019), + 4: float64(8859.197207564686), + 5: float64(37014.62677768878), +} +var _qS8 = [6]float64{ + 0: float64(163.77602689568982), + 1: float64(8098.344946564498), + 2: float64(142538.29141912048), + 3: float64(803309.2571195144), + 4: float64(840501.5798190605), + 5: -Float64FromFloat64(343899.2935378666), +} + +var _qR5 = [6]float64{ + 0: float64(1.8408596359451553e-11), + 1: float64(0.07324217666126848), + 2: float64(5.8356350896205695), + 3: float64(135.11157728644983), + 4: float64(1027.243765961641), + 5: float64(1989.9778586460538), +} +var _qS5 = [6]float64{ + 0: float64(82.77661022365378), + 1: float64(2077.81416421393), + 2: float64(18847.28877857181), + 3: float64(56751.11228949473), + 4: float64(35976.75384251145), + 5: -Float64FromFloat64(5354.342756019448), +} + +var _qR3 = [6]float64{ + 0: float64(4.377410140897386e-09), + 1: float64(0.07324111800429114), + 2: float64(3.344231375161707), + 3: float64(42.621844074541265), + 4: float64(170.8080913405656), + 5: float64(166.73394869665117), +} +var _qS32 = [6]float64{ + 0: float64(48.75887297245872), + 1: float64(709.689221056606), + 2: float64(3704.1482262011136), + 3: float64(6460.425167525689), + 4: float64(2516.3336892036896), + 5: -Float64FromFloat64(149.2474518361564), +} + +var _qR2 = [6]float64{ + 0: float64(1.5044444488698327e-07), + 1: float64(0.07322342659630793), + 2: float64(1.99819174093816), + 3: float64(14.495602934788574), + 4: float64(31.666231750478154), + 5: float64(16.252707571092927), +} +var _qS22 = [6]float64{ + 0: float64(30.36558483552192), + 1: float64(269.34811860804984), + 2: float64(844.7837575953201), + 3: float64(882.9358451124886), + 4: float64(212.66638851179883), + 5: -Float64FromFloat64(5.3109549388266695), +} + +func _qzero(tls *TLS, x float64) (r1 float64) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tdouble_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x40200000) { + p = uintptr(unsafe.Pointer(&_qR8)) + q = uintptr(unsafe.Pointer(&_qS8)) + } else { + if ix >= uint32(0x40122E8B) { + p = uintptr(unsafe.Pointer(&_qR5)) + q = uintptr(unsafe.Pointer(&_qS5)) + } else { + if ix >= uint32(0x4006DB6D) { + p = uintptr(unsafe.Pointer(&_qR3)) + q = uintptr(unsafe.Pointer(&_qS32)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_qR2)) + q = uintptr(unsafe.Pointer(&_qS22)) + } + } + } + z = float64(1) / float64(x*x) + r = **(**float64)(__ccgo_up(p)) + float64(z*(**(**float64)(__ccgo_up(p + 1*8))+float64(z*(**(**float64)(__ccgo_up(p + 2*8))+float64(z*(**(**float64)(__ccgo_up(p + 3*8))+float64(z*(**(**float64)(__ccgo_up(p + 4*8))+float64(z***(**float64)(__ccgo_up(p + 5*8))))))))))) + s = float64(1) + float64(z*(**(**float64)(__ccgo_up(q))+float64(z*(**(**float64)(__ccgo_up(q + 1*8))+float64(z*(**(**float64)(__ccgo_up(q + 2*8))+float64(z*(**(**float64)(__ccgo_up(q + 3*8))+float64(z*(**(**float64)(__ccgo_up(q + 4*8))+float64(z***(**float64)(__ccgo_up(q + 5*8))))))))))))) + return (-Float64FromFloat64(0.125) + r/s) / x +} + +var _invsqrtpi1 = float32(0.56418961287) /* 0x3f106ebb */ +var _tpi1 = float32(0.63661974669) /* 0x3f22f983 */ + +func _common1(tls *TLS, ix Tuint32_t, x float32, y0 int32) (r float32) { + var c, cc, s, ss, z float32 + _, _, _, _, _ = c, cc, s, ss, z + /* + * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) + * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) + */ + s = Xsinf(tls, x) + c = Xcosf(tls, x) + if y0 != 0 { + c = -c + } + cc = s + c + if ix < uint32(0x7f000000) { + ss = s - c + z = -Xcosf(tls, float32(Float32FromInt32(2)*x)) + if float32(s*c) < Float32FromInt32(0) { + cc = z / ss + } else { + ss = z / cc + } + if ix < uint32(0x58800000) { + if y0 != 0 { + ss = -ss + } + cc = float32(_pzerof(tls, x)*cc) - float32(_qzerof(tls, x)*ss) + } + } + return float32(_invsqrtpi1*cc) / Xsqrtf(tls, x) +} + +// C documentation +// +// /* R0/S0 on [0, 2.00] */ + +var _R021 = float32(0.015625) /* 0x3c800000 */ +var _R031 = float32(-Float64FromFloat64(0.00018997929874)) /* 0xb947352e */ +var _R041 = float32(1.8295404516e-06) /* 0x35f58e88 */ +var _R051 = float32(-Float64FromFloat64(4.6183270541e-09)) /* 0xb19eaf3c */ +var _S011 = float32(0.015619102865) /* 0x3c7fe744 */ +var _S021 = float32(0.00011692678527) /* 0x38f53697 */ +var _S031 = float32(5.1354652442e-07) /* 0x3509daa6 */ +var _S041 = float32(1.1661400734e-09) /* 0x30a045e8 */ + +func Xj0f(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, z float32 + _, _, _, _ = ix, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + return Float32FromInt32(1) / float32(x*x) + } + x = Xfabsf(tls, x) + if ix >= uint32(0x40000000) { /* |x| >= 2 */ + /* large ulp error near zeros */ + return _common1(tls, ix, x, 0) + } + if ix >= uint32(0x3a000000) { /* |x| >= 2**-11 */ + /* up to 4ulp error near 2 */ + z = float32(x * x) + r = float32(z * (_R021 + float32(z*(_R031+float32(z*(_R041+float32(z*_R051))))))) + s = Float32FromInt32(1) + float32(z*(_S011+float32(z*(_S021+float32(z*(_S031+float32(z*_S041))))))) + return float32((Float32FromInt32(1)+x/Float32FromInt32(2))*(Float32FromInt32(1)-x/Float32FromInt32(2))) + float32(z*(r/s)) + } + if ix >= uint32(0x21800000) { /* |x| >= 2**-60 */ + x = float32(float32(Float32FromFloat32(0.25)*x) * x) + } + return Float32FromInt32(1) - x +} + +var _u001 = float32(-Float64FromFloat64(0.073804296553)) /* 0xbd9726b5 */ +var _u011 = float32(0.17666645348) /* 0x3e34e80d */ +var _u021 = float32(-Float64FromFloat64(0.013818567619)) /* 0xbc626746 */ +var _u031 = float32(0.00034745343146) /* 0x39b62a69 */ +var _u041 = float32(-Float64FromFloat64(3.8140706238e-06)) /* 0xb67ff53c */ +var _u051 = float32(1.9559013964e-08) /* 0x32a802ba */ +var _u061 = float32(-Float64FromFloat64(3.982051841e-11)) /* 0xae2f21eb */ +var _v011 = float32(0.012730483897) /* 0x3c509385 */ +var _v021 = float32(7.6006865129e-05) /* 0x389f65e0 */ +var _v031 = float32(2.5915085189e-07) /* 0x348b216c */ +var _v041 = float32(4.4111031494e-10) /* 0x2ff280c2 */ + +func Xy0f(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ix Tuint32_t + var u, v, z float32 + _, _, _, _ = ix, u, v, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + if ix&uint32(0x7fffffff) == uint32(0) { + return float32(-Int32FromInt32(1)) / Float32FromFloat32(0) + } + if ix>>int32(31) != 0 { + return Float32FromInt32(0) / Float32FromFloat32(0) + } + if ix >= uint32(0x7f800000) { + return Float32FromInt32(1) / x + } + if ix >= uint32(0x40000000) { /* |x| >= 2.0 */ + /* large ulp error near zeros */ + return _common1(tls, ix, x, int32(1)) + } + if ix >= uint32(0x39000000) { /* x >= 2**-13 */ + /* large ulp error at x ~= 0.89 */ + z = float32(x * x) + u = _u001 + float32(z*(_u011+float32(z*(_u021+float32(z*(_u031+float32(z*(_u041+float32(z*(_u051+float32(z*_u061))))))))))) + v = Float32FromInt32(1) + float32(z*(_v011+float32(z*(_v021+float32(z*(_v031+float32(z*_v041))))))) + return u/v + float32(_tpi1*float32(Xj0f(tls, x)*Xlogf(tls, x))) + } + return _u001 + float32(_tpi1*Xlogf(tls, x)) +} + +// C documentation +// +// /* The asymptotic expansions of pzero is +// * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. +// * For x >= 2, We approximate pzero by +// * pzero(x) = 1 + (R/S) +// * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 +// * S = 1 + pS0*s^2 + ... + pS4*s^10 +// * and +// * | pzero(x)-1-R/S | <= 2 ** ( -60.26) +// */ +var _pR81 = [6]float32{ + 1: float32(-Float64FromFloat64(0.0703125)), + 2: float32(-Float64FromFloat64(8.0816707611)), + 3: float32(-Float64FromFloat64(257.06311035)), + 4: float32(-Float64FromFloat64(2485.2163086)), + 5: float32(-Float64FromFloat64(5253.0439453)), +} +var _pS81 = [5]float32{ + 0: float32(116.53436279), + 1: float32(3833.744873), + 2: float32(40597.855469), + 3: float32(116752.96875), + 4: float32(47627.726562), +} +var _pR51 = [6]float32{ + 0: float32(-Float64FromFloat64(1.1412546255e-11)), + 1: float32(-Float64FromFloat64(0.070312492549)), + 2: float32(-Float64FromFloat64(4.1596107483)), + 3: float32(-Float64FromFloat64(67.674766541)), + 4: float32(-Float64FromFloat64(331.23129272)), + 5: float32(-Float64FromFloat64(346.43338013)), +} +var _pS53 = [5]float32{ + 0: float32(60.753936768), + 1: float32(1051.2523193), + 2: float32(5978.9707031), + 3: float32(9625.4453125), + 4: float32(2406.0581055), +} + +var _pR31 = [6]float32{ + 0: float32(-Float64FromFloat64(2.5470459075e-09)), + 1: float32(-Float64FromFloat64(0.070311963558)), + 2: float32(-Float64FromFloat64(2.4090321064)), + 3: float32(-Float64FromFloat64(21.965976715)), + 4: float32(-Float64FromFloat64(58.079170227)), + 5: float32(-Float64FromFloat64(31.447946548)), +} +var _pS33 = [5]float32{ + 0: float32(35.856033325), + 1: float32(361.51397705), + 2: float32(1193.6077881), + 3: float32(1127.9968262), + 4: float32(173.58093262), +} + +var _pR21 = [6]float32{ + 0: float32(-Float64FromFloat64(8.8753431271e-08)), + 1: float32(-Float64FromFloat64(0.070303097367)), + 2: float32(-Float64FromFloat64(1.45073843)), + 3: float32(-Float64FromFloat64(7.6356959343)), + 4: float32(-Float64FromFloat64(11.193166733)), + 5: float32(-Float64FromFloat64(3.2336456776)), +} +var _pS25 = [5]float32{ + 0: float32(22.220300674), + 1: float32(136.20678711), + 2: float32(270.47027588), + 3: float32(153.87539673), + 4: float32(14.657617569), +} + +func _pzerof(tls *TLS, x float32) (r1 float32) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tfloat_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x41000000) { + p = uintptr(unsafe.Pointer(&_pR81)) + q = uintptr(unsafe.Pointer(&_pS81)) + } else { + if ix >= uint32(0x409173eb) { + p = uintptr(unsafe.Pointer(&_pR51)) + q = uintptr(unsafe.Pointer(&_pS53)) + } else { + if ix >= uint32(0x4036d917) { + p = uintptr(unsafe.Pointer(&_pR31)) + q = uintptr(unsafe.Pointer(&_pS33)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_pR21)) + q = uintptr(unsafe.Pointer(&_pS25)) + } + } + } + z = Float32FromFloat32(1) / float32(x*x) + r = **(**float32)(__ccgo_up(p)) + float32(z*(**(**float32)(__ccgo_up(p + 1*4))+float32(z*(**(**float32)(__ccgo_up(p + 2*4))+float32(z*(**(**float32)(__ccgo_up(p + 3*4))+float32(z*(**(**float32)(__ccgo_up(p + 4*4))+float32(z***(**float32)(__ccgo_up(p + 5*4))))))))))) + s = Float32FromFloat32(1) + float32(z*(**(**float32)(__ccgo_up(q))+float32(z*(**(**float32)(__ccgo_up(q + 1*4))+float32(z*(**(**float32)(__ccgo_up(q + 2*4))+float32(z*(**(**float32)(__ccgo_up(q + 3*4))+float32(z***(**float32)(__ccgo_up(q + 4*4))))))))))) + return Float32FromFloat32(1) + r/s +} + +// C documentation +// +// /* For x >= 8, the asymptotic expansions of qzero is +// * -1/8 s + 75/1024 s^3 - ..., where s = 1/x. +// * We approximate pzero by +// * qzero(x) = s*(-1.25 + (R/S)) +// * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 +// * S = 1 + qS0*s^2 + ... + qS5*s^12 +// * and +// * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) +// */ +var _qR81 = [6]float32{ + 1: float32(0.0732421875), + 2: float32(11.768206596), + 3: float32(557.67340088), + 4: float32(8859.1972656), + 5: float32(37014.625), +} +var _qS81 = [6]float32{ + 0: float32(163.77603149), + 1: float32(8098.3447266), + 2: float32(142538.29688), + 3: float32(803309.25), + 4: float32(840501.5625), + 5: float32(-Float64FromFloat64(343899.28125)), +} + +var _qR51 = [6]float32{ + 0: float32(1.8408595828e-11), + 1: float32(0.073242180049), + 2: float32(5.8356351852), + 3: float32(135.11157227), + 4: float32(1027.2437744), + 5: float32(1989.9779053), +} +var _qS51 = [6]float32{ + 0: float32(82.776611328), + 1: float32(2077.814209), + 2: float32(18847.289062), + 3: float32(56751.113281), + 4: float32(35976.753906), + 5: float32(-Float64FromFloat64(5354.3427734)), +} + +var _qR31 = [6]float32{ + 0: float32(4.37740999e-09), + 1: float32(0.073241114616), + 2: float32(3.3442313671), + 3: float32(42.621845245), + 4: float32(170.80809021), + 5: float32(166.73394775), +} +var _qS33 = [6]float32{ + 0: float32(48.758872986), + 1: float32(709.68920898), + 2: float32(3704.1481934), + 3: float32(6460.425293), + 4: float32(2516.3337402), + 5: float32(-Float64FromFloat64(149.24745178)), +} + +var _qR21 = [6]float32{ + 0: float32(1.5044444979e-07), + 1: float32(0.073223426938), + 2: float32(1.9981917143), + 3: float32(14.495602608), + 4: float32(31.666231155), + 5: float32(16.252708435), +} +var _qS23 = [6]float32{ + 0: float32(30.365585327), + 1: float32(269.34811401), + 2: float32(844.78375244), + 3: float32(882.93585205), + 4: float32(212.66638184), + 5: float32(-Float64FromFloat64(5.3109550476)), +} + +func _qzerof(tls *TLS, x float32) (r1 float32) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tfloat_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x41000000) { + p = uintptr(unsafe.Pointer(&_qR81)) + q = uintptr(unsafe.Pointer(&_qS81)) + } else { + if ix >= uint32(0x409173eb) { + p = uintptr(unsafe.Pointer(&_qR51)) + q = uintptr(unsafe.Pointer(&_qS51)) + } else { + if ix >= uint32(0x4036d917) { + p = uintptr(unsafe.Pointer(&_qR31)) + q = uintptr(unsafe.Pointer(&_qS33)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_qR21)) + q = uintptr(unsafe.Pointer(&_qS23)) + } + } + } + z = Float32FromFloat32(1) / float32(x*x) + r = **(**float32)(__ccgo_up(p)) + float32(z*(**(**float32)(__ccgo_up(p + 1*4))+float32(z*(**(**float32)(__ccgo_up(p + 2*4))+float32(z*(**(**float32)(__ccgo_up(p + 3*4))+float32(z*(**(**float32)(__ccgo_up(p + 4*4))+float32(z***(**float32)(__ccgo_up(p + 5*4))))))))))) + s = Float32FromFloat32(1) + float32(z*(**(**float32)(__ccgo_up(q))+float32(z*(**(**float32)(__ccgo_up(q + 1*4))+float32(z*(**(**float32)(__ccgo_up(q + 2*4))+float32(z*(**(**float32)(__ccgo_up(q + 3*4))+float32(z*(**(**float32)(__ccgo_up(q + 4*4))+float32(z***(**float32)(__ccgo_up(q + 5*4))))))))))))) + return (-Float32FromFloat32(0.125) + r/s) / x +} + +var _invsqrtpi2 = float64(0.5641895835477563) /* 0x3FE20DD7, 0x50429B6D */ +var _tpi2 = float64(0.6366197723675814) /* 0x3FE45F30, 0x6DC9C883 */ + +func _common2(tls *TLS, ix Tuint32_t, x float64, y1 int32, sign int32) (r float64) { + var c, cc, s, ss, z float64 + _, _, _, _, _ = c, cc, s, ss, z + /* + * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x-3pi/4)-q1(x)*sin(x-3pi/4)) + * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x-3pi/4)+q1(x)*cos(x-3pi/4)) + * + * sin(x-3pi/4) = -(sin(x) + cos(x))/sqrt(2) + * cos(x-3pi/4) = (sin(x) - cos(x))/sqrt(2) + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + */ + s = Xsin(tls, x) + if y1 != 0 { + s = -s + } + c = Xcos(tls, x) + cc = s - c + if ix < uint32(0x7fe00000) { + /* avoid overflow in 2*x */ + ss = -s - c + z = Xcos(tls, float64(Float64FromInt32(2)*x)) + if float64(s*c) > Float64FromInt32(0) { + cc = z / ss + } else { + ss = z / cc + } + if ix < uint32(0x48000000) { + if y1 != 0 { + ss = -ss + } + cc = float64(_pone(tls, x)*cc) - float64(_qone(tls, x)*ss) + } + } + if sign != 0 { + cc = -cc + } + return float64(_invsqrtpi2*cc) / Xsqrt(tls, x) +} + +// C documentation +// +// /* R0/S0 on [0,2] */ + +var _r00 = -Float64FromFloat64(0.0625) /* 0xBFB00000, 0x00000000 */ +var _r01 = float64(0.001407056669551897) /* 0x3F570D9F, 0x98472C61 */ +var _r02 = -Float64FromFloat64(1.599556310840356e-05) /* 0xBEF0C5C6, 0xBA169668 */ +var _r03 = float64(4.9672799960958445e-08) /* 0x3E6AAAFA, 0x46CA0BD9 */ +var _s01 = float64(0.019153759953836346) /* 0x3F939D0B, 0x12637E53 */ +var _s02 = float64(0.00018594678558863092) /* 0x3F285F56, 0xB9CDF664 */ +var _s03 = float64(1.1771846404262368e-06) /* 0x3EB3BFF8, 0x333F8498 */ +var _s04 = float64(5.0463625707621704e-09) /* 0x3E35AC88, 0xC97DFF2C */ +var _s05 = float64(1.2354227442613791e-11) /* 0x3DAB2ACF, 0xCFB97ED8 */ + +func Xj1(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, z float64 + var sign int32 + _, _, _, _, _ = ix, r, s, sign, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7ff00000) { + return Float64FromInt32(1) / float64(x*x) + } + if ix >= uint32(0x40000000) { /* |x| >= 2 */ + return _common2(tls, ix, Xfabs(tls, x), 0, sign) + } + if ix >= uint32(0x38000000) { /* |x| >= 2**-127 */ + z = float64(x * x) + r = float64(z * (_r00 + float64(z*(_r01+float64(z*(_r02+float64(z*_r03))))))) + s = Float64FromInt32(1) + float64(z*(_s01+float64(z*(_s02+float64(z*(_s03+float64(z*(_s04+float64(z*_s05))))))))) + z = r / s + } else { + /* avoid underflow, raise inexact if x!=0 */ + z = x + } + return float64((float64(0.5) + z) * x) +} + +var _U0 = [5]float64{ + 0: -Float64FromFloat64(0.19605709064623894), + 1: float64(0.05044387166398113), + 2: -Float64FromFloat64(0.0019125689587576355), + 3: float64(2.352526005616105e-05), + 4: -Float64FromFloat64(9.190991580398789e-08), +} +var _V0 = [5]float64{ + 0: float64(0.01991673182366499), + 1: float64(0.00020255258102513517), + 2: float64(1.3560880109751623e-06), + 3: float64(6.227414523646215e-09), + 4: float64(1.6655924620799208e-11), +} + +func Xy1(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u Tuint64_t + var ix, lx Tuint32_t + var u, v, z float64 + _, _, _, _, _, _ = __u, ix, lx, u, v, z + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + ix = uint32(__u >> int32(32)) + lx = uint32(__u) + /* y1(nan)=nan, y1(<0)=nan, y1(0)=-inf, y1(inf)=0 */ + if ix<>int32(31) != 0 { + return Float64FromInt32(0) / Float64FromFloat64(0) + } + if ix >= uint32(0x7ff00000) { + return Float64FromInt32(1) / x + } + if ix >= uint32(0x40000000) { /* x >= 2 */ + return _common2(tls, ix, x, int32(1), 0) + } + if ix < uint32(0x3c900000) { /* x < 2**-54 */ + return -_tpi2 / x + } + z = float64(x * x) + u = _U0[0] + float64(z*(_U0[int32(1)]+float64(z*(_U0[int32(2)]+float64(z*(_U0[int32(3)]+float64(z*_U0[int32(4)]))))))) + v = Float64FromInt32(1) + float64(z*(_V0[0]+float64(z*(_V0[int32(1)]+float64(z*(_V0[int32(2)]+float64(z*(_V0[int32(3)]+float64(z*_V0[int32(4)]))))))))) + return float64(x*(u/v)) + float64(_tpi2*(float64(Xj1(tls, x)*Xlog(tls, x))-Float64FromInt32(1)/x)) +} + +/* For x >= 8, the asymptotic expansions of pone is + * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. + * We approximate pone by + * pone(x) = 1 + (R/S) + * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 + * S = 1 + ps0*s^2 + ... + ps4*s^10 + * and + * | pone(x)-1-R/S | <= 2 ** ( -60.06) + */ + +var _pr8 = [6]float64{ + 1: float64(0.11718749999998865), + 2: float64(13.239480659307358), + 3: float64(412.05185430737856), + 4: float64(3874.7453891396053), + 5: float64(7914.479540318917), +} +var _ps8 = [5]float64{ + 0: float64(114.20737037567841), + 1: float64(3650.9308342085346), + 2: float64(36956.206026903346), + 3: float64(97602.79359349508), + 4: float64(30804.27206278888), +} + +var _pr5 = [6]float64{ + 0: float64(1.3199051955624352e-11), + 1: float64(0.1171874931906141), + 2: float64(6.802751278684329), + 3: float64(108.30818299018911), + 4: float64(517.6361395331998), + 5: float64(528.7152013633375), +} +var _ps5 = [5]float64{ + 0: float64(59.28059872211313), + 1: float64(991.4014187336144), + 2: float64(5353.26695291488), + 3: float64(7844.690317495512), + 4: float64(1504.0468881036106), +} + +var _pr3 = [6]float64{ + 0: float64(3.025039161373736e-09), + 1: float64(0.11718686556725359), + 2: float64(3.9329775003331564), + 3: float64(35.11940355916369), + 4: float64(91.05501107507813), + 5: float64(48.55906851973649), +} +var _ps3 = [5]float64{ + 0: float64(34.79130950012515), + 1: float64(336.76245874782575), + 2: float64(1046.8713997577513), + 3: float64(890.8113463982564), + 4: float64(103.78793243963928), +} + +var _pr2 = [6]float64{ + 0: float64(1.0771083010687374e-07), + 1: float64(0.11717621946268335), + 2: float64(2.368514966676088), + 3: float64(12.242610914826123), + 4: float64(17.693971127168773), + 5: float64(5.073523125888185), +} +var _ps2 = [5]float64{ + 0: float64(21.43648593638214), + 1: float64(125.29022716840275), + 2: float64(232.2764690571628), + 3: float64(117.6793732871471), + 4: float64(8.364638933716183), +} + +func _pone(tls *TLS, x float64) (r1 float64) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tdouble_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x40200000) { + p = uintptr(unsafe.Pointer(&_pr8)) + q = uintptr(unsafe.Pointer(&_ps8)) + } else { + if ix >= uint32(0x40122E8B) { + p = uintptr(unsafe.Pointer(&_pr5)) + q = uintptr(unsafe.Pointer(&_ps5)) + } else { + if ix >= uint32(0x4006DB6D) { + p = uintptr(unsafe.Pointer(&_pr3)) + q = uintptr(unsafe.Pointer(&_ps3)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_pr2)) + q = uintptr(unsafe.Pointer(&_ps2)) + } + } + } + z = float64(1) / float64(x*x) + r = **(**float64)(__ccgo_up(p)) + float64(z*(**(**float64)(__ccgo_up(p + 1*8))+float64(z*(**(**float64)(__ccgo_up(p + 2*8))+float64(z*(**(**float64)(__ccgo_up(p + 3*8))+float64(z*(**(**float64)(__ccgo_up(p + 4*8))+float64(z***(**float64)(__ccgo_up(p + 5*8))))))))))) + s = float64(1) + float64(z*(**(**float64)(__ccgo_up(q))+float64(z*(**(**float64)(__ccgo_up(q + 1*8))+float64(z*(**(**float64)(__ccgo_up(q + 2*8))+float64(z*(**(**float64)(__ccgo_up(q + 3*8))+float64(z***(**float64)(__ccgo_up(q + 4*8))))))))))) + return float64(1) + r/s +} + +/* For x >= 8, the asymptotic expansions of qone is + * 3/8 s - 105/1024 s^3 - ..., where s = 1/x. + * We approximate pone by + * qone(x) = s*(0.375 + (R/S)) + * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 + * S = 1 + qs1*s^2 + ... + qs6*s^12 + * and + * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) + */ + +var _qr8 = [6]float64{ + 1: -Float64FromFloat64(0.10253906249999271), + 2: -Float64FromFloat64(16.271753454459), + 3: -Float64FromFloat64(759.6017225139501), + 4: -Float64FromFloat64(11849.806670242959), + 5: -Float64FromFloat64(48438.512428575035), +} +var _qs8 = [6]float64{ + 0: float64(161.3953697007229), + 1: float64(7825.385999233485), + 2: float64(133875.33628724958), + 3: float64(719657.7236832409), + 4: float64(666601.2326177764), + 5: -Float64FromFloat64(294490.26430383464), +} + +var _qr5 = [6]float64{ + 0: -Float64FromFloat64(2.089799311417641e-11), + 1: -Float64FromFloat64(0.10253905024137543), + 2: -Float64FromFloat64(8.05644828123936), + 3: -Float64FromFloat64(183.66960747488838), + 4: -Float64FromFloat64(1373.1937606550816), + 5: -Float64FromFloat64(2612.4444045321566), +} +var _qs5 = [6]float64{ + 0: float64(81.27655013843358), + 1: float64(1991.7987346048596), + 2: float64(17468.48519249089), + 3: float64(49851.42709103523), + 4: float64(27948.075163891812), + 5: -Float64FromFloat64(4719.183547951285), +} + +var _qr3 = [6]float64{ + 0: -Float64FromFloat64(5.078312264617666e-09), + 1: -Float64FromFloat64(0.10253782982083709), + 2: -Float64FromFloat64(4.610115811394734), + 3: -Float64FromFloat64(57.847221656278364), + 4: -Float64FromFloat64(228.2445407376317), + 5: -Float64FromFloat64(219.21012847890933), +} +var _qs3 = [6]float64{ + 0: float64(47.66515503237295), + 1: float64(673.8651126766997), + 2: float64(3380.1528667952634), + 3: float64(5547.729097207228), + 4: float64(1903.119193388108), + 5: -Float64FromFloat64(135.20119144430734), +} + +var _qr2 = [6]float64{ + 0: -Float64FromFloat64(1.7838172751095887e-07), + 1: -Float64FromFloat64(0.10251704260798555), + 2: -Float64FromFloat64(2.7522056827818746), + 3: -Float64FromFloat64(19.663616264370372), + 4: -Float64FromFloat64(42.32531333728305), + 5: -Float64FromFloat64(21.371921170370406), +} +var _qs2 = [6]float64{ + 0: float64(29.533362906052385), + 1: float64(252.98154998219053), + 2: float64(757.5028348686454), + 3: float64(739.3932053204672), + 4: float64(155.94900333666612), + 5: -Float64FromFloat64(4.959498988226282), +} + +func _qone(tls *TLS, x float64) (r1 float64) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tdouble_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x40200000) { + p = uintptr(unsafe.Pointer(&_qr8)) + q = uintptr(unsafe.Pointer(&_qs8)) + } else { + if ix >= uint32(0x40122E8B) { + p = uintptr(unsafe.Pointer(&_qr5)) + q = uintptr(unsafe.Pointer(&_qs5)) + } else { + if ix >= uint32(0x4006DB6D) { + p = uintptr(unsafe.Pointer(&_qr3)) + q = uintptr(unsafe.Pointer(&_qs3)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_qr2)) + q = uintptr(unsafe.Pointer(&_qs2)) + } + } + } + z = float64(1) / float64(x*x) + r = **(**float64)(__ccgo_up(p)) + float64(z*(**(**float64)(__ccgo_up(p + 1*8))+float64(z*(**(**float64)(__ccgo_up(p + 2*8))+float64(z*(**(**float64)(__ccgo_up(p + 3*8))+float64(z*(**(**float64)(__ccgo_up(p + 4*8))+float64(z***(**float64)(__ccgo_up(p + 5*8))))))))))) + s = float64(1) + float64(z*(**(**float64)(__ccgo_up(q))+float64(z*(**(**float64)(__ccgo_up(q + 1*8))+float64(z*(**(**float64)(__ccgo_up(q + 2*8))+float64(z*(**(**float64)(__ccgo_up(q + 3*8))+float64(z*(**(**float64)(__ccgo_up(q + 4*8))+float64(z***(**float64)(__ccgo_up(q + 5*8))))))))))))) + return (float64(0.375) + r/s) / x +} + +var _invsqrtpi3 = float32(0.56418961287) /* 0x3f106ebb */ +var _tpi3 = float32(0.63661974669) /* 0x3f22f983 */ + +func _common3(tls *TLS, ix Tuint32_t, x float32, y1 int32, sign int32) (r float32) { + var c, cc, s, ss, z float64 + _, _, _, _, _ = c, cc, s, ss, z + s = float64(Xsinf(tls, x)) + if y1 != 0 { + s = -s + } + c = float64(Xcosf(tls, x)) + cc = s - c + if ix < uint32(0x7f000000) { + ss = -s - c + z = float64(Xcosf(tls, float32(Float32FromInt32(2)*x))) + if float64(s*c) > Float64FromInt32(0) { + cc = z / ss + } else { + ss = z / cc + } + if ix < uint32(0x58800000) { + if y1 != 0 { + ss = -ss + } + cc = float64(float64(_ponef(tls, x))*cc) - float64(float64(_qonef(tls, x))*ss) + } + } + if sign != 0 { + cc = -cc + } + return float32(float64(float64(_invsqrtpi3)*cc) / float64(Xsqrtf(tls, x))) +} + +// C documentation +// +// /* R0/S0 on [0,2] */ + +var _r001 = float32(-Float64FromFloat64(0.0625)) /* 0xbd800000 */ +var _r011 = float32(0.0014070566976) /* 0x3ab86cfd */ +var _r021 = float32(-Float64FromFloat64(1.5995563444e-05)) /* 0xb7862e36 */ +var _r031 = float32(4.9672799207e-08) /* 0x335557d2 */ +var _s011 = float32(0.019153760746) /* 0x3c9ce859 */ +var _s021 = float32(0.00018594678841) /* 0x3942fab6 */ +var _s031 = float32(1.1771846857e-06) /* 0x359dffc2 */ +var _s041 = float32(5.046362439e-09) /* 0x31ad6446 */ +var _s051 = float32(1.2354227016e-11) /* 0x2d59567e */ + +func Xj1f(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ix Tuint32_t + var r, s, z float32 + var sign int32 + _, _, _, _, _ = ix, r, s, sign, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + return Float32FromInt32(1) / float32(x*x) + } + if ix >= uint32(0x40000000) { /* |x| >= 2 */ + return _common3(tls, ix, Xfabsf(tls, x), 0, sign) + } + if ix >= uint32(0x39000000) { /* |x| >= 2**-13 */ + z = float32(x * x) + r = float32(z * (_r001 + float32(z*(_r011+float32(z*(_r021+float32(z*_r031))))))) + s = Float32FromInt32(1) + float32(z*(_s011+float32(z*(_s021+float32(z*(_s031+float32(z*(_s041+float32(z*_s051))))))))) + z = Float32FromFloat32(0.5) + r/s + } else { + z = Float32FromFloat32(0.5) + } + return float32(z * x) +} + +var _U01 = [5]float32{ + 0: float32(-Float64FromFloat64(0.19605709612)), + 1: float32(0.050443872809), + 2: float32(-Float64FromFloat64(0.0019125689287)), + 3: float32(2.3525259166e-05), + 4: float32(-Float64FromFloat64(9.1909917899e-08)), +} +var _V01 = [5]float32{ + 0: float32(0.019916731864), + 1: float32(0.0002025525755), + 2: float32(1.3560879779e-06), + 3: float32(6.227414584e-09), + 4: float32(1.6655924903e-11), +} + +func Xy1f(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ix Tuint32_t + var u, v, z float32 + _, _, _, _ = ix, u, v, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + if ix&uint32(0x7fffffff) == uint32(0) { + return float32(-Int32FromInt32(1)) / Float32FromFloat32(0) + } + if ix>>int32(31) != 0 { + return Float32FromInt32(0) / Float32FromFloat32(0) + } + if ix >= uint32(0x7f800000) { + return Float32FromInt32(1) / x + } + if ix >= uint32(0x40000000) { /* |x| >= 2.0 */ + return _common3(tls, ix, x, int32(1), 0) + } + if ix < uint32(0x33000000) { /* x < 2**-25 */ + return -_tpi3 / x + } + z = float32(x * x) + u = _U01[0] + float32(z*(_U01[int32(1)]+float32(z*(_U01[int32(2)]+float32(z*(_U01[int32(3)]+float32(z*_U01[int32(4)]))))))) + v = Float32FromFloat32(1) + float32(z*(_V01[0]+float32(z*(_V01[int32(1)]+float32(z*(_V01[int32(2)]+float32(z*(_V01[int32(3)]+float32(z*_V01[int32(4)]))))))))) + return float32(x*(u/v)) + float32(_tpi3*(float32(Xj1f(tls, x)*Xlogf(tls, x))-Float32FromFloat32(1)/x)) +} + +/* For x >= 8, the asymptotic expansions of pone is + * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. + * We approximate pone by + * pone(x) = 1 + (R/S) + * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 + * S = 1 + ps0*s^2 + ... + ps4*s^10 + * and + * | pone(x)-1-R/S | <= 2 ** ( -60.06) + */ + +var _pr81 = [6]float32{ + 1: float32(0.1171875), + 2: float32(13.239480972), + 3: float32(412.05184937), + 4: float32(3874.7453613), + 5: float32(7914.4794922), +} +var _ps81 = [5]float32{ + 0: float32(114.20736694), + 1: float32(3650.9309082), + 2: float32(36956.207031), + 3: float32(97602.796875), + 4: float32(30804.271484), +} + +var _pr51 = [6]float32{ + 0: float32(1.3199052094e-11), + 1: float32(0.11718749255), + 2: float32(6.8027510643), + 3: float32(108.30818176), + 4: float32(517.63616943), + 5: float32(528.71520996), +} +var _ps51 = [5]float32{ + 0: float32(59.280597687), + 1: float32(991.40142822), + 2: float32(5353.2670898), + 3: float32(7844.6904297), + 4: float32(1504.046875), +} + +var _pr31 = [6]float32{ + 0: float32(3.0250391081e-09), + 1: float32(0.1171868667), + 2: float32(3.932977438), + 3: float32(35.119403839), + 4: float32(91.055007935), + 5: float32(48.559066772), +} +var _ps31 = [5]float32{ + 0: float32(34.791309357), + 1: float32(336.76245117), + 2: float32(1046.87146), + 3: float32(890.81134033), + 4: float32(103.78793335), +} + +var _pr21 = [6]float32{ + 0: float32(1.0771083225e-07), + 1: float32(0.11717621982), + 2: float32(2.3685150146), + 3: float32(12.242610931), + 4: float32(17.693971634), + 5: float32(5.0735230446), +} +var _ps21 = [5]float32{ + 0: float32(21.436485291), + 1: float32(125.2902298), + 2: float32(232.276474), + 3: float32(117.67937469), + 4: float32(8.3646392822), +} + +func _ponef(tls *TLS, x float32) (r1 float32) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tfloat_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x41000000) { + p = uintptr(unsafe.Pointer(&_pr81)) + q = uintptr(unsafe.Pointer(&_ps81)) + } else { + if ix >= uint32(0x409173eb) { + p = uintptr(unsafe.Pointer(&_pr51)) + q = uintptr(unsafe.Pointer(&_ps51)) + } else { + if ix >= uint32(0x4036d917) { + p = uintptr(unsafe.Pointer(&_pr31)) + q = uintptr(unsafe.Pointer(&_ps31)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_pr21)) + q = uintptr(unsafe.Pointer(&_ps21)) + } + } + } + z = Float32FromFloat32(1) / float32(x*x) + r = **(**float32)(__ccgo_up(p)) + float32(z*(**(**float32)(__ccgo_up(p + 1*4))+float32(z*(**(**float32)(__ccgo_up(p + 2*4))+float32(z*(**(**float32)(__ccgo_up(p + 3*4))+float32(z*(**(**float32)(__ccgo_up(p + 4*4))+float32(z***(**float32)(__ccgo_up(p + 5*4))))))))))) + s = Float32FromFloat32(1) + float32(z*(**(**float32)(__ccgo_up(q))+float32(z*(**(**float32)(__ccgo_up(q + 1*4))+float32(z*(**(**float32)(__ccgo_up(q + 2*4))+float32(z*(**(**float32)(__ccgo_up(q + 3*4))+float32(z***(**float32)(__ccgo_up(q + 4*4))))))))))) + return Float32FromFloat32(1) + r/s +} + +/* For x >= 8, the asymptotic expansions of qone is + * 3/8 s - 105/1024 s^3 - ..., where s = 1/x. + * We approximate pone by + * qone(x) = s*(0.375 + (R/S)) + * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 + * S = 1 + qs1*s^2 + ... + qs6*s^12 + * and + * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) + */ + +var _qr81 = [6]float32{ + 1: float32(-Float64FromFloat64(0.1025390625)), + 2: float32(-Float64FromFloat64(16.271753311)), + 3: float32(-Float64FromFloat64(759.60174561)), + 4: float32(-Float64FromFloat64(11849.806641)), + 5: float32(-Float64FromFloat64(48438.511719)), +} +var _qs81 = [6]float32{ + 0: float32(161.39537048), + 1: float32(7825.3862305), + 2: float32(133875.34375), + 3: float32(719657.75), + 4: float32(666601.25), + 5: float32(-Float64FromFloat64(294490.25)), +} + +var _qr51 = [6]float32{ + 0: float32(-Float64FromFloat64(2.0897993405e-11)), + 1: float32(-Float64FromFloat64(0.1025390476)), + 2: float32(-Float64FromFloat64(8.0564479828)), + 3: float32(-Float64FromFloat64(183.66960144)), + 4: float32(-Float64FromFloat64(1373.1937256)), + 5: float32(-Float64FromFloat64(2612.4443359)), +} +var _qs51 = [6]float32{ + 0: float32(81.276550293), + 1: float32(1991.7987061), + 2: float32(17468.484375), + 3: float32(49851.425781), + 4: float32(27948.074219), + 5: float32(-Float64FromFloat64(4719.1835938)), +} + +var _qr31 = [6]float32{ + 0: float32(-Float64FromFloat64(5.0783124372e-09)), + 1: float32(-Float64FromFloat64(0.10253783315)), + 2: float32(-Float64FromFloat64(4.6101160049)), + 3: float32(-Float64FromFloat64(57.847221375)), + 4: float32(-Float64FromFloat64(228.24453735)), + 5: float32(-Float64FromFloat64(219.21012878)), +} +var _qs31 = [6]float32{ + 0: float32(47.665153503), + 1: float32(673.8651123), + 2: float32(3380.152832), + 3: float32(5547.7290039), + 4: float32(1903.1191406), + 5: float32(-Float64FromFloat64(135.20118713)), +} + +var _qr21 = [6]float32{ + 0: float32(-Float64FromFloat64(1.7838172539e-07)), + 1: float32(-Float64FromFloat64(0.10251704603)), + 2: float32(-Float64FromFloat64(2.7522056103)), + 3: float32(-Float64FromFloat64(19.66361618)), + 4: float32(-Float64FromFloat64(42.325313568)), + 5: float32(-Float64FromFloat64(21.371921539)), +} +var _qs21 = [6]float32{ + 0: float32(29.533363342), + 1: float32(252.98155212), + 2: float32(757.50280762), + 3: float32(739.39318848), + 4: float32(155.94900513), + 5: float32(-Float64FromFloat64(4.9594988823)), +} + +func _qonef(tls *TLS, x float32) (r1 float32) { + var ix Tuint32_t + var p, q uintptr + var r, s, z Tfloat_t + _, _, _, _, _, _ = ix, p, q, r, s, z + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + ix = ix & uint32(0x7fffffff) + if ix >= uint32(0x41000000) { + p = uintptr(unsafe.Pointer(&_qr81)) + q = uintptr(unsafe.Pointer(&_qs81)) + } else { + if ix >= uint32(0x409173eb) { + p = uintptr(unsafe.Pointer(&_qr51)) + q = uintptr(unsafe.Pointer(&_qs51)) + } else { + if ix >= uint32(0x4036d917) { + p = uintptr(unsafe.Pointer(&_qr31)) + q = uintptr(unsafe.Pointer(&_qs31)) + } else { /*ix >= 0x40000000*/ + p = uintptr(unsafe.Pointer(&_qr21)) + q = uintptr(unsafe.Pointer(&_qs21)) + } + } + } + z = Float32FromFloat32(1) / float32(x*x) + r = **(**float32)(__ccgo_up(p)) + float32(z*(**(**float32)(__ccgo_up(p + 1*4))+float32(z*(**(**float32)(__ccgo_up(p + 2*4))+float32(z*(**(**float32)(__ccgo_up(p + 3*4))+float32(z*(**(**float32)(__ccgo_up(p + 4*4))+float32(z***(**float32)(__ccgo_up(p + 5*4))))))))))) + s = Float32FromFloat32(1) + float32(z*(**(**float32)(__ccgo_up(q))+float32(z*(**(**float32)(__ccgo_up(q + 1*4))+float32(z*(**(**float32)(__ccgo_up(q + 2*4))+float32(z*(**(**float32)(__ccgo_up(q + 3*4))+float32(z*(**(**float32)(__ccgo_up(q + 4*4))+float32(z***(**float32)(__ccgo_up(q + 5*4))))))))))))) + return (Float32FromFloat32(0.375) + r/s) / x +} + +var _invsqrtpi4 = float64(0.5641895835477563) /* 0x3FE20DD7, 0x50429B6D */ + +func Xjn(tls *TLS, n int32, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v n=%v x=%v, (%v:)", tls, n, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u Tuint64_t + var a, b, h, nf, q0, q1, t, temp, tmp, w, z, v6 float64 + var i, k, nm1, sign int32 + var ix, lx Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __u, a, b, h, i, ix, k, lx, nf, nm1, q0, q1, sign, t, temp, tmp, w, z, v6 + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + ix = uint32(__u >> int32(32)) + lx = uint32(__u) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix|(lx|-lx)>>int32(31) > uint32(0x7ff00000) { /* nan */ + return x + } + /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) + * Thus, J(-n,x) = J(n,-x) + */ + /* nm1 = |n|-1 is used instead of |n| to handle n==INT_MIN */ + if n == 0 { + return Xj0(tls, x) + } + if n < 0 { + nm1 = -(n + int32(1)) + x = -x + sign = sign ^ int32(1) + } else { + nm1 = n - int32(1) + } + if nm1 == 0 { + return Xj1(tls, x) + } + sign = sign & n /* even n: 0, odd n: signbit(x) */ + x = Xfabs(tls, x) + if ix|lx == uint32(0) || ix == uint32(0x7ff00000) { /* if x is 0 or inf */ + b = float64(0) + } else { + if float64(nm1) < x { + /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ + if ix >= uint32(0x52d00000) { /* x > 2**302 */ + /* (x >> n**2) + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + switch nm1 & Int32FromInt32(3) { + case 0: + temp = -Xcos(tls, x) + Xsin(tls, x) + case int32(1): + temp = -Xcos(tls, x) - Xsin(tls, x) + case int32(2): + temp = Xcos(tls, x) - Xsin(tls, x) + default: + fallthrough + case int32(3): + temp = Xcos(tls, x) + Xsin(tls, x) + break + } + b = float64(_invsqrtpi4*temp) / Xsqrt(tls, x) + } else { + a = Xj0(tls, x) + b = Xj1(tls, x) + i = 0 + for { + if !(i < nm1) { + break + } + i = i + 1 + temp = b + b = float64(b*(float64(float64(2)*float64(i))/x)) - a /* avoid underflow */ + a = temp + goto _1 + _1: + } + } + } else { + if ix < uint32(0x3e100000) { /* x < 2**-29 */ + /* x is tiny, return the first Taylor expansion of J(n,x) + * J(n,x) = 1/n!*(x/2)^n - ... + */ + if nm1 > int32(32) { /* underflow */ + b = float64(0) + } else { + temp = float64(x * float64(0.5)) + b = temp + a = float64(1) + i = int32(2) + for { + if !(i <= nm1+int32(1)) { + break + } + a = a * float64(i) /* a = n! */ + b = b * temp /* b = (x/2)^n */ + goto _2 + _2: + ; + i = i + 1 + } + b = b / a + } + } else { + nf = float64(nm1) + float64(1) + w = float64(Float64FromInt32(2)*nf) / x + h = Float64FromInt32(2) / x + z = w + h + q0 = w + q1 = float64(w*z) - float64(1) + k = int32(1) + for q1 < float64(1e+09) { + k = k + int32(1) + z = z + h + tmp = float64(z*q1) - q0 + q0 = q1 + q1 = tmp + } + t = float64(0) + i = k + for { + if !(i >= 0) { + break + } + t = Float64FromInt32(1) / (float64(Float64FromInt32(2)*(float64(i)+nf))/x - t) + goto _3 + _3: + ; + i = i - 1 + } + a = t + b = float64(1) + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * Hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = float64(nf * Xlog(tls, Xfabs(tls, w))) + if tmp < float64(709.782712893384) { + i = nm1 + for { + if !(i > 0) { + break + } + temp = b + b = float64(b*float64(float64(2)*float64(i)))/x - a + a = temp + goto _4 + _4: + ; + i = i - 1 + } + } else { + i = nm1 + for { + if !(i > 0) { + break + } + temp = b + b = float64(b*float64(float64(2)*float64(i)))/x - a + a = temp + /* scale b to avoid spurious overflow */ + if b > float64(3.273390607896142e+150) { + a = a / b + t = t / b + b = float64(1) + } + goto _5 + _5: + ; + i = i - 1 + } + } + z = Xj0(tls, x) + w = Xj1(tls, x) + if Xfabs(tls, z) >= Xfabs(tls, w) { + b = float64(t*z) / b + } else { + b = float64(t*w) / a + } + } + } + } + if sign != 0 { + v6 = -b + } else { + v6 = b + } + return v6 +} + +func Xyn(tls *TLS, n int32, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v n=%v x=%v, (%v:)", tls, n, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __u Tuint64_t + var a, b, temp, v1 float64 + var i, nm1, sign int32 + var ib, ix, lx Tuint32_t + _, _, _, _, _, _, _, _, _, _, _ = __u, a, b, i, ib, ix, lx, nm1, sign, temp, v1 + __u = *(*Tuint64_t)(unsafe.Pointer(&x)) + ix = uint32(__u >> int32(32)) + lx = uint32(__u) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix|(lx|-lx)>>int32(31) > uint32(0x7ff00000) { /* nan */ + return x + } + if sign != 0 && ix|lx != uint32(0) { /* x < 0 */ + return Float64FromInt32(0) / Float64FromFloat64(0) + } + if ix == uint32(0x7ff00000) { + return float64(0) + } + if n == 0 { + return Xy0(tls, x) + } + if n < 0 { + nm1 = -(n + int32(1)) + sign = n & int32(1) + } else { + nm1 = n - int32(1) + sign = 0 + } + if nm1 == 0 { + if sign != 0 { + v1 = -Xy1(tls, x) + } else { + v1 = Xy1(tls, x) + } + return v1 + } + if ix >= uint32(0x52d00000) { /* x > 2**302 */ + /* (x >> n**2) + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + switch nm1 & Int32FromInt32(3) { + case 0: + temp = -Xsin(tls, x) - Xcos(tls, x) + case int32(1): + temp = -Xsin(tls, x) + Xcos(tls, x) + case int32(2): + temp = Xsin(tls, x) + Xcos(tls, x) + default: + fallthrough + case int32(3): + temp = Xsin(tls, x) - Xcos(tls, x) + break + } + b = float64(_invsqrtpi4*temp) / Xsqrt(tls, x) + } else { + a = Xy0(tls, x) + b = Xy1(tls, x) + /* quit if b is -inf */ + ib = uint32(*(*Tuint64_t)(unsafe.Pointer(&b)) >> int32(32)) + i = 0 + for { + if !(i < nm1 && ib != uint32(0xfff00000)) { + break + } + i = i + 1 + temp = b + b = float64(float64(float64(2)*float64(i))/x*b) - a + ib = uint32(*(*Tuint64_t)(unsafe.Pointer(&b)) >> int32(32)) + a = temp + goto _2 + _2: + } + } + if sign != 0 { + v1 = -b + } else { + v1 = b + } + return v1 +} + +func Xjnf(tls *TLS, n int32, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v n=%v x=%v, (%v:)", tls, n, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, b, h, nf, q0, q1, t, temp, tmp, w, z, v6 float32 + var i, k, nm1, sign int32 + var ix Tuint32_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, b, h, i, ix, k, nf, nm1, q0, q1, sign, t, temp, tmp, w, z, v6 + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix > uint32(0x7f800000) { /* nan */ + return x + } + /* J(-n,x) = J(n,-x), use |n|-1 to avoid overflow in -n */ + if n == 0 { + return Xj0f(tls, x) + } + if n < 0 { + nm1 = -(n + int32(1)) + x = -x + sign = sign ^ int32(1) + } else { + nm1 = n - int32(1) + } + if nm1 == 0 { + return Xj1f(tls, x) + } + sign = sign & n /* even n: 0, odd n: signbit(x) */ + x = Xfabsf(tls, x) + if ix == uint32(0) || ix == uint32(0x7f800000) { /* if x is 0 or inf */ + b = Float32FromFloat32(0) + } else { + if float32(nm1) < x { + /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ + a = Xj0f(tls, x) + b = Xj1f(tls, x) + i = 0 + for { + if !(i < nm1) { + break + } + i = i + 1 + temp = b + b = float32(b*(float32(Float32FromFloat32(2)*float32(i))/x)) - a + a = temp + goto _1 + _1: + } + } else { + if ix < uint32(0x35800000) { /* x < 2**-20 */ + /* x is tiny, return the first Taylor expansion of J(n,x) + * J(n,x) = 1/n!*(x/2)^n - ... + */ + if nm1 > int32(8) { /* underflow */ + nm1 = int32(8) + } + temp = float32(Float32FromFloat32(0.5) * x) + b = temp + a = Float32FromFloat32(1) + i = int32(2) + for { + if !(i <= nm1+int32(1)) { + break + } + a = a * float32(i) /* a = n! */ + b = b * temp /* b = (x/2)^n */ + goto _2 + _2: + ; + i = i + 1 + } + b = b / a + } else { + nf = float32(nm1) + Float32FromFloat32(1) + w = float32(Float32FromInt32(2)*nf) / x + h = Float32FromInt32(2) / x + z = w + h + q0 = w + q1 = float32(w*z) - Float32FromFloat32(1) + k = int32(1) + for q1 < Float32FromFloat32(10000) { + k = k + int32(1) + z = z + h + tmp = float32(z*q1) - q0 + q0 = q1 + q1 = tmp + } + t = Float32FromFloat32(0) + i = k + for { + if !(i >= 0) { + break + } + t = Float32FromFloat32(1) / (float32(Float32FromInt32(2)*(float32(i)+nf))/x - t) + goto _3 + _3: + ; + i = i - 1 + } + a = t + b = Float32FromFloat32(1) + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * Hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = float32(nf * Xlogf(tls, Xfabsf(tls, w))) + if tmp < Float32FromFloat32(88.721679688) { + i = nm1 + for { + if !(i > 0) { + break + } + temp = b + b = float32(float32(Float32FromFloat32(2)*float32(i))*b)/x - a + a = temp + goto _4 + _4: + ; + i = i - 1 + } + } else { + i = nm1 + for { + if !(i > 0) { + break + } + temp = b + b = float32(float32(Float32FromFloat32(2)*float32(i))*b)/x - a + a = temp + /* scale b to avoid spurious overflow */ + if b > Float32FromFloat32(1.152921504606847e+18) { + a = a / b + t = t / b + b = Float32FromFloat32(1) + } + goto _5 + _5: + ; + i = i - 1 + } + } + z = Xj0f(tls, x) + w = Xj1f(tls, x) + if Xfabsf(tls, z) >= Xfabsf(tls, w) { + b = float32(t*z) / b + } else { + b = float32(t*w) / a + } + } + } + } + if sign != 0 { + v6 = -b + } else { + v6 = b + } + return v6 +} + +func Xynf(tls *TLS, n int32, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v n=%v x=%v, (%v:)", tls, n, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, b, temp, v1 float32 + var i, nm1, sign int32 + var ib, ix Tuint32_t + _, _, _, _, _, _, _, _, _ = a, b, i, ib, ix, nm1, sign, temp, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix > uint32(0x7f800000) { /* nan */ + return x + } + if sign != 0 && ix != uint32(0) { /* x < 0 */ + return Float32FromInt32(0) / Float32FromFloat32(0) + } + if ix == uint32(0x7f800000) { + return Float32FromFloat32(0) + } + if n == 0 { + return Xy0f(tls, x) + } + if n < 0 { + nm1 = -(n + int32(1)) + sign = n & int32(1) + } else { + nm1 = n - int32(1) + sign = 0 + } + if nm1 == 0 { + if sign != 0 { + v1 = -Xy1f(tls, x) + } else { + v1 = Xy1f(tls, x) + } + return v1 + } + a = Xy0f(tls, x) + b = Xy1f(tls, x) + /* quit if b is -inf */ + ib = *(*Tuint32_t)(unsafe.Pointer(&b)) + i = 0 + for { + if !(i < nm1 && ib != uint32(0xff800000)) { + break + } + i = i + 1 + temp = b + b = float32(float32(Float32FromFloat32(2)*float32(i))/x*b) - a + ib = *(*Tuint32_t)(unsafe.Pointer(&b)) + a = temp + goto _2 + _2: + } + if sign != 0 { + v1 = -b + } else { + v1 = b + } + return v1 +} + +func Xldexp(tls *TLS, x float64, n int32) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbn(tls, x, n) +} + +func Xldexpf(tls *TLS, x float32, n int32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbnf(tls, x, n) +} + +func Xldexpl(tls *TLS, x float64, n int32) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbnl(tls, x, n) +} + +func Xlgamma(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgamma_r(tls, x, uintptr(unsafe.Pointer(&Xsigngam))) +} + +var _pi2 = float64(3.141592653589793) /* 0x400921FB, 0x54442D18 */ +var _a0 = float64(0.07721566490153287) /* 0x3FB3C467, 0xE37DB0C8 */ +var _a1 = float64(0.3224670334241136) /* 0x3FD4A34C, 0xC4A60FAD */ +var _a2 = float64(0.06735230105312927) /* 0x3FB13E00, 0x1A5562A7 */ +var _a3 = float64(0.020580808432516733) /* 0x3F951322, 0xAC92547B */ +var _a4 = float64(0.007385550860814029) /* 0x3F7E404F, 0xB68FEFE8 */ +var _a5 = float64(0.0028905138367341563) /* 0x3F67ADD8, 0xCCB7926B */ +var _a6 = float64(0.0011927076318336207) /* 0x3F538A94, 0x116F3F5D */ +var _a7 = float64(0.0005100697921535113) /* 0x3F40B6C6, 0x89B99C00 */ +var _a8 = float64(0.00022086279071390839) /* 0x3F2CF2EC, 0xED10E54D */ +var _a9 = float64(0.00010801156724758394) /* 0x3F1C5088, 0x987DFB07 */ +var _a10 = float64(2.5214456545125733e-05) /* 0x3EFA7074, 0x428CFA52 */ +var _a11 = float64(4.4864094961891516e-05) /* 0x3F07858E, 0x90A45837 */ +var _tc = float64(1.4616321449683622) /* 0x3FF762D8, 0x6356BE3F */ +var _tf = -Float64FromFloat64(0.12148629053584961) /* 0xBFBF19B9, 0xBCC38A42 */ +/* tt = -(tail of tf) */ +var _tt = -Float64FromFloat64(3.638676997039505e-18) /* 0xBC50C7CA, 0xA48A971F */ +var _t0 = float64(0.48383612272381005) /* 0x3FDEF72B, 0xC8EE38A2 */ +var _t1 = -Float64FromFloat64(0.1475877229945939) /* 0xBFC2E427, 0x8DC6C509 */ +var _t2 = float64(0.06462494023913339) /* 0x3FB08B42, 0x94D5419B */ +var _t3 = -Float64FromFloat64(0.032788541075985965) /* 0xBFA0C9A8, 0xDF35B713 */ +var _t4 = float64(0.01797067508118204) /* 0x3F9266E7, 0x970AF9EC */ +var _t5 = -Float64FromFloat64(0.010314224129834144) /* 0xBF851F9F, 0xBA91EC6A */ +var _t6 = float64(0.006100538702462913) /* 0x3F78FCE0, 0xE370E344 */ +var _t7 = -Float64FromFloat64(0.0036845201678113826) /* 0xBF6E2EFF, 0xB3E914D7 */ +var _t8 = float64(0.0022596478090061247) /* 0x3F6282D3, 0x2E15C915 */ +var _t9 = -Float64FromFloat64(0.0014034646998923284) /* 0xBF56FE8E, 0xBF2D1AF1 */ +var _t10 = float64(0.000881081882437654) /* 0x3F4CDF0C, 0xEF61A8E9 */ +var _t11 = -Float64FromFloat64(0.0005385953053567405) /* 0xBF41A610, 0x9C73E0EC */ +var _t12 = float64(0.00031563207090362595) /* 0x3F34AF6D, 0x6C0EBBF7 */ +var _t13 = -Float64FromFloat64(0.00031275416837512086) /* 0xBF347F24, 0xECC38C38 */ +var _t14 = float64(0.0003355291926355191) /* 0x3F35FD3E, 0xE8C2D3F4 */ +var _u0 = -Float64FromFloat64(0.07721566490153287) /* 0xBFB3C467, 0xE37DB0C8 */ +var _u1 = float64(0.6328270640250934) /* 0x3FE4401E, 0x8B005DFF */ +var _u2 = float64(1.4549225013723477) /* 0x3FF7475C, 0xD119BD6F */ +var _u3 = float64(0.9777175279633727) /* 0x3FEF4976, 0x44EA8450 */ +var _u4 = float64(0.22896372806469245) /* 0x3FCD4EAE, 0xF6010924 */ +var _u5 = float64(0.013381091853678766) /* 0x3F8B678B, 0xBF2BAB09 */ +var _v1 = float64(2.4559779371304113) /* 0x4003A5D7, 0xC2BD619C */ +var _v2 = float64(2.128489763798934) /* 0x40010725, 0xA42B18F5 */ +var _v3 = float64(0.7692851504566728) /* 0x3FE89DFB, 0xE45050AF */ +var _v4 = float64(0.10422264559336913) /* 0x3FBAAE55, 0xD6537C88 */ +var _v5 = float64(0.003217092422824239) /* 0x3F6A5ABB, 0x57D0CF61 */ +var _s0 = -Float64FromFloat64(0.07721566490153287) /* 0xBFB3C467, 0xE37DB0C8 */ +var _s1 = float64(0.21498241596060885) /* 0x3FCB848B, 0x36E20878 */ +var _s2 = float64(0.325778796408931) /* 0x3FD4D98F, 0x4F139F59 */ +var _s3 = float64(0.14635047265246445) /* 0x3FC2BB9C, 0xBEE5F2F7 */ +var _s4 = float64(0.02664227030336386) /* 0x3F9B481C, 0x7E939961 */ +var _s5 = float64(0.0018402845140733772) /* 0x3F5E26B6, 0x7368F239 */ +var _s6 = float64(3.194753265841009e-05) /* 0x3F00BFEC, 0xDD17E945 */ +var _r1 = float64(1.3920053346762105) /* 0x3FF645A7, 0x62C4AB74 */ +var _r2 = float64(0.7219355475671381) /* 0x3FE71A18, 0x93D3DCDC */ +var _r3 = float64(0.17193386563280308) /* 0x3FC601ED, 0xCCFBDF27 */ +var _r4 = float64(0.01864591917156529) /* 0x3F9317EA, 0x742ED475 */ +var _r5 = float64(0.0007779424963818936) /* 0x3F497DDA, 0xCA41A95B */ +var _r6 = float64(7.326684307446256e-06) /* 0x3EDEBAF7, 0xA5B38140 */ +var _w0 = float64(0.4189385332046727) /* 0x3FDACFE3, 0x90C97D69 */ +var _w1 = float64(0.08333333333333297) /* 0x3FB55555, 0x5555553B */ +var _w2 = -Float64FromFloat64(0.0027777777772877554) /* 0xBF66C16C, 0x16B02E5C */ +var _w3 = float64(0.0007936505586430196) /* 0x3F4A019F, 0x98CF38B6 */ +var _w4 = -Float64FromFloat64(0.00059518755745034) /* 0xBF4380CB, 0x8C0FE741 */ +var _w5 = float64(0.0008363399189962821) /* 0x3F4B67BA, 0x4CDAD5D1 */ +var _w6 = -Float64FromFloat64(0.0016309293409657527) /* 0xBF5AB89D, 0x0B9E43E4 */ + +// C documentation +// +// /* sin(pi*x) assuming x > 2^-100, if sin(pi*x)==0 the sign is arbitrary */ +func _sin_pi(tls *TLS, x float64) (r float64) { + var n int32 + _ = n + /* spurious inexact if odd int */ + x = float64(float64(2) * (float64(x*float64(0.5)) - Xfloor(tls, float64(x*float64(0.5))))) /* x mod 2.0 */ + n = int32(float64(x * Float64FromFloat64(4))) + n = (n + int32(1)) / int32(2) + x = x - float64(float32(n)*Float32FromFloat32(0.5)) + x = x * _pi2 + switch n { + default: /* case 4: */ + fallthrough + case 0: + return X__sin(tls, x, float64(0), 0) + case int32(1): + return X__cos(tls, x, float64(0)) + case int32(2): + return X__sin(tls, -x, float64(0), 0) + case int32(3): + return -X__cos(tls, x, float64(0)) + } + return r +} + +func X__lgamma_r(tls *TLS, x float64, signgamp uintptr) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v signgamp=%v, (%v:)", tls, x, signgamp, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, sign int32 + var ix Tuint32_t + var nadj, p, p1, p2, p3, q, r, t, w, y, z Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, ix, nadj, p, p1, p2, p3, q, r, sign, t, w, y, z + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + /* purge off +-inf, NaN, +-0, tiny and negative arguments */ + **(**int32)(__ccgo_up(signgamp)) = int32(1) + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if ix >= uint32(0x7ff00000) { + return float64(x * x) + } + if ix < Uint32FromInt32((Int32FromInt32(0x3ff)-Int32FromInt32(70))< float64(0) { + **(**int32)(__ccgo_up(signgamp)) = -int32(1) + } else { + t = -t + } + nadj = Xlog(tls, _pi2/Tdouble_t(t*x)) + } + /* purge off 1 and 2 */ + if (ix == uint32(0x3ff00000) || ix == uint32(0x40000000)) && uint32(*(*Tuint64_t)(unsafe.Pointer(bp))) == uint32(0) { + r = Float64FromInt32(0) + } else { + if ix < uint32(0x40000000) { + if ix <= uint32(0x3feccccc) { /* lgamma(x) = lgamma(x+1)-log(x) */ + r = -Xlog(tls, x) + if ix >= uint32(0x3FE76944) { + y = float64(1) - x + i = 0 + } else { + if ix >= uint32(0x3FCDA661) { + y = x - (_tc - Float64FromFloat64(1)) + i = int32(1) + } else { + y = x + i = int32(2) + } + } + } else { + r = float64(0) + if ix >= uint32(0x3FFBB4C3) { /* [1.7316,2] */ + y = float64(2) - x + i = 0 + } else { + if ix >= uint32(0x3FF3B4C4) { /* [1.23,1.73] */ + y = x - _tc + i = int32(1) + } else { + y = x - float64(1) + i = int32(2) + } + } + } + switch i { + case 0: + z = Tdouble_t(y * y) + p1 = _a0 + float64(z*(_a2+float64(z*(_a4+float64(z*(_a6+float64(z*(_a8+float64(z*_a10))))))))) + p2 = Tdouble_t(z * (_a1 + float64(z*(_a3+float64(z*(_a5+float64(z*(_a7+float64(z*(_a9+float64(z*_a11))))))))))) + p = Tdouble_t(y*p1) + p2 + r = r + (p - Tdouble_t(float64(0.5)*y)) + case int32(1): + z = Tdouble_t(y * y) + w = Tdouble_t(z * y) + p1 = _t0 + float64(w*(_t3+float64(w*(_t6+float64(w*(_t9+float64(w*_t12))))))) /* parallel comp */ + p2 = _t1 + float64(w*(_t4+float64(w*(_t7+float64(w*(_t10+float64(w*_t13))))))) + p3 = _t2 + float64(w*(_t5+float64(w*(_t8+float64(w*(_t11+float64(w*_t14))))))) + p = Tdouble_t(z*p1) - (_tt - float64(w*(p2+Tdouble_t(y*p3)))) + r = r + (_tf + p) + case int32(2): + p1 = Tdouble_t(y * (_u0 + float64(y*(_u1+float64(y*(_u2+float64(y*(_u3+float64(y*(_u4+float64(y*_u5))))))))))) + p2 = float64(1) + float64(y*(_v1+float64(y*(_v2+float64(y*(_v3+float64(y*(_v4+float64(y*_v5))))))))) + r = r + (float64(-Float64FromFloat64(0.5)*y) + p1/p2) + } + } else { + if ix < uint32(0x40200000) { /* x < 8.0 */ + i = int32(x) + y = x - float64(i) + p = Tdouble_t(y * (_s0 + float64(y*(_s1+float64(y*(_s2+float64(y*(_s3+float64(y*(_s4+float64(y*(_s5+float64(y*_s6))))))))))))) + q = float64(1) + float64(y*(_r1+float64(y*(_r2+float64(y*(_r3+float64(y*(_r4+float64(y*(_r5+float64(y*_r6))))))))))) + r = float64(float64(0.5)*y) + p/q + z = float64(1) /* lgamma(1+s) = log(s) + lgamma(s) */ + switch i { + case int32(7): + z = z * (y + float64(6)) /* FALLTHRU */ + fallthrough + case int32(6): + z = z * (y + float64(5)) /* FALLTHRU */ + fallthrough + case int32(5): + z = z * (y + float64(4)) /* FALLTHRU */ + fallthrough + case int32(4): + z = z * (y + float64(3)) /* FALLTHRU */ + fallthrough + case int32(3): + z = z * (y + float64(2)) /* FALLTHRU */ + r = r + Xlog(tls, z) + break + } + } else { + if ix < uint32(0x43900000) { /* 8.0 <= x < 2**58 */ + t = Xlog(tls, x) + z = float64(1) / x + y = Tdouble_t(z * z) + w = _w0 + float64(z*(_w1+float64(y*(_w2+float64(y*(_w3+float64(y*(_w4+float64(y*(_w5+float64(y*_w6))))))))))) + r = float64((x-float64(0.5))*(t-Float64FromFloat64(1))) + w + } else { /* 2**58 <= x <= inf */ + r = Tdouble_t(x * (Xlog(tls, x) - float64(1))) + } + } + } + } + if sign != 0 { + r = nadj - r + } + return r +} + +func Xlgamma_r(tls *TLS, x float64, signgamp uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v signgamp=%v, (%v:)", tls, x, signgamp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgamma_r(tls, x, signgamp) +} + +func Xlgammaf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgammaf_r(tls, x, uintptr(unsafe.Pointer(&Xsigngam))) +} + +var _pi3 = float32(3.141592741) /* 0x40490fdb */ +var _a01 = float32(0.077215664089) /* 0x3d9e233f */ +var _a12 = float32(0.32246702909) /* 0x3ea51a66 */ +var _a21 = float32(0.067352302372) /* 0x3d89f001 */ +var _a31 = float32(0.020580807701) /* 0x3ca89915 */ +var _a41 = float32(0.0073855509982) /* 0x3bf2027e */ +var _a51 = float32(0.0028905137442) /* 0x3b3d6ec6 */ +var _a61 = float32(0.0011927076848) /* 0x3a9c54a1 */ +var _a71 = float32(0.00051006977446) /* 0x3a05b634 */ +var _a81 = float32(0.00022086278477) /* 0x39679767 */ +var _a91 = float32(0.00010801156895) /* 0x38e28445 */ +var _a101 = float32(2.52144564e-05) /* 0x37d383a2 */ +var _a111 = float32(4.4864096708e-05) /* 0x383c2c75 */ +var _tc1 = float32(1.4616321325) /* 0x3fbb16c3 */ +var _tf1 = float32(-Float64FromFloat64(0.12148628384)) /* 0xbdf8cdcd */ +/* tt = -(tail of tf) */ +var _tt1 = float32(6.6971006518e-09) /* 0x31e61c52 */ +var _t01 = float32(0.48383611441) /* 0x3ef7b95e */ +var _t15 = float32(-Float64FromFloat64(0.14758771658)) /* 0xbe17213c */ +var _t21 = float32(0.064624942839) /* 0x3d845a15 */ +var _t31 = float32(-Float64FromFloat64(0.032788541168)) /* 0xbd064d47 */ +var _t41 = float32(0.017970675603) /* 0x3c93373d */ +var _t51 = float32(-Float64FromFloat64(0.010314224288)) /* 0xbc28fcfe */ +var _t61 = float32(0.0061005386524) /* 0x3bc7e707 */ +var _t71 = float32(-Float64FromFloat64(0.0036845202558)) /* 0xbb7177fe */ +var _t81 = float32(0.0022596477065) /* 0x3b141699 */ +var _t91 = float32(-Float64FromFloat64(0.0014034647029)) /* 0xbab7f476 */ +var _t101 = float32(0.00088108185446) /* 0x3a66f867 */ +var _t111 = float32(-Float64FromFloat64(0.00053859531181)) /* 0xba0d3085 */ +var _t121 = float32(0.00031563205994) /* 0x39a57b6b */ +var _t131 = float32(-Float64FromFloat64(0.00031275415677)) /* 0xb9a3f927 */ +var _t141 = float32(0.00033552918467) /* 0x39afe9f7 */ +var _u07 = float32(-Float64FromFloat64(0.077215664089)) /* 0xbd9e233f */ +var _u11 = float32(0.63282704353) /* 0x3f2200f4 */ +var _u21 = float32(1.4549225569) /* 0x3fba3ae7 */ +var _u31 = float32(0.97771751881) /* 0x3f7a4bb2 */ +var _u41 = float32(0.22896373272) /* 0x3e6a7578 */ +var _u51 = float32(0.013381091878) /* 0x3c5b3c5e */ +var _v11 = float32(2.4559779167) /* 0x401d2ebe */ +var _v21 = float32(2.1284897327) /* 0x4008392d */ +var _v31 = float32(0.76928514242) /* 0x3f44efdf */ +var _v41 = float32(0.10422264785) /* 0x3dd572af */ +var _v51 = float32(0.0032170924824) /* 0x3b52d5db */ +var _s06 = float32(-Float64FromFloat64(0.077215664089)) /* 0xbd9e233f */ +var _s11 = float32(0.21498242021) /* 0x3e5c245a */ +var _s21 = float32(0.32577878237) /* 0x3ea6cc7a */ +var _s31 = float32(0.14635047317) /* 0x3e15dce6 */ +var _s41 = float32(0.026642270386) /* 0x3cda40e4 */ +var _s51 = float32(0.0018402845599) /* 0x3af135b4 */ +var _s61 = float32(3.1947532989e-05) /* 0x3805ff67 */ +var _r11 = float32(1.3920053244) /* 0x3fb22d3b */ +var _r21 = float32(0.72193557024) /* 0x3f38d0c5 */ +var _r31 = float32(0.17193385959) /* 0x3e300f6e */ +var _r41 = float32(0.018645919859) /* 0x3c98bf54 */ +var _r51 = float32(0.00077794247773) /* 0x3a4beed6 */ +var _r61 = float32(7.3266842264e-06) /* 0x36f5d7bd */ +var _w01 = float32(0.41893854737) /* 0x3ed67f1d */ +var _w11 = float32(0.083333335817) /* 0x3daaaaab */ +var _w21 = float32(-Float64FromFloat64(0.002777777845)) /* 0xbb360b61 */ +var _w31 = float32(0.00079365057172) /* 0x3a500cfd */ +var _w41 = float32(-Float64FromFloat64(0.00059518753551)) /* 0xba1c065c */ +var _w51 = float32(0.00083633989561) /* 0x3a5b3dd2 */ +var _w61 = float32(-Float64FromFloat64(0.0016309292987)) /* 0xbad5c4e8 */ + +// C documentation +// +// /* sin(pi*x) assuming x > 2^-100, if sin(pi*x)==0 the sign is arbitrary */ +func _sin_pi1(tls *TLS, x float32) (r float32) { + var n int32 + var y Tdouble_t + _, _ = n, y + /* spurious inexact if odd int */ + x = float32(Float32FromInt32(2) * (float32(x*Float32FromFloat32(0.5)) - Xfloorf(tls, float32(x*Float32FromFloat32(0.5))))) /* x mod 2.0 */ + n = int32(float32(x * Float32FromInt32(4))) + n = (n + int32(1)) / int32(2) + y = float64(x - float32(float32(n)*Float32FromFloat32(0.5))) + y = y * float64(3.141592653589793) + switch n { + default: /* case 4: */ + fallthrough + case 0: + return X__sindf(tls, y) + case int32(1): + return X__cosdf(tls, y) + case int32(2): + return X__sindf(tls, -y) + case int32(3): + return -X__cosdf(tls, y) + } + return r +} + +func X__lgammaf_r(tls *TLS, x float32, signgamp uintptr) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v signgamp=%v, (%v:)", tls, x, signgamp, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, sign int32 + var ix Tuint32_t + var nadj, p, p1, p2, p3, q, r, t, w, y, z float32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, ix, nadj, p, p1, p2, p3, q, r, sign, t, w, y, z + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + /* purge off +-inf, NaN, +-0, tiny and negative arguments */ + **(**int32)(__ccgo_up(signgamp)) = int32(1) + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + if ix >= uint32(0x7f800000) { + return float32(x * x) + } + if ix < uint32(0x35000000) { /* |x| < 2**-21, return -log(|x|) */ + if sign != 0 { + **(**int32)(__ccgo_up(signgamp)) = -int32(1) + x = -x + } + return -Xlogf(tls, x) + } + if sign != 0 { + x = -x + t = _sin_pi1(tls, x) + if t == Float32FromFloat32(0) { /* -integer */ + return Float32FromFloat32(1) / (x - x) + } + if t > Float32FromFloat32(0) { + **(**int32)(__ccgo_up(signgamp)) = -int32(1) + } else { + t = -t + } + nadj = Xlogf(tls, _pi3/float32(t*x)) + } + /* purge off 1 and 2 */ + if ix == uint32(0x3f800000) || ix == uint32(0x40000000) { + r = Float32FromInt32(0) + } else { + if ix < uint32(0x40000000) { + if ix <= uint32(0x3f666666) { /* lgamma(x) = lgamma(x+1)-log(x) */ + r = -Xlogf(tls, x) + if ix >= uint32(0x3f3b4a20) { + y = Float32FromFloat32(1) - x + i = 0 + } else { + if ix >= uint32(0x3e6d3308) { + y = x - (_tc1 - Float32FromFloat32(1)) + i = int32(1) + } else { + y = x + i = int32(2) + } + } + } else { + r = Float32FromFloat32(0) + if ix >= uint32(0x3fdda618) { /* [1.7316,2] */ + y = Float32FromFloat32(2) - x + i = 0 + } else { + if ix >= uint32(0x3F9da620) { /* [1.23,1.73] */ + y = x - _tc1 + i = int32(1) + } else { + y = x - Float32FromFloat32(1) + i = int32(2) + } + } + } + switch i { + case 0: + z = float32(y * y) + p1 = _a01 + float32(z*(_a21+float32(z*(_a41+float32(z*(_a61+float32(z*(_a81+float32(z*_a101))))))))) + p2 = float32(z * (_a12 + float32(z*(_a31+float32(z*(_a51+float32(z*(_a71+float32(z*(_a91+float32(z*_a111))))))))))) + p = float32(y*p1) + p2 + r = r + (p - float32(Float32FromFloat32(0.5)*y)) + case int32(1): + z = float32(y * y) + w = float32(z * y) + p1 = _t01 + float32(w*(_t31+float32(w*(_t61+float32(w*(_t91+float32(w*_t121))))))) /* parallel comp */ + p2 = _t15 + float32(w*(_t41+float32(w*(_t71+float32(w*(_t101+float32(w*_t131))))))) + p3 = _t21 + float32(w*(_t51+float32(w*(_t81+float32(w*(_t111+float32(w*_t141))))))) + p = float32(z*p1) - (_tt1 - float32(w*(p2+float32(y*p3)))) + r = r + (_tf1 + p) + case int32(2): + p1 = float32(y * (_u07 + float32(y*(_u11+float32(y*(_u21+float32(y*(_u31+float32(y*(_u41+float32(y*_u51))))))))))) + p2 = Float32FromFloat32(1) + float32(y*(_v11+float32(y*(_v21+float32(y*(_v31+float32(y*(_v41+float32(y*_v51))))))))) + r = r + (float32(-Float32FromFloat32(0.5)*y) + p1/p2) + } + } else { + if ix < uint32(0x41000000) { /* x < 8.0 */ + i = int32(x) + y = x - float32(i) + p = float32(y * (_s06 + float32(y*(_s11+float32(y*(_s21+float32(y*(_s31+float32(y*(_s41+float32(y*(_s51+float32(y*_s61))))))))))))) + q = Float32FromFloat32(1) + float32(y*(_r11+float32(y*(_r21+float32(y*(_r31+float32(y*(_r41+float32(y*(_r51+float32(y*_r61))))))))))) + r = float32(Float32FromFloat32(0.5)*y) + p/q + z = Float32FromFloat32(1) /* lgamma(1+s) = log(s) + lgamma(s) */ + switch i { + case int32(7): + z = z * (y + Float32FromFloat32(6)) /* FALLTHRU */ + fallthrough + case int32(6): + z = z * (y + Float32FromFloat32(5)) /* FALLTHRU */ + fallthrough + case int32(5): + z = z * (y + Float32FromFloat32(4)) /* FALLTHRU */ + fallthrough + case int32(4): + z = z * (y + Float32FromFloat32(3)) /* FALLTHRU */ + fallthrough + case int32(3): + z = z * (y + Float32FromFloat32(2)) /* FALLTHRU */ + r = r + Xlogf(tls, z) + break + } + } else { + if ix < uint32(0x5c800000) { /* 8.0 <= x < 2**58 */ + t = Xlogf(tls, x) + z = Float32FromFloat32(1) / x + y = float32(z * z) + w = _w01 + float32(z*(_w11+float32(y*(_w21+float32(y*(_w31+float32(y*(_w41+float32(y*(_w51+float32(y*_w61))))))))))) + r = float32((x-Float32FromFloat32(0.5))*(t-Float32FromFloat32(1))) + w + } else { /* 2**58 <= x <= inf */ + r = float32(x * (Xlogf(tls, x) - Float32FromFloat32(1))) + } + } + } + } + if sign != 0 { + r = nadj - r + } + return r +} + +func Xlgammaf_r(tls *TLS, x float32, signgamp uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v signgamp=%v, (%v:)", tls, x, signgamp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgammaf_r(tls, x, signgamp) +} + +func X__lgammal_r(tls *TLS, x float64, sg uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v sg=%v, (%v:)", tls, x, sg, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgamma_r(tls, x, sg) +} + +func Xlgammal(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgammal_r(tls, x, uintptr(unsafe.Pointer(&Xsigngam))) +} + +func Xlgammal_r(tls *TLS, x float64, sg uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v sg=%v, (%v:)", tls, x, sg, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lgammal_r(tls, x, sg) +} + +/* uses LLONG_MAX > 2^53, see comments in lrint.c */ + +func Xllrint(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xrint(tls, x)) +} + +/* uses LLONG_MAX > 2^24, see comments in lrint.c */ + +func Xllrintf(tls *TLS, x float32) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xrintf(tls, x)) +} + +func Xllrintl(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xllrint(tls, x) +} + +func Xllround(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xround(tls, x)) +} + +func Xllroundf(tls *TLS, x float32) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xroundf(tls, x)) +} + +func Xllroundl(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xroundl(tls, x)) +} + +const LOG_POLY1_ORDER = 12 +const LOG_POLY_ORDER = 6 +const LOG_TABLE_BITS = 7 +const N4 = 128 +const OFF = 4604367669032910848 + +// C documentation +// +// /* Top 16 bits of a double. */ +func _top16(tls *TLS, x float64) (r Tuint32_t) { + return uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(48)) +} + +func Xlog(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var hi, invc, kd, lo, logc, r, r2, r3, rhi, rlo, w, y1, z Tdouble_t + var i, k int32 + var ix, iz, tmp Tuint64_t + var top Tuint32_t + var y, v1, v2, v3, v4 float64 + var v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = hi, i, invc, ix, iz, k, kd, lo, logc, r, r2, r3, rhi, rlo, tmp, top, w, y, y1, z, v1, v2, v3, v4, v5 + ix = *(*Tuint64_t)(unsafe.Pointer(&x1)) + top = _top16(tls, x1) + v1 = Float64FromFloat64(1) - Float64FromFloat64(0.0625) + v2 = Float64FromFloat64(1) + Float64FromFloat64(0.064697265625) + v3 = Float64FromFloat64(1) - Float64FromFloat64(0.0625) + if ix-*(*Tuint64_t)(unsafe.Pointer(&v1)) < *(*Tuint64_t)(unsafe.Pointer(&v2))-*(*Tuint64_t)(unsafe.Pointer(&v3)) { + /* Handle close to 1.0 inputs separately. */ + /* Fix sign of zero with downward rounding when x==1. */ + if v5 = Bool(int32(WANT_ROUNDING) != 0); v5 { + v4 = float64(1) + } + if v5 && ix == *(*Tuint64_t)(unsafe.Pointer(&v4)) { + return Float64FromInt32(0) + } + r = x1 - float64(1) + r2 = Tdouble_t(r * r) + r3 = Tdouble_t(r * r2) + y1 = Tdouble_t(r3 * (**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 1*8)) + float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 2*8))) + float64(r2***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 3*8))) + float64(r3*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 4*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 5*8)))+float64(r2***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 6*8)))+float64(r3*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 7*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 8*8)))+float64(r2***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 9*8)))+float64(r3***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56 + 10*8))))))))) + /* Worst-case error is around 0.507 ULP. */ + w = Tdouble_t(r * float64(1.34217728e+08)) + rhi = r + w - w + rlo = r - rhi + w = Tdouble_t(Tdouble_t(rhi*rhi) * **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56))) /* B[0] == -0.5. */ + hi = r + w + lo = r - hi + w + lo = lo + Tdouble_t(float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 56))*rlo)*(rhi+r)) + y1 = y1 + lo + y1 = y1 + hi + y = y1 + v1 = y + goto _7 + _7: + return v1 + } + if top-uint32(0x0010) >= Uint32FromInt32(Int32FromInt32(0x7ff0)-Int32FromInt32(0x0010)) { + /* x < 0x1p-1022 or inf or nan. */ + if ix*uint64(2) == uint64(0) { + return X__math_divzero(tls, uint32(1)) + } + v1 = float64(X__builtin_inff(tls)) + if ix == *(*Tuint64_t)(unsafe.Pointer(&v1)) { /* log(inf) == inf. */ + return x1 + } + if top&uint32(0x8000) != 0 || top&uint32(0x7ff0) == uint32(0x7ff0) { + return X__math_invalid(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float64(x1 * float64(4.503599627370496e+15)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + ix = uint64(ix - Uint64FromUint64(52)<> (Int32FromInt32(52) - Int32FromInt32(LOG_TABLE_BITS)) % Uint64FromInt32(Int32FromInt32(1)<> int32(52)) /* arithmetic shift */ + iz = uint64(ix - tmp&(Uint64FromUint64(0xfff)< 0x1p-5: + 0.5 + 4.13/N + abs-poly-error*2^57 ULP (+ 0.002 ULP without fma) + Worst case error if |y| > 0x1p-4: + 0.5 + 2.06/N + abs-poly-error*2^56 ULP (+ 0.001 ULP without fma). */ + y1 = lo + Tdouble_t(r2***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16))) + Tdouble_t(Tdouble_t(r*r2)*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16 + 1*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16 + 2*8)))+float64(r2*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16 + 3*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log_data)) + 16 + 4*8))))))) + hi + y = y1 + v1 = y + goto _11 +_11: + return v1 +} + +var _ivln10hi = float64(0.4342944818781689) /* 0x3fdbcb7b, 0x15200000 */ +var _ivln10lo = float64(2.5082946711645275e-11) /* 0x3dbb9438, 0xca9aadd5 */ +var _log10_2hi = float64(0.30102999566361177) /* 0x3FD34413, 0x509F6000 */ +var _log10_2lo = float64(3.694239077158931e-13) /* 0x3D59FEF3, 0x11F12B36 */ +var _Lg1 = float64(0.6666666666666735) /* 3FE55555 55555593 */ +var _Lg2 = float64(0.3999999999940942) /* 3FD99999 9997FA04 */ +var _Lg3 = float64(0.2857142874366239) /* 3FD24924 94229359 */ +var _Lg4 = float64(0.22222198432149784) /* 3FCC71C5 1D8E78AF */ +var _Lg5 = float64(0.1818357216161805) /* 3FC74664 96CB03DE */ +var _Lg6 = float64(0.15313837699209373) /* 3FC39A09 D078C69F */ +var _Lg7 = float64(0.14798198605116586) /* 3FC2F112 DF3E5244 */ + +func Xlog10(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, dk, f, hfsq, hi, lo, s, t1, t2, val_hi, val_lo, w, y, z Tdouble_t + var hx Tuint32_t + var k int32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, dk, f, hfsq, hi, hx, k, lo, s, t1, t2, val_hi, val_lo, w, y, z + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + k = 0 + if hx < uint32(0x00100000) || hx>>int32(31) != 0 { + if *(*Tuint64_t)(unsafe.Pointer(bp))<>int32(31) != 0 { + return (x - x) / float64(0) + } /* log(-#) = NaN */ + /* subnormal number, scale x up */ + k = k - int32(54) + x = x * float64(1.8014398509481984e+16) + *(*float64)(unsafe.Pointer(bp)) = x + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + } else { + if hx >= uint32(0x7ff00000) { + return x + } else { + if hx == uint32(0x3ff00000) && *(*Tuint64_t)(unsafe.Pointer(bp))<>Int32FromInt32(20)) - int32(0x3ff)) + hx = hx&uint32(0x000fffff) + uint32(0x3fe6a09e) + *(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(hx)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, dk, f, hfsq, hi, lo, s, t1, t2, w, z Tfloat_t + var ix Tuint32_t + var k int32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _ = R, dk, f, hfsq, hi, ix, k, lo, s, t1, t2, w, z + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) + k = 0 + if ix < uint32(0x00800000) || ix>>int32(31) != 0 { /* x < 2**-126 */ + if ix<>int32(31) != 0 { + return (x - x) / Float32FromFloat32(0) + } /* log(-#) = NaN */ + /* subnormal number, scale up x */ + k = k - int32(25) + x = x * Float32FromFloat32(3.3554432e+07) + *(*float32)(unsafe.Pointer(bp)) = x + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) + } else { + if ix >= uint32(0x7f800000) { + return x + } else { + if ix == uint32(0x3f800000) { + return Float32FromInt32(0) + } + } + } + /* reduce x into [sqrt(2)/2, sqrt(2)] */ + ix = ix + Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(0x3f3504f3)) + k = k + (Int32FromUint32(ix>>Int32FromInt32(23)) - int32(0x7f)) + ix = ix&uint32(0x007fffff) + uint32(0x3f3504f3) + *(*Tuint32_t)(unsafe.Pointer(bp)) = ix + x = *(*float32)(unsafe.Pointer(bp)) + f = x - Float32FromFloat32(1) + s = f / (Float32FromFloat32(2) + f) + z = Tfloat_t(s * s) + w = Tfloat_t(z * z) + t1 = Tfloat_t(w * (_Lg21 + float32(w*_Lg41))) + t2 = Tfloat_t(z * (_Lg11 + float32(w*_Lg31))) + R = t2 + t1 + hfsq = Tfloat_t(float32(Float32FromFloat32(0.5)*f) * f) + hi = f - hfsq + *(*float32)(unsafe.Pointer(bp)) = hi + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0xfffff000) + hi = *(*float32)(unsafe.Pointer(bp)) + lo = f - hi - hfsq + Tfloat_t(s*(hfsq+R)) + dk = float32(k) + return Tfloat_t(dk*_log10_2lo1) + Tfloat_t((lo+hi)*_ivln10lo1) + Tfloat_t(lo*_ivln10hi1) + Tfloat_t(hi*_ivln10hi1) + Tfloat_t(dk*_log10_2hi1) +} + +func Xlog10l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog10(tls, x) +} + +var _ln2_hi2 = float64(0.6931471803691238) /* 3fe62e42 fee00000 */ +var _ln2_lo2 = float64(1.9082149292705877e-10) /* 3dea39ef 35793c76 */ +var _Lg12 = float64(0.6666666666666735) /* 3FE55555 55555593 */ +var _Lg22 = float64(0.3999999999940942) /* 3FD99999 9997FA04 */ +var _Lg32 = float64(0.2857142874366239) /* 3FD24924 94229359 */ +var _Lg42 = float64(0.22222198432149784) /* 3FCC71C5 1D8E78AF */ +var _Lg51 = float64(0.1818357216161805) /* 3FC74664 96CB03DE */ +var _Lg61 = float64(0.15313837699209373) /* 3FC39A09 D078C69F */ +var _Lg71 = float64(0.14798198605116586) /* 3FC2F112 DF3E5244 */ + +func Xlog1p(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, c, dk, f, hfsq, s, t1, t2, w, z Tdouble_t + var hu, hx Tuint32_t + var k int32 + var y float32 + var y1, y2, v1 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, c, dk, f, hfsq, hu, hx, k, s, t1, t2, w, y, y1, y2, z, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + k = int32(1) + if hx < uint32(0x3fda827a) || hx>>int32(31) != 0 { /* 1+x < sqrt(2)+ */ + if hx >= uint32(0xbff00000) { /* x <= -1.0 */ + if x3 == float64(-Int32FromInt32(1)) { + return x3 / float64(0) + } /* log1p(-1) = -inf */ + return (x3 - x3) / float64(0) /* log1p(x<-1) = NaN */ + } + if hx<= uint32(0x7ff00000) { + return x3 + } + } + if k != 0 { + *(*float64)(unsafe.Pointer(bp)) = Float64FromInt32(1) + x3 + hu = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + hu = hu + Uint32FromInt32(Int32FromInt32(0x3ff00000)-Int32FromInt32(0x3fe6a09e)) + k = Int32FromUint32(hu>>Int32FromInt32(20)) - int32(0x3ff) + /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ + if k < int32(54) { + if k >= int32(2) { + v1 = Float64FromInt32(1) - (*(*float64)(unsafe.Pointer(bp)) - x3) + } else { + v1 = x3 - (*(*float64)(unsafe.Pointer(bp)) - Float64FromInt32(1)) + } + c = v1 + c = c / *(*float64)(unsafe.Pointer(bp)) + } else { + c = Float64FromInt32(0) + } + /* reduce u into [sqrt(2)/2, sqrt(2)] */ + hu = hu&uint32(0x000fffff) + uint32(0x3fe6a09e) + *(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(hu)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, c, dk, f, hfsq, s, t1, t2, w, z Tfloat_t + var iu, ix Tuint32_t + var k int32 + var y, v1 float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, c, dk, f, hfsq, iu, ix, k, s, t1, t2, w, y, y1, y2, z, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) + k = int32(1) + if ix < uint32(0x3ed413d0) || ix>>int32(31) != 0 { /* 1+x < sqrt(2)+ */ + if ix >= uint32(0xbf800000) { /* x <= -1.0 */ + if x3 == float32(-Int32FromInt32(1)) { + return x3 / Float32FromFloat32(0) + } /* log1p(-1)=+inf */ + return (x3 - x3) / Float32FromFloat32(0) /* log1p(x<-1)=NaN */ + } + if ix<= uint32(0x7f800000) { + return x3 + } + } + if k != 0 { + *(*float32)(unsafe.Pointer(bp)) = Float32FromInt32(1) + x3 + iu = *(*Tuint32_t)(unsafe.Pointer(bp)) + iu = iu + Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(0x3f3504f3)) + k = Int32FromUint32(iu>>Int32FromInt32(23)) - int32(0x7f) + /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ + if k < int32(25) { + if k >= int32(2) { + v1 = Float32FromInt32(1) - (*(*float32)(unsafe.Pointer(bp)) - x3) + } else { + v1 = x3 - (*(*float32)(unsafe.Pointer(bp)) - Float32FromInt32(1)) + } + c = v1 + c = c / *(*float32)(unsafe.Pointer(bp)) + } else { + c = Float32FromInt32(0) + } + /* reduce u into [sqrt(2)/2, sqrt(2)] */ + iu = iu&uint32(0x007fffff) + uint32(0x3f3504f3) + *(*Tuint32_t)(unsafe.Pointer(bp)) = iu + f = *(*float32)(unsafe.Pointer(bp)) - Float32FromInt32(1) + } + s = f / (Float32FromFloat32(2) + f) + z = Tfloat_t(s * s) + w = Tfloat_t(z * z) + t1 = Tfloat_t(w * (_Lg23 + float32(w*_Lg43))) + t2 = Tfloat_t(z * (_Lg13 + float32(w*_Lg33))) + R = t2 + t1 + hfsq = Tfloat_t(float32(Float32FromFloat32(0.5)*f) * f) + dk = float32(k) + return Tfloat_t(s*(hfsq+R)) + (Tfloat_t(dk*_ln2_lo3) + c) - hfsq + f + Tfloat_t(dk*_ln2_hi3) +} + +func Xlog1pl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog1p(tls, x) +} + +const LOG2_POLY1_ORDER = 11 +const LOG2_POLY_ORDER = 7 +const LOG2_TABLE_BITS = 6 +const N5 = 64 + +// C documentation +// +// /* Top 16 bits of a double. */ +func _top161(tls *TLS, x float64) (r Tuint32_t) { + return uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(48)) +} + +func Xlog2(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var hi, invc, kd, lo, logc, p, r, r2, r4, t1, t2, t3, y1, z Tdouble_t + var i, k int32 + var ix, iz, tmp Tuint64_t + var top Tuint32_t + var y, v1, v2, v3, v4 float64 + var v5 bool + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = hi, i, invc, ix, iz, k, kd, lo, logc, p, r, r2, r4, t1, t2, t3, tmp, top, y, y1, z, v1, v2, v3, v4, v5 + ix = *(*Tuint64_t)(unsafe.Pointer(&x1)) + top = _top161(tls, x1) + v1 = Float64FromFloat64(1) - Float64FromFloat64(0.04239702224731445) + v2 = Float64FromFloat64(1) + Float64FromFloat64(0.044274330139160156) + v3 = Float64FromFloat64(1) - Float64FromFloat64(0.04239702224731445) + if ix-*(*Tuint64_t)(unsafe.Pointer(&v1)) < *(*Tuint64_t)(unsafe.Pointer(&v2))-*(*Tuint64_t)(unsafe.Pointer(&v3)) { + /* Handle close to 1.0 inputs separately. */ + /* Fix sign of zero with downward rounding when x==1. */ + if v5 = Bool(int32(WANT_ROUNDING) != 0); v5 { + v4 = float64(1) + } + if v5 && ix == *(*Tuint64_t)(unsafe.Pointer(&v4)) { + return Float64FromInt32(0) + } + r = x1 - float64(1) + hi = Tdouble_t(r * X__log2_data.Finvln2hi) + lo = Tdouble_t(r*X__log2_data.Finvln2lo) + float64(X__builtin_fma(tls, r, X__log2_data.Finvln2hi, -hi)) + r2 = Tdouble_t(r * r) /* rounding error: 0x1p-62. */ + r4 = Tdouble_t(r2 * r2) + /* Worst-case error is less than 0.54 ULP (0.55 ULP without fma). */ + p = Tdouble_t(r2 * (**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64)) + float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 1*8))))) + y1 = hi + p + lo = lo + (hi - y1 + p) + lo = lo + Tdouble_t(r4*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 2*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 3*8)))+float64(r2*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 4*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 5*8)))))+float64(r4*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 6*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 7*8)))+float64(r2*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 8*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 64 + 9*8))))))))) + y1 = y1 + lo + y = y1 + v1 = y + goto _7 + _7: + return v1 + } + if top-uint32(0x0010) >= Uint32FromInt32(Int32FromInt32(0x7ff0)-Int32FromInt32(0x0010)) { + /* x < 0x1p-1022 or inf or nan. */ + if ix*uint64(2) == uint64(0) { + return X__math_divzero(tls, uint32(1)) + } + v1 = float64(X__builtin_inff(tls)) + if ix == *(*Tuint64_t)(unsafe.Pointer(&v1)) { /* log(inf) == inf. */ + return x1 + } + if top&uint32(0x8000) != 0 || top&uint32(0x7ff0) == uint32(0x7ff0) { + return X__math_invalid(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float64(x1 * float64(4.503599627370496e+15)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + ix = uint64(ix - Uint64FromUint64(52)<> (Int32FromInt32(52) - Int32FromInt32(LOG2_TABLE_BITS)) % Uint64FromInt32(Int32FromInt32(1)<> int32(52)) /* arithmetic shift */ + iz = uint64(ix - tmp&(Uint64FromUint64(0xfff)< 0x1p-4: 0.547 ULP (0.550 ULP without fma). + ~ 0.5 + 2/N/ln2 + abs-poly-error*0x1p56 ULP (+ 0.003 ULP without fma). */ + p = **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16)) + float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 1*8))) + float64(r2*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 2*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 3*8))))) + float64(r4*(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 4*8))+float64(r***(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2_data)) + 16 + 5*8))))) + y1 = lo + Tdouble_t(r2*p) + hi + y = y1 + v1 = y + goto _11 +_11: + return v1 +} + +type Tlog2_data = struct { + Finvln2hi float64 + Finvln2lo float64 + Fpoly [6]float64 + Fpoly1 [10]float64 + Ftab [64]struct { + Finvc float64 + Flogc float64 + } +} + +const LOG2F_POLY_ORDER = 4 +const LOG2F_TABLE_BITS = 4 +const N6 = 16 +const OFF1 = 1060306944 + +/* +LOG2F_TABLE_BITS = 4 +LOG2F_POLY_ORDER = 4 + +ULP error: 0.752 (nearest rounding.) +Relative error: 1.9 * 2^-26 (before rounding.) +*/ + +func Xlog2f(tls *TLS, x1 float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var i, k int32 + var invc, logc, p, r, r2, y0, y1, z Tdouble_t + var ix, iz, tmp, top Tuint32_t + var y, v1 float32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, invc, ix, iz, k, logc, p, r, r2, tmp, top, y, y0, y1, z, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x1)) + /* Fix sign of zero with downward rounding when x==1. */ + if Bool(int32(WANT_ROUNDING) != 0) && ix == uint32(0x3f800000) { + return Float32FromInt32(0) + } + if ix-uint32(0x00800000) >= Uint32FromInt32(Int32FromInt32(0x7f800000)-Int32FromInt32(0x00800000)) { + /* x < 0x1p-126 or inf or nan. */ + if ix*uint32(2) == uint32(0) { + return X__math_divzerof(tls, uint32(1)) + } + if ix == uint32(0x7f800000) { /* log2(inf) == inf. */ + return x1 + } + if ix&uint32(0x80000000) != 0 || ix*uint32(2) >= uint32(0xff000000) { + return X__math_invalidf(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float32(x1 * Float32FromFloat32(8.388608e+06)) + ix = *(*Tuint32_t)(unsafe.Pointer(&v1)) + ix = ix - Uint32FromInt32(Int32FromInt32(23)<> (Int32FromInt32(23) - Int32FromInt32(LOG2F_TABLE_BITS)) % Uint32FromInt32(Int32FromInt32(1)<> int32(23) /* arithmetic shift */ + invc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + uintptr(i)*16))).Finvc + logc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + uintptr(i)*16))).Flogc + z = float64(*(*float32)(unsafe.Pointer(&iz))) + /* log2(x) = log1p(z/c-1)/ln2 + log2(c) + k */ + r = Tdouble_t(z*invc) - Float64FromInt32(1) + y0 = logc + float64(k) + /* Pipelined polynomial evaluation to approximate log1p(r)/ln2. */ + r2 = Tdouble_t(r * r) + y1 = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + 256 + 1*8))*r) + **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + 256 + 2*8)) + y1 = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + 256))*r2) + y1 + p = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__log2f_data)) + 256 + 3*8))*r) + y0 + y1 = Tdouble_t(y1*r2) + p + y = float32(y1) + v1 = y + goto _3 +_3: + return v1 +} + +type Tlog2f_data = struct { + Ftab [16]struct { + Finvc float64 + Flogc float64 + } + Fpoly [4]float64 +} + +func Xlog2l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog2(tls, x) +} + +const N7 = 128 + +type Tlog_data = struct { + Fln2hi float64 + Fln2lo float64 + Fpoly [5]float64 + Fpoly1 [11]float64 + Ftab [128]struct { + Finvc float64 + Flogc float64 + } +} + +/* +special cases: + logb(+-0) = -inf, and raise divbyzero + logb(+-inf) = +inf + logb(nan) = nan +*/ + +func Xlogb(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _ = v1 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if !(BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _ = v1 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if !(BoolInt32(v1&Uint32FromInt32(0x7fffffff) < Uint32FromInt32(0x7f800000)) != 0) { + return float32(x * x) + } + if x == Float32FromInt32(0) { + return float32(-Int32FromInt32(1)) / float32(x*x) + } + return float32(Xilogbf(tls, x)) +} + +func Xlogbl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _ = v1 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if !(BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< %v", r1) }() + } + var i, k int32 + var invc, logc, r, r2, y0, y1, z Tdouble_t + var ix, iz, tmp Tuint32_t + var y, v1 float32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = i, invc, ix, iz, k, logc, r, r2, tmp, y, y0, y1, z, v1 + ix = *(*Tuint32_t)(unsafe.Pointer(&x1)) + /* Fix sign of zero with downward rounding when x==1. */ + if Bool(int32(WANT_ROUNDING) != 0) && ix == uint32(0x3f800000) { + return Float32FromInt32(0) + } + if ix-uint32(0x00800000) >= Uint32FromInt32(Int32FromInt32(0x7f800000)-Int32FromInt32(0x00800000)) { + /* x < 0x1p-126 or inf or nan. */ + if ix*uint32(2) == uint32(0) { + return X__math_divzerof(tls, uint32(1)) + } + if ix == uint32(0x7f800000) { /* log(inf) == inf. */ + return x1 + } + if ix&uint32(0x80000000) != 0 || ix*uint32(2) >= uint32(0xff000000) { + return X__math_invalidf(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float32(x1 * Float32FromFloat32(8.388608e+06)) + ix = *(*Tuint32_t)(unsafe.Pointer(&v1)) + ix = ix - Uint32FromInt32(Int32FromInt32(23)<> (Int32FromInt32(23) - Int32FromInt32(LOGF_TABLE_BITS)) % Uint32FromInt32(Int32FromInt32(1)<> int32(23) /* arithmetic shift */ + iz = ix - tmp&uint32(0xff800000) + invc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + uintptr(i)*16))).Finvc + logc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + uintptr(i)*16))).Flogc + z = float64(*(*float32)(unsafe.Pointer(&iz))) + /* log(x) = log1p(z/c-1) + log(c) + k*Ln2 */ + r = Tdouble_t(z*invc) - Float64FromInt32(1) + y0 = logc + Tdouble_t(float64(k)*X__logf_data.Fln2) + /* Pipelined polynomial evaluation to approximate log1p(r). */ + r2 = Tdouble_t(r * r) + y1 = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + 264 + 1*8))*r) + **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + 264 + 2*8)) + y1 = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__logf_data)) + 264))*r2) + y1 + y1 = Tdouble_t(y1*r2) + (y0 + r) + y = float32(y1) + v1 = y + goto _3 +_3: + return v1 +} + +type Tlogf_data = struct { + Ftab [16]struct { + Finvc float64 + Flogc float64 + } + Fln2 float64 + Fpoly [3]float64 +} + +func Xlogl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog(tls, x) +} + +/* +If the result cannot be represented (overflow, nan), then +lrint raises the invalid exception. + +Otherwise if the input was not an integer then the inexact +exception is raised. + +C99 is a bit vague about whether inexact exception is +allowed to be raised when invalid is raised. +(F.9 explicitly allows spurious inexact exceptions, F.9.6.5 +does not make it clear if that rule applies to lrint, but +IEEE 754r 7.8 seems to forbid spurious inexact exception in +the ineger conversion functions) + +So we try to make sure that no spurious inexact exception is +raised in case of an overflow. + +If the bit size of long > precision of double, then there +cannot be inexact rounding in case the result overflows, +otherwise LONG_MAX and LONG_MIN can be represented exactly +as a double. +*/ + +func Xlrint(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xrint(tls, x)) +} + +/* uses LONG_MAX > 2^24, see comments in lrint.c */ + +func Xlrintf(tls *TLS, x float32) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xrintf(tls, x)) +} + +func Xlrintl(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlrint(tls, x) +} + +func Xlround(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xround(tls, x)) +} + +func Xlroundf(tls *TLS, x float32) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xroundf(tls, x)) +} + +func Xlroundl(tls *TLS, x float64) (r int64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Xroundl(tls, x)) +} + +func Xmodf(tls *TLS, x float64, iptr uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v iptr=%v, (%v:)", tls, x, iptr, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var mask Tuint64_t + var v1 uintptr + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _ = e, mask, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp))>>Int32FromInt32(52)&Uint64FromInt32(0x7ff)) - int32(0x3ff) + /* no fractional part */ + if e >= int32(52) { + **(**float64)(__ccgo_up(iptr)) = x + if e == int32(0x400) && *(*Tuint64_t)(unsafe.Pointer(bp))<> Int32FromInt32(12) >> e) + if *(*Tuint64_t)(unsafe.Pointer(bp))&mask == uint64(0) { + **(**float64)(__ccgo_up(iptr)) = x + v1 = bp + *(*Tuint64_t)(unsafe.Pointer(v1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v1)) & (Uint64FromUint64(1) << Int32FromInt32(63))) + return *(*float64)(unsafe.Pointer(bp)) + } + *(*Tuint64_t)(unsafe.Pointer(bp)) &= ^mask + **(**float64)(__ccgo_up(iptr)) = *(*float64)(unsafe.Pointer(bp)) + return x - *(*float64)(unsafe.Pointer(bp)) +} + +func Xmodff(tls *TLS, x float32, iptr uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v iptr=%v, (%v:)", tls, x, iptr, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var mask Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _ = e, mask + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp))>>Int32FromInt32(23)&Uint32FromInt32(0xff)) - int32(0x7f) + /* no fractional part */ + if e >= int32(23) { + **(**float32)(__ccgo_up(iptr)) = x + if e == int32(0x80) && *(*Tuint32_t)(unsafe.Pointer(bp))<> e) + if *(*Tuint32_t)(unsafe.Pointer(bp))&mask == uint32(0) { + **(**float32)(__ccgo_up(iptr)) = x + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x80000000) + return *(*float32)(unsafe.Pointer(bp)) + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= ^mask + **(**float32)(__ccgo_up(iptr)) = *(*float32)(unsafe.Pointer(bp)) + return x - *(*float32)(unsafe.Pointer(bp)) +} + +func Xmodfl(tls *TLS, x float64, iptr uintptr) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v iptr=%v, (%v:)", tls, x, iptr, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r float64 + var _ /* d at bp+0 */ float64 + _ = r + r = Xmodf(tls, x, bp) + **(**float64)(__ccgo_up(iptr)) = float64(**(**float64)(__ccgo_up(bp))) + return r +} + +func Xnan(tls *TLS, s uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) +} + +func Xnanf(tls *TLS, s uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__builtin_nanf(tls, __ccgo_ts) +} + +func Xnanl(tls *TLS, s uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float64(X__builtin_nanf(tls, __ccgo_ts)) +} + +func Xnextafter(tls *TLS, x3 float64, y3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v y3=%v, (%v:)", tls, x3, y3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ax, ay Tuint64_t + var e int32 + var y float32 + var y1, y2 float64 + var v1, v3 uint64 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* ux at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+16 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _ = ax, ay, e, y, y1, y2, v1, v3, v5 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x3 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 16)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 16)) = y3 + *(*float64)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< ay || (*(*Tuint64_t)(unsafe.Pointer(bp + 8))^*(*Tuint64_t)(unsafe.Pointer(bp + 16)))&(Uint64FromUint64(1)<> int32(52) & uint64(0x7ff)) + /* raise overflow if ux.f is infinite and x is finite */ + if e == int32(0x7ff) { + if uint64(8) == uint64(4) { + y = float32(x3 + x3) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + x3 + } else { + y2 = x3 + x3 + } + } + } + /* raise underflow if ux.f is subnormal or zero */ + if e == 0 { + if uint64(8) == uint64(4) { + y = float32(float64(x3*x3) + float64(*(*float64)(unsafe.Pointer(bp + 8))**(*float64)(unsafe.Pointer(bp + 8)))) + } else { + if uint64(8) == uint64(8) { + y1 = float64(x3*x3) + float64(*(*float64)(unsafe.Pointer(bp + 8))**(*float64)(unsafe.Pointer(bp + 8))) + } else { + y2 = float64(x3*x3) + float64(*(*float64)(unsafe.Pointer(bp + 8))**(*float64)(unsafe.Pointer(bp + 8))) + } + } + } + return *(*float64)(unsafe.Pointer(bp + 8)) +} + +func Xnextafterf(tls *TLS, x3 float32, y3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v y3=%v, (%v:)", tls, x3, y3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ax, ay, e Tuint32_t + var y float32 + var y1, y2 float64 + var v1, v3 uint32 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + var _ /* ux at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _ = ax, ay, e, y, y1, y2, v1, v3, v5 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = x3 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 8)) = y3 + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0; !v5 { + *(*float32)(unsafe.Pointer(bp)) = y3 + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x3 + y3 + } + if *(*Tuint32_t)(unsafe.Pointer(bp + 4)) == *(*Tuint32_t)(unsafe.Pointer(bp + 8)) { + return y3 + } + ax = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) & uint32(0x7fffffff) + ay = *(*Tuint32_t)(unsafe.Pointer(bp + 8)) & uint32(0x7fffffff) + if ax == uint32(0) { + if ay == uint32(0) { + return y3 + } + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = *(*Tuint32_t)(unsafe.Pointer(bp + 8))&uint32(0x80000000) | uint32(1) + } else { + if ax > ay || (*(*Tuint32_t)(unsafe.Pointer(bp + 4))^*(*Tuint32_t)(unsafe.Pointer(bp + 8)))&uint32(0x80000000) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) - 1 + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) + 1 + } + } + e = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) & uint32(0x7f800000) + /* raise overflow if ux.f is infinite and x is finite */ + if e == uint32(0x7f800000) { + if uint64(4) == uint64(4) { + y = x3 + x3 + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + x3) + } else { + y2 = float64(x3 + x3) + } + } + } + /* raise underflow if ux.f is subnormal or zero */ + if e == uint32(0) { + if uint64(4) == uint64(4) { + y = float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 4))**(*float32)(unsafe.Pointer(bp + 4))) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 4))**(*float32)(unsafe.Pointer(bp + 4)))) + } else { + y2 = float64(float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 4))**(*float32)(unsafe.Pointer(bp + 4)))) + } + } + } + return *(*float32)(unsafe.Pointer(bp + 4)) +} + +func Xnextafterl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xnextafter(tls, x, y) +} + +func Xnexttoward(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xnextafter(tls, x, y) +} + +func Xnexttowardf(tls *TLS, x3 float32, y3 float64) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v y3=%v, (%v:)", tls, x3, y3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var e Tuint32_t + var y float32 + var y1, y2 float64 + var v1 uint32 + var v3 uint64 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + var _ /* __u at bp+8 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* ux at bp+16 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _ = e, y, y1, y2, v1, v3, v5 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 16)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 16)) = x3 + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0; !v5 { + *(*float64)(unsafe.Pointer(bp + 8)) = y3 + v3 = *(*uint64)(unsafe.Pointer(bp + 8)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) |= uint32(0x80000000) + } + } else { + if float64(x3) < y3 { + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _9 + _9: + if Int32FromUint32(v1>>Int32FromInt32(31)) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) - 1 + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) + 1 + } + } else { + *(*float32)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v1>>Int32FromInt32(31)) != 0 { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) + 1 + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 16)) = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) - 1 + } + } + } + e = *(*Tuint32_t)(unsafe.Pointer(bp + 16)) & uint32(0x7f800000) + /* raise overflow if ux.f is infinite and x is finite */ + if e == uint32(0x7f800000) { + if uint64(4) == uint64(4) { + y = x3 + x3 + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + x3) + } else { + y2 = float64(x3 + x3) + } + } + } + /* raise underflow if ux.f is subnormal or zero */ + if e == uint32(0) { + if uint64(4) == uint64(4) { + y = float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 16))**(*float32)(unsafe.Pointer(bp + 16))) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 16))**(*float32)(unsafe.Pointer(bp + 16)))) + } else { + y2 = float64(float32(x3*x3) + float32(*(*float32)(unsafe.Pointer(bp + 16))**(*float32)(unsafe.Pointer(bp + 16)))) + } + } + } + return *(*float32)(unsafe.Pointer(bp + 16)) +} + +func Xnexttowardl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xnextafterl(tls, x, y) +} + +const OFF2 = 4604531861337669632 +const POW_LOG_POLY_ORDER = 8 +const POW_LOG_TABLE_BITS = 7 +const SIGN_BIAS = 262144 + +/* +Worst-case error: 0.54 ULP (~= ulperr_exp + 1024*Ln2*relerr_log*2^53) +relerr_log: 1.3 * 2^-68 (Relative error of log, 1.5 * 2^-68 without fma) +ulperr_exp: 0.509 ULP (ULP error of exp, 0.511 ULP without fma) +*/ + +// C documentation +// +// /* Top 12 bits of a double (sign and exponent bits). */ +func _top124(tls *TLS, x float64) (r Tuint32_t) { + return uint32(*(*Tuint64_t)(unsafe.Pointer(&x)) >> int32(52)) +} + +// C documentation +// +// /* Compute y+TAIL = log(x) where the rounded result is y and TAIL has about +// additional 15 bits precision. IX is the bit representation of x, but +// normalized in the subnormal range using the sign bit for the exponent. */ +func _log_inline(tls *TLS, ix Tuint64_t, tail uintptr) (r1 Tdouble_t) { + var ar, ar2, ar3, hi, invc, kd, lo, lo1, lo2, lo3, lo4, logc, logctail, p, r, t1, t2, y, z Tdouble_t + var i, k int32 + var iz, tmp Tuint64_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ar, ar2, ar3, hi, i, invc, iz, k, kd, lo, lo1, lo2, lo3, lo4, logc, logctail, p, r, t1, t2, tmp, y, z + /* x = 2^k z; where z is in range [OFF,2*OFF) and exact. + The range is split into N subintervals. + The ith subinterval contains z and c is near its center. */ + tmp = ix - uint64(OFF2) + i = Int32FromUint64(tmp >> (Int32FromInt32(52) - Int32FromInt32(POW_LOG_TABLE_BITS)) % Uint64FromInt32(Int32FromInt32(1)<> int32(52)) /* arithmetic shift */ + iz = uint64(ix - tmp&(Uint64FromUint64(0xfff)< 0, the exponent of scale might have overflowed by <= 460. */ + sbits = uint64(sbits - Uint64FromUint64(1009)<= _top124(tls, float64(512))-_top124(tls, float64(5.551115123125783e-17)) { + if abstop-_top124(tls, float64(5.551115123125783e-17)) >= uint32(0x80000000) { + /* Avoid spurious underflow for tiny x. */ + /* Note: 0 is common input. */ + one = float64(1) + x1 + if sign_bias != 0 { + v1 = -one + } else { + v1 = one + } + return v1 + } + if abstop >= _top124(tls, float64(1024)) { + /* Note: inf and nan are already handled. */ + v2 = x1 + if *(*Tuint64_t)(unsafe.Pointer(&v2))>>int32(63) != 0 { + return X__math_uflow(tls, sign_bias) + } else { + return X__math_oflow(tls, sign_bias) + } + } + /* Large x is special cased below. */ + abstop = uint32(0) + } + /* exp(x) = 2^(k/N) * exp(r), with exp(r) in [2^(-1/2N),2^(1/2N)]. */ + /* x = ln2/N*k + r, with int k and r in [-ln2/2N, ln2/2N]. */ + z = Tdouble_t(X__exp_data.Finvln2N * x1) + /* z - kd is in [-1, 1] in non-nearest rounding modes. */ + y = z + X__exp_data.Fshift + v2 = y + goto _4 +_4: + kd = v2 + v2 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v2)) + kd = kd - X__exp_data.Fshift + r = x1 + Tdouble_t(kd*X__exp_data.Fnegln2hiN) + Tdouble_t(kd*X__exp_data.Fnegln2loN) + /* The code assumes 2^-200 < |xtail| < 2^-8/N. */ + r = r + xtail + /* 2^(k/N) ~= scale * (1 + tail). */ + idx = uint64(2) * (ki % Uint64FromInt32(Int32FromInt32(1)< 2^-200 and scale > 2^-739, so there + is no spurious underflow here even without fma. */ + y = scale + Tdouble_t(scale*tmp) + v2 = y + goto _8 +_8: + return v2 +} + +// C documentation +// +// /* Returns 0 if not int, 1 if odd int, 2 if even int. The argument is +// the bit representation of a non-zero finite floating-point value. */ +func _checkint(tls *TLS, iy Tuint64_t) (r int32) { + var e int32 + _ = e + e = Int32FromUint64(iy >> int32(52) & uint64(0x7ff)) + if e < int32(0x3ff) { + return 0 + } + if e > Int32FromInt32(0x3ff)+Int32FromInt32(52) { + return int32(2) + } + if iy&(uint64(1)<<(Int32FromInt32(0x3ff)+Int32FromInt32(52)-e)-uint64(1)) != 0 { + return 0 + } + if iy&(uint64(1)<<(Int32FromInt32(0x3ff)+Int32FromInt32(52)-e)) != 0 { + return int32(1) + } + return int32(2) +} + +// C documentation +// +// /* Returns 1 if input is the bit representation of 0, infinity or nan. */ +func _zeroinfnan(tls *TLS, i Tuint64_t) (r int32) { + var v1 float64 + _ = v1 + v1 = float64(X__builtin_inff(tls)) + return BoolInt32(uint64(2)*i-uint64(1) >= uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1))-uint64(1)) +} + +func Xpow(tls *TLS, x1 float64, y1 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x1=%v y1=%v, (%v:)", tls, x1, y1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ehi, elo, hi, x2 Tdouble_t + var ix, iy Tuint64_t + var sign_bias, topx, topy Tuint32_t + var y, v1, v2 float64 + var yint int32 + var v4 bool + var _ /* lo at bp+0 */ Tdouble_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = ehi, elo, hi, ix, iy, sign_bias, topx, topy, x2, y, yint, v1, v2, v4 + sign_bias = uint32(0) + ix = *(*Tuint64_t)(unsafe.Pointer(&x1)) + iy = *(*Tuint64_t)(unsafe.Pointer(&y1)) + topx = _top124(tls, x1) + topy = _top124(tls, y1) + if topx-uint32(0x001) >= Uint32FromInt32(Int32FromInt32(0x7ff)-Int32FromInt32(0x001)) || topy&uint32(0x7ff)-uint32(0x3be) >= Uint32FromInt32(Int32FromInt32(0x43e)-Int32FromInt32(0x3be)) { + /* Note: if |y| > 1075 * ln2 * 2^53 ~= 0x1.749p62 then pow(x,y) = inf/0 + and if |y| < 2^-54 / 1075 ~= 0x1.e7b6p-65 then pow(x,y) = +-1. */ + /* Special cases: (x < 0x1p-126 or inf or nan) or + (|y| < 0x1p-65 or |y| >= 0x1p63 or nan). */ + if _zeroinfnan(tls, iy) != 0 { + if uint64(2)*iy == uint64(0) { + return float64(1) + } + v1 = float64(1) + if ix == *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(1) + } + v1 = float64(X__builtin_inff(tls)) + if v4 = uint64(2)*ix > uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1)); !v4 { + v2 = float64(X__builtin_inff(tls)) + } + if v4 || uint64(2)*iy > uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v2)) { + return x1 + y1 + } + v1 = float64(1) + if uint64(2)*ix == uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(1) + } + v1 = float64(1) + if BoolInt32(uint64(2)*ix < uint64(2)**(*Tuint64_t)(unsafe.Pointer(&v1))) == BoolInt32(!(iy>>Int32FromInt32(63) != 0)) { + return float64(0) + } /* |x|<1 && y==inf or |x|>1 && y==-inf. */ + return float64(y1 * y1) + } + if _zeroinfnan(tls, ix) != 0 { + x2 = Tdouble_t(x1 * x1) + if ix>>int32(63) != 0 && _checkint(tls, iy) == int32(1) { + x2 = -x2 + } + /* Without the barrier some versions of clang hoist the 1/x2 and + thus division by zero exception can be signaled spuriously. */ + if iy>>int32(63) != 0 { + y = Float64FromInt32(1) / x2 + v2 = y + goto _9 + _9: + v1 = v2 + } else { + v1 = x2 + } + return v1 + } + /* Here x and y are non-zero finite. */ + if ix>>int32(63) != 0 { + /* Finite x < 0. */ + yint = _checkint(tls, iy) + if yint == 0 { + return X__math_invalid(tls, x1) + } + if yint == int32(1) { + sign_bias = Uint32FromInt32(Int32FromInt32(0x800) << Int32FromInt32(EXP_TABLE_BITS)) + } + ix = ix & uint64(0x7fffffffffffffff) + topx = topx & uint32(0x7ff) + } + if topy&uint32(0x7ff)-uint32(0x3be) >= Uint32FromInt32(Int32FromInt32(0x43e)-Int32FromInt32(0x3be)) { + /* Note: sign_bias == 0 here because y is not odd. */ + v1 = float64(1) + if ix == *(*Tuint64_t)(unsafe.Pointer(&v1)) { + return float64(1) + } + if topy&uint32(0x7ff) < uint32(0x3be) { + /* |y| < 2^-65, x^y ~= 1 + y*log(x). */ + if int32(WANT_ROUNDING) != 0 { + v2 = float64(1) + if ix > *(*Tuint64_t)(unsafe.Pointer(&v2)) { + v1 = float64(1) + y1 + } else { + v1 = float64(1) - y1 + } + return v1 + } else { + return float64(1) + } + } + v2 = float64(1) + if BoolInt32(ix > *(*Tuint64_t)(unsafe.Pointer(&v2))) == BoolInt32(topy < uint32(0x800)) { + v1 = X__math_oflow(tls, uint32(0)) + } else { + v1 = X__math_uflow(tls, uint32(0)) + } + return v1 + } + if topx == uint32(0) { + /* Normalize subnormal x so exponent becomes negative. */ + v1 = float64(x1 * float64(4.503599627370496e+15)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + ix = ix & uint64(0x7fffffffffffffff) + ix = uint64(ix - Uint64FromUint64(52)<> (Int32FromInt32(23) - Int32FromInt32(POWF_LOG2_TABLE_BITS)) % Uint32FromInt32(Int32FromInt32(1)<> (Int32FromInt32(23) - Int32FromInt32(POWF_SCALE_BITS)) /* arithmetic shift */ + invc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + uintptr(i)*16))).Finvc + logc = (**(**struct { + Finvc float64 + Flogc float64 + })(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + uintptr(i)*16))).Flogc + z = float64(*(*float32)(unsafe.Pointer(&iz))) + /* log2(x) = log1p(z/c-1)/ln2 + log2(c) + k */ + r = Tdouble_t(z*invc) - Float64FromInt32(1) + y0 = logc + float64(k) + /* Pipelined polynomial evaluation to approximate log1p(r)/ln2. */ + r2 = Tdouble_t(r * r) + y = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256))*r) + **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256 + 1*8)) + p = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256 + 2*8))*r) + **(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256 + 3*8)) + r4 = Tdouble_t(r2 * r2) + q = float64(**(**float64)(__ccgo_up(uintptr(unsafe.Pointer(&X__powf_log2_data)) + 256 + 4*8))*r) + y0 + q = Tdouble_t(p*r2) + q + y = Tdouble_t(y*r4) + q + return y +} + +// C documentation +// +// /* The output of log2 and thus the input of exp2 is either scaled by N +// (in case of fast toint intrinsics) or not. The unscaled xd must be +// in [-1021,1023], sign_bias sets the sign of the result. */ +func _exp2_inline(tls *TLS, xd Tdouble_t, sign_bias Tuint32_t) (r1 float32) { + var kd, r, r2, s, y2, z Tdouble_t + var ki, ski, t Tuint64_t + var y, v4 float32 + var y1, v1 float64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = kd, ki, r, r2, s, ski, t, y, y1, y2, z, v1, v4 + /* x = k/N + r with r in [-1/(2N), 1/(2N)] */ + y1 = xd + X__exp2f_data.Fshift_scaled + v1 = y1 + goto _2 +_2: + kd = v1 + v1 = kd + ki = *(*Tuint64_t)(unsafe.Pointer(&v1)) + kd = kd - X__exp2f_data.Fshift_scaled /* k/N */ + r = xd - kd + /* exp2(x) = 2^(k/N) * 2^r ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */ + t = **(**Tuint64_t)(__ccgo_up(uintptr(unsafe.Pointer(&X__exp2f_data)) + uintptr(ki%Uint64FromInt32(Int32FromInt32(1)<> int32(23) & uint32(0xff)) + if e < int32(0x7f) { + return 0 + } + if e > Int32FromInt32(0x7f)+Int32FromInt32(23) { + return int32(2) + } + if iy&Uint32FromInt32(Int32FromInt32(1)<<(Int32FromInt32(0x7f)+Int32FromInt32(23)-e)-Int32FromInt32(1)) != 0 { + return 0 + } + if iy&Uint32FromInt32(Int32FromInt32(1)<<(Int32FromInt32(0x7f)+Int32FromInt32(23)-e)) != 0 { + return int32(1) + } + return int32(2) +} + +func _zeroinfnan1(tls *TLS, ix Tuint32_t) (r int32) { + return BoolInt32(uint32(2)*ix-uint32(1) >= Uint32FromUint32(2)*Uint32FromInt32(0x7f800000)-Uint32FromInt32(1)) +} + +func Xpowf(tls *TLS, x1 float32, y1 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x1=%v y1=%v, (%v:)", tls, x1, y1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ix, iy, sign_bias Tuint32_t + var logx, ylogx Tdouble_t + var x2 Tfloat_t + var y, v1, v2 float32 + var yint int32 + var v5, v6 float64 + _, _, _, _, _, _, _, _, _, _, _, _ = ix, iy, logx, sign_bias, x2, y, yint, ylogx, v1, v2, v5, v6 + sign_bias = uint32(0) + ix = *(*Tuint32_t)(unsafe.Pointer(&x1)) + iy = *(*Tuint32_t)(unsafe.Pointer(&y1)) + if ix-uint32(0x00800000) >= Uint32FromInt32(Int32FromInt32(0x7f800000)-Int32FromInt32(0x00800000)) || _zeroinfnan1(tls, iy) != 0 { + /* Either (x < 0x1p-126 or inf or nan) or (y is 0 or inf or nan). */ + if _zeroinfnan1(tls, iy) != 0 { + if uint32(2)*iy == uint32(0) { + return Float32FromFloat32(1) + } + if ix == uint32(0x3f800000) { + return Float32FromFloat32(1) + } + if uint32(2)*ix > Uint32FromUint32(2)*Uint32FromInt32(0x7f800000) || uint32(2)*iy > Uint32FromUint32(2)*Uint32FromInt32(0x7f800000) { + return x1 + y1 + } + if uint32(2)*ix == Uint32FromInt32(Int32FromInt32(2)*Int32FromInt32(0x3f800000)) { + return Float32FromFloat32(1) + } + if BoolInt32(uint32(2)*ix < Uint32FromInt32(Int32FromInt32(2)*Int32FromInt32(0x3f800000))) == BoolInt32(!(iy&Uint32FromUint32(0x80000000) != 0)) { + return Float32FromFloat32(0) + } /* |x|<1 && y==inf or |x|>1 && y==-inf. */ + return float32(y1 * y1) + } + if _zeroinfnan1(tls, ix) != 0 { + x2 = Tfloat_t(x1 * x1) + if ix&uint32(0x80000000) != 0 && _checkint1(tls, iy) == int32(1) { + x2 = -x2 + } + /* Without the barrier some versions of clang hoist the 1/x2 and + thus division by zero exception can be signaled spuriously. */ + if iy&uint32(0x80000000) != 0 { + y = Float32FromInt32(1) / x2 + v2 = y + goto _3 + _3: + v1 = v2 + } else { + v1 = x2 + } + return v1 + } + /* x and y are non-zero finite. */ + if ix&uint32(0x80000000) != 0 { + /* Finite x < 0. */ + yint = _checkint1(tls, iy) + if yint == 0 { + return X__math_invalidf(tls, x1) + } + if yint == int32(1) { + sign_bias = Uint32FromInt32(Int32FromInt32(1) << (Int32FromInt32(EXP2F_TABLE_BITS) + Int32FromInt32(11))) + } + ix = ix & uint32(0x7fffffff) + } + if ix < uint32(0x00800000) { + /* Normalize subnormal x so exponent becomes negative. */ + v1 = float32(x1 * Float32FromFloat32(8.388608e+06)) + ix = *(*Tuint32_t)(unsafe.Pointer(&v1)) + ix = ix & uint32(0x7fffffff) + ix = ix - Uint32FromInt32(Int32FromInt32(23)<>int32(47)&uint64(0xffff) >= *(*Tuint64_t)(unsafe.Pointer(&v6))>>int32(47) { + /* |y*log(x)| >= 126. */ + if ylogx > Tdouble_t(float64(127.99999995700433)*float64(Int32FromInt32(1)< %v", r) }() + } + return Xpow(tls, x, y) +} + +func Xremainder(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* q at bp+0 */ int32 + return Xremquo(tls, x, y, bp) +} + +func Xdrem(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xremainder(tls, x, y) +} + +func Xremainderf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* q at bp+0 */ int32 + return Xremquof(tls, x, y, bp) +} + +func Xdremf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xremainderf(tls, x, y) +} + +func Xremainderl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xremainder(tls, x, y) +} + +func Xremquo(tls *TLS, x float64, y float64, quo uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v quo=%v, (%v:)", tls, x, y, quo, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ex, ey, sx, sy, v10 int32 + var i, uxi Tuint64_t + var q Tuint32_t + var v1 uint64 + var v11 float64 + var v3 bool + var v6 uintptr + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* ux at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + var _ /* uy at bp+16 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _ = ex, ey, i, q, sx, sy, uxi, v1, v10, v11, v3, v6 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 16)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 16)) = y + ex = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(52) & uint64(0x7ff)) + ey = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 16)) >> int32(52) & uint64(0x7ff)) + sx = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(63)) + sy = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 16)) >> int32(63)) + uxi = *(*Tuint64_t)(unsafe.Pointer(bp + 8)) + **(**int32)(__ccgo_up(quo)) = 0 + if v3 = *(*Tuint64_t)(unsafe.Pointer(bp + 16))<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>int32(63) == uint64(0)) { + break + } + goto _4 + _4: + ; + ex = ex - 1 + i = i << uint64(1) + } + uxi = uxi << Uint64FromInt32(-ex+int32(1)) + } else { + uxi = uint64(uxi & (-Uint64FromUint64(1) >> Int32FromInt32(12))) + uxi = uint64(uxi | Uint64FromUint64(1)<>int32(63) == uint64(0)) { + break + } + goto _5 + _5: + ; + ey = ey - 1 + i = i << uint64(1) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 16)) <<= Uint64FromInt32(-ey + int32(1)) + } else { + v6 = bp + 16 + *(*Tuint64_t)(unsafe.Pointer(v6)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v6)) & (-Uint64FromUint64(1) >> Int32FromInt32(12))) + v6 = bp + 16 + *(*Tuint64_t)(unsafe.Pointer(v6)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(v6)) | Uint64FromUint64(1)< ey) { + break + } + i = uxi - *(*Tuint64_t)(unsafe.Pointer(bp + 16)) + if i>>int32(63) == uint64(0) { + uxi = i + q = q + 1 + } + uxi = uxi << uint64(1) + q = q << uint32(1) + goto _8 + _8: + ; + ex = ex - 1 + } + i = uxi - *(*Tuint64_t)(unsafe.Pointer(bp + 16)) + if i>>int32(63) == uint64(0) { + uxi = i + q = q + 1 + } + if uxi == uint64(0) { + ex = -int32(60) + } else { + for { + if !(uxi>>int32(52) == uint64(0)) { + break + } + goto _9 + _9: + ; + uxi = uxi << uint64(1) + ex = ex - 1 + } + } + goto end +end: + ; + /* scale result and decide between |x| and |x|-|y| */ + if ex > 0 { + uxi = uint64(uxi - Uint64FromUint64(1)<> Uint64FromInt32(-ex+int32(1)) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 8)) = uxi + x = *(*float64)(unsafe.Pointer(bp + 8)) + if sy != 0 { + y = -y + } + if ex == ey || ex+int32(1) == ey && (float64(Float64FromInt32(2)*x) > y || float64(Float64FromInt32(2)*x) == y && q%uint32(2) != 0) { + x = x - y + q = q + 1 + } + q = q & uint32(0x7fffffff) + if sx^sy != 0 { + v10 = -Int32FromUint32(q) + } else { + v10 = Int32FromUint32(q) + } + **(**int32)(__ccgo_up(quo)) = v10 + if sx != 0 { + v11 = -x + } else { + v11 = x + } + return v11 +} + +func Xremquof(tls *TLS, x float32, y float32, quo uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v quo=%v, (%v:)", tls, x, y, quo, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ex, ey, sx, sy, v8 int32 + var i, q, uxi Tuint32_t + var v1 uint32 + var v3 bool + var v9 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + var _ /* ux at bp+4 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + var _ /* uy at bp+8 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _ = ex, ey, i, q, sx, sy, uxi, v1, v3, v8, v9 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 4)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 4)) = x + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp + 8)) = y + ex = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 4)) >> int32(23) & uint32(0xff)) + ey = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 8)) >> int32(23) & uint32(0xff)) + sx = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 4)) >> int32(31)) + sy = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp + 8)) >> int32(31)) + uxi = *(*Tuint32_t)(unsafe.Pointer(bp + 4)) + **(**int32)(__ccgo_up(quo)) = 0 + if v3 = *(*Tuint32_t)(unsafe.Pointer(bp + 8))< uint32(0x7f800000)) != 0 || ex == int32(0xff) { + return float32(x*y) / float32(x*y) + } + if *(*Tuint32_t)(unsafe.Pointer(bp + 4))<>int32(31) == uint32(0)) { + break + } + goto _4 + _4: + ; + ex = ex - 1 + i = i << uint32(1) + } + uxi = uxi << Uint32FromInt32(-ex+int32(1)) + } else { + uxi = uxi & (-Uint32FromUint32(1) >> Int32FromInt32(9)) + uxi = uxi | Uint32FromUint32(1)<>int32(31) == uint32(0)) { + break + } + goto _5 + _5: + ; + ey = ey - 1 + i = i << uint32(1) + } + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) <<= Uint32FromInt32(-ey + int32(1)) + } else { + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) &= -Uint32FromUint32(1) >> Int32FromInt32(9) + *(*Tuint32_t)(unsafe.Pointer(bp + 8)) |= Uint32FromUint32(1) << Int32FromInt32(23) + } + q = uint32(0) + if ex < ey { + if ex+int32(1) == ey { + goto end + } + return x + } + /* x mod y */ + for { + if !(ex > ey) { + break + } + i = uxi - *(*Tuint32_t)(unsafe.Pointer(bp + 8)) + if i>>int32(31) == uint32(0) { + uxi = i + q = q + 1 + } + uxi = uxi << uint32(1) + q = q << uint32(1) + goto _6 + _6: + ; + ex = ex - 1 + } + i = uxi - *(*Tuint32_t)(unsafe.Pointer(bp + 8)) + if i>>int32(31) == uint32(0) { + uxi = i + q = q + 1 + } + if uxi == uint32(0) { + ex = -int32(30) + } else { + for { + if !(uxi>>int32(23) == uint32(0)) { + break + } + goto _7 + _7: + ; + uxi = uxi << uint32(1) + ex = ex - 1 + } + } + goto end +end: + ; + /* scale result and decide between |x| and |x|-|y| */ + if ex > 0 { + uxi = uxi - Uint32FromUint32(1)<> Uint32FromInt32(-ex+int32(1)) + } + *(*Tuint32_t)(unsafe.Pointer(bp + 4)) = uxi + x = *(*float32)(unsafe.Pointer(bp + 4)) + if sy != 0 { + y = -y + } + if ex == ey || ex+int32(1) == ey && (float32(Float32FromInt32(2)*x) > y || float32(Float32FromInt32(2)*x) == y && q%uint32(2) != 0) { + x = x - y + q = q + 1 + } + q = q & uint32(0x7fffffff) + if sx^sy != 0 { + v8 = -Int32FromUint32(q) + } else { + v8 = Int32FromUint32(q) + } + **(**int32)(__ccgo_up(quo)) = v8 + if sx != 0 { + v9 = -x + } else { + v9 = x + } + return v9 +} + +func Xremquol(tls *TLS, x float64, y float64, quo uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v quo=%v, (%v:)", tls, x, y, quo, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xremquo(tls, x, y, quo) +} + +const DBL_EPSILON9 = 2.220446049250313e-16 + +var _toint4 = Float64FromInt32(1) / Float64FromFloat64(2.220446049250313e-16) + +func Xrint(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s int32 + var y Tdouble_t + var v1 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _ = e, s, y, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + s = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + if e >= Int32FromInt32(0x3ff)+Int32FromInt32(52) { + return x + } + if s != 0 { + y = x - _toint4 + _toint4 + } else { + y = x + _toint4 - _toint4 + } + if y == Float64FromInt32(0) { + if s != 0 { + v1 = -Float64FromFloat64(0) + } else { + v1 = Float64FromInt32(0) + } + return v1 + } + return y +} + +const DBL_EPSILON10 = 0 +const FLT_EPSILON1 = 1.1920928955078125e-07 + +var _toint5 = Float32FromInt32(1) / Float32FromFloat32(1.1920928955078125e-07) + +func Xrintf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s int32 + var y Tfloat_t + var v1 float32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _ = e, s, y, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + s = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + if e >= Int32FromInt32(0x7f)+Int32FromInt32(23) { + return x + } + if s != 0 { + y = x - _toint5 + _toint5 + } else { + y = x + _toint5 - _toint5 + } + if y == Float32FromInt32(0) { + if s != 0 { + v1 = -Float32FromFloat32(0) + } else { + v1 = Float32FromFloat32(0) + } + return v1 + } + return y +} + +const FLT_EPSILON2 = 0 + +func Xrintl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xrint(tls, x) +} + +const DBL_EPSILON11 = 2.220446049250313e-16 + +var _toint6 = Float64FromInt32(1) / Float64FromFloat64(2.220446049250313e-16) + +func Xround(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var y float32 + var y1, y2 float64 + var y3 Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _ = e, y, y1, y2, y3 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(52) & uint64(0x7ff)) + if e >= Int32FromInt32(0x3ff)+Int32FromInt32(52) { + return x3 + } + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + x3 = -x3 + } + if e < Int32FromInt32(0x3ff)-Int32FromInt32(1) { + /* raise inexact if x!=0 */ + if uint64(8) == uint64(4) { + y = float32(x3 + _toint6) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + _toint6 + } else { + y2 = float64(x3 + _toint6) + } + } + return float64(Float64FromInt32(0) * *(*float64)(unsafe.Pointer(bp))) + } + y3 = x3 + _toint6 - _toint6 - x3 + if y3 > float64(0.5) { + y3 = y3 + x3 - Float64FromInt32(1) + } else { + if y3 <= -Float64FromFloat64(0.5) { + y3 = y3 + x3 + Float64FromInt32(1) + } else { + y3 = y3 + x3 + } + } + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + y3 = -y3 + } + return y3 +} + +const DBL_EPSILON12 = 0 +const FLT_EPSILON3 = 1.1920928955078125e-07 + +var _toint7 = Float32FromInt32(1) / Float32FromFloat32(1.1920928955078125e-07) + +func Xroundf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var y float32 + var y1, y2 float64 + var y3 Tfloat_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e, y, y1, y2, y3 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + if e >= Int32FromInt32(0x7f)+Int32FromInt32(23) { + return x3 + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + x3 = -x3 + } + if e < Int32FromInt32(0x7f)-Int32FromInt32(1) { + if uint64(4) == uint64(4) { + y = x3 + _toint7 + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + _toint7) + } else { + y2 = float64(x3 + _toint7) + } + } + return float32(Float32FromInt32(0) * *(*float32)(unsafe.Pointer(bp))) + } + y3 = x3 + _toint7 - _toint7 - x3 + if y3 > Float32FromFloat32(0.5) { + y3 = y3 + x3 - Float32FromInt32(1) + } else { + if y3 <= -Float32FromFloat32(0.5) { + y3 = y3 + x3 + Float32FromInt32(1) + } else { + y3 = y3 + x3 + } + } + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + y3 = -y3 + } + return y3 +} + +const FLT_EPSILON4 = 0 + +func Xroundl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xround(tls, x) +} + +func Xscalb(tls *TLS, x float64, fn float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v fn=%v, (%v:)", tls, x, fn, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3 uint64 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _ = v1, v3, v5 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< float64(0) { + return float64(x * fn) + } else { + return x / -fn + } + } + if Xrint(tls, fn) != fn { + return (fn - fn) / (fn - fn) + } + if fn > float64(65000) { + return Xscalbn(tls, x, int32(65000)) + } + if -fn > float64(65000) { + return Xscalbn(tls, x, -int32(65000)) + } + return Xscalbn(tls, x, int32(fn)) +} + +func Xscalbf(tls *TLS, x float32, fn float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v fn=%v, (%v:)", tls, x, fn, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v3 uint32 + var v5 bool + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _ = v1, v3, v5 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + ; + if v5 = BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0; !v5 { + *(*float32)(unsafe.Pointer(bp)) = fn + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 + _4: + } + if v5 || BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return float32(x * fn) + } + *(*float32)(unsafe.Pointer(bp)) = fn + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _7 +_7: + if !(BoolInt32(v1&Uint32FromInt32(0x7fffffff) < Uint32FromInt32(0x7f800000)) != 0) { + if fn > Float32FromFloat32(0) { + return float32(x * fn) + } else { + return x / -fn + } + } + if Xrintf(tls, fn) != fn { + return (fn - fn) / (fn - fn) + } + if fn > Float32FromFloat32(65000) { + return Xscalbnf(tls, x, int32(65000)) + } + if -fn > Float32FromFloat32(65000) { + return Xscalbnf(tls, x, -int32(65000)) + } + return Xscalbnf(tls, x, int32(fn)) +} + +func Xscalbln(tls *TLS, x float64, n int64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n > int64(INT_MAX) { + n = int64(INT_MAX) + } else { + if n < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff)) { + n = int64(-Int32FromInt32(1) - Int32FromInt32(0x7fffffff)) + } + } + return Xscalbn(tls, x, int32(n)) +} + +func Xscalblnf(tls *TLS, x float32, n int64) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n > int64(INT_MAX) { + n = int64(INT_MAX) + } else { + if n < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff)) { + n = int64(-Int32FromInt32(1) - Int32FromInt32(0x7fffffff)) + } + } + return Xscalbnf(tls, x, int32(n)) +} + +func Xscalblnl(tls *TLS, x float64, n int64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbln(tls, x, n) +} + +func Xscalbn(tls *TLS, x float64, n int32) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var y Tdouble_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _ = y + y = x + if n > int32(1023) { + y = y * float64(8.98846567431158e+307) + n = n - int32(1023) + if n > int32(1023) { + y = y * float64(8.98846567431158e+307) + n = n - int32(1023) + if n > int32(1023) { + n = int32(1023) + } + } + } else { + if n < -int32(1022) { + /* make sure final n < -53 to avoid double + rounding in the subnormal range */ + y = y * Tdouble_t(Float64FromFloat64(2.2250738585072014e-308)*Float64FromFloat64(9.007199254740992e+15)) + n = n + (Int32FromInt32(1022) - Int32FromInt32(53)) + if n < -int32(1022) { + y = y * Tdouble_t(Float64FromFloat64(2.2250738585072014e-308)*Float64FromFloat64(9.007199254740992e+15)) + n = n + (Int32FromInt32(1022) - Int32FromInt32(53)) + if n < -int32(1022) { + n = -int32(1022) + } + } + } + } + *(*Tuint64_t)(unsafe.Pointer(bp)) = Uint64FromInt32(Int32FromInt32(0x3ff)+n) << int32(52) + x = float64(y * *(*float64)(unsafe.Pointer(bp))) + return x +} + +func Xscalbnf(tls *TLS, x float32, n int32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var y Tfloat_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _ = y + y = x + if n > int32(127) { + y = y * Float32FromFloat32(1.7014118346046923e+38) + n = n - int32(127) + if n > int32(127) { + y = y * Float32FromFloat32(1.7014118346046923e+38) + n = n - int32(127) + if n > int32(127) { + n = int32(127) + } + } + } else { + if n < -int32(126) { + y = y * Tfloat_t(Float32FromFloat32(1.1754943508222875e-38)*Float32FromFloat32(1.6777216e+07)) + n = n + (Int32FromInt32(126) - Int32FromInt32(24)) + if n < -int32(126) { + y = y * Tfloat_t(Float32FromFloat32(1.1754943508222875e-38)*Float32FromFloat32(1.6777216e+07)) + n = n + (Int32FromInt32(126) - Int32FromInt32(24)) + if n < -int32(126) { + n = -int32(126) + } + } + } + } + *(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32(Int32FromInt32(0x7f)+n) << int32(23) + x = float32(y * *(*float32)(unsafe.Pointer(bp))) + return x +} + +func Xscalbnl(tls *TLS, x float64, n int32) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbn(tls, x, n) +} + +func Xsignificand(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbn(tls, x, -Xilogb(tls, x)) +} + +func Xsignificandf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscalbnf(tls, x, -Xilogbf(tls, x)) +} + +func Xsin(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n uint32 + var y float32 + var y1, y2, v1 float64 + var _ /* y at bp+0 */ [2]float64 + _, _, _, _, _, _ = ix, n, y, y1, y2, v1 + /* High word of x. */ + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* |x| ~< pi/4 */ + if ix <= uint32(0x3fe921fb) { + if ix < uint32(0x3e500000) { /* |x| < 2**-26 */ + /* raise inexact if x != 0 and underflow if subnormal*/ + if uint64(8) == uint64(4) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y = float32(v1) + } else { + if uint64(8) == uint64(8) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y1 = v1 + } else { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y2 = v1 + } + } + return x3 + } + return X__sin(tls, x3, float64(0), 0) + } + /* sin(Inf or NaN) is NaN */ + if ix >= uint32(0x7ff00000) { + return x3 - x3 + } + /* argument reduction needed */ + n = Uint32FromInt32(X__rem_pio2(tls, x3, bp)) + switch n & Uint32FromInt32(3) { + case uint32(0): + return X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + case uint32(1): + return X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + case uint32(2): + return -X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + default: + return -X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + } + return r +} + +func Xsincos(tls *TLS, x3 float64, sin uintptr, cos uintptr) { + if __ccgo_strace { + trc("tls=%v x3=%v sin=%v cos=%v, (%v:)", tls, x3, sin, cos, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, s, y1, y2, v1 float64 + var ix Tuint32_t + var n uint32 + var y float32 + var _ /* y at bp+0 */ [2]float64 + _, _, _, _, _, _, _, _ = c, ix, n, s, y, y1, y2, v1 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* |x| ~< pi/4 */ + if ix <= uint32(0x3fe921fb) { + /* if |x| < 2**-27 * sqrt(2) */ + if ix < uint32(0x3e46a09e) { + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(8) == uint64(4) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y = float32(v1) + } else { + if uint64(8) == uint64(8) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y1 = v1 + } else { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y2 = v1 + } + } + **(**float64)(__ccgo_up(sin)) = x3 + **(**float64)(__ccgo_up(cos)) = float64(1) + return + } + **(**float64)(__ccgo_up(sin)) = X__sin(tls, x3, float64(0), 0) + **(**float64)(__ccgo_up(cos)) = X__cos(tls, x3, float64(0)) + return + } + /* sincos(Inf or NaN) is NaN */ + if ix >= uint32(0x7ff00000) { + v1 = x3 - x3 + **(**float64)(__ccgo_up(cos)) = v1 + **(**float64)(__ccgo_up(sin)) = v1 + return + } + /* argument reduction needed */ + n = Uint32FromInt32(X__rem_pio2(tls, x3, bp)) + s = X__sin(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], int32(1)) + c = X__cos(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)]) + switch n & Uint32FromInt32(3) { + case uint32(0): + **(**float64)(__ccgo_up(sin)) = s + **(**float64)(__ccgo_up(cos)) = c + case uint32(1): + **(**float64)(__ccgo_up(sin)) = c + **(**float64)(__ccgo_up(cos)) = -s + case uint32(2): + **(**float64)(__ccgo_up(sin)) = -s + **(**float64)(__ccgo_up(cos)) = -c + case uint32(3): + fallthrough + default: + **(**float64)(__ccgo_up(sin)) = -c + **(**float64)(__ccgo_up(cos)) = s + break + } +} + +const M_PI_25 = 1.5707963267948966 + +// C documentation +// +// /* Small multiples of pi/2 rounded to double precision. */ + +var _s1pio2 = float64(Float64FromInt32(1) * Float64FromFloat64(1.5707963267948966)) /* 0x3FF921FB, 0x54442D18 */ +var _s2pio2 = float64(Float64FromInt32(2) * Float64FromFloat64(1.5707963267948966)) /* 0x400921FB, 0x54442D18 */ +var _s3pio2 = float64(Float64FromInt32(3) * Float64FromFloat64(1.5707963267948966)) /* 0x4012D97C, 0x7F3321D2 */ +var _s4pio2 = float64(Float64FromInt32(4) * Float64FromFloat64(1.5707963267948966)) /* 0x401921FB, 0x54442D18 */ + +func Xsincosf(tls *TLS, x3 float32, sin uintptr, cos uintptr) { + if __ccgo_strace { + trc("tls=%v x3=%v sin=%v cos=%v, (%v:)", tls, x3, sin, cos, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, s Tfloat_t + var ix Tuint32_t + var n, sign uint32 + var y, v1 float32 + var y1, y2, v4 float64 + var _ /* y at bp+0 */ float64 + _, _, _, _, _, _, _, _, _, _ = c, ix, n, s, sign, y, y1, y2, v1, v4 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + /* |x| ~<= pi/4 */ + if ix <= uint32(0x3f490fda) { + /* |x| < 2**-12 */ + if ix < uint32(0x39800000) { + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(4) == uint64(4) { + if ix < uint32(0x00100000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y = v1 + } else { + if uint64(4) == uint64(8) { + if ix < uint32(0x00100000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y1 = float64(v1) + } else { + if ix < uint32(0x00100000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y2 = float64(v1) + } + } + **(**float32)(__ccgo_up(sin)) = x3 + **(**float32)(__ccgo_up(cos)) = Float32FromFloat32(1) + return + } + **(**float32)(__ccgo_up(sin)) = X__sindf(tls, float64(x3)) + **(**float32)(__ccgo_up(cos)) = X__cosdf(tls, float64(x3)) + return + } + /* |x| ~<= 5*pi/4 */ + if ix <= uint32(0x407b53d1) { + if ix <= uint32(0x4016cbe3) { /* |x| ~<= 3pi/4 */ + if sign != 0 { + **(**float32)(__ccgo_up(sin)) = -X__cosdf(tls, float64(x3)+_s1pio2) + **(**float32)(__ccgo_up(cos)) = X__sindf(tls, float64(x3)+_s1pio2) + } else { + **(**float32)(__ccgo_up(sin)) = X__cosdf(tls, _s1pio2-float64(x3)) + **(**float32)(__ccgo_up(cos)) = X__sindf(tls, _s1pio2-float64(x3)) + } + return + } + /* -sin(x+c) is not correct if x+c could be 0: -0 vs +0 */ + if sign != 0 { + v4 = float64(x3) + _s2pio2 + } else { + v4 = float64(x3) - _s2pio2 + } + **(**float32)(__ccgo_up(sin)) = -X__sindf(tls, v4) + if sign != 0 { + v4 = float64(x3) + _s2pio2 + } else { + v4 = float64(x3) - _s2pio2 + } + **(**float32)(__ccgo_up(cos)) = -X__cosdf(tls, v4) + return + } + /* |x| ~<= 9*pi/4 */ + if ix <= uint32(0x40e231d5) { + if ix <= uint32(0x40afeddf) { /* |x| ~<= 7*pi/4 */ + if sign != 0 { + **(**float32)(__ccgo_up(sin)) = X__cosdf(tls, float64(x3)+_s3pio2) + **(**float32)(__ccgo_up(cos)) = -X__sindf(tls, float64(x3)+_s3pio2) + } else { + **(**float32)(__ccgo_up(sin)) = -X__cosdf(tls, float64(x3)-_s3pio2) + **(**float32)(__ccgo_up(cos)) = X__sindf(tls, float64(x3)-_s3pio2) + } + return + } + if sign != 0 { + v4 = float64(x3) + _s4pio2 + } else { + v4 = float64(x3) - _s4pio2 + } + **(**float32)(__ccgo_up(sin)) = X__sindf(tls, v4) + if sign != 0 { + v4 = float64(x3) + _s4pio2 + } else { + v4 = float64(x3) - _s4pio2 + } + **(**float32)(__ccgo_up(cos)) = X__cosdf(tls, v4) + return + } + /* sin(Inf or NaN) is NaN */ + if ix >= uint32(0x7f800000) { + v1 = x3 - x3 + **(**float32)(__ccgo_up(cos)) = v1 + **(**float32)(__ccgo_up(sin)) = v1 + return + } + /* general argument reduction needed */ + n = Uint32FromInt32(X__rem_pio2f(tls, x3, bp)) + s = X__sindf(tls, **(**float64)(__ccgo_up(bp))) + c = X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + switch n & Uint32FromInt32(3) { + case uint32(0): + **(**float32)(__ccgo_up(sin)) = s + **(**float32)(__ccgo_up(cos)) = c + case uint32(1): + **(**float32)(__ccgo_up(sin)) = c + **(**float32)(__ccgo_up(cos)) = -s + case uint32(2): + **(**float32)(__ccgo_up(sin)) = -s + **(**float32)(__ccgo_up(cos)) = -c + case uint32(3): + fallthrough + default: + **(**float32)(__ccgo_up(sin)) = -c + **(**float32)(__ccgo_up(cos)) = s + break + } +} + +const M_PI_26 = 0 + +func Xsincosl(tls *TLS, x float64, sin uintptr, cos uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v sin=%v cos=%v, (%v:)", tls, x, sin, cos, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* cosd at bp+8 */ float64 + var _ /* sind at bp+0 */ float64 + Xsincos(tls, x, bp, bp+8) + **(**float64)(__ccgo_up(sin)) = float64(**(**float64)(__ccgo_up(bp))) + **(**float64)(__ccgo_up(cos)) = float64(**(**float64)(__ccgo_up(bp + 8))) +} + +const M_PI_27 = 1.5707963267948966 + +// C documentation +// +// /* Small multiples of pi/2 rounded to double precision. */ + +var _s1pio21 = float64(Float64FromInt32(1) * Float64FromFloat64(1.5707963267948966)) /* 0x3FF921FB, 0x54442D18 */ +var _s2pio21 = float64(Float64FromInt32(2) * Float64FromFloat64(1.5707963267948966)) /* 0x400921FB, 0x54442D18 */ +var _s3pio21 = float64(Float64FromInt32(3) * Float64FromFloat64(1.5707963267948966)) /* 0x4012D97C, 0x7F3321D2 */ +var _s4pio21 = float64(Float64FromInt32(4) * Float64FromFloat64(1.5707963267948966)) /* 0x401921FB, 0x54442D18 */ + +func Xsinf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n, sign int32 + var y, v1 float32 + var y1, y2, v4 float64 + var _ /* y at bp+0 */ float64 + _, _, _, _, _, _, _, _ = ix, n, sign, y, y1, y2, v1, v4 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = Int32FromUint32(ix >> int32(31)) + ix = ix & uint32(0x7fffffff) + if ix <= uint32(0x3f490fda) { /* |x| ~<= pi/4 */ + if ix < uint32(0x39800000) { /* |x| < 2**-12 */ + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(4) == uint64(4) { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y = v1 + } else { + if uint64(4) == uint64(8) { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y1 = float64(v1) + } else { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y2 = float64(v1) + } + } + return x3 + } + return X__sindf(tls, float64(x3)) + } + if ix <= uint32(0x407b53d1) { /* |x| ~<= 5*pi/4 */ + if ix <= uint32(0x4016cbe3) { /* |x| ~<= 3pi/4 */ + if sign != 0 { + return -X__cosdf(tls, float64(x3)+_s1pio21) + } else { + return X__cosdf(tls, float64(x3)-_s1pio21) + } + } + if sign != 0 { + v4 = -(float64(x3) + _s2pio21) + } else { + v4 = -(float64(x3) - _s2pio21) + } + return X__sindf(tls, v4) + } + if ix <= uint32(0x40e231d5) { /* |x| ~<= 9*pi/4 */ + if ix <= uint32(0x40afeddf) { /* |x| ~<= 7*pi/4 */ + if sign != 0 { + return X__cosdf(tls, float64(x3)+_s3pio21) + } else { + return -X__cosdf(tls, float64(x3)-_s3pio21) + } + } + if sign != 0 { + v4 = float64(x3) + _s4pio21 + } else { + v4 = float64(x3) - _s4pio21 + } + return X__sindf(tls, v4) + } + /* sin(Inf or NaN) is NaN */ + if ix >= uint32(0x7f800000) { + return x3 - x3 + } + /* general argument reduction needed */ + n = X__rem_pio2f(tls, x3, bp) + switch n & Int32FromInt32(3) { + case 0: + return X__sindf(tls, **(**float64)(__ccgo_up(bp))) + case int32(1): + return X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + case int32(2): + return X__sindf(tls, -**(**float64)(__ccgo_up(bp))) + default: + return -X__cosdf(tls, **(**float64)(__ccgo_up(bp))) + } + return r +} + +const M_PI_28 = 0 + +// C documentation +// +// /* sinh(x) = (exp(x) - 1/exp(x))/2 +// * = (exp(x)-1 + (exp(x)-1)/exp(x))/2 +// * = x + x^3/6 + o(x^5) +// */ +func Xsinh(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var absx, h, t float64 + var w Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _ = absx, h, t, w + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + h = float64(0.5) + if *(*Tuint64_t)(unsafe.Pointer(bp))>>int32(63) != 0 { + h = -h + } + /* |x| */ + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + absx = *(*float64)(unsafe.Pointer(bp)) + w = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + /* |x| < log(DBL_MAX) */ + if w < uint32(0x40862e42) { + t = Xexpm1(tls, absx) + if w < uint32(0x3ff00000) { + if w < Uint32FromInt32(Int32FromInt32(0x3ff00000)-Int32FromInt32(26)<log(0x1p26)+eps could be just h*exp(x) */ + return float64(h * (t + t/(t+Float64FromInt32(1)))) + } + /* |x| > log(DBL_MAX) or nan */ + /* note: the result is stored to handle overflow */ + t = X__expo2(tls, absx, float64(Float64FromInt32(2)*h)) + return t +} + +func Xsinhf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var absx, h, t float32 + var w Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _ = absx, h, t, w + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + h = float32(0.5) + if *(*Tuint32_t)(unsafe.Pointer(bp))>>int32(31) != 0 { + h = -h + } + /* |x| */ + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + absx = *(*float32)(unsafe.Pointer(bp)) + w = *(*Tuint32_t)(unsafe.Pointer(bp)) + /* |x| < log(FLT_MAX) */ + if w < uint32(0x42b17217) { + t = Xexpm1f(tls, absx) + if w < uint32(0x3f800000) { + if w < Uint32FromInt32(Int32FromInt32(0x3f800000)-Int32FromInt32(12)< logf(FLT_MAX) or nan */ + t = X__expo2f(tls, absx, float32(Float32FromInt32(2)*h)) + return t +} + +func Xsinhl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsinh(tls, x) +} + +func Xsinl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsin(tls, x) +} + +const FENV_SUPPORT = 1 + +// C documentation +// +// /* returns a*b*2^-32 - e, with error 0 <= e < 1. */ +func _mul32(tls *TLS, a Tuint32_t, b Tuint32_t) (r Tuint32_t) { + return uint32(uint64(a) * uint64(b) >> int32(32)) +} + +// C documentation +// +// /* returns a*b*2^-64 - e, with error 0 <= e < 3. */ +func _mul64(tls *TLS, a Tuint64_t, b Tuint64_t) (r Tuint64_t) { + var ahi, alo, bhi, blo Tuint64_t + _, _, _, _ = ahi, alo, bhi, blo + ahi = a >> int32(32) + alo = a & uint64(0xffffffff) + bhi = b >> int32(32) + blo = b & uint64(0xffffffff) + return ahi*bhi + ahi*blo>>int32(32) + alo*bhi>>int32(32) +} + +func Xsqrt(tls *TLS, x1 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var d, d0, d1, d2, i, ix, m, r, s, tiny, top, u Tuint64_t + var even int32 + var t, y, y1, v1 float64 + var v2 int64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = d, d0, d1, d2, even, i, ix, m, r, s, t, tiny, top, u, y, y1, v1, v2 + /* special case handling. */ + ix = *(*Tuint64_t)(unsafe.Pointer(&x1)) + top = ix >> int32(52) + if top-uint64(0x001) >= Uint64FromInt32(Int32FromInt32(0x7ff)-Int32FromInt32(0x001)) { + /* x < 0x1p-1022 or inf or nan. */ + if ix*uint64(2) == uint64(0) { + return x1 + } + if ix == uint64(0x7ff0000000000000) { + return x1 + } + if ix > uint64(0x7ff0000000000000) { + return X__math_invalid(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float64(x1 * float64(4.503599627370496e+15)) + ix = *(*Tuint64_t)(unsafe.Pointer(&v1)) + top = ix >> int32(52) + top = top - uint64(52) + } + /* argument reduction: + x = 4^e m; with integer e, and m in [1, 4) + m: fixed point representation [2.62] + 2^e is the exponent part of the result. */ + even = Int32FromUint64(top & uint64(1)) + m = ix<> uint64(1) + } + top = (top + uint64(0x3ff)) >> int32(1) + i = ix >> Int32FromInt32(46) % uint64(128) + r = uint64(uint32(X__rsqrt_tab[i]) << int32(16)) + /* |r sqrt(m) - 1| < 0x1.fdp-9 */ + s = uint64(_mul32(tls, uint32(m>>int32(32)), uint32(r))) + /* |s/sqrt(m) - 1| < 0x1.fdp-9 */ + d = uint64(_mul32(tls, uint32(s), uint32(r))) + u = _three - d + r = uint64(_mul32(tls, uint32(r), uint32(u)) << int32(1)) + /* |r sqrt(m) - 1| < 0x1.7bp-16 */ + s = uint64(_mul32(tls, uint32(s), uint32(u)) << int32(1)) + /* |s/sqrt(m) - 1| < 0x1.7bp-16 */ + d = uint64(_mul32(tls, uint32(s), uint32(r))) + u = _three - d + r = uint64(_mul32(tls, uint32(r), uint32(u)) << int32(1)) + /* |r sqrt(m) - 1| < 0x1.3704p-29 (measured worst-case) */ + r = r << int32(32) + s = _mul64(tls, m, r) + d = _mul64(tls, s, r) + u = _three<> int32(9) + d0 = m<>int32(63) + s = s & uint64(0x000fffffffffffff) + s = s | top<=13bit table would be needed (16k). + + a newton-raphson iteration for r is + w = r*r + u = 3 - m*w + r = r*u/2 + can use a goldschmidt iteration for s at the end or + s = m*r + + first goldschmidt iteration is + s = m*r + u = 3 - s*r + r = r*u/2 + s = s*u/2 + next goldschmidt iteration is + u = 3 - s*r + r = r*u/2 + s = s*u/2 + and at the end r is not computed only s. + + they use the same amount of operations and converge at the + same quadratic rate, i.e. if + r1 sqrt(m) - 1 = e, then + r2 sqrt(m) - 1 = -3/2 e^2 - 1/2 e^3 + the advantage of goldschmidt is that the mul for s and r + are independent (computed in parallel), however it is not + "self synchronizing": it only uses the input m in the + first iteration so rounding errors accumulate. at the end + or when switching to larger precision arithmetics rounding + errors dominate so the first iteration should be used. + + the fixed point representations are + m: 2.30 r: 0.32, s: 2.30, d: 2.30, u: 2.30, three: 2.30 + and after switching to 64 bit + m: 2.62 r: 0.64, s: 2.62, d: 2.62, u: 2.62, three: 2.62 */ + +var _three = uint64(0xc0000000) + +func _mul321(tls *TLS, a Tuint32_t, b Tuint32_t) (r Tuint32_t) { + return uint32(uint64(a) * uint64(b) >> int32(32)) +} + +/* see sqrt.c for more detailed comments. */ + +func Xsqrtf(tls *TLS, x1 float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x1=%v, (%v:)", tls, x1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var d, d0, d1, d2, even, ey, i, ix, m, m0, m1, r, s, tiny, u Tuint32_t + var t, y, y1, v1 float32 + var v2 uint32 + var v3 int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = d, d0, d1, d2, even, ey, i, ix, m, m0, m1, r, s, t, tiny, u, y, y1, v1, v2, v3 + ix = *(*Tuint32_t)(unsafe.Pointer(&x1)) + if ix-uint32(0x00800000) >= Uint32FromInt32(Int32FromInt32(0x7f800000)-Int32FromInt32(0x00800000)) { + /* x < 0x1p-126 or inf or nan. */ + if ix*uint32(2) == uint32(0) { + return x1 + } + if ix == uint32(0x7f800000) { + return x1 + } + if ix > uint32(0x7f800000) { + return X__math_invalidf(tls, x1) + } + /* x is subnormal, normalize it. */ + v1 = float32(x1 * Float32FromFloat32(8.388608e+06)) + ix = *(*Tuint32_t)(unsafe.Pointer(&v1)) + ix = ix - Uint32FromInt32(Int32FromInt32(23)<> int32(1) + ey = ey + Uint32FromInt32(Int32FromInt32(0x3f800000)>>Int32FromInt32(1)) + ey = ey & uint32(0x7f800000) + i = ix >> Int32FromInt32(17) % uint32(128) + r = uint32(X__rsqrt_tab[i]) << int32(16) + /* |r*sqrt(m) - 1| < 0x1p-8 */ + s = _mul321(tls, m, r) + /* |s/sqrt(m) - 1| < 0x1p-8 */ + d = _mul321(tls, s, r) + u = _three1 - d + r = _mul321(tls, r, u) << int32(1) + /* |r*sqrt(m) - 1| < 0x1.7bp-16 */ + s = _mul321(tls, s, u) << int32(1) + /* |s/sqrt(m) - 1| < 0x1.7bp-16 */ + d = _mul321(tls, s, r) + u = _three1 - d + s = _mul321(tls, s, u) + /* -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 */ + s = (s - uint32(1)) >> int32(6) + d0 = m<>int32(31) + s = s & uint32(0x007fffff) + s = s | ey + y1 = *(*float32)(unsafe.Pointer(&s)) + if int32(FENV_SUPPORT) != 0 { + if d2 == uint32(0) { + v3 = 0 + } else { + v3 = int32(0x01000000) + } + /* handle rounding and inexact exception. */ + tiny = Uint32FromInt32(v3) + tiny = tiny | (d1^d2)&uint32(0x80000000) + t = *(*float32)(unsafe.Pointer(&tiny)) + y = y1 + t + v1 = y + goto _5 + _5: + y1 = v1 + } + return y1 +} + +/* compute r ~ 1/sqrt(m), s ~ sqrt(m) with 2 goldschmidt iterations. */ +var _three1 = uint32(0xc0000000) + +func Xsqrtl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsqrt(tls, x) +} + +func Xtan(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n uint32 + var y float32 + var y1, y2, v1 float64 + var _ /* y at bp+0 */ [2]float64 + _, _, _, _, _, _ = ix, n, y, y1, y2, v1 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(&x3)) >> int32(32)) + ix = ix & uint32(0x7fffffff) + /* |x| ~< pi/4 */ + if ix <= uint32(0x3fe921fb) { + if ix < uint32(0x3e400000) { /* |x| < 2**-27 */ + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(8) == uint64(4) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y = float32(v1) + } else { + if uint64(8) == uint64(8) { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y1 = v1 + } else { + if ix < uint32(0x00100000) { + v1 = x3 / Float64FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } + y2 = v1 + } + } + return x3 + } + return X__tan(tls, x3, float64(0), 0) + } + /* tan(Inf or NaN) is NaN */ + if ix >= uint32(0x7ff00000) { + return x3 - x3 + } + /* argument reduction */ + n = Uint32FromInt32(X__rem_pio2(tls, x3, bp)) + return X__tan(tls, (**(**[2]float64)(__ccgo_up(bp)))[0], (**(**[2]float64)(__ccgo_up(bp)))[int32(1)], Int32FromUint32(n&uint32(1))) +} + +const M_PI_29 = 1.5707963267948966 + +// C documentation +// +// /* Small multiples of pi/2 rounded to double precision. */ + +var _t1pio2 = float64(Float64FromInt32(1) * Float64FromFloat64(1.5707963267948966)) /* 0x3FF921FB, 0x54442D18 */ +var _t2pio2 = float64(Float64FromInt32(2) * Float64FromFloat64(1.5707963267948966)) /* 0x400921FB, 0x54442D18 */ +var _t3pio2 = float64(Float64FromInt32(3) * Float64FromFloat64(1.5707963267948966)) /* 0x4012D97C, 0x7F3321D2 */ +var _t4pio2 = float64(Float64FromInt32(4) * Float64FromFloat64(1.5707963267948966)) /* 0x401921FB, 0x54442D18 */ + +func Xtanf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ix Tuint32_t + var n, sign uint32 + var y, v1 float32 + var y1, y2, v4 float64 + var _ /* y at bp+0 */ float64 + _, _, _, _, _, _, _, _ = ix, n, sign, y, y1, y2, v1, v4 + ix = *(*Tuint32_t)(unsafe.Pointer(&x3)) + sign = ix >> int32(31) + ix = ix & uint32(0x7fffffff) + if ix <= uint32(0x3f490fda) { /* |x| ~<= pi/4 */ + if ix < uint32(0x39800000) { /* |x| < 2**-12 */ + /* raise inexact if x!=0 and underflow if subnormal */ + if uint64(4) == uint64(4) { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y = v1 + } else { + if uint64(4) == uint64(8) { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y1 = float64(v1) + } else { + if ix < uint32(0x00800000) { + v1 = x3 / Float32FromFloat32(1.329227995784916e+36) + } else { + v1 = x3 + Float32FromFloat32(1.329227995784916e+36) + } + y2 = float64(v1) + } + } + return x3 + } + return X__tandf(tls, float64(x3), 0) + } + if ix <= uint32(0x407b53d1) { /* |x| ~<= 5*pi/4 */ + if ix <= uint32(0x4016cbe3) { /* |x| ~<= 3pi/4 */ + if sign != 0 { + v4 = float64(x3) + _t1pio2 + } else { + v4 = float64(x3) - _t1pio2 + } + return X__tandf(tls, v4, int32(1)) + } else { + if sign != 0 { + v4 = float64(x3) + _t2pio2 + } else { + v4 = float64(x3) - _t2pio2 + } + return X__tandf(tls, v4, 0) + } + } + if ix <= uint32(0x40e231d5) { /* |x| ~<= 9*pi/4 */ + if ix <= uint32(0x40afeddf) { /* |x| ~<= 7*pi/4 */ + if sign != 0 { + v4 = float64(x3) + _t3pio2 + } else { + v4 = float64(x3) - _t3pio2 + } + return X__tandf(tls, v4, int32(1)) + } else { + if sign != 0 { + v4 = float64(x3) + _t4pio2 + } else { + v4 = float64(x3) - _t4pio2 + } + return X__tandf(tls, v4, 0) + } + } + /* tan(Inf or NaN) is NaN */ + if ix >= uint32(0x7f800000) { + return x3 - x3 + } + /* argument reduction */ + n = Uint32FromInt32(X__rem_pio2f(tls, x3, bp)) + return X__tandf(tls, **(**float64)(__ccgo_up(bp)), Int32FromUint32(n&uint32(1))) +} + +const M_PI_210 = 0 + +// C documentation +// +// /* tanh(x) = (exp(x) - exp(-x))/(exp(x) + exp(-x)) +// * = (exp(2*x) - 1)/(exp(2*x) - 1 + 2) +// * = (1 - exp(-2*x))/(exp(-2*x) - 1 + 2) +// */ +func Xtanh(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var sign int32 + var t, v1 Tdouble_t + var w Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _ = sign, t, w, y, y1, y2, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + /* x = |x| */ + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + *(*Tuint64_t)(unsafe.Pointer(bp)) &= Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(2) + x3 = *(*float64)(unsafe.Pointer(bp)) + w = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + if w > uint32(0x3fe193ea) { + /* |x| > log(3)/2 ~= 0.5493 or nan */ + if w > uint32(0x40340000) { + /* |x| > 20 or nan */ + /* note: this branch avoids raising overflow */ + t = Float64FromInt32(1) - Float64FromInt32(0)/x3 + } else { + t = Xexpm1(tls, float64(Float64FromInt32(2)*x3)) + t = Float64FromInt32(1) - Float64FromInt32(2)/(t+Float64FromInt32(2)) + } + } else { + if w > uint32(0x3fd058ae) { + /* |x| > log(5/3)/2 ~= 0.2554 */ + t = Xexpm1(tls, float64(Float64FromInt32(2)*x3)) + t = t / (t + Float64FromInt32(2)) + } else { + if w >= uint32(0x00100000) { + /* |x| >= 0x1p-1022, up to 2ulp error in [0.1,0.2554] */ + t = Xexpm1(tls, float64(float64(-Int32FromInt32(2))*x3)) + t = -t / (t + Float64FromInt32(2)) + } else { + /* |x| is subnormal */ + /* note: the branch above would not raise underflow in [0x1p-1023,0x1p-1022) */ + if uint64(4) == uint64(4) { + y = float32(x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3)) + } else { + y2 = float64(float32(x3)) + } + } + t = x3 + } + } + } + if sign != 0 { + v1 = -t + } else { + v1 = t + } + return v1 +} + +func Xtanhf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var sign int32 + var t, y, v1 float32 + var w Tuint32_t + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _ = sign, t, w, y, y1, y2, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + /* x = |x| */ + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x7fffffff) + x3 = *(*float32)(unsafe.Pointer(bp)) + w = *(*Tuint32_t)(unsafe.Pointer(bp)) + if w > uint32(0x3f0c9f54) { + /* |x| > log(3)/2 ~= 0.5493 or nan */ + if w > uint32(0x41200000) { + /* |x| > 10 */ + t = Float32FromInt32(1) + Float32FromInt32(0)/x3 + } else { + t = Xexpm1f(tls, float32(Float32FromInt32(2)*x3)) + t = Float32FromInt32(1) - Float32FromInt32(2)/(t+Float32FromInt32(2)) + } + } else { + if w > uint32(0x3e82c578) { + /* |x| > log(5/3)/2 ~= 0.2554 */ + t = Xexpm1f(tls, float32(Float32FromInt32(2)*x3)) + t = t / (t + Float32FromInt32(2)) + } else { + if w >= uint32(0x00800000) { + /* |x| >= 0x1p-126 */ + t = Xexpm1f(tls, float32(float32(-Int32FromInt32(2))*x3)) + t = -t / (t + Float32FromInt32(2)) + } else { + /* |x| is subnormal */ + if uint64(4) == uint64(4) { + y = float32(x3 * x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 * x3) + } else { + y2 = float64(x3 * x3) + } + } + t = x3 + } + } + } + if sign != 0 { + v1 = -t + } else { + v1 = t + } + return v1 +} + +func Xtanhl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtanh(tls, x) +} + +func Xtanl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtan(tls, x) +} + +const N10 = 12 + +var _pi4 = float64(3.141592653589793) + +// C documentation +// +// /* sin(pi x) with x > 0x1p-100, if sin(pi*x)==0 the sign is arbitrary */ +func _sinpi(tls *TLS, x float64) (r float64) { + var n int32 + _ = n + /* argument reduction: x = |x| mod 2 */ + /* spurious inexact when x is odd int */ + x = float64(x * float64(0.5)) + x = float64(Float64FromInt32(2) * (x - Xfloor(tls, x))) + /* reduce x into [-.25,.25] */ + n = int32(Float64FromInt32(4) * x) + n = (n + int32(1)) / int32(2) + x = x - float64(float64(n)*float64(0.5)) + x = x * _pi4 + switch n { + default: /* case 4 */ + fallthrough + case 0: + return X__sin(tls, x, Float64FromInt32(0), 0) + case int32(1): + return X__cos(tls, x, Float64FromInt32(0)) + case int32(2): + return X__sin(tls, -x, Float64FromInt32(0), 0) + case int32(3): + return -X__cos(tls, x, Float64FromInt32(0)) + } + return r +} + +// C documentation +// +// //static const double g = 6.024680040776729583740234375; +var _gmhalf = float64(5.52468004077673) +var _Snum = [13]float64{ + 0: float64(2.353137688041076e+10), + 1: float64(4.29198036426491e+10), + 2: float64(3.571195923735567e+10), + 3: float64(1.792103442603721e+10), + 4: float64(6.039542586352028e+09), + 5: float64(1.4397204073117216e+09), + 6: float64(2.4887455786205417e+08), + 7: float64(3.1426415585400194e+07), + 8: float64(2.8763706289353725e+06), + 9: float64(186056.26539522348), + 10: float64(8071.672002365816), + 11: float64(210.82427775157936), + 12: float64(2.5066282746310002), +} +var _Sden = [13]float64{ + 1: Float64FromInt32(39916800), + 2: Float64FromInt32(120543840), + 3: Float64FromInt32(150917976), + 4: Float64FromInt32(105258076), + 5: Float64FromInt32(45995730), + 6: Float64FromInt32(13339535), + 7: Float64FromInt32(2637558), + 8: Float64FromInt32(357423), + 9: Float64FromInt32(32670), + 10: Float64FromInt32(1925), + 11: Float64FromInt32(66), + 12: Float64FromInt32(1), +} + +// C documentation +// +// /* n! for small integer n */ +var _fact = [23]float64{ + 0: Float64FromInt32(1), + 1: Float64FromInt32(1), + 2: Float64FromInt32(2), + 3: Float64FromInt32(6), + 4: Float64FromInt32(24), + 5: Float64FromInt32(120), + 6: Float64FromInt32(720), + 7: float64(5040), + 8: float64(40320), + 9: float64(362880), + 10: float64(3.6288e+06), + 11: float64(3.99168e+07), + 12: float64(4.790016e+08), + 13: float64(6.2270208e+09), + 14: float64(8.71782912e+10), + 15: float64(1.307674368e+12), + 16: float64(2.0922789888e+13), + 17: float64(3.55687428096e+14), + 18: float64(6.402373705728e+15), + 19: float64(1.21645100408832e+17), + 20: float64(2.43290200817664e+18), + 21: float64(5.109094217170944e+19), + 22: float64(1.1240007277776077e+21), +} + +// C documentation +// +// /* S(x) rational function for positive x */ +func _S(tls *TLS, x float64) (r float64) { + var den, num Tdouble_t + var i int32 + _, _, _ = den, i, num + num = Float64FromInt32(0) + den = Float64FromInt32(0) + /* to avoid overflow handle large x differently */ + if x < Float64FromInt32(8) { + i = int32(N10) + for { + if !(i >= 0) { + break + } + num = Tdouble_t(num*x) + _Snum[i] + den = Tdouble_t(den*x) + _Sden[i] + goto _1 + _1: + ; + i = i - 1 + } + } else { + i = 0 + for { + if !(i <= int32(N10)) { + break + } + num = num/x + _Snum[i] + den = den/x + _Sden[i] + goto _2 + _2: + ; + i = i + 1 + } + } + return num / den +} + +func Xtgamma(tls *TLS, x3 float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var absx, y1, y2, y3, v1 float64 + var dy, r, z Tdouble_t + var ix Tuint32_t + var sign int32 + var y float32 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _ = absx, dy, ix, r, sign, y, y1, y2, y3, z, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + ix = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(63)) + /* special cases */ + if ix >= uint32(0x7ff00000) { + /* tgamma(nan)=nan, tgamma(inf)=inf, tgamma(-inf)=nan with invalid */ + return x3 + float64(X__builtin_inff(tls)) + } + if ix < Uint32FromInt32((Int32FromInt32(0x3ff)-Int32FromInt32(54))<= 172: tgamma(x)=inf with overflow */ + /* x =< -184: tgamma(x)=+-0 with underflow */ + if ix >= uint32(0x40670000) { /* |x| >= 184 */ + if sign != 0 { + if uint64(4) == uint64(4) { + y = float32(Float64FromFloat64(1.1754943508222875e-38) / x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(Float64FromFloat64(1.1754943508222875e-38) / x3)) + } else { + y2 = float64(float32(Float64FromFloat64(1.1754943508222875e-38) / x3)) + } + } + if float64(Xfloor(tls, x3)*float64(0.5)) == Xfloor(tls, float64(x3*float64(0.5))) { + return Float64FromInt32(0) + } + return -Float64FromFloat64(0) + } + x3 = x3 * float64(8.98846567431158e+307) + return x3 + } + if sign != 0 { + v1 = -x3 + } else { + v1 = x3 + } + absx = v1 + /* handle the error of x + g - 0.5 */ + y3 = absx + _gmhalf + if absx > _gmhalf { + dy = y3 - absx + dy = dy - _gmhalf + } else { + dy = y3 - _gmhalf + dy = dy - absx + } + z = absx - float64(0.5) + r = Tdouble_t(_S(tls, absx) * Xexp(tls, -y3)) + if x3 < Float64FromInt32(0) { + /* reflection formula for negative x */ + /* sinpi(absx) is not 0, integers are already handled */ + r = -_pi4 / float64(float64(_sinpi(tls, absx)*absx)*r) + dy = -dy + z = -z + } + r = r + Tdouble_t(Tdouble_t(dy*(_gmhalf+Float64FromFloat64(0.5)))*r)/y3 + z = Xpow(tls, y3, float64(float64(0.5)*z)) + y3 = float64(Tdouble_t(r*z) * z) + return y3 +} + +func Xtgammaf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float32(Xtgamma(tls, float64(x))) +} + +func Xtgammal(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtgamma(tls, x) +} + +func Xtrunc(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var m Tuint64_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _ = e, m, y, y1, y2 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp))>>Int32FromInt32(52)&Uint64FromInt32(0x7ff)) - int32(0x3ff) + int32(12) + if e >= Int32FromInt32(52)+Int32FromInt32(12) { + return x3 + } + if e < int32(12) { + e = int32(1) + } + m = uint64(-Uint64FromUint64(1) >> e) + if *(*Tuint64_t)(unsafe.Pointer(bp))&m == uint64(0) { + return x3 + } + if uint64(8) == uint64(4) { + y = float32(x3 + Float64FromFloat32(1.329227995784916e+36)) + } else { + if uint64(8) == uint64(8) { + y1 = x3 + Float64FromFloat32(1.329227995784916e+36) + } else { + y2 = float64(x3 + Float64FromFloat32(1.329227995784916e+36)) + } + } + *(*Tuint64_t)(unsafe.Pointer(bp)) &= ^m + return *(*float64)(unsafe.Pointer(bp)) +} + +func Xtruncf(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e int32 + var m Tuint32_t + var y float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _ = e, m, y, y1, y2 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + e = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp))>>Int32FromInt32(23)&Uint32FromInt32(0xff)) - int32(0x7f) + int32(9) + if e >= Int32FromInt32(23)+Int32FromInt32(9) { + return x3 + } + if e < int32(9) { + e = int32(1) + } + m = -Uint32FromUint32(1) >> e + if *(*Tuint32_t)(unsafe.Pointer(bp))&m == uint32(0) { + return x3 + } + if uint64(4) == uint64(4) { + y = x3 + Float32FromFloat32(1.329227995784916e+36) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } else { + y2 = float64(x3 + Float32FromFloat32(1.329227995784916e+36)) + } + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= ^m + return *(*float32)(unsafe.Pointer(bp)) +} + +func Xtruncl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xtrunc(tls, x) +} + +var _digits = [65]uint8{'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} + +func Xa64l(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d uintptr + var e int32 + var x Tuint32_t + _, _, _ = d, e, x + x = uint32(0) + e = 0 + for { + if !(e < int32(36) && **(**uint8)(__ccgo_up(s)) != 0) { + break + } + d = Xstrchr(tls, uintptr(unsafe.Pointer(&_digits)), Int32FromUint8(**(**uint8)(__ccgo_up(s)))) + if !(d != 0) { + break + } + x = x | Uint32FromInt64(int64(d)-t__predefined_ptrdiff_t(uintptr(unsafe.Pointer(&_digits))))< %v", r) }() + } + var p uintptr + var x Tuint32_t + _, _ = p, x + x = Uint32FromInt64(x0) + p = uintptr(unsafe.Pointer(&_s)) + for { + if !(x != 0) { + break + } + **(**uint8)(__ccgo_up(p)) = _digits[x&uint32(63)] + goto _1 + _1: + ; + p = p + 1 + x = x >> uint32(6) + } + **(**uint8)(__ccgo_up(p)) = uint8(0) + return uintptr(unsafe.Pointer(&_s)) +} + +var _s [7]uint8 + +func Xbasename(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i Tsize_t + _ = i + if !(s != 0) || !(**(**uint8)(__ccgo_up(s)) != 0) { + return __ccgo_ts + 558 + } + i = _strlen(tls, s) - uint64(1) + for { + if !(i != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(i)))) == int32('/')) { + break + } + **(**uint8)(__ccgo_up(s + uintptr(i))) = uint8(0) + goto _1 + _1: + ; + i = i - 1 + } + for { + if !(i != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(i-uint64(1))))) != int32('/')) { + break + } + goto _2 + _2: + ; + i = i - 1 + } + return s + uintptr(i) +} + +func X__xpg_basename(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xbasename(tls, s) +} + +func Xdirname(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i Tsize_t + _ = i + if !(s != 0) || !(**(**uint8)(__ccgo_up(s)) != 0) { + return __ccgo_ts + 558 + } + i = _strlen(tls, s) - uint64(1) + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(i)))) == int32('/')) { + break + } + if !(i != 0) { + return __ccgo_ts + 570 + } + goto _1 + _1: + ; + i = i - 1 + } + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(i)))) != int32('/')) { + break + } + if !(i != 0) { + return __ccgo_ts + 558 + } + goto _2 + _2: + ; + i = i - 1 + } + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(i)))) == int32('/')) { + break + } + if !(i != 0) { + return __ccgo_ts + 570 + } + goto _3 + _3: + ; + i = i - 1 + } + **(**uint8)(__ccgo_up(s + uintptr(i+uint64(1)))) = uint8(0) + return s +} + +func Xffs(tls *TLS, i int32) (r int32) { + if __ccgo_strace { + trc("tls=%v i=%v, (%v:)", tls, i, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if i != 0 { + v1 = _a_ctz_l(tls, Uint64FromInt32(i)) + int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xffsl(tls *TLS, i int64) (r int32) { + if __ccgo_strace { + trc("tls=%v i=%v, (%v:)", tls, i, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if i != 0 { + v1 = _a_ctz_l(tls, Uint64FromInt64(i)) + int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xffsll(tls *TLS, i int64) (r int32) { + if __ccgo_strace { + trc("tls=%v i=%v, (%v:)", tls, i, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v3 int32 + var v2 Tuint64_t + _, _, _ = v1, v2, v3 + if i != 0 { + v2 = Uint64FromInt64(i) + // __asm__( + // + // " rbit %0, %1\n clz %0, %0\n" + // : "=r"(x) : "r"(x)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 70, __ccgo_ts+572) + v3 = Int32FromUint64(v2) + goto _4 + _4: + v1 = v3 + int32(1) + } else { + v1 = 0 + } + return v1 +} + +const MM_APPL = 8 +const MM_CONSOLE = 512 +const MM_ERROR = 2 +const MM_FIRM = 4 +const MM_HALT = 1 +const MM_HARD = 1 +const MM_INFO = 4 +const MM_NOCON = 4 +const MM_NOMSG = 1 +const MM_NOSEV = 0 +const MM_NOTOK = -1 +const MM_NRECOV = 128 +const MM_NULLMC = 0 +const MM_NULLSEV = 0 +const MM_OK = 0 +const MM_OPSYS = 32 +const MM_PRINT = 256 +const MM_RECOVER = 64 +const MM_SOFT = 2 +const MM_UTIL = 16 +const MM_WARNING = 3 + +// C documentation +// +// /* +// * If lstr is the first part of bstr, check that the next char in bstr +// * is either \0 or : +// */ +func __strcolcmp(tls *TLS, lstr uintptr, bstr uintptr) (r int32) { + var i Tsize_t + _ = i + i = uint64(0) + for **(**uint8)(__ccgo_up(lstr + uintptr(i))) != 0 && **(**uint8)(__ccgo_up(bstr + uintptr(i))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(bstr + uintptr(i)))) == Int32FromUint8(**(**uint8)(__ccgo_up(lstr + uintptr(i)))) { + i = i + 1 + } + if **(**uint8)(__ccgo_up(lstr + uintptr(i))) != 0 || **(**uint8)(__ccgo_up(bstr + uintptr(i))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(bstr + uintptr(i)))) != int32(':') { + return int32(1) + } + return 0 +} + +func Xfmtmsg(tls *TLS, classification int64, label uintptr, severity int32, text uintptr, action uintptr, tag uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v classification=%v label=%v severity=%v text=%v action=%v tag=%v, (%v:)", tls, classification, label, severity, text, action, tag, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var cmsg, errstring, v1, v2, v3, v4, v5, v6, v7, v8 uintptr + var consolefd, i, ret, verb int32 + var msgs [6]uintptr + var _ /* cs at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cmsg, consolefd, errstring, i, msgs, ret, verb, v1, v2, v3, v4, v5, v6, v7, v8 + ret = 0 + verb = 0 + errstring = uintptr(MM_NULLSEV) + cmsg = Xgetenv(tls, __ccgo_ts+578) + msgs = [6]uintptr{ + 0: __ccgo_ts + 586, + 1: __ccgo_ts + 592, + 2: __ccgo_ts + 601, + 3: __ccgo_ts + 606, + 4: __ccgo_ts + 613, + 5: UintptrFromInt32(0), + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + if severity == int32(MM_HALT) { + errstring = __ccgo_ts + 617 + } else { + if severity == int32(MM_ERROR) { + errstring = __ccgo_ts + 624 + } else { + if severity == int32(MM_WARNING) { + errstring = __ccgo_ts + 632 + } else { + if severity == int32(MM_INFO) { + errstring = __ccgo_ts + 642 + } + } + } + } + if classification&int64(MM_CONSOLE) != 0 { + consolefd = Xopen(tls, __ccgo_ts+649, int32(O_WRONLY), 0) + if consolefd < 0 { + ret = int32(MM_NOCON) + } else { + if label != 0 { + v1 = label + } else { + v1 = __ccgo_ts + } + if label != 0 { + v2 = __ccgo_ts + 289 + } else { + v2 = __ccgo_ts + } + if severity != 0 { + v3 = errstring + } else { + v3 = __ccgo_ts + } + if text != 0 { + v4 = text + } else { + v4 = __ccgo_ts + } + if action != 0 { + v5 = __ccgo_ts + 662 + } else { + v5 = __ccgo_ts + } + if action != 0 { + v6 = action + } else { + v6 = __ccgo_ts + } + if action != 0 { + v7 = __ccgo_ts + 672 + } else { + v7 = __ccgo_ts + } + if tag != 0 { + v8 = tag + } else { + v8 = __ccgo_ts + } + if Xdprintf(tls, consolefd, __ccgo_ts+674, VaList(bp+16, v1, v2, v3, v4, v5, v6, v7, v8)) < int32(1) { + ret = int32(MM_NOCON) + } + Xclose(tls, consolefd) + } + } + if classification&int64(MM_PRINT) != 0 { + for cmsg != 0 && **(**uint8)(__ccgo_up(cmsg)) != 0 { + i = 0 + for { + if !(msgs[i] != 0) { + break + } + if !(__strcolcmp(tls, msgs[i], cmsg) != 0) { + break + } + goto _9 + _9: + ; + i = i + 1 + } + if msgs[i] == UintptrFromInt32(0) { + //ignore MSGVERB-unrecognized component + verb = int32(0xFF) + break + } else { + verb = verb | int32(1)< %v", r) }() + } + bp := tls.Alloc(256) + defer tls.Free(256) + var res uintptr + var _ /* a at bp+0 */ Tstat + var _ /* b at bp+128 */ Tstat + _ = res + res = Xgetenv(tls, __ccgo_ts+692) + if res != 0 && **(**uint8)(__ccgo_up(res)) != 0 && !(Xstat(tls, res, bp) != 0) && !(Xstat(tls, __ccgo_ts+558, bp+128) != 0) && (**(**Tstat)(__ccgo_up(bp))).Fst_dev == (**(**Tstat)(__ccgo_up(bp + 128))).Fst_dev && (**(**Tstat)(__ccgo_up(bp))).Fst_ino == (**(**Tstat)(__ccgo_up(bp + 128))).Fst_ino { + return Xstrdup(tls, res) + } + return Xgetcwd(tls, uintptr(0), uint64(0)) +} + +func X__getauxval(tls *TLS, item uint64) (r uint64) { + if __ccgo_strace { + trc("tls=%v item=%v, (%v:)", tls, item, origin(2)) + defer func() { trc("-> %v", r) }() + } + var auxv uintptr + _ = auxv + auxv = X__libc.Fauxv + if item == uint64(AT_SECURE) { + return uint64(X__libc.Fsecure) + } + for { + if !(**(**Tsize_t)(__ccgo_up(auxv)) != 0) { + break + } + if **(**Tsize_t)(__ccgo_up(auxv)) == item { + return **(**Tsize_t)(__ccgo_up(auxv + 1*8)) + } + goto _1 + _1: + ; + auxv = auxv + uintptr(2)*8 + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uint64(0) +} + +func Xgetauxval(tls *TLS, item uint64) (r uint64) { + if __ccgo_strace { + trc("tls=%v item=%v, (%v:)", tls, item, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__getauxval(tls, item) +} + +type Tutsname = struct { + Fsysname [65]uint8 + Fnodename [65]uint8 + Frelease [65]uint8 + Fversion [65]uint8 + Fmachine [65]uint8 + Fdomainname [65]uint8 +} + +func Xgetdomainname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v len1=%v, (%v:)", tls, name, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(400) + defer tls.Free(400) + var _ /* temp at bp+0 */ Tutsname + Xuname(tls, bp) + if !(len1 != 0) || _strlen(tls, bp+325) >= len1 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + Xstrcpy(tls, name, bp+325) + return 0 +} + +func Xgetentropy(tls *TLS, buffer uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v buffer=%v len1=%v, (%v:)", tls, buffer, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var pos uintptr + var ret int32 + var _ /* cs at bp+0 */ int32 + _, _ = pos, ret + ret = 0 + pos = buffer + if len1 > uint64(256) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EIO) + return -int32(1) + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + for len1 != 0 { + ret = int32(Xgetrandom(tls, pos, len1, uint32(0))) + if ret < 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EINTR) { + continue + } else { + break + } + } + pos = pos + uintptr(ret) + len1 = len1 - Uint64FromInt32(ret) + ret = 0 + } + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) + return ret +} + +func Xgethostid(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +const optpos = 0 + +type t__ucontext1 = Tucontext_t1 + +func X__getopt_msg(tls *TLS, a uintptr, b uintptr, c uintptr, l Tsize_t) { + if __ccgo_strace { + trc("tls=%v a=%v b=%v c=%v l=%v, (%v:)", tls, a, b, c, l, origin(2)) + } + var __need_unlock, v1 int32 + var f uintptr + _, _, _ = __need_unlock, f, v1 + f = uintptr(unsafe.Pointer(&X__stderr_FILE)) + b = X__lctrans_cur(tls, b) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + _ = Xfputs(tls, a, f) >= 0 && Xfwrite(tls, b, _strlen(tls, b), uint64(1), f) != 0 && Xfwrite(tls, c, uint64(1), l, f) == l && Xputc(tls, int32('\n'), f) != 0 + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xgetopt(tls *TLS, argc int32, argv uintptr, optstring uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v argc=%v argv=%v optstring=%v, (%v:)", tls, argc, argv, optstring, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, k, l, v1 int32 + var optchar uintptr + var _ /* c at bp+0 */ Twchar_t + var _ /* d at bp+4 */ Twchar_t + _, _, _, _, _ = i, k, l, optchar, v1 + if !(Xoptind != 0) || Xoptreset != 0 { + Xoptreset = 0 + X__optpos = 0 + Xoptind = int32(1) + } + if Xoptind >= argc || !(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) != 0) { + return -int32(1) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))))) != int32('-') { + if Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) == int32('-') { + v1 = Xoptind + Xoptind = Xoptind + 1 + Xoptarg = **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8)) + return int32(1) + } + return -int32(1) + } + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1)) != 0) { + return -int32(1) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1))) == int32('-') && !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 2)) != 0) { + Xoptind = Xoptind + 1 + return -Int32FromInt32(1) + } + if !(X__optpos != 0) { + X__optpos = X__optpos + 1 + } + v1 = Xmbtowc(tls, bp, **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))+uintptr(X__optpos), uint64(MB_LEN_MAX)) + k = v1 + if v1 < 0 { + k = int32(1) + **(**Twchar_t)(__ccgo_up(bp)) = uint32(0xfffd) /* replacement char */ + } + optchar = **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + uintptr(X__optpos) + X__optpos = X__optpos + k + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + uintptr(X__optpos))) != 0) { + Xoptind = Xoptind + 1 + X__optpos = 0 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) == int32('-') || Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) == int32('+') { + optstring = optstring + 1 + } + i = 0 + **(**Twchar_t)(__ccgo_up(bp + 4)) = uint32(0) + for cond := true; cond; cond = l != 0 && **(**Twchar_t)(__ccgo_up(bp + 4)) != **(**Twchar_t)(__ccgo_up(bp)) { + l = Xmbtowc(tls, bp+4, optstring+uintptr(i), uint64(MB_LEN_MAX)) + if l > 0 { + i = i + l + } else { + i = i + 1 + } + } + if **(**Twchar_t)(__ccgo_up(bp + 4)) != **(**Twchar_t)(__ccgo_up(bp)) || **(**Twchar_t)(__ccgo_up(bp)) == uint32(':') { + Xoptopt = Int32FromUint32(**(**Twchar_t)(__ccgo_up(bp))) + if Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) != int32(':') && Xopterr != 0 { + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), __ccgo_ts+696, optchar, Uint64FromInt32(k)) + } + return int32('?') + } + if Int32FromUint8(**(**uint8)(__ccgo_up(optstring + uintptr(i)))) == int32(':') { + Xoptarg = uintptr(0) + if Int32FromUint8(**(**uint8)(__ccgo_up(optstring + uintptr(i+int32(1))))) != int32(':') || X__optpos != 0 { + v1 = Xoptind + Xoptind = Xoptind + 1 + Xoptarg = **(**uintptr)(__ccgo_up(argv + uintptr(v1)*8)) + if X__optpos != 0 { + Xoptarg = Xoptarg + uintptr(X__optpos) + } + X__optpos = 0 + } + if Xoptind > argc { + Xoptopt = Int32FromUint32(**(**Twchar_t)(__ccgo_up(bp))) + if Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) == int32(':') { + return int32(':') + } + if Xopterr != 0 { + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), __ccgo_ts+720, optchar, Uint64FromInt32(k)) + } + return int32('?') + } + } + return Int32FromUint32(**(**Twchar_t)(__ccgo_up(bp))) +} + +func X__posix_getopt(tls *TLS, argc int32, argv uintptr, optstring uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v argc=%v argv=%v optstring=%v, (%v:)", tls, argc, argv, optstring, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetopt(tls, argc, argv, optstring) +} + +const no_argument = 0 +const optional_argument = 2 +const required_argument = 1 + +type Toption = struct { + Fname uintptr + Fhas_arg int32 + Fflag uintptr + Fval int32 +} + +func _permute(tls *TLS, argv uintptr, dest int32, src int32) { + var av, tmp uintptr + var i int32 + _, _, _ = av, i, tmp + av = argv + tmp = **(**uintptr)(__ccgo_up(av + uintptr(src)*8)) + i = src + for { + if !(i > dest) { + break + } + **(**uintptr)(__ccgo_up(av + uintptr(i)*8)) = **(**uintptr)(__ccgo_up(av + uintptr(i-int32(1))*8)) + goto _1 + _1: + ; + i = i - 1 + } + **(**uintptr)(__ccgo_up(av + uintptr(dest)*8)) = tmp +} + +func ___getopt_long(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr, longonly int32) (r int32) { + var cnt, i, i1, resumed, ret, skipped int32 + _, _, _, _, _, _ = cnt, i, i1, resumed, ret, skipped + if !(Xoptind != 0) || Xoptreset != 0 { + Xoptreset = 0 + X__optpos = 0 + Xoptind = int32(1) + } + if Xoptind >= argc || !(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) != 0) { + return -int32(1) + } + skipped = Xoptind + if Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) != int32('+') && Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) != int32('-') { + i = Xoptind + for { + if i >= argc || !(**(**uintptr)(__ccgo_up(argv + uintptr(i)*8)) != 0) { + return -int32(1) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(i)*8))))) == int32('-') && **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(i)*8)) + 1)) != 0 { + break + } + goto _1 + _1: + ; + i = i + 1 + } + Xoptind = i + } + resumed = Xoptind + ret = ___getopt_long_core(tls, argc, argv, optstring, longopts, idx, longonly) + if resumed > skipped { + cnt = Xoptind - resumed + i1 = 0 + for { + if !(i1 < cnt) { + break + } + _permute(tls, argv, skipped, Xoptind-int32(1)) + goto _2 + _2: + ; + i1 = i1 + 1 + } + Xoptind = skipped + cnt + } + return ret +} + +func ___getopt_long_core(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr, longonly int32) (r int32) { + var arg, name, opt, start, v5 uintptr + var cnt, colon, i, j, l, match, v2 int32 + _, _, _, _, _, _, _, _, _, _, _, _ = arg, cnt, colon, i, j, l, match, name, opt, start, v2, v5 + Xoptarg = uintptr(0) + if longopts != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))))) == int32('-') && (longonly != 0 && **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1))) != int32('-') || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1))) == int32('-') && **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 2)) != 0) { + colon = BoolInt32(Int32FromUint8(**(**uint8)(__ccgo_up(optstring + BoolUintptr(Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) == int32('+') || Int32FromUint8(**(**uint8)(__ccgo_up(optstring))) == int32('-'))))) == int32(':')) + start = **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + uintptr(1) + v2 = Int32FromInt32(0) + i = v2 + cnt = v2 + for { + if !((**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname != 0) { + break + } + name = (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname + opt = start + if Int32FromUint8(**(**uint8)(__ccgo_up(opt))) == int32('-') { + opt = opt + 1 + } + for **(**uint8)(__ccgo_up(opt)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(opt))) != int32('=') && Int32FromUint8(**(**uint8)(__ccgo_up(opt))) == Int32FromUint8(**(**uint8)(__ccgo_up(name))) { + name = name + 1 + opt = opt + 1 + } + if **(**uint8)(__ccgo_up(opt)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(opt))) != int32('=') { + goto _1 + } + arg = opt + match = i + if !(**(**uint8)(__ccgo_up(name)) != 0) { + cnt = int32(1) + break + } + cnt = cnt + 1 + goto _1 + _1: + ; + i = i + 1 + } + if cnt == int32(1) && longonly != 0 && int64(arg)-int64(start) == int64(Xmblen(tls, start, uint64(MB_LEN_MAX))) { + l = int32(int64(arg) - int64(start)) + i = 0 + for { + if !(**(**uint8)(__ccgo_up(optstring + uintptr(i))) != 0) { + break + } + j = 0 + for { + if !(j < l && Int32FromUint8(**(**uint8)(__ccgo_up(start + uintptr(j)))) == Int32FromUint8(**(**uint8)(__ccgo_up(optstring + uintptr(i+j))))) { + break + } + goto _4 + _4: + ; + j = j + 1 + } + if j == l { + cnt = cnt + 1 + break + } + goto _3 + _3: + ; + i = i + 1 + } + } + if cnt == int32(1) { + i = match + opt = arg + Xoptind = Xoptind + 1 + if Int32FromUint8(**(**uint8)(__ccgo_up(opt))) == int32('=') { + if !((**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fhas_arg != 0) { + Xoptopt = (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fval + if colon != 0 || !(Xopterr != 0) { + return int32('?') + } + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), __ccgo_ts+752, (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname, _strlen(tls, (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname)) + return int32('?') + } + Xoptarg = opt + uintptr(1) + } else { + if (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fhas_arg == int32(required_argument) { + v5 = **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + Xoptarg = v5 + if !(v5 != 0) { + Xoptopt = (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fval + if colon != 0 { + return int32(':') + } + if !(Xopterr != 0) { + return int32('?') + } + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), __ccgo_ts+720, (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname, _strlen(tls, (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fname)) + return int32('?') + } + Xoptind = Xoptind + 1 + } + } + if idx != 0 { + **(**int32)(__ccgo_up(idx)) = i + } + if (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fflag != 0 { + **(**int32)(__ccgo_up((**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fflag)) = (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fval + return 0 + } + return (**(**Toption)(__ccgo_up(longopts + uintptr(i)*32))).Fval + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8)) + 1))) == int32('-') { + Xoptopt = 0 + if !(colon != 0) && Xopterr != 0 { + if cnt != 0 { + v5 = __ccgo_ts + 789 + } else { + v5 = __ccgo_ts + 696 + } + X__getopt_msg(tls, **(**uintptr)(__ccgo_up(argv)), v5, **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))+uintptr(2), _strlen(tls, **(**uintptr)(__ccgo_up(argv + uintptr(Xoptind)*8))+uintptr(2))) + } + Xoptind = Xoptind + 1 + return int32('?') + } + } + return Xgetopt(tls, argc, argv, optstring) +} + +func Xgetopt_long(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v argc=%v argv=%v optstring=%v longopts=%v idx=%v, (%v:)", tls, argc, argv, optstring, longopts, idx, origin(2)) + defer func() { trc("-> %v", r) }() + } + return ___getopt_long(tls, argc, argv, optstring, longopts, idx, 0) +} + +func Xgetopt_long_only(tls *TLS, argc int32, argv uintptr, optstring uintptr, longopts uintptr, idx uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v argc=%v argv=%v optstring=%v longopts=%v idx=%v, (%v:)", tls, argc, argv, optstring, longopts, idx, origin(2)) + defer func() { trc("-> %v", r) }() + } + return ___getopt_long(tls, argc, argv, optstring, longopts, idx, int32(1)) +} + +func Xgetpriority(tls *TLS, which int32, who Tid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v which=%v who=%v, (%v:)", tls, which, who, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + ret = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getpriority), int64(which), Int64FromUint32(who))))) + if ret < 0 { + return ret + } + return int32(20) - ret +} + +func Xgetresgid(tls *TLS, rgid uintptr, egid uintptr, sgid uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v rgid=%v egid=%v sgid=%v, (%v:)", tls, rgid, egid, sgid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_getresgid), int64(rgid), int64(egid), int64(sgid))))) +} + +func Xgetresuid(tls *TLS, ruid uintptr, euid uintptr, suid uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ruid=%v euid=%v suid=%v, (%v:)", tls, ruid, euid, suid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_getresuid), int64(ruid), int64(euid), int64(suid))))) +} + +func Xgetrlimit(tls *TLS, resource int32, rlim uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v resource=%v rlim=%v, (%v:)", tls, resource, rlim, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ret int32 + var v1 uint64 + var _ /* k_rlim at bp+0 */ [2]uint64 + _, _ = ret, v1 + ret = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_prlimit64), int64(Int32FromInt32(0)), int64(resource), int64(Int32FromInt32(0)), int64(rlim))))) + if !(ret != 0) { + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur = ^Uint64FromUint64(0) + } + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max = ^Uint64FromUint64(0) + } + } + if !(ret != 0) || **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(ENOSYS) { + return ret + } + if X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getrlimit), int64(resource), int64(bp)))) < 0 { + return -int32(1) + } + if (**(**[2]uint64)(__ccgo_up(bp)))[0] == -Uint64FromUint64(1) { + v1 = ^Uint64FromUint64(0) + } else { + v1 = (**(**[2]uint64)(__ccgo_up(bp)))[0] + } + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur = v1 + if (**(**[2]uint64)(__ccgo_up(bp)))[int32(1)] == -Uint64FromUint64(1) { + v1 = ^Uint64FromUint64(0) + } else { + v1 = (**(**[2]uint64)(__ccgo_up(bp)))[int32(1)] + } + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max = v1 + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur = ^Uint64FromUint64(0) + } + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max >= ^Uint64FromUint64(0) { + (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max = ^Uint64FromUint64(0) + } + return 0 +} + +func Xgetrusage(tls *TLS, who int32, ru uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v who=%v ru=%v, (%v:)", tls, who, ru, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var dest uintptr + var r int32 + var _ /* kru at bp+0 */ [4]int64 + _, _ = dest, r + dest = ru + 32 - uintptr(Uint64FromInt32(4)*Uint64FromInt64(8)) + r = int32(X__syscall2(tls, int64(SYS_getrusage), int64(who), int64(dest))) + if !(r != 0) && Bool(uint64(8) > uint64(8)) { + Xmemcpy(tls, bp, dest, Uint64FromInt32(4)*Uint64FromInt64(8)) + (*Trusage)(unsafe.Pointer(ru)).Fru_utime = Ttimeval{ + Ftv_sec: (**(**[4]int64)(__ccgo_up(bp)))[0], + Ftv_usec: (**(**[4]int64)(__ccgo_up(bp)))[int32(1)], + } + (*Trusage)(unsafe.Pointer(ru)).Fru_stime = Ttimeval{ + Ftv_sec: (**(**[4]int64)(__ccgo_up(bp)))[int32(2)], + Ftv_usec: (**(**[4]int64)(__ccgo_up(bp)))[int32(3)], + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xgetsubopt(tls *TLS, opt uintptr, keys uintptr, val uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v opt=%v keys=%v val=%v, (%v:)", tls, opt, keys, val, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i int32 + var l Tsize_t + var s, v1, v2 uintptr + _, _, _, _, _ = i, l, s, v1, v2 + s = **(**uintptr)(__ccgo_up(opt)) + **(**uintptr)(__ccgo_up(val)) = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(opt)) = Xstrchr(tls, s, int32(',')) + if **(**uintptr)(__ccgo_up(opt)) != 0 { + v2 = opt + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + } else { + **(**uintptr)(__ccgo_up(opt)) = s + uintptr(_strlen(tls, s)) + } + i = 0 + for { + if !(**(**uintptr)(__ccgo_up(keys + uintptr(i)*8)) != 0) { + break + } + l = _strlen(tls, **(**uintptr)(__ccgo_up(keys + uintptr(i)*8))) + if Xstrncmp(tls, **(**uintptr)(__ccgo_up(keys + uintptr(i)*8)), s, l) != 0 { + goto _3 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(l)))) == int32('=') { + **(**uintptr)(__ccgo_up(val)) = s + uintptr(l) + uintptr(1) + } else { + if **(**uint8)(__ccgo_up(s + uintptr(l))) != 0 { + goto _3 + } + } + return i + goto _3 + _3: + ; + i = i + 1 + } + return -int32(1) +} + +const R = 2 +const W = 1 +const WR = 3 + +type Tioctl_compat_map = struct { + Fnew_req int32 + Fold_req int32 + Fold_size uint8 + Fdir uint8 + Fforce_align uint8 + Fnoffs uint8 + Foffsets [8]uint8 +} + +/* yields a type for a struct with original size n, with a misaligned + * timeval/timespec expanded from 32- to 64-bit. for use with ioctl + * number producing macros; only size of result is meaningful. */ + +type Tv4l2_event = struct { + Fa Tuint32_t + Fb [8]Tuint64_t + Fc [2]Tuint32_t + Fts [2]Tuint32_t + Fd [9]Tuint32_t +} + +var _compat_map = [20]Tioctl_compat_map{ + 0: { + Fnew_req: int32(SIOCGSTAMP), + Fold_req: int32(SIOCGSTAMP_OLD), + Fold_size: uint8(8), + Fdir: uint8(R), + Fnoffs: uint8(2), + Foffsets: [8]uint8{ + 1: uint8(4), + }, + }, + 1: { + Fnew_req: int32(SIOCGSTAMPNS), + Fold_req: int32(SIOCGSTAMPNS_OLD), + Fold_size: uint8(8), + Fdir: uint8(R), + Fnoffs: uint8(2), + Foffsets: [8]uint8{ + 1: uint8(4), + }, + }, + 2: { + Fnew_req: Int32FromUint64(uint64(Uint32FromUint32(2)< %v", r1) }() + } + bp := tls.Alloc(256) + defer tls.Free(256) + var ap Tva_list + var arg uintptr + var i, r int32 + var _ /* u at bp+0 */ struct { + Fbuf [0][256]uint8 + Falign int64 + F__ccgo_pad2 [248]byte + } + _, _, _, _ = ap, arg, i, r + ap = va + arg = VaUintptr(&ap) + _ = ap + r = int32(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(req), int64(arg))) + if Bool(Bool(int32(SIOCGSTAMP) != int32(SIOCGSTAMP_OLD)) && req != 0) && r == -int32(ENOTTY) { + i = 0 + for { + if !(Uint64FromInt32(i) < Uint64FromInt64(400)/Uint64FromInt64(20)) { + break + } + if _compat_map[i].Fnew_req != req { + goto _1 + } + _convert_ioctl_struct(tls, uintptr(unsafe.Pointer(&_compat_map))+uintptr(i)*20, bp, arg, int32(W)) + r = int32(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(_compat_map[i].Fold_req), int64(bp))) + if r < 0 { + break + } + _convert_ioctl_struct(tls, uintptr(unsafe.Pointer(&_compat_map))+uintptr(i)*20, bp, arg, int32(R)) + break + goto _1 + _1: + ; + i = i + 1 + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xissetugid(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int32FromUint8(X__libc.Fsecure) +} + +func Xlockf(tls *TLS, fd int32, op int32, size Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v op=%v size=%v, (%v:)", tls, fd, op, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var _ /* l at bp+0 */ Tflock + **(**Tflock)(__ccgo_up(bp)) = Tflock{ + Fl_type: int16(F_WRLCK), + Fl_whence: int16(1), + Fl_len: size, + } + switch op { + case int32(F_TEST): + (**(**Tflock)(__ccgo_up(bp))).Fl_type = F_RDLCK + if Xfcntl(tls, fd, int32(F_GETLK), VaList(bp+40, bp)) < 0 { + return -int32(1) + } + if int32((**(**Tflock)(__ccgo_up(bp))).Fl_type) == int32(F_UNLCK) || (**(**Tflock)(__ccgo_up(bp))).Fl_pid == Xgetpid(tls) { + return 0 + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EACCES) + return -int32(1) + case F_ULOCK: + (**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_UNLCK) + fallthrough + case int32(F_TLOCK): + return Xfcntl(tls, fd, int32(F_SETLK), VaList(bp+40, bp)) + case int32(F_LOCK): + return Xfcntl(tls, fd, int32(F_SETLKW), VaList(bp+40, bp)) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) +} + +const ACCOUNTING = 9 +const UTMP_FILE = "_PATH_UTMP" +const UTMP_FILENAME = "_PATH_UTMP" +const UT_HOSTSIZE = 256 +const UT_LINESIZE = 32 +const UT_NAMESIZE = 32 +const WTMP_FILE = "_PATH_WTMP" +const WTMP_FILENAME = "_PATH_WTMP" +const _PATH_UTMP = "/dev/null/utmp" +const _PATH_WTMP = "/dev/null/wtmp" +const ut_name = 0 +const utmp = 0 + +type Tlastlog = struct { + Fll_time Ttime_t + Fll_line [32]uint8 + Fll_host [256]uint8 +} + +func Xlogin_tty(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + Xsetsid(tls) + if Xioctl(tls, fd, int32(TIOCSCTTY), VaList(bp+8, UintptrFromInt32(0))) != 0 { + return -int32(1) + } + Xdup2(tls, fd, 0) + Xdup2(tls, fd, int32(1)) + Xdup2(tls, fd, int32(2)) + if fd > int32(2) { + Xclose(tls, fd) + } + return 0 +} + +const MNTOPT_DEFAULTS = "defaults" +const MNTOPT_NOAUTO = "noauto" +const MNTOPT_NOSUID = "nosuid" +const MNTOPT_RO = "ro" +const MNTOPT_RW = "rw" +const MNTOPT_SUID = "suid" +const MNTTYPE_IGNORE = "ignore" +const MNTTYPE_NFS = "nfs" +const MNTTYPE_SWAP = "swap" +const MOUNTED = "/etc/mtab" +const SENTINEL = 0 + +type Tmntent = struct { + Fmnt_fsname uintptr + Fmnt_dir uintptr + Fmnt_type uintptr + Fmnt_opts uintptr + Fmnt_freq int32 + Fmnt_passno int32 +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +var _internal_buf uintptr +var _internal_bufsize Tsize_t + +func Xsetmntent(tls *TLS, name uintptr, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v mode=%v, (%v:)", tls, name, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfopen(tls, name, mode) +} + +func Xendmntent(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + if f != 0 { + Xfclose(tls, f) + } + return int32(1) +} + +func _unescape_ent(tls *TLS, beg uintptr) (r uintptr) { + var cval uint8 + var dest, src, val, v1, v2 uintptr + var i int32 + _, _, _, _, _, _, _ = cval, dest, i, src, val, v1, v2 + dest = beg + src = beg + for **(**uint8)(__ccgo_up(src)) != 0 { + cval = uint8(0) + if Int32FromUint8(**(**uint8)(__ccgo_up(src))) != int32('\\') { + v1 = dest + dest = dest + 1 + v2 = src + src = src + 1 + **(**uint8)(__ccgo_up(v1)) = **(**uint8)(__ccgo_up(v2)) + continue + } + if Int32FromUint8(**(**uint8)(__ccgo_up(src + 1))) == int32('\\') { + src = src + 1 + v1 = dest + dest = dest + 1 + v2 = src + src = src + 1 + **(**uint8)(__ccgo_up(v1)) = **(**uint8)(__ccgo_up(v2)) + continue + } + val = src + uintptr(1) + i = 0 + for { + if !(i < int32(3)) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(val))) >= int32('0') && Int32FromUint8(**(**uint8)(__ccgo_up(val))) <= int32('7') { + cval = Uint8FromInt32(int32(cval) << Int32FromInt32(3)) + v1 = val + val = val + 1 + cval = Uint8FromInt32(int32(cval) + (Int32FromUint8(**(**uint8)(__ccgo_up(v1))) - Int32FromUint8('0'))) + } else { + break + } + goto _5 + _5: + ; + i = i + 1 + } + if cval != 0 { + v1 = dest + dest = dest + 1 + **(**uint8)(__ccgo_up(v1)) = cval + src = val + } else { + v1 = dest + dest = dest + 1 + v2 = src + src = src + 1 + **(**uint8)(__ccgo_up(v1)) = **(**uint8)(__ccgo_up(v2)) + } + } + **(**uint8)(__ccgo_up(dest)) = uint8(0) + return beg +} + +func Xgetmntent_r(tls *TLS, f uintptr, mnt uintptr, linebuf uintptr, buflen int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v mnt=%v linebuf=%v buflen=%v, (%v:)", tls, f, mnt, linebuf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var i, len1 Tsize_t + var use_internal int32 + var _ /* n at bp+0 */ [8]int32 + _, _, _ = i, len1, use_internal + use_internal = BoolInt32(linebuf == uintptr(unsafe.Pointer(&_internal_buf))) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_freq = 0 + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_passno = 0 + for cond := true; cond; cond = Int32FromUint8(**(**uint8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[0])))) == int32('#') || Uint64FromInt32((**(**[8]int32)(__ccgo_up(bp)))[int32(1)]) == len1 { + if use_internal != 0 { + Xgetline(tls, uintptr(unsafe.Pointer(&_internal_buf)), uintptr(unsafe.Pointer(&_internal_bufsize)), f) + linebuf = _internal_buf + } else { + Xfgets(tls, linebuf, buflen, f) + } + if Xfeof(tls, f) != 0 || Xferror(tls, f) != 0 { + return uintptr(0) + } + if !(Xstrchr(tls, linebuf, int32('\n')) != 0) { + Xfscanf(tls, f, __ccgo_ts+813, 0) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ERANGE) + return uintptr(0) + } + len1 = _strlen(tls, linebuf) + if len1 > uint64(INT_MAX) { + continue + } + i = uint64(0) + for { + if !(i < Uint64FromInt64(32)/Uint64FromInt64(4)) { + break + } + (**(**[8]int32)(__ccgo_up(bp)))[i] = Int32FromUint64(len1) + goto _1 + _1: + ; + i = i + 1 + } + Xsscanf(tls, linebuf, __ccgo_ts+825, VaList(bp+40, bp, bp+uintptr(1)*4, bp+uintptr(2)*4, bp+uintptr(3)*4, bp+uintptr(4)*4, bp+uintptr(5)*4, bp+uintptr(6)*4, bp+uintptr(7)*4, mnt+32, mnt+36)) + } + **(**uint8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(1)]))) = uint8(0) + **(**uint8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(3)]))) = uint8(0) + **(**uint8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(5)]))) = uint8(0) + **(**uint8)(__ccgo_up(linebuf + uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(7)]))) = uint8(0) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_fsname = _unescape_ent(tls, linebuf+uintptr((**(**[8]int32)(__ccgo_up(bp)))[0])) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_dir = _unescape_ent(tls, linebuf+uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(2)])) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_type = _unescape_ent(tls, linebuf+uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(4)])) + (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_opts = _unescape_ent(tls, linebuf+uintptr((**(**[8]int32)(__ccgo_up(bp)))[int32(6)])) + return mnt +} + +func Xgetmntent(tls *TLS, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetmntent_r(tls, f, uintptr(unsafe.Pointer(&_mnt)), uintptr(unsafe.Pointer(&_internal_buf)), 0) +} + +var _mnt Tmntent + +func Xaddmntent(tls *TLS, f uintptr, mnt uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v mnt=%v, (%v:)", tls, f, mnt, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + if Xfseek(tls, f, 0, int32(2)) != 0 { + return int32(1) + } + return BoolInt32(Xfprintf(tls, f, __ccgo_ts+880, VaList(bp+8, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_fsname, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_dir, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_type, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_opts, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_freq, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_passno)) < 0) +} + +func Xhasmntopt(tls *TLS, mnt uintptr, opt uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v mnt=%v opt=%v, (%v:)", tls, mnt, opt, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrstr(tls, (*Tmntent)(unsafe.Pointer(mnt)).Fmnt_opts, opt) +} + +type Thistory = struct { + Fchain uintptr + Fdev Tdev_t + Fino Tino_t + Flevel int32 + Fbase int32 +} + +func _do_nftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32, flags int32, h uintptr) (r1 int32) { + bp := tls.Alloc(176) + defer tls.Free(176) + var d, de, v10 uintptr + var dfd, err, r, type1, v3 int32 + var j, k, l Tsize_t + var v1 uint64 + var v8 bool + var v2 Tino_t + var _ /* lev at bp+160 */ TFTW + var _ /* new at bp+128 */ Thistory + var _ /* st at bp+0 */ Tstat + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = d, de, dfd, err, j, k, l, r, type1, v1, v10, v2, v3, v8 + l = _strlen(tls, path) + if l != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(path + uintptr(l-uint64(1))))) == int32('/') { + v1 = l - uint64(1) + } else { + v1 = l + } + j = v1 + v2 = Uint64FromInt32(0) + (**(**Tstat)(__ccgo_up(bp))).Fst_ino = v2 + (**(**Tstat)(__ccgo_up(bp))).Fst_dev = v2 + if flags&int32(FTW_PHYS) != 0 { + v3 = Xlstat(tls, path, bp) + } else { + v3 = BoolInt32(Xstat(tls, path, bp) < 0) + } + if v3 != 0 { + if !(flags&Int32FromInt32(FTW_PHYS) != 0) && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOENT) && !(Xlstat(tls, path, bp) != 0) { + type1 = int32(FTW_SLN) + } else { + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(EACCES) { + return -int32(1) + } else { + type1 = int32(FTW_NS) + } + } + } else { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFDIR) { + if flags&int32(FTW_DEPTH) != 0 { + type1 = int32(FTW_DP) + } else { + type1 = int32(FTW_D) + } + } else { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFLNK) { + if flags&int32(FTW_PHYS) != 0 { + type1 = int32(FTW_SL) + } else { + type1 = int32(FTW_SLN) + } + } else { + type1 = int32(FTW_F) + } + } + } + if flags&int32(FTW_MOUNT) != 0 && h != 0 && type1 != int32(FTW_NS) && (**(**Tstat)(__ccgo_up(bp))).Fst_dev != (*Thistory)(unsafe.Pointer(h)).Fdev { + return 0 + } + (**(**Thistory)(__ccgo_up(bp + 128))).Fchain = h + (**(**Thistory)(__ccgo_up(bp + 128))).Fdev = (**(**Tstat)(__ccgo_up(bp))).Fst_dev + (**(**Thistory)(__ccgo_up(bp + 128))).Fino = (**(**Tstat)(__ccgo_up(bp))).Fst_ino + if h != 0 { + v3 = (*Thistory)(unsafe.Pointer(h)).Flevel + int32(1) + } else { + v3 = 0 + } + (**(**Thistory)(__ccgo_up(bp + 128))).Flevel = v3 + (**(**Thistory)(__ccgo_up(bp + 128))).Fbase = Int32FromUint64(j + uint64(1)) + (**(**TFTW)(__ccgo_up(bp + 160))).Flevel = (**(**Thistory)(__ccgo_up(bp + 128))).Flevel + if h != 0 { + (**(**TFTW)(__ccgo_up(bp + 160))).Fbase = (*Thistory)(unsafe.Pointer(h)).Fbase + } else { + k = j + for { + if !(k != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(path + uintptr(k)))) == int32('/')) { + break + } + goto _5 + _5: + ; + k = k - 1 + } + for { + if !(k != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(path + uintptr(k-uint64(1))))) != int32('/')) { + break + } + goto _6 + _6: + ; + k = k - 1 + } + (**(**TFTW)(__ccgo_up(bp + 160))).Fbase = Int32FromUint64(k) + } + if type1 == int32(FTW_D) || type1 == int32(FTW_DP) { + dfd = Xopen(tls, path, O_RDONLY, 0) + err = **(**int32)(__ccgo_up(X__errno_location(tls))) + if dfd < 0 && err == int32(EACCES) { + type1 = int32(FTW_DNR) + } + if !(fd_limit != 0) { + Xclose(tls, dfd) + } + } + if v8 = !(flags&Int32FromInt32(FTW_DEPTH) != 0); v8 { + v3 = (*(*func(*TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_fn})))(tls, path, bp, type1, bp+160) + r = v3 + } + if v8 && v3 != 0 { + return r + } + for { + if !(h != 0) { + break + } + if (*Thistory)(unsafe.Pointer(h)).Fdev == (**(**Tstat)(__ccgo_up(bp))).Fst_dev && (*Thistory)(unsafe.Pointer(h)).Fino == (**(**Tstat)(__ccgo_up(bp))).Fst_ino { + return 0 + } + goto _9 + _9: + ; + h = (*Thistory)(unsafe.Pointer(h)).Fchain + } + if (type1 == int32(FTW_D) || type1 == int32(FTW_DP)) && fd_limit != 0 { + if dfd < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = err + return -int32(1) + } + d = Xfdopendir(tls, dfd) + if d != 0 { + for { + v10 = Xreaddir(tls, d) + de = v10 + if !(v10 != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(de + 19))) == int32('.') && (!(**(**uint8)(__ccgo_up(de + 19 + 1)) != 0) || Int32FromUint8(**(**uint8)(__ccgo_up(de + 19 + 1))) == int32('.') && !(**(**uint8)(__ccgo_up(de + 19 + 2)) != 0)) { + continue + } + if _strlen(tls, de+19) >= uint64(PATH_MAX)-l { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + Xclosedir(tls, d) + return -int32(1) + } + **(**uint8)(__ccgo_up(path + uintptr(j))) = uint8('/') + Xstrcpy(tls, path+uintptr(j)+uintptr(1), de+19) + v3 = _do_nftw(tls, path, __ccgo_fp_fn, fd_limit-int32(1), flags, bp+128) + r = v3 + if v3 != 0 { + Xclosedir(tls, d) + return r + } + } + Xclosedir(tls, d) + } else { + Xclose(tls, dfd) + return -int32(1) + } + } + **(**uint8)(__ccgo_up(path + uintptr(l))) = uint8(0) + if v8 = flags&int32(FTW_DEPTH) != 0; v8 { + v3 = (*(*func(*TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_fn})))(tls, path, bp, type1, bp+160) + r = v3 + } + if v8 && v3 != 0 { + return r + } + return 0 +} + +type t__ccgo_fp__Xnftw_1 = func(*TLS, uintptr, uintptr, int32, uintptr) int32 + +func Xnftw(tls *TLS, path uintptr, __ccgo_fp_fn uintptr, fd_limit int32, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v path=%v __ccgo_fp_fn=%v fd_limit=%v flags=%v, (%v:)", tls, path, __ccgo_fp_fn, fd_limit, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(4112) + defer tls.Free(4112) + var l Tsize_t + var r int32 + var _ /* cs at bp+0 */ int32 + var _ /* pathbuf at bp+4 */ [4097]uint8 + _, _ = l, r + if fd_limit <= 0 { + return 0 + } + l = _strlen(tls, path) + if l > uint64(PATH_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return -int32(1) + } + Xmemcpy(tls, bp+4, path, l+uint64(1)) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + r = _do_nftw(tls, bp+4, __ccgo_fp_fn, fd_limit, flags, UintptrFromInt32(0)) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) + return r +} + +/* Nonstandard, but vastly superior to the standard functions */ + +func Xopenpty(tls *TLS, pm uintptr, ps uintptr, name uintptr, tio uintptr, ws uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v pm=%v ps=%v name=%v tio=%v ws=%v, (%v:)", tls, pm, ps, name, tio, ws, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var m, s, v1 int32 + var _ /* buf at bp+8 */ [20]uint8 + var _ /* cs at bp+4 */ int32 + var _ /* n at bp+0 */ int32 + _, _, _ = m, s, v1 + **(**int32)(__ccgo_up(bp)) = 0 + m = Xopen(tls, __ccgo_ts+899, Int32FromInt32(O_RDWR)|Int32FromInt32(O_NOCTTY), 0) + if m < 0 { + return -int32(1) + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+4) + if Xioctl(tls, m, int32(TIOCSPTLCK), VaList(bp+40, bp)) != 0 || Xioctl(tls, m, Int32FromUint32(TIOCGPTN), VaList(bp+40, bp)) != 0 { + goto fail + } + if !(name != 0) { + name = bp + 8 + } + Xsnprintf(tls, name, uint64(20), __ccgo_ts+909, VaList(bp+40, **(**int32)(__ccgo_up(bp)))) + v1 = Xopen(tls, name, Int32FromInt32(O_RDWR)|Int32FromInt32(O_NOCTTY), 0) + s = v1 + if v1 < 0 { + goto fail + } + if tio != 0 { + Xtcsetattr(tls, s, TCSANOW, tio) + } + if ws != 0 { + Xioctl(tls, s, int32(TIOCSWINSZ), VaList(bp+40, ws)) + } + **(**int32)(__ccgo_up(pm)) = m + **(**int32)(__ccgo_up(ps)) = s + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 4)), uintptr(0)) + return 0 + goto fail +fail: + ; + Xclose(tls, m) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 4)), uintptr(0)) + return -int32(1) +} + +func Xptsname(tls *TLS, fd int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var err int32 + _ = err + err = X__ptsname_r(tls, fd, uintptr(unsafe.Pointer(&_buf2)), uint64(22)) + if err != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = err + return uintptr(0) + } + return uintptr(unsafe.Pointer(&_buf2)) +} + +var _buf2 [22]uint8 + +func Xposix_openpt(tls *TLS, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = Xopen(tls, __ccgo_ts+899, flags, 0) + if r < 0 && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOSPC) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EAGAIN) + } + return r +} + +func Xgrantpt(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xunlockpt(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* unlock at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = 0 + return Xioctl(tls, fd, int32(TIOCSPTLCK), VaList(bp+16, bp)) +} + +func X__ptsname_r(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v, (%v:)", tls, fd, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var err, v1 int32 + var _ /* pty at bp+0 */ int32 + _, _ = err, v1 + if !(buf != 0) { + len1 = uint64(0) + } + v1 = int32(X__syscall3(tls, int64(SYS_ioctl), int64(fd), Int64FromUint32(Uint32FromUint32(TIOCGPTN)), int64(bp))) + err = v1 + if v1 != 0 { + return -err + } + if Uint64FromInt32(Xsnprintf(tls, buf, len1, __ccgo_ts+909, VaList(bp+16, **(**int32)(__ccgo_up(bp))))) >= len1 { + return int32(ERANGE) + } + return 0 +} + +func Xptsname_r(tls *TLS, fd int32, buf uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v, (%v:)", tls, fd, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__ptsname_r(tls, fd, buf, len1) +} + +func _slash_len(tls *TLS, s uintptr) (r Tsize_t) { + var s0 uintptr + _ = s0 + s0 = s + for Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('/') { + s = s + 1 + } + return Uint64FromInt64(int64(s) - int64(s0)) +} + +func Xrealpath(tls *TLS, filename uintptr, resolved uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v filename=%v resolved=%v, (%v:)", tls, filename, resolved, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(8208) + defer tls.Free(8208) + var check_dir, up int32 + var cnt, l, l0, nup, p, q, v4 Tsize_t + var k Tssize_t + var z uintptr + var _ /* output at bp+4097 */ [4096]uint8 + var _ /* stack at bp+0 */ [4097]uint8 + _, _, _, _, _, _, _, _, _, _, _ = check_dir, cnt, k, l, l0, nup, p, q, up, z, v4 + cnt = uint64(0) + nup = uint64(0) + check_dir = 0 + if !(filename != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + l = Xstrnlen(tls, filename, uint64(4097)) + if !(l != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(0) + } + if l >= uint64(PATH_MAX) { + goto toolong + } + p = uint64(4097) - l - uint64(1) + q = uint64(0) + Xmemcpy(tls, bp+uintptr(p), filename, l+uint64(1)) + /* Main loop. Each iteration pops the next part from stack of + * remaining path components and consumes any slashes that follow. + * If not a link, it's moved to output; if a link, contents are + * pushed to the stack. */ + goto restart +restart: + ; +_3: + ; + /* If stack starts with /, the whole component is / or // + * and the output state must be reset. */ + if Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[p]) == int32('/') { + check_dir = 0 + nup = uint64(0) + q = uint64(0) + v4 = q + q = q + 1 + (**(**[4096]uint8)(__ccgo_up(bp + 4097)))[v4] = uint8('/') + p = p + 1 + /* Initial // is special. */ + if Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[p]) == int32('/') && Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[p+uint64(1)]) != int32('/') { + v4 = q + q = q + 1 + (**(**[4096]uint8)(__ccgo_up(bp + 4097)))[v4] = uint8('/') + } + goto _2 + } + z = X__strchrnul(tls, bp+uintptr(p), int32('/')) + v4 = Uint64FromInt64(int64(z) - int64(bp+uintptr(p))) + l = v4 + l0 = v4 + if !(l != 0) && !(check_dir != 0) { + goto _1 + } + /* Skip any . component but preserve check_dir status. */ + if l == uint64(1) && Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[p]) == int32('.') { + p = p + l + goto _2 + } + /* Copy next component onto output at least temporarily, to + * call readlink, but wait to advance output position until + * determining it's not a link. */ + if q != 0 && Int32FromUint8((**(**[4096]uint8)(__ccgo_up(bp + 4097)))[q-uint64(1)]) != int32('/') { + if !(p != 0) { + goto toolong + } + p = p - 1 + v4 = p + (**(**[4097]uint8)(__ccgo_up(bp)))[v4] = uint8('/') + l = l + 1 + } + if q+l >= uint64(PATH_MAX) { + goto toolong + } + Xmemcpy(tls, bp+4097+uintptr(q), bp+uintptr(p), l) + (**(**[4096]uint8)(__ccgo_up(bp + 4097)))[q+l] = uint8(0) + p = p + l + up = 0 + if l0 == uint64(2) && Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[p-uint64(2)]) == int32('.') && Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[p-uint64(1)]) == int32('.') { + up = int32(1) + /* Any non-.. path components we could cancel start + * after nup repetitions of the 3-byte string "../"; + * if there are none, accumulate .. components to + * later apply to cwd, if needed. */ + if q <= uint64(3)*nup { + nup = nup + 1 + q = q + l + goto _2 + } + /* When previous components are already known to be + * directories, processing .. can skip readlink. */ + if !(check_dir != 0) { + goto skip_readlink + } + } + k = Xreadlink(tls, bp+4097, bp, p) + if Uint64FromInt64(k) == p { + goto toolong + } + if !(k != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(0) + } + if !(k < 0) { + goto _8 + } + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(EINVAL) { + return uintptr(0) + } + goto skip_readlink +skip_readlink: + ; + check_dir = 0 + if up != 0 { + for q != 0 && Int32FromUint8((**(**[4096]uint8)(__ccgo_up(bp + 4097)))[q-uint64(1)]) != int32('/') { + q = q - 1 + } + if q > uint64(1) && (q > uint64(2) || Int32FromUint8((**(**[4096]uint8)(__ccgo_up(bp + 4097)))[0]) != int32('/')) { + q = q - 1 + } + goto _2 + } + if l0 != 0 { + q = q + l + } + check_dir = Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[p]) + goto _2 +_8: + ; + cnt = cnt + 1 + v4 = cnt + if v4 == uint64(SYMLOOP_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ELOOP) + return uintptr(0) + } + /* If link contents end in /, strip any slashes already on + * stack to avoid /->// or //->/// or spurious toolong. */ + if Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[k-int64(1)]) == int32('/') { + for Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[p]) == int32('/') { + p = p + 1 + } + } + p = p - Uint64FromInt64(k) + Xmemmove(tls, bp+uintptr(p), bp, Uint64FromInt64(k)) + /* Skip the stack advancement in case we have a new + * absolute base path. */ + goto restart + goto _2 +_2: + ; + p = p + _slash_len(tls, bp+uintptr(p)) + goto _3 + goto _1 +_1: + ; + (**(**[4096]uint8)(__ccgo_up(bp + 4097)))[q] = uint8(0) + if Int32FromUint8((**(**[4096]uint8)(__ccgo_up(bp + 4097)))[0]) != int32('/') { + if !(Xgetcwd(tls, bp, uint64(4097)) != 0) { + return uintptr(0) + } + l = _strlen(tls, bp) + /* Cancel any initial .. components. */ + p = uint64(0) + for { + v4 = nup + nup = nup - 1 + if !(v4 != 0) { + break + } + for l > uint64(1) && Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[l-uint64(1)]) != int32('/') { + l = l - 1 + } + if l > uint64(1) { + l = l - 1 + } + p = p + uint64(2) + if p < q { + p = p + 1 + } + } + if q-p != 0 && Int32FromUint8((**(**[4097]uint8)(__ccgo_up(bp)))[l-uint64(1)]) != int32('/') { + v4 = l + l = l + 1 + (**(**[4097]uint8)(__ccgo_up(bp)))[v4] = uint8('/') + } + if l+(q-p)+uint64(1) >= uint64(PATH_MAX) { + goto toolong + } + Xmemmove(tls, bp+4097+uintptr(l), bp+4097+uintptr(p), q-p+uint64(1)) + Xmemcpy(tls, bp+4097, bp, l) + q = l + q - p + } + if resolved != 0 { + return Xmemcpy(tls, resolved, bp+4097, q+uint64(1)) + } else { + return Xstrdup(tls, bp+4097) + } + goto toolong +toolong: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return uintptr(0) +} + +func Xsetdomainname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v len1=%v, (%v:)", tls, name, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_setdomainname), int64(name), Int64FromUint64(len1))))) +} + +func Xsetpriority(tls *TLS, which int32, who Tid_t, prio int32) (r int32) { + if __ccgo_strace { + trc("tls=%v which=%v who=%v prio=%v, (%v:)", tls, which, who, prio, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_setpriority), int64(which), Int64FromUint32(who), int64(prio))))) +} + +type Tctx = struct { + Flim [2]uint64 + Fres int32 + Ferr int32 +} + +func _do_setrlimit(tls *TLS, p uintptr) { + var c uintptr + _ = c + c = p + if (*Tctx)(unsafe.Pointer(c)).Ferr > 0 { + return + } + (*Tctx)(unsafe.Pointer(c)).Ferr = int32(-X__syscall2(tls, int64(SYS_setrlimit), int64((*Tctx)(unsafe.Pointer(c)).Fres), int64(c))) +} + +func Xsetrlimit(tls *TLS, resource int32, rlim uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v resource=%v rlim=%v, (%v:)", tls, resource, rlim, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var ret int32 + var v1, v2 uint64 + var _ /* c at bp+16 */ Tctx + var _ /* tmp at bp+0 */ Trlimit + _, _, _ = ret, v1, v2 + if ^Uint64FromUint64(0) != ^Uint64FromUint64(0) { + **(**Trlimit)(__ccgo_up(bp)) = **(**Trlimit)(__ccgo_up(rlim)) + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur >= ^Uint64FromUint64(0) { + (**(**Trlimit)(__ccgo_up(bp))).Frlim_cur = ^Uint64FromUint64(0) + } + if (**(**Trlimit)(__ccgo_up(bp))).Frlim_max >= ^Uint64FromUint64(0) { + (**(**Trlimit)(__ccgo_up(bp))).Frlim_max = ^Uint64FromUint64(0) + } + rlim = bp + } + ret = int32(X__syscall4(tls, int64(SYS_prlimit64), int64(Int32FromInt32(0)), int64(resource), int64(rlim), int64(Int32FromInt32(0)))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur < ^Uint64FromUint64(0) { + v1 = (*Trlimit)(unsafe.Pointer(rlim)).Frlim_cur + } else { + v1 = ^Uint64FromUint64(0) + } + if (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max < ^Uint64FromUint64(0) { + v2 = (*Trlimit)(unsafe.Pointer(rlim)).Frlim_max + } else { + v2 = ^Uint64FromUint64(0) + } + **(**Tctx)(__ccgo_up(bp + 16)) = Tctx{ + Flim: [2]uint64{ + 0: v1, + 1: v2, + }, + Fres: resource, + Ferr: -int32(1), + } + ___synccall(tls, __ccgo_fp(_do_setrlimit), bp+16) + if (**(**Tctx)(__ccgo_up(bp + 16))).Ferr != 0 { + if (**(**Tctx)(__ccgo_up(bp + 16))).Ferr > 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = (**(**Tctx)(__ccgo_up(bp + 16))).Ferr + } + return -int32(1) + } + return 0 +} + +func Xsyscall(tls *TLS, n int64, va uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v n=%v va=%v, (%v:)", tls, n, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, b, c, d, e, f Tsyscall_arg_t + var ap Tva_list + _, _, _, _, _, _, _ = a, ap, b, c, d, e, f + ap = va + a = VaInt64(&ap) + b = VaInt64(&ap) + c = VaInt64(&ap) + d = VaInt64(&ap) + e = VaInt64(&ap) + f = VaInt64(&ap) + _ = ap + return X__syscall_ret(tls, Uint64FromInt64(X__syscall6(tls, n, a, b, c, d, e, f))) +} + +const AF_ALG = 38 +const AF_APPLETALK = 5 +const AF_ASH = 18 +const AF_ATMPVC = 8 +const AF_ATMSVC = 20 +const AF_AX25 = 3 +const AF_BLUETOOTH = 31 +const AF_BRIDGE = 7 +const AF_CAIF = 37 +const AF_CAN = 29 +const AF_DECnet = 12 +const AF_ECONET = 19 +const AF_FILE = 1 +const AF_IB = 27 +const AF_IEEE802154 = 36 +const AF_INET = 2 +const AF_INET6 = 10 +const AF_IPX = 4 +const AF_IRDA = 23 +const AF_ISDN = 34 +const AF_IUCV = 32 +const AF_KCM = 41 +const AF_KEY = 15 +const AF_LLC = 26 +const AF_LOCAL = 1 +const AF_MAX = 45 +const AF_MPLS = 28 +const AF_NETBEUI = 13 +const AF_NETLINK = 16 +const AF_NETROM = 6 +const AF_NFC = 39 +const AF_PACKET = 17 +const AF_PHONET = 35 +const AF_PPPOX = 24 +const AF_QIPCRTR = 42 +const AF_RDS = 21 +const AF_ROSE = 11 +const AF_ROUTE = 16 +const AF_RXRPC = 33 +const AF_SECURITY = 14 +const AF_SMC = 43 +const AF_SNA = 22 +const AF_TIPC = 30 +const AF_UNIX = 1 +const AF_UNSPEC = 0 +const AF_VSOCK = 40 +const AF_WANPIPE = 25 +const AF_X25 = 9 +const AF_XDP = 44 +const LOG_ALERT = 1 +const LOG_AUTH = 32 +const LOG_AUTHPRIV = 80 +const LOG_CONS = 2 +const LOG_CRIT = 2 +const LOG_CRON = 72 +const LOG_DAEMON = 24 +const LOG_DEBUG = 7 +const LOG_EMERG = 0 +const LOG_ERR = 3 +const LOG_FACMASK = 1016 +const LOG_FTP = 88 +const LOG_INFO = 6 +const LOG_KERN = 0 +const LOG_LOCAL0 = 128 +const LOG_LOCAL1 = 136 +const LOG_LOCAL2 = 144 +const LOG_LOCAL3 = 152 +const LOG_LOCAL4 = 160 +const LOG_LOCAL5 = 168 +const LOG_LOCAL6 = 176 +const LOG_LOCAL7 = 184 +const LOG_LPR = 48 +const LOG_MAIL = 16 +const LOG_NDELAY = 8 +const LOG_NEWS = 56 +const LOG_NFACILITIES = 24 +const LOG_NOTICE = 5 +const LOG_NOWAIT = 16 +const LOG_ODELAY = 4 +const LOG_PERROR = 32 +const LOG_PID = 1 +const LOG_PRIMASK = 7 +const LOG_SYSLOG = 40 +const LOG_USER = 8 +const LOG_UUCP = 64 +const LOG_WARNING = 4 +const MSG_BATCH = 262144 +const MSG_CMSG_CLOEXEC = 1073741824 +const MSG_CONFIRM = 2048 +const MSG_CTRUNC = 8 +const MSG_DONTROUTE = 4 +const MSG_DONTWAIT = 64 +const MSG_EOR = 128 +const MSG_ERRQUEUE = 8192 +const MSG_FASTOPEN = 536870912 +const MSG_FIN = 512 +const MSG_MORE = 32768 +const MSG_NOSIGNAL = 16384 +const MSG_OOB = 1 +const MSG_PEEK = 2 +const MSG_PROXY = 16 +const MSG_RST = 4096 +const MSG_SYN = 1024 +const MSG_TRUNC = 32 +const MSG_WAITALL = 256 +const MSG_WAITFORONE = 65536 +const MSG_ZEROCOPY = 67108864 +const PF_ALG = 38 +const PF_APPLETALK = 5 +const PF_ASH = 18 +const PF_ATMPVC = 8 +const PF_ATMSVC = 20 +const PF_AX25 = 3 +const PF_BLUETOOTH = 31 +const PF_BRIDGE = 7 +const PF_CAIF = 37 +const PF_CAN = 29 +const PF_DECnet = 12 +const PF_ECONET = 19 +const PF_FILE = 1 +const PF_IB = 27 +const PF_IEEE802154 = 36 +const PF_INET = 2 +const PF_INET6 = 10 +const PF_IPX = 4 +const PF_IRDA = 23 +const PF_ISDN = 34 +const PF_IUCV = 32 +const PF_KCM = 41 +const PF_KEY = 15 +const PF_LLC = 26 +const PF_LOCAL = 1 +const PF_MAX = 45 +const PF_MPLS = 28 +const PF_NETBEUI = 13 +const PF_NETLINK = 16 +const PF_NETROM = 6 +const PF_NFC = 39 +const PF_PACKET = 17 +const PF_PHONET = 35 +const PF_PPPOX = 24 +const PF_QIPCRTR = 42 +const PF_RDS = 21 +const PF_ROSE = 11 +const PF_ROUTE = 16 +const PF_RXRPC = 33 +const PF_SECURITY = 14 +const PF_SMC = 43 +const PF_SNA = 22 +const PF_TIPC = 30 +const PF_UNIX = 1 +const PF_UNSPEC = 0 +const PF_VSOCK = 40 +const PF_WANPIPE = 25 +const PF_X25 = 9 +const PF_XDP = 44 +const SCM_CREDENTIALS = 2 +const SCM_RIGHTS = 1 +const SCM_TIMESTAMP = 29 +const SCM_TIMESTAMPING = 37 +const SCM_TIMESTAMPING_OPT_STATS = 54 +const SCM_TIMESTAMPING_PKTINFO = 58 +const SCM_TIMESTAMPNS = 35 +const SCM_TXTIME = 61 +const SCM_WIFI_STATUS = 41 +const SHUT_RD = 0 +const SHUT_RDWR = 2 +const SHUT_WR = 1 +const SOCK_CLOEXEC = 524288 +const SOCK_DCCP = 6 +const SOCK_DGRAM = 2 +const SOCK_NONBLOCK = 2048 +const SOCK_PACKET = 10 +const SOCK_RAW = 3 +const SOCK_RDM = 4 +const SOCK_SEQPACKET = 5 +const SOCK_STREAM = 1 +const SOL_AAL = 265 +const SOL_ALG = 279 +const SOL_ATM = 264 +const SOL_BLUETOOTH = 274 +const SOL_CAIF = 278 +const SOL_DCCP = 269 +const SOL_DECNET = 261 +const SOL_ICMPV6 = 58 +const SOL_IP = 0 +const SOL_IPV6 = 41 +const SOL_IRDA = 266 +const SOL_IUCV = 277 +const SOL_KCM = 281 +const SOL_LLC = 268 +const SOL_NETBEUI = 267 +const SOL_NETLINK = 270 +const SOL_NFC = 280 +const SOL_PACKET = 263 +const SOL_PNPIPE = 275 +const SOL_PPPOL2TP = 273 +const SOL_RAW = 255 +const SOL_RDS = 276 +const SOL_RXRPC = 272 +const SOL_SOCKET = 1 +const SOL_TIPC = 271 +const SOL_TLS = 282 +const SOL_X25 = 262 +const SOL_XDP = 283 +const SOMAXCONN = 128 +const SO_ACCEPTCONN = 30 +const SO_ATTACH_BPF = 50 +const SO_ATTACH_FILTER = 26 +const SO_ATTACH_REUSEPORT_CBPF = 51 +const SO_ATTACH_REUSEPORT_EBPF = 52 +const SO_BINDTODEVICE = 25 +const SO_BINDTOIFINDEX = 62 +const SO_BPF_EXTENSIONS = 48 +const SO_BROADCAST = 6 +const SO_BSDCOMPAT = 14 +const SO_BUSY_POLL = 46 +const SO_BUSY_POLL_BUDGET = 70 +const SO_CNX_ADVICE = 53 +const SO_COOKIE = 57 +const SO_DEBUG = 1 +const SO_DETACH_BPF = 27 +const SO_DETACH_FILTER = 27 +const SO_DETACH_REUSEPORT_BPF = 68 +const SO_DOMAIN = 39 +const SO_DONTROUTE = 5 +const SO_ERROR = 4 +const SO_GET_FILTER = 26 +const SO_INCOMING_CPU = 49 +const SO_INCOMING_NAPI_ID = 56 +const SO_KEEPALIVE = 9 +const SO_LINGER = 13 +const SO_LOCK_FILTER = 44 +const SO_MARK = 36 +const SO_MAX_PACING_RATE = 47 +const SO_MEMINFO = 55 +const SO_NOFCS = 43 +const SO_NO_CHECK = 11 +const SO_OOBINLINE = 10 +const SO_PASSCRED = 16 +const SO_PASSSEC = 34 +const SO_PEEK_OFF = 42 +const SO_PEERCRED = 17 +const SO_PEERGROUPS = 59 +const SO_PEERNAME = 28 +const SO_PEERSEC = 31 +const SO_PREFER_BUSY_POLL = 69 +const SO_PRIORITY = 12 +const SO_PROTOCOL = 38 +const SO_RCVBUF = 8 +const SO_RCVBUFFORCE = 33 +const SO_RCVLOWAT = 18 +const SO_RCVTIMEO = 20 +const SO_REUSEADDR = 2 +const SO_REUSEPORT = 15 +const SO_RXQ_OVFL = 40 +const SO_SECURITY_AUTHENTICATION = 22 +const SO_SECURITY_ENCRYPTION_NETWORK = 24 +const SO_SECURITY_ENCRYPTION_TRANSPORT = 23 +const SO_SELECT_ERR_QUEUE = 45 +const SO_SNDBUF = 7 +const SO_SNDBUFFORCE = 32 +const SO_SNDLOWAT = 19 +const SO_SNDTIMEO = 21 +const SO_TIMESTAMP = 29 +const SO_TIMESTAMPING = 37 +const SO_TIMESTAMPNS = 35 +const SO_TXTIME = 61 +const SO_TYPE = 3 +const SO_WIFI_STATUS = 41 +const SO_ZEROCOPY = 60 + +type Tsocklen_t = uint32 + +type Tsa_family_t = uint16 + +type Tmsghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Tsocklen_t + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__pad1 int32 + Fmsg_control uintptr + Fmsg_controllen Tsocklen_t + F__pad2 int32 + Fmsg_flags int32 +} + +type Tcmsghdr = struct { + Fcmsg_len Tsocklen_t + F__pad1 int32 + Fcmsg_level int32 + Fcmsg_type int32 +} + +type Tlinger = struct { + Fl_onoff int32 + Fl_linger int32 +} + +type Tsockaddr = struct { + Fsa_family Tsa_family_t + Fsa_data [14]uint8 +} + +type Tsockaddr_storage = struct { + Fss_family Tsa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 +} + +var _lock2 [1]int32 +var _log_ident [32]uint8 +var _log_opt int32 +var _log_facility = Int32FromInt32(1) << Int32FromInt32(3) +var _log_mask = int32(0xff) +var _log_fd = -int32(1) + +func Xsetlogmask(tls *TLS, maskpri int32) (r int32) { + if __ccgo_strace { + trc("tls=%v maskpri=%v, (%v:)", tls, maskpri, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + ___lock(tls, uintptr(unsafe.Pointer(&_lock2))) + ret = _log_mask + if maskpri != 0 { + _log_mask = maskpri + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock2))) + return ret +} + +var _log_addr = struct { + Fsun_family int16 + Fsun_path [9]uint8 +}{ + Fsun_family: int16(PF_LOCAL), + Fsun_path: [9]uint8{'/', 'd', 'e', 'v', '/', 'l', 'o', 'g'}, +} + +func Xcloselog(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* cs at bp+0 */ int32 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + ___lock(tls, uintptr(unsafe.Pointer(&_lock2))) + Xclose(tls, _log_fd) + _log_fd = -int32(1) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock2))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) +} + +func ___openlog(tls *TLS) { + _log_fd = Xsocket(tls, int32(PF_LOCAL), Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC), 0) + if _log_fd >= 0 { + Xconnect(tls, _log_fd, uintptr(unsafe.Pointer(&_log_addr)), uint32(12)) + } +} + +func Xopenlog(tls *TLS, ident uintptr, opt int32, facility int32) { + if __ccgo_strace { + trc("tls=%v ident=%v opt=%v facility=%v, (%v:)", tls, ident, opt, facility, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var n Tsize_t + var _ /* cs at bp+0 */ int32 + _ = n + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + ___lock(tls, uintptr(unsafe.Pointer(&_lock2))) + if ident != 0 { + n = Xstrnlen(tls, ident, Uint64FromInt64(32)-Uint64FromInt32(1)) + Xmemcpy(tls, uintptr(unsafe.Pointer(&_log_ident)), ident, n) + _log_ident[n] = uint8(0) + } else { + _log_ident[0] = uint8(0) + } + _log_opt = opt + _log_facility = facility + if opt&int32(LOG_NDELAY) != 0 && _log_fd < 0 { + ___openlog(tls) + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock2))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) +} + +func _is_lost_conn(tls *TLS, e int32) (r int32) { + return BoolInt32(e == int32(ECONNREFUSED) || e == int32(ECONNRESET) || e == int32(ENOTCONN) || e == int32(EPIPE)) +} + +func __vsyslog(tls *TLS, priority int32, message uintptr, ap Tva_list) { + bp := tls.Alloc(1184) + defer tls.Free(1184) + var errno_save, fd, l, l2, pid, v1 int32 + var _ /* buf at bp+80 */ [1024]uint8 + var _ /* hlen at bp+1104 */ int32 + var _ /* now at bp+16 */ Ttime_t + var _ /* timebuf at bp+0 */ [16]uint8 + var _ /* tm at bp+24 */ Ttm + _, _, _, _, _, _ = errno_save, fd, l, l2, pid, v1 + errno_save = **(**int32)(__ccgo_up(X__errno_location(tls))) + if _log_fd < 0 { + ___openlog(tls) + } + if !(priority&Int32FromInt32(LOG_FACMASK) != 0) { + priority = priority | _log_facility + } + **(**Ttime_t)(__ccgo_up(bp + 16)) = Xtime(tls, UintptrFromInt32(0)) + Xgmtime_r(tls, bp+16, bp+24) + Xstrftime_l(tls, bp, uint64(16), __ccgo_ts+921, bp+24, uintptr(unsafe.Pointer(&X__c_locale))) + if _log_opt&int32(LOG_PID) != 0 { + v1 = Xgetpid(tls) + } else { + v1 = 0 + } + pid = v1 + l = Xsnprintf(tls, bp+80, uint64(1024), __ccgo_ts+930, VaList(bp+1120, priority, bp, bp+1104, uintptr(unsafe.Pointer(&_log_ident)), __ccgo_ts+952+BoolUintptr(!(pid != 0)), pid, __ccgo_ts+954+BoolUintptr(!(pid != 0)))) + **(**int32)(__ccgo_up(X__errno_location(tls))) = errno_save + l2 = Xvsnprintf(tls, bp+80+uintptr(l), uint64(1024)-Uint64FromInt32(l), message, ap) + if l2 >= 0 { + if Uint64FromInt32(l2) >= uint64(1024)-Uint64FromInt32(l) { + l = Int32FromUint64(Uint64FromInt64(1024) - Uint64FromInt32(1)) + } else { + l = l + l2 + } + if Int32FromUint8((**(**[1024]uint8)(__ccgo_up(bp + 80)))[l-int32(1)]) != int32('\n') { + v1 = l + l = l + 1 + (**(**[1024]uint8)(__ccgo_up(bp + 80)))[v1] = uint8('\n') + } + if Xsend(tls, _log_fd, bp+80, Uint64FromInt32(l), 0) < 0 && (!(_is_lost_conn(tls, **(**int32)(__ccgo_up(X__errno_location(tls)))) != 0) || Xconnect(tls, _log_fd, uintptr(unsafe.Pointer(&_log_addr)), uint32(12)) < 0 || Xsend(tls, _log_fd, bp+80, Uint64FromInt32(l), 0) < 0) && _log_opt&int32(LOG_CONS) != 0 { + fd = Xopen(tls, __ccgo_ts+649, Int32FromInt32(O_WRONLY)|Int32FromInt32(O_NOCTTY)|Int32FromInt32(O_CLOEXEC), 0) + if fd >= 0 { + Xdprintf(tls, fd, __ccgo_ts+956, VaList(bp+1120, l-**(**int32)(__ccgo_up(bp + 1104)), bp+80+uintptr(**(**int32)(__ccgo_up(bp + 1104))))) + Xclose(tls, fd) + } + } + if _log_opt&int32(LOG_PERROR) != 0 { + Xdprintf(tls, int32(2), __ccgo_ts+956, VaList(bp+1120, l-**(**int32)(__ccgo_up(bp + 1104)), bp+80+uintptr(**(**int32)(__ccgo_up(bp + 1104))))) + } + } +} + +func ___vsyslog(tls *TLS, priority int32, message uintptr, ap Tva_list) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* cs at bp+0 */ int32 + if !(_log_mask&(Int32FromInt32(1)<<(priority&Int32FromInt32(7))) != 0) || priority & ^Int32FromInt32(0x3ff) != 0 { + return + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + ___lock(tls, uintptr(unsafe.Pointer(&_lock2))) + __vsyslog(tls, priority, message, ap) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock2))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) +} + +func Xsyslog(tls *TLS, priority int32, message uintptr, va uintptr) { + if __ccgo_strace { + trc("tls=%v priority=%v message=%v va=%v, (%v:)", tls, priority, message, va, origin(2)) + } + var ap Tva_list + _ = ap + ap = va + ___vsyslog(tls, priority, message, ap) + _ = ap +} + +type Tutsname1 = struct { + Fsysname [65]uint8 + Fnodename [65]uint8 + Frelease [65]uint8 + Fversion [65]uint8 + Fmachine [65]uint8 + F__domainname [65]uint8 +} + +func Xuname(tls *TLS, uts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v uts=%v, (%v:)", tls, uts, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_uname), int64(uts))))) +} + +func X__madvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v advice=%v, (%v:)", tls, addr, len1, advice, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_madvise), int64(addr), Int64FromUint64(len1), int64(advice))))) +} + +func Xmadvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v advice=%v, (%v:)", tls, addr, len1, advice, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__madvise(tls, addr, len1, advice) +} + +func Xmincore(tls *TLS, addr uintptr, len1 Tsize_t, vec uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v vec=%v, (%v:)", tls, addr, len1, vec, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mincore), int64(addr), Int64FromUint64(len1), int64(vec))))) +} + +func Xmlock(tls *TLS, addr uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v, (%v:)", tls, addr, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_mlock), int64(addr), Int64FromUint64(len1))))) +} + +func Xmlockall(tls *TLS, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v flags=%v, (%v:)", tls, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_mlockall), int64(flags))))) +} + +const OFF_MASK = 4095 +const UNIT = 4096 + +func _dummy5(tls *TLS) { +} + +func X__mmap(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v prot=%v flags=%v fd=%v off=%v, (%v:)", tls, start, len1, prot, flags, fd, off, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int64 + _ = ret + if Uint64FromInt64(off)&(-Uint64FromUint64(0x2000)<<(Uint64FromInt32(8)*Uint64FromInt64(8)-Uint64FromInt32(1))|(Uint64FromUint64(4096)-Uint64FromInt32(1))) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(-Int32FromInt32(1)) + } + if len1 >= Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return uintptr(-Int32FromInt32(1)) + } + if flags&int32(MAP_FIXED) != 0 { + _dummy5(tls) + } + ret = X__syscall6(tls, int64(SYS_mmap), int64(start), Int64FromUint64(len1), int64(prot), int64(flags), int64(fd), off) + /* Fixup incorrect EPERM from kernel. */ + if ret == int64(-int32(EPERM)) && !(start != 0) && flags&int32(MAP_ANON) != 0 && !(flags&Int32FromInt32(MAP_FIXED) != 0) { + ret = int64(-int32(ENOMEM)) + } + return uintptr(X__syscall_ret(tls, Uint64FromInt64(ret))) +} + +func Xmmap(tls *TLS, start uintptr, len1 Tsize_t, prot int32, flags int32, fd int32, off Toff_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v prot=%v flags=%v fd=%v off=%v, (%v:)", tls, start, len1, prot, flags, fd, off, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mmap(tls, start, len1, prot, flags, fd, off) +} + +func X__mprotect(tls *TLS, addr uintptr, len1 Tsize_t, prot int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v prot=%v, (%v:)", tls, addr, len1, prot, origin(2)) + defer func() { trc("-> %v", r) }() + } + var end, start Tsize_t + _, _ = end, start + start = uint64(addr) & -X__libc.Fpage_size + end = uint64(addr+uintptr(len1)+uintptr(X__libc.Fpage_size)-UintptrFromInt32(1)) & -X__libc.Fpage_size + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mprotect), Int64FromUint64(start), Int64FromUint64(end-start), int64(prot))))) +} + +func Xmprotect(tls *TLS, addr uintptr, len1 Tsize_t, prot int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v prot=%v, (%v:)", tls, addr, len1, prot, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mprotect(tls, addr, len1, prot) +} + +func _dummy6(tls *TLS) { +} + +func X__mremap(tls *TLS, old_addr uintptr, old_len Tsize_t, new_len Tsize_t, flags int32, va uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v old_addr=%v old_len=%v new_len=%v flags=%v va=%v, (%v:)", tls, old_addr, old_len, new_len, flags, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var new_addr uintptr + _, _ = ap, new_addr + new_addr = uintptr(0) + if new_len >= Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return uintptr(-Int32FromInt32(1)) + } + if flags&int32(MREMAP_FIXED) != 0 { + _dummy6(tls) + ap = va + new_addr = VaUintptr(&ap) + _ = ap + } + return uintptr(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_mremap), int64(old_addr), Int64FromUint64(old_len), Int64FromUint64(new_len), int64(flags), int64(new_addr))))) +} + +func Xmremap(tls *TLS, old_addr uintptr, old_len Tsize_t, new_len Tsize_t, flags int32, va uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v old_addr=%v old_len=%v new_len=%v flags=%v va=%v, (%v:)", tls, old_addr, old_len, new_len, flags, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mremap(tls, old_addr, old_len, new_len, flags, va) +} + +func Xmsync(tls *TLS, start uintptr, len1 Tsize_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v flags=%v, (%v:)", tls, start, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_msync), int64(start), Int64FromUint64(len1), int64(flags), 0, 0, 0)))) +} + +func Xmunlock(tls *TLS, addr uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v, (%v:)", tls, addr, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_munlock), int64(addr), Int64FromUint64(len1))))) +} + +func Xmunlockall(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall0(tls, int64(SYS_munlockall))))) +} + +func _dummy7(tls *TLS) { +} + +func X__munmap(tls *TLS, start uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v, (%v:)", tls, start, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + _dummy7(tls) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_munmap), int64(start), Int64FromUint64(len1))))) +} + +func Xmunmap(tls *TLS, start uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v start=%v len1=%v, (%v:)", tls, start, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__munmap(tls, start, len1) +} + +func Xposix_madvise(tls *TLS, addr uintptr, len1 Tsize_t, advice int32) (r int32) { + if __ccgo_strace { + trc("tls=%v addr=%v len1=%v advice=%v, (%v:)", tls, addr, len1, advice, origin(2)) + defer func() { trc("-> %v", r) }() + } + if advice == int32(MADV_DONTNEED) { + return 0 + } + return int32(-X__syscall3(tls, int64(SYS_madvise), int64(addr), Int64FromUint64(len1), int64(advice))) +} + +func X__shm_mapname(tls *TLS, name uintptr, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v buf=%v, (%v:)", tls, name, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p, v1 uintptr + _, _ = p, v1 + for Int32FromUint8(**(**uint8)(__ccgo_up(name))) == int32('/') { + name = name + 1 + } + v1 = X__strchrnul(tls, name, int32('/')) + p = v1 + if **(**uint8)(__ccgo_up(v1)) != 0 || p == name || int64(p)-int64(name) <= int64(2) && Int32FromUint8(**(**uint8)(__ccgo_up(name))) == int32('.') && Int32FromUint8(**(**uint8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) == int32('.') { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + if int64(p)-int64(name) > int64(NAME_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return uintptr(0) + } + Xmemcpy(tls, buf, __ccgo_ts+961, uint64(9)) + Xmemcpy(tls, buf+uintptr(9), name, Uint64FromInt64(int64(p)-int64(name)+int64(1))) + return buf +} + +func Xshm_open(tls *TLS, name uintptr, flag int32, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v flag=%v mode=%v, (%v:)", tls, name, flag, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(288) + defer tls.Free(288) + var fd int32 + var v1 uintptr + var _ /* buf at bp+4 */ [265]uint8 + var _ /* cs at bp+0 */ int32 + _, _ = fd, v1 + v1 = X__shm_mapname(tls, name, bp+4) + name = v1 + if !(v1 != 0) { + return -int32(1) + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + fd = Xopen(tls, name, flag|int32(O_NOFOLLOW)|int32(O_CLOEXEC)|int32(O_NONBLOCK), VaList(bp+280, mode)) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) + return fd +} + +func Xshm_unlink(tls *TLS, name uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(272) + defer tls.Free(272) + var v1 uintptr + var _ /* buf at bp+0 */ [265]uint8 + _ = v1 + v1 = X__shm_mapname(tls, name, bp) + name = v1 + if !(v1 != 0) { + return -int32(1) + } + return Xunlink(tls, name) +} + +const SA = 194 +const SB = 244 +const bittab = 0 + +func Xbtowc(tls *TLS, c int32) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var b, v3 int32 + var v1, v2 uint32 + _, _, _, _ = b, v1, v2, v3 + b = Int32FromUint8(Uint8FromInt32(c)) + if Uint32FromInt32(b) < uint32(128) { + v1 = Uint32FromInt32(b) + } else { + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v3 = int32(4) + } else { + v3 = int32(1) + } + if v3 == int32(1) && c != -int32(1) { + v2 = Uint32FromInt32(Int32FromInt32(0xdfff) & int32(int8(c))) + } else { + v2 = uint32(0xffffffff) + } + v1 = v2 + } + return v1 +} + +type Tchar16_t = uint16 + +type Tchar32_t = uint32 + +func Xc16rtomb(tls *TLS, s uintptr, c16 Tchar16_t, ps uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c16=%v ps=%v, (%v:)", tls, s, c16, ps, origin(2)) + defer func() { trc("-> %v", r) }() + } + var wc Twchar_t + var x uintptr + _, _ = wc, x + if !(ps != 0) { + ps = uintptr(unsafe.Pointer(&_internal_state)) + } + x = ps + if !(s != 0) { + if **(**uint32)(__ccgo_up(x)) != 0 { + goto ilseq + } + return uint64(1) + } + if !(**(**uint32)(__ccgo_up(x)) != 0) && uint32(c16)-uint32(0xd800) < uint32(0x400) { + **(**uint32)(__ccgo_up(x)) = Uint32FromInt32((Int32FromUint16(c16) - int32(0xd7c0)) << int32(10)) + return uint64(0) + } + if **(**uint32)(__ccgo_up(x)) != 0 { + if uint32(c16)-uint32(0xdc00) >= uint32(0x400) { + goto ilseq + } else { + wc = **(**uint32)(__ccgo_up(x)) + uint32(c16) - uint32(0xdc00) + } + **(**uint32)(__ccgo_up(x)) = uint32(0) + } else { + wc = uint32(c16) + } + return Xwcrtomb(tls, s, wc, uintptr(0)) + goto ilseq +ilseq: + ; + **(**uint32)(__ccgo_up(x)) = uint32(0) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + return Uint64FromInt32(-Int32FromInt32(1)) +} + +var _internal_state uint32 + +func Xc32rtomb(tls *TLS, s uintptr, c32 Tchar32_t, ps uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c32=%v ps=%v, (%v:)", tls, s, c32, ps, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcrtomb(tls, s, c32, ps) +} + +func Xmblen(tls *TLS, s uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmbtowc(tls, uintptr(0), s, n) +} + +func Xmbrlen(tls *TLS, s uintptr, n Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v st=%v, (%v:)", tls, s, n, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + if st != 0 { + v1 = st + } else { + v1 = uintptr(unsafe.Pointer(&_internal)) + } + return Xmbrtowc(tls, uintptr(0), s, n, v1) +} + +var _internal uint32 + +func Xmbrtoc16(tls *TLS, pc16 uintptr, s uintptr, n Tsize_t, ps uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v pc16=%v s=%v n=%v ps=%v, (%v:)", tls, pc16, s, n, ps, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var pending uintptr + var ret Tsize_t + var _ /* wc at bp+0 */ Twchar_t + _, _ = pending, ret + if !(ps != 0) { + ps = uintptr(unsafe.Pointer(&_internal_state1)) + } + pending = ps + if !(s != 0) { + return Xmbrtoc16(tls, uintptr(0), __ccgo_ts, uint64(1), ps) + } + /* mbrtowc states for partial UTF-8 characters have the high bit set; + * we use nonzero states without high bit for pending surrogates. */ + if Int32FromUint32(**(**uint32)(__ccgo_up(pending))) > 0 { + if pc16 != 0 { + **(**Tchar16_t)(__ccgo_up(pc16)) = uint16(**(**uint32)(__ccgo_up(pending))) + } + **(**uint32)(__ccgo_up(pending)) = uint32(0) + return Uint64FromInt32(-Int32FromInt32(3)) + } + ret = Xmbrtowc(tls, bp, s, n, ps) + if ret <= uint64(4) { + if **(**Twchar_t)(__ccgo_up(bp)) >= uint32(0x10000) { + **(**uint32)(__ccgo_up(pending)) = **(**Twchar_t)(__ccgo_up(bp))&uint32(0x3ff) + uint32(0xdc00) + **(**Twchar_t)(__ccgo_up(bp)) = uint32(0xd7c0) + **(**Twchar_t)(__ccgo_up(bp))>>Int32FromInt32(10) + } + if pc16 != 0 { + **(**Tchar16_t)(__ccgo_up(pc16)) = uint16(**(**Twchar_t)(__ccgo_up(bp))) + } + } + return ret +} + +var _internal_state1 uint32 + +func Xmbrtoc32(tls *TLS, pc32 uintptr, s uintptr, n Tsize_t, ps uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v pc32=%v s=%v n=%v ps=%v, (%v:)", tls, pc32, s, n, ps, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ret Tsize_t + var _ /* wc at bp+0 */ Twchar_t + _ = ret + if !(ps != 0) { + ps = uintptr(unsafe.Pointer(&_internal_state2)) + } + if !(s != 0) { + return Xmbrtoc32(tls, uintptr(0), __ccgo_ts, uint64(1), ps) + } + ret = Xmbrtowc(tls, bp, s, n, ps) + if ret <= uint64(4) && pc32 != 0 { + **(**Tchar32_t)(__ccgo_up(pc32)) = **(**Twchar_t)(__ccgo_up(bp)) + } + return ret +} + +var _internal_state2 uint32 + +func Xmbrtowc(tls *TLS, wc uintptr, src uintptr, n Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v wc=%v src=%v n=%v st=%v, (%v:)", tls, wc, src, n, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var N Tsize_t + var c uint32 + var s, v3 uintptr + var v1 Twchar_t + var v2 int32 + var _ /* dummy at bp+0 */ Twchar_t + _, _, _, _, _, _ = N, c, s, v1, v2, v3 + s = src + N = n + if !(st != 0) { + st = uintptr(unsafe.Pointer(&_internal_state3)) + } + c = **(**uint32)(__ccgo_up(st)) + if !(s != 0) { + if c != 0 { + goto ilseq + } + return uint64(0) + } else { + if !(wc != 0) { + wc = bp + } + } + if !(n != 0) { + return Uint64FromInt32(-Int32FromInt32(2)) + } + if !(c != 0) { + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) < int32(0x80) { + v1 = uint32(**(**uint8)(__ccgo_up(s))) + **(**Twchar_t)(__ccgo_up(wc)) = v1 + return BoolUint64(!!(v1 != 0)) + } + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v2 = int32(4) + } else { + v2 = int32(1) + } + if v2 == int32(1) { + **(**Twchar_t)(__ccgo_up(wc)) = Uint32FromInt32(Int32FromInt32(0xdfff) & int32(Int8FromUint8(**(**uint8)(__ccgo_up(s))))) + return Uint64FromInt32(1) + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(0xc2) > Uint32FromUint32(0xf4)-Uint32FromUint32(0xc2) { + goto ilseq + } + v3 = s + s = s + 1 + c = X__fsmu8[uint32(**(**uint8)(__ccgo_up(v3)))-uint32(0xc2)] + n = n - 1 + } + if n != 0 { + if (Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)-int32(0x10)|(Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)+Int32FromUint32(c)>>Int32FromInt32(26))) & ^Int32FromInt32(7) != 0 { + goto ilseq + } + goto loop + loop: + ; + v3 = s + s = s + 1 + c = c<= uint32(0x40) { + goto ilseq + } + goto loop + } + } + **(**uint32)(__ccgo_up(st)) = c + return Uint64FromInt32(-Int32FromInt32(2)) + goto ilseq +ilseq: + ; + **(**uint32)(__ccgo_up(st)) = uint32(0) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + return Uint64FromInt32(-Int32FromInt32(1)) +} + +var _internal_state3 uint32 + +func Xmbsinit(tls *TLS, st uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v st=%v, (%v:)", tls, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(!(st != 0) || !(**(**uint32)(__ccgo_up(st)) != 0)) +} + +func Xmbsnrtowcs(tls *TLS, wcs uintptr, src uintptr, n Tsize_t, wn Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v wcs=%v src=%v n=%v wn=%v st=%v, (%v:)", tls, wcs, src, n, wn, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(1040) + defer tls.Free(1040) + var cnt, l, n2, v1 Tsize_t + var tmp_s, ws uintptr + var v2 bool + var v3 uint64 + var _ /* s at bp+1024 */ uintptr + var _ /* wbuf at bp+0 */ [256]Twchar_t + _, _, _, _, _, _, _, _ = cnt, l, n2, tmp_s, ws, v1, v2, v3 + cnt = uint64(0) + **(**uintptr)(__ccgo_up(bp + 1024)) = **(**uintptr)(__ccgo_up(src)) + if !(wcs != 0) { + ws = bp + wn = Uint64FromInt64(1024) / Uint64FromInt64(4) + } else { + ws = wcs + } + /* making sure output buffer size is at most n/4 will ensure + * that mbsrtowcs never reads more than n input bytes. thus + * we can use mbsrtowcs as long as it's practical.. */ + for { + if v2 = **(**uintptr)(__ccgo_up(bp + 1024)) != 0 && wn != 0; v2 { + v1 = n / Uint64FromInt32(4) + n2 = v1 + } + if !(v2 && (v1 >= wn || n2 > uint64(32))) { + break + } + if n2 >= wn { + n2 = wn + } + tmp_s = **(**uintptr)(__ccgo_up(bp + 1024)) + l = Xmbsrtowcs(tls, ws, bp+1024, n2, st) + if !(l+Uint64FromInt32(1) != 0) { + cnt = l + wn = uint64(0) + break + } + if ws != bp { + ws = ws + uintptr(l)*4 + wn = wn - l + } + if **(**uintptr)(__ccgo_up(bp + 1024)) != 0 { + v3 = n - Uint64FromInt64(int64(**(**uintptr)(__ccgo_up(bp + 1024)))-int64(tmp_s)) + } else { + v3 = uint64(0) + } + n = v3 + cnt = cnt + l + } + if **(**uintptr)(__ccgo_up(bp + 1024)) != 0 { + for wn != 0 && n != 0 { + l = Xmbrtowc(tls, ws, **(**uintptr)(__ccgo_up(bp + 1024)), n, st) + if l+uint64(2) <= uint64(2) { + if !(l+Uint64FromInt32(1) != 0) { + cnt = l + break + } + if !(l != 0) { + **(**uintptr)(__ccgo_up(bp + 1024)) = uintptr(0) + break + } + /* have to roll back partial character */ + **(**uint32)(__ccgo_up(st)) = uint32(0) + break + } + **(**uintptr)(__ccgo_up(bp + 1024)) = **(**uintptr)(__ccgo_up(bp + 1024)) + uintptr(l) + n = n - l + /* safe - this loop runs fewer than sizeof(wbuf)/8 times */ + ws += 4 + wn = wn - 1 + cnt = cnt + 1 + } + } + if wcs != 0 { + **(**uintptr)(__ccgo_up(src)) = **(**uintptr)(__ccgo_up(bp + 1024)) + } + return cnt +} + +func Xmbsrtowcs(tls *TLS, ws uintptr, src uintptr, wn Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v ws=%v src=%v wn=%v st=%v, (%v:)", tls, ws, src, wn, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c, v1 uint32 + var s, v5, v6 uintptr + var wn0 Tsize_t + var v2 bool + var v3 int32 + _, _, _, _, _, _, _, _ = c, s, wn0, v1, v2, v3, v5, v6 + s = **(**uintptr)(__ccgo_up(src)) + wn0 = wn + c = uint32(0) + if v2 = st != 0; v2 { + v1 = **(**uint32)(__ccgo_up(st)) + c = v1 + } + if v2 && v1 != 0 { + if ws != 0 { + **(**uint32)(__ccgo_up(st)) = uint32(0) + goto resume + } else { + goto resume0 + } + } + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v3 = int32(4) + } else { + v3 = int32(1) + } + if v3 == int32(1) { + if !(ws != 0) { + return _strlen(tls, s) + } + for { + if !(wn != 0) { + **(**uintptr)(__ccgo_up(src)) = s + return wn0 + } + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + v5 = s + s = s + 1 + c = uint32(**(**uint8)(__ccgo_up(v5))) + v5 = ws + ws += 4 + **(**Twchar_t)(__ccgo_up(v5)) = Uint32FromInt32(Int32FromInt32(0xdfff) & int32(Int8FromUint32(c))) + wn = wn - 1 + goto _4 + _4: + } + **(**Twchar_t)(__ccgo_up(ws)) = uint32(0) + **(**uintptr)(__ccgo_up(src)) = uintptr(0) + return wn0 - wn + } + if !!(ws != 0) { + goto _7 + } +_11: + ; + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(1) < uint32(0x7f) && uint64(s)%uint64(4) == uint64(0) { + for !((**(**uint32)(__ccgo_up(s))|(**(**uint32)(__ccgo_up(s))-Uint32FromInt32(0x01010101)))&Uint32FromUint32(0x80808080) != 0) { + s = s + uintptr(4) + wn = wn - uint64(4) + } + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(1) < uint32(0x7f) { + s = s + 1 + wn = wn - 1 + goto _10 + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(0xc2) > Uint32FromUint32(0xf4)-Uint32FromUint32(0xc2) { + goto _9 + } + v5 = s + s = s + 1 + c = X__fsmu8[uint32(**(**uint8)(__ccgo_up(v5)))-uint32(0xc2)] + goto resume0 +resume0: + ; + if (Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)-int32(0x10)|(Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)+Int32FromUint32(c)>>Int32FromInt32(26))) & ^Int32FromInt32(7) != 0 { + s = s - 1 + goto _9 + } + s = s + 1 + if c&(Uint32FromUint32(1)<= uint32(0x40) { + s = s - uintptr(2) + goto _9 + } + s = s + 1 + if c&(Uint32FromUint32(1)<= uint32(0x40) { + s = s - uintptr(3) + goto _9 + } + s = s + 1 + } + } + wn = wn - 1 + c = uint32(0) + goto _10 +_10: + ; + goto _11 + goto _9 +_9: + ; + goto _8 +_7: + ; +_15: + ; + if !(wn != 0) { + **(**uintptr)(__ccgo_up(src)) = s + return wn0 + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(1) < uint32(0x7f) && uint64(s)%uint64(4) == uint64(0) { + for wn >= uint64(5) && !((**(**uint32)(__ccgo_up(s))|(**(**uint32)(__ccgo_up(s))-Uint32FromInt32(0x01010101)))&Uint32FromUint32(0x80808080) != 0) { + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = uint32(**(**uint8)(__ccgo_up(v6))) + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = uint32(**(**uint8)(__ccgo_up(v6))) + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = uint32(**(**uint8)(__ccgo_up(v6))) + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = uint32(**(**uint8)(__ccgo_up(v6))) + wn = wn - uint64(4) + } + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(1) < uint32(0x7f) { + v5 = ws + ws += 4 + v6 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(v5)) = uint32(**(**uint8)(__ccgo_up(v6))) + wn = wn - 1 + goto _14 + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(0xc2) > Uint32FromUint32(0xf4)-Uint32FromUint32(0xc2) { + goto _13 + } + v5 = s + s = s + 1 + c = X__fsmu8[uint32(**(**uint8)(__ccgo_up(v5)))-uint32(0xc2)] + goto resume +resume: + ; + if (Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)-int32(0x10)|(Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)+Int32FromUint32(c)>>Int32FromInt32(26))) & ^Int32FromInt32(7) != 0 { + s = s - 1 + goto _13 + } + v5 = s + s = s + 1 + c = c<= uint32(0x40) { + s = s - uintptr(2) + goto _13 + } + v5 = s + s = s + 1 + c = c<= uint32(0x40) { + s = s - uintptr(3) + goto _13 + } + v5 = s + s = s + 1 + c = c< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _s + return Xmbsrtowcs(tls, ws, bp, wn, uintptr(0)) +} + +func Xmbtowc(tls *TLS, wc uintptr, src uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v wc=%v src=%v n=%v, (%v:)", tls, wc, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c uint32 + var s, v3 uintptr + var v1 Twchar_t + var v2 int32 + var _ /* dummy at bp+0 */ Twchar_t + _, _, _, _, _ = c, s, v1, v2, v3 + s = src + if !(s != 0) { + return 0 + } + if !(n != 0) { + goto ilseq + } + if !(wc != 0) { + wc = bp + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) < int32(0x80) { + v1 = uint32(**(**uint8)(__ccgo_up(s))) + **(**Twchar_t)(__ccgo_up(wc)) = v1 + return BoolInt32(!!(v1 != 0)) + } + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v2 = int32(4) + } else { + v2 = int32(1) + } + if v2 == int32(1) { + **(**Twchar_t)(__ccgo_up(wc)) = Uint32FromInt32(Int32FromInt32(0xdfff) & int32(Int8FromUint8(**(**uint8)(__ccgo_up(s))))) + return Int32FromInt32(1) + } + if uint32(**(**uint8)(__ccgo_up(s)))-uint32(0xc2) > Uint32FromUint32(0xf4)-Uint32FromUint32(0xc2) { + goto ilseq + } + v3 = s + s = s + 1 + c = X__fsmu8[uint32(**(**uint8)(__ccgo_up(v3)))-uint32(0xc2)] + /* Avoid excessive checks against n: If shifting the state n-1 + * times does not clear the high bit, then the value of n is + * insufficient to read a character */ + if n < uint64(4) && c<<(uint64(6)*n-uint64(6))&(Uint32FromUint32(1)<>int32(3)-int32(0x10)|(Int32FromUint8(**(**uint8)(__ccgo_up(s)))>>int32(3)+Int32FromUint32(c)>>Int32FromInt32(26))) & ^Int32FromInt32(7) != 0 { + goto ilseq + } + v3 = s + s = s + 1 + c = c<= uint32(0x40) { + goto ilseq + } + v3 = s + s = s + 1 + c = c<= uint32(0x40) { + goto ilseq + } + v3 = s + s = s + 1 + **(**Twchar_t)(__ccgo_up(wc)) = c< %v", r) }() + } + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + if !(s != 0) { + return uint64(1) + } + if wc < uint32(0x80) { + **(**uint8)(__ccgo_up(s)) = uint8(wc) + return uint64(1) + } else { + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v1 = int32(4) + } else { + v1 = int32(1) + } + if v1 == int32(1) { + if !(wc-Uint32FromInt32(0xdf80) < Uint32FromInt32(0x80)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + return Uint64FromInt32(-Int32FromInt32(1)) + } + **(**uint8)(__ccgo_up(s)) = uint8(wc) + return uint64(1) + } else { + if wc < uint32(0x800) { + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(uint32(0xc0) | wc>>Int32FromInt32(6)) + **(**uint8)(__ccgo_up(s)) = uint8(uint32(0x80) | wc&uint32(0x3f)) + return uint64(2) + } else { + if wc < uint32(0xd800) || wc-uint32(0xe000) < uint32(0x2000) { + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(uint32(0xe0) | wc>>Int32FromInt32(12)) + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(uint32(0x80) | wc>>Int32FromInt32(6)&uint32(0x3f)) + **(**uint8)(__ccgo_up(s)) = uint8(uint32(0x80) | wc&uint32(0x3f)) + return uint64(3) + } else { + if wc-uint32(0x10000) < uint32(0x100000) { + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(uint32(0xf0) | wc>>Int32FromInt32(18)) + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(uint32(0x80) | wc>>Int32FromInt32(12)&uint32(0x3f)) + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(uint32(0x80) | wc>>Int32FromInt32(6)&uint32(0x3f)) + **(**uint8)(__ccgo_up(s)) = uint8(uint32(0x80) | wc&uint32(0x3f)) + return uint64(4) + } + } + } + } + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + return Uint64FromInt32(-Int32FromInt32(1)) +} + +func Xwcsnrtombs(tls *TLS, dst uintptr, wcs uintptr, wn Tsize_t, n Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v dst=%v wcs=%v wn=%v n=%v st=%v, (%v:)", tls, dst, wcs, wn, n, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var cnt, l Tsize_t + var ws, v1 uintptr + var _ /* tmp at bp+0 */ [4]uint8 + _, _, _, _ = cnt, l, ws, v1 + ws = **(**uintptr)(__ccgo_up(wcs)) + cnt = uint64(0) + if !(dst != 0) { + n = uint64(0) + } + for ws != 0 && wn != 0 { + if n < uint64(MB_LEN_MAX) { + v1 = bp + } else { + v1 = dst + } + l = Xwcrtomb(tls, v1, **(**Twchar_t)(__ccgo_up(ws)), uintptr(0)) + if l == Uint64FromInt32(-Int32FromInt32(1)) { + cnt = Uint64FromInt32(-Int32FromInt32(1)) + break + } + if dst != 0 { + if n < uint64(MB_LEN_MAX) { + if l > n { + break + } + Xmemcpy(tls, dst, bp, l) + } + dst = dst + uintptr(l) + n = n - l + } + if !(**(**Twchar_t)(__ccgo_up(ws)) != 0) { + ws = uintptr(0) + break + } + ws += 4 + wn = wn - 1 + cnt = cnt + l + } + if dst != 0 { + **(**uintptr)(__ccgo_up(wcs)) = ws + } + return cnt +} + +func Xwcsrtombs(tls *TLS, s uintptr, ws uintptr, n Tsize_t, st uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v ws=%v n=%v st=%v, (%v:)", tls, s, ws, n, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var N, l Tsize_t + var ws2, v2 uintptr + var _ /* buf at bp+0 */ [4]uint8 + _, _, _, _ = N, l, ws2, v2 + N = n + if !(s != 0) { + n = uint64(0) + ws2 = **(**uintptr)(__ccgo_up(ws)) + for { + if !(**(**Twchar_t)(__ccgo_up(ws2)) != 0) { + break + } + if **(**Twchar_t)(__ccgo_up(ws2)) >= uint32(0x80) { + l = Xwcrtomb(tls, bp, **(**Twchar_t)(__ccgo_up(ws2)), uintptr(0)) + if !(l+Uint64FromInt32(1) != 0) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + n = n + l + } else { + n = n + 1 + } + goto _1 + _1: + ; + ws2 += 4 + } + return n + } + for n >= uint64(4) { + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws))))-uint32(1) >= uint32(0x7f) { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))) != 0) { + **(**uint8)(__ccgo_up(s)) = uint8(0) + **(**uintptr)(__ccgo_up(ws)) = uintptr(0) + return N - n + } + l = Xwcrtomb(tls, s, **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))), uintptr(0)) + if !(l+Uint64FromInt32(1) != 0) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + s = s + uintptr(l) + n = n - l + } else { + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws))))) + n = n - 1 + } + **(**uintptr)(__ccgo_up(ws)) += 4 + } + for n != 0 { + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws))))-uint32(1) >= uint32(0x7f) { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))) != 0) { + **(**uint8)(__ccgo_up(s)) = uint8(0) + **(**uintptr)(__ccgo_up(ws)) = uintptr(0) + return N - n + } + l = Xwcrtomb(tls, bp, **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))), uintptr(0)) + if !(l+Uint64FromInt32(1) != 0) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + if l > n { + return N - n + } + Xwcrtomb(tls, s, **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws)))), uintptr(0)) + s = s + uintptr(l) + n = n - l + } else { + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(ws))))) + n = n - 1 + } + **(**uintptr)(__ccgo_up(ws)) += 4 + } + return N +} + +func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v ws=%v n=%v, (%v:)", tls, s, ws, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = ws + return Xwcsrtombs(tls, s, bp, n, uintptr(0)) +} + +func Xwctob(tls *TLS, c Twint_t) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if c < uint32(128) { + return Int32FromUint32(c) + } + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v1 = int32(4) + } else { + v1 = int32(1) + } + if v1 == int32(1) && c-uint32(0xdf80) < uint32(0x80) { + return Int32FromUint8(uint8(c)) + } + return -int32(1) +} + +func Xwctomb(tls *TLS, s uintptr, wc Twchar_t) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v wc=%v, (%v:)", tls, s, wc, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !(s != 0) { + return 0 + } + return Int32FromUint64(Xwcrtomb(tls, s, wc, uintptr(0))) +} + +func Xaccept(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_accept) + _ = int32(__SC_accept) + v2 = int64(fd) + v3 = int64(addr) + v4 = int64(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +type Tucred = struct { + Fpid Tpid_t + Fuid Tuid_t + Fgid Tgid_t +} + +type Tmmsghdr = struct { + Fmsg_hdr Tmsghdr + Fmsg_len uint32 +} + +func Xaccept4(tls *TLS, fd int32, addr uintptr, len1 uintptr, flg int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v flg=%v, (%v:)", tls, fd, addr, len1, flg, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var ret, v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _, _ = r, ret, v1, v2, v3, v4, v5, v6, v7, v8 + if !(flg != 0) { + return Xaccept(tls, fd, addr, len1) + } + v1 = int32(SYS_accept4) + _ = int32(__SC_accept4) + v2 = int64(fd) + v3 = int64(addr) + v4 = int64(len1) + v5 = int64(flg) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + ret = int32(X__syscall_ret(tls, Uint64FromInt64(v8))) + if ret >= 0 || **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(ENOSYS) && **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(EINVAL) { + return ret + } + if flg & ^(Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + ret = Xaccept(tls, fd, addr, len1) + if ret < 0 { + return ret + } + if flg&int32(SOCK_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if flg&int32(SOCK_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(ret), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + return ret +} + +func Xbind(tls *TLS, fd int32, addr uintptr, len1 Tsocklen_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_bind) + _ = int32(__SC_bind) + v2 = int64(fd) + v3 = int64(addr) + v4 = Int64FromUint32(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func Xconnect(tls *TLS, fd int32, addr uintptr, len1 Tsocklen_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_connect) + _ = int32(__SC_connect) + v2 = int64(fd) + v3 = int64(addr) + v4 = Int64FromUint32(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +const ADD = 0 +const C_ANY = 0 +const C_CHAOS = 0 +const C_HS = 0 +const C_IN = 0 +const C_NONE = 0 +const DELETE = 0 +const FORMERR = 0 +const GETLONG = 0 +const GETSHORT = 0 +const HFIXEDSZ = 12 +const IN6ADDRSZ = 16 +const INADDRSZ = 4 +const INDIR_MASK = 192 +const INET6_ADDRSTRLEN = 46 +const INET_ADDRSTRLEN = 16 +const INT16SZ = 2 +const INT32SZ = 4 +const INT8SZ = 1 +const IN_CLASSA_HOST = 16777215 +const IN_CLASSA_MAX = 128 +const IN_CLASSA_NET = 4278190080 +const IN_CLASSA_NSHIFT = 24 +const IN_CLASSB_HOST = 65535 +const IN_CLASSB_MAX = 65536 +const IN_CLASSB_NET = 4294901760 +const IN_CLASSB_NSHIFT = 16 +const IN_CLASSC_HOST = 255 +const IN_CLASSC_NET = 4294967040 +const IN_CLASSC_NSHIFT = 8 +const IN_LOOPBACKNET = 127 +const IPPORT_RESERVED = 1024 +const IPPROTO_AH = 51 +const IPPROTO_BEETPH = 94 +const IPPROTO_COMP = 108 +const IPPROTO_DCCP = 33 +const IPPROTO_DSTOPTS = 60 +const IPPROTO_EGP = 8 +const IPPROTO_ENCAP = 98 +const IPPROTO_ESP = 50 +const IPPROTO_ETHERNET = 143 +const IPPROTO_FRAGMENT = 44 +const IPPROTO_GRE = 47 +const IPPROTO_HOPOPTS = 0 +const IPPROTO_ICMP = 1 +const IPPROTO_ICMPV6 = 58 +const IPPROTO_IDP = 22 +const IPPROTO_IGMP = 2 +const IPPROTO_IP = 0 +const IPPROTO_IPIP = 4 +const IPPROTO_IPV6 = 41 +const IPPROTO_MAX = 263 +const IPPROTO_MH = 135 +const IPPROTO_MPLS = 137 +const IPPROTO_MPTCP = 262 +const IPPROTO_MTP = 92 +const IPPROTO_NONE = 59 +const IPPROTO_PIM = 103 +const IPPROTO_PUP = 12 +const IPPROTO_RAW = 255 +const IPPROTO_ROUTING = 43 +const IPPROTO_RSVP = 46 +const IPPROTO_SCTP = 132 +const IPPROTO_TCP = 6 +const IPPROTO_TP = 29 +const IPPROTO_UDP = 17 +const IPPROTO_UDPLITE = 136 +const IPV6_2292DSTOPTS = 4 +const IPV6_2292HOPLIMIT = 8 +const IPV6_2292HOPOPTS = 3 +const IPV6_2292PKTINFO = 2 +const IPV6_2292PKTOPTIONS = 6 +const IPV6_2292RTHDR = 5 +const IPV6_ADDRFORM = 1 +const IPV6_ADDR_PREFERENCES = 72 +const IPV6_ADD_MEMBERSHIP = 20 +const IPV6_AUTHHDR = 10 +const IPV6_AUTOFLOWLABEL = 70 +const IPV6_CHECKSUM = 7 +const IPV6_DONTFRAG = 62 +const IPV6_DROP_MEMBERSHIP = 21 +const IPV6_DSTOPTS = 59 +const IPV6_FREEBIND = 78 +const IPV6_HDRINCL = 36 +const IPV6_HOPLIMIT = 52 +const IPV6_HOPOPTS = 54 +const IPV6_IPSEC_POLICY = 34 +const IPV6_JOIN_ANYCAST = 27 +const IPV6_JOIN_GROUP = 20 +const IPV6_LEAVE_ANYCAST = 28 +const IPV6_LEAVE_GROUP = 21 +const IPV6_MINHOPCOUNT = 73 +const IPV6_MTU = 24 +const IPV6_MTU_DISCOVER = 23 +const IPV6_MULTICAST_ALL = 29 +const IPV6_MULTICAST_HOPS = 18 +const IPV6_MULTICAST_IF = 17 +const IPV6_MULTICAST_LOOP = 19 +const IPV6_NEXTHOP = 9 +const IPV6_ORIGDSTADDR = 74 +const IPV6_PATHMTU = 61 +const IPV6_PKTINFO = 50 +const IPV6_PMTUDISC_DO = 2 +const IPV6_PMTUDISC_DONT = 0 +const IPV6_PMTUDISC_INTERFACE = 4 +const IPV6_PMTUDISC_OMIT = 5 +const IPV6_PMTUDISC_PROBE = 3 +const IPV6_PMTUDISC_WANT = 1 +const IPV6_PREFER_SRC_CGA = 8 +const IPV6_PREFER_SRC_COA = 4 +const IPV6_PREFER_SRC_HOME = 1024 +const IPV6_PREFER_SRC_NONCGA = 2048 +const IPV6_PREFER_SRC_PUBLIC = 2 +const IPV6_PREFER_SRC_PUBTMP_DEFAULT = 256 +const IPV6_PREFER_SRC_TMP = 1 +const IPV6_RECVDSTOPTS = 58 +const IPV6_RECVERR = 25 +const IPV6_RECVFRAGSIZE = 77 +const IPV6_RECVHOPLIMIT = 51 +const IPV6_RECVHOPOPTS = 53 +const IPV6_RECVORIGDSTADDR = 74 +const IPV6_RECVPATHMTU = 60 +const IPV6_RECVPKTINFO = 49 +const IPV6_RECVRTHDR = 56 +const IPV6_RECVTCLASS = 66 +const IPV6_ROUTER_ALERT = 22 +const IPV6_ROUTER_ALERT_ISOLATE = 30 +const IPV6_RTHDR = 57 +const IPV6_RTHDRDSTOPTS = 55 +const IPV6_RTHDR_LOOSE = 0 +const IPV6_RTHDR_STRICT = 1 +const IPV6_RTHDR_TYPE_0 = 0 +const IPV6_RXDSTOPTS = 59 +const IPV6_RXHOPOPTS = 54 +const IPV6_TCLASS = 67 +const IPV6_TRANSPARENT = 75 +const IPV6_UNICAST_HOPS = 16 +const IPV6_UNICAST_IF = 76 +const IPV6_V6ONLY = 26 +const IPV6_XFRM_POLICY = 35 +const IP_ADD_MEMBERSHIP = 35 +const IP_ADD_SOURCE_MEMBERSHIP = 39 +const IP_BIND_ADDRESS_NO_PORT = 24 +const IP_BLOCK_SOURCE = 38 +const IP_CHECKSUM = 23 +const IP_DEFAULT_MULTICAST_LOOP = 1 +const IP_DEFAULT_MULTICAST_TTL = 1 +const IP_DROP_MEMBERSHIP = 36 +const IP_DROP_SOURCE_MEMBERSHIP = 40 +const IP_FREEBIND = 15 +const IP_HDRINCL = 3 +const IP_IPSEC_POLICY = 16 +const IP_MAX_MEMBERSHIPS = 20 +const IP_MINTTL = 21 +const IP_MSFILTER = 41 +const IP_MTU = 14 +const IP_MTU_DISCOVER = 10 +const IP_MULTICAST_ALL = 49 +const IP_MULTICAST_IF = 32 +const IP_MULTICAST_LOOP = 34 +const IP_MULTICAST_TTL = 33 +const IP_NODEFRAG = 22 +const IP_OPTIONS = 4 +const IP_ORIGDSTADDR = 20 +const IP_PASSSEC = 18 +const IP_PKTINFO = 8 +const IP_PKTOPTIONS = 9 +const IP_PMTUDISC = 10 +const IP_PMTUDISC_DO = 2 +const IP_PMTUDISC_DONT = 0 +const IP_PMTUDISC_INTERFACE = 4 +const IP_PMTUDISC_OMIT = 5 +const IP_PMTUDISC_PROBE = 3 +const IP_PMTUDISC_WANT = 1 +const IP_RECVERR = 11 +const IP_RECVERR_RFC4884 = 26 +const IP_RECVFRAGSIZE = 25 +const IP_RECVOPTS = 6 +const IP_RECVORIGDSTADDR = 20 +const IP_RECVRETOPTS = 7 +const IP_RECVTOS = 13 +const IP_RECVTTL = 12 +const IP_RETOPTS = 7 +const IP_ROUTER_ALERT = 5 +const IP_TOS = 1 +const IP_TRANSPARENT = 19 +const IP_TTL = 2 +const IP_UNBLOCK_SOURCE = 37 +const IP_UNICAST_IF = 50 +const IP_XFRM_POLICY = 17 +const IQUERY = 0 +const LOCALDOMAINPARTS = 2 +const MAXCDNAME = 255 +const MAXDFLSRCH = 3 +const MAXDNAME = 1025 +const MAXDNSRCH = 6 +const MAXLABEL = 63 +const MAXNS = 3 +const MAXRESOLVSORT = 10 +const NAMESERVER_PORT = 53 +const NOERROR = 0 +const NOTAUTH = 0 +const NOTIMP = 0 +const NOTZONE = 0 +const NS_ALG_DH = 2 +const NS_ALG_DSA = 3 +const NS_ALG_DSS = 3 +const NS_ALG_EXPIRE_ONLY = 253 +const NS_ALG_MD5RSA = 1 +const NS_ALG_PRIVATE_OID = 254 +const NS_CMPRSFLGS = 192 +const NS_DEFAULTPORT = 53 +const NS_DSA_MAX_BYTES = 405 +const NS_DSA_MIN_SIZE = 213 +const NS_DSA_SIG_SIZE = 41 +const NS_HFIXEDSZ = 12 +const NS_IN6ADDRSZ = 16 +const NS_INADDRSZ = 4 +const NS_INT16SZ = 2 +const NS_INT32SZ = 4 +const NS_INT8SZ = 1 +const NS_KEY_EXTENDED_FLAGS = 4096 +const NS_KEY_NAME_ENTITY = 512 +const NS_KEY_NAME_RESERVED = 768 +const NS_KEY_NAME_TYPE = 768 +const NS_KEY_NAME_USER = 0 +const NS_KEY_NAME_ZONE = 256 +const NS_KEY_NO_AUTH = 32768 +const NS_KEY_NO_CONF = 16384 +const NS_KEY_PROT_ANY = 255 +const NS_KEY_PROT_DNSSEC = 3 +const NS_KEY_PROT_EMAIL = 2 +const NS_KEY_PROT_IPSEC = 4 +const NS_KEY_PROT_TLS = 1 +const NS_KEY_RESERVED10 = 32 +const NS_KEY_RESERVED11 = 16 +const NS_KEY_RESERVED2 = 8192 +const NS_KEY_RESERVED4 = 2048 +const NS_KEY_RESERVED5 = 1024 +const NS_KEY_RESERVED8 = 128 +const NS_KEY_RESERVED9 = 64 +const NS_KEY_RESERVED_BITMASK = 11504 +const NS_KEY_RESERVED_BITMASK2 = 65535 +const NS_KEY_SIGNATORYMASK = 15 +const NS_KEY_TYPEMASK = 49152 +const NS_KEY_TYPE_AUTH_CONF = 0 +const NS_KEY_TYPE_AUTH_ONLY = 16384 +const NS_KEY_TYPE_CONF_ONLY = 32768 +const NS_KEY_TYPE_NO_KEY = 49152 +const NS_MAXCDNAME = 255 +const NS_MAXDNAME = 1025 +const NS_MAXLABEL = 63 +const NS_MAXMSG = 65535 +const NS_MD5RSA_MAX_BASE64 = 10928 +const NS_MD5RSA_MAX_BITS = 4096 +const NS_MD5RSA_MAX_BYTES = 8195 +const NS_MD5RSA_MAX_SIZE = 512 +const NS_MD5RSA_MIN_BITS = 512 +const NS_MD5RSA_MIN_SIZE = 64 +const NS_NOTIFY_OP = 0 +const NS_NXT_BITS = 8 +const NS_NXT_MAX = 127 +const NS_OPT_DNSSEC_OK = 32768 +const NS_OPT_NSID = 3 +const NS_PACKETSZ = 512 +const NS_QFIXEDSZ = 4 +const NS_RRFIXEDSZ = 10 +const NS_SIG_ALG = 2 +const NS_SIG_EXPIR = 8 +const NS_SIG_FOOT = 16 +const NS_SIG_LABELS = 3 +const NS_SIG_OTTL = 4 +const NS_SIG_SIGNED = 12 +const NS_SIG_SIGNER = 18 +const NS_SIG_TYPE = 0 +const NS_TSIG_ALG_HMAC_MD5 = "HMAC-MD5.SIG-ALG.REG.INT" +const NS_TSIG_ERROR_FORMERR = -12 +const NS_TSIG_ERROR_NO_SPACE = -11 +const NS_TSIG_ERROR_NO_TSIG = -10 +const NS_TSIG_FUDGE = 300 +const NS_TSIG_TCP_COUNT = 100 +const NS_UPDATE_OP = 0 +const NXDOMAIN = 0 +const NXRRSET = 0 +const PACKETSZ = 512 +const PRIX16 = "X" +const PRIX32 = "X" +const PRIX8 = "X" +const PRIXFAST16 = "X" +const PRIXFAST32 = "X" +const PRIXFAST8 = "X" +const PRIXLEAST16 = "X" +const PRIXLEAST32 = "X" +const PRIXLEAST8 = "X" +const PRId16 = "d" +const PRId32 = "d" +const PRId8 = "d" +const PRIdFAST16 = "d" +const PRIdFAST32 = "d" +const PRIdFAST8 = "d" +const PRIdLEAST16 = "d" +const PRIdLEAST32 = "d" +const PRIdLEAST8 = "d" +const PRIi16 = "i" +const PRIi32 = "i" +const PRIi8 = "i" +const PRIiFAST16 = "i" +const PRIiFAST32 = "i" +const PRIiFAST8 = "i" +const PRIiLEAST16 = "i" +const PRIiLEAST32 = "i" +const PRIiLEAST8 = "i" +const PRIo16 = "o" +const PRIo32 = "o" +const PRIo8 = "o" +const PRIoFAST16 = "o" +const PRIoFAST32 = "o" +const PRIoFAST8 = "o" +const PRIoLEAST16 = "o" +const PRIoLEAST32 = "o" +const PRIoLEAST8 = "o" +const PRIu16 = "u" +const PRIu32 = "u" +const PRIu8 = "u" +const PRIuFAST16 = "u" +const PRIuFAST32 = "u" +const PRIuFAST8 = "u" +const PRIuLEAST16 = "u" +const PRIuLEAST32 = "u" +const PRIuLEAST8 = "u" +const PRIx16 = "x" +const PRIx32 = "x" +const PRIx8 = "x" +const PRIxFAST16 = "x" +const PRIxFAST32 = "x" +const PRIxFAST8 = "x" +const PRIxLEAST16 = "x" +const PRIxLEAST32 = "x" +const PRIxLEAST8 = "x" +const PUTLONG = 0 +const PUTSHORT = 0 +const QFIXEDSZ = 4 +const QUERY = 0 +const REFUSED = 0 +const RES_AAONLY = 4 +const RES_BLAST = 131072 +const RES_DEBUG = 2 +const RES_DEFAULT = 524992 +const RES_DEFNAMES = 128 +const RES_DFLRETRY = 2 +const RES_DNSRCH = 512 +const RES_EXHAUSTIVE = 1 +const RES_F_CONN = 2 +const RES_F_EDNS0ERR = 4 +const RES_F_VC = 1 +const RES_IGNTC = 32 +const RES_INIT = 1 +const RES_INSECURE1 = 1024 +const RES_INSECURE2 = 2048 +const RES_KEEPTSIG = 65536 +const RES_MAXNDOTS = 15 +const RES_MAXRETRANS = 30 +const RES_MAXRETRY = 5 +const RES_MAXTIME = 65535 +const RES_NOALIASES = 4096 +const RES_NOCHECKNAME = 32768 +const RES_NOIP6DOTINT = 524288 +const RES_PRF_ADD = 128 +const RES_PRF_ANS = 32 +const RES_PRF_AUTH = 64 +const RES_PRF_CLASS = 4 +const RES_PRF_CMD = 8 +const RES_PRF_HEAD1 = 256 +const RES_PRF_HEAD2 = 512 +const RES_PRF_HEADX = 2048 +const RES_PRF_INIT = 16384 +const RES_PRF_QUERY = 4096 +const RES_PRF_QUES = 16 +const RES_PRF_REPLY = 8192 +const RES_PRF_STATS = 1 +const RES_PRF_TTLID = 1024 +const RES_PRF_UPDATE = 2 +const RES_PRIMARY = 16 +const RES_RECURSE = 64 +const RES_ROTATE = 16384 +const RES_SNGLKUP = 2097152 +const RES_SNGLKUPREOP = 4194304 +const RES_STAYOPEN = 256 +const RES_TIMEOUT = 5 +const RES_USEBSTRING = 262144 +const RES_USEVC = 8 +const RES_USE_DNSSEC = 8388608 +const RES_USE_EDNS0 = 1048576 +const RES_USE_INET6 = 8192 +const RRFIXEDSZ = 10 +const SCNd16 = "hd" +const SCNd32 = "d" +const SCNd8 = "hhd" +const SCNdFAST16 = "d" +const SCNdFAST32 = "d" +const SCNdFAST8 = "hhd" +const SCNdLEAST16 = "hd" +const SCNdLEAST32 = "d" +const SCNdLEAST8 = "hhd" +const SCNi16 = "hi" +const SCNi32 = "i" +const SCNi8 = "hhi" +const SCNiFAST16 = "i" +const SCNiFAST32 = "i" +const SCNiFAST8 = "hhi" +const SCNiLEAST16 = "hi" +const SCNiLEAST32 = "i" +const SCNiLEAST8 = "hhi" +const SCNo16 = "ho" +const SCNo32 = "o" +const SCNo8 = "hho" +const SCNoFAST16 = "o" +const SCNoFAST32 = "o" +const SCNoFAST8 = "hho" +const SCNoLEAST16 = "ho" +const SCNoLEAST32 = "o" +const SCNoLEAST8 = "hho" +const SCNu16 = "hu" +const SCNu32 = "u" +const SCNu8 = "hhu" +const SCNuFAST16 = "u" +const SCNuFAST32 = "u" +const SCNuFAST8 = "hhu" +const SCNuLEAST16 = "hu" +const SCNuLEAST32 = "u" +const SCNuLEAST8 = "hhu" +const SCNx16 = "hx" +const SCNx32 = "x" +const SCNx8 = "hhx" +const SCNxFAST16 = "x" +const SCNxFAST32 = "x" +const SCNxFAST8 = "hhx" +const SCNxLEAST16 = "hx" +const SCNxLEAST32 = "x" +const SCNxLEAST8 = "hhx" +const SERVFAIL = 0 +const STATUS = 0 +const S_ADDT = 0 +const S_PREREQ = 0 +const S_UPDATE = 0 +const S_ZONE = 0 +const T_A = 0 +const T_A6 = 0 +const T_AAAA = 0 +const T_AFSDB = 0 +const T_ANY = 0 +const T_ATMA = 0 +const T_AVC = 0 +const T_AXFR = 0 +const T_CAA = 0 +const T_CDNSKEY = 0 +const T_CDS = 0 +const T_CNAME = 0 +const T_CSYNC = 0 +const T_DHCID = 0 +const T_DLV = 0 +const T_DNAME = 0 +const T_DNSKEY = 0 +const T_DS = 0 +const T_EID = 0 +const T_EUI48 = 0 +const T_EUI64 = 0 +const T_GID = 0 +const T_GPOS = 0 +const T_HINFO = 0 +const T_HIP = 0 +const T_IPSECKEY = 0 +const T_ISDN = 0 +const T_IXFR = 0 +const T_KEY = 0 +const T_L32 = 0 +const T_L64 = 0 +const T_LOC = 0 +const T_LP = 0 +const T_MAILA = 0 +const T_MAILB = 0 +const T_MB = 0 +const T_MD = 0 +const T_MF = 0 +const T_MG = 0 +const T_MINFO = 0 +const T_MR = 0 +const T_MX = 0 +const T_NAPTR = 0 +const T_NID = 0 +const T_NIMLOC = 0 +const T_NINFO = 0 +const T_NS = 0 +const T_NSAP = 0 +const T_NSAP_PTR = 0 +const T_NSEC = 0 +const T_NSEC3 = 0 +const T_NSEC3PARAM = 0 +const T_NULL = 0 +const T_NXT = 0 +const T_OPENPGPKEY = 0 +const T_PTR = 0 +const T_PX = 0 +const T_RKEY = 0 +const T_RP = 0 +const T_RRSIG = 0 +const T_RT = 0 +const T_SIG = 0 +const T_SMIMEA = 0 +const T_SOA = 0 +const T_SPF = 0 +const T_SRV = 0 +const T_SSHFP = 0 +const T_TA = 0 +const T_TALINK = 0 +const T_TKEY = 0 +const T_TLSA = 0 +const T_TSIG = 0 +const T_TXT = 0 +const T_UID = 0 +const T_UINFO = 0 +const T_UNSPEC = 0 +const T_URI = 0 +const T_WKS = 0 +const T_X25 = 0 +const YXDOMAIN = 0 +const YXRRSET = 0 +const _PATH_RESCONF = "/etc/resolv.conf" +const __BIND = 19950621 +const __NAMESER = 19991006 +const __PRI64 = "l" +const __PRIPTR = "l" +const __RES = 19960801 +const __UAPI_DEF_IN6_ADDR = 0 +const __UAPI_DEF_IN6_ADDR_ALT = 0 +const __UAPI_DEF_IN6_PKTINFO = 0 +const __UAPI_DEF_IN_ADDR = 0 +const __UAPI_DEF_IN_CLASS = 0 +const __UAPI_DEF_IN_IPPROTO = 0 +const __UAPI_DEF_IN_PKTINFO = 0 +const __UAPI_DEF_IP6_MTUINFO = 0 +const __UAPI_DEF_IPPROTO_V6 = 0 +const __UAPI_DEF_IPV6_MREQ = 0 +const __UAPI_DEF_IPV6_OPTIONS = 0 +const __UAPI_DEF_IP_MREQ = 0 +const __UAPI_DEF_SOCKADDR_IN = 0 +const __UAPI_DEF_SOCKADDR_IN6 = 0 +const _res = 0 + +type Tns_sect = int32 + +type ___ns_sect = int32 + +const _ns_s_qd = 0 +const _ns_s_zn = 0 +const _ns_s_an = 1 +const _ns_s_pr = 1 +const _ns_s_ns = 2 +const _ns_s_ud = 2 +const _ns_s_ar = 3 +const _ns_s_max = 4 + +type Tns_msg = struct { + F_msg uintptr + F_eom uintptr + F_id Tuint16_t + F_flags Tuint16_t + F_counts [4]Tuint16_t + F_sections [4]uintptr + F_sect Tns_sect + F_rrnum int32 + F_msg_ptr uintptr +} + +type t__ns_msg = Tns_msg + +type T_ns_flagdata = struct { + Fmask int32 + Fshift int32 +} + +type Tns_rr = struct { + Fname [1025]uint8 + Ftype1 Tuint16_t + Frr_class Tuint16_t + Fttl Tuint32_t + Frdlength Tuint16_t + Frdata uintptr +} + +type t__ns_rr = Tns_rr + +type Tns_flag = int32 + +type ___ns_flag = int32 + +const _ns_f_qr = 0 +const _ns_f_opcode = 1 +const _ns_f_aa = 2 +const _ns_f_tc = 3 +const _ns_f_rd = 4 +const _ns_f_ra = 5 +const _ns_f_z = 6 +const _ns_f_ad = 7 +const _ns_f_cd = 8 +const _ns_f_rcode = 9 +const _ns_f_max = 10 + +type Tns_opcode = int32 + +type ___ns_opcode = int32 + +const _ns_o_query = 0 +const _ns_o_iquery = 1 +const _ns_o_status = 2 +const _ns_o_notify = 4 +const _ns_o_update = 5 +const _ns_o_max = 6 + +type Tns_rcode = int32 + +type ___ns_rcode = int32 + +const _ns_r_noerror = 0 +const _ns_r_formerr = 1 +const _ns_r_servfail = 2 +const _ns_r_nxdomain = 3 +const _ns_r_notimpl = 4 +const _ns_r_refused = 5 +const _ns_r_yxdomain = 6 +const _ns_r_yxrrset = 7 +const _ns_r_nxrrset = 8 +const _ns_r_notauth = 9 +const _ns_r_notzone = 10 +const _ns_r_max = 11 +const _ns_r_badvers = 16 +const _ns_r_badsig = 16 +const _ns_r_badkey = 17 +const _ns_r_badtime = 18 + +type Tns_update_operation = int32 + +type ___ns_update_operation = int32 + +const _ns_uop_delete = 0 +const _ns_uop_add = 1 +const _ns_uop_max = 2 + +type Tns_tsig_key = struct { + Fname [1025]uint8 + Falg [1025]uint8 + Fdata uintptr + Flen1 int32 +} + +type Tns_tcp_tsig_state = struct { + Fcounter int32 + Fkey uintptr + Fctx uintptr + Fsig [512]uint8 + Fsiglen int32 +} + +type Tns_type = int32 + +type ___ns_type = int32 + +const _ns_t_invalid = 0 +const _ns_t_a = 1 +const _ns_t_ns = 2 +const _ns_t_md = 3 +const _ns_t_mf = 4 +const _ns_t_cname = 5 +const _ns_t_soa = 6 +const _ns_t_mb = 7 +const _ns_t_mg = 8 +const _ns_t_mr = 9 +const _ns_t_null = 10 +const _ns_t_wks = 11 +const _ns_t_ptr = 12 +const _ns_t_hinfo = 13 +const _ns_t_minfo = 14 +const _ns_t_mx = 15 +const _ns_t_txt = 16 +const _ns_t_rp = 17 +const _ns_t_afsdb = 18 +const _ns_t_x25 = 19 +const _ns_t_isdn = 20 +const _ns_t_rt = 21 +const _ns_t_nsap = 22 +const _ns_t_nsap_ptr = 23 +const _ns_t_sig = 24 +const _ns_t_key = 25 +const _ns_t_px = 26 +const _ns_t_gpos = 27 +const _ns_t_aaaa = 28 +const _ns_t_loc = 29 +const _ns_t_nxt = 30 +const _ns_t_eid = 31 +const _ns_t_nimloc = 32 +const _ns_t_srv = 33 +const _ns_t_atma = 34 +const _ns_t_naptr = 35 +const _ns_t_kx = 36 +const _ns_t_cert = 37 +const _ns_t_a6 = 38 +const _ns_t_dname = 39 +const _ns_t_sink = 40 +const _ns_t_opt = 41 +const _ns_t_apl = 42 +const _ns_t_ds = 43 +const _ns_t_sshfp = 44 +const _ns_t_ipseckey = 45 +const _ns_t_rrsig = 46 +const _ns_t_nsec = 47 +const _ns_t_dnskey = 48 +const _ns_t_dhcid = 49 +const _ns_t_nsec3 = 50 +const _ns_t_nsec3param = 51 +const _ns_t_tlsa = 52 +const _ns_t_smimea = 53 +const _ns_t_hip = 55 +const _ns_t_ninfo = 56 +const _ns_t_rkey = 57 +const _ns_t_talink = 58 +const _ns_t_cds = 59 +const _ns_t_cdnskey = 60 +const _ns_t_openpgpkey = 61 +const _ns_t_csync = 62 +const _ns_t_spf = 99 +const _ns_t_uinfo = 100 +const _ns_t_uid = 101 +const _ns_t_gid = 102 +const _ns_t_unspec = 103 +const _ns_t_nid = 104 +const _ns_t_l32 = 105 +const _ns_t_l64 = 106 +const _ns_t_lp = 107 +const _ns_t_eui48 = 108 +const _ns_t_eui64 = 109 +const _ns_t_tkey = 249 +const _ns_t_tsig = 250 +const _ns_t_ixfr = 251 +const _ns_t_axfr = 252 +const _ns_t_mailb = 253 +const _ns_t_maila = 254 +const _ns_t_any = 255 +const _ns_t_zxfr = 256 +const _ns_t_uri = 256 +const _ns_t_caa = 257 +const _ns_t_avc = 258 +const _ns_t_ta = 32768 +const _ns_t_dlv = 32769 +const _ns_t_max = 65536 + +type Tns_class = int32 + +type ___ns_class = int32 + +const _ns_c_invalid = 0 +const _ns_c_in = 1 +const _ns_c_2 = 2 +const _ns_c_chaos = 3 +const _ns_c_hs = 4 +const _ns_c_none = 254 +const _ns_c_any = 255 +const _ns_c_max = 65536 + +type Tns_key_types = int32 + +type ___ns_key_types = int32 + +const _ns_kt_rsa = 1 +const _ns_kt_dh = 2 +const _ns_kt_dsa = 3 +const _ns_kt_private = 254 + +type Tns_cert_types = int32 + +type ___ns_cert_types = int32 + +const _cert_t_pkix = 1 +const _cert_t_spki = 2 +const _cert_t_pgp = 3 +const _cert_t_url = 253 +const _cert_t_oid = 254 + +type THEADER = struct { + F__ccgo0 uint32 + F__ccgo4 uint32 + F__ccgo8 uint32 +} + +type Timaxdiv_t = struct { + Fquot Tintmax_t + Frem Tintmax_t +} + +type Tin_port_t = uint16 + +type Tin_addr_t = uint32 + +type Tin_addr = struct { + Fs_addr Tin_addr_t +} + +type Tsockaddr_in = struct { + Fsin_family Tsa_family_t + Fsin_port Tin_port_t + Fsin_addr Tin_addr + Fsin_zero [8]Tuint8_t +} + +type Tin6_addr = struct { + F__in6_union struct { + F__s6_addr16 [0][8]Tuint16_t + F__s6_addr32 [0][4]Tuint32_t + F__s6_addr [16]Tuint8_t + } +} + +type Tsockaddr_in6 = struct { + Fsin6_family Tsa_family_t + Fsin6_port Tin_port_t + Fsin6_flowinfo Tuint32_t + Fsin6_addr Tin6_addr + Fsin6_scope_id Tuint32_t +} + +type Tipv6_mreq = struct { + Fipv6mr_multiaddr Tin6_addr + Fipv6mr_interface uint32 +} + +type Tip_opts = struct { + Fip_dst Tin_addr + Fip_opts [40]uint8 +} + +type Tres_state = uintptr + +type t__res_state = struct { + Fretrans int32 + Fretry int32 + Foptions uint64 + Fnscount int32 + Fnsaddr_list [3]Tsockaddr_in + Fid uint16 + Fdnsrch [7]uintptr + Fdefdname [256]uint8 + Fpfcode uint64 + F__ccgo392 uint32 + Fsort_list [10]struct { + Faddr Tin_addr + Fmask Tuint32_t + } + Fqhook uintptr + Frhook uintptr + Fres_h_errno int32 + F_vcsock int32 + F_flags uint32 + F_u struct { + F_ext [0]struct { + Fnscount Tuint16_t + Fnsmap [3]Tuint16_t + Fnssocks [3]int32 + Fnscount6 Tuint16_t + Fnsinit Tuint16_t + Fnsaddrs [3]uintptr + F_initstamp [2]uint32 + } + Fpad [52]uint8 + F__ccgo_pad2 [4]byte + } +} + +type Tres_sym = struct { + Fnumber int32 + Fname uintptr + Fhumanname uintptr +} + +/* RFC 1035 message compression */ + +// C documentation +// +// /* label start offsets of a compressed domain name s */ +func _getoffs(tls *TLS, offs uintptr, base uintptr, s uintptr) (r int32) { + var i, v2 int32 + _, _ = i, v2 + i = 0 + for { + for Int32FromUint8(**(**uint8)(__ccgo_up(s)))&int32(0xc0) != 0 { + if Int32FromUint8(**(**uint8)(__ccgo_up(s)))&int32(0xc0) != int32(0xc0) { + return 0 + } + s = base + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(s)))&Int32FromInt32(0x3f)<= int64(0x4000) { + return 0 + } + v2 = i + i = i + 1 + **(**int16)(__ccgo_up(offs + uintptr(v2)*2)) = int16(int64(s) - int64(base)) + s = s + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(s)))+int32(1)) + goto _1 + _1: + } + return r +} + +// C documentation +// +// /* label lengths of an ascii domain name s */ +func _getlens(tls *TLS, lens uintptr, s uintptr, l int32) (r int32) { + var i, j, k, v3 int32 + _, _, _, _ = i, j, k, v3 + i = 0 + j = 0 + k = 0 + for { + for { + if !(j < l && Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(j)))) != int32('.')) { + break + } + goto _2 + _2: + ; + j = j + 1 + } + if Uint32FromInt32(j-k)-uint32(1) > uint32(62) { + return 0 + } + v3 = i + i = i + 1 + **(**uint8)(__ccgo_up(lens + uintptr(v3))) = Uint8FromInt32(j - k) + if j == l { + return i + } + j = j + 1 + v3 = j + k = v3 + goto _1 + _1: + } + return r +} + +// C documentation +// +// /* longest suffix match of an ascii domain with a compressed domain name dn */ +func _match(tls *TLS, offset uintptr, base uintptr, dn uintptr, end uintptr, lens uintptr, nlen int32) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var l, m, noff, o, v2 int32 + var _ /* offs at bp+0 */ [128]int16 + _, _, _, _, _ = l, m, noff, o, v2 + m = 0 + noff = _getoffs(tls, bp, base, dn) + if !(noff != 0) { + return 0 + } + for { + nlen = nlen - 1 + v2 = nlen + l = Int32FromUint8(**(**uint8)(__ccgo_up(lens + uintptr(v2)))) + noff = noff - 1 + v2 = noff + o = int32((**(**[128]int16)(__ccgo_up(bp)))[v2]) + end = end - uintptr(l) + if l != Int32FromUint8(**(**uint8)(__ccgo_up(base + uintptr(o)))) || Xmemcmp(tls, base+uintptr(o)+uintptr(1), end, Uint64FromInt32(l)) != 0 { + return m + } + **(**int32)(__ccgo_up(offset)) = o + m = m + l + if nlen != 0 { + m = m + 1 + } + if !(nlen != 0) || !(noff != 0) { + return m + } + end = end - 1 + goto _1 + _1: + } + return r +} + +func Xdn_comp(tls *TLS, src uintptr, dst uintptr, space int32, dnptrs uintptr, lastdnptr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v src=%v dst=%v space=%v dnptrs=%v lastdnptr=%v, (%v:)", tls, src, dst, space, dnptrs, lastdnptr, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var bestlen, bestoff, i, j, m, n, v3 int32 + var end, p, v8 uintptr + var l Tsize_t + var _ /* lens at bp+4 */ [127]uint8 + var _ /* offset at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _ = bestlen, bestoff, end, i, j, l, m, n, p, v3, v8 + m = 0 + bestlen = 0 + l = Xstrnlen(tls, src, uint64(255)) + if l != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(src + uintptr(l-uint64(1))))) == int32('.') { + l = l - 1 + } + if l > uint64(253) || space <= 0 { + return -int32(1) + } + if !(l != 0) { + **(**uint8)(__ccgo_up(dst)) = uint8(0) + return int32(1) + } + end = src + uintptr(l) + n = _getlens(tls, bp+4, src, Int32FromUint64(l)) + if !(n != 0) { + return -int32(1) + } + p = dnptrs + if p != 0 && **(**uintptr)(__ccgo_up(p)) != 0 { + p += 8 + for { + if !(**(**uintptr)(__ccgo_up(p)) != 0) { + break + } + m = _match(tls, bp, **(**uintptr)(__ccgo_up(dnptrs)), **(**uintptr)(__ccgo_up(p)), end, bp+4, n) + if m > bestlen { + bestlen = m + bestoff = **(**int32)(__ccgo_up(bp)) + if Uint64FromInt32(m) == l { + break + } + } + goto _1 + _1: + ; + p += 8 + } + } + /* encode unmatched part */ + if Uint64FromInt32(space) < l-Uint64FromInt32(bestlen)+uint64(2)+BoolUint64(Uint64FromInt32(bestlen-Int32FromInt32(1)) < l-Uint64FromInt32(1)) { + return -int32(1) + } + Xmemcpy(tls, dst+uintptr(1), src, l-Uint64FromInt32(bestlen)) + v3 = Int32FromInt32(0) + j = v3 + i = v3 + for { + if !(Uint64FromInt32(i) < l-Uint64FromInt32(bestlen)) { + break + } + **(**uint8)(__ccgo_up(dst + uintptr(i))) = (**(**[127]uint8)(__ccgo_up(bp + 4)))[j] + goto _2 + _2: + ; + v3 = j + j = j + 1 + i = i + (Int32FromUint8((**(**[127]uint8)(__ccgo_up(bp + 4)))[v3]) + int32(1)) + } + /* add tail */ + if bestlen != 0 { + v3 = i + i = i + 1 + **(**uint8)(__ccgo_up(dst + uintptr(v3))) = Uint8FromInt32(int32(0xc0) | bestoff>>int32(8)) + v3 = i + i = i + 1 + **(**uint8)(__ccgo_up(dst + uintptr(v3))) = Uint8FromInt32(bestoff) + } else { + v3 = i + i = i + 1 + **(**uint8)(__ccgo_up(dst + uintptr(v3))) = uint8(0) + } + /* save dst pointer */ + if i > int32(2) && lastdnptr != 0 && dnptrs != 0 && **(**uintptr)(__ccgo_up(dnptrs)) != 0 { + for **(**uintptr)(__ccgo_up(p)) != 0 { + p += 8 + } + if p+uintptr(1)*8 < lastdnptr { + v8 = p + p += 8 + **(**uintptr)(__ccgo_up(v8)) = dst + **(**uintptr)(__ccgo_up(p)) = uintptr(0) + } + } + return i +} + +func X__dn_expand(tls *TLS, base uintptr, end uintptr, src uintptr, dest uintptr, space int32) (r int32) { + if __ccgo_strace { + trc("tls=%v base=%v end=%v src=%v dest=%v space=%v, (%v:)", tls, base, end, src, dest, space, origin(2)) + defer func() { trc("-> %v", r) }() + } + var dbegin, dend, p, v3, v4 uintptr + var i, j, len1, v1 int32 + _, _, _, _, _, _, _, _, _ = dbegin, dend, i, j, len1, p, v1, v3, v4 + p = src + dbegin = dest + len1 = -int32(1) + if p == end || space <= 0 { + return -int32(1) + } + if space > int32(254) { + v1 = int32(254) + } else { + v1 = space + } + dend = dest + uintptr(v1) + /* detect reference loop using an iteration counter */ + i = 0 + for { + if !(int64(i) < int64(end)-int64(base)) { + break + } + /* loop invariants: p= int64(end)-int64(base) { + return -int32(1) + } + p = base + uintptr(j) + } else { + if **(**uint8)(__ccgo_up(p)) != 0 { + if dest != dbegin { + v3 = dest + dest = dest + 1 + **(**uint8)(__ccgo_up(v3)) = uint8('.') + } + v3 = p + p = p + 1 + j = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + if int64(j) >= int64(end)-int64(p) || int64(j) >= int64(dend)-int64(dest) { + return -int32(1) + } + for { + v1 = j + j = j - 1 + if !(v1 != 0) { + break + } + v3 = dest + dest = dest + 1 + v4 = p + p = p + 1 + **(**uint8)(__ccgo_up(v3)) = uint8(**(**uint8)(__ccgo_up(v4))) + } + } else { + **(**uint8)(__ccgo_up(dest)) = uint8(0) + if len1 < 0 { + len1 = int32(int64(p+uintptr(1)) - int64(src)) + } + return len1 + } + } + goto _2 + _2: + ; + i = i + int32(2) + } + return -int32(1) +} + +func Xdn_expand(tls *TLS, base uintptr, end uintptr, src uintptr, dest uintptr, space int32) (r int32) { + if __ccgo_strace { + trc("tls=%v base=%v end=%v src=%v dest=%v space=%v, (%v:)", tls, base, end, src, dest, space, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__dn_expand(tls, base, end, src, dest, space) +} + +func Xdn_skipname(tls *TLS, s uintptr, end uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v end=%v, (%v:)", tls, s, end, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + _ = p + p = s + for p < end { + if !(**(**uint8)(__ccgo_up(p)) != 0) { + return int32(int64(p) - int64(s) + int64(1)) + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) >= int32(192) { + if p+uintptr(1) < end { + return int32(int64(p) - int64(s) + int64(2)) + } else { + break + } + } else { + if int64(end)-int64(p) < int64(Int32FromUint8(**(**uint8)(__ccgo_up(p)))+int32(1)) { + break + } else { + p = p + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(p)))+int32(1)) + } + } + } + } + return -int32(1) +} + +const AI_ADDRCONFIG = 32 +const AI_ALL = 16 +const AI_CANONNAME = 2 +const AI_NUMERICHOST = 4 +const AI_NUMERICSERV = 1024 +const AI_PASSIVE = 1 +const AI_V4MAPPED = 8 +const EAI_AGAIN = -3 +const EAI_BADFLAGS = -1 +const EAI_FAIL = -4 +const EAI_FAMILY = -6 +const EAI_MEMORY = -10 +const EAI_NODATA = -5 +const EAI_NONAME = -2 +const EAI_OVERFLOW = -12 +const EAI_SERVICE = -8 +const EAI_SOCKTYPE = -7 +const EAI_SYSTEM = -11 +const MAXADDRS = 48 +const MAXSERVS = 2 +const NI_DGRAM = 16 +const NI_NAMEREQD = 8 +const NI_NOFQDN = 4 +const NI_NUMERICHOST = 1 +const NI_NUMERICSCOPE = 256 +const NI_NUMERICSERV = 2 + +type Taddrinfo = struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen Tsocklen_t + Fai_addr uintptr + Fai_canonname uintptr + Fai_next uintptr +} + +type Tnetent = struct { + Fn_name uintptr + Fn_aliases uintptr + Fn_addrtype int32 + Fn_net Tuint32_t +} + +type Thostent = struct { + Fh_name uintptr + Fh_aliases uintptr + Fh_addrtype int32 + Fh_length int32 + Fh_addr_list uintptr +} + +type Tservent = struct { + Fs_name uintptr + Fs_aliases uintptr + Fs_port int32 + Fs_proto uintptr +} + +type Tprotoent = struct { + Fp_name uintptr + Fp_aliases uintptr + Fp_proto int32 +} + +type Taibuf = struct { + Fai Taddrinfo + Fsa Tsa + Flock [1]int32 + Fslot int16 + Fref int16 +} + +type Taddress = struct { + Ffamily int32 + Fscopeid uint32 + Faddr [16]Tuint8_t + Fsortkey int32 +} + +type Tservice = struct { + Fport Tuint16_t + Fproto uint8 + Fsocktype uint8 +} + +type Tresolvconf = struct { + Fns [3]Taddress + Fnns uint32 + Fattempts uint32 + Fndots uint32 + Ftimeout uint32 +} + +type t__ccgo_fp__X__dns_parse_2 = func(*TLS, uintptr, int32, uintptr, int32, uintptr, int32) int32 + +func X__dns_parse(tls *TLS, r uintptr, rlen int32, __ccgo_fp_callback uintptr, ctx uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v r=%v rlen=%v __ccgo_fp_callback=%v ctx=%v, (%v:)", tls, r, rlen, __ccgo_fp_callback, ctx, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var ancount, len1, qdcount, v1 int32 + var p uintptr + _, _, _, _, _ = ancount, len1, p, qdcount, v1 + if rlen < int32(12) { + return -int32(1) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(r + 3)))&int32(15) != 0 { + return 0 + } + p = r + uintptr(12) + qdcount = Int32FromUint8(**(**uint8)(__ccgo_up(r + 4)))*int32(256) + Int32FromUint8(**(**uint8)(__ccgo_up(r + 5))) + ancount = Int32FromUint8(**(**uint8)(__ccgo_up(r + 6)))*int32(256) + Int32FromUint8(**(**uint8)(__ccgo_up(r + 7))) + for { + v1 = qdcount + qdcount = qdcount - 1 + if !(v1 != 0) { + break + } + for int64(p)-int64(r) < int64(rlen) && uint32(**(**uint8)(__ccgo_up(p)))-uint32(1) < uint32(127) { + p = p + 1 + } + if p > r+uintptr(rlen)-uintptr(6) { + return -int32(1) + } + p = p + uintptr(int32(5)+BoolInt32(!!(**(**uint8)(__ccgo_up(p)) != 0))) + } + for { + v1 = ancount + ancount = ancount - 1 + if !(v1 != 0) { + break + } + for int64(p)-int64(r) < int64(rlen) && uint32(**(**uint8)(__ccgo_up(p)))-uint32(1) < uint32(127) { + p = p + 1 + } + if p > r+uintptr(rlen)-uintptr(12) { + return -int32(1) + } + p = p + uintptr(int32(1)+BoolInt32(!!(**(**uint8)(__ccgo_up(p)) != 0))) + len1 = Int32FromUint8(**(**uint8)(__ccgo_up(p + 8)))*int32(256) + Int32FromUint8(**(**uint8)(__ccgo_up(p + 9))) + if int64(len1+int32(10)) > int64(r+uintptr(rlen))-int64(p) { + return -int32(1) + } + if (*(*func(*TLS, uintptr, int32, uintptr, int32, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_callback})))(tls, ctx, Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))), p+uintptr(10), len1, r, rlen) < 0 { + return -int32(1) + } + p = p + uintptr(int32(10)+len1) + } + return 0 +} + +type Tsa = struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte +} + +func Xsethostent(tls *TLS, x int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } +} + +func Xgethostent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xgetnetent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xendhostent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xendnetent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xendhostent(tls) +} + +func Xsetnetent(tls *TLS, x int32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + Xsethostent(tls, x) +} + +const ARPD_FLUSH = 3 +const ARPD_LOOKUP = 2 +const ARPD_UPDATE = 1 +const ARPHRD_6LOWPAN = 825 +const ARPHRD_ADAPT = 264 +const ARPHRD_APPLETLK = 8 +const ARPHRD_ARCNET = 7 +const ARPHRD_ASH = 781 +const ARPHRD_ATM = 19 +const ARPHRD_AX25 = 3 +const ARPHRD_BIF = 775 +const ARPHRD_CAIF = 822 +const ARPHRD_CAN = 280 +const ARPHRD_CHAOS = 5 +const ARPHRD_CISCO = 513 +const ARPHRD_CSLIP = 257 +const ARPHRD_CSLIP6 = 259 +const ARPHRD_DDCMP = 517 +const ARPHRD_DLCI = 15 +const ARPHRD_ECONET = 782 +const ARPHRD_EETHER = 2 +const ARPHRD_ETHER = 1 +const ARPHRD_EUI64 = 27 +const ARPHRD_FCAL = 785 +const ARPHRD_FCFABRIC = 787 +const ARPHRD_FCPL = 786 +const ARPHRD_FCPP = 784 +const ARPHRD_FDDI = 774 +const ARPHRD_FRAD = 770 +const ARPHRD_HDLC = 513 +const ARPHRD_HIPPI = 780 +const ARPHRD_HWX25 = 272 +const ARPHRD_IEEE1394 = 24 +const ARPHRD_IEEE802 = 6 +const ARPHRD_IEEE80211 = 801 +const ARPHRD_IEEE80211_PRISM = 802 +const ARPHRD_IEEE80211_RADIOTAP = 803 +const ARPHRD_IEEE802154 = 804 +const ARPHRD_IEEE802154_MONITOR = 805 +const ARPHRD_IEEE802_TR = 800 +const ARPHRD_INFINIBAND = 32 +const ARPHRD_IP6GRE = 823 +const ARPHRD_IPDDP = 777 +const ARPHRD_IPGRE = 778 +const ARPHRD_IRDA = 783 +const ARPHRD_LAPB = 516 +const ARPHRD_LOCALTLK = 773 +const ARPHRD_LOOPBACK = 772 +const ARPHRD_METRICOM = 23 +const ARPHRD_NETLINK = 824 +const ARPHRD_NETROM = 0 +const ARPHRD_NONE = 65534 +const ARPHRD_PHONET = 820 +const ARPHRD_PHONET_PIPE = 821 +const ARPHRD_PIMREG = 779 +const ARPHRD_PPP = 512 +const ARPHRD_PRONET = 4 +const ARPHRD_RAWHDLC = 518 +const ARPHRD_RAWIP = 519 +const ARPHRD_ROSE = 270 +const ARPHRD_RSRVD = 260 +const ARPHRD_SIT = 776 +const ARPHRD_SKIP = 771 +const ARPHRD_SLIP = 256 +const ARPHRD_SLIP6 = 258 +const ARPHRD_TUNNEL = 768 +const ARPHRD_TUNNEL6 = 769 +const ARPHRD_VOID = 65535 +const ARPHRD_VSOCKMON = 826 +const ARPHRD_X25 = 271 +const ARPOP_InREPLY = 9 +const ARPOP_InREQUEST = 8 +const ARPOP_NAK = 10 +const ARPOP_REPLY = 2 +const ARPOP_REQUEST = 1 +const ARPOP_RREPLY = 4 +const ARPOP_RREQUEST = 3 +const ATF_COM = 2 +const ATF_DONTPUB = 64 +const ATF_MAGIC = 128 +const ATF_NETMASK = 32 +const ATF_PERM = 4 +const ATF_PUBL = 8 +const ATF_USETRAILERS = 16 +const ETHERMIN = 46 +const ETHERMTU = 1500 +const ETHERTYPE_AARP = 33011 +const ETHERTYPE_ARP = 2054 +const ETHERTYPE_AT = 32923 +const ETHERTYPE_IP = 2048 +const ETHERTYPE_IPV6 = 34525 +const ETHERTYPE_IPX = 33079 +const ETHERTYPE_LOOPBACK = 36864 +const ETHERTYPE_NTRAILER = 16 +const ETHERTYPE_PUP = 512 +const ETHERTYPE_REVARP = 32821 +const ETHERTYPE_SPRITE = 1280 +const ETHERTYPE_TRAIL = 4096 +const ETHERTYPE_VLAN = 33024 +const ETHER_ADDR_LEN = 6 +const ETHER_CRC_LEN = 4 +const ETHER_HDR_LEN = 14 +const ETHER_MAX_LEN = 1518 +const ETHER_MIN_LEN = 64 +const ETHER_TYPE_LEN = 2 +const ETH_ALEN = 6 +const ETH_DATA_LEN = 1500 +const ETH_FCS_LEN = 4 +const ETH_FRAME_LEN = 1514 +const ETH_HLEN = 14 +const ETH_MAX_MTU = 65535 +const ETH_MIN_MTU = 68 +const ETH_P_1588 = 35063 +const ETH_P_8021AD = 34984 +const ETH_P_8021AH = 35047 +const ETH_P_8021Q = 33024 +const ETH_P_80221 = 35095 +const ETH_P_802_2 = 4 +const ETH_P_802_3 = 1 +const ETH_P_802_3_MIN = 1536 +const ETH_P_802_EX1 = 34997 +const ETH_P_AARP = 33011 +const ETH_P_AF_IUCV = 64507 +const ETH_P_ALL = 3 +const ETH_P_AOE = 34978 +const ETH_P_ARCNET = 26 +const ETH_P_ARP = 2054 +const ETH_P_ATALK = 32923 +const ETH_P_ATMFATE = 34948 +const ETH_P_ATMMPOA = 34892 +const ETH_P_AX25 = 2 +const ETH_P_BATMAN = 17157 +const ETH_P_BPQ = 2303 +const ETH_P_CAIF = 247 +const ETH_P_CAN = 12 +const ETH_P_CANFD = 13 +const ETH_P_CFM = 35074 +const ETH_P_CONTROL = 22 +const ETH_P_CUST = 24582 +const ETH_P_DDCMP = 6 +const ETH_P_DEC = 24576 +const ETH_P_DIAG = 24581 +const ETH_P_DNA_DL = 24577 +const ETH_P_DNA_RC = 24578 +const ETH_P_DNA_RT = 24579 +const ETH_P_DSA = 27 +const ETH_P_DSA_8021Q = 56027 +const ETH_P_ECONET = 24 +const ETH_P_EDSA = 56026 +const ETH_P_ERSPAN = 35006 +const ETH_P_ERSPAN2 = 8939 +const ETH_P_FCOE = 35078 +const ETH_P_FIP = 35092 +const ETH_P_HDLC = 25 +const ETH_P_HSR = 35119 +const ETH_P_IBOE = 35093 +const ETH_P_IEEE802154 = 246 +const ETH_P_IEEEPUP = 2560 +const ETH_P_IEEEPUPAT = 2561 +const ETH_P_IFE = 60734 +const ETH_P_IP = 2048 +const ETH_P_IPV6 = 34525 +const ETH_P_IPX = 33079 +const ETH_P_IRDA = 23 +const ETH_P_LAT = 24580 +const ETH_P_LINK_CTL = 34924 +const ETH_P_LLDP = 35020 +const ETH_P_LOCALTALK = 9 +const ETH_P_LOOP = 96 +const ETH_P_LOOPBACK = 36864 +const ETH_P_MACSEC = 35045 +const ETH_P_MAP = 249 +const ETH_P_MOBITEX = 21 +const ETH_P_MPLS_MC = 34888 +const ETH_P_MPLS_UC = 34887 +const ETH_P_MRP = 35043 +const ETH_P_MVRP = 35061 +const ETH_P_NCSI = 35064 +const ETH_P_NSH = 35151 +const ETH_P_PAE = 34958 +const ETH_P_PAUSE = 34824 +const ETH_P_PHONET = 245 +const ETH_P_PPPTALK = 16 +const ETH_P_PPP_DISC = 34915 +const ETH_P_PPP_MP = 8 +const ETH_P_PPP_SES = 34916 +const ETH_P_PREAUTH = 35015 +const ETH_P_PRP = 35067 +const ETH_P_PUP = 512 +const ETH_P_PUPAT = 513 +const ETH_P_QINQ1 = 37120 +const ETH_P_QINQ2 = 37376 +const ETH_P_QINQ3 = 37632 +const ETH_P_RARP = 32821 +const ETH_P_SCA = 24583 +const ETH_P_SLOW = 34825 +const ETH_P_SNAP = 5 +const ETH_P_TDLS = 35085 +const ETH_P_TEB = 25944 +const ETH_P_TIPC = 35018 +const ETH_P_TRAILER = 28 +const ETH_P_TR_802_2 = 17 +const ETH_P_TSN = 8944 +const ETH_P_WAN_PPP = 7 +const ETH_P_WCCP = 34878 +const ETH_P_X25 = 2053 +const ETH_P_XDSA = 248 +const ETH_TLEN = 2 +const ETH_ZLEN = 60 +const MAX_ADDR_LEN = 7 +const __UAPI_DEF_ETHHDR = 0 + +type Tethhdr = struct { + Fh_dest [6]Tuint8_t + Fh_source [6]Tuint8_t + Fh_proto Tuint16_t +} + +type Tether_addr = struct { + Fether_addr_octet [6]Tuint8_t +} + +type Tether_header = struct { + Fether_dhost [6]Tuint8_t + Fether_shost [6]Tuint8_t + Fether_type Tuint16_t +} + +type Tarphdr = struct { + Far_hrd Tuint16_t + Far_pro Tuint16_t + Far_hln Tuint8_t + Far_pln Tuint8_t + Far_op Tuint16_t +} + +type Tarpreq = struct { + Farp_pa Tsockaddr + Farp_ha Tsockaddr + Farp_flags int32 + Farp_netmask Tsockaddr + Farp_dev [16]uint8 +} + +type Tarpreq_old = struct { + Farp_pa Tsockaddr + Farp_ha Tsockaddr + Farp_flags int32 + Farp_netmask Tsockaddr +} + +type Tarpd_request = struct { + Freq uint16 + Fip Tuint32_t + Fdev uint64 + Fstamp uint64 + Fupdated uint64 + Fha [7]uint8 +} + +type Tether_arp = struct { + Fea_hdr Tarphdr + Farp_sha [6]Tuint8_t + Farp_spa [4]Tuint8_t + Farp_tha [6]Tuint8_t + Farp_tpa [4]Tuint8_t +} + +func Xether_aton_r(tls *TLS, x uintptr, p_a uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v p_a=%v, (%v:)", tls, x, p_a, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ii int32 + var n uint64 + var _ /* a at bp+0 */ Tether_addr + var _ /* y at bp+8 */ uintptr + _, _ = ii, n + ii = 0 + for { + if !(ii < int32(6)) { + break + } + if ii != 0 { + if Int32FromUint8(**(**uint8)(__ccgo_up(x))) != int32(':') { + return uintptr(0) + } else { + x = x + 1 + } + } + n = Xstrtoul(tls, x, bp+8, int32(16)) + x = **(**uintptr)(__ccgo_up(bp + 8)) + if n > uint64(0xFF) { + return uintptr(0) + } /* bad byte */ + **(**Tuint8_t)(__ccgo_up(bp + uintptr(ii))) = uint8(n) + goto _1 + _1: + ; + ii = ii + 1 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(x))) != 0 { + return uintptr(0) + } /* bad format */ + **(**Tether_addr)(__ccgo_up(p_a)) = **(**Tether_addr)(__ccgo_up(bp)) + return p_a +} + +func Xether_aton(tls *TLS, x uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xether_aton_r(tls, x, uintptr(unsafe.Pointer(&_a))) +} + +var _a Tether_addr + +func Xether_ntoa_r(tls *TLS, p_a uintptr, x uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v p_a=%v x=%v, (%v:)", tls, p_a, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ii int32 + var y, v2 uintptr + _, _, _ = ii, y, v2 + y = x + ii = 0 + for { + if !(ii < int32(6)) { + break + } + if ii == 0 { + v2 = __ccgo_ts + 971 + } else { + v2 = __ccgo_ts + 976 + } + x = x + uintptr(Xsprintf(tls, x, v2, VaList(bp+8, Int32FromUint8(**(**Tuint8_t)(__ccgo_up(p_a + uintptr(ii))))))) + goto _1 + _1: + ; + ii = ii + 1 + } + return y +} + +func Xether_ntoa(tls *TLS, p_a uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v p_a=%v, (%v:)", tls, p_a, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xether_ntoa_r(tls, p_a, uintptr(unsafe.Pointer(&_x))) +} + +var _x [18]uint8 + +func Xether_line(tls *TLS, l uintptr, e uintptr, hostname uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v l=%v e=%v hostname=%v, (%v:)", tls, l, e, hostname, origin(2)) + defer func() { trc("-> %v", r) }() + } + return -int32(1) +} + +func Xether_ntohost(tls *TLS, hostname uintptr, e uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v hostname=%v e=%v, (%v:)", tls, hostname, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + return -int32(1) +} + +func Xether_hostton(tls *TLS, hostname uintptr, e uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v hostname=%v e=%v, (%v:)", tls, hostname, e, origin(2)) + defer func() { trc("-> %v", r) }() + } + return -int32(1) +} + +func Xfreeaddrinfo(tls *TLS, p uintptr) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + } + var b, v2 uintptr + var cnt Tsize_t + _, _, _ = b, cnt, v2 + cnt = uint64(1) + for { + if !((*Taddrinfo)(unsafe.Pointer(p)).Fai_next != 0) { + break + } + goto _1 + _1: + ; + cnt = cnt + 1 + p = (*Taddrinfo)(unsafe.Pointer(p)).Fai_next + } + b = p - uintptr(uint64(UintptrFromInt32(0))) + b = b - uintptr((*Taibuf)(unsafe.Pointer(b)).Fslot)*88 + ___lock(tls, b+76) + v2 = b + 82 + *(*int16)(unsafe.Pointer(v2)) = int16(uint64(*(*int16)(unsafe.Pointer(v2))) - cnt) + if !(*(*int16)(unsafe.Pointer(v2)) != 0) { + Xfree(tls, b) + } else { + ___unlock(tls, b+76) + } +} + +var _msgs = [252]uint8{'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'f', 'l', 'a', 'g', 's', 0, 'N', 'a', 'm', 'e', ' ', 'd', 'o', 'e', 's', ' ', 'n', 'o', 't', ' ', 'r', 'e', 's', 'o', 'l', 'v', 'e', 0, 'T', 'r', 'y', ' ', 'a', 'g', 'a', 'i', 'n', 0, 'N', 'o', 'n', '-', 'r', 'e', 'c', 'o', 'v', 'e', 'r', 'a', 'b', 'l', 'e', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'N', 'a', 'm', 'e', ' ', 'h', 'a', 's', ' ', 'n', 'o', ' ', 'u', 's', 'a', 'b', 'l', 'e', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's', 0, 'U', 'n', 'r', 'e', 'c', 'o', 'g', 'n', 'i', 'z', 'e', 'd', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's', ' ', 'f', 'a', 'm', 'i', 'l', 'y', ' ', 'o', 'r', ' ', 'i', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'l', 'e', 'n', 'g', 't', 'h', 0, 'U', 'n', 'r', 'e', 'c', 'o', 'g', 'n', 'i', 'z', 'e', 'd', ' ', 's', 'o', 'c', 'k', 'e', 't', ' ', 't', 'y', 'p', 'e', 0, 'U', 'n', 'r', 'e', 'c', 'o', 'g', 'n', 'i', 'z', 'e', 'd', ' ', 's', 'e', 'r', 'v', 'i', 'c', 'e', 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'O', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0, 'S', 'y', 's', 't', 'e', 'm', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'O', 'v', 'e', 'r', 'f', 'l', 'o', 'w', 0, 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r'} + +func Xgai_strerror(tls *TLS, ecode int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ecode=%v, (%v:)", tls, ecode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + _ = s + s = uintptr(unsafe.Pointer(&_msgs)) + ecode = ecode + 1 + for { + if !(ecode != 0 && **(**uint8)(__ccgo_up(s)) != 0) { + break + } + for { + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + goto _2 + _2: + ; + s = s + 1 + } + goto _1 + _1: + ; + ecode = ecode + 1 + s = s + 1 + } + if !(**(**uint8)(__ccgo_up(s)) != 0) { + s = s + 1 + } + return X__lctrans_cur(tls, s) +} + +func Xgetaddrinfo(tls *TLS, host uintptr, serv uintptr, hint uintptr, res uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v host=%v serv=%v hint=%v res=%v, (%v:)", tls, host, serv, hint, res, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(1616) + defer tls.Free(1616) + var canon_len, family, flags, i, j, k, mask, naddrs, nais, no_family, nservs, proto, r, s, saved_errno, socktype, v3 int32 + var out, outcanon uintptr + var ta [2]uintptr + var tf [2]int32 + var tl [2]Tsocklen_t + var v5 uint64 + var _ /* addrs at bp+8 */ [48]Taddress + var _ /* canon at bp+1352 */ [256]uint8 + var _ /* cs at bp+1608 */ int32 + var _ /* ports at bp+0 */ [2]Tservice + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = canon_len, family, flags, i, j, k, mask, naddrs, nais, no_family, nservs, out, outcanon, proto, r, s, saved_errno, socktype, ta, tf, tl, v3, v5 + family = PF_UNSPEC + flags = 0 + proto = 0 + socktype = 0 + no_family = 0 + if !(host != 0) && !(serv != 0) { + return -int32(2) + } + if hint != 0 { + family = (*Taddrinfo)(unsafe.Pointer(hint)).Fai_family + flags = (*Taddrinfo)(unsafe.Pointer(hint)).Fai_flags + proto = (*Taddrinfo)(unsafe.Pointer(hint)).Fai_protocol + socktype = (*Taddrinfo)(unsafe.Pointer(hint)).Fai_socktype + mask = Int32FromInt32(AI_PASSIVE) | Int32FromInt32(AI_CANONNAME) | Int32FromInt32(AI_NUMERICHOST) | Int32FromInt32(AI_V4MAPPED) | Int32FromInt32(AI_ALL) | Int32FromInt32(AI_ADDRCONFIG) | Int32FromInt32(AI_NUMERICSERV) + if flags&mask != flags { + return -int32(1) + } + switch family { + case int32(PF_INET): + fallthrough + case int32(PF_INET6): + fallthrough + case PF_UNSPEC: + default: + return -int32(6) + } + } + if flags&int32(AI_ADDRCONFIG) != 0 { + tf = [2]int32{ + 0: int32(PF_INET), + 1: int32(PF_INET6), + } + ta = [2]uintptr{ + 0: uintptr(unsafe.Pointer(&_lo4)), + 1: uintptr(unsafe.Pointer(&_lo6)), + } + tl = [2]Tsocklen_t{ + 0: uint32(16), + 1: uint32(28), + } + i = 0 + for { + if !(i < int32(2)) { + break + } + if family == tf[int32(1)-i] { + goto _1 + } + s = Xsocket(tls, tf[i], Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_DGRAM), int32(IPPROTO_UDP)) + if s >= 0 { + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+1608) + r = Xconnect(tls, s, ta[i], tl[i]) + saved_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 1608)), uintptr(0)) + Xclose(tls, s) + if !(r != 0) { + goto _1 + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = saved_errno + } + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(EADDRNOTAVAIL): + fallthrough + case int32(EAFNOSUPPORT): + fallthrough + case int32(EHOSTUNREACH): + fallthrough + case int32(ENETDOWN): + fallthrough + case int32(ENETUNREACH): + default: + return -int32(11) + } + if family == tf[i] { + no_family = int32(1) + } + family = tf[int32(1)-i] + goto _1 + _1: + ; + i = i + 1 + } + } + nservs = X__lookup_serv(tls, bp, serv, proto, socktype, flags) + if nservs < 0 { + return nservs + } + naddrs = X__lookup_name(tls, bp+8, bp+1352, host, family, flags) + if naddrs < 0 { + return naddrs + } + if no_family != 0 { + return -int32(5) + } + nais = nservs * naddrs + canon_len = Int32FromUint64(_strlen(tls, bp+1352)) + out = Xcalloc(tls, uint64(1), Uint64FromInt32(nais)*uint64(88)+Uint64FromInt32(canon_len)+uint64(1)) + if !(out != 0) { + return -int32(10) + } + if canon_len != 0 { + outcanon = out + uintptr(nais)*88 + Xmemcpy(tls, outcanon, bp+1352, Uint64FromInt32(canon_len+int32(1))) + } else { + outcanon = uintptr(0) + } + v3 = Int32FromInt32(0) + i = v3 + k = v3 + for { + if !(i < naddrs) { + break + } + j = 0 + for { + if !(j < nservs) { + break + } + (**(**Taibuf)(__ccgo_up(out + uintptr(k)*88))).Fslot = int16(k) + if (**(**[48]Taddress)(__ccgo_up(bp + 8)))[i].Ffamily == int32(PF_INET) { + v5 = uint64(16) + } else { + v5 = uint64(28) + } + (**(**Taibuf)(__ccgo_up(out + uintptr(k)*88))).Fai = Taddrinfo{ + Fai_family: (**(**[48]Taddress)(__ccgo_up(bp + 8)))[i].Ffamily, + Fai_socktype: Int32FromUint8((**(**[2]Tservice)(__ccgo_up(bp)))[j].Fsocktype), + Fai_protocol: Int32FromUint8((**(**[2]Tservice)(__ccgo_up(bp)))[j].Fproto), + Fai_addrlen: uint32(v5), + Fai_addr: out + uintptr(k)*88 + 48, + Fai_canonname: outcanon, + } + if k != 0 { + (**(**Taibuf)(__ccgo_up(out + uintptr(k-int32(1))*88))).Fai.Fai_next = out + uintptr(k)*88 + } + switch (**(**[48]Taddress)(__ccgo_up(bp + 8)))[i].Ffamily { + case int32(PF_INET): + *(*Tsa_family_t)(unsafe.Pointer(out + uintptr(k)*88 + 48)) = uint16(PF_INET) + *(*Tin_port_t)(unsafe.Pointer(out + uintptr(k)*88 + 48 + 2)) = Xhtons(tls, (**(**[2]Tservice)(__ccgo_up(bp)))[j].Fport) + Xmemcpy(tls, out+uintptr(k)*88+48+4, bp+8+uintptr(i)*28+8, uint64(4)) + case int32(PF_INET6): + *(*Tsa_family_t)(unsafe.Pointer(out + uintptr(k)*88 + 48)) = uint16(PF_INET6) + *(*Tin_port_t)(unsafe.Pointer(out + uintptr(k)*88 + 48 + 2)) = Xhtons(tls, (**(**[2]Tservice)(__ccgo_up(bp)))[j].Fport) + *(*Tuint32_t)(unsafe.Pointer(out + uintptr(k)*88 + 48 + 24)) = (**(**[48]Taddress)(__ccgo_up(bp + 8)))[i].Fscopeid + Xmemcpy(tls, out+uintptr(k)*88+48+8, bp+8+uintptr(i)*28+8, uint64(16)) + break + } + goto _4 + _4: + ; + j = j + 1 + k = k + 1 + } + goto _2 + _2: + ; + i = i + 1 + } + (**(**Taibuf)(__ccgo_up(out))).Fref = int16(nais) + **(**uintptr)(__ccgo_up(res)) = out + return 0 +} + +/* Define the "an address is configured" condition for address + * families via ability to create a socket for the family plus + * routability of the loopback address for the family. */ +var _lo4 = Tsockaddr_in{ + Fsin_family: uint16(PF_INET), + Fsin_port: uint16(65535), + Fsin_addr: Tin_addr{ + Fs_addr: uint32(0x0100007f), + }, +} + +var _lo6 = Tsockaddr_in6{ + Fsin6_family: uint16(PF_INET6), + Fsin6_port: uint16(65535), + Fsin6_addr: Tin6_addr{ + F__in6_union: *(*struct { + F__s6_addr16 [0][8]Tuint16_t + F__s6_addr32 [0][4]Tuint32_t + F__s6_addr [16]Tuint8_t + })(unsafe.Pointer(&[16]Tuint8_t{ + 15: uint8(1), + })), + }, +} + +const EAI_ADDRFAMILY = -9 +const EAI_ALLDONE = -103 +const EAI_CANCELED = -101 +const EAI_IDN_ENCODE = -105 +const EAI_INPROGRESS = -100 +const EAI_INTR = -104 +const EAI_NOTCANCELED = -102 +const HOST_NOT_FOUND = 1 +const MCAST_BLOCK_SOURCE = 43 +const MCAST_EXCLUDE = 0 +const MCAST_INCLUDE = 1 +const MCAST_JOIN_GROUP = 42 +const MCAST_JOIN_SOURCE_GROUP = 46 +const MCAST_LEAVE_GROUP = 45 +const MCAST_LEAVE_SOURCE_GROUP = 47 +const MCAST_MSFILTER = 48 +const MCAST_UNBLOCK_SOURCE = 44 +const NI_MAXHOST = 255 +const NI_MAXSERV = 32 +const NO_ADDRESS = 4 +const NO_DATA = 4 +const NO_RECOVERY = 3 +const TRY_AGAIN = 2 +const h_errno = 0 + +type Tip_mreq = struct { + Fimr_multiaddr Tin_addr + Fimr_interface Tin_addr +} + +type Tip_mreqn = struct { + Fimr_multiaddr Tin_addr + Fimr_address Tin_addr + Fimr_ifindex int32 +} + +type Tip_mreq_source = struct { + Fimr_multiaddr Tin_addr + Fimr_interface Tin_addr + Fimr_sourceaddr Tin_addr +} + +type Tip_msfilter = struct { + Fimsf_multiaddr Tin_addr + Fimsf_interface Tin_addr + Fimsf_fmode Tuint32_t + Fimsf_numsrc Tuint32_t + Fimsf_slist [1]Tin_addr +} + +type Tgroup_req = struct { + Fgr_interface Tuint32_t + Fgr_group Tsockaddr_storage +} + +type Tgroup_source_req = struct { + Fgsr_interface Tuint32_t + Fgsr_group Tsockaddr_storage + Fgsr_source Tsockaddr_storage +} + +type Tgroup_filter = struct { + Fgf_interface Tuint32_t + Fgf_group Tsockaddr_storage + Fgf_fmode Tuint32_t + Fgf_numsrc Tuint32_t + Fgf_slist [1]Tsockaddr_storage +} + +type Tin_pktinfo = struct { + Fipi_ifindex int32 + Fipi_spec_dst Tin_addr + Fipi_addr Tin_addr +} + +type Tin6_pktinfo = struct { + Fipi6_addr Tin6_addr + Fipi6_ifindex uint32 +} + +type Tip6_mtuinfo = struct { + Fip6m_addr Tsockaddr_in6 + Fip6m_mtu Tuint32_t +} + +func Xgethostbyaddr(tls *TLS, a uintptr, l Tsocklen_t, af int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v a=%v l=%v af=%v, (%v:)", tls, a, l, af, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var err int32 + var size Tsize_t + var _ /* res at bp+0 */ uintptr + _, _ = err, size + size = uint64(63) + for cond := true; cond; cond = err == int32(ERANGE) { + Xfree(tls, _h) + size = size + (size + uint64(1)) + _h = Xmalloc(tls, size) + if !(_h != 0) { + **(**int32)(__ccgo_up(X__h_errno_location(tls))) = int32(NO_RECOVERY) + return uintptr(0) + } + err = Xgethostbyaddr_r(tls, a, l, af, _h, _h+UintptrFromInt32(1)*32, size-uint64(32), bp, X__h_errno_location(tls)) + } + return **(**uintptr)(__ccgo_up(bp)) +} + +var _h uintptr + +func Xgethostbyaddr_r(tls *TLS, a uintptr, l Tsocklen_t, af int32, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v l=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, a, l, af, h, buf, buflen, res, err, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var sl Tsocklen_t + var v1 uint64 + var _ /* sa at bp+0 */ struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + } + _, _, _ = i, sl, v1 + *(*struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(unsafe.Pointer(bp)) = struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + }{} + *(*uint16)(unsafe.Pointer(bp)) = Uint16FromInt32(af) + if af == int32(PF_INET6) { + v1 = uint64(28) + } else { + v1 = uint64(16) + } + sl = uint32(v1) + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + /* Load address argument into sockaddr structure */ + if af == int32(PF_INET6) && l == uint32(16) { + Xmemcpy(tls, bp+8, a, uint64(16)) + } else { + if af == int32(PF_INET) && l == uint32(4) { + Xmemcpy(tls, bp+4, a, uint64(4)) + } else { + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return int32(EINVAL) + } + } + /* Align buffer and check for space for pointers and ip address */ + i = Int32FromUint64(uint64(buf) & (Uint64FromInt64(8) - Uint64FromInt32(1))) + if !(i != 0) { + i = int32(8) + } + if buflen <= Uint64FromInt32(5)*Uint64FromInt64(8)-Uint64FromInt32(i)+uint64(l) { + return int32(ERANGE) + } + buf = buf + uintptr(uint64(8)-Uint64FromInt32(i)) + buflen = buflen - (Uint64FromInt32(5)*Uint64FromInt64(8) - Uint64FromInt32(i) + uint64(l)) + (*Thostent)(unsafe.Pointer(h)).Fh_addr_list = buf + buf = buf + uintptr(Uint64FromInt32(2)*Uint64FromInt64(8)) + (*Thostent)(unsafe.Pointer(h)).Fh_aliases = buf + buf = buf + uintptr(Uint64FromInt32(2)*Uint64FromInt64(8)) + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list)) = buf + Xmemcpy(tls, **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list)), a, uint64(l)) + buf = buf + uintptr(l) + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list + 1*8)) = uintptr(0) + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases)) = buf + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0) + switch Xgetnameinfo(tls, bp, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) { + case -int32(3): + **(**int32)(__ccgo_up(err)) = int32(TRY_AGAIN) + return int32(EAGAIN) + case -int32(12): + return int32(ERANGE) + default: + fallthrough + case -int32(4): + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return int32(EBADMSG) + case -int32(11): + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return **(**int32)(__ccgo_up(X__errno_location(tls))) + case 0: + break + } + (*Thostent)(unsafe.Pointer(h)).Fh_addrtype = af + (*Thostent)(unsafe.Pointer(h)).Fh_length = Int32FromUint32(l) + (*Thostent)(unsafe.Pointer(h)).Fh_name = **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases)) + **(**uintptr)(__ccgo_up(res)) = h + return 0 +} + +func Xgethostbyname(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgethostbyname2(tls, name, int32(PF_INET)) +} + +func Xgethostbyname2(tls *TLS, name uintptr, af int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v af=%v, (%v:)", tls, name, af, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var err int32 + var size Tsize_t + var _ /* res at bp+0 */ uintptr + _, _ = err, size + size = uint64(63) + for cond := true; cond; cond = err == int32(ERANGE) { + Xfree(tls, _h1) + size = size + (size + uint64(1)) + _h1 = Xmalloc(tls, size) + if !(_h1 != 0) { + **(**int32)(__ccgo_up(X__h_errno_location(tls))) = int32(NO_RECOVERY) + return uintptr(0) + } + err = Xgethostbyname2_r(tls, name, af, _h1, _h1+UintptrFromInt32(1)*32, size-uint64(32), bp, X__h_errno_location(tls)) + } + return **(**uintptr)(__ccgo_up(bp)) +} + +var _h1 uintptr + +func Xgethostbyname2_r(tls *TLS, name uintptr, af int32, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, name, af, h, buf, buflen, res, err, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(1600) + defer tls.Free(1600) + var align, need Tsize_t + var cnt, i, v1 int32 + var v3 uintptr + var _ /* addrs at bp+0 */ [48]Taddress + var _ /* canon at bp+1344 */ [256]uint8 + _, _, _, _, _, _ = align, cnt, i, need, v1, v3 + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + cnt = X__lookup_name(tls, bp, bp+1344, name, af, int32(AI_CANONNAME)) + if cnt < 0 { + switch cnt { + case -int32(2): + **(**int32)(__ccgo_up(err)) = int32(HOST_NOT_FOUND) + return 0 + case -int32(5): + **(**int32)(__ccgo_up(err)) = int32(NO_DATA) + return 0 + case -int32(3): + **(**int32)(__ccgo_up(err)) = int32(TRY_AGAIN) + return int32(EAGAIN) + default: + fallthrough + case -int32(4): + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return int32(EBADMSG) + case -int32(11): + **(**int32)(__ccgo_up(err)) = int32(NO_RECOVERY) + return **(**int32)(__ccgo_up(X__errno_location(tls))) + } + } + (*Thostent)(unsafe.Pointer(h)).Fh_addrtype = af + if af == int32(PF_INET6) { + v1 = int32(16) + } else { + v1 = int32(4) + } + (*Thostent)(unsafe.Pointer(h)).Fh_length = v1 + /* Align buffer */ + align = -uint64(buf) & (Uint64FromInt64(8) - Uint64FromInt32(1)) + need = Uint64FromInt32(4) * Uint64FromInt64(8) + need = need + Uint64FromInt32(cnt+Int32FromInt32(1))*(uint64(8)+Uint64FromInt32((*Thostent)(unsafe.Pointer(h)).Fh_length)) + need = need + (_strlen(tls, name) + uint64(1)) + need = need + (_strlen(tls, bp+1344) + uint64(1)) + need = need + align + if need > buflen { + return int32(ERANGE) + } + buf = buf + uintptr(align) + (*Thostent)(unsafe.Pointer(h)).Fh_aliases = buf + buf = buf + uintptr(Uint64FromInt32(3)*Uint64FromInt64(8)) + (*Thostent)(unsafe.Pointer(h)).Fh_addr_list = buf + buf = buf + uintptr(Uint64FromInt32(cnt+Int32FromInt32(1))*uint64(8)) + i = 0 + for { + if !(i < cnt) { + break + } + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = buf + buf = buf + uintptr((*Thostent)(unsafe.Pointer(h)).Fh_length) + Xmemcpy(tls, **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)), bp+uintptr(i)*28+8, Uint64FromInt32((*Thostent)(unsafe.Pointer(h)).Fh_length)) + goto _2 + _2: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = uintptr(0) + v3 = buf + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases)) = v3 + (*Thostent)(unsafe.Pointer(h)).Fh_name = v3 + Xstrcpy(tls, (*Thostent)(unsafe.Pointer(h)).Fh_name, bp+1344) + buf = buf + uintptr(_strlen(tls, (*Thostent)(unsafe.Pointer(h)).Fh_name)+uint64(1)) + if Xstrcmp(tls, (*Thostent)(unsafe.Pointer(h)).Fh_name, name) != 0 { + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = buf + Xstrcpy(tls, **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)), name) + buf = buf + uintptr(_strlen(tls, **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)))+uint64(1)) + } else { + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0) + } + **(**uintptr)(__ccgo_up((*Thostent)(unsafe.Pointer(h)).Fh_aliases + 2*8)) = uintptr(0) + **(**uintptr)(__ccgo_up(res)) = h + return 0 +} + +func Xgethostbyname_r(tls *TLS, name uintptr, h uintptr, buf uintptr, buflen Tsize_t, res uintptr, err uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, name, h, buf, buflen, res, err, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgethostbyname2_r(tls, name, int32(PF_INET), h, buf, buflen, res, err) +} + +const IFADDRS_HASH_SIZE = 64 +const IFA_ADDRESS = 1 +const IFA_BROADCAST = 4 +const IFA_LABEL = 3 +const IFA_LOCAL = 2 +const IFF_ALLMULTI = 512 +const IFF_AUTOMEDIA = 16384 +const IFF_BROADCAST = 2 +const IFF_DEBUG = 4 +const IFF_DORMANT = 131072 +const IFF_DYNAMIC = 32768 +const IFF_ECHO = 262144 +const IFF_LOOPBACK = 8 +const IFF_LOWER_UP = 65536 +const IFF_MASTER = 1024 +const IFF_MULTICAST = 4096 +const IFF_NOARP = 128 +const IFF_NOTRAILERS = 32 +const IFF_POINTOPOINT = 16 +const IFF_PORTSEL = 8192 +const IFF_PROMISC = 256 +const IFF_RUNNING = 64 +const IFF_SLAVE = 2048 +const IFF_UP = 1 +const IFF_VOLATILE = 461914 +const IFHWADDRLEN = 6 +const IFLA_ADDRESS = 1 +const IFLA_BROADCAST = 2 +const IFLA_IFNAME = 3 +const IFLA_STATS = 7 +const IFNAMSIZ = 16 +const IF_NAMESIZE = 16 +const NETLINK_ROUTE = 0 +const NLMSG_DONE = 3 +const NLMSG_ERROR = 2 +const NLMSG_NOOP = 1 +const NLMSG_OVERRUN = 4 +const NLM_F_ACK = 4 +const NLM_F_ATOMIC = 1024 +const NLM_F_DUMP = 768 +const NLM_F_MATCH = 512 +const NLM_F_MULTI = 2 +const NLM_F_REQUEST = 1 +const NLM_F_ROOT = 256 +const RTM_GETADDR = 22 +const RTM_GETLINK = 18 +const RTM_NEWADDR = 20 +const RTM_NEWLINK = 16 +const __UAPI_DEF_IF_IFCONF = 0 +const __UAPI_DEF_IF_IFMAP = 0 +const __UAPI_DEF_IF_IFNAMSIZ = 0 +const __UAPI_DEF_IF_IFREQ = 0 +const __UAPI_DEF_IF_NET_DEVICE_FLAGS = 0 +const __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO = 0 + +type Tifaddrs = struct { + Fifa_next uintptr + Fifa_name uintptr + Fifa_flags uint32 + Fifa_addr uintptr + Fifa_netmask uintptr + Fifa_ifu struct { + Fifu_dstaddr [0]uintptr + Fifu_broadaddr uintptr + } + Fifa_data uintptr +} + +type Tif_nameindex = struct { + Fif_index uint32 + Fif_name uintptr +} + +type Tifaddr = struct { + Fifa_addr Tsockaddr + Fifa_ifu struct { + Fifu_dstaddr [0]Tsockaddr + Fifu_broadaddr Tsockaddr + } + Fifa_ifp uintptr + Fifa_next uintptr +} + +type Tifmap = struct { + Fmem_start uint64 + Fmem_end uint64 + Fbase_addr uint16 + Firq uint8 + Fdma uint8 + Fport uint8 +} + +type Tifreq = struct { + Fifr_ifrn struct { + Fifrn_name [16]uint8 + } + Fifr_ifru struct { + Fifru_dstaddr [0]Tsockaddr + Fifru_broadaddr [0]Tsockaddr + Fifru_netmask [0]Tsockaddr + Fifru_hwaddr [0]Tsockaddr + Fifru_flags [0]int16 + Fifru_ivalue [0]int32 + Fifru_mtu [0]int32 + Fifru_map [0]Tifmap + Fifru_slave [0][16]uint8 + Fifru_newname [0][16]uint8 + Fifru_data [0]uintptr + Fifru_addr Tsockaddr + F__ccgo_pad12 [8]byte + } +} + +type Tifconf = struct { + Fifc_len int32 + Fifc_ifcu struct { + Fifcu_req [0]uintptr + Fifcu_buf uintptr + } +} + +type Tnlmsghdr = struct { + Fnlmsg_len Tuint32_t + Fnlmsg_type Tuint16_t + Fnlmsg_flags Tuint16_t + Fnlmsg_seq Tuint32_t + Fnlmsg_pid Tuint32_t +} + +type Trtattr = struct { + Frta_len uint16 + Frta_type uint16 +} + +type Trtgenmsg = struct { + Frtgen_family uint8 +} + +type Tifinfomsg = struct { + Fifi_family uint8 + F__ifi_pad uint8 + Fifi_type uint16 + Fifi_index int32 + Fifi_flags uint32 + Fifi_change uint32 +} + +type Tifaddrmsg = struct { + Fifa_family Tuint8_t + Fifa_prefixlen Tuint8_t + Fifa_flags Tuint8_t + Fifa_scope Tuint8_t + Fifa_index Tuint32_t +} + +/* getifaddrs() reports hardware addresses with PF_PACKET that implies + * struct sockaddr_ll. But e.g. Infiniband socket address length is + * longer than sockaddr_ll.ssl_addr[8] can hold. Use this hack struct + * to extend ssl_addr - callers should be able to still use it. */ +type Tsockaddr_ll_hack = struct { + Fsll_family uint16 + Fsll_protocol uint16 + Fsll_ifindex int32 + Fsll_hatype uint16 + Fsll_pkttype uint8 + Fsll_halen uint8 + Fsll_addr [24]uint8 +} + +type Tsockany = struct { + Fll [0]Tsockaddr_ll_hack + Fv4 [0]Tsockaddr_in + Fv6 [0]Tsockaddr_in6 + Fsa Tsockaddr + F__ccgo_pad4 [20]byte +} + +type Tifaddrs_storage = struct { + Fifa Tifaddrs + Fhash_next uintptr + Faddr Tsockany + Fnetmask Tsockany + Fifu Tsockany + Findex uint32 + Fname [17]uint8 +} + +type Tifaddrs_ctx = struct { + Ffirst uintptr + Flast uintptr + Fhash [64]uintptr +} + +func Xfreeifaddrs(tls *TLS, ifp uintptr) { + if __ccgo_strace { + trc("tls=%v ifp=%v, (%v:)", tls, ifp, origin(2)) + } + var n uintptr + _ = n + for ifp != 0 { + n = (*Tifaddrs)(unsafe.Pointer(ifp)).Fifa_next + Xfree(tls, ifp) + ifp = n + } +} + +func _copy_addr(tls *TLS, r uintptr, af int32, sa uintptr, addr uintptr, addrlen Tsize_t, ifindex int32) { + var dst uintptr + var len1 int32 + _, _ = dst, len1 + switch af { + case int32(PF_INET): + dst = sa + 4 + len1 = int32(4) + case int32(PF_INET6): + dst = sa + 8 + len1 = int32(16) + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(addr))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(addr + 1)))&int32(0xc0) == int32(0x80) || Int32FromUint8(**(**Tuint8_t)(__ccgo_up(addr))) == int32(0xff) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(addr + 1)))&int32(0xf) == int32(0x2) { + (*(*Tsockaddr_in6)(unsafe.Pointer(sa))).Fsin6_scope_id = Uint32FromInt32(ifindex) + } + default: + return + } + if addrlen < Uint64FromInt32(len1) { + return + } + (*Tsockany)(unsafe.Pointer(sa)).Fsa.Fsa_family = Uint16FromInt32(af) + Xmemcpy(tls, dst, addr, Uint64FromInt32(len1)) + **(**uintptr)(__ccgo_up(r)) = sa +} + +func _gen_netmask(tls *TLS, r uintptr, af int32, sa uintptr, prefixlen int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var i, v1 int32 + var _ /* addr at bp+0 */ [16]Tuint8_t + _, _ = i, v1 + **(**[16]Tuint8_t)(__ccgo_up(bp)) = [16]Tuint8_t{} + if Uint64FromInt32(prefixlen) > Uint64FromInt32(8)*Uint64FromInt64(16) { + prefixlen = Int32FromUint64(Uint64FromInt32(8) * Uint64FromInt64(16)) + } + i = prefixlen / int32(8) + Xmemset(tls, bp, int32(0xff), Uint64FromInt32(i)) + if Uint64FromInt32(i) < uint64(16) { + v1 = i + i = i + 1 + (**(**[16]Tuint8_t)(__ccgo_up(bp)))[v1] = Uint8FromInt32(int32(0xff) << (int32(8) - prefixlen%int32(8))) + } + _copy_addr(tls, r, af, sa, bp, uint64(16), 0) +} + +func _copy_lladdr(tls *TLS, r uintptr, sa uintptr, addr uintptr, addrlen Tsize_t, ifindex int32, hatype uint16) { + if addrlen > uint64(24) { + return + } + (*(*Tsockaddr_ll_hack)(unsafe.Pointer(sa))).Fsll_family = uint16(PF_PACKET) + (*(*Tsockaddr_ll_hack)(unsafe.Pointer(sa))).Fsll_ifindex = ifindex + (*(*Tsockaddr_ll_hack)(unsafe.Pointer(sa))).Fsll_hatype = hatype + (*(*Tsockaddr_ll_hack)(unsafe.Pointer(sa))).Fsll_halen = uint8(addrlen) + Xmemcpy(tls, sa+12, addr, addrlen) + **(**uintptr)(__ccgo_up(r)) = sa +} + +func _netlink_msg_to_ifaddr(tls *TLS, pctx uintptr, h uintptr) (r int32) { + var bucket uint32 + var ctx, ifa, ifi, ifs, ifs0, rta uintptr + var stats_len int32 + _, _, _, _, _, _, _, _ = bucket, ctx, ifa, ifi, ifs, ifs0, rta, stats_len + ctx = pctx + ifi = h + UintptrFromInt64(16) + ifa = h + UintptrFromInt64(16) + stats_len = 0 + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(RTM_NEWLINK) { + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(16)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + for { + if !(Uint64FromInt64(int64(h+uintptr((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len))-int64(rta)) >= uint64(4)) { + break + } + if Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_type) != int32(IFLA_STATS) { + goto _1 + } + stats_len = Int32FromUint64(uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len) - Uint64FromInt64(4)) + break + goto _1 + _1: + ; + rta = rta + uintptr((Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_len)+Int32FromInt32(3)) & ^Int32FromInt32(3)) + } + } else { + ifs0 = **(**uintptr)(__ccgo_up(ctx + 16 + uintptr((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index%uint32(IFADDRS_HASH_SIZE))*8)) + for { + if !(ifs0 != 0) { + break + } + if (*Tifaddrs_storage)(unsafe.Pointer(ifs0)).Findex == (*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index { + break + } + goto _2 + _2: + ; + ifs0 = (*Tifaddrs_storage)(unsafe.Pointer(ifs0)).Fhash_next + } + if !(ifs0 != 0) { + return 0 + } + } + ifs = Xcalloc(tls, uint64(1), uint64(200)+Uint64FromInt32(stats_len)) + if ifs == uintptr(0) { + return -int32(1) + } + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(RTM_NEWLINK) { + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Findex = Uint32FromInt32((*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_index) + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_flags = (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_flags + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(16)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + for { + if !(Uint64FromInt64(int64(h+uintptr((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len))-int64(rta)) >= uint64(4)) { + break + } + switch Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_type) { + case int32(IFLA_IFNAME): + if uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-uint64(4) < uint64(17) { + Xmemcpy(tls, ifs+176, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4)) + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name = ifs + 176 + } + case int32(IFLA_ADDRESS): + _copy_lladdr(tls, ifs+24, ifs+64, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_index, (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_type) + case int32(IFLA_BROADCAST): + _copy_lladdr(tls, ifs+40, ifs+136, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_index, (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_type) + case int32(IFLA_STATS): + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_data = ifs + UintptrFromInt32(1)*200 + Xmemcpy(tls, (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_data, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4)) + break + } + goto _3 + _3: + ; + rta = rta + uintptr((Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_len)+Int32FromInt32(3)) & ^Int32FromInt32(3)) + } + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name != 0 { + bucket = (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Findex % uint32(IFADDRS_HASH_SIZE) + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fhash_next = **(**uintptr)(__ccgo_up(ctx + 16 + uintptr(bucket)*8)) + **(**uintptr)(__ccgo_up(ctx + 16 + uintptr(bucket)*8)) = ifs + } + } else { + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name = (*Tifaddrs_storage)(unsafe.Pointer(ifs0)).Fifa.Fifa_name + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_flags = (*Tifaddrs_storage)(unsafe.Pointer(ifs0)).Fifa.Fifa_flags + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(8)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + for { + if !(Uint64FromInt64(int64(h+uintptr((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len))-int64(rta)) >= uint64(4)) { + break + } + switch Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_type) { + case int32(IFA_ADDRESS): + /* If ifa_addr is already set we, received an IFA_LOCAL before + * so treat this as destination address */ + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_addr != 0 { + _copy_addr(tls, ifs+40, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+136, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index)) + } else { + _copy_addr(tls, ifs+24, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+64, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index)) + } + case int32(IFA_BROADCAST): + _copy_addr(tls, ifs+40, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+136, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index)) + case int32(IFA_LOCAL): + /* If ifa_addr is set and we get IFA_LOCAL, assume we have + * a point-to-point network. Move address to correct field. */ + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_addr != 0 { + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifu = (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Faddr + *(*uintptr)(unsafe.Pointer(ifs + 40)) = ifs + 136 + Xmemset(tls, ifs+64, 0, uint64(36)) + } + _copy_addr(tls, ifs+24, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+64, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4), Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index)) + case int32(IFA_LABEL): + if uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-uint64(4) < uint64(17) { + Xmemcpy(tls, ifs+176, rta+UintptrFromInt64(4), uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len)-Uint64FromInt64(4)) + (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name = ifs + 176 + } + break + } + goto _4 + _4: + ; + rta = rta + uintptr((Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_len)+Int32FromInt32(3)) & ^Int32FromInt32(3)) + } + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_addr != 0 { + _gen_netmask(tls, ifs+32, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_family), ifs+100, Int32FromUint8((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_prefixlen)) + } + } + if (*Tifaddrs_storage)(unsafe.Pointer(ifs)).Fifa.Fifa_name != 0 { + if !((*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Ffirst != 0) { + (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Ffirst = ifs + } + if (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Flast != 0 { + (*Tifaddrs)(unsafe.Pointer((*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Flast)).Fifa_next = ifs + } + (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Flast = ifs + } else { + Xfree(tls, ifs) + } + return 0 +} + +func Xgetifaddrs(tls *TLS, ifap uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v ifap=%v, (%v:)", tls, ifap, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(528) + defer tls.Free(528) + var ctx uintptr + var r int32 + var _ /* _ctx at bp+0 */ Tifaddrs_ctx + _, _ = ctx, r + ctx = bp + Xmemset(tls, ctx, 0, uint64(528)) + r = X__rtnetlink_enumerate(tls, PF_UNSPEC, PF_UNSPEC, __ccgo_fp(_netlink_msg_to_ifaddr), ctx) + if r == 0 { + **(**uintptr)(__ccgo_up(ifap)) = (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Ffirst + } else { + Xfreeifaddrs(tls, (*Tifaddrs_ctx)(unsafe.Pointer(ctx)).Ffirst) + } + return r +} + +const RR_PTR = 12 + +func _itoa(tls *TLS, p uintptr, x uint32) (r uintptr) { + var v1 uintptr + _ = v1 + p = p + uintptr(Uint64FromInt32(3)*Uint64FromInt64(4)) + p = p - 1 + v1 = p + **(**uint8)(__ccgo_up(v1)) = uint8(0) + for cond := true; cond; cond = x != 0 { + p = p - 1 + v1 = p + **(**uint8)(__ccgo_up(v1)) = uint8(uint32('0') + x%uint32(10)) + x = x / uint32(10) + } + return p +} + +func _mkptr4(tls *TLS, s uintptr, ip uintptr) { + bp := tls.Alloc(48) + defer tls.Free(48) + Xsprintf(tls, s, __ccgo_ts+982, VaList(bp+8, Int32FromUint8(**(**uint8)(__ccgo_up(ip + 3))), Int32FromUint8(**(**uint8)(__ccgo_up(ip + 2))), Int32FromUint8(**(**uint8)(__ccgo_up(ip + 1))), Int32FromUint8(**(**uint8)(__ccgo_up(ip))))) +} + +func _mkptr6(tls *TLS, s uintptr, ip uintptr) { + var i int32 + var v2 uintptr + _, _ = i, v2 + i = int32(15) + for { + if !(i >= 0) { + break + } + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = _xdigits[Int32FromUint8(**(**uint8)(__ccgo_up(ip + uintptr(i))))&int32(15)] + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8('.') + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = _xdigits[Int32FromUint8(**(**uint8)(__ccgo_up(ip + uintptr(i))))>>int32(4)] + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = uint8('.') + goto _1 + _1: + ; + i = i - 1 + } + Xstrcpy(tls, s, __ccgo_ts+1007) +} + +var _xdigits = [17]uint8{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'} + +func _reverse_hosts(tls *TLS, buf uintptr, a uintptr, scopeid uint32, family int32) { + bp := tls.Alloc(1824) + defer tls.Free(1824) + var f, p, z, v1, v2 uintptr + var v4, v5 int32 + var v7 bool + var _ /* _buf at bp+512 */ [1032]uint8 + var _ /* _f at bp+1592 */ TFILE + var _ /* atmp at bp+1544 */ [16]uint8 + var _ /* iplit at bp+1560 */ Taddress + var _ /* line at bp+0 */ [512]uint8 + _, _, _, _, _, _, _, _ = f, p, z, v1, v2, v4, v5, v7 + f = X__fopen_rb_ca(tls, __ccgo_ts+1016, bp+1592, bp+512, uint64(1032)) + if !(f != 0) { + return + } + if family == int32(PF_INET) { + Xmemcpy(tls, bp+1544+uintptr(12), a, uint64(4)) + Xmemcpy(tls, bp+1544, __ccgo_ts+1027, uint64(12)) + a = bp + 1544 + } + for Xfgets(tls, bp, int32(512), f) != 0 { + v1 = Xstrchr(tls, bp, int32('#')) + p = v1 + if v1 != 0 { + v2 = p + p = p + 1 + **(**uint8)(__ccgo_up(v2)) = uint8('\n') + **(**uint8)(__ccgo_up(p)) = Uint8FromInt32(0) + } + p = bp + for { + if v7 = **(**uint8)(__ccgo_up(p)) != 0; v7 { + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v5 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _6 + _6: + } + if !(v7 && !(v5 != 0)) { + break + } + goto _3 + _3: + ; + p = p + 1 + } + if !(**(**uint8)(__ccgo_up(p)) != 0) { + continue + } + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + if X__lookup_ipliteral(tls, bp+1560, bp, PF_UNSPEC) <= 0 { + continue + } + if (**(**Taddress)(__ccgo_up(bp + 1560))).Ffamily == int32(PF_INET) { + Xmemcpy(tls, bp+1560+8+uintptr(12), bp+1560+8, uint64(4)) + Xmemcpy(tls, bp+1560+8, __ccgo_ts+1027, uint64(12)) + (**(**Taddress)(__ccgo_up(bp + 1560))).Fscopeid = uint32(0) + } + if Xmemcmp(tls, a, bp+1560+8, uint64(16)) != 0 || (**(**Taddress)(__ccgo_up(bp + 1560))).Fscopeid != scopeid { + continue + } + for { + if v7 = **(**uint8)(__ccgo_up(p)) != 0; v7 { + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v5 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _12 + _12: + } + if !(v7 && v5 != 0) { + break + } + goto _9 + _9: + ; + p = p + 1 + } + z = p + for { + if v7 = **(**uint8)(__ccgo_up(z)) != 0; v7 { + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(z))) + v5 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _17 + _17: + } + if !(v7 && !(v5 != 0)) { + break + } + goto _14 + _14: + ; + z = z + 1 + } + **(**uint8)(__ccgo_up(z)) = uint8(0) + if int64(z)-int64(p) < int64(256) { + Xmemcpy(tls, buf, p, Uint64FromInt64(int64(z)-int64(p)+int64(1))) + break + } + } + X__fclose_ca(tls, f) +} + +func _reverse_services(tls *TLS, buf uintptr, port int32, dgram int32) { + bp := tls.Alloc(1408) + defer tls.Free(1408) + var f, p, v1, v2 uintptr + var svport uint64 + var v4, v5 int32 + var v7 bool + var _ /* _buf at bp+136 */ [1032]uint8 + var _ /* _f at bp+1168 */ TFILE + var _ /* line at bp+0 */ [128]uint8 + var _ /* z at bp+128 */ uintptr + _, _, _, _, _, _, _, _ = f, p, svport, v1, v2, v4, v5, v7 + f = X__fopen_rb_ca(tls, __ccgo_ts+1040, bp+1168, bp+136, uint64(1032)) + if !(f != 0) { + return + } + for Xfgets(tls, bp, int32(128), f) != 0 { + v1 = Xstrchr(tls, bp, int32('#')) + p = v1 + if v1 != 0 { + v2 = p + p = p + 1 + **(**uint8)(__ccgo_up(v2)) = uint8('\n') + **(**uint8)(__ccgo_up(p)) = Uint8FromInt32(0) + } + p = bp + for { + if v7 = **(**uint8)(__ccgo_up(p)) != 0; v7 { + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v5 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _6 + _6: + } + if !(v7 && !(v5 != 0)) { + break + } + goto _3 + _3: + ; + p = p + 1 + } + if !(**(**uint8)(__ccgo_up(p)) != 0) { + continue + } + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + svport = Xstrtoul(tls, p, bp+128, int32(10)) + if svport != Uint64FromInt32(port) || **(**uintptr)(__ccgo_up(bp + 128)) == p { + continue + } + if dgram != 0 && Xstrncmp(tls, **(**uintptr)(__ccgo_up(bp + 128)), __ccgo_ts+1054, uint64(4)) != 0 { + continue + } + if !(dgram != 0) && Xstrncmp(tls, **(**uintptr)(__ccgo_up(bp + 128)), __ccgo_ts+1059, uint64(4)) != 0 { + continue + } + if int64(p)-t__predefined_ptrdiff_t(bp) > int64(32) { + continue + } + Xmemcpy(tls, buf, bp, Uint64FromInt64(int64(p)-t__predefined_ptrdiff_t(bp))) + break + } + X__fclose_ca(tls, f) +} + +func _dns_parse_callback(tls *TLS, c uintptr, rr int32, data uintptr, len1 int32, packet uintptr, plen int32) (r int32) { + if rr != int32(RR_PTR) { + return 0 + } + if X__dn_expand(tls, packet, packet+uintptr(plen), data, c, int32(256)) <= 0 { + **(**uint8)(__ccgo_up(c)) = uint8(0) + } + return 0 +} + +func Xgetnameinfo(tls *TLS, sa uintptr, sl Tsocklen_t, node uintptr, nodelen Tsocklen_t, serv uintptr, servlen Tsocklen_t, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v sa=%v sl=%v node=%v nodelen=%v serv=%v servlen=%v flags=%v, (%v:)", tls, sa, sl, node, nodelen, serv, servlen, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(976) + defer tls.Free(976) + var a, p, p1, v1 uintptr + var af, port, qlen, rlen int32 + var scopeid uint32 + var _ /* buf at bp+78 */ [256]uint8 + var _ /* num at bp+334 */ [13]uint8 + var _ /* ptr at bp+0 */ [78]uint8 + var _ /* query at bp+347 */ [96]uint8 + var _ /* reply at bp+443 */ [512]uint8 + var _ /* tmp at bp+955 */ [17]uint8 + _, _, _, _, _, _, _, _, _ = a, af, p, p1, port, qlen, rlen, scopeid, v1 + af = Int32FromUint16((*Tsockaddr)(unsafe.Pointer(sa)).Fsa_family) + switch af { + case int32(PF_INET): + a = sa + 4 + if uint64(sl) < uint64(16) { + return -int32(6) + } + _mkptr4(tls, bp, a) + scopeid = uint32(0) + case int32(PF_INET6): + a = sa + 8 + if uint64(sl) < uint64(28) { + return -int32(6) + } + if Xmemcmp(tls, a, __ccgo_ts+1027, uint64(12)) != 0 { + _mkptr6(tls, bp, a) + } else { + _mkptr4(tls, bp, a+uintptr(12)) + } + scopeid = (*Tsockaddr_in6)(unsafe.Pointer(sa)).Fsin6_scope_id + default: + return -int32(6) + } + if node != 0 && nodelen != 0 { + (**(**[256]uint8)(__ccgo_up(bp + 78)))[0] = uint8(0) + if !(flags&Int32FromInt32(NI_NUMERICHOST) != 0) { + _reverse_hosts(tls, bp+78, a, scopeid, af) + } + if !(**(**uint8)(__ccgo_up(bp + 78)) != 0) && !(flags&Int32FromInt32(NI_NUMERICHOST) != 0) { + qlen = X__res_mkquery(tls, 0, bp, int32(1), int32(RR_PTR), uintptr(0), 0, uintptr(0), bp+347, int32(96)) + (**(**[96]uint8)(__ccgo_up(bp + 347)))[int32(3)] = uint8(0) /* don't need AD flag */ + rlen = X__res_send(tls, bp+347, qlen, bp+443, int32(512)) + (**(**[256]uint8)(__ccgo_up(bp + 78)))[0] = uint8(0) + if rlen > 0 { + if Uint64FromInt32(rlen) > uint64(512) { + rlen = int32(512) + } + X__dns_parse(tls, bp+443, rlen, __ccgo_fp(_dns_parse_callback), bp+78) + } + } + if !(**(**uint8)(__ccgo_up(bp + 78)) != 0) { + if flags&int32(NI_NAMEREQD) != 0 { + return -int32(2) + } + Xinet_ntop(tls, af, a, bp+78, uint32(256)) + if scopeid != 0 { + p = uintptr(0) + if !(flags&Int32FromInt32(NI_NUMERICSCOPE) != 0) && (Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1)))&int32(0xc0) == int32(0x80) || Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xff) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1)))&int32(0xf) == int32(0x2)) { + p = Xif_indextoname(tls, scopeid, bp+955+uintptr(1)) + } + if !(p != 0) { + p = _itoa(tls, bp+334, scopeid) + } + p = p - 1 + v1 = p + **(**uint8)(__ccgo_up(v1)) = uint8('%') + Xstrcat(tls, bp+78, p) + } + } + if _strlen(tls, bp+78) >= uint64(nodelen) { + return -int32(12) + } + Xstrcpy(tls, node, bp+78) + } + if serv != 0 && servlen != 0 { + p1 = bp + 78 + port = Int32FromUint16(Xntohs(tls, (*Tsockaddr_in)(unsafe.Pointer(sa)).Fsin_port)) + (**(**[256]uint8)(__ccgo_up(bp + 78)))[0] = uint8(0) + if !(flags&Int32FromInt32(NI_NUMERICSERV) != 0) { + _reverse_services(tls, bp+78, port, flags&int32(NI_DGRAM)) + } + if !(**(**uint8)(__ccgo_up(p1)) != 0) { + p1 = _itoa(tls, bp+334, Uint32FromInt32(port)) + } + if _strlen(tls, p1) >= uint64(servlen) { + return -int32(12) + } + Xstrcpy(tls, serv, p1) + } + return 0 +} + +func Xgetpeername(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_getpeername) + _ = int32(__SC_getpeername) + v2 = int64(fd) + v3 = int64(addr) + v4 = int64(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func Xgetservbyname(tls *TLS, name uintptr, prots uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v prots=%v, (%v:)", tls, name, prots, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+0 */ uintptr + if Xgetservbyname_r(tls, name, prots, uintptr(unsafe.Pointer(&_se)), uintptr(unsafe.Pointer(&_buf3)), uint64(16), bp) != 0 { + return uintptr(0) + } + return uintptr(unsafe.Pointer(&_se)) +} + +var _se Tservent + +var _buf3 [2]uintptr + +const ALIGN = 0 + +func Xgetservbyname_r(tls *TLS, name uintptr, prots uintptr, se uintptr, buf uintptr, buflen Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v prots=%v se=%v buf=%v buflen=%v res=%v, (%v:)", tls, name, prots, se, buf, buflen, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var align, cnt, proto int32 + var v1 uintptr + var _ /* end at bp+8 */ uintptr + var _ /* servs at bp+0 */ [2]Tservice + _, _, _, _ = align, cnt, proto, v1 + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + /* Don't treat numeric port number strings as service records. */ + **(**uintptr)(__ccgo_up(bp + 8)) = __ccgo_ts + Xstrtoul(tls, name, bp+8, int32(10)) + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != 0) { + return int32(ENOENT) + } + /* Align buffer */ + align = Int32FromUint64(-uint64(buf) & (Uint64FromInt64(16) - Uint64FromInt64(8) - Uint64FromInt32(1))) + if buflen < Uint64FromInt32(2)*Uint64FromInt64(8)+Uint64FromInt32(align) { + return int32(ERANGE) + } + buf = buf + uintptr(align) + if !(prots != 0) { + proto = 0 + } else { + if !(Xstrcmp(tls, prots, __ccgo_ts+1064) != 0) { + proto = int32(IPPROTO_TCP) + } else { + if !(Xstrcmp(tls, prots, __ccgo_ts+1068) != 0) { + proto = int32(IPPROTO_UDP) + } else { + return int32(EINVAL) + } + } + } + cnt = X__lookup_serv(tls, bp, name, proto, 0, 0) + if cnt < 0 { + switch cnt { + case -int32(10): + fallthrough + case -int32(11): + return int32(ENOMEM) + default: + return int32(ENOENT) + } + } + (*Tservent)(unsafe.Pointer(se)).Fs_name = name + (*Tservent)(unsafe.Pointer(se)).Fs_aliases = buf + **(**uintptr)(__ccgo_up((*Tservent)(unsafe.Pointer(se)).Fs_aliases)) = (*Tservent)(unsafe.Pointer(se)).Fs_name + **(**uintptr)(__ccgo_up((*Tservent)(unsafe.Pointer(se)).Fs_aliases + 1*8)) = uintptr(0) + (*Tservent)(unsafe.Pointer(se)).Fs_port = Int32FromUint16(Xhtons(tls, (**(**[2]Tservice)(__ccgo_up(bp)))[0].Fport)) + if Int32FromUint8((**(**[2]Tservice)(__ccgo_up(bp)))[0].Fproto) == int32(IPPROTO_TCP) { + v1 = __ccgo_ts + 1064 + } else { + v1 = __ccgo_ts + 1068 + } + (*Tservent)(unsafe.Pointer(se)).Fs_proto = v1 + **(**uintptr)(__ccgo_up(res)) = se + return 0 +} + +func Xgetsockname(tls *TLS, fd int32, addr uintptr, len1 uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v addr=%v len1=%v, (%v:)", tls, fd, addr, len1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_getsockname) + _ = int32(__SC_getsockname) + v2 = int64(fd) + v3 = int64(addr) + v4 = int64(len1) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func Xgetsockopt(tls *TLS, fd int32, level int32, optname int32, optval uintptr, optlen uintptr) (r2 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v level=%v optname=%v optval=%v optlen=%v, (%v:)", tls, fd, level, optname, optval, optlen, origin(2)) + defer func() { trc("-> %v", r2) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var r, v8 int64 + var r1, v1 int32 + var tv uintptr + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + var _ /* tv32 at bp+8 */ [2]int64 + _, _, _, _, _, _, _, _, _, _, _ = r, r1, tv, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_getsockopt) + _ = int32(__SC_getsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(optval) + v6 = int64(optlen) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + r1 = int32(v8) + if r1 == -int32(ENOPROTOOPT) { + switch level { + case int32(SOL_SOCKET): + switch optname { + case int32(SO_RCVTIMEO): + fallthrough + case int32(SO_SNDTIMEO): + if true { + break + } + if uint64(**(**Tsocklen_t)(__ccgo_up(optlen))) < uint64(16) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + if optname == int32(SO_RCVTIMEO) { + optname = int32(SO_RCVTIMEO_OLD) + } + if optname == int32(SO_SNDTIMEO) { + optname = int32(SO_SNDTIMEO_OLD) + } + *(*[1]Tsocklen_t)(unsafe.Pointer(bp)) = [1]Tsocklen_t{ + 0: uint32(16), + } + v1 = int32(SYS_getsockopt) + _ = int32(__SC_getsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(bp + 8) + v6 = int64(bp) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _18 + } + v8 = r + goto _18 + _18: + r1 = int32(v8) + if r1 < 0 { + break + } + tv = optval + (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec = (**(**[2]int64)(__ccgo_up(bp + 8)))[0] + (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec = (**(**[2]int64)(__ccgo_up(bp + 8)))[int32(1)] + **(**Tsocklen_t)(__ccgo_up(optlen)) = uint32(16) + case int32(SO_TIMESTAMP): + fallthrough + case int32(SO_TIMESTAMPNS): + if true { + break + } + if optname == int32(SO_TIMESTAMP) { + optname = int32(SO_TIMESTAMP_OLD) + } + if optname == int32(SO_TIMESTAMPNS) { + optname = int32(SO_TIMESTAMPNS_OLD) + } + v1 = int32(SYS_getsockopt) + _ = int32(__SC_getsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(optval) + v6 = int64(optlen) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _27 + } + v8 = r + goto _27 + _27: + r1 = int32(v8) + break + } + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r1))) +} + +func X__h_errno_location(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + if !((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Fstack != 0) { + return uintptr(unsafe.Pointer(&Xh_errno)) + } + return uintptr(___get_tp(tls)) + 144 +} + +func Xherror(tls *TLS, msg uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v, (%v:)", tls, msg, origin(2)) + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1, v2 uintptr + _, _ = v1, v2 + if msg != 0 { + v1 = msg + } else { + v1 = __ccgo_ts + } + if msg != 0 { + v2 = __ccgo_ts + 289 + } else { + v2 = __ccgo_ts + } + Xfprintf(tls, uintptr(unsafe.Pointer(&X__stderr_FILE)), __ccgo_ts+1072, VaList(bp+8, v1, v2, Xhstrerror(tls, **(**int32)(__ccgo_up(X__h_errno_location(tls)))))) +} + +var _msgs1 = [84]uint8{'H', 'o', 's', 't', ' ', 'n', 'o', 't', ' ', 'f', 'o', 'u', 'n', 'd', 0, 'T', 'r', 'y', ' ', 'a', 'g', 'a', 'i', 'n', 0, 'N', 'o', 'n', '-', 'r', 'e', 'c', 'o', 'v', 'e', 'r', 'a', 'b', 'l', 'e', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'A', 'd', 'd', 'r', 'e', 's', 's', ' ', 'n', 'o', 't', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e', 0, 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r'} + +func Xhstrerror(tls *TLS, ecode int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v ecode=%v, (%v:)", tls, ecode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + _ = s + s = uintptr(unsafe.Pointer(&_msgs1)) + ecode = ecode - 1 + for { + if !(ecode != 0 && **(**uint8)(__ccgo_up(s)) != 0) { + break + } + for { + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + goto _2 + _2: + ; + s = s + 1 + } + goto _1 + _1: + ; + ecode = ecode - 1 + s = s + 1 + } + if !(**(**uint8)(__ccgo_up(s)) != 0) { + s = s + 1 + } + return X__lctrans_cur(tls, s) +} + +func Xhtonl(tls *TLS, n Tuint32_t) (r Tuint32_t) { + if __ccgo_strace { + trc("tls=%v n=%v, (%v:)", tls, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var u struct { + Fc [0]uint8 + Fi int32 + } + var v1 uint32 + var v2, v3 Tuint32_t + _, _, _, _ = u, v1, v2, v3 + u = *(*struct { + Fc [0]uint8 + Fi int32 + })(unsafe.Pointer(&struct{ f int32 }{f: int32(1)})) + if *(*uint8)(unsafe.Pointer(&u)) != 0 { + v2 = n + v3 = v2>>int32(24) | v2>>int32(8)&uint32(0xff00) | v2< %v", r) }() + } + var u struct { + Fc [0]uint8 + Fi int32 + } + var v1 int32 + var v2, v3 Tuint16_t + _, _, _, _ = u, v1, v2, v3 + u = *(*struct { + Fc [0]uint8 + Fi int32 + })(unsafe.Pointer(&struct{ f int32 }{f: int32(1)})) + if *(*uint8)(unsafe.Pointer(&u)) != 0 { + v2 = n + v3 = Uint16FromInt32(Int32FromUint16(v2)<>int32(8)) + goto _4 + _4: + v1 = Int32FromUint16(v3) + } else { + v1 = Int32FromUint16(n) + } + return Uint16FromInt32(v1) +} + +func Xif_freenameindex(tls *TLS, idx uintptr) { + if __ccgo_strace { + trc("tls=%v idx=%v, (%v:)", tls, idx, origin(2)) + } + Xfree(tls, idx) +} + +func Xif_indextoname(tls *TLS, index uint32, name uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v index=%v name=%v, (%v:)", tls, index, name, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var fd, r, v1 int32 + var _ /* ifr at bp+0 */ Tifreq + _, _, _ = fd, r, v1 + v1 = Xsocket(tls, int32(PF_LOCAL), Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC), 0) + fd = v1 + if v1 < 0 { + return uintptr(0) + } + *(*int32)(unsafe.Pointer(bp + 16)) = Int32FromUint32(index) + r = Xioctl(tls, fd, int32(SIOCGIFNAME), VaList(bp+48, bp)) + X__syscall1(tls, int64(SYS_close), int64(fd)) + if r < 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENODEV) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENXIO) + } + return uintptr(0) + } + return Xstrncpy(tls, name, bp, uint64(IF_NAMESIZE)) +} + +type Tifnamemap = struct { + Fhash_next uint32 + Findex uint32 + Fnamelen uint8 + Fname [16]uint8 +} + +type Tifnameindexctx = struct { + Fnum uint32 + Fallocated uint32 + Fstr_bytes uint32 + Flist uintptr + Fhash [64]uint32 +} + +func _netlink_msg_to_nameindex(tls *TLS, pctx uintptr, h uintptr) (r int32) { + var a Tsize_t + var bucket, index, namelen, type1 int32 + var ctx, ifa, ifi, map1, rta uintptr + var i, v2 uint32 + _, _, _, _, _, _, _, _, _, _, _, _ = a, bucket, ctx, i, ifa, ifi, index, map1, namelen, rta, type1, v2 + ctx = pctx + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(RTM_NEWLINK) { + ifi = h + UintptrFromInt64(16) + index = (*Tifinfomsg)(unsafe.Pointer(ifi)).Fifi_index + type1 = int32(IFLA_IFNAME) + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(16)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + } else { + ifa = h + UintptrFromInt64(16) + index = Int32FromUint32((*Tifaddrmsg)(unsafe.Pointer(ifa)).Fifa_index) + type1 = int32(IFA_LABEL) + rta = h + UintptrFromInt64(16) + uintptr((Uint64FromInt64(8)+Uint64FromInt32(3))&Uint64FromInt32(^Int32FromInt32(3))) + } + for { + if !(Uint64FromInt64(int64(h+uintptr((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len))-int64(rta)) >= uint64(4)) { + break + } + if Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_type) != type1 { + goto _1 + } + namelen = Int32FromUint64(uint64((*Trtattr)(unsafe.Pointer(rta)).Frta_len) - uint64(4) - uint64(1)) + if namelen > int32(IF_NAMESIZE) { + return 0 + } + /* suppress duplicates */ + bucket = index % int32(IFADDRS_HASH_SIZE) + i = **(**uint32)(__ccgo_up(ctx + 24 + uintptr(bucket)*4)) + for i != 0 { + map1 = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist + uintptr(i-uint32(1))*28 + if (*Tifnamemap)(unsafe.Pointer(map1)).Findex == Uint32FromInt32(index) && Int32FromUint8((*Tifnamemap)(unsafe.Pointer(map1)).Fnamelen) == namelen && Xmemcmp(tls, map1+9, rta+UintptrFromInt64(4), Uint64FromInt32(namelen)) == 0 { + return 0 + } + i = (*Tifnamemap)(unsafe.Pointer(map1)).Fhash_next + } + if (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum >= (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fallocated { + if (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fallocated != 0 { + v2 = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fallocated*uint32(2) + uint32(1) + } else { + v2 = uint32(8) + } + a = uint64(v2) + if a > Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt64(28) { + return -int32(1) + } + map1 = Xrealloc(tls, (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist, a*uint64(28)) + if !(map1 != 0) { + return -int32(1) + } + (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist = map1 + (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fallocated = uint32(a) + } + map1 = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist + uintptr((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum)*28 + (*Tifnamemap)(unsafe.Pointer(map1)).Findex = Uint32FromInt32(index) + (*Tifnamemap)(unsafe.Pointer(map1)).Fnamelen = Uint8FromInt32(namelen) + Xmemcpy(tls, map1+9, rta+UintptrFromInt64(4), Uint64FromInt32(namelen)) + **(**uint32)(__ccgo_up(ctx + 8)) += Uint32FromInt32(namelen + int32(1)) + (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum + 1 + (*Tifnamemap)(unsafe.Pointer(map1)).Fhash_next = **(**uint32)(__ccgo_up(ctx + 24 + uintptr(bucket)*4)) + **(**uint32)(__ccgo_up(ctx + 24 + uintptr(bucket)*4)) = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum + return 0 + goto _1 + _1: + ; + rta = rta + uintptr((Int32FromUint16((*Trtattr)(unsafe.Pointer(rta)).Frta_len)+Int32FromInt32(3)) & ^Int32FromInt32(3)) + } + return 0 +} + +func Xif_nameindex(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(288) + defer tls.Free(288) + var ctx, d, ifs, p, s, v2 uintptr + var i int32 + var _ /* _ctx at bp+0 */ Tifnameindexctx + var _ /* cs at bp+280 */ int32 + _, _, _, _, _, _, _ = ctx, d, i, ifs, p, s, v2 + ctx = bp + ifs = uintptr(0) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+280) + Xmemset(tls, ctx, 0, uint64(280)) + if X__rtnetlink_enumerate(tls, PF_UNSPEC, int32(PF_INET), __ccgo_fp(_netlink_msg_to_nameindex), ctx) < 0 { + goto err + } + ifs = Xmalloc(tls, uint64((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum+Uint32FromInt32(1))*16+uint64((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fstr_bytes)) + if !(ifs != 0) { + goto err + } + p = ifs + uintptr((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum)*16 + UintptrFromInt32(1)*16 + i = Int32FromUint32((*Tifnameindexctx)(unsafe.Pointer(ctx)).Fnum) + d = ifs + s = (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist + for { + if !(i != 0) { + break + } + (*Tif_nameindex)(unsafe.Pointer(d)).Fif_index = (*Tifnamemap)(unsafe.Pointer(s)).Findex + (*Tif_nameindex)(unsafe.Pointer(d)).Fif_name = p + Xmemcpy(tls, p, s+9, uint64((*Tifnamemap)(unsafe.Pointer(s)).Fnamelen)) + p = p + uintptr((*Tifnamemap)(unsafe.Pointer(s)).Fnamelen) + v2 = p + p = p + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(0) + goto _1 + _1: + ; + i = i - 1 + s += 28 + d += 16 + } + (*Tif_nameindex)(unsafe.Pointer(d)).Fif_index = uint32(0) + (*Tif_nameindex)(unsafe.Pointer(d)).Fif_name = uintptr(0) + goto err +err: + ; + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 280)), uintptr(0)) + Xfree(tls, (*Tifnameindexctx)(unsafe.Pointer(ctx)).Flist) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOBUFS) + return ifs +} + +func Xif_nametoindex(tls *TLS, name uintptr) (r1 uint32) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var fd, r, v1 int32 + var _ /* ifr at bp+0 */ Tifreq + _, _, _ = fd, r, v1 + v1 = Xsocket(tls, int32(PF_LOCAL), Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC), 0) + fd = v1 + if v1 < 0 { + return uint32(0) + } + Xstrncpy(tls, bp, name, uint64(16)) + r = Xioctl(tls, fd, int32(SIOCGIFINDEX), VaList(bp+48, bp)) + X__syscall1(tls, int64(SYS_close), int64(fd)) + if r < 0 { + v1 = 0 + } else { + v1 = *(*int32)(unsafe.Pointer(bp + 16)) + } + return Uint32FromInt32(v1) +} + +func Xinet_addr(tls *TLS, p uintptr) (r Tin_addr_t) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* a at bp+0 */ Tin_addr + if !(X__inet_aton(tls, p, bp) != 0) { + return Uint32FromInt32(-Int32FromInt32(1)) + } + return (**(**Tin_addr)(__ccgo_up(bp))).Fs_addr +} + +func X__inet_aton(tls *TLS, s0 uintptr, dest uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s0=%v dest=%v, (%v:)", tls, s0, dest, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var d, s uintptr + var i int32 + var _ /* a at bp+0 */ [4]uint64 + var _ /* z at bp+32 */ uintptr + _, _, _ = d, i, s + s = s0 + d = dest + **(**[4]uint64)(__ccgo_up(bp)) = [4]uint64{} + i = 0 + for { + if !(i < int32(4)) { + break + } + (**(**[4]uint64)(__ccgo_up(bp)))[i] = Xstrtoul(tls, s, bp+32, 0) + if **(**uintptr)(__ccgo_up(bp + 32)) == s || **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32))))) != int32('.') || !(BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return 0 + } + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 32)))) != 0) { + break + } + s = **(**uintptr)(__ccgo_up(bp + 32)) + uintptr(1) + goto _1 + _1: + ; + i = i + 1 + } + if i == int32(4) { + return 0 + } + switch i { + case 0: + (**(**[4]uint64)(__ccgo_up(bp)))[int32(1)] = (**(**[4]uint64)(__ccgo_up(bp)))[0] & uint64(0xffffff) + **(**uint64)(__ccgo_up(bp)) >>= uint64(24) + fallthrough + case int32(1): + (**(**[4]uint64)(__ccgo_up(bp)))[int32(2)] = (**(**[4]uint64)(__ccgo_up(bp)))[int32(1)] & uint64(0xffff) + **(**uint64)(__ccgo_up(bp + 1*8)) >>= uint64(16) + fallthrough + case int32(2): + (**(**[4]uint64)(__ccgo_up(bp)))[int32(3)] = (**(**[4]uint64)(__ccgo_up(bp)))[int32(2)] & uint64(0xff) + **(**uint64)(__ccgo_up(bp + 2*8)) >>= uint64(8) + } + i = 0 + for { + if !(i < int32(4)) { + break + } + if (**(**[4]uint64)(__ccgo_up(bp)))[i] > uint64(255) { + return 0 + } + **(**uint8)(__ccgo_up(d + uintptr(i))) = uint8((**(**[4]uint64)(__ccgo_up(bp)))[i]) + goto _2 + _2: + ; + i = i + 1 + } + return int32(1) +} + +func Xinet_aton(tls *TLS, s0 uintptr, dest uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s0=%v dest=%v, (%v:)", tls, s0, dest, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__inet_aton(tls, s0, dest) +} + +func Xinet_network(tls *TLS, p uintptr) (r Tin_addr_t) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xntohl(tls, Xinet_addr(tls, p)) +} + +func Xinet_makeaddr(tls *TLS, n Tin_addr_t, h Tin_addr_t) (r Tin_addr) { + if __ccgo_strace { + trc("tls=%v n=%v h=%v, (%v:)", tls, n, h, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n < uint32(256) { + h = h | n< %v", r) }() + } + var h Tuint32_t + _ = h + h = in.Fs_addr + if h>>int32(24) < uint32(128) { + return h & uint32(0xffffff) + } + if h>>int32(24) < uint32(192) { + return h & uint32(0xffff) + } + return h & uint32(0xff) +} + +func Xinet_netof(tls *TLS, in Tin_addr) (r Tin_addr_t) { + if __ccgo_strace { + trc("tls=%v in=%v, (%v:)", tls, in, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h Tuint32_t + _ = h + h = in.Fs_addr + if h>>int32(24) < uint32(128) { + return h >> int32(24) + } + if h>>int32(24) < uint32(192) { + return h >> int32(16) + } + return h >> int32(8) +} + +func Xinet_ntoa(tls *TLS, _in Tin_addr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v _in=%v, (%v:)", tls, _in, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + *(*Tin_addr)(unsafe.Pointer(bp)) = _in + var a uintptr + _ = a + a = bp + Xsnprintf(tls, uintptr(unsafe.Pointer(&_buf4)), uint64(16), __ccgo_ts+1080, VaList(bp+16, Int32FromUint8(**(**uint8)(__ccgo_up(a))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 1))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 2))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 3))))) + return uintptr(unsafe.Pointer(&_buf4)) +} + +var _buf4 [16]uint8 + +func Xinet_ntop(tls *TLS, af int32, a0 uintptr, s uintptr, l Tsocklen_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v af=%v a0=%v s=%v l=%v, (%v:)", tls, af, a0, s, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(192) + defer tls.Free(192) + var a uintptr + var best, i, j, max, v2 int32 + var v3 uint8 + var _ /* buf at bp+0 */ [100]uint8 + _, _, _, _, _, _, _ = a, best, i, j, max, v2, v3 + a = a0 + switch af { + case int32(PF_INET): + if Uint32FromInt32(Xsnprintf(tls, s, uint64(l), __ccgo_ts+1080, VaList(bp+112, Int32FromUint8(**(**uint8)(__ccgo_up(a))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 1))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 2))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 3)))))) < l { + return s + } + case int32(PF_INET6): + if Xmemcmp(tls, a, __ccgo_ts+1027, uint64(12)) != 0 { + Xsnprintf(tls, bp, uint64(100), __ccgo_ts+1092, VaList(bp+112, int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 1))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 2)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 3))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 4)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 5))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 6)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 7))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 8)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 9))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 10)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 11))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 12)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 13))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 14)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 15))))) + } else { + Xsnprintf(tls, bp, uint64(100), __ccgo_ts+1116, VaList(bp+112, int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 1))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 2)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 3))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 4)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 5))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 6)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 7))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 8)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 9))), int32(256)*Int32FromUint8(**(**uint8)(__ccgo_up(a + 10)))+Int32FromUint8(**(**uint8)(__ccgo_up(a + 11))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 12))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 13))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 14))), Int32FromUint8(**(**uint8)(__ccgo_up(a + 15))))) + } + /* Replace longest /(^0|:)[:0]{2,}/ with "::" */ + v2 = Int32FromInt32(0) + best = v2 + i = v2 + max = Int32FromInt32(2) + for { + if !((**(**[100]uint8)(__ccgo_up(bp)))[i] != 0) { + break + } + if i != 0 && Int32FromUint8((**(**[100]uint8)(__ccgo_up(bp)))[i]) != int32(':') { + goto _1 + } + j = Int32FromUint64(Xstrspn(tls, bp+uintptr(i), __ccgo_ts+1146)) + if j > max { + best = i + max = j + } + goto _1 + _1: + ; + i = i + 1 + } + if max > int32(3) { + v3 = Uint8FromUint8(':') + (**(**[100]uint8)(__ccgo_up(bp)))[best+int32(1)] = v3 + (**(**[100]uint8)(__ccgo_up(bp)))[best] = v3 + Xmemmove(tls, bp+uintptr(best)+uintptr(2), bp+uintptr(best)+uintptr(max), Uint64FromInt32(i-best-max+int32(1))) + } + if _strlen(tls, bp) < uint64(l) { + Xstrcpy(tls, s, bp) + return s + } + default: + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EAFNOSUPPORT) + return uintptr(0) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOSPC) + return uintptr(0) +} + +func _hexval(tls *TLS, c uint32) (r int32) { + if c-uint32('0') < uint32(10) { + return Int32FromUint32(c - uint32('0')) + } + c = c | uint32(32) + if c-uint32('a') < uint32(6) { + return Int32FromUint32(c - uint32('a') + uint32(10)) + } + return -int32(1) +} + +func Xinet_pton(tls *TLS, af int32, s uintptr, a0 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v af=%v s=%v a0=%v, (%v:)", tls, af, s, a0, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var a, v4 uintptr + var brk, d, i, j, need_v4, v, v3, v9 int32 + var v5 bool + var _ /* ip at bp+0 */ [8]Tuint16_t + _, _, _, _, _, _, _, _, _, _, _ = a, brk, d, i, j, need_v4, v, v3, v4, v5, v9 + a = a0 + brk = -int32(1) + need_v4 = 0 + if af == int32(PF_INET) { + i = 0 + for { + if !(i < int32(4)) { + break + } + v3 = Int32FromInt32(0) + j = v3 + v = v3 + for { + if !(j < int32(3) && BoolInt32(uint32(**(**uint8)(__ccgo_up(s + uintptr(j))))-uint32('0') < uint32(10)) != 0) { + break + } + v = int32(10)*v + Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(j)))) - int32('0') + goto _2 + _2: + ; + j = j + 1 + } + if j == 0 || j > int32(1) && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('0') || v > int32(255) { + return 0 + } + **(**uint8)(__ccgo_up(a + uintptr(i))) = Uint8FromInt32(v) + if Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(j)))) == 0 && i == int32(3) { + return int32(1) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(j)))) != int32('.') { + return 0 + } + s = s + uintptr(j+int32(1)) + goto _1 + _1: + ; + i = i + 1 + } + return 0 + } else { + if af != int32(PF_INET6) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EAFNOSUPPORT) + return -int32(1) + } + } + if v5 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32(':'); v5 { + s = s + 1 + v4 = s + } + if v5 && Int32FromUint8(**(**uint8)(__ccgo_up(v4))) != int32(':') { + return 0 + } + i = 0 + for { + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32(':') && brk < 0 { + brk = i + (**(**[8]Tuint16_t)(__ccgo_up(bp)))[i&int32(7)] = uint16(0) + s = s + 1 + v4 = s + if !(**(**uint8)(__ccgo_up(v4)) != 0) { + break + } + if i == int32(7) { + return 0 + } + goto _6 + } + v3 = Int32FromInt32(0) + j = v3 + v = v3 + for { + if v5 = j < int32(4); v5 { + v9 = _hexval(tls, uint32(**(**uint8)(__ccgo_up(s + uintptr(j))))) + d = v9 + } + if !(v5 && v9 >= 0) { + break + } + v = int32(16)*v + d + goto _8 + _8: + ; + j = j + 1 + } + if j == 0 { + return 0 + } + (**(**[8]Tuint16_t)(__ccgo_up(bp)))[i&int32(7)] = Uint16FromInt32(v) + if !(**(**uint8)(__ccgo_up(s + uintptr(j))) != 0) && (brk >= 0 || i == int32(7)) { + break + } + if i == int32(7) { + return 0 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(j)))) != int32(':') { + if Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(j)))) != int32('.') || i < int32(6) && brk < 0 { + return 0 + } + need_v4 = int32(1) + i = i + 1 + (**(**[8]Tuint16_t)(__ccgo_up(bp)))[i&int32(7)] = uint16(0) + break + } + s = s + uintptr(j+int32(1)) + goto _6 + _6: + ; + i = i + 1 + } + if brk >= 0 { + Xmemmove(tls, bp+uintptr(brk)*2+uintptr(7)*2-uintptr(i)*2, bp+uintptr(brk)*2, Uint64FromInt32(int32(2)*(i+int32(1)-brk))) + j = 0 + for { + if !(j < int32(7)-i) { + break + } + (**(**[8]Tuint16_t)(__ccgo_up(bp)))[brk+j] = uint16(0) + goto _12 + _12: + ; + j = j + 1 + } + } + j = 0 + for { + if !(j < int32(8)) { + break + } + v4 = a + a = a + 1 + **(**uint8)(__ccgo_up(v4)) = Uint8FromInt32(Int32FromUint16((**(**[8]Tuint16_t)(__ccgo_up(bp)))[j]) >> int32(8)) + v4 = a + a = a + 1 + **(**uint8)(__ccgo_up(v4)) = uint8((**(**[8]Tuint16_t)(__ccgo_up(bp)))[j]) + goto _13 + _13: + ; + j = j + 1 + } + if need_v4 != 0 && Xinet_pton(tls, int32(PF_INET), s, a-uintptr(4)) <= 0 { + return 0 + } + return int32(1) +} + +func Xlisten(tls *TLS, fd int32, backlog int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v backlog=%v, (%v:)", tls, fd, backlog, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_listen) + _ = int32(__SC_listen) + v2 = int64(fd) + v3 = int64(backlog) + v4 = int64(Int32FromInt32(0)) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func X__lookup_ipliteral(tls *TLS, buf uintptr, name uintptr, family int32) (r int32) { + if __ccgo_strace { + trc("tls=%v buf=%v name=%v family=%v, (%v:)", tls, buf, name, family, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(96) + defer tls.Free(96) + var p, v1 uintptr + var scopeid uint64 + var _ /* a4 at bp+0 */ Tin_addr + var _ /* a6 at bp+4 */ Tin6_addr + var _ /* tmp at bp+20 */ [64]uint8 + var _ /* z at bp+88 */ uintptr + _, _, _ = p, scopeid, v1 + if X__inet_aton(tls, name, bp) > 0 { + if family == int32(PF_INET6) { /* wrong family */ + return -int32(5) + } + Xmemcpy(tls, buf+8, bp, uint64(4)) + (**(**Taddress)(__ccgo_up(buf))).Ffamily = int32(PF_INET) + (**(**Taddress)(__ccgo_up(buf))).Fscopeid = uint32(0) + return int32(1) + } + p = Xstrchr(tls, name, int32('%')) + scopeid = uint64(0) + if p != 0 && int64(p)-int64(name) < int64(64) { + Xmemcpy(tls, bp+20, name, Uint64FromInt64(int64(p)-int64(name))) + (**(**[64]uint8)(__ccgo_up(bp + 20)))[int64(p)-int64(name)] = uint8(0) + name = bp + 20 + } + if Xinet_pton(tls, int32(PF_INET6), name, bp+4) <= 0 { + return 0 + } + if family == int32(PF_INET) { /* wrong family */ + return -int32(5) + } + Xmemcpy(tls, buf+8, bp+4, uint64(16)) + (**(**Taddress)(__ccgo_up(buf))).Ffamily = int32(PF_INET6) + if p != 0 { + p = p + 1 + v1 = p + if BoolInt32(uint32(**(**uint8)(__ccgo_up(v1)))-uint32('0') < uint32(10)) != 0 { + scopeid = Xstrtoull(tls, p, bp+88, int32(10)) + } else { + **(**uintptr)(__ccgo_up(bp + 88)) = p - uintptr(1) + } + if **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 88)))) != 0 { + if !(Int32FromUint8(**(**Tuint8_t)(__ccgo_up(bp + 4))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(bp + 4 + 1)))&int32(0xc0) == int32(0x80)) && !(Int32FromUint8(**(**Tuint8_t)(__ccgo_up(bp + 4))) == int32(0xff) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(bp + 4 + 1)))&int32(0xf) == int32(0x2)) { + return -int32(2) + } + scopeid = uint64(Xif_nametoindex(tls, p)) + if !(scopeid != 0) { + return -int32(2) + } + } + if scopeid > uint64(0xffffffff) { + return -int32(2) + } + } + (**(**Taddress)(__ccgo_up(buf))).Fscopeid = uint32(scopeid) + return int32(1) +} + +const ABUF_SIZE = 4800 +const DAS_MATCHINGLABEL = 268435456 +const DAS_MATCHINGSCOPE = 536870912 +const DAS_ORDER_SHIFT = 0 +const DAS_PREC_SHIFT = 20 +const DAS_PREFIX_SHIFT = 8 +const DAS_SCOPE_SHIFT = 16 +const DAS_USABLE = 1073741824 +const RR_A = 1 +const RR_AAAA = 28 +const RR_CNAME = 5 + +func _is_valid_hostname(tls *TLS, host uintptr) (r int32) { + var s uintptr + _ = s + if Xstrnlen(tls, host, uint64(255))-uint64(1) >= uint64(254) || Xmbstowcs(tls, uintptr(0), host, uint64(0)) == Uint64FromInt32(-Int32FromInt32(1)) { + return 0 + } + s = host + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(s))) >= int32(0x80) || Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('.') || Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('-') || Xisalnum(tls, Int32FromUint8(**(**uint8)(__ccgo_up(s)))) != 0) { + break + } + goto _1 + _1: + ; + s = s + 1 + } + return BoolInt32(!(**(**uint8)(__ccgo_up(s)) != 0)) +} + +func _name_from_null(tls *TLS, buf uintptr, name uintptr, family int32, flags int32) (r int32) { + var cnt, v1 int32 + _, _ = cnt, v1 + cnt = 0 + if name != 0 { + return 0 + } + if flags&int32(AI_PASSIVE) != 0 { + if family != int32(PF_INET6) { + v1 = cnt + cnt = cnt + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = Taddress{ + Ffamily: int32(PF_INET), + } + } + if family != int32(PF_INET) { + v1 = cnt + cnt = cnt + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = Taddress{ + Ffamily: int32(PF_INET6), + } + } + } else { + if family != int32(PF_INET6) { + v1 = cnt + cnt = cnt + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = Taddress{ + Ffamily: int32(PF_INET), + Faddr: [16]Tuint8_t{ + 0: uint8(127), + 3: uint8(1), + }, + } + } + if family != int32(PF_INET) { + v1 = cnt + cnt = cnt + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = Taddress{ + Ffamily: int32(PF_INET6), + Faddr: [16]Tuint8_t{ + 15: uint8(1), + }, + } + } + } + return cnt +} + +func _name_from_numeric(tls *TLS, buf uintptr, name uintptr, family int32) (r int32) { + return X__lookup_ipliteral(tls, buf, name, family) +} + +func _name_from_hosts(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) (r int32) { + bp := tls.Alloc(1776) + defer tls.Free(1776) + var badfam, cnt, have_canon, v5, v6, v8, v9 int32 + var f, p, z, v1, v2 uintptr + var l Tsize_t + var v11, v12 bool + var _ /* _buf at bp+512 */ [1032]uint8 + var _ /* _f at bp+1544 */ TFILE + var _ /* line at bp+0 */ [512]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = badfam, cnt, f, have_canon, l, p, z, v1, v11, v12, v2, v5, v6, v8, v9 + l = _strlen(tls, name) + cnt = 0 + badfam = 0 + have_canon = 0 + f = X__fopen_rb_ca(tls, __ccgo_ts+1016, bp+1544, bp+512, uint64(1032)) + if !(f != 0) { + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(ENOENT): + fallthrough + case int32(ENOTDIR): + fallthrough + case int32(EACCES): + return 0 + default: + return -int32(11) + } + } + for Xfgets(tls, bp, int32(512), f) != 0 && cnt < int32(MAXADDRS) { + v1 = Xstrchr(tls, bp, int32('#')) + p = v1 + if v1 != 0 { + v2 = p + p = p + 1 + **(**uint8)(__ccgo_up(v2)) = uint8('\n') + **(**uint8)(__ccgo_up(p)) = Uint8FromInt32(0) + } + p = bp + uintptr(1) + for { + v1 = Xstrstr(tls, p, name) + p = v1 + if v12 = v1 != 0; v12 { + v5 = Int32FromUint8(**(**uint8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + ; + if v11 = !(v6 != 0); !v11 { + v8 = Int32FromUint8(**(**uint8)(__ccgo_up(p + uintptr(l)))) + v9 = BoolInt32(v8 == int32(' ') || Uint32FromInt32(v8)-uint32('\t') < uint32(5)) + goto _10 + _10: + } + } + if !(v12 && (v11 || !(v9 != 0))) { + break + } + goto _3 + _3: + ; + p = p + 1 + } + if !(p != 0) { + continue + } + /* Isolate IP address to parse */ + p = bp + for { + if v11 = **(**uint8)(__ccgo_up(p)) != 0; v11 { + v5 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _16 + _16: + } + if !(v11 && !(v6 != 0)) { + break + } + goto _13 + _13: + ; + p = p + 1 + } + v1 = p + p = p + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + switch _name_from_numeric(tls, buf+uintptr(cnt)*28, bp, family) { + case int32(1): + cnt = cnt + 1 + case 0: + continue + default: + badfam = -int32(5) + break + } + if have_canon != 0 { + continue + } + /* Extract first name as canonical name */ + for { + if v11 = **(**uint8)(__ccgo_up(p)) != 0; v11 { + v5 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _22 + _22: + } + if !(v11 && v6 != 0) { + break + } + goto _19 + _19: + ; + p = p + 1 + } + z = p + for { + if v11 = **(**uint8)(__ccgo_up(z)) != 0; v11 { + v5 = Int32FromUint8(**(**uint8)(__ccgo_up(z))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _27 + _27: + } + if !(v11 && !(v6 != 0)) { + break + } + goto _24 + _24: + ; + z = z + 1 + } + **(**uint8)(__ccgo_up(z)) = uint8(0) + if _is_valid_hostname(tls, p) != 0 { + have_canon = int32(1) + Xmemcpy(tls, canon, p, Uint64FromInt64(int64(z)-int64(p)+int64(1))) + } + } + X__fclose_ca(tls, f) + if cnt != 0 { + v5 = cnt + } else { + v5 = badfam + } + return v5 +} + +type Tdpc_ctx = struct { + Faddrs uintptr + Fcanon uintptr + Fcnt int32 + Frrtype int32 +} + +func _dns_parse_callback1(tls *TLS, c uintptr, rr int32, data uintptr, len1 int32, packet uintptr, plen int32) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var ctx, v2 uintptr + var family, v1 int32 + var _ /* tmp at bp+0 */ [256]uint8 + _, _, _, _ = ctx, family, v1, v2 + ctx = c + if rr == int32(RR_CNAME) { + if X__dn_expand(tls, packet, packet+uintptr(plen), data, bp, int32(256)) > 0 && _is_valid_hostname(tls, bp) != 0 { + Xstrcpy(tls, (*Tdpc_ctx)(unsafe.Pointer(ctx)).Fcanon, bp) + } + return 0 + } + if (*Tdpc_ctx)(unsafe.Pointer(ctx)).Fcnt >= int32(MAXADDRS) { + return 0 + } + if rr != (*Tdpc_ctx)(unsafe.Pointer(ctx)).Frrtype { + return 0 + } + switch rr { + case int32(RR_A): + if len1 != int32(4) { + return -int32(1) + } + family = int32(PF_INET) + case int32(RR_AAAA): + if len1 != int32(16) { + return -int32(1) + } + family = int32(PF_INET6) + break + } + (**(**Taddress)(__ccgo_up((*Tdpc_ctx)(unsafe.Pointer(ctx)).Faddrs + uintptr((*Tdpc_ctx)(unsafe.Pointer(ctx)).Fcnt)*28))).Ffamily = family + (**(**Taddress)(__ccgo_up((*Tdpc_ctx)(unsafe.Pointer(ctx)).Faddrs + uintptr((*Tdpc_ctx)(unsafe.Pointer(ctx)).Fcnt)*28))).Fscopeid = uint32(0) + v2 = ctx + 16 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + Xmemcpy(tls, (*Tdpc_ctx)(unsafe.Pointer(ctx)).Faddrs+uintptr(v1)*28+8, data, Uint64FromInt32(len1)) + return 0 +} + +func _name_from_dns(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, conf uintptr) (r int32) { + bp := tls.Alloc(10240) + defer tls.Free(10240) + var i, nq int32 + var qtypes [2]int32 + var _ /* abuf at bp+560 */ [2][4800]uint8 + var _ /* alens at bp+10200 */ [2]int32 + var _ /* ap at bp+10176 */ [2]uintptr + var _ /* ctx at bp+10208 */ Tdpc_ctx + var _ /* qbuf at bp+0 */ [2][280]uint8 + var _ /* qlens at bp+10192 */ [2]int32 + var _ /* qp at bp+10160 */ [2]uintptr + _, _, _ = i, nq, qtypes + **(**[2]uintptr)(__ccgo_up(bp + 10160)) = [2]uintptr{ + 0: bp, + 1: bp + 1*280, + } + **(**[2]uintptr)(__ccgo_up(bp + 10176)) = [2]uintptr{ + 0: bp + 560, + 1: bp + 560 + 1*4800, + } + nq = 0 + **(**Tdpc_ctx)(__ccgo_up(bp + 10208)) = Tdpc_ctx{ + Faddrs: buf, + Fcanon: canon, + } + i = 0 + for { + if !(i < int32(2)) { + break + } + if family != _afrr[i].Faf { + (**(**[2]int32)(__ccgo_up(bp + 10192)))[nq] = X__res_mkquery(tls, 0, name, int32(1), _afrr[i].Frr, uintptr(0), 0, uintptr(0), bp+uintptr(nq)*280, int32(280)) + if (**(**[2]int32)(__ccgo_up(bp + 10192)))[nq] == -int32(1) { + return 0 + } + qtypes[nq] = _afrr[i].Frr + **(**uint8)(__ccgo_up(bp + uintptr(nq)*280 + 3)) = uint8(0) /* don't need AD flag */ + /* Ensure query IDs are distinct. */ + if nq != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(bp + uintptr(nq)*280))) == Int32FromUint8(**(**uint8)(__ccgo_up(bp))) { + **(**uint8)(__ccgo_up(bp + uintptr(nq)*280)) = **(**uint8)(__ccgo_up(bp + uintptr(nq)*280)) + 1 + } + nq = nq + 1 + } + goto _1 + _1: + ; + i = i + 1 + } + if X__res_msend_rc(tls, nq, bp+10160, bp+10192, bp+10176, bp+10200, int32(4800), conf) < 0 { + return -int32(11) + } + i = 0 + for { + if !(i < nq) { + break + } + if (**(**[2]int32)(__ccgo_up(bp + 10200)))[i] < int32(4) || Int32FromUint8(**(**uint8)(__ccgo_up(bp + 560 + uintptr(i)*4800 + 3)))&int32(15) == int32(2) { + return -int32(3) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(bp + 560 + uintptr(i)*4800 + 3)))&int32(15) == int32(3) { + return 0 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(bp + 560 + uintptr(i)*4800 + 3)))&int32(15) != 0 { + return -int32(4) + } + goto _2 + _2: + ; + i = i + 1 + } + i = nq - int32(1) + for { + if !(i >= 0) { + break + } + (**(**Tdpc_ctx)(__ccgo_up(bp + 10208))).Frrtype = qtypes[i] + if Uint64FromInt32((**(**[2]int32)(__ccgo_up(bp + 10200)))[i]) > uint64(4800) { + (**(**[2]int32)(__ccgo_up(bp + 10200)))[i] = int32(4800) + } + X__dns_parse(tls, bp+560+uintptr(i)*4800, (**(**[2]int32)(__ccgo_up(bp + 10200)))[i], __ccgo_fp(_dns_parse_callback1), bp+10208) + goto _3 + _3: + ; + i = i - 1 + } + if (**(**Tdpc_ctx)(__ccgo_up(bp + 10208))).Fcnt != 0 { + return (**(**Tdpc_ctx)(__ccgo_up(bp + 10208))).Fcnt + } + return -int32(5) +} + +var _afrr = [2]struct { + Faf int32 + Frr int32 +}{ + 0: { + Faf: int32(PF_INET6), + Frr: int32(RR_A), + }, + 1: { + Faf: int32(PF_INET), + Frr: int32(RR_AAAA), + }, +} + +func _name_from_dns_search(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) (r int32) { + bp := tls.Alloc(368) + defer tls.Free(368) + var cnt, v5, v6 int32 + var dots, l, v2 Tsize_t + var p, z uintptr + var v12 bool + var _ /* conf at bp+256 */ Tresolvconf + var _ /* search at bp+0 */ [256]uint8 + _, _, _, _, _, _, _, _, _ = cnt, dots, l, p, z, v12, v2, v5, v6 + if X__get_resolv_conf(tls, bp+256, bp, uint64(256)) < 0 { + return -int32(1) + } + /* Count dots, suppress search when >=ndots or name ends in + * a dot, which is an explicit request for global scope. */ + v2 = Uint64FromInt32(0) + l = v2 + dots = v2 + for { + if !(**(**uint8)(__ccgo_up(name + uintptr(l))) != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(name + uintptr(l)))) == int32('.') { + dots = dots + 1 + } + goto _1 + _1: + ; + l = l + 1 + } + if dots >= uint64((**(**Tresolvconf)(__ccgo_up(bp + 256))).Fndots) || Int32FromUint8(**(**uint8)(__ccgo_up(name + uintptr(l-uint64(1))))) == int32('.') { + **(**uint8)(__ccgo_up(bp)) = uint8(0) + } + /* Strip final dot for canon, fail if multiple trailing dots. */ + if Int32FromUint8(**(**uint8)(__ccgo_up(name + uintptr(l-uint64(1))))) == int32('.') { + l = l - 1 + } + if !(l != 0) || Int32FromUint8(**(**uint8)(__ccgo_up(name + uintptr(l-uint64(1))))) == int32('.') { + return -int32(2) + } + /* This can never happen; the caller already checked length. */ + if l >= uint64(256) { + return -int32(2) + } + /* Name with search domain appended is setup in canon[]. This both + * provides the desired default canonical name (if the requested + * name is not a CNAME record) and serves as a buffer for passing + * the full requested name to name_from_dns. */ + Xmemcpy(tls, canon, name, l) + **(**uint8)(__ccgo_up(canon + uintptr(l))) = uint8('.') + p = bp + for { + if !(**(**uint8)(__ccgo_up(p)) != 0) { + break + } + for { + v5 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + if !(v6 != 0) { + break + } + goto _4 + _4: + ; + p = p + 1 + } + z = p + for { + if v12 = **(**uint8)(__ccgo_up(z)) != 0; v12 { + v5 = Int32FromUint8(**(**uint8)(__ccgo_up(z))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _11 + _11: + } + if !(v12 && !(v6 != 0)) { + break + } + goto _8 + _8: + ; + z = z + 1 + } + if z == p { + break + } + if Uint64FromInt64(int64(z)-int64(p)) < uint64(256)-l-uint64(1) { + Xmemcpy(tls, canon+uintptr(l)+uintptr(1), p, Uint64FromInt64(int64(z)-int64(p))) + **(**uint8)(__ccgo_up(canon + uintptr(Uint64FromInt64(int64(z)-int64(p)+int64(1))+l))) = uint8(0) + cnt = _name_from_dns(tls, buf, canon, canon, family, bp+256) + if cnt != 0 { + return cnt + } + } + goto _3 + _3: + ; + p = z + } + **(**uint8)(__ccgo_up(canon + uintptr(l))) = uint8(0) + return _name_from_dns(tls, buf, canon, name, family, bp+256) +} + +type Tpolicy = struct { + Faddr [16]uint8 + Flen1 uint8 + Fmask uint8 + Fprec uint8 + Flabel uint8 +} + +var _defpolicy = [6]Tpolicy{ + 0: { + Faddr: [16]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, + Flen1: uint8(15), + Fmask: uint8(0xff), + Fprec: uint8(50), + }, + 1: { + Faddr: [16]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255}, + Flen1: uint8(11), + Fmask: uint8(0xff), + Fprec: uint8(35), + Flabel: uint8(4), + }, + 2: { + Faddr: [16]uint8{' ', 2}, + Flen1: uint8(1), + Fmask: uint8(0xff), + Fprec: uint8(30), + Flabel: uint8(2), + }, + 3: { + Faddr: [16]uint8{' ', 1}, + Flen1: uint8(3), + Fmask: uint8(0xff), + Fprec: uint8(5), + Flabel: uint8(5), + }, + 4: { + Faddr: [16]uint8{252}, + Fmask: uint8(0xfe), + Fprec: uint8(3), + Flabel: uint8(13), + }, + 5: { + Faddr: [16]uint8{}, + Fprec: uint8(40), + Flabel: uint8(1), + }, +} + +func _policyof(tls *TLS, a uintptr) (r uintptr) { + var i int32 + _ = i + i = 0 + for { + if Xmemcmp(tls, a, uintptr(unsafe.Pointer(&_defpolicy))+uintptr(i)*20, uint64(_defpolicy[i].Flen1)) != 0 { + goto _1 + } + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + uintptr(_defpolicy[i].Flen1))))&Int32FromUint8(_defpolicy[i].Fmask) != Int32FromUint8(**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_defpolicy)) + uintptr(i)*20 + uintptr(_defpolicy[i].Flen1)))) { + goto _1 + } + return uintptr(unsafe.Pointer(&_defpolicy)) + uintptr(i)*20 + goto _1 + _1: + ; + i = i + 1 + } + return r +} + +func _labelof(tls *TLS, a uintptr) (r int32) { + return Int32FromUint8((*Tpolicy)(unsafe.Pointer(_policyof(tls, a))).Flabel) +} + +func _scopeof(tls *TLS, a uintptr) (r int32) { + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xff) { + return Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1))) & int32(15) + } + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1)))&int32(0xc0) == int32(0x80) { + return int32(2) + } + if **(**Tuint32_t)(__ccgo_up(a)) == uint32(0) && **(**Tuint32_t)(__ccgo_up(a + 1*4)) == uint32(0) && **(**Tuint32_t)(__ccgo_up(a + 2*4)) == uint32(0) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 12))) == 0 && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 13))) == 0 && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 14))) == 0 && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 15))) == int32(1) { + return int32(2) + } + if Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a))) == int32(0xfe) && Int32FromUint8(**(**Tuint8_t)(__ccgo_up(a + 1)))&int32(0xc0) == int32(0xc0) { + return int32(5) + } + return int32(14) +} + +func _prefixmatch(tls *TLS, s uintptr, d uintptr) (r int32) { + var i uint32 + _ = i + i = uint32(0) + for { + if !(i < uint32(128) && !((Int32FromUint8(**(**Tuint8_t)(__ccgo_up(s + uintptr(i/uint32(8)))))^Int32FromUint8(**(**Tuint8_t)(__ccgo_up(d + uintptr(i/uint32(8))))))&(Int32FromInt32(128)>>(i%Uint32FromInt32(8))) != 0)) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + return Int32FromUint32(i) +} + +func _addrcmp(tls *TLS, _a uintptr, _b uintptr) (r int32) { + var a, b uintptr + _, _ = a, b + a = _a + b = _b + return (*Taddress)(unsafe.Pointer(b)).Fsortkey - (*Taddress)(unsafe.Pointer(a)).Fsortkey +} + +func X__lookup_name(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v buf=%v canon=%v name=%v family=%v flags=%v, (%v:)", tls, buf, canon, name, family, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(96) + defer tls.Free(96) + var cnt, dlabel, dprec, dscope, family1, fd, i, j, key, prefixlen, v1 int32 + var da, dpolicy, sa uintptr + var dalen Tsocklen_t + var l Tsize_t + var _ /* cs at bp+0 */ int32 + var _ /* da4 at bp+76 */ Tsockaddr_in + var _ /* da6 at bp+32 */ Tsockaddr_in6 + var _ /* sa4 at bp+60 */ Tsockaddr_in + var _ /* sa6 at bp+4 */ Tsockaddr_in6 + var _ /* salen at bp+92 */ Tsocklen_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cnt, da, dalen, dlabel, dpolicy, dprec, dscope, family1, fd, i, j, key, l, prefixlen, sa, v1 + cnt = 0 + **(**uint8)(__ccgo_up(canon)) = uint8(0) + if name != 0 { + /* reject empty name and check len so it fits into temp bufs */ + l = Xstrnlen(tls, name, uint64(255)) + if l-uint64(1) >= uint64(254) { + return -int32(2) + } + Xmemcpy(tls, canon, name, l+uint64(1)) + } + /* Procedurally, a request for v6 addresses with the v4-mapped + * flag set is like a request for unspecified family, followed + * by filtering of the results. */ + if flags&int32(AI_V4MAPPED) != 0 { + if family == int32(PF_INET6) { + family = PF_UNSPEC + } else { + flags = flags - int32(AI_V4MAPPED) + } + } + /* Try each backend until there's at least one result. */ + cnt = _name_from_null(tls, buf, name, family, flags) + if !(cnt != 0) { + cnt = _name_from_numeric(tls, buf, name, family) + } + if !(cnt != 0) && !(flags&Int32FromInt32(AI_NUMERICHOST) != 0) { + cnt = _name_from_hosts(tls, buf, canon, name, family) + if !(cnt != 0) { + cnt = _name_from_dns_search(tls, buf, canon, name, family) + } + } + if cnt <= 0 { + if cnt != 0 { + v1 = cnt + } else { + v1 = -int32(2) + } + return v1 + } + /* Filter/transform results for v4-mapped lookup, if requested. */ + if flags&int32(AI_V4MAPPED) != 0 { + if !(flags&Int32FromInt32(AI_ALL) != 0) { + /* If any v6 results exist, remove v4 results. */ + i = 0 + for { + if !(i < cnt && (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily != int32(PF_INET6)) { + break + } + goto _2 + _2: + ; + i = i + 1 + } + if i < cnt { + j = 0 + for { + if !(i < cnt) { + break + } + if (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily == int32(PF_INET6) { + v1 = j + j = j + 1 + **(**Taddress)(__ccgo_up(buf + uintptr(v1)*28)) = **(**Taddress)(__ccgo_up(buf + uintptr(i)*28)) + } + goto _3 + _3: + ; + i = i + 1 + } + v1 = j + i = v1 + cnt = v1 + } + } + /* Translate any remaining v4 results to v6 */ + i = 0 + for { + if !(i < cnt) { + break + } + if (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily != int32(PF_INET) { + goto _6 + } + Xmemcpy(tls, buf+uintptr(i)*28+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4)) + Xmemcpy(tls, buf+uintptr(i)*28+8, __ccgo_ts+1027, uint64(12)) + (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily = int32(PF_INET6) + goto _6 + _6: + ; + i = i + 1 + } + } + /* No further processing is needed if there are fewer than 2 + * results or if there are only IPv4 results. */ + if cnt < int32(2) || family == int32(PF_INET) { + return cnt + } + i = 0 + for { + if !(i < cnt) { + break + } + if (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily != int32(PF_INET) { + break + } + goto _7 + _7: + ; + i = i + 1 + } + if i == cnt { + return cnt + } + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + /* The following implements a subset of RFC 3484/6724 destination + * address selection by generating a single 31-bit sort key for + * each address. Rules 3, 4, and 7 are omitted for having + * excessive runtime and code size cost and dubious benefit. + * So far the label/precedence table cannot be customized. */ + i = 0 + for { + if !(i < cnt) { + break + } + family1 = (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Ffamily + key = 0 + **(**Tsockaddr_in6)(__ccgo_up(bp + 4)) = Tsockaddr_in6{} + **(**Tsockaddr_in6)(__ccgo_up(bp + 32)) = Tsockaddr_in6{ + Fsin6_family: uint16(PF_INET6), + Fsin6_port: uint16(65535), + Fsin6_scope_id: (**(**Taddress)(__ccgo_up(buf + uintptr(i)*28))).Fscopeid, + } + **(**Tsockaddr_in)(__ccgo_up(bp + 60)) = Tsockaddr_in{} + **(**Tsockaddr_in)(__ccgo_up(bp + 76)) = Tsockaddr_in{ + Fsin_family: uint16(PF_INET), + Fsin_port: uint16(65535), + } + if family1 == int32(PF_INET6) { + Xmemcpy(tls, bp+32+8, buf+uintptr(i)*28+8, uint64(16)) + da = bp + 32 + dalen = uint32(28) + sa = bp + 4 + **(**Tsocklen_t)(__ccgo_up(bp + 92)) = uint32(28) + } else { + Xmemcpy(tls, bp+4+8, __ccgo_ts+1027, uint64(12)) + Xmemcpy(tls, bp+32+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4)) + Xmemcpy(tls, bp+32+8, __ccgo_ts+1027, uint64(12)) + Xmemcpy(tls, bp+32+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4)) + Xmemcpy(tls, bp+76+4, buf+uintptr(i)*28+8, uint64(4)) + da = bp + 76 + dalen = uint32(16) + sa = bp + 60 + **(**Tsocklen_t)(__ccgo_up(bp + 92)) = uint32(16) + } + dpolicy = _policyof(tls, bp+32+8) + dscope = _scopeof(tls, bp+32+8) + dlabel = Int32FromUint8((*Tpolicy)(unsafe.Pointer(dpolicy)).Flabel) + dprec = Int32FromUint8((*Tpolicy)(unsafe.Pointer(dpolicy)).Fprec) + prefixlen = 0 + fd = Xsocket(tls, family1, Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC), int32(IPPROTO_UDP)) + if fd >= 0 { + if !(Xconnect(tls, fd, da, dalen) != 0) { + key = key | int32(DAS_USABLE) + if !(Xgetsockname(tls, fd, sa, bp+92) != 0) { + if family1 == int32(PF_INET) { + Xmemcpy(tls, bp+4+8+uintptr(12), bp+60+4, uint64(4)) + } + if dscope == _scopeof(tls, bp+4+8) { + key = key | int32(DAS_MATCHINGSCOPE) + } + if dlabel == _labelof(tls, bp+4+8) { + key = key | int32(DAS_MATCHINGLABEL) + } + prefixlen = _prefixmatch(tls, bp+4+8, bp+32+8) + } + } + Xclose(tls, fd) + } + key = key | dprec< %v", r) }() + } + bp := tls.Alloc(1408) + defer tls.Free(1408) + var cnt, v1, v2 int32 + var f, p, v3, v4 uintptr + var l Tsize_t + var port uint64 + var v10 bool + var _ /* _buf at bp+136 */ [1032]uint8 + var _ /* _f at bp+1168 */ TFILE + var _ /* line at bp+0 */ [128]uint8 + var _ /* z at bp+128 */ uintptr + _, _, _, _, _, _, _, _, _, _ = cnt, f, l, p, port, v1, v10, v2, v3, v4 + cnt = 0 + **(**uintptr)(__ccgo_up(bp + 128)) = __ccgo_ts + port = uint64(0) + switch socktype { + case int32(SOCK_STREAM): + switch proto { + case 0: + proto = int32(IPPROTO_TCP) + fallthrough + case int32(IPPROTO_TCP): + default: + return -int32(8) + } + case int32(SOCK_DGRAM): + switch proto { + case 0: + proto = int32(IPPROTO_UDP) + fallthrough + case int32(IPPROTO_UDP): + default: + return -int32(8) + } + fallthrough + case 0: + default: + if name != 0 { + return -int32(8) + } + (**(**Tservice)(__ccgo_up(buf))).Fport = uint16(0) + (**(**Tservice)(__ccgo_up(buf))).Fproto = Uint8FromInt32(proto) + (**(**Tservice)(__ccgo_up(buf))).Fsocktype = Uint8FromInt32(socktype) + return int32(1) + } + if name != 0 { + if !(**(**uint8)(__ccgo_up(name)) != 0) { + return -int32(8) + } + port = Xstrtoul(tls, name, bp+128, int32(10)) + } + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 128)))) != 0) { + if port > uint64(65535) { + return -int32(8) + } + if proto != int32(IPPROTO_UDP) { + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fport = uint16(port) + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fsocktype = uint8(SOCK_STREAM) + v1 = cnt + cnt = cnt + 1 + (**(**Tservice)(__ccgo_up(buf + uintptr(v1)*4))).Fproto = uint8(IPPROTO_TCP) + } + if proto != int32(IPPROTO_TCP) { + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fport = uint16(port) + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fsocktype = uint8(SOCK_DGRAM) + v1 = cnt + cnt = cnt + 1 + (**(**Tservice)(__ccgo_up(buf + uintptr(v1)*4))).Fproto = uint8(IPPROTO_UDP) + } + return cnt + } + if flags&int32(AI_NUMERICSERV) != 0 { + return -int32(2) + } + l = _strlen(tls, name) + f = X__fopen_rb_ca(tls, __ccgo_ts+1040, bp+1168, bp+136, uint64(1032)) + if !(f != 0) { + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(ENOENT): + fallthrough + case int32(ENOTDIR): + fallthrough + case int32(EACCES): + return -int32(8) + default: + return -int32(11) + } + } + for Xfgets(tls, bp, int32(128), f) != 0 && cnt < int32(MAXSERVS) { + v3 = Xstrchr(tls, bp, int32('#')) + p = v3 + if v3 != 0 { + v4 = p + p = p + 1 + **(**uint8)(__ccgo_up(v4)) = uint8('\n') + **(**uint8)(__ccgo_up(p)) = Uint8FromInt32(0) + } + /* Find service name */ + p = bp + for { + v3 = Xstrstr(tls, p, name) + p = v3 + if !(v3 != 0) { + break + } + if v10 = p > bp; v10 { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _9 + _9: + } + if v10 && !(v2 != 0) { + goto _5 + } + if v10 = **(**uint8)(__ccgo_up(p + uintptr(l))) != 0; v10 { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(p + uintptr(l)))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _13 + _13: + } + if v10 && !(v2 != 0) { + goto _5 + } + break + goto _5 + _5: + ; + p = p + 1 + } + if !(p != 0) { + continue + } + /* Skip past canonical name at beginning of line */ + p = bp + for { + if v10 = **(**uint8)(__ccgo_up(p)) != 0; v10 { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _18 + _18: + } + if !(v10 && !(v2 != 0)) { + break + } + goto _15 + _15: + ; + p = p + 1 + } + port = Xstrtoul(tls, p, bp+128, int32(10)) + if port > uint64(65535) || **(**uintptr)(__ccgo_up(bp + 128)) == p { + continue + } + if !(Xstrncmp(tls, **(**uintptr)(__ccgo_up(bp + 128)), __ccgo_ts+1054, uint64(4)) != 0) { + if proto == int32(IPPROTO_TCP) { + continue + } + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fport = uint16(port) + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fsocktype = uint8(SOCK_DGRAM) + v1 = cnt + cnt = cnt + 1 + (**(**Tservice)(__ccgo_up(buf + uintptr(v1)*4))).Fproto = uint8(IPPROTO_UDP) + } + if !(Xstrncmp(tls, **(**uintptr)(__ccgo_up(bp + 128)), __ccgo_ts+1059, uint64(4)) != 0) { + if proto == int32(IPPROTO_UDP) { + continue + } + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fport = uint16(port) + (**(**Tservice)(__ccgo_up(buf + uintptr(cnt)*4))).Fsocktype = uint8(SOCK_STREAM) + v1 = cnt + cnt = cnt + 1 + (**(**Tservice)(__ccgo_up(buf + uintptr(v1)*4))).Fproto = uint8(IPPROTO_TCP) + } + } + X__fclose_ca(tls, f) + if cnt > 0 { + v1 = cnt + } else { + v1 = -int32(8) + } + return v1 +} + +func ___netlink_enumerate(tls *TLS, fd int32, seq uint32, type1 int32, af int32, __ccgo_fp_cb uintptr, ctx uintptr) (r1 int32) { + bp := tls.Alloc(8192) + defer tls.Free(8192) + var h uintptr + var r, ret int32 + var _ /* u at bp+0 */ struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + } + _, _, _ = h, r, ret + Xmemset(tls, bp, 0, uint64(20)) + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fnlh.Fnlmsg_len = uint32(20) + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fnlh.Fnlmsg_type = Uint16FromInt32(type1) + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fnlh.Fnlmsg_flags = Uint16FromInt32(Int32FromInt32(NLM_F_ROOT) | Int32FromInt32(NLM_F_MATCH) | Int32FromInt32(NLM_F_REQUEST)) + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fnlh.Fnlmsg_seq = seq + (*(*struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + })(unsafe.Pointer(&**(**struct { + Freq [0]struct { + Fnlh Tnlmsghdr + Fg Trtgenmsg + } + Freply [0]Tnlmsghdr + Fbuf [8192]Tuint8_t + })(__ccgo_up(bp))))).Fg.Frtgen_family = Uint8FromInt32(af) + r = int32(Xsend(tls, fd, bp, uint64(20), 0)) + if r < 0 { + return r + } + for int32(1) != 0 { + r = int32(Xrecv(tls, fd, bp, uint64(8192), int32(MSG_DONTWAIT))) + if r <= 0 { + return -int32(1) + } + h = bp + for { + if !(Uint64FromInt64(int64(bp+uintptr(r))-int64(h)) >= uint64(16)) { + break + } + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(NLMSG_DONE) { + return 0 + } + if Int32FromUint16((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_type) == int32(NLMSG_ERROR) { + return -int32(1) + } + ret = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cb})))(tls, ctx, h) + if ret != 0 { + return ret + } + goto _1 + _1: + ; + h = h + uintptr(((*Tnlmsghdr)(unsafe.Pointer(h)).Fnlmsg_len+Uint32FromInt32(3))&Uint32FromInt32(^Int32FromInt32(3))) + } + } + return r1 +} + +type t__ccgo_fp__X__rtnetlink_enumerate_2 = func(*TLS, uintptr, uintptr) int32 + +func X__rtnetlink_enumerate(tls *TLS, link_af int32, addr_af int32, __ccgo_fp_cb uintptr, ctx uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v link_af=%v addr_af=%v __ccgo_fp_cb=%v ctx=%v, (%v:)", tls, link_af, addr_af, __ccgo_fp_cb, ctx, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var fd, r int32 + _, _ = fd, r + fd = Xsocket(tls, int32(PF_NETLINK), Int32FromInt32(SOCK_RAW)|Int32FromInt32(SOCK_CLOEXEC), NETLINK_ROUTE) + if fd < 0 { + return -int32(1) + } + r = ___netlink_enumerate(tls, fd, uint32(1), int32(RTM_GETLINK), link_af, __ccgo_fp_cb, ctx) + if !(r != 0) { + r = ___netlink_enumerate(tls, fd, uint32(2), int32(RTM_GETADDR), addr_af, __ccgo_fp_cb, ctx) + } + X__syscall1(tls, int64(SYS_close), int64(fd)) + return r +} + +func Xgetnetbyaddr(tls *TLS, net Tuint32_t, type1 int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v net=%v type1=%v, (%v:)", tls, net, type1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xgetnetbyname(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xns_get16(tls *TLS, cp uintptr) (r uint32) { + if __ccgo_strace { + trc("tls=%v cp=%v, (%v:)", tls, cp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(cp)))< %v", r) }() + } + return uint64(uint32(**(**uint8)(__ccgo_up(cp)))<> int32(8)) + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(s) +} + +func Xns_put32(tls *TLS, l uint64, cp uintptr) { + if __ccgo_strace { + trc("tls=%v l=%v cp=%v, (%v:)", tls, l, cp, origin(2)) + } + var v1 uintptr + _ = v1 + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(l >> int32(24)) + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(l >> int32(16)) + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(l >> int32(8)) + v1 = cp + cp = cp + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(l) +} + +func Xns_initparse(tls *TLS, msg uintptr, msglen int32, handle uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v msg=%v msglen=%v handle=%v, (%v:)", tls, msg, msglen, handle, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var i, r int32 + _, _ = i, r + (*Tns_msg)(unsafe.Pointer(handle)).F_msg = msg + (*Tns_msg)(unsafe.Pointer(handle)).F_eom = msg + uintptr(msglen) + if msglen < (Int32FromInt32(2)+int32(_ns_s_max))*Int32FromInt32(NS_INT16SZ) { + goto bad + } + msg = msg + uintptr(2) + (*Tns_msg)(unsafe.Pointer(handle)).F_id = uint16(Xns_get16(tls, msg-uintptr(2))) + msg = msg + uintptr(2) + (*Tns_msg)(unsafe.Pointer(handle)).F_flags = uint16(Xns_get16(tls, msg-uintptr(2))) + i = 0 + for { + if !(i < int32(_ns_s_max)) { + break + } + msg = msg + uintptr(2) + **(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(i)*2)) = uint16(Xns_get16(tls, msg-uintptr(2))) + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < int32(_ns_s_max)) { + break + } + if **(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(i)*2)) != 0 { + **(**uintptr)(__ccgo_up(handle + 32 + uintptr(i)*8)) = msg + r = Xns_skiprr(tls, msg, (*Tns_msg)(unsafe.Pointer(handle)).F_eom, i, Int32FromUint16(**(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(i)*2)))) + if r < 0 { + return -int32(1) + } + msg = msg + uintptr(r) + } else { + **(**uintptr)(__ccgo_up(handle + 32 + uintptr(i)*8)) = UintptrFromInt32(0) + } + goto _2 + _2: + ; + i = i + 1 + } + if msg != (*Tns_msg)(unsafe.Pointer(handle)).F_eom { + goto bad + } + (*Tns_msg)(unsafe.Pointer(handle)).F_sect = int32(_ns_s_max) + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = -int32(1) + (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr = UintptrFromInt32(0) + return 0 + goto bad +bad: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EMSGSIZE) + return -int32(1) +} + +func Xns_skiprr(tls *TLS, ptr uintptr, eom uintptr, section Tns_sect, count int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v ptr=%v eom=%v section=%v count=%v, (%v:)", tls, ptr, eom, section, count, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var p uintptr + var r, v1 int32 + _, _, _ = p, r, v1 + p = ptr + for { + v1 = count + count = count - 1 + if !(v1 != 0) { + break + } + r = Xdn_skipname(tls, p, eom) + if r < 0 { + goto bad + } + if int64(r+Int32FromInt32(2)*Int32FromInt32(NS_INT16SZ)) > int64(eom)-int64(p) { + goto bad + } + p = p + uintptr(r+Int32FromInt32(2)*Int32FromInt32(NS_INT16SZ)) + if section != int32(_ns_s_qd) { + if int64(Int32FromInt32(NS_INT32SZ)+Int32FromInt32(NS_INT16SZ)) > int64(eom)-int64(p) { + goto bad + } + p = p + uintptr(NS_INT32SZ) + p = p + uintptr(2) + r = Int32FromUint32(Xns_get16(tls, p-uintptr(2))) + if int64(r) > int64(eom)-int64(p) { + goto bad + } + p = p + uintptr(r) + } + } + return int32(int64(p) - int64(ptr)) + goto bad +bad: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EMSGSIZE) + return -int32(1) +} + +func Xns_parserr(tls *TLS, handle uintptr, section Tns_sect, rrnum int32, rr uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v handle=%v section=%v rrnum=%v rr=%v, (%v:)", tls, handle, section, rrnum, rr, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + var v1 uintptr + _, _ = r, v1 + if section < 0 || section >= int32(_ns_s_max) { + goto bad + } + if section != (*Tns_msg)(unsafe.Pointer(handle)).F_sect { + (*Tns_msg)(unsafe.Pointer(handle)).F_sect = section + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = 0 + (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr = **(**uintptr)(__ccgo_up(handle + 32 + uintptr(section)*8)) + } + if rrnum == -int32(1) { + rrnum = (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum + } + if rrnum < 0 || rrnum >= Int32FromUint16(**(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(section)*2))) { + goto bad + } + if rrnum < (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum { + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = 0 + (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr = **(**uintptr)(__ccgo_up(handle + 32 + uintptr(section)*8)) + } + if rrnum > (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum { + r = Xns_skiprr(tls, (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr, (*Tns_msg)(unsafe.Pointer(handle)).F_eom, section, rrnum-(*Tns_msg)(unsafe.Pointer(handle)).F_rrnum) + if r < 0 { + return -int32(1) + } + **(**uintptr)(__ccgo_up(handle + 72)) += uintptr(r) + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = rrnum + } + r = Xns_name_uncompress(tls, (*Tns_msg)(unsafe.Pointer(handle)).F_msg, (*Tns_msg)(unsafe.Pointer(handle)).F_eom, (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr, rr, uint64(NS_MAXDNAME)) + if r < 0 { + return -int32(1) + } + **(**uintptr)(__ccgo_up(handle + 72)) += uintptr(r) + if int64(Int32FromInt32(2)*Int32FromInt32(NS_INT16SZ)) > int64((*Tns_msg)(unsafe.Pointer(handle)).F_eom)-int64((*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr) { + goto size + } + v1 = handle + 72 + *(*uintptr)(unsafe.Pointer(v1)) += uintptr(2) + (*Tns_rr)(unsafe.Pointer(rr)).Ftype1 = uint16(Xns_get16(tls, *(*uintptr)(unsafe.Pointer(v1))-uintptr(2))) + v1 = handle + 72 + *(*uintptr)(unsafe.Pointer(v1)) += uintptr(2) + (*Tns_rr)(unsafe.Pointer(rr)).Frr_class = uint16(Xns_get16(tls, *(*uintptr)(unsafe.Pointer(v1))-uintptr(2))) + if section != int32(_ns_s_qd) { + if int64(Int32FromInt32(NS_INT32SZ)+Int32FromInt32(NS_INT16SZ)) > int64((*Tns_msg)(unsafe.Pointer(handle)).F_eom)-int64((*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr) { + goto size + } + v1 = handle + 72 + *(*uintptr)(unsafe.Pointer(v1)) += uintptr(4) + (*Tns_rr)(unsafe.Pointer(rr)).Fttl = uint32(Xns_get32(tls, *(*uintptr)(unsafe.Pointer(v1))-uintptr(4))) + v1 = handle + 72 + *(*uintptr)(unsafe.Pointer(v1)) += uintptr(2) + (*Tns_rr)(unsafe.Pointer(rr)).Frdlength = uint16(Xns_get16(tls, *(*uintptr)(unsafe.Pointer(v1))-uintptr(2))) + if Int64FromUint16((*Tns_rr)(unsafe.Pointer(rr)).Frdlength) > int64((*Tns_msg)(unsafe.Pointer(handle)).F_eom)-int64((*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr) { + goto size + } + (*Tns_rr)(unsafe.Pointer(rr)).Frdata = (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr + **(**uintptr)(__ccgo_up(handle + 72)) += uintptr((*Tns_rr)(unsafe.Pointer(rr)).Frdlength) + } else { + (*Tns_rr)(unsafe.Pointer(rr)).Fttl = uint32(0) + (*Tns_rr)(unsafe.Pointer(rr)).Frdlength = uint16(0) + (*Tns_rr)(unsafe.Pointer(rr)).Frdata = UintptrFromInt32(0) + } + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum + 1 + if (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum > Int32FromUint16(**(**Tuint16_t)(__ccgo_up(handle + 20 + uintptr(section)*2))) { + (*Tns_msg)(unsafe.Pointer(handle)).F_sect = section + int32(1) + if (*Tns_msg)(unsafe.Pointer(handle)).F_sect == int32(_ns_s_max) { + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = -int32(1) + (*Tns_msg)(unsafe.Pointer(handle)).F_msg_ptr = UintptrFromInt32(0) + } else { + (*Tns_msg)(unsafe.Pointer(handle)).F_rrnum = 0 + } + } + return 0 + goto bad +bad: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENODEV) + return -int32(1) + goto size +size: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EMSGSIZE) + return -int32(1) +} + +func Xns_name_uncompress(tls *TLS, msg uintptr, eom uintptr, src uintptr, dst uintptr, dstsiz Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v msg=%v eom=%v src=%v dst=%v dstsiz=%v, (%v:)", tls, msg, eom, src, dst, dstsiz, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = Xdn_expand(tls, msg, eom, src, dst, Int32FromUint64(dstsiz)) + if r < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EMSGSIZE) + } + return r +} + +func Xntohl(tls *TLS, n Tuint32_t) (r Tuint32_t) { + if __ccgo_strace { + trc("tls=%v n=%v, (%v:)", tls, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var u struct { + Fc [0]uint8 + Fi int32 + } + var v1 uint32 + var v2, v3 Tuint32_t + _, _, _, _ = u, v1, v2, v3 + u = *(*struct { + Fc [0]uint8 + Fi int32 + })(unsafe.Pointer(&struct{ f int32 }{f: int32(1)})) + if *(*uint8)(unsafe.Pointer(&u)) != 0 { + v2 = n + v3 = v2>>int32(24) | v2>>int32(8)&uint32(0xff00) | v2< %v", r) }() + } + var u struct { + Fc [0]uint8 + Fi int32 + } + var v1 int32 + var v2, v3 Tuint16_t + _, _, _, _ = u, v1, v2, v3 + u = *(*struct { + Fc [0]uint8 + Fi int32 + })(unsafe.Pointer(&struct{ f int32 }{f: int32(1)})) + if *(*uint8)(unsafe.Pointer(&u)) != 0 { + v2 = n + v3 = Uint16FromInt32(Int32FromUint16(v2)<>int32(8)) + goto _4 + _4: + v1 = Int32FromUint16(v3) + } else { + v1 = Int32FromUint16(n) + } + return Uint16FromInt32(v1) +} + +/* do we really need all these?? */ + +var _idx int32 +var _protos = [239]uint8{0, 'i', 'p', 0, 1, 'i', 'c', 'm', 'p', 0, 2, 'i', 'g', 'm', 'p', 0, 3, 'g', 'g', 'p', 0, 4, 'i', 'p', 'e', 'n', 'c', 'a', 'p', 0, 5, 's', 't', 0, 6, 't', 'c', 'p', 0, 8, 'e', 'g', 'p', 0, 12, 'p', 'u', 'p', 0, 17, 'u', 'd', 'p', 0, 20, 'h', 'm', 'p', 0, 22, 'x', 'n', 's', '-', 'i', 'd', 'p', 0, 27, 'r', 'd', 'p', 0, 29, 'i', 's', 'o', '-', 't', 'p', '4', 0, '$', 'x', 't', 'p', 0, '%', 'd', 'd', 'p', 0, '&', 'i', 'd', 'p', 'r', '-', 'c', 'm', 't', 'p', 0, ')', 'i', 'p', 'v', '6', 0, '+', 'i', 'p', 'v', '6', '-', 'r', 'o', 'u', 't', 'e', 0, ',', 'i', 'p', 'v', '6', '-', 'f', 'r', 'a', 'g', 0, '-', 'i', 'd', 'r', 'p', 0, '.', 'r', 's', 'v', 'p', 0, '/', 'g', 'r', 'e', 0, '2', 'e', 's', 'p', 0, '3', 'a', 'h', 0, '9', 's', 'k', 'i', 'p', 0, ':', 'i', 'p', 'v', '6', '-', 'i', 'c', 'm', 'p', 0, ';', 'i', 'p', 'v', '6', '-', 'n', 'o', 'n', 'x', 't', 0, '<', 'i', 'p', 'v', '6', '-', 'o', 'p', 't', 's', 0, 'I', 'r', 's', 'p', 'f', 0, 'Q', 'v', 'm', 't', 'p', 0, 'Y', 'o', 's', 'p', 'f', 0, '^', 'i', 'p', 'i', 'p', 0, 'b', 'e', 'n', 'c', 'a', 'p', 0, 'g', 'p', 'i', 'm', 0, 255, 'r', 'a', 'w'} + +func Xendprotoent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + _idx = 0 +} + +func Xsetprotoent(tls *TLS, stayopen int32) { + if __ccgo_strace { + trc("tls=%v stayopen=%v, (%v:)", tls, stayopen, origin(2)) + } + _idx = 0 +} + +func Xgetprotoent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + if Uint64FromInt32(_idx) >= uint64(239) { + return UintptrFromInt32(0) + } + _p.Fp_proto = Int32FromUint8(_protos[_idx]) + _p.Fp_name = uintptr(unsafe.Pointer(&_protos)) + uintptr(_idx+int32(1)) + _p.Fp_aliases = uintptr(unsafe.Pointer(&_aliases)) + _idx = Int32FromUint64(uint64(_idx) + (_strlen(tls, _p.Fp_name) + Uint64FromInt32(2))) + return uintptr(unsafe.Pointer(&_p)) +} + +var _p Tprotoent + +var _aliases uintptr + +func Xgetprotobyname(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + _ = p + Xendprotoent(tls) + for cond := true; cond; cond = p != 0 && Xstrcmp(tls, name, (*Tprotoent)(unsafe.Pointer(p)).Fp_name) != 0 { + p = Xgetprotoent(tls) + } + return p +} + +func Xgetprotobynumber(tls *TLS, num int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v num=%v, (%v:)", tls, num, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + _ = p + Xendprotoent(tls) + for cond := true; cond; cond = p != 0 && (*Tprotoent)(unsafe.Pointer(p)).Fp_proto != num { + p = Xgetprotoent(tls) + } + return p +} + +func Xrecv(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v flags=%v, (%v:)", tls, fd, buf, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xrecvfrom(tls, fd, buf, len1, flags, uintptr(0), uintptr(0)) +} + +func Xrecvfrom(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32, addr uintptr, alen uintptr) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v flags=%v addr=%v alen=%v, (%v:)", tls, fd, buf, len1, flags, addr, alen, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_recvfrom) + _ = int32(__SC_recvfrom) + v2 = int64(fd) + v3 = int64(buf) + v4 = Int64FromUint64(len1) + v5 = int64(flags) + v6 = int64(addr) + v7 = int64(alen) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return X__syscall_ret(tls, Uint64FromInt64(v8)) +} + +func Xrecvmmsg(tls *TLS, fd int32, msgvec uintptr, vlen uint32, flags uint32, timeout uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v msgvec=%v vlen=%v flags=%v timeout=%v, (%v:)", tls, fd, msgvec, vlen, flags, timeout, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i uint32 + var mh uintptr + var v2 int32 + _, _, _ = i, mh, v2 + mh = msgvec + i = vlen + for { + if !(i != 0) { + break + } + v2 = Int32FromInt32(0) + (*Tmmsghdr)(unsafe.Pointer(mh)).Fmsg_hdr.F__pad2 = v2 + (*Tmmsghdr)(unsafe.Pointer(mh)).Fmsg_hdr.F__pad1 = v2 + goto _1 + _1: + ; + i = i - 1 + mh += 64 + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_recvmmsg), int64(fd), int64(msgvec), Int64FromUint32(vlen), Int64FromUint32(flags), int64(timeout), 0)))) +} + +func X__convert_scm_timestamps(tls *TLS, msg uintptr, csize Tsocklen_t) { + if __ccgo_strace { + trc("tls=%v msg=%v csize=%v, (%v:)", tls, msg, csize, origin(2)) + } + bp := tls.Alloc(32) + defer tls.Free(32) + var cmsg, last, v2 uintptr + var type1 int32 + var _ /* tmp at bp+0 */ int64 + var _ /* tvts at bp+8 */ [2]int64 + _, _, _, _ = cmsg, last, type1, v2 + if true { + return + } + if !((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_control != 0) || !((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen != 0) { + return + } + last = uintptr(0) + type1 = 0 + if uint64((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen) >= uint64(16) { + v2 = (*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_control + } else { + v2 = UintptrFromInt32(0) + } + cmsg = v2 + for { + if !(cmsg != 0) { + break + } + if (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_level == int32(SOL_SOCKET) { + switch (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_type { + case int32(SO_TIMESTAMP_OLD): + goto _3 + case int32(SO_TIMESTAMPNS_OLD): + goto _4 + } + goto _5 + _3: + ; + if type1 != 0 { + goto _5 + } + type1 = int32(SO_TIMESTAMP) + goto common + _4: + ; + type1 = int32(SO_TIMESTAMPNS) + goto common + common: + ; + Xmemcpy(tls, bp, cmsg+UintptrFromInt32(1)*16, uint64(8)) + (**(**[2]int64)(__ccgo_up(bp + 8)))[0] = int64(**(**int64)(__ccgo_up(bp))) + Xmemcpy(tls, bp, cmsg+UintptrFromInt32(1)*16+uintptr(8), uint64(8)) + (**(**[2]int64)(__ccgo_up(bp + 8)))[int32(1)] = int64(**(**int64)(__ccgo_up(bp))) + goto _5 + _5: + } + last = cmsg + goto _1 + _1: + ; + if uint64((*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_len) < uint64(16) || (uint64((*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_len)+uint64(8)-uint64(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))+uint64(16) >= Uint64FromInt64(int64((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_control+uintptr((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen))-int64(cmsg)) { + v2 = uintptr(0) + } else { + v2 = cmsg + uintptr((uint64((*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_len)+Uint64FromInt64(8)-Uint64FromInt32(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))) + } + cmsg = v2 + } + if !(last != 0) || !(type1 != 0) { + return + } + if (Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)) + (Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)) > uint64(csize-(*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen) { + **(**int32)(__ccgo_up(msg + 48)) |= int32(MSG_CTRUNC) + return + } + v2 = msg + 40 + *(*Tsocklen_t)(unsafe.Pointer(v2)) = Tsocklen_t(uint64(*(*Tsocklen_t)(unsafe.Pointer(v2))) + ((Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)) + (Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)))) + if uint64((*Tcmsghdr)(unsafe.Pointer(last)).Fcmsg_len) < uint64(16) || (uint64((*Tcmsghdr)(unsafe.Pointer(last)).Fcmsg_len)+uint64(8)-uint64(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))+uint64(16) >= Uint64FromInt64(int64((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_control+uintptr((*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen))-int64(last)) { + v2 = uintptr(0) + } else { + v2 = last + uintptr((uint64((*Tcmsghdr)(unsafe.Pointer(last)).Fcmsg_len)+Uint64FromInt64(8)-Uint64FromInt32(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))) + } + cmsg = v2 + (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_level = int32(SOL_SOCKET) + (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_type = type1 + (*Tcmsghdr)(unsafe.Pointer(cmsg)).Fcmsg_len = uint32((Uint64FromInt64(16)+Uint64FromInt64(8)-Uint64FromInt32(1)) & ^(Uint64FromInt64(8)-Uint64FromInt32(1)) + Uint64FromInt64(16)) + Xmemcpy(tls, cmsg+UintptrFromInt32(1)*16, bp+8, uint64(16)) +} + +func Xrecvmsg(tls *TLS, fd int32, msg uintptr, flags int32) (r2 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v msg=%v flags=%v, (%v:)", tls, fd, msg, flags, origin(2)) + defer func() { trc("-> %v", r2) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var orig uintptr + var orig_controllen Tsocklen_t + var r, v9 int64 + var r1 Tssize_t + var v1 int32 + var v3, v4, v5, v6, v7, v8 Tsyscall_arg_t + var _ /* h at bp+0 */ Tmsghdr + _, _, _, _, _, _, _, _, _, _, _, _ = orig, orig_controllen, r, r1, v1, v3, v4, v5, v6, v7, v8, v9 + orig_controllen = (*Tmsghdr)(unsafe.Pointer(msg)).Fmsg_controllen + orig = msg + if msg != 0 { + **(**Tmsghdr)(__ccgo_up(bp)) = **(**Tmsghdr)(__ccgo_up(msg)) + v1 = Int32FromInt32(0) + (**(**Tmsghdr)(__ccgo_up(bp))).F__pad2 = v1 + (**(**Tmsghdr)(__ccgo_up(bp))).F__pad1 = v1 + msg = bp + } + v1 = int32(SYS_recvmsg) + _ = int32(__SC_recvmsg) + v3 = int64(fd) + v4 = int64(msg) + v5 = int64(flags) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + v8 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v3, v4, v5, v6, v7, v8) + } else { + r = X__syscall6(tls, int64(v1), v3, v4, v5, v6, v7, v8) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v9 = r + goto _10 + } + v9 = r + goto _10 +_10: + r1 = X__syscall_ret(tls, Uint64FromInt64(v9)) + if r1 >= 0 { + X__convert_scm_timestamps(tls, msg, orig_controllen) + } + if orig != 0 { + **(**Tmsghdr)(__ccgo_up(orig)) = **(**Tmsghdr)(__ccgo_up(bp)) + } + return r1 +} + +func Xres_init(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func X__res_mkquery(tls *TLS, op int32, dname uintptr, class int32, type1 int32, data uintptr, datalen int32, newrr uintptr, buf uintptr, buflen int32) (r int32) { + if __ccgo_strace { + trc("tls=%v op=%v dname=%v class=%v type1=%v data=%v datalen=%v newrr=%v buf=%v buflen=%v, (%v:)", tls, op, dname, class, type1, data, datalen, newrr, buf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(304) + defer tls.Free(304) + var i, id, j, n int32 + var l Tsize_t + var _ /* q at bp+0 */ [280]uint8 + var _ /* ts at bp+280 */ Ttimespec + _, _, _, _, _ = i, id, j, l, n + l = Xstrnlen(tls, dname, uint64(255)) + if l != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(dname + uintptr(l-uint64(1))))) == int32('.') { + l = l - 1 + } + if l != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(dname + uintptr(l-uint64(1))))) == int32('.') { + return -int32(1) + } + n = Int32FromUint64(uint64(17) + l + BoolUint64(!!(l != 0))) + if l > uint64(253) || buflen < n || Uint32FromInt32(op) > uint32(15) || Uint32FromInt32(class) > uint32(255) || Uint32FromInt32(type1) > uint32(255) { + return -int32(1) + } + /* Construct query template - ID will be filled later */ + Xmemset(tls, bp, 0, Uint64FromInt32(n)) + (**(**[280]uint8)(__ccgo_up(bp)))[int32(2)] = Uint8FromInt32(op*int32(8) + int32(1)) + (**(**[280]uint8)(__ccgo_up(bp)))[int32(3)] = uint8(32) /* AD */ + (**(**[280]uint8)(__ccgo_up(bp)))[int32(5)] = uint8(1) + Xmemcpy(tls, bp+uintptr(13), dname, l) + i = int32(13) + for { + if !((**(**[280]uint8)(__ccgo_up(bp)))[i] != 0) { + break + } + j = i + for { + if !((**(**[280]uint8)(__ccgo_up(bp)))[j] != 0 && Int32FromUint8((**(**[280]uint8)(__ccgo_up(bp)))[j]) != int32('.')) { + break + } + goto _2 + _2: + ; + j = j + 1 + } + if Uint32FromInt32(j-i)-uint32(1) > uint32(62) { + return -int32(1) + } + (**(**[280]uint8)(__ccgo_up(bp)))[i-int32(1)] = Uint8FromInt32(j - i) + goto _1 + _1: + ; + i = j + int32(1) + } + (**(**[280]uint8)(__ccgo_up(bp)))[i+int32(1)] = Uint8FromInt32(type1) + (**(**[280]uint8)(__ccgo_up(bp)))[i+int32(3)] = Uint8FromInt32(class) + /* Make a reasonably unpredictable id */ + Xclock_gettime(tls, CLOCK_REALTIME, bp+280) + id = Int32FromUint64((Uint64FromInt64((**(**Ttimespec)(__ccgo_up(bp + 280))).Ftv_nsec) + Uint64FromInt64((**(**Ttimespec)(__ccgo_up(bp + 280))).Ftv_nsec)/uint64(65536)) & uint64(0xffff)) + (**(**[280]uint8)(__ccgo_up(bp)))[0] = Uint8FromInt32(id / int32(256)) + (**(**[280]uint8)(__ccgo_up(bp)))[int32(1)] = Uint8FromInt32(id) + Xmemcpy(tls, buf, bp, Uint64FromInt32(n)) + return n +} + +func Xres_mkquery(tls *TLS, op int32, dname uintptr, class int32, type1 int32, data uintptr, datalen int32, newrr uintptr, buf uintptr, buflen int32) (r int32) { + if __ccgo_strace { + trc("tls=%v op=%v dname=%v class=%v type1=%v data=%v datalen=%v newrr=%v buf=%v buflen=%v, (%v:)", tls, op, dname, class, type1, data, datalen, newrr, buf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__res_mkquery(tls, op, dname, class, type1, data, datalen, newrr, buf, buflen) +} + +const POLLERR = 8 +const POLLHUP = 16 +const POLLIN = 1 +const POLLMSG = 1024 +const POLLNVAL = 32 +const POLLOUT = 4 +const POLLPRI = 2 +const POLLRDBAND = 128 +const POLLRDHUP = 8192 +const POLLRDNORM = 64 +const POLLWRBAND = 512 +const POLLWRNORM = 256 +const TCP_CC_INFO = 26 +const TCP_CLOSE = 7 +const TCP_CLOSE_WAIT = 8 +const TCP_CLOSING = 11 +const TCP_CM_INQ = 36 +const TCP_CONGESTION = 13 +const TCP_CORK = 3 +const TCP_DEFER_ACCEPT = 9 +const TCP_ESTABLISHED = 1 +const TCP_FASTOPEN = 23 +const TCP_FASTOPEN_CONNECT = 30 +const TCP_FASTOPEN_KEY = 33 +const TCP_FASTOPEN_NO_COOKIE = 34 +const TCP_FIN_WAIT1 = 4 +const TCP_FIN_WAIT2 = 5 +const TCP_INFO = 11 +const TCP_INQ = 36 +const TCP_KEEPCNT = 6 +const TCP_KEEPIDLE = 4 +const TCP_KEEPINTVL = 5 +const TCP_LAST_ACK = 9 +const TCP_LINGER2 = 8 +const TCP_LISTEN = 10 +const TCP_MAXSEG = 2 +const TCP_MD5SIG = 14 +const TCP_MD5SIG_EXT = 32 +const TCP_NODELAY = 1 +const TCP_NOTSENT_LOWAT = 25 +const TCP_QUEUE_SEQ = 21 +const TCP_QUICKACK = 12 +const TCP_REPAIR = 19 +const TCP_REPAIR_OPTIONS = 22 +const TCP_REPAIR_QUEUE = 20 +const TCP_REPAIR_WINDOW = 29 +const TCP_SAVED_SYN = 28 +const TCP_SAVE_SYN = 27 +const TCP_SYNCNT = 7 +const TCP_SYN_RECV = 3 +const TCP_SYN_SENT = 2 +const TCP_THIN_DUPACK = 17 +const TCP_THIN_LINEAR_TIMEOUTS = 16 +const TCP_TIMESTAMP = 24 +const TCP_TIME_WAIT = 6 +const TCP_TX_DELAY = 37 +const TCP_ULP = 31 +const TCP_USER_TIMEOUT = 18 +const TCP_WINDOW_CLAMP = 10 +const TCP_ZEROCOPY_RECEIVE = 35 + +const _TCP_NLA_PAD = 0 +const _TCP_NLA_BUSY = 1 +const _TCP_NLA_RWND_LIMITED = 2 +const _TCP_NLA_SNDBUF_LIMITED = 3 +const _TCP_NLA_DATA_SEGS_OUT = 4 +const _TCP_NLA_TOTAL_RETRANS = 5 +const _TCP_NLA_PACING_RATE = 6 +const _TCP_NLA_DELIVERY_RATE = 7 +const _TCP_NLA_SND_CWND = 8 +const _TCP_NLA_REORDERING = 9 +const _TCP_NLA_MIN_RTT = 10 +const _TCP_NLA_RECUR_RETRANS = 11 +const _TCP_NLA_DELIVERY_RATE_APP_LMT = 12 +const _TCP_NLA_SNDQ_SIZE = 13 +const _TCP_NLA_CA_STATE = 14 +const _TCP_NLA_SND_SSTHRESH = 15 +const _TCP_NLA_DELIVERED = 16 +const _TCP_NLA_DELIVERED_CE = 17 +const _TCP_NLA_BYTES_SENT = 18 +const _TCP_NLA_BYTES_RETRANS = 19 +const _TCP_NLA_DSACK_DUPS = 20 +const _TCP_NLA_REORD_SEEN = 21 +const _TCP_NLA_SRTT = 22 +const _TCP_NLA_TIMEOUT_REHASH = 23 +const _TCP_NLA_BYTES_NOTSENT = 24 +const _TCP_NLA_EDT = 25 +const _TCP_NLA_TTL = 26 + +type Tnfds_t = uint64 + +type Tpollfd = struct { + Ffd int32 + Fevents int16 + Frevents int16 +} + +func _cleanup(tls *TLS, p uintptr) { + var i int32 + var pfd uintptr + _, _ = i, pfd + pfd = p + i = 0 + for { + if !((**(**Tpollfd)(__ccgo_up(pfd + uintptr(i)*8))).Ffd >= -int32(1)) { + break + } + if (**(**Tpollfd)(__ccgo_up(pfd + uintptr(i)*8))).Ffd >= 0 { + X__syscall1(tls, int64(SYS_close), int64((**(**Tpollfd)(__ccgo_up(pfd + uintptr(i)*8))).Ffd)) + } + goto _1 + _1: + ; + i = i + 1 + } +} + +func _mtime(tls *TLS) (r uint64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ts at bp+0 */ Ttimespec + if Xclock_gettime(tls, int32(CLOCK_MONOTONIC), bp) < 0 && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOSYS) { + Xclock_gettime(tls, CLOCK_REALTIME, bp) + } + return Uint64FromInt64((**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec)*uint64(1000) + Uint64FromInt64((**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec/int64(1000000)) +} + +func _start_tcp(tls *TLS, pfd uintptr, family int32, sa uintptr, sl Tsocklen_t, q uintptr, ql int32) (r1 int32) { + bp := tls.Alloc(96) + defer tls.Free(96) + var fd, r int32 + var _ /* mh at bp+40 */ Tmsghdr + _, _ = fd, r + *(*[2]Tuint8_t)(unsafe.Pointer(bp + 32)) = [2]Tuint8_t{ + 0: Uint8FromInt32(ql >> int32(8)), + 1: Uint8FromInt32(ql), + } + *(*[2]Tiovec)(unsafe.Pointer(bp)) = [2]Tiovec{ + 0: { + Fiov_base: bp + 32, + Fiov_len: uint64(2), + }, + 1: { + Fiov_base: q, + Fiov_len: Uint64FromInt32(ql), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 40)) = Tmsghdr{ + Fmsg_name: sa, + Fmsg_namelen: sl, + Fmsg_iov: bp, + Fmsg_iovlen: int32(2), + } + fd = Xsocket(tls, family, Int32FromInt32(SOCK_STREAM)|Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK), 0) + (*Tpollfd)(unsafe.Pointer(pfd)).Ffd = fd + (*Tpollfd)(unsafe.Pointer(pfd)).Fevents = int16(POLLOUT) + *(*int32)(unsafe.Pointer(bp + 36)) = int32(1) + if !(Xsetsockopt(tls, fd, int32(IPPROTO_TCP), int32(TCP_FASTOPEN_CONNECT), bp+36, uint32(4)) != 0) { + r = int32(Xsendmsg(tls, fd, bp+40, Int32FromInt32(MSG_FASTOPEN)|Int32FromInt32(MSG_NOSIGNAL))) + if r == ql+int32(2) { + (*Tpollfd)(unsafe.Pointer(pfd)).Fevents = int16(POLLIN) + } + if r >= 0 { + return r + } + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EINPROGRESS) { + return 0 + } + } + r = Xconnect(tls, fd, sa, sl) + if !(r != 0) || **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EINPROGRESS) { + return 0 + } + Xclose(tls, fd) + (*Tpollfd)(unsafe.Pointer(pfd)).Ffd = -int32(1) + return -int32(1) +} + +func _step_mh(tls *TLS, mh uintptr, n Tsize_t) { + /* Adjust iovec in msghdr to skip first n bytes. */ + for (*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iovlen != 0 && n >= (*Tiovec)(unsafe.Pointer((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov)).Fiov_len { + n = n - (*Tiovec)(unsafe.Pointer((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov)).Fiov_len + (*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov += 16 + (*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iovlen = (*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iovlen - 1 + } + if !((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iovlen != 0) { + return + } + (*Tiovec)(unsafe.Pointer((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov)).Fiov_base = (*Tiovec)(unsafe.Pointer((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov)).Fiov_base + uintptr(n) + **(**Tsize_t)(__ccgo_up((*Tmsghdr)(unsafe.Pointer(mh)).Fmsg_iov + 8)) -= n +} + +/* Internal contract for __res_msend[_rc]: asize must be >=512, nqueries + * must be sufficiently small to be safe as VLA size. In practice it's + * either 1 or 2, anyway. */ + +func X__res_msend_rc(tls *TLS, nqueries int32, queries uintptr, qlens uintptr, answers uintptr, alens uintptr, asize int32, conf uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v nqueries=%v queries=%v qlens=%v answers=%v alens=%v asize=%v conf=%v, (%v:)", tls, nqueries, queries, qlens, answers, alens, asize, conf, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(400) + defer tls.Free(400) + var alen, attempts, family, fd, i, j, next, nns, r, rcode, retry_interval, rlen, servfail_retry, timeout, v6 int32 + var alen_buf, apos, iplit, pfd, qpos uintptr + var sl Tsocklen_t + var t0, t1, t2, v10 uint64 + var v1, v2, v3, v4 t__predefined_size_t + var v18 bool + var _ /* __cb at bp+208 */ t__ptcb + var _ /* cs at bp+200 */ int32 + var _ /* mh at bp+232 */ Tmsghdr + var _ /* mh at bp+288 */ Tmsghdr + var _ /* mh at bp+344 */ Tmsghdr + var _ /* ns at bp+116 */ [3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + } + var _ /* sa at bp+88 */ struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = alen, alen_buf, apos, attempts, family, fd, i, iplit, j, next, nns, pfd, qpos, r, rcode, retry_interval, rlen, servfail_retry, sl, t0, t1, t2, timeout, v1, v10, v18, v2, v3, v4, v6 + defer func() { + Xrealloc(tls, alen_buf, 0) + Xrealloc(tls, apos, 0) + Xrealloc(tls, pfd, 0) + Xrealloc(tls, qpos, 0) + }() + *(*struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(unsafe.Pointer(bp + 88)) = struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + }{} + *(*uint16)(unsafe.Pointer(bp + 88)) = uint16(0) + **(**[3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 116)) = [3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + }{} + sl = uint32(16) + nns = 0 + family = int32(PF_INET) + v1 = Uint64FromInt32(nqueries+int32(2)) * 8 + pfd = Xrealloc(tls, pfd, v1) + v2 = Uint64FromInt32(nqueries) * 4 + qpos = Xrealloc(tls, qpos, v2) + v3 = Uint64FromInt32(nqueries) * 4 + apos = Xrealloc(tls, apos, v3) + v4 = Uint64FromInt32(nqueries) * 2 + alen_buf = Xrealloc(tls, alen_buf, v4) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+200) + timeout = Int32FromUint32(uint32(1000) * (*Tresolvconf)(unsafe.Pointer(conf)).Ftimeout) + attempts = Int32FromUint32((*Tresolvconf)(unsafe.Pointer(conf)).Fattempts) + nns = 0 + for { + if !(Uint32FromInt32(nns) < (*Tresolvconf)(unsafe.Pointer(conf)).Fnns) { + break + } + iplit = conf + uintptr(nns)*28 + if (*Taddress)(unsafe.Pointer(iplit)).Ffamily == int32(PF_INET) { + Xmemcpy(tls, bp+116+uintptr(nns)*28+4, iplit+8, uint64(4)) + (**(**[3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 116)))[nns].Fsin.Fsin_port = Xhtons(tls, uint16(53)) + (**(**[3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 116)))[nns].Fsin.Fsin_family = uint16(PF_INET) + } else { + sl = uint32(28) + Xmemcpy(tls, bp+116+uintptr(nns)*28+8, iplit+8, uint64(16)) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(nns)*28))).Fsin6_port = Xhtons(tls, uint16(53)) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(nns)*28))).Fsin6_scope_id = (*Taddress)(unsafe.Pointer(iplit)).Fscopeid + v6 = Int32FromInt32(PF_INET6) + family = v6 + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(nns)*28))).Fsin6_family = Uint16FromInt32(v6) + } + goto _5 + _5: + ; + nns = nns + 1 + } + /* Get local address and open/bind a socket */ + fd = Xsocket(tls, family, Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK), 0) + /* Handle case where system lacks IPv6 support */ + if fd < 0 && family == int32(PF_INET6) && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EAFNOSUPPORT) { + i = 0 + for { + if !(i < nns && (**(**Taddress)(__ccgo_up(conf + uintptr(nns)*28))).Ffamily == int32(PF_INET6)) { + break + } + goto _7 + _7: + ; + i = i + 1 + } + if i == nns { + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 200)), uintptr(0)) + return -int32(1) + } + fd = Xsocket(tls, int32(PF_INET), Int32FromInt32(SOCK_DGRAM)|Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK), 0) + family = int32(PF_INET) + sl = uint32(16) + } + /* Convert any IPv4 addresses in a mixed environment to v4-mapped */ + if fd >= 0 && family == int32(PF_INET6) { + *(*int32)(unsafe.Pointer(bp)) = 0 + Xsetsockopt(tls, fd, int32(IPPROTO_IPV6), int32(IPV6_V6ONLY), bp, uint32(4)) + i = 0 + for { + if !(i < nns) { + break + } + if Int32FromUint16((**(**[3]struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 116)))[i].Fsin.Fsin_family) != int32(PF_INET) { + goto _8 + } + Xmemcpy(tls, bp+116+uintptr(i)*28+8+uintptr(12), bp+116+uintptr(i)*28+4, uint64(4)) + Xmemcpy(tls, bp+116+uintptr(i)*28+8, __ccgo_ts+1027, uint64(12)) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(i)*28))).Fsin6_family = uint16(PF_INET6) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(i)*28))).Fsin6_flowinfo = uint32(0) + (*(*Tsockaddr_in6)(unsafe.Pointer(bp + 116 + uintptr(i)*28))).Fsin6_scope_id = uint32(0) + goto _8 + _8: + ; + i = i + 1 + } + } + (**(**struct { + Fsin6 [0]Tsockaddr_in6 + Fsin Tsockaddr_in + F__ccgo_pad2 [12]byte + })(__ccgo_up(bp + 88))).Fsin.Fsin_family = Uint16FromInt32(family) + if fd < 0 || Xbind(tls, fd, bp+88, sl) < 0 { + if fd >= 0 { + Xclose(tls, fd) + } + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 200)), uintptr(0)) + return -int32(1) + } + /* Past this point, there are no errors. Each individual query will + * yield either no reply (indicated by zero length) or an answer + * packet which is up to the caller to interpret. */ + i = 0 + for { + if !(i < nqueries) { + break + } + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd = -int32(1) + goto _9 + _9: + ; + i = i + 1 + } + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), nqueries*8))).Ffd = fd + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), nqueries*8))).Fevents = int16(POLLIN) + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), (nqueries+int32(1))*8))).Ffd = -int32(2) + __pthread_cleanup_push(tls, bp+208, __ccgo_fp(_cleanup), pfd) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 200)), uintptr(0)) + Xmemset(tls, alens, 0, uint64(4)*Uint64FromInt32(nqueries)) + retry_interval = timeout / attempts + next = 0 + v10 = _mtime(tls) + t2 = v10 + t0 = v10 + t1 = t2 - Uint64FromInt32(retry_interval) + for { + if !(t2-t0 < Uint64FromInt32(timeout)) { + break + } + /* This is the loop exit condition: that all queries + * have an accepted answer. */ + i = 0 + for { + if !(i < nqueries && **(**int32)(__ccgo_up(alens + uintptr(i)*4)) > 0) { + break + } + goto _12 + _12: + ; + i = i + 1 + } + if i == nqueries { + break + } + if t2-t1 >= Uint64FromInt32(retry_interval) { + /* Query all configured namservers in parallel */ + i = 0 + for { + if !(i < nqueries) { + break + } + if !(**(**int32)(__ccgo_up(alens + uintptr(i)*4)) != 0) { + j = 0 + for { + if !(j < nns) { + break + } + Xsendto(tls, fd, **(**uintptr)(__ccgo_up(queries + uintptr(i)*8)), Uint64FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4))), int32(MSG_NOSIGNAL), bp+116+uintptr(j)*28, sl) + goto _14 + _14: + ; + j = j + 1 + } + } + goto _13 + _13: + ; + i = i + 1 + } + t1 = t2 + servfail_retry = int32(2) * nqueries + } + /* Wait for a response, or until time to retry */ + if Xpoll(tls, pfd, Uint64FromInt32(nqueries+int32(1)), Int32FromUint64(t1+Uint64FromInt32(retry_interval)-t2)) <= 0 { + goto _11 + } + for next < nqueries { + *(*[1]Tiovec)(unsafe.Pointer(bp + 8)) = [1]Tiovec{ + 0: { + Fiov_base: **(**uintptr)(__ccgo_up(answers + uintptr(next)*8)), + Fiov_len: Uint64FromInt32(asize), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 232)) = Tmsghdr{ + Fmsg_name: bp + 88, + Fmsg_namelen: sl, + Fmsg_iov: bp + 8, + Fmsg_iovlen: int32(1), + } + rlen = int32(Xrecvmsg(tls, fd, bp+232, 0)) + if rlen < 0 { + break + } + /* Ignore non-identifiable packets */ + if rlen < int32(4) { + continue + } + /* Ignore replies from addresses we didn't send to */ + j = 0 + for { + if !(j < nns && Xmemcmp(tls, bp+116+uintptr(j)*28, bp+88, uint64(sl)) != 0) { + break + } + goto _15 + _15: + ; + j = j + 1 + } + if j == nns { + continue + } + /* Find which query this answer goes with, if any */ + i = next + for { + if !(i < nqueries && (Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(next)*8))))) != Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(queries + uintptr(i)*8))))) || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(next)*8)) + 1))) != Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(queries + uintptr(i)*8)) + 1))))) { + break + } + goto _16 + _16: + ; + i = i + 1 + } + if i == nqueries { + continue + } + if **(**int32)(__ccgo_up(alens + uintptr(i)*4)) != 0 { + continue + } + /* Only accept positive or negative responses; + * retry immediately on server failure, and ignore + * all other codes such as refusal. */ + switch Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(next)*8)) + 3))) & Int32FromInt32(15) { + case 0: + fallthrough + case int32(3): + case int32(2): + if v18 = servfail_retry != 0; v18 { + v6 = servfail_retry + servfail_retry = servfail_retry - 1 + } + if v18 && v6 != 0 { + Xsendto(tls, fd, **(**uintptr)(__ccgo_up(queries + uintptr(i)*8)), Uint64FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4))), int32(MSG_NOSIGNAL), bp+116+uintptr(j)*28, sl) + } + fallthrough + default: + continue + } + /* Store answer in the right slot, or update next + * available temp slot if it's already in place. */ + **(**int32)(__ccgo_up(alens + uintptr(i)*4)) = rlen + if i == next { + for { + if !(next < nqueries && **(**int32)(__ccgo_up(alens + uintptr(next)*4)) != 0) { + break + } + goto _19 + _19: + ; + next = next + 1 + } + } else { + Xmemcpy(tls, **(**uintptr)(__ccgo_up(answers + uintptr(i)*8)), **(**uintptr)(__ccgo_up(answers + uintptr(next)*8)), Uint64FromInt32(rlen)) + } + /* Ignore further UDP if all slots full or TCP-mode */ + if next == nqueries { + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), nqueries*8))).Fevents = 0 + } + /* If answer is truncated (TC bit), fallback to TCP */ + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(i)*8)) + 2)))&int32(2) != 0 || (**(**Tmsghdr)(__ccgo_up(bp + 232))).Fmsg_flags&int32(MSG_TRUNC) != 0 { + **(**int32)(__ccgo_up(alens + uintptr(i)*4)) = -int32(1) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), uintptr(0)) + r = _start_tcp(tls, pfd+uintptr(i)*8, family, bp+116+uintptr(j)*28, sl, **(**uintptr)(__ccgo_up(queries + uintptr(i)*8)), **(**int32)(__ccgo_up(qlens + uintptr(i)*4))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 200)), uintptr(0)) + if r >= 0 { + *(*int32)(unsafe.Add(unsafe.Pointer(qpos), i*4)) = r + *(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)) = 0 + } + continue + } + } + i = 0 + for { + if !(i < nqueries) { + break + } + if int32((*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Frevents)&int32(POLLOUT) != 0 { + *(*[2]Tuint8_t)(unsafe.Pointer(bp + 52)) = [2]Tuint8_t{ + 0: Uint8FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4)) >> int32(8)), + 1: Uint8FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4))), + } + *(*[2]Tiovec)(unsafe.Pointer(bp + 24)) = [2]Tiovec{ + 0: { + Fiov_base: bp + 52, + Fiov_len: uint64(2), + }, + 1: { + Fiov_base: **(**uintptr)(__ccgo_up(queries + uintptr(i)*8)), + Fiov_len: Uint64FromInt32(**(**int32)(__ccgo_up(qlens + uintptr(i)*4))), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 288)) = Tmsghdr{ + Fmsg_iov: bp + 24, + Fmsg_iovlen: int32(2), + } + _step_mh(tls, bp+288, Uint64FromInt32(*(*int32)(unsafe.Add(unsafe.Pointer(qpos), i*4)))) + r = int32(Xsendmsg(tls, (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd, bp+288, int32(MSG_NOSIGNAL))) + if r < 0 { + goto out + } + **(**int32)(__ccgo_up(qpos + uintptr(i)*4)) += r + if *(*int32)(unsafe.Add(unsafe.Pointer(qpos), i*4)) == **(**int32)(__ccgo_up(qlens + uintptr(i)*4))+int32(2) { + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Fevents = int16(POLLIN) + } + } + goto _20 + _20: + ; + i = i + 1 + } + i = 0 + for { + if !(i < nqueries) { + break + } + if int32((*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Frevents)&int32(POLLIN) != 0 { + *(*[2]Tiovec)(unsafe.Pointer(bp + 56)) = [2]Tiovec{ + 0: { + Fiov_base: alen_buf + uintptr(i)*2, + Fiov_len: uint64(2), + }, + 1: { + Fiov_base: **(**uintptr)(__ccgo_up(answers + uintptr(i)*8)), + Fiov_len: Uint64FromInt32(asize), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 344)) = Tmsghdr{ + Fmsg_iov: bp + 56, + Fmsg_iovlen: int32(2), + } + _step_mh(tls, bp+344, Uint64FromInt32(*(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)))) + r = int32(Xrecvmsg(tls, (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd, bp+344, 0)) + if r <= 0 { + goto out + } + **(**int32)(__ccgo_up(apos + uintptr(i)*4)) += r + if *(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)) < int32(2) { + goto _21 + } + alen = Int32FromUint8(**(**uint8)(__ccgo_up(alen_buf + uintptr(i)*2)))*int32(256) + Int32FromUint8(**(**uint8)(__ccgo_up(alen_buf + uintptr(i)*2 + 1))) + if alen < int32(13) { + goto out + } + if *(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)) < alen+int32(2) && *(*int32)(unsafe.Add(unsafe.Pointer(apos), i*4)) < asize+int32(2) { + goto _21 + } + rcode = Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(answers + uintptr(i)*8)) + 3))) & int32(15) + if rcode != 0 && rcode != int32(3) { + goto out + } + /* Storing the length here commits the accepted answer. + * Immediately close TCP socket so as not to consume + * resources we no longer need. */ + **(**int32)(__ccgo_up(alens + uintptr(i)*4)) = alen + X__syscall1(tls, int64(SYS_close), int64((*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd)) + (*(*Tpollfd)(unsafe.Add(unsafe.Pointer(pfd), i*8))).Ffd = -int32(1) + } + goto _21 + _21: + ; + i = i + 1 + } + goto _11 + _11: + ; + t2 = _mtime(tls) + } + goto out +out: + ; + __pthread_cleanup_pop(tls, bp+208, int32(1)) + /* Disregard any incomplete TCP results */ + i = 0 + for { + if !(i < nqueries) { + break + } + if **(**int32)(__ccgo_up(alens + uintptr(i)*4)) < 0 { + **(**int32)(__ccgo_up(alens + uintptr(i)*4)) = 0 + } + goto _22 + _22: + ; + i = i + 1 + } + return 0 +} + +func X__res_msend(tls *TLS, nqueries int32, queries uintptr, qlens uintptr, answers uintptr, alens uintptr, asize int32) (r int32) { + if __ccgo_strace { + trc("tls=%v nqueries=%v queries=%v qlens=%v answers=%v alens=%v asize=%v, (%v:)", tls, nqueries, queries, qlens, answers, alens, asize, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(112) + defer tls.Free(112) + var _ /* conf at bp+0 */ Tresolvconf + if X__get_resolv_conf(tls, bp, uintptr(0), uint64(0)) < 0 { + return -int32(1) + } + return X__res_msend_rc(tls, nqueries, queries, qlens, answers, alens, asize, bp) +} + +func X__res_send(tls *TLS, _msg uintptr, _msglen int32, _answer uintptr, _anslen int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v _msg=%v _msglen=%v _answer=%v _anslen=%v, (%v:)", tls, _msg, _msglen, _answer, _anslen, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(544) + defer tls.Free(544) + *(*uintptr)(unsafe.Pointer(bp)) = _msg + *(*int32)(unsafe.Pointer(bp + 8)) = _msglen + *(*uintptr)(unsafe.Pointer(bp + 16)) = _answer + *(*int32)(unsafe.Pointer(bp + 24)) = _anslen + var r, v1 int32 + var _ /* buf at bp+28 */ [512]uint8 + _, _ = r, v1 + if **(**int32)(__ccgo_up(bp + 24)) < int32(512) { + r = X__res_send(tls, **(**uintptr)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 8)), bp+28, int32(512)) + if r >= 0 { + if r < **(**int32)(__ccgo_up(bp + 24)) { + v1 = r + } else { + v1 = **(**int32)(__ccgo_up(bp + 24)) + } + Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp + 16)), bp+28, Uint64FromInt32(v1)) + } + return r + } + r = X__res_msend(tls, int32(1), bp, bp+8, bp+16, bp+24, **(**int32)(__ccgo_up(bp + 24))) + if r < 0 || !(**(**int32)(__ccgo_up(bp + 24)) != 0) { + v1 = -int32(1) + } else { + v1 = **(**int32)(__ccgo_up(bp + 24)) + } + return v1 +} + +func Xres_send(tls *TLS, _msg uintptr, _msglen int32, _answer uintptr, _anslen int32) (r int32) { + if __ccgo_strace { + trc("tls=%v _msg=%v _msglen=%v _answer=%v _anslen=%v, (%v:)", tls, _msg, _msglen, _answer, _anslen, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__res_send(tls, _msg, _msglen, _answer, _anslen) +} + +/* This is completely unused, and exists purely to satisfy broken apps. */ + +func X__res_state(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(unsafe.Pointer(&_res1)) +} + +var _res1 t__res_state + +func X__get_resolv_conf(tls *TLS, conf uintptr, search uintptr, search_sz Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v conf=%v search=%v search_sz=%v, (%v:)", tls, conf, search, search_sz, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(752) + defer tls.Free(752) + var c, nns, v1, v2 int32 + var f, p uintptr + var l Tsize_t + var x, x1, x2, v5 uint64 + var v4 bool + var _ /* _buf at bp+256 */ [256]uint8 + var _ /* _f at bp+512 */ TFILE + var _ /* line at bp+0 */ [256]uint8 + var _ /* z at bp+744 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _ = c, f, l, nns, p, x, x1, x2, v1, v2, v4, v5 + nns = 0 + (*Tresolvconf)(unsafe.Pointer(conf)).Fndots = uint32(1) + (*Tresolvconf)(unsafe.Pointer(conf)).Ftimeout = uint32(5) + (*Tresolvconf)(unsafe.Pointer(conf)).Fattempts = uint32(2) + if search != 0 { + **(**uint8)(__ccgo_up(search)) = uint8(0) + } + f = X__fopen_rb_ca(tls, __ccgo_ts+1149, bp+512, bp+256, uint64(256)) + if !(f != 0) { + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(ENOENT): + fallthrough + case int32(ENOTDIR): + fallthrough + case int32(EACCES): + goto no_resolv_conf + default: + return -int32(1) + } + } + for Xfgets(tls, bp, int32(256), f) != 0 { + if !(Xstrchr(tls, bp, int32('\n')) != 0) && !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_EOF) != 0) { + for cond := true; cond; cond = c != int32('\n') && c != -int32(1) { + c = Xgetc(tls, f) + } + continue + } + if v4 = !(Xstrncmp(tls, bp, __ccgo_ts+1166, uint64(7)) != 0); v4 { + v1 = Int32FromUint8((**(**[256]uint8)(__ccgo_up(bp)))[int32(7)]) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + } + if v4 && v2 != 0 { + p = Xstrstr(tls, bp, __ccgo_ts+1174) + if p != 0 && BoolInt32(uint32(**(**uint8)(__ccgo_up(p + 6)))-uint32('0') < uint32(10)) != 0 { + p = p + uintptr(6) + x = Xstrtoul(tls, p, bp+744, int32(10)) + if **(**uintptr)(__ccgo_up(bp + 744)) != p { + if x > uint64(15) { + v5 = uint64(15) + } else { + v5 = x + } + (*Tresolvconf)(unsafe.Pointer(conf)).Fndots = uint32(v5) + } + } + p = Xstrstr(tls, bp, __ccgo_ts+1181) + if p != 0 && BoolInt32(uint32(**(**uint8)(__ccgo_up(p + 9)))-uint32('0') < uint32(10)) != 0 { + p = p + uintptr(9) + x1 = Xstrtoul(tls, p, bp+744, int32(10)) + if **(**uintptr)(__ccgo_up(bp + 744)) != p { + if x1 > uint64(10) { + v5 = uint64(10) + } else { + v5 = x1 + } + (*Tresolvconf)(unsafe.Pointer(conf)).Fattempts = uint32(v5) + } + } + p = Xstrstr(tls, bp, __ccgo_ts+1191) + if p != 0 && (BoolInt32(uint32(**(**uint8)(__ccgo_up(p + 8)))-uint32('0') < uint32(10)) != 0 || Int32FromUint8(**(**uint8)(__ccgo_up(p + 8))) == int32('.')) { + p = p + uintptr(8) + x2 = Xstrtoul(tls, p, bp+744, int32(10)) + if **(**uintptr)(__ccgo_up(bp + 744)) != p { + if x2 > uint64(60) { + v5 = uint64(60) + } else { + v5 = x2 + } + (*Tresolvconf)(unsafe.Pointer(conf)).Ftimeout = uint32(v5) + } + } + continue + } + if v4 = !(Xstrncmp(tls, bp, __ccgo_ts+1200, uint64(10)) != 0); v4 { + v1 = Int32FromUint8((**(**[256]uint8)(__ccgo_up(bp)))[int32(10)]) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _10 + _10: + } + if v4 && v2 != 0 { + if nns >= int32(MAXNS) { + continue + } + p = bp + uintptr(11) + for { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _15 + _15: + if !(v2 != 0) { + break + } + goto _12 + _12: + ; + p = p + 1 + } + **(**uintptr)(__ccgo_up(bp + 744)) = p + for { + if v4 = **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 744)))) != 0; v4 { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 744))))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _19 + _19: + } + if !(v4 && !(v2 != 0)) { + break + } + goto _16 + _16: + ; + **(**uintptr)(__ccgo_up(bp + 744)) = **(**uintptr)(__ccgo_up(bp + 744)) + 1 + } + **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 744)))) = uint8(0) + if X__lookup_ipliteral(tls, conf+uintptr(nns)*28, p, PF_UNSPEC) > 0 { + nns = nns + 1 + } + continue + } + if !(search != 0) { + continue + } + if v4 = Xstrncmp(tls, bp, __ccgo_ts+1211, uint64(6)) != 0 && Xstrncmp(tls, bp, __ccgo_ts+1218, uint64(6)) != 0; !v4 { + v1 = Int32FromUint8((**(**[256]uint8)(__ccgo_up(bp)))[int32(6)]) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _23 + _23: + } + if v4 || !(v2 != 0) { + continue + } + p = bp + uintptr(7) + for { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _28 + _28: + if !(v2 != 0) { + break + } + goto _25 + _25: + ; + p = p + 1 + } + l = _strlen(tls, p) + /* This can never happen anyway with chosen buffer sizes. */ + if l >= search_sz { + continue + } + Xmemcpy(tls, search, p, l+uint64(1)) + } + X__fclose_ca(tls, f) + goto no_resolv_conf +no_resolv_conf: + ; + if !(nns != 0) { + X__lookup_ipliteral(tls, conf, __ccgo_ts+1225, PF_UNSPEC) + nns = int32(1) + } + (*Tresolvconf)(unsafe.Pointer(conf)).Fnns = Uint32FromInt32(nns) + return 0 +} + +func Xsend(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v flags=%v, (%v:)", tls, fd, buf, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsendto(tls, fd, buf, len1, flags, uintptr(0), uint32(0)) +} + +func Xsendmmsg(tls *TLS, fd int32, msgvec uintptr, vlen uint32, flags uint32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v msgvec=%v vlen=%v flags=%v, (%v:)", tls, fd, msgvec, vlen, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var i, v2 int32 + var r Tssize_t + _, _, _ = i, r, v2 + if vlen > uint32(IOV_MAX) { + vlen = uint32(IOV_MAX) + } /* This matches the kernel. */ + if !(vlen != 0) { + return 0 + } + i = 0 + for { + if !(Uint32FromInt32(i) < vlen) { + break + } + /* As an unfortunate inconsistency, the sendmmsg API uses + * unsigned int for the resulting msg_len, despite sendmsg + * returning ssize_t. However Linux limits the total bytes + * sent by sendmsg to INT_MAX, so the assignment is safe. */ + r = Xsendmsg(tls, fd, msgvec+uintptr(i)*64, Int32FromUint32(flags)) + if r < 0 { + goto error + } + (**(**Tmmsghdr)(__ccgo_up(msgvec + uintptr(i)*64))).Fmsg_len = Uint32FromInt64(r) + goto _1 + _1: + ; + i = i + 1 + } + goto error +error: + ; + if i != 0 { + v2 = i + } else { + v2 = -int32(1) + } + return v2 + return r1 +} + +func Xsendmsg(tls *TLS, fd int32, msg uintptr, flags int32) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v msg=%v flags=%v, (%v:)", tls, fd, msg, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(1120) + defer tls.Free(1120) + var c1, v3 uintptr + var r, v12 int64 + var v1 int32 + var v10, v11, v6, v7, v8, v9 Tsyscall_arg_t + var _ /* chbuf at bp+56 */ [66]Tcmsghdr + var _ /* h at bp+0 */ Tmsghdr + _, _, _, _, _, _, _, _, _, _, _ = c1, r, v1, v10, v11, v12, v3, v6, v7, v8, v9 + if msg != 0 { + **(**Tmsghdr)(__ccgo_up(bp)) = **(**Tmsghdr)(__ccgo_up(msg)) + v1 = Int32FromInt32(0) + (**(**Tmsghdr)(__ccgo_up(bp))).F__pad2 = v1 + (**(**Tmsghdr)(__ccgo_up(bp))).F__pad1 = v1 + msg = bp + if (**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_controllen != 0 { + if uint64((**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_controllen) > uint64(1056) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return int64(-int32(1)) + } + Xmemcpy(tls, bp+56, (**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_control, uint64((**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_controllen)) + (**(**Tmsghdr)(__ccgo_up(bp))).Fmsg_control = bp + 56 + if uint64((*Tmsghdr)(unsafe.Pointer(bp)).Fmsg_controllen) >= uint64(16) { + v3 = (*Tmsghdr)(unsafe.Pointer(bp)).Fmsg_control + } else { + v3 = UintptrFromInt32(0) + } + c1 = v3 + for { + if !(c1 != 0) { + break + } + (*Tcmsghdr)(unsafe.Pointer(c1)).F__pad1 = 0 + goto _2 + _2: + ; + if uint64((*Tcmsghdr)(unsafe.Pointer(c1)).Fcmsg_len) < uint64(16) || (uint64((*Tcmsghdr)(unsafe.Pointer(c1)).Fcmsg_len)+uint64(8)-uint64(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))+uint64(16) >= Uint64FromInt64(int64((*Tmsghdr)(unsafe.Pointer(bp)).Fmsg_control+uintptr((*Tmsghdr)(unsafe.Pointer(bp)).Fmsg_controllen))-int64(c1)) { + v3 = uintptr(0) + } else { + v3 = c1 + uintptr((uint64((*Tcmsghdr)(unsafe.Pointer(c1)).Fcmsg_len)+Uint64FromInt64(8)-Uint64FromInt32(1))&Uint64FromInt64(^Int64FromUint64(Uint64FromInt64(8)-Uint64FromInt32(1)))) + } + c1 = v3 + } + } + } + v1 = int32(SYS_sendmsg) + _ = int32(__SC_sendmsg) + v6 = int64(fd) + v7 = int64(msg) + v8 = int64(flags) + v9 = int64(Int32FromInt32(0)) + v10 = int64(Int32FromInt32(0)) + v11 = int64(Int32FromInt32(0)) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v6, v7, v8, v9, v10, v11) + } else { + r = X__syscall6(tls, int64(v1), v6, v7, v8, v9, v10, v11) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v12 = r + goto _13 + } + v12 = r + goto _13 +_13: + return X__syscall_ret(tls, Uint64FromInt64(v12)) +} + +func Xsendto(tls *TLS, fd int32, buf uintptr, len1 Tsize_t, flags int32, addr uintptr, alen Tsocklen_t) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v len1=%v flags=%v addr=%v alen=%v, (%v:)", tls, fd, buf, len1, flags, addr, alen, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_sendto) + _ = int32(__SC_sendto) + v2 = int64(fd) + v3 = int64(buf) + v4 = Int64FromUint64(len1) + v5 = int64(flags) + v6 = int64(addr) + v7 = Int64FromUint32(alen) + if int32(1) != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return X__syscall_ret(tls, Uint64FromInt64(v8)) +} + +func Xendservent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xsetservent(tls *TLS, stayopen int32) { + if __ccgo_strace { + trc("tls=%v stayopen=%v, (%v:)", tls, stayopen, origin(2)) + } +} + +func Xgetservent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xsetsockopt(tls *TLS, fd int32, level int32, optname int32, optval uintptr, optlen Tsocklen_t) (r2 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v level=%v optname=%v optval=%v optlen=%v, (%v:)", tls, fd, level, optname, optval, optlen, origin(2)) + defer func() { trc("-> %v", r2) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r, v8 int64 + var r1, v1 int32 + var s Ttime_t + var tv uintptr + var us Tsuseconds_t + var v10 uint64 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = r, r1, s, tv, us, v1, v10, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_setsockopt) + _ = int32(__SC_setsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(optval) + v6 = Int64FromUint32(optlen) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + r1 = int32(v8) + if r1 == -int32(ENOPROTOOPT) { + switch level { + case int32(SOL_SOCKET): + switch optname { + case int32(SO_RCVTIMEO): + fallthrough + case int32(SO_SNDTIMEO): + if true { + break + } + if uint64(optlen) < uint64(16) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + tv = optval + s = (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec + us = (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec + if !!((Uint64FromInt64(s)+Uint64FromUint64(0x80000000))>>Int32FromInt32(32) != 0) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } + if optname == int32(SO_RCVTIMEO) { + optname = int32(SO_RCVTIMEO_OLD) + } + if optname == int32(SO_SNDTIMEO) { + optname = int32(SO_SNDTIMEO_OLD) + } + if !((Uint64FromInt64(us)+Uint64FromUint64(0x80000000))>>Int32FromInt32(32) != 0) { + v10 = Uint64FromInt64(us) + } else { + v10 = uint64(0x7fffffff) + (0+Uint64FromInt64(us))>>int32(63) + } + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: s, + 1: int64(Int32FromUint64(v10)), + } + v1 = int32(SYS_setsockopt) + _ = int32(__SC_setsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(bp) + v6 = Int64FromUint64(Uint64FromInt32(2) * Uint64FromInt64(8)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _19 + } + v8 = r + goto _19 + _19: + r1 = int32(v8) + case int32(SO_TIMESTAMP): + fallthrough + case int32(SO_TIMESTAMPNS): + if true { + break + } + if optname == int32(SO_TIMESTAMP) { + optname = int32(SO_TIMESTAMP_OLD) + } + if optname == int32(SO_TIMESTAMPNS) { + optname = int32(SO_TIMESTAMPNS_OLD) + } + v1 = int32(SYS_setsockopt) + _ = int32(__SC_setsockopt) + v2 = int64(fd) + v3 = int64(level) + v4 = int64(optname) + v5 = int64(optval) + v6 = Int64FromUint32(optlen) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _28 + } + v8 = r + goto _28 + _28: + r1 = int32(v8) + break + } + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r1))) +} + +func Xshutdown(tls *TLS, fd int32, how int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v how=%v, (%v:)", tls, fd, how, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v8 int64 + var v1 int32 + var v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _ = r, v1, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_shutdown) + _ = int32(__SC_shutdown) + v2 = int64(fd) + v3 = int64(how) + v4 = int64(Int32FromInt32(0)) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + return int32(X__syscall_ret(tls, Uint64FromInt64(v8))) +} + +func Xsockatmark(tls *TLS, s int32) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* ret at bp+0 */ int32 + if Xioctl(tls, s, int32(SIOCATMARK), VaList(bp+16, bp)) < 0 { + return -int32(1) + } + return **(**int32)(__ccgo_up(bp)) +} + +func Xsocket(tls *TLS, domain int32, type1 int32, protocol int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v domain=%v type1=%v protocol=%v, (%v:)", tls, domain, type1, protocol, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v17, v8 int64 + var s, v1, v10 int32 + var v11, v12, v13, v14, v15, v16, v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = r, s, v1, v10, v11, v12, v13, v14, v15, v16, v17, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_socket) + _ = int32(__SC_socket) + v2 = int64(domain) + v3 = int64(type1) + v4 = int64(protocol) + v5 = int64(Int32FromInt32(0)) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + s = int32(v8) + if (s == -int32(EINVAL) || s == -int32(EPROTONOSUPPORT)) && type1&(Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK)) != 0 { + v10 = int32(SYS_socket) + _ = int32(__SC_socket) + v11 = int64(domain) + v12 = int64(type1 & ^(Int32FromInt32(SOCK_CLOEXEC) | Int32FromInt32(SOCK_NONBLOCK))) + v13 = int64(protocol) + v14 = int64(Int32FromInt32(0)) + v15 = int64(Int32FromInt32(0)) + v16 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v10), v11, v12, v13, v14, v15, v16) + } else { + r = X__syscall6(tls, int64(v10), v11, v12, v13, v14, v15, v16) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v17 = r + goto _18 + } + v17 = r + goto _18 + _18: + s = int32(v17) + if s < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(s))) + } + if type1&int32(SOCK_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(s), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if type1&int32(SOCK_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(s), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(s))) +} + +func Xsocketpair(tls *TLS, domain int32, type1 int32, protocol int32, fd uintptr) (r2 int32) { + if __ccgo_strace { + trc("tls=%v domain=%v type1=%v protocol=%v fd=%v, (%v:)", tls, domain, type1, protocol, fd, origin(2)) + defer func() { trc("-> %v", r2) }() + } + var r, v17, v8 int64 + var r1, v1, v10 int32 + var v11, v12, v13, v14, v15, v16, v2, v3, v4, v5, v6, v7 Tsyscall_arg_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = r, r1, v1, v10, v11, v12, v13, v14, v15, v16, v17, v2, v3, v4, v5, v6, v7, v8 + v1 = int32(SYS_socketpair) + _ = int32(__SC_socketpair) + v2 = int64(domain) + v3 = int64(type1) + v4 = int64(protocol) + v5 = int64(fd) + v6 = int64(Int32FromInt32(0)) + v7 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } else { + r = X__syscall6(tls, int64(v1), v2, v3, v4, v5, v6, v7) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v8 = r + goto _9 + } + v8 = r + goto _9 +_9: + r1 = int32(X__syscall_ret(tls, Uint64FromInt64(v8))) + if r1 < 0 && (**(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EINVAL) || **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EPROTONOSUPPORT)) && type1&(Int32FromInt32(SOCK_CLOEXEC)|Int32FromInt32(SOCK_NONBLOCK)) != 0 { + v10 = int32(SYS_socketpair) + _ = int32(__SC_socketpair) + v11 = int64(domain) + v12 = int64(type1 & ^(Int32FromInt32(SOCK_CLOEXEC) | Int32FromInt32(SOCK_NONBLOCK))) + v13 = int64(protocol) + v14 = int64(fd) + v15 = int64(Int32FromInt32(0)) + v16 = int64(Int32FromInt32(0)) + if 0 != 0 { + r = ___syscall_cp(tls, int64(v10), v11, v12, v13, v14, v15, v16) + } else { + r = X__syscall6(tls, int64(v10), v11, v12, v13, v14, v15, v16) + } + if r != int64(-Int32FromInt32(ENOSYS)) { + v17 = r + goto _18 + } + v17 = r + goto _18 + _18: + r1 = int32(X__syscall_ret(tls, Uint64FromInt64(v17))) + if r1 < 0 { + return r1 + } + if type1&int32(SOCK_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd))), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd + 1*4))), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if type1&int32(SOCK_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd))), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd + 1*4))), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + } + return r1 +} + +const SHADOW = "/etc/shadow" + +type Tgroup = struct { + Fgr_name uintptr + Fgr_passwd uintptr + Fgr_gid Tgid_t + Fgr_mem uintptr +} + +type Tspwd = struct { + Fsp_namp uintptr + Fsp_pwdp uintptr + Fsp_lstchg int64 + Fsp_min int64 + Fsp_max int64 + Fsp_warn int64 + Fsp_inact int64 + Fsp_expire int64 + Fsp_flag uint64 +} + +func Xfgetgrent(tls *TLS, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* nmem at bp+16 */ Tsize_t + var _ /* res at bp+0 */ uintptr + var _ /* size at bp+8 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**Tsize_t)(__ccgo_up(bp + 16)) = uint64(0) + X__getgrent_a(tls, f, uintptr(unsafe.Pointer(&_gr)), uintptr(unsafe.Pointer(&_line1)), bp+8, uintptr(unsafe.Pointer(&_mem)), bp+16, bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +var _line1 uintptr + +var _mem uintptr + +var _gr Tgroup + +func Xfgetpwent(tls *TLS, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+8 */ uintptr + var _ /* size at bp+0 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp)) = uint64(0) + X__getpwent_a(tls, f, uintptr(unsafe.Pointer(&_pw)), uintptr(unsafe.Pointer(&_line2)), bp, bp+8) + return **(**uintptr)(__ccgo_up(bp + 8)) +} + +var _line2 uintptr + +var _pw Tpasswd + +const GETGRBYGID = 3 +const GETGRBYNAME = 2 +const GETINITGR = 15 +const GETPWBYNAME = 0 +const GETPWBYUID = 1 +const GRFOUND = 1 +const GRGID = 4 +const GRMEMCNT = 5 +const GRNAMELEN = 2 +const GRPASSWDLEN = 3 +const GRVERSION = 0 +const GR_LEN = 6 +const INITGRFOUND = 1 +const INITGRNGRPS = 2 +const INITGRVERSION = 0 +const INITGR_LEN = 3 +const NSCDVERSION = 2 +const PWDIRLEN = 7 +const PWFOUND = 1 +const PWGECOSLEN = 6 +const PWGID = 5 +const PWNAMELEN = 2 +const PWPASSWDLEN = 3 +const PWSHELLLEN = 8 +const PWUID = 4 +const PWVERSION = 0 +const PW_LEN = 9 +const REQKEYLEN = 2 +const REQTYPE = 1 +const REQVERSION = 0 +const REQ_LEN = 3 + +func _itoa1(tls *TLS, p uintptr, x Tuint32_t) (r uintptr) { + var v1 uintptr + _ = v1 + // number of digits in a uint32_t + NUL + p = p + uintptr(11) + p = p - 1 + v1 = p + **(**uint8)(__ccgo_up(v1)) = uint8(0) + for cond := true; cond; cond = x != 0 { + p = p - 1 + v1 = p + **(**uint8)(__ccgo_up(v1)) = uint8(uint32('0') + x%uint32(10)) + x = x / uint32(10) + } + return p +} + +func X__getgr_a(tls *TLS, name uintptr, gid Tgid_t, gr uintptr, buf uintptr, size uintptr, mem uintptr, nmem uintptr, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v gid=%v gr=%v buf=%v size=%v mem=%v nmem=%v res=%v, (%v:)", tls, name, gid, gr, buf, size, mem, nmem, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(48) + defer tls.Free(48) + var f, key, ptr, tmp, tmp1 uintptr + var grlist_len, len1 Tsize_t + var i, req, v10 Tint32_t + var rv, v1 int32 + var v5, v6 Tuint32_t + var _ /* cs at bp+0 */ int32 + var _ /* gidbuf at bp+28 */ [11]uint8 + var _ /* groupbuf at bp+4 */ [6]Tint32_t + var _ /* name_len at bp+44 */ Tuint32_t + var _ /* swap at bp+40 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = f, grlist_len, i, key, len1, ptr, req, rv, tmp, tmp1, v1, v10, v5, v6 + rv = 0 + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp) + f = Xfopen(tls, __ccgo_ts+1235, __ccgo_ts+315) + if !(f != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto done + } + for { + v1 = X__getgrent_a(tls, f, gr, buf, size, mem, nmem, res) + rv = v1 + if !(!(v1 != 0) && **(**uintptr)(__ccgo_up(res)) != 0) { + break + } + if name != 0 && !(Xstrcmp(tls, name, (*Tgroup)(unsafe.Pointer(**(**uintptr)(__ccgo_up(res)))).Fgr_name) != 0) || !(name != 0) && (*Tgroup)(unsafe.Pointer(**(**uintptr)(__ccgo_up(res)))).Fgr_gid == gid { + break + } + } + Xfclose(tls, f) + if !(**(**uintptr)(__ccgo_up(res)) != 0) && (rv == 0 || rv == int32(ENOENT) || rv == int32(ENOTDIR)) { + if name != 0 { + v1 = int32(GETGRBYNAME) + } else { + v1 = int32(GETGRBYGID) + } + req = v1 + **(**[6]Tint32_t)(__ccgo_up(bp + 4)) = [6]Tint32_t{} + len1 = uint64(0) + grlist_len = uint64(0) + **(**[11]uint8)(__ccgo_up(bp + 28)) = [11]uint8{} + **(**int32)(__ccgo_up(bp + 40)) = 0 + if name != 0 { + key = name + } else { + if gid < uint32(0) || gid > uint32(0xffffffff) { + rv = 0 + goto done + } + key = _itoa1(tls, bp+28, gid) + } + f = X__nscd_query(tls, req, key, bp+4, uint64(24), bp+40) + if !(f != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto done + } + if !((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRFOUND)] != 0) { + rv = 0 + goto cleanup_f + } + if !((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)] != 0) || !((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)] != 0) { + rv = int32(EIO) + goto cleanup_f + } + if Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)]) > uint64(0xffffffffffffffff)-Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)]) { + rv = int32(ENOMEM) + goto cleanup_f + } + len1 = Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)] + (**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)]) + i = 0 + for { + if !(i < (**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)]) { + break + } + if Xfread(tls, bp+44, uint64(4), uint64(1), f) < uint64(1) { + if Xferror(tls, f) != 0 { + v1 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v1 = int32(EIO) + } + rv = v1 + goto cleanup_f + } + if **(**int32)(__ccgo_up(bp + 40)) != 0 { + v5 = **(**Tuint32_t)(__ccgo_up(bp + 44)) + v6 = v5>>int32(24) | v5>>int32(8)&uint32(0xff00) | v5< uint64(0xffffffffffffffff)-grlist_len || uint64(**(**Tuint32_t)(__ccgo_up(bp + 44))) > uint64(0xffffffffffffffff)-len1 { + rv = int32(ENOMEM) + goto cleanup_f + } + len1 = len1 + uint64(**(**Tuint32_t)(__ccgo_up(bp + 44))) + grlist_len = grlist_len + uint64(**(**Tuint32_t)(__ccgo_up(bp + 44))) + goto _3 + _3: + ; + i = i + 1 + } + if len1 > **(**Tsize_t)(__ccgo_up(size)) || !(**(**uintptr)(__ccgo_up(buf)) != 0) { + tmp = Xrealloc(tls, **(**uintptr)(__ccgo_up(buf)), len1) + if !(tmp != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(buf)) = tmp + **(**Tsize_t)(__ccgo_up(size)) = len1 + } + if !(Xfread(tls, **(**uintptr)(__ccgo_up(buf)), len1, uint64(1), f) != 0) { + if Xferror(tls, f) != 0 { + v1 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v1 = int32(EIO) + } + rv = v1 + goto cleanup_f + } + if Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)]+int32(1)) > **(**Tsize_t)(__ccgo_up(nmem)) { + if Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)]+int32(1)) > Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt64(8) { + rv = int32(ENOMEM) + goto cleanup_f + } + tmp1 = Xrealloc(tls, **(**uintptr)(__ccgo_up(mem)), Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)]+Int32FromInt32(1))*uint64(8)) + if !(tmp1 != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(mem)) = tmp1 + **(**Tsize_t)(__ccgo_up(nmem)) = Uint64FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)] + int32(1)) + } + if (**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)] != 0 { + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) = **(**uintptr)(__ccgo_up(buf)) + uintptr((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)]) + uintptr((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)]) + ptr = **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) + i = Int32FromInt32(0) + for { + if !(ptr != **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem))))+uintptr(grlist_len)) { + break + } + if !(**(**uint8)(__ccgo_up(ptr)) != 0) { + i = i + 1 + v10 = i + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)) + uintptr(v10)*8)) = ptr + uintptr(1) + } + goto _9 + _9: + ; + ptr = ptr + 1 + } + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)) + uintptr(i)*8)) = uintptr(0) + if i != (**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRMEMCNT)] { + rv = int32(EIO) + goto cleanup_f + } + } else { + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) = uintptr(0) + } + (*Tgroup)(unsafe.Pointer(gr)).Fgr_name = **(**uintptr)(__ccgo_up(buf)) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd = (*Tgroup)(unsafe.Pointer(gr)).Fgr_name + uintptr((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRNAMELEN)]) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_gid = Uint32FromInt32((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRGID)]) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_mem = **(**uintptr)(__ccgo_up(mem)) + if **(**uint8)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd + uintptr(-Int32FromInt32(1)))) != 0 || **(**uint8)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd + uintptr((**(**[6]Tint32_t)(__ccgo_up(bp + 4)))[int32(GRPASSWDLEN)]-int32(1)))) != 0 { + rv = int32(EIO) + goto cleanup_f + } + if name != 0 && Xstrcmp(tls, name, (*Tgroup)(unsafe.Pointer(gr)).Fgr_name) != 0 || !(name != 0) && gid != (*Tgroup)(unsafe.Pointer(gr)).Fgr_gid { + rv = int32(EIO) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(res)) = gr + goto cleanup_f + cleanup_f: + ; + Xfclose(tls, f) + goto done + } + goto done +done: + ; + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp)), uintptr(0)) + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func _getgr_r(tls *TLS, name uintptr, gid Tgid_t, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + bp := tls.Alloc(48) + defer tls.Free(48) + var i Tsize_t + var rv int32 + var _ /* cs at bp+32 */ int32 + var _ /* len at bp+8 */ Tsize_t + var _ /* line at bp+0 */ uintptr + var _ /* mem at bp+16 */ uintptr + var _ /* nmem at bp+24 */ Tsize_t + _, _ = i, rv + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) + **(**Tsize_t)(__ccgo_up(bp + 24)) = uint64(0) + rv = 0 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+32) + rv = X__getgr_a(tls, name, gid, gr, bp, bp+8, bp+16, bp+24, res) + if **(**uintptr)(__ccgo_up(res)) != 0 && size < **(**Tsize_t)(__ccgo_up(bp + 8))+(**(**Tsize_t)(__ccgo_up(bp + 24))+uint64(1))*uint64(8)+uint64(32) { + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + rv = int32(ERANGE) + } + if **(**uintptr)(__ccgo_up(res)) != 0 { + buf = buf + uintptr((uint64(16)-uint64(buf))%uint64(16)) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_mem = buf + buf = buf + uintptr((**(**Tsize_t)(__ccgo_up(bp + 24))+uint64(1))*uint64(8)) + Xmemcpy(tls, buf, **(**uintptr)(__ccgo_up(bp)), **(**Tsize_t)(__ccgo_up(bp + 8))) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_name = uintptr(int64((*Tgroup)(unsafe.Pointer(gr)).Fgr_name)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd = uintptr(int64((*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + i = uint64(0) + for { + if !(**(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 16)) + uintptr(i)*8)) != 0) { + break + } + **(**uintptr)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_mem + uintptr(i)*8)) = uintptr(int64(**(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 16)) + uintptr(i)*8)))-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + goto _1 + _1: + ; + i = i + 1 + } + **(**uintptr)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_mem + uintptr(i)*8)) = uintptr(0) + } + Xfree(tls, **(**uintptr)(__ccgo_up(bp + 16))) + Xfree(tls, **(**uintptr)(__ccgo_up(bp))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 32)), uintptr(0)) + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func Xgetgrnam_r(tls *TLS, name uintptr, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v gr=%v buf=%v size=%v res=%v, (%v:)", tls, name, gr, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _getgr_r(tls, name, uint32(0), gr, buf, size, res) +} + +func Xgetgrgid_r(tls *TLS, gid Tgid_t, gr uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v gid=%v gr=%v buf=%v size=%v res=%v, (%v:)", tls, gid, gr, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _getgr_r(tls, uintptr(0), gid, gr, buf, size, res) +} + +var _f1 uintptr +var _line3 uintptr +var _mem1 uintptr +var _gr1 Tgroup + +func Xsetgrent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + if _f1 != 0 { + Xfclose(tls, _f1) + } + _f1 = uintptr(0) +} + +func Xgetgrent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* nmem at bp+16 */ Tsize_t + var _ /* res at bp+0 */ uintptr + var _ /* size at bp+8 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**Tsize_t)(__ccgo_up(bp + 16)) = uint64(0) + if !(_f1 != 0) { + _f1 = Xfopen(tls, __ccgo_ts+1235, __ccgo_ts+315) + } + if !(_f1 != 0) { + return uintptr(0) + } + X__getgrent_a(tls, _f1, uintptr(unsafe.Pointer(&_gr1)), uintptr(unsafe.Pointer(&_line3)), bp+8, uintptr(unsafe.Pointer(&_mem1)), bp+16, bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xgetgrgid(tls *TLS, gid Tgid_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v gid=%v, (%v:)", tls, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* nmem at bp+16 */ Tsize_t + var _ /* res at bp+0 */ uintptr + var _ /* size at bp+8 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**Tsize_t)(__ccgo_up(bp + 16)) = uint64(0) + X__getgr_a(tls, uintptr(0), gid, uintptr(unsafe.Pointer(&_gr1)), uintptr(unsafe.Pointer(&_line3)), bp+8, uintptr(unsafe.Pointer(&_mem1)), bp+16, bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xgetgrnam(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* nmem at bp+16 */ Tsize_t + var _ /* res at bp+0 */ uintptr + var _ /* size at bp+8 */ Tsize_t + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + **(**Tsize_t)(__ccgo_up(bp + 16)) = uint64(0) + X__getgr_a(tls, name, uint32(0), uintptr(unsafe.Pointer(&_gr1)), uintptr(unsafe.Pointer(&_line3)), bp+8, uintptr(unsafe.Pointer(&_mem1)), bp+16, bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xendgrent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xsetgrent(tls) +} + +func _atou(tls *TLS, s uintptr) (r uint32) { + var x uint32 + _ = x + x = uint32(0) + for { + if !(Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-int32('0')) < uint32(10)) { + break + } + x = uint32(10)*x + Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-Int32FromUint8('0')) + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(s)) = **(**uintptr)(__ccgo_up(s)) + 1 + } + return x +} + +func X__getgrent_a(tls *TLS, f uintptr, gr uintptr, line uintptr, size uintptr, mem uintptr, nmem uintptr, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v gr=%v line=%v size=%v mem=%v nmem=%v res=%v, (%v:)", tls, f, gr, line, size, mem, nmem, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i, v13 Tsize_t + var l, v2 Tssize_t + var mems, v4 uintptr + var rv, v3 int32 + var _ /* cs at bp+8 */ int32 + var _ /* s at bp+0 */ uintptr + _, _, _, _, _, _, _, _ = i, l, mems, rv, v13, v2, v3, v4 + rv = 0 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+8) + for { + v2 = Xgetline(tls, line, size, f) + l = v2 + if v2 < 0 { + if Xferror(tls, f) != 0 { + v3 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v3 = 0 + } + rv = v3 + Xfree(tls, **(**uintptr)(__ccgo_up(line))) + **(**uintptr)(__ccgo_up(line)) = uintptr(0) + gr = uintptr(0) + goto end + } + **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(line)) + uintptr(l-int64(1)))) = uint8(0) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(line)) + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + (*Tgroup)(unsafe.Pointer(gr)).Fgr_name = v4 + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd = **(**uintptr)(__ccgo_up(bp)) + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + (*Tgroup)(unsafe.Pointer(gr)).Fgr_gid = _atou(tls, bp) + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(':') { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + mems = **(**uintptr)(__ccgo_up(bp)) + break + goto _1 + _1: + } + **(**Tsize_t)(__ccgo_up(nmem)) = BoolUint64(!!(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0)) + for { + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32(',') { + **(**Tsize_t)(__ccgo_up(nmem)) = **(**Tsize_t)(__ccgo_up(nmem)) + 1 + } + goto _10 + _10: + ; + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + Xfree(tls, **(**uintptr)(__ccgo_up(mem))) + **(**uintptr)(__ccgo_up(mem)) = Xcalloc(tls, uint64(8), **(**Tsize_t)(__ccgo_up(nmem))+uint64(1)) + if !(**(**uintptr)(__ccgo_up(mem)) != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + Xfree(tls, **(**uintptr)(__ccgo_up(line))) + **(**uintptr)(__ccgo_up(line)) = uintptr(0) + gr = uintptr(0) + goto end + } + if **(**uint8)(__ccgo_up(mems)) != 0 { + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) = mems + **(**uintptr)(__ccgo_up(bp)) = mems + i = Uint64FromInt32(0) + for { + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32(',') { + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + i = i + 1 + v13 = i + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)) + uintptr(v13)*8)) = **(**uintptr)(__ccgo_up(bp)) + } + goto _11 + _11: + ; + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + i = i + 1 + v13 = i + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)) + uintptr(v13)*8)) = uintptr(0) + } else { + **(**uintptr)(__ccgo_up(**(**uintptr)(__ccgo_up(mem)))) = uintptr(0) + } + (*Tgroup)(unsafe.Pointer(gr)).Fgr_mem = **(**uintptr)(__ccgo_up(mem)) + goto end +end: + ; + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 8)), uintptr(0)) + **(**uintptr)(__ccgo_up(res)) = gr + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func Xgetgrouplist(tls *TLS, user uintptr, gid Tgid_t, groups uintptr, ngroups uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v user=%v gid=%v groups=%v ngroups=%v, (%v:)", tls, user, gid, groups, ngroups, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(96) + defer tls.Free(96) + var f, nscdbuf, v1 uintptr + var i, n, v9 Tssize_t + var nbytes Tsize_t + var nlim, ret, rv, v6 int32 + var v14 int64 + var v3, v4 Tuint32_t + var _ /* buf at bp+56 */ uintptr + var _ /* gr at bp+0 */ Tgroup + var _ /* mem at bp+64 */ uintptr + var _ /* nmem at bp+72 */ Tsize_t + var _ /* res at bp+32 */ uintptr + var _ /* resp at bp+44 */ [3]Tint32_t + var _ /* size at bp+80 */ Tsize_t + var _ /* swap at bp+40 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = f, i, n, nbytes, nlim, nscdbuf, ret, rv, v1, v14, v3, v4, v6, v9 + ret = -int32(1) + n = int64(1) + **(**int32)(__ccgo_up(bp + 40)) = 0 + nscdbuf = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 56)) = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 64)) = uintptr(0) + **(**Tsize_t)(__ccgo_up(bp + 72)) = uint64(0) + nlim = **(**int32)(__ccgo_up(ngroups)) + if nlim >= int32(1) { + v1 = groups + groups += 4 + **(**Tgid_t)(__ccgo_up(v1)) = gid + } + f = X__nscd_query(tls, int32(GETINITGR), user, bp+44, uint64(12), bp+40) + if !(f != 0) { + goto cleanup + } + if (**(**[3]Tint32_t)(__ccgo_up(bp + 44)))[int32(INITGRFOUND)] != 0 { + nscdbuf = Xcalloc(tls, Uint64FromInt32((**(**[3]Tint32_t)(__ccgo_up(bp + 44)))[int32(INITGRNGRPS)]), uint64(4)) + if !(nscdbuf != 0) { + goto cleanup + } + nbytes = uint64(4) * Uint64FromInt32((**(**[3]Tint32_t)(__ccgo_up(bp + 44)))[int32(INITGRNGRPS)]) + if nbytes != 0 && !(Xfread(tls, nscdbuf, nbytes, uint64(1), f) != 0) { + if !(Xferror(tls, f) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EIO) + } + goto cleanup + } + if **(**int32)(__ccgo_up(bp + 40)) != 0 { + i = 0 + for { + if !(i < int64((**(**[3]Tint32_t)(__ccgo_up(bp + 44)))[int32(INITGRNGRPS)])) { + break + } + v3 = **(**Tuint32_t)(__ccgo_up(nscdbuf + uintptr(i)*4)) + v4 = v3>>int32(24) | v3>>int32(8)&uint32(0xff00) | v3< int64(nlim) { + v14 = int64(-int32(1)) + } else { + v14 = n + } + ret = int32(v14) + **(**int32)(__ccgo_up(ngroups)) = int32(n) + goto cleanup +cleanup: + ; + if f != 0 { + Xfclose(tls, f) + } + Xfree(tls, nscdbuf) + Xfree(tls, **(**uintptr)(__ccgo_up(bp + 56))) + Xfree(tls, **(**uintptr)(__ccgo_up(bp + 64))) + return ret +} + +func _itoa2(tls *TLS, p uintptr, x Tuint32_t) (r uintptr) { + var v1 uintptr + _ = v1 + // number of digits in a uint32_t + NUL + p = p + uintptr(11) + p = p - 1 + v1 = p + **(**uint8)(__ccgo_up(v1)) = uint8(0) + for cond := true; cond; cond = x != 0 { + p = p - 1 + v1 = p + **(**uint8)(__ccgo_up(v1)) = uint8(uint32('0') + x%uint32(10)) + x = x / uint32(10) + } + return p +} + +func X__getpw_a(tls *TLS, name uintptr, uid Tuid_t, pw uintptr, buf uintptr, size uintptr, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v uid=%v pw=%v buf=%v size=%v res=%v, (%v:)", tls, name, uid, pw, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var f, key, tmp uintptr + var len1 Tsize_t + var req Tint32_t + var rv, v1 int32 + var _ /* cs at bp+4 */ int32 + var _ /* passwdbuf at bp+8 */ [9]Tint32_t + var _ /* uidbuf at bp+44 */ [11]uint8 + _, _, _, _, _, _, _ = f, key, len1, req, rv, tmp, v1 + rv = 0 + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+4) + f = Xfopen(tls, __ccgo_ts+1246, __ccgo_ts+315) + if !(f != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto done + } + for { + v1 = X__getpwent_a(tls, f, pw, buf, size, res) + rv = v1 + if !(!(v1 != 0) && **(**uintptr)(__ccgo_up(res)) != 0) { + break + } + if name != 0 && !(Xstrcmp(tls, name, (*Tpasswd)(unsafe.Pointer(**(**uintptr)(__ccgo_up(res)))).Fpw_name) != 0) || !(name != 0) && (*Tpasswd)(unsafe.Pointer(**(**uintptr)(__ccgo_up(res)))).Fpw_uid == uid { + break + } + } + Xfclose(tls, f) + if !(**(**uintptr)(__ccgo_up(res)) != 0) && (rv == 0 || rv == int32(ENOENT) || rv == int32(ENOTDIR)) { + if name != 0 { + v1 = GETPWBYNAME + } else { + v1 = int32(GETPWBYUID) + } + req = v1 + **(**[9]Tint32_t)(__ccgo_up(bp + 8)) = [9]Tint32_t{} + len1 = uint64(0) + **(**[11]uint8)(__ccgo_up(bp + 44)) = [11]uint8{} + if name != 0 { + key = name + } else { + /* uid outside of this range can't be queried with the + * nscd interface, but might happen if uid_t ever + * happens to be a larger type (this is not true as of + * now) + */ + if uid < uint32(0) || uid > uint32(0xffffffff) { + rv = 0 + goto done + } + key = _itoa2(tls, bp+44, uid) + } + *(*[1]int32)(unsafe.Pointer(bp)) = [1]int32{} + f = X__nscd_query(tls, req, key, bp+8, uint64(36), bp) + if !(f != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto done + } + if !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWFOUND)] != 0) { + rv = 0 + goto cleanup_f + } + /* A zero length response from nscd is invalid. We ignore + * invalid responses and just report an error, rather than + * trying to do something with them. + */ + if !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWNAMELEN)] != 0) || !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWPASSWDLEN)] != 0) || !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGECOSLEN)] != 0) || !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWDIRLEN)] != 0) || !((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWSHELLLEN)] != 0) { + rv = int32(EIO) + goto cleanup_f + } + if Uint64FromInt32((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWNAMELEN)]|(**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWPASSWDLEN)]|(**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGECOSLEN)]|(**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWDIRLEN)]|(**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWSHELLLEN)]) >= Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt32(8) { + rv = int32(ENOMEM) + goto cleanup_f + } + len1 = Uint64FromInt32((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWNAMELEN)] + (**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWPASSWDLEN)] + (**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGECOSLEN)] + (**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWDIRLEN)] + (**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWSHELLLEN)]) + if len1 > **(**Tsize_t)(__ccgo_up(size)) || !(**(**uintptr)(__ccgo_up(buf)) != 0) { + tmp = Xrealloc(tls, **(**uintptr)(__ccgo_up(buf)), len1) + if !(tmp != 0) { + rv = **(**int32)(__ccgo_up(X__errno_location(tls))) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(buf)) = tmp + **(**Tsize_t)(__ccgo_up(size)) = len1 + } + if !(Xfread(tls, **(**uintptr)(__ccgo_up(buf)), len1, uint64(1), f) != 0) { + if Xferror(tls, f) != 0 { + v1 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v1 = int32(EIO) + } + rv = v1 + goto cleanup_f + } + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name = **(**uintptr)(__ccgo_up(buf)) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd = (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWNAMELEN)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos = (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWPASSWDLEN)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir = (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGECOSLEN)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell = (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWDIRLEN)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_uid = Uint32FromInt32((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWUID)]) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gid = Uint32FromInt32((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWGID)]) + /* Don't assume that nscd made sure to null terminate strings. + * It's supposed to, but malicious nscd should be ignored + * rather than causing a crash. + */ + if **(**uint8)(__ccgo_up((*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd + uintptr(-Int32FromInt32(1)))) != 0 || **(**uint8)(__ccgo_up((*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos + uintptr(-Int32FromInt32(1)))) != 0 || **(**uint8)(__ccgo_up((*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir + uintptr(-Int32FromInt32(1)))) != 0 || **(**uint8)(__ccgo_up((*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell + uintptr((**(**[9]Tint32_t)(__ccgo_up(bp + 8)))[int32(PWSHELLLEN)]-int32(1)))) != 0 { + rv = int32(EIO) + goto cleanup_f + } + if name != 0 && Xstrcmp(tls, name, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name) != 0 || !(name != 0) && uid != (*Tpasswd)(unsafe.Pointer(pw)).Fpw_uid { + rv = int32(EIO) + goto cleanup_f + } + **(**uintptr)(__ccgo_up(res)) = pw + goto cleanup_f + cleanup_f: + ; + Xfclose(tls, f) + goto done + } + goto done +done: + ; + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 4)), uintptr(0)) + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func _getpw_r(tls *TLS, name uintptr, uid Tuid_t, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var rv int32 + var _ /* cs at bp+16 */ int32 + var _ /* len at bp+8 */ Tsize_t + var _ /* line at bp+0 */ uintptr + _ = rv + **(**uintptr)(__ccgo_up(bp)) = uintptr(0) + **(**Tsize_t)(__ccgo_up(bp + 8)) = uint64(0) + rv = 0 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+16) + rv = X__getpw_a(tls, name, uid, pw, bp, bp+8, res) + if **(**uintptr)(__ccgo_up(res)) != 0 && size < **(**Tsize_t)(__ccgo_up(bp + 8)) { + **(**uintptr)(__ccgo_up(res)) = uintptr(0) + rv = int32(ERANGE) + } + if **(**uintptr)(__ccgo_up(res)) != 0 { + Xmemcpy(tls, buf, **(**uintptr)(__ccgo_up(bp)), **(**Tsize_t)(__ccgo_up(bp + 8))) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_name)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell = uintptr(int64((*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell)-int64(**(**uintptr)(__ccgo_up(bp)))) + buf + } + Xfree(tls, **(**uintptr)(__ccgo_up(bp))) + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 16)), uintptr(0)) + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func Xgetpwnam_r(tls *TLS, name uintptr, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v pw=%v buf=%v size=%v res=%v, (%v:)", tls, name, pw, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _getpw_r(tls, name, uint32(0), pw, buf, size, res) +} + +func Xgetpwuid_r(tls *TLS, uid Tuid_t, pw uintptr, buf uintptr, size Tsize_t, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v uid=%v pw=%v buf=%v size=%v res=%v, (%v:)", tls, uid, pw, buf, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _getpw_r(tls, uintptr(0), uid, pw, buf, size, res) +} + +var _f2 uintptr +var _line4 uintptr +var _pw1 Tpasswd +var _size Tsize_t + +func Xsetpwent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + if _f2 != 0 { + Xfclose(tls, _f2) + } + _f2 = uintptr(0) +} + +func Xgetpwent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+0 */ uintptr + if !(_f2 != 0) { + _f2 = Xfopen(tls, __ccgo_ts+1246, __ccgo_ts+315) + } + if !(_f2 != 0) { + return uintptr(0) + } + X__getpwent_a(tls, _f2, uintptr(unsafe.Pointer(&_pw1)), uintptr(unsafe.Pointer(&_line4)), uintptr(unsafe.Pointer(&_size)), bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xgetpwuid(tls *TLS, uid Tuid_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v uid=%v, (%v:)", tls, uid, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+0 */ uintptr + X__getpw_a(tls, uintptr(0), uid, uintptr(unsafe.Pointer(&_pw1)), uintptr(unsafe.Pointer(&_line4)), uintptr(unsafe.Pointer(&_size)), bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xgetpwnam(tls *TLS, name uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* res at bp+0 */ uintptr + X__getpw_a(tls, name, uint32(0), uintptr(unsafe.Pointer(&_pw1)), uintptr(unsafe.Pointer(&_line4)), uintptr(unsafe.Pointer(&_size)), bp) + return **(**uintptr)(__ccgo_up(bp)) +} + +func Xendpwent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xsetpwent(tls) +} + +func _atou1(tls *TLS, s uintptr) (r uint32) { + var x uint32 + _ = x + x = uint32(0) + for { + if !(Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-int32('0')) < uint32(10)) { + break + } + x = uint32(10)*x + Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-Int32FromUint8('0')) + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(s)) = **(**uintptr)(__ccgo_up(s)) + 1 + } + return x +} + +func X__getpwent_a(tls *TLS, f uintptr, pw uintptr, line uintptr, size uintptr, res uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v pw=%v line=%v size=%v res=%v, (%v:)", tls, f, pw, line, size, res, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var l, v2 Tssize_t + var rv, v3 int32 + var v4 uintptr + var _ /* cs at bp+8 */ int32 + var _ /* s at bp+0 */ uintptr + _, _, _, _, _ = l, rv, v2, v3, v4 + rv = 0 + _pthread_setcancelstate(tls, int32(PTHREAD_CANCEL_DISABLE), bp+8) + for { + v2 = Xgetline(tls, line, size, f) + l = v2 + if v2 < 0 { + if Xferror(tls, f) != 0 { + v3 = **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + v3 = 0 + } + rv = v3 + Xfree(tls, **(**uintptr)(__ccgo_up(line))) + **(**uintptr)(__ccgo_up(line)) = uintptr(0) + pw = uintptr(0) + break + } + **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(line)) + uintptr(l-int64(1)))) = uint8(0) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(line)) + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name = v4 + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd = **(**uintptr)(__ccgo_up(bp)) + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_uid = _atou1(tls, bp) + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(':') { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gid = _atou1(tls, bp) + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32(':') { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos = **(**uintptr)(__ccgo_up(bp)) + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir = **(**uintptr)(__ccgo_up(bp)) + v4 = Xstrchr(tls, **(**uintptr)(__ccgo_up(bp)), int32(':')) + **(**uintptr)(__ccgo_up(bp)) = v4 + if !(v4 != 0) { + goto _1 + } + v4 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + **(**uint8)(__ccgo_up(v4)) = uint8(0) + (*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell = **(**uintptr)(__ccgo_up(bp)) + break + goto _1 + _1: + } + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 8)), uintptr(0)) + **(**uintptr)(__ccgo_up(res)) = pw + if rv != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = rv + } + return rv +} + +func Xsetspent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xendspent(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xgetspent(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return uintptr(0) +} + +func Xlckpwdf(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xulckpwdf(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +var _addr = struct { + Fsun_family int16 + Fsun_path [21]uint8 +}{ + Fsun_family: int16(PF_LOCAL), + Fsun_path: [21]uint8{'/', 'v', 'a', 'r', '/', 'r', 'u', 'n', '/', 'n', 's', 'c', 'd', '/', 's', 'o', 'c', 'k', 'e', 't'}, +} + +func X__nscd_query(tls *TLS, req Tint32_t, key uintptr, buf uintptr, len1 Tsize_t, swap uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v req=%v key=%v buf=%v len1=%v swap=%v, (%v:)", tls, req, key, buf, len1, swap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(112) + defer tls.Free(112) + var errno_save, fd int32 + var f, v1 uintptr + var i Tsize_t + var v3, v4 Tuint32_t + var _ /* msg at bp+48 */ Tmsghdr + var _ /* req_buf at bp+32 */ [3]Tint32_t + _, _, _, _, _, _, _ = errno_save, f, fd, i, v1, v3, v4 + f = uintptr(0) + **(**[3]Tint32_t)(__ccgo_up(bp + 32)) = [3]Tint32_t{ + 0: int32(NSCDVERSION), + 1: req, + 2: Int32FromUint64(Xstrnlen(tls, key, uint64(LOGIN_NAME_MAX)) + uint64(1)), + } + *(*[2]Tiovec)(unsafe.Pointer(bp)) = [2]Tiovec{ + 0: { + Fiov_base: bp + 32, + Fiov_len: uint64(12), + }, + 1: { + Fiov_base: key, + Fiov_len: _strlen(tls, key) + uint64(1), + }, + } + **(**Tmsghdr)(__ccgo_up(bp + 48)) = Tmsghdr{ + Fmsg_iov: bp, + Fmsg_iovlen: int32(2), + } + errno_save = **(**int32)(__ccgo_up(X__errno_location(tls))) + **(**int32)(__ccgo_up(swap)) = 0 + goto retry +retry: + ; + Xmemset(tls, buf, 0, len1) + **(**Tint32_t)(__ccgo_up(buf)) = int32(NSCDVERSION) + fd = Xsocket(tls, int32(PF_LOCAL), Int32FromInt32(SOCK_STREAM)|Int32FromInt32(SOCK_CLOEXEC), 0) + if fd < 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EAFNOSUPPORT) { + f = Xfopen(tls, __ccgo_ts+1258, __ccgo_ts+1268) + if f != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = errno_save + } + return f + } + return uintptr(0) + } + v1 = Xfdopen(tls, fd, __ccgo_ts+1271) + f = v1 + if !(v1 != 0) { + Xclose(tls, fd) + return uintptr(0) + } + if (**(**[3]Tint32_t)(__ccgo_up(bp + 32)))[int32(2)] > int32(LOGIN_NAME_MAX) { + return f + } + if Xconnect(tls, fd, uintptr(unsafe.Pointer(&_addr)), uint32(24)) < 0 { + /* If there isn't a running nscd we simulate a "not found" + * result and the caller is responsible for calling + * fclose on the (unconnected) socket. The value of + * errno must be left unchanged in this case. */ + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EACCES) || **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ECONNREFUSED) || **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOENT) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = errno_save + return f + } + goto error + } + if Xsendmsg(tls, fd, bp+48, int32(MSG_NOSIGNAL)) < 0 { + goto error + } + if !(Xfread(tls, buf, len1, uint64(1), f) != 0) { + /* If the VERSION entry mismatches nscd will disconnect. The + * most likely cause is that the endianness mismatched. So, we + * byteswap and try once more. (if we already swapped, just + * fail out) + */ + if Xferror(tls, f) != 0 { + goto error + } + if !(**(**int32)(__ccgo_up(swap)) != 0) { + Xfclose(tls, f) + i = uint64(0) + for { + if !(i < Uint64FromInt64(12)/Uint64FromInt64(4)) { + break + } + v3 = Uint32FromInt32((**(**[3]Tint32_t)(__ccgo_up(bp + 32)))[i]) + v4 = v3>>int32(24) | v3>>int32(8)&uint32(0xff00) | v3<>int32(24) | v3>>int32(8)&uint32(0xff00) | v3< %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var i Tsize_t + var r, v1 int32 + var v4 uintptr + _, _, _, _ = i, r, v1, v4 + Xflockfile(tls, f) + v1 = Xfprintf(tls, f, __ccgo_ts+1273, VaList(bp+8, (*Tgroup)(unsafe.Pointer(gr)).Fgr_name, (*Tgroup)(unsafe.Pointer(gr)).Fgr_passwd, (*Tgroup)(unsafe.Pointer(gr)).Fgr_gid)) + r = v1 + if v1 < 0 { + goto done + } + if (*Tgroup)(unsafe.Pointer(gr)).Fgr_mem != 0 { + i = uint64(0) + for { + if !(**(**uintptr)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_mem + uintptr(i)*8)) != 0) { + break + } + if i != 0 { + v4 = __ccgo_ts + 1283 + } else { + v4 = __ccgo_ts + } + v1 = Xfprintf(tls, f, __ccgo_ts+1285, VaList(bp+8, v4, **(**uintptr)(__ccgo_up((*Tgroup)(unsafe.Pointer(gr)).Fgr_mem + uintptr(i)*8)))) + r = v1 + if v1 < 0 { + goto done + } + goto _2 + _2: + ; + i = i + 1 + } + } + r = Xfputc(tls, int32('\n'), f) + goto done +done: + ; + Xfunlockfile(tls, f) + if r < 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xputpwent(tls *TLS, pw uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v pw=%v f=%v, (%v:)", tls, pw, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var v1 int32 + _ = v1 + if Xfprintf(tls, f, __ccgo_ts+1290, VaList(bp+8, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_name, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_passwd, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_uid, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gid, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_gecos, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_dir, (*Tpasswd)(unsafe.Pointer(pw)).Fpw_shell)) < 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 +} + +func Xputspent(tls *TLS, sp uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v sp=%v f=%v, (%v:)", tls, sp, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(144) + defer tls.Free(144) + var v1, v10, v12, v14, v16, v4, v6, v8 int32 + var v11, v13, v15, v5, v7, v9 int64 + var v17 uint64 + var v2, v3 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = v1, v10, v11, v12, v13, v14, v15, v16, v17, v2, v3, v4, v5, v6, v7, v8, v9 + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_namp != 0 { + v2 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_namp + } else { + v2 = __ccgo_ts + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_pwdp != 0 { + v3 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_pwdp + } else { + v3 = __ccgo_ts + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_lstchg == int64(-int32(1)) { + v4 = 0 + } else { + v4 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_lstchg == int64(-int32(1)) { + v5 = 0 + } else { + v5 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_lstchg + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_min == int64(-int32(1)) { + v6 = 0 + } else { + v6 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_min == int64(-int32(1)) { + v7 = 0 + } else { + v7 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_min + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_max == int64(-int32(1)) { + v8 = 0 + } else { + v8 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_max == int64(-int32(1)) { + v9 = 0 + } else { + v9 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_max + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_warn == int64(-int32(1)) { + v10 = 0 + } else { + v10 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_warn == int64(-int32(1)) { + v11 = 0 + } else { + v11 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_warn + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_inact == int64(-int32(1)) { + v12 = 0 + } else { + v12 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_inact == int64(-int32(1)) { + v13 = 0 + } else { + v13 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_inact + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_expire == int64(-int32(1)) { + v14 = 0 + } else { + v14 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_expire == int64(-int32(1)) { + v15 = 0 + } else { + v15 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_expire + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_flag == Uint64FromInt32(-Int32FromInt32(1)) { + v16 = 0 + } else { + v16 = -int32(1) + } + if (*Tspwd)(unsafe.Pointer(sp)).Fsp_flag == Uint64FromInt32(-Int32FromInt32(1)) { + v17 = uint64(0) + } else { + v17 = (*Tspwd)(unsafe.Pointer(sp)).Fsp_flag + } + if Xfprintf(tls, f, __ccgo_ts+1312, VaList(bp+8, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)) < 0 { + v1 = -int32(1) + } else { + v1 = 0 + } + return v1 +} + +func X__rand48_step(tls *TLS, xi uintptr, lc uintptr) (r Tuint64_t) { + if __ccgo_strace { + trc("tls=%v xi=%v lc=%v, (%v:)", tls, xi, lc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, x Tuint64_t + _, _ = a, x + x = uint64(uint32(**(**uint16)(__ccgo_up(xi)))|(uint32(**(**uint16)(__ccgo_up(xi + 1*2)))+0)<> int32(16)) + **(**uint16)(__ccgo_up(xi + 2*2)) = uint16(x >> int32(32)) + return x & uint64(0xffffffffffff) +} + +func Xerand48(tls *TLS, s uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* x at bp+0 */ struct { + Ff [0]float64 + Fu Tuint64_t + } + *(*struct { + Ff [0]float64 + Fu Tuint64_t + })(unsafe.Pointer(bp)) = struct { + Ff [0]float64 + Fu Tuint64_t + }{} + *(*uint64)(unsafe.Pointer(bp)) = uint64(0x3ff0000000000000) | X__rand48_step(tls, s, uintptr(unsafe.Pointer(&X__seed48))+uintptr(3)*2)< %v", r) }() + } + return Xerand48(tls, uintptr(unsafe.Pointer(&X__seed48))) +} + +func Xlcong48(tls *TLS, p uintptr) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + } + Xmemcpy(tls, uintptr(unsafe.Pointer(&X__seed48)), p, uint64(14)) +} + +func Xnrand48(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(X__rand48_step(tls, s, uintptr(unsafe.Pointer(&X__seed48))+uintptr(3)*2) >> int32(17)) +} + +func Xlrand48(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xnrand48(tls, uintptr(unsafe.Pointer(&X__seed48))) +} + +func Xjrand48(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int64(Int32FromUint64(X__rand48_step(tls, s, uintptr(unsafe.Pointer(&X__seed48))+uintptr(3)*2) >> Int32FromInt32(16))) +} + +func Xmrand48(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xjrand48(tls, uintptr(unsafe.Pointer(&X__seed48))) +} + +var _seed Tuint64_t + +func Xsrand(tls *TLS, s uint32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + } + _seed = uint64(s - uint32(1)) +} + +func Xrand(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + _seed = uint64(6364136223846793005)*_seed + uint64(1) + return Int32FromUint64(_seed >> int32(33)) +} + +func _temper(tls *TLS, x uint32) (r uint32) { + x = x ^ x>>int32(11) + x = x ^ x<>int32(18) + return x +} + +func Xrand_r(tls *TLS, seed uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uint32 + _ = v1 + v1 = **(**uint32)(__ccgo_up(seed))*Uint32FromInt32(1103515245) + Uint32FromInt32(12345) + **(**uint32)(__ccgo_up(seed)) = v1 + return Int32FromUint32(_temper(tls, v1) / uint32(2)) +} + +/* +this code uses the same lagged fibonacci generator as the +original bsd random implementation except for the seeding +which was broken in the original +*/ + +var _init = [32]Tuint32_t{ + 1: uint32(0x5851f42d), + 2: uint32(0xc0b18ccf), + 3: uint32(0xcbb5f646), + 4: uint32(0xc7033129), + 5: uint32(0x30705b04), + 6: uint32(0x20fd5db4), + 7: uint32(0x9a8b7f78), + 8: uint32(0x502959d8), + 9: uint32(0xab894868), + 10: uint32(0x6c0356a7), + 11: uint32(0x88cdb7ff), + 12: uint32(0xb477d43f), + 13: uint32(0x70a3a52b), + 14: uint32(0xa8e4baf1), + 15: uint32(0xfd8341fc), + 16: uint32(0x8ae16fd9), + 17: uint32(0x742d2f7a), + 18: uint32(0x0d1f0796), + 19: uint32(0x76035e09), + 20: uint32(0x40f7702c), + 21: uint32(0x6fa72ca5), + 22: uint32(0xaaa84157), + 23: uint32(0x58a0df74), + 24: uint32(0xc74a0364), + 25: uint32(0xae533cc4), + 26: uint32(0x04185faf), + 27: uint32(0x6de3b115), + 28: uint32(0x0cab8628), + 29: uint32(0xf043bfa4), + 30: uint32(0x398150e9), + 31: uint32(0x37521657), +} + +var _n = int32(31) +var _i = int32(3) +var _j = int32(0) +var _x1 = uintptr(unsafe.Pointer(&_init)) + uintptr(1)*4 +var _lock3 [1]int32 + +func _lcg31(tls *TLS, x Tuint32_t) (r Tuint32_t) { + return (uint32(1103515245)*x + uint32(12345)) & uint32(0x7fffffff) +} + +func _lcg64(tls *TLS, x Tuint64_t) (r Tuint64_t) { + return uint64(6364136223846793005)*x + uint64(1) +} + +func _savestate(tls *TLS) (r uintptr) { + **(**Tuint32_t)(__ccgo_up(_x1 + uintptr(-Int32FromInt32(1))*4)) = Uint32FromInt32(_n<> int32(16)) + _i = Int32FromUint32(**(**Tuint32_t)(__ccgo_up(_x1 + uintptr(-Int32FromInt32(1))*4)) >> Int32FromInt32(8) & uint32(0xff)) + _j = Int32FromUint32(**(**Tuint32_t)(__ccgo_up(_x1 + uintptr(-Int32FromInt32(1))*4)) & uint32(0xff)) +} + +func ___srandom(tls *TLS, seed uint32) { + var k, v1 int32 + var s Tuint64_t + _, _, _ = k, s, v1 + s = uint64(seed) + if _n == 0 { + **(**Tuint32_t)(__ccgo_up(_x1)) = uint32(s) + return + } + if _n == int32(31) || _n == int32(7) { + v1 = int32(3) + } else { + v1 = int32(1) + } + _i = v1 + _j = 0 + k = 0 + for { + if !(k < _n) { + break + } + s = _lcg64(tls, s) + **(**Tuint32_t)(__ccgo_up(_x1 + uintptr(k)*4)) = uint32(s >> int32(32)) + goto _2 + _2: + ; + k = k + 1 + } + /* make sure x contains at least one odd number */ + **(**Tuint32_t)(__ccgo_up(_x1)) |= uint32(1) +} + +func Xsrandom(tls *TLS, seed uint32) { + if __ccgo_strace { + trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2)) + } + ___lock(tls, uintptr(unsafe.Pointer(&_lock3))) + ___srandom(tls, seed) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock3))) +} + +func Xinitstate(tls *TLS, seed uint32, state uintptr, size Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v seed=%v state=%v size=%v, (%v:)", tls, seed, state, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + var old uintptr + _ = old + if size < uint64(8) { + return uintptr(0) + } + ___lock(tls, uintptr(unsafe.Pointer(&_lock3))) + old = _savestate(tls) + if size < uint64(32) { + _n = 0 + } else { + if size < uint64(64) { + _n = int32(7) + } else { + if size < uint64(128) { + _n = int32(15) + } else { + if size < uint64(256) { + _n = int32(31) + } else { + _n = int32(63) + } + } + } + } + _x1 = state + uintptr(1)*4 + ___srandom(tls, seed) + _savestate(tls) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock3))) + return old +} + +func Xsetstate(tls *TLS, state uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v state=%v, (%v:)", tls, state, origin(2)) + defer func() { trc("-> %v", r) }() + } + var old uintptr + _ = old + ___lock(tls, uintptr(unsafe.Pointer(&_lock3))) + old = _savestate(tls) + _loadstate(tls, state) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock3))) + return old +} + +func Xrandom(tls *TLS) (r int64) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k int64 + var v1 Tuint32_t + var v2 int32 + _, _, _ = k, v1, v2 + ___lock(tls, uintptr(unsafe.Pointer(&_lock3))) + if _n == 0 { + v1 = _lcg31(tls, **(**Tuint32_t)(__ccgo_up(_x1))) + **(**Tuint32_t)(__ccgo_up(_x1)) = v1 + k = Int64FromUint32(v1) + goto end + } + **(**Tuint32_t)(__ccgo_up(_x1 + uintptr(_i)*4)) += **(**Tuint32_t)(__ccgo_up(_x1 + uintptr(_j)*4)) + k = Int64FromUint32(**(**Tuint32_t)(__ccgo_up(_x1 + uintptr(_i)*4)) >> int32(1)) + _i = _i + 1 + v2 = _i + if v2 == _n { + _i = 0 + } + _j = _j + 1 + v2 = _j + if v2 == _n { + _j = 0 + } + goto end +end: + ; + ___unlock(tls, uintptr(unsafe.Pointer(&_lock3))) + return k +} + +func Xseed48(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + Xmemcpy(tls, uintptr(unsafe.Pointer(&_p1)), uintptr(unsafe.Pointer(&X__seed48)), uint64(6)) + Xmemcpy(tls, uintptr(unsafe.Pointer(&X__seed48)), s, uint64(6)) + return uintptr(unsafe.Pointer(&_p1)) +} + +var _p1 [3]uint16 + +func Xsrand48(tls *TLS, seed int64) { + if __ccgo_strace { + trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*[3]uint16)(unsafe.Pointer(bp)) = [3]uint16{ + 0: uint16(0x330e), + 1: Uint16FromInt64(seed), + 2: Uint16FromInt64(seed >> int32(16)), + } + Xseed48(tls, bp) +} + +func Xexecl(tls *TLS, path uintptr, argv0 uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v argv0=%v va=%v, (%v:)", tls, path, argv0, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var argc, i int32 + var argv uintptr + var v2 t__predefined_size_t + _, _, _, _, _ = ap, argc, argv, i, v2 + defer func() { Xrealloc(tls, argv, 0) }() + ap = va + argc = int32(1) + for { + if !(VaUintptr(&ap) != 0) { + break + } + goto _1 + _1: + ; + argc = argc + 1 + } + _ = ap + v2 = Uint64FromInt32(argc+int32(1)) * 8 + argv = Xrealloc(tls, argv, v2) + ap = va + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), 0*8)) = argv0 + i = int32(1) + for { + if !(i < argc) { + break + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = VaUintptr(&ap) + goto _3 + _3: + ; + i = i + 1 + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = UintptrFromInt32(0) + _ = ap + return Xexecv(tls, path, argv) + return r +} + +func Xexecle(tls *TLS, path uintptr, argv0 uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v argv0=%v va=%v, (%v:)", tls, path, argv0, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var argc, i int32 + var argv, envp uintptr + var v2 t__predefined_size_t + _, _, _, _, _, _ = ap, argc, argv, envp, i, v2 + defer func() { Xrealloc(tls, argv, 0) }() + ap = va + argc = int32(1) + for { + if !(VaUintptr(&ap) != 0) { + break + } + goto _1 + _1: + ; + argc = argc + 1 + } + _ = ap + v2 = Uint64FromInt32(argc+int32(1)) * 8 + argv = Xrealloc(tls, argv, v2) + ap = va + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), 0*8)) = argv0 + i = int32(1) + for { + if !(i <= argc) { + break + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = VaUintptr(&ap) + goto _3 + _3: + ; + i = i + 1 + } + envp = VaUintptr(&ap) + _ = ap + return Xexecve(tls, path, argv, envp) + return r +} + +func Xexeclp(tls *TLS, file uintptr, argv0 uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v file=%v argv0=%v va=%v, (%v:)", tls, file, argv0, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var argc, i int32 + var argv uintptr + var v2 t__predefined_size_t + _, _, _, _, _ = ap, argc, argv, i, v2 + defer func() { Xrealloc(tls, argv, 0) }() + ap = va + argc = int32(1) + for { + if !(VaUintptr(&ap) != 0) { + break + } + goto _1 + _1: + ; + argc = argc + 1 + } + _ = ap + v2 = Uint64FromInt32(argc+int32(1)) * 8 + argv = Xrealloc(tls, argv, v2) + ap = va + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), 0*8)) = argv0 + i = int32(1) + for { + if !(i < argc) { + break + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = VaUintptr(&ap) + goto _3 + _3: + ; + i = i + 1 + } + *(*uintptr)(unsafe.Add(unsafe.Pointer(argv), i*8)) = UintptrFromInt32(0) + _ = ap + return Xexecvp(tls, file, argv) + return r +} + +func Xexecv(tls *TLS, path uintptr, argv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v argv=%v, (%v:)", tls, path, argv, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexecve(tls, path, argv, Xenviron) +} + +func Xexecve(tls *TLS, path uintptr, argv uintptr, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v argv=%v envp=%v, (%v:)", tls, path, argv, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* do we need to use environ if envp is null? */ + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_execve), int64(path), int64(argv), int64(envp))))) +} + +func X__execvpe(tls *TLS, file uintptr, argv uintptr, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v file=%v argv=%v envp=%v, (%v:)", tls, file, argv, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var b, p, path, z, v3 uintptr + var k, l Tsize_t + var seen_eacces int32 + var v2 t__predefined_size_t + _, _, _, _, _, _, _, _, _ = b, k, l, p, path, seen_eacces, z, v2, v3 + defer func() { Xrealloc(tls, b, 0) }() + path = Xgetenv(tls, __ccgo_ts+1361) + seen_eacces = 0 + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + if !(**(**uint8)(__ccgo_up(file)) != 0) { + return -int32(1) + } + if Xstrchr(tls, file, int32('/')) != 0 { + return Xexecve(tls, file, argv, envp) + } + if !(path != 0) { + path = __ccgo_ts + 1366 + } + k = Xstrnlen(tls, file, Uint64FromInt32(Int32FromInt32(NAME_MAX)+Int32FromInt32(1))) + if k > uint64(NAME_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return -int32(1) + } + l = Xstrnlen(tls, path, Uint64FromInt32(Int32FromInt32(PATH_MAX)-Int32FromInt32(1))) + uint64(1) + p = path + for { + v2 = l + k + uint64(1) + b = Xrealloc(tls, b, v2) + z = X__strchrnul(tls, p, int32(':')) + if Uint64FromInt64(int64(z)-int64(p)) >= l { + v3 = z + z = z + 1 + if !(**(**uint8)(__ccgo_up(v3)) != 0) { + break + } + goto _1 + } + Xmemcpy(tls, b, p, Uint64FromInt64(int64(z)-int64(p))) + *(*uint8)(unsafe.Add(unsafe.Pointer(b), int64(z)-int64(p))) = uint8('/') + Xmemcpy(tls, b+uintptr(int64(z)-int64(p))+BoolUintptr(z > p), file, k+uint64(1)) + Xexecve(tls, b, argv, envp) + switch **(**int32)(__ccgo_up(X__errno_location(tls))) { + case int32(EACCES): + seen_eacces = int32(1) + fallthrough + case int32(ENOENT): + fallthrough + case int32(ENOTDIR): + default: + return -int32(1) + } + v3 = z + z = z + 1 + if !(**(**uint8)(__ccgo_up(v3)) != 0) { + break + } + goto _1 + _1: + ; + p = z + } + if seen_eacces != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EACCES) + } + return -int32(1) +} + +func Xexecvp(tls *TLS, file uintptr, argv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v file=%v argv=%v, (%v:)", tls, file, argv, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__execvpe(tls, file, argv, Xenviron) +} + +func Xexecvpe(tls *TLS, file uintptr, argv uintptr, envp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v file=%v argv=%v envp=%v, (%v:)", tls, file, argv, envp, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__execvpe(tls, file, argv, envp) +} + +func Xfexecve(tls *TLS, fd int32, argv uintptr, envp uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v argv=%v envp=%v, (%v:)", tls, fd, argv, envp, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var r int32 + var _ /* buf at bp+0 */ [27]uint8 + _ = r + r = int32(X__syscall5(tls, int64(SYS_execveat), int64(fd), int64(__ccgo_ts), int64(argv), int64(envp), int64(Int32FromInt32(AT_EMPTY_PATH)))) + if r != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + X__procfdname(tls, bp, Uint32FromInt32(fd)) + Xexecve(tls, bp, argv, envp) + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOENT) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EBADF) + } + return -int32(1) +} + +var _dummy_lockptr = uintptr(0) + +var _atfork_locks = [10]uintptr{ + 0: uintptr(unsafe.Pointer(&X__at_quick_exit_lockptr)), + 1: uintptr(unsafe.Pointer(&_dummy_lockptr)), + 2: uintptr(unsafe.Pointer(&X__gettext_lockptr)), + 3: uintptr(unsafe.Pointer(&X__locale_lockptr)), + 4: uintptr(unsafe.Pointer(&X__random_lockptr)), + 5: uintptr(unsafe.Pointer(&_dummy_lockptr)), + 6: uintptr(unsafe.Pointer(&X__stdio_ofl_lockptr)), + 7: uintptr(unsafe.Pointer(&X__syslog_lockptr)), + 8: uintptr(unsafe.Pointer(&X__timezone_lockptr)), + 9: uintptr(unsafe.Pointer(&_dummy_lockptr)), +} + +func _dummy8(tls *TLS, x int32) { +} + +func _dummy_0(tls *TLS) { +} + +const FDOP_CHDIR = 4 +const FDOP_CLOSE = 1 +const FDOP_DUP2 = 2 +const FDOP_FCHDIR = 5 +const FDOP_OPEN = 3 +const POSIX_SPAWN_RESETIDS = 1 +const POSIX_SPAWN_SETPGROUP = 2 +const POSIX_SPAWN_SETSCHEDPARAM = 16 +const POSIX_SPAWN_SETSCHEDULER = 32 +const POSIX_SPAWN_SETSID = 128 +const POSIX_SPAWN_SETSIGDEF = 4 +const POSIX_SPAWN_SETSIGMASK = 8 +const POSIX_SPAWN_USEVFORK = 64 + +type Tposix_spawnattr_t = struct { + F__flags int32 + F__pgrp Tpid_t + F__def Tsigset_t + F__mask Tsigset_t + F__prio int32 + F__pol int32 + F__fn uintptr + F__pad [56]uint8 +} + +type Tposix_spawn_file_actions_t = struct { + F__pad0 [2]int32 + F__actions uintptr + F__pad [16]int32 +} + +type Tfdop = struct { + Fnext uintptr + Fprev uintptr + Fcmd int32 + Ffd int32 + Fsrcfd int32 + Foflag int32 + Fmode Tmode_t +} + +func Xposix_spawn_file_actions_addchdir_np(tls *TLS, fa uintptr, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v path=%v, (%v:)", tls, fa, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + op = Xmalloc(tls, uint64(40)+_strlen(tls, path)+uint64(1)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_CHDIR) + (*Tfdop)(unsafe.Pointer(op)).Ffd = -int32(1) + Xstrcpy(tls, op+36, path) + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_addclose(tls *TLS, fa uintptr, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v fd=%v, (%v:)", tls, fa, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + if fd < 0 { + return int32(EBADF) + } + op = Xmalloc(tls, uint64(40)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_CLOSE) + (*Tfdop)(unsafe.Pointer(op)).Ffd = fd + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_adddup2(tls *TLS, fa uintptr, srcfd int32, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v srcfd=%v fd=%v, (%v:)", tls, fa, srcfd, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + if srcfd < 0 || fd < 0 { + return int32(EBADF) + } + op = Xmalloc(tls, uint64(40)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_DUP2) + (*Tfdop)(unsafe.Pointer(op)).Fsrcfd = srcfd + (*Tfdop)(unsafe.Pointer(op)).Ffd = fd + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_addfchdir_np(tls *TLS, fa uintptr, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v fd=%v, (%v:)", tls, fa, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + if fd < 0 { + return int32(EBADF) + } + op = Xmalloc(tls, uint64(40)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_FCHDIR) + (*Tfdop)(unsafe.Pointer(op)).Ffd = fd + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_addopen(tls *TLS, fa uintptr, fd int32, path uintptr, flags int32, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v fd=%v path=%v flags=%v mode=%v, (%v:)", tls, fa, fd, path, flags, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var op, v1 uintptr + _, _ = op, v1 + if fd < 0 { + return int32(EBADF) + } + op = Xmalloc(tls, uint64(40)+_strlen(tls, path)+uint64(1)) + if !(op != 0) { + return int32(ENOMEM) + } + (*Tfdop)(unsafe.Pointer(op)).Fcmd = int32(FDOP_OPEN) + (*Tfdop)(unsafe.Pointer(op)).Ffd = fd + (*Tfdop)(unsafe.Pointer(op)).Foflag = flags + (*Tfdop)(unsafe.Pointer(op)).Fmode = mode + Xstrcpy(tls, op+36, path) + v1 = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + (*Tfdop)(unsafe.Pointer(op)).Fnext = v1 + if v1 != 0 { + (*Tfdop)(unsafe.Pointer((*Tfdop)(unsafe.Pointer(op)).Fnext)).Fprev = op + } + (*Tfdop)(unsafe.Pointer(op)).Fprev = uintptr(0) + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = op + return 0 +} + +func Xposix_spawn_file_actions_destroy(tls *TLS, fa uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v, (%v:)", tls, fa, origin(2)) + defer func() { trc("-> %v", r) }() + } + var next, op uintptr + _, _ = next, op + op = (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions + for op != 0 { + next = (*Tfdop)(unsafe.Pointer(op)).Fnext + Xfree(tls, op) + op = next + } + return 0 +} + +func Xposix_spawn_file_actions_init(tls *TLS, fa uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fa=%v, (%v:)", tls, fa, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*Tposix_spawn_file_actions_t)(unsafe.Pointer(fa)).F__actions = uintptr(0) + return 0 +} + +func Xposix_spawnattr_destroy(tls *TLS, attr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v, (%v:)", tls, attr, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func Xposix_spawnattr_getflags(tls *TLS, attr uintptr, flags uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v flags=%v, (%v:)", tls, attr, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**int16)(__ccgo_up(flags)) = int16((*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__flags) + return 0 +} + +func Xposix_spawnattr_getpgroup(tls *TLS, attr uintptr, pgrp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v pgrp=%v, (%v:)", tls, attr, pgrp, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tpid_t)(__ccgo_up(pgrp)) = (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__pgrp + return 0 +} + +func Xposix_spawnattr_getsigdefault(tls *TLS, attr uintptr, def uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v def=%v, (%v:)", tls, attr, def, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tsigset_t)(__ccgo_up(def)) = (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__def + return 0 +} + +func Xposix_spawnattr_getsigmask(tls *TLS, attr uintptr, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v mask=%v, (%v:)", tls, attr, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tsigset_t)(__ccgo_up(mask)) = (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__mask + return 0 +} + +func Xposix_spawnattr_init(tls *TLS, attr uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v, (%v:)", tls, attr, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tposix_spawnattr_t)(__ccgo_up(attr)) = Tposix_spawnattr_t{} + return 0 +} + +func Xposix_spawnattr_getschedparam(tls *TLS, attr uintptr, schedparam uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v schedparam=%v, (%v:)", tls, attr, schedparam, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(ENOSYS) +} + +func Xposix_spawnattr_setschedparam(tls *TLS, attr uintptr, schedparam uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v schedparam=%v, (%v:)", tls, attr, schedparam, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(ENOSYS) +} + +func Xposix_spawnattr_getschedpolicy(tls *TLS, attr uintptr, policy uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v policy=%v, (%v:)", tls, attr, policy, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(ENOSYS) +} + +func Xposix_spawnattr_setschedpolicy(tls *TLS, attr uintptr, policy int32) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v policy=%v, (%v:)", tls, attr, policy, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(ENOSYS) +} + +func Xposix_spawnattr_setflags(tls *TLS, attr uintptr, flags int16) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v flags=%v, (%v:)", tls, attr, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + var all_flags uint32 + _ = all_flags + all_flags = Uint32FromInt32(Int32FromInt32(POSIX_SPAWN_RESETIDS) | Int32FromInt32(POSIX_SPAWN_SETPGROUP) | Int32FromInt32(POSIX_SPAWN_SETSIGDEF) | Int32FromInt32(POSIX_SPAWN_SETSIGMASK) | Int32FromInt32(POSIX_SPAWN_SETSCHEDPARAM) | Int32FromInt32(POSIX_SPAWN_SETSCHEDULER) | Int32FromInt32(POSIX_SPAWN_USEVFORK) | Int32FromInt32(POSIX_SPAWN_SETSID)) + if Uint32FromInt16(flags) & ^all_flags != 0 { + return int32(EINVAL) + } + (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__flags = int32(flags) + return 0 +} + +func Xposix_spawnattr_setpgroup(tls *TLS, attr uintptr, pgrp Tpid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v pgrp=%v, (%v:)", tls, attr, pgrp, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__pgrp = pgrp + return 0 +} + +func Xposix_spawnattr_setsigdefault(tls *TLS, attr uintptr, def uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v def=%v, (%v:)", tls, attr, def, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__def = **(**Tsigset_t)(__ccgo_up(def)) + return 0 +} + +func Xposix_spawnattr_setsigmask(tls *TLS, attr uintptr, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v attr=%v mask=%v, (%v:)", tls, attr, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*Tposix_spawnattr_t)(unsafe.Pointer(attr)).F__mask = **(**Tsigset_t)(__ccgo_up(mask)) + return 0 +} + +func Xvfork(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* vfork syscall cannot be made from C code */ + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_clone), int64(Int32FromInt32(SIGCHLD)), int64(Int32FromInt32(0)))))) +} + +func Xwait(tls *TLS, status uintptr) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v status=%v, (%v:)", tls, status, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwaitpid(tls, -Int32FromInt32(1), status, 0) +} + +func Xwaitid(tls *TLS, type1 Tidtype_t, id Tid_t, info uintptr, options int32) (r int32) { + if __ccgo_strace { + trc("tls=%v type1=%v id=%v info=%v options=%v, (%v:)", tls, type1, id, info, options, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_waitid), int64(type1), Int64FromUint32(id), int64(info), int64(options), int64(Int32FromInt32(0)), 0)))) +} + +func Xwaitpid(tls *TLS, pid Tpid_t, status uintptr, options int32) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v pid=%v status=%v options=%v, (%v:)", tls, pid, status, options, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_wait4), int64(pid), int64(status), int64(options), int64(Int32FromInt32(0)), 0, 0)))) +} + +const BRACKET = -3 +const END = 0 +const FNM_CASEFOLD = 16 +const FNM_FILE_NAME = 1 +const FNM_LEADING_DIR = 8 +const FNM_NOESCAPE = 2 +const FNM_NOMATCH = 1 +const FNM_NOSYS = -1 +const FNM_PATHNAME = 1 +const FNM_PERIOD = 4 +const QUESTION = -4 +const STAR = -5 +const UNMATCHABLE = -2 + +func _str_next(tls *TLS, str uintptr, n Tsize_t, step uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var k int32 + var _ /* wc at bp+0 */ Twchar_t + _ = k + if !(n != 0) { + **(**Tsize_t)(__ccgo_up(step)) = uint64(0) + return 0 + } + if uint32(**(**uint8)(__ccgo_up(str))) >= uint32(128) { + k = Xmbtowc(tls, bp, str, n) + if k < 0 { + **(**Tsize_t)(__ccgo_up(step)) = uint64(1) + return -int32(1) + } + **(**Tsize_t)(__ccgo_up(step)) = Uint64FromInt32(k) + return Int32FromUint32(**(**Twchar_t)(__ccgo_up(bp))) + } + **(**Tsize_t)(__ccgo_up(step)) = uint64(1) + return Int32FromUint8(**(**uint8)(__ccgo_up(str))) +} + +func _pat_next(tls *TLS, pat uintptr, m Tsize_t, step uintptr, flags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var esc, k1, z int32 + var k Tsize_t + var _ /* wc at bp+0 */ Twchar_t + _, _, _, _ = esc, k, k1, z + esc = 0 + if !(m != 0) || !(**(**uint8)(__ccgo_up(pat)) != 0) { + **(**Tsize_t)(__ccgo_up(step)) = uint64(0) + return END + } + **(**Tsize_t)(__ccgo_up(step)) = uint64(1) + if Int32FromUint8(**(**uint8)(__ccgo_up(pat))) == int32('\\') && **(**uint8)(__ccgo_up(pat + 1)) != 0 && !(flags&Int32FromInt32(FNM_NOESCAPE) != 0) { + **(**Tsize_t)(__ccgo_up(step)) = uint64(2) + pat = pat + 1 + esc = int32(1) + goto escaped + } + if Int32FromUint8(**(**uint8)(__ccgo_up(pat))) == int32('[') { + k = uint64(1) + if k < m { + if Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k)))) == int32('^') || Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k)))) == int32('!') { + k = k + 1 + } + } + if k < m { + if Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k)))) == int32(']') { + k = k + 1 + } + } + for { + if !(k < m && **(**uint8)(__ccgo_up(pat + uintptr(k))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k)))) != int32(']')) { + break + } + if k+uint64(1) < m && **(**uint8)(__ccgo_up(pat + uintptr(k+uint64(1)))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k)))) == int32('[') && (Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k+uint64(1))))) == int32(':') || Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k+uint64(1))))) == int32('.') || Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k+uint64(1))))) == int32('=')) { + z = Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k+uint64(1))))) + k = k + uint64(2) + if k < m && **(**uint8)(__ccgo_up(pat + uintptr(k))) != 0 { + k = k + 1 + } + for k < m && **(**uint8)(__ccgo_up(pat + uintptr(k))) != 0 && (Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k-uint64(1))))) != z || Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(k)))) != int32(']')) { + k = k + 1 + } + if k == m || !(**(**uint8)(__ccgo_up(pat + uintptr(k))) != 0) { + break + } + } + goto _1 + _1: + ; + k = k + 1 + } + if k == m || !(**(**uint8)(__ccgo_up(pat + uintptr(k))) != 0) { + **(**Tsize_t)(__ccgo_up(step)) = uint64(1) + return int32('[') + } + **(**Tsize_t)(__ccgo_up(step)) = k + uint64(1) + return -int32(3) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(pat))) == int32('*') { + return -int32(5) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(pat))) == int32('?') { + return -int32(4) + } + goto escaped +escaped: + ; + if uint32(**(**uint8)(__ccgo_up(pat))) >= uint32(128) { + k1 = Xmbtowc(tls, bp, pat, m) + if k1 < 0 { + **(**Tsize_t)(__ccgo_up(step)) = uint64(0) + return -int32(2) + } + **(**Tsize_t)(__ccgo_up(step)) = Uint64FromInt32(k1 + esc) + return Int32FromUint32(**(**Twchar_t)(__ccgo_up(bp))) + } + return Int32FromUint8(**(**uint8)(__ccgo_up(pat))) +} + +func _casefold(tls *TLS, k int32) (r int32) { + var c int32 + var v1 uint32 + _, _ = c, v1 + c = Int32FromUint32(Xtowupper(tls, Uint32FromInt32(k))) + if c == k { + v1 = Xtowlower(tls, Uint32FromInt32(k)) + } else { + v1 = Uint32FromInt32(c) + } + return Int32FromUint32(v1) +} + +func _match_bracket(tls *TLS, p uintptr, k int32, kfold int32) (r int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + var inv, l, l1, z int32 + var p0 uintptr + var _ /* buf at bp+8 */ [16]uint8 + var _ /* wc at bp+0 */ Twchar_t + var _ /* wc2 at bp+4 */ Twchar_t + _, _, _, _, _ = inv, l, l1, p0, z + inv = 0 + p = p + 1 + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('^') || Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('!') { + inv = int32(1) + p = p + 1 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32(']') { + if k == int32(']') { + return BoolInt32(!(inv != 0)) + } + p = p + 1 + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('-') { + if k == int32('-') { + return BoolInt32(!(inv != 0)) + } + p = p + 1 + } + } + **(**Twchar_t)(__ccgo_up(bp)) = uint32(**(**uint8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32(']')) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('-') && Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) != int32(']') { + l = Xmbtowc(tls, bp+4, p+uintptr(1), uint64(4)) + if l < 0 { + return 0 + } + if **(**Twchar_t)(__ccgo_up(bp)) <= **(**Twchar_t)(__ccgo_up(bp + 4)) { + if Uint32FromInt32(k)-**(**Twchar_t)(__ccgo_up(bp)) <= **(**Twchar_t)(__ccgo_up(bp + 4))-**(**Twchar_t)(__ccgo_up(bp)) || Uint32FromInt32(kfold)-**(**Twchar_t)(__ccgo_up(bp)) <= **(**Twchar_t)(__ccgo_up(bp + 4))-**(**Twchar_t)(__ccgo_up(bp)) { + return BoolInt32(!(inv != 0)) + } + } + p = p + uintptr(l-int32(1)) + goto _1 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('[') && (Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) == int32(':') || Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) == int32('.') || Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) == int32('=')) { + p0 = p + uintptr(2) + z = Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) + p = p + uintptr(3) + for Int32FromUint8(**(**uint8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) != z || Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32(']') { + p = p + 1 + } + if z == int32(':') && int64(p-uintptr(1))-int64(p0) < int64(16) { + Xmemcpy(tls, bp+8, p0, Uint64FromInt64(int64(p-uintptr(1))-int64(p0))) + (**(**[16]uint8)(__ccgo_up(bp + 8)))[int64(p-uintptr(1))-int64(p0)] = uint8(0) + if Xiswctype(tls, Uint32FromInt32(k), Xwctype(tls, bp+8)) != 0 || Xiswctype(tls, Uint32FromInt32(kfold), Xwctype(tls, bp+8)) != 0 { + return BoolInt32(!(inv != 0)) + } + } + goto _1 + } + if uint32(**(**uint8)(__ccgo_up(p))) < uint32(128) { + **(**Twchar_t)(__ccgo_up(bp)) = uint32(uint8(**(**uint8)(__ccgo_up(p)))) + } else { + l1 = Xmbtowc(tls, bp, p, uint64(4)) + if l1 < 0 { + return 0 + } + p = p + uintptr(l1-int32(1)) + } + if **(**Twchar_t)(__ccgo_up(bp)) == Uint32FromInt32(k) || **(**Twchar_t)(__ccgo_up(bp)) == Uint32FromInt32(kfold) { + return BoolInt32(!(inv != 0)) + } + goto _1 + _1: + ; + p = p + 1 + } + return inv +} + +func _fnmatch_internal(tls *TLS, pat uintptr, m Tsize_t, str uintptr, n Tsize_t, flags int32) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, k, kfold, v2 int32 + var endpat, endstr, p, ptail, s, stail, v6 uintptr + var tailcnt Tsize_t + var v9 bool + var _ /* pinc at bp+0 */ Tsize_t + var _ /* sinc at bp+8 */ Tsize_t + _, _, _, _, _, _, _, _, _, _, _, _, _ = c, endpat, endstr, k, kfold, p, ptail, s, stail, tailcnt, v2, v6, v9 + tailcnt = uint64(0) + if flags&int32(FNM_PERIOD) != 0 { + if Int32FromUint8(**(**uint8)(__ccgo_up(str))) == int32('.') && Int32FromUint8(**(**uint8)(__ccgo_up(pat))) != int32('.') { + return int32(FNM_NOMATCH) + } + } + for { + v2 = _pat_next(tls, pat, m, bp, flags) + c = v2 + switch v2 { + case -int32(2): + return int32(FNM_NOMATCH) + case -int32(5): + pat = pat + 1 + m = m - 1 + default: + k = _str_next(tls, str, n, bp+8) + if k <= 0 { + if c == END { + v2 = 0 + } else { + v2 = int32(FNM_NOMATCH) + } + return v2 + } + str = str + uintptr(**(**Tsize_t)(__ccgo_up(bp + 8))) + n = n - **(**Tsize_t)(__ccgo_up(bp + 8)) + if flags&int32(FNM_CASEFOLD) != 0 { + v2 = _casefold(tls, k) + } else { + v2 = k + } + kfold = v2 + if c == -int32(3) { + if !(_match_bracket(tls, pat, k, kfold) != 0) { + return int32(FNM_NOMATCH) + } + } else { + if c != -int32(4) && k != c && kfold != c { + return int32(FNM_NOMATCH) + } + } + pat = pat + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + m = m - **(**Tsize_t)(__ccgo_up(bp)) + goto _1 + } + break + goto _1 + _1: + } + /* Compute real pat length if it was initially unknown/-1 */ + m = Xstrnlen(tls, pat, m) + endpat = pat + uintptr(m) + /* Find the last * in pat and count chars needed after it */ + v6 = pat + ptail = v6 + p = v6 + for { + if !(p < endpat) { + break + } + switch _pat_next(tls, p, Uint64FromInt64(int64(endpat)-int64(p)), bp, flags) { + case -int32(2): + return int32(FNM_NOMATCH) + case -int32(5): + tailcnt = uint64(0) + ptail = p + uintptr(1) + default: + tailcnt = tailcnt + 1 + break + } + goto _5 + _5: + ; + p = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + } + /* Past this point we need not check for UNMATCHABLE in pat, + * because all of pat has already been parsed once. */ + /* Compute real str length if it was initially unknown/-1 */ + n = Xstrnlen(tls, str, n) + endstr = str + uintptr(n) + if n < tailcnt { + return int32(FNM_NOMATCH) + } + /* Find the final tailcnt chars of str, accounting for UTF-8. + * On illegal sequences we may get it wrong, but in that case + * we necessarily have a matching failure anyway. */ + s = endstr + for { + if !(s > str && tailcnt != 0) { + break + } + if v9 = uint32(**(**uint8)(__ccgo_up(s + uintptr(-Int32FromInt32(1))))) < uint32(128); !v9 { + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v2 = int32(4) + } else { + v2 = int32(1) + } + } + if v9 || v2 == int32(1) { + s = s - 1 + } else { + for { + s = s - 1 + v6 = s + if !(uint32(uint8(**(**uint8)(__ccgo_up(v6))))-uint32(0x80) < uint32(0x40) && s > str) { + break + } + } + } + goto _7 + _7: + ; + tailcnt = tailcnt - 1 + } + if tailcnt != 0 { + return int32(FNM_NOMATCH) + } + stail = s + /* Check that the pat and str tails match */ + p = ptail + for { + c = _pat_next(tls, p, Uint64FromInt64(int64(endpat)-int64(p)), bp, flags) + p = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + v2 = _str_next(tls, s, Uint64FromInt64(int64(endstr)-int64(s)), bp+8) + k = v2 + if v2 <= 0 { + if c != END { + return int32(FNM_NOMATCH) + } + break + } + s = s + uintptr(**(**Tsize_t)(__ccgo_up(bp + 8))) + if flags&int32(FNM_CASEFOLD) != 0 { + v2 = _casefold(tls, k) + } else { + v2 = k + } + kfold = v2 + if c == -int32(3) { + if !(_match_bracket(tls, p-uintptr(**(**Tsize_t)(__ccgo_up(bp))), k, kfold) != 0) { + return int32(FNM_NOMATCH) + } + } else { + if c != -int32(4) && k != c && kfold != c { + return int32(FNM_NOMATCH) + } + } + goto _11 + _11: + } + /* We're all done with the tails now, so throw them out */ + endstr = stail + endpat = ptail + /* Match pattern components until there are none left */ + for pat < endpat { + p = pat + s = str + for { + c = _pat_next(tls, p, Uint64FromInt64(int64(endpat)-int64(p)), bp, flags) + p = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + /* Encountering * completes/commits a component */ + if c == -int32(5) { + pat = p + str = s + break + } + k = _str_next(tls, s, Uint64FromInt64(int64(endstr)-int64(s)), bp+8) + if !(k != 0) { + return int32(FNM_NOMATCH) + } + if flags&int32(FNM_CASEFOLD) != 0 { + v2 = _casefold(tls, k) + } else { + v2 = k + } + kfold = v2 + if c == -int32(3) { + if !(_match_bracket(tls, p-uintptr(**(**Tsize_t)(__ccgo_up(bp))), k, kfold) != 0) { + break + } + } else { + if c != -int32(4) && k != c && kfold != c { + break + } + } + s = s + uintptr(**(**Tsize_t)(__ccgo_up(bp + 8))) + goto _14 + _14: + } + if c == -int32(5) { + continue + } + /* If we failed, advance str, by 1 char if it's a valid + * char, or past all invalid bytes otherwise. */ + k = _str_next(tls, str, Uint64FromInt64(int64(endstr)-int64(str)), bp+8) + if k > 0 { + str = str + uintptr(**(**Tsize_t)(__ccgo_up(bp + 8))) + } else { + str = str + 1 + for { + if !(_str_next(tls, str, Uint64FromInt64(int64(endstr)-int64(str)), bp+8) < 0) { + break + } + goto _16 + _16: + ; + str = str + 1 + } + } + } + return 0 +} + +func Xfnmatch(tls *TLS, pat uintptr, str uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v pat=%v str=%v flags=%v, (%v:)", tls, pat, str, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, v4 int32 + var p, s uintptr + var _ /* inc at bp+0 */ Tsize_t + _, _, _, _ = c, p, s, v4 + if flags&int32(FNM_PATHNAME) != 0 { + for { + s = str + for { + if !(**(**uint8)(__ccgo_up(s)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('/')) { + break + } + goto _2 + _2: + ; + s = s + 1 + } + p = pat + for { + v4 = _pat_next(tls, p, Uint64FromInt32(-Int32FromInt32(1)), bp, flags) + c = v4 + if !(v4 != END && c != int32('/')) { + break + } + goto _3 + _3: + ; + p = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + } + if c != Int32FromUint8(**(**uint8)(__ccgo_up(s))) && (!(**(**uint8)(__ccgo_up(s)) != 0) || !(flags&Int32FromInt32(FNM_LEADING_DIR) != 0)) { + return int32(FNM_NOMATCH) + } + if _fnmatch_internal(tls, pat, Uint64FromInt64(int64(p)-int64(pat)), str, Uint64FromInt64(int64(s)-int64(str)), flags) != 0 { + return int32(FNM_NOMATCH) + } + if !(c != 0) { + return 0 + } + str = s + uintptr(1) + pat = p + uintptr(**(**Tsize_t)(__ccgo_up(bp))) + goto _1 + _1: + } + } else { + if flags&int32(FNM_LEADING_DIR) != 0 { + s = str + for { + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('/') { + goto _5 + } + if !(_fnmatch_internal(tls, pat, Uint64FromInt32(-Int32FromInt32(1)), str, Uint64FromInt64(int64(s)-int64(str)), flags) != 0) { + return 0 + } + goto _5 + _5: + ; + s = s + 1 + } + } + } + return _fnmatch_internal(tls, pat, Uint64FromInt32(-Int32FromInt32(1)), str, Uint64FromInt32(-Int32FromInt32(1)), flags) +} + +const GLOB_ABORTED = 2 +const GLOB_APPEND = 32 +const GLOB_DOOFFS = 8 +const GLOB_ERR = 1 +const GLOB_MARK = 2 +const GLOB_NOCHECK = 16 +const GLOB_NOESCAPE = 64 +const GLOB_NOMATCH = 3 +const GLOB_NOSORT = 4 +const GLOB_NOSPACE = 1 +const GLOB_NOSYS = 4 +const GLOB_PERIOD = 128 +const GLOB_TILDE = 4096 +const GLOB_TILDE_CHECK = 16384 + +type Tglob_t = struct { + Fgl_pathc Tsize_t + Fgl_pathv uintptr + Fgl_offs Tsize_t + F__dummy1 int32 + F__dummy2 [5]uintptr +} + +type Tmatch = struct { + Fnext uintptr +} + +func _append(tls *TLS, tail uintptr, name uintptr, len1 Tsize_t, mark int32) (r int32) { + var new1 uintptr + _ = new1 + new1 = Xmalloc(tls, uint64(8)+len1+uint64(2)) + if !(new1 != 0) { + return -int32(1) + } + (*Tmatch)(unsafe.Pointer(**(**uintptr)(__ccgo_up(tail)))).Fnext = new1 + (*Tmatch)(unsafe.Pointer(new1)).Fnext = UintptrFromInt32(0) + Xmemcpy(tls, new1+8, name, len1+uint64(1)) + if mark != 0 && len1 != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(name + uintptr(len1-uint64(1))))) != int32('/') { + *(*uint8)(unsafe.Pointer(new1 + 8 + uintptr(len1))) = uint8('/') + *(*uint8)(unsafe.Pointer(new1 + 8 + uintptr(len1+uint64(1)))) = uint8(0) + } + **(**uintptr)(__ccgo_up(tail)) = new1 + return 0 +} + +func _do_glob(tls *TLS, buf uintptr, pos Tsize_t, type1 int32, pat uintptr, flags int32, __ccgo_fp_errfunc uintptr, tail uintptr) (r1 int32) { + bp := tls.Alloc(128) + defer tls.Free(128) + var de, dir, p, p2, v2 uintptr + var fnm_flags, in_bracket, old_errno, overflow, r, readerr, v10, v9 int32 + var i, j, v4 Tptrdiff_t + var l, v1 Tsize_t + var saved_sep uint8 + var _ /* st at bp+0 */ Tstat + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = de, dir, fnm_flags, i, in_bracket, j, l, old_errno, overflow, p, p2, r, readerr, saved_sep, v1, v10, v2, v4, v9 + /* If GLOB_MARK is unused, we don't care about type. */ + if !(type1 != 0) && !(flags&Int32FromInt32(GLOB_MARK) != 0) { + type1 = int32(DT_REG) + } + /* Special-case the remaining pattern being all slashes, in + * which case we can use caller-passed type if it's a dir. */ + if **(**uint8)(__ccgo_up(pat)) != 0 && type1 != int32(DT_DIR) { + type1 = 0 + } + for pos+uint64(1) < uint64(PATH_MAX) && Int32FromUint8(**(**uint8)(__ccgo_up(pat))) == int32('/') { + v1 = pos + pos = pos + 1 + v2 = pat + pat = pat + 1 + **(**uint8)(__ccgo_up(buf + uintptr(v1))) = **(**uint8)(__ccgo_up(v2)) + } + /* Consume maximal [escaped-]literal prefix of pattern, copying + * and un-escaping it to the running buffer as we go. */ + i = 0 + j = 0 + in_bracket = 0 + overflow = 0 + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(i)))) != int32('*') && Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(i)))) != int32('?') && (!(in_bracket != 0) || Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(i)))) != int32(']'))) { + break + } + if !(**(**uint8)(__ccgo_up(pat + uintptr(i))) != 0) { + if overflow != 0 { + return 0 + } + pat = pat + uintptr(i) + pos = pos + Uint64FromInt64(j) + v4 = Int64FromInt32(0) + j = v4 + i = v4 + break + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(i)))) == int32('[') { + in_bracket = int32(1) + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(i)))) == int32('\\') && !(flags&Int32FromInt32(GLOB_NOESCAPE) != 0) { + /* Backslashes inside a bracket are (at least by + * our interpretation) non-special, so if next + * char is ']' we have a complete expression. */ + if in_bracket != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(i+int64(1))))) == int32(']') { + break + } + /* Unpaired final backslash never matches. */ + if !(**(**uint8)(__ccgo_up(pat + uintptr(i+int64(1)))) != 0) { + return 0 + } + i = i + 1 + } + } + } + if Int32FromUint8(**(**uint8)(__ccgo_up(pat + uintptr(i)))) == int32('/') { + if overflow != 0 { + return 0 + } + in_bracket = 0 + pat = pat + uintptr(i+int64(1)) + i = int64(-int32(1)) + pos = pos + Uint64FromInt64(j+int64(1)) + j = int64(-int32(1)) + } + /* Only store a character if it fits in the buffer, but if + * a potential bracket expression is open, the overflow + * must be remembered and handled later only if the bracket + * is unterminated (and thereby a literal), so as not to + * disallow long bracket expressions with short matches. */ + if pos+Uint64FromInt64(j+Int64FromInt32(1)) < uint64(PATH_MAX) { + v4 = j + j = j + 1 + **(**uint8)(__ccgo_up(buf + uintptr(pos+Uint64FromInt64(v4)))) = **(**uint8)(__ccgo_up(pat + uintptr(i))) + } else { + if in_bracket != 0 { + overflow = int32(1) + } else { + return 0 + } + } + /* If we consume any new components, the caller-passed type + * or dummy type from above is no longer valid. */ + type1 = 0 + goto _3 + _3: + ; + i = i + 1 + } + **(**uint8)(__ccgo_up(buf + uintptr(pos))) = uint8(0) + if !(**(**uint8)(__ccgo_up(pat)) != 0) { + if flags&int32(GLOB_MARK) != 0 && (!(type1 != 0) || type1 == int32(DT_LNK)) && !(Xstat(tls, buf, bp) != 0) { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFDIR) { + type1 = int32(DT_DIR) + } else { + type1 = int32(DT_REG) + } + } + if !(type1 != 0) && Xlstat(tls, buf, bp) != 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(ENOENT) && ((*(*func(*TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_errfunc})))(tls, buf, **(**int32)(__ccgo_up(X__errno_location(tls)))) != 0 || flags&int32(GLOB_ERR) != 0) { + return int32(GLOB_ABORTED) + } + return 0 + } + if _append(tls, tail, buf, pos, BoolInt32(flags&int32(GLOB_MARK) != 0 && type1 == int32(DT_DIR))) != 0 { + return int32(GLOB_NOSPACE) + } + return 0 + } + p2 = Xstrchr(tls, pat, int32('/')) + saved_sep = uint8('/') + /* Check if the '/' was escaped and, if so, remove the escape char + * so that it will not be unpaired when passed to fnmatch. */ + if p2 != 0 && !(flags&Int32FromInt32(GLOB_NOESCAPE) != 0) { + p = p2 + for { + if !(p > pat && Int32FromUint8(**(**uint8)(__ccgo_up(p + uintptr(-Int32FromInt32(1))))) == int32('\\')) { + break + } + goto _6 + _6: + ; + p = p - 1 + } + if (int64(p2)-int64(p))%int64(2) != 0 { + p2 = p2 - 1 + saved_sep = uint8('\\') + } + } + if pos != 0 { + v2 = buf + } else { + v2 = __ccgo_ts + 558 + } + dir = Xopendir(tls, v2) + if !(dir != 0) { + if (*(*func(*TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_errfunc})))(tls, buf, **(**int32)(__ccgo_up(X__errno_location(tls)))) != 0 || flags&int32(GLOB_ERR) != 0 { + return int32(GLOB_ABORTED) + } + return 0 + } + old_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + for { + **(**int32)(__ccgo_up(X__errno_location(tls))) = 0 + v2 = Xreaddir(tls, dir) + de = v2 + if !(v2 != 0) { + break + } + /* Quickly skip non-directories when there's pattern left. */ + if p2 != 0 && (*Tdirent)(unsafe.Pointer(de)).Fd_type != 0 && Int32FromUint8((*Tdirent)(unsafe.Pointer(de)).Fd_type) != int32(DT_DIR) && Int32FromUint8((*Tdirent)(unsafe.Pointer(de)).Fd_type) != int32(DT_LNK) { + continue + } + l = _strlen(tls, de+19) + if l >= uint64(PATH_MAX)-pos { + continue + } + if p2 != 0 { + **(**uint8)(__ccgo_up(p2)) = uint8(0) + } + if flags&int32(GLOB_NOESCAPE) != 0 { + v9 = int32(FNM_NOESCAPE) + } else { + v9 = 0 + } + if !(flags&Int32FromInt32(GLOB_PERIOD) != 0) { + v10 = int32(FNM_PERIOD) + } else { + v10 = 0 + } + fnm_flags = v9 | v10 + if Xfnmatch(tls, pat, de+19, fnm_flags) != 0 { + continue + } + /* With GLOB_PERIOD, don't allow matching . or .. unless + * fnmatch would match them with FNM_PERIOD rules in effect. */ + if p2 != 0 && flags&int32(GLOB_PERIOD) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(de + 19))) == int32('.') && (!(**(**uint8)(__ccgo_up(de + 19 + 1)) != 0) || Int32FromUint8(**(**uint8)(__ccgo_up(de + 19 + 1))) == int32('.') && !(**(**uint8)(__ccgo_up(de + 19 + 2)) != 0)) && Xfnmatch(tls, pat, de+19, fnm_flags|int32(FNM_PERIOD)) != 0 { + continue + } + Xmemcpy(tls, buf+uintptr(pos), de+19, l+uint64(1)) + if p2 != 0 { + **(**uint8)(__ccgo_up(p2)) = saved_sep + } + if p2 != 0 { + v2 = p2 + } else { + v2 = __ccgo_ts + } + r = _do_glob(tls, buf, pos+l, Int32FromUint8((*Tdirent)(unsafe.Pointer(de)).Fd_type), v2, flags, __ccgo_fp_errfunc, tail) + if r != 0 { + Xclosedir(tls, dir) + return r + } + } + readerr = **(**int32)(__ccgo_up(X__errno_location(tls))) + if p2 != 0 { + **(**uint8)(__ccgo_up(p2)) = saved_sep + } + Xclosedir(tls, dir) + if readerr != 0 && ((*(*func(*TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_errfunc})))(tls, buf, **(**int32)(__ccgo_up(X__errno_location(tls)))) != 0 || flags&int32(GLOB_ERR) != 0) { + return int32(GLOB_ABORTED) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + return 0 +} + +func _ignore_err(tls *TLS, path uintptr, err int32) (r int32) { + return 0 +} + +func _freelist(tls *TLS, head uintptr) { + var match, next uintptr + _, _ = match, next + match = (*Tmatch)(unsafe.Pointer(head)).Fnext + for { + if !(match != 0) { + break + } + next = (*Tmatch)(unsafe.Pointer(match)).Fnext + Xfree(tls, match) + goto _1 + _1: + ; + match = next + } +} + +func _sort(tls *TLS, a uintptr, b uintptr) (r int32) { + return Xstrcmp(tls, **(**uintptr)(__ccgo_up(a)), **(**uintptr)(__ccgo_up(b))) +} + +func _expand_tilde(tls *TLS, pat uintptr, buf uintptr, pos uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var delim, v1 uint8 + var home, name_end, p, v2 uintptr + var i, v10 Tsize_t + var v4 int32 + var _ /* pw at bp+0 */ Tpasswd + var _ /* res at bp+48 */ uintptr + _, _, _, _, _, _, _, _, _ = delim, home, i, name_end, p, v1, v10, v2, v4 + p = **(**uintptr)(__ccgo_up(pat)) + uintptr(1) + i = uint64(0) + name_end = X__strchrnul(tls, p, int32('/')) + v1 = **(**uint8)(__ccgo_up(name_end)) + delim = v1 + if v1 != 0 { + v2 = name_end + name_end = name_end + 1 + **(**uint8)(__ccgo_up(v2)) = uint8(0) + } + **(**uintptr)(__ccgo_up(pat)) = name_end + if **(**uint8)(__ccgo_up(p)) != 0 { + v2 = UintptrFromInt32(0) + } else { + v2 = Xgetenv(tls, __ccgo_ts+1395) + } + home = v2 + if !(home != 0) { + if **(**uint8)(__ccgo_up(p)) != 0 { + v4 = Xgetpwnam_r(tls, p, bp, buf, uint64(PATH_MAX), bp+48) + } else { + v4 = Xgetpwuid_r(tls, Xgetuid(tls), bp, buf, uint64(PATH_MAX), bp+48) + } + switch v4 { + case int32(ENOMEM): + goto _5 + default: + goto _6 + case 0: + goto _7 + } + goto _8 + _5: + ; + return int32(GLOB_NOSPACE) + _7: + ; + if !!(**(**uintptr)(__ccgo_up(bp + 48)) != 0) { + goto _9 + } + _6: + ; + return int32(GLOB_NOMATCH) + _9: + ; + _8: + ; + home = (**(**Tpasswd)(__ccgo_up(bp))).Fpw_dir + } + for i < Uint64FromInt32(Int32FromInt32(PATH_MAX)-Int32FromInt32(2)) && **(**uint8)(__ccgo_up(home)) != 0 { + v10 = i + i = i + 1 + v2 = home + home = home + 1 + **(**uint8)(__ccgo_up(buf + uintptr(v10))) = **(**uint8)(__ccgo_up(v2)) + } + if **(**uint8)(__ccgo_up(home)) != 0 { + return int32(GLOB_NOMATCH) + } + v1 = delim + **(**uint8)(__ccgo_up(buf + uintptr(i))) = v1 + if v1 != 0 { + i = i + 1 + v10 = i + **(**uint8)(__ccgo_up(buf + uintptr(v10))) = uint8(0) + } + **(**Tsize_t)(__ccgo_up(pos)) = i + return 0 +} + +type t__ccgo_fp__Xglob_2 = func(*TLS, uintptr, int32) int32 + +func Xglob(tls *TLS, pat uintptr, flags int32, __ccgo_fp_errfunc uintptr, g uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v pat=%v flags=%v __ccgo_fp_errfunc=%v g=%v, (%v:)", tls, pat, flags, __ccgo_fp_errfunc, g, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(4128) + defer tls.Free(4128) + var cnt, i, offs Tsize_t + var error1 int32 + var p, pathv uintptr + var v1 uint64 + var _ /* buf at bp+16 */ [4096]uint8 + var _ /* head at bp+0 */ Tmatch + var _ /* pos at bp+4112 */ Tsize_t + var _ /* s at bp+4120 */ uintptr + var _ /* tail at bp+8 */ uintptr + _, _, _, _, _, _, _ = cnt, error1, i, offs, p, pathv, v1 + **(**Tmatch)(__ccgo_up(bp)) = struct { + Fnext uintptr + }{} + **(**uintptr)(__ccgo_up(bp + 8)) = bp + if flags&int32(GLOB_DOOFFS) != 0 { + v1 = (*Tglob_t)(unsafe.Pointer(g)).Fgl_offs + } else { + v1 = uint64(0) + } + offs = v1 + error1 = 0 + if !(__ccgo_fp_errfunc != 0) { + __ccgo_fp_errfunc = __ccgo_fp(_ignore_err) + } + if !(flags&Int32FromInt32(GLOB_APPEND) != 0) { + (*Tglob_t)(unsafe.Pointer(g)).Fgl_offs = offs + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc = uint64(0) + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv = UintptrFromInt32(0) + } + if **(**uint8)(__ccgo_up(pat)) != 0 { + p = Xstrdup(tls, pat) + if !(p != 0) { + return int32(GLOB_NOSPACE) + } + (**(**[4096]uint8)(__ccgo_up(bp + 16)))[0] = uint8(0) + **(**Tsize_t)(__ccgo_up(bp + 4112)) = uint64(0) + **(**uintptr)(__ccgo_up(bp + 4120)) = p + if flags&(Int32FromInt32(GLOB_TILDE)|Int32FromInt32(GLOB_TILDE_CHECK)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('~') { + error1 = _expand_tilde(tls, bp+4120, bp+16, bp+4112) + } + if !(error1 != 0) { + error1 = _do_glob(tls, bp+16, **(**Tsize_t)(__ccgo_up(bp + 4112)), 0, **(**uintptr)(__ccgo_up(bp + 4120)), flags, __ccgo_fp_errfunc, bp+8) + } + Xfree(tls, p) + } + if error1 == int32(GLOB_NOSPACE) { + _freelist(tls, bp) + return error1 + } + cnt = uint64(0) + **(**uintptr)(__ccgo_up(bp + 8)) = (**(**Tmatch)(__ccgo_up(bp))).Fnext + for { + if !(**(**uintptr)(__ccgo_up(bp + 8)) != 0) { + break + } + goto _2 + _2: + ; + **(**uintptr)(__ccgo_up(bp + 8)) = (*Tmatch)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).Fnext + cnt = cnt + 1 + } + if !(cnt != 0) { + if flags&int32(GLOB_NOCHECK) != 0 { + **(**uintptr)(__ccgo_up(bp + 8)) = bp + if _append(tls, bp+8, pat, _strlen(tls, pat), 0) != 0 { + return int32(GLOB_NOSPACE) + } + cnt = cnt + 1 + } else { + if !(error1 != 0) { + return int32(GLOB_NOMATCH) + } + } + } + if flags&int32(GLOB_APPEND) != 0 { + pathv = Xrealloc(tls, (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv, (offs+(*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc+cnt+uint64(1))*uint64(8)) + if !(pathv != 0) { + _freelist(tls, bp) + return int32(GLOB_NOSPACE) + } + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv = pathv + offs = offs + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc + } else { + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv = Xmalloc(tls, (offs+cnt+uint64(1))*uint64(8)) + if !((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv != 0) { + _freelist(tls, bp) + return int32(GLOB_NOSPACE) + } + i = uint64(0) + for { + if !(i < offs) { + break + } + **(**uintptr)(__ccgo_up((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv + uintptr(i)*8)) = UintptrFromInt32(0) + goto _3 + _3: + ; + i = i + 1 + } + } + i = uint64(0) + **(**uintptr)(__ccgo_up(bp + 8)) = (**(**Tmatch)(__ccgo_up(bp))).Fnext + for { + if !(i < cnt) { + break + } + **(**uintptr)(__ccgo_up((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv + uintptr(offs+i)*8)) = **(**uintptr)(__ccgo_up(bp + 8)) + 8 + goto _4 + _4: + ; + **(**uintptr)(__ccgo_up(bp + 8)) = (*Tmatch)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 8)))).Fnext + i = i + 1 + } + **(**uintptr)(__ccgo_up((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv + uintptr(offs+i)*8)) = UintptrFromInt32(0) + **(**Tsize_t)(__ccgo_up(g)) += cnt + if !(flags&Int32FromInt32(GLOB_NOSORT) != 0) { + Xqsort(tls, (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv+uintptr(offs)*8, cnt, uint64(8), __ccgo_fp(_sort)) + } + return error1 +} + +func Xglobfree(tls *TLS, g uintptr) { + if __ccgo_strace { + trc("tls=%v g=%v, (%v:)", tls, g, origin(2)) + } + var i Tsize_t + _ = i + i = uint64(0) + for { + if !(i < (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc) { + break + } + Xfree(tls, **(**uintptr)(__ccgo_up((*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv + uintptr((*Tglob_t)(unsafe.Pointer(g)).Fgl_offs+i)*8))-uintptr(uint64(UintptrFromInt32(0)+8))) + goto _1 + _1: + ; + i = i + 1 + } + Xfree(tls, (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv) + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathc = uint64(0) + (*Tglob_t)(unsafe.Pointer(g)).Fgl_pathv = UintptrFromInt32(0) +} + +const ASSERTION = -2 +const ASSERT_AT_BOL = 1 +const ASSERT_AT_BOW = 16 +const ASSERT_AT_EOL = 2 +const ASSERT_AT_EOW = 32 +const ASSERT_AT_WB = 64 +const ASSERT_AT_WB_NEG = 128 +const ASSERT_BACKREF = 256 +const ASSERT_CHAR_CLASS = 4 +const ASSERT_CHAR_CLASS_NEG = 8 +const ASSERT_LAST = 256 +const BACKREF = -4 +const COPY_MAXIMIZE_FIRST_TAG = 2 +const COPY_REMOVE_TAGS = 1 +const EMPTY1 = -1 +const MAX_NEG_CLASSES = 64 +const REG_BADBR = 10 +const REG_BADPAT = 2 +const REG_BADRPT = 13 +const REG_EBRACE = 9 +const REG_EBRACK = 7 +const REG_ECOLLATE = 3 +const REG_ECTYPE = 4 +const REG_EESCAPE = 5 +const REG_ENOSYS = -1 +const REG_EPAREN = 8 +const REG_ERANGE = 11 +const REG_ESPACE = 12 +const REG_ESUBREG = 6 +const REG_EXTENDED = 1 +const REG_ICASE = 2 +const REG_NEWLINE = 4 +const REG_NOMATCH = 1 +const REG_NOSUB = 8 +const REG_NOTBOL = 1 +const REG_NOTEOL = 2 +const REG_OK = 0 +const TAG = -3 +const TRE_CHAR_MAX = 1114111 +const TRE_MEM_BLOCK_SIZE = 1024 +const TRE_REGEX_T_FIELD = 0 +const tre_ctype = 0 +const tre_isalnum = 0 +const tre_isalpha = 0 +const tre_isblank = 0 +const tre_iscntrl = 0 +const tre_isctype = 0 +const tre_isdigit = 0 +const tre_isgraph = 0 +const tre_islower = 0 +const tre_isprint = 0 +const tre_ispunct = 0 +const tre_isspace = 0 +const tre_isupper = 0 +const tre_isxdigit = 0 +const tre_mem_alloc_impl = 0 +const tre_mem_destroy = 0 +const tre_mem_new_impl = 0 +const tre_strlen = 0 +const tre_tolower = 0 +const tre_toupper = 0 +const xcalloc = 0 +const xfree = 0 +const xmalloc = 0 +const xrealloc = 0 + +type Tregoff_t = int64 + +type Tregex_t = struct { + Fre_nsub Tsize_t + F__opaque uintptr + F__padding [4]uintptr + F__nsub2 Tsize_t + F__padding2 uint8 +} + +type Tre_pattern_buffer = Tregex_t + +type Tregmatch_t = struct { + Frm_so Tregoff_t + Frm_eo Tregoff_t +} + +type Treg_errcode_t = int32 + +type Ttre_char_t = uint32 + +type Ttre_cint_t = uint32 + +type Ttre_ctype_t = uint64 + +type Ttre_tnfa_transition_t = struct { + Fcode_min Ttre_cint_t + Fcode_max Ttre_cint_t + Fstate uintptr + Fstate_id int32 + Ftags uintptr + Fassertions int32 + Fu struct { + Fbackref [0]int32 + Fclass Ttre_ctype_t + } + Fneg_classes uintptr +} + +type Ttnfa_transition = Ttre_tnfa_transition_t + +type Ttre_tag_direction_t = int32 + +const _TRE_TAG_MINIMIZE = 0 +const _TRE_TAG_MAXIMIZE = 1 + +type Ttre_submatch_data = struct { + Fso_tag int32 + Feo_tag int32 + Fparents uintptr +} + +type Ttre_submatch_data_t = struct { + Fso_tag int32 + Feo_tag int32 + Fparents uintptr +} + +type Ttre_tnfa_t = struct { + Ftransitions uintptr + Fnum_transitions uint32 + Finitial uintptr + Ffinal uintptr + Fsubmatch_data uintptr + Ffirstpos_chars uintptr + Ffirst_char int32 + Fnum_submatches uint32 + Ftag_directions uintptr + Fminimal_tags uintptr + Fnum_tags int32 + Fnum_minimals int32 + Fend_tag int32 + Fnum_states int32 + Fcflags int32 + Fhave_backrefs int32 + Fhave_approx int32 +} + +type Ttnfa = Ttre_tnfa_t + +type Ttre_list_t = struct { + Fdata uintptr + Fnext uintptr +} + +type Ttre_list = Ttre_list_t + +type Ttre_mem_t = uintptr + +type Ttre_mem_struct = struct { + Fblocks uintptr + Fcurrent uintptr + Fptr uintptr + Fn Tsize_t + Ffailed int32 + Fprovided uintptr +} + +/*********************************************************************** + from tre-compile.h +***********************************************************************/ + +type Ttre_pos_and_tags_t = struct { + Fposition int32 + Fcode_min int32 + Fcode_max int32 + Ftags uintptr + Fassertions int32 + Fclass Ttre_ctype_t + Fneg_classes uintptr + Fbackref int32 +} + +/*********************************************************************** + from tre-ast.c and tre-ast.h +***********************************************************************/ + +// C documentation +// +// /* The different AST node types. */ +type Ttre_ast_type_t = int32 + +const _LITERAL = 0 +const _CATENATION = 1 +const _ITERATION = 2 +const _UNION = 3 + +/* Special subtypes of TRE_LITERAL. */ + +// C documentation +// +// /* A generic AST node. All AST nodes consist of this node on the top +// level with `obj' pointing to the actual content. */ +type Ttre_ast_node_t = struct { + Ftype1 Ttre_ast_type_t + Fobj uintptr + Fnullable int32 + Fsubmatch_id int32 + Fnum_submatches int32 + Fnum_tags int32 + Ffirstpos uintptr + Flastpos uintptr +} + +// C documentation +// +// /* A "literal" node. These are created for assertions, back references, +// tags, matching parameter settings, and all expressions that match one +// character. */ +type Ttre_literal_t = struct { + Fcode_min int64 + Fcode_max int64 + Fposition int32 + Fclass Ttre_ctype_t + Fneg_classes uintptr +} + +// C documentation +// +// /* A "catenation" node. These are created when two regexps are concatenated. +// If there are more than one subexpressions in sequence, the `left' part +// holds all but the last, and `right' part holds the last subexpression +// (catenation is left associative). */ +type Ttre_catenation_t = struct { + Fleft uintptr + Fright uintptr +} + +// C documentation +// +// /* An "iteration" node. These are created for the "*", "+", "?", and "{m,n}" +// operators. */ +type Ttre_iteration_t = struct { + Farg uintptr + Fmin int32 + Fmax int32 + F__ccgo16 uint8 +} + +// C documentation +// +// /* An "union" node. These are created for the "|" operator. */ +type Ttre_union_t = struct { + Fleft uintptr + Fright uintptr +} + +func _tre_ast_new_node(tls *TLS, mem Ttre_mem_t, type1 int32, obj uintptr) (r uintptr) { + var node uintptr + _ = node + node = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(48)) + if !(node != 0) || !(obj != 0) { + return uintptr(0) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj = obj + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 = type1 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id = -int32(1) + return node +} + +func _tre_ast_new_literal(tls *TLS, mem Ttre_mem_t, code_min int32, code_max int32, position int32) (r uintptr) { + var lit, node uintptr + _, _ = lit, node + lit = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(40)) + node = _tre_ast_new_node(tls, mem, int32(_LITERAL), lit) + if !(node != 0) { + return uintptr(0) + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64(code_min) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64(code_max) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = position + return node +} + +func _tre_ast_new_iter(tls *TLS, mem Ttre_mem_t, arg uintptr, min int32, max int32, minimal int32) (r uintptr) { + var iter, node uintptr + _, _ = iter, node + iter = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(24)) + node = _tre_ast_new_node(tls, mem, int32(_ITERATION), iter) + if !(node != 0) { + return uintptr(0) + } + (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg = arg + (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmin = min + (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmax = max + SetBitFieldPtr8Uint32(iter+16, Uint32FromInt32(minimal), 0, 0x1) + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(arg)).Fnum_submatches + return node +} + +func _tre_ast_new_union(tls *TLS, mem Ttre_mem_t, left uintptr, right uintptr) (r uintptr) { + var node, un uintptr + _, _ = node, un + if !(left != 0) { + return right + } + un = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(16)) + node = _tre_ast_new_node(tls, mem, int32(_UNION), un) + if !(node != 0) || !(right != 0) { + return uintptr(0) + } + (*Ttre_union_t)(unsafe.Pointer(un)).Fleft = left + (*Ttre_union_t)(unsafe.Pointer(un)).Fright = right + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(left)).Fnum_submatches + (*Ttre_ast_node_t)(unsafe.Pointer(right)).Fnum_submatches + return node +} + +func _tre_ast_new_catenation(tls *TLS, mem Ttre_mem_t, left uintptr, right uintptr) (r uintptr) { + var cat, node uintptr + _, _ = cat, node + if !(left != 0) { + return right + } + cat = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(16)) + node = _tre_ast_new_node(tls, mem, int32(_CATENATION), cat) + if !(node != 0) { + return uintptr(0) + } + (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft = left + (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright = right + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(left)).Fnum_submatches + (*Ttre_ast_node_t)(unsafe.Pointer(right)).Fnum_submatches + return node +} + +/*********************************************************************** + from tre-stack.c and tre-stack.h +***********************************************************************/ + +type Ttre_stack_t = struct { + Fsize int32 + Fmax_size int32 + Fincrement int32 + Fptr int32 + Fstack uintptr +} + +/*********************************************************************** + from tre-stack.c and tre-stack.h +***********************************************************************/ + +type Ttre_stack_rec = Ttre_stack_t + +/* Just to save some typing. */ + +type Ttre_stack_item = struct { + Fint_value [0]int32 + Fvoidptr_value uintptr +} + +func _tre_stack_new(tls *TLS, size int32, max_size int32, increment int32) (r uintptr) { + var s uintptr + _ = s + s = Xmalloc(tls, uint64(24)) + if s != UintptrFromInt32(0) { + (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack = Xmalloc(tls, uint64(8)*Uint64FromInt32(size)) + if (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack == UintptrFromInt32(0) { + Xfree(tls, s) + return UintptrFromInt32(0) + } + (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize = size + (*Ttre_stack_t)(unsafe.Pointer(s)).Fmax_size = max_size + (*Ttre_stack_t)(unsafe.Pointer(s)).Fincrement = increment + (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr = 0 + } + return s +} + +func _tre_stack_destroy(tls *TLS, s uintptr) { + Xfree(tls, (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack) + Xfree(tls, s) +} + +func _tre_stack_num_objects(tls *TLS, s uintptr) (r int32) { + return (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr +} + +func _tre_stack_push(tls *TLS, s uintptr, value Ttre_stack_item) (r Treg_errcode_t) { + var new_buffer uintptr + var new_size int32 + _, _ = new_buffer, new_size + if (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr < (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize { + **(**Ttre_stack_item)(__ccgo_up((*Ttre_stack_t)(unsafe.Pointer(s)).Fstack + uintptr((*Ttre_stack_t)(unsafe.Pointer(s)).Fptr)*8)) = value + (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr = (*Ttre_stack_t)(unsafe.Pointer(s)).Fptr + 1 + } else { + if (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize >= (*Ttre_stack_t)(unsafe.Pointer(s)).Fmax_size { + return int32(REG_ESPACE) + } else { + new_size = (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize + (*Ttre_stack_t)(unsafe.Pointer(s)).Fincrement + if new_size > (*Ttre_stack_t)(unsafe.Pointer(s)).Fmax_size { + new_size = (*Ttre_stack_t)(unsafe.Pointer(s)).Fmax_size + } + new_buffer = Xrealloc(tls, (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack, uint64(8)*Uint64FromInt32(new_size)) + if new_buffer == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_stack_t)(unsafe.Pointer(s)).Fsize = new_size + (*Ttre_stack_t)(unsafe.Pointer(s)).Fstack = new_buffer + _tre_stack_push(tls, s, value) + } + } + return REG_OK +} + +func _tre_stack_push_int(tls *TLS, s uintptr, value int32) (r Treg_errcode_t) { + var item Ttre_stack_item + _ = item + *(*int32)(unsafe.Pointer(&item)) = value + return _tre_stack_push(tls, s, item) +} + +func _tre_stack_push_voidptr(tls *TLS, s uintptr, value uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* item at bp+0 */ Ttre_stack_item + *(*uintptr)(unsafe.Pointer(bp)) = value + return _tre_stack_push(tls, s, **(**Ttre_stack_item)(__ccgo_up(bp))) +} + +func _tre_stack_pop_int(tls *TLS, s uintptr) (r int32) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + v2 = s + 12 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + return *(*int32)(unsafe.Pointer(&**(**Ttre_stack_item)(__ccgo_up((*Ttre_stack_t)(unsafe.Pointer(s)).Fstack + uintptr(v1)*8)))) +} + +func _tre_stack_pop_voidptr(tls *TLS, s uintptr) (r uintptr) { + var v1 int32 + var v2 uintptr + _, _ = v1, v2 + v2 = s + 12 + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) - 1 + v1 = *(*int32)(unsafe.Pointer(v2)) + return *(*uintptr)(unsafe.Pointer((*Ttre_stack_t)(unsafe.Pointer(s)).Fstack + uintptr(v1)*8)) +} + +/*********************************************************************** + from tre-parse.c and tre-parse.h +***********************************************************************/ + +// C documentation +// +// /* Parse context. */ +type Ttre_parse_ctx_t = struct { + Fmem Ttre_mem_t + Fstack uintptr + Fn uintptr + Fs uintptr + Fstart uintptr + Fsubmatch_id int32 + Fposition int32 + Fmax_backref int32 + Fcflags int32 +} + +// C documentation +// +// /* Some macros for expanding \w, \s, etc. */ +var _tre_macros = [13]struct { + Fc uint8 + Fexpansion uintptr +}{ + 0: { + Fc: uint8('t'), + Fexpansion: __ccgo_ts + 1400, + }, + 1: { + Fc: uint8('n'), + Fexpansion: __ccgo_ts + 301, + }, + 2: { + Fc: uint8('r'), + Fexpansion: __ccgo_ts + 1402, + }, + 3: { + Fc: uint8('f'), + Fexpansion: __ccgo_ts + 1404, + }, + 4: { + Fc: uint8('a'), + Fexpansion: __ccgo_ts + 1406, + }, + 5: { + Fc: uint8('e'), + Fexpansion: __ccgo_ts + 1408, + }, + 6: { + Fc: uint8('w'), + Fexpansion: __ccgo_ts + 1410, + }, + 7: { + Fc: uint8('W'), + Fexpansion: __ccgo_ts + 1423, + }, + 8: { + Fc: uint8('s'), + Fexpansion: __ccgo_ts + 1437, + }, + 9: { + Fc: uint8('S'), + Fexpansion: __ccgo_ts + 1449, + }, + 10: { + Fc: uint8('d'), + Fexpansion: __ccgo_ts + 1462, + }, + 11: { + Fc: uint8('D'), + Fexpansion: __ccgo_ts + 1474, + }, + 12: {}, +} + +// C documentation +// +// /* Expands a macro delimited by `regex' and `regex_end' to `buf', which +// must have at least `len' items. Sets buf[0] to zero if the there +// is no match in `tre_macros'. */ +func _tre_expand_macro(tls *TLS, s uintptr) (r uintptr) { + var i int32 + _ = i + i = 0 + for { + if !(_tre_macros[i].Fc != 0 && Int32FromUint8(_tre_macros[i].Fc) != Int32FromUint8(**(**uint8)(__ccgo_up(s)))) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + return _tre_macros[i].Fexpansion +} + +func _tre_compare_lit(tls *TLS, a uintptr, b uintptr) (r int32) { + var la, lb uintptr + _, _ = la, lb + la = a + lb = b + /* assumes the range of valid code_min is < INT_MAX */ + return int32((*Ttre_literal_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(la)))).Fcode_min - (*Ttre_literal_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(lb)))).Fcode_min) +} + +type Tliterals = struct { + Fmem Ttre_mem_t + Fa uintptr + Flen1 int32 + Fcap1 int32 +} + +func _tre_new_lit(tls *TLS, p uintptr) (r uintptr) { + var a, v2 uintptr + var v1 int32 + _, _, _ = a, v1, v2 + if (*Tliterals)(unsafe.Pointer(p)).Flen1 >= (*Tliterals)(unsafe.Pointer(p)).Fcap1 { + if (*Tliterals)(unsafe.Pointer(p)).Fcap1 >= Int32FromInt32(1)< max { + return int32(REG_ERANGE) + } + s = s + uintptr(len1) + } + } + if class != 0 && (*Tneg)(unsafe.Pointer(neg)).Fnegate != 0 { + if (*Tneg)(unsafe.Pointer(neg)).Flen1 >= int32(MAX_NEG_CLASSES) { + return int32(REG_ESPACE) + } + v6 = neg + 4 + v2 = *(*int32)(unsafe.Pointer(v6)) + *(*int32)(unsafe.Pointer(v6)) = *(*int32)(unsafe.Pointer(v6)) + 1 + **(**Ttre_ctype_t)(__ccgo_up(neg + 8 + uintptr(v2)*8)) = class + } else { + lit = _tre_new_lit(tls, ls) + if !(lit != 0) { + return int32(REG_ESPACE) + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64(min) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64(max) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fclass = class + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = -int32(1) + /* Add opposite-case codepoints if REG_ICASE is present. + It seems that POSIX requires that bracket negation + should happen before case-folding, but most practical + implementations do it the other way around. Changing + the order would need efficient representation of + case-fold ranges and bracket range sets even with + simple patterns so this is ok for now. */ + if (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags&int32(REG_ICASE) != 0 && !(class != 0) { + if _add_icase_literals(tls, ls, min, max) != 0 { + return int32(REG_ESPACE) + } + } + } + goto _1 + _1: + } + return r +} + +func _parse_bracket(tls *TLS, ctx uintptr, s uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(544) + defer tls.Free(544) + var err Treg_errcode_t + var i, max, min, negmax, negmin, v1 int32 + var lit, n, nc, node uintptr + var _ /* ls at bp+0 */ Tliterals + var _ /* neg at bp+24 */ Tneg + _, _, _, _, _, _, _, _, _, _, _ = err, i, lit, max, min, n, nc, negmax, negmin, node, v1 + node = uintptr(0) + nc = uintptr(0) + (**(**Tliterals)(__ccgo_up(bp))).Fmem = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem + (**(**Tliterals)(__ccgo_up(bp))).Flen1 = 0 + (**(**Tliterals)(__ccgo_up(bp))).Fcap1 = int32(32) + (**(**Tliterals)(__ccgo_up(bp))).Fa = Xmalloc(tls, Uint64FromInt32((**(**Tliterals)(__ccgo_up(bp))).Fcap1)*uint64(8)) + if !((**(**Tliterals)(__ccgo_up(bp))).Fa != 0) { + return int32(REG_ESPACE) + } + (**(**Tneg)(__ccgo_up(bp + 24))).Flen1 = 0 + (**(**Tneg)(__ccgo_up(bp + 24))).Fnegate = BoolInt32(Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('^')) + if (**(**Tneg)(__ccgo_up(bp + 24))).Fnegate != 0 { + s = s + 1 + } + err = _parse_bracket_terms(tls, ctx, s, bp, bp+24) + if err != REG_OK { + goto parse_bracket_done + } + if (**(**Tneg)(__ccgo_up(bp + 24))).Fnegate != 0 { + /* + * With REG_NEWLINE, POSIX requires that newlines are not matched by + * any form of a non-matching list. + */ + if (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags&int32(REG_NEWLINE) != 0 { + lit = _tre_new_lit(tls, bp) + if !(lit != 0) { + err = int32(REG_ESPACE) + goto parse_bracket_done + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64('\n') + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64('\n') + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = -int32(1) + } + /* Sort the array if we need to negate it. */ + Xqsort(tls, (**(**Tliterals)(__ccgo_up(bp))).Fa, Uint64FromInt32((**(**Tliterals)(__ccgo_up(bp))).Flen1), uint64(8), __ccgo_fp(_tre_compare_lit)) + /* extra lit for the last negated range */ + lit = _tre_new_lit(tls, bp) + if !(lit != 0) { + err = int32(REG_ESPACE) + goto parse_bracket_done + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64(Int32FromInt32(TRE_CHAR_MAX) + Int32FromInt32(1)) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64(Int32FromInt32(TRE_CHAR_MAX) + Int32FromInt32(1)) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = -int32(1) + /* negated classes */ + if (**(**Tneg)(__ccgo_up(bp + 24))).Flen1 != 0 { + nc = X__tre_mem_alloc_impl(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, 0, UintptrFromInt32(0), 0, Uint64FromInt32((**(**Tneg)(__ccgo_up(bp + 24))).Flen1+Int32FromInt32(1))*uint64(8)) + if !(nc != 0) { + err = int32(REG_ESPACE) + goto parse_bracket_done + } + Xmemcpy(tls, nc, bp+24+8, Uint64FromInt32((**(**Tneg)(__ccgo_up(bp + 24))).Flen1)*uint64(8)) + **(**Ttre_ctype_t)(__ccgo_up(nc + uintptr((**(**Tneg)(__ccgo_up(bp + 24))).Flen1)*8)) = uint64(0) + } + } + /* Build a union of the items in the array, negated if necessary. */ + v1 = Int32FromInt32(0) + negmin = v1 + negmax = v1 + i = 0 + for { + if !(i < (**(**Tliterals)(__ccgo_up(bp))).Flen1) { + break + } + lit = **(**uintptr)(__ccgo_up((**(**Tliterals)(__ccgo_up(bp))).Fa + uintptr(i)*8)) + min = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min) + max = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max) + if (**(**Tneg)(__ccgo_up(bp + 24))).Fnegate != 0 { + if min <= negmin { + /* Overlap. */ + if max+int32(1) >= negmin { + v1 = max + int32(1) + } else { + v1 = negmin + } + negmin = v1 + goto _2 + } + negmax = min - int32(1) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min = int64(negmin) + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max = int64(negmax) + negmin = max + int32(1) + } + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition + (*Ttre_literal_t)(unsafe.Pointer(lit)).Fneg_classes = nc + n = _tre_ast_new_node(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, int32(_LITERAL), lit) + node = _tre_ast_new_union(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, node, n) + if !(node != 0) { + err = int32(REG_ESPACE) + break + } + goto _2 + _2: + ; + i = i + 1 + } + goto parse_bracket_done +parse_bracket_done: + ; + Xfree(tls, (**(**Tliterals)(__ccgo_up(bp))).Fa) + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition + 1 + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = node + return err +} + +func _parse_dup_count(tls *TLS, s uintptr, n uintptr) (r uintptr) { + **(**int32)(__ccgo_up(n)) = -int32(1) + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return s + } + **(**int32)(__ccgo_up(n)) = 0 + for { + **(**int32)(__ccgo_up(n)) = int32(10)***(**int32)(__ccgo_up(n)) + (Int32FromUint8(**(**uint8)(__ccgo_up(s))) - int32('0')) + s = s + 1 + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) || **(**int32)(__ccgo_up(n)) > int32(RE_DUP_MAX) { + break + } + goto _1 + _1: + } + return s +} + +func _parse_dup(tls *TLS, s uintptr, ere int32, pmin uintptr, pmax uintptr) (r uintptr) { + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v4 uintptr + var v2, v3, v5 bool + var _ /* max at bp+4 */ int32 + var _ /* min at bp+0 */ int32 + _, _, _, _, _ = v1, v2, v3, v4, v5 + s = _parse_dup_count(tls, s, bp) + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32(',') { + s = _parse_dup_count(tls, s+uintptr(1), bp+4) + } else { + **(**int32)(__ccgo_up(bp + 4)) = **(**int32)(__ccgo_up(bp)) + } + if v3 = **(**int32)(__ccgo_up(bp + 4)) < **(**int32)(__ccgo_up(bp)) && **(**int32)(__ccgo_up(bp + 4)) >= 0 || **(**int32)(__ccgo_up(bp + 4)) > int32(RE_DUP_MAX) || **(**int32)(__ccgo_up(bp)) > int32(RE_DUP_MAX) || **(**int32)(__ccgo_up(bp)) < 0; !v3 { + if v2 = !(ere != 0); v2 { + v1 = s + s = s + 1 + } + } + if v5 = v3 || v2 && Int32FromUint8(**(**uint8)(__ccgo_up(v1))) != int32('\\'); !v5 { + v4 = s + s = s + 1 + } + if v5 || Int32FromUint8(**(**uint8)(__ccgo_up(v4))) != int32('}') { + return uintptr(0) + } + **(**int32)(__ccgo_up(pmin)) = **(**int32)(__ccgo_up(bp)) + **(**int32)(__ccgo_up(pmax)) = **(**int32)(__ccgo_up(bp + 4)) + return s +} + +func _hexval1(tls *TLS, c uint32) (r int32) { + if c-uint32('0') < uint32(10) { + return Int32FromUint32(c - uint32('0')) + } + c = c | uint32(32) + if c-uint32('a') < uint32(6) { + return Int32FromUint32(c - uint32('a') + uint32(10)) + } + return -int32(1) +} + +func _marksub(tls *TLS, ctx uintptr, node uintptr, subid int32) (r Treg_errcode_t) { + var n uintptr + _ = n + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id >= 0 { + n = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + if !(n != 0) { + return int32(REG_ESPACE) + } + n = _tre_ast_new_catenation(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, n, node) + if !(n != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(n)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches + node = n + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id = subid + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches + 1 + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = node + return REG_OK +} + +/* +BRE grammar: +Regex = Branch | '^' | '$' | '^$' | '^' Branch | Branch '$' | '^' Branch '$' +Branch = Atom | Branch Atom +Atom = char | quoted_char | '.' | Bracket | Atom Dup | '\(' Branch '\)' | back_ref +Dup = '*' | '\{' Count '\}' | '\{' Count ',\}' | '\{' Count ',' Count '\}' + +(leading ^ and trailing $ in a sub expr may be an anchor or literal as well) + +ERE grammar: +Regex = Branch | Regex '|' Branch +Branch = Atom | Branch Atom +Atom = char | quoted_char | '.' | Bracket | Atom Dup | '(' Regex ')' | '^' | '$' +Dup = '*' | '+' | '?' | '{' Count '}' | '{' Count ',}' | '{' Count ',' Count '}' + +(a*+?, ^*, $+, \X, {, (|a) are unspecified) +*/ + +func _parse_atom(tls *TLS, ctx uintptr, s uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, ere, i, len1, v, val, v16 int32 + var err Treg_errcode_t + var node, p, tmp1, tmp11, tmp2, tmp21, v14 uintptr + var _ /* wc at bp+0 */ Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, ere, err, i, len1, node, p, tmp1, tmp11, tmp2, tmp21, v, val, v14, v16 + ere = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags & int32(REG_EXTENDED) + switch Int32FromUint8(**(**uint8)(__ccgo_up(s))) { + case int32('['): + goto _1 + case int32('\\'): + goto _2 + case int32('.'): + goto _3 + case int32('^'): + goto _4 + case int32('$'): + goto _5 + case int32('?'): + goto _6 + case int32('+'): + goto _7 + case int32('{'): + goto _8 + case int32('*'): + goto _9 + case int32('|'): + goto _10 + case 0: + goto _11 + default: + goto _12 + } + goto _13 +_1: + ; + return _parse_bracket(tls, ctx, s+uintptr(1)) +_2: + ; + p = _tre_expand_macro(tls, s+uintptr(1)) + if p != 0 { + /* assume \X expansion is a single atom */ + err = _parse_atom(tls, ctx, p) + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fs = s + uintptr(2) + return err + } + /* extensions: \b, \B, \<, \>, \xHH \x{HHHH} */ + s = s + 1 + v14 = s + switch Int32FromUint8(**(**uint8)(__ccgo_up(v14))) { + case 0: + return int32(REG_EESCAPE) + case int32('b'): + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_WB), -int32(1)) + case int32('B'): + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_WB_NEG), -int32(1)) + case int32('<'): + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_BOW), -int32(1)) + case int32('>'): + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_EOW), -int32(1)) + case int32('x'): + s = s + 1 + v = 0 + len1 = int32(2) + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('{') { + len1 = int32(8) + s = s + 1 + } + i = 0 + for { + if !(i < len1 && v < int32(0x110000)) { + break + } + c = _hexval1(tls, uint32(**(**uint8)(__ccgo_up(s + uintptr(i))))) + if c < 0 { + break + } + v = int32(16)*v + c + goto _15 + _15: + ; + i = i + 1 + } + s = s + uintptr(i) + if len1 == int32(8) { + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('}') { + return int32(REG_EBRACE) + } + s = s + 1 + } + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, v, v, v16) + s = s - 1 + case int32('{'): + fallthrough + case int32('+'): + fallthrough + case int32('?'): + /* extension: treat \+, \? as repetitions in BRE */ + /* reject repetitions after empty expression in BRE */ + if !(ere != 0) { + return int32(REG_BADRPT) + } + fallthrough + case int32('|'): + /* extension: treat \| as alternation in BRE */ + if !(ere != 0) { + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + s = s - 1 + goto end + } + /* fallthrough */ + fallthrough + default: + if !(ere != 0) && uint32(**(**uint8)(__ccgo_up(s)))-uint32('1') < uint32(9) { + /* back reference */ + val = Int32FromUint8(**(**uint8)(__ccgo_up(s))) - int32('0') + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(4), val, v16) + if val >= (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmax_backref { + v16 = val + } else { + v16 = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmax_backref + } + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmax_backref = v16 + } else { + /* extension: accept unknown escaped char + as a literal */ + goto parse_literal + } + } + s = s + 1 + goto _13 +_3: + ; + if (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags&int32(REG_NEWLINE) != 0 { + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + tmp1 = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, 0, Int32FromUint8('\n')-Int32FromInt32(1), v16) + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + tmp2 = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, Int32FromUint8('\n')+Int32FromInt32(1), int32(TRE_CHAR_MAX), v16) + if tmp1 != 0 && tmp2 != 0 { + node = _tre_ast_new_union(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, tmp1, tmp2) + } else { + node = uintptr(0) + } + } else { + v14 = ctx + 44 + v16 = *(*int32)(unsafe.Pointer(v14)) + *(*int32)(unsafe.Pointer(v14)) = *(*int32)(unsafe.Pointer(v14)) + 1 + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, 0, int32(TRE_CHAR_MAX), v16) + } + s = s + 1 + goto _13 +_4: + ; + /* '^' has a special meaning everywhere in EREs, and at beginning of BRE. */ + if !(ere != 0) && s != (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart { + goto parse_literal + } + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_BOL), -int32(1)) + s = s + 1 + goto _13 +_5: + ; + /* '$' is special everywhere in EREs, and at the end of a BRE subexpression. */ + if !(ere != 0) && **(**uint8)(__ccgo_up(s + 1)) != 0 && (Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) != int32('\\') || Int32FromUint8(**(**uint8)(__ccgo_up(s + 2))) != int32(')') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 2))) != int32('|')) { + goto parse_literal + } + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(2), int32(ASSERT_AT_EOL), -int32(1)) + s = s + 1 + goto _13 +_9: + ; +_8: + ; +_7: + ; +_6: + ; + /* reject repetitions after empty expression in ERE */ + if ere != 0 { + return int32(REG_BADRPT) + } +_10: + ; + if !(ere != 0) { + goto parse_literal + } +_11: + ; + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + goto _13 +_12: + ; + goto parse_literal +parse_literal: + ; + len1 = Xmbtowc(tls, bp, s, Uint64FromInt32(-Int32FromInt32(1))) + if len1 < 0 { + return int32(REG_BADPAT) + } + if (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags&int32(REG_ICASE) != 0 && (Xiswupper(tls, **(**Twchar_t)(__ccgo_up(bp))) != 0 || Xiswlower(tls, **(**Twchar_t)(__ccgo_up(bp))) != 0) { + /* multiple opposite case characters are not supported */ + tmp11 = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, Int32FromUint32(Xtowupper(tls, **(**Twchar_t)(__ccgo_up(bp)))), Int32FromUint32(Xtowupper(tls, **(**Twchar_t)(__ccgo_up(bp)))), (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition) + tmp21 = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, Int32FromUint32(Xtowlower(tls, **(**Twchar_t)(__ccgo_up(bp)))), Int32FromUint32(Xtowlower(tls, **(**Twchar_t)(__ccgo_up(bp)))), (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition) + if tmp11 != 0 && tmp21 != 0 { + node = _tre_ast_new_union(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, tmp11, tmp21) + } else { + node = uintptr(0) + } + } else { + node = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, Int32FromUint32(**(**Twchar_t)(__ccgo_up(bp))), Int32FromUint32(**(**Twchar_t)(__ccgo_up(bp))), (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition) + } + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fposition + 1 + s = s + uintptr(len1) + goto _13 +_13: + ; + goto end +end: + ; + if !(node != 0) { + return int32(REG_ESPACE) + } + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = node + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fs = s + return REG_OK +} + +func _tre_parse(tls *TLS, ctx uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c, depth, ere, subid, v2 int32 + var err, v1 Treg_errcode_t + var nbranch, nunion, s, stack, v8 uintptr + var _ /* max at bp+4 */ int32 + var _ /* min at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _ = c, depth, ere, err, nbranch, nunion, s, stack, subid, v1, v2, v8 + nbranch = uintptr(0) + nunion = uintptr(0) + ere = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fcflags & int32(REG_EXTENDED) + s = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart + subid = 0 + depth = 0 + stack = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstack + v2 = subid + subid = subid + 1 + v1 = _tre_stack_push_int(tls, stack, v2) + err = v1 + if v1 != REG_OK { + return err + } + for { + if !(ere != 0) && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('\\') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) == int32('(') || ere != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('(') { + v1 = _tre_stack_push_voidptr(tls, stack, nunion) + err = v1 + if v1 != REG_OK { + return err + } + v1 = _tre_stack_push_voidptr(tls, stack, nbranch) + err = v1 + if v1 != REG_OK { + return err + } + v2 = subid + subid = subid + 1 + v1 = _tre_stack_push_int(tls, stack, v2) + err = v1 + if v1 != REG_OK { + return err + } + s = s + 1 + if !(ere != 0) { + s = s + 1 + } + depth = depth + 1 + v8 = UintptrFromInt32(0) + nunion = v8 + nbranch = v8 + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart = s + goto _3 + } + if !(ere != 0) && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('\\') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) == int32(')') || ere != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32(')') && depth != 0 { + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + if !((*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn != 0) { + return int32(REG_ESPACE) + } + } else { + err = _parse_atom(tls, ctx, s) + if err != REG_OK { + return err + } + s = (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fs + } + goto parse_iter + parse_iter: + ; + for { + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('\\') && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('*') { + if !(ere != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('+') && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('?') && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != int32('{') { + break + } + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('\\') && ere != 0 { + break + } + /* extension: treat \+, \? as repetitions in BRE */ + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('\\') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) != int32('+') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) != int32('?') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) != int32('{') { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('\\') { + s = s + 1 + } + /* handle ^* at the start of a BRE. */ + if !(ere != 0) && s == (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart+uintptr(1) && Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(-Int32FromInt32(1))))) == int32('^') { + break + } + /* extension: multiple consecutive *+?{,} is unspecified, + but (a+)+ has to be supported so accepting a++ makes + sense, note however that the RE_DUP_MAX limit can be + circumvented: (a{255}){255} uses a lot of memory.. */ + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('{') { + s = _parse_dup(tls, s+uintptr(1), ere, bp, bp+4) + if !(s != 0) { + return int32(REG_BADBR) + } + } else { + **(**int32)(__ccgo_up(bp)) = 0 + **(**int32)(__ccgo_up(bp + 4)) = -int32(1) + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('+') { + **(**int32)(__ccgo_up(bp)) = int32(1) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('?') { + **(**int32)(__ccgo_up(bp + 4)) = int32(1) + } + s = s + 1 + } + if **(**int32)(__ccgo_up(bp + 4)) == 0 { + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = _tre_ast_new_literal(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, -int32(1), -int32(1), -int32(1)) + } else { + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn = _tre_ast_new_iter(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4)), 0) + } + if !((*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn != 0) { + return int32(REG_ESPACE) + } + goto _9 + _9: + } + nbranch = _tre_ast_new_catenation(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, nbranch, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fn) + if ere != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('|') || ere != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32(')') && depth != 0 || !(ere != 0) && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('\\') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) == int32(')') || !(ere != 0) && Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('\\') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) == int32('|') || !(**(**uint8)(__ccgo_up(s)) != 0) { + /* extension: empty branch is unspecified (), (|a), (a|) + here they are not rejected but match on empty string */ + c = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + nunion = _tre_ast_new_union(tls, (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fmem, nunion, nbranch) + nbranch = uintptr(0) + if c == int32('\\') && Int32FromUint8(**(**uint8)(__ccgo_up(s + 1))) == int32('|') { + s = s + uintptr(2) + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart = s + } else { + if c == int32('|') { + s = s + 1 + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fstart = s + } else { + if c == int32('\\') { + if !(depth != 0) { + return int32(REG_EPAREN) + } + s = s + uintptr(2) + } else { + if c == int32(')') { + s = s + 1 + } + } + depth = depth - 1 + err = _marksub(tls, ctx, nunion, _tre_stack_pop_int(tls, stack)) + if err != REG_OK { + return err + } + if !(c != 0) && depth < 0 { + (*Ttre_parse_ctx_t)(unsafe.Pointer(ctx)).Fsubmatch_id = subid + return REG_OK + } + if !(c != 0) || depth < 0 { + return int32(REG_EPAREN) + } + nbranch = _tre_stack_pop_voidptr(tls, stack) + nunion = _tre_stack_pop_voidptr(tls, stack) + goto parse_iter + } + } + } + goto _3 + _3: + } + return r +} + +/*********************************************************************** + from tre-compile.c +***********************************************************************/ + +/* + TODO: + - Fix tre_ast_to_tnfa() to recurse using a stack instead of recursive + function calls. +*/ + +/* + Algorithms to setup tags so that submatch addressing can be done. +*/ + +// C documentation +// +// /* Inserts a catenation node to the root of the tree given in `node'. +// As the left child a new tag with number `tag_id' to `node' is added, +// and the right child is the old root. */ +func _tre_add_tag_left(tls *TLS, mem Ttre_mem_t, node uintptr, tag_id int32) (r Treg_errcode_t) { + var c uintptr + _ = c + c = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(16)) + if c == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft = _tre_ast_new_literal(tls, mem, -int32(3), tag_id, -int32(1)) + if (*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_catenation_t)(unsafe.Pointer(c)).Fright = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(48)) + if (*Ttre_catenation_t)(unsafe.Pointer(c)).Fright == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fobj = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Ftype1 = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fnullable = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fsubmatch_id = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Ffirstpos = UintptrFromInt32(0) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Flastpos = UintptrFromInt32(0) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fnum_tags = 0 + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fright)).Fnum_submatches = 0 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj = c + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 = int32(_CATENATION) + return REG_OK +} + +// C documentation +// +// /* Inserts a catenation node to the root of the tree given in `node'. +// As the right child a new tag with number `tag_id' to `node' is added, +// and the left child is the old root. */ +func _tre_add_tag_right(tls *TLS, mem Ttre_mem_t, node uintptr, tag_id int32) (r Treg_errcode_t) { + var c uintptr + _ = c + c = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(16)) + if c == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_catenation_t)(unsafe.Pointer(c)).Fright = _tre_ast_new_literal(tls, mem, -int32(3), tag_id, -int32(1)) + if (*Ttre_catenation_t)(unsafe.Pointer(c)).Fright == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(48)) + if (*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fobj = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Ftype1 = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fnullable = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fsubmatch_id = -int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Ffirstpos = UintptrFromInt32(0) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Flastpos = UintptrFromInt32(0) + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fnum_tags = 0 + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(c)).Fleft)).Fnum_submatches = 0 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj = c + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 = int32(_CATENATION) + return REG_OK +} + +type Ttre_addtags_symbol_t = int32 + +const _ADDTAGS_RECURSE = 0 +const _ADDTAGS_AFTER_ITERATION = 1 +const _ADDTAGS_AFTER_UNION_LEFT = 2 +const _ADDTAGS_AFTER_UNION_RIGHT = 3 +const _ADDTAGS_AFTER_CAT_LEFT = 4 +const _ADDTAGS_AFTER_CAT_RIGHT = 5 +const _ADDTAGS_SET_SUBMATCH_END = 6 + +type Ttre_tag_states_t = struct { + Ftag int32 + Fnext_tag int32 +} + +// C documentation +// +// /* Go through `regset' and set submatch data for submatches that are +// using this tag. */ +func _tre_purge_regset(tls *TLS, regset uintptr, tnfa uintptr, tag int32) { + var i, id, start int32 + _, _, _ = i, id, start + i = 0 + for { + if !(**(**int32)(__ccgo_up(regset + uintptr(i)*4)) >= 0) { + break + } + id = **(**int32)(__ccgo_up(regset + uintptr(i)*4)) / int32(2) + start = BoolInt32(!(**(**int32)(__ccgo_up(regset + uintptr(i)*4))%Int32FromInt32(2) != 0)) + if start != 0 { + (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(id)*16))).Fso_tag = tag + } else { + (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(id)*16))).Feo_tag = tag + } + goto _1 + _1: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(regset)) = -int32(1) +} + +// C documentation +// +// /* Adds tags to appropriate locations in the parse tree in `tree', so that +// subexpressions marked for submatch addressing can be traced. */ +func _tre_add_tags(tls *TLS, mem Ttre_mem_t, stack uintptr, tree uintptr, tnfa uintptr) (r Treg_errcode_t) { + var added_tags, bottom, enter_tag, first_pass, i1, i2, i3, i4, i5, i6, i7, id, id1, left_tag, minimal, minimal_tag, new_tag, next_tag, num_minimals, num_tags, reserved_tag, right_tag, tag, tag_left, tag_right, v22 int32 + var cat, iter, left, left1, left2, lit, node, orig_regset, p, parents, regset, right, right1, right2, saved_states, uni uintptr + var direction Ttre_tag_direction_t + var i uint32 + var status Treg_errcode_t + var symbol Ttre_addtags_symbol_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = added_tags, bottom, cat, direction, enter_tag, first_pass, i, i1, i2, i3, i4, i5, i6, i7, id, id1, iter, left, left1, left2, left_tag, lit, minimal, minimal_tag, new_tag, next_tag, node, num_minimals, num_tags, orig_regset, p, parents, regset, reserved_tag, right, right1, right2, right_tag, saved_states, status, symbol, tag, tag_left, tag_right, uni, v22 + status = REG_OK + node = tree /* Tree node we are currently looking at. */ + bottom = _tre_stack_num_objects(tls, stack) + /* True for first pass (counting number of needed tags) */ + first_pass = BoolInt32(mem == UintptrFromInt32(0) || tnfa == UintptrFromInt32(0)) + num_tags = 0 /* Total number of tags. */ + num_minimals = 0 /* Number of special minimal tags. */ + tag = 0 /* The tag that is to be added next. */ + next_tag = int32(1) /* Stack of submatches the current submatch is + contained in. */ + minimal_tag = -int32(1) + direction = int32(_TRE_TAG_MINIMIZE) + if !(first_pass != 0) { + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fend_tag = 0 + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags)) = -int32(1) + } + regset = Xmalloc(tls, uint64(4)*uint64(((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches+Uint32FromInt32(1))*Uint32FromInt32(2))) + if regset == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + **(**int32)(__ccgo_up(regset)) = -int32(1) + orig_regset = regset + parents = Xmalloc(tls, uint64(4)*uint64((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches+Uint32FromInt32(1))) + if parents == UintptrFromInt32(0) { + Xfree(tls, regset) + return int32(REG_ESPACE) + } + **(**int32)(__ccgo_up(parents)) = -int32(1) + saved_states = Xmalloc(tls, uint64(8)*uint64((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches+Uint32FromInt32(1))) + if saved_states == UintptrFromInt32(0) { + Xfree(tls, regset) + Xfree(tls, parents) + return int32(REG_ESPACE) + } else { + i = uint32(0) + for { + if !(i <= (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches) { + break + } + (**(**Ttre_tag_states_t)(__ccgo_up(saved_states + uintptr(i)*8))).Ftag = -int32(1) + goto _1 + _1: + ; + i = i + 1 + } + } + status = _tre_stack_push_voidptr(tls, stack, node) + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + for _tre_stack_num_objects(tls, stack) > bottom { + if status != REG_OK { + break + } + symbol = _tre_stack_pop_int(tls, stack) + switch symbol { + case int32(_ADDTAGS_SET_SUBMATCH_END): + goto _2 + case int32(_ADDTAGS_RECURSE): + goto _3 + case int32(_ADDTAGS_AFTER_ITERATION): + goto _4 + case int32(_ADDTAGS_AFTER_CAT_LEFT): + goto _5 + case int32(_ADDTAGS_AFTER_CAT_RIGHT): + goto _6 + case int32(_ADDTAGS_AFTER_UNION_LEFT): + goto _7 + case int32(_ADDTAGS_AFTER_UNION_RIGHT): + goto _8 + default: + goto _9 + } + goto _10 + _2: + ; + id = _tre_stack_pop_int(tls, stack) + /* Add end of this submatch to regset. */ + i1 = 0 + for { + if !(**(**int32)(__ccgo_up(regset + uintptr(i1)*4)) >= 0) { + break + } + goto _11 + _11: + ; + i1 = i1 + 1 + } + **(**int32)(__ccgo_up(regset + uintptr(i1)*4)) = id*int32(2) + int32(1) + **(**int32)(__ccgo_up(regset + uintptr(i1+int32(1))*4)) = -int32(1) + /* Pop this submatch from the parents stack. */ + i1 = 0 + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(i1)*4)) >= 0) { + break + } + goto _12 + _12: + ; + i1 = i1 + 1 + } + **(**int32)(__ccgo_up(parents + uintptr(i1-int32(1))*4)) = -int32(1) + goto _10 + _3: + ; + node = _tre_stack_pop_voidptr(tls, stack) + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id >= 0 { + id1 = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id + /* Add start of this submatch to regset. */ + i2 = 0 + for { + if !(**(**int32)(__ccgo_up(regset + uintptr(i2)*4)) >= 0) { + break + } + goto _13 + _13: + ; + i2 = i2 + 1 + } + **(**int32)(__ccgo_up(regset + uintptr(i2)*4)) = id1 * int32(2) + **(**int32)(__ccgo_up(regset + uintptr(i2+int32(1))*4)) = -int32(1) + if !(first_pass != 0) { + i2 = 0 + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(i2)*4)) >= 0) { + break + } + goto _14 + _14: + ; + i2 = i2 + 1 + } + (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(id1)*16))).Fparents = UintptrFromInt32(0) + if i2 > 0 { + p = Xmalloc(tls, uint64(4)*Uint64FromInt32(i2+Int32FromInt32(1))) + if p == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + goto _10 + } + (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(id1)*16))).Fparents = p + i2 = 0 + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(i2)*4)) >= 0) { + break + } + **(**int32)(__ccgo_up(p + uintptr(i2)*4)) = **(**int32)(__ccgo_up(parents + uintptr(i2)*4)) + goto _15 + _15: + ; + i2 = i2 + 1 + } + **(**int32)(__ccgo_up(p + uintptr(i2)*4)) = -int32(1) + } + } + /* Add end of this submatch to regset after processing this + node. */ + status = _tre_stack_push_int(tls, stack, (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id) + if status != REG_OK { + goto _10 + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_SET_SUBMATCH_END)) + if status != REG_OK { + goto _10 + } + } + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if !((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min < Int64FromInt32(0)) || (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(4)) { + if **(**int32)(__ccgo_up(regset)) >= 0 { + /* Regset is not empty, so add a tag before the + literal or backref. */ + if !(first_pass != 0) { + status = _tre_add_tag_left(tls, mem, node, tag) + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag)*4)) = direction + if minimal_tag >= 0 { + i3 = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i3)*4)) >= 0) { + break + } + goto _16 + _16: + ; + i3 = i3 + 1 + } + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i3)*4)) = tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i3+int32(1))*4)) = minimal_tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i3+int32(2))*4)) = -int32(1) + minimal_tag = -int32(1) + num_minimals = num_minimals + 1 + } + _tre_purge_regset(tls, regset, tnfa, tag) + } else { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_tags = int32(1) + } + **(**int32)(__ccgo_up(regset)) = -int32(1) + tag = next_tag + num_tags = num_tags + 1 + next_tag = next_tag + 1 + } + } else { + } + case int32(_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + left = (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft + right = (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright + reserved_tag = -int32(1) + /* After processing right child. */ + status = _tre_stack_push_voidptr(tls, stack, node) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_CAT_RIGHT)) + if status != REG_OK { + break + } + /* Process right child. */ + status = _tre_stack_push_voidptr(tls, stack, right) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + /* After processing left child. */ + status = _tre_stack_push_int(tls, stack, next_tag+(*Ttre_ast_node_t)(unsafe.Pointer(left)).Fnum_tags) + if status != REG_OK { + break + } + if (*Ttre_ast_node_t)(unsafe.Pointer(left)).Fnum_tags > 0 && (*Ttre_ast_node_t)(unsafe.Pointer(right)).Fnum_tags > 0 { + /* Reserve the next tag to the right child. */ + reserved_tag = next_tag + next_tag = next_tag + 1 + } + status = _tre_stack_push_int(tls, stack, reserved_tag) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_CAT_LEFT)) + if status != REG_OK { + break + } + /* Process left child. */ + status = _tre_stack_push_voidptr(tls, stack, left) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + case int32(_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if first_pass != 0 { + status = _tre_stack_push_int(tls, stack, BoolInt32(**(**int32)(__ccgo_up(regset)) >= 0 || int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0)) != 0)) + if status != REG_OK { + break + } + } else { + status = _tre_stack_push_int(tls, stack, tag) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0))) + if status != REG_OK { + break + } + } + status = _tre_stack_push_voidptr(tls, stack, node) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_ITERATION)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + /* Regset is not empty, so add a tag here. */ + if **(**int32)(__ccgo_up(regset)) >= 0 || int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0)) != 0 { + if !(first_pass != 0) { + status = _tre_add_tag_left(tls, mem, node, tag) + if int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0)) != 0 { + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag)*4)) = int32(_TRE_TAG_MAXIMIZE) + } else { + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag)*4)) = direction + } + if minimal_tag >= 0 { + i4 = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i4)*4)) >= 0) { + break + } + goto _17 + _17: + ; + i4 = i4 + 1 + } + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i4)*4)) = tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i4+int32(1))*4)) = minimal_tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i4+int32(2))*4)) = -int32(1) + minimal_tag = -int32(1) + num_minimals = num_minimals + 1 + } + _tre_purge_regset(tls, regset, tnfa, tag) + } + **(**int32)(__ccgo_up(regset)) = -int32(1) + tag = next_tag + num_tags = num_tags + 1 + next_tag = next_tag + 1 + } + direction = int32(_TRE_TAG_MINIMIZE) + case int32(_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + left1 = (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft + right1 = (*Ttre_union_t)(unsafe.Pointer(uni)).Fright + if **(**int32)(__ccgo_up(regset)) >= 0 { + left_tag = next_tag + right_tag = next_tag + int32(1) + } else { + left_tag = tag + right_tag = next_tag + } + /* After processing right child. */ + status = _tre_stack_push_int(tls, stack, right_tag) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, left_tag) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, regset) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, BoolInt32(**(**int32)(__ccgo_up(regset)) >= 0)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, node) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, right1) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, left1) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_UNION_RIGHT)) + if status != REG_OK { + break + } + /* Process right child. */ + status = _tre_stack_push_voidptr(tls, stack, right1) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + /* After processing left child. */ + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_AFTER_UNION_LEFT)) + if status != REG_OK { + break + } + /* Process left child. */ + status = _tre_stack_push_voidptr(tls, stack, left1) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_ADDTAGS_RECURSE)) + if status != REG_OK { + break + } + /* Regset is not empty, so add a tag here. */ + if **(**int32)(__ccgo_up(regset)) >= 0 { + if !(first_pass != 0) { + status = _tre_add_tag_left(tls, mem, node, tag) + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag)*4)) = direction + if minimal_tag >= 0 { + i5 = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i5)*4)) >= 0) { + break + } + goto _18 + _18: + ; + i5 = i5 + 1 + } + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i5)*4)) = tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i5+int32(1))*4)) = minimal_tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i5+int32(2))*4)) = -int32(1) + minimal_tag = -int32(1) + num_minimals = num_minimals + 1 + } + _tre_purge_regset(tls, regset, tnfa, tag) + } + **(**int32)(__ccgo_up(regset)) = -int32(1) + tag = next_tag + num_tags = num_tags + 1 + next_tag = next_tag + 1 + } + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches > 0 { + /* The next two tags are reserved for markers. */ + next_tag = next_tag + 1 + tag = next_tag + next_tag = next_tag + 1 + } + break + } + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id >= 0 { + /* Push this submatch on the parents stack. */ + i6 = 0 + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(i6)*4)) >= 0) { + break + } + goto _19 + _19: + ; + i6 = i6 + 1 + } + **(**int32)(__ccgo_up(parents + uintptr(i6)*4)) = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fsubmatch_id + **(**int32)(__ccgo_up(parents + uintptr(i6+int32(1))*4)) = -int32(1) + } + goto _10 /* end case: ADDTAGS_RECURSE */ + _4: + ; + minimal = 0 + node = _tre_stack_pop_voidptr(tls, stack) + if first_pass != 0 { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_tags = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Farg)).Fnum_tags + _tre_stack_pop_int(tls, stack) + minimal_tag = -int32(1) + } else { + minimal = _tre_stack_pop_int(tls, stack) + enter_tag = _tre_stack_pop_int(tls, stack) + if minimal != 0 { + minimal_tag = enter_tag + } + } + if !(first_pass != 0) { + if minimal != 0 { + direction = int32(_TRE_TAG_MINIMIZE) + } else { + direction = int32(_TRE_TAG_MAXIMIZE) + } + } + goto _10 + _5: + ; + new_tag = _tre_stack_pop_int(tls, stack) + next_tag = _tre_stack_pop_int(tls, stack) + if new_tag >= 0 { + tag = new_tag + } + goto _10 + _6: + ; + node = _tre_stack_pop_voidptr(tls, stack) + if first_pass != 0 { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_tags = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fleft)).Fnum_tags + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fright)).Fnum_tags + } + goto _10 + _7: + ; + /* Lift the bottom of the `regset' array so that when processing + the right operand the items currently in the array are + invisible. The original bottom was saved at ADDTAGS_UNION and + will be restored at ADDTAGS_AFTER_UNION_RIGHT below. */ + _21: + ; + if !(**(**int32)(__ccgo_up(regset)) >= 0) { + goto _20 + } + regset += 4 + goto _21 + _20: + ; + goto _10 + _8: + ; + left2 = _tre_stack_pop_voidptr(tls, stack) + right2 = _tre_stack_pop_voidptr(tls, stack) + node = _tre_stack_pop_voidptr(tls, stack) + added_tags = _tre_stack_pop_int(tls, stack) + if first_pass != 0 { + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches > 0 { + v22 = int32(2) + } else { + v22 = 0 + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_tags = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fleft)).Fnum_tags + (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fright)).Fnum_tags + added_tags + v22 + } + regset = _tre_stack_pop_voidptr(tls, stack) + tag_left = _tre_stack_pop_int(tls, stack) + tag_right = _tre_stack_pop_int(tls, stack) + /* Add tags after both children, the left child gets a smaller + tag than the right child. This guarantees that we prefer + the left child over the right child. */ + /* XXX - This is not always necessary (if the children have + tags which must be seen for every match of that child). */ + /* XXX - Check if this is the only place where tre_add_tag_right + is used. If so, use tre_add_tag_left (putting the tag before + the child as opposed after the child) and throw away + tre_add_tag_right. */ + if (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnum_submatches > 0 { + if !(first_pass != 0) { + status = _tre_add_tag_right(tls, mem, left2, tag_left) + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag_left)*4)) = int32(_TRE_TAG_MAXIMIZE) + if status == REG_OK { + status = _tre_add_tag_right(tls, mem, right2, tag_right) + } + **(**Ttre_tag_direction_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions + uintptr(tag_right)*4)) = int32(_TRE_TAG_MAXIMIZE) + } + num_tags = num_tags + int32(2) + } + direction = int32(_TRE_TAG_MAXIMIZE) + goto _10 + _9: + ; + goto _10 + _10: + /* end switch(symbol) */ + } /* end while(tre_stack_num_objects(stack) > bottom) */ + if !(first_pass != 0) { + _tre_purge_regset(tls, regset, tnfa, tag) + } + if !(first_pass != 0) && minimal_tag >= 0 { + i7 = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i7)*4)) >= 0) { + break + } + goto _23 + _23: + ; + i7 = i7 + 1 + } + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i7)*4)) = tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i7+int32(1))*4)) = minimal_tag + **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i7+int32(2))*4)) = -int32(1) + minimal_tag = -int32(1) + num_minimals = num_minimals + 1 + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fend_tag = num_tags + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags = num_tags + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_minimals = num_minimals + Xfree(tls, orig_regset) + Xfree(tls, parents) + Xfree(tls, saved_states) + return status +} + +/* + AST to TNFA compilation routines. +*/ + +type Ttre_copyast_symbol_t = int32 + +const _COPY_RECURSE = 0 +const _COPY_SET_RESULT_PTR = 1 + +/* Flags for tre_copy_ast(). */ + +func _tre_copy_ast(tls *TLS, mem Ttre_mem_t, stack uintptr, ast uintptr, flags int32, pos_add uintptr, tag_directions uintptr, copy1 uintptr, max_pos uintptr) (r Treg_errcode_t) { + var bottom, first_tag, max, min, num_copied, pos, v1 int32 + var cat, iter, lit, node, p, result, tmp, tmp1, uni uintptr + var status Treg_errcode_t + var symbol Ttre_copyast_symbol_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bottom, cat, first_tag, iter, lit, max, min, node, num_copied, p, pos, result, status, symbol, tmp, tmp1, uni, v1 + status = REG_OK + bottom = _tre_stack_num_objects(tls, stack) + num_copied = 0 + first_tag = int32(1) + result = copy1 + status = _tre_stack_push_voidptr(tls, stack, ast) + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + for status == REG_OK && _tre_stack_num_objects(tls, stack) > bottom { + if status != REG_OK { + break + } + symbol = _tre_stack_pop_int(tls, stack) + switch symbol { + case int32(_COPY_SET_RESULT_PTR): + result = _tre_stack_pop_voidptr(tls, stack) + case int32(_COPY_RECURSE): + node = _tre_stack_pop_voidptr(tls, stack) + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + pos = (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition + min = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min) + max = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max) + if !((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min < Int64FromInt32(0)) || (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(4)) { + /* XXX - e.g. [ab] has only one position but two + nodes, so we are creating holes in the state space + here. Not fatal, just wastes memory. */ + pos = pos + **(**int32)(__ccgo_up(pos_add)) + num_copied = num_copied + 1 + } else { + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(3)) && flags&int32(COPY_REMOVE_TAGS) != 0 { + /* Change this tag to empty. */ + min = -int32(1) + v1 = -Int32FromInt32(1) + pos = v1 + max = v1 + } else { + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(3)) && flags&int32(COPY_MAXIMIZE_FIRST_TAG) != 0 && first_tag != 0 { + /* Maximize the first tag. */ + **(**Ttre_tag_direction_t)(__ccgo_up(tag_directions + uintptr(max)*4)) = int32(_TRE_TAG_MAXIMIZE) + first_tag = 0 + } + } + } + **(**uintptr)(__ccgo_up(result)) = _tre_ast_new_literal(tls, mem, min, max, pos) + if **(**uintptr)(__ccgo_up(result)) == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + } else { + p = (*Ttre_ast_node_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(result)))).Fobj + (*Ttre_literal_t)(unsafe.Pointer(p)).Fclass = (*Ttre_literal_t)(unsafe.Pointer(lit)).Fclass + (*Ttre_literal_t)(unsafe.Pointer(p)).Fneg_classes = (*Ttre_literal_t)(unsafe.Pointer(lit)).Fneg_classes + } + if pos > **(**int32)(__ccgo_up(max_pos)) { + **(**int32)(__ccgo_up(max_pos)) = pos + } + case int32(_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + **(**uintptr)(__ccgo_up(result)) = _tre_ast_new_union(tls, mem, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright) + if **(**uintptr)(__ccgo_up(result)) == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + break + } + tmp = (*Ttre_ast_node_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(result)))).Fobj + result = tmp + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, tmp+8) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_SET_RESULT_PTR)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + case int32(_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + **(**uintptr)(__ccgo_up(result)) = _tre_ast_new_catenation(tls, mem, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright) + if **(**uintptr)(__ccgo_up(result)) == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + break + } + tmp1 = (*Ttre_ast_node_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(result)))).Fobj + (*Ttre_catenation_t)(unsafe.Pointer(tmp1)).Fleft = UintptrFromInt32(0) + (*Ttre_catenation_t)(unsafe.Pointer(tmp1)).Fright = UintptrFromInt32(0) + result = tmp1 + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, tmp1+8) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_SET_RESULT_PTR)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + case int32(_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_COPY_RECURSE)) + if status != REG_OK { + break + } + **(**uintptr)(__ccgo_up(result)) = _tre_ast_new_iter(tls, mem, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmin, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmax, int32(uint32(*(*uint8)(unsafe.Pointer(iter + 16))&0x1>>0))) + if **(**uintptr)(__ccgo_up(result)) == UintptrFromInt32(0) { + status = int32(REG_ESPACE) + break + } + iter = (*Ttre_ast_node_t)(unsafe.Pointer(**(**uintptr)(__ccgo_up(result)))).Fobj + result = iter + default: + break + } + break + } + } + **(**int32)(__ccgo_up(pos_add)) += num_copied + return status +} + +type Ttre_expand_ast_symbol_t = int32 + +const _EXPAND_RECURSE = 0 +const _EXPAND_AFTER_ITER = 1 + +// C documentation +// +// /* Expands each iteration node that has a finite nonzero minimum or maximum +// iteration count to a catenated sequence of copies of the node. */ +func _tre_expand_ast(tls *TLS, mem Ttre_mem_t, stack uintptr, ast uintptr, position uintptr, tag_directions uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var _status, _status1, status Treg_errcode_t + var bottom, flags, iter_depth, j, pos_add_last, pos_add_save, pos_add_total, v2 int32 + var cat, iter, iter1, lit, node, seq1, tmp, uni uintptr + var symbol Ttre_expand_ast_symbol_t + var _ /* copy at bp+16 */ uintptr + var _ /* copy at bp+24 */ uintptr + var _ /* max_pos at bp+4 */ int32 + var _ /* pos_add at bp+0 */ int32 + var _ /* seq2 at bp+8 */ uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _status, _status1, bottom, cat, flags, iter, iter1, iter_depth, j, lit, node, pos_add_last, pos_add_save, pos_add_total, seq1, status, symbol, tmp, uni, v2 + status = REG_OK + bottom = _tre_stack_num_objects(tls, stack) + **(**int32)(__ccgo_up(bp)) = 0 + pos_add_total = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + iter_depth = 0 + _status = _tre_stack_push_voidptr(tls, stack, ast) + if _status != REG_OK { + return _status + } + _status1 = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if _status1 != REG_OK { + return _status1 + } + for status == REG_OK && _tre_stack_num_objects(tls, stack) > bottom { + if status != REG_OK { + break + } + symbol = _tre_stack_pop_int(tls, stack) + node = _tre_stack_pop_voidptr(tls, stack) + switch symbol { + case int32(_EXPAND_RECURSE): + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if !((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min < Int64FromInt32(0)) || (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(4)) { + **(**int32)(__ccgo_up(lit + 16)) += **(**int32)(__ccgo_up(bp)) + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition > **(**int32)(__ccgo_up(bp + 4)) { + **(**int32)(__ccgo_up(bp + 4)) = (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition + } + } + case int32(_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + case int32(_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + case int32(_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_int(tls, stack, **(**int32)(__ccgo_up(bp))) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, node) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_AFTER_ITER)) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg) + if status != REG_OK { + break + } + status = _tre_stack_push_int(tls, stack, int32(_EXPAND_RECURSE)) + if status != REG_OK { + break + } + /* If we are going to expand this node at EXPAND_AFTER_ITER + then don't increase the `pos' fields of the nodes now, it + will get done when expanding. */ + if (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmin > int32(1) || (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmax > int32(1) { + **(**int32)(__ccgo_up(bp)) = 0 + } + iter_depth = iter_depth + 1 + default: + break + } + case int32(_EXPAND_AFTER_ITER): + iter1 = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + **(**int32)(__ccgo_up(bp)) = _tre_stack_pop_int(tls, stack) + pos_add_last = **(**int32)(__ccgo_up(bp)) + if (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmin > int32(1) || (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmax > int32(1) { + seq1 = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(bp + 8)) = UintptrFromInt32(0) + pos_add_save = **(**int32)(__ccgo_up(bp)) + /* Create a catenated sequence of copies of the node. */ + j = 0 + for { + if !(j < (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmin) { + break + } + if j+int32(1) < (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmin { + v2 = int32(COPY_REMOVE_TAGS) + } else { + v2 = int32(COPY_MAXIMIZE_FIRST_TAG) + } + /* Remove tags from all but the last copy. */ + flags = v2 + pos_add_save = **(**int32)(__ccgo_up(bp)) + status = _tre_copy_ast(tls, mem, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Farg, flags, bp, tag_directions, bp+16, bp+4) + if status != REG_OK { + return status + } + if seq1 != UintptrFromInt32(0) { + seq1 = _tre_ast_new_catenation(tls, mem, seq1, **(**uintptr)(__ccgo_up(bp + 16))) + } else { + seq1 = **(**uintptr)(__ccgo_up(bp + 16)) + } + if seq1 == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + goto _1 + _1: + ; + j = j + 1 + } + if (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmax == -int32(1) { + /* No upper limit. */ + pos_add_save = **(**int32)(__ccgo_up(bp)) + status = _tre_copy_ast(tls, mem, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Farg, 0, bp, UintptrFromInt32(0), bp+8, bp+4) + if status != REG_OK { + return status + } + **(**uintptr)(__ccgo_up(bp + 8)) = _tre_ast_new_iter(tls, mem, **(**uintptr)(__ccgo_up(bp + 8)), 0, -int32(1), 0) + if **(**uintptr)(__ccgo_up(bp + 8)) == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + } else { + j = (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmin + for { + if !(j < (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Fmax) { + break + } + pos_add_save = **(**int32)(__ccgo_up(bp)) + status = _tre_copy_ast(tls, mem, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter1)).Farg, 0, bp, UintptrFromInt32(0), bp+24, bp+4) + if status != REG_OK { + return status + } + if **(**uintptr)(__ccgo_up(bp + 8)) != UintptrFromInt32(0) { + **(**uintptr)(__ccgo_up(bp + 8)) = _tre_ast_new_catenation(tls, mem, **(**uintptr)(__ccgo_up(bp + 24)), **(**uintptr)(__ccgo_up(bp + 8))) + } else { + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 24)) + } + if **(**uintptr)(__ccgo_up(bp + 8)) == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + tmp = _tre_ast_new_literal(tls, mem, -int32(1), -int32(1), -int32(1)) + if tmp == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + **(**uintptr)(__ccgo_up(bp + 8)) = _tre_ast_new_union(tls, mem, tmp, **(**uintptr)(__ccgo_up(bp + 8))) + if **(**uintptr)(__ccgo_up(bp + 8)) == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + goto _3 + _3: + ; + j = j + 1 + } + } + **(**int32)(__ccgo_up(bp)) = pos_add_save + if seq1 == UintptrFromInt32(0) { + seq1 = **(**uintptr)(__ccgo_up(bp + 8)) + } else { + if **(**uintptr)(__ccgo_up(bp + 8)) != UintptrFromInt32(0) { + seq1 = _tre_ast_new_catenation(tls, mem, seq1, **(**uintptr)(__ccgo_up(bp + 8))) + } + } + if seq1 == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj = (*Ttre_ast_node_t)(unsafe.Pointer(seq1)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 = (*Ttre_ast_node_t)(unsafe.Pointer(seq1)).Ftype1 + } + iter_depth = iter_depth - 1 + pos_add_total = pos_add_total + (**(**int32)(__ccgo_up(bp)) - pos_add_last) + if iter_depth == 0 { + **(**int32)(__ccgo_up(bp)) = pos_add_total + } + default: + break + } + } + **(**int32)(__ccgo_up(position)) += pos_add_total + /* `max_pos' should never be larger than `*position' if the above + code works, but just an extra safeguard let's make sure + `*position' is set large enough so enough memory will be + allocated for the transition table. */ + if **(**int32)(__ccgo_up(bp + 4)) > **(**int32)(__ccgo_up(position)) { + **(**int32)(__ccgo_up(position)) = **(**int32)(__ccgo_up(bp + 4)) + } + return status +} + +func _tre_set_empty(tls *TLS, mem Ttre_mem_t) (r uintptr) { + var new_set uintptr + _ = new_set + new_set = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(56)) + if new_set == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fposition = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fcode_min = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fcode_max = -int32(1) + return new_set +} + +func _tre_set_one(tls *TLS, mem Ttre_mem_t, position int32, code_min int32, code_max int32, class Ttre_ctype_t, neg_classes uintptr, backref int32) (r uintptr) { + var new_set uintptr + _ = new_set + new_set = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), Uint64FromInt64(56)*Uint64FromInt32(2)) + if new_set == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fposition = position + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fcode_min = code_min + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fcode_max = code_max + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fclass = class + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fneg_classes = neg_classes + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set))).Fbackref = backref + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + 1*56))).Fposition = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + 1*56))).Fcode_min = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + 1*56))).Fcode_max = -int32(1) + return new_set +} + +func _tre_set_union(tls *TLS, mem Ttre_mem_t, set1 uintptr, set2 uintptr, tags uintptr, assertions int32) (r uintptr) { + var i, j, num_tags, s1, s2 int32 + var new_set, new_tags uintptr + _, _, _, _, _, _, _ = i, j, new_set, new_tags, num_tags, s1, s2 + num_tags = 0 + for { + if !(tags != UintptrFromInt32(0) && **(**int32)(__ccgo_up(tags + uintptr(num_tags)*4)) >= 0) { + break + } + goto _1 + _1: + ; + num_tags = num_tags + 1 + } + s1 = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fposition >= 0) { + break + } + goto _2 + _2: + ; + s1 = s1 + 1 + } + s2 = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fposition >= 0) { + break + } + goto _3 + _3: + ; + s2 = s2 + 1 + } + new_set = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), int32(1), uint64(56)*Uint64FromInt32(s1+s2+Int32FromInt32(1))) + if !(new_set != 0) { + return UintptrFromInt32(0) + } + s1 = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fposition >= 0) { + break + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fposition = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fposition + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fcode_min = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fcode_min + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fcode_max = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fcode_max + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fassertions = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fassertions | assertions + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fclass = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fclass + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fneg_classes = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fneg_classes + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Fbackref = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Fbackref + if (**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Ftags == UintptrFromInt32(0) && tags == UintptrFromInt32(0) { + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Ftags = UintptrFromInt32(0) + } else { + i = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Ftags != UintptrFromInt32(0) && **(**int32)(__ccgo_up((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Ftags + uintptr(i)*4)) >= 0) { + break + } + goto _5 + _5: + ; + i = i + 1 + } + new_tags = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, Uint64FromInt64(4)*Uint64FromInt32(i+num_tags+Int32FromInt32(1))) + if new_tags == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + j = 0 + for { + if !(j < i) { + break + } + **(**int32)(__ccgo_up(new_tags + uintptr(j)*4)) = **(**int32)(__ccgo_up((**(**Ttre_pos_and_tags_t)(__ccgo_up(set1 + uintptr(s1)*56))).Ftags + uintptr(j)*4)) + goto _6 + _6: + ; + j = j + 1 + } + i = 0 + for { + if !(i < num_tags) { + break + } + **(**int32)(__ccgo_up(new_tags + uintptr(j+i)*4)) = **(**int32)(__ccgo_up(tags + uintptr(i)*4)) + goto _7 + _7: + ; + i = i + 1 + } + **(**int32)(__ccgo_up(new_tags + uintptr(j+i)*4)) = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1)*56))).Ftags = new_tags + } + goto _4 + _4: + ; + s1 = s1 + 1 + } + s2 = 0 + for { + if !((**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fposition >= 0) { + break + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fposition = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fposition + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fcode_min = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fcode_min + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fcode_max = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fcode_max + /* XXX - why not | assertions here as well? */ + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fassertions = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fassertions + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fclass = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fclass + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fneg_classes = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fneg_classes + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fbackref = (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Fbackref + if (**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Ftags == UintptrFromInt32(0) { + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Ftags = UintptrFromInt32(0) + } else { + i = 0 + for { + if !(**(**int32)(__ccgo_up((**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Ftags + uintptr(i)*4)) >= 0) { + break + } + goto _9 + _9: + ; + i = i + 1 + } + new_tags = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(4)*Uint64FromInt32(i+Int32FromInt32(1))) + if new_tags == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + j = 0 + for { + if !(j < i) { + break + } + **(**int32)(__ccgo_up(new_tags + uintptr(j)*4)) = **(**int32)(__ccgo_up((**(**Ttre_pos_and_tags_t)(__ccgo_up(set2 + uintptr(s2)*56))).Ftags + uintptr(j)*4)) + goto _10 + _10: + ; + j = j + 1 + } + **(**int32)(__ccgo_up(new_tags + uintptr(j)*4)) = -int32(1) + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Ftags = new_tags + } + goto _8 + _8: + ; + s2 = s2 + 1 + } + (**(**Ttre_pos_and_tags_t)(__ccgo_up(new_set + uintptr(s1+s2)*56))).Fposition = -int32(1) + return new_set +} + +// C documentation +// +// /* Finds the empty path through `node' which is the one that should be +// taken according to POSIX.2 rules, and adds the tags on that path to +// `tags'. `tags' may be NULL. If `num_tags_seen' is not NULL, it is +// set to the number of tags seen on the path. */ +func _tre_match_empty(tls *TLS, stack uintptr, node uintptr, tags uintptr, assertions uintptr, num_tags_seen uintptr) (r Treg_errcode_t) { + var bottom, i int32 + var cat, iter, lit, uni, v2 uintptr + var status Treg_errcode_t + _, _, _, _, _, _, _, _ = bottom, cat, i, iter, lit, status, uni, v2 + bottom = _tre_stack_num_objects(tls, stack) + status = REG_OK + if num_tags_seen != 0 { + **(**int32)(__ccgo_up(num_tags_seen)) = 0 + } + status = _tre_stack_push_voidptr(tls, stack, node) + /* Walk through the tree recursively. */ + for status == REG_OK && _tre_stack_num_objects(tls, stack) > bottom { + node = _tre_stack_pop_voidptr(tls, stack) + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + switch (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min { + case int64(-int32(3)): + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max >= 0 { + if tags != UintptrFromInt32(0) { + /* Add the tag to `tags'. */ + i = 0 + for { + if !(**(**int32)(__ccgo_up(tags + uintptr(i)*4)) >= 0) { + break + } + if int64(**(**int32)(__ccgo_up(tags + uintptr(i)*4))) == (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if **(**int32)(__ccgo_up(tags + uintptr(i)*4)) < 0 { + **(**int32)(__ccgo_up(tags + uintptr(i)*4)) = int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max) + **(**int32)(__ccgo_up(tags + uintptr(i+int32(1))*4)) = -int32(1) + } + } + if num_tags_seen != 0 { + **(**int32)(__ccgo_up(num_tags_seen)) = **(**int32)(__ccgo_up(num_tags_seen)) + 1 + } + } + case int64(-int32(2)): + if assertions != UintptrFromInt32(0) { + v2 = assertions + *(*int32)(unsafe.Pointer(v2)) = int32(int64(*(*int32)(unsafe.Pointer(v2))) | (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max) + } + case int64(-int32(1)): + default: + break + } + case int32(_UNION): + /* Subexpressions starting earlier take priority over ones + starting later, so we prefer the left subexpression over the + right subexpression. */ + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fleft)).Fnullable != 0 { + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft) + if status != REG_OK { + break + } + } else { + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fright)).Fnullable != 0 { + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright) + if status != REG_OK { + break + } + } else { + } + } + case int32(_CATENATION): + /* The path must go through both children. */ + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft) + if status != REG_OK { + break + } + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright) + if status != REG_OK { + break + } + case int32(_ITERATION): + /* A match with an empty string is preferred over no match at + all, so we go through the argument if possible. */ + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Fnullable != 0 { + status = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg) + if status != REG_OK { + break + } + } + default: + break + } + } + return status +} + +type Ttre_nfl_stack_symbol_t = int32 + +const _NFL_RECURSE = 0 +const _NFL_POST_UNION = 1 +const _NFL_POST_CATENATION = 2 +const _NFL_POST_ITERATION = 3 + +// C documentation +// +// /* Computes and fills in the fields `nullable', `firstpos', and `lastpos' for +// the nodes of the AST `tree'. */ +func _tre_compute_nfl(tls *TLS, mem Ttre_mem_t, stack uintptr, tree uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var _status, _status1, _status10, _status11, _status12, _status13, _status14, _status15, _status16, _status17, _status2, _status3, _status4, _status5, _status6, _status7, _status8, _status9, status Treg_errcode_t + var bottom int32 + var cat, iter, lit, node, tags, uni uintptr + var symbol Ttre_nfl_stack_symbol_t + var _ /* assertions at bp+4 */ int32 + var _ /* num_tags at bp+0 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = _status, _status1, _status10, _status11, _status12, _status13, _status14, _status15, _status16, _status17, _status2, _status3, _status4, _status5, _status6, _status7, _status8, _status9, bottom, cat, iter, lit, node, status, symbol, tags, uni + bottom = _tre_stack_num_objects(tls, stack) + _status = _tre_stack_push_voidptr(tls, stack, tree) + if _status != REG_OK { + return _status + } + _status1 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status1 != REG_OK { + return _status1 + } + for _tre_stack_num_objects(tls, stack) > bottom { + symbol = _tre_stack_pop_int(tls, stack) + node = _tre_stack_pop_voidptr(tls, stack) + switch symbol { + case int32(_NFL_RECURSE): + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + lit = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min == int64(-int32(4)) { + /* Back references: nullable = false, firstpos = {i}, + lastpos = {i}. */ + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = 0 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_one(tls, mem, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition, 0, int32(TRE_CHAR_MAX), uint64(0), UintptrFromInt32(0), -int32(1)) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_one(tls, mem, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition, 0, int32(TRE_CHAR_MAX), uint64(0), UintptrFromInt32(0), int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max)) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + } else { + if (*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min < 0 { + /* Tags, empty strings, params, and zero width assertions: + nullable = true, firstpos = {}, and lastpos = {}. */ + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = int32(1) + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_empty(tls, mem) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_empty(tls, mem) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + } else { + /* Literal at position i: nullable = false, firstpos = {i}, + lastpos = {i}. */ + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = 0 + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_one(tls, mem, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition, int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min), int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max), uint64(0), UintptrFromInt32(0), -int32(1)) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_one(tls, mem, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fposition, int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_min), int32((*Ttre_literal_t)(unsafe.Pointer(lit)).Fcode_max), (*Ttre_literal_t)(unsafe.Pointer(lit)).Fclass, (*Ttre_literal_t)(unsafe.Pointer(lit)).Fneg_classes, -int32(1)) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + } + } + case int32(_UNION): + /* Compute the attributes for the two subtrees, and after that + for this node. */ + _status2 = _tre_stack_push_voidptr(tls, stack, node) + if _status2 != REG_OK { + return _status2 + } + _status3 = _tre_stack_push_int(tls, stack, int32(_NFL_POST_UNION)) + if _status3 != REG_OK { + return _status3 + } + _status4 = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fright) + if _status4 != REG_OK { + return _status4 + } + _status5 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status5 != REG_OK { + return _status5 + } + _status6 = _tre_stack_push_voidptr(tls, stack, (*Ttre_union_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fleft) + if _status6 != REG_OK { + return _status6 + } + _status7 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status7 != REG_OK { + return _status7 + } + case int32(_CATENATION): + /* Compute the attributes for the two subtrees, and after that + for this node. */ + _status8 = _tre_stack_push_voidptr(tls, stack, node) + if _status8 != REG_OK { + return _status8 + } + _status9 = _tre_stack_push_int(tls, stack, int32(_NFL_POST_CATENATION)) + if _status9 != REG_OK { + return _status9 + } + _status10 = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fright) + if _status10 != REG_OK { + return _status10 + } + _status11 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status11 != REG_OK { + return _status11 + } + _status12 = _tre_stack_push_voidptr(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Fleft) + if _status12 != REG_OK { + return _status12 + } + _status13 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status13 != REG_OK { + return _status13 + } + case int32(_ITERATION): + /* Compute the attributes for the subtree, and after that for + this node. */ + _status14 = _tre_stack_push_voidptr(tls, stack, node) + if _status14 != REG_OK { + return _status14 + } + _status15 = _tre_stack_push_int(tls, stack, int32(_NFL_POST_ITERATION)) + if _status15 != REG_OK { + return _status15 + } + _status16 = _tre_stack_push_voidptr(tls, stack, (*Ttre_iteration_t)(unsafe.Pointer((*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj)).Farg) + if _status16 != REG_OK { + return _status16 + } + _status17 = _tre_stack_push_int(tls, stack, int32(_NFL_RECURSE)) + if _status17 != REG_OK { + return _status17 + } + break + } + case int32(_NFL_POST_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = BoolInt32((*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fleft)).Fnullable != 0 || (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fright)).Fnullable != 0) + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_union(tls, mem, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fleft)).Ffirstpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fright)).Ffirstpos, UintptrFromInt32(0), 0) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_union(tls, mem, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fleft)).Flastpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_union_t)(unsafe.Pointer(uni)).Fright)).Flastpos, UintptrFromInt32(0), 0) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + case int32(_NFL_POST_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmin == 0 || (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Fnullable != 0 { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = int32(1) + } else { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = 0 + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Ffirstpos + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Flastpos + case int32(_NFL_POST_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fnullable = BoolInt32((*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Fnullable != 0 && (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Fnullable != 0) + /* Compute firstpos. */ + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Fnullable != 0 { + /* The left side matches the empty string. Make a first pass + with tre_match_empty() to get the number of tags and + parameters. */ + status = _tre_match_empty(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft, UintptrFromInt32(0), UintptrFromInt32(0), bp) + if status != REG_OK { + return status + } + /* Allocate arrays for the tags and parameters. */ + tags = Xmalloc(tls, uint64(4)*Uint64FromInt32(**(**int32)(__ccgo_up(bp))+Int32FromInt32(1))) + if !(tags != 0) { + return int32(REG_ESPACE) + } + **(**int32)(__ccgo_up(tags)) = -int32(1) + **(**int32)(__ccgo_up(bp + 4)) = 0 + /* Second pass with tre_mach_empty() to get the list of + tags and parameters. */ + status = _tre_match_empty(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft, tags, bp+4, UintptrFromInt32(0)) + if status != REG_OK { + Xfree(tls, tags) + return status + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = _tre_set_union(tls, mem, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Ffirstpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Ffirstpos, tags, **(**int32)(__ccgo_up(bp + 4))) + Xfree(tls, tags) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos != 0) { + return int32(REG_ESPACE) + } + } else { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ffirstpos = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Ffirstpos + } + /* Compute lastpos. */ + if (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Fnullable != 0 { + /* The right side matches the empty string. Make a first pass + with tre_match_empty() to get the number of tags and + parameters. */ + status = _tre_match_empty(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright, UintptrFromInt32(0), UintptrFromInt32(0), bp) + if status != REG_OK { + return status + } + /* Allocate arrays for the tags and parameters. */ + tags = Xmalloc(tls, uint64(4)*Uint64FromInt32(**(**int32)(__ccgo_up(bp))+Int32FromInt32(1))) + if !(tags != 0) { + return int32(REG_ESPACE) + } + **(**int32)(__ccgo_up(tags)) = -int32(1) + **(**int32)(__ccgo_up(bp + 4)) = 0 + /* Second pass with tre_mach_empty() to get the list of + tags and parameters. */ + status = _tre_match_empty(tls, stack, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright, tags, bp+4, UintptrFromInt32(0)) + if status != REG_OK { + Xfree(tls, tags) + return status + } + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = _tre_set_union(tls, mem, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Flastpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Flastpos, tags, **(**int32)(__ccgo_up(bp + 4))) + Xfree(tls, tags) + if !((*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos != 0) { + return int32(REG_ESPACE) + } + } else { + (*Ttre_ast_node_t)(unsafe.Pointer(node)).Flastpos = (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Flastpos + } + default: + break + } + } + return REG_OK +} + +// C documentation +// +// /* Adds a transition from each position in `p1' to each position in `p2'. */ +func _tre_make_trans(tls *TLS, p1 uintptr, p2 uintptr, transitions uintptr, counts uintptr, offs uintptr) (r Treg_errcode_t) { + var dup, i, j, k, l, prev_p2_pos, v1, v2 int32 + var orig_p2, trans uintptr + _, _, _, _, _, _, _, _, _, _ = dup, i, j, k, l, orig_p2, prev_p2_pos, trans, v1, v2 + orig_p2 = p2 + if transitions != UintptrFromInt32(0) { + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition >= 0 { + p2 = orig_p2 + prev_p2_pos = -int32(1) + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition >= 0 { + /* Optimization: if this position was already handled, skip it. */ + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition == prev_p2_pos { + p2 += 56 + continue + } + prev_p2_pos = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition + /* Set `trans' to point to the next unused transition from + position `p1->position'. */ + trans = transitions + uintptr(**(**int32)(__ccgo_up(offs + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition)*4)))*56 + for (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate != UintptrFromInt32(0) { + trans += 56 + } + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate == UintptrFromInt32(0) { + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans + UintptrFromInt32(1)*56)).Fstate = UintptrFromInt32(0) + } + /* Use the character ranges, assertions, etc. from `p1' for + the transition from `p1' to `p2'. */ + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fcode_min = Uint32FromInt32((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fcode_min) + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fcode_max = Uint32FromInt32((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fcode_max) + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate = transitions + uintptr(**(**int32)(__ccgo_up(offs + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition)*4)))*56 + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate_id = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fclass != 0 { + v1 = int32(ASSERT_CHAR_CLASS) + } else { + v1 = 0 + } + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes != UintptrFromInt32(0) { + v2 = int32(ASSERT_CHAR_CLASS_NEG) + } else { + v2 = 0 + } + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fassertions = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fassertions | (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fassertions | v1 | v2 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fbackref >= 0 { + *(*int32)(unsafe.Pointer(&(*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fu)) = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fbackref + **(**int32)(__ccgo_up(trans + 32)) |= int32(ASSERT_BACKREF) + } else { + *(*Ttre_ctype_t)(unsafe.Pointer(trans + 40)) = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fclass + } + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes != UintptrFromInt32(0) { + i = 0 + for { + if !(**(**Ttre_ctype_t)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes + uintptr(i)*8)) != Uint64FromInt32(0)) { + break + } + goto _3 + _3: + ; + i = i + 1 + } + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes = Xmalloc(tls, uint64(8)*Uint64FromInt32(i+Int32FromInt32(1))) + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + i = 0 + for { + if !(**(**Ttre_ctype_t)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes + uintptr(i)*8)) != Uint64FromInt32(0)) { + break + } + **(**Ttre_ctype_t)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes + uintptr(i)*8)) = **(**Ttre_ctype_t)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fneg_classes + uintptr(i)*8)) + goto _4 + _4: + ; + i = i + 1 + } + **(**Ttre_ctype_t)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes + uintptr(i)*8)) = Uint64FromInt32(0) + } else { + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fneg_classes = UintptrFromInt32(0) + } + /* Find out how many tags this transition has. */ + i = 0 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags + uintptr(i)*4)) >= 0 { + i = i + 1 + } + } + j = 0 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags + uintptr(j)*4)) >= 0 { + j = j + 1 + } + } + /* If we are overwriting a transition, free the old tag array. */ + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags != UintptrFromInt32(0) { + Xfree(tls, (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags) + } + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags = UintptrFromInt32(0) + /* If there were any tags, allocate an array and fill it. */ + if i+j > 0 { + (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags = Xmalloc(tls, uint64(4)*Uint64FromInt32(i+j+Int32FromInt32(1))) + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags != 0) { + return int32(REG_ESPACE) + } + i = 0 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags + uintptr(i)*4)) >= 0 { + **(**int32)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags + uintptr(i)*4)) = **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Ftags + uintptr(i)*4)) + i = i + 1 + } + } + l = i + j = 0 + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags + uintptr(j)*4)) >= 0 { + /* Don't add duplicates. */ + dup = 0 + k = 0 + for { + if !(k < i) { + break + } + if **(**int32)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags + uintptr(k)*4)) == **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags + uintptr(j)*4)) { + dup = int32(1) + break + } + goto _5 + _5: + ; + k = k + 1 + } + if !(dup != 0) { + v1 = l + l = l + 1 + **(**int32)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags + uintptr(v1)*4)) = **(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Ftags + uintptr(j)*4)) + } + j = j + 1 + } + } + **(**int32)(__ccgo_up((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags + uintptr(l)*4)) = -int32(1) + } + p2 += 56 + } + p1 += 56 + } + } else { + /* Compute a maximum limit for the number of transitions leaving + from each state. */ + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition >= 0 { + p2 = orig_p2 + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p2)).Fposition >= 0 { + **(**int32)(__ccgo_up(counts + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition)*4)) = **(**int32)(__ccgo_up(counts + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p1)).Fposition)*4)) + 1 + p2 += 56 + } + p1 += 56 + } + } + return REG_OK +} + +// C documentation +// +// /* Converts the syntax tree to a TNFA. All the transitions in the TNFA are +// labelled with one character range (there are no transitions on empty +// strings). The TNFA takes O(n^2) space in the worst case, `n' is size of +// the regexp. */ +func _tre_ast_to_tnfa(tls *TLS, node uintptr, transitions uintptr, counts uintptr, offs uintptr) (r Treg_errcode_t) { + var cat, iter, uni uintptr + var errcode Treg_errcode_t + _, _, _, _ = cat, errcode, iter, uni + errcode = REG_OK + /* XXX - recurse using a stack!. */ + switch (*Ttre_ast_node_t)(unsafe.Pointer(node)).Ftype1 { + case int32(_LITERAL): + case int32(_UNION): + uni = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + errcode = _tre_ast_to_tnfa(tls, (*Ttre_union_t)(unsafe.Pointer(uni)).Fleft, transitions, counts, offs) + if errcode != REG_OK { + return errcode + } + errcode = _tre_ast_to_tnfa(tls, (*Ttre_union_t)(unsafe.Pointer(uni)).Fright, transitions, counts, offs) + case int32(_CATENATION): + cat = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + /* Add a transition from each position in cat->left->lastpos + to each position in cat->right->firstpos. */ + errcode = _tre_make_trans(tls, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft)).Flastpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright)).Ffirstpos, transitions, counts, offs) + if errcode != REG_OK { + return errcode + } + errcode = _tre_ast_to_tnfa(tls, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fleft, transitions, counts, offs) + if errcode != REG_OK { + return errcode + } + errcode = _tre_ast_to_tnfa(tls, (*Ttre_catenation_t)(unsafe.Pointer(cat)).Fright, transitions, counts, offs) + case int32(_ITERATION): + iter = (*Ttre_ast_node_t)(unsafe.Pointer(node)).Fobj + if (*Ttre_iteration_t)(unsafe.Pointer(iter)).Fmax == -int32(1) { + /* Add a transition from each last position in the iterated + expression to each first position. */ + errcode = _tre_make_trans(tls, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Flastpos, (*Ttre_ast_node_t)(unsafe.Pointer((*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg)).Ffirstpos, transitions, counts, offs) + if errcode != REG_OK { + return errcode + } + } + errcode = _tre_ast_to_tnfa(tls, (*Ttre_iteration_t)(unsafe.Pointer(iter)).Farg, transitions, counts, offs) + break + } + return errcode +} + +func Xregcomp(tls *TLS, preg uintptr, regex uintptr, cflags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v preg=%v regex=%v cflags=%v, (%v:)", tls, preg, regex, cflags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var add, i, j, v1 int32 + var counts, initial, offs, p, stack, submatch_data, tag_directions, tmp_ast_l, tmp_ast_r, tnfa, transitions, tree, v2 uintptr + var errcode Treg_errcode_t + var mem Ttre_mem_t + var _ /* parse_ctx at bp+0 */ Ttre_parse_ctx_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = add, counts, errcode, i, initial, j, mem, offs, p, stack, submatch_data, tag_directions, tmp_ast_l, tmp_ast_r, tnfa, transitions, tree, v1, v2 + counts = UintptrFromInt32(0) + offs = UintptrFromInt32(0) + add = 0 + tnfa = UintptrFromInt32(0) + tag_directions = UintptrFromInt32(0) + /* Allocate a stack used throughout the compilation process for various + purposes. */ + stack = _tre_stack_new(tls, int32(512), int32(1024000), int32(128)) + if !(stack != 0) { + return int32(REG_ESPACE) + } + /* Allocate a fast memory allocator. */ + mem = X__tre_mem_new_impl(tls, 0, UintptrFromInt32(0)) + if !(mem != 0) { + _tre_stack_destroy(tls, stack) + return int32(REG_ESPACE) + } + /* Parse the regexp. */ + Xmemset(tls, bp, 0, uint64(56)) + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fmem = mem + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fstack = stack + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fstart = regex + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fcflags = cflags + (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fmax_backref = -int32(1) + errcode = _tre_parse(tls, bp) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + (*Tregex_t)(unsafe.Pointer(preg)).Fre_nsub = Uint64FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fsubmatch_id - int32(1)) + tree = (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fn + /* Referring to nonexistent subexpressions is illegal. */ + if (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fmax_backref > Int32FromUint64((*Tregex_t)(unsafe.Pointer(preg)).Fre_nsub) { + errcode = int32(REG_ESUBREG) + if int32(1) != 0 { + goto error_exit + } + } + /* Allocate the TNFA struct. */ + tnfa = Xcalloc(tls, uint64(1), uint64(104)) + if tnfa == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fhave_backrefs = BoolInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fmax_backref >= 0) + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fhave_approx = 0 + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches = Uint32FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fsubmatch_id) + /* Set up tags for submatch addressing. If REG_NOSUB is set and the + regexp does not have back references, this can be skipped. */ + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fhave_backrefs != 0 || !(cflags&Int32FromInt32(REG_NOSUB) != 0) { + /* Figure out how many tags we will need. */ + errcode = _tre_add_tags(tls, UintptrFromInt32(0), stack, tree, tnfa) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags > 0 { + tag_directions = Xmalloc(tls, uint64(4)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags+Int32FromInt32(1))) + if tag_directions == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions = tag_directions + Xmemset(tls, tag_directions, -int32(1), uint64(4)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags+Int32FromInt32(1))) + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags = Xcalloc(tls, uint64(Uint32FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)*uint32(2)+uint32(1)), uint64(4)) + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + submatch_data = Xcalloc(tls, uint64(Uint32FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fsubmatch_id)), uint64(16)) + if submatch_data == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data = submatch_data + errcode = _tre_add_tags(tls, mem, stack, tree, tnfa) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + } + /* Expand iteration nodes. */ + errcode = _tre_expand_ast(tls, mem, stack, tree, bp+44, tag_directions) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + /* Add a dummy node for the final state. + XXX - For certain patterns this dummy node can be optimized away, + for example "a*" or "ab*". Figure out a simple way to detect + this possibility. */ + tmp_ast_l = tree + v2 = bp + 44 + v1 = *(*int32)(unsafe.Pointer(v2)) + *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 + tmp_ast_r = _tre_ast_new_literal(tls, mem, 0, 0, v1) + if tmp_ast_r == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + tree = _tre_ast_new_catenation(tls, mem, tmp_ast_l, tmp_ast_r) + if tree == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + errcode = _tre_compute_nfl(tls, mem, stack, tree) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + counts = Xmalloc(tls, uint64(4)*Uint64FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition)) + if counts == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + offs = Xmalloc(tls, uint64(4)*Uint64FromInt32((**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition)) + if offs == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + i = 0 + for { + if !(i < (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition) { + break + } + **(**int32)(__ccgo_up(counts + uintptr(i)*4)) = 0 + goto _3 + _3: + ; + i = i + 1 + } + _tre_ast_to_tnfa(tls, tree, UintptrFromInt32(0), counts, UintptrFromInt32(0)) + add = 0 + i = 0 + for { + if !(i < (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition) { + break + } + **(**int32)(__ccgo_up(offs + uintptr(i)*4)) = add + add = add + (**(**int32)(__ccgo_up(counts + uintptr(i)*4)) + int32(1)) + **(**int32)(__ccgo_up(counts + uintptr(i)*4)) = 0 + goto _4 + _4: + ; + i = i + 1 + } + transitions = Xcalloc(tls, uint64(Uint32FromInt32(add)+uint32(1)), uint64(56)) + if transitions == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions = transitions + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_transitions = Uint32FromInt32(add) + errcode = _tre_ast_to_tnfa(tls, tree, transitions, counts, offs) + if errcode != REG_OK { + errcode = errcode + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffirstpos_chars = UintptrFromInt32(0) + p = (*Ttre_ast_node_t)(unsafe.Pointer(tree)).Ffirstpos + i = 0 + for (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fposition >= 0 { + i = i + 1 + p += 56 + } + initial = Xcalloc(tls, uint64(Uint32FromInt32(i)+uint32(1)), uint64(56)) + if initial == UintptrFromInt32(0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial = initial + i = 0 + p = (*Ttre_ast_node_t)(unsafe.Pointer(tree)).Ffirstpos + for { + if !((*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fposition >= 0) { + break + } + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Fstate = transitions + uintptr(**(**int32)(__ccgo_up(offs + uintptr((*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fposition)*4)))*56 + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Fstate_id = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fposition + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Ftags = UintptrFromInt32(0) + /* Copy the arrays p->tags, and p->params, they are allocated + from a tre_mem object. */ + if (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Ftags != 0 { + j = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Ftags + uintptr(j)*4)) >= 0) { + break + } + goto _6 + _6: + ; + j = j + 1 + } + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Ftags = Xmalloc(tls, uint64(4)*Uint64FromInt32(j+Int32FromInt32(1))) + if !((**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Ftags != 0) { + errcode = int32(REG_ESPACE) + if int32(1) != 0 { + goto error_exit + } + } + Xmemcpy(tls, (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Ftags, (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Ftags, uint64(4)*Uint64FromInt32(j+Int32FromInt32(1))) + } + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Fassertions = (*Ttre_pos_and_tags_t)(unsafe.Pointer(p)).Fassertions + i = i + 1 + goto _5 + _5: + ; + p += 56 + } + (**(**Ttre_tnfa_transition_t)(__ccgo_up(initial + uintptr(i)*56))).Fstate = UintptrFromInt32(0) + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_transitions = Uint32FromInt32(add) + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal = transitions + uintptr(**(**int32)(__ccgo_up(offs + uintptr((**(**Ttre_pos_and_tags_t)(__ccgo_up((*Ttre_ast_node_t)(unsafe.Pointer(tree)).Flastpos))).Fposition)*4)))*56 + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states = (**(**Ttre_parse_ctx_t)(__ccgo_up(bp))).Fposition + (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags = cflags + X__tre_mem_destroy(tls, mem) + _tre_stack_destroy(tls, stack) + Xfree(tls, counts) + Xfree(tls, offs) + (*Tregex_t)(unsafe.Pointer(preg)).F__opaque = tnfa + return REG_OK + goto error_exit +error_exit: + ; + /* Free everything that was allocated and return the error code. */ + X__tre_mem_destroy(tls, mem) + if stack != UintptrFromInt32(0) { + _tre_stack_destroy(tls, stack) + } + if counts != UintptrFromInt32(0) { + Xfree(tls, counts) + } + if offs != UintptrFromInt32(0) { + Xfree(tls, offs) + } + (*Tregex_t)(unsafe.Pointer(preg)).F__opaque = tnfa + Xregfree(tls, preg) + return errcode +} + +func Xregfree(tls *TLS, preg uintptr) { + if __ccgo_strace { + trc("tls=%v preg=%v, (%v:)", tls, preg, origin(2)) + } + var i uint32 + var tnfa, trans uintptr + _, _, _ = i, tnfa, trans + tnfa = (*Tregex_t)(unsafe.Pointer(preg)).F__opaque + if !(tnfa != 0) { + return + } + i = uint32(0) + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_transitions) { + break + } + if (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Fstate != 0 { + if (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Ftags != 0 { + Xfree(tls, (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Ftags) + } + if (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Fneg_classes != 0 { + Xfree(tls, (**(**Ttre_tnfa_transition_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions + uintptr(i)*56))).Fneg_classes) + } + } + goto _1 + _1: + ; + i = i + 1 + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions != 0 { + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftransitions) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial != 0 { + trans = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial + for { + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Fstate != 0) { + break + } + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags != 0 { + Xfree(tls, (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans)).Ftags) + } + goto _2 + _2: + ; + trans += 56 + } + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data != 0 { + i = uint32(0) + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches) { + break + } + if (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(i)*16))).Fparents != 0 { + Xfree(tls, (**(**Ttre_submatch_data_t)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + uintptr(i)*16))).Fparents) + } + goto _3 + _3: + ; + i = i + 1 + } + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions != 0 { + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffirstpos_chars != 0 { + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffirstpos_chars) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags != 0 { + Xfree(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags) + } + Xfree(tls, tnfa) +} + +/* Error message strings for error codes listed in `regex.h'. This list + needs to be in sync with the codes listed there, naturally. */ + +/* Converted to single string by Rich Felker to remove the need for + * data relocations at runtime, 27 Feb 2006. */ + +var _messages = [286]uint8{'N', 'o', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'N', 'o', ' ', 'm', 'a', 't', 'c', 'h', 0, 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'r', 'e', 'g', 'e', 'x', 'p', 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'c', 'o', 'l', 'l', 'a', 't', 'i', 'n', 'g', ' ', 'e', 'l', 'e', 'm', 'e', 'n', 't', 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'c', 'h', 'a', 'r', 'a', 'c', 't', 'e', 'r', ' ', 'c', 'l', 'a', 's', 's', ' ', 'n', 'a', 'm', 'e', 0, 'T', 'r', 'a', 'i', 'l', 'i', 'n', 'g', ' ', 'b', 'a', 'c', 'k', 's', 'l', 'a', 's', 'h', 0, 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'b', 'a', 'c', 'k', ' ', 'r', 'e', 'f', 'e', 'r', 'e', 'n', 'c', 'e', 0, 'M', 'i', 's', 's', 'i', 'n', 'g', ' ', '\'', ']', '\'', 0, 'M', 'i', 's', 's', 'i', 'n', 'g', ' ', '\'', ')', '\'', 0, 'M', 'i', 's', 's', 'i', 'n', 'g', ' ', '\'', '}', '\'', 0, 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'c', 'o', 'n', 't', 'e', 'n', 't', 's', ' ', 'o', 'f', ' ', '{', '}', 0, 'I', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'c', 'h', 'a', 'r', 'a', 'c', 't', 'e', 'r', ' ', 'r', 'a', 'n', 'g', 'e', 0, 'O', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0, 'R', 'e', 'p', 'e', 't', 'i', 't', 'i', 'o', 'n', ' ', 'n', 'o', 't', ' ', 'p', 'r', 'e', 'c', 'e', 'd', 'e', 'd', ' ', 'b', 'y', ' ', 'v', 'a', 'l', 'i', 'd', ' ', 'e', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', 0, 0, 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r'} + +func Xregerror(tls *TLS, e int32, preg uintptr, buf uintptr, size Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v e=%v preg=%v buf=%v size=%v, (%v:)", tls, e, preg, buf, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var s uintptr + _ = s + s = uintptr(unsafe.Pointer(&_messages)) + for { + if !(e != 0 && **(**uint8)(__ccgo_up(s)) != 0) { + break + } + goto _1 + _1: + ; + e = e - 1 + s = s + uintptr(_strlen(tls, s)+uint64(1)) + } + if !(**(**uint8)(__ccgo_up(s)) != 0) { + s = s + 1 + } + s = X__lctrans_cur(tls, s) + return Uint64FromInt32(int32(1) + Xsnprintf(tls, buf, size, __ccgo_ts+15, VaList(bp+8, s))) +} + +const tre_bt_mem_alloc = 0 +const tre_bt_mem_destroy = 0 +const tre_bt_mem_new = 0 + +/*********************************************************************** + from tre-match-utils.h +***********************************************************************/ + +// C documentation +// +// /* Returns 1 if `t1' wins `t2', 0 otherwise. */ +func _tre_tag_order(tls *TLS, num_tags int32, tag_directions uintptr, t1 uintptr, t2 uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(i < num_tags) { + break + } + if **(**Ttre_tag_direction_t)(__ccgo_up(tag_directions + uintptr(i)*4)) == int32(_TRE_TAG_MINIMIZE) { + if **(**Tregoff_t)(__ccgo_up(t1 + uintptr(i)*8)) < **(**Tregoff_t)(__ccgo_up(t2 + uintptr(i)*8)) { + return int32(1) + } + if **(**Tregoff_t)(__ccgo_up(t1 + uintptr(i)*8)) > **(**Tregoff_t)(__ccgo_up(t2 + uintptr(i)*8)) { + return 0 + } + } else { + if **(**Tregoff_t)(__ccgo_up(t1 + uintptr(i)*8)) > **(**Tregoff_t)(__ccgo_up(t2 + uintptr(i)*8)) { + return int32(1) + } + if **(**Tregoff_t)(__ccgo_up(t1 + uintptr(i)*8)) < **(**Tregoff_t)(__ccgo_up(t2 + uintptr(i)*8)) { + return 0 + } + } + goto _1 + _1: + ; + i = i + 1 + } + /* assert(0);*/ + return 0 +} + +func _tre_neg_char_classes_match(tls *TLS, classes uintptr, wc Ttre_cint_t, icase int32) (r int32) { + for **(**Ttre_ctype_t)(__ccgo_up(classes)) != Uint64FromInt32(0) { + if !(icase != 0) && Xiswctype(tls, wc, **(**Ttre_ctype_t)(__ccgo_up(classes))) != 0 || icase != 0 && (Xiswctype(tls, Xtowupper(tls, wc), **(**Ttre_ctype_t)(__ccgo_up(classes))) != 0 || Xiswctype(tls, Xtowlower(tls, wc), **(**Ttre_ctype_t)(__ccgo_up(classes))) != 0) { + return int32(1) + } else { + classes += 8 + } + } + return 0 /* No match. */ +} + +/*********************************************************************** + from tre-match-parallel.c +***********************************************************************/ + +/* + This algorithm searches for matches basically by reading characters + in the searched string one by one, starting at the beginning. All + matching paths in the TNFA are traversed in parallel. When two or + more paths reach the same state, exactly one is chosen according to + tag ordering rules; if returning submatches is not required it does + not matter which path is chosen. + + The worst case time required for finding the leftmost and longest + match, or determining that there is no match, is always linearly + dependent on the length of the text being searched. + + This algorithm cannot handle TNFAs with back referencing nodes. + See `tre-match-backtrack.c'. +*/ + +type Ttre_tnfa_reach_t = struct { + Fstate uintptr + Ftags uintptr +} + +type Ttre_reach_pos_t = struct { + Fpos Tregoff_t + Ftags uintptr +} + +func _tre_tnfa_run_parallel(tls *TLS, tnfa uintptr, string1 uintptr, match_tags uintptr, eflags int32, match_end_ofs uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var buf, reach, reach_i, reach_next, reach_next_i, reach_pos, str_byte, tag_i, tmp_buf, tmp_iptr, tmp_tags, trans_i uintptr + var end, i, new_match, num_tags, reg_newline, reg_notbol, reg_noteol, skip, start, v18 int32 + var match_eo, pos, pos_add_next, v7 Tregoff_t + var pbytes, rbytes, tbytes, total_bytes, xbytes Tsize_t + var prev_c Ttre_char_t + var ret Treg_errcode_t + var v1 uint64 + var _ /* next_c at bp+0 */ Ttre_char_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = buf, end, i, match_eo, new_match, num_tags, pbytes, pos, pos_add_next, prev_c, rbytes, reach, reach_i, reach_next, reach_next_i, reach_pos, reg_newline, reg_notbol, reg_noteol, ret, skip, start, str_byte, tag_i, tbytes, tmp_buf, tmp_iptr, tmp_tags, total_bytes, trans_i, xbytes, v1, v18, v7 + /* State variables required by GET_NEXT_WCHAR. */ + prev_c = uint32(0) + **(**Ttre_char_t)(__ccgo_up(bp)) = uint32(0) + str_byte = string1 + pos = int64(-int32(1)) + pos_add_next = int64(1) + reg_notbol = eflags & int32(REG_NOTBOL) + reg_noteol = eflags & int32(REG_NOTEOL) + reg_newline = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags & int32(REG_NEWLINE) + match_eo = int64(-int32(1)) /* end offset of match (-1 if no match found yet) */ + new_match = 0 + tmp_tags = UintptrFromInt32(0) + if !(match_tags != 0) { + num_tags = 0 + } else { + num_tags = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags + } + /* Allocate memory for temporary data required for matching. This needs to + be done for every matching operation to be thread safe. This allocates + everything in a single large block with calloc(). */ + /* Ensure that tbytes and xbytes*num_states cannot overflow, and that + * they don't contribute more than 1/8 of SIZE_MAX to total_bytes. */ + if Uint64FromInt32(num_tags) > uint64(0xffffffffffffffff)/(Uint64FromInt32(8)*Uint64FromInt64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states)) { + return int32(REG_ESPACE) + } + /* Likewise check rbytes. */ + if Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states+int32(1)) > Uint64FromUint64(0xffffffffffffffff)/(Uint64FromInt32(8)*Uint64FromInt64(16)) { + return int32(REG_ESPACE) + } + /* Likewise check pbytes. */ + if Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) > Uint64FromUint64(0xffffffffffffffff)/(Uint64FromInt32(8)*Uint64FromInt64(16)) { + return int32(REG_ESPACE) + } + /* Compute the length of the block we need. */ + tbytes = uint64(8) * Uint64FromInt32(num_tags) + rbytes = uint64(16) * Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states+Int32FromInt32(1)) + pbytes = uint64(16) * Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) + xbytes = uint64(8) * Uint64FromInt32(num_tags) + total_bytes = (Uint64FromInt64(8)-Uint64FromInt32(1))*Uint64FromInt32(4) + (rbytes+xbytes*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states))*uint64(2) + tbytes + pbytes + /* Allocate the memory. */ + buf = Xcalloc(tls, total_bytes, uint64(1)) + if buf == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + /* Get the various pointers within tmp_buf (properly aligned). */ + tmp_tags = buf + tmp_buf = buf + uintptr(tbytes) + if Uint64FromInt64(int64(tmp_buf))%uint64(8) != 0 { + v1 = uint64(8) - Uint64FromInt64(int64(tmp_buf))%uint64(8) + } else { + v1 = uint64(0) + } + tmp_buf = tmp_buf + uintptr(v1) + reach_next = tmp_buf + tmp_buf = tmp_buf + uintptr(rbytes) + if Uint64FromInt64(int64(tmp_buf))%uint64(8) != 0 { + v1 = uint64(8) - Uint64FromInt64(int64(tmp_buf))%uint64(8) + } else { + v1 = uint64(0) + } + tmp_buf = tmp_buf + uintptr(v1) + reach = tmp_buf + tmp_buf = tmp_buf + uintptr(rbytes) + if Uint64FromInt64(int64(tmp_buf))%uint64(8) != 0 { + v1 = uint64(8) - Uint64FromInt64(int64(tmp_buf))%uint64(8) + } else { + v1 = uint64(0) + } + tmp_buf = tmp_buf + uintptr(v1) + reach_pos = tmp_buf + tmp_buf = tmp_buf + uintptr(pbytes) + if Uint64FromInt64(int64(tmp_buf))%uint64(8) != 0 { + v1 = uint64(8) - Uint64FromInt64(int64(tmp_buf))%uint64(8) + } else { + v1 = uint64(0) + } + tmp_buf = tmp_buf + uintptr(v1) + i = 0 + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) { + break + } + (**(**Ttre_tnfa_reach_t)(__ccgo_up(reach + uintptr(i)*16))).Ftags = tmp_buf + tmp_buf = tmp_buf + uintptr(xbytes) + (**(**Ttre_tnfa_reach_t)(__ccgo_up(reach_next + uintptr(i)*16))).Ftags = tmp_buf + tmp_buf = tmp_buf + uintptr(xbytes) + goto _5 + _5: + ; + i = i + 1 + } + i = 0 + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) { + break + } + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr(i)*16))).Fpos = int64(-int32(1)) + goto _6 + _6: + ; + i = i + 1 + } + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v7 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v7 + if v7 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + pos = 0 + reach_next_i = reach_next + for int32(1) != 0 { + /* If no match found yet, add the initial states to `reach_next'. */ + if match_eo < 0 { + trans_i = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial + for (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != UintptrFromInt32(0) { + if (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Fpos < pos { + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions != 0 && ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOL) != 0 && (pos > 0 || reg_notbol != 0) && (prev_c != uint32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOL) != 0 && (**(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\000') || reg_noteol != 0) && (**(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOW) != 0 && (prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0 || !(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOW) != 0 && (!(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) || (**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB) != 0 && (pos != 0 && **(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\000') && BoolInt32(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) == BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB_NEG) != 0 && (pos == 0 || **(**Ttre_char_t)(__ccgo_up(bp)) == uint32('\000') || BoolInt32(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) != BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0))) { + trans_i += 56 + continue + } + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + uintptr(i)*8)) = int64(-int32(1)) + goto _8 + _8: + ; + i = i + 1 + } + tag_i = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + if tag_i != 0 { + for **(**int32)(__ccgo_up(tag_i)) >= 0 { + if **(**int32)(__ccgo_up(tag_i)) < num_tags { + **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + uintptr(**(**int32)(__ccgo_up(tag_i)))*8)) = pos + } + tag_i += 4 + } + } + if (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal { + match_eo = pos + new_match = int32(1) + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i)*8)) = **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + uintptr(i)*8)) + goto _9 + _9: + ; + i = i + 1 + } + } + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Fpos = pos + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags = reach_next_i + 8 + reach_next_i += 16 + } + trans_i += 56 + } + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = UintptrFromInt32(0) + } else { + if num_tags == 0 || reach_next_i == reach_next { + /* We have found a match. */ + break + } + } + /* Check for end of string. */ + if !(**(**Ttre_char_t)(__ccgo_up(bp)) != 0) { + break + } + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v7 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v7 + if v7 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + /* Swap `reach' and `reach_next'. */ + reach_i = reach + reach = reach_next + reach_next = reach_i + /* For each state in `reach', weed out states that don't fulfill the + minimal matching conditions. */ + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_minimals != 0 && new_match != 0 { + new_match = 0 + reach_next_i = reach_next + reach_i = reach + for { + if !((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Fstate != 0) { + break + } + skip = 0 + i = 0 + for { + if !(**(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i)*4)) >= 0) { + break + } + end = **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i)*4)) + start = **(**int32)(__ccgo_up((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fminimal_tags + uintptr(i+int32(1))*4)) + if end >= num_tags { + skip = int32(1) + break + } else { + if **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags + uintptr(start)*8)) == **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(start)*8)) && **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags + uintptr(end)*8)) < **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(end)*8)) { + skip = int32(1) + break + } + } + goto _12 + _12: + ; + i = i + int32(2) + } + if !(skip != 0) { + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Fstate + tmp_iptr = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags = tmp_iptr + reach_next_i += 16 + } + goto _11 + _11: + ; + reach_i += 16 + } + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = UintptrFromInt32(0) + /* Swap `reach' and `reach_next'. */ + reach_i = reach + reach = reach_next + reach_next = reach_i + } + /* For each state in `reach' see if there is a transition leaving with + the current input symbol to a state not yet in `reach_next', and + add the destination states to `reach_next'. */ + reach_next_i = reach_next + reach_i = reach + for { + if !((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Fstate != 0) { + break + } + trans_i = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Fstate + for { + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != 0) { + break + } + /* Does this transition match the input symbol? */ + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fcode_min <= prev_c && (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fcode_max >= prev_c { + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions != 0 && ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOL) != 0 && (pos > 0 || reg_notbol != 0) && (prev_c != uint32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOL) != 0 && (**(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\000') || reg_noteol != 0) && (**(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOW) != 0 && (prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0 || !(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOW) != 0 && (!(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) || (**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB) != 0 && (pos != 0 && **(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\000') && BoolInt32(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) == BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB_NEG) != 0 && (pos == 0 || **(**Ttre_char_t)(__ccgo_up(bp)) == uint32('\000') || BoolInt32(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) != BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS) != 0 && !((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&Int32FromInt32(REG_ICASE) != 0) && !(Xiswctype(tls, prev_c, *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS) != 0 && (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_ICASE) != 0 && !(Xiswctype(tls, Xtowlower(tls, prev_c), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) && !(Xiswctype(tls, Xtowupper(tls, prev_c), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS_NEG) != 0 && _tre_neg_char_classes_match(tls, (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fneg_classes, prev_c, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_ICASE)) != 0)) { + goto _14 + } + /* Compute the tags after this transition. */ + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(tmp_tags + uintptr(i)*8)) = **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_i)).Ftags + uintptr(i)*8)) + goto _15 + _15: + ; + i = i + 1 + } + tag_i = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + if tag_i != UintptrFromInt32(0) { + for **(**int32)(__ccgo_up(tag_i)) >= 0 { + if **(**int32)(__ccgo_up(tag_i)) < num_tags { + **(**Tregoff_t)(__ccgo_up(tmp_tags + uintptr(**(**int32)(__ccgo_up(tag_i)))*8)) = pos + } + tag_i += 4 + } + } + if (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Fpos < pos { + /* Found an unvisited node. */ + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + tmp_iptr = (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags = tmp_tags + tmp_tags = tmp_iptr + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Fpos = pos + (**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags = reach_next_i + 8 + if (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal && (match_eo == int64(-int32(1)) || num_tags > 0 && **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags)) <= **(**Tregoff_t)(__ccgo_up(match_tags))) { + match_eo = pos + new_match = int32(1) + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i)*8)) = **(**Tregoff_t)(__ccgo_up((*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Ftags + uintptr(i)*8)) + goto _16 + _16: + ; + i = i + 1 + } + } + reach_next_i += 16 + } else { + /* Another path has also reached this state. We choose + the winner by examining the tag values for both + paths. */ + if _tre_tag_order(tls, num_tags, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions, tmp_tags, **(**uintptr)(__ccgo_up((**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags))) != 0 { + /* The new path wins. */ + tmp_iptr = **(**uintptr)(__ccgo_up((**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags)) + **(**uintptr)(__ccgo_up((**(**Ttre_reach_pos_t)(__ccgo_up(reach_pos + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*16))).Ftags)) = tmp_tags + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal { + match_eo = pos + new_match = int32(1) + i = 0 + for { + if !(i < num_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i)*8)) = **(**Tregoff_t)(__ccgo_up(tmp_tags + uintptr(i)*8)) + goto _17 + _17: + ; + i = i + 1 + } + } + tmp_tags = tmp_iptr + } + } + } + goto _14 + _14: + ; + trans_i += 56 + } + goto _13 + _13: + ; + reach_i += 16 + } + (*Ttre_tnfa_reach_t)(unsafe.Pointer(reach_next_i)).Fstate = UintptrFromInt32(0) + } + **(**Tregoff_t)(__ccgo_up(match_end_ofs)) = match_eo + if match_eo >= 0 { + v18 = REG_OK + } else { + v18 = int32(REG_NOMATCH) + } + ret = v18 + goto error_exit +error_exit: + ; + Xfree(tls, buf) + return ret +} + +/*********************************************************************** + from tre-match-backtrack.c +***********************************************************************/ + +/* + This matcher is for regexps that use back referencing. Regexp matching + with back referencing is an NP-complete problem on the number of back + references. The easiest way to match them is to use a backtracking + routine which basically goes through all possible paths in the TNFA + and chooses the one which results in the best (leftmost and longest) + match. This can be spectacularly expensive and may run out of stack + space, but there really is no better known generic algorithm. Quoting + Henry Spencer from comp.compilers: + + + POSIX.2 REs require longest match, which is really exciting to + implement since the obsolete ("basic") variant also includes + \. I haven't found a better way of tackling this than doing + a preliminary match using a DFA (or simulation) on a modified RE + that just replicates subREs for \, and then doing a + backtracking match to determine whether the subRE matches were + right. This can be rather slow, but I console myself with the + thought that people who use \ deserve very slow execution. + (Pun unintentional but very appropriate.) + +*/ + +type Ttre_backtrack_item_t = struct { + Fpos Tregoff_t + Fstr_byte uintptr + Fstate uintptr + Fstate_id int32 + Fnext_c int32 + Ftags uintptr +} + +type Ttre_backtrack_t = uintptr + +type Ttre_backtrack_struct = struct { + Fitem Ttre_backtrack_item_t + Fprev uintptr + Fnext uintptr +} + +func _tre_tnfa_run_backtrack(tls *TLS, tnfa uintptr, string1 uintptr, match_tags uintptr, eflags int32, match_end_ofs uintptr) (r Treg_errcode_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var bt, empty_br_match, i, i1, i2, i3, i4, next_c_start, reg_newline, reg_notbol, reg_noteol, result, ret, v20 int32 + var bt_len, eo, match_eo, pos, pos_add_next, pos_start, so, v3 Tregoff_t + var mem Ttre_mem_t + var next_state, next_tags, pmatch, state, states_seen, str_byte, str_byte_start, tags, tmp, tmp1, trans_i, v6 uintptr + var prev_c Ttre_char_t + var s, s1, stack Ttre_backtrack_t + var _ /* next_c at bp+0 */ Ttre_char_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bt, bt_len, empty_br_match, eo, i, i1, i2, i3, i4, match_eo, mem, next_c_start, next_state, next_tags, pmatch, pos, pos_add_next, pos_start, prev_c, reg_newline, reg_notbol, reg_noteol, result, ret, s, s1, so, stack, state, states_seen, str_byte, str_byte_start, tags, tmp, tmp1, trans_i, v20, v3, v6 + /* State variables required by GET_NEXT_WCHAR. */ + prev_c = uint32(0) + **(**Ttre_char_t)(__ccgo_up(bp)) = uint32(0) + str_byte = string1 + pos = 0 + pos_add_next = int64(1) + reg_notbol = eflags & int32(REG_NOTBOL) + reg_noteol = eflags & int32(REG_NOTEOL) + reg_newline = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags & int32(REG_NEWLINE) + pos_start = int64(-int32(1)) + /* End offset of best match so far, or -1 if no match found yet. */ + match_eo = int64(-int32(1)) + tags = UintptrFromInt32(0) + states_seen = UintptrFromInt32(0) + /* Memory allocator to for allocating the backtracking stack. */ + mem = X__tre_mem_new_impl(tls, 0, UintptrFromInt32(0)) + pmatch = UintptrFromInt32(0) + if !(mem != 0) { + return int32(REG_ESPACE) + } + stack = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(56)) + if !(stack != 0) { + ret = int32(REG_ESPACE) + goto error_exit + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fprev = UintptrFromInt32(0) + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext = UintptrFromInt32(0) + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags != 0 { + tags = Xmalloc(tls, uint64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)) + if !(tags != 0) { + ret = int32(REG_ESPACE) + goto error_exit + } + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches != 0 { + pmatch = Xmalloc(tls, uint64(16)*uint64((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches)) + if !(pmatch != 0) { + ret = int32(REG_ESPACE) + goto error_exit + } + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states != 0 { + states_seen = Xmalloc(tls, uint64(4)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states)) + if !(states_seen != 0) { + ret = int32(REG_ESPACE) + goto error_exit + } + } + goto retry +retry: + ; + i = 0 + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(tags + uintptr(i)*8)) = int64(-int32(1)) + if match_tags != 0 { + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i)*8)) = int64(-int32(1)) + } + goto _1 + _1: + ; + i = i + 1 + } + i = 0 + for { + if !(i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_states) { + break + } + **(**int32)(__ccgo_up(states_seen + uintptr(i)*4)) = 0 + goto _2 + _2: + ; + i = i + 1 + } + state = UintptrFromInt32(0) + pos = pos_start + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v3 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v3 + if v3 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + pos_start = pos + next_c_start = Int32FromUint32(**(**Ttre_char_t)(__ccgo_up(bp))) + str_byte_start = str_byte + /* Handle initial states. */ + next_tags = UintptrFromInt32(0) + trans_i = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Finitial + for { + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != 0) { + break + } + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions != 0 && ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOL) != 0 && (pos > 0 || reg_notbol != 0) && (prev_c != uint32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOL) != 0 && (**(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\000') || reg_noteol != 0) && (**(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOW) != 0 && (prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0 || !(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOW) != 0 && (!(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) || (**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB) != 0 && (pos != 0 && **(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\000') && BoolInt32(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) == BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB_NEG) != 0 && (pos == 0 || **(**Ttre_char_t)(__ccgo_up(bp)) == uint32('\000') || BoolInt32(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) != BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0))) { + goto _4 + } + if state == UintptrFromInt32(0) { + /* Start from this state. */ + state = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + next_tags = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + } else { + /* Backtrack to this state. */ + if !((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext != 0) { + s = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(56)) + if !(s != 0) { + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return int32(REG_ESPACE) + } + (*Ttre_backtrack_struct)(unsafe.Pointer(s)).Fprev = stack + (*Ttre_backtrack_struct)(unsafe.Pointer(s)).Fnext = UintptrFromInt32(0) + (*Ttre_backtrack_struct)(unsafe.Pointer(s)).Fitem.Ftags = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)) + if !((*Ttre_backtrack_struct)(unsafe.Pointer(s)).Fitem.Ftags != 0) { + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return int32(REG_ESPACE) + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext = s + stack = s + } else { + stack = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fpos = pos + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstr_byte = str_byte + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate_id = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fnext_c = Int32FromUint32(**(**Ttre_char_t)(__ccgo_up(bp))) + i1 = 0 + for { + if !(i1 < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(i1)*8)) = **(**Tregoff_t)(__ccgo_up(tags + uintptr(i1)*8)) + goto _5 + _5: + ; + i1 = i1 + 1 + } + tmp = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + if tmp != 0 { + for **(**int32)(__ccgo_up(tmp)) >= 0 { + v6 = tmp + tmp += 4 + **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(**(**int32)(__ccgo_up(v6)))*8)) = pos + } + } + } + goto _4 + _4: + ; + trans_i += 56 + } + if next_tags != 0 { + for { + if !(**(**int32)(__ccgo_up(next_tags)) >= 0) { + break + } + **(**Tregoff_t)(__ccgo_up(tags + uintptr(**(**int32)(__ccgo_up(next_tags)))*8)) = pos + goto _7 + _7: + ; + next_tags += 4 + } + } + if state == UintptrFromInt32(0) { + goto backtrack + } +_9: + ; + if !(int32(1) != 0) { + goto _8 + } + if state == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ffinal { + if match_eo < pos || match_eo == pos && match_tags != 0 && _tre_tag_order(tls, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Ftag_directions, tags, match_tags) != 0 { + /* This match wins the previous match. */ + match_eo = pos + if match_tags != 0 { + i2 = 0 + for { + if !(i2 < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(match_tags + uintptr(i2)*8)) = **(**Tregoff_t)(__ccgo_up(tags + uintptr(i2)*8)) + goto _10 + _10: + ; + i2 = i2 + 1 + } + } + } + /* Our TNFAs never have transitions leaving from the final state, + so we jump right to backtracking. */ + goto backtrack + } + /* Go to the next character in the input string. */ + empty_br_match = 0 + trans_i = state + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != 0 && (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_BACKREF) != 0 { + bt = *(*int32)(unsafe.Pointer(&(*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fu)) + /* Get the substring we need to match against. Remember to + turn off REG_NOSUB temporarily. */ + _tre_fill_pmatch(tls, Uint64FromInt32(bt+int32(1)), pmatch, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags & ^Int32FromInt32(REG_NOSUB), tnfa, tags, pos) + so = (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(bt)*16))).Frm_so + eo = (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(bt)*16))).Frm_eo + bt_len = eo - so + result = Xstrncmp(tls, string1+uintptr(so), str_byte-uintptr(1), Uint64FromInt64(bt_len)) + if result == 0 { + /* Back reference matched. Check for infinite loop. */ + if bt_len == 0 { + empty_br_match = int32(1) + } + if empty_br_match != 0 && **(**int32)(__ccgo_up(states_seen + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*4)) != 0 { + goto backtrack + } + **(**int32)(__ccgo_up(states_seen + uintptr((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id)*4)) = empty_br_match + /* Advance in input string and resync `prev_c', `next_c' + and pos. */ + str_byte = str_byte + uintptr(bt_len-int64(1)) + pos = pos + (bt_len - int64(1)) + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v3 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v3 + if v3 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + } else { + goto backtrack + } + } else { + /* Check for end of string. */ + if **(**Ttre_char_t)(__ccgo_up(bp)) == uint32('\000') { + goto backtrack + } + /* Read the next character. */ + prev_c = **(**Ttre_char_t)(__ccgo_up(bp)) + pos = pos + pos_add_next + v3 = int64(Xmbtowc(tls, bp, str_byte, uint64(MB_LEN_MAX))) + pos_add_next = v3 + if v3 <= 0 { + if pos_add_next < 0 { + ret = int32(REG_NOMATCH) + goto error_exit + } else { + pos_add_next = pos_add_next + 1 + } + } + str_byte = str_byte + uintptr(pos_add_next) + } + next_state = UintptrFromInt32(0) + trans_i = state + for { + if !((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate != 0) { + break + } + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fcode_min <= prev_c && (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fcode_max >= prev_c { + if (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions != 0 && ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOL) != 0 && (pos > 0 || reg_notbol != 0) && (prev_c != uint32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOL) != 0 && (**(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\000') || reg_noteol != 0) && (**(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\n') || !(reg_newline != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_BOW) != 0 && (prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0 || !(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_EOW) != 0 && (!(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) || (**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB) != 0 && (pos != 0 && **(**Ttre_char_t)(__ccgo_up(bp)) != uint32('\000') && BoolInt32(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) == BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_AT_WB_NEG) != 0 && (pos == 0 || **(**Ttre_char_t)(__ccgo_up(bp)) == uint32('\000') || BoolInt32(prev_c == uint32('_') || Xiswalnum(tls, prev_c) != 0) != BoolInt32(**(**Ttre_char_t)(__ccgo_up(bp)) == uint32('_') || Xiswalnum(tls, **(**Ttre_char_t)(__ccgo_up(bp))) != 0)) || ((*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS) != 0 && !((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&Int32FromInt32(REG_ICASE) != 0) && !(Xiswctype(tls, prev_c, *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS) != 0 && (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_ICASE) != 0 && !(Xiswctype(tls, Xtowlower(tls, prev_c), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) && !(Xiswctype(tls, Xtowupper(tls, prev_c), *(*Ttre_ctype_t)(unsafe.Pointer(trans_i + 40))) != 0) || (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fassertions&int32(ASSERT_CHAR_CLASS_NEG) != 0 && _tre_neg_char_classes_match(tls, (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fneg_classes, prev_c, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_ICASE)) != 0)) { + goto _13 + } + if next_state == UintptrFromInt32(0) { + /* First matching transition. */ + next_state = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + next_tags = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + } else { + /* Second matching transition. We may need to backtrack here + to take this transition instead of the first one, so we + push this transition in the backtracking stack so we can + jump back here if needed. */ + if !((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext != 0) { + s1 = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(56)) + if !(s1 != 0) { + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return int32(REG_ESPACE) + } + (*Ttre_backtrack_struct)(unsafe.Pointer(s1)).Fprev = stack + (*Ttre_backtrack_struct)(unsafe.Pointer(s1)).Fnext = UintptrFromInt32(0) + (*Ttre_backtrack_struct)(unsafe.Pointer(s1)).Fitem.Ftags = X__tre_mem_alloc_impl(tls, mem, 0, UintptrFromInt32(0), 0, uint64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)) + if !((*Ttre_backtrack_struct)(unsafe.Pointer(s1)).Fitem.Ftags != 0) { + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return int32(REG_ESPACE) + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext = s1 + stack = s1 + } else { + stack = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fnext + } + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fpos = pos + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstr_byte = str_byte + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate_id = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Fstate_id + (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fnext_c = Int32FromUint32(**(**Ttre_char_t)(__ccgo_up(bp))) + i3 = 0 + for { + if !(i3 < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(i3)*8)) = **(**Tregoff_t)(__ccgo_up(tags + uintptr(i3)*8)) + goto _14 + _14: + ; + i3 = i3 + 1 + } + tmp1 = (*Ttre_tnfa_transition_t)(unsafe.Pointer(trans_i)).Ftags + for { + if !(tmp1 != 0 && **(**int32)(__ccgo_up(tmp1)) >= 0) { + break + } + **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(**(**int32)(__ccgo_up(tmp1)))*8)) = pos + goto _15 + _15: + ; + tmp1 += 4 + } + } + } + goto _13 + _13: + ; + trans_i += 56 + } + if !(next_state != UintptrFromInt32(0)) { + goto _16 + } + /* Matching transitions were found. Take the first one. */ + state = next_state + /* Update the tag values. */ + if next_tags != 0 { + for **(**int32)(__ccgo_up(next_tags)) >= 0 { + v6 = next_tags + next_tags += 4 + **(**Tregoff_t)(__ccgo_up(tags + uintptr(**(**int32)(__ccgo_up(v6)))*8)) = pos + } + } + goto _17 +_16: + ; + goto backtrack +backtrack: + ; + /* A matching transition was not found. Try to backtrack. */ + if (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fprev != 0 { + if (*Ttre_tnfa_transition_t)(unsafe.Pointer((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate)).Fassertions&int32(ASSERT_BACKREF) != 0 { + **(**int32)(__ccgo_up(states_seen + uintptr((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate_id)*4)) = 0 + } + pos = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fpos + str_byte = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstr_byte + state = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fstate + **(**Ttre_char_t)(__ccgo_up(bp)) = Uint32FromInt32((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Fnext_c) + i4 = 0 + for { + if !(i4 < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags) { + break + } + **(**Tregoff_t)(__ccgo_up(tags + uintptr(i4)*8)) = **(**Tregoff_t)(__ccgo_up((*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fitem.Ftags + uintptr(i4)*8)) + goto _19 + _19: + ; + i4 = i4 + 1 + } + stack = (*Ttre_backtrack_struct)(unsafe.Pointer(stack)).Fprev + } else { + if match_eo < 0 { + /* Try starting from a later position in the input string. */ + /* Check for end of string. */ + if **(**Ttre_char_t)(__ccgo_up(bp)) == uint32('\000') { + goto _8 + } + **(**Ttre_char_t)(__ccgo_up(bp)) = Uint32FromInt32(next_c_start) + str_byte = str_byte_start + goto retry + } else { + goto _8 + } + } +_17: + ; + goto _9 +_8: + ; + if match_eo >= 0 { + v20 = REG_OK + } else { + v20 = int32(REG_NOMATCH) + } + ret = v20 + **(**Tregoff_t)(__ccgo_up(match_end_ofs)) = match_eo + goto error_exit +error_exit: + ; + X__tre_mem_destroy(tls, mem) + if tags != 0 { + Xfree(tls, tags) + } + if pmatch != 0 { + Xfree(tls, pmatch) + } + if states_seen != 0 { + Xfree(tls, states_seen) + } + return ret +} + +/*********************************************************************** + from regexec.c +***********************************************************************/ + +// C documentation +// +// /* Fills the POSIX.2 regmatch_t array according to the TNFA tag and match +// endpoint values. */ +func _tre_fill_pmatch(tls *TLS, nmatch Tsize_t, pmatch uintptr, cflags int32, tnfa uintptr, tags uintptr, match_eo Tregoff_t) { + var i, j uint32 + var parents, submatch_data uintptr + var v1 Tregoff_t + _, _, _, _, _ = i, j, parents, submatch_data, v1 + i = uint32(0) + if match_eo >= 0 && !(cflags&Int32FromInt32(REG_NOSUB) != 0) { + /* Construct submatch offsets from the tags. */ + submatch_data = (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fsubmatch_data + for i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches && uint64(i) < nmatch { + if (**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Fso_tag == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fend_tag { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = match_eo + } else { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = **(**Tregoff_t)(__ccgo_up(tags + uintptr((**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Fso_tag)*8)) + } + if (**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Feo_tag == (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fend_tag { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = match_eo + } else { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = **(**Tregoff_t)(__ccgo_up(tags + uintptr((**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Feo_tag)*8)) + } + /* If either of the endpoints were not used, this submatch + was not part of the match. */ + if (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so == int64(-int32(1)) || (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo == int64(-int32(1)) { + v1 = int64(-Int32FromInt32(1)) + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = v1 + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = v1 + } + i = i + 1 + } + /* Reset all submatches that are not within all of their parent + submatches. */ + i = uint32(0) + for i < (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_submatches && uint64(i) < nmatch { + if (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo == int64(-int32(1)) { + } + parents = (**(**Ttre_submatch_data_t)(__ccgo_up(submatch_data + uintptr(i)*16))).Fparents + if parents != UintptrFromInt32(0) { + j = uint32(0) + for { + if !(**(**int32)(__ccgo_up(parents + uintptr(j)*4)) >= 0) { + break + } + if (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so < (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(**(**int32)(__ccgo_up(parents + uintptr(j)*4)))*16))).Frm_so || (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo > (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(**(**int32)(__ccgo_up(parents + uintptr(j)*4)))*16))).Frm_eo { + v1 = int64(-Int32FromInt32(1)) + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = v1 + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = v1 + } + goto _2 + _2: + ; + j = j + 1 + } + } + i = i + 1 + } + } + for uint64(i) < nmatch { + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_so = int64(-int32(1)) + (**(**Tregmatch_t)(__ccgo_up(pmatch + uintptr(i)*16))).Frm_eo = int64(-int32(1)) + i = i + 1 + } +} + +/* + Wrapper functions for POSIX compatible regexp matching. +*/ + +func Xregexec(tls *TLS, preg uintptr, string1 uintptr, nmatch Tsize_t, pmatch uintptr, eflags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v preg=%v string1=%v nmatch=%v pmatch=%v eflags=%v, (%v:)", tls, preg, string1, nmatch, pmatch, eflags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var status Treg_errcode_t + var tags, tnfa uintptr + var _ /* eo at bp+0 */ Tregoff_t + _, _, _ = status, tags, tnfa + tnfa = (*Tregex_t)(unsafe.Pointer(preg)).F__opaque + tags = UintptrFromInt32(0) + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags&int32(REG_NOSUB) != 0 { + nmatch = uint64(0) + } + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags > 0 && nmatch > uint64(0) { + tags = Xmalloc(tls, uint64(8)*Uint64FromInt32((*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fnum_tags)) + if tags == UintptrFromInt32(0) { + return int32(REG_ESPACE) + } + } + /* Dispatch to the appropriate matcher. */ + if (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fhave_backrefs != 0 { + /* The regex has back references, use the backtracking matcher. */ + status = _tre_tnfa_run_backtrack(tls, tnfa, string1, tags, eflags, bp) + } else { + /* Exact matching, no back references, use the parallel matcher. */ + status = _tre_tnfa_run_parallel(tls, tnfa, string1, tags, eflags, bp) + } + if status == REG_OK { + /* A match was found, so fill the submatch registers. */ + _tre_fill_pmatch(tls, nmatch, pmatch, (*Ttre_tnfa_t)(unsafe.Pointer(tnfa)).Fcflags, tnfa, tags, **(**Tregoff_t)(__ccgo_up(bp))) + } + if tags != 0 { + Xfree(tls, tags) + } + return status +} + +/* + This memory allocator is for allocating small memory blocks efficiently + in terms of memory overhead and execution speed. The allocated blocks + cannot be freed individually, only all at once. There can be multiple + allocators, though. +*/ + +// C documentation +// +// /* Returns a new memory allocator or NULL if out of memory. */ +func X__tre_mem_new_impl(tls *TLS, provided int32, provided_block uintptr) (r Ttre_mem_t) { + if __ccgo_strace { + trc("tls=%v provided=%v provided_block=%v, (%v:)", tls, provided, provided_block, origin(2)) + defer func() { trc("-> %v", r) }() + } + var mem Ttre_mem_t + _ = mem + if provided != 0 { + mem = provided_block + Xmemset(tls, mem, 0, uint64(48)) + } else { + mem = Xcalloc(tls, uint64(1), uint64(48)) + } + if mem == UintptrFromInt32(0) { + return UintptrFromInt32(0) + } + return mem +} + +// C documentation +// +// /* Frees the memory allocator and all memory allocated with it. */ +func X__tre_mem_destroy(tls *TLS, mem Ttre_mem_t) { + if __ccgo_strace { + trc("tls=%v mem=%v, (%v:)", tls, mem, origin(2)) + } + var l, tmp uintptr + _, _ = l, tmp + l = (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fblocks + for l != UintptrFromInt32(0) { + Xfree(tls, (*Ttre_list_t)(unsafe.Pointer(l)).Fdata) + tmp = (*Ttre_list_t)(unsafe.Pointer(l)).Fnext + Xfree(tls, l) + l = tmp + } + Xfree(tls, mem) +} + +// C documentation +// +// /* Allocates a block of `size' bytes from `mem'. Returns a pointer to the +// allocated block or NULL if an underlying malloc() failed. */ +func X__tre_mem_alloc_impl(tls *TLS, mem Ttre_mem_t, provided int32, provided_block uintptr, zero int32, size Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v mem=%v provided=%v provided_block=%v zero=%v size=%v, (%v:)", tls, mem, provided, provided_block, zero, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + var block_size int32 + var l, ptr uintptr + var v1 uint64 + _, _, _, _ = block_size, l, ptr, v1 + if (*Ttre_mem_struct)(unsafe.Pointer(mem)).Ffailed != 0 { + return UintptrFromInt32(0) + } + if (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fn < size { + if provided != 0 { + if provided_block == UintptrFromInt32(0) { + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Ffailed = int32(1) + return UintptrFromInt32(0) + } + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr = provided_block + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fn = uint64(TRE_MEM_BLOCK_SIZE) + } else { + if size*uint64(8) > uint64(TRE_MEM_BLOCK_SIZE) { + block_size = Int32FromUint64(size * uint64(8)) + } else { + block_size = int32(TRE_MEM_BLOCK_SIZE) + } + l = Xmalloc(tls, uint64(16)) + if l == UintptrFromInt32(0) { + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Ffailed = int32(1) + return UintptrFromInt32(0) + } + (*Ttre_list_t)(unsafe.Pointer(l)).Fdata = Xmalloc(tls, Uint64FromInt32(block_size)) + if (*Ttre_list_t)(unsafe.Pointer(l)).Fdata == UintptrFromInt32(0) { + Xfree(tls, l) + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Ffailed = int32(1) + return UintptrFromInt32(0) + } + (*Ttre_list_t)(unsafe.Pointer(l)).Fnext = UintptrFromInt32(0) + if (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fcurrent != UintptrFromInt32(0) { + (*Ttre_list_t)(unsafe.Pointer((*Ttre_mem_struct)(unsafe.Pointer(mem)).Fcurrent)).Fnext = l + } + if (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fblocks == UintptrFromInt32(0) { + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fblocks = l + } + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fcurrent = l + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr = (*Ttre_list_t)(unsafe.Pointer(l)).Fdata + (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fn = Uint64FromInt32(block_size) + } + } + /* Make sure the next pointer will be aligned. */ + if (Uint64FromInt64(int64((*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr))+size)%uint64(8) != 0 { + v1 = uint64(8) - (Uint64FromInt64(int64((*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr))+size)%uint64(8) + } else { + v1 = uint64(0) + } + size = size + v1 + /* Allocate from current block. */ + ptr = (*Ttre_mem_struct)(unsafe.Pointer(mem)).Fptr + **(**uintptr)(__ccgo_up(mem + 16)) += uintptr(size) + **(**Tsize_t)(__ccgo_up(mem + 24)) -= size + /* Set to zero if needed. */ + if zero != 0 { + Xmemset(tls, ptr, 0, size) + } + return ptr +} + +const MAXSIZE = 1 +const MINSIZE = 8 + +type TACTION = int32 + +const _FIND = 0 +const _ENTER = 1 + +type TVISIT = int32 + +const _preorder = 0 +const _postorder = 1 +const _endorder = 2 +const _leaf = 3 + +type TENTRY = struct { + Fkey uintptr + Fdata uintptr +} + +type Tentry = TENTRY + +type Thsearch_data = struct { + F__tab uintptr + F__unused1 uint32 + F__unused2 uint32 +} + +type Tqelem = struct { + Fq_forw uintptr + Fq_back uintptr + Fq_data [1]uint8 +} + +/* +open addressing hash table with 2^n table size +quadratic probing is used in case of hash collision +tab indices and hash are size_t +after resize fails with ENOMEM the state of tab is still usable + +with the posix api items cannot be iterated and length cannot be queried +*/ + +type t__tab = struct { + Fentries uintptr + Fmask Tsize_t + Fused Tsize_t +} + +var _htab Thsearch_data + +func _keyhash(tls *TLS, k uintptr) (r Tsize_t) { + var h Tsize_t + var p, v1 uintptr + _, _, _ = h, p, v1 + p = k + h = uint64(0) + for **(**uint8)(__ccgo_up(p)) != 0 { + v1 = p + p = p + 1 + h = uint64(31)*h + uint64(**(**uint8)(__ccgo_up(v1))) + } + return h +} + +func _resize(tls *TLS, nel Tsize_t, htab uintptr) (r int32) { + var e, newe, oldtab uintptr + var i, j, newsize, oldsize, v4 Tsize_t + _, _, _, _, _, _, _, _ = e, i, j, newe, newsize, oldsize, oldtab, v4 + oldsize = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask + uint64(1) + oldtab = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries + if nel > Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(2)+Uint64FromInt32(1) { + nel = Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(2) + Uint64FromInt32(1) + } + newsize = uint64(MINSIZE) + for { + if !(newsize < nel) { + break + } + goto _1 + _1: + ; + newsize = newsize * uint64(2) + } + (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries = Xcalloc(tls, newsize, uint64(16)) + if !((*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries != 0) { + (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries = oldtab + return 0 + } + (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask = newsize - uint64(1) + if !(oldtab != 0) { + return int32(1) + } + e = oldtab + for { + if !(e < oldtab+uintptr(oldsize)*16) { + break + } + if (*TENTRY)(unsafe.Pointer(e)).Fkey != 0 { + i = _keyhash(tls, (*TENTRY)(unsafe.Pointer(e)).Fkey) + j = Uint64FromInt32(1) + for { + newe = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries + uintptr(i&(*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask)*16 + if !((*TENTRY)(unsafe.Pointer(newe)).Fkey != 0) { + break + } + goto _3 + _3: + ; + v4 = j + j = j + 1 + i = i + v4 + } + **(**TENTRY)(__ccgo_up(newe)) = **(**TENTRY)(__ccgo_up(e)) + } + goto _2 + _2: + ; + e += 16 + } + Xfree(tls, oldtab) + return int32(1) +} + +func Xhcreate(tls *TLS, nel Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v nel=%v, (%v:)", tls, nel, origin(2)) + defer func() { trc("-> %v", r) }() + } + return ___hcreate_r(tls, nel, uintptr(unsafe.Pointer(&_htab))) +} + +func Xhdestroy(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + ___hdestroy_r(tls, uintptr(unsafe.Pointer(&_htab))) +} + +func _lookup(tls *TLS, key uintptr, hash Tsize_t, htab uintptr) (r uintptr) { + var e uintptr + var i, j, v2 Tsize_t + _, _, _, _ = e, i, j, v2 + i = hash + j = Uint64FromInt32(1) + for { + e = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries + uintptr(i&(*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask)*16 + if !((*TENTRY)(unsafe.Pointer(e)).Fkey != 0) || Xstrcmp(tls, (*TENTRY)(unsafe.Pointer(e)).Fkey, key) == 0 { + break + } + goto _1 + _1: + ; + v2 = j + j = j + 1 + i = i + v2 + } + return e +} + +func Xhsearch(tls *TLS, item TENTRY, action TACTION) (r uintptr) { + if __ccgo_strace { + trc("tls=%v item=%v action=%v, (%v:)", tls, item, action, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* e at bp+0 */ uintptr + ___hsearch_r(tls, item, action, bp, uintptr(unsafe.Pointer(&_htab))) + return **(**uintptr)(__ccgo_up(bp)) +} + +func ___hcreate_r(tls *TLS, nel Tsize_t, htab uintptr) (r1 int32) { + var r int32 + _ = r + (*Thsearch_data)(unsafe.Pointer(htab)).F__tab = Xcalloc(tls, uint64(1), uint64(24)) + if !((*Thsearch_data)(unsafe.Pointer(htab)).F__tab != 0) { + return 0 + } + r = _resize(tls, nel, htab) + if r == 0 { + Xfree(tls, (*Thsearch_data)(unsafe.Pointer(htab)).F__tab) + (*Thsearch_data)(unsafe.Pointer(htab)).F__tab = uintptr(0) + } + return r +} + +func ___hdestroy_r(tls *TLS, htab uintptr) { + if (*Thsearch_data)(unsafe.Pointer(htab)).F__tab != 0 { + Xfree(tls, (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fentries) + } + Xfree(tls, (*Thsearch_data)(unsafe.Pointer(htab)).F__tab) + (*Thsearch_data)(unsafe.Pointer(htab)).F__tab = uintptr(0) +} + +func ___hsearch_r(tls *TLS, item TENTRY, action TACTION, retval uintptr, htab uintptr) (r int32) { + var e, v2 uintptr + var hash, v1 Tsize_t + _, _, _, _ = e, hash, v1, v2 + hash = _keyhash(tls, item.Fkey) + e = _lookup(tls, item.Fkey, hash, htab) + if (*TENTRY)(unsafe.Pointer(e)).Fkey != 0 { + **(**uintptr)(__ccgo_up(retval)) = e + return int32(1) + } + if action == int32(_FIND) { + **(**uintptr)(__ccgo_up(retval)) = uintptr(0) + return 0 + } + **(**TENTRY)(__ccgo_up(e)) = item + v2 = (*Thsearch_data)(unsafe.Pointer(htab)).F__tab + 16 + *(*Tsize_t)(unsafe.Pointer(v2)) = *(*Tsize_t)(unsafe.Pointer(v2)) + 1 + v1 = *(*Tsize_t)(unsafe.Pointer(v2)) + if v1 > (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask-(*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fmask/uint64(4) { + if !(_resize(tls, uint64(2)*(*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fused, htab) != 0) { + (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fused = (*t__tab)(unsafe.Pointer((*Thsearch_data)(unsafe.Pointer(htab)).F__tab)).Fused - 1 + (*TENTRY)(unsafe.Pointer(e)).Fkey = uintptr(0) + **(**uintptr)(__ccgo_up(retval)) = uintptr(0) + return 0 + } + e = _lookup(tls, item.Fkey, hash, htab) + } + **(**uintptr)(__ccgo_up(retval)) = e + return int32(1) +} + +type Tnode = struct { + Fnext uintptr + Fprev uintptr +} + +func Xinsque(tls *TLS, element uintptr, pred uintptr) { + if __ccgo_strace { + trc("tls=%v element=%v pred=%v, (%v:)", tls, element, pred, origin(2)) + } + var e, p, v1 uintptr + _, _, _ = e, p, v1 + e = element + p = pred + if !(p != 0) { + v1 = UintptrFromInt32(0) + (*Tnode)(unsafe.Pointer(e)).Fprev = v1 + (*Tnode)(unsafe.Pointer(e)).Fnext = v1 + return + } + (*Tnode)(unsafe.Pointer(e)).Fnext = (*Tnode)(unsafe.Pointer(p)).Fnext + (*Tnode)(unsafe.Pointer(e)).Fprev = p + (*Tnode)(unsafe.Pointer(p)).Fnext = e + if (*Tnode)(unsafe.Pointer(e)).Fnext != 0 { + (*Tnode)(unsafe.Pointer((*Tnode)(unsafe.Pointer(e)).Fnext)).Fprev = e + } +} + +func Xremque(tls *TLS, element uintptr) { + if __ccgo_strace { + trc("tls=%v element=%v, (%v:)", tls, element, origin(2)) + } + var e uintptr + _ = e + e = element + if (*Tnode)(unsafe.Pointer(e)).Fnext != 0 { + (*Tnode)(unsafe.Pointer((*Tnode)(unsafe.Pointer(e)).Fnext)).Fprev = (*Tnode)(unsafe.Pointer(e)).Fprev + } + if (*Tnode)(unsafe.Pointer(e)).Fprev != 0 { + (*Tnode)(unsafe.Pointer((*Tnode)(unsafe.Pointer(e)).Fprev)).Fnext = (*Tnode)(unsafe.Pointer(e)).Fnext + } +} + +type t__ccgo_fp__Xlsearch_4 = func(*TLS, uintptr, uintptr) int32 + +func Xlsearch(tls *TLS, key uintptr, base uintptr, nelp uintptr, width Tsize_t, __ccgo_fp_compar uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v base=%v nelp=%v width=%v __ccgo_fp_compar=%v, (%v:)", tls, key, base, nelp, width, __ccgo_fp_compar, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i, n Tsize_t + var p uintptr + var v1 t__predefined_size_t + _, _, _, _ = i, n, p, v1 + defer func() {}() + v1 = width + p = base + n = **(**Tsize_t)(__ccgo_up(nelp)) + i = uint64(0) + for { + if !(i < n) { + break + } + if (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_compar})))(tls, key, p+uintptr(i)*uintptr(v1)) == 0 { + return p + uintptr(i)*uintptr(v1) + } + goto _2 + _2: + ; + i = i + 1 + } + **(**Tsize_t)(__ccgo_up(nelp)) = n + uint64(1) + return Xmemcpy(tls, p+uintptr(n)*uintptr(v1), key, width) +} + +type t__ccgo_fp__Xlfind_4 = func(*TLS, uintptr, uintptr) int32 + +func Xlfind(tls *TLS, key uintptr, base uintptr, nelp uintptr, width Tsize_t, __ccgo_fp_compar uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v base=%v nelp=%v width=%v __ccgo_fp_compar=%v, (%v:)", tls, key, base, nelp, width, __ccgo_fp_compar, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i, n Tsize_t + var p uintptr + var v1 t__predefined_size_t + _, _, _, _ = i, n, p, v1 + defer func() {}() + v1 = width + p = base + n = **(**Tsize_t)(__ccgo_up(nelp)) + i = uint64(0) + for { + if !(i < n) { + break + } + if (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_compar})))(tls, key, p+uintptr(i)*uintptr(v1)) == 0 { + return p + uintptr(i)*uintptr(v1) + } + goto _2 + _2: + ; + i = i + 1 + } + return uintptr(0) +} + +const MAXH = 0 + +type Tnode1 = struct { + Fkey uintptr + Fa [2]uintptr + Fh int32 +} + +type t__ccgo_fp__Xtdelete_2 = func(*TLS, uintptr, uintptr) int32 + +func Xtdelete(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v rootp=%v __ccgo_fp_cmp=%v, (%v:)", tls, key, rootp, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a [97]uintptr + var c, i, v1 int32 + var child, deleted, n, parent uintptr + _, _, _, _, _, _, _, _ = a, c, child, deleted, i, n, parent, v1 + if !(rootp != 0) { + return uintptr(0) + } + n = **(**uintptr)(__ccgo_up(rootp)) + i = 0 + /* *a[0] is an arbitrary non-null pointer that is returned when + the root node is deleted. */ + v1 = i + i = i + 1 + a[v1] = rootp + v1 = i + i = i + 1 + a[v1] = rootp + for { + if !(n != 0) { + return uintptr(0) + } + c = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, key, (*Tnode1)(unsafe.Pointer(n)).Fkey) + if !(c != 0) { + break + } + v1 = i + i = i + 1 + a[v1] = n + 8 + BoolUintptr(c > 0)*8 + n = **(**uintptr)(__ccgo_up(n + 8 + BoolUintptr(c > 0)*8)) + goto _3 + _3: + } + parent = **(**uintptr)(__ccgo_up(a[i-int32(2)])) + if **(**uintptr)(__ccgo_up(n + 8)) != 0 { + /* free the preceding node instead of the deleted one. */ + deleted = n + v1 = i + i = i + 1 + a[v1] = n + 8 + n = **(**uintptr)(__ccgo_up(n + 8)) + for **(**uintptr)(__ccgo_up(n + 8 + 1*8)) != 0 { + v1 = i + i = i + 1 + a[v1] = n + 8 + 1*8 + n = **(**uintptr)(__ccgo_up(n + 8 + 1*8)) + } + (*Tnode1)(unsafe.Pointer(deleted)).Fkey = (*Tnode1)(unsafe.Pointer(n)).Fkey + child = **(**uintptr)(__ccgo_up(n + 8)) + } else { + child = **(**uintptr)(__ccgo_up(n + 8 + 1*8)) + } + /* freed node has at most one child, move it up and rebalance. */ + Xfree(tls, n) + i = i - 1 + v1 = i + **(**uintptr)(__ccgo_up(a[v1])) = child + for { + i = i - 1 + v1 = i + if !(v1 != 0 && X__tsearch_balance(tls, a[i]) != 0) { + break + } + } + return parent +} + +type t__ccgo_fp__Xtdestroy_1 = func(*TLS, uintptr) + +func Xtdestroy(tls *TLS, root uintptr, __ccgo_fp_freekey uintptr) { + if __ccgo_strace { + trc("tls=%v root=%v __ccgo_fp_freekey=%v, (%v:)", tls, root, __ccgo_fp_freekey, origin(2)) + } + var r uintptr + _ = r + r = root + if r == uintptr(0) { + return + } + Xtdestroy(tls, **(**uintptr)(__ccgo_up(r + 8)), __ccgo_fp_freekey) + Xtdestroy(tls, **(**uintptr)(__ccgo_up(r + 8 + 1*8)), __ccgo_fp_freekey) + if __ccgo_fp_freekey != 0 { + (*(*func(*TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_freekey})))(tls, (*Tnode1)(unsafe.Pointer(r)).Fkey) + } + Xfree(tls, r) +} + +type t__ccgo_fp__Xtfind_2 = func(*TLS, uintptr, uintptr) int32 + +func Xtfind(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v rootp=%v __ccgo_fp_cmp=%v, (%v:)", tls, key, rootp, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c int32 + var n uintptr + _, _ = c, n + if !(rootp != 0) { + return uintptr(0) + } + n = **(**uintptr)(__ccgo_up(rootp)) + for { + if !(n != 0) { + break + } + c = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, key, (*Tnode1)(unsafe.Pointer(n)).Fkey) + if !(c != 0) { + break + } + n = **(**uintptr)(__ccgo_up(n + 8 + BoolUintptr(c > 0)*8)) + goto _1 + _1: + } + return n +} + +func _height(tls *TLS, n uintptr) (r int32) { + var v1 int32 + _ = v1 + if n != 0 { + v1 = (*Tnode1)(unsafe.Pointer(n)).Fh + } else { + v1 = 0 + } + return v1 +} + +func _rot(tls *TLS, p uintptr, x uintptr, dir int32) (r int32) { + var hx, hz int32 + var y, z uintptr + _, _, _, _ = hx, hz, y, z + y = **(**uintptr)(__ccgo_up(x + 8 + uintptr(dir)*8)) + z = **(**uintptr)(__ccgo_up(y + 8 + BoolUintptr(!(dir != 0))*8)) + hx = (*Tnode1)(unsafe.Pointer(x)).Fh + hz = _height(tls, z) + if hz > _height(tls, **(**uintptr)(__ccgo_up(y + 8 + uintptr(dir)*8))) { + /* + * x + * / \ dir z + * A y / * / \ --> x y + * z D /| | * / \ A B C D + * B C + */ + **(**uintptr)(__ccgo_up(x + 8 + uintptr(dir)*8)) = **(**uintptr)(__ccgo_up(z + 8 + BoolUintptr(!(dir != 0))*8)) + **(**uintptr)(__ccgo_up(y + 8 + BoolUintptr(!(dir != 0))*8)) = **(**uintptr)(__ccgo_up(z + 8 + uintptr(dir)*8)) + **(**uintptr)(__ccgo_up(z + 8 + BoolUintptr(!(dir != 0))*8)) = x + **(**uintptr)(__ccgo_up(z + 8 + uintptr(dir)*8)) = y + (*Tnode1)(unsafe.Pointer(x)).Fh = hz + (*Tnode1)(unsafe.Pointer(y)).Fh = hz + (*Tnode1)(unsafe.Pointer(z)).Fh = hz + int32(1) + } else { + /* + * x y + * / \ / * A y --> x D + * / \ / * z D A z + */ + **(**uintptr)(__ccgo_up(x + 8 + uintptr(dir)*8)) = z + **(**uintptr)(__ccgo_up(y + 8 + BoolUintptr(!(dir != 0))*8)) = x + (*Tnode1)(unsafe.Pointer(x)).Fh = hz + int32(1) + (*Tnode1)(unsafe.Pointer(y)).Fh = hz + int32(2) + z = y + } + **(**uintptr)(__ccgo_up(p)) = z + return (*Tnode1)(unsafe.Pointer(z)).Fh - hx +} + +// C documentation +// +// /* balance *p, return 0 if height is unchanged. */ +func X__tsearch_balance(tls *TLS, p uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h0, h1, old, v1 int32 + var n uintptr + _, _, _, _, _ = h0, h1, n, old, v1 + n = **(**uintptr)(__ccgo_up(p)) + h0 = _height(tls, **(**uintptr)(__ccgo_up(n + 8))) + h1 = _height(tls, **(**uintptr)(__ccgo_up(n + 8 + 1*8))) + if Uint32FromInt32(h0-h1)+uint32(1) < uint32(3) { + old = (*Tnode1)(unsafe.Pointer(n)).Fh + if h0 < h1 { + v1 = h1 + int32(1) + } else { + v1 = h0 + int32(1) + } + (*Tnode1)(unsafe.Pointer(n)).Fh = v1 + return (*Tnode1)(unsafe.Pointer(n)).Fh - old + } + return _rot(tls, p, n, BoolInt32(h0 < h1)) +} + +type t__ccgo_fp__Xtsearch_2 = func(*TLS, uintptr, uintptr) int32 + +func Xtsearch(tls *TLS, key uintptr, rootp uintptr, __ccgo_fp_cmp uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v rootp=%v __ccgo_fp_cmp=%v, (%v:)", tls, key, rootp, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var a [96]uintptr + var c, i, v1 int32 + var n, r, v4 uintptr + var v7 bool + _, _, _, _, _, _, _, _ = a, c, i, n, r, v1, v4, v7 + if !(rootp != 0) { + return uintptr(0) + } + n = **(**uintptr)(__ccgo_up(rootp)) + i = 0 + v1 = i + i = i + 1 + a[v1] = rootp + for { + if !(n != 0) { + break + } + c = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, key, (*Tnode1)(unsafe.Pointer(n)).Fkey) + if !(c != 0) { + return n + } + v1 = i + i = i + 1 + a[v1] = n + 8 + BoolUintptr(c > 0)*8 + n = **(**uintptr)(__ccgo_up(n + 8 + BoolUintptr(c > 0)*8)) + goto _2 + _2: + } + r = Xmalloc(tls, uint64(32)) + if !(r != 0) { + return uintptr(0) + } + (*Tnode1)(unsafe.Pointer(r)).Fkey = key + v4 = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(r + 8 + 1*8)) = v4 + **(**uintptr)(__ccgo_up(r + 8)) = v4 + (*Tnode1)(unsafe.Pointer(r)).Fh = int32(1) + /* insert new node, rebalance ancestors. */ + i = i - 1 + v1 = i + **(**uintptr)(__ccgo_up(a[v1])) = r + for { + if v7 = i != 0; v7 { + i = i - 1 + v1 = i + } + if !(v7 && X__tsearch_balance(tls, a[v1]) != 0) { + break + } + } + return r +} + +func _walk(tls *TLS, r uintptr, __ccgo_fp_action uintptr, d int32) { + if !(r != 0) { + return + } + if (*Tnode1)(unsafe.Pointer(r)).Fh == int32(1) { + (*(*func(*TLS, uintptr, TVISIT, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_action})))(tls, r, int32(_leaf), d) + } else { + (*(*func(*TLS, uintptr, TVISIT, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_action})))(tls, r, int32(_preorder), d) + _walk(tls, **(**uintptr)(__ccgo_up(r + 8)), __ccgo_fp_action, d+int32(1)) + (*(*func(*TLS, uintptr, TVISIT, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_action})))(tls, r, int32(_postorder), d) + _walk(tls, **(**uintptr)(__ccgo_up(r + 8 + 1*8)), __ccgo_fp_action, d+int32(1)) + (*(*func(*TLS, uintptr, TVISIT, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_action})))(tls, r, int32(_endorder), d) + } +} + +type t__ccgo_fp__Xtwalk_1 = func(*TLS, uintptr, int32, int32) + +func Xtwalk(tls *TLS, root uintptr, __ccgo_fp_action uintptr) { + if __ccgo_strace { + trc("tls=%v root=%v __ccgo_fp_action=%v, (%v:)", tls, root, __ccgo_fp_action, origin(2)) + } + _walk(tls, root, __ccgo_fp_action, 0) +} + +func Xpoll(tls *TLS, fds uintptr, n Tnfds_t, timeout int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fds=%v n=%v timeout=%v, (%v:)", tls, fds, n, timeout, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uintptr + _ = v1 + if timeout >= 0 { + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: int64(timeout / int32(1000)), + 1: int64(timeout % int32(1000) * int32(1000000)), + } + v1 = bp + } else { + v1 = uintptr(0) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_ppoll), int64(fds), Int64FromUint64(n), int64(v1), int64(Int32FromInt32(0)), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), 0)))) +} + +func Xppoll(tls *TLS, fds uintptr, n Tnfds_t, to uintptr, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fds=%v n=%v to=%v mask=%v, (%v:)", tls, fds, n, to, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var ns, v1, v2 int64 + var s Ttime_t + var v3 uintptr + _, _, _, _, _ = ns, s, v1, v2, v3 + if to != 0 { + v1 = (*Ttimespec)(unsafe.Pointer(to)).Ftv_sec + } else { + v1 = 0 + } + s = v1 + if to != 0 { + v2 = (*Ttimespec)(unsafe.Pointer(to)).Ftv_nsec + } else { + v2 = 0 + } + ns = v2 + if to != 0 { + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: s, + 1: ns, + } + v3 = bp + } else { + v3 = uintptr(0) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_ppoll), int64(fds), Int64FromUint64(n), int64(v3), int64(mask), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), 0)))) +} + +func Xpselect(tls *TLS, n int32, rfds uintptr, wfds uintptr, efds uintptr, ts uintptr, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v n=%v rfds=%v wfds=%v efds=%v ts=%v mask=%v, (%v:)", tls, n, rfds, wfds, efds, ts, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ns, v1, v2 int64 + var s Ttime_t + var v3 uintptr + var _ /* data at bp+16 */ [2]Tsyscall_arg_t + _, _, _, _, _ = ns, s, v1, v2, v3 + **(**[2]Tsyscall_arg_t)(__ccgo_up(bp + 16)) = [2]Tsyscall_arg_t{ + 0: Int64FromUint64(uint64(mask)), + 1: int64(Int32FromInt32(_NSIG) / Int32FromInt32(8)), + } + if ts != 0 { + v1 = (*Ttimespec)(unsafe.Pointer(ts)).Ftv_sec + } else { + v1 = 0 + } + s = v1 + if ts != 0 { + v2 = (*Ttimespec)(unsafe.Pointer(ts)).Ftv_nsec + } else { + v2 = 0 + } + ns = v2 + if ts != 0 { + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: s, + 1: ns, + } + v3 = bp + } else { + v3 = uintptr(0) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pselect6), int64(n), int64(rfds), int64(wfds), int64(efds), int64(v3), int64(bp+16))))) +} + +func Xselect(tls *TLS, n int32, rfds uintptr, wfds uintptr, efds uintptr, tv uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v n=%v rfds=%v wfds=%v efds=%v tv=%v, (%v:)", tls, n, rfds, wfds, efds, tv, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var max_time, s Ttime_t + var ns, v1, v2 int64 + var us Tsuseconds_t + var v3 uintptr + _, _, _, _, _, _, _ = max_time, ns, s, us, v1, v2, v3 + if tv != 0 { + v1 = (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec + } else { + v1 = 0 + } + s = v1 + if tv != 0 { + v2 = (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec + } else { + v2 = 0 + } + us = v2 + max_time = Int64FromUint64(Uint64FromUint64(1)<<(Uint64FromInt32(8)*Uint64FromInt64(8)-Uint64FromInt32(1)) - Uint64FromInt32(1)) + if s < 0 || us < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + if us/int64(1000000) > max_time-s { + s = max_time + us = int64(999999) + ns = int64(999999999) + } else { + s = s + us/int64(1000000) + us = us % int64(1000000) + ns = us * int64(1000) + } + if tv != 0 { + *(*[2]int64)(unsafe.Pointer(bp)) = [2]int64{ + 0: s, + 1: ns, + } + v3 = bp + } else { + v3 = uintptr(0) + } + *(*[2]Tsyscall_arg_t)(unsafe.Pointer(bp + 16)) = [2]Tsyscall_arg_t{ + 1: int64(Int32FromInt32(_NSIG) / Int32FromInt32(8)), + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pselect6), int64(n), int64(rfds), int64(wfds), int64(efds), int64(v3), int64(bp+16))))) +} + +var _all_mask = [1]uint64{ + 0: -Uint64FromUint64(1), +} + +var _app_mask = [1]uint64{ + 0: uint64(0xfffffffc7fffffff), +} + +func X__block_all_sigs(tls *TLS, set uintptr) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_BLOCK)), int64(uintptr(unsafe.Pointer(&_all_mask))), int64(set), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) +} + +func X__block_app_sigs(tls *TLS, set uintptr) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_BLOCK)), int64(uintptr(unsafe.Pointer(&_app_mask))), int64(set), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) +} + +func X__restore_sigs(tls *TLS, set uintptr) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_SETMASK)), int64(set), int64(Int32FromInt32(0)), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) +} + +func Xgetitimer(tls *TLS, which int32, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v which=%v old=%v, (%v:)", tls, which, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var r int32 + var _ /* old32 at bp+0 */ [4]int64 + _ = r + if uint64(8) > uint64(8) { + r = int32(X__syscall2(tls, int64(SYS_getitimer), int64(which), int64(bp))) + if !(r != 0) { + (*Titimerval)(unsafe.Pointer(old)).Fit_interval.Ftv_sec = (**(**[4]int64)(__ccgo_up(bp)))[0] + (*Titimerval)(unsafe.Pointer(old)).Fit_interval.Ftv_usec = (**(**[4]int64)(__ccgo_up(bp)))[int32(1)] + (*Titimerval)(unsafe.Pointer(old)).Fit_value.Ftv_sec = (**(**[4]int64)(__ccgo_up(bp)))[int32(2)] + (*Titimerval)(unsafe.Pointer(old)).Fit_value.Ftv_usec = (**(**[4]int64)(__ccgo_up(bp)))[int32(3)] + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getitimer), int64(which), int64(old))))) +} + +func Xkill(tls *TLS, pid Tpid_t, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v pid=%v sig=%v, (%v:)", tls, pid, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_kill), int64(pid), int64(sig))))) +} + +func Xkillpg(tls *TLS, pgid Tpid_t, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v pgid=%v sig=%v, (%v:)", tls, pgid, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + if pgid < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + return Xkill(tls, -pgid, sig) +} + +func Xpsiginfo(tls *TLS, si uintptr, msg uintptr) { + if __ccgo_strace { + trc("tls=%v si=%v msg=%v, (%v:)", tls, si, msg, origin(2)) + } + Xpsignal(tls, (*Tsiginfo_t)(unsafe.Pointer(si)).Fsi_signo, msg) +} + +func Xpsignal(tls *TLS, sig int32, msg uintptr) { + if __ccgo_strace { + trc("tls=%v sig=%v msg=%v, (%v:)", tls, sig, msg, origin(2)) + } + bp := tls.Alloc(32) + defer tls.Free(32) + var __need_unlock, old_errno, old_mode, v1 int32 + var f, old_locale, s, v2, v3 uintptr + _, _, _, _, _, _, _, _, _ = __need_unlock, f, old_errno, old_locale, old_mode, s, v1, v2, v3 + f = uintptr(unsafe.Pointer(&X__stderr_FILE)) + s = Xstrsignal(tls, sig) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + /* Save stderr's orientation and encoding rule, since psignal is not + * permitted to change them. Save errno and restore it if there is no + * error since fprintf might change it even on success but psignal is + * not permitted to do so. */ + old_locale = (*TFILE)(unsafe.Pointer(f)).Flocale + old_mode = (*TFILE)(unsafe.Pointer(f)).Fmode + old_errno = **(**int32)(__ccgo_up(X__errno_location(tls))) + if msg != 0 { + v2 = msg + } else { + v2 = __ccgo_ts + } + if msg != 0 { + v3 = __ccgo_ts + 289 + } else { + v3 = __ccgo_ts + } + if Xfprintf(tls, f, __ccgo_ts+1072, VaList(bp+8, v2, v3, s)) >= 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = old_errno + } + (*TFILE)(unsafe.Pointer(f)).Fmode = old_mode + (*TFILE)(unsafe.Pointer(f)).Flocale = old_locale + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xraise(tls *TLS, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v sig=%v, (%v:)", tls, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var ret int32 + var _ /* set at bp+0 */ Tsigset_t + _ = ret + X__block_app_sigs(tls, bp) + ret = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_tkill), int64((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid), int64(sig))))) + X__restore_sigs(tls, bp) + return ret +} + +/* These functions will not work, but suffice for targets where the + * kernel sigaction structure does not actually use sa_restorer. */ +func X__restore(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func X__restore_rt(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } +} + +func Xsetitimer(tls *TLS, which int32, new1 uintptr, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v which=%v new1=%v old=%v, (%v:)", tls, which, new1, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var is, vs Ttime_t + var ius, vus int64 + var r int32 + var _ /* old32 at bp+32 */ [4]int64 + _, _, _, _, _ = is, ius, r, vs, vus + if uint64(8) > uint64(8) { + is = (*Titimerval)(unsafe.Pointer(new1)).Fit_interval.Ftv_sec + vs = (*Titimerval)(unsafe.Pointer(new1)).Fit_value.Ftv_sec + ius = (*Titimerval)(unsafe.Pointer(new1)).Fit_interval.Ftv_usec + vus = (*Titimerval)(unsafe.Pointer(new1)).Fit_value.Ftv_usec + if !!((Uint64FromInt64(is)+Uint64FromUint64(0x80000000))>>Int32FromInt32(32) != 0) || !!((Uint64FromInt64(vs)+Uint64FromUint64(0x80000000))>>Int32FromInt32(32) != 0) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } + *(*[4]int64)(unsafe.Pointer(bp)) = [4]int64{ + 0: is, + 1: ius, + 2: vs, + 3: vus, + } + r = int32(X__syscall3(tls, int64(SYS_setitimer), int64(which), int64(bp), int64(bp+32))) + if !(r != 0) && old != 0 { + (*Titimerval)(unsafe.Pointer(old)).Fit_interval.Ftv_sec = (**(**[4]int64)(__ccgo_up(bp + 32)))[0] + (*Titimerval)(unsafe.Pointer(old)).Fit_interval.Ftv_usec = (**(**[4]int64)(__ccgo_up(bp + 32)))[int32(1)] + (*Titimerval)(unsafe.Pointer(old)).Fit_value.Ftv_sec = (**(**[4]int64)(__ccgo_up(bp + 32)))[int32(2)] + (*Titimerval)(unsafe.Pointer(old)).Fit_value.Ftv_usec = (**(**[4]int64)(__ccgo_up(bp + 32)))[int32(3)] + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_setitimer), int64(which), int64(new1), int64(old))))) +} + +type Tk_sigaction = struct { + Fhandler uintptr + Fflags uint64 + Frestorer uintptr + Fmask [2]uint32 +} + +var _unmask_done int32 +var _handler_set [1]uint64 + +func X__get_handler_set(tls *TLS, set uintptr) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + } + Xmemcpy(tls, set, uintptr(unsafe.Pointer(&_handler_set)), uint64(8)) +} + +func X__libc_sigaction(tls *TLS, sig int32, sa uintptr, old1 uintptr) (r2 int32) { + if __ccgo_strace { + trc("tls=%v sig=%v sa=%v old1=%v, (%v:)", tls, sig, sa, old1, origin(2)) + defer func() { trc("-> %v", r2) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var old, r, r1, v, v12, v15, v19, v22, v4, v7 int32 + var v1, v10, v11, v18, v3 uintptr + var v2 int64 + var _ /* ksa at bp+16 */ Tk_sigaction + var _ /* ksa_old at bp+48 */ Tk_sigaction + var _ /* u at bp+8 */ struct { + Fr [0][2]Tuint32_t + Fv Tuint64_t + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = old, r, r1, v, v1, v10, v11, v12, v15, v18, v19, v2, v22, v3, v4, v7 + if sa != 0 { + if uint64(*(*uintptr)(unsafe.Pointer(sa))) > uint64(1) { + v1 = uintptr(unsafe.Pointer(&_handler_set)) + uintptr(Uint64FromInt32(sig-Int32FromInt32(1))/(Uint64FromInt32(8)*Uint64FromInt64(8)))*8 + v2 = Int64FromUint64(uint64(1) << (Uint64FromInt32(sig-Int32FromInt32(1)) % (Uint64FromInt32(8) * Uint64FromInt64(8)))) + if Uint64FromInt64(8) == Uint64FromInt64(4) { + v3 = v1 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1487) + v7 = v + goto _8 + _8: + old = v7 + goto _6 + _6: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1487) + v4 = BoolInt32(!(r != 0)) + goto _5 + _5: + ; + if !!(v4 != 0) { + break + } + } + _ = old + goto _9 + _9: + } else { + v10 = v1 + *(*struct { + Fr [0][2]Tuint32_t + Fv Tuint64_t + })(unsafe.Pointer(bp + 8)) = struct { + Fr [0][2]Tuint32_t + Fv Tuint64_t + }{} + *(*uint64)(unsafe.Pointer(bp + 8)) = Uint64FromInt64(v2) + if **(**Tuint32_t)(__ccgo_up(bp + 8)) != 0 { + v11 = v10 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1487) + v15 = v + goto _16 + _16: + old = v15 + goto _14 + _14: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1487) + v12 = BoolInt32(!(r != 0)) + goto _13 + _13: + ; + if !!(v12 != 0) { + break + } + } + _ = old + goto _17 + _17: + } + if **(**Tuint32_t)(__ccgo_up(bp + 8 + 1*4)) != 0 { + v18 = v10 + uintptr(1)*4 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1487) + v22 = v + goto _23 + _23: + old = v22 + goto _21 + _21: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1487) + v19 = BoolInt32(!(r != 0)) + goto _20 + _20: + ; + if !!(v19 != 0) { + break + } + } + _ = old + goto _24 + _24: + } + } + /* If pthread_create has not yet been called, + * implementation-internal signals might not + * yet have been unblocked. They must be + * unblocked before any signal handler is + * installed, so that an application cannot + * receive an illegal sigset_t (with them + * blocked) as part of the ucontext_t passed + * to the signal handler. */ + if !(X__libc.Fthreaded != 0) && !(_unmask_done != 0) { + *(*[1]uint64)(unsafe.Pointer(bp)) = [1]uint64{ + 0: Uint64FromUint64(3) << (Int32FromInt32(32) * BoolInt32(Uint64FromInt64(8) > Uint64FromInt32(4))), + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_UNBLOCK)), int64(bp), int64(Int32FromInt32(0)), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) + _unmask_done = int32(1) + } + if !((*Tsigaction)(unsafe.Pointer(sa)).Fsa_flags&Int32FromInt32(SA_RESTART) != 0) { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1487) + AtomicStorePInt32(uintptr(unsafe.Pointer(&X__eintr_valid_flag)), int32(1)) + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1487) + } + } + (**(**Tk_sigaction)(__ccgo_up(bp + 16))).Fhandler = *(*uintptr)(unsafe.Pointer(sa)) + (**(**Tk_sigaction)(__ccgo_up(bp + 16))).Fflags = Uint64FromInt32((*Tsigaction)(unsafe.Pointer(sa)).Fsa_flags) + (**(**Tk_sigaction)(__ccgo_up(bp + 16))).Fflags |= uint64(SA_RESTORER) + if (*Tsigaction)(unsafe.Pointer(sa)).Fsa_flags&int32(SA_SIGINFO) != 0 { + v1 = __ccgo_fp(X__restore_rt) + } else { + v1 = __ccgo_fp(X__restore) + } + (**(**Tk_sigaction)(__ccgo_up(bp + 16))).Frestorer = v1 + Xmemcpy(tls, bp+16+24, sa+8, Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))) + } + if sa != 0 { + v1 = bp + 16 + } else { + v1 = uintptr(0) + } + if old1 != 0 { + v3 = bp + 48 + } else { + v3 = uintptr(0) + } + r1 = int32(X__syscall4(tls, int64(SYS_rt_sigaction), int64(sig), int64(v1), int64(v3), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)))) + if old1 != 0 && !(r1 != 0) { + *(*uintptr)(unsafe.Pointer(old1)) = (**(**Tk_sigaction)(__ccgo_up(bp + 48))).Fhandler + (*Tsigaction)(unsafe.Pointer(old1)).Fsa_flags = Int32FromUint64((**(**Tk_sigaction)(__ccgo_up(bp + 48))).Fflags) + Xmemcpy(tls, old1+8, bp+48+24, Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r1))) +} + +func X__sigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v sig=%v sa=%v old=%v, (%v:)", tls, sig, sa, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r int32 + var _ /* set at bp+0 */ [1]uint64 + _ = r + if Uint32FromInt32(sig)-uint32(32) < uint32(3) || Uint32FromInt32(sig)-uint32(1) >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + /* Doing anything with the disposition of SIGABRT requires a lock, + * so that it cannot be changed while abort is terminating the + * process and so any change made by abort can't be observed. */ + if sig == int32(SIGABRT) { + X__block_all_sigs(tls, bp) + ___lock(tls, uintptr(unsafe.Pointer(&X__abort_lock))) + } + r = X__libc_sigaction(tls, sig, sa, old) + if sig == int32(SIGABRT) { + ___unlock(tls, uintptr(unsafe.Pointer(&X__abort_lock))) + X__restore_sigs(tls, bp) + } + return r +} + +func Xsigaction(tls *TLS, sig int32, sa uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v sig=%v sa=%v old=%v, (%v:)", tls, sig, sa, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__sigaction(tls, sig, sa, old) +} + +func Xsigaddset(tls *TLS, set uintptr, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v sig=%v, (%v:)", tls, set, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uint32 + _ = s + s = Uint32FromInt32(sig - int32(1)) + if s >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) || Uint32FromInt32(sig)-uint32(32) < uint32(3) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + **(**uint64)(__ccgo_up(set + uintptr(uint64(s/uint32(8))/uint64(8))*8)) |= uint64(1) << (uint64(s) & (Uint64FromInt32(8)*Uint64FromInt64(8) - Uint64FromInt32(1))) + return 0 +} + +func Xsigaltstack(tls *TLS, ss uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ss=%v old=%v, (%v:)", tls, ss, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + if ss != 0 { + if !((*Tstack_t)(unsafe.Pointer(ss)).Fss_flags&Int32FromInt32(SS_DISABLE) != 0) && (*Tstack_t)(unsafe.Pointer(ss)).Fss_size < uint64(MINSIGSTKSZ) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return -int32(1) + } + if (*Tstack_t)(unsafe.Pointer(ss)).Fss_flags&int32(SS_ONSTACK) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_sigaltstack), int64(ss), int64(old))))) +} + +const SST_SIZE = 8 + +func Xsigandset(tls *TLS, dest uintptr, left uintptr, right uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v dest=%v left=%v right=%v, (%v:)", tls, dest, left, right, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var d, l, r uintptr + var i uint64 + _, _, _, _ = d, i, l, r + i = uint64(0) + d = dest + l = left + r = right + for { + if !(i < Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))/Uint64FromInt64(8)) { + break + } + **(**uint64)(__ccgo_up(d + uintptr(i)*8)) = **(**uint64)(__ccgo_up(l + uintptr(i)*8)) & **(**uint64)(__ccgo_up(r + uintptr(i)*8)) + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +func Xsigdelset(tls *TLS, set uintptr, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v sig=%v, (%v:)", tls, set, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uint32 + _ = s + s = Uint32FromInt32(sig - int32(1)) + if s >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) || Uint32FromInt32(sig)-uint32(32) < uint32(3) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + **(**uint64)(__ccgo_up(set + uintptr(uint64(s/uint32(8))/uint64(8))*8)) &= ^(Uint64FromUint64(1) << (uint64(s) & (Uint64FromInt32(8)*Uint64FromInt64(8) - Uint64FromInt32(1)))) + return 0 +} + +func Xsigemptyset(tls *TLS, set uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**uint64)(__ccgo_up(set)) = uint64(0) + if Bool(uint64(8) == uint64(4)) || Bool(int32(_NSIG) > int32(65)) { + **(**uint64)(__ccgo_up(set + 1*8)) = uint64(0) + } + if Bool(uint64(8) == uint64(4)) && Bool(int32(_NSIG) > int32(65)) { + **(**uint64)(__ccgo_up(set + 2*8)) = uint64(0) + **(**uint64)(__ccgo_up(set + 3*8)) = uint64(0) + } + return 0 +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xsigfillset(tls *TLS, set uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**uint64)(__ccgo_up(set)) = uint64(0xfffffffc7fffffff) + if int32(_NSIG) > int32(65) { + **(**uint64)(__ccgo_up(set + 1*8)) = uint64(0xffffffffffffffff) + } + return 0 +} + +func Xsigisemptyset(tls *TLS, set uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i Tsize_t + _ = i + i = uint64(0) + for { + if !(i < Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))/Uint64FromInt64(8)) { + break + } + if **(**uint64)(__ccgo_up(set + uintptr(i)*8)) != 0 { + return 0 + } + goto _1 + _1: + ; + i = i + 1 + } + return int32(1) +} + +func Xsigismember(tls *TLS, set uintptr, sig int32) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v sig=%v, (%v:)", tls, set, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uint32 + _ = s + s = Uint32FromInt32(sig - int32(1)) + if s >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) { + return 0 + } + return BoolInt32(!!(**(**uint64)(__ccgo_up(set + uintptr(uint64(s/uint32(8))/uint64(8))*8))&(Uint64FromUint64(1)<<(uint64(s)&(Uint64FromInt32(8)*Uint64FromInt64(8)-Uint64FromInt32(1)))) != 0)) +} + +func Xsigorset(tls *TLS, dest uintptr, left uintptr, right uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v dest=%v left=%v right=%v, (%v:)", tls, dest, left, right, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var d, l, r uintptr + var i uint64 + _, _, _, _ = d, i, l, r + i = uint64(0) + d = dest + l = left + r = right + for { + if !(i < Uint64FromInt32(Int32FromInt32(_NSIG)/Int32FromInt32(8))/Uint64FromInt64(8)) { + break + } + **(**uint64)(__ccgo_up(d + uintptr(i)*8)) = **(**uint64)(__ccgo_up(l + uintptr(i)*8)) | **(**uint64)(__ccgo_up(r + uintptr(i)*8)) + goto _1 + _1: + ; + i = i + 1 + } + return 0 +} + +func Xsigpending(tls *TLS, set uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v set=%v, (%v:)", tls, set, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_rt_sigpending), int64(set), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)))))) +} + +func Xsigprocmask(tls *TLS, how int32, set uintptr, old uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v how=%v set=%v old=%v, (%v:)", tls, how, set, old, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = _pthread_sigmask(tls, how, set, old) + if !(r != 0) { + return r + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = r + return -int32(1) +} + +func Xsigqueue(tls *TLS, pid Tpid_t, sig int32, value Tsigval) (r1 int32) { + if __ccgo_strace { + trc("tls=%v pid=%v sig=%v value=%v, (%v:)", tls, pid, sig, value, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(256) + defer tls.Free(256) + var r int32 + var _ /* set at bp+128 */ Tsigset_t + var _ /* si at bp+0 */ Tsiginfo_t + _ = r + Xmemset(tls, bp, 0, uint64(128)) + (**(**Tsiginfo_t)(__ccgo_up(bp))).Fsi_signo = sig + (**(**Tsiginfo_t)(__ccgo_up(bp))).Fsi_code = -int32(1) + *(*Tsigval)(unsafe.Pointer(bp + 16 + 8)) = value + *(*Tuid_t)(unsafe.Pointer(bp + 16 + 4)) = Xgetuid(tls) + X__block_app_sigs(tls, bp+128) + *(*Tpid_t)(unsafe.Pointer(bp + 16)) = Xgetpid(tls) + r = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_rt_sigqueueinfo), int64(pid), int64(sig), int64(bp))))) + X__restore_sigs(tls, bp+128) + return r +} + +func X__libc_current_sigrtmax(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int32FromInt32(_NSIG) - Int32FromInt32(1) +} + +func X__libc_current_sigrtmin(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(35) +} + +type t__jmp_buf = [22]uint64 + +type Tjmp_buf = [1]t__jmp_buf_tag + +type t__jmp_buf_tag = struct { + F__jb t__jmp_buf + F__fl uint64 + F__ss [16]uint64 +} + +type Tsigjmp_buf = [1]t__jmp_buf_tag + +func X__sigsetjmp_tail(tls *TLS, jb uintptr, ret int32) (r int32) { + if __ccgo_strace { + trc("tls=%v jb=%v ret=%v, (%v:)", tls, jb, ret, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p, v1, v2 uintptr + _, _, _ = p, v1, v2 + p = jb + 184 + if ret != 0 { + v1 = p + } else { + v1 = uintptr(0) + } + if ret != 0 { + v2 = uintptr(0) + } else { + v2 = p + } + X__syscall4(tls, int64(SYS_rt_sigprocmask), int64(Int32FromInt32(SIG_SETMASK)), int64(v1), int64(v2), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8))) + return ret +} + +func Xsigsuspend(tls *TLS, mask uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v, (%v:)", tls, mask, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_rt_sigsuspend), int64(mask), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), 0, 0, 0, 0)))) +} + +func _do_sigtimedwait(tls *TLS, mask uintptr, si uintptr, ts uintptr) (r int32) { + return int32(___syscall_cp(tls, int64(SYS_rt_sigtimedwait), int64(mask), int64(si), int64(ts), int64(Int32FromInt32(_NSIG)/Int32FromInt32(8)), 0, 0)) +} + +func Xsigtimedwait(tls *TLS, mask uintptr, si uintptr, timeout uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v si=%v timeout=%v, (%v:)", tls, mask, si, timeout, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + for cond := true; cond; cond = ret == -int32(EINTR) { + ret = _do_sigtimedwait(tls, mask, si, timeout) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) +} + +func Xsigwait(tls *TLS, mask uintptr, sig uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v sig=%v, (%v:)", tls, mask, sig, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* si at bp+0 */ Tsiginfo_t + if Xsigtimedwait(tls, mask, bp, uintptr(0)) < 0 { + return -int32(1) + } + **(**int32)(__ccgo_up(sig)) = (**(**Tsiginfo_t)(__ccgo_up(bp))).Fsi_signo + return 0 +} + +func Xsigwaitinfo(tls *TLS, mask uintptr, si uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mask=%v si=%v, (%v:)", tls, mask, si, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsigtimedwait(tls, mask, si, uintptr(0)) +} + +func X__fxstat(tls *TLS, ver int32, fd int32, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v fd=%v buf=%v, (%v:)", tls, ver, fd, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfstat(tls, fd, buf) +} + +func X__fxstatat(tls *TLS, ver int32, fd int32, path uintptr, buf uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v fd=%v path=%v buf=%v flag=%v, (%v:)", tls, ver, fd, path, buf, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfstatat(tls, fd, path, buf, flag) +} + +func X__lxstat(tls *TLS, ver int32, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v path=%v buf=%v, (%v:)", tls, ver, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlstat(tls, path, buf) +} + +func X__xstat(tls *TLS, ver int32, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v path=%v buf=%v, (%v:)", tls, ver, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstat(tls, path, buf) +} + +func X__xmknod(tls *TLS, ver int32, path uintptr, mode Tmode_t, dev uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v path=%v mode=%v dev=%v, (%v:)", tls, ver, path, mode, dev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmknod(tls, path, mode, **(**Tdev_t)(__ccgo_up(dev))) +} + +func X__xmknodat(tls *TLS, ver int32, fd int32, path uintptr, mode Tmode_t, dev uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v ver=%v fd=%v path=%v mode=%v dev=%v, (%v:)", tls, ver, fd, path, mode, dev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmknodat(tls, fd, path, mode, **(**Tdev_t)(__ccgo_up(dev))) +} + +func Xchmod(tls *TLS, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v, (%v:)", tls, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fchmodat), int64(-Int32FromInt32(100)), int64(path), Int64FromUint32(mode))))) +} + +func Xfchmod(tls *TLS, fd int32, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v mode=%v, (%v:)", tls, fd, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ret int32 + var _ /* buf at bp+0 */ [27]uint8 + _ = ret + ret = int32(X__syscall2(tls, int64(SYS_fchmod), int64(fd), Int64FromUint32(mode))) + if ret != -int32(EBADF) || X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFD))) < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + X__procfdname(tls, bp, Uint32FromInt32(fd)) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fchmodat), int64(-Int32FromInt32(100)), int64(bp), Int64FromUint32(mode))))) +} + +func Xfchmodat(tls *TLS, fd int32, path uintptr, mode Tmode_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v mode=%v flag=%v, (%v:)", tls, fd, path, mode, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(160) + defer tls.Free(160) + var fd2, ret, v1 int32 + var _ /* proc at bp+128 */ [27]uint8 + var _ /* st at bp+0 */ Tstat + _, _, _ = fd2, ret, v1 + if !(flag != 0) { + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fchmodat), int64(fd), int64(path), Int64FromUint32(mode))))) + } + ret = int32(X__syscall4(tls, int64(SYS_fchmodat2), int64(fd), int64(path), Int64FromUint32(mode), int64(flag))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + if flag != int32(AT_SYMLINK_NOFOLLOW) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + if Xfstatat(tls, fd, path, bp, flag) != 0 { + return -int32(1) + } + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFLNK) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } + v1 = int32(X__syscall3(tls, int64(SYS_openat), int64(fd), int64(path), int64(Int32FromInt32(O_RDONLY)|Int32FromInt32(O_PATH)|Int32FromInt32(O_NOFOLLOW)|Int32FromInt32(O_NOCTTY)|Int32FromInt32(O_CLOEXEC)))) + fd2 = v1 + if v1 < 0 { + if fd2 == -int32(ELOOP) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(fd2))) + } + X__procfdname(tls, bp+128, Uint32FromInt32(fd2)) + ret = Xstat(tls, bp+128, bp) + if !(ret != 0) { + if (**(**Tstat)(__ccgo_up(bp))).Fst_mode&uint32(S_IFMT) == uint32(S_IFLNK) { + ret = int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EOPNOTSUPP)))) + } else { + ret = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fchmodat), int64(-Int32FromInt32(100)), int64(bp+128), Int64FromUint32(mode))))) + } + } + X__syscall1(tls, int64(SYS_close), int64(fd2)) + return ret +} + +func X__fstat(tls *TLS, fd int32, st uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v st=%v, (%v:)", tls, fd, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + if fd < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EBADF)))) + } + return X__fstatat(tls, fd, __ccgo_ts, st, int32(AT_EMPTY_PATH)) +} + +func Xfstat(tls *TLS, fd int32, st uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v st=%v, (%v:)", tls, fd, st, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fstat(tls, fd, st) +} + +type Tstatx1 = struct { + Fstx_mask Tuint32_t + Fstx_blksize Tuint32_t + Fstx_attributes Tuint64_t + Fstx_nlink Tuint32_t + Fstx_uid Tuint32_t + Fstx_gid Tuint32_t + Fstx_mode Tuint16_t + Fpad1 Tuint16_t + Fstx_ino Tuint64_t + Fstx_size Tuint64_t + Fstx_blocks Tuint64_t + Fstx_attributes_mask Tuint64_t + Fstx_atime struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + Fpad Tint32_t + } + Fstx_btime struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + Fpad Tint32_t + } + Fstx_ctime struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + Fpad Tint32_t + } + Fstx_mtime struct { + Ftv_sec Tint64_t + Ftv_nsec Tuint32_t + Fpad Tint32_t + } + Fstx_rdev_major Tuint32_t + Fstx_rdev_minor Tuint32_t + Fstx_dev_major Tuint32_t + Fstx_dev_minor Tuint32_t + Fspare [14]Tuint64_t +} + +func _fstatat_statx(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var ret int32 + var _ /* stx at bp+0 */ Tstatx1 + _ = ret + flag = flag | int32(AT_NO_AUTOMOUNT) + ret = int32(X__syscall5(tls, int64(SYS_statx), int64(fd), int64(path), int64(flag), int64(Int32FromInt32(0x7ff)), int64(bp))) + if ret != 0 { + return ret + } + **(**Tstat)(__ccgo_up(st)) = Tstat{ + Fst_dev: uint64(uint64((**(**Tstatx1)(__ccgo_up(bp))).Fstx_dev_major)&Uint64FromUint64(0xfffff000)<= 0 && !(**(**uint8)(__ccgo_up(path)) != 0) { + ret = int32(X__syscall2(tls, int64(SYS_fstat), int64(fd), int64(bp))) + if ret == -int32(EBADF) && X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFD))) >= 0 { + ret = int32(X__syscall4(tls, int64(SYS_newfstatat), int64(fd), int64(path), int64(bp), int64(flag))) + if ret == -int32(EINVAL) { + X__procfdname(tls, bp+128, Uint32FromInt32(fd)) + ret = int32(X__syscall4(tls, int64(SYS_newfstatat), int64(-Int32FromInt32(100)), int64(bp+128), int64(bp), int64(Int32FromInt32(0)))) + } + } + } else { + ret = int32(X__syscall4(tls, int64(SYS_newfstatat), int64(fd), int64(path), int64(bp), int64(flag))) + } + if ret != 0 { + return ret + } + **(**Tstat)(__ccgo_up(st)) = Tstat{ + Fst_dev: (**(**Tkstat)(__ccgo_up(bp))).Fst_dev, + Fst_ino: (**(**Tkstat)(__ccgo_up(bp))).Fst_ino, + Fst_mode: (**(**Tkstat)(__ccgo_up(bp))).Fst_mode, + Fst_nlink: (**(**Tkstat)(__ccgo_up(bp))).Fst_nlink, + Fst_uid: (**(**Tkstat)(__ccgo_up(bp))).Fst_uid, + Fst_gid: (**(**Tkstat)(__ccgo_up(bp))).Fst_gid, + Fst_rdev: (**(**Tkstat)(__ccgo_up(bp))).Fst_rdev, + Fst_size: (**(**Tkstat)(__ccgo_up(bp))).Fst_size, + Fst_blksize: (**(**Tkstat)(__ccgo_up(bp))).Fst_blksize, + Fst_blocks: (**(**Tkstat)(__ccgo_up(bp))).Fst_blocks, + Fst_atim: Ttimespec{ + Ftv_sec: (**(**Tkstat)(__ccgo_up(bp))).Fst_atime_sec, + Ftv_nsec: (**(**Tkstat)(__ccgo_up(bp))).Fst_atime_nsec, + }, + Fst_mtim: Ttimespec{ + Ftv_sec: (**(**Tkstat)(__ccgo_up(bp))).Fst_mtime_sec, + Ftv_nsec: (**(**Tkstat)(__ccgo_up(bp))).Fst_mtime_nsec, + }, + Fst_ctim: Ttimespec{ + Ftv_sec: (**(**Tkstat)(__ccgo_up(bp))).Fst_ctime_sec, + Ftv_nsec: (**(**Tkstat)(__ccgo_up(bp))).Fst_ctime_nsec, + }, + } + return 0 +} + +func X__fstatat(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v st=%v flag=%v, (%v:)", tls, fd, path, st, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + if uint64(8) < uint64(8) { + ret = _fstatat_statx(tls, fd, path, st, flag) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + } + ret = _fstatat_kstat(tls, fd, path, st, flag) + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) +} + +func Xfstatat(tls *TLS, fd int32, path uintptr, st uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v st=%v flag=%v, (%v:)", tls, fd, path, st, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fstatat(tls, fd, path, st, flag) +} + +func Xfutimens(tls *TLS, fd int32, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v times=%v, (%v:)", tls, fd, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xutimensat(tls, fd, uintptr(0), times, 0) +} + +func X__futimesat(tls *TLS, dirfd int32, pathname uintptr, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dirfd=%v pathname=%v times=%v, (%v:)", tls, dirfd, pathname, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var i int32 + var v2 uintptr + var _ /* ts at bp+0 */ [2]Ttimespec + _, _ = i, v2 + if times != 0 { + i = 0 + for { + if !(i < int32(2)) { + break + } + if Uint64FromInt64((**(**Ttimeval)(__ccgo_up(times + uintptr(i)*16))).Ftv_usec) >= uint64(1000000) { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + (**(**[2]Ttimespec)(__ccgo_up(bp)))[i].Ftv_sec = (**(**Ttimeval)(__ccgo_up(times + uintptr(i)*16))).Ftv_sec + (**(**[2]Ttimespec)(__ccgo_up(bp)))[i].Ftv_nsec = (**(**Ttimeval)(__ccgo_up(times + uintptr(i)*16))).Ftv_usec * int64(1000) + goto _1 + _1: + ; + i = i + 1 + } + } + if times != 0 { + v2 = bp + } else { + v2 = uintptr(0) + } + return Xutimensat(tls, dirfd, pathname, v2, 0) +} + +func Xfutimesat(tls *TLS, dirfd int32, pathname uintptr, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v dirfd=%v pathname=%v times=%v, (%v:)", tls, dirfd, pathname, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__futimesat(tls, dirfd, pathname, times) +} + +func Xlchmod(tls *TLS, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v, (%v:)", tls, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfchmodat(tls, -int32(100), path, mode, int32(AT_SYMLINK_NOFOLLOW)) +} + +func Xlstat(tls *TLS, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v buf=%v, (%v:)", tls, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfstatat(tls, -int32(100), path, buf, int32(AT_SYMLINK_NOFOLLOW)) +} + +func Xmkdir(tls *TLS, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v, (%v:)", tls, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mkdirat), int64(-Int32FromInt32(100)), int64(path), Int64FromUint32(mode))))) +} + +func Xmkdirat(tls *TLS, fd int32, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v mode=%v, (%v:)", tls, fd, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_mkdirat), int64(fd), int64(path), Int64FromUint32(mode))))) +} + +func Xmkfifo(tls *TLS, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v, (%v:)", tls, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmknod(tls, path, mode|uint32(S_IFIFO), uint64(0)) +} + +func Xmkfifoat(tls *TLS, fd int32, path uintptr, mode Tmode_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v mode=%v, (%v:)", tls, fd, path, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmknodat(tls, fd, path, mode|uint32(S_IFIFO), uint64(0)) +} + +func Xmknod(tls *TLS, path uintptr, mode Tmode_t, dev Tdev_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v mode=%v dev=%v, (%v:)", tls, path, mode, dev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_mknodat), int64(-Int32FromInt32(100)), int64(path), Int64FromUint32(mode), Int64FromUint64(dev))))) +} + +func Xmknodat(tls *TLS, fd int32, path uintptr, mode Tmode_t, dev Tdev_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v mode=%v dev=%v, (%v:)", tls, fd, path, mode, dev, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_mknodat), int64(fd), int64(path), Int64FromUint32(mode), Int64FromUint64(dev))))) +} + +func Xstat(tls *TLS, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v buf=%v, (%v:)", tls, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfstatat(tls, -int32(100), path, buf, 0) +} + +func ___statfs(tls *TLS, path uintptr, buf uintptr) (r int32) { + **(**Tstatfs)(__ccgo_up(buf)) = Tstatfs{} + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_statfs), int64(path), int64(buf))))) +} + +func Xfstatfs(tls *TLS, fd int32, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v, (%v:)", tls, fd, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + **(**Tstatfs)(__ccgo_up(buf)) = Tstatfs{} + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_fstatfs), int64(fd), int64(buf))))) +} + +func _fixup(tls *TLS, out uintptr, in uintptr) { + var v1 uint64 + _ = v1 + **(**Tstatvfs)(__ccgo_up(out)) = Tstatvfs{} + (*Tstatvfs)(unsafe.Pointer(out)).Ff_bsize = (*Tstatfs)(unsafe.Pointer(in)).Ff_bsize + if (*Tstatfs)(unsafe.Pointer(in)).Ff_frsize != 0 { + v1 = (*Tstatfs)(unsafe.Pointer(in)).Ff_frsize + } else { + v1 = (*Tstatfs)(unsafe.Pointer(in)).Ff_bsize + } + (*Tstatvfs)(unsafe.Pointer(out)).Ff_frsize = v1 + (*Tstatvfs)(unsafe.Pointer(out)).Ff_blocks = (*Tstatfs)(unsafe.Pointer(in)).Ff_blocks + (*Tstatvfs)(unsafe.Pointer(out)).Ff_bfree = (*Tstatfs)(unsafe.Pointer(in)).Ff_bfree + (*Tstatvfs)(unsafe.Pointer(out)).Ff_bavail = (*Tstatfs)(unsafe.Pointer(in)).Ff_bavail + (*Tstatvfs)(unsafe.Pointer(out)).Ff_files = (*Tstatfs)(unsafe.Pointer(in)).Ff_files + (*Tstatvfs)(unsafe.Pointer(out)).Ff_ffree = (*Tstatfs)(unsafe.Pointer(in)).Ff_ffree + (*Tstatvfs)(unsafe.Pointer(out)).Ff_favail = (*Tstatfs)(unsafe.Pointer(in)).Ff_ffree + (*Tstatvfs)(unsafe.Pointer(out)).Ff_fsid = Uint64FromInt32(**(**int32)(__ccgo_up(in + 56))) + (*Tstatvfs)(unsafe.Pointer(out)).Ff_flag = (*Tstatfs)(unsafe.Pointer(in)).Ff_flags + (*Tstatvfs)(unsafe.Pointer(out)).Ff_namemax = (*Tstatfs)(unsafe.Pointer(in)).Ff_namelen + (*Tstatvfs)(unsafe.Pointer(out)).Ff_type = uint32((*Tstatfs)(unsafe.Pointer(in)).Ff_type) +} + +func Xstatvfs(tls *TLS, path uintptr, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v buf=%v, (%v:)", tls, path, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* kbuf at bp+0 */ Tstatfs + if ___statfs(tls, path, bp) < 0 { + return -int32(1) + } + _fixup(tls, buf, bp) + return 0 +} + +func Xfstatvfs(tls *TLS, fd int32, buf uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v, (%v:)", tls, fd, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var _ /* kbuf at bp+0 */ Tstatfs + if Xfstatfs(tls, fd, bp) < 0 { + return -int32(1) + } + _fixup(tls, buf, bp) + return 0 +} + +func Xumask(tls *TLS, mode Tmode_t) (r Tmode_t) { + if __ccgo_strace { + trc("tls=%v mode=%v, (%v:)", tls, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_umask), Int64FromUint32(mode))))) +} + +func Xutimensat(tls *TLS, fd int32, path uintptr, times uintptr, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v times=%v flags=%v, (%v:)", tls, fd, path, times, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + if times != 0 && (**(**Ttimespec)(__ccgo_up(times))).Ftv_nsec == int64(UTIME_NOW) && (**(**Ttimespec)(__ccgo_up(times + 1*16))).Ftv_nsec == int64(UTIME_NOW) { + times = uintptr(0) + } + r = int32(X__syscall4(tls, int64(SYS_utimensat), int64(fd), int64(path), int64(times), int64(flags))) + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func X__fclose_ca(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*(*func(*TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fclose1})))(tls, f) +} + +func X__fdopen(tls *TLS, fd int32, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v mode=%v, (%v:)", tls, fd, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var f, v1 uintptr + var flags, v2 int32 + var _ /* wsz at bp+0 */ Twinsize + _, _, _, _ = f, flags, v1, v2 + /* Check for valid initial mode character */ + if !(Xstrchr(tls, __ccgo_ts+1504, Int32FromUint8(**(**uint8)(__ccgo_up(mode)))) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + /* Allocate FILE+buffer or fail */ + v1 = Xmalloc(tls, Uint64FromInt64(232)+Uint64FromInt32(UNGET)+Uint64FromInt32(BUFSIZ)) + f = v1 + if !(v1 != 0) { + return uintptr(0) + } + /* Zero-fill only the struct, not the buffer */ + Xmemset(tls, f, 0, uint64(232)) + /* Impose mode restrictions */ + if !(Xstrchr(tls, mode, int32('+')) != 0) { + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('r') { + v2 = int32(F_NOWR) + } else { + v2 = int32(F_NORD) + } + (*TFILE)(unsafe.Pointer(f)).Fflags = Uint32FromInt32(v2) + } + /* Apply close-on-exec flag */ + if Xstrchr(tls, mode, int32('e')) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + /* Set append mode on fd if opened for append */ + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('a') { + flags = int32(X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFL)))) + if !(flags&Int32FromInt32(O_APPEND) != 0) { + X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_SETFL)), int64(flags|Int32FromInt32(O_APPEND))) + } + **(**uint32)(__ccgo_up(f)) |= uint32(F_APP) + } + (*TFILE)(unsafe.Pointer(f)).Ffd = fd + (*TFILE)(unsafe.Pointer(f)).Fbuf = f + uintptr(232) + uintptr(UNGET) + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = uint64(BUFSIZ) + /* Activate line buffered mode for terminals */ + (*TFILE)(unsafe.Pointer(f)).Flbf = -int32(1) + if !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_NOWR) != 0) && !(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TIOCGWINSZ)), int64(bp)) != 0) { + (*TFILE)(unsafe.Pointer(f)).Flbf = int32('\n') + } + /* Initialize op ptrs. No problem if some are unneeded. */ + (*TFILE)(unsafe.Pointer(f)).Fread = __ccgo_fp(X__stdio_read) + (*TFILE)(unsafe.Pointer(f)).Fwrite = __ccgo_fp(X__stdio_write) + (*TFILE)(unsafe.Pointer(f)).Fseek = __ccgo_fp(X__stdio_seek) + (*TFILE)(unsafe.Pointer(f)).Fclose1 = __ccgo_fp(X__stdio_close) + if !(X__libc.Fthreaded != 0) { + AtomicStorePInt32(f+140, -int32(1)) + } + /* Add new FILE to open file list */ + return X__ofl_add(tls, f) +} + +func Xfdopen(tls *TLS, fd int32, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v mode=%v, (%v:)", tls, fd, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fdopen(tls, fd, mode) +} + +func X__fmodeflags(tls *TLS, mode uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v mode=%v, (%v:)", tls, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var flags int32 + _ = flags + if Xstrchr(tls, mode, int32('+')) != 0 { + flags = int32(O_RDWR) + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('r') { + flags = O_RDONLY + } else { + flags = int32(O_WRONLY) + } + } + if Xstrchr(tls, mode, int32('x')) != 0 { + flags = flags | int32(O_EXCL) + } + if Xstrchr(tls, mode, int32('e')) != 0 { + flags = flags | int32(O_CLOEXEC) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) != int32('r') { + flags = flags | int32(O_CREAT) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('w') { + flags = flags | int32(O_TRUNC) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('a') { + flags = flags | int32(O_APPEND) + } + return flags +} + +func X__fopen_rb_ca(tls *TLS, filename uintptr, f uintptr, buf uintptr, len1 Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v filename=%v f=%v buf=%v len1=%v, (%v:)", tls, filename, f, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + Xmemset(tls, f, 0, uint64(232)) + (*TFILE)(unsafe.Pointer(f)).Ffd = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_openat), int64(-Int32FromInt32(100)), int64(filename), int64(Int32FromInt32(O_RDONLY)|Int32FromInt32(O_CLOEXEC)|Int32FromInt32(O_LARGEFILE)))))) + if (*TFILE)(unsafe.Pointer(f)).Ffd < 0 { + return uintptr(0) + } + X__syscall3(tls, int64(SYS_fcntl), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + (*TFILE)(unsafe.Pointer(f)).Fflags = Uint32FromInt32(Int32FromInt32(F_NOWR) | Int32FromInt32(F_PERM)) + (*TFILE)(unsafe.Pointer(f)).Fbuf = buf + uintptr(UNGET) + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = len1 - uint64(UNGET) + (*TFILE)(unsafe.Pointer(f)).Fread = __ccgo_fp(X__stdio_read) + (*TFILE)(unsafe.Pointer(f)).Fseek = __ccgo_fp(X__stdio_seek) + (*TFILE)(unsafe.Pointer(f)).Fclose1 = __ccgo_fp(X__stdio_close) + AtomicStorePInt32(f+140, -int32(1)) + return f +} + +func X__overflow(tls *TLS, f uintptr, _c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v _c=%v, (%v:)", tls, f, _c, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 uint8 + var v2, v3 uintptr + var _ /* c at bp+0 */ uint8 + _, _, _ = v1, v2, v3 + **(**uint8)(__ccgo_up(bp)) = Uint8FromInt32(_c) + if !((*TFILE)(unsafe.Pointer(f)).Fwend != 0) && X__towrite(tls, f) != 0 { + return -int32(1) + } + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend && Int32FromUint8(**(**uint8)(__ccgo_up(bp))) != (*TFILE)(unsafe.Pointer(f)).Flbf { + v1 = **(**uint8)(__ccgo_up(bp)) + v3 = f + 40 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + **(**uint8)(__ccgo_up(v2)) = v1 + return Int32FromUint8(v1) + } + if (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, bp, uint64(1)) != uint64(1) { + return -int32(1) + } + return Int32FromUint8(**(**uint8)(__ccgo_up(bp))) +} + +func _dummy9(tls *TLS, fd int32) (r int32) { + return fd +} + +func X__stdio_close(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_close), int64(_dummy9(tls, (*TFILE)(unsafe.Pointer(f)).Ffd)))))) +} + +var _dummy_file = uintptr(0) + +func _close_file(tls *TLS, f uintptr) { + if !(f != 0) { + return + } + if AtomicLoadPInt32(f+140) >= 0 { + ___lockfile(tls, f) + } + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + (*(*func(*TLS, uintptr, Toff_t, int32) Toff_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fseek})))(tls, f, int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Frend), int32(1)) + } +} + +func X__stdio_exit(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + var f uintptr + _ = f + f = **(**uintptr)(__ccgo_up(X__ofl_lock(tls))) + for { + if !(f != 0) { + break + } + _close_file(tls, f) + goto _1 + _1: + ; + f = (*TFILE)(unsafe.Pointer(f)).Fnext + } + _close_file(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stdin_used)))) + _close_file(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stdout_used)))) + _close_file(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stderr_used)))) +} + +func X__stdio_exit_needed(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__stdio_exit(tls) +} + +func X__stdio_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v len1=%v, (%v:)", tls, f, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var cnt Tssize_t + var v1 int64 + var v2 int32 + var v3, v4 uintptr + var _ /* iov at bp+0 */ [2]Tiovec + _, _, _, _, _ = cnt, v1, v2, v3, v4 + **(**[2]Tiovec)(__ccgo_up(bp)) = [2]Tiovec{ + 0: { + Fiov_base: buf, + Fiov_len: len1 - BoolUint64(!!((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0)), + }, + 1: { + Fiov_base: (*TFILE)(unsafe.Pointer(f)).Fbuf, + Fiov_len: (*TFILE)(unsafe.Pointer(f)).Fbuf_size, + }, + } + if (**(**[2]Tiovec)(__ccgo_up(bp)))[0].Fiov_len != 0 { + v1 = X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_readv), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(bp), int64(Int32FromInt32(2))))) + } else { + v1 = X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_read), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64((**(**[2]Tiovec)(__ccgo_up(bp)))[int32(1)].Fiov_base), Int64FromUint64((**(**[2]Tiovec)(__ccgo_up(bp)))[int32(1)].Fiov_len)))) + } + cnt = v1 + if cnt <= 0 { + if cnt != 0 { + v2 = int32(F_ERR) + } else { + v2 = int32(F_EOF) + } + **(**uint32)(__ccgo_up(f)) |= Uint32FromInt32(v2) + return uint64(0) + } + if Uint64FromInt64(cnt) <= (**(**[2]Tiovec)(__ccgo_up(bp)))[0].Fiov_len { + return Uint64FromInt64(cnt) + } + cnt = Int64FromUint64(uint64(cnt) - (**(**[2]Tiovec)(__ccgo_up(bp)))[0].Fiov_len) + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(cnt) + if (*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0 { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(buf + uintptr(len1-uint64(1)))) = **(**uint8)(__ccgo_up(v3)) + } + return len1 +} + +func X__stdio_seek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lseek(tls, (*TFILE)(unsafe.Pointer(f)).Ffd, off, whence) +} + +func X__stdio_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v len1=%v, (%v:)", tls, f, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var cnt Tssize_t + var iov, v2, v3 uintptr + var iovcnt int32 + var rem Tsize_t + var v5 uint64 + var _ /* iovs at bp+0 */ [2]Tiovec + _, _, _, _, _, _, _ = cnt, iov, iovcnt, rem, v2, v3, v5 + **(**[2]Tiovec)(__ccgo_up(bp)) = [2]Tiovec{ + 0: { + Fiov_base: (*TFILE)(unsafe.Pointer(f)).Fwbase, + Fiov_len: Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)), + }, + 1: { + Fiov_base: buf, + Fiov_len: len1, + }, + } + iov = bp + rem = (**(**Tiovec)(__ccgo_up(iov))).Fiov_len + (**(**Tiovec)(__ccgo_up(iov + 1*16))).Fiov_len + iovcnt = int32(2) + for { + cnt = X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_writev), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(iov), int64(iovcnt)))) + if Uint64FromInt64(cnt) == rem { + (*TFILE)(unsafe.Pointer(f)).Fwend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr((*TFILE)(unsafe.Pointer(f)).Fbuf_size) + v2 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fwbase = v2 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v2 + return len1 + } + if cnt < 0 { + v3 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v3 + v2 = v3 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v2 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v2 + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + if iovcnt == int32(2) { + v5 = uint64(0) + } else { + v5 = len1 - (**(**Tiovec)(__ccgo_up(iov))).Fiov_len + } + return v5 + } + rem = rem - Uint64FromInt64(cnt) + if Uint64FromInt64(cnt) > (**(**Tiovec)(__ccgo_up(iov))).Fiov_len { + cnt = Int64FromUint64(uint64(cnt) - (**(**Tiovec)(__ccgo_up(iov))).Fiov_len) + iov += 16 + iovcnt = iovcnt - 1 + } + (**(**Tiovec)(__ccgo_up(iov))).Fiov_base = (**(**Tiovec)(__ccgo_up(iov))).Fiov_base + uintptr(cnt) + (**(**Tiovec)(__ccgo_up(iov))).Fiov_len -= Uint64FromInt64(cnt) + goto _1 + _1: + } + return r +} + +func X__stdout_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v len1=%v, (%v:)", tls, f, buf, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* wsz at bp+0 */ Twinsize + (*TFILE)(unsafe.Pointer(f)).Fwrite = __ccgo_fp(X__stdio_write) + if !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_SVB) != 0) && X__syscall3(tls, int64(SYS_ioctl), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(Int32FromInt32(TIOCGWINSZ)), int64(bp)) != 0 { + (*TFILE)(unsafe.Pointer(f)).Flbf = -int32(1) + } + return X__stdio_write(tls, f, buf, len1) +} + +func X__toread(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v2 uintptr + var v4 int32 + _, _, _ = v1, v2, v4 + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + } + v2 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v2 + v1 = v2 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NORD) != 0 { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + return -int32(1) + } + v1 = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr((*TFILE)(unsafe.Pointer(f)).Fbuf_size) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_EOF) != 0 { + v4 = -int32(1) + } else { + v4 = 0 + } + return v4 +} + +func X__toread_needs_stdio_exit(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__stdio_exit_needed(tls) +} + +func X__towrite(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NOWR) != 0 { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + return -int32(1) + } + /* Clear read buffer (easier than summoning nasal demons) */ + v1 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + /* Activate write through the buffer. */ + v1 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + (*TFILE)(unsafe.Pointer(f)).Fwend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr((*TFILE)(unsafe.Pointer(f)).Fbuf_size) + return 0 +} + +func X__towrite_needs_stdio_exit(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__stdio_exit_needed(tls) +} + +/* This function assumes it will never be called if there is already + * data buffered for reading. */ + +func X__uflow(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* c at bp+0 */ uint8 + if !(X__toread(tls, f) != 0) && (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fread})))(tls, f, bp, uint64(1)) == uint64(1) { + return Int32FromUint8(**(**uint8)(__ccgo_up(bp))) + } + return -int32(1) +} + +func Xasprintf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvasprintf(tls, s, fmt, ap) + _ = ap + return ret +} + +func Xclearerr(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + var __need_unlock, v1 int32 + _, _ = __need_unlock, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^(Int32FromInt32(F_EOF) | Int32FromInt32(F_ERR))) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xclearerr_unlocked(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + Xclearerr(tls, f) +} + +func Xdprintf(tls *TLS, fd int32, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v fmt=%v va=%v, (%v:)", tls, fd, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvdprintf(tls, fd, fmt, ap) + _ = ap + return ret +} + +const FSETLOCKING_BYCALLER = 2 +const FSETLOCKING_INTERNAL = 1 +const FSETLOCKING_QUERY = 0 + +func X_flushlbf(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + Xfflush(tls, uintptr(0)) +} + +func X__fsetlocking(tls *TLS, f uintptr, type1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v type1=%v, (%v:)", tls, f, type1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return 0 +} + +func X__fwriting(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32((*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NORD) != 0 || (*TFILE)(unsafe.Pointer(f)).Fwend != 0) +} + +func X__freading(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32((*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NOWR) != 0 || (*TFILE)(unsafe.Pointer(f)).Frend != 0) +} + +func X__freadable(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(!((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_NORD) != 0)) +} + +func X__fwritable(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32(!((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_NOWR) != 0)) +} + +func X__flbf(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return BoolInt32((*TFILE)(unsafe.Pointer(f)).Flbf >= 0) +} + +func X__fbufsize(tls *TLS, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*TFILE)(unsafe.Pointer(f)).Fbuf_size +} + +func X__fpending(tls *TLS, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if (*TFILE)(unsafe.Pointer(f)).Fwend != 0 { + v1 = int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase) + } else { + v1 = 0 + } + return Uint64FromInt64(v1) +} + +func X__fpurge(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v2 uintptr + _, _ = v1, v2 + if !(f != 0) { // libbsd fpurge test fails w/o this. + return int32(1) + } + v2 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v2 + v1 = v2 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + v1 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + return 0 +} + +func Xfpurge(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fpurge(tls, f) +} + +func X__freadahead(tls *TLS, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 { + v1 = int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + } else { + v1 = 0 + } + return Uint64FromInt64(v1) +} + +func X__freadptr(tls *TLS, f uintptr, sizep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v sizep=%v, (%v:)", tls, f, sizep, origin(2)) + defer func() { trc("-> %v", r) }() + } + if (*TFILE)(unsafe.Pointer(f)).Frpos == (*TFILE)(unsafe.Pointer(f)).Frend { + return uintptr(0) + } + **(**Tsize_t)(__ccgo_up(sizep)) = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos)) + return (*TFILE)(unsafe.Pointer(f)).Frpos +} + +func X__freadptrinc(tls *TLS, f uintptr, inc Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v inc=%v, (%v:)", tls, f, inc, origin(2)) + } + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(inc) +} + +func X__fseterr(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) +} + +func _dummy10(tls *TLS, f uintptr) { +} + +func Xfclose(tls *TLS, f uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var __need_unlock, r, v1 int32 + var head uintptr + _, _, _, _ = __need_unlock, head, r, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + r = Xfflush(tls, f) + r = r | (*(*func(*TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fclose1})))(tls, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + /* Past this point, f is closed and any further explict access + * to it is undefined. However, it still exists as an entry in + * the open file list and possibly in the thread's locked files + * list, if it was closed while explicitly locked. Functions + * which process these lists must tolerate dead FILE objects + * (which necessarily have inactive buffer pointers) without + * producing any side effects. */ + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_PERM) != 0 { + return r + } + X__unlist_locked_file(tls, f) + head = X__ofl_lock(tls) + if (*TFILE)(unsafe.Pointer(f)).Fprev != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fprev)).Fnext = (*TFILE)(unsafe.Pointer(f)).Fnext + } + if (*TFILE)(unsafe.Pointer(f)).Fnext != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fnext)).Fprev = (*TFILE)(unsafe.Pointer(f)).Fprev + } + if **(**uintptr)(__ccgo_up(head)) == f { + **(**uintptr)(__ccgo_up(head)) = (*TFILE)(unsafe.Pointer(f)).Fnext + } + X__ofl_unlock(tls) + Xfree(tls, (*TFILE)(unsafe.Pointer(f)).Fgetln_buf) + Xfree(tls, f) + return r +} + +func Xfeof(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, ret, v1 int32 + _, _, _ = __need_unlock, ret, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + ret = BoolInt32(!!((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_EOF) != 0)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return ret +} + +func X_IO_feof_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfeof(tls, f) +} + +func Xfeof_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfeof(tls, f) +} + +func Xferror(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, ret, v1 int32 + _, _, _ = __need_unlock, ret, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + ret = BoolInt32(!!((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_ERR) != 0)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return ret +} + +func X_IO_ferror_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xferror(tls, f) +} + +func Xferror_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xferror(tls, f) +} + +// C documentation +// +// /* stdout.c will override this if linked */ +var _dummy11 = uintptr(0) + +func Xfflush(tls *TLS, f uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var __need_unlock, __need_unlock1, r, v2 int32 + var v4, v5 uintptr + _, _, _, _, _, _ = __need_unlock, __need_unlock1, r, v2, v4, v5 + if !(f != 0) { + r = 0 + if AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stdout_used))) != 0 { + r = r | Xfflush(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stdout_used)))) + } + if AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stderr_used))) != 0 { + r = r | Xfflush(tls, AtomicLoadPUintptr(uintptr(unsafe.Pointer(&X__stderr_used)))) + } + f = **(**uintptr)(__ccgo_up(X__ofl_lock(tls))) + for { + if !(f != 0) { + break + } + if AtomicLoadPInt32(f+140) >= 0 { + v2 = ___lockfile(tls, f) + } else { + v2 = 0 + } + __need_unlock = v2 + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + r = r | Xfflush(tls, f) + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + goto _1 + _1: + ; + f = (*TFILE)(unsafe.Pointer(f)).Fnext + } + X__ofl_unlock(tls) + return r + } + if AtomicLoadPInt32(f+140) >= 0 { + v2 = ___lockfile(tls, f) + } else { + v2 = 0 + } + __need_unlock1 = v2 + /* If writing, flush output */ + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + if !((*TFILE)(unsafe.Pointer(f)).Fwpos != 0) { + if __need_unlock1 != 0 { + ___unlockfile(tls, f) + } + return -int32(1) + } + } + /* If reading, sync position, per POSIX */ + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + (*(*func(*TLS, uintptr, Toff_t, int32) Toff_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fseek})))(tls, f, int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Frend), int32(1)) + } + /* Clear read and write modes */ + v5 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v5 + v4 = v5 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v4 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v4 + v4 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v4 + (*TFILE)(unsafe.Pointer(f)).Frpos = v4 + if __need_unlock1 != 0 { + ___unlockfile(tls, f) + } + return 0 +} + +func Xfflush_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfflush(tls, f) +} + +func _locking_getc(tls *TLS, f uintptr) (r1 int32) { + var c, old, old1, r, v, v13, v16, v2, v5, v7, v9 int32 + var v1, v10, v11, v12 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, old, old1, r, v, v1, v10, v11, v12, v13, v16, v2, v5, v7, v9 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1508) + v5 = v + goto _6 + _6: + old = v5 + if old != 0 { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1508) + break + } + goto _4 + _4: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1508) + v2 = BoolInt32(!(r != 0)) + goto _3 + _3: + ; + if !!(v2 != 0) { + break + } + } + v7 = old + goto _8 +_8: + if v7 != 0 { + ___lockfile(tls, f) + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v10 = f + 8 + v1 = *(*uintptr)(unsafe.Pointer(v10)) + *(*uintptr)(unsafe.Pointer(v10)) = *(*uintptr)(unsafe.Pointer(v10)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v1))) + } else { + v2 = X__uflow(tls, f) + } + c = v2 + v11 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1508) + v7 = v + goto _17 + _17: + old1 = v7 + goto _15 + _15: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1508) + v5 = BoolInt32(!(r != 0)) + goto _14 + _14: + ; + if !!(v5 != 0) { + break + } + } + v9 = old1 + goto _19 +_19: + if v9&int32(MAYBE_WAITERS) != 0 { + v12 = f + 140 + v13 = int32(1) + v16 = int32(1) + if v16 != 0 { + v16 = int32(FUTEX_PRIVATE) + } + if v13 < Int32FromInt32(0) { + v13 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v12), int64(Int32FromInt32(FUTEX_WAKE)|v16), int64(v13)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v12), int64(Int32FromInt32(FUTEX_WAKE)), int64(v13)) != 0 + } + return c +} + +func Xfgetc(tls *TLS, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f1=%v, (%v:)", tls, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v2, v4 int32 + var v1, v5, v6 uintptr + _, _, _, _, _, _ = l, v1, v2, v4, v5, v6 + v1 = f1 + l = AtomicLoadPInt32(v1 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if (*TFILE)(unsafe.Pointer(v1)).Frpos != (*TFILE)(unsafe.Pointer(v1)).Frend { + v6 = v1 + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = X__uflow(tls, v1) + } + v2 = v4 + goto _3 + } + v2 = _locking_getc(tls, v1) + goto _3 +_3: + return v2 +} + +func Xfgetln(tls *TLS, f uintptr, plen uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v plen=%v, (%v:)", tls, f, plen, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var __need_unlock, v1, v2 int32 + var l, v8 Tssize_t + var ret, z, v3, v4 uintptr + var v6 bool + _, _, _, _, _, _, _, _, _, _ = __need_unlock, l, ret, z, v1, v2, v3, v4, v6, v8 + ret = uintptr(0) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__uflow(tls, f) + } + Xungetc(tls, v2, f) + if v6 = (*TFILE)(unsafe.Pointer(f)).Frend != 0; v6 { + v3 = Xmemchr(tls, (*TFILE)(unsafe.Pointer(f)).Frpos, int32('\n'), Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos))) + z = v3 + } + if v6 && v3 != 0 { + ret = (*TFILE)(unsafe.Pointer(f)).Frpos + z = z + 1 + v3 = z + **(**Tsize_t)(__ccgo_up(plen)) = Uint64FromInt64(int64(v3) - int64(ret)) + (*TFILE)(unsafe.Pointer(f)).Frpos = z + } else { + *(*[1]Tsize_t)(unsafe.Pointer(bp)) = [1]Tsize_t{} + v8 = Xgetline(tls, f+168, bp, f) + l = v8 + if v8 > 0 { + **(**Tsize_t)(__ccgo_up(plen)) = Uint64FromInt64(l) + ret = (*TFILE)(unsafe.Pointer(f)).Fgetln_buf + } + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return ret +} + +func Xfgetpos(tls *TLS, f uintptr, pos uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v pos=%v, (%v:)", tls, f, pos, origin(2)) + defer func() { trc("-> %v", r) }() + } + var off Toff_t + _ = off + off = X__ftello(tls, f) + if off < 0 { + return -int32(1) + } + **(**int64)(__ccgo_up(pos)) = off + return 0 +} + +func Xfgets(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, c, v1, v4 int32 + var k Tsize_t + var p, z, v6, v7 uintptr + var v2 int64 + var v3 uint64 + var v8 uint8 + _, _, _, _, _, _, _, _, _, _, _, _ = __need_unlock, c, k, p, z, v1, v2, v3, v4, v6, v7, v8 + p = s + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if n <= int32(1) { + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + if n < int32(1) { + return uintptr(0) + } + **(**uint8)(__ccgo_up(s)) = uint8(0) + return s + } + n = n - 1 + for n != 0 { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + z = Xmemchr(tls, (*TFILE)(unsafe.Pointer(f)).Frpos, int32('\n'), Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos))) + if z != 0 { + v2 = int64(z) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + int64(1) + } else { + v2 = int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + } + k = Uint64FromInt64(v2) + if k < Uint64FromInt32(n) { + v3 = k + } else { + v3 = Uint64FromInt32(n) + } + k = v3 + Xmemcpy(tls, p, (*TFILE)(unsafe.Pointer(f)).Frpos, k) + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(k) + p = p + uintptr(k) + n = Int32FromUint64(uint64(n) - k) + if z != 0 || !(n != 0) { + break + } + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v7 = f + 8 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + } else { + v4 = X__uflow(tls, f) + } + v1 = v4 + c = v1 + if v1 < 0 { + if p == s || !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_EOF) != 0) { + s = uintptr(0) + } + break + } + n = n - 1 + v8 = Uint8FromInt32(c) + v6 = p + p = p + 1 + **(**uint8)(__ccgo_up(v6)) = v8 + if Int32FromUint8(v8) == int32('\n') { + break + } + } + if s != 0 { + **(**uint8)(__ccgo_up(p)) = uint8(0) + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return s +} + +func Xfgets_unlocked(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfgets(tls, s, n, f) +} + +func ___fgetwc_unlocked_internal(tls *TLS, f uintptr) (r Twint_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var c, first, v1, v2 int32 + var l Tsize_t + var v3, v4 uintptr + var _ /* b at bp+16 */ uint8 + var _ /* st at bp+8 */ Tmbstate_t + var _ /* wc at bp+0 */ Twchar_t + _, _, _, _, _, _, _ = c, first, l, v1, v2, v3, v4 + /* Convert character from buffer if possible */ + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + l = Uint64FromInt32(Xmbtowc(tls, bp, (*TFILE)(unsafe.Pointer(f)).Frpos, Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos)))) + if l+uint64(1) >= uint64(1) { + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(l + BoolUint64(!(l != 0))) /* l==0 means 1 byte, null */ + return **(**Twchar_t)(__ccgo_up(bp)) + } + } + /* Convert character byte-by-byte */ + **(**Tmbstate_t)(__ccgo_up(bp + 8)) = Tmbstate_t{} + first = int32(1) + for cond := true; cond; cond = l == Uint64FromInt32(-Int32FromInt32(2)) { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } else { + v2 = X__uflow(tls, f) + } + v1 = v2 + c = v1 + **(**uint8)(__ccgo_up(bp + 16)) = Uint8FromInt32(v1) + if c < 0 { + if !(first != 0) { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EILSEQ) + } + return uint32(0xffffffff) + } + l = Xmbrtowc(tls, bp, bp+16, uint64(1), bp+8) + if l == Uint64FromInt32(-Int32FromInt32(1)) { + if !(first != 0) { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + Xungetc(tls, Int32FromUint8(**(**uint8)(__ccgo_up(bp + 16))), f) + } + return uint32(0xffffffff) + } + first = 0 + } + return **(**Twchar_t)(__ccgo_up(bp)) +} + +func X__fgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var loc Tlocale_t + var ploc uintptr + var wc Twchar_t + _, _, _ = loc, ploc, wc + ploc = uintptr(___get_tp(tls)) + 152 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if (*TFILE)(unsafe.Pointer(f)).Fmode <= 0 { + Xfwide(tls, f, int32(1)) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = (*TFILE)(unsafe.Pointer(f)).Flocale + wc = ___fgetwc_unlocked_internal(tls, f) + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return wc +} + +func Xfgetwc(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var c Twint_t + _, _, _ = __need_unlock, c, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + c = X__fgetwc_unlocked(tls, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return c +} + +func Xfgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fgetwc_unlocked(tls, f) +} + +func Xgetwc_unlocked(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fgetwc_unlocked(tls, f) +} + +func Xfgetws(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var c Twint_t + var p, v4 uintptr + _, _, _, _, _ = __need_unlock, c, p, v1, v4 + p = s + v1 = n + n = n - 1 + if !(v1 != 0) { + return s + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + for { + if !(n != 0) { + break + } + c = X__fgetwc_unlocked(tls, f) + if c == uint32(0xffffffff) { + break + } + v4 = p + p += 4 + **(**Twchar_t)(__ccgo_up(v4)) = c + if c == uint32('\n') { + break + } + goto _3 + _3: + ; + n = n - 1 + } + **(**Twchar_t)(__ccgo_up(p)) = uint32(0) + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + p = s + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + if p == s { + v4 = UintptrFromInt32(0) + } else { + v4 = s + } + return v4 +} + +func Xfgetws_unlocked(tls *TLS, s uintptr, n int32, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfgetws(tls, s, n, f) +} + +func Xfileno(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, fd, v1 int32 + _, _, _ = __need_unlock, fd, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + fd = (*TFILE)(unsafe.Pointer(f)).Ffd + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + if fd < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EBADF) + return -int32(1) + } + return fd +} + +func Xfileno_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfileno(tls, f) +} + +func Xflockfile(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + if !(Xftrylockfile(tls, f) != 0) { + return + } + ___lockfile(tls, f) + X__register_locked_file(tls, f, uintptr(___get_tp(tls))) +} + +type Tcookie = struct { + Fpos Tsize_t + Flen1 Tsize_t + Fsize Tsize_t + Fbuf uintptr + Fmode int32 +} + +type Tmem_FILE = struct { + Ff TFILE + Fc Tcookie + Fbuf [1032]uint8 +} + +func _mseek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var base Tssize_t + var c uintptr + var v2 Tsize_t + _, _, _ = base, c, v2 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(Uint32FromInt32(whence) > uint32(2)) { + goto _1 + } + goto fail +fail: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) +_1: + ; + *(*[3]Tsize_t)(unsafe.Pointer(bp)) = [3]Tsize_t{ + 1: (*Tcookie)(unsafe.Pointer(c)).Fpos, + 2: (*Tcookie)(unsafe.Pointer(c)).Flen1, + } + base = Int64FromUint64(**(**Tsize_t)(__ccgo_up(bp + uintptr(whence)*8))) + if off < -base || off > Int64FromUint64((*Tcookie)(unsafe.Pointer(c)).Fsize)-base { + goto fail + } + v2 = Uint64FromInt64(base + off) + (*Tcookie)(unsafe.Pointer(c)).Fpos = v2 + return Int64FromUint64(v2) +} + +func _mread(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var c uintptr + var rem Tsize_t + _, _ = c, rem + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + rem = (*Tcookie)(unsafe.Pointer(c)).Flen1 - (*Tcookie)(unsafe.Pointer(c)).Fpos + if (*Tcookie)(unsafe.Pointer(c)).Fpos > (*Tcookie)(unsafe.Pointer(c)).Flen1 { + rem = uint64(0) + } + if len1 > rem { + len1 = rem + **(**uint32)(__ccgo_up(f)) |= uint32(F_EOF) + } + Xmemcpy(tls, buf, (*Tcookie)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie)(unsafe.Pointer(c)).Fpos), len1) + **(**Tsize_t)(__ccgo_up(c)) += len1 + rem = rem - len1 + if rem > (*TFILE)(unsafe.Pointer(f)).Fbuf_size { + rem = (*TFILE)(unsafe.Pointer(f)).Fbuf_size + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(rem) + Xmemcpy(tls, (*TFILE)(unsafe.Pointer(f)).Frpos, (*Tcookie)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie)(unsafe.Pointer(c)).Fpos), rem) + **(**Tsize_t)(__ccgo_up(c)) += rem + return len1 +} + +func _mwrite(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var c uintptr + var len2, rem Tsize_t + _, _, _ = c, len2, rem + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + len2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + if len2 != 0 { + (*TFILE)(unsafe.Pointer(f)).Fwpos = (*TFILE)(unsafe.Pointer(f)).Fwbase + if _mwrite(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwpos, len2) < len2 { + return uint64(0) + } + } + if (*Tcookie)(unsafe.Pointer(c)).Fmode == int32('a') { + (*Tcookie)(unsafe.Pointer(c)).Fpos = (*Tcookie)(unsafe.Pointer(c)).Flen1 + } + rem = (*Tcookie)(unsafe.Pointer(c)).Fsize - (*Tcookie)(unsafe.Pointer(c)).Fpos + if len1 > rem { + len1 = rem + } + Xmemcpy(tls, (*Tcookie)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie)(unsafe.Pointer(c)).Fpos), buf, len1) + **(**Tsize_t)(__ccgo_up(c)) += len1 + if (*Tcookie)(unsafe.Pointer(c)).Fpos > (*Tcookie)(unsafe.Pointer(c)).Flen1 { + (*Tcookie)(unsafe.Pointer(c)).Flen1 = (*Tcookie)(unsafe.Pointer(c)).Fpos + if (*Tcookie)(unsafe.Pointer(c)).Flen1 < (*Tcookie)(unsafe.Pointer(c)).Fsize { + **(**uint8)(__ccgo_up((*Tcookie)(unsafe.Pointer(c)).Fbuf + uintptr((*Tcookie)(unsafe.Pointer(c)).Flen1))) = uint8(0) + } else { + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_NORD) != 0 && (*Tcookie)(unsafe.Pointer(c)).Fsize != 0 { + **(**uint8)(__ccgo_up((*Tcookie)(unsafe.Pointer(c)).Fbuf + uintptr((*Tcookie)(unsafe.Pointer(c)).Fsize-uint64(1)))) = uint8(0) + } + } + } + return len1 +} + +func _mclose(tls *TLS, m uintptr) (r int32) { + return 0 +} + +func Xfmemopen(tls *TLS, buf uintptr, size Tsize_t, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v buf=%v size=%v mode=%v, (%v:)", tls, buf, size, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var f uintptr + var plus, v2 int32 + var v1 uint64 + var v3 Tsize_t + _, _, _, _, _ = f, plus, v1, v2, v3 + plus = BoolInt32(!!(Xstrchr(tls, mode, int32('+')) != 0)) + if !(Xstrchr(tls, __ccgo_ts+1504, Int32FromUint8(**(**uint8)(__ccgo_up(mode)))) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + if !(buf != 0) && size > Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return uintptr(0) + } + if buf != 0 { + v1 = uint64(0) + } else { + v1 = size + } + f = Xmalloc(tls, uint64(1304)+v1) + if !(f != 0) { + return uintptr(0) + } + Xmemset(tls, f, 0, uint64(UintptrFromInt32(0)+272)) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fcookie = f + 232 + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Ffd = -int32(1) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Flbf = -int32(1) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fbuf = f + 272 + uintptr(UNGET) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fbuf_size = Uint64FromInt64(1032) - Uint64FromInt32(UNGET) + if !(buf != 0) { + buf = f + 1304 + Xmemset(tls, buf, 0, size) + } + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fbuf = buf + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fsize = size + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fmode = Int32FromUint8(**(**uint8)(__ccgo_up(mode))) + if !(plus != 0) { + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('r') { + v2 = int32(F_NOWR) + } else { + v2 = int32(F_NORD) + } + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fflags = Uint32FromInt32(v2) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('r') { + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Flen1 = size + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('a') { + v3 = Xstrnlen(tls, buf, size) + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fpos = v3 + (*Tmem_FILE)(unsafe.Pointer(f)).Fc.Flen1 = v3 + } else { + if plus != 0 { + **(**uint8)(__ccgo_up((*Tmem_FILE)(unsafe.Pointer(f)).Fc.Fbuf)) = uint8(0) + } + } + } + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fread = __ccgo_fp(_mread) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fwrite = __ccgo_fp(_mwrite) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fseek = __ccgo_fp(_mseek) + (*Tmem_FILE)(unsafe.Pointer(f)).Ff.Fclose1 = __ccgo_fp(_mclose) + if !(X__libc.Fthreaded != 0) { + AtomicStorePInt32(f+140, -int32(1)) + } + return X__ofl_add(tls, f) +} + +func Xfopen(tls *TLS, filename uintptr, mode uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v filename=%v mode=%v, (%v:)", tls, filename, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var f uintptr + var fd, flags int32 + _, _, _ = f, fd, flags + /* Check for valid initial mode character */ + if !(Xstrchr(tls, __ccgo_ts+1504, Int32FromUint8(**(**uint8)(__ccgo_up(mode)))) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + /* Compute the flags to pass to open() */ + flags = X__fmodeflags(tls, mode) + fd = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_openat), int64(-Int32FromInt32(100)), int64(filename), int64(flags|Int32FromInt32(O_LARGEFILE)), int64(Int32FromInt32(0666)))))) + if fd < 0 { + return uintptr(0) + } + if flags&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + f = X__fdopen(tls, fd, mode) + if f != 0 { + return f + } + X__syscall1(tls, int64(SYS_close), int64(fd)) + return uintptr(0) +} + +type Tfcookie = struct { + Fcookie uintptr + Fiofuncs Tcookie_io_functions_t +} + +type Tcookie_FILE = struct { + Ff TFILE + Ffc Tfcookie + Fbuf [1032]uint8 +} + +func _cookieread(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var fc, v2, v3 uintptr + var len2, readlen, remain, v1 Tsize_t + var ret Tssize_t + var v4 int32 + _, _, _, _, _, _, _, _, _ = fc, len2, readlen, remain, ret, v1, v2, v3, v4 + fc = (*TFILE)(unsafe.Pointer(f)).Fcookie + ret = int64(-int32(1)) + remain = len1 + readlen = uint64(0) + len2 = len1 - BoolUint64(!!((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0)) + if !((*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fread != 0) { + goto bail + } + if len2 != 0 { + ret = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fread})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie, buf, len2) + if ret <= 0 { + goto bail + } + readlen = readlen + Uint64FromInt64(ret) + remain = remain - Uint64FromInt64(ret) + } + if !((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0) || remain > BoolUint64(!!((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0)) { + return readlen + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + ret = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fread})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie, (*TFILE)(unsafe.Pointer(f)).Frpos, (*TFILE)(unsafe.Pointer(f)).Fbuf_size) + if ret <= 0 { + goto bail + } + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Frpos + uintptr(ret) + v1 = readlen + readlen = readlen + 1 + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + **(**uint8)(__ccgo_up(buf + uintptr(v1))) = **(**uint8)(__ccgo_up(v2)) + return readlen + goto bail +bail: + ; + if ret == 0 { + v4 = int32(F_EOF) + } else { + v4 = int32(F_ERR) + } + **(**uint32)(__ccgo_up(f)) |= Uint32FromInt32(v4) + v2 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = v2 + (*TFILE)(unsafe.Pointer(f)).Frpos = v2 + return readlen +} + +func _cookiewrite(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var fc, v1, v2 uintptr + var len2 Tsize_t + var ret Tssize_t + _, _, _, _, _ = fc, len2, ret, v1, v2 + fc = (*TFILE)(unsafe.Pointer(f)).Fcookie + len2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + if !((*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fwrite != 0) { + return len1 + } + if len2 != 0 { + (*TFILE)(unsafe.Pointer(f)).Fwpos = (*TFILE)(unsafe.Pointer(f)).Fwbase + if _cookiewrite(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwpos, len2) < len2 { + return uint64(0) + } + } + ret = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tssize_t)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fwrite})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie, buf, len1) + if ret < 0 { + v2 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v2 + v1 = v2 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + return uint64(0) + } + return Uint64FromInt64(ret) +} + +func _cookieseek(tls *TLS, f uintptr, _off Toff_t, whence int32) (r Toff_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*Toff_t)(unsafe.Pointer(bp)) = _off + var fc uintptr + var res int32 + _, _ = fc, res + fc = (*TFILE)(unsafe.Pointer(f)).Fcookie + if Uint32FromInt32(whence) > uint32(2) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) + } + if !((*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fseek != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOPNOTSUPP) + return int64(-int32(1)) + } + res = (*(*func(*TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fseek})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie, bp, whence) + if res < 0 { + return int64(res) + } + return **(**Toff_t)(__ccgo_up(bp)) +} + +func _cookieclose(tls *TLS, f uintptr) (r int32) { + var fc uintptr + _ = fc + fc = (*TFILE)(unsafe.Pointer(f)).Fcookie + if (*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fclose1 != 0 { + return (*(*func(*TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfcookie)(unsafe.Pointer(fc)).Fiofuncs.Fclose1})))(tls, (*Tfcookie)(unsafe.Pointer(fc)).Fcookie) + } + return 0 +} + +func Xfopencookie(tls *TLS, cookie uintptr, mode uintptr, iofuncs Tcookie_io_functions_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v cookie=%v mode=%v iofuncs=%v, (%v:)", tls, cookie, mode, iofuncs, origin(2)) + defer func() { trc("-> %v", r) }() + } + var f, v1 uintptr + var v2 int32 + _, _, _ = f, v1, v2 + /* Check for valid initial mode character */ + if !(Xstrchr(tls, __ccgo_ts+1504, Int32FromUint8(**(**uint8)(__ccgo_up(mode)))) != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + /* Allocate FILE+fcookie+buffer or fail */ + v1 = Xmalloc(tls, uint64(1304)) + f = v1 + if !(v1 != 0) { + return uintptr(0) + } + /* Zero-fill only the struct, not the buffer */ + Xmemset(tls, f, 0, uint64(232)) + /* Impose mode restrictions */ + if !(Xstrchr(tls, mode, int32('+')) != 0) { + if Int32FromUint8(**(**uint8)(__ccgo_up(mode))) == int32('r') { + v2 = int32(F_NOWR) + } else { + v2 = int32(F_NORD) + } + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fflags = Uint32FromInt32(v2) + } + /* Set up our fcookie */ + (*Tcookie_FILE)(unsafe.Pointer(f)).Ffc.Fcookie = cookie + (*Tcookie_FILE)(unsafe.Pointer(f)).Ffc.Fiofuncs = iofuncs + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Ffd = -int32(1) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fcookie = f + 232 + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fbuf = f + 272 + uintptr(UNGET) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fbuf_size = Uint64FromInt64(1032) - Uint64FromInt32(UNGET) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Flbf = -int32(1) + /* Initialize op ptrs. No problem if some are unneeded. */ + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fread = __ccgo_fp(_cookieread) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fwrite = __ccgo_fp(_cookiewrite) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fseek = __ccgo_fp(_cookieseek) + (*Tcookie_FILE)(unsafe.Pointer(f)).Ff.Fclose1 = __ccgo_fp(_cookieclose) + /* Add new FILE to open file list */ + return X__ofl_add(tls, f) +} + +func Xfprintf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfprintf(tls, f, fmt, ap) + _ = ap + return ret +} + +func _locking_putc(tls *TLS, c int32, f uintptr) (r1 int32) { + var old, old1, r, v, v14, v2, v5, v7, v9 int32 + var v1, v11 uintptr + var v10 uint8 + _, _, _, _, _, _, _, _, _, _, _, _ = old, old1, r, v, v1, v10, v11, v14, v2, v5, v7, v9 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1521) + v5 = v + goto _6 + _6: + old = v5 + if old != 0 { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1521) + break + } + goto _4 + _4: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1521) + v2 = BoolInt32(!(r != 0)) + goto _3 + _3: + ; + if !!(v2 != 0) { + break + } + } + v7 = old + goto _8 +_8: + if v7 != 0 { + ___lockfile(tls, f) + } + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v10 = Uint8FromInt32(c) + v11 = f + 40 + v1 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + **(**uint8)(__ccgo_up(v1)) = v10 + v2 = Int32FromUint8(v10) + } else { + v2 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + c = v2 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1521) + v5 = v + goto _18 + _18: + old1 = v5 + goto _16 + _16: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1521) + v2 = BoolInt32(!(r != 0)) + goto _15 + _15: + ; + if !!(v2 != 0) { + break + } + } + v7 = old1 + goto _20 +_20: + if v7&int32(MAYBE_WAITERS) != 0 { + v11 = f + 140 + v9 = int32(1) + v14 = int32(1) + if v14 != 0 { + v14 = int32(FUTEX_PRIVATE) + } + if v9 < Int32FromInt32(0) { + v9 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v11), int64(Int32FromInt32(FUTEX_WAKE)|v14), int64(v9)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v11), int64(Int32FromInt32(FUTEX_WAKE)), int64(v9)) != 0 + } + return c +} + +func Xfputc(tls *TLS, c1 int32, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c1=%v f1=%v, (%v:)", tls, c1, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v1, v3, v5 int32 + var v2, v7, v8 uintptr + var v6 uint8 + _, _, _, _, _, _, _, _ = l, v1, v2, v3, v5, v6, v7, v8 + v1 = c1 + v2 = f1 + l = AtomicLoadPInt32(v2 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if Int32FromUint8(Uint8FromInt32(v1)) != (*TFILE)(unsafe.Pointer(v2)).Flbf && (*TFILE)(unsafe.Pointer(v2)).Fwpos != (*TFILE)(unsafe.Pointer(v2)).Fwend { + v6 = Uint8FromInt32(v1) + v8 = v2 + 40 + v7 = *(*uintptr)(unsafe.Pointer(v8)) + *(*uintptr)(unsafe.Pointer(v8)) = *(*uintptr)(unsafe.Pointer(v8)) + 1 + **(**uint8)(__ccgo_up(v7)) = v6 + v5 = Int32FromUint8(v6) + } else { + v5 = X__overflow(tls, v2, Int32FromUint8(Uint8FromInt32(v1))) + } + v3 = v5 + goto _4 + } + v3 = _locking_putc(tls, v1, v2) + goto _4 +_4: + return v3 +} + +func Xfputs(tls *TLS, s uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v f=%v, (%v:)", tls, s, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = _strlen(tls, s) + return BoolInt32(Xfwrite(tls, s, uint64(1), l, f) == l) - int32(1) +} + +func Xfputs_unlocked(tls *TLS, s uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v f=%v, (%v:)", tls, s, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfputs(tls, s, f) +} + +func X__fputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var l, v1 int32 + var loc Tlocale_t + var ploc, v3, v4 uintptr + var v2 uint8 + var _ /* mbc at bp+0 */ [4]uint8 + _, _, _, _, _, _, _ = l, loc, ploc, v1, v2, v3, v4 + ploc = uintptr(___get_tp(tls)) + 152 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if (*TFILE)(unsafe.Pointer(f)).Fmode <= 0 { + Xfwide(tls, f, int32(1)) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = (*TFILE)(unsafe.Pointer(f)).Flocale + if BoolInt32(c < uint32(128)) != 0 { + if Int32FromUint8(uint8(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v2 = uint8(c) + v4 = f + 40 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(v3)) = v2 + v1 = Int32FromUint8(v2) + } else { + v1 = X__overflow(tls, f, Int32FromUint8(uint8(c))) + } + c = Uint32FromInt32(v1) + } else { + if (*TFILE)(unsafe.Pointer(f)).Fwpos+uintptr(MB_LEN_MAX) < (*TFILE)(unsafe.Pointer(f)).Fwend { + l = Xwctomb(tls, (*TFILE)(unsafe.Pointer(f)).Fwpos, c) + if l < 0 { + c = uint32(0xffffffff) + } else { + **(**uintptr)(__ccgo_up(f + 40)) += uintptr(l) + } + } else { + l = Xwctomb(tls, bp, c) + if l < 0 || X__fwritex(tls, bp, Uint64FromInt32(l), f) < Uint64FromInt32(l) { + c = uint32(0xffffffff) + } + } + } + if c == uint32(0xffffffff) { + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return c +} + +func Xfputwc(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + _, _ = __need_unlock, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + c = X__fputwc_unlocked(tls, c, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return c +} + +func Xfputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fputwc_unlocked(tls, c, f) +} + +func Xputwc_unlocked(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fputwc_unlocked(tls, c, f) +} + +func Xfputws(tls *TLS, _ws uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v _ws=%v f=%v, (%v:)", tls, _ws, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(1040) + defer tls.Free(1040) + *(*uintptr)(unsafe.Pointer(bp)) = _ws + var __need_unlock, v1 int32 + var l, v2 Tsize_t + var loc Tlocale_t + var ploc uintptr + var v3 bool + var _ /* buf at bp+8 */ [1024]uint8 + _, _, _, _, _, _, _ = __need_unlock, l, loc, ploc, v1, v2, v3 + l = uint64(0) + ploc = uintptr(___get_tp(tls)) + 152 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + Xfwide(tls, f, int32(1)) + **(**Tlocale_t)(__ccgo_up(ploc)) = (*TFILE)(unsafe.Pointer(f)).Flocale + for { + if v3 = **(**uintptr)(__ccgo_up(bp)) != 0; v3 { + v2 = Xwcsrtombs(tls, bp+8, bp, uint64(1024), uintptr(0)) + l = v2 + } + if !(v3 && v2+uint64(1) > uint64(1)) { + break + } + if X__fwritex(tls, bp+8, l, f) < l { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return -int32(1) + } + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return Int32FromUint64(l) /* 0 or -1 */ +} + +func Xfputws_unlocked(tls *TLS, _ws uintptr, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v _ws=%v f=%v, (%v:)", tls, _ws, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfputws(tls, _ws, f) +} + +func Xfread(tls *TLS, destv uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v destv=%v size=%v nmemb=%v f=%v, (%v:)", tls, destv, size, nmemb, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var dest uintptr + var k, l, len1 Tsize_t + var v2 uint64 + _, _, _, _, _, _, _ = __need_unlock, dest, k, l, len1, v1, v2 + dest = destv + len1 = size * nmemb + l = len1 + if !(size != 0) { + nmemb = uint64(0) + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + /* First exhaust the buffer. */ + if Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos)) < l { + v2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos)) + } else { + v2 = l + } + k = v2 + Xmemcpy(tls, dest, (*TFILE)(unsafe.Pointer(f)).Frpos, k) + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(k) + dest = dest + uintptr(k) + l = l - k + } + /* Read the remainder directly */ + for { + if !(l != 0) { + break + } + if X__toread(tls, f) != 0 { + v2 = uint64(0) + } else { + v2 = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fread})))(tls, f, dest, l) + } + k = v2 + if !(k != 0) { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return (len1 - l) / size + } + goto _3 + _3: + ; + l = l - k + dest = dest + uintptr(k) + } + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return nmemb +} + +func Xfread_unlocked(tls *TLS, destv uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v destv=%v size=%v nmemb=%v f=%v, (%v:)", tls, destv, size, nmemb, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfread(tls, destv, size, nmemb, f) +} + +/* The basic idea of this implementation is to open a new FILE, + * hack the necessary parts of the new FILE into the old one, then + * close the new FILE. */ + +/* Locking IS necessary because another thread may provably hold the + * lock, via flockfile or otherwise, when freopen is called, and in that + * case, freopen cannot act until the lock is released. */ + +func Xfreopen(tls *TLS, filename uintptr, mode uintptr, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v filename=%v mode=%v f=%v, (%v:)", tls, filename, mode, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, fl, v1 int32 + var f2 uintptr + _, _, _, _ = __need_unlock, f2, fl, v1 + fl = X__fmodeflags(tls, mode) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + Xfflush(tls, f) + if !(filename != 0) { + if fl&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + fl = fl & ^(Int32FromInt32(O_CREAT) | Int32FromInt32(O_EXCL) | Int32FromInt32(O_CLOEXEC)) + if X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_fcntl), int64((*TFILE)(unsafe.Pointer(f)).Ffd), int64(Int32FromInt32(F_SETFL)), int64(fl)))) < 0 { + goto fail + } + } else { + f2 = Xfopen(tls, filename, mode) + if !(f2 != 0) { + goto fail + } + if (*TFILE)(unsafe.Pointer(f2)).Ffd == (*TFILE)(unsafe.Pointer(f)).Ffd { + (*TFILE)(unsafe.Pointer(f2)).Ffd = -int32(1) + } else { + if X__dup3(tls, (*TFILE)(unsafe.Pointer(f2)).Ffd, (*TFILE)(unsafe.Pointer(f)).Ffd, fl&int32(O_CLOEXEC)) < 0 { + goto fail2 + } + } + (*TFILE)(unsafe.Pointer(f)).Fflags = (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_PERM) | (*TFILE)(unsafe.Pointer(f2)).Fflags + (*TFILE)(unsafe.Pointer(f)).Fread = (*TFILE)(unsafe.Pointer(f2)).Fread + (*TFILE)(unsafe.Pointer(f)).Fwrite = (*TFILE)(unsafe.Pointer(f2)).Fwrite + (*TFILE)(unsafe.Pointer(f)).Fseek = (*TFILE)(unsafe.Pointer(f2)).Fseek + (*TFILE)(unsafe.Pointer(f)).Fclose1 = (*TFILE)(unsafe.Pointer(f2)).Fclose1 + Xfclose(tls, f2) + } + (*TFILE)(unsafe.Pointer(f)).Fmode = 0 + (*TFILE)(unsafe.Pointer(f)).Flocale = uintptr(0) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return f + goto fail2 +fail2: + ; + Xfclose(tls, f2) + goto fail +fail: + ; + Xfclose(tls, f) + return UintptrFromInt32(0) +} + +func Xfscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfscanf(tls, f, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_fscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfscanf(tls, f, fmt, va) +} + +func X__fseeko_unlocked(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v2 uintptr + _, _ = v1, v2 + /* Fail immediately for invalid whence argument. */ + if whence != int32(1) && whence != 0 && whence != int32(2) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + /* Adjust relative offset for unread data in buffer, if any. */ + if whence == int32(1) && (*TFILE)(unsafe.Pointer(f)).Frend != 0 { + off = off - (int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos)) + } + /* Flush write buffer, and report error on failure. */ + if (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + if !((*TFILE)(unsafe.Pointer(f)).Fwpos != 0) { + return -int32(1) + } + } + /* Leave writing mode */ + v2 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v2 + v1 = v2 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v1 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v1 + /* Perform the underlying seek. */ + if (*(*func(*TLS, uintptr, Toff_t, int32) Toff_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fseek})))(tls, f, off, whence) < 0 { + return -int32(1) + } + /* If seek succeeded, file is seekable and we discard read buffer. */ + v1 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_EOF)) + return 0 +} + +func X__fseeko(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, result, v1 int32 + _, _, _ = __need_unlock, result, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + result = X__fseeko_unlocked(tls, f, off, whence) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return result +} + +func Xfseek(tls *TLS, f uintptr, off int64, whence int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fseeko(tls, f, off, whence) +} + +func Xfseeko(tls *TLS, f uintptr, off Toff_t, whence int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v off=%v whence=%v, (%v:)", tls, f, off, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fseeko(tls, f, off, whence) +} + +func Xfsetpos(tls *TLS, f uintptr, pos uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v pos=%v, (%v:)", tls, f, pos, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__fseeko(tls, f, int64(**(**int64)(__ccgo_up(pos))), 0) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__ftello_unlocked(tls *TLS, f uintptr) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var pos Toff_t + var v1 int32 + _, _ = pos, v1 + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_APP) != 0 && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwbase { + v1 = int32(2) + } else { + v1 = int32(1) + } + pos = (*(*func(*TLS, uintptr, Toff_t, int32) Toff_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fseek})))(tls, f, 0, v1) + if pos < 0 { + return pos + } + /* Adjust for data in buffer. */ + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 { + pos = pos + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Frend)) + } else { + if (*TFILE)(unsafe.Pointer(f)).Fwbase != 0 { + pos = pos + (int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + } + } + return pos +} + +func X__ftello(tls *TLS, f uintptr) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var pos Toff_t + _, _, _ = __need_unlock, pos, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + pos = X__ftello_unlocked(tls, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return pos +} + +func Xftell(tls *TLS, f uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var pos Toff_t + _ = pos + pos = X__ftello(tls, f) + if pos > int64(0x7fffffffffffffff) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return int64(-int32(1)) + } + return pos +} + +func Xftello(tls *TLS, f uintptr) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__ftello(tls, f) +} + +func X__do_orphaned_stdio_locks(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + var f uintptr + _ = f + f = (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Fstdio_locks + for { + if !(f != 0) { + break + } + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1534) + AtomicStorePInt32(f+140, int32(0x40000000)) + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1534) + goto _1 + _1: + ; + f = (*TFILE)(unsafe.Pointer(f)).Fnext_locked + } +} + +func X__unlist_locked_file(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + if (*TFILE)(unsafe.Pointer(f)).Flockcount != 0 { + if (*TFILE)(unsafe.Pointer(f)).Fnext_locked != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fnext_locked)).Fprev_locked = (*TFILE)(unsafe.Pointer(f)).Fprev_locked + } + if (*TFILE)(unsafe.Pointer(f)).Fprev_locked != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fprev_locked)).Fnext_locked = (*TFILE)(unsafe.Pointer(f)).Fnext_locked + } else { + (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Fstdio_locks = (*TFILE)(unsafe.Pointer(f)).Fnext_locked + } + } +} + +func X__register_locked_file(tls *TLS, f uintptr, self Tpthread_t) { + if __ccgo_strace { + trc("tls=%v f=%v self=%v, (%v:)", tls, f, self, origin(2)) + } + (*TFILE)(unsafe.Pointer(f)).Flockcount = int64(1) + (*TFILE)(unsafe.Pointer(f)).Fprev_locked = uintptr(0) + (*TFILE)(unsafe.Pointer(f)).Fnext_locked = (*t__pthread)(unsafe.Pointer(self)).Fstdio_locks + if (*TFILE)(unsafe.Pointer(f)).Fnext_locked != 0 { + (*TFILE)(unsafe.Pointer((*TFILE)(unsafe.Pointer(f)).Fnext_locked)).Fprev_locked = f + } + (*t__pthread)(unsafe.Pointer(self)).Fstdio_locks = f +} + +func Xftrylockfile(tls *TLS, f uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var old, owner, r, tid, v, v1, v3, v6 int32 + var self Tpthread_t + var v10 bool + var v2 uintptr + _, _, _, _, _, _, _, _, _, _, _ = old, owner, r, self, tid, v, v1, v10, v2, v3, v6 + self = uintptr(___get_tp(tls)) + tid = (*t__pthread)(unsafe.Pointer(self)).Ftid + owner = AtomicLoadPInt32(f + 140) + if owner & ^Int32FromInt32(MAYBE_WAITERS) == tid { + if (*TFILE)(unsafe.Pointer(f)).Flockcount == int64(0x7fffffffffffffff) { + return -int32(1) + } + (*TFILE)(unsafe.Pointer(f)).Flockcount = (*TFILE)(unsafe.Pointer(f)).Flockcount + 1 + return 0 + } + if owner < 0 { + v1 = Int32FromInt32(0) + owner = v1 + AtomicStorePInt32(f+140, v1) + } + if v10 = owner != 0; !v10 { + v2 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1560) + v3 = v + goto _7 + _7: + old = v3 + if old != 0 { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1560) + break + } + goto _5 + _5: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1560) + v1 = BoolInt32(!(r != 0)) + goto _4 + _4: + ; + if !!(v1 != 0) { + break + } + } + v6 = old + goto _9 + _9: + } + if v10 || v6 != 0 { + return -int32(1) + } + X__register_locked_file(tls, f, self) + return 0 +} + +func Xfunlockfile(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + if (*TFILE)(unsafe.Pointer(f)).Flockcount == int64(1) { + X__unlist_locked_file(tls, f) + (*TFILE)(unsafe.Pointer(f)).Flockcount = 0 + ___unlockfile(tls, f) + } else { + (*TFILE)(unsafe.Pointer(f)).Flockcount = (*TFILE)(unsafe.Pointer(f)).Flockcount - 1 + } +} + +func Xfwide(tls *TLS, f uintptr, mode int32) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v mode=%v, (%v:)", tls, f, mode, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1, v3 int32 + var v2 Tlocale_t + _, _, _, _ = __need_unlock, v1, v2, v3 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if mode != 0 { + if !((*TFILE)(unsafe.Pointer(f)).Flocale != 0) { + if !!(**(**uintptr)(__ccgo_up((*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale)) != 0) { + v3 = int32(4) + } else { + v3 = int32(1) + } + if v3 == int32(1) { + v2 = uintptr(unsafe.Pointer(&X__c_locale)) + } else { + v2 = uintptr(unsafe.Pointer(&X__c_dot_utf8_locale)) + } + (*TFILE)(unsafe.Pointer(f)).Flocale = v2 + } + if !((*TFILE)(unsafe.Pointer(f)).Fmode != 0) { + if mode > 0 { + v1 = int32(1) + } else { + v1 = -int32(1) + } + (*TFILE)(unsafe.Pointer(f)).Fmode = v1 + } + } + mode = (*TFILE)(unsafe.Pointer(f)).Fmode + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return mode +} + +func Xfwprintf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfwprintf(tls, f, fmt, ap) + _ = ap + return ret +} + +func X__fwritex(tls *TLS, s uintptr, l Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v f=%v, (%v:)", tls, s, l, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var i, n Tsize_t + _, _ = i, n + i = uint64(0) + if !((*TFILE)(unsafe.Pointer(f)).Fwend != 0) && X__towrite(tls, f) != 0 { + return uint64(0) + } + if l > Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwend)-int64((*TFILE)(unsafe.Pointer(f)).Fwpos)) { + return (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, s, l) + } + if (*TFILE)(unsafe.Pointer(f)).Flbf >= 0 { + /* Match /^(.*\n|)/ */ + i = l + for { + if !(i != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(i-uint64(1))))) != int32('\n')) { + break + } + goto _1 + _1: + ; + i = i - 1 + } + if i != 0 { + n = (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, s, i) + if n < i { + return n + } + s = s + uintptr(i) + l = l - i + } + } + Xmemcpy(tls, (*TFILE)(unsafe.Pointer(f)).Fwpos, s, l) + **(**uintptr)(__ccgo_up(f + 40)) += uintptr(l) + return l + i +} + +func Xfwrite(tls *TLS, src uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v src=%v size=%v nmemb=%v f=%v, (%v:)", tls, src, size, nmemb, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var k, l Tsize_t + var v2 uint64 + _, _, _, _, _ = __need_unlock, k, l, v1, v2 + l = size * nmemb + if !(size != 0) { + nmemb = uint64(0) + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + k = X__fwritex(tls, src, l, f) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + if k == l { + v2 = nmemb + } else { + v2 = k / size + } + return v2 +} + +func Xfwrite_unlocked(tls *TLS, src uintptr, size Tsize_t, nmemb Tsize_t, f uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v src=%v size=%v nmemb=%v f=%v, (%v:)", tls, src, size, nmemb, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfwrite(tls, src, size, nmemb, f) +} + +func Xfwscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfwscanf(tls, f, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_fwscanf(tls *TLS, f uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v va=%v, (%v:)", tls, f, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfwscanf(tls, f, fmt, va) +} + +func _locking_getc1(tls *TLS, f uintptr) (r1 int32) { + var c, old, old1, r, v, v13, v16, v2, v5, v7, v9 int32 + var v1, v10, v11, v12 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, old, old1, r, v, v1, v10, v11, v12, v13, v16, v2, v5, v7, v9 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1508) + v5 = v + goto _6 + _6: + old = v5 + if old != 0 { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1508) + break + } + goto _4 + _4: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1508) + v2 = BoolInt32(!(r != 0)) + goto _3 + _3: + ; + if !!(v2 != 0) { + break + } + } + v7 = old + goto _8 +_8: + if v7 != 0 { + ___lockfile(tls, f) + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v10 = f + 8 + v1 = *(*uintptr)(unsafe.Pointer(v10)) + *(*uintptr)(unsafe.Pointer(v10)) = *(*uintptr)(unsafe.Pointer(v10)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v1))) + } else { + v2 = X__uflow(tls, f) + } + c = v2 + v11 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1508) + v7 = v + goto _17 + _17: + old1 = v7 + goto _15 + _15: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1508) + v5 = BoolInt32(!(r != 0)) + goto _14 + _14: + ; + if !!(v5 != 0) { + break + } + } + v9 = old1 + goto _19 +_19: + if v9&int32(MAYBE_WAITERS) != 0 { + v12 = f + 140 + v13 = int32(1) + v16 = int32(1) + if v16 != 0 { + v16 = int32(FUTEX_PRIVATE) + } + if v13 < Int32FromInt32(0) { + v13 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v12), int64(Int32FromInt32(FUTEX_WAKE)|v16), int64(v13)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v12), int64(Int32FromInt32(FUTEX_WAKE)), int64(v13)) != 0 + } + return c +} + +func Xgetc(tls *TLS, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f1=%v, (%v:)", tls, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v2, v4 int32 + var v1, v5, v6 uintptr + _, _, _, _, _, _ = l, v1, v2, v4, v5, v6 + v1 = f1 + l = AtomicLoadPInt32(v1 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if (*TFILE)(unsafe.Pointer(v1)).Frpos != (*TFILE)(unsafe.Pointer(v1)).Frend { + v6 = v1 + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = X__uflow(tls, v1) + } + v2 = v4 + goto _3 + } + v2 = _locking_getc1(tls, v1) + goto _3 +_3: + return v2 +} + +func X_IO_getc(tls *TLS, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f1=%v, (%v:)", tls, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetc(tls, f1) +} + +func Xgetc_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + var v2, v3 uintptr + _, _, _ = v1, v2, v3 + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v3 = f + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__uflow(tls, f) + } + return v1 +} + +func X_IO_getc_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetc_unlocked(tls, f) +} + +func Xfgetc_unlocked(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetc_unlocked(tls, f) +} + +func _locking_getc2(tls *TLS, f uintptr) (r1 int32) { + var c, old, old1, r, v, v13, v16, v2, v5, v7, v9 int32 + var v1, v10, v11, v12 uintptr + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, old, old1, r, v, v1, v10, v11, v12, v13, v16, v2, v5, v7, v9 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1508) + v5 = v + goto _6 + _6: + old = v5 + if old != 0 { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1508) + break + } + goto _4 + _4: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1508) + v2 = BoolInt32(!(r != 0)) + goto _3 + _3: + ; + if !!(v2 != 0) { + break + } + } + v7 = old + goto _8 +_8: + if v7 != 0 { + ___lockfile(tls, f) + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v10 = f + 8 + v1 = *(*uintptr)(unsafe.Pointer(v10)) + *(*uintptr)(unsafe.Pointer(v10)) = *(*uintptr)(unsafe.Pointer(v10)) + 1 + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(v1))) + } else { + v2 = X__uflow(tls, f) + } + c = v2 + v11 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1508) + v7 = v + goto _17 + _17: + old1 = v7 + goto _15 + _15: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1508) + v5 = BoolInt32(!(r != 0)) + goto _14 + _14: + ; + if !!(v5 != 0) { + break + } + } + v9 = old1 + goto _19 +_19: + if v9&int32(MAYBE_WAITERS) != 0 { + v12 = f + 140 + v13 = int32(1) + v16 = int32(1) + if v16 != 0 { + v16 = int32(FUTEX_PRIVATE) + } + if v13 < Int32FromInt32(0) { + v13 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v12), int64(Int32FromInt32(FUTEX_WAKE)|v16), int64(v13)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v12), int64(Int32FromInt32(FUTEX_WAKE)), int64(v13)) != 0 + } + return c +} + +func Xgetchar(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v2, v4 int32 + var v1, v5, v6 uintptr + _, _, _, _, _, _ = l, v1, v2, v4, v5, v6 + v1 = uintptr(unsafe.Pointer(&X__stdin_FILE)) + l = AtomicLoadPInt32(v1 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if (*TFILE)(unsafe.Pointer(v1)).Frpos != (*TFILE)(unsafe.Pointer(v1)).Frend { + v6 = v1 + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = X__uflow(tls, v1) + } + v2 = v4 + goto _3 + } + v2 = _locking_getc2(tls, v1) + goto _3 +_3: + return v2 +} + +func Xgetchar_unlocked(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + var v2, v3 uintptr + _, _, _ = v1, v2, v3 + if (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Frpos != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Frend { + v3 = uintptr(unsafe.Pointer(&X__stdin_FILE)) + 8 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v2))) + } else { + v1 = X__uflow(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) + } + return v1 +} + +func Xgetdelim(tls *TLS, s uintptr, n uintptr, delim int32, f uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v delim=%v f=%v, (%v:)", tls, s, n, delim, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, c, v1, v4 int32 + var i, k, m, v11 Tsize_t + var tmp, z, v6, v7 uintptr + var v10 uint8 + var v3 int64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __need_unlock, c, i, k, m, tmp, z, v1, v10, v11, v3, v4, v6, v7 + i = uint64(0) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if !(n != 0) || !(s != 0) { + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) + } + if !(**(**uintptr)(__ccgo_up(s)) != 0) { + **(**Tsize_t)(__ccgo_up(n)) = uint64(0) + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + z = Xmemchr(tls, (*TFILE)(unsafe.Pointer(f)).Frpos, delim, Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Frend)-int64((*TFILE)(unsafe.Pointer(f)).Frpos))) + if z != 0 { + v3 = int64(z) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + int64(1) + } else { + v3 = int64((*TFILE)(unsafe.Pointer(f)).Frend) - int64((*TFILE)(unsafe.Pointer(f)).Frpos) + } + k = Uint64FromInt64(v3) + } else { + z = uintptr(0) + k = uint64(0) + } + if i+k >= **(**Tsize_t)(__ccgo_up(n)) { + m = i + k + uint64(2) + if !(z != 0) && m < Uint64FromUint64(0xffffffffffffffff)/Uint64FromInt32(4) { + m = m + m/uint64(2) + } + tmp = Xrealloc(tls, **(**uintptr)(__ccgo_up(s)), m) + if !(tmp != 0) { + m = i + k + uint64(2) + tmp = Xrealloc(tls, **(**uintptr)(__ccgo_up(s)), m) + if !(tmp != 0) { + /* Copy as much as fits and ensure no + * pushback remains in the FILE buf. */ + k = **(**Tsize_t)(__ccgo_up(n)) - i + Xmemcpy(tls, **(**uintptr)(__ccgo_up(s))+uintptr(i), (*TFILE)(unsafe.Pointer(f)).Frpos, k) + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(k) + **(**int32)(__ccgo_up(f + 136)) |= (*TFILE)(unsafe.Pointer(f)).Fmode - int32(1) + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOMEM) + return int64(-int32(1)) + } + } + **(**uintptr)(__ccgo_up(s)) = tmp + **(**Tsize_t)(__ccgo_up(n)) = m + } + if k != 0 { + Xmemcpy(tls, **(**uintptr)(__ccgo_up(s))+uintptr(i), (*TFILE)(unsafe.Pointer(f)).Frpos, k) + **(**uintptr)(__ccgo_up(f + 8)) += uintptr(k) + i = i + k + } + if z != 0 { + break + } + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend { + v7 = f + 8 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) + 1 + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(v6))) + } else { + v4 = X__uflow(tls, f) + } + v1 = v4 + c = v1 + if v1 == -int32(1) { + if !(i != 0) || !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_EOF) != 0) { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return int64(-int32(1)) + } + break + } + /* If the byte read by getc won't fit without growing the + * output buffer, push it back for next iteration. */ + if i+uint64(1) >= **(**Tsize_t)(__ccgo_up(n)) { + v7 = f + 8 + *(*uintptr)(unsafe.Pointer(v7)) = *(*uintptr)(unsafe.Pointer(v7)) - 1 + v6 = *(*uintptr)(unsafe.Pointer(v7)) + **(**uint8)(__ccgo_up(v6)) = Uint8FromInt32(c) + } else { + v10 = Uint8FromInt32(c) + v11 = i + i = i + 1 + **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)) + uintptr(v11))) = v10 + if Int32FromUint8(v10) == delim { + break + } + } + goto _2 + _2: + } + **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)) + uintptr(i))) = uint8(0) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return Int64FromUint64(i) +} + +func X__getdelim(tls *TLS, s uintptr, n uintptr, delim int32, f uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v delim=%v f=%v, (%v:)", tls, s, n, delim, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetdelim(tls, s, n, delim, f) +} + +func Xgetline(tls *TLS, s uintptr, n uintptr, f uintptr) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v, (%v:)", tls, s, n, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetdelim(tls, s, n, int32('\n'), f) +} + +func Xgets(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, c, v1, v2, v3 int32 + var i, v6 Tsize_t + var v4, v5 uintptr + _, _, _, _, _, _, _, _, _ = __need_unlock, c, i, v1, v2, v3, v4, v5, v6 + i = uint64(0) + if AtomicLoadPInt32(uintptr(unsafe.Pointer(&X__stdin_FILE))+140) >= 0 { + v1 = ___lockfile(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) + } else { + v1 = 0 + } + __need_unlock = v1 + for { + if (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Frpos != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Frend { + v5 = uintptr(unsafe.Pointer(&X__stdin_FILE)) + 8 + v4 = *(*uintptr)(unsafe.Pointer(v5)) + *(*uintptr)(unsafe.Pointer(v5)) = *(*uintptr)(unsafe.Pointer(v5)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v4))) + } else { + v3 = X__uflow(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) + } + v2 = v3 + c = v2 + if !(v2 != -int32(1) && c != int32('\n')) { + break + } + v6 = i + i = i + 1 + **(**uint8)(__ccgo_up(s + uintptr(v6))) = Uint8FromInt32(c) + } + **(**uint8)(__ccgo_up(s + uintptr(i))) = uint8(0) + if c != int32('\n') && (!((*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdin_FILE)))).Fflags&Uint32FromInt32(F_EOF) != 0) || !(i != 0)) { + s = uintptr(0) + } + if __need_unlock != 0 { + ___unlockfile(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) + } + return s +} + +func Xgetw(tls *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 int32 + var _ /* x at bp+0 */ int32 + _ = v1 + if Xfread(tls, bp, uint64(4), uint64(1), f) != 0 { + v1 = **(**int32)(__ccgo_up(bp)) + } else { + v1 = -int32(1) + } + return v1 +} + +func Xgetwc(tls *TLS, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfgetwc(tls, f) +} + +func Xgetwchar(tls *TLS) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfgetwc(tls, uintptr(unsafe.Pointer(&X__stdin_FILE))) +} + +func Xgetwchar_unlocked(tls *TLS) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetwchar(tls) +} + +var _ofl_head uintptr +var _ofl_lock [1]int32 + +func X__ofl_lock(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + ___lock(tls, uintptr(unsafe.Pointer(&_ofl_lock))) + return uintptr(unsafe.Pointer(&_ofl_head)) +} + +func X__ofl_unlock(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + ___unlock(tls, uintptr(unsafe.Pointer(&_ofl_lock))) +} + +func X__ofl_add(tls *TLS, f uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var head uintptr + _ = head + head = X__ofl_lock(tls) + (*TFILE)(unsafe.Pointer(f)).Fnext = **(**uintptr)(__ccgo_up(head)) + if **(**uintptr)(__ccgo_up(head)) != 0 { + (*TFILE)(unsafe.Pointer(**(**uintptr)(__ccgo_up(head)))).Fprev = f + } + **(**uintptr)(__ccgo_up(head)) = f + X__ofl_unlock(tls) + return f +} + +type Tcookie1 = struct { + Fbufp uintptr + Fsizep uintptr + Fpos Tsize_t + Fbuf uintptr + Flen1 Tsize_t + Fspace Tsize_t +} + +type Tms_FILE = struct { + Ff TFILE + Fc Tcookie1 + Fbuf [1024]uint8 +} + +func _ms_seek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var base Tssize_t + var c uintptr + var v2 Tsize_t + _, _, _ = base, c, v2 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(Uint32FromInt32(whence) > uint32(2)) { + goto _1 + } + goto fail +fail: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) +_1: + ; + *(*[3]Tsize_t)(unsafe.Pointer(bp)) = [3]Tsize_t{ + 1: (*Tcookie1)(unsafe.Pointer(c)).Fpos, + 2: (*Tcookie1)(unsafe.Pointer(c)).Flen1, + } + base = Int64FromUint64(**(**Tsize_t)(__ccgo_up(bp + uintptr(whence)*8))) + if off < -base || off > int64(0x7fffffffffffffff)-base { + goto fail + } + v2 = Uint64FromInt64(base + off) + (*Tcookie1)(unsafe.Pointer(c)).Fpos = v2 + return Int64FromUint64(v2) +} + +func _ms_write(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var c, newbuf, v1 uintptr + var len2 Tsize_t + _, _, _, _ = c, len2, newbuf, v1 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + len2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + if len2 != 0 { + (*TFILE)(unsafe.Pointer(f)).Fwpos = (*TFILE)(unsafe.Pointer(f)).Fwbase + if _ms_write(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwbase, len2) < len2 { + return uint64(0) + } + } + if len1+(*Tcookie1)(unsafe.Pointer(c)).Fpos >= (*Tcookie1)(unsafe.Pointer(c)).Fspace { + len2 = uint64(2)*(*Tcookie1)(unsafe.Pointer(c)).Fspace + uint64(1) | ((*Tcookie1)(unsafe.Pointer(c)).Fpos + len1 + uint64(1)) + newbuf = Xrealloc(tls, (*Tcookie1)(unsafe.Pointer(c)).Fbuf, len2) + if !(newbuf != 0) { + return uint64(0) + } + v1 = newbuf + (*Tcookie1)(unsafe.Pointer(c)).Fbuf = v1 + **(**uintptr)(__ccgo_up((*Tcookie1)(unsafe.Pointer(c)).Fbufp)) = v1 + Xmemset(tls, (*Tcookie1)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie1)(unsafe.Pointer(c)).Fspace), 0, len2-(*Tcookie1)(unsafe.Pointer(c)).Fspace) + (*Tcookie1)(unsafe.Pointer(c)).Fspace = len2 + } + Xmemcpy(tls, (*Tcookie1)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie1)(unsafe.Pointer(c)).Fpos), buf, len1) + **(**Tsize_t)(__ccgo_up(c + 16)) += len1 + if (*Tcookie1)(unsafe.Pointer(c)).Fpos >= (*Tcookie1)(unsafe.Pointer(c)).Flen1 { + (*Tcookie1)(unsafe.Pointer(c)).Flen1 = (*Tcookie1)(unsafe.Pointer(c)).Fpos + } + **(**Tsize_t)(__ccgo_up((*Tcookie1)(unsafe.Pointer(c)).Fsizep)) = (*Tcookie1)(unsafe.Pointer(c)).Fpos + return len1 +} + +func _ms_close(tls *TLS, f uintptr) (r int32) { + return 0 +} + +func Xopen_memstream(tls *TLS, bufp uintptr, sizep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v bufp=%v sizep=%v, (%v:)", tls, bufp, sizep, origin(2)) + defer func() { trc("-> %v", r) }() + } + var buf, f, v1 uintptr + var v3, v4, v5 Tsize_t + _, _, _, _, _, _ = buf, f, v1, v3, v4, v5 + v1 = Xmalloc(tls, uint64(1304)) + f = v1 + if !(v1 != 0) { + return uintptr(0) + } + v1 = Xmalloc(tls, uint64(1)) + buf = v1 + if !(v1 != 0) { + Xfree(tls, f) + return uintptr(0) + } + Xmemset(tls, f, 0, uint64(232)) + Xmemset(tls, f+232, 0, uint64(48)) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fcookie = f + 232 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fbufp = bufp + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fsizep = sizep + v5 = Uint64FromInt32(0) + **(**Tsize_t)(__ccgo_up(sizep)) = v5 + v4 = v5 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fspace = v4 + v3 = v4 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Flen1 = v3 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fpos = v3 + v1 = buf + **(**uintptr)(__ccgo_up(bufp)) = v1 + (*Tms_FILE)(unsafe.Pointer(f)).Fc.Fbuf = v1 + **(**uint8)(__ccgo_up(buf)) = uint8(0) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fflags = uint32(F_NORD) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Ffd = -int32(1) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fbuf = f + 280 + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fbuf_size = uint64(1024) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Flbf = -int32(1) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fwrite = __ccgo_fp(_ms_write) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fseek = __ccgo_fp(_ms_seek) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fclose1 = __ccgo_fp(_ms_close) + (*Tms_FILE)(unsafe.Pointer(f)).Ff.Fmode = -int32(1) + if !(X__libc.Fthreaded != 0) { + AtomicStorePInt32(f+140, -int32(1)) + } + return X__ofl_add(tls, f) +} + +type Tcookie2 = struct { + Fbufp uintptr + Fsizep uintptr + Fpos Tsize_t + Fbuf uintptr + Flen1 Tsize_t + Fspace Tsize_t + Fmbs Tmbstate_t +} + +type Twms_FILE = struct { + Ff TFILE + Fc Tcookie2 + Fbuf [1]uint8 +} + +func _wms_seek(tls *TLS, f uintptr, off Toff_t, whence int32) (r Toff_t) { + bp := tls.Alloc(32) + defer tls.Free(32) + var base Tssize_t + var c uintptr + var v2 Tsize_t + _, _, _ = base, c, v2 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(Uint32FromInt32(whence) > uint32(2)) { + goto _1 + } + goto fail +fail: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return int64(-int32(1)) +_1: + ; + *(*[3]Tsize_t)(unsafe.Pointer(bp)) = [3]Tsize_t{ + 1: (*Tcookie2)(unsafe.Pointer(c)).Fpos, + 2: (*Tcookie2)(unsafe.Pointer(c)).Flen1, + } + base = Int64FromUint64(**(**Tsize_t)(__ccgo_up(bp + uintptr(whence)*8))) + if off < -base || off > Int64FromInt64(0x7fffffffffffffff)/Int64FromInt32(4)-base { + goto fail + } + Xmemset(tls, c+48, 0, uint64(8)) + v2 = Uint64FromInt64(base + off) + (*Tcookie2)(unsafe.Pointer(c)).Fpos = v2 + return Int64FromUint64(v2) +} + +func _wms_write(tls *TLS, f uintptr, _buf uintptr, len1 Tsize_t) (r Tsize_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + *(*uintptr)(unsafe.Pointer(bp)) = _buf + var c, newbuf, v1 uintptr + var len2 Tsize_t + _, _, _, _ = c, len2, newbuf, v1 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + len2 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + if len2 != 0 { + (*TFILE)(unsafe.Pointer(f)).Fwpos = (*TFILE)(unsafe.Pointer(f)).Fwbase + if _wms_write(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwbase, len2) < len2 { + return uint64(0) + } + } + if len1+(*Tcookie2)(unsafe.Pointer(c)).Fpos >= (*Tcookie2)(unsafe.Pointer(c)).Fspace { + len2 = uint64(2)*(*Tcookie2)(unsafe.Pointer(c)).Fspace + uint64(1) | ((*Tcookie2)(unsafe.Pointer(c)).Fpos + len1 + uint64(1)) + if len2 > Uint64FromInt64(Int64FromInt64(0x7fffffffffffffff)/Int64FromInt32(4)) { + return uint64(0) + } + newbuf = Xrealloc(tls, (*Tcookie2)(unsafe.Pointer(c)).Fbuf, len2*uint64(4)) + if !(newbuf != 0) { + return uint64(0) + } + v1 = newbuf + (*Tcookie2)(unsafe.Pointer(c)).Fbuf = v1 + **(**uintptr)(__ccgo_up((*Tcookie2)(unsafe.Pointer(c)).Fbufp)) = v1 + Xmemset(tls, (*Tcookie2)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie2)(unsafe.Pointer(c)).Fspace)*4, 0, uint64(4)*(len2-(*Tcookie2)(unsafe.Pointer(c)).Fspace)) + (*Tcookie2)(unsafe.Pointer(c)).Fspace = len2 + } + len2 = Xmbsnrtowcs(tls, (*Tcookie2)(unsafe.Pointer(c)).Fbuf+uintptr((*Tcookie2)(unsafe.Pointer(c)).Fpos)*4, bp, len1, (*Tcookie2)(unsafe.Pointer(c)).Fspace-(*Tcookie2)(unsafe.Pointer(c)).Fpos, c+48) + if len2 == Uint64FromInt32(-Int32FromInt32(1)) { + return uint64(0) + } + **(**Tsize_t)(__ccgo_up(c + 16)) += len2 + if (*Tcookie2)(unsafe.Pointer(c)).Fpos >= (*Tcookie2)(unsafe.Pointer(c)).Flen1 { + (*Tcookie2)(unsafe.Pointer(c)).Flen1 = (*Tcookie2)(unsafe.Pointer(c)).Fpos + } + **(**Tsize_t)(__ccgo_up((*Tcookie2)(unsafe.Pointer(c)).Fsizep)) = (*Tcookie2)(unsafe.Pointer(c)).Fpos + return len1 +} + +func _wms_close(tls *TLS, f uintptr) (r int32) { + return 0 +} + +func Xopen_wmemstream(tls *TLS, bufp uintptr, sizep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v bufp=%v sizep=%v, (%v:)", tls, bufp, sizep, origin(2)) + defer func() { trc("-> %v", r) }() + } + var buf, f, v1 uintptr + var v3, v4, v5 Tsize_t + _, _, _, _, _, _ = buf, f, v1, v3, v4, v5 + v1 = Xmalloc(tls, uint64(296)) + f = v1 + if !(v1 != 0) { + return uintptr(0) + } + v1 = Xmalloc(tls, uint64(4)) + buf = v1 + if !(v1 != 0) { + Xfree(tls, f) + return uintptr(0) + } + Xmemset(tls, f, 0, uint64(232)) + Xmemset(tls, f+232, 0, uint64(56)) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fcookie = f + 232 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fbufp = bufp + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fsizep = sizep + v5 = Uint64FromInt32(0) + **(**Tsize_t)(__ccgo_up(sizep)) = v5 + v4 = v5 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fspace = v4 + v3 = v4 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Flen1 = v3 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fpos = v3 + v1 = buf + **(**uintptr)(__ccgo_up(bufp)) = v1 + (*Twms_FILE)(unsafe.Pointer(f)).Fc.Fbuf = v1 + **(**Twchar_t)(__ccgo_up(buf)) = uint32(0) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fflags = uint32(F_NORD) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Ffd = -int32(1) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fbuf = f + 288 + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fbuf_size = uint64(0) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Flbf = -int32(1) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fwrite = __ccgo_fp(_wms_write) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fseek = __ccgo_fp(_wms_seek) + (*Twms_FILE)(unsafe.Pointer(f)).Ff.Fclose1 = __ccgo_fp(_wms_close) + if !(X__libc.Fthreaded != 0) { + AtomicStorePInt32(f+140, -int32(1)) + } + Xfwide(tls, f, int32(1)) + return X__ofl_add(tls, f) +} + +func Xpclose(tls *TLS, f uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var pid Tpid_t + var r, v1 int32 + var _ /* status at bp+0 */ int32 + _, _, _ = pid, r, v1 + pid = (*TFILE)(unsafe.Pointer(f)).Fpipe_pid + Xfclose(tls, f) + for { + v1 = int32(X__syscall4(tls, int64(SYS_wait4), int64(pid), int64(bp), int64(Int32FromInt32(0)), int64(Int32FromInt32(0)))) + r = v1 + if !(v1 == -int32(EINTR)) { + break + } + } + if r < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) + } + return **(**int32)(__ccgo_up(bp)) +} + +func Xperror(tls *TLS, msg uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v, (%v:)", tls, msg, origin(2)) + } + var __need_unlock, old_mode, v1 int32 + var errstr, f, old_locale uintptr + _, _, _, _, _, _ = __need_unlock, errstr, f, old_locale, old_mode, v1 + f = uintptr(unsafe.Pointer(&X__stderr_FILE)) + errstr = Xstrerror(tls, **(**int32)(__ccgo_up(X__errno_location(tls)))) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + /* Save stderr's orientation and encoding rule, since perror is not + * permitted to change them. */ + old_locale = (*TFILE)(unsafe.Pointer(f)).Flocale + old_mode = (*TFILE)(unsafe.Pointer(f)).Fmode + if msg != 0 && **(**uint8)(__ccgo_up(msg)) != 0 { + Xfwrite(tls, msg, _strlen(tls, msg), uint64(1), f) + Xfputc(tls, int32(':'), f) + Xfputc(tls, int32(' '), f) + } + Xfwrite(tls, errstr, _strlen(tls, errstr), uint64(1), f) + Xfputc(tls, int32('\n'), f) + (*TFILE)(unsafe.Pointer(f)).Fmode = old_mode + (*TFILE)(unsafe.Pointer(f)).Flocale = old_locale + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xprintf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvfprintf(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), fmt, ap) + _ = ap + return ret +} + +func _locking_putc1(tls *TLS, c int32, f uintptr) (r1 int32) { + var old, old1, r, v, v14, v2, v5, v7, v9 int32 + var v1, v11 uintptr + var v10 uint8 + _, _, _, _, _, _, _, _, _, _, _, _ = old, old1, r, v, v1, v10, v11, v14, v2, v5, v7, v9 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1521) + v5 = v + goto _6 + _6: + old = v5 + if old != 0 { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1521) + break + } + goto _4 + _4: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1521) + v2 = BoolInt32(!(r != 0)) + goto _3 + _3: + ; + if !!(v2 != 0) { + break + } + } + v7 = old + goto _8 +_8: + if v7 != 0 { + ___lockfile(tls, f) + } + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v10 = Uint8FromInt32(c) + v11 = f + 40 + v1 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + **(**uint8)(__ccgo_up(v1)) = v10 + v2 = Int32FromUint8(v10) + } else { + v2 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + c = v2 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1521) + v5 = v + goto _18 + _18: + old1 = v5 + goto _16 + _16: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1521) + v2 = BoolInt32(!(r != 0)) + goto _15 + _15: + ; + if !!(v2 != 0) { + break + } + } + v7 = old1 + goto _20 +_20: + if v7&int32(MAYBE_WAITERS) != 0 { + v11 = f + 140 + v9 = int32(1) + v14 = int32(1) + if v14 != 0 { + v14 = int32(FUTEX_PRIVATE) + } + if v9 < Int32FromInt32(0) { + v9 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v11), int64(Int32FromInt32(FUTEX_WAKE)|v14), int64(v9)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v11), int64(Int32FromInt32(FUTEX_WAKE)), int64(v9)) != 0 + } + return c +} + +func Xputc(tls *TLS, c1 int32, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c1=%v f1=%v, (%v:)", tls, c1, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v1, v3, v5 int32 + var v2, v7, v8 uintptr + var v6 uint8 + _, _, _, _, _, _, _, _ = l, v1, v2, v3, v5, v6, v7, v8 + v1 = c1 + v2 = f1 + l = AtomicLoadPInt32(v2 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if Int32FromUint8(Uint8FromInt32(v1)) != (*TFILE)(unsafe.Pointer(v2)).Flbf && (*TFILE)(unsafe.Pointer(v2)).Fwpos != (*TFILE)(unsafe.Pointer(v2)).Fwend { + v6 = Uint8FromInt32(v1) + v8 = v2 + 40 + v7 = *(*uintptr)(unsafe.Pointer(v8)) + *(*uintptr)(unsafe.Pointer(v8)) = *(*uintptr)(unsafe.Pointer(v8)) + 1 + **(**uint8)(__ccgo_up(v7)) = v6 + v5 = Int32FromUint8(v6) + } else { + v5 = X__overflow(tls, v2, Int32FromUint8(Uint8FromInt32(v1))) + } + v3 = v5 + goto _4 + } + v3 = _locking_putc1(tls, v1, v2) + goto _4 +_4: + return v3 +} + +func X_IO_putc(tls *TLS, c1 int32, f1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c1=%v f1=%v, (%v:)", tls, c1, f1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xputc(tls, c1, f1) +} + +func Xputc_unlocked(tls *TLS, c int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + var v2 uint8 + var v3, v4 uintptr + _, _, _, _ = v1, v2, v3, v4 + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v2 = Uint8FromInt32(c) + v4 = f + 40 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(v3)) = v2 + v1 = Int32FromUint8(v2) + } else { + v1 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + return v1 +} + +func X_IO_putc_unlocked(tls *TLS, c int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xputc_unlocked(tls, c, f) +} + +func Xfputc_unlocked(tls *TLS, c int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xputc_unlocked(tls, c, f) +} + +func _locking_putc2(tls *TLS, c int32, f uintptr) (r1 int32) { + var old, old1, r, v, v14, v2, v5, v7, v9 int32 + var v1, v11 uintptr + var v10 uint8 + _, _, _, _, _, _, _, _, _, _, _, _ = old, old1, r, v, v1, v10, v11, v14, v2, v5, v7, v9 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1521) + v5 = v + goto _6 + _6: + old = v5 + if old != 0 { + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1521) + break + } + goto _4 + _4: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1521) + v2 = BoolInt32(!(r != 0)) + goto _3 + _3: + ; + if !!(v2 != 0) { + break + } + } + v7 = old + goto _8 +_8: + if v7 != 0 { + ___lockfile(tls, f) + } + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(f)).Flbf && (*TFILE)(unsafe.Pointer(f)).Fwpos != (*TFILE)(unsafe.Pointer(f)).Fwend { + v10 = Uint8FromInt32(c) + v11 = f + 40 + v1 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + **(**uint8)(__ccgo_up(v1)) = v10 + v2 = Int32FromUint8(v10) + } else { + v2 = X__overflow(tls, f, Int32FromUint8(Uint8FromInt32(c))) + } + c = v2 + v1 = f + 140 + for { + // __asm__ __volatile__ ("ldaxr %w0,%1" : "=r"(v) : "Q"(*p)); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 5, __ccgo_ts+1521) + v5 = v + goto _18 + _18: + old1 = v5 + goto _16 + _16: + ; + // __asm__ __volatile__ ("stlxr %w0,%w2,%1" : "=&r"(r), "=Q"(*p) : "r"(v) : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 13, __ccgo_ts+1521) + v2 = BoolInt32(!(r != 0)) + goto _15 + _15: + ; + if !!(v2 != 0) { + break + } + } + v7 = old1 + goto _20 +_20: + if v7&int32(MAYBE_WAITERS) != 0 { + v11 = f + 140 + v9 = int32(1) + v14 = int32(1) + if v14 != 0 { + v14 = int32(FUTEX_PRIVATE) + } + if v9 < Int32FromInt32(0) { + v9 = int32(INT_MAX) + } + _ = X__syscall3(tls, int64(SYS_futex), int64(v11), int64(Int32FromInt32(FUTEX_WAKE)|v14), int64(v9)) != int64(-int32(ENOSYS)) || X__syscall3(tls, int64(SYS_futex), int64(v11), int64(Int32FromInt32(FUTEX_WAKE)), int64(v9)) != 0 + } + return c +} + +func Xputchar(tls *TLS, c1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c1=%v, (%v:)", tls, c1, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l, v1, v3, v5 int32 + var v2, v7, v8 uintptr + var v6 uint8 + _, _, _, _, _, _, _, _ = l, v1, v2, v3, v5, v6, v7, v8 + v1 = c1 + v2 = uintptr(unsafe.Pointer(&X__stdout_FILE)) + l = AtomicLoadPInt32(v2 + 140) + if l < 0 || l != 0 && l & ^Int32FromInt32(MAYBE_WAITERS) == (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Ftid { + if Int32FromUint8(Uint8FromInt32(v1)) != (*TFILE)(unsafe.Pointer(v2)).Flbf && (*TFILE)(unsafe.Pointer(v2)).Fwpos != (*TFILE)(unsafe.Pointer(v2)).Fwend { + v6 = Uint8FromInt32(v1) + v8 = v2 + 40 + v7 = *(*uintptr)(unsafe.Pointer(v8)) + *(*uintptr)(unsafe.Pointer(v8)) = *(*uintptr)(unsafe.Pointer(v8)) + 1 + **(**uint8)(__ccgo_up(v7)) = v6 + v5 = Int32FromUint8(v6) + } else { + v5 = X__overflow(tls, v2, Int32FromUint8(Uint8FromInt32(v1))) + } + v3 = v5 + goto _4 + } + v3 = _locking_putc2(tls, v1, v2) + goto _4 +_4: + return v3 +} + +func Xputchar_unlocked(tls *TLS, c int32) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + var v2 uint8 + var v3, v4 uintptr + _, _, _, _ = v1, v2, v3, v4 + if Int32FromUint8(Uint8FromInt32(c)) != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Flbf && (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Fwpos != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Fwend { + v2 = Uint8FromInt32(c) + v4 = uintptr(unsafe.Pointer(&X__stdout_FILE)) + 40 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(v3)) = v2 + v1 = Int32FromUint8(v2) + } else { + v1 = X__overflow(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), Int32FromUint8(Uint8FromInt32(c))) + } + return v1 +} + +func Xputs(tls *TLS, s uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var __need_unlock, r, v1, v2 int32 + var v3 uint8 + var v4, v5 uintptr + var v6 bool + _, _, _, _, _, _, _, _ = __need_unlock, r, v1, v2, v3, v4, v5, v6 + if AtomicLoadPInt32(uintptr(unsafe.Pointer(&X__stdout_FILE))+140) >= 0 { + v1 = ___lockfile(tls, uintptr(unsafe.Pointer(&X__stdout_FILE))) + } else { + v1 = 0 + } + __need_unlock = v1 + if v6 = Xfputs(tls, s, uintptr(unsafe.Pointer(&X__stdout_FILE))) < 0; !v6 { + if Int32FromUint8(Uint8FromInt32(Int32FromUint8('\n'))) != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Flbf && (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Fwpos != (*TFILE)(unsafe.Pointer(uintptr(unsafe.Pointer(&X__stdout_FILE)))).Fwend { + v3 = Uint8FromInt32(Int32FromUint8('\n')) + v5 = uintptr(unsafe.Pointer(&X__stdout_FILE)) + 40 + v4 = *(*uintptr)(unsafe.Pointer(v5)) + *(*uintptr)(unsafe.Pointer(v5)) = *(*uintptr)(unsafe.Pointer(v5)) + 1 + **(**uint8)(__ccgo_up(v4)) = v3 + v2 = Int32FromUint8(v3) + } else { + v2 = X__overflow(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), Int32FromUint8(Uint8FromInt32(Int32FromUint8('\n')))) + } + } + r = -BoolInt32(v6 || v2 < 0) + if __need_unlock != 0 { + ___unlockfile(tls, uintptr(unsafe.Pointer(&X__stdout_FILE))) + } + return r +} + +func Xputw(tls *TLS, _x int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v _x=%v f=%v, (%v:)", tls, _x, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + *(*int32)(unsafe.Pointer(bp)) = _x + return Int32FromUint64(Xfwrite(tls, bp, uint64(4), uint64(1), f)) - int32(1) +} + +func Xputwc(tls *TLS, c Twchar_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfputwc(tls, c, f) +} + +func Xputwchar(tls *TLS, c Twchar_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfputwc(tls, c, uintptr(unsafe.Pointer(&X__stdout_FILE))) +} + +func Xputwchar_unlocked(tls *TLS, c Twchar_t) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xputwchar(tls, c) +} + +func Xremove(tls *TLS, path uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall3(tls, int64(SYS_unlinkat), int64(-Int32FromInt32(100)), int64(path), int64(Int32FromInt32(0)))) + if r == -int32(EISDIR) { + r = int32(X__syscall3(tls, int64(SYS_unlinkat), int64(-Int32FromInt32(100)), int64(path), int64(Int32FromInt32(AT_REMOVEDIR)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xrename(tls *TLS, old uintptr, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v, (%v:)", tls, old, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_renameat), int64(-Int32FromInt32(100)), int64(old), int64(-Int32FromInt32(100)), int64(new1))))) +} + +func Xrewind(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + var __need_unlock, v1 int32 + _, _ = __need_unlock, v1 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + X__fseeko_unlocked(tls, f, 0, 0) + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_ERR)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } +} + +func Xscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvscanf(tls, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_scanf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xscanf(tls, fmt, va) +} + +func Xsetbuf(tls *TLS, f uintptr, buf uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v, (%v:)", tls, f, buf, origin(2)) + } + var v1 int32 + _ = v1 + if buf != 0 { + v1 = _IOFBF + } else { + v1 = int32(_IONBF) + } + Xsetvbuf(tls, f, buf, v1, uint64(BUFSIZ)) +} + +func Xsetbuffer(tls *TLS, f uintptr, buf uintptr, size Tsize_t) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v size=%v, (%v:)", tls, f, buf, size, origin(2)) + } + var v1 int32 + _ = v1 + if buf != 0 { + v1 = _IOFBF + } else { + v1 = int32(_IONBF) + } + Xsetvbuf(tls, f, buf, v1, size) +} + +func Xsetlinebuf(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + Xsetvbuf(tls, f, uintptr(0), int32(_IOLBF), uint64(0)) +} + +/* The behavior of this function is undefined except when it is the first + * operation on the stream, so the presence or absence of locking is not + * observable in a program whose behavior is defined. Thus no locking is + * performed here. No allocation of buffers is performed, but a buffer + * provided by the caller is used as long as it is suitably sized. */ + +func Xsetvbuf(tls *TLS, f uintptr, buf uintptr, type1 int32, size Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v buf=%v type1=%v size=%v, (%v:)", tls, f, buf, type1, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + (*TFILE)(unsafe.Pointer(f)).Flbf = -int32(1) + if type1 == int32(_IONBF) { + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = uint64(0) + } else { + if type1 == int32(_IOLBF) || type1 == _IOFBF { + if buf != 0 && size >= uint64(UNGET) { + (*TFILE)(unsafe.Pointer(f)).Fbuf = buf + UintptrFromInt32(UNGET) + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = size - uint64(UNGET) + } + if type1 == int32(_IOLBF) && (*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0 { + (*TFILE)(unsafe.Pointer(f)).Flbf = int32('\n') + } + } else { + return -int32(1) + } + } + **(**uint32)(__ccgo_up(f)) |= uint32(F_SVB) + return 0 +} + +func Xsnprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v va=%v, (%v:)", tls, s, n, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvsnprintf(tls, s, n, fmt, ap) + _ = ap + return ret +} + +func Xsprintf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvsprintf(tls, s, fmt, ap) + _ = ap + return ret +} + +func Xsscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvsscanf(tls, s, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_sscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsscanf(tls, s, fmt, va) +} + +var _buf5 [8]uint8 + +func init() { + p := unsafe.Pointer(&X__stderr_FILE) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(X__stdio_close) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(X__stdio_write) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(X__stdio_seek) +} + +var _buf6 [1032]uint8 + +func init() { + p := unsafe.Pointer(&X__stdin_FILE) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(X__stdio_close) + *(*uintptr)(unsafe.Add(p, 64)) = __ccgo_fp(X__stdio_read) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(X__stdio_seek) +} + +var _buf7 [1032]uint8 + +func init() { + p := unsafe.Pointer(&X__stdout_FILE) + *(*uintptr)(unsafe.Add(p, 24)) = __ccgo_fp(X__stdio_close) + *(*uintptr)(unsafe.Add(p, 72)) = __ccgo_fp(X__stdout_write) + *(*uintptr)(unsafe.Add(p, 80)) = __ccgo_fp(X__stdio_seek) +} + +func Xswprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v va=%v, (%v:)", tls, s, n, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvswprintf(tls, s, n, fmt, ap) + _ = ap + return ret +} + +func Xswscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvswscanf(tls, s, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_swscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xswscanf(tls, s, fmt, va) +} + +const MAXTRIES = 100 + +func Xtempnam(tls *TLS, dir uintptr, pfx uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v dir=%v pfx=%v, (%v:)", tls, dir, pfx, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(4112) + defer tls.Free(4112) + var dl, l, pl Tsize_t + var r, try int32 + var _ /* s at bp+1 */ [4096]uint8 + _, _, _, _, _ = dl, l, pl, r, try + if !(dir != 0) { + dir = __ccgo_ts + 1573 + } + if !(pfx != 0) { + pfx = __ccgo_ts + 1578 + } + dl = _strlen(tls, dir) + pl = _strlen(tls, pfx) + l = dl + uint64(1) + pl + uint64(1) + uint64(6) + if l >= uint64(PATH_MAX) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENAMETOOLONG) + return uintptr(0) + } + Xmemcpy(tls, bp+1, dir, dl) + (**(**[4096]uint8)(__ccgo_up(bp + 1)))[dl] = uint8('/') + Xmemcpy(tls, bp+1+uintptr(dl)+uintptr(1), pfx, pl) + (**(**[4096]uint8)(__ccgo_up(bp + 1)))[dl+uint64(1)+pl] = uint8('_') + (**(**[4096]uint8)(__ccgo_up(bp + 1)))[l] = uint8(0) + try = 0 + for { + if !(try < int32(MAXTRIES)) { + break + } + ___randname(tls, bp+1+uintptr(l)-uintptr(6)) + *(*[1]uint8)(unsafe.Pointer(bp)) = [1]uint8{} + r = int32(X__syscall4(tls, int64(SYS_readlinkat), int64(-Int32FromInt32(100)), int64(bp+1), int64(bp), int64(Int32FromInt32(1)))) + if r == -int32(ENOENT) { + return Xstrdup(tls, bp+1) + } + goto _1 + _1: + ; + try = try + 1 + } + return uintptr(0) +} + +func Xtmpfile(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var f uintptr + var fd, try int32 + var _ /* s at bp+0 */ [20]uint8 + _, _, _ = f, fd, try + **(**[20]uint8)(__ccgo_up(bp)) = [20]uint8{'/', 't', 'm', 'p', '/', 't', 'm', 'p', 'f', 'i', 'l', 'e', '_', 'X', 'X', 'X', 'X', 'X', 'X'} + try = 0 + for { + if !(try < int32(MAXTRIES)) { + break + } + ___randname(tls, bp+uintptr(13)) + fd = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_openat), int64(-Int32FromInt32(100)), int64(bp), int64(Int32FromInt32(O_RDWR)|Int32FromInt32(O_CREAT)|Int32FromInt32(O_EXCL)|Int32FromInt32(O_LARGEFILE)), int64(Int32FromInt32(0600)))))) + if fd >= 0 { + X__syscall3(tls, int64(SYS_unlinkat), int64(-Int32FromInt32(100)), int64(bp), int64(Int32FromInt32(0))) + f = X__fdopen(tls, fd, __ccgo_ts+1583) + if !(f != 0) { + X__syscall1(tls, int64(SYS_close), int64(fd)) + } + return f + } + goto _1 + _1: + ; + try = try + 1 + } + return uintptr(0) +} + +func Xtmpnam(tls *TLS, buf uintptr) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v buf=%v, (%v:)", tls, buf, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var r, try int32 + var v2 uintptr + var _ /* s at bp+1 */ [19]uint8 + _, _, _ = r, try, v2 + **(**[19]uint8)(__ccgo_up(bp + 1)) = [19]uint8{'/', 't', 'm', 'p', '/', 't', 'm', 'p', 'n', 'a', 'm', '_', 'X', 'X', 'X', 'X', 'X', 'X'} + try = 0 + for { + if !(try < int32(MAXTRIES)) { + break + } + ___randname(tls, bp+1+uintptr(12)) + *(*[1]uint8)(unsafe.Pointer(bp)) = [1]uint8{} + r = int32(X__syscall4(tls, int64(SYS_readlinkat), int64(-Int32FromInt32(100)), int64(bp+1), int64(bp), int64(Int32FromInt32(1)))) + if r == -int32(ENOENT) { + if buf != 0 { + v2 = buf + } else { + v2 = uintptr(unsafe.Pointer(&_internal1)) + } + return Xstrcpy(tls, v2, bp+1) + } + goto _1 + _1: + ; + try = try + 1 + } + return uintptr(0) +} + +var _internal1 [20]uint8 + +func Xungetc(tls *TLS, c int32, f uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + var __need_unlock, v1 int32 + var v2, v3 uintptr + _, _, _, _ = __need_unlock, v1, v2, v3 + if c == -int32(1) { + return c + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) { + X__toread(tls, f) + } + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) || (*TFILE)(unsafe.Pointer(f)).Frpos <= (*TFILE)(unsafe.Pointer(f)).Fbuf-uintptr(UNGET) { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return -int32(1) + } + v3 = f + 8 + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) - 1 + v2 = *(*uintptr)(unsafe.Pointer(v3)) + **(**uint8)(__ccgo_up(v2)) = Uint8FromInt32(c) + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_EOF)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return Int32FromUint8(Uint8FromInt32(c)) +} + +func Xungetwc(tls *TLS, c Twint_t, f uintptr) (r Twint_t) { + if __ccgo_strace { + trc("tls=%v c=%v f=%v, (%v:)", tls, c, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var __need_unlock, l, v1 int32 + var loc Tlocale_t + var ploc, v4, v5 uintptr + var v3 bool + var _ /* mbc at bp+0 */ [4]uint8 + _, _, _, _, _, _, _, _ = __need_unlock, l, loc, ploc, v1, v3, v4, v5 + ploc = uintptr(___get_tp(tls)) + 152 + loc = **(**Tlocale_t)(__ccgo_up(ploc)) + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if (*TFILE)(unsafe.Pointer(f)).Fmode <= 0 { + Xfwide(tls, f, int32(1)) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = (*TFILE)(unsafe.Pointer(f)).Flocale + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) { + X__toread(tls, f) + } + if v3 = !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) || c == uint32(0xffffffff); !v3 { + v1 = Int32FromUint64(Xwcrtomb(tls, bp, c, uintptr(0))) + l = v1 + } + if v3 || v1 < 0 || (*TFILE)(unsafe.Pointer(f)).Frpos < (*TFILE)(unsafe.Pointer(f)).Fbuf-uintptr(UNGET)+uintptr(l) { + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return uint32(0xffffffff) + } + if BoolInt32(c < uint32(128)) != 0 { + v5 = f + 8 + *(*uintptr)(unsafe.Pointer(v5)) = *(*uintptr)(unsafe.Pointer(v5)) - 1 + v4 = *(*uintptr)(unsafe.Pointer(v5)) + **(**uint8)(__ccgo_up(v4)) = uint8(c) + } else { + v4 = f + 8 + *(*uintptr)(unsafe.Pointer(v4)) -= uintptr(l) + Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(v4)), bp, Uint64FromInt32(l)) + } + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_EOF)) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + **(**Tlocale_t)(__ccgo_up(ploc)) = loc + return c +} + +func Xvasprintf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap2 Tva_list + var l int32 + var v1 uintptr + var v2 bool + _, _, _, _ = ap2, l, v1, v2 + ap2 = ap + l = Xvsnprintf(tls, uintptr(0), uint64(0), fmt, ap2) + _ = ap2 + if v2 = l < 0; !v2 { + v1 = Xmalloc(tls, uint64(Uint32FromInt32(l)+uint32(1))) + **(**uintptr)(__ccgo_up(s)) = v1 + } + if v2 || !(v1 != 0) { + return -int32(1) + } + return Xvsnprintf(tls, **(**uintptr)(__ccgo_up(s)), uint64(Uint32FromInt32(l)+uint32(1)), fmt, ap) +} + +func Xvdprintf(tls *TLS, fd int32, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v fmt=%v ap=%v, (%v:)", tls, fd, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(240) + defer tls.Free(240) + var _ /* f at bp+0 */ TFILE + **(**TFILE)(__ccgo_up(bp)) = TFILE{ + Fwrite: __ccgo_fp(X__stdio_write), + Fbuf: fmt, + Ffd: fd, + Flock: -int32(1), + Flbf: -int32(1), + } + return Xvfprintf(tls, bp, fmt, ap) +} + +const ALT_FORM = 8 +const FLAGMASK = 75913 +const GROUPED = 128 +const LDBL_EPSILON3 = 2.22044604925031308085e-16 +const LEFT_ADJ = 8192 +const MARK_POS = 2048 +const PAD_POS = 1 +const ZERO_PAD = 65536 + +const _BARE = 0 +const _LPRE = 1 +const _LLPRE = 2 +const _HPRE = 3 +const _HHPRE = 4 +const _BIGLPRE = 5 +const _ZTPRE = 6 +const _JPRE = 7 +const _STOP = 8 +const _PTR = 9 +const _INT = 10 +const _UINT = 11 +const _ULLONG = 12 +const _LONG = 13 +const _ULONG = 14 +const _SHORT = 15 +const _USHORT = 16 +const _CHAR = 17 +const _UCHAR = 18 +const _LLONG = 19 +const _SIZET = 20 +const _IMAX = 21 +const _UMAX = 22 +const _PDIFF = 23 +const _UIPTR = 24 +const _DBL = 25 +const _LDBL = 26 +const _NOARG = 27 +const _MAXSTATE = 28 + +var _states = [8][58]uint8{ + 0: { + 0: uint8(_DBL), + 2: uint8(_UINT), + 4: uint8(_DBL), + 5: uint8(_DBL), + 6: uint8(_DBL), + 11: uint8(_BIGLPRE), + 18: uint8(_PTR), + 23: uint8(_UINT), + 32: uint8(_DBL), + 34: uint8(_INT), + 35: uint8(_INT), + 36: uint8(_DBL), + 37: uint8(_DBL), + 38: uint8(_DBL), + 39: uint8(_HPRE), + 40: uint8(_INT), + 41: uint8(_JPRE), + 43: uint8(_LPRE), + 44: uint8(_NOARG), + 45: uint8(_PTR), + 46: uint8(_UINT), + 47: uint8(_UIPTR), + 50: uint8(_PTR), + 51: uint8(_ZTPRE), + 52: uint8(_UINT), + 55: uint8(_UINT), + 57: uint8(_ZTPRE), + }, + 1: { + 0: uint8(_DBL), + 4: uint8(_DBL), + 5: uint8(_DBL), + 6: uint8(_DBL), + 23: uint8(_ULONG), + 32: uint8(_DBL), + 34: uint8(_UINT), + 35: uint8(_LONG), + 36: uint8(_DBL), + 37: uint8(_DBL), + 38: uint8(_DBL), + 40: uint8(_LONG), + 43: uint8(_LLPRE), + 45: uint8(_PTR), + 46: uint8(_ULONG), + 50: uint8(_PTR), + 52: uint8(_ULONG), + 55: uint8(_ULONG), + }, + 2: { + 23: uint8(_ULLONG), + 35: uint8(_LLONG), + 40: uint8(_LLONG), + 45: uint8(_PTR), + 46: uint8(_ULLONG), + 52: uint8(_ULLONG), + 55: uint8(_ULLONG), + }, + 3: { + 23: uint8(_USHORT), + 35: uint8(_SHORT), + 39: uint8(_HHPRE), + 40: uint8(_SHORT), + 45: uint8(_PTR), + 46: uint8(_USHORT), + 52: uint8(_USHORT), + 55: uint8(_USHORT), + }, + 4: { + 23: uint8(_UCHAR), + 35: uint8(_CHAR), + 40: uint8(_CHAR), + 45: uint8(_PTR), + 46: uint8(_UCHAR), + 52: uint8(_UCHAR), + 55: uint8(_UCHAR), + }, + 5: { + 0: uint8(_LDBL), + 4: uint8(_LDBL), + 5: uint8(_LDBL), + 6: uint8(_LDBL), + 32: uint8(_LDBL), + 36: uint8(_LDBL), + 37: uint8(_LDBL), + 38: uint8(_LDBL), + 45: uint8(_PTR), + }, + 6: { + 23: uint8(_SIZET), + 35: uint8(_PDIFF), + 40: uint8(_PDIFF), + 45: uint8(_PTR), + 46: uint8(_SIZET), + 52: uint8(_SIZET), + 55: uint8(_SIZET), + }, + 7: { + 23: uint8(_UMAX), + 35: uint8(_IMAX), + 40: uint8(_IMAX), + 45: uint8(_PTR), + 46: uint8(_UMAX), + 52: uint8(_UMAX), + 55: uint8(_UMAX), + }, +} + +type Targ = struct { + Ff [0]float64 + Fp [0]uintptr + Fi Tuintmax_t +} + +func _pop_arg(tls *TLS, arg uintptr, type1 int32, ap uintptr) { + switch type1 { + case int32(_PTR): + *(*uintptr)(unsafe.Pointer(arg)) = VaUintptr(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_INT): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UINT): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUint32(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_LONG): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_ULONG): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_ULLONG): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUint64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_SHORT): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt16(int16(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_USHORT): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(Uint16FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_CHAR): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt8(int8(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_UCHAR): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(Uint8FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_LLONG): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_SIZET): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_IMAX): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UMAX): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_PDIFF): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UIPTR): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUintptr(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_DBL): + *(*float64)(unsafe.Pointer(arg)) = float64(VaFloat64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_LDBL): + *(*float64)(unsafe.Pointer(arg)) = VaFloat64(&**(**Tva_list)(__ccgo_up(ap))) + } +} + +func _out(tls *TLS, f uintptr, s uintptr, l Tsize_t) { + if !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_ERR) != 0) { + X__fwritex(tls, s, l, f) + } +} + +func _pad3(tls *TLS, f uintptr, c uint8, w int32, l int32, fl int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var v1 uint64 + var _ /* pad at bp+0 */ [256]uint8 + _ = v1 + if Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' '))) != 0 || l >= w { + return + } + l = w - l + if Uint64FromInt32(l) > uint64(256) { + v1 = uint64(256) + } else { + v1 = Uint64FromInt32(l) + } + Xmemset(tls, bp, Int32FromUint8(c), v1) + for { + if !(Uint64FromInt32(l) >= uint64(256)) { + break + } + _out(tls, f, bp, uint64(256)) + goto _2 + _2: + ; + l = Int32FromUint64(uint64(l) - Uint64FromInt64(256)) + } + _out(tls, f, bp, Uint64FromInt32(l)) +} + +var _xdigits1 = [16]uint8{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'} + +func _fmt_x(tls *TLS, x Tuintmax_t, s uintptr, lower int32) (r uintptr) { + var v2 uintptr + _ = v2 + for { + if !(x != 0) { + break + } + s = s - 1 + v2 = s + **(**uint8)(__ccgo_up(v2)) = Uint8FromInt32(Int32FromUint8(_xdigits1[x&uint64(15)]) | lower) + goto _1 + _1: + ; + x = x >> uint64(4) + } + return s +} + +func _fmt_o(tls *TLS, x Tuintmax_t, s uintptr) (r uintptr) { + var v2 uintptr + _ = v2 + for { + if !(x != 0) { + break + } + s = s - 1 + v2 = s + **(**uint8)(__ccgo_up(v2)) = uint8(uint64('0') + x&uint64(7)) + goto _1 + _1: + ; + x = x >> uint64(3) + } + return s +} + +func _fmt_u(tls *TLS, x Tuintmax_t, s uintptr) (r uintptr) { + var y uint64 + var v2 uintptr + _, _ = y, v2 + for { + if !(x > Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)) { + break + } + s = s - 1 + v2 = s + **(**uint8)(__ccgo_up(v2)) = uint8(uint64('0') + x%uint64(10)) + goto _1 + _1: + ; + x = x / uint64(10) + } + y = x + for { + if !(y != 0) { + break + } + s = s - 1 + v2 = s + **(**uint8)(__ccgo_up(v2)) = uint8(uint64('0') + y%uint64(10)) + goto _3 + _3: + ; + y = y / uint64(10) + } + return s +} + +// C documentation +// +// /* Do not override this check. The floating point printing code below +// * depends on the float.h constants being right. If they are wrong, it +// * may overflow the stack. */ +type Tcompiler_defines_long_double_incorrectly = [1]uint8 + +func _fmt_fp(tls *TLS, f uintptr, y float64, w int32, p int32, fl int32, t int32) (r1 int32) { + bp := tls.Alloc(560) + defer tls.Free(560) + var a, b, d, ebuf, estr, prefix, r, s, s1, s2, s3, s4, z, v5, v6 uintptr + var carry, carry1, rm, x2 Tuint32_t + var e, i, j, l, need, pl, re, sh, sh1, x, v7 int32 + var round, round1, small float64 + var x1 Tuint64_t + var v1 uint64 + var v36, v37, v38 int64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* big at bp+8 */ [126]Tuint32_t + var _ /* buf at bp+516 */ [22]uint8 + var _ /* e2 at bp+512 */ int32 + var _ /* ebuf0 at bp+538 */ [12]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, b, carry, carry1, d, e, ebuf, estr, i, j, l, need, pl, prefix, r, re, rm, round, round1, s, s1, s2, s3, s4, sh, sh1, small, x, x1, x2, z, v1, v36, v37, v38, v5, v6, v7 + **(**int32)(__ccgo_up(bp + 512)) = 0 + prefix = __ccgo_ts + 1586 + ebuf = bp + 538 + uintptr(Uint64FromInt32(3)*Uint64FromInt64(4)) + pl = int32(1) + *(*float64)(unsafe.Pointer(bp)) = y + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if Int32FromUint64(v1>>Int32FromInt32(63)) != 0 { + y = -y + } else { + if Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))) != 0 { + prefix = prefix + uintptr(3) + } else { + if Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))) != 0 { + prefix = prefix + uintptr(6) + } else { + prefix = prefix + 1 + pl = Int32FromInt32(0) + } + } + } + *(*float64)(unsafe.Pointer(bp)) = y + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _4 +_4: + if !(BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) < Uint64FromUint64(0x7ff)< int32(3)+pl { + v7 = w + } else { + v7 = int32(3) + pl + } + return v7 + } + y = float64(Xfrexpl(tls, y, bp+512) * Float64FromInt32(2)) + if y != 0 { + **(**int32)(__ccgo_up(bp + 512)) = **(**int32)(__ccgo_up(bp + 512)) - 1 + } + if t|int32(32) == int32('a') { + round = Float64FromFloat64(8) + if t&int32(32) != 0 { + prefix = prefix + uintptr(9) + } + pl = pl + int32(2) + if p < 0 || p >= Int32FromInt32(LDBL_MANT_DIG)/Int32FromInt32(4)-Int32FromInt32(1) { + re = 0 + } else { + re = Int32FromInt32(LDBL_MANT_DIG)/Int32FromInt32(4) - Int32FromInt32(1) - p + } + if re != 0 { + round = round * float64(Int32FromInt32(1)<<(Int32FromInt32(LDBL_MANT_DIG)%Int32FromInt32(4))) + for { + v7 = re + re = re - 1 + if !(v7 != 0) { + break + } + round = round * Float64FromInt32(16) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(prefix))) == int32('-') { + y = -y + y = y - round + y = y + round + y = -y + } else { + y = y + round + y = y - round + } + } + if **(**int32)(__ccgo_up(bp + 512)) < 0 { + v7 = -**(**int32)(__ccgo_up(bp + 512)) + } else { + v7 = **(**int32)(__ccgo_up(bp + 512)) + } + estr = _fmt_u(tls, Uint64FromInt32(v7), ebuf) + if estr == ebuf { + estr = estr - 1 + v5 = estr + **(**uint8)(__ccgo_up(v5)) = uint8('0') + } + estr = estr - 1 + v5 = estr + if **(**int32)(__ccgo_up(bp + 512)) < 0 { + v7 = int32('-') + } else { + v7 = int32('+') + } + **(**uint8)(__ccgo_up(v5)) = Uint8FromInt32(v7) + estr = estr - 1 + v5 = estr + **(**uint8)(__ccgo_up(v5)) = Uint8FromInt32(t + (Int32FromUint8('p') - Int32FromUint8('a'))) + s = bp + 516 + for cond := true; cond; cond = y != 0 { + x = int32(y) + v5 = s + s = s + 1 + **(**uint8)(__ccgo_up(v5)) = Uint8FromInt32(Int32FromUint8(_xdigits1[x]) | t&int32(32)) + y = float64(Float64FromInt32(16) * (y - float64(x))) + if int64(s)-t__predefined_ptrdiff_t(bp+516) == int64(1) && (y != 0 || p > 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0) { + v5 = s + s = s + 1 + **(**uint8)(__ccgo_up(v5)) = uint8('.') + } + } + if int64(p) > int64(Int32FromInt32(INT_MAX)-Int32FromInt32(2))-(int64(ebuf)-int64(estr))-int64(pl) { + return -int32(1) + } + if p != 0 && int64(s)-t__predefined_ptrdiff_t(bp+516)-int64(2) < int64(p) { + l = int32(int64(p+Int32FromInt32(2)) + (int64(ebuf) - int64(estr))) + } else { + l = int32(int64(s) - t__predefined_ptrdiff_t(bp+516) + (int64(ebuf) - int64(estr))) + } + _pad3(tls, f, uint8(' '), w, pl+l, fl) + _out(tls, f, prefix, Uint64FromInt32(pl)) + _pad3(tls, f, uint8('0'), w, pl+l, Int32FromUint32(Uint32FromInt32(fl)^Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' ')))) + _out(tls, f, bp+516, Uint64FromInt64(int64(s)-t__predefined_ptrdiff_t(bp+516))) + _pad3(tls, f, uint8('0'), int32(int64(l)-(int64(ebuf)-int64(estr))-(int64(s)-t__predefined_ptrdiff_t(bp+516))), 0, 0) + _out(tls, f, estr, Uint64FromInt64(int64(ebuf)-int64(estr))) + _pad3(tls, f, uint8(' '), w, pl+l, Int32FromUint32(Uint32FromInt32(fl)^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + if w > pl+l { + v7 = w + } else { + v7 = pl + l + } + return v7 + } + if p < 0 { + p = int32(6) + } + if y != 0 { + y = y * Float64FromFloat64(2.68435456e+08) + **(**int32)(__ccgo_up(bp + 512)) = **(**int32)(__ccgo_up(bp + 512)) - int32(28) + } + if **(**int32)(__ccgo_up(bp + 512)) < 0 { + v6 = bp + 8 + z = v6 + v5 = v6 + r = v5 + a = v5 + } else { + v6 = bp + 8 + uintptr(Uint64FromInt64(504)/Uint64FromInt64(4))*4 - UintptrFromInt32(LDBL_MANT_DIG)*4 - UintptrFromInt32(1)*4 + z = v6 + v5 = v6 + r = v5 + a = v5 + } + for cond := true; cond; cond = y != 0 { + **(**Tuint32_t)(__ccgo_up(z)) = uint32(y) + v5 = z + z += 4 + y = float64(Float64FromInt32(1000000000) * (y - float64(**(**Tuint32_t)(__ccgo_up(v5))))) + } + for **(**int32)(__ccgo_up(bp + 512)) > 0 { + carry = uint32(0) + if int32(29) < **(**int32)(__ccgo_up(bp + 512)) { + v7 = int32(29) + } else { + v7 = **(**int32)(__ccgo_up(bp + 512)) + } + sh = v7 + d = z - uintptr(1)*4 + for { + if !(d >= a) { + break + } + x1 = uint64(**(**Tuint32_t)(__ccgo_up(d)))< a && !(**(**Tuint32_t)(__ccgo_up(z + uintptr(-Int32FromInt32(1))*4)) != 0) { + z -= 4 + } + **(**int32)(__ccgo_up(bp + 512)) = **(**int32)(__ccgo_up(bp + 512)) - sh + } + for **(**int32)(__ccgo_up(bp + 512)) < 0 { + carry1 = uint32(0) + if int32(9) < -**(**int32)(__ccgo_up(bp + 512)) { + v7 = int32(9) + } else { + v7 = -**(**int32)(__ccgo_up(bp + 512)) + } + sh1 = v7 + need = Int32FromUint32(uint32(1) + (Uint32FromInt32(p)+Uint32FromInt32(LDBL_MANT_DIG)/Uint32FromUint32(3)+uint32(8))/uint32(9)) + d = a + for { + if !(d < z) { + break + } + rm = **(**Tuint32_t)(__ccgo_up(d)) & Uint32FromInt32(int32(1)<>sh1 + carry1 + carry1 = Uint32FromInt32(Int32FromInt32(1000000000)>>sh1) * rm + goto _26 + _26: + ; + d += 4 + } + if !(**(**Tuint32_t)(__ccgo_up(a)) != 0) { + a += 4 + } + if carry1 != 0 { + v5 = z + z += 4 + **(**Tuint32_t)(__ccgo_up(v5)) = carry1 + } + /* Avoid (slow!) computation past requested precision */ + if t|int32(32) == int32('f') { + v5 = r + } else { + v5 = a + } + b = v5 + if (int64(z)-int64(b))/4 > int64(need) { + z = b + uintptr(need)*4 + } + **(**int32)(__ccgo_up(bp + 512)) = **(**int32)(__ccgo_up(bp + 512)) + sh1 + } + if a < z { + i = int32(10) + e = int32(Int64FromInt32(9) * ((int64(r) - int64(a)) / 4)) + for { + if !(**(**Tuint32_t)(__ccgo_up(a)) >= Uint32FromInt32(i)) { + break + } + goto _29 + _29: + ; + i = i * int32(10) + e = e + 1 + } + } else { + e = 0 + } + /* Perform rounding: j is precision after the radix (possibly neg) */ + j = p - BoolInt32(t|int32(32) != int32('f'))*e - BoolInt32(t|int32(32) == int32('g') && p != 0) + if int64(j) < int64(9)*((int64(z)-int64(r))/4-int64(1)) { + /* We avoid C's broken division of negative numbers */ + d = r + uintptr(1)*4 + uintptr((j+Int32FromInt32(9)*Int32FromInt32(LDBL_MAX_EXP))/Int32FromInt32(9)-Int32FromInt32(LDBL_MAX_EXP))*4 + j = j + Int32FromInt32(9)*Int32FromInt32(LDBL_MAX_EXP) + j = j % int32(9) + i = int32(10) + j = j + 1 + for { + if !(j < int32(9)) { + break + } + goto _30 + _30: + ; + i = i * int32(10) + j = j + 1 + } + x2 = **(**Tuint32_t)(__ccgo_up(d)) % Uint32FromInt32(i) + /* Are there any significant digits past j? */ + if x2 != 0 || d+uintptr(1)*4 != z { + round1 = Float64FromInt32(2) / Float64FromFloat64(2.22044604925031308085e-16) + if **(**Tuint32_t)(__ccgo_up(d))/Uint32FromInt32(i)&uint32(1) != 0 || i == int32(1000000000) && d > a && **(**Tuint32_t)(__ccgo_up(d + uintptr(-Int32FromInt32(1))*4))&uint32(1) != 0 { + round1 = round1 + Float64FromInt32(2) + } + if x2 < Uint32FromInt32(i/int32(2)) { + small = Float64FromFloat64(0.5) + } else { + if x2 == Uint32FromInt32(i/int32(2)) && d+uintptr(1)*4 == z { + small = Float64FromFloat64(1) + } else { + small = Float64FromFloat64(1.5) + } + } + if pl != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(prefix))) == int32('-') { + round1 = round1 * float64(-Int32FromInt32(1)) + small = small * float64(-Int32FromInt32(1)) + } + **(**Tuint32_t)(__ccgo_up(d)) -= x2 + /* Decide whether to round by probing round+small */ + if round1+small != round1 { + **(**Tuint32_t)(__ccgo_up(d)) = **(**Tuint32_t)(__ccgo_up(d)) + Uint32FromInt32(i) + for **(**Tuint32_t)(__ccgo_up(d)) > uint32(999999999) { + v5 = d + d -= 4 + **(**Tuint32_t)(__ccgo_up(v5)) = uint32(0) + if d < a { + a -= 4 + v5 = a + **(**Tuint32_t)(__ccgo_up(v5)) = uint32(0) + } + **(**Tuint32_t)(__ccgo_up(d)) = **(**Tuint32_t)(__ccgo_up(d)) + 1 + } + i = int32(10) + e = int32(Int64FromInt32(9) * ((int64(r) - int64(a)) / 4)) + for { + if !(**(**Tuint32_t)(__ccgo_up(a)) >= Uint32FromInt32(i)) { + break + } + goto _33 + _33: + ; + i = i * int32(10) + e = e + 1 + } + } + } + if z > d+uintptr(1)*4 { + z = d + uintptr(1)*4 + } + } + for { + if !(z > a && !(**(**Tuint32_t)(__ccgo_up(z + uintptr(-Int32FromInt32(1))*4)) != 0)) { + break + } + goto _34 + _34: + ; + z -= 4 + } + if t|int32(32) == int32('g') { + if !(p != 0) { + p = p + 1 + } + if p > e && e >= -int32(4) { + t = t - 1 + p = p - (e + int32(1)) + } else { + t = t - int32(2) + p = p - 1 + } + if !(Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0) { + /* Count trailing zeros in last place */ + if z > a && **(**Tuint32_t)(__ccgo_up(z + uintptr(-Int32FromInt32(1))*4)) != 0 { + i = int32(10) + j = Int32FromInt32(0) + for { + if !(**(**Tuint32_t)(__ccgo_up(z + uintptr(-Int32FromInt32(1))*4))%Uint32FromInt32(i) == uint32(0)) { + break + } + goto _35 + _35: + ; + i = i * int32(10) + j = j + 1 + } + } else { + j = int32(9) + } + if t|int32(32) == int32('f') { + if int64(Int32FromInt32(0)) > int64(9)*((int64(z)-int64(r))/4-int64(1))-int64(j) { + v37 = int64(Int32FromInt32(0)) + } else { + v37 = int64(9)*((int64(z)-int64(r))/4-int64(1)) - int64(j) + } + if int64(p) < v37 { + v36 = int64(p) + } else { + if int64(Int32FromInt32(0)) > int64(9)*((int64(z)-int64(r))/4-int64(1))-int64(j) { + v38 = int64(Int32FromInt32(0)) + } else { + v38 = int64(9)*((int64(z)-int64(r))/4-int64(1)) - int64(j) + } + v36 = v38 + } + p = int32(v36) + } else { + if int64(Int32FromInt32(0)) > int64(9)*((int64(z)-int64(r))/4-int64(1))+int64(e)-int64(j) { + v37 = int64(Int32FromInt32(0)) + } else { + v37 = int64(9)*((int64(z)-int64(r))/4-int64(1)) + int64(e) - int64(j) + } + if int64(p) < v37 { + v36 = int64(p) + } else { + if int64(Int32FromInt32(0)) > int64(9)*((int64(z)-int64(r))/4-int64(1))+int64(e)-int64(j) { + v38 = int64(Int32FromInt32(0)) + } else { + v38 = int64(9)*((int64(z)-int64(r))/4-int64(1)) + int64(e) - int64(j) + } + v36 = v38 + } + p = int32(v36) + } + } + } + if p > Int32FromInt32(INT_MAX)-Int32FromInt32(1)-BoolInt32(p != 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0) { + return -int32(1) + } + l = int32(1) + p + BoolInt32(p != 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0) + if t|int32(32) == int32('f') { + if e > int32(INT_MAX)-l { + return -int32(1) + } + if e > 0 { + l = l + e + } + } else { + if e < 0 { + v7 = -e + } else { + v7 = e + } + estr = _fmt_u(tls, Uint64FromInt32(v7), ebuf) + for int64(ebuf)-int64(estr) < int64(2) { + estr = estr - 1 + v5 = estr + **(**uint8)(__ccgo_up(v5)) = uint8('0') + } + estr = estr - 1 + v5 = estr + if e < 0 { + v7 = int32('-') + } else { + v7 = int32('+') + } + **(**uint8)(__ccgo_up(v5)) = Uint8FromInt32(v7) + estr = estr - 1 + v5 = estr + **(**uint8)(__ccgo_up(v5)) = Uint8FromInt32(t) + if int64(ebuf)-int64(estr) > int64(int32(INT_MAX)-l) { + return -int32(1) + } + l = int32(int64(l) + (int64(ebuf) - int64(estr))) + } + if l > int32(INT_MAX)-pl { + return -int32(1) + } + _pad3(tls, f, uint8(' '), w, pl+l, fl) + _out(tls, f, prefix, Uint64FromInt32(pl)) + _pad3(tls, f, uint8('0'), w, pl+l, Int32FromUint32(Uint32FromInt32(fl)^Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' ')))) + if t|int32(32) == int32('f') { + if a > r { + a = r + } + d = a + for { + if !(d <= r) { + break + } + s2 = _fmt_u(tls, uint64(**(**Tuint32_t)(__ccgo_up(d))), bp+516+uintptr(9)) + if d != a { + for s2 > bp+516 { + s2 = s2 - 1 + v5 = s2 + **(**uint8)(__ccgo_up(v5)) = uint8('0') + } + } else { + if s2 == bp+516+uintptr(9) { + s2 = s2 - 1 + v5 = s2 + **(**uint8)(__ccgo_up(v5)) = uint8('0') + } + } + _out(tls, f, s2, Uint64FromInt64(int64(bp+516+uintptr(9))-int64(s2))) + goto _47 + _47: + ; + d += 4 + } + if p != 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0 { + _out(tls, f, __ccgo_ts+558, uint64(1)) + } + for { + if !(d < z && p > 0) { + break + } + s3 = _fmt_u(tls, uint64(**(**Tuint32_t)(__ccgo_up(d))), bp+516+uintptr(9)) + for s3 > bp+516 { + s3 = s3 - 1 + v5 = s3 + **(**uint8)(__ccgo_up(v5)) = uint8('0') + } + if int32(9) < p { + v7 = int32(9) + } else { + v7 = p + } + _out(tls, f, s3, Uint64FromInt32(v7)) + goto _50 + _50: + ; + d += 4 + p = p - int32(9) + } + _pad3(tls, f, uint8('0'), p+int32(9), int32(9), 0) + } else { + if z <= a { + z = a + uintptr(1)*4 + } + d = a + for { + if !(d < z && p >= 0) { + break + } + s4 = _fmt_u(tls, uint64(**(**Tuint32_t)(__ccgo_up(d))), bp+516+uintptr(9)) + if s4 == bp+516+uintptr(9) { + s4 = s4 - 1 + v5 = s4 + **(**uint8)(__ccgo_up(v5)) = uint8('0') + } + if d != a { + for s4 > bp+516 { + s4 = s4 - 1 + v5 = s4 + **(**uint8)(__ccgo_up(v5)) = uint8('0') + } + } else { + v5 = s4 + s4 = s4 + 1 + _out(tls, f, v5, uint64(1)) + if p > 0 || Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0 { + _out(tls, f, __ccgo_ts+558, uint64(1)) + } + } + if int64(bp+516+UintptrFromInt32(9))-int64(s4) < int64(p) { + v36 = int64(bp+516+UintptrFromInt32(9)) - int64(s4) + } else { + v36 = int64(p) + } + _out(tls, f, s4, Uint64FromInt64(v36)) + p = int32(int64(p) - (int64(bp+516+UintptrFromInt32(9)) - int64(s4))) + goto _53 + _53: + ; + d += 4 + } + _pad3(tls, f, uint8('0'), p+int32(18), int32(18), 0) + _out(tls, f, estr, Uint64FromInt64(int64(ebuf)-int64(estr))) + } + _pad3(tls, f, uint8(' '), w, pl+l, Int32FromUint32(Uint32FromInt32(fl)^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + if w > pl+l { + v7 = w + } else { + v7 = pl + l + } + return v7 +} + +func _getint(tls *TLS, s uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-uint32('0') < uint32(10)) != 0) { + break + } + if Uint32FromInt32(i) > Uint32FromInt32(INT_MAX)/Uint32FromUint32(10) || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))))-int32('0') > int32(INT_MAX)-int32(10)*i { + i = -int32(1) + } else { + i = int32(10)*i + (Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(s))))) - int32('0')) + } + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(s)) = **(**uintptr)(__ccgo_up(s)) + 1 + } + return i +} + +func _printf_core(tls *TLS, f uintptr, fmt uintptr, ap uintptr, nl_arg uintptr, nl_type uintptr) (r int32) { + bp := tls.Alloc(64) + defer tls.Free(64) + var a, prefix, ws, z, v8 uintptr + var argpos, cnt, l, p, pl, t, w, xp, v5, v6 int32 + var fl, l10n, ps, st uint32 + var i Tsize_t + var v31 uint64 + var v34 int64 + var v45 bool + var _ /* arg at bp+8 */ Targ + var _ /* buf at bp+16 */ [24]uint8 + var _ /* mb at bp+48 */ [4]uint8 + var _ /* s at bp+0 */ uintptr + var _ /* wc at bp+40 */ [2]Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, argpos, cnt, fl, i, l, l10n, p, pl, prefix, ps, st, t, w, ws, xp, z, v31, v34, v45, v5, v6, v8 + **(**uintptr)(__ccgo_up(bp)) = fmt + l10n = uint32(0) + cnt = 0 + l = 0 + for { + /* This error is only specified for snprintf, but since it's + * unspecified for other forms, do the same. Stop immediately + * on overflow; otherwise %n could produce wrong results. */ + if l > int32(INT_MAX)-cnt { + goto overflow + } + /* Update output count, end loop when fmt is exhausted */ + cnt = cnt + l + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0) { + break + } + /* Handle literal text and %% format specifiers */ + a = **(**uintptr)(__ccgo_up(bp)) + for { + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) != int32('%')) { + break + } + goto _2 + _2: + ; + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + z = **(**uintptr)(__ccgo_up(bp)) + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32('%') && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1))) == int32('%')) { + break + } + goto _3 + _3: + ; + z = z + 1 + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(2) + } + if int64(z)-int64(a) > int64(int32(INT_MAX)-cnt) { + goto overflow + } + l = int32(int64(z) - int64(a)) + if f != 0 { + _out(tls, f, a, Uint64FromInt32(l)) + } + if l != 0 { + goto _1 + } + if BoolInt32(uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1)))-uint32('0') < uint32(10)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2))) == int32('$') { + l10n = uint32(1) + argpos = Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1))) - int32('0') + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(3) + } else { + argpos = -int32(1) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + /* Read modifier flags */ + fl = uint32(0) + for { + if !(uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))))-uint32(' ') < uint32(32) && (Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('\'')-Int32FromUint8(' ')))&(uint32(1)<<(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))))-int32(' '))) != 0) { + break + } + fl = fl | uint32(1)<<(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))))-int32(' ')) + goto _4 + _4: + ; + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } + /* Read field width */ + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32('*') { + if BoolInt32(uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1)))-uint32('0') < uint32(10)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2))) == int32('$') { + l10n = uint32(1) + if !(f != 0) { + **(**int32)(__ccgo_up(nl_type + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1)))-int32('0'))*4)) = int32(_INT) + w = Int32FromInt32(0) + } else { + w = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(nl_arg + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1)))-int32('0'))*8))) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(3) + } else { + if !(l10n != 0) { + if f != 0 { + v5 = VaInt32(&**(**Tva_list)(__ccgo_up(ap))) + } else { + v5 = 0 + } + w = v5 + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + } else { + goto inval + } + } + if w < 0 { + fl = fl | Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')) + w = -w + } + } else { + v5 = _getint(tls, bp) + w = v5 + if v5 < 0 { + goto overflow + } + } + /* Read precision */ + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32('.') && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 1))) == int32('*') { + if BoolInt32(uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2)))-uint32('0') < uint32(10)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 3))) == int32('$') { + if !(f != 0) { + **(**int32)(__ccgo_up(nl_type + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2)))-int32('0'))*4)) = int32(_INT) + p = Int32FromInt32(0) + } else { + p = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(nl_arg + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + 2)))-int32('0'))*8))) + } + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(4) + } else { + if !(l10n != 0) { + if f != 0 { + v5 = VaInt32(&**(**Tva_list)(__ccgo_up(ap))) + } else { + v5 = 0 + } + p = v5 + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + uintptr(2) + } else { + goto inval + } + } + xp = BoolInt32(p >= 0) + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp))))) == int32('.') { + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + p = _getint(tls, bp) + xp = int32(1) + } else { + p = -int32(1) + xp = 0 + } + } + /* Format specifier state machine */ + st = uint32(0) + for cond := true; cond; cond = st-uint32(1) < uint32(_STOP) { + if uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)))))-uint32('A') > Uint32FromInt32(Int32FromUint8('z')-Int32FromUint8('A')) { + goto inval + } + ps = st + v8 = **(**uintptr)(__ccgo_up(bp)) + **(**uintptr)(__ccgo_up(bp)) = **(**uintptr)(__ccgo_up(bp)) + 1 + st = uint32(**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_states)) + uintptr(st)*58 + uintptr(Int32FromUint8(**(**uint8)(__ccgo_up(v8)))-int32('A'))))) + } + if !(st != 0) { + goto inval + } + /* Check validity of argument type (nl/normal) */ + if st == uint32(_NOARG) { + if argpos >= 0 { + goto inval + } + } else { + if argpos >= 0 { + if !(f != 0) { + **(**int32)(__ccgo_up(nl_type + uintptr(argpos)*4)) = Int32FromUint32(st) + } else { + **(**Targ)(__ccgo_up(bp + 8)) = **(**Targ)(__ccgo_up(nl_arg + uintptr(argpos)*8)) + } + } else { + if f != 0 { + _pop_arg(tls, bp+8, Int32FromUint32(st), ap) + } else { + return 0 + } + } + } + if !(f != 0) { + goto _1 + } + /* Do not process any new directives once in error state. */ + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + return -int32(1) + } + z = bp + 16 + uintptr(24) + prefix = __ccgo_ts + 1617 + pl = 0 + t = Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp)) + uintptr(-Int32FromInt32(1))))) + /* Transform ls,lc -> S,C */ + if ps != 0 && t&int32(15) == int32(3) { + t = t & ^Int32FromInt32(32) + } + /* - and 0 flags are mutually exclusive */ + if fl&(Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))) != 0 { + fl = fl & ^(Uint32FromUint32(1) << (Int32FromUint8('0') - Int32FromUint8(' '))) + } + switch t { + case int32('n'): + goto _9 + case int32('p'): + goto _10 + case int32('X'): + goto _11 + case int32('x'): + goto _12 + case int32('o'): + goto _13 + case int32('i'): + goto _14 + case int32('d'): + goto _15 + case int32('u'): + goto _16 + case int32('c'): + goto _17 + case int32('s'): + goto _18 + case int32('m'): + goto _19 + case int32('C'): + goto _20 + case int32('S'): + goto _21 + case int32('A'): + goto _22 + case int32('G'): + goto _23 + case int32('F'): + goto _24 + case int32('E'): + goto _25 + case int32('a'): + goto _26 + case int32('g'): + goto _27 + case int32('f'): + goto _28 + case int32('e'): + goto _29 + } + goto _30 + _9: + ; + switch ps { + case uint32(_BARE): + **(**int32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = cnt + case uint32(_LPRE): + **(**int64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = int64(cnt) + case uint32(_LLPRE): + **(**int64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = int64(cnt) + case uint32(_HPRE): + **(**uint16)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = Uint16FromInt32(cnt) + case uint32(_HHPRE): + **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = Uint8FromInt32(cnt) + case uint32(_ZTPRE): + **(**Tsize_t)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = Uint64FromInt32(cnt) + case uint32(_JPRE): + **(**Tuintmax_t)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 8)))) = Uint64FromInt32(cnt) + break + } + goto _1 + _10: + ; + if Uint64FromInt32(p) > Uint64FromInt32(2)*Uint64FromInt64(8) { + v31 = Uint64FromInt32(p) + } else { + v31 = Uint64FromInt32(2) * Uint64FromInt64(8) + } + p = Int32FromUint64(v31) + t = int32('x') + fl = fl | Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' ')) + _12: + ; + _11: + ; + a = _fmt_x(tls, *(*Tuintmax_t)(unsafe.Pointer(bp + 8)), z, t&int32(32)) + if *(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0 && fl&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0 { + prefix = prefix + uintptr(t>>Int32FromInt32(4)) + pl = Int32FromInt32(2) + } + if !(0 != 0) { + goto _32 + } + _13: + ; + a = _fmt_o(tls, *(*Tuintmax_t)(unsafe.Pointer(bp + 8)), z) + if fl&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0 && int64(p) < int64(z)-int64(a)+int64(1) { + p = int32(int64(z) - int64(a) + int64(1)) + } + _32: + ; + if !(0 != 0) { + goto _33 + } + _15: + ; + _14: + ; + pl = int32(1) + if *(*Tuintmax_t)(unsafe.Pointer(bp + 8)) > Uint64FromInt64(Int64FromInt64(INT64_MAX)) { + *(*Tuintmax_t)(unsafe.Pointer(bp + 8)) = -*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) + } else { + if fl&(Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))) != 0 { + prefix = prefix + 1 + } else { + if fl&(Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))) != 0 { + prefix = prefix + uintptr(2) + } else { + pl = 0 + } + } + } + _16: + ; + a = _fmt_u(tls, *(*Tuintmax_t)(unsafe.Pointer(bp + 8)), z) + _33: + ; + if xp != 0 && p < 0 { + goto overflow + } + if xp != 0 { + fl = fl & ^(Uint32FromUint32(1) << (Int32FromUint8('0') - Int32FromUint8(' '))) + } + if !(*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0) && !(p != 0) { + a = z + goto _30 + } + if int64(p) > int64(z)-int64(a)+BoolInt64(!(*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0)) { + v34 = int64(p) + } else { + v34 = int64(z) - int64(a) + BoolInt64(!(*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0)) + } + p = int32(v34) + goto _30 + goto narrow_c + narrow_c: + ; + _17: + ; + v5 = Int32FromInt32(1) + p = v5 + v8 = z - uintptr(v5) + a = v8 + **(**uint8)(__ccgo_up(v8)) = uint8(*(*Tuintmax_t)(unsafe.Pointer(bp + 8))) + fl = fl & ^(Uint32FromUint32(1) << (Int32FromUint8('0') - Int32FromUint8(' '))) + goto _30 + _19: + ; + if !(int32(1) != 0) { + goto _37 + } + a = Xstrerror(tls, **(**int32)(__ccgo_up(X__errno_location(tls)))) + goto _38 + _37: + ; + _18: + ; + if *(*uintptr)(unsafe.Pointer(bp + 8)) != 0 { + v8 = *(*uintptr)(unsafe.Pointer(bp + 8)) + } else { + v8 = __ccgo_ts + 1627 + } + a = v8 + _38: + ; + if p < 0 { + v5 = int32(INT_MAX) + } else { + v5 = p + } + z = a + uintptr(Xstrnlen(tls, a, Uint64FromInt32(v5))) + if p < 0 && **(**uint8)(__ccgo_up(z)) != 0 { + goto overflow + } + p = int32(int64(z) - int64(a)) + fl = fl & ^(Uint32FromUint32(1) << (Int32FromUint8('0') - Int32FromUint8(' '))) + goto _30 + _20: + ; + if !(*(*Tuintmax_t)(unsafe.Pointer(bp + 8)) != 0) { + goto narrow_c + } + (**(**[2]Twchar_t)(__ccgo_up(bp + 40)))[0] = uint32(*(*Tuintmax_t)(unsafe.Pointer(bp + 8))) + (**(**[2]Twchar_t)(__ccgo_up(bp + 40)))[int32(1)] = uint32(0) + *(*uintptr)(unsafe.Pointer(bp + 8)) = bp + 40 + p = -int32(1) + _21: + ; + ws = *(*uintptr)(unsafe.Pointer(bp + 8)) + v5 = Int32FromInt32(0) + l = v5 + i = Uint64FromInt32(v5) + for { + if v45 = i < Uint64FromInt32(p) && **(**Twchar_t)(__ccgo_up(ws)) != 0; v45 { + v8 = ws + ws += 4 + v6 = Xwctomb(tls, bp+48, **(**Twchar_t)(__ccgo_up(v8))) + l = v6 + } + if !(v45 && v6 >= 0 && Uint64FromInt32(l) <= Uint64FromInt32(p)-i) { + break + } + goto _41 + _41: + ; + i = i + Uint64FromInt32(l) + } + if l < 0 { + return -int32(1) + } + if i > uint64(INT_MAX) { + goto overflow + } + p = Int32FromUint64(i) + _pad3(tls, f, uint8(' '), w, p, Int32FromUint32(fl)) + ws = *(*uintptr)(unsafe.Pointer(bp + 8)) + i = uint64(0) + for { + if v45 = i < uint64(0+Uint32FromInt32(p)) && **(**Twchar_t)(__ccgo_up(ws)) != 0; v45 { + v8 = ws + ws += 4 + v5 = Xwctomb(tls, bp+48, **(**Twchar_t)(__ccgo_up(v8))) + l = v5 + } + if !(v45 && i+Uint64FromInt32(v5) <= Uint64FromInt32(p)) { + break + } + _out(tls, f, bp+48, Uint64FromInt32(l)) + goto _46 + _46: + ; + i = i + Uint64FromInt32(l) + } + _pad3(tls, f, uint8(' '), w, p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + if w > p { + v5 = w + } else { + v5 = p + } + l = v5 + goto _1 + _29: + ; + _28: + ; + _27: + ; + _26: + ; + _25: + ; + _24: + ; + _23: + ; + _22: + ; + if xp != 0 && p < 0 { + goto overflow + } + l = _fmt_fp(tls, f, *(*float64)(unsafe.Pointer(bp + 8)), w, p, Int32FromUint32(fl), t) + if l < 0 { + goto overflow + } + goto _1 + _30: + ; + if int64(p) < int64(z)-int64(a) { + p = int32(int64(z) - int64(a)) + } + if p > int32(INT_MAX)-pl { + goto overflow + } + if w < pl+p { + w = pl + p + } + if w > int32(INT_MAX)-cnt { + goto overflow + } + _pad3(tls, f, uint8(' '), w, pl+p, Int32FromUint32(fl)) + _out(tls, f, prefix, Uint64FromInt32(pl)) + _pad3(tls, f, uint8('0'), w, pl+p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' ')))) + _pad3(tls, f, uint8('0'), p, int32(int64(z)-int64(a)), 0) + _out(tls, f, a, Uint64FromInt64(int64(z)-int64(a))) + _pad3(tls, f, uint8(' '), w, pl+p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + l = w + goto _1 + _1: + } + if f != 0 { + return cnt + } + if !(l10n != 0) { + return 0 + } + i = uint64(1) + for { + if !(i <= uint64(NL_ARGMAX) && **(**int32)(__ccgo_up(nl_type + uintptr(i)*4)) != 0) { + break + } + _pop_arg(tls, nl_arg+uintptr(i)*8, **(**int32)(__ccgo_up(nl_type + uintptr(i)*4)), ap) + goto _51 + _51: + ; + i = i + 1 + } + for { + if !(i <= uint64(NL_ARGMAX) && !(**(**int32)(__ccgo_up(nl_type + uintptr(i)*4)) != 0)) { + break + } + goto _52 + _52: + ; + i = i + 1 + } + if i <= uint64(NL_ARGMAX) { + goto inval + } + return int32(1) + goto inval +inval: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + goto overflow +overflow: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return -int32(1) +} + +func Xvfprintf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(208) + defer tls.Free(208) + var __need_unlock, olderr, ret, v1 int32 + var saved_buf, v2, v3 uintptr + var _ /* ap2 at bp+0 */ Tva_list + var _ /* internal_buf at bp+128 */ [80]uint8 + var _ /* nl_arg at bp+48 */ [10]Targ + var _ /* nl_type at bp+8 */ [10]int32 + _, _, _, _, _, _, _ = __need_unlock, olderr, ret, saved_buf, v1, v2, v3 + **(**[10]int32)(__ccgo_up(bp + 8)) = [10]int32{} + saved_buf = uintptr(0) + /* the copy allows passing va_list* even if va_list is an array */ + **(**Tva_list)(__ccgo_up(bp)) = ap + if _printf_core(tls, uintptr(0), fmt, bp, bp+48, bp+8) < 0 { + _ = **(**Tva_list)(__ccgo_up(bp)) + return -int32(1) + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + olderr = Int32FromUint32((*TFILE)(unsafe.Pointer(f)).Fflags & uint32(F_ERR)) + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_ERR)) + if !((*TFILE)(unsafe.Pointer(f)).Fbuf_size != 0) { + saved_buf = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fbuf = bp + 128 + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = uint64(80) + v3 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v3 + v2 = v3 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v2 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v2 + } + if !((*TFILE)(unsafe.Pointer(f)).Fwend != 0) && X__towrite(tls, f) != 0 { + ret = -int32(1) + } else { + ret = _printf_core(tls, f, fmt, bp, bp+48, bp+8) + } + if saved_buf != 0 { + (*(*func(*TLS, uintptr, uintptr, Tsize_t) Tsize_t)(unsafe.Pointer(&struct{ uintptr }{(*TFILE)(unsafe.Pointer(f)).Fwrite})))(tls, f, uintptr(0), uint64(0)) + if !((*TFILE)(unsafe.Pointer(f)).Fwpos != 0) { + ret = -int32(1) + } + (*TFILE)(unsafe.Pointer(f)).Fbuf = saved_buf + (*TFILE)(unsafe.Pointer(f)).Fbuf_size = uint64(0) + v3 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v3 + v2 = v3 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v2 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v2 + } + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + ret = -int32(1) + } + **(**uint32)(__ccgo_up(f)) |= Uint32FromInt32(olderr) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + _ = **(**Tva_list)(__ccgo_up(bp)) + return ret +} + +const SIZE_L = 2 +const SIZE_def = 0 +const SIZE_h = -1 +const SIZE_hh = -2 +const SIZE_l = 1 +const SIZE_ll = 3 + +func _store_int(tls *TLS, dest uintptr, size int32, i uint64) { + if !(dest != 0) { + return + } + switch size { + case -int32(2): + **(**uint8)(__ccgo_up(dest)) = uint8(i) + case -int32(1): + **(**int16)(__ccgo_up(dest)) = Int16FromUint64(i) + case SIZE_def: + **(**int32)(__ccgo_up(dest)) = Int32FromUint64(i) + case int32(SIZE_l): + **(**int64)(__ccgo_up(dest)) = Int64FromUint64(i) + case int32(SIZE_ll): + **(**int64)(__ccgo_up(dest)) = Int64FromUint64(i) + break + } +} + +func _arg_n(tls *TLS, ap Tva_list, n uint32) (r uintptr) { + var ap2 Tva_list + var i uint32 + var p uintptr + _, _, _ = ap2, i, p + ap2 = ap + i = n + for { + if !(i > uint32(1)) { + break + } + _ = VaUintptr(&ap2) + goto _1 + _1: + ; + i = i - 1 + } + p = VaUintptr(&ap2) + _ = ap2 + return p +} + +func Xvfscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(288) + defer tls.Free(288) + var __need_unlock, alloc, base, c, invert, matches, size, t, width, v1, v3, v4, v6 int32 + var dest, p, s, tmp, tmp1, wcs, v10, v11, v17 uintptr + var i, k, v64 Tsize_t + var pos Toff_t + var x uint64 + var y float64 + var v59 uint32 + var _ /* scanset at bp+16 */ [257]uint8 + var _ /* st at bp+8 */ Tmbstate_t + var _ /* wc at bp+276 */ Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __need_unlock, alloc, base, c, dest, i, invert, k, matches, p, pos, s, size, t, tmp, tmp1, wcs, width, x, y, v1, v10, v11, v17, v3, v4, v59, v6, v64 + alloc = 0 + dest = UintptrFromInt32(0) + matches = 0 + pos = 0 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) { + X__toread(tls, f) + } + if !((*TFILE)(unsafe.Pointer(f)).Frpos != 0) { + goto input_fail + } + p = fmt + for { + if !(**(**uint8)(__ccgo_up(p)) != 0) { + break + } + alloc = 0 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + v3 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _5 + _5: + if v3 != 0 { + for { + v4 = Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) + v6 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _8 + _8: + if !(v6 != 0) { + break + } + p = p + 1 + } + X__shlim(tls, f, int64(Int32FromInt32(0))) + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v1 = X__shgetc(tls, f) + } + v3 = v1 + v4 = BoolInt32(v3 == int32(' ') || Uint32FromInt32(v3)-uint32('\t') < uint32(5)) + goto _14 + _14: + if !(v4 != 0) { + break + } + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + pos = pos + ((*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf))) + goto _2 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32('%') || Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) == int32('%') { + X__shlim(tls, f, int64(Int32FromInt32(0))) + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('%') { + p = p + 1 + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + v4 = v1 + v6 = BoolInt32(v4 == int32(' ') || Uint32FromInt32(v4)-uint32('\t') < uint32(5)) + goto _21 + _21: + if !(v6 != 0) { + break + } + } + } else { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v1 = X__shgetc(tls, f) + } + c = v1 + } + if c != Int32FromUint8(**(**uint8)(__ccgo_up(p))) { + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if c < 0 { + goto input_fail + } + goto match_fail + } + pos = pos + ((*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf))) + goto _2 + } + p = p + 1 + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('*') { + dest = uintptr(0) + p = p + 1 + } else { + if BoolInt32(uint32(**(**uint8)(__ccgo_up(p)))-uint32('0') < uint32(10)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) == int32('$') { + dest = _arg_n(tls, ap, Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(p)))-int32('0'))) + p = p + uintptr(2) + } else { + dest = VaUintptr(&ap) + } + } + width = 0 + for { + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(p)))-uint32('0') < uint32(10)) != 0) { + break + } + width = int32(10)*width + Int32FromUint8(**(**uint8)(__ccgo_up(p))) - int32('0') + goto _25 + _25: + ; + p = p + 1 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('m') { + wcs = uintptr(0) + s = uintptr(0) + alloc = BoolInt32(!!(dest != 0)) + p = p + 1 + } else { + alloc = 0 + } + size = SIZE_def + v10 = p + p = p + 1 + switch Int32FromUint8(**(**uint8)(__ccgo_up(v10))) { + case int32('h'): + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('h') { + p = p + 1 + size = -Int32FromInt32(2) + } else { + size = -int32(1) + } + case int32('l'): + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('l') { + p = p + 1 + size = Int32FromInt32(SIZE_ll) + } else { + size = int32(SIZE_l) + } + case int32('j'): + size = int32(SIZE_ll) + case int32('z'): + fallthrough + case int32('t'): + size = int32(SIZE_l) + case int32('L'): + size = int32(SIZE_L) + case int32('d'): + fallthrough + case int32('i'): + fallthrough + case int32('o'): + fallthrough + case int32('u'): + fallthrough + case int32('x'): + fallthrough + case int32('a'): + fallthrough + case int32('e'): + fallthrough + case int32('f'): + fallthrough + case int32('g'): + fallthrough + case int32('A'): + fallthrough + case int32('E'): + fallthrough + case int32('F'): + fallthrough + case int32('G'): + fallthrough + case int32('X'): + fallthrough + case int32('s'): + fallthrough + case int32('c'): + fallthrough + case int32('['): + fallthrough + case int32('S'): + fallthrough + case int32('C'): + fallthrough + case int32('p'): + fallthrough + case int32('n'): + p = p - 1 + default: + goto fmt_fail + } + t = Int32FromUint8(**(**uint8)(__ccgo_up(p))) + /* C or S */ + if t&int32(0x2f) == int32(3) { + t = t | int32(32) + size = int32(SIZE_l) + } + switch t { + case int32('c'): + if width < int32(1) { + width = int32(1) + } + fallthrough + case int32('['): + case int32('n'): + _store_int(tls, dest, size, Uint64FromInt64(pos)) + /* do not increment match count, etc! */ + goto _2 + default: + X__shlim(tls, f, int64(Int32FromInt32(0))) + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v1 = X__shgetc(tls, f) + } + v3 = v1 + v4 = BoolInt32(v3 == int32(' ') || Uint32FromInt32(v3)-uint32('\t') < uint32(5)) + goto _32 + _32: + if !(v4 != 0) { + break + } + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + pos = pos + ((*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf))) + } + X__shlim(tls, f, int64(width)) + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v1 = X__shgetc(tls, f) + } + if v1 < 0 { + goto input_fail + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + switch t { + case int32('['): + goto _36 + case int32('c'): + goto _37 + case int32('s'): + goto _38 + case int32('x'): + goto _39 + case int32('X'): + goto _40 + case int32('p'): + goto _41 + case int32('o'): + goto _42 + case int32('u'): + goto _43 + case int32('d'): + goto _44 + case int32('i'): + goto _45 + case int32('G'): + goto _46 + case int32('g'): + goto _47 + case int32('F'): + goto _48 + case int32('f'): + goto _49 + case int32('E'): + goto _50 + case int32('e'): + goto _51 + case int32('A'): + goto _52 + case int32('a'): + goto _53 + } + goto _54 + _38: + ; + _37: + ; + _36: + ; + if t == int32('c') || t == int32('s') { + Xmemset(tls, bp+16, -int32(1), uint64(257)) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[0] = uint8(0) + if t == int32('s') { + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\t')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\n')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\v')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\f')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('\r')] = uint8(0) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8(' ')] = uint8(0) + } + } else { + p = p + 1 + v10 = p + if Int32FromUint8(**(**uint8)(__ccgo_up(v10))) == int32('^') { + p = p + 1 + invert = Int32FromInt32(1) + } else { + invert = 0 + } + Xmemset(tls, bp+16, invert, uint64(257)) + (**(**[257]uint8)(__ccgo_up(bp + 16)))[0] = uint8(0) + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('-') { + p = p + 1 + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8('-')] = Uint8FromInt32(Int32FromInt32(1) - invert) + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32(']') { + p = p + 1 + (**(**[257]uint8)(__ccgo_up(bp + 16)))[Int32FromInt32(1)+Int32FromUint8(']')] = Uint8FromInt32(Int32FromInt32(1) - invert) + } + } + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(p))) != int32(']')) { + break + } + if !(**(**uint8)(__ccgo_up(p)) != 0) { + goto fmt_fail + } + if Int32FromUint8(**(**uint8)(__ccgo_up(p))) == int32('-') && **(**uint8)(__ccgo_up(p + 1)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(p + 1))) != int32(']') { + v10 = p + p = p + 1 + c = Int32FromUint8(**(**uint8)(__ccgo_up(v10 + uintptr(-Int32FromInt32(1))))) + for { + if !(c < Int32FromUint8(**(**uint8)(__ccgo_up(p)))) { + break + } + (**(**[257]uint8)(__ccgo_up(bp + 16)))[int32(1)+c] = Uint8FromInt32(int32(1) - invert) + goto _57 + _57: + ; + c = c + 1 + } + } + (**(**[257]uint8)(__ccgo_up(bp + 16)))[int32(1)+Int32FromUint8(**(**uint8)(__ccgo_up(p)))] = Uint8FromInt32(int32(1) - invert) + goto _56 + _56: + ; + p = p + 1 + } + } + wcs = uintptr(0) + s = uintptr(0) + i = uint64(0) + if t == int32('c') { + v59 = Uint32FromInt32(width) + uint32(1) + } else { + v59 = uint32(31) + } + k = uint64(v59) + if size == int32(SIZE_l) { + if alloc != 0 { + wcs = Xmalloc(tls, k*uint64(4)) + if !(wcs != 0) { + goto alloc_fail + } + } else { + wcs = dest + } + **(**Tmbstate_t)(__ccgo_up(bp + 8)) = Tmbstate_t{} + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + if !((**(**[257]uint8)(__ccgo_up(bp + 16)))[v1+int32(1)] != 0) { + break + } + *(*uint8)(unsafe.Pointer(bp)) = Uint8FromInt32(c) + switch Xmbrtowc(tls, bp+276, bp, uint64(1), bp+8) { + case Uint64FromInt32(-Int32FromInt32(1)): + goto input_fail + case Uint64FromInt32(-Int32FromInt32(2)): + continue + } + if wcs != 0 { + v64 = i + i = i + 1 + **(**Twchar_t)(__ccgo_up(wcs + uintptr(v64)*4)) = **(**Twchar_t)(__ccgo_up(bp + 276)) + } + if alloc != 0 && i == k { + k = k + (k + uint64(1)) + tmp = Xrealloc(tls, wcs, k*uint64(4)) + if !(tmp != 0) { + goto alloc_fail + } + wcs = tmp + } + } + if !(Xmbsinit(tls, bp+8) != 0) { + goto input_fail + } + } else { + if alloc != 0 { + s = Xmalloc(tls, k) + if !(s != 0) { + goto alloc_fail + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + if !((**(**[257]uint8)(__ccgo_up(bp + 16)))[v1+int32(1)] != 0) { + break + } + v64 = i + i = i + 1 + **(**uint8)(__ccgo_up(s + uintptr(v64))) = Uint8FromInt32(c) + if i == k { + k = k + (k + uint64(1)) + tmp1 = Xrealloc(tls, s, k) + if !(tmp1 != 0) { + goto alloc_fail + } + s = tmp1 + } + } + } else { + v10 = dest + s = v10 + if v10 != 0 { + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v17 = f + 8 + v11 = *(*uintptr)(unsafe.Pointer(v17)) + *(*uintptr)(unsafe.Pointer(v17)) = *(*uintptr)(unsafe.Pointer(v17)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v11))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + if !((**(**[257]uint8)(__ccgo_up(bp + 16)))[v1+int32(1)] != 0) { + break + } + v64 = i + i = i + 1 + **(**uint8)(__ccgo_up(s + uintptr(v64))) = Uint8FromInt32(c) + } + } else { + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Fshend { + v11 = f + 8 + v10 = *(*uintptr)(unsafe.Pointer(v11)) + *(*uintptr)(unsafe.Pointer(v11)) = *(*uintptr)(unsafe.Pointer(v11)) + 1 + v3 = Int32FromUint8(**(**uint8)(__ccgo_up(v10))) + } else { + v3 = X__shgetc(tls, f) + } + v1 = v3 + c = v1 + if !((**(**[257]uint8)(__ccgo_up(bp + 16)))[v1+int32(1)] != 0) { + break + } + } + } + } + } + if (*TFILE)(unsafe.Pointer(f)).Fshlim >= 0 { + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Frpos - 1 + } + if !((*TFILE)(unsafe.Pointer(f)).Fshcnt+(int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) != 0) { + goto match_fail + } + if t == int32('c') && (*TFILE)(unsafe.Pointer(f)).Fshcnt+(int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) != int64(width) { + goto match_fail + } + if alloc != 0 { + if size == int32(SIZE_l) { + **(**uintptr)(__ccgo_up(dest)) = wcs + } else { + **(**uintptr)(__ccgo_up(dest)) = s + } + } + if t != int32('c') { + if wcs != 0 { + **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) = uint32(0) + } + if s != 0 { + **(**uint8)(__ccgo_up(s + uintptr(i))) = uint8(0) + } + } + goto _54 + _41: + ; + _40: + ; + _39: + ; + base = int32(16) + goto int_common + _42: + ; + base = int32(8) + goto int_common + _44: + ; + _43: + ; + base = int32(10) + goto int_common + _45: + ; + base = 0 + goto int_common + int_common: + ; + x = X__intscan(tls, f, Uint32FromInt32(base), 0, Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)) + if !((*TFILE)(unsafe.Pointer(f)).Fshcnt+(int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) != 0) { + goto match_fail + } + if t == int32('p') && dest != 0 { + **(**uintptr)(__ccgo_up(dest)) = uintptr(x) + } else { + _store_int(tls, dest, size, x) + } + goto _54 + _53: + ; + _52: + ; + _51: + ; + _50: + ; + _49: + ; + _48: + ; + _47: + ; + _46: + ; + y = X__floatscan(tls, f, size, 0) + if !((*TFILE)(unsafe.Pointer(f)).Fshcnt+(int64((*TFILE)(unsafe.Pointer(f)).Frpos)-int64((*TFILE)(unsafe.Pointer(f)).Fbuf)) != 0) { + goto match_fail + } + if dest != 0 { + switch size { + case SIZE_def: + **(**float32)(__ccgo_up(dest)) = float32(y) + case int32(SIZE_l): + **(**float64)(__ccgo_up(dest)) = y + case int32(SIZE_L): + **(**float64)(__ccgo_up(dest)) = y + break + } + } + goto _54 + _54: + ; + pos = pos + ((*TFILE)(unsafe.Pointer(f)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(f)).Frpos) - int64((*TFILE)(unsafe.Pointer(f)).Fbuf))) + if dest != 0 { + matches = matches + 1 + } + goto _2 + _2: + ; + p = p + 1 + } + if !(0 != 0) { + goto _80 + } + goto fmt_fail +fmt_fail: + ; + goto alloc_fail +alloc_fail: + ; + goto input_fail +input_fail: + ; + if !(matches != 0) { + matches = matches - 1 + } + goto match_fail +match_fail: + ; + if alloc != 0 { + Xfree(tls, s) + Xfree(tls, wcs) + } +_80: + ; + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return matches +} + +func X__isoc99_vfscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfscanf(tls, f, fmt, ap) +} + +var _states1 = [8][58]uint8{ + 0: { + 0: uint8(_DBL), + 2: uint8(_UINT), + 4: uint8(_DBL), + 5: uint8(_DBL), + 6: uint8(_DBL), + 11: uint8(_BIGLPRE), + 18: uint8(_PTR), + 23: uint8(_UINT), + 32: uint8(_DBL), + 34: uint8(_INT), + 35: uint8(_INT), + 36: uint8(_DBL), + 37: uint8(_DBL), + 38: uint8(_DBL), + 39: uint8(_HPRE), + 40: uint8(_INT), + 41: uint8(_JPRE), + 43: uint8(_LPRE), + 44: uint8(_NOARG), + 45: uint8(_PTR), + 46: uint8(_UINT), + 47: uint8(_UIPTR), + 50: uint8(_PTR), + 51: uint8(_ZTPRE), + 52: uint8(_UINT), + 55: uint8(_UINT), + 57: uint8(_ZTPRE), + }, + 1: { + 0: uint8(_DBL), + 4: uint8(_DBL), + 5: uint8(_DBL), + 6: uint8(_DBL), + 23: uint8(_ULONG), + 32: uint8(_DBL), + 34: uint8(_UINT), + 35: uint8(_LONG), + 36: uint8(_DBL), + 37: uint8(_DBL), + 38: uint8(_DBL), + 40: uint8(_LONG), + 43: uint8(_LLPRE), + 45: uint8(_PTR), + 46: uint8(_ULONG), + 50: uint8(_PTR), + 52: uint8(_ULONG), + 55: uint8(_ULONG), + }, + 2: { + 23: uint8(_ULLONG), + 35: uint8(_LLONG), + 40: uint8(_LLONG), + 45: uint8(_PTR), + 46: uint8(_ULLONG), + 52: uint8(_ULLONG), + 55: uint8(_ULLONG), + }, + 3: { + 23: uint8(_USHORT), + 35: uint8(_SHORT), + 39: uint8(_HHPRE), + 40: uint8(_SHORT), + 45: uint8(_PTR), + 46: uint8(_USHORT), + 52: uint8(_USHORT), + 55: uint8(_USHORT), + }, + 4: { + 23: uint8(_UCHAR), + 35: uint8(_CHAR), + 40: uint8(_CHAR), + 45: uint8(_PTR), + 46: uint8(_UCHAR), + 52: uint8(_UCHAR), + 55: uint8(_UCHAR), + }, + 5: { + 0: uint8(_LDBL), + 4: uint8(_LDBL), + 5: uint8(_LDBL), + 6: uint8(_LDBL), + 32: uint8(_LDBL), + 36: uint8(_LDBL), + 37: uint8(_LDBL), + 38: uint8(_LDBL), + 45: uint8(_PTR), + }, + 6: { + 23: uint8(_SIZET), + 35: uint8(_PDIFF), + 40: uint8(_PDIFF), + 45: uint8(_PTR), + 46: uint8(_SIZET), + 52: uint8(_SIZET), + 55: uint8(_SIZET), + }, + 7: { + 23: uint8(_UMAX), + 35: uint8(_IMAX), + 40: uint8(_IMAX), + 45: uint8(_PTR), + 46: uint8(_UMAX), + 52: uint8(_UMAX), + 55: uint8(_UMAX), + }, +} + +func _pop_arg1(tls *TLS, arg uintptr, type1 int32, ap uintptr) { + switch type1 { + case int32(_PTR): + *(*uintptr)(unsafe.Pointer(arg)) = VaUintptr(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_INT): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UINT): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUint32(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_LONG): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_ULONG): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_ULLONG): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUint64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_SHORT): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt16(int16(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_USHORT): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(Uint16FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_CHAR): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt8(int8(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_UCHAR): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(Uint8FromInt32(VaInt32(&**(**Tva_list)(__ccgo_up(ap))))) + case int32(_LLONG): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_SIZET): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_IMAX): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UMAX): + (*Targ)(unsafe.Pointer(arg)).Fi = VaUint64(&**(**Tva_list)(__ccgo_up(ap))) + case int32(_PDIFF): + (*Targ)(unsafe.Pointer(arg)).Fi = Uint64FromInt64(VaInt64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_UIPTR): + (*Targ)(unsafe.Pointer(arg)).Fi = uint64(VaUintptr(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_DBL): + *(*float64)(unsafe.Pointer(arg)) = float64(VaFloat64(&**(**Tva_list)(__ccgo_up(ap)))) + case int32(_LDBL): + *(*float64)(unsafe.Pointer(arg)) = VaFloat64(&**(**Tva_list)(__ccgo_up(ap))) + } +} + +func _out1(tls *TLS, f uintptr, s uintptr, l Tsize_t) { + var v1 Tsize_t + var v2 uintptr + _, _ = v1, v2 + for { + v1 = l + l = l - 1 + if !(v1 != 0 && !((*TFILE)(unsafe.Pointer(f)).Fflags&Uint32FromInt32(F_ERR) != 0)) { + break + } + v2 = s + s += 4 + Xfputwc(tls, **(**Twchar_t)(__ccgo_up(v2)), f) + } +} + +func _pad4(tls *TLS, f uintptr, n int32, fl int32) { + bp := tls.Alloc(32) + defer tls.Free(32) + if Uint32FromInt32(fl)&(Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))) != 0 || !(n != 0) || (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + return + } + Xfprintf(tls, f, __ccgo_ts+1634, VaList(bp+8, n, __ccgo_ts)) +} + +func _getint1(tls *TLS, s uintptr) (r int32) { + var i int32 + _ = i + i = 0 + for { + if !(BoolInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(s))))-uint32('0') < uint32(10)) != 0) { + break + } + if Uint32FromInt32(i) > Uint32FromInt32(INT_MAX)/Uint32FromUint32(10) || **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(s))))-uint32('0') > Uint32FromInt32(int32(INT_MAX)-int32(10)*i) { + i = -int32(1) + } else { + i = Int32FromUint32(Uint32FromInt32(int32(10)*i) + (**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(s)))) - uint32('0'))) + } + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(s)) += 4 + } + return i +} + +var _sizeprefix = [24]uint8{ + 0: uint8('L'), + 3: uint8('j'), + 4: uint8('L'), + 5: uint8('L'), + 6: uint8('L'), + 8: uint8('j'), + 14: uint8('j'), + 15: uint8('j'), + 20: uint8('j'), + 23: uint8('j'), +} + +func _wprintf_core(tls *TLS, f uintptr, fmt uintptr, ap uintptr, nl_arg uintptr, nl_type uintptr) (r int32) { + bp := tls.Alloc(112) + defer tls.Free(112) + var a, bs, z, v8 uintptr + var argpos, cnt, i, l, p, t, w, xp, v5, v6, v7 int32 + var fl, l10n, ps, st uint32 + var v15 bool + var v9 uint64 + var _ /* arg at bp+16 */ Targ + var _ /* charfmt at bp+24 */ [16]uint8 + var _ /* s at bp+8 */ uintptr + var _ /* wc at bp+40 */ Twchar_t + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a, argpos, bs, cnt, fl, i, l, l10n, p, ps, st, t, w, xp, z, v15, v5, v6, v7, v8, v9 + **(**uintptr)(__ccgo_up(bp + 8)) = fmt + l10n = uint32(0) + cnt = 0 + l = 0 + for { + /* This error is only specified for snprintf, but since it's + * unspecified for other forms, do the same. Stop immediately + * on overflow; otherwise %n could produce wrong results. */ + if l > int32(INT_MAX)-cnt { + goto overflow + } + /* Update output count, end loop when fmt is exhausted */ + cnt = cnt + l + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != 0) { + break + } + /* Handle literal text and %% format specifiers */ + a = **(**uintptr)(__ccgo_up(bp + 8)) + for { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != 0 && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) != uint32('%')) { + break + } + goto _2 + _2: + ; + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + } + z = **(**uintptr)(__ccgo_up(bp + 8)) + for { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) == uint32('%') && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4)) == uint32('%')) { + break + } + goto _3 + _3: + ; + z += 4 + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(2)*4 + } + if (int64(z)-int64(a))/4 > int64(int32(INT_MAX)-cnt) { + goto overflow + } + l = int32((int64(z) - int64(a)) / 4) + if f != 0 { + _out1(tls, f, a, Uint64FromInt32(l)) + } + if l != 0 { + goto _1 + } + if BoolInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4))-uint32('0') < uint32(10)) != 0 && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4)) == uint32('$') { + l10n = uint32(1) + argpos = Int32FromUint32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4)) - uint32('0')) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(3)*4 + } else { + argpos = -int32(1) + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + } + /* Read modifier flags */ + fl = uint32(0) + for { + if !(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))-uint32(' ') < uint32(32) && (Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))|Uint32FromUint32(1)<<(Int32FromUint8('\'')-Int32FromUint8(' ')))&(uint32(1)<<(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))-uint32(' '))) != 0) { + break + } + fl = fl | uint32(1)<<(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))-uint32(' ')) + goto _4 + _4: + ; + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + } + /* Read field width */ + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) == uint32('*') { + if BoolInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4))-uint32('0') < uint32(10)) != 0 && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4)) == uint32('$') { + l10n = uint32(1) + **(**int32)(__ccgo_up(nl_type + uintptr(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4))-uint32('0'))*4)) = int32(_INT) + w = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(nl_arg + uintptr(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4))-uint32('0'))*8))) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(3)*4 + } else { + if !(l10n != 0) { + if f != 0 { + v5 = VaInt32(&**(**Tva_list)(__ccgo_up(ap))) + } else { + v5 = 0 + } + w = v5 + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + } else { + goto inval + } + } + if w < 0 { + fl = fl | Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')) + w = -w + } + } else { + v5 = _getint1(tls, bp+8) + w = v5 + if v5 < 0 { + goto overflow + } + } + /* Read precision */ + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) == uint32('.') && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 1*4)) == uint32('*') { + if BoolInt32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4))-uint32('0') < uint32(10)) != 0 && **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 3*4)) == uint32('$') { + **(**int32)(__ccgo_up(nl_type + uintptr(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4))-uint32('0'))*4)) = int32(_INT) + p = Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(nl_arg + uintptr(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + 2*4))-uint32('0'))*8))) + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(4)*4 + } else { + if !(l10n != 0) { + if f != 0 { + v5 = VaInt32(&**(**Tva_list)(__ccgo_up(ap))) + } else { + v5 = 0 + } + p = v5 + **(**uintptr)(__ccgo_up(bp + 8)) = **(**uintptr)(__ccgo_up(bp + 8)) + uintptr(2)*4 + } else { + goto inval + } + } + xp = BoolInt32(p >= 0) + } else { + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)))) == uint32('.') { + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + p = _getint1(tls, bp+8) + xp = int32(1) + } else { + p = -int32(1) + xp = 0 + } + } + /* Format specifier state machine */ + st = uint32(0) + for cond := true; cond; cond = st-uint32(1) < uint32(_STOP) { + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8))))-uint32('A') > Uint32FromInt32(Int32FromUint8('z')-Int32FromUint8('A')) { + goto inval + } + ps = st + v8 = **(**uintptr)(__ccgo_up(bp + 8)) + **(**uintptr)(__ccgo_up(bp + 8)) += 4 + st = uint32(**(**uint8)(__ccgo_up(uintptr(unsafe.Pointer(&_states1)) + uintptr(st)*58 + uintptr(**(**Twchar_t)(__ccgo_up(v8))-uint32('A'))))) + } + if !(st != 0) { + goto inval + } + /* Check validity of argument type (nl/normal) */ + if st == uint32(_NOARG) { + if argpos >= 0 { + goto inval + } + } else { + if argpos >= 0 { + **(**int32)(__ccgo_up(nl_type + uintptr(argpos)*4)) = Int32FromUint32(st) + **(**Targ)(__ccgo_up(bp + 16)) = **(**Targ)(__ccgo_up(nl_arg + uintptr(argpos)*8)) + } else { + if f != 0 { + _pop_arg1(tls, bp+16, Int32FromUint32(st), ap) + } else { + return 0 + } + } + } + if !(f != 0) { + goto _1 + } + /* Do not process any new directives once in error state. */ + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + return -int32(1) + } + t = Int32FromUint32(**(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + uintptr(-Int32FromInt32(1))*4))) + if ps != 0 && t&int32(15) == int32(3) { + t = t & ^Int32FromInt32(32) + } + switch t { + case int32('n'): + switch ps { + case uint32(_BARE): + **(**int32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = cnt + case uint32(_LPRE): + **(**int64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = int64(cnt) + case uint32(_LLPRE): + **(**int64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = int64(cnt) + case uint32(_HPRE): + **(**uint16)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = Uint16FromInt32(cnt) + case uint32(_HHPRE): + **(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = Uint8FromInt32(cnt) + case uint32(_ZTPRE): + **(**Tsize_t)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = Uint64FromInt32(cnt) + case uint32(_JPRE): + **(**Tuintmax_t)(__ccgo_up(*(*uintptr)(unsafe.Pointer(bp + 16)))) = Uint64FromInt32(cnt) + break + } + goto _1 + case int32('c'): + fallthrough + case int32('C'): + if w < int32(1) { + w = int32(1) + } + _pad4(tls, f, w-int32(1), Int32FromUint32(fl)) + if t == int32('C') { + v9 = *(*Tuintmax_t)(unsafe.Pointer(bp + 16)) + } else { + v9 = uint64(Xbtowc(tls, Int32FromUint64(*(*Tuintmax_t)(unsafe.Pointer(bp + 16))))) + } + *(*Twchar_t)(unsafe.Pointer(bp)) = uint32(v9) + _out1(tls, f, bp, uint64(1)) + _pad4(tls, f, w-int32(1), Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + l = w + goto _1 + case int32('S'): + a = *(*uintptr)(unsafe.Pointer(bp + 16)) + if p < 0 { + v5 = int32(INT_MAX) + } else { + v5 = p + } + z = a + uintptr(Xwcsnlen(tls, a, Uint64FromInt32(v5)))*4 + if p < 0 && **(**Twchar_t)(__ccgo_up(z)) != 0 { + goto overflow + } + p = int32((int64(z) - int64(a)) / 4) + if w < p { + w = p + } + _pad4(tls, f, w-p, Int32FromUint32(fl)) + _out1(tls, f, a, Uint64FromInt32(p)) + _pad4(tls, f, w-p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + l = w + goto _1 + case int32('m'): + *(*uintptr)(unsafe.Pointer(bp + 16)) = Xstrerror(tls, **(**int32)(__ccgo_up(X__errno_location(tls)))) + fallthrough + case int32('s'): + if !(*(*uintptr)(unsafe.Pointer(bp + 16)) != 0) { + *(*uintptr)(unsafe.Pointer(bp + 16)) = __ccgo_ts + 1627 + } + bs = *(*uintptr)(unsafe.Pointer(bp + 16)) + v5 = Int32FromInt32(0) + l = v5 + i = v5 + for { + if p < 0 { + v6 = int32(INT_MAX) + } else { + v6 = p + } + if v15 = l < v6; v15 { + v7 = Xmbtowc(tls, bp+40, bs, uint64(MB_LEN_MAX)) + i = v7 + } + if !(v15 && v7 > 0) { + break + } + goto _11 + _11: + ; + bs = bs + uintptr(i) + l = l + 1 + } + if i < 0 { + return -int32(1) + } + if p < 0 && **(**uint8)(__ccgo_up(bs)) != 0 { + goto overflow + } + p = l + if w < p { + w = p + } + _pad4(tls, f, w-p, Int32FromUint32(fl)) + bs = *(*uintptr)(unsafe.Pointer(bp + 16)) + for { + v5 = l + l = l - 1 + if !(v5 != 0) { + break + } + i = Xmbtowc(tls, bp+40, bs, uint64(MB_LEN_MAX)) + bs = bs + uintptr(i) + _out1(tls, f, bp+40, uint64(1)) + } + _pad4(tls, f, w-p, Int32FromUint32(fl^Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' ')))) + l = w + goto _1 + } + if xp != 0 && p < 0 { + goto overflow + } + Xsnprintf(tls, bp+24, uint64(16), __ccgo_ts+1638, VaList(bp+56, __ccgo_ts+1658+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8('#')-Int32FromUint8(' '))) != 0)), __ccgo_ts+1660+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8('+')-Int32FromUint8(' '))) != 0)), __ccgo_ts+1662+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8('-')-Int32FromUint8(' '))) != 0)), __ccgo_ts+672+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8(' ')-Int32FromUint8(' '))) != 0)), __ccgo_ts+1664+BoolUintptr(!(fl&(Uint32FromUint32(1)<<(Int32FromUint8('0')-Int32FromUint8(' '))) != 0)), Int32FromUint8(_sizeprefix[t|int32(32)-int32('a')]), t)) + switch t | Int32FromInt32(32) { + case int32('a'): + fallthrough + case int32('e'): + fallthrough + case int32('f'): + fallthrough + case int32('g'): + l = Xfprintf(tls, f, bp+24, VaList(bp+56, w, p, *(*float64)(unsafe.Pointer(bp + 16)))) + case int32('d'): + fallthrough + case int32('i'): + fallthrough + case int32('o'): + fallthrough + case int32('u'): + fallthrough + case int32('x'): + fallthrough + case int32('p'): + l = Xfprintf(tls, f, bp+24, VaList(bp+56, w, p, *(*Tuintmax_t)(unsafe.Pointer(bp + 16)))) + break + } + goto _1 + _1: + } + if f != 0 { + return cnt + } + if !(l10n != 0) { + return 0 + } + i = int32(1) + for { + if !(i <= int32(NL_ARGMAX) && **(**int32)(__ccgo_up(nl_type + uintptr(i)*4)) != 0) { + break + } + _pop_arg1(tls, nl_arg+uintptr(i)*8, **(**int32)(__ccgo_up(nl_type + uintptr(i)*4)), ap) + goto _17 + _17: + ; + i = i + 1 + } + for { + if !(i <= int32(NL_ARGMAX) && !(**(**int32)(__ccgo_up(nl_type + uintptr(i)*4)) != 0)) { + break + } + goto _18 + _18: + ; + i = i + 1 + } + if i <= int32(NL_ARGMAX) { + return -int32(1) + } + return int32(1) + goto inval +inval: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + goto overflow +overflow: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return -int32(1) +} + +func Xvfwprintf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var __need_unlock, olderr, ret, v1 int32 + var _ /* ap2 at bp+0 */ Tva_list + var _ /* nl_arg at bp+48 */ [10]Targ + var _ /* nl_type at bp+8 */ [10]int32 + _, _, _, _ = __need_unlock, olderr, ret, v1 + **(**[10]int32)(__ccgo_up(bp + 8)) = [10]int32{} + /* the copy allows passing va_list* even if va_list is an array */ + **(**Tva_list)(__ccgo_up(bp)) = ap + if _wprintf_core(tls, uintptr(0), fmt, bp, bp+48, bp+8) < 0 { + _ = **(**Tva_list)(__ccgo_up(bp)) + return -int32(1) + } + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + Xfwide(tls, f, int32(1)) + olderr = Int32FromUint32((*TFILE)(unsafe.Pointer(f)).Fflags & uint32(F_ERR)) + **(**uint32)(__ccgo_up(f)) &= Uint32FromInt32(^Int32FromInt32(F_ERR)) + ret = _wprintf_core(tls, f, fmt, bp, bp+48, bp+8) + if (*TFILE)(unsafe.Pointer(f)).Fflags&uint32(F_ERR) != 0 { + ret = -int32(1) + } + **(**uint32)(__ccgo_up(f)) |= Uint32FromInt32(olderr) + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + _ = **(**Tva_list)(__ccgo_up(bp)) + return ret +} + +func _store_int1(tls *TLS, dest uintptr, size int32, i uint64) { + if !(dest != 0) { + return + } + switch size { + case -int32(2): + **(**uint8)(__ccgo_up(dest)) = uint8(i) + case -int32(1): + **(**int16)(__ccgo_up(dest)) = Int16FromUint64(i) + case SIZE_def: + **(**int32)(__ccgo_up(dest)) = Int32FromUint64(i) + case int32(SIZE_l): + **(**int64)(__ccgo_up(dest)) = Int64FromUint64(i) + case int32(SIZE_ll): + **(**int64)(__ccgo_up(dest)) = Int64FromUint64(i) + break + } +} + +func _arg_n1(tls *TLS, ap Tva_list, n uint32) (r uintptr) { + var ap2 Tva_list + var i uint32 + var p uintptr + _, _, _ = ap2, i, p + ap2 = ap + i = n + for { + if !(i > uint32(1)) { + break + } + _ = VaUintptr(&ap2) + goto _1 + _1: + ; + i = i - 1 + } + p = VaUintptr(&ap2) + _ = ap2 + return p +} + +func _in_set(tls *TLS, set uintptr, c int32) (r int32) { + var j int32 + var p, v3 uintptr + _, _, _ = j, p, v3 + p = set + if **(**Twchar_t)(__ccgo_up(p)) == uint32('-') { + if c == int32('-') { + return int32(1) + } + p += 4 + } else { + if **(**Twchar_t)(__ccgo_up(p)) == uint32(']') { + if c == int32(']') { + return int32(1) + } + p += 4 + } + } + for { + if !(**(**Twchar_t)(__ccgo_up(p)) != 0 && **(**Twchar_t)(__ccgo_up(p)) != uint32(']')) { + break + } + if **(**Twchar_t)(__ccgo_up(p)) == uint32('-') && **(**Twchar_t)(__ccgo_up(p + 1*4)) != 0 && **(**Twchar_t)(__ccgo_up(p + 1*4)) != uint32(']') { + v3 = p + p += 4 + j = Int32FromUint32(**(**Twchar_t)(__ccgo_up(v3 + uintptr(-Int32FromInt32(1))*4))) + for { + if !(Uint32FromInt32(j) < **(**Twchar_t)(__ccgo_up(p))) { + break + } + if c == j { + return int32(1) + } + goto _2 + _2: + ; + j = j + 1 + } + } + if Uint32FromInt32(c) == **(**Twchar_t)(__ccgo_up(p)) { + return int32(1) + } + goto _1 + _1: + ; + p += 4 + } + return 0 +} + +func Xvfwscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(80) + defer tls.Free(80) + var __need_unlock, alloc, c, gotmatch, invert, l, matches, size, t, width, v1 int32 + var dest, p, s, set, tmp1, tmp2, wcs, v5, v6 uintptr + var i, k, v37 Tsize_t + var pos Toff_t + var v4 uint32 + var _ /* cnt at bp+0 */ Toff_t + var _ /* tmp at bp+8 */ [22]uint8 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = __need_unlock, alloc, c, dest, gotmatch, i, invert, k, l, matches, p, pos, s, set, size, t, tmp1, tmp2, wcs, width, v1, v37, v4, v5, v6 + dest = UintptrFromInt32(0) + matches = 0 + pos = 0 + if AtomicLoadPInt32(f+140) >= 0 { + v1 = ___lockfile(tls, f) + } else { + v1 = 0 + } + __need_unlock = v1 + Xfwide(tls, f, int32(1)) + p = fmt + for { + if !(**(**Twchar_t)(__ccgo_up(p)) != 0) { + break + } + alloc = 0 + if Xiswspace(tls, **(**Twchar_t)(__ccgo_up(p))) != 0 { + for Xiswspace(tls, **(**Twchar_t)(__ccgo_up(p + 1*4))) != 0 { + p += 4 + } + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + v1 = Int32FromUint32(v4) + c = v1 + if !(Xiswspace(tls, Uint32FromInt32(v1)) != 0) { + break + } + pos = pos + 1 + } + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 && Uint32FromInt32(c) < uint32(128) { + v6 = f + 8 + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) - 1 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + _ = **(**uint8)(__ccgo_up(v5)) + } else { + Xungetwc(tls, Uint32FromInt32(c), f) + } + goto _2 + } + if **(**Twchar_t)(__ccgo_up(p)) != uint32('%') || **(**Twchar_t)(__ccgo_up(p + 1*4)) == uint32('%') { + if **(**Twchar_t)(__ccgo_up(p)) == uint32('%') { + p += 4 + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + v1 = Int32FromUint32(v4) + c = v1 + if !(Xiswspace(tls, Uint32FromInt32(v1)) != 0) { + break + } + pos = pos + 1 + } + } else { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + c = Int32FromUint32(v4) + } + if Uint32FromInt32(c) != **(**Twchar_t)(__ccgo_up(p)) { + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 && Uint32FromInt32(c) < uint32(128) { + v6 = f + 8 + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) - 1 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + _ = **(**uint8)(__ccgo_up(v5)) + } else { + Xungetwc(tls, Uint32FromInt32(c), f) + } + if c < 0 { + goto input_fail + } + goto match_fail + } + pos = pos + 1 + goto _2 + } + p += 4 + if **(**Twchar_t)(__ccgo_up(p)) == uint32('*') { + dest = uintptr(0) + p += 4 + } else { + if BoolInt32(**(**Twchar_t)(__ccgo_up(p))-uint32('0') < uint32(10)) != 0 && **(**Twchar_t)(__ccgo_up(p + 1*4)) == uint32('$') { + dest = _arg_n1(tls, ap, **(**Twchar_t)(__ccgo_up(p))-uint32('0')) + p = p + uintptr(2)*4 + } else { + dest = VaUintptr(&ap) + } + } + width = 0 + for { + if !(BoolInt32(**(**Twchar_t)(__ccgo_up(p))-uint32('0') < uint32(10)) != 0) { + break + } + width = Int32FromUint32(Uint32FromInt32(int32(10)*width) + **(**Twchar_t)(__ccgo_up(p)) - uint32('0')) + goto _18 + _18: + ; + p += 4 + } + if **(**Twchar_t)(__ccgo_up(p)) == uint32('m') { + wcs = uintptr(0) + s = uintptr(0) + alloc = BoolInt32(!!(dest != 0)) + p += 4 + } else { + alloc = 0 + } + size = SIZE_def + v5 = p + p += 4 + switch **(**Twchar_t)(__ccgo_up(v5)) { + case uint32('h'): + if **(**Twchar_t)(__ccgo_up(p)) == uint32('h') { + p += 4 + size = -Int32FromInt32(2) + } else { + size = -int32(1) + } + case uint32('l'): + if **(**Twchar_t)(__ccgo_up(p)) == uint32('l') { + p += 4 + size = Int32FromInt32(SIZE_ll) + } else { + size = int32(SIZE_l) + } + case uint32('j'): + size = int32(SIZE_ll) + case uint32('z'): + fallthrough + case uint32('t'): + size = int32(SIZE_l) + case uint32('L'): + size = int32(SIZE_L) + case uint32('d'): + fallthrough + case uint32('i'): + fallthrough + case uint32('o'): + fallthrough + case uint32('u'): + fallthrough + case uint32('x'): + fallthrough + case uint32('a'): + fallthrough + case uint32('e'): + fallthrough + case uint32('f'): + fallthrough + case uint32('g'): + fallthrough + case uint32('A'): + fallthrough + case uint32('E'): + fallthrough + case uint32('F'): + fallthrough + case uint32('G'): + fallthrough + case uint32('X'): + fallthrough + case uint32('s'): + fallthrough + case uint32('c'): + fallthrough + case uint32('['): + fallthrough + case uint32('S'): + fallthrough + case uint32('C'): + fallthrough + case uint32('p'): + fallthrough + case uint32('n'): + p -= 4 + default: + goto fmt_fail + } + t = Int32FromUint32(**(**Twchar_t)(__ccgo_up(p))) + /* Transform S,C -> ls,lc */ + if t&int32(0x2f) == int32(3) { + size = int32(SIZE_l) + t = t | int32(32) + } + if t != int32('n') { + if t != int32('[') && t|int32(32) != int32('c') { + for { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + v1 = Int32FromUint32(v4) + c = v1 + if !(Xiswspace(tls, Uint32FromInt32(v1)) != 0) { + break + } + pos = pos + 1 + } + } else { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + c = Int32FromUint32(v4) + } + if c < 0 { + goto input_fail + } + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 && Uint32FromInt32(c) < uint32(128) { + v6 = f + 8 + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) - 1 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + _ = **(**uint8)(__ccgo_up(v5)) + } else { + Xungetwc(tls, Uint32FromInt32(c), f) + } + } + switch t { + case int32('n'): + _store_int1(tls, dest, size, Uint64FromInt64(pos)) + /* do not increment match count, etc! */ + goto _2 + case int32('s'): + fallthrough + case int32('c'): + fallthrough + case int32('['): + if t == int32('c') { + if width < int32(1) { + width = int32(1) + } + invert = int32(1) + set = __ccgo_ts + 1666 + } else { + if t == int32('s') { + invert = int32(1) + set = uintptr(unsafe.Pointer(&_spaces1)) + } else { + p += 4 + v5 = p + if **(**Twchar_t)(__ccgo_up(v5)) == uint32('^') { + p += 4 + invert = Int32FromInt32(1) + } else { + invert = 0 + } + set = p + if **(**Twchar_t)(__ccgo_up(p)) == uint32(']') { + p += 4 + } + for **(**Twchar_t)(__ccgo_up(p)) != uint32(']') { + if !(**(**Twchar_t)(__ccgo_up(p)) != 0) { + goto fmt_fail + } + p += 4 + } + } + } + if size == SIZE_def { + v5 = dest + } else { + v5 = uintptr(0) + } + s = v5 + if size == int32(SIZE_l) { + v5 = dest + } else { + v5 = uintptr(0) + } + wcs = v5 + gotmatch = 0 + if width < int32(1) { + width = -int32(1) + } + i = uint64(0) + if alloc != 0 { + if t == int32('c') { + v4 = Uint32FromInt32(width) + uint32(1) + } else { + v4 = uint32(31) + } + k = uint64(v4) + if size == int32(SIZE_l) { + wcs = Xmalloc(tls, k*uint64(4)) + if !(wcs != 0) { + goto alloc_fail + } + } else { + s = Xmalloc(tls, k) + if !(s != 0) { + goto alloc_fail + } + } + } + for width != 0 { + if (*TFILE)(unsafe.Pointer(f)).Frpos != (*TFILE)(unsafe.Pointer(f)).Frend && Int32FromUint8(**(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Frpos))) < int32(128) { + v6 = f + 8 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) + 1 + v4 = uint32(**(**uint8)(__ccgo_up(v5))) + } else { + v4 = Xgetwc(tls, f) + } + v1 = Int32FromUint32(v4) + c = v1 + if v1 < 0 { + break + } + if _in_set(tls, set, c) == invert { + break + } + if wcs != 0 { + v37 = i + i = i + 1 + **(**Twchar_t)(__ccgo_up(wcs + uintptr(v37)*4)) = Uint32FromInt32(c) + if alloc != 0 && i == k { + k = k + (k + uint64(1)) + tmp1 = Xrealloc(tls, wcs, k*uint64(4)) + if !(tmp1 != 0) { + goto alloc_fail + } + wcs = tmp1 + } + } else { + if size != int32(SIZE_l) { + if s != 0 { + v5 = s + uintptr(i) + } else { + v5 = bp + 8 + } + l = Xwctomb(tls, v5, Uint32FromInt32(c)) + if l < 0 { + goto input_fail + } + i = i + Uint64FromInt32(l) + if alloc != 0 && i > k-uint64(4) { + k = k + (k + uint64(1)) + tmp2 = Xrealloc(tls, s, k) + if !(tmp2 != 0) { + goto alloc_fail + } + s = tmp2 + } + } + } + pos = pos + 1 + width = width - BoolInt32(width > 0) + gotmatch = int32(1) + } + if width != 0 { + if (*TFILE)(unsafe.Pointer(f)).Frend != 0 && Uint32FromInt32(c) < uint32(128) { + v6 = f + 8 + *(*uintptr)(unsafe.Pointer(v6)) = *(*uintptr)(unsafe.Pointer(v6)) - 1 + v5 = *(*uintptr)(unsafe.Pointer(v6)) + _ = **(**uint8)(__ccgo_up(v5)) + } else { + Xungetwc(tls, Uint32FromInt32(c), f) + } + if t == int32('c') || !(gotmatch != 0) { + goto match_fail + } + } + if alloc != 0 { + if size == int32(SIZE_l) { + **(**uintptr)(__ccgo_up(dest)) = wcs + } else { + **(**uintptr)(__ccgo_up(dest)) = s + } + } + if t != int32('c') { + if wcs != 0 { + **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) = uint32(0) + } + if s != 0 { + **(**uint8)(__ccgo_up(s + uintptr(i))) = uint8(0) + } + } + case int32('d'): + fallthrough + case int32('i'): + fallthrough + case int32('o'): + fallthrough + case int32('u'): + fallthrough + case int32('x'): + fallthrough + case int32('a'): + fallthrough + case int32('e'): + fallthrough + case int32('f'): + fallthrough + case int32('g'): + fallthrough + case int32('A'): + fallthrough + case int32('E'): + fallthrough + case int32('F'): + fallthrough + case int32('G'): + fallthrough + case int32('X'): + fallthrough + case int32('p'): + if width < int32(1) { + width = 0 + } + Xsnprintf(tls, bp+8, uint64(22), __ccgo_ts+1670, VaList(bp+40, int32(1)+BoolInt32(!(dest != 0)), __ccgo_ts+1688, width, uintptr(unsafe.Pointer(&_size_pfx))+uintptr(size+int32(2))*3, t)) + **(**Toff_t)(__ccgo_up(bp)) = 0 + if dest != 0 { + v5 = dest + } else { + v5 = bp + } + if Xfscanf(tls, f, bp+8, VaList(bp+40, v5, bp)) == -int32(1) { + goto input_fail + } else { + if !(**(**Toff_t)(__ccgo_up(bp)) != 0) { + goto match_fail + } + } + pos = pos + **(**Toff_t)(__ccgo_up(bp)) + default: + goto fmt_fail + } + if dest != 0 { + matches = matches + 1 + } + goto _2 + _2: + ; + p += 4 + } + if !(0 != 0) { + goto _42 + } + goto fmt_fail +fmt_fail: + ; + goto alloc_fail +alloc_fail: + ; + goto input_fail +input_fail: + ; + if !(matches != 0) { + matches = matches - 1 + } + goto match_fail +match_fail: + ; + if alloc != 0 { + Xfree(tls, s) + Xfree(tls, wcs) + } +_42: + ; + if __need_unlock != 0 { + ___unlockfile(tls, f) + } + return matches +} + +var _size_pfx = [6][3]uint8{ + 0: {'h', 'h'}, + 1: {'h'}, + 2: {}, + 3: {'l'}, + 4: {'L'}, + 5: {'l', 'l'}, +} + +var _spaces1 = [22]Twchar_t{ + 0: uint32(' '), + 1: uint32('\t'), + 2: uint32('\n'), + 3: uint32('\r'), + 4: uint32(11), + 5: uint32(12), + 6: uint32(0x0085), + 7: uint32(0x2000), + 8: uint32(0x2001), + 9: uint32(0x2002), + 10: uint32(0x2003), + 11: uint32(0x2004), + 12: uint32(0x2005), + 13: uint32(0x2006), + 14: uint32(0x2008), + 15: uint32(0x2009), + 16: uint32(0x200a), + 17: uint32(0x2028), + 18: uint32(0x2029), + 19: uint32(0x205f), + 20: uint32(0x3000), +} + +func X__isoc99_vfwscanf(tls *TLS, f uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfwscanf(tls, f, fmt, ap) +} + +func Xvprintf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfprintf(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), fmt, ap) +} + +func Xvscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfscanf(tls, uintptr(unsafe.Pointer(&X__stdin_FILE)), fmt, ap) +} + +func X__isoc99_vscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvscanf(tls, fmt, ap) +} + +type Tcookie3 = struct { + Fs uintptr + Fn Tsize_t +} + +func _sn_write(tls *TLS, f uintptr, s uintptr, l Tsize_t) (r Tsize_t) { + var c, v3 uintptr + var k Tsize_t + var v1 uint64 + _, _, _, _ = c, k, v1, v3 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if (*Tcookie3)(unsafe.Pointer(c)).Fn < Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos)-int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) { + v1 = (*Tcookie3)(unsafe.Pointer(c)).Fn + } else { + v1 = Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos) - int64((*TFILE)(unsafe.Pointer(f)).Fwbase)) + } + k = v1 + if k != 0 { + Xmemcpy(tls, (*Tcookie3)(unsafe.Pointer(c)).Fs, (*TFILE)(unsafe.Pointer(f)).Fwbase, k) + **(**uintptr)(__ccgo_up(c)) += uintptr(k) + **(**Tsize_t)(__ccgo_up(c + 8)) -= k + } + if (*Tcookie3)(unsafe.Pointer(c)).Fn < l { + v1 = (*Tcookie3)(unsafe.Pointer(c)).Fn + } else { + v1 = l + } + k = v1 + if k != 0 { + Xmemcpy(tls, (*Tcookie3)(unsafe.Pointer(c)).Fs, s, k) + **(**uintptr)(__ccgo_up(c)) += uintptr(k) + **(**Tsize_t)(__ccgo_up(c + 8)) -= k + } + **(**uint8)(__ccgo_up((*Tcookie3)(unsafe.Pointer(c)).Fs)) = uint8(0) + v3 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fwbase = v3 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v3 + /* pretend to succeed, even if we discarded extra data */ + return l +} + +func Xvsnprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v ap=%v, (%v:)", tls, s, n, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(256) + defer tls.Free(256) + var v1 uintptr + var v2 uint64 + var _ /* buf at bp+0 */ [1]uint8 + var _ /* c at bp+8 */ Tcookie3 + var _ /* dummy at bp+1 */ [1]uint8 + var _ /* f at bp+24 */ TFILE + _, _ = v1, v2 + if n != 0 { + v1 = s + } else { + v1 = bp + 1 + } + if n != 0 { + v2 = n - uint64(1) + } else { + v2 = uint64(0) + } + **(**Tcookie3)(__ccgo_up(bp + 8)) = Tcookie3{ + Fs: v1, + Fn: v2, + } + **(**TFILE)(__ccgo_up(bp + 24)) = TFILE{ + Fwrite: __ccgo_fp(_sn_write), + Fbuf: bp, + Flock: -int32(1), + Flbf: -int32(1), + Fcookie: bp + 8, + } + **(**uint8)(__ccgo_up((**(**Tcookie3)(__ccgo_up(bp + 8))).Fs)) = uint8(0) + return Xvfprintf(tls, bp+24, fmt, ap) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xvsprintf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvsnprintf(tls, s, uint64(INT_MAX), fmt, ap) +} + +func _string_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var end, src uintptr + var k Tsize_t + _, _, _ = end, k, src + src = (*TFILE)(unsafe.Pointer(f)).Fcookie + k = len1 + uint64(256) + end = Xmemchr(tls, src, 0, k) + if end != 0 { + k = Uint64FromInt64(int64(end) - int64(src)) + } + if k < len1 { + len1 = k + } + Xmemcpy(tls, buf, src, len1) + (*TFILE)(unsafe.Pointer(f)).Frpos = src + uintptr(len1) + (*TFILE)(unsafe.Pointer(f)).Frend = src + uintptr(k) + (*TFILE)(unsafe.Pointer(f)).Fcookie = src + uintptr(k) + return len1 +} + +func Xvsscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(240) + defer tls.Free(240) + var _ /* f at bp+0 */ TFILE + **(**TFILE)(__ccgo_up(bp)) = TFILE{ + Fread: __ccgo_fp(_string_read), + Fbuf: s, + Flock: -int32(1), + Fcookie: s, + } + return Xvfscanf(tls, bp, fmt, ap) +} + +func X__isoc99_vsscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvsscanf(tls, s, fmt, ap) +} + +type Tcookie4 = struct { + Fws uintptr + Fl Tsize_t +} + +func _sw_write(tls *TLS, f uintptr, s uintptr, l Tsize_t) (r Tsize_t) { + var c, v3, v4 uintptr + var i, v1 int32 + var l0 Tsize_t + var v2 bool + _, _, _, _, _, _, _ = c, i, l0, v1, v2, v3, v4 + l0 = l + i = 0 + c = (*TFILE)(unsafe.Pointer(f)).Fcookie + if s != (*TFILE)(unsafe.Pointer(f)).Fwbase && _sw_write(tls, f, (*TFILE)(unsafe.Pointer(f)).Fwbase, Uint64FromInt64(int64((*TFILE)(unsafe.Pointer(f)).Fwpos)-int64((*TFILE)(unsafe.Pointer(f)).Fwbase))) == Uint64FromInt32(-Int32FromInt32(1)) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + for { + if v2 = (*Tcookie4)(unsafe.Pointer(c)).Fl != 0 && l != 0; v2 { + v1 = Xmbtowc(tls, (*Tcookie4)(unsafe.Pointer(c)).Fws, s, l) + i = v1 + } + if !(v2 && v1 >= 0) { + break + } + if !(i != 0) { + i = int32(1) + } + s = s + uintptr(i) + l = l - Uint64FromInt32(i) + (*Tcookie4)(unsafe.Pointer(c)).Fl = (*Tcookie4)(unsafe.Pointer(c)).Fl - 1 + (*Tcookie4)(unsafe.Pointer(c)).Fws += 4 + } + **(**Twchar_t)(__ccgo_up((*Tcookie4)(unsafe.Pointer(c)).Fws)) = uint32(0) + if i < 0 { + v4 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Fwend = v4 + v3 = v4 + (*TFILE)(unsafe.Pointer(f)).Fwbase = v3 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v3 + **(**uint32)(__ccgo_up(f)) |= uint32(F_ERR) + return Uint64FromInt32(i) + } + (*TFILE)(unsafe.Pointer(f)).Fwend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr((*TFILE)(unsafe.Pointer(f)).Fbuf_size) + v3 = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Fwbase = v3 + (*TFILE)(unsafe.Pointer(f)).Fwpos = v3 + return l0 +} + +func Xvswprintf(tls *TLS, s uintptr, n Tsize_t, fmt uintptr, ap Tva_list) (r1 int32) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v fmt=%v ap=%v, (%v:)", tls, s, n, fmt, ap, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(512) + defer tls.Free(512) + var r, v1 int32 + var _ /* buf at bp+0 */ [256]uint8 + var _ /* c at bp+256 */ Tcookie4 + var _ /* f at bp+272 */ TFILE + _, _ = r, v1 + **(**Tcookie4)(__ccgo_up(bp + 256)) = Tcookie4{ + Fws: s, + Fl: n - uint64(1), + } + **(**TFILE)(__ccgo_up(bp + 272)) = TFILE{ + Fwrite: __ccgo_fp(_sw_write), + Fbuf: bp, + Fbuf_size: uint64(256), + Flock: -int32(1), + Flbf: -int32(1), + Fcookie: bp + 256, + } + if !(n != 0) { + return -int32(1) + } + r = Xvfwprintf(tls, bp+272, fmt, ap) + _sw_write(tls, bp+272, uintptr(0), uint64(0)) + if Uint64FromInt32(r) >= n { + v1 = -int32(1) + } else { + v1 = r + } + return v1 +} + +func _wstring_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + bp := tls.Alloc(16) + defer tls.Free(16) + var k Tsize_t + var v1, v2 uintptr + var _ /* src at bp+0 */ uintptr + _, _, _ = k, v1, v2 + **(**uintptr)(__ccgo_up(bp)) = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(**(**uintptr)(__ccgo_up(bp)) != 0) { + return uint64(0) + } + k = Xwcsrtombs(tls, (*TFILE)(unsafe.Pointer(f)).Fbuf, bp, (*TFILE)(unsafe.Pointer(f)).Fbuf_size, uintptr(0)) + if k == Uint64FromInt32(-Int32FromInt32(1)) { + v1 = UintptrFromInt32(0) + (*TFILE)(unsafe.Pointer(f)).Frend = v1 + (*TFILE)(unsafe.Pointer(f)).Frpos = v1 + return uint64(0) + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(k) + (*TFILE)(unsafe.Pointer(f)).Fcookie = **(**uintptr)(__ccgo_up(bp)) + if !(len1 != 0) || !(k != 0) { + return uint64(0) + } + v2 = f + 8 + v1 = *(*uintptr)(unsafe.Pointer(v2)) + *(*uintptr)(unsafe.Pointer(v2)) = *(*uintptr)(unsafe.Pointer(v2)) + 1 + **(**uint8)(__ccgo_up(buf)) = **(**uint8)(__ccgo_up(v1)) + return uint64(1) +} + +func Xvswscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(496) + defer tls.Free(496) + var _ /* buf at bp+0 */ [256]uint8 + var _ /* f at bp+256 */ TFILE + **(**TFILE)(__ccgo_up(bp + 256)) = TFILE{ + Fread: __ccgo_fp(_wstring_read), + Fbuf: bp, + Fbuf_size: uint64(256), + Flock: -int32(1), + Fcookie: s, + } + return Xvfwscanf(tls, bp+256, fmt, ap) +} + +func X__isoc99_vswscanf(tls *TLS, s uintptr, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvswscanf(tls, s, fmt, ap) +} + +func Xvwprintf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfwprintf(tls, uintptr(unsafe.Pointer(&X__stdout_FILE)), fmt, ap) +} + +func Xvwscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvfwscanf(tls, uintptr(unsafe.Pointer(&X__stdin_FILE)), fmt, ap) +} + +func X__isoc99_vwscanf(tls *TLS, fmt uintptr, ap Tva_list) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v ap=%v, (%v:)", tls, fmt, ap, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xvwscanf(tls, fmt, ap) +} + +func Xwprintf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvwprintf(tls, fmt, ap) + _ = ap + return ret +} + +func Xwscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ap Tva_list + var ret int32 + _, _ = ap, ret + ap = va + ret = Xvwscanf(tls, fmt, ap) + _ = ap + return ret +} + +func X__isoc99_wscanf(tls *TLS, fmt uintptr, va uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fmt=%v va=%v, (%v:)", tls, fmt, va, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwscanf(tls, fmt, va) +} + +func Xabs(tls *TLS, a int32) (r int32) { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if a > 0 { + v1 = a + } else { + v1 = -a + } + return v1 +} + +func Xatof(tls *TLS, s uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtod(tls, s, uintptr(0)) +} + +func Xatoi(tls *TLS, s uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var n, neg, v1, v2 int32 + var v4 uintptr + _, _, _, _, _ = n, neg, v1, v2, v4 + n = 0 + neg = 0 + for { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if !(v2 != 0) { + break + } + s = s + 1 + } + switch Int32FromUint8(**(**uint8)(__ccgo_up(s))) { + case int32('-'): + neg = int32(1) + fallthrough + case int32('+'): + s = s + 1 + } + /* Compute n as a negative number to avoid overflow on INT_MIN */ + for BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0 { + v4 = s + s = s + 1 + n = int32(10)*n - (Int32FromUint8(**(**uint8)(__ccgo_up(v4))) - int32('0')) + } + if neg != 0 { + v1 = n + } else { + v1 = -n + } + return v1 +} + +func Xatol(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var n, v5 int64 + var neg, v1, v2 int32 + var v4 uintptr + _, _, _, _, _, _ = n, neg, v1, v2, v4, v5 + n = 0 + neg = 0 + for { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if !(v2 != 0) { + break + } + s = s + 1 + } + switch Int32FromUint8(**(**uint8)(__ccgo_up(s))) { + case int32('-'): + neg = int32(1) + fallthrough + case int32('+'): + s = s + 1 + } + /* Compute n as a negative number to avoid overflow on LONG_MIN */ + for BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0 { + v4 = s + s = s + 1 + n = int64(10)*n - int64(Int32FromUint8(**(**uint8)(__ccgo_up(v4)))-Int32FromUint8('0')) + } + if neg != 0 { + v5 = n + } else { + v5 = -n + } + return v5 +} + +func Xatoll(tls *TLS, s uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var n, v5 int64 + var neg, v1, v2 int32 + var v4 uintptr + _, _, _, _, _, _ = n, neg, v1, v2, v4, v5 + n = 0 + neg = 0 + for { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if !(v2 != 0) { + break + } + s = s + 1 + } + switch Int32FromUint8(**(**uint8)(__ccgo_up(s))) { + case int32('-'): + neg = int32(1) + fallthrough + case int32('+'): + s = s + 1 + } + /* Compute n as a negative number to avoid overflow on LLONG_MIN */ + for BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0 { + v4 = s + s = s + 1 + n = int64(10)*n - int64(Int32FromUint8(**(**uint8)(__ccgo_up(v4)))-Int32FromUint8('0')) + } + if neg != 0 { + v5 = n + } else { + v5 = -n + } + return v5 +} + +type t__ccgo_fp__Xbsearch_4 = func(*TLS, uintptr, uintptr) int32 + +func Xbsearch(tls *TLS, key uintptr, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v key=%v base=%v nel=%v width=%v __ccgo_fp_cmp=%v, (%v:)", tls, key, base, nel, width, __ccgo_fp_cmp, origin(2)) + defer func() { trc("-> %v", r) }() + } + var sign int32 + var try uintptr + _, _ = sign, try + for nel > uint64(0) { + try = base + uintptr(width*(nel/uint64(2))) + sign = (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, key, try) + if sign < 0 { + nel = nel / uint64(2) + } else { + if sign > 0 { + base = try + uintptr(width) + nel = nel - (nel/uint64(2) + uint64(1)) + } else { + return try + } + } + } + return UintptrFromInt32(0) +} + +func Xdiv(tls *TLS, num int32, den int32) (r Tdiv_t) { + if __ccgo_strace { + trc("tls=%v num=%v den=%v, (%v:)", tls, num, den, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Tdiv_t{ + Fquot: num / den, + Frem: num % den, + } +} + +func Xecvt(tls *TLS, x float64, n int32, dp uintptr, sign uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v dp=%v sign=%v, (%v:)", tls, x, n, dp, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var i, j, v1 int32 + var _ /* tmp at bp+0 */ [32]uint8 + _, _, _ = i, j, v1 + if Uint32FromInt32(n)-uint32(1) > uint32(15) { + n = int32(15) + } + Xsprintf(tls, bp, __ccgo_ts+1691, VaList(bp+40, n-int32(1), x)) + v1 = BoolInt32(Int32FromUint8((**(**[32]uint8)(__ccgo_up(bp)))[0]) == Int32FromUint8('-')) + **(**int32)(__ccgo_up(sign)) = v1 + i = v1 + j = 0 + for { + if !(Int32FromUint8((**(**[32]uint8)(__ccgo_up(bp)))[i]) != int32('e')) { + break + } + _buf8[j] = (**(**[32]uint8)(__ccgo_up(bp)))[i] + goto _2 + _2: + ; + v1 = i + i = i + 1 + j = j + BoolInt32(Int32FromUint8((**(**[32]uint8)(__ccgo_up(bp)))[v1]) != int32('.')) + } + _buf8[j] = uint8(0) + **(**int32)(__ccgo_up(dp)) = Xatoi(tls, bp+uintptr(i)+uintptr(1)) + int32(1) + return uintptr(unsafe.Pointer(&_buf8)) +} + +var _buf8 [16]uint8 + +func Xfcvt(tls *TLS, x float64, n int32, dp uintptr, sign uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v dp=%v sign=%v, (%v:)", tls, x, n, dp, sign, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(1536) + defer tls.Free(1536) + var i, lz int32 + var _ /* tmp at bp+0 */ [1500]uint8 + _, _ = i, lz + if Uint32FromInt32(n) > uint32(1400) { + n = int32(1400) + } + Xsprintf(tls, bp, __ccgo_ts+1696, VaList(bp+1512, n, x)) + i = BoolInt32(Int32FromUint8((**(**[1500]uint8)(__ccgo_up(bp)))[0]) == int32('-')) + if Int32FromUint8((**(**[1500]uint8)(__ccgo_up(bp)))[i]) == int32('0') { + lz = Int32FromUint64(Xstrspn(tls, bp+uintptr(i)+uintptr(2), __ccgo_ts+1664)) + } else { + lz = -Int32FromUint64(Xstrcspn(tls, bp+uintptr(i), __ccgo_ts+558)) + } + if n <= lz { + **(**int32)(__ccgo_up(sign)) = i + **(**int32)(__ccgo_up(dp)) = int32(1) + if Uint32FromInt32(n) > uint32(14) { + n = int32(14) + } + return __ccgo_ts + 1701 + UintptrFromInt32(14) - uintptr(n) + } + return Xecvt(tls, x, n-lz, dp, sign) +} + +func Xgcvt(tls *TLS, x float64, n int32, b uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v x=%v n=%v b=%v, (%v:)", tls, x, n, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + Xsprintf(tls, b, __ccgo_ts+1717, VaList(bp+8, n, x)) + return b +} + +func Ximaxabs(tls *TLS, a Tintmax_t) (r Tintmax_t) { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if a > 0 { + v1 = a + } else { + v1 = -a + } + return v1 +} + +func Ximaxdiv(tls *TLS, num Tintmax_t, den Tintmax_t) (r Timaxdiv_t) { + if __ccgo_strace { + trc("tls=%v num=%v den=%v, (%v:)", tls, num, den, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Timaxdiv_t{ + Fquot: num / den, + Frem: num % den, + } +} + +func Xlabs(tls *TLS, a int64) (r int64) { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if a > 0 { + v1 = a + } else { + v1 = -a + } + return v1 +} + +func Xldiv(tls *TLS, num int64, den int64) (r Tldiv_t) { + if __ccgo_strace { + trc("tls=%v num=%v den=%v, (%v:)", tls, num, den, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Tldiv_t{ + Fquot: num / den, + Frem: num % den, + } +} + +func Xllabs(tls *TLS, a int64) (r int64) { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int64 + _ = v1 + if a > 0 { + v1 = a + } else { + v1 = -a + } + return v1 +} + +func Xlldiv(tls *TLS, num int64, den int64) (r Tlldiv_t) { + if __ccgo_strace { + trc("tls=%v num=%v den=%v, (%v:)", tls, num, den, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Tlldiv_t{ + Fquot: num / den, + Frem: num % den, + } +} + +type Tcmpfun = uintptr + +func _pntz(tls *TLS, p uintptr) (r1 int32) { + var r, v1 int32 + var v2 bool + _, _, _ = r, v1, v2 + r = _a_ctz_l(tls, **(**Tsize_t)(__ccgo_up(p))-uint64(1)) + if v2 = r != 0; !v2 { + v1 = Int32FromUint64(Uint64FromInt32(8)*Uint64FromInt64(8) + Uint64FromInt32(_a_ctz_l(tls, **(**Tsize_t)(__ccgo_up(p + 1*8))))) + r = v1 + } + if v2 || Uint64FromInt32(v1) != Uint64FromInt32(8)*Uint64FromInt64(8) { + return r + } + return 0 +} + +func _cycle(tls *TLS, width Tsize_t, ar uintptr, n int32) { + bp := tls.Alloc(256) + defer tls.Free(256) + var i int32 + var l Tsize_t + var v1 uint64 + var _ /* tmp at bp+0 */ [256]uint8 + _, _, _ = i, l, v1 + if n < int32(2) { + return + } + **(**uintptr)(__ccgo_up(ar + uintptr(n)*8)) = bp + for width != 0 { + if uint64(256) < width { + v1 = uint64(256) + } else { + v1 = width + } + l = v1 + Xmemcpy(tls, **(**uintptr)(__ccgo_up(ar + uintptr(n)*8)), **(**uintptr)(__ccgo_up(ar)), l) + i = 0 + for { + if !(i < n) { + break + } + Xmemcpy(tls, **(**uintptr)(__ccgo_up(ar + uintptr(i)*8)), **(**uintptr)(__ccgo_up(ar + uintptr(i+int32(1))*8)), l) + **(**uintptr)(__ccgo_up(ar + uintptr(i)*8)) += uintptr(l) + goto _2 + _2: + ; + i = i + 1 + } + width = width - l + } +} + +// C documentation +// +// /* shl() and shr() need n > 0 */ +func _shl(tls *TLS, p uintptr, n int32) { + if Uint64FromInt32(n) >= Uint64FromInt32(8)*Uint64FromInt64(8) { + n = Int32FromUint64(uint64(n) - Uint64FromInt32(8)*Uint64FromInt64(8)) + **(**Tsize_t)(__ccgo_up(p + 1*8)) = **(**Tsize_t)(__ccgo_up(p)) + **(**Tsize_t)(__ccgo_up(p)) = uint64(0) + } + **(**Tsize_t)(__ccgo_up(p + 1*8)) <<= Uint64FromInt32(n) + **(**Tsize_t)(__ccgo_up(p + 1*8)) |= **(**Tsize_t)(__ccgo_up(p)) >> (Uint64FromInt64(8)*Uint64FromInt32(8) - Uint64FromInt32(n)) + **(**Tsize_t)(__ccgo_up(p)) <<= Uint64FromInt32(n) +} + +func _shr(tls *TLS, p uintptr, n int32) { + if Uint64FromInt32(n) >= Uint64FromInt32(8)*Uint64FromInt64(8) { + n = Int32FromUint64(uint64(n) - Uint64FromInt32(8)*Uint64FromInt64(8)) + **(**Tsize_t)(__ccgo_up(p)) = **(**Tsize_t)(__ccgo_up(p + 1*8)) + **(**Tsize_t)(__ccgo_up(p + 1*8)) = uint64(0) + } + **(**Tsize_t)(__ccgo_up(p)) >>= Uint64FromInt32(n) + **(**Tsize_t)(__ccgo_up(p)) |= **(**Tsize_t)(__ccgo_up(p + 1*8)) << (Uint64FromInt64(8)*Uint64FromInt32(8) - Uint64FromInt32(n)) + **(**Tsize_t)(__ccgo_up(p + 1*8)) >>= Uint64FromInt32(n) +} + +func _sift(tls *TLS, head uintptr, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr, pshift int32, lp uintptr) { + bp := tls.Alloc(912) + defer tls.Free(912) + var i, v1 int32 + var lf, rt uintptr + var _ /* ar at bp+0 */ [113]uintptr + _, _, _, _ = i, lf, rt, v1 + i = int32(1) + (**(**[113]uintptr)(__ccgo_up(bp)))[0] = head + for pshift > int32(1) { + rt = head - uintptr(width) + lf = head - uintptr(width) - uintptr(**(**Tsize_t)(__ccgo_up(lp + uintptr(pshift-int32(2))*8))) + if (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, (**(**[113]uintptr)(__ccgo_up(bp)))[0], lf, arg) >= 0 && (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, (**(**[113]uintptr)(__ccgo_up(bp)))[0], rt, arg) >= 0 { + break + } + if (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, lf, rt, arg) >= 0 { + v1 = i + i = i + 1 + (**(**[113]uintptr)(__ccgo_up(bp)))[v1] = lf + head = lf + pshift = pshift - int32(1) + } else { + v1 = i + i = i + 1 + (**(**[113]uintptr)(__ccgo_up(bp)))[v1] = rt + head = rt + pshift = pshift - int32(2) + } + } + _cycle(tls, width, bp, i) +} + +func _trinkle(tls *TLS, head uintptr, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr, pp uintptr, pshift int32, trusty int32, lp uintptr) { + bp := tls.Alloc(928) + defer tls.Free(928) + var i, trail, v1 int32 + var lf, rt, stepson uintptr + var _ /* ar at bp+16 */ [113]uintptr + var _ /* p at bp+0 */ [2]Tsize_t + _, _, _, _, _, _ = i, lf, rt, stepson, trail, v1 + i = int32(1) + (**(**[2]Tsize_t)(__ccgo_up(bp)))[0] = **(**Tsize_t)(__ccgo_up(pp)) + (**(**[2]Tsize_t)(__ccgo_up(bp)))[int32(1)] = **(**Tsize_t)(__ccgo_up(pp + 1*8)) + (**(**[113]uintptr)(__ccgo_up(bp + 16)))[0] = head + for (**(**[2]Tsize_t)(__ccgo_up(bp)))[0] != uint64(1) || (**(**[2]Tsize_t)(__ccgo_up(bp)))[int32(1)] != uint64(0) { + stepson = head - uintptr(**(**Tsize_t)(__ccgo_up(lp + uintptr(pshift)*8))) + if (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, stepson, (**(**[113]uintptr)(__ccgo_up(bp + 16)))[0], arg) <= 0 { + break + } + if !(trusty != 0) && pshift > int32(1) { + rt = head - uintptr(width) + lf = head - uintptr(width) - uintptr(**(**Tsize_t)(__ccgo_up(lp + uintptr(pshift-int32(2))*8))) + if (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, rt, stepson, arg) >= 0 || (*(*func(*TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_cmp})))(tls, lf, stepson, arg) >= 0 { + break + } + } + v1 = i + i = i + 1 + (**(**[113]uintptr)(__ccgo_up(bp + 16)))[v1] = stepson + head = stepson + trail = _pntz(tls, bp) + _shr(tls, bp, trail) + pshift = pshift + trail + trusty = 0 + } + if !(trusty != 0) { + _cycle(tls, width, bp+16, i) + _sift(tls, head, width, __ccgo_fp_cmp, arg, pshift, lp) + } +} + +type t__ccgo_fp__X__qsort_r_3 = func(*TLS, uintptr, uintptr, uintptr) int32 + +func X__qsort_r(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr) { + if __ccgo_strace { + trc("tls=%v base=%v nel=%v width=%v __ccgo_fp_cmp=%v arg=%v, (%v:)", tls, base, nel, width, __ccgo_fp_cmp, arg, origin(2)) + } + bp := tls.Alloc(784) + defer tls.Free(784) + var head, high uintptr + var i, size, v2, v3 Tsize_t + var pshift, trail int32 + var _ /* lp at bp+0 */ [96]Tsize_t + var _ /* p at bp+768 */ [2]Tsize_t + _, _, _, _, _, _, _, _ = head, high, i, pshift, size, trail, v2, v3 + size = width * nel + **(**[2]Tsize_t)(__ccgo_up(bp + 768)) = [2]Tsize_t{ + 0: uint64(1), + } + pshift = int32(1) + if !(size != 0) { + return + } + head = base + high = head + uintptr(size) - uintptr(width) + /* Precompute Leonardo numbers, scaled by element width */ + v2 = width + (**(**[96]Tsize_t)(__ccgo_up(bp)))[int32(1)] = v2 + (**(**[96]Tsize_t)(__ccgo_up(bp)))[0] = v2 + i = Uint64FromInt32(2) + for { + v3 = (**(**[96]Tsize_t)(__ccgo_up(bp)))[i-uint64(2)] + (**(**[96]Tsize_t)(__ccgo_up(bp)))[i-uint64(1)] + width + (**(**[96]Tsize_t)(__ccgo_up(bp)))[i] = v3 + if !(v3 < size) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + for head < high { + if (**(**[2]Tsize_t)(__ccgo_up(bp + 768)))[0]&uint64(3) == uint64(3) { + _sift(tls, head, width, __ccgo_fp_cmp, arg, pshift, bp) + _shr(tls, bp+768, int32(2)) + pshift = pshift + int32(2) + } else { + if (**(**[96]Tsize_t)(__ccgo_up(bp)))[pshift-int32(1)] >= Uint64FromInt64(int64(high)-int64(head)) { + _trinkle(tls, head, width, __ccgo_fp_cmp, arg, bp+768, pshift, 0, bp) + } else { + _sift(tls, head, width, __ccgo_fp_cmp, arg, pshift, bp) + } + if pshift == int32(1) { + _shl(tls, bp+768, int32(1)) + pshift = 0 + } else { + _shl(tls, bp+768, pshift-int32(1)) + pshift = int32(1) + } + } + **(**Tsize_t)(__ccgo_up(bp + 768)) |= uint64(1) + head = head + uintptr(width) + } + _trinkle(tls, head, width, __ccgo_fp_cmp, arg, bp+768, pshift, 0, bp) + for pshift != int32(1) || (**(**[2]Tsize_t)(__ccgo_up(bp + 768)))[0] != uint64(1) || (**(**[2]Tsize_t)(__ccgo_up(bp + 768)))[int32(1)] != uint64(0) { + if pshift <= int32(1) { + trail = _pntz(tls, bp+768) + _shr(tls, bp+768, trail) + pshift = pshift + trail + } else { + _shl(tls, bp+768, int32(2)) + pshift = pshift - int32(2) + **(**Tsize_t)(__ccgo_up(bp + 768)) ^= uint64(7) + _shr(tls, bp+768, int32(1)) + _trinkle(tls, head-uintptr((**(**[96]Tsize_t)(__ccgo_up(bp)))[pshift])-uintptr(width), width, __ccgo_fp_cmp, arg, bp+768, pshift+int32(1), int32(1), bp) + _shl(tls, bp+768, int32(1)) + **(**Tsize_t)(__ccgo_up(bp + 768)) |= uint64(1) + _trinkle(tls, head-uintptr(width), width, __ccgo_fp_cmp, arg, bp+768, pshift, int32(1), bp) + } + head = head - uintptr(width) + } +} + +type t__ccgo_fp__Xqsort_r_3 = func(*TLS, uintptr, uintptr, uintptr) int32 + +func Xqsort_r(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun, arg uintptr) { + if __ccgo_strace { + trc("tls=%v base=%v nel=%v width=%v __ccgo_fp_cmp=%v arg=%v, (%v:)", tls, base, nel, width, __ccgo_fp_cmp, arg, origin(2)) + } + X__qsort_r(tls, base, nel, width, __ccgo_fp_cmp, arg) +} + +func _wrapper_cmp(tls *TLS, v1 uintptr, v2 uintptr, cmp uintptr) (r int32) { + return (*(*func(*TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{cmp})))(tls, v1, v2) +} + +type t__ccgo_fp__Xqsort_3 = func(*TLS, uintptr, uintptr) int32 + +func Xqsort(tls *TLS, base uintptr, nel Tsize_t, width Tsize_t, __ccgo_fp_cmp Tcmpfun) { + if __ccgo_strace { + trc("tls=%v base=%v nel=%v width=%v __ccgo_fp_cmp=%v, (%v:)", tls, base, nel, width, __ccgo_fp_cmp, origin(2)) + } + X__qsort_r(tls, base, nel, width, __ccgo_fp(_wrapper_cmp), __ccgo_fp_cmp) +} + +func _strtox(tls *TLS, s uintptr, p uintptr, prec int32) (r float64) { + bp := tls.Alloc(240) + defer tls.Free(240) + var cnt Toff_t + var y float64 + var v1 uintptr + var _ /* f at bp+0 */ TFILE + _, _, _ = cnt, y, v1 + v1 = s + (*TFILE)(unsafe.Pointer(bp)).Frpos = v1 + (*TFILE)(unsafe.Pointer(bp)).Fbuf = v1 + (*TFILE)(unsafe.Pointer(bp)).Frend = uintptr(-Int32FromInt32(1)) + X__shlim(tls, bp, int64(Int32FromInt32(0))) + y = X__floatscan(tls, bp, prec, int32(1)) + cnt = (*TFILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(bp)).Frpos) - int64((*TFILE)(unsafe.Pointer(bp)).Fbuf)) + if p != 0 { + if cnt != 0 { + v1 = s + uintptr(cnt) + } else { + v1 = s + } + **(**uintptr)(__ccgo_up(p)) = v1 + } + return y +} + +func Xstrtof(tls *TLS, s uintptr, p uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float32(_strtox(tls, s, p, 0)) +} + +func Xstrtod(tls *TLS, s uintptr, p uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _strtox(tls, s, p, int32(1)) +} + +func Xstrtold(tls *TLS, s uintptr, p uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _strtox(tls, s, p, int32(2)) +} + +func _strtox1(tls *TLS, s uintptr, p uintptr, base int32, lim uint64) (r uint64) { + bp := tls.Alloc(240) + defer tls.Free(240) + var cnt Tsize_t + var y uint64 + var v1 uintptr + var _ /* f at bp+0 */ TFILE + _, _, _ = cnt, y, v1 + v1 = s + (*TFILE)(unsafe.Pointer(bp)).Frpos = v1 + (*TFILE)(unsafe.Pointer(bp)).Fbuf = v1 + (*TFILE)(unsafe.Pointer(bp)).Frend = uintptr(-Int32FromInt32(1)) + X__shlim(tls, bp, int64(Int32FromInt32(0))) + y = X__intscan(tls, bp, Uint32FromInt32(base), int32(1), lim) + if p != 0 { + cnt = Uint64FromInt64((*TFILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(bp)).Frpos) - int64((*TFILE)(unsafe.Pointer(bp)).Fbuf))) + **(**uintptr)(__ccgo_up(p)) = s + uintptr(cnt) + } + return y +} + +func Xstrtoull(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _strtox1(tls, s, p, base, Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)) +} + +func Xstrtoll(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(_strtox1(tls, s, p, base, Uint64FromInt64(-Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1)))) +} + +func Xstrtoul(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _strtox1(tls, s, p, base, uint64(Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1))) +} + +func Xstrtol(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(_strtox1(tls, s, p, base, uint64(Uint64FromUint64(0)+Uint64FromInt64(-Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1))))) +} + +func Xstrtoimax(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoll(tls, s, p, base) +} + +func Xstrtoumax(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoull(tls, s, p, base) +} + +func X__strtoimax_internal(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoimax(tls, s, p, base) +} + +func X__strtol_internal(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtol(tls, s, p, base) +} + +func X__strtoll_internal(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoll(tls, s, p, base) +} + +func X__strtoul_internal(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoul(tls, s, p, base) +} + +func X__strtoull_internal(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoull(tls, s, p, base) +} + +func X__strtoumax_internal(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrtoumax(tls, s, p, base) +} + +/* This read function heavily cheats. It knows: + * (1) len will always be 1 + * (2) non-ascii characters don't matter */ + +func _do_read(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var i Tsize_t + var wcs, v3, v4 uintptr + var v2 uint32 + _, _, _, _, _ = i, wcs, v2, v3, v4 + wcs = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(**(**Twchar_t)(__ccgo_up(wcs)) != 0) { + wcs = __ccgo_ts + 1722 + } + i = uint64(0) + for { + if !(i < (*TFILE)(unsafe.Pointer(f)).Fbuf_size && **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) != 0) { + break + } + if **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) < uint32(128) { + v2 = **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) + } else { + v2 = uint32('@') + } + **(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(i))) = uint8(v2) + goto _1 + _1: + ; + i = i + 1 + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(i) + (*TFILE)(unsafe.Pointer(f)).Fcookie = wcs + uintptr(i)*4 + if i != 0 && len1 != 0 { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(buf)) = **(**uint8)(__ccgo_up(v3)) + return uint64(1) + } + return uint64(0) +} + +func _wcstox(tls *TLS, s uintptr, p uintptr, prec int32) (r float64) { + bp := tls.Alloc(304) + defer tls.Free(304) + var cnt Tsize_t + var t, v1, v2 uintptr + var y float64 + var _ /* buf at bp+0 */ [64]uint8 + var _ /* f at bp+64 */ TFILE + _, _, _, _, _ = cnt, t, y, v1, v2 + t = s + **(**TFILE)(__ccgo_up(bp + 64)) = TFILE{} + (**(**TFILE)(__ccgo_up(bp + 64))).Fflags = uint32(0) + v2 = bp + UintptrFromInt32(4) + (**(**TFILE)(__ccgo_up(bp + 64))).Fbuf = v2 + v1 = v2 + (**(**TFILE)(__ccgo_up(bp + 64))).Frend = v1 + (**(**TFILE)(__ccgo_up(bp + 64))).Frpos = v1 + (**(**TFILE)(__ccgo_up(bp + 64))).Fbuf_size = Uint64FromInt64(64) - Uint64FromInt32(4) + AtomicStorePInt32(bp+64+140, -int32(1)) + (**(**TFILE)(__ccgo_up(bp + 64))).Fread = __ccgo_fp(_do_read) + for Xiswspace(tls, **(**Twchar_t)(__ccgo_up(t))) != 0 { + t += 4 + } + (**(**TFILE)(__ccgo_up(bp + 64))).Fcookie = t + X__shlim(tls, bp+64, int64(Int32FromInt32(0))) + y = X__floatscan(tls, bp+64, prec, int32(1)) + if p != 0 { + cnt = Uint64FromInt64((*TFILE)(unsafe.Pointer(bp+64)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(bp+64)).Frpos) - int64((*TFILE)(unsafe.Pointer(bp+64)).Fbuf))) + if cnt != 0 { + v1 = t + uintptr(cnt)*4 + } else { + v1 = s + } + **(**uintptr)(__ccgo_up(p)) = v1 + } + return y +} + +func Xwcstof(tls *TLS, s uintptr, p uintptr) (r float32) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float32(_wcstox(tls, s, p, 0)) +} + +func Xwcstod(tls *TLS, s uintptr, p uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _wcstox(tls, s, p, int32(1)) +} + +func Xwcstold(tls *TLS, s uintptr, p uintptr) (r float64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _wcstox(tls, s, p, int32(2)) +} + +/* This read function heavily cheats. It knows: + * (1) len will always be 1 + * (2) non-ascii characters don't matter */ + +func _do_read1(tls *TLS, f uintptr, buf uintptr, len1 Tsize_t) (r Tsize_t) { + var i Tsize_t + var wcs, v3, v4 uintptr + var v2 uint32 + _, _, _, _, _ = i, wcs, v2, v3, v4 + wcs = (*TFILE)(unsafe.Pointer(f)).Fcookie + if !(**(**Twchar_t)(__ccgo_up(wcs)) != 0) { + wcs = __ccgo_ts + 1722 + } + i = uint64(0) + for { + if !(i < (*TFILE)(unsafe.Pointer(f)).Fbuf_size && **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) != 0) { + break + } + if **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) < uint32(128) { + v2 = **(**Twchar_t)(__ccgo_up(wcs + uintptr(i)*4)) + } else { + v2 = uint32('@') + } + **(**uint8)(__ccgo_up((*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(i))) = uint8(v2) + goto _1 + _1: + ; + i = i + 1 + } + (*TFILE)(unsafe.Pointer(f)).Frpos = (*TFILE)(unsafe.Pointer(f)).Fbuf + (*TFILE)(unsafe.Pointer(f)).Frend = (*TFILE)(unsafe.Pointer(f)).Fbuf + uintptr(i) + (*TFILE)(unsafe.Pointer(f)).Fcookie = wcs + uintptr(i)*4 + if i != 0 && len1 != 0 { + v4 = f + 8 + v3 = *(*uintptr)(unsafe.Pointer(v4)) + *(*uintptr)(unsafe.Pointer(v4)) = *(*uintptr)(unsafe.Pointer(v4)) + 1 + **(**uint8)(__ccgo_up(buf)) = **(**uint8)(__ccgo_up(v3)) + return uint64(1) + } + return uint64(0) +} + +func _wcstox1(tls *TLS, s uintptr, p uintptr, base int32, lim uint64) (r uint64) { + bp := tls.Alloc(304) + defer tls.Free(304) + var cnt Tsize_t + var t, v1, v2 uintptr + var y uint64 + var _ /* buf at bp+0 */ [64]uint8 + var _ /* f at bp+64 */ TFILE + _, _, _, _, _ = cnt, t, y, v1, v2 + t = s + **(**TFILE)(__ccgo_up(bp + 64)) = TFILE{} + (**(**TFILE)(__ccgo_up(bp + 64))).Fflags = uint32(0) + v2 = bp + UintptrFromInt32(4) + (**(**TFILE)(__ccgo_up(bp + 64))).Fbuf = v2 + v1 = v2 + (**(**TFILE)(__ccgo_up(bp + 64))).Frend = v1 + (**(**TFILE)(__ccgo_up(bp + 64))).Frpos = v1 + (**(**TFILE)(__ccgo_up(bp + 64))).Fbuf_size = Uint64FromInt64(64) - Uint64FromInt32(4) + AtomicStorePInt32(bp+64+140, -int32(1)) + (**(**TFILE)(__ccgo_up(bp + 64))).Fread = __ccgo_fp(_do_read1) + for Xiswspace(tls, **(**Twchar_t)(__ccgo_up(t))) != 0 { + t += 4 + } + (**(**TFILE)(__ccgo_up(bp + 64))).Fcookie = t + X__shlim(tls, bp+64, int64(Int32FromInt32(0))) + y = X__intscan(tls, bp+64, Uint32FromInt32(base), int32(1), lim) + if p != 0 { + cnt = Uint64FromInt64((*TFILE)(unsafe.Pointer(bp+64)).Fshcnt + (int64((*TFILE)(unsafe.Pointer(bp+64)).Frpos) - int64((*TFILE)(unsafe.Pointer(bp+64)).Fbuf))) + if cnt != 0 { + v1 = t + uintptr(cnt)*4 + } else { + v1 = s + } + **(**uintptr)(__ccgo_up(p)) = v1 + } + return y +} + +func Xwcstoull(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _wcstox1(tls, s, p, base, Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1)) +} + +func Xwcstoll(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(_wcstox1(tls, s, p, base, Uint64FromInt64(-Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1)))) +} + +func Xwcstoul(tls *TLS, s uintptr, p uintptr, base int32) (r uint64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return _wcstox1(tls, s, p, base, uint64(Uint64FromUint64(2)*Uint64FromInt64(0x7fffffffffffffff)+Uint64FromInt32(1))) +} + +func Xwcstol(tls *TLS, s uintptr, p uintptr, base int32) (r int64) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Int64FromUint64(_wcstox1(tls, s, p, base, uint64(Uint64FromUint64(0)+Uint64FromInt64(-Int64FromInt64(0x7fffffffffffffff)-Int64FromInt32(1))))) +} + +func Xwcstoimax(tls *TLS, s uintptr, p uintptr, base int32) (r Tintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcstoll(tls, s, p, base) +} + +func Xwcstoumax(tls *TLS, s uintptr, p uintptr, base int32) (r Tuintmax_t) { + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcstoull(tls, s, p, base) +} + +func Xbcmp(tls *TLS, s1 uintptr, s2 uintptr, n Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v s1=%v s2=%v n=%v, (%v:)", tls, s1, s2, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmemcmp(tls, s1, s2, n) +} + +func Xbcopy(tls *TLS, s1 uintptr, s2 uintptr, n Tsize_t) { + if __ccgo_strace { + trc("tls=%v s1=%v s2=%v n=%v, (%v:)", tls, s1, s2, n, origin(2)) + } + Xmemmove(tls, s2, s1, n) +} + +func Xbzero(tls *TLS, s uintptr, n Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + } + Xmemset(tls, s, 0, n) +} + +func Xexplicit_bzero(tls *TLS, d uintptr, n Tsize_t) { + if __ccgo_strace { + trc("tls=%v d=%v n=%v, (%v:)", tls, d, n, origin(2)) + } + d = Xmemset(tls, d, 0, n) +} + +func Xindex(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrchr(tls, s, c) +} + +const ALIGN1 = -1 +const HIGHS = 0 +const ONES = 0 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xmemccpy(tls *TLS, dest uintptr, src uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v c=%v n=%v, (%v:)", tls, dest, src, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d, s, wd, ws uintptr + var k Tsize_t + var v2 uint8 + var v3 bool + _, _, _, _, _, _, _ = d, k, s, wd, ws, v2, v3 + d = dest + s = src + c = Int32FromUint8(Uint8FromInt32(c)) + if uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) == uint64(d)&(Uint64FromInt64(8)-Uint64FromInt32(1)) { + for { + if v3 = uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 && n != 0; v3 { + v2 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v2 + } + if !(v3 && Int32FromUint8(v2) != c) { + break + } + goto _1 + _1: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + if uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 { + goto tail + } + k = Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(UCHAR_MAX) * Uint64FromInt32(c) + wd = d + ws = s + for { + if !(n >= uint64(8) && !((**(**uint64)(__ccgo_up(ws))^k-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^(**(**uint64)(__ccgo_up(ws))^k) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + **(**uint64)(__ccgo_up(wd)) = **(**uint64)(__ccgo_up(ws)) + goto _4 + _4: + ; + n = n - uint64(8) + ws += 8 + wd += 8 + } + d = wd + s = ws + } + for { + if v3 = n != 0; v3 { + v2 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v2 + } + if !(v3 && Int32FromUint8(v2) != c) { + break + } + goto _5 + _5: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + goto tail +tail: + ; + if n != 0 { + return d + uintptr(1) + } + return uintptr(0) +} + +const SS = 0 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xmemchr(tls *TLS, src uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v src=%v c=%v n=%v, (%v:)", tls, src, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k Tsize_t + var s, w, v4 uintptr + _, _, _, _ = k, s, w, v4 + s = src + c = Int32FromUint8(Uint8FromInt32(c)) + for { + if !(uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 && n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != c) { + break + } + goto _1 + _1: + ; + s = s + 1 + n = n - 1 + } + if n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != c { + k = Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(UCHAR_MAX) * Uint64FromInt32(c) + w = s + for { + if !(n >= Uint64FromInt64(8) && !((**(**uint64)(__ccgo_up(w))^k-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^(**(**uint64)(__ccgo_up(w))^k) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + goto _2 + _2: + ; + w += 8 + n = n - Uint64FromInt64(8) + } + s = w + } + for { + if !(n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != c) { + break + } + goto _3 + _3: + ; + s = s + 1 + n = n - 1 + } + if n != 0 { + v4 = s + } else { + v4 = uintptr(0) + } + return v4 +} + +func Xmemcmp(tls *TLS, vl uintptr, vr uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v vl=%v vr=%v n=%v, (%v:)", tls, vl, vr, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var l, r uintptr + var v2 int32 + _, _, _ = l, r, v2 + l = vl + r = vr + for { + if !(n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r)))) { + break + } + goto _1 + _1: + ; + n = n - 1 + l = l + 1 + r = r + 1 + } + if n != 0 { + v2 = Int32FromUint8(**(**uint8)(__ccgo_up(l))) - Int32FromUint8(**(**uint8)(__ccgo_up(r))) + } else { + v2 = 0 + } + return v2 +} + +const LS = 0 +const RS = 0 + +func Xmemcpy(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d, s, v2, v3 uintptr + var w, x Tuint32_t + _, _, _, _, _, _ = d, s, w, x, v2, v3 + d = dest + s = src + for { + if !(uint64(s)%uint64(4) != 0 && n != 0) { + break + } + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + goto _1 + _1: + ; + n = n - 1 + } + if uint64(d)%uint64(4) == uint64(0) { + for { + if !(n >= uint64(16)) { + break + } + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(0))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(4))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(4))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(8))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(8))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(12))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(12))) + goto _4 + _4: + ; + s = s + uintptr(16) + d = d + uintptr(16) + n = n - uint64(16) + } + if n&uint64(8) != 0 { + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(0))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(4))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(4))) + d = d + uintptr(8) + s = s + uintptr(8) + } + if n&uint64(4) != 0 { + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = **(**uint32)(__ccgo_up(s + UintptrFromInt32(0))) + d = d + uintptr(4) + s = s + uintptr(4) + } + if n&uint64(2) != 0 { + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + } + if n&uint64(1) != 0 { + **(**uint8)(__ccgo_up(d)) = **(**uint8)(__ccgo_up(s)) + } + return dest + } + if n >= uint64(32) { + switch uint64(d) % Uint64FromInt32(4) { + case uint64(1): + w = **(**uint32)(__ccgo_up(s)) + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + n = n - uint64(3) + for { + if !(n >= uint64(17)) { + break + } + x = **(**uint32)(__ccgo_up(s + UintptrFromInt32(1))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = w>>Int32FromInt32(24) | x<>Int32FromInt32(24) | w<>Int32FromInt32(24) | x<>Int32FromInt32(24) | w<= uint64(18)) { + break + } + x = **(**uint32)(__ccgo_up(s + UintptrFromInt32(2))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = w>>Int32FromInt32(16) | x<>Int32FromInt32(16) | w<>Int32FromInt32(16) | x<>Int32FromInt32(16) | w<= uint64(19)) { + break + } + x = **(**uint32)(__ccgo_up(s + UintptrFromInt32(3))) + **(**uint32)(__ccgo_up(d + UintptrFromInt32(0))) = w>>Int32FromInt32(8) | x<>Int32FromInt32(8) | w<>Int32FromInt32(8) | x<>Int32FromInt32(8) | w< Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + ms = ip + p0 = p + /* And with the opposite comparison */ + ip = Uint64FromInt32(-Int32FromInt32(1)) + jp = uint64(0) + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + for jp+k < l { + if Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(ip+k)))) == Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + if k == p { + jp = jp + p + k = uint64(1) + } else { + k = k + 1 + } + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(ip+k)))) < Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + if ip+uint64(1) > ms+uint64(1) { + ms = ip + } else { + p = p0 + } + /* Periodic needle? */ + if Xmemcmp(tls, n, n+uintptr(p), ms+uint64(1)) != 0 { + mem0 = uint64(0) + if ms > l-ms-uint64(1) { + v8 = ms + } else { + v8 = l - ms - uint64(1) + } + p = v8 + uint64(1) + } else { + mem0 = l - p + } + mem = uint64(0) + /* Search loop */ + for { + /* If remainder of haystack is shorter than needle, done */ + if Uint64FromInt64(int64(z)-int64(h)) < l { + return uintptr(0) + } + /* Check last byte first; advance by shift on mismatch */ + if (**(**[4]Tsize_t)(__ccgo_up(bp)))[uint64(**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1)))))/(Uint64FromInt32(8)*Uint64FromInt64(8))]&(Uint64FromInt32(1)<<(uint64(**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1)))))%(Uint64FromInt32(8)*Uint64FromInt64(8)))) != 0 { + k = l - shift[**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1))))] + if k != 0 { + if k < mem { + k = mem + } + h = h + uintptr(k) + mem = uint64(0) + goto _9 + } + } else { + h = h + uintptr(l) + mem = uint64(0) + goto _9 + } + /* Compare right half */ + if ms+uint64(1) > mem { + v8 = ms + uint64(1) + } else { + v8 = mem + } + k = v8 + for { + if !(k < l && Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(k)))) == Int32FromUint8(**(**uint8)(__ccgo_up(h + uintptr(k))))) { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if k < l { + h = h + uintptr(k-ms) + mem = uint64(0) + goto _9 + } + /* Compare left half */ + k = ms + uint64(1) + for { + if !(k > mem && Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(k-uint64(1))))) == Int32FromUint8(**(**uint8)(__ccgo_up(h + uintptr(k-uint64(1)))))) { + break + } + goto _12 + _12: + ; + k = k - 1 + } + if k <= mem { + return h + } + h = h + uintptr(p) + mem = mem0 + goto _9 + _9: + } + return r +} + +func Xmemmem(tls *TLS, h0 uintptr, k Tsize_t, n0 uintptr, l Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v h0=%v k=%v n0=%v l=%v, (%v:)", tls, h0, k, n0, l, origin(2)) + defer func() { trc("-> %v", r) }() + } + var h, n uintptr + _, _ = h, n + h = h0 + n = n0 + /* Return immediately on empty needle */ + if !(l != 0) { + return h + } + /* Return immediately when needle is longer than haystack */ + if k < l { + return uintptr(0) + } + /* Use faster algorithms for short needles */ + h = Xmemchr(tls, h0, Int32FromUint8(**(**uint8)(__ccgo_up(n))), k) + if !(h != 0) || l == uint64(1) { + return h + } + k = k - Uint64FromInt64(int64(h)-int64(h0)) + if k < l { + return uintptr(0) + } + if l == uint64(2) { + return _twobyte_memmem(tls, h, k, n) + } + if l == uint64(3) { + return _threebyte_memmem(tls, h, k, n) + } + if l == uint64(4) { + return _fourbyte_memmem(tls, h, k, n) + } + return _twoway_memmem(tls, h, h+uintptr(k), n, l) +} + +const WS = 0 + +type TWT = uint64 + +func Xmemmove(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d, s, v2, v3 uintptr + var v1 Tsize_t + _, _, _, _, _ = d, s, v1, v2, v3 + d = dest + s = src + if d == s { + return d + } + if uint64(s)-uint64(d)-n <= Uint64FromInt32(-Int32FromInt32(2))*n { + return Xmemcpy(tls, d, s, n) + } + if d < s { + if uint64(s)%Uint64FromInt64(8) == uint64(d)%Uint64FromInt64(8) { + for uint64(d)%Uint64FromInt64(8) != 0 { + v1 = n + n = n - 1 + if !(v1 != 0) { + return dest + } + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + } + for { + if !(n >= Uint64FromInt64(8)) { + break + } + **(**TWT)(__ccgo_up(d)) = **(**TWT)(__ccgo_up(s)) + goto _4 + _4: + ; + n = n - Uint64FromInt64(8) + d = d + uintptr(Uint64FromInt64(8)) + s = s + uintptr(Uint64FromInt64(8)) + } + } + for { + if !(n != 0) { + break + } + v2 = d + d = d + 1 + v3 = s + s = s + 1 + **(**uint8)(__ccgo_up(v2)) = **(**uint8)(__ccgo_up(v3)) + goto _5 + _5: + ; + n = n - 1 + } + } else { + if uint64(s)%Uint64FromInt64(8) == uint64(d)%Uint64FromInt64(8) { + for uint64(d+uintptr(n))%Uint64FromInt64(8) != 0 { + v1 = n + n = n - 1 + if !(v1 != 0) { + return dest + } + **(**uint8)(__ccgo_up(d + uintptr(n))) = **(**uint8)(__ccgo_up(s + uintptr(n))) + } + for n >= Uint64FromInt64(8) { + n = n - Uint64FromInt64(8) + **(**TWT)(__ccgo_up(d + uintptr(n))) = **(**TWT)(__ccgo_up(s + uintptr(n))) + } + } + for n != 0 { + n = n - 1 + **(**uint8)(__ccgo_up(d + uintptr(n))) = **(**uint8)(__ccgo_up(s + uintptr(n))) + } + } + return dest +} + +func Xmempcpy(tls *TLS, dest uintptr, src uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v n=%v, (%v:)", tls, dest, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmemcpy(tls, dest, src, n) + uintptr(n) +} + +func X__memrchr(tls *TLS, m uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v m=%v c=%v n=%v, (%v:)", tls, m, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + var v1 Tsize_t + _, _ = s, v1 + s = m + c = Int32FromUint8(Uint8FromInt32(c)) + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + if Int32FromUint8(**(**uint8)(__ccgo_up(s + uintptr(n)))) == c { + return s + uintptr(n) + } + } + return uintptr(0) +} + +func Xmemrchr(tls *TLS, m uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v m=%v c=%v n=%v, (%v:)", tls, m, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__memrchr(tls, m, c, n) +} + +func Xmemset(tls *TLS, dest uintptr, c int32, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v c=%v n=%v, (%v:)", tls, dest, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c32 uint32 + var c64 uint64 + var k Tsize_t + var s uintptr + _, _, _, _ = c32, c64, k, s + s = dest + /* Fill head and tail with minimal branching. Each + * conditional ensures that all the subsequently used + * offsets are well-defined and in the dest region. */ + if !(n != 0) { + return dest + } + **(**uint8)(__ccgo_up(s)) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + uintptr(n-uint64(1)))) = Uint8FromInt32(c) + if n <= uint64(2) { + return dest + } + **(**uint8)(__ccgo_up(s + 1)) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + 2)) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + uintptr(n-uint64(2)))) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + uintptr(n-uint64(3)))) = Uint8FromInt32(c) + if n <= uint64(6) { + return dest + } + **(**uint8)(__ccgo_up(s + 3)) = Uint8FromInt32(c) + **(**uint8)(__ccgo_up(s + uintptr(n-uint64(4)))) = Uint8FromInt32(c) + if n <= uint64(8) { + return dest + } + /* Advance pointer to align it at a 4-byte boundary, + * and truncate n to a multiple of 4. The previous code + * already took care of any head/tail that get cut off + * by the alignment. */ + k = -uint64(s) & uint64(3) + s = s + uintptr(k) + n = n - k + n = n & Uint64FromInt32(-Int32FromInt32(4)) + c32 = Uint32FromInt32(-Int32FromInt32(1)) / Uint32FromInt32(255) * uint32(Uint8FromInt32(c)) + /* In preparation to copy 32 bytes at a time, aligned on + * an 8-byte bounary, fill head/tail up to 28 bytes each. + * As in the initial byte-based head/tail fill, each + * conditional below ensures that the subsequent offsets + * are valid (e.g. !(n<=24) implies n>=28). */ + **(**uint32)(__ccgo_up(s + UintptrFromInt32(0))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(4))) = c32 + if n <= uint64(8) { + return dest + } + **(**uint32)(__ccgo_up(s + UintptrFromInt32(4))) = c32 + **(**uint32)(__ccgo_up(s + UintptrFromInt32(8))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(12))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(8))) = c32 + if n <= uint64(24) { + return dest + } + **(**uint32)(__ccgo_up(s + UintptrFromInt32(12))) = c32 + **(**uint32)(__ccgo_up(s + UintptrFromInt32(16))) = c32 + **(**uint32)(__ccgo_up(s + UintptrFromInt32(20))) = c32 + **(**uint32)(__ccgo_up(s + UintptrFromInt32(24))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(28))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(24))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(20))) = c32 + **(**uint32)(__ccgo_up(s + uintptr(n) - UintptrFromInt32(16))) = c32 + /* Align to a multiple of 8 so we can fill 64 bits at a time, + * and avoid writing the same bytes twice as much as is + * practical without introducing additional branching. */ + k = uint64(24) + uint64(s)&uint64(4) + s = s + uintptr(k) + n = n - k + /* If this loop is reached, 28 tail bytes have already been + * filled, so any remainder when n drops below 32 can be + * safely ignored. */ + c64 = uint64(c32) | uint64(c32)<= uint64(32)) { + break + } + **(**uint64)(__ccgo_up(s + UintptrFromInt32(0))) = c64 + **(**uint64)(__ccgo_up(s + UintptrFromInt32(8))) = c64 + **(**uint64)(__ccgo_up(s + UintptrFromInt32(16))) = c64 + **(**uint64)(__ccgo_up(s + UintptrFromInt32(24))) = c64 + goto _1 + _1: + ; + n = n - uint64(32) + s = s + uintptr(32) + } + return dest +} + +func Xrindex(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrrchr(tls, s, c) +} + +const ALIGN2 = 0 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__stpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v, (%v:)", tls, d, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var wd, ws, v4, v5 uintptr + var v2 uint8 + _, _, _, _, _ = wd, ws, v2, v4, v5 + if uint64(s)%Uint64FromInt64(8) == uint64(d)%Uint64FromInt64(8) { + for { + if !(uint64(s)%Uint64FromInt64(8) != 0) { + break + } + v2 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v2 + if !(v2 != 0) { + return d + } + goto _1 + _1: + ; + s = s + 1 + d = d + 1 + } + wd = d + ws = s + for { + if !!((**(**uint64)(__ccgo_up(ws))-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^**(**uint64)(__ccgo_up(ws)) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0) { + break + } + goto _3 + _3: + ; + v4 = wd + wd += 8 + v5 = ws + ws += 8 + **(**uint64)(__ccgo_up(v4)) = **(**uint64)(__ccgo_up(v5)) + } + d = wd + s = ws + } + for { + v2 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v2 + if !(v2 != 0) { + break + } + goto _6 + _6: + ; + s = s + 1 + d = d + 1 + } + return d +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xstpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v, (%v:)", tls, d, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__stpcpy(tls, d, s) +} + +const ALIGN3 = -1 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__stpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var wd, ws uintptr + var v2 uint8 + var v3 bool + _, _, _, _ = wd, ws, v2, v3 + if uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) == uint64(d)&(Uint64FromInt64(8)-Uint64FromInt32(1)) { + for { + if v3 = uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 && n != 0; v3 { + v2 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v2 + } + if !(v3 && v2 != 0) { + break + } + goto _1 + _1: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + if !(n != 0) || !(**(**uint8)(__ccgo_up(s)) != 0) { + goto tail + } + wd = d + ws = s + for { + if !(n >= uint64(8) && !((**(**uint64)(__ccgo_up(ws))-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^**(**uint64)(__ccgo_up(ws)) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + **(**uint64)(__ccgo_up(wd)) = **(**uint64)(__ccgo_up(ws)) + goto _4 + _4: + ; + n = n - uint64(8) + ws += 8 + wd += 8 + } + d = wd + s = ws + } + for { + if v3 = n != 0; v3 { + v2 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v2 + } + if !(v3 && v2 != 0) { + break + } + goto _5 + _5: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + goto tail +tail: + ; + Xmemset(tls, d, 0, n) + return d +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xstpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__stpncpy(tls, d, s, n) +} + +func Xstrcasecmp(tls *TLS, _l uintptr, _r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v _l=%v _r=%v, (%v:)", tls, _l, _r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var l, r uintptr + _, _ = l, r + l = _l + r = _r + for { + if !(**(**uint8)(__ccgo_up(l)) != 0 && **(**uint8)(__ccgo_up(r)) != 0 && (Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r))) || Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(l)))) == Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(r)))))) { + break + } + goto _1 + _1: + ; + l = l + 1 + r = r + 1 + } + return Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(l)))) - Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(r)))) +} + +func X__strcasecmp_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v loc=%v, (%v:)", tls, l, r, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xstrcasecmp(tls, l, r) +} + +func Xstrcasecmp_l(tls *TLS, l uintptr, r uintptr, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v loc=%v, (%v:)", tls, l, r, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__strcasecmp_l(tls, l, r, loc) +} + +func Xstrcasestr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v h=%v n=%v, (%v:)", tls, h, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = _strlen(tls, n) + for { + if !(**(**uint8)(__ccgo_up(h)) != 0) { + break + } + if !(Xstrncasecmp(tls, h, n, l) != 0) { + return h + } + goto _1 + _1: + ; + h = h + 1 + } + return uintptr(0) +} + +func Xstrcat(tls *TLS, dest uintptr, src uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v, (%v:)", tls, dest, src, origin(2)) + defer func() { trc("-> %v", r) }() + } + Xstrcpy(tls, dest+uintptr(_strlen(tls, dest)), src) + return dest +} + +func Xstrchr(tls *TLS, s uintptr, c int32) (r1 uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v1 uintptr + _, _ = r, v1 + r = X__strchrnul(tls, s, c) + if Int32FromUint8(**(**uint8)(__ccgo_up(r))) == Int32FromUint8(Uint8FromInt32(c)) { + v1 = r + } else { + v1 = uintptr(0) + } + return v1 +} + +const ALIGN4 = 0 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__strchrnul(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k Tsize_t + var w uintptr + _, _ = k, w + c = Int32FromUint8(Uint8FromInt32(c)) + if !(c != 0) { + return s + uintptr(_strlen(tls, s)) + } + for { + if !(uint64(s)%Uint64FromInt64(8) != 0) { + break + } + if !(**(**uint8)(__ccgo_up(s)) != 0) || Int32FromUint8(**(**uint8)(__ccgo_up(s))) == c { + return s + } + goto _1 + _1: + ; + s = s + 1 + } + k = Uint64FromInt32(-Int32FromInt32(1)) / Uint64FromInt32(UCHAR_MAX) * Uint64FromInt32(c) + w = s + for { + if !(!((**(**uint64)(__ccgo_up(w))-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^**(**uint64)(__ccgo_up(w)) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0) && !((**(**uint64)(__ccgo_up(w))^k-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^(**(**uint64)(__ccgo_up(w))^k) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + goto _2 + _2: + ; + w += 8 + } + s = w + for { + if !(**(**uint8)(__ccgo_up(s)) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(s))) != c) { + break + } + goto _3 + _3: + ; + s = s + 1 + } + return s +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xstrchrnul(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strchrnul(tls, s, c) +} + +func Xstrcmp(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r))) && **(**uint8)(__ccgo_up(l)) != 0) { + break + } + goto _1 + _1: + ; + l = l + 1 + r = r + 1 + } + return Int32FromUint8(**(**uint8)(__ccgo_up(l))) - Int32FromUint8(**(**uint8)(__ccgo_up(r))) +} + +func Xstrcpy(tls *TLS, dest uintptr, src uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v, (%v:)", tls, dest, src, origin(2)) + defer func() { trc("-> %v", r) }() + } + X__stpcpy(tls, dest, src) + return dest +} + +func Xstrcspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var a, v2 uintptr + var v3 bool + var _ /* byteset at bp+0 */ [4]Tsize_t + _, _, _ = a, v2, v3 + a = s + if !(**(**uint8)(__ccgo_up(c)) != 0) || !(**(**uint8)(__ccgo_up(c + 1)) != 0) { + return Uint64FromInt64(int64(X__strchrnul(tls, s, Int32FromUint8(**(**uint8)(__ccgo_up(c))))) - int64(a)) + } + Xmemset(tls, bp, 0, uint64(32)) + for { + if v3 = **(**uint8)(__ccgo_up(c)) != 0; v3 { + v2 = bp + uintptr(uint64(**(**uint8)(__ccgo_up(c)))/(Uint64FromInt32(8)*Uint64FromInt64(8)))*8 + *(*Tsize_t)(unsafe.Pointer(v2)) |= Uint64FromInt32(1) << (uint64(**(**uint8)(__ccgo_up(c))) % (Uint64FromInt32(8) * Uint64FromInt64(8))) + } + if !(v3 && *(*Tsize_t)(unsafe.Pointer(v2)) != 0) { + break + } + goto _1 + _1: + ; + c = c + 1 + } + for { + if !(**(**uint8)(__ccgo_up(s)) != 0 && !((**(**[4]Tsize_t)(__ccgo_up(bp)))[uint64(**(**uint8)(__ccgo_up(s)))/(Uint64FromInt32(8)*Uint64FromInt64(8))]&(Uint64FromInt32(1)<<(uint64(**(**uint8)(__ccgo_up(s)))%(Uint64FromInt32(8)*Uint64FromInt64(8)))) != 0)) { + break + } + goto _4 + _4: + ; + s = s + 1 + } + return Uint64FromInt64(int64(s) - int64(a)) +} + +func Xstrdup(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d uintptr + var l Tsize_t + _, _ = d, l + l = _strlen(tls, s) + d = Xmalloc(tls, l+uint64(1)) + if !(d != 0) { + return UintptrFromInt32(0) + } + return Xmemcpy(tls, d, s, l+uint64(1)) +} + +func Xstrerror_r(tls *TLS, err int32, buf uintptr, buflen Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v err=%v buf=%v buflen=%v, (%v:)", tls, err, buf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + var msg uintptr + _, _ = l, msg + msg = Xstrerror(tls, err) + l = _strlen(tls, msg) + if l >= buflen { + if buflen != 0 { + Xmemcpy(tls, buf, msg, buflen-uint64(1)) + **(**uint8)(__ccgo_up(buf + uintptr(buflen-uint64(1)))) = uint8(0) + } + return int32(ERANGE) + } + Xmemcpy(tls, buf, msg, l+uint64(1)) + return 0 +} + +func X__xpg_strerror_r(tls *TLS, err int32, buf uintptr, buflen Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v err=%v buf=%v buflen=%v, (%v:)", tls, err, buf, buflen, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrerror_r(tls, err, buf, buflen) +} + +func Xstrlcat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + _ = l + l = Xstrnlen(tls, d, n) + if l == n { + return l + _strlen(tls, s) + } + return l + Xstrlcpy(tls, d+uintptr(l), s, n-l) +} + +const ALIGN5 = -1 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xstrlcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d0, wd, ws uintptr + var v1 Tsize_t + var v3 uint8 + var v4 bool + _, _, _, _, _, _ = d0, wd, ws, v1, v3, v4 + d0 = d + v1 = n + n = n - 1 + if !(v1 != 0) { + goto finish + } + if uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) == uint64(d)&(Uint64FromInt64(8)-Uint64FromInt32(1)) { + for { + if v4 = uint64(s)&(Uint64FromInt64(8)-Uint64FromInt32(1)) != 0 && n != 0; v4 { + v3 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v3 + } + if !(v4 && v3 != 0) { + break + } + goto _2 + _2: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + if n != 0 && **(**uint8)(__ccgo_up(s)) != 0 { + wd = d + ws = s + for { + if !(n >= uint64(8) && !((**(**uint64)(__ccgo_up(ws))-Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)) & ^**(**uint64)(__ccgo_up(ws)) & (Uint64FromInt32(-Int32FromInt32(1))/Uint64FromInt32(UCHAR_MAX)*Uint64FromInt32(Int32FromInt32(UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + **(**Tsize_t)(__ccgo_up(wd)) = **(**uint64)(__ccgo_up(ws)) + goto _5 + _5: + ; + n = n - uint64(8) + ws += 8 + wd += 8 + } + d = wd + s = ws + } + } + for { + if v4 = n != 0; v4 { + v3 = **(**uint8)(__ccgo_up(s)) + **(**uint8)(__ccgo_up(d)) = v3 + } + if !(v4 && v3 != 0) { + break + } + goto _6 + _6: + ; + n = n - 1 + s = s + 1 + d = d + 1 + } + **(**uint8)(__ccgo_up(d)) = uint8(0) + goto finish +finish: + ; + return Uint64FromInt64(int64(d)-int64(d0)) + _strlen(tls, s) + return r +} + +const ALIGN6 = 0 + +func Xstrncasecmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v _l=%v _r=%v n=%v, (%v:)", tls, _l, _r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var l, r uintptr + var v1 Tsize_t + _, _, _ = l, r, v1 + l = _l + r = _r + v1 = n + n = n - 1 + if !(v1 != 0) { + return 0 + } + for { + if !(**(**uint8)(__ccgo_up(l)) != 0 && **(**uint8)(__ccgo_up(r)) != 0 && n != 0 && (Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r))) || Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(l)))) == Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(r)))))) { + break + } + goto _2 + _2: + ; + l = l + 1 + r = r + 1 + n = n - 1 + } + return Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(l)))) - Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(r)))) +} + +func X__strncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v loc=%v, (%v:)", tls, l, r, n, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xstrncasecmp(tls, l, r, n) +} + +func Xstrncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, loc Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v loc=%v, (%v:)", tls, l, r, n, loc, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return X__strncasecmp_l(tls, l, r, n, loc) +} + +func Xstrncat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v1, v2 uintptr + _, _, _ = a, v1, v2 + a = d + d = d + uintptr(_strlen(tls, d)) + for n != 0 && **(**uint8)(__ccgo_up(s)) != 0 { + n = n - 1 + v1 = d + d = d + 1 + v2 = s + s = s + 1 + **(**uint8)(__ccgo_up(v1)) = **(**uint8)(__ccgo_up(v2)) + } + v1 = d + d = d + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + return a +} + +func Xstrncmp(tls *TLS, _l uintptr, _r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v _l=%v _r=%v n=%v, (%v:)", tls, _l, _r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var l, r uintptr + var v1 Tsize_t + _, _, _ = l, r, v1 + l = _l + r = _r + v1 = n + n = n - 1 + if !(v1 != 0) { + return 0 + } + for { + if !(**(**uint8)(__ccgo_up(l)) != 0 && **(**uint8)(__ccgo_up(r)) != 0 && n != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(l))) == Int32FromUint8(**(**uint8)(__ccgo_up(r)))) { + break + } + goto _2 + _2: + ; + l = l + 1 + r = r + 1 + n = n - 1 + } + return Int32FromUint8(**(**uint8)(__ccgo_up(l))) - Int32FromUint8(**(**uint8)(__ccgo_up(r))) +} + +func Xstrncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + X__stpncpy(tls, d, s, n) + return d +} + +func Xstrndup(tls *TLS, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d uintptr + var l Tsize_t + _, _ = d, l + l = Xstrnlen(tls, s, n) + d = Xmalloc(tls, l+uint64(1)) + if !(d != 0) { + return UintptrFromInt32(0) + } + Xmemcpy(tls, d, s, l) + **(**uint8)(__ccgo_up(d + uintptr(l))) = uint8(0) + return d +} + +func Xstrnlen(tls *TLS, s uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + var v1 uint64 + _, _ = p, v1 + p = Xmemchr(tls, s, 0, n) + if p != 0 { + v1 = Uint64FromInt64(int64(p) - int64(s)) + } else { + v1 = n + } + return v1 +} + +func Xstrpbrk(tls *TLS, s uintptr, b uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v b=%v, (%v:)", tls, s, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + s = s + uintptr(Xstrcspn(tls, s, b)) + if **(**uint8)(__ccgo_up(s)) != 0 { + v1 = s + } else { + v1 = uintptr(0) + } + return v1 +} + +func Xstrrchr(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__memrchr(tls, s, c, _strlen(tls, s)+uint64(1)) +} + +func Xstrsep(tls *TLS, str uintptr, sep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v str=%v sep=%v, (%v:)", tls, str, sep, origin(2)) + defer func() { trc("-> %v", r) }() + } + var end, s, v1 uintptr + _, _, _ = end, s, v1 + s = **(**uintptr)(__ccgo_up(str)) + if !(s != 0) { + return UintptrFromInt32(0) + } + end = s + uintptr(Xstrcspn(tls, s, sep)) + if **(**uint8)(__ccgo_up(end)) != 0 { + v1 = end + end = end + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + } else { + end = uintptr(0) + } + **(**uintptr)(__ccgo_up(str)) = end + return s +} + +var _strings = [671]uint8{'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 's', 'i', 'g', 'n', 'a', 'l', 0, 'H', 'a', 'n', 'g', 'u', 'p', 0, 'I', 'n', 't', 'e', 'r', 'r', 'u', 'p', 't', 0, 'Q', 'u', 'i', 't', 0, 'I', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'i', 'n', 's', 't', 'r', 'u', 'c', 't', 'i', 'o', 'n', 0, 'T', 'r', 'a', 'c', 'e', '/', 'b', 'r', 'e', 'a', 'k', 'p', 'o', 'i', 'n', 't', ' ', 't', 'r', 'a', 'p', 0, 'A', 'b', 'o', 'r', 't', 'e', 'd', 0, 'B', 'u', 's', ' ', 'e', 'r', 'r', 'o', 'r', 0, 'A', 'r', 'i', 't', 'h', 'm', 'e', 't', 'i', 'c', ' ', 'e', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n', 0, 'K', 'i', 'l', 'l', 'e', 'd', 0, 'U', 's', 'e', 'r', ' ', 'd', 'e', 'f', 'i', 'n', 'e', 'd', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' ', '1', 0, 'S', 'e', 'g', 'm', 'e', 'n', 't', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'a', 'u', 'l', 't', 0, 'U', 's', 'e', 'r', ' ', 'd', 'e', 'f', 'i', 'n', 'e', 'd', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' ', '2', 0, 'B', 'r', 'o', 'k', 'e', 'n', ' ', 'p', 'i', 'p', 'e', 0, 'A', 'l', 'a', 'r', 'm', ' ', 'c', 'l', 'o', 'c', 'k', 0, 'T', 'e', 'r', 'm', 'i', 'n', 'a', 't', 'e', 'd', 0, 'S', 't', 'a', 'c', 'k', ' ', 'f', 'a', 'u', 'l', 't', 0, 'C', 'h', 'i', 'l', 'd', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's', ' ', 's', 't', 'a', 't', 'u', 's', 0, 'C', 'o', 'n', 't', 'i', 'n', 'u', 'e', 'd', 0, 'S', 't', 'o', 'p', 'p', 'e', 'd', ' ', '(', 's', 'i', 'g', 'n', 'a', 'l', ')', 0, 'S', 't', 'o', 'p', 'p', 'e', 'd', 0, 'S', 't', 'o', 'p', 'p', 'e', 'd', ' ', '(', 't', 't', 'y', ' ', 'i', 'n', 'p', 'u', 't', ')', 0, 'S', 't', 'o', 'p', 'p', 'e', 'd', ' ', '(', 't', 't', 'y', ' ', 'o', 'u', 't', 'p', 'u', 't', ')', 0, 'U', 'r', 'g', 'e', 'n', 't', ' ', 'I', '/', 'O', ' ', 'c', 'o', 'n', 'd', 'i', 't', 'i', 'o', 'n', 0, 'C', 'P', 'U', ' ', 't', 'i', 'm', 'e', ' ', 'l', 'i', 'm', 'i', 't', ' ', 'e', 'x', 'c', 'e', 'e', 'd', 'e', 'd', 0, 'F', 'i', 'l', 'e', ' ', 's', 'i', 'z', 'e', ' ', 'l', 'i', 'm', 'i', 't', ' ', 'e', 'x', 'c', 'e', 'e', 'd', 'e', 'd', 0, 'V', 'i', 'r', 't', 'u', 'a', 'l', ' ', 't', 'i', 'm', 'e', 'r', ' ', 'e', 'x', 'p', 'i', 'r', 'e', 'd', 0, 'P', 'r', 'o', 'f', 'i', 'l', 'i', 'n', 'g', ' ', 't', 'i', 'm', 'e', 'r', ' ', 'e', 'x', 'p', 'i', 'r', 'e', 'd', 0, 'W', 'i', 'n', 'd', 'o', 'w', ' ', 'c', 'h', 'a', 'n', 'g', 'e', 'd', 0, 'I', '/', 'O', ' ', 'p', 'o', 's', 's', 'i', 'b', 'l', 'e', 0, 'P', 'o', 'w', 'e', 'r', ' ', 'f', 'a', 'i', 'l', 'u', 'r', 'e', 0, 'B', 'a', 'd', ' ', 's', 'y', 's', 't', 'e', 'm', ' ', 'c', 'a', 'l', 'l', 0, 'R', 'T', '3', '2', 0, 'R', 'T', '3', '3', 0, 'R', 'T', '3', '4', 0, 'R', 'T', '3', '5', 0, 'R', 'T', '3', '6', 0, 'R', 'T', '3', '7', 0, 'R', 'T', '3', '8', 0, 'R', 'T', '3', '9', 0, 'R', 'T', '4', '0', 0, 'R', 'T', '4', '1', 0, 'R', 'T', '4', '2', 0, 'R', 'T', '4', '3', 0, 'R', 'T', '4', '4', 0, 'R', 'T', '4', '5', 0, 'R', 'T', '4', '6', 0, 'R', 'T', '4', '7', 0, 'R', 'T', '4', '8', 0, 'R', 'T', '4', '9', 0, 'R', 'T', '5', '0', 0, 'R', 'T', '5', '1', 0, 'R', 'T', '5', '2', 0, 'R', 'T', '5', '3', 0, 'R', 'T', '5', '4', 0, 'R', 'T', '5', '5', 0, 'R', 'T', '5', '6', 0, 'R', 'T', '5', '7', 0, 'R', 'T', '5', '8', 0, 'R', 'T', '5', '9', 0, 'R', 'T', '6', '0', 0, 'R', 'T', '6', '1', 0, 'R', 'T', '6', '2', 0, 'R', 'T', '6', '3', 0, 'R', 'T', '6', '4'} + +func Xstrsignal(tls *TLS, signum int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v signum=%v, (%v:)", tls, signum, origin(2)) + defer func() { trc("-> %v", r) }() + } + var s uintptr + var v2 int32 + _, _ = s, v2 + s = uintptr(unsafe.Pointer(&_strings)) + signum = signum + if Uint32FromInt32(signum)-uint32(1) >= Uint32FromInt32(Int32FromInt32(_NSIG)-Int32FromInt32(1)) { + signum = 0 + } + for { + v2 = signum + signum = signum - 1 + if !(v2 != 0) { + break + } + for { + if !(**(**uint8)(__ccgo_up(s)) != 0) { + break + } + goto _3 + _3: + ; + s = s + 1 + } + goto _1 + _1: + ; + s = s + 1 + } + return X__lctrans_cur(tls, s) +} + +func Xstrspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var a, v3 uintptr + var v4 bool + var _ /* byteset at bp+0 */ [4]Tsize_t + _, _, _ = a, v3, v4 + a = s + **(**[4]Tsize_t)(__ccgo_up(bp)) = [4]Tsize_t{} + if !(**(**uint8)(__ccgo_up(c)) != 0) { + return uint64(0) + } + if !(**(**uint8)(__ccgo_up(c + 1)) != 0) { + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(s))) == Int32FromUint8(**(**uint8)(__ccgo_up(c)))) { + break + } + goto _1 + _1: + ; + s = s + 1 + } + return Uint64FromInt64(int64(s) - int64(a)) + } + for { + if v4 = **(**uint8)(__ccgo_up(c)) != 0; v4 { + v3 = bp + uintptr(uint64(**(**uint8)(__ccgo_up(c)))/(Uint64FromInt32(8)*Uint64FromInt64(8)))*8 + *(*Tsize_t)(unsafe.Pointer(v3)) |= Uint64FromInt32(1) << (uint64(**(**uint8)(__ccgo_up(c))) % (Uint64FromInt32(8) * Uint64FromInt64(8))) + } + if !(v4 && *(*Tsize_t)(unsafe.Pointer(v3)) != 0) { + break + } + goto _2 + _2: + ; + c = c + 1 + } + for { + if !(**(**uint8)(__ccgo_up(s)) != 0 && (**(**[4]Tsize_t)(__ccgo_up(bp)))[uint64(**(**uint8)(__ccgo_up(s)))/(Uint64FromInt32(8)*Uint64FromInt64(8))]&(Uint64FromInt32(1)<<(uint64(**(**uint8)(__ccgo_up(s)))%(Uint64FromInt32(8)*Uint64FromInt64(8)))) != 0) { + break + } + goto _5 + _5: + ; + s = s + 1 + } + return Uint64FromInt64(int64(s) - int64(a)) +} + +func _twobyte_strstr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + var hw, nw Tuint16_t + var v2 uintptr + _, _, _ = hw, nw, v2 + nw = Uint16FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(n)))< Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + ms = ip + p0 = p + /* And with the opposite comparison */ + ip = Uint64FromInt32(-Int32FromInt32(1)) + jp = uint64(0) + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + for jp+k < l { + if Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(ip+k)))) == Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + if k == p { + jp = jp + p + k = uint64(1) + } else { + k = k + 1 + } + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(ip+k)))) < Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(jp+k)))) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + if ip+uint64(1) > ms+uint64(1) { + ms = ip + } else { + p = p0 + } + /* Periodic needle? */ + if Xmemcmp(tls, n, n+uintptr(p), ms+uint64(1)) != 0 { + mem0 = uint64(0) + if ms > l-ms-uint64(1) { + v8 = ms + } else { + v8 = l - ms - uint64(1) + } + p = v8 + uint64(1) + } else { + mem0 = l - p + } + mem = uint64(0) + /* Initialize incremental end-of-haystack pointer */ + z = h + /* Search loop */ + for { + /* Update incremental end-of-haystack pointer */ + if Uint64FromInt64(int64(z)-int64(h)) < l { + /* Fast estimate for MAX(l,63) */ + grow = l | uint64(63) + z2 = Xmemchr(tls, z, 0, grow) + if z2 != 0 { + z = z2 + if Uint64FromInt64(int64(z)-int64(h)) < l { + return uintptr(0) + } + } else { + z = z + uintptr(grow) + } + } + /* Check last byte first; advance by shift on mismatch */ + if (**(**[4]Tsize_t)(__ccgo_up(bp)))[uint64(**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1)))))/(Uint64FromInt32(8)*Uint64FromInt64(8))]&(Uint64FromInt32(1)<<(uint64(**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1)))))%(Uint64FromInt32(8)*Uint64FromInt64(8)))) != 0 { + k = l - shift[**(**uint8)(__ccgo_up(h + uintptr(l-uint64(1))))] + if k != 0 { + if k < mem { + k = mem + } + h = h + uintptr(k) + mem = uint64(0) + goto _9 + } + } else { + h = h + uintptr(l) + mem = uint64(0) + goto _9 + } + /* Compare right half */ + if ms+uint64(1) > mem { + v8 = ms + uint64(1) + } else { + v8 = mem + } + k = v8 + for { + if !(**(**uint8)(__ccgo_up(n + uintptr(k))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(k)))) == Int32FromUint8(**(**uint8)(__ccgo_up(h + uintptr(k))))) { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if **(**uint8)(__ccgo_up(n + uintptr(k))) != 0 { + h = h + uintptr(k-ms) + mem = uint64(0) + goto _9 + } + /* Compare left half */ + k = ms + uint64(1) + for { + if !(k > mem && Int32FromUint8(**(**uint8)(__ccgo_up(n + uintptr(k-uint64(1))))) == Int32FromUint8(**(**uint8)(__ccgo_up(h + uintptr(k-uint64(1)))))) { + break + } + goto _12 + _12: + ; + k = k - 1 + } + if k <= mem { + return h + } + h = h + uintptr(p) + mem = mem0 + goto _9 + _9: + } + return r +} + +func Xstrstr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v h=%v n=%v, (%v:)", tls, h, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* Return immediately on empty needle */ + if !(**(**uint8)(__ccgo_up(n)) != 0) { + return h + } + /* Use faster algorithms for short needles */ + h = Xstrchr(tls, h, Int32FromUint8(**(**uint8)(__ccgo_up(n)))) + if !(h != 0) || !(**(**uint8)(__ccgo_up(n + 1)) != 0) { + return h + } + if !(**(**uint8)(__ccgo_up(h + 1)) != 0) { + return uintptr(0) + } + if !(**(**uint8)(__ccgo_up(n + 2)) != 0) { + return _twobyte_strstr(tls, h, n) + } + if !(**(**uint8)(__ccgo_up(h + 2)) != 0) { + return uintptr(0) + } + if !(**(**uint8)(__ccgo_up(n + 3)) != 0) { + return _threebyte_strstr(tls, h, n) + } + if !(**(**uint8)(__ccgo_up(h + 3)) != 0) { + return uintptr(0) + } + if !(**(**uint8)(__ccgo_up(n + 4)) != 0) { + return _fourbyte_strstr(tls, h, n) + } + return _twoway_strstr(tls, h, n) +} + +func Xstrtok(tls *TLS, s uintptr, sep uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v sep=%v, (%v:)", tls, s, sep, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + var v2 bool + _, _ = v1, v2 + if v2 = !(s != 0); v2 { + v1 = _p2 + s = v1 + } + if v2 && !(v1 != 0) { + return UintptrFromInt32(0) + } + s = s + uintptr(Xstrspn(tls, s, sep)) + if !(**(**uint8)(__ccgo_up(s)) != 0) { + v1 = UintptrFromInt32(0) + _p2 = v1 + return v1 + } + _p2 = s + uintptr(Xstrcspn(tls, s, sep)) + if **(**uint8)(__ccgo_up(_p2)) != 0 { + v1 = _p2 + _p2 = _p2 + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + } else { + _p2 = uintptr(0) + } + return s +} + +var _p2 uintptr + +func Xstrtok_r(tls *TLS, s uintptr, sep uintptr, p uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v sep=%v p=%v, (%v:)", tls, s, sep, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v3 uintptr + var v2 bool + _, _, _ = v1, v2, v3 + if v2 = !(s != 0); v2 { + v1 = **(**uintptr)(__ccgo_up(p)) + s = v1 + } + if v2 && !(v1 != 0) { + return UintptrFromInt32(0) + } + s = s + uintptr(Xstrspn(tls, s, sep)) + if !(**(**uint8)(__ccgo_up(s)) != 0) { + v1 = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(p)) = v1 + return v1 + } + **(**uintptr)(__ccgo_up(p)) = s + uintptr(Xstrcspn(tls, s, sep)) + if **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)))) != 0 { + v3 = p + v1 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) = *(*uintptr)(unsafe.Pointer(v3)) + 1 + **(**uint8)(__ccgo_up(v1)) = uint8(0) + } else { + **(**uintptr)(__ccgo_up(p)) = uintptr(0) + } + return s +} + +func Xstrverscmp(tls *TLS, l0 uintptr, r0 uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l0=%v r0=%v, (%v:)", tls, l0, r0, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var c, z int32 + var dp, i, j, v2 Tsize_t + var l, r uintptr + _, _, _, _, _, _, _, _ = c, dp, i, j, l, r, z, v2 + l = l0 + r = r0 + z = int32(1) + /* Find maximal matching prefix and track its maximal digit + * suffix and whether those digits are all zeros. */ + v2 = Uint64FromInt32(0) + i = v2 + dp = v2 + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(i)))) == Int32FromUint8(**(**uint8)(__ccgo_up(r + uintptr(i))))) { + break + } + c = Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(i)))) + if !(c != 0) { + return 0 + } + if !(BoolInt32(Uint32FromInt32(c)-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + dp = i + uint64(1) + z = Int32FromInt32(1) + } else { + if c != int32('0') { + z = 0 + } + } + goto _1 + _1: + ; + i = i + 1 + } + if Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(dp))))-int32('1')) < uint32(9) && Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(r + uintptr(dp))))-int32('1')) < uint32(9) { + /* If we're looking at non-degenerate digit sequences starting + * with nonzero digits, longest digit string is greater. */ + j = i + for { + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(l + uintptr(j))))-uint32('0') < uint32(10)) != 0) { + break + } + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(r + uintptr(j))))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return int32(1) + } + goto _3 + _3: + ; + j = j + 1 + } + if BoolInt32(uint32(**(**uint8)(__ccgo_up(r + uintptr(j))))-uint32('0') < uint32(10)) != 0 { + return -int32(1) + } + } else { + if z != 0 && dp < i && (BoolInt32(uint32(**(**uint8)(__ccgo_up(l + uintptr(i))))-uint32('0') < uint32(10)) != 0 || BoolInt32(uint32(**(**uint8)(__ccgo_up(r + uintptr(i))))-uint32('0') < uint32(10)) != 0) { + /* Otherwise, if common prefix of digit sequence is + * all zeros, digits order less than non-digits. */ + return Int32FromUint8(Uint8FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(i))))-Int32FromUint8('0'))) - Int32FromUint8(Uint8FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(r + uintptr(i))))-Int32FromUint8('0'))) + } + } + return Int32FromUint8(**(**uint8)(__ccgo_up(l + uintptr(i)))) - Int32FromUint8(**(**uint8)(__ccgo_up(r + uintptr(i)))) +} + +func Xswab(tls *TLS, _src uintptr, _dest uintptr, n Tssize_t) { + if __ccgo_strace { + trc("tls=%v _src=%v _dest=%v n=%v, (%v:)", tls, _src, _dest, n, origin(2)) + } + var dest, src uintptr + _, _ = dest, src + src = _src + dest = _dest + for { + if !(n > int64(1)) { + break + } + **(**uint8)(__ccgo_up(dest)) = **(**uint8)(__ccgo_up(src + 1)) + **(**uint8)(__ccgo_up(dest + 1)) = **(**uint8)(__ccgo_up(src)) + dest = dest + uintptr(2) + src = src + uintptr(2) + goto _1 + _1: + ; + n = n - int64(2) + } +} + +func Xwcpcpy(tls *TLS, d uintptr, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v, (%v:)", tls, d, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcscpy(tls, d, s) + uintptr(Xwcslen(tls, s))*4 +} + +func Xwcpncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcsncpy(tls, d, s, n) + uintptr(Xwcsnlen(tls, s, n))*4 +} + +func Xwcscasecmp(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xwcsncasecmp(tls, l, r, Uint64FromInt32(-Int32FromInt32(1))) +} + +func Xwcscasecmp_l(tls *TLS, l uintptr, r uintptr, locale Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v locale=%v, (%v:)", tls, l, r, locale, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xwcscasecmp(tls, l, r) +} + +func Xwcscat(tls *TLS, dest uintptr, src uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v dest=%v src=%v, (%v:)", tls, dest, src, origin(2)) + defer func() { trc("-> %v", r) }() + } + Xwcscpy(tls, dest+uintptr(Xwcslen(tls, dest))*4, src) + return dest +} + +func Xwcschr(tls *TLS, s uintptr, c Twchar_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v2 uintptr + _ = v2 + if !(c != 0) { + return s + uintptr(Xwcslen(tls, s))*4 + } + for { + if !(**(**Twchar_t)(__ccgo_up(s)) != 0 && **(**Twchar_t)(__ccgo_up(s)) != c) { + break + } + goto _1 + _1: + ; + s += 4 + } + if **(**Twchar_t)(__ccgo_up(s)) != 0 { + v2 = s + } else { + v2 = uintptr(0) + } + return v2 +} + +func Xwcscmp(tls *TLS, l uintptr, r uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v, (%v:)", tls, l, r, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var v2 int32 + _ = v2 + for { + if !(**(**Twchar_t)(__ccgo_up(l)) == **(**Twchar_t)(__ccgo_up(r)) && **(**Twchar_t)(__ccgo_up(l)) != 0 && **(**Twchar_t)(__ccgo_up(r)) != 0) { + break + } + goto _1 + _1: + ; + l += 4 + r += 4 + } + if **(**Twchar_t)(__ccgo_up(l)) < **(**Twchar_t)(__ccgo_up(r)) { + v2 = -int32(1) + } else { + v2 = BoolInt32(**(**Twchar_t)(__ccgo_up(l)) > **(**Twchar_t)(__ccgo_up(r))) + } + return v2 +} + +func Xwcscpy(tls *TLS, d uintptr, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v, (%v:)", tls, d, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v2, v3 uintptr + var v1 Twchar_t + _, _, _, _ = a, v1, v2, v3 + a = d + for { + v2 = s + s += 4 + v1 = **(**Twchar_t)(__ccgo_up(v2)) + v3 = d + d += 4 + **(**Twchar_t)(__ccgo_up(v3)) = v1 + if !(v1 != 0) { + break + } + } + return a +} + +func Xwcscspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v2, v3 uintptr + var v1 uint64 + _, _, _, _ = a, v1, v2, v3 + if !(**(**Twchar_t)(__ccgo_up(c)) != 0) { + return Xwcslen(tls, s) + } + if !(**(**Twchar_t)(__ccgo_up(c + 1*4)) != 0) { + v3 = s + a = v3 + v2 = Xwcschr(tls, v3, **(**Twchar_t)(__ccgo_up(c))) + s = v2 + if v2 != 0 { + v1 = Uint64FromInt64((int64(s) - int64(a)) / 4) + } else { + v1 = Xwcslen(tls, a) + } + return v1 + } + a = s + for { + if !(**(**Twchar_t)(__ccgo_up(s)) != 0 && !(Xwcschr(tls, c, **(**Twchar_t)(__ccgo_up(s))) != 0)) { + break + } + goto _4 + _4: + ; + s += 4 + } + return Uint64FromInt64((int64(s) - int64(a)) / 4) +} + +func Xwcsdup(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d uintptr + var l Tsize_t + _, _ = d, l + l = Xwcslen(tls, s) + d = Xmalloc(tls, (l+uint64(1))*uint64(4)) + if !(d != 0) { + return UintptrFromInt32(0) + } + return Xwmemcpy(tls, d, s, l+uint64(1)) +} + +func Xwcslen(tls *TLS, s uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a uintptr + _ = a + a = s + for { + if !(**(**Twchar_t)(__ccgo_up(s)) != 0) { + break + } + goto _1 + _1: + ; + s += 4 + } + return Uint64FromInt64((int64(s) - int64(a)) / 4) +} + +func Xwcsncasecmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v, (%v:)", tls, l, r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var v1 Tsize_t + _ = v1 + v1 = n + n = n - 1 + if !(v1 != 0) { + return 0 + } + for { + if !(**(**Twchar_t)(__ccgo_up(l)) != 0 && **(**Twchar_t)(__ccgo_up(r)) != 0 && n != 0 && (**(**Twchar_t)(__ccgo_up(l)) == **(**Twchar_t)(__ccgo_up(r)) || Xtowlower(tls, **(**Twchar_t)(__ccgo_up(l))) == Xtowlower(tls, **(**Twchar_t)(__ccgo_up(r))))) { + break + } + goto _2 + _2: + ; + l += 4 + r += 4 + n = n - 1 + } + return Int32FromUint32(Xtowlower(tls, **(**Twchar_t)(__ccgo_up(l))) - Xtowlower(tls, **(**Twchar_t)(__ccgo_up(r)))) +} + +func Xwcsncasecmp_l(tls *TLS, l uintptr, r uintptr, n Tsize_t, locale Tlocale_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v locale=%v, (%v:)", tls, l, r, n, locale, origin(2)) + defer func() { trc("-> %v", r1) }() + } + return Xwcsncasecmp(tls, l, r, n) +} + +func Xwcsncat(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v1, v2 uintptr + _, _, _ = a, v1, v2 + a = d + d = d + uintptr(Xwcslen(tls, d))*4 + for n != 0 && **(**Twchar_t)(__ccgo_up(s)) != 0 { + n = n - 1 + v1 = d + d += 4 + v2 = s + s += 4 + **(**Twchar_t)(__ccgo_up(v1)) = **(**Twchar_t)(__ccgo_up(v2)) + } + v1 = d + d += 4 + **(**Twchar_t)(__ccgo_up(v1)) = uint32(0) + return a +} + +func Xwcsncmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v, (%v:)", tls, l, r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var v2, v3 int32 + _, _ = v2, v3 + for { + if !(n != 0 && **(**Twchar_t)(__ccgo_up(l)) == **(**Twchar_t)(__ccgo_up(r)) && **(**Twchar_t)(__ccgo_up(l)) != 0 && **(**Twchar_t)(__ccgo_up(r)) != 0) { + break + } + goto _1 + _1: + ; + n = n - 1 + l += 4 + r += 4 + } + if n != 0 { + if **(**Twchar_t)(__ccgo_up(l)) < **(**Twchar_t)(__ccgo_up(r)) { + v3 = -int32(1) + } else { + v3 = BoolInt32(**(**Twchar_t)(__ccgo_up(l)) > **(**Twchar_t)(__ccgo_up(r))) + } + v2 = v3 + } else { + v2 = 0 + } + return v2 +} + +func Xwcsncpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v1, v2 uintptr + _, _, _ = a, v1, v2 + a = d + for n != 0 && **(**Twchar_t)(__ccgo_up(s)) != 0 { + n = n - 1 + v1 = d + d += 4 + v2 = s + s += 4 + **(**Twchar_t)(__ccgo_up(v1)) = **(**Twchar_t)(__ccgo_up(v2)) + } + Xwmemset(tls, d, uint32(0), n) + return a +} + +func Xwcsnlen(tls *TLS, s uintptr, n Tsize_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var z uintptr + _ = z + z = Xwmemchr(tls, s, uint32(0), n) + if z != 0 { + n = Uint64FromInt64((int64(z) - int64(s)) / 4) + } + return n +} + +func Xwcspbrk(tls *TLS, s uintptr, b uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v b=%v, (%v:)", tls, s, b, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + s = s + uintptr(Xwcscspn(tls, s, b))*4 + if **(**Twchar_t)(__ccgo_up(s)) != 0 { + v1 = s + } else { + v1 = UintptrFromInt32(0) + } + return v1 +} + +func Xwcsrchr(tls *TLS, s uintptr, c Twchar_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p, v2 uintptr + _, _ = p, v2 + p = s + uintptr(Xwcslen(tls, s))*4 + for { + if !(p >= s && **(**Twchar_t)(__ccgo_up(p)) != c) { + break + } + goto _1 + _1: + ; + p -= 4 + } + if p >= s { + v2 = p + } else { + v2 = uintptr(0) + } + return v2 +} + +func Xwcsspn(tls *TLS, s uintptr, c uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a uintptr + _ = a + a = s + for { + if !(**(**Twchar_t)(__ccgo_up(s)) != 0 && Xwcschr(tls, c, **(**Twchar_t)(__ccgo_up(s))) != 0) { + break + } + goto _1 + _1: + ; + s += 4 + } + return Uint64FromInt64((int64(s) - int64(a)) / 4) +} + +func _twoway_wcsstr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + var grow, ip, jp, k, l, mem, mem0, ms, p, p0, v2 Tsize_t + var z, z2 uintptr + var v8 uint64 + _, _, _, _, _, _, _, _, _, _, _, _, _, _ = grow, ip, jp, k, l, mem, mem0, ms, p, p0, z, z2, v2, v8 + /* Computing length of needle */ + l = uint64(0) + for { + if !(**(**Twchar_t)(__ccgo_up(n + uintptr(l)*4)) != 0 && **(**Twchar_t)(__ccgo_up(h + uintptr(l)*4)) != 0) { + break + } + goto _1 + _1: + ; + l = l + 1 + } + if **(**Twchar_t)(__ccgo_up(n + uintptr(l)*4)) != 0 { + return uintptr(0) + } /* hit the end of h */ + /* Compute maximal suffix */ + ip = Uint64FromInt32(-Int32FromInt32(1)) + jp = uint64(0) + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + for jp+k < l { + if **(**Twchar_t)(__ccgo_up(n + uintptr(ip+k)*4)) == **(**Twchar_t)(__ccgo_up(n + uintptr(jp+k)*4)) { + if k == p { + jp = jp + p + k = uint64(1) + } else { + k = k + 1 + } + } else { + if **(**Twchar_t)(__ccgo_up(n + uintptr(ip+k)*4)) > **(**Twchar_t)(__ccgo_up(n + uintptr(jp+k)*4)) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + ms = ip + p0 = p + /* And with the opposite comparison */ + ip = Uint64FromInt32(-Int32FromInt32(1)) + jp = uint64(0) + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + for jp+k < l { + if **(**Twchar_t)(__ccgo_up(n + uintptr(ip+k)*4)) == **(**Twchar_t)(__ccgo_up(n + uintptr(jp+k)*4)) { + if k == p { + jp = jp + p + k = uint64(1) + } else { + k = k + 1 + } + } else { + if **(**Twchar_t)(__ccgo_up(n + uintptr(ip+k)*4)) < **(**Twchar_t)(__ccgo_up(n + uintptr(jp+k)*4)) { + jp = jp + k + k = uint64(1) + p = jp - ip + } else { + v2 = jp + jp = jp + 1 + ip = v2 + v2 = Uint64FromInt32(1) + p = v2 + k = v2 + } + } + } + if ip+uint64(1) > ms+uint64(1) { + ms = ip + } else { + p = p0 + } + /* Periodic needle? */ + if Xwmemcmp(tls, n, n+uintptr(p)*4, ms+uint64(1)) != 0 { + mem0 = uint64(0) + if ms > l-ms-uint64(1) { + v8 = ms + } else { + v8 = l - ms - uint64(1) + } + p = v8 + uint64(1) + } else { + mem0 = l - p + } + mem = uint64(0) + /* Initialize incremental end-of-haystack pointer */ + z = h + /* Search loop */ + for { + /* Update incremental end-of-haystack pointer */ + if Uint64FromInt64((int64(z)-int64(h))/4) < l { + /* Fast estimate for MIN(l,63) */ + grow = l | uint64(63) + z2 = Xwmemchr(tls, z, uint32(0), grow) + if z2 != 0 { + z = z2 + if Uint64FromInt64((int64(z)-int64(h))/4) < l { + return uintptr(0) + } + } else { + z = z + uintptr(grow)*4 + } + } + /* Compare right half */ + if ms+uint64(1) > mem { + v8 = ms + uint64(1) + } else { + v8 = mem + } + k = v8 + for { + if !(**(**Twchar_t)(__ccgo_up(n + uintptr(k)*4)) != 0 && **(**Twchar_t)(__ccgo_up(n + uintptr(k)*4)) == **(**Twchar_t)(__ccgo_up(h + uintptr(k)*4))) { + break + } + goto _10 + _10: + ; + k = k + 1 + } + if **(**Twchar_t)(__ccgo_up(n + uintptr(k)*4)) != 0 { + h = h + uintptr(k-ms)*4 + mem = uint64(0) + goto _9 + } + /* Compare left half */ + k = ms + uint64(1) + for { + if !(k > mem && **(**Twchar_t)(__ccgo_up(n + uintptr(k-uint64(1))*4)) == **(**Twchar_t)(__ccgo_up(h + uintptr(k-uint64(1))*4))) { + break + } + goto _12 + _12: + ; + k = k - 1 + } + if k <= mem { + return h + } + h = h + uintptr(p)*4 + mem = mem0 + goto _9 + _9: + } + return r +} + +func Xwcsstr(tls *TLS, h uintptr, n uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v h=%v n=%v, (%v:)", tls, h, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* Return immediately on empty needle or haystack */ + if !(**(**Twchar_t)(__ccgo_up(n)) != 0) { + return h + } + if !(**(**Twchar_t)(__ccgo_up(h)) != 0) { + return uintptr(0) + } + /* Use faster algorithms for short needles */ + h = Xwcschr(tls, h, **(**Twchar_t)(__ccgo_up(n))) + if !(h != 0) || !(**(**Twchar_t)(__ccgo_up(n + 1*4)) != 0) { + return h + } + if !(**(**Twchar_t)(__ccgo_up(h + 1*4)) != 0) { + return uintptr(0) + } + return _twoway_wcsstr(tls, h, n) +} + +func Xwcstok(tls *TLS, s uintptr, sep uintptr, p uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v sep=%v p=%v, (%v:)", tls, s, sep, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1, v3 uintptr + var v2 bool + _, _, _ = v1, v2, v3 + if v2 = !(s != 0); v2 { + v1 = **(**uintptr)(__ccgo_up(p)) + s = v1 + } + if v2 && !(v1 != 0) { + return UintptrFromInt32(0) + } + s = s + uintptr(Xwcsspn(tls, s, sep))*4 + if !(**(**Twchar_t)(__ccgo_up(s)) != 0) { + v1 = UintptrFromInt32(0) + **(**uintptr)(__ccgo_up(p)) = v1 + return v1 + } + **(**uintptr)(__ccgo_up(p)) = s + uintptr(Xwcscspn(tls, s, sep))*4 + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(p)))) != 0 { + v3 = p + v1 = *(*uintptr)(unsafe.Pointer(v3)) + *(*uintptr)(unsafe.Pointer(v3)) += 4 + **(**Twchar_t)(__ccgo_up(v1)) = uint32(0) + } else { + **(**uintptr)(__ccgo_up(p)) = uintptr(0) + } + return s +} + +func Xwcswcs(tls *TLS, haystack uintptr, needle uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v haystack=%v needle=%v, (%v:)", tls, haystack, needle, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xwcsstr(tls, haystack, needle) +} + +func Xwmemchr(tls *TLS, s uintptr, c Twchar_t, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v n=%v, (%v:)", tls, s, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v2 uintptr + _ = v2 + for { + if !(n != 0 && **(**Twchar_t)(__ccgo_up(s)) != c) { + break + } + goto _1 + _1: + ; + n = n - 1 + s += 4 + } + if n != 0 { + v2 = s + } else { + v2 = uintptr(0) + } + return v2 +} + +func Xwmemcmp(tls *TLS, l uintptr, r uintptr, n Tsize_t) (r1 int32) { + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v, (%v:)", tls, l, r, n, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var v2, v3 int32 + _, _ = v2, v3 + for { + if !(n != 0 && **(**Twchar_t)(__ccgo_up(l)) == **(**Twchar_t)(__ccgo_up(r))) { + break + } + goto _1 + _1: + ; + n = n - 1 + l += 4 + r += 4 + } + if n != 0 { + if **(**Twchar_t)(__ccgo_up(l)) < **(**Twchar_t)(__ccgo_up(r)) { + v3 = -int32(1) + } else { + v3 = BoolInt32(**(**Twchar_t)(__ccgo_up(l)) > **(**Twchar_t)(__ccgo_up(r))) + } + v2 = v3 + } else { + v2 = 0 + } + return v2 +} + +func Xwmemcpy(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var a, v2, v3 uintptr + var v1 Tsize_t + _, _, _, _ = a, v1, v2, v3 + a = d + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + v2 = d + d += 4 + v3 = s + s += 4 + **(**Twchar_t)(__ccgo_up(v2)) = **(**Twchar_t)(__ccgo_up(v3)) + } + return a +} + +func Xwmemmove(tls *TLS, d uintptr, s uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var d0, v3, v4 uintptr + var v1 Tsize_t + _, _, _, _ = d0, v1, v3, v4 + d0 = d + if d == s { + return d + } + if uint64(d)-uint64(s) < n*uint64(4) { + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + **(**Twchar_t)(__ccgo_up(d + uintptr(n)*4)) = **(**Twchar_t)(__ccgo_up(s + uintptr(n)*4)) + } + } else { + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + v3 = d + d += 4 + v4 = s + s += 4 + **(**Twchar_t)(__ccgo_up(v3)) = **(**Twchar_t)(__ccgo_up(v4)) + } + } + return d0 +} + +func Xwmemset(tls *TLS, d uintptr, c Twchar_t, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v d=%v c=%v n=%v, (%v:)", tls, d, c, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret, v2 uintptr + var v1 Tsize_t + _, _, _ = ret, v1, v2 + ret = d + for { + v1 = n + n = n - 1 + if !(v1 != 0) { + break + } + v2 = d + d += 4 + **(**Twchar_t)(__ccgo_up(v2)) = c + } + return ret +} + +func Xmkdtemp(tls *TLS, template uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v template=%v, (%v:)", tls, template, origin(2)) + defer func() { trc("-> %v", r) }() + } + var l Tsize_t + var retries, v1 int32 + _, _, _ = l, retries, v1 + l = _strlen(tls, template) + retries = int32(100) + if l < uint64(6) || Xmemcmp(tls, template+uintptr(l)-uintptr(6), __ccgo_ts+1730, uint64(6)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + for { + ___randname(tls, template+uintptr(l)-uintptr(6)) + if !(Xmkdir(tls, template, uint32(0700)) != 0) { + return template + } + goto _2 + _2: + ; + retries = retries - 1 + v1 = retries + if !(v1 != 0 && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EEXIST)) { + break + } + } + Xmemcpy(tls, template+uintptr(l)-uintptr(6), __ccgo_ts+1730, uint64(6)) + return uintptr(0) +} + +func Xmkostemp(tls *TLS, template uintptr, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v flags=%v, (%v:)", tls, template, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mkostemps(tls, template, 0, flags) +} + +func X__mkostemps(tls *TLS, template uintptr, len1 int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v len1=%v flags=%v, (%v:)", tls, template, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var fd, retries, v1 int32 + var l Tsize_t + _, _, _, _ = fd, l, retries, v1 + l = _strlen(tls, template) + if l < uint64(6) || Uint64FromInt32(len1) > l-uint64(6) || Xmemcmp(tls, template+uintptr(l)-uintptr(len1)-uintptr(6), __ccgo_ts+1730, uint64(6)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + flags = flags - flags&(Int32FromInt32(03)|Int32FromInt32(O_PATH)) + retries = int32(100) + for { + ___randname(tls, template+uintptr(l)-uintptr(len1)-uintptr(6)) + v1 = Xopen(tls, template, flags|int32(O_RDWR)|int32(O_CREAT)|int32(O_EXCL), VaList(bp+8, int32(0600))) + fd = v1 + if v1 >= 0 { + return fd + } + goto _2 + _2: + ; + retries = retries - 1 + v1 = retries + if !(v1 != 0 && **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EEXIST)) { + break + } + } + Xmemcpy(tls, template+uintptr(l)-uintptr(len1)-uintptr(6), __ccgo_ts+1730, uint64(6)) + return -int32(1) +} + +func Xmkostemps(tls *TLS, template uintptr, len1 int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v len1=%v flags=%v, (%v:)", tls, template, len1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mkostemps(tls, template, len1, flags) +} + +func Xmkstemp(tls *TLS, template uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v, (%v:)", tls, template, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mkostemps(tls, template, 0, 0) +} + +func Xmkstemps(tls *TLS, template uintptr, len1 int32) (r int32) { + if __ccgo_strace { + trc("tls=%v template=%v len1=%v, (%v:)", tls, template, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__mkostemps(tls, template, len1, 0) +} + +func Xmktemp(tls *TLS, template uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v template=%v, (%v:)", tls, template, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var l Tsize_t + var retries, v1 int32 + var _ /* st at bp+0 */ Tstat + _, _, _ = l, retries, v1 + l = _strlen(tls, template) + retries = int32(100) + if l < uint64(6) || Xmemcmp(tls, template+uintptr(l)-uintptr(6), __ccgo_ts+1730, uint64(6)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + **(**uint8)(__ccgo_up(template)) = uint8(0) + return template + } + for { + ___randname(tls, template+uintptr(l)-uintptr(6)) + if Xstat(tls, template, bp) != 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(ENOENT) { + **(**uint8)(__ccgo_up(template)) = uint8(0) + } + return template + } + goto _2 + _2: + ; + retries = retries - 1 + v1 = retries + if !(v1 != 0) { + break + } + } + **(**uint8)(__ccgo_up(template)) = uint8(0) + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EEXIST) + return template +} + +func Xcfgetospeed(tls *TLS, tio uintptr) (r Tspeed_t) { + if __ccgo_strace { + trc("tls=%v tio=%v, (%v:)", tls, tio, origin(2)) + defer func() { trc("-> %v", r) }() + } + return (*Ttermios)(unsafe.Pointer(tio)).Fc_cflag & uint32(CBAUD) +} + +func Xcfgetispeed(tls *TLS, tio uintptr) (r Tspeed_t) { + if __ccgo_strace { + trc("tls=%v tio=%v, (%v:)", tls, tio, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcfgetospeed(tls, tio) +} + +func Xcfmakeraw(tls *TLS, t uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + } + **(**Ttcflag_t)(__ccgo_up(t)) &= Uint32FromInt32(^(Int32FromInt32(IGNBRK) | Int32FromInt32(BRKINT) | Int32FromInt32(PARMRK) | Int32FromInt32(ISTRIP) | Int32FromInt32(INLCR) | Int32FromInt32(IGNCR) | Int32FromInt32(ICRNL) | Int32FromInt32(IXON))) + **(**Ttcflag_t)(__ccgo_up(t + 4)) &= Uint32FromInt32(^Int32FromInt32(OPOST)) + **(**Ttcflag_t)(__ccgo_up(t + 12)) &= Uint32FromInt32(^(Int32FromInt32(ECHO) | Int32FromInt32(ECHONL) | Int32FromInt32(ICANON) | Int32FromInt32(ISIG) | Int32FromInt32(IEXTEN))) + **(**Ttcflag_t)(__ccgo_up(t + 8)) &= Uint32FromInt32(^(Int32FromInt32(CSIZE) | Int32FromInt32(PARENB))) + **(**Ttcflag_t)(__ccgo_up(t + 8)) |= uint32(CS8) + **(**Tcc_t)(__ccgo_up(t + 17 + 6)) = uint8(1) + **(**Tcc_t)(__ccgo_up(t + 17 + 5)) = uint8(0) +} + +func Xcfsetospeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) { + if __ccgo_strace { + trc("tls=%v tio=%v speed=%v, (%v:)", tls, tio, speed, origin(2)) + defer func() { trc("-> %v", r) }() + } + if speed&Uint32FromInt32(^Int32FromInt32(CBAUD)) != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + **(**Ttcflag_t)(__ccgo_up(tio + 8)) &= Uint32FromInt32(^Int32FromInt32(CBAUD)) + **(**Ttcflag_t)(__ccgo_up(tio + 8)) |= speed + return 0 +} + +func Xcfsetispeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) { + if __ccgo_strace { + trc("tls=%v tio=%v speed=%v, (%v:)", tls, tio, speed, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 int32 + _ = v1 + if speed != 0 { + v1 = Xcfsetospeed(tls, tio, speed) + } else { + v1 = 0 + } + return v1 +} + +func Xcfsetspeed(tls *TLS, tio uintptr, speed Tspeed_t) (r int32) { + if __ccgo_strace { + trc("tls=%v tio=%v speed=%v, (%v:)", tls, tio, speed, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcfsetospeed(tls, tio, speed) +} + +func Xtcdrain(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TCSBRK)), int64(Int32FromInt32(1)), 0, 0, 0)))) +} + +func Xtcflow(tls *TLS, fd int32, action int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v action=%v, (%v:)", tls, fd, action, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + return Xioctl(tls, fd, int32(TCXONC), VaList(bp+8, action)) +} + +func Xtcflush(tls *TLS, fd int32, queue int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v queue=%v, (%v:)", tls, fd, queue, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + return Xioctl(tls, fd, int32(TCFLSH), VaList(bp+8, queue)) +} + +func Xtcgetattr(tls *TLS, fd int32, tio uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v tio=%v, (%v:)", tls, fd, tio, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + if Xioctl(tls, fd, int32(TCGETS), VaList(bp+8, tio)) != 0 { + return -int32(1) + } + return 0 +} + +func Xtcgetsid(tls *TLS, fd int32) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* sid at bp+0 */ int32 + if Xioctl(tls, fd, int32(TIOCGSID), VaList(bp+16, bp)) < 0 { + return -int32(1) + } + return **(**int32)(__ccgo_up(bp)) +} + +func Xtcgetwinsize(tls *TLS, fd int32, wsz uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v wsz=%v, (%v:)", tls, fd, wsz, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TIOCGWINSZ)), int64(wsz))))) +} + +func Xtcsendbreak(tls *TLS, fd int32, dur int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v dur=%v, (%v:)", tls, fd, dur, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + /* nonzero duration is implementation-defined, so ignore it */ + return Xioctl(tls, fd, int32(TCSBRK), VaList(bp+8, 0)) +} + +func Xtcsetattr(tls *TLS, fd int32, act int32, tio uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v act=%v tio=%v, (%v:)", tls, fd, act, tio, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + if act < 0 || act > int32(2) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return -int32(1) + } + return Xioctl(tls, fd, int32(TCSETS)+act, VaList(bp+8, tio)) +} + +func Xtcsetwinsize(tls *TLS, fd int32, wsz uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v wsz=%v, (%v:)", tls, fd, wsz, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TIOCSWINSZ)), int64(wsz))))) +} + +func X__map_file(tls *TLS, pathname uintptr, size uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v pathname=%v size=%v, (%v:)", tls, pathname, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var fd int32 + var map1, v1 uintptr + var _ /* st at bp+0 */ Tstat + _, _, _ = fd, map1, v1 + map1 = uintptr(-Int32FromInt32(1)) + fd = int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_openat), int64(-Int32FromInt32(100)), int64(pathname), int64(Int32FromInt32(O_RDONLY)|Int32FromInt32(O_CLOEXEC)|Int32FromInt32(O_NONBLOCK)|Int32FromInt32(O_LARGEFILE)))))) + if fd < 0 { + return uintptr(0) + } + if !(X__fstat(tls, fd, bp) != 0) { + map1 = X__mmap(tls, uintptr(0), Uint64FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_size), int32(PROT_READ), int32(MAP_SHARED), fd, 0) + **(**Tsize_t)(__ccgo_up(size)) = Uint64FromInt64((**(**Tstat)(__ccgo_up(bp))).Fst_size) + } + X__syscall1(tls, int64(SYS_close), int64(fd)) + if map1 == uintptr(-Int32FromInt32(1)) { + v1 = uintptr(0) + } else { + v1 = map1 + } + return v1 +} + +func X__month_to_secs(tls *TLS, month int32, is_leap int32) (r int32) { + if __ccgo_strace { + trc("tls=%v month=%v is_leap=%v, (%v:)", tls, month, is_leap, origin(2)) + defer func() { trc("-> %v", r) }() + } + var t int32 + _ = t + t = _secs_through_month[month] + if is_leap != 0 && month >= int32(2) { + t = t + int32(86400) + } + return t +} + +var _secs_through_month = [12]int32{ + 1: Int32FromInt32(31) * Int32FromInt32(86400), + 2: Int32FromInt32(59) * Int32FromInt32(86400), + 3: Int32FromInt32(90) * Int32FromInt32(86400), + 4: Int32FromInt32(120) * Int32FromInt32(86400), + 5: Int32FromInt32(151) * Int32FromInt32(86400), + 6: Int32FromInt32(181) * Int32FromInt32(86400), + 7: Int32FromInt32(212) * Int32FromInt32(86400), + 8: Int32FromInt32(243) * Int32FromInt32(86400), + 9: Int32FromInt32(273) * Int32FromInt32(86400), + 10: Int32FromInt32(304) * Int32FromInt32(86400), + 11: Int32FromInt32(334) * Int32FromInt32(86400), +} + +const DAYS_PER_100Y = 36524 +const DAYS_PER_400Y = 146097 +const DAYS_PER_4Y = 1461 +const LEAPOCH = 951868800 + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +/* 2000-03-01 (mod 400 year, immediately after feb29 */ + +func X__secs_to_tm(tls *TLS, t int64, tm uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + var c_cycles, leap, months, q_cycles, qc_cycles, remdays, remsecs, remyears, wday, yday int32 + var days, secs, years int64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = c_cycles, days, leap, months, q_cycles, qc_cycles, remdays, remsecs, remyears, secs, wday, yday, years + /* Reject time_t values whose year would overflow int */ + if t < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff))*Int64FromInt64(31622400) || t > Int64FromInt32(INT_MAX)*Int64FromInt64(31622400) { + return -int32(1) + } + secs = t - (Int64FromInt64(946684800) + int64(Int32FromInt32(86400)*(Int32FromInt32(31)+Int32FromInt32(29)))) + days = secs / int64(86400) + remsecs = int32(secs % int64(86400)) + if remsecs < 0 { + remsecs = remsecs + int32(86400) + days = days - 1 + } + wday = int32((int64(3) + days) % int64(7)) + if wday < 0 { + wday = wday + int32(7) + } + qc_cycles = int32(days / int64(Int32FromInt32(365)*Int32FromInt32(400)+Int32FromInt32(97))) + remdays = int32(days % int64(Int32FromInt32(365)*Int32FromInt32(400)+Int32FromInt32(97))) + if remdays < 0 { + remdays = remdays + (Int32FromInt32(365)*Int32FromInt32(400) + Int32FromInt32(97)) + qc_cycles = qc_cycles - 1 + } + c_cycles = remdays / (Int32FromInt32(365)*Int32FromInt32(100) + Int32FromInt32(24)) + if c_cycles == int32(4) { + c_cycles = c_cycles - 1 + } + remdays = remdays - c_cycles*(Int32FromInt32(365)*Int32FromInt32(100)+Int32FromInt32(24)) + q_cycles = remdays / (Int32FromInt32(365)*Int32FromInt32(4) + Int32FromInt32(1)) + if q_cycles == int32(25) { + q_cycles = q_cycles - 1 + } + remdays = remdays - q_cycles*(Int32FromInt32(365)*Int32FromInt32(4)+Int32FromInt32(1)) + remyears = remdays / int32(365) + if remyears == int32(4) { + remyears = remyears - 1 + } + remdays = remdays - remyears*int32(365) + leap = BoolInt32(!(remyears != 0) && (q_cycles != 0 || !(c_cycles != 0))) + yday = remdays + int32(31) + int32(28) + leap + if yday >= int32(365)+leap { + yday = yday - (int32(365) + leap) + } + years = int64(remyears+int32(4)*q_cycles+int32(100)*c_cycles) + int64(400)*int64(qc_cycles) + months = 0 + for { + if !(Int32FromUint8(_days_in_month[months]) <= remdays) { + break + } + remdays = remdays - Int32FromUint8(_days_in_month[months]) + goto _1 + _1: + ; + months = months + 1 + } + if months >= int32(10) { + months = months - int32(12) + years = years + 1 + } + if years+int64(100) > int64(INT_MAX) || years+int64(100) < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff)) { + return -int32(1) + } + (*Ttm)(unsafe.Pointer(tm)).Ftm_year = int32(years + int64(100)) + (*Ttm)(unsafe.Pointer(tm)).Ftm_mon = months + int32(2) + (*Ttm)(unsafe.Pointer(tm)).Ftm_mday = remdays + int32(1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_wday = wday + (*Ttm)(unsafe.Pointer(tm)).Ftm_yday = yday + (*Ttm)(unsafe.Pointer(tm)).Ftm_hour = remsecs / int32(3600) + (*Ttm)(unsafe.Pointer(tm)).Ftm_min = remsecs / int32(60) % int32(60) + (*Ttm)(unsafe.Pointer(tm)).Ftm_sec = remsecs % int32(60) + return 0 +} + +var _days_in_month = [12]uint8{ + 0: uint8(31), + 1: uint8(30), + 2: uint8(31), + 3: uint8(30), + 4: uint8(31), + 5: uint8(31), + 6: uint8(30), + 7: uint8(31), + 8: uint8(30), + 9: uint8(31), + 10: uint8(31), + 11: uint8(29), +} + +func X__tm_to_secs(tls *TLS, tm uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var adj, month int32 + var t, year int64 + var _ /* is_leap at bp+0 */ int32 + _, _, _, _ = adj, month, t, year + year = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year) + month = (*Ttm)(unsafe.Pointer(tm)).Ftm_mon + if month >= int32(12) || month < 0 { + adj = month / int32(12) + month = month % int32(12) + if month < 0 { + adj = adj - 1 + month = month + int32(12) + } + year = year + int64(adj) + } + t = X__year_to_secs(tls, year, bp) + t = t + int64(X__month_to_secs(tls, month, **(**int32)(__ccgo_up(bp)))) + t = t + int64(86400)*int64((*Ttm)(unsafe.Pointer(tm)).Ftm_mday-Int32FromInt32(1)) + t = t + int64(3600)*int64((*Ttm)(unsafe.Pointer(tm)).Ftm_hour) + t = t + int64(60)*int64((*Ttm)(unsafe.Pointer(tm)).Ftm_min) + t = t + int64((*Ttm)(unsafe.Pointer(tm)).Ftm_sec) + return t +} + +var _std_name [7]uint8 +var _dst_name [7]uint8 + +var _dst_off int32 +var _r0 [5]int32 +var _r12 [5]int32 + +var _zi uintptr +var _trans uintptr +var _index uintptr +var _types uintptr +var _abbrevs uintptr +var _abbrevs_end uintptr +var _map_size Tsize_t + +var _old_tz_buf [32]uint8 +var _old_tz = uintptr(unsafe.Pointer(&_old_tz_buf)) +var _old_tz_size = uint64(32) + +var _lock4 [1]int32 + +func _getint2(tls *TLS, p uintptr) (r int32) { + var x uint32 + _ = x + x = uint32(0) + for { + if !(Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)))))-int32('0')) < uint32(10)) { + break + } + x = Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)))))-int32('0')) + uint32(10)*x + goto _1 + _1: + ; + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + } + return Int32FromUint32(x) +} + +func _getoff(tls *TLS, p uintptr) (r int32) { + var neg, off, v1 int32 + _, _, _ = neg, off, v1 + neg = 0 + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32('-') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + neg = int32(1) + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32('+') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + } + } + off = int32(3600) * _getint2(tls, p) + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32(':') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + off = off + int32(60)*_getint2(tls, p) + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32(':') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + off = off + _getint2(tls, p) + } + } + if neg != 0 { + v1 = -off + } else { + v1 = off + } + return v1 +} + +func _getrule(tls *TLS, p uintptr, rule uintptr) { + var r, v1 int32 + _, _ = r, v1 + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) + **(**int32)(__ccgo_up(rule)) = v1 + r = v1 + if r != int32('M') { + if r == int32('J') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + } else { + **(**int32)(__ccgo_up(rule)) = 0 + } + **(**int32)(__ccgo_up(rule + 1*4)) = _getint2(tls, p) + } else { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + **(**int32)(__ccgo_up(rule + 1*4)) = _getint2(tls, p) + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + **(**int32)(__ccgo_up(rule + 2*4)) = _getint2(tls, p) + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + **(**int32)(__ccgo_up(rule + 3*4)) = _getint2(tls, p) + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32('/') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + **(**int32)(__ccgo_up(rule + 4*4)) = _getoff(tls, p) + } else { + **(**int32)(__ccgo_up(rule + 4*4)) = int32(7200) + } +} + +func _getname(tls *TLS, d uintptr, p uintptr) { + var i, v3 int32 + _, _ = i, v3 + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p))))) == int32('<') { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + i = 0 + for { + if !(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))) != 0 && Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i)))) != int32('>')) { + break + } + if i < int32(TZNAME_MAX) { + **(**uint8)(__ccgo_up(d + uintptr(i))) = **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))) + } + goto _1 + _1: + ; + i = i + 1 + } + if **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))) != 0 { + **(**uintptr)(__ccgo_up(p)) = **(**uintptr)(__ccgo_up(p)) + 1 + } + } else { + i = 0 + for { + if !(Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))))|int32(32)-int32('a')) < uint32(26)) { + break + } + if i < int32(TZNAME_MAX) { + **(**uint8)(__ccgo_up(d + uintptr(i))) = **(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(p)) + uintptr(i))) + } + goto _2 + _2: + ; + i = i + 1 + } + } + **(**uintptr)(__ccgo_up(p)) += uintptr(i) + if i < int32(TZNAME_MAX) { + v3 = i + } else { + v3 = int32(TZNAME_MAX) + } + **(**uint8)(__ccgo_up(d + uintptr(v3))) = uint8(0) +} + +func _zi_read32(tls *TLS, z uintptr) (r Tuint32_t) { + return uint32(**(**uint8)(__ccgo_up(z)))< Uint64FromInt32(Int32FromInt32(PATH_MAX)+Int32FromInt32(1)) { + **(**uintptr)(__ccgo_up(bp + 288)) = uintptr(unsafe.Pointer(&X__utc)) + i = Uint64FromInt32(3) + } + if i >= _old_tz_size { + _old_tz_size = _old_tz_size * uint64(2) + if i >= _old_tz_size { + _old_tz_size = i + uint64(1) + } + if _old_tz_size > Uint64FromInt32(Int32FromInt32(PATH_MAX)+Int32FromInt32(2)) { + _old_tz_size = Uint64FromInt32(Int32FromInt32(PATH_MAX) + Int32FromInt32(2)) + } + _old_tz = Xmalloc(tls, _old_tz_size) + } + if _old_tz != 0 { + Xmemcpy(tls, _old_tz, **(**uintptr)(__ccgo_up(bp + 288)), i+uint64(1)) + } + posix_form = 0 + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 288))))) != int32(':') { + **(**uintptr)(__ccgo_up(bp + 296)) = **(**uintptr)(__ccgo_up(bp + 288)) + _getname(tls, bp+308, bp+296) + if **(**uintptr)(__ccgo_up(bp + 296)) != **(**uintptr)(__ccgo_up(bp + 288)) && (Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 296))))) == int32('+') || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 296))))) == int32('-') || BoolInt32(uint32(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 296)))))-uint32('0') < uint32(10)) != 0 || !(Xstrcmp(tls, bp+308, __ccgo_ts+1755) != 0) || !(Xstrcmp(tls, bp+308, __ccgo_ts+1759) != 0)) { + posix_form = int32(1) + } + } + /* Non-suid can use an absolute tzfile pathname or a relative + * pathame beginning with "."; in secure mode, only the + * standard path will be searched. */ + if !(posix_form != 0) { + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 288))))) == int32(':') { + **(**uintptr)(__ccgo_up(bp + 288)) = **(**uintptr)(__ccgo_up(bp + 288)) + 1 + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 288))))) == int32('/') || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 288))))) == int32('.') { + if !(X__libc.Fsecure != 0) || !(Xstrcmp(tls, **(**uintptr)(__ccgo_up(bp + 288)), __ccgo_ts+1740) != 0) { + map1 = X__map_file(tls, **(**uintptr)(__ccgo_up(bp + 288)), uintptr(unsafe.Pointer(&_map_size))) + } + } else { + l = _strlen(tls, **(**uintptr)(__ccgo_up(bp + 288))) + if l <= uint64(NAME_MAX) && !(Xstrchr(tls, **(**uintptr)(__ccgo_up(bp + 288)), int32('.')) != 0) { + Xmemcpy(tls, pathname, **(**uintptr)(__ccgo_up(bp + 288)), l+uint64(1)) + **(**uint8)(__ccgo_up(pathname + uintptr(l))) = uint8(0) + try = uintptr(unsafe.Pointer(&_search)) + for { + if !(!(map1 != 0) && **(**uint8)(__ccgo_up(try)) != 0) { + break + } + l = _strlen(tls, try) + Xmemcpy(tls, pathname-uintptr(l), try, l) + map1 = X__map_file(tls, pathname-uintptr(l), uintptr(unsafe.Pointer(&_map_size))) + goto _3 + _3: + ; + try = try + uintptr(l+uint64(1)) + } + } + } + if !(map1 != 0) { + **(**uintptr)(__ccgo_up(bp + 288)) = uintptr(unsafe.Pointer(&X__utc)) + } + } + if map1 != 0 && (_map_size < uint64(44) || Xmemcmp(tls, map1, __ccgo_ts+1763, uint64(4)) != 0) { + X__munmap(tls, map1, _map_size) + map1 = uintptr(0) + **(**uintptr)(__ccgo_up(bp + 288)) = uintptr(unsafe.Pointer(&X__utc)) + } + _zi = map1 + if map1 != 0 { + scale = int32(2) + if Int32FromUint8(**(**uint8)(__ccgo_up(map1 + 4))) != int32('1') { + *(*[6]uint8)(unsafe.Pointer(bp)) = [6]uint8{ + 0: uint8(1), + 1: uint8(1), + 2: uint8(8), + 3: uint8(5), + 4: uint8(6), + 5: uint8(1), + } + skip = _zi_dotprod(tls, _zi+uintptr(20), bp, uint64(6)) + _trans = _zi + uintptr(skip) + uintptr(44) + uintptr(44) + scale = scale + 1 + } else { + _trans = _zi + uintptr(44) + } + _index = _trans + uintptr(_zi_read32(tls, _trans-uintptr(12))<> scale) + if !(n != 0) { + if alt != 0 { + **(**Tsize_t)(__ccgo_up(alt)) = uint64(0) + } + return uint64(0) + } + /* Binary search for 'most-recent rule before t'. */ + for n > uint64(1) { + m = a + n/uint64(2) + x = uint64(_zi_read32(tls, _trans+uintptr(m<> scale) + if a == n-uint64(1) { + return Uint64FromInt32(-Int32FromInt32(1)) + } + if a == uint64(0) { + x = uint64(_zi_read32(tls, _trans)) + if scale == int32(3) { + x = x<>(m-int32(1))&int32(1) + } + return r +} + +/* Convert a POSIX DST rule plus year to seconds since epoch. */ + +func _rule_to_secs(tls *TLS, rule uintptr, year int32) (r int64) { + bp := tls.Alloc(16) + defer tls.Free(16) + var d, days, m, n, wday, x int32 + var t int64 + var _ /* is_leap at bp+0 */ int32 + _, _, _, _, _, _, _ = d, days, m, n, t, wday, x + t = X__year_to_secs(tls, int64(year), bp) + if **(**int32)(__ccgo_up(rule)) != int32('M') { + x = **(**int32)(__ccgo_up(rule + 1*4)) + if **(**int32)(__ccgo_up(rule)) == int32('J') && (x < int32(60) || !(**(**int32)(__ccgo_up(bp)) != 0)) { + x = x - 1 + } + t = t + int64(int32(86400)*x) + } else { + m = **(**int32)(__ccgo_up(rule + 1*4)) + n = **(**int32)(__ccgo_up(rule + 2*4)) + d = **(**int32)(__ccgo_up(rule + 3*4)) + t = t + int64(X__month_to_secs(tls, m-int32(1), **(**int32)(__ccgo_up(bp)))) + wday = int32((t+int64(Int32FromInt32(4)*Int32FromInt32(86400)))%int64(Int32FromInt32(7)*Int32FromInt32(86400))) / int32(86400) + days = d - wday + if days < 0 { + days = days + int32(7) + } + if n == int32(5) && days+int32(28) >= _days_in_month1(tls, m, **(**int32)(__ccgo_up(bp))) { + n = int32(4) + } + t = t + int64(int32(86400)*(days+int32(7)*(n-int32(1)))) + } + t = t + int64(**(**int32)(__ccgo_up(rule + 4*4))) + return t +} + +/* Determine the time zone in effect for a given time in seconds since the + * epoch. It can be given in local or universal time. The results will + * indicate whether DST is in effect at the queried time, and will give both + * the GMT offset for the active zone/DST rule and the opposite DST. This + * enables a caller to efficiently adjust for the case where an explicit + * DST specification mismatches what would be in effect at the time. */ + +func X__secs_to_zone(tls *TLS, t int64, local int32, isdst uintptr, offset uintptr, oppoff uintptr, zonename uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v local=%v isdst=%v offset=%v oppoff=%v zonename=%v, (%v:)", tls, t, local, isdst, offset, oppoff, zonename, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + var i Tsize_t + var t0, t1, y int64 + var _ /* alt at bp+0 */ Tsize_t + _, _, _, _ = i, t0, t1, y + ___lock(tls, uintptr(unsafe.Pointer(&_lock4))) + _do_tzset(tls) + if _zi != 0 { + i = _scan_trans(tls, t, local, bp) + if i != Uint64FromInt32(-Int32FromInt32(1)) { + **(**int32)(__ccgo_up(isdst)) = Int32FromUint8(**(**uint8)(__ccgo_up(_types + uintptr(uint64(6)*i+uint64(4))))) + **(**int64)(__ccgo_up(offset)) = int64(Int32FromUint32(_zi_read32(tls, _types+uintptr(uint64(6)*i)))) + **(**uintptr)(__ccgo_up(zonename)) = _abbrevs + uintptr(**(**uint8)(__ccgo_up(_types + uintptr(uint64(6)*i+uint64(5))))) + if oppoff != 0 { + **(**int64)(__ccgo_up(oppoff)) = int64(Int32FromUint32(_zi_read32(tls, _types+uintptr(uint64(6)***(**Tsize_t)(__ccgo_up(bp)))))) + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) + return + } + } + if !(Xdaylight != 0) { + goto std + } + /* FIXME: may be broken if DST changes right at year boundary? + * Also, this could be more efficient.*/ + y = t/int64(31556952) + int64(70) + for X__year_to_secs(tls, y, uintptr(0)) > t { + y = y - 1 + } + for X__year_to_secs(tls, y+int64(1), uintptr(0)) < t { + y = y + 1 + } + t0 = _rule_to_secs(tls, uintptr(unsafe.Pointer(&_r0)), int32(y)) + t1 = _rule_to_secs(tls, uintptr(unsafe.Pointer(&_r12)), int32(y)) + if !(local != 0) { + t0 = t0 + Xtimezone + t1 = t1 + int64(_dst_off) + } + if t0 < t1 { + if t >= t0 && t < t1 { + goto dst + } + goto std + } else { + if t >= t1 && t < t0 { + goto std + } + goto dst + } + goto std +std: + ; + **(**int32)(__ccgo_up(isdst)) = 0 + **(**int64)(__ccgo_up(offset)) = -Xtimezone + if oppoff != 0 { + **(**int64)(__ccgo_up(oppoff)) = int64(-_dst_off) + } + **(**uintptr)(__ccgo_up(zonename)) = Xtzname[0] + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) + return + goto dst +dst: + ; + **(**int32)(__ccgo_up(isdst)) = int32(1) + **(**int64)(__ccgo_up(offset)) = int64(-_dst_off) + if oppoff != 0 { + **(**int64)(__ccgo_up(oppoff)) = -Xtimezone + } + **(**uintptr)(__ccgo_up(zonename)) = Xtzname[int32(1)] + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) +} + +func ___tzset(tls *TLS) { + ___lock(tls, uintptr(unsafe.Pointer(&_lock4))) + _do_tzset(tls) + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) +} + +func X__tm_to_tzname(tls *TLS, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + var p uintptr + _ = p + p = (*Ttm)(unsafe.Pointer(tm)).F__tm_zone + ___lock(tls, uintptr(unsafe.Pointer(&_lock4))) + _do_tzset(tls) + if p != uintptr(unsafe.Pointer(&X__utc)) && p != Xtzname[0] && p != Xtzname[int32(1)] && (!(_zi != 0) || uint64(p)-uint64(_abbrevs) >= Uint64FromInt64(int64(_abbrevs_end)-int64(_abbrevs))) { + p = __ccgo_ts + } + ___unlock(tls, uintptr(unsafe.Pointer(&_lock4))) + return p +} + +func X__year_to_secs(tls *TLS, year int64, is_leap uintptr) (r int64) { + if __ccgo_strace { + trc("tls=%v year=%v is_leap=%v, (%v:)", tls, year, is_leap, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var centuries, cycles, leaps, leaps1, rem, y int32 + var _ /* dummy at bp+0 */ int32 + _, _, _, _, _, _ = centuries, cycles, leaps, leaps1, rem, y + if Uint64FromInt64(year)-uint64(2) <= uint64(136) { + y = int32(year) + leaps = (y - int32(68)) >> int32(2) + if !((y-Int32FromInt32(68))&Int32FromInt32(3) != 0) { + leaps = leaps - 1 + if is_leap != 0 { + **(**int32)(__ccgo_up(is_leap)) = int32(1) + } + } else { + if is_leap != 0 { + **(**int32)(__ccgo_up(is_leap)) = 0 + } + } + return int64(int32(31536000)*(y-int32(70)) + int32(86400)*leaps) + } + if !(is_leap != 0) { + is_leap = bp + } + cycles = int32((year - int64(100)) / int64(400)) + rem = int32((year - int64(100)) % int64(400)) + if rem < 0 { + cycles = cycles - 1 + rem = rem + int32(400) + } + if !(rem != 0) { + **(**int32)(__ccgo_up(is_leap)) = int32(1) + centuries = 0 + leaps1 = 0 + } else { + if rem >= int32(200) { + if rem >= int32(300) { + centuries = int32(3) + rem = rem - int32(300) + } else { + centuries = int32(2) + rem = rem - int32(200) + } + } else { + if rem >= int32(100) { + centuries = int32(1) + rem = rem - int32(100) + } else { + centuries = 0 + } + } + if !(rem != 0) { + **(**int32)(__ccgo_up(is_leap)) = 0 + leaps1 = 0 + } else { + leaps1 = Int32FromUint32(Uint32FromInt32(rem) / uint32(4)) + rem = Int32FromUint32(uint32(rem) % Uint32FromUint32(4)) + **(**int32)(__ccgo_up(is_leap)) = BoolInt32(!(rem != 0)) + } + } + leaps1 = leaps1 + (int32(97)*cycles + int32(24)*centuries - **(**int32)(__ccgo_up(is_leap))) + return (year-int64(100))*int64(31536000) + int64(leaps1)*int64(86400) + int64(946684800) + int64(86400) +} + +func Xasctime(tls *TLS, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__asctime_r(tls, tm, uintptr(unsafe.Pointer(&_buf9))) +} + +var _buf9 [26]uint8 + +func X__asctime_r(tls *TLS, tm uintptr, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v tm=%v buf=%v, (%v:)", tls, tm, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + if Xsnprintf(tls, buf, uint64(26), __ccgo_ts+1768, VaList(bp+8, X__nl_langinfo_l(tls, int32(ABDAY_1)+(*Ttm)(unsafe.Pointer(tm)).Ftm_wday, uintptr(unsafe.Pointer(&X__c_locale))), X__nl_langinfo_l(tls, int32(ABMON_1)+(*Ttm)(unsafe.Pointer(tm)).Ftm_mon, uintptr(unsafe.Pointer(&X__c_locale))), (*Ttm)(unsafe.Pointer(tm)).Ftm_mday, (*Ttm)(unsafe.Pointer(tm)).Ftm_hour, (*Ttm)(unsafe.Pointer(tm)).Ftm_min, (*Ttm)(unsafe.Pointer(tm)).Ftm_sec, int32(1900)+(*Ttm)(unsafe.Pointer(tm)).Ftm_year)) >= int32(26) { + /* ISO C requires us to use the above format string, + * even if it will not fit in the buffer. Thus asctime_r + * is _supposed_ to crash if the fields in tm are too large. + * We follow this behavior and crash "gracefully" to warn + * application developers that they may not be so lucky + * on other implementations (e.g. stack smashing..). + */ + **(**uint8)(__ccgo_up(UintptrFromInt32(0))) = uint8(0) + } + return buf +} + +func Xasctime_r(tls *TLS, tm uintptr, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v tm=%v buf=%v, (%v:)", tls, tm, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__asctime_r(tls, tm, buf) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xclock(tls *TLS) (r Tclock_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ts at bp+0 */ Ttimespec + if X__clock_gettime(tls, int32(CLOCK_PROCESS_CPUTIME_ID), bp) != 0 { + return int64(-int32(1)) + } + if (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec > Int64FromInt64(0x7fffffffffffffff)/Int64FromInt32(1000000) || (**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec/int64(1000) > int64(0x7fffffffffffffff)-int64(1000000)*(**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec { + return int64(-int32(1)) + } + return (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec*int64(1000000) + (**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec/int64(1000) +} + +func Xclock_getcpuclockid(tls *TLS, pid Tpid_t, clk uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v pid=%v clk=%v, (%v:)", tls, pid, clk, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var id Tclockid_t + var ret int32 + var _ /* ts at bp+0 */ Ttimespec + _, _ = id, ret + id = Int32FromUint32(Uint32FromInt32(-pid-Int32FromInt32(1))*uint32(8) + uint32(2)) + ret = int32(X__syscall2(tls, int64(SYS_clock_getres), int64(id), int64(bp))) + if ret == -int32(EINVAL) { + ret = -int32(ESRCH) + } + if ret != 0 { + return -ret + } + **(**Tclockid_t)(__ccgo_up(clk)) = id + return 0 +} + +func Xclock_getres(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v ts=%v, (%v:)", tls, clk, ts, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* If reaching this point, it's a 64-bit arch or time64-only + * 32-bit arch and we can get result directly into timespec. */ + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_clock_getres), int64(clk), int64(ts))))) +} + +func X__clock_gettime(tls *TLS, clk Tclockid_t, ts uintptr) (r1 int32) { + if __ccgo_strace { + trc("tls=%v clk=%v ts=%v, (%v:)", tls, clk, ts, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + r = int32(X__syscall2(tls, int64(SYS_clock_gettime), int64(clk), int64(ts))) + if r == -int32(ENOSYS) { + if clk == CLOCK_REALTIME { + X__syscall2(tls, int64(SYS_gettimeofday), int64(ts), int64(Int32FromInt32(0))) + (*Ttimespec)(unsafe.Pointer(ts)).Ftv_nsec = int64(int32((*Ttimespec)(unsafe.Pointer(ts)).Ftv_nsec) * int32(1000)) + return 0 + } + r = -int32(EINVAL) + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xclock_gettime(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v ts=%v, (%v:)", tls, clk, ts, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__clock_gettime(tls, clk, ts) +} + +func X__clock_nanosleep(tls *TLS, clk Tclockid_t, flags int32, req uintptr, rem uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v flags=%v req=%v rem=%v, (%v:)", tls, clk, flags, req, rem, origin(2)) + defer func() { trc("-> %v", r) }() + } + if clk == int32(CLOCK_THREAD_CPUTIME_ID) { + return int32(EINVAL) + } + if clk == CLOCK_REALTIME && !(flags != 0) { + return int32(-___syscall_cp(tls, int64(SYS_nanosleep), int64(req), int64(rem), 0, 0, 0, 0)) + } + return int32(-___syscall_cp(tls, int64(SYS_clock_nanosleep), int64(clk), int64(flags), int64(req), int64(rem), 0, 0)) +} + +func Xclock_nanosleep(tls *TLS, clk Tclockid_t, flags int32, req uintptr, rem uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v flags=%v req=%v rem=%v, (%v:)", tls, clk, flags, req, rem, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__clock_nanosleep(tls, clk, flags, req, rem) +} + +func Xclock_settime(tls *TLS, clk Tclockid_t, ts uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v clk=%v ts=%v, (%v:)", tls, clk, ts, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_clock_settime), int64(clk), int64(ts))))) +} + +func Xctime(tls *TLS, t uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + var tm uintptr + _ = tm + tm = Xlocaltime(tls, t) + if !(tm != 0) { + return uintptr(0) + } + return Xasctime(tls, tm) +} + +func Xctime_r(tls *TLS, t uintptr, buf uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v buf=%v, (%v:)", tls, t, buf, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var tm_p, v1 uintptr + var _ /* tm at bp+0 */ Ttm + _, _ = tm_p, v1 + tm_p = Xlocaltime_r(tls, t, bp) + if tm_p != 0 { + v1 = Xasctime_r(tls, tm_p, buf) + } else { + v1 = uintptr(0) + } + return v1 +} + +func Xdifftime(tls *TLS, t1 Ttime_t, t0 Ttime_t) (r float64) { + if __ccgo_strace { + trc("tls=%v t1=%v t0=%v, (%v:)", tls, t1, t0, origin(2)) + defer func() { trc("-> %v", r) }() + } + return float64(t1 - t0) +} + +type Ttimeb = struct { + Ftime Ttime_t + Fmillitm uint16 + Ftimezone int16 + Fdstflag int16 +} + +func Xftime(tls *TLS, tp uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v tp=%v, (%v:)", tls, tp, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1 int16 + var _ /* ts at bp+0 */ Ttimespec + _ = v1 + Xclock_gettime(tls, CLOCK_REALTIME, bp) + (*Ttimeb)(unsafe.Pointer(tp)).Ftime = (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec + (*Ttimeb)(unsafe.Pointer(tp)).Fmillitm = Uint16FromInt64((**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec / int64(1000000)) + v1 = Int16FromInt32(0) + (*Ttimeb)(unsafe.Pointer(tp)).Fdstflag = v1 + (*Ttimeb)(unsafe.Pointer(tp)).Ftimezone = v1 + return 0 +} + +func Xgetdate(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(112) + defer tls.Free(112) + var datemsk, f, p, ret uintptr + var _ /* cs at bp+100 */ int32 + var _ /* fmt at bp+0 */ [100]uint8 + _, _, _, _ = datemsk, f, p, ret + ret = uintptr(0) + datemsk = Xgetenv(tls, __ccgo_ts+1800) + f = uintptr(0) + _pthread_setcancelstate(tls, PTHREAD_CANCEL_DEFERRED, bp+100) + if !(datemsk != 0) { + Xgetdate_err = int32(1) + goto out + } + f = Xfopen(tls, datemsk, __ccgo_ts+315) + if !(f != 0) { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(ENOMEM) { + Xgetdate_err = int32(6) + } else { + Xgetdate_err = int32(2) + } + goto out + } + for Xfgets(tls, bp, int32(100), f) != 0 { + p = Xstrptime(tls, s, bp, uintptr(unsafe.Pointer(&_tmbuf))) + if p != 0 && !(**(**uint8)(__ccgo_up(p)) != 0) { + ret = uintptr(unsafe.Pointer(&_tmbuf)) + goto out + } + } + if Xferror(tls, f) != 0 { + Xgetdate_err = int32(5) + } else { + Xgetdate_err = int32(7) + } + goto out +out: + ; + if f != 0 { + Xfclose(tls, f) + } + _pthread_setcancelstate(tls, **(**int32)(__ccgo_up(bp + 100)), uintptr(0)) + return ret +} + +var _tmbuf Ttm + +func Xgettimeofday(tls *TLS, tv uintptr, tz uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v tv=%v tz=%v, (%v:)", tls, tv, tz, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ts at bp+0 */ Ttimespec + if !(tv != 0) { + return 0 + } + Xclock_gettime(tls, CLOCK_REALTIME, bp) + (*Ttimeval)(unsafe.Pointer(tv)).Ftv_sec = (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec + (*Ttimeval)(unsafe.Pointer(tv)).Ftv_usec = int64(int32((**(**Ttimespec)(__ccgo_up(bp))).Ftv_nsec) / int32(1000)) + return 0 +} + +func Xgmtime(tls *TLS, t uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__gmtime_r(tls, t, uintptr(unsafe.Pointer(&_tm))) +} + +var _tm Ttm + +func X__gmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + if X__secs_to_tm(tls, int64(**(**Ttime_t)(__ccgo_up(t))), tm) < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return uintptr(0) + } + (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst = 0 + (*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff = 0 + (*Ttm)(unsafe.Pointer(tm)).F__tm_zone = uintptr(unsafe.Pointer(&X__utc)) + return tm +} + +func Xgmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__gmtime_r(tls, t, tm) +} + +func Xlocaltime(tls *TLS, t uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__localtime_r(tls, t, uintptr(unsafe.Pointer(&_tm1))) +} + +var _tm1 Ttm + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func X__localtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + /* Reject time_t values whose year would overflow int because + * __secs_to_zone cannot safely handle them. */ + if int64(**(**Ttime_t)(__ccgo_up(t))) < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff))*Int64FromInt64(31622400) || int64(**(**Ttime_t)(__ccgo_up(t))) > Int64FromInt32(INT_MAX)*Int64FromInt64(31622400) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return uintptr(0) + } + X__secs_to_zone(tls, int64(**(**Ttime_t)(__ccgo_up(t))), 0, tm+32, tm+40, uintptr(0), tm+48) + if X__secs_to_tm(tls, int64(**(**Ttime_t)(__ccgo_up(t)))+(*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff, tm) < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return uintptr(0) + } + return tm +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xlocaltime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__localtime_r(tls, t, tm) +} + +func Xmktime(tls *TLS, tm uintptr) (r Ttime_t) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var t int64 + var _ /* new at bp+0 */ Ttm + var _ /* opp at bp+56 */ int64 + _ = t + t = X__tm_to_secs(tls, tm) + X__secs_to_zone(tls, t, int32(1), bp+32, bp+40, bp+56, bp+48) + if (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst >= 0 && (**(**Ttm)(__ccgo_up(bp))).Ftm_isdst != (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst { + t = t - int64(**(**int64)(__ccgo_up(bp + 56))-(**(**Ttm)(__ccgo_up(bp))).F__tm_gmtoff) + } + t = t - int64((**(**Ttm)(__ccgo_up(bp))).F__tm_gmtoff) + if t != t { + goto error + } + X__secs_to_zone(tls, t, 0, bp+32, bp+40, bp+56, bp+48) + if X__secs_to_tm(tls, t+int64((**(**Ttm)(__ccgo_up(bp))).F__tm_gmtoff), bp) < 0 { + goto error + } + **(**Ttm)(__ccgo_up(tm)) = **(**Ttm)(__ccgo_up(bp)) + return t + goto error +error: + ; + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return int64(-int32(1)) +} + +func Xnanosleep(tls *TLS, req uintptr, rem uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v req=%v rem=%v, (%v:)", tls, req, rem, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt32(-X__clock_nanosleep(tls, CLOCK_REALTIME, 0, req, rem)))) +} + +func _is_leap(tls *TLS, y int32) (r int32) { + /* Avoid overflow */ + if y > Int32FromInt32(INT_MAX)-Int32FromInt32(1900) { + y = y - int32(2000) + } + y = y + int32(1900) + return BoolInt32(!(y%Int32FromInt32(4) != 0) && (y%int32(100) != 0 || !(y%Int32FromInt32(400) != 0))) +} + +func _week_num(tls *TLS, tm uintptr) (r int32) { + var dec31, jan1, val int32 + _, _, _ = dec31, jan1, val + val = Int32FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday) + uint32(7) - (Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday)+uint32(6))%uint32(7)) / uint32(7)) + /* If 1 Jan is just 1-3 days past Monday, + * the previous week is also in this year. */ + if (Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday)+uint32(371)-Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday)-uint32(2))%uint32(7) <= uint32(2) { + val = val + 1 + } + if !(val != 0) { + val = int32(52) + /* If 31 December of prev year a Thursday, + * or Friday of a leap year, then the + * prev year has 53 weeks. */ + dec31 = Int32FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) + uint32(7) - Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday) - uint32(1)) % uint32(7)) + if dec31 == int32(4) || dec31 == int32(5) && _is_leap(tls, (*Ttm)(unsafe.Pointer(tm)).Ftm_year%int32(400)-int32(1)) != 0 { + val = val + 1 + } + } else { + if val == int32(53) { + /* If 1 January is not a Thursday, and not + * a Wednesday of a leap year, then this + * year has only 52 weeks. */ + jan1 = Int32FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) + uint32(371) - Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday)) % uint32(7)) + if jan1 != int32(4) && (jan1 != int32(3) || !(_is_leap(tls, (*Ttm)(unsafe.Pointer(tm)).Ftm_year) != 0)) { + val = int32(1) + } + } + } + return val +} + +func X__strftime_fmt_1(tls *TLS, s uintptr, l uintptr, f int32, tm uintptr, loc Tlocale_t, pad int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v l=%v f=%v tm=%v loc=%v pad=%v, (%v:)", tls, s, l, f, tm, loc, pad, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var d, fmt, v4, v5 uintptr + var def_pad, width, v1 int32 + var item Tnl_item + var val int64 + _, _, _, _, _, _, _, _, _ = d, def_pad, fmt, item, val, width, v1, v4, v5 + fmt = __ccgo_ts + 1662 + width = int32(2) + def_pad = int32('0') + switch f { + case int32('a'): + if Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) > uint32(6) { + goto string + } + item = int32(ABDAY_1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_wday + goto nl_strcat + case int32('A'): + if Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) > uint32(6) { + goto string + } + item = int32(DAY_1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_wday + goto nl_strcat + case int32('h'): + fallthrough + case int32('b'): + if Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_mon) > uint32(11) { + goto string + } + item = int32(ABMON_1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_mon + goto nl_strcat + case int32('B'): + if Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_mon) > uint32(11) { + goto string + } + item = int32(MON_1) + (*Ttm)(unsafe.Pointer(tm)).Ftm_mon + goto nl_strcat + case int32('c'): + item = int32(D_T_FMT) + goto nl_strftime + case int32('C'): + val = (int64(1900) + int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year)) / int64(100) + goto number + case int32('e'): + def_pad = int32('_') + fallthrough + case int32('d'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_mday) + goto number + case int32('D'): + fmt = __ccgo_ts + 1808 + goto recu_strftime + case int32('F'): + fmt = __ccgo_ts + 1817 + goto recu_strftime + case int32('g'): + fallthrough + case int32('G'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year) + int64(1900) + if (*Ttm)(unsafe.Pointer(tm)).Ftm_yday < int32(3) && _week_num(tls, tm) != int32(1) { + val = val - 1 + } else { + if (*Ttm)(unsafe.Pointer(tm)).Ftm_yday > int32(360) && _week_num(tls, tm) == int32(1) { + val = val + 1 + } + } + if f == int32('g') { + val = val % int64(100) + } else { + width = int32(4) + } + goto number + case int32('H'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_hour) + goto number + case int32('l'): + def_pad = int32('_') + fallthrough + case int32('I'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_hour) + if !(val != 0) { + val = int64(12) + } else { + if val > int64(12) { + val = val - int64(12) + } + } + goto number + case int32('j'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_yday + int32(1)) + width = int32(3) + goto number + case int32('k'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_hour) + def_pad = int32('_') + goto number + case int32('m'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_mon + int32(1)) + goto number + case int32('M'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_min) + goto number + case int32('n'): + **(**Tsize_t)(__ccgo_up(l)) = uint64(1) + return __ccgo_ts + 301 + case int32('p'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_hour >= int32(12) { + v1 = int32(PM_STR) + } else { + v1 = int32(AM_STR) + } + item = v1 + goto nl_strcat + case int32('P'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_hour >= int32(12) { + v1 = int32(PM_STR) + } else { + v1 = int32(AM_STR) + } + item = v1 + fmt = X__nl_langinfo_l(tls, item, loc) + d = s + **(**Tsize_t)(__ccgo_up(l)) = uint64(0) + for { + if !(**(**uint8)(__ccgo_up(fmt)) != 0) { + break + } + v4 = d + d = d + 1 + v5 = fmt + fmt = fmt + 1 + **(**uint8)(__ccgo_up(v4)) = Uint8FromInt32(Xtolower(tls, Int32FromUint8(**(**uint8)(__ccgo_up(v5))))) + goto _3 + _3: + ; + **(**Tsize_t)(__ccgo_up(l)) = **(**Tsize_t)(__ccgo_up(l)) + 1 + } + return s + case int32('r'): + item = int32(T_FMT_AMPM) + goto nl_strftime + case int32('R'): + fmt = __ccgo_ts + 1826 + goto recu_strftime + case int32('s'): + val = X__tm_to_secs(tls, tm) - (*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff + width = int32(1) + goto number + case int32('S'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_sec) + goto number + case int32('t'): + **(**Tsize_t)(__ccgo_up(l)) = uint64(1) + return __ccgo_ts + 1400 + case int32('T'): + fmt = __ccgo_ts + 1832 + goto recu_strftime + case int32('u'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_wday != 0 { + v1 = (*Ttm)(unsafe.Pointer(tm)).Ftm_wday + } else { + v1 = int32(7) + } + val = int64(v1) + width = int32(1) + goto number + case int32('U'): + val = Int64FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday) + uint32(7) - Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday)) / uint32(7)) + goto number + case int32('W'): + val = Int64FromUint32((Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_yday) + uint32(7) - (Uint32FromInt32((*Ttm)(unsafe.Pointer(tm)).Ftm_wday)+uint32(6))%uint32(7)) / uint32(7)) + goto number + case int32('V'): + val = int64(_week_num(tls, tm)) + goto number + case int32('w'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_wday) + width = int32(1) + goto number + case int32('x'): + item = int32(D_FMT) + goto nl_strftime + case int32('X'): + item = int32(T_FMT) + goto nl_strftime + case int32('y'): + val = (int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year) + int64(1900)) % int64(100) + if val < 0 { + val = -val + } + goto number + case int32('Y'): + val = int64((*Ttm)(unsafe.Pointer(tm)).Ftm_year) + int64(1900) + if val >= int64(10000) { + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1841, VaList(bp+8, val))) + return s + } + width = int32(4) + goto number + case int32('z'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst < 0 { + **(**Tsize_t)(__ccgo_up(l)) = uint64(0) + return __ccgo_ts + } + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1847, VaList(bp+8, (*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff/int64(3600)*int64(100)+(*Ttm)(unsafe.Pointer(tm)).F__tm_gmtoff%int64(3600)/int64(60)))) + return s + case int32('Z'): + if (*Ttm)(unsafe.Pointer(tm)).Ftm_isdst < 0 { + **(**Tsize_t)(__ccgo_up(l)) = uint64(0) + return __ccgo_ts + } + fmt = X__tm_to_tzname(tls, tm) + goto string + case int32('%'): + **(**Tsize_t)(__ccgo_up(l)) = uint64(1) + return __ccgo_ts + 348 + default: + return uintptr(0) + } + goto number +number: + ; + if pad != 0 { + v1 = pad + } else { + v1 = def_pad + } + switch v1 { + case int32('-'): + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1854, VaList(bp+8, val))) + case int32('_'): + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1859, VaList(bp+8, width, val))) + case int32('0'): + fallthrough + default: + **(**Tsize_t)(__ccgo_up(l)) = Uint64FromInt32(Xsnprintf(tls, s, uint64(100), __ccgo_ts+1865, VaList(bp+8, width, val))) + break + } + return s + goto nl_strcat +nl_strcat: + ; + fmt = X__nl_langinfo_l(tls, item, loc) + goto string +string: + ; + **(**Tsize_t)(__ccgo_up(l)) = _strlen(tls, fmt) + return fmt + goto nl_strftime +nl_strftime: + ; + fmt = X__nl_langinfo_l(tls, item, loc) + goto recu_strftime +recu_strftime: + ; + **(**Tsize_t)(__ccgo_up(l)) = X__strftime_l(tls, s, uint64(100), fmt, tm, loc) + if !(**(**Tsize_t)(__ccgo_up(l)) != 0) { + return uintptr(0) + } + return s +} + +func X__strftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v loc=%v, (%v:)", tls, s, n, f, tm, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(128) + defer tls.Free(128) + var d, l, v2 Tsize_t + var pad, plus, v4 int32 + var t, v3 uintptr + var width uint64 + var v9 bool + var _ /* buf at bp+8 */ [100]uint8 + var _ /* k at bp+0 */ Tsize_t + var _ /* p at bp+112 */ uintptr + _, _, _, _, _, _, _, _, _, _ = d, l, pad, plus, t, width, v2, v3, v4, v9 + l = uint64(0) + for { + if !(l < n) { + break + } + if !(**(**uint8)(__ccgo_up(f)) != 0) { + **(**uint8)(__ccgo_up(s + uintptr(l))) = uint8(0) + return l + } + if Int32FromUint8(**(**uint8)(__ccgo_up(f))) != int32('%') { + v2 = l + l = l + 1 + **(**uint8)(__ccgo_up(s + uintptr(v2))) = **(**uint8)(__ccgo_up(f)) + goto _1 + } + f = f + 1 + pad = 0 + if Int32FromUint8(**(**uint8)(__ccgo_up(f))) == int32('-') || Int32FromUint8(**(**uint8)(__ccgo_up(f))) == int32('_') || Int32FromUint8(**(**uint8)(__ccgo_up(f))) == int32('0') { + v3 = f + f = f + 1 + pad = Int32FromUint8(**(**uint8)(__ccgo_up(v3))) + } + v4 = BoolInt32(Int32FromUint8(**(**uint8)(__ccgo_up(f))) == Int32FromUint8('+')) + plus = v4 + if v4 != 0 { + f = f + 1 + } + if BoolInt32(uint32(**(**uint8)(__ccgo_up(f)))-uint32('0') < uint32(10)) != 0 { + width = Xstrtoul(tls, f, bp+112, int32(10)) + } else { + width = uint64(0) + **(**uintptr)(__ccgo_up(bp + 112)) = f + } + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('C') || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('F') || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('G') || Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('Y') { + if !(width != 0) && **(**uintptr)(__ccgo_up(bp + 112)) != f { + width = uint64(1) + } + } else { + width = uint64(0) + } + f = **(**uintptr)(__ccgo_up(bp + 112)) + if Int32FromUint8(**(**uint8)(__ccgo_up(f))) == int32('E') || Int32FromUint8(**(**uint8)(__ccgo_up(f))) == int32('O') { + f = f + 1 + } + t = X__strftime_fmt_1(tls, bp+8, bp, Int32FromUint8(**(**uint8)(__ccgo_up(f))), tm, loc, pad) + if !(t != 0) { + break + } + if width != 0 { + /* Trim off any sign and leading zeros, then + * count remaining digits to determine behavior + * for the + flag. */ + if Int32FromUint8(**(**uint8)(__ccgo_up(t))) == int32('+') || Int32FromUint8(**(**uint8)(__ccgo_up(t))) == int32('-') { + t = t + 1 + **(**Tsize_t)(__ccgo_up(bp)) = **(**Tsize_t)(__ccgo_up(bp)) - 1 + } + for { + if !(Int32FromUint8(**(**uint8)(__ccgo_up(t))) == int32('0') && Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(t + 1)))-int32('0')) < uint32(10)) { + break + } + goto _5 + _5: + ; + t = t + 1 + **(**Tsize_t)(__ccgo_up(bp)) = **(**Tsize_t)(__ccgo_up(bp)) - 1 + } + if width < **(**Tsize_t)(__ccgo_up(bp)) { + width = **(**Tsize_t)(__ccgo_up(bp)) + } + d = uint64(0) + for { + if !(Uint32FromInt32(Int32FromUint8(**(**uint8)(__ccgo_up(t + uintptr(d))))-int32('0')) < uint32(10)) { + break + } + goto _6 + _6: + ; + d = d + 1 + } + if (*Ttm)(unsafe.Pointer(tm)).Ftm_year < -int32(1900) { + v2 = l + l = l + 1 + **(**uint8)(__ccgo_up(s + uintptr(v2))) = uint8('-') + width = width - 1 + } else { + if v9 = plus != 0; v9 { + if Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 112))))) == int32('C') { + v4 = int32(3) + } else { + v4 = int32(5) + } + } + if v9 && d+(width-**(**Tsize_t)(__ccgo_up(bp))) >= Uint64FromInt32(v4) { + v2 = l + l = l + 1 + **(**uint8)(__ccgo_up(s + uintptr(v2))) = uint8('+') + width = width - 1 + } + } + for { + if !(width > **(**Tsize_t)(__ccgo_up(bp)) && l < n) { + break + } + v2 = l + l = l + 1 + **(**uint8)(__ccgo_up(s + uintptr(v2))) = uint8('0') + goto _11 + _11: + ; + width = width - 1 + } + } + if **(**Tsize_t)(__ccgo_up(bp)) > n-l { + **(**Tsize_t)(__ccgo_up(bp)) = n - l + } + Xmemcpy(tls, s+uintptr(l), t, **(**Tsize_t)(__ccgo_up(bp))) + l = l + **(**Tsize_t)(__ccgo_up(bp)) + goto _1 + _1: + ; + f = f + 1 + } + if n != 0 { + if l == n { + l = n - uint64(1) + } + **(**uint8)(__ccgo_up(s + uintptr(l))) = uint8(0) + } + return uint64(0) +} + +func Xstrftime(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v, (%v:)", tls, s, n, f, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strftime_l(tls, s, n, f, tm, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xstrftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v loc=%v, (%v:)", tls, s, n, f, tm, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__strftime_l(tls, s, n, f, tm, loc) +} + +func Xstrptime(tls *TLS, s uintptr, f uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v f=%v tm=%v, (%v:)", tls, s, f, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var adj, i, min, neg, range1, w, want_century, v1, v2, v5, v6 int32 + var dest, ex, v9 uintptr + var len1 Tsize_t + var v8 bool + var _ /* century at bp+4 */ int32 + var _ /* dummy at bp+0 */ int32 + var _ /* new_f at bp+16 */ uintptr + var _ /* relyear at bp+8 */ int32 + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = adj, dest, ex, i, len1, min, neg, range1, w, want_century, v1, v2, v5, v6, v8, v9 + want_century = 0 + **(**int32)(__ccgo_up(bp + 4)) = 0 + **(**int32)(__ccgo_up(bp + 8)) = 0 + for **(**uint8)(__ccgo_up(f)) != 0 { + if Int32FromUint8(**(**uint8)(__ccgo_up(f))) != int32('%') { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(f))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _3 + _3: + if v2 != 0 { + for { + if v8 = **(**uint8)(__ccgo_up(s)) != 0; v8 { + v5 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + v6 = BoolInt32(v5 == int32(' ') || Uint32FromInt32(v5)-uint32('\t') < uint32(5)) + goto _7 + _7: + } + if !(v8 && v6 != 0) { + break + } + goto _4 + _4: + ; + s = s + 1 + } + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) != Int32FromUint8(**(**uint8)(__ccgo_up(f))) { + return uintptr(0) + } else { + s = s + 1 + } + } + f = f + 1 + continue + } + f = f + 1 + if Int32FromUint8(**(**uint8)(__ccgo_up(f))) == int32('+') { + f = f + 1 + } + if BoolInt32(uint32(**(**uint8)(__ccgo_up(f)))-uint32('0') < uint32(10)) != 0 { + w = Int32FromUint64(Xstrtoul(tls, f, bp+16, int32(10))) + f = **(**uintptr)(__ccgo_up(bp + 16)) + } else { + w = -int32(1) + } + adj = 0 + v9 = f + f = f + 1 + switch Int32FromUint8(**(**uint8)(__ccgo_up(v9))) { + case int32('A'): + goto _10 + case int32('a'): + goto _11 + case int32('h'): + goto _12 + case int32('B'): + goto _13 + case int32('b'): + goto _14 + case int32('c'): + goto _15 + case int32('C'): + goto _16 + case int32('e'): + goto _17 + case int32('d'): + goto _18 + case int32('D'): + goto _19 + case int32('H'): + goto _20 + case int32('I'): + goto _21 + case int32('j'): + goto _22 + case int32('m'): + goto _23 + case int32('M'): + goto _24 + case int32('t'): + goto _25 + case int32('n'): + goto _26 + case int32('p'): + goto _27 + case int32('r'): + goto _28 + case int32('R'): + goto _29 + case int32('S'): + goto _30 + case int32('T'): + goto _31 + case int32('W'): + goto _32 + case int32('U'): + goto _33 + case int32('w'): + goto _34 + case int32('x'): + goto _35 + case int32('X'): + goto _36 + case int32('y'): + goto _37 + case int32('Y'): + goto _38 + case int32('%'): + goto _39 + default: + goto _40 + } + goto _41 + _11: + ; + _10: + ; + dest = tm + 24 + min = int32(ABDAY_1) + range1 = int32(7) + goto symbolic_range + _14: + ; + _13: + ; + _12: + ; + dest = tm + 16 + min = int32(ABMON_1) + range1 = int32(12) + goto symbolic_range + _15: + ; + s = Xstrptime(tls, s, Xnl_langinfo(tls, int32(D_T_FMT)), tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _16: + ; + dest = bp + 4 + if w < 0 { + w = int32(2) + } + want_century = want_century | int32(2) + goto numeric_digits + _18: + ; + _17: + ; + dest = tm + 12 + min = int32(1) + range1 = int32(31) + goto numeric_range + _19: + ; + s = Xstrptime(tls, s, __ccgo_ts+1808, tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _20: + ; + dest = tm + 8 + min = 0 + range1 = int32(24) + goto numeric_range + _21: + ; + dest = tm + 8 + min = int32(1) + range1 = int32(12) + goto numeric_range + _22: + ; + dest = tm + 28 + min = int32(1) + range1 = int32(366) + adj = int32(1) + goto numeric_range + _23: + ; + dest = tm + 16 + min = int32(1) + range1 = int32(12) + adj = int32(1) + goto numeric_range + _24: + ; + dest = tm + 4 + min = 0 + range1 = int32(60) + goto numeric_range + _26: + ; + _25: + ; + _44: + ; + if v8 = **(**uint8)(__ccgo_up(s)) != 0; v8 { + v1 = Int32FromUint8(**(**uint8)(__ccgo_up(s))) + v2 = BoolInt32(v1 == int32(' ') || Uint32FromInt32(v1)-uint32('\t') < uint32(5)) + goto _47 + _47: + } + if !(v8 && v2 != 0) { + goto _42 + } + goto _43 + _43: + ; + s = s + 1 + goto _44 + goto _42 + _42: + ; + goto _41 + _27: + ; + ex = Xnl_langinfo(tls, int32(AM_STR)) + len1 = _strlen(tls, ex) + if !(Xstrncasecmp(tls, s, ex, len1) != 0) { + **(**int32)(__ccgo_up(tm + 8)) %= int32(12) + s = s + uintptr(len1) + goto _41 + } + ex = Xnl_langinfo(tls, int32(PM_STR)) + len1 = _strlen(tls, ex) + if !(Xstrncasecmp(tls, s, ex, len1) != 0) { + **(**int32)(__ccgo_up(tm + 8)) %= int32(12) + **(**int32)(__ccgo_up(tm + 8)) += int32(12) + s = s + uintptr(len1) + goto _41 + } + return uintptr(0) + _28: + ; + s = Xstrptime(tls, s, Xnl_langinfo(tls, int32(T_FMT_AMPM)), tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _29: + ; + s = Xstrptime(tls, s, __ccgo_ts+1826, tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _30: + ; + dest = tm + min = 0 + range1 = int32(61) + goto numeric_range + _31: + ; + s = Xstrptime(tls, s, __ccgo_ts+1832, tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _33: + ; + _32: + ; + /* Throw away result, for now. (FIXME?) */ + dest = bp + min = 0 + range1 = int32(54) + goto numeric_range + _34: + ; + dest = tm + 24 + min = 0 + range1 = int32(7) + goto numeric_range + _35: + ; + s = Xstrptime(tls, s, Xnl_langinfo(tls, int32(D_FMT)), tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _36: + ; + s = Xstrptime(tls, s, Xnl_langinfo(tls, int32(T_FMT)), tm) + if !(s != 0) { + return uintptr(0) + } + goto _41 + _37: + ; + dest = bp + 8 + w = int32(2) + want_century = want_century | int32(1) + goto numeric_digits + _38: + ; + dest = tm + 20 + if w < 0 { + w = int32(4) + } + adj = int32(1900) + want_century = 0 + goto numeric_digits + _39: + ; + v9 = s + s = s + 1 + if Int32FromUint8(**(**uint8)(__ccgo_up(v9))) != int32('%') { + return uintptr(0) + } + goto _41 + _40: + ; + return uintptr(0) + goto numeric_range + numeric_range: + ; + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return uintptr(0) + } + **(**int32)(__ccgo_up(dest)) = 0 + i = int32(1) + for { + if !(i <= min+range1 && BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0) { + break + } + v9 = s + s = s + 1 + **(**int32)(__ccgo_up(dest)) = **(**int32)(__ccgo_up(dest))*int32(10) + Int32FromUint8(**(**uint8)(__ccgo_up(v9))) - int32('0') + goto _50 + _50: + ; + i = i * int32(10) + } + if Uint32FromInt32(**(**int32)(__ccgo_up(dest))-min) >= Uint32FromInt32(range1) { + return uintptr(0) + } + **(**int32)(__ccgo_up(dest)) -= adj + switch int64(dest) - int64(tm) { + case Int64FromUint64(uint64(UintptrFromInt32(0) + 28)): + } + goto update + goto numeric_digits + numeric_digits: + ; + neg = 0 + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('+') { + s = s + 1 + } else { + if Int32FromUint8(**(**uint8)(__ccgo_up(s))) == int32('-') { + neg = int32(1) + s = s + 1 + } + } + if !(BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-Uint32FromUint8('0') < Uint32FromInt32(10)) != 0) { + return uintptr(0) + } + v1 = Int32FromInt32(0) + i = v1 + **(**int32)(__ccgo_up(dest)) = v1 + for { + if !(i < w && BoolInt32(uint32(**(**uint8)(__ccgo_up(s)))-uint32('0') < uint32(10)) != 0) { + break + } + v9 = s + s = s + 1 + **(**int32)(__ccgo_up(dest)) = **(**int32)(__ccgo_up(dest))*int32(10) + Int32FromUint8(**(**uint8)(__ccgo_up(v9))) - int32('0') + goto _52 + _52: + ; + i = i + 1 + } + if neg != 0 { + **(**int32)(__ccgo_up(dest)) = -**(**int32)(__ccgo_up(dest)) + } + **(**int32)(__ccgo_up(dest)) -= adj + goto update + goto symbolic_range + symbolic_range: + ; + i = int32(2)*range1 - int32(1) + for { + if !(i >= 0) { + break + } + ex = Xnl_langinfo(tls, min+i) + len1 = _strlen(tls, ex) + if Xstrncasecmp(tls, s, ex, len1) != 0 { + goto _55 + } + s = s + uintptr(len1) + **(**int32)(__ccgo_up(dest)) = i % range1 + break + goto _55 + _55: + ; + i = i - 1 + } + if i < 0 { + return uintptr(0) + } + goto update + goto update + update: + ; + //FIXME + _41: + } + if want_century != 0 { + (*Ttm)(unsafe.Pointer(tm)).Ftm_year = **(**int32)(__ccgo_up(bp + 8)) + if want_century&int32(2) != 0 { + **(**int32)(__ccgo_up(tm + 20)) += **(**int32)(__ccgo_up(bp + 4))*int32(100) - int32(1900) + } else { + if (*Ttm)(unsafe.Pointer(tm)).Ftm_year <= int32(68) { + **(**int32)(__ccgo_up(tm + 20)) += int32(100) + } + } + } + return s +} + +func Xtime(tls *TLS, t uintptr) (r Ttime_t) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* ts at bp+0 */ Ttimespec + X__clock_gettime(tls, CLOCK_REALTIME, bp) + if t != 0 { + **(**Ttime_t)(__ccgo_up(t)) = (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec + } + return (**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec +} + +func Xtimegm(tls *TLS, tm uintptr) (r Ttime_t) { + if __ccgo_strace { + trc("tls=%v tm=%v, (%v:)", tls, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var t int64 + var _ /* new at bp+0 */ Ttm1 + _ = t + t = X__tm_to_secs(tls, tm) + if X__secs_to_tm(tls, t, bp) < 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EOVERFLOW) + return int64(-int32(1)) + } + **(**Ttm1)(__ccgo_up(tm)) = **(**Ttm1)(__ccgo_up(bp)) + (*Ttm1)(unsafe.Pointer(tm)).Ftm_isdst = 0 + (*Ttm1)(unsafe.Pointer(tm)).Ftm_gmtoff = 0 + (*Ttm1)(unsafe.Pointer(tm)).Ftm_zone = uintptr(unsafe.Pointer(&X__utc)) + return t +} + +func Xtimer_delete(tls *TLS, t Ttimer_t) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + var td Tpthread_t + _ = td + if int64(t) < 0 { + td = uintptr(uint64(t) << Int32FromInt32(1)) + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1872) + AtomicStorePInt32(td+148, AtomicLoadPInt32(td+148)|(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff))) + // __asm__ __volatile__ ("dmb ish" : : : "memory"); + X__assert_fail(tls, __ccgo_ts+350, __ccgo_ts+385, 20, __ccgo_ts+1872) + X__syscall2(tls, int64(SYS_tkill), int64((*t__pthread)(unsafe.Pointer(td)).Ftid), int64(Int32FromInt32(SIGTIMER))) + return 0 + } + return int32(X__syscall1(tls, int64(SYS_timer_delete), int64(t))) +} + +func Xtimer_getoverrun(tls *TLS, t Ttimer_t) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + var td Tpthread_t + _ = td + if int64(t) < 0 { + td = uintptr(uint64(t) << Int32FromInt32(1)) + t = uintptr(Uint64FromInt32(AtomicLoadPInt32(td+148) & Int32FromInt32(INT_MAX))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_timer_getoverrun), int64(t))))) +} + +func Xtimer_gettime(tls *TLS, t Ttimer_t, val uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v val=%v, (%v:)", tls, t, val, origin(2)) + defer func() { trc("-> %v", r) }() + } + var td Tpthread_t + _ = td + if int64(t) < 0 { + td = uintptr(uint64(t) << Int32FromInt32(1)) + t = uintptr(Uint64FromInt32(AtomicLoadPInt32(td+148) & Int32FromInt32(INT_MAX))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_timer_gettime), int64(t), int64(val))))) +} + +func Xtimer_settime(tls *TLS, t Ttimer_t, flags int32, val uintptr, old uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v t=%v flags=%v val=%v old=%v, (%v:)", tls, t, flags, val, old, origin(2)) + defer func() { trc("-> %v", r) }() + } + var td Tpthread_t + _ = td + if int64(t) < 0 { + td = uintptr(uint64(t) << Int32FromInt32(1)) + t = uintptr(Uint64FromInt32(AtomicLoadPInt32(td+148) & Int32FromInt32(INT_MAX))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_timer_settime), int64(t), int64(flags), int64(val), int64(old))))) +} + +type Ttms = struct { + Ftms_utime Tclock_t + Ftms_stime Tclock_t + Ftms_cutime Tclock_t + Ftms_cstime Tclock_t +} + +func Xtimes(tls *TLS, tms uintptr) (r Tclock_t) { + if __ccgo_strace { + trc("tls=%v tms=%v, (%v:)", tls, tms, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall1(tls, int64(SYS_times), int64(tms)) +} + +// C documentation +// +// /* There is no other implemented value than TIME_UTC; all other values +// * are considered erroneous. */ +func Xtimespec_get(tls *TLS, ts uintptr, base int32) (r int32) { + if __ccgo_strace { + trc("tls=%v ts=%v base=%v, (%v:)", tls, ts, base, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret, v1 int32 + _, _ = ret, v1 + if base != int32(TIME_UTC) { + return 0 + } + ret = X__clock_gettime(tls, CLOCK_REALTIME, ts) + if ret < 0 { + v1 = 0 + } else { + v1 = base + } + return v1 +} + +type Tutimbuf = struct { + Factime Ttime_t + Fmodtime Ttime_t +} + +func Xutime(tls *TLS, path uintptr, times uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v times=%v, (%v:)", tls, path, times, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1 uintptr + _ = v1 + if times != 0 { + *(*[2]Ttimespec)(unsafe.Pointer(bp)) = [2]Ttimespec{ + 0: { + Ftv_sec: (*Tutimbuf)(unsafe.Pointer(times)).Factime, + }, + 1: { + Ftv_sec: (*Tutimbuf)(unsafe.Pointer(times)).Fmodtime, + }, + } + v1 = bp + } else { + v1 = uintptr(0) + } + return Xutimensat(tls, -int32(100), path, v1, 0) +} + +func X__wcsftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v loc=%v, (%v:)", tls, s, n, f, tm, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(528) + defer tls.Free(528) + var l, v2 Tsize_t + var pad, plus, v4 int32 + var t, t_mb, v3 uintptr + var width uint64 + var _ /* buf at bp+8 */ [100]uint8 + var _ /* k at bp+0 */ Tsize_t + var _ /* p at bp+512 */ uintptr + var _ /* wbuf at bp+108 */ [100]Twchar_t + _, _, _, _, _, _, _, _, _ = l, pad, plus, t, t_mb, width, v2, v3, v4 + l = uint64(0) + for { + if !(l < n) { + break + } + if !(**(**Twchar_t)(__ccgo_up(f)) != 0) { + **(**Twchar_t)(__ccgo_up(s + uintptr(l)*4)) = uint32(0) + return l + } + if **(**Twchar_t)(__ccgo_up(f)) != uint32('%') { + v2 = l + l = l + 1 + **(**Twchar_t)(__ccgo_up(s + uintptr(v2)*4)) = **(**Twchar_t)(__ccgo_up(f)) + goto _1 + } + f += 4 + pad = 0 + if **(**Twchar_t)(__ccgo_up(f)) == uint32('-') || **(**Twchar_t)(__ccgo_up(f)) == uint32('_') || **(**Twchar_t)(__ccgo_up(f)) == uint32('0') { + v3 = f + f += 4 + pad = Int32FromUint32(**(**Twchar_t)(__ccgo_up(v3))) + } + v4 = BoolInt32(**(**Twchar_t)(__ccgo_up(f)) == Uint32FromUint8('+')) + plus = v4 + if v4 != 0 { + f += 4 + } + width = Xwcstoul(tls, f, bp+512, int32(10)) + if **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 512)))) == uint32('C') || **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 512)))) == uint32('F') || **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 512)))) == uint32('G') || **(**Twchar_t)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 512)))) == uint32('Y') { + if !(width != 0) && **(**uintptr)(__ccgo_up(bp + 512)) != f { + width = uint64(1) + } + } else { + width = uint64(0) + } + f = **(**uintptr)(__ccgo_up(bp + 512)) + if **(**Twchar_t)(__ccgo_up(f)) == uint32('E') || **(**Twchar_t)(__ccgo_up(f)) == uint32('O') { + f += 4 + } + t_mb = X__strftime_fmt_1(tls, bp+8, bp, Int32FromUint32(**(**Twchar_t)(__ccgo_up(f))), tm, loc, pad) + if !(t_mb != 0) { + break + } + **(**Tsize_t)(__ccgo_up(bp)) = Xmbstowcs(tls, bp+108, t_mb, Uint64FromInt64(400)/Uint64FromInt64(4)) + if **(**Tsize_t)(__ccgo_up(bp)) == Uint64FromInt32(-Int32FromInt32(1)) { + return uint64(0) + } + t = bp + 108 + if width != 0 { + for { + if !(**(**Twchar_t)(__ccgo_up(t)) == uint32('+') || **(**Twchar_t)(__ccgo_up(t)) == uint32('-') || **(**Twchar_t)(__ccgo_up(t)) == uint32('0') && **(**Twchar_t)(__ccgo_up(t + 1*4)) != 0) { + break + } + goto _5 + _5: + ; + t += 4 + **(**Tsize_t)(__ccgo_up(bp)) = **(**Tsize_t)(__ccgo_up(bp)) - 1 + } + width = width - 1 + if plus != 0 && (*Ttm)(unsafe.Pointer(tm)).Ftm_year >= Int32FromInt32(10000)-Int32FromInt32(1900) { + v2 = l + l = l + 1 + **(**Twchar_t)(__ccgo_up(s + uintptr(v2)*4)) = uint32('+') + } else { + if (*Ttm)(unsafe.Pointer(tm)).Ftm_year < -int32(1900) { + v2 = l + l = l + 1 + **(**Twchar_t)(__ccgo_up(s + uintptr(v2)*4)) = uint32('-') + } else { + width = width + 1 + } + } + for { + if !(width > **(**Tsize_t)(__ccgo_up(bp)) && l < n) { + break + } + v2 = l + l = l + 1 + **(**Twchar_t)(__ccgo_up(s + uintptr(v2)*4)) = uint32('0') + goto _8 + _8: + ; + width = width - 1 + } + } + if **(**Tsize_t)(__ccgo_up(bp)) >= n-l { + **(**Tsize_t)(__ccgo_up(bp)) = n - l + } + Xwmemcpy(tls, s+uintptr(l)*4, t, **(**Tsize_t)(__ccgo_up(bp))) + l = l + **(**Tsize_t)(__ccgo_up(bp)) + goto _1 + _1: + ; + f += 4 + } + if n != 0 { + if l == n { + l = n - uint64(1) + } + **(**Twchar_t)(__ccgo_up(s + uintptr(l)*4)) = uint32(0) + } + return uint64(0) +} + +func Xwcsftime(tls *TLS, wcs uintptr, n Tsize_t, f uintptr, tm uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v wcs=%v n=%v f=%v tm=%v, (%v:)", tls, wcs, n, f, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wcsftime_l(tls, wcs, n, f, tm, (*t__pthread)(unsafe.Pointer(uintptr(___get_tp(tls)))).Flocale) +} + +func Xwcsftime_l(tls *TLS, s uintptr, n Tsize_t, f uintptr, tm uintptr, loc Tlocale_t) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v loc=%v, (%v:)", tls, s, n, f, tm, loc, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__wcsftime_l(tls, s, n, f, tm, loc) +} + +func X_exit(tls *TLS, status int32) { + if __ccgo_strace { + trc("tls=%v status=%v, (%v:)", tls, status, origin(2)) + } + X_Exit(tls, status) +} + +func Xaccess(tls *TLS, filename uintptr, amode int32) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v amode=%v, (%v:)", tls, filename, amode, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_faccessat), int64(-Int32FromInt32(100)), int64(filename), int64(amode), int64(Int32FromInt32(0)))))) +} + +func Xacct(tls *TLS, filename uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v filename=%v, (%v:)", tls, filename, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_acct), int64(filename))))) +} + +func Xalarm(tls *TLS, seconds uint32) (r uint32) { + if __ccgo_strace { + trc("tls=%v seconds=%v, (%v:)", tls, seconds, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var _ /* it at bp+0 */ Titimerval + var _ /* old at bp+32 */ Titimerval + **(**Titimerval)(__ccgo_up(bp)) = Titimerval{ + Fit_value: Ttimeval{ + Ftv_sec: Int64FromUint32(seconds), + }, + } + **(**Titimerval)(__ccgo_up(bp + 32)) = Titimerval{} + Xsetitimer(tls, ITIMER_REAL, bp, bp+32) + return Uint32FromInt64((**(**Titimerval)(__ccgo_up(bp + 32))).Fit_value.Ftv_sec + BoolInt64(!!((**(**Titimerval)(__ccgo_up(bp + 32))).Fit_value.Ftv_usec != 0))) +} + +func Xchdir(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_chdir), int64(path))))) +} + +func Xchown(tls *TLS, path uintptr, uid Tuid_t, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v uid=%v gid=%v, (%v:)", tls, path, uid, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fchownat), int64(-Int32FromInt32(100)), int64(path), Int64FromUint32(uid), Int64FromUint32(gid), int64(Int32FromInt32(0)))))) +} + +func _dummy12(tls *TLS, fd int32) (r int32) { + return fd +} + +func Xclose(tls *TLS, fd int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r int32 + _ = r + fd = _dummy12(tls, fd) + r = int32(___syscall_cp(tls, int64(SYS_close), int64(fd), 0, 0, 0, 0, 0)) + if r == -int32(EINTR) { + r = 0 + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xctermid(tls *TLS, s uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + var v1 uintptr + _ = v1 + if s != 0 { + v1 = Xstrcpy(tls, s, __ccgo_ts+292) + } else { + v1 = __ccgo_ts + 292 + } + return v1 +} + +func Xdup(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_dup), int64(fd))))) +} + +func Xdup2(tls *TLS, old int32, new1 int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v, (%v:)", tls, old, new1, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v1 int32 + _, _ = r, v1 + if old == new1 { + r = int32(X__syscall2(tls, int64(SYS_fcntl), int64(old), int64(Int32FromInt32(F_GETFD)))) + if r >= 0 { + return old + } + } else { + for { + v1 = int32(X__syscall3(tls, int64(SYS_dup3), int64(old), int64(new1), int64(Int32FromInt32(0)))) + r = v1 + if !(v1 == -int32(EBUSY)) { + break + } + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func X__dup3(tls *TLS, old int32, new1 int32, flags int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v flags=%v, (%v:)", tls, old, new1, flags, origin(2)) + defer func() { trc("-> %v", r1) }() + } + var r, v1 int32 + _, _ = r, v1 + for { + v1 = int32(X__syscall3(tls, int64(SYS_dup3), int64(old), int64(new1), int64(flags))) + r = v1 + if !(v1 == -int32(EBUSY)) { + break + } + } + return int32(X__syscall_ret(tls, Uint64FromInt32(r))) +} + +func Xdup3(tls *TLS, old int32, new1 int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v old=%v new1=%v flags=%v, (%v:)", tls, old, new1, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__dup3(tls, old, new1, flags) +} + +type Tctx1 = struct { + Ffd int32 + Ffilename uintptr + Famode int32 + Fp int32 +} + +func _checker(tls *TLS, p uintptr) (r int32) { + bp := tls.Alloc(16) + defer tls.Free(16) + var c uintptr + var _ /* ret at bp+0 */ int32 + _ = c + c = p + if X__syscall2(tls, int64(SYS_setregid), X__syscall0(tls, int64(SYS_getegid)), int64(-Int32FromInt32(1))) != 0 || X__syscall2(tls, int64(SYS_setreuid), X__syscall0(tls, int64(SYS_geteuid)), int64(-Int32FromInt32(1))) != 0 { + X__syscall1(tls, int64(SYS_exit), int64(Int32FromInt32(1))) + } + **(**int32)(__ccgo_up(bp)) = int32(X__syscall4(tls, int64(SYS_faccessat), int64((*Tctx1)(unsafe.Pointer(c)).Ffd), int64((*Tctx1)(unsafe.Pointer(c)).Ffilename), int64((*Tctx1)(unsafe.Pointer(c)).Famode), int64(Int32FromInt32(0)))) + X__syscall3(tls, int64(SYS_write), int64((*Tctx1)(unsafe.Pointer(c)).Fp), int64(bp), Int64FromUint64(Uint64FromInt64(4))) + return 0 +} + +func Xfaccessat(tls *TLS, fd int32, filename uintptr, amode int32, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v filename=%v amode=%v flag=%v, (%v:)", tls, fd, filename, amode, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + if flag != 0 { + ret = int32(X__syscall4(tls, int64(SYS_faccessat2), int64(fd), int64(filename), int64(amode), int64(flag))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + } + if flag & ^Int32FromInt32(AT_EACCESS) != 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_faccessat), int64(fd), int64(filename), int64(amode))))) +} + +func Xfchdir(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ret int32 + var _ /* buf at bp+0 */ [27]uint8 + _ = ret + ret = int32(X__syscall1(tls, int64(SYS_fchdir), int64(fd))) + if ret != -int32(EBADF) || X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFD))) < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + X__procfdname(tls, bp, Uint32FromInt32(fd)) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_chdir), int64(bp))))) +} + +func Xfchown(tls *TLS, fd int32, uid Tuid_t, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v uid=%v gid=%v, (%v:)", tls, fd, uid, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var ret int32 + var _ /* buf at bp+0 */ [27]uint8 + _ = ret + ret = int32(X__syscall3(tls, int64(SYS_fchown), int64(fd), Int64FromUint32(uid), Int64FromUint32(gid))) + if ret != -int32(EBADF) || X__syscall2(tls, int64(SYS_fcntl), int64(fd), int64(Int32FromInt32(F_GETFD))) < 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + X__procfdname(tls, bp, Uint32FromInt32(fd)) + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fchownat), int64(-Int32FromInt32(100)), int64(bp), Int64FromUint32(uid), Int64FromUint32(gid), int64(Int32FromInt32(0)))))) +} + +func Xfchownat(tls *TLS, fd int32, path uintptr, uid Tuid_t, gid Tgid_t, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v uid=%v gid=%v flag=%v, (%v:)", tls, fd, path, uid, gid, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fchownat), int64(fd), int64(path), Int64FromUint32(uid), Int64FromUint32(gid), int64(flag))))) +} + +func Xfdatasync(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_fdatasync), int64(fd), 0, 0, 0, 0, 0)))) +} + +func Xfsync(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_fsync), int64(fd), 0, 0, 0, 0, 0)))) +} + +func Xftruncate(tls *TLS, fd int32, length Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v length=%v, (%v:)", tls, fd, length, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_ftruncate), int64(fd), length)))) +} + +func Xgetcwd(tls *TLS, buf uintptr, size Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v buf=%v size=%v, (%v:)", tls, buf, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int64 + var tmp, v3 uintptr + var v1 t__predefined_size_t + var v2 int32 + _, _, _, _, _ = ret, tmp, v1, v2, v3 + defer func() { Xrealloc(tls, tmp, 0) }() + if buf != 0 { + v2 = int32(1) + } else { + v2 = int32(PATH_MAX) + } + v1 = Uint64FromInt32(v2) + tmp = Xrealloc(tls, tmp, v1) + if !(buf != 0) { + buf = tmp + size = v1 + } else { + if !(size != 0) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EINVAL) + return uintptr(0) + } + } + ret = X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getcwd), int64(buf), Int64FromUint64(size)))) + if ret < 0 { + return uintptr(0) + } + if ret == 0 || Int32FromUint8(**(**uint8)(__ccgo_up(buf))) != int32('/') { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOENT) + return uintptr(0) + } + if buf == tmp { + v3 = Xstrdup(tls, buf) + } else { + v3 = buf + } + return v3 +} + +func Xgetegid(tls *TLS) (r Tgid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall0(tls, int64(SYS_getegid))) +} + +func Xgeteuid(tls *TLS) (r Tuid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall0(tls, int64(SYS_geteuid))) +} + +func Xgetgid(tls *TLS) (r Tgid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall0(tls, int64(SYS_getgid))) +} + +func Xgetgroups(tls *TLS, count int32, list uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v count=%v list=%v, (%v:)", tls, count, list, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_getgroups), int64(count), int64(list))))) +} + +func Xgethostname(tls *TLS, name uintptr, len1 Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v len1=%v, (%v:)", tls, name, len1, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(400) + defer tls.Free(400) + var i Tsize_t + var v2 uint8 + var v3 bool + var _ /* uts at bp+0 */ Tutsname1 + _, _, _ = i, v2, v3 + if Xuname(tls, bp) != 0 { + return -int32(1) + } + if len1 > uint64(65) { + len1 = uint64(65) + } + i = uint64(0) + for { + if v3 = i < len1; v3 { + v2 = **(**uint8)(__ccgo_up(bp + 65 + uintptr(i))) + **(**uint8)(__ccgo_up(name + uintptr(i))) = v2 + } + if !(v3 && v2 != 0) { + break + } + goto _1 + _1: + ; + i = i + 1 + } + if i != 0 && i == len1 { + **(**uint8)(__ccgo_up(name + uintptr(i-uint64(1)))) = uint8(0) + } + return 0 +} + +func Xgetlogin(tls *TLS) (r uintptr) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgetenv(tls, __ccgo_ts+1885) +} + +func Xgetlogin_r(tls *TLS, name uintptr, size Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v name=%v size=%v, (%v:)", tls, name, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + var logname uintptr + _ = logname + logname = Xgetlogin(tls) + if !(logname != 0) { + return int32(ENXIO) + } /* or...? */ + if _strlen(tls, logname) >= size { + return int32(ERANGE) + } + Xstrcpy(tls, name, logname) + return 0 +} + +func Xgetpgid(tls *TLS, pid Tpid_t) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v pid=%v, (%v:)", tls, pid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_getpgid), int64(pid))))) +} + +func Xgetpgrp(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall1(tls, int64(SYS_getpgid), int64(Int32FromInt32(0)))) +} + +func Xgetpid(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall0(tls, int64(SYS_getpid))) +} + +func Xgetppid(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall0(tls, int64(SYS_getppid))) +} + +func Xgetsid(tls *TLS, pid Tpid_t) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v pid=%v, (%v:)", tls, pid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall1(tls, int64(SYS_getsid), int64(pid))))) +} + +func Xgetuid(tls *TLS) (r Tuid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Uint32FromInt64(X__syscall0(tls, int64(SYS_getuid))) +} + +func Xisatty(tls *TLS, fd int32) (r1 int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r uint64 + var _ /* wsz at bp+0 */ Twinsize + _ = r + r = Uint64FromInt64(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_ioctl), int64(fd), int64(Int32FromInt32(TIOCGWINSZ)), int64(bp))))) + if r == uint64(0) { + return int32(1) + } + if **(**int32)(__ccgo_up(X__errno_location(tls))) != int32(EBADF) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(ENOTTY) + } + return 0 +} + +func Xlchown(tls *TLS, path uintptr, uid Tuid_t, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v uid=%v gid=%v, (%v:)", tls, path, uid, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_fchownat), int64(-Int32FromInt32(100)), int64(path), Int64FromUint32(uid), Int64FromUint32(gid), int64(Int32FromInt32(AT_SYMLINK_NOFOLLOW)))))) +} + +func Xlink(tls *TLS, existing uintptr, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v existing=%v new1=%v, (%v:)", tls, existing, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_linkat), int64(-Int32FromInt32(100)), int64(existing), int64(-Int32FromInt32(100)), int64(new1), int64(Int32FromInt32(0)))))) +} + +func Xlinkat(tls *TLS, fd1 int32, existing uintptr, fd2 int32, new1 uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd1=%v existing=%v fd2=%v new1=%v flag=%v, (%v:)", tls, fd1, existing, fd2, new1, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall5(tls, int64(SYS_linkat), int64(fd1), int64(existing), int64(fd2), int64(new1), int64(flag))))) +} + +func X__lseek(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v fd=%v offset=%v whence=%v, (%v:)", tls, fd, offset, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_lseek), int64(fd), offset, int64(whence)))) +} + +func Xlseek(tls *TLS, fd int32, offset Toff_t, whence int32) (r Toff_t) { + if __ccgo_strace { + trc("tls=%v fd=%v offset=%v whence=%v, (%v:)", tls, fd, offset, whence, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__lseek(tls, fd, offset, whence) +} + +func Xnice(tls *TLS, inc int32) (r int32) { + if __ccgo_strace { + trc("tls=%v inc=%v, (%v:)", tls, inc, origin(2)) + defer func() { trc("-> %v", r) }() + } + var prio int32 + _ = prio + prio = inc + // Only query old priority if it can affect the result. + // This also avoids issues with integer overflow. + if inc > -Int32FromInt32(2)*Int32FromInt32(NZERO) && inc < Int32FromInt32(2)*Int32FromInt32(NZERO) { + prio = prio + Xgetpriority(tls, PRIO_PROCESS, uint32(0)) + } + if prio > Int32FromInt32(NZERO)-Int32FromInt32(1) { + prio = Int32FromInt32(NZERO) - Int32FromInt32(1) + } + if prio < -int32(NZERO) { + prio = -int32(NZERO) + } + if Xsetpriority(tls, PRIO_PROCESS, uint32(0), prio) != 0 { + if **(**int32)(__ccgo_up(X__errno_location(tls))) == int32(EACCES) { + **(**int32)(__ccgo_up(X__errno_location(tls))) = int32(EPERM) + } + return -int32(1) + } else { + return prio + } + return r +} + +func Xpause(tls *TLS) (r int32) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_ppoll), int64(Int32FromInt32(0)), int64(Int32FromInt32(0)), int64(Int32FromInt32(0)), int64(Int32FromInt32(0)), 0, 0)))) +} + +func Xpipe(tls *TLS, fd uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_pipe2), int64(fd), int64(Int32FromInt32(0)))))) +} + +func Xpipe2(tls *TLS, fd uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v flag=%v, (%v:)", tls, fd, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + var ret int32 + _ = ret + if !(flag != 0) { + return Xpipe(tls, fd) + } + ret = int32(X__syscall2(tls, int64(SYS_pipe2), int64(fd), int64(flag))) + if ret != -int32(ENOSYS) { + return int32(X__syscall_ret(tls, Uint64FromInt32(ret))) + } + if flag & ^(Int32FromInt32(O_CLOEXEC)|Int32FromInt32(O_NONBLOCK)) != 0 { + return int32(X__syscall_ret(tls, Uint64FromInt32(-Int32FromInt32(EINVAL)))) + } + ret = Xpipe(tls, fd) + if ret != 0 { + return ret + } + if flag&int32(O_CLOEXEC) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd))), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd + 1*4))), int64(Int32FromInt32(F_SETFD)), int64(Int32FromInt32(FD_CLOEXEC))) + } + if flag&int32(O_NONBLOCK) != 0 { + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd))), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + X__syscall3(tls, int64(SYS_fcntl), int64(**(**int32)(__ccgo_up(fd + 1*4))), int64(Int32FromInt32(F_SETFL)), int64(Int32FromInt32(O_NONBLOCK))) + } + return 0 +} + +func Xposix_close(tls *TLS, fd int32, flags int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v flags=%v, (%v:)", tls, fd, flags, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xclose(tls, fd) +} + +func Xpread(tls *TLS, fd int32, buf uintptr, size Tsize_t, ofs Toff_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v size=%v ofs=%v, (%v:)", tls, fd, buf, size, ofs, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pread64), int64(fd), int64(buf), Int64FromUint64(size), ofs, 0, 0))) +} + +func Xpreadv(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v ofs=%v, (%v:)", tls, fd, iov, count, ofs, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_preadv), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), 0))) +} + +func Xpwrite(tls *TLS, fd int32, buf uintptr, size Tsize_t, ofs Toff_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v size=%v ofs=%v, (%v:)", tls, fd, buf, size, ofs, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pwrite64), int64(fd), int64(buf), Int64FromUint64(size), ofs, 0, 0))) +} + +func Xpwritev(tls *TLS, fd int32, iov uintptr, count int32, ofs Toff_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v ofs=%v, (%v:)", tls, fd, iov, count, ofs, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_pwritev), int64(fd), int64(iov), int64(count), ofs, ofs>>Int32FromInt32(32), 0))) +} + +func Xread(tls *TLS, fd int32, buf uintptr, count Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v count=%v, (%v:)", tls, fd, buf, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_read), int64(fd), int64(buf), Int64FromUint64(count), 0, 0, 0))) +} + +func Xreadlink(tls *TLS, path uintptr, buf uintptr, bufsize Tsize_t) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v path=%v buf=%v bufsize=%v, (%v:)", tls, path, buf, bufsize, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r int32 + var _ /* dummy at bp+0 */ [1]uint8 + _ = r + if !(bufsize != 0) { + buf = bp + bufsize = uint64(1) + } + r = int32(X__syscall4(tls, int64(SYS_readlinkat), int64(-Int32FromInt32(100)), int64(path), int64(buf), Int64FromUint64(bufsize))) + if buf == bp && r > 0 { + r = 0 + } + return X__syscall_ret(tls, Uint64FromInt32(r)) +} + +func Xreadlinkat(tls *TLS, fd int32, path uintptr, buf uintptr, bufsize Tsize_t) (r1 Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v buf=%v bufsize=%v, (%v:)", tls, fd, path, buf, bufsize, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var r int32 + var _ /* dummy at bp+0 */ [1]uint8 + _ = r + if !(bufsize != 0) { + buf = bp + bufsize = uint64(1) + } + r = int32(X__syscall4(tls, int64(SYS_readlinkat), int64(fd), int64(path), int64(buf), Int64FromUint64(bufsize))) + if buf == bp && r > 0 { + r = 0 + } + return X__syscall_ret(tls, Uint64FromInt32(r)) +} + +func Xreadv(tls *TLS, fd int32, iov uintptr, count int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v, (%v:)", tls, fd, iov, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_readv), int64(fd), int64(iov), int64(count), 0, 0, 0))) +} + +func Xrenameat(tls *TLS, oldfd int32, old uintptr, newfd int32, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v oldfd=%v old=%v newfd=%v new1=%v, (%v:)", tls, oldfd, old, newfd, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall4(tls, int64(SYS_renameat), int64(oldfd), int64(old), int64(newfd), int64(new1))))) +} + +func Xrmdir(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_unlinkat), int64(-Int32FromInt32(100)), int64(path), int64(Int32FromInt32(AT_REMOVEDIR)))))) +} + +func Xsetgid(tls *TLS, gid Tgid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v gid=%v, (%v:)", tls, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__setxid(tls, int32(SYS_setgid), Int32FromUint32(gid), 0, 0) +} + +func Xsetpgid(tls *TLS, pid Tpid_t, pgid Tpid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v pid=%v pgid=%v, (%v:)", tls, pid, pgid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_setpgid), int64(pid), int64(pgid))))) +} + +func Xsetpgrp(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsetpgid(tls, 0, 0) +} + +func Xsetsid(tls *TLS) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall0(tls, int64(SYS_setsid))))) +} + +func Xsetuid(tls *TLS, uid Tuid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v uid=%v, (%v:)", tls, uid, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__setxid(tls, int32(SYS_setuid), Int32FromUint32(uid), 0, 0) +} + +type Tctx2 = struct { + Fid int32 + Feid int32 + Fsid int32 + Fnr int32 + Fret int32 +} + +func _do_setxid(tls *TLS, p uintptr) { + var c uintptr + var ret int32 + _, _ = c, ret + c = p + if (*Tctx2)(unsafe.Pointer(c)).Fret < 0 { + return + } + ret = int32(X__syscall3(tls, int64((*Tctx2)(unsafe.Pointer(c)).Fnr), int64((*Tctx2)(unsafe.Pointer(c)).Fid), int64((*Tctx2)(unsafe.Pointer(c)).Feid), int64((*Tctx2)(unsafe.Pointer(c)).Fsid))) + if ret != 0 && !((*Tctx2)(unsafe.Pointer(c)).Fret != 0) { + /* If one thread fails to set ids after another has already + * succeeded, forcibly killing the process is the only safe + * thing to do. State is inconsistent and dangerous. Use + * SIGKILL because it is uncatchable. */ + X__block_all_sigs(tls, uintptr(0)) + X__syscall2(tls, int64(SYS_kill), X__syscall0(tls, int64(SYS_getpid)), int64(Int32FromInt32(SIGKILL))) + } + (*Tctx2)(unsafe.Pointer(c)).Fret = ret +} + +func X__setxid(tls *TLS, nr int32, id int32, eid int32, sid int32) (r int32) { + if __ccgo_strace { + trc("tls=%v nr=%v id=%v eid=%v sid=%v, (%v:)", tls, nr, id, eid, sid, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var v1 int32 + var _ /* c at bp+0 */ Tctx2 + _ = v1 + /* ret is initially nonzero so that failure of the first thread does not + * trigger the safety kill above. */ + **(**Tctx2)(__ccgo_up(bp)) = Tctx2{ + Fid: id, + Feid: eid, + Fsid: sid, + Fnr: nr, + Fret: int32(1), + } + ___synccall(tls, __ccgo_fp(_do_setxid), bp) + if (**(**Tctx2)(__ccgo_up(bp))).Fret > 0 { + v1 = -int32(EAGAIN) + } else { + v1 = (**(**Tctx2)(__ccgo_up(bp))).Fret + } + return int32(X__syscall_ret(tls, Uint64FromInt32(v1))) +} + +func Xsleep(tls *TLS, seconds uint32) (r uint32) { + if __ccgo_strace { + trc("tls=%v seconds=%v, (%v:)", tls, seconds, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* tv at bp+0 */ Ttimespec + **(**Ttimespec)(__ccgo_up(bp)) = Ttimespec{ + Ftv_sec: Int64FromUint32(seconds), + } + if Xnanosleep(tls, bp, bp) != 0 { + return Uint32FromInt64((**(**Ttimespec)(__ccgo_up(bp))).Ftv_sec) + } + return uint32(0) +} + +func Xsymlink(tls *TLS, existing uintptr, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v existing=%v new1=%v, (%v:)", tls, existing, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_symlinkat), int64(existing), int64(-Int32FromInt32(100)), int64(new1))))) +} + +func Xsymlinkat(tls *TLS, existing uintptr, fd int32, new1 uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v existing=%v fd=%v new1=%v, (%v:)", tls, existing, fd, new1, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_symlinkat), int64(existing), int64(fd), int64(new1))))) +} + +func Xsync(tls *TLS) { + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__syscall0(tls, int64(SYS_sync)) +} + +func Xtcgetpgrp(tls *TLS, fd int32) (r Tpid_t) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* pgrp at bp+0 */ int32 + if Xioctl(tls, fd, int32(TIOCGPGRP), VaList(bp+16, bp)) < 0 { + return -int32(1) + } + return **(**int32)(__ccgo_up(bp)) +} + +func Xtcsetpgrp(tls *TLS, fd int32, pgrp Tpid_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v pgrp=%v, (%v:)", tls, fd, pgrp, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(32) + defer tls.Free(32) + var _ /* pgrp_int at bp+0 */ int32 + **(**int32)(__ccgo_up(bp)) = pgrp + return Xioctl(tls, fd, int32(TIOCSPGRP), VaList(bp+16, bp)) +} + +func Xtruncate(tls *TLS, path uintptr, length Toff_t) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v length=%v, (%v:)", tls, path, length, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall2(tls, int64(SYS_truncate), int64(path), length)))) +} + +/* Support signed or unsigned plain-char */ + +/* Implementation choices... */ + +/* Arbitrary numbers... */ + +/* POSIX/SUS requirements follow. These numbers come directly + * from SUS and have nothing to do with the host system. */ + +func Xttyname(tls *TLS, fd int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + var result, v1 int32 + _, _ = result, v1 + v1 = Xttyname_r(tls, fd, uintptr(unsafe.Pointer(&_buf10)), uint64(32)) + result = v1 + if v1 != 0 { + **(**int32)(__ccgo_up(X__errno_location(tls))) = result + return UintptrFromInt32(0) + } + return uintptr(unsafe.Pointer(&_buf10)) +} + +var _buf10 [32]uint8 + +func Xttyname_r(tls *TLS, fd int32, name uintptr, size Tsize_t) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v name=%v size=%v, (%v:)", tls, fd, name, size, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(288) + defer tls.Free(288) + var l Tssize_t + var _ /* procname at bp+256 */ [29]uint8 + var _ /* st1 at bp+0 */ Tstat + var _ /* st2 at bp+128 */ Tstat + _ = l + if !(Xisatty(tls, fd) != 0) { + return **(**int32)(__ccgo_up(X__errno_location(tls))) + } + X__procfdname(tls, bp+256, Uint32FromInt32(fd)) + l = Xreadlink(tls, bp+256, name, size) + if l < 0 { + return **(**int32)(__ccgo_up(X__errno_location(tls))) + } else { + if Uint64FromInt64(l) == size { + return int32(ERANGE) + } + } + **(**uint8)(__ccgo_up(name + uintptr(l))) = uint8(0) + if Xstat(tls, name, bp) != 0 || Xfstat(tls, fd, bp+128) != 0 { + return **(**int32)(__ccgo_up(X__errno_location(tls))) + } + if (**(**Tstat)(__ccgo_up(bp))).Fst_dev != (**(**Tstat)(__ccgo_up(bp + 128))).Fst_dev || (**(**Tstat)(__ccgo_up(bp))).Fst_ino != (**(**Tstat)(__ccgo_up(bp + 128))).Fst_ino { + return int32(ENODEV) + } + return 0 +} + +func Xualarm(tls *TLS, value uint32, interval uint32) (r uint32) { + if __ccgo_strace { + trc("tls=%v value=%v interval=%v, (%v:)", tls, value, interval, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(64) + defer tls.Free(64) + var _ /* it at bp+0 */ Titimerval + var _ /* it_old at bp+32 */ Titimerval + **(**Titimerval)(__ccgo_up(bp)) = Titimerval{ + Fit_interval: Ttimeval{ + Ftv_usec: Int64FromUint32(interval), + }, + Fit_value: Ttimeval{ + Ftv_usec: Int64FromUint32(value), + }, + } + Xsetitimer(tls, ITIMER_REAL, bp, bp+32) + return Uint32FromInt64((**(**Titimerval)(__ccgo_up(bp + 32))).Fit_value.Ftv_sec*int64(1000000) + (**(**Titimerval)(__ccgo_up(bp + 32))).Fit_value.Ftv_usec) +} + +func Xunlink(tls *TLS, path uintptr) (r int32) { + if __ccgo_strace { + trc("tls=%v path=%v, (%v:)", tls, path, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_unlinkat), int64(-Int32FromInt32(100)), int64(path), int64(Int32FromInt32(0)))))) +} + +func Xunlinkat(tls *TLS, fd int32, path uintptr, flag int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v path=%v flag=%v, (%v:)", tls, fd, path, flag, origin(2)) + defer func() { trc("-> %v", r) }() + } + return int32(X__syscall_ret(tls, Uint64FromInt64(X__syscall3(tls, int64(SYS_unlinkat), int64(fd), int64(path), int64(flag))))) +} + +func Xusleep(tls *TLS, useconds uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v useconds=%v, (%v:)", tls, useconds, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var _ /* tv at bp+0 */ Ttimespec + **(**Ttimespec)(__ccgo_up(bp)) = Ttimespec{ + Ftv_sec: Int64FromUint32(useconds / uint32(1000000)), + Ftv_nsec: Int64FromUint32(useconds % uint32(1000000) * uint32(1000)), + } + return Xnanosleep(tls, bp, bp) +} + +func Xwrite(tls *TLS, fd int32, buf uintptr, count Tsize_t) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v buf=%v count=%v, (%v:)", tls, fd, buf, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_write), int64(fd), int64(buf), Int64FromUint64(count), 0, 0, 0))) +} + +func Xwritev(tls *TLS, fd int32, iov uintptr, count int32) (r Tssize_t) { + if __ccgo_strace { + trc("tls=%v fd=%v iov=%v count=%v, (%v:)", tls, fd, iov, count, origin(2)) + defer func() { trc("-> %v", r) }() + } + return X__syscall_ret(tls, Uint64FromInt64(___syscall_cp(tls, int64(SYS_writev), int64(fd), int64(iov), int64(count), 0, 0, 0))) +} + +func __ccgo_fp(f interface{}) uintptr { + type iface [2]uintptr + return (*iface)(unsafe.Pointer(&f))[1] +} + +func __ccgo_up(n uintptr) unsafe.Pointer { + return unsafe.Pointer(&n) +} + +var X__abort_lock [1]int32 + +var X__at_quick_exit_lockptr = uintptr(unsafe.Pointer(&_lock)) + +var X__c_dot_utf8 = t__locale_map{ + Fmap1: uintptr(unsafe.Pointer(&_empty_mo)), + Fmap_size: uint64(20), + Fname: [24]uint8{'C', '.', 'U', 'T', 'F', '-', '8'}, +} + +var X__c_dot_utf8_locale = t__locale_struct{ + Fcat: [6]uintptr{ + 0: uintptr(unsafe.Pointer(&X__c_dot_utf8)), + }, +} + +var X__c_locale = t__locale_struct{} + +var Xdaylight int32 + +var X__eintr_valid_flag int32 + +var Xenviron uintptr + +var X__exp2f_data = Texp2f_data{ + Ftab: [32]Tuint64_t{ + 0: uint64(0x3ff0000000000000), + 1: uint64(0x3fefd9b0d3158574), + 2: uint64(0x3fefb5586cf9890f), + 3: uint64(0x3fef9301d0125b51), + 4: uint64(0x3fef72b83c7d517b), + 5: uint64(0x3fef54873168b9aa), + 6: uint64(0x3fef387a6e756238), + 7: uint64(0x3fef1e9df51fdee1), + 8: uint64(0x3fef06fe0a31b715), + 9: uint64(0x3feef1a7373aa9cb), + 10: uint64(0x3feedea64c123422), + 11: uint64(0x3feece086061892d), + 12: uint64(0x3feebfdad5362a27), + 13: uint64(0x3feeb42b569d4f82), + 14: uint64(0x3feeab07dd485429), + 15: uint64(0x3feea47eb03a5585), + 16: uint64(0x3feea09e667f3bcd), + 17: uint64(0x3fee9f75e8ec5f74), + 18: uint64(0x3feea11473eb0187), + 19: uint64(0x3feea589994cce13), + 20: uint64(0x3feeace5422aa0db), + 21: uint64(0x3feeb737b0cdc5e5), + 22: uint64(0x3feec49182a3f090), + 23: uint64(0x3feed503b23e255d), + 24: uint64(0x3feee89f995ad3ad), + 25: uint64(0x3feeff76f2fb5e47), + 26: uint64(0x3fef199bdd85529c), + 27: uint64(0x3fef3720dcef9069), + 28: uint64(0x3fef5818dcfba487), + 29: uint64(0x3fef7c97337b9b5f), + 30: uint64(0x3fefa4afa2a490da), + 31: uint64(0x3fefd0765b6e4540), + }, + Fshift_scaled: Float64FromFloat64(6.755399441055744e+15) / float64(Int32FromInt32(1)<>Int32FromInt32(6) | Uint32FromInt32(0x0), + 31: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x1), + 32: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x2), + 33: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x3), + 34: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x4), + 35: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x5), + 36: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x6), + 37: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x7), + 38: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x8), + 39: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0x9), + 40: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xa), + 41: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xb), + 42: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xc), + 43: (Uint32FromUint32(0x40)-Uint32FromInt32(0xa0))<>Int32FromInt32(6) | Uint32FromInt32(0xd), + 44: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xe), + 45: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | Uint32FromInt32(0xf), + 46: (Uint32FromUint32(0)-Uint32FromInt32(0x90))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x0), + 47: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x1), + 48: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x2), + 49: (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x3), + 50: (Uint32FromUint32(0x40)-Uint32FromInt32(0x90))<>Int32FromInt32(6) | (Uint32FromUint32(0x40)-Uint32FromInt32(0xc0))<>Int32FromInt32(12) | Uint32FromInt32(0x4), +} + +var X__gettext_lockptr = uintptr(unsafe.Pointer(&_lock1)) + +var X__hwcap Tsize_t + +var X__libc t__libc + +var X__libc_version = [6]uint8{'1', '.', '2', '.', '5'} + +var X__locale_lock [1]int32 + +var X__locale_lockptr = uintptr(unsafe.Pointer(&X__locale_lock)) + +var X__log2_data = Tlog2_data{ + Finvln2hi: float64(1.4426950407214463), + Finvln2lo: float64(1.6751713164886512e-10), + Fpoly: [6]float64{ + 0: -Float64FromFloat64(0.7213475204444882), + 1: float64(0.4808983469629985), + 2: -Float64FromFloat64(0.36067375954075914), + 3: float64(0.2885390073180969), + 4: -Float64FromFloat64(0.2404693555628422), + 5: float64(0.2061202382173603), + }, + Fpoly1: [10]float64{ + 0: -Float64FromFloat64(0.7213475204444817), + 1: float64(0.48089834696298744), + 2: -Float64FromFloat64(0.360673760222145), + 3: float64(0.2885390081805197), + 4: -Float64FromFloat64(0.24044917405728863), + 5: float64(0.2060992861022954), + 6: -Float64FromFloat64(0.18033596705327856), + 7: float64(0.1603032746063156), + 8: -Float64FromFloat64(0.14483316576701266), + 9: float64(0.13046826811283835), + }, + Ftab: [64]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.4463276106642393), + Flogc: -Float64FromFloat64(0.5323943771486483), + }, + 1: { + Finvc: float64(1.4301675812282968), + Flogc: -Float64FromFloat64(0.516184206053822), + }, + 2: { + Finvc: float64(1.4143648676229383), + Flogc: -Float64FromFloat64(0.5001543441974263), + }, + 3: { + Finvc: float64(1.3989068970611538), + Flogc: -Float64FromFloat64(0.4842999484799293), + }, + 4: { + Finvc: float64(1.3837838957784339), + Flogc: -Float64FromFloat64(0.46861865624623533), + }, + 5: { + Finvc: float64(1.368983882697786), + Flogc: -Float64FromFloat64(0.4531054615783887), + }, + 6: { + Finvc: float64(1.3544972916324536), + Flogc: -Float64FromFloat64(0.43775750882059583), + }, + 7: { + Finvc: float64(1.3403139676437443), + Flogc: -Float64FromFloat64(0.4225709906127122), + }, + 8: { + Finvc: float64(1.3264249304188642), + Flogc: -Float64FromFloat64(0.40754302793970965), + }, + 9: { + Finvc: float64(1.3128203652112156), + Flogc: -Float64FromFloat64(0.3926695240384106), + }, + 10: { + Finvc: float64(1.299492412370217), + Flogc: -Float64FromFloat64(0.3779482100565019), + }, + 11: { + Finvc: float64(1.28643198385998), + Flogc: -Float64FromFloat64(0.36337518101890964), + }, + 12: { + Finvc: float64(1.2736319291846832), + Flogc: -Float64FromFloat64(0.3489484089425332), + }, + 13: { + Finvc: float64(1.2610838968062879), + Flogc: -Float64FromFloat64(0.33466425780738973), + }, + 14: { + Finvc: float64(1.248780314313572), + Flogc: -Float64FromFloat64(0.3205197000629596), + }, + 15: { + Finvc: float64(1.2367150450059063), + Flogc: -Float64FromFloat64(0.3065131231801388), + }, + 16: { + Finvc: float64(1.2248804968401878), + Flogc: -Float64FromFloat64(0.2926410022678283), + }, + 17: { + Finvc: float64(1.2132702353497795), + Flogc: -Float64FromFloat64(0.2789009220805383), + }, + 18: { + Finvc: float64(1.2018780785715362), + Flogc: -Float64FromFloat64(0.2652905529862437), + }, + 19: { + Finvc: float64(1.190697765061355), + Flogc: -Float64FromFloat64(0.2518072602367738), + }, + 20: { + Finvc: float64(1.1797235410550593), + Flogc: -Float64FromFloat64(0.23844881494437686), + }, + 21: { + Finvc: float64(1.1689498986205256), + Flogc: -Float64FromFloat64(0.22521309705462045), + }, + 22: { + Finvc: float64(1.158371137408455), + Flogc: -Float64FromFloat64(0.21209756102439314), + }, + 23: { + Finvc: float64(1.1479820146386086), + Flogc: -Float64FromFloat64(0.1991000395789797), + }, + 24: { + Finvc: float64(1.1377775576851088), + Flogc: -Float64FromFloat64(0.18621852970682085), + }, + 25: { + Finvc: float64(1.127753150630225), + Flogc: -Float64FromFloat64(0.17345131655361), + }, + 26: { + Finvc: float64(1.1179037012282074), + Flogc: -Float64FromFloat64(0.16079591649577196), + }, + 27: { + Finvc: float64(1.1082251967632821), + Flogc: -Float64FromFloat64(0.14825107384353942), + }, + 28: { + Finvc: float64(1.098712461056607), + Flogc: -Float64FromFloat64(0.13581387465410444), + }, + 29: { + Finvc: float64(1.0893619091634283), + Flogc: -Float64FromFloat64(0.12348332762257996), + }, + 30: { + Finvc: float64(1.0801689912316736), + Flogc: -Float64FromFloat64(0.11125703807351783), + }, + 31: { + Finvc: float64(1.071129489697672), + Flogc: -Float64FromFloat64(0.09913289918449664), + }, + 32: { + Finvc: float64(1.0622406576750423), + Flogc: -Float64FromFloat64(0.08711065531497297), + }, + 33: { + Finvc: float64(1.0534977607927976), + Flogc: -Float64FromFloat64(0.07518724771330199), + }, + 34: { + Finvc: float64(1.044897877982342), + Flogc: -Float64FromFloat64(0.06336194888240243), + }, + 35: { + Finvc: float64(1.0364370289499079), + Flogc: -Float64FromFloat64(0.0516324649456692), + }, + 36: { + Finvc: float64(1.0281122132034575), + Flogc: -Float64FromFloat64(0.039997735929773626), + }, + 37: { + Finvc: float64(1.0199202450036955), + Flogc: -Float64FromFloat64(0.028456341769015125), + }, + 38: { + Finvc: float64(1.0118577522306755), + Flogc: -Float64FromFloat64(0.017006489068080555), + }, + 39: { + Finvc: float64(1.003921649236766), + Flogc: -Float64FromFloat64(0.005646678981520381), + }, + 40: { + Finvc: float64(0.9922480467550775), + Flogc: float64(0.011227277611396858), + }, + 41: { + Finvc: float64(0.9770993366178549), + Flogc: float64(0.033422853921138085), + }, + 42: { + Finvc: float64(0.9624059787315814), + Flogc: float64(0.05528248992573026), + }, + 43: { + Finvc: float64(0.9481480598286369), + Flogc: float64(0.07681573143713649), + }, + 44: { + Finvc: float64(0.9343065931261065), + Flogc: float64(0.09803204623631245), + }, + 45: { + Finvc: float64(0.9208633936884979), + Flogc: float64(0.11894094059630334), + }, + 46: { + Finvc: float64(0.9078013641840602), + Flogc: float64(0.13955143862290242), + }, + 47: { + Finvc: float64(0.8951048181512927), + Flogc: float64(0.15987146080919956), + }, + 48: { + Finvc: float64(0.882758574260473), + Flogc: float64(0.17990916589428707), + }, + 49: { + Finvc: float64(0.8707481902241709), + Flogc: float64(0.19967252559081317), + }, + 50: { + Finvc: float64(0.8590602881746972), + Flogc: float64(0.2191687127685782), + }, + 51: { + Finvc: float64(0.8476822044336688), + Flogc: float64(0.23840459427242422), + }, + 52: { + Finvc: float64(0.8366013284053287), + Flogc: float64(0.25738780610663525), + }, + 53: { + Finvc: float64(0.8258064913621258), + Flogc: float64(0.27612433583180973), + }, + 54: { + Finvc: float64(0.8152865101579193), + Flogc: float64(0.2946209507022104), + }, + 55: { + Finvc: float64(0.8050314363208223), + Flogc: float64(0.31288297359969874), + }, + 56: { + Finvc: float64(0.7950310492640542), + Flogc: float64(0.33091689015759584), + }, + 57: { + Finvc: float64(0.7852760432487271), + Flogc: float64(0.3487282100279572), + }, + 58: { + Finvc: float64(0.7757575660314712), + Flogc: float64(0.36632223233368677), + }, + 59: { + Finvc: float64(0.7664670566588946), + Flogc: float64(0.383704309808536), + }, + 60: { + Finvc: float64(0.7573965608078645), + Flogc: float64(0.4008792246509074), + }, + 61: { + Finvc: float64(0.7485380168514022), + Flogc: float64(0.41785250494945103), + }, + 62: { + Finvc: float64(0.7398844213755009), + Flogc: float64(0.4346281724315304), + }, + 63: { + Finvc: float64(0.7314286113178112), + Flogc: float64(0.45121103315341315), + }, + }, +} + +var X__log2f_data = Tlog2f_data{ + Ftab: [16]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.398907162146528), + Flogc: -Float64FromFloat64(0.48430022186289673), + }, + 1: { + Finvc: float64(1.3403141896637998), + Flogc: -Float64FromFloat64(0.42257122959194704), + }, + 2: { + Finvc: float64(1.286432210124115), + Flogc: -Float64FromFloat64(0.3633754347673556), + }, + 3: { + Finvc: float64(1.2367150214269895), + Flogc: -Float64FromFloat64(0.30651309567405577), + }, + 4: { + Finvc: float64(1.1906977166711752), + Flogc: -Float64FromFloat64(0.25180720160537634), + }, + 5: { + Finvc: float64(1.1479821020556429), + Flogc: -Float64FromFloat64(0.19910014943794563), + }, + 6: { + Finvc: float64(1.1082251448272158), + Flogc: -Float64FromFloat64(0.14825100623281615), + }, + 7: { + Finvc: float64(1.0711297413057381), + Flogc: -Float64FromFloat64(0.09913323807318392), + }, + 8: { + Finvc: float64(1.036437278977283), + Flogc: -Float64FromFloat64(0.051632812977629436), + }, + 9: { + Finvc: float64(1), + }, + 10: { + Finvc: float64(0.9492859795739057), + Flogc: float64(0.07508531937943004), + }, + 11: { + Finvc: float64(0.8951049428609004), + Flogc: float64(0.15987125980713107), + }, + 12: { + Finvc: float64(0.8476821620351103), + Flogc: float64(0.2384046664317681), + }, + 13: { + Finvc: float64(0.8050314851692001), + Flogc: float64(0.31288288605863257), + }, + 14: { + Finvc: float64(0.7664671008843108), + Flogc: float64(0.38370422656453185), + }, + 15: { + Finvc: float64(0.731428603316328), + Flogc: float64(0.451211048935815), + }, + }, + Fpoly: [4]float64{ + 0: -Float64FromFloat64(0.36051725506874704), + 1: float64(0.4811247078767291), + 2: -Float64FromFloat64(0.7213476299867769), + 3: float64(1.4426950186867042), + }, +} + +var X__log_data = Tlog_data{ + Fln2hi: float64(0.6931471805598903), + Fln2lo: float64(5.497923018708371e-14), + Fpoly: [5]float64{ + 0: -Float64FromFloat64(0.5000000000000001), + 1: float64(0.33333333331825593), + 2: -Float64FromFloat64(0.2499999999622955), + 3: float64(0.20000304511814496), + 4: -Float64FromFloat64(0.16667054827627667), + }, + Fpoly1: [11]float64{ + 0: -Float64FromFloat64(0.5), + 1: float64(0.3333333333333352), + 2: -Float64FromFloat64(0.24999999999998432), + 3: float64(0.19999999999320328), + 4: -Float64FromFloat64(0.16666666669929706), + 5: float64(0.14285715076560868), + 6: -Float64FromFloat64(0.12499997863982555), + 7: float64(0.11110712032936046), + 8: -Float64FromFloat64(0.10000486757818193), + 9: float64(0.09181994006195467), + 10: -Float64FromFloat64(0.08328363062289341), + }, + Ftab: [128]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.4504249240398293), + Flogc: -Float64FromFloat64(0.3718565645633589), + }, + 1: { + Finvc: float64(1.442253508327276), + Flogc: -Float64FromFloat64(0.36620682668944937), + }, + 2: { + Finvc: float64(1.4341736174350004), + Flogc: -Float64FromFloat64(0.3605888069791945), + }, + 3: { + Finvc: float64(1.426183816329995), + Flogc: -Float64FromFloat64(0.3550022171419869), + }, + 4: { + Finvc: float64(1.4182825527052965), + Flogc: -Float64FromFloat64(0.34944666968829097), + }, + 5: { + Finvc: float64(1.4104682921759335), + Flogc: -Float64FromFloat64(0.3439217713603284), + }, + 6: { + Finvc: float64(1.4027396147468003), + Flogc: -Float64FromFloat64(0.3384271921261188), + }, + 7: { + Finvc: float64(1.3950954438932313), + Flogc: -Float64FromFloat64(0.332962831494342), + }, + 8: { + Finvc: float64(1.3875338232485754), + Flogc: -Float64FromFloat64(0.32752794345742586), + }, + 9: { + Finvc: float64(1.3800539211058593), + Flogc: -Float64FromFloat64(0.32212257167088865), + }, + 10: { + Finvc: float64(1.3726542695419708), + Flogc: -Float64FromFloat64(0.3167462884799761), + }, + 11: { + Finvc: float64(1.3653332798446802), + Flogc: -Float64FromFloat64(0.3113985598928366), + }, + 12: { + Finvc: float64(1.358090204587874), + Flogc: -Float64FromFloat64(0.3060794515165526), + }, + 13: { + Finvc: float64(1.3509234892132138), + Flogc: -Float64FromFloat64(0.300788424667644), + }, + 14: { + Finvc: float64(1.3438320840699889), + Flogc: -Float64FromFloat64(0.2955252968476998), + }, + 15: { + Finvc: float64(1.3368146974742003), + Flogc: -Float64FromFloat64(0.29028969275850613), + }, + 16: { + Finvc: float64(1.329870114677736), + Flogc: -Float64FromFloat64(0.2850812793277555), + }, + 17: { + Finvc: float64(1.322997339161106), + Flogc: -Float64FromFloat64(0.27989987391470095), + }, + 18: { + Finvc: float64(1.316195352741367), + Flogc: -Float64FromFloat64(0.27474526621870154), + }, + 19: { + Finvc: float64(1.3094628125672239), + Flogc: -Float64FromFloat64(0.2696169863701243), + }, + 20: { + Finvc: float64(1.3027990455471041), + Flogc: -Float64FromFloat64(0.26451506180308115), + }, + 21: { + Finvc: float64(1.2962024229438942), + Flogc: -Float64FromFloat64(0.2594387762767383), + }, + 22: { + Finvc: float64(1.2896726275815547), + Flogc: -Float64FromFloat64(0.2543884090981692), + }, + 23: { + Finvc: float64(1.2832080305745537), + Flogc: -Float64FromFloat64(0.24936321635129843), + }, + 24: { + Finvc: float64(1.276807885983376), + Flogc: -Float64FromFloat64(0.24436312405975968), + }, + 25: { + Finvc: float64(1.2704714060687552), + Flogc: -Float64FromFloat64(0.23938801747897287), + }, + 26: { + Finvc: float64(1.2641976054949482), + Flogc: -Float64FromFloat64(0.23443761696705678), + }, + 27: { + Finvc: float64(1.257985357514882), + Flogc: -Float64FromFloat64(0.22951151871518505), + }, + 28: { + Finvc: float64(1.2518337750655457), + Flogc: -Float64FromFloat64(0.2246094963439873), + }, + 29: { + Finvc: float64(1.2457421919097305), + Flogc: -Float64FromFloat64(0.21973149037705753), + }, + 30: { + Finvc: float64(1.2397094966625508), + Flogc: -Float64FromFloat64(0.2148770752847895), + }, + 31: { + Finvc: float64(1.2337348463589233), + Flogc: -Float64FromFloat64(0.210046029103637), + }, + 32: { + Finvc: float64(1.2278176973028803), + Flogc: -Float64FromFloat64(0.20523836373934046), + }, + 33: { + Finvc: float64(1.2219570190618474), + Flogc: -Float64FromFloat64(0.20045368751368642), + }, + 34: { + Finvc: float64(1.2161519732977757), + Flogc: -Float64FromFloat64(0.1956917537758045), + }, + 35: { + Finvc: float64(1.2104018095009725), + Flogc: -Float64FromFloat64(0.19095237845203883), + }, + 36: { + Finvc: float64(1.204705805718973), + Flogc: -Float64FromFloat64(0.18623539250290833), + }, + 37: { + Finvc: float64(1.1990631185441964), + Flogc: -Float64FromFloat64(0.18154051731551135), + }, + 38: { + Finvc: float64(1.1934733004462308), + Flogc: -Float64FromFloat64(0.1768677957431919), + }, + 39: { + Finvc: float64(1.1879350812847385), + Flogc: -Float64FromFloat64(0.17221657406412305), + }, + 40: { + Finvc: float64(1.1824481322833125), + Flogc: -Float64FromFloat64(0.16758697765942543), + }, + 41: { + Finvc: float64(1.1770114976921955), + Flogc: -Float64FromFloat64(0.16297859687290384), + }, + 42: { + Finvc: float64(1.1716248121809465), + Flogc: -Float64FromFloat64(0.15839151377804228), + }, + 43: { + Finvc: float64(1.1662869231674715), + Flogc: -Float64FromFloat64(0.15382513241456763), + }, + 44: { + Finvc: float64(1.1609977486762766), + Flogc: -Float64FromFloat64(0.14927976358922024), + }, + 45: { + Finvc: float64(1.1557563220795803), + Flogc: -Float64FromFloat64(0.14475495398119165), + }, + 46: { + Finvc: float64(1.1505619105480347), + Flogc: -Float64FromFloat64(0.14025044090817573), + }, + 47: { + Finvc: float64(1.1454138888505974), + Flogc: -Float64FromFloat64(0.1357660466685502), + }, + 48: { + Finvc: float64(1.140311877374656), + Flogc: -Float64FromFloat64(0.1313018016355727), + }, + 49: { + Finvc: float64(1.1352550225747513), + Flogc: -Float64FromFloat64(0.12685731518763532), + }, + 50: { + Finvc: float64(1.1302429094831266), + Flogc: -Float64FromFloat64(0.1224325737671279), + }, + 51: { + Finvc: float64(1.1252747693068048), + Flogc: -Float64FromFloat64(0.11802724521862729), + }, + 52: { + Finvc: float64(1.1203501571039876), + Flogc: -Float64FromFloat64(0.11364127671663482), + }, + 53: { + Finvc: float64(1.1154683327680124), + Flogc: -Float64FromFloat64(0.10927434611278386), + }, + 54: { + Finvc: float64(1.1106291463292157), + Flogc: -Float64FromFloat64(0.10492665324943573), + }, + 55: { + Finvc: float64(1.1058315813301596), + Flogc: -Float64FromFloat64(0.10059761422644442), + }, + 56: { + Finvc: float64(1.1010752177696026), + Flogc: -Float64FromFloat64(0.09628717309055901), + }, + 57: { + Finvc: float64(1.0963597137952512), + Flogc: -Float64FromFloat64(0.09199534069557558), + }, + 58: { + Finvc: float64(1.0916844827550398), + Flogc: -Float64FromFloat64(0.08772190036688698), + }, + 59: { + Finvc: float64(1.0870487291277784), + Flogc: -Float64FromFloat64(0.08346643613867855), + }, + 60: { + Finvc: float64(1.082452357388312), + Flogc: -Float64FromFloat64(0.07922916827544668), + }, + 61: { + Finvc: float64(1.0778948225025884), + Flogc: -Float64FromFloat64(0.0750099004750382), + }, + 62: { + Finvc: float64(1.0733751731601076), + Flogc: -Float64FromFloat64(0.07080805133352897), + }, + 63: { + Finvc: float64(1.068893585073351), + Flogc: -Float64FromFloat64(0.06662408085151128), + }, + 64: { + Finvc: float64(1.0644491706655506), + Flogc: -Float64FromFloat64(0.06245745471915143), + }, + 65: { + Finvc: float64(1.0600414846328305), + Flogc: -Float64FromFloat64(0.0583080438042316), + }, + 66: { + Finvc: float64(1.0556701316181605), + Flogc: -Float64FromFloat64(0.05417576112313327), + }, + 67: { + Finvc: float64(1.051334750556926), + Flogc: -Float64FromFloat64(0.050060547896805474), + }, + 68: { + Finvc: float64(1.0470347288442157), + Flogc: -Float64FromFloat64(0.045962101199052086), + }, + 69: { + Finvc: float64(1.0427699229652954), + Flogc: -Float64FromFloat64(0.04188056008865715), + }, + 70: { + Finvc: float64(1.0385395013738175), + Flogc: -Float64FromFloat64(0.03781540056183985), + }, + 71: { + Finvc: float64(1.034343418940345), + Flogc: -Float64FromFloat64(0.03376684757915882), + }, + 72: { + Finvc: float64(1.0301811073173315), + Flogc: -Float64FromFloat64(0.029734619131772888), + }, + 73: { + Finvc: float64(1.026052043621297), + Flogc: -Float64FromFloat64(0.025718470239212365), + }, + 74: { + Finvc: float64(1.0219561082336197), + Flogc: -Float64FromFloat64(0.021718543925430822), + }, + 75: { + Finvc: float64(1.0178926505784922), + Flogc: -Float64FromFloat64(0.01773446126981071), + }, + 76: { + Finvc: float64(1.0138614436244586), + Flogc: -Float64FromFloat64(0.013766252464051831), + }, + 77: { + Finvc: float64(1.0098620186501341), + Flogc: -Float64FromFloat64(0.009813706322574944), + }, + 78: { + Finvc: float64(1.0058938559734134), + Flogc: -Float64FromFloat64(0.005876555150052809), + }, + 79: { + Finvc: float64(1.00195696235014), + Flogc: -Float64FromFloat64(0.0019550499938532084), + }, + 80: { + Finvc: float64(0.9961089923088509), + Flogc: float64(0.0038985973556009412), + }, + 81: { + Finvc: float64(0.9884170338185201), + Flogc: float64(0.011650571286395461), + }, + 82: { + Finvc: float64(0.9808429191005297), + Flogc: float64(0.019342955478919066), + }, + 83: { + Finvc: float64(0.9733840169987446), + Flogc: float64(0.0269766014846482), + }, + 84: { + Finvc: float64(0.9660377568876556), + Flogc: float64(0.034552359728422744), + }, + 85: { + Finvc: float64(0.9588014945307369), + Flogc: float64(0.04207121767183253), + }, + 86: { + Finvc: float64(0.9516728569073111), + Flogc: float64(0.049533940950141186), + }, + 87: { + Finvc: float64(0.9446494635965822), + Flogc: float64(0.056941358295944156), + }, + 88: { + Finvc: float64(0.9377288993026223), + Flogc: float64(0.06429439168346107), + }, + 89: { + Finvc: float64(0.9309091073790681), + Flogc: float64(0.0715936354946507), + }, + 90: { + Finvc: float64(0.924187681612722), + Flogc: float64(0.07884010933776153), + }, + 91: { + Finvc: float64(0.9175626765599192), + Flogc: float64(0.08603438905970506), + }, + 92: { + Finvc: float64(0.9110320403624034), + Flogc: float64(0.09317721180013905), + }, + 93: { + Finvc: float64(0.9045935839762024), + Flogc: float64(0.10026951462748457), + }, + 94: { + Finvc: float64(0.8982456375922825), + Flogc: float64(0.10731170956330516), + }, + 95: { + Finvc: float64(0.8919860966782501), + Flogc: float64(0.11430473320717738), + }, + 96: { + Finvc: float64(0.8858131121185129), + Flogc: float64(0.12124928503033061), + }, + 97: { + Finvc: float64(0.879725075760676), + Flogc: float64(0.12814583422959913), + }, + 98: { + Finvc: float64(0.8737201372634685), + Flogc: float64(0.1349951636851756), + }, + 99: { + Finvc: float64(0.8677966405782273), + Flogc: float64(0.1417978768189414), + }, + 100: { + Finvc: float64(0.8619528050060739), + Flogc: float64(0.14855476039031146), + }, + 101: { + Finvc: float64(0.8561872354420692), + Flogc: float64(0.1552661937658968), + }, + 102: { + Finvc: float64(0.8504983927816893), + Flogc: float64(0.16193275688146969), + }, + 103: { + Finvc: float64(0.8448844572790304), + Flogc: float64(0.16855539792220497), + }, + 104: { + Finvc: float64(0.8393442741575965), + Flogc: float64(0.1751343179947753), + }, + 105: { + Finvc: float64(0.8338762249349438), + Flogc: float64(0.1816702989864325), + }, + 106: { + Finvc: float64(0.8284789320557778), + Flogc: float64(0.18816387146023317), + }, + 107: { + Finvc: float64(0.8231510800065832), + Flogc: float64(0.1946155228479256), + }, + 108: { + Finvc: float64(0.8178913903778707), + Flogc: float64(0.20102572579389744), + }, + 109: { + Finvc: float64(0.8126984007245374), + Flogc: float64(0.2073952090795501), + }, + 110: { + Finvc: float64(0.8075710029460227), + Flogc: float64(0.21372429840596396), + }, + 111: { + Finvc: float64(0.8025078881160415), + Flogc: float64(0.2200135945981856), + }, + 112: { + Finvc: float64(0.7975077379364331), + Flogc: float64(0.22626374162859975), + }, + 113: { + Finvc: float64(0.792569604966373), + Flogc: float64(0.23247494747693054), + }, + 114: { + Finvc: float64(0.7876923641254114), + Flogc: float64(0.23864766620658884), + }, + 115: { + Finvc: float64(0.7828746724940998), + Flogc: float64(0.24478265647405806), + }, + 116: { + Finvc: float64(0.7781155388790811), + Flogc: float64(0.25088025827324145), + }, + 117: { + Finvc: float64(0.7734139557869777), + Flogc: float64(0.2569408552510595), + }, + 118: { + Finvc: float64(0.7687687179914933), + Flogc: float64(0.26296511155101143), + }, + 119: { + Finvc: float64(0.7641790698041854), + Flogc: float64(0.2689531327189343), + }, + 120: { + Finvc: float64(0.7596438763692399), + Flogc: float64(0.27490553924610595), + }, + 121: { + Finvc: float64(0.7551621951078668), + Flogc: float64(0.2808227248478943), + }, + 122: { + Finvc: float64(0.7507331780216866), + Flogc: float64(0.286704979267256), + }, + 123: { + Finvc: float64(0.7463557196361751), + Flogc: float64(0.29255295645509705), + }, + 124: { + Finvc: float64(0.7420289364869653), + Flogc: float64(0.2983670386142876), + }, + 125: { + Finvc: float64(0.7377521537065876), + Flogc: float64(0.30414734587282055), + }, + 126: { + Finvc: float64(0.7335242966002608), + Flogc: float64(0.30989455774829366), + }, + 127: { + Finvc: float64(0.729344777457841), + Flogc: float64(0.31560871301871884), + }, + }, +} + +var X__logf_data = Tlogf_data{ + Ftab: [16]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.398907162146528), + Flogc: -Float64FromFloat64(0.33569133332882284), + }, + 1: { + Finvc: float64(1.3403141896637998), + Flogc: -Float64FromFloat64(0.2929040563774074), + }, + 2: { + Finvc: float64(1.286432210124115), + Flogc: -Float64FromFloat64(0.2518726580937369), + }, + 3: { + Finvc: float64(1.2367150214269895), + Flogc: -Float64FromFloat64(0.21245868807117255), + }, + 4: { + Finvc: float64(1.1906977166711752), + Flogc: -Float64FromFloat64(0.17453945183745634), + }, + 5: { + Finvc: float64(1.1479821020556429), + Flogc: -Float64FromFloat64(0.1380057072319758), + }, + 6: { + Finvc: float64(1.1082251448272158), + Flogc: -Float64FromFloat64(0.10275976698545139), + }, + 7: { + Finvc: float64(1.0711297413057381), + Flogc: -Float64FromFloat64(0.06871392447020525), + }, + 8: { + Finvc: float64(1.036437278977283), + Flogc: -Float64FromFloat64(0.0357891387398228), + }, + 9: { + Finvc: float64(1), + }, + 10: { + Finvc: float64(0.9492859795739057), + Flogc: float64(0.05204517742929496), + }, + 11: { + Finvc: float64(0.8951049428609004), + Flogc: float64(0.11081431298787942), + }, + 12: { + Finvc: float64(0.8476821620351103), + Flogc: float64(0.1652495223695143), + }, + 13: { + Finvc: float64(0.8050314851692001), + Flogc: float64(0.21687389031699977), + }, + 14: { + Finvc: float64(0.7664671008843108), + Flogc: float64(0.2659635028121397), + }, + 15: { + Finvc: float64(0.731428603316328), + Flogc: float64(0.3127556664073557), + }, + }, + Fln2: float64(0.6931471805599453), + Fpoly: [3]float64{ + 0: -Float64FromFloat64(0.25089342214237154), + 1: float64(0.333456765744066), + 2: -Float64FromFloat64(0.4999997485802103), + }, +} + +var X__optpos int32 + +var Xoptreset int32 + +var X__pow_log_data = Tpow_log_data{ + Fln2hi: float64(0.6931471805598903), + Fln2lo: float64(5.497923018708371e-14), + Fpoly: [7]float64{ + 0: -Float64FromFloat64(0.5), + 1: float64(Float64FromFloat64(0.3333333333333339) * float64(-Int32FromInt32(2))), + 2: float64(-Float64FromFloat64(0.25000000000000033) * float64(-Int32FromInt32(2))), + 3: float64(Float64FromFloat64(0.1999999998830994) * Float64FromInt32(4)), + 4: float64(-Float64FromFloat64(0.16666666658719348) * Float64FromInt32(4)), + 5: float64(Float64FromFloat64(0.14286370355743763) * float64(-Int32FromInt32(8))), + 6: float64(-Float64FromFloat64(0.12500519079594427) * float64(-Int32FromInt32(8))), + }, + Ftab: [128]struct { + Finvc float64 + Fpad float64 + Flogc float64 + Flogctail float64 + }{ + 0: { + Finvc: float64(1.4140625), + Flogc: -Float64FromFloat64(0.3464667673462145), + Flogctail: float64(5.929407345889625e-15), + }, + 1: { + Finvc: float64(1.40625), + Flogc: -Float64FromFloat64(0.34092658697056777), + Flogctail: -Float64FromFloat64(2.544157440035963e-14), + }, + 2: { + Finvc: float64(1.3984375), + Flogc: -Float64FromFloat64(0.3353555419211034), + Flogctail: -Float64FromFloat64(3.443525940775045e-14), + }, + 3: { + Finvc: float64(1.390625), + Flogc: -Float64FromFloat64(0.3297532863724655), + Flogctail: -Float64FromFloat64(2.500123826022799e-15), + }, + 4: { + Finvc: float64(1.3828125), + Flogc: -Float64FromFloat64(0.32411946865420305), + Flogctail: -Float64FromFloat64(8.929337133850617e-15), + }, + 5: { + Finvc: float64(1.375), + Flogc: -Float64FromFloat64(0.31845373111855224), + Flogctail: float64(1.7625431312172662e-14), + }, + 6: { + Finvc: float64(1.3671875), + Flogc: -Float64FromFloat64(0.31275571000389846), + Flogctail: float64(1.5688303180062087e-15), + }, + 7: { + Finvc: float64(1.359375), + Flogc: -Float64FromFloat64(0.3070250352949415), + Flogctail: float64(2.9655274673691784e-14), + }, + 8: { + Finvc: float64(1.3515625), + Flogc: -Float64FromFloat64(0.3012613305781997), + Flogctail: float64(3.7923164802093147e-14), + }, + 9: { + Finvc: float64(1.34375), + Flogc: -Float64FromFloat64(0.2954642128938758), + Flogctail: float64(3.993416384387844e-14), + }, + 10: { + Finvc: float64(1.3359375), + Flogc: -Float64FromFloat64(0.28963329258306203), + Flogctail: float64(1.9352855826489123e-14), + }, + 11: { + Finvc: float64(1.3359375), + Flogc: -Float64FromFloat64(0.28963329258306203), + Flogctail: float64(1.9352855826489123e-14), + }, + 12: { + Finvc: float64(1.328125), + Flogc: -Float64FromFloat64(0.28376817313062475), + Flogctail: -Float64FromFloat64(1.9852665484979036e-14), + }, + 13: { + Finvc: float64(1.3203125), + Flogc: -Float64FromFloat64(0.27786845100342816), + Flogctail: -Float64FromFloat64(2.814323765595281e-14), + }, + 14: { + Finvc: float64(1.3125), + Flogc: -Float64FromFloat64(0.2719337154836694), + Flogctail: float64(2.7643769993528702e-14), + }, + 15: { + Finvc: float64(1.3046875), + Flogc: -Float64FromFloat64(0.2659635484970977), + Flogctail: -Float64FromFloat64(4.025092402293806e-14), + }, + 16: { + Finvc: float64(1.296875), + Flogc: -Float64FromFloat64(0.25995752443691345), + Flogctail: -Float64FromFloat64(1.2621729398885316e-14), + }, + 17: { + Finvc: float64(1.2890625), + Flogc: -Float64FromFloat64(0.25391520998095984), + Flogctail: -Float64FromFloat64(3.600176732637335e-15), + }, + 18: { + Finvc: float64(1.2890625), + Flogc: -Float64FromFloat64(0.25391520998095984), + Flogctail: -Float64FromFloat64(3.600176732637335e-15), + }, + 19: { + Finvc: float64(1.28125), + Flogc: -Float64FromFloat64(0.2478361639045943), + Flogctail: float64(1.3029797173308663e-14), + }, + 20: { + Finvc: float64(1.2734375), + Flogc: -Float64FromFloat64(0.2417199368871934), + Flogctail: float64(4.8230289429940886e-14), + }, + 21: { + Finvc: float64(1.265625), + Flogc: -Float64FromFloat64(0.23556607131274632), + Flogctail: -Float64FromFloat64(2.0592242769647135e-14), + }, + 22: { + Finvc: float64(1.2578125), + Flogc: -Float64FromFloat64(0.22937410106487732), + Flogctail: float64(3.149265065191484e-14), + }, + 23: { + Finvc: float64(1.25), + Flogc: -Float64FromFloat64(0.22314355131425145), + Flogctail: float64(4.169796584527195e-14), + }, + 24: { + Finvc: float64(1.25), + Flogc: -Float64FromFloat64(0.22314355131425145), + Flogctail: float64(4.169796584527195e-14), + }, + 25: { + Finvc: float64(1.2421875), + Flogc: -Float64FromFloat64(0.21687393830063684), + Flogctail: float64(2.2477465222466186e-14), + }, + 26: { + Finvc: float64(1.234375), + Flogc: -Float64FromFloat64(0.21056476910735), + Flogctail: float64(3.6507188831790577e-16), + }, + 27: { + Finvc: float64(1.2265625), + Flogc: -Float64FromFloat64(0.2042155414286526), + Flogctail: -Float64FromFloat64(3.827767260205414e-14), + }, + 28: { + Finvc: float64(1.2265625), + Flogc: -Float64FromFloat64(0.2042155414286526), + Flogctail: -Float64FromFloat64(3.827767260205414e-14), + }, + 29: { + Finvc: float64(1.21875), + Flogc: -Float64FromFloat64(0.19782574332987224), + Flogctail: -Float64FromFloat64(4.7641388950792196e-14), + }, + 30: { + Finvc: float64(1.2109375), + Flogc: -Float64FromFloat64(0.19139485299967873), + Flogctail: float64(4.9278276214647115e-14), + }, + 31: { + Finvc: float64(1.203125), + Flogc: -Float64FromFloat64(0.18492233849406148), + Flogctail: float64(4.9485167661250996e-14), + }, + 32: { + Finvc: float64(1.203125), + Flogc: -Float64FromFloat64(0.18492233849406148), + Flogctail: float64(4.9485167661250996e-14), + }, + 33: { + Finvc: float64(1.1953125), + Flogc: -Float64FromFloat64(0.1784076574728033), + Flogctail: -Float64FromFloat64(1.5003333854266542e-14), + }, + 34: { + Finvc: float64(1.1875), + Flogc: -Float64FromFloat64(0.17185025692663203), + Flogctail: -Float64FromFloat64(2.7194441649495324e-14), + }, + 35: { + Finvc: float64(1.1875), + Flogc: -Float64FromFloat64(0.17185025692663203), + Flogctail: -Float64FromFloat64(2.7194441649495324e-14), + }, + 36: { + Finvc: float64(1.1796875), + Flogc: -Float64FromFloat64(0.1652495728952772), + Flogctail: -Float64FromFloat64(2.99659267292569e-14), + }, + 37: { + Finvc: float64(1.171875), + Flogc: -Float64FromFloat64(0.15860503017665906), + Flogctail: float64(2.0472357800461955e-14), + }, + 38: { + Finvc: float64(1.171875), + Flogc: -Float64FromFloat64(0.15860503017665906), + Flogctail: float64(2.0472357800461955e-14), + }, + 39: { + Finvc: float64(1.1640625), + Flogc: -Float64FromFloat64(0.15191604202584585), + Flogctail: float64(3.879296723063646e-15), + }, + 40: { + Finvc: float64(1.15625), + Flogc: -Float64FromFloat64(0.1451820098444614), + Flogctail: -Float64FromFloat64(3.6506824353335045e-14), + }, + 41: { + Finvc: float64(1.1484375), + Flogc: -Float64FromFloat64(0.13840232285906495), + Flogctail: -Float64FromFloat64(5.4183331379008994e-14), + }, + 42: { + Finvc: float64(1.1484375), + Flogc: -Float64FromFloat64(0.13840232285906495), + Flogctail: -Float64FromFloat64(5.4183331379008994e-14), + }, + 43: { + Finvc: float64(1.140625), + Flogc: -Float64FromFloat64(0.131576357788731), + Flogctail: float64(1.1729485484531301e-14), + }, + 44: { + Finvc: float64(1.140625), + Flogc: -Float64FromFloat64(0.131576357788731), + Flogctail: float64(1.1729485484531301e-14), + }, + 45: { + Finvc: float64(1.1328125), + Flogc: -Float64FromFloat64(0.12470347850091912), + Flogctail: -Float64FromFloat64(3.811763084710266e-14), + }, + 46: { + Finvc: float64(1.125), + Flogc: -Float64FromFloat64(0.11778303565643), + Flogctail: float64(4.654729747598445e-14), + }, + 47: { + Finvc: float64(1.125), + Flogc: -Float64FromFloat64(0.11778303565643), + Flogctail: float64(4.654729747598445e-14), + }, + 48: { + Finvc: float64(1.1171875), + Flogc: -Float64FromFloat64(0.11081436634026431), + Flogctail: -Float64FromFloat64(2.5799991283069902e-14), + }, + 49: { + Finvc: float64(1.109375), + Flogc: -Float64FromFloat64(0.10379679368168127), + Flogctail: float64(3.7700471749674615e-14), + }, + 50: { + Finvc: float64(1.109375), + Flogc: -Float64FromFloat64(0.10379679368168127), + Flogctail: float64(3.7700471749674615e-14), + }, + 51: { + Finvc: float64(1.1015625), + Flogc: -Float64FromFloat64(0.09672962645856842), + Flogctail: float64(1.7306161136093256e-14), + }, + 52: { + Finvc: float64(1.1015625), + Flogc: -Float64FromFloat64(0.09672962645856842), + Flogctail: float64(1.7306161136093256e-14), + }, + 53: { + Finvc: float64(1.09375), + Flogc: -Float64FromFloat64(0.089612158689647), + Flogctail: -Float64FromFloat64(4.012913552726574e-14), + }, + 54: { + Finvc: float64(1.0859375), + Flogc: -Float64FromFloat64(0.08244366921110213), + Flogctail: float64(2.7541708360737882e-14), + }, + 55: { + Finvc: float64(1.0859375), + Flogc: -Float64FromFloat64(0.08244366921110213), + Flogctail: float64(2.7541708360737882e-14), + }, + 56: { + Finvc: float64(1.078125), + Flogc: -Float64FromFloat64(0.07522342123763792), + Flogctail: float64(5.0396178134370583e-14), + }, + 57: { + Finvc: float64(1.078125), + Flogc: -Float64FromFloat64(0.07522342123763792), + Flogctail: float64(5.0396178134370583e-14), + }, + 58: { + Finvc: float64(1.0703125), + Flogc: -Float64FromFloat64(0.06795066190852594), + Flogctail: float64(1.8195060030168815e-14), + }, + 59: { + Finvc: float64(1.0625), + Flogc: -Float64FromFloat64(0.06062462181648698), + Flogctail: float64(5.213620639136504e-14), + }, + 60: { + Finvc: float64(1.0625), + Flogc: -Float64FromFloat64(0.06062462181648698), + Flogctail: float64(5.213620639136504e-14), + }, + 61: { + Finvc: float64(1.0546875), + Flogc: -Float64FromFloat64(0.053244514518837605), + Flogctail: float64(2.532168943117445e-14), + }, + 62: { + Finvc: float64(1.0546875), + Flogc: -Float64FromFloat64(0.053244514518837605), + Flogctail: float64(2.532168943117445e-14), + }, + 63: { + Finvc: float64(1.046875), + Flogc: -Float64FromFloat64(0.045809536031242715), + Flogctail: -Float64FromFloat64(5.148849572685811e-14), + }, + 64: { + Finvc: float64(1.046875), + Flogc: -Float64FromFloat64(0.045809536031242715), + Flogctail: -Float64FromFloat64(5.148849572685811e-14), + }, + 65: { + Finvc: float64(1.0390625), + Flogc: -Float64FromFloat64(0.038318864302141264), + Flogctail: float64(4.6652946995830086e-15), + }, + 66: { + Finvc: float64(1.0390625), + Flogc: -Float64FromFloat64(0.038318864302141264), + Flogctail: float64(4.6652946995830086e-15), + }, + 67: { + Finvc: float64(1.03125), + Flogc: -Float64FromFloat64(0.03077165866670839), + Flogctail: -Float64FromFloat64(4.529814257790929e-14), + }, + 68: { + Finvc: float64(1.03125), + Flogc: -Float64FromFloat64(0.03077165866670839), + Flogctail: -Float64FromFloat64(4.529814257790929e-14), + }, + 69: { + Finvc: float64(1.0234375), + Flogc: -Float64FromFloat64(0.023167059281490765), + Flogctail: -Float64FromFloat64(4.361324067851568e-14), + }, + 70: { + Finvc: float64(1.015625), + Flogc: -Float64FromFloat64(0.015504186535963527), + Flogctail: -Float64FromFloat64(1.7274567499706107e-15), + }, + 71: { + Finvc: float64(1.015625), + Flogc: -Float64FromFloat64(0.015504186535963527), + Flogctail: -Float64FromFloat64(1.7274567499706107e-15), + }, + 72: { + Finvc: float64(1.0078125), + Flogc: -Float64FromFloat64(0.0077821404420319595), + Flogctail: -Float64FromFloat64(2.298941004620351e-14), + }, + 73: { + Finvc: float64(1.0078125), + Flogc: -Float64FromFloat64(0.0077821404420319595), + Flogctail: -Float64FromFloat64(2.298941004620351e-14), + }, + 74: { + Finvc: float64(1), + }, + 75: { + Finvc: float64(1), + }, + 76: { + Finvc: float64(0.9921875), + Flogc: float64(0.007843177461040796), + Flogctail: -Float64FromFloat64(1.4902732911301337e-14), + }, + 77: { + Finvc: float64(0.984375), + Flogc: float64(0.01574835696817445), + Flogctail: -Float64FromFloat64(3.527980389655325e-14), + }, + 78: { + Finvc: float64(0.9765625), + Flogc: float64(0.023716526617363343), + Flogctail: -Float64FromFloat64(4.730054772033249e-14), + }, + 79: { + Finvc: float64(0.96875), + Flogc: float64(0.03174869831457272), + Flogctail: float64(7.580310369375161e-15), + }, + 80: { + Finvc: float64(0.9609375), + Flogc: float64(0.039845908547249564), + Flogctail: -Float64FromFloat64(4.9893776716773285e-14), + }, + 81: { + Finvc: float64(0.953125), + Flogc: float64(0.048009219186383234), + Flogctail: -Float64FromFloat64(2.262629393030674e-14), + }, + 82: { + Finvc: float64(0.9453125), + Flogc: float64(0.056239718322899535), + Flogctail: -Float64FromFloat64(2.345674491018699e-14), + }, + 83: { + Finvc: float64(0.94140625), + Flogc: float64(0.06038051098892083), + Flogctail: -Float64FromFloat64(1.3352588834854848e-14), + }, + 84: { + Finvc: float64(0.93359375), + Flogc: float64(0.06871389254808946), + Flogctail: -Float64FromFloat64(3.765296820388875e-14), + }, + 85: { + Finvc: float64(0.92578125), + Flogc: float64(0.07711730334438016), + Flogctail: float64(5.1128335719851986e-14), + }, + 86: { + Finvc: float64(0.91796875), + Flogc: float64(0.08559193033545398), + Flogctail: -Float64FromFloat64(5.046674438470119e-14), + }, + 87: { + Finvc: float64(0.9140625), + Flogc: float64(0.08985632912185793), + Flogctail: float64(3.1218748807418837e-15), + }, + 88: { + Finvc: float64(0.90625), + Flogc: float64(0.09844007281321865), + Flogctail: float64(3.3871241029241416e-14), + }, + 89: { + Finvc: float64(0.8984375), + Flogc: float64(0.10709813555638448), + Flogctail: -Float64FromFloat64(1.7376727386423858e-14), + }, + 90: { + Finvc: float64(0.89453125), + Flogc: float64(0.11145544092528326), + Flogctail: float64(3.957125899799804e-14), + }, + 91: { + Finvc: float64(0.88671875), + Flogc: float64(0.12022742699821265), + Flogctail: -Float64FromFloat64(5.2849453521890294e-14), + }, + 92: { + Finvc: float64(0.8828125), + Flogc: float64(0.12464244520731427), + Flogctail: -Float64FromFloat64(3.767012502308738e-14), + }, + 93: { + Finvc: float64(0.875), + Flogc: float64(0.13353139262449076), + Flogctail: float64(3.1859736349078334e-14), + }, + 94: { + Finvc: float64(0.87109375), + Flogc: float64(0.13800567301939282), + Flogctail: float64(5.0900642926060466e-14), + }, + 95: { + Finvc: float64(0.86328125), + Flogc: float64(0.14701474296180095), + Flogctail: float64(8.710783796122478e-15), + }, + 96: { + Finvc: float64(0.859375), + Flogc: float64(0.15154989812720032), + Flogctail: float64(6.157896229122976e-16), + }, + 97: { + Finvc: float64(0.8515625), + Flogc: float64(0.16068238169043525), + Flogctail: float64(3.821577743916796e-14), + }, + 98: { + Finvc: float64(0.84765625), + Flogc: float64(0.16528009093906348), + Flogctail: float64(3.9440046718453496e-14), + }, + 99: { + Finvc: float64(0.83984375), + Flogc: float64(0.17453941635187675), + Flogctail: float64(2.2924522154618074e-14), + }, + 100: { + Finvc: float64(0.8359375), + Flogc: float64(0.17920142945774842), + Flogctail: -Float64FromFloat64(3.742530094732263e-14), + }, + 101: { + Finvc: float64(0.83203125), + Flogc: float64(0.18388527877016259), + Flogctail: -Float64FromFloat64(2.5223102140407338e-14), + }, + 102: { + Finvc: float64(0.82421875), + Flogc: float64(0.1933193110035063), + Flogctail: -Float64FromFloat64(1.0320443688698849e-14), + }, + 103: { + Finvc: float64(0.8203125), + Flogc: float64(0.19806991376208316), + Flogctail: float64(1.0634128304268335e-14), + }, + 104: { + Finvc: float64(0.8125), + Flogc: float64(0.20763936477828793), + Flogctail: -Float64FromFloat64(4.3425422595242564e-14), + }, + 105: { + Finvc: float64(0.80859375), + Flogc: float64(0.21245865121420593), + Flogctail: -Float64FromFloat64(1.2527395755711364e-14), + }, + 106: { + Finvc: float64(0.8046875), + Flogc: float64(0.21730127569003344), + Flogctail: -Float64FromFloat64(5.204008743405884e-14), + }, + 107: { + Finvc: float64(0.80078125), + Flogc: float64(0.22216746534115828), + Flogctail: -Float64FromFloat64(3.979844515951702e-15), + }, + 108: { + Finvc: float64(0.79296875), + Flogc: float64(0.2319714654378231), + Flogctail: -Float64FromFloat64(4.7955860343296286e-14), + }, + 109: { + Finvc: float64(0.7890625), + Flogc: float64(0.2369097470783572), + Flogctail: float64(5.015686013791602e-16), + }, + 110: { + Finvc: float64(0.78515625), + Flogc: float64(0.24187253642048745), + Flogctail: -Float64FromFloat64(7.252318953240293e-16), + }, + 111: { + Finvc: float64(0.78125), + Flogc: float64(0.2468600779315011), + Flogctail: float64(2.4688324156011588e-14), + }, + 112: { + Finvc: float64(0.7734375), + Flogc: float64(0.2569104137850218), + Flogctail: float64(5.465121253624792e-15), + }, + 113: { + Finvc: float64(0.76953125), + Flogc: float64(0.26197371574153294), + Flogctail: float64(4.102651071698446e-14), + }, + 114: { + Finvc: float64(0.765625), + Flogc: float64(0.2670627852490952), + Flogctail: -Float64FromFloat64(4.996736502345936e-14), + }, + 115: { + Finvc: float64(0.76171875), + Flogc: float64(0.27217788591576664), + Flogctail: float64(4.903580708156347e-14), + }, + 116: { + Finvc: float64(0.7578125), + Flogc: float64(0.27731928541618345), + Flogctail: float64(5.089628039500759e-14), + }, + 117: { + Finvc: float64(0.75390625), + Flogc: float64(0.28248725557466514), + Flogctail: float64(1.1782016386565151e-14), + }, + 118: { + Finvc: float64(0.74609375), + Flogc: float64(0.29290401643288533), + Flogctail: float64(4.727452940514406e-14), + }, + 119: { + Finvc: float64(0.7421875), + Flogc: float64(0.29815337231912054), + Flogctail: -Float64FromFloat64(4.4204083338755686e-14), + }, + 120: { + Finvc: float64(0.73828125), + Flogc: float64(0.3034304294199046), + Flogctail: float64(1.548345993498083e-14), + }, + 121: { + Finvc: float64(0.734375), + Flogc: float64(0.30873548164959175), + Flogctail: float64(2.1522127491642888e-14), + }, + 122: { + Finvc: float64(0.73046875), + Flogc: float64(0.3140688276249648), + Flogctail: float64(1.1054030169005386e-14), + }, + 123: { + Finvc: float64(0.7265625), + Flogc: float64(0.31943077076641657), + Flogctail: -Float64FromFloat64(5.534326352070679e-14), + }, + 124: { + Finvc: float64(0.72265625), + Flogc: float64(0.3248216194012912), + Flogctail: -Float64FromFloat64(5.351646604259541e-14), + }, + 125: { + Finvc: float64(0.71875), + Flogc: float64(0.33024168687052224), + Flogctail: float64(5.4612144489920215e-14), + }, + 126: { + Finvc: float64(0.71484375), + Flogc: float64(0.3356912916381134), + Flogctail: float64(2.8136969901227338e-14), + }, + 127: { + Finvc: float64(0.7109375), + Flogc: float64(0.3411707574027787), + Flogctail: -Float64FromFloat64(1.156568624616423e-14), + }, + }, +} + +var X__powf_log2_data = Tpowf_log2_data{ + Ftab: [16]struct { + Finvc float64 + Flogc float64 + }{ + 0: { + Finvc: float64(1.398907162146528), + Flogc: float64(-Float64FromFloat64(0.48430022186289673) * float64(Int32FromInt32(1)<:25:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_SYS_ERRNO_H_ = 0 // errno.h:70:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2012 Apple, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)errno.h 8.5 (Berkeley) 1/21/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// Error codes + +// 11 was EAGAIN + +// math software + +// non-blocking and interrupt i/o + +// ipc/network software -- argument errors + +// ipc/network software -- operational errors + +// should be rearranged + +// quotas & mush + +// Network File System + +// Intelligent device errors + +// Program loading errors + +// This value is only discrete when compiling __DARWIN_UNIX03, or KERNEL + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/errno/errno_darwin_arm64.go b/internal/libc/errno/errno_darwin_arm64.go new file mode 100644 index 0000000..6ccecc1 --- /dev/null +++ b/internal/libc/errno/errno_darwin_arm64.go @@ -0,0 +1,680 @@ +// Code generated by 'ccgo errno/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_darwin_arm64.go -pkgname errno', DO NOT EDIT. + +package errno + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + E2BIG = 7 // errno.h:94:1: + EACCES = 13 // errno.h:101:1: + EADDRINUSE = 48 // errno.h:161:1: + EADDRNOTAVAIL = 49 // errno.h:162:1: + EAFNOSUPPORT = 47 // errno.h:160:1: + EAGAIN = 35 // errno.h:129:1: + EALREADY = 37 // errno.h:132:1: + EAUTH = 80 // errno.h:213:1: + EBADARCH = 86 // errno.h:226:1: + EBADEXEC = 85 // errno.h:225:1: + EBADF = 9 // errno.h:96:1: + EBADMACHO = 88 // errno.h:228:1: + EBADMSG = 94 // errno.h:240:1: + EBADRPC = 72 // errno.h:201:1: + EBUSY = 16 // errno.h:106:1: + ECANCELED = 89 // errno.h:231:1: + ECHILD = 10 // errno.h:97:1: + ECONNABORTED = 53 // errno.h:168:1: + ECONNREFUSED = 61 // errno.h:178:1: + ECONNRESET = 54 // errno.h:169:1: + EDEADLK = 11 // errno.h:98:1: + EDESTADDRREQ = 39 // errno.h:136:1: + EDEVERR = 83 // errno.h:218:1: + EDOM = 33 // errno.h:125:1: + EDQUOT = 69 // errno.h:195:1: + EEXIST = 17 // errno.h:107:1: + EFAULT = 14 // errno.h:102:1: + EFBIG = 27 // errno.h:117:1: + EFTYPE = 79 // errno.h:212:1: + EHOSTDOWN = 64 // errno.h:185:1: + EHOSTUNREACH = 65 // errno.h:187:1: + EIDRM = 90 // errno.h:233:1: + EILSEQ = 92 // errno.h:235:1: + EINPROGRESS = 36 // errno.h:131:1: + EINTR = 4 // errno.h:91:1: + EINVAL = 22 // errno.h:112:1: + EIO = 5 // errno.h:92:1: + EISCONN = 56 // errno.h:171:1: + EISDIR = 21 // errno.h:111:1: + ELAST = 106 // errno.h:263:1: + ELOOP = 62 // errno.h:180:1: + EMFILE = 24 // errno.h:114:1: + EMLINK = 31 // errno.h:121:1: + EMSGSIZE = 40 // errno.h:137:1: + EMULTIHOP = 95 // errno.h:241:1: + ENAMETOOLONG = 63 // errno.h:181:1: + ENEEDAUTH = 81 // errno.h:214:1: + ENETDOWN = 50 // errno.h:165:1: + ENETRESET = 52 // errno.h:167:1: + ENETUNREACH = 51 // errno.h:166:1: + ENFILE = 23 // errno.h:113:1: + ENOATTR = 93 // errno.h:237:1: + ENOBUFS = 55 // errno.h:170:1: + ENODATA = 96 // errno.h:242:1: + ENODEV = 19 // errno.h:109:1: + ENOENT = 2 // errno.h:89:1: + ENOEXEC = 8 // errno.h:95:1: + ENOLCK = 77 // errno.h:208:1: + ENOLINK = 97 // errno.h:243:1: + ENOMEM = 12 // errno.h:100:1: + ENOMSG = 91 // errno.h:234:1: + ENOPOLICY = 103 // errno.h:254:1: + ENOPROTOOPT = 42 // errno.h:139:1: + ENOSPC = 28 // errno.h:118:1: + ENOSR = 98 // errno.h:244:1: + ENOSTR = 99 // errno.h:245:1: + ENOSYS = 78 // errno.h:209:1: + ENOTBLK = 15 // errno.h:104:1: + ENOTCONN = 57 // errno.h:172:1: + ENOTDIR = 20 // errno.h:110:1: + ENOTEMPTY = 66 // errno.h:188:1: + ENOTRECOVERABLE = 104 // errno.h:257:1: + ENOTSOCK = 38 // errno.h:135:1: + ENOTSUP = 45 // errno.h:144:1: + ENOTTY = 25 // errno.h:115:1: + ENXIO = 6 // errno.h:93:1: + EOPNOTSUPP = 102 // errno.h:251:1: + EOVERFLOW = 84 // errno.h:221:1: + EOWNERDEAD = 105 // errno.h:258:1: + EPERM = 1 // errno.h:88:1: + EPFNOSUPPORT = 46 // errno.h:158:1: + EPIPE = 32 // errno.h:122:1: + EPROCLIM = 67 // errno.h:192:1: + EPROCUNAVAIL = 76 // errno.h:205:1: + EPROGMISMATCH = 75 // errno.h:204:1: + EPROGUNAVAIL = 74 // errno.h:203:1: + EPROTO = 100 // errno.h:246:1: + EPROTONOSUPPORT = 43 // errno.h:140:1: + EPROTOTYPE = 41 // errno.h:138:1: + EPWROFF = 82 // errno.h:217:1: + EQFULL = 106 // errno.h:262:1: + ERANGE = 34 // errno.h:126:1: + EREMOTE = 71 // errno.h:200:1: + EROFS = 30 // errno.h:120:1: + ERPCMISMATCH = 73 // errno.h:202:1: + ESHLIBVERS = 87 // errno.h:227:1: + ESHUTDOWN = 58 // errno.h:174:1: + ESOCKTNOSUPPORT = 44 // errno.h:142:1: + ESPIPE = 29 // errno.h:119:1: + ESRCH = 3 // errno.h:90:1: + ESTALE = 70 // errno.h:198:1: + ETIME = 101 // errno.h:247:1: + ETIMEDOUT = 60 // errno.h:177:1: + ETOOMANYREFS = 59 // errno.h:175:1: + ETXTBSY = 26 // errno.h:116:1: + EUSERS = 68 // errno.h:193:1: + EWOULDBLOCK = 35 // errno.h:130:1: + EXDEV = 18 // errno.h:108:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_SYS_ERRNO_H_ = 0 // errno.h:70:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2012 Apple, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)errno.h 8.5 (Berkeley) 1/21/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// Error codes + +// 11 was EAGAIN + +// math software + +// non-blocking and interrupt i/o + +// ipc/network software -- argument errors + +// ipc/network software -- operational errors + +// should be rearranged + +// quotas & mush + +// Network File System + +// Intelligent device errors + +// Program loading errors + +// This value is only discrete when compiling __DARWIN_UNIX03, or KERNEL + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/errno/errno_linux_amd64.go b/internal/libc/errno/errno_linux_amd64.go new file mode 100644 index 0000000..448b8d2 --- /dev/null +++ b/internal/libc/errno/errno_linux_amd64.go @@ -0,0 +1,187 @@ +// Code generated by 'ccgo errno/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_linux_amd64.go -pkgname errno', DO NOT EDIT. + +package errno + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + E2BIG = 7 // errno-base.h:11:1: + EACCES = 13 // errno-base.h:17:1: + EADDRINUSE = 98 // errno.h:81:1: + EADDRNOTAVAIL = 99 // errno.h:82:1: + EADV = 68 // errno.h:51:1: + EAFNOSUPPORT = 97 // errno.h:80:1: + EAGAIN = 11 // errno-base.h:15:1: + EALREADY = 114 // errno.h:97:1: + EBADE = 52 // errno.h:33:1: + EBADF = 9 // errno-base.h:13:1: + EBADFD = 77 // errno.h:60:1: + EBADMSG = 74 // errno.h:57:1: + EBADR = 53 // errno.h:34:1: + EBADRQC = 56 // errno.h:37:1: + EBADSLT = 57 // errno.h:38:1: + EBFONT = 59 // errno.h:42:1: + EBUSY = 16 // errno-base.h:20:1: + ECANCELED = 125 // errno.h:109:1: + ECHILD = 10 // errno-base.h:14:1: + ECHRNG = 44 // errno.h:25:1: + ECOMM = 70 // errno.h:53:1: + ECONNABORTED = 103 // errno.h:86:1: + ECONNREFUSED = 111 // errno.h:94:1: + ECONNRESET = 104 // errno.h:87:1: + EDEADLK = 35 // errno.h:7:1: + EDEADLOCK = 35 // errno.h:40:1: + EDESTADDRREQ = 89 // errno.h:72:1: + EDOM = 33 // errno-base.h:37:1: + EDOTDOT = 73 // errno.h:56:1: + EDQUOT = 122 // errno.h:105:1: + EEXIST = 17 // errno-base.h:21:1: + EFAULT = 14 // errno-base.h:18:1: + EFBIG = 27 // errno-base.h:31:1: + EHOSTDOWN = 112 // errno.h:95:1: + EHOSTUNREACH = 113 // errno.h:96:1: + EHWPOISON = 133 // errno.h:121:1: + EIDRM = 43 // errno.h:24:1: + EILSEQ = 84 // errno.h:67:1: + EINPROGRESS = 115 // errno.h:98:1: + EINTR = 4 // errno-base.h:8:1: + EINVAL = 22 // errno-base.h:26:1: + EIO = 5 // errno-base.h:9:1: + EISCONN = 106 // errno.h:89:1: + EISDIR = 21 // errno-base.h:25:1: + EISNAM = 120 // errno.h:103:1: + EKEYEXPIRED = 127 // errno.h:111:1: + EKEYREJECTED = 129 // errno.h:113:1: + EKEYREVOKED = 128 // errno.h:112:1: + EL2HLT = 51 // errno.h:32:1: + EL2NSYNC = 45 // errno.h:26:1: + EL3HLT = 46 // errno.h:27:1: + EL3RST = 47 // errno.h:28:1: + ELIBACC = 79 // errno.h:62:1: + ELIBBAD = 80 // errno.h:63:1: + ELIBEXEC = 83 // errno.h:66:1: + ELIBMAX = 82 // errno.h:65:1: + ELIBSCN = 81 // errno.h:64:1: + ELNRNG = 48 // errno.h:29:1: + ELOOP = 40 // errno.h:21:1: + EMEDIUMTYPE = 124 // errno.h:108:1: + EMFILE = 24 // errno-base.h:28:1: + EMLINK = 31 // errno-base.h:35:1: + EMSGSIZE = 90 // errno.h:73:1: + EMULTIHOP = 72 // errno.h:55:1: + ENAMETOOLONG = 36 // errno.h:8:1: + ENAVAIL = 119 // errno.h:102:1: + ENETDOWN = 100 // errno.h:83:1: + ENETRESET = 102 // errno.h:85:1: + ENETUNREACH = 101 // errno.h:84:1: + ENFILE = 23 // errno-base.h:27:1: + ENOANO = 55 // errno.h:36:1: + ENOBUFS = 105 // errno.h:88:1: + ENOCSI = 50 // errno.h:31:1: + ENODATA = 61 // errno.h:44:1: + ENODEV = 19 // errno-base.h:23:1: + ENOENT = 2 // errno-base.h:6:1: + ENOEXEC = 8 // errno-base.h:12:1: + ENOKEY = 126 // errno.h:110:1: + ENOLCK = 37 // errno.h:9:1: + ENOLINK = 67 // errno.h:50:1: + ENOMEDIUM = 123 // errno.h:107:1: + ENOMEM = 12 // errno-base.h:16:1: + ENOMSG = 42 // errno.h:23:1: + ENONET = 64 // errno.h:47:1: + ENOPKG = 65 // errno.h:48:1: + ENOPROTOOPT = 92 // errno.h:75:1: + ENOSPC = 28 // errno-base.h:32:1: + ENOSR = 63 // errno.h:46:1: + ENOSTR = 60 // errno.h:43:1: + ENOSYS = 38 // errno.h:18:1: + ENOTBLK = 15 // errno-base.h:19:1: + ENOTCONN = 107 // errno.h:90:1: + ENOTDIR = 20 // errno-base.h:24:1: + ENOTEMPTY = 39 // errno.h:20:1: + ENOTNAM = 118 // errno.h:101:1: + ENOTRECOVERABLE = 131 // errno.h:117:1: + ENOTSOCK = 88 // errno.h:71:1: + ENOTSUP = 95 // errno.h:30:1: + ENOTTY = 25 // errno-base.h:29:1: + ENOTUNIQ = 76 // errno.h:59:1: + ENXIO = 6 // errno-base.h:10:1: + EOPNOTSUPP = 95 // errno.h:78:1: + EOVERFLOW = 75 // errno.h:58:1: + EOWNERDEAD = 130 // errno.h:116:1: + EPERM = 1 // errno-base.h:5:1: + EPFNOSUPPORT = 96 // errno.h:79:1: + EPIPE = 32 // errno-base.h:36:1: + EPROTO = 71 // errno.h:54:1: + EPROTONOSUPPORT = 93 // errno.h:76:1: + EPROTOTYPE = 91 // errno.h:74:1: + ERANGE = 34 // errno-base.h:38:1: + EREMCHG = 78 // errno.h:61:1: + EREMOTE = 66 // errno.h:49:1: + EREMOTEIO = 121 // errno.h:104:1: + ERESTART = 85 // errno.h:68:1: + ERFKILL = 132 // errno.h:119:1: + EROFS = 30 // errno-base.h:34:1: + ESHUTDOWN = 108 // errno.h:91:1: + ESOCKTNOSUPPORT = 94 // errno.h:77:1: + ESPIPE = 29 // errno-base.h:33:1: + ESRCH = 3 // errno-base.h:7:1: + ESRMNT = 69 // errno.h:52:1: + ESTALE = 116 // errno.h:99:1: + ESTRPIPE = 86 // errno.h:69:1: + ETIME = 62 // errno.h:45:1: + ETIMEDOUT = 110 // errno.h:93:1: + ETOOMANYREFS = 109 // errno.h:92:1: + ETXTBSY = 26 // errno-base.h:30:1: + EUCLEAN = 117 // errno.h:100:1: + EUNATCH = 49 // errno.h:30:1: + EUSERS = 87 // errno.h:70:1: + EWOULDBLOCK = 11 // errno.h:22:1: + EXDEV = 18 // errno-base.h:22:1: + EXFULL = 54 // errno.h:35:1: + X_ASM_GENERIC_ERRNO_BASE_H = 0 // errno-base.h:3:1: + X_ASM_GENERIC_ERRNO_H = 0 // errno.h:3:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_ERRNO_H = 1 // errno.h:20:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_ERRNO_H = 1 // errno.h:23:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/errno/errno_linux_arm64.go b/internal/libc/errno/errno_linux_arm64.go new file mode 100644 index 0000000..db74062 --- /dev/null +++ b/internal/libc/errno/errno_linux_arm64.go @@ -0,0 +1,187 @@ +// Code generated by 'ccgo errno/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o errno/errno_linux_arm64.go -pkgname errno', DO NOT EDIT. + +package errno + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + E2BIG = 7 + EACCES = 13 + EADDRINUSE = 98 + EADDRNOTAVAIL = 99 + EADV = 68 + EAFNOSUPPORT = 97 + EAGAIN = 11 + EALREADY = 114 + EBADE = 52 + EBADF = 9 + EBADFD = 77 + EBADMSG = 74 + EBADR = 53 + EBADRQC = 56 + EBADSLT = 57 + EBFONT = 59 + EBUSY = 16 + ECANCELED = 125 + ECHILD = 10 + ECHRNG = 44 + ECOMM = 70 + ECONNABORTED = 103 + ECONNREFUSED = 111 + ECONNRESET = 104 + EDEADLK = 35 + EDEADLOCK = 35 + EDESTADDRREQ = 89 + EDOM = 33 + EDOTDOT = 73 + EDQUOT = 122 + EEXIST = 17 + EFAULT = 14 + EFBIG = 27 + EHOSTDOWN = 112 + EHOSTUNREACH = 113 + EHWPOISON = 133 + EIDRM = 43 + EILSEQ = 84 + EINPROGRESS = 115 + EINTR = 4 + EINVAL = 22 + EIO = 5 + EISCONN = 106 + EISDIR = 21 + EISNAM = 120 + EKEYEXPIRED = 127 + EKEYREJECTED = 129 + EKEYREVOKED = 128 + EL2HLT = 51 + EL2NSYNC = 45 + EL3HLT = 46 + EL3RST = 47 + ELIBACC = 79 + ELIBBAD = 80 + ELIBEXEC = 83 + ELIBMAX = 82 + ELIBSCN = 81 + ELNRNG = 48 + ELOOP = 40 + EMEDIUMTYPE = 124 + EMFILE = 24 + EMLINK = 31 + EMSGSIZE = 90 + EMULTIHOP = 72 + ENAMETOOLONG = 36 + ENAVAIL = 119 + ENETDOWN = 100 + ENETRESET = 102 + ENETUNREACH = 101 + ENFILE = 23 + ENOANO = 55 + ENOBUFS = 105 + ENOCSI = 50 + ENODATA = 61 + ENODEV = 19 + ENOENT = 2 + ENOEXEC = 8 + ENOKEY = 126 + ENOLCK = 37 + ENOLINK = 67 + ENOMEDIUM = 123 + ENOMEM = 12 + ENOMSG = 42 + ENONET = 64 + ENOPKG = 65 + ENOPROTOOPT = 92 + ENOSPC = 28 + ENOSR = 63 + ENOSTR = 60 + ENOSYS = 38 + ENOTBLK = 15 + ENOTCONN = 107 + ENOTDIR = 20 + ENOTEMPTY = 39 + ENOTNAM = 118 + ENOTRECOVERABLE = 131 + ENOTSOCK = 88 + ENOTSUP = 95 + ENOTTY = 25 + ENOTUNIQ = 76 + ENXIO = 6 + EOPNOTSUPP = 95 + EOVERFLOW = 75 + EOWNERDEAD = 130 + EPERM = 1 + EPFNOSUPPORT = 96 + EPIPE = 32 + EPROTO = 71 + EPROTONOSUPPORT = 93 + EPROTOTYPE = 91 + ERANGE = 34 + EREMCHG = 78 + EREMOTE = 66 + EREMOTEIO = 121 + ERESTART = 85 + ERFKILL = 132 + EROFS = 30 + ESHUTDOWN = 108 + ESOCKTNOSUPPORT = 94 + ESPIPE = 29 + ESRCH = 3 + ESRMNT = 69 + ESTALE = 116 + ESTRPIPE = 86 + ETIME = 62 + ETIMEDOUT = 110 + ETOOMANYREFS = 109 + ETXTBSY = 26 + EUCLEAN = 117 + EUNATCH = 49 + EUSERS = 87 + EWOULDBLOCK = 11 + EXDEV = 18 + EXFULL = 54 + X_ASM_GENERIC_ERRNO_BASE_H = 0 + X_ASM_GENERIC_ERRNO_H = 0 + X_ATFILE_SOURCE = 1 + X_BITS_ERRNO_H = 1 + X_DEFAULT_SOURCE = 1 + X_ERRNO_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/etc.go b/internal/libc/etc.go new file mode 100644 index 0000000..933d79a --- /dev/null +++ b/internal/libc/etc.go @@ -0,0 +1,926 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "fmt" + "io" + "os" + "path/filepath" + "reflect" + "runtime" + "sort" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc/errno" + "github.com/hanzoai/sqlite/internal/libc/signal" + "github.com/hanzoai/sqlite/internal/libc/sys/types" +) + +const ( + allocatorPageOverhead = 4 * unsafe.Sizeof(int(0)) + stackHeaderSize = unsafe.Sizeof(stackHeader{}) + stackSegmentSize = 1<<12 - allocatorPageOverhead + uintptrSize = unsafe.Sizeof(uintptr(0)) +) + +var ( + Covered = map[uintptr]struct{}{} + CoveredC = map[string]struct{}{} + fToken uintptr + tid int32 + + atExit []func() + atExitMu sync.Mutex + + signals [signal.NSIG]uintptr + signalsMu sync.Mutex + + objectMu sync.Mutex + objects = map[uintptr]interface{}{} + + tlsBalance int32 + + _ = origin + _ = trc +) + +func init() { + if n := stackHeaderSize; n%16 != 0 { + panic(fmt.Errorf("internal error: stackHeaderSize %v == %v (mod 16)", n, n%16)) + } +} + +func origin(skip int) string { + pc, fn, fl, _ := runtime.Caller(skip) + f := runtime.FuncForPC(pc) + var fns string + if f != nil { + fns = f.Name() + if x := strings.LastIndex(fns, "."); x > 0 { + fns = fns[x+1:] + } + } + return fmt.Sprintf("%s:%d:%s", filepath.Base(fn), fl, fns) +} + +func trc(s string, args ...interface{}) string { //TODO- + switch { + case s == "": + s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...) + default: + s = fmt.Sprintf(s, args...) + } + r := fmt.Sprintf("%s: TRC %s", origin(2), s) + fmt.Fprintf(os.Stdout, "%s\n", r) + os.Stdout.Sync() + return r +} + +func todo(s string, args ...interface{}) string { //TODO- + switch { + case s == "": + s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...) + default: + s = fmt.Sprintf(s, args...) + } + r := fmt.Sprintf("%s: TODOTODO %s", origin(2), s) //TODOOK + if dmesgs { + dmesg("%s", r) + } + fmt.Fprintf(os.Stdout, "%s\n", r) + os.Stdout.Sync() + os.Exit(1) + panic("unrechable") +} + +var coverPCs [1]uintptr //TODO not concurrent safe + +func Cover() { + runtime.Callers(2, coverPCs[:]) + Covered[coverPCs[0]] = struct{}{} +} + +func CoverReport(w io.Writer) error { + var a []string + pcs := make([]uintptr, 1) + for pc := range Covered { + pcs[0] = pc + frame, _ := runtime.CallersFrames(pcs).Next() + a = append(a, fmt.Sprintf("%s:%07d:%s", filepath.Base(frame.File), frame.Line, frame.Func.Name())) + } + sort.Strings(a) + _, err := fmt.Fprintf(w, "%s\n", strings.Join(a, "\n")) + return err +} + +func CoverC(s string) { + CoveredC[s] = struct{}{} +} + +func CoverCReport(w io.Writer) error { + var a []string + for k := range CoveredC { + a = append(a, k) + } + sort.Strings(a) + _, err := fmt.Fprintf(w, "%s\n", strings.Join(a, "\n")) + return err +} + +func token() uintptr { return atomic.AddUintptr(&fToken, 1) } + +func addObject(o interface{}) uintptr { + t := token() + objectMu.Lock() + objects[t] = o + objectMu.Unlock() + return t +} + +func getObject(t uintptr) interface{} { + objectMu.Lock() + defer objectMu.Unlock() + o := objects[t] + if o == nil { + panic(todo("", t)) + } + + return o +} + +func removeObject(t uintptr) { + objectMu.Lock() + defer objectMu.Unlock() + if _, ok := objects[t]; !ok { + panic(todo("")) + } + + delete(objects, t) +} + +func (t *TLS) setErrno(err interface{}) { + if t == nil { + panic("nil TLS") + } + + if memgrind { + if atomic.SwapInt32(&t.reentryGuard, 1) != 0 { + panic(todo("concurrent use of TLS instance %p", t)) + } + + defer func() { + if atomic.SwapInt32(&t.reentryGuard, 0) != 1 { + panic(todo("concurrent use of TLS instance %p", t)) + } + }() + } + // if dmesgs { + // dmesg("%v: %T(%v)\n%s", origin(1), err, err, debug.Stack()) + // } +again: + switch x := err.(type) { + case int: + *(*int32)(unsafe.Pointer(t.errnop)) = int32(x) + case int32: + *(*int32)(unsafe.Pointer(t.errnop)) = x + case *os.PathError: + err = x.Err + goto again + case syscallErrno: + *(*int32)(unsafe.Pointer(t.errnop)) = int32(x) + case *os.SyscallError: + err = x.Err + goto again + default: + panic(todo("%T", x)) + } +} + +// Close frees the resources of t. +func (t *TLS) Close() { + t.Free(int(unsafe.Sizeof(int32(0)))) + if memgrind { + if t.stackHeaderBalance != 0 { + panic(todo("non zero stack header balance: %d", t.stackHeaderBalance)) + } + + atomic.AddInt32(&tlsBalance, -1) + } + t.pthreadData.close(t) + *t = TLS{} +} + +// Alloc allocates n bytes of thread-local storage. It must be paired with a +// call to t.Free(n), using the same n. The order matters. This is ok: +// +// t.Alloc(11) +// t.Alloc(22) +// t.Free(22) +// t.Free(11) +// +// This is not correct: +// +// t.Alloc(11) +// t.Alloc(22) +// t.Free(11) +// t.Free(22) +func (t *TLS) Alloc(n int) (r uintptr) { + t.sp++ + if memgrind { + if atomic.SwapInt32(&t.reentryGuard, 1) != 0 { + panic(todo("concurrent use of TLS instance %p", t)) + } + + defer func() { + if atomic.SwapInt32(&t.reentryGuard, 0) != 1 { + panic(todo("concurrent use of TLS instance %p", t)) + } + }() + } + n += 15 + n &^= 15 + if t.stack.free >= n { + r = t.stack.sp + t.stack.free -= n + t.stack.sp += uintptr(n) + return r + } + //if we have a next stack + if nstack := t.stack.next; nstack != 0 { + if (*stackHeader)(unsafe.Pointer(nstack)).free >= n { + *(*stackHeader)(unsafe.Pointer(t.stack.page)) = t.stack + t.stack = *(*stackHeader)(unsafe.Pointer(nstack)) + r = t.stack.sp + t.stack.free -= n + t.stack.sp += uintptr(n) + return r + } + nstack := *(*stackHeader)(unsafe.Pointer(t.stack.next)) + for ; ; nstack = *(*stackHeader)(unsafe.Pointer(nstack.next)) { + if memgrind { + if atomic.AddInt32(&t.stackHeaderBalance, -1) < 0 { + panic(todo("negative stack header balance")) + } + } + Xfree(t, nstack.page) + if nstack.next == 0 { + break + } + } + t.stack.next = 0 + } + + if t.stack.page != 0 { + *(*stackHeader)(unsafe.Pointer(t.stack.page)) = t.stack + } + + rq := n + int(stackHeaderSize) + if rq%int(stackSegmentSize) != 0 { + rq -= rq % int(stackSegmentSize) + rq += int(stackSegmentSize) + } + t.stack.free = rq - int(stackHeaderSize) + t.stack.prev = t.stack.page + + rq += 15 + rq &^= 15 + t.stack.page = Xmalloc(t, types.Size_t(rq)) + if t.stack.page == 0 { + panic("OOM") + } + + if memgrind { + atomic.AddInt32(&t.stackHeaderBalance, 1) + } + t.stack.sp = t.stack.page + stackHeaderSize + + r = t.stack.sp + t.stack.free -= n + t.stack.sp += uintptr(n) + if t.stack.prev != 0 { + (*stackHeader)(unsafe.Pointer(t.stack.prev)).next = t.stack.page + } + + return r +} + +// this declares how many stack frames are kept alive before being freed +const stackFrameKeepalive = 2 + +// Free deallocates n bytes of thread-local storage. See TLS.Alloc for details +// on correct usage. +func (t *TLS) Free(n int) { + t.sp-- + if memgrind { + if atomic.SwapInt32(&t.reentryGuard, 1) != 0 { + panic(todo("concurrent use of TLS instance %p", t)) + } + + defer func() { + if atomic.SwapInt32(&t.reentryGuard, 0) != 1 { + panic(todo("concurrent use of TLS instance %p", t)) + } + }() + } + n += 15 + n &^= 15 + t.stack.free += n + t.stack.sp -= uintptr(n) + if t.stack.sp != t.stack.page+stackHeaderSize { + return + } + + nstack := t.stack + + //if we are the first one, just free all of them + if t.stack.prev == 0 { + for ; ; nstack = *(*stackHeader)(unsafe.Pointer(nstack.next)) { + if memgrind { + if atomic.AddInt32(&t.stackHeaderBalance, -1) < 0 { + panic(todo("negative stack header balance")) + } + } + Xfree(t, nstack.page) + if nstack.next == 0 { + break + } + } + t.stack = stackHeader{} + return + } + + //look if we are in the last n stackframes (n=stackFrameKeepalive) + //if we find something just return and set the current stack pointer to the previous one + for i := 0; i < stackFrameKeepalive; i++ { + if nstack.next == 0 { + *((*stackHeader)(unsafe.Pointer(t.stack.page))) = t.stack + t.stack = *(*stackHeader)(unsafe.Pointer(t.stack.prev)) + return + } + nstack = *(*stackHeader)(unsafe.Pointer(nstack.next)) + } + + //else only free the last + if memgrind { + if atomic.AddInt32(&t.stackHeaderBalance, -1) < 0 { + panic(todo("negative stack header balance")) + } + } + Xfree(t, nstack.page) + (*stackHeader)(unsafe.Pointer(nstack.prev)).next = 0 + *(*stackHeader)(unsafe.Pointer(t.stack.page)) = t.stack + t.stack = *(*stackHeader)(unsafe.Pointer(t.stack.prev)) +} + +type stackHeader struct { + free int // bytes left in page + page uintptr // stack page + prev uintptr // prev stack page = prev stack header + next uintptr // next stack page = next stack header + sp uintptr // next allocation address + _ stackHeaderPadding +} + +func cString(t *TLS, s string) uintptr { //TODO- + n := len(s) + p := Xmalloc(t, types.Size_t(n)+1) + if p == 0 { + panic("OOM") + } + + copy((*RawMem)(unsafe.Pointer(p))[:n:n], s) + *(*byte)(unsafe.Pointer(p + uintptr(n))) = 0 + return p +} + +// VaList fills a varargs list at p with args and returns p. The list must +// have been allocated by caller and it must not be in Go managed memory, ie. +// it must be pinned. Caller is responsible for freeing the list. +// +// Individual arguments must be one of int, uint, int32, uint32, int64, uint64, +// float64, uintptr or Intptr. Other types will panic. +// +// This function supports code generated by ccgo/v3. For manually constructed +// var args it's recommended to use the NewVaList function instead. +// +// Note: The C translated to Go varargs ABI alignment for all types is 8 on all +// architectures. +func VaList(p uintptr, args ...interface{}) (r uintptr) { + if p&7 != 0 { + panic("internal error") + } + + r = p + for _, v := range args { + switch x := v.(type) { + case int: + *(*int64)(unsafe.Pointer(p)) = int64(x) + case int32: + *(*int64)(unsafe.Pointer(p)) = int64(x) + case int64: + *(*int64)(unsafe.Pointer(p)) = x + case uint: + *(*uint64)(unsafe.Pointer(p)) = uint64(x) + case uint16: + *(*uint64)(unsafe.Pointer(p)) = uint64(x) + case uint32: + *(*uint64)(unsafe.Pointer(p)) = uint64(x) + case uint64: + *(*uint64)(unsafe.Pointer(p)) = x + case float64: + *(*float64)(unsafe.Pointer(p)) = x + case uintptr: + *(*uintptr)(unsafe.Pointer(p)) = x + default: + sz := reflect.TypeOf(v).Size() + copy(unsafe.Slice((*byte)(unsafe.Pointer(p)), sz), unsafe.Slice((*byte)(unsafe.Pointer((*[2]uintptr)(unsafe.Pointer(&v))[1])), sz)) + p += roundup(sz, 8) + continue + } + p += 8 + } + return r +} + +// NewVaListN returns a newly allocated va_list for n items. The caller of +// NewVaListN is responsible for freeing the va_list. +func NewVaListN(n int) (va_list uintptr) { + return Xmalloc(nil, types.Size_t(8*n)) +} + +// NewVaList is like VaList but automatically allocates the correct amount of +// memory for all of the items in args. +// +// The va_list return value is used to pass the constructed var args to var +// args accepting functions. The caller of NewVaList is responsible for freeing +// the va_list. +func NewVaList(args ...interface{}) (va_list uintptr) { + return VaList(NewVaListN(len(args)), args...) +} + +func VaOther(app *uintptr, sz uint64) (r uintptr) { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + r = ap + ap = roundup(ap+uintptr(sz), 8) + *(*uintptr)(unsafe.Pointer(app)) = ap + return r +} + +func VaInt32(app *uintptr) int32 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := int32(*(*int64)(unsafe.Pointer(ap))) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaUint32(app *uintptr) uint32 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := uint32(*(*uint64)(unsafe.Pointer(ap))) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaInt64(app *uintptr) int64 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*int64)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaUint64(app *uintptr) uint64 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*uint64)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaFloat32(app *uintptr) float32 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*float64)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return float32(v) +} + +func VaFloat64(app *uintptr) float64 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*float64)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaUintptr(app *uintptr) uintptr { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*uintptr)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func getVaList(va uintptr) []string { + r := []string{} + + for p := va; ; p += 8 { + st := *(*uintptr)(unsafe.Pointer(p)) + if st == 0 { + return r + } + r = append(r, GoString(st)) + } + return r +} + +func roundup(n, to uintptr) uintptr { + if r := n % to; r != 0 { + return n + to - r + } + + return n +} + +func Bool(v bool) bool { return v } + +func Bool32(b bool) int32 { + if b { + return 1 + } + + return 0 +} + +func Bool64(b bool) int64 { + if b { + return 1 + } + + return 0 +} + +type sorter struct { + len int + base uintptr + sz uintptr + f func(*TLS, uintptr, uintptr) int32 + t *TLS +} + +func (s *sorter) Len() int { return s.len } + +func (s *sorter) Less(i, j int) bool { + return s.f(s.t, s.base+uintptr(i)*s.sz, s.base+uintptr(j)*s.sz) < 0 +} + +func (s *sorter) Swap(i, j int) { + p := uintptr(s.base + uintptr(i)*s.sz) + q := uintptr(s.base + uintptr(j)*s.sz) + for i := 0; i < int(s.sz); i++ { + *(*byte)(unsafe.Pointer(p)), *(*byte)(unsafe.Pointer(q)) = *(*byte)(unsafe.Pointer(q)), *(*byte)(unsafe.Pointer(p)) + p++ + q++ + } +} + +func CString(s string) (uintptr, error) { + n := len(s) + p := Xmalloc(nil, types.Size_t(n)+1) + if p == 0 { + return 0, fmt.Errorf("CString: cannot allocate %d bytes", n+1) + } + + copy((*RawMem)(unsafe.Pointer(p))[:n:n], s) + *(*byte)(unsafe.Pointer(p + uintptr(n))) = 0 + return p, nil +} + +func GetEnviron() (r []string) { + for p := Environ(); ; p += unsafe.Sizeof(p) { + q := *(*uintptr)(unsafe.Pointer(p)) + if q == 0 { + return r + } + + r = append(r, GoString(q)) + } +} + +func strToUint64(t *TLS, s uintptr, base int32) (seenDigits, neg bool, next uintptr, n uint64, err int32) { + var c byte +out: + for { + c = *(*byte)(unsafe.Pointer(s)) + switch c { + case ' ', '\t', '\n', '\r', '\v', '\f': + s++ + case '+': + s++ + break out + case '-': + s++ + neg = true + break out + default: + break out + } + } + for { + c = *(*byte)(unsafe.Pointer(s)) + var digit uint64 + switch base { + case 10: + switch { + case c >= '0' && c <= '9': + seenDigits = true + digit = uint64(c) - '0' + default: + return seenDigits, neg, s, n, 0 + } + case 16: + if c >= 'A' && c <= 'F' { + c = c + ('a' - 'A') + } + switch { + case c >= '0' && c <= '9': + seenDigits = true + digit = uint64(c) - '0' + case c >= 'a' && c <= 'f': + seenDigits = true + digit = uint64(c) - 'a' + 10 + default: + return seenDigits, neg, s, n, 0 + } + default: + panic(todo("", base)) + } + n0 := n + n = uint64(base)*n + digit + if n < n0 { // overflow + return seenDigits, neg, s, n0, errno.ERANGE + } + + s++ + } +} + +func strToFloatt64(t *TLS, s uintptr, bits int) (n float64, errno int32) { + var b []byte + var neg bool + + defer func() { + var err error + if n, err = strconv.ParseFloat(string(b), bits); err != nil { + panic(todo("")) + } + + if neg { + n = -n + } + }() + + var c byte +out: + for { + c = *(*byte)(unsafe.Pointer(s)) + switch c { + case ' ', '\t', '\n', '\r', '\v', '\f': + s++ + case '+': + s++ + break out + case '-': + s++ + neg = true + break out + default: + break out + } + } + for { + c = *(*byte)(unsafe.Pointer(s)) + switch { + case c >= '0' && c <= '9': + b = append(b, c) + case c == '.': + b = append(b, c) + s++ + for { + c = *(*byte)(unsafe.Pointer(s)) + switch { + case c >= '0' && c <= '9': + b = append(b, c) + case c == 'e' || c == 'E': + b = append(b, c) + s++ + for { + c = *(*byte)(unsafe.Pointer(s)) + switch { + case c == '+' || c == '-': + b = append(b, c) + s++ + for { + c = *(*byte)(unsafe.Pointer(s)) + switch { + case c >= '0' && c <= '9': + b = append(b, c) + default: + return + } + + s++ + } + default: + panic(todo("%q %q", b, string(c))) + } + } + default: + return + } + + s++ + } + default: + panic(todo("%q %q", b, string(c))) + } + + s++ + } +} + +func parseZone(s string) (name string, off int) { + _, name, off, _ = parseZoneOffset(s, false) + return name, off +} + +func parseZoneOffset(s string, offOpt bool) (string, string, int, bool) { + s0 := s + name := s + for len(s) != 0 { + switch c := s[0]; { + case c >= 'A' && c <= 'Z', c >= 'a' && c <= 'z', c == '_', c == '/': + s = s[1:] + default: + name = name[:len(name)-len(s)] + if len(name) < 3 { + panic(todo("%q", s0)) + } + + if offOpt { + if len(s) == 0 { + return "", name, 0, false + } + + if c := s[0]; (c < '0' || c > '9') && c != '+' && c != '-' { + return s, name, 0, false + } + } + + s, off := parseOffset(s) + return s, name, off, true + } + } + return "", s0, 0, true +} + +// [+|-]hh[:mm[:ss]] +func parseOffset(s string) (string, int) { + if len(s) == 0 { + panic(todo("")) + } + + k := 1 + switch s[0] { + case '+': + // nop + s = s[1:] + case '-': + k = -1 + s = s[1:] + } + s, hh, ok := parseUint(s) + if !ok { + panic(todo("")) + } + + n := hh * 3600 + if len(s) == 0 || s[0] != ':' { + return s, k * n + } + + s = s[1:] // ':' + if len(s) == 0 { + panic(todo("")) + } + + s, mm, ok := parseUint(s) + if !ok { + panic(todo("")) + } + + n += mm * 60 + if len(s) == 0 || s[0] != ':' { + return s, k * n + } + + s = s[1:] // ':' + if len(s) == 0 { + panic(todo("")) + } + + s, ss, _ := parseUint(s) + return s, k * (n + ss) +} + +func parseUint(s string) (string, int, bool) { + var ok bool + var r int + for len(s) != 0 { + switch c := s[0]; { + case c >= '0' && c <= '9': + ok = true + r0 := r + r = 10*r + int(c) - '0' + if r < r0 { + panic(todo("")) + } + + s = s[1:] + default: + return s, r, ok + } + } + return s, r, ok +} + +// https://stackoverflow.com/a/53052382 +// +// isTimeDST returns true if time t occurs within daylight saving time +// for its time zone. +func isTimeDST(t time.Time) bool { + // If the most recent (within the last year) clock change + // was forward then assume the change was from std to dst. + hh, mm, _ := t.UTC().Clock() + tClock := hh*60 + mm + for m := -1; m > -12; m-- { + // assume dst lasts for at least one month + hh, mm, _ := t.AddDate(0, m, 0).UTC().Clock() + clock := hh*60 + mm + if clock != tClock { + return clock > tClock + } + } + // assume no dst + return false +} diff --git a/internal/libc/etc_musl.go b/internal/libc/etc_musl.go new file mode 100644 index 0000000..33b49fe --- /dev/null +++ b/internal/libc/etc_musl.go @@ -0,0 +1,69 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "fmt" + "os" + "path/filepath" + "runtime" + "strings" +) + +// origin returns caller's short position, skipping skip frames. +func origin(skip int) string { + pc, fn, fl, _ := runtime.Caller(skip) + f := runtime.FuncForPC(pc) + var fns string + if f != nil { + fns = f.Name() + if x := strings.LastIndex(fns, "."); x > 0 { + fns = fns[x+1:] + } + if strings.HasPrefix(fns, "func") { + num := true + for _, c := range fns[len("func"):] { + if c < '0' || c > '9' { + num = false + break + } + } + if num { + return origin(skip + 2) + } + } + } + return fmt.Sprintf("%s:%d:%s", filepath.Base(fn), fl, fns) +} + +// todo prints and return caller's position and an optional message tagged with TODO. Output goes to stderr. +func todo(s string, args ...interface{}) string { + switch { + case s == "": + s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...) + default: + s = fmt.Sprintf(s, args...) + } + r := fmt.Sprintf("%s\n\tTODO %s", origin(2), s) + // fmt.Fprintf(os.Stderr, "%s\n", r) + // os.Stdout.Sync() + return r +} + +// trc prints and return caller's position and an optional message tagged with TRC. Output goes to stderr. +func trc(s string, args ...interface{}) string { + switch { + case s == "": + s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...) + default: + s = fmt.Sprintf(s, args...) + } + r := fmt.Sprintf("%s: TRC %s", origin(2), s) + fmt.Fprintf(os.Stderr, "%s\n", r) + os.Stderr.Sync() + return r +} diff --git a/internal/libc/fcntl/capi_darwin_amd64.go b/internal/libc/fcntl/capi_darwin_amd64.go new file mode 100644 index 0000000..768a82a --- /dev/null +++ b/internal/libc/fcntl/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo fcntl/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_darwin_amd64.go -pkgname fcntl', DO NOT EDIT. + +package fcntl + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/fcntl/capi_darwin_arm64.go b/internal/libc/fcntl/capi_darwin_arm64.go new file mode 100644 index 0000000..ebab11f --- /dev/null +++ b/internal/libc/fcntl/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo fcntl/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_darwin_arm64.go -pkgname fcntl', DO NOT EDIT. + +package fcntl + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/fcntl/capi_linux_amd64.go b/internal/libc/fcntl/capi_linux_amd64.go new file mode 100644 index 0000000..9db297f --- /dev/null +++ b/internal/libc/fcntl/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo fcntl/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_linux_amd64.go -pkgname fcntl', DO NOT EDIT. + +package fcntl + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/fcntl/capi_linux_arm64.go b/internal/libc/fcntl/capi_linux_arm64.go new file mode 100644 index 0000000..d898698 --- /dev/null +++ b/internal/libc/fcntl/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo fcntl/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o fcntl/fcntl_linux_arm64.go -pkgname fcntl', DO NOT EDIT. + +package fcntl + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/fcntl/fcntl_darwin_amd64.go b/internal/libc/fcntl/fcntl_darwin_amd64.go new file mode 100644 index 0000000..c3c357a --- /dev/null +++ b/internal/libc/fcntl/fcntl_darwin_amd64.go @@ -0,0 +1,2064 @@ +// Code generated by 'ccgo fcntl/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_darwin_amd64.go -pkgname fcntl', DO NOT EDIT. + +package fcntl + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AT_EACCESS = 0x0010 // fcntl.h:138:1: + AT_FDCWD = -2 // fcntl.h:133:1: + AT_FDONLY = 0x0400 // fcntl.h:144:1: + AT_REALDEV = 0x0200 // fcntl.h:143:1: + AT_REMOVEDIR = 0x0080 // fcntl.h:141:1: + AT_SYMLINK_FOLLOW = 0x0040 // fcntl.h:140:1: + AT_SYMLINK_NOFOLLOW = 0x0020 // fcntl.h:139:1: + CPF_IGNORE_MODE = 0x0002 // fcntl.h:201:1: + CPF_MASK = 3 // fcntl.h:202:1: + CPF_OVERWRITE = 0x0001 // fcntl.h:200:1: + FAPPEND = 8 // fcntl.h:186:1: + FASYNC = 64 // fcntl.h:187:1: + FCNTL_FS_SPECIFIC_BASE = 0x00010000 // fcntl.h:297:1: + FD_CLOEXEC = 1 // fcntl.h:306:1: + FFDSYNC = 4194304 // fcntl.h:189:1: + FFSYNC = 128 // fcntl.h:188:1: + FNDELAY = 4 // fcntl.h:191:1: + FNONBLOCK = 4 // fcntl.h:190:1: + FREAD = 0x0001 // fcntl.h:110:1: + FWRITE = 0x0002 // fcntl.h:111:1: + F_ADDFILESIGS = 61 // fcntl.h:246:1: + F_ADDFILESIGS_FOR_DYLD_SIM = 83 // fcntl.h:279:1: + F_ADDFILESIGS_RETURN = 97 // fcntl.h:285:1: + F_ADDSIGS = 59 // fcntl.h:243:1: + F_ALLOCATEALL = 0x00000004 // fcntl.h:330:1: + F_ALLOCATECONTIG = 0x00000002 // fcntl.h:329:1: + F_BARRIERFSYNC = 85 // fcntl.h:282:1: + F_CHECK_LV = 98 // fcntl.h:286:1: + F_CHKCLEAN = 41 // fcntl.h:225:1: + F_DUPFD = 0 // fcntl.h:210:1: + F_DUPFD_CLOEXEC = 67 // fcntl.h:302:1: + F_FINDSIGS = 78 // fcntl.h:276:1: + F_FLUSH_DATA = 40 // fcntl.h:224:1: + F_FREEZE_FS = 53 // fcntl.h:238:1: + F_FULLFSYNC = 51 // fcntl.h:236:1: + F_GETCODEDIR = 72 // fcntl.h:264:1: + F_GETFD = 1 // fcntl.h:211:1: + F_GETFL = 3 // fcntl.h:213:1: + F_GETLK = 7 // fcntl.h:217:1: + F_GETLKPID = 66 // fcntl.h:256:1: + F_GETNOSIGPIPE = 74 // fcntl.h:267:1: + F_GETOWN = 5 // fcntl.h:215:1: + F_GETPATH = 50 // fcntl.h:235:1: + F_GETPATH_MTMINFO = 71 // fcntl.h:262:1: + F_GETPATH_NOFIRMLINK = 102 // fcntl.h:294:1: + F_GETPROTECTIONCLASS = 63 // fcntl.h:251:1: + F_GETPROTECTIONLEVEL = 77 // fcntl.h:274:1: + F_GLOBAL_NOCACHE = 55 // fcntl.h:240:1: + F_LOG2PHYS = 49 // fcntl.h:234:1: + F_LOG2PHYS_EXT = 65 // fcntl.h:254:1: + F_NOCACHE = 48 // fcntl.h:233:1: + F_NODIRECT = 62 // fcntl.h:248:1: + F_PATHPKG_CHECK = 52 // fcntl.h:237:1: + F_PEOFPOSMODE = 3 // fcntl.h:334:1: + F_PREALLOCATE = 42 // fcntl.h:226:1: + F_PUNCHHOLE = 99 // fcntl.h:288:1: + F_RDADVISE = 44 // fcntl.h:228:1: + F_RDAHEAD = 45 // fcntl.h:229:1: + F_RDLCK = 1 // fcntl.h:309:1: + F_SETBACKINGSTORE = 70 // fcntl.h:261:1: + F_SETFD = 2 // fcntl.h:212:1: + F_SETFL = 4 // fcntl.h:214:1: + F_SETLK = 8 // fcntl.h:218:1: + F_SETLKW = 9 // fcntl.h:219:1: + F_SETLKWTIMEOUT = 10 // fcntl.h:221:1: + F_SETNOSIGPIPE = 73 // fcntl.h:266:1: + F_SETOWN = 6 // fcntl.h:216:1: + F_SETPROTECTIONCLASS = 64 // fcntl.h:252:1: + F_SETSIZE = 43 // fcntl.h:227:1: + F_SINGLE_WRITER = 76 // fcntl.h:271:1: + F_SPECULATIVE_READ = 101 // fcntl.h:292:1: + F_THAW_FS = 54 // fcntl.h:239:1: + F_TRANSCODEKEY = 75 // fcntl.h:269:1: + F_TRIM_ACTIVE_FILE = 100 // fcntl.h:290:1: + F_UNLCK = 2 // fcntl.h:310:1: + F_VOLPOSMODE = 4 // fcntl.h:336:1: + F_WRLCK = 3 // fcntl.h:311:1: + LOCK_EX = 0x02 // fcntl.h:421:1: + LOCK_NB = 0x04 // fcntl.h:422:1: + LOCK_SH = 0x01 // fcntl.h:420:1: + LOCK_UN = 0x08 // fcntl.h:423:1: + O_ACCMODE = 0x0003 // fcntl.h:99:1: + O_ALERT = 0x20000000 // fcntl.h:502:1: + O_APPEND = 0x0008 // fcntl.h:114:1: + O_ASYNC = 0x0040 // fcntl.h:121:1: + O_CLOEXEC = 0x1000000 // fcntl.h:165:1: + O_CREAT = 0x0200 // fcntl.h:125:1: + O_DIRECTORY = 0x100000 // fcntl.h:157:1: + O_DP_GETRAWENCRYPTED = 0x0001 // fcntl.h:174:1: + O_DP_GETRAWUNENCRYPTED = 0x0002 // fcntl.h:175:1: + O_DSYNC = 0x400000 // _o_dsync.h:29:1: + O_EVTONLY = 0x8000 // fcntl.h:149:1: + O_EXCL = 0x0800 // fcntl.h:127:1: + O_EXLOCK = 0x0020 // fcntl.h:120:1: + O_FSYNC = 128 // fcntl.h:122:1: + O_NDELAY = 4 // fcntl.h:192:1: + O_NOCTTY = 0x20000 // fcntl.h:153:1: + O_NOFOLLOW = 0x0100 // fcntl.h:123:1: + O_NONBLOCK = 0x0004 // fcntl.h:113:1: + O_POPUP = 0x80000000 // fcntl.h:501:1: + O_RDONLY = 0x0000 // fcntl.h:96:1: + O_RDWR = 0x0002 // fcntl.h:98:1: + O_SHLOCK = 0x0010 // fcntl.h:119:1: + O_SYMLINK = 0x200000 // fcntl.h:158:1: + O_SYNC = 0x0080 // _o_sync.h:29:1: + O_TRUNC = 0x0400 // fcntl.h:126:1: + O_WRONLY = 0x0001 // fcntl.h:97:1: + SEEK_CUR = 1 // _seek_set.h:34:1: + SEEK_DATA = 4 // _seek_set.h:44:1: + SEEK_END = 2 // _seek_set.h:35:1: + SEEK_HOLE = 3 // _seek_set.h:40:1: + SEEK_SET = 0 // _seek_set.h:33:1: + S_IEXEC = 64 // _s_ifmt.h:72:1: + S_IFBLK = 0060000 // _s_ifmt.h:39:1: + S_IFCHR = 0020000 // _s_ifmt.h:37:1: + S_IFDIR = 0040000 // _s_ifmt.h:38:1: + S_IFIFO = 0010000 // _s_ifmt.h:36:1: + S_IFLNK = 0120000 // _s_ifmt.h:41:1: + S_IFMT = 0170000 // _s_ifmt.h:35:1: + S_IFREG = 0100000 // _s_ifmt.h:40:1: + S_IFSOCK = 0140000 // _s_ifmt.h:42:1: + S_IFWHT = 0160000 // _s_ifmt.h:44:1: + S_IREAD = 256 // _s_ifmt.h:70:1: + S_IRGRP = 0000040 // _s_ifmt.h:55:1: + S_IROTH = 0000004 // _s_ifmt.h:60:1: + S_IRUSR = 0000400 // _s_ifmt.h:50:1: + S_IRWXG = 0000070 // _s_ifmt.h:54:1: + S_IRWXO = 0000007 // _s_ifmt.h:59:1: + S_IRWXU = 0000700 // _s_ifmt.h:49:1: + S_ISGID = 0002000 // _s_ifmt.h:65:1: + S_ISTXT = 512 // _s_ifmt.h:69:1: + S_ISUID = 0004000 // _s_ifmt.h:64:1: + S_ISVTX = 0001000 // _s_ifmt.h:66:1: + S_IWGRP = 0000020 // _s_ifmt.h:56:1: + S_IWOTH = 0000002 // _s_ifmt.h:61:1: + S_IWRITE = 128 // _s_ifmt.h:71:1: + S_IWUSR = 0000200 // _s_ifmt.h:51:1: + S_IXGRP = 0000010 // _s_ifmt.h:57:1: + S_IXOTH = 0000001 // _s_ifmt.h:62:1: + S_IXUSR = 0000100 // _s_ifmt.h:52:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILESEC_T = 0 // _filesec_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS_FCNTL_H_ = 0 // fcntl.h:71:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +const ( /* fcntl.h:512:1: */ + FILESEC_OWNER = 1 + FILESEC_GROUP = 2 + FILESEC_UUID = 3 + FILESEC_MODE = 4 + FILESEC_ACL = 5 + FILESEC_GRPUUID = 6 + + // XXX these are private to the implementation + FILESEC_ACL_RAW = 100 + FILESEC_ACL_ALLOCSIZE = 101 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1983, 1990, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)fcntl.h 8.3 (Berkeley) 1/21/94 + +// This file includes the definitions for open and fcntl +// described by POSIX for ; it also includes +// related kernel definitions. +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ + +// File status flags: these are used by open(2), fcntl(2). +// They are also used (indirectly) in the kernel file structure f_flags, +// which is a superset of the open/fcntl flags. Open flags and f_flags +// are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). +// Open/fcntl flags begin with O_; kernel-internal flags begin with F. +// open-only flags + +// Kernel encoding of open mode; separate read and write bits that are +// independently testable: 1 greater than the above. +// +// XXX +// FREAD and FWRITE are excluded from the #ifdef KERNEL so that TIOCFLUSH, +// which was documented to use FREAD/FWRITE, continues to work. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Descriptor value for the current working directory + +// Flags for the at functions + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Data Protection Flags + +// The O_* flags used to have only F* names, which were used in the kernel +// and by fcntl. We retain the F* names for the kernel f_flags field +// and for backward compatibility for fcntl. + +// Flags used for copyfile(2) + +// Constants used for fcntl(2) + +// command values +// 46,47 used to be F_READBOOTSTRAP and F_WRITEBOOTSTRAP + +// should not be used (i.e. its ok to temporaily create cached pages) + +// See F_DUPFD_CLOEXEC below for 67 + +// may be broken into smaller chunks with throttling in between + +// FS-specific fcntl()'s numbers begin at 0x00010000 and go up + +// file descriptor flags (F_GETFD, F_SETFD) + +// record locking flags (F_GETLK, F_SETLK, F_SETLKW) + +// [XSI] The values used for l_whence shall be defined as described +// in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// whence values for lseek(2) + +// [XSI] The symbolic names for file modes for use as values of mode_t +// shall be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The symbolic names for file modes for use as values of mode_t +// shall be defined as described in +// File type + +// File mode +// Read, write, execute/search by owner +// Read, write, execute/search by group +// Read, write, execute/search by others + +// allocate flags (F_PREALLOCATE) + +// Position Modes (fst_posmode) for F_PREALLOCATE + +// we can keep them in sync should we desire + +// Advisory file segment locking data type - +// information passed to system by user +type Flock = struct { + Fl_start Off_t + Fl_len Off_t + Fl_pid Pid_t + Fl_type int16 + Fl_whence int16 +} /* fcntl.h:343:1 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +// Advisory file segment locking with time out - +// Information passed to system by user for F_SETLKWTIMEOUT +type Flocktimeout = struct { + Ffl struct { + Fl_start Off_t + Fl_len Off_t + Fl_pid Pid_t + Fl_type int16 + Fl_whence int16 + } + Ftimeout struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } +} /* fcntl.h:358:1 */ + +// advisory file read data type - +// information passed by user to system + +type Radvisory = struct { + Fra_offset Off_t + Fra_count int32 + F__ccgo_pad1 [4]byte +} /* fcntl.h:371:1 */ + +// * Information the user passes in to get the codeblobs out of the kernel +type Fcodeblobs = struct { + Ff_cd_hash uintptr + Ff_hash_size Size_t + Ff_cd_buffer uintptr + Ff_cd_size Size_t + Ff_out_size uintptr + Ff_arch int32 + F__padding int32 +} /* fcntl.h:378:9 */ + +// * Information the user passes in to get the codeblobs out of the kernel +type Fcodeblobs_t = Fcodeblobs /* fcntl.h:386:3 */ + +// detached code signatures data type - +// information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS. +// F_ADDFILESIGS is a shortcut for files that contain their own signature and +// doesn't require mapping of the file in order to load the signature. +type Fsignatures = struct { + Ffs_file_start Off_t + Ffs_blob_start uintptr + Ffs_blob_size Size_t +} /* fcntl.h:395:9 */ + +// detached code signatures data type - +// information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS. +// F_ADDFILESIGS is a shortcut for files that contain their own signature and +// doesn't require mapping of the file in order to load the signature. +type Fsignatures_t = Fsignatures /* fcntl.h:399:3 */ + +// DYLD needs to check if the object is allowed to be combined +// into the main binary. This is done between the code signature +// is loaded and dyld is doing all the work to process the LOAD commands. +// +// While this could be done in F_ADDFILESIGS.* family the hook into +// the MAC module doesn't say no when LV isn't enabled and then that +// is cached on the vnode, and the MAC module never gets change once +// a process that library validation enabled. +type Fchecklv = struct { + Flv_file_start Off_t + Flv_error_message_size Size_t + Flv_error_message uintptr +} /* fcntl.h:411:9 */ + +// DYLD needs to check if the object is allowed to be combined +// into the main binary. This is done between the code signature +// is loaded and dyld is doing all the work to process the LOAD commands. +// +// While this could be done in F_ADDFILESIGS.* family the hook into +// the MAC module doesn't say no when LV isn't enabled and then that +// is cached on the vnode, and the MAC module never gets change once +// a process that library validation enabled. +type Fchecklv_t = Fchecklv /* fcntl.h:415:3 */ + +// lock operations for flock(2) + +// fstore_t type used by F_PREALLOCATE command + +type Fstore = struct { + Ffst_flags uint32 + Ffst_posmode int32 + Ffst_offset Off_t + Ffst_length Off_t + Ffst_bytesalloc Off_t +} /* fcntl.h:427:9 */ + +// lock operations for flock(2) + +// fstore_t type used by F_PREALLOCATE command + +type Fstore_t = Fstore /* fcntl.h:433:3 */ + +// fpunchhole_t used by F_PUNCHHOLE +type Fpunchhole = struct { + Ffp_flags uint32 + Freserved uint32 + Ffp_offset Off_t + Ffp_length Off_t +} /* fcntl.h:436:9 */ + +// fpunchhole_t used by F_PUNCHHOLE +type Fpunchhole_t = Fpunchhole /* fcntl.h:441:3 */ + +// factive_file_trim_t used by F_TRIM_ACTIVE_FILE +type Ftrimactivefile = struct { + Ffta_offset Off_t + Ffta_length Off_t +} /* fcntl.h:444:9 */ + +// factive_file_trim_t used by F_TRIM_ACTIVE_FILE +type Ftrimactivefile_t = Ftrimactivefile /* fcntl.h:447:3 */ + +// fspecread_t used by F_SPECULATIVE_READ +type Fspecread = struct { + Ffsr_flags uint32 + Freserved uint32 + Ffsr_offset Off_t + Ffsr_length Off_t +} /* fcntl.h:450:9 */ + +// fspecread_t used by F_SPECULATIVE_READ +type Fspecread_t = Fspecread /* fcntl.h:455:3 */ + +// fbootstraptransfer_t used by F_READBOOTSTRAP and F_WRITEBOOTSTRAP commands + +type Fbootstraptransfer = struct { + Ffbt_offset Off_t + Ffbt_length Size_t + Ffbt_buffer uintptr +} /* fcntl.h:459:9 */ + +// fbootstraptransfer_t used by F_READBOOTSTRAP and F_WRITEBOOTSTRAP commands + +type Fbootstraptransfer_t = Fbootstraptransfer /* fcntl.h:463:3 */ + +// For F_LOG2PHYS this information is passed back to user +// Currently only devoffset is returned - that is the VOP_BMAP +// result - the disk device address corresponding to the +// current file offset (likely set with an lseek). +// +// The flags could hold an indication of whether the # of +// contiguous bytes reflects the true extent length on disk, +// or is an advisory value that indicates there is at least that +// many bytes contiguous. For some filesystems it might be too +// inefficient to provide anything beyond the advisory value. +// Flags and contiguous bytes return values are not yet implemented. +// For them the fcntl will nedd to switch from using BMAP to CMAP +// and a per filesystem type flag will be needed to interpret the +// contiguous bytes count result from CMAP. +// +// F_LOG2PHYS_EXT is a variant of F_LOG2PHYS that uses a passed in +// file offset and length instead of the current file offset. +// F_LOG2PHYS_EXT operates on the same structure as F_LOG2PHYS, but +// treats it as an in/out. + +type Log2phys = struct { + Fl2p_flags uint32 + F__ccgo_pad1 [4]byte + Fl2p_contigbytes Off_t + Fl2p_devoffset Off_t +} /* fcntl.h:489:1 */ + +type Filesec_t = uintptr /* _filesec_t.h:31:25 */ + +type Filesec_property_t = uint32 /* fcntl.h:523:3 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/fcntl/fcntl_darwin_arm64.go b/internal/libc/fcntl/fcntl_darwin_arm64.go new file mode 100644 index 0000000..0b90858 --- /dev/null +++ b/internal/libc/fcntl/fcntl_darwin_arm64.go @@ -0,0 +1,2080 @@ +// Code generated by 'ccgo fcntl/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_darwin_arm64.go -pkgname fcntl', DO NOT EDIT. + +package fcntl + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AT_EACCESS = 0x0010 // fcntl.h:168:1: + AT_FDCWD = -2 // fcntl.h:163:1: + AT_FDONLY = 0x0400 // fcntl.h:174:1: + AT_REALDEV = 0x0200 // fcntl.h:173:1: + AT_REMOVEDIR = 0x0080 // fcntl.h:171:1: + AT_SYMLINK_FOLLOW = 0x0040 // fcntl.h:170:1: + AT_SYMLINK_NOFOLLOW = 0x0020 // fcntl.h:169:1: + AT_SYMLINK_NOFOLLOW_ANY = 0x0800 // fcntl.h:175:1: + CPF_IGNORE_MODE = 0x0002 // fcntl.h:208:1: + CPF_MASK = 3 // fcntl.h:209:1: + CPF_OVERWRITE = 0x0001 // fcntl.h:207:1: + FAPPEND = 8 // fcntl.h:193:1: + FASYNC = 64 // fcntl.h:194:1: + FCNTL_FS_SPECIFIC_BASE = 0x00010000 // fcntl.h:315:1: + FD_CLOEXEC = 1 // fcntl.h:324:1: + FFDSYNC = 4194304 // fcntl.h:196:1: + FFSYNC = 128 // fcntl.h:195:1: + FNDELAY = 4 // fcntl.h:198:1: + FNONBLOCK = 4 // fcntl.h:197:1: + FREAD = 0x00000001 // fcntl.h:110:1: + FWRITE = 0x00000002 // fcntl.h:111:1: + F_ADDFILESIGS = 61 // fcntl.h:253:1: + F_ADDFILESIGS_FOR_DYLD_SIM = 83 // fcntl.h:292:1: + F_ADDFILESIGS_INFO = 103 // fcntl.h:309:1: + F_ADDFILESIGS_RETURN = 97 // fcntl.h:298:1: + F_ADDFILESUPPL = 104 // fcntl.h:310:1: + F_ADDSIGS = 59 // fcntl.h:250:1: + F_ALLOCATEALL = 0x00000004 // fcntl.h:348:1: + F_ALLOCATECONTIG = 0x00000002 // fcntl.h:347:1: + F_BARRIERFSYNC = 85 // fcntl.h:295:1: + F_CHECK_LV = 98 // fcntl.h:299:1: + F_CHKCLEAN = 41 // fcntl.h:232:1: + F_DUPFD = 0 // fcntl.h:217:1: + F_DUPFD_CLOEXEC = 67 // fcntl.h:320:1: + F_FINDSIGS = 78 // fcntl.h:289:1: + F_FLUSH_DATA = 40 // fcntl.h:231:1: + F_FREEZE_FS = 53 // fcntl.h:245:1: + F_FSRESERVED = 106 // fcntl.h:312:1: + F_FULLFSYNC = 51 // fcntl.h:243:1: + F_GETCODEDIR = 72 // fcntl.h:277:1: + F_GETFD = 1 // fcntl.h:218:1: + F_GETFL = 3 // fcntl.h:220:1: + F_GETLK = 7 // fcntl.h:224:1: + F_GETLKPID = 66 // fcntl.h:263:1: + F_GETNOSIGPIPE = 74 // fcntl.h:280:1: + F_GETOWN = 5 // fcntl.h:222:1: + F_GETPATH = 50 // fcntl.h:242:1: + F_GETPATH_MTMINFO = 71 // fcntl.h:275:1: + F_GETPATH_NOFIRMLINK = 102 // fcntl.h:307:1: + F_GETPROTECTIONCLASS = 63 // fcntl.h:258:1: + F_GETPROTECTIONLEVEL = 77 // fcntl.h:287:1: + F_GETSIGSINFO = 105 // fcntl.h:311:1: + F_GLOBAL_NOCACHE = 55 // fcntl.h:247:1: + F_LOG2PHYS = 49 // fcntl.h:241:1: + F_LOG2PHYS_EXT = 65 // fcntl.h:261:1: + F_NOCACHE = 48 // fcntl.h:240:1: + F_NODIRECT = 62 // fcntl.h:255:1: + F_PATHPKG_CHECK = 52 // fcntl.h:244:1: + F_PEOFPOSMODE = 3 // fcntl.h:352:1: + F_PREALLOCATE = 42 // fcntl.h:233:1: + F_PUNCHHOLE = 99 // fcntl.h:301:1: + F_RDADVISE = 44 // fcntl.h:235:1: + F_RDAHEAD = 45 // fcntl.h:236:1: + F_RDLCK = 1 // fcntl.h:327:1: + F_SETBACKINGSTORE = 70 // fcntl.h:274:1: + F_SETFD = 2 // fcntl.h:219:1: + F_SETFL = 4 // fcntl.h:221:1: + F_SETLK = 8 // fcntl.h:225:1: + F_SETLKW = 9 // fcntl.h:226:1: + F_SETLKWTIMEOUT = 10 // fcntl.h:228:1: + F_SETNOSIGPIPE = 73 // fcntl.h:279:1: + F_SETOWN = 6 // fcntl.h:223:1: + F_SETPROTECTIONCLASS = 64 // fcntl.h:259:1: + F_SETSIZE = 43 // fcntl.h:234:1: + F_SINGLE_WRITER = 76 // fcntl.h:284:1: + F_SPECULATIVE_READ = 101 // fcntl.h:305:1: + F_THAW_FS = 54 // fcntl.h:246:1: + F_TRANSCODEKEY = 75 // fcntl.h:282:1: + F_TRIM_ACTIVE_FILE = 100 // fcntl.h:303:1: + F_UNLCK = 2 // fcntl.h:328:1: + F_VOLPOSMODE = 4 // fcntl.h:354:1: + F_WRLCK = 3 // fcntl.h:329:1: + GETSIGSINFO_PLATFORM_BINARY = 1 // fcntl.h:444:1: + LOCK_EX = 0x02 // fcntl.h:456:1: + LOCK_NB = 0x04 // fcntl.h:457:1: + LOCK_SH = 0x01 // fcntl.h:455:1: + LOCK_UN = 0x08 // fcntl.h:458:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + O_ACCMODE = 0x0003 // fcntl.h:99:1: + O_ALERT = 0x20000000 // fcntl.h:537:1: + O_APPEND = 0x00000008 // fcntl.h:114:1: + O_ASYNC = 0x00000040 // fcntl.h:121:1: + O_CLOEXEC = 0x01000000 // fcntl.h:150:1: + O_CREAT = 0x00000200 // fcntl.h:125:1: + O_DIRECTORY = 0x00100000 // fcntl.h:138:1: + O_DP_GETRAWENCRYPTED = 0x0001 // fcntl.h:181:1: + O_DP_GETRAWUNENCRYPTED = 0x0002 // fcntl.h:182:1: + O_DSYNC = 0x400000 // _o_dsync.h:29:1: + O_EVTONLY = 0x00008000 // fcntl.h:130:1: + O_EXCL = 0x00000800 // fcntl.h:127:1: + O_EXLOCK = 0x00000020 // fcntl.h:120:1: + O_FSYNC = 128 // fcntl.h:122:1: + O_NDELAY = 4 // fcntl.h:199:1: + O_NOCTTY = 0x00020000 // fcntl.h:134:1: + O_NOFOLLOW = 0x00000100 // fcntl.h:123:1: + O_NOFOLLOW_ANY = 0x20000000 // fcntl.h:155:1: + O_NONBLOCK = 0x00000004 // fcntl.h:113:1: + O_POPUP = 0x80000000 // fcntl.h:536:1: + O_RDONLY = 0x0000 // fcntl.h:96:1: + O_RDWR = 0x0002 // fcntl.h:98:1: + O_SHLOCK = 0x00000010 // fcntl.h:119:1: + O_SYMLINK = 0x00200000 // fcntl.h:142:1: + O_SYNC = 0x0080 // _o_sync.h:29:1: + O_TRUNC = 0x00000400 // fcntl.h:126:1: + O_WRONLY = 0x0001 // fcntl.h:97:1: + SEEK_CUR = 1 // _seek_set.h:34:1: + SEEK_DATA = 4 // _seek_set.h:44:1: + SEEK_END = 2 // _seek_set.h:35:1: + SEEK_HOLE = 3 // _seek_set.h:40:1: + SEEK_SET = 0 // _seek_set.h:33:1: + S_IEXEC = 64 // _s_ifmt.h:72:1: + S_IFBLK = 0060000 // _s_ifmt.h:39:1: + S_IFCHR = 0020000 // _s_ifmt.h:37:1: + S_IFDIR = 0040000 // _s_ifmt.h:38:1: + S_IFIFO = 0010000 // _s_ifmt.h:36:1: + S_IFLNK = 0120000 // _s_ifmt.h:41:1: + S_IFMT = 0170000 // _s_ifmt.h:35:1: + S_IFREG = 0100000 // _s_ifmt.h:40:1: + S_IFSOCK = 0140000 // _s_ifmt.h:42:1: + S_IFWHT = 0160000 // _s_ifmt.h:44:1: + S_IREAD = 256 // _s_ifmt.h:70:1: + S_IRGRP = 0000040 // _s_ifmt.h:55:1: + S_IROTH = 0000004 // _s_ifmt.h:60:1: + S_IRUSR = 0000400 // _s_ifmt.h:50:1: + S_IRWXG = 0000070 // _s_ifmt.h:54:1: + S_IRWXO = 0000007 // _s_ifmt.h:59:1: + S_IRWXU = 0000700 // _s_ifmt.h:49:1: + S_ISGID = 0002000 // _s_ifmt.h:65:1: + S_ISTXT = 512 // _s_ifmt.h:69:1: + S_ISUID = 0004000 // _s_ifmt.h:64:1: + S_ISVTX = 0001000 // _s_ifmt.h:66:1: + S_IWGRP = 0000020 // _s_ifmt.h:56:1: + S_IWOTH = 0000002 // _s_ifmt.h:61:1: + S_IWRITE = 128 // _s_ifmt.h:71:1: + S_IWUSR = 0000200 // _s_ifmt.h:51:1: + S_IXGRP = 0000010 // _s_ifmt.h:57:1: + S_IXOTH = 0000001 // _s_ifmt.h:62:1: + S_IXUSR = 0000100 // _s_ifmt.h:52:1: + USER_FSIGNATURES_CDHASH_LEN = 20 // fcntl.h:401:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILESEC_T = 0 // _filesec_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS_FCNTL_H_ = 0 // fcntl.h:71:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +const ( /* fcntl.h:547:1: */ + FILESEC_OWNER = 1 + FILESEC_GROUP = 2 + FILESEC_UUID = 3 + FILESEC_MODE = 4 + FILESEC_ACL = 5 + FILESEC_GRPUUID = 6 + + // XXX these are private to the implementation + FILESEC_ACL_RAW = 100 + FILESEC_ACL_ALLOCSIZE = 101 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1983, 1990, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)fcntl.h 8.3 (Berkeley) 1/21/94 + +// This file includes the definitions for open and fcntl +// described by POSIX for ; it also includes +// related kernel definitions. +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ + +// File status flags: these are used by open(2), fcntl(2). +// They are also used (indirectly) in the kernel file structure f_flags, +// which is a superset of the open/fcntl flags. Open flags and f_flags +// are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). +// Open/fcntl flags begin with O_; kernel-internal flags begin with F. +// open-only flags + +// Kernel encoding of open mode; separate read and write bits that are +// independently testable: 1 greater than the above. +// +// XXX +// FREAD and FWRITE are excluded from the #ifdef KERNEL so that TIOCFLUSH, +// which was documented to use FREAD/FWRITE, continues to work. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// O_DSYNC 0x00400000 /* synch I/O data integrity */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Descriptor value for the current working directory + +// Flags for the at functions + +// Data Protection Flags + +// The O_* flags used to have only F* names, which were used in the kernel +// and by fcntl. We retain the F* names for the kernel f_flags field +// and for backward compatibility for fcntl. + +// Flags used for copyfile(2) + +// Constants used for fcntl(2) + +// command values +// 46,47 used to be F_READBOOTSTRAP and F_WRITEBOOTSTRAP + +// should not be used (i.e. its ok to temporaily create cached pages) + +// See F_DUPFD_CLOEXEC below for 67 + +// may be broken into smaller chunks with throttling in between + +// FS-specific fcntl()'s numbers begin at 0x00010000 and go up + +// file descriptor flags (F_GETFD, F_SETFD) + +// record locking flags (F_GETLK, F_SETLK, F_SETLKW) + +// [XSI] The values used for l_whence shall be defined as described +// in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// whence values for lseek(2) + +// [XSI] The symbolic names for file modes for use as values of mode_t +// shall be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The symbolic names for file modes for use as values of mode_t +// shall be defined as described in +// File type + +// File mode +// Read, write, execute/search by owner +// Read, write, execute/search by group +// Read, write, execute/search by others + +// allocate flags (F_PREALLOCATE) + +// Position Modes (fst_posmode) for F_PREALLOCATE + +// we can keep them in sync should we desire + +// Advisory file segment locking data type - +// information passed to system by user +type Flock = struct { + Fl_start Off_t + Fl_len Off_t + Fl_pid Pid_t + Fl_type int16 + Fl_whence int16 +} /* fcntl.h:361:1 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +// Advisory file segment locking with time out - +// Information passed to system by user for F_SETLKWTIMEOUT +type Flocktimeout = struct { + Ffl struct { + Fl_start Off_t + Fl_len Off_t + Fl_pid Pid_t + Fl_type int16 + Fl_whence int16 + } + Ftimeout struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } +} /* fcntl.h:376:1 */ + +// advisory file read data type - +// information passed by user to system + +type Radvisory = struct { + Fra_offset Off_t + Fra_count int32 + F__ccgo_pad1 [4]byte +} /* fcntl.h:389:1 */ + +// detached code signatures data type - +// information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS. +// F_ADDFILESIGS is a shortcut for files that contain their own signature and +// doesn't require mapping of the file in order to load the signature. +type Fsignatures = struct { + Ffs_file_start Off_t + Ffs_blob_start uintptr + Ffs_blob_size Size_t + Ffs_fsignatures_size Size_t + Ffs_cdhash [20]int8 + Ffs_hash_type int32 +} /* fcntl.h:402:9 */ + +// detached code signatures data type - +// information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS. +// F_ADDFILESIGS is a shortcut for files that contain their own signature and +// doesn't require mapping of the file in order to load the signature. +type Fsignatures_t = Fsignatures /* fcntl.h:412:3 */ + +type Fsupplement = struct { + Ffs_file_start Off_t + Ffs_blob_start Off_t + Ffs_blob_size Size_t + Ffs_orig_fd int32 + F__ccgo_pad1 [4]byte +} /* fcntl.h:414:9 */ + +type Fsupplement_t = Fsupplement /* fcntl.h:419:3 */ + +// DYLD needs to check if the object is allowed to be combined +// into the main binary. This is done between the code signature +// is loaded and dyld is doing all the work to process the LOAD commands. +// +// While this could be done in F_ADDFILESIGS.* family the hook into +// the MAC module doesn't say no when LV isn't enabled and then that +// is cached on the vnode, and the MAC module never gets change once +// a process that library validation enabled. +type Fchecklv = struct { + Flv_file_start Off_t + Flv_error_message_size Size_t + Flv_error_message uintptr +} /* fcntl.h:433:9 */ + +// DYLD needs to check if the object is allowed to be combined +// into the main binary. This is done between the code signature +// is loaded and dyld is doing all the work to process the LOAD commands. +// +// While this could be done in F_ADDFILESIGS.* family the hook into +// the MAC module doesn't say no when LV isn't enabled and then that +// is cached on the vnode, and the MAC module never gets change once +// a process that library validation enabled. +type Fchecklv_t = Fchecklv /* fcntl.h:437:3 */ + +// At this time F_GETSIGSINFO can only indicate platformness. +// As additional requestable information is defined, new keys will be added and the +// fgetsigsinfo_t structure will be lengthened to add space for the additional information + +// fgetsigsinfo_t used by F_GETSIGSINFO command +type Fgetsigsinfo = struct { + Ffg_file_start Off_t + Ffg_info_request int32 + Ffg_sig_is_platform int32 +} /* fcntl.h:447:9 */ + +// At this time F_GETSIGSINFO can only indicate platformness. +// As additional requestable information is defined, new keys will be added and the +// fgetsigsinfo_t structure will be lengthened to add space for the additional information + +// fgetsigsinfo_t used by F_GETSIGSINFO command +type Fgetsigsinfo_t = Fgetsigsinfo /* fcntl.h:451:3 */ + +// lock operations for flock(2) + +// fstore_t type used by F_PREALLOCATE command + +type Fstore = struct { + Ffst_flags uint32 + Ffst_posmode int32 + Ffst_offset Off_t + Ffst_length Off_t + Ffst_bytesalloc Off_t +} /* fcntl.h:462:9 */ + +// lock operations for flock(2) + +// fstore_t type used by F_PREALLOCATE command + +type Fstore_t = Fstore /* fcntl.h:468:3 */ + +// fpunchhole_t used by F_PUNCHHOLE +type Fpunchhole = struct { + Ffp_flags uint32 + Freserved uint32 + Ffp_offset Off_t + Ffp_length Off_t +} /* fcntl.h:471:9 */ + +// fpunchhole_t used by F_PUNCHHOLE +type Fpunchhole_t = Fpunchhole /* fcntl.h:476:3 */ + +// factive_file_trim_t used by F_TRIM_ACTIVE_FILE +type Ftrimactivefile = struct { + Ffta_offset Off_t + Ffta_length Off_t +} /* fcntl.h:479:9 */ + +// factive_file_trim_t used by F_TRIM_ACTIVE_FILE +type Ftrimactivefile_t = Ftrimactivefile /* fcntl.h:482:3 */ + +// fspecread_t used by F_SPECULATIVE_READ +type Fspecread = struct { + Ffsr_flags uint32 + Freserved uint32 + Ffsr_offset Off_t + Ffsr_length Off_t +} /* fcntl.h:485:9 */ + +// fspecread_t used by F_SPECULATIVE_READ +type Fspecread_t = Fspecread /* fcntl.h:490:3 */ + +// fbootstraptransfer_t used by F_READBOOTSTRAP and F_WRITEBOOTSTRAP commands + +type Fbootstraptransfer = struct { + Ffbt_offset Off_t + Ffbt_length Size_t + Ffbt_buffer uintptr +} /* fcntl.h:494:9 */ + +// fbootstraptransfer_t used by F_READBOOTSTRAP and F_WRITEBOOTSTRAP commands + +type Fbootstraptransfer_t = Fbootstraptransfer /* fcntl.h:498:3 */ + +// For F_LOG2PHYS this information is passed back to user +// Currently only devoffset is returned - that is the VOP_BMAP +// result - the disk device address corresponding to the +// current file offset (likely set with an lseek). +// +// The flags could hold an indication of whether the # of +// contiguous bytes reflects the true extent length on disk, +// or is an advisory value that indicates there is at least that +// many bytes contiguous. For some filesystems it might be too +// inefficient to provide anything beyond the advisory value. +// Flags and contiguous bytes return values are not yet implemented. +// For them the fcntl will nedd to switch from using BMAP to CMAP +// and a per filesystem type flag will be needed to interpret the +// contiguous bytes count result from CMAP. +// +// F_LOG2PHYS_EXT is a variant of F_LOG2PHYS that uses a passed in +// file offset and length instead of the current file offset. +// F_LOG2PHYS_EXT operates on the same structure as F_LOG2PHYS, but +// treats it as an in/out. + +type Log2phys = struct { + Fl2p_flags uint32 + F__ccgo_pad1 [4]byte + Fl2p_contigbytes Off_t + Fl2p_devoffset Off_t +} /* fcntl.h:524:1 */ + +type Filesec_t = uintptr /* _filesec_t.h:31:25 */ + +type Filesec_property_t = uint32 /* fcntl.h:558:3 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/fcntl/fcntl_linux_amd64.go b/internal/libc/fcntl/fcntl_linux_amd64.go new file mode 100644 index 0000000..9e87667 --- /dev/null +++ b/internal/libc/fcntl/fcntl_linux_amd64.go @@ -0,0 +1,1087 @@ +// Code generated by 'ccgo fcntl/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_linux_amd64.go -pkgname fcntl', DO NOT EDIT. + +package fcntl + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AT_EACCESS = 0x200 // fcntl-linux.h:388:1: + AT_FDCWD = -100 // fcntl-linux.h:371:1: + AT_REMOVEDIR = 0x200 // fcntl-linux.h:375:1: + AT_SYMLINK_FOLLOW = 0x400 // fcntl-linux.h:377:1: + AT_SYMLINK_NOFOLLOW = 0x100 // fcntl-linux.h:374:1: + FAPPEND = 1024 // fcntl-linux.h:304:1: + FASYNC = 8192 // fcntl-linux.h:306:1: + FD_CLOEXEC = 1 // fcntl-linux.h:219:1: + FFSYNC = 1052672 // fcntl-linux.h:305:1: + FNDELAY = 2048 // fcntl-linux.h:308:1: + FNONBLOCK = 2048 // fcntl-linux.h:307:1: + F_DUPFD = 0 // fcntl-linux.h:167:1: + F_DUPFD_CLOEXEC = 1030 // fcntl-linux.h:214:1: + F_EXLCK = 4 // fcntl-linux.h:231:1: + F_GETFD = 1 // fcntl-linux.h:168:1: + F_GETFL = 3 // fcntl-linux.h:170:1: + F_GETLK = 5 // fcntl-linux.h:109:1: + F_GETLK64 = 5 // fcntl.h:29:1: + F_GETOWN = 9 // fcntl-linux.h:180:1: + F_LOCK = 1 // fcntl.h:238:1: + F_OK = 0 // fcntl.h:131:1: + F_RDLCK = 0 // fcntl-linux.h:223:1: + F_SETFD = 2 // fcntl-linux.h:169:1: + F_SETFL = 4 // fcntl-linux.h:171:1: + F_SETLK = 6 // fcntl-linux.h:110:1: + F_SETLK64 = 6 // fcntl.h:30:1: + F_SETLKW = 7 // fcntl-linux.h:111:1: + F_SETLKW64 = 7 // fcntl.h:31:1: + F_SETOWN = 8 // fcntl-linux.h:179:1: + F_SHLCK = 8 // fcntl-linux.h:232:1: + F_TEST = 3 // fcntl.h:240:1: + F_TLOCK = 2 // fcntl.h:239:1: + F_ULOCK = 0 // fcntl.h:237:1: + F_UNLCK = 2 // fcntl-linux.h:225:1: + F_WRLCK = 1 // fcntl-linux.h:224:1: + LOCK_EX = 2 // fcntl-linux.h:238:1: + LOCK_NB = 4 // fcntl-linux.h:239:1: + LOCK_SH = 1 // fcntl-linux.h:237:1: + LOCK_UN = 8 // fcntl-linux.h:241:1: + O_ACCMODE = 0003 // fcntl-linux.h:42:1: + O_APPEND = 02000 // fcntl-linux.h:59:1: + O_ASYNC = 020000 // fcntl-linux.h:72:1: + O_CLOEXEC = 524288 // fcntl-linux.h:144:1: + O_CREAT = 0100 // fcntl-linux.h:47:1: + O_DIRECTORY = 65536 // fcntl-linux.h:142:1: + O_DSYNC = 4096 // fcntl-linux.h:158:1: + O_EXCL = 0200 // fcntl-linux.h:50:1: + O_FSYNC = 1052672 // fcntl-linux.h:70:1: + O_NDELAY = 2048 // fcntl-linux.h:65:1: + O_NOCTTY = 0400 // fcntl-linux.h:53:1: + O_NOFOLLOW = 131072 // fcntl-linux.h:143:1: + O_NONBLOCK = 04000 // fcntl-linux.h:62:1: + O_RDONLY = 00 // fcntl-linux.h:43:1: + O_RDWR = 02 // fcntl-linux.h:45:1: + O_RSYNC = 1052672 // fcntl-linux.h:162:1: + O_SYNC = 04010000 // fcntl-linux.h:68:1: + O_TRUNC = 01000 // fcntl-linux.h:56:1: + O_WRONLY = 01 // fcntl-linux.h:44:1: + POSIX_FADV_DONTNEED = 4 // fcntl-linux.h:321:1: + POSIX_FADV_NOREUSE = 5 // fcntl-linux.h:322:1: + POSIX_FADV_NORMAL = 0 // fcntl-linux.h:317:1: + POSIX_FADV_RANDOM = 1 // fcntl-linux.h:318:1: + POSIX_FADV_SEQUENTIAL = 2 // fcntl-linux.h:319:1: + POSIX_FADV_WILLNEED = 3 // fcntl-linux.h:320:1: + R_OK = 4 // fcntl.h:128:1: + SEEK_CUR = 1 // fcntl.h:138:1: + SEEK_END = 2 // fcntl.h:139:1: + SEEK_SET = 0 // fcntl.h:137:1: + S_IFBLK = 24576 // fcntl.h:83:1: + S_IFCHR = 8192 // fcntl.h:82:1: + S_IFDIR = 16384 // fcntl.h:81:1: + S_IFIFO = 4096 // fcntl.h:86:1: + S_IFLNK = 40960 // fcntl.h:89:1: + S_IFMT = 61440 // fcntl.h:80:1: + S_IFREG = 32768 // fcntl.h:84:1: + S_IFSOCK = 49152 // fcntl.h:92:1: + S_IRGRP = 32 // fcntl.h:111:1: + S_IROTH = 4 // fcntl.h:117:1: + S_IRUSR = 256 // fcntl.h:105:1: + S_IRWXG = 56 // fcntl.h:115:1: + S_IRWXO = 7 // fcntl.h:121:1: + S_IRWXU = 448 // fcntl.h:109:1: + S_ISGID = 1024 // fcntl.h:98:1: + S_ISUID = 2048 // fcntl.h:97:1: + S_ISVTX = 512 // fcntl.h:102:1: + S_IWGRP = 16 // fcntl.h:112:1: + S_IWOTH = 2 // fcntl.h:118:1: + S_IWUSR = 128 // fcntl.h:106:1: + S_IXGRP = 8 // fcntl.h:113:1: + S_IXOTH = 1 // fcntl.h:119:1: + S_IXUSR = 64 // fcntl.h:107:1: + UTIME_NOW = 1073741823 // stat.h:206:1: + UTIME_OMIT = 1073741822 // stat.h:207:1: + W_OK = 2 // fcntl.h:129:1: + X_OK = 1 // fcntl.h:130:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_STAT_H = 1 // stat.h:23:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FCNTL_H = 1 // fcntl.h:23:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :284:1: + X_MKNOD_VER_LINUX = 0 // stat.h:41:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_STATBUF_ST_BLKSIZE = 0 // stat.h:172:1: + X_STATBUF_ST_NSEC = 0 // stat.h:175:1: + X_STATBUF_ST_RDEV = 0 // stat.h:173:1: + X_STAT_VER = 1 // stat.h:44:1: + X_STAT_VER_KERNEL = 0 // stat.h:37:1: + X_STAT_VER_LINUX = 1 // stat.h:38:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 6.5 File Control Operations + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// This must be early so can define types winningly. + +// Get __mode_t, __dev_t and __off_t . +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// Get the definitions of O_*, F_*, FD_*: all the +// numbers and flag bits for `open', `fcntl', et al. +// O_*, F_*, FD_* bit values for Linux/x86. +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Not necessary, we always have 64-bit offsets. + +type Flock = struct { + Fl_type int16 + Fl_whence int16 + F__ccgo_pad1 [4]byte + Fl_start X__off64_t + Fl_len X__off64_t + Fl_pid X__pid_t + F__ccgo_pad2 [4]byte +} /* fcntl.h:35:1 */ + +// Include generic Linux declarations. +// O_*, F_*, FD_* bit values for Linux. +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file contains shared definitions between Linux architectures +// and is included by to declare them. The various +// #ifndef cases allow the architecture specific file to define those +// values with different values. +// +// A minimal contains just: +// +// struct flock {...} +// #ifdef __USE_LARGEFILE64 +// struct flock64 {...} +// #endif +// #include + +// open/fcntl. + +// open file description locks. +// +// Usually record locks held by a process are released on *any* close and are +// not inherited across a fork. +// +// These cmd values will set locks that conflict with process-associated record +// locks, but are "owned" by the opened file description, not the process. +// This means that they are inherited across fork or clone with CLONE_FILES +// like BSD (flock) locks, and they are only released automatically when the +// last reference to the the file description against which they were acquired +// is put. + +// For now, Linux has no separate synchronicity options for read +// operations. We define O_RSYNC therefore as the same as O_SYNC +// since this is a superset. + +// Values for the second argument to `fcntl'. + +// For F_[GET|SET]FD. + +// For posix fcntl() and `l_type' field of a `struct flock' for lockf(). + +// For old implementation of BSD flock. + +// Operations for BSD flock, also used by the kernel implementation. + +// Define some more compatibility macros to be backward compatible with +// BSD systems which did not managed to hide these kernel macros. + +// Advise to `posix_fadvise'. + +// Values for `*at' functions. + +// Detect if open needs mode as a third argument (or for openat as a fourth +// argument). + +// POSIX.1-2001 specifies that these types are defined by . +// +// Earlier POSIX standards permitted any type ending in `_t' to be defined +// by any POSIX header, so we don't conditionalize the definitions here. +type Mode_t = X__mode_t /* fcntl.h:50:18 */ + +type Off_t = X__off64_t /* fcntl.h:58:19 */ + +type Pid_t = X__pid_t /* fcntl.h:69:17 */ + +// For XPG all symbols from should also be available. +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// i386/x86_64 are little-endian. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +// Copyright (C) 1999-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Versions of the `struct stat' data structure. + +// x86-64 versions of the `xmknod' interface. + +type Stat = struct { + Fst_dev X__dev_t + Fst_ino X__ino_t + Fst_nlink X__nlink_t + Fst_mode X__mode_t + Fst_uid X__uid_t + Fst_gid X__gid_t + F__pad0 int32 + Fst_rdev X__dev_t + Fst_size X__off_t + Fst_blksize X__blksize_t + Fst_blocks X__blkcnt_t + Fst_atim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_mtim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_ctim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + F__glibc_reserved [3]X__syscall_slong_t +} /* stat.h:46:1 */ + +// Define some inlines helping to catch common problems. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/fcntl/fcntl_linux_arm64.go b/internal/libc/fcntl/fcntl_linux_arm64.go new file mode 100644 index 0000000..a61f9e7 --- /dev/null +++ b/internal/libc/fcntl/fcntl_linux_arm64.go @@ -0,0 +1,1199 @@ +// Code generated by 'ccgo fcntl/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o fcntl/fcntl_linux_arm64.go -pkgname fcntl', DO NOT EDIT. + +package fcntl + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AT_EACCESS = 0x200 + AT_FDCWD = -100 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 + FAPPEND = 1024 + FASYNC = 8192 + FD_CLOEXEC = 1 + FFSYNC = 1052672 + FNDELAY = 2048 + FNONBLOCK = 2048 + F_DUPFD = 0 + F_DUPFD_CLOEXEC = 1030 + F_EXLCK = 4 + F_GETFD = 1 + F_GETFL = 3 + F_GETLK = 5 + F_GETLK64 = 5 + F_GETOWN = 9 + F_LOCK = 1 + F_OK = 0 + F_RDLCK = 0 + F_SETFD = 2 + F_SETFL = 4 + F_SETLK = 6 + F_SETLK64 = 6 + F_SETLKW = 7 + F_SETLKW64 = 7 + F_SETOWN = 8 + F_SHLCK = 8 + F_TEST = 3 + F_TLOCK = 2 + F_ULOCK = 0 + F_UNLCK = 2 + F_WRLCK = 1 + LOCK_EX = 2 + LOCK_NB = 4 + LOCK_SH = 1 + LOCK_UN = 8 + O_ACCMODE = 0003 + O_APPEND = 02000 + O_ASYNC = 020000 + O_CLOEXEC = 524288 + O_CREAT = 0100 + O_DIRECTORY = 16384 + O_DSYNC = 4096 + O_EXCL = 0200 + O_FSYNC = 1052672 + O_NDELAY = 2048 + O_NOCTTY = 0400 + O_NOFOLLOW = 32768 + O_NONBLOCK = 04000 + O_RDONLY = 00 + O_RDWR = 02 + O_RSYNC = 1052672 + O_SYNC = 04010000 + O_TRUNC = 01000 + O_WRONLY = 01 + POSIX_FADV_DONTNEED = 4 + POSIX_FADV_NOREUSE = 5 + POSIX_FADV_NORMAL = 0 + POSIX_FADV_RANDOM = 1 + POSIX_FADV_SEQUENTIAL = 2 + POSIX_FADV_WILLNEED = 3 + R_OK = 4 + SEEK_CUR = 1 + SEEK_END = 2 + SEEK_SET = 0 + S_IFBLK = 24576 + S_IFCHR = 8192 + S_IFDIR = 16384 + S_IFIFO = 4096 + S_IFLNK = 40960 + S_IFMT = 61440 + S_IFREG = 32768 + S_IFSOCK = 49152 + S_IRGRP = 32 + S_IROTH = 4 + S_IRUSR = 256 + S_IRWXG = 56 + S_IRWXO = 7 + S_IRWXU = 448 + S_ISGID = 1024 + S_ISUID = 2048 + S_ISVTX = 512 + S_IWGRP = 16 + S_IWOTH = 2 + S_IWUSR = 128 + S_IXGRP = 8 + S_IXOTH = 1 + S_IXUSR = 64 + UTIME_NOW = 1073741823 + UTIME_OMIT = 1073741822 + W_OK = 2 + X_OK = 1 + X_ATFILE_SOURCE = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_STAT_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_DEFAULT_SOURCE = 1 + X_FCNTL_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_LP64 = 1 + X_MKNOD_VER_LINUX = 0 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_STATBUF_ST_BLKSIZE = 0 + X_STATBUF_ST_NSEC = 0 + X_STATBUF_ST_RDEV = 0 + X_STAT_VER = 0 + X_STAT_VER_KERNEL = 0 + X_STAT_VER_LINUX = 0 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 6.5 File Control Operations + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// This must be early so can define types winningly. + +// Get __mode_t, __dev_t and __off_t . +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// Get the definitions of O_*, F_*, FD_*: all the +// numbers and flag bits for `open', `fcntl', et al. +// O_*, F_*, FD_* bit values for the AArch64 Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +type Flock = struct { + Fl_type int16 + Fl_whence int16 + F__ccgo_pad1 [4]byte + Fl_start X__off_t + Fl_len X__off_t + Fl_pid X__pid_t + F__ccgo_pad2 [4]byte +} /* fcntl.h:40:1 */ + +// Include generic Linux declarations. +// O_*, F_*, FD_* bit values for Linux. +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file contains shared definitions between Linux architectures +// and is included by to declare them. The various +// #ifndef cases allow the architecture specific file to define those +// values with different values. +// +// A minimal contains just: +// +// struct flock {...} +// #ifdef __USE_LARGEFILE64 +// struct flock64 {...} +// #endif +// #include + +// open/fcntl. + +// open file description locks. +// +// Usually record locks held by a process are released on *any* close and are +// not inherited across a fork. +// +// These cmd values will set locks that conflict with process-associated record +// locks, but are "owned" by the opened file description, not the process. +// This means that they are inherited across fork or clone with CLONE_FILES +// like BSD (flock) locks, and they are only released automatically when the +// last reference to the the file description against which they were acquired +// is put. + +// For now, Linux has no separate synchronicity options for read +// operations. We define O_RSYNC therefore as the same as O_SYNC +// since this is a superset. + +// Values for the second argument to `fcntl'. + +// For F_[GET|SET]FD. + +// For posix fcntl() and `l_type' field of a `struct flock' for lockf(). + +// For old implementation of BSD flock. + +// Operations for BSD flock, also used by the kernel implementation. + +// Define some more compatibility macros to be backward compatible with +// BSD systems which did not managed to hide these kernel macros. + +// Advise to `posix_fadvise'. + +// Values for `*at' functions. + +// Detect if open needs mode as a third argument (or for openat as a fourth +// argument). + +// POSIX.1-2001 specifies that these types are defined by . +// +// Earlier POSIX standards permitted any type ending in `_t' to be defined +// by any POSIX header, so we don't conditionalize the definitions here. +type Mode_t = X__mode_t /* fcntl.h:50:18 */ + +type Off_t = X__off64_t /* fcntl.h:58:19 */ + +type Pid_t = X__pid_t /* fcntl.h:69:17 */ + +// For XPG all symbols from should also be available. +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// AArch64 has selectable endianness. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// 64-bit libc uses the kernel's 'struct stat', accessed via the +// stat() syscall; 32-bit libc uses the kernel's 'struct stat64' +// and accesses it via the stat64() syscall. All the various +// APIs offered by libc use the kernel shape for their struct stat +// structure; the only difference is that 32-bit programs not +// using __USE_FILE_OFFSET64 only see the low 32 bits of some +// of the fields (specifically st_ino, st_size, and st_blocks). + +// Versions of the `xmknod' interface. + +type Stat = struct { + Fst_dev X__dev_t + Fst_ino X__ino64_t + Fst_mode X__mode_t + Fst_nlink X__nlink_t + Fst_uid X__uid_t + Fst_gid X__gid_t + Fst_rdev X__dev_t + F__pad1 X__dev_t + Fst_size X__off64_t + Fst_blksize X__blksize_t + F__pad2 int32 + Fst_blocks X__blkcnt64_t + Fst_atim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_mtim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_ctim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + F__glibc_reserved [2]int32 +} /* stat.h:58:1 */ + +// Define some inlines helping to catch common problems. + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/fsync.go b/internal/libc/fsync.go new file mode 100644 index 0000000..015a8de --- /dev/null +++ b/internal/libc/fsync.go @@ -0,0 +1,10 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !libc.nofsync +// +build !libc.nofsync + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +const noFsync = false diff --git a/internal/libc/fts/capi_darwin_amd64.go b/internal/libc/fts/capi_darwin_amd64.go new file mode 100644 index 0000000..71d2f55 --- /dev/null +++ b/internal/libc/fts/capi_darwin_amd64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo fts/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_darwin_amd64.go -pkgname fts', DO NOT EDIT. + +package fts + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/fts/capi_darwin_arm64.go b/internal/libc/fts/capi_darwin_arm64.go new file mode 100644 index 0000000..35b9632 --- /dev/null +++ b/internal/libc/fts/capi_darwin_arm64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo fts/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_darwin_arm64.go -pkgname fts', DO NOT EDIT. + +package fts + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/fts/capi_linux_amd64.go b/internal/libc/fts/capi_linux_amd64.go new file mode 100644 index 0000000..5dc389b --- /dev/null +++ b/internal/libc/fts/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo fts/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_linux_amd64.go -pkgname fts', DO NOT EDIT. + +package fts + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/fts/capi_linux_arm64.go b/internal/libc/fts/capi_linux_arm64.go new file mode 100644 index 0000000..24a78a6 --- /dev/null +++ b/internal/libc/fts/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo fts/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o fts/fts_linux_arm64.go -pkgname fts', DO NOT EDIT. + +package fts + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/fts/fts_darwin_amd64.go b/internal/libc/fts/fts_darwin_amd64.go new file mode 100644 index 0000000..1de3233 --- /dev/null +++ b/internal/libc/fts/fts_darwin_amd64.go @@ -0,0 +1,5132 @@ +// Code generated by 'ccgo fts/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_darwin_amd64.go -pkgname fts', DO NOT EDIT. + +package fts + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSPERMS = 511 // stat.h:297:1: + ALLPERMS = 4095 // stat.h:299:1: + BIG_ENDIAN = 4321 // endian.h:94:1: + BYTE_ORDER = 1234 // endian.h:97:1: + DEFFILEMODE = 438 // stat.h:301:1: + EF_IS_PURGEABLE = 0x00000008 // stat.h:370:1: + EF_IS_SPARSE = 0x00000010 // stat.h:371:1: + EF_IS_SYNC_ROOT = 0x00000004 // stat.h:369:1: + EF_MAY_SHARE_BLOCKS = 0x00000001 // stat.h:367:1: + EF_NO_XATTRS = 0x00000002 // stat.h:368:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + FTS_AGAIN = 1 // fts.h:156:1: + FTS_BLOCK_COMPAR = 0x80000000 // fts.h:108:1: + FTS_COMFOLLOW = 0x001 // fts.h:89:1: + FTS_COMFOLLOWDIR = 0x400 // fts.h:97:1: + FTS_D = 1 // fts.h:135:1: + FTS_DC = 2 // fts.h:136:1: + FTS_DEFAULT = 3 // fts.h:137:1: + FTS_DNR = 4 // fts.h:138:1: + FTS_DONTCHDIR = 0x01 // fts.h:151:1: + FTS_DOT = 5 // fts.h:139:1: + FTS_DP = 6 // fts.h:140:1: + FTS_ERR = 7 // fts.h:141:1: + FTS_F = 8 // fts.h:142:1: + FTS_FOLLOW = 2 // fts.h:157:1: + FTS_INIT = 9 // fts.h:143:1: + FTS_ISW = 0x04 // fts.h:153:1: + FTS_LOGICAL = 0x002 // fts.h:90:1: + FTS_MAXLEVEL = 0x7fffffff // fts.h:132:1: + FTS_NAMEONLY = 0x100 // fts.h:105:1: + FTS_NOCHDIR = 0x004 // fts.h:91:1: + FTS_NOINSTR = 3 // fts.h:158:1: + FTS_NOSTAT = 0x008 // fts.h:92:1: + FTS_NOSTAT_TYPE = 0x800 // fts.h:101:1: + FTS_NS = 10 // fts.h:144:1: + FTS_NSOK = 11 // fts.h:145:1: + FTS_OPTIONMASK = 0xcff // fts.h:102:1: + FTS_PHYSICAL = 0x010 // fts.h:93:1: + FTS_ROOTLEVEL = 0 // fts.h:131:1: + FTS_ROOTPARENTLEVEL = -1 // fts.h:130:1: + FTS_SEEDOT = 0x020 // fts.h:94:1: + FTS_SKIP = 4 // fts.h:159:1: + FTS_SL = 12 // fts.h:146:1: + FTS_SLNONE = 13 // fts.h:147:1: + FTS_STOP = 0x200 // fts.h:106:1: + FTS_SYMFOLLOW = 0x02 // fts.h:152:1: + FTS_W = 14 // fts.h:148:1: + FTS_WHITEOUT = 0x080 // fts.h:96:1: + FTS_XDEV = 0x040 // fts.h:95:1: + LITTLE_ENDIAN = 1234 // endian.h:93:1: + NBBY = 8 // types.h:186:1: + PDP_ENDIAN = 3412 // endian.h:95:1: + SF_APPEND = 0x00040000 // stat.h:340:1: + SF_ARCHIVED = 0x00010000 // stat.h:338:1: + SF_DATALESS = 0x40000000 // stat.h:359:1: + SF_FIRMLINK = 0x00800000 // stat.h:351:1: + SF_IMMUTABLE = 0x00020000 // stat.h:339:1: + SF_NOUNLINK = 0x00100000 // stat.h:342:1: + SF_RESTRICTED = 0x00080000 // stat.h:341:1: + SF_SETTABLE = 0x3fff0000 // stat.h:336:1: + SF_SUPPORTED = 0x009f0000 // stat.h:335:1: + SF_SYNTHETIC = 0xc0000000 // stat.h:337:1: + S_BLKSIZE = 512 // stat.h:303:1: + S_IEXEC = 64 // _s_ifmt.h:72:1: + S_IFBLK = 0060000 // _s_ifmt.h:39:1: + S_IFCHR = 0020000 // _s_ifmt.h:37:1: + S_IFDIR = 0040000 // _s_ifmt.h:38:1: + S_IFIFO = 0010000 // _s_ifmt.h:36:1: + S_IFLNK = 0120000 // _s_ifmt.h:41:1: + S_IFMT = 0170000 // _s_ifmt.h:35:1: + S_IFREG = 0100000 // _s_ifmt.h:40:1: + S_IFSOCK = 0140000 // _s_ifmt.h:42:1: + S_IFWHT = 0160000 // _s_ifmt.h:44:1: + S_IREAD = 256 // _s_ifmt.h:70:1: + S_IRGRP = 0000040 // _s_ifmt.h:55:1: + S_IROTH = 0000004 // _s_ifmt.h:60:1: + S_IRUSR = 0000400 // _s_ifmt.h:50:1: + S_IRWXG = 0000070 // _s_ifmt.h:54:1: + S_IRWXO = 0000007 // _s_ifmt.h:59:1: + S_IRWXU = 0000700 // _s_ifmt.h:49:1: + S_ISGID = 0002000 // _s_ifmt.h:65:1: + S_ISTXT = 512 // _s_ifmt.h:69:1: + S_ISUID = 0004000 // _s_ifmt.h:64:1: + S_ISVTX = 0001000 // _s_ifmt.h:66:1: + S_IWGRP = 0000020 // _s_ifmt.h:56:1: + S_IWOTH = 0000002 // _s_ifmt.h:61:1: + S_IWRITE = 128 // _s_ifmt.h:71:1: + S_IWUSR = 0000200 // _s_ifmt.h:51:1: + S_IXGRP = 0000010 // _s_ifmt.h:57:1: + S_IXOTH = 0000001 // _s_ifmt.h:62:1: + S_IXUSR = 0000100 // _s_ifmt.h:52:1: + UF_APPEND = 0x00000004 // stat.h:313:1: + UF_COMPRESSED = 0x00000020 // stat.h:320:1: + UF_DATAVAULT = 0x00000080 // stat.h:326:1: + UF_HIDDEN = 0x00008000 // stat.h:330:1: + UF_IMMUTABLE = 0x00000002 // stat.h:312:1: + UF_NODUMP = 0x00000001 // stat.h:311:1: + UF_OPAQUE = 0x00000008 // stat.h:314:1: + UF_SETTABLE = 0x0000ffff // stat.h:310:1: + UF_TRACKED = 0x00000040 // stat.h:324:1: + UTIME_NOW = -1 // stat.h:393:1: + UTIME_OMIT = -2 // stat.h:394:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILESEC_T = 0 // _filesec_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_FTS_H_ = 0 // fts.h:59:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_I386__ENDIAN_H_ = 0 // endian.h:67:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS__OSBYTEORDERI386_H = 0 // _OSByteOrder.h:30:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:78:1: + X_QUAD_LOWWORD = 0 // endian.h:79:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_STAT_H_ = 0 // stat.h:71:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1991, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)types.h 8.4 (Berkeley) 1/21/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Machine type dependent parameters. +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +// Copyright (c) 2000-2014 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)stat.h 8.9 (Berkeley) 8/17/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// [XSI] The timespec structure may be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +// [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t, +// gid_t, off_t, and time_t types shall be defined as described in +// . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX So deprecated, it would make your head spin +// +// The old stat structure. In fact, this is not used by the kernel at all, +// and should not be used by user space, and should be removed from this +// header file entirely (along with the unused cvtstat() prototype in +// vnode_internal.h). +type Ostat = struct { + Fst_dev X__uint16_t + F__ccgo_pad1 [6]byte + Fst_ino Ino_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_uid X__uint16_t + Fst_gid X__uint16_t + Fst_rdev X__uint16_t + F__ccgo_pad2 [2]byte + Fst_size X__int32_t + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_blksize X__int32_t + Fst_blocks X__int32_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t +} /* stat.h:110:1 */ + +// This structure is used as the second parameter to the fstat64(), +// lstat64(), and stat64() functions, and for struct stat when +// __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined +// above, depending on whether we use struct timespec or the direct +// components. +// +// This is simillar to stat except for 64bit inode number +// number instead of 32bit ino_t and the addition of create(birth) time. + +// [XSI] This structure is used as the second parameter to the fstat(), +// lstat(), and stat() functions. + +type Stat = struct { + Fst_dev Dev_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_ino X__darwin_ino64_t + Fst_uid Uid_t + Fst_gid Gid_t + Fst_rdev Dev_t + F__ccgo_pad1 [4]byte + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_birthtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_size Off_t + Fst_blocks Blkcnt_t + Fst_blksize Blksize_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t + Fst_lspare X__int32_t + Fst_qspare [2]X__int64_t +} /* stat.h:182:1 */ + +type Stat64 = struct { + Fst_dev Dev_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_ino X__darwin_ino64_t + Fst_uid Uid_t + Fst_gid Gid_t + Fst_rdev Dev_t + F__ccgo_pad1 [4]byte + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_birthtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_size Off_t + Fst_blocks Blkcnt_t + Fst_blksize Blksize_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t + Fst_lspare X__int32_t + Fst_qspare [2]X__int64_t +} /* stat.h:221:1 */ + +type Filesec_t = uintptr /* _filesec_t.h:31:25 */ + +// Copyright (c) 2000, 2003-2006, 2008, 2012 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 1989, 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. +// +// @(#)fts.h 8.3 (Berkeley) 8/14/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type X_ftsent = struct { + Ffts_cycle uintptr + Ffts_parent uintptr + Ffts_link uintptr + Ffts_number int64 + Ffts_pointer uintptr + Ffts_accpath uintptr + Ffts_path uintptr + Ffts_errno int32 + Ffts_symfd int32 + Ffts_pathlen uint16 + Ffts_namelen uint16 + F__ccgo_pad1 [4]byte + Ffts_ino Ino_t + Ffts_dev Dev_t + Ffts_nlink Nlink_t + Ffts_level int16 + Ffts_info uint16 + Ffts_flags uint16 + Ffts_instr uint16 + F__ccgo_pad2 [2]byte + Ffts_statp uintptr + Ffts_name [1]int8 + F__ccgo_pad3 [7]byte +} /* fts.h:72:2 */ + +// Copyright (c) 2000, 2003-2006, 2008, 2012 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 1989, 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. +// +// @(#)fts.h 8.3 (Berkeley) 8/14/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type FTS = struct { + Ffts_cur uintptr + Ffts_child uintptr + Ffts_array uintptr + Ffts_dev Dev_t + F__ccgo_pad1 [4]byte + Ffts_path uintptr + Ffts_rfd int32 + Ffts_pathlen int32 + Ffts_nitems int32 + F__ccgo_pad2 [4]byte + F__56 struct{ Ffts_compar uintptr } + Ffts_options int32 + F__ccgo_pad3 [4]byte +} /* fts.h:111:3 */ + +type FTSENT = X_ftsent /* fts.h:164:3 */ + +var _ int8 /* gen.c:5:13: */ diff --git a/internal/libc/fts/fts_darwin_arm64.go b/internal/libc/fts/fts_darwin_arm64.go new file mode 100644 index 0000000..d37a696 --- /dev/null +++ b/internal/libc/fts/fts_darwin_arm64.go @@ -0,0 +1,5230 @@ +// Code generated by 'ccgo fts/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_darwin_arm64.go -pkgname fts', DO NOT EDIT. + +package fts + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSPERMS = 511 // stat.h:297:1: + ALLPERMS = 4095 // stat.h:299:1: + BIG_ENDIAN = 4321 // endian.h:72:1: + BYTE_ORDER = 1234 // endian.h:75:1: + DEFFILEMODE = 438 // stat.h:301:1: + EF_IS_PURGEABLE = 0x00000008 // stat.h:371:1: + EF_IS_SPARSE = 0x00000010 // stat.h:372:1: + EF_IS_SYNC_ROOT = 0x00000004 // stat.h:370:1: + EF_IS_SYNTHETIC = 0x00000020 // stat.h:373:1: + EF_MAY_SHARE_BLOCKS = 0x00000001 // stat.h:368:1: + EF_NO_XATTRS = 0x00000002 // stat.h:369:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + FTS_AGAIN = 1 // fts.h:157:1: + FTS_BLOCK_COMPAR = 0x80000000 // fts.h:108:1: + FTS_CHDIRFD = 0x08 // fts.h:154:1: + FTS_COMFOLLOW = 0x001 // fts.h:89:1: + FTS_COMFOLLOWDIR = 0x400 // fts.h:97:1: + FTS_D = 1 // fts.h:135:1: + FTS_DC = 2 // fts.h:136:1: + FTS_DEFAULT = 3 // fts.h:137:1: + FTS_DNR = 4 // fts.h:138:1: + FTS_DONTCHDIR = 0x01 // fts.h:151:1: + FTS_DOT = 5 // fts.h:139:1: + FTS_DP = 6 // fts.h:140:1: + FTS_ERR = 7 // fts.h:141:1: + FTS_F = 8 // fts.h:142:1: + FTS_FOLLOW = 2 // fts.h:158:1: + FTS_INIT = 9 // fts.h:143:1: + FTS_ISW = 0x04 // fts.h:153:1: + FTS_LOGICAL = 0x002 // fts.h:90:1: + FTS_MAXLEVEL = 0x7fffffff // fts.h:132:1: + FTS_NAMEONLY = 0x100 // fts.h:105:1: + FTS_NOCHDIR = 0x004 // fts.h:91:1: + FTS_NOINSTR = 3 // fts.h:159:1: + FTS_NOSTAT = 0x008 // fts.h:92:1: + FTS_NOSTAT_TYPE = 0x800 // fts.h:101:1: + FTS_NS = 10 // fts.h:144:1: + FTS_NSOK = 11 // fts.h:145:1: + FTS_OPTIONMASK = 0xcff // fts.h:102:1: + FTS_PHYSICAL = 0x010 // fts.h:93:1: + FTS_ROOTLEVEL = 0 // fts.h:131:1: + FTS_ROOTPARENTLEVEL = -1 // fts.h:130:1: + FTS_SEEDOT = 0x020 // fts.h:94:1: + FTS_SKIP = 4 // fts.h:160:1: + FTS_SL = 12 // fts.h:146:1: + FTS_SLNONE = 13 // fts.h:147:1: + FTS_STOP = 0x200 // fts.h:106:1: + FTS_SYMFOLLOW = 0x02 // fts.h:152:1: + FTS_W = 14 // fts.h:148:1: + FTS_WHITEOUT = 0x080 // fts.h:96:1: + FTS_XDEV = 0x040 // fts.h:95:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + LITTLE_ENDIAN = 1234 // endian.h:71:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + NBBY = 8 // types.h:186:1: + PDP_ENDIAN = 3412 // endian.h:73:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + RSIZE_MAX = 9223372036854775807 // stdint.h:658:1: + SF_APPEND = 0x00040000 // stat.h:340:1: + SF_ARCHIVED = 0x00010000 // stat.h:338:1: + SF_DATALESS = 0x40000000 // stat.h:359:1: + SF_FIRMLINK = 0x00800000 // stat.h:351:1: + SF_IMMUTABLE = 0x00020000 // stat.h:339:1: + SF_NOUNLINK = 0x00100000 // stat.h:342:1: + SF_RESTRICTED = 0x00080000 // stat.h:341:1: + SF_SETTABLE = 0x3fff0000 // stat.h:336:1: + SF_SUPPORTED = 0x009f0000 // stat.h:335:1: + SF_SYNTHETIC = 0xc0000000 // stat.h:337:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + S_BLKSIZE = 512 // stat.h:303:1: + S_IEXEC = 64 // _s_ifmt.h:72:1: + S_IFBLK = 0060000 // _s_ifmt.h:39:1: + S_IFCHR = 0020000 // _s_ifmt.h:37:1: + S_IFDIR = 0040000 // _s_ifmt.h:38:1: + S_IFIFO = 0010000 // _s_ifmt.h:36:1: + S_IFLNK = 0120000 // _s_ifmt.h:41:1: + S_IFMT = 0170000 // _s_ifmt.h:35:1: + S_IFREG = 0100000 // _s_ifmt.h:40:1: + S_IFSOCK = 0140000 // _s_ifmt.h:42:1: + S_IFWHT = 0160000 // _s_ifmt.h:44:1: + S_IREAD = 256 // _s_ifmt.h:70:1: + S_IRGRP = 0000040 // _s_ifmt.h:55:1: + S_IROTH = 0000004 // _s_ifmt.h:60:1: + S_IRUSR = 0000400 // _s_ifmt.h:50:1: + S_IRWXG = 0000070 // _s_ifmt.h:54:1: + S_IRWXO = 0000007 // _s_ifmt.h:59:1: + S_IRWXU = 0000700 // _s_ifmt.h:49:1: + S_ISGID = 0002000 // _s_ifmt.h:65:1: + S_ISTXT = 512 // _s_ifmt.h:69:1: + S_ISUID = 0004000 // _s_ifmt.h:64:1: + S_ISVTX = 0001000 // _s_ifmt.h:66:1: + S_IWGRP = 0000020 // _s_ifmt.h:56:1: + S_IWOTH = 0000002 // _s_ifmt.h:61:1: + S_IWRITE = 128 // _s_ifmt.h:71:1: + S_IWUSR = 0000200 // _s_ifmt.h:51:1: + S_IXGRP = 0000010 // _s_ifmt.h:57:1: + S_IXOTH = 0000001 // _s_ifmt.h:62:1: + S_IXUSR = 0000100 // _s_ifmt.h:52:1: + UF_APPEND = 0x00000004 // stat.h:313:1: + UF_COMPRESSED = 0x00000020 // stat.h:320:1: + UF_DATAVAULT = 0x00000080 // stat.h:326:1: + UF_HIDDEN = 0x00008000 // stat.h:330:1: + UF_IMMUTABLE = 0x00000002 // stat.h:312:1: + UF_NODUMP = 0x00000001 // stat.h:311:1: + UF_OPAQUE = 0x00000008 // stat.h:314:1: + UF_SETTABLE = 0x0000ffff // stat.h:310:1: + UF_TRACKED = 0x00000040 // stat.h:324:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + UTIME_NOW = -1 // stat.h:395:1: + UTIME_OMIT = -2 // stat.h:396:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + X_ARM_ARCH_H = 0 // arch.h:29:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_ARM__ENDIAN_H_ = 0 // endian.h:43:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILESEC_T = 0 // _filesec_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_FTS_H_ = 0 // fts.h:59:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS_OSBYTEORDERARM_H = 0 // OSByteOrder.h:6:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:56:1: + X_QUAD_LOWWORD = 0 // endian.h:57:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_STAT_H_ = 0 // stat.h:71:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1991, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)types.h 8.4 (Berkeley) 1/21/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Machine type dependent parameters. +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// Functions for byte reversed loads. + +type X_OSUnalignedU16 = struct{ F__val Uint16_t } /* OSByteOrder.h:64:1 */ + +type X_OSUnalignedU32 = struct{ F__val Uint32_t } /* OSByteOrder.h:68:1 */ + +type X_OSUnalignedU64 = struct{ F__val Uint64_t } /* OSByteOrder.h:72:1 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +// Copyright (c) 2000-2014 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)stat.h 8.9 (Berkeley) 8/17/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// [XSI] The timespec structure may be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +// [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t, +// gid_t, off_t, and time_t types shall be defined as described in +// . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX So deprecated, it would make your head spin +// +// The old stat structure. In fact, this is not used by the kernel at all, +// and should not be used by user space, and should be removed from this +// header file entirely (along with the unused cvtstat() prototype in +// vnode_internal.h). +type Ostat = struct { + Fst_dev X__uint16_t + F__ccgo_pad1 [6]byte + Fst_ino Ino_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_uid X__uint16_t + Fst_gid X__uint16_t + Fst_rdev X__uint16_t + F__ccgo_pad2 [2]byte + Fst_size X__int32_t + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_blksize X__int32_t + Fst_blocks X__int32_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t +} /* stat.h:110:1 */ + +// This structure is used as the second parameter to the fstat64(), +// lstat64(), and stat64() functions, and for struct stat when +// __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined +// above, depending on whether we use struct timespec or the direct +// components. +// +// This is simillar to stat except for 64bit inode number +// number instead of 32bit ino_t and the addition of create(birth) time. + +// [XSI] This structure is used as the second parameter to the fstat(), +// lstat(), and stat() functions. + +type Stat = struct { + Fst_dev Dev_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_ino X__darwin_ino64_t + Fst_uid Uid_t + Fst_gid Gid_t + Fst_rdev Dev_t + F__ccgo_pad1 [4]byte + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_birthtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_size Off_t + Fst_blocks Blkcnt_t + Fst_blksize Blksize_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t + Fst_lspare X__int32_t + Fst_qspare [2]X__int64_t +} /* stat.h:182:1 */ + +type Filesec_t = uintptr /* _filesec_t.h:31:25 */ + +// Copyright (c) 2000, 2003-2006, 2008, 2012 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 1989, 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. +// +// @(#)fts.h 8.3 (Berkeley) 8/14/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type X_ftsent = struct { + Ffts_cycle uintptr + Ffts_parent uintptr + Ffts_link uintptr + Ffts_number int64 + Ffts_pointer uintptr + Ffts_accpath uintptr + Ffts_path uintptr + Ffts_errno int32 + Ffts_symfd int32 + Ffts_pathlen uint16 + Ffts_namelen uint16 + F__ccgo_pad1 [4]byte + Ffts_ino Ino_t + Ffts_dev Dev_t + Ffts_nlink Nlink_t + Ffts_level int16 + Ffts_info uint16 + Ffts_flags uint16 + Ffts_instr uint16 + F__ccgo_pad2 [2]byte + Ffts_statp uintptr + Ffts_name [1]int8 + F__ccgo_pad3 [7]byte +} /* fts.h:72:2 */ + +// Copyright (c) 2000, 2003-2006, 2008, 2012 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 1989, 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. +// +// @(#)fts.h 8.3 (Berkeley) 8/14/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type FTS = struct { + Ffts_cur uintptr + Ffts_child uintptr + Ffts_array uintptr + Ffts_dev Dev_t + F__ccgo_pad1 [4]byte + Ffts_path uintptr + Ffts_rfd int32 + Ffts_pathlen int32 + Ffts_nitems int32 + F__ccgo_pad2 [4]byte + F__56 struct{ Ffts_compar uintptr } + Ffts_options int32 + F__ccgo_pad3 [4]byte +} /* fts.h:111:3 */ + +type FTSENT = X_ftsent /* fts.h:165:3 */ + +var _ int8 /* gen.c:5:13: */ diff --git a/internal/libc/fts/fts_linux_amd64.go b/internal/libc/fts/fts_linux_amd64.go new file mode 100644 index 0000000..ba83f3f --- /dev/null +++ b/internal/libc/fts/fts_linux_amd64.go @@ -0,0 +1,1904 @@ +// Code generated by 'ccgo fts/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_linux_amd64.go -pkgname fts', DO NOT EDIT. + +package fts + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSPERMS = 511 // stat.h:195:1: + ALLPERMS = 4095 // stat.h:196:1: + BIG_ENDIAN = 4321 // endian.h:28:1: + BYTE_ORDER = 1234 // endian.h:30:1: + DEFFILEMODE = 438 // stat.h:197:1: + FD_SETSIZE = 1024 // select.h:73:1: + FTS_AGAIN = 1 // fts.h:139:1: + FTS_COMFOLLOW = 0x0001 // fts.h:68:1: + FTS_D = 1 // fts.h:119:1: + FTS_DC = 2 // fts.h:120:1: + FTS_DEFAULT = 3 // fts.h:121:1: + FTS_DNR = 4 // fts.h:122:1: + FTS_DONTCHDIR = 0x01 // fts.h:135:1: + FTS_DOT = 5 // fts.h:123:1: + FTS_DP = 6 // fts.h:124:1: + FTS_ERR = 7 // fts.h:125:1: + FTS_F = 8 // fts.h:126:1: + FTS_FOLLOW = 2 // fts.h:140:1: + FTS_INIT = 9 // fts.h:127:1: + FTS_LOGICAL = 0x0002 // fts.h:69:1: + FTS_NAMEONLY = 0x0100 // fts.h:78:1: + FTS_NOCHDIR = 0x0004 // fts.h:70:1: + FTS_NOINSTR = 3 // fts.h:141:1: + FTS_NOSTAT = 0x0008 // fts.h:71:1: + FTS_NS = 10 // fts.h:128:1: + FTS_NSOK = 11 // fts.h:129:1: + FTS_OPTIONMASK = 0x00ff // fts.h:76:1: + FTS_PHYSICAL = 0x0010 // fts.h:72:1: + FTS_ROOTLEVEL = 0 // fts.h:116:1: + FTS_ROOTPARENTLEVEL = -1 // fts.h:115:1: + FTS_SEEDOT = 0x0020 // fts.h:73:1: + FTS_SKIP = 4 // fts.h:142:1: + FTS_SL = 12 // fts.h:130:1: + FTS_SLNONE = 13 // fts.h:131:1: + FTS_STOP = 0x0200 // fts.h:79:1: + FTS_SYMFOLLOW = 0x02 // fts.h:136:1: + FTS_W = 14 // fts.h:132:1: + FTS_WHITEOUT = 0x0080 // fts.h:75:1: + FTS_XDEV = 0x0040 // fts.h:74:1: + LITTLE_ENDIAN = 1234 // endian.h:27:1: + PDP_ENDIAN = 3412 // endian.h:29:1: + S_BLKSIZE = 512 // stat.h:199:1: + S_IEXEC = 64 // stat.h:177:1: + S_IFBLK = 24576 // stat.h:107:1: + S_IFCHR = 8192 // stat.h:106:1: + S_IFDIR = 16384 // stat.h:105:1: + S_IFIFO = 4096 // stat.h:110:1: + S_IFLNK = 40960 // stat.h:113:1: + S_IFMT = 61440 // stat.h:104:1: + S_IFREG = 32768 // stat.h:108:1: + S_IFSOCK = 49152 // stat.h:117:1: + S_IREAD = 256 // stat.h:175:1: + S_IRGRP = 32 // stat.h:180:1: + S_IROTH = 4 // stat.h:186:1: + S_IRUSR = 256 // stat.h:168:1: + S_IRWXG = 56 // stat.h:184:1: + S_IRWXO = 7 // stat.h:190:1: + S_IRWXU = 448 // stat.h:172:1: + S_ISGID = 1024 // stat.h:161:1: + S_ISUID = 2048 // stat.h:160:1: + S_ISVTX = 512 // stat.h:165:1: + S_IWGRP = 16 // stat.h:181:1: + S_IWOTH = 2 // stat.h:187:1: + S_IWRITE = 128 // stat.h:176:1: + S_IWUSR = 128 // stat.h:169:1: + S_IXGRP = 8 // stat.h:182:1: + S_IXOTH = 1 // stat.h:188:1: + S_IXUSR = 64 // stat.h:170:1: + UTIME_NOW = 1073741823 // stat.h:206:1: + UTIME_OMIT = 1073741822 // stat.h:207:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_STAT_H = 1 // stat.h:23:1: + X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_ENDIAN_H = 1 // endian.h:19:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FTS_H = 1 // fts.h:51:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LP64 = 1 // :284:1: + X_MKNOD_VER = 0 // stat.h:390:1: + X_MKNOD_VER_LINUX = 0 // stat.h:41:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STATBUF_ST_BLKSIZE = 0 // stat.h:172:1: + X_STATBUF_ST_NSEC = 0 // stat.h:175:1: + X_STATBUF_ST_RDEV = 0 // stat.h:173:1: + X_STAT_VER = 1 // stat.h:44:1: + X_STAT_VER_KERNEL = 0 // stat.h:37:1: + X_STAT_VER_LINUX = 1 // stat.h:38:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SELECT_H = 1 // select.h:22:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_SYS_STAT_H = 1 // stat.h:23:1: + X_SYS_TYPES_H = 1 // types.h:23:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 5.6 File Characteristics + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// NB: Include guard matches what uses. + +// The Single Unix specification says that some more types are +// available here. + +// Copyright (C) 1999-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Versions of the `struct stat' data structure. + +// x86-64 versions of the `xmknod' interface. + +type Stat = struct { + Fst_dev X__dev_t + Fst_ino X__ino_t + Fst_nlink X__nlink_t + Fst_mode X__mode_t + Fst_uid X__uid_t + Fst_gid X__gid_t + F__pad0 int32 + Fst_rdev X__dev_t + Fst_size X__off_t + Fst_blksize X__blksize_t + Fst_blocks X__blkcnt_t + Fst_atim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_mtim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_ctim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + F__glibc_reserved [3]X__syscall_slong_t +} /* stat.h:46:1 */ + +// File tree traversal functions declarations. +// Copyright (C) 1994-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (c) 1989, 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. +// 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. +// +// @(#)fts.h 8.3 (Berkeley) 8/14/94 + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +type X_ftsent = struct { + Ffts_cycle uintptr + Ffts_parent uintptr + Ffts_link uintptr + Ffts_number int64 + Ffts_pointer uintptr + Ffts_accpath uintptr + Ffts_path uintptr + Ffts_errno int32 + Ffts_symfd int32 + Ffts_pathlen uint16 + Ffts_namelen uint16 + F__ccgo_pad1 [4]byte + Ffts_ino Ino_t + Ffts_dev Dev_t + Ffts_nlink Nlink_t + Ffts_level int16 + Ffts_info uint16 + Ffts_flags uint16 + Ffts_instr uint16 + Ffts_statp uintptr + Ffts_name [1]int8 + F__ccgo_pad2 [7]byte +} /* fts.h:58:2 */ + +// File tree traversal functions declarations. +// Copyright (C) 1994-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (c) 1989, 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. +// 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. +// +// @(#)fts.h 8.3 (Berkeley) 8/14/94 + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +type FTS = struct { + Ffts_cur uintptr + Ffts_child uintptr + Ffts_array uintptr + Ffts_dev Dev_t + Ffts_path uintptr + Ffts_rfd int32 + Ffts_pathlen int32 + Ffts_nitems int32 + F__ccgo_pad1 [4]byte + Ffts_compar uintptr + Ffts_options int32 + F__ccgo_pad2 [4]byte +} /* fts.h:81:3 */ + +type FTSENT = X_ftsent /* fts.h:147:3 */ + +var _ int8 /* gen.c:5:13: */ diff --git a/internal/libc/fts/fts_linux_arm64.go b/internal/libc/fts/fts_linux_arm64.go new file mode 100644 index 0000000..e85b8dc --- /dev/null +++ b/internal/libc/fts/fts_linux_arm64.go @@ -0,0 +1,2053 @@ +// Code generated by 'ccgo fts/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o fts/fts_linux_arm64.go -pkgname fts', DO NOT EDIT. + +package fts + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSPERMS = 511 + ALLPERMS = 4095 + BIG_ENDIAN = 4321 + BYTE_ORDER = 1234 + DEFFILEMODE = 438 + FD_SETSIZE = 1024 + FTS_AGAIN = 1 + FTS_COMFOLLOW = 0x0001 + FTS_D = 1 + FTS_DC = 2 + FTS_DEFAULT = 3 + FTS_DNR = 4 + FTS_DONTCHDIR = 0x01 + FTS_DOT = 5 + FTS_DP = 6 + FTS_ERR = 7 + FTS_F = 8 + FTS_FOLLOW = 2 + FTS_INIT = 9 + FTS_LOGICAL = 0x0002 + FTS_NAMEONLY = 0x0100 + FTS_NOCHDIR = 0x0004 + FTS_NOINSTR = 3 + FTS_NOSTAT = 0x0008 + FTS_NS = 10 + FTS_NSOK = 11 + FTS_OPTIONMASK = 0x00ff + FTS_PHYSICAL = 0x0010 + FTS_ROOTLEVEL = 0 + FTS_ROOTPARENTLEVEL = -1 + FTS_SEEDOT = 0x0020 + FTS_SKIP = 4 + FTS_SL = 12 + FTS_SLNONE = 13 + FTS_STOP = 0x0200 + FTS_SYMFOLLOW = 0x02 + FTS_W = 14 + FTS_WHITEOUT = 0x0080 + FTS_XDEV = 0x0040 + LITTLE_ENDIAN = 1234 + PDP_ENDIAN = 3412 + S_BLKSIZE = 512 + S_IEXEC = 64 + S_IFBLK = 24576 + S_IFCHR = 8192 + S_IFDIR = 16384 + S_IFIFO = 4096 + S_IFLNK = 40960 + S_IFMT = 61440 + S_IFREG = 32768 + S_IFSOCK = 49152 + S_IREAD = 256 + S_IRGRP = 32 + S_IROTH = 4 + S_IRUSR = 256 + S_IRWXG = 56 + S_IRWXO = 7 + S_IRWXU = 448 + S_ISGID = 1024 + S_ISUID = 2048 + S_ISVTX = 512 + S_IWGRP = 16 + S_IWOTH = 2 + S_IWRITE = 128 + S_IWUSR = 128 + S_IXGRP = 8 + S_IXOTH = 1 + S_IXUSR = 64 + UTIME_NOW = 1073741823 + UTIME_OMIT = 1073741822 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_STAT_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_FTS_H = 1 + X_GCC_SIZE_T = 0 + X_LP64 = 1 + X_MKNOD_VER = 0 + X_MKNOD_VER_LINUX = 0 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STATBUF_ST_BLKSIZE = 0 + X_STATBUF_ST_NSEC = 0 + X_STATBUF_ST_RDEV = 0 + X_STAT_VER = 0 + X_STAT_VER_KERNEL = 0 + X_STAT_VER_LINUX = 0 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_STAT_H = 1 + X_SYS_TYPES_H = 1 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We don't use `memset' because this would require a prototype and +// the array isn't too big. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 5.6 File Characteristics + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// NB: Include guard matches what uses. + +// The Single Unix specification says that some more types are +// available here. + +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// 64-bit libc uses the kernel's 'struct stat', accessed via the +// stat() syscall; 32-bit libc uses the kernel's 'struct stat64' +// and accesses it via the stat64() syscall. All the various +// APIs offered by libc use the kernel shape for their struct stat +// structure; the only difference is that 32-bit programs not +// using __USE_FILE_OFFSET64 only see the low 32 bits of some +// of the fields (specifically st_ino, st_size, and st_blocks). + +// Versions of the `xmknod' interface. + +type Stat = struct { + Fst_dev X__dev_t + Fst_ino X__ino64_t + Fst_mode X__mode_t + Fst_nlink X__nlink_t + Fst_uid X__uid_t + Fst_gid X__gid_t + Fst_rdev X__dev_t + F__pad1 X__dev_t + Fst_size X__off64_t + Fst_blksize X__blksize_t + F__pad2 int32 + Fst_blocks X__blkcnt64_t + Fst_atim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_mtim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_ctim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + F__glibc_reserved [2]int32 +} /* stat.h:58:1 */ + +// File tree traversal functions declarations. +// Copyright (C) 1994-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (c) 1989, 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. +// 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. +// +// @(#)fts.h 8.3 (Berkeley) 8/14/94 + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +type X_ftsent = struct { + Ffts_cycle uintptr + Ffts_parent uintptr + Ffts_link uintptr + Ffts_number int64 + Ffts_pointer uintptr + Ffts_accpath uintptr + Ffts_path uintptr + Ffts_errno int32 + Ffts_symfd int32 + Ffts_pathlen uint16 + Ffts_namelen uint16 + F__ccgo_pad1 [4]byte + Ffts_ino Ino_t + Ffts_dev Dev_t + Ffts_nlink Nlink_t + Ffts_level int16 + Ffts_info uint16 + Ffts_flags uint16 + Ffts_instr uint16 + F__ccgo_pad2 [4]byte + Ffts_statp uintptr + Ffts_name [1]uint8 + F__ccgo_pad3 [7]byte +} /* fts.h:58:2 */ + +// File tree traversal functions declarations. +// Copyright (C) 1994-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (c) 1989, 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. +// 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. +// +// @(#)fts.h 8.3 (Berkeley) 8/14/94 + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +type FTS = struct { + Ffts_cur uintptr + Ffts_child uintptr + Ffts_array uintptr + Ffts_dev Dev_t + Ffts_path uintptr + Ffts_rfd int32 + Ffts_pathlen int32 + Ffts_nitems int32 + F__ccgo_pad1 [4]byte + Ffts_compar uintptr + Ffts_options int32 + F__ccgo_pad2 [4]byte +} /* fts.h:81:3 */ + +type FTSENT = X_ftsent /* fts.h:147:3 */ + +var _ uint8 /* gen.c:5:13: */ diff --git a/internal/libc/grp/capi_darwin_amd64.go b/internal/libc/grp/capi_darwin_amd64.go new file mode 100644 index 0000000..f527382 --- /dev/null +++ b/internal/libc/grp/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo grp/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o grp/grp_darwin_amd64.go -pkgname grp', DO NOT EDIT. + +package grp + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/grp/capi_darwin_arm64.go b/internal/libc/grp/capi_darwin_arm64.go new file mode 100644 index 0000000..2299beb --- /dev/null +++ b/internal/libc/grp/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo grp/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o grp/grp_darwin_arm64.go -pkgname grp', DO NOT EDIT. + +package grp + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/grp/capi_linux_amd64.go b/internal/libc/grp/capi_linux_amd64.go new file mode 100644 index 0000000..39c1b89 --- /dev/null +++ b/internal/libc/grp/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo grp/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o grp/grp_linux_amd64.go -pkgname grp', DO NOT EDIT. + +package grp + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/grp/capi_linux_arm64.go b/internal/libc/grp/capi_linux_arm64.go new file mode 100644 index 0000000..1d9f5ca --- /dev/null +++ b/internal/libc/grp/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo grp/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o grp/grp_linux_arm64.go -pkgname grp', DO NOT EDIT. + +package grp + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/grp/grp_darwin_amd64.go b/internal/libc/grp/grp_darwin_amd64.go new file mode 100644 index 0000000..a4da1b3 --- /dev/null +++ b/internal/libc/grp/grp_darwin_amd64.go @@ -0,0 +1,1001 @@ +// Code generated by 'ccgo grp/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o grp/grp_darwin_amd64.go -pkgname grp', DO NOT EDIT. + +package grp + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_GRP_H_ = 0 // grp.h:43:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_PATH_GROUP = "/etc/group" // grp.h:50:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UUID_STRING_T = 0 // uuid.h:42:1: + X_UUID_T = 0 // _uuid_t.h:29:1: + X_UUID_UUID_H = 0 // uuid.h:36:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// - +// Copyright (c) 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)grp.h 8.2 (Berkeley) 1/21/94 +/* Portions copyright (c) 2000-2018 Apple Inc. All rights reserved. */ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ + +type Group = struct { + Fgr_name uintptr + Fgr_passwd uintptr + Fgr_gid Gid_t + F__ccgo_pad1 [4]byte + Fgr_mem uintptr +} /* grp.h:53:1 */ + +// Public include file for the UUID library +// +// Copyright (C) 1996, 1997, 1998 Theodore Ts'o. +// +// %Begin-Header% +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, and the entire permission notice in its entirety, +// including the disclaimer of warranties. +// 2. Redistributions in binary form must reproduce 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 ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +// WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// %End-Header% + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uuid_t = X__darwin_uuid_t /* _uuid_t.h:31:25 */ + +type Uuid_string_t = X__darwin_uuid_string_t /* uuid.h:43:33 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/grp/grp_darwin_arm64.go b/internal/libc/grp/grp_darwin_arm64.go new file mode 100644 index 0000000..f43dae0 --- /dev/null +++ b/internal/libc/grp/grp_darwin_arm64.go @@ -0,0 +1,1003 @@ +// Code generated by 'ccgo grp/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o grp/grp_darwin_arm64.go -pkgname grp', DO NOT EDIT. + +package grp + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_GRP_H_ = 0 // grp.h:43:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_PATH_GROUP = "/etc/group" // grp.h:50:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UUID_STRING_T = 0 // uuid.h:42:1: + X_UUID_T = 0 // _uuid_t.h:29:1: + X_UUID_UUID_H = 0 // uuid.h:36:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// - +// Copyright (c) 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)grp.h 8.2 (Berkeley) 1/21/94 +/* Portions copyright (c) 2000-2018 Apple Inc. All rights reserved. */ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ + +type Group = struct { + Fgr_name uintptr + Fgr_passwd uintptr + Fgr_gid Gid_t + F__ccgo_pad1 [4]byte + Fgr_mem uintptr +} /* grp.h:53:1 */ + +// Public include file for the UUID library +// +// Copyright (C) 1996, 1997, 1998 Theodore Ts'o. +// +// %Begin-Header% +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, and the entire permission notice in its entirety, +// including the disclaimer of warranties. +// 2. Redistributions in binary form must reproduce 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 ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +// WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// %End-Header% + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uuid_t = X__darwin_uuid_t /* _uuid_t.h:31:25 */ + +type Uuid_string_t = X__darwin_uuid_string_t /* uuid.h:43:33 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/grp/grp_linux_amd64.go b/internal/libc/grp/grp_linux_amd64.go new file mode 100644 index 0000000..b10efb4 --- /dev/null +++ b/internal/libc/grp/grp_linux_amd64.go @@ -0,0 +1,783 @@ +// Code generated by 'ccgo grp/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o grp/grp_linux_amd64.go -pkgname grp', DO NOT EDIT. + +package grp + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + NSS_BUFLEN_GROUP = 1024 // grp.h:114:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_GRP_H = 1 // grp.h:23:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 9.2.1 Group Database Access + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// For the Single Unix specification we must define this type here. +type Gid_t = X__gid_t /* grp.h:37:17 */ + +// The group structure. +type Group = struct { + Fgr_name uintptr + Fgr_passwd uintptr + Fgr_gid X__gid_t + F__ccgo_pad1 [4]byte + Fgr_mem uintptr +} /* grp.h:42:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/grp/grp_linux_arm64.go b/internal/libc/grp/grp_linux_arm64.go new file mode 100644 index 0000000..08c0d14 --- /dev/null +++ b/internal/libc/grp/grp_linux_arm64.go @@ -0,0 +1,851 @@ +// Code generated by 'ccgo grp/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o grp/grp_linux_arm64.go -pkgname grp', DO NOT EDIT. + +package grp + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + NSS_BUFLEN_GROUP = 1024 + X_ATFILE_SOURCE = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_GRP_H = 1 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SIZE_T_H = 0 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 9.2.1 Group Database Access + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// For the Single Unix specification we must define this type here. +type Gid_t = X__gid_t /* grp.h:37:17 */ + +// The group structure. +type Group = struct { + Fgr_name uintptr + Fgr_passwd uintptr + Fgr_gid X__gid_t + F__ccgo_pad1 [4]byte + Fgr_mem uintptr +} /* grp.h:42:1 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/honnef.co/go/netdb/netdb.go b/internal/libc/honnef.co/go/netdb/netdb.go new file mode 100644 index 0000000..aef043a --- /dev/null +++ b/internal/libc/honnef.co/go/netdb/netdb.go @@ -0,0 +1,872 @@ +// Package netdb provides a Go interface for the protoent and servent +// structures as defined in netdb.h +// +// A pure Go implementation is used by parsing /etc/protocols and +// /etc/services +// +// All return values are pointers that point to the entries in the +// original list of protocols and services. Manipulating the entries +// would affect the entire program. +package netdb // import "github.com/hanzoai/sqlite/internal/libc/honnef.co/go/netdb" + +// Modifications Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +import ( + "io/ioutil" + "os" + "strconv" + "strings" +) + +const ( + protocols = ` +# Internet (IP) protocols +# +# Updated from http://www.iana.org/assignments/protocol-numbers and other +# sources. +# New protocols will be added on request if they have been officially +# assigned by IANA and are not historical. +# If you need a huge list of used numbers please install the nmap package. + +ip 0 IP # internet protocol, pseudo protocol number +hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883] +icmp 1 ICMP # internet control message protocol +igmp 2 IGMP # Internet Group Management +ggp 3 GGP # gateway-gateway protocol +ipencap 4 IP-ENCAP # IP encapsulated in IP (officially "IP") +st 5 ST # ST datagram mode +tcp 6 TCP # transmission control protocol +egp 8 EGP # exterior gateway protocol +igp 9 IGP # any private interior gateway (Cisco) +pup 12 PUP # PARC universal packet protocol +udp 17 UDP # user datagram protocol +hmp 20 HMP # host monitoring protocol +xns-idp 22 XNS-IDP # Xerox NS IDP +rdp 27 RDP # "reliable datagram" protocol +iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905] +dccp 33 DCCP # Datagram Congestion Control Prot. [RFC4340] +xtp 36 XTP # Xpress Transfer Protocol +ddp 37 DDP # Datagram Delivery Protocol +idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport +ipv6 41 IPv6 # Internet Protocol, version 6 +ipv6-route 43 IPv6-Route # Routing Header for IPv6 +ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6 +idrp 45 IDRP # Inter-Domain Routing Protocol +rsvp 46 RSVP # Reservation Protocol +gre 47 GRE # General Routing Encapsulation +esp 50 IPSEC-ESP # Encap Security Payload [RFC2406] +ah 51 IPSEC-AH # Authentication Header [RFC2402] +skip 57 SKIP # SKIP +ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 +ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6 +ipv6-opts 60 IPv6-Opts # Destination Options for IPv6 +rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB) +vmtp 81 VMTP # Versatile Message Transport +eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco) +ospf 89 OSPFIGP # Open Shortest Path First IGP +ax.25 93 AX.25 # AX.25 frames +ipip 94 IPIP # IP-within-IP Encapsulation Protocol +etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378] +encap 98 ENCAP # Yet Another IP encapsulation [RFC1241] +# 99 # any private encryption scheme +pim 103 PIM # Protocol Independent Multicast +ipcomp 108 IPCOMP # IP Payload Compression Protocol +vrrp 112 VRRP # Virtual Router Redundancy Protocol [RFC5798] +l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661] +isis 124 ISIS # IS-IS over IPv4 +sctp 132 SCTP # Stream Control Transmission Protocol +fc 133 FC # Fibre Channel +mobility-header 135 Mobility-Header # Mobility Support for IPv6 [RFC3775] +udplite 136 UDPLite # UDP-Lite [RFC3828] +mpls-in-ip 137 MPLS-in-IP # MPLS-in-IP [RFC4023] +manet 138 # MANET Protocols [RFC5498] +hip 139 HIP # Host Identity Protocol +shim6 140 Shim6 # Shim6 Protocol [RFC5533] +wesp 141 WESP # Wrapped Encapsulating Security Payload +rohc 142 ROHC # Robust Header Compression +` + + services = ` +# Network services, Internet style +# +# Note that it is presently the policy of IANA to assign a single well-known +# port number for both TCP and UDP; hence, officially ports have two entries +# even if the protocol doesn't support UDP operations. +# +# Updated from https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml . +# +# New ports will be added on request if they have been officially assigned +# by IANA and used in the real-world or are needed by a debian package. +# If you need a huge list of used numbers please install the nmap package. + +tcpmux 1/tcp # TCP port service multiplexer +echo 7/tcp +echo 7/udp +discard 9/tcp sink null +discard 9/udp sink null +systat 11/tcp users +daytime 13/tcp +daytime 13/udp +netstat 15/tcp +qotd 17/tcp quote +msp 18/tcp # message send protocol +msp 18/udp +chargen 19/tcp ttytst source +chargen 19/udp ttytst source +ftp-data 20/tcp +ftp 21/tcp +fsp 21/udp fspd +ssh 22/tcp # SSH Remote Login Protocol +telnet 23/tcp +smtp 25/tcp mail +time 37/tcp timserver +time 37/udp timserver +rlp 39/udp resource # resource location +nameserver 42/tcp name # IEN 116 +whois 43/tcp nicname +tacacs 49/tcp # Login Host Protocol (TACACS) +tacacs 49/udp +domain 53/tcp # Domain Name Server +domain 53/udp +bootps 67/udp +bootpc 68/udp +tftp 69/udp +gopher 70/tcp # Internet Gopher +finger 79/tcp +http 80/tcp www # WorldWideWeb HTTP +link 87/tcp ttylink +kerberos 88/tcp kerberos5 krb5 kerberos-sec # Kerberos v5 +kerberos 88/udp kerberos5 krb5 kerberos-sec # Kerberos v5 +iso-tsap 102/tcp tsap # part of ISODE +acr-nema 104/tcp dicom # Digital Imag. & Comm. 300 +pop3 110/tcp pop-3 # POP version 3 +sunrpc 111/tcp portmapper # RPC 4.0 portmapper +sunrpc 111/udp portmapper +auth 113/tcp authentication tap ident +sftp 115/tcp +nntp 119/tcp readnews untp # USENET News Transfer Protocol +ntp 123/udp # Network Time Protocol +epmap 135/tcp loc-srv # DCE endpoint resolution +epmap 135/udp loc-srv +netbios-ns 137/tcp # NETBIOS Name Service +netbios-ns 137/udp +netbios-dgm 138/tcp # NETBIOS Datagram Service +netbios-dgm 138/udp +netbios-ssn 139/tcp # NETBIOS session service +netbios-ssn 139/udp +imap2 143/tcp imap # Interim Mail Access P 2 and 4 +snmp 161/tcp # Simple Net Mgmt Protocol +snmp 161/udp +snmp-trap 162/tcp snmptrap # Traps for SNMP +snmp-trap 162/udp snmptrap +cmip-man 163/tcp # ISO mgmt over IP (CMOT) +cmip-man 163/udp +cmip-agent 164/tcp +cmip-agent 164/udp +mailq 174/tcp # Mailer transport queue for Zmailer +mailq 174/udp +xdmcp 177/tcp # X Display Mgr. Control Proto +xdmcp 177/udp +nextstep 178/tcp NeXTStep NextStep # NeXTStep window +nextstep 178/udp NeXTStep NextStep # server +bgp 179/tcp # Border Gateway Protocol +irc 194/tcp # Internet Relay Chat +irc 194/udp +smux 199/tcp # SNMP Unix Multiplexer +smux 199/udp +at-rtmp 201/tcp # AppleTalk routing +at-rtmp 201/udp +at-nbp 202/tcp # AppleTalk name binding +at-nbp 202/udp +at-echo 204/tcp # AppleTalk echo +at-echo 204/udp +at-zis 206/tcp # AppleTalk zone information +at-zis 206/udp +qmtp 209/tcp # Quick Mail Transfer Protocol +qmtp 209/udp +z3950 210/tcp wais # NISO Z39.50 database +z3950 210/udp wais +ipx 213/tcp # IPX +ipx 213/udp +ptp-event 319/udp +ptp-general 320/udp +pawserv 345/tcp # Perf Analysis Workbench +pawserv 345/udp +zserv 346/tcp # Zebra server +zserv 346/udp +fatserv 347/tcp # Fatmen Server +fatserv 347/udp +rpc2portmap 369/tcp +rpc2portmap 369/udp # Coda portmapper +codaauth2 370/tcp +codaauth2 370/udp # Coda authentication server +clearcase 371/tcp Clearcase +clearcase 371/udp Clearcase +ulistserv 372/tcp # UNIX Listserv +ulistserv 372/udp +ldap 389/tcp # Lightweight Directory Access Protocol +ldap 389/udp +imsp 406/tcp # Interactive Mail Support Protocol +imsp 406/udp +svrloc 427/tcp # Server Location +svrloc 427/udp +https 443/tcp # http protocol over TLS/SSL +snpp 444/tcp # Simple Network Paging Protocol +snpp 444/udp +microsoft-ds 445/tcp # Microsoft Naked CIFS +microsoft-ds 445/udp +kpasswd 464/tcp +kpasswd 464/udp +submissions 465/tcp ssmtp smtps urd # Submission over TLS [RFC8314] +saft 487/tcp # Simple Asynchronous File Transfer +saft 487/udp +isakmp 500/tcp # IPsec - Internet Security Association +isakmp 500/udp # and Key Management Protocol +rtsp 554/tcp # Real Time Stream Control Protocol +rtsp 554/udp +nqs 607/tcp # Network Queuing system +nqs 607/udp +npmp-local 610/tcp dqs313_qmaster # npmp-local / DQS +npmp-local 610/udp dqs313_qmaster +npmp-gui 611/tcp dqs313_execd # npmp-gui / DQS +npmp-gui 611/udp dqs313_execd +hmmp-ind 612/tcp dqs313_intercell # HMMP Indication / DQS +hmmp-ind 612/udp dqs313_intercell +asf-rmcp 623/udp # ASF Remote Management and Control Protocol +qmqp 628/tcp +qmqp 628/udp +ipp 631/tcp # Internet Printing Protocol +ipp 631/udp +# +# UNIX specific services +# +exec 512/tcp +biff 512/udp comsat +login 513/tcp +who 513/udp whod +shell 514/tcp cmd # no passwords used +syslog 514/udp +printer 515/tcp spooler # line printer spooler +talk 517/udp +ntalk 518/udp +route 520/udp router routed # RIP +timed 525/udp timeserver +tempo 526/tcp newdate +courier 530/tcp rpc +conference 531/tcp chat +netnews 532/tcp readnews +netwall 533/udp # for emergency broadcasts +gdomap 538/tcp # GNUstep distributed objects +gdomap 538/udp +uucp 540/tcp uucpd # uucp daemon +klogin 543/tcp # Kerberized 'rlogin' (v5) +kshell 544/tcp krcmd # Kerberized 'rsh' (v5) +dhcpv6-client 546/tcp +dhcpv6-client 546/udp +dhcpv6-server 547/tcp +dhcpv6-server 547/udp +afpovertcp 548/tcp # AFP over TCP +afpovertcp 548/udp +idfp 549/tcp +idfp 549/udp +remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem +nntps 563/tcp snntp # NNTP over SSL +submission 587/tcp # Submission [RFC4409] +ldaps 636/tcp # LDAP over SSL +ldaps 636/udp +tinc 655/tcp # tinc control port +tinc 655/udp +silc 706/tcp +silc 706/udp +kerberos-adm 749/tcp # Kerberos 'kadmin' (v5) +# +webster 765/tcp # Network dictionary +webster 765/udp +domain-s 853/tcp # DNS over TLS [RFC7858] +domain-s 853/udp # DNS over DTLS [RFC8094] +rsync 873/tcp +ftps-data 989/tcp # FTP over SSL (data) +ftps 990/tcp +telnets 992/tcp # Telnet over SSL +imaps 993/tcp # IMAP over SSL +pop3s 995/tcp # POP-3 over SSL +# +# From "ssigned Numbers": +# +#> The Registered Ports are not controlled by the IANA and on most systems +#> can be used by ordinary user processes or programs executed by ordinary +#> users. +# +#> Ports are used in the TCP [45,106] to name the ends of logical +#> connections which carry long term conversations. For the purpose of +#> providing services to unknown callers, a service contact port is +#> defined. This list specifies the port used by the server process as its +#> contact port. While the IANA can not control uses of these ports it +#> does register or list uses of these ports as a convienence to the +#> community. +# +socks 1080/tcp # socks proxy server +socks 1080/udp +proofd 1093/tcp +proofd 1093/udp +rootd 1094/tcp +rootd 1094/udp +openvpn 1194/tcp +openvpn 1194/udp +rmiregistry 1099/tcp # Java RMI Registry +rmiregistry 1099/udp +kazaa 1214/tcp +kazaa 1214/udp +nessus 1241/tcp # Nessus vulnerability +nessus 1241/udp # assessment scanner +lotusnote 1352/tcp lotusnotes # Lotus Note +lotusnote 1352/udp lotusnotes +ms-sql-s 1433/tcp # Microsoft SQL Server +ms-sql-s 1433/udp +ms-sql-m 1434/tcp # Microsoft SQL Monitor +ms-sql-m 1434/udp +ingreslock 1524/tcp +ingreslock 1524/udp +datametrics 1645/tcp old-radius +datametrics 1645/udp old-radius +sa-msg-port 1646/tcp old-radacct +sa-msg-port 1646/udp old-radacct +kermit 1649/tcp +kermit 1649/udp +groupwise 1677/tcp +groupwise 1677/udp +l2f 1701/tcp l2tp +l2f 1701/udp l2tp +radius 1812/tcp +radius 1812/udp +radius-acct 1813/tcp radacct # Radius Accounting +radius-acct 1813/udp radacct +msnp 1863/tcp # MSN Messenger +msnp 1863/udp +unix-status 1957/tcp # remstats unix-status server +log-server 1958/tcp # remstats log server +remoteping 1959/tcp # remstats remoteping server +cisco-sccp 2000/tcp # Cisco SCCP +cisco-sccp 2000/udp +search 2010/tcp ndtp +pipe-server 2010/tcp pipe_server +nfs 2049/tcp # Network File System +nfs 2049/udp # Network File System +gnunet 2086/tcp +gnunet 2086/udp +rtcm-sc104 2101/tcp # RTCM SC-104 IANA 1/29/99 +rtcm-sc104 2101/udp +gsigatekeeper 2119/tcp +gsigatekeeper 2119/udp +gris 2135/tcp # Grid Resource Information Server +gris 2135/udp +cvspserver 2401/tcp # CVS client/server operations +cvspserver 2401/udp +venus 2430/tcp # codacon port +venus 2430/udp # Venus callback/wbc interface +venus-se 2431/tcp # tcp side effects +venus-se 2431/udp # udp sftp side effect +codasrv 2432/tcp # not used +codasrv 2432/udp # server port +codasrv-se 2433/tcp # tcp side effects +codasrv-se 2433/udp # udp sftp side effect +mon 2583/tcp # MON traps +mon 2583/udp +dict 2628/tcp # Dictionary server +dict 2628/udp +f5-globalsite 2792/tcp +f5-globalsite 2792/udp +gsiftp 2811/tcp +gsiftp 2811/udp +gpsd 2947/tcp +gpsd 2947/udp +gds-db 3050/tcp gds_db # InterBase server +gds-db 3050/udp gds_db +icpv2 3130/tcp icp # Internet Cache Protocol +icpv2 3130/udp icp +isns 3205/tcp # iSNS Server Port +isns 3205/udp # iSNS Server Port +iscsi-target 3260/tcp +mysql 3306/tcp +mysql 3306/udp +nut 3493/tcp # Network UPS Tools +nut 3493/udp +distcc 3632/tcp # distributed compiler +distcc 3632/udp +daap 3689/tcp # Digital Audio Access Protocol +daap 3689/udp +svn 3690/tcp subversion # Subversion protocol +svn 3690/udp subversion +suucp 4031/tcp # UUCP over SSL +suucp 4031/udp +sysrqd 4094/tcp # sysrq daemon +sysrqd 4094/udp +sieve 4190/tcp # ManageSieve Protocol +epmd 4369/tcp # Erlang Port Mapper Daemon +epmd 4369/udp +remctl 4373/tcp # Remote Authenticated Command Service +remctl 4373/udp +f5-iquery 4353/tcp # F5 iQuery +f5-iquery 4353/udp +ipsec-nat-t 4500/udp # IPsec NAT-Traversal [RFC3947] +iax 4569/tcp # Inter-Asterisk eXchange +iax 4569/udp +mtn 4691/tcp # monotone Netsync Protocol +mtn 4691/udp +radmin-port 4899/tcp # RAdmin Port +radmin-port 4899/udp +rfe 5002/udp # Radio Free Ethernet +rfe 5002/tcp +mmcc 5050/tcp # multimedia conference control tool (Yahoo IM) +mmcc 5050/udp +sip 5060/tcp # Session Initiation Protocol +sip 5060/udp +sip-tls 5061/tcp +sip-tls 5061/udp +aol 5190/tcp # AIM +aol 5190/udp +xmpp-client 5222/tcp jabber-client # Jabber Client Connection +xmpp-client 5222/udp jabber-client +xmpp-server 5269/tcp jabber-server # Jabber Server Connection +xmpp-server 5269/udp jabber-server +cfengine 5308/tcp +cfengine 5308/udp +mdns 5353/tcp # Multicast DNS +mdns 5353/udp +postgresql 5432/tcp postgres # PostgreSQL Database +postgresql 5432/udp postgres +freeciv 5556/tcp rptp # Freeciv gameplay +freeciv 5556/udp +amqps 5671/tcp # AMQP protocol over TLS/SSL +amqp 5672/tcp +amqp 5672/udp +amqp 5672/sctp +ggz 5688/tcp # GGZ Gaming Zone +ggz 5688/udp +x11 6000/tcp x11-0 # X Window System +x11 6000/udp x11-0 +x11-1 6001/tcp +x11-1 6001/udp +x11-2 6002/tcp +x11-2 6002/udp +x11-3 6003/tcp +x11-3 6003/udp +x11-4 6004/tcp +x11-4 6004/udp +x11-5 6005/tcp +x11-5 6005/udp +x11-6 6006/tcp +x11-6 6006/udp +x11-7 6007/tcp +x11-7 6007/udp +gnutella-svc 6346/tcp # gnutella +gnutella-svc 6346/udp +gnutella-rtr 6347/tcp # gnutella +gnutella-rtr 6347/udp +sge-qmaster 6444/tcp sge_qmaster # Grid Engine Qmaster Service +sge-qmaster 6444/udp sge_qmaster +sge-execd 6445/tcp sge_execd # Grid Engine Execution Service +sge-execd 6445/udp sge_execd +mysql-proxy 6446/tcp # MySQL Proxy +mysql-proxy 6446/udp +babel 6696/udp # Babel Routing Protocol +ircs-u 6697/tcp # Internet Relay Chat via TLS/SSL +afs3-fileserver 7000/tcp bbs # file server itself +afs3-fileserver 7000/udp bbs +afs3-callback 7001/tcp # callbacks to cache managers +afs3-callback 7001/udp +afs3-prserver 7002/tcp # users & groups database +afs3-prserver 7002/udp +afs3-vlserver 7003/tcp # volume location database +afs3-vlserver 7003/udp +afs3-kaserver 7004/tcp # AFS/Kerberos authentication +afs3-kaserver 7004/udp +afs3-volser 7005/tcp # volume managment server +afs3-volser 7005/udp +afs3-errors 7006/tcp # error interpretation service +afs3-errors 7006/udp +afs3-bos 7007/tcp # basic overseer process +afs3-bos 7007/udp +afs3-update 7008/tcp # server-to-server updater +afs3-update 7008/udp +afs3-rmtsys 7009/tcp # remote cache manager service +afs3-rmtsys 7009/udp +font-service 7100/tcp xfs # X Font Service +font-service 7100/udp xfs +http-alt 8080/tcp webcache # WWW caching service +http-alt 8080/udp +puppet 8140/tcp # The Puppet master service +bacula-dir 9101/tcp # Bacula Director +bacula-dir 9101/udp +bacula-fd 9102/tcp # Bacula File Daemon +bacula-fd 9102/udp +bacula-sd 9103/tcp # Bacula Storage Daemon +bacula-sd 9103/udp +xmms2 9667/tcp # Cross-platform Music Multiplexing System +xmms2 9667/udp +nbd 10809/tcp # Linux Network Block Device +zabbix-agent 10050/tcp # Zabbix Agent +zabbix-agent 10050/udp +zabbix-trapper 10051/tcp # Zabbix Trapper +zabbix-trapper 10051/udp +amanda 10080/tcp # amanda backup services +amanda 10080/udp +dicom 11112/tcp +hkp 11371/tcp # OpenPGP HTTP Keyserver +hkp 11371/udp +bprd 13720/tcp # VERITAS NetBackup +bprd 13720/udp +bpdbm 13721/tcp # VERITAS NetBackup +bpdbm 13721/udp +bpjava-msvc 13722/tcp # BP Java MSVC Protocol +bpjava-msvc 13722/udp +vnetd 13724/tcp # Veritas Network Utility +vnetd 13724/udp +bpcd 13782/tcp # VERITAS NetBackup +bpcd 13782/udp +vopied 13783/tcp # VERITAS NetBackup +vopied 13783/udp +db-lsp 17500/tcp # Dropbox LanSync Protocol +dcap 22125/tcp # dCache Access Protocol +gsidcap 22128/tcp # GSI dCache Access Protocol +wnn6 22273/tcp # wnn6 +wnn6 22273/udp + +# +# Datagram Delivery Protocol services +# +rtmp 1/ddp # Routing Table Maintenance Protocol +nbp 2/ddp # Name Binding Protocol +echo 4/ddp # AppleTalk Echo Protocol +zip 6/ddp # Zone Information Protocol + +#========================================================================= +# The remaining port numbers are not as allocated by IANA. +#========================================================================= + +# Kerberos (Project Athena/MIT) services +# Note that these are for Kerberos v4, and are unofficial. Sites running +# v4 should uncomment these and comment out the v5 entries above. +# +kerberos4 750/udp kerberos-iv kdc # Kerberos (server) +kerberos4 750/tcp kerberos-iv kdc +kerberos-master 751/udp kerberos_master # Kerberos authentication +kerberos-master 751/tcp +passwd-server 752/udp passwd_server # Kerberos passwd server +krb-prop 754/tcp krb_prop krb5_prop hprop # Kerberos slave propagation +krbupdate 760/tcp kreg # Kerberos registration +swat 901/tcp # swat +kpop 1109/tcp # Pop with Kerberos +knetd 2053/tcp # Kerberos de-multiplexor +zephyr-srv 2102/udp # Zephyr server +zephyr-clt 2103/udp # Zephyr serv-hm connection +zephyr-hm 2104/udp # Zephyr hostmanager +eklogin 2105/tcp # Kerberos encrypted rlogin +# Hmmm. Are we using Kv4 or Kv5 now? Worrying. +# The following is probably Kerberos v5 --- ajt@debian.org (11/02/2000) +kx 2111/tcp # X over Kerberos +iprop 2121/tcp # incremental propagation +# +# Unofficial but necessary (for NetBSD) services +# +supfilesrv 871/tcp # SUP server +supfiledbg 1127/tcp # SUP debugging + +# +# Services added for the Debian GNU/Linux distribution +# +poppassd 106/tcp # Eudora +poppassd 106/udp +moira-db 775/tcp moira_db # Moira database +moira-update 777/tcp moira_update # Moira update protocol +moira-ureg 779/udp moira_ureg # Moira user registration +spamd 783/tcp # spamassassin daemon +omirr 808/tcp omirrd # online mirror +omirr 808/udp omirrd +customs 1001/tcp # pmake customs server +customs 1001/udp +skkserv 1178/tcp # skk jisho server port +predict 1210/udp # predict -- satellite tracking +rmtcfg 1236/tcp # Gracilis Packeten remote config server +wipld 1300/tcp # Wipl network monitor +xtel 1313/tcp # french minitel +xtelw 1314/tcp # french minitel +support 1529/tcp # GNATS +cfinger 2003/tcp # GNU Finger +frox 2121/tcp # frox: caching ftp proxy +ninstall 2150/tcp # ninstall service +ninstall 2150/udp +zebrasrv 2600/tcp # zebra service +zebra 2601/tcp # zebra vty +ripd 2602/tcp # ripd vty (zebra) +ripngd 2603/tcp # ripngd vty (zebra) +ospfd 2604/tcp # ospfd vty (zebra) +bgpd 2605/tcp # bgpd vty (zebra) +ospf6d 2606/tcp # ospf6d vty (zebra) +ospfapi 2607/tcp # OSPF-API +isisd 2608/tcp # ISISd vty (zebra) +afbackup 2988/tcp # Afbackup system +afbackup 2988/udp +afmbackup 2989/tcp # Afmbackup system +afmbackup 2989/udp +xtell 4224/tcp # xtell server +fax 4557/tcp # FAX transmission service (old) +hylafax 4559/tcp # HylaFAX client-server protocol (new) +distmp3 4600/tcp # distmp3host daemon +munin 4949/tcp lrrd # Munin +enbd-cstatd 5051/tcp # ENBD client statd +enbd-sstatd 5052/tcp # ENBD server statd +pcrd 5151/tcp # PCR-1000 Daemon +noclog 5354/tcp # noclogd with TCP (nocol) +noclog 5354/udp # noclogd with UDP (nocol) +hostmon 5355/tcp # hostmon uses TCP (nocol) +hostmon 5355/udp # hostmon uses UDP (nocol) +rplay 5555/udp # RPlay audio service +nrpe 5666/tcp # Nagios Remote Plugin Executor +nsca 5667/tcp # Nagios Agent - NSCA +mrtd 5674/tcp # MRT Routing Daemon +bgpsim 5675/tcp # MRT Routing Simulator +canna 5680/tcp # cannaserver +syslog-tls 6514/tcp # Syslog over TLS [RFC5425] +sane-port 6566/tcp sane saned # SANE network scanner daemon +ircd 6667/tcp # Internet Relay Chat +zope-ftp 8021/tcp # zope management by ftp +tproxy 8081/tcp # Transparent Proxy +omniorb 8088/tcp # OmniORB +omniorb 8088/udp +clc-build-daemon 8990/tcp # Common lisp build daemon +xinetd 9098/tcp +mandelspawn 9359/udp mandelbrot # network mandelbrot +git 9418/tcp # Git Version Control System +zope 9673/tcp # zope server +webmin 10000/tcp +kamanda 10081/tcp # amanda backup services (Kerberos) +kamanda 10081/udp +amandaidx 10082/tcp # amanda backup services +amidxtape 10083/tcp # amanda backup services +smsqp 11201/tcp # Alamin SMS gateway +smsqp 11201/udp +xpilot 15345/tcp # XPilot Contact Port +xpilot 15345/udp +sgi-cmsd 17001/udp # Cluster membership services daemon +sgi-crsd 17002/udp +sgi-gcd 17003/udp # SGI Group membership daemon +sgi-cad 17004/tcp # Cluster Admin daemon +isdnlog 20011/tcp # isdn logging system +isdnlog 20011/udp +vboxd 20012/tcp # voice box system +vboxd 20012/udp +binkp 24554/tcp # binkp fidonet protocol +asp 27374/tcp # Address Search Protocol +asp 27374/udp +csync2 30865/tcp # cluster synchronization tool +dircproxy 57000/tcp # Detachable IRC Proxy +tfido 60177/tcp # fidonet EMSI over telnet +fido 60179/tcp # fidonet EMSI over TCP + +# Local services +` +) + +type Protoent struct { + Name string + Aliases []string + Number int +} + +type Servent struct { + Name string + Aliases []string + Port int + Protocol *Protoent +} + +// These variables get populated from /etc/protocols and /etc/services +// respectively. +var ( + Protocols []*Protoent + Services []*Servent +) + +func init() { + protoMap := make(map[string]*Protoent) + + // Load protocols + data, err := ioutil.ReadFile("/etc/protocols") + if err != nil { + // See https://gitlab.com/cznic/libc/-/issues/48#note_2952938171 + if !os.IsNotExist(err) && !os.IsPermission(err) { + panic(err) + } + + data = []byte(protocols) + } + + for _, line := range strings.Split(string(data), "\n") { + line = strings.TrimSpace(line) + split := strings.SplitN(line, "#", 2) + fields := strings.Fields(split[0]) + if len(fields) < 2 { + continue + } + + num, err := strconv.ParseInt(fields[1], 10, 32) + if err != nil { + // If we find lines that don't match the expected format we skip over them. + // The expected format is ... + // As we're using strings.Fields for splitting the line, failures can happen if the protocol field contains white spaces. + continue + } + + protoent := &Protoent{ + Name: fields[0], + Aliases: fields[2:], + Number: int(num), + } + Protocols = append(Protocols, protoent) + + protoMap[fields[0]] = protoent + } + + // Load services + data, err = ioutil.ReadFile("/etc/services") + if err != nil { + // See https://gitlab.com/cznic/libc/-/issues/48#note_2952938171 + if !os.IsNotExist(err) && !os.IsPermission(err) { + panic(err) + } + + data = []byte(services) + } + + for _, line := range strings.Split(string(data), "\n") { + line = strings.TrimSpace(line) + split := strings.SplitN(line, "#", 2) + fields := strings.Fields(split[0]) + if len(fields) < 2 { + continue + } + + // https://gitlab.com/cznic/libc/-/issues/25 + if strings.Index(fields[1], "/") < 0 { + continue + } + + name := fields[0] + portproto := strings.SplitN(fields[1], "/", 2) + port, err := strconv.ParseInt(portproto[0], 10, 32) + if err != nil { + // If we find lines that don't match the expected format we skip over them. + // The expected format is / [aliases ...] + // As we're using strings.Fields for splitting the line, failures can happen if the service name field contains white spaces. + continue + } + + proto := portproto[1] + aliases := fields[2:] + + Services = append(Services, &Servent{ + Name: name, + Aliases: aliases, + Port: int(port), + Protocol: protoMap[proto], + }) + } +} + +// Equal checks if two Protoents are the same, which is the case if +// their protocol numbers are identical or when both Protoents are +// nil. +func (this *Protoent) Equal(other *Protoent) bool { + if this == nil && other == nil { + return true + } + + if this == nil || other == nil { + return false + } + + return this.Number == other.Number +} + +// Equal checks if two Servents are the same, which is the case if +// their port numbers and protocols are identical or when both +// Servents are nil. +func (this *Servent) Equal(other *Servent) bool { + if this == nil && other == nil { + return true + } + + if this == nil || other == nil { + return false + } + + return this.Port == other.Port && + this.Protocol.Equal(other.Protocol) +} + +// GetProtoByNumber returns the Protoent for a given protocol number. +func GetProtoByNumber(num int) (protoent *Protoent) { + for _, protoent := range Protocols { + if protoent.Number == num { + return protoent + } + } + return nil +} + +// GetProtoByName returns the Protoent whose name or any of its +// aliases matches the argument. +func GetProtoByName(name string) (protoent *Protoent) { + for _, protoent := range Protocols { + if protoent.Name == name { + return protoent + } + + for _, alias := range protoent.Aliases { + if alias == name { + return protoent + } + } + } + + return nil +} + +// GetServByName returns the Servent for a given service name or alias +// and protocol. If the protocol is nil, the first service matching +// the service name is returned. +func GetServByName(name string, protocol *Protoent) (servent *Servent) { + for _, servent := range Services { + if !servent.Protocol.Equal(protocol) { + continue + } + + if servent.Name == name { + return servent + } + + for _, alias := range servent.Aliases { + if alias == name { + return servent + } + } + } + + return nil +} + +// GetServByPort returns the Servent for a given port number and +// protocol. If the protocol is nil, the first service matching the +// port number is returned. +func GetServByPort(port int, protocol *Protoent) *Servent { + for _, servent := range Services { + if servent.Port == port && servent.Protocol.Equal(protocol) { + return servent + } + } + + return nil +} diff --git a/internal/libc/int128.go b/internal/libc/int128.go new file mode 100644 index 0000000..d37715c --- /dev/null +++ b/internal/libc/int128.go @@ -0,0 +1,331 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Some code is copied and adjusted from +// https://github.com/lukechampine/uint128, the original LICENSE file +// reproduced below in full as of 2021-01-19: + +/* +The MIT License (MIT) + +Copyright (c) 2019 Luke Champine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + mbits "math/bits" + + "github.com/hanzoai/sqlite/internal/mathutil" +) + +type Int128 mathutil.Int128 + +var ( + int128Minus1 = Int128{-1, -1} + int128Plus1 = Int128{Lo: 1} +) + +func Int128FromFloat32(n float32) Int128 { return Int128(mathutil.NewInt128FromFloat32(n)) } +func Int128FromFloat64(n float64) Int128 { return Int128(mathutil.NewInt128FromFloat64(n)) } +func Int128FromInt16(n int16) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) } +func Int128FromInt32(n int32) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) } +func Int128FromInt64(n int64) Int128 { return Int128(mathutil.NewInt128FromInt64(n)) } +func Int128FromInt8(n int8) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) } +func Int128FromUint16(n uint16) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) } +func Int128FromUint32(n uint32) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) } +func Int128FromUint64(n uint64) Int128 { return Int128(mathutil.NewInt128FromUint64(n)) } +func Int128FromUint8(n uint8) Int128 { return Int128(mathutil.NewInt128FromInt64(int64(n))) } +func Int128FromUint128(n Uint128) Int128 { return Int128{Lo: int64(n.Lo), Hi: int64(n.Hi)} } + +func (n *Int128) LValueDec() { *n = n.Add(int128Minus1) } +func (n *Int128) LValueInc() { *n = n.Add(int128Plus1) } +func (n *Int128) LValueShl(c int32) { *n = n.Shl(c) } +func (n *Int128) LValueShr(c int32) { *n = n.Shr(c) } +func (n Int128) And(v Int128) Int128 { return Int128{n.Lo & v.Lo, n.Hi & v.Hi} } +func (n Int128) Cmp(y Int128) int { return mathutil.Int128(n).Cmp(mathutil.Int128(y)) } +func (n Int128) Int16() int16 { return int16(n.Lo) } +func (n Int128) Int32() int32 { return int32(n.Lo) } +func (n Int128) Int64() int64 { return n.Lo } +func (n Int128) Int8() int8 { return int8(n.Lo) } +func (n Int128) Or(v Int128) Int128 { return Int128{n.Lo | v.Lo, n.Hi | v.Hi} } +func (n Int128) Uint128() (r Uint128) { return Uint128{uint64(n.Lo), uint64(n.Hi)} } +func (n Int128) Uint16() uint16 { return uint16(n.Lo) } +func (n Int128) Uint32() uint32 { return uint32(n.Lo) } +func (n Int128) Uint64() uint64 { return uint64(n.Lo) } +func (n Int128) Uint8() uint8 { return uint8(n.Lo) } +func (n Int128) Xor(v Int128) Int128 { return Int128{n.Lo ^ v.Lo, n.Hi ^ v.Hi} } + +func (n Int128) Neg() Int128 { + n.Lo ^= -1 + n.Hi ^= -1 + return n.Add(int128Plus1) +} + +func (n Int128) Float32() float32 { + switch n.Hi { + case 0: + return float32(uint64(n.Lo)) + case -1: + return -float32(uint64(n.Lo)) + } + + if n.Hi < 0 { + n = n.Neg() + return -float32(n.Hi)*(1<<64) + float32(uint64(n.Lo)) + } + + return -float32(n.Hi)*(1<<64) + float32(uint64(n.Lo)) +} + +func (n Int128) Float64() float64 { + switch n.Hi { + case 0: + return float64(uint64(n.Lo)) + case -1: + return -float64(uint64(n.Lo)) + } + + if n.Hi < 0 { + n = n.Neg() + return -float64(n.Hi)*(1<<64) + float64(uint64(n.Lo)) + } + + return float64(n.Hi)*(1<<64) + float64(uint64(n.Lo)) +} + +func (n Int128) Add(m Int128) (r Int128) { + r.Lo = n.Lo + m.Lo + r.Hi = n.Hi + m.Hi + if uint64(r.Lo) < uint64(n.Lo) { + r.Hi++ + } + return r +} + +func (n Int128) Mul(m Int128) Int128 { + hi, lo := mbits.Mul64(uint64(n.Lo), uint64(m.Lo)) + _, p1 := mbits.Mul64(uint64(n.Hi), uint64(m.Lo)) + _, p3 := mbits.Mul64(uint64(n.Lo), uint64(m.Hi)) + hi, _ = mbits.Add64(hi, p1, 0) + hi, _ = mbits.Add64(hi, p3, 0) + return Int128{int64(lo), int64(hi)} +} + +func (n Int128) Shl(c int32) (r Int128) { + if c > 64 { + r.Lo = 0 + r.Hi = n.Lo << (c - 64) + } else { + r.Lo = n.Lo << c + r.Hi = n.Hi<>(64-c) + } + return r +} + +func (n Int128) Shr(c int32) (r Int128) { + if c > 64 { + r.Lo = n.Hi >> (c - 64) + switch { + case n.Hi < 0: + r.Hi = -1 + default: + r.Hi = 0 + } + } else { + r.Lo = n.Lo>>c | n.Hi<<(64-c) + r.Hi = n.Hi >> c + } + return r +} + +type Uint128 mathutil.Uint128 + +func Uint128FromFloat32(n float32) Uint128 { return Uint128(mathutil.NewUint128FromFloat32(n)) } +func Uint128FromFloat64(n float64) Uint128 { return Uint128(mathutil.NewUint128FromFloat64(n)) } +func Uint128FromInt128(n Int128) Uint128 { return Uint128{Lo: uint64(n.Lo), Hi: uint64(n.Hi)} } +func Uint128FromInt16(n int16) Uint128 { return Uint128FromInt64(int64(n)) } +func Uint128FromInt32(n int32) Uint128 { return Uint128FromInt64(int64(n)) } +func Uint128FromInt8(n int8) Uint128 { return Uint128FromInt64(int64(n)) } +func Uint128FromUint16(n uint16) Uint128 { return Uint128{Lo: uint64(n)} } +func Uint128FromUint32(n uint32) Uint128 { return Uint128{Lo: uint64(n)} } +func Uint128FromUint64(n uint64) Uint128 { return Uint128{Lo: n} } +func Uint128FromUint8(n uint8) Uint128 { return Uint128{Lo: uint64(n)} } + +func Uint128FromInt64(n int64) (r Uint128) { + r.Lo = uint64(n) + if n < 0 { + r.Hi = ^uint64(0) + } + return r +} + +func (n *Uint128) LValueShl(c int32) { *n = n.Shl(c) } +func (n *Uint128) LValueShr(c int32) { *n = n.Shr(c) } +func (n Uint128) And(m Uint128) Uint128 { return Uint128{n.Lo & m.Lo, n.Hi & m.Hi} } +func (n Uint128) Int128() Int128 { return Int128{int64(n.Lo), int64(n.Hi)} } +func (n Uint128) Int16() int16 { return int16(n.Lo) } +func (n Uint128) Int32() int32 { return int32(n.Lo) } +func (n Uint128) Int64() int64 { return int64(n.Lo) } +func (n Uint128) Int8() int8 { return int8(n.Lo) } +func (n Uint128) Or(m Uint128) Uint128 { return Uint128{n.Lo | m.Lo, n.Hi | m.Hi} } +func (n Uint128) Uint16() uint16 { return uint16(n.Lo) } +func (n Uint128) Uint32() uint32 { return uint32(n.Lo) } +func (n Uint128) Uint64() uint64 { return n.Lo } +func (n Uint128) Uint8() uint8 { return uint8(n.Lo) } +func (n Uint128) Xor(m Uint128) Uint128 { return Uint128{n.Lo ^ m.Lo, n.Hi ^ m.Hi} } + +func (n Uint128) Add(m Uint128) (r Uint128) { + var carry uint64 + r.Lo, carry = mbits.Add64(n.Lo, m.Lo, 0) + r.Hi, _ = mbits.Add64(n.Hi, m.Hi, carry) + return r +} + +func (n Uint128) Mul(m Uint128) Uint128 { + hi, lo := mbits.Mul64(n.Lo, m.Lo) + _, p1 := mbits.Mul64(n.Hi, m.Lo) + _, p3 := mbits.Mul64(n.Lo, m.Hi) + hi, _ = mbits.Add64(hi, p1, 0) + hi, _ = mbits.Add64(hi, p3, 0) + return Uint128{lo, hi} +} + +func (n Uint128) Shr(c int32) (r Uint128) { + if c > 64 { + r.Lo = n.Hi >> (c - 64) + r.Hi = 0 + } else { + r.Lo = n.Lo>>c | n.Hi<<(64-c) + r.Hi = n.Hi >> c + } + return r +} + +func (n Uint128) mulOvf(m Uint128) (_ Uint128, ovf bool) { + hi, lo := mbits.Mul64(n.Lo, m.Lo) + p0, p1 := mbits.Mul64(n.Hi, m.Lo) + p2, p3 := mbits.Mul64(n.Lo, m.Hi) + hi, c0 := mbits.Add64(hi, p1, 0) + hi, c1 := mbits.Add64(hi, p3, 0) + ovf = p0 != 0 || p2 != 0 || c0 != 0 || c1 != 0 + return Uint128{lo, hi}, ovf +} + +func (n Uint128) quoRem(m Uint128) (q, r Uint128) { + if m.Hi == 0 { + var r64 uint64 + q, r64 = n.quoRem64(m.Lo) + r = Uint128FromUint64(r64) + } else { + // generate a "trial quotient," guaranteed to be within 1 of the actual + // quotient, then adjust. + nz := mbits.LeadingZeros64(m.Hi) + v1 := m.Shl(int32(nz)) + u1 := n.Shr(1) + tq, _ := mbits.Div64(u1.Hi, u1.Lo, v1.Hi) + tq >>= 63 - nz + if tq != 0 { + tq-- + } + q = Uint128FromUint64(tq) + // calculate remainder using trial quotient, then adjust if remainder is + // greater than divisor + r = n.Sub(m.mul64(tq)) + if r.Cmp(m) >= 0 { + q = q.add64(1) + r = r.Sub(m) + } + } + return +} + +func (n Uint128) quoRem64(m uint64) (q Uint128, r uint64) { + if n.Hi < m { + q.Lo, r = mbits.Div64(n.Hi, n.Lo, m) + } else { + q.Hi, r = mbits.Div64(0, n.Hi, m) + q.Lo, r = mbits.Div64(r, n.Lo, m) + } + return +} + +func (n Uint128) Div(m Uint128) (r Uint128) { + r, _ = n.quoRem(m) + return r +} + +func (n Uint128) Shl(c int32) (r Uint128) { + if c > 64 { + r.Lo = 0 + r.Hi = n.Lo << (c - 64) + } else { + r.Lo = n.Lo << c + r.Hi = n.Hi<>(64-c) + } + return +} + +func (n Uint128) Sub(m Uint128) Uint128 { + lo, borrow := mbits.Sub64(n.Lo, m.Lo, 0) + hi, _ := mbits.Sub64(n.Hi, m.Hi, borrow) + return Uint128{lo, hi} +} + +func (n Uint128) mul64(m uint64) Uint128 { + hi, lo := mbits.Mul64(n.Lo, m) + _, p1 := mbits.Mul64(n.Hi, m) + hi, _ = mbits.Add64(hi, p1, 0) + return Uint128{lo, hi} +} + +func (n Uint128) Cmp(m Uint128) int { + if n == m { + return 0 + } else if n.Hi < m.Hi || (n.Hi == m.Hi && n.Lo < m.Lo) { + return -1 + } else { + return 1 + } +} + +func (n Uint128) add64(m uint64) Uint128 { + lo, carry := mbits.Add64(n.Lo, m, 0) + hi, _ := mbits.Add64(n.Hi, 0, carry) + return Uint128{lo, hi} +} + +func (n Uint128) Float32() float32 { + if n.Hi == 0 { + return float32(n.Lo) + } + + return float32(n.Hi)*(1<<64) + float32(n.Lo) +} + +func (n Uint128) Float64() float64 { + if n.Hi == 0 { + return float64(n.Lo) + } + + return float64(n.Hi)*(1<<64) + float64(n.Lo) +} diff --git a/internal/libc/ioutil_darwin.go b/internal/libc/ioutil_darwin.go new file mode 100644 index 0000000..ae6fd43 --- /dev/null +++ b/internal/libc/ioutil_darwin.go @@ -0,0 +1,65 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE-GO file. + +// Modifications Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "fmt" + "os" + "sync" + "time" + "unsafe" + + "golang.org/x/sys/unix" +) + +// Random number state. +// We generate random temporary file names so that there's a good +// chance the file doesn't exist yet - keeps the number of tries in +// TempFile to a minimum. +var randState uint32 +var randStateMu sync.Mutex + +func reseed() uint32 { + return uint32(time.Now().UnixNano() + int64(os.Getpid())) +} + +func nextRandom(x uintptr) { + randStateMu.Lock() + r := randState + if r == 0 { + r = reseed() + } + r = r*1664525 + 1013904223 // constants from Numerical Recipes + randState = r + randStateMu.Unlock() + copy((*RawMem)(unsafe.Pointer(x))[:6:6], fmt.Sprintf("%06d", int(1e9+r%1e9)%1e6)) +} + +func tempFile(s, x uintptr, _ int32) (fd int, err error) { + const maxTry = 10000 + nconflict := 0 + for i := 0; i < maxTry; i++ { + nextRandom(x) + if fd, err = unix.Open(GoString(s), os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600); err == nil { + return fd, nil + } + + if !os.IsExist(err) { + return -1, err + } + + if nconflict++; nconflict > 10 { + randStateMu.Lock() + randState = reseed() + nconflict = 0 + randStateMu.Unlock() + } + } + return -1, err +} diff --git a/internal/libc/langinfo/capi_darwin_amd64.go b/internal/libc/langinfo/capi_darwin_amd64.go new file mode 100644 index 0000000..f9459e9 --- /dev/null +++ b/internal/libc/langinfo/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo langinfo/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o langinfo/langinfo_darwin_amd64.go -pkgname langinfo', DO NOT EDIT. + +package langinfo + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/langinfo/capi_darwin_arm64.go b/internal/libc/langinfo/capi_darwin_arm64.go new file mode 100644 index 0000000..a7a9ae8 --- /dev/null +++ b/internal/libc/langinfo/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo langinfo/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o langinfo/langinfo_darwin_arm64.go -pkgname langinfo', DO NOT EDIT. + +package langinfo + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/langinfo/capi_linux_amd64.go b/internal/libc/langinfo/capi_linux_amd64.go new file mode 100644 index 0000000..f9c787b --- /dev/null +++ b/internal/libc/langinfo/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo langinfo/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o langinfo/langinfo_linux_amd64.go -pkgname langinfo', DO NOT EDIT. + +package langinfo + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/langinfo/capi_linux_arm64.go b/internal/libc/langinfo/capi_linux_arm64.go new file mode 100644 index 0000000..de9629f --- /dev/null +++ b/internal/libc/langinfo/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo langinfo/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o langinfo/langinfo_linux_arm64.go -pkgname langinfo', DO NOT EDIT. + +package langinfo + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/langinfo/langinfo_darwin_amd64.go b/internal/libc/langinfo/langinfo_darwin_amd64.go new file mode 100644 index 0000000..5388e76 --- /dev/null +++ b/internal/libc/langinfo/langinfo_darwin_amd64.go @@ -0,0 +1,916 @@ +// Code generated by 'ccgo langinfo/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o langinfo/langinfo_darwin_amd64.go -pkgname langinfo', DO NOT EDIT. + +package langinfo + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ABDAY_1 = 14 // langinfo.h:53:1: + ABDAY_2 = 15 // langinfo.h:54:1: + ABDAY_3 = 16 // langinfo.h:55:1: + ABDAY_4 = 17 // langinfo.h:56:1: + ABDAY_5 = 18 // langinfo.h:57:1: + ABDAY_6 = 19 // langinfo.h:58:1: + ABDAY_7 = 20 // langinfo.h:59:1: + ABMON_1 = 33 // langinfo.h:76:1: + ABMON_10 = 42 // langinfo.h:85:1: + ABMON_11 = 43 // langinfo.h:86:1: + ABMON_12 = 44 // langinfo.h:87:1: + ABMON_2 = 34 // langinfo.h:77:1: + ABMON_3 = 35 // langinfo.h:78:1: + ABMON_4 = 36 // langinfo.h:79:1: + ABMON_5 = 37 // langinfo.h:80:1: + ABMON_6 = 38 // langinfo.h:81:1: + ABMON_7 = 39 // langinfo.h:82:1: + ABMON_8 = 40 // langinfo.h:83:1: + ABMON_9 = 41 // langinfo.h:84:1: + ALT_DIGITS = 49 // langinfo.h:93:1: + AM_STR = 5 // langinfo.h:40:1: + CODESET = 0 // langinfo.h:35:1: + CRNCYSTR = 56 // langinfo.h:106:1: + DAY_1 = 7 // langinfo.h:44:1: + DAY_2 = 8 // langinfo.h:45:1: + DAY_3 = 9 // langinfo.h:46:1: + DAY_4 = 10 // langinfo.h:47:1: + DAY_5 = 11 // langinfo.h:48:1: + DAY_6 = 12 // langinfo.h:49:1: + DAY_7 = 13 // langinfo.h:50:1: + D_FMT = 2 // langinfo.h:37:1: + D_MD_ORDER = 57 // langinfo.h:109:1: + D_T_FMT = 1 // langinfo.h:36:1: + ERA = 45 // langinfo.h:89:1: + ERA_D_FMT = 46 // langinfo.h:90:1: + ERA_D_T_FMT = 47 // langinfo.h:91:1: + ERA_T_FMT = 48 // langinfo.h:92:1: + MON_1 = 21 // langinfo.h:62:1: + MON_10 = 30 // langinfo.h:71:1: + MON_11 = 31 // langinfo.h:72:1: + MON_12 = 32 // langinfo.h:73:1: + MON_2 = 22 // langinfo.h:63:1: + MON_3 = 23 // langinfo.h:64:1: + MON_4 = 24 // langinfo.h:65:1: + MON_5 = 25 // langinfo.h:66:1: + MON_6 = 26 // langinfo.h:67:1: + MON_7 = 27 // langinfo.h:68:1: + MON_8 = 28 // langinfo.h:69:1: + MON_9 = 29 // langinfo.h:70:1: + NOEXPR = 53 // langinfo.h:99:1: + NOSTR = 55 // langinfo.h:103:1: + PM_STR = 6 // langinfo.h:41:1: + RADIXCHAR = 50 // langinfo.h:95:1: + THOUSEP = 51 // langinfo.h:96:1: + T_FMT = 3 // langinfo.h:38:1: + T_FMT_AMPM = 4 // langinfo.h:39:1: + YESEXPR = 52 // langinfo.h:98:1: + YESSTR = 54 // langinfo.h:102:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_LANGINFO_H_ = 0 // langinfo.h:30:1: + X_LP64 = 1 // :1:1: + X_NL_ITEM = 0 // _nl_item.h:30:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// - +// Copyright (c) 2001 Alexey Zelkin +// 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. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// $FreeBSD: /repoman/r/ncvs/src/include/langinfo.h,v 1.6 2002/09/18 05:54:25 mike Exp $ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type Nl_item = X__darwin_nl_item /* _nl_item.h:32:26 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/langinfo/langinfo_darwin_arm64.go b/internal/libc/langinfo/langinfo_darwin_arm64.go new file mode 100644 index 0000000..b18da5b --- /dev/null +++ b/internal/libc/langinfo/langinfo_darwin_arm64.go @@ -0,0 +1,918 @@ +// Code generated by 'ccgo langinfo/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o langinfo/langinfo_darwin_arm64.go -pkgname langinfo', DO NOT EDIT. + +package langinfo + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ABDAY_1 = 14 // langinfo.h:53:1: + ABDAY_2 = 15 // langinfo.h:54:1: + ABDAY_3 = 16 // langinfo.h:55:1: + ABDAY_4 = 17 // langinfo.h:56:1: + ABDAY_5 = 18 // langinfo.h:57:1: + ABDAY_6 = 19 // langinfo.h:58:1: + ABDAY_7 = 20 // langinfo.h:59:1: + ABMON_1 = 33 // langinfo.h:76:1: + ABMON_10 = 42 // langinfo.h:85:1: + ABMON_11 = 43 // langinfo.h:86:1: + ABMON_12 = 44 // langinfo.h:87:1: + ABMON_2 = 34 // langinfo.h:77:1: + ABMON_3 = 35 // langinfo.h:78:1: + ABMON_4 = 36 // langinfo.h:79:1: + ABMON_5 = 37 // langinfo.h:80:1: + ABMON_6 = 38 // langinfo.h:81:1: + ABMON_7 = 39 // langinfo.h:82:1: + ABMON_8 = 40 // langinfo.h:83:1: + ABMON_9 = 41 // langinfo.h:84:1: + ALT_DIGITS = 49 // langinfo.h:93:1: + AM_STR = 5 // langinfo.h:40:1: + CODESET = 0 // langinfo.h:35:1: + CRNCYSTR = 56 // langinfo.h:106:1: + DAY_1 = 7 // langinfo.h:44:1: + DAY_2 = 8 // langinfo.h:45:1: + DAY_3 = 9 // langinfo.h:46:1: + DAY_4 = 10 // langinfo.h:47:1: + DAY_5 = 11 // langinfo.h:48:1: + DAY_6 = 12 // langinfo.h:49:1: + DAY_7 = 13 // langinfo.h:50:1: + D_FMT = 2 // langinfo.h:37:1: + D_MD_ORDER = 57 // langinfo.h:109:1: + D_T_FMT = 1 // langinfo.h:36:1: + ERA = 45 // langinfo.h:89:1: + ERA_D_FMT = 46 // langinfo.h:90:1: + ERA_D_T_FMT = 47 // langinfo.h:91:1: + ERA_T_FMT = 48 // langinfo.h:92:1: + MON_1 = 21 // langinfo.h:62:1: + MON_10 = 30 // langinfo.h:71:1: + MON_11 = 31 // langinfo.h:72:1: + MON_12 = 32 // langinfo.h:73:1: + MON_2 = 22 // langinfo.h:63:1: + MON_3 = 23 // langinfo.h:64:1: + MON_4 = 24 // langinfo.h:65:1: + MON_5 = 25 // langinfo.h:66:1: + MON_6 = 26 // langinfo.h:67:1: + MON_7 = 27 // langinfo.h:68:1: + MON_8 = 28 // langinfo.h:69:1: + MON_9 = 29 // langinfo.h:70:1: + NOEXPR = 53 // langinfo.h:99:1: + NOSTR = 55 // langinfo.h:103:1: + PM_STR = 6 // langinfo.h:41:1: + RADIXCHAR = 50 // langinfo.h:95:1: + THOUSEP = 51 // langinfo.h:96:1: + T_FMT = 3 // langinfo.h:38:1: + T_FMT_AMPM = 4 // langinfo.h:39:1: + YESEXPR = 52 // langinfo.h:98:1: + YESSTR = 54 // langinfo.h:102:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_LANGINFO_H_ = 0 // langinfo.h:30:1: + X_LP64 = 1 // :1:1: + X_NL_ITEM = 0 // _nl_item.h:30:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// - +// Copyright (c) 2001 Alexey Zelkin +// 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. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// $FreeBSD: /repoman/r/ncvs/src/include/langinfo.h,v 1.6 2002/09/18 05:54:25 mike Exp $ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type Nl_item = X__darwin_nl_item /* _nl_item.h:32:26 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/langinfo/langinfo_linux_amd64.go b/internal/libc/langinfo/langinfo_linux_amd64.go new file mode 100644 index 0000000..52273c6 --- /dev/null +++ b/internal/libc/langinfo/langinfo_linux_amd64.go @@ -0,0 +1,1058 @@ +// Code generated by 'ccgo langinfo/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o langinfo/langinfo_linux_amd64.go -pkgname langinfo', DO NOT EDIT. + +package langinfo + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + NL_CAT_LOCALE = 1 // nl_types.h:27:1: + NL_SETD = 1 // nl_types.h:24:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_LOCALE_H = 1 // locale.h:24:1: + X_BITS_TYPES_LOCALE_T_H = 1 // locale_t.h:20:1: + X_BITS_TYPES___LOCALE_T_H = 1 // __locale_t.h:21:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LANGINFO_H = 1 // langinfo.h:20:1: + X_LP64 = 1 // :284:1: + X_NL_TYPES_H = 1 // nl_types.h:19:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// Definition of locale category symbol values. +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Construct an `nl_item' value for `nl_langinfo' from a locale category +// (LC_*) and an item index within the category. Some code may depend on +// the item values within a category increasing monotonically with the +// indices. + +// Extract the category and item index from a constructed `nl_item' value. + +// Enumeration of locale items that can be queried with `nl_langinfo'. +const ( /* langinfo.h:41:1: */ + // LC_TIME category: date and time formatting. + + // Abbreviated days of the week. + ABDAY_1 = 131072 // Sun + ABDAY_2 = 131073 + ABDAY_3 = 131074 + ABDAY_4 = 131075 + ABDAY_5 = 131076 + ABDAY_6 = 131077 + ABDAY_7 = 131078 + + // Long-named days of the week. + DAY_1 = 131079 // Sunday + DAY_2 = 131080 // Monday + DAY_3 = 131081 // Tuesday + DAY_4 = 131082 // Wednesday + DAY_5 = 131083 // Thursday + DAY_6 = 131084 // Friday + DAY_7 = 131085 // Saturday + + // Abbreviated month names, in the grammatical form used when the month + // is a part of a complete date. + ABMON_1 = 131086 // Jan + ABMON_2 = 131087 + ABMON_3 = 131088 + ABMON_4 = 131089 + ABMON_5 = 131090 + ABMON_6 = 131091 + ABMON_7 = 131092 + ABMON_8 = 131093 + ABMON_9 = 131094 + ABMON_10 = 131095 + ABMON_11 = 131096 + ABMON_12 = 131097 + + // Long month names, in the grammatical form used when the month + // is a part of a complete date. + MON_1 = 131098 // January + MON_2 = 131099 + MON_3 = 131100 + MON_4 = 131101 + MON_5 = 131102 + MON_6 = 131103 + MON_7 = 131104 + MON_8 = 131105 + MON_9 = 131106 + MON_10 = 131107 + MON_11 = 131108 + MON_12 = 131109 + + AM_STR = 131110 // Ante meridiem string. + PM_STR = 131111 // Post meridiem string. + + D_T_FMT = 131112 // Date and time format for strftime. + D_FMT = 131113 // Date format for strftime. + T_FMT = 131114 // Time format for strftime. + T_FMT_AMPM = 131115 // 12-hour time format for strftime. + + ERA = 131116 // Alternate era. + X__ERA_YEAR = 131117 // Year in alternate era format. + ERA_D_FMT = 131118 // Date in alternate era format. + ALT_DIGITS = 131119 // Alternate symbols for digits. + ERA_D_T_FMT = 131120 // Date and time in alternate era format. + ERA_T_FMT = 131121 // Time in alternate era format. + + X_NL_TIME_ERA_NUM_ENTRIES = 131122 // Number entries in the era arrays. + X_NL_TIME_ERA_ENTRIES = 131123 // Structure with era entries in usable form. + + X_NL_WABDAY_1 = 131124 // Sun + X_NL_WABDAY_2 = 131125 + X_NL_WABDAY_3 = 131126 + X_NL_WABDAY_4 = 131127 + X_NL_WABDAY_5 = 131128 + X_NL_WABDAY_6 = 131129 + X_NL_WABDAY_7 = 131130 + + // Long-named days of the week. + X_NL_WDAY_1 = 131131 // Sunday + X_NL_WDAY_2 = 131132 // Monday + X_NL_WDAY_3 = 131133 // Tuesday + X_NL_WDAY_4 = 131134 // Wednesday + X_NL_WDAY_5 = 131135 // Thursday + X_NL_WDAY_6 = 131136 // Friday + X_NL_WDAY_7 = 131137 // Saturday + + // Abbreviated month names, in the grammatical form used when the month + // is a part of a complete date. + X_NL_WABMON_1 = 131138 // Jan + X_NL_WABMON_2 = 131139 + X_NL_WABMON_3 = 131140 + X_NL_WABMON_4 = 131141 + X_NL_WABMON_5 = 131142 + X_NL_WABMON_6 = 131143 + X_NL_WABMON_7 = 131144 + X_NL_WABMON_8 = 131145 + X_NL_WABMON_9 = 131146 + X_NL_WABMON_10 = 131147 + X_NL_WABMON_11 = 131148 + X_NL_WABMON_12 = 131149 + + // Long month names, in the grammatical form used when the month + // is a part of a complete date. + X_NL_WMON_1 = 131150 // January + X_NL_WMON_2 = 131151 + X_NL_WMON_3 = 131152 + X_NL_WMON_4 = 131153 + X_NL_WMON_5 = 131154 + X_NL_WMON_6 = 131155 + X_NL_WMON_7 = 131156 + X_NL_WMON_8 = 131157 + X_NL_WMON_9 = 131158 + X_NL_WMON_10 = 131159 + X_NL_WMON_11 = 131160 + X_NL_WMON_12 = 131161 + + X_NL_WAM_STR = 131162 // Ante meridiem string. + X_NL_WPM_STR = 131163 // Post meridiem string. + + X_NL_WD_T_FMT = 131164 // Date and time format for strftime. + X_NL_WD_FMT = 131165 // Date format for strftime. + X_NL_WT_FMT = 131166 // Time format for strftime. + X_NL_WT_FMT_AMPM = 131167 // 12-hour time format for strftime. + + X_NL_WERA_YEAR = 131168 // Year in alternate era format. + X_NL_WERA_D_FMT = 131169 // Date in alternate era format. + X_NL_WALT_DIGITS = 131170 // Alternate symbols for digits. + X_NL_WERA_D_T_FMT = 131171 // Date and time in alternate era format. + X_NL_WERA_T_FMT = 131172 // Time in alternate era format. + + X_NL_TIME_WEEK_NDAYS = 131173 + X_NL_TIME_WEEK_1STDAY = 131174 + X_NL_TIME_WEEK_1STWEEK = 131175 + X_NL_TIME_FIRST_WEEKDAY = 131176 + X_NL_TIME_FIRST_WORKDAY = 131177 + X_NL_TIME_CAL_DIRECTION = 131178 + X_NL_TIME_TIMEZONE = 131179 + + X_DATE_FMT = 131180 // strftime format for date. + X_NL_W_DATE_FMT = 131181 + + X_NL_TIME_CODESET = 131182 + + // Long month names, in the grammatical form used when the month + // is named by itself. + X__ALTMON_1 = 131183 // January + X__ALTMON_2 = 131184 + X__ALTMON_3 = 131185 + X__ALTMON_4 = 131186 + X__ALTMON_5 = 131187 + X__ALTMON_6 = 131188 + X__ALTMON_7 = 131189 + X__ALTMON_8 = 131190 + X__ALTMON_9 = 131191 + X__ALTMON_10 = 131192 + X__ALTMON_11 = 131193 + X__ALTMON_12 = 131194 + + // Long month names, in the grammatical form used when the month + // is named by itself. + X_NL_WALTMON_1 = 131195 // January + X_NL_WALTMON_2 = 131196 + X_NL_WALTMON_3 = 131197 + X_NL_WALTMON_4 = 131198 + X_NL_WALTMON_5 = 131199 + X_NL_WALTMON_6 = 131200 + X_NL_WALTMON_7 = 131201 + X_NL_WALTMON_8 = 131202 + X_NL_WALTMON_9 = 131203 + X_NL_WALTMON_10 = 131204 + X_NL_WALTMON_11 = 131205 + X_NL_WALTMON_12 = 131206 + + // Abbreviated month names, in the grammatical form used when the month + // is named by itself. + X_NL_ABALTMON_1 = 131207 // Jan + X_NL_ABALTMON_2 = 131208 + X_NL_ABALTMON_3 = 131209 + X_NL_ABALTMON_4 = 131210 + X_NL_ABALTMON_5 = 131211 + X_NL_ABALTMON_6 = 131212 + X_NL_ABALTMON_7 = 131213 + X_NL_ABALTMON_8 = 131214 + X_NL_ABALTMON_9 = 131215 + X_NL_ABALTMON_10 = 131216 + X_NL_ABALTMON_11 = 131217 + X_NL_ABALTMON_12 = 131218 + + // Abbreviated month names, in the grammatical form used when the month + // is named by itself. + X_NL_WABALTMON_1 = 131219 // Jan + X_NL_WABALTMON_2 = 131220 + X_NL_WABALTMON_3 = 131221 + X_NL_WABALTMON_4 = 131222 + X_NL_WABALTMON_5 = 131223 + X_NL_WABALTMON_6 = 131224 + X_NL_WABALTMON_7 = 131225 + X_NL_WABALTMON_8 = 131226 + X_NL_WABALTMON_9 = 131227 + X_NL_WABALTMON_10 = 131228 + X_NL_WABALTMON_11 = 131229 + X_NL_WABALTMON_12 = 131230 + + X_NL_NUM_LC_TIME = 131231 // Number of indices in LC_TIME category. + + // LC_COLLATE category: text sorting. + // This information is accessed by the strcoll and strxfrm functions. + // These `nl_langinfo' names are used only internally. + X_NL_COLLATE_NRULES = 196608 + X_NL_COLLATE_RULESETS = 196609 + X_NL_COLLATE_TABLEMB = 196610 + X_NL_COLLATE_WEIGHTMB = 196611 + X_NL_COLLATE_EXTRAMB = 196612 + X_NL_COLLATE_INDIRECTMB = 196613 + X_NL_COLLATE_GAP1 = 196614 + X_NL_COLLATE_GAP2 = 196615 + X_NL_COLLATE_GAP3 = 196616 + X_NL_COLLATE_TABLEWC = 196617 + X_NL_COLLATE_WEIGHTWC = 196618 + X_NL_COLLATE_EXTRAWC = 196619 + X_NL_COLLATE_INDIRECTWC = 196620 + X_NL_COLLATE_SYMB_HASH_SIZEMB = 196621 + X_NL_COLLATE_SYMB_TABLEMB = 196622 + X_NL_COLLATE_SYMB_EXTRAMB = 196623 + X_NL_COLLATE_COLLSEQMB = 196624 + X_NL_COLLATE_COLLSEQWC = 196625 + X_NL_COLLATE_CODESET = 196626 + X_NL_NUM_LC_COLLATE = 196627 + + // LC_CTYPE category: character classification. + // This information is accessed by the functions in . + // These `nl_langinfo' names are used only internally. + X_NL_CTYPE_CLASS = 0 + X_NL_CTYPE_TOUPPER = 1 + X_NL_CTYPE_GAP1 = 2 + X_NL_CTYPE_TOLOWER = 3 + X_NL_CTYPE_GAP2 = 4 + X_NL_CTYPE_CLASS32 = 5 + X_NL_CTYPE_GAP3 = 6 + X_NL_CTYPE_GAP4 = 7 + X_NL_CTYPE_GAP5 = 8 + X_NL_CTYPE_GAP6 = 9 + X_NL_CTYPE_CLASS_NAMES = 10 + X_NL_CTYPE_MAP_NAMES = 11 + X_NL_CTYPE_WIDTH = 12 + X_NL_CTYPE_MB_CUR_MAX = 13 + X_NL_CTYPE_CODESET_NAME = 14 + CODESET = 14 + X_NL_CTYPE_TOUPPER32 = 15 + X_NL_CTYPE_TOLOWER32 = 16 + X_NL_CTYPE_CLASS_OFFSET = 17 + X_NL_CTYPE_MAP_OFFSET = 18 + X_NL_CTYPE_INDIGITS_MB_LEN = 19 + X_NL_CTYPE_INDIGITS0_MB = 20 + X_NL_CTYPE_INDIGITS1_MB = 21 + X_NL_CTYPE_INDIGITS2_MB = 22 + X_NL_CTYPE_INDIGITS3_MB = 23 + X_NL_CTYPE_INDIGITS4_MB = 24 + X_NL_CTYPE_INDIGITS5_MB = 25 + X_NL_CTYPE_INDIGITS6_MB = 26 + X_NL_CTYPE_INDIGITS7_MB = 27 + X_NL_CTYPE_INDIGITS8_MB = 28 + X_NL_CTYPE_INDIGITS9_MB = 29 + X_NL_CTYPE_INDIGITS_WC_LEN = 30 + X_NL_CTYPE_INDIGITS0_WC = 31 + X_NL_CTYPE_INDIGITS1_WC = 32 + X_NL_CTYPE_INDIGITS2_WC = 33 + X_NL_CTYPE_INDIGITS3_WC = 34 + X_NL_CTYPE_INDIGITS4_WC = 35 + X_NL_CTYPE_INDIGITS5_WC = 36 + X_NL_CTYPE_INDIGITS6_WC = 37 + X_NL_CTYPE_INDIGITS7_WC = 38 + X_NL_CTYPE_INDIGITS8_WC = 39 + X_NL_CTYPE_INDIGITS9_WC = 40 + X_NL_CTYPE_OUTDIGIT0_MB = 41 + X_NL_CTYPE_OUTDIGIT1_MB = 42 + X_NL_CTYPE_OUTDIGIT2_MB = 43 + X_NL_CTYPE_OUTDIGIT3_MB = 44 + X_NL_CTYPE_OUTDIGIT4_MB = 45 + X_NL_CTYPE_OUTDIGIT5_MB = 46 + X_NL_CTYPE_OUTDIGIT6_MB = 47 + X_NL_CTYPE_OUTDIGIT7_MB = 48 + X_NL_CTYPE_OUTDIGIT8_MB = 49 + X_NL_CTYPE_OUTDIGIT9_MB = 50 + X_NL_CTYPE_OUTDIGIT0_WC = 51 + X_NL_CTYPE_OUTDIGIT1_WC = 52 + X_NL_CTYPE_OUTDIGIT2_WC = 53 + X_NL_CTYPE_OUTDIGIT3_WC = 54 + X_NL_CTYPE_OUTDIGIT4_WC = 55 + X_NL_CTYPE_OUTDIGIT5_WC = 56 + X_NL_CTYPE_OUTDIGIT6_WC = 57 + X_NL_CTYPE_OUTDIGIT7_WC = 58 + X_NL_CTYPE_OUTDIGIT8_WC = 59 + X_NL_CTYPE_OUTDIGIT9_WC = 60 + X_NL_CTYPE_TRANSLIT_TAB_SIZE = 61 + X_NL_CTYPE_TRANSLIT_FROM_IDX = 62 + X_NL_CTYPE_TRANSLIT_FROM_TBL = 63 + X_NL_CTYPE_TRANSLIT_TO_IDX = 64 + X_NL_CTYPE_TRANSLIT_TO_TBL = 65 + X_NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN = 66 + X_NL_CTYPE_TRANSLIT_DEFAULT_MISSING = 67 + X_NL_CTYPE_TRANSLIT_IGNORE_LEN = 68 + X_NL_CTYPE_TRANSLIT_IGNORE = 69 + X_NL_CTYPE_MAP_TO_NONASCII = 70 + X_NL_CTYPE_NONASCII_CASE = 71 + X_NL_CTYPE_EXTRA_MAP_1 = 72 + X_NL_CTYPE_EXTRA_MAP_2 = 73 + X_NL_CTYPE_EXTRA_MAP_3 = 74 + X_NL_CTYPE_EXTRA_MAP_4 = 75 + X_NL_CTYPE_EXTRA_MAP_5 = 76 + X_NL_CTYPE_EXTRA_MAP_6 = 77 + X_NL_CTYPE_EXTRA_MAP_7 = 78 + X_NL_CTYPE_EXTRA_MAP_8 = 79 + X_NL_CTYPE_EXTRA_MAP_9 = 80 + X_NL_CTYPE_EXTRA_MAP_10 = 81 + X_NL_CTYPE_EXTRA_MAP_11 = 82 + X_NL_CTYPE_EXTRA_MAP_12 = 83 + X_NL_CTYPE_EXTRA_MAP_13 = 84 + X_NL_CTYPE_EXTRA_MAP_14 = 85 + X_NL_NUM_LC_CTYPE = 86 + + // LC_MONETARY category: formatting of monetary quantities. + // These items each correspond to a member of `struct lconv', + // defined in . + X__INT_CURR_SYMBOL = 262144 + X__CURRENCY_SYMBOL = 262145 + X__MON_DECIMAL_POINT = 262146 + X__MON_THOUSANDS_SEP = 262147 + X__MON_GROUPING = 262148 + X__POSITIVE_SIGN = 262149 + X__NEGATIVE_SIGN = 262150 + X__INT_FRAC_DIGITS = 262151 + X__FRAC_DIGITS = 262152 + X__P_CS_PRECEDES = 262153 + X__P_SEP_BY_SPACE = 262154 + X__N_CS_PRECEDES = 262155 + X__N_SEP_BY_SPACE = 262156 + X__P_SIGN_POSN = 262157 + X__N_SIGN_POSN = 262158 + X_NL_MONETARY_CRNCYSTR = 262159 + X__INT_P_CS_PRECEDES = 262160 + X__INT_P_SEP_BY_SPACE = 262161 + X__INT_N_CS_PRECEDES = 262162 + X__INT_N_SEP_BY_SPACE = 262163 + X__INT_P_SIGN_POSN = 262164 + X__INT_N_SIGN_POSN = 262165 + X_NL_MONETARY_DUO_INT_CURR_SYMBOL = 262166 + X_NL_MONETARY_DUO_CURRENCY_SYMBOL = 262167 + X_NL_MONETARY_DUO_INT_FRAC_DIGITS = 262168 + X_NL_MONETARY_DUO_FRAC_DIGITS = 262169 + X_NL_MONETARY_DUO_P_CS_PRECEDES = 262170 + X_NL_MONETARY_DUO_P_SEP_BY_SPACE = 262171 + X_NL_MONETARY_DUO_N_CS_PRECEDES = 262172 + X_NL_MONETARY_DUO_N_SEP_BY_SPACE = 262173 + X_NL_MONETARY_DUO_INT_P_CS_PRECEDES = 262174 + X_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE = 262175 + X_NL_MONETARY_DUO_INT_N_CS_PRECEDES = 262176 + X_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE = 262177 + X_NL_MONETARY_DUO_P_SIGN_POSN = 262178 + X_NL_MONETARY_DUO_N_SIGN_POSN = 262179 + X_NL_MONETARY_DUO_INT_P_SIGN_POSN = 262180 + X_NL_MONETARY_DUO_INT_N_SIGN_POSN = 262181 + X_NL_MONETARY_UNO_VALID_FROM = 262182 + X_NL_MONETARY_UNO_VALID_TO = 262183 + X_NL_MONETARY_DUO_VALID_FROM = 262184 + X_NL_MONETARY_DUO_VALID_TO = 262185 + X_NL_MONETARY_CONVERSION_RATE = 262186 + X_NL_MONETARY_DECIMAL_POINT_WC = 262187 + X_NL_MONETARY_THOUSANDS_SEP_WC = 262188 + X_NL_MONETARY_CODESET = 262189 + X_NL_NUM_LC_MONETARY = 262190 + + // LC_NUMERIC category: formatting of numbers. + // These also correspond to members of `struct lconv'; see . + X__DECIMAL_POINT = 65536 + RADIXCHAR = 65536 + X__THOUSANDS_SEP = 65537 + THOUSEP = 65537 + X__GROUPING = 65538 + X_NL_NUMERIC_DECIMAL_POINT_WC = 65539 + X_NL_NUMERIC_THOUSANDS_SEP_WC = 65540 + X_NL_NUMERIC_CODESET = 65541 + X_NL_NUM_LC_NUMERIC = 65542 + + X__YESEXPR = 327680 // Regex matching ``yes'' input. + X__NOEXPR = 327681 // Regex matching ``no'' input. + X__YESSTR = 327682 // Output string for ``yes''. + X__NOSTR = 327683 // Output string for ``no''. + X_NL_MESSAGES_CODESET = 327684 + X_NL_NUM_LC_MESSAGES = 327685 + + X_NL_PAPER_HEIGHT = 458752 + X_NL_PAPER_WIDTH = 458753 + X_NL_PAPER_CODESET = 458754 + X_NL_NUM_LC_PAPER = 458755 + + X_NL_NAME_NAME_FMT = 524288 + X_NL_NAME_NAME_GEN = 524289 + X_NL_NAME_NAME_MR = 524290 + X_NL_NAME_NAME_MRS = 524291 + X_NL_NAME_NAME_MISS = 524292 + X_NL_NAME_NAME_MS = 524293 + X_NL_NAME_CODESET = 524294 + X_NL_NUM_LC_NAME = 524295 + + X_NL_ADDRESS_POSTAL_FMT = 589824 + X_NL_ADDRESS_COUNTRY_NAME = 589825 + X_NL_ADDRESS_COUNTRY_POST = 589826 + X_NL_ADDRESS_COUNTRY_AB2 = 589827 + X_NL_ADDRESS_COUNTRY_AB3 = 589828 + X_NL_ADDRESS_COUNTRY_CAR = 589829 + X_NL_ADDRESS_COUNTRY_NUM = 589830 + X_NL_ADDRESS_COUNTRY_ISBN = 589831 + X_NL_ADDRESS_LANG_NAME = 589832 + X_NL_ADDRESS_LANG_AB = 589833 + X_NL_ADDRESS_LANG_TERM = 589834 + X_NL_ADDRESS_LANG_LIB = 589835 + X_NL_ADDRESS_CODESET = 589836 + X_NL_NUM_LC_ADDRESS = 589837 + + X_NL_TELEPHONE_TEL_INT_FMT = 655360 + X_NL_TELEPHONE_TEL_DOM_FMT = 655361 + X_NL_TELEPHONE_INT_SELECT = 655362 + X_NL_TELEPHONE_INT_PREFIX = 655363 + X_NL_TELEPHONE_CODESET = 655364 + X_NL_NUM_LC_TELEPHONE = 655365 + + X_NL_MEASUREMENT_MEASUREMENT = 720896 + X_NL_MEASUREMENT_CODESET = 720897 + X_NL_NUM_LC_MEASUREMENT = 720898 + + X_NL_IDENTIFICATION_TITLE = 786432 + X_NL_IDENTIFICATION_SOURCE = 786433 + X_NL_IDENTIFICATION_ADDRESS = 786434 + X_NL_IDENTIFICATION_CONTACT = 786435 + X_NL_IDENTIFICATION_EMAIL = 786436 + X_NL_IDENTIFICATION_TEL = 786437 + X_NL_IDENTIFICATION_FAX = 786438 + X_NL_IDENTIFICATION_LANGUAGE = 786439 + X_NL_IDENTIFICATION_TERRITORY = 786440 + X_NL_IDENTIFICATION_AUDIENCE = 786441 + X_NL_IDENTIFICATION_APPLICATION = 786442 + X_NL_IDENTIFICATION_ABBREVIATION = 786443 + X_NL_IDENTIFICATION_REVISION = 786444 + X_NL_IDENTIFICATION_DATE = 786445 + X_NL_IDENTIFICATION_CATEGORY = 786446 + X_NL_IDENTIFICATION_CODESET = 786447 + X_NL_NUM_LC_IDENTIFICATION = 786448 + + // This marks the highest value used. + X_NL_NUM = 786449 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Access to locale-dependent parameters. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get the type definition. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// The default message set used by the gencat program. + +// Value for FLAG parameter of `catgets' to say we want XPG4 compliance. + +// Message catalog descriptor type. +type Nl_catd = uintptr /* nl_types.h:33:14 */ + +// Type used by `nl_langinfo'. +type Nl_item = int32 /* nl_types.h:36:13 */ + +// POSIX.1-2008 extended locale interface (see locale.h). +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/langinfo/langinfo_linux_arm64.go b/internal/libc/langinfo/langinfo_linux_arm64.go new file mode 100644 index 0000000..3c99586 --- /dev/null +++ b/internal/libc/langinfo/langinfo_linux_arm64.go @@ -0,0 +1,1093 @@ +// Code generated by 'ccgo langinfo/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o langinfo/langinfo_linux_arm64.go -pkgname langinfo', DO NOT EDIT. + +package langinfo + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + NL_CAT_LOCALE = 1 + NL_SETD = 1 + X_ATFILE_SOURCE = 1 + X_BITS_LOCALE_H = 1 + X_BITS_TYPES_LOCALE_T_H = 1 + X_BITS_TYPES___LOCALE_T_H = 1 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_LANGINFO_H = 1 + X_LP64 = 1 + X_NL_TYPES_H = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + Linux = 1 + Unix = 1 +) + +// Definition of locale category symbol values. +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Construct an `nl_item' value for `nl_langinfo' from a locale category +// (LC_*) and an item index within the category. Some code may depend on +// the item values within a category increasing monotonically with the +// indices. + +// Extract the category and item index from a constructed `nl_item' value. + +// Enumeration of locale items that can be queried with `nl_langinfo'. +const ( /* langinfo.h:41:1: */ + // LC_TIME category: date and time formatting. + + // Abbreviated days of the week. + ABDAY_1 = 131072 // Sun + ABDAY_2 = 131073 + ABDAY_3 = 131074 + ABDAY_4 = 131075 + ABDAY_5 = 131076 + ABDAY_6 = 131077 + ABDAY_7 = 131078 + + // Long-named days of the week. + DAY_1 = 131079 // Sunday + DAY_2 = 131080 // Monday + DAY_3 = 131081 // Tuesday + DAY_4 = 131082 // Wednesday + DAY_5 = 131083 // Thursday + DAY_6 = 131084 // Friday + DAY_7 = 131085 // Saturday + + // Abbreviated month names, in the grammatical form used when the month + // is a part of a complete date. + ABMON_1 = 131086 // Jan + ABMON_2 = 131087 + ABMON_3 = 131088 + ABMON_4 = 131089 + ABMON_5 = 131090 + ABMON_6 = 131091 + ABMON_7 = 131092 + ABMON_8 = 131093 + ABMON_9 = 131094 + ABMON_10 = 131095 + ABMON_11 = 131096 + ABMON_12 = 131097 + + // Long month names, in the grammatical form used when the month + // is a part of a complete date. + MON_1 = 131098 // January + MON_2 = 131099 + MON_3 = 131100 + MON_4 = 131101 + MON_5 = 131102 + MON_6 = 131103 + MON_7 = 131104 + MON_8 = 131105 + MON_9 = 131106 + MON_10 = 131107 + MON_11 = 131108 + MON_12 = 131109 + + AM_STR = 131110 // Ante meridiem string. + PM_STR = 131111 // Post meridiem string. + + D_T_FMT = 131112 // Date and time format for strftime. + D_FMT = 131113 // Date format for strftime. + T_FMT = 131114 // Time format for strftime. + T_FMT_AMPM = 131115 // 12-hour time format for strftime. + + ERA = 131116 // Alternate era. + X__ERA_YEAR = 131117 // Year in alternate era format. + ERA_D_FMT = 131118 // Date in alternate era format. + ALT_DIGITS = 131119 // Alternate symbols for digits. + ERA_D_T_FMT = 131120 // Date and time in alternate era format. + ERA_T_FMT = 131121 // Time in alternate era format. + + X_NL_TIME_ERA_NUM_ENTRIES = 131122 // Number entries in the era arrays. + X_NL_TIME_ERA_ENTRIES = 131123 // Structure with era entries in usable form. + + X_NL_WABDAY_1 = 131124 // Sun + X_NL_WABDAY_2 = 131125 + X_NL_WABDAY_3 = 131126 + X_NL_WABDAY_4 = 131127 + X_NL_WABDAY_5 = 131128 + X_NL_WABDAY_6 = 131129 + X_NL_WABDAY_7 = 131130 + + // Long-named days of the week. + X_NL_WDAY_1 = 131131 // Sunday + X_NL_WDAY_2 = 131132 // Monday + X_NL_WDAY_3 = 131133 // Tuesday + X_NL_WDAY_4 = 131134 // Wednesday + X_NL_WDAY_5 = 131135 // Thursday + X_NL_WDAY_6 = 131136 // Friday + X_NL_WDAY_7 = 131137 // Saturday + + // Abbreviated month names, in the grammatical form used when the month + // is a part of a complete date. + X_NL_WABMON_1 = 131138 // Jan + X_NL_WABMON_2 = 131139 + X_NL_WABMON_3 = 131140 + X_NL_WABMON_4 = 131141 + X_NL_WABMON_5 = 131142 + X_NL_WABMON_6 = 131143 + X_NL_WABMON_7 = 131144 + X_NL_WABMON_8 = 131145 + X_NL_WABMON_9 = 131146 + X_NL_WABMON_10 = 131147 + X_NL_WABMON_11 = 131148 + X_NL_WABMON_12 = 131149 + + // Long month names, in the grammatical form used when the month + // is a part of a complete date. + X_NL_WMON_1 = 131150 // January + X_NL_WMON_2 = 131151 + X_NL_WMON_3 = 131152 + X_NL_WMON_4 = 131153 + X_NL_WMON_5 = 131154 + X_NL_WMON_6 = 131155 + X_NL_WMON_7 = 131156 + X_NL_WMON_8 = 131157 + X_NL_WMON_9 = 131158 + X_NL_WMON_10 = 131159 + X_NL_WMON_11 = 131160 + X_NL_WMON_12 = 131161 + + X_NL_WAM_STR = 131162 // Ante meridiem string. + X_NL_WPM_STR = 131163 // Post meridiem string. + + X_NL_WD_T_FMT = 131164 // Date and time format for strftime. + X_NL_WD_FMT = 131165 // Date format for strftime. + X_NL_WT_FMT = 131166 // Time format for strftime. + X_NL_WT_FMT_AMPM = 131167 // 12-hour time format for strftime. + + X_NL_WERA_YEAR = 131168 // Year in alternate era format. + X_NL_WERA_D_FMT = 131169 // Date in alternate era format. + X_NL_WALT_DIGITS = 131170 // Alternate symbols for digits. + X_NL_WERA_D_T_FMT = 131171 // Date and time in alternate era format. + X_NL_WERA_T_FMT = 131172 // Time in alternate era format. + + X_NL_TIME_WEEK_NDAYS = 131173 + X_NL_TIME_WEEK_1STDAY = 131174 + X_NL_TIME_WEEK_1STWEEK = 131175 + X_NL_TIME_FIRST_WEEKDAY = 131176 + X_NL_TIME_FIRST_WORKDAY = 131177 + X_NL_TIME_CAL_DIRECTION = 131178 + X_NL_TIME_TIMEZONE = 131179 + + X_DATE_FMT = 131180 // strftime format for date. + X_NL_W_DATE_FMT = 131181 + + X_NL_TIME_CODESET = 131182 + + // Long month names, in the grammatical form used when the month + // is named by itself. + X__ALTMON_1 = 131183 // January + X__ALTMON_2 = 131184 + X__ALTMON_3 = 131185 + X__ALTMON_4 = 131186 + X__ALTMON_5 = 131187 + X__ALTMON_6 = 131188 + X__ALTMON_7 = 131189 + X__ALTMON_8 = 131190 + X__ALTMON_9 = 131191 + X__ALTMON_10 = 131192 + X__ALTMON_11 = 131193 + X__ALTMON_12 = 131194 + + // Long month names, in the grammatical form used when the month + // is named by itself. + X_NL_WALTMON_1 = 131195 // January + X_NL_WALTMON_2 = 131196 + X_NL_WALTMON_3 = 131197 + X_NL_WALTMON_4 = 131198 + X_NL_WALTMON_5 = 131199 + X_NL_WALTMON_6 = 131200 + X_NL_WALTMON_7 = 131201 + X_NL_WALTMON_8 = 131202 + X_NL_WALTMON_9 = 131203 + X_NL_WALTMON_10 = 131204 + X_NL_WALTMON_11 = 131205 + X_NL_WALTMON_12 = 131206 + + // Abbreviated month names, in the grammatical form used when the month + // is named by itself. + X_NL_ABALTMON_1 = 131207 // Jan + X_NL_ABALTMON_2 = 131208 + X_NL_ABALTMON_3 = 131209 + X_NL_ABALTMON_4 = 131210 + X_NL_ABALTMON_5 = 131211 + X_NL_ABALTMON_6 = 131212 + X_NL_ABALTMON_7 = 131213 + X_NL_ABALTMON_8 = 131214 + X_NL_ABALTMON_9 = 131215 + X_NL_ABALTMON_10 = 131216 + X_NL_ABALTMON_11 = 131217 + X_NL_ABALTMON_12 = 131218 + + // Abbreviated month names, in the grammatical form used when the month + // is named by itself. + X_NL_WABALTMON_1 = 131219 // Jan + X_NL_WABALTMON_2 = 131220 + X_NL_WABALTMON_3 = 131221 + X_NL_WABALTMON_4 = 131222 + X_NL_WABALTMON_5 = 131223 + X_NL_WABALTMON_6 = 131224 + X_NL_WABALTMON_7 = 131225 + X_NL_WABALTMON_8 = 131226 + X_NL_WABALTMON_9 = 131227 + X_NL_WABALTMON_10 = 131228 + X_NL_WABALTMON_11 = 131229 + X_NL_WABALTMON_12 = 131230 + + X_NL_NUM_LC_TIME = 131231 // Number of indices in LC_TIME category. + + // LC_COLLATE category: text sorting. + // This information is accessed by the strcoll and strxfrm functions. + // These `nl_langinfo' names are used only internally. + X_NL_COLLATE_NRULES = 196608 + X_NL_COLLATE_RULESETS = 196609 + X_NL_COLLATE_TABLEMB = 196610 + X_NL_COLLATE_WEIGHTMB = 196611 + X_NL_COLLATE_EXTRAMB = 196612 + X_NL_COLLATE_INDIRECTMB = 196613 + X_NL_COLLATE_GAP1 = 196614 + X_NL_COLLATE_GAP2 = 196615 + X_NL_COLLATE_GAP3 = 196616 + X_NL_COLLATE_TABLEWC = 196617 + X_NL_COLLATE_WEIGHTWC = 196618 + X_NL_COLLATE_EXTRAWC = 196619 + X_NL_COLLATE_INDIRECTWC = 196620 + X_NL_COLLATE_SYMB_HASH_SIZEMB = 196621 + X_NL_COLLATE_SYMB_TABLEMB = 196622 + X_NL_COLLATE_SYMB_EXTRAMB = 196623 + X_NL_COLLATE_COLLSEQMB = 196624 + X_NL_COLLATE_COLLSEQWC = 196625 + X_NL_COLLATE_CODESET = 196626 + X_NL_NUM_LC_COLLATE = 196627 + + // LC_CTYPE category: character classification. + // This information is accessed by the functions in . + // These `nl_langinfo' names are used only internally. + X_NL_CTYPE_CLASS = 0 + X_NL_CTYPE_TOUPPER = 1 + X_NL_CTYPE_GAP1 = 2 + X_NL_CTYPE_TOLOWER = 3 + X_NL_CTYPE_GAP2 = 4 + X_NL_CTYPE_CLASS32 = 5 + X_NL_CTYPE_GAP3 = 6 + X_NL_CTYPE_GAP4 = 7 + X_NL_CTYPE_GAP5 = 8 + X_NL_CTYPE_GAP6 = 9 + X_NL_CTYPE_CLASS_NAMES = 10 + X_NL_CTYPE_MAP_NAMES = 11 + X_NL_CTYPE_WIDTH = 12 + X_NL_CTYPE_MB_CUR_MAX = 13 + X_NL_CTYPE_CODESET_NAME = 14 + CODESET = 14 + X_NL_CTYPE_TOUPPER32 = 15 + X_NL_CTYPE_TOLOWER32 = 16 + X_NL_CTYPE_CLASS_OFFSET = 17 + X_NL_CTYPE_MAP_OFFSET = 18 + X_NL_CTYPE_INDIGITS_MB_LEN = 19 + X_NL_CTYPE_INDIGITS0_MB = 20 + X_NL_CTYPE_INDIGITS1_MB = 21 + X_NL_CTYPE_INDIGITS2_MB = 22 + X_NL_CTYPE_INDIGITS3_MB = 23 + X_NL_CTYPE_INDIGITS4_MB = 24 + X_NL_CTYPE_INDIGITS5_MB = 25 + X_NL_CTYPE_INDIGITS6_MB = 26 + X_NL_CTYPE_INDIGITS7_MB = 27 + X_NL_CTYPE_INDIGITS8_MB = 28 + X_NL_CTYPE_INDIGITS9_MB = 29 + X_NL_CTYPE_INDIGITS_WC_LEN = 30 + X_NL_CTYPE_INDIGITS0_WC = 31 + X_NL_CTYPE_INDIGITS1_WC = 32 + X_NL_CTYPE_INDIGITS2_WC = 33 + X_NL_CTYPE_INDIGITS3_WC = 34 + X_NL_CTYPE_INDIGITS4_WC = 35 + X_NL_CTYPE_INDIGITS5_WC = 36 + X_NL_CTYPE_INDIGITS6_WC = 37 + X_NL_CTYPE_INDIGITS7_WC = 38 + X_NL_CTYPE_INDIGITS8_WC = 39 + X_NL_CTYPE_INDIGITS9_WC = 40 + X_NL_CTYPE_OUTDIGIT0_MB = 41 + X_NL_CTYPE_OUTDIGIT1_MB = 42 + X_NL_CTYPE_OUTDIGIT2_MB = 43 + X_NL_CTYPE_OUTDIGIT3_MB = 44 + X_NL_CTYPE_OUTDIGIT4_MB = 45 + X_NL_CTYPE_OUTDIGIT5_MB = 46 + X_NL_CTYPE_OUTDIGIT6_MB = 47 + X_NL_CTYPE_OUTDIGIT7_MB = 48 + X_NL_CTYPE_OUTDIGIT8_MB = 49 + X_NL_CTYPE_OUTDIGIT9_MB = 50 + X_NL_CTYPE_OUTDIGIT0_WC = 51 + X_NL_CTYPE_OUTDIGIT1_WC = 52 + X_NL_CTYPE_OUTDIGIT2_WC = 53 + X_NL_CTYPE_OUTDIGIT3_WC = 54 + X_NL_CTYPE_OUTDIGIT4_WC = 55 + X_NL_CTYPE_OUTDIGIT5_WC = 56 + X_NL_CTYPE_OUTDIGIT6_WC = 57 + X_NL_CTYPE_OUTDIGIT7_WC = 58 + X_NL_CTYPE_OUTDIGIT8_WC = 59 + X_NL_CTYPE_OUTDIGIT9_WC = 60 + X_NL_CTYPE_TRANSLIT_TAB_SIZE = 61 + X_NL_CTYPE_TRANSLIT_FROM_IDX = 62 + X_NL_CTYPE_TRANSLIT_FROM_TBL = 63 + X_NL_CTYPE_TRANSLIT_TO_IDX = 64 + X_NL_CTYPE_TRANSLIT_TO_TBL = 65 + X_NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN = 66 + X_NL_CTYPE_TRANSLIT_DEFAULT_MISSING = 67 + X_NL_CTYPE_TRANSLIT_IGNORE_LEN = 68 + X_NL_CTYPE_TRANSLIT_IGNORE = 69 + X_NL_CTYPE_MAP_TO_NONASCII = 70 + X_NL_CTYPE_NONASCII_CASE = 71 + X_NL_CTYPE_EXTRA_MAP_1 = 72 + X_NL_CTYPE_EXTRA_MAP_2 = 73 + X_NL_CTYPE_EXTRA_MAP_3 = 74 + X_NL_CTYPE_EXTRA_MAP_4 = 75 + X_NL_CTYPE_EXTRA_MAP_5 = 76 + X_NL_CTYPE_EXTRA_MAP_6 = 77 + X_NL_CTYPE_EXTRA_MAP_7 = 78 + X_NL_CTYPE_EXTRA_MAP_8 = 79 + X_NL_CTYPE_EXTRA_MAP_9 = 80 + X_NL_CTYPE_EXTRA_MAP_10 = 81 + X_NL_CTYPE_EXTRA_MAP_11 = 82 + X_NL_CTYPE_EXTRA_MAP_12 = 83 + X_NL_CTYPE_EXTRA_MAP_13 = 84 + X_NL_CTYPE_EXTRA_MAP_14 = 85 + X_NL_NUM_LC_CTYPE = 86 + + // LC_MONETARY category: formatting of monetary quantities. + // These items each correspond to a member of `struct lconv', + // defined in . + X__INT_CURR_SYMBOL = 262144 + X__CURRENCY_SYMBOL = 262145 + X__MON_DECIMAL_POINT = 262146 + X__MON_THOUSANDS_SEP = 262147 + X__MON_GROUPING = 262148 + X__POSITIVE_SIGN = 262149 + X__NEGATIVE_SIGN = 262150 + X__INT_FRAC_DIGITS = 262151 + X__FRAC_DIGITS = 262152 + X__P_CS_PRECEDES = 262153 + X__P_SEP_BY_SPACE = 262154 + X__N_CS_PRECEDES = 262155 + X__N_SEP_BY_SPACE = 262156 + X__P_SIGN_POSN = 262157 + X__N_SIGN_POSN = 262158 + X_NL_MONETARY_CRNCYSTR = 262159 + X__INT_P_CS_PRECEDES = 262160 + X__INT_P_SEP_BY_SPACE = 262161 + X__INT_N_CS_PRECEDES = 262162 + X__INT_N_SEP_BY_SPACE = 262163 + X__INT_P_SIGN_POSN = 262164 + X__INT_N_SIGN_POSN = 262165 + X_NL_MONETARY_DUO_INT_CURR_SYMBOL = 262166 + X_NL_MONETARY_DUO_CURRENCY_SYMBOL = 262167 + X_NL_MONETARY_DUO_INT_FRAC_DIGITS = 262168 + X_NL_MONETARY_DUO_FRAC_DIGITS = 262169 + X_NL_MONETARY_DUO_P_CS_PRECEDES = 262170 + X_NL_MONETARY_DUO_P_SEP_BY_SPACE = 262171 + X_NL_MONETARY_DUO_N_CS_PRECEDES = 262172 + X_NL_MONETARY_DUO_N_SEP_BY_SPACE = 262173 + X_NL_MONETARY_DUO_INT_P_CS_PRECEDES = 262174 + X_NL_MONETARY_DUO_INT_P_SEP_BY_SPACE = 262175 + X_NL_MONETARY_DUO_INT_N_CS_PRECEDES = 262176 + X_NL_MONETARY_DUO_INT_N_SEP_BY_SPACE = 262177 + X_NL_MONETARY_DUO_P_SIGN_POSN = 262178 + X_NL_MONETARY_DUO_N_SIGN_POSN = 262179 + X_NL_MONETARY_DUO_INT_P_SIGN_POSN = 262180 + X_NL_MONETARY_DUO_INT_N_SIGN_POSN = 262181 + X_NL_MONETARY_UNO_VALID_FROM = 262182 + X_NL_MONETARY_UNO_VALID_TO = 262183 + X_NL_MONETARY_DUO_VALID_FROM = 262184 + X_NL_MONETARY_DUO_VALID_TO = 262185 + X_NL_MONETARY_CONVERSION_RATE = 262186 + X_NL_MONETARY_DECIMAL_POINT_WC = 262187 + X_NL_MONETARY_THOUSANDS_SEP_WC = 262188 + X_NL_MONETARY_CODESET = 262189 + X_NL_NUM_LC_MONETARY = 262190 + + // LC_NUMERIC category: formatting of numbers. + // These also correspond to members of `struct lconv'; see . + X__DECIMAL_POINT = 65536 + RADIXCHAR = 65536 + X__THOUSANDS_SEP = 65537 + THOUSEP = 65537 + X__GROUPING = 65538 + X_NL_NUMERIC_DECIMAL_POINT_WC = 65539 + X_NL_NUMERIC_THOUSANDS_SEP_WC = 65540 + X_NL_NUMERIC_CODESET = 65541 + X_NL_NUM_LC_NUMERIC = 65542 + + X__YESEXPR = 327680 // Regex matching ``yes'' input. + X__NOEXPR = 327681 // Regex matching ``no'' input. + X__YESSTR = 327682 // Output string for ``yes''. + X__NOSTR = 327683 // Output string for ``no''. + X_NL_MESSAGES_CODESET = 327684 + X_NL_NUM_LC_MESSAGES = 327685 + + X_NL_PAPER_HEIGHT = 458752 + X_NL_PAPER_WIDTH = 458753 + X_NL_PAPER_CODESET = 458754 + X_NL_NUM_LC_PAPER = 458755 + + X_NL_NAME_NAME_FMT = 524288 + X_NL_NAME_NAME_GEN = 524289 + X_NL_NAME_NAME_MR = 524290 + X_NL_NAME_NAME_MRS = 524291 + X_NL_NAME_NAME_MISS = 524292 + X_NL_NAME_NAME_MS = 524293 + X_NL_NAME_CODESET = 524294 + X_NL_NUM_LC_NAME = 524295 + + X_NL_ADDRESS_POSTAL_FMT = 589824 + X_NL_ADDRESS_COUNTRY_NAME = 589825 + X_NL_ADDRESS_COUNTRY_POST = 589826 + X_NL_ADDRESS_COUNTRY_AB2 = 589827 + X_NL_ADDRESS_COUNTRY_AB3 = 589828 + X_NL_ADDRESS_COUNTRY_CAR = 589829 + X_NL_ADDRESS_COUNTRY_NUM = 589830 + X_NL_ADDRESS_COUNTRY_ISBN = 589831 + X_NL_ADDRESS_LANG_NAME = 589832 + X_NL_ADDRESS_LANG_AB = 589833 + X_NL_ADDRESS_LANG_TERM = 589834 + X_NL_ADDRESS_LANG_LIB = 589835 + X_NL_ADDRESS_CODESET = 589836 + X_NL_NUM_LC_ADDRESS = 589837 + + X_NL_TELEPHONE_TEL_INT_FMT = 655360 + X_NL_TELEPHONE_TEL_DOM_FMT = 655361 + X_NL_TELEPHONE_INT_SELECT = 655362 + X_NL_TELEPHONE_INT_PREFIX = 655363 + X_NL_TELEPHONE_CODESET = 655364 + X_NL_NUM_LC_TELEPHONE = 655365 + + X_NL_MEASUREMENT_MEASUREMENT = 720896 + X_NL_MEASUREMENT_CODESET = 720897 + X_NL_NUM_LC_MEASUREMENT = 720898 + + X_NL_IDENTIFICATION_TITLE = 786432 + X_NL_IDENTIFICATION_SOURCE = 786433 + X_NL_IDENTIFICATION_ADDRESS = 786434 + X_NL_IDENTIFICATION_CONTACT = 786435 + X_NL_IDENTIFICATION_EMAIL = 786436 + X_NL_IDENTIFICATION_TEL = 786437 + X_NL_IDENTIFICATION_FAX = 786438 + X_NL_IDENTIFICATION_LANGUAGE = 786439 + X_NL_IDENTIFICATION_TERRITORY = 786440 + X_NL_IDENTIFICATION_AUDIENCE = 786441 + X_NL_IDENTIFICATION_APPLICATION = 786442 + X_NL_IDENTIFICATION_ABBREVIATION = 786443 + X_NL_IDENTIFICATION_REVISION = 786444 + X_NL_IDENTIFICATION_DATE = 786445 + X_NL_IDENTIFICATION_CATEGORY = 786446 + X_NL_IDENTIFICATION_CODESET = 786447 + X_NL_NUM_LC_IDENTIFICATION = 786448 + + // This marks the highest value used. + X_NL_NUM = 786449 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Access to locale-dependent parameters. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get the type definition. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// The default message set used by the gencat program. + +// Value for FLAG parameter of `catgets' to say we want XPG4 compliance. + +// Message catalog descriptor type. +type Nl_catd = uintptr /* nl_types.h:33:14 */ + +// Type used by `nl_langinfo'. +type Nl_item = int32 /* nl_types.h:36:13 */ + +// POSIX.1-2008 extended locale interface (see locale.h). +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/libc.go b/internal/libc/libc.go new file mode 100644 index 0000000..468f630 --- /dev/null +++ b/internal/libc/libc.go @@ -0,0 +1,3572 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !linux || mips64le + +///go.generate echo package libc > ccgo.go +///go:generate go fmt -l -s -w ./... + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +//TODO use O_RDONLY etc. from fcntl header + +//TODO use t.Alloc/Free where appropriate + +import ( + "bufio" + crand "crypto/rand" + "fmt" + "math" + mbits "math/bits" + "math/rand" + "os" + "runtime" + "runtime/debug" + "sort" + "strings" + "sync" + "sync/atomic" + gotime "time" + "unsafe" + + "github.com/mattn/go-isatty" + "github.com/hanzoai/sqlite/internal/libc/errno" + "github.com/hanzoai/sqlite/internal/libc/stdio" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/libc/time" + "github.com/hanzoai/sqlite/internal/libc/unistd" + "github.com/hanzoai/sqlite/internal/mathutil" +) + +const ( + ENOENT = errno.ENOENT +) + +type ( + // RawMem64 represents the biggest uint64 array the runtime can handle. + RawMem64 [unsafe.Sizeof(RawMem{}) / unsafe.Sizeof(uint64(0))]uint64 +) + +var ( + allocMu sync.Mutex + environInitialized bool + isWindows bool + ungetcMu sync.Mutex + ungetc = map[uintptr]byte{} +) + +// Keep these outside of the var block otherwise go generate will miss them. +var Xenviron uintptr +var Xstdin = newFile(nil, unistd.STDIN_FILENO) +var Xstdout = newFile(nil, unistd.STDOUT_FILENO) +var Xstderr = newFile(nil, unistd.STDERR_FILENO) + +func setEnviron() { + SetEnviron(nil, os.Environ()) +} + +func Environ() uintptr { + if !environInitialized { + SetEnviron(nil, os.Environ()) + } + return Xenviron +} + +func EnvironP() uintptr { + if !environInitialized { + SetEnviron(nil, os.Environ()) + } + return uintptr(unsafe.Pointer(&Xenviron)) +} + +func X___errno_location(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return X__errno_location(t) +} + +// int * __errno_location(void); +func X__errno_location(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return t.errnop +} + +func Start(main func(*TLS, int32, uintptr) int32) { + if dmesgs { + wd, err := os.Getwd() + dmesg("%v: %v, wd %v, %v", origin(1), os.Args, wd, err) + + defer func() { + if err := recover(); err != nil { + dmesg("%v: CRASH: %v\n%s", origin(1), err, debug.Stack()) + } + }() + } + runtime.LockOSThread() + t := &TLS{errnop: uintptr(unsafe.Pointer(&errno0))} + argv := Xcalloc(t, 1, types.Size_t((len(os.Args)+1)*int(uintptrSize))) + if argv == 0 { + panic("OOM") + } + + p := argv + for _, v := range os.Args { + s := Xcalloc(t, 1, types.Size_t(len(v)+1)) + if s == 0 { + panic("OOM") + } + + copy((*RawMem)(unsafe.Pointer(s))[:len(v):len(v)], v) + *(*uintptr)(unsafe.Pointer(p)) = s + p += uintptrSize + } + SetEnviron(t, os.Environ()) + audit := false + if memgrind { + if s := os.Getenv("LIBC_MEMGRIND_START"); s != "0" { + MemAuditStart() + audit = true + } + } + t = NewTLS() + rc := main(t, int32(len(os.Args)), argv) + exit(t, rc, audit) +} + +func Xexit(t *TLS, status int32) { + if __ccgo_strace { + trc("t=%v status=%v, (%v:)", t, status, origin(2)) + } + exit(t, status, false) +} + +func exit(t *TLS, status int32, audit bool) { + if len(Covered) != 0 { + buf := bufio.NewWriter(os.Stdout) + CoverReport(buf) + buf.Flush() + } + if len(CoveredC) != 0 { + buf := bufio.NewWriter(os.Stdout) + CoverCReport(buf) + buf.Flush() + } + for i := len(atExit) - 1; i >= 0; i-- { + atExit[i]() + } + if audit { + t.Close() + if tlsBalance != 0 { + fmt.Fprintf(os.Stderr, "non zero TLS balance: %d\n", tlsBalance) + status = 1 + } + } + X_exit(nil, status) +} + +// void _exit(int status); +func X_exit(_ *TLS, status int32) { + if dmesgs { + dmesg("%v: EXIT %v", origin(1), status) + } + os.Exit(int(status)) +} + +func SetEnviron(t *TLS, env []string) { + if environInitialized { + return + } + + environInitialized = true + p := Xcalloc(t, 1, types.Size_t((len(env)+1)*(int(uintptrSize)))) + if p == 0 { + panic("OOM") + } + + Xenviron = p + for _, v := range env { + s := Xcalloc(t, 1, types.Size_t(len(v)+1)) + if s == 0 { + panic("OOM") + } + + copy((*(*RawMem)(unsafe.Pointer(s)))[:len(v):len(v)], v) + *(*uintptr)(unsafe.Pointer(p)) = s + p += uintptrSize + } +} + +// void setbuf(FILE *stream, char *buf); +func Xsetbuf(t *TLS, stream, buf uintptr) { + if __ccgo_strace { + trc("t=%v buf=%v, (%v:)", t, buf, origin(2)) + } + //TODO panic(todo("")) +} + +// size_t confstr(int name, char *buf, size_t len); +func Xconfstr(t *TLS, name int32, buf uintptr, len types.Size_t) types.Size_t { + if __ccgo_strace { + trc("t=%v name=%v buf=%v len=%v, (%v:)", t, name, buf, len, origin(2)) + } + panic(todo("")) +} + +// int puts(const char *s); +func Xputs(t *TLS, s uintptr) int32 { + if __ccgo_strace { + trc("t=%v s=%v, (%v:)", t, s, origin(2)) + } + n, err := fmt.Printf("%s\n", GoString(s)) + if err != nil { + return stdio.EOF + } + + return int32(n) +} + +var ( + randomMu sync.Mutex + randomGen = rand.New(rand.NewSource(42)) +) + +// long int random(void); +func Xrandom(t *TLS) long { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + randomMu.Lock() + r := randomGen.Int63n(math.MaxInt32 + 1) + randomMu.Unlock() + return long(r) +} + +func write(b []byte) (int, error) { + // if dmesgs { + // dmesg("%v: %s", origin(1), b) + // } + if _, err := os.Stdout.Write(b); err != nil { + return -1, err + } + + return len(b), nil +} + +func X__builtin_bzero(t *TLS, s uintptr, n types.Size_t) { + if __ccgo_strace { + trc("t=%v s=%v n=%v, (%v:)", t, s, n, origin(2)) + } + Xbzero(t, s, n) +} + +func X__builtin_abort(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + Xabort(t) +} + +func X__builtin_abs(t *TLS, j int32) int32 { + if __ccgo_strace { + trc("t=%v j=%v, (%v:)", t, j, origin(2)) + } + return Xabs(t, j) +} + +func X__builtin_clz(t *TLS, n uint32) int32 { + if __ccgo_strace { + trc("t=%v n=%v, (%v:)", t, n, origin(2)) + } + return int32(mbits.LeadingZeros32(n)) +} + +func X__builtin_clzl(t *TLS, n ulong) int32 { + if __ccgo_strace { + trc("t=%v n=%v, (%v:)", t, n, origin(2)) + } + return int32(mbits.LeadingZeros64(uint64(n))) +} + +func X__builtin_clzll(t *TLS, n uint64) int32 { + if __ccgo_strace { + trc("t=%v n=%v, (%v:)", t, n, origin(2)) + } + return int32(mbits.LeadingZeros64(n)) +} +func X__builtin_constant_p_impl() { panic(todo("internal error: should never be called")) } + +func X__builtin_copysign(t *TLS, x, y float64) float64 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return Xcopysign(t, x, y) +} + +func X__builtin_copysignf(t *TLS, x, y float32) float32 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return Xcopysignf(t, x, y) +} + +func X__builtin_copysignl(t *TLS, x, y float64) float64 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return Xcopysign(t, x, y) +} + +func X__builtin_exit(t *TLS, status int32) { + if __ccgo_strace { + trc("t=%v status=%v, (%v:)", t, status, origin(2)) + } + Xexit(t, status) +} + +func X__builtin_expect(t *TLS, exp, c long) long { + if __ccgo_strace { + trc("t=%v c=%v, (%v:)", t, c, origin(2)) + } + return exp +} + +func X__builtin_fabs(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Xfabs(t, x) +} + +func X__builtin_fabsf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Xfabsf(t, x) +} + +func X__builtin_fabsl(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Xfabsl(t, x) +} + +func X__builtin_free(t *TLS, ptr uintptr) { + if __ccgo_strace { + trc("t=%v ptr=%v, (%v:)", t, ptr, origin(2)) + } + Xfree(t, ptr) +} + +func X__builtin_getentropy(t *TLS, buf uintptr, n types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v buf=%v n=%v, (%v:)", t, buf, n, origin(2)) + } + return Xgetentropy(t, buf, n) +} + +func X__builtin_huge_val(t *TLS) float64 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return math.Inf(1) +} + +func X__builtin_huge_valf(t *TLS) float32 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return float32(math.Inf(1)) +} + +func X__builtin_inf(t *TLS) float64 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return math.Inf(1) +} + +func X__builtin_inff(t *TLS) float32 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return float32(math.Inf(1)) +} + +func X__builtin_infl(t *TLS) float64 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return math.Inf(1) +} + +func X__builtin_malloc(t *TLS, size types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v size=%v, (%v:)", t, size, origin(2)) + } + return Xmalloc(t, size) +} + +func X__builtin_memcmp(t *TLS, s1, s2 uintptr, n types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v s2=%v n=%v, (%v:)", t, s2, n, origin(2)) + } + return Xmemcmp(t, s1, s2, n) +} + +func X__builtin_nan(t *TLS, s uintptr) float64 { + if __ccgo_strace { + trc("t=%v s=%v, (%v:)", t, s, origin(2)) + } + return math.NaN() +} + +func X__builtin_nanf(t *TLS, s uintptr) float32 { + if __ccgo_strace { + trc("t=%v s=%v, (%v:)", t, s, origin(2)) + } + return float32(math.NaN()) +} + +func X__builtin_nanl(t *TLS, s uintptr) float64 { + if __ccgo_strace { + trc("t=%v s=%v, (%v:)", t, s, origin(2)) + } + return math.NaN() +} + +func X__builtin_prefetch(t *TLS, addr, args uintptr) { + if __ccgo_strace { + trc("t=%v args=%v, (%v:)", t, args, origin(2)) + } +} + +func X__builtin_printf(t *TLS, s, args uintptr) int32 { + if __ccgo_strace { + trc("t=%v args=%v, (%v:)", t, args, origin(2)) + } + return Xprintf(t, s, args) +} + +func X__builtin_strchr(t *TLS, s uintptr, c int32) uintptr { + if __ccgo_strace { + trc("t=%v s=%v c=%v, (%v:)", t, s, c, origin(2)) + } + return Xstrchr(t, s, c) +} + +func X__builtin_strcmp(t *TLS, s1, s2 uintptr) int32 { + if __ccgo_strace { + trc("t=%v s2=%v, (%v:)", t, s2, origin(2)) + } + return Xstrcmp(t, s1, s2) +} + +func X__builtin_strcpy(t *TLS, dest, src uintptr) uintptr { + if __ccgo_strace { + trc("t=%v src=%v, (%v:)", t, src, origin(2)) + } + return Xstrcpy(t, dest, src) +} + +func X__builtin_strlen(t *TLS, s uintptr) types.Size_t { + if __ccgo_strace { + trc("t=%v s=%v, (%v:)", t, s, origin(2)) + } + return Xstrlen(t, s) +} + +func X__builtin_trap(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + Xabort(t) +} + +func X__isnan(t *TLS, arg float64) int32 { + if __ccgo_strace { + trc("t=%v arg=%v, (%v:)", t, arg, origin(2)) + } + return X__builtin_isnan(t, arg) +} + +func X__isnanf(t *TLS, arg float32) int32 { + if __ccgo_strace { + trc("t=%v arg=%v, (%v:)", t, arg, origin(2)) + } + return Xisnanf(t, arg) +} + +func X__isnanl(t *TLS, arg float64) int32 { + if __ccgo_strace { + trc("t=%v arg=%v, (%v:)", t, arg, origin(2)) + } + return Xisnanl(t, arg) +} + +func Xvfprintf(t *TLS, stream, format, ap uintptr) int32 { + if __ccgo_strace { + trc("t=%v ap=%v, (%v:)", t, ap, origin(2)) + } + return Xfprintf(t, stream, format, ap) +} + +// int __builtin_popcount (unsigned int x) +func X__builtin_popcount(t *TLS, x uint32) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return int32(mbits.OnesCount32(x)) +} + +// int __builtin_popcountl (unsigned long x) +func X__builtin_popcountl(t *TLS, x ulong) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return int32(mbits.OnesCount64(uint64(x))) +} + +// int __builtin_popcountll (unsigned long long) +func X__builtin_popcountll(t *TLS, x uint64) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return int32(mbits.OnesCount64(uint64(x))) +} + +// char * __builtin___strcpy_chk (char *dest, const char *src, size_t os); +func X__builtin___strcpy_chk(t *TLS, dest, src uintptr, os types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v src=%v os=%v, (%v:)", t, src, os, origin(2)) + } + return Xstrcpy(t, dest, src) +} + +func X__builtin_mmap(t *TLS, addr uintptr, length types.Size_t, prot, flags, fd int32, offset types.Off_t) uintptr { + if __ccgo_strace { + trc("t=%v addr=%v length=%v fd=%v offset=%v, (%v:)", t, addr, length, fd, offset, origin(2)) + } + return Xmmap(t, addr, length, prot, flags, fd, offset) +} + +// uint16_t __builtin_bswap16 (uint32_t x) +func X__builtin_bswap16(t *TLS, x uint16) uint16 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return x<<8 | + x>>8 +} + +// uint32_t __builtin_bswap32 (uint32_t x) +func X__builtin_bswap32(t *TLS, x uint32) uint32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return x<<24 | + x&0xff00<<8 | + x&0xff0000>>8 | + x>>24 +} + +// uint64_t __builtin_bswap64 (uint64_t x) +func X__builtin_bswap64(t *TLS, x uint64) uint64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return x<<56 | + x&0xff00<<40 | + x&0xff0000<<24 | + x&0xff000000<<8 | + x&0xff00000000>>8 | + x&0xff0000000000>>24 | + x&0xff000000000000>>40 | + x>>56 +} + +// bool __builtin_add_overflow (type1 a, type2 b, type3 *res) +func X__builtin_add_overflowInt64(t *TLS, a, b int64, res uintptr) int32 { + if __ccgo_strace { + trc("t=%v b=%v res=%v, (%v:)", t, b, res, origin(2)) + } + r, ovf := mathutil.AddOverflowInt64(a, b) + *(*int64)(unsafe.Pointer(res)) = r + return Bool32(ovf) +} + +// bool __builtin_add_overflow (type1 a, type2 b, type3 *res) +func X__builtin_add_overflowUint32(t *TLS, a, b uint32, res uintptr) int32 { + if __ccgo_strace { + trc("t=%v b=%v res=%v, (%v:)", t, b, res, origin(2)) + } + r := a + b + *(*uint32)(unsafe.Pointer(res)) = r + return Bool32(r < a) +} + +// bool __builtin_add_overflow (type1 a, type2 b, type3 *res) +func X__builtin_add_overflowUint64(t *TLS, a, b uint64, res uintptr) int32 { + if __ccgo_strace { + trc("t=%v b=%v res=%v, (%v:)", t, b, res, origin(2)) + } + r := a + b + *(*uint64)(unsafe.Pointer(res)) = r + return Bool32(r < a) +} + +// bool __builtin_sub_overflow (type1 a, type2 b, type3 *res) +func X__builtin_sub_overflowInt64(t *TLS, a, b int64, res uintptr) int32 { + if __ccgo_strace { + trc("t=%v b=%v res=%v, (%v:)", t, b, res, origin(2)) + } + r, ovf := mathutil.SubOverflowInt64(a, b) + *(*int64)(unsafe.Pointer(res)) = r + return Bool32(ovf) +} + +// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res) +func X__builtin_mul_overflowInt64(t *TLS, a, b int64, res uintptr) int32 { + if __ccgo_strace { + trc("t=%v b=%v res=%v, (%v:)", t, b, res, origin(2)) + } + r, ovf := mathutil.MulOverflowInt64(a, b) + *(*int64)(unsafe.Pointer(res)) = r + return Bool32(ovf) +} + +// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res) +func X__builtin_mul_overflowUint64(t *TLS, a, b uint64, res uintptr) int32 { + if __ccgo_strace { + trc("t=%v b=%v res=%v, (%v:)", t, b, res, origin(2)) + } + hi, lo := mbits.Mul64(a, b) + *(*uint64)(unsafe.Pointer(res)) = lo + return Bool32(hi != 0) +} + +// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res) +func X__builtin_mul_overflowUint128(t *TLS, a, b Uint128, res uintptr) int32 { + if __ccgo_strace { + trc("t=%v b=%v res=%v, (%v:)", t, b, res, origin(2)) + } + r, ovf := a.mulOvf(b) + *(*Uint128)(unsafe.Pointer(res)) = r + return Bool32(ovf) +} + +func X__builtin_unreachable(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + fmt.Fprintf(os.Stderr, "unrechable\n") + os.Stderr.Sync() + Xexit(t, 1) +} + +func X__builtin_snprintf(t *TLS, str uintptr, size types.Size_t, format, args uintptr) int32 { + if __ccgo_strace { + trc("t=%v str=%v size=%v args=%v, (%v:)", t, str, size, args, origin(2)) + } + return Xsnprintf(t, str, size, format, args) +} + +func X__builtin_sprintf(t *TLS, str, format, args uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v args=%v, (%v:)", t, args, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsprintf(t, str, format, args) +} + +func X__builtin_memcpy(t *TLS, dest, src uintptr, n types.Size_t) (r uintptr) { + if __ccgo_strace { + trc("t=%v src=%v n=%v, (%v:)", t, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xmemcpy(t, dest, src, n) +} + +// void * __builtin___memcpy_chk (void *dest, const void *src, size_t n, size_t os); +func X__builtin___memcpy_chk(t *TLS, dest, src uintptr, n, os types.Size_t) (r uintptr) { + if __ccgo_strace { + trc("t=%v src=%v os=%v, (%v:)", t, src, os, origin(2)) + defer func() { trc("-> %v", r) }() + } + if os != ^types.Size_t(0) && n < os { + Xabort(t) + } + + return Xmemcpy(t, dest, src, n) +} + +func X__builtin_memset(t *TLS, s uintptr, c int32, n types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v s=%v c=%v n=%v, (%v:)", t, s, c, n, origin(2)) + } + return Xmemset(t, s, c, n) +} + +// void * __builtin___memset_chk (void *s, int c, size_t n, size_t os); +func X__builtin___memset_chk(t *TLS, s uintptr, c int32, n, os types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v s=%v c=%v os=%v, (%v:)", t, s, c, os, origin(2)) + } + if os < n { + Xabort(t) + } + + return Xmemset(t, s, c, n) +} + +// size_t __builtin_object_size (const void * ptr, int type) +func X__builtin_object_size(t *TLS, p uintptr, typ int32) types.Size_t { + if __ccgo_strace { + trc("t=%v p=%v typ=%v, (%v:)", t, p, typ, origin(2)) + } + switch typ { + case 0, 1: + return ^types.Size_t(0) + default: + return 0 + } +} + +var atomicLoadStore16 sync.Mutex + +func AtomicStoreNUint8(ptr uintptr, val uint8, memorder int32) { + a_store_8(ptr, val) +} + +func AtomicStoreNUint16(ptr uintptr, val uint16, memorder int32) { + a_store_16(ptr, val) +} + +// int sprintf(char *str, const char *format, ...); +func Xsprintf(t *TLS, str, format, args uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v args=%v, (%v:)", t, args, origin(2)) + defer func() { trc("-> %v", r) }() + } + b := printf(format, args) + r = int32(len(b)) + copy((*RawMem)(unsafe.Pointer(str))[:r:r], b) + *(*byte)(unsafe.Pointer(str + uintptr(r))) = 0 + return int32(len(b)) +} + +// int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...); +func X__builtin___sprintf_chk(t *TLS, s uintptr, flag int32, os types.Size_t, format, args uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v s=%v flag=%v os=%v args=%v, (%v:)", t, s, flag, os, args, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xsprintf(t, s, format, args) +} + +// void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); +func Xqsort(t *TLS, base uintptr, nmemb, size types.Size_t, compar uintptr) { + if __ccgo_strace { + trc("t=%v base=%v size=%v compar=%v, (%v:)", t, base, size, compar, origin(2)) + } + sort.Sort(&sorter{ + len: int(nmemb), + base: base, + sz: uintptr(size), + f: (*struct { + f func(*TLS, uintptr, uintptr) int32 + })(unsafe.Pointer(&struct{ uintptr }{compar})).f, + t: t, + }) +} + +// void __assert_fail(const char * assertion, const char * file, unsigned int line, const char * function); +func X__assert_fail(t *TLS, assertion, file uintptr, line uint32, function uintptr) { + if __ccgo_strace { + trc("t=%v file=%v line=%v function=%v, (%v:)", t, file, line, function, origin(2)) + } + fmt.Fprintf(os.Stderr, "assertion failure: %s:%d.%s: %s\n", GoString(file), line, GoString(function), GoString(assertion)) + if memgrind { + fmt.Fprintf(os.Stderr, "%s\n", debug.Stack()) + } + os.Stderr.Sync() + Xexit(t, 1) +} + +// int vprintf(const char *format, va_list ap); + +func Xvprintf(t *TLS, s, ap uintptr) int32 { + if __ccgo_strace { + trc("t=%v ap=%v, (%v:)", t, ap, origin(2)) + } + return Xprintf(t, s, ap) +} + +// int vsprintf(char *str, const char *format, va_list ap); +func Xvsprintf(t *TLS, str, format, va uintptr) int32 { + if __ccgo_strace { + trc("t=%v va=%v, (%v:)", t, va, origin(2)) + } + return Xsprintf(t, str, format, va) +} + +// int vsnprintf(char *str, size_t size, const char *format, va_list ap); +func Xvsnprintf(t *TLS, str uintptr, size types.Size_t, format, va uintptr) int32 { + if __ccgo_strace { + trc("t=%v str=%v size=%v va=%v, (%v:)", t, str, size, va, origin(2)) + } + return Xsnprintf(t, str, size, format, va) +} + +func X__builtin_vsnprintf(t *TLS, str uintptr, size types.Size_t, format, va uintptr) int32 { + if __ccgo_strace { + trc("t=%v str=%v size=%v va=%v, (%v:)", t, str, size, va, origin(2)) + } + return Xvsnprintf(t, str, size, format, va) +} + +// int obstack_vprintf (struct obstack *obstack, const char *template, va_list ap) +func Xobstack_vprintf(t *TLS, obstack, template, va uintptr) int32 { + if __ccgo_strace { + trc("t=%v va=%v, (%v:)", t, va, origin(2)) + } + panic(todo("")) +} + +// extern void _obstack_newchunk(struct obstack *, int); +func X_obstack_newchunk(t *TLS, obstack uintptr, length int32) int32 { + if __ccgo_strace { + trc("t=%v obstack=%v length=%v, (%v:)", t, obstack, length, origin(2)) + } + panic(todo("")) +} + +// int _obstack_begin (struct obstack *h, _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment, void *(*chunkfun) (size_t), void (*freefun) (void *)) +func X_obstack_begin(t *TLS, obstack uintptr, size, alignment int32, chunkfun, freefun uintptr) int32 { + if __ccgo_strace { + trc("t=%v obstack=%v alignment=%v freefun=%v, (%v:)", t, obstack, alignment, freefun, origin(2)) + } + panic(todo("")) +} + +// void obstack_free (struct obstack *h, void *obj) +func Xobstack_free(t *TLS, obstack, obj uintptr) { + if __ccgo_strace { + trc("t=%v obj=%v, (%v:)", t, obj, origin(2)) + } + panic(todo("")) +} + +// unsigned int sleep(unsigned int seconds); +func Xsleep(t *TLS, seconds uint32) uint32 { + if __ccgo_strace { + trc("t=%v seconds=%v, (%v:)", t, seconds, origin(2)) + } + gotime.Sleep(gotime.Second * gotime.Duration(seconds)) + return 0 +} + +// size_t strcspn(const char *s, const char *reject); +func Xstrcspn(t *TLS, s, reject uintptr) (r types.Size_t) { + if __ccgo_strace { + trc("t=%v reject=%v, (%v:)", t, reject, origin(2)) + defer func() { trc("-> %v", r) }() + } + bits := newBits(256) + for { + c := *(*byte)(unsafe.Pointer(reject)) + if c == 0 { + break + } + + reject++ + bits.set(int(c)) + } + for { + c := *(*byte)(unsafe.Pointer(s)) + if c == 0 || bits.has(int(c)) { + return r + } + + s++ + r++ + } +} + +// int printf(const char *format, ...); +func Xprintf(t *TLS, format, args uintptr) int32 { + if __ccgo_strace { + trc("t=%v args=%v, (%v:)", t, args, origin(2)) + } + n, _ := write(printf(format, args)) + return int32(n) +} + +// int snprintf(char *str, size_t size, const char *format, ...); +func Xsnprintf(t *TLS, str uintptr, size types.Size_t, format, args uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v str=%v size=%v args=%v, (%v:)", t, str, size, args, origin(2)) + defer func() { trc("-> %v", r) }() + } + if format == 0 { + return 0 + } + + b := printf(format, args) + r = int32(len(b)) + if size == 0 { + return r + } + + if len(b)+1 > int(size) { + b = b[:size-1] + } + n := len(b) + copy((*RawMem)(unsafe.Pointer(str))[:n:n], b) + *(*byte)(unsafe.Pointer(str + uintptr(n))) = 0 + return r +} + +// int __builtin___snprintf_chk(char * str, size_t maxlen, int flag, size_t os, const char * format, ...); +func X__builtin___snprintf_chk(t *TLS, str uintptr, maxlen types.Size_t, flag int32, os types.Size_t, format, args uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v str=%v maxlen=%v flag=%v os=%v args=%v, (%v:)", t, str, maxlen, flag, os, args, origin(2)) + defer func() { trc("-> %v", r) }() + } + if os != ^types.Size_t(0) && maxlen > os { + Xabort(t) + } + + return Xsnprintf(t, str, maxlen, format, args) +} + +// int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os, const char *fmt, va_list ap); +func X__builtin___vsnprintf_chk(t *TLS, str uintptr, maxlen types.Size_t, flag int32, os types.Size_t, format, args uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v str=%v maxlen=%v flag=%v os=%v args=%v, (%v:)", t, str, maxlen, flag, os, args, origin(2)) + defer func() { trc("-> %v", r) }() + } + if os != ^types.Size_t(0) && maxlen > os { + Xabort(t) + } + + return Xsnprintf(t, str, maxlen, format, args) +} + +// int abs(int j); +func Xabs(t *TLS, j int32) int32 { + if __ccgo_strace { + trc("t=%v j=%v, (%v:)", t, j, origin(2)) + } + if j >= 0 { + return j + } + + return -j +} + +// long abs(long j); +func Xlabs(t *TLS, j long) long { + if __ccgo_strace { + trc("t=%v j=%v, (%v:)", t, j, origin(2)) + } + if j >= 0 { + return j + } + + return -j +} + +func Xllabs(tls *TLS, a int64) int64 { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + } + if a >= int64(0) { + return a + } + + return -a +} + +func X__builtin_isnan(t *TLS, x float64) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Bool32(math.IsNaN(x)) +} + +func X__builtin_llabs(tls *TLS, a int64) int64 { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + } + return Xllabs(tls, a) +} + +func Xacos(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Acos(x) +} + +func Xacosf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Acos(float64(x))) +} + +func Xacosh(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Acosh(x) +} + +func Xacoshf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Acosh(float64(x))) +} + +func Xasin(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Asin(x) +} + +func Xasinf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Asin(float64(x))) +} + +func Xasinh(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Asinh(x) +} + +func Xasinhf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Asinh(float64(x))) +} + +func Xatan(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Atan(x) +} + +func Xatanf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Atan(float64(x))) +} + +func Xatan2(t *TLS, x, y float64) float64 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return math.Atan2(x, y) +} + +func Xatan2f(t *TLS, x, y float32) float32 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return float32(math.Atan2(float64(x), float64(y))) +} + +func Xatanh(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Atanh(x) +} + +func Xatanhf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Atanh(float64(x))) +} + +func Xceil(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Ceil(x) +} + +func Xceilf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Ceil(float64(x))) +} + +func Xcopysign(t *TLS, x, y float64) float64 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return math.Copysign(x, y) +} + +func Xcopysignf(t *TLS, x, y float32) float32 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return float32(math.Copysign(float64(x), float64(y))) +} + +func Xcos(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Cos(x) +} + +func Xcosf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Cos(float64(x))) +} + +func Xcosh(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Cosh(x) +} + +func Xcoshf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Cosh(float64(x))) +} + +func Xexp(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Exp(x) +} + +func Xexpf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Exp(float64(x))) +} + +func Xfabs(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Abs(x) +} + +func Xfabsf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Abs(float64(x))) +} + +func Xfloor(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Floor(x) +} + +func Xfloorf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Floor(float64(x))) +} + +func Xfmod(t *TLS, x, y float64) float64 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return math.Mod(x, y) +} + +func Xfmodf(t *TLS, x, y float32) float32 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return float32(math.Mod(float64(x), float64(y))) +} + +func X__builtin_hypot(t *TLS, x float64, y float64) (r float64) { + return Xhypot(t, x, y) +} + +func Xhypot(t *TLS, x, y float64) float64 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return math.Hypot(x, y) +} + +func Xhypotf(t *TLS, x, y float32) float32 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return float32(math.Hypot(float64(x), float64(y))) +} + +func Xisnan(t *TLS, x float64) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return X__builtin_isnan(t, x) +} + +func Xisnanf(t *TLS, x float32) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Bool32(math.IsNaN(float64(x))) +} + +func Xisnanl(t *TLS, x float64) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Bool32(math.IsNaN(x)) +} // ccgo has to handle long double as double as Go does not support long double. + +func Xldexp(t *TLS, x float64, exp int32) float64 { + if __ccgo_strace { + trc("t=%v x=%v exp=%v, (%v:)", t, x, exp, origin(2)) + } + return math.Ldexp(x, int(exp)) +} + +func Xlog(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Log(x) +} + +func Xlogf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Log(float64(x))) +} + +func Xlog10(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Log10(x) +} + +func Xlog10f(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Log10(float64(x))) +} + +func X__builtin_log2(t *TLS, x float64) float64 { + return Xlog2(t, x) +} + +func Xlog2(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Log2(x) +} + +func Xlog2f(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Log2(float64(x))) +} + +func Xround(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Round(x) +} + +func Xroundf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Round(float64(x))) +} + +func X__builtin_round(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Round(x) +} + +func X__builtin_roundf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Round(float64(x))) +} + +func Xsin(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Sin(x) +} + +func Xsinf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Sin(float64(x))) +} + +func Xsinh(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Sinh(x) +} + +func Xsinhf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Sinh(float64(x))) +} + +func Xsqrt(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Sqrt(x) +} + +func Xsqrtf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Sqrt(float64(x))) +} + +func Xtan(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Tan(x) +} + +func Xtanf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Tan(float64(x))) +} + +func Xtanh(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Tanh(x) +} + +func Xtanhf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Tanh(float64(x))) +} + +func Xtrunc(t *TLS, x float64) float64 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return math.Trunc(x) +} + +func Xtruncf(t *TLS, x float32) float32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return float32(math.Trunc(float64(x))) +} + +var nextRand = uint64(1) + +// int rand(void); +func Xrand(t *TLS) int32 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + nextRand = nextRand*1103515245 + 12345 + return int32(uint32(nextRand / (math.MaxUint32 + 1) % math.MaxInt32)) +} + +func Xpow(t *TLS, x, y float64) float64 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + r := math.Pow(x, y) + if x > 0 && r == 1 && y >= -1.0000000000000000715e-18 && y < -1e-30 { + r = 0.9999999999999999 + } + return r +} + +func Xpowf(t *TLS, x, y float32) float32 { + if __ccgo_strace { + trc("t=%v y=%v, (%v:)", t, y, origin(2)) + } + return float32(math.Pow(float64(x), float64(y))) +} + +func Xfrexp(t *TLS, x float64, exp uintptr) float64 { + if __ccgo_strace { + trc("t=%v x=%v exp=%v, (%v:)", t, x, exp, origin(2)) + } + f, e := math.Frexp(x) + *(*int32)(unsafe.Pointer(exp)) = int32(e) + return f +} + +func Xfrexpf(t *TLS, x float32, exp uintptr) float32 { + if __ccgo_strace { + trc("t=%v x=%v exp=%v, (%v:)", t, x, exp, origin(2)) + } + f, e := math.Frexp(float64(x)) + *(*int32)(unsafe.Pointer(exp)) = int32(e) + return float32(f) +} + +func Xmodf(t *TLS, x float64, iptr uintptr) float64 { + if __ccgo_strace { + trc("t=%v x=%v iptr=%v, (%v:)", t, x, iptr, origin(2)) + } + i, f := math.Modf(x) + *(*float64)(unsafe.Pointer(iptr)) = i + return f +} + +func Xmodff(t *TLS, x float32, iptr uintptr) float32 { + if __ccgo_strace { + trc("t=%v x=%v iptr=%v, (%v:)", t, x, iptr, origin(2)) + } + i, f := math.Modf(float64(x)) + *(*float32)(unsafe.Pointer(iptr)) = float32(i) + return float32(f) +} + +// char *strncpy(char *dest, const char *src, size_t n) +func Xstrncpy(t *TLS, dest, src uintptr, n types.Size_t) (r uintptr) { + if __ccgo_strace { + trc("t=%v src=%v n=%v, (%v:)", t, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + r = dest + for c := *(*int8)(unsafe.Pointer(src)); c != 0 && n > 0; n-- { + *(*int8)(unsafe.Pointer(dest)) = c + dest++ + src++ + c = *(*int8)(unsafe.Pointer(src)) + } + for ; uintptr(n) > 0; n-- { + *(*int8)(unsafe.Pointer(dest)) = 0 + dest++ + } + return r +} + +// char * __builtin___strncpy_chk (char *dest, const char *src, size_t n, size_t os); +func X__builtin___strncpy_chk(t *TLS, dest, src uintptr, n, os types.Size_t) (r uintptr) { + if __ccgo_strace { + trc("t=%v src=%v os=%v, (%v:)", t, src, os, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n != ^types.Size_t(0) && os < n { + Xabort(t) + } + + return Xstrncpy(t, dest, src, n) +} + +// int strcmp(const char *s1, const char *s2) +func Xstrcmp(t *TLS, s1, s2 uintptr) int32 { + if __ccgo_strace { + trc("t=%v s2=%v, (%v:)", t, s2, origin(2)) + } + for { + ch1 := *(*byte)(unsafe.Pointer(s1)) + s1++ + ch2 := *(*byte)(unsafe.Pointer(s2)) + s2++ + if ch1 != ch2 || ch1 == 0 || ch2 == 0 { + return int32(ch1) - int32(ch2) + } + } +} + +// char *strcat(char *dest, const char *src) +func Xstrcat(t *TLS, dest, src uintptr) (r uintptr) { + if __ccgo_strace { + trc("t=%v src=%v, (%v:)", t, src, origin(2)) + defer func() { trc("-> %v", r) }() + } + r = dest + for *(*int8)(unsafe.Pointer(dest)) != 0 { + dest++ + } + for { + c := *(*int8)(unsafe.Pointer(src)) + src++ + *(*int8)(unsafe.Pointer(dest)) = c + dest++ + if c == 0 { + return r + } + } +} + +// char * __builtin___strcat_chk (char *dest, const char *src, size_t os); +func X__builtin___strcat_chk(t *TLS, dest, src uintptr, os types.Size_t) (r uintptr) { + if __ccgo_strace { + trc("t=%v src=%v os=%v, (%v:)", t, src, os, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xstrcat(t, dest, src) +} + +// int strncmp(const char *s1, const char *s2, size_t n) +func Xstrncmp(t *TLS, s1, s2 uintptr, n types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v s2=%v n=%v, (%v:)", t, s2, n, origin(2)) + } + var ch1, ch2 byte + for ; n != 0; n-- { + ch1 = *(*byte)(unsafe.Pointer(s1)) + s1++ + ch2 = *(*byte)(unsafe.Pointer(s2)) + s2++ + if ch1 != ch2 { + return int32(ch1) - int32(ch2) + } + + if ch1 == 0 { + return 0 + } + } + return 0 +} + +// char *strcpy(char *dest, const char *src) +func Xstrcpy(t *TLS, dest, src uintptr) (r uintptr) { + if __ccgo_strace { + trc("t=%v src=%v, (%v:)", t, src, origin(2)) + defer func() { trc("-> %v", r) }() + } + r = dest + // src0 := src + for ; ; dest++ { + c := *(*int8)(unsafe.Pointer(src)) + src++ + *(*int8)(unsafe.Pointer(dest)) = c + if c == 0 { + return r + } + } +} + +// char *strchr(const char *s, int c) +func Xstrchr(t *TLS, s uintptr, c int32) uintptr { + if __ccgo_strace { + trc("t=%v s=%v c=%v, (%v:)", t, s, c, origin(2)) + } + for { + ch2 := *(*byte)(unsafe.Pointer(s)) + if ch2 == byte(c) { + return s + } + + if ch2 == 0 { + return 0 + } + + s++ + } +} + +// char *strrchr(const char *s, int c) +func Xstrrchr(t *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("t=%v s=%v c=%v, (%v:)", t, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + for { + ch2 := *(*byte)(unsafe.Pointer(s)) + if ch2 == 0 { + return r + } + + if ch2 == byte(c) { + r = s + } + s++ + } +} + +// void *memset(void *s, int c, size_t n) +func Xmemset(t *TLS, dest uintptr, c int32, n types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v s=%v c=%v n=%v, (%v:)", t, dest, c, n, origin(2)) + } + var c8 uint8 + var c32 uint32 + var c64 uint64 + var k types.Size_t + var s uintptr + + s = dest + /* Fill head and tail with minimal branching. Each + * conditional ensures that all the subsequently used + * offsets are well-defined and in the dest region. */ + if n == 0 { + return dest + } + c8 = uint8(c) + *(*uint8)(unsafe.Pointer(s)) = c8 + *(*uint8)(unsafe.Pointer(s + uintptr(n-1))) = c8 + if n <= types.Size_t(2) { + return dest + } + *(*uint8)(unsafe.Pointer(s + 1)) = c8 + *(*uint8)(unsafe.Pointer(s + 2)) = c8 + *(*uint8)(unsafe.Pointer(s + uintptr(n-2))) = c8 + *(*uint8)(unsafe.Pointer(s + uintptr(n-3))) = c8 + if n <= types.Size_t(6) { + return dest + } + *(*uint8)(unsafe.Pointer(s + 3)) = c8 + *(*uint8)(unsafe.Pointer(s + uintptr(n-4))) = c8 + if n <= types.Size_t(8) { + return dest + } + /* Advance pointer to align it at a 4-byte boundary, + * and truncate n to a multiple of 4. The previous code + * already took care of any head/tail that get cut off + * by the alignment. */ + k = -types.Size_t(s) & types.Size_t(3) + s += uintptr(k) + n -= k + n &= types.Size_t(-Int32FromInt32(4)) + c32 = uint32(0x01010101) * uint32(c8) + /* In preparation to copy 32 bytes at a time, aligned on + * an 8-byte bounary, fill head/tail up to 28 bytes each. + * As in the initial byte-based head/tail fill, each + * conditional below ensures that the subsequent offsets + * are valid (e.g. !(n<=24) implies n>=28). */ + *(*uint32)(unsafe.Pointer(s + uintptr(0))) = c32 + *(*uint32)(unsafe.Pointer(s + uintptr(n-4))) = c32 + if n <= types.Size_t(8) { + return dest + } + c64 = uint64(c32) | (uint64(c32) << 32) + *(*uint64)(unsafe.Pointer(s + uintptr(4))) = c64 + *(*uint64)(unsafe.Pointer(s + uintptr(n-12))) = c64 + if n <= types.Size_t(24) { + return dest + } + *(*uint64)(unsafe.Pointer(s + uintptr(12))) = c64 + *(*uint64)(unsafe.Pointer(s + uintptr(20))) = c64 + *(*uint64)(unsafe.Pointer(s + uintptr(n-28))) = c64 + *(*uint64)(unsafe.Pointer(s + uintptr(n-20))) = c64 + /* Align to a multiple of 8 so we can fill 64 bits at a time, + * and avoid writing the same bytes twice as much as is + * practical without introducing additional branching. */ + k = types.Size_t(24) + types.Size_t(s)&types.Size_t(4) + s += uintptr(k) + n -= k + /* If this loop is reached, 28 tail bytes have already been + * filled, so any remainder when n drops below 32 can be + * safely ignored. */ + for { + if !(n >= types.Size_t(32)) { + break + } + *(*uint64)(unsafe.Pointer(s + uintptr(0))) = c64 + *(*uint64)(unsafe.Pointer(s + uintptr(8))) = c64 + *(*uint64)(unsafe.Pointer(s + uintptr(16))) = c64 + *(*uint64)(unsafe.Pointer(s + uintptr(24))) = c64 + n -= types.Size_t(32) + s += uintptr(32) + } + return dest +} + +// void *memcpy(void *dest, const void *src, size_t n); +func Xmemcpy(t *TLS, dest, src uintptr, n types.Size_t) (r uintptr) { + if __ccgo_strace { + trc("t=%v src=%v n=%v, (%v:)", t, src, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n != 0 { + copy((*RawMem)(unsafe.Pointer(dest))[:n:n], (*RawMem)(unsafe.Pointer(src))[:n:n]) + } + return dest +} + +// int memcmp(const void *s1, const void *s2, size_t n); +func Xmemcmp(t *TLS, s1, s2 uintptr, n types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v s2=%v n=%v, (%v:)", t, s2, n, origin(2)) + } + for ; n != 0; n-- { + c1 := *(*byte)(unsafe.Pointer(s1)) + s1++ + c2 := *(*byte)(unsafe.Pointer(s2)) + s2++ + if c1 < c2 { + return -1 + } + + if c1 > c2 { + return 1 + } + } + return 0 +} + +// void *memchr(const void *s, int c, size_t n); +func Xmemchr(t *TLS, s uintptr, c int32, n types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v s=%v c=%v n=%v, (%v:)", t, s, c, n, origin(2)) + } + for ; n != 0; n-- { + if *(*byte)(unsafe.Pointer(s)) == byte(c) { + return s + } + + s++ + } + return 0 +} + +// void *memmove(void *dest, const void *src, size_t n); +func Xmemmove(t *TLS, dest, src uintptr, n types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v src=%v n=%v, (%v:)", t, src, n, origin(2)) + } + if n == 0 { + return dest + } + + copy((*RawMem)(unsafe.Pointer(uintptr(dest)))[:n:n], (*RawMem)(unsafe.Pointer(uintptr(src)))[:n:n]) + return dest +} + +// void * __builtin___memmove_chk (void *dest, const void *src, size_t n, size_t os); +func X__builtin___memmove_chk(t *TLS, dest, src uintptr, n, os types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v src=%v os=%v, (%v:)", t, src, os, origin(2)) + } + if os != ^types.Size_t(0) && os < n { + Xabort(t) + } + + return Xmemmove(t, dest, src, n) +} + +// char *getenv(const char *name); +func Xgetenv(t *TLS, name uintptr) uintptr { + if __ccgo_strace { + trc("t=%v name=%v, (%v:)", t, name, origin(2)) + } + return getenv(Environ(), GoString(name)) +} + +func getenv(p uintptr, nm string) uintptr { + for ; ; p += uintptrSize { + q := *(*uintptr)(unsafe.Pointer(p)) + if q == 0 { + return 0 + } + + s := GoString(q) + a := strings.SplitN(s, "=", 2) + if len(a) != 2 { + panic(todo("%q %q %q", nm, s, a)) + } + + if a[0] == nm { + return q + uintptr(len(nm)) + 1 + } + } +} + +// char *strstr(const char *haystack, const char *needle); +func Xstrstr(t *TLS, haystack, needle uintptr) uintptr { + if __ccgo_strace { + trc("t=%v needle=%v, (%v:)", t, needle, origin(2)) + } + hs := GoString(haystack) + nd := GoString(needle) + if i := strings.Index(hs, nd); i >= 0 { + r := haystack + uintptr(i) + return r + } + + return 0 +} + +// int putc(int c, FILE *stream); +func Xputc(t *TLS, c int32, fp uintptr) int32 { + if __ccgo_strace { + trc("t=%v c=%v fp=%v, (%v:)", t, c, fp, origin(2)) + } + return Xfputc(t, c, fp) +} + +// int atoi(const char *nptr); +func Xatoi(t *TLS, nptr uintptr) int32 { + if __ccgo_strace { + trc("t=%v nptr=%v, (%v:)", t, nptr, origin(2)) + } + + _, neg, _, n, _ := strToUint64(t, nptr, 10) + switch { + case neg: + return int32(-n) + default: + return int32(n) + } +} + +// double atof(const char *nptr); +func Xatof(t *TLS, nptr uintptr) float64 { + if __ccgo_strace { + trc("t=%v nptr=%v, (%v:)", t, nptr, origin(2)) + } + n, _ := strToFloatt64(t, nptr, 64) + // if dmesgs { + // dmesg("%v: %q: %v", origin(1), GoString(nptr), n) + // } + return n +} + +// int tolower(int c); +func Xtolower(t *TLS, c int32) int32 { + if __ccgo_strace { + trc("t=%v c=%v, (%v:)", t, c, origin(2)) + } + if c >= 'A' && c <= 'Z' { + return c + ('a' - 'A') + } + + return c +} + +// int toupper(int c); +func Xtoupper(t *TLS, c int32) int32 { + if __ccgo_strace { + trc("t=%v c=%v, (%v:)", t, c, origin(2)) + } + if c >= 'a' && c <= 'z' { + return c - ('a' - 'A') + } + + return c +} + +// int isatty(int fd); +func Xisatty(t *TLS, fd int32) int32 { + if __ccgo_strace { + trc("t=%v fd=%v, (%v:)", t, fd, origin(2)) + } + return Bool32(isatty.IsTerminal(uintptr(fd))) +} + +// long atol(const char *nptr); +func Xatol(t *TLS, nptr uintptr) long { + if __ccgo_strace { + trc("t=%v nptr=%v, (%v:)", t, nptr, origin(2)) + } + _, neg, _, n, _ := strToUint64(t, nptr, 10) + switch { + case neg: + return long(-n) + default: + return long(n) + } +} + +func getLocalLocation() (loc *gotime.Location) { + loc = gotime.Local + if r := getenv(Environ(), "TZ"); r != 0 { + zname := GoString(r) + zone, off := parseZone(zname) + loc = gotime.FixedZone(zone, -off) + loc2, _ := gotime.LoadLocation(zname) + if loc2 != nil { + loc = loc2 + } + } + return loc + +} + +// time_t mktime(struct tm *tm); +func Xmktime(t *TLS, ptm uintptr) (r time.Time_t) { + if __ccgo_strace { + trc("t=%v ptm=%v, (%v:)", t, ptm, origin(2)) + } + loc := getLocalLocation() + tt := gotime.Date( + int((*time.Tm)(unsafe.Pointer(ptm)).Ftm_year+1900), + gotime.Month((*time.Tm)(unsafe.Pointer(ptm)).Ftm_mon+1), + int((*time.Tm)(unsafe.Pointer(ptm)).Ftm_mday), + int((*time.Tm)(unsafe.Pointer(ptm)).Ftm_hour), + int((*time.Tm)(unsafe.Pointer(ptm)).Ftm_min), + int((*time.Tm)(unsafe.Pointer(ptm)).Ftm_sec), + 0, + loc, + ) + (*time.Tm)(unsafe.Pointer(ptm)).Ftm_wday = int32(tt.Weekday()) + (*time.Tm)(unsafe.Pointer(ptm)).Ftm_yday = int32(tt.YearDay() - 1) + r = time.Time_t(tt.Unix()) + return r +} + +// char *strpbrk(const char *s, const char *accept); +func Xstrpbrk(t *TLS, s, accept uintptr) uintptr { + if __ccgo_strace { + trc("t=%v accept=%v, (%v:)", t, accept, origin(2)) + } + bits := newBits(256) + for { + b := *(*byte)(unsafe.Pointer(accept)) + if b == 0 { + break + } + + bits.set(int(b)) + accept++ + } + for { + b := *(*byte)(unsafe.Pointer(s)) + if b == 0 { + return 0 + } + + if bits.has(int(b)) { + return s + } + + s++ + } +} + +// int strcasecmp(const char *s1, const char *s2); +func Xstrcasecmp(t *TLS, s1, s2 uintptr) int32 { + if __ccgo_strace { + trc("t=%v s2=%v, (%v:)", t, s2, origin(2)) + } + for { + ch1 := *(*byte)(unsafe.Pointer(s1)) + if ch1 >= 'a' && ch1 <= 'z' { + ch1 = ch1 - ('a' - 'A') + } + s1++ + ch2 := *(*byte)(unsafe.Pointer(s2)) + if ch2 >= 'a' && ch2 <= 'z' { + ch2 = ch2 - ('a' - 'A') + } + s2++ + if ch1 != ch2 || ch1 == 0 || ch2 == 0 { + r := int32(ch1) - int32(ch2) + return r + } + } +} + +func Xntohs(t *TLS, netshort uint16) uint16 { + if __ccgo_strace { + trc("t=%v netshort=%v, (%v:)", t, netshort, origin(2)) + } + return uint16((*[2]byte)(unsafe.Pointer(&netshort))[0])<<8 | uint16((*[2]byte)(unsafe.Pointer(&netshort))[1]) +} + +// uint16_t htons(uint16_t hostshort); +func Xhtons(t *TLS, hostshort uint16) uint16 { + if __ccgo_strace { + trc("t=%v hostshort=%v, (%v:)", t, hostshort, origin(2)) + } + var a [2]byte + a[0] = byte(hostshort >> 8) + a[1] = byte(hostshort) + return *(*uint16)(unsafe.Pointer(&a)) +} + +// uint32_t htonl(uint32_t hostlong); +func Xhtonl(t *TLS, hostlong uint32) uint32 { + if __ccgo_strace { + trc("t=%v hostlong=%v, (%v:)", t, hostlong, origin(2)) + } + var a [4]byte + a[0] = byte(hostlong >> 24) + a[1] = byte(hostlong >> 16) + a[2] = byte(hostlong >> 8) + a[3] = byte(hostlong) + return *(*uint32)(unsafe.Pointer(&a)) +} + +// FILE *fopen(const char *pathname, const char *mode); +func Xfopen(t *TLS, pathname, mode uintptr) uintptr { + if __ccgo_strace { + trc("t=%v mode=%v, (%v:)", t, mode, origin(2)) + } + return Xfopen64(t, pathname, mode) //TODO 32 bit +} + +func Dmesg(s string, args ...interface{}) { + if dmesgs { + dmesg(s, args...) + } +} + +// void sqlite3_log(int iErrCode, const char *zFormat, ...); +func X__ccgo_sqlite3_log(t *TLS, iErrCode int32, zFormat uintptr, args uintptr) { + if __ccgo_strace { + trc("t=%v iErrCode=%v zFormat=%v args=%v, (%v:)", t, iErrCode, zFormat, args, origin(2)) + } + // if dmesgs { + // dmesg("%v: iErrCode: %v, msg: %s\n%s", origin(1), iErrCode, printf(zFormat, args), debug.Stack()) + // } +} + +// int _IO_putc(int __c, _IO_FILE *__fp); +func X_IO_putc(t *TLS, c int32, fp uintptr) int32 { + if __ccgo_strace { + trc("t=%v c=%v fp=%v, (%v:)", t, c, fp, origin(2)) + } + return Xputc(t, c, fp) +} + +// int atexit(void (*function)(void)); +func Xatexit(t *TLS, function uintptr) int32 { + if __ccgo_strace { + trc("t=%v function=%v, (%v:)", t, function, origin(2)) + } + AtExit(func() { + (*struct{ f func(*TLS) })(unsafe.Pointer(&struct{ uintptr }{function})).f(t) + }) + return 0 +} + +// int vasprintf(char **strp, const char *fmt, va_list ap); +func Xvasprintf(t *TLS, strp, fmt, ap uintptr) int32 { + if __ccgo_strace { + trc("t=%v ap=%v, (%v:)", t, ap, origin(2)) + } + panic(todo("")) +} + +func AtomicLoadInt32(addr *int32) (val int32) { return atomic.LoadInt32(addr) } +func AtomicLoadInt64(addr *int64) (val int64) { return atomic.LoadInt64(addr) } +func AtomicLoadUint32(addr *uint32) (val uint32) { return atomic.LoadUint32(addr) } +func AtomicLoadUint64(addr *uint64) (val uint64) { return atomic.LoadUint64(addr) } +func AtomicLoadUintptr(addr *uintptr) (val uintptr) { return atomic.LoadUintptr(addr) } + +func AtomicLoadFloat32(addr *float32) (val float32) { + return math.Float32frombits(atomic.LoadUint32((*uint32)(unsafe.Pointer(addr)))) +} + +func AtomicLoadFloat64(addr *float64) (val float64) { + return math.Float64frombits(atomic.LoadUint64((*uint64)(unsafe.Pointer(addr)))) +} + +func AtomicLoadPInt32(addr uintptr) (val int32) { + return atomic.LoadInt32((*int32)(unsafe.Pointer(addr))) +} + +func AtomicLoadPInt64(addr uintptr) (val int64) { + return atomic.LoadInt64((*int64)(unsafe.Pointer(addr))) +} + +func AtomicLoadPUint32(addr uintptr) (val uint32) { + return atomic.LoadUint32((*uint32)(unsafe.Pointer(addr))) +} + +func AtomicLoadPUint64(addr uintptr) (val uint64) { + return atomic.LoadUint64((*uint64)(unsafe.Pointer(addr))) +} + +func AtomicLoadPUintptr(addr uintptr) (val uintptr) { + return atomic.LoadUintptr((*uintptr)(unsafe.Pointer(addr))) +} + +func AtomicLoadPFloat32(addr uintptr) (val float32) { + return math.Float32frombits(atomic.LoadUint32((*uint32)(unsafe.Pointer(addr)))) +} + +func AtomicLoadPFloat64(addr uintptr) (val float64) { + return math.Float64frombits(atomic.LoadUint64((*uint64)(unsafe.Pointer(addr)))) +} + +func AtomicStoreInt32(addr *int32, val int32) { atomic.StoreInt32(addr, val) } +func AtomicStoreInt64(addr *int64, val int64) { atomic.StoreInt64(addr, val) } +func AtomicStoreUint32(addr *uint32, val uint32) { atomic.StoreUint32(addr, val) } +func AtomicStoreUint64(addr *uint64, val uint64) { atomic.StoreUint64(addr, val) } +func AtomicStoreUintptr(addr *uintptr, val uintptr) { atomic.StoreUintptr(addr, val) } + +func AtomicStoreFloat32(addr *float32, val float32) { + atomic.StoreUint32((*uint32)(unsafe.Pointer(addr)), math.Float32bits(val)) +} + +func AtomicStoreFloat64(addr *float64, val float64) { + atomic.StoreUint64((*uint64)(unsafe.Pointer(addr)), math.Float64bits(val)) +} + +func AtomicStorePInt32(addr uintptr, val int32) { + atomic.StoreInt32((*int32)(unsafe.Pointer(addr)), val) +} + +func AtomicStorePInt64(addr uintptr, val int64) { + atomic.StoreInt64((*int64)(unsafe.Pointer(addr)), val) +} + +func AtomicStorePUint32(addr uintptr, val uint32) { + atomic.StoreUint32((*uint32)(unsafe.Pointer(addr)), val) +} + +func AtomicStorePUint64(addr uintptr, val uint64) { + atomic.StoreUint64((*uint64)(unsafe.Pointer(addr)), val) +} + +func AtomicStorePUintptr(addr uintptr, val uintptr) { + atomic.StoreUintptr((*uintptr)(unsafe.Pointer(addr)), val) +} + +func AtomicStorePFloat32(addr uintptr, val float32) { + atomic.StoreUint32((*uint32)(unsafe.Pointer(addr)), math.Float32bits(val)) +} + +func AtomicStorePFloat64(addr uintptr, val float64) { + atomic.StoreUint64((*uint64)(unsafe.Pointer(addr)), math.Float64bits(val)) +} + +func AtomicAddInt32(addr *int32, delta int32) (new int32) { return atomic.AddInt32(addr, delta) } +func AtomicAddInt64(addr *int64, delta int64) (new int64) { return atomic.AddInt64(addr, delta) } +func AtomicAddUint32(addr *uint32, delta uint32) (new uint32) { return atomic.AddUint32(addr, delta) } +func AtomicAddUint64(addr *uint64, delta uint64) (new uint64) { return atomic.AddUint64(addr, delta) } + +func AtomicAddUintptr(addr *uintptr, delta uintptr) (new uintptr) { + return atomic.AddUintptr(addr, delta) + +} + +func AtomicAddFloat32(addr *float32, delta float32) (new float32) { + v := AtomicLoadFloat32(addr) + delta + AtomicStoreFloat32(addr, v) + return v +} + +func AtomicAddFloat64(addr *float64, delta float64) (new float64) { + v := AtomicLoadFloat64(addr) + delta + AtomicStoreFloat64(addr, v) + return v +} + +// size_t mbstowcs(wchar_t *dest, const char *src, size_t n); +func Xmbstowcs(t *TLS, dest, src uintptr, n types.Size_t) types.Size_t { + if __ccgo_strace { + trc("t=%v src=%v n=%v, (%v:)", t, src, n, origin(2)) + } + panic(todo("")) +} + +// int mbtowc(wchar_t *pwc, const char *s, size_t n); +func Xmbtowc(t *TLS, pwc, s uintptr, n types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v s=%v n=%v, (%v:)", t, s, n, origin(2)) + } + panic(todo("")) +} + +// size_t __ctype_get_mb_cur_max(void); +func X__ctype_get_mb_cur_max(t *TLS) types.Size_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) +} + +// int wctomb(char *s, wchar_t wc); +func Xwctomb(t *TLS, s uintptr, wc wchar_t) int32 { + if __ccgo_strace { + trc("t=%v s=%v wc=%v, (%v:)", t, s, wc, origin(2)) + } + panic(todo("")) +} + +// int mblen(const char *s, size_t n); +func Xmblen(t *TLS, s uintptr, n types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v s=%v n=%v, (%v:)", t, s, n, origin(2)) + } + panic(todo("")) +} + +// ssize_t readv(int fd, const struct iovec *iov, int iovcnt); +func Xreadv(t *TLS, fd int32, iov uintptr, iovcnt int32) types.Ssize_t { + if __ccgo_strace { + trc("t=%v fd=%v iov=%v iovcnt=%v, (%v:)", t, fd, iov, iovcnt, origin(2)) + } + panic(todo("")) +} + +// int openpty(int *amaster, int *aslave, char *name, +// +// const struct termios *termp, +// const struct winsize *winp); +func Xopenpty(t *TLS, amaster, aslave, name, termp, winp uintptr) int32 { + if __ccgo_strace { + trc("t=%v winp=%v, (%v:)", t, winp, origin(2)) + } + panic(todo("")) +} + +// pid_t setsid(void); +func Xsetsid(t *TLS) types.Pid_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) +} + +// int pselect(int nfds, fd_set *readfds, fd_set *writefds, +// +// fd_set *exceptfds, const struct timespec *timeout, +// const sigset_t *sigmask); +func Xpselect(t *TLS, nfds int32, readfds, writefds, exceptfds, timeout, sigmask uintptr) int32 { + if __ccgo_strace { + trc("t=%v nfds=%v sigmask=%v, (%v:)", t, nfds, sigmask, origin(2)) + } + panic(todo("")) +} + +// int kill(pid_t pid, int sig); +func Xkill(t *TLS, pid types.Pid_t, sig int32) int32 { + if __ccgo_strace { + trc("t=%v pid=%v sig=%v, (%v:)", t, pid, sig, origin(2)) + } + panic(todo("")) +} + +// int tcsendbreak(int fd, int duration); +func Xtcsendbreak(t *TLS, fd, duration int32) int32 { + if __ccgo_strace { + trc("t=%v duration=%v, (%v:)", t, duration, origin(2)) + } + panic(todo("")) +} + +// int wcwidth(wchar_t c); +func Xwcwidth(t *TLS, c wchar_t) int32 { + if __ccgo_strace { + trc("t=%v c=%v, (%v:)", t, c, origin(2)) + } + panic(todo("")) +} + +// AtExit will attempt to run f at process exit. The execution cannot be +// guaranteed, neither its ordering with respect to any other handlers +// registered by AtExit. +func AtExit(f func()) { + atExitMu.Lock() + atExit = append(atExit, f) + atExitMu.Unlock() +} + +func X__ccgo_dmesg(t *TLS, fmt uintptr, va uintptr) { + if __ccgo_strace { + trc("t=%v fmt=%v va=%v, (%v:)", t, fmt, va, origin(2)) + } + if dmesgs { + dmesg("%s", printf(fmt, va)) + } +} + +// int getentropy(void *buffer, size_t length); +// +// The getentropy() function writes length bytes of high-quality random data +// to the buffer starting at the location pointed to by buffer. The maximum +// permitted value for the length argument is 256. +func Xgetentropy(t *TLS, buffer uintptr, length size_t) int32 { + if __ccgo_strace { + trc("t=%v buffer=%v length=%v, (%v:)", t, buffer, length, origin(2)) + } + const max = 256 + switch { + case length == 0: + return 0 + case buffer == 0: + t.setErrno(errno.EFAULT) + return -1 + case length > max: + t.setErrno(errno.EIO) + return -1 + } + + if _, err := crand.Read((*RawMem)(unsafe.Pointer(buffer))[:length]); err != nil { + t.setErrno(errno.EIO) + return -1 + } + + return 0 +} + +// void * reallocarray(void *ptr, size_t nmemb, size_t size); +func Xreallocarray(t *TLS, ptr uintptr, nmemb, size size_t) uintptr { + if __ccgo_strace { + trc("t=%v ptr=%v size=%v, (%v:)", t, ptr, size, origin(2)) + } + hi, lo := mathutil.MulUint128_64(uint64(nmemb), uint64(size)) + if hi != 0 || lo > uint64(unsafe.Sizeof(RawMem{})) { + t.setErrno(errno.ENOMEM) + return 0 + } + + return Xrealloc(t, ptr, size_t(lo)) +} + +// int setjmp(jmp_buf env); +func Xsetjmp(t *TLS, env uintptr) int32 { + if __ccgo_strace { + trc("t=%v env=%v, (%v:)", t, env, origin(2)) + } + return 0 //TODO +} + +// void longjmp(jmp_buf env, int val); +func Xlongjmp(t *TLS, env uintptr, val int32) { + if __ccgo_strace { + trc("t=%v env=%v val=%v, (%v:)", t, env, val, origin(2)) + } + panic(todo("")) +} + +// https://linux.die.net/man/3/_setjmp +// +// The _longjmp() and _setjmp() functions shall be equivalent to longjmp() and +// setjmp(), respectively, with the additional restriction that _longjmp() and +// _setjmp() shall not manipulate the signal mask. + +// int _setjmp(jmp_buf env); +func X_setjmp(t *TLS, env uintptr) int32 { + if __ccgo_strace { + trc("t=%v env=%v, (%v:)", t, env, origin(2)) + } + return 0 //TODO +} + +// void _longjmp(jmp_buf env, int val); +func X_longjmp(t *TLS, env uintptr, val int32) { + if __ccgo_strace { + trc("t=%v env=%v val=%v, (%v:)", t, env, val, origin(2)) + } + panic(todo("")) +} + +// unsigned __sync_add_and_fetch_uint32(*unsigned, unsigned) +func X__sync_add_and_fetch_uint32(t *TLS, p uintptr, v uint32) uint32 { + if __ccgo_strace { + trc("t=%v p=%v v=%v, (%v:)", t, p, v, origin(2)) + } + return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), v) +} + +// unsigned __sync_sub_and_fetch_uint32(*unsigned, unsigned) +func X__sync_sub_and_fetch_uint32(t *TLS, p uintptr, v uint32) uint32 { + if __ccgo_strace { + trc("t=%v p=%v v=%v, (%v:)", t, p, v, origin(2)) + } + return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), -v) +} + +// int sched_yield(void); +func Xsched_yield(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + runtime.Gosched() +} + +// int getc(FILE *stream); +func Xgetc(t *TLS, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + return Xfgetc(t, stream) +} + +// char *fgets(char *s, int size, FILE *stream); +func Xfgets(t *TLS, s uintptr, size int32, stream uintptr) uintptr { + if __ccgo_strace { + trc("t=%v s=%v size=%v stream=%v, (%v:)", t, s, size, stream, origin(2)) + } + if size < 1 { + return 0 + } + if size == 1 { + *(*byte)(unsafe.Pointer(s)) = 0 + return s + } + var b []byte +out: + for ; size > 1; size-- { + switch c := Xfgetc(t, stream); c { + case '\n': + b = append(b, byte(c)) + break out + case stdio.EOF: + break out + default: + b = append(b, byte(c)) + } + } + if len(b) == 0 { + return 0 + } + + b = append(b, 0) + copy((*RawMem)(unsafe.Pointer(s))[:len(b):len(b)], b) + return s +} + +// void bzero(void *s, size_t n); +func Xbzero(t *TLS, s uintptr, n types.Size_t) { + if __ccgo_strace { + trc("t=%v s=%v n=%v, (%v:)", t, s, n, origin(2)) + } + b := (*RawMem)(unsafe.Pointer(s))[:n] + for i := range b { + b[i] = 0 + } +} + +// char *rindex(const char *s, int c); +func Xrindex(t *TLS, s uintptr, c int32) uintptr { + if __ccgo_strace { + trc("t=%v s=%v c=%v, (%v:)", t, s, c, origin(2)) + } + if s == 0 { + return 0 + } + + var r uintptr + for { + c2 := int32(*(*byte)(unsafe.Pointer(s))) + if c2 == c { + r = s + } + + if c2 == 0 { + return r + } + + s++ + } +} + +// int isascii(int c); +func Xisascii(t *TLS, c int32) int32 { + if __ccgo_strace { + trc("t=%v c=%v, (%v:)", t, c, origin(2)) + } + return Bool32(c >= 0 && c <= 0x7f) +} + +func X__builtin_isunordered(t *TLS, a, b float64) int32 { + if __ccgo_strace { + trc("t=%v b=%v, (%v:)", t, b, origin(2)) + } + return Bool32(math.IsNaN(a) || math.IsNaN(b)) +} + +func AtomicLoadNUint16(ptr uintptr, memorder int32) uint16 { + atomicLoadStore16.Lock() + r := *(*uint16)(unsafe.Pointer(ptr)) + atomicLoadStore16.Unlock() + return r +} + +func PreIncAtomicInt32P(p uintptr, d int32) int32 { + return atomic.AddInt32((*int32)(unsafe.Pointer(p)), d) +} + +func PreIncAtomicInt64P(p uintptr, d int64) int64 { + return atomic.AddInt64((*int64)(unsafe.Pointer(p)), d) +} + +func PreIncAtomicUint32P(p uintptr, d uint32) uint32 { + return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), d) +} + +func PreIncAtomicUint64P(p uintptr, d uint64) uint64 { + return atomic.AddUint64((*uint64)(unsafe.Pointer(p)), d) +} + +func PreInrAtomicUintptrP(p uintptr, d uintptr) uintptr { + return atomic.AddUintptr((*uintptr)(unsafe.Pointer(p)), d) +} + +func X__builtin_ffs(tls *TLS, i int32) (r int32) { + if __ccgo_strace { + trc("tls=%v i=%v, (%v:)", tls, i, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xffs(tls, i) +} + +func Xffs(tls *TLS, i int32) (r int32) { + if __ccgo_strace { + trc("tls=%v i=%v, (%v:)", tls, i, origin(2)) + defer func() { trc("-> %v", r) }() + } + if i == 0 { + return 0 + } + + return int32(mbits.TrailingZeros32(uint32(i))) + 1 +} + +var _toint5 = Float32FromInt32(1) / Float32FromFloat32(1.1920928955078125e-07) + +func X__builtin_rintf(tls *TLS, x float32) (r float32) { + return Xrintf(tls, x) +} + +func Xrintf(tls *TLS, x float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var e, s int32 + var y float32 + var v1 float32 + var _ /* u at bp+0 */ struct { + Fi [0]uint32 + Ff float32 + } + _, _, _, _ = e, s, y, v1 + *(*struct { + Fi [0]uint32 + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]uint32 + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + e = int32(*(*uint32)(unsafe.Pointer(bp)) >> int32(23) & uint32(0xff)) + s = int32(*(*uint32)(unsafe.Pointer(bp)) >> int32(31)) + if e >= Int32FromInt32(0x7f)+Int32FromInt32(23) { + return x + } + if s != 0 { + y = x - _toint5 + _toint5 + } else { + y = x + _toint5 - _toint5 + } + if y == Float32FromInt32(0) { + if s != 0 { + v1 = -Float32FromFloat32(0) + } else { + v1 = Float32FromFloat32(0) + } + return v1 + } + return y +} + +func X__builtin_lrintf(tls *TLS, x float32) (r long) { + return Xlrintf(tls, x) +} + +func Xlrintf(tls *TLS, x float32) (r long) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return long(Xrintf(tls, x)) +} + +func X__builtin_lrint(tls *TLS, x float64) (r long) { + return Xlrint(tls, x) +} + +func Xlrint(tls *TLS, x float64) (r long) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return long(Xrint(tls, x)) +} + +func X__builtin_trunc(tls *TLS, x float64) (r float64) { + return Xtrunc(tls, x) +} + +func X__builtin_fmin(tls *TLS, x float64, y float64) (r float64) { + return Xfmin(tls, x, y) +} + +func Xfmin(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v10, v3, v5, v7 uint64 + var v12, v9 float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _ = v1, v10, v12, v3, v5, v7, v9 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != Int32FromUint64(v7>>Int32FromInt32(63)) { + *(*float64)(unsafe.Pointer(bp)) = x + v10 = *(*uint64)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint64(v10>>Int32FromInt32(63)) != 0 { + v9 = x + } else { + v9 = y + } + return v9 + } + if x < y { + v12 = x + } else { + v12 = y + } + return v12 +} + +func Xfminf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v10, v3, v5, v7 uint32 + var v12, v9 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _, _ = v1, v10, v12, v3, v5, v7, v9 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return y + } + *(*float32)(unsafe.Pointer(bp)) = y + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 +_4: + if BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + } + /* handle signed zeros, see C99 Annex F.9.9.2 */ + *(*float32)(unsafe.Pointer(bp)) = x + v5 = *(*uint32)(unsafe.Pointer(bp)) + goto _6 +_6: + *(*float32)(unsafe.Pointer(bp)) = y + v7 = *(*uint32)(unsafe.Pointer(bp)) + goto _8 +_8: + if Int32FromUint32(v5>>Int32FromInt32(31)) != Int32FromUint32(v7>>Int32FromInt32(31)) { + *(*float32)(unsafe.Pointer(bp)) = x + v10 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v10>>Int32FromInt32(31)) != 0 { + v9 = x + } else { + v9 = y + } + return v9 + } + if x < y { + v12 = x + } else { + v12 = y + } + return v12 +} + +func Xfminl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfmin(tls, x, y) +} + +func Xfmax(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v10, v3, v5, v7 uint64 + var v12, v9 float64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + _, _, _, _, _, _, _ = v1, v10, v12, v3, v5, v7, v9 + *(*float64)(unsafe.Pointer(bp)) = x + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<>Int32FromInt32(63)) != Int32FromUint64(v7>>Int32FromInt32(63)) { + *(*float64)(unsafe.Pointer(bp)) = x + v10 = *(*uint64)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint64(v10>>Int32FromInt32(63)) != 0 { + v9 = y + } else { + v9 = x + } + return v9 + } + if x < y { + v12 = y + } else { + v12 = x + } + return v12 +} + +func Xfmaxf(tls *TLS, x float32, y float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var v1, v10, v3, v5, v7 uint32 + var v12, v9 float32 + var _ /* __u at bp+0 */ struct { + F__i [0]uint32 + F__f float32 + } + _, _, _, _, _, _, _ = v1, v10, v12, v3, v5, v7, v9 + *(*float32)(unsafe.Pointer(bp)) = x + v1 = *(*uint32)(unsafe.Pointer(bp)) + goto _2 +_2: + if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return y + } + *(*float32)(unsafe.Pointer(bp)) = y + v3 = *(*uint32)(unsafe.Pointer(bp)) + goto _4 +_4: + if BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 { + return x + } + /* handle signed zeroes, see C99 Annex F.9.9.2 */ + *(*float32)(unsafe.Pointer(bp)) = x + v5 = *(*uint32)(unsafe.Pointer(bp)) + goto _6 +_6: + *(*float32)(unsafe.Pointer(bp)) = y + v7 = *(*uint32)(unsafe.Pointer(bp)) + goto _8 +_8: + if Int32FromUint32(v5>>Int32FromInt32(31)) != Int32FromUint32(v7>>Int32FromInt32(31)) { + *(*float32)(unsafe.Pointer(bp)) = x + v10 = *(*uint32)(unsafe.Pointer(bp)) + goto _11 + _11: + if Int32FromUint32(v10>>Int32FromInt32(31)) != 0 { + v9 = y + } else { + v9 = x + } + return v9 + } + if x < y { + v12 = y + } else { + v12 = x + } + return v12 +} + +func Xfmaxl(tls *TLS, x float64, y float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xfmax(tls, x, y) +} + +func X__builtin_fmax(tls *TLS, x float64, y float64) (r float64) { + return Xfmax(tls, x, y) +} + +func Xexpm1(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, e, hfx, hi, hxs, lo, r1, t, twopk, y3 Tdouble_t + var hx Tuint32_t + var k, sign int32 + var y float32 + var y1, y2, v3 float64 + var v1 uint64 + var _ /* __u at bp+0 */ struct { + F__i [0]uint64 + F__f float64 + } + var _ /* u at bp+8 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, e, hfx, hi, hx, hxs, k, lo, r1, sign, t, twopk, y, y1, y2, y3, v1, v3 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp + 8)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp + 8)) = x3 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(32) & uint64(0x7fffffff)) + sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(63)) + /* filter out huge and non-finite argument */ + if hx >= uint32(0x4043687A) { /* if |x|>=56*ln2 */ + *(*float64)(unsafe.Pointer(bp)) = x3 + v1 = *(*uint64)(unsafe.Pointer(bp)) + goto _2 + _2: + if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)< _o_threshold { + x3 *= float64(8.98846567431158e+307) + return x3 + } + } + /* argument reduction */ + if hx > uint32(0x3fd62e42) { /* if |x| > 0.5 ln2 */ + if hx < uint32(0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ + if !(sign != 0) { + hi = x3 - _ln2_hi + lo = _ln2_lo + k = int32(1) + } else { + hi = x3 + _ln2_hi + lo = -_ln2_lo + k = -int32(1) + } + } else { + if sign != 0 { + v3 = -Float64FromFloat64(0.5) + } else { + v3 = float64(0.5) + } + k = int32(float64(_invln2*x3) + v3) + t = float64(k) + hi = x3 - float64(t*_ln2_hi) /* t*ln2_hi is exact here */ + lo = Tdouble_t(t * _ln2_lo) + } + x3 = hi - lo + c = hi - x3 - lo + } else { + if hx < uint32(0x3c900000) { /* |x| < 2**-54, return x */ + if hx < uint32(0x00100000) { + if uint64(4) == uint64(4) { + y = float32(x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(float32(x3)) + } else { + y2 = float64(float32(x3)) + } + } + } + return x3 + } else { + k = 0 + } + } + /* x is now in primary range */ + hfx = Tdouble_t(float64(0.5) * x3) + hxs = Tdouble_t(x3 * hfx) + r1 = float64(1) + float64(hxs*(_Q1+float64(hxs*(_Q2+float64(hxs*(_Q3+float64(hxs*(_Q4+float64(hxs*_Q5))))))))) + t = float64(3) - float64(r1*hfx) + e = Tdouble_t(hxs * ((r1 - t) / (Float64FromFloat64(6) - float64(x3*t)))) + if k == 0 { /* c is 0 */ + return x3 - (float64(x3*e) - hxs) + } + e = float64(x3*(e-c)) - c + e -= hxs + /* exp(x) ~ 2^k (Xreduced - e + 1) */ + if k == -int32(1) { + return float64(float64(0.5)*(x3-e)) - float64(0.5) + } + if k == int32(1) { + if x3 < -Float64FromFloat64(0.25) { + return float64(-Float64FromFloat64(2) * (e - (x3 + Float64FromFloat64(0.5)))) + } + return float64(1) + float64(float64(2)*(x3-e)) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 8)) = Uint64FromInt32(Int32FromInt32(0x3ff)+k) << int32(52) /* 2^k */ + twopk = *(*float64)(unsafe.Pointer(bp + 8)) + if k < 0 || k > int32(56) { /* suffice to return exp(x)-1 */ + y3 = x3 - e + float64(1) + if k == int32(1024) { + y3 = Tdouble_t(Tdouble_t(y3*float64(2)) * float64(8.98846567431158e+307)) + } else { + y3 = Tdouble_t(y3 * twopk) + } + return y3 - float64(1) + } + *(*Tuint64_t)(unsafe.Pointer(bp + 8)) = Uint64FromInt32(Int32FromInt32(0x3ff)-k) << int32(52) /* 2^-k */ + if k < int32(20) { + y3 = Tdouble_t((x3 - e + (Float64FromInt32(1) - *(*float64)(unsafe.Pointer(bp + 8)))) * twopk) + } else { + y3 = Tdouble_t((x3 - (e + *(*float64)(unsafe.Pointer(bp + 8))) + Float64FromInt32(1)) * twopk) + } + return y3 +} + +var _ln2_hi1 = float32(0.69313812256) /* 0x3f317180 */ +var _ln2_lo1 = float32(9.0580006145e-06) /* 0x3717f7d1 */ +var _invln21 = float32(1.4426950216) /* 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): + */ +var _Q11 = float32(-Float64FromFloat64(0.033333212137)) /* -0x888868.0p-28 */ +var _Q21 = float32(0.0015807170421) /* 0xcf3010.0p-33 */ + +func Xexpm1f(tls *TLS, x3 float32) (r float32) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var c, e, hfx, hi, hxs, lo, r1, t, twopk, y3 Tfloat_t + var hx Tuint32_t + var k, sign int32 + var y, v1 float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, e, hfx, hi, hx, hxs, k, lo, r1, sign, t, twopk, y, y1, y2, y3, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31)) + /* filter out huge and non-finite argument */ + if hx >= uint32(0x4195b844) { /* if |x|>=27*ln2 */ + if hx > uint32(0x7f800000) { /* NaN */ + return x3 + } + if sign != 0 { + return float32(-Int32FromInt32(1)) + } + if hx > uint32(0x42b17217) { /* x > log(FLT_MAX) */ + x3 *= Float32FromFloat32(1.7014118346046923e+38) + return x3 + } + } + /* argument reduction */ + if hx > uint32(0x3eb17218) { /* if |x| > 0.5 ln2 */ + if hx < uint32(0x3F851592) { /* and |x| < 1.5 ln2 */ + if !(sign != 0) { + hi = x3 - _ln2_hi1 + lo = _ln2_lo1 + k = int32(1) + } else { + hi = x3 + _ln2_hi1 + lo = -_ln2_lo1 + k = -int32(1) + } + } else { + if sign != 0 { + v1 = -Float32FromFloat32(0.5) + } else { + v1 = Float32FromFloat32(0.5) + } + k = int32(float32(_invln21*x3) + v1) + t = float32(k) + hi = x3 - float32(t*_ln2_hi1) /* t*ln2_hi is exact here */ + lo = Tfloat_t(t * _ln2_lo1) + } + x3 = hi - lo + c = hi - x3 - lo + } else { + if hx < uint32(0x33000000) { /* when |x|<2**-25, return x */ + if hx < uint32(0x00800000) { + if uint64(4) == uint64(4) { + y = float32(x3 * x3) + } else { + if uint64(4) == uint64(8) { + y1 = float64(x3 * x3) + } else { + y2 = float64(x3 * x3) + } + } + } + return x3 + } else { + k = 0 + } + } + /* x is now in primary range */ + hfx = Tfloat_t(Float32FromFloat32(0.5) * x3) + hxs = Tfloat_t(x3 * hfx) + r1 = Float32FromFloat32(1) + float32(hxs*(_Q11+float32(hxs*_Q21))) + t = Float32FromFloat32(3) - float32(r1*hfx) + e = Tfloat_t(hxs * ((r1 - t) / (Float32FromFloat32(6) - float32(x3*t)))) + if k == 0 { /* c is 0 */ + return x3 - (float32(x3*e) - hxs) + } + e = float32(x3*(e-c)) - c + e -= hxs + /* exp(x) ~ 2^k (Xreduced - e + 1) */ + if k == -int32(1) { + return float32(Float32FromFloat32(0.5)*(x3-e)) - Float32FromFloat32(0.5) + } + if k == int32(1) { + if x3 < -Float32FromFloat32(0.25) { + return float32(-Float32FromFloat32(2) * (e - (x3 + Float32FromFloat32(0.5)))) + } + return Float32FromFloat32(1) + float32(Float32FromFloat32(2)*(x3-e)) + } + *(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32((int32(0x7f) + k) << int32(23)) /* 2^k */ + twopk = *(*float32)(unsafe.Pointer(bp)) + if k < 0 || k > int32(56) { /* suffice to return exp(x)-1 */ + y3 = x3 - e + Float32FromFloat32(1) + if k == int32(128) { + y3 = Tfloat_t(Tfloat_t(y3*Float32FromFloat32(2)) * Float32FromFloat32(1.7014118346046923e+38)) + } else { + y3 = Tfloat_t(y3 * twopk) + } + return y3 - Float32FromFloat32(1) + } + *(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32((int32(0x7f) - k) << int32(23)) /* 2^-k */ + if k < int32(23) { + y3 = Tfloat_t((x3 - e + (Float32FromInt32(1) - *(*float32)(unsafe.Pointer(bp)))) * twopk) + } else { + y3 = Tfloat_t((x3 - (e + *(*float32)(unsafe.Pointer(bp))) + Float32FromInt32(1)) * twopk) + } + return y3 +} + +func Xexpm1l(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xexpm1(tls, x) +} + +type Tdouble_t = float64 +type Tuint32_t = uint32 +type Tuint64_t = uint64 + +var _o_threshold = float64(709.782712893384) /* 0x40862E42, 0xFEFA39EF */ +var _ln2_hi = float64(0.6931471803691238) /* 0x3fe62e42, 0xfee00000 */ +var _ln2_lo = float64(1.9082149292705877e-10) /* 0x3dea39ef, 0x35793c76 */ +var _invln2 = float64(1.4426950408889634) /* 0x3ff71547, 0x652b82fe */ +/* Scaled Q's: Qn_here = 2**n * Qn_above, for R(2*z) where z = hxs = x*x/2: */ +var _Q1 = -Float64FromFloat64(0.03333333333333313) /* BFA11111 111110F4 */ +var _Q2 = float64(0.0015873015872548146) /* 3F5A01A0 19FE5585 */ +var _Q3 = -Float64FromFloat64(7.93650757867488e-05) /* BF14CE19 9EAADBB7 */ +var _Q4 = float64(4.008217827329362e-06) /* 3ED0CFCA 86E65239 */ +var _Q5 = -Float64FromFloat64(2.0109921818362437e-07) /* BE8AFDB7 6E09C32D */ + +var _ln2_hi2 = float64(0.6931471803691238) /* 3fe62e42 fee00000 */ +var _ln2_lo2 = float64(1.9082149292705877e-10) /* 3dea39ef 35793c76 */ +var _Lg12 = float64(0.6666666666666735) /* 3FE55555 55555593 */ +var _Lg22 = float64(0.3999999999940942) /* 3FD99999 9997FA04 */ +var _Lg32 = float64(0.2857142874366239) /* 3FD24924 94229359 */ +var _Lg42 = float64(0.22222198432149784) /* 3FCC71C5 1D8E78AF */ +var _Lg51 = float64(0.1818357216161805) /* 3FC74664 96CB03DE */ +var _Lg61 = float64(0.15313837699209373) /* 3FC39A09 D078C69F */ +var _Lg71 = float64(0.14798198605116586) /* 3FC2F112 DF3E5244 */ + +func Xlog1p(tls *TLS, x3 float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2)) + defer func() { trc("-> %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, c, dk, f, hfsq, s, t1, t2, w, z Tdouble_t + var hu, hx Tuint32_t + var k int32 + var y float32 + var y1, y2, v1 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, c, dk, f, hfsq, hu, hx, k, s, t1, t2, w, y, y1, y2, z, v1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x3 + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + k = int32(1) + if hx < uint32(0x3fda827a) || hx>>int32(31) != 0 { /* 1+x < sqrt(2)+ */ + if hx >= uint32(0xbff00000) { /* x <= -1.0 */ + if x3 == float64(-Int32FromInt32(1)) { + return x3 / float64(0) + } /* log1p(-1) = -inf */ + return (x3 - x3) / float64(0) /* log1p(x<-1) = NaN */ + } + if hx<= uint32(0x7ff00000) { + return x3 + } + } + if k != 0 { + *(*float64)(unsafe.Pointer(bp)) = Float64FromInt32(1) + x3 + hu = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32)) + hu += Uint32FromInt32(Int32FromInt32(0x3ff00000) - Int32FromInt32(0x3fe6a09e)) + k = Int32FromUint32(hu>>Int32FromInt32(20)) - int32(0x3ff) + /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ + if k < int32(54) { + if k >= int32(2) { + v1 = Float64FromInt32(1) - (*(*float64)(unsafe.Pointer(bp)) - x3) + } else { + v1 = x3 - (*(*float64)(unsafe.Pointer(bp)) - Float64FromInt32(1)) + } + c = v1 + c /= *(*float64)(unsafe.Pointer(bp)) + } else { + c = Float64FromInt32(0) + } + /* reduce u into [sqrt(2)/2, sqrt(2)] */ + hu = hu&uint32(0x000fffff) + uint32(0x3fe6a09e) + *(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(hu)< %v", r) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var R, c, dk, f, hfsq, s, t1, t2, w, z Tfloat_t + var iu, ix Tuint32_t + var k int32 + var y, v1 float32 + var y1, y2 float64 + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, c, dk, f, hfsq, iu, ix, k, s, t1, t2, w, y, y1, y2, z, v1 + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x3 + ix = *(*Tuint32_t)(unsafe.Pointer(bp)) + k = int32(1) + if ix < uint32(0x3ed413d0) || ix>>int32(31) != 0 { /* 1+x < sqrt(2)+ */ + if ix >= uint32(0xbf800000) { /* x <= -1.0 */ + if x3 == float32(-Int32FromInt32(1)) { + return x3 / Float32FromFloat32(0) + } /* log1p(-1)=+inf */ + return (x3 - x3) / Float32FromFloat32(0) /* log1p(x<-1)=NaN */ + } + if ix<= uint32(0x7f800000) { + return x3 + } + } + if k != 0 { + *(*float32)(unsafe.Pointer(bp)) = Float32FromInt32(1) + x3 + iu = *(*Tuint32_t)(unsafe.Pointer(bp)) + iu += Uint32FromInt32(Int32FromInt32(0x3f800000) - Int32FromInt32(0x3f3504f3)) + k = Int32FromUint32(iu>>Int32FromInt32(23)) - int32(0x7f) + /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ + if k < int32(25) { + if k >= int32(2) { + v1 = Float32FromInt32(1) - (*(*float32)(unsafe.Pointer(bp)) - x3) + } else { + v1 = x3 - (*(*float32)(unsafe.Pointer(bp)) - Float32FromInt32(1)) + } + c = v1 + c /= *(*float32)(unsafe.Pointer(bp)) + } else { + c = Float32FromInt32(0) + } + /* reduce u into [sqrt(2)/2, sqrt(2)] */ + iu = iu&uint32(0x007fffff) + uint32(0x3f3504f3) + *(*Tuint32_t)(unsafe.Pointer(bp)) = iu + f = *(*float32)(unsafe.Pointer(bp)) - Float32FromInt32(1) + } + s = f / (Float32FromFloat32(2) + f) + z = Tfloat_t(s * s) + w = Tfloat_t(z * z) + t1 = Tfloat_t(w * (_Lg23 + float32(w*_Lg43))) + t2 = Tfloat_t(z * (_Lg13 + float32(w*_Lg33))) + R = t2 + t1 + hfsq = Tfloat_t(float32(Float32FromFloat32(0.5)*f) * f) + dk = float32(k) + return Tfloat_t(s*(hfsq+R)) + (Tfloat_t(dk*_ln2_lo3) + c) - hfsq + f + Tfloat_t(dk*_ln2_hi3) +} + +func Xlog1pl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xlog1p(tls, x) +} + +type Tfloat_t = float32 + +var _B1 = uint32(715094163) /* B1 = (1023-1023/3-0.03306235651)*2**20 */ +var _B2 = uint32(696219795) /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */ + +// C documentation +// +// /* |1/cbrt(x) - p(x)| < 2**-23.5 (~[-7.93e-8, 7.929e-8]). */ + +var _P0 = float64(1.87595182427177) /* 0x3ffe03e6, 0x0f61e692 */ +var _P1 = -Float64FromFloat64(1.8849797954337717) /* 0xbffe28e0, 0x92f02420 */ +var _P2 = float64(1.6214297201053545) /* 0x3ff9f160, 0x4a49d6c2 */ +var _P3 = -Float64FromFloat64(0.758397934778766) /* 0xbfe844cb, 0xbee751d9 */ +var _P4 = float64(0.14599619288661245) /* 0x3fc2b000, 0xd4e4edd7 */ + +func Xcbrt(tls *TLS, x float64) (r1 float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var hx Tuint32_t + var r, s, t, w Tdouble_t + var p1 uintptr + var _ /* u at bp+0 */ struct { + Fi [0]Tuint64_t + Ff float64 + } + _, _, _, _, _, _ = hx, r, s, t, w, p1 + *(*struct { + Fi [0]Tuint64_t + Ff float64 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint64_t + Ff float64 + }{} + *(*float64)(unsafe.Pointer(bp)) = x + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if hx >= uint32(0x7ff00000) { /* cbrt(NaN,INF) is itself */ + return x + x + } + /* + * Rough cbrt to 5 bits: + * cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3) + * where e is integral and >= 0, m is real and in [0, 1), and "/" and + * "%" are integer division and modulus with rounding towards minus + * infinity. The RHS is always >= the LHS and has a maximum relative + * error of about 1 in 16. Adding a bias of -0.03306235651 to the + * (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE + * floating point representation, for finite positive normal values, + * ordinary integer divison of the value in bits magically gives + * almost exactly the RHS of the above provided we first subtract the + * exponent bias (1023 for doubles) and later add it back. We do the + * subtraction virtually to keep e >= 0 so that ordinary integer + * division rounds towards minus infinity; this is also efficient. + */ + if hx < uint32(0x00100000) { /* zero or subnormal? */ + *(*float64)(unsafe.Pointer(bp)) = float64(x * float64(1.8014398509481984e+16)) + hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff)) + if hx == uint32(0) { + return x + } /* cbrt(0) is itself */ + hx = hx/uint32(3) + _B2 + } else { + hx = hx/uint32(3) + _B1 + } + p1 = bp + *(*Tuint64_t)(unsafe.Pointer(p1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(p1)) & (Uint64FromUint64(1) << Int32FromInt32(63))) + *(*Tuint64_t)(unsafe.Pointer(bp)) |= uint64(hx) << int32(32) + t = *(*float64)(unsafe.Pointer(bp)) + /* + * New cbrt to 23 bits: + * cbrt(x) = t*cbrt(x/t**3) ~= t*P(t**3/x) + * where P(r) is a polynomial of degree 4 that approximates 1/cbrt(r) + * to within 2**-23.5 when |r - 1| < 1/10. The rough approximation + * has produced t such than |t/cbrt(x) - 1| ~< 1/32, and cubing this + * gives us bounds for r = t**3/x. + * + * Try to optimize for parallel evaluation as in __tanf.c. + */ + r = Tdouble_t(Tdouble_t(t*t) * (t / x)) + t = Tdouble_t(t * (_P0 + float64(r*(_P1+float64(r*_P2))) + float64(Tdouble_t(Tdouble_t(r*r)*r)*(_P3+float64(r*_P4))))) + /* + * Round t away from zero to 23 bits (sloppily except for ensuring that + * the result is larger in magnitude than cbrt(x) but not much more than + * 2 23-bit ulps larger). With rounding towards zero, the error bound + * would be ~5/6 instead of ~4/6. With a maximum error of 2 23-bit ulps + * in the rounded t, the infinite-precision error in the Newton + * approximation barely affects third digit in the final error + * 0.667; the error in the rounded t can be up to about 3 23-bit ulps + * before the final error is larger than 0.667 ulps. + */ + *(*float64)(unsafe.Pointer(bp)) = t + *(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(*(*Tuint64_t)(unsafe.Pointer(bp))+Uint64FromUint32(0x80000000)) & uint64(0xffffffffc0000000) + t = *(*float64)(unsafe.Pointer(bp)) + /* one step Newton iteration to 53 bits with error < 0.667 ulps */ + s = Tdouble_t(t * t) /* t*t is exact */ + r = x / s /* error <= 0.5 ulps; |r| < |t| */ + w = t + t /* t+t is exact */ + r = (r - t) / (w + r) /* r-t is exact; w+r ~= 3*t */ + t = t + Tdouble_t(t*r) /* error <= 0.5 + 0.5/3 + epsilon */ + return t +} + +var _B11 = uint32(709958130) /* B1 = (127-127.0/3-0.03306235651)*2**23 */ +var _B21 = uint32(642849266) /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */ + +func Xcbrtf(tls *TLS, x float32) (r1 float32) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r1) }() + } + bp := tls.Alloc(16) + defer tls.Free(16) + var T, r Tdouble_t + var hx Tuint32_t + var _ /* u at bp+0 */ struct { + Fi [0]Tuint32_t + Ff float32 + } + _, _, _ = T, hx, r + *(*struct { + Fi [0]Tuint32_t + Ff float32 + })(unsafe.Pointer(bp)) = struct { + Fi [0]Tuint32_t + Ff float32 + }{} + *(*float32)(unsafe.Pointer(bp)) = x + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + if hx >= uint32(0x7f800000) { /* cbrt(NaN,INF) is itself */ + return x + x + } + /* rough cbrt to 5 bits */ + if hx < uint32(0x00800000) { /* zero or subnormal? */ + if hx == uint32(0) { + return x + } /* cbrt(+-0) is itself */ + *(*float32)(unsafe.Pointer(bp)) = float32(x * Float32FromFloat32(1.6777216e+07)) + hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff) + hx = hx/uint32(3) + _B21 + } else { + hx = hx/uint32(3) + _B11 + } + *(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x80000000) + *(*Tuint32_t)(unsafe.Pointer(bp)) |= hx + /* + * First step Newton iteration (solving t*t-x/t == 0) to 16 bits. In + * double precision so that its terms can be arranged for efficiency + * without causing overflow or underflow. + */ + T = float64(*(*float32)(unsafe.Pointer(bp))) + r = Tdouble_t(Tdouble_t(T*T) * T) + T = Tdouble_t(T*(float64(x)+float64(x)+r)) / (float64(x) + r + r) + /* + * Second step Newton iteration to 47 bits. In double precision for + * efficiency and accuracy. + */ + r = Tdouble_t(Tdouble_t(T*T) * T) + T = Tdouble_t(T*(float64(x)+float64(x)+r)) / (float64(x) + r + r) + /* rounding to 24 bits is perfect in round-to-nearest mode */ + return float32(T) +} + +func Xcbrtl(tls *TLS, x float64) (r float64) { + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xcbrt(tls, x) +} diff --git a/internal/libc/libc64.go b/internal/libc/libc64.go new file mode 100644 index 0000000..80ce1cf --- /dev/null +++ b/internal/libc/libc64.go @@ -0,0 +1,79 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build (!linux && !(386 || arm)) || mips64le + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc/limits" + "github.com/hanzoai/sqlite/internal/libc/sys/types" +) + +const ( + heapSize = 2 << 30 // Adjust for your debugging session requirements and system RAM size. +) + +type ( + // RawMem represents the biggest byte array the runtime can handle + RawMem [1<<50 - 1]byte + + // 48-5*8 = 8 bytes left to pad + stackHeaderPadding struct { + a uintptr + } +) + +type bitz []int // was bits but that is now an import qaulifier in use by mem.go + +func newBits(n int) (r bitz) { return make(bitz, (n+63)>>6) } +func (b bitz) has(n int) bool { return b != nil && b[n>>6]&(1<>6] |= 1 << uint(n&63) } + +func Xstrchrnul(tls *TLS, s uintptr, c int32) (r uintptr) { + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + defer func() { trc("-> %v", r) }() + } + var k types.Size_t + var w uintptr + _, _ = k, w + c = int32(uint8(c)) + if !(c != 0) { + return s + uintptr(Xstrlen(tls, s)) + } + for { + if !(uint64(s)%Uint64FromInt64(8) != 0) { + break + } + if !(*(*int8)(unsafe.Pointer(s)) != 0) || int32(*(*uint8)(unsafe.Pointer(s))) == c { + return s + } + goto _1 + _1: + s++ + } + k = uint64(-Int32FromInt32(1)) / Uint64FromInt32(limits.UCHAR_MAX) * uint64(c) + w = s + for { + if !(!((*(*uint64)(unsafe.Pointer(w))-uint64(-Int32FromInt32(1))/Uint64FromInt32(limits.UCHAR_MAX)) & ^*(*uint64)(unsafe.Pointer(w)) & (uint64(-Int32FromInt32(1))/Uint64FromInt32(limits.UCHAR_MAX)*uint64(Int32FromInt32(limits.UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0) && !((*(*uint64)(unsafe.Pointer(w))^k-uint64(-Int32FromInt32(1))/Uint64FromInt32(limits.UCHAR_MAX)) & ^(*(*uint64)(unsafe.Pointer(w))^k) & (uint64(-Int32FromInt32(1))/Uint64FromInt32(limits.UCHAR_MAX)*uint64(Int32FromInt32(limits.UCHAR_MAX)/Int32FromInt32(2)+Int32FromInt32(1))) != 0)) { + break + } + goto _2 + _2: + w += 8 + } + s = w + for { + if !(*(*int8)(unsafe.Pointer(s)) != 0 && int32(*(*uint8)(unsafe.Pointer(s))) != c) { + break + } + goto _3 + _3: + s++ + } + return s +} diff --git a/internal/libc/libc_all.go b/internal/libc/libc_all.go new file mode 100644 index 0000000..41c0215 --- /dev/null +++ b/internal/libc/libc_all.go @@ -0,0 +1,122 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package libc is a partial reimplementation of C libc in pure Go. +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "math" + "sync/atomic" + "unsafe" +) + +type integer interface { + ~int | ~int32 | ~int64 | ~uint | ~uint32 | ~uint64 | ~uintptr +} + +func X__sync_add_and_fetch[T integer](t *TLS, p uintptr, v T) T { + switch unsafe.Sizeof(v) { + case 4: + return T(atomic.AddInt32((*int32)(unsafe.Pointer(p)), int32(v))) + case 8: + return T(atomic.AddInt64((*int64)(unsafe.Pointer(p)), int64(v))) + default: + panic(todo("")) + } +} + +func X__sync_sub_and_fetch[T integer](t *TLS, p uintptr, v T) T { + switch unsafe.Sizeof(v) { + case 4: + return T(atomic.AddInt32((*int32)(unsafe.Pointer(p)), -int32(v))) + case 8: + return T(atomic.AddInt64((*int64)(unsafe.Pointer(p)), -int64(v))) + default: + panic(todo("")) + } +} + +// GoString returns the value of a C string at s. +func GoString(s uintptr) string { + if s == 0 { + return "" + } + + if n := strlen(s); n != 0 { + return string(unsafe.Slice((*byte)(unsafe.Pointer(s)), n)) + } + + return "" +} + +// GoBytes returns a byte slice from a C char* having length len bytes. +func GoBytes(s uintptr, len int) []byte { + return unsafe.Slice((*byte)(unsafe.Pointer(s)), len) +} + +func X__isfinitef(tls *TLS, f float32) int32 { + d := float64(f) + if !math.IsInf(d, 0) && !math.IsNaN(d) { + return 1 + } + + return 0 +} + +func X__isfinite(tls *TLS, d float64) int32 { + if !math.IsInf(d, 0) && !math.IsNaN(d) { + return 1 + } + + return 0 +} + +func X__isfinitel(tls *TLS, d float64) int32 { + if !math.IsInf(d, 0) && !math.IsNaN(d) { + return 1 + } + + return 0 +} + +func strlen(s uintptr) (r Tsize_t) { + if s == 0 { + return 0 + } + + for ; *(*int8)(unsafe.Pointer(s)) != 0; s++ { + r++ + } + + return r +} + +// size_t strlen(const char *s) +func Xstrlen(t *TLS, s uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("t=%v s=%v, (%v:)", t, s, origin(2)) + defer func() { trc("-> %v", r) }() + } + return strlen(s) + +} + +func _strlen(t *TLS, s uintptr) (r Tsize_t) { + return strlen(s) +} + +func X__builtin_ilogb(tls *TLS, x float64) int32 { + return int32(math.Ilogb(x)) +} + +func X__builtin_ilogbl(tls *TLS, x float64) int32 { + return int32(math.Ilogb(x)) +} + +func X__builtin_ilogbf(tls *TLS, x float32) int32 { + // Casting to float64 is safe and mathematically correct here. + // Subnormal float32 values become normal float64 values, + // which allows math.Ilogb to correctly return their negative exponent. + return int32(math.Ilogb(float64(x))) +} diff --git a/internal/libc/libc_amd64.go b/internal/libc/libc_amd64.go new file mode 100644 index 0000000..3f904bb --- /dev/null +++ b/internal/libc/libc_amd64.go @@ -0,0 +1,40 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !(linux && amd64) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "fmt" + "unsafe" +) + +// Byte loads are atomic on this CPU. +func a_load_8(addr uintptr) uint32 { + return uint32(*(*byte)(unsafe.Pointer(addr))) +} + +// int16 loads are atomic on this CPU when properly aligned. +func a_load_16(addr uintptr) uint32 { + if addr&1 != 0 { + panic(fmt.Errorf("unaligned atomic 16 bit access at %#0x", addr)) + } + + return uint32(*(*uint16)(unsafe.Pointer(addr))) +} + +// Byte sores are atomic on this CPU. +func a_store_8(addr uintptr, b byte) { + *(*byte)(unsafe.Pointer(addr)) = b +} + +// int16 stores are atomic on this CPU when properly aligned. +func a_store_16(addr uintptr, n uint16) { + if addr&1 != 0 { + panic(fmt.Errorf("unaligned atomic 16 bit access at %#0x", addr)) + } + + *(*uint16)(unsafe.Pointer(addr)) = n +} diff --git a/internal/libc/libc_arm64.go b/internal/libc/libc_arm64.go new file mode 100644 index 0000000..9590697 --- /dev/null +++ b/internal/libc/libc_arm64.go @@ -0,0 +1,40 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !(linux && arm64) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "fmt" + "unsafe" +) + +// Byte loads are atomic on this CPU. +func a_load_8(addr uintptr) uint32 { + return uint32(*(*byte)(unsafe.Pointer(addr))) +} + +// int16 loads are atomic on this CPU when properly aligned. +func a_load_16(addr uintptr) uint32 { + if addr&1 != 0 { + panic(fmt.Errorf("unaligned atomic 16 bit access at %#0x", addr)) + } + + return uint32(*(*uint16)(unsafe.Pointer(addr))) +} + +// Byte sores are atomic on this CPU. +func a_store_8(addr uintptr, b byte) { + *(*byte)(unsafe.Pointer(addr)) = b +} + +// int16 stores are atomic on this CPU when properly aligned. +func a_store_16(addr uintptr, n uint16) { + if addr&1 != 0 { + panic(fmt.Errorf("unaligned atomic 16 bit access at %#0x", addr)) + } + + *(*uint16)(unsafe.Pointer(addr)) = n +} diff --git a/internal/libc/libc_darwin.go b/internal/libc/libc_darwin.go new file mode 100644 index 0000000..e2a5f4b --- /dev/null +++ b/internal/libc/libc_darwin.go @@ -0,0 +1,2803 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + crand "crypto/rand" + "encoding/hex" + "errors" + "fmt" + "io" + "io/fs" + mbits "math/bits" + "os" + "os/exec" + gosignal "os/signal" + "path/filepath" + "runtime" + "strings" + gotime "time" + "unicode" + "unsafe" + + guuid "github.com/google/uuid" + "golang.org/x/sys/unix" + "github.com/hanzoai/sqlite/internal/libc/errno" + "github.com/hanzoai/sqlite/internal/libc/fcntl" + "github.com/hanzoai/sqlite/internal/libc/fts" + gonetdb "github.com/hanzoai/sqlite/internal/libc/honnef.co/go/netdb" + "github.com/hanzoai/sqlite/internal/libc/langinfo" + "github.com/hanzoai/sqlite/internal/libc/limits" + "github.com/hanzoai/sqlite/internal/libc/netdb" + "github.com/hanzoai/sqlite/internal/libc/netinet/in" + "github.com/hanzoai/sqlite/internal/libc/signal" + "github.com/hanzoai/sqlite/internal/libc/stdio" + "github.com/hanzoai/sqlite/internal/libc/sys/socket" + "github.com/hanzoai/sqlite/internal/libc/sys/stat" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/libc/termios" + "github.com/hanzoai/sqlite/internal/libc/time" + "github.com/hanzoai/sqlite/internal/libc/unistd" + "github.com/hanzoai/sqlite/internal/libc/uuid/uuid" + "github.com/hanzoai/sqlite/internal/libc/wctype" + "github.com/hanzoai/sqlite/internal/memory" +) + +const ( + maxPathLen = 1024 +) + +// var ( +// in6_addr_any in.In6_addr +// ) + +type Tsize_t = types.Size_t + +type ( + syscallErrno = unix.Errno + long = types.User_long_t + ulong = types.User_ulong_t +) + +// // Keep these outside of the var block otherwise go generate will miss them. +var X__stderrp = Xstdout +var X__stdinp = Xstdin +var X__stdoutp = Xstdout + +// user@darwin-m1:~/tmp$ cat main.c +// +// #include +// #include +// +// int main() { +// printf("%i\n", ___mb_cur_max()); +// return 0; +// } +// +// user@darwin-m1:~/tmp$ gcc main.c && ./a.out +// 1 +// user@darwin-m1:~/tmp$ +var X__mb_cur_max int32 = 1 + +var startTime = gotime.Now() // For clock(3) + +type file uintptr + +func (f file) fd() int32 { return int32((*stdio.FILE)(unsafe.Pointer(f)).F_file) } +func (f file) setFd(fd int32) { (*stdio.FILE)(unsafe.Pointer(f)).F_file = int16(fd) } + +func (f file) err() bool { + return (*stdio.FILE)(unsafe.Pointer(f)).F_flags&1 != 0 +} + +func (f file) setErr() { + (*stdio.FILE)(unsafe.Pointer(f)).F_flags |= 1 +} + +func (f file) clearErr() { + (*stdio.FILE)(unsafe.Pointer(f)).F_flags &^= 3 +} + +func (f file) eof() bool { + return (*stdio.FILE)(unsafe.Pointer(f)).F_flags&2 != 0 +} + +func (f file) setEOF() { + (*stdio.FILE)(unsafe.Pointer(f)).F_flags |= 2 +} + +func (f file) close(t *TLS) int32 { + r := Xclose(t, f.fd()) + Xfree(t, uintptr(f)) + if r < 0 { + return stdio.EOF + } + + return 0 +} + +func newFile(t *TLS, fd int32) uintptr { + p := Xcalloc(t, 1, types.Size_t(unsafe.Sizeof(stdio.FILE{}))) + if p == 0 { + return 0 + } + + file(p).setFd(fd) + return p +} + +func fwrite(fd int32, b []byte) (int, error) { + if fd == unistd.STDOUT_FILENO { + return write(b) + } + + if dmesgs { + dmesg("%v: fd %v: %s", origin(1), fd, hex.Dump(b)) + } + return unix.Write(int(fd), b) +} + +func Xclearerr(tls *TLS, f uintptr) { + file(f).clearErr() +} + +func Xfeof(t *TLS, f uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v f=%v, (%v:)", t, f, origin(2)) + defer func() { trc("-> %v", r) }() + } + r = BoolInt32(file(f).eof()) + return r +} + +func X__inline_isnand(t *TLS, x float64) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Xisnan(t, x) +} + +func X__inline_isnanf(t *TLS, x float32) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Xisnanf(t, x) +} + +func X__inline_isnanl(t *TLS, x float64) int32 { + if __ccgo_strace { + trc("t=%v x=%v, (%v:)", t, x, origin(2)) + } + return Xisnan(t, x) +} + +// int fprintf(FILE *stream, const char *format, ...); +func Xfprintf(t *TLS, stream, format, args uintptr) int32 { + if __ccgo_strace { + trc("t=%v args=%v, (%v:)", t, args, origin(2)) + } + n, _ := fwrite(int32((*stdio.FILE)(unsafe.Pointer(stream)).F_file), printf(format, args)) + return int32(n) +} + +// int usleep(useconds_t usec); +func Xusleep(t *TLS, usec types.Useconds_t) int32 { + if __ccgo_strace { + trc("t=%v usec=%v, (%v:)", t, usec, origin(2)) + } + gotime.Sleep(gotime.Microsecond * gotime.Duration(usec)) + return 0 +} + +// int futimes(int fd, const struct timeval tv[2]); +func Xfutimes(t *TLS, fd int32, tv uintptr) int32 { + if __ccgo_strace { + trc("t=%v fd=%v tv=%v, (%v:)", t, fd, tv, origin(2)) + } + var a []unix.Timeval + if tv != 0 { + a = make([]unix.Timeval, 2) + a[0] = *(*unix.Timeval)(unsafe.Pointer(tv)) + a[1] = *(*unix.Timeval)(unsafe.Pointer(tv + unsafe.Sizeof(unix.Timeval{}))) + } + if err := unix.Futimes(int(fd), a); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// void srandomdev(void); +func Xsrandomdev(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) +} + +// int gethostuuid(uuid_t id, const struct timespec *wait); +func Xgethostuuid(t *TLS, id uintptr, wait uintptr) int32 { + if __ccgo_strace { + trc("t=%v id=%v wait=%v, (%v:)", t, id, wait, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_GETHOSTUUID, id, wait, 0); err != 0 { // Cannot avoid the syscall here. + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int flock(int fd, int operation); +func Xflock(t *TLS, fd, operation int32) int32 { + if __ccgo_strace { + trc("t=%v operation=%v, (%v:)", t, operation, origin(2)) + } + if err := unix.Flock(int(fd), int(operation)); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int fsctl(const char *,unsigned long,void*,unsigned int); +func Xfsctl(t *TLS, path uintptr, request ulong, data uintptr, options uint32) int32 { + if __ccgo_strace { + trc("t=%v path=%v request=%v data=%v options=%v, (%v:)", t, path, request, data, options, origin(2)) + } + panic(todo("")) + // if _, _, err := unix.Syscall6(unix.SYS_FSCTL, path, uintptr(request), data, uintptr(options), 0, 0); err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return 0 +} + +// int * __error(void); +func X__error(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return t.errnop +} + +// int isspace(int c); +func Xisspace(t *TLS, c int32) int32 { + if __ccgo_strace { + trc("t=%v c=%v, (%v:)", t, c, origin(2)) + } + return __isspace(t, c) +} + +// void __assert_rtn(const char *, const char *, int, const char *) +func X__assert_rtn(t *TLS, function, file uintptr, line int32, assertion uintptr) { + if __ccgo_strace { + trc("t=%v file=%v line=%v assertion=%v, (%v:)", t, file, line, assertion, origin(2)) + } + panic(todo("")) + // fmt.Fprintf(os.Stderr, "assertion failure: %s:%d.%s: %s\n", GoString(file), line, GoString(function), GoString(assertion)) + // os.Stderr.Sync() + // Xexit(t, 1) +} + +// int getrusage(int who, struct rusage *usage); +func Xgetrusage(t *TLS, who int32, usage uintptr) int32 { + if __ccgo_strace { + trc("t=%v who=%v usage=%v, (%v:)", t, who, usage, origin(2)) + } + panic(todo("")) + // if _, _, err := unix.Syscall(unix.SYS_GETRUSAGE, uintptr(who), usage, 0); err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return 0 +} + +// int fgetc(FILE *stream); +func Xfgetc(t *TLS, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + fd := int((*stdio.FILE)(unsafe.Pointer(stream)).F_file) + var buf [1]byte + if n, _ := unix.Read(fd, buf[:]); n != 0 { + return int32(buf[0]) + } + + return stdio.EOF +} + +// int lstat(const char *pathname, struct stat *statbuf); +func Xlstat(t *TLS, pathname, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2)) + } + return Xlstat64(t, pathname, statbuf) +} + +// int stat(const char *pathname, struct stat *statbuf); +func Xstat(t *TLS, pathname, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2)) + } + return Xstat64(t, pathname, statbuf) +} + +// int chdir(const char *path); +func Xchdir(t *TLS, path uintptr) int32 { + if __ccgo_strace { + trc("t=%v path=%v, (%v:)", t, path, origin(2)) + } + if err := unix.Chdir(GoString(path)); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(path)) + } + return 0 +} + +var localtime time.Tm + +// struct tm *localtime(const time_t *timep); +func Xlocaltime(_ *TLS, timep uintptr) uintptr { + loc := getLocalLocation() + ut := *(*time.Time_t)(unsafe.Pointer(timep)) + t := gotime.Unix(int64(ut), 0).In(loc) + localtime.Ftm_sec = int32(t.Second()) + localtime.Ftm_min = int32(t.Minute()) + localtime.Ftm_hour = int32(t.Hour()) + localtime.Ftm_mday = int32(t.Day()) + localtime.Ftm_mon = int32(t.Month() - 1) + localtime.Ftm_year = int32(t.Year() - 1900) + localtime.Ftm_wday = int32(t.Weekday()) + localtime.Ftm_yday = int32(t.YearDay()) + localtime.Ftm_isdst = Bool32(isTimeDST(t)) + _, off := t.Zone() + localtime.Ftm_gmtoff = int64(off) + localtime.Ftm_zone = 0 + return uintptr(unsafe.Pointer(&localtime)) +} + +// struct tm *localtime_r(const time_t *timep, struct tm *result); +func Xlocaltime_r(_ *TLS, timep, result uintptr) uintptr { + loc := getLocalLocation() + ut := *(*time_t)(unsafe.Pointer(timep)) + t := gotime.Unix(int64(ut), 0).In(loc) + (*time.Tm)(unsafe.Pointer(result)).Ftm_sec = int32(t.Second()) + (*time.Tm)(unsafe.Pointer(result)).Ftm_min = int32(t.Minute()) + (*time.Tm)(unsafe.Pointer(result)).Ftm_hour = int32(t.Hour()) + (*time.Tm)(unsafe.Pointer(result)).Ftm_mday = int32(t.Day()) + (*time.Tm)(unsafe.Pointer(result)).Ftm_mon = int32(t.Month() - 1) + (*time.Tm)(unsafe.Pointer(result)).Ftm_year = int32(t.Year() - 1900) + (*time.Tm)(unsafe.Pointer(result)).Ftm_wday = int32(t.Weekday()) + (*time.Tm)(unsafe.Pointer(result)).Ftm_yday = int32(t.YearDay()) + (*time.Tm)(unsafe.Pointer(result)).Ftm_isdst = Bool32(isTimeDST(t)) + _, off := t.Zone() + (*time.Tm)(unsafe.Pointer(result)).Ftm_gmtoff = int64(off) + (*time.Tm)(unsafe.Pointer(result)).Ftm_zone = 0 + return result +} + +// int open(const char *pathname, int flags, ...); +func Xopen(t *TLS, pathname uintptr, flags int32, args uintptr) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v flags=%v args=%v, (%v:)", t, pathname, flags, args, origin(2)) + } + var mode types.Mode_t + if args != 0 { + mode = (types.Mode_t)(VaUint32(&args)) + } + fd, err := unix.Open(GoString(pathname), int(flags), uint32(mode)) + if err != nil { + if dmesgs { + dmesg("%v: %q %#x %#o: %v FAIL", origin(1), GoString(pathname), flags, mode, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q flags %#x mode %#o: fd %v", origin(1), GoString(pathname), flags, mode, fd) + } + return int32(fd) +} + +// off_t lseek(int fd, off_t offset, int whence); +func Xlseek(t *TLS, fd int32, offset types.Off_t, whence int32) types.Off_t { + if __ccgo_strace { + trc("t=%v fd=%v offset=%v whence=%v, (%v:)", t, fd, offset, whence, origin(2)) + } + return types.Off_t(Xlseek64(t, fd, offset, whence)) +} + +func whenceStr(whence int32) string { + switch whence { + case fcntl.SEEK_CUR: + return "SEEK_CUR" + case fcntl.SEEK_END: + return "SEEK_END" + case fcntl.SEEK_SET: + return "SEEK_SET" + default: + return fmt.Sprintf("whence(%d)", whence) + } +} + +var fsyncStatbuf stat.Stat + +// int fsync(int fd); +func Xfsync(t *TLS, fd int32) int32 { + if __ccgo_strace { + trc("t=%v fd=%v, (%v:)", t, fd, origin(2)) + } + if noFsync { + // Simulate -DSQLITE_NO_SYNC for sqlite3 testfixture, see function full_sync in sqlite3.c + return Xfstat(t, fd, uintptr(unsafe.Pointer(&fsyncStatbuf))) + } + + if err := unix.Fsync(int(fd)); err != nil { + if dmesgs { + dmesg("%v: %v: %v FAIL", origin(1), fd, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %d: ok", origin(1), fd) + } + return 0 +} + +// long sysconf(int name); +func Xsysconf(t *TLS, name int32) long { + if __ccgo_strace { + trc("t=%v name=%v, (%v:)", t, name, origin(2)) + } + switch name { + case unistd.X_SC_PAGESIZE: + return long(unix.Getpagesize()) + case unistd.X_SC_NPROCESSORS_ONLN: + return long(runtime.NumCPU()) + case unistd.X_SC_GETPW_R_SIZE_MAX: + return 128 + } + + panic(todo("", name)) +} + +// int close(int fd); +func Xclose(t *TLS, fd int32) int32 { + if __ccgo_strace { + trc("t=%v fd=%v, (%v:)", t, fd, origin(2)) + } + if err := unix.Close(int(fd)); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %d: ok", origin(1), fd) + } + return 0 +} + +// char *getcwd(char *buf, size_t size); +func Xgetcwd(t *TLS, buf uintptr, size types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v buf=%v size=%v, (%v:)", t, buf, size, origin(2)) + } + if _, err := unix.Getcwd((*RawMem)(unsafe.Pointer(buf))[:size:size]); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return 0 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return buf +} + +// int fstat(int fd, struct stat *statbuf); +func Xfstat(t *TLS, fd int32, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v fd=%v statbuf=%v, (%v:)", t, fd, statbuf, origin(2)) + } + return Xfstat64(t, fd, statbuf) +} + +// int ftruncate(int fd, off_t length); +func Xftruncate(t *TLS, fd int32, length types.Off_t) int32 { + if __ccgo_strace { + trc("t=%v fd=%v length=%v, (%v:)", t, fd, length, origin(2)) + } + if err := unix.Ftruncate(int(fd), int64(length)); err != nil { + if dmesgs { + dmesg("%v: fd %d: %v FAIL", origin(1), fd, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %d %#x: ok", origin(1), fd, length) + } + return 0 +} + +// int fcntl(int fd, int cmd, ... /* arg */ ); +func Xfcntl(t *TLS, fd, cmd int32, args uintptr) int32 { + if __ccgo_strace { + trc("t=%v cmd=%v args=%v, (%v:)", t, cmd, args, origin(2)) + } + return Xfcntl64(t, fd, cmd, args) +} + +// ssize_t read(int fd, void *buf, size_t count); +func Xread(t *TLS, fd int32, buf uintptr, count types.Size_t) types.Ssize_t { + if __ccgo_strace { + trc("t=%v fd=%v buf=%v count=%v, (%v:)", t, fd, buf, count, origin(2)) + } + var n int + var err error + switch { + case count == 0: + n, err = unix.Read(int(fd), nil) + default: + n, err = unix.Read(int(fd), (*RawMem)(unsafe.Pointer(buf))[:count:count]) + if dmesgs && err == nil { + dmesg("%v: fd %v, count %#x, n %#x\n%s", origin(1), fd, count, n, hex.Dump((*RawMem)(unsafe.Pointer(buf))[:n:n])) + } + } + if err != nil { + if dmesgs { + dmesg("%v: fd %v, %v FAIL", origin(1), fd, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return types.Ssize_t(n) +} + +// ssize_t write(int fd, const void *buf, size_t count); +func Xwrite(t *TLS, fd int32, buf uintptr, count types.Size_t) types.Ssize_t { + if __ccgo_strace { + trc("t=%v fd=%v buf=%v count=%v, (%v:)", t, fd, buf, count, origin(2)) + } + var n int + var err error + switch { + case count == 0: + n, err = unix.Write(int(fd), nil) + default: + n, err = unix.Write(int(fd), (*RawMem)(unsafe.Pointer(buf))[:count:count]) + if dmesgs { + dmesg("%v: fd %v, count %#x\n%s", origin(1), fd, count, hex.Dump((*RawMem)(unsafe.Pointer(buf))[:count:count])) + } + } + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return types.Ssize_t(n) +} + +// int fchmod(int fd, mode_t mode); +func Xfchmod(t *TLS, fd int32, mode types.Mode_t) int32 { + if __ccgo_strace { + trc("t=%v fd=%v mode=%v, (%v:)", t, fd, mode, origin(2)) + } + if err := unix.Fchmod(int(fd), uint32(mode)); err != nil { + if dmesgs { + dmesg("%v: %d %#o: %v FAIL", origin(1), fd, mode, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %d %#o: ok", origin(1), fd, mode) + } + return 0 +} + +// int fchown(int fd, uid_t owner, gid_t group); +func Xfchown(t *TLS, fd int32, owner types.Uid_t, group types.Gid_t) int32 { + if __ccgo_strace { + trc("t=%v fd=%v owner=%v group=%v, (%v:)", t, fd, owner, group, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_FCHOWN, uintptr(fd), uintptr(owner), uintptr(group)); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// uid_t geteuid(void); +func Xgeteuid(t *TLS) types.Uid_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + r := types.Uid_t(unix.Geteuid()) + if dmesgs { + dmesg("%v: %v", origin(1), r) + } + return r +} + +// void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); +func Xmmap(t *TLS, addr uintptr, length types.Size_t, prot, flags, fd int32, offset types.Off_t) uintptr { + if __ccgo_strace { + trc("t=%v addr=%v length=%v fd=%v offset=%v, (%v:)", t, addr, length, fd, offset, origin(2)) + } + // Cannot avoid the syscall here, addr sometimes matter. + data, _, err := unix.Syscall6(unix.SYS_MMAP, addr, uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + if err != 0 { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return ^uintptr(0) // (void*)-1 + } + + if dmesgs { + dmesg("%v: %#x", origin(1), data) + } + return data +} + +// int munmap(void *addr, size_t length); +func Xmunmap(t *TLS, addr uintptr, length types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v addr=%v length=%v, (%v:)", t, addr, length, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_MUNMAP, addr, uintptr(length), 0); err != 0 { // Cannot avoid the syscall here, must pair with mmap. + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + return 0 +} + +// int gettimeofday(struct timeval *tv, struct timezone *tz); +func Xgettimeofday(t *TLS, tv, tz uintptr) int32 { + if __ccgo_strace { + trc("t=%v tz=%v, (%v:)", t, tz, origin(2)) + } + if tz != 0 { + panic(todo("")) + } + + var tvs unix.Timeval + err := unix.Gettimeofday(&tvs) + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + *(*unix.Timeval)(unsafe.Pointer(tv)) = tvs + return 0 +} + +// int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); +func Xgetsockopt(t *TLS, sockfd, level, optname int32, optval, optlen uintptr) int32 { + if __ccgo_strace { + trc("t=%v optname=%v optlen=%v, (%v:)", t, optname, optlen, origin(2)) + } + if _, _, err := unix.Syscall6(unix.SYS_GETSOCKOPT, uintptr(sockfd), uintptr(level), uintptr(optname), optval, optlen, 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); +func Xsetsockopt(t *TLS, sockfd, level, optname int32, optval uintptr, optlen socket.Socklen_t) int32 { + if __ccgo_strace { + trc("t=%v optname=%v optval=%v optlen=%v, (%v:)", t, optname, optval, optlen, origin(2)) + } + if _, _, err := unix.Syscall6(unix.SYS_SETSOCKOPT, uintptr(sockfd), uintptr(level), uintptr(optname), optval, uintptr(optlen), 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int ioctl(int fd, unsigned long request, ...); +func Xioctl(t *TLS, fd int32, request ulong, va uintptr) int32 { + if __ccgo_strace { + trc("t=%v fd=%v request=%v va=%v, (%v:)", t, fd, request, va, origin(2)) + } + var argp uintptr + if va != 0 { + argp = VaUintptr(&va) + } + n, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), uintptr(request), argp) + if err != 0 { + t.setErrno(err) + return -1 + } + + return int32(n) +} + +// int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen); +func Xgetsockname(t *TLS, sockfd int32, addr, addrlen uintptr) int32 { + if __ccgo_strace { + trc("t=%v sockfd=%v addrlen=%v, (%v:)", t, sockfd, addrlen, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_GETSOCKNAME, uintptr(sockfd), addr, addrlen); err != 0 { // Cannot avoid the syscall here. + if dmesgs { + dmesg("%v: fd %v: %v FAIL", origin(1), sockfd, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: fd %v: ok", origin(1), sockfd) + } + return 0 +} + +// int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); +func Xselect(t *TLS, nfds int32, readfds, writefds, exceptfds, timeout uintptr) int32 { + if __ccgo_strace { + trc("t=%v nfds=%v timeout=%v, (%v:)", t, nfds, timeout, origin(2)) + } + n, err := unix.Select( + int(nfds), + (*unix.FdSet)(unsafe.Pointer(readfds)), + (*unix.FdSet)(unsafe.Pointer(writefds)), + (*unix.FdSet)(unsafe.Pointer(exceptfds)), + (*unix.Timeval)(unsafe.Pointer(timeout)), + ) + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return int32(n) +} + +// int mkfifo(const char *pathname, mode_t mode); +func Xmkfifo(t *TLS, pathname uintptr, mode types.Mode_t) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2)) + } + if err := unix.Mkfifo(GoString(pathname), uint32(mode)); err != nil { + t.setErrno(err) + return -1 + } + + return 0 +} + +// mode_t umask(mode_t mask); +func Xumask(t *TLS, mask types.Mode_t) types.Mode_t { + if __ccgo_strace { + trc("t=%v mask=%v, (%v:)", t, mask, origin(2)) + } + return types.Mode_t(unix.Umask(int(mask))) +} + +// // int execvp(const char *file, char *const argv[]); +// func Xexecvp(t *TLS, file, argv uintptr) int32 { +// if _, _, err := unix.Syscall(unix.SYS_EXECVE, file, argv, Environ()); err != 0 { +// t.setErrno(err) +// return -1 +// } +// +// return 0 +// } + +// pid_t (pid_t pid, int *wstatus, int options); +func Xwaitpid(t *TLS, pid types.Pid_t, wstatus uintptr, optname int32) types.Pid_t { + if __ccgo_strace { + trc("t=%v pid=%v wstatus=%v optname=%v, (%v:)", t, pid, wstatus, optname, origin(2)) + } + n, err := unix.Wait4(int(pid), (*unix.WaitStatus)(unsafe.Pointer(wstatus)), int(optname), nil) + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return types.Pid_t(n) +} + +// int uname(struct utsname *buf); +func Xuname(t *TLS, buf uintptr) int32 { + if __ccgo_strace { + trc("t=%v buf=%v, (%v:)", t, buf, origin(2)) + } + if err := unix.Uname((*unix.Utsname)(unsafe.Pointer(buf))); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// ssize_t recv(int sockfd, void *buf, size_t len, int flags); +func Xrecv(t *TLS, sockfd int32, buf uintptr, len types.Size_t, flags int32) types.Ssize_t { + if __ccgo_strace { + trc("t=%v sockfd=%v buf=%v len=%v flags=%v, (%v:)", t, sockfd, buf, len, flags, origin(2)) + } + n, _, err := unix.Syscall6(unix.SYS_RECVFROM, uintptr(sockfd), buf, uintptr(len), uintptr(flags), 0, 0) + if err != 0 { + t.setErrno(err) + return -1 + } + + return types.Ssize_t(n) +} + +// ssize_t send(int sockfd, const void *buf, size_t len, int flags); +func Xsend(t *TLS, sockfd int32, buf uintptr, len types.Size_t, flags int32) types.Ssize_t { + if __ccgo_strace { + trc("t=%v sockfd=%v buf=%v len=%v flags=%v, (%v:)", t, sockfd, buf, len, flags, origin(2)) + } + n, _, err := unix.Syscall6(unix.SYS_SENDTO, uintptr(sockfd), buf, uintptr(len), uintptr(flags), 0, 0) + if err != 0 { + t.setErrno(err) + return -1 + } + + return types.Ssize_t(n) +} + +// int shutdown(int sockfd, int how); +func Xshutdown(t *TLS, sockfd, how int32) int32 { + if __ccgo_strace { + trc("t=%v how=%v, (%v:)", t, how, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_SHUTDOWN, uintptr(sockfd), uintptr(how), 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen); +func Xgetpeername(t *TLS, sockfd int32, addr uintptr, addrlen uintptr) int32 { + if __ccgo_strace { + trc("t=%v sockfd=%v addr=%v addrlen=%v, (%v:)", t, sockfd, addr, addrlen, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_GETPEERNAME, uintptr(sockfd), addr, uintptr(addrlen)); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int socket(int domain, int type, int protocol); +func Xsocket(t *TLS, domain, type1, protocol int32) int32 { + if __ccgo_strace { + trc("t=%v protocol=%v, (%v:)", t, protocol, origin(2)) + } + n, _, err := unix.Syscall(unix.SYS_SOCKET, uintptr(domain), uintptr(type1), uintptr(protocol)) + if err != 0 { + t.setErrno(err) + return -1 + } + + return int32(n) +} + +// int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +func Xbind(t *TLS, sockfd int32, addr uintptr, addrlen uint32) int32 { + if __ccgo_strace { + trc("t=%v sockfd=%v addr=%v addrlen=%v, (%v:)", t, sockfd, addr, addrlen, origin(2)) + } + n, _, err := unix.Syscall(unix.SYS_BIND, uintptr(sockfd), addr, uintptr(addrlen)) + if err != 0 { + t.setErrno(err) + return -1 + } + + return int32(n) +} + +// int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +func Xconnect(t *TLS, sockfd int32, addr uintptr, addrlen uint32) int32 { + if __ccgo_strace { + trc("t=%v sockfd=%v addr=%v addrlen=%v, (%v:)", t, sockfd, addr, addrlen, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_CONNECT, uintptr(sockfd), addr, uintptr(addrlen)); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int listen(int sockfd, int backlog); +func Xlisten(t *TLS, sockfd, backlog int32) int32 { + if __ccgo_strace { + trc("t=%v backlog=%v, (%v:)", t, backlog, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_LISTEN, uintptr(sockfd), uintptr(backlog), 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); +func Xaccept(t *TLS, sockfd int32, addr uintptr, addrlen uintptr) int32 { + if __ccgo_strace { + trc("t=%v sockfd=%v addr=%v addrlen=%v, (%v:)", t, sockfd, addr, addrlen, origin(2)) + } + panic(todo("")) + // n, _, err := unix.Syscall6(unix.SYS_ACCEPT4, uintptr(sockfd), addr, uintptr(addrlen), 0, 0, 0) + // if err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return int32(n) +} + +// // int getrlimit(int resource, struct rlimit *rlim); +// func Xgetrlimit(t *TLS, resource int32, rlim uintptr) int32 { +// return Xgetrlimit64(t, resource, rlim) +// } +// +// // int setrlimit(int resource, const struct rlimit *rlim); +// func Xsetrlimit(t *TLS, resource int32, rlim uintptr) int32 { +// return Xsetrlimit64(t, resource, rlim) +// } +// +// // int setrlimit(int resource, const struct rlimit *rlim); +// func Xsetrlimit64(t *TLS, resource int32, rlim uintptr) int32 { +// if _, _, err := unix.Syscall(unix.SYS_SETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 { +// t.setErrno(err) +// return -1 +// } +// +// return 0 +// } + +// uid_t getuid(void); +func Xgetuid(t *TLS) types.Uid_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + r := types.Uid_t(os.Getuid()) + if dmesgs { + dmesg("%v: %v", origin(1), r) + } + return r +} + +// pid_t getpid(void); +func Xgetpid(t *TLS) int32 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + r := int32(os.Getpid()) + if dmesgs { + dmesg("%v: %v", origin(1), r) + } + return r +} + +// int system(const char *command); +func Xsystem(t *TLS, command uintptr) int32 { + if __ccgo_strace { + trc("t=%v command=%v, (%v:)", t, command, origin(2)) + } + s := GoString(command) + if command == 0 { + panic(todo("")) + } + + cmd := exec.Command("sh", "-c", s) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + ps := err.(*exec.ExitError) + return int32(ps.ExitCode()) + } + + return 0 +} + +// int setvbuf(FILE *stream, char *buf, int mode, size_t size); +func Xsetvbuf(t *TLS, stream, buf uintptr, mode int32, size types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v buf=%v mode=%v size=%v, (%v:)", t, buf, mode, size, origin(2)) + } + return 0 //TODO +} + +// int raise(int sig); +func Xraise(t *TLS, sig int32) int32 { + if __ccgo_strace { + trc("t=%v sig=%v, (%v:)", t, sig, origin(2)) + } + panic(todo("")) +} + +// // int backtrace(void **buffer, int size); +// func Xbacktrace(t *TLS, buf uintptr, size int32) int32 { +// panic(todo("")) +// } +// +// // void backtrace_symbols_fd(void *const *buffer, int size, int fd); +// func Xbacktrace_symbols_fd(t *TLS, buffer uintptr, size, fd int32) { +// panic(todo("")) +// } + +// int fileno(FILE *stream); +func Xfileno(t *TLS, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + if stream == 0 { + if dmesgs { + dmesg("%v: FAIL", origin(1)) + } + t.setErrno(errno.EBADF) + return -1 + } + + if fd := int32((*stdio.FILE)(unsafe.Pointer(stream)).F_file); fd >= 0 { + return fd + } + + if dmesgs { + dmesg("%v: FAIL", origin(1)) + } + t.setErrno(errno.EBADF) + return -1 +} + +func newFtsent(t *TLS, info int, path string, stat *unix.Stat_t, err syscallErrno) (r *fts.FTSENT) { + var statp uintptr + if stat != nil { + statp = Xmalloc(t, types.Size_t(unsafe.Sizeof(unix.Stat_t{}))) + if statp == 0 { + panic("OOM") + } + + *(*unix.Stat_t)(unsafe.Pointer(statp)) = *stat + } + csp, errx := CString(path) + if errx != nil { + panic("OOM") + } + + return &fts.FTSENT{ + Ffts_info: uint16(info), + Ffts_path: csp, + Ffts_pathlen: uint16(len(path)), + Ffts_statp: statp, + Ffts_errno: int32(err), + } +} + +func newCFtsent(t *TLS, info int, path string, stat *unix.Stat_t, err syscallErrno) uintptr { + p := Xcalloc(t, 1, types.Size_t(unsafe.Sizeof(fts.FTSENT{}))) + if p == 0 { + panic("OOM") + } + + *(*fts.FTSENT)(unsafe.Pointer(p)) = *newFtsent(t, info, path, stat, err) + return p +} + +func ftsentClose(t *TLS, p uintptr) { + Xfree(t, (*fts.FTSENT)(unsafe.Pointer(p)).Ffts_path) + Xfree(t, (*fts.FTSENT)(unsafe.Pointer(p)).Ffts_statp) +} + +type ftstream struct { + s []uintptr + x int +} + +func (f *ftstream) close(t *TLS) { + for _, p := range f.s { + ftsentClose(t, p) + Xfree(t, p) + } + *f = ftstream{} +} + +// FTS *fts_open(char * const *path_argv, int options, int (*compar)(const FTSENT **, const FTSENT **)); +func Xfts_open(t *TLS, path_argv uintptr, options int32, compar uintptr) uintptr { + if __ccgo_strace { + trc("t=%v path_argv=%v options=%v compar=%v, (%v:)", t, path_argv, options, compar, origin(2)) + } + f := &ftstream{} + + var walk func(string) + walk = func(path string) { + var fi os.FileInfo + var err error + switch { + case options&fts.FTS_LOGICAL != 0: + fi, err = os.Stat(path) + case options&fts.FTS_PHYSICAL != 0: + fi, err = os.Lstat(path) + default: + panic(todo("")) + } + + if err != nil { + return + } + + var statp *unix.Stat_t + if options&fts.FTS_NOSTAT == 0 { + var stat unix.Stat_t + switch { + case options&fts.FTS_LOGICAL != 0: + if err := unix.Stat(path, &stat); err != nil { + panic(todo("")) + } + case options&fts.FTS_PHYSICAL != 0: + if err := unix.Lstat(path, &stat); err != nil { + panic(todo("")) + } + default: + panic(todo("")) + } + + statp = &stat + } + + out: + switch { + case fi.IsDir(): + f.s = append(f.s, newCFtsent(t, fts.FTS_D, path, statp, 0)) + g, err := os.Open(path) + switch x := err.(type) { + case nil: + // ok + case *os.PathError: + f.s = append(f.s, newCFtsent(t, fts.FTS_DNR, path, statp, errno.EACCES)) + break out + default: + panic(todo("%q: %v %T", path, x, x)) + } + + names, err := g.Readdirnames(-1) + g.Close() + if err != nil { + panic(todo("")) + } + + for _, name := range names { + walk(path + "/" + name) + if f == nil { + break out + } + } + + f.s = append(f.s, newCFtsent(t, fts.FTS_DP, path, statp, 0)) + default: + info := fts.FTS_F + if fi.Mode()&os.ModeSymlink != 0 { + info = fts.FTS_SL + } + switch { + case statp != nil: + f.s = append(f.s, newCFtsent(t, info, path, statp, 0)) + case options&fts.FTS_NOSTAT != 0: + f.s = append(f.s, newCFtsent(t, fts.FTS_NSOK, path, nil, 0)) + default: + panic(todo("")) + } + } + } + + for { + p := *(*uintptr)(unsafe.Pointer(path_argv)) + if p == 0 { + if f == nil { + return 0 + } + + if compar != 0 { + panic(todo("")) + } + + return addObject(f) + } + + walk(GoString(p)) + path_argv += unsafe.Sizeof(uintptr(0)) + } +} + +// FTSENT *fts_read(FTS *ftsp); +func Xfts_read(t *TLS, ftsp uintptr) uintptr { + if __ccgo_strace { + trc("t=%v ftsp=%v, (%v:)", t, ftsp, origin(2)) + } + f := getObject(ftsp).(*ftstream) + if f.x == len(f.s) { + if dmesgs { + dmesg("%v: FAIL", origin(1)) + } + t.setErrno(0) + return 0 + } + + r := f.s[f.x] + if e := (*fts.FTSENT)(unsafe.Pointer(r)).Ffts_errno; e != 0 { + if dmesgs { + dmesg("%v: FAIL", origin(1)) + } + t.setErrno(e) + } + f.x++ + return r +} + +// int fts_close(FTS *ftsp); +func Xfts_close(t *TLS, ftsp uintptr) int32 { + if __ccgo_strace { + trc("t=%v ftsp=%v, (%v:)", t, ftsp, origin(2)) + } + getObject(ftsp).(*ftstream).close(t) + removeObject(ftsp) + return 0 +} + +// void tzset (void); +func Xtzset(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + //TODO +} + +var strerrorBuf [100]byte + +// char *strerror(int errnum); +func Xstrerror(t *TLS, errnum int32) uintptr { + if __ccgo_strace { + trc("t=%v errnum=%v, (%v:)", t, errnum, origin(2)) + } + // if dmesgs { + // dmesg("%v: %v\n%s", origin(1), errnum, debug.Stack()) + // } + copy(strerrorBuf[:], fmt.Sprintf("strerror(%d)\x00", errnum)) + return uintptr(unsafe.Pointer(&strerrorBuf[0])) +} + +// void *dlopen(const char *filename, int flags); +func Xdlopen(t *TLS, filename uintptr, flags int32) uintptr { + if __ccgo_strace { + trc("t=%v filename=%v flags=%v, (%v:)", t, filename, flags, origin(2)) + } + panic(todo("")) +} + +// char *dlerror(void); +func Xdlerror(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) +} + +// int dlclose(void *handle); +func Xdlclose(t *TLS, handle uintptr) int32 { + if __ccgo_strace { + trc("t=%v handle=%v, (%v:)", t, handle, origin(2)) + } + panic(todo("")) +} + +// void *dlsym(void *handle, const char *symbol); +func Xdlsym(t *TLS, handle, symbol uintptr) uintptr { + if __ccgo_strace { + trc("t=%v symbol=%v, (%v:)", t, symbol, origin(2)) + } + panic(todo("")) +} + +// void perror(const char *s); +func Xperror(tls *TLS, msg uintptr) { + if __ccgo_strace { + trc("tls=%v msg=%v, (%v:)", tls, msg, origin(2)) + } + if msg != 0 && *(*int8)(unsafe.Pointer(msg)) != 0 { + fmt.Fprintf(os.Stderr, "%s: ", GoString(msg)) + } + errstr := Xstrerror(tls, *(*int32)(unsafe.Pointer(X__errno_location(tls)))) + fmt.Fprintf(os.Stderr, "%s\n", GoString(errstr)) +} + +// int pclose(FILE *stream); +func Xpclose(t *TLS, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + panic(todo("")) +} + +// var gai_strerrorBuf [100]byte + +// const char *gai_strerror(int errcode); +func Xgai_strerror(t *TLS, errcode int32) uintptr { + if __ccgo_strace { + trc("t=%v errcode=%v, (%v:)", t, errcode, origin(2)) + } + panic(todo("")) + // copy(gai_strerrorBuf[:], fmt.Sprintf("gai error %d\x00", errcode)) + // return uintptr(unsafe.Pointer(&gai_strerrorBuf)) +} + +// int tcgetattr(int fd, struct termios *termios_p); +func Xtcgetattr(t *TLS, fd int32, termios_p uintptr) int32 { + if __ccgo_strace { + trc("t=%v fd=%v termios_p=%v, (%v:)", t, fd, termios_p, origin(2)) + } + panic(todo("")) +} + +// int tcsetattr(int fd, int optional_actions, const struct termios *termios_p); +func Xtcsetattr(t *TLS, fd, optional_actions int32, termios_p uintptr) int32 { + if __ccgo_strace { + trc("t=%v optional_actions=%v termios_p=%v, (%v:)", t, optional_actions, termios_p, origin(2)) + } + panic(todo("")) +} + +// speed_t cfgetospeed(const struct termios *termios_p); +func Xcfgetospeed(t *TLS, termios_p uintptr) termios.Speed_t { + if __ccgo_strace { + trc("t=%v termios_p=%v, (%v:)", t, termios_p, origin(2)) + } + panic(todo("")) +} + +// int cfsetospeed(struct termios *termios_p, speed_t speed); +// func Xcfsetospeed(t *TLS, termios_p uintptr, speed uint32) int32 { +func Xcfsetospeed(...interface{}) int32 { + panic(todo("")) +} + +// int cfsetispeed(struct termios *termios_p, speed_t speed); +// func Xcfsetispeed(t *TLS, termios_p uintptr, speed uint32) int32 { +func Xcfsetispeed(...interface{}) int32 { + panic(todo("")) +} + +// pid_t fork(void); +func Xfork(t *TLS) int32 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + if dmesgs { + dmesg("%v: FAIL", origin(1)) + } + t.setErrno(errno.ENOSYS) + return -1 +} + +var emptyStr = [1]byte{} + +// char *setlocale(int category, const char *locale); +func Xsetlocale(t *TLS, category int32, locale uintptr) uintptr { + if __ccgo_strace { + trc("t=%v category=%v locale=%v, (%v:)", t, category, locale, origin(2)) + } + return uintptr(unsafe.Pointer(&emptyStr)) //TODO +} + +// char *nl_langinfo(nl_item item); +func Xnl_langinfo(t *TLS, item langinfo.Nl_item) uintptr { + if __ccgo_strace { + trc("t=%v item=%v, (%v:)", t, item, origin(2)) + } + return uintptr(unsafe.Pointer(&emptyStr)) //TODO +} + +// FILE *popen(const char *command, const char *type); +func Xpopen(t *TLS, command, type1 uintptr) uintptr { + if __ccgo_strace { + trc("t=%v type1=%v, (%v:)", t, type1, origin(2)) + } + panic(todo("")) +} + +// char *realpath(const char *path, char *resolved_path); +func Xrealpath(t *TLS, path, resolved_path uintptr) uintptr { + if __ccgo_strace { + trc("t=%v resolved_path=%v, (%v:)", t, resolved_path, origin(2)) + } + s, err := filepath.EvalSymlinks(GoString(path)) + if err != nil { + if os.IsNotExist(err) { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err) + } + t.setErrno(errno.ENOENT) + return 0 + } + + panic(todo("", err)) + } + + if resolved_path == 0 { + panic(todo("")) + } + + if len(s) >= limits.PATH_MAX { + s = s[:limits.PATH_MAX-1] + } + + copy((*RawMem)(unsafe.Pointer(resolved_path))[:len(s):len(s)], s) + (*RawMem)(unsafe.Pointer(resolved_path))[len(s)] = 0 + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(path)) + } + return resolved_path +} + +// char *inet_ntoa(struct in_addr in); +func Xinet_ntoa(t *TLS, in1 in.In_addr) uintptr { + if __ccgo_strace { + trc("t=%v in1=%v, (%v:)", t, in1, origin(2)) + } + panic(todo("")) +} + +func X__ccgo_in6addr_anyp(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) + // return uintptr(unsafe.Pointer(&in6_addr_any)) +} + +func Xabort(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + if dmesgs { + dmesg("%v:", origin(1)) + } + p := Xcalloc(t, 1, types.Size_t(unsafe.Sizeof(signal.Sigaction{}))) + if p == 0 { + panic("OOM") + } + + (*signal.Sigaction)(unsafe.Pointer(p)).F__sigaction_u.F__sa_handler = signal.SIG_DFL + Xsigaction(t, signal.SIGABRT, p, 0) + Xfree(t, p) + unix.Kill(unix.Getpid(), unix.Signal(signal.SIGABRT)) + panic(todo("unrechable")) +} + +// int fflush(FILE *stream); +func Xfflush(t *TLS, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + return 0 //TODO +} + +// size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); +func Xfread(t *TLS, ptr uintptr, size, nmemb types.Size_t, stream uintptr) types.Size_t { + if __ccgo_strace { + trc("t=%v ptr=%v nmemb=%v stream=%v, (%v:)", t, ptr, nmemb, stream, origin(2)) + } + if size == 0 || nmemb == 0 { + return 0 + } + fd := uintptr(file(stream).fd()) + count := size * nmemb + var n int + var err error + switch { + case count == 0: + n, err = unix.Read(int(fd), nil) + default: + n, err = unix.Read(int(fd), (*RawMem)(unsafe.Pointer(ptr))[:count:count]) + if n == 0 { + file(stream).setEOF() + } + if dmesgs && err == nil { + dmesg("%v: fd %v, n %#x\n%s", origin(1), fd, n, hex.Dump((*RawMem)(unsafe.Pointer(ptr))[:n:n])) + } + } + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + file(stream).setErr() + return types.Size_t(n) / size + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return types.Size_t(n) / size +} + +// size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); +func Xfwrite(t *TLS, ptr uintptr, size, nmemb types.Size_t, stream uintptr) types.Size_t { + if __ccgo_strace { + trc("t=%v ptr=%v nmemb=%v stream=%v, (%v:)", t, ptr, nmemb, stream, origin(2)) + } + if size == 0 || nmemb == 0 { + return 0 + } + fd := uintptr(file(stream).fd()) + count := size * nmemb + var n int + var err error + switch { + case count == 0: + n, err = unix.Write(int(fd), nil) + default: + n, err = unix.Write(int(fd), (*RawMem)(unsafe.Pointer(ptr))[:count:count]) + if dmesgs { + dmesg("%v: fd %v, count %#x\n%s", origin(1), fd, count, hex.Dump((*RawMem)(unsafe.Pointer(ptr))[:count:count])) + } + } + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + file(stream).setErr() + return types.Size_t(n) / size + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return types.Size_t(n) / size +} + +// int fclose(FILE *stream); +func Xfclose(t *TLS, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + r := file(stream).close(t) + if r != 0 { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), r) + } + t.setErrno(r) + return stdio.EOF + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int fputc(int c, FILE *stream); +func Xfputc(t *TLS, c int32, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v c=%v stream=%v, (%v:)", t, c, stream, origin(2)) + } + if _, err := fwrite(file(stream).fd(), []byte{byte(c)}); err != nil { + return stdio.EOF + } + + return int32(byte(c)) +} + +// int fseek(FILE *stream, long offset, int whence); +func Xfseek(t *TLS, stream uintptr, offset long, whence int32) int32 { + if __ccgo_strace { + trc("t=%v stream=%v offset=%v whence=%v, (%v:)", t, stream, offset, whence, origin(2)) + } + if n := Xlseek(t, int32(file(stream).fd()), types.Off_t(offset), whence); n < 0 { + if dmesgs { + dmesg("%v: fd %v, off %#x, whence %v: %v", origin(1), file(stream).fd(), offset, whenceStr(whence), n) + } + file(stream).setErr() + return -1 + } + + if dmesgs { + dmesg("%v: fd %v, off %#x, whence %v: ok", origin(1), file(stream).fd(), offset, whenceStr(whence)) + } + return 0 +} + +// long ftell(FILE *stream); +func Xftell(t *TLS, stream uintptr) long { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + n := Xlseek(t, file(stream).fd(), 0, stdio.SEEK_CUR) + if n < 0 { + file(stream).setErr() + return -1 + } + + if dmesgs { + dmesg("%v: fd %v, n %#x: ok %#x", origin(1), file(stream).fd(), n, long(n)) + } + return long(n) +} + +// int ferror(FILE *stream); +func Xferror(t *TLS, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + return Bool32(file(stream).err()) +} + +// int fputs(const char *s, FILE *stream); +func Xfputs(t *TLS, s, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_WRITE, uintptr(file(stream).fd()), s, uintptr(Xstrlen(t, s))); err != 0 { + return -1 + } + + return 0 +} + +var getservbynameStaticResult netdb.Servent + +// struct servent *getservbyname(const char *name, const char *proto); +func Xgetservbyname(t *TLS, name, proto uintptr) uintptr { + if __ccgo_strace { + trc("t=%v proto=%v, (%v:)", t, proto, origin(2)) + } + var protoent *gonetdb.Protoent + if proto != 0 { + protoent = gonetdb.GetProtoByName(GoString(proto)) + } + servent := gonetdb.GetServByName(GoString(name), protoent) + if servent == nil { + if dmesgs { + dmesg("%q %q: nil (protoent %+v)", GoString(name), GoString(proto), protoent) + } + return 0 + } + + Xfree(t, (*netdb.Servent)(unsafe.Pointer(&getservbynameStaticResult)).Fs_name) + if v := (*netdb.Servent)(unsafe.Pointer(&getservbynameStaticResult)).Fs_aliases; v != 0 { + for { + p := *(*uintptr)(unsafe.Pointer(v)) + if p == 0 { + break + } + + Xfree(t, p) + v += unsafe.Sizeof(uintptr(0)) + } + Xfree(t, v) + } + Xfree(t, (*netdb.Servent)(unsafe.Pointer(&getservbynameStaticResult)).Fs_proto) + cname, err := CString(servent.Name) + if err != nil { + getservbynameStaticResult = netdb.Servent{} + return 0 + } + + var protoname uintptr + if protoent != nil { + if protoname, err = CString(protoent.Name); err != nil { + Xfree(t, cname) + getservbynameStaticResult = netdb.Servent{} + return 0 + } + } + var a []uintptr + for _, v := range servent.Aliases { + cs, err := CString(v) + if err != nil { + for _, v := range a { + Xfree(t, v) + } + return 0 + } + + a = append(a, cs) + } + v := Xcalloc(t, types.Size_t(len(a)+1), types.Size_t(unsafe.Sizeof(uintptr(0)))) + if v == 0 { + Xfree(t, cname) + Xfree(t, protoname) + for _, v := range a { + Xfree(t, v) + } + getservbynameStaticResult = netdb.Servent{} + return 0 + } + for _, p := range a { + *(*uintptr)(unsafe.Pointer(v)) = p + v += unsafe.Sizeof(uintptr(0)) + } + + getservbynameStaticResult = netdb.Servent{ + Fs_name: cname, + Fs_aliases: v, + Fs_port: int32(servent.Port), + Fs_proto: protoname, + } + return uintptr(unsafe.Pointer(&getservbynameStaticResult)) +} + +// //TODO- func Xreaddir64(t *TLS, dir uintptr) uintptr { +// //TODO- return Xreaddir(t, dir) +// //TODO- } +// +// func __syscall(r, _ uintptr, errno syscallErrno) long { +// if errno != 0 { +// return long(-errno) +// } +// +// return long(r) +// } + +func fcntlCmdStr(cmd int32) string { + switch cmd { + case fcntl.F_GETOWN: + return "F_GETOWN" + case fcntl.F_SETLK: + return "F_SETLK" + case fcntl.F_GETLK: + return "F_GETLK" + case fcntl.F_SETFD: + return "F_SETFD" + case fcntl.F_GETFD: + return "F_GETFD" + default: + return fmt.Sprintf("cmd(%d)", cmd) + } +} + +// // struct __float2 { float __sinval; float __cosval; }; +// // struct __double2 { double __sinval; double __cosval; }; +// // +// // extern struct __float2 __sincosf_stret(float); +// // extern struct __double2 __sincos_stret(double); +// // extern struct __float2 __sincospif_stret(float); +// // extern struct __double2 __sincospi_stret(double); +// +// type X__float2 struct{ F__sinval, F__cosval float32 } +// type X__double2 struct{ F__sinval, F__cosval float32 } +// +// func X__sincosf_stret(*TLS, float32) X__float2 { +// panic(todo("")) +// } +// +// func X__sincos_stret(*TLS, float64) X__double2 { +// panic(todo("")) +// } +// +// func X__sincospif_stret(*TLS, float32) X__float2 { +// panic(todo("")) +// } +// +// func X__sincospi_stret(*TLS, float64) X__double2 { +// panic(todo("")) +// } + +// ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); +func Xpwrite(t *TLS, fd int32, buf uintptr, count types.Size_t, offset types.Off_t) types.Ssize_t { + if __ccgo_strace { + trc("t=%v fd=%v buf=%v count=%v offset=%v, (%v:)", t, fd, buf, count, offset, origin(2)) + } + var n int + var err error + switch { + case count == 0: + n, err = unix.Pwrite(int(fd), nil, int64(offset)) + default: + n, err = unix.Pwrite(int(fd), (*RawMem)(unsafe.Pointer(buf))[:count:count], int64(offset)) + if dmesgs { + dmesg("%v: fd %v, off %#x, count %#x\n%s", origin(1), fd, offset, count, hex.Dump((*RawMem)(unsafe.Pointer(buf))[:count:count])) + } + } + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return types.Ssize_t(n) +} + +// char***_NSGetEnviron() +func X_NSGetEnviron(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return EnvironP() +} + +// int chflags(const char *path, u_int flags); +func Xchflags(t *TLS, path uintptr, flags uint32) int32 { + if __ccgo_strace { + trc("t=%v path=%v flags=%v, (%v:)", t, path, flags, origin(2)) + } + if err := unix.Chflags(GoString(path), int(flags)); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int rmdir(const char *pathname); +func Xrmdir(t *TLS, pathname uintptr) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2)) + } + if err := unix.Rmdir(GoString(pathname)); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// uint64_t mach_absolute_time(void); +func Xmach_absolute_time(t *TLS) uint64 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return uint64(gotime.Now().UnixNano()) +} + +// See https://developer.apple.com/library/archive/qa/qa1398/_index.html +type machTimebaseInfo = struct { + Fnumer uint32 + Fdenom uint32 +} /* mach_time.h:36:1 */ + +// kern_return_t mach_timebase_info(mach_timebase_info_t info); +func Xmach_timebase_info(t *TLS, info uintptr) int32 { + if __ccgo_strace { + trc("t=%v info=%v, (%v:)", t, info, origin(2)) + } + *(*machTimebaseInfo)(unsafe.Pointer(info)) = machTimebaseInfo{Fnumer: 1, Fdenom: 1} + return 0 +} + +// int getattrlist(const char* path, struct attrlist * attrList, void * attrBuf, size_t attrBufSize, unsigned long options); +func Xgetattrlist(t *TLS, path, attrList, attrBuf uintptr, attrBufSize types.Size_t, options uint32) int32 { + if __ccgo_strace { + trc("t=%v attrBuf=%v attrBufSize=%v options=%v, (%v:)", t, attrBuf, attrBufSize, options, origin(2)) + } + if _, _, err := unix.Syscall6(unix.SYS_GETATTRLIST, path, attrList, attrBuf, uintptr(attrBufSize), uintptr(options), 0); err != 0 { // Cannot avoid the syscall here. + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int setattrlist(const char* path, struct attrlist * attrList, void * attrBuf, size_t attrBufSize, unsigned long options); +func Xsetattrlist(t *TLS, path, attrList, attrBuf uintptr, attrBufSize types.Size_t, options uint32) int32 { + if __ccgo_strace { + trc("t=%v attrBuf=%v attrBufSize=%v options=%v, (%v:)", t, attrBuf, attrBufSize, options, origin(2)) + } + if _, _, err := unix.Syscall6(unix.SYS_SETATTRLIST, path, attrList, attrBuf, uintptr(attrBufSize), uintptr(options), 0); err != 0 { // Cannot avoid the syscall here. + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int copyfile(const char *from, const char *to, copyfile_state_t state, copyfile_flags_t flags); +func Xcopyfile(t *TLS, _ ...interface{}) int32 { + panic(todo("")) +} + +// int truncate(const char *path, off_t length); +func Xtruncate(t *TLS, _ ...interface{}) int32 { + panic(todo("")) +} + +type darwinDir struct { + buf [4096]byte + fd int + h int + l int + + eof bool +} + +// DIR *opendir(const char *name); +func Xopendir(t *TLS, name uintptr) uintptr { + if __ccgo_strace { + trc("t=%v name=%v, (%v:)", t, name, origin(2)) + } + p := Xmalloc(t, uint64(unsafe.Sizeof(darwinDir{}))) + if p == 0 { + panic("OOM") + } + + fd := int(Xopen(t, name, fcntl.O_RDONLY|fcntl.O_DIRECTORY|fcntl.O_CLOEXEC, 0)) + if fd < 0 { + if dmesgs { + dmesg("%v: FAIL %v", origin(1), (*darwinDir)(unsafe.Pointer(p)).fd) + } + Xfree(t, p) + // trc("==== opendir: %#x", 0) + return 0 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + (*darwinDir)(unsafe.Pointer(p)).fd = fd + (*darwinDir)(unsafe.Pointer(p)).h = 0 + (*darwinDir)(unsafe.Pointer(p)).l = 0 + (*darwinDir)(unsafe.Pointer(p)).eof = false + // trc("==== opendir: %#x", p) + return p +} + +// struct dirent *readdir(DIR *dirp); +func Xreaddir(t *TLS, dir uintptr) uintptr { + if __ccgo_strace { + trc("t=%v dir=%v, (%v:)", t, dir, origin(2)) + } + if (*darwinDir)(unsafe.Pointer(dir)).eof { + return 0 + } + + // trc(".... readdir %#x: l %v, h %v", dir, (*darwinDir)(unsafe.Pointer(dir)).l, (*darwinDir)(unsafe.Pointer(dir)).h) + if (*darwinDir)(unsafe.Pointer(dir)).l == (*darwinDir)(unsafe.Pointer(dir)).h { + n, err := unix.Getdirentries((*darwinDir)(unsafe.Pointer(dir)).fd, (*darwinDir)(unsafe.Pointer(dir)).buf[:], nil) + // trc("must read: %v %v", n, err) + if n == 0 { + if err != nil && err != io.EOF { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + } + (*darwinDir)(unsafe.Pointer(dir)).eof = true + return 0 + } + + (*darwinDir)(unsafe.Pointer(dir)).l = 0 + (*darwinDir)(unsafe.Pointer(dir)).h = n + // trc("new l %v, h %v", (*darwinDir)(unsafe.Pointer(dir)).l, (*darwinDir)(unsafe.Pointer(dir)).h) + } + de := dir + unsafe.Offsetof(darwinDir{}.buf) + uintptr((*darwinDir)(unsafe.Pointer(dir)).l) + // trc("dir %#x de %#x", dir, de) + (*darwinDir)(unsafe.Pointer(dir)).l += int((*unix.Dirent)(unsafe.Pointer(de)).Reclen) + // trc("final l %v, h %v", (*darwinDir)(unsafe.Pointer(dir)).l, (*darwinDir)(unsafe.Pointer(dir)).h) + return de +} + +func Xclosedir(t *TLS, dir uintptr) int32 { + if __ccgo_strace { + trc("t=%v dir=%v, (%v:)", t, dir, origin(2)) + } + // trc("---- closedir: %#x", dir) + r := Xclose(t, int32((*darwinDir)(unsafe.Pointer(dir)).fd)) + Xfree(t, dir) + return r +} + +// int pipe(int pipefd[2]); +func Xpipe(t *TLS, pipefd uintptr) int32 { + if __ccgo_strace { + trc("t=%v pipefd=%v, (%v:)", t, pipefd, origin(2)) + } + var a [2]int + if err := unix.Pipe(a[:]); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + *(*[2]int32)(unsafe.Pointer(pipefd)) = [2]int32{int32(a[0]), int32(a[1])} + if dmesgs { + dmesg("%v: %v ok", origin(1), a) + } + return 0 +} + +// int __isoc99_sscanf(const char *str, const char *format, ...); +func X__isoc99_sscanf(t *TLS, str, format, va uintptr) int32 { + if __ccgo_strace { + trc("t=%v va=%v, (%v:)", t, va, origin(2)) + } + r := scanf(strings.NewReader(GoString(str)), format, va) + // if dmesgs { + // dmesg("%v: %q %q: %d", origin(1), GoString(str), GoString(format), r) + // } + return r +} + +// int sscanf(const char *str, const char *format, ...); +func Xsscanf(t *TLS, str, format, va uintptr) int32 { + if __ccgo_strace { + trc("t=%v va=%v, (%v:)", t, va, origin(2)) + } + r := scanf(strings.NewReader(GoString(str)), format, va) + // if dmesgs { + // dmesg("%v: %q %q: %d", origin(1), GoString(str), GoString(format), r) + // } + return r +} + +// int posix_fadvise(int fd, off_t offset, off_t len, int advice); +func Xposix_fadvise(t *TLS, fd int32, offset, len types.Off_t, advice int32) int32 { + if __ccgo_strace { + trc("t=%v fd=%v len=%v advice=%v, (%v:)", t, fd, len, advice, origin(2)) + } + panic(todo("")) +} + +// clock_t clock(void); +func Xclock(t *TLS) time.Clock_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return time.Clock_t(gotime.Since(startTime) * gotime.Duration(time.CLOCKS_PER_SEC) / gotime.Second) +} + +// int iswspace(wint_t wc); +func Xiswspace(t *TLS, wc wctype.Wint_t) int32 { + if __ccgo_strace { + trc("t=%v wc=%v, (%v:)", t, wc, origin(2)) + } + return Bool32(unicode.IsSpace(rune(wc))) +} + +// int iswalnum(wint_t wc); +func Xiswalnum(t *TLS, wc wctype.Wint_t) int32 { + if __ccgo_strace { + trc("t=%v wc=%v, (%v:)", t, wc, origin(2)) + } + return Bool32(unicode.IsLetter(rune(wc)) || unicode.IsNumber(rune(wc))) +} + +// void arc4random_buf(void *buf, size_t nbytes); +func Xarc4random_buf(t *TLS, buf uintptr, buflen size_t) { + if __ccgo_strace { + trc("t=%v buf=%v buflen=%v, (%v:)", t, buf, buflen, origin(2)) + } + if _, err := crand.Read((*RawMem)(unsafe.Pointer(buf))[:buflen]); err != nil { + panic(todo("")) + } +} + +type darwin_mutexattr_t struct { + sig int64 + x [8]byte +} + +type darwin_mutex_t struct { + sig int64 + x [65]byte +} + +func X__ccgo_pthreadMutexattrGettype(tls *TLS, a uintptr) int32 { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + } + return (int32((*darwin_mutexattr_t)(unsafe.Pointer(a)).x[4] >> 2 & 3)) +} + +func X__ccgo_getMutexType(tls *TLS, m uintptr) int32 { + if __ccgo_strace { + trc("tls=%v m=%v, (%v:)", tls, m, origin(2)) + } + return (int32((*darwin_mutex_t)(unsafe.Pointer(m)).x[4] >> 2 & 3)) +} + +func X__ccgo_pthreadAttrGetDetachState(tls *TLS, a uintptr) int32 { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + } + return (*pthreadAttr)(unsafe.Pointer(a)).detachState +} + +func Xpthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) int32 { + if __ccgo_strace { + trc("tls=%v a=%v state=%v, (%v:)", tls, a, state, origin(2)) + } + panic(todo("")) +} + +func Xpthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) (r int32) { + if uint32(state) > 1 { + return errno.EINVAL + } + + (*pthreadAttr)(unsafe.Pointer(a)).detachState = state + return 0 +} + +func Xpthread_mutexattr_destroy(tls *TLS, a uintptr) int32 { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + } + return 0 +} + +func Xpthread_mutexattr_init(tls *TLS, a uintptr) int32 { + if __ccgo_strace { + trc("tls=%v a=%v, (%v:)", tls, a, origin(2)) + } + *(*darwin_mutexattr_t)(unsafe.Pointer(a)) = darwin_mutexattr_t{} + return 0 +} + +func Xpthread_mutexattr_settype(tls *TLS, a uintptr, type1 int32) int32 { + if __ccgo_strace { + trc("tls=%v a=%v type1=%v, (%v:)", tls, a, type1, origin(2)) + } + if uint32(type1) > uint32(2) { + return errno.EINVAL + } + (*darwin_mutexattr_t)(unsafe.Pointer(a)).x[4] = byte(type1 << 2) + return 0 +} + +// ssize_t writev(int fd, const struct iovec *iov, int iovcnt); +func Xwritev(t *TLS, fd int32, iov uintptr, iovcnt int32) types.Ssize_t { + if __ccgo_strace { + trc("t=%v fd=%v iov=%v iovcnt=%v, (%v:)", t, fd, iov, iovcnt, origin(2)) + } + // if dmesgs { + // dmesg("%v: fd %v iov %#x iovcnt %v", origin(1), fd, iov, iovcnt) + // } + r, _, err := unix.Syscall(unix.SYS_WRITEV, uintptr(fd), iov, uintptr(iovcnt)) + if err != 0 { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + return types.Ssize_t(r) +} + +// int pause(void); +func Xpause(t *TLS) int32 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + c := make(chan os.Signal) + gosignal.Notify(c, + unix.SIGABRT, + unix.SIGALRM, + unix.SIGBUS, + unix.SIGCHLD, + unix.SIGCONT, + unix.SIGFPE, + unix.SIGHUP, + unix.SIGILL, + // unix.SIGINT, + unix.SIGIO, + unix.SIGIOT, + unix.SIGKILL, + unix.SIGPIPE, + unix.SIGPROF, + unix.SIGQUIT, + unix.SIGSEGV, + unix.SIGSTOP, + unix.SIGSYS, + unix.SIGTERM, + unix.SIGTRAP, + unix.SIGTSTP, + unix.SIGTTIN, + unix.SIGTTOU, + unix.SIGURG, + unix.SIGUSR1, + unix.SIGUSR2, + unix.SIGVTALRM, + unix.SIGWINCH, + unix.SIGXCPU, + unix.SIGXFSZ, + ) + switch <-c { + case unix.SIGINT: + panic(todo("")) + default: + t.setErrno(errno.EINTR) + return -1 + } +} + +// #define __DARWIN_FD_SETSIZE 1024 +// #define __DARWIN_NFDBITS (sizeof(__int32_t) * __DARWIN_NBBY) /* bits per mask */ +// #define __DARWIN_NBBY 8 /* bits in a byte */ +// #define __DARWIN_howmany(x, y) ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1)) /* # y's == x bits? */ + +// typedef struct fd_set { +// __int32_t fds_bits[__DARWIN_howmany(__DARWIN_FD_SETSIZE, __DARWIN_NFDBITS)]; +// } fd_set; + +// __darwin_fd_set(int _fd, struct fd_set *const _p) +// +// { +// (_p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] |= ((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS)))); +// } +func X__darwin_fd_set(tls *TLS, _fd int32, _p uintptr) int32 { /* main.c:12:1: */ + if __ccgo_strace { + trc("tls=%v _fd=%v _p=%v, (%v:)", tls, _fd, _p, origin(2)) + } + *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) |= int32(uint64(uint64(1)) << (uint64(_fd) % (uint64(unsafe.Sizeof(int32(0))) * uint64(8)))) + return int32(0) +} + +// __darwin_fd_isset(int _fd, const struct fd_set *_p) +// +// { +// return _p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] & ((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS))); +// } +func X__darwin_fd_isset(tls *TLS, _fd int32, _p uintptr) int32 { /* main.c:17:1: */ + if __ccgo_strace { + trc("tls=%v _fd=%v _p=%v, (%v:)", tls, _fd, _p, origin(2)) + } + return *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) & int32(uint64(uint64(1))<<(uint64(_fd)%(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))) +} + +// __darwin_fd_clr(int _fd, struct fd_set *const _p) +// +// { +// (_p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] &= ~((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS)))); +// } +func X__darwin_fd_clr(tls *TLS, _fd int32, _p uintptr) int32 { /* main.c:22:1: */ + if __ccgo_strace { + trc("tls=%v _fd=%v _p=%v, (%v:)", tls, _fd, _p, origin(2)) + } + *(*int32)(unsafe.Pointer(_p + uintptr(uint64(_fd)/(uint64(unsafe.Sizeof(int32(0)))*uint64(8)))*4)) &= ^int32(uint64(uint64(1)) << (uint64(_fd) % (uint64(unsafe.Sizeof(int32(0))) * uint64(8)))) + return int32(0) +} + +// int ungetc(int c, FILE *stream); +func Xungetc(t *TLS, c int32, stream uintptr) int32 { + if __ccgo_strace { + trc("t=%v c=%v stream=%v, (%v:)", t, c, stream, origin(2)) + } + panic(todo("")) +} + +// int issetugid(void); +func Xissetugid(t *TLS) int32 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) +} + +var progname uintptr + +// const char *getprogname(void); +func Xgetprogname(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + if progname != 0 { + return progname + } + + var err error + progname, err = CString(filepath.Base(os.Args[0])) + if err != nil { + t.setErrno(err) + return 0 + } + + return progname +} + +// void uuid_copy(uuid_t dst, uuid_t src); +func Xuuid_copy(t *TLS, dst, src uintptr) { + if __ccgo_strace { + trc("t=%v src=%v, (%v:)", t, src, origin(2)) + } + *(*uuid.Uuid_t)(unsafe.Pointer(dst)) = *(*uuid.Uuid_t)(unsafe.Pointer(src)) +} + +// int uuid_parse( char *in, uuid_t uu); +func Xuuid_parse(t *TLS, in uintptr, uu uintptr) int32 { + if __ccgo_strace { + trc("t=%v in=%v uu=%v, (%v:)", t, in, uu, origin(2)) + } + r, err := guuid.Parse(GoString(in)) + if err != nil { + return -1 + } + + copy((*RawMem)(unsafe.Pointer(uu))[:unsafe.Sizeof(uuid.Uuid_t{})], r[:]) + return 0 +} + +// struct __float2 { float __sinval; float __cosval; }; + +// struct __float2 __sincosf_stret(float); +func X__sincosf_stret(t *TLS, f float32) struct{ F__sinval, F__cosval float32 } { + panic(todo("")) +} + +// struct __double2 { double __sinval; double __cosval; }; + +// struct __double2 __sincos_stret(double); +func X__sincos_stret(t *TLS, f float64) struct{ F__sinval, F__cosval float64 } { + panic(todo("")) +} + +// struct __float2 __sincospif_stret(float); +func X__sincospif_stret(t *TLS, f float32) struct{ F__sinval, F__cosval float32 } { + panic(todo("")) +} + +// struct _double2 __sincospi_stret(double); +func X__sincospi_stret(t *TLS, f float64) struct{ F__sinval, F__cosval float64 } { + panic(todo("")) +} + +// int __srget(FILE *); +func X__srget(t *TLS, f uintptr) int32 { + if __ccgo_strace { + trc("t=%v f=%v, (%v:)", t, f, origin(2)) + } + panic(todo("")) +} + +// int __svfscanf(FILE *, const char *, va_list) __scanflike(2, 0); +func X__svfscanf(t *TLS, f uintptr, p, q uintptr) int32 { + if __ccgo_strace { + trc("t=%v f=%v q=%v, (%v:)", t, f, q, origin(2)) + } + panic(todo("")) +} + +// int __swbuf(int, FILE *); +func X__swbuf(t *TLS, i int32, f uintptr) int32 { + if __ccgo_strace { + trc("t=%v i=%v f=%v, (%v:)", t, i, f, origin(2)) + } + panic(todo("")) +} + +// int nanosleep(const struct timespec *req, struct timespec *rem); +func Xnanosleep(t *TLS, req, rem uintptr) int32 { + if __ccgo_strace { + trc("t=%v rem=%v, (%v:)", t, rem, origin(2)) + } + v := *(*time.Timespec)(unsafe.Pointer(req)) + gotime.Sleep(gotime.Second*gotime.Duration(v.Ftv_sec) + gotime.Duration(v.Ftv_nsec)) + return 0 +} + +// // void malloc_set_zone_name(malloc_zone_t *zone, const char *name) +// func Xmalloc_set_zone_name(t *TLS, zone, name uintptr) { +// if __ccgo_strace { +// trc("t=%v zone=%v name=%v, (%v:)", t, zone, name, origin(2)) +// } +// // nop +// } + +// size_t malloc_size(const void *ptr); +func Xmalloc_size(t *TLS, p uintptr) (r types.Size_t) { + if __ccgo_strace { + trc("t=%v p=%v, (%v:)", t, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + if p == 0 { + return 0 + } + + allocMu.Lock() + + defer allocMu.Unlock() + + return types.Size_t(memory.UintptrUsableSize(p)) +} + +// int open(const char *pathname, int flags, ...); +func Xopen64(t *TLS, pathname uintptr, flags int32, args uintptr) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v flags=%v args=%v, (%v:)", t, pathname, flags, args, origin(2)) + } + var mode types.Mode_t + if args != 0 { + mode = (types.Mode_t)(VaUint32(&args)) + } + fdcwd := fcntl.AT_FDCWD + n, _, err := unix.Syscall6(unix.SYS_OPENAT, uintptr(fdcwd), pathname, uintptr(flags), uintptr(mode), 0, 0) + if err != 0 { + // if dmesgs { + // dmesg("%v: %q %#x: %v", origin(1), GoString(pathname), flags, err) + // } + t.setErrno(err) + return -1 + } + + // if dmesgs { + // dmesg("%v: %q flags %#x mode %#o: fd %v", origin(1), GoString(pathname), flags, mode, n) + // } + return int32(n) +} + +// int getrlimit(int resource, struct rlimit *rlim); +func Xgetrlimit(t *TLS, resource int32, rlim uintptr) int32 { + if __ccgo_strace { + trc("t=%v resource=%v rlim=%v, (%v:)", t, resource, rlim, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_GETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int setrlimit(int resource, const struct rlimit *rlim); +func Xsetrlimit(t *TLS, resource int32, rlim uintptr) int32 { + if __ccgo_strace { + trc("t=%v resource=%v rlim=%v, (%v:)", t, resource, rlim, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_SETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +func X__fpclassifyd(tls *TLS, x float64) (r int32) { + return X__fpclassify(tls, x) +} + +var Xin6addr_any = in6_addr{} + +func X__builtin_lround(tls *TLS, x float64) (r long) { + return Xlround(tls, x) +} + +func Xlround(tls *TLS, x float64) (r long) { + return long(Xround(tls, x)) +} + +// https://g.co/gemini/share/2c37d5b57994 + +// Constants mirroring C's ftw type flags +const ( + FTW_F = 0 // Regular file + FTW_D = 1 // Directory (visited pre-order) + FTW_DNR = 2 // Directory that cannot be read + FTW_NS = 4 // Stat failed (permissions, broken link, etc.) + FTW_SL = 4 // Symbolic link (lstat was used) + // Note: C's ftw might have other flags like FTW_DP (post-order dir) or FTW_SLN + // which are not directly supported by filepath.WalkDir's simple pre-order traversal. + // This emulation focuses on the most common flags associated with stat/lstat results. +) + +// ftwStopError is used internally to signal that the walk should stop +// because the user callback returned a non-zero value. +type ftwStopError struct { + stopValue int +} + +func (e *ftwStopError) Error() string { + return fmt.Sprintf("ftw walk stopped by callback with return value %d", e.stopValue) +} + +// goFtwFunc is the callback function type, mirroring the C ftw callback. +// It receives the path, file info (if available), and a type flag. +// Returning a non-zero value stops the walk and becomes the return value of Ftw. +// Returning 0 continues the walk. +type goFtwFunc func(path string, info os.FileInfo, typeflag int) int + +// Ftw emulates the C standard library function ftw(3). +// It walks the directory tree starting at 'dirpath' and calls the 'callback' +// function for each entry encountered. +// +// Parameters: +// - dirpath: The root directory path for the traversal. +// - callback: The goFtwFunc to call for each file system entry. +// - nopenfd: This parameter is part of the C ftw signature but is IGNORED +// in this Go implementation. Go's filepath.WalkDir manages concurrency +// and file descriptors internally. +// +// Returns: +// - 0 on successful completion of the walk. +// - The non-zero value returned by the callback, if the callback terminated the walk. +// - -1 if an error occurred during the walk that wasn't handled by calling +// the callback with FTW_DNR or FTW_NS (e.g., error accessing the initial dirpath). +func ftw(dirpath string, callback goFtwFunc, nopenfd int) int { + // nopenfd is ignored in this Go implementation. + + walkErr := filepath.WalkDir(dirpath, func(path string, d fs.DirEntry, err error) error { + var info os.FileInfo + var typeflag int + + // --- Handle errors passed by WalkDir --- + if err != nil { + // Check if the error is related to accessing a directory + if errors.Is(err, fs.ErrPermission) || errors.Is(err, unix.EACCES) { // Added syscall.EACCES check + // Try to determine if it's a directory we can't read + // We might not have 'd' if the error occurred trying to list 'path' contents + // Let's try a direct Lstat on the path itself if d is nil + lstatInfo, lstatErr := os.Lstat(path) + if lstatErr == nil && lstatInfo.IsDir() { + typeflag = FTW_DNR // Directory, but WalkDir errored (likely reading it) + info = lstatInfo // Provide the info we could get + } else { + // Can't confirm it's a directory, or Lstat itself failed + typeflag = FTW_NS // Treat as general stat failure + // info remains nil + } + } else { + // Other errors (e.g., broken symlink during traversal, I/O error) + typeflag = FTW_NS + // Attempt to get Lstat info even if WalkDir had an error, maybe it's available + lstatInfo, _ := os.Lstat(path) // Ignore error here, if it fails info stays nil + info = lstatInfo + } + // Even with errors, call the callback with the path and appropriate flag + stopVal := callback(path, info, typeflag) + if stopVal != 0 { + return &ftwStopError{stopValue: stopVal} + } + // If the error was on a directory, returning the error might stop WalkDir + // from descending. If it was fs.ErrPermission on a dir, WalkDir might + // pass filepath.SkipDir implicitly or continue depending on implementation. + // Let's return nil here to *try* to continue the walk for other siblings + // if the callback didn't stop it. The callback *was* notified. + // If the error prevents further progress WalkDir will stop anyway. + return nil // Allow walk to potentially continue elsewhere + } + + // --- No error from WalkDir, process the DirEntry --- + info, err = d.Info() // Get FileInfo (like C's stat/lstat result) + if err != nil { + // Error getting info for an entry WalkDir *could* list (rare, maybe permissions changed?) + typeflag = FTW_NS + // info remains nil + } else { + // Determine type flag based on file mode + mode := info.Mode() + if mode&fs.ModeSymlink != 0 { + typeflag = FTW_SL + } else if mode.IsDir() { + typeflag = FTW_D // Visited pre-order + } else if mode.IsRegular() { + typeflag = FTW_F + } else { + // Other types (device, socket, pipe, etc.) - C ftw usually lumps these under FTW_F + // or might have FTW_NS if stat fails. Let's treat non-dir, non-link, non-regular + // as FTW_F for simplicity, aligning with common C practice, or FTW_NS if stat failed above. + // Since we have info here, we know stat didn't fail. + // Let's be more specific, maybe treat others as FTW_NS? Or stick to FTW_F? + // C ftw man page isn't super specific about all types. FTW_F seems reasonable. + typeflag = FTW_F // Treat other valid types as 'files' for simplicity + } + } + + // --- Call the user callback --- + stopVal := callback(path, info, typeflag) + if stopVal != 0 { + // User wants to stop the walk + return &ftwStopError{stopValue: stopVal} + } + + return nil // Continue walk + }) + + // --- Handle WalkDir's final return value --- + if walkErr == nil { + return 0 // Success + } + + // Check if the error was our custom stop signal + var stopErr *ftwStopError + if errors.As(walkErr, &stopErr) { + return stopErr.stopValue // Return the value from the callback + } + + // Otherwise, it was an unhandled error during the walk + // (e.g., initial dirpath access error, or other error not mapped to FTW_NS/DNR) + return -1 // General error return +} + +func Xftw(tls *TLS, path uintptr, fn uintptr, fd_limit int32) (r int32) { + statp := tls.Alloc(int(unsafe.Sizeof(unix.Stat_t{}))) + + defer tls.Free(int(unsafe.Sizeof(unix.Stat_t{}))) + + return int32(ftw( + GoString(path), + func(path string, info os.FileInfo, typeflag int) int { + cs, _ := CString(path) + + defer Xfree(tls, cs) + + Xstat(tls, cs, statp) + return int((*(*func(*TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{fn})))(tls, cs, statp, int32(typeflag))) + }, + int(fd_limit), + )) +} + +func Xexecve(tls *TLS, path uintptr, argv uintptr, envp uintptr) (r int32) { + goPath := GoString(path) + var goArgv, goEnvp []string + for p := *(*uintptr)(unsafe.Pointer(argv)); p != 0; p = *(*uintptr)(unsafe.Pointer(argv)) { + goArgv = append(goArgv, GoString(p)) + argv += unsafe.Sizeof(uintptr(0)) + } + for p := *(*uintptr)(unsafe.Pointer(envp)); p != 0; p = *(*uintptr)(unsafe.Pointer(envp)) { + goEnvp = append(goEnvp, GoString(p)) + envp += unsafe.Sizeof(uintptr(0)) + } + if err := unix.Exec(goPath, goArgv, goEnvp); err != nil { + tls.setErrno(err) + return -1 + } + panic("unreachable") +} + +func Xsetuid(tls *TLS, uid uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v uid=%v, (%v:)", tls, uid, origin(2)) + defer func() { trc("-> %v", r) }() + } + if err := unix.Setuid(int(uid)); err != nil { + tls.setErrno(err) + return -1 + } + + return 0 +} + +func Xsetgid(tls *TLS, gid uint32) (r int32) { + if __ccgo_strace { + trc("tls=%v gid=%v, (%v:)", tls, gid, origin(2)) + defer func() { trc("-> %v", r) }() + } + if err := unix.Setgid(int(gid)); err != nil { + tls.setErrno(err) + return -1 + } + + return 0 +} + +func Xdup(tls *TLS, fd int32) (r int32) { + if __ccgo_strace { + trc("tls=%v fd=%v, (%v:)", tls, fd, origin(2)) + defer func() { trc("-> %v", r) }() + } + nfd, err := unix.Dup(int(fd)) + if err != nil { + tls.setErrno(err) + return -1 + } + + return int32(nfd) +} + +func X__builtin_ctz(t *TLS, n uint32) int32 { + return int32(mbits.TrailingZeros32(n)) +} + +func AtomicLoadNUint8(ptr uintptr, memorder int32) uint8 { + return byte(a_load_8(ptr)) +} diff --git a/internal/libc/libc_darwin_amd64.go b/internal/libc/libc_darwin_amd64.go new file mode 100644 index 0000000..b6a5b65 --- /dev/null +++ b/internal/libc/libc_darwin_amd64.go @@ -0,0 +1,536 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "strings" + "time" + "unsafe" + + "golang.org/x/sys/unix" + "github.com/hanzoai/sqlite/internal/libc/fcntl" + "github.com/hanzoai/sqlite/internal/libc/signal" + "github.com/hanzoai/sqlite/internal/libc/stdio" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/libc/utime" +) + +// #define FE_DOWNWARD 0x0400 +// #define FE_UPWARD 0x0800 +const FE_DOWNWARD = 0x0400 +const FE_UPWARD = 0x0800 + +// int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); +func Xsigaction(t *TLS, signum int32, act, oldact uintptr) int32 { + if __ccgo_strace { + trc("t=%v signum=%v oldact=%v, (%v:)", t, signum, oldact, origin(2)) + } + var kact, koldact uintptr + if act != 0 { + sz := int(unsafe.Sizeof(signal.X__sigaction{})) + kact = t.Alloc(sz) + defer t.Free(sz) + (*signal.X__sigaction)(unsafe.Pointer(kact)).F__sigaction_u.F__sa_handler = (*signal.Sigaction)(unsafe.Pointer(act)).F__sigaction_u.F__sa_handler + (*signal.X__sigaction)(unsafe.Pointer(kact)).Fsa_flags = (*signal.Sigaction)(unsafe.Pointer(act)).Fsa_flags + Xmemcpy(t, kact+unsafe.Offsetof(signal.X__sigaction{}.Fsa_mask), act+unsafe.Offsetof(signal.Sigaction{}.Fsa_mask), types.Size_t(unsafe.Sizeof(signal.Sigset_t(0)))) + } + if oldact != 0 { + panic(todo("")) + } + + if _, _, err := unix.Syscall6(unix.SYS_SIGACTION, uintptr(signum), kact, koldact, unsafe.Sizeof(signal.Sigset_t(0)), 0, 0); err != 0 { + t.setErrno(err) + return -1 + } + + if oldact != 0 { + panic(todo("")) + } + + return 0 +} + +// int fcntl(int fd, int cmd, ... /* arg */ ); +func Xfcntl64(t *TLS, fd, cmd int32, args uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v cmd=%v args=%v, (%v:)", t, cmd, args, origin(2)) + defer func() { trc("-> %v", r) }() + } + var err error + var p uintptr + var i int + switch cmd { + case fcntl.F_GETLK, fcntl.F_SETLK: + p = *(*uintptr)(unsafe.Pointer(args)) + err = unix.FcntlFlock(uintptr(fd), int(cmd), (*unix.Flock_t)(unsafe.Pointer(p))) + case fcntl.F_GETFL, fcntl.F_FULLFSYNC: + i, err = unix.FcntlInt(uintptr(fd), int(cmd), 0) + r = int32(i) + case fcntl.F_SETFD, fcntl.F_SETFL: + arg := *(*int32)(unsafe.Pointer(args)) + _, err = unix.FcntlInt(uintptr(fd), int(cmd), int(arg)) + default: + panic(todo("%v: %v %v", origin(1), fd, cmd)) + } + if err != nil { + if dmesgs { + dmesg("%v: fd %v cmd %v p %#x: %v FAIL", origin(1), fcntlCmdStr(fd), cmd, p, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %d %s %#x: ok", origin(1), fd, fcntlCmdStr(cmd), p) + } + return r +} + +// int lstat(const char *pathname, struct stat *statbuf); +func Xlstat64(t *TLS, pathname, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2)) + } + if err := unix.Lstat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(pathname)) + } + return 0 +} + +// int stat(const char *pathname, struct stat *statbuf); +func Xstat64(t *TLS, pathname, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2)) + } + if err := unix.Stat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(pathname)) + } + return 0 +} + +// int fstatfs(int fd, struct statfs *buf); +func Xfstatfs(t *TLS, fd int32, buf uintptr) int32 { + if __ccgo_strace { + trc("t=%v fd=%v buf=%v, (%v:)", t, fd, buf, origin(2)) + } + if err := unix.Fstatfs(int(fd), (*unix.Statfs_t)(unsafe.Pointer(buf))); err != nil { + if dmesgs { + dmesg("%v: %v: %v FAIL", origin(1), fd, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %v: ok", origin(1), fd) + } + return 0 +} + +// int statfs(const char *path, struct statfs *buf); +func Xstatfs(t *TLS, path uintptr, buf uintptr) int32 { + if __ccgo_strace { + trc("t=%v path=%v buf=%v, (%v:)", t, path, buf, origin(2)) + } + if err := unix.Statfs(GoString(path), (*unix.Statfs_t)(unsafe.Pointer(buf))); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(path)) + } + return 0 +} + +// int fstat(int fd, struct stat *statbuf); +func Xfstat64(t *TLS, fd int32, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v fd=%v statbuf=%v, (%v:)", t, fd, statbuf, origin(2)) + } + if err := unix.Fstat(int(fd), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil { + if dmesgs { + dmesg("%v: fd %d: %v FAIL", origin(1), fd, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: fd %d: ok", origin(1), fd) + } + return 0 +} + +// off64_t lseek64(int fd, off64_t offset, int whence); +func Xlseek64(t *TLS, fd int32, offset types.Off_t, whence int32) types.Off_t { + if __ccgo_strace { + trc("t=%v fd=%v offset=%v whence=%v, (%v:)", t, fd, offset, whence, origin(2)) + } + n, err := unix.Seek(int(fd), int64(offset), int(whence)) + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return types.Off_t(n) +} + +// int utime(const char *filename, const struct utimbuf *times); +func Xutime(t *TLS, filename, times uintptr) int32 { + if __ccgo_strace { + trc("t=%v times=%v, (%v:)", t, times, origin(2)) + } + var a []unix.Timeval + if times != 0 { + a = make([]unix.Timeval, 2) + a[0].Sec = (*utime.Utimbuf)(unsafe.Pointer(times)).Factime + a[1].Sec = (*utime.Utimbuf)(unsafe.Pointer(times)).Fmodtime + } + if err := unix.Utimes(GoString(filename), a); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// unsigned int alarm(unsigned int seconds); +func Xalarm(t *TLS, seconds uint32) uint32 { + if __ccgo_strace { + trc("t=%v seconds=%v, (%v:)", t, seconds, origin(2)) + } + panic(todo("")) + // n, _, err := unix.Syscall(unix.SYS_ALARM, uintptr(seconds), 0, 0) + // if err != 0 { + // panic(todo("")) + // } + + // return uint32(n) +} + +// time_t time(time_t *tloc); +func Xtime(t *TLS, tloc uintptr) types.Time_t { + if __ccgo_strace { + trc("t=%v tloc=%v, (%v:)", t, tloc, origin(2)) + } + n := time.Now().UTC().Unix() + if tloc != 0 { + *(*types.Time_t)(unsafe.Pointer(tloc)) = types.Time_t(n) + } + return types.Time_t(n) +} + +// // int getrlimit(int resource, struct rlimit *rlim); +// func Xgetrlimit64(t *TLS, resource int32, rlim uintptr) int32 { +// if _, _, err := unix.Syscall(unix.SYS_GETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 { +// t.setErrno(err) +// return -1 +// } +// +// return 0 +// } + +// int mkdir(const char *path, mode_t mode); +func Xmkdir(t *TLS, path uintptr, mode types.Mode_t) int32 { + if __ccgo_strace { + trc("t=%v path=%v mode=%v, (%v:)", t, path, mode, origin(2)) + } + if err := unix.Mkdir(GoString(path), uint32(mode)); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(path)) + } + return 0 +} + +// int symlink(const char *target, const char *linkpath); +func Xsymlink(t *TLS, target, linkpath uintptr) int32 { + if __ccgo_strace { + trc("t=%v linkpath=%v, (%v:)", t, linkpath, origin(2)) + } + if err := unix.Symlink(GoString(target), GoString(linkpath)); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int chmod(const char *pathname, mode_t mode) +func Xchmod(t *TLS, pathname uintptr, mode types.Mode_t) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2)) + } + if err := unix.Chmod(GoString(pathname), uint32(mode)); err != nil { + if dmesgs { + dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode) + } + return 0 +} + +// int utimes(const char *filename, const struct timeval times[2]); +func Xutimes(t *TLS, filename, times uintptr) int32 { + if __ccgo_strace { + trc("t=%v times=%v, (%v:)", t, times, origin(2)) + } + var a []unix.Timeval + if times != 0 { + a = make([]unix.Timeval, 2) + a[0] = *(*unix.Timeval)(unsafe.Pointer(times)) + a[1] = *(*unix.Timeval)(unsafe.Pointer(times + unsafe.Sizeof(unix.Timeval{}))) + } + if err := unix.Utimes(GoString(filename), a); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int unlink(const char *pathname); +func Xunlink(t *TLS, pathname uintptr) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2)) + } + if err := unix.Unlink(GoString(pathname)); err != nil { + if dmesgs { + dmesg("%v: %q: %v", origin(1), GoString(pathname), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int access(const char *pathname, int mode); +func Xaccess(t *TLS, pathname uintptr, mode int32) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2)) + } + if err := unix.Access(GoString(pathname), uint32(mode)); err != nil { + if dmesgs { + dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode) + } + return 0 +} + +// int rename(const char *oldpath, const char *newpath); +func Xrename(t *TLS, oldpath, newpath uintptr) int32 { + if __ccgo_strace { + trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2)) + } + if err := unix.Rename(GoString(oldpath), GoString(newpath)); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int mknod(const char *pathname, mode_t mode, dev_t dev); +func Xmknod(t *TLS, pathname uintptr, mode types.Mode_t, dev types.Dev_t) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v mode=%v dev=%v, (%v:)", t, pathname, mode, dev, origin(2)) + } + panic(todo("")) + // if _, _, err := unix.Syscall(unix.SYS_MKNOD, pathname, uintptr(mode), uintptr(dev)); err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return 0 +} + +// int chown(const char *pathname, uid_t owner, gid_t group); +func Xchown(t *TLS, pathname uintptr, owner types.Uid_t, group types.Gid_t) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v owner=%v group=%v, (%v:)", t, pathname, owner, group, origin(2)) + } + panic(todo("")) + // if _, _, err := unix.Syscall(unix.SYS_CHOWN, pathname, uintptr(owner), uintptr(group)); err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return 0 +} + +// int link(const char *oldpath, const char *newpath); +func Xlink(t *TLS, oldpath, newpath uintptr) int32 { + if __ccgo_strace { + trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2)) + } + panic(todo("")) + // if _, _, err := unix.Syscall(unix.SYS_LINK, oldpath, newpath, 0); err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return 0 +} + +// int dup2(int oldfd, int newfd); +func Xdup2(t *TLS, oldfd, newfd int32) int32 { + if __ccgo_strace { + trc("t=%v newfd=%v, (%v:)", t, newfd, origin(2)) + } + n, _, err := unix.Syscall(unix.SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if err != 0 { + t.setErrno(err) + return -1 + } + + return int32(n) +} + +// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize); +func Xreadlink(t *TLS, path, buf uintptr, bufsize types.Size_t) types.Ssize_t { + if __ccgo_strace { + trc("t=%v buf=%v bufsize=%v, (%v:)", t, buf, bufsize, origin(2)) + } + var n int + var err error + switch { + case buf == 0 || bufsize == 0: + n, err = unix.Readlink(GoString(path), nil) + default: + n, err = unix.Readlink(GoString(path), (*RawMem)(unsafe.Pointer(buf))[:bufsize:bufsize]) + } + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok") + } + return types.Ssize_t(n) +} + +// FILE *fopen64(const char *pathname, const char *mode); +func Xfopen64(t *TLS, pathname, mode uintptr) uintptr { + if __ccgo_strace { + trc("t=%v mode=%v, (%v:)", t, mode, origin(2)) + } + m := strings.ReplaceAll(GoString(mode), "b", "") + var flags int + switch m { + case "r": + flags = fcntl.O_RDONLY + case "r+": + flags = fcntl.O_RDWR + case "w": + flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_TRUNC + case "w+": + flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_TRUNC + case "a": + flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_APPEND + case "a+": + flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_APPEND + default: + panic(m) + } + fd, err := unix.Open(GoString(pathname), int(flags), 0666) + if err != nil { + if dmesgs { + dmesg("%v: %q %q: %v FAIL", origin(1), GoString(pathname), GoString(mode), err) + } + t.setErrno(err) + return 0 + } + + if dmesgs { + dmesg("%v: %q %q: fd %v", origin(1), GoString(pathname), GoString(mode), fd) + } + if p := newFile(t, int32(fd)); p != 0 { + return p + } + + panic("OOM") +} + +func Xrewinddir(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + Xfseek(tls, f, 0, stdio.SEEK_SET) +} diff --git a/internal/libc/libc_darwin_arm64.go b/internal/libc/libc_darwin_arm64.go new file mode 100644 index 0000000..aa3be94 --- /dev/null +++ b/internal/libc/libc_darwin_arm64.go @@ -0,0 +1,536 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "strings" + "time" + "unsafe" + + "golang.org/x/sys/unix" + "github.com/hanzoai/sqlite/internal/libc/fcntl" + "github.com/hanzoai/sqlite/internal/libc/signal" + "github.com/hanzoai/sqlite/internal/libc/stdio" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/libc/utime" +) + +// #define FE_UPWARD 0x00400000 +// #define FE_DOWNWARD 0x00800000 +const FE_UPWARD = 0x00400000 +const FE_DOWNWARD = 0x00800000 + +// int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); +func Xsigaction(t *TLS, signum int32, act, oldact uintptr) int32 { + if __ccgo_strace { + trc("t=%v signum=%v oldact=%v, (%v:)", t, signum, oldact, origin(2)) + } + var kact, koldact uintptr + if act != 0 { + sz := int(unsafe.Sizeof(signal.X__sigaction{})) + kact = t.Alloc(sz) + defer t.Free(sz) + (*signal.X__sigaction)(unsafe.Pointer(kact)).F__sigaction_u.F__sa_handler = (*signal.Sigaction)(unsafe.Pointer(act)).F__sigaction_u.F__sa_handler + (*signal.X__sigaction)(unsafe.Pointer(kact)).Fsa_flags = (*signal.Sigaction)(unsafe.Pointer(act)).Fsa_flags + Xmemcpy(t, kact+unsafe.Offsetof(signal.X__sigaction{}.Fsa_mask), act+unsafe.Offsetof(signal.Sigaction{}.Fsa_mask), types.Size_t(unsafe.Sizeof(signal.Sigset_t(0)))) + } + if oldact != 0 { + panic(todo("")) + } + + if _, _, err := unix.Syscall6(unix.SYS_SIGACTION, uintptr(signum), kact, koldact, unsafe.Sizeof(signal.Sigset_t(0)), 0, 0); err != 0 { + t.setErrno(err) + return -1 + } + + if oldact != 0 { + panic(todo("")) + } + + return 0 +} + +// int fcntl(int fd, int cmd, ... /* arg */ ); +func Xfcntl64(t *TLS, fd, cmd int32, args uintptr) (r int32) { + if __ccgo_strace { + trc("t=%v cmd=%v args=%v, (%v:)", t, cmd, args, origin(2)) + defer func() { trc("-> %v", r) }() + } + var err error + var p uintptr + var i int + switch cmd { + case fcntl.F_GETLK, fcntl.F_SETLK, fcntl.F_SETLKW: + p = *(*uintptr)(unsafe.Pointer(args)) + err = unix.FcntlFlock(uintptr(fd), int(cmd), (*unix.Flock_t)(unsafe.Pointer(p))) + case fcntl.F_GETFL, fcntl.F_FULLFSYNC: + i, err = unix.FcntlInt(uintptr(fd), int(cmd), 0) + r = int32(i) + case fcntl.F_SETFD, fcntl.F_SETFL: + arg := *(*int32)(unsafe.Pointer(args)) + _, err = unix.FcntlInt(uintptr(fd), int(cmd), int(arg)) + default: + panic(todo("%v: %v %v", origin(1), fd, cmd)) + } + if err != nil { + if dmesgs { + dmesg("%v: fd %v cmd %v p %#x: %v FAIL", origin(1), fcntlCmdStr(fd), cmd, p, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %d %s %#x: ok", origin(1), fd, fcntlCmdStr(cmd), p) + } + return r +} + +// int lstat(const char *pathname, struct stat *statbuf); +func Xlstat64(t *TLS, pathname, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2)) + } + if err := unix.Lstat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(pathname)) + } + return 0 +} + +// int stat(const char *pathname, struct stat *statbuf); +func Xstat64(t *TLS, pathname, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v statbuf=%v, (%v:)", t, statbuf, origin(2)) + } + if err := unix.Stat(GoString(pathname), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(pathname), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(pathname)) + } + return 0 +} + +// int fstatfs(int fd, struct statfs *buf); +func Xfstatfs(t *TLS, fd int32, buf uintptr) int32 { + if __ccgo_strace { + trc("t=%v fd=%v buf=%v, (%v:)", t, fd, buf, origin(2)) + } + if err := unix.Fstatfs(int(fd), (*unix.Statfs_t)(unsafe.Pointer(buf))); err != nil { + if dmesgs { + dmesg("%v: %v: %v FAIL", origin(1), fd, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %v: ok", origin(1), fd) + } + return 0 +} + +// int statfs(const char *path, struct statfs *buf); +func Xstatfs(t *TLS, path uintptr, buf uintptr) int32 { + if __ccgo_strace { + trc("t=%v path=%v buf=%v, (%v:)", t, path, buf, origin(2)) + } + if err := unix.Statfs(GoString(path), (*unix.Statfs_t)(unsafe.Pointer(buf))); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(path)) + } + return 0 +} + +// int fstat(int fd, struct stat *statbuf); +func Xfstat64(t *TLS, fd int32, statbuf uintptr) int32 { + if __ccgo_strace { + trc("t=%v fd=%v statbuf=%v, (%v:)", t, fd, statbuf, origin(2)) + } + if err := unix.Fstat(int(fd), (*unix.Stat_t)(unsafe.Pointer(statbuf))); err != nil { + if dmesgs { + dmesg("%v: fd %d: %v FAIL", origin(1), fd, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: fd %d: ok", origin(1), fd) + } + return 0 +} + +// off64_t lseek64(int fd, off64_t offset, int whence); +func Xlseek64(t *TLS, fd int32, offset types.Off_t, whence int32) types.Off_t { + if __ccgo_strace { + trc("t=%v fd=%v offset=%v whence=%v, (%v:)", t, fd, offset, whence, origin(2)) + } + n, err := unix.Seek(int(fd), int64(offset), int(whence)) + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return types.Off_t(n) +} + +// int utime(const char *filename, const struct utimbuf *times); +func Xutime(t *TLS, filename, times uintptr) int32 { + if __ccgo_strace { + trc("t=%v times=%v, (%v:)", t, times, origin(2)) + } + var a []unix.Timeval + if times != 0 { + a = make([]unix.Timeval, 2) + a[0].Sec = (*utime.Utimbuf)(unsafe.Pointer(times)).Factime + a[1].Sec = (*utime.Utimbuf)(unsafe.Pointer(times)).Fmodtime + } + if err := unix.Utimes(GoString(filename), a); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// unsigned int alarm(unsigned int seconds); +func Xalarm(t *TLS, seconds uint32) uint32 { + if __ccgo_strace { + trc("t=%v seconds=%v, (%v:)", t, seconds, origin(2)) + } + panic(todo("")) + // n, _, err := unix.Syscall(unix.SYS_ALARM, uintptr(seconds), 0, 0) + // if err != 0 { + // panic(todo("")) + // } + + // return uint32(n) +} + +// time_t time(time_t *tloc); +func Xtime(t *TLS, tloc uintptr) types.Time_t { + if __ccgo_strace { + trc("t=%v tloc=%v, (%v:)", t, tloc, origin(2)) + } + n := time.Now().UTC().Unix() + if tloc != 0 { + *(*types.Time_t)(unsafe.Pointer(tloc)) = types.Time_t(n) + } + return types.Time_t(n) +} + +// // int getrlimit(int resource, struct rlimit *rlim); +// func Xgetrlimit64(t *TLS, resource int32, rlim uintptr) int32 { +// if _, _, err := unix.Syscall(unix.SYS_GETRLIMIT, uintptr(resource), uintptr(rlim), 0); err != 0 { +// t.setErrno(err) +// return -1 +// } +// +// return 0 +// } + +// int mkdir(const char *path, mode_t mode); +func Xmkdir(t *TLS, path uintptr, mode types.Mode_t) int32 { + if __ccgo_strace { + trc("t=%v path=%v mode=%v, (%v:)", t, path, mode, origin(2)) + } + if err := unix.Mkdir(GoString(path), uint32(mode)); err != nil { + if dmesgs { + dmesg("%v: %q: %v FAIL", origin(1), GoString(path), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q: ok", origin(1), GoString(path)) + } + return 0 +} + +// int symlink(const char *target, const char *linkpath); +func Xsymlink(t *TLS, target, linkpath uintptr) int32 { + if __ccgo_strace { + trc("t=%v linkpath=%v, (%v:)", t, linkpath, origin(2)) + } + if err := unix.Symlink(GoString(target), GoString(linkpath)); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int chmod(const char *pathname, mode_t mode) +func Xchmod(t *TLS, pathname uintptr, mode types.Mode_t) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2)) + } + if err := unix.Chmod(GoString(pathname), uint32(mode)); err != nil { + if dmesgs { + dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode) + } + return 0 +} + +// int utimes(const char *filename, const struct timeval times[2]); +func Xutimes(t *TLS, filename, times uintptr) int32 { + if __ccgo_strace { + trc("t=%v times=%v, (%v:)", t, times, origin(2)) + } + var a []unix.Timeval + if times != 0 { + a = make([]unix.Timeval, 2) + a[0] = *(*unix.Timeval)(unsafe.Pointer(times)) + a[1] = *(*unix.Timeval)(unsafe.Pointer(times + unsafe.Sizeof(unix.Timeval{}))) + } + if err := unix.Utimes(GoString(filename), a); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int unlink(const char *pathname); +func Xunlink(t *TLS, pathname uintptr) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2)) + } + if err := unix.Unlink(GoString(pathname)); err != nil { + if dmesgs { + dmesg("%v: %q: %v", origin(1), GoString(pathname), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int access(const char *pathname, int mode); +func Xaccess(t *TLS, pathname uintptr, mode int32) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v mode=%v, (%v:)", t, pathname, mode, origin(2)) + } + if err := unix.Access(GoString(pathname), uint32(mode)); err != nil { + if dmesgs { + dmesg("%v: %q %#o: %v FAIL", origin(1), GoString(pathname), mode, err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: %q %#o: ok", origin(1), GoString(pathname), mode) + } + return 0 +} + +// int rename(const char *oldpath, const char *newpath); +func Xrename(t *TLS, oldpath, newpath uintptr) int32 { + if __ccgo_strace { + trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2)) + } + if err := unix.Rename(GoString(oldpath), GoString(newpath)); err != nil { + if dmesgs { + dmesg("%v: %v FAIL", origin(1), err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok", origin(1)) + } + return 0 +} + +// int mknod(const char *pathname, mode_t mode, dev_t dev); +func Xmknod(t *TLS, pathname uintptr, mode types.Mode_t, dev types.Dev_t) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v mode=%v dev=%v, (%v:)", t, pathname, mode, dev, origin(2)) + } + panic(todo("")) + // if _, _, err := unix.Syscall(unix.SYS_MKNOD, pathname, uintptr(mode), uintptr(dev)); err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return 0 +} + +// int chown(const char *pathname, uid_t owner, gid_t group); +func Xchown(t *TLS, pathname uintptr, owner types.Uid_t, group types.Gid_t) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v owner=%v group=%v, (%v:)", t, pathname, owner, group, origin(2)) + } + panic(todo("")) + // if _, _, err := unix.Syscall(unix.SYS_CHOWN, pathname, uintptr(owner), uintptr(group)); err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return 0 +} + +// int link(const char *oldpath, const char *newpath); +func Xlink(t *TLS, oldpath, newpath uintptr) int32 { + if __ccgo_strace { + trc("t=%v newpath=%v, (%v:)", t, newpath, origin(2)) + } + if _, _, err := unix.Syscall(unix.SYS_LINK, oldpath, newpath, 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int dup2(int oldfd, int newfd); +func Xdup2(t *TLS, oldfd, newfd int32) int32 { + if __ccgo_strace { + trc("t=%v newfd=%v, (%v:)", t, newfd, origin(2)) + } + panic(todo("")) + // n, _, err := unix.Syscall(unix.SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + // if err != 0 { + // t.setErrno(err) + // return -1 + // } + + // return int32(n) +} + +// ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize); +func Xreadlink(t *TLS, path, buf uintptr, bufsize types.Size_t) types.Ssize_t { + if __ccgo_strace { + trc("t=%v buf=%v bufsize=%v, (%v:)", t, buf, bufsize, origin(2)) + } + var n int + var err error + switch { + case buf == 0 || bufsize == 0: + n, err = unix.Readlink(GoString(path), nil) + default: + n, err = unix.Readlink(GoString(path), (*RawMem)(unsafe.Pointer(buf))[:bufsize:bufsize]) + } + if err != nil { + if dmesgs { + dmesg("%v: %v FAIL", err) + } + t.setErrno(err) + return -1 + } + + if dmesgs { + dmesg("%v: ok") + } + return types.Ssize_t(n) +} + +// FILE *fopen64(const char *pathname, const char *mode); +func Xfopen64(t *TLS, pathname, mode uintptr) uintptr { + if __ccgo_strace { + trc("t=%v mode=%v, (%v:)", t, mode, origin(2)) + } + m := strings.ReplaceAll(GoString(mode), "b", "") + var flags int + switch m { + case "r": + flags = fcntl.O_RDONLY + case "r+": + flags = fcntl.O_RDWR + case "w": + flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_TRUNC + case "w+": + flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_TRUNC + case "a": + flags = fcntl.O_WRONLY | fcntl.O_CREAT | fcntl.O_APPEND + case "a+": + flags = fcntl.O_RDWR | fcntl.O_CREAT | fcntl.O_APPEND + default: + panic(m) + } + fd, err := unix.Open(GoString(pathname), int(flags), 0666) + if err != nil { + if dmesgs { + dmesg("%v: %q %q: %v FAIL", origin(1), GoString(pathname), GoString(mode), err) + } + t.setErrno(err) + return 0 + } + + if dmesgs { + dmesg("%v: %q %q: fd %v", origin(1), GoString(pathname), GoString(mode), fd) + } + if p := newFile(t, int32(fd)); p != 0 { + return p + } + + panic("OOM") +} + +func Xrewinddir(tls *TLS, f uintptr) { + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + Xfseek(tls, f, 0, stdio.SEEK_SET) +} diff --git a/internal/libc/libc_linux.go b/internal/libc/libc_linux.go new file mode 100644 index 0000000..d0ab44a --- /dev/null +++ b/internal/libc/libc_linux.go @@ -0,0 +1,5 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" diff --git a/internal/libc/libc_linux_statfs.go b/internal/libc/libc_linux_statfs.go new file mode 100644 index 0000000..ed0747f --- /dev/null +++ b/internal/libc/libc_linux_statfs.go @@ -0,0 +1,13 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm || mips64le) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +// int statfs(const char *path, struct statfs *buf); +// Wrapper for ___statfs from ccgo-transpiled musl. +func Xstatfs(tls *TLS, path uintptr, buf uintptr) int32 { + return ___statfs(tls, path, buf) +} diff --git a/internal/libc/libc_musl.go b/internal/libc/libc_musl.go new file mode 100644 index 0000000..e22e2da --- /dev/null +++ b/internal/libc/libc_musl.go @@ -0,0 +1,1119 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +//go:generate go run generator.go + +// Package libc is the runtime for programs generated by ccgo/v4 or later. +// +// # Version compatibility +// +// The API of this package, in particular the bits that directly support the +// ccgo compiler, may change in a way that is not backward compatible. If you +// have generated some Go code from C you should stick to the version of this +// package that you used at that time and was tested with your payload. The +// correct way to upgrade to a newer version of this package is to first +// recompile (C to Go) your code with a newer version of ccgo that depends on +// the new libc version. +// +// If you use C to Go translated code provided by others, stick to the version +// of libc that translated code shows in its go.mod file and do not upgrade the +// dependency just because a newer libc is tagged.Vgq +// +// This is if course unfortunate. However, it's somewhat similar to C code +// linked with a specific version of, say GNU libc. When such code asking for +// glibc5 is run on a system with glibc6, or vice versa, it will fail. +// +// As a particular example, if your project imports github.com/hanzoai/sqlite/internal/engine you +// should use the same libc version as seen in the go.mod file of the sqlite +// package. +// +// tl;dr: It is not always possible to fix ccgo bugs and/or improve performance +// of the ccgo transpiled code without occasionally making incompatible changes +// to this package. +// +// # Thread Local Storage +// +// A TLS instance represents a main thread or a thread created by +// Xpthread_create. A TLS instance is not safe for concurrent use by multiple +// goroutines. +// +// If a program starts the C main function, a TLS instance is created +// automatically and the goroutine entering main() is locked to the OS thread. +// The translated C code then may create other pthreads by calling +// Xpthread_create. +// +// If the translated C code is part of a library package, new TLS instances +// must be created manually in user/client code. The first TLS instance created +// will be the "main" libc thread, but it will be not locked to OS thread +// automatically. Any subsequently manually created TLS instances will call +// Xpthread_create, but without spawning a new goroutine. +// +// A manual call to Xpthread_create will create a new TLS instance automatically +// and spawn a new goroutine executing the thread function. + +// Package libc provides run time support for programs generated by the +// [ccgo] C to Go transpiler, version 4 or later. +// +// # Concurrency +// +// Many C libc functions are not thread safe. Such functions are not safe +// for concurrent use by multiple goroutines in the Go translation as well. +// +// # Thread Local Storage +// +// C threads are modeled as Go goroutines. Every such C thread, ie. a Go +// goroutine, must use its own Thread Local Storage instance implemented by the +// [TLS] type. +// +// # Signals +// +// Signal handling in translated C code is not coordinated with the Go runtime. +// This is probably the same as when running C code via CGo. +// +// # Environmental variables +// +// This package synchronizes its environ with the current Go environ lazily and +// only once. +// +// # libc API documentation copyright +// +// From [Linux man-pages Copyleft] +// +// Permission is granted to make and distribute verbatim copies of this +// manual provided the copyright notice and this permission notice are +// preserved on all copies. +// +// Permission is granted to copy and distribute modified versions of this +// manual under the conditions for verbatim copying, provided that the +// entire resulting derived work is distributed under the terms of a +// permission notice identical to this one. +// +// Since the Linux kernel and libraries are constantly changing, this +// manual page may be incorrect or out-of-date. The author(s) assume no +// responsibility for errors or omissions, or for damages resulting from +// the use of the information contained herein. The author(s) may not have +// taken the same level of care in the production of this manual, which is +// licensed free of charge, as they might when working professionally. +// +// Formatted or processed versions of this manual, if unaccompanied by the +// source, must acknowledge the copyright and authors of this work. +// +// [Linux man-pages Copyleft]: https://spdx.org/licenses/Linux-man-pages-copyleft.html +// [ccgo]: http://modernc.org/ccgo/v4 +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "fmt" + "io" + "math" + "math/rand" + "os" + "os/exec" + gosignal "os/signal" + "path/filepath" + "runtime" + "sort" + "strings" + "sync" + "sync/atomic" + "time" + "unsafe" + + guuid "github.com/google/uuid" + "golang.org/x/sys/unix" + "github.com/hanzoai/sqlite/internal/libc/uuid/uuid" + "github.com/hanzoai/sqlite/internal/memory" +) + +const ( + heapAlign = 16 + heapGuard = 16 +) + +var ( + _ error = (*MemAuditError)(nil) + + allocator memory.Allocator + allocatorMu sync.Mutex + + atExitMu sync.Mutex + atExit []func() + + tid atomic.Int32 // TLS Go ID + + Covered = map[uintptr]struct{}{} + CoveredC = map[string]struct{}{} + coverPCs [1]uintptr //TODO not concurrent safe +) + +func init() { + nm, err := os.Executable() + if err != nil { + return + } + + Xprogram_invocation_name = mustCString(nm) + Xprogram_invocation_short_name = mustCString(filepath.Base(nm)) + X__libc.Fpage_size = Tsize_t(os.Getpagesize()) +} + +// RawMem64 represents the biggest uint64 array the runtime can handle. +type RawMem64 [unsafe.Sizeof(RawMem{}) / unsafe.Sizeof(uint64(0))]uint64 + +type MemAuditError struct { + Caller string + Message string +} + +func (e *MemAuditError) Error() string { + return fmt.Sprintf("%s: %s", e.Caller, e.Message) +} + +// Start executes C's main. +func Start(main func(*TLS, int32, uintptr) int32) { + runtime.LockOSThread() + if isMemBrk { + defer func() { + trc("==== PANIC") + for _, v := range MemAudit() { + trc("", v.Error()) + } + }() + } + + tls := NewTLS() + Xexit(tls, main(tls, int32(len(os.Args)), mustAllocStrings(os.Args))) +} + +func mustAllocStrings(a []string) (r uintptr) { + nPtrs := len(a) + 1 + pPtrs := mustCalloc(Tsize_t(uintptr(nPtrs) * unsafe.Sizeof(uintptr(0)))) + ptrs := unsafe.Slice((*uintptr)(unsafe.Pointer(pPtrs)), nPtrs) + nBytes := 0 + for _, v := range a { + nBytes += len(v) + 1 + } + pBytes := mustCalloc(Tsize_t(nBytes)) + b := unsafe.Slice((*byte)(unsafe.Pointer(pBytes)), nBytes) + for i, v := range a { + copy(b, v) + b = b[len(v)+1:] + ptrs[i] = pBytes + pBytes += uintptr(len(v)) + 1 + } + return pPtrs +} + +func mustCString(s string) (r uintptr) { + n := len(s) + r = mustMalloc(Tsize_t(n + 1)) + copy(unsafe.Slice((*byte)(unsafe.Pointer(r)), n), s) + *(*byte)(unsafe.Pointer(r + uintptr(n))) = 0 + return r +} + +// CString returns a pointer to a zero-terminated version of s. The caller is +// responsible for freeing the allocated memory using Xfree. +func CString(s string) (uintptr, error) { + n := len(s) + p := Xmalloc(nil, Tsize_t(n)+1) + if p == 0 { + return 0, fmt.Errorf("CString: cannot allocate %d bytes", n+1) + } + + copy(unsafe.Slice((*byte)(unsafe.Pointer(p)), n), s) + *(*byte)(unsafe.Pointer(p + uintptr(n))) = 0 + return p, nil +} + +func mustMalloc(sz Tsize_t) (r uintptr) { + if r = Xmalloc(nil, sz); r != 0 || sz == 0 { + return r + } + + panic(todo("OOM")) +} + +func mustCalloc(sz Tsize_t) (r uintptr) { + if r := Xcalloc(nil, 1, sz); r != 0 || sz == 0 { + return r + } + + panic(todo("OOM")) +} + +type tlsStackSlot struct { + p uintptr + sz Tsize_t +} + +// TLS emulates thread local storage. TLS is not safe for concurrent use by +// multiple goroutines. +type TLS struct { + allocaStack []int + allocas []uintptr + jumpBuffers []uintptr + pendingSignals chan os.Signal + pthread uintptr // *t__pthread + pthreadCleanupItems []pthreadCleanupItem + pthreadKeyValues map[Tpthread_key_t]uintptr + sigHandlers map[int32]uintptr + sp int + stack []tlsStackSlot + + ID int32 + + checkSignals bool + ownsPthread bool +} + +var __ccgo_environOnce sync.Once + +// NewTLS returns a newly created TLS that must be eventually closed to prevent +// resource leaks. +func NewTLS() (r *TLS) { + id := tid.Add(1) + if id == 0 { + id = tid.Add(1) + } + __ccgo_environOnce.Do(func() { + Xenviron = mustAllocStrings(os.Environ()) + }) + pthread := mustMalloc(Tsize_t(unsafe.Sizeof(t__pthread{}))) + *(*t__pthread)(unsafe.Pointer(pthread)) = t__pthread{ + Flocale: uintptr(unsafe.Pointer(&X__libc.Fglobal_locale)), + Fself: pthread, + Ftid: id, + } + return &TLS{ + ID: id, + ownsPthread: true, + pthread: pthread, + sigHandlers: map[int32]uintptr{}, + } +} + +// StackSlots reports the number of tls stack slots currently in use. +func (tls *TLS) StackSlots() int { + return tls.sp +} + +// int *__errno_location(void) +func X__errno_location(tls *TLS) (r uintptr) { + return tls.pthread + unsafe.Offsetof(t__pthread{}.Ferrno_val) +} + +// int *__errno_location(void) +func X___errno_location(tls *TLS) (r uintptr) { + return X__errno_location(tls) +} + +func (tls *TLS) setErrno(n int32) { + if tls == nil { + return + } + + *(*int32)(unsafe.Pointer(X__errno_location(tls))) = n +} + +func (tls *TLS) String() string { + return fmt.Sprintf("TLS#%v pthread=%x", tls.ID, tls.pthread) +} + +// Alloc allocates n bytes in tls's local storage. Calls to Alloc() must be +// strictly paired with calls to TLS.Free on function exit. That also means any +// memory from Alloc must not be used after a function returns. +// +// The order matters. This is ok: +// +// p := tls.Alloc(11) +// q := tls.Alloc(22) +// tls.Free(22) +// // q is no more usable here. +// tls.Free(11) +// // p is no more usable here. +// +// This is not correct: +// +// tls.Alloc(11) +// tls.Alloc(22) +// tls.Free(11) +// tls.Free(22) +func (tls *TLS) Alloc(n0 int) (r uintptr) { + // shrink stats speedtest1 + // ----------------------------------------------------------------------------------------------- + // 0 total 2,544, nallocs 107,553,070, nmallocs 25, nreallocs 107,553,045 10.984s + // 1 total 2,544, nallocs 107,553,070, nmallocs 25, nreallocs 38,905,980 9.597s + // 2 total 2,616, nallocs 107,553,070, nmallocs 25, nreallocs 18,201,284 9.206s + // 3 total 2,624, nallocs 107,553,070, nmallocs 25, nreallocs 16,716,302 9.155s + // 4 total 2,624, nallocs 107,553,070, nmallocs 25, nreallocs 16,156,102 9.398s + // 8 total 3,408, nallocs 107,553,070, nmallocs 25, nreallocs 14,364,274 9.198s + // 16 total 3,976, nallocs 107,553,070, nmallocs 25, nreallocs 6,219,602 8.910s + // --------------------------------------------------------------------------------------------- + // 32 total 5,120, nallocs 107,553,070, nmallocs 25, nreallocs 1,089,037 8.836s + // --------------------------------------------------------------------------------------------- + // 64 total 6,520, nallocs 107,553,070, nmallocs 25, nreallocs 1,788 8.420s + // 128 total 8,848, nallocs 107,553,070, nmallocs 25, nreallocs 1,098 8.833s + // 256 total 8,848, nallocs 107,553,070, nmallocs 25, nreallocs 1,049 9.508s + // 512 total 33,336, nallocs 107,553,070, nmallocs 25, nreallocs 88 8.667s + // none total 33,336, nallocs 107,553,070, nmallocs 25, nreallocs 88 8.408s + const shrinkSegment = 32 + n := Tsize_t(n0) + if tls.sp < len(tls.stack) { + p := tls.stack[tls.sp].p + sz := tls.stack[tls.sp].sz + if sz >= n /* && sz <= shrinkSegment*n */ { + // Segment shrinking is nice to have but Tcl does some dirty hacks in coroutine + // handling that require stability of stack addresses, out of the C execution + // model. Disabled. + tls.sp++ + return p + } + + Xfree(tls, p) + r = mustMalloc(n) + tls.stack[tls.sp] = tlsStackSlot{p: r, sz: Xmalloc_usable_size(tls, r)} + tls.sp++ + return r + + } + + r = mustMalloc(n) + tls.stack = append(tls.stack, tlsStackSlot{p: r, sz: Xmalloc_usable_size(tls, r)}) + tls.sp++ + return r +} + +// Free manages memory of the preceding TLS.Alloc() +func (tls *TLS) Free(n int) { + //TODO shrink stacks if possible. Tcl is currently against. + tls.sp-- + if !tls.checkSignals { + return + } + + select { + case sig := <-tls.pendingSignals: + signum := int32(sig.(unix.Signal)) + h, ok := tls.sigHandlers[signum] + if !ok { + break + } + + switch h { + case SIG_DFL: + // nop + case SIG_IGN: + // nop + default: + (*(*func(*TLS, int32))(unsafe.Pointer(&struct{ uintptr }{h})))(tls, signum) + } + default: + // nop + } +} + +func (tls *TLS) alloca(n Tsize_t) (r uintptr) { + r = mustMalloc(n) + tls.allocas = append(tls.allocas, r) + return r +} + +// AllocaEntry must be called early on function entry when the function calls +// or may call alloca(3). +func (tls *TLS) AllocaEntry() { + tls.allocaStack = append(tls.allocaStack, len(tls.allocas)) +} + +// AllocaExit must be defer-called on function exit when the function calls or +// may call alloca(3). +func (tls *TLS) AllocaExit() { + n := len(tls.allocaStack) + x := tls.allocaStack[n-1] + tls.allocaStack = tls.allocaStack[:n-1] + for _, v := range tls.allocas[x:] { + Xfree(tls, v) + } + tls.allocas = tls.allocas[:x] +} + +func (tls *TLS) Close() { + defer func() { *tls = TLS{} }() + + for _, v := range tls.allocas { + Xfree(tls, v) + } + for _, v := range tls.stack /* shrink diabled[:tls.sp] */ { + Xfree(tls, v.p) + } + if tls.ownsPthread { + Xfree(tls, tls.pthread) + } +} + +func (tls *TLS) PushJumpBuffer(jb uintptr) { + tls.jumpBuffers = append(tls.jumpBuffers, jb) +} + +type LongjmpRetval int32 + +func (tls *TLS) PopJumpBuffer(jb uintptr) { + n := len(tls.jumpBuffers) + if n == 0 || tls.jumpBuffers[n-1] != jb { + panic(todo("unsupported setjmp/longjmp usage")) + } + + tls.jumpBuffers = tls.jumpBuffers[:n-1] +} + +func (tls *TLS) Longjmp(jb uintptr, val int32) { + tls.PopJumpBuffer(jb) + if val == 0 { + val = 1 + } + panic(LongjmpRetval(val)) +} + +// ============================================================================ + +func Xexit(tls *TLS, code int32) { + //TODO atexit finalizers + X__stdio_exit(tls) + for i := len(atExit) - 1; i >= 0; i-- { + atExit[i]() + } + atExitHandlersMu.Lock() + for i := len(atExitHandlers) - 1; i >= 0; i-- { + v := atExitHandlers[i] + (*(*func(*TLS))(unsafe.Pointer(&struct{ uintptr }{v})))(tls) + } + os.Exit(int(code)) +} + +func _exit(tls *TLS, code int32) { + Xexit(tls, code) +} + +var abort Tsigaction + +func Xabort(tls *TLS) { + X__libc_sigaction(tls, SIGABRT, uintptr(unsafe.Pointer(&abort)), 0) + unix.Kill(unix.Getpid(), unix.Signal(SIGABRT)) + panic(todo("unrechable")) +} + +type lock struct { + sync.Mutex + waiters int +} + +var ( + locksMu sync.Mutex + locks = map[uintptr]*lock{} +) + +/* + + T1 T2 + + lock(&foo) // foo: 0 -> 1 + + lock(&foo) // foo: 1 -> 2 + + unlock(&foo) // foo: 2 -> 1, non zero means waiter(s) active + + unlock(&foo) // foo: 1 -> 0 + +*/ + +func ___lock(tls *TLS, p uintptr) { + if atomic.AddInt32((*int32)(unsafe.Pointer(p)), 1) == 1 { + return + } + + // foo was already acquired by some other C thread. + locksMu.Lock() + l := locks[p] + if l == nil { + l = &lock{} + locks[p] = l + l.Lock() + } + l.waiters++ + locksMu.Unlock() + l.Lock() // Wait for T1 to release foo. (X below) +} + +func ___unlock(tls *TLS, p uintptr) { + if atomic.AddInt32((*int32)(unsafe.Pointer(p)), -1) == 0 { + return + } + + // Some other C thread is waiting for foo. + locksMu.Lock() + l := locks[p] + if l == nil { + // We are T1 and we got the locksMu locked before T2. + l = &lock{waiters: 1} + l.Lock() + } + l.Unlock() // Release foo, T2 may now lock it. (X above) + l.waiters-- + if l.waiters == 0 { // we are T2 + delete(locks, p) + } + locksMu.Unlock() +} + +type lockedFile struct { + ch chan struct{} + waiters int +} + +var ( + lockedFilesMu sync.Mutex + lockedFiles = map[uintptr]*lockedFile{} +) + +func X__lockfile(tls *TLS, file uintptr) int32 { + return ___lockfile(tls, file) +} + +// int __lockfile(FILE *f) +func ___lockfile(tls *TLS, file uintptr) int32 { + panic(todo("")) + // lockedFilesMu.Lock() + + // defer lockedFilesMu.Unlock() + + // l := lockedFiles[file] + // if l == nil { + // l = &lockedFile{ch: make(chan struct{}, 1)} + // lockedFiles[file] = l + // } + + // l.waiters++ + // l.ch <- struct{}{} +} + +func X__unlockfile(tls *TLS, file uintptr) { + ___unlockfile(tls, file) +} + +// void __unlockfile(FILE *f) +func ___unlockfile(tls *TLS, file uintptr) { + panic(todo("")) + lockedFilesMu.Lock() + + defer lockedFilesMu.Unlock() + + l := lockedFiles[file] + l.waiters-- + if l.waiters == 0 { + delete(lockedFiles, file) + } + <-l.ch +} + +// void __synccall(void (*func)(void *), void *ctx) +func ___synccall(tls *TLS, fn, ctx uintptr) { + (*(*func(*TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{fn})))(tls, ctx) +} + +// func ___randname(tls *TLS, template uintptr) (r1 uintptr) { +// bp := tls.Alloc(16) +// defer tls.Free(16) +// var i int32 +// var r uint64 +// var _ /* ts at bp+0 */ Ttimespec +// X__clock_gettime(tls, CLOCK_REALTIME, bp) +// goto _2 +// _2: +// r = uint64((*(*Ttimespec)(unsafe.Pointer(bp))).Ftv_sec+(*(*Ttimespec)(unsafe.Pointer(bp))).Ftv_nsec) + uint64(tls.ID)*uint64(65537) +// i = 0 +// for { +// if !(i < int32(6)) { +// break +// } +// *(*int8)(unsafe.Pointer(template + uintptr(i))) = int8(uint64('A') + r&uint64(15) + r&uint64(16)*uint64(2)) +// goto _3 +// _3: +// i++ +// r >>= uint64(5) +// } +// return template +// } + +// #include +// #include +// #include "pthread_impl.h" +// +// /* This assumes that a check for the +// +// template size has already been made */ +// +// char *__randname(char *template) +// +// { +// int i; +// struct timespec ts; +// unsigned long r; +// +// __clock_gettime(CLOCK_REALTIME, &ts); +// r = ts.tv_sec + ts.tv_nsec + __pthread_self()->tid * 65537UL; +// for (i=0; i<6; i++, r>>=5) +// template[i] = 'A'+(r&15)+(r&16)*2; +// +// return template; +// } +func ___randname(tls *TLS, template uintptr) (r1 uintptr) { + var i int32 + ts := time.Now().UnixNano() + r := uint64(ts) + uint64(tls.ID)*65537 + i = 0 + for { + if !(i < int32(6)) { + break + } + *(*int8)(unsafe.Pointer(template + uintptr(i))) = int8(uint64('A') + r&uint64(15) + r&uint64(16)*uint64(2)) + goto _3 + _3: + i++ + r >>= uint64(5) + } + return template +} + +func ___get_tp(tls *TLS) uintptr { + return tls.pthread +} + +func Xfork(t *TLS) int32 { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + t.setErrno(ENOSYS) + return -1 +} + +const SIG_DFL = 0 +const SIG_IGN = 1 + +func Xsignal(tls *TLS, signum int32, handler uintptr) (r uintptr) { + r, tls.sigHandlers[signum] = tls.sigHandlers[signum], handler + switch handler { + case SIG_DFL: + gosignal.Reset(unix.Signal(signum)) + case SIG_IGN: + gosignal.Ignore(unix.Signal(signum)) + default: + if tls.pendingSignals == nil { + tls.pendingSignals = make(chan os.Signal, 3) + tls.checkSignals = true + } + gosignal.Notify(tls.pendingSignals, unix.Signal(signum)) + } + return r +} + +var ( + atExitHandlersMu sync.Mutex + atExitHandlers []uintptr +) + +func Xatexit(tls *TLS, func_ uintptr) (r int32) { + atExitHandlersMu.Lock() + atExitHandlers = append(atExitHandlers, func_) + atExitHandlersMu.Unlock() + return 0 +} + +var __sync_synchronize_dummy int32 + +// __sync_synchronize(); +func X__sync_synchronize(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + // Attempt to implement a full memory barrier without assembler. + atomic.StoreInt32(&__sync_synchronize_dummy, atomic.LoadInt32(&__sync_synchronize_dummy)+1) +} + +func Xdlopen(t *TLS, filename uintptr, flags int32) uintptr { + if __ccgo_strace { + trc("t=%v filename=%v flags=%v, (%v:)", t, filename, flags, origin(2)) + } + return 0 +} + +func Xdlsym(t *TLS, handle, symbol uintptr) uintptr { + if __ccgo_strace { + trc("t=%v symbol=%v, (%v:)", t, symbol, origin(2)) + } + return 0 +} + +var dlErrorMsg = []byte("not supported\x00") + +func Xdlerror(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return uintptr(unsafe.Pointer(&dlErrorMsg[0])) +} + +func Xdlclose(t *TLS, handle uintptr) int32 { + if __ccgo_strace { + trc("t=%v handle=%v, (%v:)", t, handle, origin(2)) + } + panic(todo("")) +} + +func Xsystem(t *TLS, command uintptr) int32 { + if __ccgo_strace { + trc("t=%v command=%v, (%v:)", t, command, origin(2)) + } + s := GoString(command) + if command == 0 { + panic(todo("")) + } + + cmd := exec.Command("sh", "-c", s) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + ps := err.(*exec.ExitError) + return int32(ps.ExitCode()) + } + + return 0 +} + +func Xsched_yield(tls *TLS) int32 { + runtime.Gosched() + return 0 +} + +// AtExit will attempt to run f at process exit. The execution cannot be +// guaranteed, neither its ordering with respect to any other handlers +// registered by AtExit. +func AtExit(f func()) { + atExitMu.Lock() + atExit = append(atExit, f) + atExitMu.Unlock() +} + +func Bool64(b bool) int64 { + if b { + return 1 + } + + return 0 +} + +func Environ() uintptr { + __ccgo_environOnce.Do(func() { + Xenviron = mustAllocStrings(os.Environ()) + }) + return Xenviron +} + +func EnvironP() uintptr { + __ccgo_environOnce.Do(func() { + Xenviron = mustAllocStrings(os.Environ()) + }) + return uintptr(unsafe.Pointer(&Xenviron)) +} + +// NewVaList is like VaList but automatically allocates the correct amount of +// memory for all of the items in args. +// +// The va_list return value is used to pass the constructed var args to var +// args accepting functions. The caller of NewVaList is responsible for freeing +// the va_list. +func NewVaList(args ...interface{}) (va_list uintptr) { + return VaList(NewVaListN(len(args)), args...) +} + +// NewVaListN returns a newly allocated va_list for n items. The caller of +// NewVaListN is responsible for freeing the va_list. +func NewVaListN(n int) (va_list uintptr) { + return Xmalloc(nil, Tsize_t(8*n)) +} + +func SetEnviron(t *TLS, env []string) { + __ccgo_environOnce.Do(func() { + Xenviron = mustAllocStrings(env) + }) +} + +func Dmesg(s string, args ...interface{}) { + // nop +} + +func Xalloca(tls *TLS, size Tsize_t) uintptr { + return tls.alloca(size) +} + +// struct cmsghdr *CMSG_NXTHDR(struct msghdr *msgh, struct cmsghdr *cmsg); +func X__cmsg_nxthdr(t *TLS, msgh, cmsg uintptr) uintptr { + panic(todo("")) +} + +func Cover() { + runtime.Callers(2, coverPCs[:]) + Covered[coverPCs[0]] = struct{}{} +} + +func CoverReport(w io.Writer) error { + var a []string + pcs := make([]uintptr, 1) + for pc := range Covered { + pcs[0] = pc + frame, _ := runtime.CallersFrames(pcs).Next() + a = append(a, fmt.Sprintf("%s:%07d:%s", filepath.Base(frame.File), frame.Line, frame.Func.Name())) + } + sort.Strings(a) + _, err := fmt.Fprintf(w, "%s\n", strings.Join(a, "\n")) + return err +} + +func CoverC(s string) { + CoveredC[s] = struct{}{} +} + +func CoverCReport(w io.Writer) error { + var a []string + for k := range CoveredC { + a = append(a, k) + } + sort.Strings(a) + _, err := fmt.Fprintf(w, "%s\n", strings.Join(a, "\n")) + return err +} + +func X__ccgo_dmesg(t *TLS, fmt uintptr, va uintptr) { + panic(todo("")) +} + +func X__ccgo_getMutexType(tls *TLS, m uintptr) int32 { /* pthread_mutex_lock.c:3:5: */ + panic(todo("")) +} + +func X__ccgo_in6addr_anyp(t *TLS) uintptr { + panic(todo("")) +} + +func X__ccgo_pthreadAttrGetDetachState(tls *TLS, a uintptr) int32 { /* pthread_attr_get.c:3:5: */ + panic(todo("")) +} + +func X__ccgo_pthreadMutexattrGettype(tls *TLS, a uintptr) int32 { /* pthread_attr_get.c:93:5: */ + panic(todo("")) +} + +// void sqlite3_log(int iErrCode, const char *zFormat, ...); +func X__ccgo_sqlite3_log(t *TLS, iErrCode int32, zFormat uintptr, args uintptr) { + // nop +} + +// unsigned __sync_add_and_fetch_uint32(*unsigned, unsigned) +func X__sync_add_and_fetch_uint32(t *TLS, p uintptr, v uint32) uint32 { + return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), v) +} + +// unsigned __sync_sub_and_fetch_uint32(*unsigned, unsigned) +func X__sync_sub_and_fetch_uint32(t *TLS, p uintptr, v uint32) uint32 { + return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), -v) +} + +var ( + randomData = map[uintptr]*rand.Rand{} + randomDataMu sync.Mutex +) + +// The initstate_r() function is like initstate(3) except that it initializes +// the state in the object pointed to by buf, rather than initializing the +// global state variable. Before calling this function, the buf.state field +// must be initialized to NULL. The initstate_r() function records a pointer +// to the statebuf argument inside the structure pointed to by buf. Thus, +// state‐ buf should not be deallocated so long as buf is still in use. (So, +// statebuf should typically be allocated as a static variable, or allocated on +// the heap using malloc(3) or similar.) +// +// char *initstate_r(unsigned int seed, char *statebuf, size_t statelen, struct random_data *buf); +func Xinitstate_r(t *TLS, seed uint32, statebuf uintptr, statelen Tsize_t, buf uintptr) int32 { + if buf == 0 { + panic(todo("")) + } + + randomDataMu.Lock() + + defer randomDataMu.Unlock() + + randomData[buf] = rand.New(rand.NewSource(int64(seed))) + return 0 +} + +// int random_r(struct random_data *buf, int32_t *result); +func Xrandom_r(t *TLS, buf, result uintptr) int32 { + randomDataMu.Lock() + + defer randomDataMu.Unlock() + + mr := randomData[buf] + if RAND_MAX != math.MaxInt32 { + panic(todo("")) + } + *(*int32)(unsafe.Pointer(result)) = mr.Int31() + return 0 +} + +// void longjmp(jmp_buf env, int val); +func Xlongjmp(t *TLS, env uintptr, val int32) { + panic(todo("")) +} + +// void _longjmp(jmp_buf env, int val); +func X_longjmp(t *TLS, env uintptr, val int32) { + panic(todo("")) +} + +// int _obstack_begin (struct obstack *h, _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment, void *(*chunkfun) (size_t), void (*freefun) (void *)) +func X_obstack_begin(t *TLS, obstack uintptr, size, alignment int32, chunkfun, freefun uintptr) int32 { + panic(todo("")) +} + +// extern void _obstack_newchunk(struct obstack *, int); +func X_obstack_newchunk(t *TLS, obstack uintptr, length int32) int32 { + panic(todo("")) +} + +// void obstack_free (struct obstack *h, void *obj) +func Xobstack_free(t *TLS, obstack, obj uintptr) { + panic(todo("")) +} + +// int obstack_vprintf (struct obstack *obstack, const char *template, va_list ap) +func Xobstack_vprintf(t *TLS, obstack, template, va uintptr) int32 { + panic(todo("")) +} + +// int _setjmp(jmp_buf env); +func X_setjmp(t *TLS, env uintptr) int32 { + return 0 //TODO +} + +// int setjmp(jmp_buf env); +func Xsetjmp(t *TLS, env uintptr) int32 { + panic(todo("")) +} + +// int backtrace(void **buffer, int size); +func Xbacktrace(t *TLS, buf uintptr, size int32) int32 { + panic(todo("")) +} + +// void backtrace_symbols_fd(void *const *buffer, int size, int fd); +func Xbacktrace_symbols_fd(t *TLS, buffer uintptr, size, fd int32) { + panic(todo("")) +} + +// int fts_close(FTS *ftsp); +func Xfts_close(t *TLS, ftsp uintptr) int32 { + panic(todo("")) +} + +// FTS *fts_open(char * const *path_argv, int options, int (*compar)(const FTSENT **, const FTSENT **)); +func Xfts_open(t *TLS, path_argv uintptr, options int32, compar uintptr) uintptr { + panic(todo("")) +} + +// FTSENT *fts_read(FTS *ftsp); +func Xfts64_read(t *TLS, ftsp uintptr) uintptr { + panic(todo("")) +} + +// int fts_close(FTS *ftsp); +func Xfts64_close(t *TLS, ftsp uintptr) int32 { + panic(todo("")) +} + +// FTS *fts_open(char * const *path_argv, int options, int (*compar)(const FTSENT **, const FTSENT **)); +func Xfts64_open(t *TLS, path_argv uintptr, options int32, compar uintptr) uintptr { + panic(todo("")) +} + +// FTSENT *fts_read(FTS *ftsp); +func Xfts_read(t *TLS, ftsp uintptr) uintptr { + panic(todo("")) +} + +// FILE *popen(const char *command, const char *type); +func Xpopen(t *TLS, command, type1 uintptr) uintptr { + panic(todo("")) +} + +// int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen); +func Xsysctlbyname(t *TLS, name, oldp, oldlenp, newp uintptr, newlen Tsize_t) int32 { + oldlen := *(*Tsize_t)(unsafe.Pointer(oldlenp)) + switch GoString(name) { + case "hw.ncpu": + if oldlen != 4 { + panic(todo("")) + } + + *(*int32)(unsafe.Pointer(oldp)) = int32(runtime.GOMAXPROCS(-1)) + return 0 + default: + t.setErrno(ENOENT) + return -1 + } +} + +// void uuid_copy(uuid_t dst, uuid_t src); +func Xuuid_copy(t *TLS, dst, src uintptr) { + if __ccgo_strace { + trc("t=%v src=%v, (%v:)", t, src, origin(2)) + } + *(*uuid.Uuid_t)(unsafe.Pointer(dst)) = *(*uuid.Uuid_t)(unsafe.Pointer(src)) +} + +// int uuid_parse( char *in, uuid_t uu); +func Xuuid_parse(t *TLS, in uintptr, uu uintptr) int32 { + if __ccgo_strace { + trc("t=%v in=%v uu=%v, (%v:)", t, in, uu, origin(2)) + } + r, err := guuid.Parse(GoString(in)) + if err != nil { + return -1 + } + + copy((*RawMem)(unsafe.Pointer(uu))[:unsafe.Sizeof(uuid.Uuid_t{})], r[:]) + return 0 +} + +// void uuid_generate_random(uuid_t out); +func Xuuid_generate_random(t *TLS, out uintptr) { + if __ccgo_strace { + trc("t=%v out=%v, (%v:)", t, out, origin(2)) + } + x := guuid.New() + copy((*RawMem)(unsafe.Pointer(out))[:], x[:]) +} + +// void uuid_unparse(uuid_t uu, char *out); +func Xuuid_unparse(t *TLS, uu, out uintptr) { + if __ccgo_strace { + trc("t=%v out=%v, (%v:)", t, out, origin(2)) + } + s := (*guuid.UUID)(unsafe.Pointer(uu)).String() + copy((*RawMem)(unsafe.Pointer(out))[:], s) + *(*byte)(unsafe.Pointer(out + uintptr(len(s)))) = 0 +} + +var Xzero_struct_address Taddress diff --git a/internal/libc/libc_musl_linux_amd64.go b/internal/libc/libc_musl_linux_amd64.go new file mode 100644 index 0000000..f9934b9 --- /dev/null +++ b/internal/libc/libc_musl_linux_amd64.go @@ -0,0 +1,29 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "golang.org/x/sys/unix" +) + +type long = int64 + +type ulong = uint64 + +// RawMem represents the biggest byte array the runtime can handle +type RawMem [1<<50 - 1]byte + +// int renameat2(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags); +func Xrenameat2(t *TLS, olddirfd int32, oldpath uintptr, newdirfd int32, newpath uintptr, flags int32) int32 { + if __ccgo_strace { + trc("t=%v olddirfd=%v oldpath=%v newdirfd=%v newpath=%v flags=%v, (%v:)", t, olddirfd, oldpath, newdirfd, newpath, flags, origin(2)) + } + if _, _, err := unix.Syscall6(unix.SYS_RENAMEAT2, uintptr(olddirfd), oldpath, uintptr(newdirfd), newpath, uintptr(flags), 0); err != 0 { + t.setErrno(int32(err)) + return -1 + } + + return 0 +} diff --git a/internal/libc/libc_musl_linux_arm64.go b/internal/libc/libc_musl_linux_arm64.go new file mode 100644 index 0000000..f9934b9 --- /dev/null +++ b/internal/libc/libc_musl_linux_arm64.go @@ -0,0 +1,29 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "golang.org/x/sys/unix" +) + +type long = int64 + +type ulong = uint64 + +// RawMem represents the biggest byte array the runtime can handle +type RawMem [1<<50 - 1]byte + +// int renameat2(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags); +func Xrenameat2(t *TLS, olddirfd int32, oldpath uintptr, newdirfd int32, newpath uintptr, flags int32) int32 { + if __ccgo_strace { + trc("t=%v olddirfd=%v oldpath=%v newdirfd=%v newpath=%v flags=%v, (%v:)", t, olddirfd, oldpath, newdirfd, newpath, flags, origin(2)) + } + if _, _, err := unix.Syscall6(unix.SYS_RENAMEAT2, uintptr(olddirfd), oldpath, uintptr(newdirfd), newpath, uintptr(flags), 0); err != 0 { + t.setErrno(int32(err)) + return -1 + } + + return 0 +} diff --git a/internal/libc/libc_unix.go b/internal/libc/libc_unix.go new file mode 100644 index 0000000..1f19ba0 --- /dev/null +++ b/internal/libc/libc_unix.go @@ -0,0 +1,1375 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix && !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "bufio" + // "encoding/hex" + "math" + "math/rand" + "os" + gosignal "os/signal" + "reflect" + "runtime" + "strconv" + "strings" + "sync" + "time" + "unsafe" + + guuid "github.com/google/uuid" + "github.com/ncruces/go-strftime" + "golang.org/x/sys/unix" + "github.com/hanzoai/sqlite/internal/libc/errno" + "github.com/hanzoai/sqlite/internal/libc/grp" + "github.com/hanzoai/sqlite/internal/libc/limits" + "github.com/hanzoai/sqlite/internal/libc/poll" + "github.com/hanzoai/sqlite/internal/libc/pwd" + "github.com/hanzoai/sqlite/internal/libc/signal" + "github.com/hanzoai/sqlite/internal/libc/stdio" + "github.com/hanzoai/sqlite/internal/libc/stdlib" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + ctime "github.com/hanzoai/sqlite/internal/libc/time" +) + +var staticGetpwnam pwd.Passwd + +func init() { + atExit = append(atExit, func() { closePasswd(&staticGetpwnam) }) +} + +var ( + signalCh chan os.Signal + signalTls *TLS + signalInit sync.Once +) + +func startSignalHandler() { + signalCh = make(chan os.Signal, 10) + signalTls = NewTLS() + go func() { + for sig := range signalCh { + if s, ok := sig.(unix.Signal); ok { + signum := int32(s) + signalsMu.Lock() + handler := signals[signum] + signalsMu.Unlock() + if handler != 0 && handler != signal.SIG_DFL && handler != signal.SIG_IGN { + var f func(*TLS, int32) + *(*uintptr)(unsafe.Pointer(&f)) = handler + f(signalTls, signum) + } + } + } + }() +} + +// sighandler_t signal(int signum, sighandler_t handler); +func Xsignal(t *TLS, signum int32, handler uintptr) uintptr { //TODO use sigaction? + if __ccgo_strace { + trc("t=%v signum=%v handler=%v, (%v:)", t, signum, handler, origin(2)) + } + signalInit.Do(startSignalHandler) + + signalsMu.Lock() + defer signalsMu.Unlock() + + r := signals[signum] + signals[signum] = handler + switch handler { + case signal.SIG_DFL: + gosignal.Reset(unix.Signal(signum)) + case signal.SIG_IGN: + gosignal.Ignore(unix.Signal(signum)) + default: + gosignal.Notify(signalCh, unix.Signal(signum)) + } + return r +} + +// void rewind(FILE *stream); +func Xrewind(t *TLS, stream uintptr) { + if __ccgo_strace { + trc("t=%v stream=%v, (%v:)", t, stream, origin(2)) + } + Xfseek(t, stream, 0, stdio.SEEK_SET) +} + +// int putchar(int c); +func Xputchar(t *TLS, c int32) int32 { + if __ccgo_strace { + trc("t=%v c=%v, (%v:)", t, c, origin(2)) + } + if _, err := write([]byte{byte(c)}); err != nil { + return stdio.EOF + } + + return int32(c) +} + +// int gethostname(char *name, size_t len); +func Xgethostname(t *TLS, name uintptr, slen types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v name=%v slen=%v, (%v:)", t, name, slen, origin(2)) + } + + if slen == 0 { + return 0 + } + + s, err := os.Hostname() + if err != nil { + panic(todo("")) + } + + n := len(s) + if len(s) >= int(slen) { + n = int(slen) - 1 + } + sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) + copy((*RawMem)(unsafe.Pointer(name))[:n:n], (*RawMem)(unsafe.Pointer(sh.Data))[:n:n]) + *(*byte)(unsafe.Pointer(name + uintptr(n))) = 0 + return 0 +} + +// int remove(const char *pathname); +func Xremove(t *TLS, pathname uintptr) int32 { + if __ccgo_strace { + trc("t=%v pathname=%v, (%v:)", t, pathname, origin(2)) + } + if err := os.Remove(GoString(pathname)); err != nil { + t.setErrno(err) + return -1 + } + return 0 +} + +// long pathconf(const char *path, int name); +func Xpathconf(t *TLS, path uintptr, name int32) long { + if __ccgo_strace { + trc("t=%v path=%v name=%v, (%v:)", t, path, name, origin(2)) + } + panic(todo("")) +} + +// ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); +func Xrecvfrom(t *TLS, sockfd int32, buf uintptr, len types.Size_t, flags int32, src_addr, addrlen uintptr) types.Ssize_t { + if __ccgo_strace { + trc("t=%v sockfd=%v buf=%v len=%v flags=%v addrlen=%v, (%v:)", t, sockfd, buf, len, flags, addrlen, origin(2)) + } + panic(todo("")) +} + +// ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); +func Xsendto(t *TLS, sockfd int32, buf uintptr, len types.Size_t, flags int32, src_addr uintptr, addrlen socklen_t) types.Ssize_t { + if __ccgo_strace { + trc("t=%v sockfd=%v buf=%v len=%v flags=%v src_addr=%v addrlen=%v, (%v:)", t, sockfd, buf, len, flags, src_addr, addrlen, origin(2)) + } + panic(todo("")) +} + +// void srand48(long int seedval); +func Xsrand48(t *TLS, seedval long) { + if __ccgo_strace { + trc("t=%v seedval=%v, (%v:)", t, seedval, origin(2)) + } + panic(todo("")) +} + +// long int lrand48(void); +func Xlrand48(t *TLS) long { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) +} + +// ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags); +func Xsendmsg(t *TLS, sockfd int32, msg uintptr, flags int32) types.Ssize_t { + if __ccgo_strace { + trc("t=%v sockfd=%v msg=%v flags=%v, (%v:)", t, sockfd, msg, flags, origin(2)) + } + panic(todo("")) +} + +// int poll(struct pollfd *fds, nfds_t nfds, int timeout); +func Xpoll(t *TLS, fds uintptr, nfds poll.Nfds_t, timeout int32) int32 { + if __ccgo_strace { + trc("t=%v fds=%v nfds=%v timeout=%v, (%v:)", t, fds, nfds, timeout, origin(2)) + } + if nfds == 0 { + panic(todo("")) + } + + // if dmesgs { + // dmesg("%v: %#x %v %v, %+v", origin(1), fds, nfds, timeout, (*[1000]unix.PollFd)(unsafe.Pointer(fds))[:nfds:nfds]) + // } + n, err := unix.Poll((*[1000]unix.PollFd)(unsafe.Pointer(fds))[:nfds:nfds], int(timeout)) + // if dmesgs { + // dmesg("%v: %v %v", origin(1), n, err) + // } + if err != nil { + t.setErrno(err) + return -1 + } + + return int32(n) +} + +// struct cmsghdr *CMSG_NXTHDR(struct msghdr *msgh, struct cmsghdr *cmsg); +func X__cmsg_nxthdr(t *TLS, msgh, cmsg uintptr) uintptr { + if __ccgo_strace { + trc("t=%v cmsg=%v, (%v:)", t, cmsg, origin(2)) + } + panic(todo("")) +} + +// wchar_t *wcschr(const wchar_t *wcs, wchar_t wc); +func Xwcschr(t *TLS, wcs uintptr, wc wchar_t) wchar_t { + if __ccgo_strace { + trc("t=%v wcs=%v wc=%v, (%v:)", t, wcs, wc, origin(2)) + } + panic(todo("")) +} + +// gid_t getegid(void); +func Xgetegid(t *TLS) types.Gid_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) +} + +// gid_t getgid(void); +func Xgetgid(t *TLS) types.Gid_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + panic(todo("")) +} + +// void *shmat(int shmid, const void *shmaddr, int shmflg); +func Xshmat(t *TLS, shmid int32, shmaddr uintptr, shmflg int32) uintptr { + if __ccgo_strace { + trc("t=%v shmid=%v shmaddr=%v shmflg=%v, (%v:)", t, shmid, shmaddr, shmflg, origin(2)) + } + panic(todo("")) +} + +// int shmctl(int shmid, int cmd, struct shmid_ds *buf); +func Xshmctl(t *TLS, shmid, cmd int32, buf uintptr) int32 { + if __ccgo_strace { + trc("t=%v cmd=%v buf=%v, (%v:)", t, cmd, buf, origin(2)) + } + panic(todo("")) +} + +// int shmdt(const void *shmaddr); +func Xshmdt(t *TLS, shmaddr uintptr) int32 { + if __ccgo_strace { + trc("t=%v shmaddr=%v, (%v:)", t, shmaddr, origin(2)) + } + panic(todo("")) +} + +// int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); +func Xgetresuid(t *TLS, ruid, euid, suid uintptr) int32 { + if __ccgo_strace { + trc("t=%v suid=%v, (%v:)", t, suid, origin(2)) + } + panic(todo("")) +} + +// int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); +func Xgetresgid(t *TLS, rgid, egid, sgid uintptr) int32 { + if __ccgo_strace { + trc("t=%v sgid=%v, (%v:)", t, sgid, origin(2)) + } + panic(todo("")) +} + +// FILE *tmpfile(void); +func Xtmpfile(t *TLS) uintptr { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + f, err := os.CreateTemp("", "tmpfile-") + if err != nil { + t.setErrno(err) + return 0 + } + + cf := newFile(t, int32(f.Fd())) + AtExit(func() { + nm := f.Name() + file(cf).close(t) + os.Remove(nm) + }) + + return cf +} + +// FILE *fdopen(int fd, const char *mode); +func Xfdopen(t *TLS, fd int32, mode uintptr) uintptr { + if __ccgo_strace { + trc("t=%v fd=%v mode=%v, (%v:)", t, fd, GoString(mode), origin(2)) + } + m := strings.ReplaceAll(GoString(mode), "b", "") + switch m { + case + "a", + "a+", + "r", + "r+", + "w", + "w+": + default: + t.setErrno(errno.EINVAL) + return 0 + } + + p := newFile(t, fd) + if p == 0 { + t.setErrno(errno.EINVAL) + return 0 + } + return p +} + +// struct passwd *getpwnam(const char *name); +func Xgetpwnam(t *TLS, name uintptr) uintptr { + if __ccgo_strace { + trc("t=%v name=%v, (%v:)", t, name, origin(2)) + } + f, err := os.Open("/etc/passwd") + if err != nil { + panic(todo("", err)) + } + + defer f.Close() + + sname := GoString(name) + sc := bufio.NewScanner(f) + for sc.Scan() { + s := strings.TrimSpace(sc.Text()) + if s == "" || strings.HasPrefix(s, "#") { + continue + } + + // eg. "root:x:0:0:root:/root:/bin/bash" + a := strings.Split(s, ":") + if len(a) < 7 { + panic(todo("")) + } + + if a[0] == sname { + uid, err := strconv.Atoi(a[2]) + if err != nil { + panic(todo("")) + } + + gid, err := strconv.Atoi(a[3]) + if err != nil { + panic(todo("")) + } + + closePasswd(&staticGetpwnam) + gecos := a[4] + if strings.Contains(gecos, ",") { + a := strings.Split(gecos, ",") + gecos = a[0] + } + initPasswd(t, &staticGetpwnam, a[0], a[1], uint32(uid), uint32(gid), gecos, a[5], a[6]) + return uintptr(unsafe.Pointer(&staticGetpwnam)) + } + } + + if sc.Err() != nil { + panic(todo("")) + } + + return 0 +} + +// int getpwnam_r(char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result); +func Xgetpwnam_r(t *TLS, name, cpwd, buf uintptr, buflen types.Size_t, result uintptr) int32 { + if __ccgo_strace { + trc("t=%v buf=%v buflen=%v result=%v, (%v:)", t, buf, buflen, result, origin(2)) + } + f, err := os.Open("/etc/passwd") + if err != nil { + panic(todo("", err)) + } + + defer f.Close() + + sname := GoString(name) + sc := bufio.NewScanner(f) + for sc.Scan() { + s := strings.TrimSpace(sc.Text()) + if s == "" || strings.HasPrefix(s, "#") { + continue + } + + // eg. "root:x:0:0:root:/root:/bin/bash" + a := strings.Split(s, ":") + if len(a) < 7 { + panic(todo("%q", s)) + } + + if a[0] == sname { + uid, err := strconv.Atoi(a[2]) + if err != nil { + panic(todo("")) + } + + gid, err := strconv.Atoi(a[3]) + if err != nil { + panic(todo("")) + } + + gecos := a[4] + if strings.Contains(gecos, ",") { + a := strings.Split(gecos, ",") + gecos = a[0] + } + var v pwd.Passwd + if initPasswd2(t, buf, buflen, &v, a[0], a[1], uint32(uid), uint32(gid), gecos, a[5], a[6]) { + *(*pwd.Passwd)(unsafe.Pointer(cpwd)) = v + *(*uintptr)(unsafe.Pointer(result)) = cpwd + return 0 + } + + *(*uintptr)(unsafe.Pointer(result)) = 0 + return errno.ERANGE + } + } + + if sc.Err() != nil { + panic(todo("")) + } + + *(*uintptr)(unsafe.Pointer(result)) = 0 + return 0 +} + +func init() { + atExit = append(atExit, func() { closeGroup(&staticGetgrgid) }) +} + +var staticGetgrgid grp.Group + +// struct group *getgrgid(gid_t gid); +func Xgetgrgid(t *TLS, gid uint32) uintptr { + if __ccgo_strace { + trc("t=%v gid=%v, (%v:)", t, gid, origin(2)) + } + f, err := os.Open("/etc/group") + if err != nil { + panic(todo("")) + } + + defer f.Close() + + sid := strconv.Itoa(int(gid)) + sc := bufio.NewScanner(f) + for sc.Scan() { + s := strings.TrimSpace(sc.Text()) + if s == "" || strings.HasPrefix(s, "#") { + continue + } + + // eg. "root:x:0:" + a := strings.Split(s, ":") + if len(a) < 4 { + panic(todo("%q", s)) + } + + if a[2] == sid { + closeGroup(&staticGetgrgid) + var names []string + if a[3] != "" { + names = strings.Split(a[3], ",") + } + initGroup(t, &staticGetgrgid, a[0], a[1], gid, names) + return uintptr(unsafe.Pointer(&staticGetgrgid)) + } + } + + if sc.Err() != nil { + panic(todo("")) + } + + return 0 +} + +// int getgrgid_r(gid_t gid, struct group *grp, char *buf, size_t buflen, struct group **result); +func Xgetgrgid_r(t *TLS, gid uint32, pGrp, buf uintptr, buflen types.Size_t, result uintptr) int32 { + if __ccgo_strace { + trc("t=%v gid=%v buf=%v buflen=%v result=%v, (%v:)", t, gid, buf, buflen, result, origin(2)) + } + f, err := os.Open("/etc/group") + if err != nil { + panic(todo("")) + } + + defer f.Close() + + sid := strconv.Itoa(int(gid)) + sc := bufio.NewScanner(f) + for sc.Scan() { + s := strings.TrimSpace(sc.Text()) + if s == "" || strings.HasPrefix(s, "#") { + continue + } + + // eg. "root:x:0:" + a := strings.Split(s, ":") + if len(a) < 4 { + panic(todo("%q", s)) + } + + if a[2] == sid { + var names []string + if a[3] != "" { + names = strings.Split(a[3], ",") + } + var x grp.Group + if initGroup2(buf, buflen, &x, a[0], a[1], gid, names) { + *(*grp.Group)(unsafe.Pointer(pGrp)) = x + *(*uintptr)(unsafe.Pointer(result)) = pGrp + return 0 + } + + *(*uintptr)(unsafe.Pointer(result)) = 0 + return 0 + } + } + + if sc.Err() != nil { + panic(todo("")) + } + + *(*uintptr)(unsafe.Pointer(result)) = 0 + return 0 +} + +func initPasswd2(t *TLS, buf uintptr, buflen types.Size_t, p *pwd.Passwd, name, pwd string, uid, gid uint32, gecos, dir, shell string) bool { + p.Fpw_name, buf, buflen = bufString(buf, buflen, name) + if buf == 0 { + return false + } + + p.Fpw_passwd, buf, buflen = bufString(buf, buflen, pwd) + if buf == 0 { + return false + } + + p.Fpw_uid = uid + p.Fpw_gid = gid + if buf == 0 { + return false + } + + p.Fpw_gecos, buf, buflen = bufString(buf, buflen, gecos) + if buf == 0 { + return false + } + + p.Fpw_dir, buf, buflen = bufString(buf, buflen, dir) + if buf == 0 { + return false + } + + p.Fpw_shell, buf, buflen = bufString(buf, buflen, shell) + return buf != 0 +} + +func bufString(buf uintptr, buflen types.Size_t, s string) (uintptr, uintptr, types.Size_t) { + buf0 := buf + rq := len(s) + 1 + if rq > int(buflen) { + return 0, 0, 0 + } + + copy((*RawMem)(unsafe.Pointer(buf))[:len(s):len(s)], s) + buf += uintptr(len(s)) + *(*byte)(unsafe.Pointer(buf)) = 0 + return buf0, buf + 1, buflen - types.Size_t(rq) +} + +func closeGroup(p *grp.Group) { + Xfree(nil, p.Fgr_name) + Xfree(nil, p.Fgr_passwd) + if p := p.Fgr_mem; p != 0 { + for { + q := *(*uintptr)(unsafe.Pointer(p)) + if q == 0 { + break + } + + Xfree(nil, q) + p += unsafe.Sizeof(uintptr(0)) + } + } + *p = grp.Group{} +} + +func initGroup(t *TLS, p *grp.Group, name, pwd string, gid uint32, names []string) { + p.Fgr_name = cString(t, name) + p.Fgr_passwd = cString(t, pwd) + p.Fgr_gid = gid + a := Xcalloc(t, 1, types.Size_t(unsafe.Sizeof(uintptr(0)))*types.Size_t((len(names)+1))) + if a == 0 { + panic("OOM") + } + + for p := a; len(names) != 0; p += unsafe.Sizeof(uintptr(0)) { + *(*uintptr)(unsafe.Pointer(p)) = cString(t, names[0]) + names = names[1:] + } + p.Fgr_mem = a +} + +func initGroup2(buf uintptr, buflen types.Size_t, p *grp.Group, name, pwd string, gid uint32, names []string) bool { + p.Fgr_name, buf, buflen = bufString(buf, buflen, name) + if buf == 0 { + return false + } + + p.Fgr_passwd, buf, buflen = bufString(buf, buflen, pwd) + if buf == 0 { + return false + } + + p.Fgr_gid = gid + rq := unsafe.Sizeof(uintptr(0)) * uintptr(len(names)+1) + if rq > uintptr(buflen) { + return false + } + + a := buf + buf += rq + for ; len(names) != 0; buf += unsafe.Sizeof(uintptr(0)) { + if len(names[0])+1 > int(buflen) { + return false + } + + *(*uintptr)(unsafe.Pointer(buf)), buf, buflen = bufString(buf, buflen, names[0]) + names = names[1:] + } + *(*uintptr)(unsafe.Pointer(buf)) = 0 + p.Fgr_mem = a + return true +} + +func init() { + atExit = append(atExit, func() { closeGroup(&staticGetgrgid) }) +} + +var staticGetpwuid pwd.Passwd + +func init() { + atExit = append(atExit, func() { closePasswd(&staticGetpwuid) }) +} + +func closePasswd(p *pwd.Passwd) { + Xfree(nil, p.Fpw_name) + Xfree(nil, p.Fpw_passwd) + Xfree(nil, p.Fpw_gecos) + Xfree(nil, p.Fpw_dir) + Xfree(nil, p.Fpw_shell) + *p = pwd.Passwd{} +} + +var staticGetgrnam grp.Group + +func init() { + atExit = append(atExit, func() { closeGroup(&staticGetgrnam) }) +} + +// struct passwd *getpwuid(uid_t uid); +func Xgetpwuid(t *TLS, uid uint32) uintptr { + if __ccgo_strace { + trc("t=%v uid=%v, (%v:)", t, uid, origin(2)) + } + f, err := os.Open("/etc/passwd") + if err != nil { + panic(todo("", err)) + } + + defer f.Close() + + sid := strconv.Itoa(int(uid)) + sc := bufio.NewScanner(f) + for sc.Scan() { + s := strings.TrimSpace(sc.Text()) + if len(s) == 0 || strings.HasPrefix(s, "#") { + continue + } + + // eg. "root:x:0:0:root:/root:/bin/bash" + a := strings.Split(s, ":") + if len(a) < 7 { + panic(todo("%q", s)) + } + + if a[2] == sid { + uid, err := strconv.Atoi(a[2]) + if err != nil { + panic(todo("")) + } + + gid, err := strconv.Atoi(a[3]) + if err != nil { + panic(todo("")) + } + + closePasswd(&staticGetpwuid) + gecos := a[4] + if strings.Contains(gecos, ",") { + a := strings.Split(gecos, ",") + gecos = a[0] + } + initPasswd(t, &staticGetpwuid, a[0], a[1], uint32(uid), uint32(gid), gecos, a[5], a[6]) + return uintptr(unsafe.Pointer(&staticGetpwuid)) + } + } + + if sc.Err() != nil { + panic(todo("")) + } + + return 0 +} + +func initPasswd(t *TLS, p *pwd.Passwd, name, pwd string, uid, gid uint32, gecos, dir, shell string) { + p.Fpw_name = cString(t, name) + p.Fpw_passwd = cString(t, pwd) + p.Fpw_uid = uid + p.Fpw_gid = gid + p.Fpw_gecos = cString(t, gecos) + p.Fpw_dir = cString(t, dir) + p.Fpw_shell = cString(t, shell) +} + +// struct group *getgrnam(const char *name); +func Xgetgrnam(t *TLS, name uintptr) uintptr { + if __ccgo_strace { + trc("t=%v name=%v, (%v:)", t, name, origin(2)) + } + f, err := os.Open("/etc/group") + if err != nil { + panic(todo("")) + } + + defer f.Close() + + sname := GoString(name) + sc := bufio.NewScanner(f) + for sc.Scan() { + s := strings.TrimSpace(sc.Text()) + if len(s) == 0 || strings.HasPrefix(s, "#") { + continue + } + + // eg. "root:x:0:" + a := strings.Split(s, ":") + if len(a) < 4 { + panic(todo("%q", s)) + } + + if a[0] == sname { + closeGroup(&staticGetgrnam) + gid, err := strconv.Atoi(a[2]) + if err != nil { + panic(todo("")) + } + + var names []string + if a[3] != "" { + names = strings.Split(a[3], ",") + } + initGroup(t, &staticGetgrnam, a[0], a[1], uint32(gid), names) + return uintptr(unsafe.Pointer(&staticGetgrnam)) + } + } + + if sc.Err() != nil { + panic(todo("")) + } + + return 0 +} + +// int getgrnam_r(const char *name, struct group *grp, char *buf, size_t buflen, struct group **result); +func Xgetgrnam_r(t *TLS, name, pGrp, buf uintptr, buflen types.Size_t, result uintptr) int32 { + if __ccgo_strace { + trc("t=%v buf=%v buflen=%v result=%v, (%v:)", t, buf, buflen, result, origin(2)) + } + f, err := os.Open("/etc/group") + if err != nil { + panic(todo("")) + } + + defer f.Close() + + sname := GoString(name) + sc := bufio.NewScanner(f) + for sc.Scan() { + s := strings.TrimSpace(sc.Text()) + if len(s) == 0 || strings.HasPrefix(s, "#") { + continue + } + + // eg. "root:x:0:" + a := strings.Split(s, ":") + if len(a) < 4 { + panic(todo("%q", s)) + } + + if a[0] == sname { + gid, err := strconv.Atoi(a[2]) + if err != nil { + panic(todo("")) + } + + var names []string + if a[3] != "" { + names = strings.Split(a[3], ",") + } + var x grp.Group + if initGroup2(buf, buflen, &x, a[0], a[1], uint32(gid), names) { + *(*grp.Group)(unsafe.Pointer(pGrp)) = x + *(*uintptr)(unsafe.Pointer(result)) = pGrp + return 0 + } + + *(*uintptr)(unsafe.Pointer(result)) = 0 + return 0 + } + } + + if sc.Err() != nil { + panic(todo("")) + } + + *(*uintptr)(unsafe.Pointer(result)) = 0 + return 0 +} + +// int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result); +func Xgetpwuid_r(t *TLS, uid types.Uid_t, cpwd, buf uintptr, buflen types.Size_t, result uintptr) int32 { + if __ccgo_strace { + trc("t=%v uid=%v buf=%v buflen=%v result=%v, (%v:)", t, uid, buf, buflen, result, origin(2)) + } + f, err := os.Open("/etc/passwd") + if err != nil { + panic(todo("", err)) + } + + defer f.Close() + + sid := strconv.Itoa(int(uid)) + sc := bufio.NewScanner(f) + for sc.Scan() { + s := strings.TrimSpace(sc.Text()) + if len(s) == 0 || strings.HasPrefix(s, "#") { + continue + } + + // eg. "root:x:0:0:root:/root:/bin/bash" + a := strings.Split(s, ":") + if len(a) < 7 { + panic(todo("%q", s)) + } + + if a[2] == sid { + uid, err := strconv.Atoi(a[2]) + if err != nil { + panic(todo("")) + } + + gid, err := strconv.Atoi(a[3]) + if err != nil { + panic(todo("")) + } + + gecos := a[4] + if strings.Contains(gecos, ",") { + a := strings.Split(gecos, ",") + gecos = a[0] + } + var v pwd.Passwd + if initPasswd2(t, buf, buflen, &v, a[0], a[1], uint32(uid), uint32(gid), gecos, a[5], a[6]) { + *(*pwd.Passwd)(unsafe.Pointer(cpwd)) = v + *(*uintptr)(unsafe.Pointer(result)) = cpwd + return 0 + } + + *(*uintptr)(unsafe.Pointer(result)) = 0 + return errno.ERANGE + } + } + + if sc.Err() != nil { + panic(todo("")) + } + + *(*uintptr)(unsafe.Pointer(result)) = 0 + return 0 +} + +// int mkostemp(char *template, int flags); +func Xmkostemp(t *TLS, template uintptr, flags int32) int32 { + if __ccgo_strace { + trc("t=%v template=%v flags=%v, (%v:)", t, template, flags, origin(2)) + } + len := uintptr(Xstrlen(t, template)) + x := template + uintptr(len-6) + for i := uintptr(0); i < 6; i++ { + if *(*byte)(unsafe.Pointer(x + i)) != 'X' { + t.setErrno(errno.EINVAL) + return -1 + } + } + + fd, err := tempFile(template, x, flags) + if err != nil { + t.setErrno(err) + return -1 + } + + return int32(fd) +} + +// void uuid_generate_random(uuid_t out); +func Xuuid_generate_random(t *TLS, out uintptr) { + if __ccgo_strace { + trc("t=%v out=%v, (%v:)", t, out, origin(2)) + } + x := guuid.New() + copy((*RawMem)(unsafe.Pointer(out))[:], x[:]) +} + +// void uuid_unparse(uuid_t uu, char *out); +func Xuuid_unparse(t *TLS, uu, out uintptr) { + if __ccgo_strace { + trc("t=%v out=%v, (%v:)", t, out, origin(2)) + } + s := (*guuid.UUID)(unsafe.Pointer(uu)).String() + copy((*RawMem)(unsafe.Pointer(out))[:], s) + *(*byte)(unsafe.Pointer(out + uintptr(len(s)))) = 0 +} + +// no longer used? +// var staticRandomData = &rand.Rand{} + +// char *initstate(unsigned seed, char *state, size_t size); +func Xinitstate(t *TLS, seed uint32, statebuf uintptr, statelen types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v seed=%v statebuf=%v statelen=%v, (%v:)", t, seed, statebuf, statelen, origin(2)) + } + // staticRandomData = rand.New(rand.NewSource(int64(seed))) + _ = rand.New(rand.NewSource(int64(seed))) + return 0 +} + +// char *setstate(const char *state); +func Xsetstate(t *TLS, state uintptr) uintptr { + if __ccgo_strace { + trc("t=%v state=%v, (%v:)", t, state, origin(2)) + } + t.setErrno(errno.EINVAL) //TODO + return 0 +} + +// The initstate_r() function is like initstate(3) except that it initializes +// the state in the object pointed to by buf, rather than initializing the +// global state variable. Before calling this function, the buf.state field +// must be initialized to NULL. The initstate_r() function records a pointer +// to the statebuf argument inside the structure pointed to by buf. Thus, +// state‐ buf should not be deallocated so long as buf is still in use. (So, +// statebuf should typically be allocated as a static variable, or allocated on +// the heap using malloc(3) or similar.) +// +// char *initstate_r(unsigned int seed, char *statebuf, size_t statelen, struct random_data *buf); +func Xinitstate_r(t *TLS, seed uint32, statebuf uintptr, statelen types.Size_t, buf uintptr) int32 { + if __ccgo_strace { + trc("t=%v seed=%v statebuf=%v statelen=%v buf=%v, (%v:)", t, seed, statebuf, statelen, buf, origin(2)) + } + if buf == 0 { + panic(todo("")) + } + + randomDataMu.Lock() + + defer randomDataMu.Unlock() + + randomData[buf] = rand.New(rand.NewSource(int64(seed))) + return 0 +} + +var ( + randomData = map[uintptr]*rand.Rand{} + randomDataMu sync.Mutex +) + +// int mkstemps(char *template, int suffixlen); +func Xmkstemps(t *TLS, template uintptr, suffixlen int32) int32 { + if __ccgo_strace { + trc("t=%v template=%v suffixlen=%v, (%v:)", t, template, suffixlen, origin(2)) + } + return Xmkstemps64(t, template, suffixlen) +} + +// int mkstemps(char *template, int suffixlen); +func Xmkstemps64(t *TLS, template uintptr, suffixlen int32) int32 { + if __ccgo_strace { + trc("t=%v template=%v suffixlen=%v, (%v:)", t, template, suffixlen, origin(2)) + } + len := uintptr(Xstrlen(t, template)) + x := template + uintptr(len-6) - uintptr(suffixlen) + for i := uintptr(0); i < 6; i++ { + if *(*byte)(unsafe.Pointer(x + i)) != 'X' { + t.setErrno(errno.EINVAL) + return -1 + } + } + + fd, err := tempFile(template, x, 0) + if err != nil { + t.setErrno(err) + return -1 + } + + return int32(fd) +} + +// int mkstemp(char *template); +func Xmkstemp(t *TLS, template uintptr) int32 { + if __ccgo_strace { + trc("t=%v template=%v, (%v:)", t, template, origin(2)) + } + return Xmkstemp64(t, template) +} + +// int mkstemp(char *template); +func Xmkstemp64(t *TLS, template uintptr) int32 { + if __ccgo_strace { + trc("t=%v template=%v, (%v:)", t, template, origin(2)) + } + return Xmkstemps64(t, template, 0) +} + +// int random_r(struct random_data *buf, int32_t *result); +func Xrandom_r(t *TLS, buf, result uintptr) int32 { + if __ccgo_strace { + trc("t=%v result=%v, (%v:)", t, result, origin(2)) + } + randomDataMu.Lock() + + defer randomDataMu.Unlock() + + mr := randomData[buf] + if stdlib.RAND_MAX != math.MaxInt32 { + panic(todo("")) + } + *(*int32)(unsafe.Pointer(result)) = mr.Int31() + return 0 +} + +// int strerror_r(int errnum, char *buf, size_t buflen); +func Xstrerror_r(t *TLS, errnum int32, buf uintptr, buflen size_t) int32 { + if __ccgo_strace { + trc("t=%v errnum=%v buf=%v buflen=%v, (%v:)", t, errnum, buf, buflen, origin(2)) + } + panic(todo("")) +} + +// void endpwent(void); +func Xendpwent(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + // nop +} + +var ctimeStaticBuf [32]byte + +// char *ctime(const time_t *timep); +func Xctime(t *TLS, timep uintptr) uintptr { + if __ccgo_strace { + trc("t=%v timep=%v, (%v:)", t, timep, origin(2)) + } + return Xctime_r(t, timep, uintptr(unsafe.Pointer(&ctimeStaticBuf[0]))) +} + +// char *ctime_r(const time_t *timep, char *buf); +func Xctime_r(t *TLS, timep, buf uintptr) uintptr { + if __ccgo_strace { + trc("t=%v buf=%v, (%v:)", t, buf, origin(2)) + } + ut := *(*ctime.Time_t)(unsafe.Pointer(timep)) + tm := time.Unix(int64(ut), 0).Local() + s := tm.Format(time.ANSIC) + "\n\x00" + copy((*RawMem)(unsafe.Pointer(buf))[:26:26], s) + return buf +} + +// ssize_t pread(int fd, void *buf, size_t count, off_t offset); +func Xpread(t *TLS, fd int32, buf uintptr, count types.Size_t, offset types.Off_t) types.Ssize_t { + if __ccgo_strace { + trc("t=%v fd=%v buf=%v count=%v offset=%v, (%v:)", t, fd, buf, count, offset, origin(2)) + } + var n int + var err error + switch { + case count == 0: + n, err = unix.Pread(int(fd), nil, int64(offset)) + default: + n, err = unix.Pread(int(fd), (*RawMem)(unsafe.Pointer(buf))[:count:count], int64(offset)) + // if dmesgs && err == nil { + // dmesg("%v: fd %v, off %#x, count %#x, n %#x\n%s", origin(1), fd, offset, count, n, hex.Dump((*RawMem)(unsafe.Pointer(buf))[:n:n])) + // } + } + if err != nil { + // if dmesgs { + // dmesg("%v: %v FAIL", origin(1), err) + // } + t.setErrno(err) + return -1 + } + + // if dmesgs { + // dmesg("%v: ok", origin(1)) + // } + return types.Ssize_t(n) +} + +// // malloc_zone_t * malloc_create_zone(vm_size_t start_size, unsigned flags); +// func Xmalloc_create_zone(t *TLS, start_size types.Size_t, flags uint32) uintptr { +// if __ccgo_strace { +// trc("t=%v start_size=%v flags=%v, (%v:)", t, start_size, flags, origin(2)) +// } +// panic(todo("")) +// } +// +// // void * malloc_zone_malloc(malloc_zone_t *zone, size_t size); +// func Xmalloc_zone_malloc(t *TLS, zone uintptr, size types.Size_t) uintptr { +// if __ccgo_strace { +// trc("t=%v zone=%v size=%v, (%v:)", t, zone, size, origin(2)) +// } +// if zone == defaultZone { +// return Xmalloc(t, size) +// } +// +// panic(todo("")) +// } +// +// // malloc_zone_t * malloc_default_zone(void); +// func Xmalloc_default_zone(t *TLS) uintptr { +// if __ccgo_strace { +// trc("t=%v (%v:)", t, origin(2)) +// } +// return defaultZone +// } +// +// // void malloc_zone_free(malloc_zone_t *zone, void *ptr); +// func Xmalloc_zone_free(t *TLS, zone, ptr uintptr) { +// if __ccgo_strace { +// trc("t=%v zone=%v ptr=%v, (%v:)", t, zone, ptr, origin(2)) +// } +// +// if zone == defaultZone { +// Xfree(t, ptr) +// return +// } +// +// panic(todo("")) +// } +// +// // void * malloc_zone_realloc(malloc_zone_t *zone, void *ptr, size_t size); +// func Xmalloc_zone_realloc(t *TLS, zone, ptr uintptr, size types.Size_t) uintptr { +// if __ccgo_strace { +// trc("t=%v zone=%v ptr=%v size=%v, (%v:)", t, zone, ptr, size, origin(2)) +// } +// panic(todo("")) +// } + +// int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen); +func Xsysctlbyname(t *TLS, name, oldp, oldlenp, newp uintptr, newlen types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v name=%q oldp=%#0x oldlenp=%v newp=%v newlen=%v, (%v:)", t, GoString(name), oldp, *(*types.Size_t)(unsafe.Pointer(oldlenp)), newp, newlen, origin(2)) + } + oldlen := *(*types.Size_t)(unsafe.Pointer(oldlenp)) + switch GoString(name) { + case "hw.ncpu": + if oldlen != 4 { + panic(todo("")) + } + + *(*int32)(unsafe.Pointer(oldp)) = int32(runtime.GOMAXPROCS(-1)) + return 0 + default: + t.setErrno(errno.ENOENT) + return -1 + } +} + +// type mallocZone struct { +// a memory.Allocator +// mu sync.Mutex +// +// isDefault bool +// } +// +// func newMallocZone(isDefault bool) *mallocZone { +// return &mallocZone{isDefault: isDefault} +// } +// +// var ( +// defaultZone uintptr +// ) +// +// func init() { +// defaultZone = addObject(newMallocZone(true)) +// } + +// /tmp/libc/musl-master/src/time/gmtime.c:6:19: +var _tm ctime.Tm + +// /tmp/libc/musl-master/src/time/gmtime.c:4:11: +func Xgmtime(tls *TLS, t uintptr) (r uintptr) { // /tmp/libc/musl-master/src/time/gmtime.c:7:2: + if __ccgo_strace { + trc("tls=%v t=%v, (%v:)", tls, t, origin(2)) + defer func() { trc("-> %v", r) }() + } + return Xgmtime_r(tls, t, uintptr(unsafe.Pointer(&_tm))) +} + +var _days_in_month = [12]int8{ + 0: int8(31), + 1: int8(30), + 2: int8(31), + 3: int8(30), + 4: int8(31), + 5: int8(31), + 6: int8(30), + 7: int8(31), + 8: int8(30), + 9: int8(31), + 10: int8(31), + 11: int8(29), +} + +var x___utc = [4]int8{'U', 'T', 'C'} + +func Xstrftime(tls *TLS, s uintptr, n size_t, f uintptr, tm uintptr) (r size_t) { + if __ccgo_strace { + trc("tls=%v s=%v n=%v f=%v tm=%v, (%v:)", tls, s, n, f, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + tt := time.Date( + int((*ctime.Tm)(unsafe.Pointer(tm)).Ftm_year+1900), + time.Month((*ctime.Tm)(unsafe.Pointer(tm)).Ftm_mon+1), + int((*ctime.Tm)(unsafe.Pointer(tm)).Ftm_mday), + int((*ctime.Tm)(unsafe.Pointer(tm)).Ftm_hour), + int((*ctime.Tm)(unsafe.Pointer(tm)).Ftm_min), + int((*ctime.Tm)(unsafe.Pointer(tm)).Ftm_sec), + 0, + time.UTC, + ) + fmt := GoString(f) + var result string + if fmt != "" { + result = strftime.Format(fmt, tt) + } + switch r = size_t(len(result)); { + case r > n: + r = 0 + default: + copy((*RawMem)(unsafe.Pointer(s))[:r:r], result) + *(*byte)(unsafe.Pointer(s + uintptr(r))) = 0 + } + return r + +} + +func x___secs_to_tm(tls *TLS, t int64, tm uintptr) (r int32) { + var c_cycles, leap, months, q_cycles, qc_cycles, remdays, remsecs, remyears, wday, yday int32 + var days, secs, years int64 + _, _, _, _, _, _, _, _, _, _, _, _, _ = c_cycles, days, leap, months, q_cycles, qc_cycles, remdays, remsecs, remyears, secs, wday, yday, years + /* Reject time_t values whose year would overflow int */ + if t < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff))*Int64FromInt64(31622400) || t > Int64FromInt32(limits.INT_MAX)*Int64FromInt64(31622400) { + return -int32(1) + } + secs = t - (Int64FromInt64(946684800) + int64(Int32FromInt32(86400)*(Int32FromInt32(31)+Int32FromInt32(29)))) + days = secs / int64(86400) + remsecs = int32(secs % int64(86400)) + if remsecs < 0 { + remsecs += int32(86400) + days-- + } + wday = int32((int64(3) + days) % int64(7)) + if wday < 0 { + wday += int32(7) + } + qc_cycles = int32(days / int64(Int32FromInt32(365)*Int32FromInt32(400)+Int32FromInt32(97))) + remdays = int32(days % int64(Int32FromInt32(365)*Int32FromInt32(400)+Int32FromInt32(97))) + if remdays < 0 { + remdays += Int32FromInt32(365)*Int32FromInt32(400) + Int32FromInt32(97) + qc_cycles-- + } + c_cycles = remdays / (Int32FromInt32(365)*Int32FromInt32(100) + Int32FromInt32(24)) + if c_cycles == int32(4) { + c_cycles-- + } + remdays -= c_cycles * (Int32FromInt32(365)*Int32FromInt32(100) + Int32FromInt32(24)) + q_cycles = remdays / (Int32FromInt32(365)*Int32FromInt32(4) + Int32FromInt32(1)) + if q_cycles == int32(25) { + q_cycles-- + } + remdays -= q_cycles * (Int32FromInt32(365)*Int32FromInt32(4) + Int32FromInt32(1)) + remyears = remdays / int32(365) + if remyears == int32(4) { + remyears-- + } + remdays -= remyears * int32(365) + leap = BoolInt32(!(remyears != 0) && (q_cycles != 0 || !(c_cycles != 0))) + yday = remdays + int32(31) + int32(28) + leap + if yday >= int32(365)+leap { + yday -= int32(365) + leap + } + years = int64(remyears+int32(4)*q_cycles+int32(100)*c_cycles) + int64(400)*int64(int64(qc_cycles)) + months = 0 + for { + if !(int32(_days_in_month[months]) <= remdays) { + break + } + remdays -= int32(_days_in_month[months]) + goto _1 + _1: + months++ + } + if months >= int32(10) { + months -= int32(12) + years++ + } + if years+int64(100) > int64(limits.INT_MAX) || years+int64(100) < int64(-Int32FromInt32(1)-Int32FromInt32(0x7fffffff)) { + return -int32(1) + } + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_year = int32(years + int64(100)) + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_mon = months + int32(2) + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_mday = remdays + int32(1) + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_wday = wday + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_yday = yday + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_hour = remsecs / int32(3600) + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_min = remsecs / int32(60) % int32(60) + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_sec = remsecs % int32(60) + return 0 +} diff --git a/internal/libc/libc_unix1.go b/internal/libc/libc_unix1.go new file mode 100644 index 0000000..2ec8586 --- /dev/null +++ b/internal/libc/libc_unix1.go @@ -0,0 +1,27 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix && !illumos && !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) && !openbsd + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "golang.org/x/sys/unix" + + "github.com/hanzoai/sqlite/internal/libc/sys/types" +) + +// ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags); +func Xrecvmsg(t *TLS, sockfd int32, msg uintptr, flags int32) types.Ssize_t { + if __ccgo_strace { + trc("t=%v sockfd=%v msg=%v flags=%v, (%v:)", t, sockfd, msg, flags, origin(2)) + } + n, _, err := unix.Syscall(unix.SYS_RECVMSG, uintptr(sockfd), msg, uintptr(flags)) + if err != 0 { + t.setErrno(err) + return -1 + } + + return types.Ssize_t(n) +} diff --git a/internal/libc/libc_unix3.go b/internal/libc/libc_unix3.go new file mode 100644 index 0000000..561b844 --- /dev/null +++ b/internal/libc/libc_unix3.go @@ -0,0 +1,46 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix && !illumos && !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "unsafe" + + "golang.org/x/sys/unix" + "github.com/hanzoai/sqlite/internal/libc/errno" + ctime "github.com/hanzoai/sqlite/internal/libc/time" +) + +// int clock_gettime(clockid_t clk_id, struct timespec *tp); +func Xclock_gettime(t *TLS, clk_id int32, tp uintptr) int32 { + if __ccgo_strace { + trc("t=%v clk_id=%v tp=%v, (%v:)", t, clk_id, tp, origin(2)) + } + var ts unix.Timespec + if err := unix.ClockGettime(clk_id, &ts); err != nil { + t.setErrno(err) + trc("FAIL: %v", err) + return -1 + } + + *(*unix.Timespec)(unsafe.Pointer(tp)) = ts + return 0 +} + +func Xgmtime_r(tls *TLS, t uintptr, tm uintptr) (r uintptr) { + if __ccgo_strace { + trc("tls=%v t=%v tm=%v, (%v:)", tls, t, tm, origin(2)) + defer func() { trc("-> %v", r) }() + } + if x___secs_to_tm(tls, int64(*(*time_t)(unsafe.Pointer(t))), tm) < 0 { + *(*int32)(unsafe.Pointer(X__errno_location(tls))) = int32(errno.EOVERFLOW) + return uintptr(0) + } + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_isdst = 0 + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_gmtoff = 0 + (*ctime.Tm)(unsafe.Pointer(tm)).Ftm_zone = uintptr(unsafe.Pointer(&x___utc)) + return tm +} diff --git a/internal/libc/limits/capi_darwin_amd64.go b/internal/libc/limits/capi_darwin_amd64.go new file mode 100644 index 0000000..92b08b3 --- /dev/null +++ b/internal/libc/limits/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo limits/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o limits/limits_darwin_amd64.go -pkgname limits', DO NOT EDIT. + +package limits + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/limits/capi_darwin_arm64.go b/internal/libc/limits/capi_darwin_arm64.go new file mode 100644 index 0000000..4cf4ad2 --- /dev/null +++ b/internal/libc/limits/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo limits/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o limits/limits_darwin_arm64.go -pkgname limits', DO NOT EDIT. + +package limits + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/limits/capi_linux_amd64.go b/internal/libc/limits/capi_linux_amd64.go new file mode 100644 index 0000000..dbe66d8 --- /dev/null +++ b/internal/libc/limits/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo limits/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o limits/limits_linux_amd64.go -pkgname limits', DO NOT EDIT. + +package limits + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/limits/capi_linux_arm64.go b/internal/libc/limits/capi_linux_arm64.go new file mode 100644 index 0000000..7563066 --- /dev/null +++ b/internal/libc/limits/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo limits/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o limits/limits_linux_arm64.go -pkgname limits', DO NOT EDIT. + +package limits + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/limits/limits_darwin_amd64.go b/internal/libc/limits/limits_darwin_amd64.go new file mode 100644 index 0000000..d99d752 --- /dev/null +++ b/internal/libc/limits/limits_darwin_amd64.go @@ -0,0 +1,935 @@ +// Code generated by 'ccgo limits/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o limits/limits_darwin_amd64.go -pkgname limits', DO NOT EDIT. + +package limits + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ARG_MAX = 262144 + BC_BASE_MAX = 99 + BC_DIM_MAX = 2048 + BC_SCALE_MAX = 99 + BC_STRING_MAX = 1000 + CHARCLASS_NAME_MAX = 14 + CHAR_BIT = 8 + CHAR_MAX = 127 + CHAR_MIN = -128 + CHILD_MAX = 266 + CLK_TCK = 100 + COLL_WEIGHTS_MAX = 2 + EQUIV_CLASS_MAX = 2 + EXPR_NEST_MAX = 32 + GID_MAX = 2147483647 + INT_MAX = 2147483647 + INT_MIN = -2147483648 + IOV_MAX = 1024 + LINE_MAX = 2048 + LINK_MAX = 32767 + LLONG_MAX = 9223372036854775807 + LLONG_MIN = -9223372036854775808 + LONG_BIT = 64 + LONG_LONG_MAX = 9223372036854775807 + LONG_LONG_MIN = -9223372036854775808 + LONG_MAX = 9223372036854775807 + LONG_MIN = -9223372036854775808 + MAX_CANON = 1024 + MAX_INPUT = 1024 + MB_LEN_MAX = 6 + NAME_MAX = 255 + NGROUPS_MAX = 16 + NL_ARGMAX = 9 + NL_LANGMAX = 14 + NL_MSGMAX = 32767 + NL_NMAX = 1 + NL_SETMAX = 255 + NL_TEXTMAX = 2048 + NZERO = 20 + OFF_MAX = 9223372036854775807 + OFF_MIN = -9223372036854775808 + OPEN_MAX = 10240 + PASS_MAX = 128 + PATH_MAX = 1024 + PIPE_BUF = 512 + PTHREAD_DESTRUCTOR_ITERATIONS = 4 + PTHREAD_KEYS_MAX = 512 + PTHREAD_STACK_MIN = 8192 + QUAD_MAX = 9223372036854775807 + QUAD_MIN = -9223372036854775808 + RE_DUP_MAX = 255 + SCHAR_MAX = 127 + SCHAR_MIN = -128 + SHRT_MAX = 32767 + SHRT_MIN = -32768 + SIZE_T_MAX = 18446744073709551615 + SSIZE_MAX = 9223372036854775807 + UCHAR_MAX = 255 + UID_MAX = 2147483647 + UINT_MAX = 4294967295 + ULLONG_MAX = 18446744073709551615 + ULONG_LONG_MAX = 18446744073709551615 + ULONG_MAX = 18446744073709551615 + UQUAD_MAX = 18446744073709551615 + USHRT_MAX = 65535 + WORD_BIT = 32 + X_CDEFS_H_ = 0 + X_DARWIN_FEATURE_64_BIT_INODE = 1 + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 + X_FILE_OFFSET_BITS = 64 + X_GCC_LIMITS_H_ = 0 + X_I386_LIMITS_H_ = 0 + X_I386__LIMITS_H_ = 0 + X_LIMITS_H_ = 0 + X_LIMITS_H___ = 0 + X_LP64 = 1 + X_Nonnull = 0 + X_Null_unspecified = 0 + X_Nullable = 0 + X_POSIX2_BC_BASE_MAX = 99 + X_POSIX2_BC_DIM_MAX = 2048 + X_POSIX2_BC_SCALE_MAX = 99 + X_POSIX2_BC_STRING_MAX = 1000 + X_POSIX2_CHARCLASS_NAME_MAX = 14 + X_POSIX2_COLL_WEIGHTS_MAX = 2 + X_POSIX2_EQUIV_CLASS_MAX = 2 + X_POSIX2_EXPR_NEST_MAX = 32 + X_POSIX2_LINE_MAX = 2048 + X_POSIX2_RE_DUP_MAX = 255 + X_POSIX_AIO_LISTIO_MAX = 2 + X_POSIX_AIO_MAX = 1 + X_POSIX_ARG_MAX = 4096 + X_POSIX_CHILD_MAX = 25 + X_POSIX_CLOCKRES_MIN = 20000000 + X_POSIX_DELAYTIMER_MAX = 32 + X_POSIX_HOST_NAME_MAX = 255 + X_POSIX_LINK_MAX = 8 + X_POSIX_LOGIN_NAME_MAX = 9 + X_POSIX_MAX_CANON = 255 + X_POSIX_MAX_INPUT = 255 + X_POSIX_MQ_OPEN_MAX = 8 + X_POSIX_MQ_PRIO_MAX = 32 + X_POSIX_NAME_MAX = 14 + X_POSIX_NGROUPS_MAX = 8 + X_POSIX_OPEN_MAX = 20 + X_POSIX_PATH_MAX = 256 + X_POSIX_PIPE_BUF = 512 + X_POSIX_RE_DUP_MAX = 255 + X_POSIX_RTSIG_MAX = 8 + X_POSIX_SEM_NSEMS_MAX = 256 + X_POSIX_SEM_VALUE_MAX = 32767 + X_POSIX_SIGQUEUE_MAX = 32 + X_POSIX_SSIZE_MAX = 32767 + X_POSIX_SS_REPL_MAX = 4 + X_POSIX_STREAM_MAX = 8 + X_POSIX_SYMLINK_MAX = 255 + X_POSIX_SYMLOOP_MAX = 8 + X_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 + X_POSIX_THREAD_KEYS_MAX = 128 + X_POSIX_THREAD_THREADS_MAX = 64 + X_POSIX_TIMER_MAX = 32 + X_POSIX_TRACE_EVENT_NAME_MAX = 30 + X_POSIX_TRACE_NAME_MAX = 8 + X_POSIX_TRACE_SYS_MAX = 8 + X_POSIX_TRACE_USER_EVENT_MAX = 32 + X_POSIX_TTY_NAME_MAX = 9 + X_POSIX_TZNAME_MAX = 6 + X_SYS_SYSLIMITS_H_ = 0 + X_XOPEN_IOV_MAX = 16 + X_XOPEN_NAME_MAX = 255 + X_XOPEN_PATH_MAX = 1024 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (C) 1992-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) any later +// version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// This administrivia gets added to the beginning of limits.h +// if the system has its own version of limits.h. + +// We use _GCC_LIMITS_H_ because we want this not to match +// any macros that the system's limits.h uses for its own purposes. + +// Use "..." so that we find syslimits.h only in this same directory. +// syslimits.h stands for the system's own limits.h file. +// If we can use it ok unmodified, then we install this text. +// If fixincludes fixes it, then the fixed version is installed +// instead of this text. + +// Copyright (c) 2000, 2004-2007, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// $NetBSD: limits.h,v 1.8 1996/10/21 05:10:50 jtc Exp $ + +// 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. +// +// @(#)limits.h 8.2 (Berkeley) 1/4/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// This is the `system' limits.h, independent of any particular +// compiler. GCC provides its own limits.h which can be found in +// /usr/lib/gcc, although it is not very informative. +// This file is public domain. +// 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. +// +// @(#)limits.h 8.3 (Berkeley) 1/4/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// The contents of this file constitute Original Code as defined in and +// are subject to the Apple Public Source License Version 1.1 (the +// "License"). You may not use this file except in compliance with the +// License. Please obtain a copy of the License at +// http://www.apple.com/publicsource and read it before using this file. +// +// This Original Code and all software distributed under the License are +// distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +// License for the specific language governing rights and limitations +// under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// According to ANSI (section 2.2.4.2), the values below must be usable by +// #if preprocessing directives. Additionally, the expression must have the +// same type as would an expression that is an object of the corresponding +// type converted according to the integral promotions. The subtraction for +// INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an +// unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). +// These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values +// are written as hex so that GCC will be quiet about large integer constants. + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// $NetBSD: syslimits.h,v 1.15 1997/06/25 00:48:09 lukem Exp $ + +// 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. +// +// @(#)syslimits.h 8.1 (Berkeley) 6/2/93 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Note: CHILD_MAX *must* be less than hard_maxproc, which is set at +// compile time; you *cannot* set it higher than the hard limit!! + +// = ((PRIO_MAX - PRIO_MIN) / 2) + 1 +// range: 0 - 39 [(2 * NZERO) - 1] +// 0 is not actually used + +// Actually for XSI Visible + +// Removed in Issue 6 + +// NZERO to be defined here. TBD. See also sys/param.h + +// Copyright (C) 1991-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) any later +// version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// Number of bits in a `char'. + +// Maximum length of a multibyte character. + +// Minimum and maximum values a `signed char' can hold. + +// Maximum value an `unsigned char' can hold. (Minimum is 0). + +// Minimum and maximum values a `char' can hold. + +// Minimum and maximum values a `signed short int' can hold. + +// Maximum value an `unsigned short int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed int' can hold. + +// Maximum value an `unsigned int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long int' can hold. +// (Same as `int'). + +// Maximum value an `unsigned long int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long long int' can hold. + +// Maximum value an `unsigned long long int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long long int' can hold. + +// Maximum value an `unsigned long long int' can hold. (Minimum is 0). + +// This administrivia gets added to the end of limits.h +// if the system has its own version of limits.h. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/limits/limits_darwin_arm64.go b/internal/libc/limits/limits_darwin_arm64.go new file mode 100644 index 0000000..1d650b0 --- /dev/null +++ b/internal/libc/limits/limits_darwin_arm64.go @@ -0,0 +1,932 @@ +// Code generated by 'ccgo limits/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o limits/limits_darwin_arm64.go -pkgname limits', DO NOT EDIT. + +package limits + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ARG_MAX = 1048576 + BC_BASE_MAX = 99 + BC_DIM_MAX = 2048 + BC_SCALE_MAX = 99 + BC_STRING_MAX = 1000 + CHARCLASS_NAME_MAX = 14 + CHAR_BIT = 8 + CHAR_MAX = 127 + CHAR_MIN = -128 + CHILD_MAX = 266 + CLK_TCK = 100 + COLL_WEIGHTS_MAX = 2 + EQUIV_CLASS_MAX = 2 + EXPR_NEST_MAX = 32 + GID_MAX = 2147483647 + INT_MAX = 2147483647 + INT_MIN = -2147483648 + IOV_MAX = 1024 + LINE_MAX = 2048 + LINK_MAX = 32767 + LLONG_MAX = 9223372036854775807 + LLONG_MIN = -9223372036854775808 + LONG_BIT = 64 + LONG_LONG_MAX = 9223372036854775807 + LONG_LONG_MIN = -9223372036854775808 + LONG_MAX = 9223372036854775807 + LONG_MIN = -9223372036854775808 + MAX_CANON = 1024 + MAX_INPUT = 1024 + MB_LEN_MAX = 6 + NAME_MAX = 255 + NGROUPS_MAX = 16 + NL_ARGMAX = 9 + NL_LANGMAX = 14 + NL_MSGMAX = 32767 + NL_NMAX = 1 + NL_SETMAX = 255 + NL_TEXTMAX = 2048 + NZERO = 20 + OFF_MAX = 9223372036854775807 + OFF_MIN = -9223372036854775808 + OPEN_MAX = 10240 + PASS_MAX = 128 + PATH_MAX = 1024 + PIPE_BUF = 512 + PTHREAD_DESTRUCTOR_ITERATIONS = 4 + PTHREAD_KEYS_MAX = 512 + PTHREAD_STACK_MIN = 16384 + QUAD_MAX = 9223372036854775807 + QUAD_MIN = -9223372036854775808 + RE_DUP_MAX = 255 + SCHAR_MAX = 127 + SCHAR_MIN = -128 + SHRT_MAX = 32767 + SHRT_MIN = -32768 + SIZE_T_MAX = 18446744073709551615 + SSIZE_MAX = 9223372036854775807 + UCHAR_MAX = 255 + UID_MAX = 2147483647 + UINT_MAX = 4294967295 + ULLONG_MAX = 18446744073709551615 + ULONG_LONG_MAX = 18446744073709551615 + ULONG_MAX = 18446744073709551615 + UQUAD_MAX = 18446744073709551615 + USHRT_MAX = 65535 + WORD_BIT = 32 + X_ARM_LIMITS_H_ = 0 + X_ARM__LIMITS_H_ = 0 + X_BSD_MACHINE_LIMITS_H_ = 0 + X_CDEFS_H_ = 0 + X_DARWIN_FEATURE_64_BIT_INODE = 1 + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 + X_FILE_OFFSET_BITS = 64 + X_GCC_LIMITS_H_ = 0 + X_LIMITS_H_ = 0 + X_LIMITS_H___ = 0 + X_LP64 = 1 + X_Nonnull = 0 + X_Null_unspecified = 0 + X_Nullable = 0 + X_POSIX2_BC_BASE_MAX = 99 + X_POSIX2_BC_DIM_MAX = 2048 + X_POSIX2_BC_SCALE_MAX = 99 + X_POSIX2_BC_STRING_MAX = 1000 + X_POSIX2_CHARCLASS_NAME_MAX = 14 + X_POSIX2_COLL_WEIGHTS_MAX = 2 + X_POSIX2_EQUIV_CLASS_MAX = 2 + X_POSIX2_EXPR_NEST_MAX = 32 + X_POSIX2_LINE_MAX = 2048 + X_POSIX2_RE_DUP_MAX = 255 + X_POSIX_AIO_LISTIO_MAX = 2 + X_POSIX_AIO_MAX = 1 + X_POSIX_ARG_MAX = 4096 + X_POSIX_CHILD_MAX = 25 + X_POSIX_CLOCKRES_MIN = 20000000 + X_POSIX_DELAYTIMER_MAX = 32 + X_POSIX_HOST_NAME_MAX = 255 + X_POSIX_LINK_MAX = 8 + X_POSIX_LOGIN_NAME_MAX = 9 + X_POSIX_MAX_CANON = 255 + X_POSIX_MAX_INPUT = 255 + X_POSIX_MQ_OPEN_MAX = 8 + X_POSIX_MQ_PRIO_MAX = 32 + X_POSIX_NAME_MAX = 14 + X_POSIX_NGROUPS_MAX = 8 + X_POSIX_OPEN_MAX = 20 + X_POSIX_PATH_MAX = 256 + X_POSIX_PIPE_BUF = 512 + X_POSIX_RE_DUP_MAX = 255 + X_POSIX_RTSIG_MAX = 8 + X_POSIX_SEM_NSEMS_MAX = 256 + X_POSIX_SEM_VALUE_MAX = 32767 + X_POSIX_SIGQUEUE_MAX = 32 + X_POSIX_SSIZE_MAX = 32767 + X_POSIX_SS_REPL_MAX = 4 + X_POSIX_STREAM_MAX = 8 + X_POSIX_SYMLINK_MAX = 255 + X_POSIX_SYMLOOP_MAX = 8 + X_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 + X_POSIX_THREAD_KEYS_MAX = 128 + X_POSIX_THREAD_THREADS_MAX = 64 + X_POSIX_TIMER_MAX = 32 + X_POSIX_TRACE_EVENT_NAME_MAX = 30 + X_POSIX_TRACE_NAME_MAX = 8 + X_POSIX_TRACE_SYS_MAX = 8 + X_POSIX_TRACE_USER_EVENT_MAX = 32 + X_POSIX_TTY_NAME_MAX = 9 + X_POSIX_TZNAME_MAX = 6 + X_SYS_SYSLIMITS_H_ = 0 + X_XOPEN_IOV_MAX = 16 + X_XOPEN_NAME_MAX = 255 + X_XOPEN_PATH_MAX = 1024 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1992-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) any later +// version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// This administrivia gets added to the beginning of limits.h +// if the system has its own version of limits.h. + +// We use _GCC_LIMITS_H_ because we want this not to match +// any macros that the system's limits.h uses for its own purposes. + +// Use "..." so that we find syslimits.h only in this same directory. +// syslimits.h stands for the system's own limits.h file. +// If we can use it ok unmodified, then we install this text. +// If fixincludes fixes it, then the fixed version is installed +// instead of this text. + +// Copyright (c) 2000, 2004-2007, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// $NetBSD: limits.h,v 1.8 1996/10/21 05:10:50 jtc Exp $ + +// 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. +// +// @(#)limits.h 8.2 (Berkeley) 1/4/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// This is the `system' limits.h, independent of any particular +// compiler. GCC provides its own limits.h which can be found in +// /usr/lib/gcc, although it is not very informative. +// This file is public domain. + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// 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. +// +// @(#)limits.h 8.3 (Berkeley) 1/4/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. + +// According to ANSI (section 2.2.4.2), the values below must be usable by +// #if preprocessing directives. Additionally, the expression must have the +// same type as would an expression that is an object of the corresponding +// type converted according to the integral promotions. The subtraction for +// INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an +// unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). +// These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values +// are written as hex so that GCC will be quiet about large integer constants. + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// $NetBSD: syslimits.h,v 1.15 1997/06/25 00:48:09 lukem Exp $ + +// 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. +// +// @(#)syslimits.h 8.1 (Berkeley) 6/2/93 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// max bytes for an exec function + +// Note: CHILD_MAX *must* be less than hard_maxproc, which is set at +// compile time; you *cannot* set it higher than the hard limit!! + +// = ((PRIO_MAX - PRIO_MIN) / 2) + 1 +// range: 0 - 39 [(2 * NZERO) - 1] +// 0 is not actually used + +// Actually for XSI Visible + +// Removed in Issue 6 + +// NZERO to be defined here. TBD. See also sys/param.h + +// Copyright (C) 1991-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) any later +// version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// Number of bits in a `char'. + +// Maximum length of a multibyte character. + +// Minimum and maximum values a `signed char' can hold. + +// Maximum value an `unsigned char' can hold. (Minimum is 0). + +// Minimum and maximum values a `char' can hold. + +// Minimum and maximum values a `signed short int' can hold. + +// Maximum value an `unsigned short int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed int' can hold. + +// Maximum value an `unsigned int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long int' can hold. +// (Same as `int'). + +// Maximum value an `unsigned long int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long long int' can hold. + +// Maximum value an `unsigned long long int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long long int' can hold. + +// Maximum value an `unsigned long long int' can hold. (Minimum is 0). + +// This administrivia gets added to the end of limits.h +// if the system has its own version of limits.h. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/limits/limits_linux_amd64.go b/internal/libc/limits/limits_linux_amd64.go new file mode 100644 index 0000000..6ccd3a0 --- /dev/null +++ b/internal/libc/limits/limits_linux_amd64.go @@ -0,0 +1,943 @@ +// Code generated by 'ccgo limits/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o limits/limits_linux_amd64.go -pkgname limits', DO NOT EDIT. + +package limits + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AIO_PRIO_DELTA_MAX = 20 // local_lim.h:78:1: + BC_BASE_MAX = 99 // posix2_lim.h:63:1: + BC_DIM_MAX = 2048 // posix2_lim.h:66:1: + BC_SCALE_MAX = 99 // posix2_lim.h:69:1: + BC_STRING_MAX = 1000 // posix2_lim.h:72:1: + CHARCLASS_NAME_MAX = 2048 // posix2_lim.h:84:1: + CHAR_BIT = 8 // limits.h:64:1: + CHAR_MAX = 127 // limits.h:99:1: + CHAR_MIN = -128 // limits.h:97:1: + COLL_WEIGHTS_MAX = 255 // posix2_lim.h:75:1: + DELAYTIMER_MAX = 2147483647 // local_lim.h:84:1: + EXPR_NEST_MAX = 32 // posix2_lim.h:78:1: + HOST_NAME_MAX = 64 // local_lim.h:93:1: + INT_MAX = 2147483647 // limits.h:120:1: + INT_MIN = -2147483648 // limits.h:118:1: + LINE_MAX = 2048 // posix2_lim.h:81:1: + LLONG_MAX = 9223372036854775807 // limits.h:142:1: + LLONG_MIN = -9223372036854775808 // limits.h:140:1: + LOGIN_NAME_MAX = 256 // local_lim.h:90:1: + LONG_MAX = 9223372036854775807 // limits.h:131:1: + LONG_MIN = -9223372036854775808 // limits.h:129:1: + MAX_CANON = 255 // limits.h:10:1: + MAX_INPUT = 255 // limits.h:11:1: + MB_LEN_MAX = 16 // limits.h:32:1: + MQ_PRIO_MAX = 32768 // local_lim.h:96:1: + NAME_MAX = 255 // limits.h:12:1: + NGROUPS_MAX = 65536 // limits.h:7:1: + PATH_MAX = 4096 // limits.h:13:1: + PIPE_BUF = 4096 // limits.h:14:1: + PTHREAD_DESTRUCTOR_ITERATIONS = 4 // local_lim.h:69:1: + PTHREAD_KEYS_MAX = 1024 // local_lim.h:64:1: + PTHREAD_STACK_MIN = 16384 // local_lim.h:81:1: + RE_DUP_MAX = 32767 // posix2_lim.h:88:1: + RTSIG_MAX = 32 // limits.h:19:1: + SCHAR_MAX = 127 // limits.h:75:1: + SCHAR_MIN = -128 // limits.h:73:1: + SEM_VALUE_MAX = 2147483647 // local_lim.h:99:1: + SHRT_MAX = 32767 // limits.h:106:1: + SHRT_MIN = -32768 // limits.h:104:1: + SSIZE_MAX = 9223372036854775807 // posix1_lim.h:169:1: + TTY_NAME_MAX = 32 // local_lim.h:87:1: + UCHAR_MAX = 255 // limits.h:82:1: + UINT_MAX = 4294967295 // limits.h:124:1: + ULLONG_MAX = 18446744073709551615 // limits.h:146:1: + ULONG_MAX = 18446744073709551615 // limits.h:135:1: + USHRT_MAX = 65535 // limits.h:113:1: + XATTR_LIST_MAX = 65536 // limits.h:17:1: + XATTR_NAME_MAX = 255 // limits.h:15:1: + XATTR_SIZE_MAX = 65536 // limits.h:16:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_POSIX1_LIM_H = 1 // posix1_lim.h:25:1: + X_BITS_POSIX2_LIM_H = 1 // posix2_lim.h:23:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_LIMITS_H_ = 0 // limits.h:30:1: + X_LIBC_LIMITS_H_ = 1 // limits.h:23:1: + X_LIMITS_H___ = 0 // limits.h:60:1: + X_LINUX_LIMITS_H = 0 // limits.h:3:1: + X_LP64 = 1 // :284:1: + X_POSIX2_BC_BASE_MAX = 99 // posix2_lim.h:27:1: + X_POSIX2_BC_DIM_MAX = 2048 // posix2_lim.h:30:1: + X_POSIX2_BC_SCALE_MAX = 99 // posix2_lim.h:33:1: + X_POSIX2_BC_STRING_MAX = 1000 // posix2_lim.h:36:1: + X_POSIX2_CHARCLASS_NAME_MAX = 14 // posix2_lim.h:55:1: + X_POSIX2_COLL_WEIGHTS_MAX = 2 // posix2_lim.h:40:1: + X_POSIX2_EXPR_NEST_MAX = 32 // posix2_lim.h:44:1: + X_POSIX2_LINE_MAX = 2048 // posix2_lim.h:47:1: + X_POSIX2_RE_DUP_MAX = 255 // posix2_lim.h:51:1: + X_POSIX_AIO_LISTIO_MAX = 2 // posix1_lim.h:32:1: + X_POSIX_AIO_MAX = 1 // posix1_lim.h:35:1: + X_POSIX_ARG_MAX = 4096 // posix1_lim.h:38:1: + X_POSIX_CHILD_MAX = 25 // posix1_lim.h:42:1: + X_POSIX_CLOCKRES_MIN = 20000000 // posix1_lim.h:157:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_DELAYTIMER_MAX = 32 // posix1_lim.h:48:1: + X_POSIX_HOST_NAME_MAX = 255 // posix1_lim.h:52:1: + X_POSIX_LINK_MAX = 8 // posix1_lim.h:55:1: + X_POSIX_LOGIN_NAME_MAX = 9 // posix1_lim.h:58:1: + X_POSIX_MAX_CANON = 255 // posix1_lim.h:61:1: + X_POSIX_MAX_INPUT = 255 // posix1_lim.h:65:1: + X_POSIX_MQ_OPEN_MAX = 8 // posix1_lim.h:68:1: + X_POSIX_MQ_PRIO_MAX = 32 // posix1_lim.h:71:1: + X_POSIX_NAME_MAX = 14 // posix1_lim.h:74:1: + X_POSIX_NGROUPS_MAX = 8 // posix1_lim.h:78:1: + X_POSIX_OPEN_MAX = 20 // posix1_lim.h:85:1: + X_POSIX_PATH_MAX = 256 // posix1_lim.h:97:1: + X_POSIX_PIPE_BUF = 512 // posix1_lim.h:100:1: + X_POSIX_RE_DUP_MAX = 255 // posix1_lim.h:104:1: + X_POSIX_RTSIG_MAX = 8 // posix1_lim.h:107:1: + X_POSIX_SEM_NSEMS_MAX = 256 // posix1_lim.h:110:1: + X_POSIX_SEM_VALUE_MAX = 32767 // posix1_lim.h:113:1: + X_POSIX_SIGQUEUE_MAX = 32 // posix1_lim.h:116:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_POSIX_SSIZE_MAX = 32767 // posix1_lim.h:119:1: + X_POSIX_STREAM_MAX = 8 // posix1_lim.h:122:1: + X_POSIX_SYMLINK_MAX = 255 // posix1_lim.h:125:1: + X_POSIX_SYMLOOP_MAX = 8 // posix1_lim.h:129:1: + X_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 // local_lim.h:67:1: + X_POSIX_THREAD_KEYS_MAX = 128 // local_lim.h:62:1: + X_POSIX_THREAD_THREADS_MAX = 64 // local_lim.h:72:1: + X_POSIX_TIMER_MAX = 32 // posix1_lim.h:132:1: + X_POSIX_TTY_NAME_MAX = 9 // posix1_lim.h:135:1: + X_POSIX_TZNAME_MAX = 6 // posix1_lim.h:139:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) any later +// version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// This administrivia gets added to the beginning of limits.h +// if the system has its own version of limits.h. + +// We use _GCC_LIMITS_H_ because we want this not to match +// any macros that the system's limits.h uses for its own purposes. + +// Use "..." so that we find syslimits.h only in this same directory. +// syslimits.h stands for the system's own limits.h file. +// If we can use it ok unmodified, then we install this text. +// If fixincludes fixes it, then the fixed version is installed +// instead of this text. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types + +// Handle feature test macros at the start of a header. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This header is internal to glibc and should not be included outside +// of glibc headers. Headers including it must define +// __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION first. This header +// cannot have multiple include guards because ISO C feature test +// macros depend on the definition of the macro when an affected +// header is included, not when the first system header is +// included. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// ISO/IEC TR 24731-2:2010 defines the __STDC_WANT_LIB_EXT2__ +// macro. + +// ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__ +// macro. Most but not all symbols enabled by that macro in TS +// 18661-1 are enabled unconditionally in C2X; the symbols in Annex F +// still require that macro in C2X. + +// ISO/IEC TS 18661-4:2015 defines the +// __STDC_WANT_IEC_60559_FUNCS_EXT__ macro. Other than the reduction +// functions, the symbols from this TS are enabled unconditionally in +// C2X. + +// ISO/IEC TS 18661-3:2015 defines the +// __STDC_WANT_IEC_60559_TYPES_EXT__ macro. + +// Maximum length of any multibyte character in any locale. +// We define this value here since the gcc header does not define +// the correct value. + +// If we are not using GNU CC we have to define all the symbols ourself. +// Otherwise use gcc's definitions (see below). + +// Get the compiler's limits.h, which defines almost all the ISO constants. +// +// We put this #include_next outside the double inclusion check because +// it should be possible to include this file more than once and still get +// the definitions from gcc's header. + +// The files in some gcc versions don't define LLONG_MIN, +// LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for +// ages are available. + +// The integer width macros are not defined by GCC's before +// GCC 7, or if _GNU_SOURCE rather than +// __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. + +// POSIX adds things to . +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.9.2 Minimum Values Added to +// +// Never include this file directly; use instead. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// These are the standard-mandated minimum values. + +// Minimum number of operations in one list I/O call. + +// Minimal number of outstanding asynchronous I/O operations. + +// Maximum length of arguments to `execve', including environment. + +// Maximum simultaneous processes per real user ID. + +// Minimal number of timer expiration overruns. + +// Maximum length of a host name (not including the terminating null) +// as returned from the GETHOSTNAME function. + +// Maximum link count of a file. + +// Maximum length of login name. + +// Number of bytes in a terminal canonical input queue. + +// Number of bytes for which space will be +// available in a terminal input queue. + +// Maximum number of message queues open for a process. + +// Maximum number of supported message priorities. + +// Number of bytes in a filename. + +// Number of simultaneous supplementary group IDs per process. + +// Number of files one process can have open at once. + +// Number of bytes in a pathname. + +// Number of bytes than can be written atomically to a pipe. + +// The number of repeated occurrences of a BRE permitted by the +// REGEXEC and REGCOMP functions when using the interval notation. + +// Minimal number of realtime signals reserved for the application. + +// Number of semaphores a process can have. + +// Maximal value of a semaphore. + +// Number of pending realtime signals. + +// Largest value of a `ssize_t'. + +// Number of streams a process can have open at once. + +// The number of bytes in a symbolic link. + +// The number of symbolic links that can be traversed in the +// resolution of a pathname in the absence of a loop. + +// Number of timer for a process. + +// Maximum number of characters in a tty name. + +// Maximum length of a timezone name (element of `tzname'). + +// Maximum clock resolution in nanoseconds. + +// Get the implementation-specific values for the above. +// Minimum guaranteed maximum values for system limits. Linux version. +// Copyright (C) 1993-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; see the file COPYING.LIB. If +// not, see . + +// The kernel header pollutes the namespace with the NR_OPEN symbol +// and defines LINK_MAX although filesystems have different maxima. A +// similar thing is true for OPEN_MAX: the limit can be changed at +// runtime and therefore the macro must not be defined. Remove this +// after including the header if necessary. + +// The kernel sources contain a file with all the needed information. +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// Have to remove NR_OPEN? +// Have to remove LINK_MAX? +// Have to remove OPEN_MAX? +// Have to remove ARG_MAX? + +// The number of data keys per process. +// This is the value this implementation supports. + +// Controlling the iterations of destructors for thread-specific data. +// Number of iterations this implementation does. + +// The number of threads per process. +// We have no predefined limit on the number of threads. + +// Maximum amount by which a process can descrease its asynchronous I/O +// priority level. + +// Minimum size for a thread. We are free to choose a reasonable value. + +// Maximum number of timer expiration overruns. + +// Maximum tty name length. + +// Maximum login name length. This is arbitrary. + +// Maximum host name length. + +// Maximum message queue priority level. + +// Maximum value the semaphore can have. + +// ssize_t is not formally required to be the signed type +// corresponding to size_t, but it is for all configurations supported +// by glibc. + +// This value is a guaranteed minimum maximum. +// The current maximum can be got from `sysconf'. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; include instead. + +// The maximum `ibase' and `obase' values allowed by the `bc' utility. + +// The maximum number of elements allowed in an array by the `bc' utility. + +// The maximum `scale' value allowed by the `bc' utility. + +// The maximum length of a string constant accepted by the `bc' utility. + +// The maximum number of weights that can be assigned to an entry of +// the LC_COLLATE `order' keyword in the locale definition file. + +// The maximum number of expressions that can be nested +// within parentheses by the `expr' utility. + +// The maximum length, in bytes, of an input line. + +// The maximum number of repeated occurrences of a regular expression +// permitted when using the interval notation `\{M,N\}'. + +// The maximum number of bytes in a character class name. We have no +// fixed limit, 2048 is a high number. + +// These values are implementation-specific, +// and may vary within the implementation. +// Their precise values can be obtained from sysconf. + +// This value is defined like this in regex.h. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) any later +// version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// Number of bits in a `char'. + +// Maximum length of a multibyte character. + +// Minimum and maximum values a `signed char' can hold. + +// Maximum value an `unsigned char' can hold. (Minimum is 0). + +// Minimum and maximum values a `char' can hold. + +// Minimum and maximum values a `signed short int' can hold. + +// Maximum value an `unsigned short int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed int' can hold. + +// Maximum value an `unsigned int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long int' can hold. +// (Same as `int'). + +// Maximum value an `unsigned long int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long long int' can hold. + +// Maximum value an `unsigned long long int' can hold. (Minimum is 0). + +// This administrivia gets added to the end of limits.h +// if the system has its own version of limits.h. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/limits/limits_linux_arm64.go b/internal/libc/limits/limits_linux_arm64.go new file mode 100644 index 0000000..2bee99e --- /dev/null +++ b/internal/libc/limits/limits_linux_arm64.go @@ -0,0 +1,995 @@ +// Code generated by 'ccgo limits/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o limits/limits_linux_arm64.go -pkgname limits', DO NOT EDIT. + +package limits + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AIO_PRIO_DELTA_MAX = 20 + BC_BASE_MAX = 99 + BC_DIM_MAX = 2048 + BC_SCALE_MAX = 99 + BC_STRING_MAX = 1000 + CHARCLASS_NAME_MAX = 2048 + CHAR_BIT = 8 + CHAR_MAX = 255 + CHAR_MIN = 0 + COLL_WEIGHTS_MAX = 255 + DELAYTIMER_MAX = 2147483647 + EXPR_NEST_MAX = 32 + HOST_NAME_MAX = 64 + INT_MAX = 2147483647 + INT_MIN = -2147483648 + LINE_MAX = 2048 + LLONG_MAX = 9223372036854775807 + LLONG_MIN = -9223372036854775808 + LOGIN_NAME_MAX = 256 + LONG_MAX = 9223372036854775807 + LONG_MIN = -9223372036854775808 + MAX_CANON = 255 + MAX_INPUT = 255 + MB_LEN_MAX = 16 + MQ_PRIO_MAX = 32768 + NAME_MAX = 255 + NGROUPS_MAX = 65536 + PATH_MAX = 4096 + PIPE_BUF = 4096 + PTHREAD_DESTRUCTOR_ITERATIONS = 4 + PTHREAD_KEYS_MAX = 1024 + PTHREAD_STACK_MIN = 131072 + RE_DUP_MAX = 32767 + RTSIG_MAX = 32 + SCHAR_MAX = 127 + SCHAR_MIN = -128 + SEM_VALUE_MAX = 2147483647 + SHRT_MAX = 32767 + SHRT_MIN = -32768 + SSIZE_MAX = 9223372036854775807 + TTY_NAME_MAX = 32 + UCHAR_MAX = 255 + UINT_MAX = 4294967295 + ULLONG_MAX = 18446744073709551615 + ULONG_MAX = 18446744073709551615 + USHRT_MAX = 65535 + XATTR_LIST_MAX = 65536 + XATTR_NAME_MAX = 255 + XATTR_SIZE_MAX = 65536 + X_ATFILE_SOURCE = 1 + X_BITS_POSIX1_LIM_H = 1 + X_BITS_POSIX2_LIM_H = 1 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_LIMITS_H_ = 0 + X_LIBC_LIMITS_H_ = 1 + X_LIMITS_H___ = 0 + X_LINUX_LIMITS_H = 0 + X_LP64 = 1 + X_POSIX2_BC_BASE_MAX = 99 + X_POSIX2_BC_DIM_MAX = 2048 + X_POSIX2_BC_SCALE_MAX = 99 + X_POSIX2_BC_STRING_MAX = 1000 + X_POSIX2_CHARCLASS_NAME_MAX = 14 + X_POSIX2_COLL_WEIGHTS_MAX = 2 + X_POSIX2_EXPR_NEST_MAX = 32 + X_POSIX2_LINE_MAX = 2048 + X_POSIX2_RE_DUP_MAX = 255 + X_POSIX_AIO_LISTIO_MAX = 2 + X_POSIX_AIO_MAX = 1 + X_POSIX_ARG_MAX = 4096 + X_POSIX_CHILD_MAX = 25 + X_POSIX_CLOCKRES_MIN = 20000000 + X_POSIX_C_SOURCE = 200809 + X_POSIX_DELAYTIMER_MAX = 32 + X_POSIX_HOST_NAME_MAX = 255 + X_POSIX_LINK_MAX = 8 + X_POSIX_LOGIN_NAME_MAX = 9 + X_POSIX_MAX_CANON = 255 + X_POSIX_MAX_INPUT = 255 + X_POSIX_MQ_OPEN_MAX = 8 + X_POSIX_MQ_PRIO_MAX = 32 + X_POSIX_NAME_MAX = 14 + X_POSIX_NGROUPS_MAX = 8 + X_POSIX_OPEN_MAX = 20 + X_POSIX_PATH_MAX = 256 + X_POSIX_PIPE_BUF = 512 + X_POSIX_RE_DUP_MAX = 255 + X_POSIX_RTSIG_MAX = 8 + X_POSIX_SEM_NSEMS_MAX = 256 + X_POSIX_SEM_VALUE_MAX = 32767 + X_POSIX_SIGQUEUE_MAX = 32 + X_POSIX_SOURCE = 1 + X_POSIX_SSIZE_MAX = 32767 + X_POSIX_STREAM_MAX = 8 + X_POSIX_SYMLINK_MAX = 255 + X_POSIX_SYMLOOP_MAX = 8 + X_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 + X_POSIX_THREAD_KEYS_MAX = 128 + X_POSIX_THREAD_THREADS_MAX = 64 + X_POSIX_TIMER_MAX = 32 + X_POSIX_TTY_NAME_MAX = 9 + X_POSIX_TZNAME_MAX = 6 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) any later +// version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// This administrivia gets added to the beginning of limits.h +// if the system has its own version of limits.h. + +// We use _GCC_LIMITS_H_ because we want this not to match +// any macros that the system's limits.h uses for its own purposes. + +// Use "..." so that we find syslimits.h only in this same directory. +// syslimits.h stands for the system's own limits.h file. +// If we can use it ok unmodified, then we install this text. +// If fixincludes fixes it, then the fixed version is installed +// instead of this text. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types + +// Handle feature test macros at the start of a header. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This header is internal to glibc and should not be included outside +// of glibc headers. Headers including it must define +// __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION first. This header +// cannot have multiple include guards because ISO C feature test +// macros depend on the definition of the macro when an affected +// header is included, not when the first system header is +// included. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// ISO/IEC TR 24731-2:2010 defines the __STDC_WANT_LIB_EXT2__ +// macro. + +// ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__ +// macro. Most but not all symbols enabled by that macro in TS +// 18661-1 are enabled unconditionally in C2X; the symbols in Annex F +// still require that macro in C2X. + +// ISO/IEC TS 18661-4:2015 defines the +// __STDC_WANT_IEC_60559_FUNCS_EXT__ macro. Other than the reduction +// functions, the symbols from this TS are enabled unconditionally in +// C2X. + +// ISO/IEC TS 18661-3:2015 defines the +// __STDC_WANT_IEC_60559_TYPES_EXT__ macro. + +// Maximum length of any multibyte character in any locale. +// We define this value here since the gcc header does not define +// the correct value. + +// If we are not using GNU CC we have to define all the symbols ourself. +// Otherwise use gcc's definitions (see below). + +// Get the compiler's limits.h, which defines almost all the ISO constants. +// +// We put this #include_next outside the double inclusion check because +// it should be possible to include this file more than once and still get +// the definitions from gcc's header. + +// The files in some gcc versions don't define LLONG_MIN, +// LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for +// ages are available. + +// The integer width macros are not defined by GCC's before +// GCC 7, or if _GNU_SOURCE rather than +// __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. + +// POSIX adds things to . +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.9.2 Minimum Values Added to +// +// Never include this file directly; use instead. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are the standard-mandated minimum values. + +// Minimum number of operations in one list I/O call. + +// Minimal number of outstanding asynchronous I/O operations. + +// Maximum length of arguments to `execve', including environment. + +// Maximum simultaneous processes per real user ID. + +// Minimal number of timer expiration overruns. + +// Maximum length of a host name (not including the terminating null) +// as returned from the GETHOSTNAME function. + +// Maximum link count of a file. + +// Maximum length of login name. + +// Number of bytes in a terminal canonical input queue. + +// Number of bytes for which space will be +// available in a terminal input queue. + +// Maximum number of message queues open for a process. + +// Maximum number of supported message priorities. + +// Number of bytes in a filename. + +// Number of simultaneous supplementary group IDs per process. + +// Number of files one process can have open at once. + +// Number of bytes in a pathname. + +// Number of bytes than can be written atomically to a pipe. + +// The number of repeated occurrences of a BRE permitted by the +// REGEXEC and REGCOMP functions when using the interval notation. + +// Minimal number of realtime signals reserved for the application. + +// Number of semaphores a process can have. + +// Maximal value of a semaphore. + +// Number of pending realtime signals. + +// Largest value of a `ssize_t'. + +// Number of streams a process can have open at once. + +// The number of bytes in a symbolic link. + +// The number of symbolic links that can be traversed in the +// resolution of a pathname in the absence of a loop. + +// Number of timer for a process. + +// Maximum number of characters in a tty name. + +// Maximum length of a timezone name (element of `tzname'). + +// Maximum clock resolution in nanoseconds. + +// Get the implementation-specific values for the above. +// Minimum guaranteed maximum values for system limits. Linux version. +// Copyright (C) 1993-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// The kernel header pollutes the namespace with the NR_OPEN symbol +// and defines LINK_MAX although filesystems have different maxima. A +// similar thing is true for OPEN_MAX: the limit can be changed at +// runtime and therefore the macro must not be defined. Remove this +// after including the header if necessary. + +// The kernel sources contain a file with all the needed information. +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// Have to remove NR_OPEN? +// Have to remove LINK_MAX? +// Have to remove OPEN_MAX? +// Have to remove ARG_MAX? + +// The number of data keys per process. +// This is the value this implementation supports. + +// Controlling the iterations of destructors for thread-specific data. +// Number of iterations this implementation does. + +// The number of threads per process. +// We have no predefined limit on the number of threads. + +// Maximum amount by which a process can descrease its asynchronous I/O +// priority level. + +// Minimum size for a thread. At least two pages for systems with 64k +// pages. + +// Maximum number of timer expiration overruns. + +// Maximum tty name length. + +// Maximum login name length. This is arbitrary. + +// Maximum host name length. + +// Maximum message queue priority level. + +// Maximum value the semaphore can have. + +// ssize_t is not formally required to be the signed type +// corresponding to size_t, but it is for all configurations supported +// by glibc. + +// This value is a guaranteed minimum maximum. +// The current maximum can be got from `sysconf'. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; include instead. + +// The maximum `ibase' and `obase' values allowed by the `bc' utility. + +// The maximum number of elements allowed in an array by the `bc' utility. + +// The maximum `scale' value allowed by the `bc' utility. + +// The maximum length of a string constant accepted by the `bc' utility. + +// The maximum number of weights that can be assigned to an entry of +// the LC_COLLATE `order' keyword in the locale definition file. + +// The maximum number of expressions that can be nested +// within parentheses by the `expr' utility. + +// The maximum length, in bytes, of an input line. + +// The maximum number of repeated occurrences of a regular expression +// permitted when using the interval notation `\{M,N\}'. + +// The maximum number of bytes in a character class name. We have no +// fixed limit, 2048 is a high number. + +// These values are implementation-specific, +// and may vary within the implementation. +// Their precise values can be obtained from sysconf. + +// This value is defined like this in regex.h. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) any later +// version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// Number of bits in a `char'. + +// Maximum length of a multibyte character. + +// Minimum and maximum values a `signed char' can hold. + +// Maximum value an `unsigned char' can hold. (Minimum is 0). + +// Minimum and maximum values a `char' can hold. + +// Minimum and maximum values a `signed short int' can hold. + +// Maximum value an `unsigned short int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed int' can hold. + +// Maximum value an `unsigned int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long int' can hold. +// (Same as `int'). + +// Maximum value an `unsigned long int' can hold. (Minimum is 0). + +// Minimum and maximum values a `signed long long int' can hold. + +// Maximum value an `unsigned long long int' can hold. (Minimum is 0). + +// This administrivia gets added to the end of limits.h +// if the system has its own version of limits.h. + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/mem.go b/internal/libc/mem.go new file mode 100644 index 0000000..a15ecf8 --- /dev/null +++ b/internal/libc/mem.go @@ -0,0 +1,174 @@ +// Copyright 2021 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !libc.membrk && !libc.memgrind && !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "math" + "math/bits" + + "github.com/hanzoai/sqlite/internal/libc/errno" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + "github.com/hanzoai/sqlite/internal/memory" +) + +const memgrind = false + +var ( + allocator memory.Allocator +) + +// void *malloc(size_t size); +func Xmalloc(t *TLS, n types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v n=%v, (%v:)", t, n, origin(2)) + } + if n == 0 { + // malloc(0) should return unique pointers + // (often expected and gnulib replaces malloc if malloc(0) returns 0) + n = 1 + } + + allocMu.Lock() + + defer allocMu.Unlock() + + p, err := allocator.UintptrMalloc(int(n)) + if err != nil { + t.setErrno(errno.ENOMEM) + return 0 + } + + return p +} + +// void *calloc(size_t nmemb, size_t size); +func Xcalloc(t *TLS, n, size types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v n=%v size=%v, (%v:)", t, n, size, origin(2)) + } + hi, rq0 := bits.Mul(uint(n), uint(size)) + if hi != 0 || rq0 > math.MaxInt { + t.setErrno(errno.ENOMEM) + return 0 + } + rq := int(rq0) + if rq == 0 { + rq = 1 + } + + allocMu.Lock() + + defer allocMu.Unlock() + + p, err := allocator.UintptrCalloc(rq) + if err != nil { + t.setErrno(errno.ENOMEM) + return 0 + } + + return p +} + +// void *realloc(void *ptr, size_t size); +func Xrealloc(t *TLS, ptr uintptr, size types.Size_t) uintptr { + if __ccgo_strace { + trc("t=%v ptr=%v size=%v, (%v:)", t, ptr, size, origin(2)) + } + allocMu.Lock() + + defer allocMu.Unlock() + + p, err := allocator.UintptrRealloc(ptr, int(size)) + if err != nil { + t.setErrno(errno.ENOMEM) + return 0 + } + + return p +} + +// void free(void *ptr); +func Xfree(t *TLS, p uintptr) { + if __ccgo_strace { + trc("t=%v p=%v, (%v:)", t, p, origin(2)) + } + if p == 0 { + return + } + + allocMu.Lock() + + defer allocMu.Unlock() + + allocator.UintptrFree(p) +} + +func Xmalloc_usable_size(tls *TLS, p uintptr) (r types.Size_t) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + if p == 0 { + return 0 + } + + allocMu.Lock() + + defer allocMu.Unlock() + + return types.Size_t(memory.UintptrUsableSize(p)) +} + +func UsableSize(p uintptr) types.Size_t { + allocMu.Lock() + + defer allocMu.Unlock() + + return types.Size_t(memory.UintptrUsableSize(p)) +} + +type MemAllocatorStat struct { + Allocs int + Bytes int + Mmaps int +} + +// MemStat returns the global memory allocator statistics. +// should be compiled with the memory.counters build tag for the data to be available. +func MemStat() MemAllocatorStat { + allocMu.Lock() + defer allocMu.Unlock() + + return MemAllocatorStat{ + Allocs: allocator.Allocs, + Bytes: allocator.Bytes, + Mmaps: allocator.Mmaps, + } +} + +// MemAuditStart locks the memory allocator, initializes and enables memory +// auditing. Finaly it unlocks the memory allocator. +// +// Some memory handling errors, like double free or freeing of unallocated +// memory, will panic when memory auditing is enabled. +// +// This memory auditing functionality has to be enabled using the libc.memgrind +// build tag. +// +// It is intended only for debug/test builds. It slows down memory allocation +// routines and it has additional memory costs. +func MemAuditStart() {} + +// MemAuditReport locks the memory allocator, reports memory leaks, if any. +// Finally it disables memory auditing and unlocks the memory allocator. +// +// This memory auditing functionality has to be enabled using the libc.memgrind +// build tag. +// +// It is intended only for debug/test builds. It slows down memory allocation +// routines and it has additional memory costs. +func MemAuditReport() error { return nil } diff --git a/internal/libc/mem_musl.go b/internal/libc/mem_musl.go new file mode 100644 index 0000000..31e521f --- /dev/null +++ b/internal/libc/mem_musl.go @@ -0,0 +1,170 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !libc.membrk && !libc.memgrind && linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "math" + mbits "math/bits" + + "github.com/hanzoai/sqlite/internal/memory" +) + +const ( + isMemBrk = false +) + +func Xmalloc(tls *TLS, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v n=%v, (%v:)", tls, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + if n > math.MaxInt { + tls.setErrno(ENOMEM) + return 0 + } + + allocatorMu.Lock() + + defer allocatorMu.Unlock() + + if n == 0 { + // malloc(0) should return unique pointers + // (often expected and gnulib replaces malloc if malloc(0) returns 0) + n = 1 + } + var err error + if r, err = allocator.UintptrMalloc(int(n)); err != nil { + r = 0 + tls.setErrno(ENOMEM) + } + return r +} + +func Xcalloc(tls *TLS, m Tsize_t, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v m=%v n=%v, (%v:)", tls, m, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + hi, rq := mbits.Mul(uint(m), uint(n)) + if hi != 0 || rq > math.MaxInt { + tls.setErrno(ENOMEM) + return 0 + } + + allocatorMu.Lock() + + defer allocatorMu.Unlock() + + if rq == 0 { + rq = 1 + } + + var err error + if r, err = allocator.UintptrCalloc(int(rq)); err != nil { + r = 0 + tls.setErrno(ENOMEM) + } + return r +} + +func Xrealloc(tls *TLS, p uintptr, n Tsize_t) (r uintptr) { + if __ccgo_strace { + trc("tls=%v p=%v n=%v, (%v:)", tls, p, n, origin(2)) + defer func() { trc("-> %v", r) }() + } + allocatorMu.Lock() + + defer allocatorMu.Unlock() + + var err error + if r, err = allocator.UintptrRealloc(p, int(n)); err != nil { + r = 0 + tls.setErrno(ENOMEM) + } + return r +} + +func Xfree(tls *TLS, p uintptr) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + } + allocatorMu.Lock() + + defer allocatorMu.Unlock() + + allocator.UintptrFree(p) +} + +func Xmalloc_usable_size(tls *TLS, p uintptr) (r Tsize_t) { + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + defer func() { trc("-> %v", r) }() + } + if p == 0 { + return 0 + } + + allocatorMu.Lock() + + defer allocatorMu.Unlock() + + return Tsize_t(memory.UintptrUsableSize(p)) +} + +func MemAudit() (r []*MemAuditError) { + return nil +} + +func UsableSize(p uintptr) Tsize_t { + allocatorMu.Lock() + + defer allocatorMu.Unlock() + + return Tsize_t(memory.UintptrUsableSize(p)) +} + +type MemAllocatorStat struct { + Allocs int + Bytes int + Mmaps int +} + +// MemStat returns the global memory allocator statistics. +// should be compiled with the memory.counters build tag for the data to be available. +func MemStat() MemAllocatorStat { + allocatorMu.Lock() + defer allocatorMu.Unlock() + + return MemAllocatorStat{ + Allocs: allocator.Allocs, + Bytes: allocator.Bytes, + Mmaps: allocator.Mmaps, + } +} + +// MemAuditStart locks the memory allocator, initializes and enables memory +// auditing. Finaly it unlocks the memory allocator. +// +// Some memory handling errors, like double free or freeing of unallocated +// memory, will panic when memory auditing is enabled. +// +// This memory auditing functionality has to be enabled using the libc.memgrind +// build tag. +// +// It is intended only for debug/test builds. It slows down memory allocation +// routines and it has additional memory costs. +func MemAuditStart() {} + +// MemAuditReport locks the memory allocator, reports memory leaks, if any. +// Finally it disables memory auditing and unlocks the memory allocator. +// +// This memory auditing functionality has to be enabled using the libc.memgrind +// build tag. +// +// It is intended only for debug/test builds. It slows down memory allocation +// routines and it has additional memory costs. +func MemAuditReport() error { return nil } diff --git a/internal/libc/musl_darwin_amd64.go b/internal/libc/musl_darwin_amd64.go new file mode 100644 index 0000000..29081e4 --- /dev/null +++ b/internal/libc/musl_darwin_amd64.go @@ -0,0 +1,4988 @@ +// Code generated by 'ccgo -D__environ=environ -export-externs X -export-fields F -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -hide isascii,isspace,tolower,toupper -nostdinc -nostdlib -o ../musl_darwin_amd64.go -pkgname libc -static-locals-prefix _s -Iarch/x86_64 -Iarch/generic -Iobj/src/internal -Isrc/include -Isrc/internal -Iobj/include -Iinclude copyright.c ../darwin/table.c src/env/putenv.c src/env/setenv.c src/env/unsetenv.c src/internal/floatscan.c src/internal/intscan.c src/internal/shgetc.c src/locale/localeconv.c src/math/__fpclassify.c src/math/__fpclassifyf.c src/math/__fpclassifyl.c src/math/copysignl.c src/math/fabsl.c src/math/fmodl.c src/math/nanf.c src/math/rint.c src/math/scalbn.c src/math/scalbnl.c src/network/freeaddrinfo.c src/network/getaddrinfo.c src/network/gethostbyaddr.c src/network/gethostbyaddr_r.c src/network/gethostbyname.c src/network/gethostbyname2.c src/network/gethostbyname2_r.c src/network/getnameinfo.c src/network/h_errno.c src/network/inet_aton.c src/network/inet_ntop.c src/network/inet_pton.c src/network/lookup_ipliteral.c src/network/lookup_name.c src/network/lookup_serv.c src/prng/rand_r.c src/stdio/__toread.c src/stdio/__uflow.c src/stdlib/bsearch.c src/stdlib/strtod.c src/stdlib/strtol.c src/string/strchrnul.c src/string/strdup.c src/string/strlcat.c src/string/strlcpy.c src/string/strncasecmp.c src/string/strncat.c src/string/strnlen.c src/string/strspn.c src/string/strtok.c', DO NOT EDIT. + +package libc + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +// musl as a whole is licensed under the following standard MIT license: +// +// ---------------------------------------------------------------------- +// Copyright © 2005-2020 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. +// ---------------------------------------------------------------------- +// +// Authors/contributors include: +// +// A. Wilcox +// Ada Worcester +// Alex Dowad +// Alex Suykov +// Alexander Monakov +// Andre McCurdy +// Andrew Kelley +// Anthony G. Basile +// Aric Belsito +// Arvid Picciani +// Bartosz Brachaczek +// Benjamin Peterson +// Bobby Bingham +// Boris Brezillon +// Brent Cook +// Chris Spiegel +// Clément Vasseur +// Daniel Micay +// Daniel Sabogal +// Daurnimator +// David Carlier +// David Edelsohn +// Denys Vlasenko +// Dmitry Ivanov +// Dmitry V. Levin +// Drew DeVault +// Emil Renner Berthing +// Fangrui Song +// Felix Fietkau +// Felix Janda +// Gianluca Anzolin +// Hauke Mehrtens +// He X +// Hiltjo Posthuma +// Isaac Dunham +// Jaydeep Patil +// Jens Gustedt +// Jeremy Huntwork +// Jo-Philipp Wich +// Joakim Sindholt +// John Spencer +// Julien Ramseier +// Justin Cormack +// Kaarle Ritvanen +// Khem Raj +// Kylie McClain +// Leah Neukirchen +// Luca Barbato +// Luka Perkov +// M Farkas-Dyck (Strake) +// Mahesh Bodapati +// Markus Wichmann +// Masanori Ogino +// Michael Clark +// Michael Forney +// Mikhail Kremnyov +// Natanael Copa +// Nicholas J. Kain +// orc +// Pascal Cuoq +// Patrick Oppenlander +// Petr Hosek +// Petr Skocik +// Pierre Carrier +// Reini Urban +// Rich Felker +// Richard Pennington +// Ryan Fairfax +// Samuel Holland +// Segev Finer +// Shiz +// sin +// Solar Designer +// Stefan Kristiansson +// Stefan O'Rear +// Szabolcs Nagy +// Timo Teräs +// Trutz Behn +// Valentin Ochs +// Will Dietz +// William Haddon +// William Pitcock +// +// Portions of this software are derived from third-party works licensed +// under terms compatible with the above MIT license: +// +// The TRE regular expression implementation (src/regex/reg* and +// src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed +// under a 2-clause BSD license (license text in the source files). The +// included version has been heavily modified by Rich Felker in 2012, in +// the interests of size, simplicity, and namespace cleanliness. +// +// Much of the math library code (src/math/* and src/complex/*) is +// Copyright © 1993,2004 Sun Microsystems or +// Copyright © 2003-2011 David Schultz or +// Copyright © 2003-2009 Steven G. Kargl or +// Copyright © 2003-2009 Bruce D. Evans or +// Copyright © 2008 Stephen L. Moshier or +// Copyright © 2017-2018 Arm Limited +// and labelled as such in comments in the individual source files. All +// have been licensed under extremely permissive terms. +// +// The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008 +// The Android Open Source Project and is licensed under a two-clause BSD +// license. It was taken from Bionic libc, used on Android. +// +// The AArch64 memcpy and memset code (src/string/aarch64/*) are +// Copyright © 1999-2019, Arm Limited. +// +// The implementation of DES for crypt (src/crypt/crypt_des.c) is +// Copyright © 1994 David Burren. It is licensed under a BSD license. +// +// The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was +// originally written by Solar Designer and placed into the public +// domain. The code also comes with a fallback permissive license for use +// in jurisdictions that may not recognize the public domain. +// +// The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011 +// Valentin Ochs and is licensed under an MIT-style license. +// +// The x86_64 port was written by Nicholas J. Kain and is licensed under +// the standard MIT terms. +// +// The mips and microblaze ports were originally written by Richard +// Pennington for use in the ellcc project. The original code was adapted +// by Rich Felker for build system and code conventions during upstream +// integration. It is licensed under the standard MIT terms. +// +// The mips64 port was contributed by Imagination Technologies and is +// licensed under the standard MIT terms. +// +// The powerpc port was also originally written by Richard Pennington, +// and later supplemented and integrated by John Spencer. It is licensed +// under the standard MIT terms. +// +// All other files which have no copyright comments are original works +// produced specifically for use as part of this library, written either +// by Rich Felker, the main author of the library, or by one or more +// contibutors listed above. Details on authorship of individual files +// can be found in the git version control history of the project. The +// omission of copyright and license comments in each file is in the +// interest of source tree size. +// +// In addition, permission is hereby granted for all public header files +// (include/* and arch/*/bits/*) and crt files intended to be linked into +// applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit +// the copyright notice and permission notice otherwise required by the +// license, and to use these files without any requirement of +// attribution. These files include substantial contributions from: +// +// Bobby Bingham +// John Spencer +// Nicholas J. Kain +// Rich Felker +// Richard Pennington +// Stefan Kristiansson +// Szabolcs Nagy +// +// all of whom have explicitly granted such permission. +// +// This file previously contained text expressing a belief that most of +// the files covered by the above exception were sufficiently trivial not +// to be subject to copyright, resulting in confusion over whether it +// negated the permissions granted in the license. In the spirit of +// permissive licensing, and of not having licensing issues being an +// obstacle to adoption, that text has been removed. +const ( /* copyright.c:194:1: */ + __musl__copyright__ = 0 +) + +const ( /* nameser.h:117:1: */ + ns_uop_delete = 0 + ns_uop_add = 1 + ns_uop_max = 2 +) + +const ( /* nameser.h:147:1: */ + ns_t_invalid = 0 + ns_t_a = 1 + ns_t_ns = 2 + ns_t_md = 3 + ns_t_mf = 4 + ns_t_cname = 5 + ns_t_soa = 6 + ns_t_mb = 7 + ns_t_mg = 8 + ns_t_mr = 9 + ns_t_null = 10 + ns_t_wks = 11 + ns_t_ptr = 12 + ns_t_hinfo = 13 + ns_t_minfo = 14 + ns_t_mx = 15 + ns_t_txt = 16 + ns_t_rp = 17 + ns_t_afsdb = 18 + ns_t_x25 = 19 + ns_t_isdn = 20 + ns_t_rt = 21 + ns_t_nsap = 22 + ns_t_nsap_ptr = 23 + ns_t_sig = 24 + ns_t_key = 25 + ns_t_px = 26 + ns_t_gpos = 27 + ns_t_aaaa = 28 + ns_t_loc = 29 + ns_t_nxt = 30 + ns_t_eid = 31 + ns_t_nimloc = 32 + ns_t_srv = 33 + ns_t_atma = 34 + ns_t_naptr = 35 + ns_t_kx = 36 + ns_t_cert = 37 + ns_t_a6 = 38 + ns_t_dname = 39 + ns_t_sink = 40 + ns_t_opt = 41 + ns_t_apl = 42 + ns_t_tkey = 249 + ns_t_tsig = 250 + ns_t_ixfr = 251 + ns_t_axfr = 252 + ns_t_mailb = 253 + ns_t_maila = 254 + ns_t_any = 255 + ns_t_zxfr = 256 + ns_t_max = 65536 +) + +const ( /* nameser.h:210:1: */ + ns_c_invalid = 0 + ns_c_in = 1 + ns_c_2 = 2 + ns_c_chaos = 3 + ns_c_hs = 4 + ns_c_none = 254 + ns_c_any = 255 + ns_c_max = 65536 +) + +const ( /* nameser.h:221:1: */ + ns_kt_rsa = 1 + ns_kt_dh = 2 + ns_kt_dsa = 3 + ns_kt_private = 254 +) + +const ( /* nameser.h:228:1: */ + cert_t_pkix = 1 + cert_t_spki = 2 + cert_t_pgp = 3 + cert_t_url = 253 + cert_t_oid = 254 +) + +const ( /* nameser.h:28:1: */ + ns_s_qd = 0 + ns_s_zn = 0 + ns_s_an = 1 + ns_s_pr = 1 + ns_s_ns = 2 + ns_s_ud = 2 + ns_s_ar = 3 + ns_s_max = 4 +) + +const ( /* nameser.h:75:1: */ + ns_f_qr = 0 + ns_f_opcode = 1 + ns_f_aa = 2 + ns_f_tc = 3 + ns_f_rd = 4 + ns_f_ra = 5 + ns_f_z = 6 + ns_f_ad = 7 + ns_f_cd = 8 + ns_f_rcode = 9 + ns_f_max = 10 +) + +const ( /* nameser.h:89:1: */ + ns_o_query = 0 + ns_o_iquery = 1 + ns_o_status = 2 + ns_o_notify = 4 + ns_o_update = 5 + ns_o_max = 6 +) + +const ( /* nameser.h:98:1: */ + ns_r_noerror = 0 + ns_r_formerr = 1 + ns_r_servfail = 2 + ns_r_nxdomain = 3 + ns_r_notimpl = 4 + ns_r_refused = 5 + ns_r_yxdomain = 6 + ns_r_yxrrset = 7 + ns_r_nxrrset = 8 + ns_r_notauth = 9 + ns_r_notzone = 10 + ns_r_max = 11 + ns_r_badvers = 16 + ns_r_badsig = 16 + ns_r_badkey = 17 + ns_r_badtime = 18 +) + +type ptrdiff_t = int64 /* :3:26 */ + +type size_t = uint64 /* :9:23 */ + +type wchar_t = int32 /* :15:24 */ + +// /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_fd_def.h:54 +// int __darwin_check_fd_set_overflow(int, const void *, int) __API_AVAILABLE(macosx(11.0), ios(14.0), tvos(14.0), watchos(7.0)); +func X__darwin_check_fd_set_overflow(tls *TLS, _ int32, _ uintptr, _ int32) int32 { + return 1 +} + +// pthread opaque structures + +type __darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* table.c:1396:1 */ + +type _opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* table.c:1402:1 */ + +type _opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* table.c:1407:1 */ + +type _opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* table.c:1412:1 */ + +type _opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* table.c:1417:1 */ + +type _opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* table.c:1422:1 */ + +type _opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* table.c:1427:1 */ + +type _opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* table.c:1432:1 */ + +type _opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* table.c:1437:1 */ + +type _opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* table.c:1442:1 */ + +type ct_rune_t = int32 /* table.c:1527:28 */ + +type rune_t = int32 /* table.c:1536:25 */ + +type wint_t = int32 /* table.c:1558:25 */ + +type _RuneEntry = struct { + F__min int32 + F__max int32 + F__map int32 + F__ccgo_pad1 [4]byte + F__types uintptr +} /* table.c:1575:3 */ + +type _RuneRange = struct { + F__nranges int32 + F__ccgo_pad1 [4]byte + F__ranges uintptr +} /* table.c:1580:3 */ + +type _RuneCharClass = struct { + F__name [14]int8 + F__ccgo_pad1 [2]byte + F__mask uint32 +} /* table.c:1585:3 */ + +type _RuneLocale = struct { + F__magic [8]int8 + F__encoding [32]int8 + F__sgetrune uintptr + F__sputrune uintptr + F__invalid_rune int32 + F__runetype [256]uint32 + F__maplower [256]int32 + F__mapupper [256]int32 + F__ccgo_pad1 [4]byte + F__runetype_ext _RuneRange + F__maplower_ext _RuneRange + F__mapupper_ext _RuneRange + F__variable uintptr + F__variable_len int32 + F__ncharclasses int32 + F__charclasses uintptr +} /* table.c:1616:3 */ + +func X__istype(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1670:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2)) + } + + return func() int32 { + if Xisascii(tls, _c) != 0 { + return BoolInt32(!!(uint64(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c)*4)))&_f != 0)) + } + return BoolInt32(!!(X__maskrune(tls, _c, _f) != 0)) + }() + +} + +func X__isctype(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1681:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2)) + } + + if _c < 0 || _c >= int32(1)<<8 { + return 0 + } + return BoolInt32(!!(uint64(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c)*4)))&_f != 0)) + +} + +func X__wcwidth(tls *TLS, _c int32) int32 { /* table.c:1700:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + var _x uint32 + + if _c == 0 { + return 0 + } + _x = uint32(X__maskrune(tls, _c, uint64(0xe0000000|0x00040000))) + if int64(_x)&0xe0000000 != int64(0) { + return int32(int64(_x) & 0xe0000000 >> 30) + } + return func() int32 { + if int64(_x)&0x00040000 != int64(0) { + return 1 + } + return -1 + }() +} + +func Xisalnum(tls *TLS, _c int32) int32 { /* table.c:1718:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000100|0x00000400)) +} + +func Xisalpha(tls *TLS, _c int32) int32 { /* table.c:1724:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000100)) +} + +func Xisblank(tls *TLS, _c int32) int32 { /* table.c:1730:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00020000)) +} + +func Xiscntrl(tls *TLS, _c int32) int32 { /* table.c:1736:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000200)) +} + +func Xisdigit(tls *TLS, _c int32) int32 { /* table.c:1743:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__isctype(tls, _c, uint64(0x00000400)) +} + +func Xisgraph(tls *TLS, _c int32) int32 { /* table.c:1749:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000800)) +} + +func Xislower(tls *TLS, _c int32) int32 { /* table.c:1755:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00001000)) +} + +func Xisprint(tls *TLS, _c int32) int32 { /* table.c:1761:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00040000)) +} + +func Xispunct(tls *TLS, _c int32) int32 { /* table.c:1767:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00002000)) +} + +func Xisupper(tls *TLS, _c int32) int32 { /* table.c:1779:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00008000)) +} + +func Xisxdigit(tls *TLS, _c int32) int32 { /* table.c:1786:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__isctype(tls, _c, uint64(0x00010000)) +} + +func Xtoascii(tls *TLS, _c int32) int32 { /* table.c:1792:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return _c & 0x7F +} + +func Xdigittoint(tls *TLS, _c int32) int32 { /* table.c:1811:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__maskrune(tls, _c, uint64(0x0F)) +} + +func Xishexnumber(tls *TLS, _c int32) int32 { /* table.c:1817:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00010000)) +} + +func Xisideogram(tls *TLS, _c int32) int32 { /* table.c:1823:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00080000)) +} + +func Xisnumber(tls *TLS, _c int32) int32 { /* table.c:1829:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000400)) +} + +func Xisphonogram(tls *TLS, _c int32) int32 { /* table.c:1835:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00200000)) +} + +func Xisrune(tls *TLS, _c int32) int32 { /* table.c:1841:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0xFFFFFFF0)) +} + +func Xisspecial(tls *TLS, _c int32) int32 { /* table.c:1847:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00100000)) +} + +func X__maskrune(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1871:2: */ + if __ccgo_strace { + trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2)) + } + return int32(uint32(int32(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c&0xff)*4)))) & uint32(_f)) +} + +func X__toupper(tls *TLS, c int32) int32 { /* table.c:1876:20: */ + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + } + return Xtoupper(tls, c) +} + +func X__tolower(tls *TLS, c int32) int32 { /* table.c:1878:20: */ + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + } + return Xtolower(tls, c) +} + +var X_DefaultRuneLocale = _RuneLocale{F__magic: [8]int8{int8(82), int8(117), int8(110), int8(101), int8(77), int8(97), int8(103), int8(65)}, F__encoding: [32]int8{int8(78), int8(79), int8(78), int8(69), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0)}, F__invalid_rune: 0xfffd, F__runetype: [256]uint32{ + uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x24200), uint32(0x4200), uint32(0x4200), uint32(0x4200), uint32(0x4200), uint32(0x200), uint32(0x200), + uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), + uint32(0x64000), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), + uint32(0x50c00), uint32(0x50c01), uint32(0x50c02), uint32(0x50c03), uint32(0x50c04), uint32(0x50c05), uint32(0x50c06), uint32(0x50c07), uint32(0x50c08), uint32(0x50c09), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), + uint32(0x42800), uint32(0x5890a), uint32(0x5890b), uint32(0x5890c), uint32(0x5890d), uint32(0x5890e), uint32(0x5890f), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), + uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), + uint32(0x42800), uint32(0x5190a), uint32(0x5190b), uint32(0x5190c), uint32(0x5190d), uint32(0x5190e), uint32(0x5190f), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), + uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x200), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), +}, F__maplower: [256]int32{ + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 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, +}, F__mapupper: [256]int32{ + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 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, +}, +} /* table.c:1879:13 */ + +var X_CurrentRuneLocale uintptr = 0 /* table.c:1940:13 */ + +type div_t = struct { + Fquot int32 + Frem int32 +} /* stdlib.h:62:35 */ +type ldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:63:36 */ +type lldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:64:41 */ + +type locale_t = uintptr /* alltypes.h:343:32 */ + +type ssize_t = int64 /* alltypes.h:65:15 */ + +type intptr_t = int64 /* alltypes.h:70:15 */ + +type off_t = int64 /* alltypes.h:162:16 */ + +type pid_t = int32 /* alltypes.h:235:13 */ + +type uid_t = uint32 /* alltypes.h:245:18 */ + +type gid_t = uint32 /* alltypes.h:250:18 */ + +type useconds_t = uint32 /* alltypes.h:260:18 */ + +func X__putenv(tls *TLS, s uintptr, l size_t, r uintptr) int32 { /* putenv.c:8:5: */ + if __ccgo_strace { + trc("tls=%v s=%v l=%v r=%v, (%v:)", tls, s, l, r, origin(2)) + } + var i size_t + var newenv uintptr + var tmp uintptr + //TODO for (char **e = __environ; *e; e++, i++) + var e uintptr + i = uint64(0) + if !(Environ() != 0) { + goto __1 + } + //TODO for (char **e = __environ; *e; e++, i++) + e = Environ() +__2: + if !(*(*uintptr)(unsafe.Pointer(e)) != 0) { + goto __4 + } + if !!(Xstrncmp(tls, s, *(*uintptr)(unsafe.Pointer(e)), l+uint64(1)) != 0) { + goto __5 + } + tmp = *(*uintptr)(unsafe.Pointer(e)) + *(*uintptr)(unsafe.Pointer(e)) = s + X__env_rm_add(tls, tmp, r) + return 0 +__5: + ; + goto __3 +__3: + e += 8 + i++ + goto __2 + goto __4 +__4: + ; +__1: + ; + if !(Environ() == _soldenv) { + goto __6 + } + newenv = Xrealloc(tls, _soldenv, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2))) + if !!(newenv != 0) { + goto __8 + } + goto oom +__8: + ; + goto __7 +__6: + newenv = Xmalloc(tls, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2))) + if !!(newenv != 0) { + goto __9 + } + goto oom +__9: + ; + if !(i != 0) { + goto __10 + } + Xmemcpy(tls, newenv, Environ(), uint64(unsafe.Sizeof(uintptr(0)))*i) +__10: + ; + Xfree(tls, _soldenv) +__7: + ; + *(*uintptr)(unsafe.Pointer(newenv + uintptr(i)*8)) = s + *(*uintptr)(unsafe.Pointer(newenv + uintptr(i+uint64(1))*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(EnvironP())) = AssignPtrUintptr(uintptr(unsafe.Pointer(&_soldenv)), newenv) + if !(r != 0) { + goto __11 + } + X__env_rm_add(tls, uintptr(0), r) +__11: + ; + return 0 +oom: + Xfree(tls, r) + return -1 +} + +var _soldenv uintptr /* putenv.c:22:14: */ + +func Xputenv(tls *TLS, s uintptr) int32 { /* putenv.c:43:5: */ + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + } + var l size_t = size_t((int64(X__strchrnul(tls, s, '=')) - int64(s)) / 1) + if !(l != 0) || !(int32(*(*int8)(unsafe.Pointer(s + uintptr(l)))) != 0) { + return Xunsetenv(tls, s) + } + return X__putenv(tls, s, l, uintptr(0)) +} + +func X__env_rm_add(tls *TLS, old uintptr, new uintptr) { /* setenv.c:5:6: */ + if __ccgo_strace { + trc("tls=%v old=%v new=%v, (%v:)", tls, old, new, origin(2)) + } + //TODO for (size_t i=0; i < env_alloced_n; i++) + var i size_t = uint64(0) + for ; i < _senv_alloced_n; i++ { + if *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) == old { + *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new + Xfree(tls, old) + return + } else if !(int32(*(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8))) != 0) && new != 0 { + *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new + new = uintptr(0) + } + } + if !(new != 0) { + return + } + var t uintptr = Xrealloc(tls, _senv_alloced, uint64(unsafe.Sizeof(uintptr(0)))*(_senv_alloced_n+uint64(1))) + if !(t != 0) { + return + } + *(*uintptr)(unsafe.Pointer(AssignPtrUintptr(uintptr(unsafe.Pointer(&_senv_alloced)), t) + uintptr(PostIncUint64(&_senv_alloced_n, 1))*8)) = new +} + +var _senv_alloced uintptr /* setenv.c:7:14: */ +var _senv_alloced_n size_t /* setenv.c:8:16: */ + +func Xsetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) int32 { /* setenv.c:26:5: */ + if __ccgo_strace { + trc("tls=%v var1=%v value=%v overwrite=%v, (%v:)", tls, var1, value, overwrite, origin(2)) + } + var s uintptr + var l1 size_t + var l2 size_t + + if !(var1 != 0) || !(int32(AssignUint64(&l1, size_t((int64(X__strchrnul(tls, var1, '='))-int64(var1))/1))) != 0) || *(*int8)(unsafe.Pointer(var1 + uintptr(l1))) != 0 { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + return -1 + } + if !(overwrite != 0) && Xgetenv(tls, var1) != 0 { + return 0 + } + + l2 = Xstrlen(tls, value) + s = Xmalloc(tls, l1+l2+uint64(2)) + if !(s != 0) { + return -1 + } + Xmemcpy(tls, s, var1, l1) + *(*int8)(unsafe.Pointer(s + uintptr(l1))) = int8('=') + Xmemcpy(tls, s+uintptr(l1)+uintptr(1), value, l2+uint64(1)) + return X__putenv(tls, s, l1, s) +} + +func Xunsetenv(tls *TLS, name uintptr) int32 { /* unsetenv.c:9:5: */ + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + } + var l size_t = size_t((int64(X__strchrnul(tls, name, '=')) - int64(name)) / 1) + if !(l != 0) || *(*int8)(unsafe.Pointer(name + uintptr(l))) != 0 { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + return -1 + } + if Environ() != 0 { + var e uintptr = Environ() + var eo uintptr = e + for ; *(*uintptr)(unsafe.Pointer(e)) != 0; e += 8 { + //TODO if (!strncmp(name, *e, l) && l[*e] == '=') + if !(Xstrncmp(tls, name, *(*uintptr)(unsafe.Pointer(e)), l) != 0) && int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(e)) + uintptr(l)))) == '=' { + X__env_rm_add(tls, *(*uintptr)(unsafe.Pointer(e)), uintptr(0)) + } else if eo != e { + *(*uintptr)(unsafe.Pointer(PostIncUintptr(&eo, 8))) = *(*uintptr)(unsafe.Pointer(e)) + } else { + eo += 8 + } + } + if eo != e { + *(*uintptr)(unsafe.Pointer(eo)) = uintptr(0) + } + } + return 0 +} + +type uintptr_t = uint64 /* alltypes.h:55:24 */ + +type int8_t = int8 /* alltypes.h:96:25 */ + +type int16_t = int16 /* alltypes.h:101:25 */ + +type int32_t = int32 /* alltypes.h:106:25 */ + +type int64_t = int64 /* alltypes.h:111:25 */ + +type intmax_t = int64 /* alltypes.h:116:25 */ + +type uint8_t = uint8 /* alltypes.h:121:25 */ + +type uint16_t = uint16 /* alltypes.h:126:25 */ + +type uint32_t = uint32 /* alltypes.h:131:25 */ + +type uint64_t = uint64 /* alltypes.h:136:25 */ + +type uintmax_t = uint64 /* alltypes.h:146:25 */ + +type int_fast8_t = int8_t /* stdint.h:22:16 */ +type int_fast64_t = int64_t /* stdint.h:23:17 */ + +type int_least8_t = int8_t /* stdint.h:25:17 */ +type int_least16_t = int16_t /* stdint.h:26:17 */ +type int_least32_t = int32_t /* stdint.h:27:17 */ +type int_least64_t = int64_t /* stdint.h:28:17 */ + +type uint_fast8_t = uint8_t /* stdint.h:30:17 */ +type uint_fast64_t = uint64_t /* stdint.h:31:18 */ + +type uint_least8_t = uint8_t /* stdint.h:33:18 */ +type uint_least16_t = uint16_t /* stdint.h:34:18 */ +type uint_least32_t = uint32_t /* stdint.h:35:18 */ +type uint_least64_t = uint64_t /* stdint.h:36:18 */ + +type int_fast16_t = int32_t /* stdint.h:1:17 */ +type int_fast32_t = int32_t /* stdint.h:2:17 */ +type uint_fast16_t = uint32_t /* stdint.h:3:18 */ +type uint_fast32_t = uint32_t /* stdint.h:4:18 */ + +type _IO_FILE = struct { + Fflags uint32 + F__ccgo_pad1 [4]byte + Frpos uintptr + Frend uintptr + Fclose uintptr + Fwend uintptr + Fwpos uintptr + Fmustbezero_1 uintptr + Fwbase uintptr + Fread uintptr + Fwrite uintptr + Fseek uintptr + Fbuf uintptr + Fbuf_size size_t + Fprev uintptr + Fnext uintptr + Ffd int32 + Fpipe_pid int32 + Flockcount int64 + Fmode int32 + Flock int32 + Flbf int32 + F__ccgo_pad2 [4]byte + Fcookie uintptr + Foff off_t + Fgetln_buf uintptr + Fmustbezero_2 uintptr + Fshend uintptr + Fshlim off_t + Fshcnt off_t + Fprev_locked uintptr + Fnext_locked uintptr + Flocale uintptr +} /* alltypes.h:320:9 */ + +type FILE = _IO_FILE /* alltypes.h:320:25 */ + +type va_list = uintptr /* alltypes.h:326:27 */ + +type _G_fpos64_t = struct { + F__ccgo_pad1 [0]uint64 + F__opaque [16]int8 +} /* stdio.h:54:9 */ + +type fpos_t = _G_fpos64_t /* stdio.h:58:3 */ + +type float_t = float32 /* alltypes.h:29:15 */ + +type double_t = float64 /* alltypes.h:34:16 */ + +func __FLOAT_BITS(tls *TLS, __f float32) uint32 { /* math.h:55:26: */ + bp := tls.Alloc(4) + defer tls.Free(4) + + // var __u struct {F__f float32;} at bp, 4 + + *(*float32)(unsafe.Pointer(bp)) = __f + return *(*uint32)(unsafe.Pointer(bp)) +} + +func __DOUBLE_BITS(tls *TLS, __f float64) uint64 { /* math.h:61:36: */ + bp := tls.Alloc(8) + defer tls.Free(8) + + // var __u struct {F__f float64;} at bp, 8 + + *(*float64)(unsafe.Pointer(bp)) = __f + return *(*uint64)(unsafe.Pointer(bp)) +} + +func __isspace(tls *TLS, _c int32) int32 { /* ctype.h:26:21: */ + return Bool32(_c == ' ' || uint32(_c)-uint32('\t') < uint32(5)) +} + +type syscall_arg_t = int64 /* syscall.h:22:14 */ + +func scanexp(tls *TLS, f uintptr, pok int32) int64 { /* floatscan.c:37:18: */ + var c int32 + var x int32 + var y int64 + var neg int32 = 0 + + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if c == '+' || c == '-' { + neg = Bool32(c == '-') + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if uint32(c-'0') >= 10 && pok != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + } + if uint32(c-'0') >= 10 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + return -0x7fffffffffffffff - int64(1) + } + for x = 0; uint32(c-'0') < 10 && x < 0x7fffffff/10; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + x = 10*x + c - '0' + } + for y = int64(x); uint32(c-'0') < 10 && y < 0x7fffffffffffffff/int64(100); c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + y = int64(10)*y + int64(c) - int64('0') + } + for ; uint32(c-'0') < 10; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if neg != 0 { + return -y + } + return y +} + +func decfloat(tls *TLS, f uintptr, c int32, bits int32, emin int32, sign int32, pok int32) float64 { /* floatscan.c:64:20: */ + bp := tls.Alloc(512) + defer tls.Free(512) + + // var x [128]uint32_t at bp, 512 + + var i int32 + var j int32 + var k int32 + var a int32 + var z int32 + var lrp int64 = int64(0) + var dc int64 = int64(0) + var e10 int64 = int64(0) + var lnz int32 = 0 + var gotdig int32 = 0 + var gotrad int32 = 0 + var rp int32 + var e2 int32 + var emax int32 = -emin - bits + 3 + var denormal int32 = 0 + var y float64 + var frac float64 = float64(0) + var bias float64 = float64(0) + + j = 0 + k = 0 + + // Don't let leading zeros consume buffer space + for ; c == '0'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + gotdig = 1 + } + if c == '.' { + gotrad = 1 + for c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }(); c == '0'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + gotdig = 1 + lrp-- + } + } + + *(*uint32_t)(unsafe.Pointer(bp)) = uint32_t(0) + for ; uint32(c-'0') < 10 || c == '.'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + if c == '.' { + if gotrad != 0 { + break + } + gotrad = 1 + lrp = dc + } else if k < 128-3 { + dc++ + if c != '0' { + lnz = int32(dc) + } + if j != 0 { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))*uint32_t(10) + uint32_t(c) - uint32_t('0') + } else { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(c - '0') + } + if PreIncInt32(&j, 1) == 9 { + k++ + j = 0 + } + gotdig = 1 + } else { + dc++ + if c != '0' { + lnz = (128 - 4) * 9 + *(*uint32_t)(unsafe.Pointer(bp + 124*4)) |= uint32_t(1) + } + } + } + if !(gotrad != 0) { + lrp = dc + } + + if gotdig != 0 && c|32 == 'e' { + e10 = scanexp(tls, f, pok) + if e10 == -0x7fffffffffffffff-int64(1) { + if pok != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } else { + X__shlim(tls, f, int64(0)) + return float64(0) + } + e10 = int64(0) + } + lrp = lrp + e10 + } else if c >= 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + if !(gotdig != 0) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + X__shlim(tls, f, int64(0)) + return float64(0) + } + + // Handle zero specially to avoid nasty special cases later + if !(int32(*(*uint32_t)(unsafe.Pointer(bp))) != 0) { + return float64(sign) * 0.0 + } + + // Optimize small integers (w/no exponent) and over/under-flow + if lrp == dc && dc < int64(10) && (bits > 30 || *(*uint32_t)(unsafe.Pointer(bp))>>bits == uint32_t(0)) { + return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) + } + if lrp > int64(-emin/2) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308 + } + if lrp < int64(emin-2*53) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308 + } + + // Align incomplete final B1B digit + if j != 0 { + for ; j < 9; j++ { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) *= uint32_t(10) + } + k++ + j = 0 + } + + a = 0 + z = k + e2 = 0 + rp = int32(lrp) + + // Optimize small to mid-size integers (even in exp. notation) + if lnz < 9 && lnz <= rp && rp < 18 { + if rp == 9 { + return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) + } + if rp < 9 { + return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) / float64(_sp10s[8-rp]) + } + var bitlim int32 = bits - 3*(rp-9) + if bitlim > 30 || *(*uint32_t)(unsafe.Pointer(bp))>>bitlim == uint32_t(0) { + return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) * float64(_sp10s[rp-10]) + } + } + + // Drop trailing zeros + for ; !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(z-1)*4))) != 0); z-- { + } + + // Align radix point to B1B digit boundary + if rp%9 != 0 { + var rpm9 int32 + if rp >= 0 { + rpm9 = rp % 9 + } else { + rpm9 = rp%9 + 9 + } + var p10 int32 = _sp10s[8-rpm9] + var carry uint32_t = uint32_t(0) + for k = a; k != z; k++ { + var tmp uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) % uint32_t(p10) + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))/uint32_t(p10) + carry + carry = uint32_t(1000000000/p10) * tmp + if k == a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) { + a = (a + 1) & (128 - 1) + rp = rp - 9 + } + } + if carry != 0 { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(PostIncInt32(&z, 1))*4)) = carry + } + rp = rp + (9 - rpm9) + } + + // Upscale until desired number of bits are left of radix point + for rp < 9*2 || rp == 9*2 && *(*uint32_t)(unsafe.Pointer(bp + uintptr(a)*4)) < _sth[0] { + var carry uint32_t = uint32_t(0) + e2 = e2 - 29 + for k = (z - 1) & (128 - 1); ; k = (k - 1) & (128 - 1) { + var tmp uint64_t = uint64_t(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)))<<29 + uint64_t(carry) + if tmp > uint64(1000000000) { + carry = uint32_t(tmp / uint64(1000000000)) + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(tmp % uint64(1000000000)) + } else { + carry = uint32_t(0) + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(tmp) + } + if k == (z-1)&(128-1) && k != a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) { + z = k + } + if k == a { + break + } + } + if carry != 0 { + rp = rp + 9 + a = (a - 1) & (128 - 1) + if a == z { + z = (z - 1) & (128 - 1) + *(*uint32_t)(unsafe.Pointer(bp + uintptr((z-1)&(128-1))*4)) |= *(*uint32_t)(unsafe.Pointer(bp + uintptr(z)*4)) + } + *(*uint32_t)(unsafe.Pointer(bp + uintptr(a)*4)) = carry + } + } + + // Downscale until exactly number of bits are left of radix point + for { + var carry uint32_t = uint32_t(0) + var sh int32 = 1 + for i = 0; i < 2; i++ { + k = (a + i) & (128 - 1) + if k == z || *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) < _sth[i] { + i = 2 + break + } + if *(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4)) > _sth[i] { + break + } + } + if i == 2 && rp == 9*2 { + break + } + // FIXME: find a way to compute optimal sh + if rp > 9+9*2 { + sh = 9 + } + e2 = e2 + sh + for k = a; k != z; k = (k + 1) & (128 - 1) { + var tmp uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) & uint32_t(int32(1)<>sh + carry + carry = uint32_t(int32(1000000000)>>sh) * tmp + if k == a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) { + a = (a + 1) & (128 - 1) + i-- + rp = rp - 9 + } + } + if carry != 0 { + if (z+1)&(128-1) != a { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(z)*4)) = carry + z = (z + 1) & (128 - 1) + } else { + *(*uint32_t)(unsafe.Pointer(bp + uintptr((z-1)&(128-1))*4)) |= uint32_t(1) + } + } + } + + // Assemble desired bits into floating point variable + for y = float64(AssignInt32(&i, 0)); i < 2; i++ { + if (a+i)&(128-1) == z { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(AssignInt32(&z, (z+1)&(128-1))-1)*4)) = uint32_t(0) + } + y = 1000000000.0*y + float64(*(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4))) + } + + y = y * float64(sign) + + // Limit precision for denormal results + if bits > 53+e2-emin { + bits = 53 + e2 - emin + if bits < 0 { + bits = 0 + } + denormal = 1 + } + + // Calculate bias term to force rounding, move out lower bits + if bits < 53 { + bias = Xcopysignl(tls, Xscalbn(tls, float64(1), 2*53-bits-1), y) + frac = Xfmodl(tls, y, Xscalbn(tls, float64(1), 53-bits)) + y = y - frac + y = y + bias + } + + // Process tail of decimal input so it can affect rounding + if (a+i)&(128-1) != z { + var t uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4)) + if t < uint32_t(500000000) && (t != 0 || (a+i+1)&(128-1) != z) { + frac = frac + 0.25*float64(sign) + } else if t > uint32_t(500000000) { + frac = frac + 0.75*float64(sign) + } else if t == uint32_t(500000000) { + if (a+i+1)&(128-1) == z { + frac = frac + 0.5*float64(sign) + } else { + frac = frac + 0.75*float64(sign) + } + } + if 53-bits >= 2 && !(Xfmodl(tls, frac, float64(1)) != 0) { + frac += 1 + } + } + + y = y + frac + y = y - bias + + if (e2+53)&0x7fffffff > emax-5 { + if Xfabsl(tls, y) >= float64(float64(2))/2.22044604925031308085e-16 { + if denormal != 0 && bits == 53+e2-emin { + denormal = 0 + } + y = y * 0.5 + e2++ + } + if e2+53 > emax || denormal != 0 && frac != 0 { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + } + } + + return Xscalbnl(tls, y, e2) +} + +var _sth = [2]uint32_t{uint32_t(9007199), uint32_t(254740991)} /* floatscan.c:67:24 */ +var _sp10s = [8]int32{10, 100, 1000, 10000, + 100000, 1000000, 10000000, 100000000} /* floatscan.c:80:19 */ + +func hexfloat(tls *TLS, f uintptr, bits int32, emin int32, sign int32, pok int32) float64 { /* floatscan.c:315:20: */ + var x uint32_t = uint32_t(0) + var y float64 = float64(0) + var scale float64 = float64(1) + var bias float64 = float64(0) + var gottail int32 = 0 + var gotrad int32 = 0 + var gotdig int32 = 0 + var rp int64 = int64(0) + var dc int64 = int64(0) + var e2 int64 = int64(0) + var d int32 + var c int32 + + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + + // Skip leading zeros + for ; c == '0'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + gotdig = 1 + } + + if c == '.' { + gotrad = 1 + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + // Count zeros after the radix point before significand + rp = int64(0) + __1: + if !(c == '0') { + goto __3 + } + gotdig = 1 + goto __2 + __2: + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + rp-- + goto __1 + goto __3 + __3: + } + + for ; uint32(c-'0') < 10 || uint32(c|32-'a') < 6 || c == '.'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + if c == '.' { + if gotrad != 0 { + break + } + rp = dc + gotrad = 1 + } else { + gotdig = 1 + if c > '9' { + d = c | 32 + 10 - 'a' + } else { + d = c - '0' + } + if dc < int64(8) { + x = x*uint32_t(16) + uint32_t(d) + } else if dc < int64(53/4+1) { + y = y + float64(d)*AssignDivFloat64(&scale, float64(16)) + } else if d != 0 && !(gottail != 0) { + y = y + 0.5*scale + gottail = 1 + } + dc++ + } + } + if !(gotdig != 0) { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if pok != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if gotrad != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + } else { + X__shlim(tls, f, int64(0)) + } + return float64(sign) * 0.0 + } + if !(gotrad != 0) { + rp = dc + } + for dc < int64(8) { + x = x * uint32_t(16) + dc++ + } + if c|32 == 'p' { + e2 = scanexp(tls, f, pok) + if e2 == -0x7fffffffffffffff-int64(1) { + if pok != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } else { + X__shlim(tls, f, int64(0)) + return float64(0) + } + e2 = int64(0) + } + } else { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + e2 = e2 + (int64(4)*rp - int64(32)) + + if !(x != 0) { + return float64(sign) * 0.0 + } + if e2 > int64(-emin) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308 + } + if e2 < int64(emin-2*53) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308 + } + + for x < 0x80000000 { + if y >= 0.5 { + x = x + (x + uint32_t(1)) + y = y + (y - float64(1)) + } else { + x = x + x + y = y + y + } + e2-- + } + + if int64(bits) > int64(32)+e2-int64(emin) { + bits = int32(int64(32) + e2 - int64(emin)) + if bits < 0 { + bits = 0 + } + } + + if bits < 53 { + bias = Xcopysignl(tls, Xscalbn(tls, float64(1), 32+53-bits-1), float64(sign)) + } + + if bits < 32 && y != 0 && !(x&uint32_t(1) != 0) { + x++ + y = float64(0) + } + + y = bias + float64(sign)*float64(x) + float64(sign)*y + y = y - bias + + if !(y != 0) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + } + + return Xscalbnl(tls, y, int32(e2)) +} + +func X__floatscan(tls *TLS, f uintptr, prec int32, pok int32) float64 { /* floatscan.c:427:13: */ + if __ccgo_strace { + trc("tls=%v f=%v prec=%v pok=%v, (%v:)", tls, f, prec, pok, origin(2)) + } + var sign int32 = 1 + var i size_t + var bits int32 + var emin int32 + var c int32 + + switch prec { + case 0: + bits = 24 + emin = -125 - bits + break + case 1: + bits = 53 + emin = -1021 - bits + break + case 2: + bits = 53 + emin = -1021 - bits + break + default: + return float64(0) + } + + for __isspace(tls, AssignInt32(&c, func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }())) != 0 { + } + + if c == '+' || c == '-' { + sign = sign - 2*Bool32(c == '-') + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + } + + for i = uint64(0); i < uint64(8) && c|32 == int32(*(*int8)(unsafe.Pointer(ts /* "infinity" */ + uintptr(i)))); i++ { + if i < uint64(7) { + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + } + } + if i == uint64(3) || i == uint64(8) || i > uint64(3) && pok != 0 { + if i != uint64(8) { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if pok != 0 { + for ; i > uint64(3); i-- { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + } + } + return float64(float32(sign) * X__builtin_inff(tls)) + } + if !(i != 0) { + for i = uint64(0); i < uint64(3) && c|32 == int32(*(*int8)(unsafe.Pointer(ts + 9 /* "nan" */ + uintptr(i)))); i++ { + if i < uint64(2) { + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + } + } + } + if i == uint64(3) { + if func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() != '(' { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + return float64(X__builtin_nanf(tls, ts+13)) + } + for i = uint64(1); ; i++ { + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if uint32(c-'0') < 10 || uint32(c-'A') < 26 || uint32(c-'a') < 26 || c == '_' { + continue + } + if c == ')' { + return float64(X__builtin_nanf(tls, ts+13)) + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if !(pok != 0) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + X__shlim(tls, f, int64(0)) + return float64(0) + } + for PostDecUint64(&i, 1) != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + return float64(X__builtin_nanf(tls, ts+13)) + } + return float64(X__builtin_nanf(tls, ts+13)) + } + + if i != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + X__shlim(tls, f, int64(0)) + return float64(0) + } + + if c == '0' { + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if c|32 == 'x' { + return hexfloat(tls, f, bits, emin, sign, pok) + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + c = '0' + } + + return decfloat(tls, f, c, bits, emin, sign, pok) +} + +// Lookup table for digit values. -1==255>=36 -> invalid +var table = [257]uint8{Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + uint8(0), uint8(1), uint8(2), uint8(3), uint8(4), uint8(5), uint8(6), uint8(7), uint8(8), uint8(9), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), uint8(10), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(17), uint8(18), uint8(19), uint8(20), uint8(21), uint8(22), uint8(23), uint8(24), + uint8(25), uint8(26), uint8(27), uint8(28), uint8(29), uint8(30), uint8(31), uint8(32), uint8(33), uint8(34), uint8(35), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), uint8(10), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(17), uint8(18), uint8(19), uint8(20), uint8(21), uint8(22), uint8(23), uint8(24), + uint8(25), uint8(26), uint8(27), uint8(28), uint8(29), uint8(30), uint8(31), uint8(32), uint8(33), uint8(34), uint8(35), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), +} /* intscan.c:7:28 */ + +func X__intscan(tls *TLS, f uintptr, base uint32, pok int32, lim uint64) uint64 { /* intscan.c:26:20: */ + if __ccgo_strace { + trc("tls=%v f=%v base=%v pok=%v lim=%v, (%v:)", tls, f, base, pok, lim, origin(2)) + } + var val uintptr + var c int32 + var neg int32 + var x uint32 + var y uint64 + var bs int32 + val = uintptr(unsafe.Pointer(&table)) + uintptr(1) + neg = 0 + if !(base > uint32(36) || base == uint32(1)) { + goto __1 + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + return uint64(0) +__1: + ; +__2: + if !(__isspace(tls, AssignInt32(&c, func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }())) != 0) { + goto __3 + } + goto __2 +__3: + ; + if !(c == '+' || c == '-') { + goto __4 + } + neg = -Bool32(c == '-') + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() +__4: + ; + if !((base == uint32(0) || base == uint32(16)) && c == '0') { + goto __5 + } + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if !(c|32 == 'x') { + goto __7 + } + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if !(int32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) >= 16) { + goto __9 + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if !(pok != 0) { + goto __10 + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + goto __11 +__10: + X__shlim(tls, f, int64(0)) +__11: + ; + return uint64(0) +__9: + ; + base = uint32(16) + goto __8 +__7: + if !(base == uint32(0)) { + goto __12 + } + base = uint32(8) +__12: + ; +__8: + ; + goto __6 +__5: + if !(base == uint32(0)) { + goto __13 + } + base = uint32(10) +__13: + ; + if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) >= base) { + goto __14 + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + X__shlim(tls, f, int64(0)) + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + return uint64(0) +__14: + ; +__6: + ; + if !(base == uint32(10)) { + goto __15 + } + x = uint32(0) +__17: + if !(uint32(c-'0') < 10 && x <= 0xffffffff/uint32(10)-uint32(1)) { + goto __19 + } + x = x*uint32(10) + uint32(c-'0') + goto __18 +__18: + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + goto __17 + goto __19 +__19: + ; + y = uint64(x) +__20: + if !(uint32(c-'0') < 10 && y <= (2*uint64(0x7fffffffffffffff)+uint64(1))/uint64(10) && uint64(10)*y <= 2*uint64(0x7fffffffffffffff)+uint64(1)-uint64(c-'0')) { + goto __22 + } + y = y*uint64(10) + uint64(c-'0') + goto __21 +__21: + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + goto __20 + goto __22 +__22: + ; + if !(uint32(c-'0') >= 10) { + goto __23 + } + goto done +__23: + ; + goto __16 +__15: + if !!(base&(base-uint32(1)) != 0) { + goto __24 + } + bs = int32(*(*int8)(unsafe.Pointer(ts + 14 + uintptr(uint32(0x17)*base>>5&uint32(7))))) + x = uint32(0) +__26: + if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && x <= 0xffffffff/uint32(32)) { + goto __28 + } + x = x<>bs) { + goto __31 + } + y = y<= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if !(y >= lim) { + goto __43 + } + if !(!(lim&uint64(1) != 0) && !(neg != 0)) { + goto __44 + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return lim - uint64(1) + goto __45 +__44: + if !(y > lim) { + goto __46 + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return lim +__46: + ; +__45: + ; +__43: + ; + return y ^ uint64(neg) - uint64(neg) +} + +// The shcnt field stores the number of bytes read so far, offset by +// the value of buf-rpos at the last function call (__shlim or __shgetc), +// so that between calls the inline shcnt macro can add rpos-buf to get +// the actual count. + +func X__shlim(tls *TLS, f uintptr, lim off_t) { /* shgetc.c:8:6: */ + if __ccgo_strace { + trc("tls=%v f=%v lim=%v, (%v:)", tls, f, lim, origin(2)) + } + (*FILE)(unsafe.Pointer(f)).Fshlim = lim + (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf) - int64((*FILE)(unsafe.Pointer(f)).Frpos)) / 1 + // If lim is nonzero, rend must be a valid pointer. + if lim != 0 && (int64((*FILE)(unsafe.Pointer(f)).Frend)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 > lim { + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos + uintptr(lim) + } else { + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frend + } +} + +func X__shgetc(tls *TLS, f uintptr) int32 { /* shgetc.c:19:5: */ + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + var c int32 + var cnt off_t = (*FILE)(unsafe.Pointer(f)).Fshcnt + (int64((*FILE)(unsafe.Pointer(f)).Frpos)-int64((*FILE)(unsafe.Pointer(f)).Fbuf))/1 + if (*FILE)(unsafe.Pointer(f)).Fshlim != 0 && cnt >= (*FILE)(unsafe.Pointer(f)).Fshlim || AssignInt32(&c, X__uflow(tls, f)) < 0 { + (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 + cnt + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos + (*FILE)(unsafe.Pointer(f)).Fshlim = int64(-1) + return -1 + } + cnt++ + if (*FILE)(unsafe.Pointer(f)).Fshlim != 0 && (int64((*FILE)(unsafe.Pointer(f)).Frend)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 > (*FILE)(unsafe.Pointer(f)).Fshlim-cnt { + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos + uintptr((*FILE)(unsafe.Pointer(f)).Fshlim-cnt) + } else { + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frend + } + (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 + cnt + if (*FILE)(unsafe.Pointer(f)).Frpos <= (*FILE)(unsafe.Pointer(f)).Fbuf { + *(*uint8)(unsafe.Pointer((*FILE)(unsafe.Pointer(f)).Frpos + UintptrFromInt32(-1))) = uint8(c) + } + return c +} + +type lconv = struct { + Fdecimal_point uintptr + Fthousands_sep uintptr + Fgrouping uintptr + Fint_curr_symbol uintptr + Fcurrency_symbol uintptr + Fmon_decimal_point uintptr + Fmon_thousands_sep uintptr + Fmon_grouping uintptr + Fpositive_sign uintptr + Fnegative_sign uintptr + Fint_frac_digits int8 + Ffrac_digits int8 + Fp_cs_precedes int8 + Fp_sep_by_space int8 + Fn_cs_precedes int8 + Fn_sep_by_space int8 + Fp_sign_posn int8 + Fn_sign_posn int8 + Fint_p_cs_precedes int8 + Fint_p_sep_by_space int8 + Fint_n_cs_precedes int8 + Fint_n_sep_by_space int8 + Fint_p_sign_posn int8 + Fint_n_sign_posn int8 + F__ccgo_pad1 [2]byte +} /* locale.h:24:1 */ + +// Support signed or unsigned plain-char + +// Implementation choices... + +// Arbitrary numbers... + +// POSIX/SUS requirements follow. These numbers come directly +// from SUS and have nothing to do with the host system. + +var posix_lconv = lconv{Fdecimal_point: ts + 23, Fthousands_sep: ts + 13, Fgrouping: ts + 13, Fint_curr_symbol: ts + 13, Fcurrency_symbol: ts + 13, Fmon_decimal_point: ts + 13, Fmon_thousands_sep: ts + 13, Fmon_grouping: ts + 13, Fpositive_sign: ts + 13, Fnegative_sign: ts + 13, Fint_frac_digits: Int8FromInt32(255), Ffrac_digits: Int8FromInt32(255), Fp_cs_precedes: Int8FromInt32(255), Fp_sep_by_space: Int8FromInt32(255), Fn_cs_precedes: Int8FromInt32(255), Fn_sep_by_space: Int8FromInt32(255), Fp_sign_posn: Int8FromInt32(255), Fn_sign_posn: Int8FromInt32(255), Fint_p_cs_precedes: Int8FromInt32(255), Fint_p_sep_by_space: Int8FromInt32(255), Fint_n_cs_precedes: Int8FromInt32(255), Fint_n_sep_by_space: Int8FromInt32(255), Fint_p_sign_posn: Int8FromInt32(255), Fint_n_sign_posn: Int8FromInt32(255)} /* localeconv.c:4:27 */ + +func Xlocaleconv(tls *TLS) uintptr { /* localeconv.c:31:14: */ + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + return uintptr(unsafe.Pointer(&posix_lconv)) +} + +func X__fpclassify(tls *TLS, x float64) int32 { /* __fpclassify.c:4:5: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + *(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) { + *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x + return r + }() + var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff)) + if !(e != 0) { + if *(*uint64_t)(unsafe.Pointer(bp))<<1 != 0 { + return 3 + } + return 2 + } + if e == 0x7ff { + if *(*uint64_t)(unsafe.Pointer(bp))<<12 != 0 { + return 0 + } + return 1 + } + return 4 +} + +func X__fpclassifyf(tls *TLS, x float32) int32 { /* __fpclassifyf.c:4:5: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + bp := tls.Alloc(4) + defer tls.Free(4) + + *(*struct{ Ff float32 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float32 }) { + *(*float32)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x + return r + }() + var e int32 = int32(*(*uint32_t)(unsafe.Pointer(bp)) >> 23 & uint32_t(0xff)) + if !(e != 0) { + if *(*uint32_t)(unsafe.Pointer(bp))<<1 != 0 { + return 3 + } + return 2 + } + if e == 0xff { + if *(*uint32_t)(unsafe.Pointer(bp))<<9 != 0 { + return 0 + } + return 1 + } + return 4 +} + +func __bswap32(tls *TLS, __x uint32_t) uint32_t { /* endian.h:24:26: */ + return __x>>24 | __x>>8&uint32_t(0xff00) | __x<<8&uint32_t(0xff0000) | __x<<24 +} + +func X__fpclassifyl(tls *TLS, x float64) int32 { /* __fpclassifyl.c:4:5: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + return X__fpclassify(tls, x) +} + +func Xcopysignl(tls *TLS, x float64, y float64) float64 { /* copysignl.c:4:13: */ + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + } + return Xcopysign(tls, x, y) +} + +func Xfabsl(tls *TLS, x float64) float64 { /* fabsl.c:3:13: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + return Xfabs(tls, x) +} + +func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */ + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + } + return Xfmod(tls, x, y) +} + +func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */ + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + } + return X__builtin_nanf(tls, ts+13) +} + +var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */ + +func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + *(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) { + *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x + return r + }() + var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff)) + var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63) + var y double_t + + if e >= 0x3ff+52 { + return x + } + if s != 0 { + y = x - toint + toint + } else { + y = x + toint - toint + } + if y == float64(0) { + if s != 0 { + return -Float64FromFloat64(0.0) + } + return float64(0) + } + return y +} + +func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */ + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + // var u struct {Ff float64;} at bp, 8 + + var y double_t = x + + if n > 1023 { + y = y * 0x1p1023 + n = n - 1023 + if n > 1023 { + y = y * 0x1p1023 + n = 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 = y * (float64(0x1p-1022) * 0x1p53) + n = n + (1022 - 53) + if n < -1022 { + y = y * (float64(0x1p-1022) * 0x1p53) + n = n + (1022 - 53) + if n < -1022 { + n = -1022 + } + } + } + *(*uint64_t)(unsafe.Pointer(bp)) = uint64_t(0x3ff+n) << 52 + x = y * *(*float64)(unsafe.Pointer(bp)) + return x +} + +func Xscalbnl(tls *TLS, x float64, n int32) float64 { /* scalbnl.c:4:13: */ + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + } + return Xscalbn(tls, x, n) +} + +type max_align_t = struct { + F__ll int64 + F__ld float64 +} /* alltypes.h:41:54 */ + +type imaxdiv_t = struct { + Fquot intmax_t + Frem intmax_t +} /* inttypes.h:14:40 */ + +type iovec = struct { + Fiov_base uintptr + Fiov_len size_t +} /* alltypes.h:355:1 */ + +type socklen_t = uint32 /* alltypes.h:361:18 */ + +type sa_family_t = uint16 /* alltypes.h:366:24 */ + +type msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__pad1 int32 + Fmsg_control uintptr + Fmsg_controllen socklen_t + F__pad2 int32 + Fmsg_flags int32 + F__ccgo_pad2 [4]byte +} /* socket.h:22:1 */ + +type cmsghdr = struct { + Fcmsg_len socklen_t + F__pad1 int32 + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:44:1 */ + +type linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:74:1 */ + +type sockaddr = struct { + Fsa_family sa_family_t + Fsa_data [14]int8 +} /* socket.h:367:1 */ + +type sockaddr_storage = struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 +} /* socket.h:372:1 */ + +type in_port_t = uint16_t /* in.h:12:18 */ +type in_addr_t = uint32_t /* in.h:13:18 */ +type in_addr = struct{ Fs_addr in_addr_t } /* in.h:14:1 */ + +type sockaddr_in = struct { + Fsin_family sa_family_t + Fsin_port in_port_t + Fsin_addr struct{ Fs_addr in_addr_t } + Fsin_zero [8]uint8_t +} /* in.h:16:1 */ + +type in6_addr = struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } +} /* in.h:23:1 */ + +type sockaddr_in6 = struct { + Fsin6_family sa_family_t + Fsin6_port in_port_t + Fsin6_flowinfo uint32_t + Fsin6_addr struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } + } + Fsin6_scope_id uint32_t +} /* in.h:34:1 */ + +type ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } + } + Fipv6mr_interface uint32 +} /* in.h:42:1 */ + +type ip_opts = struct { + Fip_dst struct{ Fs_addr in_addr_t } + Fip_opts [40]int8 +} /* in.h:229:1 */ + +type ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr in_addr_t } + Fimr_interface struct{ Fs_addr in_addr_t } +} /* in.h:247:1 */ + +type ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr in_addr_t } + Fimr_address struct{ Fs_addr in_addr_t } + Fimr_ifindex int32 +} /* in.h:252:1 */ + +type ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr in_addr_t } + Fimr_interface struct{ Fs_addr in_addr_t } + Fimr_sourceaddr struct{ Fs_addr in_addr_t } +} /* in.h:258:1 */ + +type ip_msfilter = struct { + Fimsf_multiaddr struct{ Fs_addr in_addr_t } + Fimsf_interface struct{ Fs_addr in_addr_t } + Fimsf_fmode uint32_t + Fimsf_numsrc uint32_t + Fimsf_slist [1]struct{ Fs_addr in_addr_t } +} /* in.h:264:1 */ + +type group_req = struct { + Fgr_interface uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:275:1 */ + +type group_source_req = struct { + Fgsr_interface uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } + Fgsr_source struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:280:1 */ + +type group_filter = struct { + Fgf_interface uint32_t + F__ccgo_pad1 [4]byte + Fgf_group struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } + Fgf_fmode uint32_t + Fgf_numsrc uint32_t + Fgf_slist [1]struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:286:1 */ + +type in_pktinfo = struct { + Fipi_ifindex int32 + Fipi_spec_dst struct{ Fs_addr in_addr_t } + Fipi_addr struct{ Fs_addr in_addr_t } +} /* in.h:297:1 */ + +type in6_pktinfo = struct { + Fipi6_addr struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } + } + Fipi6_ifindex uint32 +} /* in.h:303:1 */ + +type ip6_mtuinfo = struct { + Fip6m_addr struct { + Fsin6_family sa_family_t + Fsin6_port in_port_t + Fsin6_flowinfo uint32_t + Fsin6_addr struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } + } + Fsin6_scope_id uint32_t + } + Fip6m_mtu uint32_t +} /* in.h:308:1 */ + +type addrinfo = struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen socklen_t + F__ccgo_pad1 [4]byte + Fai_addr uintptr + Fai_canonname uintptr + Fai_next uintptr +} /* netdb.h:16:1 */ + +// Legacy functions follow (marked OBsolete in SUS) + +type netent = struct { + Fn_name uintptr + Fn_aliases uintptr + Fn_addrtype int32 + Fn_net uint32_t +} /* netdb.h:62:1 */ + +type hostent = struct { + Fh_name uintptr + Fh_aliases uintptr + Fh_addrtype int32 + Fh_length int32 + Fh_addr_list uintptr +} /* netdb.h:69:1 */ + +type servent = struct { + Fs_name uintptr + Fs_aliases uintptr + Fs_port int32 + F__ccgo_pad1 [4]byte + Fs_proto uintptr +} /* netdb.h:78:1 */ + +type protoent = struct { + Fp_name uintptr + Fp_aliases uintptr + Fp_proto int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:85:1 */ + +type aibuf = struct { + Fai struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen socklen_t + F__ccgo_pad1 [4]byte + Fai_addr uintptr + Fai_canonname uintptr + Fai_next uintptr + } + Fsa struct { + Fsin struct { + Fsin_family sa_family_t + Fsin_port in_port_t + Fsin_addr struct{ Fs_addr in_addr_t } + Fsin_zero [8]uint8_t + } + F__ccgo_pad1 [12]byte + } + Flock [1]int32 + Fslot int16 + Fref int16 + F__ccgo_pad1 [4]byte +} /* lookup.h:10:1 */ + +type sa = struct { + Fsin struct { + Fsin_family sa_family_t + Fsin_port in_port_t + Fsin_addr struct{ Fs_addr in_addr_t } + Fsin_zero [8]uint8_t + } + F__ccgo_pad1 [12]byte +} /* lookup.h:10:1 */ + +type address = struct { + Ffamily int32 + Fscopeid uint32 + Faddr [16]uint8_t + Fsortkey int32 +} /* lookup.h:20:1 */ + +type service = struct { + Fport uint16_t + Fproto uint8 + Fsocktype uint8 +} /* lookup.h:27:1 */ + +type resolvconf = struct { + Fns [3]struct { + Ffamily int32 + Fscopeid uint32 + Faddr [16]uint8_t + Fsortkey int32 + } + Fnns uint32 + Fattempts uint32 + Fndots uint32 + Ftimeout uint32 +} /* lookup.h:34:1 */ + +func Xfreeaddrinfo(tls *TLS, p uintptr) { /* freeaddrinfo.c:7:6: */ + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + } + var cnt size_t + cnt = uint64(1) +__1: + if !((*addrinfo)(unsafe.Pointer(p)).Fai_next != 0) { + goto __3 + } + goto __2 +__2: + cnt++ + p = (*addrinfo)(unsafe.Pointer(p)).Fai_next + goto __1 + goto __3 +__3: + ; + var b uintptr = p - uintptr(uint64(uintptr(0))) + b -= 88 * uintptr((*aibuf)(unsafe.Pointer(b)).Fslot) + //TODO LOCK(b->lock); + if !(int32(AssignSubPtrInt16(b+82, int16(cnt))) != 0) { + Xfree(tls, b) + } + //TODO else UNLOCK(b->lock); +} + +type time_t = int64 /* alltypes.h:85:16 */ + +type clockid_t = int32 /* alltypes.h:214:13 */ + +type timespec = struct { + Ftv_sec time_t + Ftv_nsec int64 +} /* alltypes.h:229:1 */ + +type pthread_t = uintptr /* alltypes.h:273:26 */ + +type pthread_once_t = int32 /* alltypes.h:279:13 */ + +type pthread_key_t = uint32 /* alltypes.h:284:18 */ + +type pthread_spinlock_t = int32 /* alltypes.h:289:13 */ + +type pthread_mutexattr_t = struct{ F__attr uint32 } /* alltypes.h:294:37 */ + +type pthread_condattr_t = struct{ F__attr uint32 } /* alltypes.h:299:37 */ + +type pthread_barrierattr_t = struct{ F__attr uint32 } /* alltypes.h:304:37 */ + +type pthread_rwlockattr_t = struct{ F__attr [2]uint32 } /* alltypes.h:309:40 */ + +type __sigset_t = struct{ F__bits [16]uint64 } /* alltypes.h:349:9 */ + +type sigset_t = __sigset_t /* alltypes.h:349:71 */ + +type pthread_attr_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [14]int32 + } +} /* alltypes.h:372:147 */ + +type pthread_mutex_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [10]int32 + } +} /* alltypes.h:377:157 */ + +type pthread_cond_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [12]int32 + } +} /* alltypes.h:387:112 */ + +type pthread_rwlock_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [14]int32 + } +} /* alltypes.h:397:139 */ + +type pthread_barrier_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [8]int32 + } +} /* alltypes.h:402:137 */ + +type sched_param = struct { + Fsched_priority int32 + F__reserved1 int32 + F__reserved2 [2]struct { + F__reserved1 time_t + F__reserved2 int64 + } + F__reserved3 int32 + F__ccgo_pad1 [4]byte +} /* sched.h:19:1 */ + +type timer_t = uintptr /* alltypes.h:209:14 */ + +type clock_t = int64 /* alltypes.h:219:14 */ + +type tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* time.h:38:1 */ + +type itimerspec = struct { + Fit_interval struct { + Ftv_sec time_t + Ftv_nsec int64 + } + Fit_value struct { + Ftv_sec time_t + Ftv_nsec int64 + } +} /* time.h:80:1 */ + +type __ptcb = struct { + F__f uintptr + F__x uintptr + F__next uintptr +} /* pthread.h:206:1 */ + +func Xgetaddrinfo(tls *TLS, host uintptr, serv uintptr, hint uintptr, res uintptr) int32 { /* getaddrinfo.c:12:5: */ + if __ccgo_strace { + trc("tls=%v host=%v serv=%v hint=%v res=%v, (%v:)", tls, host, serv, hint, res, origin(2)) + } + bp := tls.Alloc(1608) + defer tls.Free(1608) + + // var ports [2]service at bp, 8 + + // var addrs [48]address at bp+8, 1344 + + // var canon [256]int8 at bp+1352, 256 + + var outcanon uintptr + var nservs int32 + var naddrs int32 + var nais int32 + var canon_len int32 + var i int32 + var j int32 + var k int32 + var family int32 = 0 + var flags int32 = 0 + var proto int32 = 0 + var socktype int32 = 0 + var out uintptr + + if !(host != 0) && !(serv != 0) { + return -2 + } + + if hint != 0 { + family = (*addrinfo)(unsafe.Pointer(hint)).Fai_family + flags = (*addrinfo)(unsafe.Pointer(hint)).Fai_flags + proto = (*addrinfo)(unsafe.Pointer(hint)).Fai_protocol + socktype = (*addrinfo)(unsafe.Pointer(hint)).Fai_socktype + + var mask int32 = 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x400 + if flags&mask != flags { + return -1 + } + + switch family { + case 2: + fallthrough + case 10: + fallthrough + case 0: + break + fallthrough + default: + return -6 + } + } + + if flags&0x20 != 0 { + Xabort(tls) //TODO- + // /* Define the "an address is configured" condition for address + // * families via ability to create a socket for the family plus + // * routability of the loopback address for the family. */ + // static const struct sockaddr_in lo4 = { + // .sin_family = AF_INET, .sin_port = 65535, + // .sin_addr.s_addr = __BYTE_ORDER == __BIG_ENDIAN + // ? 0x7f000001 : 0x0100007f + // }; + // static const struct sockaddr_in6 lo6 = { + // .sin6_family = AF_INET6, .sin6_port = 65535, + // .sin6_addr = IN6ADDR_LOOPBACK_INIT + // }; + // int tf[2] = { AF_INET, AF_INET6 }; + // const void *ta[2] = { &lo4, &lo6 }; + // socklen_t tl[2] = { sizeof lo4, sizeof lo6 }; + // for (i=0; i<2; i++) { + // if (family==tf[1-i]) continue; + // int s = socket(tf[i], SOCK_CLOEXEC|SOCK_DGRAM, + // IPPROTO_UDP); + // if (s>=0) { + // int cs; + // pthread_setcancelstate( + // PTHREAD_CANCEL_DISABLE, &cs); + // int r = connect(s, ta[i], tl[i]); + // pthread_setcancelstate(cs, 0); + // close(s); + // if (!r) continue; + // } + // switch (errno) { + // case EADDRNOTAVAIL: + // case EAFNOSUPPORT: + // case EHOSTUNREACH: + // case ENETDOWN: + // case ENETUNREACH: + // break; + // default: + // return EAI_SYSTEM; + // } + // if (family == tf[i]) return EAI_NONAME; + // family = tf[1-i]; + // } + } + + nservs = X__lookup_serv(tls, bp, serv, proto, socktype, flags) + if nservs < 0 { + return nservs + } + + naddrs = X__lookup_name(tls, bp+8, bp+1352, host, family, flags) + if naddrs < 0 { + return naddrs + } + + nais = nservs * naddrs + canon_len = int32(Xstrlen(tls, bp+1352)) + out = Xcalloc(tls, uint64(1), uint64(nais)*uint64(unsafe.Sizeof(aibuf{}))+uint64(canon_len)+uint64(1)) + if !(out != 0) { + return -10 + } + + if canon_len != 0 { + outcanon = out + uintptr(nais)*88 + Xmemcpy(tls, outcanon, bp+1352, uint64(canon_len+1)) + } else { + outcanon = uintptr(0) + } + + for k = AssignInt32(&i, 0); i < naddrs; i++ { + j = 0 + __1: + if !(j < nservs) { + goto __3 + } + { + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fslot = int16(k) + //TODO out[k].ai = (struct addrinfo){ + //TODO .ai_family = addrs[i].family, + //TODO .ai_socktype = ports[j].socktype, + //TODO .ai_protocol = ports[j].proto, + //TODO .ai_addrlen = addrs[i].family == AF_INET + //TODO ? sizeof(struct sockaddr_in) + //TODO : sizeof(struct sockaddr_in6), + //TODO .ai_addr = (void *)&out[k].sa, + //TODO .ai_canonname = outcanon }; + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_family = (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Ffamily + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_socktype = int32((*service)(unsafe.Pointer(bp + uintptr(j)*4)).Fsocktype) + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_protocol = int32((*service)(unsafe.Pointer(bp + uintptr(j)*4)).Fproto) + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_addrlen = func() uint32 { + if (*address)(unsafe.Pointer(bp+8+uintptr(i)*28)).Ffamily == 2 { + return uint32(unsafe.Sizeof(sockaddr_in{})) + } + return uint32(unsafe.Sizeof(sockaddr_in6{})) + }() + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_addr = out + uintptr(k)*88 + 48 + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_canonname = outcanon + if k != 0 { + (*aibuf)(unsafe.Pointer(out + uintptr(k-1)*88)).Fai.Fai_next = out + uintptr(k)*88 + } + switch (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Ffamily { + case 2: + (*sockaddr_in)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin_family = sa_family_t(2) + (*sockaddr_in)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin_port = Xhtons(tls, (*service)(unsafe.Pointer(bp+uintptr(j)*4)).Fport) + Xmemcpy(tls, out+uintptr(k)*88+48+4, bp+8+uintptr(i)*28+8, uint64(4)) + break + case 10: + (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_family = sa_family_t(10) + (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_port = Xhtons(tls, (*service)(unsafe.Pointer(bp+uintptr(j)*4)).Fport) + (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_scope_id = (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Fscopeid + Xmemcpy(tls, out+uintptr(k)*88+48+8, bp+8+uintptr(i)*28+8, uint64(16)) + break + } + + } + goto __2 + __2: + j++ + k++ + goto __1 + goto __3 + __3: + } + (*aibuf)(unsafe.Pointer(out)).Fref = int16(nais) + *(*uintptr)(unsafe.Pointer(res)) = out + return 0 +} + +type ucred = struct { + Fpid pid_t + Fuid uid_t + Fgid gid_t +} /* socket.h:57:1 */ + +type mmsghdr = struct { + Fmsg_hdr struct { + Fmsg_name uintptr + Fmsg_namelen socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__pad1 int32 + Fmsg_control uintptr + Fmsg_controllen socklen_t + F__pad2 int32 + Fmsg_flags int32 + F__ccgo_pad2 [4]byte + } + Fmsg_len uint32 + F__ccgo_pad1 [4]byte +} /* socket.h:63:1 */ + +func Xgethostbyaddr(tls *TLS, a uintptr, l socklen_t, af int32) uintptr { /* gethostbyaddr.c:7:16: */ + if __ccgo_strace { + trc("tls=%v a=%v l=%v af=%v, (%v:)", tls, a, l, af, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + var size size_t = uint64(63) + // var res uintptr at bp, 8 + + var err int32 + for __ccgo := true; __ccgo; __ccgo = err == 34 { + Xfree(tls, _sh) + _sh = Xmalloc(tls, AssignAddUint64(&size, size+uint64(1))) + if !(_sh != 0) { + *(*int32)(unsafe.Pointer(X__h_errno_location(tls))) = 3 + return uintptr(0) + } + err = Xgethostbyaddr_r(tls, a, l, af, _sh, + _sh+uintptr(1)*32, size-size_t(unsafe.Sizeof(hostent{})), bp, X__h_errno_location(tls)) + } + if err != 0 { + return uintptr(0) + } + return _sh +} + +var _sh uintptr /* gethostbyaddr.c:9:24: */ + +func Xgethostbyaddr_r(tls *TLS, a uintptr, l socklen_t, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyaddr_r.c:10:5: */ + if __ccgo_strace { + trc("tls=%v a=%v l=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, a, l, af, h, buf, buflen, res, err, origin(2)) + } + bp := tls.Alloc(28) + defer tls.Free(28) + + //TODO union { + //TODO struct sockaddr_in sin; + //TODO struct sockaddr_in6 sin6; + //TODO } sa = { .sin.sin_family = af }; + *(*struct { + Fsin sockaddr_in + F__ccgo_pad1 [12]byte + })(unsafe.Pointer(bp)) = struct { + Fsin sockaddr_in + F__ccgo_pad1 [12]byte + }{} //TODO- + (*sockaddr_in)(unsafe.Pointer(bp)).Fsin_family = sa_family_t(af) //TODO- + var sl socklen_t + if af == 10 { + sl = uint32(unsafe.Sizeof(sockaddr_in6{})) + } else { + sl = uint32(unsafe.Sizeof(sockaddr_in{})) + } + var i int32 + + *(*uintptr)(unsafe.Pointer(res)) = uintptr(0) + + // Load address argument into sockaddr structure + if af == 10 && l == socklen_t(16) { + Xmemcpy(tls, bp+8, a, uint64(16)) + } else if af == 2 && l == socklen_t(4) { + Xmemcpy(tls, bp+4, a, uint64(4)) + } else { + *(*int32)(unsafe.Pointer(err)) = 3 + return 22 + } + + // Align buffer and check for space for pointers and ip address + i = int32(uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1))) + if !(i != 0) { + i = int32(unsafe.Sizeof(uintptr(0))) + } + if buflen <= uint64(5)*uint64(unsafe.Sizeof(uintptr(0)))-uint64(i)+uint64(l) { + return 34 + } + buf += uintptr(uint64(unsafe.Sizeof(uintptr(0))) - uint64(i)) + buflen = buflen - (uint64(5)*uint64(unsafe.Sizeof(uintptr(0))) - uint64(i) + uint64(l)) + + (*hostent)(unsafe.Pointer(h)).Fh_addr_list = buf + buf += uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))) + (*hostent)(unsafe.Pointer(h)).Fh_aliases = buf + buf += uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))) + + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list)) = buf + Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list)), a, uint64(l)) + buf += uintptr(l) + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + 1*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases)) = buf + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0) + + switch Xgetnameinfo(tls, bp, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) { + case -3: + *(*int32)(unsafe.Pointer(err)) = 2 + return 11 + case -12: + return 34 + default: + fallthrough + case -10: + fallthrough + case -11: + fallthrough + case -4: + *(*int32)(unsafe.Pointer(err)) = 3 + return *(*int32)(unsafe.Pointer(X___errno_location(tls))) + case 0: + break + } + + (*hostent)(unsafe.Pointer(h)).Fh_addrtype = af + (*hostent)(unsafe.Pointer(h)).Fh_length = int32(l) + (*hostent)(unsafe.Pointer(h)).Fh_name = *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases)) + *(*uintptr)(unsafe.Pointer(res)) = h + return 0 +} + +func Xgethostbyname(tls *TLS, name uintptr) uintptr { /* gethostbyname.c:8:16: */ + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + } + return Xgethostbyname2(tls, name, 2) +} + +func Xgethostbyname2(tls *TLS, name uintptr, af int32) uintptr { /* gethostbyname2.c:8:16: */ + if __ccgo_strace { + trc("tls=%v name=%v af=%v, (%v:)", tls, name, af, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + var size size_t = uint64(63) + // var res uintptr at bp, 8 + + var err int32 + for __ccgo := true; __ccgo; __ccgo = err == 34 { + Xfree(tls, _sh1) + _sh1 = Xmalloc(tls, AssignAddUint64(&size, size+uint64(1))) + if !(_sh1 != 0) { + *(*int32)(unsafe.Pointer(X__h_errno_location(tls))) = 3 + return uintptr(0) + } + err = Xgethostbyname2_r(tls, name, af, _sh1, + _sh1+uintptr(1)*32, size-size_t(unsafe.Sizeof(hostent{})), bp, X__h_errno_location(tls)) + } + if err != 0 { + return uintptr(0) + } + return _sh1 +} + +var _sh1 uintptr /* gethostbyname2.c:10:24: */ + +func Xgethostbyname2_r(tls *TLS, name uintptr, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyname2_r.c:11:5: */ + if __ccgo_strace { + trc("tls=%v name=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, name, af, h, buf, buflen, res, err, origin(2)) + } + bp := tls.Alloc(1600) + defer tls.Free(1600) + + // var addrs [48]address at bp, 1344 + + // var canon [256]int8 at bp+1344, 256 + + var i int32 + var cnt int32 + var align size_t + var need size_t + + *(*uintptr)(unsafe.Pointer(res)) = uintptr(0) + cnt = X__lookup_name(tls, bp, bp+1344, name, af, 0x02) + if cnt < 0 { + switch cnt { + case -2: + *(*int32)(unsafe.Pointer(err)) = 1 + return 2 + fallthrough + case -3: + *(*int32)(unsafe.Pointer(err)) = 2 + return 11 + fallthrough + default: + fallthrough + case -4: + *(*int32)(unsafe.Pointer(err)) = 3 + return 74 + fallthrough + case -10: + fallthrough + case -11: + *(*int32)(unsafe.Pointer(err)) = 3 + return *(*int32)(unsafe.Pointer(X___errno_location(tls))) + } + } + + (*hostent)(unsafe.Pointer(h)).Fh_addrtype = af + (*hostent)(unsafe.Pointer(h)).Fh_length = func() int32 { + if af == 10 { + return 16 + } + return 4 + }() + + // Align buffer + align = -uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1)) + + need = uint64(4) * uint64(unsafe.Sizeof(uintptr(0))) + need = need + uint64(cnt+1)*(uint64(unsafe.Sizeof(uintptr(0)))+uint64((*hostent)(unsafe.Pointer(h)).Fh_length)) + need = need + (Xstrlen(tls, name) + uint64(1)) + need = need + (Xstrlen(tls, bp+1344) + uint64(1)) + need = need + align + + if need > buflen { + return 34 + } + + buf += uintptr(align) + (*hostent)(unsafe.Pointer(h)).Fh_aliases = buf + buf += uintptr(uint64(3) * uint64(unsafe.Sizeof(uintptr(0)))) + (*hostent)(unsafe.Pointer(h)).Fh_addr_list = buf + buf += uintptr(uint64(cnt+1) * uint64(unsafe.Sizeof(uintptr(0)))) + + for i = 0; i < cnt; i++ { + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = buf + buf += uintptr((*hostent)(unsafe.Pointer(h)).Fh_length) + Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)), bp+uintptr(i)*28+8, uint64((*hostent)(unsafe.Pointer(h)).Fh_length)) + } + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = uintptr(0) + + (*hostent)(unsafe.Pointer(h)).Fh_name = AssignPtrUintptr((*hostent)(unsafe.Pointer(h)).Fh_aliases, buf) + Xstrcpy(tls, (*hostent)(unsafe.Pointer(h)).Fh_name, bp+1344) + buf += uintptr(Xstrlen(tls, (*hostent)(unsafe.Pointer(h)).Fh_name) + uint64(1)) + + if Xstrcmp(tls, (*hostent)(unsafe.Pointer(h)).Fh_name, name) != 0 { + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = buf + Xstrcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)), name) + buf += uintptr(Xstrlen(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8))) + uint64(1)) + } else { + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0) + } + + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 2*8)) = uintptr(0) + + *(*uintptr)(unsafe.Pointer(res)) = h + return 0 +} + +type if_nameindex = struct { + Fif_index uint32 + F__ccgo_pad1 [4]byte + Fif_name uintptr +} /* if.h:12:1 */ + +type ifaddr = struct { + Fifa_addr struct { + Fsa_family sa_family_t + Fsa_data [14]int8 + } + Fifa_ifu struct { + Fifu_broadaddr struct { + Fsa_family sa_family_t + Fsa_data [14]int8 + } + } + Fifa_ifp uintptr + Fifa_next uintptr +} /* if.h:51:1 */ + +type ifmap = struct { + Fmem_start uint64 + Fmem_end uint64 + Fbase_addr uint16 + Firq uint8 + Fdma uint8 + Fport uint8 + F__ccgo_pad1 [3]byte +} /* if.h:64:1 */ + +type ifreq = struct { + Fifr_ifrn struct{ Fifrn_name [16]int8 } + Fifr_ifru struct { + F__ccgo_pad1 [0]uint64 + Fifru_addr struct { + Fsa_family sa_family_t + Fsa_data [14]int8 + } + F__ccgo_pad2 [8]byte + } +} /* if.h:76:1 */ + +type ifconf = struct { + Fifc_len int32 + F__ccgo_pad1 [4]byte + Fifc_ifcu struct{ Fifcu_buf uintptr } +} /* if.h:116:1 */ + +type ns_sect = uint32 /* nameser.h:37:3 */ + +type __ns_msg = struct { + F_msg uintptr + F_eom uintptr + F_id uint16_t + F_flags uint16_t + F_counts [4]uint16_t + F__ccgo_pad1 [4]byte + F_sections [4]uintptr + F_sect ns_sect + F_rrnum int32 + F_msg_ptr uintptr +} /* nameser.h:39:9 */ + +type ns_msg = __ns_msg /* nameser.h:46:3 */ + +type _ns_flagdata = struct { + Fmask int32 + Fshift int32 +} /* nameser.h:48:1 */ + +type __ns_rr = struct { + Fname [1025]int8 + F__ccgo_pad1 [1]byte + Ftype uint16_t + Frr_class uint16_t + F__ccgo_pad2 [2]byte + Fttl uint32_t + Frdlength uint16_t + F__ccgo_pad3 [2]byte + Frdata uintptr +} /* nameser.h:59:9 */ + +type ns_rr = __ns_rr /* nameser.h:66:3 */ + +type ns_flag = uint32 /* nameser.h:87:3 */ + +type ns_opcode = uint32 /* nameser.h:96:3 */ + +type ns_rcode = uint32 /* nameser.h:115:3 */ + +type ns_update_operation = uint32 /* nameser.h:121:3 */ + +type ns_tsig_key1 = struct { + Fname [1025]int8 + Falg [1025]int8 + F__ccgo_pad1 [6]byte + Fdata uintptr + Flen int32 + F__ccgo_pad2 [4]byte +} /* nameser.h:123:1 */ + +type ns_tsig_key = ns_tsig_key1 /* nameser.h:128:28 */ + +type ns_tcp_tsig_state1 = struct { + Fcounter int32 + F__ccgo_pad1 [4]byte + Fkey uintptr + Fctx uintptr + Fsig [512]uint8 + Fsiglen int32 + F__ccgo_pad2 [4]byte +} /* nameser.h:130:1 */ + +type ns_tcp_tsig_state = ns_tcp_tsig_state1 /* nameser.h:137:34 */ + +type ns_type = uint32 /* nameser.h:200:3 */ + +type ns_class = uint32 /* nameser.h:219:3 */ + +type ns_key_types = uint32 /* nameser.h:226:3 */ + +type ns_cert_types = uint32 /* nameser.h:234:3 */ + +type HEADER = struct { + F__ccgo_pad1 [0]uint32 + Fid uint32 /* unsigned id: 16, unsigned rd: 1, unsigned tc: 1, unsigned aa: 1, unsigned opcode: 4, unsigned qr: 1, unsigned rcode: 4, unsigned cd: 1, unsigned ad: 1, unsigned unused: 1, unsigned ra: 1 */ + Fqdcount uint32 /* unsigned qdcount: 16, unsigned ancount: 16 */ + Fnscount uint32 /* unsigned nscount: 16, unsigned arcount: 16 */ +} /* nameser.h:353:3 */ + +// unused; purely for broken apps +type __res_state = struct { + Fretrans int32 + Fretry int32 + Foptions uint64 + Fnscount int32 + Fnsaddr_list [3]struct { + Fsin_family sa_family_t + Fsin_port in_port_t + Fsin_addr struct{ Fs_addr in_addr_t } + Fsin_zero [8]uint8_t + } + Fid uint16 + F__ccgo_pad1 [2]byte + Fdnsrch [7]uintptr + Fdefdname [256]int8 + Fpfcode uint64 + Fndots uint32 /* unsigned ndots: 4, unsigned nsort: 4, unsigned ipv6_unavail: 1, unsigned unused: 23 */ + F__ccgo_pad2 [4]byte + Fsort_list [10]struct { + Faddr struct{ Fs_addr in_addr_t } + Fmask uint32_t + } + Fqhook uintptr + Frhook uintptr + Fres_h_errno int32 + F_vcsock int32 + F_flags uint32 + F__ccgo_pad3 [4]byte + F_u struct { + F__ccgo_pad1 [0]uint64 + Fpad [52]int8 + F__ccgo_pad2 [4]byte + } +} /* resolv.h:26:9 */ + +// unused; purely for broken apps +type res_state = uintptr /* resolv.h:62:3 */ + +type res_sym = struct { + Fnumber int32 + F__ccgo_pad1 [4]byte + Fname uintptr + Fhumanname uintptr +} /* resolv.h:70:1 */ + +func itoa(tls *TLS, p uintptr, x uint32) uintptr { /* getnameinfo.c:18:13: */ + p += uintptr(uint64(3) * uint64(unsafe.Sizeof(int32(0)))) + *(*int8)(unsafe.Pointer(PreDecUintptr(&p, 1))) = int8(0) + for __ccgo := true; __ccgo; __ccgo = x != 0 { + *(*int8)(unsafe.Pointer(PreDecUintptr(&p, 1))) = int8(uint32('0') + x%uint32(10)) + x = x / uint32(10) + } + return p +} + +func mkptr4(tls *TLS, s uintptr, ip uintptr) { /* getnameinfo.c:28:13: */ + bp := tls.Alloc(32) + defer tls.Free(32) + + Xsprintf(tls, s, ts+25, + VaList(bp, int32(*(*uint8)(unsafe.Pointer(ip + 3))), int32(*(*uint8)(unsafe.Pointer(ip + 2))), int32(*(*uint8)(unsafe.Pointer(ip + 1))), int32(*(*uint8)(unsafe.Pointer(ip))))) +} + +func mkptr6(tls *TLS, s uintptr, ip uintptr) { /* getnameinfo.c:34:13: */ + var i int32 + for i = 15; i >= 0; i-- { + *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = _sxdigits[int32(*(*uint8)(unsafe.Pointer(ip + uintptr(i))))&15] + *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8('.') + *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = _sxdigits[int32(*(*uint8)(unsafe.Pointer(ip + uintptr(i))))>>4] + *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8('.') + } + Xstrcpy(tls, s, ts+50) +} + +var _sxdigits = *(*[17]int8)(unsafe.Pointer(ts + 59)) /* getnameinfo.c:36:20 */ + +func reverse_hosts(tls *TLS, buf uintptr, a uintptr, scopeid uint32, family int32) { /* getnameinfo.c:45:13: */ + bp := tls.Alloc(556) + defer tls.Free(556) + + // var line [512]int8 at bp+16, 512 + + var p uintptr + var z uintptr + var _buf [1032]uint8 + _ = _buf + // var atmp [16]uint8 at bp, 16 + + // var iplit address at bp+528, 28 + + //TODO FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); + var f uintptr = Xfopen(tls, ts+76, ts+87) + if !(f != 0) { + return + } + if family == 2 { + Xmemcpy(tls, bp+uintptr(12), a, uint64(4)) + Xmemcpy(tls, bp, ts+90, uint64(12)) + a = bp /* &atmp[0] */ + } + for Xfgets(tls, bp+16, int32(unsafe.Sizeof([512]int8{})), f) != 0 { + if AssignUintptr(&p, Xstrchr(tls, bp+16, '#')) != 0 { + *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8('\n') + *(*int8)(unsafe.Pointer(p)) = int8(0) + } + + for p = bp + 16; /* &line[0] */ *(*int8)(unsafe.Pointer(p)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0); p++ { + } + *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8(0) + if X__lookup_ipliteral(tls, bp+528, bp+16, 0) <= 0 { + continue + } + + if (*address)(unsafe.Pointer(bp+528)).Ffamily == 2 { + Xmemcpy(tls, bp+528+8+uintptr(12), bp+528+8, uint64(4)) + Xmemcpy(tls, bp+528+8, ts+90, uint64(12)) + (*address)(unsafe.Pointer(bp + 528 /* &iplit */)).Fscopeid = uint32(0) + } + + if Xmemcmp(tls, a, bp+528+8, uint64(16)) != 0 || (*address)(unsafe.Pointer(bp+528)).Fscopeid != scopeid { + continue + } + + for ; *(*int8)(unsafe.Pointer(p)) != 0 && __isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0; p++ { + } + for z = p; *(*int8)(unsafe.Pointer(z)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(z)))) != 0); z++ { + } + *(*int8)(unsafe.Pointer(z)) = int8(0) + if (int64(z)-int64(p))/1 < int64(256) { + Xmemcpy(tls, buf, p, uint64((int64(z)-int64(p))/1+int64(1))) + break + } + } + //TODO __fclose_ca(f); + Xfclose(tls, f) +} + +func reverse_services(tls *TLS, buf uintptr, port int32, dgram int32) { /* getnameinfo.c:87:13: */ + Xabort(tls) //TODO- + // unsigned long svport; + // char line[128], *p, *z; + // unsigned char _buf[1032]; + // FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf); + // if (!f) return; + // while (fgets(line, sizeof line, f)) { + // if ((p=strchr(line, '#'))) *p++='\n', *p=0; + + // for (p=line; *p && !isspace(*p); p++); + // if (!*p) continue; + // *p++ = 0; + // svport = strtoul(p, &z, 10); + + // if (svport != port || z==p) continue; + // if (dgram && strncmp(z, "/udp", 4)) continue; + // if (!dgram && strncmp(z, "/tcp", 4)) continue; + // if (p-line > 32) continue; + + // memcpy(buf, line, p-line); + // break; + // } + // __fclose_ca(f); +} + +func Xgetnameinfo(tls *TLS, sa1 uintptr, sl socklen_t, node uintptr, nodelen socklen_t, serv uintptr, servlen socklen_t, flags int32) int32 { /* getnameinfo.c:125:5: */ + if __ccgo_strace { + trc("tls=%v sa1=%v sl=%v node=%v nodelen=%v serv=%v servlen=%v flags=%v, (%v:)", tls, sa1, sl, node, nodelen, serv, servlen, flags, origin(2)) + } + bp := tls.Alloc(347) + defer tls.Free(347) + + // var ptr [78]int8 at bp, 78 + + // var buf [256]int8 at bp+78, 256 + + // var num [13]int8 at bp+334, 13 + + var af int32 = int32((*sockaddr)(unsafe.Pointer(sa1)).Fsa_family) + var a uintptr + var scopeid uint32 + + switch af { + case 2: + a = sa1 + 4 + if uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in{})) { + return -6 + } + mkptr4(tls, bp, a) + scopeid = uint32(0) + break + case 10: + a = sa1 + 8 + if uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in6{})) { + return -6 + } + if Xmemcmp(tls, a, ts+90, uint64(12)) != 0 { + mkptr6(tls, bp, a) + } else { + mkptr4(tls, bp, a+uintptr(12)) + } + scopeid = (*sockaddr_in6)(unsafe.Pointer(sa1)).Fsin6_scope_id + break + default: + return -6 + } + + if node != 0 && nodelen != 0 { + *(*int8)(unsafe.Pointer(bp + 78)) = int8(0) + if !(flags&0x01 != 0) { + reverse_hosts(tls, bp+78, a, scopeid, af) + } + if !(int32(*(*int8)(unsafe.Pointer(bp + 78))) != 0) && !(flags&0x01 != 0) { + Xabort(tls) //TODO- + // unsigned char query[18+PTR_MAX], reply[512]; + // int qlen = __res_mkquery(0, ptr, 1, RR_PTR, + // 0, 0, 0, query, sizeof query); + // query[3] = 0; /* don't need AD flag */ + // int rlen = __res_send(query, qlen, reply, sizeof reply); + // buf[0] = 0; + // if (rlen > 0) + // __dns_parse(reply, rlen, dns_parse_callback, buf); + } + if !(int32(*(*int8)(unsafe.Pointer(bp + 78))) != 0) { + if flags&0x08 != 0 { + return -2 + } + Xinet_ntop(tls, af, a, bp+78, uint32(unsafe.Sizeof([256]int8{}))) + if scopeid != 0 { + Xabort(tls) //TODO- + // char *p = 0, tmp[IF_NAMESIZE+1]; + // if (!(flags & NI_NUMERICSCOPE) && + // (IN6_IS_ADDR_LINKLOCAL(a) || + // IN6_IS_ADDR_MC_LINKLOCAL(a))) + // p = if_indextoname(scopeid, tmp+1); + // if (!p) + // p = itoa(num, scopeid); + // *--p = '%'; + // strcat(buf, p); + } + } + if Xstrlen(tls, bp+78) >= size_t(nodelen) { + return -12 + } + Xstrcpy(tls, node, bp+78) + } + + if serv != 0 && servlen != 0 { + var p uintptr = bp + 78 /* buf */ + var port int32 = int32(Xntohs(tls, (*sockaddr_in)(unsafe.Pointer(sa1)).Fsin_port)) + *(*int8)(unsafe.Pointer(bp + 78)) = int8(0) + if !(flags&0x02 != 0) { + reverse_services(tls, bp+78, port, flags&0x10) + } + if !(int32(*(*int8)(unsafe.Pointer(p))) != 0) { + p = itoa(tls, bp+334, uint32(port)) + } + if Xstrlen(tls, p) >= size_t(servlen) { + return -12 + } + Xstrcpy(tls, serv, p) + } + + return 0 +} + +var Xh_errno int32 /* h_errno.c:4:5: */ + +func X__h_errno_location(tls *TLS) uintptr { /* h_errno.c:6:5: */ + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + return uintptr(unsafe.Pointer(&Xh_errno)) +} + +func X__inet_aton(tls *TLS, s0 uintptr, dest uintptr) int32 { /* inet_aton.c:7:5: */ + if __ccgo_strace { + trc("tls=%v s0=%v dest=%v, (%v:)", tls, s0, dest, origin(2)) + } + bp := tls.Alloc(40) + defer tls.Free(40) + + var s uintptr = s0 + var d uintptr = dest + *(*[4]uint64)(unsafe.Pointer(bp /* a */)) = [4]uint64{0: uint64(0)} + // var z uintptr at bp+32, 8 + + var i int32 + + for i = 0; i < 4; i++ { + *(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)) = Xstrtoul(tls, s, bp+32, 0) + if *(*uintptr)(unsafe.Pointer(bp + 32)) == s || *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)))) != 0 && int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32))))) != '.' || !(func() int32 { + if 0 != 0 { + return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(s)))) + } + return Bool32(uint32(*(*int8)(unsafe.Pointer(s)))-uint32('0') < uint32(10)) + }() != 0) { + return 0 + } + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32))))) != 0) { + break + } + s = *(*uintptr)(unsafe.Pointer(bp + 32)) + uintptr(1) + } + if i == 4 { + return 0 + } + switch i { + case 0: + *(*uint64)(unsafe.Pointer(bp + 1*8)) = *(*uint64)(unsafe.Pointer(bp)) & uint64(0xffffff) + AssignShrPtrUint64(bp, int(24)) + fallthrough + case 1: + *(*uint64)(unsafe.Pointer(bp + 2*8)) = *(*uint64)(unsafe.Pointer(bp + 1*8)) & uint64(0xffff) + AssignShrPtrUint64(bp+1*8, int(16)) + fallthrough + case 2: + *(*uint64)(unsafe.Pointer(bp + 3*8)) = *(*uint64)(unsafe.Pointer(bp + 2*8)) & uint64(0xff) + AssignShrPtrUint64(bp+2*8, int(8)) + } + for i = 0; i < 4; i++ { + if *(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)) > uint64(255) { + return 0 + } + *(*uint8)(unsafe.Pointer(d + uintptr(i))) = uint8(*(*uint64)(unsafe.Pointer(bp + uintptr(i)*8))) + } + return 1 +} + +func Xinet_ntop(tls *TLS, af int32, a0 uintptr, s uintptr, l socklen_t) uintptr { /* inet_ntop.c:7:12: */ + if __ccgo_strace { + trc("tls=%v af=%v a0=%v s=%v l=%v, (%v:)", tls, af, a0, s, l, origin(2)) + } + bp := tls.Alloc(276) + defer tls.Free(276) + + var a uintptr = a0 + var i int32 + var j int32 + var max int32 + var best int32 + // var buf [100]int8 at bp+176, 100 + + switch af { + case 2: + if socklen_t(Xsnprintf(tls, s, uint64(l), ts+103, VaList(bp, int32(*(*uint8)(unsafe.Pointer(a))), int32(*(*uint8)(unsafe.Pointer(a + 1))), int32(*(*uint8)(unsafe.Pointer(a + 2))), int32(*(*uint8)(unsafe.Pointer(a + 3)))))) < l { + return s + } + break + case 10: + if Xmemcmp(tls, a, ts+90, uint64(12)) != 0 { + Xsnprintf(tls, bp+176, uint64(unsafe.Sizeof([100]int8{})), + ts+115, + VaList(bp+32, 256*int32(*(*uint8)(unsafe.Pointer(a)))+int32(*(*uint8)(unsafe.Pointer(a + 1))), 256*int32(*(*uint8)(unsafe.Pointer(a + 2)))+int32(*(*uint8)(unsafe.Pointer(a + 3))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 4)))+int32(*(*uint8)(unsafe.Pointer(a + 5))), 256*int32(*(*uint8)(unsafe.Pointer(a + 6)))+int32(*(*uint8)(unsafe.Pointer(a + 7))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 8)))+int32(*(*uint8)(unsafe.Pointer(a + 9))), 256*int32(*(*uint8)(unsafe.Pointer(a + 10)))+int32(*(*uint8)(unsafe.Pointer(a + 11))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 12)))+int32(*(*uint8)(unsafe.Pointer(a + 13))), 256*int32(*(*uint8)(unsafe.Pointer(a + 14)))+int32(*(*uint8)(unsafe.Pointer(a + 15))))) + } else { + Xsnprintf(tls, bp+176, uint64(unsafe.Sizeof([100]int8{})), + ts+139, + VaList(bp+96, 256*int32(*(*uint8)(unsafe.Pointer(a)))+int32(*(*uint8)(unsafe.Pointer(a + 1))), 256*int32(*(*uint8)(unsafe.Pointer(a + 2)))+int32(*(*uint8)(unsafe.Pointer(a + 3))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 4)))+int32(*(*uint8)(unsafe.Pointer(a + 5))), 256*int32(*(*uint8)(unsafe.Pointer(a + 6)))+int32(*(*uint8)(unsafe.Pointer(a + 7))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 8)))+int32(*(*uint8)(unsafe.Pointer(a + 9))), 256*int32(*(*uint8)(unsafe.Pointer(a + 10)))+int32(*(*uint8)(unsafe.Pointer(a + 11))), + int32(*(*uint8)(unsafe.Pointer(a + 12))), int32(*(*uint8)(unsafe.Pointer(a + 13))), int32(*(*uint8)(unsafe.Pointer(a + 14))), int32(*(*uint8)(unsafe.Pointer(a + 15))))) + } + // Replace longest /(^0|:)[:0]{2,}/ with "::" + i = AssignInt32(&best, 0) + max = 2 + for ; *(*int8)(unsafe.Pointer(bp + 176 + uintptr(i))) != 0; i++ { + if i != 0 && int32(*(*int8)(unsafe.Pointer(bp + 176 + uintptr(i)))) != ':' { + continue + } + j = int32(Xstrspn(tls, bp+176+uintptr(i), ts+169)) + if j > max { + best = i + max = j + } + } + if max > 3 { + *(*int8)(unsafe.Pointer(bp + 176 + uintptr(best))) = AssignPtrInt8(bp+176+uintptr(best+1), int8(':')) + Xmemmove(tls, bp+176+uintptr(best)+uintptr(2), bp+176+uintptr(best)+uintptr(max), uint64(i-best-max+1)) + } + if Xstrlen(tls, bp+176) < size_t(l) { + Xstrcpy(tls, s, bp+176) + return s + } + break + default: + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 97 + return uintptr(0) + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 28 + return uintptr(0) +} + +func hexval(tls *TLS, c uint32) int32 { /* inet_pton.c:7:12: */ + if c-uint32('0') < uint32(10) { + return int32(c - uint32('0')) + } + c = c | uint32(32) + if c-uint32('a') < uint32(6) { + return int32(c - uint32('a') + uint32(10)) + } + return -1 +} + +func Xinet_pton(tls *TLS, af int32, s uintptr, a0 uintptr) int32 { /* inet_pton.c:15:5: */ + if __ccgo_strace { + trc("tls=%v af=%v s=%v a0=%v, (%v:)", tls, af, s, a0, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + + // var ip [8]uint16_t at bp, 16 + + var a uintptr = a0 + var i int32 + var j int32 + var v int32 + var d int32 + var brk int32 = -1 + var need_v4 int32 = 0 + + if af == 2 { + for i = 0; i < 4; i++ { + for v = AssignInt32(&j, 0); j < 3 && func() int32 { + if 0 != 0 { + return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(s + uintptr(j))))) + } + return Bool32(uint32(*(*int8)(unsafe.Pointer(s + uintptr(j))))-uint32('0') < uint32(10)) + }() != 0; j++ { + v = 10*v + int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) - '0' + } + if j == 0 || j > 1 && int32(*(*int8)(unsafe.Pointer(s))) == '0' || v > 255 { + return 0 + } + *(*uint8)(unsafe.Pointer(a + uintptr(i))) = uint8(v) + if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) == 0 && i == 3 { + return 1 + } + if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != '.' { + return 0 + } + s += uintptr(j + 1) + } + return 0 + } else if af != 10 { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 97 + return -1 + } + + if int32(*(*int8)(unsafe.Pointer(s))) == ':' && int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&s, 1)))) != ':' { + return 0 + } + + for i = 0; ; i++ { + if int32(*(*int8)(unsafe.Pointer(s))) == ':' && brk < 0 { + brk = i + *(*uint16_t)(unsafe.Pointer(bp + uintptr(i&7)*2)) = uint16_t(0) + if !(int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&s, 1)))) != 0) { + break + } + if i == 7 { + return 0 + } + continue + } + for v = AssignInt32(&j, 0); j < 4 && AssignInt32(&d, hexval(tls, uint32(*(*int8)(unsafe.Pointer(s + uintptr(j)))))) >= 0; j++ { + v = 16*v + d + } + if j == 0 { + return 0 + } + *(*uint16_t)(unsafe.Pointer(bp + uintptr(i&7)*2)) = uint16_t(v) + if !(int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != 0) && (brk >= 0 || i == 7) { + break + } + if i == 7 { + return 0 + } + if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != ':' { + if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != '.' || i < 6 && brk < 0 { + return 0 + } + need_v4 = 1 + i++ + break + } + s += uintptr(j + 1) + } + if brk >= 0 { + Xmemmove(tls, bp+uintptr(brk)*2+uintptr(7)*2-uintptr(i)*2, bp+uintptr(brk)*2, uint64(2*(i+1-brk))) + for j = 0; j < 7-i; j++ { + *(*uint16_t)(unsafe.Pointer(bp + uintptr(brk+j)*2)) = uint16_t(0) + } + } + for j = 0; j < 8; j++ { + *(*uint8)(unsafe.Pointer(PostIncUintptr(&a, 1))) = uint8(int32(*(*uint16_t)(unsafe.Pointer(bp + uintptr(j)*2))) >> 8) + *(*uint8)(unsafe.Pointer(PostIncUintptr(&a, 1))) = uint8(*(*uint16_t)(unsafe.Pointer(bp + uintptr(j)*2))) + } + if need_v4 != 0 && Xinet_pton(tls, 2, s, a-uintptr(4)) <= 0 { + return 0 + } + return 1 +} + +func X__lookup_ipliteral(tls *TLS, buf uintptr, name uintptr, family int32) int32 { /* lookup_ipliteral.c:12:5: */ + if __ccgo_strace { + trc("tls=%v buf=%v name=%v family=%v, (%v:)", tls, buf, name, family, origin(2)) + } + bp := tls.Alloc(96) + defer tls.Free(96) + + // var a4 in_addr at bp, 4 + + // var a6 in6_addr at bp+68, 16 + + if X__inet_aton(tls, name, bp) > 0 { + if family == 10 { // wrong family + return -2 + } + Xmemcpy(tls, buf+8, bp, uint64(unsafe.Sizeof(in_addr{}))) + (*address)(unsafe.Pointer(buf)).Ffamily = 2 + (*address)(unsafe.Pointer(buf)).Fscopeid = uint32(0) + return 1 + } + // var tmp [64]int8 at bp+4, 64 + + var p uintptr = Xstrchr(tls, name, '%') + // var z uintptr at bp+88, 8 + + var scopeid uint64 = uint64(0) + if p != 0 && (int64(p)-int64(name))/1 < int64(64) { + Xmemcpy(tls, bp+4, name, uint64((int64(p)-int64(name))/1)) + *(*int8)(unsafe.Pointer(bp + 4 + uintptr((int64(p)-int64(name))/1))) = int8(0) + name = bp + 4 /* &tmp[0] */ + } + + if Xinet_pton(tls, 10, name, bp+68) <= 0 { + return 0 + } + if family == 2 { // wrong family + return -2 + } + + Xmemcpy(tls, buf+8, bp+68, uint64(unsafe.Sizeof(in6_addr{}))) + (*address)(unsafe.Pointer(buf)).Ffamily = 10 + if p != 0 { + if func() int32 { + if 0 != 0 { + return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&p, 1))))) + } + return Bool32(uint32(*(*int8)(unsafe.Pointer(PreIncUintptr(&p, 1))))-uint32('0') < uint32(10)) + }() != 0 { + scopeid = Xstrtoull(tls, p, bp+88, 10) + } else { + *(*uintptr)(unsafe.Pointer(bp + 88 /* z */)) = p - uintptr(1) + } + if *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 88)))) != 0 { + Xabort(tls) //TODO- + // if (!IN6_IS_ADDR_LINKLOCAL(&a6) && + // !IN6_IS_ADDR_MC_LINKLOCAL(&a6)) + // return EAI_NONAME; + // scopeid = if_nametoindex(p); + // if (!scopeid) return EAI_NONAME; + } + if scopeid > uint64(0xffffffff) { + return -2 + } + } + (*address)(unsafe.Pointer(buf)).Fscopeid = uint32(scopeid) + return 1 +} + +type mode_t = uint32 /* alltypes.h:152:18 */ + +type flock = struct { + Fl_type int16 + Fl_whence int16 + F__ccgo_pad1 [4]byte + Fl_start off_t + Fl_len off_t + Fl_pid pid_t + F__ccgo_pad2 [4]byte +} /* fcntl.h:24:1 */ + +func is_valid_hostname(tls *TLS, host uintptr) int32 { /* lookup_name.c:18:12: */ + var s uintptr + //TODO if (strnlen(host, 255)-1 >= 254 || mbstowcs(0, host, 0) == -1) return 0; + if Xstrnlen(tls, host, uint64(255))-uint64(1) >= uint64(254) { + return 0 + } + for s = host; int32(*(*uint8)(unsafe.Pointer(s))) >= 0x80 || int32(*(*uint8)(unsafe.Pointer(s))) == '.' || int32(*(*uint8)(unsafe.Pointer(s))) == '-' || Xisalnum(tls, int32(*(*uint8)(unsafe.Pointer(s)))) != 0; s++ { + } + return BoolInt32(!(*(*uint8)(unsafe.Pointer(s)) != 0)) +} + +var Xzero_struct_address address /* lookup_name.c:27:16: */ + +func name_from_null(tls *TLS, buf uintptr, name uintptr, family int32, flags int32) int32 { /* lookup_name.c:29:12: */ + var cnt int32 = 0 + if name != 0 { + return 0 + } + if flags&0x01 != 0 { + //TODO if (family != AF_INET6) + //TODO buf[cnt++] = (struct address){ .family = AF_INET }; + if family != 10 { + var x = Xzero_struct_address + x.Ffamily = 2 + *(*address)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*28)) = x + } + //TODO if (family != AF_INET) + //TODO buf[cnt++] = (struct address){ .family = AF_INET6 }; + if family != 2 { + var x = Xzero_struct_address + x.Ffamily = 10 + *(*address)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*28)) = x + } + } else { + Xabort(tls) //TODO- + // if (family != AF_INET6) + // buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } }; + // if (family != AF_INET) + // buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } }; + } + return cnt +} + +func name_from_numeric(tls *TLS, buf uintptr, name uintptr, family int32) int32 { /* lookup_name.c:58:12: */ + return X__lookup_ipliteral(tls, buf, name, family) +} + +func name_from_hosts(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) int32 { /* lookup_name.c:63:12: */ + bp := tls.Alloc(512) + defer tls.Free(512) + + // var line [512]int8 at bp, 512 + + var l size_t = Xstrlen(tls, name) + var cnt int32 = 0 + var badfam int32 = 0 + var _buf [1032]uint8 + _ = _buf + //TODO FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); + var _f FILE + _ = _f + var f uintptr = Xfopen(tls, ts+76, ts+87) + if !(f != 0) { + switch *(*int32)(unsafe.Pointer(X___errno_location(tls))) { + case 2: + fallthrough + case 20: + fallthrough + case 13: + return 0 + fallthrough + default: + return -11 + } + } + for Xfgets(tls, bp, int32(unsafe.Sizeof([512]int8{})), f) != 0 && cnt < 48 { + var p uintptr + var z uintptr + + if AssignUintptr(&p, Xstrchr(tls, bp, '#')) != 0 { + *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8('\n') + *(*int8)(unsafe.Pointer(p)) = int8(0) + } + for p = bp + uintptr(1); AssignUintptr(&p, Xstrstr(tls, p, name)) != 0 && (!(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p + UintptrFromInt32(-1))))) != 0) || !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p + uintptr(l))))) != 0)); p++ { + } + if !(p != 0) { + continue + } + + // Isolate IP address to parse + for p = bp; /* &line[0] */ *(*int8)(unsafe.Pointer(p)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0); p++ { + } + *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8(0) + switch name_from_numeric(tls, buf+uintptr(cnt)*28, bp, family) { + case 1: + cnt++ + break + case 0: + continue + default: + badfam = -2 + continue + } + + // Extract first name as canonical name + for ; *(*int8)(unsafe.Pointer(p)) != 0 && __isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0; p++ { + } + for z = p; *(*int8)(unsafe.Pointer(z)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(z)))) != 0); z++ { + } + *(*int8)(unsafe.Pointer(z)) = int8(0) + if is_valid_hostname(tls, p) != 0 { + Xmemcpy(tls, canon, p, uint64((int64(z)-int64(p))/1+int64(1))) + } + } + //TODO __fclose_ca(f); + Xfclose(tls, f) + if cnt != 0 { + return cnt + } + return badfam +} + +type dpc_ctx = struct { + Faddrs uintptr + Fcanon uintptr + Fcnt int32 + F__ccgo_pad1 [4]byte +} /* lookup_name.c:112:1 */ + +func name_from_dns_search(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) int32 { /* lookup_name.c:191:12: */ + return -1 //TODO- + Xabort(tls) + return int32(0) //TODO- + // char search[256]; + // struct resolvconf conf; + // size_t l, dots; + // char *p, *z; + + // if (__get_resolv_conf(&conf, search, sizeof search) < 0) return -1; + + // /* Count dots, suppress search when >=ndots or name ends in + // * a dot, which is an explicit request for global scope. */ + // for (dots=l=0; name[l]; l++) if (name[l]=='.') dots++; + // if (dots >= conf.ndots || name[l-1]=='.') *search = 0; + + // /* Strip final dot for canon, fail if multiple trailing dots. */ + // if (name[l-1]=='.') l--; + // if (!l || name[l-1]=='.') return EAI_NONAME; + + // /* This can never happen; the caller already checked length. */ + // if (l >= 256) return EAI_NONAME; + + // /* Name with search domain appended is setup in canon[]. This both + // * provides the desired default canonical name (if the requested + // * name is not a CNAME record) and serves as a buffer for passing + // * the full requested name to name_from_dns. */ + // memcpy(canon, name, l); + // canon[l] = '.'; + + // for (p=search; *p; p=z) { + // for (; isspace(*p); p++); + // for (z=p; *z && !isspace(*z); z++); + // if (z==p) break; + // if (z-p < 256 - l - 1) { + // memcpy(canon+l+1, p, z-p); + // canon[z-p+1+l] = 0; + // int cnt = name_from_dns(buf, canon, canon, family, &conf); + // if (cnt) return cnt; + // } + // } + + // canon[l] = 0; + // return name_from_dns(buf, canon, name, family, &conf); +} + +type policy = struct { + Faddr [16]uint8 + Flen uint8 + Fmask uint8 + Fprec uint8 + Flabel uint8 +} /* lookup_name.c:237:14 */ + +var defpolicy = [6]policy{ + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 172)), Flen: uint8(15), Fmask: uint8(0xff), Fprec: uint8(50)}, + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 189)), Flen: uint8(11), Fmask: uint8(0xff), Fprec: uint8(35), Flabel: uint8(4)}, + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 205)), Flen: uint8(1), Fmask: uint8(0xff), Fprec: uint8(30), Flabel: uint8(2)}, + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 221)), Flen: uint8(3), Fmask: uint8(0xff), Fprec: uint8(5), Flabel: uint8(5)}, + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 237)), Fmask: uint8(0xfe), Fprec: uint8(3), Flabel: uint8(13)}, + // Last rule must match all addresses to stop loop. + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 253)), Fprec: uint8(40), Flabel: uint8(1)}, +} /* lookup_name.c:241:3 */ + +func policyof(tls *TLS, a uintptr) uintptr { /* lookup_name.c:259:28: */ + var i int32 + for i = 0; ; i++ { + if Xmemcmp(tls, a, uintptr(unsafe.Pointer(&defpolicy))+uintptr(i)*20, uint64(defpolicy[i].Flen)) != 0 { + continue + } + if int32(*(*uint8_t)(unsafe.Pointer(a + uintptr(defpolicy[i].Flen))))&int32(defpolicy[i].Fmask) != + int32(*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(&defpolicy)) + uintptr(i)*20 + uintptr(defpolicy[i].Flen)))) { + continue + } + return uintptr(unsafe.Pointer(&defpolicy)) + uintptr(i)*20 + } + return uintptr(0) +} + +func labelof(tls *TLS, a uintptr) int32 { /* lookup_name.c:272:12: */ + return int32((*policy)(unsafe.Pointer(policyof(tls, a))).Flabel) +} + +func scopeof(tls *TLS, a uintptr) int32 { /* lookup_name.c:277:12: */ + if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xff { + return int32(*(*uint8_t)(unsafe.Pointer(a + 1))) & 15 + } + if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xfe && int32(*(*uint8_t)(unsafe.Pointer(a + 1)))&0xc0 == 0x80 { + return 2 + } + if *(*uint32_t)(unsafe.Pointer(a)) == uint32_t(0) && *(*uint32_t)(unsafe.Pointer(a + 1*4)) == uint32_t(0) && *(*uint32_t)(unsafe.Pointer(a + 2*4)) == uint32_t(0) && int32(*(*uint8_t)(unsafe.Pointer(a + 12))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 13))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 14))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 15))) == 1 { + return 2 + } + if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xfe && int32(*(*uint8_t)(unsafe.Pointer(a + 1)))&0xc0 == 0xc0 { + return 5 + } + return 14 +} + +func prefixmatch(tls *TLS, s uintptr, d uintptr) int32 { /* lookup_name.c:286:12: */ + // FIXME: The common prefix length should be limited to no greater + // than the nominal length of the prefix portion of the source + // address. However the definition of the source prefix length is + // not clear and thus this limiting is not yet implemented. + var i uint32 + for i = uint32(0); i < uint32(128) && !((int32(*(*uint8_t)(unsafe.Pointer(s /* &.__in6_union */ /* &.__s6_addr */ + uintptr(i/uint32(8)))))^int32(*(*uint8_t)(unsafe.Pointer(d /* &.__in6_union */ /* &.__s6_addr */ + uintptr(i/uint32(8))))))&(int32(128)>>(i%uint32(8))) != 0); i++ { + } + return int32(i) +} + +func addrcmp(tls *TLS, _a uintptr, _b uintptr) int32 { /* lookup_name.c:305:12: */ + var a uintptr = _a + var b uintptr = _b + return (*address)(unsafe.Pointer(b)).Fsortkey - (*address)(unsafe.Pointer(a)).Fsortkey +} + +func X__lookup_name(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, flags int32) int32 { /* lookup_name.c:311:5: */ + if __ccgo_strace { + trc("tls=%v buf=%v canon=%v name=%v family=%v flags=%v, (%v:)", tls, buf, canon, name, family, flags, origin(2)) + } + bp := tls.Alloc(92) + defer tls.Free(92) + + var cnt int32 = 0 + var i int32 + var j int32 + _ = j + + *(*int8)(unsafe.Pointer(canon)) = int8(0) + if name != 0 { + // reject empty name and check len so it fits into temp bufs + var l size_t = Xstrnlen(tls, name, uint64(255)) + if l-uint64(1) >= uint64(254) { + return -2 + } + Xmemcpy(tls, canon, name, l+uint64(1)) + } + + // Procedurally, a request for v6 addresses with the v4-mapped + // flag set is like a request for unspecified family, followed + // by filtering of the results. + if flags&0x08 != 0 { + if family == 10 { + family = 0 + } else { + flags = flags - 0x08 + } + } + + // Try each backend until there's at least one result. + cnt = name_from_null(tls, buf, name, family, flags) + if !(cnt != 0) { + cnt = name_from_numeric(tls, buf, name, family) + } + if !(cnt != 0) && !(flags&0x04 != 0) { + cnt = name_from_hosts(tls, buf, canon, name, family) + if !(cnt != 0) { + cnt = name_from_dns_search(tls, buf, canon, name, family) + } + } + if cnt <= 0 { + if cnt != 0 { + return cnt + } + return -2 + } + + // Filter/transform results for v4-mapped lookup, if requested. + if flags&0x08 != 0 { + Xabort(tls) //TODO- + // if (!(flags & AI_ALL)) { + // /* If any v6 results exist, remove v4 results. */ + // for (i=0; i= 0 { + if !(Xconnect(tls, fd, da, dalen) != 0) { + key = key | 0x40000000 + if !(Xgetsockname(tls, fd, sa1, bp+88) != 0) { + if family == 2 { + Xmemcpy(tls, + bp+28+8+uintptr(12), + bp+72+4, uint64(4)) + } + if dscope == scopeof(tls, bp+28+8) { + key = key | 0x20000000 + } + if dlabel == labelof(tls, bp+28+8) { + key = key | 0x10000000 + } + prefixlen = prefixmatch(tls, bp+28+8, + bp+8) + } + } + Xclose(tls, fd) + } + key = key | dprec<<20 + key = key | (15-dscope)<<16 + key = key | prefixlen<<8 + key = key | (48-i)<<0 + (*address)(unsafe.Pointer(buf + uintptr(i)*28)).Fsortkey = key + } + Xqsort(tls, buf, uint64(cnt), uint64(unsafe.Sizeof(address{})), *(*uintptr)(unsafe.Pointer(&struct { + f func(*TLS, uintptr, uintptr) int32 + }{addrcmp}))) + + //TODO pthread_setcancelstate(cs, 0); + + return cnt +} + +func X__lookup_serv(tls *TLS, buf uintptr, name uintptr, proto int32, socktype int32, flags int32) int32 { /* lookup_serv.c:12:5: */ + if __ccgo_strace { + trc("tls=%v buf=%v name=%v proto=%v socktype=%v flags=%v, (%v:)", tls, buf, name, proto, socktype, flags, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + var line [128]int8 + _ = line + var cnt int32 = 0 + var p uintptr + _ = p + *(*uintptr)(unsafe.Pointer(bp /* z */)) = ts + 13 /* "" */ + var port uint64 = uint64(0) + + switch socktype { + case 1: + switch proto { + case 0: + proto = 6 + fallthrough + case 6: + break + default: + return -8 + } + break + case 2: + switch proto { + case 0: + proto = 17 + fallthrough + case 17: + break + default: + return -8 + } + fallthrough + case 0: + break + default: + if name != 0 { + return -8 + } + (*service)(unsafe.Pointer(buf)).Fport = uint16_t(0) + (*service)(unsafe.Pointer(buf)).Fproto = uint8(proto) + (*service)(unsafe.Pointer(buf)).Fsocktype = uint8(socktype) + return 1 + } + + if name != 0 { + if !(int32(*(*int8)(unsafe.Pointer(name))) != 0) { + return -8 + } + port = Xstrtoul(tls, name, bp, 10) + } + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0) { + if port > uint64(65535) { + return -8 + } + if proto != 17 { + (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fport = uint16_t(port) + (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fsocktype = uint8(1) + (*service)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*4)).Fproto = uint8(6) + } + if proto != 6 { + (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fport = uint16_t(port) + (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fsocktype = uint8(2) + (*service)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*4)).Fproto = uint8(17) + } + return cnt + } + + if flags&0x400 != 0 { + return -2 + } + + var l size_t = Xstrlen(tls, name) + _ = l + + Xabort(tls) //TODO- + // unsigned char _buf[1032]; + // FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf); + // if (!f) switch (errno) { + // case ENOENT: + // case ENOTDIR: + // case EACCES: + // return EAI_SERVICE; + // default: + // return EAI_SYSTEM; + // } + + Xabort(tls) //TODO- + // while (fgets(line, sizeof line, f) && cnt < MAXSERVS) { + // if ((p=strchr(line, '#'))) *p++='\n', *p=0; + + // /* Find service name */ + // for(p=line; (p=strstr(p, name)); p++) { + // if (p>line && !isspace(p[-1])) continue; + // if (p[l] && !isspace(p[l])) continue; + // break; + // } + // if (!p) continue; + + // /* Skip past canonical name at beginning of line */ + // for (p=line; *p && !isspace(*p); p++); + + // port = strtoul(p, &z, 10); + // if (port > 65535 || z==p) continue; + // if (!strncmp(z, "/udp", 4)) { + // if (proto == IPPROTO_TCP) continue; + // buf[cnt].port = port; + // buf[cnt].socktype = SOCK_DGRAM; + // buf[cnt++].proto = IPPROTO_UDP; + // } + // if (!strncmp(z, "/tcp", 4)) { + // if (proto == IPPROTO_UDP) continue; + // buf[cnt].port = port; + // buf[cnt].socktype = SOCK_STREAM; + // buf[cnt++].proto = IPPROTO_TCP; + // } + // } + // __fclose_ca(f); + // return cnt > 0 ? cnt : EAI_SERVICE; + Xabort(tls) + return int32(0) //TODO- +} + +func temper(tls *TLS, x uint32) uint32 { /* rand_r.c:3:17: */ + x = x ^ x>>11 + x = x ^ x<<7&0x9D2C5680 + x = x ^ x<<15&0xEFC60000 + x = x ^ x>>18 + return x +} + +func Xrand_r(tls *TLS, seed uintptr) int32 { /* rand_r.c:12:5: */ + if __ccgo_strace { + trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2)) + } + return int32(temper(tls, AssignPtrUint32(seed, *(*uint32)(unsafe.Pointer(seed))*uint32(1103515245)+uint32(12345))) / uint32(2)) +} + +func X__toread(tls *TLS, f uintptr) int32 { /* __toread.c:3:5: */ + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + *(*int32)(unsafe.Pointer(f + 136)) |= (*FILE)(unsafe.Pointer(f)).Fmode - 1 + if (*FILE)(unsafe.Pointer(f)).Fwpos != (*FILE)(unsafe.Pointer(f)).Fwbase { + (*struct { + f func(*TLS, uintptr, uintptr, size_t) size_t + })(unsafe.Pointer(&struct{ uintptr }{(*FILE)(unsafe.Pointer(f)).Fwrite})).f(tls, f, uintptr(0), uint64(0)) + } + (*FILE)(unsafe.Pointer(f)).Fwpos = AssignPtrUintptr(f+56, AssignPtrUintptr(f+32, uintptr(0))) + if (*FILE)(unsafe.Pointer(f)).Fflags&uint32(4) != 0 { + *(*uint32)(unsafe.Pointer(f)) |= uint32(32) + return -1 + } + (*FILE)(unsafe.Pointer(f)).Frpos = AssignPtrUintptr(f+16, (*FILE)(unsafe.Pointer(f)).Fbuf+uintptr((*FILE)(unsafe.Pointer(f)).Fbuf_size)) + if (*FILE)(unsafe.Pointer(f)).Fflags&uint32(16) != 0 { + return -1 + } + return 0 +} + +func X__toread_needs_stdio_exit(tls *TLS) { /* __toread.c:16:13: */ + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__builtin_abort(tls) //TODO- + // __stdio_exit_needed(); +} + +// This function assumes it will never be called if there is already +// data buffered for reading. + +func X__uflow(tls *TLS, f uintptr) int32 { /* __uflow.c:6:5: */ + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + bp := tls.Alloc(1) + defer tls.Free(1) + + // var c uint8 at bp, 1 + + if !(X__toread(tls, f) != 0) && (*struct { + f func(*TLS, uintptr, uintptr, size_t) size_t + })(unsafe.Pointer(&struct{ uintptr }{(*FILE)(unsafe.Pointer(f)).Fread})).f(tls, f, bp, uint64(1)) == uint64(1) { + return int32(*(*uint8)(unsafe.Pointer(bp))) + } + return -1 +} + +func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */ + if __ccgo_strace { + trc("tls=%v key=%v base=%v nel=%v width=%v cmp=%v, (%v:)", tls, key, base, nel, width, cmp, origin(2)) + } + var try uintptr + var sign int32 + for nel > uint64(0) { + try = base + uintptr(width*(nel/uint64(2))) + sign = (*struct { + f func(*TLS, uintptr, uintptr) int32 + })(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try) + if sign < 0 { + nel = nel / uint64(2) + } else if sign > 0 { + base = try + uintptr(width) + nel = nel - (nel/uint64(2) + uint64(1)) + } else { + return try + } + } + return uintptr(0) +} + +func strtox(tls *TLS, s uintptr, p uintptr, prec int32) float64 { /* strtod.c:6:20: */ + bp := tls.Alloc(232) + defer tls.Free(232) + + // var f FILE at bp, 232 + + (*FILE)(unsafe.Pointer(bp)).Fbuf = AssignPtrUintptr(bp+8, s) + (*FILE)(unsafe.Pointer(bp)).Frend = UintptrFromInt32(-1) + X__shlim(tls, bp, int64(0)) + var y float64 = X__floatscan(tls, bp, prec, 1) + var cnt off_t = (*FILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*FILE)(unsafe.Pointer(bp)).Frpos)-int64((*FILE)(unsafe.Pointer(bp)).Fbuf))/1 + if p != 0 { + *(*uintptr)(unsafe.Pointer(p)) = func() uintptr { + if cnt != 0 { + return s + uintptr(cnt) + } + return s + }() + } + return y +} + +func Xstrtof(tls *TLS, s uintptr, p uintptr) float32 { /* strtod.c:17:7: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + } + return float32(strtox(tls, s, p, 0)) +} + +func Xstrtod(tls *TLS, s uintptr, p uintptr) float64 { /* strtod.c:22:8: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + } + return strtox(tls, s, p, 1) +} + +func Xstrtold(tls *TLS, s uintptr, p uintptr) float64 { /* strtod.c:27:13: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + } + return strtox(tls, s, p, 2) +} + +func strtox1(tls *TLS, s uintptr, p uintptr, base int32, lim uint64) uint64 { /* strtol.c:8:27: */ + bp := tls.Alloc(232) + defer tls.Free(232) + + // var f FILE at bp, 232 + + (*FILE)(unsafe.Pointer(bp)).Fbuf = AssignPtrUintptr(bp+8, s) + (*FILE)(unsafe.Pointer(bp)).Frend = UintptrFromInt32(-1) + X__shlim(tls, bp, int64(0)) + var y uint64 = X__intscan(tls, bp, uint32(base), 1, lim) + if p != 0 { + var cnt size_t = size_t((*FILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*FILE)(unsafe.Pointer(bp)).Frpos)-int64((*FILE)(unsafe.Pointer(bp)).Fbuf))/1) + *(*uintptr)(unsafe.Pointer(p)) = s + uintptr(cnt) + } + return y +} + +func Xstrtoull(tls *TLS, s uintptr, p uintptr, base int32) uint64 { /* strtol.c:21:20: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return strtox1(tls, s, p, base, 2*uint64(0x7fffffffffffffff)+uint64(1)) +} + +func Xstrtoll(tls *TLS, s uintptr, p uintptr, base int32) int64 { /* strtol.c:26:11: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return int64(strtox1(tls, s, p, base, Uint64FromInt64(-0x7fffffffffffffff-int64(1)))) +} + +func Xstrtoul(tls *TLS, s uintptr, p uintptr, base int32) uint64 { /* strtol.c:31:15: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return uint64(strtox1(tls, s, p, base, 2*uint64(0x7fffffffffffffff)+uint64(1))) +} + +func Xstrtol(tls *TLS, s uintptr, p uintptr, base int32) int64 { /* strtol.c:36:6: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return int64(strtox1(tls, s, p, base, 0+Uint64FromInt64(Int64(-Int64(0x7fffffffffffffff))-Int64FromInt32(1)))) +} + +func Xstrtoimax(tls *TLS, s uintptr, p uintptr, base int32) intmax_t { /* strtol.c:41:10: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return intmax_t(Xstrtoll(tls, s, p, base)) +} + +func Xstrtoumax(tls *TLS, s uintptr, p uintptr, base int32) uintmax_t { /* strtol.c:46:11: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return uintmax_t(Xstrtoull(tls, s, p, base)) +} + +// Support signed or unsigned plain-char + +// Implementation choices... + +// Arbitrary numbers... + +// POSIX/SUS requirements follow. These numbers come directly +// from SUS and have nothing to do with the host system. + +func X__strchrnul(tls *TLS, s uintptr, c int32) uintptr { /* strchrnul.c:10:6: */ + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + } + c = int32(uint8(c)) + if !(c != 0) { + return s + uintptr(Xstrlen(tls, s)) + } + var w uintptr + for ; uintptr_t(s)%uintptr_t(unsafe.Sizeof(size_t(0))) != 0; s++ { + if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) || int32(*(*uint8)(unsafe.Pointer(s))) == c { + return s + } + } + var k size_t = Uint64(Uint64FromInt32(-1)) / uint64(255) * size_t(c) + for w = s; !((*(*uint64)(unsafe.Pointer(w))-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^*(*uint64)(unsafe.Pointer(w)) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0) && !((*(*uint64)(unsafe.Pointer(w))^k-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^(*(*uint64)(unsafe.Pointer(w))^k) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0); w += 8 { + } + s = w + for ; *(*int8)(unsafe.Pointer(s)) != 0 && int32(*(*uint8)(unsafe.Pointer(s))) != c; s++ { + } + return s +} + +func Xstrdup(tls *TLS, s uintptr) uintptr { /* strdup.c:4:6: */ + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + } + var l size_t = Xstrlen(tls, s) + var d uintptr = Xmalloc(tls, l+uint64(1)) + if !(d != 0) { + return uintptr(0) + } + return Xmemcpy(tls, d, s, l+uint64(1)) +} + +func Xstrlcat(tls *TLS, d uintptr, s uintptr, n size_t) size_t { /* strlcat.c:4:8: */ + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + } + var l size_t = Xstrnlen(tls, d, n) + if l == n { + return l + Xstrlen(tls, s) + } + return l + Xstrlcpy(tls, d+uintptr(l), s, n-l) +} + +// Support signed or unsigned plain-char + +// Implementation choices... + +// Arbitrary numbers... + +// POSIX/SUS requirements follow. These numbers come directly +// from SUS and have nothing to do with the host system. + +func Xstrlcpy(tls *TLS, d uintptr, s uintptr, n size_t) size_t { /* strlcpy.c:11:8: */ + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + } + var d0 uintptr + var wd uintptr + var ws uintptr + d0 = d + + if !!(int32(PostDecUint64(&n, 1)) != 0) { + goto __1 + } + goto finish +__1: + ; + if !(uintptr_t(s)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1)) == uintptr_t(d)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1))) { + goto __2 + } +__3: + if !(uintptr_t(s)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1)) != 0 && n != 0 && AssignPtrInt8(d, *(*int8)(unsafe.Pointer(s))) != 0) { + goto __5 + } + goto __4 +__4: + n-- + s++ + d++ + goto __3 + goto __5 +__5: + ; + if !(n != 0 && *(*int8)(unsafe.Pointer(s)) != 0) { + goto __6 + } + wd = d + ws = s +__7: + if !(n >= size_t(unsafe.Sizeof(size_t(0))) && !((*(*uint64)(unsafe.Pointer(ws))-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^*(*uint64)(unsafe.Pointer(ws)) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0)) { + goto __9 + } + *(*size_t)(unsafe.Pointer(wd)) = *(*uint64)(unsafe.Pointer(ws)) + goto __8 +__8: + n = n - size_t(unsafe.Sizeof(size_t(0))) + ws += 8 + wd += 8 + goto __7 + goto __9 +__9: + ; + d = wd + s = ws +__6: + ; +__2: + ; +__10: + if !(n != 0 && AssignPtrInt8(d, *(*int8)(unsafe.Pointer(s))) != 0) { + goto __12 + } + goto __11 +__11: + n-- + s++ + d++ + goto __10 + goto __12 +__12: + ; + *(*int8)(unsafe.Pointer(d)) = int8(0) +finish: + return size_t((int64(d)-int64(d0))/1) + Xstrlen(tls, s) +} + +func Xstrncasecmp(tls *TLS, _l uintptr, _r uintptr, n size_t) int32 { /* strncasecmp.c:4:5: */ + if __ccgo_strace { + trc("tls=%v _l=%v _r=%v n=%v, (%v:)", tls, _l, _r, n, origin(2)) + } + var l uintptr = _l + var r uintptr = _r + if !(int32(PostDecUint64(&n, 1)) != 0) { + return 0 + } +__1: + if !(*(*uint8)(unsafe.Pointer(l)) != 0 && *(*uint8)(unsafe.Pointer(r)) != 0 && n != 0 && (int32(*(*uint8)(unsafe.Pointer(l))) == int32(*(*uint8)(unsafe.Pointer(r))) || Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(l)))) == Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(r)))))) { + goto __3 + } + goto __2 +__2: + l++ + r++ + n-- + goto __1 + goto __3 +__3: + ; + return Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(l)))) - Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(r)))) +} + +func X__strncasecmp_l(tls *TLS, l uintptr, r uintptr, n size_t, loc locale_t) int32 { /* strncasecmp.c:12:5: */ + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v loc=%v, (%v:)", tls, l, r, n, loc, origin(2)) + } + return Xstrncasecmp(tls, l, r, n) +} + +func Xstrncat(tls *TLS, d uintptr, s uintptr, n size_t) uintptr { /* strncat.c:3:6: */ + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + } + var a uintptr = d + d += uintptr(Xstrlen(tls, d)) + for n != 0 && *(*int8)(unsafe.Pointer(s)) != 0 { + n-- + *(*int8)(unsafe.Pointer(PostIncUintptr(&d, 1))) = *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) + } + *(*int8)(unsafe.Pointer(PostIncUintptr(&d, 1))) = int8(0) + return a +} + +func Xstrnlen(tls *TLS, s uintptr, n size_t) size_t { /* strnlen.c:3:8: */ + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + } + var p uintptr = Xmemchr(tls, s, 0, n) + if p != 0 { + return uint64((int64(p) - int64(s)) / 1) + } + return n +} + +func Xstrspn(tls *TLS, s uintptr, c uintptr) size_t { /* strspn.c:6:8: */ + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + } + bp := tls.Alloc(32) + defer tls.Free(32) + + var a uintptr = s + *(*[4]size_t)(unsafe.Pointer(bp /* byteset */)) = [4]size_t{0: uint64(0)} + + if !(int32(*(*int8)(unsafe.Pointer(c))) != 0) { + return uint64(0) + } + if !(int32(*(*int8)(unsafe.Pointer(c + 1))) != 0) { + for ; int32(*(*int8)(unsafe.Pointer(s))) == int32(*(*int8)(unsafe.Pointer(c))); s++ { + } + return size_t((int64(s) - int64(a)) / 1) + } + + for ; *(*int8)(unsafe.Pointer(c)) != 0 && AssignOrPtrUint64(bp+uintptr(size_t(*(*uint8)(unsafe.Pointer(c)))/(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))*8, size_t(uint64(1))<<(size_t(*(*uint8)(unsafe.Pointer(c)))%(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))) != 0; c++ { + } + for ; *(*int8)(unsafe.Pointer(s)) != 0 && *(*size_t)(unsafe.Pointer(bp + uintptr(size_t(*(*uint8)(unsafe.Pointer(s)))/(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))*8))&(size_t(uint64(1))<<(size_t(*(*uint8)(unsafe.Pointer(s)))%(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))) != 0; s++ { + } + return size_t((int64(s) - int64(a)) / 1) +} + +func Xstrtok(tls *TLS, s uintptr, sep uintptr) uintptr { /* strtok.c:3:6: */ + if __ccgo_strace { + trc("tls=%v s=%v sep=%v, (%v:)", tls, s, sep, origin(2)) + } + if !(s != 0) && !(int32(AssignUintptr(&s, _sp)) != 0) { + return uintptr(0) + } + s += uintptr(Xstrspn(tls, s, sep)) + if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) { + return AssignPtrUintptr(uintptr(unsafe.Pointer(&_sp)), uintptr(0)) + } + _sp = s + uintptr(Xstrcspn(tls, s, sep)) + if *(*int8)(unsafe.Pointer(_sp)) != 0 { + *(*int8)(unsafe.Pointer(PostIncUintptr(&_sp, 1))) = int8(0) + } else { + _sp = uintptr(0) + } + return s +} + +var _sp uintptr /* strtok.c:5:14: */ + +func init() { + *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_CurrentRuneLocale)) + 0)) = uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) // table.c:1940:35: + *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_CurrentRuneLocale)) + 0)) = uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) // table.c:1940:35: +} + +var ts1 = "infinity\x00nan\x00\x00\x00\x01\x02\x04\a\x03\x06\x05\x00.\x00%d.%d.%d.%d.in-addr.arpa\x00ip6.arpa\x000123456789abcdef\x00/etc/hosts\x00rb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00%d.%d.%d.%d\x00%x:%x:%x:%x:%x:%x:%x:%x\x00%x:%x:%x:%x:%x:%x:%d.%d.%d.%d\x00:0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00 \x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data diff --git a/internal/libc/musl_darwin_arm64.go b/internal/libc/musl_darwin_arm64.go new file mode 100644 index 0000000..65b8c53 --- /dev/null +++ b/internal/libc/musl_darwin_arm64.go @@ -0,0 +1,4984 @@ +// Code generated by 'ccgo -D__environ=environ -export-externs X -export-fields F -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -hide isascii,isspace,tolower,toupper -nostdinc -nostdlib -o ../musl_darwin_arm64.go -pkgname libc -static-locals-prefix _s -Iarch/aarch64 -Iarch/generic -Iobj/src/internal -Isrc/include -Isrc/internal -Iobj/include -Iinclude copyright.c ../darwin/table.c src/env/putenv.c src/env/setenv.c src/env/unsetenv.c src/internal/floatscan.c src/internal/intscan.c src/internal/shgetc.c src/locale/localeconv.c src/math/__fpclassify.c src/math/__fpclassifyf.c src/math/__fpclassifyl.c src/math/copysignl.c src/math/fabsl.c src/math/fmodl.c src/math/nanf.c src/math/rint.c src/math/scalbn.c src/math/scalbnl.c src/network/freeaddrinfo.c src/network/getaddrinfo.c src/network/gethostbyaddr.c src/network/gethostbyaddr_r.c src/network/gethostbyname.c src/network/gethostbyname2.c src/network/gethostbyname2_r.c src/network/getnameinfo.c src/network/h_errno.c src/network/inet_aton.c src/network/inet_ntop.c src/network/inet_pton.c src/network/lookup_ipliteral.c src/network/lookup_name.c src/network/lookup_serv.c src/prng/rand_r.c src/stdio/__toread.c src/stdio/__uflow.c src/stdlib/bsearch.c src/stdlib/strtod.c src/stdlib/strtol.c src/string/strchrnul.c src/string/strdup.c src/string/strlcat.c src/string/strlcpy.c src/string/strncasecmp.c src/string/strncat.c src/string/strnlen.c src/string/strspn.c src/string/strtok.c', DO NOT EDIT. + +package libc + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +// musl as a whole is licensed under the following standard MIT license: +// +// ---------------------------------------------------------------------- +// Copyright © 2005-2020 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. +// ---------------------------------------------------------------------- +// +// Authors/contributors include: +// +// A. Wilcox +// Ada Worcester +// Alex Dowad +// Alex Suykov +// Alexander Monakov +// Andre McCurdy +// Andrew Kelley +// Anthony G. Basile +// Aric Belsito +// Arvid Picciani +// Bartosz Brachaczek +// Benjamin Peterson +// Bobby Bingham +// Boris Brezillon +// Brent Cook +// Chris Spiegel +// Clément Vasseur +// Daniel Micay +// Daniel Sabogal +// Daurnimator +// David Carlier +// David Edelsohn +// Denys Vlasenko +// Dmitry Ivanov +// Dmitry V. Levin +// Drew DeVault +// Emil Renner Berthing +// Fangrui Song +// Felix Fietkau +// Felix Janda +// Gianluca Anzolin +// Hauke Mehrtens +// He X +// Hiltjo Posthuma +// Isaac Dunham +// Jaydeep Patil +// Jens Gustedt +// Jeremy Huntwork +// Jo-Philipp Wich +// Joakim Sindholt +// John Spencer +// Julien Ramseier +// Justin Cormack +// Kaarle Ritvanen +// Khem Raj +// Kylie McClain +// Leah Neukirchen +// Luca Barbato +// Luka Perkov +// M Farkas-Dyck (Strake) +// Mahesh Bodapati +// Markus Wichmann +// Masanori Ogino +// Michael Clark +// Michael Forney +// Mikhail Kremnyov +// Natanael Copa +// Nicholas J. Kain +// orc +// Pascal Cuoq +// Patrick Oppenlander +// Petr Hosek +// Petr Skocik +// Pierre Carrier +// Reini Urban +// Rich Felker +// Richard Pennington +// Ryan Fairfax +// Samuel Holland +// Segev Finer +// Shiz +// sin +// Solar Designer +// Stefan Kristiansson +// Stefan O'Rear +// Szabolcs Nagy +// Timo Teräs +// Trutz Behn +// Valentin Ochs +// Will Dietz +// William Haddon +// William Pitcock +// +// Portions of this software are derived from third-party works licensed +// under terms compatible with the above MIT license: +// +// The TRE regular expression implementation (src/regex/reg* and +// src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed +// under a 2-clause BSD license (license text in the source files). The +// included version has been heavily modified by Rich Felker in 2012, in +// the interests of size, simplicity, and namespace cleanliness. +// +// Much of the math library code (src/math/* and src/complex/*) is +// Copyright © 1993,2004 Sun Microsystems or +// Copyright © 2003-2011 David Schultz or +// Copyright © 2003-2009 Steven G. Kargl or +// Copyright © 2003-2009 Bruce D. Evans or +// Copyright © 2008 Stephen L. Moshier or +// Copyright © 2017-2018 Arm Limited +// and labelled as such in comments in the individual source files. All +// have been licensed under extremely permissive terms. +// +// The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008 +// The Android Open Source Project and is licensed under a two-clause BSD +// license. It was taken from Bionic libc, used on Android. +// +// The AArch64 memcpy and memset code (src/string/aarch64/*) are +// Copyright © 1999-2019, Arm Limited. +// +// The implementation of DES for crypt (src/crypt/crypt_des.c) is +// Copyright © 1994 David Burren. It is licensed under a BSD license. +// +// The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was +// originally written by Solar Designer and placed into the public +// domain. The code also comes with a fallback permissive license for use +// in jurisdictions that may not recognize the public domain. +// +// The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011 +// Valentin Ochs and is licensed under an MIT-style license. +// +// The x86_64 port was written by Nicholas J. Kain and is licensed under +// the standard MIT terms. +// +// The mips and microblaze ports were originally written by Richard +// Pennington for use in the ellcc project. The original code was adapted +// by Rich Felker for build system and code conventions during upstream +// integration. It is licensed under the standard MIT terms. +// +// The mips64 port was contributed by Imagination Technologies and is +// licensed under the standard MIT terms. +// +// The powerpc port was also originally written by Richard Pennington, +// and later supplemented and integrated by John Spencer. It is licensed +// under the standard MIT terms. +// +// All other files which have no copyright comments are original works +// produced specifically for use as part of this library, written either +// by Rich Felker, the main author of the library, or by one or more +// contibutors listed above. Details on authorship of individual files +// can be found in the git version control history of the project. The +// omission of copyright and license comments in each file is in the +// interest of source tree size. +// +// In addition, permission is hereby granted for all public header files +// (include/* and arch/*/bits/*) and crt files intended to be linked into +// applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit +// the copyright notice and permission notice otherwise required by the +// license, and to use these files without any requirement of +// attribution. These files include substantial contributions from: +// +// Bobby Bingham +// John Spencer +// Nicholas J. Kain +// Rich Felker +// Richard Pennington +// Stefan Kristiansson +// Szabolcs Nagy +// +// all of whom have explicitly granted such permission. +// +// This file previously contained text expressing a belief that most of +// the files covered by the above exception were sufficiently trivial not +// to be subject to copyright, resulting in confusion over whether it +// negated the permissions granted in the license. In the spirit of +// permissive licensing, and of not having licensing issues being an +// obstacle to adoption, that text has been removed. +const ( /* copyright.c:194:1: */ + __musl__copyright__ = 0 +) + +const ( /* nameser.h:117:1: */ + ns_uop_delete = 0 + ns_uop_add = 1 + ns_uop_max = 2 +) + +const ( /* nameser.h:147:1: */ + ns_t_invalid = 0 + ns_t_a = 1 + ns_t_ns = 2 + ns_t_md = 3 + ns_t_mf = 4 + ns_t_cname = 5 + ns_t_soa = 6 + ns_t_mb = 7 + ns_t_mg = 8 + ns_t_mr = 9 + ns_t_null = 10 + ns_t_wks = 11 + ns_t_ptr = 12 + ns_t_hinfo = 13 + ns_t_minfo = 14 + ns_t_mx = 15 + ns_t_txt = 16 + ns_t_rp = 17 + ns_t_afsdb = 18 + ns_t_x25 = 19 + ns_t_isdn = 20 + ns_t_rt = 21 + ns_t_nsap = 22 + ns_t_nsap_ptr = 23 + ns_t_sig = 24 + ns_t_key = 25 + ns_t_px = 26 + ns_t_gpos = 27 + ns_t_aaaa = 28 + ns_t_loc = 29 + ns_t_nxt = 30 + ns_t_eid = 31 + ns_t_nimloc = 32 + ns_t_srv = 33 + ns_t_atma = 34 + ns_t_naptr = 35 + ns_t_kx = 36 + ns_t_cert = 37 + ns_t_a6 = 38 + ns_t_dname = 39 + ns_t_sink = 40 + ns_t_opt = 41 + ns_t_apl = 42 + ns_t_tkey = 249 + ns_t_tsig = 250 + ns_t_ixfr = 251 + ns_t_axfr = 252 + ns_t_mailb = 253 + ns_t_maila = 254 + ns_t_any = 255 + ns_t_zxfr = 256 + ns_t_max = 65536 +) + +const ( /* nameser.h:210:1: */ + ns_c_invalid = 0 + ns_c_in = 1 + ns_c_2 = 2 + ns_c_chaos = 3 + ns_c_hs = 4 + ns_c_none = 254 + ns_c_any = 255 + ns_c_max = 65536 +) + +const ( /* nameser.h:221:1: */ + ns_kt_rsa = 1 + ns_kt_dh = 2 + ns_kt_dsa = 3 + ns_kt_private = 254 +) + +const ( /* nameser.h:228:1: */ + cert_t_pkix = 1 + cert_t_spki = 2 + cert_t_pgp = 3 + cert_t_url = 253 + cert_t_oid = 254 +) + +const ( /* nameser.h:28:1: */ + ns_s_qd = 0 + ns_s_zn = 0 + ns_s_an = 1 + ns_s_pr = 1 + ns_s_ns = 2 + ns_s_ud = 2 + ns_s_ar = 3 + ns_s_max = 4 +) + +const ( /* nameser.h:75:1: */ + ns_f_qr = 0 + ns_f_opcode = 1 + ns_f_aa = 2 + ns_f_tc = 3 + ns_f_rd = 4 + ns_f_ra = 5 + ns_f_z = 6 + ns_f_ad = 7 + ns_f_cd = 8 + ns_f_rcode = 9 + ns_f_max = 10 +) + +const ( /* nameser.h:89:1: */ + ns_o_query = 0 + ns_o_iquery = 1 + ns_o_status = 2 + ns_o_notify = 4 + ns_o_update = 5 + ns_o_max = 6 +) + +const ( /* nameser.h:98:1: */ + ns_r_noerror = 0 + ns_r_formerr = 1 + ns_r_servfail = 2 + ns_r_nxdomain = 3 + ns_r_notimpl = 4 + ns_r_refused = 5 + ns_r_yxdomain = 6 + ns_r_yxrrset = 7 + ns_r_nxrrset = 8 + ns_r_notauth = 9 + ns_r_notzone = 10 + ns_r_max = 11 + ns_r_badvers = 16 + ns_r_badsig = 16 + ns_r_badkey = 17 + ns_r_badtime = 18 +) + +type ptrdiff_t = int64 /* :3:26 */ + +type size_t = uint64 /* :9:23 */ + +type wchar_t = int32 /* :15:24 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// pthread opaque structures + +type __darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* table.c:1396:1 */ + +type _opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* table.c:1402:1 */ + +type _opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* table.c:1407:1 */ + +type _opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* table.c:1412:1 */ + +type _opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* table.c:1417:1 */ + +type _opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* table.c:1422:1 */ + +type _opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* table.c:1427:1 */ + +type _opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* table.c:1432:1 */ + +type _opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* table.c:1437:1 */ + +type _opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* table.c:1442:1 */ + +type ct_rune_t = int32 /* table.c:1527:28 */ + +type rune_t = int32 /* table.c:1536:25 */ + +type wint_t = int32 /* table.c:1558:25 */ + +type _RuneEntry = struct { + F__min int32 + F__max int32 + F__map int32 + F__ccgo_pad1 [4]byte + F__types uintptr +} /* table.c:1575:3 */ + +type _RuneRange = struct { + F__nranges int32 + F__ccgo_pad1 [4]byte + F__ranges uintptr +} /* table.c:1580:3 */ + +type _RuneCharClass = struct { + F__name [14]int8 + F__ccgo_pad1 [2]byte + F__mask uint32 +} /* table.c:1585:3 */ + +type _RuneLocale = struct { + F__magic [8]int8 + F__encoding [32]int8 + F__sgetrune uintptr + F__sputrune uintptr + F__invalid_rune int32 + F__runetype [256]uint32 + F__maplower [256]int32 + F__mapupper [256]int32 + F__ccgo_pad1 [4]byte + F__runetype_ext _RuneRange + F__maplower_ext _RuneRange + F__mapupper_ext _RuneRange + F__variable uintptr + F__variable_len int32 + F__ncharclasses int32 + F__charclasses uintptr +} /* table.c:1616:3 */ + +func X__istype(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1670:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2)) + } + + return func() int32 { + if Xisascii(tls, _c) != 0 { + return BoolInt32(!!(uint64(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c)*4)))&_f != 0)) + } + return BoolInt32(!!(X__maskrune(tls, _c, _f) != 0)) + }() + +} + +func X__isctype(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1681:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2)) + } + + if _c < 0 || _c >= int32(1)<<8 { + return 0 + } + return BoolInt32(!!(uint64(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c)*4)))&_f != 0)) + +} + +func X__wcwidth(tls *TLS, _c int32) int32 { /* table.c:1700:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + var _x uint32 + + if _c == 0 { + return 0 + } + _x = uint32(X__maskrune(tls, _c, uint64(0xe0000000|0x00040000))) + if int64(_x)&0xe0000000 != int64(0) { + return int32(int64(_x) & 0xe0000000 >> 30) + } + return func() int32 { + if int64(_x)&0x00040000 != int64(0) { + return 1 + } + return -1 + }() +} + +func Xisalnum(tls *TLS, _c int32) int32 { /* table.c:1718:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000100|0x00000400)) +} + +func Xisalpha(tls *TLS, _c int32) int32 { /* table.c:1724:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000100)) +} + +func Xisblank(tls *TLS, _c int32) int32 { /* table.c:1730:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00020000)) +} + +func Xiscntrl(tls *TLS, _c int32) int32 { /* table.c:1736:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000200)) +} + +func Xisdigit(tls *TLS, _c int32) int32 { /* table.c:1743:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__isctype(tls, _c, uint64(0x00000400)) +} + +func Xisgraph(tls *TLS, _c int32) int32 { /* table.c:1749:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000800)) +} + +func Xislower(tls *TLS, _c int32) int32 { /* table.c:1755:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00001000)) +} + +func Xisprint(tls *TLS, _c int32) int32 { /* table.c:1761:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00040000)) +} + +func Xispunct(tls *TLS, _c int32) int32 { /* table.c:1767:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00002000)) +} + +func Xisupper(tls *TLS, _c int32) int32 { /* table.c:1779:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00008000)) +} + +func Xisxdigit(tls *TLS, _c int32) int32 { /* table.c:1786:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__isctype(tls, _c, uint64(0x00010000)) +} + +func Xtoascii(tls *TLS, _c int32) int32 { /* table.c:1792:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return _c & 0x7F +} + +func Xdigittoint(tls *TLS, _c int32) int32 { /* table.c:1811:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__maskrune(tls, _c, uint64(0x0F)) +} + +func Xishexnumber(tls *TLS, _c int32) int32 { /* table.c:1817:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00010000)) +} + +func Xisideogram(tls *TLS, _c int32) int32 { /* table.c:1823:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00080000)) +} + +func Xisnumber(tls *TLS, _c int32) int32 { /* table.c:1829:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00000400)) +} + +func Xisphonogram(tls *TLS, _c int32) int32 { /* table.c:1835:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00200000)) +} + +func Xisrune(tls *TLS, _c int32) int32 { /* table.c:1841:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0xFFFFFFF0)) +} + +func Xisspecial(tls *TLS, _c int32) int32 { /* table.c:1847:1: */ + if __ccgo_strace { + trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2)) + } + return X__istype(tls, _c, uint64(0x00100000)) +} + +func X__maskrune(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1871:2: */ + if __ccgo_strace { + trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2)) + } + return int32(uint32(int32(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c&0xff)*4)))) & uint32(_f)) +} + +func X__toupper(tls *TLS, c int32) int32 { /* table.c:1876:20: */ + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + } + return Xtoupper(tls, c) +} + +func X__tolower(tls *TLS, c int32) int32 { /* table.c:1878:20: */ + if __ccgo_strace { + trc("tls=%v c=%v, (%v:)", tls, c, origin(2)) + } + return Xtolower(tls, c) +} + +var X_DefaultRuneLocale = _RuneLocale{F__magic: [8]int8{int8(82), int8(117), int8(110), int8(101), int8(77), int8(97), int8(103), int8(65)}, F__encoding: [32]int8{int8(78), int8(79), int8(78), int8(69), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0)}, F__invalid_rune: 0xfffd, F__runetype: [256]uint32{ + uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x24200), uint32(0x4200), uint32(0x4200), uint32(0x4200), uint32(0x4200), uint32(0x200), uint32(0x200), + uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), + uint32(0x64000), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), + uint32(0x50c00), uint32(0x50c01), uint32(0x50c02), uint32(0x50c03), uint32(0x50c04), uint32(0x50c05), uint32(0x50c06), uint32(0x50c07), uint32(0x50c08), uint32(0x50c09), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), + uint32(0x42800), uint32(0x5890a), uint32(0x5890b), uint32(0x5890c), uint32(0x5890d), uint32(0x5890e), uint32(0x5890f), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), + uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), + uint32(0x42800), uint32(0x5190a), uint32(0x5190b), uint32(0x5190c), uint32(0x5190d), uint32(0x5190e), uint32(0x5190f), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), + uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x200), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), + uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), +}, F__maplower: [256]int32{ + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 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, +}, F__mapupper: [256]int32{ + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 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, +}, +} /* table.c:1879:13 */ + +var X_CurrentRuneLocale uintptr = 0 /* table.c:1940:13 */ + +type div_t = struct { + Fquot int32 + Frem int32 +} /* stdlib.h:62:35 */ +type ldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:63:36 */ +type lldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:64:41 */ + +type locale_t = uintptr /* alltypes.h:351:32 */ + +type ssize_t = int64 /* alltypes.h:73:15 */ + +type intptr_t = int64 /* alltypes.h:78:15 */ + +type off_t = int64 /* alltypes.h:170:16 */ + +type pid_t = int32 /* alltypes.h:243:13 */ + +type uid_t = uint32 /* alltypes.h:253:18 */ + +type gid_t = uint32 /* alltypes.h:258:18 */ + +type useconds_t = uint32 /* alltypes.h:268:18 */ + +func X__putenv(tls *TLS, s uintptr, l size_t, r uintptr) int32 { /* putenv.c:8:5: */ + if __ccgo_strace { + trc("tls=%v s=%v l=%v r=%v, (%v:)", tls, s, l, r, origin(2)) + } + var i size_t + var newenv uintptr + var tmp uintptr + //TODO for (char **e = __environ; *e; e++, i++) + var e uintptr + i = uint64(0) + if !(Environ() != 0) { + goto __1 + } + //TODO for (char **e = __environ; *e; e++, i++) + e = Environ() +__2: + if !(*(*uintptr)(unsafe.Pointer(e)) != 0) { + goto __4 + } + if !!(Xstrncmp(tls, s, *(*uintptr)(unsafe.Pointer(e)), l+uint64(1)) != 0) { + goto __5 + } + tmp = *(*uintptr)(unsafe.Pointer(e)) + *(*uintptr)(unsafe.Pointer(e)) = s + X__env_rm_add(tls, tmp, r) + return 0 +__5: + ; + goto __3 +__3: + e += 8 + i++ + goto __2 + goto __4 +__4: + ; +__1: + ; + if !(Environ() == _soldenv) { + goto __6 + } + newenv = Xrealloc(tls, _soldenv, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2))) + if !!(newenv != 0) { + goto __8 + } + goto oom +__8: + ; + goto __7 +__6: + newenv = Xmalloc(tls, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2))) + if !!(newenv != 0) { + goto __9 + } + goto oom +__9: + ; + if !(i != 0) { + goto __10 + } + Xmemcpy(tls, newenv, Environ(), uint64(unsafe.Sizeof(uintptr(0)))*i) +__10: + ; + Xfree(tls, _soldenv) +__7: + ; + *(*uintptr)(unsafe.Pointer(newenv + uintptr(i)*8)) = s + *(*uintptr)(unsafe.Pointer(newenv + uintptr(i+uint64(1))*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(EnvironP())) = AssignPtrUintptr(uintptr(unsafe.Pointer(&_soldenv)), newenv) + if !(r != 0) { + goto __11 + } + X__env_rm_add(tls, uintptr(0), r) +__11: + ; + return 0 +oom: + Xfree(tls, r) + return -1 +} + +var _soldenv uintptr /* putenv.c:22:14: */ + +func Xputenv(tls *TLS, s uintptr) int32 { /* putenv.c:43:5: */ + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + } + var l size_t = size_t((int64(X__strchrnul(tls, s, '=')) - int64(s)) / 1) + if !(l != 0) || !(int32(*(*int8)(unsafe.Pointer(s + uintptr(l)))) != 0) { + return Xunsetenv(tls, s) + } + return X__putenv(tls, s, l, uintptr(0)) +} + +func X__env_rm_add(tls *TLS, old uintptr, new uintptr) { /* setenv.c:5:6: */ + if __ccgo_strace { + trc("tls=%v old=%v new=%v, (%v:)", tls, old, new, origin(2)) + } + //TODO for (size_t i=0; i < env_alloced_n; i++) + var i size_t = uint64(0) + for ; i < _senv_alloced_n; i++ { + if *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) == old { + *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new + Xfree(tls, old) + return + } else if !(int32(*(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8))) != 0) && new != 0 { + *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new + new = uintptr(0) + } + } + if !(new != 0) { + return + } + var t uintptr = Xrealloc(tls, _senv_alloced, uint64(unsafe.Sizeof(uintptr(0)))*(_senv_alloced_n+uint64(1))) + if !(t != 0) { + return + } + *(*uintptr)(unsafe.Pointer(AssignPtrUintptr(uintptr(unsafe.Pointer(&_senv_alloced)), t) + uintptr(PostIncUint64(&_senv_alloced_n, 1))*8)) = new +} + +var _senv_alloced uintptr /* setenv.c:7:14: */ +var _senv_alloced_n size_t /* setenv.c:8:16: */ + +func Xsetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) int32 { /* setenv.c:26:5: */ + if __ccgo_strace { + trc("tls=%v var1=%v value=%v overwrite=%v, (%v:)", tls, var1, value, overwrite, origin(2)) + } + var s uintptr + var l1 size_t + var l2 size_t + + if !(var1 != 0) || !(int32(AssignUint64(&l1, size_t((int64(X__strchrnul(tls, var1, '='))-int64(var1))/1))) != 0) || *(*int8)(unsafe.Pointer(var1 + uintptr(l1))) != 0 { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + return -1 + } + if !(overwrite != 0) && Xgetenv(tls, var1) != 0 { + return 0 + } + + l2 = Xstrlen(tls, value) + s = Xmalloc(tls, l1+l2+uint64(2)) + if !(s != 0) { + return -1 + } + Xmemcpy(tls, s, var1, l1) + *(*int8)(unsafe.Pointer(s + uintptr(l1))) = int8('=') + Xmemcpy(tls, s+uintptr(l1)+uintptr(1), value, l2+uint64(1)) + return X__putenv(tls, s, l1, s) +} + +func Xunsetenv(tls *TLS, name uintptr) int32 { /* unsetenv.c:9:5: */ + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + } + var l size_t = size_t((int64(X__strchrnul(tls, name, '=')) - int64(name)) / 1) + if !(l != 0) || *(*int8)(unsafe.Pointer(name + uintptr(l))) != 0 { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + return -1 + } + if Environ() != 0 { + var e uintptr = Environ() + var eo uintptr = e + for ; *(*uintptr)(unsafe.Pointer(e)) != 0; e += 8 { + //TODO if (!strncmp(name, *e, l) && l[*e] == '=') + if !(Xstrncmp(tls, name, *(*uintptr)(unsafe.Pointer(e)), l) != 0) && int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(e)) + uintptr(l)))) == '=' { + X__env_rm_add(tls, *(*uintptr)(unsafe.Pointer(e)), uintptr(0)) + } else if eo != e { + *(*uintptr)(unsafe.Pointer(PostIncUintptr(&eo, 8))) = *(*uintptr)(unsafe.Pointer(e)) + } else { + eo += 8 + } + } + if eo != e { + *(*uintptr)(unsafe.Pointer(eo)) = uintptr(0) + } + } + return 0 +} + +type uintptr_t = uint64 /* alltypes.h:63:24 */ + +type int8_t = int8 /* alltypes.h:104:25 */ + +type int16_t = int16 /* alltypes.h:109:25 */ + +type int32_t = int32 /* alltypes.h:114:25 */ + +type int64_t = int64 /* alltypes.h:119:25 */ + +type intmax_t = int64 /* alltypes.h:124:25 */ + +type uint8_t = uint8 /* alltypes.h:129:25 */ + +type uint16_t = uint16 /* alltypes.h:134:25 */ + +type uint32_t = uint32 /* alltypes.h:139:25 */ + +type uint64_t = uint64 /* alltypes.h:144:25 */ + +type uintmax_t = uint64 /* alltypes.h:154:25 */ + +type int_fast8_t = int8_t /* stdint.h:22:16 */ +type int_fast64_t = int64_t /* stdint.h:23:17 */ + +type int_least8_t = int8_t /* stdint.h:25:17 */ +type int_least16_t = int16_t /* stdint.h:26:17 */ +type int_least32_t = int32_t /* stdint.h:27:17 */ +type int_least64_t = int64_t /* stdint.h:28:17 */ + +type uint_fast8_t = uint8_t /* stdint.h:30:17 */ +type uint_fast64_t = uint64_t /* stdint.h:31:18 */ + +type uint_least8_t = uint8_t /* stdint.h:33:18 */ +type uint_least16_t = uint16_t /* stdint.h:34:18 */ +type uint_least32_t = uint32_t /* stdint.h:35:18 */ +type uint_least64_t = uint64_t /* stdint.h:36:18 */ + +type int_fast16_t = int32_t /* stdint.h:1:17 */ +type int_fast32_t = int32_t /* stdint.h:2:17 */ +type uint_fast16_t = uint32_t /* stdint.h:3:18 */ +type uint_fast32_t = uint32_t /* stdint.h:4:18 */ + +type _IO_FILE = struct { + Fflags uint32 + F__ccgo_pad1 [4]byte + Frpos uintptr + Frend uintptr + Fclose uintptr + Fwend uintptr + Fwpos uintptr + Fmustbezero_1 uintptr + Fwbase uintptr + Fread uintptr + Fwrite uintptr + Fseek uintptr + Fbuf uintptr + Fbuf_size size_t + Fprev uintptr + Fnext uintptr + Ffd int32 + Fpipe_pid int32 + Flockcount int64 + Fmode int32 + Flock int32 + Flbf int32 + F__ccgo_pad2 [4]byte + Fcookie uintptr + Foff off_t + Fgetln_buf uintptr + Fmustbezero_2 uintptr + Fshend uintptr + Fshlim off_t + Fshcnt off_t + Fprev_locked uintptr + Fnext_locked uintptr + Flocale uintptr +} /* alltypes.h:328:9 */ + +type FILE = _IO_FILE /* alltypes.h:328:25 */ + +type va_list = uintptr /* alltypes.h:334:27 */ + +type _G_fpos64_t = struct { + F__ccgo_pad1 [0]uint64 + F__opaque [16]int8 +} /* stdio.h:54:9 */ + +type fpos_t = _G_fpos64_t /* stdio.h:58:3 */ + +type float_t = float32 /* alltypes.h:38:15 */ + +type double_t = float64 /* alltypes.h:43:16 */ + +func __FLOAT_BITS(tls *TLS, __f float32) uint32 { /* math.h:55:26: */ + bp := tls.Alloc(4) + defer tls.Free(4) + + // var __u struct {F__f float32;} at bp, 4 + + *(*float32)(unsafe.Pointer(bp)) = __f + return *(*uint32)(unsafe.Pointer(bp)) +} + +func __DOUBLE_BITS(tls *TLS, __f float64) uint64 { /* math.h:61:36: */ + bp := tls.Alloc(8) + defer tls.Free(8) + + // var __u struct {F__f float64;} at bp, 8 + + *(*float64)(unsafe.Pointer(bp)) = __f + return *(*uint64)(unsafe.Pointer(bp)) +} + +func __isspace(tls *TLS, _c int32) int32 { /* ctype.h:26:21: */ + return Bool32(_c == ' ' || uint32(_c)-uint32('\t') < uint32(5)) +} + +type syscall_arg_t = int64 /* syscall.h:22:14 */ + +func scanexp(tls *TLS, f uintptr, pok int32) int64 { /* floatscan.c:37:18: */ + var c int32 + var x int32 + var y int64 + var neg int32 = 0 + + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if c == '+' || c == '-' { + neg = Bool32(c == '-') + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if uint32(c-'0') >= 10 && pok != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + } + if uint32(c-'0') >= 10 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + return -0x7fffffffffffffff - int64(1) + } + for x = 0; uint32(c-'0') < 10 && x < 0x7fffffff/10; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + x = 10*x + c - '0' + } + for y = int64(x); uint32(c-'0') < 10 && y < 0x7fffffffffffffff/int64(100); c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + y = int64(10)*y + int64(c) - int64('0') + } + for ; uint32(c-'0') < 10; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if neg != 0 { + return -y + } + return y +} + +func decfloat(tls *TLS, f uintptr, c int32, bits int32, emin int32, sign int32, pok int32) float64 { /* floatscan.c:64:20: */ + bp := tls.Alloc(512) + defer tls.Free(512) + + // var x [128]uint32_t at bp, 512 + + var i int32 + var j int32 + var k int32 + var a int32 + var z int32 + var lrp int64 = int64(0) + var dc int64 = int64(0) + var e10 int64 = int64(0) + var lnz int32 = 0 + var gotdig int32 = 0 + var gotrad int32 = 0 + var rp int32 + var e2 int32 + var emax int32 = -emin - bits + 3 + var denormal int32 = 0 + var y float64 + var frac float64 = float64(0) + var bias float64 = float64(0) + + j = 0 + k = 0 + + // Don't let leading zeros consume buffer space + for ; c == '0'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + gotdig = 1 + } + if c == '.' { + gotrad = 1 + for c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }(); c == '0'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + gotdig = 1 + lrp-- + } + } + + *(*uint32_t)(unsafe.Pointer(bp)) = uint32_t(0) + for ; uint32(c-'0') < 10 || c == '.'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + if c == '.' { + if gotrad != 0 { + break + } + gotrad = 1 + lrp = dc + } else if k < 128-3 { + dc++ + if c != '0' { + lnz = int32(dc) + } + if j != 0 { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))*uint32_t(10) + uint32_t(c) - uint32_t('0') + } else { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(c - '0') + } + if PreIncInt32(&j, 1) == 9 { + k++ + j = 0 + } + gotdig = 1 + } else { + dc++ + if c != '0' { + lnz = (128 - 4) * 9 + *(*uint32_t)(unsafe.Pointer(bp + 124*4)) |= uint32_t(1) + } + } + } + if !(gotrad != 0) { + lrp = dc + } + + if gotdig != 0 && c|32 == 'e' { + e10 = scanexp(tls, f, pok) + if e10 == -0x7fffffffffffffff-int64(1) { + if pok != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } else { + X__shlim(tls, f, int64(0)) + return float64(0) + } + e10 = int64(0) + } + lrp = lrp + e10 + } else if c >= 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + if !(gotdig != 0) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + X__shlim(tls, f, int64(0)) + return float64(0) + } + + // Handle zero specially to avoid nasty special cases later + if !(int32(*(*uint32_t)(unsafe.Pointer(bp))) != 0) { + return float64(sign) * 0.0 + } + + // Optimize small integers (w/no exponent) and over/under-flow + if lrp == dc && dc < int64(10) && (bits > 30 || *(*uint32_t)(unsafe.Pointer(bp))>>bits == uint32_t(0)) { + return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) + } + if lrp > int64(-emin/2) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308 + } + if lrp < int64(emin-2*53) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308 + } + + // Align incomplete final B1B digit + if j != 0 { + for ; j < 9; j++ { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) *= uint32_t(10) + } + k++ + j = 0 + } + + a = 0 + z = k + e2 = 0 + rp = int32(lrp) + + // Optimize small to mid-size integers (even in exp. notation) + if lnz < 9 && lnz <= rp && rp < 18 { + if rp == 9 { + return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) + } + if rp < 9 { + return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) / float64(_sp10s[8-rp]) + } + var bitlim int32 = bits - 3*(rp-9) + if bitlim > 30 || *(*uint32_t)(unsafe.Pointer(bp))>>bitlim == uint32_t(0) { + return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) * float64(_sp10s[rp-10]) + } + } + + // Drop trailing zeros + for ; !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(z-1)*4))) != 0); z-- { + } + + // Align radix point to B1B digit boundary + if rp%9 != 0 { + var rpm9 int32 + if rp >= 0 { + rpm9 = rp % 9 + } else { + rpm9 = rp%9 + 9 + } + var p10 int32 = _sp10s[8-rpm9] + var carry uint32_t = uint32_t(0) + for k = a; k != z; k++ { + var tmp uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) % uint32_t(p10) + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))/uint32_t(p10) + carry + carry = uint32_t(1000000000/p10) * tmp + if k == a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) { + a = (a + 1) & (128 - 1) + rp = rp - 9 + } + } + if carry != 0 { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(PostIncInt32(&z, 1))*4)) = carry + } + rp = rp + (9 - rpm9) + } + + // Upscale until desired number of bits are left of radix point + for rp < 9*2 || rp == 9*2 && *(*uint32_t)(unsafe.Pointer(bp + uintptr(a)*4)) < _sth[0] { + var carry uint32_t = uint32_t(0) + e2 = e2 - 29 + for k = (z - 1) & (128 - 1); ; k = (k - 1) & (128 - 1) { + var tmp uint64_t = uint64_t(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)))<<29 + uint64_t(carry) + if tmp > uint64(1000000000) { + carry = uint32_t(tmp / uint64(1000000000)) + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(tmp % uint64(1000000000)) + } else { + carry = uint32_t(0) + *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(tmp) + } + if k == (z-1)&(128-1) && k != a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) { + z = k + } + if k == a { + break + } + } + if carry != 0 { + rp = rp + 9 + a = (a - 1) & (128 - 1) + if a == z { + z = (z - 1) & (128 - 1) + *(*uint32_t)(unsafe.Pointer(bp + uintptr((z-1)&(128-1))*4)) |= *(*uint32_t)(unsafe.Pointer(bp + uintptr(z)*4)) + } + *(*uint32_t)(unsafe.Pointer(bp + uintptr(a)*4)) = carry + } + } + + // Downscale until exactly number of bits are left of radix point + for { + var carry uint32_t = uint32_t(0) + var sh int32 = 1 + for i = 0; i < 2; i++ { + k = (a + i) & (128 - 1) + if k == z || *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) < _sth[i] { + i = 2 + break + } + if *(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4)) > _sth[i] { + break + } + } + if i == 2 && rp == 9*2 { + break + } + // FIXME: find a way to compute optimal sh + if rp > 9+9*2 { + sh = 9 + } + e2 = e2 + sh + for k = a; k != z; k = (k + 1) & (128 - 1) { + var tmp uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) & uint32_t(int32(1)<>sh + carry + carry = uint32_t(int32(1000000000)>>sh) * tmp + if k == a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) { + a = (a + 1) & (128 - 1) + i-- + rp = rp - 9 + } + } + if carry != 0 { + if (z+1)&(128-1) != a { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(z)*4)) = carry + z = (z + 1) & (128 - 1) + } else { + *(*uint32_t)(unsafe.Pointer(bp + uintptr((z-1)&(128-1))*4)) |= uint32_t(1) + } + } + } + + // Assemble desired bits into floating point variable + for y = float64(AssignInt32(&i, 0)); i < 2; i++ { + if (a+i)&(128-1) == z { + *(*uint32_t)(unsafe.Pointer(bp + uintptr(AssignInt32(&z, (z+1)&(128-1))-1)*4)) = uint32_t(0) + } + y = 1000000000.0*y + float64(*(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4))) + } + + y = y * float64(sign) + + // Limit precision for denormal results + if bits > 53+e2-emin { + bits = 53 + e2 - emin + if bits < 0 { + bits = 0 + } + denormal = 1 + } + + // Calculate bias term to force rounding, move out lower bits + if bits < 53 { + bias = Xcopysignl(tls, Xscalbn(tls, float64(1), 2*53-bits-1), y) + frac = Xfmodl(tls, y, Xscalbn(tls, float64(1), 53-bits)) + y = y - frac + y = y + bias + } + + // Process tail of decimal input so it can affect rounding + if (a+i)&(128-1) != z { + var t uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4)) + if t < uint32_t(500000000) && (t != 0 || (a+i+1)&(128-1) != z) { + frac = frac + 0.25*float64(sign) + } else if t > uint32_t(500000000) { + frac = frac + 0.75*float64(sign) + } else if t == uint32_t(500000000) { + if (a+i+1)&(128-1) == z { + frac = frac + 0.5*float64(sign) + } else { + frac = frac + 0.75*float64(sign) + } + } + if 53-bits >= 2 && !(Xfmodl(tls, frac, float64(1)) != 0) { + frac += 1 + } + } + + y = y + frac + y = y - bias + + if (e2+53)&0x7fffffff > emax-5 { + if Xfabsl(tls, y) >= float64(float64(2))/2.22044604925031308085e-16 { + if denormal != 0 && bits == 53+e2-emin { + denormal = 0 + } + y = y * 0.5 + e2++ + } + if e2+53 > emax || denormal != 0 && frac != 0 { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + } + } + + return Xscalbnl(tls, y, e2) +} + +var _sth = [2]uint32_t{uint32_t(9007199), uint32_t(254740991)} /* floatscan.c:67:24 */ +var _sp10s = [8]int32{10, 100, 1000, 10000, + 100000, 1000000, 10000000, 100000000} /* floatscan.c:80:19 */ + +func hexfloat(tls *TLS, f uintptr, bits int32, emin int32, sign int32, pok int32) float64 { /* floatscan.c:315:20: */ + var x uint32_t = uint32_t(0) + var y float64 = float64(0) + var scale float64 = float64(1) + var bias float64 = float64(0) + var gottail int32 = 0 + var gotrad int32 = 0 + var gotdig int32 = 0 + var rp int64 = int64(0) + var dc int64 = int64(0) + var e2 int64 = int64(0) + var d int32 + var c int32 + + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + + // Skip leading zeros + for ; c == '0'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + gotdig = 1 + } + + if c == '.' { + gotrad = 1 + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + // Count zeros after the radix point before significand + rp = int64(0) + __1: + if !(c == '0') { + goto __3 + } + gotdig = 1 + goto __2 + __2: + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + rp-- + goto __1 + goto __3 + __3: + } + + for ; uint32(c-'0') < 10 || uint32(c|32-'a') < 6 || c == '.'; c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() { + if c == '.' { + if gotrad != 0 { + break + } + rp = dc + gotrad = 1 + } else { + gotdig = 1 + if c > '9' { + d = c | 32 + 10 - 'a' + } else { + d = c - '0' + } + if dc < int64(8) { + x = x*uint32_t(16) + uint32_t(d) + } else if dc < int64(53/4+1) { + y = y + float64(d)*AssignDivFloat64(&scale, float64(16)) + } else if d != 0 && !(gottail != 0) { + y = y + 0.5*scale + gottail = 1 + } + dc++ + } + } + if !(gotdig != 0) { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if pok != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if gotrad != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + } else { + X__shlim(tls, f, int64(0)) + } + return float64(sign) * 0.0 + } + if !(gotrad != 0) { + rp = dc + } + for dc < int64(8) { + x = x * uint32_t(16) + dc++ + } + if c|32 == 'p' { + e2 = scanexp(tls, f, pok) + if e2 == -0x7fffffffffffffff-int64(1) { + if pok != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } else { + X__shlim(tls, f, int64(0)) + return float64(0) + } + e2 = int64(0) + } + } else { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + e2 = e2 + (int64(4)*rp - int64(32)) + + if !(x != 0) { + return float64(sign) * 0.0 + } + if e2 > int64(-emin) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308 + } + if e2 < int64(emin-2*53) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308 + } + + for x < 0x80000000 { + if y >= 0.5 { + x = x + (x + uint32_t(1)) + y = y + (y - float64(1)) + } else { + x = x + x + y = y + y + } + e2-- + } + + if int64(bits) > int64(32)+e2-int64(emin) { + bits = int32(int64(32) + e2 - int64(emin)) + if bits < 0 { + bits = 0 + } + } + + if bits < 53 { + bias = Xcopysignl(tls, Xscalbn(tls, float64(1), 32+53-bits-1), float64(sign)) + } + + if bits < 32 && y != 0 && !(x&uint32_t(1) != 0) { + x++ + y = float64(0) + } + + y = bias + float64(sign)*float64(x) + float64(sign)*y + y = y - bias + + if !(y != 0) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + } + + return Xscalbnl(tls, y, int32(e2)) +} + +func X__floatscan(tls *TLS, f uintptr, prec int32, pok int32) float64 { /* floatscan.c:427:13: */ + if __ccgo_strace { + trc("tls=%v f=%v prec=%v pok=%v, (%v:)", tls, f, prec, pok, origin(2)) + } + var sign int32 = 1 + var i size_t + var bits int32 + var emin int32 + var c int32 + + switch prec { + case 0: + bits = 24 + emin = -125 - bits + break + case 1: + bits = 53 + emin = -1021 - bits + break + case 2: + bits = 53 + emin = -1021 - bits + break + default: + return float64(0) + } + + for __isspace(tls, AssignInt32(&c, func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }())) != 0 { + } + + if c == '+' || c == '-' { + sign = sign - 2*Bool32(c == '-') + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + } + + for i = uint64(0); i < uint64(8) && c|32 == int32(*(*int8)(unsafe.Pointer(ts /* "infinity" */ + uintptr(i)))); i++ { + if i < uint64(7) { + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + } + } + if i == uint64(3) || i == uint64(8) || i > uint64(3) && pok != 0 { + if i != uint64(8) { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if pok != 0 { + for ; i > uint64(3); i-- { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + } + } + return float64(float32(sign) * X__builtin_inff(tls)) + } + if !(i != 0) { + for i = uint64(0); i < uint64(3) && c|32 == int32(*(*int8)(unsafe.Pointer(ts + 9 /* "nan" */ + uintptr(i)))); i++ { + if i < uint64(2) { + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + } + } + } + if i == uint64(3) { + if func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() != '(' { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + return float64(X__builtin_nanf(tls, ts+13)) + } + for i = uint64(1); ; i++ { + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if uint32(c-'0') < 10 || uint32(c-'A') < 26 || uint32(c-'a') < 26 || c == '_' { + continue + } + if c == ')' { + return float64(X__builtin_nanf(tls, ts+13)) + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if !(pok != 0) { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + X__shlim(tls, f, int64(0)) + return float64(0) + } + for PostDecUint64(&i, 1) != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + } + return float64(X__builtin_nanf(tls, ts+13)) + } + return float64(X__builtin_nanf(tls, ts+13)) + } + + if i != 0 { + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + X__shlim(tls, f, int64(0)) + return float64(0) + } + + if c == '0' { + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if c|32 == 'x' { + return hexfloat(tls, f, bits, emin, sign, pok) + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + c = '0' + } + + return decfloat(tls, f, c, bits, emin, sign, pok) +} + +// Lookup table for digit values. -1==255>=36 -> invalid +var table = [257]uint8{Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + uint8(0), uint8(1), uint8(2), uint8(3), uint8(4), uint8(5), uint8(6), uint8(7), uint8(8), uint8(9), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), uint8(10), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(17), uint8(18), uint8(19), uint8(20), uint8(21), uint8(22), uint8(23), uint8(24), + uint8(25), uint8(26), uint8(27), uint8(28), uint8(29), uint8(30), uint8(31), uint8(32), uint8(33), uint8(34), uint8(35), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), uint8(10), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(17), uint8(18), uint8(19), uint8(20), uint8(21), uint8(22), uint8(23), uint8(24), + uint8(25), uint8(26), uint8(27), uint8(28), uint8(29), uint8(30), uint8(31), uint8(32), uint8(33), uint8(34), uint8(35), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), + Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), +} /* intscan.c:7:28 */ + +func X__intscan(tls *TLS, f uintptr, base uint32, pok int32, lim uint64) uint64 { /* intscan.c:26:20: */ + if __ccgo_strace { + trc("tls=%v f=%v base=%v pok=%v lim=%v, (%v:)", tls, f, base, pok, lim, origin(2)) + } + var val uintptr + var c int32 + var neg int32 + var x uint32 + var y uint64 + var bs int32 + val = uintptr(unsafe.Pointer(&table)) + uintptr(1) + neg = 0 + if !(base > uint32(36) || base == uint32(1)) { + goto __1 + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + return uint64(0) +__1: + ; +__2: + if !(__isspace(tls, AssignInt32(&c, func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }())) != 0) { + goto __3 + } + goto __2 +__3: + ; + if !(c == '+' || c == '-') { + goto __4 + } + neg = -Bool32(c == '-') + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() +__4: + ; + if !((base == uint32(0) || base == uint32(16)) && c == '0') { + goto __5 + } + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if !(c|32 == 'x') { + goto __7 + } + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + if !(int32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) >= 16) { + goto __9 + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if !(pok != 0) { + goto __10 + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + goto __11 +__10: + X__shlim(tls, f, int64(0)) +__11: + ; + return uint64(0) +__9: + ; + base = uint32(16) + goto __8 +__7: + if !(base == uint32(0)) { + goto __12 + } + base = uint32(8) +__12: + ; +__8: + ; + goto __6 +__5: + if !(base == uint32(0)) { + goto __13 + } + base = uint32(10) +__13: + ; + if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) >= base) { + goto __14 + } + if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + X__shlim(tls, f, int64(0)) + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22 + return uint64(0) +__14: + ; +__6: + ; + if !(base == uint32(10)) { + goto __15 + } + x = uint32(0) +__17: + if !(uint32(c-'0') < 10 && x <= 0xffffffff/uint32(10)-uint32(1)) { + goto __19 + } + x = x*uint32(10) + uint32(c-'0') + goto __18 +__18: + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + goto __17 + goto __19 +__19: + ; + y = uint64(x) +__20: + if !(uint32(c-'0') < 10 && y <= (2*uint64(0x7fffffffffffffff)+uint64(1))/uint64(10) && uint64(10)*y <= 2*uint64(0x7fffffffffffffff)+uint64(1)-uint64(c-'0')) { + goto __22 + } + y = y*uint64(10) + uint64(c-'0') + goto __21 +__21: + c = func() int32 { + if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend { + return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1)))) + } + return X__shgetc(tls, f) + }() + goto __20 + goto __22 +__22: + ; + if !(uint32(c-'0') >= 10) { + goto __23 + } + goto done +__23: + ; + goto __16 +__15: + if !!(base&(base-uint32(1)) != 0) { + goto __24 + } + bs = int32(*(*int8)(unsafe.Pointer(ts + 14 + uintptr(uint32(0x17)*base>>5&uint32(7))))) + x = uint32(0) +__26: + if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && x <= 0xffffffff/uint32(32)) { + goto __28 + } + x = x<>bs) { + goto __31 + } + y = y<= int64(0) { + (*FILE)(unsafe.Pointer(f)).Frpos-- + } else { + } + if !(y >= lim) { + goto __43 + } + if !(!(lim&uint64(1) != 0) && !(neg != 0)) { + goto __44 + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return lim - uint64(1) + goto __45 +__44: + if !(y > lim) { + goto __46 + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34 + return lim +__46: + ; +__45: + ; +__43: + ; + return y ^ uint64(neg) - uint64(neg) +} + +// The shcnt field stores the number of bytes read so far, offset by +// the value of buf-rpos at the last function call (__shlim or __shgetc), +// so that between calls the inline shcnt macro can add rpos-buf to get +// the actual count. + +func X__shlim(tls *TLS, f uintptr, lim off_t) { /* shgetc.c:8:6: */ + if __ccgo_strace { + trc("tls=%v f=%v lim=%v, (%v:)", tls, f, lim, origin(2)) + } + (*FILE)(unsafe.Pointer(f)).Fshlim = lim + (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf) - int64((*FILE)(unsafe.Pointer(f)).Frpos)) / 1 + // If lim is nonzero, rend must be a valid pointer. + if lim != 0 && (int64((*FILE)(unsafe.Pointer(f)).Frend)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 > lim { + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos + uintptr(lim) + } else { + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frend + } +} + +func X__shgetc(tls *TLS, f uintptr) int32 { /* shgetc.c:19:5: */ + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + var c int32 + var cnt off_t = (*FILE)(unsafe.Pointer(f)).Fshcnt + (int64((*FILE)(unsafe.Pointer(f)).Frpos)-int64((*FILE)(unsafe.Pointer(f)).Fbuf))/1 + if (*FILE)(unsafe.Pointer(f)).Fshlim != 0 && cnt >= (*FILE)(unsafe.Pointer(f)).Fshlim || AssignInt32(&c, X__uflow(tls, f)) < 0 { + (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 + cnt + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos + (*FILE)(unsafe.Pointer(f)).Fshlim = int64(-1) + return -1 + } + cnt++ + if (*FILE)(unsafe.Pointer(f)).Fshlim != 0 && (int64((*FILE)(unsafe.Pointer(f)).Frend)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 > (*FILE)(unsafe.Pointer(f)).Fshlim-cnt { + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos + uintptr((*FILE)(unsafe.Pointer(f)).Fshlim-cnt) + } else { + (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frend + } + (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 + cnt + if (*FILE)(unsafe.Pointer(f)).Frpos <= (*FILE)(unsafe.Pointer(f)).Fbuf { + *(*uint8)(unsafe.Pointer((*FILE)(unsafe.Pointer(f)).Frpos + UintptrFromInt32(-1))) = uint8(c) + } + return c +} + +type lconv = struct { + Fdecimal_point uintptr + Fthousands_sep uintptr + Fgrouping uintptr + Fint_curr_symbol uintptr + Fcurrency_symbol uintptr + Fmon_decimal_point uintptr + Fmon_thousands_sep uintptr + Fmon_grouping uintptr + Fpositive_sign uintptr + Fnegative_sign uintptr + Fint_frac_digits int8 + Ffrac_digits int8 + Fp_cs_precedes int8 + Fp_sep_by_space int8 + Fn_cs_precedes int8 + Fn_sep_by_space int8 + Fp_sign_posn int8 + Fn_sign_posn int8 + Fint_p_cs_precedes int8 + Fint_p_sep_by_space int8 + Fint_n_cs_precedes int8 + Fint_n_sep_by_space int8 + Fint_p_sign_posn int8 + Fint_n_sign_posn int8 + F__ccgo_pad1 [2]byte +} /* locale.h:24:1 */ + +// Support signed or unsigned plain-char + +// Implementation choices... + +// Arbitrary numbers... + +// POSIX/SUS requirements follow. These numbers come directly +// from SUS and have nothing to do with the host system. + +var posix_lconv = lconv{Fdecimal_point: ts + 23, Fthousands_sep: ts + 13, Fgrouping: ts + 13, Fint_curr_symbol: ts + 13, Fcurrency_symbol: ts + 13, Fmon_decimal_point: ts + 13, Fmon_thousands_sep: ts + 13, Fmon_grouping: ts + 13, Fpositive_sign: ts + 13, Fnegative_sign: ts + 13, Fint_frac_digits: Int8FromInt32(255), Ffrac_digits: Int8FromInt32(255), Fp_cs_precedes: Int8FromInt32(255), Fp_sep_by_space: Int8FromInt32(255), Fn_cs_precedes: Int8FromInt32(255), Fn_sep_by_space: Int8FromInt32(255), Fp_sign_posn: Int8FromInt32(255), Fn_sign_posn: Int8FromInt32(255), Fint_p_cs_precedes: Int8FromInt32(255), Fint_p_sep_by_space: Int8FromInt32(255), Fint_n_cs_precedes: Int8FromInt32(255), Fint_n_sep_by_space: Int8FromInt32(255), Fint_p_sign_posn: Int8FromInt32(255), Fint_n_sign_posn: Int8FromInt32(255)} /* localeconv.c:4:27 */ + +func Xlocaleconv(tls *TLS) uintptr { /* localeconv.c:31:14: */ + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + return uintptr(unsafe.Pointer(&posix_lconv)) +} + +func X__fpclassify(tls *TLS, x float64) int32 { /* __fpclassify.c:4:5: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + *(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) { + *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x + return r + }() + var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff)) + if !(e != 0) { + if *(*uint64_t)(unsafe.Pointer(bp))<<1 != 0 { + return 3 + } + return 2 + } + if e == 0x7ff { + if *(*uint64_t)(unsafe.Pointer(bp))<<12 != 0 { + return 0 + } + return 1 + } + return 4 +} + +func X__fpclassifyf(tls *TLS, x float32) int32 { /* __fpclassifyf.c:4:5: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + bp := tls.Alloc(4) + defer tls.Free(4) + + *(*struct{ Ff float32 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float32 }) { + *(*float32)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x + return r + }() + var e int32 = int32(*(*uint32_t)(unsafe.Pointer(bp)) >> 23 & uint32_t(0xff)) + if !(e != 0) { + if *(*uint32_t)(unsafe.Pointer(bp))<<1 != 0 { + return 3 + } + return 2 + } + if e == 0xff { + if *(*uint32_t)(unsafe.Pointer(bp))<<9 != 0 { + return 0 + } + return 1 + } + return 4 +} + +func __bswap32(tls *TLS, __x uint32_t) uint32_t { /* endian.h:24:26: */ + return __x>>24 | __x>>8&uint32_t(0xff00) | __x<<8&uint32_t(0xff0000) | __x<<24 +} + +func X__fpclassifyl(tls *TLS, x float64) int32 { /* __fpclassifyl.c:4:5: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + return X__fpclassify(tls, x) +} + +func Xcopysignl(tls *TLS, x float64, y float64) float64 { /* copysignl.c:4:13: */ + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + } + return Xcopysign(tls, x, y) +} + +func Xfabsl(tls *TLS, x float64) float64 { /* fabsl.c:3:13: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + return Xfabs(tls, x) +} + +func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */ + if __ccgo_strace { + trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2)) + } + return Xfmod(tls, x, y) +} + +func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */ + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + } + return X__builtin_nanf(tls, ts+13) +} + +var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */ + +func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */ + if __ccgo_strace { + trc("tls=%v x=%v, (%v:)", tls, x, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + *(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) { + *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x + return r + }() + var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff)) + var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63) + var y double_t + + if e >= 0x3ff+52 { + return x + } + if s != 0 { + y = x - toint + toint + } else { + y = x + toint - toint + } + if y == float64(0) { + if s != 0 { + return -Float64FromFloat64(0.0) + } + return float64(0) + } + return y +} + +func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */ + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + // var u struct {Ff float64;} at bp, 8 + + var y double_t = x + + if n > 1023 { + y = y * 0x1p1023 + n = n - 1023 + if n > 1023 { + y = y * 0x1p1023 + n = 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 = y * (float64(0x1p-1022) * 0x1p53) + n = n + (1022 - 53) + if n < -1022 { + y = y * (float64(0x1p-1022) * 0x1p53) + n = n + (1022 - 53) + if n < -1022 { + n = -1022 + } + } + } + *(*uint64_t)(unsafe.Pointer(bp)) = uint64_t(0x3ff+n) << 52 + x = y * *(*float64)(unsafe.Pointer(bp)) + return x +} + +func Xscalbnl(tls *TLS, x float64, n int32) float64 { /* scalbnl.c:4:13: */ + if __ccgo_strace { + trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2)) + } + return Xscalbn(tls, x, n) +} + +type max_align_t = struct { + F__ll int64 + F__ld float64 +} /* alltypes.h:49:54 */ + +type imaxdiv_t = struct { + Fquot intmax_t + Frem intmax_t +} /* inttypes.h:14:40 */ + +type iovec = struct { + Fiov_base uintptr + Fiov_len size_t +} /* alltypes.h:363:1 */ + +type socklen_t = uint32 /* alltypes.h:369:18 */ + +type sa_family_t = uint16 /* alltypes.h:374:24 */ + +type msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__pad1 int32 + Fmsg_control uintptr + Fmsg_controllen socklen_t + F__pad2 int32 + Fmsg_flags int32 + F__ccgo_pad2 [4]byte +} /* socket.h:22:1 */ + +type cmsghdr = struct { + Fcmsg_len socklen_t + F__pad1 int32 + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:44:1 */ + +type linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:74:1 */ + +type sockaddr = struct { + Fsa_family sa_family_t + Fsa_data [14]int8 +} /* socket.h:367:1 */ + +type sockaddr_storage = struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 +} /* socket.h:372:1 */ + +type in_port_t = uint16_t /* in.h:12:18 */ +type in_addr_t = uint32_t /* in.h:13:18 */ +type in_addr = struct{ Fs_addr in_addr_t } /* in.h:14:1 */ + +type sockaddr_in = struct { + Fsin_family sa_family_t + Fsin_port in_port_t + Fsin_addr struct{ Fs_addr in_addr_t } + Fsin_zero [8]uint8_t +} /* in.h:16:1 */ + +type in6_addr = struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } +} /* in.h:23:1 */ + +type sockaddr_in6 = struct { + Fsin6_family sa_family_t + Fsin6_port in_port_t + Fsin6_flowinfo uint32_t + Fsin6_addr struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } + } + Fsin6_scope_id uint32_t +} /* in.h:34:1 */ + +type ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } + } + Fipv6mr_interface uint32 +} /* in.h:42:1 */ + +type ip_opts = struct { + Fip_dst struct{ Fs_addr in_addr_t } + Fip_opts [40]int8 +} /* in.h:229:1 */ + +type ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr in_addr_t } + Fimr_interface struct{ Fs_addr in_addr_t } +} /* in.h:247:1 */ + +type ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr in_addr_t } + Fimr_address struct{ Fs_addr in_addr_t } + Fimr_ifindex int32 +} /* in.h:252:1 */ + +type ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr in_addr_t } + Fimr_interface struct{ Fs_addr in_addr_t } + Fimr_sourceaddr struct{ Fs_addr in_addr_t } +} /* in.h:258:1 */ + +type ip_msfilter = struct { + Fimsf_multiaddr struct{ Fs_addr in_addr_t } + Fimsf_interface struct{ Fs_addr in_addr_t } + Fimsf_fmode uint32_t + Fimsf_numsrc uint32_t + Fimsf_slist [1]struct{ Fs_addr in_addr_t } +} /* in.h:264:1 */ + +type group_req = struct { + Fgr_interface uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:275:1 */ + +type group_source_req = struct { + Fgsr_interface uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } + Fgsr_source struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:280:1 */ + +type group_filter = struct { + Fgf_interface uint32_t + F__ccgo_pad1 [4]byte + Fgf_group struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } + Fgf_fmode uint32_t + Fgf_numsrc uint32_t + Fgf_slist [1]struct { + Fss_family sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:286:1 */ + +type in_pktinfo = struct { + Fipi_ifindex int32 + Fipi_spec_dst struct{ Fs_addr in_addr_t } + Fipi_addr struct{ Fs_addr in_addr_t } +} /* in.h:297:1 */ + +type in6_pktinfo = struct { + Fipi6_addr struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } + } + Fipi6_ifindex uint32 +} /* in.h:303:1 */ + +type ip6_mtuinfo = struct { + Fip6m_addr struct { + Fsin6_family sa_family_t + Fsin6_port in_port_t + Fsin6_flowinfo uint32_t + Fsin6_addr struct { + F__in6_union struct { + F__ccgo_pad1 [0]uint32 + F__s6_addr [16]uint8_t + } + } + Fsin6_scope_id uint32_t + } + Fip6m_mtu uint32_t +} /* in.h:308:1 */ + +type addrinfo = struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen socklen_t + F__ccgo_pad1 [4]byte + Fai_addr uintptr + Fai_canonname uintptr + Fai_next uintptr +} /* netdb.h:16:1 */ + +// Legacy functions follow (marked OBsolete in SUS) + +type netent = struct { + Fn_name uintptr + Fn_aliases uintptr + Fn_addrtype int32 + Fn_net uint32_t +} /* netdb.h:62:1 */ + +type hostent = struct { + Fh_name uintptr + Fh_aliases uintptr + Fh_addrtype int32 + Fh_length int32 + Fh_addr_list uintptr +} /* netdb.h:69:1 */ + +type servent = struct { + Fs_name uintptr + Fs_aliases uintptr + Fs_port int32 + F__ccgo_pad1 [4]byte + Fs_proto uintptr +} /* netdb.h:78:1 */ + +type protoent = struct { + Fp_name uintptr + Fp_aliases uintptr + Fp_proto int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:85:1 */ + +type aibuf = struct { + Fai struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen socklen_t + F__ccgo_pad1 [4]byte + Fai_addr uintptr + Fai_canonname uintptr + Fai_next uintptr + } + Fsa struct { + Fsin struct { + Fsin_family sa_family_t + Fsin_port in_port_t + Fsin_addr struct{ Fs_addr in_addr_t } + Fsin_zero [8]uint8_t + } + F__ccgo_pad1 [12]byte + } + Flock [1]int32 + Fslot int16 + Fref int16 + F__ccgo_pad1 [4]byte +} /* lookup.h:10:1 */ + +type sa = struct { + Fsin struct { + Fsin_family sa_family_t + Fsin_port in_port_t + Fsin_addr struct{ Fs_addr in_addr_t } + Fsin_zero [8]uint8_t + } + F__ccgo_pad1 [12]byte +} /* lookup.h:10:1 */ + +type address = struct { + Ffamily int32 + Fscopeid uint32 + Faddr [16]uint8_t + Fsortkey int32 +} /* lookup.h:20:1 */ + +type service = struct { + Fport uint16_t + Fproto uint8 + Fsocktype uint8 +} /* lookup.h:27:1 */ + +type resolvconf = struct { + Fns [3]struct { + Ffamily int32 + Fscopeid uint32 + Faddr [16]uint8_t + Fsortkey int32 + } + Fnns uint32 + Fattempts uint32 + Fndots uint32 + Ftimeout uint32 +} /* lookup.h:34:1 */ + +func Xfreeaddrinfo(tls *TLS, p uintptr) { /* freeaddrinfo.c:7:6: */ + if __ccgo_strace { + trc("tls=%v p=%v, (%v:)", tls, p, origin(2)) + } + var cnt size_t + cnt = uint64(1) +__1: + if !((*addrinfo)(unsafe.Pointer(p)).Fai_next != 0) { + goto __3 + } + goto __2 +__2: + cnt++ + p = (*addrinfo)(unsafe.Pointer(p)).Fai_next + goto __1 + goto __3 +__3: + ; + var b uintptr = p - uintptr(uint64(uintptr(0))) + b -= 88 * uintptr((*aibuf)(unsafe.Pointer(b)).Fslot) + //TODO LOCK(b->lock); + if !(int32(AssignSubPtrInt16(b+82, int16(cnt))) != 0) { + Xfree(tls, b) + } + //TODO else UNLOCK(b->lock); +} + +type time_t = int64 /* alltypes.h:93:16 */ + +type clockid_t = int32 /* alltypes.h:222:13 */ + +type timespec = struct { + Ftv_sec time_t + Ftv_nsec int64 +} /* alltypes.h:237:1 */ + +type pthread_t = uintptr /* alltypes.h:281:26 */ + +type pthread_once_t = int32 /* alltypes.h:287:13 */ + +type pthread_key_t = uint32 /* alltypes.h:292:18 */ + +type pthread_spinlock_t = int32 /* alltypes.h:297:13 */ + +type pthread_mutexattr_t = struct{ F__attr uint32 } /* alltypes.h:302:37 */ + +type pthread_condattr_t = struct{ F__attr uint32 } /* alltypes.h:307:37 */ + +type pthread_barrierattr_t = struct{ F__attr uint32 } /* alltypes.h:312:37 */ + +type pthread_rwlockattr_t = struct{ F__attr [2]uint32 } /* alltypes.h:317:40 */ + +type __sigset_t = struct{ F__bits [16]uint64 } /* alltypes.h:357:9 */ + +type sigset_t = __sigset_t /* alltypes.h:357:71 */ + +type pthread_attr_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [14]int32 + } +} /* alltypes.h:380:147 */ + +type pthread_mutex_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [10]int32 + } +} /* alltypes.h:385:157 */ + +type pthread_cond_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [12]int32 + } +} /* alltypes.h:395:112 */ + +type pthread_rwlock_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [14]int32 + } +} /* alltypes.h:405:139 */ + +type pthread_barrier_t = struct { + F__u struct { + F__ccgo_pad1 [0]uint64 + F__i [8]int32 + } +} /* alltypes.h:410:137 */ + +type sched_param = struct { + Fsched_priority int32 + F__reserved1 int32 + F__reserved2 [2]struct { + F__reserved1 time_t + F__reserved2 int64 + } + F__reserved3 int32 + F__ccgo_pad1 [4]byte +} /* sched.h:19:1 */ + +type timer_t = uintptr /* alltypes.h:217:14 */ + +type clock_t = int64 /* alltypes.h:227:14 */ + +type tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* time.h:38:1 */ + +type itimerspec = struct { + Fit_interval struct { + Ftv_sec time_t + Ftv_nsec int64 + } + Fit_value struct { + Ftv_sec time_t + Ftv_nsec int64 + } +} /* time.h:80:1 */ + +type __ptcb = struct { + F__f uintptr + F__x uintptr + F__next uintptr +} /* pthread.h:206:1 */ + +func Xgetaddrinfo(tls *TLS, host uintptr, serv uintptr, hint uintptr, res uintptr) int32 { /* getaddrinfo.c:12:5: */ + if __ccgo_strace { + trc("tls=%v host=%v serv=%v hint=%v res=%v, (%v:)", tls, host, serv, hint, res, origin(2)) + } + bp := tls.Alloc(1608) + defer tls.Free(1608) + + // var ports [2]service at bp, 8 + + // var addrs [48]address at bp+8, 1344 + + // var canon [256]int8 at bp+1352, 256 + + var outcanon uintptr + var nservs int32 + var naddrs int32 + var nais int32 + var canon_len int32 + var i int32 + var j int32 + var k int32 + var family int32 = 0 + var flags int32 = 0 + var proto int32 = 0 + var socktype int32 = 0 + var out uintptr + + if !(host != 0) && !(serv != 0) { + return -2 + } + + if hint != 0 { + family = (*addrinfo)(unsafe.Pointer(hint)).Fai_family + flags = (*addrinfo)(unsafe.Pointer(hint)).Fai_flags + proto = (*addrinfo)(unsafe.Pointer(hint)).Fai_protocol + socktype = (*addrinfo)(unsafe.Pointer(hint)).Fai_socktype + + var mask int32 = 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x400 + if flags&mask != flags { + return -1 + } + + switch family { + case 2: + fallthrough + case 10: + fallthrough + case 0: + break + fallthrough + default: + return -6 + } + } + + if flags&0x20 != 0 { + Xabort(tls) //TODO- + // /* Define the "an address is configured" condition for address + // * families via ability to create a socket for the family plus + // * routability of the loopback address for the family. */ + // static const struct sockaddr_in lo4 = { + // .sin_family = AF_INET, .sin_port = 65535, + // .sin_addr.s_addr = __BYTE_ORDER == __BIG_ENDIAN + // ? 0x7f000001 : 0x0100007f + // }; + // static const struct sockaddr_in6 lo6 = { + // .sin6_family = AF_INET6, .sin6_port = 65535, + // .sin6_addr = IN6ADDR_LOOPBACK_INIT + // }; + // int tf[2] = { AF_INET, AF_INET6 }; + // const void *ta[2] = { &lo4, &lo6 }; + // socklen_t tl[2] = { sizeof lo4, sizeof lo6 }; + // for (i=0; i<2; i++) { + // if (family==tf[1-i]) continue; + // int s = socket(tf[i], SOCK_CLOEXEC|SOCK_DGRAM, + // IPPROTO_UDP); + // if (s>=0) { + // int cs; + // pthread_setcancelstate( + // PTHREAD_CANCEL_DISABLE, &cs); + // int r = connect(s, ta[i], tl[i]); + // pthread_setcancelstate(cs, 0); + // close(s); + // if (!r) continue; + // } + // switch (errno) { + // case EADDRNOTAVAIL: + // case EAFNOSUPPORT: + // case EHOSTUNREACH: + // case ENETDOWN: + // case ENETUNREACH: + // break; + // default: + // return EAI_SYSTEM; + // } + // if (family == tf[i]) return EAI_NONAME; + // family = tf[1-i]; + // } + } + + nservs = X__lookup_serv(tls, bp, serv, proto, socktype, flags) + if nservs < 0 { + return nservs + } + + naddrs = X__lookup_name(tls, bp+8, bp+1352, host, family, flags) + if naddrs < 0 { + return naddrs + } + + nais = nservs * naddrs + canon_len = int32(Xstrlen(tls, bp+1352)) + out = Xcalloc(tls, uint64(1), uint64(nais)*uint64(unsafe.Sizeof(aibuf{}))+uint64(canon_len)+uint64(1)) + if !(out != 0) { + return -10 + } + + if canon_len != 0 { + outcanon = out + uintptr(nais)*88 + Xmemcpy(tls, outcanon, bp+1352, uint64(canon_len+1)) + } else { + outcanon = uintptr(0) + } + + for k = AssignInt32(&i, 0); i < naddrs; i++ { + j = 0 + __1: + if !(j < nservs) { + goto __3 + } + { + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fslot = int16(k) + //TODO out[k].ai = (struct addrinfo){ + //TODO .ai_family = addrs[i].family, + //TODO .ai_socktype = ports[j].socktype, + //TODO .ai_protocol = ports[j].proto, + //TODO .ai_addrlen = addrs[i].family == AF_INET + //TODO ? sizeof(struct sockaddr_in) + //TODO : sizeof(struct sockaddr_in6), + //TODO .ai_addr = (void *)&out[k].sa, + //TODO .ai_canonname = outcanon }; + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_family = (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Ffamily + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_socktype = int32((*service)(unsafe.Pointer(bp + uintptr(j)*4)).Fsocktype) + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_protocol = int32((*service)(unsafe.Pointer(bp + uintptr(j)*4)).Fproto) + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_addrlen = func() uint32 { + if (*address)(unsafe.Pointer(bp+8+uintptr(i)*28)).Ffamily == 2 { + return uint32(unsafe.Sizeof(sockaddr_in{})) + } + return uint32(unsafe.Sizeof(sockaddr_in6{})) + }() + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_addr = out + uintptr(k)*88 + 48 + (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_canonname = outcanon + if k != 0 { + (*aibuf)(unsafe.Pointer(out + uintptr(k-1)*88)).Fai.Fai_next = out + uintptr(k)*88 + } + switch (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Ffamily { + case 2: + (*sockaddr_in)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin_family = sa_family_t(2) + (*sockaddr_in)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin_port = Xhtons(tls, (*service)(unsafe.Pointer(bp+uintptr(j)*4)).Fport) + Xmemcpy(tls, out+uintptr(k)*88+48+4, bp+8+uintptr(i)*28+8, uint64(4)) + break + case 10: + (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_family = sa_family_t(10) + (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_port = Xhtons(tls, (*service)(unsafe.Pointer(bp+uintptr(j)*4)).Fport) + (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_scope_id = (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Fscopeid + Xmemcpy(tls, out+uintptr(k)*88+48+8, bp+8+uintptr(i)*28+8, uint64(16)) + break + } + + } + goto __2 + __2: + j++ + k++ + goto __1 + goto __3 + __3: + } + (*aibuf)(unsafe.Pointer(out)).Fref = int16(nais) + *(*uintptr)(unsafe.Pointer(res)) = out + return 0 +} + +type ucred = struct { + Fpid pid_t + Fuid uid_t + Fgid gid_t +} /* socket.h:57:1 */ + +type mmsghdr = struct { + Fmsg_hdr struct { + Fmsg_name uintptr + Fmsg_namelen socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__pad1 int32 + Fmsg_control uintptr + Fmsg_controllen socklen_t + F__pad2 int32 + Fmsg_flags int32 + F__ccgo_pad2 [4]byte + } + Fmsg_len uint32 + F__ccgo_pad1 [4]byte +} /* socket.h:63:1 */ + +func Xgethostbyaddr(tls *TLS, a uintptr, l socklen_t, af int32) uintptr { /* gethostbyaddr.c:7:16: */ + if __ccgo_strace { + trc("tls=%v a=%v l=%v af=%v, (%v:)", tls, a, l, af, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + var size size_t = uint64(63) + // var res uintptr at bp, 8 + + var err int32 + for __ccgo := true; __ccgo; __ccgo = err == 34 { + Xfree(tls, _sh) + _sh = Xmalloc(tls, AssignAddUint64(&size, size+uint64(1))) + if !(_sh != 0) { + *(*int32)(unsafe.Pointer(X__h_errno_location(tls))) = 3 + return uintptr(0) + } + err = Xgethostbyaddr_r(tls, a, l, af, _sh, + _sh+uintptr(1)*32, size-size_t(unsafe.Sizeof(hostent{})), bp, X__h_errno_location(tls)) + } + if err != 0 { + return uintptr(0) + } + return _sh +} + +var _sh uintptr /* gethostbyaddr.c:9:24: */ + +func Xgethostbyaddr_r(tls *TLS, a uintptr, l socklen_t, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyaddr_r.c:10:5: */ + if __ccgo_strace { + trc("tls=%v a=%v l=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, a, l, af, h, buf, buflen, res, err, origin(2)) + } + bp := tls.Alloc(28) + defer tls.Free(28) + + //TODO union { + //TODO struct sockaddr_in sin; + //TODO struct sockaddr_in6 sin6; + //TODO } sa = { .sin.sin_family = af }; + *(*struct { + Fsin sockaddr_in + F__ccgo_pad1 [12]byte + })(unsafe.Pointer(bp)) = struct { + Fsin sockaddr_in + F__ccgo_pad1 [12]byte + }{} //TODO- + (*sockaddr_in)(unsafe.Pointer(bp)).Fsin_family = sa_family_t(af) //TODO- + var sl socklen_t + if af == 10 { + sl = uint32(unsafe.Sizeof(sockaddr_in6{})) + } else { + sl = uint32(unsafe.Sizeof(sockaddr_in{})) + } + var i int32 + + *(*uintptr)(unsafe.Pointer(res)) = uintptr(0) + + // Load address argument into sockaddr structure + if af == 10 && l == socklen_t(16) { + Xmemcpy(tls, bp+8, a, uint64(16)) + } else if af == 2 && l == socklen_t(4) { + Xmemcpy(tls, bp+4, a, uint64(4)) + } else { + *(*int32)(unsafe.Pointer(err)) = 3 + return 22 + } + + // Align buffer and check for space for pointers and ip address + i = int32(uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1))) + if !(i != 0) { + i = int32(unsafe.Sizeof(uintptr(0))) + } + if buflen <= uint64(5)*uint64(unsafe.Sizeof(uintptr(0)))-uint64(i)+uint64(l) { + return 34 + } + buf += uintptr(uint64(unsafe.Sizeof(uintptr(0))) - uint64(i)) + buflen = buflen - (uint64(5)*uint64(unsafe.Sizeof(uintptr(0))) - uint64(i) + uint64(l)) + + (*hostent)(unsafe.Pointer(h)).Fh_addr_list = buf + buf += uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))) + (*hostent)(unsafe.Pointer(h)).Fh_aliases = buf + buf += uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0)))) + + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list)) = buf + Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list)), a, uint64(l)) + buf += uintptr(l) + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + 1*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases)) = buf + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0) + + switch Xgetnameinfo(tls, bp, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) { + case -3: + *(*int32)(unsafe.Pointer(err)) = 2 + return 11 + case -12: + return 34 + default: + fallthrough + case -10: + fallthrough + case -11: + fallthrough + case -4: + *(*int32)(unsafe.Pointer(err)) = 3 + return *(*int32)(unsafe.Pointer(X___errno_location(tls))) + case 0: + break + } + + (*hostent)(unsafe.Pointer(h)).Fh_addrtype = af + (*hostent)(unsafe.Pointer(h)).Fh_length = int32(l) + (*hostent)(unsafe.Pointer(h)).Fh_name = *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases)) + *(*uintptr)(unsafe.Pointer(res)) = h + return 0 +} + +func Xgethostbyname(tls *TLS, name uintptr) uintptr { /* gethostbyname.c:8:16: */ + if __ccgo_strace { + trc("tls=%v name=%v, (%v:)", tls, name, origin(2)) + } + return Xgethostbyname2(tls, name, 2) +} + +func Xgethostbyname2(tls *TLS, name uintptr, af int32) uintptr { /* gethostbyname2.c:8:16: */ + if __ccgo_strace { + trc("tls=%v name=%v af=%v, (%v:)", tls, name, af, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + var size size_t = uint64(63) + // var res uintptr at bp, 8 + + var err int32 + for __ccgo := true; __ccgo; __ccgo = err == 34 { + Xfree(tls, _sh1) + _sh1 = Xmalloc(tls, AssignAddUint64(&size, size+uint64(1))) + if !(_sh1 != 0) { + *(*int32)(unsafe.Pointer(X__h_errno_location(tls))) = 3 + return uintptr(0) + } + err = Xgethostbyname2_r(tls, name, af, _sh1, + _sh1+uintptr(1)*32, size-size_t(unsafe.Sizeof(hostent{})), bp, X__h_errno_location(tls)) + } + if err != 0 { + return uintptr(0) + } + return _sh1 +} + +var _sh1 uintptr /* gethostbyname2.c:10:24: */ + +func Xgethostbyname2_r(tls *TLS, name uintptr, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyname2_r.c:11:5: */ + if __ccgo_strace { + trc("tls=%v name=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, name, af, h, buf, buflen, res, err, origin(2)) + } + bp := tls.Alloc(1600) + defer tls.Free(1600) + + // var addrs [48]address at bp, 1344 + + // var canon [256]int8 at bp+1344, 256 + + var i int32 + var cnt int32 + var align size_t + var need size_t + + *(*uintptr)(unsafe.Pointer(res)) = uintptr(0) + cnt = X__lookup_name(tls, bp, bp+1344, name, af, 0x02) + if cnt < 0 { + switch cnt { + case -2: + *(*int32)(unsafe.Pointer(err)) = 1 + return 2 + fallthrough + case -3: + *(*int32)(unsafe.Pointer(err)) = 2 + return 11 + fallthrough + default: + fallthrough + case -4: + *(*int32)(unsafe.Pointer(err)) = 3 + return 74 + fallthrough + case -10: + fallthrough + case -11: + *(*int32)(unsafe.Pointer(err)) = 3 + return *(*int32)(unsafe.Pointer(X___errno_location(tls))) + } + } + + (*hostent)(unsafe.Pointer(h)).Fh_addrtype = af + (*hostent)(unsafe.Pointer(h)).Fh_length = func() int32 { + if af == 10 { + return 16 + } + return 4 + }() + + // Align buffer + align = -uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1)) + + need = uint64(4) * uint64(unsafe.Sizeof(uintptr(0))) + need = need + uint64(cnt+1)*(uint64(unsafe.Sizeof(uintptr(0)))+uint64((*hostent)(unsafe.Pointer(h)).Fh_length)) + need = need + (Xstrlen(tls, name) + uint64(1)) + need = need + (Xstrlen(tls, bp+1344) + uint64(1)) + need = need + align + + if need > buflen { + return 34 + } + + buf += uintptr(align) + (*hostent)(unsafe.Pointer(h)).Fh_aliases = buf + buf += uintptr(uint64(3) * uint64(unsafe.Sizeof(uintptr(0)))) + (*hostent)(unsafe.Pointer(h)).Fh_addr_list = buf + buf += uintptr(uint64(cnt+1) * uint64(unsafe.Sizeof(uintptr(0)))) + + for i = 0; i < cnt; i++ { + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = buf + buf += uintptr((*hostent)(unsafe.Pointer(h)).Fh_length) + Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)), bp+uintptr(i)*28+8, uint64((*hostent)(unsafe.Pointer(h)).Fh_length)) + } + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = uintptr(0) + + (*hostent)(unsafe.Pointer(h)).Fh_name = AssignPtrUintptr((*hostent)(unsafe.Pointer(h)).Fh_aliases, buf) + Xstrcpy(tls, (*hostent)(unsafe.Pointer(h)).Fh_name, bp+1344) + buf += uintptr(Xstrlen(tls, (*hostent)(unsafe.Pointer(h)).Fh_name) + uint64(1)) + + if Xstrcmp(tls, (*hostent)(unsafe.Pointer(h)).Fh_name, name) != 0 { + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = buf + Xstrcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)), name) + buf += uintptr(Xstrlen(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8))) + uint64(1)) + } else { + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0) + } + + *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 2*8)) = uintptr(0) + + *(*uintptr)(unsafe.Pointer(res)) = h + return 0 +} + +type if_nameindex = struct { + Fif_index uint32 + F__ccgo_pad1 [4]byte + Fif_name uintptr +} /* if.h:12:1 */ + +type ifaddr = struct { + Fifa_addr struct { + Fsa_family sa_family_t + Fsa_data [14]int8 + } + Fifa_ifu struct { + Fifu_broadaddr struct { + Fsa_family sa_family_t + Fsa_data [14]int8 + } + } + Fifa_ifp uintptr + Fifa_next uintptr +} /* if.h:51:1 */ + +type ifmap = struct { + Fmem_start uint64 + Fmem_end uint64 + Fbase_addr uint16 + Firq uint8 + Fdma uint8 + Fport uint8 + F__ccgo_pad1 [3]byte +} /* if.h:64:1 */ + +type ifreq = struct { + Fifr_ifrn struct{ Fifrn_name [16]int8 } + Fifr_ifru struct { + F__ccgo_pad1 [0]uint64 + Fifru_addr struct { + Fsa_family sa_family_t + Fsa_data [14]int8 + } + F__ccgo_pad2 [8]byte + } +} /* if.h:76:1 */ + +type ifconf = struct { + Fifc_len int32 + F__ccgo_pad1 [4]byte + Fifc_ifcu struct{ Fifcu_buf uintptr } +} /* if.h:116:1 */ + +type ns_sect = uint32 /* nameser.h:37:3 */ + +type __ns_msg = struct { + F_msg uintptr + F_eom uintptr + F_id uint16_t + F_flags uint16_t + F_counts [4]uint16_t + F__ccgo_pad1 [4]byte + F_sections [4]uintptr + F_sect ns_sect + F_rrnum int32 + F_msg_ptr uintptr +} /* nameser.h:39:9 */ + +type ns_msg = __ns_msg /* nameser.h:46:3 */ + +type _ns_flagdata = struct { + Fmask int32 + Fshift int32 +} /* nameser.h:48:1 */ + +type __ns_rr = struct { + Fname [1025]int8 + F__ccgo_pad1 [1]byte + Ftype uint16_t + Frr_class uint16_t + F__ccgo_pad2 [2]byte + Fttl uint32_t + Frdlength uint16_t + F__ccgo_pad3 [2]byte + Frdata uintptr +} /* nameser.h:59:9 */ + +type ns_rr = __ns_rr /* nameser.h:66:3 */ + +type ns_flag = uint32 /* nameser.h:87:3 */ + +type ns_opcode = uint32 /* nameser.h:96:3 */ + +type ns_rcode = uint32 /* nameser.h:115:3 */ + +type ns_update_operation = uint32 /* nameser.h:121:3 */ + +type ns_tsig_key1 = struct { + Fname [1025]int8 + Falg [1025]int8 + F__ccgo_pad1 [6]byte + Fdata uintptr + Flen int32 + F__ccgo_pad2 [4]byte +} /* nameser.h:123:1 */ + +type ns_tsig_key = ns_tsig_key1 /* nameser.h:128:28 */ + +type ns_tcp_tsig_state1 = struct { + Fcounter int32 + F__ccgo_pad1 [4]byte + Fkey uintptr + Fctx uintptr + Fsig [512]uint8 + Fsiglen int32 + F__ccgo_pad2 [4]byte +} /* nameser.h:130:1 */ + +type ns_tcp_tsig_state = ns_tcp_tsig_state1 /* nameser.h:137:34 */ + +type ns_type = uint32 /* nameser.h:200:3 */ + +type ns_class = uint32 /* nameser.h:219:3 */ + +type ns_key_types = uint32 /* nameser.h:226:3 */ + +type ns_cert_types = uint32 /* nameser.h:234:3 */ + +type HEADER = struct { + F__ccgo_pad1 [0]uint32 + Fid uint32 /* unsigned id: 16, unsigned rd: 1, unsigned tc: 1, unsigned aa: 1, unsigned opcode: 4, unsigned qr: 1, unsigned rcode: 4, unsigned cd: 1, unsigned ad: 1, unsigned unused: 1, unsigned ra: 1 */ + Fqdcount uint32 /* unsigned qdcount: 16, unsigned ancount: 16 */ + Fnscount uint32 /* unsigned nscount: 16, unsigned arcount: 16 */ +} /* nameser.h:353:3 */ + +// unused; purely for broken apps +type __res_state = struct { + Fretrans int32 + Fretry int32 + Foptions uint64 + Fnscount int32 + Fnsaddr_list [3]struct { + Fsin_family sa_family_t + Fsin_port in_port_t + Fsin_addr struct{ Fs_addr in_addr_t } + Fsin_zero [8]uint8_t + } + Fid uint16 + F__ccgo_pad1 [2]byte + Fdnsrch [7]uintptr + Fdefdname [256]int8 + Fpfcode uint64 + Fndots uint32 /* unsigned ndots: 4, unsigned nsort: 4, unsigned ipv6_unavail: 1, unsigned unused: 23 */ + F__ccgo_pad2 [4]byte + Fsort_list [10]struct { + Faddr struct{ Fs_addr in_addr_t } + Fmask uint32_t + } + Fqhook uintptr + Frhook uintptr + Fres_h_errno int32 + F_vcsock int32 + F_flags uint32 + F__ccgo_pad3 [4]byte + F_u struct { + F__ccgo_pad1 [0]uint64 + Fpad [52]int8 + F__ccgo_pad2 [4]byte + } +} /* resolv.h:26:9 */ + +// unused; purely for broken apps +type res_state = uintptr /* resolv.h:62:3 */ + +type res_sym = struct { + Fnumber int32 + F__ccgo_pad1 [4]byte + Fname uintptr + Fhumanname uintptr +} /* resolv.h:70:1 */ + +func itoa(tls *TLS, p uintptr, x uint32) uintptr { /* getnameinfo.c:18:13: */ + p += uintptr(uint64(3) * uint64(unsafe.Sizeof(int32(0)))) + *(*int8)(unsafe.Pointer(PreDecUintptr(&p, 1))) = int8(0) + for __ccgo := true; __ccgo; __ccgo = x != 0 { + *(*int8)(unsafe.Pointer(PreDecUintptr(&p, 1))) = int8(uint32('0') + x%uint32(10)) + x = x / uint32(10) + } + return p +} + +func mkptr4(tls *TLS, s uintptr, ip uintptr) { /* getnameinfo.c:28:13: */ + bp := tls.Alloc(32) + defer tls.Free(32) + + Xsprintf(tls, s, ts+25, + VaList(bp, int32(*(*uint8)(unsafe.Pointer(ip + 3))), int32(*(*uint8)(unsafe.Pointer(ip + 2))), int32(*(*uint8)(unsafe.Pointer(ip + 1))), int32(*(*uint8)(unsafe.Pointer(ip))))) +} + +func mkptr6(tls *TLS, s uintptr, ip uintptr) { /* getnameinfo.c:34:13: */ + var i int32 + for i = 15; i >= 0; i-- { + *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = _sxdigits[int32(*(*uint8)(unsafe.Pointer(ip + uintptr(i))))&15] + *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8('.') + *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = _sxdigits[int32(*(*uint8)(unsafe.Pointer(ip + uintptr(i))))>>4] + *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8('.') + } + Xstrcpy(tls, s, ts+50) +} + +var _sxdigits = *(*[17]int8)(unsafe.Pointer(ts + 59)) /* getnameinfo.c:36:20 */ + +func reverse_hosts(tls *TLS, buf uintptr, a uintptr, scopeid uint32, family int32) { /* getnameinfo.c:45:13: */ + bp := tls.Alloc(556) + defer tls.Free(556) + + // var line [512]int8 at bp+16, 512 + + var p uintptr + var z uintptr + var _buf [1032]uint8 + _ = _buf + // var atmp [16]uint8 at bp, 16 + + // var iplit address at bp+528, 28 + + //TODO FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); + var f uintptr = Xfopen(tls, ts+76, ts+87) + if !(f != 0) { + return + } + if family == 2 { + Xmemcpy(tls, bp+uintptr(12), a, uint64(4)) + Xmemcpy(tls, bp, ts+90, uint64(12)) + a = bp /* &atmp[0] */ + } + for Xfgets(tls, bp+16, int32(unsafe.Sizeof([512]int8{})), f) != 0 { + if AssignUintptr(&p, Xstrchr(tls, bp+16, '#')) != 0 { + *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8('\n') + *(*int8)(unsafe.Pointer(p)) = int8(0) + } + + for p = bp + 16; /* &line[0] */ *(*int8)(unsafe.Pointer(p)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0); p++ { + } + *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8(0) + if X__lookup_ipliteral(tls, bp+528, bp+16, 0) <= 0 { + continue + } + + if (*address)(unsafe.Pointer(bp+528)).Ffamily == 2 { + Xmemcpy(tls, bp+528+8+uintptr(12), bp+528+8, uint64(4)) + Xmemcpy(tls, bp+528+8, ts+90, uint64(12)) + (*address)(unsafe.Pointer(bp + 528 /* &iplit */)).Fscopeid = uint32(0) + } + + if Xmemcmp(tls, a, bp+528+8, uint64(16)) != 0 || (*address)(unsafe.Pointer(bp+528)).Fscopeid != scopeid { + continue + } + + for ; *(*int8)(unsafe.Pointer(p)) != 0 && __isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0; p++ { + } + for z = p; *(*int8)(unsafe.Pointer(z)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(z)))) != 0); z++ { + } + *(*int8)(unsafe.Pointer(z)) = int8(0) + if (int64(z)-int64(p))/1 < int64(256) { + Xmemcpy(tls, buf, p, uint64((int64(z)-int64(p))/1+int64(1))) + break + } + } + //TODO __fclose_ca(f); + Xfclose(tls, f) +} + +func reverse_services(tls *TLS, buf uintptr, port int32, dgram int32) { /* getnameinfo.c:87:13: */ + Xabort(tls) //TODO- + // unsigned long svport; + // char line[128], *p, *z; + // unsigned char _buf[1032]; + // FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf); + // if (!f) return; + // while (fgets(line, sizeof line, f)) { + // if ((p=strchr(line, '#'))) *p++='\n', *p=0; + + // for (p=line; *p && !isspace(*p); p++); + // if (!*p) continue; + // *p++ = 0; + // svport = strtoul(p, &z, 10); + + // if (svport != port || z==p) continue; + // if (dgram && strncmp(z, "/udp", 4)) continue; + // if (!dgram && strncmp(z, "/tcp", 4)) continue; + // if (p-line > 32) continue; + + // memcpy(buf, line, p-line); + // break; + // } + // __fclose_ca(f); +} + +func Xgetnameinfo(tls *TLS, sa1 uintptr, sl socklen_t, node uintptr, nodelen socklen_t, serv uintptr, servlen socklen_t, flags int32) int32 { /* getnameinfo.c:125:5: */ + if __ccgo_strace { + trc("tls=%v sa1=%v sl=%v node=%v nodelen=%v serv=%v servlen=%v flags=%v, (%v:)", tls, sa1, sl, node, nodelen, serv, servlen, flags, origin(2)) + } + bp := tls.Alloc(347) + defer tls.Free(347) + + // var ptr [78]int8 at bp, 78 + + // var buf [256]int8 at bp+78, 256 + + // var num [13]int8 at bp+334, 13 + + var af int32 = int32((*sockaddr)(unsafe.Pointer(sa1)).Fsa_family) + var a uintptr + var scopeid uint32 + + switch af { + case 2: + a = sa1 + 4 + if uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in{})) { + return -6 + } + mkptr4(tls, bp, a) + scopeid = uint32(0) + break + case 10: + a = sa1 + 8 + if uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in6{})) { + return -6 + } + if Xmemcmp(tls, a, ts+90, uint64(12)) != 0 { + mkptr6(tls, bp, a) + } else { + mkptr4(tls, bp, a+uintptr(12)) + } + scopeid = (*sockaddr_in6)(unsafe.Pointer(sa1)).Fsin6_scope_id + break + default: + return -6 + } + + if node != 0 && nodelen != 0 { + *(*int8)(unsafe.Pointer(bp + 78)) = int8(0) + if !(flags&0x01 != 0) { + reverse_hosts(tls, bp+78, a, scopeid, af) + } + if !(int32(*(*int8)(unsafe.Pointer(bp + 78))) != 0) && !(flags&0x01 != 0) { + Xabort(tls) //TODO- + // unsigned char query[18+PTR_MAX], reply[512]; + // int qlen = __res_mkquery(0, ptr, 1, RR_PTR, + // 0, 0, 0, query, sizeof query); + // query[3] = 0; /* don't need AD flag */ + // int rlen = __res_send(query, qlen, reply, sizeof reply); + // buf[0] = 0; + // if (rlen > 0) + // __dns_parse(reply, rlen, dns_parse_callback, buf); + } + if !(int32(*(*int8)(unsafe.Pointer(bp + 78))) != 0) { + if flags&0x08 != 0 { + return -2 + } + Xinet_ntop(tls, af, a, bp+78, uint32(unsafe.Sizeof([256]int8{}))) + if scopeid != 0 { + Xabort(tls) //TODO- + // char *p = 0, tmp[IF_NAMESIZE+1]; + // if (!(flags & NI_NUMERICSCOPE) && + // (IN6_IS_ADDR_LINKLOCAL(a) || + // IN6_IS_ADDR_MC_LINKLOCAL(a))) + // p = if_indextoname(scopeid, tmp+1); + // if (!p) + // p = itoa(num, scopeid); + // *--p = '%'; + // strcat(buf, p); + } + } + if Xstrlen(tls, bp+78) >= size_t(nodelen) { + return -12 + } + Xstrcpy(tls, node, bp+78) + } + + if serv != 0 && servlen != 0 { + var p uintptr = bp + 78 /* buf */ + var port int32 = int32(Xntohs(tls, (*sockaddr_in)(unsafe.Pointer(sa1)).Fsin_port)) + *(*int8)(unsafe.Pointer(bp + 78)) = int8(0) + if !(flags&0x02 != 0) { + reverse_services(tls, bp+78, port, flags&0x10) + } + if !(int32(*(*int8)(unsafe.Pointer(p))) != 0) { + p = itoa(tls, bp+334, uint32(port)) + } + if Xstrlen(tls, p) >= size_t(servlen) { + return -12 + } + Xstrcpy(tls, serv, p) + } + + return 0 +} + +var Xh_errno int32 /* h_errno.c:4:5: */ + +func X__h_errno_location(tls *TLS) uintptr { /* h_errno.c:6:5: */ + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + return uintptr(unsafe.Pointer(&Xh_errno)) +} + +func X__inet_aton(tls *TLS, s0 uintptr, dest uintptr) int32 { /* inet_aton.c:7:5: */ + if __ccgo_strace { + trc("tls=%v s0=%v dest=%v, (%v:)", tls, s0, dest, origin(2)) + } + bp := tls.Alloc(40) + defer tls.Free(40) + + var s uintptr = s0 + var d uintptr = dest + *(*[4]uint64)(unsafe.Pointer(bp /* a */)) = [4]uint64{0: uint64(0)} + // var z uintptr at bp+32, 8 + + var i int32 + + for i = 0; i < 4; i++ { + *(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)) = Xstrtoul(tls, s, bp+32, 0) + if *(*uintptr)(unsafe.Pointer(bp + 32)) == s || *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)))) != 0 && int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32))))) != '.' || !(func() int32 { + if 0 != 0 { + return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(s)))) + } + return Bool32(uint32(*(*int8)(unsafe.Pointer(s)))-uint32('0') < uint32(10)) + }() != 0) { + return 0 + } + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32))))) != 0) { + break + } + s = *(*uintptr)(unsafe.Pointer(bp + 32)) + uintptr(1) + } + if i == 4 { + return 0 + } + switch i { + case 0: + *(*uint64)(unsafe.Pointer(bp + 1*8)) = *(*uint64)(unsafe.Pointer(bp)) & uint64(0xffffff) + AssignShrPtrUint64(bp, int(24)) + fallthrough + case 1: + *(*uint64)(unsafe.Pointer(bp + 2*8)) = *(*uint64)(unsafe.Pointer(bp + 1*8)) & uint64(0xffff) + AssignShrPtrUint64(bp+1*8, int(16)) + fallthrough + case 2: + *(*uint64)(unsafe.Pointer(bp + 3*8)) = *(*uint64)(unsafe.Pointer(bp + 2*8)) & uint64(0xff) + AssignShrPtrUint64(bp+2*8, int(8)) + } + for i = 0; i < 4; i++ { + if *(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)) > uint64(255) { + return 0 + } + *(*uint8)(unsafe.Pointer(d + uintptr(i))) = uint8(*(*uint64)(unsafe.Pointer(bp + uintptr(i)*8))) + } + return 1 +} + +func Xinet_ntop(tls *TLS, af int32, a0 uintptr, s uintptr, l socklen_t) uintptr { /* inet_ntop.c:7:12: */ + if __ccgo_strace { + trc("tls=%v af=%v a0=%v s=%v l=%v, (%v:)", tls, af, a0, s, l, origin(2)) + } + bp := tls.Alloc(276) + defer tls.Free(276) + + var a uintptr = a0 + var i int32 + var j int32 + var max int32 + var best int32 + // var buf [100]int8 at bp+176, 100 + + switch af { + case 2: + if socklen_t(Xsnprintf(tls, s, uint64(l), ts+103, VaList(bp, int32(*(*uint8)(unsafe.Pointer(a))), int32(*(*uint8)(unsafe.Pointer(a + 1))), int32(*(*uint8)(unsafe.Pointer(a + 2))), int32(*(*uint8)(unsafe.Pointer(a + 3)))))) < l { + return s + } + break + case 10: + if Xmemcmp(tls, a, ts+90, uint64(12)) != 0 { + Xsnprintf(tls, bp+176, uint64(unsafe.Sizeof([100]int8{})), + ts+115, + VaList(bp+32, 256*int32(*(*uint8)(unsafe.Pointer(a)))+int32(*(*uint8)(unsafe.Pointer(a + 1))), 256*int32(*(*uint8)(unsafe.Pointer(a + 2)))+int32(*(*uint8)(unsafe.Pointer(a + 3))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 4)))+int32(*(*uint8)(unsafe.Pointer(a + 5))), 256*int32(*(*uint8)(unsafe.Pointer(a + 6)))+int32(*(*uint8)(unsafe.Pointer(a + 7))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 8)))+int32(*(*uint8)(unsafe.Pointer(a + 9))), 256*int32(*(*uint8)(unsafe.Pointer(a + 10)))+int32(*(*uint8)(unsafe.Pointer(a + 11))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 12)))+int32(*(*uint8)(unsafe.Pointer(a + 13))), 256*int32(*(*uint8)(unsafe.Pointer(a + 14)))+int32(*(*uint8)(unsafe.Pointer(a + 15))))) + } else { + Xsnprintf(tls, bp+176, uint64(unsafe.Sizeof([100]int8{})), + ts+139, + VaList(bp+96, 256*int32(*(*uint8)(unsafe.Pointer(a)))+int32(*(*uint8)(unsafe.Pointer(a + 1))), 256*int32(*(*uint8)(unsafe.Pointer(a + 2)))+int32(*(*uint8)(unsafe.Pointer(a + 3))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 4)))+int32(*(*uint8)(unsafe.Pointer(a + 5))), 256*int32(*(*uint8)(unsafe.Pointer(a + 6)))+int32(*(*uint8)(unsafe.Pointer(a + 7))), + 256*int32(*(*uint8)(unsafe.Pointer(a + 8)))+int32(*(*uint8)(unsafe.Pointer(a + 9))), 256*int32(*(*uint8)(unsafe.Pointer(a + 10)))+int32(*(*uint8)(unsafe.Pointer(a + 11))), + int32(*(*uint8)(unsafe.Pointer(a + 12))), int32(*(*uint8)(unsafe.Pointer(a + 13))), int32(*(*uint8)(unsafe.Pointer(a + 14))), int32(*(*uint8)(unsafe.Pointer(a + 15))))) + } + // Replace longest /(^0|:)[:0]{2,}/ with "::" + i = AssignInt32(&best, 0) + max = 2 + for ; *(*int8)(unsafe.Pointer(bp + 176 + uintptr(i))) != 0; i++ { + if i != 0 && int32(*(*int8)(unsafe.Pointer(bp + 176 + uintptr(i)))) != ':' { + continue + } + j = int32(Xstrspn(tls, bp+176+uintptr(i), ts+169)) + if j > max { + best = i + max = j + } + } + if max > 3 { + *(*int8)(unsafe.Pointer(bp + 176 + uintptr(best))) = AssignPtrInt8(bp+176+uintptr(best+1), int8(':')) + Xmemmove(tls, bp+176+uintptr(best)+uintptr(2), bp+176+uintptr(best)+uintptr(max), uint64(i-best-max+1)) + } + if Xstrlen(tls, bp+176) < size_t(l) { + Xstrcpy(tls, s, bp+176) + return s + } + break + default: + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 97 + return uintptr(0) + } + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 28 + return uintptr(0) +} + +func hexval(tls *TLS, c uint32) int32 { /* inet_pton.c:7:12: */ + if c-uint32('0') < uint32(10) { + return int32(c - uint32('0')) + } + c = c | uint32(32) + if c-uint32('a') < uint32(6) { + return int32(c - uint32('a') + uint32(10)) + } + return -1 +} + +func Xinet_pton(tls *TLS, af int32, s uintptr, a0 uintptr) int32 { /* inet_pton.c:15:5: */ + if __ccgo_strace { + trc("tls=%v af=%v s=%v a0=%v, (%v:)", tls, af, s, a0, origin(2)) + } + bp := tls.Alloc(16) + defer tls.Free(16) + + // var ip [8]uint16_t at bp, 16 + + var a uintptr = a0 + var i int32 + var j int32 + var v int32 + var d int32 + var brk int32 = -1 + var need_v4 int32 = 0 + + if af == 2 { + for i = 0; i < 4; i++ { + for v = AssignInt32(&j, 0); j < 3 && func() int32 { + if 0 != 0 { + return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(s + uintptr(j))))) + } + return Bool32(uint32(*(*int8)(unsafe.Pointer(s + uintptr(j))))-uint32('0') < uint32(10)) + }() != 0; j++ { + v = 10*v + int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) - '0' + } + if j == 0 || j > 1 && int32(*(*int8)(unsafe.Pointer(s))) == '0' || v > 255 { + return 0 + } + *(*uint8)(unsafe.Pointer(a + uintptr(i))) = uint8(v) + if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) == 0 && i == 3 { + return 1 + } + if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != '.' { + return 0 + } + s += uintptr(j + 1) + } + return 0 + } else if af != 10 { + *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 97 + return -1 + } + + if int32(*(*int8)(unsafe.Pointer(s))) == ':' && int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&s, 1)))) != ':' { + return 0 + } + + for i = 0; ; i++ { + if int32(*(*int8)(unsafe.Pointer(s))) == ':' && brk < 0 { + brk = i + *(*uint16_t)(unsafe.Pointer(bp + uintptr(i&7)*2)) = uint16_t(0) + if !(int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&s, 1)))) != 0) { + break + } + if i == 7 { + return 0 + } + continue + } + for v = AssignInt32(&j, 0); j < 4 && AssignInt32(&d, hexval(tls, uint32(*(*int8)(unsafe.Pointer(s + uintptr(j)))))) >= 0; j++ { + v = 16*v + d + } + if j == 0 { + return 0 + } + *(*uint16_t)(unsafe.Pointer(bp + uintptr(i&7)*2)) = uint16_t(v) + if !(int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != 0) && (brk >= 0 || i == 7) { + break + } + if i == 7 { + return 0 + } + if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != ':' { + if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != '.' || i < 6 && brk < 0 { + return 0 + } + need_v4 = 1 + i++ + break + } + s += uintptr(j + 1) + } + if brk >= 0 { + Xmemmove(tls, bp+uintptr(brk)*2+uintptr(7)*2-uintptr(i)*2, bp+uintptr(brk)*2, uint64(2*(i+1-brk))) + for j = 0; j < 7-i; j++ { + *(*uint16_t)(unsafe.Pointer(bp + uintptr(brk+j)*2)) = uint16_t(0) + } + } + for j = 0; j < 8; j++ { + *(*uint8)(unsafe.Pointer(PostIncUintptr(&a, 1))) = uint8(int32(*(*uint16_t)(unsafe.Pointer(bp + uintptr(j)*2))) >> 8) + *(*uint8)(unsafe.Pointer(PostIncUintptr(&a, 1))) = uint8(*(*uint16_t)(unsafe.Pointer(bp + uintptr(j)*2))) + } + if need_v4 != 0 && Xinet_pton(tls, 2, s, a-uintptr(4)) <= 0 { + return 0 + } + return 1 +} + +func X__lookup_ipliteral(tls *TLS, buf uintptr, name uintptr, family int32) int32 { /* lookup_ipliteral.c:12:5: */ + if __ccgo_strace { + trc("tls=%v buf=%v name=%v family=%v, (%v:)", tls, buf, name, family, origin(2)) + } + bp := tls.Alloc(96) + defer tls.Free(96) + + // var a4 in_addr at bp, 4 + + // var a6 in6_addr at bp+68, 16 + + if X__inet_aton(tls, name, bp) > 0 { + if family == 10 { // wrong family + return -2 + } + Xmemcpy(tls, buf+8, bp, uint64(unsafe.Sizeof(in_addr{}))) + (*address)(unsafe.Pointer(buf)).Ffamily = 2 + (*address)(unsafe.Pointer(buf)).Fscopeid = uint32(0) + return 1 + } + // var tmp [64]int8 at bp+4, 64 + + var p uintptr = Xstrchr(tls, name, '%') + // var z uintptr at bp+88, 8 + + var scopeid uint64 = uint64(0) + if p != 0 && (int64(p)-int64(name))/1 < int64(64) { + Xmemcpy(tls, bp+4, name, uint64((int64(p)-int64(name))/1)) + *(*int8)(unsafe.Pointer(bp + 4 + uintptr((int64(p)-int64(name))/1))) = int8(0) + name = bp + 4 /* &tmp[0] */ + } + + if Xinet_pton(tls, 10, name, bp+68) <= 0 { + return 0 + } + if family == 2 { // wrong family + return -2 + } + + Xmemcpy(tls, buf+8, bp+68, uint64(unsafe.Sizeof(in6_addr{}))) + (*address)(unsafe.Pointer(buf)).Ffamily = 10 + if p != 0 { + if func() int32 { + if 0 != 0 { + return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&p, 1))))) + } + return Bool32(uint32(*(*int8)(unsafe.Pointer(PreIncUintptr(&p, 1))))-uint32('0') < uint32(10)) + }() != 0 { + scopeid = Xstrtoull(tls, p, bp+88, 10) + } else { + *(*uintptr)(unsafe.Pointer(bp + 88 /* z */)) = p - uintptr(1) + } + if *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 88)))) != 0 { + Xabort(tls) //TODO- + // if (!IN6_IS_ADDR_LINKLOCAL(&a6) && + // !IN6_IS_ADDR_MC_LINKLOCAL(&a6)) + // return EAI_NONAME; + // scopeid = if_nametoindex(p); + // if (!scopeid) return EAI_NONAME; + } + if scopeid > uint64(0xffffffff) { + return -2 + } + } + (*address)(unsafe.Pointer(buf)).Fscopeid = uint32(scopeid) + return 1 +} + +type mode_t = uint32 /* alltypes.h:160:18 */ + +type flock = struct { + Fl_type int16 + Fl_whence int16 + F__ccgo_pad1 [4]byte + Fl_start off_t + Fl_len off_t + Fl_pid pid_t + F__ccgo_pad2 [4]byte +} /* fcntl.h:24:1 */ + +func is_valid_hostname(tls *TLS, host uintptr) int32 { /* lookup_name.c:18:12: */ + var s uintptr + //TODO if (strnlen(host, 255)-1 >= 254 || mbstowcs(0, host, 0) == -1) return 0; + if Xstrnlen(tls, host, uint64(255))-uint64(1) >= uint64(254) { + return 0 + } + for s = host; int32(*(*uint8)(unsafe.Pointer(s))) >= 0x80 || int32(*(*uint8)(unsafe.Pointer(s))) == '.' || int32(*(*uint8)(unsafe.Pointer(s))) == '-' || Xisalnum(tls, int32(*(*uint8)(unsafe.Pointer(s)))) != 0; s++ { + } + return BoolInt32(!(*(*uint8)(unsafe.Pointer(s)) != 0)) +} + +var Xzero_struct_address address /* lookup_name.c:27:16: */ + +func name_from_null(tls *TLS, buf uintptr, name uintptr, family int32, flags int32) int32 { /* lookup_name.c:29:12: */ + var cnt int32 = 0 + if name != 0 { + return 0 + } + if flags&0x01 != 0 { + //TODO if (family != AF_INET6) + //TODO buf[cnt++] = (struct address){ .family = AF_INET }; + if family != 10 { + var x = Xzero_struct_address + x.Ffamily = 2 + *(*address)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*28)) = x + } + //TODO if (family != AF_INET) + //TODO buf[cnt++] = (struct address){ .family = AF_INET6 }; + if family != 2 { + var x = Xzero_struct_address + x.Ffamily = 10 + *(*address)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*28)) = x + } + } else { + Xabort(tls) //TODO- + // if (family != AF_INET6) + // buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } }; + // if (family != AF_INET) + // buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } }; + } + return cnt +} + +func name_from_numeric(tls *TLS, buf uintptr, name uintptr, family int32) int32 { /* lookup_name.c:58:12: */ + return X__lookup_ipliteral(tls, buf, name, family) +} + +func name_from_hosts(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) int32 { /* lookup_name.c:63:12: */ + bp := tls.Alloc(512) + defer tls.Free(512) + + // var line [512]int8 at bp, 512 + + var l size_t = Xstrlen(tls, name) + var cnt int32 = 0 + var badfam int32 = 0 + var _buf [1032]uint8 + _ = _buf + //TODO FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); + var _f FILE + _ = _f + var f uintptr = Xfopen(tls, ts+76, ts+87) + if !(f != 0) { + switch *(*int32)(unsafe.Pointer(X___errno_location(tls))) { + case 2: + fallthrough + case 20: + fallthrough + case 13: + return 0 + fallthrough + default: + return -11 + } + } + for Xfgets(tls, bp, int32(unsafe.Sizeof([512]int8{})), f) != 0 && cnt < 48 { + var p uintptr + var z uintptr + + if AssignUintptr(&p, Xstrchr(tls, bp, '#')) != 0 { + *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8('\n') + *(*int8)(unsafe.Pointer(p)) = int8(0) + } + for p = bp + uintptr(1); AssignUintptr(&p, Xstrstr(tls, p, name)) != 0 && (!(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p + UintptrFromInt32(-1))))) != 0) || !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p + uintptr(l))))) != 0)); p++ { + } + if !(p != 0) { + continue + } + + // Isolate IP address to parse + for p = bp; /* &line[0] */ *(*int8)(unsafe.Pointer(p)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0); p++ { + } + *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8(0) + switch name_from_numeric(tls, buf+uintptr(cnt)*28, bp, family) { + case 1: + cnt++ + break + case 0: + continue + default: + badfam = -2 + continue + } + + // Extract first name as canonical name + for ; *(*int8)(unsafe.Pointer(p)) != 0 && __isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0; p++ { + } + for z = p; *(*int8)(unsafe.Pointer(z)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(z)))) != 0); z++ { + } + *(*int8)(unsafe.Pointer(z)) = int8(0) + if is_valid_hostname(tls, p) != 0 { + Xmemcpy(tls, canon, p, uint64((int64(z)-int64(p))/1+int64(1))) + } + } + //TODO __fclose_ca(f); + Xfclose(tls, f) + if cnt != 0 { + return cnt + } + return badfam +} + +type dpc_ctx = struct { + Faddrs uintptr + Fcanon uintptr + Fcnt int32 + F__ccgo_pad1 [4]byte +} /* lookup_name.c:112:1 */ + +func name_from_dns_search(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) int32 { /* lookup_name.c:191:12: */ + return -1 //TODO- + Xabort(tls) + return int32(0) //TODO- + // char search[256]; + // struct resolvconf conf; + // size_t l, dots; + // char *p, *z; + + // if (__get_resolv_conf(&conf, search, sizeof search) < 0) return -1; + + // /* Count dots, suppress search when >=ndots or name ends in + // * a dot, which is an explicit request for global scope. */ + // for (dots=l=0; name[l]; l++) if (name[l]=='.') dots++; + // if (dots >= conf.ndots || name[l-1]=='.') *search = 0; + + // /* Strip final dot for canon, fail if multiple trailing dots. */ + // if (name[l-1]=='.') l--; + // if (!l || name[l-1]=='.') return EAI_NONAME; + + // /* This can never happen; the caller already checked length. */ + // if (l >= 256) return EAI_NONAME; + + // /* Name with search domain appended is setup in canon[]. This both + // * provides the desired default canonical name (if the requested + // * name is not a CNAME record) and serves as a buffer for passing + // * the full requested name to name_from_dns. */ + // memcpy(canon, name, l); + // canon[l] = '.'; + + // for (p=search; *p; p=z) { + // for (; isspace(*p); p++); + // for (z=p; *z && !isspace(*z); z++); + // if (z==p) break; + // if (z-p < 256 - l - 1) { + // memcpy(canon+l+1, p, z-p); + // canon[z-p+1+l] = 0; + // int cnt = name_from_dns(buf, canon, canon, family, &conf); + // if (cnt) return cnt; + // } + // } + + // canon[l] = 0; + // return name_from_dns(buf, canon, name, family, &conf); +} + +type policy = struct { + Faddr [16]uint8 + Flen uint8 + Fmask uint8 + Fprec uint8 + Flabel uint8 +} /* lookup_name.c:237:14 */ + +var defpolicy = [6]policy{ + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 172)), Flen: uint8(15), Fmask: uint8(0xff), Fprec: uint8(50)}, + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 189)), Flen: uint8(11), Fmask: uint8(0xff), Fprec: uint8(35), Flabel: uint8(4)}, + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 205)), Flen: uint8(1), Fmask: uint8(0xff), Fprec: uint8(30), Flabel: uint8(2)}, + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 221)), Flen: uint8(3), Fmask: uint8(0xff), Fprec: uint8(5), Flabel: uint8(5)}, + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 237)), Fmask: uint8(0xfe), Fprec: uint8(3), Flabel: uint8(13)}, + // Last rule must match all addresses to stop loop. + {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 253)), Fprec: uint8(40), Flabel: uint8(1)}, +} /* lookup_name.c:241:3 */ + +func policyof(tls *TLS, a uintptr) uintptr { /* lookup_name.c:259:28: */ + var i int32 + for i = 0; ; i++ { + if Xmemcmp(tls, a, uintptr(unsafe.Pointer(&defpolicy))+uintptr(i)*20, uint64(defpolicy[i].Flen)) != 0 { + continue + } + if int32(*(*uint8_t)(unsafe.Pointer(a + uintptr(defpolicy[i].Flen))))&int32(defpolicy[i].Fmask) != + int32(*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(&defpolicy)) + uintptr(i)*20 + uintptr(defpolicy[i].Flen)))) { + continue + } + return uintptr(unsafe.Pointer(&defpolicy)) + uintptr(i)*20 + } + return uintptr(0) +} + +func labelof(tls *TLS, a uintptr) int32 { /* lookup_name.c:272:12: */ + return int32((*policy)(unsafe.Pointer(policyof(tls, a))).Flabel) +} + +func scopeof(tls *TLS, a uintptr) int32 { /* lookup_name.c:277:12: */ + if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xff { + return int32(*(*uint8_t)(unsafe.Pointer(a + 1))) & 15 + } + if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xfe && int32(*(*uint8_t)(unsafe.Pointer(a + 1)))&0xc0 == 0x80 { + return 2 + } + if *(*uint32_t)(unsafe.Pointer(a)) == uint32_t(0) && *(*uint32_t)(unsafe.Pointer(a + 1*4)) == uint32_t(0) && *(*uint32_t)(unsafe.Pointer(a + 2*4)) == uint32_t(0) && int32(*(*uint8_t)(unsafe.Pointer(a + 12))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 13))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 14))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 15))) == 1 { + return 2 + } + if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xfe && int32(*(*uint8_t)(unsafe.Pointer(a + 1)))&0xc0 == 0xc0 { + return 5 + } + return 14 +} + +func prefixmatch(tls *TLS, s uintptr, d uintptr) int32 { /* lookup_name.c:286:12: */ + // FIXME: The common prefix length should be limited to no greater + // than the nominal length of the prefix portion of the source + // address. However the definition of the source prefix length is + // not clear and thus this limiting is not yet implemented. + var i uint32 + for i = uint32(0); i < uint32(128) && !((int32(*(*uint8_t)(unsafe.Pointer(s /* &.__in6_union */ /* &.__s6_addr */ + uintptr(i/uint32(8)))))^int32(*(*uint8_t)(unsafe.Pointer(d /* &.__in6_union */ /* &.__s6_addr */ + uintptr(i/uint32(8))))))&(int32(128)>>(i%uint32(8))) != 0); i++ { + } + return int32(i) +} + +func addrcmp(tls *TLS, _a uintptr, _b uintptr) int32 { /* lookup_name.c:305:12: */ + var a uintptr = _a + var b uintptr = _b + return (*address)(unsafe.Pointer(b)).Fsortkey - (*address)(unsafe.Pointer(a)).Fsortkey +} + +func X__lookup_name(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, flags int32) int32 { /* lookup_name.c:311:5: */ + if __ccgo_strace { + trc("tls=%v buf=%v canon=%v name=%v family=%v flags=%v, (%v:)", tls, buf, canon, name, family, flags, origin(2)) + } + bp := tls.Alloc(92) + defer tls.Free(92) + + var cnt int32 = 0 + var i int32 + var j int32 + _ = j + + *(*int8)(unsafe.Pointer(canon)) = int8(0) + if name != 0 { + // reject empty name and check len so it fits into temp bufs + var l size_t = Xstrnlen(tls, name, uint64(255)) + if l-uint64(1) >= uint64(254) { + return -2 + } + Xmemcpy(tls, canon, name, l+uint64(1)) + } + + // Procedurally, a request for v6 addresses with the v4-mapped + // flag set is like a request for unspecified family, followed + // by filtering of the results. + if flags&0x08 != 0 { + if family == 10 { + family = 0 + } else { + flags = flags - 0x08 + } + } + + // Try each backend until there's at least one result. + cnt = name_from_null(tls, buf, name, family, flags) + if !(cnt != 0) { + cnt = name_from_numeric(tls, buf, name, family) + } + if !(cnt != 0) && !(flags&0x04 != 0) { + cnt = name_from_hosts(tls, buf, canon, name, family) + if !(cnt != 0) { + cnt = name_from_dns_search(tls, buf, canon, name, family) + } + } + if cnt <= 0 { + if cnt != 0 { + return cnt + } + return -2 + } + + // Filter/transform results for v4-mapped lookup, if requested. + if flags&0x08 != 0 { + Xabort(tls) //TODO- + // if (!(flags & AI_ALL)) { + // /* If any v6 results exist, remove v4 results. */ + // for (i=0; i= 0 { + if !(Xconnect(tls, fd, da, dalen) != 0) { + key = key | 0x40000000 + if !(Xgetsockname(tls, fd, sa1, bp+88) != 0) { + if family == 2 { + Xmemcpy(tls, + bp+28+8+uintptr(12), + bp+72+4, uint64(4)) + } + if dscope == scopeof(tls, bp+28+8) { + key = key | 0x20000000 + } + if dlabel == labelof(tls, bp+28+8) { + key = key | 0x10000000 + } + prefixlen = prefixmatch(tls, bp+28+8, + bp+8) + } + } + Xclose(tls, fd) + } + key = key | dprec<<20 + key = key | (15-dscope)<<16 + key = key | prefixlen<<8 + key = key | (48-i)<<0 + (*address)(unsafe.Pointer(buf + uintptr(i)*28)).Fsortkey = key + } + Xqsort(tls, buf, uint64(cnt), uint64(unsafe.Sizeof(address{})), *(*uintptr)(unsafe.Pointer(&struct { + f func(*TLS, uintptr, uintptr) int32 + }{addrcmp}))) + + //TODO pthread_setcancelstate(cs, 0); + + return cnt +} + +func X__lookup_serv(tls *TLS, buf uintptr, name uintptr, proto int32, socktype int32, flags int32) int32 { /* lookup_serv.c:12:5: */ + if __ccgo_strace { + trc("tls=%v buf=%v name=%v proto=%v socktype=%v flags=%v, (%v:)", tls, buf, name, proto, socktype, flags, origin(2)) + } + bp := tls.Alloc(8) + defer tls.Free(8) + + var line [128]int8 + _ = line + var cnt int32 = 0 + var p uintptr + _ = p + *(*uintptr)(unsafe.Pointer(bp /* z */)) = ts + 13 /* "" */ + var port uint64 = uint64(0) + + switch socktype { + case 1: + switch proto { + case 0: + proto = 6 + fallthrough + case 6: + break + default: + return -8 + } + break + case 2: + switch proto { + case 0: + proto = 17 + fallthrough + case 17: + break + default: + return -8 + } + fallthrough + case 0: + break + default: + if name != 0 { + return -8 + } + (*service)(unsafe.Pointer(buf)).Fport = uint16_t(0) + (*service)(unsafe.Pointer(buf)).Fproto = uint8(proto) + (*service)(unsafe.Pointer(buf)).Fsocktype = uint8(socktype) + return 1 + } + + if name != 0 { + if !(int32(*(*int8)(unsafe.Pointer(name))) != 0) { + return -8 + } + port = Xstrtoul(tls, name, bp, 10) + } + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0) { + if port > uint64(65535) { + return -8 + } + if proto != 17 { + (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fport = uint16_t(port) + (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fsocktype = uint8(1) + (*service)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*4)).Fproto = uint8(6) + } + if proto != 6 { + (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fport = uint16_t(port) + (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fsocktype = uint8(2) + (*service)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*4)).Fproto = uint8(17) + } + return cnt + } + + if flags&0x400 != 0 { + return -2 + } + + var l size_t = Xstrlen(tls, name) + _ = l + + Xabort(tls) //TODO- + // unsigned char _buf[1032]; + // FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf); + // if (!f) switch (errno) { + // case ENOENT: + // case ENOTDIR: + // case EACCES: + // return EAI_SERVICE; + // default: + // return EAI_SYSTEM; + // } + + Xabort(tls) //TODO- + // while (fgets(line, sizeof line, f) && cnt < MAXSERVS) { + // if ((p=strchr(line, '#'))) *p++='\n', *p=0; + + // /* Find service name */ + // for(p=line; (p=strstr(p, name)); p++) { + // if (p>line && !isspace(p[-1])) continue; + // if (p[l] && !isspace(p[l])) continue; + // break; + // } + // if (!p) continue; + + // /* Skip past canonical name at beginning of line */ + // for (p=line; *p && !isspace(*p); p++); + + // port = strtoul(p, &z, 10); + // if (port > 65535 || z==p) continue; + // if (!strncmp(z, "/udp", 4)) { + // if (proto == IPPROTO_TCP) continue; + // buf[cnt].port = port; + // buf[cnt].socktype = SOCK_DGRAM; + // buf[cnt++].proto = IPPROTO_UDP; + // } + // if (!strncmp(z, "/tcp", 4)) { + // if (proto == IPPROTO_UDP) continue; + // buf[cnt].port = port; + // buf[cnt].socktype = SOCK_STREAM; + // buf[cnt++].proto = IPPROTO_TCP; + // } + // } + // __fclose_ca(f); + // return cnt > 0 ? cnt : EAI_SERVICE; + Xabort(tls) + return int32(0) //TODO- +} + +func temper(tls *TLS, x uint32) uint32 { /* rand_r.c:3:17: */ + x = x ^ x>>11 + x = x ^ x<<7&0x9D2C5680 + x = x ^ x<<15&0xEFC60000 + x = x ^ x>>18 + return x +} + +func Xrand_r(tls *TLS, seed uintptr) int32 { /* rand_r.c:12:5: */ + if __ccgo_strace { + trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2)) + } + return int32(temper(tls, AssignPtrUint32(seed, *(*uint32)(unsafe.Pointer(seed))*uint32(1103515245)+uint32(12345))) / uint32(2)) +} + +func X__toread(tls *TLS, f uintptr) int32 { /* __toread.c:3:5: */ + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + *(*int32)(unsafe.Pointer(f + 136)) |= (*FILE)(unsafe.Pointer(f)).Fmode - 1 + if (*FILE)(unsafe.Pointer(f)).Fwpos != (*FILE)(unsafe.Pointer(f)).Fwbase { + (*struct { + f func(*TLS, uintptr, uintptr, size_t) size_t + })(unsafe.Pointer(&struct{ uintptr }{(*FILE)(unsafe.Pointer(f)).Fwrite})).f(tls, f, uintptr(0), uint64(0)) + } + (*FILE)(unsafe.Pointer(f)).Fwpos = AssignPtrUintptr(f+56, AssignPtrUintptr(f+32, uintptr(0))) + if (*FILE)(unsafe.Pointer(f)).Fflags&uint32(4) != 0 { + *(*uint32)(unsafe.Pointer(f)) |= uint32(32) + return -1 + } + (*FILE)(unsafe.Pointer(f)).Frpos = AssignPtrUintptr(f+16, (*FILE)(unsafe.Pointer(f)).Fbuf+uintptr((*FILE)(unsafe.Pointer(f)).Fbuf_size)) + if (*FILE)(unsafe.Pointer(f)).Fflags&uint32(16) != 0 { + return -1 + } + return 0 +} + +func X__toread_needs_stdio_exit(tls *TLS) { /* __toread.c:16:13: */ + if __ccgo_strace { + trc("tls=%v, (%v:)", tls, origin(2)) + } + X__builtin_abort(tls) //TODO- + // __stdio_exit_needed(); +} + +// This function assumes it will never be called if there is already +// data buffered for reading. + +func X__uflow(tls *TLS, f uintptr) int32 { /* __uflow.c:6:5: */ + if __ccgo_strace { + trc("tls=%v f=%v, (%v:)", tls, f, origin(2)) + } + bp := tls.Alloc(1) + defer tls.Free(1) + + // var c uint8 at bp, 1 + + if !(X__toread(tls, f) != 0) && (*struct { + f func(*TLS, uintptr, uintptr, size_t) size_t + })(unsafe.Pointer(&struct{ uintptr }{(*FILE)(unsafe.Pointer(f)).Fread})).f(tls, f, bp, uint64(1)) == uint64(1) { + return int32(*(*uint8)(unsafe.Pointer(bp))) + } + return -1 +} + +func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */ + if __ccgo_strace { + trc("tls=%v key=%v base=%v nel=%v width=%v cmp=%v, (%v:)", tls, key, base, nel, width, cmp, origin(2)) + } + var try uintptr + var sign int32 + for nel > uint64(0) { + try = base + uintptr(width*(nel/uint64(2))) + sign = (*struct { + f func(*TLS, uintptr, uintptr) int32 + })(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try) + if sign < 0 { + nel = nel / uint64(2) + } else if sign > 0 { + base = try + uintptr(width) + nel = nel - (nel/uint64(2) + uint64(1)) + } else { + return try + } + } + return uintptr(0) +} + +func strtox(tls *TLS, s uintptr, p uintptr, prec int32) float64 { /* strtod.c:6:20: */ + bp := tls.Alloc(232) + defer tls.Free(232) + + // var f FILE at bp, 232 + + (*FILE)(unsafe.Pointer(bp)).Fbuf = AssignPtrUintptr(bp+8, s) + (*FILE)(unsafe.Pointer(bp)).Frend = UintptrFromInt32(-1) + X__shlim(tls, bp, int64(0)) + var y float64 = X__floatscan(tls, bp, prec, 1) + var cnt off_t = (*FILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*FILE)(unsafe.Pointer(bp)).Frpos)-int64((*FILE)(unsafe.Pointer(bp)).Fbuf))/1 + if p != 0 { + *(*uintptr)(unsafe.Pointer(p)) = func() uintptr { + if cnt != 0 { + return s + uintptr(cnt) + } + return s + }() + } + return y +} + +func Xstrtof(tls *TLS, s uintptr, p uintptr) float32 { /* strtod.c:17:7: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + } + return float32(strtox(tls, s, p, 0)) +} + +func Xstrtod(tls *TLS, s uintptr, p uintptr) float64 { /* strtod.c:22:8: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + } + return strtox(tls, s, p, 1) +} + +func Xstrtold(tls *TLS, s uintptr, p uintptr) float64 { /* strtod.c:27:13: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2)) + } + return strtox(tls, s, p, 2) +} + +func strtox1(tls *TLS, s uintptr, p uintptr, base int32, lim uint64) uint64 { /* strtol.c:8:27: */ + bp := tls.Alloc(232) + defer tls.Free(232) + + // var f FILE at bp, 232 + + (*FILE)(unsafe.Pointer(bp)).Fbuf = AssignPtrUintptr(bp+8, s) + (*FILE)(unsafe.Pointer(bp)).Frend = UintptrFromInt32(-1) + X__shlim(tls, bp, int64(0)) + var y uint64 = X__intscan(tls, bp, uint32(base), 1, lim) + if p != 0 { + var cnt size_t = size_t((*FILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*FILE)(unsafe.Pointer(bp)).Frpos)-int64((*FILE)(unsafe.Pointer(bp)).Fbuf))/1) + *(*uintptr)(unsafe.Pointer(p)) = s + uintptr(cnt) + } + return y +} + +func Xstrtoull(tls *TLS, s uintptr, p uintptr, base int32) uint64 { /* strtol.c:21:20: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return strtox1(tls, s, p, base, 2*uint64(0x7fffffffffffffff)+uint64(1)) +} + +func Xstrtoll(tls *TLS, s uintptr, p uintptr, base int32) int64 { /* strtol.c:26:11: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return int64(strtox1(tls, s, p, base, Uint64FromInt64(-0x7fffffffffffffff-int64(1)))) +} + +func Xstrtoul(tls *TLS, s uintptr, p uintptr, base int32) uint64 { /* strtol.c:31:15: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return uint64(strtox1(tls, s, p, base, 2*uint64(0x7fffffffffffffff)+uint64(1))) +} + +func Xstrtol(tls *TLS, s uintptr, p uintptr, base int32) int64 { /* strtol.c:36:6: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return int64(strtox1(tls, s, p, base, 0+Uint64FromInt64(Int64(-Int64(0x7fffffffffffffff))-Int64FromInt32(1)))) +} + +func Xstrtoimax(tls *TLS, s uintptr, p uintptr, base int32) intmax_t { /* strtol.c:41:10: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return intmax_t(Xstrtoll(tls, s, p, base)) +} + +func Xstrtoumax(tls *TLS, s uintptr, p uintptr, base int32) uintmax_t { /* strtol.c:46:11: */ + if __ccgo_strace { + trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2)) + } + return uintmax_t(Xstrtoull(tls, s, p, base)) +} + +// Support signed or unsigned plain-char + +// Implementation choices... + +// Arbitrary numbers... + +// POSIX/SUS requirements follow. These numbers come directly +// from SUS and have nothing to do with the host system. + +func X__strchrnul(tls *TLS, s uintptr, c int32) uintptr { /* strchrnul.c:10:6: */ + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + } + c = int32(uint8(c)) + if !(c != 0) { + return s + uintptr(Xstrlen(tls, s)) + } + var w uintptr + for ; uintptr_t(s)%uintptr_t(unsafe.Sizeof(size_t(0))) != 0; s++ { + if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) || int32(*(*uint8)(unsafe.Pointer(s))) == c { + return s + } + } + var k size_t = Uint64(Uint64FromInt32(-1)) / uint64(255) * size_t(c) + for w = s; !((*(*uint64)(unsafe.Pointer(w))-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^*(*uint64)(unsafe.Pointer(w)) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0) && !((*(*uint64)(unsafe.Pointer(w))^k-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^(*(*uint64)(unsafe.Pointer(w))^k) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0); w += 8 { + } + s = w + for ; *(*int8)(unsafe.Pointer(s)) != 0 && int32(*(*uint8)(unsafe.Pointer(s))) != c; s++ { + } + return s +} + +func Xstrdup(tls *TLS, s uintptr) uintptr { /* strdup.c:4:6: */ + if __ccgo_strace { + trc("tls=%v s=%v, (%v:)", tls, s, origin(2)) + } + var l size_t = Xstrlen(tls, s) + var d uintptr = Xmalloc(tls, l+uint64(1)) + if !(d != 0) { + return uintptr(0) + } + return Xmemcpy(tls, d, s, l+uint64(1)) +} + +func Xstrlcat(tls *TLS, d uintptr, s uintptr, n size_t) size_t { /* strlcat.c:4:8: */ + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + } + var l size_t = Xstrnlen(tls, d, n) + if l == n { + return l + Xstrlen(tls, s) + } + return l + Xstrlcpy(tls, d+uintptr(l), s, n-l) +} + +// Support signed or unsigned plain-char + +// Implementation choices... + +// Arbitrary numbers... + +// POSIX/SUS requirements follow. These numbers come directly +// from SUS and have nothing to do with the host system. + +func Xstrlcpy(tls *TLS, d uintptr, s uintptr, n size_t) size_t { /* strlcpy.c:11:8: */ + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + } + var d0 uintptr + var wd uintptr + var ws uintptr + d0 = d + + if !!(int32(PostDecUint64(&n, 1)) != 0) { + goto __1 + } + goto finish +__1: + ; + if !(uintptr_t(s)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1)) == uintptr_t(d)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1))) { + goto __2 + } +__3: + if !(uintptr_t(s)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1)) != 0 && n != 0 && AssignPtrInt8(d, *(*int8)(unsafe.Pointer(s))) != 0) { + goto __5 + } + goto __4 +__4: + n-- + s++ + d++ + goto __3 + goto __5 +__5: + ; + if !(n != 0 && *(*int8)(unsafe.Pointer(s)) != 0) { + goto __6 + } + wd = d + ws = s +__7: + if !(n >= size_t(unsafe.Sizeof(size_t(0))) && !((*(*uint64)(unsafe.Pointer(ws))-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^*(*uint64)(unsafe.Pointer(ws)) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0)) { + goto __9 + } + *(*size_t)(unsafe.Pointer(wd)) = *(*uint64)(unsafe.Pointer(ws)) + goto __8 +__8: + n = n - size_t(unsafe.Sizeof(size_t(0))) + ws += 8 + wd += 8 + goto __7 + goto __9 +__9: + ; + d = wd + s = ws +__6: + ; +__2: + ; +__10: + if !(n != 0 && AssignPtrInt8(d, *(*int8)(unsafe.Pointer(s))) != 0) { + goto __12 + } + goto __11 +__11: + n-- + s++ + d++ + goto __10 + goto __12 +__12: + ; + *(*int8)(unsafe.Pointer(d)) = int8(0) +finish: + return size_t((int64(d)-int64(d0))/1) + Xstrlen(tls, s) +} + +func Xstrncasecmp(tls *TLS, _l uintptr, _r uintptr, n size_t) int32 { /* strncasecmp.c:4:5: */ + if __ccgo_strace { + trc("tls=%v _l=%v _r=%v n=%v, (%v:)", tls, _l, _r, n, origin(2)) + } + var l uintptr = _l + var r uintptr = _r + if !(int32(PostDecUint64(&n, 1)) != 0) { + return 0 + } +__1: + if !(*(*uint8)(unsafe.Pointer(l)) != 0 && *(*uint8)(unsafe.Pointer(r)) != 0 && n != 0 && (int32(*(*uint8)(unsafe.Pointer(l))) == int32(*(*uint8)(unsafe.Pointer(r))) || Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(l)))) == Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(r)))))) { + goto __3 + } + goto __2 +__2: + l++ + r++ + n-- + goto __1 + goto __3 +__3: + ; + return Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(l)))) - Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(r)))) +} + +func X__strncasecmp_l(tls *TLS, l uintptr, r uintptr, n size_t, loc locale_t) int32 { /* strncasecmp.c:12:5: */ + if __ccgo_strace { + trc("tls=%v l=%v r=%v n=%v loc=%v, (%v:)", tls, l, r, n, loc, origin(2)) + } + return Xstrncasecmp(tls, l, r, n) +} + +func Xstrncat(tls *TLS, d uintptr, s uintptr, n size_t) uintptr { /* strncat.c:3:6: */ + if __ccgo_strace { + trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2)) + } + var a uintptr = d + d += uintptr(Xstrlen(tls, d)) + for n != 0 && *(*int8)(unsafe.Pointer(s)) != 0 { + n-- + *(*int8)(unsafe.Pointer(PostIncUintptr(&d, 1))) = *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) + } + *(*int8)(unsafe.Pointer(PostIncUintptr(&d, 1))) = int8(0) + return a +} + +func Xstrnlen(tls *TLS, s uintptr, n size_t) size_t { /* strnlen.c:3:8: */ + if __ccgo_strace { + trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2)) + } + var p uintptr = Xmemchr(tls, s, 0, n) + if p != 0 { + return uint64((int64(p) - int64(s)) / 1) + } + return n +} + +func Xstrspn(tls *TLS, s uintptr, c uintptr) size_t { /* strspn.c:6:8: */ + if __ccgo_strace { + trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2)) + } + bp := tls.Alloc(32) + defer tls.Free(32) + + var a uintptr = s + *(*[4]size_t)(unsafe.Pointer(bp /* byteset */)) = [4]size_t{0: uint64(0)} + + if !(int32(*(*int8)(unsafe.Pointer(c))) != 0) { + return uint64(0) + } + if !(int32(*(*int8)(unsafe.Pointer(c + 1))) != 0) { + for ; int32(*(*int8)(unsafe.Pointer(s))) == int32(*(*int8)(unsafe.Pointer(c))); s++ { + } + return size_t((int64(s) - int64(a)) / 1) + } + + for ; *(*int8)(unsafe.Pointer(c)) != 0 && AssignOrPtrUint64(bp+uintptr(size_t(*(*uint8)(unsafe.Pointer(c)))/(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))*8, size_t(uint64(1))<<(size_t(*(*uint8)(unsafe.Pointer(c)))%(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))) != 0; c++ { + } + for ; *(*int8)(unsafe.Pointer(s)) != 0 && *(*size_t)(unsafe.Pointer(bp + uintptr(size_t(*(*uint8)(unsafe.Pointer(s)))/(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))*8))&(size_t(uint64(1))<<(size_t(*(*uint8)(unsafe.Pointer(s)))%(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))) != 0; s++ { + } + return size_t((int64(s) - int64(a)) / 1) +} + +func Xstrtok(tls *TLS, s uintptr, sep uintptr) uintptr { /* strtok.c:3:6: */ + if __ccgo_strace { + trc("tls=%v s=%v sep=%v, (%v:)", tls, s, sep, origin(2)) + } + if !(s != 0) && !(int32(AssignUintptr(&s, _sp)) != 0) { + return uintptr(0) + } + s += uintptr(Xstrspn(tls, s, sep)) + if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) { + return AssignPtrUintptr(uintptr(unsafe.Pointer(&_sp)), uintptr(0)) + } + _sp = s + uintptr(Xstrcspn(tls, s, sep)) + if *(*int8)(unsafe.Pointer(_sp)) != 0 { + *(*int8)(unsafe.Pointer(PostIncUintptr(&_sp, 1))) = int8(0) + } else { + _sp = uintptr(0) + } + return s +} + +var _sp uintptr /* strtok.c:5:14: */ + +func init() { + *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_CurrentRuneLocale)) + 0)) = uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) // table.c:1940:35: + *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_CurrentRuneLocale)) + 0)) = uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) // table.c:1940:35: +} + +var ts1 = "infinity\x00nan\x00\x00\x00\x01\x02\x04\a\x03\x06\x05\x00.\x00%d.%d.%d.%d.in-addr.arpa\x00ip6.arpa\x000123456789abcdef\x00/etc/hosts\x00rb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00%d.%d.%d.%d\x00%x:%x:%x:%x:%x:%x:%x:%x\x00%x:%x:%x:%x:%x:%x:%d.%d.%d.%d\x00:0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00 \x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data diff --git a/internal/libc/netdb/capi_darwin_amd64.go b/internal/libc/netdb/capi_darwin_amd64.go new file mode 100644 index 0000000..a360eef --- /dev/null +++ b/internal/libc/netdb/capi_darwin_amd64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_darwin_amd64.go -pkgname netdb', DO NOT EDIT. + +package netdb + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/netdb/capi_darwin_arm64.go b/internal/libc/netdb/capi_darwin_arm64.go new file mode 100644 index 0000000..8fa61c1 --- /dev/null +++ b/internal/libc/netdb/capi_darwin_arm64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_darwin_arm64.go -pkgname netdb', DO NOT EDIT. + +package netdb + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/netdb/capi_linux_amd64.go b/internal/libc/netdb/capi_linux_amd64.go new file mode 100644 index 0000000..8be6cac --- /dev/null +++ b/internal/libc/netdb/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_amd64.go -pkgname netdb', DO NOT EDIT. + +package netdb + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/netdb/capi_linux_arm64.go b/internal/libc/netdb/capi_linux_arm64.go new file mode 100644 index 0000000..aad6e36 --- /dev/null +++ b/internal/libc/netdb/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo netdb/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_arm64.go -pkgname netdb', DO NOT EDIT. + +package netdb + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/netdb/netdb_darwin_amd64.go b/internal/libc/netdb/netdb_darwin_amd64.go new file mode 100644 index 0000000..e99c970 --- /dev/null +++ b/internal/libc/netdb/netdb_darwin_amd64.go @@ -0,0 +1,6364 @@ +// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_darwin_amd64.go -pkgname netdb', DO NOT EDIT. + +package netdb + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_APPLETALK = 16 // socket.h:375:1: + AF_CCITT = 10 // socket.h:369:1: + AF_CHAOS = 5 // socket.h:363:1: + AF_CNT = 21 // socket.h:380:1: + AF_COIP = 20 // socket.h:379:1: + AF_DATAKIT = 9 // socket.h:368:1: + AF_DECnet = 12 // socket.h:371:1: + AF_DLI = 13 // socket.h:372:1: + AF_E164 = 28 // socket.h:387:1: + AF_ECMA = 8 // socket.h:367:1: + AF_HYLINK = 15 // socket.h:374:1: + AF_IEEE80211 = 37 // socket.h:399:1: + AF_IMPLINK = 3 // socket.h:361:1: + AF_INET = 2 // socket.h:359:1: + AF_INET6 = 30 // socket.h:390:1: + AF_IPX = 23 // socket.h:382:1: + AF_ISDN = 28 // socket.h:386:1: + AF_ISO = 7 // socket.h:365:1: + AF_LAT = 14 // socket.h:373:1: + AF_LINK = 18 // socket.h:377:1: + AF_LOCAL = 1 // socket.h:357:1: + AF_MAX = 40 // socket.h:401:1: + AF_NATM = 31 // socket.h:392:1: + AF_NDRV = 27 // socket.h:385:1: + AF_NETBIOS = 33 // socket.h:394:1: + AF_NS = 6 // socket.h:364:1: + AF_OSI = 7 // socket.h:366:1: + AF_PPP = 34 // socket.h:395:1: + AF_PUP = 4 // socket.h:362:1: + AF_RESERVED_36 = 36 // socket.h:398:1: + AF_ROUTE = 17 // socket.h:376:1: + AF_SIP = 24 // socket.h:383:1: + AF_SNA = 11 // socket.h:370:1: + AF_SYSTEM = 32 // socket.h:393:1: + AF_UNIX = 1 // socket.h:355:1: + AF_UNSPEC = 0 // socket.h:354:1: + AF_UTUN = 38 // socket.h:400:1: + AI_ADDRCONFIG = 0x00000400 // netdb.h:226:1: + AI_ALL = 0x00000100 // netdb.h:222:1: + AI_CANONNAME = 0x00000002 // netdb.h:212:1: + AI_DEFAULT = 1536 // netdb.h:230:1: + AI_MASK = 5127 // netdb.h:217:1: + AI_NUMERICHOST = 0x00000004 // netdb.h:213:1: + AI_NUMERICSERV = 0x00001000 // netdb.h:214:1: + AI_PASSIVE = 0x00000001 // netdb.h:211:1: + AI_UNUSABLE = 0x10000000 // netdb.h:234:1: + AI_V4MAPPED = 0x00000800 // netdb.h:227:1: + AI_V4MAPPED_CFG = 0x00000200 // netdb.h:224:1: + BIG_ENDIAN = 4321 // endian.h:94:1: + BYTE_ORDER = 1234 // endian.h:97:1: + CONNECT_DATA_AUTHENTICATED = 0x4 // socket.h:300:1: + CONNECT_DATA_IDEMPOTENT = 0x2 // socket.h:299:1: + CONNECT_RESUME_ON_READ_WRITE = 0x1 // socket.h:298:1: + EAI_ADDRFAMILY = 1 // netdb.h:185:1: + EAI_AGAIN = 2 // netdb.h:187:1: + EAI_BADFLAGS = 3 // netdb.h:188:1: + EAI_BADHINTS = 12 // netdb.h:200:1: + EAI_FAIL = 4 // netdb.h:189:1: + EAI_FAMILY = 5 // netdb.h:190:1: + EAI_MAX = 15 // netdb.h:205:1: + EAI_MEMORY = 6 // netdb.h:191:1: + EAI_NODATA = 7 // netdb.h:193:1: + EAI_NONAME = 8 // netdb.h:195:1: + EAI_OVERFLOW = 14 // netdb.h:203:1: + EAI_PROTOCOL = 13 // netdb.h:201:1: + EAI_SERVICE = 9 // netdb.h:196:1: + EAI_SOCKTYPE = 10 // netdb.h:197:1: + EAI_SYSTEM = 11 // netdb.h:198:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + HOST_NOT_FOUND = 1 // netdb.h:174:1: + ICMP6_FILTER = 18 // in6.h:380:1: + ICMPV6CTL_ND6_ONLINKNSRFC4861 = 50 // in6.h:615:1: + INADDR_NONE = 0xffffffff // in.h:342:1: + INET6_ADDRSTRLEN = 46 // in6.h:161:1: + INET_ADDRSTRLEN = 16 // in.h:388:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + IN_CLASSA_HOST = 0x00ffffff // in.h:317:1: + IN_CLASSA_MAX = 128 // in.h:318:1: + IN_CLASSA_NET = 0xff000000 // in.h:315:1: + IN_CLASSA_NSHIFT = 24 // in.h:316:1: + IN_CLASSB_HOST = 0x0000ffff // in.h:323:1: + IN_CLASSB_MAX = 65536 // in.h:324:1: + IN_CLASSB_NET = 0xffff0000 // in.h:321:1: + IN_CLASSB_NSHIFT = 16 // in.h:322:1: + IN_CLASSC_HOST = 0x000000ff // in.h:329:1: + IN_CLASSC_NET = 0xffffff00 // in.h:327:1: + IN_CLASSC_NSHIFT = 8 // in.h:328:1: + IN_CLASSD_HOST = 0x0fffffff // in.h:334:1: + IN_CLASSD_NET = 0xf0000000 // in.h:332:1: + IN_CLASSD_NSHIFT = 28 // in.h:333:1: + IN_LOOPBACKNET = 127 // in.h:369:1: + IPCTL_ACCEPTSOURCEROUTE = 13 // in.h:649:1: + IPCTL_DEFTTL = 3 // in.h:637:1: + IPCTL_DIRECTEDBROADCAST = 9 // in.h:645:1: + IPCTL_FASTFORWARDING = 14 // in.h:650:1: + IPCTL_FORWARDING = 1 // in.h:635:1: + IPCTL_GIF_TTL = 16 // in.h:652:1: + IPCTL_INTRQDROPS = 11 // in.h:647:1: + IPCTL_INTRQMAXLEN = 10 // in.h:646:1: + IPCTL_KEEPFAITH = 15 // in.h:651:1: + IPCTL_MAXID = 17 // in.h:653:1: + IPCTL_RTEXPIRE = 5 // in.h:641:1: + IPCTL_RTMAXCACHE = 7 // in.h:643:1: + IPCTL_RTMINEXPIRE = 6 // in.h:642:1: + IPCTL_SENDREDIRECTS = 2 // in.h:636:1: + IPCTL_SOURCEROUTE = 8 // in.h:644:1: + IPCTL_STATS = 12 // in.h:648:1: + IPPORT_HIFIRSTAUTO = 49152 // in.h:286:1: + IPPORT_HILASTAUTO = 65535 // in.h:287:1: + IPPORT_RESERVED = 1024 // in.h:279:1: + IPPORT_RESERVEDSTART = 600 // in.h:295:1: + IPPORT_USERRESERVED = 5000 // in.h:281:1: + IPPROTO_3PC = 34 // in.h:139:1: + IPPROTO_ADFS = 68 // in.h:173:1: + IPPROTO_AH = 51 // in.h:158:1: + IPPROTO_AHIP = 61 // in.h:166:1: + IPPROTO_APES = 99 // in.h:204:1: + IPPROTO_ARGUS = 13 // in.h:116:1: + IPPROTO_AX25 = 93 // in.h:198:1: + IPPROTO_BHA = 49 // in.h:156:1: + IPPROTO_BLT = 30 // in.h:135:1: + IPPROTO_BRSATMON = 76 // in.h:181:1: + IPPROTO_CFTP = 62 // in.h:167:1: + IPPROTO_CHAOS = 16 // in.h:119:1: + IPPROTO_CMTP = 38 // in.h:143:1: + IPPROTO_CPHB = 73 // in.h:178:1: + IPPROTO_CPNX = 72 // in.h:177:1: + IPPROTO_DDP = 37 // in.h:142:1: + IPPROTO_DGP = 86 // in.h:191:1: + IPPROTO_DIVERT = 254 // in.h:213:1: + IPPROTO_DONE = 257 // in.h:221:1: + IPPROTO_DSTOPTS = 60 // in.h:165:1: + IPPROTO_EGP = 8 // in.h:111:1: + IPPROTO_EMCON = 14 // in.h:117:1: + IPPROTO_ENCAP = 98 // in.h:203:1: + IPPROTO_EON = 80 // in.h:185:1: + IPPROTO_ESP = 50 // in.h:157:1: + IPPROTO_ETHERIP = 97 // in.h:202:1: + IPPROTO_FRAGMENT = 44 // in.h:151:1: + IPPROTO_GGP = 3 // in.h:104:1: + IPPROTO_GMTP = 100 // in.h:205:1: + IPPROTO_GRE = 47 // in.h:154:1: + IPPROTO_HELLO = 63 // in.h:168:1: + IPPROTO_HMP = 20 // in.h:125:1: + IPPROTO_HOPOPTS = 0 // in.h:99:1: + IPPROTO_ICMP = 1 // in.h:101:1: + IPPROTO_ICMPV6 = 58 // in.h:163:1: + IPPROTO_IDP = 22 // in.h:127:1: + IPPROTO_IDPR = 35 // in.h:140:1: + IPPROTO_IDRP = 45 // in.h:152:1: + IPPROTO_IGMP = 2 // in.h:103:1: + IPPROTO_IGP = 85 // in.h:190:1: + IPPROTO_IGRP = 88 // in.h:193:1: + IPPROTO_IL = 40 // in.h:145:1: + IPPROTO_INLSP = 52 // in.h:159:1: + IPPROTO_INP = 32 // in.h:137:1: + IPPROTO_IP = 0 // in.h:97:1: + IPPROTO_IPCOMP = 108 // in.h:208:1: + IPPROTO_IPCV = 71 // in.h:176:1: + IPPROTO_IPEIP = 94 // in.h:199:1: + IPPROTO_IPIP = 4 // in.h:106:1: + IPPROTO_IPPC = 67 // in.h:172:1: + IPPROTO_IPV4 = 4 // in.h:105:1: + IPPROTO_IPV6 = 41 // in.h:147:1: + IPPROTO_IRTP = 28 // in.h:133:1: + IPPROTO_KRYPTOLAN = 65 // in.h:170:1: + IPPROTO_LARP = 91 // in.h:196:1: + IPPROTO_LEAF1 = 25 // in.h:130:1: + IPPROTO_LEAF2 = 26 // in.h:131:1: + IPPROTO_MAX = 256 // in.h:218:1: + IPPROTO_MAXID = 52 // in.h:629:1: + IPPROTO_MEAS = 19 // in.h:124:1: + IPPROTO_MHRP = 48 // in.h:155:1: + IPPROTO_MICP = 95 // in.h:200:1: + IPPROTO_MTP = 92 // in.h:197:1: + IPPROTO_MUX = 18 // in.h:123:1: + IPPROTO_ND = 77 // in.h:182:1: + IPPROTO_NHRP = 54 // in.h:161:1: + IPPROTO_NONE = 59 // in.h:164:1: + IPPROTO_NSP = 31 // in.h:136:1: + IPPROTO_NVPII = 11 // in.h:114:1: + IPPROTO_OSPFIGP = 89 // in.h:194:1: + IPPROTO_PGM = 113 // in.h:209:1: + IPPROTO_PIGP = 9 // in.h:112:1: + IPPROTO_PIM = 103 // in.h:207:1: + IPPROTO_PRM = 21 // in.h:126:1: + IPPROTO_PUP = 12 // in.h:115:1: + IPPROTO_PVP = 75 // in.h:180:1: + IPPROTO_RAW = 255 // in.h:215:1: + IPPROTO_RCCMON = 10 // in.h:113:1: + IPPROTO_RDP = 27 // in.h:132:1: + IPPROTO_ROUTING = 43 // in.h:150:1: + IPPROTO_RSVP = 46 // in.h:153:1: + IPPROTO_RVD = 66 // in.h:171:1: + IPPROTO_SATEXPAK = 64 // in.h:169:1: + IPPROTO_SATMON = 69 // in.h:174:1: + IPPROTO_SCCSP = 96 // in.h:201:1: + IPPROTO_SCTP = 132 // in.h:210:1: + IPPROTO_SDRP = 42 // in.h:149:1: + IPPROTO_SEP = 33 // in.h:138:1: + IPPROTO_SRPC = 90 // in.h:195:1: + IPPROTO_ST = 7 // in.h:110:1: + IPPROTO_SVMTP = 82 // in.h:187:1: + IPPROTO_SWIPE = 53 // in.h:160:1: + IPPROTO_TCF = 87 // in.h:192:1: + IPPROTO_TCP = 6 // in.h:108:1: + IPPROTO_TP = 29 // in.h:134:1: + IPPROTO_TPXX = 39 // in.h:144:1: + IPPROTO_TRUNK1 = 23 // in.h:128:1: + IPPROTO_TRUNK2 = 24 // in.h:129:1: + IPPROTO_TTP = 84 // in.h:189:1: + IPPROTO_UDP = 17 // in.h:121:1: + IPPROTO_VINES = 83 // in.h:188:1: + IPPROTO_VISA = 70 // in.h:175:1: + IPPROTO_VMTP = 81 // in.h:186:1: + IPPROTO_WBEXPAK = 79 // in.h:184:1: + IPPROTO_WBMON = 78 // in.h:183:1: + IPPROTO_WSN = 74 // in.h:179:1: + IPPROTO_XNET = 15 // in.h:118:1: + IPPROTO_XTP = 36 // in.h:141:1: + IPV6CTL_ACCEPT_RTADV = 12 // in6.h:580:1: + IPV6CTL_ADDRCTLPOLICY = 38 // in6.h:605:1: + IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:585:1: + IPV6CTL_AUTO_LINKLOCAL = 35 // in6.h:602:1: + IPV6CTL_DAD_COUNT = 16 // in6.h:584:1: + IPV6CTL_DEFHLIM = 3 // in6.h:569:1: + IPV6CTL_DEFMCASTHLIM = 18 // in6.h:586:1: + IPV6CTL_FORWARDING = 1 // in6.h:567:1: + IPV6CTL_FORWSRCRT = 5 // in6.h:573:1: + IPV6CTL_GIF_HLIM = 19 // in6.h:587:1: + IPV6CTL_HDRNESTLIMIT = 15 // in6.h:583:1: + IPV6CTL_KAME_VERSION = 20 // in6.h:588:1: + IPV6CTL_KEEPFAITH = 13 // in6.h:581:1: + IPV6CTL_LOG_INTERVAL = 14 // in6.h:582:1: + IPV6CTL_MAXDYNROUTES = 49 // in6.h:614:1: + IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:577:1: + IPV6CTL_MAXFRAGS = 41 // in6.h:608:1: + IPV6CTL_MAXID = 51 // in6.h:619:1: + IPV6CTL_MAXIFDEFROUTERS = 48 // in6.h:613:1: + IPV6CTL_MAXIFPREFIXES = 47 // in6.h:612:1: + IPV6CTL_MCAST_PMTU = 44 // in6.h:609:1: + IPV6CTL_MRTPROTO = 8 // in6.h:576:1: + IPV6CTL_MRTSTATS = 7 // in6.h:575:1: + IPV6CTL_NEIGHBORGCTHRESH = 46 // in6.h:611:1: + IPV6CTL_PREFER_TEMPADDR = 37 // in6.h:604:1: + IPV6CTL_RIP6STATS = 36 // in6.h:603:1: + IPV6CTL_RR_PRUNE = 22 // in6.h:590:1: + IPV6CTL_RTEXPIRE = 25 // in6.h:595:1: + IPV6CTL_RTMAXCACHE = 27 // in6.h:597:1: + IPV6CTL_RTMINEXPIRE = 26 // in6.h:596:1: + IPV6CTL_SENDREDIRECTS = 2 // in6.h:568:1: + IPV6CTL_SOURCECHECK = 10 // in6.h:578:1: + IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:579:1: + IPV6CTL_STATS = 6 // in6.h:574:1: + IPV6CTL_TEMPPLTIME = 33 // in6.h:600:1: + IPV6CTL_TEMPVLTIME = 34 // in6.h:601:1: + IPV6CTL_USETEMPADDR = 32 // in6.h:599:1: + IPV6CTL_USE_DEFAULTZONE = 39 // in6.h:606:1: + IPV6CTL_USE_DEPRECATED = 21 // in6.h:589:1: + IPV6CTL_V6ONLY = 24 // in6.h:594:1: + IPV6PORT_ANONMAX = 65535 // in6.h:143:1: + IPV6PORT_ANONMIN = 49152 // in6.h:142:1: + IPV6PORT_RESERVED = 1024 // in6.h:141:1: + IPV6PORT_RESERVEDMAX = 1023 // in6.h:145:1: + IPV6PORT_RESERVEDMIN = 600 // in6.h:144:1: + IPV6PROTO_MAXID = 104 // in6.h:562:1: + IPV6_2292DSTOPTS = 23 // in6.h:385:1: + IPV6_2292HOPLIMIT = 20 // in6.h:382:1: + IPV6_2292HOPOPTS = 22 // in6.h:384:1: + IPV6_2292NEXTHOP = 21 // in6.h:383:1: + IPV6_2292PKTINFO = 19 // in6.h:381:1: + IPV6_2292PKTOPTIONS = 25 // in6.h:389:1: + IPV6_2292RTHDR = 24 // in6.h:386:1: + IPV6_BINDV6ONLY = 27 // in6.h:405:1: + IPV6_BOUND_IF = 125 // in6.h:494:1: + IPV6_CHECKSUM = 26 // in6.h:401:1: + IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:506:1: + IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:507:1: + IPV6_FAITH = 29 // in6.h:411:1: + IPV6_FW_ADD = 30 // in6.h:414:1: + IPV6_FW_DEL = 31 // in6.h:415:1: + IPV6_FW_FLUSH = 32 // in6.h:416:1: + IPV6_FW_GET = 34 // in6.h:418:1: + IPV6_FW_ZERO = 33 // in6.h:417:1: + IPV6_IPSEC_POLICY = 28 // in6.h:409:1: + IPV6_JOIN_GROUP = 12 // in6.h:375:1: + IPV6_LEAVE_GROUP = 13 // in6.h:376:1: + IPV6_MAX_GROUP_SRC_FILTER = 512 // in6.h:521:1: + IPV6_MAX_MEMBERSHIPS = 4095 // in6.h:515:1: + IPV6_MAX_SOCK_SRC_FILTER = 128 // in6.h:522:1: + IPV6_MIN_MEMBERSHIPS = 31 // in6.h:514:1: + IPV6_MULTICAST_HOPS = 10 // in6.h:373:1: + IPV6_MULTICAST_IF = 9 // in6.h:372:1: + IPV6_MULTICAST_LOOP = 11 // in6.h:374:1: + IPV6_PORTRANGE = 14 // in6.h:379:1: + IPV6_PORTRANGE_DEFAULT = 0 // in6.h:552:1: + IPV6_PORTRANGE_HIGH = 1 // in6.h:553:1: + IPV6_PORTRANGE_LOW = 2 // in6.h:554:1: + IPV6_RECVTCLASS = 35 // in6.h:426:1: + IPV6_RTHDR_LOOSE = 0 // in6.h:499:1: + IPV6_RTHDR_STRICT = 1 // in6.h:500:1: + IPV6_RTHDR_TYPE_0 = 0 // in6.h:501:1: + IPV6_SOCKOPT_RESERVED1 = 3 // in6.h:369:1: + IPV6_TCLASS = 36 // in6.h:427:1: + IPV6_UNICAST_HOPS = 4 // in6.h:371:1: + IPV6_V6ONLY = 27 // in6.h:403:1: + IP_ADD_MEMBERSHIP = 12 // in.h:418:1: + IP_ADD_SOURCE_MEMBERSHIP = 70 // in.h:464:1: + IP_BLOCK_SOURCE = 72 // in.h:466:1: + IP_BOUND_IF = 25 // in.h:434:1: + IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:485:1: + IP_DEFAULT_MULTICAST_TTL = 1 // in.h:484:1: + IP_DROP_MEMBERSHIP = 13 // in.h:419:1: + IP_DROP_SOURCE_MEMBERSHIP = 71 // in.h:465:1: + IP_DUMMYNET_CONFIGURE = 60 // in.h:455:1: + IP_DUMMYNET_DEL = 61 // in.h:456:1: + IP_DUMMYNET_FLUSH = 62 // in.h:457:1: + IP_DUMMYNET_GET = 64 // in.h:458:1: + IP_FAITH = 22 // in.h:429:1: + IP_FW_ADD = 40 // in.h:439:1: + IP_FW_DEL = 41 // in.h:440:1: + IP_FW_FLUSH = 42 // in.h:441:1: + IP_FW_GET = 44 // in.h:443:1: + IP_FW_RESETLOG = 45 // in.h:444:1: + IP_FW_ZERO = 43 // in.h:442:1: + IP_HDRINCL = 2 // in.h:408:1: + IP_IPSEC_POLICY = 21 // in.h:428:1: + IP_MAX_GROUP_SRC_FILTER = 512 // in.h:499:1: + IP_MAX_MEMBERSHIPS = 4095 // in.h:493:1: + IP_MAX_SOCK_MUTE_FILTER = 128 // in.h:501:1: + IP_MAX_SOCK_SRC_FILTER = 128 // in.h:500:1: + IP_MIN_MEMBERSHIPS = 31 // in.h:492:1: + IP_MSFILTER = 74 // in.h:470:1: + IP_MULTICAST_IF = 9 // in.h:415:1: + IP_MULTICAST_IFINDEX = 66 // in.h:461:1: + IP_MULTICAST_LOOP = 11 // in.h:417:1: + IP_MULTICAST_TTL = 10 // in.h:416:1: + IP_MULTICAST_VIF = 14 // in.h:420:1: + IP_NAT__XXX = 55 // in.h:452:1: + IP_OLD_FW_ADD = 50 // in.h:447:1: + IP_OLD_FW_DEL = 51 // in.h:448:1: + IP_OLD_FW_FLUSH = 52 // in.h:449:1: + IP_OLD_FW_GET = 54 // in.h:451:1: + IP_OLD_FW_RESETLOG = 56 // in.h:453:1: + IP_OLD_FW_ZERO = 53 // in.h:450:1: + IP_OPTIONS = 1 // in.h:407:1: + IP_PKTINFO = 26 // in.h:435:1: + IP_PORTRANGE = 19 // in.h:425:1: + IP_PORTRANGE_DEFAULT = 0 // in.h:593:1: + IP_PORTRANGE_HIGH = 1 // in.h:594:1: + IP_PORTRANGE_LOW = 2 // in.h:595:1: + IP_RECVDSTADDR = 7 // in.h:413:1: + IP_RECVIF = 20 // in.h:426:1: + IP_RECVOPTS = 5 // in.h:411:1: + IP_RECVPKTINFO = 26 // in.h:436:1: + IP_RECVRETOPTS = 6 // in.h:412:1: + IP_RECVTOS = 27 // in.h:437:1: + IP_RECVTTL = 24 // in.h:433:1: + IP_RETOPTS = 8 // in.h:414:1: + IP_RSVP_OFF = 16 // in.h:422:1: + IP_RSVP_ON = 15 // in.h:421:1: + IP_RSVP_VIF_OFF = 18 // in.h:424:1: + IP_RSVP_VIF_ON = 17 // in.h:423:1: + IP_STRIPHDR = 23 // in.h:431:1: + IP_TOS = 3 // in.h:409:1: + IP_TRAFFIC_MGT_BACKGROUND = 65 // in.h:460:1: + IP_TTL = 4 // in.h:410:1: + IP_UNBLOCK_SOURCE = 73 // in.h:467:1: + KEV_DL_ADDMULTI = 7 // net_kev.h:61:1: + KEV_DL_AWDL_RESTRICTED = 26 // net_kev.h:80:1: + KEV_DL_AWDL_UNRESTRICTED = 27 // net_kev.h:81:1: + KEV_DL_DELMULTI = 8 // net_kev.h:62:1: + KEV_DL_IFCAP_CHANGED = 19 // net_kev.h:73:1: + KEV_DL_IFDELEGATE_CHANGED = 25 // net_kev.h:79:1: + KEV_DL_IF_ATTACHED = 9 // net_kev.h:63:1: + KEV_DL_IF_DETACHED = 11 // net_kev.h:65:1: + KEV_DL_IF_DETACHING = 10 // net_kev.h:64:1: + KEV_DL_IF_IDLE_ROUTE_REFCNT = 18 // net_kev.h:72:1: + KEV_DL_ISSUES = 24 // net_kev.h:78:1: + KEV_DL_LINK_ADDRESS_CHANGED = 16 // net_kev.h:70:1: + KEV_DL_LINK_OFF = 12 // net_kev.h:66:1: + KEV_DL_LINK_ON = 13 // net_kev.h:67:1: + KEV_DL_LINK_QUALITY_METRIC_CHANGED = 20 // net_kev.h:74:1: + KEV_DL_LOW_POWER_MODE_CHANGED = 30 // net_kev.h:84:1: + KEV_DL_MASTER_ELECTED = 23 // net_kev.h:77:1: + KEV_DL_NODE_ABSENCE = 22 // net_kev.h:76:1: + KEV_DL_NODE_PRESENCE = 21 // net_kev.h:75:1: + KEV_DL_PROTO_ATTACHED = 14 // net_kev.h:68:1: + KEV_DL_PROTO_DETACHED = 15 // net_kev.h:69:1: + KEV_DL_QOS_MODE_CHANGED = 29 // net_kev.h:83:1: + KEV_DL_RRC_STATE_CHANGED = 28 // net_kev.h:82:1: + KEV_DL_SIFFLAGS = 1 // net_kev.h:55:1: + KEV_DL_SIFGENERIC = 6 // net_kev.h:60:1: + KEV_DL_SIFMEDIA = 5 // net_kev.h:59:1: + KEV_DL_SIFMETRICS = 2 // net_kev.h:56:1: + KEV_DL_SIFMTU = 3 // net_kev.h:57:1: + KEV_DL_SIFPHYS = 4 // net_kev.h:58:1: + KEV_DL_SUBCLASS = 2 // net_kev.h:50:1: + KEV_DL_WAKEFLAGS_CHANGED = 17 // net_kev.h:71:1: + KEV_INET6_ADDR_DELETED = 3 // net_kev.h:91:1: + KEV_INET6_CHANGED_ADDR = 2 // net_kev.h:90:1: + KEV_INET6_DEFROUTER = 6 // net_kev.h:94:1: + KEV_INET6_NEW_LL_ADDR = 4 // net_kev.h:92:1: + KEV_INET6_NEW_RTADV_ADDR = 5 // net_kev.h:93:1: + KEV_INET6_NEW_USER_ADDR = 1 // net_kev.h:89:1: + KEV_INET6_REQUEST_NAT64_PREFIX = 7 // net_kev.h:95:1: + KEV_INET6_SUBCLASS = 6 // net_kev.h:87:1: + KEV_INET_ADDR_DELETED = 3 // net_kev.h:39:1: + KEV_INET_ARPCOLLISION = 7 // net_kev.h:43:1: + KEV_INET_ARPRTRALIVE = 10 // net_kev.h:48:1: + KEV_INET_ARPRTRFAILURE = 9 // net_kev.h:47:1: + KEV_INET_CHANGED_ADDR = 2 // net_kev.h:38:1: + KEV_INET_NEW_ADDR = 1 // net_kev.h:37:1: + KEV_INET_PORTINUSE = 8 // net_kev.h:45:1: + KEV_INET_SIFBRDADDR = 5 // net_kev.h:41:1: + KEV_INET_SIFDSTADDR = 4 // net_kev.h:40:1: + KEV_INET_SIFNETMASK = 6 // net_kev.h:42:1: + KEV_INET_SUBCLASS = 1 // net_kev.h:35:1: + LITTLE_ENDIAN = 1234 // endian.h:93:1: + MCAST_BLOCK_SOURCE = 84 // in.h:477:1: + MCAST_EXCLUDE = 2 // in.h:587:1: + MCAST_INCLUDE = 1 // in.h:586:1: + MCAST_JOIN_GROUP = 80 // in.h:473:1: + MCAST_JOIN_SOURCE_GROUP = 82 // in.h:475:1: + MCAST_LEAVE_GROUP = 81 // in.h:474:1: + MCAST_LEAVE_SOURCE_GROUP = 83 // in.h:476:1: + MCAST_UNBLOCK_SOURCE = 85 // in.h:478:1: + MCAST_UNDEFINED = 0 // in.h:585:1: + MSG_CTRUNC = 0x20 // socket.h:563:1: + MSG_DONTROUTE = 0x4 // socket.h:560:1: + MSG_DONTWAIT = 0x80 // socket.h:566:1: + MSG_EOF = 0x100 // socket.h:567:1: + MSG_EOR = 0x8 // socket.h:561:1: + MSG_FLUSH = 0x400 // socket.h:572:1: + MSG_HAVEMORE = 0x2000 // socket.h:575:1: + MSG_HOLD = 0x800 // socket.h:573:1: + MSG_NEEDSA = 0x10000 // socket.h:578:1: + MSG_OOB = 0x1 // socket.h:558:1: + MSG_PEEK = 0x2 // socket.h:559:1: + MSG_RCVMORE = 0x4000 // socket.h:576:1: + MSG_SEND = 0x1000 // socket.h:574:1: + MSG_TRUNC = 0x10 // socket.h:562:1: + MSG_WAITALL = 0x40 // socket.h:564:1: + MSG_WAITSTREAM = 0x200 // socket.h:570:1: + NBBY = 8 // types.h:186:1: + NETDB_INTERNAL = -1 // netdb.h:171:1: + NETDB_SUCCESS = 0 // netdb.h:172:1: + NETSVC_MRKNG_LVL_L2 = 1 // socket.h:283:1: + NETSVC_MRKNG_LVL_L3L2_ALL = 2 // socket.h:284:1: + NETSVC_MRKNG_LVL_L3L2_BK = 3 // socket.h:285:1: + NETSVC_MRKNG_UNKNOWN = 0 // socket.h:282:1: + NET_MAXID = 40 // socket.h:506:1: + NET_RT_DUMP = 1 // socket.h:519:1: + NET_RT_DUMP2 = 7 // socket.h:525:1: + NET_RT_FLAGS = 2 // socket.h:520:1: + NET_RT_FLAGS_PRIV = 10 // socket.h:530:1: + NET_RT_IFLIST = 3 // socket.h:521:1: + NET_RT_IFLIST2 = 6 // socket.h:524:1: + NET_RT_MAXID = 11 // socket.h:531:1: + NET_RT_STAT = 4 // socket.h:522:1: + NET_RT_TRASH = 5 // socket.h:523:1: + NET_SERVICE_TYPE_AV = 6 // socket.h:276:1: + NET_SERVICE_TYPE_BE = 0 // socket.h:270:1: + NET_SERVICE_TYPE_BK = 1 // socket.h:271:1: + NET_SERVICE_TYPE_OAM = 7 // socket.h:277:1: + NET_SERVICE_TYPE_RD = 8 // socket.h:278:1: + NET_SERVICE_TYPE_RV = 5 // socket.h:275:1: + NET_SERVICE_TYPE_SIG = 2 // socket.h:272:1: + NET_SERVICE_TYPE_VI = 3 // socket.h:273:1: + NET_SERVICE_TYPE_VO = 4 // socket.h:274:1: + NI_DGRAM = 0x00000010 // netdb.h:252:1: + NI_MAXHOST = 1025 // netdb.h:241:1: + NI_MAXSERV = 32 // netdb.h:242:1: + NI_NAMEREQD = 0x00000004 // netdb.h:249:1: + NI_NOFQDN = 0x00000001 // netdb.h:247:1: + NI_NUMERICHOST = 0x00000002 // netdb.h:248:1: + NI_NUMERICSCOPE = 0x00000100 // netdb.h:251:1: + NI_NUMERICSERV = 0x00000008 // netdb.h:250:1: + NI_WITHSCOPEID = 0x00000020 // netdb.h:254:1: + NO_ADDRESS = 4 // netdb.h:179:1: + NO_DATA = 4 // netdb.h:177:1: + NO_RECOVERY = 3 // netdb.h:176:1: + PDP_ENDIAN = 3412 // endian.h:95:1: + PF_APPLETALK = 16 // socket.h:469:1: + PF_CCITT = 10 // socket.h:463:1: + PF_CHAOS = 5 // socket.h:457:1: + PF_CNT = 21 // socket.h:474:1: + PF_COIP = 20 // socket.h:473:1: + PF_DATAKIT = 9 // socket.h:462:1: + PF_DECnet = 12 // socket.h:465:1: + PF_DLI = 13 // socket.h:466:1: + PF_ECMA = 8 // socket.h:461:1: + PF_HYLINK = 15 // socket.h:468:1: + PF_IMPLINK = 3 // socket.h:455:1: + PF_INET = 2 // socket.h:454:1: + PF_INET6 = 30 // socket.h:482:1: + PF_IPX = 23 // socket.h:476:1: + PF_ISDN = 28 // socket.h:480:1: + PF_ISO = 7 // socket.h:459:1: + PF_KEY = 29 // socket.h:481:1: + PF_LAT = 14 // socket.h:467:1: + PF_LINK = 18 // socket.h:471:1: + PF_LOCAL = 1 // socket.h:452:1: + PF_MAX = 40 // socket.h:489:1: + PF_NATM = 31 // socket.h:483:1: + PF_NDRV = 27 // socket.h:479:1: + PF_NETBIOS = 33 // socket.h:485:1: + PF_NS = 6 // socket.h:458:1: + PF_OSI = 7 // socket.h:460:1: + PF_PIP = 25 // socket.h:478:1: + PF_PPP = 34 // socket.h:486:1: + PF_PUP = 4 // socket.h:456:1: + PF_RESERVED_36 = 36 // socket.h:487:1: + PF_ROUTE = 17 // socket.h:470:1: + PF_RTIP = 22 // socket.h:477:1: + PF_SIP = 24 // socket.h:475:1: + PF_SNA = 11 // socket.h:464:1: + PF_SYSTEM = 32 // socket.h:484:1: + PF_UNIX = 1 // socket.h:453:1: + PF_UNSPEC = 0 // socket.h:451:1: + PF_UTUN = 38 // socket.h:488:1: + PF_XTP = 19 // socket.h:472:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + RSIZE_MAX = 9223372036854775807 // stdint.h:658:1: + SAE_ASSOCID_ANY = 0 // socket.h:290:1: + SAE_CONNID_ANY = 0 // socket.h:294:1: + SCM_CREDS = 0x03 // socket.h:661:1: + SCM_RIGHTS = 0x01 // socket.h:658:1: + SCM_TIMESTAMP = 0x02 // socket.h:660:1: + SCM_TIMESTAMP_MONOTONIC = 0x04 // socket.h:662:1: + SCOPE_DELIMITER = 37 // netdb.h:259:1: + SHUT_RD = 0 // socket.h:670:1: + SHUT_RDWR = 2 // socket.h:672:1: + SHUT_WR = 1 // socket.h:671:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIN6_LEN = 0 // in6.h:167:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + SOCK_DGRAM = 2 // socket.h:112:1: + SOCK_MAXADDRLEN = 255 // socket.h:414:1: + SOCK_RAW = 3 // socket.h:113:1: + SOCK_RDM = 4 // socket.h:115:1: + SOCK_SEQPACKET = 5 // socket.h:117:1: + SOCK_STREAM = 1 // socket.h:111:1: + SOL_SOCKET = 0xffff // socket.h:348:1: + SOMAXCONN = 128 // socket.h:540:1: + SONPX_SETOPTSHUT = 0x000000001 // socket.h:338:1: + SO_ACCEPTCONN = 0x0002 // socket.h:123:1: + SO_BROADCAST = 0x0020 // socket.h:127:1: + SO_DEBUG = 0x0001 // socket.h:122:1: + SO_DONTROUTE = 0x0010 // socket.h:126:1: + SO_DONTTRUNC = 0x2000 // socket.h:142:1: + SO_ERROR = 0x1007 // socket.h:160:1: + SO_KEEPALIVE = 0x0008 // socket.h:125:1: + SO_LABEL = 0x1010 // socket.h:163:1: + SO_LINGER = 0x0080 // socket.h:130:1: + SO_LINGER_SEC = 0x1080 // socket.h:176:1: + SO_NETSVC_MARKING_LEVEL = 0x1119 // socket.h:185:1: + SO_NET_SERVICE_TYPE = 0x1116 // socket.h:182:1: + SO_NKE = 0x1021 // socket.h:167:1: + SO_NOADDRERR = 0x1023 // socket.h:169:1: + SO_NOSIGPIPE = 0x1022 // socket.h:168:1: + SO_NOTIFYCONFLICT = 0x1026 // socket.h:173:1: + SO_NP_EXTENSIONS = 0x1083 // socket.h:178:1: + SO_NREAD = 0x1020 // socket.h:166:1: + SO_NUMRCVPKT = 0x1112 // socket.h:181:1: + SO_NWRITE = 0x1024 // socket.h:170:1: + SO_OOBINLINE = 0x0100 // socket.h:134:1: + SO_PEERLABEL = 0x1011 // socket.h:164:1: + SO_RANDOMPORT = 0x1082 // socket.h:177:1: + SO_RCVBUF = 0x1002 // socket.h:155:1: + SO_RCVLOWAT = 0x1004 // socket.h:157:1: + SO_RCVTIMEO = 0x1006 // socket.h:159:1: + SO_REUSEADDR = 0x0004 // socket.h:124:1: + SO_REUSEPORT = 0x0200 // socket.h:136:1: + SO_REUSESHAREUID = 0x1025 // socket.h:171:1: + SO_SNDBUF = 0x1001 // socket.h:154:1: + SO_SNDLOWAT = 0x1003 // socket.h:156:1: + SO_SNDTIMEO = 0x1005 // socket.h:158:1: + SO_TIMESTAMP = 0x0400 // socket.h:137:1: + SO_TIMESTAMP_MONOTONIC = 0x0800 // socket.h:138:1: + SO_TYPE = 0x1008 // socket.h:161:1: + SO_UPCALLCLOSEWAIT = 0x1027 // socket.h:174:1: + SO_USELOOPBACK = 0x0040 // socket.h:129:1: + SO_WANTMORE = 0x4000 // socket.h:144:1: + SO_WANTOOBFLAG = 0x8000 // socket.h:145:1: + TRY_AGAIN = 2 // netdb.h:175:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_I386__ENDIAN_H_ = 0 // endian.h:67:1: + X_I386__PARAM_H_ = 0 // _param.h:30:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NETDB_H_ = 0 // netdb.h:84:1: + X_NETINET6_IN6_H_ = 0 // in6.h:99:1: + X_NETINET_IN_H_ = 0 // in.h:65:1: + X_NET_NETKEV_H_ = 0 // net_kev.h:30:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS__OSBYTEORDERI386_H = 0 // _OSByteOrder.h:30:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:94:1: + X_PATH_HOSTS = "/etc/hosts" // netdb.h:96:1: + X_PATH_NETWORKS = "/etc/networks" // netdb.h:97:1: + X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:98:1: + X_PATH_SERVICES = "/etc/services" // netdb.h:99:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:78:1: + X_QUAD_LOWWORD = 0 // endian.h:79:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SA_FAMILY_T = 0 // _sa_family_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SOCKLEN_T = 0 // _socklen_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SS_MAXSIZE = 128 // socket.h:429:1: + X_STRUCT_IOVEC = 0 // _iovec_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_SOCKET_H_ = 0 // socket.h:73:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: + Pseudo_AF_HDRCMPLT = 35 // socket.h:396:1: + Pseudo_AF_KEY = 29 // socket.h:388:1: + Pseudo_AF_PIP = 25 // socket.h:384:1: + Pseudo_AF_RTIP = 22 // socket.h:381:1: + Pseudo_AF_XTP = 19 // socket.h:378:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// ++Copyright++ 1980, 1983, 1988, 1993 +// - +// Copyright (c) 1980, 1983, 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. +// +// - +// Portions Copyright (c) 1993 by Digital Equipment Corporation. +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies, and that +// the name of Digital Equipment Corporation not be used in advertising or +// publicity pertaining to distribution of the document or software without +// specific, written prior permission. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL +// WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT +// CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +// DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +// PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +// ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +// SOFTWARE. +// - +// --Copyright-- + +// @(#)netdb.h 8.1 (Berkeley) 6/2/93 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type Socklen_t = X__darwin_socklen_t /* _socklen_t.h:31:33 */ +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// C99 7.18.4 Macros for minimum-width integer constants. +// +// The standard requires that integer constant macros be defined for all the +// minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width +// types are required, the corresponding integer constant macros are defined +// here. This implementation also defines minimum-width types for every other +// integer width that the target implements, so corresponding macros are +// defined below, too. +// +// These macros are defined using the same successive-shrinking approach as +// the type definitions above. It is likewise important that macros are defined +// in order of decending width. +// +// Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// C99 7.18.2.1 Limits of exact-width integer types. +// C99 7.18.2.2 Limits of minimum-width integer types. +// C99 7.18.2.3 Limits of fastest minimum-width integer types. +// +// The presence of limit macros are completely optional in C99. This +// implementation defines limits for all of the types (exact- and +// minimum-width) that it defines above, using the limits of the minimum-width +// type for any types that do not have exact-width representations. +// +// As in the type definitions, this section takes an approach of +// successive-shrinking to determine which limits to use for the standard (8, +// 16, 32, 64) bit widths when they don't have exact representations. It is +// therefore important that the definitions be kept in order of decending +// widths. +// +// Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// Some utility macros + +// C99 7.18.2.4 Limits of integer types capable of holding object pointers. +// C99 7.18.3 Limits of other integer types. + +// ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ +// is enabled. + +// C99 7.18.2.5 Limits of greatest-width integer types. + +// C99 7.18.3 Limits of other integer types. + +// 7.18.4.2 Macros for greatest-width integer constants. + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 +// $FreeBSD: src/sys/netinet/in.h,v 1.48.2.2 2001/04/21 14:53:06 ume Exp $ + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +//===---- stdint.h - Standard header for sized integer types --------------===* * +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// \*===----------------------------------------------------------------------=== + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2008 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Round p (pointer or byte index) up to a correctly-aligned value for all +// data types (int, long, ...). The result is unsigned int and must be +// cast to any desired pointer type. + +// Copyright (c) 2016-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Kernel event subclass identifiers for KEV_NETWORK_CLASS +// KEV_INET_SUBCLASS event codes + +// Define Data-Link event subclass, and associated +// events. + +// KEV_INET6_SUBCLASS event codes + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Definitions related to sockets: types, address families, options. + +// Data types. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Sa_family_t = X__uint8_t /* _sa_family_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The iovec structure shall be defined as described in . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* _iovec_t.h:31:1 */ + +// Types + +// Option flags per-socket. +// (ATOMIC proto) + +// Additional options, not kept in so_options. + +// Network Service Type for option SO_NET_SERVICE_TYPE +// +// The vast majority of sockets should use Best Effort that is the default +// Network Service Type. Other Network Service Types have to be used only if +// the traffic actually matches the description of the Network Service Type. +// +// Network Service Types do not represent priorities but rather describe +// different categories of delay, jitter and loss parameters. +// Those parameters may influence protocols from layer 4 protocols like TCP +// to layer 2 protocols like Wi-Fi. The Network Service Type can determine +// how the traffic is queued and scheduled by the host networking stack and +// by other entities on the network like switches and routers. For example +// for Wi-Fi, the Network Service Type can select the marking of the +// layer 2 packet with the appropriate WMM Access Category. +// +// There is no point in attempting to game the system and use +// a Network Service Type that does not correspond to the actual +// traffic characteristic but one that seems to have a higher precedence. +// The reason is that for service classes that have lower tolerance +// for delay and jitter, the queues size is lower than for service +// classes that are more tolerant to delay and jitter. +// +// For example using a voice service type for bulk data transfer will lead +// to disastrous results as soon as congestion happens because the voice +// queue overflows and packets get dropped. This is not only bad for the bulk +// data transfer but it is also bad for VoIP apps that legitimately are using +// the voice service type. +// +// The characteristics of the Network Service Types are based on the service +// classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service +// Classes" +// +// When system detects the outgoing interface belongs to a DiffServ domain +// that follows the recommendation of the IETF draft "Guidelines for DiffServ to +// IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value +// that corresponds to Network Service Type. +// +// NET_SERVICE_TYPE_BE +// "Best Effort", unclassified/standard. This is the default service +// class and cover the majority of the traffic. +// +// NET_SERVICE_TYPE_BK +// "Background", high delay tolerant, loss tolerant. elastic flow, +// variable size & long-lived. E.g: non-interactive network bulk transfer +// like synching or backup. +// +// NET_SERVICE_TYPE_RD +// "Responsive Data", a notch higher than "Best Effort", medium delay +// tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, +// instant messaging, for which there is a sense of interactivity and +// urgency (user waiting for output). +// +// NET_SERVICE_TYPE_OAM +// "Operations, Administration, and Management", medium delay tolerant, +// low-medium loss tolerant, elastic & inelastic flows, variable size. +// E.g. VPN tunnels. +// +// NET_SERVICE_TYPE_AV +// "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium +// loss tolerant, elastic flow, constant packet interval, variable rate +// and size. E.g. video and audio playback with buffering. +// +// NET_SERVICE_TYPE_RV +// "Responsive Multimedia Audio/Video", low delay tolerant, low-medium +// loss tolerant, elastic flow, variable packet interval, rate and size. +// E.g. screen sharing. +// +// NET_SERVICE_TYPE_VI +// "Interactive Video", low delay tolerant, low-medium loss tolerant, +// elastic flow, constant packet interval, variable rate & size. E.g. +// video telephony. +// +// NET_SERVICE_TYPE_SIG +// "Signaling", low delay tolerant, low loss tolerant, inelastic flow, +// jitter tolerant, rate is bursty but short, variable size. E.g. SIP. +// +// NET_SERVICE_TYPE_VO +// "Interactive Voice", very low delay tolerant, very low loss tolerant, +// inelastic flow, constant packet rate, somewhat fixed size. +// E.g. VoIP. + +// These are supported values for SO_NETSVC_MARKING_LEVEL + +type Sae_associd_t = X__uint32_t /* socket.h:289:20 */ + +type Sae_connid_t = X__uint32_t /* socket.h:293:20 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints = struct { + Fsae_srcif uint32 + F__ccgo_pad1 [4]byte + Fsae_srcaddr uintptr + Fsae_srcaddrlen Socklen_t + F__ccgo_pad2 [4]byte + Fsae_dstaddr uintptr + Fsae_dstaddrlen Socklen_t + F__ccgo_pad3 [4]byte +} /* socket.h:303:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sockaddr = struct { + Fsa_len X__uint8_t + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:303:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints_t = Sa_endpoints /* socket.h:309:3 */ + +// Structure used for manipulating linger option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:315:1 */ + +// Structure to control non-portable Sockets extension to POSIX +type So_np_extensions = struct { + Fnpx_flags U_int32_t + Fnpx_mask U_int32_t +} /* socket.h:333:1 */ + +// Structure used by kernel to pass protocol +// information in raw sockets. +type Sockproto = struct { + Fsp_family X__uint16_t + Fsp_protocol X__uint16_t +} /* socket.h:420:1 */ + +// RFC 2553: protocol-independent placeholder for socket addresses + +// [XSI] sockaddr_storage +type Sockaddr_storage = struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 +} /* socket.h:440:1 */ + +// Protocol families, same as address families for now. + +// These do not have socket-layer support: + +// Definitions for network related sysctl, CTL_NET. +// +// Second level is protocol family. +// Third level is protocol number. +// +// Further levels are defined by the individual families below. + +// PF_ROUTE - Routing table +// +// Three additional levels are defined: +// Fourth: address family, 0 is wildcard +// Fifth: type of info, defined below +// Sixth: flag(s) to mask with for NET_RT_FLAGS +// Allows read access non-local host's MAC address +// if the process has neighbor cache entitlement. + +// Maximum queue length specifiable by listen. + +// [XSI] Message header for recvmsg and sendmsg calls. +// Used value-result for recvmsg, value only for sendmsg. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__ccgo_pad2 [4]byte + Fmsg_control uintptr + Fmsg_controllen Socklen_t + Fmsg_flags int32 +} /* socket.h:546:1 */ + +// Header for ancillary data objects in msg_control buffer. +// Used for additional information with/about a datagram +// not expressible by flags. The format is a sequence +// of message elements headed by cmsghdr structures. +type Cmsghdr = struct { + Fcmsg_len Socklen_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:587:1 */ + +// given pointer to struct cmsghdr, return pointer to data + +// RFC 2292 requires to check msg_controllen, in case that the kernel returns +// an empty list for some reasons. + +// Given pointer to struct cmsghdr, return pointer to next cmsghdr +// RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) + +// RFC 2292 additions + +// "Socket"-level control message types: + +// howto arguments for shutdown(2), specified by Posix.1g. + +// sendfile(2) header/trailer struct +type Sf_hdtr = struct { + Fheaders uintptr + Fhdr_cnt int32 + F__ccgo_pad1 [4]byte + Ftrailers uintptr + Ftrl_cnt int32 + F__ccgo_pad2 [4]byte +} /* socket.h:678:1 */ + +// The following two #includes insure htonl and family are defined +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2004, 2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1987, 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. + +// Constants and structures defined by the internet system, +// Per RFC 790, September 1981, and numerous additions. + +// Protocols (RFC 1700) +// 55-57: Unassigned +// 101-252: Partly Unassigned +// 253-254: Experimentation and testing; 255: Reserved (RFC3692) +// BSD Private, local use, namespace incursion + +// last return value of *_input(), meaning "all job for this pkt is done". + +// Local port number conventions: +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// The default range is IPPORT_RESERVED through +// IPPORT_USERRESERVED, although that is settable by sysctl. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH changes the range of candidate port numbers +// into the "high" range. These are reserved for client outbound connections +// which do not want to be filtered by any firewalls. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. This +// convention is based on "vouchsafe" principles only. It is only secure +// if you trust the remote host to restrict these ports. +// +// The default range of ports and the high range can be changed by +// sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) +// +// Changing those values has bad security implications if you are +// using a a stateless firewall that is allowing packets outside of that +// range in order to allow transparent outgoing connections. +// +// Such a firewall configuration will generally depend on the use of these +// default values. If you change them, you may find your Security +// Administrator looking for you with a heavy object. +// +// For a slightly more orthodox text view on this: +// +// ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers +// +// port numbers are divided into three ranges: +// +// 0 - 1023 Well Known Ports +// 1024 - 49151 Registered Ports +// 49152 - 65535 Dynamic and/or Private Ports +// + +// Ports < IPPORT_RESERVED are reserved for +// privileged processes (e.g. root). (IP_PORTRANGE_LOW) +// Ports > IPPORT_USERRESERVED are reserved +// for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) + +// Default local port range to use by setting IP_PORTRANGE_HIGH + +// Scanning for a free reserved port return a value below IPPORT_RESERVED, +// but higher than IPPORT_RESERVEDSTART. Traditionally the start value was +// 512, but that conflicts with some well-known-services that firewalls may +// have a fit if we use. + +// Internet address (a structure for historical reasons) +type In_addr = struct{ Fs_addr In_addr_t } /* in.h:301:1 */ + +// Definitions of bits in internet address integers. +// On subnets, the decomposition of addresses to host and net parts +// is done according to subnet mask, not the masks here. + +// Socket address, internet style. +type Sockaddr_in = struct { + Fsin_len X__uint8_t + Fsin_family Sa_family_t + Fsin_port In_port_t + Fsin_addr struct{ Fs_addr In_addr_t } + Fsin_zero [8]int8 +} /* in.h:375:1 */ + +// Structure used to describe IP options. +// Used to store options internally, to pass them to a process, +// or to restore options retrieved earlier. +// The ip_dst is used for the first-hop gateway when using a source route +// (this gets put into the header proper). +type Ip_opts = struct { + Fip_dst struct{ Fs_addr In_addr_t } + Fip_opts [40]int8 +} /* in.h:398:1 */ + +// Options for use with [gs]etsockopt at the IP level. +// First word of comment is data type; bool is stored in int. +// for IPSEC + +// These older firewall socket option codes are maintained for backward compatibility. + +// IPv4 Source Filter Multicast API [RFC3678] + +// The following option is private; do not use it from user applications. + +// Protocol Independent Multicast API [RFC3678] + +// Defaults and limits for options + +// The imo_membership vector for each socket is now dynamically allocated at +// run-time, bounded by USHRT_MAX, and is reallocated when needed, sized +// according to a power-of-two increment. + +// Default resource limits for IPv4 multicast source filtering. +// These may be modified by sysctl. + +// Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. +type Ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:506:1 */ + +// Modified argument structure for IP_MULTICAST_IF, obtained from Linux. +// This is used to specify an interface index for multicast sends, as +// the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). +type Ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_address struct{ Fs_addr In_addr_t } + Fimr_ifindex int32 +} /* in.h:516:1 */ + +// Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] +type Ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_sourceaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:526:1 */ + +// Argument structures for Protocol-Independent Multicast Source +// Filter APIs. [RFC3678] +type Group_req = struct { + Fgr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } +} /* in.h:536:1 */ + +type Group_source_req = struct { + Fgsr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } + Fgsr_source struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } +} /* in.h:541:1 */ + +// The following structure is private; do not use it from user applications. +// It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between +// the RFC 3678 libc functions and the kernel. +type X__msfilterreq = struct { + Fmsfr_ifindex Uint32_t + Fmsfr_fmode Uint32_t + Fmsfr_nsrcs Uint32_t + F__msfr_align Uint32_t + Fmsfr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } + Fmsfr_srcs uintptr +} /* in.h:554:1 */ + +// Filter modes; also used to represent per-socket filter mode internally. + +// Argument for IP_PORTRANGE: +// - which range to search when port is unspecified at bind() or connect() + +// IP_PKTINFO: Packet information (equivalent to RFC2292 sec 5 for IPv4) +// This structure is used for +// +// 1. Receiving ancilliary data about the datagram if IP_PKTINFO sockopt is +// set on the socket. In this case ipi_ifindex will contain the interface +// index the datagram was received on, ipi_addr is the IP address the +// datagram was received to. +// +// 2. Sending a datagram using a specific interface or IP source address. +// if ipi_ifindex is set to non-zero when in_pktinfo is passed as +// ancilliary data of type IP_PKTINFO, this will be used as the source +// interface to send the datagram from. If ipi_ifindex is null, ip_spec_dst +// will be used for the source address. +// +// Note: if IP_BOUND_IF is set on the socket, ipi_ifindex in the ancillary +// IP_PKTINFO option silently overrides the bound interface when it is +// specified during send time. +type In_pktinfo = struct { + Fipi_ifindex uint32 + Fipi_spec_dst struct{ Fs_addr In_addr_t } + Fipi_addr struct{ Fs_addr In_addr_t } +} /* in.h:617:1 */ + +// Definitions for inet sysctl operations. +// +// Third level is protocol number. +// Fourth level is desired variable within that protocol. + +// Names for IP sysctl objects + +// INET6 stuff +// Copyright (c) 2008-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +// 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 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Identification of the network protocol stack +// for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE +// has the table of implementation/integration differences. + +// Local port number conventions: +// +// Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), +// unless a kernel is compiled with IPNOPRIVPORTS defined. +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// +// The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although +// that is settable by sysctl(3); net.inet.ip.anonportmin and +// net.inet.ip.anonportmax respectively. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, +// and exists only for FreeBSD compatibility purposes. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. +// This convention is based on "vouchsafe" principles only. +// It is only secure if you trust the remote host to restrict these ports. +// The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + +// IPv6 address +type In6_addr = struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } +} /* in6.h:151:9 */ + +// Definitions for inet sysctl operations. +// +// Third level is protocol number. +// Fourth level is desired variable within that protocol. + +// Names for IP sysctl objects + +// INET6 stuff +// Copyright (c) 2008-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +// 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 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Identification of the network protocol stack +// for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE +// has the table of implementation/integration differences. + +// Local port number conventions: +// +// Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), +// unless a kernel is compiled with IPNOPRIVPORTS defined. +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// +// The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although +// that is settable by sysctl(3); net.inet.ip.anonportmin and +// net.inet.ip.anonportmax respectively. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, +// and exists only for FreeBSD compatibility purposes. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. +// This convention is based on "vouchsafe" principles only. +// It is only secure if you trust the remote host to restrict these ports. +// The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + +// IPv6 address +type In6_addr_t = In6_addr /* in6.h:157:3 */ + +// Socket address for IPv6 +type Sockaddr_in6 = struct { + Fsin6_len X__uint8_t + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo X__uint32_t + Fsin6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fsin6_scope_id X__uint32_t +} /* in6.h:169:1 */ + +// Equality +// NOTE: Some of kernel programming environment (for example, openbsd/sparc) +// does not supply memcmp(). For userland memcmp() is preferred as it is +// in ANSI standard. + +// Unspecified + +// Loopback + +// IPv4 compatible + +// Mapped + +// 6to4 + +// KAME Scope Values + +// Unicast Scope +// Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). + +// Multicast + +// Unique Local IPv6 Unicast Addresses (per RFC 4193) + +// Multicast Scope + +// Options for use with [gs]etsockopt at the IPV6 level. +// First word of comment is data type; bool is stored in int. +// no hdrincl +// RFC 3542 define the following socket options in a manner incompatible +// with RFC 2292: +// IPV6_PKTINFO +// IPV6_HOPLIMIT +// IPV6_NEXTHOP +// IPV6_HOPOPTS +// IPV6_DSTOPTS +// IPV6_RTHDR +// +// To use the new IPv6 Sockets options introduced by RFC 3542 +// the constant __APPLE_USE_RFC_3542 must be defined before +// including +// +// To use the old IPv6 Sockets options from RFC 2292 +// the constant __APPLE_USE_RFC_2292 must be defined before +// including +// +// Note that eventually RFC 3542 is going to be the +// default and RFC 2292 will be obsolete. + +// buf/cmsghdr; set/get IPv6 options [obsoleted by RFC3542] + +// APPLE: NOTE the value of those 2 options is kept unchanged from +// previous version of darwin/OS X for binary compatibility reasons +// and differ from FreeBSD (values 57 and 61). See below. + +// to define items, should talk with KAME guys first, for *BSD compatibility + +// Defaults and limits for options + +// The im6o_membership vector for each socket is now dynamically allocated at +// run-time, bounded by USHRT_MAX, and is reallocated when needed, sized +// according to a power-of-two increment. + +// Default resource limits for IPv6 multicast source filtering. +// These may be modified by sysctl. + +// Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. +type Ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fipv6mr_interface uint32 +} /* in6.h:527:1 */ + +// IPV6_2292PKTINFO: Packet information(RFC2292 sec 5) +type In6_pktinfo = struct { + Fipi6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fipi6_ifindex uint32 +} /* in6.h:535:1 */ + +// Control structure for IPV6_RECVPATHMTU socket option. +type Ip6_mtuinfo = struct { + Fip6m_addr struct { + Fsin6_len X__uint8_t + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo X__uint32_t + Fsin6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fsin6_scope_id X__uint32_t + } + Fip6m_mtu Uint32_t +} /* in6.h:543:1 */ + +// Structures returned by network data base library. All addresses are +// supplied in host order, and returned in network order (suitable for +// use in system calls). +type Hostent = struct { + Fh_name uintptr + Fh_aliases uintptr + Fh_addrtype int32 + Fh_length int32 + Fh_addr_list uintptr +} /* netdb.h:112:1 */ + +// Assumption here is that a network number +// fits in an unsigned long -- probably a poor one. +type Netent = struct { + Fn_name uintptr + Fn_aliases uintptr + Fn_addrtype int32 + Fn_net Uint32_t +} /* netdb.h:127:1 */ + +type Servent = struct { + Fs_name uintptr + Fs_aliases uintptr + Fs_port int32 + F__ccgo_pad1 [4]byte + Fs_proto uintptr +} /* netdb.h:134:1 */ + +type Protoent = struct { + Fp_name uintptr + Fp_aliases uintptr + Fp_proto int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:141:1 */ + +type Addrinfo = struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen Socklen_t + F__ccgo_pad1 [4]byte + Fai_canonname uintptr + Fai_addr uintptr + Fai_next uintptr +} /* netdb.h:147:1 */ + +type Rpcent = struct { + Fr_name uintptr + Fr_aliases uintptr + Fr_number int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:159:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/netdb/netdb_darwin_arm64.go b/internal/libc/netdb/netdb_darwin_arm64.go new file mode 100644 index 0000000..8a15897 --- /dev/null +++ b/internal/libc/netdb/netdb_darwin_arm64.go @@ -0,0 +1,6323 @@ +// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_darwin_arm64.go -pkgname netdb', DO NOT EDIT. + +package netdb + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_APPLETALK = 16 // socket.h:379:1: + AF_CCITT = 10 // socket.h:373:1: + AF_CHAOS = 5 // socket.h:367:1: + AF_CNT = 21 // socket.h:384:1: + AF_COIP = 20 // socket.h:383:1: + AF_DATAKIT = 9 // socket.h:372:1: + AF_DECnet = 12 // socket.h:375:1: + AF_DLI = 13 // socket.h:376:1: + AF_E164 = 28 // socket.h:391:1: + AF_ECMA = 8 // socket.h:371:1: + AF_HYLINK = 15 // socket.h:378:1: + AF_IEEE80211 = 37 // socket.h:403:1: + AF_IMPLINK = 3 // socket.h:365:1: + AF_INET = 2 // socket.h:363:1: + AF_INET6 = 30 // socket.h:394:1: + AF_IPX = 23 // socket.h:386:1: + AF_ISDN = 28 // socket.h:390:1: + AF_ISO = 7 // socket.h:369:1: + AF_LAT = 14 // socket.h:377:1: + AF_LINK = 18 // socket.h:381:1: + AF_LOCAL = 1 // socket.h:361:1: + AF_MAX = 41 // socket.h:406:1: + AF_NATM = 31 // socket.h:396:1: + AF_NDRV = 27 // socket.h:389:1: + AF_NETBIOS = 33 // socket.h:398:1: + AF_NS = 6 // socket.h:368:1: + AF_OSI = 7 // socket.h:370:1: + AF_PPP = 34 // socket.h:399:1: + AF_PUP = 4 // socket.h:366:1: + AF_RESERVED_36 = 36 // socket.h:402:1: + AF_ROUTE = 17 // socket.h:380:1: + AF_SIP = 24 // socket.h:387:1: + AF_SNA = 11 // socket.h:374:1: + AF_SYSTEM = 32 // socket.h:397:1: + AF_UNIX = 1 // socket.h:359:1: + AF_UNSPEC = 0 // socket.h:358:1: + AF_UTUN = 38 // socket.h:404:1: + AF_VSOCK = 40 // socket.h:405:1: + AI_ADDRCONFIG = 0x00000400 // netdb.h:226:1: + AI_ALL = 0x00000100 // netdb.h:222:1: + AI_CANONNAME = 0x00000002 // netdb.h:212:1: + AI_DEFAULT = 1536 // netdb.h:230:1: + AI_MASK = 5127 // netdb.h:217:1: + AI_NUMERICHOST = 0x00000004 // netdb.h:213:1: + AI_NUMERICSERV = 0x00001000 // netdb.h:214:1: + AI_PASSIVE = 0x00000001 // netdb.h:211:1: + AI_UNUSABLE = 0x10000000 // netdb.h:234:1: + AI_V4MAPPED = 0x00000800 // netdb.h:227:1: + AI_V4MAPPED_CFG = 0x00000200 // netdb.h:224:1: + BIG_ENDIAN = 4321 // endian.h:72:1: + BYTE_ORDER = 1234 // endian.h:75:1: + CONNECT_DATA_AUTHENTICATED = 0x4 // socket.h:304:1: + CONNECT_DATA_IDEMPOTENT = 0x2 // socket.h:303:1: + CONNECT_RESUME_ON_READ_WRITE = 0x1 // socket.h:302:1: + EAI_ADDRFAMILY = 1 // netdb.h:185:1: + EAI_AGAIN = 2 // netdb.h:187:1: + EAI_BADFLAGS = 3 // netdb.h:188:1: + EAI_BADHINTS = 12 // netdb.h:200:1: + EAI_FAIL = 4 // netdb.h:189:1: + EAI_FAMILY = 5 // netdb.h:190:1: + EAI_MAX = 15 // netdb.h:205:1: + EAI_MEMORY = 6 // netdb.h:191:1: + EAI_NODATA = 7 // netdb.h:193:1: + EAI_NONAME = 8 // netdb.h:195:1: + EAI_OVERFLOW = 14 // netdb.h:203:1: + EAI_PROTOCOL = 13 // netdb.h:201:1: + EAI_SERVICE = 9 // netdb.h:196:1: + EAI_SOCKTYPE = 10 // netdb.h:197:1: + EAI_SYSTEM = 11 // netdb.h:198:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + HOST_NOT_FOUND = 1 // netdb.h:174:1: + ICMP6_FILTER = 18 // in6.h:394:1: + ICMPV6CTL_ND6_ONLINKNSRFC4861 = 50 // in6.h:629:1: + INADDR_NONE = 0xffffffff // in.h:342:1: + INET6_ADDRSTRLEN = 46 // in6.h:162:1: + INET_ADDRSTRLEN = 16 // in.h:388:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + IN_CLASSA_HOST = 0x00ffffff // in.h:317:1: + IN_CLASSA_MAX = 128 // in.h:318:1: + IN_CLASSA_NET = 0xff000000 // in.h:315:1: + IN_CLASSA_NSHIFT = 24 // in.h:316:1: + IN_CLASSB_HOST = 0x0000ffff // in.h:323:1: + IN_CLASSB_MAX = 65536 // in.h:324:1: + IN_CLASSB_NET = 0xffff0000 // in.h:321:1: + IN_CLASSB_NSHIFT = 16 // in.h:322:1: + IN_CLASSC_HOST = 0x000000ff // in.h:329:1: + IN_CLASSC_NET = 0xffffff00 // in.h:327:1: + IN_CLASSC_NSHIFT = 8 // in.h:328:1: + IN_CLASSD_HOST = 0x0fffffff // in.h:334:1: + IN_CLASSD_NET = 0xf0000000 // in.h:332:1: + IN_CLASSD_NSHIFT = 28 // in.h:333:1: + IN_LOOPBACKNET = 127 // in.h:369:1: + IPCTL_ACCEPTSOURCEROUTE = 13 // in.h:650:1: + IPCTL_DEFTTL = 3 // in.h:638:1: + IPCTL_DIRECTEDBROADCAST = 9 // in.h:646:1: + IPCTL_FASTFORWARDING = 14 // in.h:651:1: + IPCTL_FORWARDING = 1 // in.h:636:1: + IPCTL_GIF_TTL = 16 // in.h:653:1: + IPCTL_INTRQDROPS = 11 // in.h:648:1: + IPCTL_INTRQMAXLEN = 10 // in.h:647:1: + IPCTL_KEEPFAITH = 15 // in.h:652:1: + IPCTL_MAXID = 17 // in.h:654:1: + IPCTL_RTEXPIRE = 5 // in.h:642:1: + IPCTL_RTMAXCACHE = 7 // in.h:644:1: + IPCTL_RTMINEXPIRE = 6 // in.h:643:1: + IPCTL_SENDREDIRECTS = 2 // in.h:637:1: + IPCTL_SOURCEROUTE = 8 // in.h:645:1: + IPCTL_STATS = 12 // in.h:649:1: + IPPORT_HIFIRSTAUTO = 49152 // in.h:286:1: + IPPORT_HILASTAUTO = 65535 // in.h:287:1: + IPPORT_RESERVED = 1024 // in.h:279:1: + IPPORT_RESERVEDSTART = 600 // in.h:295:1: + IPPORT_USERRESERVED = 5000 // in.h:281:1: + IPPROTO_3PC = 34 // in.h:139:1: + IPPROTO_ADFS = 68 // in.h:173:1: + IPPROTO_AH = 51 // in.h:158:1: + IPPROTO_AHIP = 61 // in.h:166:1: + IPPROTO_APES = 99 // in.h:204:1: + IPPROTO_ARGUS = 13 // in.h:116:1: + IPPROTO_AX25 = 93 // in.h:198:1: + IPPROTO_BHA = 49 // in.h:156:1: + IPPROTO_BLT = 30 // in.h:135:1: + IPPROTO_BRSATMON = 76 // in.h:181:1: + IPPROTO_CFTP = 62 // in.h:167:1: + IPPROTO_CHAOS = 16 // in.h:119:1: + IPPROTO_CMTP = 38 // in.h:143:1: + IPPROTO_CPHB = 73 // in.h:178:1: + IPPROTO_CPNX = 72 // in.h:177:1: + IPPROTO_DDP = 37 // in.h:142:1: + IPPROTO_DGP = 86 // in.h:191:1: + IPPROTO_DIVERT = 254 // in.h:213:1: + IPPROTO_DONE = 257 // in.h:221:1: + IPPROTO_DSTOPTS = 60 // in.h:165:1: + IPPROTO_EGP = 8 // in.h:111:1: + IPPROTO_EMCON = 14 // in.h:117:1: + IPPROTO_ENCAP = 98 // in.h:203:1: + IPPROTO_EON = 80 // in.h:185:1: + IPPROTO_ESP = 50 // in.h:157:1: + IPPROTO_ETHERIP = 97 // in.h:202:1: + IPPROTO_FRAGMENT = 44 // in.h:151:1: + IPPROTO_GGP = 3 // in.h:104:1: + IPPROTO_GMTP = 100 // in.h:205:1: + IPPROTO_GRE = 47 // in.h:154:1: + IPPROTO_HELLO = 63 // in.h:168:1: + IPPROTO_HMP = 20 // in.h:125:1: + IPPROTO_HOPOPTS = 0 // in.h:99:1: + IPPROTO_ICMP = 1 // in.h:101:1: + IPPROTO_ICMPV6 = 58 // in.h:163:1: + IPPROTO_IDP = 22 // in.h:127:1: + IPPROTO_IDPR = 35 // in.h:140:1: + IPPROTO_IDRP = 45 // in.h:152:1: + IPPROTO_IGMP = 2 // in.h:103:1: + IPPROTO_IGP = 85 // in.h:190:1: + IPPROTO_IGRP = 88 // in.h:193:1: + IPPROTO_IL = 40 // in.h:145:1: + IPPROTO_INLSP = 52 // in.h:159:1: + IPPROTO_INP = 32 // in.h:137:1: + IPPROTO_IP = 0 // in.h:97:1: + IPPROTO_IPCOMP = 108 // in.h:208:1: + IPPROTO_IPCV = 71 // in.h:176:1: + IPPROTO_IPEIP = 94 // in.h:199:1: + IPPROTO_IPIP = 4 // in.h:106:1: + IPPROTO_IPPC = 67 // in.h:172:1: + IPPROTO_IPV4 = 4 // in.h:105:1: + IPPROTO_IPV6 = 41 // in.h:147:1: + IPPROTO_IRTP = 28 // in.h:133:1: + IPPROTO_KRYPTOLAN = 65 // in.h:170:1: + IPPROTO_LARP = 91 // in.h:196:1: + IPPROTO_LEAF1 = 25 // in.h:130:1: + IPPROTO_LEAF2 = 26 // in.h:131:1: + IPPROTO_MAX = 256 // in.h:218:1: + IPPROTO_MAXID = 52 // in.h:630:1: + IPPROTO_MEAS = 19 // in.h:124:1: + IPPROTO_MHRP = 48 // in.h:155:1: + IPPROTO_MICP = 95 // in.h:200:1: + IPPROTO_MTP = 92 // in.h:197:1: + IPPROTO_MUX = 18 // in.h:123:1: + IPPROTO_ND = 77 // in.h:182:1: + IPPROTO_NHRP = 54 // in.h:161:1: + IPPROTO_NONE = 59 // in.h:164:1: + IPPROTO_NSP = 31 // in.h:136:1: + IPPROTO_NVPII = 11 // in.h:114:1: + IPPROTO_OSPFIGP = 89 // in.h:194:1: + IPPROTO_PGM = 113 // in.h:209:1: + IPPROTO_PIGP = 9 // in.h:112:1: + IPPROTO_PIM = 103 // in.h:207:1: + IPPROTO_PRM = 21 // in.h:126:1: + IPPROTO_PUP = 12 // in.h:115:1: + IPPROTO_PVP = 75 // in.h:180:1: + IPPROTO_RAW = 255 // in.h:215:1: + IPPROTO_RCCMON = 10 // in.h:113:1: + IPPROTO_RDP = 27 // in.h:132:1: + IPPROTO_ROUTING = 43 // in.h:150:1: + IPPROTO_RSVP = 46 // in.h:153:1: + IPPROTO_RVD = 66 // in.h:171:1: + IPPROTO_SATEXPAK = 64 // in.h:169:1: + IPPROTO_SATMON = 69 // in.h:174:1: + IPPROTO_SCCSP = 96 // in.h:201:1: + IPPROTO_SCTP = 132 // in.h:210:1: + IPPROTO_SDRP = 42 // in.h:149:1: + IPPROTO_SEP = 33 // in.h:138:1: + IPPROTO_SRPC = 90 // in.h:195:1: + IPPROTO_ST = 7 // in.h:110:1: + IPPROTO_SVMTP = 82 // in.h:187:1: + IPPROTO_SWIPE = 53 // in.h:160:1: + IPPROTO_TCF = 87 // in.h:192:1: + IPPROTO_TCP = 6 // in.h:108:1: + IPPROTO_TP = 29 // in.h:134:1: + IPPROTO_TPXX = 39 // in.h:144:1: + IPPROTO_TRUNK1 = 23 // in.h:128:1: + IPPROTO_TRUNK2 = 24 // in.h:129:1: + IPPROTO_TTP = 84 // in.h:189:1: + IPPROTO_UDP = 17 // in.h:121:1: + IPPROTO_VINES = 83 // in.h:188:1: + IPPROTO_VISA = 70 // in.h:175:1: + IPPROTO_VMTP = 81 // in.h:186:1: + IPPROTO_WBEXPAK = 79 // in.h:184:1: + IPPROTO_WBMON = 78 // in.h:183:1: + IPPROTO_WSN = 74 // in.h:179:1: + IPPROTO_XNET = 15 // in.h:118:1: + IPPROTO_XTP = 36 // in.h:141:1: + IPV6CTL_ACCEPT_RTADV = 12 // in6.h:594:1: + IPV6CTL_ADDRCTLPOLICY = 38 // in6.h:619:1: + IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:599:1: + IPV6CTL_AUTO_LINKLOCAL = 35 // in6.h:616:1: + IPV6CTL_DAD_COUNT = 16 // in6.h:598:1: + IPV6CTL_DEFHLIM = 3 // in6.h:583:1: + IPV6CTL_DEFMCASTHLIM = 18 // in6.h:600:1: + IPV6CTL_FORWARDING = 1 // in6.h:581:1: + IPV6CTL_FORWSRCRT = 5 // in6.h:587:1: + IPV6CTL_GIF_HLIM = 19 // in6.h:601:1: + IPV6CTL_HDRNESTLIMIT = 15 // in6.h:597:1: + IPV6CTL_KAME_VERSION = 20 // in6.h:602:1: + IPV6CTL_KEEPFAITH = 13 // in6.h:595:1: + IPV6CTL_LOG_INTERVAL = 14 // in6.h:596:1: + IPV6CTL_MAXDYNROUTES = 49 // in6.h:628:1: + IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:591:1: + IPV6CTL_MAXFRAGS = 41 // in6.h:622:1: + IPV6CTL_MAXID = 51 // in6.h:635:1: + IPV6CTL_MAXIFDEFROUTERS = 48 // in6.h:627:1: + IPV6CTL_MAXIFPREFIXES = 47 // in6.h:626:1: + IPV6CTL_MCAST_PMTU = 44 // in6.h:623:1: + IPV6CTL_MRTPROTO = 8 // in6.h:590:1: + IPV6CTL_MRTSTATS = 7 // in6.h:589:1: + IPV6CTL_NEIGHBORGCTHRESH = 46 // in6.h:625:1: + IPV6CTL_PREFER_TEMPADDR = 37 // in6.h:618:1: + IPV6CTL_RIP6STATS = 36 // in6.h:617:1: + IPV6CTL_RR_PRUNE = 22 // in6.h:604:1: + IPV6CTL_RTEXPIRE = 25 // in6.h:609:1: + IPV6CTL_RTMAXCACHE = 27 // in6.h:611:1: + IPV6CTL_RTMINEXPIRE = 26 // in6.h:610:1: + IPV6CTL_SENDREDIRECTS = 2 // in6.h:582:1: + IPV6CTL_SOURCECHECK = 10 // in6.h:592:1: + IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:593:1: + IPV6CTL_STATS = 6 // in6.h:588:1: + IPV6CTL_TEMPPLTIME = 33 // in6.h:614:1: + IPV6CTL_TEMPVLTIME = 34 // in6.h:615:1: + IPV6CTL_ULA_USETEMPADDR = 51 // in6.h:630:1: + IPV6CTL_USETEMPADDR = 32 // in6.h:613:1: + IPV6CTL_USE_DEFAULTZONE = 39 // in6.h:620:1: + IPV6CTL_USE_DEPRECATED = 21 // in6.h:603:1: + IPV6CTL_V6ONLY = 24 // in6.h:608:1: + IPV6PORT_ANONMAX = 65535 // in6.h:144:1: + IPV6PORT_ANONMIN = 49152 // in6.h:143:1: + IPV6PORT_RESERVED = 1024 // in6.h:142:1: + IPV6PORT_RESERVEDMAX = 1023 // in6.h:146:1: + IPV6PORT_RESERVEDMIN = 600 // in6.h:145:1: + IPV6PROTO_MAXID = 104 // in6.h:576:1: + IPV6_2292DSTOPTS = 23 // in6.h:399:1: + IPV6_2292HOPLIMIT = 20 // in6.h:396:1: + IPV6_2292HOPOPTS = 22 // in6.h:398:1: + IPV6_2292NEXTHOP = 21 // in6.h:397:1: + IPV6_2292PKTINFO = 19 // in6.h:395:1: + IPV6_2292PKTOPTIONS = 25 // in6.h:403:1: + IPV6_2292RTHDR = 24 // in6.h:400:1: + IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 // in6.h:306:1: + IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 // in6.h:305:1: + IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 48 // in6.h:307:1: + IPV6_BINDV6ONLY = 27 // in6.h:419:1: + IPV6_BOUND_IF = 125 // in6.h:508:1: + IPV6_CHECKSUM = 26 // in6.h:415:1: + IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:520:1: + IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:521:1: + IPV6_FAITH = 29 // in6.h:425:1: + IPV6_FW_ADD = 30 // in6.h:428:1: + IPV6_FW_DEL = 31 // in6.h:429:1: + IPV6_FW_FLUSH = 32 // in6.h:430:1: + IPV6_FW_GET = 34 // in6.h:432:1: + IPV6_FW_ZERO = 33 // in6.h:431:1: + IPV6_IPSEC_POLICY = 28 // in6.h:423:1: + IPV6_JOIN_GROUP = 12 // in6.h:389:1: + IPV6_LEAVE_GROUP = 13 // in6.h:390:1: + IPV6_MAX_GROUP_SRC_FILTER = 512 // in6.h:535:1: + IPV6_MAX_MEMBERSHIPS = 4095 // in6.h:529:1: + IPV6_MAX_SOCK_SRC_FILTER = 128 // in6.h:536:1: + IPV6_MIN_MEMBERSHIPS = 31 // in6.h:528:1: + IPV6_MULTICAST_HOPS = 10 // in6.h:387:1: + IPV6_MULTICAST_IF = 9 // in6.h:386:1: + IPV6_MULTICAST_LOOP = 11 // in6.h:388:1: + IPV6_PORTRANGE = 14 // in6.h:393:1: + IPV6_PORTRANGE_DEFAULT = 0 // in6.h:566:1: + IPV6_PORTRANGE_HIGH = 1 // in6.h:567:1: + IPV6_PORTRANGE_LOW = 2 // in6.h:568:1: + IPV6_RECVTCLASS = 35 // in6.h:440:1: + IPV6_RTHDR_LOOSE = 0 // in6.h:513:1: + IPV6_RTHDR_STRICT = 1 // in6.h:514:1: + IPV6_RTHDR_TYPE_0 = 0 // in6.h:515:1: + IPV6_SOCKOPT_RESERVED1 = 3 // in6.h:383:1: + IPV6_TCLASS = 36 // in6.h:441:1: + IPV6_UNICAST_HOPS = 4 // in6.h:385:1: + IPV6_V6ONLY = 27 // in6.h:417:1: + IP_ADD_MEMBERSHIP = 12 // in.h:418:1: + IP_ADD_SOURCE_MEMBERSHIP = 70 // in.h:465:1: + IP_BLOCK_SOURCE = 72 // in.h:467:1: + IP_BOUND_IF = 25 // in.h:434:1: + IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:486:1: + IP_DEFAULT_MULTICAST_TTL = 1 // in.h:485:1: + IP_DONTFRAG = 28 // in.h:438:1: + IP_DROP_MEMBERSHIP = 13 // in.h:419:1: + IP_DROP_SOURCE_MEMBERSHIP = 71 // in.h:466:1: + IP_DUMMYNET_CONFIGURE = 60 // in.h:456:1: + IP_DUMMYNET_DEL = 61 // in.h:457:1: + IP_DUMMYNET_FLUSH = 62 // in.h:458:1: + IP_DUMMYNET_GET = 64 // in.h:459:1: + IP_FAITH = 22 // in.h:429:1: + IP_FW_ADD = 40 // in.h:440:1: + IP_FW_DEL = 41 // in.h:441:1: + IP_FW_FLUSH = 42 // in.h:442:1: + IP_FW_GET = 44 // in.h:444:1: + IP_FW_RESETLOG = 45 // in.h:445:1: + IP_FW_ZERO = 43 // in.h:443:1: + IP_HDRINCL = 2 // in.h:408:1: + IP_IPSEC_POLICY = 21 // in.h:428:1: + IP_MAX_GROUP_SRC_FILTER = 512 // in.h:500:1: + IP_MAX_MEMBERSHIPS = 4095 // in.h:494:1: + IP_MAX_SOCK_MUTE_FILTER = 128 // in.h:502:1: + IP_MAX_SOCK_SRC_FILTER = 128 // in.h:501:1: + IP_MIN_MEMBERSHIPS = 31 // in.h:493:1: + IP_MSFILTER = 74 // in.h:471:1: + IP_MULTICAST_IF = 9 // in.h:415:1: + IP_MULTICAST_IFINDEX = 66 // in.h:462:1: + IP_MULTICAST_LOOP = 11 // in.h:417:1: + IP_MULTICAST_TTL = 10 // in.h:416:1: + IP_MULTICAST_VIF = 14 // in.h:420:1: + IP_NAT__XXX = 55 // in.h:453:1: + IP_OLD_FW_ADD = 50 // in.h:448:1: + IP_OLD_FW_DEL = 51 // in.h:449:1: + IP_OLD_FW_FLUSH = 52 // in.h:450:1: + IP_OLD_FW_GET = 54 // in.h:452:1: + IP_OLD_FW_RESETLOG = 56 // in.h:454:1: + IP_OLD_FW_ZERO = 53 // in.h:451:1: + IP_OPTIONS = 1 // in.h:407:1: + IP_PKTINFO = 26 // in.h:435:1: + IP_PORTRANGE = 19 // in.h:425:1: + IP_PORTRANGE_DEFAULT = 0 // in.h:594:1: + IP_PORTRANGE_HIGH = 1 // in.h:595:1: + IP_PORTRANGE_LOW = 2 // in.h:596:1: + IP_RECVDSTADDR = 7 // in.h:413:1: + IP_RECVIF = 20 // in.h:426:1: + IP_RECVOPTS = 5 // in.h:411:1: + IP_RECVPKTINFO = 26 // in.h:436:1: + IP_RECVRETOPTS = 6 // in.h:412:1: + IP_RECVTOS = 27 // in.h:437:1: + IP_RECVTTL = 24 // in.h:433:1: + IP_RETOPTS = 8 // in.h:414:1: + IP_RSVP_OFF = 16 // in.h:422:1: + IP_RSVP_ON = 15 // in.h:421:1: + IP_RSVP_VIF_OFF = 18 // in.h:424:1: + IP_RSVP_VIF_ON = 17 // in.h:423:1: + IP_STRIPHDR = 23 // in.h:431:1: + IP_TOS = 3 // in.h:409:1: + IP_TRAFFIC_MGT_BACKGROUND = 65 // in.h:461:1: + IP_TTL = 4 // in.h:410:1: + IP_UNBLOCK_SOURCE = 73 // in.h:468:1: + KEV_DL_ADDMULTI = 7 // net_kev.h:61:1: + KEV_DL_AWDL_RESTRICTED = 26 // net_kev.h:80:1: + KEV_DL_AWDL_UNRESTRICTED = 27 // net_kev.h:81:1: + KEV_DL_DELMULTI = 8 // net_kev.h:62:1: + KEV_DL_IFCAP_CHANGED = 19 // net_kev.h:73:1: + KEV_DL_IFDELEGATE_CHANGED = 25 // net_kev.h:79:1: + KEV_DL_IF_ATTACHED = 9 // net_kev.h:63:1: + KEV_DL_IF_DETACHED = 11 // net_kev.h:65:1: + KEV_DL_IF_DETACHING = 10 // net_kev.h:64:1: + KEV_DL_IF_IDLE_ROUTE_REFCNT = 18 // net_kev.h:72:1: + KEV_DL_ISSUES = 24 // net_kev.h:78:1: + KEV_DL_LINK_ADDRESS_CHANGED = 16 // net_kev.h:70:1: + KEV_DL_LINK_OFF = 12 // net_kev.h:66:1: + KEV_DL_LINK_ON = 13 // net_kev.h:67:1: + KEV_DL_LINK_QUALITY_METRIC_CHANGED = 20 // net_kev.h:74:1: + KEV_DL_LOW_POWER_MODE_CHANGED = 30 // net_kev.h:84:1: + KEV_DL_NODE_ABSENCE = 22 // net_kev.h:76:1: + KEV_DL_NODE_PRESENCE = 21 // net_kev.h:75:1: + KEV_DL_PRIMARY_ELECTED = 23 // net_kev.h:77:1: + KEV_DL_PROTO_ATTACHED = 14 // net_kev.h:68:1: + KEV_DL_PROTO_DETACHED = 15 // net_kev.h:69:1: + KEV_DL_QOS_MODE_CHANGED = 29 // net_kev.h:83:1: + KEV_DL_RRC_STATE_CHANGED = 28 // net_kev.h:82:1: + KEV_DL_SIFFLAGS = 1 // net_kev.h:55:1: + KEV_DL_SIFGENERIC = 6 // net_kev.h:60:1: + KEV_DL_SIFMEDIA = 5 // net_kev.h:59:1: + KEV_DL_SIFMETRICS = 2 // net_kev.h:56:1: + KEV_DL_SIFMTU = 3 // net_kev.h:57:1: + KEV_DL_SIFPHYS = 4 // net_kev.h:58:1: + KEV_DL_SUBCLASS = 2 // net_kev.h:50:1: + KEV_DL_WAKEFLAGS_CHANGED = 17 // net_kev.h:71:1: + KEV_INET6_ADDR_DELETED = 3 // net_kev.h:93:1: + KEV_INET6_CHANGED_ADDR = 2 // net_kev.h:92:1: + KEV_INET6_DEFROUTER = 6 // net_kev.h:96:1: + KEV_INET6_NEW_LL_ADDR = 4 // net_kev.h:94:1: + KEV_INET6_NEW_RTADV_ADDR = 5 // net_kev.h:95:1: + KEV_INET6_NEW_USER_ADDR = 1 // net_kev.h:91:1: + KEV_INET6_REQUEST_NAT64_PREFIX = 7 // net_kev.h:97:1: + KEV_INET6_SUBCLASS = 6 // net_kev.h:89:1: + KEV_INET_ADDR_DELETED = 3 // net_kev.h:39:1: + KEV_INET_ARPCOLLISION = 7 // net_kev.h:43:1: + KEV_INET_ARPRTRALIVE = 10 // net_kev.h:48:1: + KEV_INET_ARPRTRFAILURE = 9 // net_kev.h:47:1: + KEV_INET_CHANGED_ADDR = 2 // net_kev.h:38:1: + KEV_INET_NEW_ADDR = 1 // net_kev.h:37:1: + KEV_INET_PORTINUSE = 8 // net_kev.h:45:1: + KEV_INET_SIFBRDADDR = 5 // net_kev.h:41:1: + KEV_INET_SIFDSTADDR = 4 // net_kev.h:40:1: + KEV_INET_SIFNETMASK = 6 // net_kev.h:42:1: + KEV_INET_SUBCLASS = 1 // net_kev.h:35:1: + LITTLE_ENDIAN = 1234 // endian.h:71:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + MCAST_BLOCK_SOURCE = 84 // in.h:478:1: + MCAST_EXCLUDE = 2 // in.h:588:1: + MCAST_INCLUDE = 1 // in.h:587:1: + MCAST_JOIN_GROUP = 80 // in.h:474:1: + MCAST_JOIN_SOURCE_GROUP = 82 // in.h:476:1: + MCAST_LEAVE_GROUP = 81 // in.h:475:1: + MCAST_LEAVE_SOURCE_GROUP = 83 // in.h:477:1: + MCAST_UNBLOCK_SOURCE = 85 // in.h:479:1: + MCAST_UNDEFINED = 0 // in.h:586:1: + MSG_CTRUNC = 0x20 // socket.h:569:1: + MSG_DONTROUTE = 0x4 // socket.h:566:1: + MSG_DONTWAIT = 0x80 // socket.h:572:1: + MSG_EOF = 0x100 // socket.h:573:1: + MSG_EOR = 0x8 // socket.h:567:1: + MSG_FLUSH = 0x400 // socket.h:578:1: + MSG_HAVEMORE = 0x2000 // socket.h:581:1: + MSG_HOLD = 0x800 // socket.h:579:1: + MSG_NEEDSA = 0x10000 // socket.h:584:1: + MSG_NOSIGNAL = 0x80000 // socket.h:588:1: + MSG_OOB = 0x1 // socket.h:564:1: + MSG_PEEK = 0x2 // socket.h:565:1: + MSG_RCVMORE = 0x4000 // socket.h:582:1: + MSG_SEND = 0x1000 // socket.h:580:1: + MSG_TRUNC = 0x10 // socket.h:568:1: + MSG_WAITALL = 0x40 // socket.h:570:1: + MSG_WAITSTREAM = 0x200 // socket.h:576:1: + NBBY = 8 // types.h:186:1: + NETDB_INTERNAL = -1 // netdb.h:171:1: + NETDB_SUCCESS = 0 // netdb.h:172:1: + NETSVC_MRKNG_LVL_L2 = 1 // socket.h:287:1: + NETSVC_MRKNG_LVL_L3L2_ALL = 2 // socket.h:288:1: + NETSVC_MRKNG_LVL_L3L2_BK = 3 // socket.h:289:1: + NETSVC_MRKNG_UNKNOWN = 0 // socket.h:286:1: + NET_MAXID = 41 // socket.h:512:1: + NET_RT_DUMP = 1 // socket.h:525:1: + NET_RT_DUMP2 = 7 // socket.h:531:1: + NET_RT_FLAGS = 2 // socket.h:526:1: + NET_RT_FLAGS_PRIV = 10 // socket.h:536:1: + NET_RT_IFLIST = 3 // socket.h:527:1: + NET_RT_IFLIST2 = 6 // socket.h:530:1: + NET_RT_MAXID = 11 // socket.h:537:1: + NET_RT_STAT = 4 // socket.h:528:1: + NET_RT_TRASH = 5 // socket.h:529:1: + NET_SERVICE_TYPE_AV = 6 // socket.h:280:1: + NET_SERVICE_TYPE_BE = 0 // socket.h:274:1: + NET_SERVICE_TYPE_BK = 1 // socket.h:275:1: + NET_SERVICE_TYPE_OAM = 7 // socket.h:281:1: + NET_SERVICE_TYPE_RD = 8 // socket.h:282:1: + NET_SERVICE_TYPE_RV = 5 // socket.h:279:1: + NET_SERVICE_TYPE_SIG = 2 // socket.h:276:1: + NET_SERVICE_TYPE_VI = 3 // socket.h:277:1: + NET_SERVICE_TYPE_VO = 4 // socket.h:278:1: + NI_DGRAM = 0x00000010 // netdb.h:252:1: + NI_MAXHOST = 1025 // netdb.h:241:1: + NI_MAXSERV = 32 // netdb.h:242:1: + NI_NAMEREQD = 0x00000004 // netdb.h:249:1: + NI_NOFQDN = 0x00000001 // netdb.h:247:1: + NI_NUMERICHOST = 0x00000002 // netdb.h:248:1: + NI_NUMERICSCOPE = 0x00000100 // netdb.h:251:1: + NI_NUMERICSERV = 0x00000008 // netdb.h:250:1: + NI_WITHSCOPEID = 0x00000020 // netdb.h:254:1: + NO_ADDRESS = 4 // netdb.h:179:1: + NO_DATA = 4 // netdb.h:177:1: + NO_RECOVERY = 3 // netdb.h:176:1: + PDP_ENDIAN = 3412 // endian.h:73:1: + PF_APPLETALK = 16 // socket.h:474:1: + PF_CCITT = 10 // socket.h:468:1: + PF_CHAOS = 5 // socket.h:462:1: + PF_CNT = 21 // socket.h:479:1: + PF_COIP = 20 // socket.h:478:1: + PF_DATAKIT = 9 // socket.h:467:1: + PF_DECnet = 12 // socket.h:470:1: + PF_DLI = 13 // socket.h:471:1: + PF_ECMA = 8 // socket.h:466:1: + PF_HYLINK = 15 // socket.h:473:1: + PF_IMPLINK = 3 // socket.h:460:1: + PF_INET = 2 // socket.h:459:1: + PF_INET6 = 30 // socket.h:487:1: + PF_IPX = 23 // socket.h:481:1: + PF_ISDN = 28 // socket.h:485:1: + PF_ISO = 7 // socket.h:464:1: + PF_KEY = 29 // socket.h:486:1: + PF_LAT = 14 // socket.h:472:1: + PF_LINK = 18 // socket.h:476:1: + PF_LOCAL = 1 // socket.h:457:1: + PF_MAX = 41 // socket.h:495:1: + PF_NATM = 31 // socket.h:488:1: + PF_NDRV = 27 // socket.h:484:1: + PF_NETBIOS = 33 // socket.h:490:1: + PF_NS = 6 // socket.h:463:1: + PF_OSI = 7 // socket.h:465:1: + PF_PIP = 25 // socket.h:483:1: + PF_PPP = 34 // socket.h:491:1: + PF_PUP = 4 // socket.h:461:1: + PF_RESERVED_36 = 36 // socket.h:492:1: + PF_ROUTE = 17 // socket.h:475:1: + PF_RTIP = 22 // socket.h:482:1: + PF_SIP = 24 // socket.h:480:1: + PF_SNA = 11 // socket.h:469:1: + PF_SYSTEM = 32 // socket.h:489:1: + PF_UNIX = 1 // socket.h:458:1: + PF_UNSPEC = 0 // socket.h:456:1: + PF_UTUN = 38 // socket.h:493:1: + PF_VSOCK = 40 // socket.h:494:1: + PF_XTP = 19 // socket.h:477:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + RSIZE_MAX = 9223372036854775807 // stdint.h:658:1: + SAE_ASSOCID_ANY = 0 // socket.h:294:1: + SAE_CONNID_ANY = 0 // socket.h:298:1: + SCM_CREDS = 0x03 // socket.h:674:1: + SCM_RIGHTS = 0x01 // socket.h:671:1: + SCM_TIMESTAMP = 0x02 // socket.h:673:1: + SCM_TIMESTAMP_MONOTONIC = 0x04 // socket.h:675:1: + SCOPE_DELIMITER = 37 // netdb.h:259:1: + SHUT_RD = 0 // socket.h:683:1: + SHUT_RDWR = 2 // socket.h:685:1: + SHUT_WR = 1 // socket.h:684:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIN6_LEN = 0 // in6.h:168:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + SOCK_DGRAM = 2 // socket.h:113:1: + SOCK_MAXADDRLEN = 255 // socket.h:419:1: + SOCK_RAW = 3 // socket.h:114:1: + SOCK_RDM = 4 // socket.h:116:1: + SOCK_SEQPACKET = 5 // socket.h:118:1: + SOCK_STREAM = 1 // socket.h:112:1: + SOL_SOCKET = 0xffff // socket.h:352:1: + SOMAXCONN = 128 // socket.h:546:1: + SONPX_SETOPTSHUT = 0x000000001 // socket.h:342:1: + SO_ACCEPTCONN = 0x0002 // socket.h:124:1: + SO_BROADCAST = 0x0020 // socket.h:128:1: + SO_DEBUG = 0x0001 // socket.h:123:1: + SO_DONTROUTE = 0x0010 // socket.h:127:1: + SO_DONTTRUNC = 0x2000 // socket.h:143:1: + SO_ERROR = 0x1007 // socket.h:161:1: + SO_KEEPALIVE = 0x0008 // socket.h:126:1: + SO_LABEL = 0x1010 // socket.h:164:1: + SO_LINGER = 0x0080 // socket.h:131:1: + SO_LINGER_SEC = 0x1080 // socket.h:177:1: + SO_NETSVC_MARKING_LEVEL = 0x1119 // socket.h:186:1: + SO_NET_SERVICE_TYPE = 0x1116 // socket.h:183:1: + SO_NKE = 0x1021 // socket.h:168:1: + SO_NOADDRERR = 0x1023 // socket.h:170:1: + SO_NOSIGPIPE = 0x1022 // socket.h:169:1: + SO_NOTIFYCONFLICT = 0x1026 // socket.h:174:1: + SO_NP_EXTENSIONS = 0x1083 // socket.h:179:1: + SO_NREAD = 0x1020 // socket.h:167:1: + SO_NUMRCVPKT = 0x1112 // socket.h:182:1: + SO_NWRITE = 0x1024 // socket.h:171:1: + SO_OOBINLINE = 0x0100 // socket.h:135:1: + SO_PEERLABEL = 0x1011 // socket.h:165:1: + SO_RANDOMPORT = 0x1082 // socket.h:178:1: + SO_RCVBUF = 0x1002 // socket.h:156:1: + SO_RCVLOWAT = 0x1004 // socket.h:158:1: + SO_RCVTIMEO = 0x1006 // socket.h:160:1: + SO_REUSEADDR = 0x0004 // socket.h:125:1: + SO_REUSEPORT = 0x0200 // socket.h:137:1: + SO_REUSESHAREUID = 0x1025 // socket.h:172:1: + SO_SNDBUF = 0x1001 // socket.h:155:1: + SO_SNDLOWAT = 0x1003 // socket.h:157:1: + SO_SNDTIMEO = 0x1005 // socket.h:159:1: + SO_TIMESTAMP = 0x0400 // socket.h:138:1: + SO_TIMESTAMP_MONOTONIC = 0x0800 // socket.h:139:1: + SO_TYPE = 0x1008 // socket.h:162:1: + SO_UPCALLCLOSEWAIT = 0x1027 // socket.h:175:1: + SO_USELOOPBACK = 0x0040 // socket.h:130:1: + SO_WANTMORE = 0x4000 // socket.h:145:1: + SO_WANTOOBFLAG = 0x8000 // socket.h:146:1: + TRY_AGAIN = 2 // netdb.h:175:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + X_ARM_ARCH_H = 0 // arch.h:29:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_ARM__ENDIAN_H_ = 0 // endian.h:43:1: + X_ARM__PARAM_H_ = 0 // _param.h:6:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__PARAM_H_ = 0 // _param.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NETDB_H_ = 0 // netdb.h:84:1: + X_NETINET6_IN6_H_ = 0 // in6.h:99:1: + X_NETINET_IN_H_ = 0 // in.h:65:1: + X_NET_NETKEV_H_ = 0 // net_kev.h:30:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS_OSBYTEORDERARM_H = 0 // OSByteOrder.h:6:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:94:1: + X_PATH_HOSTS = "/etc/hosts" // netdb.h:96:1: + X_PATH_NETWORKS = "/etc/networks" // netdb.h:97:1: + X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:98:1: + X_PATH_SERVICES = "/etc/services" // netdb.h:99:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:56:1: + X_QUAD_LOWWORD = 0 // endian.h:57:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SA_FAMILY_T = 0 // _sa_family_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SOCKLEN_T = 0 // _socklen_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SS_MAXSIZE = 128 // socket.h:434:1: + X_STRUCT_IOVEC = 0 // _iovec_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_SOCKET_H_ = 0 // socket.h:73:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: + Pseudo_AF_HDRCMPLT = 35 // socket.h:400:1: + Pseudo_AF_KEY = 29 // socket.h:392:1: + Pseudo_AF_PIP = 25 // socket.h:388:1: + Pseudo_AF_RTIP = 22 // socket.h:385:1: + Pseudo_AF_XTP = 19 // socket.h:382:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// ++Copyright++ 1980, 1983, 1988, 1993 +// - +// Copyright (c) 1980, 1983, 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. +// +// - +// Portions Copyright (c) 1993 by Digital Equipment Corporation. +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies, and that +// the name of Digital Equipment Corporation not be used in advertising or +// publicity pertaining to distribution of the document or software without +// specific, written prior permission. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL +// WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT +// CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +// DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +// PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +// ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +// SOFTWARE. +// - +// --Copyright-- + +// @(#)netdb.h 8.1 (Berkeley) 6/2/93 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type Socklen_t = X__darwin_socklen_t /* _socklen_t.h:31:33 */ +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// C99 7.18.4 Macros for minimum-width integer constants. +// +// The standard requires that integer constant macros be defined for all the +// minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width +// types are required, the corresponding integer constant macros are defined +// here. This implementation also defines minimum-width types for every other +// integer width that the target implements, so corresponding macros are +// defined below, too. +// +// These macros are defined using the same successive-shrinking approach as +// the type definitions above. It is likewise important that macros are defined +// in order of decending width. +// +// Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// C99 7.18.2.1 Limits of exact-width integer types. +// C99 7.18.2.2 Limits of minimum-width integer types. +// C99 7.18.2.3 Limits of fastest minimum-width integer types. +// +// The presence of limit macros are completely optional in C99. This +// implementation defines limits for all of the types (exact- and +// minimum-width) that it defines above, using the limits of the minimum-width +// type for any types that do not have exact-width representations. +// +// As in the type definitions, this section takes an approach of +// successive-shrinking to determine which limits to use for the standard (8, +// 16, 32, 64) bit widths when they don't have exact representations. It is +// therefore important that the definitions be kept in order of decending +// widths. +// +// Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// Some utility macros + +// C99 7.18.2.4 Limits of integer types capable of holding object pointers. +// C99 7.18.3 Limits of other integer types. + +// ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ +// is enabled. + +// C99 7.18.2.5 Limits of greatest-width integer types. + +// C99 7.18.3 Limits of other integer types. + +// 7.18.4.2 Macros for greatest-width integer constants. + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 +// $FreeBSD: src/sys/netinet/in.h,v 1.48.2.2 2001/04/21 14:53:06 ume Exp $ + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +//===---- stdint.h - Standard header for sized integer types --------------===* * +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// \*===----------------------------------------------------------------------=== + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ + +// Functions for byte reversed loads. + +type X_OSUnalignedU16 = struct{ F__val Uint16_t } /* OSByteOrder.h:64:1 */ + +type X_OSUnalignedU32 = struct{ F__val Uint32_t } /* OSByteOrder.h:68:1 */ + +type X_OSUnalignedU64 = struct{ F__val Uint64_t } /* OSByteOrder.h:72:1 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2006-2007 Apple Inc. All rights reserved. + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// Round p (pointer or byte index) up to a correctly-aligned value for all +// data types (int, long, ...). The result is unsigned int and must be +// cast to any desired pointer type. + +// Copyright (c) 2016-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Kernel event subclass identifiers for KEV_NETWORK_CLASS +// KEV_INET_SUBCLASS event codes + +// Define Data-Link event subclass, and associated +// events. + +// KEV_INET6_SUBCLASS event codes + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Definitions related to sockets: types, address families, options. + +// Data types. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Sa_family_t = X__uint8_t /* _sa_family_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The iovec structure shall be defined as described in . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* _iovec_t.h:31:1 */ + +// Types + +// Option flags per-socket. +// (ATOMIC proto) + +// Additional options, not kept in so_options. + +// When adding new socket-options, you need to make sure MPTCP supports these as well! + +// Network Service Type for option SO_NET_SERVICE_TYPE +// +// The vast majority of sockets should use Best Effort that is the default +// Network Service Type. Other Network Service Types have to be used only if +// the traffic actually matches the description of the Network Service Type. +// +// Network Service Types do not represent priorities but rather describe +// different categories of delay, jitter and loss parameters. +// Those parameters may influence protocols from layer 4 protocols like TCP +// to layer 2 protocols like Wi-Fi. The Network Service Type can determine +// how the traffic is queued and scheduled by the host networking stack and +// by other entities on the network like switches and routers. For example +// for Wi-Fi, the Network Service Type can select the marking of the +// layer 2 packet with the appropriate WMM Access Category. +// +// There is no point in attempting to game the system and use +// a Network Service Type that does not correspond to the actual +// traffic characteristic but one that seems to have a higher precedence. +// The reason is that for service classes that have lower tolerance +// for delay and jitter, the queues size is lower than for service +// classes that are more tolerant to delay and jitter. +// +// For example using a voice service type for bulk data transfer will lead +// to disastrous results as soon as congestion happens because the voice +// queue overflows and packets get dropped. This is not only bad for the bulk +// data transfer but it is also bad for VoIP apps that legitimately are using +// the voice service type. +// +// The characteristics of the Network Service Types are based on the service +// classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service +// Classes" +// +// When system detects the outgoing interface belongs to a DiffServ domain +// that follows the recommendation of the IETF draft "Guidelines for DiffServ to +// IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value +// that corresponds to Network Service Type. +// +// NET_SERVICE_TYPE_BE +// "Best Effort", unclassified/standard. This is the default service +// class and cover the majority of the traffic. +// +// NET_SERVICE_TYPE_BK +// "Background", high delay tolerant, loss tolerant. elastic flow, +// variable size & long-lived. E.g: non-interactive network bulk transfer +// like synching or backup. +// +// NET_SERVICE_TYPE_RD +// "Responsive Data", a notch higher than "Best Effort", medium delay +// tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, +// instant messaging, for which there is a sense of interactivity and +// urgency (user waiting for output). +// +// NET_SERVICE_TYPE_OAM +// "Operations, Administration, and Management", medium delay tolerant, +// low-medium loss tolerant, elastic & inelastic flows, variable size. +// E.g. VPN tunnels. +// +// NET_SERVICE_TYPE_AV +// "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium +// loss tolerant, elastic flow, constant packet interval, variable rate +// and size. E.g. video and audio playback with buffering. +// +// NET_SERVICE_TYPE_RV +// "Responsive Multimedia Audio/Video", low delay tolerant, low-medium +// loss tolerant, elastic flow, variable packet interval, rate and size. +// E.g. screen sharing. +// +// NET_SERVICE_TYPE_VI +// "Interactive Video", low delay tolerant, low-medium loss tolerant, +// elastic flow, constant packet interval, variable rate & size. E.g. +// video telephony. +// +// NET_SERVICE_TYPE_SIG +// "Signaling", low delay tolerant, low loss tolerant, inelastic flow, +// jitter tolerant, rate is bursty but short, variable size. E.g. SIP. +// +// NET_SERVICE_TYPE_VO +// "Interactive Voice", very low delay tolerant, very low loss tolerant, +// inelastic flow, constant packet rate, somewhat fixed size. +// E.g. VoIP. + +// These are supported values for SO_NETSVC_MARKING_LEVEL + +type Sae_associd_t = X__uint32_t /* socket.h:293:20 */ + +type Sae_connid_t = X__uint32_t /* socket.h:297:20 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints = struct { + Fsae_srcif uint32 + F__ccgo_pad1 [4]byte + Fsae_srcaddr uintptr + Fsae_srcaddrlen Socklen_t + F__ccgo_pad2 [4]byte + Fsae_dstaddr uintptr + Fsae_dstaddrlen Socklen_t + F__ccgo_pad3 [4]byte +} /* socket.h:307:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sockaddr = struct { + Fsa_len X__uint8_t + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:307:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints_t = Sa_endpoints /* socket.h:313:3 */ + +// Structure used for manipulating linger option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:319:1 */ + +// Structure to control non-portable Sockets extension to POSIX +type So_np_extensions = struct { + Fnpx_flags U_int32_t + Fnpx_mask U_int32_t +} /* socket.h:337:1 */ + +// Structure used by kernel to pass protocol +// information in raw sockets. +type Sockproto = struct { + Fsp_family X__uint16_t + Fsp_protocol X__uint16_t +} /* socket.h:425:1 */ + +// RFC 2553: protocol-independent placeholder for socket addresses + +// [XSI] sockaddr_storage +type Sockaddr_storage = struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 +} /* socket.h:445:1 */ + +// Protocol families, same as address families for now. + +// These do not have socket-layer support: + +// Definitions for network related sysctl, CTL_NET. +// +// Second level is protocol family. +// Third level is protocol number. +// +// Further levels are defined by the individual families below. + +// PF_ROUTE - Routing table +// +// Three additional levels are defined: +// Fourth: address family, 0 is wildcard +// Fifth: type of info, defined below +// Sixth: flag(s) to mask with for NET_RT_FLAGS +// Allows read access non-local host's MAC address +// if the process has neighbor cache entitlement. + +// Maximum queue length specifiable by listen. + +// [XSI] Message header for recvmsg and sendmsg calls. +// Used value-result for recvmsg, value only for sendmsg. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__ccgo_pad2 [4]byte + Fmsg_control uintptr + Fmsg_controllen Socklen_t + Fmsg_flags int32 +} /* socket.h:552:1 */ + +// Header for ancillary data objects in msg_control buffer. +// Used for additional information with/about a datagram +// not expressible by flags. The format is a sequence +// of message elements headed by cmsghdr structures. +type Cmsghdr = struct { + Fcmsg_len Socklen_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:600:1 */ + +// given pointer to struct cmsghdr, return pointer to data + +// RFC 2292 requires to check msg_controllen, in case that the kernel returns +// an empty list for some reasons. + +// Given pointer to struct cmsghdr, return pointer to next cmsghdr +// RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) + +// RFC 2292 additions + +// "Socket"-level control message types: + +// howto arguments for shutdown(2), specified by Posix.1g. + +// sendfile(2) header/trailer struct +type Sf_hdtr = struct { + Fheaders uintptr + Fhdr_cnt int32 + F__ccgo_pad1 [4]byte + Ftrailers uintptr + Ftrl_cnt int32 + F__ccgo_pad2 [4]byte +} /* socket.h:691:1 */ + +// The following two #includes insure htonl and family are defined +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2004, 2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1987, 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. + +// Constants and structures defined by the internet system, +// Per RFC 790, September 1981, and numerous additions. + +// Protocols (RFC 1700) +// 55-57: Unassigned +// 101-252: Partly Unassigned +// 253-254: Experimentation and testing; 255: Reserved (RFC3692) +// BSD Private, local use, namespace incursion + +// last return value of *_input(), meaning "all job for this pkt is done". + +// Local port number conventions: +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// The default range is IPPORT_RESERVED through +// IPPORT_USERRESERVED, although that is settable by sysctl. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH changes the range of candidate port numbers +// into the "high" range. These are reserved for client outbound connections +// which do not want to be filtered by any firewalls. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. This +// convention is based on "vouchsafe" principles only. It is only secure +// if you trust the remote host to restrict these ports. +// +// The default range of ports and the high range can be changed by +// sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) +// +// Changing those values has bad security implications if you are +// using a a stateless firewall that is allowing packets outside of that +// range in order to allow transparent outgoing connections. +// +// Such a firewall configuration will generally depend on the use of these +// default values. If you change them, you may find your Security +// Administrator looking for you with a heavy object. +// +// For a slightly more orthodox text view on this: +// +// ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers +// +// port numbers are divided into three ranges: +// +// 0 - 1023 Well Known Ports +// 1024 - 49151 Registered Ports +// 49152 - 65535 Dynamic and/or Private Ports +// + +// Ports < IPPORT_RESERVED are reserved for +// privileged processes (e.g. root). (IP_PORTRANGE_LOW) +// Ports > IPPORT_USERRESERVED are reserved +// for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) + +// Default local port range to use by setting IP_PORTRANGE_HIGH + +// Scanning for a free reserved port return a value below IPPORT_RESERVED, +// but higher than IPPORT_RESERVEDSTART. Traditionally the start value was +// 512, but that conflicts with some well-known-services that firewalls may +// have a fit if we use. + +// Internet address (a structure for historical reasons) +type In_addr = struct{ Fs_addr In_addr_t } /* in.h:301:1 */ + +// Definitions of bits in internet address integers. +// On subnets, the decomposition of addresses to host and net parts +// is done according to subnet mask, not the masks here. + +// Socket address, internet style. +type Sockaddr_in = struct { + Fsin_len X__uint8_t + Fsin_family Sa_family_t + Fsin_port In_port_t + Fsin_addr struct{ Fs_addr In_addr_t } + Fsin_zero [8]int8 +} /* in.h:375:1 */ + +// Structure used to describe IP options. +// Used to store options internally, to pass them to a process, +// or to restore options retrieved earlier. +// The ip_dst is used for the first-hop gateway when using a source route +// (this gets put into the header proper). +type Ip_opts = struct { + Fip_dst struct{ Fs_addr In_addr_t } + Fip_opts [40]int8 +} /* in.h:398:1 */ + +// Options for use with [gs]etsockopt at the IP level. +// First word of comment is data type; bool is stored in int. +// for IPSEC + +// These older firewall socket option codes are maintained for backward compatibility. + +// IPv4 Source Filter Multicast API [RFC3678] + +// The following option is private; do not use it from user applications. + +// Protocol Independent Multicast API [RFC3678] + +// Defaults and limits for options + +// The imo_membership vector for each socket is now dynamically allocated at +// run-time, bounded by USHRT_MAX, and is reallocated when needed, sized +// according to a power-of-two increment. + +// Default resource limits for IPv4 multicast source filtering. +// These may be modified by sysctl. + +// Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. +type Ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:507:1 */ + +// Modified argument structure for IP_MULTICAST_IF, obtained from Linux. +// This is used to specify an interface index for multicast sends, as +// the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). +type Ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_address struct{ Fs_addr In_addr_t } + Fimr_ifindex int32 +} /* in.h:517:1 */ + +// Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] +type Ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_sourceaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:527:1 */ + +// Argument structures for Protocol-Independent Multicast Source +// Filter APIs. [RFC3678] +type Group_req = struct { + Fgr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } +} /* in.h:537:1 */ + +type Group_source_req = struct { + Fgsr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } + Fgsr_source struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } +} /* in.h:542:1 */ + +// The following structure is private; do not use it from user applications. +// It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between +// the RFC 3678 libc functions and the kernel. +type X__msfilterreq = struct { + Fmsfr_ifindex Uint32_t + Fmsfr_fmode Uint32_t + Fmsfr_nsrcs Uint32_t + F__msfr_align Uint32_t + Fmsfr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } + Fmsfr_srcs uintptr +} /* in.h:555:1 */ + +// Filter modes; also used to represent per-socket filter mode internally. + +// Argument for IP_PORTRANGE: +// - which range to search when port is unspecified at bind() or connect() + +// IP_PKTINFO: Packet information (equivalent to RFC2292 sec 5 for IPv4) +// This structure is used for +// +// 1. Receiving ancilliary data about the datagram if IP_PKTINFO sockopt is +// set on the socket. In this case ipi_ifindex will contain the interface +// index the datagram was received on, ipi_addr is the IP address the +// datagram was received to. +// +// 2. Sending a datagram using a specific interface or IP source address. +// if ipi_ifindex is set to non-zero when in_pktinfo is passed as +// ancilliary data of type IP_PKTINFO, this will be used as the source +// interface to send the datagram from. If ipi_ifindex is null, ip_spec_dst +// will be used for the source address. +// +// Note: if IP_BOUND_IF is set on the socket, ipi_ifindex in the ancillary +// IP_PKTINFO option silently overrides the bound interface when it is +// specified during send time. +type In_pktinfo = struct { + Fipi_ifindex uint32 + Fipi_spec_dst struct{ Fs_addr In_addr_t } + Fipi_addr struct{ Fs_addr In_addr_t } +} /* in.h:618:1 */ + +// Definitions for inet sysctl operations. +// +// Third level is protocol number. +// Fourth level is desired variable within that protocol. + +// Names for IP sysctl objects + +// INET6 stuff +// Copyright (c) 2008-2020 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +// 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 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Identification of the network protocol stack +// for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE +// has the table of implementation/integration differences. + +// Local port number conventions: +// +// Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), +// unless a kernel is compiled with IPNOPRIVPORTS defined. +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// +// The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although +// that is settable by sysctl(3); net.inet.ip.anonportmin and +// net.inet.ip.anonportmax respectively. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, +// and exists only for FreeBSD compatibility purposes. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. +// This convention is based on "vouchsafe" principles only. +// It is only secure if you trust the remote host to restrict these ports. +// The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + +// IPv6 address +type In6_addr = struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } +} /* in6.h:152:9 */ + +// Definitions for inet sysctl operations. +// +// Third level is protocol number. +// Fourth level is desired variable within that protocol. + +// Names for IP sysctl objects + +// INET6 stuff +// Copyright (c) 2008-2020 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +// 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 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Identification of the network protocol stack +// for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE +// has the table of implementation/integration differences. + +// Local port number conventions: +// +// Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), +// unless a kernel is compiled with IPNOPRIVPORTS defined. +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// +// The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although +// that is settable by sysctl(3); net.inet.ip.anonportmin and +// net.inet.ip.anonportmax respectively. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, +// and exists only for FreeBSD compatibility purposes. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. +// This convention is based on "vouchsafe" principles only. +// It is only secure if you trust the remote host to restrict these ports. +// The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + +// IPv6 address +type In6_addr_t = In6_addr /* in6.h:158:3 */ + +// Socket address for IPv6 +type Sockaddr_in6 = struct { + Fsin6_len X__uint8_t + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo X__uint32_t + Fsin6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fsin6_scope_id X__uint32_t +} /* in6.h:170:1 */ + +// Equality +// NOTE: Some of kernel programming environment (for example, openbsd/sparc) +// does not supply memcmp(). For userland memcmp() is preferred as it is +// in ANSI standard. + +// Unspecified + +// Loopback + +// IPv4 compatible + +// Mapped + +// 6to4 + +// KAME Scope Values + +// Unicast Scope +// Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). + +// Multicast + +// Unique Local IPv6 Unicast Addresses (per RFC 4193) + +// Multicast Scope + +// Options for use with [gs]etsockopt at the IPV6 level. +// First word of comment is data type; bool is stored in int. +// no hdrincl +// RFC 3542 define the following socket options in a manner incompatible +// with RFC 2292: +// IPV6_PKTINFO +// IPV6_HOPLIMIT +// IPV6_NEXTHOP +// IPV6_HOPOPTS +// IPV6_DSTOPTS +// IPV6_RTHDR +// +// To use the new IPv6 Sockets options introduced by RFC 3542 +// the constant __APPLE_USE_RFC_3542 must be defined before +// including +// +// To use the old IPv6 Sockets options from RFC 2292 +// the constant __APPLE_USE_RFC_2292 must be defined before +// including +// +// Note that eventually RFC 3542 is going to be the +// default and RFC 2292 will be obsolete. + +// buf/cmsghdr; set/get IPv6 options [obsoleted by RFC3542] + +// APPLE: NOTE the value of those 2 options is kept unchanged from +// previous version of darwin/OS X for binary compatibility reasons +// and differ from FreeBSD (values 57 and 61). See below. + +// to define items, should talk with KAME guys first, for *BSD compatibility + +// Defaults and limits for options + +// The im6o_membership vector for each socket is now dynamically allocated at +// run-time, bounded by USHRT_MAX, and is reallocated when needed, sized +// according to a power-of-two increment. + +// Default resource limits for IPv6 multicast source filtering. +// These may be modified by sysctl. + +// Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. +type Ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fipv6mr_interface uint32 +} /* in6.h:541:1 */ + +// IPV6_2292PKTINFO: Packet information(RFC2292 sec 5) +type In6_pktinfo = struct { + Fipi6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fipi6_ifindex uint32 +} /* in6.h:549:1 */ + +// Control structure for IPV6_RECVPATHMTU socket option. +type Ip6_mtuinfo = struct { + Fip6m_addr struct { + Fsin6_len X__uint8_t + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo X__uint32_t + Fsin6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fsin6_scope_id X__uint32_t + } + Fip6m_mtu Uint32_t +} /* in6.h:557:1 */ + +// Structures returned by network data base library. All addresses are +// supplied in host order, and returned in network order (suitable for +// use in system calls). +type Hostent = struct { + Fh_name uintptr + Fh_aliases uintptr + Fh_addrtype int32 + Fh_length int32 + Fh_addr_list uintptr +} /* netdb.h:112:1 */ + +// Assumption here is that a network number +// fits in an unsigned long -- probably a poor one. +type Netent = struct { + Fn_name uintptr + Fn_aliases uintptr + Fn_addrtype int32 + Fn_net Uint32_t +} /* netdb.h:127:1 */ + +type Servent = struct { + Fs_name uintptr + Fs_aliases uintptr + Fs_port int32 + F__ccgo_pad1 [4]byte + Fs_proto uintptr +} /* netdb.h:134:1 */ + +type Protoent = struct { + Fp_name uintptr + Fp_aliases uintptr + Fp_proto int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:141:1 */ + +type Addrinfo = struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen Socklen_t + F__ccgo_pad1 [4]byte + Fai_canonname uintptr + Fai_addr uintptr + Fai_next uintptr +} /* netdb.h:147:1 */ + +type Rpcent = struct { + Fr_name uintptr + Fr_aliases uintptr + Fr_number int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:159:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/netdb/netdb_linux_amd64.go b/internal/libc/netdb/netdb_linux_amd64.go new file mode 100644 index 0000000..f302d9b --- /dev/null +++ b/internal/libc/netdb/netdb_linux_amd64.go @@ -0,0 +1,3081 @@ +// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netdb/netdb_linux_amd64.go -pkgname netdb', DO NOT EDIT. + +package netdb + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_ALG = 38 // socket.h:133:1: + AF_APPLETALK = 5 // socket.h:99:1: + AF_ASH = 18 // socket.h:113:1: + AF_ATMPVC = 8 // socket.h:102:1: + AF_ATMSVC = 20 // socket.h:115:1: + AF_AX25 = 3 // socket.h:97:1: + AF_BLUETOOTH = 31 // socket.h:126:1: + AF_BRIDGE = 7 // socket.h:101:1: + AF_CAIF = 37 // socket.h:132:1: + AF_CAN = 29 // socket.h:124:1: + AF_DECnet = 12 // socket.h:106:1: + AF_ECONET = 19 // socket.h:114:1: + AF_FILE = 1 // socket.h:95:1: + AF_IB = 27 // socket.h:122:1: + AF_IEEE802154 = 36 // socket.h:131:1: + AF_INET = 2 // socket.h:96:1: + AF_INET6 = 10 // socket.h:104:1: + AF_IPX = 4 // socket.h:98:1: + AF_IRDA = 23 // socket.h:118:1: + AF_ISDN = 34 // socket.h:129:1: + AF_IUCV = 32 // socket.h:127:1: + AF_KCM = 41 // socket.h:136:1: + AF_KEY = 15 // socket.h:109:1: + AF_LLC = 26 // socket.h:121:1: + AF_LOCAL = 1 // socket.h:93:1: + AF_MAX = 45 // socket.h:140:1: + AF_MPLS = 28 // socket.h:123:1: + AF_NETBEUI = 13 // socket.h:107:1: + AF_NETLINK = 16 // socket.h:110:1: + AF_NETROM = 6 // socket.h:100:1: + AF_NFC = 39 // socket.h:134:1: + AF_PACKET = 17 // socket.h:112:1: + AF_PHONET = 35 // socket.h:130:1: + AF_PPPOX = 24 // socket.h:119:1: + AF_QIPCRTR = 42 // socket.h:137:1: + AF_RDS = 21 // socket.h:116:1: + AF_ROSE = 11 // socket.h:105:1: + AF_ROUTE = 16 // socket.h:111:1: + AF_RXRPC = 33 // socket.h:128:1: + AF_SECURITY = 14 // socket.h:108:1: + AF_SMC = 43 // socket.h:138:1: + AF_SNA = 22 // socket.h:117:1: + AF_TIPC = 30 // socket.h:125:1: + AF_UNIX = 1 // socket.h:94:1: + AF_UNSPEC = 0 // socket.h:92:1: + AF_VSOCK = 40 // socket.h:135:1: + AF_WANPIPE = 25 // socket.h:120:1: + AF_X25 = 9 // socket.h:103:1: + AF_XDP = 44 // socket.h:139:1: + AI_ADDRCONFIG = 0x0020 // netdb.h:601:1: + AI_ALL = 0x0010 // netdb.h:600:1: + AI_CANONNAME = 0x0002 // netdb.h:597:1: + AI_NUMERICHOST = 0x0004 // netdb.h:598:1: + AI_NUMERICSERV = 0x0400 // netdb.h:613:1: + AI_PASSIVE = 0x0001 // netdb.h:596:1: + AI_V4MAPPED = 0x0008 // netdb.h:599:1: + BIG_ENDIAN = 4321 // endian.h:28:1: + BYTE_ORDER = 1234 // endian.h:30:1: + EAI_AGAIN = -3 // netdb.h:618:1: + EAI_BADFLAGS = -1 // netdb.h:616:1: + EAI_FAIL = -4 // netdb.h:619:1: + EAI_FAMILY = -6 // netdb.h:620:1: + EAI_MEMORY = -10 // netdb.h:623:1: + EAI_NONAME = -2 // netdb.h:617:1: + EAI_OVERFLOW = -12 // netdb.h:625:1: + EAI_SERVICE = -8 // netdb.h:622:1: + EAI_SOCKTYPE = -7 // netdb.h:621:1: + EAI_SYSTEM = -11 // netdb.h:624:1: + FD_SETSIZE = 1024 // select.h:73:1: + FIOGETOWN = 0x8903 // sockios.h:8:1: + FIOSETOWN = 0x8901 // sockios.h:6:1: + HOST_NOT_FOUND = 1 // netdb.h:63:1: + INET6_ADDRSTRLEN = 46 // in.h:234:1: + INET_ADDRSTRLEN = 16 // in.h:233:1: + IN_CLASSA_HOST = 16777215 // in.h:169:1: + IN_CLASSA_MAX = 128 // in.h:170:1: + IN_CLASSA_NET = 0xff000000 // in.h:167:1: + IN_CLASSA_NSHIFT = 24 // in.h:168:1: + IN_CLASSB_HOST = 65535 // in.h:175:1: + IN_CLASSB_MAX = 65536 // in.h:176:1: + IN_CLASSB_NET = 0xffff0000 // in.h:173:1: + IN_CLASSB_NSHIFT = 16 // in.h:174:1: + IN_CLASSC_HOST = 255 // in.h:181:1: + IN_CLASSC_NET = 0xffffff00 // in.h:179:1: + IN_CLASSC_NSHIFT = 8 // in.h:180:1: + IN_LOOPBACKNET = 127 // in.h:197:1: + IPPORT_RESERVED1 = 1024 // netdb.h:79:1: + IPV6_2292DSTOPTS = 4 // in.h:171:1: + IPV6_2292HOPLIMIT = 8 // in.h:175:1: + IPV6_2292HOPOPTS = 3 // in.h:170:1: + IPV6_2292PKTINFO = 2 // in.h:169:1: + IPV6_2292PKTOPTIONS = 6 // in.h:173:1: + IPV6_2292RTHDR = 5 // in.h:172:1: + IPV6_ADDRFORM = 1 // in.h:168:1: + IPV6_ADDR_PREFERENCES = 72 // in.h:223:1: + IPV6_ADD_MEMBERSHIP = 20 // in.h:237:1: + IPV6_AUTHHDR = 10 // in.h:180:1: + IPV6_AUTOFLOWLABEL = 70 // in.h:220:1: + IPV6_CHECKSUM = 7 // in.h:174:1: + IPV6_DONTFRAG = 62 // in.h:214:1: + IPV6_DROP_MEMBERSHIP = 21 // in.h:238:1: + IPV6_DSTOPTS = 59 // in.h:211:1: + IPV6_FREEBIND = 78 // in.h:233:1: + IPV6_HDRINCL = 36 // in.h:198:1: + IPV6_HOPLIMIT = 52 // in.h:204:1: + IPV6_HOPOPTS = 54 // in.h:206:1: + IPV6_IPSEC_POLICY = 34 // in.h:196:1: + IPV6_JOIN_ANYCAST = 27 // in.h:192:1: + IPV6_JOIN_GROUP = 20 // in.h:185:1: + IPV6_LEAVE_ANYCAST = 28 // in.h:193:1: + IPV6_LEAVE_GROUP = 21 // in.h:186:1: + IPV6_MINHOPCOUNT = 73 // in.h:226:1: + IPV6_MTU = 24 // in.h:189:1: + IPV6_MTU_DISCOVER = 23 // in.h:188:1: + IPV6_MULTICAST_ALL = 29 // in.h:194:1: + IPV6_MULTICAST_HOPS = 18 // in.h:183:1: + IPV6_MULTICAST_IF = 17 // in.h:182:1: + IPV6_MULTICAST_LOOP = 19 // in.h:184:1: + IPV6_NEXTHOP = 9 // in.h:179:1: + IPV6_ORIGDSTADDR = 74 // in.h:228:1: + IPV6_PATHMTU = 61 // in.h:213:1: + IPV6_PKTINFO = 50 // in.h:202:1: + IPV6_PMTUDISC_DO = 2 // in.h:246:1: + IPV6_PMTUDISC_DONT = 0 // in.h:244:1: + IPV6_PMTUDISC_INTERFACE = 4 // in.h:248:1: + IPV6_PMTUDISC_OMIT = 5 // in.h:249:1: + IPV6_PMTUDISC_PROBE = 3 // in.h:247:1: + IPV6_PMTUDISC_WANT = 1 // in.h:245:1: + IPV6_RECVDSTOPTS = 58 // in.h:210:1: + IPV6_RECVERR = 25 // in.h:190:1: + IPV6_RECVFRAGSIZE = 77 // in.h:232:1: + IPV6_RECVHOPLIMIT = 51 // in.h:203:1: + IPV6_RECVHOPOPTS = 53 // in.h:205:1: + IPV6_RECVORIGDSTADDR = 74 // in.h:229:1: + IPV6_RECVPATHMTU = 60 // in.h:212:1: + IPV6_RECVPKTINFO = 49 // in.h:201:1: + IPV6_RECVRTHDR = 56 // in.h:208:1: + IPV6_RECVTCLASS = 66 // in.h:217:1: + IPV6_ROUTER_ALERT = 22 // in.h:187:1: + IPV6_ROUTER_ALERT_ISOLATE = 30 // in.h:195:1: + IPV6_RTHDR = 57 // in.h:209:1: + IPV6_RTHDRDSTOPTS = 55 // in.h:207:1: + IPV6_RTHDR_LOOSE = 0 // in.h:256:1: + IPV6_RTHDR_STRICT = 1 // in.h:257:1: + IPV6_RTHDR_TYPE_0 = 0 // in.h:259:1: + IPV6_RXDSTOPTS = 59 // in.h:241:1: + IPV6_RXHOPOPTS = 54 // in.h:240:1: + IPV6_TCLASS = 67 // in.h:218:1: + IPV6_TRANSPARENT = 75 // in.h:230:1: + IPV6_UNICAST_HOPS = 16 // in.h:181:1: + IPV6_UNICAST_IF = 76 // in.h:231:1: + IPV6_V6ONLY = 26 // in.h:191:1: + IPV6_XFRM_POLICY = 35 // in.h:197:1: + IP_ADD_MEMBERSHIP = 35 // in.h:121:1: + IP_ADD_SOURCE_MEMBERSHIP = 39 // in.h:125:1: + IP_BIND_ADDRESS_NO_PORT = 24 // in.h:103:1: + IP_BLOCK_SOURCE = 38 // in.h:124:1: + IP_CHECKSUM = 23 // in.h:102:1: + IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:135:1: + IP_DEFAULT_MULTICAST_TTL = 1 // in.h:134:1: + IP_DROP_MEMBERSHIP = 36 // in.h:122:1: + IP_DROP_SOURCE_MEMBERSHIP = 40 // in.h:126:1: + IP_FREEBIND = 15 // in.h:89:1: + IP_HDRINCL = 3 // in.h:48:1: + IP_IPSEC_POLICY = 16 // in.h:90:1: + IP_MAX_MEMBERSHIPS = 20 // in.h:136:1: + IP_MINTTL = 21 // in.h:100:1: + IP_MSFILTER = 41 // in.h:127:1: + IP_MTU = 14 // in.h:88:1: + IP_MTU_DISCOVER = 10 // in.h:84:1: + IP_MULTICAST_ALL = 49 // in.h:128:1: + IP_MULTICAST_IF = 32 // in.h:118:1: + IP_MULTICAST_LOOP = 34 // in.h:120:1: + IP_MULTICAST_TTL = 33 // in.h:119:1: + IP_NODEFRAG = 22 // in.h:101:1: + IP_OPTIONS = 4 // in.h:47:1: + IP_ORIGDSTADDR = 20 // in.h:97:1: + IP_PASSSEC = 18 // in.h:92:1: + IP_PKTINFO = 8 // in.h:81:1: + IP_PKTOPTIONS = 9 // in.h:82:1: + IP_PMTUDISC = 10 // in.h:83:1: + IP_PMTUDISC_DO = 2 // in.h:109:1: + IP_PMTUDISC_DONT = 0 // in.h:107:1: + IP_PMTUDISC_INTERFACE = 4 // in.h:114:1: + IP_PMTUDISC_OMIT = 5 // in.h:116:1: + IP_PMTUDISC_PROBE = 3 // in.h:110:1: + IP_PMTUDISC_WANT = 1 // in.h:108:1: + IP_RECVERR = 11 // in.h:85:1: + IP_RECVFRAGSIZE = 25 // in.h:104:1: + IP_RECVOPTS = 6 // in.h:51:1: + IP_RECVORIGDSTADDR = 20 // in.h:98:1: + IP_RECVRETOPTS = 7 // in.h:53:1: + IP_RECVTOS = 13 // in.h:87:1: + IP_RECVTTL = 12 // in.h:86:1: + IP_RETOPTS = 7 // in.h:54:1: + IP_ROUTER_ALERT = 5 // in.h:80:1: + IP_TOS = 1 // in.h:49:1: + IP_TRANSPARENT = 19 // in.h:93:1: + IP_TTL = 2 // in.h:50:1: + IP_UNBLOCK_SOURCE = 37 // in.h:123:1: + IP_UNICAST_IF = 50 // in.h:129:1: + IP_XFRM_POLICY = 17 // in.h:91:1: + LITTLE_ENDIAN = 1234 // endian.h:27:1: + MCAST_BLOCK_SOURCE = 43 // in.h:67:1: + MCAST_EXCLUDE = 0 // in.h:76:1: + MCAST_INCLUDE = 1 // in.h:77:1: + MCAST_JOIN_GROUP = 42 // in.h:66:1: + MCAST_JOIN_SOURCE_GROUP = 46 // in.h:70:1: + MCAST_LEAVE_GROUP = 45 // in.h:69:1: + MCAST_LEAVE_SOURCE_GROUP = 47 // in.h:71:1: + MCAST_MSFILTER = 48 // in.h:72:1: + MCAST_UNBLOCK_SOURCE = 44 // in.h:68:1: + NETDB_INTERNAL = -1 // netdb.h:72:1: + NETDB_SUCCESS = 0 // netdb.h:73:1: + NI_DGRAM = 16 // netdb.h:646:1: + NI_MAXHOST = 1025 // netdb.h:638:1: + NI_MAXSERV = 32 // netdb.h:639:1: + NI_NAMEREQD = 8 // netdb.h:645:1: + NI_NOFQDN = 4 // netdb.h:644:1: + NI_NUMERICHOST = 1 // netdb.h:642:1: + NI_NUMERICSERV = 2 // netdb.h:643:1: + NO_ADDRESS = 4 // netdb.h:74:1: + NO_DATA = 4 // netdb.h:68:1: + NO_RECOVERY = 3 // netdb.h:66:1: + PDP_ENDIAN = 3412 // endian.h:29:1: + PF_ALG = 38 // socket.h:82:1: + PF_APPLETALK = 5 // socket.h:48:1: + PF_ASH = 18 // socket.h:62:1: + PF_ATMPVC = 8 // socket.h:51:1: + PF_ATMSVC = 20 // socket.h:64:1: + PF_AX25 = 3 // socket.h:46:1: + PF_BLUETOOTH = 31 // socket.h:75:1: + PF_BRIDGE = 7 // socket.h:50:1: + PF_CAIF = 37 // socket.h:81:1: + PF_CAN = 29 // socket.h:73:1: + PF_DECnet = 12 // socket.h:55:1: + PF_ECONET = 19 // socket.h:63:1: + PF_FILE = 1 // socket.h:44:1: + PF_IB = 27 // socket.h:71:1: + PF_IEEE802154 = 36 // socket.h:80:1: + PF_INET = 2 // socket.h:45:1: + PF_INET6 = 10 // socket.h:53:1: + PF_IPX = 4 // socket.h:47:1: + PF_IRDA = 23 // socket.h:67:1: + PF_ISDN = 34 // socket.h:78:1: + PF_IUCV = 32 // socket.h:76:1: + PF_KCM = 41 // socket.h:85:1: + PF_KEY = 15 // socket.h:58:1: + PF_LLC = 26 // socket.h:70:1: + PF_LOCAL = 1 // socket.h:42:1: + PF_MAX = 45 // socket.h:89:1: + PF_MPLS = 28 // socket.h:72:1: + PF_NETBEUI = 13 // socket.h:56:1: + PF_NETLINK = 16 // socket.h:59:1: + PF_NETROM = 6 // socket.h:49:1: + PF_NFC = 39 // socket.h:83:1: + PF_PACKET = 17 // socket.h:61:1: + PF_PHONET = 35 // socket.h:79:1: + PF_PPPOX = 24 // socket.h:68:1: + PF_QIPCRTR = 42 // socket.h:86:1: + PF_RDS = 21 // socket.h:65:1: + PF_ROSE = 11 // socket.h:54:1: + PF_ROUTE = 16 // socket.h:60:1: + PF_RXRPC = 33 // socket.h:77:1: + PF_SECURITY = 14 // socket.h:57:1: + PF_SMC = 43 // socket.h:87:1: + PF_SNA = 22 // socket.h:66:1: + PF_TIPC = 30 // socket.h:74:1: + PF_UNIX = 1 // socket.h:43:1: + PF_UNSPEC = 0 // socket.h:41:1: + PF_VSOCK = 40 // socket.h:84:1: + PF_WANPIPE = 25 // socket.h:69:1: + PF_X25 = 9 // socket.h:52:1: + PF_XDP = 44 // socket.h:88:1: + SCM_TIMESTAMP = 29 // socket.h:140:1: + SCM_TIMESTAMPING = 37 // socket.h:142:1: + SCM_TIMESTAMPING_OPT_STATS = 54 // socket.h:90:1: + SCM_TIMESTAMPING_PKTINFO = 58 // socket.h:98:1: + SCM_TIMESTAMPNS = 35 // socket.h:141:1: + SCM_TXTIME = 61 // socket.h:105:1: + SCM_WIFI_STATUS = 41 // socket.h:64:1: + SIOCATMARK = 0x8905 // sockios.h:10:1: + SIOCGPGRP = 0x8904 // sockios.h:9:1: + SIOCGSTAMP = 0x8906 // sockios.h:11:1: + SIOCGSTAMPNS = 0x8907 // sockios.h:12:1: + SIOCSPGRP = 0x8902 // sockios.h:7:1: + SOL_AAL = 265 // socket.h:151:1: + SOL_ALG = 279 // socket.h:165:1: + SOL_ATM = 264 // socket.h:150:1: + SOL_BLUETOOTH = 274 // socket.h:160:1: + SOL_CAIF = 278 // socket.h:164:1: + SOL_DCCP = 269 // socket.h:155:1: + SOL_DECNET = 261 // socket.h:147:1: + SOL_ICMPV6 = 58 // in.h:253:1: + SOL_IP = 0 // in.h:132:1: + SOL_IPV6 = 41 // in.h:252:1: + SOL_IRDA = 266 // socket.h:152:1: + SOL_IUCV = 277 // socket.h:163:1: + SOL_KCM = 281 // socket.h:167:1: + SOL_LLC = 268 // socket.h:154:1: + SOL_NETBEUI = 267 // socket.h:153:1: + SOL_NETLINK = 270 // socket.h:156:1: + SOL_NFC = 280 // socket.h:166:1: + SOL_PACKET = 263 // socket.h:149:1: + SOL_PNPIPE = 275 // socket.h:161:1: + SOL_PPPOL2TP = 273 // socket.h:159:1: + SOL_RAW = 255 // socket.h:146:1: + SOL_RDS = 276 // socket.h:162:1: + SOL_RXRPC = 272 // socket.h:158:1: + SOL_SOCKET = 1 // socket.h:9:1: + SOL_TIPC = 271 // socket.h:157:1: + SOL_TLS = 282 // socket.h:168:1: + SOL_X25 = 262 // socket.h:148:1: + SOL_XDP = 283 // socket.h:169:1: + SOMAXCONN = 4096 // socket.h:172:1: + SO_ACCEPTCONN = 30 // socket.h:51:1: + SO_ATTACH_BPF = 50 // socket.h:82:1: + SO_ATTACH_FILTER = 26 // socket.h:45:1: + SO_ATTACH_REUSEPORT_CBPF = 51 // socket.h:85:1: + SO_ATTACH_REUSEPORT_EBPF = 52 // socket.h:86:1: + SO_BINDTODEVICE = 25 // socket.h:42:1: + SO_BINDTOIFINDEX = 62 // socket.h:107:1: + SO_BPF_EXTENSIONS = 48 // socket.h:78:1: + SO_BROADCAST = 6 // socket.h:16:1: + SO_BSDCOMPAT = 14 // socket.h:26:1: + SO_BUSY_POLL = 46 // socket.h:74:1: + SO_CNX_ADVICE = 53 // socket.h:88:1: + SO_COOKIE = 57 // socket.h:96:1: + SO_DEBUG = 1 // socket.h:11:1: + SO_DETACH_BPF = 27 // socket.h:83:1: + SO_DETACH_FILTER = 27 // socket.h:46:1: + SO_DETACH_REUSEPORT_BPF = 68 // socket.h:120:1: + SO_DOMAIN = 39 // socket.h:59:1: + SO_DONTROUTE = 5 // socket.h:15:1: + SO_ERROR = 4 // socket.h:14:1: + SO_GET_FILTER = 26 // socket.h:47:1: + SO_INCOMING_CPU = 49 // socket.h:80:1: + SO_INCOMING_NAPI_ID = 56 // socket.h:94:1: + SO_KEEPALIVE = 9 // socket.h:21:1: + SO_LINGER = 13 // socket.h:25:1: + SO_LOCK_FILTER = 44 // socket.h:70:1: + SO_MARK = 36 // socket.h:56:1: + SO_MAX_PACING_RATE = 47 // socket.h:76:1: + SO_MEMINFO = 55 // socket.h:92:1: + SO_NOFCS = 43 // socket.h:68:1: + SO_NO_CHECK = 11 // socket.h:23:1: + SO_OOBINLINE = 10 // socket.h:22:1: + SO_PASSCRED = 16 // socket.h:29:1: + SO_PASSSEC = 34 // socket.h:54:1: + SO_PEEK_OFF = 42 // socket.h:65:1: + SO_PEERCRED = 17 // socket.h:30:1: + SO_PEERGROUPS = 59 // socket.h:100:1: + SO_PEERNAME = 28 // socket.h:49:1: + SO_PEERSEC = 31 // socket.h:53:1: + SO_PRIORITY = 12 // socket.h:24:1: + SO_PROTOCOL = 38 // socket.h:58:1: + SO_RCVBUF = 8 // socket.h:18:1: + SO_RCVBUFFORCE = 33 // socket.h:20:1: + SO_RCVLOWAT = 18 // socket.h:31:1: + SO_RCVTIMEO = 20 // socket.h:129:1: + SO_RCVTIMEO_NEW = 66 // socket.h:117:1: + SO_RCVTIMEO_OLD = 20 // socket.h:33:1: + SO_REUSEADDR = 2 // socket.h:12:1: + SO_REUSEPORT = 15 // socket.h:27:1: + SO_RXQ_OVFL = 40 // socket.h:61:1: + SO_SECURITY_AUTHENTICATION = 22 // socket.h:38:1: + SO_SECURITY_ENCRYPTION_NETWORK = 24 // socket.h:40:1: + SO_SECURITY_ENCRYPTION_TRANSPORT = 23 // socket.h:39:1: + SO_SELECT_ERR_QUEUE = 45 // socket.h:72:1: + SO_SNDBUF = 7 // socket.h:17:1: + SO_SNDBUFFORCE = 32 // socket.h:19:1: + SO_SNDLOWAT = 19 // socket.h:32:1: + SO_SNDTIMEO = 21 // socket.h:130:1: + SO_SNDTIMEO_NEW = 67 // socket.h:118:1: + SO_SNDTIMEO_OLD = 21 // socket.h:34:1: + SO_TIMESTAMP = 29 // socket.h:125:1: + SO_TIMESTAMPING = 37 // socket.h:127:1: + SO_TIMESTAMPING_NEW = 65 // socket.h:115:1: + SO_TIMESTAMPING_OLD = 37 // socket.h:111:1: + SO_TIMESTAMPNS = 35 // socket.h:126:1: + SO_TIMESTAMPNS_NEW = 64 // socket.h:114:1: + SO_TIMESTAMPNS_OLD = 35 // socket.h:110:1: + SO_TIMESTAMP_NEW = 63 // socket.h:113:1: + SO_TIMESTAMP_OLD = 29 // socket.h:109:1: + SO_TXTIME = 61 // socket.h:104:1: + SO_TYPE = 3 // socket.h:13:1: + SO_WIFI_STATUS = 41 // socket.h:63:1: + SO_ZEROCOPY = 60 // socket.h:102:1: + TRY_AGAIN = 2 // netdb.h:64:1: + X_ASM_X86_POSIX_TYPES_64_H = 0 // posix_types_64.h:3:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_SOCKADDR_H = 1 // sockaddr.h:24:1: + X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: + X_BITS_STDINT_UINTN_H = 1 // stdint-uintn.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_ENDIAN_H = 1 // endian.h:19:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LINUX_POSIX_TYPES_H = 0 // posix_types.h:3:1: + X_LP64 = 1 // :284:1: + X_NETDB_H = 1 // netdb.h:23:1: + X_NETINET_IN_H = 1 // in.h:19:1: + X_PATH_HEQUIV = "/etc/hosts.equiv" // netdb.h:43:1: + X_PATH_HOSTS = "/etc/hosts" // netdb.h:44:1: + X_PATH_NETWORKS = "/etc/networks" // netdb.h:45:1: + X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" // netdb.h:46:1: + X_PATH_PROTOCOLS = "/etc/protocols" // netdb.h:47:1: + X_PATH_SERVICES = "/etc/services" // netdb.h:48:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_RPC_NETDB_H = 1 // netdb.h:37:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_SS_SIZE = 128 // sockaddr.h:40:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SELECT_H = 1 // select.h:22:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_SYS_SOCKET_H = 1 // socket.h:20:1: + X_SYS_TYPES_H = 1 // types.h:23:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// Standard well-known ports. +const ( /* in.h:122:1: */ + IPPORT_ECHO = 7 // Echo service. + IPPORT_DISCARD = 9 // Discard transmissions service. + IPPORT_SYSTAT = 11 // System status service. + IPPORT_DAYTIME = 13 // Time of day service. + IPPORT_NETSTAT = 15 // Network status service. + IPPORT_FTP = 21 // File Transfer Protocol. + IPPORT_TELNET = 23 // Telnet protocol. + IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. + IPPORT_TIMESERVER = 37 // Timeserver service. + IPPORT_NAMESERVER = 42 // Domain Name Service. + IPPORT_WHOIS = 43 // Internet Whois service. + IPPORT_MTP = 57 + + IPPORT_TFTP = 69 // Trivial File Transfer Protocol. + IPPORT_RJE = 77 + IPPORT_FINGER = 79 // Finger service. + IPPORT_TTYLINK = 87 + IPPORT_SUPDUP = 95 // SUPDUP protocol. + + IPPORT_EXECSERVER = 512 // execd service. + IPPORT_LOGINSERVER = 513 // rlogind service. + IPPORT_CMDSERVER = 514 + IPPORT_EFSSERVER = 520 + + // UDP ports. + IPPORT_BIFFUDP = 512 + IPPORT_WHOSERVER = 513 + IPPORT_ROUTESERVER = 520 + + // Ports less than this value are reserved for privileged processes. + IPPORT_RESERVED = 1024 + + // Ports greater this value are reserved for (non-privileged) servers. + IPPORT_USERRESERVED = 5000 +) + +// Options for use with `getsockopt' and `setsockopt' at the IPv6 level. +// The first word in the comment at the right is the data type used; +// "bool" means a boolean value stored in an `int'. + +// Advanced API (RFC3542) (1). + +// Advanced API (RFC3542) (2). + +// RFC5014. + +// RFC5082. + +// Obsolete synonyms for the above. + +// IPV6_MTU_DISCOVER values. + +// Socket level values for IPv6. + +// Routing header options for IPv6. + +// Standard well-defined IP protocols. +const ( /* in.h:40:1: */ + IPPROTO_IP = 0 // Dummy protocol for TCP. + IPPROTO_ICMP = 1 // Internet Control Message Protocol. + IPPROTO_IGMP = 2 // Internet Group Management Protocol. + IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). + IPPROTO_TCP = 6 // Transmission Control Protocol. + IPPROTO_EGP = 8 // Exterior Gateway Protocol. + IPPROTO_PUP = 12 // PUP protocol. + IPPROTO_UDP = 17 // User Datagram Protocol. + IPPROTO_IDP = 22 // XNS IDP protocol. + IPPROTO_TP = 29 // SO Transport Protocol Class 4. + IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. + IPPROTO_IPV6 = 41 // IPv6 header. + IPPROTO_RSVP = 46 // Reservation Protocol. + IPPROTO_GRE = 47 // General Routing Encapsulation. + IPPROTO_ESP = 50 // encapsulating security payload. + IPPROTO_AH = 51 // authentication header. + IPPROTO_MTP = 92 // Multicast Transport Protocol. + IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. + IPPROTO_ENCAP = 98 // Encapsulation Header. + IPPROTO_PIM = 103 // Protocol Independent Multicast. + IPPROTO_COMP = 108 // Compression Header Protocol. + IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. + IPPROTO_UDPLITE = 136 // UDP-Lite protocol. + IPPROTO_MPLS = 137 // MPLS in IP. + IPPROTO_RAW = 255 // Raw IP packets. + IPPROTO_MAX = 256 +) + +// If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel +// +// network headers first and we should use those ABI-identical definitions +// instead of our own, otherwise 0. +const ( /* in.h:99:1: */ + IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. + IPPROTO_ROUTING = 43 // IPv6 routing header. + IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. + IPPROTO_ICMPV6 = 58 // ICMPv6. + IPPROTO_NONE = 59 // IPv6 no next header. + IPPROTO_DSTOPTS = 60 // IPv6 destination options. + IPPROTO_MH = 135 +) + +// Bits in the FLAGS argument to `send', `recv', et al. +const ( /* socket.h:200:1: */ + MSG_OOB = 1 // Process out-of-band data. + MSG_PEEK = 2 // Peek at incoming messages. + MSG_DONTROUTE = 4 // Don't use local routing. + MSG_CTRUNC = 8 // Control data lost before delivery. + MSG_PROXY = 16 // Supply or ask second address. + MSG_TRUNC = 32 + MSG_DONTWAIT = 64 // Nonblocking IO. + MSG_EOR = 128 // End of record. + MSG_WAITALL = 256 // Wait for a full request. + MSG_FIN = 512 + MSG_SYN = 1024 + MSG_CONFIRM = 2048 // Confirm path validity. + MSG_RST = 4096 + MSG_ERRQUEUE = 8192 // Fetch message from error queue. + MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. + MSG_MORE = 32768 // Sender will send more. + MSG_WAITFORONE = 65536 // Wait for at least one packet to return. + MSG_BATCH = 262144 // sendmmsg: more messages coming. + MSG_ZEROCOPY = 67108864 // Use user data in kernel path. + MSG_FASTOPEN = 536870912 // Send data in TCP SYN. + + MSG_CMSG_CLOEXEC = 1073741824 +) + +// Socket level message types. This must match the definitions in +// +// . +const ( /* socket.h:332:1: */ + SCM_RIGHTS = 1 +) + +// Get the architecture-dependent definition of enum __socket_type. +// Define enum __socket_type for generic Linux. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Types of sockets. +const ( /* socket_type.h:24:1: */ + SOCK_STREAM = 1 // Sequenced, reliable, connection-based + // byte streams. + SOCK_DGRAM = 2 // Connectionless, unreliable datagrams + // of fixed maximum length. + SOCK_RAW = 3 // Raw protocol interface. + SOCK_RDM = 4 // Reliably-delivered messages. + SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, + // datagrams of fixed maximum length. + SOCK_DCCP = 6 // Datagram Congestion Control Protocol. + SOCK_PACKET = 10 // Linux specific way of getting packets + // at the dev level. For writing rarp and + // other similar things on the user level. + + // Flags to be ORed into the type parameter of socket and socketpair and + // used for the flags parameter of paccept. + + SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the + // new descriptor(s). + SOCK_NONBLOCK = 2048 +) + +// The following constants should be used for the second parameter of +// +// `shutdown'. +const ( /* socket.h:41:1: */ + SHUT_RD = 0 // No more receptions. + SHUT_WR = 1 // No more transmissions. + SHUT_RDWR = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// All data returned by the network data base library are supplied in +// host order and returned in network order (suitable for use in +// system calls). + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define uintN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type Uint8_t = X__uint8_t /* stdint-uintn.h:24:19 */ +type Uint16_t = X__uint16_t /* stdint-uintn.h:25:20 */ +type Uint32_t = X__uint32_t /* stdint-uintn.h:26:20 */ +type Uint64_t = X__uint64_t /* stdint-uintn.h:27:20 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Structure for scatter/gather I/O. +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* struct_iovec.h:26:1 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This operating system-specific header file defines the SOCK_*, PF_*, +// AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', +// `struct msghdr', and `struct linger' types. +// System-specific socket constants and types. Linux version. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +// Type for length arguments in socket calls. +type Socklen_t = X__socklen_t /* socket.h:33:21 */ + +// Protocol families. + +// Address families. + +// Socket level values. Others are defined in the appropriate headers. +// +// XXX These definitions also should go into the appropriate headers as +// far as they are available. + +// Maximum queue length specifiable by listen. + +// Get the definition of the macro to define the common sockaddr members. +// Definition of struct sockaddr_* common members and sizes, generic version. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// POSIX.1g specifies this type name for the `sa_family' member. +type Sa_family_t = uint16 /* sockaddr.h:28:28 */ + +// This macro is used to declare the initial common members +// of the data types used for socket addresses, `struct sockaddr', +// `struct sockaddr_in', `struct sockaddr_un', etc. + +// Size of struct sockaddr_storage. + +// Structure describing a generic socket address. +type Sockaddr = struct { + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:178:1 */ + +// Structure large enough to hold any socket address (with the historical +// exception of AF_UNIX). + +type Sockaddr_storage = struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 +} /* socket.h:191:1 */ + +// Structure describing messages sent by +// +// `sendmsg' and received by `recvmsg'. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen Size_t + Fmsg_control uintptr + Fmsg_controllen Size_t + Fmsg_flags int32 + F__ccgo_pad2 [4]byte +} /* socket.h:257:1 */ + +// Structure used for storage of ancillary data object information. +type Cmsghdr = struct { + F__ccgo_pad1 [0]uint64 + Fcmsg_len Size_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:275:1 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This allows for 1024 file descriptors: if NR_OPEN is ever grown +// beyond that you'll have to change this too. But 1024 fd's seem to be +// enough even for such "real" unices like OSF/1, so hopefully this is +// one limit that doesn't have to be changed [again]. +// +// Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in +// (and thus ) - but this is a more logical +// place for them. Solved by having dummy defines in . + +// This macro may have been defined in . But we always +// use the one here. + +type X__kernel_fd_set = struct{ Ffds_bits [16]uint64 } /* posix_types.h:27:3 */ + +// Type of a signal handler. +type X__kernel_sighandler_t = uintptr /* posix_types.h:30:14 */ + +// Type of a SYSV IPC key. +type X__kernel_key_t = int32 /* posix_types.h:33:13 */ +type X__kernel_mqd_t = int32 /* posix_types.h:34:13 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. Also, we cannot +// assume GCC is being used. + +type X__kernel_old_uid_t = uint16 /* posix_types_64.h:11:24 */ +type X__kernel_old_gid_t = uint16 /* posix_types_64.h:12:24 */ + +type X__kernel_old_dev_t = uint64 /* posix_types_64.h:15:23 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// There seems to be no way of detecting this automatically from user +// space, so 64 bit architectures should override this in their +// bitsperlong.h. In particular, an architecture that supports +// both 32 and 64 bit user space must not rely on CONFIG_64BIT +// to decide it, but rather check a compiler provided macro. + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. +// +// First the types that are often defined in different ways across +// architectures, so that you can override them. + +type X__kernel_long_t = int64 /* posix_types.h:15:15 */ +type X__kernel_ulong_t = uint64 /* posix_types.h:16:23 */ + +type X__kernel_ino_t = X__kernel_ulong_t /* posix_types.h:20:26 */ + +type X__kernel_mode_t = uint32 /* posix_types.h:24:22 */ + +type X__kernel_pid_t = int32 /* posix_types.h:28:14 */ + +type X__kernel_ipc_pid_t = int32 /* posix_types.h:32:14 */ + +type X__kernel_uid_t = uint32 /* posix_types.h:36:22 */ +type X__kernel_gid_t = uint32 /* posix_types.h:37:22 */ + +type X__kernel_suseconds_t = X__kernel_long_t /* posix_types.h:41:26 */ + +type X__kernel_daddr_t = int32 /* posix_types.h:45:14 */ + +type X__kernel_uid32_t = uint32 /* posix_types.h:49:22 */ +type X__kernel_gid32_t = uint32 /* posix_types.h:50:22 */ + +// Most 32 bit architectures use "unsigned int" size_t, +// and all 64 bit architectures use "unsigned long" size_t. +type X__kernel_size_t = X__kernel_ulong_t /* posix_types.h:72:26 */ +type X__kernel_ssize_t = X__kernel_long_t /* posix_types.h:73:25 */ +type X__kernel_ptrdiff_t = X__kernel_long_t /* posix_types.h:74:25 */ + +type X__kernel_fsid_t = struct{ Fval [2]int32 } /* posix_types.h:81:3 */ + +// anything below here should be completely generic +type X__kernel_off_t = X__kernel_long_t /* posix_types.h:87:25 */ +type X__kernel_loff_t = int64 /* posix_types.h:88:19 */ +type X__kernel_old_time_t = X__kernel_long_t /* posix_types.h:89:25 */ +type X__kernel_time_t = X__kernel_long_t /* posix_types.h:90:25 */ +type X__kernel_time64_t = int64 /* posix_types.h:91:19 */ +type X__kernel_clock_t = X__kernel_long_t /* posix_types.h:92:25 */ +type X__kernel_timer_t = int32 /* posix_types.h:93:14 */ +type X__kernel_clockid_t = int32 /* posix_types.h:94:14 */ +type X__kernel_caddr_t = uintptr /* posix_types.h:95:14 */ +type X__kernel_uid16_t = uint16 /* posix_types.h:96:24 */ +type X__kernel_gid16_t = uint16 /* posix_types.h:97:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// Socket-level I/O control calls. + +// For setsockopt(2) + +// Security levels - as per NRL IPv6 - don't actually do anything + +// Socket filtering + +// Instruct lower device to use last 4-bytes of skb data as FCS + +// on 64-bit and x32, avoid the ?: operator + +// Structure used to manipulate the SO_LINGER option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:361:1 */ + +// This is the 4.3 BSD `struct sockaddr' format, which is used as wire +// +// format in the grotty old 4.3 `talk' protocol. +type Osockaddr = struct { + Fsa_family uint16 + Fsa_data [14]uint8 +} /* struct_osockaddr.h:6:1 */ + +// Define some macros helping to catch buffer overflows. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Internet address. +type In_addr_t = Uint32_t /* in.h:30:18 */ +type In_addr = struct{ Fs_addr In_addr_t } /* in.h:31:1 */ + +// Get system-specific definitions. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Linux version. + +// If the application has already included linux/in6.h from a linux-based +// kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the +// defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo +// in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly. +// Neither the linux kernel nor glibc should break this ABI without coordination. +// In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check +// for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for +// maximum backwards compatibility. + +// Options for use with `getsockopt' and `setsockopt' at the IP level. +// The first word in the comment at the right is the data type used; +// "bool" means a boolean value stored in an `int'. +// For BSD compatibility. + +// TProxy original addresses + +// IP_MTU_DISCOVER arguments. +// Always use interface mtu (ignores dst pmtu) but don't set DF flag. +// Also incoming ICMP frag_needed notifications will be ignored on +// this socket to prevent accepting spoofed ones. +// Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented. + +// To select the IP level. + +// Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. +// +// The `ip_dst' field is used for the first-hop gateway when using a +// source route (this gets put into the header proper). +type Ip_opts = struct { + Fip_dst struct{ Fs_addr In_addr_t } + Fip_opts [40]int8 +} /* in.h:142:1 */ + +// Like `struct ip_mreq' but including interface specification by index. +type Ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_address struct{ Fs_addr In_addr_t } + Fimr_ifindex int32 +} /* in.h:149:1 */ + +// Structure used for IP_PKTINFO. +type In_pktinfo = struct { + Fipi_ifindex int32 + Fipi_spec_dst struct{ Fs_addr In_addr_t } + Fipi_addr struct{ Fs_addr In_addr_t } +} /* in.h:157:1 */ + +// Type to represent a port. +type In_port_t = Uint16_t /* in.h:119:18 */ + +// 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. + +// Address to accept any incoming messages. +// Address to send to all hosts. +// Address indicating an error return. + +// Network number for local host loopback. +// Address to loopback in software to local host. + +// Defines for Multicast INADDR. + +// IPv6 address +type In6_addr = struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } +} /* in.h:212:1 */ + +// ::1 + +// Structure describing an Internet socket address. +type Sockaddr_in = struct { + Fsin_family Sa_family_t + Fsin_port In_port_t + Fsin_addr struct{ Fs_addr In_addr_t } + Fsin_zero [8]uint8 +} /* in.h:238:1 */ + +// Ditto, for IPv6. +type Sockaddr_in6 = struct { + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo Uint32_t + Fsin6_addr struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } + } + Fsin6_scope_id Uint32_t +} /* in.h:253:1 */ + +// IPv4 multicast request. +type Ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:265:1 */ + +type Ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } + Fimr_sourceaddr struct{ Fs_addr In_addr_t } +} /* in.h:274:1 */ + +// Likewise, for IPv6. +type Ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } + } + Fipv6mr_interface uint32 +} /* in.h:289:1 */ + +// Multicast group request. +type Group_req = struct { + Fgr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:301:1 */ + +type Group_source_req = struct { + Fgsr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } + Fgsr_source struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:310:1 */ + +// Full-state filter operations. +type Ip_msfilter = struct { + Fimsf_multiaddr struct{ Fs_addr In_addr_t } + Fimsf_interface struct{ Fs_addr In_addr_t } + Fimsf_fmode Uint32_t + Fimsf_numsrc Uint32_t + Fimsf_slist [1]struct{ Fs_addr In_addr_t } +} /* in.h:324:1 */ + +type Group_filter = struct { + Fgf_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgf_group struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } + Fgf_fmode Uint32_t + Fgf_numsrc Uint32_t + Fgf_slist [1]struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:345:1 */ + +// Define uintN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This is necessary to make this include file properly replace the +// Sun version. +// @(#)netdb.h 2.1 88/07/29 3.9 RPCSRC +// Copyright (c) 2010, Oracle America, Inc. +// 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 "Oracle America, Inc." nor the names of its +// 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Cleaned up for GNU C library roland@gnu.ai.mit.edu: +// added multiple inclusion protection and use of . +// In GNU this file is #include'd by . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +type Rpcent = struct { + Fr_name uintptr + Fr_aliases uintptr + Fr_number int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:46:1 */ + +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Description of data base entry for a single network. NOTE: here a +// +// poor assumption is made. The network number is expected to fit +// into an unsigned long int variable. +type Netent = struct { + Fn_name uintptr + Fn_aliases uintptr + Fn_addrtype int32 + Fn_net Uint32_t +} /* netdb.h:26:1 */ + +// Description of data base entry for a single host. +type Hostent = struct { + Fh_name uintptr + Fh_aliases uintptr + Fh_addrtype int32 + Fh_length int32 + Fh_addr_list uintptr +} /* netdb.h:98:1 */ + +// Description of data base entry for a single service. +type Servent = struct { + Fs_name uintptr + Fs_aliases uintptr + Fs_port int32 + F__ccgo_pad1 [4]byte + Fs_proto uintptr +} /* netdb.h:255:1 */ + +// Description of data base entry for a single service. +type Protoent = struct { + Fp_name uintptr + Fp_aliases uintptr + Fp_proto int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:324:1 */ + +// Extension from POSIX.1:2001. +// Structure to contain information about address of a service provider. +type Addrinfo = struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen Socklen_t + F__ccgo_pad1 [4]byte + Fai_addr uintptr + Fai_canonname uintptr + Fai_next uintptr +} /* netdb.h:565:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/netdb/netdb_linux_arm64.go b/internal/libc/netdb/netdb_linux_arm64.go new file mode 100644 index 0000000..b6e69b4 --- /dev/null +++ b/internal/libc/netdb/netdb_linux_arm64.go @@ -0,0 +1,3191 @@ +// Code generated by 'ccgo netdb/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netdb/netdb_linux_arm64.go -pkgname netdb', DO NOT EDIT. + +package netdb + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_ALG = 38 + AF_APPLETALK = 5 + AF_ASH = 18 + AF_ATMPVC = 8 + AF_ATMSVC = 20 + AF_AX25 = 3 + AF_BLUETOOTH = 31 + AF_BRIDGE = 7 + AF_CAIF = 37 + AF_CAN = 29 + AF_DECnet = 12 + AF_ECONET = 19 + AF_FILE = 1 + AF_IB = 27 + AF_IEEE802154 = 36 + AF_INET = 2 + AF_INET6 = 10 + AF_IPX = 4 + AF_IRDA = 23 + AF_ISDN = 34 + AF_IUCV = 32 + AF_KCM = 41 + AF_KEY = 15 + AF_LLC = 26 + AF_LOCAL = 1 + AF_MAX = 45 + AF_MPLS = 28 + AF_NETBEUI = 13 + AF_NETLINK = 16 + AF_NETROM = 6 + AF_NFC = 39 + AF_PACKET = 17 + AF_PHONET = 35 + AF_PPPOX = 24 + AF_QIPCRTR = 42 + AF_RDS = 21 + AF_ROSE = 11 + AF_ROUTE = 16 + AF_RXRPC = 33 + AF_SECURITY = 14 + AF_SMC = 43 + AF_SNA = 22 + AF_TIPC = 30 + AF_UNIX = 1 + AF_UNSPEC = 0 + AF_VSOCK = 40 + AF_WANPIPE = 25 + AF_X25 = 9 + AF_XDP = 44 + AI_ADDRCONFIG = 0x0020 + AI_ALL = 0x0010 + AI_CANONNAME = 0x0002 + AI_NUMERICHOST = 0x0004 + AI_NUMERICSERV = 0x0400 + AI_PASSIVE = 0x0001 + AI_V4MAPPED = 0x0008 + BIG_ENDIAN = 4321 + BYTE_ORDER = 1234 + EAI_AGAIN = -3 + EAI_BADFLAGS = -1 + EAI_FAIL = -4 + EAI_FAMILY = -6 + EAI_MEMORY = -10 + EAI_NONAME = -2 + EAI_OVERFLOW = -12 + EAI_SERVICE = -8 + EAI_SOCKTYPE = -7 + EAI_SYSTEM = -11 + FD_SETSIZE = 1024 + FIOGETOWN = 0x8903 + FIOSETOWN = 0x8901 + HOST_NOT_FOUND = 1 + INET6_ADDRSTRLEN = 46 + INET_ADDRSTRLEN = 16 + IN_CLASSA_HOST = 16777215 + IN_CLASSA_MAX = 128 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 24 + IN_CLASSB_HOST = 65535 + IN_CLASSB_MAX = 65536 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 16 + IN_CLASSC_HOST = 255 + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 8 + IN_LOOPBACKNET = 127 + IPPORT_RESERVED1 = 1024 + IPV6_2292DSTOPTS = 4 + IPV6_2292HOPLIMIT = 8 + IPV6_2292HOPOPTS = 3 + IPV6_2292PKTINFO = 2 + IPV6_2292PKTOPTIONS = 6 + IPV6_2292RTHDR = 5 + IPV6_ADDRFORM = 1 + IPV6_ADDR_PREFERENCES = 72 + IPV6_ADD_MEMBERSHIP = 20 + IPV6_AUTHHDR = 10 + IPV6_AUTOFLOWLABEL = 70 + IPV6_CHECKSUM = 7 + IPV6_DONTFRAG = 62 + IPV6_DROP_MEMBERSHIP = 21 + IPV6_DSTOPTS = 59 + IPV6_FREEBIND = 78 + IPV6_HDRINCL = 36 + IPV6_HOPLIMIT = 52 + IPV6_HOPOPTS = 54 + IPV6_IPSEC_POLICY = 34 + IPV6_JOIN_ANYCAST = 27 + IPV6_JOIN_GROUP = 20 + IPV6_LEAVE_ANYCAST = 28 + IPV6_LEAVE_GROUP = 21 + IPV6_MINHOPCOUNT = 73 + IPV6_MTU = 24 + IPV6_MTU_DISCOVER = 23 + IPV6_MULTICAST_ALL = 29 + IPV6_MULTICAST_HOPS = 18 + IPV6_MULTICAST_IF = 17 + IPV6_MULTICAST_LOOP = 19 + IPV6_NEXTHOP = 9 + IPV6_ORIGDSTADDR = 74 + IPV6_PATHMTU = 61 + IPV6_PKTINFO = 50 + IPV6_PMTUDISC_DO = 2 + IPV6_PMTUDISC_DONT = 0 + IPV6_PMTUDISC_INTERFACE = 4 + IPV6_PMTUDISC_OMIT = 5 + IPV6_PMTUDISC_PROBE = 3 + IPV6_PMTUDISC_WANT = 1 + IPV6_RECVDSTOPTS = 58 + IPV6_RECVERR = 25 + IPV6_RECVFRAGSIZE = 77 + IPV6_RECVHOPLIMIT = 51 + IPV6_RECVHOPOPTS = 53 + IPV6_RECVORIGDSTADDR = 74 + IPV6_RECVPATHMTU = 60 + IPV6_RECVPKTINFO = 49 + IPV6_RECVRTHDR = 56 + IPV6_RECVTCLASS = 66 + IPV6_ROUTER_ALERT = 22 + IPV6_ROUTER_ALERT_ISOLATE = 30 + IPV6_RTHDR = 57 + IPV6_RTHDRDSTOPTS = 55 + IPV6_RTHDR_LOOSE = 0 + IPV6_RTHDR_STRICT = 1 + IPV6_RTHDR_TYPE_0 = 0 + IPV6_RXDSTOPTS = 59 + IPV6_RXHOPOPTS = 54 + IPV6_TCLASS = 67 + IPV6_TRANSPARENT = 75 + IPV6_UNICAST_HOPS = 16 + IPV6_UNICAST_IF = 76 + IPV6_V6ONLY = 26 + IPV6_XFRM_POLICY = 35 + IP_ADD_MEMBERSHIP = 35 + IP_ADD_SOURCE_MEMBERSHIP = 39 + IP_BIND_ADDRESS_NO_PORT = 24 + IP_BLOCK_SOURCE = 38 + IP_CHECKSUM = 23 + IP_DEFAULT_MULTICAST_LOOP = 1 + IP_DEFAULT_MULTICAST_TTL = 1 + IP_DROP_MEMBERSHIP = 36 + IP_DROP_SOURCE_MEMBERSHIP = 40 + IP_FREEBIND = 15 + IP_HDRINCL = 3 + IP_IPSEC_POLICY = 16 + IP_MAX_MEMBERSHIPS = 20 + IP_MINTTL = 21 + IP_MSFILTER = 41 + IP_MTU = 14 + IP_MTU_DISCOVER = 10 + IP_MULTICAST_ALL = 49 + IP_MULTICAST_IF = 32 + IP_MULTICAST_LOOP = 34 + IP_MULTICAST_TTL = 33 + IP_NODEFRAG = 22 + IP_OPTIONS = 4 + IP_ORIGDSTADDR = 20 + IP_PASSSEC = 18 + IP_PKTINFO = 8 + IP_PKTOPTIONS = 9 + IP_PMTUDISC = 10 + IP_PMTUDISC_DO = 2 + IP_PMTUDISC_DONT = 0 + IP_PMTUDISC_INTERFACE = 4 + IP_PMTUDISC_OMIT = 5 + IP_PMTUDISC_PROBE = 3 + IP_PMTUDISC_WANT = 1 + IP_RECVERR = 11 + IP_RECVFRAGSIZE = 25 + IP_RECVOPTS = 6 + IP_RECVORIGDSTADDR = 20 + IP_RECVRETOPTS = 7 + IP_RECVTOS = 13 + IP_RECVTTL = 12 + IP_RETOPTS = 7 + IP_ROUTER_ALERT = 5 + IP_TOS = 1 + IP_TRANSPARENT = 19 + IP_TTL = 2 + IP_UNBLOCK_SOURCE = 37 + IP_UNICAST_IF = 50 + IP_XFRM_POLICY = 17 + LITTLE_ENDIAN = 1234 + MCAST_BLOCK_SOURCE = 43 + MCAST_EXCLUDE = 0 + MCAST_INCLUDE = 1 + MCAST_JOIN_GROUP = 42 + MCAST_JOIN_SOURCE_GROUP = 46 + MCAST_LEAVE_GROUP = 45 + MCAST_LEAVE_SOURCE_GROUP = 47 + MCAST_MSFILTER = 48 + MCAST_UNBLOCK_SOURCE = 44 + NETDB_INTERNAL = -1 + NETDB_SUCCESS = 0 + NI_DGRAM = 16 + NI_MAXHOST = 1025 + NI_MAXSERV = 32 + NI_NAMEREQD = 8 + NI_NOFQDN = 4 + NI_NUMERICHOST = 1 + NI_NUMERICSERV = 2 + NO_ADDRESS = 4 + NO_DATA = 4 + NO_RECOVERY = 3 + PDP_ENDIAN = 3412 + PF_ALG = 38 + PF_APPLETALK = 5 + PF_ASH = 18 + PF_ATMPVC = 8 + PF_ATMSVC = 20 + PF_AX25 = 3 + PF_BLUETOOTH = 31 + PF_BRIDGE = 7 + PF_CAIF = 37 + PF_CAN = 29 + PF_DECnet = 12 + PF_ECONET = 19 + PF_FILE = 1 + PF_IB = 27 + PF_IEEE802154 = 36 + PF_INET = 2 + PF_INET6 = 10 + PF_IPX = 4 + PF_IRDA = 23 + PF_ISDN = 34 + PF_IUCV = 32 + PF_KCM = 41 + PF_KEY = 15 + PF_LLC = 26 + PF_LOCAL = 1 + PF_MAX = 45 + PF_MPLS = 28 + PF_NETBEUI = 13 + PF_NETLINK = 16 + PF_NETROM = 6 + PF_NFC = 39 + PF_PACKET = 17 + PF_PHONET = 35 + PF_PPPOX = 24 + PF_QIPCRTR = 42 + PF_RDS = 21 + PF_ROSE = 11 + PF_ROUTE = 16 + PF_RXRPC = 33 + PF_SECURITY = 14 + PF_SMC = 43 + PF_SNA = 22 + PF_TIPC = 30 + PF_UNIX = 1 + PF_UNSPEC = 0 + PF_VSOCK = 40 + PF_WANPIPE = 25 + PF_X25 = 9 + PF_XDP = 44 + SCM_TIMESTAMP = 29 + SCM_TIMESTAMPING = 37 + SCM_TIMESTAMPING_OPT_STATS = 54 + SCM_TIMESTAMPING_PKTINFO = 58 + SCM_TIMESTAMPNS = 35 + SCM_TXTIME = 61 + SCM_WIFI_STATUS = 41 + SIOCATMARK = 0x8905 + SIOCGPGRP = 0x8904 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCSPGRP = 0x8902 + SOL_AAL = 265 + SOL_ALG = 279 + SOL_ATM = 264 + SOL_BLUETOOTH = 274 + SOL_CAIF = 278 + SOL_DCCP = 269 + SOL_DECNET = 261 + SOL_ICMPV6 = 58 + SOL_IP = 0 + SOL_IPV6 = 41 + SOL_IRDA = 266 + SOL_IUCV = 277 + SOL_KCM = 281 + SOL_LLC = 268 + SOL_NETBEUI = 267 + SOL_NETLINK = 270 + SOL_NFC = 280 + SOL_PACKET = 263 + SOL_PNPIPE = 275 + SOL_PPPOL2TP = 273 + SOL_RAW = 255 + SOL_RDS = 276 + SOL_RXRPC = 272 + SOL_SOCKET = 1 + SOL_TIPC = 271 + SOL_TLS = 282 + SOL_X25 = 262 + SOL_XDP = 283 + SOMAXCONN = 4096 + SO_ACCEPTCONN = 30 + SO_ATTACH_BPF = 50 + SO_ATTACH_FILTER = 26 + SO_ATTACH_REUSEPORT_CBPF = 51 + SO_ATTACH_REUSEPORT_EBPF = 52 + SO_BINDTODEVICE = 25 + SO_BINDTOIFINDEX = 62 + SO_BPF_EXTENSIONS = 48 + SO_BROADCAST = 6 + SO_BSDCOMPAT = 14 + SO_BUSY_POLL = 46 + SO_CNX_ADVICE = 53 + SO_COOKIE = 57 + SO_DEBUG = 1 + SO_DETACH_BPF = 27 + SO_DETACH_FILTER = 27 + SO_DETACH_REUSEPORT_BPF = 68 + SO_DOMAIN = 39 + SO_DONTROUTE = 5 + SO_ERROR = 4 + SO_GET_FILTER = 26 + SO_INCOMING_CPU = 49 + SO_INCOMING_NAPI_ID = 56 + SO_KEEPALIVE = 9 + SO_LINGER = 13 + SO_LOCK_FILTER = 44 + SO_MARK = 36 + SO_MAX_PACING_RATE = 47 + SO_MEMINFO = 55 + SO_NOFCS = 43 + SO_NO_CHECK = 11 + SO_OOBINLINE = 10 + SO_PASSCRED = 16 + SO_PASSSEC = 34 + SO_PEEK_OFF = 42 + SO_PEERCRED = 17 + SO_PEERGROUPS = 59 + SO_PEERNAME = 28 + SO_PEERSEC = 31 + SO_PRIORITY = 12 + SO_PROTOCOL = 38 + SO_RCVBUF = 8 + SO_RCVBUFFORCE = 33 + SO_RCVLOWAT = 18 + SO_RCVTIMEO = 20 + SO_RCVTIMEO_NEW = 66 + SO_RCVTIMEO_OLD = 20 + SO_REUSEADDR = 2 + SO_REUSEPORT = 15 + SO_RXQ_OVFL = 40 + SO_SECURITY_AUTHENTICATION = 22 + SO_SECURITY_ENCRYPTION_NETWORK = 24 + SO_SECURITY_ENCRYPTION_TRANSPORT = 23 + SO_SELECT_ERR_QUEUE = 45 + SO_SNDBUF = 7 + SO_SNDBUFFORCE = 32 + SO_SNDLOWAT = 19 + SO_SNDTIMEO = 21 + SO_SNDTIMEO_NEW = 67 + SO_SNDTIMEO_OLD = 21 + SO_TIMESTAMP = 29 + SO_TIMESTAMPING = 37 + SO_TIMESTAMPING_NEW = 65 + SO_TIMESTAMPING_OLD = 37 + SO_TIMESTAMPNS = 35 + SO_TIMESTAMPNS_NEW = 64 + SO_TIMESTAMPNS_OLD = 35 + SO_TIMESTAMP_NEW = 63 + SO_TIMESTAMP_OLD = 29 + SO_TXTIME = 61 + SO_TYPE = 3 + SO_WIFI_STATUS = 41 + SO_ZEROCOPY = 60 + TRY_AGAIN = 2 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_SOCKADDR_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_STDINT_UINTN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LINUX_POSIX_TYPES_H = 0 + X_LP64 = 1 + X_NETDB_H = 1 + X_NETINET_IN_H = 1 + X_PATH_HEQUIV = "/etc/hosts.equiv" + X_PATH_HOSTS = "/etc/hosts" + X_PATH_NETWORKS = "/etc/networks" + X_PATH_NSSWITCH_CONF = "/etc/nsswitch.conf" + X_PATH_PROTOCOLS = "/etc/protocols" + X_PATH_SERVICES = "/etc/services" + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_RPC_NETDB_H = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_SS_SIZE = 128 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_SOCKET_H = 1 + X_SYS_TYPES_H = 1 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +// Bits in the FLAGS argument to `send', `recv', et al. +const ( /* socket.h:200:1: */ + MSG_OOB = 1 // Process out-of-band data. + MSG_PEEK = 2 // Peek at incoming messages. + MSG_DONTROUTE = 4 // Don't use local routing. + MSG_CTRUNC = 8 // Control data lost before delivery. + MSG_PROXY = 16 // Supply or ask second address. + MSG_TRUNC = 32 + MSG_DONTWAIT = 64 // Nonblocking IO. + MSG_EOR = 128 // End of record. + MSG_WAITALL = 256 // Wait for a full request. + MSG_FIN = 512 + MSG_SYN = 1024 + MSG_CONFIRM = 2048 // Confirm path validity. + MSG_RST = 4096 + MSG_ERRQUEUE = 8192 // Fetch message from error queue. + MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. + MSG_MORE = 32768 // Sender will send more. + MSG_WAITFORONE = 65536 // Wait for at least one packet to return. + MSG_BATCH = 262144 // sendmmsg: more messages coming. + MSG_ZEROCOPY = 67108864 // Use user data in kernel path. + MSG_FASTOPEN = 536870912 // Send data in TCP SYN. + + MSG_CMSG_CLOEXEC = 1073741824 +) + +// Socket level message types. This must match the definitions in +// +// . +const ( /* socket.h:332:1: */ + SCM_RIGHTS = 1 +) + +// Get the architecture-dependent definition of enum __socket_type. +// Define enum __socket_type for generic Linux. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Types of sockets. +const ( /* socket_type.h:24:1: */ + SOCK_STREAM = 1 // Sequenced, reliable, connection-based + // byte streams. + SOCK_DGRAM = 2 // Connectionless, unreliable datagrams + // of fixed maximum length. + SOCK_RAW = 3 // Raw protocol interface. + SOCK_RDM = 4 // Reliably-delivered messages. + SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, + // datagrams of fixed maximum length. + SOCK_DCCP = 6 // Datagram Congestion Control Protocol. + SOCK_PACKET = 10 // Linux specific way of getting packets + // at the dev level. For writing rarp and + // other similar things on the user level. + + // Flags to be ORed into the type parameter of socket and socketpair and + // used for the flags parameter of paccept. + + SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the + // new descriptor(s). + SOCK_NONBLOCK = 2048 +) + +// Standard well-known ports. +const ( /* in.h:122:1: */ + IPPORT_ECHO = 7 // Echo service. + IPPORT_DISCARD = 9 // Discard transmissions service. + IPPORT_SYSTAT = 11 // System status service. + IPPORT_DAYTIME = 13 // Time of day service. + IPPORT_NETSTAT = 15 // Network status service. + IPPORT_FTP = 21 // File Transfer Protocol. + IPPORT_TELNET = 23 // Telnet protocol. + IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. + IPPORT_TIMESERVER = 37 // Timeserver service. + IPPORT_NAMESERVER = 42 // Domain Name Service. + IPPORT_WHOIS = 43 // Internet Whois service. + IPPORT_MTP = 57 + + IPPORT_TFTP = 69 // Trivial File Transfer Protocol. + IPPORT_RJE = 77 + IPPORT_FINGER = 79 // Finger service. + IPPORT_TTYLINK = 87 + IPPORT_SUPDUP = 95 // SUPDUP protocol. + + IPPORT_EXECSERVER = 512 // execd service. + IPPORT_LOGINSERVER = 513 // rlogind service. + IPPORT_CMDSERVER = 514 + IPPORT_EFSSERVER = 520 + + // UDP ports. + IPPORT_BIFFUDP = 512 + IPPORT_WHOSERVER = 513 + IPPORT_ROUTESERVER = 520 + + // Ports less than this value are reserved for privileged processes. + IPPORT_RESERVED = 1024 + + // Ports greater this value are reserved for (non-privileged) servers. + IPPORT_USERRESERVED = 5000 +) + +// Options for use with `getsockopt' and `setsockopt' at the IPv6 level. +// The first word in the comment at the right is the data type used; +// "bool" means a boolean value stored in an `int'. + +// Advanced API (RFC3542) (1). + +// Advanced API (RFC3542) (2). + +// RFC5014. + +// RFC5082. + +// Obsolete synonyms for the above. + +// IPV6_MTU_DISCOVER values. + +// Socket level values for IPv6. + +// Routing header options for IPv6. + +// Standard well-defined IP protocols. +const ( /* in.h:40:1: */ + IPPROTO_IP = 0 // Dummy protocol for TCP. + IPPROTO_ICMP = 1 // Internet Control Message Protocol. + IPPROTO_IGMP = 2 // Internet Group Management Protocol. + IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). + IPPROTO_TCP = 6 // Transmission Control Protocol. + IPPROTO_EGP = 8 // Exterior Gateway Protocol. + IPPROTO_PUP = 12 // PUP protocol. + IPPROTO_UDP = 17 // User Datagram Protocol. + IPPROTO_IDP = 22 // XNS IDP protocol. + IPPROTO_TP = 29 // SO Transport Protocol Class 4. + IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. + IPPROTO_IPV6 = 41 // IPv6 header. + IPPROTO_RSVP = 46 // Reservation Protocol. + IPPROTO_GRE = 47 // General Routing Encapsulation. + IPPROTO_ESP = 50 // encapsulating security payload. + IPPROTO_AH = 51 // authentication header. + IPPROTO_MTP = 92 // Multicast Transport Protocol. + IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. + IPPROTO_ENCAP = 98 // Encapsulation Header. + IPPROTO_PIM = 103 // Protocol Independent Multicast. + IPPROTO_COMP = 108 // Compression Header Protocol. + IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. + IPPROTO_UDPLITE = 136 // UDP-Lite protocol. + IPPROTO_MPLS = 137 // MPLS in IP. + IPPROTO_RAW = 255 // Raw IP packets. + IPPROTO_MAX = 256 +) + +// If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel +// +// network headers first and we should use those ABI-identical definitions +// instead of our own, otherwise 0. +const ( /* in.h:99:1: */ + IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. + IPPROTO_ROUTING = 43 // IPv6 routing header. + IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. + IPPROTO_ICMPV6 = 58 // ICMPv6. + IPPROTO_NONE = 59 // IPv6 no next header. + IPPROTO_DSTOPTS = 60 // IPv6 destination options. + IPPROTO_MH = 135 +) + +// The following constants should be used for the second parameter of +// +// `shutdown'. +const ( /* socket.h:41:1: */ + SHUT_RD = 0 // No more receptions. + SHUT_WR = 1 // No more transmissions. + SHUT_RDWR = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// All data returned by the network data base library are supplied in +// host order and returned in network order (suitable for use in +// system calls). + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define uintN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type Uint8_t = X__uint8_t /* stdint-uintn.h:24:19 */ +type Uint16_t = X__uint16_t /* stdint-uintn.h:25:20 */ +type Uint32_t = X__uint32_t /* stdint-uintn.h:26:20 */ +type Uint64_t = X__uint64_t /* stdint-uintn.h:27:20 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Structure for scatter/gather I/O. +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* struct_iovec.h:26:1 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This operating system-specific header file defines the SOCK_*, PF_*, +// AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', +// `struct msghdr', and `struct linger' types. +// System-specific socket constants and types. Linux version. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We don't use `memset' because this would require a prototype and +// the array isn't too big. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +// Type for length arguments in socket calls. +type Socklen_t = X__socklen_t /* socket.h:33:21 */ + +// Protocol families. + +// Address families. + +// Socket level values. Others are defined in the appropriate headers. +// +// XXX These definitions also should go into the appropriate headers as +// far as they are available. + +// Maximum queue length specifiable by listen. + +// Get the definition of the macro to define the common sockaddr members. +// Definition of struct sockaddr_* common members and sizes, generic version. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// POSIX.1g specifies this type name for the `sa_family' member. +type Sa_family_t = uint16 /* sockaddr.h:28:28 */ + +// This macro is used to declare the initial common members +// of the data types used for socket addresses, `struct sockaddr', +// `struct sockaddr_in', `struct sockaddr_un', etc. + +// Size of struct sockaddr_storage. + +// Structure describing a generic socket address. +type Sockaddr = struct { + Fsa_family Sa_family_t + Fsa_data [14]uint8 +} /* socket.h:178:1 */ + +// Structure large enough to hold any socket address (with the historical +// exception of AF_UNIX). + +type Sockaddr_storage = struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 +} /* socket.h:191:1 */ + +// Structure describing messages sent by +// +// `sendmsg' and received by `recvmsg'. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen Size_t + Fmsg_control uintptr + Fmsg_controllen Size_t + Fmsg_flags int32 + F__ccgo_pad2 [4]byte +} /* socket.h:257:1 */ + +// Structure used for storage of ancillary data object information. +type Cmsghdr = struct { + F__ccgo_pad1 [0]uint64 + Fcmsg_len Size_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:275:1 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This allows for 1024 file descriptors: if NR_OPEN is ever grown +// beyond that you'll have to change this too. But 1024 fd's seem to be +// enough even for such "real" unices like OSF/1, so hopefully this is +// one limit that doesn't have to be changed [again]. +// +// Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in +// (and thus ) - but this is a more logical +// place for them. Solved by having dummy defines in . + +// This macro may have been defined in . But we always +// use the one here. + +type X__kernel_fd_set = struct{ Ffds_bits [16]uint64 } /* posix_types.h:27:3 */ + +// Type of a signal handler. +type X__kernel_sighandler_t = uintptr /* posix_types.h:30:14 */ + +// Type of a SYSV IPC key. +type X__kernel_key_t = int32 /* posix_types.h:33:13 */ +type X__kernel_mqd_t = int32 /* posix_types.h:34:13 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +type X__kernel_old_uid_t = uint16 /* posix_types.h:5:24 */ +type X__kernel_old_gid_t = uint16 /* posix_types.h:6:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// Copyright (C) 2012 ARM Ltd. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 . + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// There seems to be no way of detecting this automatically from user +// space, so 64 bit architectures should override this in their +// bitsperlong.h. In particular, an architecture that supports +// both 32 and 64 bit user space must not rely on CONFIG_64BIT +// to decide it, but rather check a compiler provided macro. + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. +// +// First the types that are often defined in different ways across +// architectures, so that you can override them. + +type X__kernel_long_t = int64 /* posix_types.h:15:15 */ +type X__kernel_ulong_t = uint64 /* posix_types.h:16:23 */ + +type X__kernel_ino_t = X__kernel_ulong_t /* posix_types.h:20:26 */ + +type X__kernel_mode_t = uint32 /* posix_types.h:24:22 */ + +type X__kernel_pid_t = int32 /* posix_types.h:28:14 */ + +type X__kernel_ipc_pid_t = int32 /* posix_types.h:32:14 */ + +type X__kernel_uid_t = uint32 /* posix_types.h:36:22 */ +type X__kernel_gid_t = uint32 /* posix_types.h:37:22 */ + +type X__kernel_suseconds_t = X__kernel_long_t /* posix_types.h:41:26 */ + +type X__kernel_daddr_t = int32 /* posix_types.h:45:14 */ + +type X__kernel_uid32_t = uint32 /* posix_types.h:49:22 */ +type X__kernel_gid32_t = uint32 /* posix_types.h:50:22 */ + +type X__kernel_old_dev_t = uint32 /* posix_types.h:59:22 */ + +// Most 32 bit architectures use "unsigned int" size_t, +// and all 64 bit architectures use "unsigned long" size_t. +type X__kernel_size_t = X__kernel_ulong_t /* posix_types.h:72:26 */ +type X__kernel_ssize_t = X__kernel_long_t /* posix_types.h:73:25 */ +type X__kernel_ptrdiff_t = X__kernel_long_t /* posix_types.h:74:25 */ + +type X__kernel_fsid_t = struct{ Fval [2]int32 } /* posix_types.h:81:3 */ + +// anything below here should be completely generic +type X__kernel_off_t = X__kernel_long_t /* posix_types.h:87:25 */ +type X__kernel_loff_t = int64 /* posix_types.h:88:19 */ +type X__kernel_old_time_t = X__kernel_long_t /* posix_types.h:89:25 */ +type X__kernel_time_t = X__kernel_long_t /* posix_types.h:90:25 */ +type X__kernel_time64_t = int64 /* posix_types.h:91:19 */ +type X__kernel_clock_t = X__kernel_long_t /* posix_types.h:92:25 */ +type X__kernel_timer_t = int32 /* posix_types.h:93:14 */ +type X__kernel_clockid_t = int32 /* posix_types.h:94:14 */ +type X__kernel_caddr_t = uintptr /* posix_types.h:95:14 */ +type X__kernel_uid16_t = uint16 /* posix_types.h:96:24 */ +type X__kernel_gid16_t = uint16 /* posix_types.h:97:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// Socket-level I/O control calls. + +// For setsockopt(2) + +// Security levels - as per NRL IPv6 - don't actually do anything + +// Socket filtering + +// Instruct lower device to use last 4-bytes of skb data as FCS + +// on 64-bit and x32, avoid the ?: operator + +// Structure used to manipulate the SO_LINGER option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:361:1 */ + +// This is the 4.3 BSD `struct sockaddr' format, which is used as wire +// +// format in the grotty old 4.3 `talk' protocol. +type Osockaddr = struct { + Fsa_family uint16 + Fsa_data [14]uint8 +} /* struct_osockaddr.h:6:1 */ + +// Define some macros helping to catch buffer overflows. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Internet address. +type In_addr_t = Uint32_t /* in.h:30:18 */ +type In_addr = struct{ Fs_addr In_addr_t } /* in.h:31:1 */ + +// Get system-specific definitions. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Linux version. + +// If the application has already included linux/in6.h from a linux-based +// kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the +// defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo +// in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly. +// Neither the linux kernel nor glibc should break this ABI without coordination. +// In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check +// for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for +// maximum backwards compatibility. + +// Options for use with `getsockopt' and `setsockopt' at the IP level. +// The first word in the comment at the right is the data type used; +// "bool" means a boolean value stored in an `int'. +// For BSD compatibility. + +// TProxy original addresses + +// IP_MTU_DISCOVER arguments. +// Always use interface mtu (ignores dst pmtu) but don't set DF flag. +// Also incoming ICMP frag_needed notifications will be ignored on +// this socket to prevent accepting spoofed ones. +// Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented. + +// To select the IP level. + +// Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. +// +// The `ip_dst' field is used for the first-hop gateway when using a +// source route (this gets put into the header proper). +type Ip_opts = struct { + Fip_dst struct{ Fs_addr In_addr_t } + Fip_opts [40]uint8 +} /* in.h:142:1 */ + +// Like `struct ip_mreq' but including interface specification by index. +type Ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_address struct{ Fs_addr In_addr_t } + Fimr_ifindex int32 +} /* in.h:149:1 */ + +// Structure used for IP_PKTINFO. +type In_pktinfo = struct { + Fipi_ifindex int32 + Fipi_spec_dst struct{ Fs_addr In_addr_t } + Fipi_addr struct{ Fs_addr In_addr_t } +} /* in.h:157:1 */ + +// Type to represent a port. +type In_port_t = Uint16_t /* in.h:119:18 */ + +// 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. + +// Address to accept any incoming messages. +// Address to send to all hosts. +// Address indicating an error return. + +// Network number for local host loopback. +// Address to loopback in software to local host. + +// Defines for Multicast INADDR. + +// IPv6 address +type In6_addr = struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } +} /* in.h:212:1 */ + +// ::1 + +// Structure describing an Internet socket address. +type Sockaddr_in = struct { + Fsin_family Sa_family_t + Fsin_port In_port_t + Fsin_addr struct{ Fs_addr In_addr_t } + Fsin_zero [8]uint8 +} /* in.h:238:1 */ + +// Ditto, for IPv6. +type Sockaddr_in6 = struct { + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo Uint32_t + Fsin6_addr struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } + } + Fsin6_scope_id Uint32_t +} /* in.h:253:1 */ + +// IPv4 multicast request. +type Ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:265:1 */ + +type Ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } + Fimr_sourceaddr struct{ Fs_addr In_addr_t } +} /* in.h:274:1 */ + +// Likewise, for IPv6. +type Ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } + } + Fipv6mr_interface uint32 +} /* in.h:289:1 */ + +// Multicast group request. +type Group_req = struct { + Fgr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } +} /* in.h:301:1 */ + +type Group_source_req = struct { + Fgsr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } + Fgsr_source struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } +} /* in.h:310:1 */ + +// Full-state filter operations. +type Ip_msfilter = struct { + Fimsf_multiaddr struct{ Fs_addr In_addr_t } + Fimsf_interface struct{ Fs_addr In_addr_t } + Fimsf_fmode Uint32_t + Fimsf_numsrc Uint32_t + Fimsf_slist [1]struct{ Fs_addr In_addr_t } +} /* in.h:324:1 */ + +type Group_filter = struct { + Fgf_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgf_group struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } + Fgf_fmode Uint32_t + Fgf_numsrc Uint32_t + Fgf_slist [1]struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } +} /* in.h:345:1 */ + +// Define uintN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This is necessary to make this include file properly replace the +// Sun version. +// @(#)netdb.h 2.1 88/07/29 3.9 RPCSRC +// Copyright (c) 2010, Oracle America, Inc. +// 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 "Oracle America, Inc." nor the names of its +// 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Cleaned up for GNU C library roland@gnu.ai.mit.edu: +// added multiple inclusion protection and use of . +// In GNU this file is #include'd by . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +type Rpcent = struct { + Fr_name uintptr + Fr_aliases uintptr + Fr_number int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:46:1 */ + +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Description of data base entry for a single network. NOTE: here a +// +// poor assumption is made. The network number is expected to fit +// into an unsigned long int variable. +type Netent = struct { + Fn_name uintptr + Fn_aliases uintptr + Fn_addrtype int32 + Fn_net Uint32_t +} /* netdb.h:26:1 */ + +// Description of data base entry for a single host. +type Hostent = struct { + Fh_name uintptr + Fh_aliases uintptr + Fh_addrtype int32 + Fh_length int32 + Fh_addr_list uintptr +} /* netdb.h:98:1 */ + +// Description of data base entry for a single service. +type Servent = struct { + Fs_name uintptr + Fs_aliases uintptr + Fs_port int32 + F__ccgo_pad1 [4]byte + Fs_proto uintptr +} /* netdb.h:255:1 */ + +// Description of data base entry for a single service. +type Protoent = struct { + Fp_name uintptr + Fp_aliases uintptr + Fp_proto int32 + F__ccgo_pad1 [4]byte +} /* netdb.h:324:1 */ + +// Extension from POSIX.1:2001. +// Structure to contain information about address of a service provider. +type Addrinfo = struct { + Fai_flags int32 + Fai_family int32 + Fai_socktype int32 + Fai_protocol int32 + Fai_addrlen Socklen_t + F__ccgo_pad1 [4]byte + Fai_addr uintptr + Fai_canonname uintptr + Fai_next uintptr +} /* netdb.h:565:1 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/netinet/in/capi_darwin_amd64.go b/internal/libc/netinet/in/capi_darwin_amd64.go new file mode 100644 index 0000000..5d34ac4 --- /dev/null +++ b/internal/libc/netinet/in/capi_darwin_amd64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo netinet/in/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netinet/in/in_darwin_amd64.go -pkgname in', DO NOT EDIT. + +package in + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/netinet/in/capi_darwin_arm64.go b/internal/libc/netinet/in/capi_darwin_arm64.go new file mode 100644 index 0000000..b46f3a4 --- /dev/null +++ b/internal/libc/netinet/in/capi_darwin_arm64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo netinet/in/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netinet/in/in_darwin_arm64.go -pkgname in', DO NOT EDIT. + +package in + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/netinet/in/capi_linux_amd64.go b/internal/libc/netinet/in/capi_linux_amd64.go new file mode 100644 index 0000000..953ed09 --- /dev/null +++ b/internal/libc/netinet/in/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo netinet/in/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netinet/in/in_linux_amd64.go -pkgname in', DO NOT EDIT. + +package in + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/netinet/in/capi_linux_arm64.go b/internal/libc/netinet/in/capi_linux_arm64.go new file mode 100644 index 0000000..d461979 --- /dev/null +++ b/internal/libc/netinet/in/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo netinet/in/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netinet/in/in_linux_arm64.go -pkgname in', DO NOT EDIT. + +package in + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/netinet/in/in_darwin_amd64.go b/internal/libc/netinet/in/in_darwin_amd64.go new file mode 100644 index 0000000..9d7484b --- /dev/null +++ b/internal/libc/netinet/in/in_darwin_amd64.go @@ -0,0 +1,5514 @@ +// Code generated by 'ccgo netinet/in/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netinet/in/in_darwin_amd64.go -pkgname in', DO NOT EDIT. + +package in + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_APPLETALK = 16 // socket.h:375:1: + AF_CCITT = 10 // socket.h:369:1: + AF_CHAOS = 5 // socket.h:363:1: + AF_CNT = 21 // socket.h:380:1: + AF_COIP = 20 // socket.h:379:1: + AF_DATAKIT = 9 // socket.h:368:1: + AF_DECnet = 12 // socket.h:371:1: + AF_DLI = 13 // socket.h:372:1: + AF_E164 = 28 // socket.h:387:1: + AF_ECMA = 8 // socket.h:367:1: + AF_HYLINK = 15 // socket.h:374:1: + AF_IEEE80211 = 37 // socket.h:399:1: + AF_IMPLINK = 3 // socket.h:361:1: + AF_INET = 2 // socket.h:359:1: + AF_INET6 = 30 // socket.h:390:1: + AF_IPX = 23 // socket.h:382:1: + AF_ISDN = 28 // socket.h:386:1: + AF_ISO = 7 // socket.h:365:1: + AF_LAT = 14 // socket.h:373:1: + AF_LINK = 18 // socket.h:377:1: + AF_LOCAL = 1 // socket.h:357:1: + AF_MAX = 40 // socket.h:401:1: + AF_NATM = 31 // socket.h:392:1: + AF_NDRV = 27 // socket.h:385:1: + AF_NETBIOS = 33 // socket.h:394:1: + AF_NS = 6 // socket.h:364:1: + AF_OSI = 7 // socket.h:366:1: + AF_PPP = 34 // socket.h:395:1: + AF_PUP = 4 // socket.h:362:1: + AF_RESERVED_36 = 36 // socket.h:398:1: + AF_ROUTE = 17 // socket.h:376:1: + AF_SIP = 24 // socket.h:383:1: + AF_SNA = 11 // socket.h:370:1: + AF_SYSTEM = 32 // socket.h:393:1: + AF_UNIX = 1 // socket.h:355:1: + AF_UNSPEC = 0 // socket.h:354:1: + AF_UTUN = 38 // socket.h:400:1: + BIG_ENDIAN = 4321 // endian.h:94:1: + BYTE_ORDER = 1234 // endian.h:97:1: + CONNECT_DATA_AUTHENTICATED = 0x4 // socket.h:300:1: + CONNECT_DATA_IDEMPOTENT = 0x2 // socket.h:299:1: + CONNECT_RESUME_ON_READ_WRITE = 0x1 // socket.h:298:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + ICMP6_FILTER = 18 // in6.h:380:1: + ICMPV6CTL_ND6_ONLINKNSRFC4861 = 50 // in6.h:615:1: + INADDR_NONE = 0xffffffff // in.h:342:1: + INET6_ADDRSTRLEN = 46 // in6.h:161:1: + INET_ADDRSTRLEN = 16 // in.h:388:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + IN_CLASSA_HOST = 0x00ffffff // in.h:317:1: + IN_CLASSA_MAX = 128 // in.h:318:1: + IN_CLASSA_NET = 0xff000000 // in.h:315:1: + IN_CLASSA_NSHIFT = 24 // in.h:316:1: + IN_CLASSB_HOST = 0x0000ffff // in.h:323:1: + IN_CLASSB_MAX = 65536 // in.h:324:1: + IN_CLASSB_NET = 0xffff0000 // in.h:321:1: + IN_CLASSB_NSHIFT = 16 // in.h:322:1: + IN_CLASSC_HOST = 0x000000ff // in.h:329:1: + IN_CLASSC_NET = 0xffffff00 // in.h:327:1: + IN_CLASSC_NSHIFT = 8 // in.h:328:1: + IN_CLASSD_HOST = 0x0fffffff // in.h:334:1: + IN_CLASSD_NET = 0xf0000000 // in.h:332:1: + IN_CLASSD_NSHIFT = 28 // in.h:333:1: + IN_LOOPBACKNET = 127 // in.h:369:1: + IPCTL_ACCEPTSOURCEROUTE = 13 // in.h:649:1: + IPCTL_DEFTTL = 3 // in.h:637:1: + IPCTL_DIRECTEDBROADCAST = 9 // in.h:645:1: + IPCTL_FASTFORWARDING = 14 // in.h:650:1: + IPCTL_FORWARDING = 1 // in.h:635:1: + IPCTL_GIF_TTL = 16 // in.h:652:1: + IPCTL_INTRQDROPS = 11 // in.h:647:1: + IPCTL_INTRQMAXLEN = 10 // in.h:646:1: + IPCTL_KEEPFAITH = 15 // in.h:651:1: + IPCTL_MAXID = 17 // in.h:653:1: + IPCTL_RTEXPIRE = 5 // in.h:641:1: + IPCTL_RTMAXCACHE = 7 // in.h:643:1: + IPCTL_RTMINEXPIRE = 6 // in.h:642:1: + IPCTL_SENDREDIRECTS = 2 // in.h:636:1: + IPCTL_SOURCEROUTE = 8 // in.h:644:1: + IPCTL_STATS = 12 // in.h:648:1: + IPPORT_HIFIRSTAUTO = 49152 // in.h:286:1: + IPPORT_HILASTAUTO = 65535 // in.h:287:1: + IPPORT_RESERVED = 1024 // in.h:279:1: + IPPORT_RESERVEDSTART = 600 // in.h:295:1: + IPPORT_USERRESERVED = 5000 // in.h:281:1: + IPPROTO_3PC = 34 // in.h:139:1: + IPPROTO_ADFS = 68 // in.h:173:1: + IPPROTO_AH = 51 // in.h:158:1: + IPPROTO_AHIP = 61 // in.h:166:1: + IPPROTO_APES = 99 // in.h:204:1: + IPPROTO_ARGUS = 13 // in.h:116:1: + IPPROTO_AX25 = 93 // in.h:198:1: + IPPROTO_BHA = 49 // in.h:156:1: + IPPROTO_BLT = 30 // in.h:135:1: + IPPROTO_BRSATMON = 76 // in.h:181:1: + IPPROTO_CFTP = 62 // in.h:167:1: + IPPROTO_CHAOS = 16 // in.h:119:1: + IPPROTO_CMTP = 38 // in.h:143:1: + IPPROTO_CPHB = 73 // in.h:178:1: + IPPROTO_CPNX = 72 // in.h:177:1: + IPPROTO_DDP = 37 // in.h:142:1: + IPPROTO_DGP = 86 // in.h:191:1: + IPPROTO_DIVERT = 254 // in.h:213:1: + IPPROTO_DONE = 257 // in.h:221:1: + IPPROTO_DSTOPTS = 60 // in.h:165:1: + IPPROTO_EGP = 8 // in.h:111:1: + IPPROTO_EMCON = 14 // in.h:117:1: + IPPROTO_ENCAP = 98 // in.h:203:1: + IPPROTO_EON = 80 // in.h:185:1: + IPPROTO_ESP = 50 // in.h:157:1: + IPPROTO_ETHERIP = 97 // in.h:202:1: + IPPROTO_FRAGMENT = 44 // in.h:151:1: + IPPROTO_GGP = 3 // in.h:104:1: + IPPROTO_GMTP = 100 // in.h:205:1: + IPPROTO_GRE = 47 // in.h:154:1: + IPPROTO_HELLO = 63 // in.h:168:1: + IPPROTO_HMP = 20 // in.h:125:1: + IPPROTO_HOPOPTS = 0 // in.h:99:1: + IPPROTO_ICMP = 1 // in.h:101:1: + IPPROTO_ICMPV6 = 58 // in.h:163:1: + IPPROTO_IDP = 22 // in.h:127:1: + IPPROTO_IDPR = 35 // in.h:140:1: + IPPROTO_IDRP = 45 // in.h:152:1: + IPPROTO_IGMP = 2 // in.h:103:1: + IPPROTO_IGP = 85 // in.h:190:1: + IPPROTO_IGRP = 88 // in.h:193:1: + IPPROTO_IL = 40 // in.h:145:1: + IPPROTO_INLSP = 52 // in.h:159:1: + IPPROTO_INP = 32 // in.h:137:1: + IPPROTO_IP = 0 // in.h:97:1: + IPPROTO_IPCOMP = 108 // in.h:208:1: + IPPROTO_IPCV = 71 // in.h:176:1: + IPPROTO_IPEIP = 94 // in.h:199:1: + IPPROTO_IPIP = 4 // in.h:106:1: + IPPROTO_IPPC = 67 // in.h:172:1: + IPPROTO_IPV4 = 4 // in.h:105:1: + IPPROTO_IPV6 = 41 // in.h:147:1: + IPPROTO_IRTP = 28 // in.h:133:1: + IPPROTO_KRYPTOLAN = 65 // in.h:170:1: + IPPROTO_LARP = 91 // in.h:196:1: + IPPROTO_LEAF1 = 25 // in.h:130:1: + IPPROTO_LEAF2 = 26 // in.h:131:1: + IPPROTO_MAX = 256 // in.h:218:1: + IPPROTO_MAXID = 52 // in.h:629:1: + IPPROTO_MEAS = 19 // in.h:124:1: + IPPROTO_MHRP = 48 // in.h:155:1: + IPPROTO_MICP = 95 // in.h:200:1: + IPPROTO_MTP = 92 // in.h:197:1: + IPPROTO_MUX = 18 // in.h:123:1: + IPPROTO_ND = 77 // in.h:182:1: + IPPROTO_NHRP = 54 // in.h:161:1: + IPPROTO_NONE = 59 // in.h:164:1: + IPPROTO_NSP = 31 // in.h:136:1: + IPPROTO_NVPII = 11 // in.h:114:1: + IPPROTO_OSPFIGP = 89 // in.h:194:1: + IPPROTO_PGM = 113 // in.h:209:1: + IPPROTO_PIGP = 9 // in.h:112:1: + IPPROTO_PIM = 103 // in.h:207:1: + IPPROTO_PRM = 21 // in.h:126:1: + IPPROTO_PUP = 12 // in.h:115:1: + IPPROTO_PVP = 75 // in.h:180:1: + IPPROTO_RAW = 255 // in.h:215:1: + IPPROTO_RCCMON = 10 // in.h:113:1: + IPPROTO_RDP = 27 // in.h:132:1: + IPPROTO_ROUTING = 43 // in.h:150:1: + IPPROTO_RSVP = 46 // in.h:153:1: + IPPROTO_RVD = 66 // in.h:171:1: + IPPROTO_SATEXPAK = 64 // in.h:169:1: + IPPROTO_SATMON = 69 // in.h:174:1: + IPPROTO_SCCSP = 96 // in.h:201:1: + IPPROTO_SCTP = 132 // in.h:210:1: + IPPROTO_SDRP = 42 // in.h:149:1: + IPPROTO_SEP = 33 // in.h:138:1: + IPPROTO_SRPC = 90 // in.h:195:1: + IPPROTO_ST = 7 // in.h:110:1: + IPPROTO_SVMTP = 82 // in.h:187:1: + IPPROTO_SWIPE = 53 // in.h:160:1: + IPPROTO_TCF = 87 // in.h:192:1: + IPPROTO_TCP = 6 // in.h:108:1: + IPPROTO_TP = 29 // in.h:134:1: + IPPROTO_TPXX = 39 // in.h:144:1: + IPPROTO_TRUNK1 = 23 // in.h:128:1: + IPPROTO_TRUNK2 = 24 // in.h:129:1: + IPPROTO_TTP = 84 // in.h:189:1: + IPPROTO_UDP = 17 // in.h:121:1: + IPPROTO_VINES = 83 // in.h:188:1: + IPPROTO_VISA = 70 // in.h:175:1: + IPPROTO_VMTP = 81 // in.h:186:1: + IPPROTO_WBEXPAK = 79 // in.h:184:1: + IPPROTO_WBMON = 78 // in.h:183:1: + IPPROTO_WSN = 74 // in.h:179:1: + IPPROTO_XNET = 15 // in.h:118:1: + IPPROTO_XTP = 36 // in.h:141:1: + IPV6CTL_ACCEPT_RTADV = 12 // in6.h:580:1: + IPV6CTL_ADDRCTLPOLICY = 38 // in6.h:605:1: + IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:585:1: + IPV6CTL_AUTO_LINKLOCAL = 35 // in6.h:602:1: + IPV6CTL_DAD_COUNT = 16 // in6.h:584:1: + IPV6CTL_DEFHLIM = 3 // in6.h:569:1: + IPV6CTL_DEFMCASTHLIM = 18 // in6.h:586:1: + IPV6CTL_FORWARDING = 1 // in6.h:567:1: + IPV6CTL_FORWSRCRT = 5 // in6.h:573:1: + IPV6CTL_GIF_HLIM = 19 // in6.h:587:1: + IPV6CTL_HDRNESTLIMIT = 15 // in6.h:583:1: + IPV6CTL_KAME_VERSION = 20 // in6.h:588:1: + IPV6CTL_KEEPFAITH = 13 // in6.h:581:1: + IPV6CTL_LOG_INTERVAL = 14 // in6.h:582:1: + IPV6CTL_MAXDYNROUTES = 49 // in6.h:614:1: + IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:577:1: + IPV6CTL_MAXFRAGS = 41 // in6.h:608:1: + IPV6CTL_MAXID = 51 // in6.h:619:1: + IPV6CTL_MAXIFDEFROUTERS = 48 // in6.h:613:1: + IPV6CTL_MAXIFPREFIXES = 47 // in6.h:612:1: + IPV6CTL_MCAST_PMTU = 44 // in6.h:609:1: + IPV6CTL_MRTPROTO = 8 // in6.h:576:1: + IPV6CTL_MRTSTATS = 7 // in6.h:575:1: + IPV6CTL_NEIGHBORGCTHRESH = 46 // in6.h:611:1: + IPV6CTL_PREFER_TEMPADDR = 37 // in6.h:604:1: + IPV6CTL_RIP6STATS = 36 // in6.h:603:1: + IPV6CTL_RR_PRUNE = 22 // in6.h:590:1: + IPV6CTL_RTEXPIRE = 25 // in6.h:595:1: + IPV6CTL_RTMAXCACHE = 27 // in6.h:597:1: + IPV6CTL_RTMINEXPIRE = 26 // in6.h:596:1: + IPV6CTL_SENDREDIRECTS = 2 // in6.h:568:1: + IPV6CTL_SOURCECHECK = 10 // in6.h:578:1: + IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:579:1: + IPV6CTL_STATS = 6 // in6.h:574:1: + IPV6CTL_TEMPPLTIME = 33 // in6.h:600:1: + IPV6CTL_TEMPVLTIME = 34 // in6.h:601:1: + IPV6CTL_USETEMPADDR = 32 // in6.h:599:1: + IPV6CTL_USE_DEFAULTZONE = 39 // in6.h:606:1: + IPV6CTL_USE_DEPRECATED = 21 // in6.h:589:1: + IPV6CTL_V6ONLY = 24 // in6.h:594:1: + IPV6PORT_ANONMAX = 65535 // in6.h:143:1: + IPV6PORT_ANONMIN = 49152 // in6.h:142:1: + IPV6PORT_RESERVED = 1024 // in6.h:141:1: + IPV6PORT_RESERVEDMAX = 1023 // in6.h:145:1: + IPV6PORT_RESERVEDMIN = 600 // in6.h:144:1: + IPV6PROTO_MAXID = 104 // in6.h:562:1: + IPV6_2292DSTOPTS = 23 // in6.h:385:1: + IPV6_2292HOPLIMIT = 20 // in6.h:382:1: + IPV6_2292HOPOPTS = 22 // in6.h:384:1: + IPV6_2292NEXTHOP = 21 // in6.h:383:1: + IPV6_2292PKTINFO = 19 // in6.h:381:1: + IPV6_2292PKTOPTIONS = 25 // in6.h:389:1: + IPV6_2292RTHDR = 24 // in6.h:386:1: + IPV6_BINDV6ONLY = 27 // in6.h:405:1: + IPV6_BOUND_IF = 125 // in6.h:494:1: + IPV6_CHECKSUM = 26 // in6.h:401:1: + IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:506:1: + IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:507:1: + IPV6_FAITH = 29 // in6.h:411:1: + IPV6_FW_ADD = 30 // in6.h:414:1: + IPV6_FW_DEL = 31 // in6.h:415:1: + IPV6_FW_FLUSH = 32 // in6.h:416:1: + IPV6_FW_GET = 34 // in6.h:418:1: + IPV6_FW_ZERO = 33 // in6.h:417:1: + IPV6_IPSEC_POLICY = 28 // in6.h:409:1: + IPV6_JOIN_GROUP = 12 // in6.h:375:1: + IPV6_LEAVE_GROUP = 13 // in6.h:376:1: + IPV6_MAX_GROUP_SRC_FILTER = 512 // in6.h:521:1: + IPV6_MAX_MEMBERSHIPS = 4095 // in6.h:515:1: + IPV6_MAX_SOCK_SRC_FILTER = 128 // in6.h:522:1: + IPV6_MIN_MEMBERSHIPS = 31 // in6.h:514:1: + IPV6_MULTICAST_HOPS = 10 // in6.h:373:1: + IPV6_MULTICAST_IF = 9 // in6.h:372:1: + IPV6_MULTICAST_LOOP = 11 // in6.h:374:1: + IPV6_PORTRANGE = 14 // in6.h:379:1: + IPV6_PORTRANGE_DEFAULT = 0 // in6.h:552:1: + IPV6_PORTRANGE_HIGH = 1 // in6.h:553:1: + IPV6_PORTRANGE_LOW = 2 // in6.h:554:1: + IPV6_RECVTCLASS = 35 // in6.h:426:1: + IPV6_RTHDR_LOOSE = 0 // in6.h:499:1: + IPV6_RTHDR_STRICT = 1 // in6.h:500:1: + IPV6_RTHDR_TYPE_0 = 0 // in6.h:501:1: + IPV6_SOCKOPT_RESERVED1 = 3 // in6.h:369:1: + IPV6_TCLASS = 36 // in6.h:427:1: + IPV6_UNICAST_HOPS = 4 // in6.h:371:1: + IPV6_V6ONLY = 27 // in6.h:403:1: + IP_ADD_MEMBERSHIP = 12 // in.h:418:1: + IP_ADD_SOURCE_MEMBERSHIP = 70 // in.h:464:1: + IP_BLOCK_SOURCE = 72 // in.h:466:1: + IP_BOUND_IF = 25 // in.h:434:1: + IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:485:1: + IP_DEFAULT_MULTICAST_TTL = 1 // in.h:484:1: + IP_DROP_MEMBERSHIP = 13 // in.h:419:1: + IP_DROP_SOURCE_MEMBERSHIP = 71 // in.h:465:1: + IP_DUMMYNET_CONFIGURE = 60 // in.h:455:1: + IP_DUMMYNET_DEL = 61 // in.h:456:1: + IP_DUMMYNET_FLUSH = 62 // in.h:457:1: + IP_DUMMYNET_GET = 64 // in.h:458:1: + IP_FAITH = 22 // in.h:429:1: + IP_FW_ADD = 40 // in.h:439:1: + IP_FW_DEL = 41 // in.h:440:1: + IP_FW_FLUSH = 42 // in.h:441:1: + IP_FW_GET = 44 // in.h:443:1: + IP_FW_RESETLOG = 45 // in.h:444:1: + IP_FW_ZERO = 43 // in.h:442:1: + IP_HDRINCL = 2 // in.h:408:1: + IP_IPSEC_POLICY = 21 // in.h:428:1: + IP_MAX_GROUP_SRC_FILTER = 512 // in.h:499:1: + IP_MAX_MEMBERSHIPS = 4095 // in.h:493:1: + IP_MAX_SOCK_MUTE_FILTER = 128 // in.h:501:1: + IP_MAX_SOCK_SRC_FILTER = 128 // in.h:500:1: + IP_MIN_MEMBERSHIPS = 31 // in.h:492:1: + IP_MSFILTER = 74 // in.h:470:1: + IP_MULTICAST_IF = 9 // in.h:415:1: + IP_MULTICAST_IFINDEX = 66 // in.h:461:1: + IP_MULTICAST_LOOP = 11 // in.h:417:1: + IP_MULTICAST_TTL = 10 // in.h:416:1: + IP_MULTICAST_VIF = 14 // in.h:420:1: + IP_NAT__XXX = 55 // in.h:452:1: + IP_OLD_FW_ADD = 50 // in.h:447:1: + IP_OLD_FW_DEL = 51 // in.h:448:1: + IP_OLD_FW_FLUSH = 52 // in.h:449:1: + IP_OLD_FW_GET = 54 // in.h:451:1: + IP_OLD_FW_RESETLOG = 56 // in.h:453:1: + IP_OLD_FW_ZERO = 53 // in.h:450:1: + IP_OPTIONS = 1 // in.h:407:1: + IP_PKTINFO = 26 // in.h:435:1: + IP_PORTRANGE = 19 // in.h:425:1: + IP_PORTRANGE_DEFAULT = 0 // in.h:593:1: + IP_PORTRANGE_HIGH = 1 // in.h:594:1: + IP_PORTRANGE_LOW = 2 // in.h:595:1: + IP_RECVDSTADDR = 7 // in.h:413:1: + IP_RECVIF = 20 // in.h:426:1: + IP_RECVOPTS = 5 // in.h:411:1: + IP_RECVPKTINFO = 26 // in.h:436:1: + IP_RECVRETOPTS = 6 // in.h:412:1: + IP_RECVTOS = 27 // in.h:437:1: + IP_RECVTTL = 24 // in.h:433:1: + IP_RETOPTS = 8 // in.h:414:1: + IP_RSVP_OFF = 16 // in.h:422:1: + IP_RSVP_ON = 15 // in.h:421:1: + IP_RSVP_VIF_OFF = 18 // in.h:424:1: + IP_RSVP_VIF_ON = 17 // in.h:423:1: + IP_STRIPHDR = 23 // in.h:431:1: + IP_TOS = 3 // in.h:409:1: + IP_TRAFFIC_MGT_BACKGROUND = 65 // in.h:460:1: + IP_TTL = 4 // in.h:410:1: + IP_UNBLOCK_SOURCE = 73 // in.h:467:1: + KEV_DL_ADDMULTI = 7 // net_kev.h:61:1: + KEV_DL_AWDL_RESTRICTED = 26 // net_kev.h:80:1: + KEV_DL_AWDL_UNRESTRICTED = 27 // net_kev.h:81:1: + KEV_DL_DELMULTI = 8 // net_kev.h:62:1: + KEV_DL_IFCAP_CHANGED = 19 // net_kev.h:73:1: + KEV_DL_IFDELEGATE_CHANGED = 25 // net_kev.h:79:1: + KEV_DL_IF_ATTACHED = 9 // net_kev.h:63:1: + KEV_DL_IF_DETACHED = 11 // net_kev.h:65:1: + KEV_DL_IF_DETACHING = 10 // net_kev.h:64:1: + KEV_DL_IF_IDLE_ROUTE_REFCNT = 18 // net_kev.h:72:1: + KEV_DL_ISSUES = 24 // net_kev.h:78:1: + KEV_DL_LINK_ADDRESS_CHANGED = 16 // net_kev.h:70:1: + KEV_DL_LINK_OFF = 12 // net_kev.h:66:1: + KEV_DL_LINK_ON = 13 // net_kev.h:67:1: + KEV_DL_LINK_QUALITY_METRIC_CHANGED = 20 // net_kev.h:74:1: + KEV_DL_LOW_POWER_MODE_CHANGED = 30 // net_kev.h:84:1: + KEV_DL_MASTER_ELECTED = 23 // net_kev.h:77:1: + KEV_DL_NODE_ABSENCE = 22 // net_kev.h:76:1: + KEV_DL_NODE_PRESENCE = 21 // net_kev.h:75:1: + KEV_DL_PROTO_ATTACHED = 14 // net_kev.h:68:1: + KEV_DL_PROTO_DETACHED = 15 // net_kev.h:69:1: + KEV_DL_QOS_MODE_CHANGED = 29 // net_kev.h:83:1: + KEV_DL_RRC_STATE_CHANGED = 28 // net_kev.h:82:1: + KEV_DL_SIFFLAGS = 1 // net_kev.h:55:1: + KEV_DL_SIFGENERIC = 6 // net_kev.h:60:1: + KEV_DL_SIFMEDIA = 5 // net_kev.h:59:1: + KEV_DL_SIFMETRICS = 2 // net_kev.h:56:1: + KEV_DL_SIFMTU = 3 // net_kev.h:57:1: + KEV_DL_SIFPHYS = 4 // net_kev.h:58:1: + KEV_DL_SUBCLASS = 2 // net_kev.h:50:1: + KEV_DL_WAKEFLAGS_CHANGED = 17 // net_kev.h:71:1: + KEV_INET6_ADDR_DELETED = 3 // net_kev.h:91:1: + KEV_INET6_CHANGED_ADDR = 2 // net_kev.h:90:1: + KEV_INET6_DEFROUTER = 6 // net_kev.h:94:1: + KEV_INET6_NEW_LL_ADDR = 4 // net_kev.h:92:1: + KEV_INET6_NEW_RTADV_ADDR = 5 // net_kev.h:93:1: + KEV_INET6_NEW_USER_ADDR = 1 // net_kev.h:89:1: + KEV_INET6_REQUEST_NAT64_PREFIX = 7 // net_kev.h:95:1: + KEV_INET6_SUBCLASS = 6 // net_kev.h:87:1: + KEV_INET_ADDR_DELETED = 3 // net_kev.h:39:1: + KEV_INET_ARPCOLLISION = 7 // net_kev.h:43:1: + KEV_INET_ARPRTRALIVE = 10 // net_kev.h:48:1: + KEV_INET_ARPRTRFAILURE = 9 // net_kev.h:47:1: + KEV_INET_CHANGED_ADDR = 2 // net_kev.h:38:1: + KEV_INET_NEW_ADDR = 1 // net_kev.h:37:1: + KEV_INET_PORTINUSE = 8 // net_kev.h:45:1: + KEV_INET_SIFBRDADDR = 5 // net_kev.h:41:1: + KEV_INET_SIFDSTADDR = 4 // net_kev.h:40:1: + KEV_INET_SIFNETMASK = 6 // net_kev.h:42:1: + KEV_INET_SUBCLASS = 1 // net_kev.h:35:1: + LITTLE_ENDIAN = 1234 // endian.h:93:1: + MCAST_BLOCK_SOURCE = 84 // in.h:477:1: + MCAST_EXCLUDE = 2 // in.h:587:1: + MCAST_INCLUDE = 1 // in.h:586:1: + MCAST_JOIN_GROUP = 80 // in.h:473:1: + MCAST_JOIN_SOURCE_GROUP = 82 // in.h:475:1: + MCAST_LEAVE_GROUP = 81 // in.h:474:1: + MCAST_LEAVE_SOURCE_GROUP = 83 // in.h:476:1: + MCAST_UNBLOCK_SOURCE = 85 // in.h:478:1: + MCAST_UNDEFINED = 0 // in.h:585:1: + MSG_CTRUNC = 0x20 // socket.h:563:1: + MSG_DONTROUTE = 0x4 // socket.h:560:1: + MSG_DONTWAIT = 0x80 // socket.h:566:1: + MSG_EOF = 0x100 // socket.h:567:1: + MSG_EOR = 0x8 // socket.h:561:1: + MSG_FLUSH = 0x400 // socket.h:572:1: + MSG_HAVEMORE = 0x2000 // socket.h:575:1: + MSG_HOLD = 0x800 // socket.h:573:1: + MSG_NEEDSA = 0x10000 // socket.h:578:1: + MSG_OOB = 0x1 // socket.h:558:1: + MSG_PEEK = 0x2 // socket.h:559:1: + MSG_RCVMORE = 0x4000 // socket.h:576:1: + MSG_SEND = 0x1000 // socket.h:574:1: + MSG_TRUNC = 0x10 // socket.h:562:1: + MSG_WAITALL = 0x40 // socket.h:564:1: + MSG_WAITSTREAM = 0x200 // socket.h:570:1: + NBBY = 8 // types.h:186:1: + NETSVC_MRKNG_LVL_L2 = 1 // socket.h:283:1: + NETSVC_MRKNG_LVL_L3L2_ALL = 2 // socket.h:284:1: + NETSVC_MRKNG_LVL_L3L2_BK = 3 // socket.h:285:1: + NETSVC_MRKNG_UNKNOWN = 0 // socket.h:282:1: + NET_MAXID = 40 // socket.h:506:1: + NET_RT_DUMP = 1 // socket.h:519:1: + NET_RT_DUMP2 = 7 // socket.h:525:1: + NET_RT_FLAGS = 2 // socket.h:520:1: + NET_RT_FLAGS_PRIV = 10 // socket.h:530:1: + NET_RT_IFLIST = 3 // socket.h:521:1: + NET_RT_IFLIST2 = 6 // socket.h:524:1: + NET_RT_MAXID = 11 // socket.h:531:1: + NET_RT_STAT = 4 // socket.h:522:1: + NET_RT_TRASH = 5 // socket.h:523:1: + NET_SERVICE_TYPE_AV = 6 // socket.h:276:1: + NET_SERVICE_TYPE_BE = 0 // socket.h:270:1: + NET_SERVICE_TYPE_BK = 1 // socket.h:271:1: + NET_SERVICE_TYPE_OAM = 7 // socket.h:277:1: + NET_SERVICE_TYPE_RD = 8 // socket.h:278:1: + NET_SERVICE_TYPE_RV = 5 // socket.h:275:1: + NET_SERVICE_TYPE_SIG = 2 // socket.h:272:1: + NET_SERVICE_TYPE_VI = 3 // socket.h:273:1: + NET_SERVICE_TYPE_VO = 4 // socket.h:274:1: + PDP_ENDIAN = 3412 // endian.h:95:1: + PF_APPLETALK = 16 // socket.h:469:1: + PF_CCITT = 10 // socket.h:463:1: + PF_CHAOS = 5 // socket.h:457:1: + PF_CNT = 21 // socket.h:474:1: + PF_COIP = 20 // socket.h:473:1: + PF_DATAKIT = 9 // socket.h:462:1: + PF_DECnet = 12 // socket.h:465:1: + PF_DLI = 13 // socket.h:466:1: + PF_ECMA = 8 // socket.h:461:1: + PF_HYLINK = 15 // socket.h:468:1: + PF_IMPLINK = 3 // socket.h:455:1: + PF_INET = 2 // socket.h:454:1: + PF_INET6 = 30 // socket.h:482:1: + PF_IPX = 23 // socket.h:476:1: + PF_ISDN = 28 // socket.h:480:1: + PF_ISO = 7 // socket.h:459:1: + PF_KEY = 29 // socket.h:481:1: + PF_LAT = 14 // socket.h:467:1: + PF_LINK = 18 // socket.h:471:1: + PF_LOCAL = 1 // socket.h:452:1: + PF_MAX = 40 // socket.h:489:1: + PF_NATM = 31 // socket.h:483:1: + PF_NDRV = 27 // socket.h:479:1: + PF_NETBIOS = 33 // socket.h:485:1: + PF_NS = 6 // socket.h:458:1: + PF_OSI = 7 // socket.h:460:1: + PF_PIP = 25 // socket.h:478:1: + PF_PPP = 34 // socket.h:486:1: + PF_PUP = 4 // socket.h:456:1: + PF_RESERVED_36 = 36 // socket.h:487:1: + PF_ROUTE = 17 // socket.h:470:1: + PF_RTIP = 22 // socket.h:477:1: + PF_SIP = 24 // socket.h:475:1: + PF_SNA = 11 // socket.h:464:1: + PF_SYSTEM = 32 // socket.h:484:1: + PF_UNIX = 1 // socket.h:453:1: + PF_UNSPEC = 0 // socket.h:451:1: + PF_UTUN = 38 // socket.h:488:1: + PF_XTP = 19 // socket.h:472:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + RSIZE_MAX = 9223372036854775807 // stdint.h:658:1: + SAE_ASSOCID_ANY = 0 // socket.h:290:1: + SAE_CONNID_ANY = 0 // socket.h:294:1: + SCM_CREDS = 0x03 // socket.h:661:1: + SCM_RIGHTS = 0x01 // socket.h:658:1: + SCM_TIMESTAMP = 0x02 // socket.h:660:1: + SCM_TIMESTAMP_MONOTONIC = 0x04 // socket.h:662:1: + SHUT_RD = 0 // socket.h:670:1: + SHUT_RDWR = 2 // socket.h:672:1: + SHUT_WR = 1 // socket.h:671:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIN6_LEN = 0 // in6.h:167:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + SOCK_DGRAM = 2 // socket.h:112:1: + SOCK_MAXADDRLEN = 255 // socket.h:414:1: + SOCK_RAW = 3 // socket.h:113:1: + SOCK_RDM = 4 // socket.h:115:1: + SOCK_SEQPACKET = 5 // socket.h:117:1: + SOCK_STREAM = 1 // socket.h:111:1: + SOL_SOCKET = 0xffff // socket.h:348:1: + SOMAXCONN = 128 // socket.h:540:1: + SONPX_SETOPTSHUT = 0x000000001 // socket.h:338:1: + SO_ACCEPTCONN = 0x0002 // socket.h:123:1: + SO_BROADCAST = 0x0020 // socket.h:127:1: + SO_DEBUG = 0x0001 // socket.h:122:1: + SO_DONTROUTE = 0x0010 // socket.h:126:1: + SO_DONTTRUNC = 0x2000 // socket.h:142:1: + SO_ERROR = 0x1007 // socket.h:160:1: + SO_KEEPALIVE = 0x0008 // socket.h:125:1: + SO_LABEL = 0x1010 // socket.h:163:1: + SO_LINGER = 0x0080 // socket.h:130:1: + SO_LINGER_SEC = 0x1080 // socket.h:176:1: + SO_NETSVC_MARKING_LEVEL = 0x1119 // socket.h:185:1: + SO_NET_SERVICE_TYPE = 0x1116 // socket.h:182:1: + SO_NKE = 0x1021 // socket.h:167:1: + SO_NOADDRERR = 0x1023 // socket.h:169:1: + SO_NOSIGPIPE = 0x1022 // socket.h:168:1: + SO_NOTIFYCONFLICT = 0x1026 // socket.h:173:1: + SO_NP_EXTENSIONS = 0x1083 // socket.h:178:1: + SO_NREAD = 0x1020 // socket.h:166:1: + SO_NUMRCVPKT = 0x1112 // socket.h:181:1: + SO_NWRITE = 0x1024 // socket.h:170:1: + SO_OOBINLINE = 0x0100 // socket.h:134:1: + SO_PEERLABEL = 0x1011 // socket.h:164:1: + SO_RANDOMPORT = 0x1082 // socket.h:177:1: + SO_RCVBUF = 0x1002 // socket.h:155:1: + SO_RCVLOWAT = 0x1004 // socket.h:157:1: + SO_RCVTIMEO = 0x1006 // socket.h:159:1: + SO_REUSEADDR = 0x0004 // socket.h:124:1: + SO_REUSEPORT = 0x0200 // socket.h:136:1: + SO_REUSESHAREUID = 0x1025 // socket.h:171:1: + SO_SNDBUF = 0x1001 // socket.h:154:1: + SO_SNDLOWAT = 0x1003 // socket.h:156:1: + SO_SNDTIMEO = 0x1005 // socket.h:158:1: + SO_TIMESTAMP = 0x0400 // socket.h:137:1: + SO_TIMESTAMP_MONOTONIC = 0x0800 // socket.h:138:1: + SO_TYPE = 0x1008 // socket.h:161:1: + SO_UPCALLCLOSEWAIT = 0x1027 // socket.h:174:1: + SO_USELOOPBACK = 0x0040 // socket.h:129:1: + SO_WANTMORE = 0x4000 // socket.h:144:1: + SO_WANTOOBFLAG = 0x8000 // socket.h:145:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_I386__ENDIAN_H_ = 0 // endian.h:67:1: + X_I386__PARAM_H_ = 0 // _param.h:30:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // stdint.h:251:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NETINET6_IN6_H_ = 0 // in6.h:99:1: + X_NETINET_IN_H_ = 0 // in.h:65:1: + X_NET_NETKEV_H_ = 0 // net_kev.h:30:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS__OSBYTEORDERI386_H = 0 // _OSByteOrder.h:30:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:78:1: + X_QUAD_LOWWORD = 0 // endian.h:79:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SA_FAMILY_T = 0 // _sa_family_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SOCKLEN_T = 0 // _socklen_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SS_MAXSIZE = 128 // socket.h:429:1: + X_STRUCT_IOVEC = 0 // _iovec_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_SOCKET_H_ = 0 // socket.h:73:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // stdint.h:257:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: + Pseudo_AF_HDRCMPLT = 35 // socket.h:396:1: + Pseudo_AF_KEY = 29 // socket.h:388:1: + Pseudo_AF_PIP = 25 // socket.h:384:1: + Pseudo_AF_RTIP = 22 // socket.h:381:1: + Pseudo_AF_XTP = 19 // socket.h:378:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 +// $FreeBSD: src/sys/netinet/in.h,v 1.48.2.2 2001/04/21 14:53:06 ume Exp $ + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +//===---- stdint.h - Standard header for sized integer types --------------===* * +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// \*===----------------------------------------------------------------------=== + +// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T +// is defined until an inclusion of it without _STD_TYPES_T occurs, in which +// case the header guard macro is defined. + +// If we're hosted, fall back to the system's stdint.h, which might have +// additional definitions. + +// C99 7.18.1.1 Exact-width integer types. +// C99 7.18.1.2 Minimum-width integer types. +// C99 7.18.1.3 Fastest minimum-width integer types. +// +// The standard requires that exact-width type be defined for 8-, 16-, 32-, and +// 64-bit types if they are implemented. Other exact width types are optional. +// This implementation defines an exact-width types for every integer width +// that is represented in the standard integer types. +// +// The standard also requires minimum-width types be defined for 8-, 16-, 32-, +// and 64-bit widths regardless of whether there are corresponding exact-width +// types. +// +// To accommodate targets that are missing types that are exactly 8, 16, 32, or +// 64 bits wide, this implementation takes an approach of cascading +// redefinitions, redefining __int_leastN_t to successively smaller exact-width +// types. It is therefore important that the types are defined in order of +// descending widths. +// +// We currently assume that the minimum-width types and the fastest +// minimum-width types are the same. This is allowed by the standard, but is +// suboptimal. +// +// In violation of the standard, some targets do not implement a type that is +// wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit). +// To accommodate these targets, a required minimum-width type is only +// defined if there exists an exact-width type of equal or greater width. + +type Int64_t = int64 /* stdint.h:96:24 */ +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Int32_t = int32 /* stdint.h:167:24 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ + +type Int16_t = int16 /* stdint.h:205:24 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ + +type Int8_t = int8 /* stdint.h:224:23 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +type Intptr_t = int64 /* stdint.h:249:25 */ + +type Uintptr_t = uint64 /* stdint.h:256:26 */ + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2008 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Round p (pointer or byte index) up to a correctly-aligned value for all +// data types (int, long, ...). The result is unsigned int and must be +// cast to any desired pointer type. + +// Copyright (c) 2016-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Kernel event subclass identifiers for KEV_NETWORK_CLASS +// KEV_INET_SUBCLASS event codes + +// Define Data-Link event subclass, and associated +// events. + +// KEV_INET6_SUBCLASS event codes + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Definitions related to sockets: types, address families, options. + +// Data types. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Sa_family_t = X__uint8_t /* _sa_family_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Socklen_t = X__darwin_socklen_t /* _socklen_t.h:31:33 */ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The iovec structure shall be defined as described in . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* _iovec_t.h:31:1 */ + +// Types + +// Option flags per-socket. +// (ATOMIC proto) + +// Additional options, not kept in so_options. + +// Network Service Type for option SO_NET_SERVICE_TYPE +// +// The vast majority of sockets should use Best Effort that is the default +// Network Service Type. Other Network Service Types have to be used only if +// the traffic actually matches the description of the Network Service Type. +// +// Network Service Types do not represent priorities but rather describe +// different categories of delay, jitter and loss parameters. +// Those parameters may influence protocols from layer 4 protocols like TCP +// to layer 2 protocols like Wi-Fi. The Network Service Type can determine +// how the traffic is queued and scheduled by the host networking stack and +// by other entities on the network like switches and routers. For example +// for Wi-Fi, the Network Service Type can select the marking of the +// layer 2 packet with the appropriate WMM Access Category. +// +// There is no point in attempting to game the system and use +// a Network Service Type that does not correspond to the actual +// traffic characteristic but one that seems to have a higher precedence. +// The reason is that for service classes that have lower tolerance +// for delay and jitter, the queues size is lower than for service +// classes that are more tolerant to delay and jitter. +// +// For example using a voice service type for bulk data transfer will lead +// to disastrous results as soon as congestion happens because the voice +// queue overflows and packets get dropped. This is not only bad for the bulk +// data transfer but it is also bad for VoIP apps that legitimately are using +// the voice service type. +// +// The characteristics of the Network Service Types are based on the service +// classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service +// Classes" +// +// When system detects the outgoing interface belongs to a DiffServ domain +// that follows the recommendation of the IETF draft "Guidelines for DiffServ to +// IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value +// that corresponds to Network Service Type. +// +// NET_SERVICE_TYPE_BE +// "Best Effort", unclassified/standard. This is the default service +// class and cover the majority of the traffic. +// +// NET_SERVICE_TYPE_BK +// "Background", high delay tolerant, loss tolerant. elastic flow, +// variable size & long-lived. E.g: non-interactive network bulk transfer +// like synching or backup. +// +// NET_SERVICE_TYPE_RD +// "Responsive Data", a notch higher than "Best Effort", medium delay +// tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, +// instant messaging, for which there is a sense of interactivity and +// urgency (user waiting for output). +// +// NET_SERVICE_TYPE_OAM +// "Operations, Administration, and Management", medium delay tolerant, +// low-medium loss tolerant, elastic & inelastic flows, variable size. +// E.g. VPN tunnels. +// +// NET_SERVICE_TYPE_AV +// "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium +// loss tolerant, elastic flow, constant packet interval, variable rate +// and size. E.g. video and audio playback with buffering. +// +// NET_SERVICE_TYPE_RV +// "Responsive Multimedia Audio/Video", low delay tolerant, low-medium +// loss tolerant, elastic flow, variable packet interval, rate and size. +// E.g. screen sharing. +// +// NET_SERVICE_TYPE_VI +// "Interactive Video", low delay tolerant, low-medium loss tolerant, +// elastic flow, constant packet interval, variable rate & size. E.g. +// video telephony. +// +// NET_SERVICE_TYPE_SIG +// "Signaling", low delay tolerant, low loss tolerant, inelastic flow, +// jitter tolerant, rate is bursty but short, variable size. E.g. SIP. +// +// NET_SERVICE_TYPE_VO +// "Interactive Voice", very low delay tolerant, very low loss tolerant, +// inelastic flow, constant packet rate, somewhat fixed size. +// E.g. VoIP. + +// These are supported values for SO_NETSVC_MARKING_LEVEL + +type Sae_associd_t = X__uint32_t /* socket.h:289:20 */ + +type Sae_connid_t = X__uint32_t /* socket.h:293:20 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints = struct { + Fsae_srcif uint32 + F__ccgo_pad1 [4]byte + Fsae_srcaddr uintptr + Fsae_srcaddrlen Socklen_t + F__ccgo_pad2 [4]byte + Fsae_dstaddr uintptr + Fsae_dstaddrlen Socklen_t + F__ccgo_pad3 [4]byte +} /* socket.h:303:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sockaddr = struct { + Fsa_len X__uint8_t + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:303:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints_t = Sa_endpoints /* socket.h:309:3 */ + +// Structure used for manipulating linger option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:315:1 */ + +// Structure to control non-portable Sockets extension to POSIX +type So_np_extensions = struct { + Fnpx_flags U_int32_t + Fnpx_mask U_int32_t +} /* socket.h:333:1 */ + +// Structure used by kernel to pass protocol +// information in raw sockets. +type Sockproto = struct { + Fsp_family X__uint16_t + Fsp_protocol X__uint16_t +} /* socket.h:420:1 */ + +// RFC 2553: protocol-independent placeholder for socket addresses + +// [XSI] sockaddr_storage +type Sockaddr_storage = struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 +} /* socket.h:440:1 */ + +// Protocol families, same as address families for now. + +// These do not have socket-layer support: + +// Definitions for network related sysctl, CTL_NET. +// +// Second level is protocol family. +// Third level is protocol number. +// +// Further levels are defined by the individual families below. + +// PF_ROUTE - Routing table +// +// Three additional levels are defined: +// Fourth: address family, 0 is wildcard +// Fifth: type of info, defined below +// Sixth: flag(s) to mask with for NET_RT_FLAGS +// Allows read access non-local host's MAC address +// if the process has neighbor cache entitlement. + +// Maximum queue length specifiable by listen. + +// [XSI] Message header for recvmsg and sendmsg calls. +// Used value-result for recvmsg, value only for sendmsg. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__ccgo_pad2 [4]byte + Fmsg_control uintptr + Fmsg_controllen Socklen_t + Fmsg_flags int32 +} /* socket.h:546:1 */ + +// Header for ancillary data objects in msg_control buffer. +// Used for additional information with/about a datagram +// not expressible by flags. The format is a sequence +// of message elements headed by cmsghdr structures. +type Cmsghdr = struct { + Fcmsg_len Socklen_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:587:1 */ + +// given pointer to struct cmsghdr, return pointer to data + +// RFC 2292 requires to check msg_controllen, in case that the kernel returns +// an empty list for some reasons. + +// Given pointer to struct cmsghdr, return pointer to next cmsghdr +// RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) + +// RFC 2292 additions + +// "Socket"-level control message types: + +// howto arguments for shutdown(2), specified by Posix.1g. + +// sendfile(2) header/trailer struct +type Sf_hdtr = struct { + Fheaders uintptr + Fhdr_cnt int32 + F__ccgo_pad1 [4]byte + Ftrailers uintptr + Ftrl_cnt int32 + F__ccgo_pad2 [4]byte +} /* socket.h:678:1 */ + +// The following two #includes insure htonl and family are defined +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2004, 2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1987, 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. + +// Constants and structures defined by the internet system, +// Per RFC 790, September 1981, and numerous additions. + +// Protocols (RFC 1700) +// 55-57: Unassigned +// 101-252: Partly Unassigned +// 253-254: Experimentation and testing; 255: Reserved (RFC3692) +// BSD Private, local use, namespace incursion + +// last return value of *_input(), meaning "all job for this pkt is done". + +// Local port number conventions: +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// The default range is IPPORT_RESERVED through +// IPPORT_USERRESERVED, although that is settable by sysctl. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH changes the range of candidate port numbers +// into the "high" range. These are reserved for client outbound connections +// which do not want to be filtered by any firewalls. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. This +// convention is based on "vouchsafe" principles only. It is only secure +// if you trust the remote host to restrict these ports. +// +// The default range of ports and the high range can be changed by +// sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) +// +// Changing those values has bad security implications if you are +// using a a stateless firewall that is allowing packets outside of that +// range in order to allow transparent outgoing connections. +// +// Such a firewall configuration will generally depend on the use of these +// default values. If you change them, you may find your Security +// Administrator looking for you with a heavy object. +// +// For a slightly more orthodox text view on this: +// +// ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers +// +// port numbers are divided into three ranges: +// +// 0 - 1023 Well Known Ports +// 1024 - 49151 Registered Ports +// 49152 - 65535 Dynamic and/or Private Ports +// + +// Ports < IPPORT_RESERVED are reserved for +// privileged processes (e.g. root). (IP_PORTRANGE_LOW) +// Ports > IPPORT_USERRESERVED are reserved +// for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) + +// Default local port range to use by setting IP_PORTRANGE_HIGH + +// Scanning for a free reserved port return a value below IPPORT_RESERVED, +// but higher than IPPORT_RESERVEDSTART. Traditionally the start value was +// 512, but that conflicts with some well-known-services that firewalls may +// have a fit if we use. + +// Internet address (a structure for historical reasons) +type In_addr = struct{ Fs_addr In_addr_t } /* in.h:301:1 */ + +// Definitions of bits in internet address integers. +// On subnets, the decomposition of addresses to host and net parts +// is done according to subnet mask, not the masks here. + +// Socket address, internet style. +type Sockaddr_in = struct { + Fsin_len X__uint8_t + Fsin_family Sa_family_t + Fsin_port In_port_t + Fsin_addr struct{ Fs_addr In_addr_t } + Fsin_zero [8]int8 +} /* in.h:375:1 */ + +// Structure used to describe IP options. +// Used to store options internally, to pass them to a process, +// or to restore options retrieved earlier. +// The ip_dst is used for the first-hop gateway when using a source route +// (this gets put into the header proper). +type Ip_opts = struct { + Fip_dst struct{ Fs_addr In_addr_t } + Fip_opts [40]int8 +} /* in.h:398:1 */ + +// Options for use with [gs]etsockopt at the IP level. +// First word of comment is data type; bool is stored in int. +// for IPSEC + +// These older firewall socket option codes are maintained for backward compatibility. + +// IPv4 Source Filter Multicast API [RFC3678] + +// The following option is private; do not use it from user applications. + +// Protocol Independent Multicast API [RFC3678] + +// Defaults and limits for options + +// The imo_membership vector for each socket is now dynamically allocated at +// run-time, bounded by USHRT_MAX, and is reallocated when needed, sized +// according to a power-of-two increment. + +// Default resource limits for IPv4 multicast source filtering. +// These may be modified by sysctl. + +// Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. +type Ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:506:1 */ + +// Modified argument structure for IP_MULTICAST_IF, obtained from Linux. +// This is used to specify an interface index for multicast sends, as +// the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). +type Ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_address struct{ Fs_addr In_addr_t } + Fimr_ifindex int32 +} /* in.h:516:1 */ + +// Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] +type Ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_sourceaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:526:1 */ + +// Argument structures for Protocol-Independent Multicast Source +// Filter APIs. [RFC3678] +type Group_req = struct { + Fgr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } +} /* in.h:536:1 */ + +type Group_source_req = struct { + Fgsr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } + Fgsr_source struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } +} /* in.h:541:1 */ + +// The following structure is private; do not use it from user applications. +// It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between +// the RFC 3678 libc functions and the kernel. +type X__msfilterreq = struct { + Fmsfr_ifindex Uint32_t + Fmsfr_fmode Uint32_t + Fmsfr_nsrcs Uint32_t + F__msfr_align Uint32_t + Fmsfr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } + Fmsfr_srcs uintptr +} /* in.h:554:1 */ + +// Filter modes; also used to represent per-socket filter mode internally. + +// Argument for IP_PORTRANGE: +// - which range to search when port is unspecified at bind() or connect() + +// IP_PKTINFO: Packet information (equivalent to RFC2292 sec 5 for IPv4) +// This structure is used for +// +// 1. Receiving ancilliary data about the datagram if IP_PKTINFO sockopt is +// set on the socket. In this case ipi_ifindex will contain the interface +// index the datagram was received on, ipi_addr is the IP address the +// datagram was received to. +// +// 2. Sending a datagram using a specific interface or IP source address. +// if ipi_ifindex is set to non-zero when in_pktinfo is passed as +// ancilliary data of type IP_PKTINFO, this will be used as the source +// interface to send the datagram from. If ipi_ifindex is null, ip_spec_dst +// will be used for the source address. +// +// Note: if IP_BOUND_IF is set on the socket, ipi_ifindex in the ancillary +// IP_PKTINFO option silently overrides the bound interface when it is +// specified during send time. +type In_pktinfo = struct { + Fipi_ifindex uint32 + Fipi_spec_dst struct{ Fs_addr In_addr_t } + Fipi_addr struct{ Fs_addr In_addr_t } +} /* in.h:617:1 */ + +// Definitions for inet sysctl operations. +// +// Third level is protocol number. +// Fourth level is desired variable within that protocol. + +// Names for IP sysctl objects + +// INET6 stuff +// Copyright (c) 2008-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +// 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 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Identification of the network protocol stack +// for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE +// has the table of implementation/integration differences. + +// Local port number conventions: +// +// Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), +// unless a kernel is compiled with IPNOPRIVPORTS defined. +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// +// The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although +// that is settable by sysctl(3); net.inet.ip.anonportmin and +// net.inet.ip.anonportmax respectively. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, +// and exists only for FreeBSD compatibility purposes. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. +// This convention is based on "vouchsafe" principles only. +// It is only secure if you trust the remote host to restrict these ports. +// The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + +// IPv6 address +type In6_addr = struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } +} /* in6.h:151:9 */ + +// Definitions for inet sysctl operations. +// +// Third level is protocol number. +// Fourth level is desired variable within that protocol. + +// Names for IP sysctl objects + +// INET6 stuff +// Copyright (c) 2008-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +// 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 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Identification of the network protocol stack +// for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE +// has the table of implementation/integration differences. + +// Local port number conventions: +// +// Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), +// unless a kernel is compiled with IPNOPRIVPORTS defined. +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// +// The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although +// that is settable by sysctl(3); net.inet.ip.anonportmin and +// net.inet.ip.anonportmax respectively. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, +// and exists only for FreeBSD compatibility purposes. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. +// This convention is based on "vouchsafe" principles only. +// It is only secure if you trust the remote host to restrict these ports. +// The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + +// IPv6 address +type In6_addr_t = In6_addr /* in6.h:157:3 */ + +// Socket address for IPv6 +type Sockaddr_in6 = struct { + Fsin6_len X__uint8_t + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo X__uint32_t + Fsin6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fsin6_scope_id X__uint32_t +} /* in6.h:169:1 */ + +// Equality +// NOTE: Some of kernel programming environment (for example, openbsd/sparc) +// does not supply memcmp(). For userland memcmp() is preferred as it is +// in ANSI standard. + +// Unspecified + +// Loopback + +// IPv4 compatible + +// Mapped + +// 6to4 + +// KAME Scope Values + +// Unicast Scope +// Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). + +// Multicast + +// Unique Local IPv6 Unicast Addresses (per RFC 4193) + +// Multicast Scope + +// Options for use with [gs]etsockopt at the IPV6 level. +// First word of comment is data type; bool is stored in int. +// no hdrincl +// RFC 3542 define the following socket options in a manner incompatible +// with RFC 2292: +// IPV6_PKTINFO +// IPV6_HOPLIMIT +// IPV6_NEXTHOP +// IPV6_HOPOPTS +// IPV6_DSTOPTS +// IPV6_RTHDR +// +// To use the new IPv6 Sockets options introduced by RFC 3542 +// the constant __APPLE_USE_RFC_3542 must be defined before +// including +// +// To use the old IPv6 Sockets options from RFC 2292 +// the constant __APPLE_USE_RFC_2292 must be defined before +// including +// +// Note that eventually RFC 3542 is going to be the +// default and RFC 2292 will be obsolete. + +// buf/cmsghdr; set/get IPv6 options [obsoleted by RFC3542] + +// APPLE: NOTE the value of those 2 options is kept unchanged from +// previous version of darwin/OS X for binary compatibility reasons +// and differ from FreeBSD (values 57 and 61). See below. + +// to define items, should talk with KAME guys first, for *BSD compatibility + +// Defaults and limits for options + +// The im6o_membership vector for each socket is now dynamically allocated at +// run-time, bounded by USHRT_MAX, and is reallocated when needed, sized +// according to a power-of-two increment. + +// Default resource limits for IPv6 multicast source filtering. +// These may be modified by sysctl. + +// Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. +type Ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fipv6mr_interface uint32 +} /* in6.h:527:1 */ + +// IPV6_2292PKTINFO: Packet information(RFC2292 sec 5) +type In6_pktinfo = struct { + Fipi6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fipi6_ifindex uint32 +} /* in6.h:535:1 */ + +// Control structure for IPV6_RECVPATHMTU socket option. +type Ip6_mtuinfo = struct { + Fip6m_addr struct { + Fsin6_len X__uint8_t + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo X__uint32_t + Fsin6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fsin6_scope_id X__uint32_t + } + Fip6m_mtu Uint32_t +} /* in6.h:543:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/netinet/in/in_darwin_arm64.go b/internal/libc/netinet/in/in_darwin_arm64.go new file mode 100644 index 0000000..3218b6a --- /dev/null +++ b/internal/libc/netinet/in/in_darwin_arm64.go @@ -0,0 +1,5815 @@ +// Code generated by 'ccgo netinet/in/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netinet/in/in_darwin_arm64.go -pkgname in', DO NOT EDIT. + +package in + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_APPLETALK = 16 // socket.h:379:1: + AF_CCITT = 10 // socket.h:373:1: + AF_CHAOS = 5 // socket.h:367:1: + AF_CNT = 21 // socket.h:384:1: + AF_COIP = 20 // socket.h:383:1: + AF_DATAKIT = 9 // socket.h:372:1: + AF_DECnet = 12 // socket.h:375:1: + AF_DLI = 13 // socket.h:376:1: + AF_E164 = 28 // socket.h:391:1: + AF_ECMA = 8 // socket.h:371:1: + AF_HYLINK = 15 // socket.h:378:1: + AF_IEEE80211 = 37 // socket.h:403:1: + AF_IMPLINK = 3 // socket.h:365:1: + AF_INET = 2 // socket.h:363:1: + AF_INET6 = 30 // socket.h:394:1: + AF_IPX = 23 // socket.h:386:1: + AF_ISDN = 28 // socket.h:390:1: + AF_ISO = 7 // socket.h:369:1: + AF_LAT = 14 // socket.h:377:1: + AF_LINK = 18 // socket.h:381:1: + AF_LOCAL = 1 // socket.h:361:1: + AF_MAX = 41 // socket.h:406:1: + AF_NATM = 31 // socket.h:396:1: + AF_NDRV = 27 // socket.h:389:1: + AF_NETBIOS = 33 // socket.h:398:1: + AF_NS = 6 // socket.h:368:1: + AF_OSI = 7 // socket.h:370:1: + AF_PPP = 34 // socket.h:399:1: + AF_PUP = 4 // socket.h:366:1: + AF_RESERVED_36 = 36 // socket.h:402:1: + AF_ROUTE = 17 // socket.h:380:1: + AF_SIP = 24 // socket.h:387:1: + AF_SNA = 11 // socket.h:374:1: + AF_SYSTEM = 32 // socket.h:397:1: + AF_UNIX = 1 // socket.h:359:1: + AF_UNSPEC = 0 // socket.h:358:1: + AF_UTUN = 38 // socket.h:404:1: + AF_VSOCK = 40 // socket.h:405:1: + BIG_ENDIAN = 4321 // endian.h:72:1: + BYTE_ORDER = 1234 // endian.h:75:1: + CONNECT_DATA_AUTHENTICATED = 0x4 // socket.h:304:1: + CONNECT_DATA_IDEMPOTENT = 0x2 // socket.h:303:1: + CONNECT_RESUME_ON_READ_WRITE = 0x1 // socket.h:302:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + ICMP6_FILTER = 18 // in6.h:394:1: + ICMPV6CTL_ND6_ONLINKNSRFC4861 = 50 // in6.h:629:1: + INADDR_NONE = 0xffffffff // in.h:342:1: + INET6_ADDRSTRLEN = 46 // in6.h:162:1: + INET_ADDRSTRLEN = 16 // in.h:388:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + IN_CLASSA_HOST = 0x00ffffff // in.h:317:1: + IN_CLASSA_MAX = 128 // in.h:318:1: + IN_CLASSA_NET = 0xff000000 // in.h:315:1: + IN_CLASSA_NSHIFT = 24 // in.h:316:1: + IN_CLASSB_HOST = 0x0000ffff // in.h:323:1: + IN_CLASSB_MAX = 65536 // in.h:324:1: + IN_CLASSB_NET = 0xffff0000 // in.h:321:1: + IN_CLASSB_NSHIFT = 16 // in.h:322:1: + IN_CLASSC_HOST = 0x000000ff // in.h:329:1: + IN_CLASSC_NET = 0xffffff00 // in.h:327:1: + IN_CLASSC_NSHIFT = 8 // in.h:328:1: + IN_CLASSD_HOST = 0x0fffffff // in.h:334:1: + IN_CLASSD_NET = 0xf0000000 // in.h:332:1: + IN_CLASSD_NSHIFT = 28 // in.h:333:1: + IN_LOOPBACKNET = 127 // in.h:369:1: + IPCTL_ACCEPTSOURCEROUTE = 13 // in.h:650:1: + IPCTL_DEFTTL = 3 // in.h:638:1: + IPCTL_DIRECTEDBROADCAST = 9 // in.h:646:1: + IPCTL_FASTFORWARDING = 14 // in.h:651:1: + IPCTL_FORWARDING = 1 // in.h:636:1: + IPCTL_GIF_TTL = 16 // in.h:653:1: + IPCTL_INTRQDROPS = 11 // in.h:648:1: + IPCTL_INTRQMAXLEN = 10 // in.h:647:1: + IPCTL_KEEPFAITH = 15 // in.h:652:1: + IPCTL_MAXID = 17 // in.h:654:1: + IPCTL_RTEXPIRE = 5 // in.h:642:1: + IPCTL_RTMAXCACHE = 7 // in.h:644:1: + IPCTL_RTMINEXPIRE = 6 // in.h:643:1: + IPCTL_SENDREDIRECTS = 2 // in.h:637:1: + IPCTL_SOURCEROUTE = 8 // in.h:645:1: + IPCTL_STATS = 12 // in.h:649:1: + IPPORT_HIFIRSTAUTO = 49152 // in.h:286:1: + IPPORT_HILASTAUTO = 65535 // in.h:287:1: + IPPORT_RESERVED = 1024 // in.h:279:1: + IPPORT_RESERVEDSTART = 600 // in.h:295:1: + IPPORT_USERRESERVED = 5000 // in.h:281:1: + IPPROTO_3PC = 34 // in.h:139:1: + IPPROTO_ADFS = 68 // in.h:173:1: + IPPROTO_AH = 51 // in.h:158:1: + IPPROTO_AHIP = 61 // in.h:166:1: + IPPROTO_APES = 99 // in.h:204:1: + IPPROTO_ARGUS = 13 // in.h:116:1: + IPPROTO_AX25 = 93 // in.h:198:1: + IPPROTO_BHA = 49 // in.h:156:1: + IPPROTO_BLT = 30 // in.h:135:1: + IPPROTO_BRSATMON = 76 // in.h:181:1: + IPPROTO_CFTP = 62 // in.h:167:1: + IPPROTO_CHAOS = 16 // in.h:119:1: + IPPROTO_CMTP = 38 // in.h:143:1: + IPPROTO_CPHB = 73 // in.h:178:1: + IPPROTO_CPNX = 72 // in.h:177:1: + IPPROTO_DDP = 37 // in.h:142:1: + IPPROTO_DGP = 86 // in.h:191:1: + IPPROTO_DIVERT = 254 // in.h:213:1: + IPPROTO_DONE = 257 // in.h:221:1: + IPPROTO_DSTOPTS = 60 // in.h:165:1: + IPPROTO_EGP = 8 // in.h:111:1: + IPPROTO_EMCON = 14 // in.h:117:1: + IPPROTO_ENCAP = 98 // in.h:203:1: + IPPROTO_EON = 80 // in.h:185:1: + IPPROTO_ESP = 50 // in.h:157:1: + IPPROTO_ETHERIP = 97 // in.h:202:1: + IPPROTO_FRAGMENT = 44 // in.h:151:1: + IPPROTO_GGP = 3 // in.h:104:1: + IPPROTO_GMTP = 100 // in.h:205:1: + IPPROTO_GRE = 47 // in.h:154:1: + IPPROTO_HELLO = 63 // in.h:168:1: + IPPROTO_HMP = 20 // in.h:125:1: + IPPROTO_HOPOPTS = 0 // in.h:99:1: + IPPROTO_ICMP = 1 // in.h:101:1: + IPPROTO_ICMPV6 = 58 // in.h:163:1: + IPPROTO_IDP = 22 // in.h:127:1: + IPPROTO_IDPR = 35 // in.h:140:1: + IPPROTO_IDRP = 45 // in.h:152:1: + IPPROTO_IGMP = 2 // in.h:103:1: + IPPROTO_IGP = 85 // in.h:190:1: + IPPROTO_IGRP = 88 // in.h:193:1: + IPPROTO_IL = 40 // in.h:145:1: + IPPROTO_INLSP = 52 // in.h:159:1: + IPPROTO_INP = 32 // in.h:137:1: + IPPROTO_IP = 0 // in.h:97:1: + IPPROTO_IPCOMP = 108 // in.h:208:1: + IPPROTO_IPCV = 71 // in.h:176:1: + IPPROTO_IPEIP = 94 // in.h:199:1: + IPPROTO_IPIP = 4 // in.h:106:1: + IPPROTO_IPPC = 67 // in.h:172:1: + IPPROTO_IPV4 = 4 // in.h:105:1: + IPPROTO_IPV6 = 41 // in.h:147:1: + IPPROTO_IRTP = 28 // in.h:133:1: + IPPROTO_KRYPTOLAN = 65 // in.h:170:1: + IPPROTO_LARP = 91 // in.h:196:1: + IPPROTO_LEAF1 = 25 // in.h:130:1: + IPPROTO_LEAF2 = 26 // in.h:131:1: + IPPROTO_MAX = 256 // in.h:218:1: + IPPROTO_MAXID = 52 // in.h:630:1: + IPPROTO_MEAS = 19 // in.h:124:1: + IPPROTO_MHRP = 48 // in.h:155:1: + IPPROTO_MICP = 95 // in.h:200:1: + IPPROTO_MTP = 92 // in.h:197:1: + IPPROTO_MUX = 18 // in.h:123:1: + IPPROTO_ND = 77 // in.h:182:1: + IPPROTO_NHRP = 54 // in.h:161:1: + IPPROTO_NONE = 59 // in.h:164:1: + IPPROTO_NSP = 31 // in.h:136:1: + IPPROTO_NVPII = 11 // in.h:114:1: + IPPROTO_OSPFIGP = 89 // in.h:194:1: + IPPROTO_PGM = 113 // in.h:209:1: + IPPROTO_PIGP = 9 // in.h:112:1: + IPPROTO_PIM = 103 // in.h:207:1: + IPPROTO_PRM = 21 // in.h:126:1: + IPPROTO_PUP = 12 // in.h:115:1: + IPPROTO_PVP = 75 // in.h:180:1: + IPPROTO_RAW = 255 // in.h:215:1: + IPPROTO_RCCMON = 10 // in.h:113:1: + IPPROTO_RDP = 27 // in.h:132:1: + IPPROTO_ROUTING = 43 // in.h:150:1: + IPPROTO_RSVP = 46 // in.h:153:1: + IPPROTO_RVD = 66 // in.h:171:1: + IPPROTO_SATEXPAK = 64 // in.h:169:1: + IPPROTO_SATMON = 69 // in.h:174:1: + IPPROTO_SCCSP = 96 // in.h:201:1: + IPPROTO_SCTP = 132 // in.h:210:1: + IPPROTO_SDRP = 42 // in.h:149:1: + IPPROTO_SEP = 33 // in.h:138:1: + IPPROTO_SRPC = 90 // in.h:195:1: + IPPROTO_ST = 7 // in.h:110:1: + IPPROTO_SVMTP = 82 // in.h:187:1: + IPPROTO_SWIPE = 53 // in.h:160:1: + IPPROTO_TCF = 87 // in.h:192:1: + IPPROTO_TCP = 6 // in.h:108:1: + IPPROTO_TP = 29 // in.h:134:1: + IPPROTO_TPXX = 39 // in.h:144:1: + IPPROTO_TRUNK1 = 23 // in.h:128:1: + IPPROTO_TRUNK2 = 24 // in.h:129:1: + IPPROTO_TTP = 84 // in.h:189:1: + IPPROTO_UDP = 17 // in.h:121:1: + IPPROTO_VINES = 83 // in.h:188:1: + IPPROTO_VISA = 70 // in.h:175:1: + IPPROTO_VMTP = 81 // in.h:186:1: + IPPROTO_WBEXPAK = 79 // in.h:184:1: + IPPROTO_WBMON = 78 // in.h:183:1: + IPPROTO_WSN = 74 // in.h:179:1: + IPPROTO_XNET = 15 // in.h:118:1: + IPPROTO_XTP = 36 // in.h:141:1: + IPV6CTL_ACCEPT_RTADV = 12 // in6.h:594:1: + IPV6CTL_ADDRCTLPOLICY = 38 // in6.h:619:1: + IPV6CTL_AUTO_FLOWLABEL = 17 // in6.h:599:1: + IPV6CTL_AUTO_LINKLOCAL = 35 // in6.h:616:1: + IPV6CTL_DAD_COUNT = 16 // in6.h:598:1: + IPV6CTL_DEFHLIM = 3 // in6.h:583:1: + IPV6CTL_DEFMCASTHLIM = 18 // in6.h:600:1: + IPV6CTL_FORWARDING = 1 // in6.h:581:1: + IPV6CTL_FORWSRCRT = 5 // in6.h:587:1: + IPV6CTL_GIF_HLIM = 19 // in6.h:601:1: + IPV6CTL_HDRNESTLIMIT = 15 // in6.h:597:1: + IPV6CTL_KAME_VERSION = 20 // in6.h:602:1: + IPV6CTL_KEEPFAITH = 13 // in6.h:595:1: + IPV6CTL_LOG_INTERVAL = 14 // in6.h:596:1: + IPV6CTL_MAXDYNROUTES = 49 // in6.h:628:1: + IPV6CTL_MAXFRAGPACKETS = 9 // in6.h:591:1: + IPV6CTL_MAXFRAGS = 41 // in6.h:622:1: + IPV6CTL_MAXID = 51 // in6.h:635:1: + IPV6CTL_MAXIFDEFROUTERS = 48 // in6.h:627:1: + IPV6CTL_MAXIFPREFIXES = 47 // in6.h:626:1: + IPV6CTL_MCAST_PMTU = 44 // in6.h:623:1: + IPV6CTL_MRTPROTO = 8 // in6.h:590:1: + IPV6CTL_MRTSTATS = 7 // in6.h:589:1: + IPV6CTL_NEIGHBORGCTHRESH = 46 // in6.h:625:1: + IPV6CTL_PREFER_TEMPADDR = 37 // in6.h:618:1: + IPV6CTL_RIP6STATS = 36 // in6.h:617:1: + IPV6CTL_RR_PRUNE = 22 // in6.h:604:1: + IPV6CTL_RTEXPIRE = 25 // in6.h:609:1: + IPV6CTL_RTMAXCACHE = 27 // in6.h:611:1: + IPV6CTL_RTMINEXPIRE = 26 // in6.h:610:1: + IPV6CTL_SENDREDIRECTS = 2 // in6.h:582:1: + IPV6CTL_SOURCECHECK = 10 // in6.h:592:1: + IPV6CTL_SOURCECHECK_LOGINT = 11 // in6.h:593:1: + IPV6CTL_STATS = 6 // in6.h:588:1: + IPV6CTL_TEMPPLTIME = 33 // in6.h:614:1: + IPV6CTL_TEMPVLTIME = 34 // in6.h:615:1: + IPV6CTL_ULA_USETEMPADDR = 51 // in6.h:630:1: + IPV6CTL_USETEMPADDR = 32 // in6.h:613:1: + IPV6CTL_USE_DEFAULTZONE = 39 // in6.h:620:1: + IPV6CTL_USE_DEPRECATED = 21 // in6.h:603:1: + IPV6CTL_V6ONLY = 24 // in6.h:608:1: + IPV6PORT_ANONMAX = 65535 // in6.h:144:1: + IPV6PORT_ANONMIN = 49152 // in6.h:143:1: + IPV6PORT_RESERVED = 1024 // in6.h:142:1: + IPV6PORT_RESERVEDMAX = 1023 // in6.h:146:1: + IPV6PORT_RESERVEDMIN = 600 // in6.h:145:1: + IPV6PROTO_MAXID = 104 // in6.h:576:1: + IPV6_2292DSTOPTS = 23 // in6.h:399:1: + IPV6_2292HOPLIMIT = 20 // in6.h:396:1: + IPV6_2292HOPOPTS = 22 // in6.h:398:1: + IPV6_2292NEXTHOP = 21 // in6.h:397:1: + IPV6_2292PKTINFO = 19 // in6.h:395:1: + IPV6_2292PKTOPTIONS = 25 // in6.h:403:1: + IPV6_2292RTHDR = 24 // in6.h:400:1: + IPV6_ADDR_MC_FLAGS_PREFIX = 0x20 // in6.h:306:1: + IPV6_ADDR_MC_FLAGS_TRANSIENT = 0x10 // in6.h:305:1: + IPV6_ADDR_MC_FLAGS_UNICAST_BASED = 48 // in6.h:307:1: + IPV6_BINDV6ONLY = 27 // in6.h:419:1: + IPV6_BOUND_IF = 125 // in6.h:508:1: + IPV6_CHECKSUM = 26 // in6.h:415:1: + IPV6_DEFAULT_MULTICAST_HOPS = 1 // in6.h:520:1: + IPV6_DEFAULT_MULTICAST_LOOP = 1 // in6.h:521:1: + IPV6_FAITH = 29 // in6.h:425:1: + IPV6_FW_ADD = 30 // in6.h:428:1: + IPV6_FW_DEL = 31 // in6.h:429:1: + IPV6_FW_FLUSH = 32 // in6.h:430:1: + IPV6_FW_GET = 34 // in6.h:432:1: + IPV6_FW_ZERO = 33 // in6.h:431:1: + IPV6_IPSEC_POLICY = 28 // in6.h:423:1: + IPV6_JOIN_GROUP = 12 // in6.h:389:1: + IPV6_LEAVE_GROUP = 13 // in6.h:390:1: + IPV6_MAX_GROUP_SRC_FILTER = 512 // in6.h:535:1: + IPV6_MAX_MEMBERSHIPS = 4095 // in6.h:529:1: + IPV6_MAX_SOCK_SRC_FILTER = 128 // in6.h:536:1: + IPV6_MIN_MEMBERSHIPS = 31 // in6.h:528:1: + IPV6_MULTICAST_HOPS = 10 // in6.h:387:1: + IPV6_MULTICAST_IF = 9 // in6.h:386:1: + IPV6_MULTICAST_LOOP = 11 // in6.h:388:1: + IPV6_PORTRANGE = 14 // in6.h:393:1: + IPV6_PORTRANGE_DEFAULT = 0 // in6.h:566:1: + IPV6_PORTRANGE_HIGH = 1 // in6.h:567:1: + IPV6_PORTRANGE_LOW = 2 // in6.h:568:1: + IPV6_RECVTCLASS = 35 // in6.h:440:1: + IPV6_RTHDR_LOOSE = 0 // in6.h:513:1: + IPV6_RTHDR_STRICT = 1 // in6.h:514:1: + IPV6_RTHDR_TYPE_0 = 0 // in6.h:515:1: + IPV6_SOCKOPT_RESERVED1 = 3 // in6.h:383:1: + IPV6_TCLASS = 36 // in6.h:441:1: + IPV6_UNICAST_HOPS = 4 // in6.h:385:1: + IPV6_V6ONLY = 27 // in6.h:417:1: + IP_ADD_MEMBERSHIP = 12 // in.h:418:1: + IP_ADD_SOURCE_MEMBERSHIP = 70 // in.h:465:1: + IP_BLOCK_SOURCE = 72 // in.h:467:1: + IP_BOUND_IF = 25 // in.h:434:1: + IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:486:1: + IP_DEFAULT_MULTICAST_TTL = 1 // in.h:485:1: + IP_DONTFRAG = 28 // in.h:438:1: + IP_DROP_MEMBERSHIP = 13 // in.h:419:1: + IP_DROP_SOURCE_MEMBERSHIP = 71 // in.h:466:1: + IP_DUMMYNET_CONFIGURE = 60 // in.h:456:1: + IP_DUMMYNET_DEL = 61 // in.h:457:1: + IP_DUMMYNET_FLUSH = 62 // in.h:458:1: + IP_DUMMYNET_GET = 64 // in.h:459:1: + IP_FAITH = 22 // in.h:429:1: + IP_FW_ADD = 40 // in.h:440:1: + IP_FW_DEL = 41 // in.h:441:1: + IP_FW_FLUSH = 42 // in.h:442:1: + IP_FW_GET = 44 // in.h:444:1: + IP_FW_RESETLOG = 45 // in.h:445:1: + IP_FW_ZERO = 43 // in.h:443:1: + IP_HDRINCL = 2 // in.h:408:1: + IP_IPSEC_POLICY = 21 // in.h:428:1: + IP_MAX_GROUP_SRC_FILTER = 512 // in.h:500:1: + IP_MAX_MEMBERSHIPS = 4095 // in.h:494:1: + IP_MAX_SOCK_MUTE_FILTER = 128 // in.h:502:1: + IP_MAX_SOCK_SRC_FILTER = 128 // in.h:501:1: + IP_MIN_MEMBERSHIPS = 31 // in.h:493:1: + IP_MSFILTER = 74 // in.h:471:1: + IP_MULTICAST_IF = 9 // in.h:415:1: + IP_MULTICAST_IFINDEX = 66 // in.h:462:1: + IP_MULTICAST_LOOP = 11 // in.h:417:1: + IP_MULTICAST_TTL = 10 // in.h:416:1: + IP_MULTICAST_VIF = 14 // in.h:420:1: + IP_NAT__XXX = 55 // in.h:453:1: + IP_OLD_FW_ADD = 50 // in.h:448:1: + IP_OLD_FW_DEL = 51 // in.h:449:1: + IP_OLD_FW_FLUSH = 52 // in.h:450:1: + IP_OLD_FW_GET = 54 // in.h:452:1: + IP_OLD_FW_RESETLOG = 56 // in.h:454:1: + IP_OLD_FW_ZERO = 53 // in.h:451:1: + IP_OPTIONS = 1 // in.h:407:1: + IP_PKTINFO = 26 // in.h:435:1: + IP_PORTRANGE = 19 // in.h:425:1: + IP_PORTRANGE_DEFAULT = 0 // in.h:594:1: + IP_PORTRANGE_HIGH = 1 // in.h:595:1: + IP_PORTRANGE_LOW = 2 // in.h:596:1: + IP_RECVDSTADDR = 7 // in.h:413:1: + IP_RECVIF = 20 // in.h:426:1: + IP_RECVOPTS = 5 // in.h:411:1: + IP_RECVPKTINFO = 26 // in.h:436:1: + IP_RECVRETOPTS = 6 // in.h:412:1: + IP_RECVTOS = 27 // in.h:437:1: + IP_RECVTTL = 24 // in.h:433:1: + IP_RETOPTS = 8 // in.h:414:1: + IP_RSVP_OFF = 16 // in.h:422:1: + IP_RSVP_ON = 15 // in.h:421:1: + IP_RSVP_VIF_OFF = 18 // in.h:424:1: + IP_RSVP_VIF_ON = 17 // in.h:423:1: + IP_STRIPHDR = 23 // in.h:431:1: + IP_TOS = 3 // in.h:409:1: + IP_TRAFFIC_MGT_BACKGROUND = 65 // in.h:461:1: + IP_TTL = 4 // in.h:410:1: + IP_UNBLOCK_SOURCE = 73 // in.h:468:1: + KEV_DL_ADDMULTI = 7 // net_kev.h:61:1: + KEV_DL_AWDL_RESTRICTED = 26 // net_kev.h:80:1: + KEV_DL_AWDL_UNRESTRICTED = 27 // net_kev.h:81:1: + KEV_DL_DELMULTI = 8 // net_kev.h:62:1: + KEV_DL_IFCAP_CHANGED = 19 // net_kev.h:73:1: + KEV_DL_IFDELEGATE_CHANGED = 25 // net_kev.h:79:1: + KEV_DL_IF_ATTACHED = 9 // net_kev.h:63:1: + KEV_DL_IF_DETACHED = 11 // net_kev.h:65:1: + KEV_DL_IF_DETACHING = 10 // net_kev.h:64:1: + KEV_DL_IF_IDLE_ROUTE_REFCNT = 18 // net_kev.h:72:1: + KEV_DL_ISSUES = 24 // net_kev.h:78:1: + KEV_DL_LINK_ADDRESS_CHANGED = 16 // net_kev.h:70:1: + KEV_DL_LINK_OFF = 12 // net_kev.h:66:1: + KEV_DL_LINK_ON = 13 // net_kev.h:67:1: + KEV_DL_LINK_QUALITY_METRIC_CHANGED = 20 // net_kev.h:74:1: + KEV_DL_LOW_POWER_MODE_CHANGED = 30 // net_kev.h:84:1: + KEV_DL_NODE_ABSENCE = 22 // net_kev.h:76:1: + KEV_DL_NODE_PRESENCE = 21 // net_kev.h:75:1: + KEV_DL_PRIMARY_ELECTED = 23 // net_kev.h:77:1: + KEV_DL_PROTO_ATTACHED = 14 // net_kev.h:68:1: + KEV_DL_PROTO_DETACHED = 15 // net_kev.h:69:1: + KEV_DL_QOS_MODE_CHANGED = 29 // net_kev.h:83:1: + KEV_DL_RRC_STATE_CHANGED = 28 // net_kev.h:82:1: + KEV_DL_SIFFLAGS = 1 // net_kev.h:55:1: + KEV_DL_SIFGENERIC = 6 // net_kev.h:60:1: + KEV_DL_SIFMEDIA = 5 // net_kev.h:59:1: + KEV_DL_SIFMETRICS = 2 // net_kev.h:56:1: + KEV_DL_SIFMTU = 3 // net_kev.h:57:1: + KEV_DL_SIFPHYS = 4 // net_kev.h:58:1: + KEV_DL_SUBCLASS = 2 // net_kev.h:50:1: + KEV_DL_WAKEFLAGS_CHANGED = 17 // net_kev.h:71:1: + KEV_INET6_ADDR_DELETED = 3 // net_kev.h:93:1: + KEV_INET6_CHANGED_ADDR = 2 // net_kev.h:92:1: + KEV_INET6_DEFROUTER = 6 // net_kev.h:96:1: + KEV_INET6_NEW_LL_ADDR = 4 // net_kev.h:94:1: + KEV_INET6_NEW_RTADV_ADDR = 5 // net_kev.h:95:1: + KEV_INET6_NEW_USER_ADDR = 1 // net_kev.h:91:1: + KEV_INET6_REQUEST_NAT64_PREFIX = 7 // net_kev.h:97:1: + KEV_INET6_SUBCLASS = 6 // net_kev.h:89:1: + KEV_INET_ADDR_DELETED = 3 // net_kev.h:39:1: + KEV_INET_ARPCOLLISION = 7 // net_kev.h:43:1: + KEV_INET_ARPRTRALIVE = 10 // net_kev.h:48:1: + KEV_INET_ARPRTRFAILURE = 9 // net_kev.h:47:1: + KEV_INET_CHANGED_ADDR = 2 // net_kev.h:38:1: + KEV_INET_NEW_ADDR = 1 // net_kev.h:37:1: + KEV_INET_PORTINUSE = 8 // net_kev.h:45:1: + KEV_INET_SIFBRDADDR = 5 // net_kev.h:41:1: + KEV_INET_SIFDSTADDR = 4 // net_kev.h:40:1: + KEV_INET_SIFNETMASK = 6 // net_kev.h:42:1: + KEV_INET_SUBCLASS = 1 // net_kev.h:35:1: + LITTLE_ENDIAN = 1234 // endian.h:71:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + MCAST_BLOCK_SOURCE = 84 // in.h:478:1: + MCAST_EXCLUDE = 2 // in.h:588:1: + MCAST_INCLUDE = 1 // in.h:587:1: + MCAST_JOIN_GROUP = 80 // in.h:474:1: + MCAST_JOIN_SOURCE_GROUP = 82 // in.h:476:1: + MCAST_LEAVE_GROUP = 81 // in.h:475:1: + MCAST_LEAVE_SOURCE_GROUP = 83 // in.h:477:1: + MCAST_UNBLOCK_SOURCE = 85 // in.h:479:1: + MCAST_UNDEFINED = 0 // in.h:586:1: + MSG_CTRUNC = 0x20 // socket.h:569:1: + MSG_DONTROUTE = 0x4 // socket.h:566:1: + MSG_DONTWAIT = 0x80 // socket.h:572:1: + MSG_EOF = 0x100 // socket.h:573:1: + MSG_EOR = 0x8 // socket.h:567:1: + MSG_FLUSH = 0x400 // socket.h:578:1: + MSG_HAVEMORE = 0x2000 // socket.h:581:1: + MSG_HOLD = 0x800 // socket.h:579:1: + MSG_NEEDSA = 0x10000 // socket.h:584:1: + MSG_NOSIGNAL = 0x80000 // socket.h:588:1: + MSG_OOB = 0x1 // socket.h:564:1: + MSG_PEEK = 0x2 // socket.h:565:1: + MSG_RCVMORE = 0x4000 // socket.h:582:1: + MSG_SEND = 0x1000 // socket.h:580:1: + MSG_TRUNC = 0x10 // socket.h:568:1: + MSG_WAITALL = 0x40 // socket.h:570:1: + MSG_WAITSTREAM = 0x200 // socket.h:576:1: + NBBY = 8 // types.h:186:1: + NETSVC_MRKNG_LVL_L2 = 1 // socket.h:287:1: + NETSVC_MRKNG_LVL_L3L2_ALL = 2 // socket.h:288:1: + NETSVC_MRKNG_LVL_L3L2_BK = 3 // socket.h:289:1: + NETSVC_MRKNG_UNKNOWN = 0 // socket.h:286:1: + NET_MAXID = 41 // socket.h:512:1: + NET_RT_DUMP = 1 // socket.h:525:1: + NET_RT_DUMP2 = 7 // socket.h:531:1: + NET_RT_FLAGS = 2 // socket.h:526:1: + NET_RT_FLAGS_PRIV = 10 // socket.h:536:1: + NET_RT_IFLIST = 3 // socket.h:527:1: + NET_RT_IFLIST2 = 6 // socket.h:530:1: + NET_RT_MAXID = 11 // socket.h:537:1: + NET_RT_STAT = 4 // socket.h:528:1: + NET_RT_TRASH = 5 // socket.h:529:1: + NET_SERVICE_TYPE_AV = 6 // socket.h:280:1: + NET_SERVICE_TYPE_BE = 0 // socket.h:274:1: + NET_SERVICE_TYPE_BK = 1 // socket.h:275:1: + NET_SERVICE_TYPE_OAM = 7 // socket.h:281:1: + NET_SERVICE_TYPE_RD = 8 // socket.h:282:1: + NET_SERVICE_TYPE_RV = 5 // socket.h:279:1: + NET_SERVICE_TYPE_SIG = 2 // socket.h:276:1: + NET_SERVICE_TYPE_VI = 3 // socket.h:277:1: + NET_SERVICE_TYPE_VO = 4 // socket.h:278:1: + PDP_ENDIAN = 3412 // endian.h:73:1: + PF_APPLETALK = 16 // socket.h:474:1: + PF_CCITT = 10 // socket.h:468:1: + PF_CHAOS = 5 // socket.h:462:1: + PF_CNT = 21 // socket.h:479:1: + PF_COIP = 20 // socket.h:478:1: + PF_DATAKIT = 9 // socket.h:467:1: + PF_DECnet = 12 // socket.h:470:1: + PF_DLI = 13 // socket.h:471:1: + PF_ECMA = 8 // socket.h:466:1: + PF_HYLINK = 15 // socket.h:473:1: + PF_IMPLINK = 3 // socket.h:460:1: + PF_INET = 2 // socket.h:459:1: + PF_INET6 = 30 // socket.h:487:1: + PF_IPX = 23 // socket.h:481:1: + PF_ISDN = 28 // socket.h:485:1: + PF_ISO = 7 // socket.h:464:1: + PF_KEY = 29 // socket.h:486:1: + PF_LAT = 14 // socket.h:472:1: + PF_LINK = 18 // socket.h:476:1: + PF_LOCAL = 1 // socket.h:457:1: + PF_MAX = 41 // socket.h:495:1: + PF_NATM = 31 // socket.h:488:1: + PF_NDRV = 27 // socket.h:484:1: + PF_NETBIOS = 33 // socket.h:490:1: + PF_NS = 6 // socket.h:463:1: + PF_OSI = 7 // socket.h:465:1: + PF_PIP = 25 // socket.h:483:1: + PF_PPP = 34 // socket.h:491:1: + PF_PUP = 4 // socket.h:461:1: + PF_RESERVED_36 = 36 // socket.h:492:1: + PF_ROUTE = 17 // socket.h:475:1: + PF_RTIP = 22 // socket.h:482:1: + PF_SIP = 24 // socket.h:480:1: + PF_SNA = 11 // socket.h:469:1: + PF_SYSTEM = 32 // socket.h:489:1: + PF_UNIX = 1 // socket.h:458:1: + PF_UNSPEC = 0 // socket.h:456:1: + PF_UTUN = 38 // socket.h:493:1: + PF_VSOCK = 40 // socket.h:494:1: + PF_XTP = 19 // socket.h:477:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + SAE_ASSOCID_ANY = 0 // socket.h:294:1: + SAE_CONNID_ANY = 0 // socket.h:298:1: + SCM_CREDS = 0x03 // socket.h:674:1: + SCM_RIGHTS = 0x01 // socket.h:671:1: + SCM_TIMESTAMP = 0x02 // socket.h:673:1: + SCM_TIMESTAMP_MONOTONIC = 0x04 // socket.h:675:1: + SHUT_RD = 0 // socket.h:683:1: + SHUT_RDWR = 2 // socket.h:685:1: + SHUT_WR = 1 // socket.h:684:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIN6_LEN = 0 // in6.h:168:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + SOCK_DGRAM = 2 // socket.h:113:1: + SOCK_MAXADDRLEN = 255 // socket.h:419:1: + SOCK_RAW = 3 // socket.h:114:1: + SOCK_RDM = 4 // socket.h:116:1: + SOCK_SEQPACKET = 5 // socket.h:118:1: + SOCK_STREAM = 1 // socket.h:112:1: + SOL_SOCKET = 0xffff // socket.h:352:1: + SOMAXCONN = 128 // socket.h:546:1: + SONPX_SETOPTSHUT = 0x000000001 // socket.h:342:1: + SO_ACCEPTCONN = 0x0002 // socket.h:124:1: + SO_BROADCAST = 0x0020 // socket.h:128:1: + SO_DEBUG = 0x0001 // socket.h:123:1: + SO_DONTROUTE = 0x0010 // socket.h:127:1: + SO_DONTTRUNC = 0x2000 // socket.h:143:1: + SO_ERROR = 0x1007 // socket.h:161:1: + SO_KEEPALIVE = 0x0008 // socket.h:126:1: + SO_LABEL = 0x1010 // socket.h:164:1: + SO_LINGER = 0x0080 // socket.h:131:1: + SO_LINGER_SEC = 0x1080 // socket.h:177:1: + SO_NETSVC_MARKING_LEVEL = 0x1119 // socket.h:186:1: + SO_NET_SERVICE_TYPE = 0x1116 // socket.h:183:1: + SO_NKE = 0x1021 // socket.h:168:1: + SO_NOADDRERR = 0x1023 // socket.h:170:1: + SO_NOSIGPIPE = 0x1022 // socket.h:169:1: + SO_NOTIFYCONFLICT = 0x1026 // socket.h:174:1: + SO_NP_EXTENSIONS = 0x1083 // socket.h:179:1: + SO_NREAD = 0x1020 // socket.h:167:1: + SO_NUMRCVPKT = 0x1112 // socket.h:182:1: + SO_NWRITE = 0x1024 // socket.h:171:1: + SO_OOBINLINE = 0x0100 // socket.h:135:1: + SO_PEERLABEL = 0x1011 // socket.h:165:1: + SO_RANDOMPORT = 0x1082 // socket.h:178:1: + SO_RCVBUF = 0x1002 // socket.h:156:1: + SO_RCVLOWAT = 0x1004 // socket.h:158:1: + SO_RCVTIMEO = 0x1006 // socket.h:160:1: + SO_REUSEADDR = 0x0004 // socket.h:125:1: + SO_REUSEPORT = 0x0200 // socket.h:137:1: + SO_REUSESHAREUID = 0x1025 // socket.h:172:1: + SO_SNDBUF = 0x1001 // socket.h:155:1: + SO_SNDLOWAT = 0x1003 // socket.h:157:1: + SO_SNDTIMEO = 0x1005 // socket.h:159:1: + SO_TIMESTAMP = 0x0400 // socket.h:138:1: + SO_TIMESTAMP_MONOTONIC = 0x0800 // socket.h:139:1: + SO_TYPE = 0x1008 // socket.h:162:1: + SO_UPCALLCLOSEWAIT = 0x1027 // socket.h:175:1: + SO_USELOOPBACK = 0x0040 // socket.h:130:1: + SO_WANTMORE = 0x4000 // socket.h:145:1: + SO_WANTOOBFLAG = 0x8000 // socket.h:146:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + X_ARM_ARCH_H = 0 // arch.h:29:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_ARM__ENDIAN_H_ = 0 // endian.h:43:1: + X_ARM__PARAM_H_ = 0 // _param.h:6:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__PARAM_H_ = 0 // _param.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // stdint.h:251:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NETINET6_IN6_H_ = 0 // in6.h:99:1: + X_NETINET_IN_H_ = 0 // in.h:65:1: + X_NET_NETKEV_H_ = 0 // net_kev.h:30:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS_OSBYTEORDERARM_H = 0 // OSByteOrder.h:6:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:56:1: + X_QUAD_LOWWORD = 0 // endian.h:57:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SA_FAMILY_T = 0 // _sa_family_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SOCKLEN_T = 0 // _socklen_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SS_MAXSIZE = 128 // socket.h:434:1: + X_STRUCT_IOVEC = 0 // _iovec_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_SOCKET_H_ = 0 // socket.h:73:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // stdint.h:257:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: + Pseudo_AF_HDRCMPLT = 35 // socket.h:400:1: + Pseudo_AF_KEY = 29 // socket.h:392:1: + Pseudo_AF_PIP = 25 // socket.h:388:1: + Pseudo_AF_RTIP = 22 // socket.h:385:1: + Pseudo_AF_XTP = 19 // socket.h:382:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 +// $FreeBSD: src/sys/netinet/in.h,v 1.48.2.2 2001/04/21 14:53:06 ume Exp $ + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +//===---- stdint.h - Standard header for sized integer types --------------===* * +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// \*===----------------------------------------------------------------------=== + +// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T +// is defined until an inclusion of it without _STD_TYPES_T occurs, in which +// case the header guard macro is defined. + +// If we're hosted, fall back to the system's stdint.h, which might have +// additional definitions. + +// C99 7.18.1.1 Exact-width integer types. +// C99 7.18.1.2 Minimum-width integer types. +// C99 7.18.1.3 Fastest minimum-width integer types. +// +// The standard requires that exact-width type be defined for 8-, 16-, 32-, and +// 64-bit types if they are implemented. Other exact width types are optional. +// This implementation defines an exact-width types for every integer width +// that is represented in the standard integer types. +// +// The standard also requires minimum-width types be defined for 8-, 16-, 32-, +// and 64-bit widths regardless of whether there are corresponding exact-width +// types. +// +// To accommodate targets that are missing types that are exactly 8, 16, 32, or +// 64 bits wide, this implementation takes an approach of cascading +// redefinitions, redefining __int_leastN_t to successively smaller exact-width +// types. It is therefore important that the types are defined in order of +// descending widths. +// +// We currently assume that the minimum-width types and the fastest +// minimum-width types are the same. This is allowed by the standard, but is +// suboptimal. +// +// In violation of the standard, some targets do not implement a type that is +// wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit). +// To accommodate these targets, a required minimum-width type is only +// defined if there exists an exact-width type of equal or greater width. + +type Int64_t = int64 /* stdint.h:96:24 */ +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Int32_t = int32 /* stdint.h:167:24 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ + +type Int16_t = int16 /* stdint.h:205:24 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ + +type Int8_t = int8 /* stdint.h:224:23 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +type Intptr_t = int64 /* stdint.h:249:25 */ + +type Uintptr_t = uint64 /* stdint.h:256:26 */ + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// C99 7.18.4 Macros for minimum-width integer constants. +// +// The standard requires that integer constant macros be defined for all the +// minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width +// types are required, the corresponding integer constant macros are defined +// here. This implementation also defines minimum-width types for every other +// integer width that the target implements, so corresponding macros are +// defined below, too. +// +// These macros are defined using the same successive-shrinking approach as +// the type definitions above. It is likewise important that macros are defined +// in order of decending width. +// +// Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// C99 7.18.2.1 Limits of exact-width integer types. +// C99 7.18.2.2 Limits of minimum-width integer types. +// C99 7.18.2.3 Limits of fastest minimum-width integer types. +// +// The presence of limit macros are completely optional in C99. This +// implementation defines limits for all of the types (exact- and +// minimum-width) that it defines above, using the limits of the minimum-width +// type for any types that do not have exact-width representations. +// +// As in the type definitions, this section takes an approach of +// successive-shrinking to determine which limits to use for the standard (8, +// 16, 32, 64) bit widths when they don't have exact representations. It is +// therefore important that the definitions be kept in order of decending +// widths. +// +// Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// Some utility macros + +// C99 7.18.2.4 Limits of integer types capable of holding object pointers. +// C99 7.18.3 Limits of other integer types. + +// ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ +// is enabled. + +// C99 7.18.2.5 Limits of greatest-width integer types. + +// C99 7.18.3 Limits of other integer types. + +// 7.18.4.2 Macros for greatest-width integer constants. + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support clang language extensions. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support clang language extensions. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ + +// POSIX 1003.1-2003 +// "Inclusion of the header may also make visible all +// symbols from and ". +// Copyright (c) 2000-2019 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1985, 1986, 1988, 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. +// +// @(#)socket.h 8.4 (Berkeley) 2/21/94 +// $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $ +// NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce +// support for mandatory and extensible security protections. This notice +// is included in support of clause 2.2 (b) of the Apple Public License, +// Version 2.0. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1991, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)types.h 8.4 (Berkeley) 1/21/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Machine type dependent parameters. +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Functions for byte reversed loads. + +type X_OSUnalignedU16 = struct{ F__val Uint16_t } /* OSByteOrder.h:64:1 */ + +type X_OSUnalignedU32 = struct{ F__val Uint32_t } /* OSByteOrder.h:68:1 */ + +type X_OSUnalignedU64 = struct{ F__val Uint64_t } /* OSByteOrder.h:72:1 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2006-2007 Apple Inc. All rights reserved. + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// Round p (pointer or byte index) up to a correctly-aligned value for all +// data types (int, long, ...). The result is unsigned int and must be +// cast to any desired pointer type. + +// Copyright (c) 2016-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Kernel event subclass identifiers for KEV_NETWORK_CLASS +// KEV_INET_SUBCLASS event codes + +// Define Data-Link event subclass, and associated +// events. + +// KEV_INET6_SUBCLASS event codes + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Definitions related to sockets: types, address families, options. + +// Data types. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Sa_family_t = X__uint8_t /* _sa_family_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Socklen_t = X__darwin_socklen_t /* _socklen_t.h:31:33 */ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The iovec structure shall be defined as described in . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* _iovec_t.h:31:1 */ + +// Types + +// Option flags per-socket. +// (ATOMIC proto) + +// Additional options, not kept in so_options. + +// When adding new socket-options, you need to make sure MPTCP supports these as well! + +// Network Service Type for option SO_NET_SERVICE_TYPE +// +// The vast majority of sockets should use Best Effort that is the default +// Network Service Type. Other Network Service Types have to be used only if +// the traffic actually matches the description of the Network Service Type. +// +// Network Service Types do not represent priorities but rather describe +// different categories of delay, jitter and loss parameters. +// Those parameters may influence protocols from layer 4 protocols like TCP +// to layer 2 protocols like Wi-Fi. The Network Service Type can determine +// how the traffic is queued and scheduled by the host networking stack and +// by other entities on the network like switches and routers. For example +// for Wi-Fi, the Network Service Type can select the marking of the +// layer 2 packet with the appropriate WMM Access Category. +// +// There is no point in attempting to game the system and use +// a Network Service Type that does not correspond to the actual +// traffic characteristic but one that seems to have a higher precedence. +// The reason is that for service classes that have lower tolerance +// for delay and jitter, the queues size is lower than for service +// classes that are more tolerant to delay and jitter. +// +// For example using a voice service type for bulk data transfer will lead +// to disastrous results as soon as congestion happens because the voice +// queue overflows and packets get dropped. This is not only bad for the bulk +// data transfer but it is also bad for VoIP apps that legitimately are using +// the voice service type. +// +// The characteristics of the Network Service Types are based on the service +// classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service +// Classes" +// +// When system detects the outgoing interface belongs to a DiffServ domain +// that follows the recommendation of the IETF draft "Guidelines for DiffServ to +// IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value +// that corresponds to Network Service Type. +// +// NET_SERVICE_TYPE_BE +// "Best Effort", unclassified/standard. This is the default service +// class and cover the majority of the traffic. +// +// NET_SERVICE_TYPE_BK +// "Background", high delay tolerant, loss tolerant. elastic flow, +// variable size & long-lived. E.g: non-interactive network bulk transfer +// like synching or backup. +// +// NET_SERVICE_TYPE_RD +// "Responsive Data", a notch higher than "Best Effort", medium delay +// tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, +// instant messaging, for which there is a sense of interactivity and +// urgency (user waiting for output). +// +// NET_SERVICE_TYPE_OAM +// "Operations, Administration, and Management", medium delay tolerant, +// low-medium loss tolerant, elastic & inelastic flows, variable size. +// E.g. VPN tunnels. +// +// NET_SERVICE_TYPE_AV +// "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium +// loss tolerant, elastic flow, constant packet interval, variable rate +// and size. E.g. video and audio playback with buffering. +// +// NET_SERVICE_TYPE_RV +// "Responsive Multimedia Audio/Video", low delay tolerant, low-medium +// loss tolerant, elastic flow, variable packet interval, rate and size. +// E.g. screen sharing. +// +// NET_SERVICE_TYPE_VI +// "Interactive Video", low delay tolerant, low-medium loss tolerant, +// elastic flow, constant packet interval, variable rate & size. E.g. +// video telephony. +// +// NET_SERVICE_TYPE_SIG +// "Signaling", low delay tolerant, low loss tolerant, inelastic flow, +// jitter tolerant, rate is bursty but short, variable size. E.g. SIP. +// +// NET_SERVICE_TYPE_VO +// "Interactive Voice", very low delay tolerant, very low loss tolerant, +// inelastic flow, constant packet rate, somewhat fixed size. +// E.g. VoIP. + +// These are supported values for SO_NETSVC_MARKING_LEVEL + +type Sae_associd_t = X__uint32_t /* socket.h:293:20 */ + +type Sae_connid_t = X__uint32_t /* socket.h:297:20 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints = struct { + Fsae_srcif uint32 + F__ccgo_pad1 [4]byte + Fsae_srcaddr uintptr + Fsae_srcaddrlen Socklen_t + F__ccgo_pad2 [4]byte + Fsae_dstaddr uintptr + Fsae_dstaddrlen Socklen_t + F__ccgo_pad3 [4]byte +} /* socket.h:307:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sockaddr = struct { + Fsa_len X__uint8_t + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:307:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints_t = Sa_endpoints /* socket.h:313:3 */ + +// Structure used for manipulating linger option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:319:1 */ + +// Structure to control non-portable Sockets extension to POSIX +type So_np_extensions = struct { + Fnpx_flags U_int32_t + Fnpx_mask U_int32_t +} /* socket.h:337:1 */ + +// Structure used by kernel to pass protocol +// information in raw sockets. +type Sockproto = struct { + Fsp_family X__uint16_t + Fsp_protocol X__uint16_t +} /* socket.h:425:1 */ + +// RFC 2553: protocol-independent placeholder for socket addresses + +// [XSI] sockaddr_storage +type Sockaddr_storage = struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 +} /* socket.h:445:1 */ + +// Protocol families, same as address families for now. + +// These do not have socket-layer support: + +// Definitions for network related sysctl, CTL_NET. +// +// Second level is protocol family. +// Third level is protocol number. +// +// Further levels are defined by the individual families below. + +// PF_ROUTE - Routing table +// +// Three additional levels are defined: +// Fourth: address family, 0 is wildcard +// Fifth: type of info, defined below +// Sixth: flag(s) to mask with for NET_RT_FLAGS +// Allows read access non-local host's MAC address +// if the process has neighbor cache entitlement. + +// Maximum queue length specifiable by listen. + +// [XSI] Message header for recvmsg and sendmsg calls. +// Used value-result for recvmsg, value only for sendmsg. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__ccgo_pad2 [4]byte + Fmsg_control uintptr + Fmsg_controllen Socklen_t + Fmsg_flags int32 +} /* socket.h:552:1 */ + +// Header for ancillary data objects in msg_control buffer. +// Used for additional information with/about a datagram +// not expressible by flags. The format is a sequence +// of message elements headed by cmsghdr structures. +type Cmsghdr = struct { + Fcmsg_len Socklen_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:600:1 */ + +// given pointer to struct cmsghdr, return pointer to data + +// RFC 2292 requires to check msg_controllen, in case that the kernel returns +// an empty list for some reasons. + +// Given pointer to struct cmsghdr, return pointer to next cmsghdr +// RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) + +// RFC 2292 additions + +// "Socket"-level control message types: + +// howto arguments for shutdown(2), specified by Posix.1g. + +// sendfile(2) header/trailer struct +type Sf_hdtr = struct { + Fheaders uintptr + Fhdr_cnt int32 + F__ccgo_pad1 [4]byte + Ftrailers uintptr + Ftrl_cnt int32 + F__ccgo_pad2 [4]byte +} /* socket.h:691:1 */ + +// The following two #includes insure htonl and family are defined +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2004, 2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1987, 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. + +// Constants and structures defined by the internet system, +// Per RFC 790, September 1981, and numerous additions. + +// Protocols (RFC 1700) +// 55-57: Unassigned +// 101-252: Partly Unassigned +// 253-254: Experimentation and testing; 255: Reserved (RFC3692) +// BSD Private, local use, namespace incursion + +// last return value of *_input(), meaning "all job for this pkt is done". + +// Local port number conventions: +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// The default range is IPPORT_RESERVED through +// IPPORT_USERRESERVED, although that is settable by sysctl. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH changes the range of candidate port numbers +// into the "high" range. These are reserved for client outbound connections +// which do not want to be filtered by any firewalls. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. This +// convention is based on "vouchsafe" principles only. It is only secure +// if you trust the remote host to restrict these ports. +// +// The default range of ports and the high range can be changed by +// sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) +// +// Changing those values has bad security implications if you are +// using a a stateless firewall that is allowing packets outside of that +// range in order to allow transparent outgoing connections. +// +// Such a firewall configuration will generally depend on the use of these +// default values. If you change them, you may find your Security +// Administrator looking for you with a heavy object. +// +// For a slightly more orthodox text view on this: +// +// ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers +// +// port numbers are divided into three ranges: +// +// 0 - 1023 Well Known Ports +// 1024 - 49151 Registered Ports +// 49152 - 65535 Dynamic and/or Private Ports +// + +// Ports < IPPORT_RESERVED are reserved for +// privileged processes (e.g. root). (IP_PORTRANGE_LOW) +// Ports > IPPORT_USERRESERVED are reserved +// for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) + +// Default local port range to use by setting IP_PORTRANGE_HIGH + +// Scanning for a free reserved port return a value below IPPORT_RESERVED, +// but higher than IPPORT_RESERVEDSTART. Traditionally the start value was +// 512, but that conflicts with some well-known-services that firewalls may +// have a fit if we use. + +// Internet address (a structure for historical reasons) +type In_addr = struct{ Fs_addr In_addr_t } /* in.h:301:1 */ + +// Definitions of bits in internet address integers. +// On subnets, the decomposition of addresses to host and net parts +// is done according to subnet mask, not the masks here. + +// Socket address, internet style. +type Sockaddr_in = struct { + Fsin_len X__uint8_t + Fsin_family Sa_family_t + Fsin_port In_port_t + Fsin_addr struct{ Fs_addr In_addr_t } + Fsin_zero [8]int8 +} /* in.h:375:1 */ + +// Structure used to describe IP options. +// Used to store options internally, to pass them to a process, +// or to restore options retrieved earlier. +// The ip_dst is used for the first-hop gateway when using a source route +// (this gets put into the header proper). +type Ip_opts = struct { + Fip_dst struct{ Fs_addr In_addr_t } + Fip_opts [40]int8 +} /* in.h:398:1 */ + +// Options for use with [gs]etsockopt at the IP level. +// First word of comment is data type; bool is stored in int. +// for IPSEC + +// These older firewall socket option codes are maintained for backward compatibility. + +// IPv4 Source Filter Multicast API [RFC3678] + +// The following option is private; do not use it from user applications. + +// Protocol Independent Multicast API [RFC3678] + +// Defaults and limits for options + +// The imo_membership vector for each socket is now dynamically allocated at +// run-time, bounded by USHRT_MAX, and is reallocated when needed, sized +// according to a power-of-two increment. + +// Default resource limits for IPv4 multicast source filtering. +// These may be modified by sysctl. + +// Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. +type Ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:507:1 */ + +// Modified argument structure for IP_MULTICAST_IF, obtained from Linux. +// This is used to specify an interface index for multicast sends, as +// the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). +type Ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_address struct{ Fs_addr In_addr_t } + Fimr_ifindex int32 +} /* in.h:517:1 */ + +// Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] +type Ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_sourceaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:527:1 */ + +// Argument structures for Protocol-Independent Multicast Source +// Filter APIs. [RFC3678] +type Group_req = struct { + Fgr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } +} /* in.h:537:1 */ + +type Group_source_req = struct { + Fgsr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } + Fgsr_source struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } +} /* in.h:542:1 */ + +// The following structure is private; do not use it from user applications. +// It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between +// the RFC 3678 libc functions and the kernel. +type X__msfilterreq = struct { + Fmsfr_ifindex Uint32_t + Fmsfr_fmode Uint32_t + Fmsfr_nsrcs Uint32_t + F__msfr_align Uint32_t + Fmsfr_group struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 + } + Fmsfr_srcs uintptr +} /* in.h:555:1 */ + +// Filter modes; also used to represent per-socket filter mode internally. + +// Argument for IP_PORTRANGE: +// - which range to search when port is unspecified at bind() or connect() + +// IP_PKTINFO: Packet information (equivalent to RFC2292 sec 5 for IPv4) +// This structure is used for +// +// 1. Receiving ancilliary data about the datagram if IP_PKTINFO sockopt is +// set on the socket. In this case ipi_ifindex will contain the interface +// index the datagram was received on, ipi_addr is the IP address the +// datagram was received to. +// +// 2. Sending a datagram using a specific interface or IP source address. +// if ipi_ifindex is set to non-zero when in_pktinfo is passed as +// ancilliary data of type IP_PKTINFO, this will be used as the source +// interface to send the datagram from. If ipi_ifindex is null, ip_spec_dst +// will be used for the source address. +// +// Note: if IP_BOUND_IF is set on the socket, ipi_ifindex in the ancillary +// IP_PKTINFO option silently overrides the bound interface when it is +// specified during send time. +type In_pktinfo = struct { + Fipi_ifindex uint32 + Fipi_spec_dst struct{ Fs_addr In_addr_t } + Fipi_addr struct{ Fs_addr In_addr_t } +} /* in.h:618:1 */ + +// Definitions for inet sysctl operations. +// +// Third level is protocol number. +// Fourth level is desired variable within that protocol. + +// Names for IP sysctl objects + +// INET6 stuff +// Copyright (c) 2008-2020 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +// 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 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Identification of the network protocol stack +// for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE +// has the table of implementation/integration differences. + +// Local port number conventions: +// +// Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), +// unless a kernel is compiled with IPNOPRIVPORTS defined. +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// +// The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although +// that is settable by sysctl(3); net.inet.ip.anonportmin and +// net.inet.ip.anonportmax respectively. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, +// and exists only for FreeBSD compatibility purposes. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. +// This convention is based on "vouchsafe" principles only. +// It is only secure if you trust the remote host to restrict these ports. +// The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + +// IPv6 address +type In6_addr = struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } +} /* in6.h:152:9 */ + +// Definitions for inet sysctl operations. +// +// Third level is protocol number. +// Fourth level is desired variable within that protocol. + +// Names for IP sysctl objects + +// INET6 stuff +// Copyright (c) 2008-2020 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. +// 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 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 PROJECT AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +// Copyright (c) 1982, 1986, 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. +// +// @(#)in.h 8.3 (Berkeley) 1/3/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Identification of the network protocol stack +// for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE +// has the table of implementation/integration differences. + +// Local port number conventions: +// +// Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), +// unless a kernel is compiled with IPNOPRIVPORTS defined. +// +// When a user does a bind(2) or connect(2) with a port number of zero, +// a non-conflicting local port address is chosen. +// +// The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although +// that is settable by sysctl(3); net.inet.ip.anonportmin and +// net.inet.ip.anonportmax respectively. +// +// A user may set the IPPROTO_IP option IP_PORTRANGE to change this +// default assignment range. +// +// The value IP_PORTRANGE_DEFAULT causes the default behavior. +// +// The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, +// and exists only for FreeBSD compatibility purposes. +// +// The value IP_PORTRANGE_LOW changes the range to the "low" are +// that is (by convention) restricted to privileged processes. +// This convention is based on "vouchsafe" principles only. +// It is only secure if you trust the remote host to restrict these ports. +// The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + +// IPv6 address +type In6_addr_t = In6_addr /* in6.h:158:3 */ + +// Socket address for IPv6 +type Sockaddr_in6 = struct { + Fsin6_len X__uint8_t + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo X__uint32_t + Fsin6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fsin6_scope_id X__uint32_t +} /* in6.h:170:1 */ + +// Equality +// NOTE: Some of kernel programming environment (for example, openbsd/sparc) +// does not supply memcmp(). For userland memcmp() is preferred as it is +// in ANSI standard. + +// Unspecified + +// Loopback + +// IPv4 compatible + +// Mapped + +// 6to4 + +// KAME Scope Values + +// Unicast Scope +// Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). + +// Multicast + +// Unique Local IPv6 Unicast Addresses (per RFC 4193) + +// Multicast Scope + +// Options for use with [gs]etsockopt at the IPV6 level. +// First word of comment is data type; bool is stored in int. +// no hdrincl +// RFC 3542 define the following socket options in a manner incompatible +// with RFC 2292: +// IPV6_PKTINFO +// IPV6_HOPLIMIT +// IPV6_NEXTHOP +// IPV6_HOPOPTS +// IPV6_DSTOPTS +// IPV6_RTHDR +// +// To use the new IPv6 Sockets options introduced by RFC 3542 +// the constant __APPLE_USE_RFC_3542 must be defined before +// including +// +// To use the old IPv6 Sockets options from RFC 2292 +// the constant __APPLE_USE_RFC_2292 must be defined before +// including +// +// Note that eventually RFC 3542 is going to be the +// default and RFC 2292 will be obsolete. + +// buf/cmsghdr; set/get IPv6 options [obsoleted by RFC3542] + +// APPLE: NOTE the value of those 2 options is kept unchanged from +// previous version of darwin/OS X for binary compatibility reasons +// and differ from FreeBSD (values 57 and 61). See below. + +// to define items, should talk with KAME guys first, for *BSD compatibility + +// Defaults and limits for options + +// The im6o_membership vector for each socket is now dynamically allocated at +// run-time, bounded by USHRT_MAX, and is reallocated when needed, sized +// according to a power-of-two increment. + +// Default resource limits for IPv6 multicast source filtering. +// These may be modified by sysctl. + +// Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. +type Ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fipv6mr_interface uint32 +} /* in6.h:541:1 */ + +// IPV6_2292PKTINFO: Packet information(RFC2292 sec 5) +type In6_pktinfo = struct { + Fipi6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fipi6_ifindex uint32 +} /* in6.h:549:1 */ + +// Control structure for IPV6_RECVPATHMTU socket option. +type Ip6_mtuinfo = struct { + Fip6m_addr struct { + Fsin6_len X__uint8_t + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo X__uint32_t + Fsin6_addr struct { + F__u6_addr struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]X__uint8_t + } + } + Fsin6_scope_id X__uint32_t + } + Fip6m_mtu Uint32_t +} /* in6.h:557:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/netinet/in/in_linux_amd64.go b/internal/libc/netinet/in/in_linux_amd64.go new file mode 100644 index 0000000..8f3195e --- /dev/null +++ b/internal/libc/netinet/in/in_linux_amd64.go @@ -0,0 +1,2790 @@ +// Code generated by 'ccgo netinet/in/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o netinet/in/in_linux_amd64.go -pkgname in', DO NOT EDIT. + +package in + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_ALG = 38 // socket.h:133:1: + AF_APPLETALK = 5 // socket.h:99:1: + AF_ASH = 18 // socket.h:113:1: + AF_ATMPVC = 8 // socket.h:102:1: + AF_ATMSVC = 20 // socket.h:115:1: + AF_AX25 = 3 // socket.h:97:1: + AF_BLUETOOTH = 31 // socket.h:126:1: + AF_BRIDGE = 7 // socket.h:101:1: + AF_CAIF = 37 // socket.h:132:1: + AF_CAN = 29 // socket.h:124:1: + AF_DECnet = 12 // socket.h:106:1: + AF_ECONET = 19 // socket.h:114:1: + AF_FILE = 1 // socket.h:95:1: + AF_IB = 27 // socket.h:122:1: + AF_IEEE802154 = 36 // socket.h:131:1: + AF_INET = 2 // socket.h:96:1: + AF_INET6 = 10 // socket.h:104:1: + AF_IPX = 4 // socket.h:98:1: + AF_IRDA = 23 // socket.h:118:1: + AF_ISDN = 34 // socket.h:129:1: + AF_IUCV = 32 // socket.h:127:1: + AF_KCM = 41 // socket.h:136:1: + AF_KEY = 15 // socket.h:109:1: + AF_LLC = 26 // socket.h:121:1: + AF_LOCAL = 1 // socket.h:93:1: + AF_MAX = 45 // socket.h:140:1: + AF_MPLS = 28 // socket.h:123:1: + AF_NETBEUI = 13 // socket.h:107:1: + AF_NETLINK = 16 // socket.h:110:1: + AF_NETROM = 6 // socket.h:100:1: + AF_NFC = 39 // socket.h:134:1: + AF_PACKET = 17 // socket.h:112:1: + AF_PHONET = 35 // socket.h:130:1: + AF_PPPOX = 24 // socket.h:119:1: + AF_QIPCRTR = 42 // socket.h:137:1: + AF_RDS = 21 // socket.h:116:1: + AF_ROSE = 11 // socket.h:105:1: + AF_ROUTE = 16 // socket.h:111:1: + AF_RXRPC = 33 // socket.h:128:1: + AF_SECURITY = 14 // socket.h:108:1: + AF_SMC = 43 // socket.h:138:1: + AF_SNA = 22 // socket.h:117:1: + AF_TIPC = 30 // socket.h:125:1: + AF_UNIX = 1 // socket.h:94:1: + AF_UNSPEC = 0 // socket.h:92:1: + AF_VSOCK = 40 // socket.h:135:1: + AF_WANPIPE = 25 // socket.h:120:1: + AF_X25 = 9 // socket.h:103:1: + AF_XDP = 44 // socket.h:139:1: + BIG_ENDIAN = 4321 // endian.h:28:1: + BYTE_ORDER = 1234 // endian.h:30:1: + FD_SETSIZE = 1024 // select.h:73:1: + FIOGETOWN = 0x8903 // sockios.h:8:1: + FIOSETOWN = 0x8901 // sockios.h:6:1: + INET6_ADDRSTRLEN = 46 // in.h:234:1: + INET_ADDRSTRLEN = 16 // in.h:233:1: + IN_CLASSA_HOST = 16777215 // in.h:169:1: + IN_CLASSA_MAX = 128 // in.h:170:1: + IN_CLASSA_NET = 0xff000000 // in.h:167:1: + IN_CLASSA_NSHIFT = 24 // in.h:168:1: + IN_CLASSB_HOST = 65535 // in.h:175:1: + IN_CLASSB_MAX = 65536 // in.h:176:1: + IN_CLASSB_NET = 0xffff0000 // in.h:173:1: + IN_CLASSB_NSHIFT = 16 // in.h:174:1: + IN_CLASSC_HOST = 255 // in.h:181:1: + IN_CLASSC_NET = 0xffffff00 // in.h:179:1: + IN_CLASSC_NSHIFT = 8 // in.h:180:1: + IN_LOOPBACKNET = 127 // in.h:197:1: + IPV6_2292DSTOPTS = 4 // in.h:171:1: + IPV6_2292HOPLIMIT = 8 // in.h:175:1: + IPV6_2292HOPOPTS = 3 // in.h:170:1: + IPV6_2292PKTINFO = 2 // in.h:169:1: + IPV6_2292PKTOPTIONS = 6 // in.h:173:1: + IPV6_2292RTHDR = 5 // in.h:172:1: + IPV6_ADDRFORM = 1 // in.h:168:1: + IPV6_ADDR_PREFERENCES = 72 // in.h:223:1: + IPV6_ADD_MEMBERSHIP = 20 // in.h:237:1: + IPV6_AUTHHDR = 10 // in.h:180:1: + IPV6_AUTOFLOWLABEL = 70 // in.h:220:1: + IPV6_CHECKSUM = 7 // in.h:174:1: + IPV6_DONTFRAG = 62 // in.h:214:1: + IPV6_DROP_MEMBERSHIP = 21 // in.h:238:1: + IPV6_DSTOPTS = 59 // in.h:211:1: + IPV6_FREEBIND = 78 // in.h:233:1: + IPV6_HDRINCL = 36 // in.h:198:1: + IPV6_HOPLIMIT = 52 // in.h:204:1: + IPV6_HOPOPTS = 54 // in.h:206:1: + IPV6_IPSEC_POLICY = 34 // in.h:196:1: + IPV6_JOIN_ANYCAST = 27 // in.h:192:1: + IPV6_JOIN_GROUP = 20 // in.h:185:1: + IPV6_LEAVE_ANYCAST = 28 // in.h:193:1: + IPV6_LEAVE_GROUP = 21 // in.h:186:1: + IPV6_MINHOPCOUNT = 73 // in.h:226:1: + IPV6_MTU = 24 // in.h:189:1: + IPV6_MTU_DISCOVER = 23 // in.h:188:1: + IPV6_MULTICAST_ALL = 29 // in.h:194:1: + IPV6_MULTICAST_HOPS = 18 // in.h:183:1: + IPV6_MULTICAST_IF = 17 // in.h:182:1: + IPV6_MULTICAST_LOOP = 19 // in.h:184:1: + IPV6_NEXTHOP = 9 // in.h:179:1: + IPV6_ORIGDSTADDR = 74 // in.h:228:1: + IPV6_PATHMTU = 61 // in.h:213:1: + IPV6_PKTINFO = 50 // in.h:202:1: + IPV6_PMTUDISC_DO = 2 // in.h:246:1: + IPV6_PMTUDISC_DONT = 0 // in.h:244:1: + IPV6_PMTUDISC_INTERFACE = 4 // in.h:248:1: + IPV6_PMTUDISC_OMIT = 5 // in.h:249:1: + IPV6_PMTUDISC_PROBE = 3 // in.h:247:1: + IPV6_PMTUDISC_WANT = 1 // in.h:245:1: + IPV6_RECVDSTOPTS = 58 // in.h:210:1: + IPV6_RECVERR = 25 // in.h:190:1: + IPV6_RECVFRAGSIZE = 77 // in.h:232:1: + IPV6_RECVHOPLIMIT = 51 // in.h:203:1: + IPV6_RECVHOPOPTS = 53 // in.h:205:1: + IPV6_RECVORIGDSTADDR = 74 // in.h:229:1: + IPV6_RECVPATHMTU = 60 // in.h:212:1: + IPV6_RECVPKTINFO = 49 // in.h:201:1: + IPV6_RECVRTHDR = 56 // in.h:208:1: + IPV6_RECVTCLASS = 66 // in.h:217:1: + IPV6_ROUTER_ALERT = 22 // in.h:187:1: + IPV6_ROUTER_ALERT_ISOLATE = 30 // in.h:195:1: + IPV6_RTHDR = 57 // in.h:209:1: + IPV6_RTHDRDSTOPTS = 55 // in.h:207:1: + IPV6_RTHDR_LOOSE = 0 // in.h:256:1: + IPV6_RTHDR_STRICT = 1 // in.h:257:1: + IPV6_RTHDR_TYPE_0 = 0 // in.h:259:1: + IPV6_RXDSTOPTS = 59 // in.h:241:1: + IPV6_RXHOPOPTS = 54 // in.h:240:1: + IPV6_TCLASS = 67 // in.h:218:1: + IPV6_TRANSPARENT = 75 // in.h:230:1: + IPV6_UNICAST_HOPS = 16 // in.h:181:1: + IPV6_UNICAST_IF = 76 // in.h:231:1: + IPV6_V6ONLY = 26 // in.h:191:1: + IPV6_XFRM_POLICY = 35 // in.h:197:1: + IP_ADD_MEMBERSHIP = 35 // in.h:121:1: + IP_ADD_SOURCE_MEMBERSHIP = 39 // in.h:125:1: + IP_BIND_ADDRESS_NO_PORT = 24 // in.h:103:1: + IP_BLOCK_SOURCE = 38 // in.h:124:1: + IP_CHECKSUM = 23 // in.h:102:1: + IP_DEFAULT_MULTICAST_LOOP = 1 // in.h:135:1: + IP_DEFAULT_MULTICAST_TTL = 1 // in.h:134:1: + IP_DROP_MEMBERSHIP = 36 // in.h:122:1: + IP_DROP_SOURCE_MEMBERSHIP = 40 // in.h:126:1: + IP_FREEBIND = 15 // in.h:89:1: + IP_HDRINCL = 3 // in.h:48:1: + IP_IPSEC_POLICY = 16 // in.h:90:1: + IP_MAX_MEMBERSHIPS = 20 // in.h:136:1: + IP_MINTTL = 21 // in.h:100:1: + IP_MSFILTER = 41 // in.h:127:1: + IP_MTU = 14 // in.h:88:1: + IP_MTU_DISCOVER = 10 // in.h:84:1: + IP_MULTICAST_ALL = 49 // in.h:128:1: + IP_MULTICAST_IF = 32 // in.h:118:1: + IP_MULTICAST_LOOP = 34 // in.h:120:1: + IP_MULTICAST_TTL = 33 // in.h:119:1: + IP_NODEFRAG = 22 // in.h:101:1: + IP_OPTIONS = 4 // in.h:47:1: + IP_ORIGDSTADDR = 20 // in.h:97:1: + IP_PASSSEC = 18 // in.h:92:1: + IP_PKTINFO = 8 // in.h:81:1: + IP_PKTOPTIONS = 9 // in.h:82:1: + IP_PMTUDISC = 10 // in.h:83:1: + IP_PMTUDISC_DO = 2 // in.h:109:1: + IP_PMTUDISC_DONT = 0 // in.h:107:1: + IP_PMTUDISC_INTERFACE = 4 // in.h:114:1: + IP_PMTUDISC_OMIT = 5 // in.h:116:1: + IP_PMTUDISC_PROBE = 3 // in.h:110:1: + IP_PMTUDISC_WANT = 1 // in.h:108:1: + IP_RECVERR = 11 // in.h:85:1: + IP_RECVFRAGSIZE = 25 // in.h:104:1: + IP_RECVOPTS = 6 // in.h:51:1: + IP_RECVORIGDSTADDR = 20 // in.h:98:1: + IP_RECVRETOPTS = 7 // in.h:53:1: + IP_RECVTOS = 13 // in.h:87:1: + IP_RECVTTL = 12 // in.h:86:1: + IP_RETOPTS = 7 // in.h:54:1: + IP_ROUTER_ALERT = 5 // in.h:80:1: + IP_TOS = 1 // in.h:49:1: + IP_TRANSPARENT = 19 // in.h:93:1: + IP_TTL = 2 // in.h:50:1: + IP_UNBLOCK_SOURCE = 37 // in.h:123:1: + IP_UNICAST_IF = 50 // in.h:129:1: + IP_XFRM_POLICY = 17 // in.h:91:1: + LITTLE_ENDIAN = 1234 // endian.h:27:1: + MCAST_BLOCK_SOURCE = 43 // in.h:67:1: + MCAST_EXCLUDE = 0 // in.h:76:1: + MCAST_INCLUDE = 1 // in.h:77:1: + MCAST_JOIN_GROUP = 42 // in.h:66:1: + MCAST_JOIN_SOURCE_GROUP = 46 // in.h:70:1: + MCAST_LEAVE_GROUP = 45 // in.h:69:1: + MCAST_LEAVE_SOURCE_GROUP = 47 // in.h:71:1: + MCAST_MSFILTER = 48 // in.h:72:1: + MCAST_UNBLOCK_SOURCE = 44 // in.h:68:1: + PDP_ENDIAN = 3412 // endian.h:29:1: + PF_ALG = 38 // socket.h:82:1: + PF_APPLETALK = 5 // socket.h:48:1: + PF_ASH = 18 // socket.h:62:1: + PF_ATMPVC = 8 // socket.h:51:1: + PF_ATMSVC = 20 // socket.h:64:1: + PF_AX25 = 3 // socket.h:46:1: + PF_BLUETOOTH = 31 // socket.h:75:1: + PF_BRIDGE = 7 // socket.h:50:1: + PF_CAIF = 37 // socket.h:81:1: + PF_CAN = 29 // socket.h:73:1: + PF_DECnet = 12 // socket.h:55:1: + PF_ECONET = 19 // socket.h:63:1: + PF_FILE = 1 // socket.h:44:1: + PF_IB = 27 // socket.h:71:1: + PF_IEEE802154 = 36 // socket.h:80:1: + PF_INET = 2 // socket.h:45:1: + PF_INET6 = 10 // socket.h:53:1: + PF_IPX = 4 // socket.h:47:1: + PF_IRDA = 23 // socket.h:67:1: + PF_ISDN = 34 // socket.h:78:1: + PF_IUCV = 32 // socket.h:76:1: + PF_KCM = 41 // socket.h:85:1: + PF_KEY = 15 // socket.h:58:1: + PF_LLC = 26 // socket.h:70:1: + PF_LOCAL = 1 // socket.h:42:1: + PF_MAX = 45 // socket.h:89:1: + PF_MPLS = 28 // socket.h:72:1: + PF_NETBEUI = 13 // socket.h:56:1: + PF_NETLINK = 16 // socket.h:59:1: + PF_NETROM = 6 // socket.h:49:1: + PF_NFC = 39 // socket.h:83:1: + PF_PACKET = 17 // socket.h:61:1: + PF_PHONET = 35 // socket.h:79:1: + PF_PPPOX = 24 // socket.h:68:1: + PF_QIPCRTR = 42 // socket.h:86:1: + PF_RDS = 21 // socket.h:65:1: + PF_ROSE = 11 // socket.h:54:1: + PF_ROUTE = 16 // socket.h:60:1: + PF_RXRPC = 33 // socket.h:77:1: + PF_SECURITY = 14 // socket.h:57:1: + PF_SMC = 43 // socket.h:87:1: + PF_SNA = 22 // socket.h:66:1: + PF_TIPC = 30 // socket.h:74:1: + PF_UNIX = 1 // socket.h:43:1: + PF_UNSPEC = 0 // socket.h:41:1: + PF_VSOCK = 40 // socket.h:84:1: + PF_WANPIPE = 25 // socket.h:69:1: + PF_X25 = 9 // socket.h:52:1: + PF_XDP = 44 // socket.h:88:1: + SCM_TIMESTAMP = 29 // socket.h:140:1: + SCM_TIMESTAMPING = 37 // socket.h:142:1: + SCM_TIMESTAMPING_OPT_STATS = 54 // socket.h:90:1: + SCM_TIMESTAMPING_PKTINFO = 58 // socket.h:98:1: + SCM_TIMESTAMPNS = 35 // socket.h:141:1: + SCM_TXTIME = 61 // socket.h:105:1: + SCM_WIFI_STATUS = 41 // socket.h:64:1: + SIOCATMARK = 0x8905 // sockios.h:10:1: + SIOCGPGRP = 0x8904 // sockios.h:9:1: + SIOCGSTAMP = 0x8906 // sockios.h:11:1: + SIOCGSTAMPNS = 0x8907 // sockios.h:12:1: + SIOCSPGRP = 0x8902 // sockios.h:7:1: + SOL_AAL = 265 // socket.h:151:1: + SOL_ALG = 279 // socket.h:165:1: + SOL_ATM = 264 // socket.h:150:1: + SOL_BLUETOOTH = 274 // socket.h:160:1: + SOL_CAIF = 278 // socket.h:164:1: + SOL_DCCP = 269 // socket.h:155:1: + SOL_DECNET = 261 // socket.h:147:1: + SOL_ICMPV6 = 58 // in.h:253:1: + SOL_IP = 0 // in.h:132:1: + SOL_IPV6 = 41 // in.h:252:1: + SOL_IRDA = 266 // socket.h:152:1: + SOL_IUCV = 277 // socket.h:163:1: + SOL_KCM = 281 // socket.h:167:1: + SOL_LLC = 268 // socket.h:154:1: + SOL_NETBEUI = 267 // socket.h:153:1: + SOL_NETLINK = 270 // socket.h:156:1: + SOL_NFC = 280 // socket.h:166:1: + SOL_PACKET = 263 // socket.h:149:1: + SOL_PNPIPE = 275 // socket.h:161:1: + SOL_PPPOL2TP = 273 // socket.h:159:1: + SOL_RAW = 255 // socket.h:146:1: + SOL_RDS = 276 // socket.h:162:1: + SOL_RXRPC = 272 // socket.h:158:1: + SOL_SOCKET = 1 // socket.h:9:1: + SOL_TIPC = 271 // socket.h:157:1: + SOL_TLS = 282 // socket.h:168:1: + SOL_X25 = 262 // socket.h:148:1: + SOL_XDP = 283 // socket.h:169:1: + SOMAXCONN = 4096 // socket.h:172:1: + SO_ACCEPTCONN = 30 // socket.h:51:1: + SO_ATTACH_BPF = 50 // socket.h:82:1: + SO_ATTACH_FILTER = 26 // socket.h:45:1: + SO_ATTACH_REUSEPORT_CBPF = 51 // socket.h:85:1: + SO_ATTACH_REUSEPORT_EBPF = 52 // socket.h:86:1: + SO_BINDTODEVICE = 25 // socket.h:42:1: + SO_BINDTOIFINDEX = 62 // socket.h:107:1: + SO_BPF_EXTENSIONS = 48 // socket.h:78:1: + SO_BROADCAST = 6 // socket.h:16:1: + SO_BSDCOMPAT = 14 // socket.h:26:1: + SO_BUSY_POLL = 46 // socket.h:74:1: + SO_CNX_ADVICE = 53 // socket.h:88:1: + SO_COOKIE = 57 // socket.h:96:1: + SO_DEBUG = 1 // socket.h:11:1: + SO_DETACH_BPF = 27 // socket.h:83:1: + SO_DETACH_FILTER = 27 // socket.h:46:1: + SO_DETACH_REUSEPORT_BPF = 68 // socket.h:120:1: + SO_DOMAIN = 39 // socket.h:59:1: + SO_DONTROUTE = 5 // socket.h:15:1: + SO_ERROR = 4 // socket.h:14:1: + SO_GET_FILTER = 26 // socket.h:47:1: + SO_INCOMING_CPU = 49 // socket.h:80:1: + SO_INCOMING_NAPI_ID = 56 // socket.h:94:1: + SO_KEEPALIVE = 9 // socket.h:21:1: + SO_LINGER = 13 // socket.h:25:1: + SO_LOCK_FILTER = 44 // socket.h:70:1: + SO_MARK = 36 // socket.h:56:1: + SO_MAX_PACING_RATE = 47 // socket.h:76:1: + SO_MEMINFO = 55 // socket.h:92:1: + SO_NOFCS = 43 // socket.h:68:1: + SO_NO_CHECK = 11 // socket.h:23:1: + SO_OOBINLINE = 10 // socket.h:22:1: + SO_PASSCRED = 16 // socket.h:29:1: + SO_PASSSEC = 34 // socket.h:54:1: + SO_PEEK_OFF = 42 // socket.h:65:1: + SO_PEERCRED = 17 // socket.h:30:1: + SO_PEERGROUPS = 59 // socket.h:100:1: + SO_PEERNAME = 28 // socket.h:49:1: + SO_PEERSEC = 31 // socket.h:53:1: + SO_PRIORITY = 12 // socket.h:24:1: + SO_PROTOCOL = 38 // socket.h:58:1: + SO_RCVBUF = 8 // socket.h:18:1: + SO_RCVBUFFORCE = 33 // socket.h:20:1: + SO_RCVLOWAT = 18 // socket.h:31:1: + SO_RCVTIMEO = 20 // socket.h:129:1: + SO_RCVTIMEO_NEW = 66 // socket.h:117:1: + SO_RCVTIMEO_OLD = 20 // socket.h:33:1: + SO_REUSEADDR = 2 // socket.h:12:1: + SO_REUSEPORT = 15 // socket.h:27:1: + SO_RXQ_OVFL = 40 // socket.h:61:1: + SO_SECURITY_AUTHENTICATION = 22 // socket.h:38:1: + SO_SECURITY_ENCRYPTION_NETWORK = 24 // socket.h:40:1: + SO_SECURITY_ENCRYPTION_TRANSPORT = 23 // socket.h:39:1: + SO_SELECT_ERR_QUEUE = 45 // socket.h:72:1: + SO_SNDBUF = 7 // socket.h:17:1: + SO_SNDBUFFORCE = 32 // socket.h:19:1: + SO_SNDLOWAT = 19 // socket.h:32:1: + SO_SNDTIMEO = 21 // socket.h:130:1: + SO_SNDTIMEO_NEW = 67 // socket.h:118:1: + SO_SNDTIMEO_OLD = 21 // socket.h:34:1: + SO_TIMESTAMP = 29 // socket.h:125:1: + SO_TIMESTAMPING = 37 // socket.h:127:1: + SO_TIMESTAMPING_NEW = 65 // socket.h:115:1: + SO_TIMESTAMPING_OLD = 37 // socket.h:111:1: + SO_TIMESTAMPNS = 35 // socket.h:126:1: + SO_TIMESTAMPNS_NEW = 64 // socket.h:114:1: + SO_TIMESTAMPNS_OLD = 35 // socket.h:110:1: + SO_TIMESTAMP_NEW = 63 // socket.h:113:1: + SO_TIMESTAMP_OLD = 29 // socket.h:109:1: + SO_TXTIME = 61 // socket.h:104:1: + SO_TYPE = 3 // socket.h:13:1: + SO_WIFI_STATUS = 41 // socket.h:63:1: + SO_ZEROCOPY = 60 // socket.h:102:1: + X_ASM_X86_POSIX_TYPES_64_H = 0 // posix_types_64.h:3:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_SOCKADDR_H = 1 // sockaddr.h:24:1: + X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: + X_BITS_STDINT_UINTN_H = 1 // stdint-uintn.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_ENDIAN_H = 1 // endian.h:19:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LINUX_POSIX_TYPES_H = 0 // posix_types.h:3:1: + X_LP64 = 1 // :284:1: + X_NETINET_IN_H = 1 // in.h:19:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_SS_SIZE = 128 // sockaddr.h:40:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SELECT_H = 1 // select.h:22:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_SYS_SOCKET_H = 1 // socket.h:20:1: + X_SYS_TYPES_H = 1 // types.h:23:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// Standard well-known ports. +const ( /* in.h:122:1: */ + IPPORT_ECHO = 7 // Echo service. + IPPORT_DISCARD = 9 // Discard transmissions service. + IPPORT_SYSTAT = 11 // System status service. + IPPORT_DAYTIME = 13 // Time of day service. + IPPORT_NETSTAT = 15 // Network status service. + IPPORT_FTP = 21 // File Transfer Protocol. + IPPORT_TELNET = 23 // Telnet protocol. + IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. + IPPORT_TIMESERVER = 37 // Timeserver service. + IPPORT_NAMESERVER = 42 // Domain Name Service. + IPPORT_WHOIS = 43 // Internet Whois service. + IPPORT_MTP = 57 + + IPPORT_TFTP = 69 // Trivial File Transfer Protocol. + IPPORT_RJE = 77 + IPPORT_FINGER = 79 // Finger service. + IPPORT_TTYLINK = 87 + IPPORT_SUPDUP = 95 // SUPDUP protocol. + + IPPORT_EXECSERVER = 512 // execd service. + IPPORT_LOGINSERVER = 513 // rlogind service. + IPPORT_CMDSERVER = 514 + IPPORT_EFSSERVER = 520 + + // UDP ports. + IPPORT_BIFFUDP = 512 + IPPORT_WHOSERVER = 513 + IPPORT_ROUTESERVER = 520 + + // Ports less than this value are reserved for privileged processes. + IPPORT_RESERVED = 1024 + + // Ports greater this value are reserved for (non-privileged) servers. + IPPORT_USERRESERVED = 5000 +) + +// Options for use with `getsockopt' and `setsockopt' at the IPv6 level. +// The first word in the comment at the right is the data type used; +// "bool" means a boolean value stored in an `int'. + +// Advanced API (RFC3542) (1). + +// Advanced API (RFC3542) (2). + +// RFC5014. + +// RFC5082. + +// Obsolete synonyms for the above. + +// IPV6_MTU_DISCOVER values. + +// Socket level values for IPv6. + +// Routing header options for IPv6. + +// Standard well-defined IP protocols. +const ( /* in.h:40:1: */ + IPPROTO_IP = 0 // Dummy protocol for TCP. + IPPROTO_ICMP = 1 // Internet Control Message Protocol. + IPPROTO_IGMP = 2 // Internet Group Management Protocol. + IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). + IPPROTO_TCP = 6 // Transmission Control Protocol. + IPPROTO_EGP = 8 // Exterior Gateway Protocol. + IPPROTO_PUP = 12 // PUP protocol. + IPPROTO_UDP = 17 // User Datagram Protocol. + IPPROTO_IDP = 22 // XNS IDP protocol. + IPPROTO_TP = 29 // SO Transport Protocol Class 4. + IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. + IPPROTO_IPV6 = 41 // IPv6 header. + IPPROTO_RSVP = 46 // Reservation Protocol. + IPPROTO_GRE = 47 // General Routing Encapsulation. + IPPROTO_ESP = 50 // encapsulating security payload. + IPPROTO_AH = 51 // authentication header. + IPPROTO_MTP = 92 // Multicast Transport Protocol. + IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. + IPPROTO_ENCAP = 98 // Encapsulation Header. + IPPROTO_PIM = 103 // Protocol Independent Multicast. + IPPROTO_COMP = 108 // Compression Header Protocol. + IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. + IPPROTO_UDPLITE = 136 // UDP-Lite protocol. + IPPROTO_MPLS = 137 // MPLS in IP. + IPPROTO_RAW = 255 // Raw IP packets. + IPPROTO_MAX = 256 +) + +// If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel +// +// network headers first and we should use those ABI-identical definitions +// instead of our own, otherwise 0. +const ( /* in.h:99:1: */ + IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. + IPPROTO_ROUTING = 43 // IPv6 routing header. + IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. + IPPROTO_ICMPV6 = 58 // ICMPv6. + IPPROTO_NONE = 59 // IPv6 no next header. + IPPROTO_DSTOPTS = 60 // IPv6 destination options. + IPPROTO_MH = 135 +) + +// Bits in the FLAGS argument to `send', `recv', et al. +const ( /* socket.h:200:1: */ + MSG_OOB = 1 // Process out-of-band data. + MSG_PEEK = 2 // Peek at incoming messages. + MSG_DONTROUTE = 4 // Don't use local routing. + MSG_CTRUNC = 8 // Control data lost before delivery. + MSG_PROXY = 16 // Supply or ask second address. + MSG_TRUNC = 32 + MSG_DONTWAIT = 64 // Nonblocking IO. + MSG_EOR = 128 // End of record. + MSG_WAITALL = 256 // Wait for a full request. + MSG_FIN = 512 + MSG_SYN = 1024 + MSG_CONFIRM = 2048 // Confirm path validity. + MSG_RST = 4096 + MSG_ERRQUEUE = 8192 // Fetch message from error queue. + MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. + MSG_MORE = 32768 // Sender will send more. + MSG_WAITFORONE = 65536 // Wait for at least one packet to return. + MSG_BATCH = 262144 // sendmmsg: more messages coming. + MSG_ZEROCOPY = 67108864 // Use user data in kernel path. + MSG_FASTOPEN = 536870912 // Send data in TCP SYN. + + MSG_CMSG_CLOEXEC = 1073741824 +) + +// Socket level message types. This must match the definitions in +// +// . +const ( /* socket.h:332:1: */ + SCM_RIGHTS = 1 +) + +// Get the architecture-dependent definition of enum __socket_type. +// Define enum __socket_type for generic Linux. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Types of sockets. +const ( /* socket_type.h:24:1: */ + SOCK_STREAM = 1 // Sequenced, reliable, connection-based + // byte streams. + SOCK_DGRAM = 2 // Connectionless, unreliable datagrams + // of fixed maximum length. + SOCK_RAW = 3 // Raw protocol interface. + SOCK_RDM = 4 // Reliably-delivered messages. + SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, + // datagrams of fixed maximum length. + SOCK_DCCP = 6 // Datagram Congestion Control Protocol. + SOCK_PACKET = 10 // Linux specific way of getting packets + // at the dev level. For writing rarp and + // other similar things on the user level. + + // Flags to be ORed into the type parameter of socket and socketpair and + // used for the flags parameter of paccept. + + SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the + // new descriptor(s). + SOCK_NONBLOCK = 2048 +) + +// The following constants should be used for the second parameter of +// +// `shutdown'. +const ( /* socket.h:41:1: */ + SHUT_RD = 0 // No more receptions. + SHUT_WR = 1 // No more transmissions. + SHUT_RDWR = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// Define uintN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type Uint8_t = X__uint8_t /* stdint-uintn.h:24:19 */ +type Uint16_t = X__uint16_t /* stdint-uintn.h:25:20 */ +type Uint32_t = X__uint32_t /* stdint-uintn.h:26:20 */ +type Uint64_t = X__uint64_t /* stdint-uintn.h:27:20 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Structure for scatter/gather I/O. +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* struct_iovec.h:26:1 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This operating system-specific header file defines the SOCK_*, PF_*, +// AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', +// `struct msghdr', and `struct linger' types. +// System-specific socket constants and types. Linux version. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +// Type for length arguments in socket calls. +type Socklen_t = X__socklen_t /* socket.h:33:21 */ + +// Protocol families. + +// Address families. + +// Socket level values. Others are defined in the appropriate headers. +// +// XXX These definitions also should go into the appropriate headers as +// far as they are available. + +// Maximum queue length specifiable by listen. + +// Get the definition of the macro to define the common sockaddr members. +// Definition of struct sockaddr_* common members and sizes, generic version. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// POSIX.1g specifies this type name for the `sa_family' member. +type Sa_family_t = uint16 /* sockaddr.h:28:28 */ + +// This macro is used to declare the initial common members +// of the data types used for socket addresses, `struct sockaddr', +// `struct sockaddr_in', `struct sockaddr_un', etc. + +// Size of struct sockaddr_storage. + +// Structure describing a generic socket address. +type Sockaddr = struct { + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:178:1 */ + +// Structure large enough to hold any socket address (with the historical +// exception of AF_UNIX). + +type Sockaddr_storage = struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 +} /* socket.h:191:1 */ + +// Structure describing messages sent by +// +// `sendmsg' and received by `recvmsg'. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen Size_t + Fmsg_control uintptr + Fmsg_controllen Size_t + Fmsg_flags int32 + F__ccgo_pad2 [4]byte +} /* socket.h:257:1 */ + +// Structure used for storage of ancillary data object information. +type Cmsghdr = struct { + F__ccgo_pad1 [0]uint64 + Fcmsg_len Size_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:275:1 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This allows for 1024 file descriptors: if NR_OPEN is ever grown +// beyond that you'll have to change this too. But 1024 fd's seem to be +// enough even for such "real" unices like OSF/1, so hopefully this is +// one limit that doesn't have to be changed [again]. +// +// Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in +// (and thus ) - but this is a more logical +// place for them. Solved by having dummy defines in . + +// This macro may have been defined in . But we always +// use the one here. + +type X__kernel_fd_set = struct{ Ffds_bits [16]uint64 } /* posix_types.h:27:3 */ + +// Type of a signal handler. +type X__kernel_sighandler_t = uintptr /* posix_types.h:30:14 */ + +// Type of a SYSV IPC key. +type X__kernel_key_t = int32 /* posix_types.h:33:13 */ +type X__kernel_mqd_t = int32 /* posix_types.h:34:13 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. Also, we cannot +// assume GCC is being used. + +type X__kernel_old_uid_t = uint16 /* posix_types_64.h:11:24 */ +type X__kernel_old_gid_t = uint16 /* posix_types_64.h:12:24 */ + +type X__kernel_old_dev_t = uint64 /* posix_types_64.h:15:23 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// There seems to be no way of detecting this automatically from user +// space, so 64 bit architectures should override this in their +// bitsperlong.h. In particular, an architecture that supports +// both 32 and 64 bit user space must not rely on CONFIG_64BIT +// to decide it, but rather check a compiler provided macro. + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. +// +// First the types that are often defined in different ways across +// architectures, so that you can override them. + +type X__kernel_long_t = int64 /* posix_types.h:15:15 */ +type X__kernel_ulong_t = uint64 /* posix_types.h:16:23 */ + +type X__kernel_ino_t = X__kernel_ulong_t /* posix_types.h:20:26 */ + +type X__kernel_mode_t = uint32 /* posix_types.h:24:22 */ + +type X__kernel_pid_t = int32 /* posix_types.h:28:14 */ + +type X__kernel_ipc_pid_t = int32 /* posix_types.h:32:14 */ + +type X__kernel_uid_t = uint32 /* posix_types.h:36:22 */ +type X__kernel_gid_t = uint32 /* posix_types.h:37:22 */ + +type X__kernel_suseconds_t = X__kernel_long_t /* posix_types.h:41:26 */ + +type X__kernel_daddr_t = int32 /* posix_types.h:45:14 */ + +type X__kernel_uid32_t = uint32 /* posix_types.h:49:22 */ +type X__kernel_gid32_t = uint32 /* posix_types.h:50:22 */ + +// Most 32 bit architectures use "unsigned int" size_t, +// and all 64 bit architectures use "unsigned long" size_t. +type X__kernel_size_t = X__kernel_ulong_t /* posix_types.h:72:26 */ +type X__kernel_ssize_t = X__kernel_long_t /* posix_types.h:73:25 */ +type X__kernel_ptrdiff_t = X__kernel_long_t /* posix_types.h:74:25 */ + +type X__kernel_fsid_t = struct{ Fval [2]int32 } /* posix_types.h:81:3 */ + +// anything below here should be completely generic +type X__kernel_off_t = X__kernel_long_t /* posix_types.h:87:25 */ +type X__kernel_loff_t = int64 /* posix_types.h:88:19 */ +type X__kernel_old_time_t = X__kernel_long_t /* posix_types.h:89:25 */ +type X__kernel_time_t = X__kernel_long_t /* posix_types.h:90:25 */ +type X__kernel_time64_t = int64 /* posix_types.h:91:19 */ +type X__kernel_clock_t = X__kernel_long_t /* posix_types.h:92:25 */ +type X__kernel_timer_t = int32 /* posix_types.h:93:14 */ +type X__kernel_clockid_t = int32 /* posix_types.h:94:14 */ +type X__kernel_caddr_t = uintptr /* posix_types.h:95:14 */ +type X__kernel_uid16_t = uint16 /* posix_types.h:96:24 */ +type X__kernel_gid16_t = uint16 /* posix_types.h:97:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// Socket-level I/O control calls. + +// For setsockopt(2) + +// Security levels - as per NRL IPv6 - don't actually do anything + +// Socket filtering + +// Instruct lower device to use last 4-bytes of skb data as FCS + +// on 64-bit and x32, avoid the ?: operator + +// Structure used to manipulate the SO_LINGER option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:361:1 */ + +// This is the 4.3 BSD `struct sockaddr' format, which is used as wire +// +// format in the grotty old 4.3 `talk' protocol. +type Osockaddr = struct { + Fsa_family uint16 + Fsa_data [14]uint8 +} /* struct_osockaddr.h:6:1 */ + +// Define some macros helping to catch buffer overflows. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Internet address. +type In_addr_t = Uint32_t /* in.h:30:18 */ +type In_addr = struct{ Fs_addr In_addr_t } /* in.h:31:1 */ + +// Get system-specific definitions. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Linux version. + +// If the application has already included linux/in6.h from a linux-based +// kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the +// defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo +// in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly. +// Neither the linux kernel nor glibc should break this ABI without coordination. +// In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check +// for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for +// maximum backwards compatibility. + +// Options for use with `getsockopt' and `setsockopt' at the IP level. +// The first word in the comment at the right is the data type used; +// "bool" means a boolean value stored in an `int'. +// For BSD compatibility. + +// TProxy original addresses + +// IP_MTU_DISCOVER arguments. +// Always use interface mtu (ignores dst pmtu) but don't set DF flag. +// Also incoming ICMP frag_needed notifications will be ignored on +// this socket to prevent accepting spoofed ones. +// Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented. + +// To select the IP level. + +// Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. +// +// The `ip_dst' field is used for the first-hop gateway when using a +// source route (this gets put into the header proper). +type Ip_opts = struct { + Fip_dst struct{ Fs_addr In_addr_t } + Fip_opts [40]int8 +} /* in.h:142:1 */ + +// Like `struct ip_mreq' but including interface specification by index. +type Ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_address struct{ Fs_addr In_addr_t } + Fimr_ifindex int32 +} /* in.h:149:1 */ + +// Structure used for IP_PKTINFO. +type In_pktinfo = struct { + Fipi_ifindex int32 + Fipi_spec_dst struct{ Fs_addr In_addr_t } + Fipi_addr struct{ Fs_addr In_addr_t } +} /* in.h:157:1 */ + +// Type to represent a port. +type In_port_t = Uint16_t /* in.h:119:18 */ + +// 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. + +// Address to accept any incoming messages. +// Address to send to all hosts. +// Address indicating an error return. + +// Network number for local host loopback. +// Address to loopback in software to local host. + +// Defines for Multicast INADDR. + +// IPv6 address +type In6_addr = struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } +} /* in.h:212:1 */ + +// ::1 + +// Structure describing an Internet socket address. +type Sockaddr_in = struct { + Fsin_family Sa_family_t + Fsin_port In_port_t + Fsin_addr struct{ Fs_addr In_addr_t } + Fsin_zero [8]uint8 +} /* in.h:238:1 */ + +// Ditto, for IPv6. +type Sockaddr_in6 = struct { + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo Uint32_t + Fsin6_addr struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } + } + Fsin6_scope_id Uint32_t +} /* in.h:253:1 */ + +// IPv4 multicast request. +type Ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:265:1 */ + +type Ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } + Fimr_sourceaddr struct{ Fs_addr In_addr_t } +} /* in.h:274:1 */ + +// Likewise, for IPv6. +type Ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } + } + Fipv6mr_interface uint32 +} /* in.h:289:1 */ + +// Multicast group request. +type Group_req = struct { + Fgr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:301:1 */ + +type Group_source_req = struct { + Fgsr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } + Fgsr_source struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:310:1 */ + +// Full-state filter operations. +type Ip_msfilter = struct { + Fimsf_multiaddr struct{ Fs_addr In_addr_t } + Fimsf_interface struct{ Fs_addr In_addr_t } + Fimsf_fmode Uint32_t + Fimsf_numsrc Uint32_t + Fimsf_slist [1]struct{ Fs_addr In_addr_t } +} /* in.h:324:1 */ + +type Group_filter = struct { + Fgf_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgf_group struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } + Fgf_fmode Uint32_t + Fgf_numsrc Uint32_t + Fgf_slist [1]struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 + } +} /* in.h:345:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/netinet/in/in_linux_arm64.go b/internal/libc/netinet/in/in_linux_arm64.go new file mode 100644 index 0000000..1ab2504 --- /dev/null +++ b/internal/libc/netinet/in/in_linux_arm64.go @@ -0,0 +1,2900 @@ +// Code generated by 'ccgo netinet/in/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o netinet/in/in_linux_arm64.go -pkgname in', DO NOT EDIT. + +package in + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_ALG = 38 + AF_APPLETALK = 5 + AF_ASH = 18 + AF_ATMPVC = 8 + AF_ATMSVC = 20 + AF_AX25 = 3 + AF_BLUETOOTH = 31 + AF_BRIDGE = 7 + AF_CAIF = 37 + AF_CAN = 29 + AF_DECnet = 12 + AF_ECONET = 19 + AF_FILE = 1 + AF_IB = 27 + AF_IEEE802154 = 36 + AF_INET = 2 + AF_INET6 = 10 + AF_IPX = 4 + AF_IRDA = 23 + AF_ISDN = 34 + AF_IUCV = 32 + AF_KCM = 41 + AF_KEY = 15 + AF_LLC = 26 + AF_LOCAL = 1 + AF_MAX = 45 + AF_MPLS = 28 + AF_NETBEUI = 13 + AF_NETLINK = 16 + AF_NETROM = 6 + AF_NFC = 39 + AF_PACKET = 17 + AF_PHONET = 35 + AF_PPPOX = 24 + AF_QIPCRTR = 42 + AF_RDS = 21 + AF_ROSE = 11 + AF_ROUTE = 16 + AF_RXRPC = 33 + AF_SECURITY = 14 + AF_SMC = 43 + AF_SNA = 22 + AF_TIPC = 30 + AF_UNIX = 1 + AF_UNSPEC = 0 + AF_VSOCK = 40 + AF_WANPIPE = 25 + AF_X25 = 9 + AF_XDP = 44 + BIG_ENDIAN = 4321 + BYTE_ORDER = 1234 + FD_SETSIZE = 1024 + FIOGETOWN = 0x8903 + FIOSETOWN = 0x8901 + INET6_ADDRSTRLEN = 46 + INET_ADDRSTRLEN = 16 + IN_CLASSA_HOST = 16777215 + IN_CLASSA_MAX = 128 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 24 + IN_CLASSB_HOST = 65535 + IN_CLASSB_MAX = 65536 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 16 + IN_CLASSC_HOST = 255 + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 8 + IN_LOOPBACKNET = 127 + IPV6_2292DSTOPTS = 4 + IPV6_2292HOPLIMIT = 8 + IPV6_2292HOPOPTS = 3 + IPV6_2292PKTINFO = 2 + IPV6_2292PKTOPTIONS = 6 + IPV6_2292RTHDR = 5 + IPV6_ADDRFORM = 1 + IPV6_ADDR_PREFERENCES = 72 + IPV6_ADD_MEMBERSHIP = 20 + IPV6_AUTHHDR = 10 + IPV6_AUTOFLOWLABEL = 70 + IPV6_CHECKSUM = 7 + IPV6_DONTFRAG = 62 + IPV6_DROP_MEMBERSHIP = 21 + IPV6_DSTOPTS = 59 + IPV6_FREEBIND = 78 + IPV6_HDRINCL = 36 + IPV6_HOPLIMIT = 52 + IPV6_HOPOPTS = 54 + IPV6_IPSEC_POLICY = 34 + IPV6_JOIN_ANYCAST = 27 + IPV6_JOIN_GROUP = 20 + IPV6_LEAVE_ANYCAST = 28 + IPV6_LEAVE_GROUP = 21 + IPV6_MINHOPCOUNT = 73 + IPV6_MTU = 24 + IPV6_MTU_DISCOVER = 23 + IPV6_MULTICAST_ALL = 29 + IPV6_MULTICAST_HOPS = 18 + IPV6_MULTICAST_IF = 17 + IPV6_MULTICAST_LOOP = 19 + IPV6_NEXTHOP = 9 + IPV6_ORIGDSTADDR = 74 + IPV6_PATHMTU = 61 + IPV6_PKTINFO = 50 + IPV6_PMTUDISC_DO = 2 + IPV6_PMTUDISC_DONT = 0 + IPV6_PMTUDISC_INTERFACE = 4 + IPV6_PMTUDISC_OMIT = 5 + IPV6_PMTUDISC_PROBE = 3 + IPV6_PMTUDISC_WANT = 1 + IPV6_RECVDSTOPTS = 58 + IPV6_RECVERR = 25 + IPV6_RECVFRAGSIZE = 77 + IPV6_RECVHOPLIMIT = 51 + IPV6_RECVHOPOPTS = 53 + IPV6_RECVORIGDSTADDR = 74 + IPV6_RECVPATHMTU = 60 + IPV6_RECVPKTINFO = 49 + IPV6_RECVRTHDR = 56 + IPV6_RECVTCLASS = 66 + IPV6_ROUTER_ALERT = 22 + IPV6_ROUTER_ALERT_ISOLATE = 30 + IPV6_RTHDR = 57 + IPV6_RTHDRDSTOPTS = 55 + IPV6_RTHDR_LOOSE = 0 + IPV6_RTHDR_STRICT = 1 + IPV6_RTHDR_TYPE_0 = 0 + IPV6_RXDSTOPTS = 59 + IPV6_RXHOPOPTS = 54 + IPV6_TCLASS = 67 + IPV6_TRANSPARENT = 75 + IPV6_UNICAST_HOPS = 16 + IPV6_UNICAST_IF = 76 + IPV6_V6ONLY = 26 + IPV6_XFRM_POLICY = 35 + IP_ADD_MEMBERSHIP = 35 + IP_ADD_SOURCE_MEMBERSHIP = 39 + IP_BIND_ADDRESS_NO_PORT = 24 + IP_BLOCK_SOURCE = 38 + IP_CHECKSUM = 23 + IP_DEFAULT_MULTICAST_LOOP = 1 + IP_DEFAULT_MULTICAST_TTL = 1 + IP_DROP_MEMBERSHIP = 36 + IP_DROP_SOURCE_MEMBERSHIP = 40 + IP_FREEBIND = 15 + IP_HDRINCL = 3 + IP_IPSEC_POLICY = 16 + IP_MAX_MEMBERSHIPS = 20 + IP_MINTTL = 21 + IP_MSFILTER = 41 + IP_MTU = 14 + IP_MTU_DISCOVER = 10 + IP_MULTICAST_ALL = 49 + IP_MULTICAST_IF = 32 + IP_MULTICAST_LOOP = 34 + IP_MULTICAST_TTL = 33 + IP_NODEFRAG = 22 + IP_OPTIONS = 4 + IP_ORIGDSTADDR = 20 + IP_PASSSEC = 18 + IP_PKTINFO = 8 + IP_PKTOPTIONS = 9 + IP_PMTUDISC = 10 + IP_PMTUDISC_DO = 2 + IP_PMTUDISC_DONT = 0 + IP_PMTUDISC_INTERFACE = 4 + IP_PMTUDISC_OMIT = 5 + IP_PMTUDISC_PROBE = 3 + IP_PMTUDISC_WANT = 1 + IP_RECVERR = 11 + IP_RECVFRAGSIZE = 25 + IP_RECVOPTS = 6 + IP_RECVORIGDSTADDR = 20 + IP_RECVRETOPTS = 7 + IP_RECVTOS = 13 + IP_RECVTTL = 12 + IP_RETOPTS = 7 + IP_ROUTER_ALERT = 5 + IP_TOS = 1 + IP_TRANSPARENT = 19 + IP_TTL = 2 + IP_UNBLOCK_SOURCE = 37 + IP_UNICAST_IF = 50 + IP_XFRM_POLICY = 17 + LITTLE_ENDIAN = 1234 + MCAST_BLOCK_SOURCE = 43 + MCAST_EXCLUDE = 0 + MCAST_INCLUDE = 1 + MCAST_JOIN_GROUP = 42 + MCAST_JOIN_SOURCE_GROUP = 46 + MCAST_LEAVE_GROUP = 45 + MCAST_LEAVE_SOURCE_GROUP = 47 + MCAST_MSFILTER = 48 + MCAST_UNBLOCK_SOURCE = 44 + PDP_ENDIAN = 3412 + PF_ALG = 38 + PF_APPLETALK = 5 + PF_ASH = 18 + PF_ATMPVC = 8 + PF_ATMSVC = 20 + PF_AX25 = 3 + PF_BLUETOOTH = 31 + PF_BRIDGE = 7 + PF_CAIF = 37 + PF_CAN = 29 + PF_DECnet = 12 + PF_ECONET = 19 + PF_FILE = 1 + PF_IB = 27 + PF_IEEE802154 = 36 + PF_INET = 2 + PF_INET6 = 10 + PF_IPX = 4 + PF_IRDA = 23 + PF_ISDN = 34 + PF_IUCV = 32 + PF_KCM = 41 + PF_KEY = 15 + PF_LLC = 26 + PF_LOCAL = 1 + PF_MAX = 45 + PF_MPLS = 28 + PF_NETBEUI = 13 + PF_NETLINK = 16 + PF_NETROM = 6 + PF_NFC = 39 + PF_PACKET = 17 + PF_PHONET = 35 + PF_PPPOX = 24 + PF_QIPCRTR = 42 + PF_RDS = 21 + PF_ROSE = 11 + PF_ROUTE = 16 + PF_RXRPC = 33 + PF_SECURITY = 14 + PF_SMC = 43 + PF_SNA = 22 + PF_TIPC = 30 + PF_UNIX = 1 + PF_UNSPEC = 0 + PF_VSOCK = 40 + PF_WANPIPE = 25 + PF_X25 = 9 + PF_XDP = 44 + SCM_TIMESTAMP = 29 + SCM_TIMESTAMPING = 37 + SCM_TIMESTAMPING_OPT_STATS = 54 + SCM_TIMESTAMPING_PKTINFO = 58 + SCM_TIMESTAMPNS = 35 + SCM_TXTIME = 61 + SCM_WIFI_STATUS = 41 + SIOCATMARK = 0x8905 + SIOCGPGRP = 0x8904 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCSPGRP = 0x8902 + SOL_AAL = 265 + SOL_ALG = 279 + SOL_ATM = 264 + SOL_BLUETOOTH = 274 + SOL_CAIF = 278 + SOL_DCCP = 269 + SOL_DECNET = 261 + SOL_ICMPV6 = 58 + SOL_IP = 0 + SOL_IPV6 = 41 + SOL_IRDA = 266 + SOL_IUCV = 277 + SOL_KCM = 281 + SOL_LLC = 268 + SOL_NETBEUI = 267 + SOL_NETLINK = 270 + SOL_NFC = 280 + SOL_PACKET = 263 + SOL_PNPIPE = 275 + SOL_PPPOL2TP = 273 + SOL_RAW = 255 + SOL_RDS = 276 + SOL_RXRPC = 272 + SOL_SOCKET = 1 + SOL_TIPC = 271 + SOL_TLS = 282 + SOL_X25 = 262 + SOL_XDP = 283 + SOMAXCONN = 4096 + SO_ACCEPTCONN = 30 + SO_ATTACH_BPF = 50 + SO_ATTACH_FILTER = 26 + SO_ATTACH_REUSEPORT_CBPF = 51 + SO_ATTACH_REUSEPORT_EBPF = 52 + SO_BINDTODEVICE = 25 + SO_BINDTOIFINDEX = 62 + SO_BPF_EXTENSIONS = 48 + SO_BROADCAST = 6 + SO_BSDCOMPAT = 14 + SO_BUSY_POLL = 46 + SO_CNX_ADVICE = 53 + SO_COOKIE = 57 + SO_DEBUG = 1 + SO_DETACH_BPF = 27 + SO_DETACH_FILTER = 27 + SO_DETACH_REUSEPORT_BPF = 68 + SO_DOMAIN = 39 + SO_DONTROUTE = 5 + SO_ERROR = 4 + SO_GET_FILTER = 26 + SO_INCOMING_CPU = 49 + SO_INCOMING_NAPI_ID = 56 + SO_KEEPALIVE = 9 + SO_LINGER = 13 + SO_LOCK_FILTER = 44 + SO_MARK = 36 + SO_MAX_PACING_RATE = 47 + SO_MEMINFO = 55 + SO_NOFCS = 43 + SO_NO_CHECK = 11 + SO_OOBINLINE = 10 + SO_PASSCRED = 16 + SO_PASSSEC = 34 + SO_PEEK_OFF = 42 + SO_PEERCRED = 17 + SO_PEERGROUPS = 59 + SO_PEERNAME = 28 + SO_PEERSEC = 31 + SO_PRIORITY = 12 + SO_PROTOCOL = 38 + SO_RCVBUF = 8 + SO_RCVBUFFORCE = 33 + SO_RCVLOWAT = 18 + SO_RCVTIMEO = 20 + SO_RCVTIMEO_NEW = 66 + SO_RCVTIMEO_OLD = 20 + SO_REUSEADDR = 2 + SO_REUSEPORT = 15 + SO_RXQ_OVFL = 40 + SO_SECURITY_AUTHENTICATION = 22 + SO_SECURITY_ENCRYPTION_NETWORK = 24 + SO_SECURITY_ENCRYPTION_TRANSPORT = 23 + SO_SELECT_ERR_QUEUE = 45 + SO_SNDBUF = 7 + SO_SNDBUFFORCE = 32 + SO_SNDLOWAT = 19 + SO_SNDTIMEO = 21 + SO_SNDTIMEO_NEW = 67 + SO_SNDTIMEO_OLD = 21 + SO_TIMESTAMP = 29 + SO_TIMESTAMPING = 37 + SO_TIMESTAMPING_NEW = 65 + SO_TIMESTAMPING_OLD = 37 + SO_TIMESTAMPNS = 35 + SO_TIMESTAMPNS_NEW = 64 + SO_TIMESTAMPNS_OLD = 35 + SO_TIMESTAMP_NEW = 63 + SO_TIMESTAMP_OLD = 29 + SO_TXTIME = 61 + SO_TYPE = 3 + SO_WIFI_STATUS = 41 + SO_ZEROCOPY = 60 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_SOCKADDR_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_STDINT_UINTN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LINUX_POSIX_TYPES_H = 0 + X_LP64 = 1 + X_NETINET_IN_H = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_SS_SIZE = 128 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_SOCKET_H = 1 + X_SYS_TYPES_H = 1 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +// Bits in the FLAGS argument to `send', `recv', et al. +const ( /* socket.h:200:1: */ + MSG_OOB = 1 // Process out-of-band data. + MSG_PEEK = 2 // Peek at incoming messages. + MSG_DONTROUTE = 4 // Don't use local routing. + MSG_CTRUNC = 8 // Control data lost before delivery. + MSG_PROXY = 16 // Supply or ask second address. + MSG_TRUNC = 32 + MSG_DONTWAIT = 64 // Nonblocking IO. + MSG_EOR = 128 // End of record. + MSG_WAITALL = 256 // Wait for a full request. + MSG_FIN = 512 + MSG_SYN = 1024 + MSG_CONFIRM = 2048 // Confirm path validity. + MSG_RST = 4096 + MSG_ERRQUEUE = 8192 // Fetch message from error queue. + MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. + MSG_MORE = 32768 // Sender will send more. + MSG_WAITFORONE = 65536 // Wait for at least one packet to return. + MSG_BATCH = 262144 // sendmmsg: more messages coming. + MSG_ZEROCOPY = 67108864 // Use user data in kernel path. + MSG_FASTOPEN = 536870912 // Send data in TCP SYN. + + MSG_CMSG_CLOEXEC = 1073741824 +) + +// Socket level message types. This must match the definitions in +// +// . +const ( /* socket.h:332:1: */ + SCM_RIGHTS = 1 +) + +// Get the architecture-dependent definition of enum __socket_type. +// Define enum __socket_type for generic Linux. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Types of sockets. +const ( /* socket_type.h:24:1: */ + SOCK_STREAM = 1 // Sequenced, reliable, connection-based + // byte streams. + SOCK_DGRAM = 2 // Connectionless, unreliable datagrams + // of fixed maximum length. + SOCK_RAW = 3 // Raw protocol interface. + SOCK_RDM = 4 // Reliably-delivered messages. + SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, + // datagrams of fixed maximum length. + SOCK_DCCP = 6 // Datagram Congestion Control Protocol. + SOCK_PACKET = 10 // Linux specific way of getting packets + // at the dev level. For writing rarp and + // other similar things on the user level. + + // Flags to be ORed into the type parameter of socket and socketpair and + // used for the flags parameter of paccept. + + SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the + // new descriptor(s). + SOCK_NONBLOCK = 2048 +) + +// Standard well-known ports. +const ( /* in.h:122:1: */ + IPPORT_ECHO = 7 // Echo service. + IPPORT_DISCARD = 9 // Discard transmissions service. + IPPORT_SYSTAT = 11 // System status service. + IPPORT_DAYTIME = 13 // Time of day service. + IPPORT_NETSTAT = 15 // Network status service. + IPPORT_FTP = 21 // File Transfer Protocol. + IPPORT_TELNET = 23 // Telnet protocol. + IPPORT_SMTP = 25 // Simple Mail Transfer Protocol. + IPPORT_TIMESERVER = 37 // Timeserver service. + IPPORT_NAMESERVER = 42 // Domain Name Service. + IPPORT_WHOIS = 43 // Internet Whois service. + IPPORT_MTP = 57 + + IPPORT_TFTP = 69 // Trivial File Transfer Protocol. + IPPORT_RJE = 77 + IPPORT_FINGER = 79 // Finger service. + IPPORT_TTYLINK = 87 + IPPORT_SUPDUP = 95 // SUPDUP protocol. + + IPPORT_EXECSERVER = 512 // execd service. + IPPORT_LOGINSERVER = 513 // rlogind service. + IPPORT_CMDSERVER = 514 + IPPORT_EFSSERVER = 520 + + // UDP ports. + IPPORT_BIFFUDP = 512 + IPPORT_WHOSERVER = 513 + IPPORT_ROUTESERVER = 520 + + // Ports less than this value are reserved for privileged processes. + IPPORT_RESERVED = 1024 + + // Ports greater this value are reserved for (non-privileged) servers. + IPPORT_USERRESERVED = 5000 +) + +// Options for use with `getsockopt' and `setsockopt' at the IPv6 level. +// The first word in the comment at the right is the data type used; +// "bool" means a boolean value stored in an `int'. + +// Advanced API (RFC3542) (1). + +// Advanced API (RFC3542) (2). + +// RFC5014. + +// RFC5082. + +// Obsolete synonyms for the above. + +// IPV6_MTU_DISCOVER values. + +// Socket level values for IPv6. + +// Routing header options for IPv6. + +// Standard well-defined IP protocols. +const ( /* in.h:40:1: */ + IPPROTO_IP = 0 // Dummy protocol for TCP. + IPPROTO_ICMP = 1 // Internet Control Message Protocol. + IPPROTO_IGMP = 2 // Internet Group Management Protocol. + IPPROTO_IPIP = 4 // IPIP tunnels (older KA9Q tunnels use 94). + IPPROTO_TCP = 6 // Transmission Control Protocol. + IPPROTO_EGP = 8 // Exterior Gateway Protocol. + IPPROTO_PUP = 12 // PUP protocol. + IPPROTO_UDP = 17 // User Datagram Protocol. + IPPROTO_IDP = 22 // XNS IDP protocol. + IPPROTO_TP = 29 // SO Transport Protocol Class 4. + IPPROTO_DCCP = 33 // Datagram Congestion Control Protocol. + IPPROTO_IPV6 = 41 // IPv6 header. + IPPROTO_RSVP = 46 // Reservation Protocol. + IPPROTO_GRE = 47 // General Routing Encapsulation. + IPPROTO_ESP = 50 // encapsulating security payload. + IPPROTO_AH = 51 // authentication header. + IPPROTO_MTP = 92 // Multicast Transport Protocol. + IPPROTO_BEETPH = 94 // IP option pseudo header for BEET. + IPPROTO_ENCAP = 98 // Encapsulation Header. + IPPROTO_PIM = 103 // Protocol Independent Multicast. + IPPROTO_COMP = 108 // Compression Header Protocol. + IPPROTO_SCTP = 132 // Stream Control Transmission Protocol. + IPPROTO_UDPLITE = 136 // UDP-Lite protocol. + IPPROTO_MPLS = 137 // MPLS in IP. + IPPROTO_RAW = 255 // Raw IP packets. + IPPROTO_MAX = 256 +) + +// If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel +// +// network headers first and we should use those ABI-identical definitions +// instead of our own, otherwise 0. +const ( /* in.h:99:1: */ + IPPROTO_HOPOPTS = 0 // IPv6 Hop-by-Hop options. + IPPROTO_ROUTING = 43 // IPv6 routing header. + IPPROTO_FRAGMENT = 44 // IPv6 fragmentation header. + IPPROTO_ICMPV6 = 58 // ICMPv6. + IPPROTO_NONE = 59 // IPv6 no next header. + IPPROTO_DSTOPTS = 60 // IPv6 destination options. + IPPROTO_MH = 135 +) + +// The following constants should be used for the second parameter of +// +// `shutdown'. +const ( /* socket.h:41:1: */ + SHUT_RD = 0 // No more receptions. + SHUT_WR = 1 // No more transmissions. + SHUT_RDWR = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// Define uintN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type Uint8_t = X__uint8_t /* stdint-uintn.h:24:19 */ +type Uint16_t = X__uint16_t /* stdint-uintn.h:25:20 */ +type Uint32_t = X__uint32_t /* stdint-uintn.h:26:20 */ +type Uint64_t = X__uint64_t /* stdint-uintn.h:27:20 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Structure for scatter/gather I/O. +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* struct_iovec.h:26:1 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This operating system-specific header file defines the SOCK_*, PF_*, +// AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', +// `struct msghdr', and `struct linger' types. +// System-specific socket constants and types. Linux version. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We don't use `memset' because this would require a prototype and +// the array isn't too big. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +// Type for length arguments in socket calls. +type Socklen_t = X__socklen_t /* socket.h:33:21 */ + +// Protocol families. + +// Address families. + +// Socket level values. Others are defined in the appropriate headers. +// +// XXX These definitions also should go into the appropriate headers as +// far as they are available. + +// Maximum queue length specifiable by listen. + +// Get the definition of the macro to define the common sockaddr members. +// Definition of struct sockaddr_* common members and sizes, generic version. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// POSIX.1g specifies this type name for the `sa_family' member. +type Sa_family_t = uint16 /* sockaddr.h:28:28 */ + +// This macro is used to declare the initial common members +// of the data types used for socket addresses, `struct sockaddr', +// `struct sockaddr_in', `struct sockaddr_un', etc. + +// Size of struct sockaddr_storage. + +// Structure describing a generic socket address. +type Sockaddr = struct { + Fsa_family Sa_family_t + Fsa_data [14]uint8 +} /* socket.h:178:1 */ + +// Structure large enough to hold any socket address (with the historical +// exception of AF_UNIX). + +type Sockaddr_storage = struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 +} /* socket.h:191:1 */ + +// Structure describing messages sent by +// +// `sendmsg' and received by `recvmsg'. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen Size_t + Fmsg_control uintptr + Fmsg_controllen Size_t + Fmsg_flags int32 + F__ccgo_pad2 [4]byte +} /* socket.h:257:1 */ + +// Structure used for storage of ancillary data object information. +type Cmsghdr = struct { + F__ccgo_pad1 [0]uint64 + Fcmsg_len Size_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:275:1 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This allows for 1024 file descriptors: if NR_OPEN is ever grown +// beyond that you'll have to change this too. But 1024 fd's seem to be +// enough even for such "real" unices like OSF/1, so hopefully this is +// one limit that doesn't have to be changed [again]. +// +// Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in +// (and thus ) - but this is a more logical +// place for them. Solved by having dummy defines in . + +// This macro may have been defined in . But we always +// use the one here. + +type X__kernel_fd_set = struct{ Ffds_bits [16]uint64 } /* posix_types.h:27:3 */ + +// Type of a signal handler. +type X__kernel_sighandler_t = uintptr /* posix_types.h:30:14 */ + +// Type of a SYSV IPC key. +type X__kernel_key_t = int32 /* posix_types.h:33:13 */ +type X__kernel_mqd_t = int32 /* posix_types.h:34:13 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +type X__kernel_old_uid_t = uint16 /* posix_types.h:5:24 */ +type X__kernel_old_gid_t = uint16 /* posix_types.h:6:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// Copyright (C) 2012 ARM Ltd. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 . + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// There seems to be no way of detecting this automatically from user +// space, so 64 bit architectures should override this in their +// bitsperlong.h. In particular, an architecture that supports +// both 32 and 64 bit user space must not rely on CONFIG_64BIT +// to decide it, but rather check a compiler provided macro. + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. +// +// First the types that are often defined in different ways across +// architectures, so that you can override them. + +type X__kernel_long_t = int64 /* posix_types.h:15:15 */ +type X__kernel_ulong_t = uint64 /* posix_types.h:16:23 */ + +type X__kernel_ino_t = X__kernel_ulong_t /* posix_types.h:20:26 */ + +type X__kernel_mode_t = uint32 /* posix_types.h:24:22 */ + +type X__kernel_pid_t = int32 /* posix_types.h:28:14 */ + +type X__kernel_ipc_pid_t = int32 /* posix_types.h:32:14 */ + +type X__kernel_uid_t = uint32 /* posix_types.h:36:22 */ +type X__kernel_gid_t = uint32 /* posix_types.h:37:22 */ + +type X__kernel_suseconds_t = X__kernel_long_t /* posix_types.h:41:26 */ + +type X__kernel_daddr_t = int32 /* posix_types.h:45:14 */ + +type X__kernel_uid32_t = uint32 /* posix_types.h:49:22 */ +type X__kernel_gid32_t = uint32 /* posix_types.h:50:22 */ + +type X__kernel_old_dev_t = uint32 /* posix_types.h:59:22 */ + +// Most 32 bit architectures use "unsigned int" size_t, +// and all 64 bit architectures use "unsigned long" size_t. +type X__kernel_size_t = X__kernel_ulong_t /* posix_types.h:72:26 */ +type X__kernel_ssize_t = X__kernel_long_t /* posix_types.h:73:25 */ +type X__kernel_ptrdiff_t = X__kernel_long_t /* posix_types.h:74:25 */ + +type X__kernel_fsid_t = struct{ Fval [2]int32 } /* posix_types.h:81:3 */ + +// anything below here should be completely generic +type X__kernel_off_t = X__kernel_long_t /* posix_types.h:87:25 */ +type X__kernel_loff_t = int64 /* posix_types.h:88:19 */ +type X__kernel_old_time_t = X__kernel_long_t /* posix_types.h:89:25 */ +type X__kernel_time_t = X__kernel_long_t /* posix_types.h:90:25 */ +type X__kernel_time64_t = int64 /* posix_types.h:91:19 */ +type X__kernel_clock_t = X__kernel_long_t /* posix_types.h:92:25 */ +type X__kernel_timer_t = int32 /* posix_types.h:93:14 */ +type X__kernel_clockid_t = int32 /* posix_types.h:94:14 */ +type X__kernel_caddr_t = uintptr /* posix_types.h:95:14 */ +type X__kernel_uid16_t = uint16 /* posix_types.h:96:24 */ +type X__kernel_gid16_t = uint16 /* posix_types.h:97:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// Socket-level I/O control calls. + +// For setsockopt(2) + +// Security levels - as per NRL IPv6 - don't actually do anything + +// Socket filtering + +// Instruct lower device to use last 4-bytes of skb data as FCS + +// on 64-bit and x32, avoid the ?: operator + +// Structure used to manipulate the SO_LINGER option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:361:1 */ + +// This is the 4.3 BSD `struct sockaddr' format, which is used as wire +// +// format in the grotty old 4.3 `talk' protocol. +type Osockaddr = struct { + Fsa_family uint16 + Fsa_data [14]uint8 +} /* struct_osockaddr.h:6:1 */ + +// Define some macros helping to catch buffer overflows. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Internet address. +type In_addr_t = Uint32_t /* in.h:30:18 */ +type In_addr = struct{ Fs_addr In_addr_t } /* in.h:31:1 */ + +// Get system-specific definitions. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Linux version. + +// If the application has already included linux/in6.h from a linux-based +// kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the +// defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo +// in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly. +// Neither the linux kernel nor glibc should break this ABI without coordination. +// In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check +// for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for +// maximum backwards compatibility. + +// Options for use with `getsockopt' and `setsockopt' at the IP level. +// The first word in the comment at the right is the data type used; +// "bool" means a boolean value stored in an `int'. +// For BSD compatibility. + +// TProxy original addresses + +// IP_MTU_DISCOVER arguments. +// Always use interface mtu (ignores dst pmtu) but don't set DF flag. +// Also incoming ICMP frag_needed notifications will be ignored on +// this socket to prevent accepting spoofed ones. +// Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented. + +// To select the IP level. + +// Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. +// +// The `ip_dst' field is used for the first-hop gateway when using a +// source route (this gets put into the header proper). +type Ip_opts = struct { + Fip_dst struct{ Fs_addr In_addr_t } + Fip_opts [40]uint8 +} /* in.h:142:1 */ + +// Like `struct ip_mreq' but including interface specification by index. +type Ip_mreqn = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_address struct{ Fs_addr In_addr_t } + Fimr_ifindex int32 +} /* in.h:149:1 */ + +// Structure used for IP_PKTINFO. +type In_pktinfo = struct { + Fipi_ifindex int32 + Fipi_spec_dst struct{ Fs_addr In_addr_t } + Fipi_addr struct{ Fs_addr In_addr_t } +} /* in.h:157:1 */ + +// Type to represent a port. +type In_port_t = Uint16_t /* in.h:119:18 */ + +// 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. + +// Address to accept any incoming messages. +// Address to send to all hosts. +// Address indicating an error return. + +// Network number for local host loopback. +// Address to loopback in software to local host. + +// Defines for Multicast INADDR. + +// IPv6 address +type In6_addr = struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } +} /* in.h:212:1 */ + +// ::1 + +// Structure describing an Internet socket address. +type Sockaddr_in = struct { + Fsin_family Sa_family_t + Fsin_port In_port_t + Fsin_addr struct{ Fs_addr In_addr_t } + Fsin_zero [8]uint8 +} /* in.h:238:1 */ + +// Ditto, for IPv6. +type Sockaddr_in6 = struct { + Fsin6_family Sa_family_t + Fsin6_port In_port_t + Fsin6_flowinfo Uint32_t + Fsin6_addr struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } + } + Fsin6_scope_id Uint32_t +} /* in.h:253:1 */ + +// IPv4 multicast request. +type Ip_mreq = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } +} /* in.h:265:1 */ + +type Ip_mreq_source = struct { + Fimr_multiaddr struct{ Fs_addr In_addr_t } + Fimr_interface struct{ Fs_addr In_addr_t } + Fimr_sourceaddr struct{ Fs_addr In_addr_t } +} /* in.h:274:1 */ + +// Likewise, for IPv6. +type Ipv6_mreq = struct { + Fipv6mr_multiaddr struct { + F__in6_u struct { + F__ccgo_pad1 [0]uint32 + F__u6_addr8 [16]Uint8_t + } + } + Fipv6mr_interface uint32 +} /* in.h:289:1 */ + +// Multicast group request. +type Group_req = struct { + Fgr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgr_group struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } +} /* in.h:301:1 */ + +type Group_source_req = struct { + Fgsr_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgsr_group struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } + Fgsr_source struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } +} /* in.h:310:1 */ + +// Full-state filter operations. +type Ip_msfilter = struct { + Fimsf_multiaddr struct{ Fs_addr In_addr_t } + Fimsf_interface struct{ Fs_addr In_addr_t } + Fimsf_fmode Uint32_t + Fimsf_numsrc Uint32_t + Fimsf_slist [1]struct{ Fs_addr In_addr_t } +} /* in.h:324:1 */ + +type Group_filter = struct { + Fgf_interface Uint32_t + F__ccgo_pad1 [4]byte + Fgf_group struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } + Fgf_fmode Uint32_t + Fgf_numsrc Uint32_t + Fgf_slist [1]struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 + } +} /* in.h:345:1 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/nodmesg.go b/internal/libc/nodmesg.go new file mode 100644 index 0000000..6ee9d66 --- /dev/null +++ b/internal/libc/nodmesg.go @@ -0,0 +1,12 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !libc.dmesg +// +build !libc.dmesg + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +const dmesgs = false + +func dmesg(s string, args ...interface{}) {} diff --git a/internal/libc/poll/capi_darwin_amd64.go b/internal/libc/poll/capi_darwin_amd64.go new file mode 100644 index 0000000..b7cb991 --- /dev/null +++ b/internal/libc/poll/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo poll/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o poll/poll_darwin_amd64.go -pkgname poll', DO NOT EDIT. + +package poll + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/poll/capi_darwin_arm64.go b/internal/libc/poll/capi_darwin_arm64.go new file mode 100644 index 0000000..b80fe99 --- /dev/null +++ b/internal/libc/poll/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo poll/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o poll/poll_darwin_arm64.go -pkgname poll', DO NOT EDIT. + +package poll + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/poll/capi_linux_amd64.go b/internal/libc/poll/capi_linux_amd64.go new file mode 100644 index 0000000..52c3f3a --- /dev/null +++ b/internal/libc/poll/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo poll/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o poll/poll_linux_amd64.go -pkgname poll', DO NOT EDIT. + +package poll + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/poll/capi_linux_arm64.go b/internal/libc/poll/capi_linux_arm64.go new file mode 100644 index 0000000..9035dda --- /dev/null +++ b/internal/libc/poll/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo poll/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o poll/poll_linux_arm64.go -pkgname poll', DO NOT EDIT. + +package poll + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/poll/poll_darwin_amd64.go b/internal/libc/poll/poll_darwin_amd64.go new file mode 100644 index 0000000..9f3181e --- /dev/null +++ b/internal/libc/poll/poll_darwin_amd64.go @@ -0,0 +1,157 @@ +// Code generated by 'ccgo poll/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o poll/poll_darwin_amd64.go -pkgname poll', DO NOT EDIT. + +package poll + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + POLLATTRIB = 0x0400 // poll.h:81:1: + POLLERR = 0x0008 // poll.h:89:1: + POLLEXTEND = 0x0200 // poll.h:80:1: + POLLHUP = 0x0010 // poll.h:90:1: + POLLIN = 0x0001 // poll.h:68:1: + POLLNLINK = 0x0800 // poll.h:82:1: + POLLNVAL = 0x0020 // poll.h:91:1: + POLLOUT = 0x0004 // poll.h:70:1: + POLLPRI = 0x0002 // poll.h:69:1: + POLLRDBAND = 0x0080 // poll.h:73:1: + POLLRDNORM = 0x0040 // poll.h:71:1: + POLLSTANDARD = 511 // poll.h:93:1: + POLLWRBAND = 0x0100 // poll.h:74:1: + POLLWRITE = 0x1000 // poll.h:83:1: + POLLWRNORM = 4 // poll.h:72:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_SYS_POLL_H_ = 0 // poll.h:58:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2004 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// - +// Copyright (c) 1997 Peter Wemm +// 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 AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (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 intended to be compatible with the traditional poll.h. + +// Requestable events. If poll(2) finds any of these set, they are +// copied to revents on return. + +// FreeBSD extensions: polling on a regular file might return one +// of these events (currently only supported on local filesystems). + +// These events are set if they occur regardless of whether they were +// requested. + +type Pollfd = struct { + Ffd int32 + Fevents int16 + Frevents int16 +} /* poll.h:96:1 */ + +type Nfds_t = uint32 /* poll.h:102:22 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/poll/poll_darwin_arm64.go b/internal/libc/poll/poll_darwin_arm64.go new file mode 100644 index 0000000..1f23983 --- /dev/null +++ b/internal/libc/poll/poll_darwin_arm64.go @@ -0,0 +1,159 @@ +// Code generated by 'ccgo poll/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o poll/poll_darwin_arm64.go -pkgname poll', DO NOT EDIT. + +package poll + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + POLLATTRIB = 0x0400 // poll.h:81:1: + POLLERR = 0x0008 // poll.h:89:1: + POLLEXTEND = 0x0200 // poll.h:80:1: + POLLHUP = 0x0010 // poll.h:90:1: + POLLIN = 0x0001 // poll.h:68:1: + POLLNLINK = 0x0800 // poll.h:82:1: + POLLNVAL = 0x0020 // poll.h:91:1: + POLLOUT = 0x0004 // poll.h:70:1: + POLLPRI = 0x0002 // poll.h:69:1: + POLLRDBAND = 0x0080 // poll.h:73:1: + POLLRDNORM = 0x0040 // poll.h:71:1: + POLLSTANDARD = 511 // poll.h:93:1: + POLLWRBAND = 0x0100 // poll.h:74:1: + POLLWRITE = 0x1000 // poll.h:83:1: + POLLWRNORM = 4 // poll.h:72:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_SYS_POLL_H_ = 0 // poll.h:58:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2004 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// - +// Copyright (c) 1997 Peter Wemm +// 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 AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (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 intended to be compatible with the traditional poll.h. + +// Requestable events. If poll(2) finds any of these set, they are +// copied to revents on return. + +// FreeBSD extensions: polling on a regular file might return one +// of these events (currently only supported on local filesystems). + +// These events are set if they occur regardless of whether they were +// requested. + +type Pollfd = struct { + Ffd int32 + Fevents int16 + Frevents int16 +} /* poll.h:96:1 */ + +type Nfds_t = uint32 /* poll.h:102:22 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/poll/poll_linux_amd64.go b/internal/libc/poll/poll_linux_amd64.go new file mode 100644 index 0000000..57f1b24 --- /dev/null +++ b/internal/libc/poll/poll_linux_amd64.go @@ -0,0 +1,540 @@ +// Code generated by 'ccgo poll/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o poll/poll_linux_amd64.go -pkgname poll', DO NOT EDIT. + +package poll + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + POLLERR = 0x008 // poll.h:47:1: + POLLHUP = 0x010 // poll.h:48:1: + POLLIN = 0x001 // poll.h:25:1: + POLLNVAL = 0x020 // poll.h:49:1: + POLLOUT = 0x004 // poll.h:27:1: + POLLPRI = 0x002 // poll.h:26:1: + POLLRDBAND = 0x080 // poll.h:32:1: + POLLRDNORM = 0x040 // poll.h:31:1: + POLLWRBAND = 0x200 // poll.h:34:1: + POLLWRNORM = 0x100 // poll.h:33:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_POLL_H = 1 // poll.h:20:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Compatibility definitions for System V `poll' interface. +// Copyright (C) 1994-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// Get the platform dependent bits of `poll'. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Event types that can be polled for. These bits may be set in `events' +// to indicate the interesting event types; they will appear in `revents' +// to indicate the status of the file descriptor. + +// These values are defined in XPG4.2. + +// Event types always implicitly polled for. These bits need not be set in +// `events', but they will appear in `revents' to indicate the status of +// the file descriptor. + +// Type used for the number of file descriptors. +type Nfds_t = uint64 /* poll.h:33:27 */ + +// Data structure describing a polling request. +type Pollfd = struct { + Ffd int32 + Fevents int16 + Frevents int16 +} /* poll.h:36:1 */ + +// Define some inlines helping to catch common problems. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/poll/poll_linux_arm64.go b/internal/libc/poll/poll_linux_arm64.go new file mode 100644 index 0000000..7b7d65e --- /dev/null +++ b/internal/libc/poll/poll_linux_arm64.go @@ -0,0 +1,575 @@ +// Code generated by 'ccgo poll/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o poll/poll_linux_arm64.go -pkgname poll', DO NOT EDIT. + +package poll + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + POLLERR = 0x008 + POLLHUP = 0x010 + POLLIN = 0x001 + POLLNVAL = 0x020 + POLLOUT = 0x004 + POLLPRI = 0x002 + POLLRDBAND = 0x080 + POLLRDNORM = 0x040 + POLLWRBAND = 0x200 + POLLWRNORM = 0x100 + X_ATFILE_SOURCE = 1 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + X_SYS_POLL_H = 1 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Compatibility definitions for System V `poll' interface. +// Copyright (C) 1994-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// Get the platform dependent bits of `poll'. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Event types that can be polled for. These bits may be set in `events' +// to indicate the interesting event types; they will appear in `revents' +// to indicate the status of the file descriptor. + +// These values are defined in XPG4.2. + +// Event types always implicitly polled for. These bits need not be set in +// `events', but they will appear in `revents' to indicate the status of +// the file descriptor. + +// Type used for the number of file descriptors. +type Nfds_t = uint64 /* poll.h:33:27 */ + +// Data structure describing a polling request. +type Pollfd = struct { + Ffd int32 + Fevents int16 + Frevents int16 +} /* poll.h:36:1 */ + +// Define some inlines helping to catch common problems. + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/printf.go b/internal/libc/printf.go new file mode 100644 index 0000000..dc0925f --- /dev/null +++ b/internal/libc/printf.go @@ -0,0 +1,684 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "bytes" + "fmt" + "runtime" + "strconv" + "strings" + "unsafe" +) + +const ( + modNone = iota + modHH + modH + modL + modLL + modLD + modQ + modCapitalL + modJ + modZ + modCapitalZ + modT + mod32 + mod64 +) + +// Format of the format string +// +// The format string is a character string, beginning and ending in its initial +// shift state, if any. The format string is composed of zero or more +// directives: ordinary characters (not %), which are copied unchanged to +// the output stream; and conversion specifications, each of which results in +// fetching zero or more subsequent arguments. +func printf(format, args uintptr) []byte { + // format0 := format + // args0 := args + buf := bytes.NewBuffer(nil) + for { + switch c := *(*byte)(unsafe.Pointer(format)); c { + case '%': + format = printfConversion(buf, format, &args) + case 0: + // if dmesgs { + // dmesg("%v: %q, %#x -> %q", origin(1), GoString(format0), args0, buf.Bytes()) + // } + return buf.Bytes() + default: + format++ + buf.WriteByte(c) + } + } +} + +// Each conversion specification is introduced by the character %, and ends +// with a conversion specifier. In between there may be (in this order) zero +// or more flags, an optional minimum field width, an optional precision and +// an optional length modifier. +func printfConversion(buf *bytes.Buffer, format uintptr, args *uintptr) uintptr { + format++ // '%' + spec := "%" + + // Flags characters + // + // The character % is followed by zero or more of the following flags: +flags: + for { + switch c := *(*byte)(unsafe.Pointer(format)); c { + case '#': + // The value should be converted to an "alternate form". For o conversions, + // the first character of the output string is made zero (by prefixing a 0 if + // it was not zero already). For x and X conversions, a nonzero result has + // the string "0x" (or "0X" for X conversions) prepended to it. For a, A, e, + // E, f, F, g, and G conversions, the result will always contain a decimal + // point, even if no digits follow it (normally, a decimal point appears in the + // results of those conversions only if a digit follows). For g and G + // conversions, trailing zeros are not removed from the result as they would + // otherwise be. For other conversions, the result is undefined. + format++ + spec += "#" + case '0': + // The value should be zero padded. For d, i, o, u, x, X, a, A, e, E, f, F, + // g, and G conversions, the converted value is padded on the left with zeros + // rather than blanks. If the 0 and - flags both appear, the 0 flag is + // ignored. If a precision is given with a numeric conversion (d, i, o, u, x, + // and X), the 0 flag is ignored. For other conversions, the behav‐ ior is + // undefined. + format++ + spec += "0" + case '-': + // The converted value is to be left adjusted on the field boundary. (The + // default is right justification.) The converted value is padded on the right + // with blanks, rather than on the left with blanks or zeros. A - overrides a + // 0 if both are given. + format++ + spec += "-" + case ' ': + // A blank should be left before a positive number (or empty string) produced + // by a signed conversion. + format++ + spec += " " + case '+': + // A sign (+ or -) should always be placed before a number produced by a signed + // conversion. By default, a sign is used only for negative numbers. A + + // overrides a space if both are used. + format++ + spec += "+" + default: + break flags + } + } + format, width, hasWidth := parseFieldWidth(format, args) + if hasWidth { + spec += strconv.Itoa(width) + } + format, prec, hasPrecision := parsePrecision(format, args) + format, mod := parseLengthModifier(format) + + var str string + +more: + // Conversion specifiers + // + // A character that specifies the type of conversion to be applied. The + // conversion specifiers and their meanings are: + switch c := *(*byte)(unsafe.Pointer(format)); c { + case 'd', 'i': + // The int argument is converted to signed decimal notation. The precision, + // if any, gives the minimum number of digits that must appear; if the + // converted value requires fewer digits, it is padded on the left with zeros. + // The default precision is 1. When 0 is printed with an explicit precision 0, + // the output is empty. + format++ + var arg int64 + if isWindows && mod == modL { + mod = modNone + } + switch mod { + case modL, modLL, mod64, modJ: + arg = VaInt64(args) + case modH: + arg = int64(int16(VaInt32(args))) + case modHH: + arg = int64(int8(VaInt32(args))) + case mod32, modNone: + arg = int64(VaInt32(args)) + case modT: + arg = int64(VaInt64(args)) + default: + panic(todo("", mod)) + } + + if arg == 0 && hasPrecision && prec == 0 { + break + } + + if hasPrecision { + panic(todo("", prec)) + } + + f := spec + "d" + str = fmt.Sprintf(f, arg) + case 'u': + // The unsigned int argument is converted to unsigned decimal notation. The + // precision, if any, gives the minimum number of digits that must appear; if + // the converted value requires fewer digits, it is padded on the left with + // zeros. The default precision is 1. When 0 is printed with an explicit + // precision 0, the output is empty. + format++ + var arg uint64 + if isWindows && mod == modL { + mod = modNone + } + switch mod { + case modNone: + arg = uint64(VaUint32(args)) + case modL, modLL, mod64: + arg = VaUint64(args) + case modH: + arg = uint64(uint16(VaInt32(args))) + case modHH: + arg = uint64(uint8(VaInt32(args))) + case mod32: + arg = uint64(VaInt32(args)) + case modZ: + arg = uint64(VaInt64(args)) + default: + panic(todo("", mod)) + } + + if arg == 0 && hasPrecision && prec == 0 { + break + } + + if hasPrecision { + panic(todo("", prec)) + } + + f := spec + "d" + str = fmt.Sprintf(f, arg) + case 'o': + // The unsigned int argument is converted to unsigned octal notation. The + // precision, if any, gives the minimum number of digits that must appear; if + // the converted value requires fewer digits, it is padded on the left with + // zeros. The default precision is 1. When 0 is printed with an explicit + // precision 0, the output is empty. + format++ + var arg uint64 + if isWindows && mod == modL { + mod = modNone + } + switch mod { + case modNone: + arg = uint64(VaUint32(args)) + case modL, modLL, mod64: + arg = VaUint64(args) + case modH: + arg = uint64(uint16(VaInt32(args))) + case modHH: + arg = uint64(uint8(VaInt32(args))) + case mod32: + arg = uint64(VaInt32(args)) + default: + panic(todo("", mod)) + } + + if arg == 0 && hasPrecision && prec == 0 { + break + } + + if hasPrecision { + panic(todo("", prec)) + } + + f := spec + "o" + str = fmt.Sprintf(f, arg) + case 'b': + // Base 2. + format++ + var arg uint64 + if isWindows && mod == modL { + mod = modNone + } + switch mod { + case modNone: + arg = uint64(VaUint32(args)) + case modL, modLL, mod64: + arg = VaUint64(args) + case modH: + arg = uint64(uint16(VaInt32(args))) + case modHH: + arg = uint64(uint8(VaInt32(args))) + case mod32: + arg = uint64(VaInt32(args)) + default: + panic(todo("", mod)) + } + + if arg == 0 && hasPrecision && prec == 0 { + break + } + + if hasPrecision { + panic(todo("", prec)) + } + + f := spec + "b" + str = fmt.Sprintf(f, arg) + case 'I': + if !isWindows { + panic(todo("%#U", c)) + } + + format++ + switch c = *(*byte)(unsafe.Pointer(format)); c { + case 'x', 'X': + // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-wsprintfa + // + // Ix, IX + // + // 64-bit unsigned hexadecimal integer in lowercase or uppercase on 64-bit + // platforms, 32-bit unsigned hexadecimal integer in lowercase or uppercase on + // 32-bit platforms. + if unsafe.Sizeof(int(0)) == 4 { + mod = mod32 + } + case '3': + // https://en.wikipedia.org/wiki/Printf_format_string#Length_field + // + // I32 For integer types, causes printf to expect a 32-bit (double word) integer argument. + format++ + switch c = *(*byte)(unsafe.Pointer(format)); c { + case '2': + format++ + mod = mod32 + goto more + default: + panic(todo("%#U", c)) + } + case '6': + // https://en.wikipedia.org/wiki/Printf_format_string#Length_field + // + // I64 For integer types, causes printf to expect a 64-bit (quad word) integer argument. + format++ + switch c = *(*byte)(unsafe.Pointer(format)); c { + case '4': + format++ + mod = mod64 + goto more + default: + panic(todo("%#U", c)) + } + default: + panic(todo("%#U", c)) + } + fallthrough + case 'X': + fallthrough + case 'x': + // The unsigned int argument is converted to unsigned hexadecimal notation. + // The letters abcdef are used for x conversions; the letters ABCDEF are used + // for X conversions. The precision, if any, gives the minimum number of + // digits that must appear; if the converted value requires fewer digits, it is + // padded on the left with zeros. The default precision is 1. When 0 is + // printed with an explicit precision 0, the output is empty. + format++ + var arg uint64 + if isWindows && mod == modL { + mod = modNone + } + switch mod { + case modNone: + arg = uint64(VaUint32(args)) + case modL, modLL, mod64: + arg = VaUint64(args) + case modH: + arg = uint64(uint16(VaInt32(args))) + case modHH: + arg = uint64(uint8(VaInt32(args))) + case mod32: + arg = uint64(VaInt32(args)) + case modZ: + arg = uint64(VaInt64(args)) + default: + panic(todo("", mod)) + } + + if arg == 0 && hasPrecision && prec == 0 { + break + } + + if strings.Contains(spec, "#") && arg == 0 { + spec = strings.ReplaceAll(spec, "#", "") + } + var f string + switch { + case hasPrecision: + f = fmt.Sprintf("%s.%d%c", spec, prec, c) + default: + f = spec + string(c) + } + str = fmt.Sprintf(f, arg) + case 'e', 'E': + // The double argument is rounded and converted in the style [-]d.ddde±dd where + // there is one digit before the decimal-point character and the number of + // digits after it is equal to the precision; if the precision is missing, it + // is taken as 6; if the precision is zero, no decimal-point character appears. + // An E conversion uses the letter E (rather than e) to intro‐ duce the + // exponent. The exponent always contains at least two digits; if the value is + // zero, the exponent is 00. + format++ + arg := VaFloat64(args) + if !hasPrecision { + prec = 6 + } + f := fmt.Sprintf("%s.%d%c", spec, prec, c) + str = fmt.Sprintf(f, arg) + case 'f', 'F': + // The double argument is rounded and converted to decimal notation in the + // style [-]ddd.ddd, where the number of digits after the decimal-point + // character is equal to the precision specification. If the precision + // is missing, it is taken as 6; if the precision is explicitly zero, no + // decimal-point character appears. If a decimal point appears, at least one + // digit appears before it. + format++ + arg := VaFloat64(args) + if !hasPrecision { + prec = 6 + } + f := fmt.Sprintf("%s.%d%c", spec, prec, c) + str = fixNanInf(fmt.Sprintf(f, arg)) + case 'G': + fallthrough + case 'g': + // The double argument is converted in style f or e (or F or E for G + // conversions). The precision specifies the number of significant digits. If + // the precision is missing, 6 digits are given; if the precision is zero, it + // is treated as 1. Style e is used if the exponent from its conversion is + // less than -4 or greater than or equal to the precision. Trailing zeros are + // removed from the fractional part of the result; a decimal point appears only + // if it is followed by at least one digit. + format++ + arg := VaFloat64(args) + if !hasPrecision { + prec = 6 + } + if prec == 0 { + prec = 1 + } + + f := fmt.Sprintf("%s.%d%c", spec, prec, c) + str = fixNanInf(fmt.Sprintf(f, arg)) + case 's': + // If no l modifier is present: the const char * argument is expected to be a + // pointer to an array of character type (pointer to a string). Characters + // from the array are written up to (but not including) a terminating null byte + // ('\0'); if a precision is specified, no more than the number specified are + // written. If a precision is given, no null byte need be present; if + // the precision is not specified, or is greater than the size of the array, + // the array must contain a terminating null byte. + // + // If an l modifier is present: the const wchar_t * argument is expected + // to be a pointer to an array of wide characters. Wide characters from the + // array are converted to multibyte characters (each by a call to the + // wcrtomb(3) function, with a conversion state starting in the initial state + // before the first wide character), up to and including a terminating null + // wide character. The resulting multibyte characters are written up to + // (but not including) the terminating null byte. If a precision is specified, + // no more bytes than the number specified are written, but no partial + // multibyte characters are written. Note that the precision determines the + // number of bytes written, not the number of wide characters or screen + // positions. The array must contain a terminating null wide character, + // unless a precision is given and it is so small that the number of bytes + // written exceeds it before the end of the array is reached. + format++ + arg := VaUintptr(args) + switch mod { + case modNone: + var f string + switch { + case hasPrecision: + f = fmt.Sprintf("%s.%ds", spec, prec) + str = fmt.Sprintf(f, GoString(arg)) + default: + f = spec + "s" + str = fmt.Sprintf(f, GoString(arg)) + } + default: + panic(todo("")) + } + case 'p': + // The void * pointer argument is printed in hexadecimal (as if by %#x or + // %#lx). + format++ + switch runtime.GOOS { + case "windows": + switch runtime.GOARCH { + case "386", "arm": + fmt.Fprintf(buf, "%08X", VaUintptr(args)) + default: + fmt.Fprintf(buf, "%016X", VaUintptr(args)) + } + default: + fmt.Fprintf(buf, "%#0x", VaUintptr(args)) + } + case 'c': + // If no l modifier is present, the int argument is converted to an unsigned + // char, and the resulting character is written. If an l modifier is present, + // the wint_t (wide character) ar‐ gument is converted to a multibyte sequence + // by a call to the wcrtomb(3) function, with a conversion state starting in + // the initial state, and the resulting multibyte string is writ‐ ten. + format++ + switch mod { + case modNone: + arg := VaInt32(args) + buf.WriteByte(byte(arg)) + default: + panic(todo("")) + } + case '%': + // A '%' is written. No argument is converted. The complete conversion + // specification is '%%'. + format++ + buf.WriteByte('%') + default: + panic(todo("%#U", c)) + } + + buf.WriteString(str) + return format +} + +// Field width +// +// An optional decimal digit string (with nonzero first digit) specifying a +// minimum field width. If the converted value has fewer characters than the +// field width, it will be padded with spa‐ ces on the left (or right, if the +// left-adjustment flag has been given). Instead of a decimal digit string one +// may write "*" or "*m$" (for some decimal integer m) to specify that the +// field width is given in the next argument, or in the m-th argument, +// respectively, which must be of type int. A negative field width is taken as +// a '-' flag followed by a positive field width. In no case does a +// nonexistent or small field width cause truncation of a field; if the result +// of a conversion is wider than the field width, the field is expanded to +// contain the conversion result. +func parseFieldWidth(format uintptr, args *uintptr) (_ uintptr, n int, ok bool) { + first := true + for { + var digit int + switch c := *(*byte)(unsafe.Pointer(format)); { + case first && c == '0': + return format, n, ok + case first && c == '*': + format++ + switch c := *(*byte)(unsafe.Pointer(format)); { + case c >= '0' && c <= '9': + panic(todo("")) + default: + return format, int(VaInt32(args)), true + } + case c >= '0' && c <= '9': + format++ + ok = true + first = false + digit = int(c) - '0' + default: + return format, n, ok + } + + n0 := n + n = 10*n + digit + if n < n0 { + panic(todo("")) + } + } +} + +// Precision +// +// An optional precision, in the form of a period ('.') followed by an +// optional decimal digit string. Instead of a decimal digit string one may +// write "*" or "*m$" (for some decimal integer m) to specify that the +// precision is given in the next argument, or in the m-th argument, +// respectively, which must be of type int. If the precision is given as just +// '.', the precision is taken to be zero. A negative precision is taken +// as if the precision were omitted. This gives the minimum number of digits +// to appear for d, i, o, u, x, and X conversions, the number of digits to +// appear after the radix character for a, A, e, E, f, and F conversions, the +// maximum number of significant digits for g and G conversions, or the maximum +// number of characters to be printed from a string for s and S conversions. +func parsePrecision(format uintptr, args *uintptr) (_ uintptr, n int, ok bool) { + for { + switch c := *(*byte)(unsafe.Pointer(format)); c { + case '.': + format++ + first := true + for { + switch c := *(*byte)(unsafe.Pointer(format)); { + case first && c == '*': + format++ + n = int(VaInt32(args)) + return format, n, true + case c >= '0' && c <= '9': + format++ + first = false + n0 := n + n = 10*n + (int(c) - '0') + if n < n0 { + panic(todo("")) + } + default: + return format, n, true + } + } + default: + return format, 0, false + } + } +} + +// Length modifier +// +// Here, "integer conversion" stands for d, i, o, u, x, or X conversion. +// +// hh A following integer conversion corresponds to a signed char or +// unsigned char argument, or a following n conversion corresponds to a pointer +// to a signed char argument. +// +// h A following integer conversion corresponds to a short int or unsigned +// short int argument, or a following n conversion corresponds to a pointer to +// a short int argument. +// +// l (ell) A following integer conversion corresponds to a long int or +// unsigned long int argument, or a following n conversion corresponds to a +// pointer to a long int argument, or a fol‐ lowing c conversion corresponds to +// a wint_t argument, or a following s conversion corresponds to a pointer to +// wchar_t argument. +// +// ll (ell-ell). A following integer conversion corresponds to a long long +// int or unsigned long long int argument, or a following n conversion +// corresponds to a pointer to a long long int argument. +// +// q A synonym for ll. This is a nonstandard extension, derived from BSD; +// avoid its use in new code. +// +// L A following a, A, e, E, f, F, g, or G conversion corresponds to a +// long double argument. (C99 allows %LF, but SUSv2 does not.) +// +// j A following integer conversion corresponds to an intmax_t or +// uintmax_t argument, or a following n conversion corresponds to a pointer to +// an intmax_t argument. +// +// z A following integer conversion corresponds to a size_t or ssize_t +// argument, or a following n conversion corresponds to a pointer to a size_t +// argument. +// +// Z A nonstandard synonym for z that predates the appearance of z. Do +// not use in new code. +// +// t A following integer conversion corresponds to a ptrdiff_t argument, +// or a following n conversion corresponds to a pointer to a ptrdiff_t +// argument. + +func parseLengthModifier(format uintptr) (_ uintptr, n int) { + switch c := *(*byte)(unsafe.Pointer(format)); c { + case 'h': + format++ + n = modH + switch c := *(*byte)(unsafe.Pointer(format)); c { + case 'h': + format++ + n = modHH + } + return format, n + case 'l': + format++ + n = modL + switch c := *(*byte)(unsafe.Pointer(format)); c { + case 'l': + format++ + n = modLL + } + return format, n + case 'q': + panic(todo("")) + case 'L': + format++ + n = modLD + return format, n + case 'j': + format++ + n = modJ + return format, n + case 'z': + format++ + return format, modZ + case 'Z': + format++ + return format, modCapitalZ + case 't': + format++ + return format, modT + default: + return format, 0 + } +} + +func fixNanInf(s string) string { + switch s { + case "NaN": + return "nan" + case "+Inf", "-Inf": + return "inf" + default: + return s + } +} diff --git a/internal/libc/probes.go b/internal/libc/probes.go new file mode 100644 index 0000000..1bfbce9 --- /dev/null +++ b/internal/libc/probes.go @@ -0,0 +1,169 @@ +// Copyright 2022 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "bytes" + "fmt" + "math" + "runtime/debug" + "sort" + "strings" + "sync" + "sync/atomic" + + "github.com/dustin/go-humanize" +) + +type PerfCounter struct { + a []int32 + labels []string + + enabled bool +} + +func NewPerfCounter(labels []string) *PerfCounter { + return &PerfCounter{ + a: make([]int32, len(labels)), + labels: labels, + enabled: true, + } +} + +func (c *PerfCounter) Disable() { c.enabled = false } +func (c *PerfCounter) Enable() { c.enabled = true } + +func (c *PerfCounter) Clear() { + for i := range c.a { + c.a[i] = 0 + } +} + +func (c *PerfCounter) Inc(n int) { + if c.enabled { + atomic.AddInt32(&c.a[n], 1) + } +} + +func (c *PerfCounter) IncN(n, m int) { + if c.enabled { + atomic.AddInt32(&c.a[n], int32(m)) + } +} + +func (c *PerfCounter) String() string { + sv := c.enabled + + defer func() { c.enabled = sv }() + + c.enabled = false + + var a []string + for i, v := range c.a { + if v != 0 { + a = append(a, fmt.Sprintf("%q: %s", c.labels[i], h(v))) + } + } + return fmt.Sprint(a) +} + +func h(v interface{}) string { + switch x := v.(type) { + case int: + return humanize.Comma(int64(x)) + case int32: + return humanize.Comma(int64(x)) + case int64: + return humanize.Comma(x) + case uint32: + return humanize.Comma(int64(x)) + case uint64: + if x <= math.MaxInt64 { + return humanize.Comma(int64(x)) + } + + return "-" + humanize.Comma(-int64(x)) + } + return fmt.Sprint(v) +} + +type StackCapture struct { + sync.Mutex + m map[string]int + + depth int + + enabled bool +} + +func NewStackCapture(depth int) *StackCapture { + return &StackCapture{ + m: map[string]int{}, + depth: depth, + enabled: true, + } +} + +func (c *StackCapture) Disable() { c.enabled = false } +func (c *StackCapture) Enable() { c.enabled = true } + +func (c *StackCapture) Clear() { + c.Lock() + + defer c.Unlock() + c.m = map[string]int{} +} + +var ( + stackCapturePrefix = []byte("\n\t") +) + +func (c *StackCapture) Record() { + if !c.enabled { + return + } + + b := debug.Stack() + var s strings.Builder +out: + for i := 0; len(b) > 0 && i < c.depth+2; i++ { + l := bytes.Index(b, stackCapturePrefix) + if l < 0 { + break out + } + + b = b[l+len(stackCapturePrefix):] + h := bytes.IndexByte(b, '\n') + if h < 0 { + h = len(b) + } + if i > 1 { + fmt.Fprintf(&s, "\n\t%s", b[:h]) + } + b = b[h:] + } + c.Lock() + + defer c.Unlock() + + c.m[s.String()]++ +} + +func (c *StackCapture) String() string { + c.Lock() + + defer c.Unlock() + + var b strings.Builder + var a []string + for k := range c.m { + a = append(a, k) + } + sort.Slice(a, func(i, j int) bool { return c.m[a[i]] < c.m[a[j]] }) + for _, k := range a { + fmt.Fprintf(&b, "%d%s\n", c.m[k], k) + } + return b.String() +} diff --git a/internal/libc/pthread.go b/internal/libc/pthread.go new file mode 100644 index 0000000..4dd0d3d --- /dev/null +++ b/internal/libc/pthread.go @@ -0,0 +1,741 @@ +// Copyright 2021 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "runtime" + "sync" + "sync/atomic" + "time" + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc/errno" + "github.com/hanzoai/sqlite/internal/libc/pthread" + "github.com/hanzoai/sqlite/internal/libc/sys/types" + ctime "github.com/hanzoai/sqlite/internal/libc/time" +) + +var ( + mutexes = map[uintptr]*mutex{} + mutexesMu sync.Mutex + + threads = map[int32]*TLS{} + threadsMu sync.Mutex + + threadKey pthread.Pthread_key_t + threadKeyDestructors = map[pthread.Pthread_key_t][]uintptr{} // key: []destructor + threadsKeysMu sync.Mutex + + conds = map[uintptr]*cond{} + condsMu sync.Mutex +) + +// Thread local storage. +type TLS struct { + errnop uintptr + allocaStack [][]uintptr + allocas []uintptr + jumpBuffers []uintptr + lastError uint32 + pthreadData + sp int + stack stackHeader + + ID int32 + reentryGuard int32 // memgrind + stackHeaderBalance int32 +} + +var errno0 int32 // Temp errno for NewTLS + +func NewTLS() *TLS { + return newTLS(false) +} + +func newTLS(detached bool) *TLS { + id := atomic.AddInt32(&tid, 1) + t := &TLS{ID: id, errnop: uintptr(unsafe.Pointer(&errno0))} + t.pthreadData.init(t, detached) + if memgrind { + atomic.AddInt32(&tlsBalance, 1) + } + t.errnop = t.Alloc(int(unsafe.Sizeof(int32(0)))) + *(*int32)(unsafe.Pointer(t.errnop)) = 0 + return t +} + +// StackSlots reports the number of tls stack slots currently in use. +func (tls *TLS) StackSlots() int { + return tls.sp +} + +func (t *TLS) alloca(n size_t) (r uintptr) { + r = Xmalloc(t, n) + t.allocas = append(t.allocas, r) + return r +} + +func (t *TLS) FreeAlloca() func() { + t.allocaStack = append(t.allocaStack, t.allocas) + t.allocas = nil + return func() { + for _, v := range t.allocas { + Xfree(t, v) + } + n := len(t.allocaStack) + t.allocas = t.allocaStack[n-1] + t.allocaStack = t.allocaStack[:n-1] + } +} + +func (tls *TLS) PushJumpBuffer(jb uintptr) { + tls.jumpBuffers = append(tls.jumpBuffers, jb) +} + +type LongjmpRetval int32 + +func (tls *TLS) PopJumpBuffer(jb uintptr) { + n := len(tls.jumpBuffers) + if n == 0 || tls.jumpBuffers[n-1] != jb { + panic(todo("unsupported setjmp/longjmp usage")) + } + + tls.jumpBuffers = tls.jumpBuffers[:n-1] +} + +func (tls *TLS) Longjmp(jb uintptr, val int32) { + tls.PopJumpBuffer(jb) + if val == 0 { + val = 1 + } + panic(LongjmpRetval(val)) +} + +func Xalloca(tls *TLS, size size_t) uintptr { + if __ccgo_strace { + trc("tls=%v size=%v, (%v:)", tls, size, origin(2)) + } + return tls.alloca(size) +} + +func X__builtin_alloca(tls *TLS, size size_t) uintptr { + if __ccgo_strace { + trc("tls=%v size=%v, (%v:)", tls, size, origin(2)) + } + return Xalloca(tls, size) +} + +// Pthread specific part of a TLS. +type pthreadData struct { + done chan struct{} + kv map[pthread.Pthread_key_t]uintptr + retVal uintptr + wait chan struct{} // cond var interaction + + detached bool +} + +func (d *pthreadData) init(t *TLS, detached bool) { + d.detached = detached + d.wait = make(chan struct{}, 1) + if detached { + return + } + + d.done = make(chan struct{}) + + threadsMu.Lock() + + defer threadsMu.Unlock() + + threads[t.ID] = t +} + +func (d *pthreadData) close(t *TLS) { + threadsMu.Lock() + + defer threadsMu.Unlock() + + delete(threads, t.ID) +} + +// int pthread_attr_destroy(pthread_attr_t *attr); +func Xpthread_attr_destroy(t *TLS, pAttr uintptr) int32 { + if __ccgo_strace { + trc("t=%v pAttr=%v, (%v:)", t, pAttr, origin(2)) + } + return 0 +} + +// int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope); +func Xpthread_attr_setscope(t *TLS, pAttr uintptr, contentionScope int32) int32 { + if __ccgo_strace { + trc("t=%v pAttr=%v contentionScope=%v, (%v:)", t, pAttr, contentionScope, origin(2)) + } + switch contentionScope { + case pthread.PTHREAD_SCOPE_SYSTEM: + return 0 + default: + panic(todo("", contentionScope)) + } +} + +// int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); +func Xpthread_attr_setstacksize(t *TLS, attr uintptr, stackSize types.Size_t) int32 { + if __ccgo_strace { + trc("t=%v attr=%v stackSize=%v, (%v:)", t, attr, stackSize, origin(2)) + } + return 0 +} + +// Go side data of pthread_cond_t. +type cond struct { + sync.Mutex + waiters map[*TLS]struct{} +} + +func newCond() *cond { + return &cond{ + waiters: map[*TLS]struct{}{}, + } +} + +func (c *cond) signal(all bool) int32 { + if c == nil { + return errno.EINVAL + } + + c.Lock() + + defer c.Unlock() + + // The pthread_cond_broadcast() and pthread_cond_signal() functions shall have + // no effect if there are no threads currently blocked on cond. + for tls := range c.waiters { + tls.wait <- struct{}{} + delete(c.waiters, tls) + if !all { + break + } + } + return 0 +} + +// The pthread_cond_init() function shall initialize the condition variable +// referenced by cond with attributes referenced by attr. If attr is NULL, the +// default condition variable attributes shall be used; the effect is the same +// as passing the address of a default condition variable attributes object. +// Upon successful initialization, the state of the condition variable shall +// become initialized. +// +// If successful, the pthread_cond_destroy() and pthread_cond_init() functions +// shall return zero; otherwise, an error number shall be returned to indicate +// the error. +// +// int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr); +func Xpthread_cond_init(t *TLS, pCond, pAttr uintptr) int32 { + if __ccgo_strace { + trc("t=%v pAttr=%v, (%v:)", t, pAttr, origin(2)) + } + if pCond == 0 { + return errno.EINVAL + } + + if pAttr != 0 { + panic(todo("%#x %#x", pCond, pAttr)) + } + + condsMu.Lock() + + defer condsMu.Unlock() + + conds[pCond] = newCond() + return 0 +} + +// int pthread_cond_destroy(pthread_cond_t *cond); +func Xpthread_cond_destroy(t *TLS, pCond uintptr) int32 { + if __ccgo_strace { + trc("t=%v pCond=%v, (%v:)", t, pCond, origin(2)) + } + if pCond == 0 { + return errno.EINVAL + } + + condsMu.Lock() + + defer condsMu.Unlock() + + cond := conds[pCond] + if cond == nil { + return errno.EINVAL + } + + cond.Lock() + + defer cond.Unlock() + + if len(cond.waiters) != 0 { + return errno.EBUSY + } + + delete(conds, pCond) + return 0 +} + +// int pthread_cond_signal(pthread_cond_t *cond); +func Xpthread_cond_signal(t *TLS, pCond uintptr) int32 { + if __ccgo_strace { + trc("t=%v pCond=%v, (%v:)", t, pCond, origin(2)) + } + return condSignal(pCond, false) +} + +// int pthread_cond_broadcast(pthread_cond_t *cond); +func Xpthread_cond_broadcast(t *TLS, pCond uintptr) int32 { + if __ccgo_strace { + trc("t=%v pCond=%v, (%v:)", t, pCond, origin(2)) + } + return condSignal(pCond, true) +} + +func condSignal(pCond uintptr, all bool) int32 { + if pCond == 0 { + return errno.EINVAL + } + + condsMu.Lock() + cond := conds[pCond] + condsMu.Unlock() + + return cond.signal(all) +} + +// int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex); +func Xpthread_cond_wait(t *TLS, pCond, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } + if pCond == 0 { + return errno.EINVAL + } + + condsMu.Lock() + cond := conds[pCond] + if cond == nil { // static initialized condition variables are valid + cond = newCond() + conds[pCond] = cond + } + + cond.Lock() + cond.waiters[t] = struct{}{} + cond.Unlock() + + condsMu.Unlock() + + mutexesMu.Lock() + mu := mutexes[pMutex] + mutexesMu.Unlock() + + mu.Unlock() + <-t.wait + mu.Lock() + return 0 +} + +// int pthread_cond_timedwait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstime); +func Xpthread_cond_timedwait(t *TLS, pCond, pMutex, pAbsTime uintptr) int32 { + if __ccgo_strace { + trc("t=%v pAbsTime=%v, (%v:)", t, pAbsTime, origin(2)) + } + if pCond == 0 { + return errno.EINVAL + } + + condsMu.Lock() + cond := conds[pCond] + if cond == nil { // static initialized condition variables are valid + cond = newCond() + conds[pCond] = cond + } + + cond.Lock() + cond.waiters[t] = struct{}{} + cond.Unlock() + + condsMu.Unlock() + + mutexesMu.Lock() + mu := mutexes[pMutex] + mutexesMu.Unlock() + + deadlineSecs := (*ctime.Timespec)(unsafe.Pointer(pAbsTime)).Ftv_sec + deadlineNsecs := (*ctime.Timespec)(unsafe.Pointer(pAbsTime)).Ftv_nsec + deadline := time.Unix(int64(deadlineSecs), int64(deadlineNsecs)) + d := deadline.Sub(time.Now()) + switch { + case d <= 0: + return errno.ETIMEDOUT + default: + to := time.After(d) + mu.Unlock() + + defer mu.Lock() + + select { + case <-t.wait: + return 0 + case <-to: + cond.Lock() + + defer cond.Unlock() + + delete(cond.waiters, t) + select { + case <-t.wait: + default: + } + return errno.ETIMEDOUT + } + } +} + +// Go side data of pthread_mutex_t +type mutex struct { + sync.Mutex + typ int // PTHREAD_MUTEX_NORMAL, ... + wait sync.Mutex + + id int32 // owner's t.ID + cnt int32 + + robust bool +} + +func newMutex(typ int) *mutex { + return &mutex{ + typ: typ, + } +} + +func (m *mutex) lock(id int32) int32 { + if m.robust { + panic(todo("")) + } + + // If successful, the pthread_mutex_lock() and pthread_mutex_unlock() functions + // shall return zero; otherwise, an error number shall be returned to indicate + // the error. + switch m.typ { + default: + fallthrough + case pthread.PTHREAD_MUTEX_NORMAL: + // If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection shall not be + // provided. Attempting to relock the mutex causes deadlock. If a thread + // attempts to unlock a mutex that it has not locked or a mutex which is + // unlocked, undefined behavior results. + m.Lock() + m.id = id + return 0 + case pthread.PTHREAD_MUTEX_RECURSIVE: + for { + m.Lock() + switch m.id { + case 0: + m.cnt = 1 + m.id = id + m.wait.Lock() + m.Unlock() + return 0 + case id: + m.cnt++ + m.Unlock() + return 0 + } + + m.Unlock() + m.wait.Lock() + // intentional empty section - wake up other waiters + m.wait.Unlock() + } + } +} + +func (m *mutex) tryLock(id int32) int32 { + if m.robust { + panic(todo("")) + } + + switch m.typ { + default: + fallthrough + case pthread.PTHREAD_MUTEX_NORMAL: + return errno.EBUSY + case pthread.PTHREAD_MUTEX_RECURSIVE: + m.Lock() + switch m.id { + case 0: + m.cnt = 1 + m.id = id + m.wait.Lock() + m.Unlock() + return 0 + case id: + m.cnt++ + m.Unlock() + return 0 + } + + m.Unlock() + return errno.EBUSY + } +} + +func (m *mutex) unlock() int32 { + if m.robust { + panic(todo("")) + } + + // If successful, the pthread_mutex_lock() and pthread_mutex_unlock() functions + // shall return zero; otherwise, an error number shall be returned to indicate + // the error. + switch m.typ { + default: + fallthrough + case pthread.PTHREAD_MUTEX_NORMAL: + // If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection shall not be + // provided. Attempting to relock the mutex causes deadlock. If a thread + // attempts to unlock a mutex that it has not locked or a mutex which is + // unlocked, undefined behavior results. + m.id = 0 + m.Unlock() + return 0 + case pthread.PTHREAD_MUTEX_RECURSIVE: + m.Lock() + m.cnt-- + if m.cnt == 0 { + m.id = 0 + m.wait.Unlock() + } + m.Unlock() + return 0 + } +} + +// int pthread_mutex_destroy(pthread_mutex_t *mutex); +func Xpthread_mutex_destroy(t *TLS, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } + mutexesMu.Lock() + + defer mutexesMu.Unlock() + + delete(mutexes, pMutex) + return 0 +} + +// int pthread_mutex_lock(pthread_mutex_t *mutex); +func Xpthread_mutex_lock(t *TLS, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } + mutexesMu.Lock() + mu := mutexes[pMutex] + if mu == nil { // static initialized mutexes are valid + mu = newMutex(int(X__ccgo_getMutexType(t, pMutex))) + mutexes[pMutex] = mu + } + mutexesMu.Unlock() + return mu.lock(t.ID) +} + +// int pthread_mutex_trylock(pthread_mutex_t *mutex); +func Xpthread_mutex_trylock(t *TLS, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } + mutexesMu.Lock() + mu := mutexes[pMutex] + if mu == nil { // static initialized mutexes are valid + mu = newMutex(int(X__ccgo_getMutexType(t, pMutex))) + mutexes[pMutex] = mu + } + mutexesMu.Unlock() + return mu.tryLock(t.ID) +} + +// int pthread_mutex_unlock(pthread_mutex_t *mutex); +func Xpthread_mutex_unlock(t *TLS, pMutex uintptr) int32 { + if __ccgo_strace { + trc("t=%v pMutex=%v, (%v:)", t, pMutex, origin(2)) + } + mutexesMu.Lock() + + defer mutexesMu.Unlock() + + return mutexes[pMutex].unlock() +} + +// int pthread_key_create(pthread_key_t *key, void (*destructor)(void*)); +func Xpthread_key_create(t *TLS, pKey, destructor uintptr) int32 { + threadsKeysMu.Lock() + + defer threadsKeysMu.Unlock() + + threadKey++ + r := threadKey + if destructor != 0 { + threadKeyDestructors[r] = append(threadKeyDestructors[r], destructor) + } + *(*pthread.Pthread_key_t)(unsafe.Pointer(pKey)) = pthread.Pthread_key_t(r) + return 0 +} + +// int pthread_key_delete(pthread_key_t key); +func Xpthread_key_delete(t *TLS, key pthread.Pthread_key_t) int32 { + if __ccgo_strace { + trc("t=%v key=%v, (%v:)", t, key, origin(2)) + } + if _, ok := t.kv[key]; ok { + delete(t.kv, key) + return 0 + } + + panic(todo("")) + +} + +// void *pthread_getspecific(pthread_key_t key); +func Xpthread_getspecific(t *TLS, key pthread.Pthread_key_t) uintptr { + if __ccgo_strace { + trc("t=%v key=%v, (%v:)", t, key, origin(2)) + } + return t.kv[key] +} + +// int pthread_setspecific(pthread_key_t key, const void *value); +func Xpthread_setspecific(t *TLS, key pthread.Pthread_key_t, value uintptr) int32 { + if __ccgo_strace { + trc("t=%v key=%v value=%v, (%v:)", t, key, value, origin(2)) + } + if t.kv == nil { + t.kv = map[pthread.Pthread_key_t]uintptr{} + } + t.kv[key] = value + return 0 +} + +// int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); +func Xpthread_create(t *TLS, pThread, pAttr, startRoutine, arg uintptr) int32 { + if __ccgo_strace { + trc("t=%v arg=%v, (%v:)", t, arg, origin(2)) + } + fn := (*struct { + f func(*TLS, uintptr) uintptr + })(unsafe.Pointer(&struct{ uintptr }{startRoutine})).f + detached := pAttr != 0 && X__ccgo_pthreadAttrGetDetachState(t, pAttr) == pthread.PTHREAD_CREATE_DETACHED + tls := newTLS(detached) + *(*pthread.Pthread_t)(unsafe.Pointer(pThread)) = pthread.Pthread_t(tls.ID) + + go func() { + Xpthread_exit(tls, fn(tls, arg)) + }() + + return 0 +} + +// int pthread_detach(pthread_t thread); +func Xpthread_detach(t *TLS, thread pthread.Pthread_t) int32 { + if __ccgo_strace { + trc("t=%v thread=%v, (%v:)", t, thread, origin(2)) + } + threadsMu.Lock() + tls := threads[int32(thread)] + if tls == nil { + threadsMu.Unlock() + return errno.ESRCH + } + tls.detached = true + threadsMu.Unlock() + return 0 +} + +// int pthread_equal(pthread_t t1, pthread_t t2); +func Xpthread_equal(t *TLS, t1, t2 pthread.Pthread_t) int32 { + if __ccgo_strace { + trc("t=%v t2=%v, (%v:)", t, t2, origin(2)) + } + return Bool32(t1 == t2) +} + +// void pthread_exit(void *value_ptr); +func Xpthread_exit(t *TLS, value uintptr) { + if __ccgo_strace { + trc("t=%v value=%v, (%v:)", t, value, origin(2)) + } + t.retVal = value + + // At thread exit, if a key value has a non-NULL destructor pointer, and the + // thread has a non-NULL value associated with that key, the value of the key + // is set to NULL, and then the function pointed to is called with the + // previously associated value as its sole argument. The order of destructor + // calls is unspecified if more than one destructor exists for a thread when it + // exits. + for k, v := range t.kv { + if v == 0 { + continue + } + + threadsKeysMu.Lock() + destructors := threadKeyDestructors[k] + threadsKeysMu.Unlock() + + for _, destructor := range destructors { + delete(t.kv, k) + panic(todo("%#x", destructor)) //TODO call destructor(v) + } + } + + switch { + case t.detached: + threadsMu.Lock() + delete(threads, t.ID) + threadsMu.Unlock() + default: + close(t.done) + } + runtime.Goexit() +} + +// int pthread_join(pthread_t thread, void **value_ptr); +func Xpthread_join(t *TLS, thread pthread.Pthread_t, pValue uintptr) int32 { + if __ccgo_strace { + trc("t=%v thread=%v pValue=%v, (%v:)", t, thread, pValue, origin(2)) + } + threadsMu.Lock() + tls := threads[int32(thread)] + if tls == nil { + threadsMu.Unlock() + return errno.ESRCH + } + delete(threads, int32(thread)) + threadsMu.Unlock() + <-tls.done + if pValue != 0 { + *(*uintptr)(unsafe.Pointer(pValue)) = tls.retVal + } + return 0 +} + +// pthread_t pthread_self(void); +func Xpthread_self(t *TLS) pthread.Pthread_t { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + return pthread.Pthread_t(t.ID) +} diff --git a/internal/libc/pthread/capi_darwin_amd64.go b/internal/libc/pthread/capi_darwin_amd64.go new file mode 100644 index 0000000..ca2b6e0 --- /dev/null +++ b/internal/libc/pthread/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo pthread/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pthread/pthread_darwin_amd64.go -pkgname pthread', DO NOT EDIT. + +package pthread + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/pthread/capi_darwin_arm64.go b/internal/libc/pthread/capi_darwin_arm64.go new file mode 100644 index 0000000..e1e2a70 --- /dev/null +++ b/internal/libc/pthread/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo pthread/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pthread/pthread_darwin_arm64.go -pkgname pthread', DO NOT EDIT. + +package pthread + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/pthread/capi_linux_amd64.go b/internal/libc/pthread/capi_linux_amd64.go new file mode 100644 index 0000000..fd760fd --- /dev/null +++ b/internal/libc/pthread/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo pthread/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pthread/pthread_linux_amd64.go -pkgname pthread', DO NOT EDIT. + +package pthread + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/pthread/capi_linux_arm64.go b/internal/libc/pthread/capi_linux_arm64.go new file mode 100644 index 0000000..2569731 --- /dev/null +++ b/internal/libc/pthread/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo pthread/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o pthread/pthread_linux_arm64.go -pkgname pthread', DO NOT EDIT. + +package pthread + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/pthread/pthread_darwin_amd64.go b/internal/libc/pthread/pthread_darwin_amd64.go new file mode 100644 index 0000000..a2bba4a --- /dev/null +++ b/internal/libc/pthread/pthread_darwin_amd64.go @@ -0,0 +1,3062 @@ +// Code generated by 'ccgo pthread/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pthread/pthread_darwin_amd64.go -pkgname pthread', DO NOT EDIT. + +package pthread + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + CLOCKS_PER_SEC = 1000000 // time.h:90:1: + PTHREAD_CANCEL_ASYNCHRONOUS = 0x00 // pthread.h:147:1: + PTHREAD_CANCEL_DEFERRED = 0x02 // pthread.h:146:1: + PTHREAD_CANCEL_DISABLE = 0x00 // pthread.h:145:1: + PTHREAD_CANCEL_ENABLE = 0x01 // pthread.h:144:1: + PTHREAD_CREATE_DETACHED = 2 // pthread.h:139:1: + PTHREAD_CREATE_JOINABLE = 1 // pthread.h:138:1: + PTHREAD_EXPLICIT_SCHED = 2 // pthread.h:142:1: + PTHREAD_INHERIT_SCHED = 1 // pthread.h:141:1: + PTHREAD_MUTEX_DEFAULT = 0 // pthread.h:172:1: + PTHREAD_MUTEX_ERRORCHECK = 1 // pthread.h:170:1: + PTHREAD_MUTEX_NORMAL = 0 // pthread.h:169:1: + PTHREAD_MUTEX_POLICY_FAIRSHARE_NP = 1 // pthread.h:177:1: + PTHREAD_MUTEX_POLICY_FIRSTFIT_NP = 3 // pthread.h:178:1: + PTHREAD_MUTEX_RECURSIVE = 2 // pthread.h:171:1: + PTHREAD_PRIO_INHERIT = 1 // pthread.h:163:1: + PTHREAD_PRIO_NONE = 0 // pthread.h:162:1: + PTHREAD_PRIO_PROTECT = 2 // pthread.h:164:1: + PTHREAD_PROCESS_PRIVATE = 2 // pthread.h:157:1: + PTHREAD_PROCESS_SHARED = 1 // pthread.h:156:1: + PTHREAD_SCOPE_PROCESS = 2 // pthread.h:154:1: + PTHREAD_SCOPE_SYSTEM = 1 // pthread.h:153:1: + QOS_MIN_RELATIVE_PRIORITY = -15 // qos.h:153:1: + SCHED_FIFO = 4 // pthread_impl.h:55:1: + SCHED_OTHER = 1 // pthread_impl.h:54:1: + SCHED_RR = 2 // pthread_impl.h:56:1: + TIME_UTC = 1 // time.h:197:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MACH_PORT_T = 0 // _mach_port_t.h:48:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_SIG_init = 0x3CB0B1BB // pthread_impl.h:47:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_ERRORCHECK_MUTEX_SIG_init = 0x32AAABA1 // pthread_impl.h:43:1: + X_PTHREAD_FIRSTFIT_MUTEX_SIG_init = 0x32AAABA3 // pthread_impl.h:45:1: + X_PTHREAD_H = 0 // pthread.h:53:1: + X_PTHREAD_IMPL_H_ = 0 // pthread_impl.h:25:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_SIG_init = 0x32AAABA7 // pthread_impl.h:41:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_SIG_init = 0x30B1BCBA // pthread_impl.h:48:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_QOS_H = 0 // qos.h:25:1: + X_PTHREAD_RECURSIVE_MUTEX_SIG_init = 0x32AAABA2 // pthread_impl.h:44:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_SIG_init = 0x2DA8B3B4 // pthread_impl.h:49:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_SCHED_H_ = 0 // sched.h:25:1: + X_SIGSET_T = 0 // _sigset_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS_QOS_H = 0 // qos.h:25:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_H_ = 0 // time.h:64:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +// Copyright (c) 2013-2014 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2013-2014 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// ! +// @typedef qos_class_t +// +// @abstract +// An abstract thread quality of service (QOS) classification. +// +// @discussion +// Thread quality of service (QOS) classes are ordered abstract representations +// of the nature of work that is expected to be performed by a pthread, dispatch +// queue, or NSOperation. Each class specifies a maximum thread scheduling +// priority for that band (which may be used in combination with a relative +// priority offset within the band), as well as quality of service +// characteristics for timer latency, CPU throughput, I/O throughput, network +// socket traffic management behavior and more. +// +// A best effort is made to allocate available system resources to every QOS +// class. Quality of service degredation only occurs during system resource +// contention, proportionally to the QOS class. That said, QOS classes +// representing user-initiated work attempt to achieve peak throughput while +// QOS classes for other work attempt to achieve peak energy and thermal +// efficiency, even in the absence of contention. Finally, the use of QOS +// classes does not allow threads to supersede any limits that may be applied +// to the overall process. + +// ! +// @constant QOS_CLASS_USER_INTERACTIVE +// @abstract A QOS class which indicates work performed by this thread +// is interactive with the user. +// @discussion Such work is requested to run at high priority relative to other +// work on the system. Specifying this QOS class is a request to run with +// nearly all available system CPU and I/O bandwidth even under contention. +// This is not an energy-efficient QOS class to use for large tasks. The use of +// this QOS class should be limited to critical interaction with the user such +// as handling events on the main event loop, view drawing, animation, etc. +// +// @constant QOS_CLASS_USER_INITIATED +// @abstract A QOS class which indicates work performed by this thread +// was initiated by the user and that the user is likely waiting for the +// results. +// @discussion Such work is requested to run at a priority below critical user- +// interactive work, but relatively higher than other work on the system. This +// is not an energy-efficient QOS class to use for large tasks. Its use +// should be limited to operations of short enough duration that the user is +// unlikely to switch tasks while waiting for the results. Typical +// user-initiated work will have progress indicated by the display of +// placeholder content or modal user interface. +// +// @constant QOS_CLASS_DEFAULT +// @abstract A default QOS class used by the system in cases where more specific +// QOS class information is not available. +// @discussion Such work is requested to run at a priority below critical user- +// interactive and user-initiated work, but relatively higher than utility and +// background tasks. Threads created by pthread_create() without an attribute +// specifying a QOS class will default to QOS_CLASS_DEFAULT. This QOS class +// value is not intended to be used as a work classification, it should only be +// set when propagating or restoring QOS class values provided by the system. +// +// @constant QOS_CLASS_UTILITY +// @abstract A QOS class which indicates work performed by this thread +// may or may not be initiated by the user and that the user is unlikely to be +// immediately waiting for the results. +// @discussion Such work is requested to run at a priority below critical user- +// interactive and user-initiated work, but relatively higher than low-level +// system maintenance tasks. The use of this QOS class indicates the work +// should be run in an energy and thermally-efficient manner. The progress of +// utility work may or may not be indicated to the user, but the effect of such +// work is user-visible. +// +// @constant QOS_CLASS_BACKGROUND +// @abstract A QOS class which indicates work performed by this thread was not +// initiated by the user and that the user may be unaware of the results. +// @discussion Such work is requested to run at a priority below other work. +// The use of this QOS class indicates the work should be run in the most energy +// and thermally-efficient manner. +// +// @constant QOS_CLASS_UNSPECIFIED +// @abstract A QOS class value which indicates the absence or removal of QOS +// class information. +// @discussion As an API return value, may indicate that threads or pthread +// attributes were configured with legacy API incompatible or in conflict with +// the QOS class system. + +const ( /* qos.h:130:1: */ + QOS_CLASS_USER_INTERACTIVE = 33 + QOS_CLASS_USER_INITIATED = 25 + QOS_CLASS_DEFAULT = 21 + QOS_CLASS_UTILITY = 17 + QOS_CLASS_BACKGROUND = 9 + QOS_CLASS_UNSPECIFIED = 0 +) + +const ( /* time.h:153:1: */ + X_CLOCK_REALTIME = 0 + X_CLOCK_MONOTONIC = 6 + X_CLOCK_MONOTONIC_RAW = 4 + X_CLOCK_MONOTONIC_RAW_APPROX = 5 + X_CLOCK_UPTIME_RAW = 8 + X_CLOCK_UPTIME_RAW_APPROX = 9 + X_CLOCK_PROCESS_CPUTIME_ID = 12 + X_CLOCK_THREAD_CPUTIME_ID = 16 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2012 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991 +// All Rights Reserved +// +// Permission to use, copy, modify, and distribute this software and +// its documentation for any purpose and without fee is hereby granted, +// provided that the above copyright notice appears in all copies and +// that both the copyright notice and this permission notice appear in +// supporting documentation. +// +// OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE +// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE. +// +// IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR +// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +// LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, +// NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +// WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// +// MkLinux + +// POSIX Threads - IEEE 1003.1c + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Internal implementation details + +// This whole header file will disappear, so don't depend on it... + +// [Internal] data structure signatures + +// POSIX scheduling policies + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Scheduling paramters +type Sched_param = struct { + Fsched_priority int32 + F__opaque [4]int8 +} /* sched.h:35:1 */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)time.h 8.3 (Berkeley) 1/21/94 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* time.h:75:1 */ + +type Clockid_t = uint32 /* time.h:172:3 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ +type Qos_class_t = uint32 /* qos.h:130:1 */ + +// ! +// @typedef pthread_override_t +// +// @abstract +// An opaque object representing a QOS class override of a thread. +// +// @discussion +// A QOS class override of a target thread expresses that an item of pending +// work classified with a specific QOS class and relative priority depends on +// the completion of the work currently being executed by the thread (e.g. due +// to ordering requirements). +// +// While overrides are in effect, the target thread will execute at the maximum +// QOS class and relative priority of all overrides and of the QOS class +// requested by the thread itself. +// +// A QOS class override does not modify the target thread's requested QOS class +// value and the effect of an override is not visible to the qos_class_self() +// and pthread_get_qos_class_np() interfaces. + +type Pthread_override_t = uintptr /* qos.h:211:34 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// mach_port_t - a named port right +// +// In user-space, "rights" are represented by the name of the +// right in the Mach port namespace. Even so, this type is +// presented as a unique one to more clearly denote the presence +// of a right coming along with the name. +// +// Often, various rights for a port held in a single name space +// will coalesce and are, therefore, be identified by a single name +// [this is the case for send and receive rights]. But not +// always [send-once rights currently get a unique name for +// each right]. +// +// This definition of mach_port_t is only for user-space. +// + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mach_port_t = X__darwin_mach_port_t /* _mach_port_t.h:50:30 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Sigset_t = X__darwin_sigset_t /* _sigset_t.h:31:41 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/pthread/pthread_darwin_arm64.go b/internal/libc/pthread/pthread_darwin_arm64.go new file mode 100644 index 0000000..4156cff --- /dev/null +++ b/internal/libc/pthread/pthread_darwin_arm64.go @@ -0,0 +1,3068 @@ +// Code generated by 'ccgo pthread/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pthread/pthread_darwin_arm64.go -pkgname pthread', DO NOT EDIT. + +package pthread + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + PTHREAD_CANCEL_ASYNCHRONOUS = 0x00 // pthread.h:144:1: + PTHREAD_CANCEL_DEFERRED = 0x02 // pthread.h:143:1: + PTHREAD_CANCEL_DISABLE = 0x00 // pthread.h:142:1: + PTHREAD_CANCEL_ENABLE = 0x01 // pthread.h:141:1: + PTHREAD_CREATE_DETACHED = 2 // pthread.h:136:1: + PTHREAD_CREATE_JOINABLE = 1 // pthread.h:135:1: + PTHREAD_EXPLICIT_SCHED = 2 // pthread.h:139:1: + PTHREAD_INHERIT_SCHED = 1 // pthread.h:138:1: + PTHREAD_MUTEX_DEFAULT = 0 // pthread.h:169:1: + PTHREAD_MUTEX_ERRORCHECK = 1 // pthread.h:167:1: + PTHREAD_MUTEX_NORMAL = 0 // pthread.h:166:1: + PTHREAD_MUTEX_POLICY_FAIRSHARE_NP = 1 // pthread.h:174:1: + PTHREAD_MUTEX_POLICY_FIRSTFIT_NP = 3 // pthread.h:175:1: + PTHREAD_MUTEX_RECURSIVE = 2 // pthread.h:168:1: + PTHREAD_PRIO_INHERIT = 1 // pthread.h:160:1: + PTHREAD_PRIO_NONE = 0 // pthread.h:159:1: + PTHREAD_PRIO_PROTECT = 2 // pthread.h:161:1: + PTHREAD_PROCESS_PRIVATE = 2 // pthread.h:154:1: + PTHREAD_PROCESS_SHARED = 1 // pthread.h:153:1: + PTHREAD_SCOPE_PROCESS = 2 // pthread.h:151:1: + PTHREAD_SCOPE_SYSTEM = 1 // pthread.h:150:1: + QOS_MIN_RELATIVE_PRIORITY = -15 // qos.h:153:1: + SCHED_FIFO = 4 // pthread_impl.h:55:1: + SCHED_OTHER = 1 // pthread_impl.h:54:1: + SCHED_RR = 2 // pthread_impl.h:56:1: + TIME_UTC = 1 // time.h:197:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MACH_PORT_T = 0 // _mach_port_t.h:48:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_SIG_init = 0x3CB0B1BB // pthread_impl.h:47:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_ERRORCHECK_MUTEX_SIG_init = 0x32AAABA1 // pthread_impl.h:43:1: + X_PTHREAD_FIRSTFIT_MUTEX_SIG_init = 0x32AAABA3 // pthread_impl.h:45:1: + X_PTHREAD_H = 0 // pthread.h:53:1: + X_PTHREAD_IMPL_H_ = 0 // pthread_impl.h:25:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_SIG_init = 0x32AAABA7 // pthread_impl.h:41:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_SIG_init = 0x30B1BCBA // pthread_impl.h:48:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_QOS_H = 0 // qos.h:25:1: + X_PTHREAD_RECURSIVE_MUTEX_SIG_init = 0x32AAABA2 // pthread_impl.h:44:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_SIG_init = 0x2DA8B3B4 // pthread_impl.h:49:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_SCHED_H_ = 0 // sched.h:25:1: + X_SIGSET_T = 0 // _sigset_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS_QOS_H = 0 // qos.h:25:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_H_ = 0 // time.h:64:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +// Copyright (c) 2013-2014 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2013-2014 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// ! +// @typedef qos_class_t +// +// @abstract +// An abstract thread quality of service (QOS) classification. +// +// @discussion +// Thread quality of service (QOS) classes are ordered abstract representations +// of the nature of work that is expected to be performed by a pthread, dispatch +// queue, or NSOperation. Each class specifies a maximum thread scheduling +// priority for that band (which may be used in combination with a relative +// priority offset within the band), as well as quality of service +// characteristics for timer latency, CPU throughput, I/O throughput, network +// socket traffic management behavior and more. +// +// A best effort is made to allocate available system resources to every QOS +// class. Quality of service degredation only occurs during system resource +// contention, proportionally to the QOS class. That said, QOS classes +// representing user-initiated work attempt to achieve peak throughput while +// QOS classes for other work attempt to achieve peak energy and thermal +// efficiency, even in the absence of contention. Finally, the use of QOS +// classes does not allow threads to supersede any limits that may be applied +// to the overall process. + +// ! +// @constant QOS_CLASS_USER_INTERACTIVE +// @abstract A QOS class which indicates work performed by this thread +// is interactive with the user. +// @discussion Such work is requested to run at high priority relative to other +// work on the system. Specifying this QOS class is a request to run with +// nearly all available system CPU and I/O bandwidth even under contention. +// This is not an energy-efficient QOS class to use for large tasks. The use of +// this QOS class should be limited to critical interaction with the user such +// as handling events on the main event loop, view drawing, animation, etc. +// +// @constant QOS_CLASS_USER_INITIATED +// @abstract A QOS class which indicates work performed by this thread +// was initiated by the user and that the user is likely waiting for the +// results. +// @discussion Such work is requested to run at a priority below critical user- +// interactive work, but relatively higher than other work on the system. This +// is not an energy-efficient QOS class to use for large tasks. Its use +// should be limited to operations of short enough duration that the user is +// unlikely to switch tasks while waiting for the results. Typical +// user-initiated work will have progress indicated by the display of +// placeholder content or modal user interface. +// +// @constant QOS_CLASS_DEFAULT +// @abstract A default QOS class used by the system in cases where more specific +// QOS class information is not available. +// @discussion Such work is requested to run at a priority below critical user- +// interactive and user-initiated work, but relatively higher than utility and +// background tasks. Threads created by pthread_create() without an attribute +// specifying a QOS class will default to QOS_CLASS_DEFAULT. This QOS class +// value is not intended to be used as a work classification, it should only be +// set when propagating or restoring QOS class values provided by the system. +// +// @constant QOS_CLASS_UTILITY +// @abstract A QOS class which indicates work performed by this thread +// may or may not be initiated by the user and that the user is unlikely to be +// immediately waiting for the results. +// @discussion Such work is requested to run at a priority below critical user- +// interactive and user-initiated work, but relatively higher than low-level +// system maintenance tasks. The use of this QOS class indicates the work +// should be run in an energy and thermally-efficient manner. The progress of +// utility work may or may not be indicated to the user, but the effect of such +// work is user-visible. +// +// @constant QOS_CLASS_BACKGROUND +// @abstract A QOS class which indicates work performed by this thread was not +// initiated by the user and that the user may be unaware of the results. +// @discussion Such work is requested to run at a priority below other work. +// The use of this QOS class indicates the work should be run in the most energy +// and thermally-efficient manner. +// +// @constant QOS_CLASS_UNSPECIFIED +// @abstract A QOS class value which indicates the absence or removal of QOS +// class information. +// @discussion As an API return value, may indicate that threads or pthread +// attributes were configured with legacy API incompatible or in conflict with +// the QOS class system. + +const ( /* qos.h:130:1: */ + QOS_CLASS_USER_INTERACTIVE = 33 + QOS_CLASS_USER_INITIATED = 25 + QOS_CLASS_DEFAULT = 21 + QOS_CLASS_UTILITY = 17 + QOS_CLASS_BACKGROUND = 9 + QOS_CLASS_UNSPECIFIED = 0 +) + +const ( /* time.h:153:1: */ + X_CLOCK_REALTIME = 0 + X_CLOCK_MONOTONIC = 6 + X_CLOCK_MONOTONIC_RAW = 4 + X_CLOCK_MONOTONIC_RAW_APPROX = 5 + X_CLOCK_UPTIME_RAW = 8 + X_CLOCK_UPTIME_RAW_APPROX = 9 + X_CLOCK_PROCESS_CPUTIME_ID = 12 + X_CLOCK_THREAD_CPUTIME_ID = 16 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2012 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991 +// All Rights Reserved +// +// Permission to use, copy, modify, and distribute this software and +// its documentation for any purpose and without fee is hereby granted, +// provided that the above copyright notice appears in all copies and +// that both the copyright notice and this permission notice appear in +// supporting documentation. +// +// OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE +// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE. +// +// IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR +// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +// LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, +// NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +// WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// +// MkLinux + +// POSIX Threads - IEEE 1003.1c + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Internal implementation details + +// This whole header file will disappear, so don't depend on it... + +// [Internal] data structure signatures + +// POSIX scheduling policies + +// Scheduling paramters +type Sched_param = struct { + Fsched_priority int32 + F__opaque [4]int8 +} /* sched.h:35:1 */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)time.h 8.3 (Berkeley) 1/21/94 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* time.h:75:1 */ + +type Clockid_t = uint32 /* time.h:172:3 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ +type Qos_class_t = uint32 /* qos.h:130:1 */ + +// ! +// @typedef pthread_override_t +// +// @abstract +// An opaque object representing a QOS class override of a thread. +// +// @discussion +// A QOS class override of a target thread expresses that an item of pending +// work classified with a specific QOS class and relative priority depends on +// the completion of the work currently being executed by the thread (e.g. due +// to ordering requirements). +// +// While overrides are in effect, the target thread will execute at the maximum +// QOS class and relative priority of all overrides and of the QOS class +// requested by the thread itself. +// +// A QOS class override does not modify the target thread's requested QOS class +// value and the effect of an override is not visible to the qos_class_self() +// and pthread_get_qos_class_np() interfaces. + +type Pthread_override_t = uintptr /* qos.h:211:34 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// mach_port_t - a named port right +// +// In user-space, "rights" are represented by the name of the +// right in the Mach port namespace. Even so, this type is +// presented as a unique one to more clearly denote the presence +// of a right coming along with the name. +// +// Often, various rights for a port held in a single name space +// will coalesce and are, therefore, be identified by a single name +// [this is the case for send and receive rights]. But not +// always [send-once rights currently get a unique name for +// each right]. +// +// This definition of mach_port_t is only for user-space. +// + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mach_port_t = X__darwin_mach_port_t /* _mach_port_t.h:50:30 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Sigset_t = X__darwin_sigset_t /* _sigset_t.h:31:41 */ + +// ! +// @typedef pthread_jit_write_callback_t +// The type of a function that can be supplied to {@link +// pthread_jit_write_with_callback_np} to write to the MAP_JIT region while it +// is writeable. +// +// @param ctx +// A pointer to context that will be passed through to the callback function. +// +// @result +// A result code to be returned to the caller of @{link +// pthread_jit_write_with_callback_np}. The system does not interpret/act on +// the value of this result. +type Pthread_jit_write_callback_t = uintptr /* pthread.h:581:13 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/pthread/pthread_linux_amd64.go b/internal/libc/pthread/pthread_linux_amd64.go new file mode 100644 index 0000000..767efe7 --- /dev/null +++ b/internal/libc/pthread/pthread_linux_amd64.go @@ -0,0 +1,1873 @@ +// Code generated by 'ccgo pthread/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pthread/pthread_linux_amd64.go -pkgname pthread', DO NOT EDIT. + +package pthread + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + CLOCK_BOOTTIME = 7 // time.h:60:1: + CLOCK_BOOTTIME_ALARM = 9 // time.h:64:1: + CLOCK_MONOTONIC = 1 // time.h:48:1: + CLOCK_MONOTONIC_COARSE = 6 // time.h:58:1: + CLOCK_MONOTONIC_RAW = 4 // time.h:54:1: + CLOCK_PROCESS_CPUTIME_ID = 2 // time.h:50:1: + CLOCK_REALTIME = 0 // time.h:46:1: + CLOCK_REALTIME_ALARM = 8 // time.h:62:1: + CLOCK_REALTIME_COARSE = 5 // time.h:56:1: + CLOCK_TAI = 11 // time.h:66:1: + CLOCK_THREAD_CPUTIME_ID = 3 // time.h:52:1: + PTHREAD_BARRIER_SERIAL_THREAD = -1 // pthread.h:189:1: + PTHREAD_ONCE_INIT = 0 // pthread.h:182:1: + SCHED_FIFO = 1 // sched.h:29:1: + SCHED_OTHER = 0 // sched.h:28:1: + SCHED_RR = 2 // sched.h:30:1: + TIMER_ABSTIME = 1 // time.h:69:1: + TIME_UTC = 1 // time.h:65:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_CPU_SET_H = 1 // cpu-set.h:21:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_SCHED_H = 1 // sched.h:21:1: + X_BITS_SETJMP_H = 1 // setjmp.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TIME_H = 1 // time.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_TYPES_LOCALE_T_H = 1 // locale_t.h:20:1: + X_BITS_TYPES_STRUCT_SCHED_PARAM = 1 // struct_sched_param.h:20:1: + X_BITS_TYPES___LOCALE_T_H = 1 // __locale_t.h:21:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_PTHREAD_H = 1 // pthread.h:19:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SCHED_H = 1 // sched.h:20:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_TIME_H = 1 // time.h:23:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// Read-write lock types. +const ( /* pthread.h:100:1: */ + PTHREAD_RWLOCK_PREFER_READER_NP = 0 + PTHREAD_RWLOCK_PREFER_WRITER_NP = 1 + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP = 2 + PTHREAD_RWLOCK_DEFAULT_NP = 0 +) + +// Read-write lock initializers. + +// Scheduler inheritance. +const ( /* pthread.h:120:1: */ + PTHREAD_INHERIT_SCHED = 0 + PTHREAD_EXPLICIT_SCHED = 1 +) + +// Scope handling. +const ( /* pthread.h:130:1: */ + PTHREAD_SCOPE_SYSTEM = 0 + PTHREAD_SCOPE_PROCESS = 1 +) + +// Process shared or private flag. +const ( /* pthread.h:140:1: */ + PTHREAD_PROCESS_PRIVATE = 0 + PTHREAD_PROCESS_SHARED = 1 +) + +// Cancellation +const ( /* pthread.h:164:1: */ + PTHREAD_CANCEL_ENABLE = 0 + PTHREAD_CANCEL_DISABLE = 1 +) +const ( /* pthread.h:171:1: */ + PTHREAD_CANCEL_DEFERRED = 0 + PTHREAD_CANCEL_ASYNCHRONOUS = 1 +) + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// NB: Include guard matches what uses. + +// Detach state. +const ( /* pthread.h:33:1: */ + PTHREAD_CREATE_JOINABLE = 0 + PTHREAD_CREATE_DETACHED = 1 +) + +// Mutex types. +const ( /* pthread.h:43:1: */ + PTHREAD_MUTEX_TIMED_NP = 0 + PTHREAD_MUTEX_RECURSIVE_NP = 1 + PTHREAD_MUTEX_ERRORCHECK_NP = 2 + PTHREAD_MUTEX_ADAPTIVE_NP = 3 + PTHREAD_MUTEX_NORMAL = 0 + PTHREAD_MUTEX_RECURSIVE = 1 + PTHREAD_MUTEX_ERRORCHECK = 2 + PTHREAD_MUTEX_DEFAULT = 0 +) + +// Robust mutex or not flags. +const ( /* pthread.h:65:1: */ + PTHREAD_MUTEX_STALLED = 0 + PTHREAD_MUTEX_STALLED_NP = 0 + PTHREAD_MUTEX_ROBUST = 1 + PTHREAD_MUTEX_ROBUST_NP = 1 +) + +// Mutex protocols. +const ( /* pthread.h:77:1: */ + PTHREAD_PRIO_NONE = 0 + PTHREAD_PRIO_INHERIT = 1 + PTHREAD_PRIO_PROTECT = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get type definitions. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// i386/x86_64 are little-endian. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Pid_t = X__pid_t /* sched.h:38:17 */ + +// Get system specific constant and data structure definitions. +// Definitions of constants and data structure for POSIX 1003.1b-1993 +// scheduling interface. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Scheduling algorithms. + +// Sched parameter structure. Generic version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Data structure to describe a process' schedulability. +type Sched_param = struct{ Fsched_priority int32 } /* struct_sched_param.h:23:1 */ + +// Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993 +// scheduling interface. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size definition for CPU sets. + +// Type for array elements in 'cpu_set_t'. +type X__cpu_mask = uint64 /* cpu-set.h:32:25 */ + +// Basic access functions. + +// Data structure to describe CPU mask. +type Cpu_set_t = struct{ F__bits [16]X__cpu_mask } /* cpu-set.h:42:3 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.23 Date and time + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This defines CLOCKS_PER_SEC, which is the number of processor clock +// ticks per second, and possibly a number of other constants. +// System-dependent timing definitions. Linux version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO/IEC 9899:1999 7.23.1: Components of time +// The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is +// the number per second of the value returned by the `clock' function. +// CAE XSH, Issue 4, Version 2: +// The value of CLOCKS_PER_SEC is required to be 1 million on all +// XSI-conformant systems. + +// Identifier for system-wide realtime clock. +// Monotonic system-wide clock. +// High-resolution timer from the CPU. +// Thread-specific CPU-time clock. +// Monotonic system-wide clock, not adjusted for frequency scaling. +// Identifier for system-wide realtime clock, updated only on ticks. +// Monotonic system-wide clock, updated only on ticks. +// Monotonic system-wide clock that includes time spent in suspension. +// Like CLOCK_REALTIME but also wakes suspended system. +// Like CLOCK_BOOTTIME but also wakes suspended system. +// Like CLOCK_REALTIME but in International Atomic Time. + +// Flag to indicate time is absolute. + +// Many of the typedefs and structs whose official home is this header +// may also need to be defined by other headers. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO C `broken-down time' structure. +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* struct_tm.h:7:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// NB: Include guard matches what uses. + +// POSIX.1b structure for timer start values and intervals. +type Itimerspec = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } +} /* struct_itimerspec.h:8:1 */ + +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define the machine-dependent type `jmp_buf'. x86-64 version. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +type X__jmp_buf = [8]int64 /* setjmp.h:31:18 */ + +// Conditional variable handling. + +// Cleanup buffers +type X_pthread_cleanup_buffer = struct { + F__routine uintptr + F__arg uintptr + F__canceltype int32 + F__ccgo_pad1 [4]byte + F__prev uintptr +} /* pthread.h:155:1 */ + +// Cancellation handling with integration into exception handling. + +type X__pthread_unwind_buf_t = struct { + F__cancel_jmp_buf [1]struct { + F__cancel_jmp_buf X__jmp_buf + F__mask_was_saved int32 + F__ccgo_pad1 [4]byte + } + F__pad [4]uintptr +} /* pthread.h:507:3 */ + +// No special attributes by default. + +// Structure to hold the cleanup handler information. +type X__pthread_cleanup_frame = struct { + F__cancel_routine uintptr + F__cancel_arg uintptr + F__do_it int32 + F__cancel_type int32 +} /* pthread.h:516:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/pthread/pthread_linux_arm64.go b/internal/libc/pthread/pthread_linux_arm64.go new file mode 100644 index 0000000..75da37c --- /dev/null +++ b/internal/libc/pthread/pthread_linux_arm64.go @@ -0,0 +1,1992 @@ +// Code generated by 'ccgo pthread/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o pthread/pthread_linux_arm64.go -pkgname pthread', DO NOT EDIT. + +package pthread + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + CLOCK_BOOTTIME = 7 + CLOCK_BOOTTIME_ALARM = 9 + CLOCK_MONOTONIC = 1 + CLOCK_MONOTONIC_COARSE = 6 + CLOCK_MONOTONIC_RAW = 4 + CLOCK_PROCESS_CPUTIME_ID = 2 + CLOCK_REALTIME = 0 + CLOCK_REALTIME_ALARM = 8 + CLOCK_REALTIME_COARSE = 5 + CLOCK_TAI = 11 + CLOCK_THREAD_CPUTIME_ID = 3 + PTHREAD_BARRIER_SERIAL_THREAD = -1 + PTHREAD_ONCE_INIT = 0 + SCHED_FIFO = 1 + SCHED_OTHER = 0 + SCHED_RR = 2 + TIMER_ABSTIME = 1 + TIME_UTC = 1 + X_ATFILE_SOURCE = 1 + X_BITS_CPU_SET_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_SCHED_H = 1 + X_BITS_SETJMP_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TIME_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_TYPES_LOCALE_T_H = 1 + X_BITS_TYPES_STRUCT_SCHED_PARAM = 1 + X_BITS_TYPES___LOCALE_T_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_PTHREAD_H = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SCHED_H = 1 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SIZE_T_H = 0 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_TIME_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +// Read-write lock types. +const ( /* pthread.h:100:1: */ + PTHREAD_RWLOCK_PREFER_READER_NP = 0 + PTHREAD_RWLOCK_PREFER_WRITER_NP = 1 + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP = 2 + PTHREAD_RWLOCK_DEFAULT_NP = 0 +) + +// Read-write lock initializers. + +// Scheduler inheritance. +const ( /* pthread.h:120:1: */ + PTHREAD_INHERIT_SCHED = 0 + PTHREAD_EXPLICIT_SCHED = 1 +) + +// Scope handling. +const ( /* pthread.h:130:1: */ + PTHREAD_SCOPE_SYSTEM = 0 + PTHREAD_SCOPE_PROCESS = 1 +) + +// Process shared or private flag. +const ( /* pthread.h:140:1: */ + PTHREAD_PROCESS_PRIVATE = 0 + PTHREAD_PROCESS_SHARED = 1 +) + +// Cancellation +const ( /* pthread.h:164:1: */ + PTHREAD_CANCEL_ENABLE = 0 + PTHREAD_CANCEL_DISABLE = 1 +) +const ( /* pthread.h:171:1: */ + PTHREAD_CANCEL_DEFERRED = 0 + PTHREAD_CANCEL_ASYNCHRONOUS = 1 +) + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// NB: Include guard matches what uses. + +// Detach state. +const ( /* pthread.h:33:1: */ + PTHREAD_CREATE_JOINABLE = 0 + PTHREAD_CREATE_DETACHED = 1 +) + +// Mutex types. +const ( /* pthread.h:43:1: */ + PTHREAD_MUTEX_TIMED_NP = 0 + PTHREAD_MUTEX_RECURSIVE_NP = 1 + PTHREAD_MUTEX_ERRORCHECK_NP = 2 + PTHREAD_MUTEX_ADAPTIVE_NP = 3 + PTHREAD_MUTEX_NORMAL = 0 + PTHREAD_MUTEX_RECURSIVE = 1 + PTHREAD_MUTEX_ERRORCHECK = 2 + PTHREAD_MUTEX_DEFAULT = 0 +) + +// Robust mutex or not flags. +const ( /* pthread.h:65:1: */ + PTHREAD_MUTEX_STALLED = 0 + PTHREAD_MUTEX_STALLED_NP = 0 + PTHREAD_MUTEX_ROBUST = 1 + PTHREAD_MUTEX_ROBUST_NP = 1 +) + +// Mutex protocols. +const ( /* pthread.h:77:1: */ + PTHREAD_PRIO_NONE = 0 + PTHREAD_PRIO_INHERIT = 1 + PTHREAD_PRIO_PROTECT = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get type definitions. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// AArch64 has selectable endianness. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Pid_t = X__pid_t /* sched.h:38:17 */ + +// Get system specific constant and data structure definitions. +// Definitions of constants and data structure for POSIX 1003.1b-1993 +// scheduling interface. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Scheduling algorithms. + +// Sched parameter structure. Generic version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Data structure to describe a process' schedulability. +type Sched_param = struct{ Fsched_priority int32 } /* struct_sched_param.h:23:1 */ + +// Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993 +// scheduling interface. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size definition for CPU sets. + +// Type for array elements in 'cpu_set_t'. +type X__cpu_mask = uint64 /* cpu-set.h:32:25 */ + +// Basic access functions. + +// Data structure to describe CPU mask. +type Cpu_set_t = struct{ F__bits [16]X__cpu_mask } /* cpu-set.h:42:3 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.23 Date and time + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This defines CLOCKS_PER_SEC, which is the number of processor clock +// ticks per second, and possibly a number of other constants. +// System-dependent timing definitions. Linux version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO/IEC 9899:1999 7.23.1: Components of time +// The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is +// the number per second of the value returned by the `clock' function. +// CAE XSH, Issue 4, Version 2: +// The value of CLOCKS_PER_SEC is required to be 1 million on all +// XSI-conformant systems. + +// Identifier for system-wide realtime clock. +// Monotonic system-wide clock. +// High-resolution timer from the CPU. +// Thread-specific CPU-time clock. +// Monotonic system-wide clock, not adjusted for frequency scaling. +// Identifier for system-wide realtime clock, updated only on ticks. +// Monotonic system-wide clock, updated only on ticks. +// Monotonic system-wide clock that includes time spent in suspension. +// Like CLOCK_REALTIME but also wakes suspended system. +// Like CLOCK_BOOTTIME but also wakes suspended system. +// Like CLOCK_REALTIME but in International Atomic Time. + +// Flag to indicate time is absolute. + +// Many of the typedefs and structs whose official home is this header +// may also need to be defined by other headers. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO C `broken-down time' structure. +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* struct_tm.h:7:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// NB: Include guard matches what uses. + +// POSIX.1b structure for timer start values and intervals. +type Itimerspec = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } +} /* struct_itimerspec.h:8:1 */ + +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Jump buffer contains: +// +// x19-x28, x29(fp), x30(lr), (x31)sp, d8-d15. Other registers are not +// saved. +type X__jmp_buf = [22]uint64 /* setjmp.h:30:42 */ + +// Conditional variable handling. + +// Cleanup buffers +type X_pthread_cleanup_buffer = struct { + F__routine uintptr + F__arg uintptr + F__canceltype int32 + F__ccgo_pad1 [4]byte + F__prev uintptr +} /* pthread.h:155:1 */ + +// Cancellation handling with integration into exception handling. + +type X__pthread_unwind_buf_t = struct { + F__cancel_jmp_buf [1]struct { + F__cancel_jmp_buf X__jmp_buf + F__mask_was_saved int32 + F__ccgo_pad1 [4]byte + } + F__pad [4]uintptr +} /* pthread.h:507:3 */ + +// No special attributes by default. + +// Structure to hold the cleanup handler information. +type X__pthread_cleanup_frame = struct { + F__cancel_routine uintptr + F__cancel_arg uintptr + F__do_it int32 + F__cancel_type int32 +} /* pthread.h:516:1 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/pthread_all.go b/internal/libc/pthread_all.go new file mode 100644 index 0000000..5384c42 --- /dev/null +++ b/internal/libc/pthread_all.go @@ -0,0 +1,64 @@ +// Copyright 2021 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !freebsd && !openbsd && !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "unsafe" + + "github.com/hanzoai/sqlite/internal/libc/pthread" +) + +type pthreadAttr struct { + detachState int32 +} + +// int pthread_attr_init(pthread_attr_t *attr); +func Xpthread_attr_init(t *TLS, pAttr uintptr) int32 { + if __ccgo_strace { + trc("t=%v pAttr=%v, (%v:)", t, pAttr, origin(2)) + } + *(*pthreadAttr)(unsafe.Pointer(pAttr)) = pthreadAttr{} + return 0 +} + +// The pthread_mutex_init() function shall initialize the mutex referenced by +// mutex with attributes specified by attr. If attr is NULL, the default mutex +// attributes are used; the effect shall be the same as passing the address of +// a default mutex attributes object. Upon successful initialization, the state +// of the mutex becomes initialized and unlocked. +// +// If successful, the pthread_mutex_destroy() and pthread_mutex_init() +// functions shall return zero; otherwise, an error number shall be returned to +// indicate the error. +// +// int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr); +func Xpthread_mutex_init(t *TLS, pMutex, pAttr uintptr) int32 { + if __ccgo_strace { + trc("t=%v pAttr=%v, (%v:)", t, pAttr, origin(2)) + } + typ := pthread.PTHREAD_MUTEX_DEFAULT + if pAttr != 0 { + typ = int(X__ccgo_pthreadMutexattrGettype(t, pAttr)) + } + mutexesMu.Lock() + + defer mutexesMu.Unlock() + + mutexes[pMutex] = newMutex(typ) + return 0 +} + +func Xpthread_atfork(tls *TLS, prepare, parent, child uintptr) int32 { + // fork(2) not supported. + return 0 +} + +// int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old) +func Xpthread_sigmask(tls *TLS, now int32, set, old uintptr) int32 { + // ignored + return 0 +} diff --git a/internal/libc/pthread_musl.go b/internal/libc/pthread_musl.go new file mode 100644 index 0000000..e85b8b5 --- /dev/null +++ b/internal/libc/pthread_musl.go @@ -0,0 +1,547 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "runtime" + "sync" + "sync/atomic" + "time" + "unsafe" +) + +type pthreadAttr struct { + detachState int32 +} + +type pthreadCleanupItem struct { + routine, arg uintptr +} + +// C original, unpatched version +// +// include/alltypes.h.in:86:TYPEDEF struct { +// union { +// int __i[sizeof(long)==8?10:6]; +// volatile int __vi[sizeof(long)==8?10:6]; +// volatile void *volatile __p[sizeof(long)==8?5:6]; +// } __u; +// } pthread_mutex_t; + +//TODO(jnml) can remove __ccgo_room patches now. + +// We overlay the C version with our version below. It must not be larger than +// the C version. +type pthreadMutex struct { // gc 64b 32b | tinygo 64b 32b + sync.Mutex // 0 8 0 4 | 0 16 0 8 + count int32 // 8 4 4 4 | 16 4 8 4 + typ uint32 // 12 4 8 4 | 20 4 12 4 + owner int32 // 16 4 12 4 | 24 4 16 4 + // 20 16 | 28 20 +} + +type pthreadConds struct { + sync.Mutex + conds map[uintptr][]chan struct{} +} + +var ( + // Ensure there's enough space for unsafe type conversions. + _ [unsafe.Sizeof(Tpthread_mutex_t{}) - unsafe.Sizeof(pthreadMutex{})]byte + _ [unsafe.Sizeof(Tpthread_attr_t{}) - unsafe.Sizeof(pthreadAttr{})]byte + + pthreadKeysMutex sync.Mutex + pthreadKeyDestructors []uintptr + pthreadKeysFree []Tpthread_key_t + + conds = pthreadConds{conds: map[uintptr][]chan struct{}{}} +) + +func _pthread_setcancelstate(tls *TLS, new int32, old uintptr) int32 { + //TODO actually respect cancel state + if uint32(new) > 2 { + return EINVAL + } + + p := tls.pthread + unsafe.Offsetof(t__pthread{}.Fcanceldisable) + if old != 0 { + r := *(*int32)(unsafe.Pointer(p)) + *(*int32)(unsafe.Pointer(old)) = int32(byte(r)) + } + *(*int32)(unsafe.Pointer(p)) = new + return 0 +} + +func Xpthread_getspecific(tls *TLS, k Tpthread_key_t) uintptr { + return tls.pthreadKeyValues[k] +} + +func Xpthread_setspecific(tls *TLS, k Tpthread_key_t, x uintptr) int32 { + if tls.pthreadKeyValues == nil { + tls.pthreadKeyValues = map[Tpthread_key_t]uintptr{} + } + tls.pthreadKeyValues[k] = x + return 0 +} + +func Xpthread_key_create(tls *TLS, k uintptr, dtor uintptr) int32 { + pthreadKeysMutex.Lock() + + defer pthreadKeysMutex.Unlock() + + var key Tpthread_key_t + switch l := Tpthread_key_t(len(pthreadKeysFree)); { + case l == 0: + key = Tpthread_key_t(len(pthreadKeyDestructors)) + pthreadKeyDestructors = append(pthreadKeyDestructors, dtor) + default: + key = pthreadKeysFree[l-1] + pthreadKeysFree = pthreadKeysFree[:l-1] + pthreadKeyDestructors[key] = dtor + } + *(*Tpthread_key_t)(unsafe.Pointer(k)) = key + return 0 +} + +func Xpthread_key_delete(tls *TLS, k Tpthread_key_t) int32 { + pthreadKeysMutex.Lock() + + defer pthreadKeysMutex.Unlock() + + pthreadKeysFree = append(pthreadKeysFree, k) + return 0 +} + +func Xpthread_create(tls *TLS, res, attrp, entry, arg uintptr) int32 { + var attr pthreadAttr + if attrp != 0 { + attr = *(*pthreadAttr)(unsafe.Pointer(attrp)) + } + + detachState := int32(_DT_JOINABLE) + if attr.detachState != 0 { + detachState = _DT_DETACHED + } + tls2 := NewTLS() + tls2.ownsPthread = false + *(*Tpthread_t)(unsafe.Pointer(res)) = tls2.pthread + (*t__pthread)(unsafe.Pointer(tls2.pthread)).Fdetach_state = detachState + if detachState == _DT_JOINABLE { + (*sync.Mutex)(unsafe.Pointer(tls2.pthread + unsafe.Offsetof(t__pthread{}.F__ccgo_join_mutex))).Lock() + } + + go func() { + Xpthread_exit(tls2, (*(*func(*TLS, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{entry})))(tls2, arg)) + }() + + return 0 +} + +func Xpthread_exit(tls *TLS, result uintptr) { + state := atomic.LoadInt32((*int32)(unsafe.Pointer(tls.pthread + unsafe.Offsetof(t__pthread{}.Fdetach_state)))) + (*t__pthread)(unsafe.Pointer(tls.pthread)).Fresult = result + switch state { + case _DT_JOINABLE, _DT_DETACHED: + // ok + default: + panic(todo("", state)) + } + + for len(tls.pthreadCleanupItems) != 0 { + Xpthread_cleanup_pop(tls, 1) + } + for { + done := true + for k, v := range tls.pthreadKeyValues { + if v != 0 { + delete(tls.pthreadKeyValues, k) + pthreadKeysMutex.Lock() + d := pthreadKeyDestructors[k] + pthreadKeysMutex.Unlock() + if d != 0 { + done = false + (*(*func(*TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{d})))(tls, v) + } + } + } + if done { + break + } + } + mu := (*sync.Mutex)(unsafe.Pointer(tls.pthread + unsafe.Offsetof(t__pthread{}.F__ccgo_join_mutex))) + mu.TryLock() + mu.Unlock() + atomic.StoreInt32((*int32)(unsafe.Pointer(tls.pthread+unsafe.Offsetof(t__pthread{}.Fdetach_state))), _DT_EXITED) + tls.Close() + runtime.Goexit() +} + +func Xpthread_join(tls *TLS, t Tpthread_t, res uintptr) (r int32) { + if (*t__pthread)(unsafe.Pointer(t)).Fdetach_state > _DT_JOINABLE { + return EINVAL + } + + (*sync.Mutex)(unsafe.Pointer(t + unsafe.Offsetof(t__pthread{}.F__ccgo_join_mutex))).Lock() + if res != 0 { + *(*uintptr)(unsafe.Pointer(res)) = (*t__pthread)(unsafe.Pointer(t)).Fresult + } + return 0 +} + +func Xpthread_cleanup_push(tls *TLS, f, x uintptr) { + X_pthread_cleanup_push(tls, 0, f, x) +} + +func __pthread_cleanup_push(tls *TLS, _, f, x uintptr) { + tls.pthreadCleanupItems = append(tls.pthreadCleanupItems, pthreadCleanupItem{f, x}) +} + +func X_pthread_cleanup_push(tls *TLS, _, f, x uintptr) { + tls.pthreadCleanupItems = append(tls.pthreadCleanupItems, pthreadCleanupItem{f, x}) +} + +func Xpthread_cleanup_pop(tls *TLS, run int32) { + X_pthread_cleanup_pop(tls, 0, run) +} + +func __pthread_cleanup_pop(tls *TLS, _ uintptr, run int32) { + X_pthread_cleanup_pop(tls, 0, run) +} + +func X_pthread_cleanup_pop(tls *TLS, _ uintptr, run int32) { + l := len(tls.pthreadCleanupItems) + item := tls.pthreadCleanupItems[l-1] + tls.pthreadCleanupItems = tls.pthreadCleanupItems[:l-1] + if run != 0 { + (*(*func(*TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{item.routine})))(tls, item.arg) + } +} + +func Xpthread_attr_init(tls *TLS, a uintptr) int32 { + *(*Tpthread_attr_t)(unsafe.Pointer(a)) = Tpthread_attr_t{} + return 0 +} + +func Xpthread_attr_setscope(tls *TLS, a uintptr, scope int32) int32 { + switch scope { + case PTHREAD_SCOPE_SYSTEM: + return 0 + case PTHREAD_SCOPE_PROCESS: + return ENOTSUP + default: + return EINVAL + } +} + +func Xpthread_attr_setstacksize(tls *TLS, a uintptr, stacksite Tsize_t) int32 { + return 0 +} + +func Xpthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) (r int32) { + if uint32(state) > 1 { + return EINVAL + } + + (*pthreadAttr)(unsafe.Pointer(a)).detachState = state + return 0 +} + +func Xpthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) int32 { + *(*int32)(unsafe.Pointer(state)) = (*pthreadAttr)(unsafe.Pointer(a)).detachState + return 0 +} + +func Xpthread_attr_destroy(tls *TLS, a uintptr) int32 { + return 0 +} + +func Xpthread_self(tls *TLS) uintptr { + return tls.pthread +} + +func Xpthread_mutex_init(tls *TLS, m, a uintptr) int32 { + *(*Tpthread_mutex_t)(unsafe.Pointer(m)) = Tpthread_mutex_t{} + if a != 0 { + (*pthreadMutex)(unsafe.Pointer(m)).typ = (*Tpthread_mutexattr_t)(unsafe.Pointer(a)).F__attr + } + return 0 +} + +func Xpthread_mutex_destroy(tls *TLS, m uintptr) int32 { + *(*Tpthread_mutex_t)(unsafe.Pointer(m)) = Tpthread_mutex_t{} + return 0 +} + +func Xpthread_mutex_lock(tls *TLS, m uintptr) int32 { + switch typ := (*pthreadMutex)(unsafe.Pointer(m)).typ; typ { + case PTHREAD_MUTEX_NORMAL: + (*pthreadMutex)(unsafe.Pointer(m)).Lock() + return 0 + case PTHREAD_MUTEX_RECURSIVE: + if atomic.CompareAndSwapInt32(&((*pthreadMutex)(unsafe.Pointer(m)).owner), 0, tls.ID) { + atomic.StoreInt32(&((*pthreadMutex)(unsafe.Pointer(m)).count), 1) + (*pthreadMutex)(unsafe.Pointer(m)).Lock() + return 0 + } + + if atomic.LoadInt32(&((*pthreadMutex)(unsafe.Pointer(m)).owner)) == tls.ID { + atomic.AddInt32(&((*pthreadMutex)(unsafe.Pointer(m)).count), 1) + return 0 + } + + for { + (*pthreadMutex)(unsafe.Pointer(m)).Lock() + if atomic.CompareAndSwapInt32(&((*pthreadMutex)(unsafe.Pointer(m)).owner), 0, tls.ID) { + atomic.StoreInt32(&((*pthreadMutex)(unsafe.Pointer(m)).count), 1) + return 0 + } + + (*pthreadMutex)(unsafe.Pointer(m)).Unlock() + } + default: + panic(todo("", typ)) + } +} + +func Xpthread_mutex_trylock(tls *TLS, m uintptr) int32 { + switch typ := (*pthreadMutex)(unsafe.Pointer(m)).typ; typ { + case PTHREAD_MUTEX_NORMAL: + if (*pthreadMutex)(unsafe.Pointer(m)).TryLock() { + return 0 + } + + return EBUSY + default: + panic(todo("typ=%v", typ)) + } +} + +func Xpthread_mutex_unlock(tls *TLS, m uintptr) int32 { + switch typ := (*pthreadMutex)(unsafe.Pointer(m)).typ; typ { + case PTHREAD_MUTEX_NORMAL: + (*pthreadMutex)(unsafe.Pointer(m)).Unlock() + return 0 + case PTHREAD_MUTEX_RECURSIVE: + if atomic.LoadInt32(&((*pthreadMutex)(unsafe.Pointer(m)).owner)) != tls.ID { + return EPERM + } + + if atomic.AddInt32(&((*pthreadMutex)(unsafe.Pointer(m)).count), -1) == 0 { + atomic.StoreInt32(&((*pthreadMutex)(unsafe.Pointer(m)).owner), 0) + (*pthreadMutex)(unsafe.Pointer(m)).Unlock() + } + return 0 + default: + panic(todo("", typ)) + } +} + +func Xpthread_cond_init(tls *TLS, c, a uintptr) int32 { + *(*Tpthread_cond_t)(unsafe.Pointer(c)) = Tpthread_cond_t{} + if a != 0 { + panic(todo("")) + } + + conds.Lock() + delete(conds.conds, c) + conds.Unlock() + return 0 +} + +func Xpthread_cond_timedwait(tls *TLS, c, m, ts uintptr) (r int32) { + var to <-chan time.Time + if ts != 0 { + deadlineSecs := (*Ttimespec)(unsafe.Pointer(ts)).Ftv_sec + deadlineNsecs := (*Ttimespec)(unsafe.Pointer(ts)).Ftv_nsec + deadline := time.Unix(deadlineSecs, int64(deadlineNsecs)) + d := deadline.Sub(time.Now()) + if d <= 0 { + return ETIMEDOUT + } + + to = time.After(d) + } + + conds.Lock() + waiters := conds.conds[c] + ch := make(chan struct{}, 1) + waiters = append(waiters, ch) + conds.conds[c] = waiters + conds.Unlock() + + defer func() { + conds.Lock() + + defer conds.Unlock() + + waiters = conds.conds[c] + for i, v := range waiters { + if v == ch { + conds.conds[c] = append(waiters[:i], waiters[i+1:]...) + return + } + } + }() + + switch typ := (*pthreadMutex)(unsafe.Pointer(m)).typ; typ { + case PTHREAD_MUTEX_NORMAL: + (*pthreadMutex)(unsafe.Pointer(m)).Unlock() + select { + case <-ch: + // ok + case <-to: + r = ETIMEDOUT + } + (*pthreadMutex)(unsafe.Pointer(m)).Lock() + return r + default: + panic(todo("", typ)) + } +} + +func Xpthread_cond_wait(tls *TLS, c, m uintptr) int32 { + return Xpthread_cond_timedwait(tls, c, m, 0) +} + +func Xpthread_cond_signal(tls *TLS, c uintptr) int32 { + return pthreadSignalN(tls, c, false) +} + +func pthreadSignalN(tls *TLS, c uintptr, all bool) int32 { + conds.Lock() + waiters := conds.conds[c] + handle := waiters + if len(waiters) != 0 { + switch { + case all: + delete(conds.conds, c) + default: + handle = handle[:1] + conds.conds[c] = waiters[1:] + } + } + conds.Unlock() + for _, v := range handle { + close(v) + } + return 0 +} + +func Xpthread_cond_broadcast(tls *TLS, c uintptr) int32 { + return pthreadSignalN(tls, c, true) +} + +func Xpthread_cond_destroy(tls *TLS, c uintptr) int32 { + return Xpthread_cond_broadcast(tls, c) +} + +func Xpthread_atfork(tls *TLS, prepare, parent, child uintptr) int32 { + // fork(2) not supported. + return 0 +} + +func Xpthread_mutexattr_init(tls *TLS, a uintptr) int32 { + *(*Tpthread_mutexattr_t)(unsafe.Pointer(a)) = Tpthread_mutexattr_t{} + return 0 +} + +func Xpthread_mutexattr_destroy(tls *TLS, a uintptr) int32 { + return 0 +} + +func Xpthread_mutexattr_settype(tls *TLS, a uintptr, typ int32) int32 { + if uint32(typ) > 2 { + return EINVAL + } + + (*Tpthread_mutexattr_t)(unsafe.Pointer(a)).F__attr = uint32(typ) & 3 + return 0 +} + +func Xpthread_detach(tls *TLS, t uintptr) int32 { + state := atomic.SwapInt32((*int32)(unsafe.Pointer(t+unsafe.Offsetof(t__pthread{}.Fdetach_state))), _DT_DETACHED) + switch state { + case _DT_JOINABLE, _DT_EXITED, _DT_DETACHED: + return 0 + default: + panic(todo("", tls.ID, state)) + } +} + +// int pthread_equal(pthread_t, pthread_t); +func Xpthread_equal(tls *TLS, t, u uintptr) int32 { + return Bool32(t == u) +} + +// int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old) +func _pthread_sigmask(tls *TLS, now int32, set, old uintptr) int32 { + // ignored + return 0 +} + +type barrierState struct { + mu sync.Mutex + cond *sync.Cond + count uint32 + tripCount uint32 + generation uint32 +} + +var ( + barriers = map[uintptr]*barrierState{} + barriersMu sync.Mutex +) + +// int pthread_barrier_init(pthread_barrier_t *restrict barrier, const pthread_barrierattr_t *restrict attr, unsigned count); +func Xpthread_barrier_init(tls *TLS, barrier, attr uintptr, count uint32) int32 { + if count == 0 { + return EINVAL + } + barriersMu.Lock() + defer barriersMu.Unlock() + state := &barrierState{tripCount: count} + state.cond = sync.NewCond(&state.mu) + barriers[barrier] = state + return 0 +} + +// int pthread_barrier_destroy(pthread_barrier_t *barrier); +func Xpthread_barrier_destroy(tls *TLS, barrier uintptr) int32 { + barriersMu.Lock() + defer barriersMu.Unlock() + delete(barriers, barrier) + return 0 +} + +// int pthread_barrier_wait(pthread_barrier_t *barrier); +func Xpthread_barrier_wait(tls *TLS, barrier uintptr) int32 { + barriersMu.Lock() + state := barriers[barrier] + barriersMu.Unlock() + if state == nil { + return EINVAL + } + state.mu.Lock() + gen := state.generation + state.count++ + if state.count >= state.tripCount { + state.count = 0 + state.generation++ + state.cond.Broadcast() + state.mu.Unlock() + return -1 // PTHREAD_BARRIER_SERIAL_THREAD + } + for gen == state.generation { + state.cond.Wait() + } + state.mu.Unlock() + return 0 +} + +// 202402251838 all_test.go:589: files=36 buildFails=30 execFails=2 pass=4 +// 202402262246 all_test.go:589: files=36 buildFails=26 execFails=2 pass=8 +// 202403041858 all_musl_test.go:640: files=36 buildFails=22 execFails=4 pass=10 diff --git a/internal/libc/pwd/capi_darwin_amd64.go b/internal/libc/pwd/capi_darwin_amd64.go new file mode 100644 index 0000000..0d36fd3 --- /dev/null +++ b/internal/libc/pwd/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo pwd/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pwd/pwd_darwin_amd64.go -pkgname pwd', DO NOT EDIT. + +package pwd + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/pwd/capi_darwin_arm64.go b/internal/libc/pwd/capi_darwin_arm64.go new file mode 100644 index 0000000..5393676 --- /dev/null +++ b/internal/libc/pwd/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo pwd/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pwd/pwd_darwin_arm64.go -pkgname pwd', DO NOT EDIT. + +package pwd + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/pwd/capi_linux_amd64.go b/internal/libc/pwd/capi_linux_amd64.go new file mode 100644 index 0000000..2a479f5 --- /dev/null +++ b/internal/libc/pwd/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo pwd/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pwd/pwd_linux_amd64.go -pkgname pwd', DO NOT EDIT. + +package pwd + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/pwd/capi_linux_arm64.go b/internal/libc/pwd/capi_linux_arm64.go new file mode 100644 index 0000000..8fb5d13 --- /dev/null +++ b/internal/libc/pwd/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo pwd/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o pwd/pwd_linux_arm64.go -pkgname pwd', DO NOT EDIT. + +package pwd + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/pwd/pwd_darwin_amd64.go b/internal/libc/pwd/pwd_darwin_amd64.go new file mode 100644 index 0000000..c0d983b --- /dev/null +++ b/internal/libc/pwd/pwd_darwin_amd64.go @@ -0,0 +1,1081 @@ +// Code generated by 'ccgo pwd/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pwd/pwd_darwin_amd64.go -pkgname pwd', DO NOT EDIT. + +package pwd + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MASTERPASSWD = "master.passwd" // pwd.h:57:1: + X_MP_DB = "pwd.db" // pwd.h:60:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_PASSWD = "passwd" // pwd.h:54:1: + X_PASSWORD_CHGNOW = -1 // pwd.h:80:1: + X_PASSWORD_EFMT1 = 95 // pwd.h:70:1: + X_PASSWORD_LEN = 128 // pwd.h:72:1: + X_PASSWORD_NOCHG = 0x04 // pwd.h:76:1: + X_PASSWORD_NOEXP = 0x08 // pwd.h:77:1: + X_PASSWORD_NOGID = 0x02 // pwd.h:75:1: + X_PASSWORD_NOUID = 0x01 // pwd.h:74:1: + X_PASSWORD_WARNDAYS = 14 // pwd.h:79:1: + X_PATH_MASTERPASSWD = "/etc/master.passwd" // pwd.h:55:1: + X_PATH_MASTERPASSWD_LOCK = "/etc/ptmp" // pwd.h:56:1: + X_PATH_MP_DB = "/etc/pwd.db" // pwd.h:59:1: + X_PATH_PASSWD = "/etc/passwd" // pwd.h:53:1: + X_PATH_PWD = "/etc" // pwd.h:52:1: + X_PATH_PWD_MKDB = "/usr/sbin/pwd_mkdb" // pwd.h:64:1: + X_PATH_SMP_DB = "/etc/spwd.db" // pwd.h:61:1: + X_PWD_H_ = 0 // pwd.h:44:1: + X_PW_KEYBYNAME = 49 // pwd.h:66:1: + X_PW_KEYBYNUM = 50 // pwd.h:67:1: + X_PW_KEYBYUID = 51 // pwd.h:68:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SMP_DB = "spwd.db" // pwd.h:62:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UUID_STRING_T = 0 // uuid.h:42:1: + X_UUID_T = 0 // _uuid_t.h:29:1: + X_UUID_UUID_H = 0 // uuid.h:36:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// - +// Copyright (c) 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, Inc. +// Portions Copyright(C) 1995, Jason Downs. 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. +// +// @(#)pwd.h 8.2 (Berkeley) 1/21/94 +// Portions copyright (c) 2000-2011 Apple Inc. All rights reserved. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +type Passwd = struct { + Fpw_name uintptr + Fpw_passwd uintptr + Fpw_uid Uid_t + Fpw_gid Gid_t + Fpw_change X__darwin_time_t + Fpw_class uintptr + Fpw_gecos uintptr + Fpw_dir uintptr + Fpw_shell uintptr + Fpw_expire X__darwin_time_t +} /* pwd.h:84:1 */ + +// Public include file for the UUID library +// +// Copyright (C) 1996, 1997, 1998 Theodore Ts'o. +// +// %Begin-Header% +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, and the entire permission notice in its entirety, +// including the disclaimer of warranties. +// 2. Redistributions in binary form must reproduce 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 ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +// WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// %End-Header% + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uuid_t = X__darwin_uuid_t /* _uuid_t.h:31:25 */ + +type Uuid_string_t = X__darwin_uuid_string_t /* uuid.h:43:33 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/pwd/pwd_darwin_arm64.go b/internal/libc/pwd/pwd_darwin_arm64.go new file mode 100644 index 0000000..84ebe93 --- /dev/null +++ b/internal/libc/pwd/pwd_darwin_arm64.go @@ -0,0 +1,1083 @@ +// Code generated by 'ccgo pwd/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pwd/pwd_darwin_arm64.go -pkgname pwd', DO NOT EDIT. + +package pwd + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MASTERPASSWD = "master.passwd" // pwd.h:57:1: + X_MP_DB = "pwd.db" // pwd.h:60:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_PASSWD = "passwd" // pwd.h:54:1: + X_PASSWORD_CHGNOW = -1 // pwd.h:80:1: + X_PASSWORD_EFMT1 = 95 // pwd.h:70:1: + X_PASSWORD_LEN = 128 // pwd.h:72:1: + X_PASSWORD_NOCHG = 0x04 // pwd.h:76:1: + X_PASSWORD_NOEXP = 0x08 // pwd.h:77:1: + X_PASSWORD_NOGID = 0x02 // pwd.h:75:1: + X_PASSWORD_NOUID = 0x01 // pwd.h:74:1: + X_PASSWORD_WARNDAYS = 14 // pwd.h:79:1: + X_PATH_MASTERPASSWD = "/etc/master.passwd" // pwd.h:55:1: + X_PATH_MASTERPASSWD_LOCK = "/etc/ptmp" // pwd.h:56:1: + X_PATH_MP_DB = "/etc/pwd.db" // pwd.h:59:1: + X_PATH_PASSWD = "/etc/passwd" // pwd.h:53:1: + X_PATH_PWD = "/etc" // pwd.h:52:1: + X_PATH_PWD_MKDB = "/usr/sbin/pwd_mkdb" // pwd.h:64:1: + X_PATH_SMP_DB = "/etc/spwd.db" // pwd.h:61:1: + X_PWD_H_ = 0 // pwd.h:44:1: + X_PW_KEYBYNAME = 49 // pwd.h:66:1: + X_PW_KEYBYNUM = 50 // pwd.h:67:1: + X_PW_KEYBYUID = 51 // pwd.h:68:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SMP_DB = "spwd.db" // pwd.h:62:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UUID_STRING_T = 0 // uuid.h:42:1: + X_UUID_T = 0 // _uuid_t.h:29:1: + X_UUID_UUID_H = 0 // uuid.h:36:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// - +// Copyright (c) 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, Inc. +// Portions Copyright(C) 1995, Jason Downs. 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. +// +// @(#)pwd.h 8.2 (Berkeley) 1/21/94 +// Portions copyright (c) 2000-2011 Apple Inc. All rights reserved. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +type Passwd = struct { + Fpw_name uintptr + Fpw_passwd uintptr + Fpw_uid Uid_t + Fpw_gid Gid_t + Fpw_change X__darwin_time_t + Fpw_class uintptr + Fpw_gecos uintptr + Fpw_dir uintptr + Fpw_shell uintptr + Fpw_expire X__darwin_time_t +} /* pwd.h:84:1 */ + +// Public include file for the UUID library +// +// Copyright (C) 1996, 1997, 1998 Theodore Ts'o. +// +// %Begin-Header% +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, and the entire permission notice in its entirety, +// including the disclaimer of warranties. +// 2. Redistributions in binary form must reproduce 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 ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +// WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// %End-Header% + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uuid_t = X__darwin_uuid_t /* _uuid_t.h:31:25 */ + +type Uuid_string_t = X__darwin_uuid_string_t /* uuid.h:43:33 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/pwd/pwd_linux_amd64.go b/internal/libc/pwd/pwd_linux_amd64.go new file mode 100644 index 0000000..2e80db4 --- /dev/null +++ b/internal/libc/pwd/pwd_linux_amd64.go @@ -0,0 +1,789 @@ +// Code generated by 'ccgo pwd/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o pwd/pwd_linux_amd64.go -pkgname pwd', DO NOT EDIT. + +package pwd + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + NSS_BUFLEN_PASSWD = 1024 // pwd.h:123:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_PWD_H = 1 // pwd.h:23:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 9.2.2 User Database Access + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// The Single Unix specification says that some more types are +// +// available here. +type Gid_t = X__gid_t /* pwd.h:38:17 */ + +type Uid_t = X__uid_t /* pwd.h:43:17 */ + +// A record in the user database. +type Passwd = struct { + Fpw_name uintptr + Fpw_passwd uintptr + Fpw_uid X__uid_t + Fpw_gid X__gid_t + Fpw_gecos uintptr + Fpw_dir uintptr + Fpw_shell uintptr +} /* pwd.h:49:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/pwd/pwd_linux_arm64.go b/internal/libc/pwd/pwd_linux_arm64.go new file mode 100644 index 0000000..726791e --- /dev/null +++ b/internal/libc/pwd/pwd_linux_arm64.go @@ -0,0 +1,857 @@ +// Code generated by 'ccgo pwd/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o pwd/pwd_linux_arm64.go -pkgname pwd', DO NOT EDIT. + +package pwd + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + NSS_BUFLEN_PASSWD = 1024 + X_ATFILE_SOURCE = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_PWD_H = 1 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SIZE_T_H = 0 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 9.2.2 User Database Access + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// The Single Unix specification says that some more types are +// +// available here. +type Gid_t = X__gid_t /* pwd.h:38:17 */ + +type Uid_t = X__uid_t /* pwd.h:43:17 */ + +// A record in the user database. +type Passwd = struct { + Fpw_name uintptr + Fpw_passwd uintptr + Fpw_uid X__uid_t + Fpw_gid X__gid_t + Fpw_gecos uintptr + Fpw_dir uintptr + Fpw_shell uintptr +} /* pwd.h:49:1 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/rtl.go b/internal/libc/rtl.go new file mode 100644 index 0000000..d38a9b2 --- /dev/null +++ b/internal/libc/rtl.go @@ -0,0 +1,2200 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +// VaList fills a varargs list at p with args and returns p. The list must +// have been allocated by caller and it must not be in Go managed memory, ie. +// it must be pinned. Caller is responsible for freeing the list. +// +// This function supports code generated by ccgo/v4. +// +// Note: The C translated to Go varargs ABI alignment for all types is 8 on all +// architectures. +func VaList(p uintptr, args ...interface{}) (r uintptr) { + if p&7 != 0 { + panic("internal error") + } + + r = p + for _, v := range args { + switch x := v.(type) { + case int: + *(*int64)(unsafe.Pointer(p)) = int64(x) + case int32: + *(*int64)(unsafe.Pointer(p)) = int64(x) + case int64: + *(*int64)(unsafe.Pointer(p)) = x + case uint: + *(*uint64)(unsafe.Pointer(p)) = uint64(x) + case uint16: + *(*uint64)(unsafe.Pointer(p)) = uint64(x) + case uint32: + *(*uint64)(unsafe.Pointer(p)) = uint64(x) + case uint64: + *(*uint64)(unsafe.Pointer(p)) = x + case float64: + *(*float64)(unsafe.Pointer(p)) = x + case uintptr: + *(*uintptr)(unsafe.Pointer(p)) = x + default: + sz := reflect.TypeOf(v).Size() + copy(unsafe.Slice((*byte)(unsafe.Pointer(p)), sz), unsafe.Slice((*byte)(unsafe.Pointer((*[2]uintptr)(unsafe.Pointer(&v))[1])), sz)) + p += roundup(sz, 8) + continue + } + p += 8 + } + return r +} + +// Bool returns v as a non-constant boolean value. +func Bool(v bool) bool { return v } + +func Bool32(b bool) int32 { + if b { + return 1 + } + + return 0 +} + +func roundup(n, to uintptr) uintptr { + if r := n % to; r != 0 { + return n + to - r + } + + return n +} + +func VaOther(app *uintptr, sz uint64) (r uintptr) { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + r = ap + ap = roundup(ap+uintptr(sz), 8) + *(*uintptr)(unsafe.Pointer(app)) = ap + return r +} + +func VaInt32(app *uintptr) int32 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := int32(*(*int64)(unsafe.Pointer(ap))) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaUint32(app *uintptr) uint32 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := uint32(*(*uint64)(unsafe.Pointer(ap))) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaInt64(app *uintptr) int64 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*int64)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaUint64(app *uintptr) uint64 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*uint64)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaFloat32(app *uintptr) float32 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*float64)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return float32(v) +} + +func VaFloat64(app *uintptr) float64 { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*float64)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func VaUintptr(app *uintptr) uintptr { + ap := *(*uintptr)(unsafe.Pointer(app)) + if ap == 0 { + return 0 + } + + ap = roundup(ap, 8) + v := *(*uintptr)(unsafe.Pointer(ap)) + ap += 8 + *(*uintptr)(unsafe.Pointer(app)) = ap + return v +} + +func AtomicStoreNUint8(ptr uintptr, val uint8, memorder int32) { + a_store_8(ptr, int8(val)) +} + +func AtomicStorePInt8(addr uintptr, val int8) int8 { + a_store_8(addr, val) + return val +} + +func AtomicStorePUint8(addr uintptr, val byte) byte { + a_store_8(addr, int8(val)) + return val +} + +func AtomicStorePInt32(addr uintptr, val int32) int32 { + atomic.StoreInt32((*int32)(unsafe.Pointer(addr)), val) + return val +} + +func AtomicStorePInt64(addr uintptr, val int64) int64 { + atomic.StoreInt64((*int64)(unsafe.Pointer(addr)), val) + return val +} + +func AtomicStorePUint32(addr uintptr, val uint32) uint32 { + atomic.StoreUint32((*uint32)(unsafe.Pointer(addr)), val) + return val +} + +func AtomicStorePUint64(addr uintptr, val uint64) uint64 { + atomic.StoreUint64((*uint64)(unsafe.Pointer(addr)), val) + return val +} + +func AtomicStorePUintptr(addr uintptr, val uintptr) uintptr { + atomic.StoreUintptr((*uintptr)(unsafe.Pointer(addr)), val) + return val +} + +func AtomicStorePFloat32(addr uintptr, val float32) float32 { + atomic.StoreUint32((*uint32)(unsafe.Pointer(addr)), math.Float32bits(val)) + return val +} + +func AtomicStorePFloat64(addr uintptr, val float64) float64 { + atomic.StoreUint64((*uint64)(unsafe.Pointer(addr)), math.Float64bits(val)) + return val +} + +func AtomicLoadPInt8(addr uintptr) (val int8) { + return a_load_8(addr) +} + +func AtomicLoadPInt16(addr uintptr) (val int16) { + return a_load_16(addr) +} + +func AtomicLoadPInt32(addr uintptr) (val int32) { + return atomic.LoadInt32((*int32)(unsafe.Pointer(addr))) +} + +func AtomicLoadPInt64(addr uintptr) (val int64) { + return atomic.LoadInt64((*int64)(unsafe.Pointer(addr))) +} + +func AtomicLoadPUint8(addr uintptr) byte { + return byte(a_load_8(addr)) +} + +func AtomicLoadPUint16(addr uintptr) uint16 { + return uint16(a_load_16(addr)) +} + +func AtomicLoadPUint32(addr uintptr) (val uint32) { + return atomic.LoadUint32((*uint32)(unsafe.Pointer(addr))) +} + +func AtomicLoadPUint64(addr uintptr) (val uint64) { + return atomic.LoadUint64((*uint64)(unsafe.Pointer(addr))) +} + +func AtomicLoadPUintptr(addr uintptr) (val uintptr) { + return atomic.LoadUintptr((*uintptr)(unsafe.Pointer(addr))) +} + +func AtomicLoadPFloat32(addr uintptr) (val float32) { + return math.Float32frombits(atomic.LoadUint32((*uint32)(unsafe.Pointer(addr)))) +} + +func AtomicLoadPFloat64(addr uintptr) (val float64) { + return math.Float64frombits(atomic.LoadUint64((*uint64)(unsafe.Pointer(addr)))) +} + +func AtomicStoreNUint16(ptr uintptr, val uint16, memorder int32) { + a_store_16(ptr, val) +} + +func AtomicStoreNInt32(ptr uintptr, val int32, memorder int32) { + atomic.StoreInt32((*int32)(unsafe.Pointer(ptr)), val) +} + +func AtomicStoreNInt64(ptr uintptr, val int64, memorder int32) { + atomic.StoreInt64((*int64)(unsafe.Pointer(ptr)), val) +} + +func AtomicStoreNUint32(ptr uintptr, val uint32, memorder int32) { + atomic.StoreUint32((*uint32)(unsafe.Pointer(ptr)), val) +} + +func AtomicStoreNUint64(ptr uintptr, val uint64, memorder int32) { + atomic.StoreUint64((*uint64)(unsafe.Pointer(ptr)), val) +} + +func AtomicStoreNUintptr(ptr uintptr, val uintptr, memorder int32) { + atomic.StoreUintptr((*uintptr)(unsafe.Pointer(ptr)), val) +} + +func AtomicLoadNUint8(ptr uintptr, memorder int32) uint8 { + return byte(a_load_8(ptr)) +} + +func AtomicLoadNUint16(ptr uintptr, memorder int32) uint16 { + return uint16(a_load_16(ptr)) +} + +func AtomicLoadNInt32(ptr uintptr, memorder int32) int32 { + return atomic.LoadInt32((*int32)(unsafe.Pointer(ptr))) +} + +func AtomicLoadNInt64(ptr uintptr, memorder int32) int64 { + return atomic.LoadInt64((*int64)(unsafe.Pointer(ptr))) +} + +func AtomicLoadNUint32(ptr uintptr, memorder int32) uint32 { + return atomic.LoadUint32((*uint32)(unsafe.Pointer(ptr))) +} + +func AtomicLoadNUint64(ptr uintptr, memorder int32) uint64 { + return atomic.LoadUint64((*uint64)(unsafe.Pointer(ptr))) +} + +func AtomicLoadNUintptr(ptr uintptr, memorder int32) uintptr { + return atomic.LoadUintptr((*uintptr)(unsafe.Pointer(ptr))) +} + +func AssignInt8(p *int8, v int8) int8 { *p = v; return v } +func AssignInt16(p *int16, v int16) int16 { *p = v; return v } +func AssignInt32(p *int32, v int32) int32 { *p = v; return v } +func AssignInt64(p *int64, v int64) int64 { *p = v; return v } +func AssignUint8(p *uint8, v uint8) uint8 { *p = v; return v } +func AssignUint16(p *uint16, v uint16) uint16 { *p = v; return v } +func AssignUint32(p *uint32, v uint32) uint32 { *p = v; return v } +func AssignUint64(p *uint64, v uint64) uint64 { *p = v; return v } +func AssignFloat32(p *float32, v float32) float32 { *p = v; return v } +func AssignFloat64(p *float64, v float64) float64 { *p = v; return v } +func AssignComplex64(p *complex64, v complex64) complex64 { *p = v; return v } +func AssignComplex128(p *complex128, v complex128) complex128 { *p = v; return v } +func AssignUintptr(p *uintptr, v uintptr) uintptr { *p = v; return v } + +func AssignPtrInt8(p uintptr, v int8) int8 { *(*int8)(unsafe.Pointer(p)) = v; return v } +func AssignPtrInt16(p uintptr, v int16) int16 { *(*int16)(unsafe.Pointer(p)) = v; return v } +func AssignPtrInt32(p uintptr, v int32) int32 { *(*int32)(unsafe.Pointer(p)) = v; return v } +func AssignPtrInt64(p uintptr, v int64) int64 { *(*int64)(unsafe.Pointer(p)) = v; return v } +func AssignPtrUint8(p uintptr, v uint8) uint8 { *(*uint8)(unsafe.Pointer(p)) = v; return v } +func AssignPtrUint16(p uintptr, v uint16) uint16 { *(*uint16)(unsafe.Pointer(p)) = v; return v } +func AssignPtrUint32(p uintptr, v uint32) uint32 { *(*uint32)(unsafe.Pointer(p)) = v; return v } +func AssignPtrUint64(p uintptr, v uint64) uint64 { *(*uint64)(unsafe.Pointer(p)) = v; return v } +func AssignPtrFloat32(p uintptr, v float32) float32 { *(*float32)(unsafe.Pointer(p)) = v; return v } +func AssignPtrFloat64(p uintptr, v float64) float64 { *(*float64)(unsafe.Pointer(p)) = v; return v } +func AssignPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) = v + return v +} +func AssignPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) = v + return v +} +func AssignPtrUintptr(p uintptr, v uintptr) uintptr { *(*uintptr)(unsafe.Pointer(p)) = v; return v } + +func AssignMulInt8(p *int8, v int8) int8 { *p *= v; return *p } +func AssignMulInt16(p *int16, v int16) int16 { *p *= v; return *p } +func AssignMulInt32(p *int32, v int32) int32 { *p *= v; return *p } +func AssignMulInt64(p *int64, v int64) int64 { *p *= v; return *p } +func AssignMulUint8(p *uint8, v uint8) uint8 { *p *= v; return *p } +func AssignMulUint16(p *uint16, v uint16) uint16 { *p *= v; return *p } +func AssignMulUint32(p *uint32, v uint32) uint32 { *p *= v; return *p } +func AssignMulUint64(p *uint64, v uint64) uint64 { *p *= v; return *p } +func AssignMulFloat32(p *float32, v float32) float32 { *p *= v; return *p } +func AssignMulFloat64(p *float64, v float64) float64 { *p *= v; return *p } +func AssignMulComplex64(p *complex64, v complex64) complex64 { *p *= v; return *p } +func AssignMulComplex128(p *complex128, v complex128) complex128 { *p *= v; return *p } +func AssignMulUintptr(p *uintptr, v uintptr) uintptr { *p *= v; return *p } + +func AssignDivInt8(p *int8, v int8) int8 { *p /= v; return *p } +func AssignDivInt16(p *int16, v int16) int16 { *p /= v; return *p } +func AssignDivInt32(p *int32, v int32) int32 { *p /= v; return *p } +func AssignDivInt64(p *int64, v int64) int64 { *p /= v; return *p } +func AssignDivUint8(p *uint8, v uint8) uint8 { *p /= v; return *p } +func AssignDivUint16(p *uint16, v uint16) uint16 { *p /= v; return *p } +func AssignDivUint32(p *uint32, v uint32) uint32 { *p /= v; return *p } +func AssignDivUint64(p *uint64, v uint64) uint64 { *p /= v; return *p } +func AssignDivFloat32(p *float32, v float32) float32 { *p /= v; return *p } +func AssignDivFloat64(p *float64, v float64) float64 { *p /= v; return *p } +func AssignDivComplex64(p *complex64, v complex64) complex64 { *p /= v; return *p } +func AssignDivComplex128(p *complex128, v complex128) complex128 { *p /= v; return *p } +func AssignDivUintptr(p *uintptr, v uintptr) uintptr { *p /= v; return *p } + +func AssignRemInt8(p *int8, v int8) int8 { *p %= v; return *p } +func AssignRemInt16(p *int16, v int16) int16 { *p %= v; return *p } +func AssignRemInt32(p *int32, v int32) int32 { *p %= v; return *p } +func AssignRemInt64(p *int64, v int64) int64 { *p %= v; return *p } +func AssignRemUint8(p *uint8, v uint8) uint8 { *p %= v; return *p } +func AssignRemUint16(p *uint16, v uint16) uint16 { *p %= v; return *p } +func AssignRemUint32(p *uint32, v uint32) uint32 { *p %= v; return *p } +func AssignRemUint64(p *uint64, v uint64) uint64 { *p %= v; return *p } +func AssignRemUintptr(p *uintptr, v uintptr) uintptr { *p %= v; return *p } + +func AssignAddInt8(p *int8, v int8) int8 { *p += v; return *p } +func AssignAddInt16(p *int16, v int16) int16 { *p += v; return *p } +func AssignAddInt32(p *int32, v int32) int32 { *p += v; return *p } +func AssignAddInt64(p *int64, v int64) int64 { *p += v; return *p } +func AssignAddUint8(p *uint8, v uint8) uint8 { *p += v; return *p } +func AssignAddUint16(p *uint16, v uint16) uint16 { *p += v; return *p } +func AssignAddUint32(p *uint32, v uint32) uint32 { *p += v; return *p } +func AssignAddUint64(p *uint64, v uint64) uint64 { *p += v; return *p } +func AssignAddFloat32(p *float32, v float32) float32 { *p += v; return *p } +func AssignAddFloat64(p *float64, v float64) float64 { *p += v; return *p } +func AssignAddComplex64(p *complex64, v complex64) complex64 { *p += v; return *p } +func AssignAddComplex128(p *complex128, v complex128) complex128 { *p += v; return *p } +func AssignAddUintptr(p *uintptr, v uintptr) uintptr { *p += v; return *p } + +func AssignSubInt8(p *int8, v int8) int8 { *p -= v; return *p } +func AssignSubInt16(p *int16, v int16) int16 { *p -= v; return *p } +func AssignSubInt32(p *int32, v int32) int32 { *p -= v; return *p } +func AssignSubInt64(p *int64, v int64) int64 { *p -= v; return *p } +func AssignSubUint8(p *uint8, v uint8) uint8 { *p -= v; return *p } +func AssignSubUint16(p *uint16, v uint16) uint16 { *p -= v; return *p } +func AssignSubUint32(p *uint32, v uint32) uint32 { *p -= v; return *p } +func AssignSubUint64(p *uint64, v uint64) uint64 { *p -= v; return *p } +func AssignSubFloat32(p *float32, v float32) float32 { *p -= v; return *p } +func AssignSubFloat64(p *float64, v float64) float64 { *p -= v; return *p } +func AssignSubComplex64(p *complex64, v complex64) complex64 { *p -= v; return *p } +func AssignSubComplex128(p *complex128, v complex128) complex128 { *p -= v; return *p } +func AssignSubUintptr(p *uintptr, v uintptr) uintptr { *p -= v; return *p } + +func AssignAndInt8(p *int8, v int8) int8 { *p &= v; return *p } +func AssignAndInt16(p *int16, v int16) int16 { *p &= v; return *p } +func AssignAndInt32(p *int32, v int32) int32 { *p &= v; return *p } +func AssignAndInt64(p *int64, v int64) int64 { *p &= v; return *p } +func AssignAndUint8(p *uint8, v uint8) uint8 { *p &= v; return *p } +func AssignAndUint16(p *uint16, v uint16) uint16 { *p &= v; return *p } +func AssignAndUint32(p *uint32, v uint32) uint32 { *p &= v; return *p } +func AssignAndUint64(p *uint64, v uint64) uint64 { *p &= v; return *p } +func AssignAndUintptr(p *uintptr, v uintptr) uintptr { *p &= v; return *p } + +func AssignXorInt8(p *int8, v int8) int8 { *p ^= v; return *p } +func AssignXorInt16(p *int16, v int16) int16 { *p ^= v; return *p } +func AssignXorInt32(p *int32, v int32) int32 { *p ^= v; return *p } +func AssignXorInt64(p *int64, v int64) int64 { *p ^= v; return *p } +func AssignXorUint8(p *uint8, v uint8) uint8 { *p ^= v; return *p } +func AssignXorUint16(p *uint16, v uint16) uint16 { *p ^= v; return *p } +func AssignXorUint32(p *uint32, v uint32) uint32 { *p ^= v; return *p } +func AssignXorUint64(p *uint64, v uint64) uint64 { *p ^= v; return *p } +func AssignXorUintptr(p *uintptr, v uintptr) uintptr { *p ^= v; return *p } + +func AssignOrInt8(p *int8, v int8) int8 { *p |= v; return *p } +func AssignOrInt16(p *int16, v int16) int16 { *p |= v; return *p } +func AssignOrInt32(p *int32, v int32) int32 { *p |= v; return *p } +func AssignOrInt64(p *int64, v int64) int64 { *p |= v; return *p } +func AssignOrUint8(p *uint8, v uint8) uint8 { *p |= v; return *p } +func AssignOrUint16(p *uint16, v uint16) uint16 { *p |= v; return *p } +func AssignOrUint32(p *uint32, v uint32) uint32 { *p |= v; return *p } +func AssignOrUint64(p *uint64, v uint64) uint64 { *p |= v; return *p } +func AssignOrUintptr(p *uintptr, v uintptr) uintptr { *p |= v; return *p } + +func AssignMulPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) *= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignMulPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) *= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignMulPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) *= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignMulPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) *= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignMulPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) *= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignMulPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) *= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignMulPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) *= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignMulPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) *= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignMulPtrFloat32(p uintptr, v float32) float32 { + *(*float32)(unsafe.Pointer(p)) *= v + return *(*float32)(unsafe.Pointer(p)) +} + +func AssignMulPtrFloat64(p uintptr, v float64) float64 { + *(*float64)(unsafe.Pointer(p)) *= v + return *(*float64)(unsafe.Pointer(p)) +} + +func AssignMulPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) *= v + return *(*complex64)(unsafe.Pointer(p)) +} + +func AssignMulPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) *= v + return *(*complex128)(unsafe.Pointer(p)) +} + +func AssignMulPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) *= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignDivPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) /= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignDivPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) /= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignDivPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) /= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignDivPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) /= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignDivPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) /= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignDivPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) /= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignDivPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) /= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignDivPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) /= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignDivPtrFloat32(p uintptr, v float32) float32 { + *(*float32)(unsafe.Pointer(p)) /= v + return *(*float32)(unsafe.Pointer(p)) +} + +func AssignDivPtrFloat64(p uintptr, v float64) float64 { + *(*float64)(unsafe.Pointer(p)) /= v + return *(*float64)(unsafe.Pointer(p)) +} + +func AssignDivPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) /= v + return *(*complex64)(unsafe.Pointer(p)) +} + +func AssignDivPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) /= v + return *(*complex128)(unsafe.Pointer(p)) +} + +func AssignDivPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) /= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignRemPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) %= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignRemPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) %= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignRemPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) %= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignRemPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) %= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignRemPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) %= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignRemPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) %= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignRemPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) %= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignRemPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) %= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignRemPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) %= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignAddPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) += v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignAddPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) += v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignAddPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) += v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignAddPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) += v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignAddPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) += v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignAddPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) += v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignAddPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) += v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignAddPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) += v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignAddPtrFloat32(p uintptr, v float32) float32 { + *(*float32)(unsafe.Pointer(p)) += v + return *(*float32)(unsafe.Pointer(p)) +} + +func AssignAddPtrFloat64(p uintptr, v float64) float64 { + *(*float64)(unsafe.Pointer(p)) += v + return *(*float64)(unsafe.Pointer(p)) +} + +func AssignAddPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) += v + return *(*complex64)(unsafe.Pointer(p)) +} + +func AssignAddPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) += v + return *(*complex128)(unsafe.Pointer(p)) +} + +func AssignAddPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) += v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignSubPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) -= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignSubPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) -= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignSubPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) -= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignSubPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) -= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignSubPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) -= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignSubPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) -= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignSubPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) -= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignSubPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) -= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignSubPtrFloat32(p uintptr, v float32) float32 { + *(*float32)(unsafe.Pointer(p)) -= v + return *(*float32)(unsafe.Pointer(p)) +} + +func AssignSubPtrFloat64(p uintptr, v float64) float64 { + *(*float64)(unsafe.Pointer(p)) -= v + return *(*float64)(unsafe.Pointer(p)) +} + +func AssignSubPtrComplex64(p uintptr, v complex64) complex64 { + *(*complex64)(unsafe.Pointer(p)) -= v + return *(*complex64)(unsafe.Pointer(p)) +} + +func AssignSubPtrComplex128(p uintptr, v complex128) complex128 { + *(*complex128)(unsafe.Pointer(p)) -= v + return *(*complex128)(unsafe.Pointer(p)) +} + +func AssignSubPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) -= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignAndPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) &= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignAndPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) &= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignAndPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) &= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignAndPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) &= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignAndPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) &= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignAndPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) &= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignAndPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) &= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignAndPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) &= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignAndPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) &= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignXorPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) ^= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignXorPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) ^= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignXorPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) ^= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignXorPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) ^= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignXorPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) ^= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignXorPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) ^= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignXorPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) ^= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignXorPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) ^= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignXorPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) ^= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignOrPtrInt8(p uintptr, v int8) int8 { + *(*int8)(unsafe.Pointer(p)) |= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignOrPtrInt16(p uintptr, v int16) int16 { + *(*int16)(unsafe.Pointer(p)) |= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignOrPtrInt32(p uintptr, v int32) int32 { + *(*int32)(unsafe.Pointer(p)) |= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignOrPtrInt64(p uintptr, v int64) int64 { + *(*int64)(unsafe.Pointer(p)) |= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignOrPtrUint8(p uintptr, v uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) |= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignOrPtrUint16(p uintptr, v uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) |= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignOrPtrUint32(p uintptr, v uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) |= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignOrPtrUint64(p uintptr, v uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) |= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignOrPtrUintptr(p uintptr, v uintptr) uintptr { + *(*uintptr)(unsafe.Pointer(p)) |= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignShlPtrInt8(p uintptr, v int) int8 { + *(*int8)(unsafe.Pointer(p)) <<= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignShlPtrInt16(p uintptr, v int) int16 { + *(*int16)(unsafe.Pointer(p)) <<= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignShlPtrInt32(p uintptr, v int) int32 { + *(*int32)(unsafe.Pointer(p)) <<= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignShlPtrInt64(p uintptr, v int) int64 { + *(*int64)(unsafe.Pointer(p)) <<= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignShlPtrUint8(p uintptr, v int) uint8 { + *(*uint8)(unsafe.Pointer(p)) <<= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignShlPtrUint16(p uintptr, v int) uint16 { + *(*uint16)(unsafe.Pointer(p)) <<= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignShlPtrUint32(p uintptr, v int) uint32 { + *(*uint32)(unsafe.Pointer(p)) <<= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignShlPtrUint64(p uintptr, v int) uint64 { + *(*uint64)(unsafe.Pointer(p)) <<= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignShlPtrUintptr(p uintptr, v int) uintptr { + *(*uintptr)(unsafe.Pointer(p)) <<= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignShrPtrInt8(p uintptr, v int) int8 { + *(*int8)(unsafe.Pointer(p)) >>= v + return *(*int8)(unsafe.Pointer(p)) +} + +func AssignShrPtrInt16(p uintptr, v int) int16 { + *(*int16)(unsafe.Pointer(p)) >>= v + return *(*int16)(unsafe.Pointer(p)) +} + +func AssignShrPtrInt32(p uintptr, v int) int32 { + *(*int32)(unsafe.Pointer(p)) >>= v + return *(*int32)(unsafe.Pointer(p)) +} + +func AssignShrPtrInt64(p uintptr, v int) int64 { + *(*int64)(unsafe.Pointer(p)) >>= v + return *(*int64)(unsafe.Pointer(p)) +} + +func AssignShrPtrUint8(p uintptr, v int) uint8 { + *(*uint8)(unsafe.Pointer(p)) >>= v + return *(*uint8)(unsafe.Pointer(p)) +} + +func AssignShrPtrUint16(p uintptr, v int) uint16 { + *(*uint16)(unsafe.Pointer(p)) >>= v + return *(*uint16)(unsafe.Pointer(p)) +} + +func AssignShrPtrUint32(p uintptr, v int) uint32 { + *(*uint32)(unsafe.Pointer(p)) >>= v + return *(*uint32)(unsafe.Pointer(p)) +} + +func AssignShrPtrUint64(p uintptr, v int) uint64 { + *(*uint64)(unsafe.Pointer(p)) >>= v + return *(*uint64)(unsafe.Pointer(p)) +} + +func AssignShrPtrUintptr(p uintptr, v int) uintptr { + *(*uintptr)(unsafe.Pointer(p)) >>= v + return *(*uintptr)(unsafe.Pointer(p)) +} + +func AssignShlInt8(p *int8, v int) int8 { *p <<= v; return *p } + +func AssignShlInt16(p *int16, v int) int16 { *p <<= v; return *p } + +func AssignShlInt32(p *int32, v int) int32 { *p <<= v; return *p } + +func AssignShlInt64(p *int64, v int) int64 { *p <<= v; return *p } + +func AssignShlUint8(p *uint8, v int) uint8 { *p <<= v; return *p } + +func AssignShlUint16(p *uint16, v int) uint16 { *p <<= v; return *p } + +func AssignShlUint32(p *uint32, v int) uint32 { *p <<= v; return *p } + +func AssignShlUint64(p *uint64, v int) uint64 { *p <<= v; return *p } + +func AssignShlUintptr(p *uintptr, v int) uintptr { *p <<= v; return *p } + +func AssignShrInt8(p *int8, v int) int8 { *p >>= v; return *p } + +func AssignShrInt16(p *int16, v int) int16 { *p >>= v; return *p } + +func AssignShrInt32(p *int32, v int) int32 { *p >>= v; return *p } + +func AssignShrInt64(p *int64, v int) int64 { *p >>= v; return *p } + +func AssignShrUint8(p *uint8, v int) uint8 { *p >>= v; return *p } + +func AssignShrUint16(p *uint16, v int) uint16 { *p >>= v; return *p } + +func AssignShrUint32(p *uint32, v int) uint32 { *p >>= v; return *p } + +func AssignShrUint64(p *uint64, v int) uint64 { *p >>= v; return *p } + +func AssignShrUintptr(p *uintptr, v int) uintptr { *p >>= v; return *p } + +func PreIncInt8(p *int8, d int8) int8 { *p += d; return *p } +func PreIncInt16(p *int16, d int16) int16 { *p += d; return *p } +func PreIncInt32(p *int32, d int32) int32 { *p += d; return *p } +func PreIncInt64(p *int64, d int64) int64 { *p += d; return *p } +func PreIncUint8(p *uint8, d uint8) uint8 { *p += d; return *p } +func PreIncUint16(p *uint16, d uint16) uint16 { *p += d; return *p } +func PreIncUint32(p *uint32, d uint32) uint32 { *p += d; return *p } +func PreIncUint64(p *uint64, d uint64) uint64 { *p += d; return *p } +func PreIncFloat32(p *float32, d float32) float32 { *p += d; return *p } +func PreIncFloat64(p *float64, d float64) float64 { *p += d; return *p } +func PreIncComplex64(p *complex64, d complex64) complex64 { *p += d; return *p } +func PreIncComplex128(p *complex128, d complex128) complex128 { *p += d; return *p } +func PreIncUintptr(p *uintptr, d uintptr) uintptr { *p += d; return *p } + +func PreIncAtomicInt32(p *int32, d int32) int32 { return atomic.AddInt32(p, d) } +func PreIncAtomicInt64(p *int64, d int64) int64 { return atomic.AddInt64(p, d) } +func PreIncAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint32(p, d) } +func PreIncAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, d) } +func PreIncAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, d) } + +func PreIncAtomicInt32P(p uintptr, d int32) int32 { + return atomic.AddInt32((*int32)(unsafe.Pointer(p)), d) +} + +func PreIncAtomicInt64P(p uintptr, d int64) int64 { + return atomic.AddInt64((*int64)(unsafe.Pointer(p)), d) +} + +func PreIncAtomicUint32P(p uintptr, d uint32) uint32 { + return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), d) +} + +func PreIncAtomicUint64P(p uintptr, d uint64) uint64 { + return atomic.AddUint64((*uint64)(unsafe.Pointer(p)), d) +} + +func PreInrAtomicUintptrP(p uintptr, d uintptr) uintptr { + return atomic.AddUintptr((*uintptr)(unsafe.Pointer(p)), d) +} + +func PreDecInt8(p *int8, d int8) int8 { *p -= d; return *p } +func PreDecInt16(p *int16, d int16) int16 { *p -= d; return *p } +func PreDecInt32(p *int32, d int32) int32 { *p -= d; return *p } +func PreDecInt64(p *int64, d int64) int64 { *p -= d; return *p } +func PreDecUint8(p *uint8, d uint8) uint8 { *p -= d; return *p } +func PreDecUint16(p *uint16, d uint16) uint16 { *p -= d; return *p } +func PreDecUint32(p *uint32, d uint32) uint32 { *p -= d; return *p } +func PreDecUint64(p *uint64, d uint64) uint64 { *p -= d; return *p } +func PreDecFloat32(p *float32, d float32) float32 { *p -= d; return *p } +func PreDecFloat64(p *float64, d float64) float64 { *p -= d; return *p } +func PreDecComplex64(p *complex64, d complex64) complex64 { *p -= d; return *p } +func PreDecComplex128(p *complex128, d complex128) complex128 { *p -= d; return *p } +func PreDecUintptr(p *uintptr, d uintptr) uintptr { *p -= d; return *p } + +func PreDecAtomicInt32(p *int32, d int32) int32 { return atomic.AddInt32(p, -d) } +func PreDecAtomicInt64(p *int64, d int64) int64 { return atomic.AddInt64(p, -d) } +func PreDecAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint32(p, -d) } +func PreDecAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, -d) } +func PreDecAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, -d) } + +func PostIncInt8(p *int8, d int8) int8 { r := *p; *p += d; return r } +func PostIncInt16(p *int16, d int16) int16 { r := *p; *p += d; return r } +func PostIncInt32(p *int32, d int32) int32 { r := *p; *p += d; return r } +func PostIncInt64(p *int64, d int64) int64 { r := *p; *p += d; return r } +func PostIncUint8(p *uint8, d uint8) uint8 { r := *p; *p += d; return r } +func PostIncUint16(p *uint16, d uint16) uint16 { r := *p; *p += d; return r } +func PostIncUint32(p *uint32, d uint32) uint32 { r := *p; *p += d; return r } +func PostIncUint64(p *uint64, d uint64) uint64 { r := *p; *p += d; return r } +func PostIncFloat32(p *float32, d float32) float32 { r := *p; *p += d; return r } +func PostIncFloat64(p *float64, d float64) float64 { r := *p; *p += d; return r } +func PostIncComplex64(p *complex64, d complex64) complex64 { r := *p; *p += d; return r } +func PostIncComplex128(p *complex128, d complex128) complex128 { r := *p; *p += d; return r } +func PostIncUintptr(p *uintptr, d uintptr) uintptr { r := *p; *p += d; return r } + +func PostIncAtomicInt32(p *int32, d int32) int32 { return atomic.AddInt32(p, d) - d } +func PostIncAtomicInt64(p *int64, d int64) int64 { return atomic.AddInt64(p, d) - d } +func PostIncAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint32(p, d) - d } +func PostIncAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, d) - d } +func PostIncAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, d) - d } + +func PostIncAtomicInt32P(p uintptr, d int32) int32 { + return atomic.AddInt32((*int32)(unsafe.Pointer(p)), d) - d +} +func PostIncAtomicInt64P(p uintptr, d int64) int64 { + return atomic.AddInt64((*int64)(unsafe.Pointer(p)), d) - d +} +func PostIncAtomicUint32P(p uintptr, d uint32) uint32 { + return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), d) - d +} +func PostIncAtomicUint64P(p uintptr, d uint64) uint64 { + return atomic.AddUint64((*uint64)(unsafe.Pointer(p)), d) - d +} +func PostIncAtomicUintptrP(p uintptr, d uintptr) uintptr { + return atomic.AddUintptr((*uintptr)(unsafe.Pointer(p)), d) - d +} + +func PostDecInt8(p *int8, d int8) int8 { r := *p; *p -= d; return r } +func PostDecInt16(p *int16, d int16) int16 { r := *p; *p -= d; return r } +func PostDecInt32(p *int32, d int32) int32 { r := *p; *p -= d; return r } +func PostDecInt64(p *int64, d int64) int64 { r := *p; *p -= d; return r } +func PostDecUint8(p *uint8, d uint8) uint8 { r := *p; *p -= d; return r } +func PostDecUint16(p *uint16, d uint16) uint16 { r := *p; *p -= d; return r } +func PostDecUint32(p *uint32, d uint32) uint32 { r := *p; *p -= d; return r } +func PostDecUint64(p *uint64, d uint64) uint64 { r := *p; *p -= d; return r } +func PostDecFloat32(p *float32, d float32) float32 { r := *p; *p -= d; return r } +func PostDecFloat64(p *float64, d float64) float64 { r := *p; *p -= d; return r } +func PostDecComplex64(p *complex64, d complex64) complex64 { r := *p; *p -= d; return r } +func PostDecComplex128(p *complex128, d complex128) complex128 { r := *p; *p -= d; return r } +func PostDecUintptr(p *uintptr, d uintptr) uintptr { r := *p; *p -= d; return r } + +func PostDecAtomicInt32(p *int32, d int32) int32 { return atomic.AddInt32(p, -d) + d } +func PostDecAtomicInt64(p *int64, d int64) int64 { return atomic.AddInt64(p, -d) + d } +func PostDecAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint32(p, -d) + d } +func PostDecAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, -d) + d } +func PostDecAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, -d) + d } + +func Int8FromInt8(n int8) int8 { return n } +func Int8FromInt16(n int16) int8 { return int8(n) } +func Int8FromInt32(n int32) int8 { return int8(n) } +func Int8FromInt64(n int64) int8 { return int8(n) } +func Int8FromUint8(n uint8) int8 { return int8(n) } +func Int8FromUint16(n uint16) int8 { return int8(n) } +func Int8FromUint32(n uint32) int8 { return int8(n) } +func Int8FromUint64(n uint64) int8 { return int8(n) } +func Int8FromFloat32(n float32) int8 { return int8(n) } +func Int8FromFloat64(n float64) int8 { return int8(n) } +func Int8FromComplex64(n complex64) int8 { return int8(real(n)) } +func Int8FromComplex128(n complex128) int8 { return int8(real(n)) } +func Int8FromUintptr(n uintptr) int8 { return int8(n) } +func Int16FromInt8(n int8) int16 { return int16(n) } +func Int16FromInt16(n int16) int16 { return n } +func Int16FromInt32(n int32) int16 { return int16(n) } +func Int16FromInt64(n int64) int16 { return int16(n) } +func Int16FromUint8(n uint8) int16 { return int16(n) } +func Int16FromUint16(n uint16) int16 { return int16(n) } +func Int16FromUint32(n uint32) int16 { return int16(n) } +func Int16FromUint64(n uint64) int16 { return int16(n) } +func Int16FromFloat32(n float32) int16 { return int16(n) } +func Int16FromFloat64(n float64) int16 { return int16(n) } +func Int16FromComplex64(n complex64) int16 { return int16(real(n)) } +func Int16FromComplex128(n complex128) int16 { return int16(real(n)) } +func Int16FromUintptr(n uintptr) int16 { return int16(n) } +func Int32FromInt8(n int8) int32 { return int32(n) } +func Int32FromInt16(n int16) int32 { return int32(n) } +func Int32FromInt32(n int32) int32 { return n } +func Int32FromInt64(n int64) int32 { return int32(n) } +func Int32FromUint8(n uint8) int32 { return int32(n) } +func Int32FromUint16(n uint16) int32 { return int32(n) } +func Int32FromUint32(n uint32) int32 { return int32(n) } +func Int32FromUint64(n uint64) int32 { return int32(n) } +func Int32FromFloat32(n float32) int32 { return int32(n) } +func Int32FromFloat64(n float64) int32 { return int32(n) } +func Int32FromComplex64(n complex64) int32 { return int32(real(n)) } +func Int32FromComplex128(n complex128) int32 { return int32(real(n)) } +func Int32FromUintptr(n uintptr) int32 { return int32(n) } +func Int64FromInt8(n int8) int64 { return int64(n) } +func Int64FromInt16(n int16) int64 { return int64(n) } +func Int64FromInt32(n int32) int64 { return int64(n) } +func Int64FromInt64(n int64) int64 { return n } +func Int64FromUint8(n uint8) int64 { return int64(n) } +func Int64FromUint16(n uint16) int64 { return int64(n) } +func Int64FromUint32(n uint32) int64 { return int64(n) } +func Int64FromUint64(n uint64) int64 { return int64(n) } +func Int64FromFloat32(n float32) int64 { return int64(n) } +func Int64FromFloat64(n float64) int64 { return int64(n) } +func Int64FromComplex64(n complex64) int64 { return int64(real(n)) } +func Int64FromComplex128(n complex128) int64 { return int64(real(n)) } +func Int64FromUintptr(n uintptr) int64 { return int64(n) } +func Uint8FromInt8(n int8) uint8 { return uint8(n) } +func Uint8FromInt16(n int16) uint8 { return uint8(n) } +func Uint8FromInt32(n int32) uint8 { return uint8(n) } +func Uint8FromInt64(n int64) uint8 { return uint8(n) } +func Uint8FromUint8(n uint8) uint8 { return n } +func Uint8FromUint16(n uint16) uint8 { return uint8(n) } +func Uint8FromUint32(n uint32) uint8 { return uint8(n) } +func Uint8FromUint64(n uint64) uint8 { return uint8(n) } +func Uint8FromFloat32(n float32) uint8 { return uint8(n) } +func Uint8FromFloat64(n float64) uint8 { return uint8(n) } +func Uint8FromComplex64(n complex64) uint8 { return uint8(real(n)) } +func Uint8FromComplex128(n complex128) uint8 { return uint8(real(n)) } +func Uint8FromUintptr(n uintptr) uint8 { return uint8(n) } +func Uint16FromInt8(n int8) uint16 { return uint16(n) } +func Uint16FromInt16(n int16) uint16 { return uint16(n) } +func Uint16FromInt32(n int32) uint16 { return uint16(n) } +func Uint16FromInt64(n int64) uint16 { return uint16(n) } +func Uint16FromUint8(n uint8) uint16 { return uint16(n) } +func Uint16FromUint16(n uint16) uint16 { return n } +func Uint16FromUint32(n uint32) uint16 { return uint16(n) } +func Uint16FromUint64(n uint64) uint16 { return uint16(n) } +func Uint16FromFloat32(n float32) uint16 { return uint16(n) } +func Uint16FromFloat64(n float64) uint16 { return uint16(n) } +func Uint16FromComplex64(n complex64) uint16 { return uint16(real(n)) } +func Uint16FromComplex128(n complex128) uint16 { return uint16(real(n)) } +func Uint16FromUintptr(n uintptr) uint16 { return uint16(n) } +func Uint32FromInt8(n int8) uint32 { return uint32(n) } +func Uint32FromInt16(n int16) uint32 { return uint32(n) } +func Uint32FromInt32(n int32) uint32 { return uint32(n) } +func Uint32FromInt64(n int64) uint32 { return uint32(n) } +func Uint32FromUint8(n uint8) uint32 { return uint32(n) } +func Uint32FromUint16(n uint16) uint32 { return uint32(n) } +func Uint32FromUint32(n uint32) uint32 { return n } +func Uint32FromUint64(n uint64) uint32 { return uint32(n) } +func Uint32FromFloat32(n float32) uint32 { return uint32(n) } +func Uint32FromFloat64(n float64) uint32 { return uint32(n) } +func Uint32FromComplex64(n complex64) uint32 { return uint32(real(n)) } +func Uint32FromComplex128(n complex128) uint32 { return uint32(real(n)) } +func Uint32FromUintptr(n uintptr) uint32 { return uint32(n) } +func Uint64FromInt8(n int8) uint64 { return uint64(n) } +func Uint64FromInt16(n int16) uint64 { return uint64(n) } +func Uint64FromInt32(n int32) uint64 { return uint64(n) } +func Uint64FromInt64(n int64) uint64 { return uint64(n) } +func Uint64FromUint8(n uint8) uint64 { return uint64(n) } +func Uint64FromUint16(n uint16) uint64 { return uint64(n) } +func Uint64FromUint32(n uint32) uint64 { return uint64(n) } +func Uint64FromUint64(n uint64) uint64 { return n } +func Uint64FromFloat32(n float32) uint64 { return uint64(n) } +func Uint64FromFloat64(n float64) uint64 { return uint64(n) } +func Uint64FromComplex64(n complex64) uint64 { return uint64(real(n)) } +func Uint64FromComplex128(n complex128) uint64 { return uint64(real(n)) } +func Uint64FromUintptr(n uintptr) uint64 { return uint64(n) } +func Float32FromInt8(n int8) float32 { return float32(n) } +func Float32FromInt16(n int16) float32 { return float32(n) } +func Float32FromInt32(n int32) float32 { return float32(n) } +func Float32FromInt64(n int64) float32 { return float32(n) } +func Float32FromUint8(n uint8) float32 { return float32(n) } +func Float32FromUint16(n uint16) float32 { return float32(n) } +func Float32FromUint32(n uint32) float32 { return float32(n) } +func Float32FromUint64(n uint64) float32 { return float32(n) } +func Float32FromFloat32(n float32) float32 { return n } +func Float32FromFloat64(n float64) float32 { return float32(n) } +func Float32FromComplex64(n complex64) float32 { return real(n) } +func Float32FromComplex128(n complex128) float32 { return float32(real(n)) } +func Float32FromUintptr(n uintptr) float32 { return float32(n) } +func Float64FromInt8(n int8) float64 { return float64(n) } +func Float64FromInt16(n int16) float64 { return float64(n) } +func Float64FromInt32(n int32) float64 { return float64(n) } +func Float64FromInt64(n int64) float64 { return float64(n) } +func Float64FromUint8(n uint8) float64 { return float64(n) } +func Float64FromUint16(n uint16) float64 { return float64(n) } +func Float64FromUint32(n uint32) float64 { return float64(n) } +func Float64FromUint64(n uint64) float64 { return float64(n) } +func Float64FromFloat32(n float32) float64 { return float64(n) } +func Float64FromFloat64(n float64) float64 { return n } +func Float64FromComplex64(n complex64) float64 { return float64(real(n)) } +func Float64FromComplex128(n complex128) float64 { return real(n) } +func Float64FromUintptr(n uintptr) float64 { return float64(n) } +func Complex64FromInt8(n int8) complex64 { return complex(float32(n), 0) } +func Complex64FromInt16(n int16) complex64 { return complex(float32(n), 0) } +func Complex64FromInt32(n int32) complex64 { return complex(float32(n), 0) } +func Complex64FromInt64(n int64) complex64 { return complex(float32(n), 0) } +func Complex64FromUint8(n uint8) complex64 { return complex(float32(n), 0) } +func Complex64FromUint16(n uint16) complex64 { return complex(float32(n), 0) } +func Complex64FromUint32(n uint32) complex64 { return complex(float32(n), 0) } +func Complex64FromUint64(n uint64) complex64 { return complex(float32(n), 0) } +func Complex64FromFloat32(n float32) complex64 { return complex(n, 0) } +func Complex64FromFloat64(n float64) complex64 { return complex(float32(n), 0) } +func Complex64FromComplex64(n complex64) complex64 { return n } +func Complex64FromComplex128(n complex128) complex64 { return complex64(n) } +func Complex64FromUintptr(n uintptr) complex64 { return complex(float32(n), 0) } +func Complex128FromInt8(n int8) complex128 { return complex(float64(n), 0) } +func Complex128FromInt16(n int16) complex128 { return complex(float64(n), 0) } +func Complex128FromInt32(n int32) complex128 { return complex(float64(n), 0) } +func Complex128FromInt64(n int64) complex128 { return complex(float64(n), 0) } +func Complex128FromUint8(n uint8) complex128 { return complex(float64(n), 0) } +func Complex128FromUint16(n uint16) complex128 { return complex(float64(n), 0) } +func Complex128FromUint32(n uint32) complex128 { return complex(float64(n), 0) } +func Complex128FromUint64(n uint64) complex128 { return complex(float64(n), 0) } +func Complex128FromFloat32(n float32) complex128 { return complex(float64(n), 0) } +func Complex128FromFloat64(n float64) complex128 { return complex(n, 0) } +func Complex128FromComplex64(n complex64) complex128 { return complex128(n) } +func Complex128FromComplex128(n complex128) complex128 { return n } +func Complex128FromUintptr(n uintptr) complex128 { return complex(float64(n), 0) } +func UintptrFromInt8(n int8) uintptr { return uintptr(n) } +func UintptrFromInt16(n int16) uintptr { return uintptr(n) } +func UintptrFromInt32(n int32) uintptr { return uintptr(n) } +func UintptrFromInt64(n int64) uintptr { return uintptr(n) } +func UintptrFromUint8(n uint8) uintptr { return uintptr(n) } +func UintptrFromUint16(n uint16) uintptr { return uintptr(n) } +func UintptrFromUint32(n uint32) uintptr { return uintptr(n) } +func UintptrFromUint64(n uint64) uintptr { return uintptr(n) } +func UintptrFromFloat32(n float32) uintptr { return uintptr(n) } +func UintptrFromFloat64(n float64) uintptr { return uintptr(n) } +func UintptrFromComplex64(n complex64) uintptr { return uintptr(real(n)) } +func UintptrFromComplex128(n complex128) uintptr { return uintptr(real(n)) } +func UintptrFromUintptr(n uintptr) uintptr { return n } + +func Int8(n int8) int8 { return n } +func Int16(n int16) int16 { return n } +func Int32(n int32) int32 { return n } +func Int64(n int64) int64 { return n } +func Uint8(n uint8) uint8 { return n } +func Uint16(n uint16) uint16 { return n } +func Uint32(n uint32) uint32 { return n } +func Uint64(n uint64) uint64 { return n } +func Float32(n float32) float32 { return n } +func Float64(n float64) float64 { return n } +func Complex64(n complex64) complex64 { return n } +func Complex128(n complex128) complex128 { return n } +func Uintptr(n uintptr) uintptr { return n } + +func NegInt8(n int8) int8 { return -n } +func NegInt16(n int16) int16 { return -n } +func NegInt32(n int32) int32 { return -n } +func NegInt64(n int64) int64 { return -n } +func NegUint8(n uint8) uint8 { return -n } +func NegUint16(n uint16) uint16 { return -n } +func NegUint32(n uint32) uint32 { return -n } +func NegUint64(n uint64) uint64 { return -n } +func NegUintptr(n uintptr) uintptr { return -n } + +func CplInt8(n int8) int8 { return ^n } +func CplInt16(n int16) int16 { return ^n } +func CplInt32(n int32) int32 { return ^n } +func CplInt64(n int64) int64 { return ^n } +func CplUint8(n uint8) uint8 { return ^n } +func CplUint16(n uint16) uint16 { return ^n } +func CplUint32(n uint32) uint32 { return ^n } +func CplUint64(n uint64) uint64 { return ^n } +func CplUintptr(n uintptr) uintptr { return ^n } + +func BoolInt8(b bool) int8 { + if b { + return 1 + } + return 0 +} + +func BoolInt16(b bool) int16 { + if b { + return 1 + } + return 0 +} + +func BoolInt32(b bool) int32 { + if b { + return 1 + } + return 0 +} + +func BoolInt64(b bool) int64 { + if b { + return 1 + } + return 0 +} + +func BoolUint8(b bool) uint8 { + if b { + return 1 + } + return 0 +} + +func BoolUint16(b bool) uint16 { + if b { + return 1 + } + return 0 +} + +func BoolUint32(b bool) uint32 { + if b { + return 1 + } + return 0 +} + +func BoolUint64(b bool) uint64 { + if b { + return 1 + } + return 0 +} + +func BoolUintptr(b bool) uintptr { + if b { + return 1 + } + return 0 +} + +func SetBitFieldPtr8Int8(p uintptr, v int8, off int, mask uint8) { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^mask | uint8(v)<> s +} + +func AssignBitFieldPtr8Int16(p uintptr, v int16, w, off int, mask uint8) int16 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^mask | uint8(v)<> s +} + +func AssignBitFieldPtr8Int32(p uintptr, v int32, w, off int, mask uint8) int32 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^mask | uint8(v)<> s +} + +func AssignBitFieldPtr8Int64(p uintptr, v int64, w, off int, mask uint8) int64 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^mask | uint8(v)<> s +} + +func AssignBitFieldPtr16Int8(p uintptr, v int8, w, off int, mask uint16) int8 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^mask | uint16(v)<> s +} + +func AssignBitFieldPtr16Int16(p uintptr, v int16, w, off int, mask uint16) int16 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^mask | uint16(v)<> s +} + +func AssignBitFieldPtr16Int32(p uintptr, v int32, w, off int, mask uint16) int32 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^mask | uint16(v)<> s +} + +func AssignBitFieldPtr16Int64(p uintptr, v int64, w, off int, mask uint16) int64 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^mask | uint16(v)<> s +} + +func AssignBitFieldPtr32Int8(p uintptr, v int8, w, off int, mask uint32) int8 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^mask | uint32(v)<> s +} + +func AssignBitFieldPtr32Int16(p uintptr, v int16, w, off int, mask uint32) int16 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^mask | uint32(v)<> s +} + +func AssignBitFieldPtr32Int32(p uintptr, v int32, w, off int, mask uint32) int32 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^mask | uint32(v)<> s +} + +func AssignBitFieldPtr32Int64(p uintptr, v int64, w, off int, mask uint32) int64 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^mask | uint32(v)<> s +} + +func AssignBitFieldPtr64Int8(p uintptr, v int8, w, off int, mask uint64) int8 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^mask | uint64(v)<> s +} + +func AssignBitFieldPtr64Int16(p uintptr, v int16, w, off int, mask uint64) int16 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^mask | uint64(v)<> s +} + +func AssignBitFieldPtr64Int32(p uintptr, v int32, w, off int, mask uint64) int32 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^mask | uint64(v)<> s +} + +func AssignBitFieldPtr64Int64(p uintptr, v int64, w, off int, mask uint64) int64 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^mask | uint64(v)<> s +} + +func AssignBitFieldPtr8Uint8(p uintptr, v uint8, w, off int, mask uint8) uint8 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^mask | v<> off) +} + +func AssignBitFieldPtr8Uint16(p uintptr, v uint16, w, off int, mask uint8) uint16 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^mask | uint8(v)<>off) +} + +func AssignBitFieldPtr8Uint32(p uintptr, v uint32, w, off int, mask uint8) uint32 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^mask | uint8(v)<>off) +} + +func AssignBitFieldPtr8Uint64(p uintptr, v uint64, w, off int, mask uint8) uint64 { + *(*uint8)(unsafe.Pointer(p)) = *(*uint8)(unsafe.Pointer(p))&^mask | uint8(v)<>off) +} + +func AssignBitFieldPtr16Uint8(p uintptr, v uint8, w, off int, mask uint16) uint8 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^mask | uint16(v)<>off) +} + +func AssignBitFieldPtr16Uint16(p uintptr, v uint16, w, off int, mask uint16) uint16 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^mask | v<> off) +} + +func AssignBitFieldPtr16Uint32(p uintptr, v uint32, w, off int, mask uint16) uint32 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^mask | uint16(v)<>off) +} + +func AssignBitFieldPtr16Uint64(p uintptr, v uint64, w, off int, mask uint16) uint64 { + *(*uint16)(unsafe.Pointer(p)) = *(*uint16)(unsafe.Pointer(p))&^mask | uint16(v)<>off) +} + +func AssignBitFieldPtr32Uint8(p uintptr, v uint8, w, off int, mask uint32) uint8 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^mask | uint32(v)<>off) +} + +func AssignBitFieldPtr32Uint16(p uintptr, v uint16, w, off int, mask uint32) uint16 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^mask | uint32(v)<>off) +} + +func AssignBitFieldPtr32Uint32(p uintptr, v uint32, w, off int, mask uint32) uint32 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^mask | v<> off) +} + +func AssignBitFieldPtr32Uint64(p uintptr, v uint64, w, off int, mask uint32) uint64 { + *(*uint32)(unsafe.Pointer(p)) = *(*uint32)(unsafe.Pointer(p))&^mask | uint32(v)<>off) +} + +func AssignBitFieldPtr64Uint8(p uintptr, v uint8, w, off int, mask uint64) uint8 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^mask | uint64(v)<>off) +} + +func AssignBitFieldPtr64Uint16(p uintptr, v uint16, w, off int, mask uint64) uint16 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^mask | uint64(v)<>off) +} + +func AssignBitFieldPtr64Uint32(p uintptr, v uint32, w, off int, mask uint64) uint32 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^mask | uint64(v)<>off) +} + +func AssignBitFieldPtr64Uint64(p uintptr, v uint64, w, off int, mask uint64) uint64 { + *(*uint64)(unsafe.Pointer(p)) = *(*uint64)(unsafe.Pointer(p))&^mask | v<> off) +} + +func PostDecBitFieldPtr8Int8(p uintptr, d int8, w, off int, mask uint8) (r int8) { + x0 := *(*uint8)(unsafe.Pointer(p)) + s := 8 - w - off + r = int8(x0) & int8(mask) << s >> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r-d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r-d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r-d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r-d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r-d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r-d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r-d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r-d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r-d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r-d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r-d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r-d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r-d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r-d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r-d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r-d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | (r-d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r-d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r-d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r-d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r-d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | (r-d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r-d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r-d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r-d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r-d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | (r-d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r-d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r-d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r-d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r-d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | (r-d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r+d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r+d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r+d)<> (s + off) + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r+d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r+d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r+d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r+d)<> (s + off) + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r+d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r+d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r+d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r+d)<> (s + off) + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r+d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r+d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r+d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r+d)<> (s + off) + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r+d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | (r+d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r+d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r+d)<> off + *(*uint8)(unsafe.Pointer(p)) = x0&^mask | uint8(r+d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r+d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | (r+d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r+d)<> off + *(*uint16)(unsafe.Pointer(p)) = x0&^mask | uint16(r+d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r+d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r+d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | (r+d)<> off + *(*uint32)(unsafe.Pointer(p)) = x0&^mask | uint32(r+d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r+d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r+d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | uint64(r+d)<> off + *(*uint64)(unsafe.Pointer(p)) = x0&^mask | (r+d)<= '0' && c <= '9': + format++ + digit = int(c) - '0' + } + width0 := width + width = 10*width + digit + if width < width0 { + panic(todo("")) + } + } + case 'h', 'j', 'l', 'L', 'q', 't', 'z': + format, mod = parseLengthModifier(format) + default: + break flags + } + } + + // A conversion specifier that specifies the type of input conversion to be + // performed. + switch c := *(*byte)(unsafe.Pointer(format)); c { + case '%': + // Matches a literal '%'. That is, %% in the format string matches a single + // input '%' character. No conversion is done (but initial white space + // characters are discarded), and assign‐ ment does not occur. + format++ + skipReaderWhiteSpace(r) + c, err := r.ReadByte() + if err != nil { + return format, -1, false + } + + if c == '%' { + return format, 1, true + } + + r.UnreadByte() + return format, 0, false + case 'd': + // Matches an optionally signed decimal integer; the next pointer must be a + // pointer to int. + format++ + skipReaderWhiteSpace(r) + var digit, n uint64 + allowSign := true + neg := false + dec: + for ; width != 0; width-- { + c, err := r.ReadByte() + if err != nil { + if match { + break dec + } + + return 0, 0, false + } + + if allowSign { + switch c { + case '-': + allowSign = false + neg = true + continue + case '+': + allowSign = false + continue + } + } + + switch { + case c >= '0' && c <= '9': + digit = uint64(c) - '0' + default: + r.UnreadByte() + break dec + } + match = true + n0 := n + n = n*10 + digit + if n < n0 { + panic(todo("")) + } + } + if !match { + break + } + + if !discard { + arg := VaUintptr(args) + v := int64(n) + if neg { + v = -v + } + switch mod { + case modNone: + *(*int32)(unsafe.Pointer(arg)) = int32(v) + case modH: + *(*int16)(unsafe.Pointer(arg)) = int16(v) + case modHH: + *(*int8)(unsafe.Pointer(arg)) = int8(v) + case modL: + *(*long)(unsafe.Pointer(arg)) = long(v) + case modLL: + *(*int64)(unsafe.Pointer(arg)) = int64(v) + default: + panic(todo("", mod)) + } + } + nvalues = 1 + case 'D': + // Equivalent to ld; this exists only for backward compatibility. (Note: + // thus only in libc4. In libc5 and glibc the %D is silently ignored, causing + // old programs to fail mysteriously.) + format++ + panic(todo("")) + case 'i': + // Matches an optionally signed integer; the next pointer must be a pointer to + // int. The integer is read in base 16 if it begins with 0x or 0X, in base 8 + // if it begins with 0, and in base 10 otherwise. Only characters that + // correspond to the base are used. + format++ + panic(todo("")) + case 'o': + // Matches an unsigned octal integer; the next pointer must be a pointer to + // unsigned int. + format++ + panic(todo("")) + case 'u': + // Matches an unsigned decimal integer; the next pointer must be a pointer to + // unsigned int. + format++ + panic(todo("")) + case 'x', 'X': + // Matches an unsigned hexadecimal integer; the next pointer must be a pointer + // to unsigned int. + format++ + skipReaderWhiteSpace(r) + var digit, n uint64 + allowPrefix := true + var b []byte + hex: + for ; width != 0; width-- { + c, err := r.ReadByte() + if err != nil { + if match || err == io.EOF { + break hex + } + + panic(todo("", err)) + } + + if allowPrefix { + if len(b) == 1 && b[0] == '0' && (c == 'x' || c == 'X') { + allowPrefix = false + match = false + b = nil + continue + } + + b = append(b, c) + } + + switch { + case c >= '0' && c <= '9': + digit = uint64(c) - '0' + case c >= 'a' && c <= 'f': + digit = uint64(c) - 'a' + 10 + case c >= 'A' && c <= 'F': + digit = uint64(c) - 'A' + 10 + default: + r.UnreadByte() + break hex + } + match = true + n0 := n + n = n<<4 + digit + if n < n0 { + panic(todo("")) + } + } + if !match { + break + } + + if !discard { + arg := VaUintptr(args) + switch mod { + case modNone: + *(*uint32)(unsafe.Pointer(arg)) = uint32(n) + case modH: + *(*uint16)(unsafe.Pointer(arg)) = uint16(n) + case modHH: + *(*byte)(unsafe.Pointer(arg)) = byte(n) + case modL: + *(*ulong)(unsafe.Pointer(arg)) = ulong(n) + default: + panic(todo("")) + } + } + nvalues = 1 + case 'f', 'e', 'g', 'E', 'a': + // Matches an optionally signed floating-point number; the next pointer must be + // a pointer to float. + format++ + skipReaderWhiteSpace(r) + seq := fpLiteral(r) + if len(seq) == 0 { + return 0, 0, false + } + + var neg bool + switch seq[0] { + case '+': + seq = seq[1:] + case '-': + neg = true + seq = seq[1:] + } + n, err := strconv.ParseFloat(string(seq), 64) + if err != nil { + panic(todo("", err)) + } + + if !discard { + arg := VaUintptr(args) + if neg { + n = -n + } + switch mod { + case modNone: + *(*float32)(unsafe.Pointer(arg)) = float32(n) + case modL: + *(*float64)(unsafe.Pointer(arg)) = n + default: + panic(todo("", mod, neg, n)) + } + } + return format, 1, true + case 's': + // Matches a sequence of non-white-space characters; the next pointer must be + // a pointer to the initial element of a character array that is long enough to + // hold the input sequence and the terminating null byte ('\0'), which is added + // automatically. The input string stops at white space or at the maximum + // field width, whichever occurs first. + var c byte + var err error + var arg uintptr + if !discard { + arg = VaUintptr(args) + } + scans: + for ; width != 0; width-- { + if c, err = r.ReadByte(); err != nil { + if err != io.EOF { + nvalues = -1 + } + break scans + } + + switch c { + case ' ', '\t', '\n', '\r', '\v', '\f': + break scans + } + + nvalues = 1 + match = true + if !discard { + *(*byte)(unsafe.Pointer(arg)) = c + arg++ + } + } + if match { + switch { + case width == 0: + r.UnreadByte() + fallthrough + default: + if !discard { + *(*byte)(unsafe.Pointer(arg)) = 0 + } + } + } + case 'c': + // Matches a sequence of characters whose length is specified by the maximum + // field width (default 1); the next pointer must be a pointer to char, and + // there must be enough room for all the characters (no terminating null byte + // is added). The usual skip of leading white space is suppressed. To skip + // white space first, use an explicit space in the format. + format++ + panic(todo("")) + case '[': + // Matches a nonempty sequence of characters from the specified set of + // accepted characters; the next pointer must be a pointer to char, and there + // must be enough room for all the char‐ acters in the string, plus a + // terminating null byte. The usual skip of leading white space is suppressed. + // The string is to be made up of characters in (or not in) a particular set; + // the set is defined by the characters between the open bracket [ character + // and a close bracket ] character. The set excludes those characters if the + // first character after the open bracket is a circumflex (^). To include a + // close bracket in the set, make it the first character after the open bracket + // or the circumflex; any other position will end the set. The hyphen + // character - is also special; when placed between two other characters, it + // adds all intervening characters to the set. To include a hyphen, make it + // the last character before the final close bracket. For instance, [^]0-9-] + // means the set "everything except close bracket, zero through nine, and + // hyphen". The string ends with the appearance of a character not in the + // (or, with a circumflex, in) set or when the field width runs out. + format++ + var re0 []byte + bracket: + for i := 0; ; i++ { + c := *(*byte)(unsafe.Pointer(format)) + format++ + if c == ']' && i != 0 { + break bracket + } + + re0 = append(re0, c) + } + set := map[byte]struct{}{} + re := string(re0) + neg := strings.HasPrefix(re, "^") + if neg { + re = re[1:] + } + for len(re) != 0 { + switch { + case len(re) >= 3 && re[1] == '-': + for c := re[0]; c <= re[2]; c++ { + set[c] = struct{}{} + } + re = re[3:] + default: + set[c] = struct{}{} + re = re[1:] + } + } + var arg uintptr + if !discard { + arg = VaUintptr(args) + } + for ; width != 0; width-- { + c, err := r.ReadByte() + if err != nil { + if err == io.EOF { + return format, nvalues, match + } + + return format, -1, match + } + + if _, ok := set[c]; ok == !neg { + match = true + nvalues = 1 + if !discard { + *(*byte)(unsafe.Pointer(arg)) = c + arg++ + } + } + } + if match { + switch { + case width == 0: + r.UnreadByte() + fallthrough + default: + if !discard { + *(*byte)(unsafe.Pointer(arg)) = 0 + } + } + } + case 'p': + // Matches a pointer value (as printed by %p in printf(3); the next pointer + // must be a pointer to a pointer to void. + format++ + skipReaderWhiteSpace(r) + c, err := r.ReadByte() + if err != nil { + panic(todo("", err)) + } + + if c == '0' { + if c, err = r.ReadByte(); err != nil { + panic(todo("", err)) + } + + if c != 'x' && c != 'X' { + r.UnreadByte() + } + } + + var digit, n uint64 + ptr: + for ; width != 0; width-- { + c, err := r.ReadByte() + if err != nil { + if match { + break ptr + } + + panic(todo("")) + } + + switch { + case c >= '0' && c <= '9': + digit = uint64(c) - '0' + case c >= 'a' && c <= 'f': + digit = uint64(c) - 'a' + 10 + case c >= 'A' && c <= 'F': + digit = uint64(c) - 'A' + 10 + default: + r.UnreadByte() + break ptr + } + match = true + n0 := n + n = n<<4 + digit + if n < n0 { + panic(todo("")) + } + } + if !match { + break + } + + if !discard { + arg := VaUintptr(args) + *(*uintptr)(unsafe.Pointer(arg)) = uintptr(n) + } + nvalues = 1 + case 'n': + // Nothing is expected; instead, the number of characters consumed thus far + // from the input is stored through the next pointer, which must be a pointer + // to int. This is not a conversion and does not increase the count returned + // by the function. The assignment can be suppressed with the * + // assignment-suppression character, but the effect on the return value is + // undefined. Therefore %*n conversions should not be used. + format++ + panic(todo("")) + default: + panic(todo("%#U", c)) + } + + return format, nvalues, match +} + +func skipReaderWhiteSpace(r io.ByteScanner) error { + for { + c, err := r.ReadByte() + if err != nil { + return err + } + + switch c { + case ' ', '\t', '\n', '\r', '\v', '\f': + // ok + default: + r.UnreadByte() + return nil + } + } +} + +func skipWhiteSpace(s uintptr) uintptr { + for { + switch c := *(*byte)(unsafe.Pointer(s)); c { + case ' ', '\t', '\n', '\r', '\v', '\f': + s++ + default: + return s + } + } +} + +// [-+]?([0-9]*[.])?[0-9]+([eE][-+]?\d+)? +func fpLiteral(rd io.ByteScanner) (seq []byte) { + const endOfText = 0x110000 + var pos, width, length int + + defer func() { + if len(seq) > length { + rd.UnreadByte() + seq = seq[:len(seq)-1] + } + }() + + var r rune + step := func(pos int) (rune, int) { + b, err := rd.ReadByte() + if err != nil { + return endOfText, 0 + } + + seq = append(seq, b) + return rune(b), 1 + } + move := func() { + pos += width + if r != endOfText { + r, width = step(pos + width) + } + } + accept := func(x rune) bool { + if r == x { + move() + return true + } + return false + } + accept2 := func(x rune) bool { + if r <= x { + move() + return true + } + return false + } + r = endOfText + width = 0 + r, width = step(pos) + if accept('.') { + goto l7 + } + if accept('+') { + goto l30 + } + if accept('-') { + goto l30 + } + if r < '0' { + goto l4out + } + if accept2('9') { + goto l35 + } +l4out: + return seq +l7: + if r < '0' { + goto l7out + } + if accept2('9') { + goto l10 + } +l7out: + return seq +l10: + length = pos + if accept('E') { + goto l18 + } + if accept('e') { + goto l18 + } + if r < '0' { + goto l15out + } + if accept2('9') { + goto l10 + } +l15out: + return seq +l18: + if accept('+') { + goto l23 + } + if accept('-') { + goto l23 + } + if r < '0' { + goto l20out + } + if accept2('9') { + goto l26 + } +l20out: + return seq +l23: + if r < '0' { + goto l23out + } + if accept2('9') { + goto l26 + } +l23out: + return seq +l26: + length = pos + if r < '0' { + goto l27out + } + if accept2('9') { + goto l26 + } +l27out: + return seq +l30: + if accept('.') { + goto l7 + } + if r < '0' { + goto l32out + } + if accept2('9') { + goto l35 + } +l32out: + return seq +l35: + length = pos + if accept('.') { + goto l7 + } + if accept('E') { + goto l18 + } + if accept('e') { + goto l18 + } + if r < '0' { + goto l42out + } + if accept2('9') { + goto l35 + } +l42out: + return seq +} diff --git a/internal/libc/signal/capi_darwin_amd64.go b/internal/libc/signal/capi_darwin_amd64.go new file mode 100644 index 0000000..3c592eb --- /dev/null +++ b/internal/libc/signal/capi_darwin_amd64.go @@ -0,0 +1,8 @@ +// Code generated by 'ccgo signal/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o signal/signal_darwin_amd64.go -pkgname signal', DO NOT EDIT. + +package signal + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, + "__sigbits": {}, +} diff --git a/internal/libc/signal/capi_darwin_arm64.go b/internal/libc/signal/capi_darwin_arm64.go new file mode 100644 index 0000000..e203423 --- /dev/null +++ b/internal/libc/signal/capi_darwin_arm64.go @@ -0,0 +1,8 @@ +// Code generated by 'ccgo signal/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o signal/signal_darwin_arm64.go -pkgname signal', DO NOT EDIT. + +package signal + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, + "__sigbits": {}, +} diff --git a/internal/libc/signal/capi_linux_amd64.go b/internal/libc/signal/capi_linux_amd64.go new file mode 100644 index 0000000..20eeb2d --- /dev/null +++ b/internal/libc/signal/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo signal/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o signal/signal_linux_amd64.go -pkgname signal', DO NOT EDIT. + +package signal + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/signal/capi_linux_arm64.go b/internal/libc/signal/capi_linux_arm64.go new file mode 100644 index 0000000..a55b1d4 --- /dev/null +++ b/internal/libc/signal/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo signal/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o signal/signal_linux_arm64.go -pkgname signal', DO NOT EDIT. + +package signal + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/signal/more_darwin_amd64.go b/internal/libc/signal/more_darwin_amd64.go new file mode 100644 index 0000000..25cc318 --- /dev/null +++ b/internal/libc/signal/more_darwin_amd64.go @@ -0,0 +1,12 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package signal + +const ( + // /usr/include/asm-generic/signal-defs.h:24:#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ + SIG_DFL = 0 + // /usr/include/asm-generic/signal-defs.h:25:#define SIG_IGN ((__sighandler_t)1) /* ignore signal */ + SIG_IGN = 1 +) diff --git a/internal/libc/signal/more_darwin_arm64.go b/internal/libc/signal/more_darwin_arm64.go new file mode 100644 index 0000000..25cc318 --- /dev/null +++ b/internal/libc/signal/more_darwin_arm64.go @@ -0,0 +1,12 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package signal + +const ( + // /usr/include/asm-generic/signal-defs.h:24:#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ + SIG_DFL = 0 + // /usr/include/asm-generic/signal-defs.h:25:#define SIG_IGN ((__sighandler_t)1) /* ignore signal */ + SIG_IGN = 1 +) diff --git a/internal/libc/signal/more_linux_amd64.go b/internal/libc/signal/more_linux_amd64.go new file mode 100644 index 0000000..25cc318 --- /dev/null +++ b/internal/libc/signal/more_linux_amd64.go @@ -0,0 +1,12 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package signal + +const ( + // /usr/include/asm-generic/signal-defs.h:24:#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ + SIG_DFL = 0 + // /usr/include/asm-generic/signal-defs.h:25:#define SIG_IGN ((__sighandler_t)1) /* ignore signal */ + SIG_IGN = 1 +) diff --git a/internal/libc/signal/more_linux_arm64.go b/internal/libc/signal/more_linux_arm64.go new file mode 100644 index 0000000..25cc318 --- /dev/null +++ b/internal/libc/signal/more_linux_arm64.go @@ -0,0 +1,12 @@ +// Copyright 2020 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package signal + +const ( + // /usr/include/asm-generic/signal-defs.h:24:#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ + SIG_DFL = 0 + // /usr/include/asm-generic/signal-defs.h:25:#define SIG_IGN ((__sighandler_t)1) /* ignore signal */ + SIG_IGN = 1 +) diff --git a/internal/libc/signal/signal_darwin_amd64.go b/internal/libc/signal/signal_darwin_amd64.go new file mode 100644 index 0000000..be18efa --- /dev/null +++ b/internal/libc/signal/signal_darwin_amd64.go @@ -0,0 +1,4796 @@ +// Code generated by 'ccgo signal/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o signal/signal_darwin_amd64.go -pkgname signal', DO NOT EDIT. + +package signal + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BUS_ADRALN = 1 // signal.h:241:1: + BUS_ADRERR = 2 // signal.h:242:1: + BUS_NOOP = 0 // signal.h:239:1: + BUS_OBJERR = 3 // signal.h:243:1: + CLD_CONTINUED = 6 // signal.h:258:1: + CLD_DUMPED = 3 // signal.h:255:1: + CLD_EXITED = 1 // signal.h:253:1: + CLD_KILLED = 2 // signal.h:254:1: + CLD_NOOP = 0 // signal.h:251:1: + CLD_STOPPED = 5 // signal.h:257:1: + CLD_TRAPPED = 4 // signal.h:256:1: + FPE_FLTDIV = 1 // signal.h:221:1: + FPE_FLTINV = 5 // signal.h:225:1: + FPE_FLTOVF = 2 // signal.h:222:1: + FPE_FLTRES = 4 // signal.h:224:1: + FPE_FLTSUB = 6 // signal.h:226:1: + FPE_FLTUND = 3 // signal.h:223:1: + FPE_INTDIV = 7 // signal.h:227:1: + FPE_INTOVF = 8 // signal.h:228:1: + FPE_NOOP = 0 // signal.h:219:1: + FP_CHOP = 3 // _structs.h:112:1: + FP_PREC_24B = 0 // _structs.h:103:1: + FP_PREC_53B = 2 // _structs.h:104:1: + FP_PREC_64B = 3 // _structs.h:105:1: + FP_RND_DOWN = 1 // _structs.h:110:1: + FP_RND_NEAR = 0 // _structs.h:109:1: + FP_RND_UP = 2 // _structs.h:111:1: + FP_STATE_BYTES = 512 // _structs.h:276:1: + ILL_BADSTK = 8 // signal.h:215:1: + ILL_COPROC = 7 // signal.h:214:1: + ILL_ILLADR = 5 // signal.h:212:1: + ILL_ILLOPC = 1 // signal.h:208:1: + ILL_ILLOPN = 4 // signal.h:211:1: + ILL_ILLTRP = 2 // signal.h:209:1: + ILL_NOOP = 0 // signal.h:206:1: + ILL_PRVOPC = 3 // signal.h:210:1: + ILL_PRVREG = 6 // signal.h:213:1: + MINSIGSTKSZ = 32768 // signal.h:340:1: + NSIG = 32 // signal.h:79:1: + POLL_ERR = 4 // signal.h:264:1: + POLL_HUP = 6 // signal.h:266:1: + POLL_IN = 1 // signal.h:261:1: + POLL_MSG = 3 // signal.h:263:1: + POLL_OUT = 2 // signal.h:262:1: + POLL_PRI = 5 // signal.h:265:1: + SA_64REGSET = 0x0200 // signal.h:308:1: + SA_NOCLDSTOP = 0x0008 // signal.h:301:1: + SA_NOCLDWAIT = 0x0020 // signal.h:303:1: + SA_NODEFER = 0x0010 // signal.h:302:1: + SA_ONSTACK = 0x0001 // signal.h:298:1: + SA_RESETHAND = 0x0004 // signal.h:300:1: + SA_RESTART = 0x0002 // signal.h:299:1: + SA_SIGINFO = 0x0040 // signal.h:304:1: + SA_USERSPACE_MASK = 127 // signal.h:314:1: + SA_USERTRAMP = 0x0100 // signal.h:306:1: + SEGV_ACCERR = 2 // signal.h:235:1: + SEGV_MAPERR = 1 // signal.h:234:1: + SEGV_NOOP = 0 // signal.h:232:1: + SIGABRT = 6 // signal.h:89:1: + SIGALRM = 14 // signal.h:102:1: + SIGBUS = 10 // signal.h:98:1: + SIGCHLD = 20 // signal.h:108:1: + SIGCONT = 19 // signal.h:107:1: + SIGEMT = 7 // signal.h:94:1: + SIGEV_NONE = 0 // signal.h:164:1: + SIGEV_SIGNAL = 1 // signal.h:165:1: + SIGEV_THREAD = 3 // signal.h:166:1: + SIGFPE = 8 // signal.h:96:1: + SIGHUP = 1 // signal.h:84:1: + SIGILL = 4 // signal.h:87:1: + SIGINFO = 29 // signal.h:120:1: + SIGINT = 2 // signal.h:85:1: + SIGIO = 23 // signal.h:112:1: + SIGIOT = 6 // signal.h:93:1: + SIGKILL = 9 // signal.h:97:1: + SIGPIPE = 13 // signal.h:101:1: + SIGPROF = 27 // signal.h:117:1: + SIGQUIT = 3 // signal.h:86:1: + SIGSEGV = 11 // signal.h:99:1: + SIGSTKSZ = 131072 // signal.h:341:1: + SIGSTOP = 17 // signal.h:105:1: + SIGSYS = 12 // signal.h:100:1: + SIGTERM = 15 // signal.h:103:1: + SIGTRAP = 5 // signal.h:88:1: + SIGTSTP = 18 // signal.h:106:1: + SIGTTIN = 21 // signal.h:109:1: + SIGTTOU = 22 // signal.h:110:1: + SIGURG = 16 // signal.h:104:1: + SIGUSR1 = 30 // signal.h:122:1: + SIGUSR2 = 31 // signal.h:123:1: + SIGVTALRM = 26 // signal.h:116:1: + SIGWINCH = 28 // signal.h:119:1: + SIGXCPU = 24 // signal.h:114:1: + SIGXFSZ = 25 // signal.h:115:1: + SIG_BLOCK = 1 // signal.h:319:1: + SIG_SETMASK = 3 // signal.h:321:1: + SIG_UNBLOCK = 2 // signal.h:320:1: + SI_ASYNCIO = 0x10004 // signal.h:327:1: + SI_MESGQ = 0x10005 // signal.h:328:1: + SI_QUEUE = 0x10002 // signal.h:325:1: + SI_TIMER = 0x10003 // signal.h:326:1: + SI_USER = 0x10001 // signal.h:324:1: + SS_DISABLE = 0x0004 // signal.h:339:1: + SS_ONSTACK = 0x0001 // signal.h:338:1: + SV_INTERRUPT = 2 // signal.h:355:1: + SV_NOCLDSTOP = 8 // signal.h:358:1: + SV_NODEFER = 16 // signal.h:357:1: + SV_ONSTACK = 1 // signal.h:354:1: + SV_RESETHAND = 4 // signal.h:356:1: + SV_SIGINFO = 64 // signal.h:359:1: + TRAP_BRKPT = 1 // signal.h:246:1: + TRAP_TRACE = 2 // signal.h:247:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_SIGNAL_H_ = 0 // signal.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_I386_SIGNAL_H_ = 1 // signal.h:34:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MACH_I386__STRUCTS_H_ = 0 // _structs.h:33:1: + X_MACH_MACHINE__STRUCTS_H_ = 0 // _structs.h:30:1: + X_MCONTEXT_T = 0 // _mcontext.h:202:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_SIGSET_T = 0 // _sigset_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS_SIGNAL_H_ = 0 // signal.h:70:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USER_SIGNAL_H = 0 // signal.h:59:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)signal.h 8.3 (Berkeley) 3/30/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 1991, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)signal.h 8.2 (Berkeley) 1/21/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1992 NeXT Computer, Inc. +// + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +type Sig_atomic_t = int32 /* signal.h:39:13 */ + +// Language spec sez we must list exactly one parameter, even though we +// actually supply three. Ugh! +// SIG_HOLD is chosen to avoid KERN_SIG_* values in + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004-2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// @OSF_COPYRIGHT@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +// i386 is the structure that is exported to user threads for +// use in status/mutate calls. This structure should never change. +// + +type X__darwin_i386_thread_state = struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 +} /* _structs.h:46:1 */ + +// This structure should be double-word aligned for performance + +type X__darwin_fp_control = struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ +} /* _structs.h:92:1 */ + +type X__darwin_fp_control_t = X__darwin_fp_control /* _structs.h:117:28 */ + +// Status word. + +type X__darwin_fp_status = struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ +} /* _structs.h:150:1 */ + +type X__darwin_fp_status_t = X__darwin_fp_status /* _structs.h:167:27 */ + +// defn of 80bit x87 FPU or MMX register + +type X__darwin_mmst_reg = struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 +} /* _structs.h:194:1 */ + +// defn of 128 bit XMM regs + +type X__darwin_xmm_reg = struct{ F__xmm_reg [16]int8 } /* _structs.h:213:1 */ + +// defn of 256 bit YMM regs + +type X__darwin_ymm_reg = struct{ F__ymm_reg [32]int8 } /* _structs.h:229:1 */ + +// defn of 512 bit ZMM regs + +type X__darwin_zmm_reg = struct{ F__zmm_reg [64]int8 } /* _structs.h:245:1 */ + +type X__darwin_opmask_reg = struct{ F__opmask_reg [8]int8 } /* _structs.h:259:1 */ + +// Floating point state. + +type X__darwin_i386_float_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 +} /* _structs.h:281:1 */ + +type X__darwin_i386_avx_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } +} /* _structs.h:318:1 */ + +type X__darwin_i386_avx512_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } +} /* _structs.h:364:1 */ + +type X__darwin_i386_exception_state = struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint32_t +} /* _structs.h:575:1 */ + +type X__darwin_x86_debug_state32 = struct { + F__dr0 uint32 + F__dr1 uint32 + F__dr2 uint32 + F__dr3 uint32 + F__dr4 uint32 + F__dr5 uint32 + F__dr6 uint32 + F__dr7 uint32 +} /* _structs.h:595:1 */ + +type X__x86_pagein_state = struct{ F__pagein_error int32 } /* _structs.h:622:1 */ + +// 64 bit versions of the above + +type X__darwin_x86_thread_state64 = struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t +} /* _structs.h:633:1 */ + +// 64 bit versions of the above (complete) + +type X__darwin_x86_thread_full_state64 = struct { + F__ss64 struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__ds X__uint64_t + F__es X__uint64_t + F__ss X__uint64_t + F__gsbase X__uint64_t +} /* _structs.h:691:1 */ + +type X__darwin_x86_float_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 +} /* _structs.h:714:1 */ + +type X__darwin_x86_avx_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } +} /* _structs.h:765:1 */ + +type X__darwin_x86_avx512_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh8 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh9 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh10 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh11 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh12 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh13 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh14 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh15 struct{ F__ymm_reg [32]int8 } + F__fpu_zmm16 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm17 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm18 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm19 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm20 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm21 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm22 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm23 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm24 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm25 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm26 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm27 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm28 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm29 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm30 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm31 struct{ F__zmm_reg [64]int8 } +} /* _structs.h:833:1 */ + +type X__darwin_x86_exception_state64 = struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t +} /* _structs.h:1172:1 */ + +type X__darwin_x86_debug_state64 = struct { + F__dr0 X__uint64_t + F__dr1 X__uint64_t + F__dr2 X__uint64_t + F__dr3 X__uint64_t + F__dr4 X__uint64_t + F__dr5 X__uint64_t + F__dr6 X__uint64_t + F__dr7 X__uint64_t +} /* _structs.h:1192:1 */ + +type X__darwin_x86_cpmu_state64 = struct{ F__ctrs [16]X__uint64_t } /* _structs.h:1220:1 */ + +type X__darwin_mcontext32 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint32_t + } + F__ss struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + } +} /* _mcontext.h:39:1 */ + +type X__darwin_mcontext_avx32 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint32_t + } + F__ss struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + } +} /* _mcontext.h:47:1 */ + +type X__darwin_mcontext_avx512_32 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint32_t + } + F__ss struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } + } +} /* _mcontext.h:56:1 */ + +type X__darwin_mcontext64 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:97:1 */ + +type X__darwin_mcontext64_full = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__ss64 struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__ds X__uint64_t + F__es X__uint64_t + F__ss X__uint64_t + F__gsbase X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:105:1 */ + +type X__darwin_mcontext_avx64 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:113:1 */ + +type X__darwin_mcontext_avx64_full = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__ss64 struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__ds X__uint64_t + F__es X__uint64_t + F__ss X__uint64_t + F__gsbase X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:121:1 */ + +type X__darwin_mcontext_avx512_64 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh8 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh9 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh10 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh11 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh12 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh13 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh14 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh15 struct{ F__ymm_reg [32]int8 } + F__fpu_zmm16 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm17 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm18 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm19 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm20 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm21 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm22 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm23 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm24 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm25 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm26 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm27 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm28 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm29 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm30 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm31 struct{ F__zmm_reg [64]int8 } + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:130:1 */ + +type X__darwin_mcontext_avx512_64_full = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__ss64 struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__ds X__uint64_t + F__es X__uint64_t + F__ss X__uint64_t + F__gsbase X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh8 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh9 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh10 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh11 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh12 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh13 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh14 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh15 struct{ F__ymm_reg [32]int8 } + F__fpu_zmm16 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm17 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm18 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm19 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm20 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm21 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm22 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm23 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm24 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm25 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm26 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm27 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm28 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm29 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm30 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm31 struct{ F__zmm_reg [64]int8 } + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:138:1 */ + +type Mcontext_t = uintptr /* _mcontext.h:204:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Structure used in sigaltstack call. + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type X__darwin_sigaltstack = struct { + Fss_sp uintptr + Fss_size X__darwin_size_t + Fss_flags int32 + F__ccgo_pad1 [4]byte +} /* _sigaltstack.h:42:1 */ + +type Stack_t = X__darwin_sigaltstack /* _sigaltstack.h:48:33 */ // [???] signal stack + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_ucontext = struct { + Fuc_onstack int32 + Fuc_sigmask X__darwin_sigset_t + Fuc_stack struct { + Fss_sp uintptr + Fss_size X__darwin_size_t + Fss_flags int32 + F__ccgo_pad1 [4]byte + } + Fuc_link uintptr + Fuc_mcsize X__darwin_size_t + Fuc_mcontext uintptr +} /* _ucontext.h:42:1 */ + +// user context +type Ucontext_t = X__darwin_ucontext /* _ucontext.h:56:33 */ // [???] user context + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Sigset_t = X__darwin_sigset_t /* _sigset_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +type Sigval = struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte +} /* signal.h:158:1 */ + +type Sigevent = struct { + Fsigev_notify int32 + Fsigev_signo int32 + Fsigev_value struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte + } + Fsigev_notify_function uintptr + Fsigev_notify_attributes uintptr +} /* signal.h:168:1 */ + +type X__siginfo = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + Fsi_pid Pid_t + Fsi_uid Uid_t + Fsi_status int32 + Fsi_addr uintptr + Fsi_value struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte + } + Fsi_band int64 + F__pad [7]uint64 +} /* signal.h:177:9 */ + +type Siginfo_t = X__siginfo /* signal.h:188:3 */ + +// When the signal is SIGILL or SIGFPE, si_addr contains the address of +// the faulting instruction. +// When the signal is SIGSEGV or SIGBUS, si_addr contains the address of +// the faulting memory reference. Although for x86 there are cases of SIGSEGV +// for which si_addr cannot be determined and is NULL. +// If the signal is SIGCHLD, the si_pid field will contain the child process ID, +// si_status contains the exit value or signal and +// si_uid contains the real user ID of the process that sent the signal. + +// Values for si_code + +// Codes for SIGILL + +// Codes for SIGFPE + +// Codes for SIGSEGV + +// Codes for SIGBUS + +// Codes for SIGTRAP + +// Codes for SIGCHLD + +// Codes for SIGPOLL + +// union for signal handlers +type X__sigaction_u = struct{ F__sa_handler uintptr } /* signal.h:269:1 */ + +// Signal vector template for Kernel user boundary +type X__sigaction = struct { + F__sigaction_u struct{ F__sa_handler uintptr } + Fsa_tramp uintptr + Fsa_mask Sigset_t + Fsa_flags int32 +} /* signal.h:276:1 */ + +// Signal vector "template" used in sigaction call. +type Sigaction = struct { + F__sigaction_u struct{ F__sa_handler uintptr } + Fsa_mask Sigset_t + Fsa_flags int32 +} /* signal.h:286:1 */ + +// if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. + +// This will provide 64bit register set in a 32bit user address space + +// the following are the only bits we support from user space, the +// rest are for kernel use only. + +// Flags for sigprocmask: + +// POSIX 1003.1b required values. + +type Sig_t = uintptr /* signal.h:331:14 */ // type of signal function + +// Structure used in sigaltstack call. + +// 4.3 compatibility: +// Signal vector "template" used in sigvec call. +type Sigvec = struct { + Fsv_handler uintptr + Fsv_mask int32 + Fsv_flags int32 +} /* signal.h:348:1 */ + +// Structure used in sigstack call. +type Sigstack = struct { + Fss_sp uintptr + Fss_onstack int32 + F__ccgo_pad1 [4]byte +} /* signal.h:367:1 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/signal/signal_darwin_arm64.go b/internal/libc/signal/signal_darwin_arm64.go new file mode 100644 index 0000000..5a3f87d --- /dev/null +++ b/internal/libc/signal/signal_darwin_arm64.go @@ -0,0 +1,3132 @@ +// Code generated by 'ccgo signal/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o signal/signal_darwin_arm64.go -pkgname signal', DO NOT EDIT. + +package signal + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BUS_ADRALN = 1 // signal.h:241:1: + BUS_ADRERR = 2 // signal.h:242:1: + BUS_NOOP = 0 // signal.h:239:1: + BUS_OBJERR = 3 // signal.h:243:1: + CLD_CONTINUED = 6 // signal.h:258:1: + CLD_DUMPED = 3 // signal.h:255:1: + CLD_EXITED = 1 // signal.h:253:1: + CLD_KILLED = 2 // signal.h:254:1: + CLD_NOOP = 0 // signal.h:251:1: + CLD_STOPPED = 5 // signal.h:257:1: + CLD_TRAPPED = 4 // signal.h:256:1: + FPE_FLTDIV = 1 // signal.h:221:1: + FPE_FLTINV = 5 // signal.h:225:1: + FPE_FLTOVF = 2 // signal.h:222:1: + FPE_FLTRES = 4 // signal.h:224:1: + FPE_FLTSUB = 6 // signal.h:226:1: + FPE_FLTUND = 3 // signal.h:223:1: + FPE_INTDIV = 7 // signal.h:227:1: + FPE_INTOVF = 8 // signal.h:228:1: + FPE_NOOP = 0 // signal.h:219:1: + ILL_BADSTK = 8 // signal.h:215:1: + ILL_COPROC = 7 // signal.h:214:1: + ILL_ILLADR = 5 // signal.h:212:1: + ILL_ILLOPC = 1 // signal.h:208:1: + ILL_ILLOPN = 4 // signal.h:211:1: + ILL_ILLTRP = 2 // signal.h:209:1: + ILL_NOOP = 0 // signal.h:206:1: + ILL_PRVOPC = 3 // signal.h:210:1: + ILL_PRVREG = 6 // signal.h:213:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + MINSIGSTKSZ = 32768 // signal.h:340:1: + NSIG = 32 // signal.h:79:1: + POLL_ERR = 4 // signal.h:264:1: + POLL_HUP = 6 // signal.h:266:1: + POLL_IN = 1 // signal.h:261:1: + POLL_MSG = 3 // signal.h:263:1: + POLL_OUT = 2 // signal.h:262:1: + POLL_PRI = 5 // signal.h:265:1: + SA_64REGSET = 0x0200 // signal.h:308:1: + SA_NOCLDSTOP = 0x0008 // signal.h:301:1: + SA_NOCLDWAIT = 0x0020 // signal.h:303:1: + SA_NODEFER = 0x0010 // signal.h:302:1: + SA_ONSTACK = 0x0001 // signal.h:298:1: + SA_RESETHAND = 0x0004 // signal.h:300:1: + SA_RESTART = 0x0002 // signal.h:299:1: + SA_SIGINFO = 0x0040 // signal.h:304:1: + SA_USERSPACE_MASK = 127 // signal.h:314:1: + SA_USERTRAMP = 0x0100 // signal.h:306:1: + SEGV_ACCERR = 2 // signal.h:235:1: + SEGV_MAPERR = 1 // signal.h:234:1: + SEGV_NOOP = 0 // signal.h:232:1: + SIGABRT = 6 // signal.h:89:1: + SIGALRM = 14 // signal.h:102:1: + SIGBUS = 10 // signal.h:98:1: + SIGCHLD = 20 // signal.h:108:1: + SIGCONT = 19 // signal.h:107:1: + SIGEMT = 7 // signal.h:94:1: + SIGEV_NONE = 0 // signal.h:164:1: + SIGEV_SIGNAL = 1 // signal.h:165:1: + SIGEV_THREAD = 3 // signal.h:166:1: + SIGFPE = 8 // signal.h:96:1: + SIGHUP = 1 // signal.h:84:1: + SIGILL = 4 // signal.h:87:1: + SIGINFO = 29 // signal.h:120:1: + SIGINT = 2 // signal.h:85:1: + SIGIO = 23 // signal.h:112:1: + SIGIOT = 6 // signal.h:93:1: + SIGKILL = 9 // signal.h:97:1: + SIGPIPE = 13 // signal.h:101:1: + SIGPROF = 27 // signal.h:117:1: + SIGQUIT = 3 // signal.h:86:1: + SIGSEGV = 11 // signal.h:99:1: + SIGSTKSZ = 131072 // signal.h:341:1: + SIGSTOP = 17 // signal.h:105:1: + SIGSYS = 12 // signal.h:100:1: + SIGTERM = 15 // signal.h:103:1: + SIGTRAP = 5 // signal.h:88:1: + SIGTSTP = 18 // signal.h:106:1: + SIGTTIN = 21 // signal.h:109:1: + SIGTTOU = 22 // signal.h:110:1: + SIGURG = 16 // signal.h:104:1: + SIGUSR1 = 30 // signal.h:122:1: + SIGUSR2 = 31 // signal.h:123:1: + SIGVTALRM = 26 // signal.h:116:1: + SIGWINCH = 28 // signal.h:119:1: + SIGXCPU = 24 // signal.h:114:1: + SIGXFSZ = 25 // signal.h:115:1: + SIG_BLOCK = 1 // signal.h:319:1: + SIG_SETMASK = 3 // signal.h:321:1: + SIG_UNBLOCK = 2 // signal.h:320:1: + SI_ASYNCIO = 0x10004 // signal.h:327:1: + SI_MESGQ = 0x10005 // signal.h:328:1: + SI_QUEUE = 0x10002 // signal.h:325:1: + SI_TIMER = 0x10003 // signal.h:326:1: + SI_USER = 0x10001 // signal.h:324:1: + SS_DISABLE = 0x0004 // signal.h:339:1: + SS_ONSTACK = 0x0001 // signal.h:338:1: + SV_INTERRUPT = 2 // signal.h:355:1: + SV_NOCLDSTOP = 8 // signal.h:358:1: + SV_NODEFER = 16 // signal.h:357:1: + SV_ONSTACK = 1 // signal.h:354:1: + SV_RESETHAND = 4 // signal.h:356:1: + SV_SIGINFO = 64 // signal.h:359:1: + TRAP_BRKPT = 1 // signal.h:246:1: + TRAP_TRACE = 2 // signal.h:247:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_ARM_SIGNAL_ = 1 // signal.h:10:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_SIGNAL_H_ = 0 // signal.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__MCONTEXT_H_ = 0 // _mcontext.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MACH_ARM__STRUCTS_H_ = 0 // _structs.h:32:1: + X_MACH_MACHINE__STRUCTS_H_ = 0 // _structs.h:30:1: + X_MCONTEXT_T = 0 // _mcontext.h:83:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_SIGSET_T = 0 // _sigset_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS_SIGNAL_H_ = 0 // signal.h:70:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USER_SIGNAL_H = 0 // signal.h:59:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)signal.h 8.3 (Berkeley) 3/30/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 1991, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)signal.h 8.2 (Berkeley) 1/21/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2009 Apple, Inc. All rights reserved. +// Copyright (c) 1992 NeXT Computer, Inc. +// + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +type Sig_atomic_t = int32 /* signal.h:17:13 */ + +// Language spec sez we must list exactly one parameter, even though we +// actually supply three. Ugh! +// SIG_HOLD is chosen to avoid KERN_SIG_* values in + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// @OSF_COPYRIGHT@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type X__darwin_arm_exception_state = struct { + F__exception X__uint32_t + F__fsr X__uint32_t + F__far X__uint32_t +} /* _structs.h:41:1 */ + +type X__darwin_arm_exception_state64 = struct { + F__far X__uint64_t + F__esr X__uint32_t + F__exception X__uint32_t +} /* _structs.h:59:1 */ + +type X__darwin_arm_thread_state = struct { + F__r [13]X__uint32_t + F__sp X__uint32_t + F__lr X__uint32_t + F__pc X__uint32_t + F__cpsr X__uint32_t +} /* _structs.h:77:1 */ + +// By default, the pointer fields in the arm_thread_state64_t structure are +// opaque on the arm64e architecture and require the use of accessor macros. +// This mode can also be enabled on the arm64 architecture by building with +// -D__DARWIN_OPAQUE_ARM_THREAD_STATE64=1. + +type X__darwin_arm_thread_state64 = struct { + F__x [29]X__uint64_t + F__fp X__uint64_t + F__lr X__uint64_t + F__sp X__uint64_t + F__pc X__uint64_t + F__cpsr X__uint32_t + F__pad X__uint32_t +} /* _structs.h:136:1 */ + +// Accessor macros for arm_thread_state64_t pointer fields + +// Return pc field of arm_thread_state64_t as a data pointer value +// Return pc field of arm_thread_state64_t as a function pointer +// Set pc field of arm_thread_state64_t to a function pointer +// Return lr field of arm_thread_state64_t as a data pointer value +// Return lr field of arm_thread_state64_t as a function pointer +// Set lr field of arm_thread_state64_t to a function pointer +// Return sp field of arm_thread_state64_t as a data pointer value +// Set sp field of arm_thread_state64_t to a data pointer value +// Return fp field of arm_thread_state64_t as a data pointer value +// Set fp field of arm_thread_state64_t to a data pointer value +// Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t + +type X__darwin_arm_vfp_state = struct { + F__r [64]X__uint32_t + F__fpscr X__uint32_t +} /* _structs.h:433:1 */ + +type X__darwin_arm_neon_state64 = struct { + F__v [32]X__uint128_t + F__fpsr X__uint32_t + F__fpcr X__uint32_t +} /* _structs.h:452:1 */ + +type X__darwin_arm_neon_state = struct { + F__v [16]X__uint128_t + F__fpsr X__uint32_t + F__fpcr X__uint32_t +} /* _structs.h:459:1 */ + +type X__arm_pagein_state = struct{ F__pagein_error int32 } /* _structs.h:523:1 */ + +// Debug State + +// ARM's arm_debug_state is ARM64's arm_legacy_debug_state + +type X__arm_legacy_debug_state = struct { + F__bvr [16]X__uint32_t + F__bcr [16]X__uint32_t + F__wvr [16]X__uint32_t + F__wcr [16]X__uint32_t +} /* _structs.h:560:1 */ + +type X__darwin_arm_debug_state32 = struct { + F__bvr [16]X__uint32_t + F__bcr [16]X__uint32_t + F__wvr [16]X__uint32_t + F__wcr [16]X__uint32_t + F__mdscr_el1 X__uint64_t +} /* _structs.h:583:1 */ + +type X__darwin_arm_debug_state64 = struct { + F__bvr [16]X__uint64_t + F__bcr [16]X__uint64_t + F__wvr [16]X__uint64_t + F__wcr [16]X__uint64_t + F__mdscr_el1 X__uint64_t +} /* _structs.h:593:1 */ + +type X__darwin_arm_cpmu_state64 = struct{ F__ctrs [16]X__uint64_t } /* _structs.h:625:1 */ + +type X__darwin_mcontext32 = struct { + F__es struct { + F__exception X__uint32_t + F__fsr X__uint32_t + F__far X__uint32_t + } + F__ss struct { + F__r [13]X__uint32_t + F__sp X__uint32_t + F__lr X__uint32_t + F__pc X__uint32_t + F__cpsr X__uint32_t + } + F__fs struct { + F__r [64]X__uint32_t + F__fpscr X__uint32_t + } +} /* _mcontext.h:41:1 */ + +type X__darwin_mcontext64 = struct { + F__es struct { + F__far X__uint64_t + F__esr X__uint32_t + F__exception X__uint32_t + } + F__ss struct { + F__x [29]X__uint64_t + F__fp X__uint64_t + F__lr X__uint64_t + F__sp X__uint64_t + F__pc X__uint64_t + F__cpsr X__uint32_t + F__pad X__uint32_t + } + F__ns struct { + F__v [32]X__uint128_t + F__fpsr X__uint32_t + F__fpcr X__uint32_t + } +} /* _mcontext.h:64:1 */ + +type Mcontext_t = uintptr /* _mcontext.h:85:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Structure used in sigaltstack call. + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type X__darwin_sigaltstack = struct { + Fss_sp uintptr + Fss_size X__darwin_size_t + Fss_flags int32 + F__ccgo_pad1 [4]byte +} /* _sigaltstack.h:42:1 */ + +type Stack_t = X__darwin_sigaltstack /* _sigaltstack.h:48:33 */ // [???] signal stack + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Structure used in sigaltstack call. + +type X__darwin_ucontext = struct { + Fuc_onstack int32 + Fuc_sigmask X__darwin_sigset_t + Fuc_stack struct { + Fss_sp uintptr + Fss_size X__darwin_size_t + Fss_flags int32 + F__ccgo_pad1 [4]byte + } + Fuc_link uintptr + Fuc_mcsize X__darwin_size_t + Fuc_mcontext uintptr +} /* _ucontext.h:43:1 */ + +// user context +type Ucontext_t = X__darwin_ucontext /* _ucontext.h:57:33 */ // [???] user context + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Sigset_t = X__darwin_sigset_t /* _sigset_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +type Sigval = struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte +} /* signal.h:158:1 */ + +type Sigevent = struct { + Fsigev_notify int32 + Fsigev_signo int32 + Fsigev_value struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte + } + Fsigev_notify_function uintptr + Fsigev_notify_attributes uintptr +} /* signal.h:168:1 */ + +type X__siginfo = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + Fsi_pid Pid_t + Fsi_uid Uid_t + Fsi_status int32 + Fsi_addr uintptr + Fsi_value struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte + } + Fsi_band int64 + F__pad [7]uint64 +} /* signal.h:177:9 */ + +type Siginfo_t = X__siginfo /* signal.h:188:3 */ + +// When the signal is SIGILL or SIGFPE, si_addr contains the address of +// the faulting instruction. +// When the signal is SIGSEGV or SIGBUS, si_addr contains the address of +// the faulting memory reference. Although for x86 there are cases of SIGSEGV +// for which si_addr cannot be determined and is NULL. +// If the signal is SIGCHLD, the si_pid field will contain the child process ID, +// si_status contains the exit value or signal and +// si_uid contains the real user ID of the process that sent the signal. + +// Values for si_code + +// Codes for SIGILL + +// Codes for SIGFPE + +// Codes for SIGSEGV + +// Codes for SIGBUS + +// Codes for SIGTRAP + +// Codes for SIGCHLD + +// Codes for SIGPOLL + +// union for signal handlers +type X__sigaction_u = struct{ F__sa_handler uintptr } /* signal.h:269:1 */ + +// Signal vector template for Kernel user boundary +type X__sigaction = struct { + F__sigaction_u struct{ F__sa_handler uintptr } + Fsa_tramp uintptr + Fsa_mask Sigset_t + Fsa_flags int32 +} /* signal.h:276:1 */ + +// Signal vector "template" used in sigaction call. +type Sigaction = struct { + F__sigaction_u struct{ F__sa_handler uintptr } + Fsa_mask Sigset_t + Fsa_flags int32 +} /* signal.h:286:1 */ + +// if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. + +// This will provide 64bit register set in a 32bit user address space + +// the following are the only bits we support from user space, the +// rest are for kernel use only. + +// Flags for sigprocmask: + +// POSIX 1003.1b required values. + +type Sig_t = uintptr /* signal.h:331:14 */ // type of signal function + +// Structure used in sigaltstack call. + +// 4.3 compatibility: +// Signal vector "template" used in sigvec call. +type Sigvec = struct { + Fsv_handler uintptr + Fsv_mask int32 + Fsv_flags int32 +} /* signal.h:348:1 */ + +// Structure used in sigstack call. +type Sigstack = struct { + Fss_sp uintptr + Fss_onstack int32 + F__ccgo_pad1 [4]byte +} /* signal.h:367:1 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/signal/signal_linux_amd64.go b/internal/libc/signal/signal_linux_amd64.go new file mode 100644 index 0000000..5765c29 --- /dev/null +++ b/internal/libc/signal/signal_linux_amd64.go @@ -0,0 +1,2198 @@ +// Code generated by 'ccgo signal/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o signal/signal_linux_amd64.go -pkgname signal', DO NOT EDIT. + +package signal + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + FP_XSTATE_MAGIC1 = 0x46505853 // sigcontext.h:27:1: + FP_XSTATE_MAGIC2 = 0x46505845 // sigcontext.h:28:1: + MINSIGSTKSZ = 2048 // sigstack.h:27:1: + NGREG = 23 // ucontext.h:42:1: + NSIG = 65 // signal.h:181:1: + SA_INTERRUPT = 0x20000000 // sigaction.h:70:1: + SA_NOCLDSTOP = 1 // sigaction.h:56:1: + SA_NOCLDWAIT = 2 // sigaction.h:57:1: + SA_NODEFER = 0x40000000 // sigaction.h:65:1: + SA_NOMASK = 1073741824 // sigaction.h:73:1: + SA_ONESHOT = 2147483648 // sigaction.h:74:1: + SA_ONSTACK = 0x08000000 // sigaction.h:61:1: + SA_RESETHAND = 0x80000000 // sigaction.h:67:1: + SA_RESTART = 0x10000000 // sigaction.h:64:1: + SA_SIGINFO = 4 // sigaction.h:58:1: + SA_STACK = 134217728 // sigaction.h:75:1: + SIGABRT = 6 // signum-generic.h:50:1: + SIGALRM = 14 // signum-generic.h:63:1: + SIGBUS = 7 // signum.h:35:1: + SIGCHLD = 17 // signum.h:41:1: + SIGCLD = 17 // signum-generic.h:88:1: + SIGCONT = 18 // signum.h:43:1: + SIGFPE = 8 // signum-generic.h:51:1: + SIGHUP = 1 // signum-generic.h:56:1: + SIGILL = 4 // signum-generic.h:49:1: + SIGINT = 2 // signum-generic.h:48:1: + SIGIO = 29 // signum-generic.h:86:1: + SIGIOT = 6 // signum-generic.h:87:1: + SIGKILL = 9 // signum-generic.h:59:1: + SIGPIPE = 13 // signum-generic.h:62:1: + SIGPOLL = 29 // signum.h:51:1: + SIGPROF = 27 // signum-generic.h:77:1: + SIGPWR = 30 // signum.h:32:1: + SIGQUIT = 3 // signum-generic.h:57:1: + SIGSEGV = 11 // signum-generic.h:52:1: + SIGSTKFLT = 16 // signum.h:31:1: + SIGSTKSZ = 8192 // sigstack.h:30:1: + SIGSTOP = 19 // signum.h:45:1: + SIGSYS = 31 // signum.h:53:1: + SIGTERM = 15 // signum-generic.h:53:1: + SIGTRAP = 5 // signum-generic.h:58:1: + SIGTSTP = 20 // signum.h:47:1: + SIGTTIN = 21 // signum-generic.h:71:1: + SIGTTOU = 22 // signum-generic.h:72:1: + SIGURG = 23 // signum.h:49:1: + SIGUSR1 = 10 // signum.h:37:1: + SIGUSR2 = 12 // signum.h:39:1: + SIGVTALRM = 26 // signum-generic.h:76:1: + SIGWINCH = 28 // signum-generic.h:83:1: + SIGXCPU = 24 // signum-generic.h:74:1: + SIGXFSZ = 25 // signum-generic.h:75:1: + SIG_BLOCK = 0 // sigaction.h:79:1: + SIG_SETMASK = 2 // sigaction.h:81:1: + SIG_UNBLOCK = 1 // sigaction.h:80:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_SIGACTION_H = 1 // sigaction.h:20:1: + X_BITS_SIGCONTEXT_H = 1 // sigcontext.h:19:1: + X_BITS_SIGEVENT_CONSTS_H = 1 // sigevent-consts.h:20:1: + X_BITS_SIGINFO_ARCH_H = 1 // siginfo-arch.h:3:1: + X_BITS_SIGINFO_CONSTS_H = 1 // siginfo-consts.h:20:1: + X_BITS_SIGNUM_GENERIC_H = 1 // signum-generic.h:20:1: + X_BITS_SIGNUM_H = 1 // signum.h:20:1: + X_BITS_SIGSTACK_H = 1 // sigstack.h:20:1: + X_BITS_SIGTHREAD_H = 1 // sigthread.h:20:1: + X_BITS_SS_FLAGS_H = 1 // ss_flags.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LP64 = 1 // :284:1: + X_NSIG = 65 // signum-generic.h:100:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SIGNAL_H = 0 // signal.h:23:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_SYS_UCONTEXT_H = 1 // ucontext.h:19:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// POSIX names to access some of the members. + +// sigevent constants. Linux version. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// `sigev_notify' values. +const ( /* sigevent-consts.h:27:1: */ + SIGEV_SIGNAL = 0 // Notify via signal. + SIGEV_NONE = 1 // Other notification: meaningless. + SIGEV_THREAD = 2 // Deliver via thread creation. + + SIGEV_THREAD_ID = 4 +) + +// `si_code' values for SIGSEGV signal. +const ( /* siginfo-consts.h:119:1: */ + SEGV_MAPERR = 1 // Address not mapped to object. + SEGV_ACCERR = 2 // Invalid permissions for mapped object. + SEGV_BNDERR = 3 // Bounds checking failure. + SEGV_PKUERR = 4 // Protection key checking failure. + SEGV_ACCADI = 5 // ADI not enabled for mapped object. + SEGV_ADIDERR = 6 // Disrupting MCD error. + SEGV_ADIPERR = 7 +) + +// `si_code' values for SIGBUS signal. +const ( /* siginfo-consts.h:138:1: */ + BUS_ADRALN = 1 // Invalid address alignment. + BUS_ADRERR = 2 // Non-existant physical address. + BUS_OBJERR = 3 // Object specific hardware error. + BUS_MCEERR_AR = 4 // Hardware memory error: action required. + BUS_MCEERR_AO = 5 +) + +// `si_code' values for SIGCHLD signal. +const ( /* siginfo-consts.h:172:1: */ + CLD_EXITED = 1 // Child has exited. + CLD_KILLED = 2 // Child was killed. + CLD_DUMPED = 3 // Child terminated abnormally. + CLD_TRAPPED = 4 // Traced child has trapped. + CLD_STOPPED = 5 // Child has stopped. + CLD_CONTINUED = 6 +) + +// `si_code' values for SIGPOLL signal. +const ( /* siginfo-consts.h:189:1: */ + POLL_IN = 1 // Data input available. + POLL_OUT = 2 // Output buffers available. + POLL_MSG = 3 // Input message available. + POLL_ERR = 4 // I/O error. + POLL_PRI = 5 // High priority input available. + POLL_HUP = 6 +) + +// X/Open requires some more fields with fixed names. + +// siginfo constants. Linux version. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Most of these constants are uniform across all architectures, but there +// is one exception. +// Architecture-specific adjustments to siginfo_t. x86 version. + +// Values for `si_code'. Positive values are reserved for kernel-generated +// +// signals. +const ( /* siginfo-consts.h:35:1: */ + SI_ASYNCNL = -60 // Sent by asynch name lookup completion. + SI_DETHREAD = -7 // Sent by execve killing subsidiary + // threads. + SI_TKILL = -6 // Sent by tkill. + SI_SIGIO = -5 // Sent by queued SIGIO. + SI_ASYNCIO = -4 // Sent by AIO completion. + SI_MESGQ = -3 // Sent by real time mesq state change. + SI_TIMER = -2 // Sent by timer expiration. + SI_QUEUE = -1 // Sent by sigqueue. + SI_USER = 0 // Sent by kill, sigsend. + SI_KERNEL = 128 +) + +// `si_code' values for SIGILL signal. +const ( /* siginfo-consts.h:71:1: */ + ILL_ILLOPC = 1 // Illegal opcode. + ILL_ILLOPN = 2 // Illegal operand. + ILL_ILLADR = 3 // Illegal addressing mode. + ILL_ILLTRP = 4 // Illegal trap. + ILL_PRVOPC = 5 // Privileged opcode. + ILL_PRVREG = 6 // Privileged register. + ILL_COPROC = 7 // Coprocessor error. + ILL_BADSTK = 8 // Internal stack error. + ILL_BADIADDR = 9 +) + +// `si_code' values for SIGFPE signal. +const ( /* siginfo-consts.h:94:1: */ + FPE_INTDIV = 1 // Integer divide by zero. + FPE_INTOVF = 2 // Integer overflow. + FPE_FLTDIV = 3 // Floating point divide by zero. + FPE_FLTOVF = 4 // Floating point overflow. + FPE_FLTUND = 5 // Floating point underflow. + FPE_FLTRES = 6 // Floating point inexact result. + FPE_FLTINV = 7 // Floating point invalid operation. + FPE_FLTSUB = 8 // Subscript out of range. + FPE_FLTUNK = 14 // Undiagnosed floating-point exception. + FPE_CONDTRAP = 15 +) + +// sigstack, sigaltstack definitions. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Minimum stack size for a signal handler. + +// System default stack size. + +// ss_flags values for stack_t. Linux version. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Possible values for `ss_flags'. +const ( /* ss_flags.h:27:1: */ + SS_ONSTACK = 1 + SS_DISABLE = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.14 Signal handling + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// Signal number definitions. Linux version. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Signal number constants. Generic template. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Fake signal functions. + +// We define here all the signal names listed in POSIX (1003.1-2008); +// as of 1003.1-2013, no additional signals have been added by POSIX. +// We also define here signal names that historically exist in every +// real-world POSIX variant (e.g. SIGWINCH). +// +// Signals in the 1-15 range are defined with their historical numbers. +// For other signals, we use the BSD numbers. +// There are two unallocated signal numbers in the 1-31 range: 7 and 29. +// Signal number 0 is reserved for use as kill(pid, 0), to test whether +// a process exists without sending it a signal. + +// ISO C99 signals. + +// Historical signals specified by POSIX. + +// New(er) POSIX signals (1003.1-2008, 1003.1-2013). + +// Nonstandard signals found in all modern POSIX systems +// (including both BSD and Linux). + +// Archaic names for compatibility. + +// Not all systems support real-time signals. bits/signum.h indicates +// that they are supported by overriding __SIGRTMAX to a value greater +// than __SIGRTMIN. These constants give the kernel-level hard limits, +// but some real-time signals may be used internally by glibc. Do not +// use these constants in application code; use SIGRTMIN and SIGRTMAX +// (defined in signal.h) instead. + +// Biggest signal number + 1 (including real-time signals). + +// Adjustments and additions to the signal number constants for +// most Linux systems. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// An integral type that can be modified atomically, without the +// +// possibility of a signal arriving in the middle of the operation. +type Sig_atomic_t = X__sig_atomic_t /* sig_atomic_t.h:8:24 */ + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +type Pid_t = X__pid_t /* signal.h:40:17 */ +type Uid_t = X__uid_t /* signal.h:46:17 */ + +// We need `struct timespec' later on. +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// i386/x86_64 are little-endian. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Define __sigval_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Type for data associated with a signal. +type Sigval = struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte +} /* __sigval_t.h:24:1 */ + +type X__sigval_t = Sigval /* __sigval_t.h:30:22 */ + +// Some fields of siginfo_t have architecture-specific variations. +// Architecture-specific adjustments to siginfo_t. x86 version. + +type Siginfo_t = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + F__pad0 int32 + F_sifields struct { + F__ccgo_pad1 [0]uint64 + F_pad [28]int32 + } +} /* siginfo_t.h:124:5 */ + +// Architectures might also add architecture-specific constants. +// These are all considered GNU extensions. + +// Define __sigval_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// To avoid sigval_t (not a standard type name) having C++ name +// mangling depending on whether the selected standard includes union +// sigval, it should not be defined at all when using a standard for +// which the sigval name is not reserved; in that case, headers should +// not include and should use only the +// internal __sigval_t name. + +type Sigval_t = X__sigval_t /* sigval_t.h:16:20 */ + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Define __sigval_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Forward declaration. +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* sigevent_t.h:17:9 */ + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Define __sigval_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Forward declaration. +type Pthread_attr_t = Pthread_attr_t1 /* sigevent_t.h:17:30 */ + +// Structure to transport application-defined values with signals. +type Sigevent = struct { + Fsigev_value X__sigval_t + Fsigev_signo int32 + Fsigev_notify int32 + F_sigev_un struct { + F__ccgo_pad1 [0]uint64 + F_pad [12]int32 + } +} /* sigevent_t.h:22:9 */ + +// Structure to transport application-defined values with signals. +type Sigevent_t = Sigevent /* sigevent_t.h:42:5 */ + +// Type of a signal handler. +type X__sighandler_t = uintptr /* signal.h:72:14 */ + +// 4.4 BSD uses the name `sig_t' for this. +type Sig_t = X__sighandler_t /* signal.h:190:24 */ + +// Get the system-specific definitions of `struct sigaction' +// and the `SA_*' and `SIG_*'. constants. +// The proper definitions for Linux's sigaction. +// Copyright (C) 1993-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Structure describing the action to be taken when a signal arrives. +type Sigaction = struct { + F__sigaction_handler struct{ Fsa_handler X__sighandler_t } + Fsa_mask X__sigset_t + Fsa_flags int32 + F__ccgo_pad1 [4]byte + Fsa_restorer uintptr +} /* sigaction.h:27:1 */ + +// Get machine-dependent `struct sigcontext' and signal subcodes. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type X_fpx_sw_bytes = struct { + Fmagic1 X__uint32_t + Fextended_size X__uint32_t + Fxstate_bv X__uint64_t + Fxstate_size X__uint32_t + F__glibc_reserved1 [7]X__uint32_t +} /* sigcontext.h:31:1 */ + +type X_fpreg = struct { + Fsignificand [4]uint16 + Fexponent uint16 +} /* sigcontext.h:40:1 */ + +type X_fpxreg = struct { + Fsignificand [4]uint16 + Fexponent uint16 + F__glibc_reserved1 [3]uint16 +} /* sigcontext.h:46:1 */ + +type X_xmmreg = struct{ Felement [4]X__uint32_t } /* sigcontext.h:53:1 */ + +type X_fpstate = struct { + Fcwd X__uint16_t + Fswd X__uint16_t + Fftw X__uint16_t + Ffop X__uint16_t + Frip X__uint64_t + Frdp X__uint64_t + Fmxcsr X__uint32_t + Fmxcr_mask X__uint32_t + F_st [8]struct { + Fsignificand [4]uint16 + Fexponent uint16 + F__glibc_reserved1 [3]uint16 + } + F_xmm [16]struct{ Felement [4]X__uint32_t } + F__glibc_reserved1 [24]X__uint32_t +} /* sigcontext.h:123:1 */ + +type Sigcontext = struct { + Fr8 X__uint64_t + Fr9 X__uint64_t + Fr10 X__uint64_t + Fr11 X__uint64_t + Fr12 X__uint64_t + Fr13 X__uint64_t + Fr14 X__uint64_t + Fr15 X__uint64_t + Frdi X__uint64_t + Frsi X__uint64_t + Frbp X__uint64_t + Frbx X__uint64_t + Frdx X__uint64_t + Frax X__uint64_t + Frcx X__uint64_t + Frsp X__uint64_t + Frip X__uint64_t + Feflags X__uint64_t + Fcs uint16 + Fgs uint16 + Ffs uint16 + F__pad0 uint16 + Ferr X__uint64_t + Ftrapno X__uint64_t + Foldmask X__uint64_t + Fcr2 X__uint64_t + F__184 struct{ Ffpstate uintptr } + F__reserved1 [8]X__uint64_t +} /* sigcontext.h:139:1 */ + +type X_xsave_hdr = struct { + Fxstate_bv X__uint64_t + F__glibc_reserved1 [2]X__uint64_t + F__glibc_reserved2 [5]X__uint64_t +} /* sigcontext.h:177:1 */ + +type X_ymmh_state = struct{ Fymmh_space [64]X__uint32_t } /* sigcontext.h:184:1 */ + +type X_xstate = struct { + Ffpstate struct { + Fcwd X__uint16_t + Fswd X__uint16_t + Fftw X__uint16_t + Ffop X__uint16_t + Frip X__uint64_t + Frdp X__uint64_t + Fmxcsr X__uint32_t + Fmxcr_mask X__uint32_t + F_st [8]struct { + Fsignificand [4]uint16 + Fexponent uint16 + F__glibc_reserved1 [3]uint16 + } + F_xmm [16]struct{ Felement [4]X__uint32_t } + F__glibc_reserved1 [24]X__uint32_t + } + Fxstate_hdr struct { + Fxstate_bv X__uint64_t + F__glibc_reserved1 [2]X__uint64_t + F__glibc_reserved2 [5]X__uint64_t + } + Fymmh struct{ Fymmh_space [64]X__uint32_t } +} /* sigcontext.h:189:1 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Define stack_t. Linux version. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Structure describing a signal stack. +type Stack_t = struct { + Fss_sp uintptr + Fss_flags int32 + F__ccgo_pad1 [4]byte + Fss_size Size_t +} /* stack_t.h:31:5 */ + +// This will define `ucontext_t' and `mcontext_t'. +// Copyright (C) 2001-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Define stack_t. Linux version. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Type for general register. +type Greg_t = int64 /* ucontext.h:37:37 */ + +// Number of general registers. + +// Container for all general registers. +type Gregset_t = [23]Greg_t /* ucontext.h:46:16 */ + +type X_libc_fpxreg = struct { + Fsignificand [4]uint16 + Fexponent uint16 + F__glibc_reserved1 [3]uint16 +} /* ucontext.h:101:1 */ + +type X_libc_xmmreg = struct{ Felement [4]X__uint32_t } /* ucontext.h:108:1 */ + +type X_libc_fpstate = struct { + Fcwd X__uint16_t + Fswd X__uint16_t + Fftw X__uint16_t + Ffop X__uint16_t + Frip X__uint64_t + Frdp X__uint64_t + Fmxcsr X__uint32_t + Fmxcr_mask X__uint32_t + F_st [8]struct { + Fsignificand [4]uint16 + Fexponent uint16 + F__glibc_reserved1 [3]uint16 + } + F_xmm [16]struct{ Felement [4]X__uint32_t } + F__glibc_reserved1 [24]X__uint32_t +} /* ucontext.h:113:1 */ + +// Structure to describe FPU registers. +type Fpregset_t = uintptr /* ucontext.h:130:30 */ + +// Context to describe whole processor state. +type Mcontext_t = struct { + Fgregs Gregset_t + Ffpregs Fpregset_t + F__reserved1 [8]uint64 +} /* ucontext.h:139:3 */ + +// Userlevel context. +type Ucontext_t1 = struct { + Fuc_flags uint64 + Fuc_link uintptr + Fuc_stack Stack_t + Fuc_mcontext Mcontext_t + Fuc_sigmask Sigset_t + F__fpregs_mem struct { + Fcwd X__uint16_t + Fswd X__uint16_t + Fftw X__uint16_t + Ffop X__uint16_t + Frip X__uint64_t + Frdp X__uint64_t + Fmxcsr X__uint32_t + Fmxcr_mask X__uint32_t + F_st [8]struct { + Fsignificand [4]uint16 + Fexponent uint16 + F__glibc_reserved1 [3]uint16 + } + F_xmm [16]struct{ Felement [4]X__uint32_t } + F__glibc_reserved1 [24]X__uint32_t + } + F__ssp [4]uint64 +} /* ucontext.h:142:9 */ + +// Userlevel context. +type Ucontext_t = Ucontext_t1 /* ucontext.h:151:5 */ + +// Define struct sigstack. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Structure describing a signal stack (obsolete). +type Sigstack = struct { + Fss_sp uintptr + Fss_onstack int32 + F__ccgo_pad1 [4]byte +} /* struct_sigstack.h:23:1 */ + +// Some of the functions for handling signals in threaded programs must +// be defined here. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Some of the functions for handling signals in threaded programs must +// be defined here. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +// System-specific extensions. +// System-specific extensions of , Linux version. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/signal/signal_linux_arm64.go b/internal/libc/signal/signal_linux_arm64.go new file mode 100644 index 0000000..c17209a --- /dev/null +++ b/internal/libc/signal/signal_linux_arm64.go @@ -0,0 +1,3311 @@ +// Code generated by 'ccgo signal/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o signal/signal_linux_arm64.go -pkgname signal', DO NOT EDIT. + +package signal + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 + BYTE_ORDER = 1234 + ELF_PRARGSZ = 80 + ESR_MAGIC = 0x45535201 + EXTRA_MAGIC = 0x45585401 + FD_SETSIZE = 1024 + FPSIMD_MAGIC = 0x46508001 + LITTLE_ENDIAN = 1234 + MINSIGSTKSZ = 5120 + NSIG = 65 + PDP_ENDIAN = 3412 + SA_INTERRUPT = 0x20000000 + SA_NOCLDSTOP = 1 + SA_NOCLDWAIT = 2 + SA_NODEFER = 0x40000000 + SA_NOMASK = 1073741824 + SA_ONESHOT = 2147483648 + SA_ONSTACK = 0x08000000 + SA_RESETHAND = 0x80000000 + SA_RESTART = 0x10000000 + SA_SIGINFO = 4 + SA_STACK = 134217728 + SIGABRT = 6 + SIGALRM = 14 + SIGBUS = 7 + SIGCHLD = 17 + SIGCLD = 17 + SIGCONT = 18 + SIGFPE = 8 + SIGHUP = 1 + SIGILL = 4 + SIGINT = 2 + SIGIO = 29 + SIGIOT = 6 + SIGKILL = 9 + SIGPIPE = 13 + SIGPOLL = 29 + SIGPROF = 27 + SIGPWR = 30 + SIGQUIT = 3 + SIGSEGV = 11 + SIGSTKFLT = 16 + SIGSTKSZ = 16384 + SIGSTOP = 19 + SIGSYS = 31 + SIGTERM = 15 + SIGTRAP = 5 + SIGTSTP = 20 + SIGTTIN = 21 + SIGTTOU = 22 + SIGURG = 23 + SIGUSR1 = 10 + SIGUSR2 = 12 + SIGVTALRM = 26 + SIGWINCH = 28 + SIGXCPU = 24 + SIGXFSZ = 25 + SIG_BLOCK = 0 + SIG_SETMASK = 2 + SIG_UNBLOCK = 1 + SVE_MAGIC = 0x53564501 + SVE_NUM_PREGS = 16 + SVE_NUM_ZREGS = 32 + SVE_VL_MAX = 8192 + SVE_VL_MIN = 16 + SVE_VQ_BYTES = 16 + SVE_VQ_MAX = 512 + SVE_VQ_MIN = 1 + X_ASM_GENERIC_INT_LL64_H = 0 + X_ASM_GENERIC_TYPES_H = 0 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_SIGACTION_H = 1 + X_BITS_SIGCONTEXT_H = 1 + X_BITS_SIGEVENT_CONSTS_H = 1 + X_BITS_SIGINFO_ARCH_H = 1 + X_BITS_SIGINFO_CONSTS_H = 1 + X_BITS_SIGNUM_GENERIC_H = 1 + X_BITS_SIGNUM_H = 1 + X_BITS_SIGSTACK_H = 1 + X_BITS_SIGTHREAD_H = 1 + X_BITS_SS_FLAGS_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LINUX_POSIX_TYPES_H = 0 + X_LINUX_TYPES_H = 0 + X_LP64 = 1 + X_NSIG = 65 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SIGNAL_H = 0 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_PROCFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_TIME_H = 1 + X_SYS_TYPES_H = 1 + X_SYS_UCONTEXT_H = 1 + X_SYS_USER_H = 1 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +// POSIX names to access some of the members. + +// sigevent constants. Linux version. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// `sigev_notify' values. +const ( /* sigevent-consts.h:27:1: */ + SIGEV_SIGNAL = 0 // Notify via signal. + SIGEV_NONE = 1 // Other notification: meaningless. + SIGEV_THREAD = 2 // Deliver via thread creation. + + SIGEV_THREAD_ID = 4 +) + +// `si_code' values for SIGSEGV signal. +const ( /* siginfo-consts.h:119:1: */ + SEGV_MAPERR = 1 // Address not mapped to object. + SEGV_ACCERR = 2 // Invalid permissions for mapped object. + SEGV_BNDERR = 3 // Bounds checking failure. + SEGV_PKUERR = 4 // Protection key checking failure. + SEGV_ACCADI = 5 // ADI not enabled for mapped object. + SEGV_ADIDERR = 6 // Disrupting MCD error. + SEGV_ADIPERR = 7 +) + +// `si_code' values for SIGBUS signal. +const ( /* siginfo-consts.h:138:1: */ + BUS_ADRALN = 1 // Invalid address alignment. + BUS_ADRERR = 2 // Non-existant physical address. + BUS_OBJERR = 3 // Object specific hardware error. + BUS_MCEERR_AR = 4 // Hardware memory error: action required. + BUS_MCEERR_AO = 5 +) + +// `si_code' values for SIGCHLD signal. +const ( /* siginfo-consts.h:172:1: */ + CLD_EXITED = 1 // Child has exited. + CLD_KILLED = 2 // Child was killed. + CLD_DUMPED = 3 // Child terminated abnormally. + CLD_TRAPPED = 4 // Traced child has trapped. + CLD_STOPPED = 5 // Child has stopped. + CLD_CONTINUED = 6 +) + +// `si_code' values for SIGPOLL signal. +const ( /* siginfo-consts.h:189:1: */ + POLL_IN = 1 // Data input available. + POLL_OUT = 2 // Output buffers available. + POLL_MSG = 3 // Input message available. + POLL_ERR = 4 // I/O error. + POLL_PRI = 5 // High priority input available. + POLL_HUP = 6 +) + +// X/Open requires some more fields with fixed names. + +// siginfo constants. Linux version. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Most of these constants are uniform across all architectures, but there +// is one exception. +// Architecture-specific adjustments to siginfo_t. + +// Values for `si_code'. Positive values are reserved for kernel-generated +// +// signals. +const ( /* siginfo-consts.h:35:1: */ + SI_ASYNCNL = -60 // Sent by asynch name lookup completion. + SI_DETHREAD = -7 // Sent by execve killing subsidiary + // threads. + SI_TKILL = -6 // Sent by tkill. + SI_SIGIO = -5 // Sent by queued SIGIO. + SI_ASYNCIO = -4 // Sent by AIO completion. + SI_MESGQ = -3 // Sent by real time mesq state change. + SI_TIMER = -2 // Sent by timer expiration. + SI_QUEUE = -1 // Sent by sigqueue. + SI_USER = 0 // Sent by kill, sigsend. + SI_KERNEL = 128 +) + +// `si_code' values for SIGILL signal. +const ( /* siginfo-consts.h:71:1: */ + ILL_ILLOPC = 1 // Illegal opcode. + ILL_ILLOPN = 2 // Illegal operand. + ILL_ILLADR = 3 // Illegal addressing mode. + ILL_ILLTRP = 4 // Illegal trap. + ILL_PRVOPC = 5 // Privileged opcode. + ILL_PRVREG = 6 // Privileged register. + ILL_COPROC = 7 // Coprocessor error. + ILL_BADSTK = 8 // Internal stack error. + ILL_BADIADDR = 9 +) + +// `si_code' values for SIGFPE signal. +const ( /* siginfo-consts.h:94:1: */ + FPE_INTDIV = 1 // Integer divide by zero. + FPE_INTOVF = 2 // Integer overflow. + FPE_FLTDIV = 3 // Floating point divide by zero. + FPE_FLTOVF = 4 // Floating point overflow. + FPE_FLTUND = 5 // Floating point underflow. + FPE_FLTRES = 6 // Floating point inexact result. + FPE_FLTINV = 7 // Floating point invalid operation. + FPE_FLTSUB = 8 // Subscript out of range. + FPE_FLTUNK = 14 // Undiagnosed floating-point exception. + FPE_CONDTRAP = 15 +) + +// sigstack, sigaltstack definitions. +// Copyright (C) 2015-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Minimum stack size for a signal handler. + +// System default stack size. + +// ss_flags values for stack_t. Linux version. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Possible values for `ss_flags'. +const ( /* ss_flags.h:27:1: */ + SS_ONSTACK = 1 + SS_DISABLE = 2 +) + +// Values for the first argument to `getitimer' and `setitimer'. +const ( /* time.h:89:1: */ + // Timers run in real time. + ITIMER_REAL = 0 + // Timers run only when the process is executing. + ITIMER_VIRTUAL = 1 + // Timers run when the process is executing and when + // the system is executing on behalf of the process. + ITIMER_PROF = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.14 Signal handling + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// Signal number definitions. Linux version. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Signal number constants. Generic template. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Fake signal functions. + +// We define here all the signal names listed in POSIX (1003.1-2008); +// as of 1003.1-2013, no additional signals have been added by POSIX. +// We also define here signal names that historically exist in every +// real-world POSIX variant (e.g. SIGWINCH). +// +// Signals in the 1-15 range are defined with their historical numbers. +// For other signals, we use the BSD numbers. +// There are two unallocated signal numbers in the 1-31 range: 7 and 29. +// Signal number 0 is reserved for use as kill(pid, 0), to test whether +// a process exists without sending it a signal. + +// ISO C99 signals. + +// Historical signals specified by POSIX. + +// New(er) POSIX signals (1003.1-2008, 1003.1-2013). + +// Nonstandard signals found in all modern POSIX systems +// (including both BSD and Linux). + +// Archaic names for compatibility. + +// Not all systems support real-time signals. bits/signum.h indicates +// that they are supported by overriding __SIGRTMAX to a value greater +// than __SIGRTMIN. These constants give the kernel-level hard limits, +// but some real-time signals may be used internally by glibc. Do not +// use these constants in application code; use SIGRTMIN and SIGRTMAX +// (defined in signal.h) instead. + +// Biggest signal number + 1 (including real-time signals). + +// Adjustments and additions to the signal number constants for +// most Linux systems. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// An integral type that can be modified atomically, without the +// +// possibility of a signal arriving in the middle of the operation. +type Sig_atomic_t = X__sig_atomic_t /* sig_atomic_t.h:8:24 */ + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +type Pid_t = X__pid_t /* signal.h:40:17 */ +type Uid_t = X__uid_t /* signal.h:46:17 */ + +// We need `struct timespec' later on. +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// AArch64 has selectable endianness. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Define __sigval_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Type for data associated with a signal. +type Sigval = struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte +} /* __sigval_t.h:24:1 */ + +type X__sigval_t = Sigval /* __sigval_t.h:30:22 */ + +// Some fields of siginfo_t have architecture-specific variations. +// Architecture-specific adjustments to siginfo_t. + +// This architecture has no adjustments to make to siginfo_t. + +type Siginfo_t = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + F__pad0 int32 + F_sifields struct { + F__ccgo_pad1 [0]uint64 + F_pad [28]int32 + } +} /* siginfo_t.h:124:5 */ + +// Architectures might also add architecture-specific constants. +// These are all considered GNU extensions. + +// Define __sigval_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// To avoid sigval_t (not a standard type name) having C++ name +// mangling depending on whether the selected standard includes union +// sigval, it should not be defined at all when using a standard for +// which the sigval name is not reserved; in that case, headers should +// not include and should use only the +// internal __sigval_t name. + +type Sigval_t = X__sigval_t /* sigval_t.h:16:20 */ + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Define __sigval_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Forward declaration. +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* sigevent_t.h:17:9 */ + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Define __sigval_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Forward declaration. +type Pthread_attr_t = Pthread_attr_t1 /* sigevent_t.h:17:30 */ + +// Structure to transport application-defined values with signals. +type Sigevent = struct { + Fsigev_value X__sigval_t + Fsigev_signo int32 + Fsigev_notify int32 + F_sigev_un struct { + F__ccgo_pad1 [0]uint64 + F_pad [12]int32 + } +} /* sigevent_t.h:22:9 */ + +// Structure to transport application-defined values with signals. +type Sigevent_t = Sigevent /* sigevent_t.h:42:5 */ + +// Type of a signal handler. +type X__sighandler_t = uintptr /* signal.h:72:14 */ + +// 4.4 BSD uses the name `sig_t' for this. +type Sig_t = X__sighandler_t /* signal.h:190:24 */ + +// Get the system-specific definitions of `struct sigaction' +// and the `SA_*' and `SIG_*'. constants. +// The proper definitions for Linux's sigaction. +// Copyright (C) 1993-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Structure describing the action to be taken when a signal arrives. +type Sigaction = struct { + F__sigaction_handler struct{ Fsa_handler X__sighandler_t } + Fsa_mask X__sigset_t + Fsa_flags int32 + F__ccgo_pad1 [4]byte + Fsa_restorer uintptr +} /* sigaction.h:27:1 */ + +// Get machine-dependent `struct sigcontext' and signal subcodes. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Kernel headers before 2.1.1 define a struct sigcontext_struct, but +// we need sigcontext. + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// Copyright (C) 2012 ARM Ltd. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 . + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// int-ll64 is used everywhere now. +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// asm-generic/int-ll64.h +// +// Integer declarations for architectures which use "long long" +// for 64-bit types. + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// Copyright (C) 2012 ARM Ltd. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 . + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// There seems to be no way of detecting this automatically from user +// space, so 64 bit architectures should override this in their +// bitsperlong.h. In particular, an architecture that supports +// both 32 and 64 bit user space must not rely on CONFIG_64BIT +// to decide it, but rather check a compiler provided macro. + +// __xx is ok: it doesn't pollute the POSIX namespace. Use these in the +// header files exported to user space + +type X__s8 = int8 /* int-ll64.h:20:25 */ +type X__u8 = uint8 /* int-ll64.h:21:23 */ + +type X__s16 = int16 /* int-ll64.h:23:26 */ +type X__u16 = uint16 /* int-ll64.h:24:24 */ + +type X__s32 = int32 /* int-ll64.h:26:24 */ +type X__u32 = uint32 /* int-ll64.h:27:22 */ + +type X__s64 = int64 /* int-ll64.h:30:44 */ +type X__u64 = uint64 /* int-ll64.h:31:42 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This allows for 1024 file descriptors: if NR_OPEN is ever grown +// beyond that you'll have to change this too. But 1024 fd's seem to be +// enough even for such "real" unices like OSF/1, so hopefully this is +// one limit that doesn't have to be changed [again]. +// +// Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in +// (and thus ) - but this is a more logical +// place for them. Solved by having dummy defines in . + +// This macro may have been defined in . But we always +// use the one here. + +type X__kernel_fd_set = struct{ Ffds_bits [16]uint64 } /* posix_types.h:27:3 */ + +// Type of a signal handler. +type X__kernel_sighandler_t = uintptr /* posix_types.h:30:14 */ + +// Type of a SYSV IPC key. +type X__kernel_key_t = int32 /* posix_types.h:33:13 */ +type X__kernel_mqd_t = int32 /* posix_types.h:34:13 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +type X__kernel_old_uid_t = uint16 /* posix_types.h:5:24 */ +type X__kernel_old_gid_t = uint16 /* posix_types.h:6:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// Copyright (C) 2012 ARM Ltd. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 . +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. +// +// First the types that are often defined in different ways across +// architectures, so that you can override them. + +type X__kernel_long_t = int64 /* posix_types.h:15:15 */ +type X__kernel_ulong_t = uint64 /* posix_types.h:16:23 */ + +type X__kernel_ino_t = X__kernel_ulong_t /* posix_types.h:20:26 */ + +type X__kernel_mode_t = uint32 /* posix_types.h:24:22 */ + +type X__kernel_pid_t = int32 /* posix_types.h:28:14 */ + +type X__kernel_ipc_pid_t = int32 /* posix_types.h:32:14 */ + +type X__kernel_uid_t = uint32 /* posix_types.h:36:22 */ +type X__kernel_gid_t = uint32 /* posix_types.h:37:22 */ + +type X__kernel_suseconds_t = X__kernel_long_t /* posix_types.h:41:26 */ + +type X__kernel_daddr_t = int32 /* posix_types.h:45:14 */ + +type X__kernel_uid32_t = uint32 /* posix_types.h:49:22 */ +type X__kernel_gid32_t = uint32 /* posix_types.h:50:22 */ + +type X__kernel_old_dev_t = uint32 /* posix_types.h:59:22 */ + +// Most 32 bit architectures use "unsigned int" size_t, +// and all 64 bit architectures use "unsigned long" size_t. +type X__kernel_size_t = X__kernel_ulong_t /* posix_types.h:72:26 */ +type X__kernel_ssize_t = X__kernel_long_t /* posix_types.h:73:25 */ +type X__kernel_ptrdiff_t = X__kernel_long_t /* posix_types.h:74:25 */ + +type X__kernel_fsid_t = struct{ Fval [2]int32 } /* posix_types.h:81:3 */ + +// anything below here should be completely generic +type X__kernel_off_t = X__kernel_long_t /* posix_types.h:87:25 */ +type X__kernel_loff_t = int64 /* posix_types.h:88:19 */ +type X__kernel_old_time_t = X__kernel_long_t /* posix_types.h:89:25 */ +type X__kernel_time_t = X__kernel_long_t /* posix_types.h:90:25 */ +type X__kernel_time64_t = int64 /* posix_types.h:91:19 */ +type X__kernel_clock_t = X__kernel_long_t /* posix_types.h:92:25 */ +type X__kernel_timer_t = int32 /* posix_types.h:93:14 */ +type X__kernel_clockid_t = int32 /* posix_types.h:94:14 */ +type X__kernel_caddr_t = uintptr /* posix_types.h:95:14 */ +type X__kernel_uid16_t = uint16 /* posix_types.h:96:24 */ +type X__kernel_gid16_t = uint16 /* posix_types.h:97:24 */ + +// Below are truly Linux-specific types that should never collide with +// any application/library that wants linux/types.h. + +type X__le16 = X__u16 /* types.h:24:25 */ +type X__be16 = X__u16 /* types.h:25:25 */ +type X__le32 = X__u32 /* types.h:26:25 */ +type X__be32 = X__u32 /* types.h:27:25 */ +type X__le64 = X__u64 /* types.h:28:25 */ +type X__be64 = X__u64 /* types.h:29:25 */ + +type X__sum16 = X__u16 /* types.h:31:25 */ +type X__wsum = X__u32 /* types.h:32:25 */ + +// aligned_u64 should be used in defining kernel<->userspace ABIs to avoid +// common 32/64-bit compat problems. +// 64-bit values align to 4-byte boundaries on x86_32 (and possibly other +// architectures) and to 8-byte boundaries on 64-bit architectures. The new +// aligned_64 type enforces 8-byte alignment so that structs containing +// aligned_64 values have the same alignment on 32-bit and 64-bit architectures. +// No conversions are necessary between 32-bit user-space and a 64-bit kernel. + +type X__poll_t = uint32 /* types.h:47:28 */ + +// Signal context structure - contains all info to do with the state +// before the signal handler was invoked. +type Sigcontext = struct { + Ffault_address X__u64 + Fregs [31]X__u64 + Fsp X__u64 + Fpc X__u64 + Fpstate X__u64 + F__reserved [4096]X__u8 +} /* sigcontext.h:28:1 */ + +// Allocation of __reserved[]: +// (Note: records do not necessarily occur in the order shown here.) +// +// size description +// +// 0x210 fpsimd_context +// 0x10 esr_context +// 0x8a0 sve_context (vl <= 64) (optional) +// 0x20 extra_context (optional) +// 0x10 terminator (null _aarch64_ctx) +// +// 0x510 (reserved for future allocation) +// +// New records that can exceed this space need to be opt-in for userspace, so +// that an expanded signal frame is not generated unexpectedly. The mechanism +// for opting in will depend on the extension that generates each new record. +// The above table documents the maximum set and sizes of records than can be +// generated when userspace does not opt in for any such extension. + +// Header to be used at the beginning of structures extending the user +// context. Such structures must be placed after the rt_sigframe on the stack +// and be 16-byte aligned. The last structure must be a dummy one with the +// magic and size set to 0. +type X_aarch64_ctx = struct { + Fmagic X__u32 + Fsize X__u32 +} /* sigcontext.h:66:1 */ + +type Fpsimd_context = struct { + Fhead struct { + Fmagic X__u32 + Fsize X__u32 + } + Ffpsr X__u32 + Ffpcr X__u32 + Fvregs [32]X__uint128_t +} /* sigcontext.h:73:1 */ + +// Note: similarly to all other integer fields, each V-register is stored in an +// endianness-dependent format, with the byte at offset i from the start of the +// in-memory representation of the register value containing +// +// bits [(7 + 8 * i) : (8 * i)] of the register on little-endian hosts; or +// bits [(127 - 8 * i) : (120 - 8 * i)] on big-endian hosts. + +// ESR_EL1 context + +type Esr_context = struct { + Fhead struct { + Fmagic X__u32 + Fsize X__u32 + } + Fesr X__u64 +} /* sigcontext.h:92:1 */ + +// extra_context: describes extra space in the signal frame for +// additional structures that don't fit in sigcontext.__reserved[]. +// +// Note: +// +// 1) fpsimd_context, esr_context and extra_context must be placed in +// sigcontext.__reserved[] if present. They cannot be placed in the +// extra space. Any other record can be placed either in the extra +// space or in sigcontext.__reserved[], unless otherwise specified in +// this file. +// +// 2) There must not be more than one extra_context. +// +// 3) If extra_context is present, it must be followed immediately in +// sigcontext.__reserved[] by the terminating null _aarch64_ctx. +// +// 4) The extra space to which datap points must start at the first +// 16-byte aligned address immediately after the terminating null +// _aarch64_ctx that follows the extra_context structure in +// __reserved[]. The extra space may overrun the end of __reserved[], +// as indicated by a sufficiently large value for the size field. +// +// 5) The extra space must itself be terminated with a null +// _aarch64_ctx. + +type Extra_context = struct { + Fhead struct { + Fmagic X__u32 + Fsize X__u32 + } + Fdatap X__u64 + Fsize X__u32 + F__reserved [3]X__u32 +} /* sigcontext.h:125:1 */ + +type Sve_context = struct { + Fhead struct { + Fmagic X__u32 + Fsize X__u32 + } + Fvl X__u16 + F__reserved [3]X__u16 +} /* sigcontext.h:134:1 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Define stack_t. Linux version. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Structure describing a signal stack. +type Stack_t = struct { + Fss_sp uintptr + Fss_flags int32 + F__ccgo_pad1 [4]byte + Fss_size Size_t +} /* stack_t.h:31:5 */ + +// This will define `ucontext_t' and `mcontext_t'. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// System V/AArch64 ABI compliant context switching support. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define stack_t. Linux version. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for core files and libthread_db. Generic Linux version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This is somewhat modelled after the file of the same name on SVR4 +// systems. It provides a definition of the core file format for ELF +// used on Linux. It doesn't have anything to do with the /proc file +// system, even though Linux has one. +// +// Anyway, the whole purpose of this file is for GDB and GDB only. +// Don't read too much into it. Don't use it for anything other than +// GDB unless you know what you are doing. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +type Suseconds_t = X__suseconds_t /* time.h:28:23 */ + +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We don't use `memset' because this would require a prototype and +// the array isn't too big. + +// Get sigset_t. + +// Get definition of timer specification structures. +// NB: Include guard matches what uses. + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +// Structure crudely representing a timezone. +// +// This is obsolete and should never be used. +type Timezone = struct { + Ftz_minuteswest int32 + Ftz_dsttime int32 +} /* time.h:52:1 */ + +// Type of the second argument to `getitimer' and +// +// the second and third arguments `setitimer'. +type Itimerval = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } +} /* time.h:105:1 */ + +type X__itimer_which_t = int32 /* time.h:118:13 */ + +// Convenience macros for operations on timevals. +// NOTE: `timercmp' does not work for >= or <=. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +// Copyright (C) 2009-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type User_regs_struct = struct { + Fregs [31]uint64 + Fsp uint64 + Fpc uint64 + Fpstate uint64 +} /* user.h:22:1 */ + +type User_fpsimd_struct = struct { + Fvregs [32]X__uint128_t + Ffpsr uint32 + Ffpcr uint32 +} /* user.h:30:1 */ + +// bits/procfs.h, provided by each architecture, must define +// elf_gregset_t, elf_fpregset_t and any other architecture-specific +// types needed. +// Types for registers for sys/procfs.h. AArch64 version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Type for a general-purpose register. +type Elf_greg_t = X__uint64_t /* procfs.h:25:20 */ + +// And the whole bunch of them. We could have used `struct +// +// pt_regs' directly in the typedef, but tradition says that +// the register set is an array, which does have some peculiar +// semantics, so leave it that way. +type Elf_gregset_t = [34]Elf_greg_t /* procfs.h:32:20 */ + +// Register set for the floating-point registers. +type Elf_fpregset_t = User_fpsimd_struct /* procfs.h:35:35 */ + +// bits/procfs-id.h must define __pr_uid_t and __pr_gid_t, the types +// of pr_uid and pr_gid. +// Types of pr_uid and pr_gid in struct elf_prpsinfo. Generic Linux version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pr_uid_t = uint32 /* procfs-id.h:24:22 */ +type X__pr_gid_t = uint32 /* procfs-id.h:25:22 */ + +// Signal info. +type Elf_siginfo = struct { + Fsi_signo int32 + Fsi_code int32 + Fsi_errno int32 +} /* procfs.h:49:1 */ + +// Definitions to generate Intel SVR4-like core files. These mostly +// have the same names as the SVR4 types with "elf_" tacked on the +// front to prevent clashes with Linux definitions, and the typedef +// forms have been avoided. This is mostly like the SVR4 structure, +// but more Linuxy, with things that Linux does not support and which +// GDB doesn't really use excluded. + +type Elf_prstatus = struct { + Fpr_info struct { + Fsi_signo int32 + Fsi_code int32 + Fsi_errno int32 + } + Fpr_cursig int16 + F__ccgo_pad1 [2]byte + Fpr_sigpend uint64 + Fpr_sighold uint64 + Fpr_pid X__pid_t + Fpr_ppid X__pid_t + Fpr_pgrp X__pid_t + Fpr_sid X__pid_t + Fpr_utime struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } + Fpr_stime struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } + Fpr_cutime struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } + Fpr_cstime struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } + Fpr_reg Elf_gregset_t + Fpr_fpvalid int32 + F__ccgo_pad2 [4]byte +} /* procfs.h:63:1 */ + +type Elf_prpsinfo = struct { + Fpr_state uint8 + Fpr_sname uint8 + Fpr_zomb uint8 + Fpr_nice uint8 + F__ccgo_pad1 [4]byte + Fpr_flag uint64 + Fpr_uid X__pr_uid_t + Fpr_gid X__pr_gid_t + Fpr_pid int32 + Fpr_ppid int32 + Fpr_pgrp int32 + Fpr_sid int32 + Fpr_fname [16]uint8 + Fpr_psargs [80]uint8 +} /* procfs.h:84:1 */ + +// The rest of this file provides the types for emulation of the +// Solaris interfaces that should be implemented by +// users of libthread_db. + +// Addresses. +type Psaddr_t = uintptr /* procfs.h:104:14 */ + +// Types of prgregset_t and prfpregset_t. Generic Linux version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__prgregset_t = Elf_gregset_t /* procfs-prregset.h:24:23 */ +type X__prfpregset_t = Elf_fpregset_t /* procfs-prregset.h:25:24 */ + +// Register sets. Linux has different names. +type Prgregset_t = X__prgregset_t /* procfs.h:109:23 */ +type Prfpregset_t = X__prfpregset_t /* procfs.h:110:24 */ + +// We don't have any differences between processes and threads, +// +// therefore have only one PID type. +type Lwpid_t = X__pid_t /* procfs.h:114:17 */ + +// Process status and info. In the end we do provide typedefs for them. +type Prstatus_t = Elf_prstatus /* procfs.h:117:29 */ +type Prpsinfo_t = Elf_prpsinfo /* procfs.h:118:29 */ + +// On some architectures, provide other-ABI variants of the above +// types. +// Extra sys/procfs.h definitions. Generic Linux version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type Greg_t = Elf_greg_t /* ucontext.h:39:20 */ + +// Container for all general registers. +type Gregset_t = Elf_gregset_t /* ucontext.h:42:23 */ + +// Structure to describe FPU registers. +type Fpregset_t = Elf_fpregset_t /* ucontext.h:45:24 */ + +// Context to describe whole processor state. This only describes +// +// the core registers; coprocessor registers get saved elsewhere +// (e.g. in uc_regspace, or somewhere unspecified on the stack +// during non-RT signal handlers). +type Mcontext_t = struct { + Ffault_address uint64 + Fregs [31]uint64 + Fsp uint64 + Fpc uint64 + Fpstate uint64 + F__reserved [4096]uint8 +} /* ucontext.h:64:5 */ + +// Userlevel context. +type Ucontext_t1 = struct { + Fuc_flags uint64 + Fuc_link uintptr + Fuc_stack Stack_t + Fuc_sigmask Sigset_t + Fuc_mcontext Mcontext_t +} /* ucontext.h:67:9 */ + +// Userlevel context. +type Ucontext_t = Ucontext_t1 /* ucontext.h:74:5 */ + +// Define struct sigstack. +// Copyright (C) 1998-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Structure describing a signal stack (obsolete). +type Sigstack = struct { + Fss_sp uintptr + Fss_onstack int32 + F__ccgo_pad1 [4]byte +} /* struct_sigstack.h:23:1 */ + +// System-specific extensions. +// System-specific extensions of , Linux version. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/stdatomic.go b/internal/libc/stdatomic.go new file mode 100644 index 0000000..af1a363 --- /dev/null +++ b/internal/libc/stdatomic.go @@ -0,0 +1,1114 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "sync" + "sync/atomic" + "unsafe" +) + +var ( + int8Mu sync.Mutex + int16Mu sync.Mutex + int32Mu sync.Mutex + int64Mu sync.Mutex +) + +// type __atomic_fetch_add(type *ptr, type val, int memorder) +// +// { tmp = *ptr; *ptr op= val; return tmp; } +// { tmp = *ptr; *ptr = ~(*ptr & val); return tmp; } // nand + +func X__c11_atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_addInt8(t, ptr, val, 0) +} + +func X__atomic_fetch_addInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*int8)(unsafe.Pointer(ptr)) + *(*int8)(unsafe.Pointer(ptr)) += val + return r +} + +func X__c11_atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_addUint8(t, ptr, val, 0) +} + +func X__atomic_fetch_addUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*uint8)(unsafe.Pointer(ptr)) + *(*uint8)(unsafe.Pointer(ptr)) += val + return r +} + +func X__c11_atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_addInt16(t, ptr, val, 0) +} + +func X__atomic_fetch_addInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*int16)(unsafe.Pointer(ptr)) + *(*int16)(unsafe.Pointer(ptr)) += val + return r +} + +func X__c11_atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_addUint16(t, ptr, val, 0) +} + +func X__atomic_fetch_addUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*uint16)(unsafe.Pointer(ptr)) + *(*uint16)(unsafe.Pointer(ptr)) += val + return r +} + +func X__c11_atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_addInt32(t, ptr, val, 0) +} + +func X__atomic_fetch_addInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + p := (*int32)(unsafe.Pointer(ptr)) + return atomic.AddInt32(p, val) - val +} + +func X__c11_atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_addUint32(t, ptr, val, 0) +} + +func X__atomic_fetch_addUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + p := (*uint32)(unsafe.Pointer(ptr)) + return atomic.AddUint32(p, val) - val +} + +func X__c11_atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_addInt64(t, ptr, val, 0) +} + +func X__atomic_fetch_addInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + p := (*int64)(unsafe.Pointer(ptr)) + return atomic.AddInt64(p, val) - val +} + +func X__c11_atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_addUint64(t, ptr, val, 0) +} + +func X__atomic_fetch_addUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + p := (*uint64)(unsafe.Pointer(ptr)) + return atomic.AddUint64(p, val) - val +} + +// ---- + +func X__c11_atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_andInt8(t, ptr, val, 0) +} + +func X__atomic_fetch_andInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*int8)(unsafe.Pointer(ptr)) + *(*int8)(unsafe.Pointer(ptr)) &= val + return r +} + +func X__c11_atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_andUint8(t, ptr, val, 0) +} + +func X__atomic_fetch_andUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*uint8)(unsafe.Pointer(ptr)) + *(*uint8)(unsafe.Pointer(ptr)) &= val + return r +} + +func X__c11_atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_andInt16(t, ptr, val, 0) +} + +func X__atomic_fetch_andInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*int16)(unsafe.Pointer(ptr)) + *(*int16)(unsafe.Pointer(ptr)) &= val + return r +} + +func X__c11_atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_andUint16(t, ptr, val, 0) +} + +func X__atomic_fetch_andUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*uint16)(unsafe.Pointer(ptr)) + *(*uint16)(unsafe.Pointer(ptr)) &= val + return r +} + +func X__c11_atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_andInt32(t, ptr, val, 0) +} + +func X__atomic_fetch_andInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + p := (*int32)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadInt32(p) + if atomic.CompareAndSwapInt32(p, r, r&val) { + return r + } + } +} + +func X__c11_atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_andUint32(t, ptr, val, 0) +} + +func X__atomic_fetch_andUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + p := (*uint32)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadUint32(p) + if atomic.CompareAndSwapUint32(p, r, r&val) { + return r + } + } +} + +func X__c11_atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_andInt64(t, ptr, val, 0) +} + +func X__atomic_fetch_andInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + p := (*int64)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadInt64(p) + if atomic.CompareAndSwapInt64(p, r, r&val) { + return r + } + } +} + +func X__c11_atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_andUint64(t, ptr, val, 0) +} + +func X__atomic_fetch_andUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + p := (*uint64)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadUint64(p) + if atomic.CompareAndSwapUint64(p, r, r&val) { + return r + } + } +} + +// ---- + +func X__c11_atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_orInt8(t, ptr, val, 0) +} + +func X__atomic_fetch_orInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*int8)(unsafe.Pointer(ptr)) + *(*int8)(unsafe.Pointer(ptr)) |= val + return r +} + +func X__c11_atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_orUint8(t, ptr, val, 0) +} + +func X__atomic_fetch_orUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*uint8)(unsafe.Pointer(ptr)) + *(*uint8)(unsafe.Pointer(ptr)) |= val + return r +} + +func X__c11_atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_orInt16(t, ptr, val, 0) +} + +func X__atomic_fetch_orInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*int16)(unsafe.Pointer(ptr)) + *(*int16)(unsafe.Pointer(ptr)) |= val + return r +} + +func X__c11_atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_orUint16(t, ptr, val, 0) +} + +func X__atomic_fetch_orUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*uint16)(unsafe.Pointer(ptr)) + *(*uint16)(unsafe.Pointer(ptr)) |= val + return r +} + +func X__c11_atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_orInt32(t, ptr, val, 0) +} + +func X__atomic_fetch_orInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + p := (*int32)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadInt32(p) + if atomic.CompareAndSwapInt32(p, r, r|val) { + return r + } + } +} + +func X__c11_atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_orUint32(t, ptr, val, 0) +} + +func X__atomic_fetch_orUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + p := (*uint32)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadUint32(p) + if atomic.CompareAndSwapUint32(p, r, r|val) { + return r + } + } +} + +func X__c11_atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_orInt64(t, ptr, val, 0) +} + +func X__atomic_fetch_orInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + p := (*int64)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadInt64(p) + if atomic.CompareAndSwapInt64(p, r, r|val) { + return r + } + } +} + +func X__c11_atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_orUint64(t, ptr, val, 0) +} + +func X__atomic_fetch_orUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + p := (*uint64)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadUint64(p) + if atomic.CompareAndSwapUint64(p, r, r|val) { + return r + } + } +} + +// ---- + +func X__c11_atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_subInt8(t, ptr, val, 0) +} + +func X__atomic_fetch_subInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*int8)(unsafe.Pointer(ptr)) + *(*int8)(unsafe.Pointer(ptr)) -= val + return r +} + +func X__c11_atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_subUint8(t, ptr, val, 0) +} + +func X__atomic_fetch_subUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*uint8)(unsafe.Pointer(ptr)) + *(*uint8)(unsafe.Pointer(ptr)) -= val + return r +} + +func X__c11_atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_subInt16(t, ptr, val, 0) +} + +func X__atomic_fetch_subInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*int16)(unsafe.Pointer(ptr)) + *(*int16)(unsafe.Pointer(ptr)) -= val + return r +} + +func X__c11_atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_subUint16(t, ptr, val, 0) +} + +func X__atomic_fetch_subUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*uint16)(unsafe.Pointer(ptr)) + *(*uint16)(unsafe.Pointer(ptr)) -= val + return r +} + +func X__c11_atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_subInt32(t, ptr, val, 0) +} + +func X__atomic_fetch_subInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + p := (*int32)(unsafe.Pointer(ptr)) + return atomic.AddInt32(p, -val) + val +} + +func X__c11_atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_subUint32(t, ptr, val, 0) +} + +func X__atomic_fetch_subUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + p := (*uint32)(unsafe.Pointer(ptr)) + return atomic.AddUint32(p, ^(val-1)) + val +} + +func X__c11_atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_subInt64(t, ptr, val, 0) +} + +func X__atomic_fetch_subInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + p := (*int64)(unsafe.Pointer(ptr)) + return atomic.AddInt64(p, -val) + val +} + +func X__c11_atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_subUint64(t, ptr, val, 0) +} + +func X__atomic_fetch_subUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + p := (*uint64)(unsafe.Pointer(ptr)) + return atomic.AddUint64(p, ^(val-1)) + val +} + +// ---- + +func X__c11_atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + return X__atomic_fetch_xorInt8(t, ptr, val, 0) +} + +func X__atomic_fetch_xorInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*int8)(unsafe.Pointer(ptr)) + *(*int8)(unsafe.Pointer(ptr)) ^= val + return r +} + +func X__c11_atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + return X__atomic_fetch_xorUint8(t, ptr, val, 0) +} + +func X__atomic_fetch_xorUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*uint8)(unsafe.Pointer(ptr)) + *(*uint8)(unsafe.Pointer(ptr)) ^= val + return r +} + +func X__c11_atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + return X__atomic_fetch_xorInt16(t, ptr, val, 0) +} + +func X__atomic_fetch_xorInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*int16)(unsafe.Pointer(ptr)) + *(*int16)(unsafe.Pointer(ptr)) ^= val + return r +} + +func X__c11_atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + return X__atomic_fetch_xorUint16(t, ptr, val, 0) +} + +func X__atomic_fetch_xorUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*uint16)(unsafe.Pointer(ptr)) + *(*uint16)(unsafe.Pointer(ptr)) ^= val + return r +} + +func X__c11_atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return X__atomic_fetch_xorInt32(t, ptr, val, 0) +} + +func X__atomic_fetch_xorInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + p := (*int32)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadInt32(p) + if atomic.CompareAndSwapInt32(p, r, r^val) { + return r + } + } +} + +func X__c11_atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return X__atomic_fetch_xorUint32(t, ptr, val, 0) +} + +func X__atomic_fetch_xorUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + p := (*uint32)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadUint32(p) + if atomic.CompareAndSwapUint32(p, r, r^val) { + return r + } + } +} + +func X__c11_atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return X__atomic_fetch_xorInt64(t, ptr, val, 0) +} + +func X__atomic_fetch_xorInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + p := (*int64)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadInt64(p) + if atomic.CompareAndSwapInt64(p, r, r^val) { + return r + } + } +} + +func X__c11_atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return X__atomic_fetch_xorUint64(t, ptr, val, 0) +} + +func X__atomic_fetch_xorUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + p := (*uint64)(unsafe.Pointer(ptr)) + for { + r = atomic.LoadUint64(p) + if atomic.CompareAndSwapUint64(p, r, r^val) { + return r + } + } +} + +// ---- + +// void __atomic_exchange (type *ptr, type *val, type *ret, int memorder) + +func X__c11_atomic_exchangeInt8(t *TLS, ptr uintptr, val int8, _ int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*int8)(unsafe.Pointer(ptr)) + *(*int8)(unsafe.Pointer(ptr)) = val + return r +} + +func X__atomic_exchangeInt8(t *TLS, ptr, val, ret uintptr, _ int32) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + *(*int8)(unsafe.Pointer(ret)) = *(*int8)(unsafe.Pointer(ptr)) + *(*int8)(unsafe.Pointer(ptr)) = *(*int8)(unsafe.Pointer(val)) +} + +func X__c11_atomic_exchangeUint8(t *TLS, ptr uintptr, val uint8, _ int32) (r uint8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + r = *(*uint8)(unsafe.Pointer(ptr)) + *(*uint8)(unsafe.Pointer(ptr)) = val + return r +} + +func X__atomic_exchangeUint8(t *TLS, ptr, val, ret uintptr, _ int32) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + *(*uint8)(unsafe.Pointer(ret)) = *(*uint8)(unsafe.Pointer(ptr)) + *(*uint8)(unsafe.Pointer(ptr)) = *(*uint8)(unsafe.Pointer(val)) +} + +func X__c11_atomic_exchangeInt16(t *TLS, ptr uintptr, val int16, _ int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*int16)(unsafe.Pointer(ptr)) + *(*int16)(unsafe.Pointer(ptr)) = val + return r +} + +func X__atomic_exchangeInt16(t *TLS, ptr, val, ret uintptr, _ int32) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + *(*int16)(unsafe.Pointer(ret)) = *(*int16)(unsafe.Pointer(ptr)) + *(*int16)(unsafe.Pointer(ptr)) = *(*int16)(unsafe.Pointer(val)) +} + +func X__c11_atomic_exchangeUint16(t *TLS, ptr uintptr, val uint16, _ int32) (r uint16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + r = *(*uint16)(unsafe.Pointer(ptr)) + *(*uint16)(unsafe.Pointer(ptr)) = val + return r +} + +func X__atomic_exchangeUint16(t *TLS, ptr, val, ret uintptr, _ int32) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + *(*uint16)(unsafe.Pointer(ret)) = *(*uint16)(unsafe.Pointer(ptr)) + *(*uint16)(unsafe.Pointer(ptr)) = *(*uint16)(unsafe.Pointer(val)) +} + +func X__c11_atomic_exchangeInt32(t *TLS, ptr uintptr, val int32, _ int32) (r int32) { + return atomic.SwapInt32((*int32)(unsafe.Pointer(ptr)), val) +} + +func X__atomic_exchangeInt32(t *TLS, ptr, val, ret uintptr, _ int32) { + *(*int32)(unsafe.Pointer(ret)) = atomic.SwapInt32((*int32)(unsafe.Pointer(ptr)), *(*int32)(unsafe.Pointer(val))) +} + +func X__c11_atomic_exchangeUint32(t *TLS, ptr uintptr, val uint32, _ int32) (r uint32) { + return uint32(atomic.SwapInt32((*int32)(unsafe.Pointer(ptr)), int32(val))) +} + +func X__atomic_exchangeUint32(t *TLS, ptr, val, ret uintptr, _ int32) { + *(*uint32)(unsafe.Pointer(ret)) = atomic.SwapUint32((*uint32)(unsafe.Pointer(ptr)), *(*uint32)(unsafe.Pointer(val))) +} + +func X__c11_atomic_exchangeInt64(t *TLS, ptr uintptr, val int64, _ int32) (r int64) { + return atomic.SwapInt64((*int64)(unsafe.Pointer(ptr)), val) +} + +func X__atomic_exchangeInt64(t *TLS, ptr, val, ret uintptr, _ int32) { + *(*int64)(unsafe.Pointer(ret)) = atomic.SwapInt64((*int64)(unsafe.Pointer(ptr)), *(*int64)(unsafe.Pointer(val))) +} + +func X__c11_atomic_exchangeUint64(t *TLS, ptr uintptr, val uint64, _ int32) (r uint64) { + return uint64(atomic.SwapInt64((*int64)(unsafe.Pointer(ptr)), int64(val))) +} + +func X__atomic_exchangeUint64(t *TLS, ptr, val, ret uintptr, _ int32) { + *(*uint64)(unsafe.Pointer(ret)) = atomic.SwapUint64((*uint64)(unsafe.Pointer(ptr)), *(*uint64)(unsafe.Pointer(val))) +} + +// ---- + +// bool __atomic_compare_exchange (type *ptr, type *expected, type *desired, bool weak, int success_memorder, int failure_memorder) + +// https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html +// +// This built-in function implements an atomic compare and exchange operation. +// This compares the contents of *ptr with the contents of *expected. If equal, +// the operation is a read-modify-write operation that writes desired into +// *ptr. If they are not equal, the operation is a read and the current +// contents of *ptr are written into *expected. weak is true for weak +// compare_exchange, which may fail spuriously, and false for the strong +// variation, which never fails spuriously. Many targets only offer the strong +// variation and ignore the parameter. When in doubt, use the strong variation. +// +// If desired is written into *ptr then true is returned and memory is affected +// according to the memory order specified by success_memorder. There are no +// restrictions on what memory order can be used here. +// +// Otherwise, false is returned and memory is affected according to +// failure_memorder. This memory order cannot be __ATOMIC_RELEASE nor +// __ATOMIC_ACQ_REL. It also cannot be a stronger order than that specified by +// success_memorder. + +func X__atomic_compare_exchangeInt8(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) int32 { + int8Mu.Lock() + + defer int8Mu.Unlock() + + have := *(*int8)(unsafe.Pointer(ptr)) + if have == *(*int8)(unsafe.Pointer(expected)) { + *(*int8)(unsafe.Pointer(ptr)) = *(*int8)(unsafe.Pointer(desired)) + return 1 + } + + *(*int8)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__atomic_compare_exchangeUint8(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) int32 { + return X__atomic_compare_exchangeInt8(t, ptr, expected, desired, weak, success, failure) +} + +func X__atomic_compare_exchangeInt16(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) int32 { + int16Mu.Lock() + + defer int16Mu.Unlock() + + have := *(*int16)(unsafe.Pointer(ptr)) + if have == *(*int16)(unsafe.Pointer(expected)) { + *(*int16)(unsafe.Pointer(ptr)) = *(*int16)(unsafe.Pointer(desired)) + return 1 + } + + *(*int16)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__atomic_compare_exchangeUint16(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) int32 { + return X__atomic_compare_exchangeInt16(t, ptr, expected, desired, weak, success, failure) +} + +func X__atomic_compare_exchangeInt32(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) int32 { + p := (*int32)(unsafe.Pointer(ptr)) + exp := (*int32)(unsafe.Pointer(expected)) + des := *(*int32)(unsafe.Pointer(desired)) + old := *exp + if atomic.CompareAndSwapInt32(p, old, des) { + return 1 + } + *exp = atomic.LoadInt32(p) + return 0 +} + +func X__atomic_compare_exchangeUint32(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) int32 { + p := (*uint32)(unsafe.Pointer(ptr)) + exp := (*uint32)(unsafe.Pointer(expected)) + des := *(*uint32)(unsafe.Pointer(desired)) + old := *exp + if atomic.CompareAndSwapUint32(p, old, des) { + return 1 + } + *exp = atomic.LoadUint32(p) + return 0 +} + +func X__atomic_compare_exchangeInt64(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) int32 { + p := (*int64)(unsafe.Pointer(ptr)) + exp := (*int64)(unsafe.Pointer(expected)) + des := *(*int64)(unsafe.Pointer(desired)) + old := *exp + if atomic.CompareAndSwapInt64(p, old, des) { + return 1 + } + *exp = atomic.LoadInt64(p) + return 0 +} + +func X__atomic_compare_exchangeUint64(t *TLS, ptr, expected, desired uintptr, weak, success, failure int32) int32 { + p := (*uint64)(unsafe.Pointer(ptr)) + exp := (*uint64)(unsafe.Pointer(expected)) + des := *(*uint64)(unsafe.Pointer(desired)) + old := *exp + if atomic.CompareAndSwapUint64(p, old, des) { + return 1 + } + *exp = atomic.LoadUint64(p) + return 0 +} + +func X__c11_atomic_compare_exchange_strongInt8(t *TLS, ptr, expected uintptr, desired int8, success, failure int32) int32 { + int8Mu.Lock() + + defer int8Mu.Unlock() + + have := *(*int8)(unsafe.Pointer(ptr)) + if have == *(*int8)(unsafe.Pointer(expected)) { + *(*int8)(unsafe.Pointer(ptr)) = desired + return 1 + } + + *(*int8)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__c11_atomic_compare_exchange_strongUint8(t *TLS, ptr, expected uintptr, desired uint8, success, failure int32) int32 { + return X__c11_atomic_compare_exchange_strongInt8(t, ptr, expected, int8(desired), success, failure) +} + +func X__c11_atomic_compare_exchange_strongInt16(t *TLS, ptr, expected uintptr, desired int16, success, failure int32) int32 { + int16Mu.Lock() + + defer int16Mu.Unlock() + + have := *(*int16)(unsafe.Pointer(ptr)) + if have == *(*int16)(unsafe.Pointer(expected)) { + *(*int16)(unsafe.Pointer(ptr)) = desired + return 1 + } + + *(*int16)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__c11_atomic_compare_exchange_strongUint16(t *TLS, ptr, expected uintptr, desired uint16, success, failure int32) int32 { + return X__c11_atomic_compare_exchange_strongInt16(t, ptr, expected, int16(desired), success, failure) +} + +func X__c11_atomic_compare_exchange_strongInt32(t *TLS, ptr, expected uintptr, desired, success, failure int32) int32 { + int32Mu.Lock() + + defer int32Mu.Unlock() + + have := *(*int32)(unsafe.Pointer(ptr)) + if have == *(*int32)(unsafe.Pointer(expected)) { + *(*int32)(unsafe.Pointer(ptr)) = desired + return 1 + } + + *(*int32)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__c11_atomic_compare_exchange_strongUint32(t *TLS, ptr, expected uintptr, desired uint32, success, failure int32) int32 { + return X__c11_atomic_compare_exchange_strongInt32(t, ptr, expected, int32(desired), success, failure) +} + +func X__c11_atomic_compare_exchange_strongInt64(t *TLS, ptr, expected uintptr, desired int64, success, failure int32) int32 { + int64Mu.Lock() + + defer int64Mu.Unlock() + + have := *(*int64)(unsafe.Pointer(ptr)) + if have == *(*int64)(unsafe.Pointer(expected)) { + *(*int64)(unsafe.Pointer(ptr)) = desired + return 1 + } + + *(*int64)(unsafe.Pointer(expected)) = have + return 0 +} + +func X__c11_atomic_compare_exchange_strongUint64(t *TLS, ptr, expected uintptr, desired uint64, success, failure int32) int32 { + return X__c11_atomic_compare_exchange_strongInt64(t, ptr, expected, int64(desired), success, failure) +} + +// ---- + +// void __atomic_load (type *ptr, type *ret, int memorder) + +func X__c11_atomic_loadInt8(t *TLS, ptr uintptr, memorder int32) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + return *(*int8)(unsafe.Pointer(ptr)) +} + +func X__atomic_loadInt8(t *TLS, ptr, ret uintptr, memorder int32) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + *(*int8)(unsafe.Pointer(ret)) = *(*int8)(unsafe.Pointer(ptr)) +} + +func X__c11_atomic_loadUint8(t *TLS, ptr uintptr, memorder int32) (r uint8) { + return uint8(X__c11_atomic_loadInt8(t, ptr, memorder)) +} + +func X__atomic_loadUint8(t *TLS, ptr, ret uintptr, memorder int32) { + X__atomic_loadInt8(t, ptr, ret, memorder) +} + +func X__c11_atomic_loadInt16(t *TLS, ptr uintptr, memorder int32) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + return *(*int16)(unsafe.Pointer(ptr)) +} + +func X__atomic_loadInt16(t *TLS, ptr, ret uintptr, memorder int32) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + *(*int16)(unsafe.Pointer(ret)) = *(*int16)(unsafe.Pointer(ptr)) +} + +func X__c11_atomic_loadUint16(t *TLS, ptr uintptr, memorder int32) (r uint16) { + return uint16(X__c11_atomic_loadInt16(t, ptr, memorder)) +} + +func X__atomic_loadUint16(t *TLS, ptr, ret uintptr, memorder int32) { + X__atomic_loadInt16(t, ptr, ret, memorder) +} + +func X__c11_atomic_loadInt32(t *TLS, ptr uintptr, memorder int32) (r int32) { + return atomic.LoadInt32((*int32)(unsafe.Pointer(ptr))) +} + +func X__atomic_loadInt32(t *TLS, ptr, ret uintptr, memorder int32) { + *(*int32)(unsafe.Pointer(ret)) = atomic.LoadInt32((*int32)(unsafe.Pointer(ptr))) +} + +func X__c11_atomic_loadUint32(t *TLS, ptr uintptr, memorder int32) (r uint32) { + return uint32(X__c11_atomic_loadInt32(t, ptr, memorder)) +} + +func X__atomic_loadUint32(t *TLS, ptr, ret uintptr, memorder int32) { + X__atomic_loadInt32(t, ptr, ret, memorder) +} + +func X__c11_atomic_loadInt64(t *TLS, ptr uintptr, memorder int32) (r int64) { + return atomic.LoadInt64((*int64)(unsafe.Pointer(ptr))) +} + +func X__atomic_loadInt64(t *TLS, ptr, ret uintptr, memorder int32) { + *(*int64)(unsafe.Pointer(ret)) = atomic.LoadInt64((*int64)(unsafe.Pointer(ptr))) +} + +func X__c11_atomic_loadUint64(t *TLS, ptr uintptr, memorder int32) (r uint64) { + return uint64(X__c11_atomic_loadInt64(t, ptr, memorder)) +} + +func X__atomic_loadUint64(t *TLS, ptr, ret uintptr, memorder int32) { + X__atomic_loadInt64(t, ptr, ret, memorder) +} + +// ---- + +// void __atomic_store (type *ptr, type *val, int memorder) + +func X__c11_atomic_storeInt8(t *TLS, ptr uintptr, val int8, memorder int32) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + *(*int8)(unsafe.Pointer(ptr)) = val +} + +func X__atomic_storeInt8(t *TLS, ptr, val uintptr, memorder int32) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + *(*int8)(unsafe.Pointer(ptr)) = *(*int8)(unsafe.Pointer(val)) +} + +func X__c11_atomic_storeUint8(t *TLS, ptr uintptr, val uint8, memorder int32) { + X__c11_atomic_storeInt8(t, ptr, int8(val), memorder) +} + +func X__atomic_storeUint8(t *TLS, ptr, val uintptr, memorder int32) { + X__atomic_storeInt8(t, ptr, val, memorder) +} + +func X__c11_atomic_storeInt16(t *TLS, ptr uintptr, val int16, memorder int32) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + *(*int16)(unsafe.Pointer(ptr)) = val +} + +func X__atomic_storeInt16(t *TLS, ptr, val uintptr, memorder int32) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + *(*int16)(unsafe.Pointer(ptr)) = *(*int16)(unsafe.Pointer(val)) +} + +func X__c11_atomic_storeUint16(t *TLS, ptr uintptr, val uint16, memorder int32) { + X__c11_atomic_storeInt16(t, ptr, int16(val), memorder) +} + +func X__atomic_storeUint16(t *TLS, ptr, val uintptr, memorder int32) { + X__atomic_storeInt16(t, ptr, val, memorder) +} + +func X__c11_atomic_storeInt32(t *TLS, ptr uintptr, val int32, memorder int32) { + atomic.StoreInt32((*int32)(unsafe.Pointer(ptr)), val) +} + +func X__atomic_storeInt32(t *TLS, ptr, val uintptr, memorder int32) { + atomic.StoreInt32((*int32)(unsafe.Pointer(ptr)), *(*int32)(unsafe.Pointer(val))) +} + +func X__c11_atomic_storeUint32(t *TLS, ptr uintptr, val uint32, memorder int32) { + X__c11_atomic_storeInt32(t, ptr, int32(val), memorder) +} + +func X__atomic_storeUint32(t *TLS, ptr, val uintptr, memorder int32) { + X__atomic_storeInt32(t, ptr, val, memorder) +} + +func X__c11_atomic_storeInt64(t *TLS, ptr uintptr, val int64, memorder int32) { + atomic.StoreInt64((*int64)(unsafe.Pointer(ptr)), val) +} + +func X__atomic_storeInt64(t *TLS, ptr, val uintptr, memorder int32) { + atomic.StoreInt64((*int64)(unsafe.Pointer(ptr)), *(*int64)(unsafe.Pointer(val))) +} + +func X__c11_atomic_storeUint64(t *TLS, ptr uintptr, val uint64, memorder int32) { + X__c11_atomic_storeInt64(t, ptr, int64(val), memorder) +} + +func X__atomic_storeUint64(t *TLS, ptr, val uintptr, memorder int32) { + X__atomic_storeInt64(t, ptr, val, memorder) +} + +// type __sync_val_compare_and_swap (type *ptr, type oldval type newval, ...) +func X__sync_val_compare_and_swapInt8(t *TLS, ptr uintptr, oldval, newval int8) (r int8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + if r = *(*int8)(unsafe.Pointer(ptr)); r == oldval { + *(*int8)(unsafe.Pointer(ptr)) = newval + } + + return r +} + +func X__sync_val_compare_and_swapUint8(t *TLS, ptr uintptr, oldval, newval uint8) (r uint8) { + int8Mu.Lock() + + defer int8Mu.Unlock() + + if r = *(*uint8)(unsafe.Pointer(ptr)); r == oldval { + *(*uint8)(unsafe.Pointer(ptr)) = newval + } + + return r +} + +func X__sync_val_compare_and_swapInt16(t *TLS, ptr uintptr, oldval, newval int16) (r int16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + if r = *(*int16)(unsafe.Pointer(ptr)); r == oldval { + *(*int16)(unsafe.Pointer(ptr)) = newval + } + + return r +} + +func X__sync_val_compare_and_swapUint16(t *TLS, ptr uintptr, oldval, newval uint16) (r uint16) { + int16Mu.Lock() + + defer int16Mu.Unlock() + + if r = *(*uint16)(unsafe.Pointer(ptr)); r == oldval { + *(*uint16)(unsafe.Pointer(ptr)) = newval + } + + return r +} + +func X__sync_val_compare_and_swapInt32(t *TLS, ptr uintptr, oldval, newval int32) (r int32) { + int32Mu.Lock() + + defer int32Mu.Unlock() + + if r = *(*int32)(unsafe.Pointer(ptr)); r == oldval { + *(*int32)(unsafe.Pointer(ptr)) = newval + } + + return r +} + +func X__sync_val_compare_and_swapUint32(t *TLS, ptr uintptr, oldval, newval uint32) (r uint32) { + int32Mu.Lock() + + defer int32Mu.Unlock() + + if r = *(*uint32)(unsafe.Pointer(ptr)); r == oldval { + *(*uint32)(unsafe.Pointer(ptr)) = newval + } + + return r +} + +func X__sync_val_compare_and_swapInt64(t *TLS, ptr uintptr, oldval, newval int64) (r int64) { + int64Mu.Lock() + + defer int64Mu.Unlock() + + if r = *(*int64)(unsafe.Pointer(ptr)); r == oldval { + *(*int64)(unsafe.Pointer(ptr)) = newval + } + + return r +} + +func X__sync_val_compare_and_swapUint64(t *TLS, ptr uintptr, oldval, newval uint64) (r uint64) { + int64Mu.Lock() + + defer int64Mu.Unlock() + + if r = *(*uint64)(unsafe.Pointer(ptr)); r == oldval { + *(*uint64)(unsafe.Pointer(ptr)) = newval + } + + return r +} diff --git a/internal/libc/stdio/capi_darwin_amd64.go b/internal/libc/stdio/capi_darwin_amd64.go new file mode 100644 index 0000000..3782209 --- /dev/null +++ b/internal/libc/stdio/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo stdio/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdio/stdio_darwin_amd64.go -pkgname stdio', DO NOT EDIT. + +package stdio + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/stdio/capi_darwin_arm64.go b/internal/libc/stdio/capi_darwin_arm64.go new file mode 100644 index 0000000..fdc60c5 --- /dev/null +++ b/internal/libc/stdio/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo stdio/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdio/stdio_darwin_arm64.go -pkgname stdio', DO NOT EDIT. + +package stdio + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/stdio/capi_linux_amd64.go b/internal/libc/stdio/capi_linux_amd64.go new file mode 100644 index 0000000..e327db4 --- /dev/null +++ b/internal/libc/stdio/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo stdio/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdio/stdio_linux_amd64.go -pkgname stdio', DO NOT EDIT. + +package stdio + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/stdio/capi_linux_arm64.go b/internal/libc/stdio/capi_linux_arm64.go new file mode 100644 index 0000000..9a47692 --- /dev/null +++ b/internal/libc/stdio/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo stdio/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o stdio/stdio_linux_arm64.go -pkgname stdio', DO NOT EDIT. + +package stdio + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/stdio/stdio_darwin_amd64.go b/internal/libc/stdio/stdio_darwin_amd64.go new file mode 100644 index 0000000..eb8f4eb --- /dev/null +++ b/internal/libc/stdio/stdio_darwin_amd64.go @@ -0,0 +1,1929 @@ +// Code generated by 'ccgo stdio/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdio/stdio_darwin_amd64.go -pkgname stdio', DO NOT EDIT. + +package stdio + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BUFSIZ = 1024 // stdio.h:103:1: + EOF = -1 // stdio.h:104:1: + FILENAME_MAX = 1024 // stdio.h:108:1: + FOPEN_MAX = 20 // stdio.h:107:1: + L_ctermid = 1024 // stdio.h:202:1: + L_tmpnam = 1024 // stdio.h:114:1: + P_tmpdir = "/var/tmp/" // stdio.h:112:1: + RENAME_EXCL = 0x00000004 // stdio.h:45:1: + RENAME_SECLUDE = 0x00000001 // stdio.h:43:1: + RENAME_SWAP = 0x00000002 // stdio.h:44:1: + SEEK_CUR = 1 // stdio.h:121:1: + SEEK_END = 2 // stdio.h:124:1: + SEEK_SET = 0 // stdio.h:118:1: + TMP_MAX = 308915776 // stdio.h:115:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CTERMID_H_ = 0 // _ctermid.h:25:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_FSTDIO = 0 // _stdio.h:83:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IOFBF = 0 // stdio.h:99:1: + X_IOLBF = 1 // stdio.h:100:1: + X_IONBF = 2 // stdio.h:101:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_SECURE__COMMON_H_ = 0 // _common.h:25:1: + X_SECURE__STDIO_H_ = 0 // _stdio.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_STDIO_H_ = 0 // stdio.h:62:1: + X_SYS_STDIO_H_ = 0 // stdio.h:30:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USE_FORTIFY_LEVEL = 2 // _common.h:30:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_VA_LIST_T = 0 // _va_list.h:30:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)stdio.h 8.5 (Berkeley) 4/29/95 + +// Copyright (c) 2000, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)stdio.h 8.5 (Berkeley) 4/29/95 + +// Common header for stdio.h and xlocale/_stdio.h + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// DO NOT REMOVE THIS COMMENT: fixincludes needs to see: +// __gnuc_va_list and include +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type Va_list = X__darwin_va_list /* _va_list.h:32:26 */ + +type Fpos_t = X__darwin_off_t /* _stdio.h:81:25 */ + +// NB: to fit things in six character monocase externals, the stdio +// code uses the prefix `__s' for stdio objects, typically followed +// by a three-character attempt at a mnemonic. + +// stdio buffers +type X__sbuf = struct { + F_base uintptr + F_size int32 + F__ccgo_pad1 [4]byte +} /* _stdio.h:92:1 */ + +// stdio state variables. +// +// The following always hold: +// +// if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), +// _lbfsize is -_bf._size, else _lbfsize is 0 +// if _flags&__SRD, _w is 0 +// if _flags&__SWR, _r is 0 +// +// This ensures that the getc and putc macros (or inline functions) never +// try to write or read from a file that is in `read' or `write' mode. +// (Moreover, they can, and do, automatically switch from read mode to +// write mode, and back, on "r+" and "w+" files.) +// +// _lbfsize is used only to make the inline line-buffered output stream +// code as compact as possible. +// +// _ub, _up, and _ur are used when ungetc() pushes back more characters +// than fit in the current _bf, or when ungetc() pushes back a character +// that does not match the previous one in _bf. When this happens, +// _ub._base becomes non-nil (i.e., a stream has ungetc() data iff +// _ub._base!=NULL) and _up and _ur save the current values of _p and _r. +// +// NB: see WARNING above before changing the layout of this structure! +type X__sFILE = struct { + F_p uintptr + F_r int32 + F_w int32 + F_flags int16 + F_file int16 + F__ccgo_pad1 [4]byte + F_bf struct { + F_base uintptr + F_size int32 + F__ccgo_pad1 [4]byte + } + F_lbfsize int32 + F__ccgo_pad2 [4]byte + F_cookie uintptr + F_close uintptr + F_read uintptr + F_seek uintptr + F_write uintptr + F_ub struct { + F_base uintptr + F_size int32 + F__ccgo_pad1 [4]byte + } + F_extra uintptr + F_ur int32 + F_ubuf [3]uint8 + F_nbuf [1]uint8 + F_lb struct { + F_base uintptr + F_size int32 + F__ccgo_pad1 [4]byte + } + F_blksize int32 + F__ccgo_pad3 [4]byte + F_offset Fpos_t +} /* _stdio.h:126:9 */ + +// stdio state variables. +// +// The following always hold: +// +// if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), +// _lbfsize is -_bf._size, else _lbfsize is 0 +// if _flags&__SRD, _w is 0 +// if _flags&__SWR, _r is 0 +// +// This ensures that the getc and putc macros (or inline functions) never +// try to write or read from a file that is in `read' or `write' mode. +// (Moreover, they can, and do, automatically switch from read mode to +// write mode, and back, on "r+" and "w+" files.) +// +// _lbfsize is used only to make the inline line-buffered output stream +// code as compact as possible. +// +// _ub, _up, and _ur are used when ungetc() pushes back more characters +// than fit in the current _bf, or when ungetc() pushes back a character +// that does not match the previous one in _bf. When this happens, +// _ub._base becomes non-nil (i.e., a stream has ungetc() data iff +// _ub._base!=NULL) and _up and _ur save the current values of _p and _r. +// +// NB: see WARNING above before changing the layout of this structure! +type FILE = X__sFILE /* _stdio.h:157:3 */ + +// Additional functionality provided by: +// POSIX.1-2001 +// ISO C99 + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +// Additional functionality provided by: +// POSIX.1-2008 + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/stdio/stdio_darwin_arm64.go b/internal/libc/stdio/stdio_darwin_arm64.go new file mode 100644 index 0000000..365b49b --- /dev/null +++ b/internal/libc/stdio/stdio_darwin_arm64.go @@ -0,0 +1,1944 @@ +// Code generated by 'ccgo stdio/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdio/stdio_darwin_arm64.go -pkgname stdio', DO NOT EDIT. + +package stdio + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BUFSIZ = 1024 // stdio.h:103:1: + EOF = -1 // stdio.h:104:1: + FILENAME_MAX = 1024 // stdio.h:108:1: + FOPEN_MAX = 20 // stdio.h:107:1: + L_ctermid = 1024 // stdio.h:202:1: + L_tmpnam = 1024 // stdio.h:114:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + P_tmpdir = "/var/tmp/" // stdio.h:112:1: + RENAME_EXCL = 0x00000004 // stdio.h:37:1: + RENAME_NOFOLLOW_ANY = 0x00000010 // stdio.h:39:1: + RENAME_RESERVED1 = 0x00000008 // stdio.h:38:1: + RENAME_SECLUDE = 0x00000001 // stdio.h:35:1: + RENAME_SWAP = 0x00000002 // stdio.h:36:1: + SEEK_CUR = 1 // stdio.h:121:1: + SEEK_END = 2 // stdio.h:124:1: + SEEK_SET = 0 // stdio.h:118:1: + TMP_MAX = 308915776 // stdio.h:115:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CTERMID_H_ = 0 // _ctermid.h:25:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_FSTDIO = 0 // _stdio.h:83:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IOFBF = 0 // stdio.h:99:1: + X_IOLBF = 1 // stdio.h:100:1: + X_IONBF = 2 // stdio.h:101:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_SECURE__COMMON_H_ = 0 // _common.h:25:1: + X_SECURE__STDIO_H_ = 0 // _stdio.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_STDIO_H_ = 0 // stdio.h:62:1: + X_SYS_STDIO_H_ = 0 // stdio.h:30:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USE_FORTIFY_LEVEL = 2 // _common.h:30:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_VA_LIST_T = 0 // _va_list.h:30:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)stdio.h 8.5 (Berkeley) 4/29/95 + +// Copyright (c) 2000, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)stdio.h 8.5 (Berkeley) 4/29/95 + +// Common header for stdio.h and xlocale/_stdio.h + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// DO NOT REMOVE THIS COMMENT: fixincludes needs to see: +// __gnuc_va_list and include +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type Va_list = X__darwin_va_list /* _va_list.h:32:26 */ + +type Fpos_t = X__darwin_off_t /* _stdio.h:81:25 */ + +// NB: to fit things in six character monocase externals, the stdio +// code uses the prefix `__s' for stdio objects, typically followed +// by a three-character attempt at a mnemonic. + +// stdio buffers +type X__sbuf = struct { + F_base uintptr + F_size int32 + F__ccgo_pad1 [4]byte +} /* _stdio.h:92:1 */ + +// stdio state variables. +// +// The following always hold: +// +// if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), +// _lbfsize is -_bf._size, else _lbfsize is 0 +// if _flags&__SRD, _w is 0 +// if _flags&__SWR, _r is 0 +// +// This ensures that the getc and putc macros (or inline functions) never +// try to write or read from a file that is in `read' or `write' mode. +// (Moreover, they can, and do, automatically switch from read mode to +// write mode, and back, on "r+" and "w+" files.) +// +// _lbfsize is used only to make the inline line-buffered output stream +// code as compact as possible. +// +// _ub, _up, and _ur are used when ungetc() pushes back more characters +// than fit in the current _bf, or when ungetc() pushes back a character +// that does not match the previous one in _bf. When this happens, +// _ub._base becomes non-nil (i.e., a stream has ungetc() data iff +// _ub._base!=NULL) and _up and _ur save the current values of _p and _r. +// +// NB: see WARNING above before changing the layout of this structure! +type X__sFILE = struct { + F_p uintptr + F_r int32 + F_w int32 + F_flags int16 + F_file int16 + F__ccgo_pad1 [4]byte + F_bf struct { + F_base uintptr + F_size int32 + F__ccgo_pad1 [4]byte + } + F_lbfsize int32 + F__ccgo_pad2 [4]byte + F_cookie uintptr + F_close uintptr + F_read uintptr + F_seek uintptr + F_write uintptr + F_ub struct { + F_base uintptr + F_size int32 + F__ccgo_pad1 [4]byte + } + F_extra uintptr + F_ur int32 + F_ubuf [3]uint8 + F_nbuf [1]uint8 + F_lb struct { + F_base uintptr + F_size int32 + F__ccgo_pad1 [4]byte + } + F_blksize int32 + F__ccgo_pad3 [4]byte + F_offset Fpos_t +} /* _stdio.h:126:9 */ + +// stdio state variables. +// +// The following always hold: +// +// if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), +// _lbfsize is -_bf._size, else _lbfsize is 0 +// if _flags&__SRD, _w is 0 +// if _flags&__SWR, _r is 0 +// +// This ensures that the getc and putc macros (or inline functions) never +// try to write or read from a file that is in `read' or `write' mode. +// (Moreover, they can, and do, automatically switch from read mode to +// write mode, and back, on "r+" and "w+" files.) +// +// _lbfsize is used only to make the inline line-buffered output stream +// code as compact as possible. +// +// _ub, _up, and _ur are used when ungetc() pushes back more characters +// than fit in the current _bf, or when ungetc() pushes back a character +// that does not match the previous one in _bf. When this happens, +// _ub._base becomes non-nil (i.e., a stream has ungetc() data iff +// _ub._base!=NULL) and _up and _ur save the current values of _p and _r. +// +// NB: see WARNING above before changing the layout of this structure! +type FILE = X__sFILE /* _stdio.h:157:3 */ + +// Additional functionality provided by: +// POSIX.1-2001 +// ISO C99 + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +// Additional functionality provided by: +// POSIX.1-2008 + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/stdio/stdio_linux_amd64.go b/internal/libc/stdio/stdio_linux_amd64.go new file mode 100644 index 0000000..ce7f628 --- /dev/null +++ b/internal/libc/stdio/stdio_linux_amd64.go @@ -0,0 +1,540 @@ +// Code generated by 'ccgo stdio/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdio/stdio_linux_amd64.go -pkgname stdio', DO NOT EDIT. + +package stdio + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BUFSIZ = 8192 // stdio.h:99:1: + EOF = -1 // stdio.h:104:1: + FILENAME_MAX = 4096 // stdio_lim.h:27:1: + FOPEN_MAX = 16 // stdio_lim.h:37:1: + L_ctermid = 9 // stdio_lim.h:30:1: + L_tmpnam = 20 // stdio_lim.h:25:1: + P_tmpdir = "/tmp" // stdio.h:120:1: + SEEK_CUR = 1 // stdio.h:110:1: + SEEK_END = 2 // stdio.h:111:1: + SEEK_SET = 0 // stdio.h:109:1: + TMP_MAX = 238328 // stdio_lim.h:26:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_STDIO_LIM_H = 1 // stdio_lim.h:19:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_IOFBF = 0 // stdio.h:93:1: + X_IOLBF = 1 // stdio.h:94:1: + X_IONBF = 2 // stdio.h:95:1: + X_IO_EOF_SEEN = 0x0010 // struct_FILE.h:111:1: + X_IO_ERR_SEEN = 0x0020 // struct_FILE.h:114:1: + X_IO_USER_LOCK = 0x8000 // struct_FILE.h:117:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STDIO_H = 1 // stdio.h:24:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + X_VA_LIST_DEFINED = 0 // stdio.h:53:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.15 Variable arguments + +// Define __gnuc_va_list. + +type X__gnuc_va_list = X__builtin_va_list /* stdarg.h:40:27 */ + +// Define the standard macros for the user, +// if this invocation was from the user program. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Integral type unchanged by default argument promotions that can +// hold any value corresponding to members of the extended character +// set, as well as at least one value that does not correspond to any +// member of the extended character set. + +// Conversion state information. +type X__mbstate_t = struct { + F__count int32 + F__value struct{ F__wch uint32 } +} /* __mbstate_t.h:21:3 */ + +// The tag name of this struct is _G_fpos_t to preserve historic +// +// C++ mangled names for functions taking fpos_t arguments. +// That name should not be used in new code. +type X_G_fpos_t = struct { + F__pos X__off_t + F__state X__mbstate_t +} /* __fpos_t.h:10:9 */ + +// The tag name of this struct is _G_fpos_t to preserve historic +// +// C++ mangled names for functions taking fpos_t arguments. +// That name should not be used in new code. +type X__fpos_t = X_G_fpos_t /* __fpos_t.h:14:3 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// The tag name of this struct is _G_fpos64_t to preserve historic +// +// C++ mangled names for functions taking fpos_t and/or fpos64_t +// arguments. That name should not be used in new code. +type X_G_fpos64_t = struct { + F__pos X__off64_t + F__state X__mbstate_t +} /* __fpos64_t.h:10:9 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// The tag name of this struct is _G_fpos64_t to preserve historic +// +// C++ mangled names for functions taking fpos_t and/or fpos64_t +// arguments. That name should not be used in new code. +type X__fpos64_t = X_G_fpos64_t /* __fpos64_t.h:14:3 */ + +type X_IO_FILE = struct { + F_flags int32 + F__ccgo_pad1 [4]byte + F_IO_read_ptr uintptr + F_IO_read_end uintptr + F_IO_read_base uintptr + F_IO_write_base uintptr + F_IO_write_ptr uintptr + F_IO_write_end uintptr + F_IO_buf_base uintptr + F_IO_buf_end uintptr + F_IO_save_base uintptr + F_IO_backup_base uintptr + F_IO_save_end uintptr + F_markers uintptr + F_chain uintptr + F_fileno int32 + F_flags2 int32 + F_old_offset X__off_t + F_cur_column uint16 + F_vtable_offset int8 + F_shortbuf [1]int8 + F__ccgo_pad2 [4]byte + F_lock uintptr + F_offset X__off64_t + F_codecvt uintptr + F_wide_data uintptr + F_freeres_list uintptr + F_freeres_buf uintptr + F__pad5 Size_t + F_mode int32 + F_unused2 [20]int8 +} /* __FILE.h:4:1 */ + +type X__FILE = X_IO_FILE /* __FILE.h:5:25 */ + +// The opaque type of streams. This is the definition used elsewhere. +type FILE = X_IO_FILE /* FILE.h:7:25 */ + +// These macros are used by bits/stdio.h and internal headers. + +// Many more flag bits are defined internally. + +type Va_list = X__gnuc_va_list /* stdio.h:52:24 */ + +type Off_t = X__off64_t /* stdio.h:65:19 */ + +type Ssize_t = X__ssize_t /* stdio.h:77:19 */ + +// The type of the second argument to `fgetpos' and `fsetpos'. +type Fpos_t = X__fpos64_t /* stdio.h:86:20 */ + +// If we are compiling with optimizing read this file. It contains +// several optimizing inline functions and macros. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/stdio/stdio_linux_arm64.go b/internal/libc/stdio/stdio_linux_arm64.go new file mode 100644 index 0000000..3ca2c8b --- /dev/null +++ b/internal/libc/stdio/stdio_linux_arm64.go @@ -0,0 +1,573 @@ +// Code generated by 'ccgo stdio/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o stdio/stdio_linux_arm64.go -pkgname stdio', DO NOT EDIT. + +package stdio + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BUFSIZ = 8192 + EOF = -1 + FILENAME_MAX = 4096 + FOPEN_MAX = 16 + L_ctermid = 9 + L_tmpnam = 20 + P_tmpdir = "/tmp" + SEEK_CUR = 1 + SEEK_END = 2 + SEEK_SET = 0 + TMP_MAX = 238328 + X_ATFILE_SOURCE = 1 + X_BITS_STDIO_LIM_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_IOFBF = 0 + X_IOLBF = 1 + X_IONBF = 2 + X_IO_EOF_SEEN = 0x0010 + X_IO_ERR_SEEN = 0x0020 + X_IO_USER_LOCK = 0x8000 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_STDIO_H = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SIZE_T_H = 0 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + X_VA_LIST_DEFINED = 0 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.15 Variable arguments + +// Define __gnuc_va_list. + +type X__gnuc_va_list = X__builtin_va_list /* stdarg.h:40:27 */ + +// Define the standard macros for the user, +// if this invocation was from the user program. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Integral type unchanged by default argument promotions that can +// hold any value corresponding to members of the extended character +// set, as well as at least one value that does not correspond to any +// member of the extended character set. + +// Conversion state information. +type X__mbstate_t = struct { + F__count int32 + F__value struct{ F__wch uint32 } +} /* __mbstate_t.h:21:3 */ + +// The tag name of this struct is _G_fpos_t to preserve historic +// +// C++ mangled names for functions taking fpos_t arguments. +// That name should not be used in new code. +type X_G_fpos_t = struct { + F__pos X__off_t + F__state X__mbstate_t +} /* __fpos_t.h:10:9 */ + +// The tag name of this struct is _G_fpos_t to preserve historic +// +// C++ mangled names for functions taking fpos_t arguments. +// That name should not be used in new code. +type X__fpos_t = X_G_fpos_t /* __fpos_t.h:14:3 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// The tag name of this struct is _G_fpos64_t to preserve historic +// +// C++ mangled names for functions taking fpos_t and/or fpos64_t +// arguments. That name should not be used in new code. +type X_G_fpos64_t = struct { + F__pos X__off64_t + F__state X__mbstate_t +} /* __fpos64_t.h:10:9 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// The tag name of this struct is _G_fpos64_t to preserve historic +// +// C++ mangled names for functions taking fpos_t and/or fpos64_t +// arguments. That name should not be used in new code. +type X__fpos64_t = X_G_fpos64_t /* __fpos64_t.h:14:3 */ + +type X_IO_FILE = struct { + F_flags int32 + F__ccgo_pad1 [4]byte + F_IO_read_ptr uintptr + F_IO_read_end uintptr + F_IO_read_base uintptr + F_IO_write_base uintptr + F_IO_write_ptr uintptr + F_IO_write_end uintptr + F_IO_buf_base uintptr + F_IO_buf_end uintptr + F_IO_save_base uintptr + F_IO_backup_base uintptr + F_IO_save_end uintptr + F_markers uintptr + F_chain uintptr + F_fileno int32 + F_flags2 int32 + F_old_offset X__off_t + F_cur_column uint16 + F_vtable_offset int8 + F_shortbuf [1]uint8 + F__ccgo_pad2 [4]byte + F_lock uintptr + F_offset X__off64_t + F_codecvt uintptr + F_wide_data uintptr + F_freeres_list uintptr + F_freeres_buf uintptr + F__pad5 Size_t + F_mode int32 + F_unused2 [20]uint8 +} /* __FILE.h:4:1 */ + +type X__FILE = X_IO_FILE /* __FILE.h:5:25 */ + +// The opaque type of streams. This is the definition used elsewhere. +type FILE = X_IO_FILE /* FILE.h:7:25 */ + +// These macros are used by bits/stdio.h and internal headers. + +// Many more flag bits are defined internally. + +type Va_list = X__gnuc_va_list /* stdio.h:52:24 */ + +type Off_t = X__off64_t /* stdio.h:65:19 */ + +type Ssize_t = X__ssize_t /* stdio.h:77:19 */ + +// The type of the second argument to `fgetpos' and `fsetpos'. +type Fpos_t = X__fpos64_t /* stdio.h:86:20 */ + +// If we are compiling with optimizing read this file. It contains +// several optimizing inline functions and macros. + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/stdlib/capi_darwin_amd64.go b/internal/libc/stdlib/capi_darwin_amd64.go new file mode 100644 index 0000000..9d24024 --- /dev/null +++ b/internal/libc/stdlib/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo stdlib/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdlib/stdlib_darwin_amd64.go -pkgname stdlib', DO NOT EDIT. + +package stdlib + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/stdlib/capi_darwin_arm64.go b/internal/libc/stdlib/capi_darwin_arm64.go new file mode 100644 index 0000000..5a23d22 --- /dev/null +++ b/internal/libc/stdlib/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo stdlib/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdlib/stdlib_darwin_arm64.go -pkgname stdlib', DO NOT EDIT. + +package stdlib + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/stdlib/capi_linux_amd64.go b/internal/libc/stdlib/capi_linux_amd64.go new file mode 100644 index 0000000..bc0091e --- /dev/null +++ b/internal/libc/stdlib/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo stdlib/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdlib/stdlib_linux_amd64.go -pkgname stdlib', DO NOT EDIT. + +package stdlib + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/stdlib/capi_linux_arm64.go b/internal/libc/stdlib/capi_linux_arm64.go new file mode 100644 index 0000000..249f561 --- /dev/null +++ b/internal/libc/stdlib/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo stdlib/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o stdlib/stdlib_linux_arm64.go -pkgname stdlib', DO NOT EDIT. + +package stdlib + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/stdlib/stdlib_darwin_amd64.go b/internal/libc/stdlib/stdlib_darwin_amd64.go new file mode 100644 index 0000000..f3b1954 --- /dev/null +++ b/internal/libc/stdlib/stdlib_darwin_amd64.go @@ -0,0 +1,6026 @@ +// Code generated by 'ccgo stdlib/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdlib/stdlib_darwin_amd64.go -pkgname stdlib', DO NOT EDIT. + +package stdlib + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 // endian.h:94:1: + BUS_ADRALN = 1 // signal.h:241:1: + BUS_ADRERR = 2 // signal.h:242:1: + BUS_NOOP = 0 // signal.h:239:1: + BUS_OBJERR = 3 // signal.h:243:1: + BYTE_ORDER = 1234 // endian.h:97:1: + CLD_CONTINUED = 6 // signal.h:258:1: + CLD_DUMPED = 3 // signal.h:255:1: + CLD_EXITED = 1 // signal.h:253:1: + CLD_KILLED = 2 // signal.h:254:1: + CLD_NOOP = 0 // signal.h:251:1: + CLD_STOPPED = 5 // signal.h:257:1: + CLD_TRAPPED = 4 // signal.h:256:1: + CPUMON_MAKE_FATAL = 0x1000 // resource.h:393:1: + EXIT_FAILURE = 1 // stdlib.h:102:1: + EXIT_SUCCESS = 0 // stdlib.h:103:1: + FOOTPRINT_INTERVAL_RESET = 0x1 // resource.h:398:1: + FPE_FLTDIV = 1 // signal.h:221:1: + FPE_FLTINV = 5 // signal.h:225:1: + FPE_FLTOVF = 2 // signal.h:222:1: + FPE_FLTRES = 4 // signal.h:224:1: + FPE_FLTSUB = 6 // signal.h:226:1: + FPE_FLTUND = 3 // signal.h:223:1: + FPE_INTDIV = 7 // signal.h:227:1: + FPE_INTOVF = 8 // signal.h:228:1: + FPE_NOOP = 0 // signal.h:219:1: + FP_CHOP = 3 // _structs.h:112:1: + FP_PREC_24B = 0 // _structs.h:103:1: + FP_PREC_53B = 2 // _structs.h:104:1: + FP_PREC_64B = 3 // _structs.h:105:1: + FP_RND_DOWN = 1 // _structs.h:110:1: + FP_RND_NEAR = 0 // _structs.h:109:1: + FP_RND_UP = 2 // _structs.h:111:1: + FP_STATE_BYTES = 512 // _structs.h:276:1: + ILL_BADSTK = 8 // signal.h:215:1: + ILL_COPROC = 7 // signal.h:214:1: + ILL_ILLADR = 5 // signal.h:212:1: + ILL_ILLOPC = 1 // signal.h:208:1: + ILL_ILLOPN = 4 // signal.h:211:1: + ILL_ILLTRP = 2 // signal.h:209:1: + ILL_NOOP = 0 // signal.h:206:1: + ILL_PRVOPC = 3 // signal.h:210:1: + ILL_PRVREG = 6 // signal.h:213:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + IOPOL_APPLICATION = 5 // resource.h:427:1: + IOPOL_ATIME_UPDATES_DEFAULT = 0 // resource.h:431:1: + IOPOL_ATIME_UPDATES_OFF = 1 // resource.h:432:1: + IOPOL_DEFAULT = 0 // resource.h:419:1: + IOPOL_IMPORTANT = 1 // resource.h:420:1: + IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT = 0 // resource.h:434:1: + IOPOL_MATERIALIZE_DATALESS_FILES_OFF = 1 // resource.h:435:1: + IOPOL_MATERIALIZE_DATALESS_FILES_ON = 2 // resource.h:436:1: + IOPOL_NORMAL = 1 // resource.h:428:1: + IOPOL_PASSIVE = 2 // resource.h:421:1: + IOPOL_SCOPE_DARWIN_BG = 2 // resource.h:416:1: + IOPOL_SCOPE_PROCESS = 0 // resource.h:414:1: + IOPOL_SCOPE_THREAD = 1 // resource.h:415:1: + IOPOL_STANDARD = 5 // resource.h:424:1: + IOPOL_THROTTLE = 3 // resource.h:422:1: + IOPOL_TYPE_DISK = 0 // resource.h:408:1: + IOPOL_TYPE_VFS_ATIME_UPDATES = 2 // resource.h:409:1: + IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES = 3 // resource.h:410:1: + IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME = 4 // resource.h:411:1: + IOPOL_UTILITY = 4 // resource.h:423:1: + IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME = 1 // resource.h:439:1: + IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT = 0 // resource.h:438:1: + LITTLE_ENDIAN = 1234 // endian.h:93:1: + MINSIGSTKSZ = 32768 // signal.h:340:1: + NSIG = 32 // signal.h:79:1: + PDP_ENDIAN = 3412 // endian.h:95:1: + POLL_ERR = 4 // signal.h:264:1: + POLL_HUP = 6 // signal.h:266:1: + POLL_IN = 1 // signal.h:261:1: + POLL_MSG = 3 // signal.h:263:1: + POLL_OUT = 2 // signal.h:262:1: + POLL_PRI = 5 // signal.h:265:1: + PRIO_DARWIN_BG = 0x1000 // resource.h:120:1: + PRIO_DARWIN_NONUI = 0x1001 // resource.h:126:1: + PRIO_DARWIN_PROCESS = 4 // resource.h:106:1: + PRIO_DARWIN_THREAD = 3 // resource.h:105:1: + PRIO_MAX = 20 // resource.h:113:1: + PRIO_MIN = -20 // resource.h:112:1: + PRIO_PGRP = 1 // resource.h:101:1: + PRIO_PROCESS = 0 // resource.h:100:1: + PRIO_USER = 2 // resource.h:102:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + RAND_MAX = 0x7fffffff // stdlib.h:105:1: + RLIMIT_AS = 5 // resource.h:349:1: + RLIMIT_CORE = 4 // resource.h:348:1: + RLIMIT_CPU = 0 // resource.h:344:1: + RLIMIT_CPU_USAGE_MONITOR = 0x2 // resource.h:377:1: + RLIMIT_DATA = 2 // resource.h:346:1: + RLIMIT_FOOTPRINT_INTERVAL = 0x4 // resource.h:379:1: + RLIMIT_FSIZE = 1 // resource.h:345:1: + RLIMIT_MEMLOCK = 6 // resource.h:352:1: + RLIMIT_NOFILE = 8 // resource.h:355:1: + RLIMIT_NPROC = 7 // resource.h:353:1: + RLIMIT_RSS = 5 // resource.h:351:1: + RLIMIT_STACK = 3 // resource.h:347:1: + RLIMIT_THREAD_CPULIMITS = 0x3 // resource.h:378:1: + RLIMIT_WAKEUPS_MONITOR = 0x1 // resource.h:376:1: + RLIM_NLIMITS = 9 // resource.h:357:1: + RSIZE_MAX = 9223372036854775807 // stdint.h:658:1: + RUSAGE_CHILDREN = -1 // resource.h:141:1: + RUSAGE_INFO_CURRENT = 4 // resource.h:191:1: + RUSAGE_INFO_V0 = 0 // resource.h:186:1: + RUSAGE_INFO_V1 = 1 // resource.h:187:1: + RUSAGE_INFO_V2 = 2 // resource.h:188:1: + RUSAGE_INFO_V3 = 3 // resource.h:189:1: + RUSAGE_INFO_V4 = 4 // resource.h:190:1: + RUSAGE_SELF = 0 // resource.h:140:1: + SA_64REGSET = 0x0200 // signal.h:308:1: + SA_NOCLDSTOP = 0x0008 // signal.h:301:1: + SA_NOCLDWAIT = 0x0020 // signal.h:303:1: + SA_NODEFER = 0x0010 // signal.h:302:1: + SA_ONSTACK = 0x0001 // signal.h:298:1: + SA_RESETHAND = 0x0004 // signal.h:300:1: + SA_RESTART = 0x0002 // signal.h:299:1: + SA_SIGINFO = 0x0040 // signal.h:304:1: + SA_USERSPACE_MASK = 127 // signal.h:314:1: + SA_USERTRAMP = 0x0100 // signal.h:306:1: + SEGV_ACCERR = 2 // signal.h:235:1: + SEGV_MAPERR = 1 // signal.h:234:1: + SEGV_NOOP = 0 // signal.h:232:1: + SIGABRT = 6 // signal.h:89:1: + SIGALRM = 14 // signal.h:102:1: + SIGBUS = 10 // signal.h:98:1: + SIGCHLD = 20 // signal.h:108:1: + SIGCONT = 19 // signal.h:107:1: + SIGEMT = 7 // signal.h:94:1: + SIGEV_NONE = 0 // signal.h:164:1: + SIGEV_SIGNAL = 1 // signal.h:165:1: + SIGEV_THREAD = 3 // signal.h:166:1: + SIGFPE = 8 // signal.h:96:1: + SIGHUP = 1 // signal.h:84:1: + SIGILL = 4 // signal.h:87:1: + SIGINFO = 29 // signal.h:120:1: + SIGINT = 2 // signal.h:85:1: + SIGIO = 23 // signal.h:112:1: + SIGIOT = 6 // signal.h:93:1: + SIGKILL = 9 // signal.h:97:1: + SIGPIPE = 13 // signal.h:101:1: + SIGPROF = 27 // signal.h:117:1: + SIGQUIT = 3 // signal.h:86:1: + SIGSEGV = 11 // signal.h:99:1: + SIGSTKSZ = 131072 // signal.h:341:1: + SIGSTOP = 17 // signal.h:105:1: + SIGSYS = 12 // signal.h:100:1: + SIGTERM = 15 // signal.h:103:1: + SIGTRAP = 5 // signal.h:88:1: + SIGTSTP = 18 // signal.h:106:1: + SIGTTIN = 21 // signal.h:109:1: + SIGTTOU = 22 // signal.h:110:1: + SIGURG = 16 // signal.h:104:1: + SIGUSR1 = 30 // signal.h:122:1: + SIGUSR2 = 31 // signal.h:123:1: + SIGVTALRM = 26 // signal.h:116:1: + SIGWINCH = 28 // signal.h:119:1: + SIGXCPU = 24 // signal.h:114:1: + SIGXFSZ = 25 // signal.h:115:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIG_BLOCK = 1 // signal.h:319:1: + SIG_SETMASK = 3 // signal.h:321:1: + SIG_UNBLOCK = 2 // signal.h:320:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + SI_ASYNCIO = 0x10004 // signal.h:327:1: + SI_MESGQ = 0x10005 // signal.h:328:1: + SI_QUEUE = 0x10002 // signal.h:325:1: + SI_TIMER = 0x10003 // signal.h:326:1: + SI_USER = 0x10001 // signal.h:324:1: + SS_DISABLE = 0x0004 // signal.h:339:1: + SS_ONSTACK = 0x0001 // signal.h:338:1: + SV_INTERRUPT = 2 // signal.h:355:1: + SV_NOCLDSTOP = 8 // signal.h:358:1: + SV_NODEFER = 16 // signal.h:357:1: + SV_ONSTACK = 1 // signal.h:354:1: + SV_RESETHAND = 4 // signal.h:356:1: + SV_SIGINFO = 64 // signal.h:359:1: + TRAP_BRKPT = 1 // signal.h:246:1: + TRAP_TRACE = 2 // signal.h:247:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + WAIT_ANY = -1 // wait.h:183:1: + WAIT_MYPGRP = 0 // wait.h:184:1: + WAKEMON_DISABLE = 0x02 // resource.h:385:1: + WAKEMON_ENABLE = 0x01 // resource.h:384:1: + WAKEMON_GET_PARAMS = 0x04 // resource.h:386:1: + WAKEMON_MAKE_FATAL = 0x10 // resource.h:388:1: + WAKEMON_SET_DEFAULTS = 0x08 // resource.h:387:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WCONTINUED = 0x00000010 // wait.h:173:1: + WCOREFLAG = 0200 // wait.h:132:1: + WEXITED = 0x00000004 // wait.h:168:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + WNOHANG = 0x00000001 // wait.h:121:1: + WNOWAIT = 0x00000020 // wait.h:174:1: + WSTOPPED = 0x00000008 // wait.h:171:1: + WUNTRACED = 0x00000002 // wait.h:122:1: + X_ALLOCA_H_ = 0 // alloca.h:25:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_SIGNAL_H_ = 0 // signal.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CT_RUNE_T = 0 // _ct_rune_t.h:30:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_I386_SIGNAL_H_ = 1 // signal.h:34:1: + X_I386__ENDIAN_H_ = 0 // endian.h:67:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MACH_I386__STRUCTS_H_ = 0 // _structs.h:33:1: + X_MACH_MACHINE__STRUCTS_H_ = 0 // _structs.h:30:1: + X_MALLOC_UNDERSCORE_MALLOC_H_ = 0 // _malloc.h:25:1: + X_MCONTEXT_T = 0 // _mcontext.h:202:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OS__OSBYTEORDERI386_H = 0 // _OSByteOrder.h:30:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:78:1: + X_QUAD_LOWWORD = 0 // endian.h:79:1: + X_RLIMIT_POSIX_FLAG = 0x1000 // resource.h:359:1: + X_RUNE_T = 0 // _rune_t.h:29:1: + X_SIGSET_T = 0 // _sigset_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_STDLIB_H_ = 0 // stdlib.h:59:1: + X_SYS_RESOURCE_H_ = 0 // resource.h:65:1: + X_SYS_SIGNAL_H_ = 0 // signal.h:70:1: + X_SYS_WAIT_H_ = 0 // wait.h:65:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINT32_T = 0 // _uint32_t.h:30:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_WCHAR_T = 0 // _wchar_t.h:32:1: + X_WSTOPPED = 0177 // wait.h:137:1: +) + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 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. +// +// @(#)wait.h 8.2 (Berkeley) 7/10/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This file holds definitions relevent to the wait4 system call +// and the alternate interfaces that use it (wait, wait3, waitpid). + +// [XSI] The type idtype_t shall be defined as an enumeration type whose +// possible values shall include at least P_ALL, P_PID, and P_PGID. +const ( /* wait.h:79:1: */ + P_ALL = 0 + P_PID = 1 + P_PGID = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000, 2002 - 2008 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)stdlib.h 8.5 (Berkeley) 5/19/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support clang language extensions. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support clang language extensions. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 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. +// +// @(#)wait.h 8.2 (Berkeley) 7/10/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This file holds definitions relevent to the wait4 system call +// and the alternate interfaces that use it (wait, wait3, waitpid). + +// [XSI] The type idtype_t shall be defined as an enumeration type whose +// possible values shall include at least P_ALL, P_PID, and P_PGID. +type Idtype_t = uint32 /* wait.h:83:3 */ + +// [XSI] The id_t and pid_t types shall be defined as described +// in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t + +// [XSI] The siginfo_t type shall be defined as described in +// [XSI] The rusage structure shall be defined as described in +// [XSI] Inclusion of the header may also make visible all +// symbols from and +// +// NOTE: This requirement is currently being satisfied by the direct +// inclusion of and , below. +// +// Software should not depend on the exposure of anything other +// than the types siginfo_t and struct rusage as a result of +// this inclusion. If you depend on any types or manifest +// values othe than siginfo_t and struct rusage from either of +// those files, you should explicitly include them yourself, as +// well, or in future releases your stware may not compile +// without modification. +// Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 1991, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)signal.h 8.2 (Berkeley) 1/21/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1992 NeXT Computer, Inc. +// + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +type Sig_atomic_t = int32 /* signal.h:39:13 */ + +// Language spec sez we must list exactly one parameter, even though we +// actually supply three. Ugh! +// SIG_HOLD is chosen to avoid KERN_SIG_* values in + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004-2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// @OSF_COPYRIGHT@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +// i386 is the structure that is exported to user threads for +// use in status/mutate calls. This structure should never change. +// + +type X__darwin_i386_thread_state = struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 +} /* _structs.h:46:1 */ + +// This structure should be double-word aligned for performance + +type X__darwin_fp_control = struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ +} /* _structs.h:92:1 */ + +type X__darwin_fp_control_t = X__darwin_fp_control /* _structs.h:117:28 */ + +// Status word. + +type X__darwin_fp_status = struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ +} /* _structs.h:150:1 */ + +type X__darwin_fp_status_t = X__darwin_fp_status /* _structs.h:167:27 */ + +// defn of 80bit x87 FPU or MMX register + +type X__darwin_mmst_reg = struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 +} /* _structs.h:194:1 */ + +// defn of 128 bit XMM regs + +type X__darwin_xmm_reg = struct{ F__xmm_reg [16]int8 } /* _structs.h:213:1 */ + +// defn of 256 bit YMM regs + +type X__darwin_ymm_reg = struct{ F__ymm_reg [32]int8 } /* _structs.h:229:1 */ + +// defn of 512 bit ZMM regs + +type X__darwin_zmm_reg = struct{ F__zmm_reg [64]int8 } /* _structs.h:245:1 */ + +type X__darwin_opmask_reg = struct{ F__opmask_reg [8]int8 } /* _structs.h:259:1 */ + +// Floating point state. + +type X__darwin_i386_float_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 +} /* _structs.h:281:1 */ + +type X__darwin_i386_avx_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } +} /* _structs.h:318:1 */ + +type X__darwin_i386_avx512_state = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } +} /* _structs.h:364:1 */ + +type X__darwin_i386_exception_state = struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint32_t +} /* _structs.h:575:1 */ + +type X__darwin_x86_debug_state32 = struct { + F__dr0 uint32 + F__dr1 uint32 + F__dr2 uint32 + F__dr3 uint32 + F__dr4 uint32 + F__dr5 uint32 + F__dr6 uint32 + F__dr7 uint32 +} /* _structs.h:595:1 */ + +type X__x86_pagein_state = struct{ F__pagein_error int32 } /* _structs.h:622:1 */ + +// 64 bit versions of the above + +type X__darwin_x86_thread_state64 = struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t +} /* _structs.h:633:1 */ + +// 64 bit versions of the above (complete) + +type X__darwin_x86_thread_full_state64 = struct { + F__ss64 struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__ds X__uint64_t + F__es X__uint64_t + F__ss X__uint64_t + F__gsbase X__uint64_t +} /* _structs.h:691:1 */ + +type X__darwin_x86_float_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 +} /* _structs.h:714:1 */ + +type X__darwin_x86_avx_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } +} /* _structs.h:765:1 */ + +type X__darwin_x86_avx512_state64 = struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh8 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh9 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh10 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh11 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh12 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh13 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh14 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh15 struct{ F__ymm_reg [32]int8 } + F__fpu_zmm16 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm17 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm18 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm19 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm20 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm21 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm22 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm23 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm24 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm25 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm26 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm27 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm28 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm29 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm30 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm31 struct{ F__zmm_reg [64]int8 } +} /* _structs.h:833:1 */ + +type X__darwin_x86_exception_state64 = struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t +} /* _structs.h:1172:1 */ + +type X__darwin_x86_debug_state64 = struct { + F__dr0 X__uint64_t + F__dr1 X__uint64_t + F__dr2 X__uint64_t + F__dr3 X__uint64_t + F__dr4 X__uint64_t + F__dr5 X__uint64_t + F__dr6 X__uint64_t + F__dr7 X__uint64_t +} /* _structs.h:1192:1 */ + +type X__darwin_x86_cpmu_state64 = struct{ F__ctrs [16]X__uint64_t } /* _structs.h:1220:1 */ + +type X__darwin_mcontext32 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint32_t + } + F__ss struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + } +} /* _mcontext.h:39:1 */ + +type X__darwin_mcontext_avx32 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint32_t + } + F__ss struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + } +} /* _mcontext.h:47:1 */ + +type X__darwin_mcontext_avx512_32 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint32_t + } + F__ss struct { + F__eax uint32 + F__ebx uint32 + F__ecx uint32 + F__edx uint32 + F__edi uint32 + F__esi uint32 + F__ebp uint32 + F__esp uint32 + F__ss uint32 + F__eflags uint32 + F__eip uint32 + F__cs uint32 + F__ds uint32 + F__es uint32 + F__fs uint32 + F__gs uint32 + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [224]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } + } +} /* _mcontext.h:56:1 */ + +type X__darwin_mcontext64 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:97:1 */ + +type X__darwin_mcontext64_full = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__ss64 struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__ds X__uint64_t + F__es X__uint64_t + F__ss X__uint64_t + F__gsbase X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:105:1 */ + +type X__darwin_mcontext_avx64 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:113:1 */ + +type X__darwin_mcontext_avx64_full = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__ss64 struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__ds X__uint64_t + F__es X__uint64_t + F__ss X__uint64_t + F__gsbase X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:121:1 */ + +type X__darwin_mcontext_avx512_64 = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh8 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh9 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh10 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh11 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh12 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh13 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh14 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh15 struct{ F__ymm_reg [32]int8 } + F__fpu_zmm16 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm17 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm18 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm19 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm20 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm21 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm22 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm23 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm24 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm25 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm26 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm27 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm28 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm29 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm30 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm31 struct{ F__zmm_reg [64]int8 } + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:130:1 */ + +type X__darwin_mcontext_avx512_64_full = struct { + F__es struct { + F__trapno X__uint16_t + F__cpu X__uint16_t + F__err X__uint32_t + F__faultvaddr X__uint64_t + } + F__ss struct { + F__ss64 struct { + F__rax X__uint64_t + F__rbx X__uint64_t + F__rcx X__uint64_t + F__rdx X__uint64_t + F__rdi X__uint64_t + F__rsi X__uint64_t + F__rbp X__uint64_t + F__rsp X__uint64_t + F__r8 X__uint64_t + F__r9 X__uint64_t + F__r10 X__uint64_t + F__r11 X__uint64_t + F__r12 X__uint64_t + F__r13 X__uint64_t + F__r14 X__uint64_t + F__r15 X__uint64_t + F__rip X__uint64_t + F__rflags X__uint64_t + F__cs X__uint64_t + F__fs X__uint64_t + F__gs X__uint64_t + } + F__ds X__uint64_t + F__es X__uint64_t + F__ss X__uint64_t + F__gsbase X__uint64_t + } + F__fs struct { + F__fpu_reserved [2]int32 + F__fpu_fcw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short : 2, unsigned short __pc: 2, unsigned short __rc: 2, unsigned short : 1, unsigned short : 3 */ + } + F__fpu_fsw struct { + F__ccgo_pad1 [0]uint16 + F__invalid uint16 /* unsigned short __invalid: 1, unsigned short __denorm: 1, unsigned short __zdiv: 1, unsigned short __ovrfl: 1, unsigned short __undfl: 1, unsigned short __precis: 1, unsigned short __stkflt: 1, unsigned short __errsumm: 1, unsigned short __c0: 1, unsigned short __c1: 1, unsigned short __c2: 1, unsigned short __tos: 3, unsigned short __c3: 1, unsigned short __busy: 1 */ + } + F__fpu_ftw X__uint8_t + F__fpu_rsrv1 X__uint8_t + F__fpu_fop X__uint16_t + F__fpu_ip X__uint32_t + F__fpu_cs X__uint16_t + F__fpu_rsrv2 X__uint16_t + F__fpu_dp X__uint32_t + F__fpu_ds X__uint16_t + F__fpu_rsrv3 X__uint16_t + F__fpu_mxcsr X__uint32_t + F__fpu_mxcsrmask X__uint32_t + F__fpu_stmm0 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm1 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm2 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm3 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm4 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm5 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm6 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_stmm7 struct { + F__mmst_reg [10]int8 + F__mmst_rsrv [6]int8 + } + F__fpu_xmm0 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm1 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm2 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm3 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm4 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm5 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm6 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm7 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm8 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm9 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm10 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm11 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm12 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm13 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm14 struct{ F__xmm_reg [16]int8 } + F__fpu_xmm15 struct{ F__xmm_reg [16]int8 } + F__fpu_rsrv4 [96]int8 + F__fpu_reserved1 int32 + F__avx_reserved1 [64]int8 + F__fpu_ymmh0 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh1 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh2 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh3 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh4 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh5 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh6 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh7 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh8 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh9 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh10 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh11 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh12 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh13 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh14 struct{ F__xmm_reg [16]int8 } + F__fpu_ymmh15 struct{ F__xmm_reg [16]int8 } + F__fpu_k0 struct{ F__opmask_reg [8]int8 } + F__fpu_k1 struct{ F__opmask_reg [8]int8 } + F__fpu_k2 struct{ F__opmask_reg [8]int8 } + F__fpu_k3 struct{ F__opmask_reg [8]int8 } + F__fpu_k4 struct{ F__opmask_reg [8]int8 } + F__fpu_k5 struct{ F__opmask_reg [8]int8 } + F__fpu_k6 struct{ F__opmask_reg [8]int8 } + F__fpu_k7 struct{ F__opmask_reg [8]int8 } + F__fpu_zmmh0 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh1 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh2 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh3 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh4 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh5 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh6 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh7 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh8 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh9 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh10 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh11 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh12 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh13 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh14 struct{ F__ymm_reg [32]int8 } + F__fpu_zmmh15 struct{ F__ymm_reg [32]int8 } + F__fpu_zmm16 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm17 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm18 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm19 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm20 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm21 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm22 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm23 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm24 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm25 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm26 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm27 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm28 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm29 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm30 struct{ F__zmm_reg [64]int8 } + F__fpu_zmm31 struct{ F__zmm_reg [64]int8 } + } + F__ccgo_pad1 [4]byte +} /* _mcontext.h:138:1 */ + +type Mcontext_t = uintptr /* _mcontext.h:204:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Structure used in sigaltstack call. + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type X__darwin_sigaltstack = struct { + Fss_sp uintptr + Fss_size X__darwin_size_t + Fss_flags int32 + F__ccgo_pad1 [4]byte +} /* _sigaltstack.h:42:1 */ + +type Stack_t = X__darwin_sigaltstack /* _sigaltstack.h:48:33 */ // [???] signal stack + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_ucontext = struct { + Fuc_onstack int32 + Fuc_sigmask X__darwin_sigset_t + Fuc_stack struct { + Fss_sp uintptr + Fss_size X__darwin_size_t + Fss_flags int32 + F__ccgo_pad1 [4]byte + } + Fuc_link uintptr + Fuc_mcsize X__darwin_size_t + Fuc_mcontext uintptr +} /* _ucontext.h:42:1 */ + +// user context +type Ucontext_t = X__darwin_ucontext /* _ucontext.h:56:33 */ // [???] user context + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Sigset_t = X__darwin_sigset_t /* _sigset_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +type Sigval = struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte +} /* signal.h:158:1 */ + +type Sigevent = struct { + Fsigev_notify int32 + Fsigev_signo int32 + Fsigev_value struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte + } + Fsigev_notify_function uintptr + Fsigev_notify_attributes uintptr +} /* signal.h:168:1 */ + +type X__siginfo = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + Fsi_pid Pid_t + Fsi_uid Uid_t + Fsi_status int32 + Fsi_addr uintptr + Fsi_value struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte + } + Fsi_band int64 + F__pad [7]uint64 +} /* signal.h:177:9 */ + +type Siginfo_t = X__siginfo /* signal.h:188:3 */ + +// When the signal is SIGILL or SIGFPE, si_addr contains the address of +// the faulting instruction. +// When the signal is SIGSEGV or SIGBUS, si_addr contains the address of +// the faulting memory reference. Although for x86 there are cases of SIGSEGV +// for which si_addr cannot be determined and is NULL. +// If the signal is SIGCHLD, the si_pid field will contain the child process ID, +// si_status contains the exit value or signal and +// si_uid contains the real user ID of the process that sent the signal. + +// Values for si_code + +// Codes for SIGILL + +// Codes for SIGFPE + +// Codes for SIGSEGV + +// Codes for SIGBUS + +// Codes for SIGTRAP + +// Codes for SIGCHLD + +// Codes for SIGPOLL + +// union for signal handlers +type X__sigaction_u = struct{ F__sa_handler uintptr } /* signal.h:269:1 */ + +// Signal vector template for Kernel user boundary +type X__sigaction = struct { + F__sigaction_u struct{ F__sa_handler uintptr } + Fsa_tramp uintptr + Fsa_mask Sigset_t + Fsa_flags int32 +} /* signal.h:276:1 */ + +// Signal vector "template" used in sigaction call. +type Sigaction = struct { + F__sigaction_u struct{ F__sa_handler uintptr } + Fsa_mask Sigset_t + Fsa_flags int32 +} /* signal.h:286:1 */ + +// if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. + +// This will provide 64bit register set in a 32bit user address space + +// the following are the only bits we support from user space, the +// rest are for kernel use only. + +// Flags for sigprocmask: + +// POSIX 1003.1b required values. + +type Sig_t = uintptr /* signal.h:331:14 */ // type of signal function + +// Structure used in sigaltstack call. + +// 4.3 compatibility: +// Signal vector "template" used in sigvec call. +type Sigvec = struct { + Fsv_handler uintptr + Fsv_mask int32 + Fsv_flags int32 +} /* signal.h:348:1 */ + +// Structure used in sigstack call. +type Sigstack = struct { + Fss_sp uintptr + Fss_onstack int32 + F__ccgo_pad1 [4]byte +} /* signal.h:367:1 */ + +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// C99 7.18.4 Macros for minimum-width integer constants. +// +// The standard requires that integer constant macros be defined for all the +// minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width +// types are required, the corresponding integer constant macros are defined +// here. This implementation also defines minimum-width types for every other +// integer width that the target implements, so corresponding macros are +// defined below, too. +// +// These macros are defined using the same successive-shrinking approach as +// the type definitions above. It is likewise important that macros are defined +// in order of decending width. +// +// Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// C99 7.18.2.1 Limits of exact-width integer types. +// C99 7.18.2.2 Limits of minimum-width integer types. +// C99 7.18.2.3 Limits of fastest minimum-width integer types. +// +// The presence of limit macros are completely optional in C99. This +// implementation defines limits for all of the types (exact- and +// minimum-width) that it defines above, using the limits of the minimum-width +// type for any types that do not have exact-width representations. +// +// As in the type definitions, this section takes an approach of +// successive-shrinking to determine which limits to use for the standard (8, +// 16, 32, 64) bit widths when they don't have exact representations. It is +// therefore important that the definitions be kept in order of decending +// widths. +// +// Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// Some utility macros + +// C99 7.18.2.4 Limits of integer types capable of holding object pointers. +// C99 7.18.3 Limits of other integer types. + +// ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ +// is enabled. + +// C99 7.18.2.5 Limits of greatest-width integer types. + +// C99 7.18.3 Limits of other integer types. + +// 7.18.4.2 Macros for greatest-width integer constants. + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// [XSI] The timeval structure shall be defined as described in +// +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Timeval = struct { + Ftv_sec X__darwin_time_t + Ftv_usec X__darwin_suseconds_t + F__ccgo_pad1 [4]byte +} /* _timeval.h:34:1 */ + +// The id_t type shall be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Resource limit type (low 63 bits, excluding the sign bit) +type Rlim_t = X__uint64_t /* resource.h:89:25 */ + +// **** +// +// PRIORITY + +// Possible values of the first parameter to getpriority()/setpriority(), +// used to indicate the type of the second parameter. + +// Range limitations for the value of the third parameter to setpriority(). + +// use PRIO_DARWIN_BG to set the current thread into "background" state +// which lowers CPU, disk IO, and networking priorites until thread terminates +// or "background" state is revoked + +// use PRIO_DARWIN_NONUI to restrict a process's ability to make calls to +// the GPU. (deprecated) + +// **** +// +// RESOURCE USAGE + +// Possible values of the first parameter to getrusage(), used to indicate +// the scope of the information to be returned. + +// A structure representing an accounting of resource utilization. The +// address of an instance of this structure is the second parameter to +// getrusage(). +// +// Note: All values other than ru_utime and ru_stime are implementaiton +// +// defined and subject to change in a future release. Their use +// is discouraged for standards compliant programs. +type Rusage = struct { + Fru_utime struct { + Ftv_sec X__darwin_time_t + Ftv_usec X__darwin_suseconds_t + F__ccgo_pad1 [4]byte + } + Fru_stime struct { + Ftv_sec X__darwin_time_t + Ftv_usec X__darwin_suseconds_t + F__ccgo_pad1 [4]byte + } + Fru_maxrss int64 + Fru_ixrss int64 + Fru_idrss int64 + Fru_isrss int64 + Fru_minflt int64 + Fru_majflt int64 + Fru_nswap int64 + Fru_inblock int64 + Fru_oublock int64 + Fru_msgsnd int64 + Fru_msgrcv int64 + Fru_nsignals int64 + Fru_nvcsw int64 + Fru_nivcsw int64 +} /* resource.h:152:1 */ + +// Flavors for proc_pid_rusage(). + +type Rusage_info_t = uintptr /* resource.h:193:14 */ + +type Rusage_info_v0 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t +} /* resource.h:195:1 */ + +type Rusage_info_v1 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t +} /* resource.h:209:1 */ + +type Rusage_info_v2 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t + Fri_diskio_bytesread Uint64_t + Fri_diskio_byteswritten Uint64_t +} /* resource.h:229:1 */ + +type Rusage_info_v3 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t + Fri_diskio_bytesread Uint64_t + Fri_diskio_byteswritten Uint64_t + Fri_cpu_time_qos_default Uint64_t + Fri_cpu_time_qos_maintenance Uint64_t + Fri_cpu_time_qos_background Uint64_t + Fri_cpu_time_qos_utility Uint64_t + Fri_cpu_time_qos_legacy Uint64_t + Fri_cpu_time_qos_user_initiated Uint64_t + Fri_cpu_time_qos_user_interactive Uint64_t + Fri_billed_system_time Uint64_t + Fri_serviced_system_time Uint64_t +} /* resource.h:251:1 */ + +type Rusage_info_v4 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t + Fri_diskio_bytesread Uint64_t + Fri_diskio_byteswritten Uint64_t + Fri_cpu_time_qos_default Uint64_t + Fri_cpu_time_qos_maintenance Uint64_t + Fri_cpu_time_qos_background Uint64_t + Fri_cpu_time_qos_utility Uint64_t + Fri_cpu_time_qos_legacy Uint64_t + Fri_cpu_time_qos_user_initiated Uint64_t + Fri_cpu_time_qos_user_interactive Uint64_t + Fri_billed_system_time Uint64_t + Fri_serviced_system_time Uint64_t + Fri_logical_writes Uint64_t + Fri_lifetime_max_phys_footprint Uint64_t + Fri_instructions Uint64_t + Fri_cycles Uint64_t + Fri_billed_energy Uint64_t + Fri_serviced_energy Uint64_t + Fri_interval_max_phys_footprint Uint64_t + Fri_runnable_time Uint64_t +} /* resource.h:282:1 */ + +type Rusage_info_current = Rusage_info_v4 /* resource.h:321:31 */ + +// **** +// +// RESOURCE LIMITS + +// Symbolic constants for resource limits; since all limits are representable +// as a type rlim_t, we are permitted to define RLIM_SAVED_* in terms of +// RLIM_INFINITY. + +// Possible values of the first parameter to getrlimit()/setrlimit(), to +// indicate for which resource the operation is being performed. + +// A structure representing a resource limit. The address of an instance +// of this structure is the second parameter to getrlimit()/setrlimit(). +type Rlimit = struct { + Frlim_cur Rlim_t + Frlim_max Rlim_t +} /* resource.h:365:1 */ + +// proc_rlimit_control() +// +// Resource limit flavors + +// Flags for wakeups monitor control. + +// Flags for CPU usage monitor control. + +// Flags for memory footprint interval tracking. + +type Proc_rlimit_control_wakeupmon = struct { + Fwm_flags Uint32_t + Fwm_rate Int32_t +} /* resource.h:400:1 */ + +// Deprecated: +// Structure of the information in the status word returned by wait4. +// If w_stopval==_WSTOPPED, then the second structure describes +// the information returned, else the first. +type Wait = struct{ Fw_status int32 } /* wait.h:194:1 */ + +// built-in for gcc + +// built-in for gcc 3 + +// DO NOT REMOVE THIS COMMENT: fixincludes needs to see: +// _GCC_SIZE_T +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Ct_rune_t = X__darwin_ct_rune_t /* _ct_rune_t.h:32:28 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Rune_t = X__darwin_rune_t /* _rune_t.h:31:25 */ + +type Div_t = struct { + Fquot int32 + Frem int32 +} /* stdlib.h:86:3 */ + +type Ldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:91:3 */ + +type Lldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:97:3 */ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ // getsubopt(3) external variable +// valloc is now declared in _malloc.h + +// Poison the following routines if -fshort-wchar is set + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/stdlib/stdlib_darwin_arm64.go b/internal/libc/stdlib/stdlib_darwin_arm64.go new file mode 100644 index 0000000..65f03dd --- /dev/null +++ b/internal/libc/stdlib/stdlib_darwin_arm64.go @@ -0,0 +1,4430 @@ +// Code generated by 'ccgo stdlib/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdlib/stdlib_darwin_arm64.go -pkgname stdlib', DO NOT EDIT. + +package stdlib + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 // endian.h:72:1: + BUS_ADRALN = 1 // signal.h:241:1: + BUS_ADRERR = 2 // signal.h:242:1: + BUS_NOOP = 0 // signal.h:239:1: + BUS_OBJERR = 3 // signal.h:243:1: + BYTE_ORDER = 1234 // endian.h:75:1: + CLD_CONTINUED = 6 // signal.h:258:1: + CLD_DUMPED = 3 // signal.h:255:1: + CLD_EXITED = 1 // signal.h:253:1: + CLD_KILLED = 2 // signal.h:254:1: + CLD_NOOP = 0 // signal.h:251:1: + CLD_STOPPED = 5 // signal.h:257:1: + CLD_TRAPPED = 4 // signal.h:256:1: + CPUMON_MAKE_FATAL = 0x1000 // resource.h:439:1: + EXIT_FAILURE = 1 // stdlib.h:102:1: + EXIT_SUCCESS = 0 // stdlib.h:103:1: + FOOTPRINT_INTERVAL_RESET = 0x1 // resource.h:444:1: + FPE_FLTDIV = 1 // signal.h:221:1: + FPE_FLTINV = 5 // signal.h:225:1: + FPE_FLTOVF = 2 // signal.h:222:1: + FPE_FLTRES = 4 // signal.h:224:1: + FPE_FLTSUB = 6 // signal.h:226:1: + FPE_FLTUND = 3 // signal.h:223:1: + FPE_INTDIV = 7 // signal.h:227:1: + FPE_INTOVF = 8 // signal.h:228:1: + FPE_NOOP = 0 // signal.h:219:1: + ILL_BADSTK = 8 // signal.h:215:1: + ILL_COPROC = 7 // signal.h:214:1: + ILL_ILLADR = 5 // signal.h:212:1: + ILL_ILLOPC = 1 // signal.h:208:1: + ILL_ILLOPN = 4 // signal.h:211:1: + ILL_ILLTRP = 2 // signal.h:209:1: + ILL_NOOP = 0 // signal.h:206:1: + ILL_PRVOPC = 3 // signal.h:210:1: + ILL_PRVREG = 6 // signal.h:213:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + IOPOL_APPLICATION = 5 // resource.h:478:1: + IOPOL_ATIME_UPDATES_DEFAULT = 0 // resource.h:482:1: + IOPOL_ATIME_UPDATES_OFF = 1 // resource.h:483:1: + IOPOL_DEFAULT = 0 // resource.h:470:1: + IOPOL_IMPORTANT = 1 // resource.h:471:1: + IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT = 0 // resource.h:485:1: + IOPOL_MATERIALIZE_DATALESS_FILES_OFF = 1 // resource.h:486:1: + IOPOL_MATERIALIZE_DATALESS_FILES_ON = 2 // resource.h:487:1: + IOPOL_NORMAL = 1 // resource.h:479:1: + IOPOL_PASSIVE = 2 // resource.h:472:1: + IOPOL_SCOPE_DARWIN_BG = 2 // resource.h:467:1: + IOPOL_SCOPE_PROCESS = 0 // resource.h:465:1: + IOPOL_SCOPE_THREAD = 1 // resource.h:466:1: + IOPOL_STANDARD = 5 // resource.h:475:1: + IOPOL_THROTTLE = 3 // resource.h:473:1: + IOPOL_TYPE_DISK = 0 // resource.h:454:1: + IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES = 9 // resource.h:462:1: + IOPOL_TYPE_VFS_ATIME_UPDATES = 2 // resource.h:455:1: + IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION = 6 // resource.h:459:1: + IOPOL_TYPE_VFS_IGNORE_PERMISSIONS = 7 // resource.h:460:1: + IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES = 3 // resource.h:456:1: + IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE = 8 // resource.h:461:1: + IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME = 4 // resource.h:457:1: + IOPOL_TYPE_VFS_TRIGGER_RESOLVE = 5 // resource.h:458:1: + IOPOL_UTILITY = 4 // resource.h:474:1: + IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF = 0 // resource.h:504:1: + IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON = 1 // resource.h:505:1: + IOPOL_VFS_CONTENT_PROTECTION_DEFAULT = 0 // resource.h:495:1: + IOPOL_VFS_CONTENT_PROTECTION_IGNORE = 1 // resource.h:496:1: + IOPOL_VFS_IGNORE_PERMISSIONS_OFF = 0 // resource.h:498:1: + IOPOL_VFS_IGNORE_PERMISSIONS_ON = 1 // resource.h:499:1: + IOPOL_VFS_SKIP_MTIME_UPDATE_OFF = 0 // resource.h:501:1: + IOPOL_VFS_SKIP_MTIME_UPDATE_ON = 1 // resource.h:502:1: + IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME = 1 // resource.h:490:1: + IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT = 0 // resource.h:489:1: + IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT = 0 // resource.h:492:1: + IOPOL_VFS_TRIGGER_RESOLVE_OFF = 1 // resource.h:493:1: + LITTLE_ENDIAN = 1234 // endian.h:71:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + MINSIGSTKSZ = 32768 // signal.h:340:1: + NSIG = 32 // signal.h:79:1: + PDP_ENDIAN = 3412 // endian.h:73:1: + POLL_ERR = 4 // signal.h:264:1: + POLL_HUP = 6 // signal.h:266:1: + POLL_IN = 1 // signal.h:261:1: + POLL_MSG = 3 // signal.h:263:1: + POLL_OUT = 2 // signal.h:262:1: + POLL_PRI = 5 // signal.h:265:1: + PRIO_DARWIN_BG = 0x1000 // resource.h:120:1: + PRIO_DARWIN_NONUI = 0x1001 // resource.h:126:1: + PRIO_DARWIN_PROCESS = 4 // resource.h:106:1: + PRIO_DARWIN_THREAD = 3 // resource.h:105:1: + PRIO_MAX = 20 // resource.h:113:1: + PRIO_MIN = -20 // resource.h:112:1: + PRIO_PGRP = 1 // resource.h:101:1: + PRIO_PROCESS = 0 // resource.h:100:1: + PRIO_USER = 2 // resource.h:102:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + RAND_MAX = 0x7fffffff // stdlib.h:105:1: + RLIMIT_AS = 5 // resource.h:395:1: + RLIMIT_CORE = 4 // resource.h:394:1: + RLIMIT_CPU = 0 // resource.h:390:1: + RLIMIT_CPU_USAGE_MONITOR = 0x2 // resource.h:423:1: + RLIMIT_DATA = 2 // resource.h:392:1: + RLIMIT_FOOTPRINT_INTERVAL = 0x4 // resource.h:425:1: + RLIMIT_FSIZE = 1 // resource.h:391:1: + RLIMIT_MEMLOCK = 6 // resource.h:398:1: + RLIMIT_NOFILE = 8 // resource.h:401:1: + RLIMIT_NPROC = 7 // resource.h:399:1: + RLIMIT_RSS = 5 // resource.h:397:1: + RLIMIT_STACK = 3 // resource.h:393:1: + RLIMIT_THREAD_CPULIMITS = 0x3 // resource.h:424:1: + RLIMIT_WAKEUPS_MONITOR = 0x1 // resource.h:422:1: + RLIM_NLIMITS = 9 // resource.h:403:1: + RSIZE_MAX = 9223372036854775807 // stdint.h:658:1: + RUSAGE_CHILDREN = -1 // resource.h:141:1: + RUSAGE_INFO_CURRENT = 5 // resource.h:192:1: + RUSAGE_INFO_V0 = 0 // resource.h:186:1: + RUSAGE_INFO_V1 = 1 // resource.h:187:1: + RUSAGE_INFO_V2 = 2 // resource.h:188:1: + RUSAGE_INFO_V3 = 3 // resource.h:189:1: + RUSAGE_INFO_V4 = 4 // resource.h:190:1: + RUSAGE_INFO_V5 = 5 // resource.h:191:1: + RUSAGE_SELF = 0 // resource.h:140:1: + RU_PROC_RUNS_RESLIDE = 0x00000001 // resource.h:197:1: + SA_64REGSET = 0x0200 // signal.h:308:1: + SA_NOCLDSTOP = 0x0008 // signal.h:301:1: + SA_NOCLDWAIT = 0x0020 // signal.h:303:1: + SA_NODEFER = 0x0010 // signal.h:302:1: + SA_ONSTACK = 0x0001 // signal.h:298:1: + SA_RESETHAND = 0x0004 // signal.h:300:1: + SA_RESTART = 0x0002 // signal.h:299:1: + SA_SIGINFO = 0x0040 // signal.h:304:1: + SA_USERSPACE_MASK = 127 // signal.h:314:1: + SA_USERTRAMP = 0x0100 // signal.h:306:1: + SEGV_ACCERR = 2 // signal.h:235:1: + SEGV_MAPERR = 1 // signal.h:234:1: + SEGV_NOOP = 0 // signal.h:232:1: + SIGABRT = 6 // signal.h:89:1: + SIGALRM = 14 // signal.h:102:1: + SIGBUS = 10 // signal.h:98:1: + SIGCHLD = 20 // signal.h:108:1: + SIGCONT = 19 // signal.h:107:1: + SIGEMT = 7 // signal.h:94:1: + SIGEV_NONE = 0 // signal.h:164:1: + SIGEV_SIGNAL = 1 // signal.h:165:1: + SIGEV_THREAD = 3 // signal.h:166:1: + SIGFPE = 8 // signal.h:96:1: + SIGHUP = 1 // signal.h:84:1: + SIGILL = 4 // signal.h:87:1: + SIGINFO = 29 // signal.h:120:1: + SIGINT = 2 // signal.h:85:1: + SIGIO = 23 // signal.h:112:1: + SIGIOT = 6 // signal.h:93:1: + SIGKILL = 9 // signal.h:97:1: + SIGPIPE = 13 // signal.h:101:1: + SIGPROF = 27 // signal.h:117:1: + SIGQUIT = 3 // signal.h:86:1: + SIGSEGV = 11 // signal.h:99:1: + SIGSTKSZ = 131072 // signal.h:341:1: + SIGSTOP = 17 // signal.h:105:1: + SIGSYS = 12 // signal.h:100:1: + SIGTERM = 15 // signal.h:103:1: + SIGTRAP = 5 // signal.h:88:1: + SIGTSTP = 18 // signal.h:106:1: + SIGTTIN = 21 // signal.h:109:1: + SIGTTOU = 22 // signal.h:110:1: + SIGURG = 16 // signal.h:104:1: + SIGUSR1 = 30 // signal.h:122:1: + SIGUSR2 = 31 // signal.h:123:1: + SIGVTALRM = 26 // signal.h:116:1: + SIGWINCH = 28 // signal.h:119:1: + SIGXCPU = 24 // signal.h:114:1: + SIGXFSZ = 25 // signal.h:115:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIG_BLOCK = 1 // signal.h:319:1: + SIG_SETMASK = 3 // signal.h:321:1: + SIG_UNBLOCK = 2 // signal.h:320:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + SI_ASYNCIO = 0x10004 // signal.h:327:1: + SI_MESGQ = 0x10005 // signal.h:328:1: + SI_QUEUE = 0x10002 // signal.h:325:1: + SI_TIMER = 0x10003 // signal.h:326:1: + SI_USER = 0x10001 // signal.h:324:1: + SS_DISABLE = 0x0004 // signal.h:339:1: + SS_ONSTACK = 0x0001 // signal.h:338:1: + SV_INTERRUPT = 2 // signal.h:355:1: + SV_NOCLDSTOP = 8 // signal.h:358:1: + SV_NODEFER = 16 // signal.h:357:1: + SV_ONSTACK = 1 // signal.h:354:1: + SV_RESETHAND = 4 // signal.h:356:1: + SV_SIGINFO = 64 // signal.h:359:1: + TRAP_BRKPT = 1 // signal.h:246:1: + TRAP_TRACE = 2 // signal.h:247:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + WAIT_ANY = -1 // wait.h:183:1: + WAIT_MYPGRP = 0 // wait.h:184:1: + WAKEMON_DISABLE = 0x02 // resource.h:431:1: + WAKEMON_ENABLE = 0x01 // resource.h:430:1: + WAKEMON_GET_PARAMS = 0x04 // resource.h:432:1: + WAKEMON_MAKE_FATAL = 0x10 // resource.h:434:1: + WAKEMON_SET_DEFAULTS = 0x08 // resource.h:433:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WCONTINUED = 0x00000010 // wait.h:173:1: + WCOREFLAG = 0200 // wait.h:132:1: + WEXITED = 0x00000004 // wait.h:168:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + WNOHANG = 0x00000001 // wait.h:121:1: + WNOWAIT = 0x00000020 // wait.h:174:1: + WSTOPPED = 0x00000008 // wait.h:171:1: + WUNTRACED = 0x00000002 // wait.h:122:1: + X_ALLOCA_H_ = 0 // alloca.h:25:1: + X_ARM_ARCH_H = 0 // arch.h:29:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_ARM_SIGNAL_ = 1 // signal.h:10:1: + X_ARM__ENDIAN_H_ = 0 // endian.h:43:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_SIGNAL_H_ = 0 // signal.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__MCONTEXT_H_ = 0 // _mcontext.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CT_RUNE_T = 0 // _ct_rune_t.h:30:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MACH_ARM__STRUCTS_H_ = 0 // _structs.h:32:1: + X_MACH_MACHINE__STRUCTS_H_ = 0 // _structs.h:30:1: + X_MALLOC_UNDERSCORE_MALLOC_H_ = 0 // _malloc.h:25:1: + X_MCONTEXT_T = 0 // _mcontext.h:83:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OS_OSBYTEORDERARM_H = 0 // OSByteOrder.h:6:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:56:1: + X_QUAD_LOWWORD = 0 // endian.h:57:1: + X_RLIMIT_POSIX_FLAG = 0x1000 // resource.h:405:1: + X_RUNE_T = 0 // _rune_t.h:29:1: + X_SIGSET_T = 0 // _sigset_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_STDLIB_H_ = 0 // stdlib.h:59:1: + X_SYS_RESOURCE_H_ = 0 // resource.h:65:1: + X_SYS_SIGNAL_H_ = 0 // signal.h:70:1: + X_SYS_WAIT_H_ = 0 // wait.h:65:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINT32_T = 0 // _uint32_t.h:30:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_WCHAR_T = 0 // _wchar_t.h:32:1: + X_WSTOPPED = 0177 // wait.h:137:1: +) + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 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. +// +// @(#)wait.h 8.2 (Berkeley) 7/10/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This file holds definitions relevent to the wait4 system call +// and the alternate interfaces that use it (wait, wait3, waitpid). + +// [XSI] The type idtype_t shall be defined as an enumeration type whose +// possible values shall include at least P_ALL, P_PID, and P_PGID. +const ( /* wait.h:79:1: */ + P_ALL = 0 + P_PID = 1 + P_PGID = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000, 2002 - 2008 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)stdlib.h 8.5 (Berkeley) 5/19/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support clang language extensions. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support clang language extensions. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 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. +// +// @(#)wait.h 8.2 (Berkeley) 7/10/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This file holds definitions relevent to the wait4 system call +// and the alternate interfaces that use it (wait, wait3, waitpid). + +// [XSI] The type idtype_t shall be defined as an enumeration type whose +// possible values shall include at least P_ALL, P_PID, and P_PGID. +type Idtype_t = uint32 /* wait.h:83:3 */ + +// [XSI] The id_t and pid_t types shall be defined as described +// in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t + +// [XSI] The siginfo_t type shall be defined as described in +// [XSI] The rusage structure shall be defined as described in +// [XSI] Inclusion of the header may also make visible all +// symbols from and +// +// NOTE: This requirement is currently being satisfied by the direct +// inclusion of and , below. +// +// Software should not depend on the exposure of anything other +// than the types siginfo_t and struct rusage as a result of +// this inclusion. If you depend on any types or manifest +// values othe than siginfo_t and struct rusage from either of +// those files, you should explicitly include them yourself, as +// well, or in future releases your stware may not compile +// without modification. +// Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1989, 1991, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)signal.h 8.2 (Berkeley) 1/21/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2009 Apple, Inc. All rights reserved. +// Copyright (c) 1992 NeXT Computer, Inc. +// + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +type Sig_atomic_t = int32 /* signal.h:17:13 */ + +// Language spec sez we must list exactly one parameter, even though we +// actually supply three. Ugh! +// SIG_HOLD is chosen to avoid KERN_SIG_* values in + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// @OSF_COPYRIGHT@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type X__darwin_arm_exception_state = struct { + F__exception X__uint32_t + F__fsr X__uint32_t + F__far X__uint32_t +} /* _structs.h:41:1 */ + +type X__darwin_arm_exception_state64 = struct { + F__far X__uint64_t + F__esr X__uint32_t + F__exception X__uint32_t +} /* _structs.h:59:1 */ + +type X__darwin_arm_thread_state = struct { + F__r [13]X__uint32_t + F__sp X__uint32_t + F__lr X__uint32_t + F__pc X__uint32_t + F__cpsr X__uint32_t +} /* _structs.h:77:1 */ + +// By default, the pointer fields in the arm_thread_state64_t structure are +// opaque on the arm64e architecture and require the use of accessor macros. +// This mode can also be enabled on the arm64 architecture by building with +// -D__DARWIN_OPAQUE_ARM_THREAD_STATE64=1. + +type X__darwin_arm_thread_state64 = struct { + F__x [29]X__uint64_t + F__fp X__uint64_t + F__lr X__uint64_t + F__sp X__uint64_t + F__pc X__uint64_t + F__cpsr X__uint32_t + F__pad X__uint32_t +} /* _structs.h:136:1 */ + +// Accessor macros for arm_thread_state64_t pointer fields + +// Return pc field of arm_thread_state64_t as a data pointer value +// Return pc field of arm_thread_state64_t as a function pointer +// Set pc field of arm_thread_state64_t to a function pointer +// Return lr field of arm_thread_state64_t as a data pointer value +// Return lr field of arm_thread_state64_t as a function pointer +// Set lr field of arm_thread_state64_t to a function pointer +// Return sp field of arm_thread_state64_t as a data pointer value +// Set sp field of arm_thread_state64_t to a data pointer value +// Return fp field of arm_thread_state64_t as a data pointer value +// Set fp field of arm_thread_state64_t to a data pointer value +// Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t + +type X__darwin_arm_vfp_state = struct { + F__r [64]X__uint32_t + F__fpscr X__uint32_t +} /* _structs.h:433:1 */ + +type X__darwin_arm_neon_state64 = struct { + F__v [32]X__uint128_t + F__fpsr X__uint32_t + F__fpcr X__uint32_t +} /* _structs.h:452:1 */ + +type X__darwin_arm_neon_state = struct { + F__v [16]X__uint128_t + F__fpsr X__uint32_t + F__fpcr X__uint32_t +} /* _structs.h:459:1 */ + +type X__arm_pagein_state = struct{ F__pagein_error int32 } /* _structs.h:523:1 */ + +// Debug State + +// ARM's arm_debug_state is ARM64's arm_legacy_debug_state + +type X__arm_legacy_debug_state = struct { + F__bvr [16]X__uint32_t + F__bcr [16]X__uint32_t + F__wvr [16]X__uint32_t + F__wcr [16]X__uint32_t +} /* _structs.h:560:1 */ + +type X__darwin_arm_debug_state32 = struct { + F__bvr [16]X__uint32_t + F__bcr [16]X__uint32_t + F__wvr [16]X__uint32_t + F__wcr [16]X__uint32_t + F__mdscr_el1 X__uint64_t +} /* _structs.h:583:1 */ + +type X__darwin_arm_debug_state64 = struct { + F__bvr [16]X__uint64_t + F__bcr [16]X__uint64_t + F__wvr [16]X__uint64_t + F__wcr [16]X__uint64_t + F__mdscr_el1 X__uint64_t +} /* _structs.h:593:1 */ + +type X__darwin_arm_cpmu_state64 = struct{ F__ctrs [16]X__uint64_t } /* _structs.h:625:1 */ + +type X__darwin_mcontext32 = struct { + F__es struct { + F__exception X__uint32_t + F__fsr X__uint32_t + F__far X__uint32_t + } + F__ss struct { + F__r [13]X__uint32_t + F__sp X__uint32_t + F__lr X__uint32_t + F__pc X__uint32_t + F__cpsr X__uint32_t + } + F__fs struct { + F__r [64]X__uint32_t + F__fpscr X__uint32_t + } +} /* _mcontext.h:41:1 */ + +type X__darwin_mcontext64 = struct { + F__es struct { + F__far X__uint64_t + F__esr X__uint32_t + F__exception X__uint32_t + } + F__ss struct { + F__x [29]X__uint64_t + F__fp X__uint64_t + F__lr X__uint64_t + F__sp X__uint64_t + F__pc X__uint64_t + F__cpsr X__uint32_t + F__pad X__uint32_t + } + F__ns struct { + F__v [32]X__uint128_t + F__fpsr X__uint32_t + F__fpcr X__uint32_t + } +} /* _mcontext.h:64:1 */ + +type Mcontext_t = uintptr /* _mcontext.h:85:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Structure used in sigaltstack call. + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type X__darwin_sigaltstack = struct { + Fss_sp uintptr + Fss_size X__darwin_size_t + Fss_flags int32 + F__ccgo_pad1 [4]byte +} /* _sigaltstack.h:42:1 */ + +type Stack_t = X__darwin_sigaltstack /* _sigaltstack.h:48:33 */ // [???] signal stack + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Structure used in sigaltstack call. + +type X__darwin_ucontext = struct { + Fuc_onstack int32 + Fuc_sigmask X__darwin_sigset_t + Fuc_stack struct { + Fss_sp uintptr + Fss_size X__darwin_size_t + Fss_flags int32 + F__ccgo_pad1 [4]byte + } + Fuc_link uintptr + Fuc_mcsize X__darwin_size_t + Fuc_mcontext uintptr +} /* _ucontext.h:43:1 */ + +// user context +type Ucontext_t = X__darwin_ucontext /* _ucontext.h:57:33 */ // [???] user context + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Sigset_t = X__darwin_sigset_t /* _sigset_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +type Sigval = struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte +} /* signal.h:158:1 */ + +type Sigevent = struct { + Fsigev_notify int32 + Fsigev_signo int32 + Fsigev_value struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte + } + Fsigev_notify_function uintptr + Fsigev_notify_attributes uintptr +} /* signal.h:168:1 */ + +type X__siginfo = struct { + Fsi_signo int32 + Fsi_errno int32 + Fsi_code int32 + Fsi_pid Pid_t + Fsi_uid Uid_t + Fsi_status int32 + Fsi_addr uintptr + Fsi_value struct { + F__ccgo_pad1 [0]uint64 + Fsival_int int32 + F__ccgo_pad2 [4]byte + } + Fsi_band int64 + F__pad [7]uint64 +} /* signal.h:177:9 */ + +type Siginfo_t = X__siginfo /* signal.h:188:3 */ + +// When the signal is SIGILL or SIGFPE, si_addr contains the address of +// the faulting instruction. +// When the signal is SIGSEGV or SIGBUS, si_addr contains the address of +// the faulting memory reference. Although for x86 there are cases of SIGSEGV +// for which si_addr cannot be determined and is NULL. +// If the signal is SIGCHLD, the si_pid field will contain the child process ID, +// si_status contains the exit value or signal and +// si_uid contains the real user ID of the process that sent the signal. + +// Values for si_code + +// Codes for SIGILL + +// Codes for SIGFPE + +// Codes for SIGSEGV + +// Codes for SIGBUS + +// Codes for SIGTRAP + +// Codes for SIGCHLD + +// Codes for SIGPOLL + +// union for signal handlers +type X__sigaction_u = struct{ F__sa_handler uintptr } /* signal.h:269:1 */ + +// Signal vector template for Kernel user boundary +type X__sigaction = struct { + F__sigaction_u struct{ F__sa_handler uintptr } + Fsa_tramp uintptr + Fsa_mask Sigset_t + Fsa_flags int32 +} /* signal.h:276:1 */ + +// Signal vector "template" used in sigaction call. +type Sigaction = struct { + F__sigaction_u struct{ F__sa_handler uintptr } + Fsa_mask Sigset_t + Fsa_flags int32 +} /* signal.h:286:1 */ + +// if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. + +// This will provide 64bit register set in a 32bit user address space + +// the following are the only bits we support from user space, the +// rest are for kernel use only. + +// Flags for sigprocmask: + +// POSIX 1003.1b required values. + +type Sig_t = uintptr /* signal.h:331:14 */ // type of signal function + +// Structure used in sigaltstack call. + +// 4.3 compatibility: +// Signal vector "template" used in sigvec call. +type Sigvec = struct { + Fsv_handler uintptr + Fsv_mask int32 + Fsv_flags int32 +} /* signal.h:348:1 */ + +// Structure used in sigstack call. +type Sigstack = struct { + Fss_sp uintptr + Fss_onstack int32 + F__ccgo_pad1 [4]byte +} /* signal.h:367:1 */ + +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// C99 7.18.4 Macros for minimum-width integer constants. +// +// The standard requires that integer constant macros be defined for all the +// minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width +// types are required, the corresponding integer constant macros are defined +// here. This implementation also defines minimum-width types for every other +// integer width that the target implements, so corresponding macros are +// defined below, too. +// +// These macros are defined using the same successive-shrinking approach as +// the type definitions above. It is likewise important that macros are defined +// in order of decending width. +// +// Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// C99 7.18.2.1 Limits of exact-width integer types. +// C99 7.18.2.2 Limits of minimum-width integer types. +// C99 7.18.2.3 Limits of fastest minimum-width integer types. +// +// The presence of limit macros are completely optional in C99. This +// implementation defines limits for all of the types (exact- and +// minimum-width) that it defines above, using the limits of the minimum-width +// type for any types that do not have exact-width representations. +// +// As in the type definitions, this section takes an approach of +// successive-shrinking to determine which limits to use for the standard (8, +// 16, 32, 64) bit widths when they don't have exact representations. It is +// therefore important that the definitions be kept in order of decending +// widths. +// +// Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the +// claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + +// Some utility macros + +// C99 7.18.2.4 Limits of integer types capable of holding object pointers. +// C99 7.18.3 Limits of other integer types. + +// ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ +// is enabled. + +// C99 7.18.2.5 Limits of greatest-width integer types. + +// C99 7.18.3 Limits of other integer types. + +// 7.18.4.2 Macros for greatest-width integer constants. + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// [XSI] The timeval structure shall be defined as described in +// +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Timeval = struct { + Ftv_sec X__darwin_time_t + Ftv_usec X__darwin_suseconds_t + F__ccgo_pad1 [4]byte +} /* _timeval.h:34:1 */ + +// The id_t type shall be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Resource limit type (low 63 bits, excluding the sign bit) +type Rlim_t = X__uint64_t /* resource.h:89:25 */ + +// **** +// +// PRIORITY + +// Possible values of the first parameter to getpriority()/setpriority(), +// used to indicate the type of the second parameter. + +// Range limitations for the value of the third parameter to setpriority(). + +// use PRIO_DARWIN_BG to set the current thread into "background" state +// which lowers CPU, disk IO, and networking priorites until thread terminates +// or "background" state is revoked + +// use PRIO_DARWIN_NONUI to restrict a process's ability to make calls to +// the GPU. (deprecated) + +// **** +// +// RESOURCE USAGE + +// Possible values of the first parameter to getrusage(), used to indicate +// the scope of the information to be returned. + +// A structure representing an accounting of resource utilization. The +// address of an instance of this structure is the second parameter to +// getrusage(). +// +// Note: All values other than ru_utime and ru_stime are implementaiton +// +// defined and subject to change in a future release. Their use +// is discouraged for standards compliant programs. +type Rusage = struct { + Fru_utime struct { + Ftv_sec X__darwin_time_t + Ftv_usec X__darwin_suseconds_t + F__ccgo_pad1 [4]byte + } + Fru_stime struct { + Ftv_sec X__darwin_time_t + Ftv_usec X__darwin_suseconds_t + F__ccgo_pad1 [4]byte + } + Fru_maxrss int64 + Fru_ixrss int64 + Fru_idrss int64 + Fru_isrss int64 + Fru_minflt int64 + Fru_majflt int64 + Fru_nswap int64 + Fru_inblock int64 + Fru_oublock int64 + Fru_msgsnd int64 + Fru_msgrcv int64 + Fru_nsignals int64 + Fru_nvcsw int64 + Fru_nivcsw int64 +} /* resource.h:152:1 */ + +// Flavors for proc_pid_rusage(). + +// Flags for RUSAGE_INFO_V5 + +type Rusage_info_t = uintptr /* resource.h:199:14 */ + +type Rusage_info_v0 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t +} /* resource.h:201:1 */ + +type Rusage_info_v1 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t +} /* resource.h:215:1 */ + +type Rusage_info_v2 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t + Fri_diskio_bytesread Uint64_t + Fri_diskio_byteswritten Uint64_t +} /* resource.h:235:1 */ + +type Rusage_info_v3 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t + Fri_diskio_bytesread Uint64_t + Fri_diskio_byteswritten Uint64_t + Fri_cpu_time_qos_default Uint64_t + Fri_cpu_time_qos_maintenance Uint64_t + Fri_cpu_time_qos_background Uint64_t + Fri_cpu_time_qos_utility Uint64_t + Fri_cpu_time_qos_legacy Uint64_t + Fri_cpu_time_qos_user_initiated Uint64_t + Fri_cpu_time_qos_user_interactive Uint64_t + Fri_billed_system_time Uint64_t + Fri_serviced_system_time Uint64_t +} /* resource.h:257:1 */ + +type Rusage_info_v4 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t + Fri_diskio_bytesread Uint64_t + Fri_diskio_byteswritten Uint64_t + Fri_cpu_time_qos_default Uint64_t + Fri_cpu_time_qos_maintenance Uint64_t + Fri_cpu_time_qos_background Uint64_t + Fri_cpu_time_qos_utility Uint64_t + Fri_cpu_time_qos_legacy Uint64_t + Fri_cpu_time_qos_user_initiated Uint64_t + Fri_cpu_time_qos_user_interactive Uint64_t + Fri_billed_system_time Uint64_t + Fri_serviced_system_time Uint64_t + Fri_logical_writes Uint64_t + Fri_lifetime_max_phys_footprint Uint64_t + Fri_instructions Uint64_t + Fri_cycles Uint64_t + Fri_billed_energy Uint64_t + Fri_serviced_energy Uint64_t + Fri_interval_max_phys_footprint Uint64_t + Fri_runnable_time Uint64_t +} /* resource.h:288:1 */ + +type Rusage_info_v5 = struct { + Fri_uuid [16]Uint8_t + Fri_user_time Uint64_t + Fri_system_time Uint64_t + Fri_pkg_idle_wkups Uint64_t + Fri_interrupt_wkups Uint64_t + Fri_pageins Uint64_t + Fri_wired_size Uint64_t + Fri_resident_size Uint64_t + Fri_phys_footprint Uint64_t + Fri_proc_start_abstime Uint64_t + Fri_proc_exit_abstime Uint64_t + Fri_child_user_time Uint64_t + Fri_child_system_time Uint64_t + Fri_child_pkg_idle_wkups Uint64_t + Fri_child_interrupt_wkups Uint64_t + Fri_child_pageins Uint64_t + Fri_child_elapsed_abstime Uint64_t + Fri_diskio_bytesread Uint64_t + Fri_diskio_byteswritten Uint64_t + Fri_cpu_time_qos_default Uint64_t + Fri_cpu_time_qos_maintenance Uint64_t + Fri_cpu_time_qos_background Uint64_t + Fri_cpu_time_qos_utility Uint64_t + Fri_cpu_time_qos_legacy Uint64_t + Fri_cpu_time_qos_user_initiated Uint64_t + Fri_cpu_time_qos_user_interactive Uint64_t + Fri_billed_system_time Uint64_t + Fri_serviced_system_time Uint64_t + Fri_logical_writes Uint64_t + Fri_lifetime_max_phys_footprint Uint64_t + Fri_instructions Uint64_t + Fri_cycles Uint64_t + Fri_billed_energy Uint64_t + Fri_serviced_energy Uint64_t + Fri_interval_max_phys_footprint Uint64_t + Fri_runnable_time Uint64_t + Fri_flags Uint64_t +} /* resource.h:327:1 */ + +type Rusage_info_current = Rusage_info_v5 /* resource.h:367:31 */ + +// **** +// +// RESOURCE LIMITS + +// Symbolic constants for resource limits; since all limits are representable +// as a type rlim_t, we are permitted to define RLIM_SAVED_* in terms of +// RLIM_INFINITY. + +// Possible values of the first parameter to getrlimit()/setrlimit(), to +// indicate for which resource the operation is being performed. + +// A structure representing a resource limit. The address of an instance +// of this structure is the second parameter to getrlimit()/setrlimit(). +type Rlimit = struct { + Frlim_cur Rlim_t + Frlim_max Rlim_t +} /* resource.h:411:1 */ + +// proc_rlimit_control() +// +// Resource limit flavors + +// Flags for wakeups monitor control. + +// Flags for CPU usage monitor control. + +// Flags for memory footprint interval tracking. + +type Proc_rlimit_control_wakeupmon = struct { + Fwm_flags Uint32_t + Fwm_rate Int32_t +} /* resource.h:446:1 */ + +// Functions for byte reversed loads. + +type X_OSUnalignedU16 = struct{ F__val Uint16_t } /* OSByteOrder.h:64:1 */ + +type X_OSUnalignedU32 = struct{ F__val Uint32_t } /* OSByteOrder.h:68:1 */ + +type X_OSUnalignedU64 = struct{ F__val Uint64_t } /* OSByteOrder.h:72:1 */ + +// Deprecated: +// Structure of the information in the status word returned by wait4. +// If w_stopval==_WSTOPPED, then the second structure describes +// the information returned, else the first. +type Wait = struct{ Fw_status int32 } /* wait.h:194:1 */ + +// built-in for gcc + +// built-in for gcc 3 + +// DO NOT REMOVE THIS COMMENT: fixincludes needs to see: +// _GCC_SIZE_T +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Ct_rune_t = X__darwin_ct_rune_t /* _ct_rune_t.h:32:28 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Rune_t = X__darwin_rune_t /* _rune_t.h:31:25 */ + +type Div_t = struct { + Fquot int32 + Frem int32 +} /* stdlib.h:86:3 */ + +type Ldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:91:3 */ + +type Lldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:97:3 */ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ // getsubopt(3) external variable +// valloc is now declared in _malloc.h + +// Poison the following routines if -fshort-wchar is set + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/stdlib/stdlib_linux_amd64.go b/internal/libc/stdlib/stdlib_linux_amd64.go new file mode 100644 index 0000000..317f8bb --- /dev/null +++ b/internal/libc/stdlib/stdlib_linux_amd64.go @@ -0,0 +1,1541 @@ +// Code generated by 'ccgo stdlib/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o stdlib/stdlib_linux_amd64.go -pkgname stdlib', DO NOT EDIT. + +package stdlib + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 // endian.h:28:1: + BYTE_ORDER = 1234 // endian.h:30:1: + EXIT_FAILURE = 1 // stdlib.h:91:1: + EXIT_SUCCESS = 0 // stdlib.h:92:1: + FD_SETSIZE = 1024 // select.h:73:1: + LITTLE_ENDIAN = 1234 // endian.h:27:1: + PDP_ENDIAN = 3412 // endian.h:29:1: + RAND_MAX = 2147483647 // stdlib.h:86:1: + WCONTINUED = 8 // waitflags.h:32:1: + WEXITED = 4 // waitflags.h:31:1: + WNOHANG = 1 // waitflags.h:25:1: + WNOWAIT = 0x01000000 // waitflags.h:33:1: + WSTOPPED = 2 // waitflags.h:30:1: + WUNTRACED = 2 // waitflags.h:26:1: + X_ALLOCA_H = 1 // alloca.h:19:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_FLOATN_COMMON_H = 0 // floatn-common.h:21:1: + X_BITS_FLOATN_H = 0 // floatn.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_ENDIAN_H = 1 // endian.h:19:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_GCC_WCHAR_T = 0 // stddef.h:273:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STDLIB_H = 1 // stdlib.h:35:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SELECT_H = 1 // select.h:22:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_SYS_TYPES_H = 1 // types.h:23:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + X_T_WCHAR = 0 // stddef.h:264:1: + X_T_WCHAR_ = 0 // stddef.h:263:1: + X_WCHAR_T = 0 // stddef.h:262:1: + X_WCHAR_T_ = 0 // stddef.h:266:1: + X_WCHAR_T_DECLARED = 0 // stddef.h:274:1: + X_WCHAR_T_DEFINED = 0 // stddef.h:269:1: + X_WCHAR_T_DEFINED_ = 0 // stddef.h:268:1: + X_WCHAR_T_H = 0 // stddef.h:270:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// A null pointer constant. + +// XPG requires a few symbols from being defined. +// Definitions of flag bits for `waitpid' et al. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bits in the third argument to `waitpid'. + +// Bits in the fourth argument to `waitid'. + +// The following values are used by the `waitid' function. + +// The Linux kernel defines these bare, rather than an enum, +// which causes a conflict if the include order is reversed. + +const ( /* waitflags.h:52:1: */ + P_ALL = 0 // Wait for any child. + P_PID = 1 // Wait for specified process. + P_PGID = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// A null pointer constant. + +// XPG requires a few symbols from being defined. +// Definitions of flag bits for `waitpid' et al. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bits in the third argument to `waitpid'. + +// Bits in the fourth argument to `waitid'. + +// The following values are used by the `waitid' function. + +// The Linux kernel defines these bare, rather than an enum, +// which causes a conflict if the include order is reversed. + +type Idtype_t = uint32 /* waitflags.h:57:3 */ +// Definitions of status bits for `wait' et al. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Everything extant so far uses these same bits. + +// If WIFEXITED(STATUS), the low-order 8 bits of the status. + +// If WIFSIGNALED(STATUS), the terminating signal. + +// If WIFSTOPPED(STATUS), the signal that stopped the child. + +// Nonzero if STATUS indicates normal termination. + +// Nonzero if STATUS indicates termination by a signal. + +// Nonzero if STATUS indicates the child is stopped. + +// Nonzero if STATUS indicates the child continued after a stop. We only +// define this if provides the WCONTINUED flag bit. + +// Nonzero if STATUS indicates the child dumped core. + +// Macros for constructing status values. + +// Define the macros also would define this way. + +// _FloatN API tests for enablement. +// Macros to control TS 18661-3 glibc features on x86. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Defined to 1 if the current compiler invocation provides a +// floating-point type with the IEEE 754 binary128 format, and this +// glibc includes corresponding *f128 interfaces for it. The required +// libgcc support was added some time after the basic compiler +// support, for x86_64 and x86. + +// Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct +// from the default float, double and long double types in this glibc. + +// Defined to 1 if the current compiler invocation provides a +// floating-point type with the right format for _Float64x, and this +// glibc includes corresponding *f64x interfaces for it. + +// Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format +// of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has +// the format of _Float128, which must be different from that of long +// double. + +// Defined to concatenate the literal suffix to be used with _Float128 +// types, if __HAVE_FLOAT128 is 1. + +// Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. + +// The remaining of this file provides support for older compilers. + +// The type _Float128 exists only since GCC 7.0. + +// __builtin_huge_valf128 doesn't exist before GCC 7.0. + +// Older GCC has only a subset of built-in functions for _Float128 on +// x86, and __builtin_infq is not usable in static initializers. +// Converting a narrower sNaN to _Float128 produces a quiet NaN, so +// attempts to use _Float128 sNaNs will not work properly with older +// compilers. + +// In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*, +// e.g.: __builtin_signbitf128, before GCC 6. However, there has never +// been a __builtin_signbitf128 in GCC and the type-generic builtin is +// only available since GCC 6. + +// Macros to control TS 18661-3 glibc features where the same +// definitions are appropriate for all platforms. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// This header should be included at the bottom of each bits/floatn.h. +// It defines the following macros for each _FloatN and _FloatNx type, +// where the same definitions, or definitions based only on the macros +// in bits/floatn.h, are appropriate for all glibc configurations. + +// Defined to 1 if the current compiler invocation provides a +// floating-point type with the right format for this type, and this +// glibc includes corresponding *fN or *fNx interfaces for it. + +// Defined to 1 if the corresponding __HAVE_ macro is 1 and the +// type is the first with its format in the sequence of (the default +// choices for) float, double, long double, _Float16, _Float32, +// _Float64, _Float128, _Float32x, _Float64x, _Float128x for this +// glibc; that is, if functions present once per floating-point format +// rather than once per type are present for this type. +// +// All configurations supported by glibc have _Float32 the same format +// as float, _Float64 and _Float32x the same format as double, the +// _Float64x the same format as either long double or _Float128. No +// configurations support _Float128x or, as of GCC 7, have compiler +// support for a type meeting the requirements for _Float128x. + +// Defined to 1 if the corresponding _FloatN type is not binary compatible +// with the corresponding ISO C type in the current compilation unit as +// opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built +// in glibc. + +// Defined to 1 if any _FloatN or _FloatNx types that are not +// ABI-distinct are however distinct types at the C language level (so +// for the purposes of __builtin_types_compatible_p and _Generic). + +// Defined to concatenate the literal suffix to be used with _FloatN +// or _FloatNx types, if __HAVE_ is 1. The corresponding +// literal suffixes exist since GCC 7, for C only. + +// Defined to a complex type if __HAVE_ is 1. + +// The remaining of this file provides support for older compilers. + +// If double, long double and _Float64 all have the same set of +// values, TS 18661-3 requires the usual arithmetic conversions on +// long double and _Float64 to produce _Float64. For this to be the +// case when building with a compiler without a distinct _Float64 +// type, _Float64 must be a typedef for long double, not for +// double. + +// Returned by `div'. +type Div_t = struct { + Fquot int32 + Frem int32 +} /* stdlib.h:62:5 */ + +// Returned by `ldiv'. +type Ldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:70:5 */ + +// Returned by `lldiv'. +type Lldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:80:5 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +// Reentrant versions of the `random' family of functions. +// These functions all use the following data structure to contain +// state, rather than global state variables. + +type Random_data = struct { + Ffptr uintptr + Frptr uintptr + Fstate uintptr + Frand_type int32 + Frand_deg int32 + Frand_sep int32 + F__ccgo_pad1 [4]byte + Fend_ptr uintptr +} /* stdlib.h:423:1 */ + +// Data structure for communication with thread safe versions. This +// +// type is to be regarded as opaque. It's only exported because users +// have to allocate objects of this type. +type Drand48_data = struct { + F__x [3]uint16 + F__old_x [3]uint16 + F__c uint16 + F__init uint16 + F__a uint64 +} /* stdlib.h:490:1 */ + +// Shorthand for type of comparison functions. +type X__compar_fn_t = uintptr /* stdlib.h:808:13 */ + +// Floating-point inline functions for stdlib.h. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define some macros helping to catch buffer overflows. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/stdlib/stdlib_linux_arm64.go b/internal/libc/stdlib/stdlib_linux_arm64.go new file mode 100644 index 0000000..5c19f4b --- /dev/null +++ b/internal/libc/stdlib/stdlib_linux_arm64.go @@ -0,0 +1,1617 @@ +// Code generated by 'ccgo stdlib/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o stdlib/stdlib_linux_arm64.go -pkgname stdlib', DO NOT EDIT. + +package stdlib + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 + BYTE_ORDER = 1234 + EXIT_FAILURE = 1 + EXIT_SUCCESS = 0 + FD_SETSIZE = 1024 + LITTLE_ENDIAN = 1234 + PDP_ENDIAN = 3412 + RAND_MAX = 2147483647 + WCONTINUED = 8 + WEXITED = 4 + WNOHANG = 1 + WNOWAIT = 0x01000000 + WSTOPPED = 2 + WUNTRACED = 2 + X_ALLOCA_H = 1 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_FLOATN_COMMON_H = 0 + X_BITS_FLOATN_H = 0 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_GCC_WCHAR_T = 0 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_STDLIB_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_TYPES_H = 1 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + X_T_WCHAR = 0 + X_T_WCHAR_ = 0 + X_WCHAR_T = 0 + X_WCHAR_T_ = 0 + X_WCHAR_T_DECLARED = 0 + X_WCHAR_T_DEFINED = 0 + X_WCHAR_T_DEFINED_ = 0 + X_WCHAR_T_H = 0 + Linux = 1 + Unix = 1 +) + +// A null pointer constant. + +// XPG requires a few symbols from being defined. +// Definitions of flag bits for `waitpid' et al. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bits in the third argument to `waitpid'. + +// Bits in the fourth argument to `waitid'. + +// The following values are used by the `waitid' function. + +// The Linux kernel defines these bare, rather than an enum, +// which causes a conflict if the include order is reversed. + +const ( /* waitflags.h:52:1: */ + P_ALL = 0 // Wait for any child. + P_PID = 1 // Wait for specified process. + P_PGID = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// A null pointer constant. + +// XPG requires a few symbols from being defined. +// Definitions of flag bits for `waitpid' et al. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bits in the third argument to `waitpid'. + +// Bits in the fourth argument to `waitid'. + +// The following values are used by the `waitid' function. + +// The Linux kernel defines these bare, rather than an enum, +// which causes a conflict if the include order is reversed. + +type Idtype_t = uint32 /* waitflags.h:57:3 */ +// Definitions of status bits for `wait' et al. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Everything extant so far uses these same bits. + +// If WIFEXITED(STATUS), the low-order 8 bits of the status. + +// If WIFSIGNALED(STATUS), the terminating signal. + +// If WIFSTOPPED(STATUS), the signal that stopped the child. + +// Nonzero if STATUS indicates normal termination. + +// Nonzero if STATUS indicates termination by a signal. + +// Nonzero if STATUS indicates the child is stopped. + +// Nonzero if STATUS indicates the child continued after a stop. We only +// define this if provides the WCONTINUED flag bit. + +// Nonzero if STATUS indicates the child dumped core. + +// Macros for constructing status values. + +// Define the macros also would define this way. + +// _FloatN API tests for enablement. +// Macros to control TS 18661-3 glibc features on ldbl-128 platforms. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// Defined to 1 if the current compiler invocation provides a +// floating-point type with the IEEE 754 binary128 format, and this +// glibc includes corresponding *f128 interfaces for it. + +// Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct +// from the default float, double and long double types in this glibc. + +// Defined to 1 if the current compiler invocation provides a +// floating-point type with the right format for _Float64x, and this +// glibc includes corresponding *f64x interfaces for it. + +// Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format +// of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has +// the format of _Float128, which must be different from that of long +// double. + +// Defined to concatenate the literal suffix to be used with _Float128 +// types, if __HAVE_FLOAT128 is 1. + +// Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. + +// The remaining of this file provides support for older compilers. + +// The type _Float128 exists only since GCC 7.0. + +// Various built-in functions do not exist before GCC 7.0. + +// Macros to control TS 18661-3 glibc features where the same +// definitions are appropriate for all platforms. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// This header should be included at the bottom of each bits/floatn.h. +// It defines the following macros for each _FloatN and _FloatNx type, +// where the same definitions, or definitions based only on the macros +// in bits/floatn.h, are appropriate for all glibc configurations. + +// Defined to 1 if the current compiler invocation provides a +// floating-point type with the right format for this type, and this +// glibc includes corresponding *fN or *fNx interfaces for it. + +// Defined to 1 if the corresponding __HAVE_ macro is 1 and the +// type is the first with its format in the sequence of (the default +// choices for) float, double, long double, _Float16, _Float32, +// _Float64, _Float128, _Float32x, _Float64x, _Float128x for this +// glibc; that is, if functions present once per floating-point format +// rather than once per type are present for this type. +// +// All configurations supported by glibc have _Float32 the same format +// as float, _Float64 and _Float32x the same format as double, the +// _Float64x the same format as either long double or _Float128. No +// configurations support _Float128x or, as of GCC 7, have compiler +// support for a type meeting the requirements for _Float128x. + +// Defined to 1 if the corresponding _FloatN type is not binary compatible +// with the corresponding ISO C type in the current compilation unit as +// opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built +// in glibc. + +// Defined to 1 if any _FloatN or _FloatNx types that are not +// ABI-distinct are however distinct types at the C language level (so +// for the purposes of __builtin_types_compatible_p and _Generic). + +// Defined to concatenate the literal suffix to be used with _FloatN +// or _FloatNx types, if __HAVE_ is 1. The corresponding +// literal suffixes exist since GCC 7, for C only. + +// Defined to a complex type if __HAVE_ is 1. + +// The remaining of this file provides support for older compilers. + +// If double, long double and _Float64 all have the same set of +// values, TS 18661-3 requires the usual arithmetic conversions on +// long double and _Float64 to produce _Float64. For this to be the +// case when building with a compiler without a distinct _Float64 +// type, _Float64 must be a typedef for long double, not for +// double. + +// Returned by `div'. +type Div_t = struct { + Fquot int32 + Frem int32 +} /* stdlib.h:62:5 */ + +// Returned by `ldiv'. +type Ldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:70:5 */ + +// Returned by `lldiv'. +type Lldiv_t = struct { + Fquot int64 + Frem int64 +} /* stdlib.h:80:5 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We don't use `memset' because this would require a prototype and +// the array isn't too big. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +// Reentrant versions of the `random' family of functions. +// These functions all use the following data structure to contain +// state, rather than global state variables. + +type Random_data = struct { + Ffptr uintptr + Frptr uintptr + Fstate uintptr + Frand_type int32 + Frand_deg int32 + Frand_sep int32 + F__ccgo_pad1 [4]byte + Fend_ptr uintptr +} /* stdlib.h:423:1 */ + +// Data structure for communication with thread safe versions. This +// +// type is to be regarded as opaque. It's only exported because users +// have to allocate objects of this type. +type Drand48_data = struct { + F__x [3]uint16 + F__old_x [3]uint16 + F__c uint16 + F__init uint16 + F__a uint64 +} /* stdlib.h:490:1 */ + +// Shorthand for type of comparison functions. +type X__compar_fn_t = uintptr /* stdlib.h:808:13 */ + +// Floating-point inline functions for stdlib.h. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define some macros helping to catch buffer overflows. + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/straceoff.go b/internal/libc/straceoff.go new file mode 100644 index 0000000..da5a6a2 --- /dev/null +++ b/internal/libc/straceoff.go @@ -0,0 +1,10 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !libc.strace +// +build !libc.strace + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +const __ccgo_strace = false diff --git a/internal/libc/sync.go b/internal/libc/sync.go new file mode 100644 index 0000000..ead829f --- /dev/null +++ b/internal/libc/sync.go @@ -0,0 +1,22 @@ +// Copyright 2021 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "sync/atomic" +) + +var __sync_synchronize_dummy int32 + +// __sync_synchronize(); +func X__sync_synchronize(t *TLS) { + if __ccgo_strace { + trc("t=%v, (%v:)", t, origin(2)) + } + // Attempt to implement a full memory barrier without assembler. + atomic.StoreInt32(&__sync_synchronize_dummy, atomic.LoadInt32(&__sync_synchronize_dummy)+1) +} diff --git a/internal/libc/sys/socket/capi_darwin_amd64.go b/internal/libc/sys/socket/capi_darwin_amd64.go new file mode 100644 index 0000000..4cfd69b --- /dev/null +++ b/internal/libc/sys/socket/capi_darwin_amd64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo sys/socket/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/socket/socket_darwin_amd64.go -pkgname socket', DO NOT EDIT. + +package socket + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/sys/socket/capi_darwin_arm64.go b/internal/libc/sys/socket/capi_darwin_arm64.go new file mode 100644 index 0000000..3bc6f25 --- /dev/null +++ b/internal/libc/sys/socket/capi_darwin_arm64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo sys/socket/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/socket/socket_darwin_arm64.go -pkgname socket', DO NOT EDIT. + +package socket + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/sys/socket/capi_linux_amd64.go b/internal/libc/sys/socket/capi_linux_amd64.go new file mode 100644 index 0000000..41ea29c --- /dev/null +++ b/internal/libc/sys/socket/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo sys/socket/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/socket/socket_linux_amd64.go -pkgname socket', DO NOT EDIT. + +package socket + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/sys/socket/capi_linux_arm64.go b/internal/libc/sys/socket/capi_linux_arm64.go new file mode 100644 index 0000000..0464f88 --- /dev/null +++ b/internal/libc/sys/socket/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo sys/socket/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o sys/socket/socket_linux_arm64.go -pkgname socket', DO NOT EDIT. + +package socket + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/sys/socket/socket_darwin_amd64.go b/internal/libc/sys/socket/socket_darwin_amd64.go new file mode 100644 index 0000000..318627b --- /dev/null +++ b/internal/libc/sys/socket/socket_darwin_amd64.go @@ -0,0 +1,5022 @@ +// Code generated by 'ccgo sys/socket/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/socket/socket_darwin_amd64.go -pkgname socket', DO NOT EDIT. + +package socket + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_APPLETALK = 16 // socket.h:375:1: + AF_CCITT = 10 // socket.h:369:1: + AF_CHAOS = 5 // socket.h:363:1: + AF_CNT = 21 // socket.h:380:1: + AF_COIP = 20 // socket.h:379:1: + AF_DATAKIT = 9 // socket.h:368:1: + AF_DECnet = 12 // socket.h:371:1: + AF_DLI = 13 // socket.h:372:1: + AF_E164 = 28 // socket.h:387:1: + AF_ECMA = 8 // socket.h:367:1: + AF_HYLINK = 15 // socket.h:374:1: + AF_IEEE80211 = 37 // socket.h:399:1: + AF_IMPLINK = 3 // socket.h:361:1: + AF_INET = 2 // socket.h:359:1: + AF_INET6 = 30 // socket.h:390:1: + AF_IPX = 23 // socket.h:382:1: + AF_ISDN = 28 // socket.h:386:1: + AF_ISO = 7 // socket.h:365:1: + AF_LAT = 14 // socket.h:373:1: + AF_LINK = 18 // socket.h:377:1: + AF_LOCAL = 1 // socket.h:357:1: + AF_MAX = 40 // socket.h:401:1: + AF_NATM = 31 // socket.h:392:1: + AF_NDRV = 27 // socket.h:385:1: + AF_NETBIOS = 33 // socket.h:394:1: + AF_NS = 6 // socket.h:364:1: + AF_OSI = 7 // socket.h:366:1: + AF_PPP = 34 // socket.h:395:1: + AF_PUP = 4 // socket.h:362:1: + AF_RESERVED_36 = 36 // socket.h:398:1: + AF_ROUTE = 17 // socket.h:376:1: + AF_SIP = 24 // socket.h:383:1: + AF_SNA = 11 // socket.h:370:1: + AF_SYSTEM = 32 // socket.h:393:1: + AF_UNIX = 1 // socket.h:355:1: + AF_UNSPEC = 0 // socket.h:354:1: + AF_UTUN = 38 // socket.h:400:1: + BIG_ENDIAN = 4321 // endian.h:94:1: + BYTE_ORDER = 1234 // endian.h:97:1: + CONNECT_DATA_AUTHENTICATED = 0x4 // socket.h:300:1: + CONNECT_DATA_IDEMPOTENT = 0x2 // socket.h:299:1: + CONNECT_RESUME_ON_READ_WRITE = 0x1 // socket.h:298:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + KEV_DL_ADDMULTI = 7 // net_kev.h:61:1: + KEV_DL_AWDL_RESTRICTED = 26 // net_kev.h:80:1: + KEV_DL_AWDL_UNRESTRICTED = 27 // net_kev.h:81:1: + KEV_DL_DELMULTI = 8 // net_kev.h:62:1: + KEV_DL_IFCAP_CHANGED = 19 // net_kev.h:73:1: + KEV_DL_IFDELEGATE_CHANGED = 25 // net_kev.h:79:1: + KEV_DL_IF_ATTACHED = 9 // net_kev.h:63:1: + KEV_DL_IF_DETACHED = 11 // net_kev.h:65:1: + KEV_DL_IF_DETACHING = 10 // net_kev.h:64:1: + KEV_DL_IF_IDLE_ROUTE_REFCNT = 18 // net_kev.h:72:1: + KEV_DL_ISSUES = 24 // net_kev.h:78:1: + KEV_DL_LINK_ADDRESS_CHANGED = 16 // net_kev.h:70:1: + KEV_DL_LINK_OFF = 12 // net_kev.h:66:1: + KEV_DL_LINK_ON = 13 // net_kev.h:67:1: + KEV_DL_LINK_QUALITY_METRIC_CHANGED = 20 // net_kev.h:74:1: + KEV_DL_LOW_POWER_MODE_CHANGED = 30 // net_kev.h:84:1: + KEV_DL_MASTER_ELECTED = 23 // net_kev.h:77:1: + KEV_DL_NODE_ABSENCE = 22 // net_kev.h:76:1: + KEV_DL_NODE_PRESENCE = 21 // net_kev.h:75:1: + KEV_DL_PROTO_ATTACHED = 14 // net_kev.h:68:1: + KEV_DL_PROTO_DETACHED = 15 // net_kev.h:69:1: + KEV_DL_QOS_MODE_CHANGED = 29 // net_kev.h:83:1: + KEV_DL_RRC_STATE_CHANGED = 28 // net_kev.h:82:1: + KEV_DL_SIFFLAGS = 1 // net_kev.h:55:1: + KEV_DL_SIFGENERIC = 6 // net_kev.h:60:1: + KEV_DL_SIFMEDIA = 5 // net_kev.h:59:1: + KEV_DL_SIFMETRICS = 2 // net_kev.h:56:1: + KEV_DL_SIFMTU = 3 // net_kev.h:57:1: + KEV_DL_SIFPHYS = 4 // net_kev.h:58:1: + KEV_DL_SUBCLASS = 2 // net_kev.h:50:1: + KEV_DL_WAKEFLAGS_CHANGED = 17 // net_kev.h:71:1: + KEV_INET6_ADDR_DELETED = 3 // net_kev.h:91:1: + KEV_INET6_CHANGED_ADDR = 2 // net_kev.h:90:1: + KEV_INET6_DEFROUTER = 6 // net_kev.h:94:1: + KEV_INET6_NEW_LL_ADDR = 4 // net_kev.h:92:1: + KEV_INET6_NEW_RTADV_ADDR = 5 // net_kev.h:93:1: + KEV_INET6_NEW_USER_ADDR = 1 // net_kev.h:89:1: + KEV_INET6_REQUEST_NAT64_PREFIX = 7 // net_kev.h:95:1: + KEV_INET6_SUBCLASS = 6 // net_kev.h:87:1: + KEV_INET_ADDR_DELETED = 3 // net_kev.h:39:1: + KEV_INET_ARPCOLLISION = 7 // net_kev.h:43:1: + KEV_INET_ARPRTRALIVE = 10 // net_kev.h:48:1: + KEV_INET_ARPRTRFAILURE = 9 // net_kev.h:47:1: + KEV_INET_CHANGED_ADDR = 2 // net_kev.h:38:1: + KEV_INET_NEW_ADDR = 1 // net_kev.h:37:1: + KEV_INET_PORTINUSE = 8 // net_kev.h:45:1: + KEV_INET_SIFBRDADDR = 5 // net_kev.h:41:1: + KEV_INET_SIFDSTADDR = 4 // net_kev.h:40:1: + KEV_INET_SIFNETMASK = 6 // net_kev.h:42:1: + KEV_INET_SUBCLASS = 1 // net_kev.h:35:1: + LITTLE_ENDIAN = 1234 // endian.h:93:1: + MSG_CTRUNC = 0x20 // socket.h:563:1: + MSG_DONTROUTE = 0x4 // socket.h:560:1: + MSG_DONTWAIT = 0x80 // socket.h:566:1: + MSG_EOF = 0x100 // socket.h:567:1: + MSG_EOR = 0x8 // socket.h:561:1: + MSG_FLUSH = 0x400 // socket.h:572:1: + MSG_HAVEMORE = 0x2000 // socket.h:575:1: + MSG_HOLD = 0x800 // socket.h:573:1: + MSG_NEEDSA = 0x10000 // socket.h:578:1: + MSG_OOB = 0x1 // socket.h:558:1: + MSG_PEEK = 0x2 // socket.h:559:1: + MSG_RCVMORE = 0x4000 // socket.h:576:1: + MSG_SEND = 0x1000 // socket.h:574:1: + MSG_TRUNC = 0x10 // socket.h:562:1: + MSG_WAITALL = 0x40 // socket.h:564:1: + MSG_WAITSTREAM = 0x200 // socket.h:570:1: + NBBY = 8 // types.h:186:1: + NETSVC_MRKNG_LVL_L2 = 1 // socket.h:283:1: + NETSVC_MRKNG_LVL_L3L2_ALL = 2 // socket.h:284:1: + NETSVC_MRKNG_LVL_L3L2_BK = 3 // socket.h:285:1: + NETSVC_MRKNG_UNKNOWN = 0 // socket.h:282:1: + NET_MAXID = 40 // socket.h:506:1: + NET_RT_DUMP = 1 // socket.h:519:1: + NET_RT_DUMP2 = 7 // socket.h:525:1: + NET_RT_FLAGS = 2 // socket.h:520:1: + NET_RT_FLAGS_PRIV = 10 // socket.h:530:1: + NET_RT_IFLIST = 3 // socket.h:521:1: + NET_RT_IFLIST2 = 6 // socket.h:524:1: + NET_RT_MAXID = 11 // socket.h:531:1: + NET_RT_STAT = 4 // socket.h:522:1: + NET_RT_TRASH = 5 // socket.h:523:1: + NET_SERVICE_TYPE_AV = 6 // socket.h:276:1: + NET_SERVICE_TYPE_BE = 0 // socket.h:270:1: + NET_SERVICE_TYPE_BK = 1 // socket.h:271:1: + NET_SERVICE_TYPE_OAM = 7 // socket.h:277:1: + NET_SERVICE_TYPE_RD = 8 // socket.h:278:1: + NET_SERVICE_TYPE_RV = 5 // socket.h:275:1: + NET_SERVICE_TYPE_SIG = 2 // socket.h:272:1: + NET_SERVICE_TYPE_VI = 3 // socket.h:273:1: + NET_SERVICE_TYPE_VO = 4 // socket.h:274:1: + PDP_ENDIAN = 3412 // endian.h:95:1: + PF_APPLETALK = 16 // socket.h:469:1: + PF_CCITT = 10 // socket.h:463:1: + PF_CHAOS = 5 // socket.h:457:1: + PF_CNT = 21 // socket.h:474:1: + PF_COIP = 20 // socket.h:473:1: + PF_DATAKIT = 9 // socket.h:462:1: + PF_DECnet = 12 // socket.h:465:1: + PF_DLI = 13 // socket.h:466:1: + PF_ECMA = 8 // socket.h:461:1: + PF_HYLINK = 15 // socket.h:468:1: + PF_IMPLINK = 3 // socket.h:455:1: + PF_INET = 2 // socket.h:454:1: + PF_INET6 = 30 // socket.h:482:1: + PF_IPX = 23 // socket.h:476:1: + PF_ISDN = 28 // socket.h:480:1: + PF_ISO = 7 // socket.h:459:1: + PF_KEY = 29 // socket.h:481:1: + PF_LAT = 14 // socket.h:467:1: + PF_LINK = 18 // socket.h:471:1: + PF_LOCAL = 1 // socket.h:452:1: + PF_MAX = 40 // socket.h:489:1: + PF_NATM = 31 // socket.h:483:1: + PF_NDRV = 27 // socket.h:479:1: + PF_NETBIOS = 33 // socket.h:485:1: + PF_NS = 6 // socket.h:458:1: + PF_OSI = 7 // socket.h:460:1: + PF_PIP = 25 // socket.h:478:1: + PF_PPP = 34 // socket.h:486:1: + PF_PUP = 4 // socket.h:456:1: + PF_RESERVED_36 = 36 // socket.h:487:1: + PF_ROUTE = 17 // socket.h:470:1: + PF_RTIP = 22 // socket.h:477:1: + PF_SIP = 24 // socket.h:475:1: + PF_SNA = 11 // socket.h:464:1: + PF_SYSTEM = 32 // socket.h:484:1: + PF_UNIX = 1 // socket.h:453:1: + PF_UNSPEC = 0 // socket.h:451:1: + PF_UTUN = 38 // socket.h:488:1: + PF_XTP = 19 // socket.h:472:1: + SAE_ASSOCID_ANY = 0 // socket.h:290:1: + SAE_CONNID_ANY = 0 // socket.h:294:1: + SCM_CREDS = 0x03 // socket.h:661:1: + SCM_RIGHTS = 0x01 // socket.h:658:1: + SCM_TIMESTAMP = 0x02 // socket.h:660:1: + SCM_TIMESTAMP_MONOTONIC = 0x04 // socket.h:662:1: + SHUT_RD = 0 // socket.h:670:1: + SHUT_RDWR = 2 // socket.h:672:1: + SHUT_WR = 1 // socket.h:671:1: + SOCK_DGRAM = 2 // socket.h:112:1: + SOCK_MAXADDRLEN = 255 // socket.h:414:1: + SOCK_RAW = 3 // socket.h:113:1: + SOCK_RDM = 4 // socket.h:115:1: + SOCK_SEQPACKET = 5 // socket.h:117:1: + SOCK_STREAM = 1 // socket.h:111:1: + SOL_SOCKET = 0xffff // socket.h:348:1: + SOMAXCONN = 128 // socket.h:540:1: + SONPX_SETOPTSHUT = 0x000000001 // socket.h:338:1: + SO_ACCEPTCONN = 0x0002 // socket.h:123:1: + SO_BROADCAST = 0x0020 // socket.h:127:1: + SO_DEBUG = 0x0001 // socket.h:122:1: + SO_DONTROUTE = 0x0010 // socket.h:126:1: + SO_DONTTRUNC = 0x2000 // socket.h:142:1: + SO_ERROR = 0x1007 // socket.h:160:1: + SO_KEEPALIVE = 0x0008 // socket.h:125:1: + SO_LABEL = 0x1010 // socket.h:163:1: + SO_LINGER = 0x0080 // socket.h:130:1: + SO_LINGER_SEC = 0x1080 // socket.h:176:1: + SO_NETSVC_MARKING_LEVEL = 0x1119 // socket.h:185:1: + SO_NET_SERVICE_TYPE = 0x1116 // socket.h:182:1: + SO_NKE = 0x1021 // socket.h:167:1: + SO_NOADDRERR = 0x1023 // socket.h:169:1: + SO_NOSIGPIPE = 0x1022 // socket.h:168:1: + SO_NOTIFYCONFLICT = 0x1026 // socket.h:173:1: + SO_NP_EXTENSIONS = 0x1083 // socket.h:178:1: + SO_NREAD = 0x1020 // socket.h:166:1: + SO_NUMRCVPKT = 0x1112 // socket.h:181:1: + SO_NWRITE = 0x1024 // socket.h:170:1: + SO_OOBINLINE = 0x0100 // socket.h:134:1: + SO_PEERLABEL = 0x1011 // socket.h:164:1: + SO_RANDOMPORT = 0x1082 // socket.h:177:1: + SO_RCVBUF = 0x1002 // socket.h:155:1: + SO_RCVLOWAT = 0x1004 // socket.h:157:1: + SO_RCVTIMEO = 0x1006 // socket.h:159:1: + SO_REUSEADDR = 0x0004 // socket.h:124:1: + SO_REUSEPORT = 0x0200 // socket.h:136:1: + SO_REUSESHAREUID = 0x1025 // socket.h:171:1: + SO_SNDBUF = 0x1001 // socket.h:154:1: + SO_SNDLOWAT = 0x1003 // socket.h:156:1: + SO_SNDTIMEO = 0x1005 // socket.h:158:1: + SO_TIMESTAMP = 0x0400 // socket.h:137:1: + SO_TIMESTAMP_MONOTONIC = 0x0800 // socket.h:138:1: + SO_TYPE = 0x1008 // socket.h:161:1: + SO_UPCALLCLOSEWAIT = 0x1027 // socket.h:174:1: + SO_USELOOPBACK = 0x0040 // socket.h:129:1: + SO_WANTMORE = 0x4000 // socket.h:144:1: + SO_WANTOOBFLAG = 0x8000 // socket.h:145:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_I386__ENDIAN_H_ = 0 // endian.h:67:1: + X_I386__PARAM_H_ = 0 // _param.h:30:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NET_NETKEV_H_ = 0 // net_kev.h:30:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS__OSBYTEORDERI386_H = 0 // _OSByteOrder.h:30:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:78:1: + X_QUAD_LOWWORD = 0 // endian.h:79:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SA_FAMILY_T = 0 // _sa_family_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SOCKLEN_T = 0 // _socklen_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SS_MAXSIZE = 128 // socket.h:429:1: + X_STRUCT_IOVEC = 0 // _iovec_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_SOCKET_H_ = 0 // socket.h:73:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: + Pseudo_AF_HDRCMPLT = 35 // socket.h:396:1: + Pseudo_AF_KEY = 29 // socket.h:388:1: + Pseudo_AF_PIP = 25 // socket.h:384:1: + Pseudo_AF_RTIP = 22 // socket.h:381:1: + Pseudo_AF_XTP = 19 // socket.h:378:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2019 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1985, 1986, 1988, 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. +// +// @(#)socket.h 8.4 (Berkeley) 2/21/94 +// $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $ +// NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce +// support for mandatory and extensible security protections. This notice +// is included in support of clause 2.2 (b) of the Apple Public License, +// Version 2.0. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1991, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)types.h 8.4 (Berkeley) 1/21/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Machine type dependent parameters. +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2008 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Round p (pointer or byte index) up to a correctly-aligned value for all +// data types (int, long, ...). The result is unsigned int and must be +// cast to any desired pointer type. + +// Copyright (c) 2016-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Kernel event subclass identifiers for KEV_NETWORK_CLASS +// KEV_INET_SUBCLASS event codes + +// Define Data-Link event subclass, and associated +// events. + +// KEV_INET6_SUBCLASS event codes + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Definitions related to sockets: types, address families, options. + +// Data types. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Sa_family_t = X__uint8_t /* _sa_family_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Socklen_t = X__darwin_socklen_t /* _socklen_t.h:31:33 */ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The iovec structure shall be defined as described in . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* _iovec_t.h:31:1 */ + +// Types + +// Option flags per-socket. +// (ATOMIC proto) + +// Additional options, not kept in so_options. + +// Network Service Type for option SO_NET_SERVICE_TYPE +// +// The vast majority of sockets should use Best Effort that is the default +// Network Service Type. Other Network Service Types have to be used only if +// the traffic actually matches the description of the Network Service Type. +// +// Network Service Types do not represent priorities but rather describe +// different categories of delay, jitter and loss parameters. +// Those parameters may influence protocols from layer 4 protocols like TCP +// to layer 2 protocols like Wi-Fi. The Network Service Type can determine +// how the traffic is queued and scheduled by the host networking stack and +// by other entities on the network like switches and routers. For example +// for Wi-Fi, the Network Service Type can select the marking of the +// layer 2 packet with the appropriate WMM Access Category. +// +// There is no point in attempting to game the system and use +// a Network Service Type that does not correspond to the actual +// traffic characteristic but one that seems to have a higher precedence. +// The reason is that for service classes that have lower tolerance +// for delay and jitter, the queues size is lower than for service +// classes that are more tolerant to delay and jitter. +// +// For example using a voice service type for bulk data transfer will lead +// to disastrous results as soon as congestion happens because the voice +// queue overflows and packets get dropped. This is not only bad for the bulk +// data transfer but it is also bad for VoIP apps that legitimately are using +// the voice service type. +// +// The characteristics of the Network Service Types are based on the service +// classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service +// Classes" +// +// When system detects the outgoing interface belongs to a DiffServ domain +// that follows the recommendation of the IETF draft "Guidelines for DiffServ to +// IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value +// that corresponds to Network Service Type. +// +// NET_SERVICE_TYPE_BE +// "Best Effort", unclassified/standard. This is the default service +// class and cover the majority of the traffic. +// +// NET_SERVICE_TYPE_BK +// "Background", high delay tolerant, loss tolerant. elastic flow, +// variable size & long-lived. E.g: non-interactive network bulk transfer +// like synching or backup. +// +// NET_SERVICE_TYPE_RD +// "Responsive Data", a notch higher than "Best Effort", medium delay +// tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, +// instant messaging, for which there is a sense of interactivity and +// urgency (user waiting for output). +// +// NET_SERVICE_TYPE_OAM +// "Operations, Administration, and Management", medium delay tolerant, +// low-medium loss tolerant, elastic & inelastic flows, variable size. +// E.g. VPN tunnels. +// +// NET_SERVICE_TYPE_AV +// "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium +// loss tolerant, elastic flow, constant packet interval, variable rate +// and size. E.g. video and audio playback with buffering. +// +// NET_SERVICE_TYPE_RV +// "Responsive Multimedia Audio/Video", low delay tolerant, low-medium +// loss tolerant, elastic flow, variable packet interval, rate and size. +// E.g. screen sharing. +// +// NET_SERVICE_TYPE_VI +// "Interactive Video", low delay tolerant, low-medium loss tolerant, +// elastic flow, constant packet interval, variable rate & size. E.g. +// video telephony. +// +// NET_SERVICE_TYPE_SIG +// "Signaling", low delay tolerant, low loss tolerant, inelastic flow, +// jitter tolerant, rate is bursty but short, variable size. E.g. SIP. +// +// NET_SERVICE_TYPE_VO +// "Interactive Voice", very low delay tolerant, very low loss tolerant, +// inelastic flow, constant packet rate, somewhat fixed size. +// E.g. VoIP. + +// These are supported values for SO_NETSVC_MARKING_LEVEL + +type Sae_associd_t = X__uint32_t /* socket.h:289:20 */ + +type Sae_connid_t = X__uint32_t /* socket.h:293:20 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints = struct { + Fsae_srcif uint32 + F__ccgo_pad1 [4]byte + Fsae_srcaddr uintptr + Fsae_srcaddrlen Socklen_t + F__ccgo_pad2 [4]byte + Fsae_dstaddr uintptr + Fsae_dstaddrlen Socklen_t + F__ccgo_pad3 [4]byte +} /* socket.h:303:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sockaddr = struct { + Fsa_len X__uint8_t + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:303:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints_t = Sa_endpoints /* socket.h:309:3 */ + +// Structure used for manipulating linger option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:315:1 */ + +// Structure to control non-portable Sockets extension to POSIX +type So_np_extensions = struct { + Fnpx_flags U_int32_t + Fnpx_mask U_int32_t +} /* socket.h:333:1 */ + +// Structure used by kernel to pass protocol +// information in raw sockets. +type Sockproto = struct { + Fsp_family X__uint16_t + Fsp_protocol X__uint16_t +} /* socket.h:420:1 */ + +// RFC 2553: protocol-independent placeholder for socket addresses + +// [XSI] sockaddr_storage +type Sockaddr_storage = struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 +} /* socket.h:440:1 */ + +// Protocol families, same as address families for now. + +// These do not have socket-layer support: + +// Definitions for network related sysctl, CTL_NET. +// +// Second level is protocol family. +// Third level is protocol number. +// +// Further levels are defined by the individual families below. + +// PF_ROUTE - Routing table +// +// Three additional levels are defined: +// Fourth: address family, 0 is wildcard +// Fifth: type of info, defined below +// Sixth: flag(s) to mask with for NET_RT_FLAGS +// Allows read access non-local host's MAC address +// if the process has neighbor cache entitlement. + +// Maximum queue length specifiable by listen. + +// [XSI] Message header for recvmsg and sendmsg calls. +// Used value-result for recvmsg, value only for sendmsg. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__ccgo_pad2 [4]byte + Fmsg_control uintptr + Fmsg_controllen Socklen_t + Fmsg_flags int32 +} /* socket.h:546:1 */ + +// Header for ancillary data objects in msg_control buffer. +// Used for additional information with/about a datagram +// not expressible by flags. The format is a sequence +// of message elements headed by cmsghdr structures. +type Cmsghdr = struct { + Fcmsg_len Socklen_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:587:1 */ + +// given pointer to struct cmsghdr, return pointer to data + +// RFC 2292 requires to check msg_controllen, in case that the kernel returns +// an empty list for some reasons. + +// Given pointer to struct cmsghdr, return pointer to next cmsghdr +// RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) + +// RFC 2292 additions + +// "Socket"-level control message types: + +// howto arguments for shutdown(2), specified by Posix.1g. + +// sendfile(2) header/trailer struct +type Sf_hdtr = struct { + Fheaders uintptr + Fhdr_cnt int32 + F__ccgo_pad1 [4]byte + Ftrailers uintptr + Ftrl_cnt int32 + F__ccgo_pad2 [4]byte +} /* socket.h:678:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/socket/socket_darwin_arm64.go b/internal/libc/sys/socket/socket_darwin_arm64.go new file mode 100644 index 0000000..754a638 --- /dev/null +++ b/internal/libc/sys/socket/socket_darwin_arm64.go @@ -0,0 +1,5111 @@ +// Code generated by 'ccgo sys/socket/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/socket/socket_darwin_arm64.go -pkgname socket', DO NOT EDIT. + +package socket + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_APPLETALK = 16 // socket.h:379:1: + AF_CCITT = 10 // socket.h:373:1: + AF_CHAOS = 5 // socket.h:367:1: + AF_CNT = 21 // socket.h:384:1: + AF_COIP = 20 // socket.h:383:1: + AF_DATAKIT = 9 // socket.h:372:1: + AF_DECnet = 12 // socket.h:375:1: + AF_DLI = 13 // socket.h:376:1: + AF_E164 = 28 // socket.h:391:1: + AF_ECMA = 8 // socket.h:371:1: + AF_HYLINK = 15 // socket.h:378:1: + AF_IEEE80211 = 37 // socket.h:403:1: + AF_IMPLINK = 3 // socket.h:365:1: + AF_INET = 2 // socket.h:363:1: + AF_INET6 = 30 // socket.h:394:1: + AF_IPX = 23 // socket.h:386:1: + AF_ISDN = 28 // socket.h:390:1: + AF_ISO = 7 // socket.h:369:1: + AF_LAT = 14 // socket.h:377:1: + AF_LINK = 18 // socket.h:381:1: + AF_LOCAL = 1 // socket.h:361:1: + AF_MAX = 41 // socket.h:406:1: + AF_NATM = 31 // socket.h:396:1: + AF_NDRV = 27 // socket.h:389:1: + AF_NETBIOS = 33 // socket.h:398:1: + AF_NS = 6 // socket.h:368:1: + AF_OSI = 7 // socket.h:370:1: + AF_PPP = 34 // socket.h:399:1: + AF_PUP = 4 // socket.h:366:1: + AF_RESERVED_36 = 36 // socket.h:402:1: + AF_ROUTE = 17 // socket.h:380:1: + AF_SIP = 24 // socket.h:387:1: + AF_SNA = 11 // socket.h:374:1: + AF_SYSTEM = 32 // socket.h:397:1: + AF_UNIX = 1 // socket.h:359:1: + AF_UNSPEC = 0 // socket.h:358:1: + AF_UTUN = 38 // socket.h:404:1: + AF_VSOCK = 40 // socket.h:405:1: + BIG_ENDIAN = 4321 // endian.h:72:1: + BYTE_ORDER = 1234 // endian.h:75:1: + CONNECT_DATA_AUTHENTICATED = 0x4 // socket.h:304:1: + CONNECT_DATA_IDEMPOTENT = 0x2 // socket.h:303:1: + CONNECT_RESUME_ON_READ_WRITE = 0x1 // socket.h:302:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + KEV_DL_ADDMULTI = 7 // net_kev.h:61:1: + KEV_DL_AWDL_RESTRICTED = 26 // net_kev.h:80:1: + KEV_DL_AWDL_UNRESTRICTED = 27 // net_kev.h:81:1: + KEV_DL_DELMULTI = 8 // net_kev.h:62:1: + KEV_DL_IFCAP_CHANGED = 19 // net_kev.h:73:1: + KEV_DL_IFDELEGATE_CHANGED = 25 // net_kev.h:79:1: + KEV_DL_IF_ATTACHED = 9 // net_kev.h:63:1: + KEV_DL_IF_DETACHED = 11 // net_kev.h:65:1: + KEV_DL_IF_DETACHING = 10 // net_kev.h:64:1: + KEV_DL_IF_IDLE_ROUTE_REFCNT = 18 // net_kev.h:72:1: + KEV_DL_ISSUES = 24 // net_kev.h:78:1: + KEV_DL_LINK_ADDRESS_CHANGED = 16 // net_kev.h:70:1: + KEV_DL_LINK_OFF = 12 // net_kev.h:66:1: + KEV_DL_LINK_ON = 13 // net_kev.h:67:1: + KEV_DL_LINK_QUALITY_METRIC_CHANGED = 20 // net_kev.h:74:1: + KEV_DL_LOW_POWER_MODE_CHANGED = 30 // net_kev.h:84:1: + KEV_DL_NODE_ABSENCE = 22 // net_kev.h:76:1: + KEV_DL_NODE_PRESENCE = 21 // net_kev.h:75:1: + KEV_DL_PRIMARY_ELECTED = 23 // net_kev.h:77:1: + KEV_DL_PROTO_ATTACHED = 14 // net_kev.h:68:1: + KEV_DL_PROTO_DETACHED = 15 // net_kev.h:69:1: + KEV_DL_QOS_MODE_CHANGED = 29 // net_kev.h:83:1: + KEV_DL_RRC_STATE_CHANGED = 28 // net_kev.h:82:1: + KEV_DL_SIFFLAGS = 1 // net_kev.h:55:1: + KEV_DL_SIFGENERIC = 6 // net_kev.h:60:1: + KEV_DL_SIFMEDIA = 5 // net_kev.h:59:1: + KEV_DL_SIFMETRICS = 2 // net_kev.h:56:1: + KEV_DL_SIFMTU = 3 // net_kev.h:57:1: + KEV_DL_SIFPHYS = 4 // net_kev.h:58:1: + KEV_DL_SUBCLASS = 2 // net_kev.h:50:1: + KEV_DL_WAKEFLAGS_CHANGED = 17 // net_kev.h:71:1: + KEV_INET6_ADDR_DELETED = 3 // net_kev.h:93:1: + KEV_INET6_CHANGED_ADDR = 2 // net_kev.h:92:1: + KEV_INET6_DEFROUTER = 6 // net_kev.h:96:1: + KEV_INET6_NEW_LL_ADDR = 4 // net_kev.h:94:1: + KEV_INET6_NEW_RTADV_ADDR = 5 // net_kev.h:95:1: + KEV_INET6_NEW_USER_ADDR = 1 // net_kev.h:91:1: + KEV_INET6_REQUEST_NAT64_PREFIX = 7 // net_kev.h:97:1: + KEV_INET6_SUBCLASS = 6 // net_kev.h:89:1: + KEV_INET_ADDR_DELETED = 3 // net_kev.h:39:1: + KEV_INET_ARPCOLLISION = 7 // net_kev.h:43:1: + KEV_INET_ARPRTRALIVE = 10 // net_kev.h:48:1: + KEV_INET_ARPRTRFAILURE = 9 // net_kev.h:47:1: + KEV_INET_CHANGED_ADDR = 2 // net_kev.h:38:1: + KEV_INET_NEW_ADDR = 1 // net_kev.h:37:1: + KEV_INET_PORTINUSE = 8 // net_kev.h:45:1: + KEV_INET_SIFBRDADDR = 5 // net_kev.h:41:1: + KEV_INET_SIFDSTADDR = 4 // net_kev.h:40:1: + KEV_INET_SIFNETMASK = 6 // net_kev.h:42:1: + KEV_INET_SUBCLASS = 1 // net_kev.h:35:1: + LITTLE_ENDIAN = 1234 // endian.h:71:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + MSG_CTRUNC = 0x20 // socket.h:569:1: + MSG_DONTROUTE = 0x4 // socket.h:566:1: + MSG_DONTWAIT = 0x80 // socket.h:572:1: + MSG_EOF = 0x100 // socket.h:573:1: + MSG_EOR = 0x8 // socket.h:567:1: + MSG_FLUSH = 0x400 // socket.h:578:1: + MSG_HAVEMORE = 0x2000 // socket.h:581:1: + MSG_HOLD = 0x800 // socket.h:579:1: + MSG_NEEDSA = 0x10000 // socket.h:584:1: + MSG_NOSIGNAL = 0x80000 // socket.h:588:1: + MSG_OOB = 0x1 // socket.h:564:1: + MSG_PEEK = 0x2 // socket.h:565:1: + MSG_RCVMORE = 0x4000 // socket.h:582:1: + MSG_SEND = 0x1000 // socket.h:580:1: + MSG_TRUNC = 0x10 // socket.h:568:1: + MSG_WAITALL = 0x40 // socket.h:570:1: + MSG_WAITSTREAM = 0x200 // socket.h:576:1: + NBBY = 8 // types.h:186:1: + NETSVC_MRKNG_LVL_L2 = 1 // socket.h:287:1: + NETSVC_MRKNG_LVL_L3L2_ALL = 2 // socket.h:288:1: + NETSVC_MRKNG_LVL_L3L2_BK = 3 // socket.h:289:1: + NETSVC_MRKNG_UNKNOWN = 0 // socket.h:286:1: + NET_MAXID = 41 // socket.h:512:1: + NET_RT_DUMP = 1 // socket.h:525:1: + NET_RT_DUMP2 = 7 // socket.h:531:1: + NET_RT_FLAGS = 2 // socket.h:526:1: + NET_RT_FLAGS_PRIV = 10 // socket.h:536:1: + NET_RT_IFLIST = 3 // socket.h:527:1: + NET_RT_IFLIST2 = 6 // socket.h:530:1: + NET_RT_MAXID = 11 // socket.h:537:1: + NET_RT_STAT = 4 // socket.h:528:1: + NET_RT_TRASH = 5 // socket.h:529:1: + NET_SERVICE_TYPE_AV = 6 // socket.h:280:1: + NET_SERVICE_TYPE_BE = 0 // socket.h:274:1: + NET_SERVICE_TYPE_BK = 1 // socket.h:275:1: + NET_SERVICE_TYPE_OAM = 7 // socket.h:281:1: + NET_SERVICE_TYPE_RD = 8 // socket.h:282:1: + NET_SERVICE_TYPE_RV = 5 // socket.h:279:1: + NET_SERVICE_TYPE_SIG = 2 // socket.h:276:1: + NET_SERVICE_TYPE_VI = 3 // socket.h:277:1: + NET_SERVICE_TYPE_VO = 4 // socket.h:278:1: + PDP_ENDIAN = 3412 // endian.h:73:1: + PF_APPLETALK = 16 // socket.h:474:1: + PF_CCITT = 10 // socket.h:468:1: + PF_CHAOS = 5 // socket.h:462:1: + PF_CNT = 21 // socket.h:479:1: + PF_COIP = 20 // socket.h:478:1: + PF_DATAKIT = 9 // socket.h:467:1: + PF_DECnet = 12 // socket.h:470:1: + PF_DLI = 13 // socket.h:471:1: + PF_ECMA = 8 // socket.h:466:1: + PF_HYLINK = 15 // socket.h:473:1: + PF_IMPLINK = 3 // socket.h:460:1: + PF_INET = 2 // socket.h:459:1: + PF_INET6 = 30 // socket.h:487:1: + PF_IPX = 23 // socket.h:481:1: + PF_ISDN = 28 // socket.h:485:1: + PF_ISO = 7 // socket.h:464:1: + PF_KEY = 29 // socket.h:486:1: + PF_LAT = 14 // socket.h:472:1: + PF_LINK = 18 // socket.h:476:1: + PF_LOCAL = 1 // socket.h:457:1: + PF_MAX = 41 // socket.h:495:1: + PF_NATM = 31 // socket.h:488:1: + PF_NDRV = 27 // socket.h:484:1: + PF_NETBIOS = 33 // socket.h:490:1: + PF_NS = 6 // socket.h:463:1: + PF_OSI = 7 // socket.h:465:1: + PF_PIP = 25 // socket.h:483:1: + PF_PPP = 34 // socket.h:491:1: + PF_PUP = 4 // socket.h:461:1: + PF_RESERVED_36 = 36 // socket.h:492:1: + PF_ROUTE = 17 // socket.h:475:1: + PF_RTIP = 22 // socket.h:482:1: + PF_SIP = 24 // socket.h:480:1: + PF_SNA = 11 // socket.h:469:1: + PF_SYSTEM = 32 // socket.h:489:1: + PF_UNIX = 1 // socket.h:458:1: + PF_UNSPEC = 0 // socket.h:456:1: + PF_UTUN = 38 // socket.h:493:1: + PF_VSOCK = 40 // socket.h:494:1: + PF_XTP = 19 // socket.h:477:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + RSIZE_MAX = 9223372036854775807 // stdint.h:658:1: + SAE_ASSOCID_ANY = 0 // socket.h:294:1: + SAE_CONNID_ANY = 0 // socket.h:298:1: + SCM_CREDS = 0x03 // socket.h:674:1: + SCM_RIGHTS = 0x01 // socket.h:671:1: + SCM_TIMESTAMP = 0x02 // socket.h:673:1: + SCM_TIMESTAMP_MONOTONIC = 0x04 // socket.h:675:1: + SHUT_RD = 0 // socket.h:683:1: + SHUT_RDWR = 2 // socket.h:685:1: + SHUT_WR = 1 // socket.h:684:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + SOCK_DGRAM = 2 // socket.h:113:1: + SOCK_MAXADDRLEN = 255 // socket.h:419:1: + SOCK_RAW = 3 // socket.h:114:1: + SOCK_RDM = 4 // socket.h:116:1: + SOCK_SEQPACKET = 5 // socket.h:118:1: + SOCK_STREAM = 1 // socket.h:112:1: + SOL_SOCKET = 0xffff // socket.h:352:1: + SOMAXCONN = 128 // socket.h:546:1: + SONPX_SETOPTSHUT = 0x000000001 // socket.h:342:1: + SO_ACCEPTCONN = 0x0002 // socket.h:124:1: + SO_BROADCAST = 0x0020 // socket.h:128:1: + SO_DEBUG = 0x0001 // socket.h:123:1: + SO_DONTROUTE = 0x0010 // socket.h:127:1: + SO_DONTTRUNC = 0x2000 // socket.h:143:1: + SO_ERROR = 0x1007 // socket.h:161:1: + SO_KEEPALIVE = 0x0008 // socket.h:126:1: + SO_LABEL = 0x1010 // socket.h:164:1: + SO_LINGER = 0x0080 // socket.h:131:1: + SO_LINGER_SEC = 0x1080 // socket.h:177:1: + SO_NETSVC_MARKING_LEVEL = 0x1119 // socket.h:186:1: + SO_NET_SERVICE_TYPE = 0x1116 // socket.h:183:1: + SO_NKE = 0x1021 // socket.h:168:1: + SO_NOADDRERR = 0x1023 // socket.h:170:1: + SO_NOSIGPIPE = 0x1022 // socket.h:169:1: + SO_NOTIFYCONFLICT = 0x1026 // socket.h:174:1: + SO_NP_EXTENSIONS = 0x1083 // socket.h:179:1: + SO_NREAD = 0x1020 // socket.h:167:1: + SO_NUMRCVPKT = 0x1112 // socket.h:182:1: + SO_NWRITE = 0x1024 // socket.h:171:1: + SO_OOBINLINE = 0x0100 // socket.h:135:1: + SO_PEERLABEL = 0x1011 // socket.h:165:1: + SO_RANDOMPORT = 0x1082 // socket.h:178:1: + SO_RCVBUF = 0x1002 // socket.h:156:1: + SO_RCVLOWAT = 0x1004 // socket.h:158:1: + SO_RCVTIMEO = 0x1006 // socket.h:160:1: + SO_REUSEADDR = 0x0004 // socket.h:125:1: + SO_REUSEPORT = 0x0200 // socket.h:137:1: + SO_REUSESHAREUID = 0x1025 // socket.h:172:1: + SO_SNDBUF = 0x1001 // socket.h:155:1: + SO_SNDLOWAT = 0x1003 // socket.h:157:1: + SO_SNDTIMEO = 0x1005 // socket.h:159:1: + SO_TIMESTAMP = 0x0400 // socket.h:138:1: + SO_TIMESTAMP_MONOTONIC = 0x0800 // socket.h:139:1: + SO_TYPE = 0x1008 // socket.h:162:1: + SO_UPCALLCLOSEWAIT = 0x1027 // socket.h:175:1: + SO_USELOOPBACK = 0x0040 // socket.h:130:1: + SO_WANTMORE = 0x4000 // socket.h:145:1: + SO_WANTOOBFLAG = 0x8000 // socket.h:146:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + X_ARM_ARCH_H = 0 // arch.h:29:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_ARM__ENDIAN_H_ = 0 // endian.h:43:1: + X_ARM__PARAM_H_ = 0 // _param.h:6:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__PARAM_H_ = 0 // _param.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NET_NETKEV_H_ = 0 // net_kev.h:30:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS_OSBYTEORDERARM_H = 0 // OSByteOrder.h:6:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:56:1: + X_QUAD_LOWWORD = 0 // endian.h:57:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SA_FAMILY_T = 0 // _sa_family_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SOCKLEN_T = 0 // _socklen_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SS_MAXSIZE = 128 // socket.h:434:1: + X_STRUCT_IOVEC = 0 // _iovec_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_SOCKET_H_ = 0 // socket.h:73:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: + Pseudo_AF_HDRCMPLT = 35 // socket.h:400:1: + Pseudo_AF_KEY = 29 // socket.h:392:1: + Pseudo_AF_PIP = 25 // socket.h:388:1: + Pseudo_AF_RTIP = 22 // socket.h:385:1: + Pseudo_AF_XTP = 19 // socket.h:382:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2019 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1985, 1986, 1988, 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. +// +// @(#)socket.h 8.4 (Berkeley) 2/21/94 +// $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $ +// NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce +// support for mandatory and extensible security protections. This notice +// is included in support of clause 2.2 (b) of the Apple Public License, +// Version 2.0. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1991, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)types.h 8.4 (Berkeley) 1/21/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Machine type dependent parameters. +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// Functions for byte reversed loads. + +type X_OSUnalignedU16 = struct{ F__val Uint16_t } /* OSByteOrder.h:64:1 */ + +type X_OSUnalignedU32 = struct{ F__val Uint32_t } /* OSByteOrder.h:68:1 */ + +type X_OSUnalignedU64 = struct{ F__val Uint64_t } /* OSByteOrder.h:72:1 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2006-2007 Apple Inc. All rights reserved. + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// Round p (pointer or byte index) up to a correctly-aligned value for all +// data types (int, long, ...). The result is unsigned int and must be +// cast to any desired pointer type. + +// Copyright (c) 2016-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Kernel event subclass identifiers for KEV_NETWORK_CLASS +// KEV_INET_SUBCLASS event codes + +// Define Data-Link event subclass, and associated +// events. + +// KEV_INET6_SUBCLASS event codes + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Definitions related to sockets: types, address families, options. + +// Data types. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Sa_family_t = X__uint8_t /* _sa_family_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Socklen_t = X__darwin_socklen_t /* _socklen_t.h:31:33 */ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// XXX Not explicitly defined by POSIX, but function return types are +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The iovec structure shall be defined as described in . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* _iovec_t.h:31:1 */ + +// Types + +// Option flags per-socket. +// (ATOMIC proto) + +// Additional options, not kept in so_options. + +// When adding new socket-options, you need to make sure MPTCP supports these as well! + +// Network Service Type for option SO_NET_SERVICE_TYPE +// +// The vast majority of sockets should use Best Effort that is the default +// Network Service Type. Other Network Service Types have to be used only if +// the traffic actually matches the description of the Network Service Type. +// +// Network Service Types do not represent priorities but rather describe +// different categories of delay, jitter and loss parameters. +// Those parameters may influence protocols from layer 4 protocols like TCP +// to layer 2 protocols like Wi-Fi. The Network Service Type can determine +// how the traffic is queued and scheduled by the host networking stack and +// by other entities on the network like switches and routers. For example +// for Wi-Fi, the Network Service Type can select the marking of the +// layer 2 packet with the appropriate WMM Access Category. +// +// There is no point in attempting to game the system and use +// a Network Service Type that does not correspond to the actual +// traffic characteristic but one that seems to have a higher precedence. +// The reason is that for service classes that have lower tolerance +// for delay and jitter, the queues size is lower than for service +// classes that are more tolerant to delay and jitter. +// +// For example using a voice service type for bulk data transfer will lead +// to disastrous results as soon as congestion happens because the voice +// queue overflows and packets get dropped. This is not only bad for the bulk +// data transfer but it is also bad for VoIP apps that legitimately are using +// the voice service type. +// +// The characteristics of the Network Service Types are based on the service +// classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service +// Classes" +// +// When system detects the outgoing interface belongs to a DiffServ domain +// that follows the recommendation of the IETF draft "Guidelines for DiffServ to +// IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value +// that corresponds to Network Service Type. +// +// NET_SERVICE_TYPE_BE +// "Best Effort", unclassified/standard. This is the default service +// class and cover the majority of the traffic. +// +// NET_SERVICE_TYPE_BK +// "Background", high delay tolerant, loss tolerant. elastic flow, +// variable size & long-lived. E.g: non-interactive network bulk transfer +// like synching or backup. +// +// NET_SERVICE_TYPE_RD +// "Responsive Data", a notch higher than "Best Effort", medium delay +// tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, +// instant messaging, for which there is a sense of interactivity and +// urgency (user waiting for output). +// +// NET_SERVICE_TYPE_OAM +// "Operations, Administration, and Management", medium delay tolerant, +// low-medium loss tolerant, elastic & inelastic flows, variable size. +// E.g. VPN tunnels. +// +// NET_SERVICE_TYPE_AV +// "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium +// loss tolerant, elastic flow, constant packet interval, variable rate +// and size. E.g. video and audio playback with buffering. +// +// NET_SERVICE_TYPE_RV +// "Responsive Multimedia Audio/Video", low delay tolerant, low-medium +// loss tolerant, elastic flow, variable packet interval, rate and size. +// E.g. screen sharing. +// +// NET_SERVICE_TYPE_VI +// "Interactive Video", low delay tolerant, low-medium loss tolerant, +// elastic flow, constant packet interval, variable rate & size. E.g. +// video telephony. +// +// NET_SERVICE_TYPE_SIG +// "Signaling", low delay tolerant, low loss tolerant, inelastic flow, +// jitter tolerant, rate is bursty but short, variable size. E.g. SIP. +// +// NET_SERVICE_TYPE_VO +// "Interactive Voice", very low delay tolerant, very low loss tolerant, +// inelastic flow, constant packet rate, somewhat fixed size. +// E.g. VoIP. + +// These are supported values for SO_NETSVC_MARKING_LEVEL + +type Sae_associd_t = X__uint32_t /* socket.h:293:20 */ + +type Sae_connid_t = X__uint32_t /* socket.h:297:20 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints = struct { + Fsae_srcif uint32 + F__ccgo_pad1 [4]byte + Fsae_srcaddr uintptr + Fsae_srcaddrlen Socklen_t + F__ccgo_pad2 [4]byte + Fsae_dstaddr uintptr + Fsae_dstaddrlen Socklen_t + F__ccgo_pad3 [4]byte +} /* socket.h:307:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sockaddr = struct { + Fsa_len X__uint8_t + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:307:9 */ + +// connectx() flag parameters + +// sockaddr endpoints +type Sa_endpoints_t = Sa_endpoints /* socket.h:313:3 */ + +// Structure used for manipulating linger option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:319:1 */ + +// Structure to control non-portable Sockets extension to POSIX +type So_np_extensions = struct { + Fnpx_flags U_int32_t + Fnpx_mask U_int32_t +} /* socket.h:337:1 */ + +// Structure used by kernel to pass protocol +// information in raw sockets. +type Sockproto = struct { + Fsp_family X__uint16_t + Fsp_protocol X__uint16_t +} /* socket.h:425:1 */ + +// RFC 2553: protocol-independent placeholder for socket addresses + +// [XSI] sockaddr_storage +type Sockaddr_storage = struct { + Fss_len X__uint8_t + Fss_family Sa_family_t + F__ss_pad1 [6]int8 + F__ss_align X__int64_t + F__ss_pad2 [112]int8 +} /* socket.h:445:1 */ + +// Protocol families, same as address families for now. + +// These do not have socket-layer support: + +// Definitions for network related sysctl, CTL_NET. +// +// Second level is protocol family. +// Third level is protocol number. +// +// Further levels are defined by the individual families below. + +// PF_ROUTE - Routing table +// +// Three additional levels are defined: +// Fourth: address family, 0 is wildcard +// Fifth: type of info, defined below +// Sixth: flag(s) to mask with for NET_RT_FLAGS +// Allows read access non-local host's MAC address +// if the process has neighbor cache entitlement. + +// Maximum queue length specifiable by listen. + +// [XSI] Message header for recvmsg and sendmsg calls. +// Used value-result for recvmsg, value only for sendmsg. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen int32 + F__ccgo_pad2 [4]byte + Fmsg_control uintptr + Fmsg_controllen Socklen_t + Fmsg_flags int32 +} /* socket.h:552:1 */ + +// Header for ancillary data objects in msg_control buffer. +// Used for additional information with/about a datagram +// not expressible by flags. The format is a sequence +// of message elements headed by cmsghdr structures. +type Cmsghdr = struct { + Fcmsg_len Socklen_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:600:1 */ + +// given pointer to struct cmsghdr, return pointer to data + +// RFC 2292 requires to check msg_controllen, in case that the kernel returns +// an empty list for some reasons. + +// Given pointer to struct cmsghdr, return pointer to next cmsghdr +// RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) + +// RFC 2292 additions + +// "Socket"-level control message types: + +// howto arguments for shutdown(2), specified by Posix.1g. + +// sendfile(2) header/trailer struct +type Sf_hdtr = struct { + Fheaders uintptr + Fhdr_cnt int32 + F__ccgo_pad1 [4]byte + Ftrailers uintptr + Ftrl_cnt int32 + F__ccgo_pad2 [4]byte +} /* socket.h:691:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/socket/socket_linux_amd64.go b/internal/libc/sys/socket/socket_linux_amd64.go new file mode 100644 index 0000000..f2c99ea --- /dev/null +++ b/internal/libc/sys/socket/socket_linux_amd64.go @@ -0,0 +1,1848 @@ +// Code generated by 'ccgo sys/socket/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/socket/socket_linux_amd64.go -pkgname socket', DO NOT EDIT. + +package socket + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_ALG = 38 // socket.h:133:1: + AF_APPLETALK = 5 // socket.h:99:1: + AF_ASH = 18 // socket.h:113:1: + AF_ATMPVC = 8 // socket.h:102:1: + AF_ATMSVC = 20 // socket.h:115:1: + AF_AX25 = 3 // socket.h:97:1: + AF_BLUETOOTH = 31 // socket.h:126:1: + AF_BRIDGE = 7 // socket.h:101:1: + AF_CAIF = 37 // socket.h:132:1: + AF_CAN = 29 // socket.h:124:1: + AF_DECnet = 12 // socket.h:106:1: + AF_ECONET = 19 // socket.h:114:1: + AF_FILE = 1 // socket.h:95:1: + AF_IB = 27 // socket.h:122:1: + AF_IEEE802154 = 36 // socket.h:131:1: + AF_INET = 2 // socket.h:96:1: + AF_INET6 = 10 // socket.h:104:1: + AF_IPX = 4 // socket.h:98:1: + AF_IRDA = 23 // socket.h:118:1: + AF_ISDN = 34 // socket.h:129:1: + AF_IUCV = 32 // socket.h:127:1: + AF_KCM = 41 // socket.h:136:1: + AF_KEY = 15 // socket.h:109:1: + AF_LLC = 26 // socket.h:121:1: + AF_LOCAL = 1 // socket.h:93:1: + AF_MAX = 45 // socket.h:140:1: + AF_MPLS = 28 // socket.h:123:1: + AF_NETBEUI = 13 // socket.h:107:1: + AF_NETLINK = 16 // socket.h:110:1: + AF_NETROM = 6 // socket.h:100:1: + AF_NFC = 39 // socket.h:134:1: + AF_PACKET = 17 // socket.h:112:1: + AF_PHONET = 35 // socket.h:130:1: + AF_PPPOX = 24 // socket.h:119:1: + AF_QIPCRTR = 42 // socket.h:137:1: + AF_RDS = 21 // socket.h:116:1: + AF_ROSE = 11 // socket.h:105:1: + AF_ROUTE = 16 // socket.h:111:1: + AF_RXRPC = 33 // socket.h:128:1: + AF_SECURITY = 14 // socket.h:108:1: + AF_SMC = 43 // socket.h:138:1: + AF_SNA = 22 // socket.h:117:1: + AF_TIPC = 30 // socket.h:125:1: + AF_UNIX = 1 // socket.h:94:1: + AF_UNSPEC = 0 // socket.h:92:1: + AF_VSOCK = 40 // socket.h:135:1: + AF_WANPIPE = 25 // socket.h:120:1: + AF_X25 = 9 // socket.h:103:1: + AF_XDP = 44 // socket.h:139:1: + BIG_ENDIAN = 4321 // endian.h:28:1: + BYTE_ORDER = 1234 // endian.h:30:1: + FD_SETSIZE = 1024 // select.h:73:1: + FIOGETOWN = 0x8903 // sockios.h:8:1: + FIOSETOWN = 0x8901 // sockios.h:6:1: + LITTLE_ENDIAN = 1234 // endian.h:27:1: + PDP_ENDIAN = 3412 // endian.h:29:1: + PF_ALG = 38 // socket.h:82:1: + PF_APPLETALK = 5 // socket.h:48:1: + PF_ASH = 18 // socket.h:62:1: + PF_ATMPVC = 8 // socket.h:51:1: + PF_ATMSVC = 20 // socket.h:64:1: + PF_AX25 = 3 // socket.h:46:1: + PF_BLUETOOTH = 31 // socket.h:75:1: + PF_BRIDGE = 7 // socket.h:50:1: + PF_CAIF = 37 // socket.h:81:1: + PF_CAN = 29 // socket.h:73:1: + PF_DECnet = 12 // socket.h:55:1: + PF_ECONET = 19 // socket.h:63:1: + PF_FILE = 1 // socket.h:44:1: + PF_IB = 27 // socket.h:71:1: + PF_IEEE802154 = 36 // socket.h:80:1: + PF_INET = 2 // socket.h:45:1: + PF_INET6 = 10 // socket.h:53:1: + PF_IPX = 4 // socket.h:47:1: + PF_IRDA = 23 // socket.h:67:1: + PF_ISDN = 34 // socket.h:78:1: + PF_IUCV = 32 // socket.h:76:1: + PF_KCM = 41 // socket.h:85:1: + PF_KEY = 15 // socket.h:58:1: + PF_LLC = 26 // socket.h:70:1: + PF_LOCAL = 1 // socket.h:42:1: + PF_MAX = 45 // socket.h:89:1: + PF_MPLS = 28 // socket.h:72:1: + PF_NETBEUI = 13 // socket.h:56:1: + PF_NETLINK = 16 // socket.h:59:1: + PF_NETROM = 6 // socket.h:49:1: + PF_NFC = 39 // socket.h:83:1: + PF_PACKET = 17 // socket.h:61:1: + PF_PHONET = 35 // socket.h:79:1: + PF_PPPOX = 24 // socket.h:68:1: + PF_QIPCRTR = 42 // socket.h:86:1: + PF_RDS = 21 // socket.h:65:1: + PF_ROSE = 11 // socket.h:54:1: + PF_ROUTE = 16 // socket.h:60:1: + PF_RXRPC = 33 // socket.h:77:1: + PF_SECURITY = 14 // socket.h:57:1: + PF_SMC = 43 // socket.h:87:1: + PF_SNA = 22 // socket.h:66:1: + PF_TIPC = 30 // socket.h:74:1: + PF_UNIX = 1 // socket.h:43:1: + PF_UNSPEC = 0 // socket.h:41:1: + PF_VSOCK = 40 // socket.h:84:1: + PF_WANPIPE = 25 // socket.h:69:1: + PF_X25 = 9 // socket.h:52:1: + PF_XDP = 44 // socket.h:88:1: + SCM_TIMESTAMP = 29 // socket.h:140:1: + SCM_TIMESTAMPING = 37 // socket.h:142:1: + SCM_TIMESTAMPING_OPT_STATS = 54 // socket.h:90:1: + SCM_TIMESTAMPING_PKTINFO = 58 // socket.h:98:1: + SCM_TIMESTAMPNS = 35 // socket.h:141:1: + SCM_TXTIME = 61 // socket.h:105:1: + SCM_WIFI_STATUS = 41 // socket.h:64:1: + SIOCATMARK = 0x8905 // sockios.h:10:1: + SIOCGPGRP = 0x8904 // sockios.h:9:1: + SIOCGSTAMP = 0x8906 // sockios.h:11:1: + SIOCGSTAMPNS = 0x8907 // sockios.h:12:1: + SIOCSPGRP = 0x8902 // sockios.h:7:1: + SOL_AAL = 265 // socket.h:151:1: + SOL_ALG = 279 // socket.h:165:1: + SOL_ATM = 264 // socket.h:150:1: + SOL_BLUETOOTH = 274 // socket.h:160:1: + SOL_CAIF = 278 // socket.h:164:1: + SOL_DCCP = 269 // socket.h:155:1: + SOL_DECNET = 261 // socket.h:147:1: + SOL_IRDA = 266 // socket.h:152:1: + SOL_IUCV = 277 // socket.h:163:1: + SOL_KCM = 281 // socket.h:167:1: + SOL_LLC = 268 // socket.h:154:1: + SOL_NETBEUI = 267 // socket.h:153:1: + SOL_NETLINK = 270 // socket.h:156:1: + SOL_NFC = 280 // socket.h:166:1: + SOL_PACKET = 263 // socket.h:149:1: + SOL_PNPIPE = 275 // socket.h:161:1: + SOL_PPPOL2TP = 273 // socket.h:159:1: + SOL_RAW = 255 // socket.h:146:1: + SOL_RDS = 276 // socket.h:162:1: + SOL_RXRPC = 272 // socket.h:158:1: + SOL_SOCKET = 1 // socket.h:9:1: + SOL_TIPC = 271 // socket.h:157:1: + SOL_TLS = 282 // socket.h:168:1: + SOL_X25 = 262 // socket.h:148:1: + SOL_XDP = 283 // socket.h:169:1: + SOMAXCONN = 4096 // socket.h:172:1: + SO_ACCEPTCONN = 30 // socket.h:51:1: + SO_ATTACH_BPF = 50 // socket.h:82:1: + SO_ATTACH_FILTER = 26 // socket.h:45:1: + SO_ATTACH_REUSEPORT_CBPF = 51 // socket.h:85:1: + SO_ATTACH_REUSEPORT_EBPF = 52 // socket.h:86:1: + SO_BINDTODEVICE = 25 // socket.h:42:1: + SO_BINDTOIFINDEX = 62 // socket.h:107:1: + SO_BPF_EXTENSIONS = 48 // socket.h:78:1: + SO_BROADCAST = 6 // socket.h:16:1: + SO_BSDCOMPAT = 14 // socket.h:26:1: + SO_BUSY_POLL = 46 // socket.h:74:1: + SO_CNX_ADVICE = 53 // socket.h:88:1: + SO_COOKIE = 57 // socket.h:96:1: + SO_DEBUG = 1 // socket.h:11:1: + SO_DETACH_BPF = 27 // socket.h:83:1: + SO_DETACH_FILTER = 27 // socket.h:46:1: + SO_DETACH_REUSEPORT_BPF = 68 // socket.h:120:1: + SO_DOMAIN = 39 // socket.h:59:1: + SO_DONTROUTE = 5 // socket.h:15:1: + SO_ERROR = 4 // socket.h:14:1: + SO_GET_FILTER = 26 // socket.h:47:1: + SO_INCOMING_CPU = 49 // socket.h:80:1: + SO_INCOMING_NAPI_ID = 56 // socket.h:94:1: + SO_KEEPALIVE = 9 // socket.h:21:1: + SO_LINGER = 13 // socket.h:25:1: + SO_LOCK_FILTER = 44 // socket.h:70:1: + SO_MARK = 36 // socket.h:56:1: + SO_MAX_PACING_RATE = 47 // socket.h:76:1: + SO_MEMINFO = 55 // socket.h:92:1: + SO_NOFCS = 43 // socket.h:68:1: + SO_NO_CHECK = 11 // socket.h:23:1: + SO_OOBINLINE = 10 // socket.h:22:1: + SO_PASSCRED = 16 // socket.h:29:1: + SO_PASSSEC = 34 // socket.h:54:1: + SO_PEEK_OFF = 42 // socket.h:65:1: + SO_PEERCRED = 17 // socket.h:30:1: + SO_PEERGROUPS = 59 // socket.h:100:1: + SO_PEERNAME = 28 // socket.h:49:1: + SO_PEERSEC = 31 // socket.h:53:1: + SO_PRIORITY = 12 // socket.h:24:1: + SO_PROTOCOL = 38 // socket.h:58:1: + SO_RCVBUF = 8 // socket.h:18:1: + SO_RCVBUFFORCE = 33 // socket.h:20:1: + SO_RCVLOWAT = 18 // socket.h:31:1: + SO_RCVTIMEO = 20 // socket.h:129:1: + SO_RCVTIMEO_NEW = 66 // socket.h:117:1: + SO_RCVTIMEO_OLD = 20 // socket.h:33:1: + SO_REUSEADDR = 2 // socket.h:12:1: + SO_REUSEPORT = 15 // socket.h:27:1: + SO_RXQ_OVFL = 40 // socket.h:61:1: + SO_SECURITY_AUTHENTICATION = 22 // socket.h:38:1: + SO_SECURITY_ENCRYPTION_NETWORK = 24 // socket.h:40:1: + SO_SECURITY_ENCRYPTION_TRANSPORT = 23 // socket.h:39:1: + SO_SELECT_ERR_QUEUE = 45 // socket.h:72:1: + SO_SNDBUF = 7 // socket.h:17:1: + SO_SNDBUFFORCE = 32 // socket.h:19:1: + SO_SNDLOWAT = 19 // socket.h:32:1: + SO_SNDTIMEO = 21 // socket.h:130:1: + SO_SNDTIMEO_NEW = 67 // socket.h:118:1: + SO_SNDTIMEO_OLD = 21 // socket.h:34:1: + SO_TIMESTAMP = 29 // socket.h:125:1: + SO_TIMESTAMPING = 37 // socket.h:127:1: + SO_TIMESTAMPING_NEW = 65 // socket.h:115:1: + SO_TIMESTAMPING_OLD = 37 // socket.h:111:1: + SO_TIMESTAMPNS = 35 // socket.h:126:1: + SO_TIMESTAMPNS_NEW = 64 // socket.h:114:1: + SO_TIMESTAMPNS_OLD = 35 // socket.h:110:1: + SO_TIMESTAMP_NEW = 63 // socket.h:113:1: + SO_TIMESTAMP_OLD = 29 // socket.h:109:1: + SO_TXTIME = 61 // socket.h:104:1: + SO_TYPE = 3 // socket.h:13:1: + SO_WIFI_STATUS = 41 // socket.h:63:1: + SO_ZEROCOPY = 60 // socket.h:102:1: + X_ASM_X86_POSIX_TYPES_64_H = 0 // posix_types_64.h:3:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_SOCKADDR_H = 1 // sockaddr.h:24:1: + X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_ENDIAN_H = 1 // endian.h:19:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LINUX_POSIX_TYPES_H = 0 // posix_types.h:3:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_SS_SIZE = 128 // sockaddr.h:40:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SELECT_H = 1 // select.h:22:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_SYS_SOCKET_H = 1 // socket.h:20:1: + X_SYS_TYPES_H = 1 // types.h:23:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// Bits in the FLAGS argument to `send', `recv', et al. +const ( /* socket.h:200:1: */ + MSG_OOB = 1 // Process out-of-band data. + MSG_PEEK = 2 // Peek at incoming messages. + MSG_DONTROUTE = 4 // Don't use local routing. + MSG_CTRUNC = 8 // Control data lost before delivery. + MSG_PROXY = 16 // Supply or ask second address. + MSG_TRUNC = 32 + MSG_DONTWAIT = 64 // Nonblocking IO. + MSG_EOR = 128 // End of record. + MSG_WAITALL = 256 // Wait for a full request. + MSG_FIN = 512 + MSG_SYN = 1024 + MSG_CONFIRM = 2048 // Confirm path validity. + MSG_RST = 4096 + MSG_ERRQUEUE = 8192 // Fetch message from error queue. + MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. + MSG_MORE = 32768 // Sender will send more. + MSG_WAITFORONE = 65536 // Wait for at least one packet to return. + MSG_BATCH = 262144 // sendmmsg: more messages coming. + MSG_ZEROCOPY = 67108864 // Use user data in kernel path. + MSG_FASTOPEN = 536870912 // Send data in TCP SYN. + + MSG_CMSG_CLOEXEC = 1073741824 +) + +// Socket level message types. This must match the definitions in +// +// . +const ( /* socket.h:332:1: */ + SCM_RIGHTS = 1 +) + +// Get the architecture-dependent definition of enum __socket_type. +// Define enum __socket_type for generic Linux. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Types of sockets. +const ( /* socket_type.h:24:1: */ + SOCK_STREAM = 1 // Sequenced, reliable, connection-based + // byte streams. + SOCK_DGRAM = 2 // Connectionless, unreliable datagrams + // of fixed maximum length. + SOCK_RAW = 3 // Raw protocol interface. + SOCK_RDM = 4 // Reliably-delivered messages. + SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, + // datagrams of fixed maximum length. + SOCK_DCCP = 6 // Datagram Congestion Control Protocol. + SOCK_PACKET = 10 // Linux specific way of getting packets + // at the dev level. For writing rarp and + // other similar things on the user level. + + // Flags to be ORed into the type parameter of socket and socketpair and + // used for the flags parameter of paccept. + + SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the + // new descriptor(s). + SOCK_NONBLOCK = 2048 +) + +// The following constants should be used for the second parameter of +// +// `shutdown'. +const ( /* socket.h:41:1: */ + SHUT_RD = 0 // No more receptions. + SHUT_WR = 1 // No more transmissions. + SHUT_RDWR = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Structure for scatter/gather I/O. +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* struct_iovec.h:26:1 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This operating system-specific header file defines the SOCK_*, PF_*, +// AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', +// `struct msghdr', and `struct linger' types. +// System-specific socket constants and types. Linux version. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +// Type for length arguments in socket calls. +type Socklen_t = X__socklen_t /* socket.h:33:21 */ + +// Protocol families. + +// Address families. + +// Socket level values. Others are defined in the appropriate headers. +// +// XXX These definitions also should go into the appropriate headers as +// far as they are available. + +// Maximum queue length specifiable by listen. + +// Get the definition of the macro to define the common sockaddr members. +// Definition of struct sockaddr_* common members and sizes, generic version. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// POSIX.1g specifies this type name for the `sa_family' member. +type Sa_family_t = uint16 /* sockaddr.h:28:28 */ + +// This macro is used to declare the initial common members +// of the data types used for socket addresses, `struct sockaddr', +// `struct sockaddr_in', `struct sockaddr_un', etc. + +// Size of struct sockaddr_storage. + +// Structure describing a generic socket address. +type Sockaddr = struct { + Fsa_family Sa_family_t + Fsa_data [14]int8 +} /* socket.h:178:1 */ + +// Structure large enough to hold any socket address (with the historical +// exception of AF_UNIX). + +type Sockaddr_storage = struct { + Fss_family Sa_family_t + F__ss_padding [118]int8 + F__ss_align uint64 +} /* socket.h:191:1 */ + +// Structure describing messages sent by +// +// `sendmsg' and received by `recvmsg'. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen Size_t + Fmsg_control uintptr + Fmsg_controllen Size_t + Fmsg_flags int32 + F__ccgo_pad2 [4]byte +} /* socket.h:257:1 */ + +// Structure used for storage of ancillary data object information. +type Cmsghdr = struct { + F__ccgo_pad1 [0]uint64 + Fcmsg_len Size_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:275:1 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This allows for 1024 file descriptors: if NR_OPEN is ever grown +// beyond that you'll have to change this too. But 1024 fd's seem to be +// enough even for such "real" unices like OSF/1, so hopefully this is +// one limit that doesn't have to be changed [again]. +// +// Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in +// (and thus ) - but this is a more logical +// place for them. Solved by having dummy defines in . + +// This macro may have been defined in . But we always +// use the one here. + +type X__kernel_fd_set = struct{ Ffds_bits [16]uint64 } /* posix_types.h:27:3 */ + +// Type of a signal handler. +type X__kernel_sighandler_t = uintptr /* posix_types.h:30:14 */ + +// Type of a SYSV IPC key. +type X__kernel_key_t = int32 /* posix_types.h:33:13 */ +type X__kernel_mqd_t = int32 /* posix_types.h:34:13 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. Also, we cannot +// assume GCC is being used. + +type X__kernel_old_uid_t = uint16 /* posix_types_64.h:11:24 */ +type X__kernel_old_gid_t = uint16 /* posix_types_64.h:12:24 */ + +type X__kernel_old_dev_t = uint64 /* posix_types_64.h:15:23 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// There seems to be no way of detecting this automatically from user +// space, so 64 bit architectures should override this in their +// bitsperlong.h. In particular, an architecture that supports +// both 32 and 64 bit user space must not rely on CONFIG_64BIT +// to decide it, but rather check a compiler provided macro. + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. +// +// First the types that are often defined in different ways across +// architectures, so that you can override them. + +type X__kernel_long_t = int64 /* posix_types.h:15:15 */ +type X__kernel_ulong_t = uint64 /* posix_types.h:16:23 */ + +type X__kernel_ino_t = X__kernel_ulong_t /* posix_types.h:20:26 */ + +type X__kernel_mode_t = uint32 /* posix_types.h:24:22 */ + +type X__kernel_pid_t = int32 /* posix_types.h:28:14 */ + +type X__kernel_ipc_pid_t = int32 /* posix_types.h:32:14 */ + +type X__kernel_uid_t = uint32 /* posix_types.h:36:22 */ +type X__kernel_gid_t = uint32 /* posix_types.h:37:22 */ + +type X__kernel_suseconds_t = X__kernel_long_t /* posix_types.h:41:26 */ + +type X__kernel_daddr_t = int32 /* posix_types.h:45:14 */ + +type X__kernel_uid32_t = uint32 /* posix_types.h:49:22 */ +type X__kernel_gid32_t = uint32 /* posix_types.h:50:22 */ + +// Most 32 bit architectures use "unsigned int" size_t, +// and all 64 bit architectures use "unsigned long" size_t. +type X__kernel_size_t = X__kernel_ulong_t /* posix_types.h:72:26 */ +type X__kernel_ssize_t = X__kernel_long_t /* posix_types.h:73:25 */ +type X__kernel_ptrdiff_t = X__kernel_long_t /* posix_types.h:74:25 */ + +type X__kernel_fsid_t = struct{ Fval [2]int32 } /* posix_types.h:81:3 */ + +// anything below here should be completely generic +type X__kernel_off_t = X__kernel_long_t /* posix_types.h:87:25 */ +type X__kernel_loff_t = int64 /* posix_types.h:88:19 */ +type X__kernel_old_time_t = X__kernel_long_t /* posix_types.h:89:25 */ +type X__kernel_time_t = X__kernel_long_t /* posix_types.h:90:25 */ +type X__kernel_time64_t = int64 /* posix_types.h:91:19 */ +type X__kernel_clock_t = X__kernel_long_t /* posix_types.h:92:25 */ +type X__kernel_timer_t = int32 /* posix_types.h:93:14 */ +type X__kernel_clockid_t = int32 /* posix_types.h:94:14 */ +type X__kernel_caddr_t = uintptr /* posix_types.h:95:14 */ +type X__kernel_uid16_t = uint16 /* posix_types.h:96:24 */ +type X__kernel_gid16_t = uint16 /* posix_types.h:97:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// Socket-level I/O control calls. + +// For setsockopt(2) + +// Security levels - as per NRL IPv6 - don't actually do anything + +// Socket filtering + +// Instruct lower device to use last 4-bytes of skb data as FCS + +// on 64-bit and x32, avoid the ?: operator + +// Structure used to manipulate the SO_LINGER option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:361:1 */ + +// This is the 4.3 BSD `struct sockaddr' format, which is used as wire +// +// format in the grotty old 4.3 `talk' protocol. +type Osockaddr = struct { + Fsa_family uint16 + Fsa_data [14]uint8 +} /* struct_osockaddr.h:6:1 */ + +// Define some macros helping to catch buffer overflows. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/socket/socket_linux_arm64.go b/internal/libc/sys/socket/socket_linux_arm64.go new file mode 100644 index 0000000..38a89ea --- /dev/null +++ b/internal/libc/sys/socket/socket_linux_arm64.go @@ -0,0 +1,1923 @@ +// Code generated by 'ccgo sys/socket/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o sys/socket/socket_linux_arm64.go -pkgname socket', DO NOT EDIT. + +package socket + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + AF_ALG = 38 + AF_APPLETALK = 5 + AF_ASH = 18 + AF_ATMPVC = 8 + AF_ATMSVC = 20 + AF_AX25 = 3 + AF_BLUETOOTH = 31 + AF_BRIDGE = 7 + AF_CAIF = 37 + AF_CAN = 29 + AF_DECnet = 12 + AF_ECONET = 19 + AF_FILE = 1 + AF_IB = 27 + AF_IEEE802154 = 36 + AF_INET = 2 + AF_INET6 = 10 + AF_IPX = 4 + AF_IRDA = 23 + AF_ISDN = 34 + AF_IUCV = 32 + AF_KCM = 41 + AF_KEY = 15 + AF_LLC = 26 + AF_LOCAL = 1 + AF_MAX = 45 + AF_MPLS = 28 + AF_NETBEUI = 13 + AF_NETLINK = 16 + AF_NETROM = 6 + AF_NFC = 39 + AF_PACKET = 17 + AF_PHONET = 35 + AF_PPPOX = 24 + AF_QIPCRTR = 42 + AF_RDS = 21 + AF_ROSE = 11 + AF_ROUTE = 16 + AF_RXRPC = 33 + AF_SECURITY = 14 + AF_SMC = 43 + AF_SNA = 22 + AF_TIPC = 30 + AF_UNIX = 1 + AF_UNSPEC = 0 + AF_VSOCK = 40 + AF_WANPIPE = 25 + AF_X25 = 9 + AF_XDP = 44 + BIG_ENDIAN = 4321 + BYTE_ORDER = 1234 + FD_SETSIZE = 1024 + FIOGETOWN = 0x8903 + FIOSETOWN = 0x8901 + LITTLE_ENDIAN = 1234 + PDP_ENDIAN = 3412 + PF_ALG = 38 + PF_APPLETALK = 5 + PF_ASH = 18 + PF_ATMPVC = 8 + PF_ATMSVC = 20 + PF_AX25 = 3 + PF_BLUETOOTH = 31 + PF_BRIDGE = 7 + PF_CAIF = 37 + PF_CAN = 29 + PF_DECnet = 12 + PF_ECONET = 19 + PF_FILE = 1 + PF_IB = 27 + PF_IEEE802154 = 36 + PF_INET = 2 + PF_INET6 = 10 + PF_IPX = 4 + PF_IRDA = 23 + PF_ISDN = 34 + PF_IUCV = 32 + PF_KCM = 41 + PF_KEY = 15 + PF_LLC = 26 + PF_LOCAL = 1 + PF_MAX = 45 + PF_MPLS = 28 + PF_NETBEUI = 13 + PF_NETLINK = 16 + PF_NETROM = 6 + PF_NFC = 39 + PF_PACKET = 17 + PF_PHONET = 35 + PF_PPPOX = 24 + PF_QIPCRTR = 42 + PF_RDS = 21 + PF_ROSE = 11 + PF_ROUTE = 16 + PF_RXRPC = 33 + PF_SECURITY = 14 + PF_SMC = 43 + PF_SNA = 22 + PF_TIPC = 30 + PF_UNIX = 1 + PF_UNSPEC = 0 + PF_VSOCK = 40 + PF_WANPIPE = 25 + PF_X25 = 9 + PF_XDP = 44 + SCM_TIMESTAMP = 29 + SCM_TIMESTAMPING = 37 + SCM_TIMESTAMPING_OPT_STATS = 54 + SCM_TIMESTAMPING_PKTINFO = 58 + SCM_TIMESTAMPNS = 35 + SCM_TXTIME = 61 + SCM_WIFI_STATUS = 41 + SIOCATMARK = 0x8905 + SIOCGPGRP = 0x8904 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCSPGRP = 0x8902 + SOL_AAL = 265 + SOL_ALG = 279 + SOL_ATM = 264 + SOL_BLUETOOTH = 274 + SOL_CAIF = 278 + SOL_DCCP = 269 + SOL_DECNET = 261 + SOL_IRDA = 266 + SOL_IUCV = 277 + SOL_KCM = 281 + SOL_LLC = 268 + SOL_NETBEUI = 267 + SOL_NETLINK = 270 + SOL_NFC = 280 + SOL_PACKET = 263 + SOL_PNPIPE = 275 + SOL_PPPOL2TP = 273 + SOL_RAW = 255 + SOL_RDS = 276 + SOL_RXRPC = 272 + SOL_SOCKET = 1 + SOL_TIPC = 271 + SOL_TLS = 282 + SOL_X25 = 262 + SOL_XDP = 283 + SOMAXCONN = 4096 + SO_ACCEPTCONN = 30 + SO_ATTACH_BPF = 50 + SO_ATTACH_FILTER = 26 + SO_ATTACH_REUSEPORT_CBPF = 51 + SO_ATTACH_REUSEPORT_EBPF = 52 + SO_BINDTODEVICE = 25 + SO_BINDTOIFINDEX = 62 + SO_BPF_EXTENSIONS = 48 + SO_BROADCAST = 6 + SO_BSDCOMPAT = 14 + SO_BUSY_POLL = 46 + SO_CNX_ADVICE = 53 + SO_COOKIE = 57 + SO_DEBUG = 1 + SO_DETACH_BPF = 27 + SO_DETACH_FILTER = 27 + SO_DETACH_REUSEPORT_BPF = 68 + SO_DOMAIN = 39 + SO_DONTROUTE = 5 + SO_ERROR = 4 + SO_GET_FILTER = 26 + SO_INCOMING_CPU = 49 + SO_INCOMING_NAPI_ID = 56 + SO_KEEPALIVE = 9 + SO_LINGER = 13 + SO_LOCK_FILTER = 44 + SO_MARK = 36 + SO_MAX_PACING_RATE = 47 + SO_MEMINFO = 55 + SO_NOFCS = 43 + SO_NO_CHECK = 11 + SO_OOBINLINE = 10 + SO_PASSCRED = 16 + SO_PASSSEC = 34 + SO_PEEK_OFF = 42 + SO_PEERCRED = 17 + SO_PEERGROUPS = 59 + SO_PEERNAME = 28 + SO_PEERSEC = 31 + SO_PRIORITY = 12 + SO_PROTOCOL = 38 + SO_RCVBUF = 8 + SO_RCVBUFFORCE = 33 + SO_RCVLOWAT = 18 + SO_RCVTIMEO = 20 + SO_RCVTIMEO_NEW = 66 + SO_RCVTIMEO_OLD = 20 + SO_REUSEADDR = 2 + SO_REUSEPORT = 15 + SO_RXQ_OVFL = 40 + SO_SECURITY_AUTHENTICATION = 22 + SO_SECURITY_ENCRYPTION_NETWORK = 24 + SO_SECURITY_ENCRYPTION_TRANSPORT = 23 + SO_SELECT_ERR_QUEUE = 45 + SO_SNDBUF = 7 + SO_SNDBUFFORCE = 32 + SO_SNDLOWAT = 19 + SO_SNDTIMEO = 21 + SO_SNDTIMEO_NEW = 67 + SO_SNDTIMEO_OLD = 21 + SO_TIMESTAMP = 29 + SO_TIMESTAMPING = 37 + SO_TIMESTAMPING_NEW = 65 + SO_TIMESTAMPING_OLD = 37 + SO_TIMESTAMPNS = 35 + SO_TIMESTAMPNS_NEW = 64 + SO_TIMESTAMPNS_OLD = 35 + SO_TIMESTAMP_NEW = 63 + SO_TIMESTAMP_OLD = 29 + SO_TXTIME = 61 + SO_TYPE = 3 + SO_WIFI_STATUS = 41 + SO_ZEROCOPY = 60 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_SOCKADDR_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LINUX_POSIX_TYPES_H = 0 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_SS_SIZE = 128 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_SOCKET_H = 1 + X_SYS_TYPES_H = 1 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +// Bits in the FLAGS argument to `send', `recv', et al. +const ( /* socket.h:200:1: */ + MSG_OOB = 1 // Process out-of-band data. + MSG_PEEK = 2 // Peek at incoming messages. + MSG_DONTROUTE = 4 // Don't use local routing. + MSG_CTRUNC = 8 // Control data lost before delivery. + MSG_PROXY = 16 // Supply or ask second address. + MSG_TRUNC = 32 + MSG_DONTWAIT = 64 // Nonblocking IO. + MSG_EOR = 128 // End of record. + MSG_WAITALL = 256 // Wait for a full request. + MSG_FIN = 512 + MSG_SYN = 1024 + MSG_CONFIRM = 2048 // Confirm path validity. + MSG_RST = 4096 + MSG_ERRQUEUE = 8192 // Fetch message from error queue. + MSG_NOSIGNAL = 16384 // Do not generate SIGPIPE. + MSG_MORE = 32768 // Sender will send more. + MSG_WAITFORONE = 65536 // Wait for at least one packet to return. + MSG_BATCH = 262144 // sendmmsg: more messages coming. + MSG_ZEROCOPY = 67108864 // Use user data in kernel path. + MSG_FASTOPEN = 536870912 // Send data in TCP SYN. + + MSG_CMSG_CLOEXEC = 1073741824 +) + +// Socket level message types. This must match the definitions in +// +// . +const ( /* socket.h:332:1: */ + SCM_RIGHTS = 1 +) + +// Get the architecture-dependent definition of enum __socket_type. +// Define enum __socket_type for generic Linux. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Types of sockets. +const ( /* socket_type.h:24:1: */ + SOCK_STREAM = 1 // Sequenced, reliable, connection-based + // byte streams. + SOCK_DGRAM = 2 // Connectionless, unreliable datagrams + // of fixed maximum length. + SOCK_RAW = 3 // Raw protocol interface. + SOCK_RDM = 4 // Reliably-delivered messages. + SOCK_SEQPACKET = 5 // Sequenced, reliable, connection-based, + // datagrams of fixed maximum length. + SOCK_DCCP = 6 // Datagram Congestion Control Protocol. + SOCK_PACKET = 10 // Linux specific way of getting packets + // at the dev level. For writing rarp and + // other similar things on the user level. + + // Flags to be ORed into the type parameter of socket and socketpair and + // used for the flags parameter of paccept. + + SOCK_CLOEXEC = 524288 // Atomically set close-on-exec flag for the + // new descriptor(s). + SOCK_NONBLOCK = 2048 +) + +// The following constants should be used for the second parameter of +// +// `shutdown'. +const ( /* socket.h:41:1: */ + SHUT_RD = 0 // No more receptions. + SHUT_WR = 1 // No more transmissions. + SHUT_RDWR = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Structure for scatter/gather I/O. +type Iovec = struct { + Fiov_base uintptr + Fiov_len Size_t +} /* struct_iovec.h:26:1 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This operating system-specific header file defines the SOCK_*, PF_*, +// AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', +// `struct msghdr', and `struct linger' types. +// System-specific socket constants and types. Linux version. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We don't use `memset' because this would require a prototype and +// the array isn't too big. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +// Type for length arguments in socket calls. +type Socklen_t = X__socklen_t /* socket.h:33:21 */ + +// Protocol families. + +// Address families. + +// Socket level values. Others are defined in the appropriate headers. +// +// XXX These definitions also should go into the appropriate headers as +// far as they are available. + +// Maximum queue length specifiable by listen. + +// Get the definition of the macro to define the common sockaddr members. +// Definition of struct sockaddr_* common members and sizes, generic version. +// Copyright (C) 1995-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// POSIX.1g specifies this type name for the `sa_family' member. +type Sa_family_t = uint16 /* sockaddr.h:28:28 */ + +// This macro is used to declare the initial common members +// of the data types used for socket addresses, `struct sockaddr', +// `struct sockaddr_in', `struct sockaddr_un', etc. + +// Size of struct sockaddr_storage. + +// Structure describing a generic socket address. +type Sockaddr = struct { + Fsa_family Sa_family_t + Fsa_data [14]uint8 +} /* socket.h:178:1 */ + +// Structure large enough to hold any socket address (with the historical +// exception of AF_UNIX). + +type Sockaddr_storage = struct { + Fss_family Sa_family_t + F__ss_padding [118]uint8 + F__ss_align uint64 +} /* socket.h:191:1 */ + +// Structure describing messages sent by +// +// `sendmsg' and received by `recvmsg'. +type Msghdr = struct { + Fmsg_name uintptr + Fmsg_namelen Socklen_t + F__ccgo_pad1 [4]byte + Fmsg_iov uintptr + Fmsg_iovlen Size_t + Fmsg_control uintptr + Fmsg_controllen Size_t + Fmsg_flags int32 + F__ccgo_pad2 [4]byte +} /* socket.h:257:1 */ + +// Structure used for storage of ancillary data object information. +type Cmsghdr = struct { + F__ccgo_pad1 [0]uint64 + Fcmsg_len Size_t + Fcmsg_level int32 + Fcmsg_type int32 +} /* socket.h:275:1 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// This allows for 1024 file descriptors: if NR_OPEN is ever grown +// beyond that you'll have to change this too. But 1024 fd's seem to be +// enough even for such "real" unices like OSF/1, so hopefully this is +// one limit that doesn't have to be changed [again]. +// +// Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in +// (and thus ) - but this is a more logical +// place for them. Solved by having dummy defines in . + +// This macro may have been defined in . But we always +// use the one here. + +type X__kernel_fd_set = struct{ Ffds_bits [16]uint64 } /* posix_types.h:27:3 */ + +// Type of a signal handler. +type X__kernel_sighandler_t = uintptr /* posix_types.h:30:14 */ + +// Type of a SYSV IPC key. +type X__kernel_key_t = int32 /* posix_types.h:33:13 */ +type X__kernel_mqd_t = int32 /* posix_types.h:34:13 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +type X__kernel_old_uid_t = uint16 /* posix_types.h:5:24 */ +type X__kernel_old_gid_t = uint16 /* posix_types.h:6:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// Copyright (C) 2012 ARM Ltd. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 . + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// There seems to be no way of detecting this automatically from user +// space, so 64 bit architectures should override this in their +// bitsperlong.h. In particular, an architecture that supports +// both 32 and 64 bit user space must not rely on CONFIG_64BIT +// to decide it, but rather check a compiler provided macro. + +// This file is generally used by user-level software, so you need to +// be a little careful about namespace pollution etc. +// +// First the types that are often defined in different ways across +// architectures, so that you can override them. + +type X__kernel_long_t = int64 /* posix_types.h:15:15 */ +type X__kernel_ulong_t = uint64 /* posix_types.h:16:23 */ + +type X__kernel_ino_t = X__kernel_ulong_t /* posix_types.h:20:26 */ + +type X__kernel_mode_t = uint32 /* posix_types.h:24:22 */ + +type X__kernel_pid_t = int32 /* posix_types.h:28:14 */ + +type X__kernel_ipc_pid_t = int32 /* posix_types.h:32:14 */ + +type X__kernel_uid_t = uint32 /* posix_types.h:36:22 */ +type X__kernel_gid_t = uint32 /* posix_types.h:37:22 */ + +type X__kernel_suseconds_t = X__kernel_long_t /* posix_types.h:41:26 */ + +type X__kernel_daddr_t = int32 /* posix_types.h:45:14 */ + +type X__kernel_uid32_t = uint32 /* posix_types.h:49:22 */ +type X__kernel_gid32_t = uint32 /* posix_types.h:50:22 */ + +type X__kernel_old_dev_t = uint32 /* posix_types.h:59:22 */ + +// Most 32 bit architectures use "unsigned int" size_t, +// and all 64 bit architectures use "unsigned long" size_t. +type X__kernel_size_t = X__kernel_ulong_t /* posix_types.h:72:26 */ +type X__kernel_ssize_t = X__kernel_long_t /* posix_types.h:73:25 */ +type X__kernel_ptrdiff_t = X__kernel_long_t /* posix_types.h:74:25 */ + +type X__kernel_fsid_t = struct{ Fval [2]int32 } /* posix_types.h:81:3 */ + +// anything below here should be completely generic +type X__kernel_off_t = X__kernel_long_t /* posix_types.h:87:25 */ +type X__kernel_loff_t = int64 /* posix_types.h:88:19 */ +type X__kernel_old_time_t = X__kernel_long_t /* posix_types.h:89:25 */ +type X__kernel_time_t = X__kernel_long_t /* posix_types.h:90:25 */ +type X__kernel_time64_t = int64 /* posix_types.h:91:19 */ +type X__kernel_clock_t = X__kernel_long_t /* posix_types.h:92:25 */ +type X__kernel_timer_t = int32 /* posix_types.h:93:14 */ +type X__kernel_clockid_t = int32 /* posix_types.h:94:14 */ +type X__kernel_caddr_t = uintptr /* posix_types.h:95:14 */ +type X__kernel_uid16_t = uint16 /* posix_types.h:96:24 */ +type X__kernel_gid16_t = uint16 /* posix_types.h:97:24 */ + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +// Socket-level I/O control calls. + +// For setsockopt(2) + +// Security levels - as per NRL IPv6 - don't actually do anything + +// Socket filtering + +// Instruct lower device to use last 4-bytes of skb data as FCS + +// on 64-bit and x32, avoid the ?: operator + +// Structure used to manipulate the SO_LINGER option. +type Linger = struct { + Fl_onoff int32 + Fl_linger int32 +} /* socket.h:361:1 */ + +// This is the 4.3 BSD `struct sockaddr' format, which is used as wire +// +// format in the grotty old 4.3 `talk' protocol. +type Osockaddr = struct { + Fsa_family uint16 + Fsa_data [14]uint8 +} /* struct_osockaddr.h:6:1 */ + +// Define some macros helping to catch buffer overflows. + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/stat/capi_darwin_amd64.go b/internal/libc/sys/stat/capi_darwin_amd64.go new file mode 100644 index 0000000..07cbcc3 --- /dev/null +++ b/internal/libc/sys/stat/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo sys/stat/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/stat/stat_darwin_amd64.go -pkgname stat', DO NOT EDIT. + +package stat + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/sys/stat/capi_darwin_arm64.go b/internal/libc/sys/stat/capi_darwin_arm64.go new file mode 100644 index 0000000..934d8ff --- /dev/null +++ b/internal/libc/sys/stat/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo sys/stat/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/stat/stat_darwin_arm64.go -pkgname stat', DO NOT EDIT. + +package stat + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/sys/stat/capi_linux_amd64.go b/internal/libc/sys/stat/capi_linux_amd64.go new file mode 100644 index 0000000..7ab1512 --- /dev/null +++ b/internal/libc/sys/stat/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo sys/stat/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/stat/stat_linux_amd64.go -pkgname stat', DO NOT EDIT. + +package stat + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/sys/stat/capi_linux_arm64.go b/internal/libc/sys/stat/capi_linux_arm64.go new file mode 100644 index 0000000..381d13e --- /dev/null +++ b/internal/libc/sys/stat/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo sys/stat/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o sys/stat/stat_linux_arm64.go -pkgname stat', DO NOT EDIT. + +package stat + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/sys/stat/stat_darwin_amd64.go b/internal/libc/sys/stat/stat_darwin_amd64.go new file mode 100644 index 0000000..f0f27ed --- /dev/null +++ b/internal/libc/sys/stat/stat_darwin_amd64.go @@ -0,0 +1,2352 @@ +// Code generated by 'ccgo sys/stat/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/stat/stat_darwin_amd64.go -pkgname stat', DO NOT EDIT. + +package stat + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSPERMS = 511 // stat.h:297:1: + ALLPERMS = 4095 // stat.h:299:1: + DEFFILEMODE = 438 // stat.h:301:1: + EF_IS_PURGEABLE = 0x00000008 // stat.h:370:1: + EF_IS_SPARSE = 0x00000010 // stat.h:371:1: + EF_IS_SYNC_ROOT = 0x00000004 // stat.h:369:1: + EF_MAY_SHARE_BLOCKS = 0x00000001 // stat.h:367:1: + EF_NO_XATTRS = 0x00000002 // stat.h:368:1: + SF_APPEND = 0x00040000 // stat.h:340:1: + SF_ARCHIVED = 0x00010000 // stat.h:338:1: + SF_DATALESS = 0x40000000 // stat.h:359:1: + SF_FIRMLINK = 0x00800000 // stat.h:351:1: + SF_IMMUTABLE = 0x00020000 // stat.h:339:1: + SF_NOUNLINK = 0x00100000 // stat.h:342:1: + SF_RESTRICTED = 0x00080000 // stat.h:341:1: + SF_SETTABLE = 0x3fff0000 // stat.h:336:1: + SF_SUPPORTED = 0x009f0000 // stat.h:335:1: + SF_SYNTHETIC = 0xc0000000 // stat.h:337:1: + S_BLKSIZE = 512 // stat.h:303:1: + S_IEXEC = 64 // _s_ifmt.h:72:1: + S_IFBLK = 0060000 // _s_ifmt.h:39:1: + S_IFCHR = 0020000 // _s_ifmt.h:37:1: + S_IFDIR = 0040000 // _s_ifmt.h:38:1: + S_IFIFO = 0010000 // _s_ifmt.h:36:1: + S_IFLNK = 0120000 // _s_ifmt.h:41:1: + S_IFMT = 0170000 // _s_ifmt.h:35:1: + S_IFREG = 0100000 // _s_ifmt.h:40:1: + S_IFSOCK = 0140000 // _s_ifmt.h:42:1: + S_IFWHT = 0160000 // _s_ifmt.h:44:1: + S_IREAD = 256 // _s_ifmt.h:70:1: + S_IRGRP = 0000040 // _s_ifmt.h:55:1: + S_IROTH = 0000004 // _s_ifmt.h:60:1: + S_IRUSR = 0000400 // _s_ifmt.h:50:1: + S_IRWXG = 0000070 // _s_ifmt.h:54:1: + S_IRWXO = 0000007 // _s_ifmt.h:59:1: + S_IRWXU = 0000700 // _s_ifmt.h:49:1: + S_ISGID = 0002000 // _s_ifmt.h:65:1: + S_ISTXT = 512 // _s_ifmt.h:69:1: + S_ISUID = 0004000 // _s_ifmt.h:64:1: + S_ISVTX = 0001000 // _s_ifmt.h:66:1: + S_IWGRP = 0000020 // _s_ifmt.h:56:1: + S_IWOTH = 0000002 // _s_ifmt.h:61:1: + S_IWRITE = 128 // _s_ifmt.h:71:1: + S_IWUSR = 0000200 // _s_ifmt.h:51:1: + S_IXGRP = 0000010 // _s_ifmt.h:57:1: + S_IXOTH = 0000001 // _s_ifmt.h:62:1: + S_IXUSR = 0000100 // _s_ifmt.h:52:1: + UF_APPEND = 0x00000004 // stat.h:313:1: + UF_COMPRESSED = 0x00000020 // stat.h:320:1: + UF_DATAVAULT = 0x00000080 // stat.h:326:1: + UF_HIDDEN = 0x00008000 // stat.h:330:1: + UF_IMMUTABLE = 0x00000002 // stat.h:312:1: + UF_NODUMP = 0x00000001 // stat.h:311:1: + UF_OPAQUE = 0x00000008 // stat.h:314:1: + UF_SETTABLE = 0x0000ffff // stat.h:310:1: + UF_TRACKED = 0x00000040 // stat.h:324:1: + UTIME_NOW = -1 // stat.h:393:1: + UTIME_OMIT = -2 // stat.h:394:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_FILESEC_T = 0 // _filesec_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_SYS_STAT_H_ = 0 // stat.h:71:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2014 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)stat.h 8.9 (Berkeley) 8/17/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// [XSI] The timespec structure may be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +// [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t, +// gid_t, off_t, and time_t types shall be defined as described in +// . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// XXX So deprecated, it would make your head spin +// +// The old stat structure. In fact, this is not used by the kernel at all, +// and should not be used by user space, and should be removed from this +// header file entirely (along with the unused cvtstat() prototype in +// vnode_internal.h). +type Ostat = struct { + Fst_dev X__uint16_t + F__ccgo_pad1 [6]byte + Fst_ino Ino_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_uid X__uint16_t + Fst_gid X__uint16_t + Fst_rdev X__uint16_t + F__ccgo_pad2 [2]byte + Fst_size X__int32_t + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_blksize X__int32_t + Fst_blocks X__int32_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t +} /* stat.h:110:1 */ + +// This structure is used as the second parameter to the fstat64(), +// lstat64(), and stat64() functions, and for struct stat when +// __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined +// above, depending on whether we use struct timespec or the direct +// components. +// +// This is simillar to stat except for 64bit inode number +// number instead of 32bit ino_t and the addition of create(birth) time. + +// [XSI] This structure is used as the second parameter to the fstat(), +// lstat(), and stat() functions. + +type Stat = struct { + Fst_dev Dev_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_ino X__darwin_ino64_t + Fst_uid Uid_t + Fst_gid Gid_t + Fst_rdev Dev_t + F__ccgo_pad1 [4]byte + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_birthtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_size Off_t + Fst_blocks Blkcnt_t + Fst_blksize Blksize_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t + Fst_lspare X__int32_t + Fst_qspare [2]X__int64_t +} /* stat.h:182:1 */ + +type Stat64 = struct { + Fst_dev Dev_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_ino X__darwin_ino64_t + Fst_uid Uid_t + Fst_gid Gid_t + Fst_rdev Dev_t + F__ccgo_pad1 [4]byte + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_birthtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_size Off_t + Fst_blocks Blkcnt_t + Fst_blksize Blksize_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t + Fst_lspare X__int32_t + Fst_qspare [2]X__int64_t +} /* stat.h:221:1 */ + +type Filesec_t = uintptr /* _filesec_t.h:31:25 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/stat/stat_darwin_arm64.go b/internal/libc/sys/stat/stat_darwin_arm64.go new file mode 100644 index 0000000..82f4225 --- /dev/null +++ b/internal/libc/sys/stat/stat_darwin_arm64.go @@ -0,0 +1,2332 @@ +// Code generated by 'ccgo sys/stat/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/stat/stat_darwin_arm64.go -pkgname stat', DO NOT EDIT. + +package stat + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSPERMS = 511 // stat.h:297:1: + ALLPERMS = 4095 // stat.h:299:1: + DEFFILEMODE = 438 // stat.h:301:1: + EF_IS_PURGEABLE = 0x00000008 // stat.h:371:1: + EF_IS_SPARSE = 0x00000010 // stat.h:372:1: + EF_IS_SYNC_ROOT = 0x00000004 // stat.h:370:1: + EF_IS_SYNTHETIC = 0x00000020 // stat.h:373:1: + EF_MAY_SHARE_BLOCKS = 0x00000001 // stat.h:368:1: + EF_NO_XATTRS = 0x00000002 // stat.h:369:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + SF_APPEND = 0x00040000 // stat.h:340:1: + SF_ARCHIVED = 0x00010000 // stat.h:338:1: + SF_DATALESS = 0x40000000 // stat.h:359:1: + SF_FIRMLINK = 0x00800000 // stat.h:351:1: + SF_IMMUTABLE = 0x00020000 // stat.h:339:1: + SF_NOUNLINK = 0x00100000 // stat.h:342:1: + SF_RESTRICTED = 0x00080000 // stat.h:341:1: + SF_SETTABLE = 0x3fff0000 // stat.h:336:1: + SF_SUPPORTED = 0x009f0000 // stat.h:335:1: + SF_SYNTHETIC = 0xc0000000 // stat.h:337:1: + S_BLKSIZE = 512 // stat.h:303:1: + S_IEXEC = 64 // _s_ifmt.h:72:1: + S_IFBLK = 0060000 // _s_ifmt.h:39:1: + S_IFCHR = 0020000 // _s_ifmt.h:37:1: + S_IFDIR = 0040000 // _s_ifmt.h:38:1: + S_IFIFO = 0010000 // _s_ifmt.h:36:1: + S_IFLNK = 0120000 // _s_ifmt.h:41:1: + S_IFMT = 0170000 // _s_ifmt.h:35:1: + S_IFREG = 0100000 // _s_ifmt.h:40:1: + S_IFSOCK = 0140000 // _s_ifmt.h:42:1: + S_IFWHT = 0160000 // _s_ifmt.h:44:1: + S_IREAD = 256 // _s_ifmt.h:70:1: + S_IRGRP = 0000040 // _s_ifmt.h:55:1: + S_IROTH = 0000004 // _s_ifmt.h:60:1: + S_IRUSR = 0000400 // _s_ifmt.h:50:1: + S_IRWXG = 0000070 // _s_ifmt.h:54:1: + S_IRWXO = 0000007 // _s_ifmt.h:59:1: + S_IRWXU = 0000700 // _s_ifmt.h:49:1: + S_ISGID = 0002000 // _s_ifmt.h:65:1: + S_ISTXT = 512 // _s_ifmt.h:69:1: + S_ISUID = 0004000 // _s_ifmt.h:64:1: + S_ISVTX = 0001000 // _s_ifmt.h:66:1: + S_IWGRP = 0000020 // _s_ifmt.h:56:1: + S_IWOTH = 0000002 // _s_ifmt.h:61:1: + S_IWRITE = 128 // _s_ifmt.h:71:1: + S_IWUSR = 0000200 // _s_ifmt.h:51:1: + S_IXGRP = 0000010 // _s_ifmt.h:57:1: + S_IXOTH = 0000001 // _s_ifmt.h:62:1: + S_IXUSR = 0000100 // _s_ifmt.h:52:1: + UF_APPEND = 0x00000004 // stat.h:313:1: + UF_COMPRESSED = 0x00000020 // stat.h:320:1: + UF_DATAVAULT = 0x00000080 // stat.h:326:1: + UF_HIDDEN = 0x00008000 // stat.h:330:1: + UF_IMMUTABLE = 0x00000002 // stat.h:312:1: + UF_NODUMP = 0x00000001 // stat.h:311:1: + UF_OPAQUE = 0x00000008 // stat.h:314:1: + UF_SETTABLE = 0x0000ffff // stat.h:310:1: + UF_TRACKED = 0x00000040 // stat.h:324:1: + UTIME_NOW = -1 // stat.h:395:1: + UTIME_OMIT = -2 // stat.h:396:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_FILESEC_T = 0 // _filesec_t.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_SYS_STAT_H_ = 0 // stat.h:71:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2014 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)stat.h 8.9 (Berkeley) 8/17/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// [XSI] The timespec structure may be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +// [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t, +// gid_t, off_t, and time_t types shall be defined as described in +// . +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// XXX So deprecated, it would make your head spin +// +// The old stat structure. In fact, this is not used by the kernel at all, +// and should not be used by user space, and should be removed from this +// header file entirely (along with the unused cvtstat() prototype in +// vnode_internal.h). +type Ostat = struct { + Fst_dev X__uint16_t + F__ccgo_pad1 [6]byte + Fst_ino Ino_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_uid X__uint16_t + Fst_gid X__uint16_t + Fst_rdev X__uint16_t + F__ccgo_pad2 [2]byte + Fst_size X__int32_t + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_blksize X__int32_t + Fst_blocks X__int32_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t +} /* stat.h:110:1 */ + +// This structure is used as the second parameter to the fstat64(), +// lstat64(), and stat64() functions, and for struct stat when +// __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined +// above, depending on whether we use struct timespec or the direct +// components. +// +// This is simillar to stat except for 64bit inode number +// number instead of 32bit ino_t and the addition of create(birth) time. + +// [XSI] This structure is used as the second parameter to the fstat(), +// lstat(), and stat() functions. + +type Stat = struct { + Fst_dev Dev_t + Fst_mode Mode_t + Fst_nlink Nlink_t + Fst_ino X__darwin_ino64_t + Fst_uid Uid_t + Fst_gid Gid_t + Fst_rdev Dev_t + F__ccgo_pad1 [4]byte + Fst_atimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_mtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_ctimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_birthtimespec struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 + } + Fst_size Off_t + Fst_blocks Blkcnt_t + Fst_blksize Blksize_t + Fst_flags X__uint32_t + Fst_gen X__uint32_t + Fst_lspare X__int32_t + Fst_qspare [2]X__int64_t +} /* stat.h:182:1 */ + +type Filesec_t = uintptr /* _filesec_t.h:31:25 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/stat/stat_linux_amd64.go b/internal/libc/sys/stat/stat_linux_amd64.go new file mode 100644 index 0000000..b0349cc --- /dev/null +++ b/internal/libc/sys/stat/stat_linux_amd64.go @@ -0,0 +1,947 @@ +// Code generated by 'ccgo sys/stat/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/stat/stat_linux_amd64.go -pkgname stat', DO NOT EDIT. + +package stat + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSPERMS = 511 // stat.h:195:1: + ALLPERMS = 4095 // stat.h:196:1: + DEFFILEMODE = 438 // stat.h:197:1: + S_BLKSIZE = 512 // stat.h:199:1: + S_IEXEC = 64 // stat.h:177:1: + S_IFBLK = 24576 // stat.h:107:1: + S_IFCHR = 8192 // stat.h:106:1: + S_IFDIR = 16384 // stat.h:105:1: + S_IFIFO = 4096 // stat.h:110:1: + S_IFLNK = 40960 // stat.h:113:1: + S_IFMT = 61440 // stat.h:104:1: + S_IFREG = 32768 // stat.h:108:1: + S_IFSOCK = 49152 // stat.h:117:1: + S_IREAD = 256 // stat.h:175:1: + S_IRGRP = 32 // stat.h:180:1: + S_IROTH = 4 // stat.h:186:1: + S_IRUSR = 256 // stat.h:168:1: + S_IRWXG = 56 // stat.h:184:1: + S_IRWXO = 7 // stat.h:190:1: + S_IRWXU = 448 // stat.h:172:1: + S_ISGID = 1024 // stat.h:161:1: + S_ISUID = 2048 // stat.h:160:1: + S_ISVTX = 512 // stat.h:165:1: + S_IWGRP = 16 // stat.h:181:1: + S_IWOTH = 2 // stat.h:187:1: + S_IWRITE = 128 // stat.h:176:1: + S_IWUSR = 128 // stat.h:169:1: + S_IXGRP = 8 // stat.h:182:1: + S_IXOTH = 1 // stat.h:188:1: + S_IXUSR = 64 // stat.h:170:1: + UTIME_NOW = 1073741823 // stat.h:206:1: + UTIME_OMIT = 1073741822 // stat.h:207:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_STAT_H = 1 // stat.h:23:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :284:1: + X_MKNOD_VER = 0 // stat.h:390:1: + X_MKNOD_VER_LINUX = 0 // stat.h:41:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_STATBUF_ST_BLKSIZE = 0 // stat.h:172:1: + X_STATBUF_ST_NSEC = 0 // stat.h:175:1: + X_STATBUF_ST_RDEV = 0 // stat.h:173:1: + X_STAT_VER = 1 // stat.h:44:1: + X_STAT_VER_KERNEL = 0 // stat.h:37:1: + X_STAT_VER_LINUX = 1 // stat.h:38:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_STAT_H = 1 // stat.h:23:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 5.6 File Characteristics + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// i386/x86_64 are little-endian. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +// The Single Unix specification says that some more types are +// available here. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +type Dev_t = X__dev_t /* stat.h:40:17 */ + +type Gid_t = X__gid_t /* stat.h:45:17 */ + +type Ino_t = X__ino64_t /* stat.h:53:19 */ + +type Mode_t = X__mode_t /* stat.h:59:18 */ + +type Nlink_t = X__nlink_t /* stat.h:64:19 */ + +type Off_t = X__off64_t /* stat.h:72:19 */ + +type Uid_t = X__uid_t /* stat.h:78:17 */ + +// Copyright (C) 1999-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Versions of the `struct stat' data structure. + +// x86-64 versions of the `xmknod' interface. + +type Stat = struct { + Fst_dev X__dev_t + Fst_ino X__ino_t + Fst_nlink X__nlink_t + Fst_mode X__mode_t + Fst_uid X__uid_t + Fst_gid X__gid_t + F__pad0 int32 + Fst_rdev X__dev_t + Fst_size X__off_t + Fst_blksize X__blksize_t + Fst_blocks X__blkcnt_t + Fst_atim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_mtim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_ctim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + F__glibc_reserved [3]X__syscall_slong_t +} /* stat.h:46:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/stat/stat_linux_arm64.go b/internal/libc/sys/stat/stat_linux_arm64.go new file mode 100644 index 0000000..b5bc656 --- /dev/null +++ b/internal/libc/sys/stat/stat_linux_arm64.go @@ -0,0 +1,1060 @@ +// Code generated by 'ccgo sys/stat/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o sys/stat/stat_linux_arm64.go -pkgname stat', DO NOT EDIT. + +package stat + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSPERMS = 511 + ALLPERMS = 4095 + DEFFILEMODE = 438 + S_BLKSIZE = 512 + S_IEXEC = 64 + S_IFBLK = 24576 + S_IFCHR = 8192 + S_IFDIR = 16384 + S_IFIFO = 4096 + S_IFLNK = 40960 + S_IFMT = 61440 + S_IFREG = 32768 + S_IFSOCK = 49152 + S_IREAD = 256 + S_IRGRP = 32 + S_IROTH = 4 + S_IRUSR = 256 + S_IRWXG = 56 + S_IRWXO = 7 + S_IRWXU = 448 + S_ISGID = 1024 + S_ISUID = 2048 + S_ISVTX = 512 + S_IWGRP = 16 + S_IWOTH = 2 + S_IWRITE = 128 + S_IWUSR = 128 + S_IXGRP = 8 + S_IXOTH = 1 + S_IXUSR = 64 + UTIME_NOW = 1073741823 + UTIME_OMIT = 1073741822 + X_ATFILE_SOURCE = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_STAT_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_LP64 = 1 + X_MKNOD_VER = 0 + X_MKNOD_VER_LINUX = 0 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_STATBUF_ST_BLKSIZE = 0 + X_STATBUF_ST_NSEC = 0 + X_STATBUF_ST_RDEV = 0 + X_STAT_VER = 0 + X_STAT_VER_KERNEL = 0 + X_STAT_VER_LINUX = 0 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_STAT_H = 1 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 5.6 File Characteristics + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// AArch64 has selectable endianness. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +// The Single Unix specification says that some more types are +// available here. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +type Dev_t = X__dev_t /* stat.h:40:17 */ + +type Gid_t = X__gid_t /* stat.h:45:17 */ + +type Ino_t = X__ino64_t /* stat.h:53:19 */ + +type Mode_t = X__mode_t /* stat.h:59:18 */ + +type Nlink_t = X__nlink_t /* stat.h:64:19 */ + +type Off_t = X__off64_t /* stat.h:72:19 */ + +type Uid_t = X__uid_t /* stat.h:78:17 */ + +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// 64-bit libc uses the kernel's 'struct stat', accessed via the +// stat() syscall; 32-bit libc uses the kernel's 'struct stat64' +// and accesses it via the stat64() syscall. All the various +// APIs offered by libc use the kernel shape for their struct stat +// structure; the only difference is that 32-bit programs not +// using __USE_FILE_OFFSET64 only see the low 32 bits of some +// of the fields (specifically st_ino, st_size, and st_blocks). + +// Versions of the `xmknod' interface. + +type Stat = struct { + Fst_dev X__dev_t + Fst_ino X__ino64_t + Fst_mode X__mode_t + Fst_nlink X__nlink_t + Fst_uid X__uid_t + Fst_gid X__gid_t + Fst_rdev X__dev_t + F__pad1 X__dev_t + Fst_size X__off64_t + Fst_blksize X__blksize_t + F__pad2 int32 + Fst_blocks X__blkcnt64_t + Fst_atim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_mtim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fst_ctim struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + F__glibc_reserved [2]int32 +} /* stat.h:58:1 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/types/capi_darwin_amd64.go b/internal/libc/sys/types/capi_darwin_amd64.go new file mode 100644 index 0000000..b8090d4 --- /dev/null +++ b/internal/libc/sys/types/capi_darwin_amd64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo sys/types/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/types/types_darwin_amd64.go -pkgname types', DO NOT EDIT. + +package types + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/sys/types/capi_darwin_arm64.go b/internal/libc/sys/types/capi_darwin_arm64.go new file mode 100644 index 0000000..a5626d1 --- /dev/null +++ b/internal/libc/sys/types/capi_darwin_arm64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo sys/types/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/types/types_darwin_arm64.go -pkgname types', DO NOT EDIT. + +package types + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/sys/types/capi_linux_amd64.go b/internal/libc/sys/types/capi_linux_amd64.go new file mode 100644 index 0000000..7628006 --- /dev/null +++ b/internal/libc/sys/types/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo sys/types/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/types/types_linux_amd64.go -pkgname types', DO NOT EDIT. + +package types + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/sys/types/capi_linux_arm64.go b/internal/libc/sys/types/capi_linux_arm64.go new file mode 100644 index 0000000..4ec64ab --- /dev/null +++ b/internal/libc/sys/types/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo sys/types/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o sys/types/types_linux_arm64.go -pkgname types', DO NOT EDIT. + +package types + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/sys/types/types_darwin_amd64.go b/internal/libc/sys/types/types_darwin_amd64.go new file mode 100644 index 0000000..dab002c --- /dev/null +++ b/internal/libc/sys/types/types_darwin_amd64.go @@ -0,0 +1,4006 @@ +// Code generated by 'ccgo sys/types/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/types/types_darwin_amd64.go -pkgname types', DO NOT EDIT. + +package types + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 // endian.h:94:1: + BYTE_ORDER = 1234 // endian.h:97:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + LITTLE_ENDIAN = 1234 // endian.h:93:1: + NBBY = 8 // types.h:186:1: + PDP_ENDIAN = 3412 // endian.h:95:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_I386__ENDIAN_H_ = 0 // endian.h:67:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS__OSBYTEORDERI386_H = 0 // _OSByteOrder.h:30:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:78:1: + X_QUAD_LOWWORD = 0 // endian.h:79:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1991, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)types.h 8.4 (Berkeley) 1/21/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Machine type dependent parameters. +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/types/types_darwin_arm64.go b/internal/libc/sys/types/types_darwin_arm64.go new file mode 100644 index 0000000..70f8b80 --- /dev/null +++ b/internal/libc/sys/types/types_darwin_arm64.go @@ -0,0 +1,4136 @@ +// Code generated by 'ccgo sys/types/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/types/types_darwin_arm64.go -pkgname types', DO NOT EDIT. + +package types + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 // endian.h:72:1: + BYTE_ORDER = 1234 // endian.h:75:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + INT16_MAX = 32767 // stdint.h:599:1: + INT16_MIN = -32768 // stdint.h:600:1: + INT32_MAX = 2147483647 // stdint.h:555:1: + INT32_MIN = -2147483648 // stdint.h:556:1: + INT64_MAX = 9223372036854775807 // stdint.h:461:1: + INT64_MIN = -9223372036854775808 // stdint.h:462:1: + INT8_MAX = 127 // stdint.h:621:1: + INT8_MIN = -128 // stdint.h:622:1: + INTMAX_MAX = 9223372036854775807 // stdint.h:663:1: + INTMAX_MIN = -9223372036854775808 // stdint.h:662:1: + INTPTR_MAX = 9223372036854775807 // stdint.h:649:1: + INTPTR_MIN = -9223372036854775808 // stdint.h:648:1: + INT_FAST16_MAX = 32767 // stdint.h:615:1: + INT_FAST16_MIN = -32768 // stdint.h:614:1: + INT_FAST32_MAX = 2147483647 // stdint.h:574:1: + INT_FAST32_MIN = -2147483648 // stdint.h:573:1: + INT_FAST64_MAX = 9223372036854775807 // stdint.h:483:1: + INT_FAST64_MIN = -9223372036854775808 // stdint.h:482:1: + INT_FAST8_MAX = 127 // stdint.h:634:1: + INT_FAST8_MIN = -128 // stdint.h:633:1: + INT_LEAST16_MAX = 32767 // stdint.h:612:1: + INT_LEAST16_MIN = -32768 // stdint.h:611:1: + INT_LEAST32_MAX = 2147483647 // stdint.h:571:1: + INT_LEAST32_MIN = -2147483648 // stdint.h:570:1: + INT_LEAST64_MAX = 9223372036854775807 // stdint.h:480:1: + INT_LEAST64_MIN = -9223372036854775808 // stdint.h:479:1: + INT_LEAST8_MAX = 127 // stdint.h:631:1: + INT_LEAST8_MIN = -128 // stdint.h:630:1: + LITTLE_ENDIAN = 1234 // endian.h:71:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + NBBY = 8 // types.h:186:1: + PDP_ENDIAN = 3412 // endian.h:73:1: + PTRDIFF_MAX = 9223372036854775807 // stdint.h:652:1: + PTRDIFF_MIN = -9223372036854775808 // stdint.h:651:1: + RSIZE_MAX = 9223372036854775807 // stdint.h:658:1: + SIG_ATOMIC_MAX = 2147483647 // stdint.h:668:1: + SIG_ATOMIC_MIN = -2147483648 // stdint.h:667:1: + SIZE_MAX = 18446744073709551615 // stdint.h:653:1: + UINT16_MAX = 65535 // stdint.h:601:1: + UINT32_MAX = 4294967295 // stdint.h:557:1: + UINT64_MAX = 18446744073709551615 // stdint.h:463:1: + UINT8_MAX = 255 // stdint.h:623:1: + UINTMAX_MAX = 18446744073709551615 // stdint.h:664:1: + UINTPTR_MAX = 18446744073709551615 // stdint.h:650:1: + UINT_FAST16_MAX = 65535 // stdint.h:616:1: + UINT_FAST32_MAX = 4294967295 // stdint.h:575:1: + UINT_FAST64_MAX = 18446744073709551615 // stdint.h:484:1: + UINT_FAST8_MAX = 255 // stdint.h:635:1: + UINT_LEAST16_MAX = 65535 // stdint.h:613:1: + UINT_LEAST32_MAX = 4294967295 // stdint.h:572:1: + UINT_LEAST64_MAX = 18446744073709551615 // stdint.h:481:1: + UINT_LEAST8_MAX = 255 // stdint.h:632:1: + WCHAR_MAX = 2147483647 // stdint.h:678:1: + WCHAR_MIN = -2147483648 // stdint.h:682:1: + WINT_MAX = 2147483647 // stdint.h:674:1: + WINT_MIN = -2147483648 // stdint.h:673:1: + X_ARM_ARCH_H = 0 // arch.h:29:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_ARM__ENDIAN_H_ = 0 // endian.h:43:1: + X_BLKCNT_T = 0 // _blkcnt_t.h:29:1: + X_BLKSIZE_T = 0 // _blksize_t.h:29:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_ENDIAN_H_ = 0 // endian.h:32:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CADDR_T = 0 // _caddr_t.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_ERRNO_T = 0 // _errno_t.h:29:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FSBLKCNT_T = 0 // _fsblkcnt_t.h:29:1: + X_FSFILCNT_T = 0 // _fsfilcnt_t.h:29:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_ID_T = 0 // _id_t.h:29:1: + X_INO64_T = 0 // _ino64_t.h:29:1: + X_INO_T = 0 // _ino_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_IN_ADDR_T = 0 // _in_addr_t.h:29:1: + X_IN_PORT_T = 0 // _in_port_t.h:29:1: + X_KEY_T = 0 // _key_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_NLINK_T = 0 // _nlink_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_OS_OSBYTEORDERARM_H = 0 // OSByteOrder.h:6:1: + X_OS__OSBYTEORDER_H = 0 // _OSByteOrder.h:30:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_PTHREAD_ATTR_T = 0 // _pthread_attr_t.h:29:1: + X_PTHREAD_CONDATTR_T = 0 // _pthread_condattr_t.h:29:1: + X_PTHREAD_COND_T = 0 // _pthread_cond_t.h:29:1: + X_PTHREAD_KEY_T = 0 // _pthread_key_t.h:29:1: + X_PTHREAD_MUTEXATTR_T = 0 // _pthread_mutexattr_t.h:29:1: + X_PTHREAD_MUTEX_T = 0 // _pthread_mutex_t.h:29:1: + X_PTHREAD_ONCE_T = 0 // _pthread_once_t.h:29:1: + X_PTHREAD_RWLOCKATTR_T = 0 // _pthread_rwlockattr_t.h:29:1: + X_PTHREAD_RWLOCK_T = 0 // _pthread_rwlock_t.h:29:1: + X_PTHREAD_T = 0 // _pthread_t.h:29:1: + X_QUAD_HIGHWORD = 1 // endian.h:56:1: + X_QUAD_LOWWORD = 0 // endian.h:57:1: + X_RSIZE_T = 0 // _rsize_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_TYPES_H_ = 0 // types.h:70:1: + X_SYS__ENDIAN_H_ = 0 // _endian.h:91:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_U_CHAR = 0 // _u_char.h:29:1: + X_U_INT = 0 // _u_int.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_U_LONG = 0 // types.h:89:1: + X_U_SHORT = 0 // _u_short.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1982, 1986, 1991, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)types.h 8.4 (Berkeley) 1/21/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Machine type dependent parameters. +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ +type Uint64_t = uint64 /* stdint.h:98:25 */ + +type Int_least64_t = Int64_t /* stdint.h:110:25 */ +type Uint_least64_t = Uint64_t /* stdint.h:111:26 */ +type Int_fast64_t = Int64_t /* stdint.h:112:25 */ +type Uint_fast64_t = Uint64_t /* stdint.h:113:26 */ + +type Uint32_t = uint32 /* stdint.h:172:25 */ + +type Int_least32_t = Int32_t /* stdint.h:184:25 */ +type Uint_least32_t = Uint32_t /* stdint.h:185:26 */ +type Int_fast32_t = Int32_t /* stdint.h:186:25 */ +type Uint_fast32_t = Uint32_t /* stdint.h:187:26 */ +type Uint16_t = uint16 /* stdint.h:207:25 */ + +type Int_least16_t = Int16_t /* stdint.h:215:25 */ +type Uint_least16_t = Uint16_t /* stdint.h:216:26 */ +type Int_fast16_t = Int16_t /* stdint.h:217:25 */ +type Uint_fast16_t = Uint16_t /* stdint.h:218:26 */ +type Uint8_t = uint8 /* stdint.h:226:24 */ + +type Int_least8_t = Int8_t /* stdint.h:232:24 */ +type Uint_least8_t = Uint8_t /* stdint.h:233:25 */ +type Int_fast8_t = Int8_t /* stdint.h:234:24 */ +type Uint_fast8_t = Uint8_t /* stdint.h:235:25 */ + +// prevent glibc sys/types.h from defining conflicting types + +// C99 7.18.1.4 Integer types capable of holding object pointers. + +// C99 7.18.1.5 Greatest-width integer types. +type Intmax_t = int64 /* stdint.h:262:26 */ +type Uintmax_t = uint64 /* stdint.h:263:26 */ + +// Functions for byte reversed loads. + +type X_OSUnalignedU16 = struct{ F__val Uint16_t } /* OSByteOrder.h:64:1 */ + +type X_OSUnalignedU32 = struct{ F__val Uint32_t } /* OSByteOrder.h:68:1 */ + +type X_OSUnalignedU64 = struct{ F__val Uint64_t } /* OSByteOrder.h:72:1 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_char = uint8 /* _u_char.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_short = uint16 /* _u_short.h:30:25 */ +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int = uint32 /* _u_int.h:30:25 */ +type U_long = uint64 /* types.h:88:33 */ +type Ushort = uint16 /* types.h:91:33 */ // Sys V compatibility +type Uint = uint32 /* types.h:92:33 */ // Sys V compatibility + +type U_quad_t = U_int64_t /* types.h:95:33 */ // quads +type Quad_t = Int64_t /* types.h:96:33 */ +type Qaddr_t = uintptr /* types.h:97:16 */ + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Caddr_t = uintptr /* _caddr_t.h:30:14 */ + +type Daddr_t = Int32_t /* types.h:101:33 */ // disk address + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number + +type Fixpt_t = U_int32_t /* types.h:105:33 */ // fixed point number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blkcnt_t = X__darwin_blkcnt_t /* _blkcnt_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Blksize_t = X__darwin_blksize_t /* _blksize_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_addr_t = X__uint32_t /* _in_addr_t.h:31:25 */ // base type for internet address +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type In_port_t = X__uint16_t /* _in_port_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino_t = X__darwin_ino_t /* _ino_t.h:31:33 */ // inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Ino64_t = X__darwin_ino64_t /* _ino64_t.h:31:33 */ // 64bit inode number + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Key_t = X__int32_t /* _key_t.h:31:26 */ // IPC key (for Sys V IPC) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Nlink_t = X__uint16_t /* _nlink_t.h:31:27 */ // link count +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Id_t = X__darwin_id_t /* _id_t.h:31:25 */ // can hold pid_t, gid_t, or uid_t +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ + +type Segsz_t = Int32_t /* types.h:125:33 */ // segment size +type Swblk_t = Int32_t /* types.h:126:33 */ // swap offset + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ + +// Major, minor numbers, dev_t's. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Rsize_t = X__darwin_size_t /* _rsize_t.h:31:32 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Errno_t = int32 /* _errno_t.h:30:32 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// This code is present here in order to maintain historical backward +// compatability, and is intended to be removed at some point in the +// future; please include instead. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +type Fd_mask = X__int32_t /* types.h:189:25 */ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_attr_t = X__darwin_pthread_attr_t /* _pthread_attr_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_cond_t = X__darwin_pthread_cond_t /* _pthread_cond_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_condattr_t = X__darwin_pthread_condattr_t /* _pthread_condattr_t.h:31:37 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutex_t = X__darwin_pthread_mutex_t /* _pthread_mutex_t.h:31:34 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_mutexattr_t = X__darwin_pthread_mutexattr_t /* _pthread_mutexattr_t.h:31:38 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_once_t = X__darwin_pthread_once_t /* _pthread_once_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlock_t = X__darwin_pthread_rwlock_t /* _pthread_rwlock_t.h:31:35 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_rwlockattr_t = X__darwin_pthread_rwlockattr_t /* _pthread_rwlockattr_t.h:31:39 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_t = X__darwin_pthread_t /* _pthread_t.h:31:28 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pthread_key_t = X__darwin_pthread_key_t /* _pthread_key_t.h:31:32 */ + +// statvfs and fstatvfs + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsblkcnt_t = X__darwin_fsblkcnt_t /* _fsblkcnt_t.h:31:41 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Fsfilcnt_t = X__darwin_fsfilcnt_t /* _fsfilcnt_t.h:31:41 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/types/types_linux_amd64.go b/internal/libc/sys/types/types_linux_amd64.go new file mode 100644 index 0000000..030eb38 --- /dev/null +++ b/internal/libc/sys/types/types_linux_amd64.go @@ -0,0 +1,1511 @@ +// Code generated by 'ccgo sys/types/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o sys/types/types_linux_amd64.go -pkgname types', DO NOT EDIT. + +package types + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 // endian.h:28:1: + BYTE_ORDER = 1234 // endian.h:30:1: + FD_SETSIZE = 1024 // select.h:73:1: + LITTLE_ENDIAN = 1234 // endian.h:27:1: + PDP_ENDIAN = 3412 // endian.h:29:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_ENDIAN_H = 1 // endian.h:19:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SELECT_H = 1 // select.h:22:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_SYS_TYPES_H = 1 // types.h:23:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/sys/types/types_linux_arm64.go b/internal/libc/sys/types/types_linux_arm64.go new file mode 100644 index 0000000..ca8f031 --- /dev/null +++ b/internal/libc/sys/types/types_linux_arm64.go @@ -0,0 +1,1614 @@ +// Code generated by 'ccgo sys/types/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o sys/types/types_linux_arm64.go -pkgname types', DO NOT EDIT. + +package types + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 + BYTE_ORDER = 1234 + FD_SETSIZE = 1024 + LITTLE_ENDIAN = 1234 + PDP_ENDIAN = 3412 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_TYPES_H = 1 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We don't use `memset' because this would require a prototype and +// the array isn't too big. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/syscall_musl.go b/internal/libc/syscall_musl.go new file mode 100644 index 0000000..13b4bed --- /dev/null +++ b/internal/libc/syscall_musl.go @@ -0,0 +1,90 @@ +// Copyright 2024 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm) + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "golang.org/x/sys/unix" + "runtime" +) + +func ___syscall_cp(tls *TLS, n, a, b, c, d, e, f long) long { + r1, _, err := (unix.Syscall6(uintptr(n), uintptr(a), uintptr(b), uintptr(c), uintptr(d), uintptr(e), uintptr(f))) + if err != 0 { + return long(-err) + } + + return long(r1) +} + +func X__syscall0(tls *TLS, n long) long { + switch n { + case __NR_sched_yield: + runtime.Gosched() + return 0 + default: + r1, _, err := unix.Syscall(uintptr(n), 0, 0, 0) + if err != 0 { + return long(-err) + } + + return long(r1) + } +} + +func X__syscall1(tls *TLS, n, a1 long) long { + r1, _, err := unix.Syscall(uintptr(n), uintptr(a1), 0, 0) + if err != 0 { + return long(-err) + } + + return long(r1) +} + +func X__syscall2(tls *TLS, n, a1, a2 long) long { + r1, _, err := unix.Syscall(uintptr(n), uintptr(a1), uintptr(a2), 0) + if err != 0 { + return long(-err) + } + + return long(r1) +} + +func X__syscall3(tls *TLS, n, a1, a2, a3 long) long { + r1, _, err := unix.Syscall(uintptr(n), uintptr(a1), uintptr(a2), uintptr(a3)) + if err != 0 { + return long(-err) + } + + return long(r1) +} + +func X__syscall4(tls *TLS, n, a1, a2, a3, a4 long) long { + r1, _, err := unix.Syscall6(uintptr(n), uintptr(a1), uintptr(a2), uintptr(a3), uintptr(a4), 0, 0) + if err != 0 { + return long(-err) + } + + return long(r1) +} + +func X__syscall5(tls *TLS, n, a1, a2, a3, a4, a5 long) long { + r1, _, err := unix.Syscall6(uintptr(n), uintptr(a1), uintptr(a2), uintptr(a3), uintptr(a4), uintptr(a5), 0) + if err != 0 { + return long(-err) + } + + return long(r1) +} + +func X__syscall6(tls *TLS, n, a1, a2, a3, a4, a5, a6 long) long { + r1, _, err := unix.Syscall6(uintptr(n), uintptr(a1), uintptr(a2), uintptr(a3), uintptr(a4), uintptr(a5), uintptr(a6)) + if err != 0 { + return long(-err) + } + + return long(r1) +} diff --git a/internal/libc/termios/capi_darwin_amd64.go b/internal/libc/termios/capi_darwin_amd64.go new file mode 100644 index 0000000..32f78c4 --- /dev/null +++ b/internal/libc/termios/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo termios/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o termios/termios_darwin_amd64.go -pkgname termios', DO NOT EDIT. + +package termios + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/termios/capi_darwin_arm64.go b/internal/libc/termios/capi_darwin_arm64.go new file mode 100644 index 0000000..f663be1 --- /dev/null +++ b/internal/libc/termios/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo termios/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o termios/termios_darwin_arm64.go -pkgname termios', DO NOT EDIT. + +package termios + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/termios/capi_linux_amd64.go b/internal/libc/termios/capi_linux_amd64.go new file mode 100644 index 0000000..193dc60 --- /dev/null +++ b/internal/libc/termios/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo termios/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o termios/termios_linux_amd64.go -pkgname termios', DO NOT EDIT. + +package termios + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/termios/capi_linux_arm64.go b/internal/libc/termios/capi_linux_arm64.go new file mode 100644 index 0000000..f94925e --- /dev/null +++ b/internal/libc/termios/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo termios/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o termios/termios_linux_arm64.go -pkgname termios', DO NOT EDIT. + +package termios + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/termios/termios_darwin_amd64.go b/internal/libc/termios/termios_darwin_amd64.go new file mode 100644 index 0000000..10a7e68 --- /dev/null +++ b/internal/libc/termios/termios_darwin_amd64.go @@ -0,0 +1,1567 @@ +// Code generated by 'ccgo termios/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o termios/termios_darwin_amd64.go -pkgname termios', DO NOT EDIT. + +package termios + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ALTWERASE = 0x00000200 // termios.h:249:1: + B0 = 0 // termios.h:291:1: + B110 = 110 // termios.h:294:1: + B115200 = 115200 // termios.h:313:1: + B1200 = 1200 // termios.h:300:1: + B134 = 134 // termios.h:295:1: + B14400 = 14400 // termios.h:309:1: + B150 = 150 // termios.h:296:1: + B1800 = 1800 // termios.h:301:1: + B19200 = 19200 // termios.h:305:1: + B200 = 200 // termios.h:297:1: + B230400 = 230400 // termios.h:314:1: + B2400 = 2400 // termios.h:302:1: + B28800 = 28800 // termios.h:310:1: + B300 = 300 // termios.h:298:1: + B38400 = 38400 // termios.h:306:1: + B4800 = 4800 // termios.h:303:1: + B50 = 50 // termios.h:292:1: + B57600 = 57600 // termios.h:311:1: + B600 = 600 // termios.h:299:1: + B7200 = 7200 // termios.h:308:1: + B75 = 75 // termios.h:293:1: + B76800 = 76800 // termios.h:312:1: + B9600 = 9600 // termios.h:304:1: + BRKINT = 0x00000002 // termios.h:120:1: + BS0 = 0x00000000 // termios.h:190:1: + BS1 = 0x00008000 // termios.h:191:1: + BSDLY = 0x00008000 // termios.h:159:1: + CBRK = 255 // ttydefaults.h:107:1: + CCAR_OFLOW = 0x00100000 // termios.h:222:1: + CCTS_OFLOW = 0x00010000 // termios.h:217:1: + CDISCARD = 15 // ttydefaults.h:102:1: + CDSR_OFLOW = 0x00080000 // termios.h:221:1: + CDSUSP = 25 // ttydefaults.h:98:1: + CDTR_IFLOW = 0x00040000 // termios.h:220:1: + CEOF = 4 // ttydefaults.h:88:1: + CEOL = 0xff // ttydefaults.h:89:1: + CEOT = 4 // ttydefaults.h:105:1: + CERASE = 0177 // ttydefaults.h:90:1: + CFLUSH = 15 // ttydefaults.h:109:1: + CIGNORE = 0x00000001 // termios.h:203:1: + CINTR = 3 // ttydefaults.h:91:1: + CKILL = 21 // ttydefaults.h:93:1: + CLNEXT = 22 // ttydefaults.h:101:1: + CLOCAL = 0x00008000 // termios.h:215:1: + CMIN = 1 // ttydefaults.h:94:1: + CQUIT = 034 // ttydefaults.h:95:1: + CR0 = 0x00000000 // termios.h:184:1: + CR1 = 0x00001000 // termios.h:185:1: + CR2 = 0x00002000 // termios.h:186:1: + CR3 = 0x00003000 // termios.h:187:1: + CRDLY = 0x00003000 // termios.h:157:1: + CREAD = 0x00000800 // termios.h:211:1: + CREPRINT = 18 // ttydefaults.h:104:1: + CRPRNT = 18 // ttydefaults.h:108:1: + CRTSCTS = 196608 // termios.h:218:1: + CRTS_IFLOW = 0x00020000 // termios.h:219:1: + CS5 = 0x00000000 // termios.h:206:1: + CS6 = 0x00000100 // termios.h:207:1: + CS7 = 0x00000200 // termios.h:208:1: + CS8 = 0x00000300 // termios.h:209:1: + CSIZE = 0x00000300 // termios.h:205:1: + CSTART = 17 // ttydefaults.h:99:1: + CSTATUS = 20 // ttydefaults.h:92:1: + CSTOP = 19 // ttydefaults.h:100:1: + CSTOPB = 0x00000400 // termios.h:210:1: + CSUSP = 26 // ttydefaults.h:96:1: + CTIME = 0 // ttydefaults.h:97:1: + CWERASE = 23 // ttydefaults.h:103:1: + ECHO = 0x00000008 // termios.h:240:1: + ECHOCTL = 0x00000040 // termios.h:244:1: + ECHOE = 0x00000002 // termios.h:238:1: + ECHOK = 0x00000004 // termios.h:239:1: + ECHOKE = 0x00000001 // termios.h:236:1: + ECHONL = 0x00000010 // termios.h:241:1: + ECHOPRT = 0x00000020 // termios.h:243:1: + EXTA = 19200 // termios.h:315:1: + EXTB = 38400 // termios.h:316:1: + EXTPROC = 0x00000800 // termios.h:253:1: + FF0 = 0x00000000 // termios.h:188:1: + FF1 = 0x00004000 // termios.h:189:1: + FFDLY = 0x00004000 // termios.h:158:1: + FLUSHO = 0x00800000 // termios.h:257:1: + HUPCL = 0x00004000 // termios.h:214:1: + ICANON = 0x00000100 // termios.h:247:1: + ICRNL = 0x00000100 // termios.h:127:1: + IEXTEN = 0x00000400 // termios.h:251:1: + IGNBRK = 0x00000001 // termios.h:119:1: + IGNCR = 0x00000080 // termios.h:126:1: + IGNPAR = 0x00000004 // termios.h:121:1: + IMAXBEL = 0x00002000 // termios.h:132:1: + INLCR = 0x00000040 // termios.h:125:1: + INPCK = 0x00000010 // termios.h:123:1: + IOCPARM_MASK = 0x1fff // ioccom.h:74:1: + IOCPARM_MAX = 8192 // ioccom.h:79:1: + ISIG = 0x00000080 // termios.h:246:1: + ISTRIP = 0x00000020 // termios.h:124:1: + IUTF8 = 0x00004000 // termios.h:133:1: + IXANY = 0x00000800 // termios.h:130:1: + IXOFF = 0x00000400 // termios.h:129:1: + IXON = 0x00000200 // termios.h:128:1: + MDMBUF = 0x00100000 // termios.h:223:1: + NCCS = 20 // termios.h:108:1: + NL0 = 0x00000000 // termios.h:173:1: + NL1 = 0x00000100 // termios.h:174:1: + NL2 = 0x00000200 // termios.h:176:1: + NL3 = 0x00000300 // termios.h:177:1: + NLDLY = 0x00000300 // termios.h:155:1: + NOFLSH = 0x80000000 // termios.h:261:1: + NOKERNINFO = 0x02000000 // termios.h:258:1: + OCRNL = 0x00000010 // termios.h:151:1: + OFDEL = 0x00020000 // termios.h:161:1: + OFILL = 0x00000080 // termios.h:154:1: + ONLCR = 0x00000002 // termios.h:140:1: + ONLRET = 0x00000040 // termios.h:153:1: + ONOCR = 0x00000020 // termios.h:152:1: + ONOEOT = 0x00000008 // termios.h:143:1: + OPOST = 0x00000001 // termios.h:139:1: + OXTABS = 0x00000004 // termios.h:142:1: + PARENB = 0x00001000 // termios.h:212:1: + PARMRK = 0x00000008 // termios.h:122:1: + PARODD = 0x00002000 // termios.h:213:1: + PENDIN = 0x20000000 // termios.h:259:1: + PPPDISC = 5 // ttycom.h:171:1: + SLIPDISC = 4 // ttycom.h:170:1: + TAB0 = 0x00000000 // termios.h:179:1: + TAB1 = 0x00000400 // termios.h:180:1: + TAB2 = 0x00000800 // termios.h:181:1: + TAB3 = 0x00000004 // termios.h:183:1: + TABDLY = 0x00000c04 // termios.h:156:1: + TABLDISC = 3 // ttycom.h:169:1: + TCIFLUSH = 1 // termios.h:320:1: + TCIOFF = 3 // termios.h:325:1: + TCIOFLUSH = 3 // termios.h:322:1: + TCION = 4 // termios.h:326:1: + TCOFLUSH = 2 // termios.h:321:1: + TCOOFF = 1 // termios.h:323:1: + TCOON = 2 // termios.h:324:1: + TCSADRAIN = 1 // termios.h:282:1: + TCSAFLUSH = 2 // termios.h:283:1: + TCSANOW = 0 // termios.h:281:1: + TCSASOFT = 0x10 // termios.h:285:1: + TIOCM_CAR = 0100 // ttycom.h:97:1: + TIOCM_CD = 64 // ttycom.h:98:1: + TIOCM_CTS = 0040 // ttycom.h:96:1: + TIOCM_DSR = 0400 // ttycom.h:101:1: + TIOCM_DTR = 0002 // ttycom.h:92:1: + TIOCM_LE = 0001 // ttycom.h:91:1: + TIOCM_RI = 128 // ttycom.h:100:1: + TIOCM_RNG = 0200 // ttycom.h:99:1: + TIOCM_RTS = 0004 // ttycom.h:93:1: + TIOCM_SR = 0020 // ttycom.h:95:1: + TIOCM_ST = 0010 // ttycom.h:94:1: + TIOCPKT_DATA = 0x00 // ttycom.h:128:1: + TIOCPKT_DOSTOP = 0x20 // ttycom.h:134:1: + TIOCPKT_FLUSHREAD = 0x01 // ttycom.h:129:1: + TIOCPKT_FLUSHWRITE = 0x02 // ttycom.h:130:1: + TIOCPKT_IOCTL = 0x40 // ttycom.h:135:1: + TIOCPKT_NOSTOP = 0x10 // ttycom.h:133:1: + TIOCPKT_START = 0x08 // ttycom.h:132:1: + TIOCPKT_STOP = 0x04 // ttycom.h:131:1: + TOSTOP = 0x00400000 // termios.h:255:1: + TTYDEF_CFLAG = 19200 // ttydefaults.h:81:1: + TTYDEF_IFLAG = 11010 // ttydefaults.h:78:1: + TTYDEF_LFLAG = 1483 // ttydefaults.h:80:1: + TTYDEF_OFLAG = 3 // ttydefaults.h:79:1: + TTYDEF_SPEED = 9600 // ttydefaults.h:82:1: + TTYDISC = 0 // ttycom.h:168:1: + VDISCARD = 15 // termios.h:100:1: + VDSUSP = 11 // termios.h:94:1: + VEOF = 0 // termios.h:76:1: + VEOL = 1 // termios.h:77:1: + VEOL2 = 2 // termios.h:79:1: + VERASE = 3 // termios.h:81:1: + VINTR = 8 // termios.h:90:1: + VKILL = 5 // termios.h:85:1: + VLNEXT = 14 // termios.h:99:1: + VMIN = 16 // termios.h:102:1: + VQUIT = 9 // termios.h:91:1: + VREPRINT = 6 // termios.h:87:1: + VSTART = 12 // termios.h:96:1: + VSTATUS = 18 // termios.h:105:1: + VSTOP = 13 // termios.h:97:1: + VSUSP = 10 // termios.h:92:1: + VT0 = 0x00000000 // termios.h:192:1: + VT1 = 0x00010000 // termios.h:193:1: + VTDLY = 0x00010000 // termios.h:160:1: + VTIME = 17 // termios.h:103:1: + VWERASE = 4 // termios.h:83:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_SYS_IOCCOM_H_ = 0 // ioccom.h:65:1: + X_SYS_TERMIOS_H_ = 0 // termios.h:65:1: + X_SYS_TTYCOM_H_ = 0 // ttycom.h:70:1: + X_SYS_TTYDEFAULTS_H_ = 0 // ttydefaults.h:73:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved +// Copyright (c) 1988, 1989, 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. +// +// @(#)termios.h 8.3 (Berkeley) 3/28/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Special Control Characters +// +// Index into c_cc[] character array. +// +// Name Subscript Enabled by +// 7 spare 1 +// 19 spare 2 + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Input flags - software input processing + +// Output flags - software output processing +// The following block of features is unimplemented. Use of these flags in +// programs will currently result in unexpected behaviour. +// +// - Begin unimplemented features +// These manifest constants have the same names as those in the header +// , so you are not permitted to have both definitions +// in scope simultaneously in the same compilation unit. Nevertheless, +// they are required to be in scope when _POSIX_C_SOURCE is requested; +// this means that including the header before this +// one when _POSIX_C_SOURCE is in scope will result in redefintions. We +// attempt to maintain these as the same values so as to avoid this being +// an outright error in most compilers. +// not in sys/ioctl_compat.h, use OXTABS value +// + End unimplemented features + +// Control flags - hardware control of terminal + +// "Local" flags - dumping ground for other state +// +// Warning: some flags in this structure begin with +// the letter "I" and look like they belong in the +// input flag. + +type Tcflag_t = uint64 /* termios.h:263:25 */ +type Cc_t = uint8 /* termios.h:264:25 */ +type Speed_t = uint64 /* termios.h:265:25 */ + +type Termios = struct { + Fc_iflag Tcflag_t + Fc_oflag Tcflag_t + Fc_cflag Tcflag_t + Fc_lflag Tcflag_t + Fc_cc [20]Cc_t + F__ccgo_pad1 [4]byte + Fc_ispeed Speed_t + Fc_ospeed Speed_t +} /* termios.h:267:1 */ + +// Include tty ioctl's that aren't just for backwards compatibility +// with the old tty driver. These ioctl definitions were previously +// in . +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 1990, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)ttycom.h 8.1 (Berkeley) 3/28/94 + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 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. +// +// @(#)ioccom.h 8.2 (Berkeley) 3/28/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// 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 3 bits of the +// upper word are used to encode the in/out status of the parameter. + +// no parameters +// copy parameters out +// copy parameters in +// copy paramters in and out +// mask for IN/OUT/VOID + +// this should be _IORW, but stdio got there first + +// Tty ioctl's except for those supported only for backwards compatibility +// with the old tty driver. + +// Window/terminal size structure. This information is stored by the kernel +// in order to provide a consistent interface, but is not used by the kernel. +type Winsize = struct { + Fws_row uint16 + Fws_col uint16 + Fws_xpixel uint16 + Fws_ypixel uint16 +} /* ttycom.h:82:1 */ + +// 8-10 compat +// 15 unused +// 17-18 compat +// 127-124 compat +// 117-116 compat + +// END OF PROTECTED INCLUDE. + +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 + +// System wide defaults for terminal state. + +// Defaults on "first" open. + +// Control Character Defaults +// compat + +// PROTECTED INCLUSION ENDS HERE + +// #define TTYDEFCHARS to include an array of default control characters. +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/termios/termios_darwin_arm64.go b/internal/libc/termios/termios_darwin_arm64.go new file mode 100644 index 0000000..36b4c92 --- /dev/null +++ b/internal/libc/termios/termios_darwin_arm64.go @@ -0,0 +1,1570 @@ +// Code generated by 'ccgo termios/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o termios/termios_darwin_arm64.go -pkgname termios', DO NOT EDIT. + +package termios + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ALTWERASE = 0x00000200 // termios.h:249:1: + B0 = 0 // termios.h:291:1: + B110 = 110 // termios.h:294:1: + B115200 = 115200 // termios.h:313:1: + B1200 = 1200 // termios.h:300:1: + B134 = 134 // termios.h:295:1: + B14400 = 14400 // termios.h:309:1: + B150 = 150 // termios.h:296:1: + B1800 = 1800 // termios.h:301:1: + B19200 = 19200 // termios.h:305:1: + B200 = 200 // termios.h:297:1: + B230400 = 230400 // termios.h:314:1: + B2400 = 2400 // termios.h:302:1: + B28800 = 28800 // termios.h:310:1: + B300 = 300 // termios.h:298:1: + B38400 = 38400 // termios.h:306:1: + B4800 = 4800 // termios.h:303:1: + B50 = 50 // termios.h:292:1: + B57600 = 57600 // termios.h:311:1: + B600 = 600 // termios.h:299:1: + B7200 = 7200 // termios.h:308:1: + B75 = 75 // termios.h:293:1: + B76800 = 76800 // termios.h:312:1: + B9600 = 9600 // termios.h:304:1: + BRKINT = 0x00000002 // termios.h:120:1: + BS0 = 0x00000000 // termios.h:190:1: + BS1 = 0x00008000 // termios.h:191:1: + BSDLY = 0x00008000 // termios.h:159:1: + CBRK = 255 // ttydefaults.h:107:1: + CCAR_OFLOW = 0x00100000 // termios.h:222:1: + CCTS_OFLOW = 0x00010000 // termios.h:217:1: + CDISCARD = 15 // ttydefaults.h:102:1: + CDSR_OFLOW = 0x00080000 // termios.h:221:1: + CDSUSP = 25 // ttydefaults.h:98:1: + CDTR_IFLOW = 0x00040000 // termios.h:220:1: + CEOF = 4 // ttydefaults.h:88:1: + CEOL = 0xff // ttydefaults.h:89:1: + CEOT = 4 // ttydefaults.h:105:1: + CERASE = 0177 // ttydefaults.h:90:1: + CFLUSH = 15 // ttydefaults.h:109:1: + CIGNORE = 0x00000001 // termios.h:203:1: + CINTR = 3 // ttydefaults.h:91:1: + CKILL = 21 // ttydefaults.h:93:1: + CLNEXT = 22 // ttydefaults.h:101:1: + CLOCAL = 0x00008000 // termios.h:215:1: + CMIN = 1 // ttydefaults.h:94:1: + CQUIT = 034 // ttydefaults.h:95:1: + CR0 = 0x00000000 // termios.h:184:1: + CR1 = 0x00001000 // termios.h:185:1: + CR2 = 0x00002000 // termios.h:186:1: + CR3 = 0x00003000 // termios.h:187:1: + CRDLY = 0x00003000 // termios.h:157:1: + CREAD = 0x00000800 // termios.h:211:1: + CREPRINT = 18 // ttydefaults.h:104:1: + CRPRNT = 18 // ttydefaults.h:108:1: + CRTSCTS = 196608 // termios.h:218:1: + CRTS_IFLOW = 0x00020000 // termios.h:219:1: + CS5 = 0x00000000 // termios.h:206:1: + CS6 = 0x00000100 // termios.h:207:1: + CS7 = 0x00000200 // termios.h:208:1: + CS8 = 0x00000300 // termios.h:209:1: + CSIZE = 0x00000300 // termios.h:205:1: + CSTART = 17 // ttydefaults.h:99:1: + CSTATUS = 20 // ttydefaults.h:92:1: + CSTOP = 19 // ttydefaults.h:100:1: + CSTOPB = 0x00000400 // termios.h:210:1: + CSUSP = 26 // ttydefaults.h:96:1: + CTIME = 0 // ttydefaults.h:97:1: + CWERASE = 23 // ttydefaults.h:103:1: + ECHO = 0x00000008 // termios.h:240:1: + ECHOCTL = 0x00000040 // termios.h:244:1: + ECHOE = 0x00000002 // termios.h:238:1: + ECHOK = 0x00000004 // termios.h:239:1: + ECHOKE = 0x00000001 // termios.h:236:1: + ECHONL = 0x00000010 // termios.h:241:1: + ECHOPRT = 0x00000020 // termios.h:243:1: + EXTA = 19200 // termios.h:315:1: + EXTB = 38400 // termios.h:316:1: + EXTPROC = 0x00000800 // termios.h:253:1: + FF0 = 0x00000000 // termios.h:188:1: + FF1 = 0x00004000 // termios.h:189:1: + FFDLY = 0x00004000 // termios.h:158:1: + FLUSHO = 0x00800000 // termios.h:257:1: + HUPCL = 0x00004000 // termios.h:214:1: + ICANON = 0x00000100 // termios.h:247:1: + ICRNL = 0x00000100 // termios.h:127:1: + IEXTEN = 0x00000400 // termios.h:251:1: + IGNBRK = 0x00000001 // termios.h:119:1: + IGNCR = 0x00000080 // termios.h:126:1: + IGNPAR = 0x00000004 // termios.h:121:1: + IMAXBEL = 0x00002000 // termios.h:132:1: + INLCR = 0x00000040 // termios.h:125:1: + INPCK = 0x00000010 // termios.h:123:1: + IOCPARM_MASK = 0x1fff // ioccom.h:74:1: + IOCPARM_MAX = 8192 // ioccom.h:79:1: + ISIG = 0x00000080 // termios.h:246:1: + ISTRIP = 0x00000020 // termios.h:124:1: + IUTF8 = 0x00004000 // termios.h:133:1: + IXANY = 0x00000800 // termios.h:130:1: + IXOFF = 0x00000400 // termios.h:129:1: + IXON = 0x00000200 // termios.h:128:1: + MDMBUF = 0x00100000 // termios.h:223:1: + NCCS = 20 // termios.h:108:1: + NL0 = 0x00000000 // termios.h:173:1: + NL1 = 0x00000100 // termios.h:174:1: + NL2 = 0x00000200 // termios.h:176:1: + NL3 = 0x00000300 // termios.h:177:1: + NLDLY = 0x00000300 // termios.h:155:1: + NOFLSH = 0x80000000 // termios.h:261:1: + NOKERNINFO = 0x02000000 // termios.h:258:1: + OCRNL = 0x00000010 // termios.h:151:1: + OFDEL = 0x00020000 // termios.h:161:1: + OFILL = 0x00000080 // termios.h:154:1: + ONLCR = 0x00000002 // termios.h:140:1: + ONLRET = 0x00000040 // termios.h:153:1: + ONOCR = 0x00000020 // termios.h:152:1: + ONOEOT = 0x00000008 // termios.h:143:1: + OPOST = 0x00000001 // termios.h:139:1: + OXTABS = 0x00000004 // termios.h:142:1: + PARENB = 0x00001000 // termios.h:212:1: + PARMRK = 0x00000008 // termios.h:122:1: + PARODD = 0x00002000 // termios.h:213:1: + PENDIN = 0x20000000 // termios.h:259:1: + PPPDISC = 5 // ttycom.h:171:1: + SLIPDISC = 4 // ttycom.h:170:1: + TAB0 = 0x00000000 // termios.h:179:1: + TAB1 = 0x00000400 // termios.h:180:1: + TAB2 = 0x00000800 // termios.h:181:1: + TAB3 = 0x00000004 // termios.h:183:1: + TABDLY = 0x00000c04 // termios.h:156:1: + TABLDISC = 3 // ttycom.h:169:1: + TCIFLUSH = 1 // termios.h:320:1: + TCIOFF = 3 // termios.h:325:1: + TCIOFLUSH = 3 // termios.h:322:1: + TCION = 4 // termios.h:326:1: + TCOFLUSH = 2 // termios.h:321:1: + TCOOFF = 1 // termios.h:323:1: + TCOON = 2 // termios.h:324:1: + TCSADRAIN = 1 // termios.h:282:1: + TCSAFLUSH = 2 // termios.h:283:1: + TCSANOW = 0 // termios.h:281:1: + TCSASOFT = 0x10 // termios.h:285:1: + TIOCM_CAR = 0100 // ttycom.h:97:1: + TIOCM_CD = 64 // ttycom.h:98:1: + TIOCM_CTS = 0040 // ttycom.h:96:1: + TIOCM_DSR = 0400 // ttycom.h:101:1: + TIOCM_DTR = 0002 // ttycom.h:92:1: + TIOCM_LE = 0001 // ttycom.h:91:1: + TIOCM_RI = 128 // ttycom.h:100:1: + TIOCM_RNG = 0200 // ttycom.h:99:1: + TIOCM_RTS = 0004 // ttycom.h:93:1: + TIOCM_SR = 0020 // ttycom.h:95:1: + TIOCM_ST = 0010 // ttycom.h:94:1: + TIOCPKT_DATA = 0x00 // ttycom.h:128:1: + TIOCPKT_DOSTOP = 0x20 // ttycom.h:134:1: + TIOCPKT_FLUSHREAD = 0x01 // ttycom.h:129:1: + TIOCPKT_FLUSHWRITE = 0x02 // ttycom.h:130:1: + TIOCPKT_IOCTL = 0x40 // ttycom.h:135:1: + TIOCPKT_NOSTOP = 0x10 // ttycom.h:133:1: + TIOCPKT_START = 0x08 // ttycom.h:132:1: + TIOCPKT_STOP = 0x04 // ttycom.h:131:1: + TOSTOP = 0x00400000 // termios.h:255:1: + TTYDEF_CFLAG = 19200 // ttydefaults.h:81:1: + TTYDEF_IFLAG = 11010 // ttydefaults.h:78:1: + TTYDEF_LFLAG = 1483 // ttydefaults.h:80:1: + TTYDEF_OFLAG = 3 // ttydefaults.h:79:1: + TTYDEF_SPEED = 9600 // ttydefaults.h:82:1: + TTYDISC = 0 // ttycom.h:168:1: + VDISCARD = 15 // termios.h:100:1: + VDSUSP = 11 // termios.h:94:1: + VEOF = 0 // termios.h:76:1: + VEOL = 1 // termios.h:77:1: + VEOL2 = 2 // termios.h:79:1: + VERASE = 3 // termios.h:81:1: + VINTR = 8 // termios.h:90:1: + VKILL = 5 // termios.h:85:1: + VLNEXT = 14 // termios.h:99:1: + VMIN = 16 // termios.h:102:1: + VQUIT = 9 // termios.h:91:1: + VREPRINT = 6 // termios.h:87:1: + VSTART = 12 // termios.h:96:1: + VSTATUS = 18 // termios.h:105:1: + VSTOP = 13 // termios.h:97:1: + VSUSP = 10 // termios.h:92:1: + VT0 = 0x00000000 // termios.h:192:1: + VT1 = 0x00010000 // termios.h:193:1: + VTDLY = 0x00010000 // termios.h:160:1: + VTIME = 17 // termios.h:103:1: + VWERASE = 4 // termios.h:83:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_SYS_IOCCOM_H_ = 0 // ioccom.h:65:1: + X_SYS_TERMIOS_H_ = 0 // termios.h:65:1: + X_SYS_TTYCOM_H_ = 0 // ttycom.h:70:1: + X_SYS_TTYDEFAULTS_H_ = 0 // ttydefaults.h:73:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved +// Copyright (c) 1988, 1989, 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. +// +// @(#)termios.h 8.3 (Berkeley) 3/28/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Special Control Characters +// +// Index into c_cc[] character array. +// +// Name Subscript Enabled by +// 7 spare 1 +// 19 spare 2 + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Input flags - software input processing + +// Output flags - software output processing +// The following block of features is unimplemented. Use of these flags in +// programs will currently result in unexpected behaviour. +// +// - Begin unimplemented features +// These manifest constants have the same names as those in the header +// , so you are not permitted to have both definitions +// in scope simultaneously in the same compilation unit. Nevertheless, +// they are required to be in scope when _POSIX_C_SOURCE is requested; +// this means that including the header before this +// one when _POSIX_C_SOURCE is in scope will result in redefintions. We +// attempt to maintain these as the same values so as to avoid this being +// an outright error in most compilers. +// not in sys/ioctl_compat.h, use OXTABS value +// + End unimplemented features + +// Control flags - hardware control of terminal + +// "Local" flags - dumping ground for other state +// +// Warning: some flags in this structure begin with +// the letter "I" and look like they belong in the +// input flag. + +type Tcflag_t = uint64 /* termios.h:263:25 */ +type Cc_t = uint8 /* termios.h:264:25 */ +type Speed_t = uint64 /* termios.h:265:25 */ + +type Termios = struct { + Fc_iflag Tcflag_t + Fc_oflag Tcflag_t + Fc_cflag Tcflag_t + Fc_lflag Tcflag_t + Fc_cc [20]Cc_t + F__ccgo_pad1 [4]byte + Fc_ispeed Speed_t + Fc_ospeed Speed_t +} /* termios.h:267:1 */ + +// Include tty ioctl's that aren't just for backwards compatibility +// with the old tty driver. These ioctl definitions were previously +// in . +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 1990, 1993, 1994 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)ttycom.h 8.1 (Berkeley) 3/28/94 + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 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. +// +// @(#)ioccom.h 8.2 (Berkeley) 3/28/94 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// 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 3 bits of the +// upper word are used to encode the in/out status of the parameter. + +// no parameters +// copy parameters out +// copy parameters in +// copy parameters in and out +// mask for IN/OUT/VOID + +// this should be _IORW, but stdio got there first + +// Tty ioctl's except for those supported only for backwards compatibility +// with the old tty driver. + +// Window/terminal size structure. This information is stored by the kernel +// in order to provide a consistent interface, but is not used by the kernel. +type Winsize = struct { + Fws_row uint16 + Fws_col uint16 + Fws_xpixel uint16 + Fws_ypixel uint16 +} /* ttycom.h:82:1 */ + +// 8-10 compat +// 15 unused +// 17-18 compat +// 127-124 compat +// 117-116 compat +// 105 unused + +// END OF PROTECTED INCLUDE. + +// Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved +// - +// Copyright (c) 1982, 1986, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 + +// System wide defaults for terminal state. + +// Defaults on "first" open. + +// Control Character Defaults +// compat + +// PROTECTED INCLUSION ENDS HERE + +// #define TTYDEFCHARS to include an array of default control characters. +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/termios/termios_linux_amd64.go b/internal/libc/termios/termios_linux_amd64.go new file mode 100644 index 0000000..8d22a54 --- /dev/null +++ b/internal/libc/termios/termios_linux_amd64.go @@ -0,0 +1,1024 @@ +// Code generated by 'ccgo termios/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o termios/termios_linux_amd64.go -pkgname termios', DO NOT EDIT. + +package termios + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + B0 = 0000000 // termios.h:33:1: + B1000000 = 0010010 // termios-baud.h:40:1: + B110 = 0000003 // termios.h:36:1: + B115200 = 0010002 // termios-baud.h:34:1: + B1152000 = 0010011 // termios-baud.h:41:1: + B1200 = 0000011 // termios.h:42:1: + B134 = 0000004 // termios.h:37:1: + B150 = 0000005 // termios.h:38:1: + B1500000 = 0010012 // termios-baud.h:42:1: + B1800 = 0000012 // termios.h:43:1: + B19200 = 0000016 // termios.h:47:1: + B200 = 0000006 // termios.h:39:1: + B2000000 = 0010013 // termios-baud.h:43:1: + B230400 = 0010003 // termios-baud.h:35:1: + B2400 = 0000013 // termios.h:44:1: + B2500000 = 0010014 // termios-baud.h:44:1: + B300 = 0000007 // termios.h:40:1: + B3000000 = 0010015 // termios-baud.h:45:1: + B3500000 = 0010016 // termios-baud.h:46:1: + B38400 = 0000017 // termios.h:48:1: + B4000000 = 0010017 // termios-baud.h:47:1: + B460800 = 0010004 // termios-baud.h:36:1: + B4800 = 0000014 // termios.h:45:1: + B50 = 0000001 // termios.h:34:1: + B500000 = 0010005 // termios-baud.h:37:1: + B57600 = 0010001 // termios-baud.h:33:1: + B576000 = 0010006 // termios-baud.h:38:1: + B600 = 0000010 // termios.h:41:1: + B75 = 0000002 // termios.h:35:1: + B921600 = 0010007 // termios-baud.h:39:1: + B9600 = 0000015 // termios.h:46:1: + BRKINT = 0000002 // termios-c_iflag.h:25:1: + BS0 = 0000000 // termios-c_oflag.h:48:1: + BS1 = 0020000 // termios-c_oflag.h:49:1: + BSDLY = 0020000 // termios-c_oflag.h:47:1: + CBAUD = 000000010017 // termios-baud.h:24:1: + CBAUDEX = 000000010000 // termios-baud.h:25:1: + CBRK = 0 // ttydefaults.h:83:1: + CDISCARD = 15 // ttydefaults.h:78:1: + CDSUSP = 25 // ttydefaults.h:74:1: + CEOF = 4 // ttydefaults.h:56:1: + CEOL = 0 // ttydefaults.h:60:1: + CEOT = 4 // ttydefaults.h:81:1: + CERASE = 0177 // ttydefaults.h:62:1: + CFLUSH = 15 // ttydefaults.h:85:1: + CIBAUD = 002003600000 // termios-baud.h:27:1: + CINTR = 3 // ttydefaults.h:63:1: + CKILL = 21 // ttydefaults.h:69:1: + CLNEXT = 22 // ttydefaults.h:77:1: + CLOCAL = 0004000 // termios-c_cflag.h:34:1: + CMIN = 1 // ttydefaults.h:70:1: + CMSPAR = 010000000000 // termios-baud.h:28:1: + CQUIT = 034 // ttydefaults.h:71:1: + CR0 = 0000000 // termios-c_oflag.h:38:1: + CR1 = 0001000 // termios-c_oflag.h:39:1: + CR2 = 0002000 // termios-c_oflag.h:40:1: + CR3 = 0003000 // termios-c_oflag.h:41:1: + CRDLY = 0003000 // termios-c_oflag.h:37:1: + CREAD = 0000200 // termios-c_cflag.h:30:1: + CREPRINT = 18 // ttydefaults.h:80:1: + CRPRNT = 18 // ttydefaults.h:84:1: + CRTSCTS = 020000000000 // termios-baud.h:29:1: + CS5 = 0000000 // termios-c_cflag.h:25:1: + CS6 = 0000020 // termios-c_cflag.h:26:1: + CS7 = 0000040 // termios-c_cflag.h:27:1: + CS8 = 0000060 // termios-c_cflag.h:28:1: + CSIZE = 0000060 // termios-c_cflag.h:24:1: + CSTART = 17 // ttydefaults.h:75:1: + CSTATUS = 0 // ttydefaults.h:67:1: + CSTOP = 19 // ttydefaults.h:76:1: + CSTOPB = 0000100 // termios-c_cflag.h:29:1: + CSUSP = 26 // ttydefaults.h:72:1: + CTIME = 0 // ttydefaults.h:73:1: + CWERASE = 23 // ttydefaults.h:79:1: + ECHO = 0000010 // termios-c_lflag.h:29:1: + ECHOCTL = 0001000 // termios-c_lflag.h:37:1: + ECHOE = 0000020 // termios-c_lflag.h:30:1: + ECHOK = 0000040 // termios-c_lflag.h:32:1: + ECHOKE = 0004000 // termios-c_lflag.h:45:1: + ECHONL = 0000100 // termios-c_lflag.h:33:1: + ECHOPRT = 0002000 // termios-c_lflag.h:42:1: + EXTA = 14 // termios.h:50:1: + EXTB = 15 // termios.h:51:1: + EXTPROC = 0200000 // termios-c_lflag.h:57:1: + FF0 = 0000000 // termios-c_oflag.h:51:1: + FF1 = 0100000 // termios-c_oflag.h:52:1: + FFDLY = 0100000 // termios-c_oflag.h:50:1: + FLUSHO = 0010000 // termios-c_lflag.h:48:1: + HUPCL = 0002000 // termios-c_cflag.h:33:1: + ICANON = 0000002 // termios-c_lflag.h:25:1: + ICRNL = 0000400 // termios-c_iflag.h:32:1: + IEXTEN = 0100000 // termios-c_lflag.h:54:1: + IGNBRK = 0000001 // termios-c_iflag.h:24:1: + IGNCR = 0000200 // termios-c_iflag.h:31:1: + IGNPAR = 0000004 // termios-c_iflag.h:26:1: + IMAXBEL = 0020000 // termios-c_iflag.h:38:1: + INLCR = 0000100 // termios-c_iflag.h:30:1: + INPCK = 0000020 // termios-c_iflag.h:28:1: + ISIG = 0000001 // termios-c_lflag.h:24:1: + ISTRIP = 0000040 // termios-c_iflag.h:29:1: + IUCLC = 0001000 // termios-c_iflag.h:33:1: + IUTF8 = 0040000 // termios-c_iflag.h:40:1: + IXANY = 0004000 // termios-c_iflag.h:36:1: + IXOFF = 0010000 // termios-c_iflag.h:37:1: + IXON = 0002000 // termios-c_iflag.h:35:1: + NCCS = 32 // termios-struct.h:23:1: + NL0 = 0000000 // termios-c_oflag.h:35:1: + NL1 = 0000400 // termios-c_oflag.h:36:1: + NLDLY = 0000400 // termios-c_oflag.h:34:1: + NOFLSH = 0000200 // termios-c_lflag.h:34:1: + OCRNL = 0000010 // termios-c_oflag.h:28:1: + OFDEL = 0000200 // termios-c_oflag.h:32:1: + OFILL = 0000100 // termios-c_oflag.h:31:1: + OLCUC = 0000002 // termios-c_oflag.h:25:1: + ONLCR = 0000004 // termios-c_oflag.h:27:1: + ONLRET = 0000040 // termios-c_oflag.h:30:1: + ONOCR = 0000020 // termios-c_oflag.h:29:1: + OPOST = 0000001 // termios-c_oflag.h:24:1: + PARENB = 0000400 // termios-c_cflag.h:31:1: + PARMRK = 0000010 // termios-c_iflag.h:27:1: + PARODD = 0001000 // termios-c_cflag.h:32:1: + PENDIN = 0040000 // termios-c_lflag.h:50:1: + TAB0 = 0000000 // termios-c_oflag.h:43:1: + TAB1 = 0004000 // termios-c_oflag.h:44:1: + TAB2 = 0010000 // termios-c_oflag.h:45:1: + TAB3 = 0014000 // termios-c_oflag.h:46:1: + TABDLY = 0014000 // termios-c_oflag.h:42:1: + TCIFLUSH = 0 // termios.h:70:1: + TCIOFF = 2 // termios.h:66:1: + TCIOFLUSH = 2 // termios.h:72:1: + TCION = 3 // termios.h:67:1: + TCOFLUSH = 1 // termios.h:71:1: + TCOOFF = 0 // termios.h:64:1: + TCOON = 1 // termios.h:65:1: + TCSADRAIN = 1 // termios-tcflow.h:25:1: + TCSAFLUSH = 2 // termios-tcflow.h:26:1: + TCSANOW = 0 // termios-tcflow.h:24:1: + TIOCSER_TEMT = 0x01 // termios.h:60:1: + TOSTOP = 0000400 // termios-c_lflag.h:35:1: + TTYDEF_CFLAG = 1440 // ttydefaults.h:49:1: + TTYDEF_IFLAG = 11554 // ttydefaults.h:46:1: + TTYDEF_LFLAG = 35355 // ttydefaults.h:48:1: + TTYDEF_OFLAG = 6149 // ttydefaults.h:47:1: + TTYDEF_SPEED = 13 // ttydefaults.h:50:1: + VDISCARD = 13 // termios-c_cc.h:37:1: + VEOF = 4 // termios-c_cc.h:28:1: + VEOL = 11 // termios-c_cc.h:35:1: + VEOL2 = 16 // termios-c_cc.h:40:1: + VERASE = 2 // termios-c_cc.h:26:1: + VINTR = 0 // termios-c_cc.h:24:1: + VKILL = 3 // termios-c_cc.h:27:1: + VLNEXT = 15 // termios-c_cc.h:39:1: + VMIN = 6 // termios-c_cc.h:30:1: + VQUIT = 1 // termios-c_cc.h:25:1: + VREPRINT = 12 // termios-c_cc.h:36:1: + VSTART = 8 // termios-c_cc.h:32:1: + VSTOP = 9 // termios-c_cc.h:33:1: + VSUSP = 10 // termios-c_cc.h:34:1: + VSWTC = 7 // termios-c_cc.h:31:1: + VT0 = 0000000 // termios-c_oflag.h:56:1: + VT1 = 0040000 // termios-c_oflag.h:57:1: + VTDLY = 0040000 // termios-c_oflag.h:55:1: + VTIME = 5 // termios-c_cc.h:29:1: + VWERASE = 14 // termios-c_cc.h:38:1: + XCASE = 0000004 // termios-c_lflag.h:27:1: + XTABS = 0014000 // termios-c_oflag.h:60:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_HAVE_STRUCT_TERMIOS_C_ISPEED = 1 // termios-struct.h:34:1: + X_HAVE_STRUCT_TERMIOS_C_OSPEED = 1 // termios-struct.h:35:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_TTYDEFAULTS_H_ = 0 // ttydefaults.h:41:1: + X_TERMIOS_H = 1 // termios.h:23:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 7.1-2 General Terminal Interface + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// We need `pid_t'. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type Pid_t = X__pid_t /* termios.h:30:17 */ + +// Get the system-dependent definitions of `struct termios', `tcflag_t', +// `cc_t', `speed_t', and all the macros specifying the flag bits. +// termios type and macro definitions. Linux version. +// Copyright (C) 1993-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type Cc_t = uint8 /* termios.h:23:23 */ +type Speed_t = uint32 /* termios.h:24:22 */ +type Tcflag_t = uint32 /* termios.h:25:22 */ + +// struct termios definition. Linux/generic version. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +type Termios = struct { + Fc_iflag Tcflag_t + Fc_oflag Tcflag_t + Fc_cflag Tcflag_t + Fc_lflag Tcflag_t + Fc_line Cc_t + Fc_cc [32]Cc_t + F__ccgo_pad1 [3]byte + Fc_ispeed Speed_t + Fc_ospeed Speed_t +} /* termios-struct.h:24:1 */ + +// - +// Copyright (c) 1982, 1986, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// 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. +// +// @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 + +// System wide defaults for terminal state. Linux version. + +// Defaults on "first" open. + +// Control Character Defaults +// compat + +// PROTECTED INCLUSION ENDS HERE + +// #define TTYDEFCHARS to include an array of default control characters. + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/termios/termios_linux_arm64.go b/internal/libc/termios/termios_linux_arm64.go new file mode 100644 index 0000000..671e71d --- /dev/null +++ b/internal/libc/termios/termios_linux_arm64.go @@ -0,0 +1,1092 @@ +// Code generated by 'ccgo termios/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o termios/termios_linux_arm64.go -pkgname termios', DO NOT EDIT. + +package termios + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + B0 = 0000000 + B1000000 = 0010010 + B110 = 0000003 + B115200 = 0010002 + B1152000 = 0010011 + B1200 = 0000011 + B134 = 0000004 + B150 = 0000005 + B1500000 = 0010012 + B1800 = 0000012 + B19200 = 0000016 + B200 = 0000006 + B2000000 = 0010013 + B230400 = 0010003 + B2400 = 0000013 + B2500000 = 0010014 + B300 = 0000007 + B3000000 = 0010015 + B3500000 = 0010016 + B38400 = 0000017 + B4000000 = 0010017 + B460800 = 0010004 + B4800 = 0000014 + B50 = 0000001 + B500000 = 0010005 + B57600 = 0010001 + B576000 = 0010006 + B600 = 0000010 + B75 = 0000002 + B921600 = 0010007 + B9600 = 0000015 + BRKINT = 0000002 + BS0 = 0000000 + BS1 = 0020000 + BSDLY = 0020000 + CBAUD = 000000010017 + CBAUDEX = 000000010000 + CBRK = 0 + CDISCARD = 15 + CDSUSP = 25 + CEOF = 4 + CEOL = 0 + CEOT = 4 + CERASE = 0177 + CFLUSH = 15 + CIBAUD = 002003600000 + CINTR = 3 + CKILL = 21 + CLNEXT = 22 + CLOCAL = 0004000 + CMIN = 1 + CMSPAR = 010000000000 + CQUIT = 034 + CR0 = 0000000 + CR1 = 0001000 + CR2 = 0002000 + CR3 = 0003000 + CRDLY = 0003000 + CREAD = 0000200 + CREPRINT = 18 + CRPRNT = 18 + CRTSCTS = 020000000000 + CS5 = 0000000 + CS6 = 0000020 + CS7 = 0000040 + CS8 = 0000060 + CSIZE = 0000060 + CSTART = 17 + CSTATUS = 0 + CSTOP = 19 + CSTOPB = 0000100 + CSUSP = 26 + CTIME = 0 + CWERASE = 23 + ECHO = 0000010 + ECHOCTL = 0001000 + ECHOE = 0000020 + ECHOK = 0000040 + ECHOKE = 0004000 + ECHONL = 0000100 + ECHOPRT = 0002000 + EXTA = 14 + EXTB = 15 + EXTPROC = 0200000 + FF0 = 0000000 + FF1 = 0100000 + FFDLY = 0100000 + FLUSHO = 0010000 + HUPCL = 0002000 + ICANON = 0000002 + ICRNL = 0000400 + IEXTEN = 0100000 + IGNBRK = 0000001 + IGNCR = 0000200 + IGNPAR = 0000004 + IMAXBEL = 0020000 + INLCR = 0000100 + INPCK = 0000020 + ISIG = 0000001 + ISTRIP = 0000040 + IUCLC = 0001000 + IUTF8 = 0040000 + IXANY = 0004000 + IXOFF = 0010000 + IXON = 0002000 + NCCS = 32 + NL0 = 0000000 + NL1 = 0000400 + NLDLY = 0000400 + NOFLSH = 0000200 + OCRNL = 0000010 + OFDEL = 0000200 + OFILL = 0000100 + OLCUC = 0000002 + ONLCR = 0000004 + ONLRET = 0000040 + ONOCR = 0000020 + OPOST = 0000001 + PARENB = 0000400 + PARMRK = 0000010 + PARODD = 0001000 + PENDIN = 0040000 + TAB0 = 0000000 + TAB1 = 0004000 + TAB2 = 0010000 + TAB3 = 0014000 + TABDLY = 0014000 + TCIFLUSH = 0 + TCIOFF = 2 + TCIOFLUSH = 2 + TCION = 3 + TCOFLUSH = 1 + TCOOFF = 0 + TCOON = 1 + TCSADRAIN = 1 + TCSAFLUSH = 2 + TCSANOW = 0 + TIOCSER_TEMT = 0x01 + TOSTOP = 0000400 + TTYDEF_CFLAG = 1440 + TTYDEF_IFLAG = 11554 + TTYDEF_LFLAG = 35355 + TTYDEF_OFLAG = 6149 + TTYDEF_SPEED = 13 + VDISCARD = 13 + VEOF = 4 + VEOL = 11 + VEOL2 = 16 + VERASE = 2 + VINTR = 0 + VKILL = 3 + VLNEXT = 15 + VMIN = 6 + VQUIT = 1 + VREPRINT = 12 + VSTART = 8 + VSTOP = 9 + VSUSP = 10 + VSWTC = 7 + VT0 = 0000000 + VT1 = 0040000 + VTDLY = 0040000 + VTIME = 5 + VWERASE = 14 + XCASE = 0000004 + XTABS = 0014000 + X_ATFILE_SOURCE = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_HAVE_STRUCT_TERMIOS_C_ISPEED = 1 + X_HAVE_STRUCT_TERMIOS_C_OSPEED = 1 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + X_SYS_TTYDEFAULTS_H_ = 0 + X_TERMIOS_H = 1 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 7.1-2 General Terminal Interface + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// We need `pid_t'. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type Pid_t = X__pid_t /* termios.h:30:17 */ + +// Get the system-dependent definitions of `struct termios', `tcflag_t', +// `cc_t', `speed_t', and all the macros specifying the flag bits. +// termios type and macro definitions. Linux version. +// Copyright (C) 1993-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type Cc_t = uint8 /* termios.h:23:23 */ +type Speed_t = uint32 /* termios.h:24:22 */ +type Tcflag_t = uint32 /* termios.h:25:22 */ + +// struct termios definition. Linux/generic version. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +type Termios = struct { + Fc_iflag Tcflag_t + Fc_oflag Tcflag_t + Fc_cflag Tcflag_t + Fc_lflag Tcflag_t + Fc_line Cc_t + Fc_cc [32]Cc_t + F__ccgo_pad1 [3]byte + Fc_ispeed Speed_t + Fc_ospeed Speed_t +} /* termios-struct.h:24:1 */ + +// - +// Copyright (c) 1982, 1986, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// 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. +// +// @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 + +// System wide defaults for terminal state. Linux version. + +// Defaults on "first" open. + +// Control Character Defaults +// compat + +// PROTECTED INCLUSION ENDS HERE + +// #define TTYDEFCHARS to include an array of default control characters. + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/time/capi_darwin_amd64.go b/internal/libc/time/capi_darwin_amd64.go new file mode 100644 index 0000000..375a251 --- /dev/null +++ b/internal/libc/time/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo time/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o time/time_darwin_amd64.go -pkgname time', DO NOT EDIT. + +package time + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/time/capi_darwin_arm64.go b/internal/libc/time/capi_darwin_arm64.go new file mode 100644 index 0000000..940f523 --- /dev/null +++ b/internal/libc/time/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo time/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o time/time_darwin_arm64.go -pkgname time', DO NOT EDIT. + +package time + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/time/capi_linux_amd64.go b/internal/libc/time/capi_linux_amd64.go new file mode 100644 index 0000000..fef9264 --- /dev/null +++ b/internal/libc/time/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo time/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o time/time_linux_amd64.go -pkgname time', DO NOT EDIT. + +package time + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/time/capi_linux_arm64.go b/internal/libc/time/capi_linux_arm64.go new file mode 100644 index 0000000..200888b --- /dev/null +++ b/internal/libc/time/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo time/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o time/time_linux_arm64.go -pkgname time', DO NOT EDIT. + +package time + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/time/time_darwin_amd64.go b/internal/libc/time/time_darwin_amd64.go new file mode 100644 index 0000000..91714fb --- /dev/null +++ b/internal/libc/time/time_darwin_amd64.go @@ -0,0 +1,1769 @@ +// Code generated by 'ccgo time/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o time/time_darwin_amd64.go -pkgname time', DO NOT EDIT. + +package time + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + CLOCKS_PER_SEC = 1000000 // time.h:90:1: + TIME_UTC = 1 // time.h:197:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CLOCK_T = 0 // _clock_t.h:29:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_H_ = 0 // time.h:64:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +const ( /* time.h:153:1: */ + X_CLOCK_REALTIME = 0 + X_CLOCK_MONOTONIC = 6 + X_CLOCK_MONOTONIC_RAW = 4 + X_CLOCK_MONOTONIC_RAW_APPROX = 5 + X_CLOCK_UPTIME_RAW = 8 + X_CLOCK_UPTIME_RAW_APPROX = 9 + X_CLOCK_PROCESS_CPUTIME_ID = 12 + X_CLOCK_THREAD_CPUTIME_ID = 16 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)time.h 8.3 (Berkeley) 1/21/94 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* time.h:75:1 */ + +type Clockid_t = uint32 /* time.h:172:3 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/time/time_darwin_arm64.go b/internal/libc/time/time_darwin_arm64.go new file mode 100644 index 0000000..4412ffb --- /dev/null +++ b/internal/libc/time/time_darwin_arm64.go @@ -0,0 +1,1768 @@ +// Code generated by 'ccgo time/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o time/time_darwin_arm64.go -pkgname time', DO NOT EDIT. + +package time + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + CLOCKS_PER_SEC = 1000000 + MAC_OS_VERSION_11_0 = 110000 + MAC_OS_VERSION_12_0 = 120000 + MAC_OS_X_VERSION_10_0 = 1000 + MAC_OS_X_VERSION_10_1 = 1010 + MAC_OS_X_VERSION_10_10 = 101000 + MAC_OS_X_VERSION_10_10_2 = 101002 + MAC_OS_X_VERSION_10_10_3 = 101003 + MAC_OS_X_VERSION_10_11 = 101100 + MAC_OS_X_VERSION_10_11_2 = 101102 + MAC_OS_X_VERSION_10_11_3 = 101103 + MAC_OS_X_VERSION_10_11_4 = 101104 + MAC_OS_X_VERSION_10_12 = 101200 + MAC_OS_X_VERSION_10_12_1 = 101201 + MAC_OS_X_VERSION_10_12_2 = 101202 + MAC_OS_X_VERSION_10_12_4 = 101204 + MAC_OS_X_VERSION_10_13 = 101300 + MAC_OS_X_VERSION_10_13_1 = 101301 + MAC_OS_X_VERSION_10_13_2 = 101302 + MAC_OS_X_VERSION_10_13_4 = 101304 + MAC_OS_X_VERSION_10_14 = 101400 + MAC_OS_X_VERSION_10_14_1 = 101401 + MAC_OS_X_VERSION_10_14_4 = 101404 + MAC_OS_X_VERSION_10_14_6 = 101406 + MAC_OS_X_VERSION_10_15 = 101500 + MAC_OS_X_VERSION_10_15_1 = 101501 + MAC_OS_X_VERSION_10_16 = 101600 + MAC_OS_X_VERSION_10_2 = 1020 + MAC_OS_X_VERSION_10_3 = 1030 + MAC_OS_X_VERSION_10_4 = 1040 + MAC_OS_X_VERSION_10_5 = 1050 + MAC_OS_X_VERSION_10_6 = 1060 + MAC_OS_X_VERSION_10_7 = 1070 + MAC_OS_X_VERSION_10_8 = 1080 + MAC_OS_X_VERSION_10_9 = 1090 + TIME_UTC = 1 + X_ARM_MACHTYPES_H_ = 0 + X_BSD_ARM__TYPES_H_ = 0 + X_BSD_MACHINE_TYPES_H_ = 0 + X_BSD_MACHINE__TYPES_H_ = 0 + X_CDEFS_H_ = 0 + X_CLOCK_T = 0 + X_DARWIN_FEATURE_64_BIT_INODE = 1 + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 + X_FILE_OFFSET_BITS = 64 + X_FORTIFY_SOURCE = 2 + X_INT16_T = 0 + X_INT32_T = 0 + X_INT64_T = 0 + X_INT8_T = 0 + X_INTPTR_T = 0 + X_LP64 = 1 + X_MACHTYPES_H_ = 0 + X_Nonnull = 0 + X_Null_unspecified = 0 + X_Nullable = 0 + X_SIZE_T = 0 + X_SYS__PTHREAD_TYPES_H_ = 0 + X_SYS__TYPES_H_ = 0 + X_TIME_H_ = 0 + X_TIME_T = 0 + X_UINTPTR_T = 0 + X_U_INT16_T = 0 + X_U_INT32_T = 0 + X_U_INT64_T = 0 + X_U_INT8_T = 0 +) + +const ( /* time.h:153:1: */ + X_CLOCK_REALTIME = 0 + X_CLOCK_MONOTONIC = 6 + X_CLOCK_MONOTONIC_RAW = 4 + X_CLOCK_MONOTONIC_RAW_APPROX = 5 + X_CLOCK_UPTIME_RAW = 8 + X_CLOCK_UPTIME_RAW_APPROX = 9 + X_CLOCK_PROCESS_CPUTIME_ID = 12 + X_CLOCK_THREAD_CPUTIME_ID = 16 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// Copyright (c) 1989, 1993 +// The Regents of the University of California. All rights reserved. +// (c) UNIX System Laboratories, Inc. +// All or some portions of this file are derived from material licensed +// to the University of California by American Telephone and Telegraph +// Co. or Unix System Laboratories, Inc. and are reproduced herein with +// the permission of UNIX System Laboratories, 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. +// +// @(#)time.h 8.3 (Berkeley) 1/21/94 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// These macros are for use in OS header files. They enable function prototypes +// and Objective-C methods to be tagged with the OS version in which they +// were first available; and, if applicable, the OS version in which they +// became deprecated. +// +// The desktop Mac OS X and iOS each have different version numbers. +// The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop +// and iOS version numbers. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) +// means the function/method was first available on Mac OS X 10.2 on the desktop +// and first available in iOS 2.0 on the iPhone. +// +// If a function is available on one platform, but not the other a _NA (not +// applicable) parameter is used. For instance: +// __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) +// means that the function/method was first available on Mac OS X 10.3, and it +// currently not implemented on the iPhone. +// +// At some point, a function/method may be deprecated. That means Apple +// recommends applications stop using the function, either because there is a +// better replacement or the functionality is being phased out. Deprecated +// functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() +// macro which specifies the OS version where the function became available +// as well as the OS version in which it became deprecated. For instance: +// __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) +// means that the function/method was introduced in Mac OS X 10.0, then +// became deprecated beginning in Mac OS X 10.5. On iOS the function +// has never been available. +// +// For these macros to function properly, a program must specify the OS version range +// it is targeting. The min OS version is specified as an option to the compiler: +// -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z +// when building for the iPhone. The upper bound for the OS version is rarely needed, +// but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for +// Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. +// +// Examples: +// +// A function available in Mac OS X 10.5 and later, but not on the phone: +// +// extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// +// +// An Objective-C method in Mac OS X 10.5 and later, but not on the phone: +// +// @interface MyClass : NSObject +// -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); +// @end +// +// +// An enum available on the phone, but not available on Mac OS X: +// +// #if __IPHONE_OS_VERSION_MIN_REQUIRED +// enum { myEnum = 1 }; +// #endif +// Note: this works when targeting the Mac OS X platform because +// __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. +// +// +// An enum with values added in different iPhoneOS versions: +// +// enum { +// myX = 1, // Usable on iPhoneOS 2.1 and later +// myY = 2, // Usable on iPhoneOS 3.0 and later +// myZ = 3, // Usable on iPhoneOS 3.0 and later +// ... +// Note: you do not want to use #if with enumeration values +// when a client needs to see all values at compile time +// and use runtime logic to only use the viable values. +// +// +// It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one +// source base that can be compiled to target a range of OS versions. It is best +// to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. +// That is because you might get compiled on an old OS that does not define a later +// OS version macro, and in the C preprocessor undefined values evaluate to zero +// in expresssions, which could cause the #if expression to evaluate in an unexpected +// way. +// +// #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +// // code only compiled when targeting Mac OS X and not iPhone +// // note use of 1050 instead of __MAC_10_5 +// #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// // code in here might run on pre-Leopard OS +// #else +// // code here can assume Leopard or later +// #endif +// #endif +// +// + +// __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated +// in an upcoming release. This soft deprecation is an intermediate step before formal +// deprecation to notify developers about the API before compiler warnings are generated. +// You can find all places in your code that use soft deprecated API by redefining the +// value of this macro to your current minimum deployment target, for example: +// (macOS) +// clang -D__API_TO_BE_DEPRECATED=10.12 +// (iOS) +// clang -D__API_TO_BE_DEPRECATED=11.0 + +// Copyright (c) 2019 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable + +// Set up standard Mac OS X versions + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// +// File: AvailabilityInternal.h +// +// Contains: implementation details of __OSX_AVAILABLE_* macros from +// + +// compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + +// make sure a default max version is set + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// + +// Evaluate to nothing for compilers that don't support availability. + +// Swift compiler version +// Allows for project-agnostic "epochs" for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift +// Example: +// +// #if __swift_compiler_version_at_least(800, 2, 20) +// - (nonnull NSString *)description; +// #else +// - (NSString *)description; +// #endif + +// If __SPI_AVAILABLE has not been defined elsewhere, disable it. + +// for use to document app extension usage + +// for use marking APIs available info for Mac OSX + +// for use marking APIs available info for iOS + +// for use marking APIs available info for tvOS + +// for use marking APIs available info for Watch OS + +// for use marking APIs unavailable for swift + +// +// Macros for defining which versions/platform a given symbol can be used. +// +// @see http://clang.llvm.org/docs/AttributeReference.html#availability +// +// * Note that these macros are only compatible with clang compilers that +// * support the following target selection options: +// * +// * -mmacosx-version-min +// * -miphoneos-version-min +// * -mwatchos-version-min +// * -mtvos-version-min +// + +// Evaluate to nothing for compilers that don't support availability. + +// If SPI decorations have not been defined elsewhere, disable them. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type Clock_t = X__darwin_clock_t /* _clock_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* time.h:75:1 */ + +type Clockid_t = uint32 /* time.h:172:3 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/time/time_linux_amd64.go b/internal/libc/time/time_linux_amd64.go new file mode 100644 index 0000000..564d839 --- /dev/null +++ b/internal/libc/time/time_linux_amd64.go @@ -0,0 +1,682 @@ +// Code generated by 'ccgo time/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o time/time_linux_amd64.go -pkgname time', DO NOT EDIT. + +package time + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + CLOCK_BOOTTIME = 7 // time.h:60:1: + CLOCK_BOOTTIME_ALARM = 9 // time.h:64:1: + CLOCK_MONOTONIC = 1 // time.h:48:1: + CLOCK_MONOTONIC_COARSE = 6 // time.h:58:1: + CLOCK_MONOTONIC_RAW = 4 // time.h:54:1: + CLOCK_PROCESS_CPUTIME_ID = 2 // time.h:50:1: + CLOCK_REALTIME = 0 // time.h:46:1: + CLOCK_REALTIME_ALARM = 8 // time.h:62:1: + CLOCK_REALTIME_COARSE = 5 // time.h:56:1: + CLOCK_TAI = 11 // time.h:66:1: + CLOCK_THREAD_CPUTIME_ID = 3 // time.h:52:1: + TIMER_ABSTIME = 1 // time.h:69:1: + TIME_UTC = 1 // time.h:65:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TIME_H = 1 // time.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_TYPES_LOCALE_T_H = 1 // locale_t.h:20:1: + X_BITS_TYPES___LOCALE_T_H = 1 // __locale_t.h:21:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_TIME_H = 1 // time.h:23:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: + + // #define CLOCKS_PER_SEC ((__clock_t) 1000000) + CLOCKS_PER_SEC = 1000000 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This defines CLOCKS_PER_SEC, which is the number of processor clock +// ticks per second, and possibly a number of other constants. +// System-dependent timing definitions. Linux version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// ISO/IEC 9899:1999 7.23.1: Components of time +// The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is +// the number per second of the value returned by the `clock' function. +// CAE XSH, Issue 4, Version 2: +// The value of CLOCKS_PER_SEC is required to be 1 million on all +// XSI-conformant systems. + +// Identifier for system-wide realtime clock. +// Monotonic system-wide clock. +// High-resolution timer from the CPU. +// Thread-specific CPU-time clock. +// Monotonic system-wide clock, not adjusted for frequency scaling. +// Identifier for system-wide realtime clock, updated only on ticks. +// Monotonic system-wide clock, updated only on ticks. +// Monotonic system-wide clock that includes time spent in suspension. +// Like CLOCK_REALTIME but also wakes suspended system. +// Like CLOCK_BOOTTIME but also wakes suspended system. +// Like CLOCK_REALTIME but in International Atomic Time. + +// Flag to indicate time is absolute. + +// Many of the typedefs and structs whose official home is this header +// may also need to be defined by other headers. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO C `broken-down time' structure. +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* struct_tm.h:7:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// i386/x86_64 are little-endian. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// NB: Include guard matches what uses. + +// POSIX.1b structure for timer start values and intervals. +type Itimerspec = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } +} /* struct_itimerspec.h:8:1 */ + +type Pid_t = X__pid_t /* time.h:54:17 */ + +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/time/time_linux_arm64.go b/internal/libc/time/time_linux_arm64.go new file mode 100644 index 0000000..49d6892 --- /dev/null +++ b/internal/libc/time/time_linux_arm64.go @@ -0,0 +1,713 @@ +// Code generated by 'ccgo time/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o time/time_linux_arm64.go -pkgname time', DO NOT EDIT. + +package time + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + CLOCKS_PER_SEC = 1000000 + CLOCK_BOOTTIME = 7 + CLOCK_BOOTTIME_ALARM = 9 + CLOCK_MONOTONIC = 1 + CLOCK_MONOTONIC_COARSE = 6 + CLOCK_MONOTONIC_RAW = 4 + CLOCK_PROCESS_CPUTIME_ID = 2 + CLOCK_REALTIME = 0 + CLOCK_REALTIME_ALARM = 8 + CLOCK_REALTIME_COARSE = 5 + CLOCK_TAI = 11 + CLOCK_THREAD_CPUTIME_ID = 3 + TIMER_ABSTIME = 1 + TIME_UTC = 1 + X_ATFILE_SOURCE = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TIME_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_TYPES_LOCALE_T_H = 1 + X_BITS_TYPES___LOCALE_T_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SIZE_T_H = 0 + X_TIME_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This defines CLOCKS_PER_SEC, which is the number of processor clock +// ticks per second, and possibly a number of other constants. +// System-dependent timing definitions. Linux version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// ISO/IEC 9899:1999 7.23.1: Components of time +// The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is +// the number per second of the value returned by the `clock' function. +// CAE XSH, Issue 4, Version 2: +// The value of CLOCKS_PER_SEC is required to be 1 million on all +// XSI-conformant systems. + +// Identifier for system-wide realtime clock. +// Monotonic system-wide clock. +// High-resolution timer from the CPU. +// Thread-specific CPU-time clock. +// Monotonic system-wide clock, not adjusted for frequency scaling. +// Identifier for system-wide realtime clock, updated only on ticks. +// Monotonic system-wide clock, updated only on ticks. +// Monotonic system-wide clock that includes time spent in suspension. +// Like CLOCK_REALTIME but also wakes suspended system. +// Like CLOCK_BOOTTIME but also wakes suspended system. +// Like CLOCK_REALTIME but in International Atomic Time. + +// Flag to indicate time is absolute. + +// Many of the typedefs and structs whose official home is this header +// may also need to be defined by other headers. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO C `broken-down time' structure. +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* struct_tm.h:7:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// AArch64 has selectable endianness. + +// Some machines may need to use a different endianness for floating point +// values. + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// NB: Include guard matches what uses. + +// POSIX.1b structure for timer start values and intervals. +type Itimerspec = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } +} /* struct_itimerspec.h:8:1 */ + +type Pid_t = X__pid_t /* time.h:54:17 */ + +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/tls_linux_amd64.go b/internal/libc/tls_linux_amd64.go new file mode 100644 index 0000000..26241fa --- /dev/null +++ b/internal/libc/tls_linux_amd64.go @@ -0,0 +1,33 @@ +// Copyright 2025 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +//go:noescape +func TLSAlloc(p0 *TLS, p1 int) uintptr + +//go:noescape +func TLSFree(p0 *TLS, p1 int) + +//go:noescape +func TLSAllocaEntry(p0 *TLS) + +//go:noescape +func TLSAllocaExit(p0 *TLS) + +func tlsAlloc(tls *TLS, n int) uintptr { + return tls.Alloc(n) +} + +func tlsFree(tls *TLS, n int) { + tls.Free(n) +} + +func tlsAllocaEntry(tls *TLS) { + tls.AllocaEntry() +} + +func tlsAllocaExit(tls *TLS) { + tls.AllocaExit() +} diff --git a/internal/libc/tls_linux_amd64.s b/internal/libc/tls_linux_amd64.s new file mode 100644 index 0000000..d726787 --- /dev/null +++ b/internal/libc/tls_linux_amd64.s @@ -0,0 +1,40 @@ +#include "funcdata.h" +#include "textflag.h" + +TEXT ·TLSAlloc(SB),$24-24 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ p0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·tlsAlloc(SB) + MOVQ 16(SP), AX + MOVQ AX, ret+16(FP) + RET + +TEXT ·TLSFree(SB),$16-16 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ p0+0(FP), AX + MOVQ AX, 0(SP) + MOVQ p1+8(FP), AX + MOVQ AX, 8(SP) + CALL ·tlsFree(SB) + RET + +TEXT ·TLSAllocaEntry(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ p0+0(FP), AX + MOVQ AX, 0(SP) + CALL ·tlsAllocaEntry(SB) + RET + +TEXT ·TLSAllocaExit(SB),$8-8 + GO_ARGS + NO_LOCAL_POINTERS + MOVQ p0+0(FP), AX + MOVQ AX, 0(SP) + CALL ·tlsAllocaExit(SB) + RET diff --git a/internal/libc/unistd/capi_darwin_amd64.go b/internal/libc/unistd/capi_darwin_amd64.go new file mode 100644 index 0000000..a25427f --- /dev/null +++ b/internal/libc/unistd/capi_darwin_amd64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo unistd/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o unistd/unistd_darwin_amd64.go -pkgname unistd', DO NOT EDIT. + +package unistd + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/unistd/capi_darwin_arm64.go b/internal/libc/unistd/capi_darwin_arm64.go new file mode 100644 index 0000000..2e89f7b --- /dev/null +++ b/internal/libc/unistd/capi_darwin_arm64.go @@ -0,0 +1,11 @@ +// Code generated by 'ccgo unistd/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o unistd/unistd_darwin_arm64.go -pkgname unistd', DO NOT EDIT. + +package unistd + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set": {}, + "__darwin_check_fd_set_overflow": {}, + "__darwin_fd_clr": {}, + "__darwin_fd_isset": {}, + "__darwin_fd_set": {}, +} diff --git a/internal/libc/unistd/capi_linux_amd64.go b/internal/libc/unistd/capi_linux_amd64.go new file mode 100644 index 0000000..4e94243 --- /dev/null +++ b/internal/libc/unistd/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo unistd/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o unistd/unistd_linux_amd64.go -pkgname unistd', DO NOT EDIT. + +package unistd + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/unistd/capi_linux_arm64.go b/internal/libc/unistd/capi_linux_arm64.go new file mode 100644 index 0000000..5476869 --- /dev/null +++ b/internal/libc/unistd/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo unistd/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o unistd/unistd_linux_arm64.go -pkgname unistd', DO NOT EDIT. + +package unistd + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/unistd/unistd_darwin_amd64.go b/internal/libc/unistd/unistd_darwin_amd64.go new file mode 100644 index 0000000..cde9eda --- /dev/null +++ b/internal/libc/unistd/unistd_darwin_amd64.go @@ -0,0 +1,3474 @@ +// Code generated by 'ccgo unistd/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o unistd/unistd_darwin_amd64.go -pkgname unistd', DO NOT EDIT. + +package unistd + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSX_MAX_DESCRIPTORS = 100 // unistd.h:137:1: + ACCESSX_MAX_TABLESIZE = 16384 // unistd.h:138:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + F_LOCK = 1 // unistd.h:528:1: + F_OK = 0 // unistd.h:89:1: + F_TEST = 3 // unistd.h:530:1: + F_TLOCK = 2 // unistd.h:529:1: + F_ULOCK = 0 // unistd.h:527:1: + L_INCR = 1 // unistd.h:127:1: + L_SET = 0 // unistd.h:126:1: + L_XTND = 2 // unistd.h:128:1: + R_OK = 4 // unistd.h:92:1: + SEEK_CUR = 1 // _seek_set.h:34:1: + SEEK_DATA = 4 // _seek_set.h:44:1: + SEEK_END = 2 // _seek_set.h:35:1: + SEEK_HOLE = 3 // _seek_set.h:40:1: + SEEK_SET = 0 // _seek_set.h:33:1: + STDERR_FILENO = 2 // unistd.h:88:1: + STDIN_FILENO = 0 // unistd.h:86:1: + STDOUT_FILENO = 1 // unistd.h:87:1: + SYNC_VOLUME_FULLSYNC = 0x01 // unistd.h:776:1: + SYNC_VOLUME_WAIT = 0x02 // unistd.h:777:1: + W_OK = 2 // unistd.h:91:1: + X_OK = 1 // unistd.h:90:1: + X_ACCESS_EXTENDED_MASK = 4193792 // unistd.h:114:1: + X_APPEND_OK = 8192 // unistd.h:104:1: + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CHOWN_OK = 2097152 // unistd.h:112:1: + X_CS_DARWIN_USER_CACHE_DIR = 65538 // unistd.h:415:1: + X_CS_DARWIN_USER_DIR = 65536 // unistd.h:413:1: + X_CS_DARWIN_USER_TEMP_DIR = 65537 // unistd.h:414:1: + X_CS_PATH = 1 // unistd.h:175:1: + X_CS_POSIX_V6_ILP32_OFF32_CFLAGS = 2 // unistd.h:377:1: + X_CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 3 // unistd.h:378:1: + X_CS_POSIX_V6_ILP32_OFF32_LIBS = 4 // unistd.h:379:1: + X_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 5 // unistd.h:380:1: + X_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 6 // unistd.h:381:1: + X_CS_POSIX_V6_ILP32_OFFBIG_LIBS = 7 // unistd.h:382:1: + X_CS_POSIX_V6_LP64_OFF64_CFLAGS = 8 // unistd.h:383:1: + X_CS_POSIX_V6_LP64_OFF64_LDFLAGS = 9 // unistd.h:384:1: + X_CS_POSIX_V6_LP64_OFF64_LIBS = 10 // unistd.h:385:1: + X_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 11 // unistd.h:386:1: + X_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 12 // unistd.h:387:1: + X_CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 13 // unistd.h:388:1: + X_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 14 // unistd.h:389:1: + X_CS_XBS5_ILP32_OFF32_CFLAGS = 20 // unistd.h:394:1: + X_CS_XBS5_ILP32_OFF32_LDFLAGS = 21 // unistd.h:395:1: + X_CS_XBS5_ILP32_OFF32_LIBS = 22 // unistd.h:396:1: + X_CS_XBS5_ILP32_OFF32_LINTFLAGS = 23 // unistd.h:397:1: + X_CS_XBS5_ILP32_OFFBIG_CFLAGS = 24 // unistd.h:398:1: + X_CS_XBS5_ILP32_OFFBIG_LDFLAGS = 25 // unistd.h:399:1: + X_CS_XBS5_ILP32_OFFBIG_LIBS = 26 // unistd.h:400:1: + X_CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 27 // unistd.h:401:1: + X_CS_XBS5_LP64_OFF64_CFLAGS = 28 // unistd.h:402:1: + X_CS_XBS5_LP64_OFF64_LDFLAGS = 29 // unistd.h:403:1: + X_CS_XBS5_LP64_OFF64_LIBS = 30 // unistd.h:404:1: + X_CS_XBS5_LP64_OFF64_LINTFLAGS = 31 // unistd.h:405:1: + X_CS_XBS5_LPBIG_OFFBIG_CFLAGS = 32 // unistd.h:406:1: + X_CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 33 // unistd.h:407:1: + X_CS_XBS5_LPBIG_OFFBIG_LIBS = 34 // unistd.h:408:1: + X_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 35 // unistd.h:409:1: + X_CTERMID_H_ = 0 // _ctermid.h:25:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_DELETE_OK = 4096 // unistd.h:103:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_EXECUTE_OK = 2048 // unistd.h:102:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_PC_2_SYMLINKS = 15 // unistd.h:160:1: + X_PC_ALLOC_SIZE_MIN = 16 // unistd.h:161:1: + X_PC_ASYNC_IO = 17 // unistd.h:162:1: + X_PC_AUTH_OPAQUE_NP = 14 // unistd.h:157:1: + X_PC_CASE_PRESERVING = 12 // unistd.h:155:1: + X_PC_CASE_SENSITIVE = 11 // unistd.h:154:1: + X_PC_CHOWN_RESTRICTED = 7 // unistd.h:148:1: + X_PC_EXTENDED_SECURITY_NP = 13 // unistd.h:156:1: + X_PC_FILESIZEBITS = 18 // unistd.h:163:1: + X_PC_LINK_MAX = 1 // unistd.h:142:1: + X_PC_MAX_CANON = 2 // unistd.h:143:1: + X_PC_MAX_INPUT = 3 // unistd.h:144:1: + X_PC_MIN_HOLE_SIZE = 27 // unistd.h:172:1: + X_PC_NAME_CHARS_MAX = 10 // unistd.h:153:1: + X_PC_NAME_MAX = 4 // unistd.h:145:1: + X_PC_NO_TRUNC = 8 // unistd.h:149:1: + X_PC_PATH_MAX = 5 // unistd.h:146:1: + X_PC_PIPE_BUF = 6 // unistd.h:147:1: + X_PC_PRIO_IO = 19 // unistd.h:164:1: + X_PC_REC_INCR_XFER_SIZE = 20 // unistd.h:165:1: + X_PC_REC_MAX_XFER_SIZE = 21 // unistd.h:166:1: + X_PC_REC_MIN_XFER_SIZE = 22 // unistd.h:167:1: + X_PC_REC_XFER_ALIGN = 23 // unistd.h:168:1: + X_PC_SYMLINK_MAX = 24 // unistd.h:169:1: + X_PC_SYNC_IO = 25 // unistd.h:170:1: + X_PC_VDISABLE = 9 // unistd.h:150:1: + X_PC_XATTR_SIZE_BITS = 26 // unistd.h:171:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_POSIX2_CHAR_TERM = 200112 // unistd.h:152:1: + X_POSIX2_C_BIND = 200112 // unistd.h:150:1: + X_POSIX2_C_DEV = 200112 // unistd.h:151:1: + X_POSIX2_FORT_DEV = -1 // unistd.h:153:1: + X_POSIX2_FORT_RUN = 200112 // unistd.h:154:1: + X_POSIX2_LOCALEDEF = 200112 // unistd.h:155:1: + X_POSIX2_PBS = -1 // unistd.h:156:1: + X_POSIX2_PBS_ACCOUNTING = -1 // unistd.h:157:1: + X_POSIX2_PBS_CHECKPOINT = -1 // unistd.h:158:1: + X_POSIX2_PBS_LOCATE = -1 // unistd.h:159:1: + X_POSIX2_PBS_MESSAGE = -1 // unistd.h:160:1: + X_POSIX2_PBS_TRACK = -1 // unistd.h:161:1: + X_POSIX2_SW_DEV = 200112 // unistd.h:162:1: + X_POSIX2_UPE = 200112 // unistd.h:163:1: + X_POSIX2_VERSION = 200112 // unistd.h:80:1: + X_POSIX_ADVISORY_INFO = -1 // unistd.h:98:1: + X_POSIX_ASYNCHRONOUS_IO = -1 // unistd.h:99:1: + X_POSIX_BARRIERS = -1 // unistd.h:100:1: + X_POSIX_CHOWN_RESTRICTED = 200112 // unistd.h:101:1: + X_POSIX_CLOCK_SELECTION = -1 // unistd.h:102:1: + X_POSIX_CPUTIME = -1 // unistd.h:103:1: + X_POSIX_FSYNC = 200112 // unistd.h:104:1: + X_POSIX_IPV6 = 200112 // unistd.h:105:1: + X_POSIX_JOB_CONTROL = 200112 // unistd.h:106:1: + X_POSIX_MAPPED_FILES = 200112 // unistd.h:107:1: + X_POSIX_MEMLOCK = -1 // unistd.h:108:1: + X_POSIX_MEMLOCK_RANGE = -1 // unistd.h:109:1: + X_POSIX_MEMORY_PROTECTION = 200112 // unistd.h:110:1: + X_POSIX_MESSAGE_PASSING = -1 // unistd.h:111:1: + X_POSIX_MONOTONIC_CLOCK = -1 // unistd.h:112:1: + X_POSIX_NO_TRUNC = 200112 // unistd.h:113:1: + X_POSIX_PRIORITIZED_IO = -1 // unistd.h:114:1: + X_POSIX_PRIORITY_SCHEDULING = -1 // unistd.h:115:1: + X_POSIX_RAW_SOCKETS = -1 // unistd.h:116:1: + X_POSIX_READER_WRITER_LOCKS = 200112 // unistd.h:117:1: + X_POSIX_REALTIME_SIGNALS = -1 // unistd.h:118:1: + X_POSIX_REGEXP = 200112 // unistd.h:119:1: + X_POSIX_SAVED_IDS = 200112 // unistd.h:120:1: + X_POSIX_SEMAPHORES = -1 // unistd.h:121:1: + X_POSIX_SHARED_MEMORY_OBJECTS = -1 // unistd.h:122:1: + X_POSIX_SHELL = 200112 // unistd.h:123:1: + X_POSIX_SPAWN = -1 // unistd.h:124:1: + X_POSIX_SPIN_LOCKS = -1 // unistd.h:125:1: + X_POSIX_SPORADIC_SERVER = -1 // unistd.h:126:1: + X_POSIX_SYNCHRONIZED_IO = -1 // unistd.h:127:1: + X_POSIX_THREADS = 200112 // unistd.h:137:1: + X_POSIX_THREAD_ATTR_STACKADDR = 200112 // unistd.h:128:1: + X_POSIX_THREAD_ATTR_STACKSIZE = 200112 // unistd.h:129:1: + X_POSIX_THREAD_CPUTIME = -1 // unistd.h:130:1: + X_POSIX_THREAD_KEYS_MAX = 128 // unistd.h:86:1: + X_POSIX_THREAD_PRIORITY_SCHEDULING = -1 // unistd.h:133:1: + X_POSIX_THREAD_PRIO_INHERIT = -1 // unistd.h:131:1: + X_POSIX_THREAD_PRIO_PROTECT = -1 // unistd.h:132:1: + X_POSIX_THREAD_PROCESS_SHARED = 200112 // unistd.h:134:1: + X_POSIX_THREAD_SAFE_FUNCTIONS = 200112 // unistd.h:135:1: + X_POSIX_THREAD_SPORADIC_SERVER = -1 // unistd.h:136:1: + X_POSIX_TIMEOUTS = -1 // unistd.h:138:1: + X_POSIX_TIMERS = -1 // unistd.h:139:1: + X_POSIX_TRACE = -1 // unistd.h:140:1: + X_POSIX_TRACE_EVENT_FILTER = -1 // unistd.h:141:1: + X_POSIX_TRACE_INHERIT = -1 // unistd.h:142:1: + X_POSIX_TRACE_LOG = -1 // unistd.h:143:1: + X_POSIX_TYPED_MEMORY_OBJECTS = -1 // unistd.h:144:1: + X_POSIX_V6_ILP32_OFF32 = -1 // unistd.h:173:1: + X_POSIX_V6_ILP32_OFFBIG = -1 // unistd.h:174:1: + X_POSIX_V6_LP64_OFF64 = 1 // unistd.h:175:1: + X_POSIX_V6_LPBIG_OFFBIG = 1 // unistd.h:176:1: + X_POSIX_V7_ILP32_OFF32 = -1 // unistd.h:180:1: + X_POSIX_V7_ILP32_OFFBIG = -1 // unistd.h:181:1: + X_POSIX_V7_LP64_OFF64 = 1 // unistd.h:182:1: + X_POSIX_V7_LPBIG_OFFBIG = 1 // unistd.h:183:1: + X_POSIX_VERSION = 200112 // unistd.h:79:1: + X_RATTR_OK = 32768 // unistd.h:106:1: + X_READ_OK = 512 // unistd.h:100:1: + X_REXT_OK = 131072 // unistd.h:108:1: + X_RMFILE_OK = 16384 // unistd.h:105:1: + X_RPERM_OK = 524288 // unistd.h:110:1: + X_SC_2_CHAR_TERM = 20 // unistd.h:232:1: + X_SC_2_C_BIND = 18 // unistd.h:230:1: + X_SC_2_C_DEV = 19 // unistd.h:231:1: + X_SC_2_FORT_DEV = 21 // unistd.h:233:1: + X_SC_2_FORT_RUN = 22 // unistd.h:234:1: + X_SC_2_LOCALEDEF = 23 // unistd.h:235:1: + X_SC_2_PBS = 59 // unistd.h:275:1: + X_SC_2_PBS_ACCOUNTING = 60 // unistd.h:276:1: + X_SC_2_PBS_CHECKPOINT = 61 // unistd.h:277:1: + X_SC_2_PBS_LOCATE = 62 // unistd.h:278:1: + X_SC_2_PBS_MESSAGE = 63 // unistd.h:279:1: + X_SC_2_PBS_TRACK = 64 // unistd.h:280:1: + X_SC_2_SW_DEV = 24 // unistd.h:236:1: + X_SC_2_UPE = 25 // unistd.h:237:1: + X_SC_2_VERSION = 17 // unistd.h:229:1: + X_SC_ADVISORY_INFO = 65 // unistd.h:281:1: + X_SC_AIO_LISTIO_MAX = 42 // unistd.h:256:1: + X_SC_AIO_MAX = 43 // unistd.h:257:1: + X_SC_AIO_PRIO_DELTA_MAX = 44 // unistd.h:258:1: + X_SC_ARG_MAX = 1 // unistd.h:213:1: + X_SC_ASYNCHRONOUS_IO = 28 // unistd.h:242:1: + X_SC_ATEXIT_MAX = 107 // unistd.h:329:1: + X_SC_BARRIERS = 66 // unistd.h:282:1: + X_SC_BC_BASE_MAX = 9 // unistd.h:221:1: + X_SC_BC_DIM_MAX = 10 // unistd.h:222:1: + X_SC_BC_SCALE_MAX = 11 // unistd.h:223:1: + X_SC_BC_STRING_MAX = 12 // unistd.h:224:1: + X_SC_CHILD_MAX = 2 // unistd.h:214:1: + X_SC_CLK_TCK = 3 // unistd.h:215:1: + X_SC_CLOCK_SELECTION = 67 // unistd.h:283:1: + X_SC_COLL_WEIGHTS_MAX = 13 // unistd.h:225:1: + X_SC_CPUTIME = 68 // unistd.h:284:1: + X_SC_DELAYTIMER_MAX = 45 // unistd.h:259:1: + X_SC_EXPR_NEST_MAX = 14 // unistd.h:226:1: + X_SC_FILE_LOCKING = 69 // unistd.h:285:1: + X_SC_FSYNC = 38 // unistd.h:252:1: + X_SC_GETGR_R_SIZE_MAX = 70 // unistd.h:286:1: + X_SC_GETPW_R_SIZE_MAX = 71 // unistd.h:287:1: + X_SC_HOST_NAME_MAX = 72 // unistd.h:288:1: + X_SC_IOV_MAX = 56 // unistd.h:330:1: + X_SC_IPV6 = 118 // unistd.h:323:1: + X_SC_JOB_CONTROL = 6 // unistd.h:218:1: + X_SC_LINE_MAX = 15 // unistd.h:227:1: + X_SC_LOGIN_NAME_MAX = 73 // unistd.h:289:1: + X_SC_MAPPED_FILES = 47 // unistd.h:261:1: + X_SC_MEMLOCK = 30 // unistd.h:244:1: + X_SC_MEMLOCK_RANGE = 31 // unistd.h:245:1: + X_SC_MEMORY_PROTECTION = 32 // unistd.h:246:1: + X_SC_MESSAGE_PASSING = 33 // unistd.h:247:1: + X_SC_MONOTONIC_CLOCK = 74 // unistd.h:290:1: + X_SC_MQ_OPEN_MAX = 46 // unistd.h:260:1: + X_SC_MQ_PRIO_MAX = 75 // unistd.h:291:1: + X_SC_NGROUPS_MAX = 4 // unistd.h:216:1: + X_SC_NPROCESSORS_CONF = 57 // unistd.h:270:1: + X_SC_NPROCESSORS_ONLN = 58 // unistd.h:271:1: + X_SC_OPEN_MAX = 5 // unistd.h:217:1: + X_SC_PAGESIZE = 29 // unistd.h:243:1: + X_SC_PAGE_SIZE = 29 // unistd.h:331:1: + X_SC_PASS_MAX = 131 // unistd.h:362:1: + X_SC_PHYS_PAGES = 200 // unistd.h:367:1: + X_SC_PRIORITIZED_IO = 34 // unistd.h:248:1: + X_SC_PRIORITY_SCHEDULING = 35 // unistd.h:249:1: + X_SC_RAW_SOCKETS = 119 // unistd.h:324:1: + X_SC_READER_WRITER_LOCKS = 76 // unistd.h:292:1: + X_SC_REALTIME_SIGNALS = 36 // unistd.h:250:1: + X_SC_REGEXP = 77 // unistd.h:293:1: + X_SC_RE_DUP_MAX = 16 // unistd.h:228:1: + X_SC_RTSIG_MAX = 48 // unistd.h:262:1: + X_SC_SAVED_IDS = 7 // unistd.h:219:1: + X_SC_SEMAPHORES = 37 // unistd.h:251:1: + X_SC_SEM_NSEMS_MAX = 49 // unistd.h:263:1: + X_SC_SEM_VALUE_MAX = 50 // unistd.h:264:1: + X_SC_SHARED_MEMORY_OBJECTS = 39 // unistd.h:253:1: + X_SC_SHELL = 78 // unistd.h:294:1: + X_SC_SIGQUEUE_MAX = 51 // unistd.h:265:1: + X_SC_SPAWN = 79 // unistd.h:295:1: + X_SC_SPIN_LOCKS = 80 // unistd.h:296:1: + X_SC_SPORADIC_SERVER = 81 // unistd.h:297:1: + X_SC_SS_REPL_MAX = 126 // unistd.h:353:1: + X_SC_STREAM_MAX = 26 // unistd.h:238:1: + X_SC_SYMLOOP_MAX = 120 // unistd.h:325:1: + X_SC_SYNCHRONIZED_IO = 40 // unistd.h:254:1: + X_SC_THREADS = 96 // unistd.h:312:1: + X_SC_THREAD_ATTR_STACKADDR = 82 // unistd.h:298:1: + X_SC_THREAD_ATTR_STACKSIZE = 83 // unistd.h:299:1: + X_SC_THREAD_CPUTIME = 84 // unistd.h:300:1: + X_SC_THREAD_DESTRUCTOR_ITERATIONS = 85 // unistd.h:301:1: + X_SC_THREAD_KEYS_MAX = 86 // unistd.h:302:1: + X_SC_THREAD_PRIORITY_SCHEDULING = 89 // unistd.h:305:1: + X_SC_THREAD_PRIO_INHERIT = 87 // unistd.h:303:1: + X_SC_THREAD_PRIO_PROTECT = 88 // unistd.h:304:1: + X_SC_THREAD_PROCESS_SHARED = 90 // unistd.h:306:1: + X_SC_THREAD_SAFE_FUNCTIONS = 91 // unistd.h:307:1: + X_SC_THREAD_SPORADIC_SERVER = 92 // unistd.h:308:1: + X_SC_THREAD_STACK_MIN = 93 // unistd.h:309:1: + X_SC_THREAD_THREADS_MAX = 94 // unistd.h:310:1: + X_SC_TIMEOUTS = 95 // unistd.h:311:1: + X_SC_TIMERS = 41 // unistd.h:255:1: + X_SC_TIMER_MAX = 52 // unistd.h:266:1: + X_SC_TRACE = 97 // unistd.h:313:1: + X_SC_TRACE_EVENT_FILTER = 98 // unistd.h:314:1: + X_SC_TRACE_EVENT_NAME_MAX = 127 // unistd.h:354:1: + X_SC_TRACE_INHERIT = 99 // unistd.h:315:1: + X_SC_TRACE_LOG = 100 // unistd.h:316:1: + X_SC_TRACE_NAME_MAX = 128 // unistd.h:355:1: + X_SC_TRACE_SYS_MAX = 129 // unistd.h:356:1: + X_SC_TRACE_USER_EVENT_MAX = 130 // unistd.h:357:1: + X_SC_TTY_NAME_MAX = 101 // unistd.h:317:1: + X_SC_TYPED_MEMORY_OBJECTS = 102 // unistd.h:318:1: + X_SC_TZNAME_MAX = 27 // unistd.h:239:1: + X_SC_V6_ILP32_OFF32 = 103 // unistd.h:319:1: + X_SC_V6_ILP32_OFFBIG = 104 // unistd.h:320:1: + X_SC_V6_LP64_OFF64 = 105 // unistd.h:321:1: + X_SC_V6_LPBIG_OFFBIG = 106 // unistd.h:322:1: + X_SC_VERSION = 8 // unistd.h:220:1: + X_SC_XBS5_ILP32_OFF32 = 122 // unistd.h:346:1: + X_SC_XBS5_ILP32_OFFBIG = 123 // unistd.h:347:1: + X_SC_XBS5_LP64_OFF64 = 124 // unistd.h:348:1: + X_SC_XBS5_LPBIG_OFFBIG = 125 // unistd.h:349:1: + X_SC_XOPEN_CRYPT = 108 // unistd.h:332:1: + X_SC_XOPEN_ENH_I18N = 109 // unistd.h:333:1: + X_SC_XOPEN_LEGACY = 110 // unistd.h:334:1: + X_SC_XOPEN_REALTIME = 111 // unistd.h:335:1: + X_SC_XOPEN_REALTIME_THREADS = 112 // unistd.h:336:1: + X_SC_XOPEN_SHM = 113 // unistd.h:337:1: + X_SC_XOPEN_STREAMS = 114 // unistd.h:338:1: + X_SC_XOPEN_UNIX = 115 // unistd.h:339:1: + X_SC_XOPEN_VERSION = 116 // unistd.h:340:1: + X_SC_XOPEN_XCU_VERSION = 121 // unistd.h:341:1: + X_SIGSET_T = 0 // _sigset_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_SELECT_H_ = 0 // select.h:64:1: + X_SYS_UNISTD_H_ = 0 // unistd.h:65:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__SELECT_H_ = 0 // _select.h:37:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINT32_T = 0 // _uint32_t.h:30:1: + X_UINT64_T = 0 // _uint64_t.h:30:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_UNISTD_H_ = 0 // unistd.h:69:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_UUID_T = 0 // _uuid_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_V6_ILP32_OFF32 = -1 // unistd.h:187:1: + X_V6_ILP32_OFFBIG = -1 // unistd.h:188:1: + X_V6_LP64_OFF64 = 1 // unistd.h:189:1: + X_V6_LPBIG_OFFBIG = 1 // unistd.h:190:1: + X_WATTR_OK = 65536 // unistd.h:107:1: + X_WEXT_OK = 262144 // unistd.h:109:1: + X_WPERM_OK = 1048576 // unistd.h:111:1: + X_WRITE_OK = 1024 // unistd.h:101:1: + X_XBS5_ILP32_OFF32 = -1 // unistd.h:195:1: + X_XBS5_ILP32_OFFBIG = -1 // unistd.h:196:1: + X_XBS5_LP64_OFF64 = 1 // unistd.h:197:1: + X_XBS5_LPBIG_OFFBIG = 1 // unistd.h:198:1: + X_XOPEN_CRYPT = 1 // unistd.h:202:1: + X_XOPEN_ENH_I18N = 1 // unistd.h:203:1: + X_XOPEN_LEGACY = -1 // unistd.h:204:1: + X_XOPEN_REALTIME = -1 // unistd.h:205:1: + X_XOPEN_REALTIME_THREADS = -1 // unistd.h:206:1: + X_XOPEN_SHM = 1 // unistd.h:207:1: + X_XOPEN_STREAMS = -1 // unistd.h:208:1: + X_XOPEN_UNIX = 1 // unistd.h:209:1: + X_XOPEN_VERSION = 600 // unistd.h:93:1: + X_XOPEN_XCU_VERSION = 4 // unistd.h:94:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000, 2002-2006, 2008-2010, 2012 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// Copyright (c) 1998-1999 Apple Computer, Inc. All Rights Reserved +// 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. +// +// @(#)unistd.h 8.12 (Berkeley) 4/27/95 +// +// Copyright (c) 1998 Apple Compter, Inc. +// All Rights Reserved + +// History: +// 7/14/99 EKN at Apple fixed getdirentriesattr from getdirentryattr +// 3/26/98 CHW at Apple added real interface to searchfs call +// 3/5/98 CHW at Apple added hfs semantic system calls headers + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1989, 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. +// +// @(#)unistd.h 8.2 (Berkeley) 1/7/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Although we have saved user/group IDs, we do not use them in setuid +// as described in POSIX 1003.1, because the feature does not work for +// root. We use the saved IDs in seteuid/setegid, which are not currently +// part of the POSIX 1003.1 specification. + +// execution-time symbolic constants +// may disable terminal special characters +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// access function + +// Extended access functions. +// Note that we depend on these matching the definitions in sys/kauth.h, +// but with the bits shifted left by 8. + +// whence values for lseek(2) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// whence values for lseek(2) + +// whence values for lseek(2); renamed by POSIX 1003.1 + +type Accessx_descriptor = struct { + Fad_name_offset uint32 + Fad_flags int32 + Fad_pad [2]int32 +} /* unistd.h:132:1 */ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uint64_t = uint64 /* _uint64_t.h:31:28 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uint32_t = uint32 /* _uint32_t.h:31:22 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// DO NOT REMOVE THIS COMMENT: fixincludes needs to see: +// _GCC_SIZE_T +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ + +// Darwin extensions + +// Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1992, 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. +// +// @(#)select.h 8.2 (Berkeley) 1/4/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The header shall define the fd_set type as a structure. +// The timespec structure shall be defined as described in +// The header shall define the timeval structure. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// Darwin extensions + +// Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1992, 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. +// +// @(#)select.h 8.2 (Berkeley) 1/4/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The header shall define the fd_set type as a structure. +// The timespec structure shall be defined as described in +// The header shall define the timeval structure. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Timeval = struct { + Ftv_sec X__darwin_time_t + Ftv_usec X__darwin_suseconds_t + F__ccgo_pad1 [4]byte +} /* _timeval.h:34:1 */ + +// The time_t and suseconds_t types shall be defined as described in +// +// The sigset_t type shall be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Sigset_t = X__darwin_sigset_t /* _sigset_t.h:31:41 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uuid_t = X__darwin_uuid_t /* _uuid_t.h:31:25 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/unistd/unistd_darwin_arm64.go b/internal/libc/unistd/unistd_darwin_arm64.go new file mode 100644 index 0000000..944b0d8 --- /dev/null +++ b/internal/libc/unistd/unistd_darwin_arm64.go @@ -0,0 +1,3489 @@ +// Code generated by 'ccgo unistd/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o unistd/unistd_darwin_arm64.go -pkgname unistd', DO NOT EDIT. + +package unistd + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + ACCESSX_MAX_DESCRIPTORS = 100 // unistd.h:137:1: + ACCESSX_MAX_TABLESIZE = 16384 // unistd.h:138:1: + FD_SETSIZE = 1024 // _fd_setsize.h:29:1: + F_LOCK = 1 // unistd.h:528:1: + F_OK = 0 // unistd.h:89:1: + F_TEST = 3 // unistd.h:530:1: + F_TLOCK = 2 // unistd.h:529:1: + F_ULOCK = 0 // unistd.h:527:1: + L_INCR = 1 // unistd.h:127:1: + L_SET = 0 // unistd.h:126:1: + L_XTND = 2 // unistd.h:128:1: + MAC_OS_VERSION_11_0 = 110000 // AvailabilityVersions.h:238:1: + MAC_OS_VERSION_12_0 = 120000 // AvailabilityVersions.h:239:1: + MAC_OS_X_VERSION_10_0 = 1000 // AvailabilityVersions.h:206:1: + MAC_OS_X_VERSION_10_1 = 1010 // AvailabilityVersions.h:207:1: + MAC_OS_X_VERSION_10_10 = 101000 // AvailabilityVersions.h:216:1: + MAC_OS_X_VERSION_10_10_2 = 101002 // AvailabilityVersions.h:217:1: + MAC_OS_X_VERSION_10_10_3 = 101003 // AvailabilityVersions.h:218:1: + MAC_OS_X_VERSION_10_11 = 101100 // AvailabilityVersions.h:219:1: + MAC_OS_X_VERSION_10_11_2 = 101102 // AvailabilityVersions.h:220:1: + MAC_OS_X_VERSION_10_11_3 = 101103 // AvailabilityVersions.h:221:1: + MAC_OS_X_VERSION_10_11_4 = 101104 // AvailabilityVersions.h:222:1: + MAC_OS_X_VERSION_10_12 = 101200 // AvailabilityVersions.h:223:1: + MAC_OS_X_VERSION_10_12_1 = 101201 // AvailabilityVersions.h:224:1: + MAC_OS_X_VERSION_10_12_2 = 101202 // AvailabilityVersions.h:225:1: + MAC_OS_X_VERSION_10_12_4 = 101204 // AvailabilityVersions.h:226:1: + MAC_OS_X_VERSION_10_13 = 101300 // AvailabilityVersions.h:227:1: + MAC_OS_X_VERSION_10_13_1 = 101301 // AvailabilityVersions.h:228:1: + MAC_OS_X_VERSION_10_13_2 = 101302 // AvailabilityVersions.h:229:1: + MAC_OS_X_VERSION_10_13_4 = 101304 // AvailabilityVersions.h:230:1: + MAC_OS_X_VERSION_10_14 = 101400 // AvailabilityVersions.h:231:1: + MAC_OS_X_VERSION_10_14_1 = 101401 // AvailabilityVersions.h:232:1: + MAC_OS_X_VERSION_10_14_4 = 101404 // AvailabilityVersions.h:233:1: + MAC_OS_X_VERSION_10_14_6 = 101406 // AvailabilityVersions.h:234:1: + MAC_OS_X_VERSION_10_15 = 101500 // AvailabilityVersions.h:235:1: + MAC_OS_X_VERSION_10_15_1 = 101501 // AvailabilityVersions.h:236:1: + MAC_OS_X_VERSION_10_16 = 101600 // AvailabilityVersions.h:237:1: + MAC_OS_X_VERSION_10_2 = 1020 // AvailabilityVersions.h:208:1: + MAC_OS_X_VERSION_10_3 = 1030 // AvailabilityVersions.h:209:1: + MAC_OS_X_VERSION_10_4 = 1040 // AvailabilityVersions.h:210:1: + MAC_OS_X_VERSION_10_5 = 1050 // AvailabilityVersions.h:211:1: + MAC_OS_X_VERSION_10_6 = 1060 // AvailabilityVersions.h:212:1: + MAC_OS_X_VERSION_10_7 = 1070 // AvailabilityVersions.h:213:1: + MAC_OS_X_VERSION_10_8 = 1080 // AvailabilityVersions.h:214:1: + MAC_OS_X_VERSION_10_9 = 1090 // AvailabilityVersions.h:215:1: + R_OK = 4 // unistd.h:92:1: + SEEK_CUR = 1 // _seek_set.h:34:1: + SEEK_DATA = 4 // _seek_set.h:44:1: + SEEK_END = 2 // _seek_set.h:35:1: + SEEK_HOLE = 3 // _seek_set.h:40:1: + SEEK_SET = 0 // _seek_set.h:33:1: + STDERR_FILENO = 2 // unistd.h:88:1: + STDIN_FILENO = 0 // unistd.h:86:1: + STDOUT_FILENO = 1 // unistd.h:87:1: + SYNC_VOLUME_FULLSYNC = 0x01 // unistd.h:780:1: + SYNC_VOLUME_WAIT = 0x02 // unistd.h:781:1: + W_OK = 2 // unistd.h:91:1: + X_OK = 1 // unistd.h:90:1: + X_ACCESS_EXTENDED_MASK = 4193792 // unistd.h:114:1: + X_APPEND_OK = 8192 // unistd.h:104:1: + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CHOWN_OK = 2097152 // unistd.h:112:1: + X_CS_DARWIN_USER_CACHE_DIR = 65538 // unistd.h:415:1: + X_CS_DARWIN_USER_DIR = 65536 // unistd.h:413:1: + X_CS_DARWIN_USER_TEMP_DIR = 65537 // unistd.h:414:1: + X_CS_PATH = 1 // unistd.h:175:1: + X_CS_POSIX_V6_ILP32_OFF32_CFLAGS = 2 // unistd.h:377:1: + X_CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 3 // unistd.h:378:1: + X_CS_POSIX_V6_ILP32_OFF32_LIBS = 4 // unistd.h:379:1: + X_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 5 // unistd.h:380:1: + X_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 6 // unistd.h:381:1: + X_CS_POSIX_V6_ILP32_OFFBIG_LIBS = 7 // unistd.h:382:1: + X_CS_POSIX_V6_LP64_OFF64_CFLAGS = 8 // unistd.h:383:1: + X_CS_POSIX_V6_LP64_OFF64_LDFLAGS = 9 // unistd.h:384:1: + X_CS_POSIX_V6_LP64_OFF64_LIBS = 10 // unistd.h:385:1: + X_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 11 // unistd.h:386:1: + X_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 12 // unistd.h:387:1: + X_CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 13 // unistd.h:388:1: + X_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 14 // unistd.h:389:1: + X_CS_XBS5_ILP32_OFF32_CFLAGS = 20 // unistd.h:394:1: + X_CS_XBS5_ILP32_OFF32_LDFLAGS = 21 // unistd.h:395:1: + X_CS_XBS5_ILP32_OFF32_LIBS = 22 // unistd.h:396:1: + X_CS_XBS5_ILP32_OFF32_LINTFLAGS = 23 // unistd.h:397:1: + X_CS_XBS5_ILP32_OFFBIG_CFLAGS = 24 // unistd.h:398:1: + X_CS_XBS5_ILP32_OFFBIG_LDFLAGS = 25 // unistd.h:399:1: + X_CS_XBS5_ILP32_OFFBIG_LIBS = 26 // unistd.h:400:1: + X_CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 27 // unistd.h:401:1: + X_CS_XBS5_LP64_OFF64_CFLAGS = 28 // unistd.h:402:1: + X_CS_XBS5_LP64_OFF64_LDFLAGS = 29 // unistd.h:403:1: + X_CS_XBS5_LP64_OFF64_LIBS = 30 // unistd.h:404:1: + X_CS_XBS5_LP64_OFF64_LINTFLAGS = 31 // unistd.h:405:1: + X_CS_XBS5_LPBIG_OFFBIG_CFLAGS = 32 // unistd.h:406:1: + X_CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 33 // unistd.h:407:1: + X_CS_XBS5_LPBIG_OFFBIG_LIBS = 34 // unistd.h:408:1: + X_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 35 // unistd.h:409:1: + X_CTERMID_H_ = 0 // _ctermid.h:25:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_DELETE_OK = 4096 // unistd.h:103:1: + X_DEV_T = 0 // _dev_t.h:29:1: + X_EXECUTE_OK = 2048 // unistd.h:102:1: + X_FD_SET = 0 // _fd_def.h:29:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_GID_T = 0 // _gid_t.h:29:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_MODE_T = 0 // _mode_t.h:29:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_OFF_T = 0 // _off_t.h:29:1: + X_PC_2_SYMLINKS = 15 // unistd.h:160:1: + X_PC_ALLOC_SIZE_MIN = 16 // unistd.h:161:1: + X_PC_ASYNC_IO = 17 // unistd.h:162:1: + X_PC_AUTH_OPAQUE_NP = 14 // unistd.h:157:1: + X_PC_CASE_PRESERVING = 12 // unistd.h:155:1: + X_PC_CASE_SENSITIVE = 11 // unistd.h:154:1: + X_PC_CHOWN_RESTRICTED = 7 // unistd.h:148:1: + X_PC_EXTENDED_SECURITY_NP = 13 // unistd.h:156:1: + X_PC_FILESIZEBITS = 18 // unistd.h:163:1: + X_PC_LINK_MAX = 1 // unistd.h:142:1: + X_PC_MAX_CANON = 2 // unistd.h:143:1: + X_PC_MAX_INPUT = 3 // unistd.h:144:1: + X_PC_MIN_HOLE_SIZE = 27 // unistd.h:172:1: + X_PC_NAME_CHARS_MAX = 10 // unistd.h:153:1: + X_PC_NAME_MAX = 4 // unistd.h:145:1: + X_PC_NO_TRUNC = 8 // unistd.h:149:1: + X_PC_PATH_MAX = 5 // unistd.h:146:1: + X_PC_PIPE_BUF = 6 // unistd.h:147:1: + X_PC_PRIO_IO = 19 // unistd.h:164:1: + X_PC_REC_INCR_XFER_SIZE = 20 // unistd.h:165:1: + X_PC_REC_MAX_XFER_SIZE = 21 // unistd.h:166:1: + X_PC_REC_MIN_XFER_SIZE = 22 // unistd.h:167:1: + X_PC_REC_XFER_ALIGN = 23 // unistd.h:168:1: + X_PC_SYMLINK_MAX = 24 // unistd.h:169:1: + X_PC_SYNC_IO = 25 // unistd.h:170:1: + X_PC_VDISABLE = 9 // unistd.h:150:1: + X_PC_XATTR_SIZE_BITS = 26 // unistd.h:171:1: + X_PID_T = 0 // _pid_t.h:29:1: + X_POSIX2_CHAR_TERM = 200112 // unistd.h:152:1: + X_POSIX2_C_BIND = 200112 // unistd.h:150:1: + X_POSIX2_C_DEV = 200112 // unistd.h:151:1: + X_POSIX2_FORT_DEV = -1 // unistd.h:153:1: + X_POSIX2_FORT_RUN = 200112 // unistd.h:154:1: + X_POSIX2_LOCALEDEF = 200112 // unistd.h:155:1: + X_POSIX2_PBS = -1 // unistd.h:156:1: + X_POSIX2_PBS_ACCOUNTING = -1 // unistd.h:157:1: + X_POSIX2_PBS_CHECKPOINT = -1 // unistd.h:158:1: + X_POSIX2_PBS_LOCATE = -1 // unistd.h:159:1: + X_POSIX2_PBS_MESSAGE = -1 // unistd.h:160:1: + X_POSIX2_PBS_TRACK = -1 // unistd.h:161:1: + X_POSIX2_SW_DEV = 200112 // unistd.h:162:1: + X_POSIX2_UPE = 200112 // unistd.h:163:1: + X_POSIX2_VERSION = 200112 // unistd.h:80:1: + X_POSIX_ADVISORY_INFO = -1 // unistd.h:98:1: + X_POSIX_ASYNCHRONOUS_IO = -1 // unistd.h:99:1: + X_POSIX_BARRIERS = -1 // unistd.h:100:1: + X_POSIX_CHOWN_RESTRICTED = 200112 // unistd.h:101:1: + X_POSIX_CLOCK_SELECTION = -1 // unistd.h:102:1: + X_POSIX_CPUTIME = -1 // unistd.h:103:1: + X_POSIX_FSYNC = 200112 // unistd.h:104:1: + X_POSIX_IPV6 = 200112 // unistd.h:105:1: + X_POSIX_JOB_CONTROL = 200112 // unistd.h:106:1: + X_POSIX_MAPPED_FILES = 200112 // unistd.h:107:1: + X_POSIX_MEMLOCK = -1 // unistd.h:108:1: + X_POSIX_MEMLOCK_RANGE = -1 // unistd.h:109:1: + X_POSIX_MEMORY_PROTECTION = 200112 // unistd.h:110:1: + X_POSIX_MESSAGE_PASSING = -1 // unistd.h:111:1: + X_POSIX_MONOTONIC_CLOCK = -1 // unistd.h:112:1: + X_POSIX_NO_TRUNC = 200112 // unistd.h:113:1: + X_POSIX_PRIORITIZED_IO = -1 // unistd.h:114:1: + X_POSIX_PRIORITY_SCHEDULING = -1 // unistd.h:115:1: + X_POSIX_RAW_SOCKETS = -1 // unistd.h:116:1: + X_POSIX_READER_WRITER_LOCKS = 200112 // unistd.h:117:1: + X_POSIX_REALTIME_SIGNALS = -1 // unistd.h:118:1: + X_POSIX_REGEXP = 200112 // unistd.h:119:1: + X_POSIX_SAVED_IDS = 200112 // unistd.h:120:1: + X_POSIX_SEMAPHORES = -1 // unistd.h:121:1: + X_POSIX_SHARED_MEMORY_OBJECTS = -1 // unistd.h:122:1: + X_POSIX_SHELL = 200112 // unistd.h:123:1: + X_POSIX_SPAWN = -1 // unistd.h:124:1: + X_POSIX_SPIN_LOCKS = -1 // unistd.h:125:1: + X_POSIX_SPORADIC_SERVER = -1 // unistd.h:126:1: + X_POSIX_SYNCHRONIZED_IO = -1 // unistd.h:127:1: + X_POSIX_THREADS = 200112 // unistd.h:137:1: + X_POSIX_THREAD_ATTR_STACKADDR = 200112 // unistd.h:128:1: + X_POSIX_THREAD_ATTR_STACKSIZE = 200112 // unistd.h:129:1: + X_POSIX_THREAD_CPUTIME = -1 // unistd.h:130:1: + X_POSIX_THREAD_KEYS_MAX = 128 // unistd.h:86:1: + X_POSIX_THREAD_PRIORITY_SCHEDULING = -1 // unistd.h:133:1: + X_POSIX_THREAD_PRIO_INHERIT = -1 // unistd.h:131:1: + X_POSIX_THREAD_PRIO_PROTECT = -1 // unistd.h:132:1: + X_POSIX_THREAD_PROCESS_SHARED = 200112 // unistd.h:134:1: + X_POSIX_THREAD_SAFE_FUNCTIONS = 200112 // unistd.h:135:1: + X_POSIX_THREAD_SPORADIC_SERVER = -1 // unistd.h:136:1: + X_POSIX_TIMEOUTS = -1 // unistd.h:138:1: + X_POSIX_TIMERS = -1 // unistd.h:139:1: + X_POSIX_TRACE = -1 // unistd.h:140:1: + X_POSIX_TRACE_EVENT_FILTER = -1 // unistd.h:141:1: + X_POSIX_TRACE_INHERIT = -1 // unistd.h:142:1: + X_POSIX_TRACE_LOG = -1 // unistd.h:143:1: + X_POSIX_TYPED_MEMORY_OBJECTS = -1 // unistd.h:144:1: + X_POSIX_V6_ILP32_OFF32 = -1 // unistd.h:173:1: + X_POSIX_V6_ILP32_OFFBIG = -1 // unistd.h:174:1: + X_POSIX_V6_LP64_OFF64 = 1 // unistd.h:175:1: + X_POSIX_V6_LPBIG_OFFBIG = 1 // unistd.h:176:1: + X_POSIX_V7_ILP32_OFF32 = -1 // unistd.h:180:1: + X_POSIX_V7_ILP32_OFFBIG = -1 // unistd.h:181:1: + X_POSIX_V7_LP64_OFF64 = 1 // unistd.h:182:1: + X_POSIX_V7_LPBIG_OFFBIG = 1 // unistd.h:183:1: + X_POSIX_VERSION = 200112 // unistd.h:79:1: + X_RATTR_OK = 32768 // unistd.h:106:1: + X_READ_OK = 512 // unistd.h:100:1: + X_REXT_OK = 131072 // unistd.h:108:1: + X_RMFILE_OK = 16384 // unistd.h:105:1: + X_RPERM_OK = 524288 // unistd.h:110:1: + X_SC_2_CHAR_TERM = 20 // unistd.h:232:1: + X_SC_2_C_BIND = 18 // unistd.h:230:1: + X_SC_2_C_DEV = 19 // unistd.h:231:1: + X_SC_2_FORT_DEV = 21 // unistd.h:233:1: + X_SC_2_FORT_RUN = 22 // unistd.h:234:1: + X_SC_2_LOCALEDEF = 23 // unistd.h:235:1: + X_SC_2_PBS = 59 // unistd.h:275:1: + X_SC_2_PBS_ACCOUNTING = 60 // unistd.h:276:1: + X_SC_2_PBS_CHECKPOINT = 61 // unistd.h:277:1: + X_SC_2_PBS_LOCATE = 62 // unistd.h:278:1: + X_SC_2_PBS_MESSAGE = 63 // unistd.h:279:1: + X_SC_2_PBS_TRACK = 64 // unistd.h:280:1: + X_SC_2_SW_DEV = 24 // unistd.h:236:1: + X_SC_2_UPE = 25 // unistd.h:237:1: + X_SC_2_VERSION = 17 // unistd.h:229:1: + X_SC_ADVISORY_INFO = 65 // unistd.h:281:1: + X_SC_AIO_LISTIO_MAX = 42 // unistd.h:256:1: + X_SC_AIO_MAX = 43 // unistd.h:257:1: + X_SC_AIO_PRIO_DELTA_MAX = 44 // unistd.h:258:1: + X_SC_ARG_MAX = 1 // unistd.h:213:1: + X_SC_ASYNCHRONOUS_IO = 28 // unistd.h:242:1: + X_SC_ATEXIT_MAX = 107 // unistd.h:329:1: + X_SC_BARRIERS = 66 // unistd.h:282:1: + X_SC_BC_BASE_MAX = 9 // unistd.h:221:1: + X_SC_BC_DIM_MAX = 10 // unistd.h:222:1: + X_SC_BC_SCALE_MAX = 11 // unistd.h:223:1: + X_SC_BC_STRING_MAX = 12 // unistd.h:224:1: + X_SC_CHILD_MAX = 2 // unistd.h:214:1: + X_SC_CLK_TCK = 3 // unistd.h:215:1: + X_SC_CLOCK_SELECTION = 67 // unistd.h:283:1: + X_SC_COLL_WEIGHTS_MAX = 13 // unistd.h:225:1: + X_SC_CPUTIME = 68 // unistd.h:284:1: + X_SC_DELAYTIMER_MAX = 45 // unistd.h:259:1: + X_SC_EXPR_NEST_MAX = 14 // unistd.h:226:1: + X_SC_FILE_LOCKING = 69 // unistd.h:285:1: + X_SC_FSYNC = 38 // unistd.h:252:1: + X_SC_GETGR_R_SIZE_MAX = 70 // unistd.h:286:1: + X_SC_GETPW_R_SIZE_MAX = 71 // unistd.h:287:1: + X_SC_HOST_NAME_MAX = 72 // unistd.h:288:1: + X_SC_IOV_MAX = 56 // unistd.h:330:1: + X_SC_IPV6 = 118 // unistd.h:323:1: + X_SC_JOB_CONTROL = 6 // unistd.h:218:1: + X_SC_LINE_MAX = 15 // unistd.h:227:1: + X_SC_LOGIN_NAME_MAX = 73 // unistd.h:289:1: + X_SC_MAPPED_FILES = 47 // unistd.h:261:1: + X_SC_MEMLOCK = 30 // unistd.h:244:1: + X_SC_MEMLOCK_RANGE = 31 // unistd.h:245:1: + X_SC_MEMORY_PROTECTION = 32 // unistd.h:246:1: + X_SC_MESSAGE_PASSING = 33 // unistd.h:247:1: + X_SC_MONOTONIC_CLOCK = 74 // unistd.h:290:1: + X_SC_MQ_OPEN_MAX = 46 // unistd.h:260:1: + X_SC_MQ_PRIO_MAX = 75 // unistd.h:291:1: + X_SC_NGROUPS_MAX = 4 // unistd.h:216:1: + X_SC_NPROCESSORS_CONF = 57 // unistd.h:270:1: + X_SC_NPROCESSORS_ONLN = 58 // unistd.h:271:1: + X_SC_OPEN_MAX = 5 // unistd.h:217:1: + X_SC_PAGESIZE = 29 // unistd.h:243:1: + X_SC_PAGE_SIZE = 29 // unistd.h:331:1: + X_SC_PASS_MAX = 131 // unistd.h:362:1: + X_SC_PHYS_PAGES = 200 // unistd.h:367:1: + X_SC_PRIORITIZED_IO = 34 // unistd.h:248:1: + X_SC_PRIORITY_SCHEDULING = 35 // unistd.h:249:1: + X_SC_RAW_SOCKETS = 119 // unistd.h:324:1: + X_SC_READER_WRITER_LOCKS = 76 // unistd.h:292:1: + X_SC_REALTIME_SIGNALS = 36 // unistd.h:250:1: + X_SC_REGEXP = 77 // unistd.h:293:1: + X_SC_RE_DUP_MAX = 16 // unistd.h:228:1: + X_SC_RTSIG_MAX = 48 // unistd.h:262:1: + X_SC_SAVED_IDS = 7 // unistd.h:219:1: + X_SC_SEMAPHORES = 37 // unistd.h:251:1: + X_SC_SEM_NSEMS_MAX = 49 // unistd.h:263:1: + X_SC_SEM_VALUE_MAX = 50 // unistd.h:264:1: + X_SC_SHARED_MEMORY_OBJECTS = 39 // unistd.h:253:1: + X_SC_SHELL = 78 // unistd.h:294:1: + X_SC_SIGQUEUE_MAX = 51 // unistd.h:265:1: + X_SC_SPAWN = 79 // unistd.h:295:1: + X_SC_SPIN_LOCKS = 80 // unistd.h:296:1: + X_SC_SPORADIC_SERVER = 81 // unistd.h:297:1: + X_SC_SS_REPL_MAX = 126 // unistd.h:353:1: + X_SC_STREAM_MAX = 26 // unistd.h:238:1: + X_SC_SYMLOOP_MAX = 120 // unistd.h:325:1: + X_SC_SYNCHRONIZED_IO = 40 // unistd.h:254:1: + X_SC_THREADS = 96 // unistd.h:312:1: + X_SC_THREAD_ATTR_STACKADDR = 82 // unistd.h:298:1: + X_SC_THREAD_ATTR_STACKSIZE = 83 // unistd.h:299:1: + X_SC_THREAD_CPUTIME = 84 // unistd.h:300:1: + X_SC_THREAD_DESTRUCTOR_ITERATIONS = 85 // unistd.h:301:1: + X_SC_THREAD_KEYS_MAX = 86 // unistd.h:302:1: + X_SC_THREAD_PRIORITY_SCHEDULING = 89 // unistd.h:305:1: + X_SC_THREAD_PRIO_INHERIT = 87 // unistd.h:303:1: + X_SC_THREAD_PRIO_PROTECT = 88 // unistd.h:304:1: + X_SC_THREAD_PROCESS_SHARED = 90 // unistd.h:306:1: + X_SC_THREAD_SAFE_FUNCTIONS = 91 // unistd.h:307:1: + X_SC_THREAD_SPORADIC_SERVER = 92 // unistd.h:308:1: + X_SC_THREAD_STACK_MIN = 93 // unistd.h:309:1: + X_SC_THREAD_THREADS_MAX = 94 // unistd.h:310:1: + X_SC_TIMEOUTS = 95 // unistd.h:311:1: + X_SC_TIMERS = 41 // unistd.h:255:1: + X_SC_TIMER_MAX = 52 // unistd.h:266:1: + X_SC_TRACE = 97 // unistd.h:313:1: + X_SC_TRACE_EVENT_FILTER = 98 // unistd.h:314:1: + X_SC_TRACE_EVENT_NAME_MAX = 127 // unistd.h:354:1: + X_SC_TRACE_INHERIT = 99 // unistd.h:315:1: + X_SC_TRACE_LOG = 100 // unistd.h:316:1: + X_SC_TRACE_NAME_MAX = 128 // unistd.h:355:1: + X_SC_TRACE_SYS_MAX = 129 // unistd.h:356:1: + X_SC_TRACE_USER_EVENT_MAX = 130 // unistd.h:357:1: + X_SC_TTY_NAME_MAX = 101 // unistd.h:317:1: + X_SC_TYPED_MEMORY_OBJECTS = 102 // unistd.h:318:1: + X_SC_TZNAME_MAX = 27 // unistd.h:239:1: + X_SC_V6_ILP32_OFF32 = 103 // unistd.h:319:1: + X_SC_V6_ILP32_OFFBIG = 104 // unistd.h:320:1: + X_SC_V6_LP64_OFF64 = 105 // unistd.h:321:1: + X_SC_V6_LPBIG_OFFBIG = 106 // unistd.h:322:1: + X_SC_VERSION = 8 // unistd.h:220:1: + X_SC_XBS5_ILP32_OFF32 = 122 // unistd.h:346:1: + X_SC_XBS5_ILP32_OFFBIG = 123 // unistd.h:347:1: + X_SC_XBS5_LP64_OFF64 = 124 // unistd.h:348:1: + X_SC_XBS5_LPBIG_OFFBIG = 125 // unistd.h:349:1: + X_SC_XOPEN_CRYPT = 108 // unistd.h:332:1: + X_SC_XOPEN_ENH_I18N = 109 // unistd.h:333:1: + X_SC_XOPEN_LEGACY = 110 // unistd.h:334:1: + X_SC_XOPEN_REALTIME = 111 // unistd.h:335:1: + X_SC_XOPEN_REALTIME_THREADS = 112 // unistd.h:336:1: + X_SC_XOPEN_SHM = 113 // unistd.h:337:1: + X_SC_XOPEN_STREAMS = 114 // unistd.h:338:1: + X_SC_XOPEN_UNIX = 115 // unistd.h:339:1: + X_SC_XOPEN_VERSION = 116 // unistd.h:340:1: + X_SC_XOPEN_XCU_VERSION = 121 // unistd.h:341:1: + X_SIGSET_T = 0 // _sigset_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SSIZE_T = 0 // _ssize_t.h:29:1: + X_SUSECONDS_T = 0 // _suseconds_t.h:29:1: + X_SYS_SELECT_H_ = 0 // select.h:64:1: + X_SYS_UNISTD_H_ = 0 // unistd.h:65:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__SELECT_H_ = 0 // _select.h:37:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UID_T = 0 // _uid_t.h:29:1: + X_UINT32_T = 0 // _uint32_t.h:30:1: + X_UINT64_T = 0 // _uint64_t.h:30:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_UNISTD_H_ = 0 // unistd.h:69:1: + X_USECONDS_T = 0 // _useconds_t.h:29:1: + X_UUID_T = 0 // _uuid_t.h:29:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: + X_V6_ILP32_OFF32 = -1 // unistd.h:187:1: + X_V6_ILP32_OFFBIG = -1 // unistd.h:188:1: + X_V6_LP64_OFF64 = 1 // unistd.h:189:1: + X_V6_LPBIG_OFFBIG = 1 // unistd.h:190:1: + X_WATTR_OK = 65536 // unistd.h:107:1: + X_WEXT_OK = 262144 // unistd.h:109:1: + X_WPERM_OK = 1048576 // unistd.h:111:1: + X_WRITE_OK = 1024 // unistd.h:101:1: + X_XBS5_ILP32_OFF32 = -1 // unistd.h:195:1: + X_XBS5_ILP32_OFFBIG = -1 // unistd.h:196:1: + X_XBS5_LP64_OFF64 = 1 // unistd.h:197:1: + X_XBS5_LPBIG_OFFBIG = 1 // unistd.h:198:1: + X_XOPEN_CRYPT = 1 // unistd.h:202:1: + X_XOPEN_ENH_I18N = 1 // unistd.h:203:1: + X_XOPEN_LEGACY = -1 // unistd.h:204:1: + X_XOPEN_REALTIME = -1 // unistd.h:205:1: + X_XOPEN_REALTIME_THREADS = -1 // unistd.h:206:1: + X_XOPEN_SHM = 1 // unistd.h:207:1: + X_XOPEN_STREAMS = -1 // unistd.h:208:1: + X_XOPEN_UNIX = 1 // unistd.h:209:1: + X_XOPEN_VERSION = 600 // unistd.h:93:1: + X_XOPEN_XCU_VERSION = 4 // unistd.h:94:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000, 2002-2006, 2008-2010, 2012 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// Copyright (c) 1998-1999 Apple Computer, Inc. All Rights Reserved +// 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. +// +// @(#)unistd.h 8.12 (Berkeley) 4/27/95 +// +// Copyright (c) 1998 Apple Compter, Inc. +// All Rights Reserved + +// History: +// 7/14/99 EKN at Apple fixed getdirentriesattr from getdirentryattr +// 3/26/98 CHW at Apple added real interface to searchfs call +// 3/5/98 CHW at Apple added hfs semantic system calls headers + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2000-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved +// Copyright (c) 1989, 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. +// +// @(#)unistd.h 8.2 (Berkeley) 1/7/94 + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Although we have saved user/group IDs, we do not use them in setuid +// as described in POSIX 1003.1, because the feature does not work for +// root. We use the saved IDs in seteuid/setegid, which are not currently +// part of the POSIX 1003.1 specification. + +// execution-time symbolic constants +// may disable terminal special characters +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// access function + +// Extended access functions. +// Note that we depend on these matching the definitions in sys/kauth.h, +// but with the bits shifted left by 8. + +// whence values for lseek(2) +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// whence values for lseek(2) + +// whence values for lseek(2); renamed by POSIX 1003.1 + +type Accessx_descriptor = struct { + Fad_name_offset uint32 + Fad_flags int32 + Fad_pad [2]int32 +} /* unistd.h:132:1 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type Ssize_t = X__darwin_ssize_t /* _ssize_t.h:31:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uint64_t = uint64 /* _uint64_t.h:31:28 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uint32_t = uint32 /* _uint32_t.h:31:22 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uid_t = X__darwin_uid_t /* _uid_t.h:31:31 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Gid_t = X__darwin_gid_t /* _gid_t.h:31:25 */ + +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Off_t = X__darwin_off_t /* _off_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Pid_t = X__darwin_pid_t /* _pid_t.h:31:31 */ +// DO NOT REMOVE THIS COMMENT: fixincludes needs to see: +// _GCC_SIZE_T +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Useconds_t = X__darwin_useconds_t /* _useconds_t.h:31:33 */ + +// Darwin extensions + +// Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1992, 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. +// +// @(#)select.h 8.2 (Berkeley) 1/4/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The header shall define the fd_set type as a structure. +// The timespec structure shall be defined as described in +// The header shall define the timeval structure. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set1 = struct{ Ffds_bits [32]X__int32_t } /* _fd_def.h:50:9 */ + +// Darwin extensions + +// Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 1992, 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. +// +// @(#)select.h 8.2 (Berkeley) 1/4/94 + +// Copyright (c) 2002 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// [XSI] The header shall define the fd_set type as a structure. +// The timespec structure shall be defined as described in +// The header shall define the timeval structure. +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2007-2016 by Apple Inc.. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Select uses bit masks of file descriptors in longs. These macros +// manipulate such bit fields (the filesystem macros use chars). The +// extra protection here is to permit application redefinition above +// the default size. + +type Fd_set = Fd_set1 /* _fd_def.h:52:3 */ + +// Use the built-in bzero function instead of the library version so that +// we do not pollute the namespace or introduce prototype warnings. + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Timespec = struct { + Ftv_sec X__darwin_time_t + Ftv_nsec int64 +} /* _timespec.h:33:1 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Timeval = struct { + Ftv_sec X__darwin_time_t + Ftv_usec X__darwin_suseconds_t + F__ccgo_pad1 [4]byte +} /* _timeval.h:34:1 */ + +// The time_t and suseconds_t types shall be defined as described in +// +// The sigset_t type shall be defined as described in +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Suseconds_t = X__darwin_suseconds_t /* _suseconds_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Sigset_t = X__darwin_sigset_t /* _sigset_t.h:31:41 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Dev_t = X__darwin_dev_t /* _dev_t.h:31:31 */ // device number +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Mode_t = X__darwin_mode_t /* _mode_t.h:31:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uuid_t = X__darwin_uuid_t /* _uuid_t.h:31:25 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/unistd/unistd_linux_amd64.go b/internal/libc/unistd/unistd_linux_amd64.go new file mode 100644 index 0000000..650ff27 --- /dev/null +++ b/internal/libc/unistd/unistd_linux_amd64.go @@ -0,0 +1,1592 @@ +// Code generated by 'ccgo unistd/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o unistd/unistd_linux_amd64.go -pkgname unistd', DO NOT EDIT. + +package unistd + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + F_LOCK = 1 // unistd.h:1074:1: + F_OK = 0 // unistd.h:284:1: + F_TEST = 3 // unistd.h:1076:1: + F_TLOCK = 2 // unistd.h:1075:1: + F_ULOCK = 0 // unistd.h:1073:1: + L_INCR = 1 // unistd.h:323:1: + L_SET = 0 // unistd.h:322:1: + L_XTND = 2 // unistd.h:324:1: + R_OK = 4 // unistd.h:281:1: + SEEK_CUR = 1 // unistd.h:312:1: + SEEK_END = 2 // unistd.h:313:1: + SEEK_SET = 0 // unistd.h:311:1: + STDERR_FILENO = 2 // unistd.h:212:1: + STDIN_FILENO = 0 // unistd.h:210:1: + STDOUT_FILENO = 1 // unistd.h:211:1: + W_OK = 2 // unistd.h:282:1: + X_OK = 1 // unistd.h:283:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_POSIX_OPT_H = 1 // posix_opt.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_GETOPT_CORE_H = 1 // getopt_core.h:21:1: + X_GETOPT_POSIX_H = 1 // getopt_posix.h:21:1: + X_LFS64_ASYNCHRONOUS_IO = 1 // posix_opt.h:117:1: + X_LFS64_LARGEFILE = 1 // posix_opt.h:121:1: + X_LFS64_STDIO = 1 // posix_opt.h:122:1: + X_LFS_ASYNCHRONOUS_IO = 1 // posix_opt.h:112:1: + X_LFS_LARGEFILE = 1 // posix_opt.h:120:1: + X_LP64 = 1 // :284:1: + X_POSIX2_CHAR_TERM = 200809 // posix_opt.h:179:1: + X_POSIX2_C_BIND = 200809 // unistd.h:74:1: + X_POSIX2_C_DEV = 200809 // unistd.h:78:1: + X_POSIX2_C_VERSION = 200809 // unistd.h:70:1: + X_POSIX2_LOCALEDEF = 200809 // unistd.h:86:1: + X_POSIX2_SW_DEV = 200809 // unistd.h:82:1: + X_POSIX2_VERSION = 200809 // unistd.h:67:1: + X_POSIX_ADVISORY_INFO = 200809 // posix_opt.h:170:1: + X_POSIX_ASYNCHRONOUS_IO = 200809 // posix_opt.h:109:1: + X_POSIX_ASYNC_IO = 1 // posix_opt.h:110:1: + X_POSIX_BARRIERS = 200809 // posix_opt.h:155:1: + X_POSIX_CHOWN_RESTRICTED = 0 // posix_opt.h:53:1: + X_POSIX_CLOCK_SELECTION = 200809 // posix_opt.h:167:1: + X_POSIX_CPUTIME = 0 // posix_opt.h:128:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_FSYNC = 200809 // posix_opt.h:38:1: + X_POSIX_IPV6 = 200809 // posix_opt.h:173:1: + X_POSIX_JOB_CONTROL = 1 // posix_opt.h:23:1: + X_POSIX_MAPPED_FILES = 200809 // posix_opt.h:41:1: + X_POSIX_MEMLOCK = 200809 // posix_opt.h:44:1: + X_POSIX_MEMLOCK_RANGE = 200809 // posix_opt.h:47:1: + X_POSIX_MEMORY_PROTECTION = 200809 // posix_opt.h:50:1: + X_POSIX_MESSAGE_PASSING = 200809 // posix_opt.h:158:1: + X_POSIX_MONOTONIC_CLOCK = 0 // posix_opt.h:164:1: + X_POSIX_NO_TRUNC = 1 // posix_opt.h:60:1: + X_POSIX_PRIORITIZED_IO = 200809 // posix_opt.h:114:1: + X_POSIX_PRIORITY_SCHEDULING = 200809 // posix_opt.h:32:1: + X_POSIX_RAW_SOCKETS = 200809 // posix_opt.h:176:1: + X_POSIX_READER_WRITER_LOCKS = 200809 // posix_opt.h:137:1: + X_POSIX_REALTIME_SIGNALS = 200809 // posix_opt.h:106:1: + X_POSIX_REENTRANT_FUNCTIONS = 1 // posix_opt.h:75:1: + X_POSIX_REGEXP = 1 // posix_opt.h:134:1: + X_POSIX_SAVED_IDS = 1 // posix_opt.h:26:1: + X_POSIX_SEMAPHORES = 200809 // posix_opt.h:103:1: + X_POSIX_SHARED_MEMORY_OBJECTS = 200809 // posix_opt.h:125:1: + X_POSIX_SHELL = 1 // posix_opt.h:140:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_POSIX_SPAWN = 200809 // posix_opt.h:149:1: + X_POSIX_SPIN_LOCKS = 200809 // posix_opt.h:146:1: + X_POSIX_SPORADIC_SERVER = -1 // posix_opt.h:182:1: + X_POSIX_SYNCHRONIZED_IO = 200809 // posix_opt.h:35:1: + X_POSIX_THREADS = 200809 // posix_opt.h:72:1: + X_POSIX_THREAD_ATTR_STACKADDR = 200809 // posix_opt.h:85:1: + X_POSIX_THREAD_ATTR_STACKSIZE = 200809 // posix_opt.h:82:1: + X_POSIX_THREAD_CPUTIME = 0 // posix_opt.h:131:1: + X_POSIX_THREAD_PRIORITY_SCHEDULING = 200809 // posix_opt.h:79:1: + X_POSIX_THREAD_PRIO_INHERIT = 200809 // posix_opt.h:88:1: + X_POSIX_THREAD_PRIO_PROTECT = 200809 // posix_opt.h:92:1: + X_POSIX_THREAD_PROCESS_SHARED = 200809 // posix_opt.h:161:1: + X_POSIX_THREAD_ROBUST_PRIO_INHERIT = 200809 // posix_opt.h:96:1: + X_POSIX_THREAD_ROBUST_PRIO_PROTECT = -1 // posix_opt.h:99:1: + X_POSIX_THREAD_SAFE_FUNCTIONS = 200809 // posix_opt.h:76:1: + X_POSIX_THREAD_SPORADIC_SERVER = -1 // posix_opt.h:183:1: + X_POSIX_TIMEOUTS = 200809 // posix_opt.h:143:1: + X_POSIX_TIMERS = 200809 // posix_opt.h:152:1: + X_POSIX_TRACE = -1 // posix_opt.h:186:1: + X_POSIX_TRACE_EVENT_FILTER = -1 // posix_opt.h:187:1: + X_POSIX_TRACE_INHERIT = -1 // posix_opt.h:188:1: + X_POSIX_TRACE_LOG = -1 // posix_opt.h:189:1: + X_POSIX_TYPED_MEMORY_OBJECTS = -1 // posix_opt.h:192:1: + X_POSIX_V6_LP64_OFF64 = 1 // environments.h:62:1: + X_POSIX_V6_LPBIG_OFFBIG = -1 // environments.h:57:1: + X_POSIX_V7_LP64_OFF64 = 1 // environments.h:61:1: + X_POSIX_V7_LPBIG_OFFBIG = -1 // environments.h:56:1: + X_POSIX_VDISABLE = 0 // posix_opt.h:57:1: + X_POSIX_VERSION = 200809 // unistd.h:34:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + X_UNISTD_H = 1 // unistd.h:23:1: + X_XBS5_LP64_OFF64 = 1 // environments.h:63:1: + X_XBS5_LPBIG_OFFBIG = -1 // environments.h:58:1: + X_XOPEN_ENH_I18N = 1 // unistd.h:112:1: + X_XOPEN_LEGACY = 1 // unistd.h:115:1: + X_XOPEN_REALTIME = 1 // posix_opt.h:63:1: + X_XOPEN_REALTIME_THREADS = 1 // posix_opt.h:66:1: + X_XOPEN_SHM = 1 // posix_opt.h:69:1: + X_XOPEN_UNIX = 1 // unistd.h:108:1: + X_XOPEN_VERSION = 700 // unistd.h:90:1: + X_XOPEN_XCU_VERSION = 4 // unistd.h:100:1: + X_XOPEN_XPG2 = 1 // unistd.h:103:1: + X_XOPEN_XPG3 = 1 // unistd.h:104:1: + X_XOPEN_XPG4 = 1 // unistd.h:105:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf'; +// the `_SC_*' symbols for the NAME argument to `sysconf'; +// and the `_CS_*' symbols for the NAME argument to `confstr'. +// `sysconf', `pathconf', and `confstr' NAME values. Generic version. +// Copyright (C) 1993-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Values for the NAME argument to `pathconf' and `fpathconf'. +const ( /* confname.h:24:1: */ + X_PC_LINK_MAX = 0 + X_PC_MAX_CANON = 1 + X_PC_MAX_INPUT = 2 + X_PC_NAME_MAX = 3 + X_PC_PATH_MAX = 4 + X_PC_PIPE_BUF = 5 + X_PC_CHOWN_RESTRICTED = 6 + X_PC_NO_TRUNC = 7 + X_PC_VDISABLE = 8 + X_PC_SYNC_IO = 9 + X_PC_ASYNC_IO = 10 + X_PC_PRIO_IO = 11 + X_PC_SOCK_MAXBUF = 12 + X_PC_FILESIZEBITS = 13 + X_PC_REC_INCR_XFER_SIZE = 14 + X_PC_REC_MAX_XFER_SIZE = 15 + X_PC_REC_MIN_XFER_SIZE = 16 + X_PC_REC_XFER_ALIGN = 17 + X_PC_ALLOC_SIZE_MIN = 18 + X_PC_SYMLINK_MAX = 19 + X_PC_2_SYMLINKS = 20 +) + +// Values for the NAME argument to `confstr'. +const ( /* confname.h:533:1: */ + X_CS_PATH = 0 // The default search path. + + X_CS_V6_WIDTH_RESTRICTED_ENVS = 1 + + X_CS_GNU_LIBC_VERSION = 2 + X_CS_GNU_LIBPTHREAD_VERSION = 3 + + X_CS_V5_WIDTH_RESTRICTED_ENVS = 4 + + X_CS_V7_WIDTH_RESTRICTED_ENVS = 5 + + X_CS_LFS_CFLAGS = 1000 + X_CS_LFS_LDFLAGS = 1001 + X_CS_LFS_LIBS = 1002 + X_CS_LFS_LINTFLAGS = 1003 + X_CS_LFS64_CFLAGS = 1004 + X_CS_LFS64_LDFLAGS = 1005 + X_CS_LFS64_LIBS = 1006 + X_CS_LFS64_LINTFLAGS = 1007 + + X_CS_XBS5_ILP32_OFF32_CFLAGS = 1100 + X_CS_XBS5_ILP32_OFF32_LDFLAGS = 1101 + X_CS_XBS5_ILP32_OFF32_LIBS = 1102 + X_CS_XBS5_ILP32_OFF32_LINTFLAGS = 1103 + X_CS_XBS5_ILP32_OFFBIG_CFLAGS = 1104 + X_CS_XBS5_ILP32_OFFBIG_LDFLAGS = 1105 + X_CS_XBS5_ILP32_OFFBIG_LIBS = 1106 + X_CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 1107 + X_CS_XBS5_LP64_OFF64_CFLAGS = 1108 + X_CS_XBS5_LP64_OFF64_LDFLAGS = 1109 + X_CS_XBS5_LP64_OFF64_LIBS = 1110 + X_CS_XBS5_LP64_OFF64_LINTFLAGS = 1111 + X_CS_XBS5_LPBIG_OFFBIG_CFLAGS = 1112 + X_CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 1113 + X_CS_XBS5_LPBIG_OFFBIG_LIBS = 1114 + X_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 1115 + + X_CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 + X_CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 + X_CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 + X_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 + X_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 + X_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 + X_CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 + X_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 + X_CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 + X_CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 + X_CS_POSIX_V6_LP64_OFF64_LIBS = 1126 + X_CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 + X_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 + X_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 + X_CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 + X_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 + + X_CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 + X_CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 + X_CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 + X_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 + X_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 + X_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 + X_CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 + X_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 + X_CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 + X_CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 + X_CS_POSIX_V7_LP64_OFF64_LIBS = 1142 + X_CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 + X_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 + X_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 + X_CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 + X_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 + + X_CS_V6_ENV = 1148 + X_CS_V7_ENV = 1149 +) + +// Values for the argument to `sysconf'. +const ( /* confname.h:71:1: */ + X_SC_ARG_MAX = 0 + X_SC_CHILD_MAX = 1 + X_SC_CLK_TCK = 2 + X_SC_NGROUPS_MAX = 3 + X_SC_OPEN_MAX = 4 + X_SC_STREAM_MAX = 5 + X_SC_TZNAME_MAX = 6 + X_SC_JOB_CONTROL = 7 + X_SC_SAVED_IDS = 8 + X_SC_REALTIME_SIGNALS = 9 + X_SC_PRIORITY_SCHEDULING = 10 + X_SC_TIMERS = 11 + X_SC_ASYNCHRONOUS_IO = 12 + X_SC_PRIORITIZED_IO = 13 + X_SC_SYNCHRONIZED_IO = 14 + X_SC_FSYNC = 15 + X_SC_MAPPED_FILES = 16 + X_SC_MEMLOCK = 17 + X_SC_MEMLOCK_RANGE = 18 + X_SC_MEMORY_PROTECTION = 19 + X_SC_MESSAGE_PASSING = 20 + X_SC_SEMAPHORES = 21 + X_SC_SHARED_MEMORY_OBJECTS = 22 + X_SC_AIO_LISTIO_MAX = 23 + X_SC_AIO_MAX = 24 + X_SC_AIO_PRIO_DELTA_MAX = 25 + X_SC_DELAYTIMER_MAX = 26 + X_SC_MQ_OPEN_MAX = 27 + X_SC_MQ_PRIO_MAX = 28 + X_SC_VERSION = 29 + X_SC_PAGESIZE = 30 + X_SC_RTSIG_MAX = 31 + X_SC_SEM_NSEMS_MAX = 32 + X_SC_SEM_VALUE_MAX = 33 + X_SC_SIGQUEUE_MAX = 34 + X_SC_TIMER_MAX = 35 + + // Values for the argument to `sysconf' + // corresponding to _POSIX2_* symbols. + X_SC_BC_BASE_MAX = 36 + X_SC_BC_DIM_MAX = 37 + X_SC_BC_SCALE_MAX = 38 + X_SC_BC_STRING_MAX = 39 + X_SC_COLL_WEIGHTS_MAX = 40 + X_SC_EQUIV_CLASS_MAX = 41 + X_SC_EXPR_NEST_MAX = 42 + X_SC_LINE_MAX = 43 + X_SC_RE_DUP_MAX = 44 + X_SC_CHARCLASS_NAME_MAX = 45 + + X_SC_2_VERSION = 46 + X_SC_2_C_BIND = 47 + X_SC_2_C_DEV = 48 + X_SC_2_FORT_DEV = 49 + X_SC_2_FORT_RUN = 50 + X_SC_2_SW_DEV = 51 + X_SC_2_LOCALEDEF = 52 + + X_SC_PII = 53 + X_SC_PII_XTI = 54 + X_SC_PII_SOCKET = 55 + X_SC_PII_INTERNET = 56 + X_SC_PII_OSI = 57 + X_SC_POLL = 58 + X_SC_SELECT = 59 + X_SC_UIO_MAXIOV = 60 + X_SC_IOV_MAX = 60 + X_SC_PII_INTERNET_STREAM = 61 + X_SC_PII_INTERNET_DGRAM = 62 + X_SC_PII_OSI_COTS = 63 + X_SC_PII_OSI_CLTS = 64 + X_SC_PII_OSI_M = 65 + X_SC_T_IOV_MAX = 66 + + // Values according to POSIX 1003.1c (POSIX threads). + X_SC_THREADS = 67 + X_SC_THREAD_SAFE_FUNCTIONS = 68 + X_SC_GETGR_R_SIZE_MAX = 69 + X_SC_GETPW_R_SIZE_MAX = 70 + X_SC_LOGIN_NAME_MAX = 71 + X_SC_TTY_NAME_MAX = 72 + X_SC_THREAD_DESTRUCTOR_ITERATIONS = 73 + X_SC_THREAD_KEYS_MAX = 74 + X_SC_THREAD_STACK_MIN = 75 + X_SC_THREAD_THREADS_MAX = 76 + X_SC_THREAD_ATTR_STACKADDR = 77 + X_SC_THREAD_ATTR_STACKSIZE = 78 + X_SC_THREAD_PRIORITY_SCHEDULING = 79 + X_SC_THREAD_PRIO_INHERIT = 80 + X_SC_THREAD_PRIO_PROTECT = 81 + X_SC_THREAD_PROCESS_SHARED = 82 + + X_SC_NPROCESSORS_CONF = 83 + X_SC_NPROCESSORS_ONLN = 84 + X_SC_PHYS_PAGES = 85 + X_SC_AVPHYS_PAGES = 86 + X_SC_ATEXIT_MAX = 87 + X_SC_PASS_MAX = 88 + + X_SC_XOPEN_VERSION = 89 + X_SC_XOPEN_XCU_VERSION = 90 + X_SC_XOPEN_UNIX = 91 + X_SC_XOPEN_CRYPT = 92 + X_SC_XOPEN_ENH_I18N = 93 + X_SC_XOPEN_SHM = 94 + + X_SC_2_CHAR_TERM = 95 + X_SC_2_C_VERSION = 96 + X_SC_2_UPE = 97 + + X_SC_XOPEN_XPG2 = 98 + X_SC_XOPEN_XPG3 = 99 + X_SC_XOPEN_XPG4 = 100 + + X_SC_CHAR_BIT = 101 + X_SC_CHAR_MAX = 102 + X_SC_CHAR_MIN = 103 + X_SC_INT_MAX = 104 + X_SC_INT_MIN = 105 + X_SC_LONG_BIT = 106 + X_SC_WORD_BIT = 107 + X_SC_MB_LEN_MAX = 108 + X_SC_NZERO = 109 + X_SC_SSIZE_MAX = 110 + X_SC_SCHAR_MAX = 111 + X_SC_SCHAR_MIN = 112 + X_SC_SHRT_MAX = 113 + X_SC_SHRT_MIN = 114 + X_SC_UCHAR_MAX = 115 + X_SC_UINT_MAX = 116 + X_SC_ULONG_MAX = 117 + X_SC_USHRT_MAX = 118 + + X_SC_NL_ARGMAX = 119 + X_SC_NL_LANGMAX = 120 + X_SC_NL_MSGMAX = 121 + X_SC_NL_NMAX = 122 + X_SC_NL_SETMAX = 123 + X_SC_NL_TEXTMAX = 124 + + X_SC_XBS5_ILP32_OFF32 = 125 + X_SC_XBS5_ILP32_OFFBIG = 126 + X_SC_XBS5_LP64_OFF64 = 127 + X_SC_XBS5_LPBIG_OFFBIG = 128 + + X_SC_XOPEN_LEGACY = 129 + X_SC_XOPEN_REALTIME = 130 + X_SC_XOPEN_REALTIME_THREADS = 131 + + X_SC_ADVISORY_INFO = 132 + X_SC_BARRIERS = 133 + X_SC_BASE = 134 + X_SC_C_LANG_SUPPORT = 135 + X_SC_C_LANG_SUPPORT_R = 136 + X_SC_CLOCK_SELECTION = 137 + X_SC_CPUTIME = 138 + X_SC_THREAD_CPUTIME = 139 + X_SC_DEVICE_IO = 140 + X_SC_DEVICE_SPECIFIC = 141 + X_SC_DEVICE_SPECIFIC_R = 142 + X_SC_FD_MGMT = 143 + X_SC_FIFO = 144 + X_SC_PIPE = 145 + X_SC_FILE_ATTRIBUTES = 146 + X_SC_FILE_LOCKING = 147 + X_SC_FILE_SYSTEM = 148 + X_SC_MONOTONIC_CLOCK = 149 + X_SC_MULTI_PROCESS = 150 + X_SC_SINGLE_PROCESS = 151 + X_SC_NETWORKING = 152 + X_SC_READER_WRITER_LOCKS = 153 + X_SC_SPIN_LOCKS = 154 + X_SC_REGEXP = 155 + X_SC_REGEX_VERSION = 156 + X_SC_SHELL = 157 + X_SC_SIGNALS = 158 + X_SC_SPAWN = 159 + X_SC_SPORADIC_SERVER = 160 + X_SC_THREAD_SPORADIC_SERVER = 161 + X_SC_SYSTEM_DATABASE = 162 + X_SC_SYSTEM_DATABASE_R = 163 + X_SC_TIMEOUTS = 164 + X_SC_TYPED_MEMORY_OBJECTS = 165 + X_SC_USER_GROUPS = 166 + X_SC_USER_GROUPS_R = 167 + X_SC_2_PBS = 168 + X_SC_2_PBS_ACCOUNTING = 169 + X_SC_2_PBS_LOCATE = 170 + X_SC_2_PBS_MESSAGE = 171 + X_SC_2_PBS_TRACK = 172 + X_SC_SYMLOOP_MAX = 173 + X_SC_STREAMS = 174 + X_SC_2_PBS_CHECKPOINT = 175 + + X_SC_V6_ILP32_OFF32 = 176 + X_SC_V6_ILP32_OFFBIG = 177 + X_SC_V6_LP64_OFF64 = 178 + X_SC_V6_LPBIG_OFFBIG = 179 + + X_SC_HOST_NAME_MAX = 180 + X_SC_TRACE = 181 + X_SC_TRACE_EVENT_FILTER = 182 + X_SC_TRACE_INHERIT = 183 + X_SC_TRACE_LOG = 184 + + X_SC_LEVEL1_ICACHE_SIZE = 185 + X_SC_LEVEL1_ICACHE_ASSOC = 186 + X_SC_LEVEL1_ICACHE_LINESIZE = 187 + X_SC_LEVEL1_DCACHE_SIZE = 188 + X_SC_LEVEL1_DCACHE_ASSOC = 189 + X_SC_LEVEL1_DCACHE_LINESIZE = 190 + X_SC_LEVEL2_CACHE_SIZE = 191 + X_SC_LEVEL2_CACHE_ASSOC = 192 + X_SC_LEVEL2_CACHE_LINESIZE = 193 + X_SC_LEVEL3_CACHE_SIZE = 194 + X_SC_LEVEL3_CACHE_ASSOC = 195 + X_SC_LEVEL3_CACHE_LINESIZE = 196 + X_SC_LEVEL4_CACHE_SIZE = 197 + X_SC_LEVEL4_CACHE_ASSOC = 198 + X_SC_LEVEL4_CACHE_LINESIZE = 199 + // Leave room here, maybe we need a few more cache levels some day. + + X_SC_IPV6 = 235 + X_SC_RAW_SOCKETS = 236 + + X_SC_V7_ILP32_OFF32 = 237 + X_SC_V7_ILP32_OFFBIG = 238 + X_SC_V7_LP64_OFF64 = 239 + X_SC_V7_LPBIG_OFFBIG = 240 + + X_SC_SS_REPL_MAX = 241 + + X_SC_TRACE_EVENT_NAME_MAX = 242 + X_SC_TRACE_NAME_MAX = 243 + X_SC_TRACE_SYS_MAX = 244 + X_SC_TRACE_USER_EVENT_MAX = 245 + + X_SC_XOPEN_STREAMS = 246 + + X_SC_THREAD_ROBUST_PRIO_INHERIT = 247 + X_SC_THREAD_ROBUST_PRIO_PROTECT = 248 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.10 Symbolic Constants + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// These may be used to determine what facilities are present at compile time. +// Their values can be obtained at run time from `sysconf'. + +// POSIX Standard approved as ISO/IEC 9945-1 as of September 2008. + +// These are not #ifdef __USE_POSIX2 because they are +// in the theoretically application-owned namespace. + +// The utilities on GNU systems also correspond to this version. + +// The utilities on GNU systems also correspond to this version. + +// This symbol was required until the 2001 edition of POSIX. + +// If defined, the implementation supports the +// C Language Bindings Option. + +// If defined, the implementation supports the +// C Language Development Utilities Option. + +// If defined, the implementation supports the +// Software Development Utilities Option. + +// If defined, the implementation supports the +// creation of locales with the localedef utility. + +// X/Open version number to which the library conforms. It is selectable. + +// Commands and utilities from XPG4 are available. + +// We are compatible with the old published standards as well. + +// The X/Open Unix extensions are available. + +// The enhanced internationalization capabilities according to XPG4.2 +// are present. + +// The legacy interfaces are also available. + +// Get values of POSIX options: +// +// If these symbols are defined, the corresponding features are +// always available. If not, they may be available sometimes. +// The current values can be obtained with `sysconf'. +// +// _POSIX_JOB_CONTROL Job control is supported. +// _POSIX_SAVED_IDS Processes have a saved set-user-ID +// and a saved set-group-ID. +// _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported. +// _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported. +// _POSIX_TIMERS POSIX.4 clocks and timers are supported. +// _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported. +// _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported. +// _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported. +// _POSIX_FSYNC The fsync function is present. +// _POSIX_MAPPED_FILES Mapping of files to memory is supported. +// _POSIX_MEMLOCK Locking of all memory is supported. +// _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported. +// _POSIX_MEMORY_PROTECTION Setting of memory protections is supported. +// _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported. +// _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported. +// _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported. +// _POSIX_THREADS POSIX.1c pthreads are supported. +// _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported. +// _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported. +// _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported. +// _POSIX_THREAD_PRIORITY_SCHEDULING +// POSIX.1c thread execution scheduling supported. +// _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported. +// _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported. +// _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported. +// _POSIX_PII Protocol-independent interfaces are supported. +// _POSIX_PII_XTI XTI protocol-indep. interfaces are supported. +// _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported. +// _POSIX_PII_INTERNET Internet family of protocols supported. +// _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported. +// _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported. +// _POSIX_PII_OSI ISO/OSI family of protocols supported. +// _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported. +// _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported. +// _POSIX_POLL Implementation supports `poll' function. +// _POSIX_SELECT Implementation supports `select' and `pselect'. +// +// _XOPEN_REALTIME X/Open realtime support is available. +// _XOPEN_REALTIME_THREADS X/Open realtime thread support is available. +// _XOPEN_SHM Shared memory interface according to XPG4.2. +// +// _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit +// int, long, pointer, and off_t types. +// _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit +// int, long, and pointer and off_t with at least +// 64 bits. +// _XBS5_LP64_OFF64 Implementation provides environment with 32-bit +// int, and 64-bit long, pointer, and off_t types. +// _XBS5_LPBIG_OFFBIG Implementation provides environment with at +// least 32 bits int and long, pointer, and off_t +// with at least 64 bits. +// +// If any of these symbols is defined as -1, the corresponding option is not +// true for any file. If any is defined as other than -1, the corresponding +// option is true for all files. If a symbol is not defined at all, the value +// for a specific file can be obtained from `pathconf' and `fpathconf'. +// +// _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change +// the owner of a file. `chown' can only be used +// to change the group ID of a file to a group of +// which the calling process is a member. +// _POSIX_NO_TRUNC Pathname components longer than +// NAME_MAX generate an error. +// _POSIX_VDISABLE If defined, if the value of an element of the +// `c_cc' member of `struct termios' is +// _POSIX_VDISABLE, no character will have the +// effect associated with that element. +// _POSIX_SYNC_IO Synchronous I/O may be performed. +// _POSIX_ASYNC_IO Asynchronous I/O may be performed. +// _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed. +// +// Support for the Large File Support interface is not generally available. +// If it is available the following constants are defined to one. +// _LFS64_LARGEFILE Low-level I/O supports large files. +// _LFS64_STDIO Standard I/O supports large files. +// + +// Define POSIX options for Linux. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; see the file COPYING.LIB. If +// not, see . + +// Job control is supported. + +// Processes have a saved set-user-ID and a saved set-group-ID. + +// Priority scheduling is not supported with the correct semantics, +// but GNU/Linux applications expect that the corresponding interfaces +// are available, even though the semantics do not meet the POSIX +// requirements. See glibc bug 14829. + +// Synchronizing file data is supported. + +// The fsync function is present. + +// Mapping of files to memory is supported. + +// Locking of all memory is supported. + +// Locking of ranges of memory is supported. + +// Setting of memory protections is supported. + +// Some filesystems allow all users to change file ownership. + +// `c_cc' member of 'struct termios' structure can be disabled by +// using the value _POSIX_VDISABLE. + +// Filenames are not silently truncated. + +// X/Open realtime support is available. + +// X/Open thread realtime support is available. + +// XPG4.2 shared memory is supported. + +// Tell we have POSIX threads. + +// We have the reentrant functions described in POSIX. + +// We provide priority scheduling for threads. + +// We support user-defined stack sizes. + +// We support user-defined stacks. + +// We support priority inheritence. + +// We support priority protection, though only for non-robust +// mutexes. + +// We support priority inheritence for robust mutexes. + +// We do not support priority protection for robust mutexes. + +// We support POSIX.1b semaphores. + +// Real-time signals are supported. + +// We support asynchronous I/O. +// Alternative name for Unix98. +// Support for prioritization is also available. + +// The LFS support in asynchronous I/O is also available. + +// The rest of the LFS is also available. + +// POSIX shared memory objects are implemented. + +// CPU-time clocks support needs to be checked at runtime. + +// Clock support in threads must be also checked at runtime. + +// GNU libc provides regular expression handling. + +// Reader/Writer locks are available. + +// We have a POSIX shell. + +// We support the Timeouts option. + +// We support spinlocks. + +// The `spawn' function family is supported. + +// We have POSIX timers. + +// The barrier functions are available. + +// POSIX message queues are available. + +// Thread process-shared synchronization is supported. + +// The monotonic clock might be available. + +// The clock selection interfaces are available. + +// Advisory information interfaces are available. + +// IPv6 support is available. + +// Raw socket support is available. + +// We have at least one terminal. + +// Neither process nor thread sporadic server interfaces is available. + +// trace.h is not available. + +// Typed memory objects are not available. + +// Get the environment definitions from Unix98. +// Copyright (C) 1999-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// This header should define the following symbols under the described +// situations. A value `1' means that the model is always supported, +// `-1' means it is never supported. Undefined means it cannot be +// statically decided. +// +// _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type +// _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type +// +// _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type +// _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type +// +// The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG, +// _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32, +// _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were +// used in previous versions of the Unix standard and are available +// only for compatibility. + +// Environments with 32-bit wide pointers are optionally provided. +// Therefore following macros aren't defined: +// # undef _POSIX_V7_ILP32_OFF32 +// # undef _POSIX_V7_ILP32_OFFBIG +// # undef _POSIX_V6_ILP32_OFF32 +// # undef _POSIX_V6_ILP32_OFFBIG +// # undef _XBS5_ILP32_OFF32 +// # undef _XBS5_ILP32_OFFBIG +// and users need to check at runtime. + +// We also have no use (for now) for an environment with bigger pointers +// and offsets. + +// By default we have 64-bit wide `long int', pointers and `off_t'. + +// Standard file descriptors. + +// All functions that are not declared anywhere else. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type Ssize_t = X__ssize_t /* unistd.h:220:19 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// The Single Unix specification says that some more types are +// +// available here. +type Gid_t = X__gid_t /* unistd.h:232:17 */ + +type Uid_t = X__uid_t /* unistd.h:237:17 */ + +type Off_t = X__off64_t /* unistd.h:245:19 */ + +type Useconds_t = X__useconds_t /* unistd.h:255:22 */ + +type Pid_t = X__pid_t /* unistd.h:260:17 */ + +type Intptr_t = X__intptr_t /* unistd.h:267:20 */ + +type Socklen_t = X__socklen_t /* unistd.h:274:21 */ + +// Define some macros helping to catch buffer overflows. + +// System-specific extensions. +// System-specific extensions of , Linux version. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/unistd/unistd_linux_arm64.go b/internal/libc/unistd/unistd_linux_arm64.go new file mode 100644 index 0000000..2e0b46b --- /dev/null +++ b/internal/libc/unistd/unistd_linux_arm64.go @@ -0,0 +1,1672 @@ +// Code generated by 'ccgo unistd/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o unistd/unistd_linux_arm64.go -pkgname unistd', DO NOT EDIT. + +package unistd + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + F_LOCK = 1 + F_OK = 0 + F_TEST = 3 + F_TLOCK = 2 + F_ULOCK = 0 + L_INCR = 1 + L_SET = 0 + L_XTND = 2 + R_OK = 4 + SEEK_CUR = 1 + SEEK_END = 2 + SEEK_SET = 0 + STDERR_FILENO = 2 + STDIN_FILENO = 0 + STDOUT_FILENO = 1 + W_OK = 2 + X_OK = 1 + X_ATFILE_SOURCE = 1 + X_BITS_POSIX_OPT_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_GETOPT_CORE_H = 1 + X_GETOPT_POSIX_H = 1 + X_LFS64_ASYNCHRONOUS_IO = 1 + X_LFS64_LARGEFILE = 1 + X_LFS64_STDIO = 1 + X_LFS_ASYNCHRONOUS_IO = 1 + X_LFS_LARGEFILE = 1 + X_LP64 = 1 + X_POSIX2_CHAR_TERM = 200809 + X_POSIX2_C_BIND = 200809 + X_POSIX2_C_DEV = 200809 + X_POSIX2_C_VERSION = 200809 + X_POSIX2_LOCALEDEF = 200809 + X_POSIX2_SW_DEV = 200809 + X_POSIX2_VERSION = 200809 + X_POSIX_ADVISORY_INFO = 200809 + X_POSIX_ASYNCHRONOUS_IO = 200809 + X_POSIX_ASYNC_IO = 1 + X_POSIX_BARRIERS = 200809 + X_POSIX_CHOWN_RESTRICTED = 0 + X_POSIX_CLOCK_SELECTION = 200809 + X_POSIX_CPUTIME = 0 + X_POSIX_C_SOURCE = 200809 + X_POSIX_FSYNC = 200809 + X_POSIX_IPV6 = 200809 + X_POSIX_JOB_CONTROL = 1 + X_POSIX_MAPPED_FILES = 200809 + X_POSIX_MEMLOCK = 200809 + X_POSIX_MEMLOCK_RANGE = 200809 + X_POSIX_MEMORY_PROTECTION = 200809 + X_POSIX_MESSAGE_PASSING = 200809 + X_POSIX_MONOTONIC_CLOCK = 0 + X_POSIX_NO_TRUNC = 1 + X_POSIX_PRIORITIZED_IO = 200809 + X_POSIX_PRIORITY_SCHEDULING = 200809 + X_POSIX_RAW_SOCKETS = 200809 + X_POSIX_READER_WRITER_LOCKS = 200809 + X_POSIX_REALTIME_SIGNALS = 200809 + X_POSIX_REENTRANT_FUNCTIONS = 1 + X_POSIX_REGEXP = 1 + X_POSIX_SAVED_IDS = 1 + X_POSIX_SEMAPHORES = 200809 + X_POSIX_SHARED_MEMORY_OBJECTS = 200809 + X_POSIX_SHELL = 1 + X_POSIX_SOURCE = 1 + X_POSIX_SPAWN = 200809 + X_POSIX_SPIN_LOCKS = 200809 + X_POSIX_SPORADIC_SERVER = -1 + X_POSIX_SYNCHRONIZED_IO = 200809 + X_POSIX_THREADS = 200809 + X_POSIX_THREAD_ATTR_STACKADDR = 200809 + X_POSIX_THREAD_ATTR_STACKSIZE = 200809 + X_POSIX_THREAD_CPUTIME = 0 + X_POSIX_THREAD_PRIORITY_SCHEDULING = 200809 + X_POSIX_THREAD_PRIO_INHERIT = 200809 + X_POSIX_THREAD_PRIO_PROTECT = 200809 + X_POSIX_THREAD_PROCESS_SHARED = 200809 + X_POSIX_THREAD_ROBUST_PRIO_INHERIT = 200809 + X_POSIX_THREAD_ROBUST_PRIO_PROTECT = -1 + X_POSIX_THREAD_SAFE_FUNCTIONS = 200809 + X_POSIX_THREAD_SPORADIC_SERVER = -1 + X_POSIX_TIMEOUTS = 200809 + X_POSIX_TIMERS = 200809 + X_POSIX_TRACE = -1 + X_POSIX_TRACE_EVENT_FILTER = -1 + X_POSIX_TRACE_INHERIT = -1 + X_POSIX_TRACE_LOG = -1 + X_POSIX_TYPED_MEMORY_OBJECTS = -1 + X_POSIX_V6_ILP32_OFF32 = -1 + X_POSIX_V6_ILP32_OFFBIG = -1 + X_POSIX_V6_LP64_OFF64 = 1 + X_POSIX_V6_LPBIG_OFFBIG = -1 + X_POSIX_V7_ILP32_OFF32 = -1 + X_POSIX_V7_ILP32_OFFBIG = -1 + X_POSIX_V7_LP64_OFF64 = 1 + X_POSIX_V7_LPBIG_OFFBIG = -1 + X_POSIX_VDISABLE = 0 + X_POSIX_VERSION = 200809 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SIZE_T_H = 0 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + X_UNISTD_H = 1 + X_XBS5_ILP32_OFF32 = -1 + X_XBS5_ILP32_OFFBIG = -1 + X_XBS5_LP64_OFF64 = 1 + X_XBS5_LPBIG_OFFBIG = -1 + X_XOPEN_ENH_I18N = 1 + X_XOPEN_LEGACY = 1 + X_XOPEN_REALTIME = 1 + X_XOPEN_REALTIME_THREADS = 1 + X_XOPEN_SHM = 1 + X_XOPEN_UNIX = 1 + X_XOPEN_VERSION = 700 + X_XOPEN_XCU_VERSION = 4 + X_XOPEN_XPG2 = 1 + X_XOPEN_XPG3 = 1 + X_XOPEN_XPG4 = 1 + Linux = 1 + Unix = 1 +) + +// Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf'; +// the `_SC_*' symbols for the NAME argument to `sysconf'; +// and the `_CS_*' symbols for the NAME argument to `confstr'. +// `sysconf', `pathconf', and `confstr' NAME values. Generic version. +// Copyright (C) 1993-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Values for the NAME argument to `pathconf' and `fpathconf'. +const ( /* confname.h:24:1: */ + X_PC_LINK_MAX = 0 + X_PC_MAX_CANON = 1 + X_PC_MAX_INPUT = 2 + X_PC_NAME_MAX = 3 + X_PC_PATH_MAX = 4 + X_PC_PIPE_BUF = 5 + X_PC_CHOWN_RESTRICTED = 6 + X_PC_NO_TRUNC = 7 + X_PC_VDISABLE = 8 + X_PC_SYNC_IO = 9 + X_PC_ASYNC_IO = 10 + X_PC_PRIO_IO = 11 + X_PC_SOCK_MAXBUF = 12 + X_PC_FILESIZEBITS = 13 + X_PC_REC_INCR_XFER_SIZE = 14 + X_PC_REC_MAX_XFER_SIZE = 15 + X_PC_REC_MIN_XFER_SIZE = 16 + X_PC_REC_XFER_ALIGN = 17 + X_PC_ALLOC_SIZE_MIN = 18 + X_PC_SYMLINK_MAX = 19 + X_PC_2_SYMLINKS = 20 +) + +// Values for the NAME argument to `confstr'. +const ( /* confname.h:533:1: */ + X_CS_PATH = 0 // The default search path. + + X_CS_V6_WIDTH_RESTRICTED_ENVS = 1 + + X_CS_GNU_LIBC_VERSION = 2 + X_CS_GNU_LIBPTHREAD_VERSION = 3 + + X_CS_V5_WIDTH_RESTRICTED_ENVS = 4 + + X_CS_V7_WIDTH_RESTRICTED_ENVS = 5 + + X_CS_LFS_CFLAGS = 1000 + X_CS_LFS_LDFLAGS = 1001 + X_CS_LFS_LIBS = 1002 + X_CS_LFS_LINTFLAGS = 1003 + X_CS_LFS64_CFLAGS = 1004 + X_CS_LFS64_LDFLAGS = 1005 + X_CS_LFS64_LIBS = 1006 + X_CS_LFS64_LINTFLAGS = 1007 + + X_CS_XBS5_ILP32_OFF32_CFLAGS = 1100 + X_CS_XBS5_ILP32_OFF32_LDFLAGS = 1101 + X_CS_XBS5_ILP32_OFF32_LIBS = 1102 + X_CS_XBS5_ILP32_OFF32_LINTFLAGS = 1103 + X_CS_XBS5_ILP32_OFFBIG_CFLAGS = 1104 + X_CS_XBS5_ILP32_OFFBIG_LDFLAGS = 1105 + X_CS_XBS5_ILP32_OFFBIG_LIBS = 1106 + X_CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 1107 + X_CS_XBS5_LP64_OFF64_CFLAGS = 1108 + X_CS_XBS5_LP64_OFF64_LDFLAGS = 1109 + X_CS_XBS5_LP64_OFF64_LIBS = 1110 + X_CS_XBS5_LP64_OFF64_LINTFLAGS = 1111 + X_CS_XBS5_LPBIG_OFFBIG_CFLAGS = 1112 + X_CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 1113 + X_CS_XBS5_LPBIG_OFFBIG_LIBS = 1114 + X_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 1115 + + X_CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 + X_CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 + X_CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 + X_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 + X_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 + X_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 + X_CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 + X_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 + X_CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 + X_CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 + X_CS_POSIX_V6_LP64_OFF64_LIBS = 1126 + X_CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 + X_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 + X_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 + X_CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 + X_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 + + X_CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 + X_CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 + X_CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 + X_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 + X_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 + X_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 + X_CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 + X_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 + X_CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 + X_CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 + X_CS_POSIX_V7_LP64_OFF64_LIBS = 1142 + X_CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 + X_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 + X_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 + X_CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 + X_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 + + X_CS_V6_ENV = 1148 + X_CS_V7_ENV = 1149 +) + +// Values for the argument to `sysconf'. +const ( /* confname.h:71:1: */ + X_SC_ARG_MAX = 0 + X_SC_CHILD_MAX = 1 + X_SC_CLK_TCK = 2 + X_SC_NGROUPS_MAX = 3 + X_SC_OPEN_MAX = 4 + X_SC_STREAM_MAX = 5 + X_SC_TZNAME_MAX = 6 + X_SC_JOB_CONTROL = 7 + X_SC_SAVED_IDS = 8 + X_SC_REALTIME_SIGNALS = 9 + X_SC_PRIORITY_SCHEDULING = 10 + X_SC_TIMERS = 11 + X_SC_ASYNCHRONOUS_IO = 12 + X_SC_PRIORITIZED_IO = 13 + X_SC_SYNCHRONIZED_IO = 14 + X_SC_FSYNC = 15 + X_SC_MAPPED_FILES = 16 + X_SC_MEMLOCK = 17 + X_SC_MEMLOCK_RANGE = 18 + X_SC_MEMORY_PROTECTION = 19 + X_SC_MESSAGE_PASSING = 20 + X_SC_SEMAPHORES = 21 + X_SC_SHARED_MEMORY_OBJECTS = 22 + X_SC_AIO_LISTIO_MAX = 23 + X_SC_AIO_MAX = 24 + X_SC_AIO_PRIO_DELTA_MAX = 25 + X_SC_DELAYTIMER_MAX = 26 + X_SC_MQ_OPEN_MAX = 27 + X_SC_MQ_PRIO_MAX = 28 + X_SC_VERSION = 29 + X_SC_PAGESIZE = 30 + X_SC_RTSIG_MAX = 31 + X_SC_SEM_NSEMS_MAX = 32 + X_SC_SEM_VALUE_MAX = 33 + X_SC_SIGQUEUE_MAX = 34 + X_SC_TIMER_MAX = 35 + + // Values for the argument to `sysconf' + // corresponding to _POSIX2_* symbols. + X_SC_BC_BASE_MAX = 36 + X_SC_BC_DIM_MAX = 37 + X_SC_BC_SCALE_MAX = 38 + X_SC_BC_STRING_MAX = 39 + X_SC_COLL_WEIGHTS_MAX = 40 + X_SC_EQUIV_CLASS_MAX = 41 + X_SC_EXPR_NEST_MAX = 42 + X_SC_LINE_MAX = 43 + X_SC_RE_DUP_MAX = 44 + X_SC_CHARCLASS_NAME_MAX = 45 + + X_SC_2_VERSION = 46 + X_SC_2_C_BIND = 47 + X_SC_2_C_DEV = 48 + X_SC_2_FORT_DEV = 49 + X_SC_2_FORT_RUN = 50 + X_SC_2_SW_DEV = 51 + X_SC_2_LOCALEDEF = 52 + + X_SC_PII = 53 + X_SC_PII_XTI = 54 + X_SC_PII_SOCKET = 55 + X_SC_PII_INTERNET = 56 + X_SC_PII_OSI = 57 + X_SC_POLL = 58 + X_SC_SELECT = 59 + X_SC_UIO_MAXIOV = 60 + X_SC_IOV_MAX = 60 + X_SC_PII_INTERNET_STREAM = 61 + X_SC_PII_INTERNET_DGRAM = 62 + X_SC_PII_OSI_COTS = 63 + X_SC_PII_OSI_CLTS = 64 + X_SC_PII_OSI_M = 65 + X_SC_T_IOV_MAX = 66 + + // Values according to POSIX 1003.1c (POSIX threads). + X_SC_THREADS = 67 + X_SC_THREAD_SAFE_FUNCTIONS = 68 + X_SC_GETGR_R_SIZE_MAX = 69 + X_SC_GETPW_R_SIZE_MAX = 70 + X_SC_LOGIN_NAME_MAX = 71 + X_SC_TTY_NAME_MAX = 72 + X_SC_THREAD_DESTRUCTOR_ITERATIONS = 73 + X_SC_THREAD_KEYS_MAX = 74 + X_SC_THREAD_STACK_MIN = 75 + X_SC_THREAD_THREADS_MAX = 76 + X_SC_THREAD_ATTR_STACKADDR = 77 + X_SC_THREAD_ATTR_STACKSIZE = 78 + X_SC_THREAD_PRIORITY_SCHEDULING = 79 + X_SC_THREAD_PRIO_INHERIT = 80 + X_SC_THREAD_PRIO_PROTECT = 81 + X_SC_THREAD_PROCESS_SHARED = 82 + + X_SC_NPROCESSORS_CONF = 83 + X_SC_NPROCESSORS_ONLN = 84 + X_SC_PHYS_PAGES = 85 + X_SC_AVPHYS_PAGES = 86 + X_SC_ATEXIT_MAX = 87 + X_SC_PASS_MAX = 88 + + X_SC_XOPEN_VERSION = 89 + X_SC_XOPEN_XCU_VERSION = 90 + X_SC_XOPEN_UNIX = 91 + X_SC_XOPEN_CRYPT = 92 + X_SC_XOPEN_ENH_I18N = 93 + X_SC_XOPEN_SHM = 94 + + X_SC_2_CHAR_TERM = 95 + X_SC_2_C_VERSION = 96 + X_SC_2_UPE = 97 + + X_SC_XOPEN_XPG2 = 98 + X_SC_XOPEN_XPG3 = 99 + X_SC_XOPEN_XPG4 = 100 + + X_SC_CHAR_BIT = 101 + X_SC_CHAR_MAX = 102 + X_SC_CHAR_MIN = 103 + X_SC_INT_MAX = 104 + X_SC_INT_MIN = 105 + X_SC_LONG_BIT = 106 + X_SC_WORD_BIT = 107 + X_SC_MB_LEN_MAX = 108 + X_SC_NZERO = 109 + X_SC_SSIZE_MAX = 110 + X_SC_SCHAR_MAX = 111 + X_SC_SCHAR_MIN = 112 + X_SC_SHRT_MAX = 113 + X_SC_SHRT_MIN = 114 + X_SC_UCHAR_MAX = 115 + X_SC_UINT_MAX = 116 + X_SC_ULONG_MAX = 117 + X_SC_USHRT_MAX = 118 + + X_SC_NL_ARGMAX = 119 + X_SC_NL_LANGMAX = 120 + X_SC_NL_MSGMAX = 121 + X_SC_NL_NMAX = 122 + X_SC_NL_SETMAX = 123 + X_SC_NL_TEXTMAX = 124 + + X_SC_XBS5_ILP32_OFF32 = 125 + X_SC_XBS5_ILP32_OFFBIG = 126 + X_SC_XBS5_LP64_OFF64 = 127 + X_SC_XBS5_LPBIG_OFFBIG = 128 + + X_SC_XOPEN_LEGACY = 129 + X_SC_XOPEN_REALTIME = 130 + X_SC_XOPEN_REALTIME_THREADS = 131 + + X_SC_ADVISORY_INFO = 132 + X_SC_BARRIERS = 133 + X_SC_BASE = 134 + X_SC_C_LANG_SUPPORT = 135 + X_SC_C_LANG_SUPPORT_R = 136 + X_SC_CLOCK_SELECTION = 137 + X_SC_CPUTIME = 138 + X_SC_THREAD_CPUTIME = 139 + X_SC_DEVICE_IO = 140 + X_SC_DEVICE_SPECIFIC = 141 + X_SC_DEVICE_SPECIFIC_R = 142 + X_SC_FD_MGMT = 143 + X_SC_FIFO = 144 + X_SC_PIPE = 145 + X_SC_FILE_ATTRIBUTES = 146 + X_SC_FILE_LOCKING = 147 + X_SC_FILE_SYSTEM = 148 + X_SC_MONOTONIC_CLOCK = 149 + X_SC_MULTI_PROCESS = 150 + X_SC_SINGLE_PROCESS = 151 + X_SC_NETWORKING = 152 + X_SC_READER_WRITER_LOCKS = 153 + X_SC_SPIN_LOCKS = 154 + X_SC_REGEXP = 155 + X_SC_REGEX_VERSION = 156 + X_SC_SHELL = 157 + X_SC_SIGNALS = 158 + X_SC_SPAWN = 159 + X_SC_SPORADIC_SERVER = 160 + X_SC_THREAD_SPORADIC_SERVER = 161 + X_SC_SYSTEM_DATABASE = 162 + X_SC_SYSTEM_DATABASE_R = 163 + X_SC_TIMEOUTS = 164 + X_SC_TYPED_MEMORY_OBJECTS = 165 + X_SC_USER_GROUPS = 166 + X_SC_USER_GROUPS_R = 167 + X_SC_2_PBS = 168 + X_SC_2_PBS_ACCOUNTING = 169 + X_SC_2_PBS_LOCATE = 170 + X_SC_2_PBS_MESSAGE = 171 + X_SC_2_PBS_TRACK = 172 + X_SC_SYMLOOP_MAX = 173 + X_SC_STREAMS = 174 + X_SC_2_PBS_CHECKPOINT = 175 + + X_SC_V6_ILP32_OFF32 = 176 + X_SC_V6_ILP32_OFFBIG = 177 + X_SC_V6_LP64_OFF64 = 178 + X_SC_V6_LPBIG_OFFBIG = 179 + + X_SC_HOST_NAME_MAX = 180 + X_SC_TRACE = 181 + X_SC_TRACE_EVENT_FILTER = 182 + X_SC_TRACE_INHERIT = 183 + X_SC_TRACE_LOG = 184 + + X_SC_LEVEL1_ICACHE_SIZE = 185 + X_SC_LEVEL1_ICACHE_ASSOC = 186 + X_SC_LEVEL1_ICACHE_LINESIZE = 187 + X_SC_LEVEL1_DCACHE_SIZE = 188 + X_SC_LEVEL1_DCACHE_ASSOC = 189 + X_SC_LEVEL1_DCACHE_LINESIZE = 190 + X_SC_LEVEL2_CACHE_SIZE = 191 + X_SC_LEVEL2_CACHE_ASSOC = 192 + X_SC_LEVEL2_CACHE_LINESIZE = 193 + X_SC_LEVEL3_CACHE_SIZE = 194 + X_SC_LEVEL3_CACHE_ASSOC = 195 + X_SC_LEVEL3_CACHE_LINESIZE = 196 + X_SC_LEVEL4_CACHE_SIZE = 197 + X_SC_LEVEL4_CACHE_ASSOC = 198 + X_SC_LEVEL4_CACHE_LINESIZE = 199 + // Leave room here, maybe we need a few more cache levels some day. + + X_SC_IPV6 = 235 + X_SC_RAW_SOCKETS = 236 + + X_SC_V7_ILP32_OFF32 = 237 + X_SC_V7_ILP32_OFFBIG = 238 + X_SC_V7_LP64_OFF64 = 239 + X_SC_V7_LPBIG_OFFBIG = 240 + + X_SC_SS_REPL_MAX = 241 + + X_SC_TRACE_EVENT_NAME_MAX = 242 + X_SC_TRACE_NAME_MAX = 243 + X_SC_TRACE_SYS_MAX = 244 + X_SC_TRACE_USER_EVENT_MAX = 245 + + X_SC_XOPEN_STREAMS = 246 + + X_SC_THREAD_ROBUST_PRIO_INHERIT = 247 + X_SC_THREAD_ROBUST_PRIO_PROTECT = 248 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.10 Symbolic Constants + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// These may be used to determine what facilities are present at compile time. +// Their values can be obtained at run time from `sysconf'. + +// POSIX Standard approved as ISO/IEC 9945-1 as of September 2008. + +// These are not #ifdef __USE_POSIX2 because they are +// in the theoretically application-owned namespace. + +// The utilities on GNU systems also correspond to this version. + +// The utilities on GNU systems also correspond to this version. + +// This symbol was required until the 2001 edition of POSIX. + +// If defined, the implementation supports the +// C Language Bindings Option. + +// If defined, the implementation supports the +// C Language Development Utilities Option. + +// If defined, the implementation supports the +// Software Development Utilities Option. + +// If defined, the implementation supports the +// creation of locales with the localedef utility. + +// X/Open version number to which the library conforms. It is selectable. + +// Commands and utilities from XPG4 are available. + +// We are compatible with the old published standards as well. + +// The X/Open Unix extensions are available. + +// The enhanced internationalization capabilities according to XPG4.2 +// are present. + +// The legacy interfaces are also available. + +// Get values of POSIX options: +// +// If these symbols are defined, the corresponding features are +// always available. If not, they may be available sometimes. +// The current values can be obtained with `sysconf'. +// +// _POSIX_JOB_CONTROL Job control is supported. +// _POSIX_SAVED_IDS Processes have a saved set-user-ID +// and a saved set-group-ID. +// _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported. +// _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported. +// _POSIX_TIMERS POSIX.4 clocks and timers are supported. +// _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported. +// _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported. +// _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported. +// _POSIX_FSYNC The fsync function is present. +// _POSIX_MAPPED_FILES Mapping of files to memory is supported. +// _POSIX_MEMLOCK Locking of all memory is supported. +// _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported. +// _POSIX_MEMORY_PROTECTION Setting of memory protections is supported. +// _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported. +// _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported. +// _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported. +// _POSIX_THREADS POSIX.1c pthreads are supported. +// _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported. +// _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported. +// _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported. +// _POSIX_THREAD_PRIORITY_SCHEDULING +// POSIX.1c thread execution scheduling supported. +// _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported. +// _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported. +// _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported. +// _POSIX_PII Protocol-independent interfaces are supported. +// _POSIX_PII_XTI XTI protocol-indep. interfaces are supported. +// _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported. +// _POSIX_PII_INTERNET Internet family of protocols supported. +// _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported. +// _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported. +// _POSIX_PII_OSI ISO/OSI family of protocols supported. +// _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported. +// _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported. +// _POSIX_POLL Implementation supports `poll' function. +// _POSIX_SELECT Implementation supports `select' and `pselect'. +// +// _XOPEN_REALTIME X/Open realtime support is available. +// _XOPEN_REALTIME_THREADS X/Open realtime thread support is available. +// _XOPEN_SHM Shared memory interface according to XPG4.2. +// +// _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit +// int, long, pointer, and off_t types. +// _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit +// int, long, and pointer and off_t with at least +// 64 bits. +// _XBS5_LP64_OFF64 Implementation provides environment with 32-bit +// int, and 64-bit long, pointer, and off_t types. +// _XBS5_LPBIG_OFFBIG Implementation provides environment with at +// least 32 bits int and long, pointer, and off_t +// with at least 64 bits. +// +// If any of these symbols is defined as -1, the corresponding option is not +// true for any file. If any is defined as other than -1, the corresponding +// option is true for all files. If a symbol is not defined at all, the value +// for a specific file can be obtained from `pathconf' and `fpathconf'. +// +// _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change +// the owner of a file. `chown' can only be used +// to change the group ID of a file to a group of +// which the calling process is a member. +// _POSIX_NO_TRUNC Pathname components longer than +// NAME_MAX generate an error. +// _POSIX_VDISABLE If defined, if the value of an element of the +// `c_cc' member of `struct termios' is +// _POSIX_VDISABLE, no character will have the +// effect associated with that element. +// _POSIX_SYNC_IO Synchronous I/O may be performed. +// _POSIX_ASYNC_IO Asynchronous I/O may be performed. +// _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed. +// +// Support for the Large File Support interface is not generally available. +// If it is available the following constants are defined to one. +// _LFS64_LARGEFILE Low-level I/O supports large files. +// _LFS64_STDIO Standard I/O supports large files. +// + +// Define POSIX options for Linux. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; see the file COPYING.LIB. If +// not, see . + +// Job control is supported. + +// Processes have a saved set-user-ID and a saved set-group-ID. + +// Priority scheduling is not supported with the correct semantics, +// but GNU/Linux applications expect that the corresponding interfaces +// are available, even though the semantics do not meet the POSIX +// requirements. See glibc bug 14829. + +// Synchronizing file data is supported. + +// The fsync function is present. + +// Mapping of files to memory is supported. + +// Locking of all memory is supported. + +// Locking of ranges of memory is supported. + +// Setting of memory protections is supported. + +// Some filesystems allow all users to change file ownership. + +// `c_cc' member of 'struct termios' structure can be disabled by +// using the value _POSIX_VDISABLE. + +// Filenames are not silently truncated. + +// X/Open realtime support is available. + +// X/Open thread realtime support is available. + +// XPG4.2 shared memory is supported. + +// Tell we have POSIX threads. + +// We have the reentrant functions described in POSIX. + +// We provide priority scheduling for threads. + +// We support user-defined stack sizes. + +// We support user-defined stacks. + +// We support priority inheritence. + +// We support priority protection, though only for non-robust +// mutexes. + +// We support priority inheritence for robust mutexes. + +// We do not support priority protection for robust mutexes. + +// We support POSIX.1b semaphores. + +// Real-time signals are supported. + +// We support asynchronous I/O. +// Alternative name for Unix98. +// Support for prioritization is also available. + +// The LFS support in asynchronous I/O is also available. + +// The rest of the LFS is also available. + +// POSIX shared memory objects are implemented. + +// CPU-time clocks support needs to be checked at runtime. + +// Clock support in threads must be also checked at runtime. + +// GNU libc provides regular expression handling. + +// Reader/Writer locks are available. + +// We have a POSIX shell. + +// We support the Timeouts option. + +// We support spinlocks. + +// The `spawn' function family is supported. + +// We have POSIX timers. + +// The barrier functions are available. + +// POSIX message queues are available. + +// Thread process-shared synchronization is supported. + +// The monotonic clock might be available. + +// The clock selection interfaces are available. + +// Advisory information interfaces are available. + +// IPv6 support is available. + +// Raw socket support is available. + +// We have at least one terminal. + +// Neither process nor thread sporadic server interfaces is available. + +// trace.h is not available. + +// Typed memory objects are not available. + +// Get the environment definitions from Unix98. +// Copyright (C) 1999-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This header should define the following symbols under the described +// situations. A value `1' means that the model is always supported, +// `-1' means it is never supported. Undefined means it cannot be +// statically decided. +// +// _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type +// _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type +// +// _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type +// _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type +// +// The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG, +// _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32, +// _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were +// used in previous versions of the Unix standard and are available +// only for compatibility. + +// We can never provide environments with 32-bit wide pointers. +// We also have no use (for now) for an environment with bigger pointers +// and offsets. + +// By default we have 64-bit wide `long int', pointers and `off_t'. + +// Standard file descriptors. + +// All functions that are not declared anywhere else. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type Ssize_t = X__ssize_t /* unistd.h:220:19 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// The Single Unix specification says that some more types are +// +// available here. +type Gid_t = X__gid_t /* unistd.h:232:17 */ + +type Uid_t = X__uid_t /* unistd.h:237:17 */ + +type Off_t = X__off64_t /* unistd.h:245:19 */ + +type Useconds_t = X__useconds_t /* unistd.h:255:22 */ + +type Pid_t = X__pid_t /* unistd.h:260:17 */ + +type Intptr_t = X__intptr_t /* unistd.h:267:20 */ + +type Socklen_t = X__socklen_t /* unistd.h:274:21 */ + +// Define some macros helping to catch buffer overflows. + +// System-specific extensions. +// System-specific extensions of , Linux version. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/utime/capi_darwin_amd64.go b/internal/libc/utime/capi_darwin_amd64.go new file mode 100644 index 0000000..5958f5d --- /dev/null +++ b/internal/libc/utime/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo utime/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o utime/utime_darwin_amd64.go -pkgname utime', DO NOT EDIT. + +package utime + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/utime/capi_darwin_arm64.go b/internal/libc/utime/capi_darwin_arm64.go new file mode 100644 index 0000000..a35118c --- /dev/null +++ b/internal/libc/utime/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo utime/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o utime/utime_darwin_arm64.go -pkgname utime', DO NOT EDIT. + +package utime + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/utime/capi_linux_amd64.go b/internal/libc/utime/capi_linux_amd64.go new file mode 100644 index 0000000..8f7c87f --- /dev/null +++ b/internal/libc/utime/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo utime/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o utime/utime_linux_amd64.go -pkgname utime', DO NOT EDIT. + +package utime + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/utime/capi_linux_arm64.go b/internal/libc/utime/capi_linux_arm64.go new file mode 100644 index 0000000..c9c417d --- /dev/null +++ b/internal/libc/utime/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo utime/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o utime/utime_linux_arm64.go -pkgname utime', DO NOT EDIT. + +package utime + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/utime/utime_darwin_amd64.go b/internal/libc/utime/utime_darwin_amd64.go new file mode 100644 index 0000000..e1dd12f --- /dev/null +++ b/internal/libc/utime/utime_darwin_amd64.go @@ -0,0 +1,1359 @@ +// Code generated by 'ccgo utime/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o utime/utime_darwin_amd64.go -pkgname utime', DO NOT EDIT. + +package utime + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:67:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_UTIME_H_ = 0 // utime.h:59:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)utime.h 8.1 (Berkeley) 6/2/93 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:87:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Uintptr_t = uint64 /* _uintptr_t.h:30:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:97:33 */ +type User_size_t = U_int64_t /* types.h:98:33 */ +type User_ssize_t = Int64_t /* types.h:99:33 */ +type User_long_t = Int64_t /* types.h:100:33 */ +type User_ulong_t = U_int64_t /* types.h:101:33 */ +type User_time_t = Int64_t /* types.h:102:33 */ +type User_off_t = Int64_t /* types.h:103:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:111:33 */ + +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +type Utimbuf = struct { + Factime Time_t + Fmodtime Time_t +} /* utime.h:64:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/utime/utime_darwin_arm64.go b/internal/libc/utime/utime_darwin_arm64.go new file mode 100644 index 0000000..3238b55 --- /dev/null +++ b/internal/libc/utime/utime_darwin_arm64.go @@ -0,0 +1,1315 @@ +// Code generated by 'ccgo utime/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o utime/utime_darwin_arm64.go -pkgname utime', DO NOT EDIT. + +package utime + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_ARM_MACHTYPES_H_ = 0 // types.h:43:1: + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE_TYPES_H_ = 0 // types.h:32:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_INT16_T = 0 // _int16_t.h:29:1: + X_INT32_T = 0 // _int32_t.h:29:1: + X_INT64_T = 0 // _int64_t.h:29:1: + X_INT8_T = 0 // _int8_t.h:29:1: + X_INTPTR_T = 0 // _intptr_t.h:29:1: + X_LP64 = 1 // :1:1: + X_MACHTYPES_H_ = 0 // types.h:44:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_TIME_T = 0 // _time_t.h:29:1: + X_UINTPTR_T = 0 // _uintptr_t.h:29:1: + X_UTIME_H_ = 0 // utime.h:59:1: + X_U_INT16_T = 0 // _u_int16_t.h:29:1: + X_U_INT32_T = 0 // _u_int32_t.h:29:1: + X_U_INT64_T = 0 // _u_int64_t.h:29:1: + X_U_INT8_T = 0 // _u_int8_t.h:29:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// 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. +// +// @(#)utime.h 8.1 (Berkeley) 6/2/93 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +// Copyright (c) 2000-2008 Apple Inc. All rights reserved. +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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. +// +// @(#)types.h 8.3 (Berkeley) 1/5/94 + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Basic integral types. Omit the typedef if +// not possible for a machine/compiler combination. +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int8_t = int8 /* _int8_t.h:30:31 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int16_t = int16 /* _int16_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int32_t = int32 /* _int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Int64_t = int64 /* _int64_t.h:30:33 */ + +// Copyright (c) 2016 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int8_t = uint8 /* _u_int8_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int16_t = uint16 /* _u_int16_t.h:30:41 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int32_t = uint32 /* _u_int32_t.h:30:33 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type U_int64_t = uint64 /* _u_int64_t.h:30:33 */ + +type Register_t = Int64_t /* types.h:66:33 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. + +type Intptr_t = X__darwin_intptr_t /* _intptr_t.h:32:33 */ +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uintptr_t = uint64 /* _uintptr_t.h:34:33 */ + +// These types are used for reserving the largest possible size. +type User_addr_t = U_int64_t /* types.h:77:33 */ +type User_size_t = U_int64_t /* types.h:78:33 */ +type User_ssize_t = Int64_t /* types.h:79:33 */ +type User_long_t = Int64_t /* types.h:80:33 */ +type User_ulong_t = U_int64_t /* types.h:81:33 */ +type User_time_t = Int64_t /* types.h:82:33 */ +type User_off_t = Int64_t /* types.h:83:33 */ + +// This defines the size of syscall arguments after copying into the kernel: +type Syscall_arg_t = U_int64_t /* types.h:104:33 */ + +type Time_t = X__darwin_time_t /* _time_t.h:31:33 */ + +type Utimbuf = struct { + Factime Time_t + Fmodtime Time_t +} /* utime.h:64:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/utime/utime_linux_amd64.go b/internal/libc/utime/utime_linux_amd64.go new file mode 100644 index 0000000..b4f5120 --- /dev/null +++ b/internal/libc/utime/utime_linux_amd64.go @@ -0,0 +1,781 @@ +// Code generated by 'ccgo utime/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o utime/utime_linux_amd64.go -pkgname utime', DO NOT EDIT. + +package utime + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_UTIME_H = 1 // utime.h:23:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 5.6.6 Set File Access and Modification Times + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// Structure describing file times. +type Utimbuf = struct { + Factime X__time_t + Fmodtime X__time_t +} /* utime.h:36:1 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/utime/utime_linux_arm64.go b/internal/libc/utime/utime_linux_arm64.go new file mode 100644 index 0000000..e4ce16d --- /dev/null +++ b/internal/libc/utime/utime_linux_arm64.go @@ -0,0 +1,849 @@ +// Code generated by 'ccgo utime/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o utime/utime_linux_arm64.go -pkgname utime', DO NOT EDIT. + +package utime + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_ATFILE_SOURCE = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + X_UTIME_H = 1 + Linux = 1 + Unix = 1 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 5.6.6 Set File Access and Modification Times + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// Structure describing file times. +type Utimbuf = struct { + Factime X__time_t + Fmodtime X__time_t +} /* utime.h:36:1 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/uuid/uuid/capi_darwin_amd64.go b/internal/libc/uuid/uuid/capi_darwin_amd64.go new file mode 100644 index 0000000..9bfd13f --- /dev/null +++ b/internal/libc/uuid/uuid/capi_darwin_amd64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo uuid/uuid/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o uuid/uuid/uuid_darwin_amd64.go -pkgname uuid', DO NOT EDIT. + +package uuid + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/uuid/uuid/capi_darwin_arm64.go b/internal/libc/uuid/uuid/capi_darwin_arm64.go new file mode 100644 index 0000000..7ea285a --- /dev/null +++ b/internal/libc/uuid/uuid/capi_darwin_arm64.go @@ -0,0 +1,7 @@ +// Code generated by 'ccgo uuid/uuid/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o uuid/uuid/uuid_darwin_arm64.go -pkgname uuid', DO NOT EDIT. + +package uuid + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, +} diff --git a/internal/libc/uuid/uuid/capi_linux_amd64.go b/internal/libc/uuid/uuid/capi_linux_amd64.go new file mode 100644 index 0000000..6833179 --- /dev/null +++ b/internal/libc/uuid/uuid/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo uuid/uuid/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o uuid/uuid/uuid_linux_amd64.go -pkgname uuid', DO NOT EDIT. + +package uuid + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/uuid/uuid/capi_linux_arm64.go b/internal/libc/uuid/uuid/capi_linux_arm64.go new file mode 100644 index 0000000..8fee6f7 --- /dev/null +++ b/internal/libc/uuid/uuid/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo uuid/uuid/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o uuid/uuid/uuid_linux_arm64.go -pkgname uuid', DO NOT EDIT. + +package uuid + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/uuid/uuid/uuid_darwin_amd64.go b/internal/libc/uuid/uuid/uuid_darwin_amd64.go new file mode 100644 index 0000000..4ddd732 --- /dev/null +++ b/internal/libc/uuid/uuid/uuid_darwin_amd64.go @@ -0,0 +1,818 @@ +// Code generated by 'ccgo uuid/uuid/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o uuid/uuid/uuid_darwin_amd64.go -pkgname uuid', DO NOT EDIT. + +package uuid + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UUID_STRING_T = 0 // uuid.h:42:1: + X_UUID_T = 0 // _uuid_t.h:29:1: + X_UUID_UUID_H = 0 // uuid.h:36:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Public include file for the UUID library +// +// Copyright (C) 1996, 1997, 1998 Theodore Ts'o. +// +// %Begin-Header% +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, and the entire permission notice in its entirety, +// including the disclaimer of warranties. +// 2. Redistributions in binary form must reproduce 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 ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +// WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// %End-Header% + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uuid_t = X__darwin_uuid_t /* _uuid_t.h:31:25 */ + +type Uuid_string_t = X__darwin_uuid_string_t /* uuid.h:43:33 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/uuid/uuid/uuid_darwin_arm64.go b/internal/libc/uuid/uuid/uuid_darwin_arm64.go new file mode 100644 index 0000000..1fb18ea --- /dev/null +++ b/internal/libc/uuid/uuid/uuid_darwin_arm64.go @@ -0,0 +1,820 @@ +// Code generated by 'ccgo uuid/uuid/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o uuid/uuid/uuid_darwin_arm64.go -pkgname uuid', DO NOT EDIT. + +package uuid + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_UUID_STRING_T = 0 // uuid.h:42:1: + X_UUID_T = 0 // _uuid_t.h:29:1: + X_UUID_UUID_H = 0 // uuid.h:36:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// Public include file for the UUID library +// +// Copyright (C) 1996, 1997, 1998 Theodore Ts'o. +// +// %Begin-Header% +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, and the entire permission notice in its entirety, +// including the disclaimer of warranties. +// 2. Redistributions in binary form must reproduce 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 ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +// WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// %End-Header% + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type Uuid_t = X__darwin_uuid_t /* _uuid_t.h:31:25 */ + +type Uuid_string_t = X__darwin_uuid_string_t /* uuid.h:43:33 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/uuid/uuid/uuid_linux_amd64.go b/internal/libc/uuid/uuid/uuid_linux_amd64.go new file mode 100644 index 0000000..5f72de6 --- /dev/null +++ b/internal/libc/uuid/uuid/uuid_linux_amd64.go @@ -0,0 +1,1986 @@ +// Code generated by 'ccgo uuid/uuid/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o uuid/uuid/uuid_linux_amd64.go -pkgname uuid', DO NOT EDIT. + +package uuid + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 // endian.h:28:1: + BYTE_ORDER = 1234 // endian.h:30:1: + CLOCK_BOOTTIME = 7 // time.h:60:1: + CLOCK_BOOTTIME_ALARM = 9 // time.h:64:1: + CLOCK_MONOTONIC = 1 // time.h:48:1: + CLOCK_MONOTONIC_COARSE = 6 // time.h:58:1: + CLOCK_MONOTONIC_RAW = 4 // time.h:54:1: + CLOCK_PROCESS_CPUTIME_ID = 2 // time.h:50:1: + CLOCK_REALTIME = 0 // time.h:46:1: + CLOCK_REALTIME_ALARM = 8 // time.h:62:1: + CLOCK_REALTIME_COARSE = 5 // time.h:56:1: + CLOCK_TAI = 11 // time.h:66:1: + CLOCK_THREAD_CPUTIME_ID = 3 // time.h:52:1: + FD_SETSIZE = 1024 // select.h:73:1: + LITTLE_ENDIAN = 1234 // endian.h:27:1: + PDP_ENDIAN = 3412 // endian.h:29:1: + TIMER_ABSTIME = 1 // time.h:69:1: + TIME_UTC = 1 // time.h:65:1: + UUID_STR_LEN = 37 // uuid.h:65:1: + UUID_TYPE_DCE_MD5 = 3 // uuid.h:58:1: + UUID_TYPE_DCE_RANDOM = 4 // uuid.h:59:1: + UUID_TYPE_DCE_SECURITY = 2 // uuid.h:57:1: + UUID_TYPE_DCE_SHA1 = 5 // uuid.h:60:1: + UUID_TYPE_DCE_TIME = 1 // uuid.h:56:1: + UUID_TYPE_MASK = 0xf // uuid.h:63:1: + UUID_TYPE_SHIFT = 4 // uuid.h:62:1: + UUID_VARIANT_DCE = 1 // uuid.h:48:1: + UUID_VARIANT_MASK = 0x7 // uuid.h:53:1: + UUID_VARIANT_MICROSOFT = 2 // uuid.h:49:1: + UUID_VARIANT_NCS = 0 // uuid.h:47:1: + UUID_VARIANT_OTHER = 3 // uuid.h:50:1: + UUID_VARIANT_SHIFT = 5 // uuid.h:52:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_BYTESWAP_H = 1 // byteswap.h:24:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_PTHREADTYPES_ARCH_H = 1 // pthreadtypes-arch.h:19:1: + X_BITS_PTHREADTYPES_COMMON_H = 1 // pthreadtypes.h:20:1: + X_BITS_STDINT_INTN_H = 1 // stdint-intn.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TIME_H = 1 // time.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_TYPES_LOCALE_T_H = 1 // locale_t.h:20:1: + X_BITS_TYPES___LOCALE_T_H = 1 // __locale_t.h:21:1: + X_BITS_UINTN_IDENTITY_H = 1 // uintn-identity.h:24:1: + X_BSD_SIZE_T_ = 0 // stddef.h:189:1: + X_BSD_SIZE_T_DEFINED_ = 0 // stddef.h:192:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_ENDIAN_H = 1 // endian.h:19:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_GCC_SIZE_T = 0 // stddef.h:195:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_RWLOCK_INTERNAL_H = 0 // struct_rwlock.h:21:1: + X_SIZET_ = 0 // stddef.h:196:1: + X_SIZE_T = 0 // stddef.h:183:1: + X_SIZE_T_ = 0 // stddef.h:188:1: + X_SIZE_T_DECLARED = 0 // stddef.h:193:1: + X_SIZE_T_DEFINED = 0 // stddef.h:191:1: + X_SIZE_T_DEFINED_ = 0 // stddef.h:190:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_STRUCT_TIMESPEC = 1 // struct_timespec.h:3:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_SYS_SELECT_H = 1 // select.h:22:1: + X_SYS_SIZE_T_H = 0 // stddef.h:184:1: + X_SYS_TIME_H = 1 // time.h:19:1: + X_SYS_TYPES_H = 1 // types.h:23:1: + X_THREAD_MUTEX_INTERNAL_H = 1 // struct_mutex.h:20:1: + X_THREAD_SHARED_TYPES_H = 1 // thread-shared-types.h:20:1: + X_TIME_H = 1 // time.h:23:1: + X_T_SIZE = 0 // stddef.h:186:1: + X_T_SIZE_ = 0 // stddef.h:185:1: + X_UUID_UUID_H = 0 // uuid.h:36:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// Values for the first argument to `getitimer' and `setitimer'. +const ( /* time.h:89:1: */ + // Timers run in real time. + ITIMER_REAL = 0 + // Timers run only when the process is executing. + ITIMER_VIRTUAL = 1 + // Timers run when the process is executing and when + // the system is executing on behalf of the process. + ITIMER_PROF = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Public include file for the UUID library +// +// Copyright (C) 1996, 1997, 1998 Theodore Ts'o. +// +// %Begin-Header% +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, and the entire permission notice in its entirety, +// including the disclaimer of warranties. +// 2. Redistributions in binary form must reproduce 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 ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +// WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// %End-Header% + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// x86 internal mutex struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int16 + F__elision int16 + F__list X__pthread_list_t +} /* struct_mutex.h:22:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// x86 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__rwelision int8 + F__pad1 [7]uint8 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [56]int8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct{ F__data X__pthread_mutex_s } /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]int8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]int8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [4]int8 +} /* pthreadtypes.h:118:3 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Structure crudely representing a timezone. +// +// This is obsolete and should never be used. +type Timezone = struct { + Ftz_minuteswest int32 + Ftz_dsttime int32 +} /* time.h:52:1 */ + +// Type of the second argument to `getitimer' and +// +// the second and third arguments `setitimer'. +type Itimerval = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } +} /* time.h:105:1 */ + +type X__itimer_which_t = int32 /* time.h:118:13 */ + +// Convenience macros for operations on timevals. +// NOTE: `timercmp' does not work for >= or <=. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.23 Date and time + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This defines CLOCKS_PER_SEC, which is the number of processor clock +// ticks per second, and possibly a number of other constants. +// System-dependent timing definitions. Linux version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO/IEC 9899:1999 7.23.1: Components of time +// The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is +// the number per second of the value returned by the `clock' function. +// CAE XSH, Issue 4, Version 2: +// The value of CLOCKS_PER_SEC is required to be 1 million on all +// XSI-conformant systems. + +// Identifier for system-wide realtime clock. +// Monotonic system-wide clock. +// High-resolution timer from the CPU. +// Thread-specific CPU-time clock. +// Monotonic system-wide clock, not adjusted for frequency scaling. +// Identifier for system-wide realtime clock, updated only on ticks. +// Monotonic system-wide clock, updated only on ticks. +// Monotonic system-wide clock that includes time spent in suspension. +// Like CLOCK_REALTIME but also wakes suspended system. +// Like CLOCK_BOOTTIME but also wakes suspended system. +// Like CLOCK_REALTIME but in International Atomic Time. + +// Flag to indicate time is absolute. + +// Many of the typedefs and structs whose official home is this header +// may also need to be defined by other headers. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO C `broken-down time' structure. +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* struct_tm.h:7:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// NB: Include guard matches what uses. + +// POSIX.1b structure for timer start values and intervals. +type Itimerspec = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } +} /* struct_itimerspec.h:8:1 */ + +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +type Uuid_t = [16]uint8 /* uuid.h:44:23 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/uuid/uuid/uuid_linux_arm64.go b/internal/libc/uuid/uuid/uuid_linux_arm64.go new file mode 100644 index 0000000..e56cab9 --- /dev/null +++ b/internal/libc/uuid/uuid/uuid_linux_arm64.go @@ -0,0 +1,2089 @@ +// Code generated by 'ccgo uuid/uuid/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o uuid/uuid/uuid_linux_arm64.go -pkgname uuid', DO NOT EDIT. + +package uuid + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + BIG_ENDIAN = 4321 + BYTE_ORDER = 1234 + CLOCK_BOOTTIME = 7 + CLOCK_BOOTTIME_ALARM = 9 + CLOCK_MONOTONIC = 1 + CLOCK_MONOTONIC_COARSE = 6 + CLOCK_MONOTONIC_RAW = 4 + CLOCK_PROCESS_CPUTIME_ID = 2 + CLOCK_REALTIME = 0 + CLOCK_REALTIME_ALARM = 8 + CLOCK_REALTIME_COARSE = 5 + CLOCK_TAI = 11 + CLOCK_THREAD_CPUTIME_ID = 3 + FD_SETSIZE = 1024 + LITTLE_ENDIAN = 1234 + PDP_ENDIAN = 3412 + TIMER_ABSTIME = 1 + TIME_UTC = 1 + UUID_STR_LEN = 37 + UUID_TYPE_DCE_MD5 = 3 + UUID_TYPE_DCE_RANDOM = 4 + UUID_TYPE_DCE_SECURITY = 2 + UUID_TYPE_DCE_SHA1 = 5 + UUID_TYPE_DCE_TIME = 1 + UUID_TYPE_MASK = 0xf + UUID_TYPE_SHIFT = 4 + UUID_VARIANT_DCE = 1 + UUID_VARIANT_MASK = 0x7 + UUID_VARIANT_MICROSOFT = 2 + UUID_VARIANT_NCS = 0 + UUID_VARIANT_OTHER = 3 + UUID_VARIANT_SHIFT = 5 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TIME_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_TYPES_LOCALE_T_H = 1 + X_BITS_TYPES___LOCALE_T_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_GCC_SIZE_T = 0 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_RWLOCK_INTERNAL_H = 0 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_STDC_PREDEF_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_TIME_H = 1 + X_SYS_TYPES_H = 1 + X_THREAD_MUTEX_INTERNAL_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_TIME_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + X_UUID_UUID_H = 0 + Linux = 1 + Unix = 1 +) + +// Values for the first argument to `getitimer' and `setitimer'. +const ( /* time.h:89:1: */ + // Timers run in real time. + ITIMER_REAL = 0 + // Timers run only when the process is executing. + ITIMER_VIRTUAL = 1 + // Timers run when the process is executing and when + // the system is executing on behalf of the process. + ITIMER_PROF = 2 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Public include file for the UUID library +// +// Copyright (C) 1996, 1997, 1998 Theodore Ts'o. +// +// %Begin-Header% +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, and the entire permission notice in its entirety, +// including the disclaimer of warranties. +// 2. Redistributions in binary form must reproduce 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 ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +// WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// %End-Header% + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX Standard: 2.6 Primitive System Data Types + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +type U_char = X__u_char /* types.h:33:18 */ +type U_short = X__u_short /* types.h:34:19 */ +type U_int = X__u_int /* types.h:35:17 */ +type U_long = X__u_long /* types.h:36:18 */ +type Quad_t = X__quad_t /* types.h:37:18 */ +type U_quad_t = X__u_quad_t /* types.h:38:20 */ +type Fsid_t = X__fsid_t /* types.h:39:18 */ +type Loff_t = X__loff_t /* types.h:42:18 */ + +type Ino_t = X__ino64_t /* types.h:49:19 */ + +type Dev_t = X__dev_t /* types.h:59:17 */ + +type Gid_t = X__gid_t /* types.h:64:17 */ + +type Mode_t = X__mode_t /* types.h:69:18 */ + +type Nlink_t = X__nlink_t /* types.h:74:19 */ + +type Uid_t = X__uid_t /* types.h:79:17 */ + +type Off_t = X__off64_t /* types.h:87:19 */ + +type Pid_t = X__pid_t /* types.h:97:17 */ + +type Id_t = X__id_t /* types.h:103:16 */ + +type Ssize_t = X__ssize_t /* types.h:108:19 */ + +type Daddr_t = X__daddr_t /* types.h:114:19 */ +type Caddr_t = X__caddr_t /* types.h:115:19 */ + +type Key_t = X__key_t /* types.h:121:17 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `clock'. +type Clock_t = X__clock_t /* clock_t.h:7:19 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Clock ID used in clock and timer functions. +type Clockid_t = X__clockid_t /* clockid_t.h:7:21 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Returned by `time'. +type Time_t = X__time_t /* time_t.h:7:18 */ + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Timer ID returned by `timer_create'. +type Timer_t = X__timer_t /* timer_t.h:7:19 */ + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// Old compatibility names for C types. +type Ulong = uint64 /* types.h:148:27 */ +type Ushort = uint16 /* types.h:149:28 */ +type Uint = uint32 /* types.h:150:22 */ + +// These size-specific names are used by some of the inet code. + +// Define intN_t types. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +type Int8_t = X__int8_t /* stdint-intn.h:24:18 */ +type Int16_t = X__int16_t /* stdint-intn.h:25:19 */ +type Int32_t = X__int32_t /* stdint-intn.h:26:19 */ +type Int64_t = X__int64_t /* stdint-intn.h:27:19 */ + +// These were defined by ISO C without the first `_'. +type U_int8_t = X__uint8_t /* types.h:158:19 */ +type U_int16_t = X__uint16_t /* types.h:159:20 */ +type U_int32_t = X__uint32_t /* types.h:160:20 */ +type U_int64_t = X__uint64_t /* types.h:161:20 */ + +type Register_t = int32 /* types.h:164:13 */ + +// It also defines `fd_set' and the FD_* macros for `select'. +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Get definition of needed basic types. +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Get __FD_* definitions. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We don't use `memset' because this would require a prototype and +// the array isn't too big. + +// Get sigset_t. + +type X__sigset_t = struct{ F__val [16]uint64 } /* __sigset_t.h:8:3 */ + +// A set of signals to be blocked, unblocked, or waited for. +type Sigset_t = X__sigset_t /* sigset_t.h:7:20 */ + +// Get definition of timer specification structures. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// A time value that is accurate to the nearest +// +// microsecond but also has a range of years. +type Timeval = struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t +} /* struct_timeval.h:8:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1b structure for a time value. This is like a `struct timeval' but +// +// has nanoseconds instead of microseconds. +type Timespec = struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t +} /* struct_timespec.h:10:1 */ + +type Suseconds_t = X__suseconds_t /* select.h:43:23 */ + +// The fd_set member is required to be an array of longs. +type X__fd_mask = int64 /* select.h:49:18 */ + +// Some versions of define this macros. +// It's easier to assume 8-bit bytes than to get CHAR_BIT. + +// fd_set for select and pselect. +type Fd_set = struct{ F__fds_bits [16]X__fd_mask } /* select.h:70:5 */ + +// Maximum number of file descriptors in `fd_set'. + +// Sometimes the fd_set member is assumed to have this type. +type Fd_mask = X__fd_mask /* select.h:77:19 */ + +// Define some inlines helping to catch common problems. + +type Blksize_t = X__blksize_t /* types.h:185:21 */ + +// Types from the Large File Support interface. +type Blkcnt_t = X__blkcnt64_t /* types.h:205:22 */ // Type to count number of disk blocks. +type Fsblkcnt_t = X__fsblkcnt64_t /* types.h:209:24 */ // Type to count file system blocks. +type Fsfilcnt_t = X__fsfilcnt64_t /* types.h:213:24 */ // Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_internal_list = struct { + F__prev uintptr + F__next uintptr +} /* thread-shared-types.h:49:9 */ + +// Type to count file system inodes. + +// Now add the thread types. +// Declaration of common pthread types for all architectures. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For internal mutex and condition variable definitions. +// Common threading primitives definitions for both POSIX and C11. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Arch-specific definitions. Each architecture must define the following +// macros to define the expected sizes of pthread data types: +// +// __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. +// __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. +// __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. +// __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. +// __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. +// __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. +// __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. +// __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. +// __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. +// +// The additional macro defines any constraint for the lock alignment +// inside the thread structures: +// +// __LOCK_ALIGNMENT - for internal lock/futex usage. +// +// Same idea but for the once locking primitive: +// +// __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. + +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Common definition of pthread_mutex_t. + +type X__pthread_list_t = X__pthread_internal_list /* thread-shared-types.h:53:3 */ + +type X__pthread_internal_slist = struct{ F__next uintptr } /* thread-shared-types.h:55:9 */ + +type X__pthread_slist_t = X__pthread_internal_slist /* thread-shared-types.h:58:3 */ + +// Arch-specific mutex definitions. A generic implementation is provided +// by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture +// can override it by defining: +// +// 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t +// definition). It should contains at least the internal members +// defined in the generic version. +// +// 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with +// atomic operations. +// +// 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization. +// It should initialize the mutex internal flag. + +// Default mutex implementation struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Generic struct for both POSIX and C11 mutexes. New ports are expected +// to use the default layout, however architecture can redefine it to +// add arch-specific extension (such as lock-elision). The struct have +// a size of 32 bytes on LP32 and 40 bytes on LP64 architectures. + +type X__pthread_mutex_s = struct { + F__lock int32 + F__count uint32 + F__owner int32 + F__nusers uint32 + F__kind int32 + F__spins int32 + F__list X__pthread_list_t +} /* struct_mutex.h:27:1 */ + +// Arch-sepecific read-write lock definitions. A generic implementation is +// provided by struct_rwlock.h. If required, an architecture can override it +// by defining: +// +// 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition). +// It should contain at least the internal members defined in the +// generic version. +// +// 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization. +// It should initialize the rwlock internal type. + +// AArch64 internal rwlock struct definitions. +// Copyright (C) 2019-2020 Free Software Foundation, Inc. +// +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +type X__pthread_rwlock_arch_t = struct { + F__readers uint32 + F__writers uint32 + F__wrphase_futex uint32 + F__writers_futex uint32 + F__pad3 uint32 + F__pad4 uint32 + F__cur_writer int32 + F__shared int32 + F__pad1 uint64 + F__pad2 uint64 + F__flags uint32 + F__ccgo_pad1 [4]byte +} /* struct_rwlock.h:23:1 */ + +// Common definition of pthread_cond_t. + +type X__pthread_cond_s = struct { + F__0 struct{ F__wseq uint64 } + F__8 struct{ F__g1_start uint64 } + F__g_refs [2]uint32 + F__g_size [2]uint32 + F__g1_orig_size uint32 + F__wrefs uint32 + F__g_signals [2]uint32 +} /* thread-shared-types.h:92:1 */ + +// Thread identifiers. The structure of the attribute type is not +// +// exposed on purpose. +type Pthread_t = uint64 /* pthreadtypes.h:27:27 */ + +// Data structures for mutex handling. The structure of the attribute +// +// type is not exposed on purpose. +type Pthread_mutexattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:36:3 */ + +// Data structure for condition variable handling. The structure of +// +// the attribute type is not exposed on purpose. +type Pthread_condattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:45:3 */ + +// Keys for thread-specific data +type Pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ + +// Once-only execution +type Pthread_once_t = int32 /* pthreadtypes.h:53:30 */ + +type Pthread_attr_t1 = struct { + F__ccgo_pad1 [0]uint64 + F__size [64]uint8 +} /* pthreadtypes.h:56:1 */ + +type Pthread_attr_t = Pthread_attr_t1 /* pthreadtypes.h:62:30 */ + +type Pthread_mutex_t = struct { + F__data X__pthread_mutex_s + F__ccgo_pad1 [8]byte +} /* pthreadtypes.h:72:3 */ + +type Pthread_cond_t = struct{ F__data X__pthread_cond_s } /* pthreadtypes.h:80:3 */ + +// Data structure for reader-writer lock variable handling. The +// +// structure of the attribute type is deliberately not exposed. +type Pthread_rwlock_t = struct{ F__data X__pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ + +type Pthread_rwlockattr_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [8]uint8 +} /* pthreadtypes.h:97:3 */ + +// POSIX spinlock data type. +type Pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ + +// POSIX barriers data type. The structure of the type is +// +// deliberately not exposed. +type Pthread_barrier_t = struct { + F__ccgo_pad1 [0]uint64 + F__size [32]uint8 +} /* pthreadtypes.h:112:3 */ + +type Pthread_barrierattr_t = struct { + F__ccgo_pad1 [0]uint32 + F__size [8]uint8 +} /* pthreadtypes.h:118:3 */ + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// `fd_set' type and related macros, and `select'/`pselect' declarations. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX 1003.1g: 6.2 Select from File Descriptor Sets + +// Structure crudely representing a timezone. +// +// This is obsolete and should never be used. +type Timezone = struct { + Ftz_minuteswest int32 + Ftz_dsttime int32 +} /* time.h:52:1 */ + +// Type of the second argument to `getitimer' and +// +// the second and third arguments `setitimer'. +type Itimerval = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_usec X__suseconds_t + } +} /* time.h:105:1 */ + +type X__itimer_which_t = int32 /* time.h:118:13 */ + +// Convenience macros for operations on timevals. +// NOTE: `timercmp' does not work for >= or <=. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.23 Date and time + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Copyright (C) 1989-2020 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC 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, or (at your option) +// any later version. +// +// GCC 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. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. +// +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C Standard: 7.17 Common definitions + +// Any one of these symbols __need_* means that GNU libc +// wants us just to define one data type. So don't define +// the symbols that indicate this file's entire job has been done. + +// This avoids lossage on SunOS but only if stdtypes.h comes first. +// There's no way to win with the other order! Sun lossage. + +// Sequent's header files use _PTRDIFF_T_ in some conflicting way. +// Just ignore it. + +// On VxWorks, may have defined macros like +// _TYPE_size_t which will typedef size_t. fixincludes patched the +// vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is +// not defined, and so that defining this macro defines _GCC_SIZE_T. +// If we find that the macros are still defined at this point, we must +// invoke them so that the type is defined as expected. + +// In case nobody has defined these types, but we aren't running under +// GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and +// __WCHAR_TYPE__ have reasonable values. This can happen if the +// parts of GCC is compiled by an older compiler, that actually +// include gstddef.h, such as collect2. + +// Signed type of difference of two pointers. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Unsigned type of `sizeof' something. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// Wide character type. +// Locale-writers should change this as necessary to +// be big enough to hold unique values not between 0 and 127, +// and not (wchar_t) -1, for each defined multibyte character. + +// Define this type if we are doing the whole job, +// or if we want this type in particular. + +// A null pointer constant. + +// This defines CLOCKS_PER_SEC, which is the number of processor clock +// ticks per second, and possibly a number of other constants. +// System-dependent timing definitions. Linux version. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO/IEC 9899:1999 7.23.1: Components of time +// The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is +// the number per second of the value returned by the `clock' function. +// CAE XSH, Issue 4, Version 2: +// The value of CLOCKS_PER_SEC is required to be 1 million on all +// XSI-conformant systems. + +// Identifier for system-wide realtime clock. +// Monotonic system-wide clock. +// High-resolution timer from the CPU. +// Thread-specific CPU-time clock. +// Monotonic system-wide clock, not adjusted for frequency scaling. +// Identifier for system-wide realtime clock, updated only on ticks. +// Monotonic system-wide clock, updated only on ticks. +// Monotonic system-wide clock that includes time spent in suspension. +// Like CLOCK_REALTIME but also wakes suspended system. +// Like CLOCK_BOOTTIME but also wakes suspended system. +// Like CLOCK_REALTIME but in International Atomic Time. + +// Flag to indicate time is absolute. + +// Many of the typedefs and structs whose official home is this header +// may also need to be defined by other headers. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// ISO C `broken-down time' structure. +type Tm = struct { + Ftm_sec int32 + Ftm_min int32 + Ftm_hour int32 + Ftm_mday int32 + Ftm_mon int32 + Ftm_year int32 + Ftm_wday int32 + Ftm_yday int32 + Ftm_isdst int32 + F__ccgo_pad1 [4]byte + Ftm_gmtoff int64 + Ftm_zone uintptr +} /* struct_tm.h:7:1 */ + +// NB: Include guard matches what uses. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// NB: Include guard matches what uses. + +// POSIX.1b structure for timer start values and intervals. +type Itimerspec = struct { + Fit_interval struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } + Fit_value struct { + Ftv_sec X__time_t + Ftv_nsec X__syscall_slong_t + } +} /* struct_itimerspec.h:8:1 */ + +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +type Uuid_t = [16]uint8 /* uuid.h:44:23 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/libc/watch.go b/internal/libc/watch.go new file mode 100644 index 0000000..0fc0826 --- /dev/null +++ b/internal/libc/watch.go @@ -0,0 +1,240 @@ +// Copyright 2021 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "github.com/hanzoai/sqlite/internal/libc" + +import ( + "fmt" + "math" + "os" + "sync" + "unsafe" +) + +var ( + watches = map[uintptr]watch{} + watchesMu sync.Mutex +) + +type watch interface { + msg() string +} + +type watcher string + +func (w watcher) msg() string { + if w == "" { + return "" + } + + return fmt.Sprintf(": %s", w) +} + +type watchInt8 struct { + val int8 + watcher +} + +func WatchInt8(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchInt8{*(*int8)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchUint8 struct { + val uint8 + watcher +} + +func WatchUint8(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchUint8{*(*uint8)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchInt16 struct { + val int16 + watcher +} + +func WatchInt16(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchInt16{*(*int16)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchUint16 struct { + val uint16 + watcher +} + +func WatchUint16(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchUint16{*(*uint16)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchInt32 struct { + val int32 + watcher +} + +func WatchInt32(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchInt32{*(*int32)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchUint32 struct { + val uint32 + watcher +} + +func WatchUint32(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchUint32{*(*uint32)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchInt64 struct { + val int64 + watcher +} + +func WatchInt64(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchInt64{*(*int64)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchUint64 struct { + val uint64 + watcher +} + +func WatchUint64(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchUint64{*(*uint64)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchFloat32 struct { + val float32 + watcher +} + +func WatchFloat32(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchFloat32{*(*float32)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchFloat64 struct { + val float64 + watcher +} + +func WatchFloat64(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchFloat64{*(*float64)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +type watchPtr struct { + val uintptr + watcher +} + +func WatchPtr(p uintptr, msg string) { + watchesMu.Lock() + watches[p] = &watchPtr{*(*uintptr)(unsafe.Pointer(p)), watcher(msg)} + watchesMu.Unlock() +} + +func Watch() { + watchesMu.Lock() + flush := false + for p, v := range watches { + switch x := v.(type) { + case *watchInt8: + if val := *(*int8)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: int8@%#x was %d, new %d%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + case *watchUint8: + if val := *(*uint8)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: uint8@%#x was %d, new %d%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + case *watchInt16: + if val := *(*int16)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: int16@%#x was %d, new %d%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + case *watchUint16: + if val := *(*uint16)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: uint16@%#x was %d, new %d%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + case *watchInt32: + if val := *(*int32)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: int32@%#x was %d, new %d%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + case *watchUint32: + if val := *(*uint32)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: uint32@%#x was %d, new %d%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + case *watchInt64: + if val := *(*int64)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: int64@%#x was %d, new %d%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + case *watchUint64: + if val := *(*uint64)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: uint64@%#x was %d, new %d%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + case *watchFloat32: + if val := *(*float32)(unsafe.Pointer(p)); math.Float32bits(val) != math.Float32bits(x.val) { + flush = true + fmt.Fprintf(os.Stderr, "%v: float32@%#x was %v(%#x), new %v(%#x)%s\n", origin(2), p, x.val, math.Float32bits(x.val), val, math.Float32bits(val), x.msg()) + x.val = val + } + case *watchFloat64: + if val := *(*float64)(unsafe.Pointer(p)); math.Float64bits(val) != math.Float64bits(x.val) { + flush = true + fmt.Fprintf(os.Stderr, "%v: float64@%#x was %v(%#x), new %v(%#x)%s\n", origin(2), p, x.val, math.Float64bits(x.val), val, math.Float64bits(val), x.msg()) + x.val = val + } + case *watchPtr: + if val := *(*uintptr)(unsafe.Pointer(p)); val != x.val { + flush = true + fmt.Fprintf(os.Stderr, "%v: ptr@%#x was %#x, new %#x%s\n", origin(2), p, x.val, val, x.msg()) + x.val = val + } + default: + panic(todo("%T", x)) + } + } + if flush { + os.Stderr.Sync() + } + watchesMu.Unlock() +} + +func WatchDelete(p uintptr) { + watchesMu.Lock() + delete(watches, p) + watchesMu.Unlock() +} diff --git a/internal/libc/wctype/capi_darwin_amd64.go b/internal/libc/wctype/capi_darwin_amd64.go new file mode 100644 index 0000000..c11e2f0 --- /dev/null +++ b/internal/libc/wctype/capi_darwin_amd64.go @@ -0,0 +1,55 @@ +// Code generated by 'ccgo wctype/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o wctype/wctype_darwin_amd64.go -pkgname wctype', DO NOT EDIT. + +package wctype + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, + "__isctype": {}, + "__istype": {}, + "__wcwidth": {}, + "digittoint": {}, + "isalnum": {}, + "isalpha": {}, + "isascii": {}, + "isblank": {}, + "iscntrl": {}, + "isdigit": {}, + "isgraph": {}, + "ishexnumber": {}, + "isideogram": {}, + "islower": {}, + "isnumber": {}, + "isphonogram": {}, + "isprint": {}, + "ispunct": {}, + "isrune": {}, + "isspace": {}, + "isspecial": {}, + "isupper": {}, + "iswalnum": {}, + "iswalpha": {}, + "iswascii": {}, + "iswblank": {}, + "iswcntrl": {}, + "iswctype": {}, + "iswdigit": {}, + "iswgraph": {}, + "iswhexnumber": {}, + "iswideogram": {}, + "iswlower": {}, + "iswnumber": {}, + "iswphonogram": {}, + "iswprint": {}, + "iswpunct": {}, + "iswrune": {}, + "iswspace": {}, + "iswspecial": {}, + "iswupper": {}, + "iswxdigit": {}, + "isxdigit": {}, + "toascii": {}, + "tolower": {}, + "toupper": {}, + "towlower": {}, + "towupper": {}, +} diff --git a/internal/libc/wctype/capi_darwin_arm64.go b/internal/libc/wctype/capi_darwin_arm64.go new file mode 100644 index 0000000..f6b7076 --- /dev/null +++ b/internal/libc/wctype/capi_darwin_arm64.go @@ -0,0 +1,55 @@ +// Code generated by 'ccgo wctype/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o wctype/wctype_darwin_arm64.go -pkgname wctype', DO NOT EDIT. + +package wctype + +var CAPI = map[string]struct{}{ + "__darwin_check_fd_set_overflow": {}, + "__isctype": {}, + "__istype": {}, + "__wcwidth": {}, + "digittoint": {}, + "isalnum": {}, + "isalpha": {}, + "isascii": {}, + "isblank": {}, + "iscntrl": {}, + "isdigit": {}, + "isgraph": {}, + "ishexnumber": {}, + "isideogram": {}, + "islower": {}, + "isnumber": {}, + "isphonogram": {}, + "isprint": {}, + "ispunct": {}, + "isrune": {}, + "isspace": {}, + "isspecial": {}, + "isupper": {}, + "iswalnum": {}, + "iswalpha": {}, + "iswascii": {}, + "iswblank": {}, + "iswcntrl": {}, + "iswctype": {}, + "iswdigit": {}, + "iswgraph": {}, + "iswhexnumber": {}, + "iswideogram": {}, + "iswlower": {}, + "iswnumber": {}, + "iswphonogram": {}, + "iswprint": {}, + "iswpunct": {}, + "iswrune": {}, + "iswspace": {}, + "iswspecial": {}, + "iswupper": {}, + "iswxdigit": {}, + "isxdigit": {}, + "toascii": {}, + "tolower": {}, + "toupper": {}, + "towlower": {}, + "towupper": {}, +} diff --git a/internal/libc/wctype/capi_linux_amd64.go b/internal/libc/wctype/capi_linux_amd64.go new file mode 100644 index 0000000..e1138cc --- /dev/null +++ b/internal/libc/wctype/capi_linux_amd64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo wctype/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o wctype/wctype_linux_amd64.go -pkgname wctype', DO NOT EDIT. + +package wctype + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/wctype/capi_linux_arm64.go b/internal/libc/wctype/capi_linux_arm64.go new file mode 100644 index 0000000..17a10a4 --- /dev/null +++ b/internal/libc/wctype/capi_linux_arm64.go @@ -0,0 +1,5 @@ +// Code generated by 'ccgo wctype/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o wctype/wctype_linux_arm64.go -pkgname wctype', DO NOT EDIT. + +package wctype + +var CAPI = map[string]struct{}{} diff --git a/internal/libc/wctype/wctype_darwin_amd64.go b/internal/libc/wctype/wctype_darwin_amd64.go new file mode 100644 index 0000000..00202e7 --- /dev/null +++ b/internal/libc/wctype/wctype_darwin_amd64.go @@ -0,0 +1,1414 @@ +// Code generated by 'ccgo wctype/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o wctype/wctype_darwin_amd64.go -pkgname wctype', DO NOT EDIT. + +package wctype + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_I386__TYPES_H_ = 0 // _types.h:29:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CACHED_RUNES = 256 // runetype.h:54:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CRMASK = -256 // runetype.h:55:1: + X_CTYPE_A = 0x00000100 // _ctype.h:72:1: + X_CTYPE_B = 0x00020000 // _ctype.h:81:1: + X_CTYPE_C = 0x00000200 // _ctype.h:73:1: + X_CTYPE_D = 0x00000400 // _ctype.h:74:1: + X_CTYPE_G = 0x00000800 // _ctype.h:75:1: + X_CTYPE_H_ = 0 // ctype.h:67:1: + X_CTYPE_I = 0x00080000 // _ctype.h:83:1: + X_CTYPE_L = 0x00001000 // _ctype.h:76:1: + X_CTYPE_P = 0x00002000 // _ctype.h:77:1: + X_CTYPE_Q = 0x00200000 // _ctype.h:85:1: + X_CTYPE_R = 0x00040000 // _ctype.h:82:1: + X_CTYPE_S = 0x00004000 // _ctype.h:78:1: + X_CTYPE_SW0 = 0x20000000 // _ctype.h:86:1: + X_CTYPE_SW1 = 0x40000000 // _ctype.h:87:1: + X_CTYPE_SW2 = 0x80000000 // _ctype.h:88:1: + X_CTYPE_SW3 = 0xc0000000 // _ctype.h:89:1: + X_CTYPE_SWM = 0xe0000000 // _ctype.h:90:1: + X_CTYPE_SWS = 30 // _ctype.h:91:1: + X_CTYPE_T = 0x00100000 // _ctype.h:84:1: + X_CTYPE_U = 0x00008000 // _ctype.h:79:1: + X_CTYPE_X = 0x00010000 // _ctype.h:80:1: + X_CT_RUNE_T = 0 // _ct_rune_t.h:30:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:745:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:771:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:779:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:243:1: + X_Null_unspecified = 0 // cdefs.h:246:1: + X_Nullable = 0 // cdefs.h:240:1: + X_RUNETYPE_H_ = 0 // runetype.h:40:1: + X_RUNE_MAGIC_A = "RuneMagA" // runetype.h:108:1: + X_RUNE_T = 0 // _rune_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_WCHAR_T = 0 // _wchar_t.h:32:1: + X_WCTRANS_T = 0 // _wctrans_t.h:30:1: + X_WCTYPE_H_ = 0 // wctype.h:32:1: + X_WCTYPE_T = 0 // _wctype_t.h:30:1: + X_WINT_T = 0 // _wint_t.h:30:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// - +// Copyright (c)1999 Citrus Project, +// 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. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp +// $NetBSD: wctype.h,v 1.3 2000/12/22 14:16:16 itojun Exp $ +// $FreeBSD: /repoman/r/ncvs/src/include/wctype.h,v 1.10 2002/08/21 16:19:55 mike Exp $ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function of variable. + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX +// #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:37:33 */ +type X__uint8_t = uint8 /* _types.h:41:33 */ +type X__int16_t = int16 /* _types.h:42:33 */ +type X__uint16_t = uint16 /* _types.h:43:33 */ +type X__int32_t = int32 /* _types.h:44:33 */ +type X__uint32_t = uint32 /* _types.h:45:33 */ +type X__int64_t = int64 /* _types.h:46:33 */ +type X__uint64_t = uint64 /* _types.h:47:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:49:33 */ +type X__darwin_natural_t = uint32 /* _types.h:50:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:70:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:79:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:81:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:84:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:92:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:98:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:104:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:109:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:112:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:117:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:118:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:119:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:120:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type Wctrans_t = X__darwin_wctrans_t /* _wctrans_t.h:32:28 */ + +// - +// Copyright (c)1999 Citrus Project, +// 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. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// + +// Common header for wctype.h and wchar.h +// +// Contains everything required by wctype.h except: +// +// #include <_types/_wctrans_t.h> +// int iswblank(wint_t); +// wint_t towctrans(wint_t, wctrans_t); +// wctrans_t wctrans(const char *); + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// Copyright (c)1999 Citrus Project, +// 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. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// + +// Common header for _wctype.h and xlocale/__wctype.h + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Wint_t = X__darwin_wint_t /* _wint_t.h:32:25 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type Wctype_t = X__darwin_wctype_t /* _wctype_t.h:32:27 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Ct_rune_t = X__darwin_ct_rune_t /* _ct_rune_t.h:32:28 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Rune_t = X__darwin_rune_t /* _rune_t.h:31:25 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// The lower 8 bits of runetype[] contain the digit value of the rune. +type X_RuneEntry = struct { + F__min X__darwin_rune_t + F__max X__darwin_rune_t + F__map X__darwin_rune_t + F__ccgo_pad1 [4]byte + F__types uintptr +} /* runetype.h:65:3 */ + +type X_RuneRange = struct { + F__nranges int32 + F__ccgo_pad1 [4]byte + F__ranges uintptr +} /* runetype.h:70:3 */ + +type X_RuneCharClass = struct { + F__name [14]int8 + F__ccgo_pad1 [2]byte + F__mask X__uint32_t +} /* runetype.h:75:3 */ + +type X_RuneLocale = struct { + F__magic [8]int8 + F__encoding [32]int8 + F__sgetrune uintptr + F__sputrune uintptr + F__invalid_rune X__darwin_rune_t + F__runetype [256]X__uint32_t + F__maplower [256]X__darwin_rune_t + F__mapupper [256]X__darwin_rune_t + F__ccgo_pad1 [4]byte + F__runetype_ext X_RuneRange + F__maplower_ext X_RuneRange + F__mapupper_ext X_RuneRange + F__variable uintptr + F__variable_len int32 + F__ncharclasses int32 + F__charclasses uintptr +} /* runetype.h:106:3 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/wctype/wctype_darwin_arm64.go b/internal/libc/wctype/wctype_darwin_arm64.go new file mode 100644 index 0000000..49d5dc9 --- /dev/null +++ b/internal/libc/wctype/wctype_darwin_arm64.go @@ -0,0 +1,1416 @@ +// Code generated by 'ccgo wctype/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o wctype/wctype_darwin_arm64.go -pkgname wctype', DO NOT EDIT. + +package wctype + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + X_BSD_ARM__TYPES_H_ = 0 // _types.h:5:1: + X_BSD_MACHINE__TYPES_H_ = 0 // _types.h:29:1: + X_CACHED_RUNES = 256 // runetype.h:54:1: + X_CDEFS_H_ = 0 // cdefs.h:68:1: + X_CRMASK = -256 // runetype.h:55:1: + X_CTYPE_A = 0x00000100 // _ctype.h:72:1: + X_CTYPE_B = 0x00020000 // _ctype.h:81:1: + X_CTYPE_C = 0x00000200 // _ctype.h:73:1: + X_CTYPE_D = 0x00000400 // _ctype.h:74:1: + X_CTYPE_G = 0x00000800 // _ctype.h:75:1: + X_CTYPE_H_ = 0 // ctype.h:67:1: + X_CTYPE_I = 0x00080000 // _ctype.h:83:1: + X_CTYPE_L = 0x00001000 // _ctype.h:76:1: + X_CTYPE_P = 0x00002000 // _ctype.h:77:1: + X_CTYPE_Q = 0x00200000 // _ctype.h:85:1: + X_CTYPE_R = 0x00040000 // _ctype.h:82:1: + X_CTYPE_S = 0x00004000 // _ctype.h:78:1: + X_CTYPE_SW0 = 0x20000000 // _ctype.h:86:1: + X_CTYPE_SW1 = 0x40000000 // _ctype.h:87:1: + X_CTYPE_SW2 = 0x80000000 // _ctype.h:88:1: + X_CTYPE_SW3 = 0xc0000000 // _ctype.h:89:1: + X_CTYPE_SWM = 0xe0000000 // _ctype.h:90:1: + X_CTYPE_SWS = 30 // _ctype.h:91:1: + X_CTYPE_T = 0x00100000 // _ctype.h:84:1: + X_CTYPE_U = 0x00008000 // _ctype.h:79:1: + X_CTYPE_X = 0x00010000 // _ctype.h:80:1: + X_CT_RUNE_T = 0 // _ct_rune_t.h:30:1: + X_DARWIN_FEATURE_64_BIT_INODE = 1 // cdefs.h:774:1: + X_DARWIN_FEATURE_ONLY_64_BIT_INODE = 1 // cdefs.h:784:1: + X_DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1 // cdefs.h:800:1: + X_DARWIN_FEATURE_ONLY_VERS_1050 = 1 // cdefs.h:792:1: + X_DARWIN_FEATURE_UNIX_CONFORMANCE = 3 // cdefs.h:808:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_FORTIFY_SOURCE = 2 // _types.h:65:1: + X_LP64 = 1 // :1:1: + X_Nonnull = 0 // cdefs.h:268:1: + X_Null_unspecified = 0 // cdefs.h:271:1: + X_Nullable = 0 // cdefs.h:265:1: + X_RUNETYPE_H_ = 0 // runetype.h:40:1: + X_RUNE_MAGIC_A = "RuneMagA" // runetype.h:108:1: + X_RUNE_T = 0 // _rune_t.h:29:1: + X_SIZE_T = 0 // _size_t.h:29:1: + X_SYS__PTHREAD_TYPES_H_ = 0 // _pthread_types.h:30:1: + X_SYS__TYPES_H_ = 0 // _types.h:30:1: + X_WCHAR_T = 0 // _wchar_t.h:32:1: + X_WCTRANS_T = 0 // _wctrans_t.h:30:1: + X_WCTYPE_H_ = 0 // wctype.h:32:1: + X_WCTYPE_T = 0 // _wctype_t.h:30:1: + X_WINT_T = 0 // _wint_t.h:30:1: +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +var X__darwin_check_fd_set_overflow uintptr /* :146:5: */ + +// - +// Copyright (c)1999 Citrus Project, +// 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. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// +// citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp +// $NetBSD: wctype.h,v 1.3 2000/12/22 14:16:16 itojun Exp $ +// $FreeBSD: /repoman/r/ncvs/src/include/wctype.h,v 1.10 2002/08/21 16:19:55 mike Exp $ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// This SDK is designed to work with clang and specific versions of +// gcc >= 4.0 with Apple's patch sets + +// Compatibility with compilers and environments that don't support compiler +// feature checking function-like macros. + +// 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. + +// 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. + +// __pure2 can be used for functions that are only a function of their scalar +// arguments (meaning they can't dereference pointers). +// +// __stateful_pure can be used for functions that have no side effects, +// but depend on the state of the memory. + +// __unused denotes variables and functions that may not be used, preventing +// the compiler from warning about it if not used. + +// __used forces variables and functions to be included even if it appears +// to the compiler that they are not used (and would thust be discarded). + +// __cold marks code used for debugging or that is rarely taken +// and tells the compiler to optimize for size and outline code. + +// __exported denotes symbols that should be exported even when symbols +// are hidden by default. +// __exported_push/_exported_pop are pragmas used to delimit a range of +// symbols that should be exported even when symbols are hidden by default. + +// __deprecated causes the compiler to produce a warning when encountering +// code using the deprecated functionality. +// __deprecated_msg() does the same, and compilers that support it will print +// a message along with the deprecation warning. +// This may require turning on such warning with the -Wdeprecated flag. +// __deprecated_enum_msg() should be used on enums, and compilers that support +// it will print the deprecation warning. +// __kpi_deprecated() specifically indicates deprecation of kernel programming +// interfaces in Kernel.framework used by KEXTs. + +// __unavailable causes the compiler to error out when encountering +// code using the tagged function + +// Delete pseudo-keywords wherever they are not available or needed. + +// We use `__restrict' as a way to define the `restrict' type qualifier +// without disturbing older software that is unaware of C99 keywords. + +// Compatibility with compilers and environments that don't support the +// nullability feature. + +// __disable_tail_calls causes the compiler to not perform tail call +// optimization inside the marked function. + +// __not_tail_called causes the compiler to prevent tail call optimization +// on statically bound calls to the function. It has no effect on indirect +// calls. Virtual functions, objective-c methods, and functions marked as +// "always_inline" cannot be marked as __not_tail_called. + +// __result_use_check warns callers of a function that not using the function +// return value is a bug, i.e. dismissing malloc() return value results in a +// memory leak. + +// __swift_unavailable causes the compiler to mark a symbol as specifically +// unavailable in Swift, regardless of any other availability in C. + +// __abortlike is the attribute to put on functions like abort() that are +// typically used to mark assertions. These optimize the codegen +// for outlining while still maintaining debugability. + +// Declaring inline functions within headers is error-prone due to differences +// across various versions of the C language and extensions. __header_inline +// can be used to declare inline functions within system headers. In cases +// where you want to force inlining instead of letting the compiler make +// the decision, you can use __header_always_inline. +// +// Be aware that using inline for functions which compilers may also provide +// builtins can behave differently under various compilers. If you intend to +// provide an inline version of such a function, you may want to use a macro +// instead. +// +// The check for !__GNUC__ || __clang__ is because gcc doesn't correctly +// support c99 inline in some cases: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + +// Compiler-dependent macros that bracket portions of code where the +// "-Wunreachable-code" warning should be ignored. Please use sparingly. + +// Compiler-dependent macros to declare that functions take printf-like +// or scanf-like arguments. They are null except for versions of gcc +// that are known to support the features properly. Functions declared +// with these attributes will cause compilation warnings if there is a +// mismatch between the format string and subsequent function parameter +// types. + +// Source compatibility only, ID string not emitted in object file + +// __alloc_size can be used to label function arguments that represent the +// size of memory that the function allocates and returns. The one-argument +// form labels a single argument that gives the allocation size (where the +// arguments are numbered from 1): +// +// void *malloc(size_t __size) __alloc_size(1); +// +// The two-argument form handles the case where the size is calculated as the +// product of two arguments: +// +// void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + +// COMPILATION ENVIRONMENTS -- see compat(5) for additional detail +// +// DEFAULT By default newly complied code will get POSIX APIs plus +// Apple API extensions in scope. +// +// Most users will use this compilation environment to avoid +// behavioral differences between 32 and 64 bit code. +// +// LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple +// API extensions in scope. +// +// This is generally equivalent to the Tiger release compilation +// environment, except that it cannot be applied to 64 bit code; +// its use is discouraged. +// +// We expect this environment to be deprecated in the future. +// +// STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the +// available APIs to exactly the set of APIs defined by the +// corresponding standard, based on the value defined. +// +// A correct, portable definition for _POSIX_C_SOURCE is 200112L. +// A correct, portable definition for _XOPEN_SOURCE is 600L. +// +// Apple API extensions are not visible in this environment, +// which can cause Apple specific code to fail to compile, +// or behave incorrectly if prototypes are not in scope or +// warnings about missing prototypes are not enabled or ignored. +// +// In any compilation environment, for correct symbol resolution to occur, +// function prototypes must be in scope. It is recommended that all Apple +// tools users add either the "-Wall" or "-Wimplicit-function-declaration" +// compiler flags to their projects to be warned when a function is being +// used without a prototype in scope. + +// These settings are particular to each product. +// Platform: MacOSX + +// The __DARWIN_ALIAS macros are used to do symbol renaming; they allow +// legacy code to use the old symbol, thus maintaining binary compatibility +// while new code can use a standards compliant version of the same function. +// +// __DARWIN_ALIAS is used by itself if the function signature has not +// changed, it is used along with a #ifdef check for __DARWIN_UNIX03 +// if the signature has changed. Because the __LP64__ environment +// only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be +// defined, but causes __DARWIN_ALIAS to do no symbol mangling. +// +// As a special case, when XCode is used to target a specific version of the +// OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +// will be defined by the compiler, with the digits representing major version +// time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting +// pre-10.5, and it is the default compilation environment, revert the +// compilation environment to pre-__DARWIN_UNIX03. + +// symbol suffixes used for symbol versioning + +// symbol versioning macros + +// symbol release macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// POSIX.1 requires that the macros we test be defined before any standard +// header file is included. This permits us to convert values for feature +// testing, as necessary, using only _POSIX_C_SOURCE. +// +// Here's a quick run-down of the versions: +// defined(_POSIX_SOURCE) 1003.1-1988 +// _POSIX_C_SOURCE == 1L 1003.1-1990 +// _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option +// _POSIX_C_SOURCE == 199309L 1003.1b-1993 +// _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, +// and the omnibus ISO/IEC 9945-1: 1996 +// _POSIX_C_SOURCE == 200112L 1003.1-2001 +// _POSIX_C_SOURCE == 200809L 1003.1-2008 +// +// In addition, the X/Open Portability Guide, which is now the Single UNIX +// Specification, defines a feature-test macro which indicates the version of +// that specification, and which subsumes _POSIX_C_SOURCE. + +// Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. + +// Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. + +// Deal with various X/Open Portability Guides and Single UNIX Spec. + +// Deal with all versions of POSIX. The ordering relative to the tests above is +// important. + +// POSIX C deprecation macros +// Copyright (c) 2010 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Set a single macro which will always be defined and can be used to determine +// the appropriate namespace. For POSIX, these values will correspond to +// _POSIX_C_SOURCE value. Currently there are two additional levels corresponding +// to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + +// If the developer has neither requested a strict language mode nor a version +// of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part +// of __DARWIN_C_FULL. + +// long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and +// c99 still want long longs. While not perfect, we allow long longs for +// g++. + +// **************************************** +// +// Public darwin-specific feature macros +// + +// _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and +// structures modified for 64-bit inodes (like struct stat) will be used. + +// _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only +// be 64-bit; there is no support for 32-bit ino_t when this macro is defined +// (and non-zero). There is no struct stat64 either, as the regular +// struct stat will already be the 64-bit version. + +// _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated +// in 10.5 exists; no pre-10.5 variants are available. + +// _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API +// are available (the legacy BSD APIs are not available) + +// _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, +// and specifies the conformance level (3 is SUSv3) + +// This macro casts away the qualifier from the variable +// +// Note: use at your own risk, removing qualifiers can result in +// catastrophic run-time failures. + +// __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be +// used from other compilation units, but not other libraries or executables. + +// We intentionally define to nothing pointer attributes which do not have an +// impact on the ABI. __indexable and __bidi_indexable are not defined because +// of the ABI incompatibility that makes the diagnostic preferable. + +// Similarly, we intentionally define to nothing the +// __ptrcheck_abi_assume_single and __ptrcheck_abi_assume_unsafe_indexable +// macros because they do not lead to an ABI incompatibility. However, we do not +// define the indexable and unsafe_indexable ones because the diagnostic is +// better than the silent ABI break. + +// __unsafe_forge intrinsics are defined as regular C casts. + +// decay operates normally; attribute is meaningless without pointer checks. + +// Architecture validation for current SDK + +// Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS +// +// This provides more advanced type checking on compilers supporting +// the proper extensions, even in C. + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2007 Apple Inc. All rights reserved. + +// This header file contains integer types. It's intended to also contain +// flotaing point and other arithmetic types, as needed, later. + +type X__int8_t = int8 /* _types.h:15:33 */ +type X__uint8_t = uint8 /* _types.h:19:33 */ +type X__int16_t = int16 /* _types.h:20:33 */ +type X__uint16_t = uint16 /* _types.h:21:33 */ +type X__int32_t = int32 /* _types.h:22:33 */ +type X__uint32_t = uint32 /* _types.h:23:33 */ +type X__int64_t = int64 /* _types.h:24:33 */ +type X__uint64_t = uint64 /* _types.h:25:33 */ + +type X__darwin_intptr_t = int64 /* _types.h:27:33 */ +type X__darwin_natural_t = uint32 /* _types.h:28:33 */ + +// The rune type below is declared to be an ``int'' instead of the more natural +// ``unsigned long'' or ``long''. Two things are happening here. It is not +// unsigned so that EOF (-1) can be naturally assigned to it and used. Also, +// it looks like 10646 will be a 31 bit standard. This means that if your +// ints cannot hold 32 bits, you will be in trouble. The reason an int was +// chosen over a long is that the is*() and to*() routines take ints (says +// ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it +// here, you lose a bit of ANSI conformance, but your programs will still +// work. +// +// NOTE: rune_t is not covered by ANSI nor other standards, and should not +// be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and +// rune_t must be the same type. Also wint_t must be no narrower than +// wchar_t, and should also be able to hold all members of the largest +// character set plus one extra value (WEOF). wint_t must be at least 16 bits. + +type X__darwin_ct_rune_t = int32 /* _types.h:48:33 */ // ct_rune_t + +// mbstate_t is an opaque object to keep conversion state, during multibyte +// stream conversions. The content must not be referenced by user programs. +type X__mbstate_t = struct { + F__ccgo_pad1 [0]uint64 + F__mbstate8 [128]int8 +} /* _types.h:57:3 */ + +type X__darwin_mbstate_t = X__mbstate_t /* _types.h:59:33 */ // mbstate_t + +type X__darwin_ptrdiff_t = int64 /* _types.h:62:33 */ // ptr1 - ptr2 + +type X__darwin_size_t = uint64 /* _types.h:70:33 */ // sizeof() + +type X__darwin_va_list = X__builtin_va_list /* _types.h:76:33 */ // va_list + +type X__darwin_wchar_t = int32 /* _types.h:82:33 */ // wchar_t + +type X__darwin_rune_t = X__darwin_wchar_t /* _types.h:87:33 */ // rune_t + +type X__darwin_wint_t = int32 /* _types.h:90:33 */ // wint_t + +type X__darwin_clock_t = uint64 /* _types.h:95:33 */ // clock() +type X__darwin_socklen_t = X__uint32_t /* _types.h:96:33 */ // socklen_t (duh) +type X__darwin_ssize_t = int64 /* _types.h:97:33 */ // byte count or error +type X__darwin_time_t = int64 /* _types.h:98:33 */ // time() + +// Type definitions; takes common type definitions that must be used +// in multiple header files due to [XSI], removes them from the system +// space, and puts them in the implementation space. + +type X__darwin_blkcnt_t = X__int64_t /* _types.h:55:25 */ // total blocks +type X__darwin_blksize_t = X__int32_t /* _types.h:56:25 */ // preferred block size +type X__darwin_dev_t = X__int32_t /* _types.h:57:25 */ // dev_t +type X__darwin_fsblkcnt_t = uint32 /* _types.h:58:25 */ // Used by statvfs and fstatvfs +type X__darwin_fsfilcnt_t = uint32 /* _types.h:59:25 */ // Used by statvfs and fstatvfs +type X__darwin_gid_t = X__uint32_t /* _types.h:60:25 */ // [???] process and group IDs +type X__darwin_id_t = X__uint32_t /* _types.h:61:25 */ // [XSI] pid_t, uid_t, or gid_t +type X__darwin_ino64_t = X__uint64_t /* _types.h:62:25 */ // [???] Used for 64 bit inodes +type X__darwin_ino_t = X__darwin_ino64_t /* _types.h:64:26 */ // [???] Used for inodes +type X__darwin_mach_port_name_t = X__darwin_natural_t /* _types.h:68:28 */ // Used by mach +type X__darwin_mach_port_t = X__darwin_mach_port_name_t /* _types.h:69:35 */ // Used by mach +type X__darwin_mode_t = X__uint16_t /* _types.h:70:25 */ // [???] Some file attributes +type X__darwin_off_t = X__int64_t /* _types.h:71:25 */ // [???] Used for file sizes +type X__darwin_pid_t = X__int32_t /* _types.h:72:25 */ // [???] process and group IDs +type X__darwin_sigset_t = X__uint32_t /* _types.h:73:25 */ // [???] signal set +type X__darwin_suseconds_t = X__int32_t /* _types.h:74:25 */ // [???] microseconds +type X__darwin_uid_t = X__uint32_t /* _types.h:75:25 */ // [???] user IDs +type X__darwin_useconds_t = X__uint32_t /* _types.h:76:25 */ // [???] microseconds +type X__darwin_uuid_t = [16]uint8 /* _types.h:77:25 */ +type X__darwin_uuid_string_t = [37]int8 /* _types.h:78:17 */ + +// Copyright (c) 2003-2013 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// pthread opaque structures + +type X__darwin_pthread_handler_rec = struct { + F__routine uintptr + F__arg uintptr + F__next uintptr +} /* _pthread_types.h:57:1 */ + +type X_opaque_pthread_attr_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:63:1 */ + +type X_opaque_pthread_cond_t = struct { + F__sig int64 + F__opaque [40]int8 +} /* _pthread_types.h:68:1 */ + +type X_opaque_pthread_condattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:73:1 */ + +type X_opaque_pthread_mutex_t = struct { + F__sig int64 + F__opaque [56]int8 +} /* _pthread_types.h:78:1 */ + +type X_opaque_pthread_mutexattr_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:83:1 */ + +type X_opaque_pthread_once_t = struct { + F__sig int64 + F__opaque [8]int8 +} /* _pthread_types.h:88:1 */ + +type X_opaque_pthread_rwlock_t = struct { + F__sig int64 + F__opaque [192]int8 +} /* _pthread_types.h:93:1 */ + +type X_opaque_pthread_rwlockattr_t = struct { + F__sig int64 + F__opaque [16]int8 +} /* _pthread_types.h:98:1 */ + +type X_opaque_pthread_t = struct { + F__sig int64 + F__cleanup_stack uintptr + F__opaque [8176]int8 +} /* _pthread_types.h:103:1 */ + +type X__darwin_pthread_attr_t = X_opaque_pthread_attr_t /* _pthread_types.h:109:39 */ +type X__darwin_pthread_cond_t = X_opaque_pthread_cond_t /* _pthread_types.h:110:39 */ +type X__darwin_pthread_condattr_t = X_opaque_pthread_condattr_t /* _pthread_types.h:111:43 */ +type X__darwin_pthread_key_t = uint64 /* _pthread_types.h:112:23 */ +type X__darwin_pthread_mutex_t = X_opaque_pthread_mutex_t /* _pthread_types.h:113:40 */ +type X__darwin_pthread_mutexattr_t = X_opaque_pthread_mutexattr_t /* _pthread_types.h:114:44 */ +type X__darwin_pthread_once_t = X_opaque_pthread_once_t /* _pthread_types.h:115:39 */ +type X__darwin_pthread_rwlock_t = X_opaque_pthread_rwlock_t /* _pthread_types.h:116:41 */ +type X__darwin_pthread_rwlockattr_t = X_opaque_pthread_rwlockattr_t /* _pthread_types.h:117:45 */ +type X__darwin_pthread_t = uintptr /* _pthread_types.h:118:34 */ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +type X__darwin_nl_item = int32 /* _types.h:40:14 */ +type X__darwin_wctrans_t = int32 /* _types.h:41:14 */ +type X__darwin_wctype_t = X__uint32_t /* _types.h:43:20 */ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type Wctrans_t = X__darwin_wctrans_t /* _wctrans_t.h:32:28 */ + +// - +// Copyright (c)1999 Citrus Project, +// 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. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// + +// Common header for wctype.h and wchar.h +// +// Contains everything required by wctype.h except: +// +// #include <_types/_wctrans_t.h> +// int iswblank(wint_t); +// wint_t towctrans(wint_t, wctrans_t); +// wctrans_t wctrans(const char *); + +// Copyright (c) 2017 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ +// - +// Copyright (c)1999 Citrus Project, +// 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. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +// ANY EXPRESS OR IMPLIED 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 OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. +// + +// Common header for _wctype.h and xlocale/__wctype.h + +// Copyright (c) 2000-2018 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright 1995 NeXT Computer, Inc. All rights reserved. +// 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.8 (Berkeley) 1/9/95 + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Wint_t = X__darwin_wint_t /* _wint_t.h:32:25 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2004, 2008, 2009 Apple Inc. All rights reserved. +// +// @APPLE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this +// file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_LICENSE_HEADER_END@ + +type Wctype_t = X__darwin_wctype_t /* _wctype_t.h:32:27 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Ct_rune_t = X__darwin_ct_rune_t /* _ct_rune_t.h:32:28 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +// Copyright (c) 2003-2007 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ +type Rune_t = X__darwin_rune_t /* _rune_t.h:31:25 */ +// Copyright (c) 2012 Apple Inc. All rights reserved. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_START@ +// +// This file contains Original Code and/or Modifications of Original Code +// as defined in and that are subject to the Apple Public Source License +// Version 2.0 (the 'License'). You may not use this file except in +// compliance with the License. The rights granted to you under the License +// may not be used to create, or enable the creation or redistribution of, +// unlawful or unlicensed copies of an Apple operating system, or to +// circumvent, violate, or enable the circumvention or violation of, any +// terms of an Apple operating system software license agreement. +// +// Please obtain a copy of the License at +// http://www.opensource.apple.com/apsl/ and read it before using this file. +// +// The Original Code and all software distributed under the License are +// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +// Please see the License for the specific language governing rights and +// limitations under the License. +// +// @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + +// The lower 8 bits of runetype[] contain the digit value of the rune. +type X_RuneEntry = struct { + F__min X__darwin_rune_t + F__max X__darwin_rune_t + F__map X__darwin_rune_t + F__ccgo_pad1 [4]byte + F__types uintptr +} /* runetype.h:65:3 */ + +type X_RuneRange = struct { + F__nranges int32 + F__ccgo_pad1 [4]byte + F__ranges uintptr +} /* runetype.h:70:3 */ + +type X_RuneCharClass = struct { + F__name [14]int8 + F__ccgo_pad1 [2]byte + F__mask X__uint32_t +} /* runetype.h:75:3 */ + +type X_RuneLocale = struct { + F__magic [8]int8 + F__encoding [32]int8 + F__sgetrune uintptr + F__sputrune uintptr + F__invalid_rune X__darwin_rune_t + F__runetype [256]X__uint32_t + F__maplower [256]X__darwin_rune_t + F__mapupper [256]X__darwin_rune_t + F__ccgo_pad1 [4]byte + F__runetype_ext X_RuneRange + F__maplower_ext X_RuneRange + F__mapupper_ext X_RuneRange + F__variable uintptr + F__variable_len int32 + F__ncharclasses int32 + F__charclasses uintptr +} /* runetype.h:106:3 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/wctype/wctype_linux_amd64.go b/internal/libc/wctype/wctype_linux_amd64.go new file mode 100644 index 0000000..1ed6386 --- /dev/null +++ b/internal/libc/wctype/wctype_linux_amd64.go @@ -0,0 +1,953 @@ +// Code generated by 'ccgo wctype/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o wctype/wctype_linux_amd64.go -pkgname wctype', DO NOT EDIT. + +package wctype + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + WEOF = 4294967295 // wctype.h:33:1: + X_ATFILE_SOURCE = 1 // features.h:342:1: + X_BITS_ENDIANNESS_H = 1 // endianness.h:2:1: + X_BITS_ENDIAN_H = 1 // endian.h:20:1: + X_BITS_TIME64_H = 1 // time64.h:24:1: + X_BITS_TYPESIZES_H = 1 // typesizes.h:24:1: + X_BITS_TYPES_H = 1 // types.h:24:1: + X_BITS_TYPES_LOCALE_T_H = 1 // locale_t.h:20:1: + X_BITS_TYPES___LOCALE_T_H = 1 // __locale_t.h:21:1: + X_BITS_WCTYPE_WCHAR_H = 1 // wctype-wchar.h:24:1: + X_DEFAULT_SOURCE = 1 // features.h:227:1: + X_FEATURES_H = 1 // features.h:19:1: + X_FILE_OFFSET_BITS = 64 // :25:1: + X_LP64 = 1 // :284:1: + X_POSIX_C_SOURCE = 200809 // features.h:281:1: + X_POSIX_SOURCE = 1 // features.h:279:1: + X_STDC_PREDEF_H = 1 // :162:1: + X_SYS_CDEFS_H = 1 // cdefs.h:19:1: + X_WCTYPE_H = 1 // wctype.h:24:1: + X_WINT_T = 1 // wint_t.h:10:1: + Linux = 1 // :231:1: + Unix = 1 // :177:1: +) + +// The characteristics are stored always in network byte order (big +// endian). We define the bit value interpretations here dependent on the +// machine's byte order. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// i386/x86_64 are little-endian. + +// Some machines may need to use a different endianness for floating point +// values. + +const ( /* wctype-wchar.h:56:1: */ + X__ISwupper = 0 // UPPERCASE. + X__ISwlower = 1 // lowercase. + X__ISwalpha = 2 // Alphabetic. + X__ISwdigit = 3 // Numeric. + X__ISwxdigit = 4 // Hexadecimal numeric. + X__ISwspace = 5 // Whitespace. + X__ISwprint = 6 // Printing. + X__ISwgraph = 7 // Graphical. + X__ISwblank = 8 // Blank (usually SPC and TAB). + X__ISwcntrl = 9 // Control character. + X__ISwpunct = 10 // Punctuation. + X__ISwalnum = 11 // Alphanumeric. + + X_ISwupper = 16777216 // UPPERCASE. + X_ISwlower = 33554432 // lowercase. + X_ISwalpha = 67108864 // Alphabetic. + X_ISwdigit = 134217728 // Numeric. + X_ISwxdigit = 268435456 // Hexadecimal numeric. + X_ISwspace = 536870912 // Whitespace. + X_ISwprint = 1073741824 // Printing. + X_ISwgraph = -2147483648 // Graphical. + X_ISwblank = 65536 // Blank (usually SPC and TAB). + X_ISwcntrl = 131072 // Control character. + X_ISwpunct = 262144 // Punctuation. + X_ISwalnum = 524288 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = int32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.25 +// Wide character classification and mapping utilities + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Properties of long double type. ldbl-96 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. + +// Both x86-64 and x32 use the 64-bit system call interface. +// Bit size of the time_t type at glibc build time, x86-64 and x32 case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// For others, time size is word size. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. +// Copyright (C) 2012-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// X32 kernel interface is 64-bit. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. + +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint64 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int64 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// Some versions of stddef.h provide wint_t, even though neither the +// C nor C++ standards, nor POSIX, specifies this. We assume that +// stddef.h will define the macro _WINT_T if and only if it provides +// wint_t, and conversely, that it will avoid providing wint_t if +// _WINT_T is already defined. + +// Integral type unchanged by default argument promotions that can +// hold any value corresponding to members of the extended character +// set, as well as at least one value that does not correspond to any +// member of the extended character set. + +type Wint_t = uint32 /* wint_t.h:20:23 */ + +// Constant expression of type `wint_t' whose value does not correspond +// to any member of the extended character set. + +// Some definitions from this header also appear in in +// Unix98 mode. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.25 +// Wide character classification and mapping utilities + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// The definitions in this header are specified to appear in +// in ISO C99, but in in Unix98. _GNU_SOURCE follows C99. + +// Scalar type that can hold values which represent locale-specific +// +// character classifications. +type Wctype_t = uint64 /* wctype-wchar.h:38:27 */ + +// Extensible wide-character mapping functions: 7.15.3.2. + +// Scalar type that can hold values which represent locale-specific +// +// character mappings. +type Wctrans_t = uintptr /* wctype.h:48:25 */ + +// POSIX.1-2008 extended locale interface (see locale.h). +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +var _ int8 /* gen.c:2:13: */ diff --git a/internal/libc/wctype/wctype_linux_arm64.go b/internal/libc/wctype/wctype_linux_arm64.go new file mode 100644 index 0000000..62e2f11 --- /dev/null +++ b/internal/libc/wctype/wctype_linux_arm64.go @@ -0,0 +1,1021 @@ +// Code generated by 'ccgo wctype/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -o wctype/wctype_linux_arm64.go -pkgname wctype', DO NOT EDIT. + +package wctype + +import ( + "math" + "reflect" + "sync/atomic" + "unsafe" +) + +var _ = math.Pi +var _ reflect.Kind +var _ atomic.Value +var _ unsafe.Pointer + +const ( + WEOF = 4294967295 + X_ATFILE_SOURCE = 1 + X_BITS_ENDIANNESS_H = 1 + X_BITS_ENDIAN_H = 1 + X_BITS_TIME64_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_TYPES_LOCALE_T_H = 1 + X_BITS_TYPES___LOCALE_T_H = 1 + X_BITS_WCTYPE_WCHAR_H = 1 + X_DEFAULT_SOURCE = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_LP64 = 1 + X_POSIX_C_SOURCE = 200809 + X_POSIX_SOURCE = 1 + X_STDC_PREDEF_H = 1 + X_SYS_CDEFS_H = 1 + X_WCTYPE_H = 1 + X_WINT_T = 1 + Linux = 1 + Unix = 1 +) + +// The characteristics are stored always in network byte order (big +// endian). We define the bit value interpretations here dependent on the +// machine's byte order. + +// Endian macros for string.h functions +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definitions for byte order, according to significance of bytes, +// from low addresses to high addresses. The value is what you get by +// putting '4' in the most significant byte, '3' in the second most +// significant byte, '2' in the second least significant byte, and '1' +// in the least significant byte, and then writing down one digit for +// each byte, starting with the byte at the lowest address at the left, +// and proceeding to the byte with the highest address at the right. + +// This file defines `__BYTE_ORDER' for the particular machine. + +// AArch64 has selectable endianness. + +// Some machines may need to use a different endianness for floating point +// values. + +const ( /* wctype-wchar.h:56:1: */ + X__ISwupper = 0 // UPPERCASE. + X__ISwlower = 1 // lowercase. + X__ISwalpha = 2 // Alphabetic. + X__ISwdigit = 3 // Numeric. + X__ISwxdigit = 4 // Hexadecimal numeric. + X__ISwspace = 5 // Whitespace. + X__ISwprint = 6 // Printing. + X__ISwgraph = 7 // Graphical. + X__ISwblank = 8 // Blank (usually SPC and TAB). + X__ISwcntrl = 9 // Control character. + X__ISwpunct = 10 // Punctuation. + X__ISwalnum = 11 // Alphanumeric. + + X_ISwupper = 16777216 // UPPERCASE. + X_ISwlower = 33554432 // lowercase. + X_ISwalpha = 67108864 // Alphabetic. + X_ISwdigit = 134217728 // Numeric. + X_ISwxdigit = 268435456 // Hexadecimal numeric. + X_ISwspace = 536870912 // Whitespace. + X_ISwprint = 1073741824 // Printing. + X_ISwgraph = -2147483648 // Graphical. + X_ISwblank = 65536 // Blank (usually SPC and TAB). + X_ISwcntrl = 131072 // Control character. + X_ISwpunct = 262144 // Punctuation. + X_ISwalnum = 524288 +) + +type Ptrdiff_t = int64 /* :3:26 */ + +type Size_t = uint64 /* :9:23 */ + +type Wchar_t = uint32 /* :15:24 */ + +type X__int128_t = struct { + Flo int64 + Fhi int64 +} /* :21:43 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 +type X__uint128_t = struct { + Flo uint64 + Fhi uint64 +} /* :22:44 */ // must match github.com/hanzoai/sqlite/internal/mathutil.Int128 + +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ + +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.25 +// Wide character classification and mapping utilities + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// These are defined by the user (or the compiler) +// to specify the desired environment: +// +// __STRICT_ANSI__ ISO Standard C. +// _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. +// _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. +// _ISOC2X_SOURCE Extensions to ISO C99 from ISO C2X. +// __STDC_WANT_LIB_EXT2__ +// Extensions to ISO C99 from TR 27431-2:2010. +// __STDC_WANT_IEC_60559_BFP_EXT__ +// Extensions to ISO C11 from TS 18661-1:2014. +// __STDC_WANT_IEC_60559_FUNCS_EXT__ +// Extensions to ISO C11 from TS 18661-4:2015. +// __STDC_WANT_IEC_60559_TYPES_EXT__ +// Extensions to ISO C11 from TS 18661-3:2015. +// +// _POSIX_SOURCE IEEE Std 1003.1. +// _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; +// if >=199309L, add IEEE Std 1003.1b-1993; +// if >=199506L, add IEEE Std 1003.1c-1995; +// if >=200112L, all of IEEE 1003.1-2004 +// if >=200809L, all of IEEE 1003.1-2008 +// _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if +// Single Unix conformance is wanted, to 600 for the +// sixth revision, to 700 for the seventh revision. +// _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. +// _LARGEFILE_SOURCE Some more functions for correct standard I/O. +// _LARGEFILE64_SOURCE Additional functionality from LFS for large files. +// _FILE_OFFSET_BITS=N Select default filesystem interface. +// _ATFILE_SOURCE Additional *at interfaces. +// _GNU_SOURCE All of the above, plus GNU extensions. +// _DEFAULT_SOURCE The default set of features (taking precedence over +// __STRICT_ANSI__). +// +// _FORTIFY_SOURCE Add security hardening to many library functions. +// Set to 1 or 2; 2 performs stricter checks than 1. +// +// _REENTRANT, _THREAD_SAFE +// Obsolete; equivalent to _POSIX_C_SOURCE=199506L. +// +// The `-ansi' switch to the GNU C compiler, and standards conformance +// options such as `-std=c99', define __STRICT_ANSI__. If none of +// these are defined, or if _DEFAULT_SOURCE is defined, the default is +// to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to +// 200809L, as well as enabling miscellaneous functions from BSD and +// SVID. If more than one of these are defined, they accumulate. For +// example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together +// give you ISO C, 1003.1, and 1003.2, but nothing else. +// +// These are defined by this file and are used by the +// header files to decide what to declare or define: +// +// __GLIBC_USE (F) Define things from feature set F. This is defined +// to 1 or 0; the subsequent macros are either defined +// or undefined, and those tests should be moved to +// __GLIBC_USE. +// __USE_ISOC11 Define ISO C11 things. +// __USE_ISOC99 Define ISO C99 things. +// __USE_ISOC95 Define ISO C90 AMD1 (C95) things. +// __USE_ISOCXX11 Define ISO C++11 things. +// __USE_POSIX Define IEEE Std 1003.1 things. +// __USE_POSIX2 Define IEEE Std 1003.2 things. +// __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. +// __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. +// __USE_XOPEN Define XPG things. +// __USE_XOPEN_EXTENDED Define X/Open Unix things. +// __USE_UNIX98 Define Single Unix V2 things. +// __USE_XOPEN2K Define XPG6 things. +// __USE_XOPEN2KXSI Define XPG6 XSI things. +// __USE_XOPEN2K8 Define XPG7 things. +// __USE_XOPEN2K8XSI Define XPG7 XSI things. +// __USE_LARGEFILE Define correct standard I/O things. +// __USE_LARGEFILE64 Define LFS things with separate names. +// __USE_FILE_OFFSET64 Define 64bit interface as default. +// __USE_MISC Define things from 4.3BSD or System V Unix. +// __USE_ATFILE Define *at interfaces and AT_* constants for them. +// __USE_GNU Define GNU extensions. +// __USE_FORTIFY_LEVEL Additional security measures used, according to level. +// +// The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are +// defined by this file unconditionally. `__GNU_LIBRARY__' is provided +// only for compatibility. All new code should use the other symbols +// to test for features. +// +// All macros listed above as possibly being defined by this file are +// explicitly undefined if they are not explicitly defined. +// Feature-test macros that are not defined by the user or compiler +// but are implied by the other feature-test macros defined (or by the +// lack of any definitions) are defined by the file. +// +// ISO C feature test macros depend on the definition of the macro +// when an affected header is included, not when the first system +// header is included, and so they are handled in +// , which does not have a multiple include +// guard. Feature test macros that can be handled from the first +// system header included are handled here. + +// Undefine everything, so we get a clean slate. + +// Suppress kernel-name space pollution unless user expressedly asks +// for it. + +// Convenience macro to test the version of gcc. +// Use like this: +// #if __GNUC_PREREQ (2,8) +// ... code requiring gcc 2.8 or later ... +// #endif +// Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was +// added in 2.0. + +// Similarly for clang. Features added to GCC after version 4.2 may +// or may not also be available in clang, and clang's definitions of +// __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such +// features can be queried via __has_extension/__has_feature. + +// Whether to use feature set F. + +// _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for +// _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not +// issue a warning; the expectation is that the source is being +// transitioned to use the new macro. + +// If _GNU_SOURCE was defined by the user, turn on all the other features. + +// If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, +// define _DEFAULT_SOURCE. + +// This is to enable the ISO C2X extension. + +// This is to enable the ISO C11 extension. + +// This is to enable the ISO C99 extension. + +// This is to enable the ISO C90 Amendment 1:1995 extension. + +// If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE +// is defined, use POSIX.1-2008 (or another version depending on +// _XOPEN_SOURCE). + +// Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be +// defined in all multithreaded code. GNU libc has not required this +// for many years. We now treat them as compatibility synonyms for +// _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with +// comprehensive support for multithreaded code. Using them never +// lowers the selected level of POSIX conformance, only raises it. + +// The function 'gets' existed in C89, but is impossible to use +// safely. It has been removed from ISO C11 and ISO C++14. Note: for +// compatibility with various implementations of , this test +// must consider only the value of __cplusplus when compiling C++. + +// GNU formerly extended the scanf functions with modified format +// specifiers %as, %aS, and %a[...] that allocate a buffer for the +// input using malloc. This extension conflicts with ISO C99, which +// defines %a as a standalone format specifier that reads a floating- +// point number; moreover, POSIX.1-2008 provides the same feature +// using the modifier letter 'm' instead (%ms, %mS, %m[...]). +// +// We now follow C99 unless GNU extensions are active and the compiler +// is specifically in C89 or C++98 mode (strict or not). For +// instance, with GCC, -std=gnu11 will have C99-compliant scanf with +// or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the +// old extension. + +// Get definitions of __STDC_* predefined macros, if the compiler has +// not preincluded this header automatically. +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This macro indicates that the installed library is the GNU C Library. +// For historic reasons the value now is 6 and this will stay from now +// on. The use of this variable is deprecated. Use __GLIBC__ and +// __GLIBC_MINOR__ now (see below) when you want to test for a specific +// GNU C library version and use the values in to get +// the sonames of the shared libraries. + +// Major and minor version number of the GNU C library package. Use +// these macros to test for features in specific releases. + +// This is here only because every header file already includes this one. +// Copyright (C) 1992-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// We are almost always included from features.h. + +// The GNU libc does not support any K&R compilers or the traditional mode +// of ISO C compilers anymore. Check for some of the combinations not +// anymore supported. + +// Some user header file might have defined this before. + +// All functions, except those with callbacks or those that +// synchronize memory, are leaf functions. + +// GCC can always grok prototypes. For C++ programs we add throw() +// to help it optimize the function calls. But this works only with +// gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions +// as non-throwing using a function attribute since programs can use +// the -fexceptions options for C code as well. + +// Compilers that are not clang may object to +// #if defined __clang__ && __has_extension(...) +// even though they do not need to evaluate the right-hand side of the &&. + +// These two macros are not used in glibc anymore. They are kept here +// only because some other projects expect the macros to be defined. + +// For these things, GCC behaves the ANSI way normally, +// and the non-ANSI way under -traditional. + +// This is not a typedef so `const __ptr_t' does the right thing. + +// C++ needs to know that types and declarations are C, not C++. + +// Fortify support. + +// Support for flexible arrays. +// Headers that should use flexible arrays only if they're "real" +// (e.g. only if they won't affect sizeof()) should test +// #if __glibc_c99_flexarr_available. + +// __asm__ ("xyz") is used throughout the headers to rename functions +// at the assembly language level. This is wrapped by the __REDIRECT +// macro, in order to support compilers that can do this some other +// way. When compilers don't support asm-names at all, we have to do +// preprocessor tricks instead (which don't have exactly the right +// semantics, but it's the best we can do). +// +// Example: +// int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); + +// +// #elif __SOME_OTHER_COMPILER__ +// +// # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) + +// GCC has various useful declarations that can be made with the +// `__attribute__' syntax. All of the ways we use this do fine if +// they are omitted for compilers that don't understand it. + +// At some point during the gcc 2.96 development the `malloc' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Tell the compiler which arguments to an allocation function +// indicate the size of the allocation. + +// At some point during the gcc 2.96 development the `pure' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// This declaration tells the compiler that the value is constant. + +// At some point during the gcc 3.1 development the `used' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. + +// Since version 3.2, gcc allows marking deprecated functions. + +// Since version 4.5, gcc also allows one to specify the message printed +// when a deprecated function is used. clang claims to be gcc 4.2, but +// may also support this feature. + +// At some point during the gcc 2.8 development the `format_arg' attribute +// for functions was introduced. We don't want to use it unconditionally +// (although this would be possible) since it generates warnings. +// If several `format_arg' attributes are given for the same function, in +// gcc-3.0 and older, all but the last one are ignored. In newer gccs, +// all designated arguments are considered. + +// At some point during the gcc 2.97 development the `strfmon' format +// attribute for functions was introduced. We don't want to use it +// unconditionally (although this would be possible) since it +// generates warnings. + +// The nonull function attribute allows to mark pointer parameters which +// must not be NULL. + +// If fortification mode, we warn about unused results of certain +// function calls which can lead to problems. + +// Forces a function to be always inlined. +// The Linux kernel defines __always_inline in stddef.h (283d7573), and +// it conflicts with this definition. Therefore undefine it first to +// allow either header to be included first. + +// Associate error messages with the source location of the call site rather +// than with the source location inside the function. + +// GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 +// inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ +// or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions +// older than 4.3 may define these macros and still not guarantee GNU inlining +// semantics. +// +// clang++ identifies itself as gcc-4.2, but has support for GNU inlining +// semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and +// __GNUC_GNU_INLINE__ macro definitions. + +// GCC 4.3 and above allow passing all anonymous arguments of an +// __extern_always_inline function to some other vararg function. + +// It is possible to compile containing GCC extensions even if GCC is +// run in pedantic mode if the uses are carefully marked using the +// `__extension__' keyword. But this is not generally available before +// version 2.8. + +// __restrict is known in EGCS 1.2 and above. + +// ISO C99 also allows to declare arrays as non-overlapping. The syntax is +// array_name[restrict] +// GCC 3.1 supports this. + +// Describes a char array whose address can safely be passed as the first +// argument to strncpy and strncat, as the char array is not necessarily +// a NUL-terminated string. + +// Undefine (also defined in libc-symbols.h). +// Copies attributes from the declaration or type referenced by +// the argument. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Properties of long double type. ldbl-128 version. +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// long double is distinct from double, so there is nothing to +// define here. + +// __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is +// intended for use in preprocessor macros. +// +// Note: MESSAGE must be a _single_ string; concatenation of string +// literals is not supported. + +// Generic selection (ISO C11) is a C-only feature, available in GCC +// since version 4.9. Previous versions do not provide generic +// selection, even though they might set __STDC_VERSION__ to 201112L, +// when in -std=c11 mode. Thus, we must check for !defined __GNUC__ +// when testing __STDC_VERSION__ for generic selection support. +// On the other hand, Clang also defines __GNUC__, so a clang-specific +// check is required to enable the use of generic selection. + +// If we don't have __REDIRECT, prototypes will be missing if +// __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. + +// Decide whether we can define 'extern inline' functions in headers. + +// This is here only because every header file already includes this one. +// Get the definitions of all the appropriate `__stub_FUNCTION' symbols. +// contains `#define __stub_FUNCTION' when FUNCTION is a stub +// that will always return failure (and set errno to ENOSYS). +// This file is automatically generated. +// This file selects the right generated file of `__stub_FUNCTION' macros +// based on the architecture being compiled for. + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// This file is automatically generated. +// It defines a symbol `__stub_FUNCTION' for each function +// in the C library which is a stub, meaning it will fail +// every time called, usually setting errno to ENOSYS. + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// Copyright (C) 1991-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Bit size of the time_t type at glibc build time, general case. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Determine the wordsize from the preprocessor defines. +// +// Copyright (C) 2016-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Size in bits of the 'time_t' type of the default ABI. + +// Convenience types. +type X__u_char = uint8 /* types.h:31:23 */ +type X__u_short = uint16 /* types.h:32:28 */ +type X__u_int = uint32 /* types.h:33:22 */ +type X__u_long = uint64 /* types.h:34:27 */ + +// Fixed-size types, underlying types depend on word size and compiler. +type X__int8_t = int8 /* types.h:37:21 */ +type X__uint8_t = uint8 /* types.h:38:23 */ +type X__int16_t = int16 /* types.h:39:26 */ +type X__uint16_t = uint16 /* types.h:40:28 */ +type X__int32_t = int32 /* types.h:41:20 */ +type X__uint32_t = uint32 /* types.h:42:22 */ +type X__int64_t = int64 /* types.h:44:25 */ +type X__uint64_t = uint64 /* types.h:45:27 */ + +// Smallest types with at least a given width. +type X__int_least8_t = X__int8_t /* types.h:52:18 */ +type X__uint_least8_t = X__uint8_t /* types.h:53:19 */ +type X__int_least16_t = X__int16_t /* types.h:54:19 */ +type X__uint_least16_t = X__uint16_t /* types.h:55:20 */ +type X__int_least32_t = X__int32_t /* types.h:56:19 */ +type X__uint_least32_t = X__uint32_t /* types.h:57:20 */ +type X__int_least64_t = X__int64_t /* types.h:58:19 */ +type X__uint_least64_t = X__uint64_t /* types.h:59:20 */ + +// quad_t is also 64 bits. +type X__quad_t = int64 /* types.h:63:18 */ +type X__u_quad_t = uint64 /* types.h:64:27 */ + +// Largest integral types. +type X__intmax_t = int64 /* types.h:72:18 */ +type X__uintmax_t = uint64 /* types.h:73:27 */ + +// The machine-dependent file defines __*_T_TYPE +// macros for each of the OS types we define below. The definitions +// of those macros must use the following macros for underlying types. +// We define __S_TYPE and __U_TYPE for the signed and unsigned +// variants of each of the following integer types on this machine. +// +// 16 -- "natural" 16-bit type (always short) +// 32 -- "natural" 32-bit type (always int) +// 64 -- "natural" 64-bit type (long or long long) +// LONG32 -- 32-bit type, traditionally long +// QUAD -- 64-bit type, traditionally long long +// WORD -- natural type of __WORDSIZE bits (int or long) +// LONGWORD -- type of __WORDSIZE bits, traditionally long +// +// We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the +// conventional uses of `long' or `long long' type modifiers match the +// types we define, even when a less-adorned type would be the same size. +// This matters for (somewhat) portably writing printf/scanf formats for +// these types, where using the appropriate l or ll format modifiers can +// make the typedefs and the formats match up across all GNU platforms. If +// we used `long' when it's 64 bits where `long long' is expected, then the +// compiler would warn about the formats not matching the argument types, +// and the programmer changing them to shut up the compiler would break the +// program's portability. +// +// Here we assume what is presently the case in all the GCC configurations +// we support: long long is always 64 bits, long is always word/address size, +// and int is always 32 bits. + +// No need to mark the typedef with __extension__. +// bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI. +// Copyright (C) 2011-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Chris Metcalf , 2011. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library. If not, see +// . + +// See for the meaning of these macros. This file exists so +// that need not vary across different GNU platforms. + +// Tell the libc code that off_t and off64_t are actually the same type +// for all ABI purposes, even if possibly expressed as different base types +// for C type-checking purposes. + +// Same for ino_t and ino64_t. + +// And for __rlim_t and __rlim64_t. + +// And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. +// Number of descriptors that can fit in an `fd_set'. + +// bits/time64.h -- underlying types for __time64_t. Generic version. +// Copyright (C) 2018-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Define __TIME64_T_TYPE so that it is always a 64-bit type. + +// If we already have 64-bit time type then use it. + +type X__dev_t = uint64 /* types.h:145:25 */ // Type of device numbers. +type X__uid_t = uint32 /* types.h:146:25 */ // Type of user identifications. +type X__gid_t = uint32 /* types.h:147:25 */ // Type of group identifications. +type X__ino_t = uint64 /* types.h:148:25 */ // Type of file serial numbers. +type X__ino64_t = uint64 /* types.h:149:27 */ // Type of file serial numbers (LFS). +type X__mode_t = uint32 /* types.h:150:26 */ // Type of file attribute bitmasks. +type X__nlink_t = uint32 /* types.h:151:27 */ // Type of file link counts. +type X__off_t = int64 /* types.h:152:25 */ // Type of file sizes and offsets. +type X__off64_t = int64 /* types.h:153:27 */ // Type of file sizes and offsets (LFS). +type X__pid_t = int32 /* types.h:154:25 */ // Type of process identifications. +type X__fsid_t = struct{ F__val [2]int32 } /* types.h:155:26 */ // Type of file system IDs. +type X__clock_t = int64 /* types.h:156:27 */ // Type of CPU usage counts. +type X__rlim_t = uint64 /* types.h:157:26 */ // Type for resource measurement. +type X__rlim64_t = uint64 /* types.h:158:28 */ // Type for resource measurement (LFS). +type X__id_t = uint32 /* types.h:159:24 */ // General type for IDs. +type X__time_t = int64 /* types.h:160:26 */ // Seconds since the Epoch. +type X__useconds_t = uint32 /* types.h:161:30 */ // Count of microseconds. +type X__suseconds_t = int64 /* types.h:162:31 */ // Signed count of microseconds. + +type X__daddr_t = int32 /* types.h:164:27 */ // The type of a disk address. +type X__key_t = int32 /* types.h:165:25 */ // Type of an IPC key. + +// Clock ID used in clock and timer functions. +type X__clockid_t = int32 /* types.h:168:29 */ + +// Timer ID returned by `timer_create'. +type X__timer_t = uintptr /* types.h:171:12 */ + +// Type to represent block size. +type X__blksize_t = int32 /* types.h:174:29 */ + +// Types from the Large File Support interface. + +// Type to count number of disk blocks. +type X__blkcnt_t = int64 /* types.h:179:28 */ +type X__blkcnt64_t = int64 /* types.h:180:30 */ + +// Type to count file system blocks. +type X__fsblkcnt_t = uint64 /* types.h:183:30 */ +type X__fsblkcnt64_t = uint64 /* types.h:184:32 */ + +// Type to count file system nodes. +type X__fsfilcnt_t = uint64 /* types.h:187:30 */ +type X__fsfilcnt64_t = uint64 /* types.h:188:32 */ + +// Type of miscellaneous file system fields. +type X__fsword_t = int64 /* types.h:191:28 */ + +type X__ssize_t = int64 /* types.h:193:27 */ // Type of a byte count, or error. + +// Signed long type used in system calls. +type X__syscall_slong_t = int64 /* types.h:196:33 */ +// Unsigned long type used in system calls. +type X__syscall_ulong_t = uint64 /* types.h:198:33 */ + +// These few don't really vary by system, they always correspond +// +// to one of the other defined types. +type X__loff_t = X__off64_t /* types.h:202:19 */ // Type of file sizes and offsets (LFS). +type X__caddr_t = uintptr /* types.h:203:14 */ + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__intptr_t = int64 /* types.h:206:25 */ + +// Duplicate info from sys/socket.h. +type X__socklen_t = uint32 /* types.h:209:23 */ + +// C99: An integer type that can be accessed as an atomic entity, +// +// even in the presence of asynchronous interrupts. +// It is not currently necessary for this to be machine-specific. +type X__sig_atomic_t = int32 /* types.h:214:13 */ + +// Seconds since the Epoch, visible to user code when time_t is too +// narrow only for consistency with the old way of widening too-narrow +// types. User code should never use __time64_t. + +// Some versions of stddef.h provide wint_t, even though neither the +// C nor C++ standards, nor POSIX, specifies this. We assume that +// stddef.h will define the macro _WINT_T if and only if it provides +// wint_t, and conversely, that it will avoid providing wint_t if +// _WINT_T is already defined. + +// Integral type unchanged by default argument promotions that can +// hold any value corresponding to members of the extended character +// set, as well as at least one value that does not correspond to any +// member of the extended character set. + +type Wint_t = uint32 /* wint_t.h:20:23 */ + +// Constant expression of type `wint_t' whose value does not correspond +// to any member of the extended character set. + +// Some definitions from this header also appear in in +// Unix98 mode. +// Copyright (C) 1996-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// ISO C99 Standard: 7.25 +// Wide character classification and mapping utilities + +// bits/types.h -- definitions of __*_t types underlying *_t types. +// Copyright (C) 2002-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Never include this file directly; use instead. + +// The definitions in this header are specified to appear in +// in ISO C99, but in in Unix98. _GNU_SOURCE follows C99. + +// Scalar type that can hold values which represent locale-specific +// +// character classifications. +type Wctype_t = uint64 /* wctype-wchar.h:38:27 */ + +// Extensible wide-character mapping functions: 7.15.3.2. + +// Scalar type that can hold values which represent locale-specific +// +// character mappings. +type Wctrans_t = uintptr /* wctype.h:48:25 */ + +// POSIX.1-2008 extended locale interface (see locale.h). +// Definition of locale_t. +// Copyright (C) 2017-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// Definition of struct __locale_struct and __locale_t. +// Copyright (C) 1997-2020 Free Software Foundation, Inc. +// This file is part of the GNU C Library. +// Contributed by Ulrich Drepper , 1997. +// +// The GNU C Library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// The GNU C Library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with the GNU C Library; if not, see +// . + +// POSIX.1-2008: the locale_t type, representing a locale context +// (implementation-namespace version). This type should be treated +// as opaque by applications; some details are exposed for the sake of +// efficiency in e.g. ctype functions. + +type X__locale_struct = struct { + F__locales [13]uintptr + F__ctype_b uintptr + F__ctype_tolower uintptr + F__ctype_toupper uintptr + F__names [13]uintptr +} /* __locale_t.h:28:1 */ + +type X__locale_t = uintptr /* __locale_t.h:42:32 */ + +type Locale_t = X__locale_t /* locale_t.h:24:20 */ + +var _ uint8 /* gen.c:2:13: */ diff --git a/internal/mathutil/LICENSE b/internal/mathutil/LICENSE new file mode 100644 index 0000000..128a1b6 --- /dev/null +++ b/internal/mathutil/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The mathutil Authors. 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 names of the authors nor the names of the +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. diff --git a/internal/mathutil/binarylog.go b/internal/mathutil/binarylog.go new file mode 100644 index 0000000..74041cb --- /dev/null +++ b/internal/mathutil/binarylog.go @@ -0,0 +1,80 @@ +// Copyright (c) 2016 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "math/big" +) + +type float struct { + n *big.Int + fracBits int + maxFracBits int +} + +func newFloat(n *big.Int, fracBits, maxFracBits int) float { + f := float{n: n, fracBits: fracBits, maxFracBits: maxFracBits} + f.normalize() + return f +} + +func (f *float) normalize() { + n := f.n.BitLen() + if n == 0 { + return + } + + if n := f.fracBits - f.maxFracBits; n > 0 { + bit := f.n.Bit(n - 1) + f.n.Rsh(f.n, uint(n)) + if bit != 0 { + f.n.Add(f.n, _1) + } + f.fracBits -= n + } + + var i int + for ; f.fracBits > 0 && i <= f.fracBits && f.n.Bit(i) == 0; i++ { + f.fracBits-- + } + + if i != 0 { + f.n.Rsh(f.n, uint(i)) + } +} + +func (f *float) eq1() bool { return f.fracBits == 0 && f.n.BitLen() == 1 } +func (f *float) ge2() bool { return f.n.BitLen() > f.fracBits+1 } + +func (f *float) div2() { + f.fracBits++ + f.normalize() +} + +// BinaryLog computes the binary logarithm of n. The result consists of a +// characteristic and a mantissa having precision mantissaBits. The value of +// the binary logarithm is +// +// characteristic + mantissa*(2^-mantissaBits) +// +// BinaryLog panics for n <= 0 or mantissaBits < 0. +func BinaryLog(n *big.Int, mantissaBits int) (characteristic int, mantissa *big.Int) { + if n.Sign() <= 0 || mantissaBits < 0 { + panic("invalid argument of BinaryLog") + } + + characteristic = n.BitLen() - 1 + mantissa = big.NewInt(0) + x := newFloat(n, characteristic, mantissaBits) + for ; mantissaBits != 0 && !x.eq1(); mantissaBits-- { + x.sqr() + mantissa.Lsh(mantissa, 1) + if x.ge2() { + mantissa.SetBit(mantissa, 0, 1) + x.div2() + } + } + return characteristic, mantissa +} diff --git a/internal/mathutil/bits.go b/internal/mathutil/bits.go new file mode 100644 index 0000000..fc0ab6c --- /dev/null +++ b/internal/mathutil/bits.go @@ -0,0 +1,207 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "math/big" +) + +// BitLenByte returns the bit width of the non zero part of n. +func BitLenByte(n byte) int { + return log2[n] + 1 +} + +// BitLenUint16 returns the bit width of the non zero part of n. +func BitLenUint16(n uint16) int { + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// BitLenUint32 returns the bit width of the non zero part of n. +func BitLenUint32(n uint32) int { + if b := n >> 24; b != 0 { + return log2[b] + 24 + 1 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + 1 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// BitLen returns the bit width of the non zero part of n. +func BitLen(n int) int { // Should handle correctly [future] 64 bit Go ints + if IntBits == 64 { + return BitLenUint64(uint64(n)) + } + + if b := byte(n >> 24); b != 0 { + return log2[b] + 24 + 1 + } + + if b := byte(n >> 16); b != 0 { + return log2[b] + 16 + 1 + } + + if b := byte(n >> 8); b != 0 { + return log2[b] + 8 + 1 + } + + return log2[byte(n)] + 1 +} + +// BitLenUint returns the bit width of the non zero part of n. +func BitLenUint(n uint) int { // Should handle correctly [future] 64 bit Go uints + if IntBits == 64 { + return BitLenUint64(uint64(n)) + } + + if b := n >> 24; b != 0 { + return log2[b] + 24 + 1 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + 1 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// BitLenUint64 returns the bit width of the non zero part of n. +func BitLenUint64(n uint64) int { + if b := n >> 56; b != 0 { + return log2[b] + 56 + 1 + } + + if b := n >> 48; b != 0 { + return log2[b] + 48 + 1 + } + + if b := n >> 40; b != 0 { + return log2[b] + 40 + 1 + } + + if b := n >> 32; b != 0 { + return log2[b] + 32 + 1 + } + + if b := n >> 24; b != 0 { + return log2[b] + 24 + 1 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + 1 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// BitLenUintptr returns the bit width of the non zero part of n. +func BitLenUintptr(n uintptr) int { + if b := n >> 56; b != 0 { + return log2[b] + 56 + 1 + } + + if b := n >> 48; b != 0 { + return log2[b] + 48 + 1 + } + + if b := n >> 40; b != 0 { + return log2[b] + 40 + 1 + } + + if b := n >> 32; b != 0 { + return log2[b] + 32 + 1 + } + + if b := n >> 24; b != 0 { + return log2[b] + 24 + 1 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + 1 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// PopCountByte returns population count of n (number of bits set in n). +func PopCountByte(n byte) int { + return int(popcnt[n]) +} + +// PopCountUint16 returns population count of n (number of bits set in n). +func PopCountUint16(n uint16) int { + return int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) +} + +// PopCountUint32 returns population count of n (number of bits set in n). +func PopCountUint32(n uint32) int { + return int(popcnt[byte(n>>24)]) + int(popcnt[byte(n>>16)]) + + int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) +} + +// PopCount returns population count of n (number of bits set in n). +func PopCount(n int) int { // Should handle correctly [future] 64 bit Go ints + if IntBits == 64 { + return PopCountUint64(uint64(n)) + } + + return PopCountUint32(uint32(n)) +} + +// PopCountUint returns population count of n (number of bits set in n). +func PopCountUint(n uint) int { // Should handle correctly [future] 64 bit Go uints + if IntBits == 64 { + return PopCountUint64(uint64(n)) + } + + return PopCountUint32(uint32(n)) +} + +// PopCountUintptr returns population count of n (number of bits set in n). +func PopCountUintptr(n uintptr) int { + if UintPtrBits == 64 { + return PopCountUint64(uint64(n)) + } + + return PopCountUint32(uint32(n)) +} + +// PopCountUint64 returns population count of n (number of bits set in n). +func PopCountUint64(n uint64) int { + return int(popcnt[byte(n>>56)]) + int(popcnt[byte(n>>48)]) + + int(popcnt[byte(n>>40)]) + int(popcnt[byte(n>>32)]) + + int(popcnt[byte(n>>24)]) + int(popcnt[byte(n>>16)]) + + int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) +} + +// PopCountBigInt returns population count of |n| (number of bits set in |n|). +func PopCountBigInt(n *big.Int) (r int) { + for _, v := range n.Bits() { + r += PopCountUintptr(uintptr(v)) + } + return +} diff --git a/internal/mathutil/envelope.go b/internal/mathutil/envelope.go new file mode 100644 index 0000000..381d622 --- /dev/null +++ b/internal/mathutil/envelope.go @@ -0,0 +1,46 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "math" +) + +// Approximation type determines approximation methods used by e.g. Envelope. +type Approximation int + +// Specific approximation method tags +const ( + _ Approximation = iota + Linear // As named + Sinusoidal // Smooth for all derivations +) + +// Envelope is an utility for defining simple curves using a small (usually) +// set of data points. Envelope returns a value defined by x, points and +// approximation. The value of x must be in [0,1) otherwise the result is +// undefined or the function may panic. Points are interpreted as dividing the +// [0,1) interval in len(points)-1 sections, so len(points) must be > 1 or the +// function may panic. According to the left and right points closing/adjacent +// to the section the resulting value is interpolated using the chosen +// approximation method. Unsupported values of approximation are silently +// interpreted as 'Linear'. +func Envelope(x float64, points []float64, approximation Approximation) float64 { + step := 1 / float64(len(points)-1) + fslot := math.Floor(x / step) + mod := x - fslot*step + slot := int(fslot) + l, r := points[slot], points[slot+1] + rmod := mod / step + switch approximation { + case Sinusoidal: + k := (math.Sin(math.Pi*(rmod-0.5)) + 1) / 2 + return l + (r-l)*k + case Linear: + fallthrough + default: + return l + (r-l)*rmod + } +} diff --git a/internal/mathutil/int.go b/internal/mathutil/int.go new file mode 100644 index 0000000..4c2e058 --- /dev/null +++ b/internal/mathutil/int.go @@ -0,0 +1,279 @@ +// Copyright (c) 2018 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "fmt" + "math" + "math/big" +) + +var ( + // MaxInt128 represents the maximun Int128 value as big.Int + MaxInt128 *big.Int + // MinInt128 represents the minimun Int128 value as big.Int + MinInt128 *big.Int + // MaxUint128 represents the maximun Uint128 value as big.Int + MaxUint128 *big.Int +) + +func init() { + var ok bool + MaxInt128, ok = big.NewInt(0).SetString("0x7fffffff_ffffffff_ffffffff_ffffffff", 0) + if !ok { + panic("internal error") + } + + MinInt128 = big.NewInt(0).Set(MaxInt128) + MinInt128.Add(MinInt128, _1) + MinInt128.Neg(MinInt128) + + MaxUint128, ok = big.NewInt(0).SetString("0xffffffff_ffffffff_ffffffff_ffffffff", 0) + if !ok { + panic("internal error") + } +} + +const ( + maxInt128 = 1<<127 - 1 + maxUint128 = 1<<128 - 1 + minInt128 = -maxInt128 - 1 +) + +// Int128 is an 128 bit signed integer. +type Int128 struct { + Lo int64 // Bits 63..0. + Hi int64 // Bits 127..64. +} + +// Add returns the sum of x and y and a carry indication. +func (x Int128) Add(y Int128) (r Int128, cy bool) { + r.Lo = x.Lo + y.Lo + r.Hi = x.Hi + y.Hi + if uint64(r.Lo) < uint64(x.Lo) { + r.Hi++ + } + return r, (r.Cmp(x) < 0) == (y.Sign() >= 0) +} + +// BigInt returns x in the form of a big.Int. +func (x Int128) BigInt() *big.Int { + r := big.NewInt(x.Hi) + r.Lsh(r, 64) + lo := big.NewInt(0) + lo.SetUint64(uint64(x.Lo)) + return r.Add(r, lo) +} + +// Cmp compares x and y and returns: +// +// -1 if x < y +// 0 if x == y +// +1 if x > y +func (x Int128) Cmp(y Int128) int { + if x.Hi > y.Hi { + return 1 + } + + if x.Hi < y.Hi { + return -1 + } + + if uint64(x.Lo) > uint64(y.Lo) { + return 1 + } + + if uint64(x.Lo) < uint64(y.Lo) { + return -1 + } + + return 0 +} + +// Neg returns -x and an indication that x was not equal to MinInt128. +func (x Int128) Neg() (r Int128, ok bool) { + if x == (Int128{Hi: math.MinInt64}) { + return x, false + } + + x.Lo = ^x.Lo + x.Hi = ^x.Hi + r, _ = x.Add(Int128{Lo: 1}) + return r, true +} + +// SetBigInt sets x to y, returns x and an error, if any. +func (x *Int128) SetBigInt(y *big.Int) (r Int128, err error) { + if y.Cmp(MaxInt128) > 0 { + return *x, fmt.Errorf("%T.SetInt: overflow", x) + } + if y.Cmp(MinInt128) < 0 { + return *x, fmt.Errorf("%T.SetInt: underflow", x) + } + neg := y.Sign() < 0 + var z big.Int + z.Set(y) + if neg { + z.Neg(&z) + } + r.Lo = z.Int64() + z.Rsh(&z, 64) + r.Hi = z.Int64() + if neg { + r, _ = r.Neg() + } + *x = r + return r, nil +} + +// SetInt64 sets x to y and returns x. +func (x *Int128) SetInt64(y int64) (r Int128) { + r.Lo = y + if y >= 0 { + r.Hi = 0 + *x = r + return r + } + + r.Hi = -1 + *x = r + return r +} + +// SetUint64 sets x to y and returns x. +func (x *Int128) SetUint64(y uint64) (r Int128) { + r = Int128{Lo: int64(y)} + *x = r + return r +} + +// Sign returns: +// +// -1 if x < 0 +// 0 if x == 0 +// +1 if x > 0 +func (x Int128) Sign() int { + if x.Hi < 0 { + return -1 + } + + if x.Hi != 0 || x.Lo != 0 { + return 1 + } + + return 0 +} + +// String implements fmt.Stringer() +func (x Int128) String() string { return x.BigInt().String() } + +// NewInt128FromInt64 return a new Int128 value initialized to n. +func NewInt128FromInt64(n int64) (r Int128) { + r.Lo = n + if n < 0 { + r.Hi = -1 + } + return r +} + +// NewInt128FromUint64 return a new Int128 value initialized to n. +func NewInt128FromUint64(n uint64) (r Int128) { return Int128{Lo: int64(n)} } + +// NewInt128FromFloat32 returns a new Int128 value initialized to n. Result is +// not specified in n does not represent a number within the range of Int128 +// values. +func NewInt128FromFloat32(n float32) (r Int128) { + if n >= minInt128 && n <= maxInt128 { + if n >= math.MinInt64 && n <= math.MaxInt64 { + return NewInt128FromInt64(int64(n)) + } + + f := big.NewFloat(float64(n)) + bi, _ := f.Int(nil) + r.SetBigInt(bi) + } + return r +} + +// NewInt128FromFloat64 returns a new Int128 value initialized to n. Result is +// not specified in n does not represent a number within the range of Int128 +// values. +func NewInt128FromFloat64(n float64) (r Int128) { + if n >= minInt128 && n <= maxInt128 { + if n >= math.MinInt64 && n <= math.MaxInt64 { + return NewInt128FromInt64(int64(n)) + } + + f := big.NewFloat(n) + bi, _ := f.Int(nil) + r.SetBigInt(bi) + } + return r +} + +// Uint128 is an 128 bit unsigned integer. +type Uint128 struct { + Lo uint64 // Bits 63..0. + Hi uint64 // Bits 127..64. +} + +// NewUint128FromInt64 return a new Uint128 value initialized to n. +func NewUint128FromInt64(n int64) (r Uint128) { + r.Lo = uint64(n) + if n < 0 { + r.Hi = ^uint64(0) + } + return r +} + +// NewUint128FromUint64 return a new Uint128 value initialized to n. +func NewUint128FromUint64(n uint64) (r Uint128) { return Uint128{Lo: n} } + +// NewUint128FromFloat32 returns a new Uint128 value initialized to n. Result is +// not specified in n does not represent a number within the range of Uint128 +// values. +func NewUint128FromFloat32(n float32) (r Uint128) { + if n >= 0 { + if n <= math.MaxUint64 { + return NewUint128FromUint64(uint64(n)) + } + + f := big.NewFloat(float64(n)) + bi, _ := f.Int(nil) + r.SetBigInt(bi) + } + return r +} + +// NewUint128FromFloat64 returns a new Uint128 value initialized to n. Result is +// not specified in n does not represent a number within the range of Uint128 +// values. +func NewUint128FromFloat64(n float64) (r Uint128) { + if n >= 0 && n <= maxUint128 { + if n <= math.MaxUint64 { + return NewUint128FromUint64(uint64(n)) + } + + f := big.NewFloat(n) + bi, _ := f.Int(nil) + r.SetBigInt(bi) + } + return r +} + +// SetBigInt sets x to y, returns x and an error, if any. +func (x *Uint128) SetBigInt(y *big.Int) (r Uint128, err error) { + if y.Sign() < 0 || y.Cmp(MaxUint128) > 0 { + return *x, fmt.Errorf("%T.SetInt: overflow", x) + } + + var z big.Int + z.Set(y) + r.Lo = z.Uint64() + z.Rsh(&z, 64) + r.Hi = z.Uint64() + *x = r + return r, nil +} diff --git a/internal/mathutil/mathutil.go b/internal/mathutil/mathutil.go new file mode 100644 index 0000000..676cf0d --- /dev/null +++ b/internal/mathutil/mathutil.go @@ -0,0 +1,1606 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package mathutil provides utilities supplementing the standard 'math' and +// 'math/rand' packages. +// +// # Release history and compatibility issues +// +// 2020-12-20 v1.2.1 fixes MulOverflowInt64. +// +// 2020-12-19 Added {Add,Sub,Mul}OverflowInt{8,16,32,64} +// +// 2018-10-21 Added BinaryLog +// +// 2018-04-25: New functions for determining Max/Min of nullable values. Ex: +// +// func MaxPtr(a, b *int) *int { +// func MinPtr(a, b *int) *int { +// func MaxBytePtr(a, b *byte) *byte { +// func MinBytePtr(a, b *byte) *byte { +// ... +// +// 2017-10-14: New variadic functions for Max/Min. Ex: +// +// func MaxVal(val int, vals ...int) int { +// func MinVal(val int, vals ...int) int { +// func MaxByteVal(val byte, vals ...byte) byte { +// func MinByteVal(val byte, vals ...byte) byte { +// ... +// +// 2016-10-10: New functions QuadPolyDiscriminant and QuadPolyFactors. +// +// 2013-12-13: The following functions have been REMOVED +// +// func Uint64ToBigInt(n uint64) *big.Int +// func Uint64FromBigInt(n *big.Int) (uint64, bool) +// +// 2013-05-13: The following functions are now DEPRECATED +// +// func Uint64ToBigInt(n uint64) *big.Int +// func Uint64FromBigInt(n *big.Int) (uint64, bool) +// +// These functions will be REMOVED with Go release 1.1+1. +// +// 2013-01-21: The following functions have been REMOVED +// +// func MaxInt() int +// func MinInt() int +// func MaxUint() uint +// func UintPtrBits() int +// +// They are now replaced by untyped constants +// +// MaxInt +// MinInt +// MaxUint +// UintPtrBits +// +// Additionally one more untyped constant was added +// +// IntBits +// +// This change breaks any existing code depending on the above removed +// functions. They should have not been published in the first place, that was +// unfortunate. Instead, defining such architecture and/or implementation +// specific integer limits and bit widths as untyped constants improves +// performance and allows for static dead code elimination if it depends on +// these values. Thanks to minux for pointing it out in the mail list +// (https://groups.google.com/d/msg/golang-nuts/tlPpLW6aJw8/NT3mpToH-a4J). +// +// 2012-12-12: The following functions will be DEPRECATED with Go release +// 1.0.3+1 and REMOVED with Go release 1.0.3+2, b/c of +// http://code.google.com/p/go/source/detail?r=954a79ee3ea8 +// +// func Uint64ToBigInt(n uint64) *big.Int +// func Uint64FromBigInt(n *big.Int) (uint64, bool) +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "math" + "math/big" +) + +// Architecture and/or implementation specific integer limits and bit widths. +const ( + MaxInt = 1<<(IntBits-1) - 1 + MinInt = -MaxInt - 1 + MaxUint = 1<>32&1 + ^uint(0)>>16&1 + ^uint(0)>>8&1 + 3) + UintPtrBits = 1 << (^uintptr(0)>>32&1 + ^uintptr(0)>>16&1 + ^uintptr(0)>>8&1 + 3) +) + +var ( + _1 = big.NewInt(1) + _2 = big.NewInt(2) +) + +// GCDByte returns the greatest common divisor of a and b. Based on: +// http://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations +func GCDByte(a, b byte) byte { + for b != 0 { + a, b = b, a%b + } + return a +} + +// GCDUint16 returns the greatest common divisor of a and b. +func GCDUint16(a, b uint16) uint16 { + for b != 0 { + a, b = b, a%b + } + return a +} + +// GCDUint32 returns the greatest common divisor of a and b. +func GCDUint32(a, b uint32) uint32 { + for b != 0 { + a, b = b, a%b + } + return a +} + +// GCDUint64 returns the greatest common divisor of a and b. +func GCDUint64(a, b uint64) uint64 { + for b != 0 { + a, b = b, a%b + } + return a +} + +// ISqrt returns floor(sqrt(n)). Typical run time is few hundreds of ns. +func ISqrt(n uint32) (x uint32) { + if n == 0 { + return + } + + if n >= math.MaxUint16*math.MaxUint16 { + return math.MaxUint16 + } + + var px, nx uint32 + for x = n; ; px, x = x, nx { + nx = (x + n/x) / 2 + if nx == x || nx == px { + break + } + } + return +} + +// SqrtUint64 returns floor(sqrt(n)). Typical run time is about 0.5 µs. +func SqrtUint64(n uint64) (x uint64) { + if n == 0 { + return + } + + if n >= math.MaxUint32*math.MaxUint32 { + return math.MaxUint32 + } + + var px, nx uint64 + for x = n; ; px, x = x, nx { + nx = (x + n/x) / 2 + if nx == x || nx == px { + break + } + } + return +} + +// SqrtBig returns floor(sqrt(n)). It panics on n < 0. +func SqrtBig(n *big.Int) (x *big.Int) { + switch n.Sign() { + case -1: + panic(-1) + case 0: + return big.NewInt(0) + } + + var px, nx big.Int + x = big.NewInt(0) + x.SetBit(x, n.BitLen()/2+1, 1) + for { + nx.Rsh(nx.Add(x, nx.Div(n, x)), 1) + if nx.Cmp(x) == 0 || nx.Cmp(&px) == 0 { + break + } + px.Set(x) + x.Set(&nx) + } + return +} + +// Log2Byte returns log base 2 of n. It's the same as index of the highest +// bit set in n. For n == 0 -1 is returned. +func Log2Byte(n byte) int { + return log2[n] +} + +// Log2Uint16 returns log base 2 of n. It's the same as index of the highest +// bit set in n. For n == 0 -1 is returned. +func Log2Uint16(n uint16) int { + if b := n >> 8; b != 0 { + return log2[b] + 8 + } + + return log2[n] +} + +// Log2Uint32 returns log base 2 of n. It's the same as index of the highest +// bit set in n. For n == 0 -1 is returned. +func Log2Uint32(n uint32) int { + if b := n >> 24; b != 0 { + return log2[b] + 24 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + } + + return log2[n] +} + +// Log2Uint64 returns log base 2 of n. It's the same as index of the highest +// bit set in n. For n == 0 -1 is returned. +func Log2Uint64(n uint64) int { + if b := n >> 56; b != 0 { + return log2[b] + 56 + } + + if b := n >> 48; b != 0 { + return log2[b] + 48 + } + + if b := n >> 40; b != 0 { + return log2[b] + 40 + } + + if b := n >> 32; b != 0 { + return log2[b] + 32 + } + + if b := n >> 24; b != 0 { + return log2[b] + 24 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + } + + return log2[n] +} + +// ModPowByte computes (b^e)%m. It panics for m == 0 || b == e == 0. +// +// See also: http://en.wikipedia.org/wiki/Modular_exponentiation#Right-to-left_binary_method +func ModPowByte(b, e, m byte) byte { + if b == 0 && e == 0 { + panic(0) + } + + if m == 1 { + return 0 + } + + r := uint16(1) + for b, m := uint16(b), uint16(m); e > 0; b, e = b*b%m, e>>1 { + if e&1 == 1 { + r = r * b % m + } + } + return byte(r) +} + +// ModPowUint16 computes (b^e)%m. It panics for m == 0 || b == e == 0. +func ModPowUint16(b, e, m uint16) uint16 { + if b == 0 && e == 0 { + panic(0) + } + + if m == 1 { + return 0 + } + + r := uint32(1) + for b, m := uint32(b), uint32(m); e > 0; b, e = b*b%m, e>>1 { + if e&1 == 1 { + r = r * b % m + } + } + return uint16(r) +} + +// ModPowUint32 computes (b^e)%m. It panics for m == 0 || b == e == 0. +func ModPowUint32(b, e, m uint32) uint32 { + if b == 0 && e == 0 { + panic(0) + } + + if m == 1 { + return 0 + } + + r := uint64(1) + for b, m := uint64(b), uint64(m); e > 0; b, e = b*b%m, e>>1 { + if e&1 == 1 { + r = r * b % m + } + } + return uint32(r) +} + +// ModPowUint64 computes (b^e)%m. It panics for m == 0 || b == e == 0. +func ModPowUint64(b, e, m uint64) (r uint64) { + if b == 0 && e == 0 { + panic(0) + } + + if m == 1 { + return 0 + } + + return modPowBigInt(big.NewInt(0).SetUint64(b), big.NewInt(0).SetUint64(e), big.NewInt(0).SetUint64(m)).Uint64() +} + +func modPowBigInt(b, e, m *big.Int) (r *big.Int) { + r = big.NewInt(1) + for i, n := 0, e.BitLen(); i < n; i++ { + if e.Bit(i) != 0 { + r.Mod(r.Mul(r, b), m) + } + b.Mod(b.Mul(b, b), m) + } + return +} + +// ModPowBigInt computes (b^e)%m. Returns nil for e < 0. It panics for m == 0 || b == e == 0. +func ModPowBigInt(b, e, m *big.Int) (r *big.Int) { + if b.Sign() == 0 && e.Sign() == 0 { + panic(0) + } + + if m.Cmp(_1) == 0 { + return big.NewInt(0) + } + + if e.Sign() < 0 { + return + } + + return modPowBigInt(big.NewInt(0).Set(b), big.NewInt(0).Set(e), m) +} + +var uint64ToBigIntDelta big.Int + +func init() { + uint64ToBigIntDelta.SetBit(&uint64ToBigIntDelta, 63, 1) +} + +var uintptrBits int + +func init() { + x := uint64(math.MaxUint64) + uintptrBits = BitLenUintptr(uintptr(x)) +} + +// UintptrBits returns the bit width of an uintptr at the executing machine. +func UintptrBits() int { + return uintptrBits +} + +// AddUint128_64 returns the uint128 sum of uint64 a and b. +func AddUint128_64(a, b uint64) (hi uint64, lo uint64) { + lo = a + b + if lo < a { + hi = 1 + } + return hi, lo +} + +// MulUint128_64 returns the uint128 bit product of uint64 a and b. +func MulUint128_64(a, b uint64) (hi, lo uint64) { + /* + 2^(2 W) ahi bhi + 2^W alo bhi + 2^W ahi blo + alo blo + + FEDCBA98 76543210 FEDCBA98 76543210 + ---- alo*blo ---- + ---- alo*bhi ---- + ---- ahi*blo ---- + ---- ahi*bhi ---- + */ + const w = 32 + const m = 1<>w, b>>w, a&m, b&m + lo = alo * blo + mid1 := alo * bhi + mid2 := ahi * blo + c1, lo := AddUint128_64(lo, mid1<>w+mid2>>w+c1+c2) + return +} + +// PowerizeBigInt returns (e, p) such that e is the smallest number for which p +// == b^e is greater or equal n. For n < 0 or b < 2 (0, nil) is returned. +// +// NOTE: Run time for large values of n (above about 2^1e6 ~= 1e300000) can be +// significant and/or unacceptabe. For any smaller values of n the function +// typically performs in sub second time. For "small" values of n (cca bellow +// 2^1e3 ~= 1e300) the same can be easily below 10 µs. +// +// A special (and trivial) case of b == 2 is handled separately and performs +// much faster. +func PowerizeBigInt(b, n *big.Int) (e uint32, p *big.Int) { + switch { + case b.Cmp(_2) < 0 || n.Sign() < 0: + return + case n.Sign() == 0 || n.Cmp(_1) == 0: + return 0, big.NewInt(1) + case b.Cmp(_2) == 0: + p = big.NewInt(0) + e = uint32(n.BitLen() - 1) + p.SetBit(p, int(e), 1) + if p.Cmp(n) < 0 { + p.Mul(p, _2) + e++ + } + return + } + + bw := b.BitLen() + nw := n.BitLen() + p = big.NewInt(1) + var bb, r big.Int + for { + switch p.Cmp(n) { + case -1: + x := uint32((nw - p.BitLen()) / bw) + if x == 0 { + x = 1 + } + e += x + switch x { + case 1: + p.Mul(p, b) + default: + r.Set(_1) + bb.Set(b) + e := x + for { + if e&1 != 0 { + r.Mul(&r, &bb) + } + if e >>= 1; e == 0 { + break + } + + bb.Mul(&bb, &bb) + } + p.Mul(p, &r) + } + case 0, 1: + return + } + } +} + +// PowerizeUint32BigInt returns (e, p) such that e is the smallest number for +// which p == b^e is greater or equal n. For n < 0 or b < 2 (0, nil) is +// returned. +// +// More info: see PowerizeBigInt. +func PowerizeUint32BigInt(b uint32, n *big.Int) (e uint32, p *big.Int) { + switch { + case b < 2 || n.Sign() < 0: + return + case n.Sign() == 0 || n.Cmp(_1) == 0: + return 0, big.NewInt(1) + case b == 2: + p = big.NewInt(0) + e = uint32(n.BitLen() - 1) + p.SetBit(p, int(e), 1) + if p.Cmp(n) < 0 { + p.Mul(p, _2) + e++ + } + return + } + + var bb big.Int + bb.SetInt64(int64(b)) + return PowerizeBigInt(&bb, n) +} + +/* +ProbablyPrimeUint32 returns true if n is prime or n is a pseudoprime to base a. +It implements the Miller-Rabin primality test for one specific value of 'a' and +k == 1. + +Wrt pseudocode shown at +http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Algorithm_and_running_time + + Input: n > 3, an odd integer to be tested for primality; + Input: k, a parameter that determines the accuracy of the test + Output: composite if n is composite, otherwise probably prime + write n − 1 as 2^s·d with d odd by factoring powers of 2 from n − 1 + LOOP: repeat k times: + pick a random integer a in the range [2, n − 2] + x ← a^d mod n + if x = 1 or x = n − 1 then do next LOOP + for r = 1 .. s − 1 + x ← x^2 mod n + if x = 1 then return composite + if x = n − 1 then do next LOOP + return composite + return probably prime + +... this function behaves like passing 1 for 'k' and additionally a +fixed/non-random 'a'. Otherwise it's the same algorithm. + +See also: http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html +*/ +func ProbablyPrimeUint32(n, a uint32) bool { + d, s := n-1, 0 + for ; d&1 == 0; d, s = d>>1, s+1 { + } + x := uint64(ModPowUint32(a, d, n)) + if x == 1 || uint32(x) == n-1 { + return true + } + + for ; s > 1; s-- { + if x = x * x % uint64(n); x == 1 { + return false + } + + if uint32(x) == n-1 { + return true + } + } + return false +} + +// ProbablyPrimeUint64_32 returns true if n is prime or n is a pseudoprime to +// base a. It implements the Miller-Rabin primality test for one specific value +// of 'a' and k == 1. See also ProbablyPrimeUint32. +func ProbablyPrimeUint64_32(n uint64, a uint32) bool { + d, s := n-1, 0 + for ; d&1 == 0; d, s = d>>1, s+1 { + } + x := ModPowUint64(uint64(a), d, n) + if x == 1 || x == n-1 { + return true + } + + bx, bn := big.NewInt(0).SetUint64(x), big.NewInt(0).SetUint64(n) + for ; s > 1; s-- { + if x = bx.Mod(bx.Mul(bx, bx), bn).Uint64(); x == 1 { + return false + } + + if x == n-1 { + return true + } + } + return false +} + +// ProbablyPrimeBigInt_32 returns true if n is prime or n is a pseudoprime to +// base a. It implements the Miller-Rabin primality test for one specific value +// of 'a' and k == 1. See also ProbablyPrimeUint32. +func ProbablyPrimeBigInt_32(n *big.Int, a uint32) bool { + var d big.Int + d.Set(n) + d.Sub(&d, _1) // d <- n-1 + s := 0 + for ; d.Bit(s) == 0; s++ { + } + nMinus1 := big.NewInt(0).Set(&d) + d.Rsh(&d, uint(s)) + + x := ModPowBigInt(big.NewInt(int64(a)), &d, n) + if x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 { + return true + } + + for ; s > 1; s-- { + if x = x.Mod(x.Mul(x, x), n); x.Cmp(_1) == 0 { + return false + } + + if x.Cmp(nMinus1) == 0 { + return true + } + } + return false +} + +// ProbablyPrimeBigInt returns true if n is prime or n is a pseudoprime to base +// a. It implements the Miller-Rabin primality test for one specific value of +// 'a' and k == 1. See also ProbablyPrimeUint32. +func ProbablyPrimeBigInt(n, a *big.Int) bool { + var d big.Int + d.Set(n) + d.Sub(&d, _1) // d <- n-1 + s := 0 + for ; d.Bit(s) == 0; s++ { + } + nMinus1 := big.NewInt(0).Set(&d) + d.Rsh(&d, uint(s)) + + x := ModPowBigInt(a, &d, n) + if x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 { + return true + } + + for ; s > 1; s-- { + if x = x.Mod(x.Mul(x, x), n); x.Cmp(_1) == 0 { + return false + } + + if x.Cmp(nMinus1) == 0 { + return true + } + } + return false +} + +// Max returns the larger of a and b. +func Max(a, b int) int { + if a > b { + return a + } + + return b +} + +// Min returns the smaller of a and b. +func Min(a, b int) int { + if a < b { + return a + } + + return b +} + +// MaxPtr returns a pointer to the larger of a and b, or nil. +func MaxPtr(a, b *int) *int { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinPtr returns a pointer to the smaller of a and b, or nil. +func MinPtr(a, b *int) *int { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxVal returns the largest argument passed. +func MaxVal(val int, vals ...int) int { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinVal returns the smallest argument passed. +func MinVal(val int, vals ...int) int { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// Clamp returns a value restricted between lo and hi. +func Clamp(v, lo, hi int) int { + return Min(Max(v, lo), hi) +} + +// UMax returns the larger of a and b. +func UMax(a, b uint) uint { + if a > b { + return a + } + + return b +} + +// UMin returns the smaller of a and b. +func UMin(a, b uint) uint { + if a < b { + return a + } + + return b +} + +// UMaxPtr returns a pointer to the larger of a and b, or nil. +func UMaxPtr(a, b *uint) *uint { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// UMinPtr returns a pointer to the smaller of a and b, or nil. +func UMinPtr(a, b *uint) *uint { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// UMaxVal returns the largest argument passed. +func UMaxVal(val uint, vals ...uint) uint { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// UMinVal returns the smallest argument passed. +func UMinVal(val uint, vals ...uint) uint { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// UClamp returns a value restricted between lo and hi. +func UClamp(v, lo, hi uint) uint { + return UMin(UMax(v, lo), hi) +} + +// MaxByte returns the larger of a and b. +func MaxByte(a, b byte) byte { + if a > b { + return a + } + + return b +} + +// MinByte returns the smaller of a and b. +func MinByte(a, b byte) byte { + if a < b { + return a + } + + return b +} + +// MaxBytePtr returns a pointer to the larger of a and b, or nil. +func MaxBytePtr(a, b *byte) *byte { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinBytePtr returns a pointer to the smaller of a and b, or nil. +func MinBytePtr(a, b *byte) *byte { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxByteVal returns the largest argument passed. +func MaxByteVal(val byte, vals ...byte) byte { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinByteVal returns the smallest argument passed. +func MinByteVal(val byte, vals ...byte) byte { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// ClampByte returns a value restricted between lo and hi. +func ClampByte(v, lo, hi byte) byte { + return MinByte(MaxByte(v, lo), hi) +} + +// MaxInt8 returns the larger of a and b. +func MaxInt8(a, b int8) int8 { + if a > b { + return a + } + + return b +} + +// MinInt8 returns the smaller of a and b. +func MinInt8(a, b int8) int8 { + if a < b { + return a + } + + return b +} + +// MaxInt8Ptr returns a pointer to the larger of a and b, or nil. +func MaxInt8Ptr(a, b *int8) *int8 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinInt8Ptr returns a pointer to the smaller of a and b, or nil. +func MinInt8Ptr(a, b *int8) *int8 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxInt8Val returns the largest argument passed. +func MaxInt8Val(val int8, vals ...int8) int8 { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinInt8Val returns the smallest argument passed. +func MinInt8Val(val int8, vals ...int8) int8 { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// ClampInt8 returns a value restricted between lo and hi. +func ClampInt8(v, lo, hi int8) int8 { + return MinInt8(MaxInt8(v, lo), hi) +} + +// MaxUint16 returns the larger of a and b. +func MaxUint16(a, b uint16) uint16 { + if a > b { + return a + } + + return b +} + +// MinUint16 returns the smaller of a and b. +func MinUint16(a, b uint16) uint16 { + if a < b { + return a + } + + return b +} + +// MaxUint16Ptr returns a pointer to the larger of a and b, or nil. +func MaxUint16Ptr(a, b *uint16) *uint16 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinUint16Ptr returns a pointer to the smaller of a and b, or nil. +func MinUint16Ptr(a, b *uint16) *uint16 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxUint16Val returns the largest argument passed. +func MaxUint16Val(val uint16, vals ...uint16) uint16 { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinUint16Val returns the smallest argument passed. +func MinUint16Val(val uint16, vals ...uint16) uint16 { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// ClampUint16 returns a value restricted between lo and hi. +func ClampUint16(v, lo, hi uint16) uint16 { + return MinUint16(MaxUint16(v, lo), hi) +} + +// MaxInt16 returns the larger of a and b. +func MaxInt16(a, b int16) int16 { + if a > b { + return a + } + + return b +} + +// MinInt16 returns the smaller of a and b. +func MinInt16(a, b int16) int16 { + if a < b { + return a + } + + return b +} + +// MaxInt16Ptr returns a pointer to the larger of a and b, or nil. +func MaxInt16Ptr(a, b *int16) *int16 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinInt16Ptr returns a pointer to the smaller of a and b, or nil. +func MinInt16Ptr(a, b *int16) *int16 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxInt16Val returns the largest argument passed. +func MaxInt16Val(val int16, vals ...int16) int16 { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinInt16Val returns the smallest argument passed. +func MinInt16Val(val int16, vals ...int16) int16 { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// ClampInt16 returns a value restricted between lo and hi. +func ClampInt16(v, lo, hi int16) int16 { + return MinInt16(MaxInt16(v, lo), hi) +} + +// MaxUint32 returns the larger of a and b. +func MaxUint32(a, b uint32) uint32 { + if a > b { + return a + } + + return b +} + +// MinUint32 returns the smaller of a and b. +func MinUint32(a, b uint32) uint32 { + if a < b { + return a + } + + return b +} + +// MaxUint32Ptr returns a pointer to the larger of a and b, or nil. +func MaxUint32Ptr(a, b *uint32) *uint32 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinUint32Ptr returns a pointer to the smaller of a and b, or nil. +func MinUint32Ptr(a, b *uint32) *uint32 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxUint32Val returns the largest argument passed. +func MaxUint32Val(val uint32, vals ...uint32) uint32 { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinUint32Val returns the smallest argument passed. +func MinUint32Val(val uint32, vals ...uint32) uint32 { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// ClampUint32 returns a value restricted between lo and hi. +func ClampUint32(v, lo, hi uint32) uint32 { + return MinUint32(MaxUint32(v, lo), hi) +} + +// MaxInt32 returns the larger of a and b. +func MaxInt32(a, b int32) int32 { + if a > b { + return a + } + + return b +} + +// MinInt32 returns the smaller of a and b. +func MinInt32(a, b int32) int32 { + if a < b { + return a + } + + return b +} + +// MaxInt32Ptr returns a pointer to the larger of a and b, or nil. +func MaxInt32Ptr(a, b *int32) *int32 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinInt32Ptr returns a pointer to the smaller of a and b, or nil. +func MinInt32Ptr(a, b *int32) *int32 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxInt32Val returns the largest argument passed. +func MaxInt32Val(val int32, vals ...int32) int32 { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinInt32Val returns the smallest argument passed. +func MinInt32Val(val int32, vals ...int32) int32 { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// ClampInt32 returns a value restricted between lo and hi. +func ClampInt32(v, lo, hi int32) int32 { + return MinInt32(MaxInt32(v, lo), hi) +} + +// MaxUint64 returns the larger of a and b. +func MaxUint64(a, b uint64) uint64 { + if a > b { + return a + } + + return b +} + +// MinUint64 returns the smaller of a and b. +func MinUint64(a, b uint64) uint64 { + if a < b { + return a + } + + return b +} + +// MaxUint64Ptr returns a pointer to the larger of a and b, or nil. +func MaxUint64Ptr(a, b *uint64) *uint64 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinUint64Ptr returns a pointer to the smaller of a and b, or nil. +func MinUint64Ptr(a, b *uint64) *uint64 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxUint64Val returns the largest argument passed. +func MaxUint64Val(val uint64, vals ...uint64) uint64 { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinUint64Val returns the smallest argument passed. +func MinUint64Val(val uint64, vals ...uint64) uint64 { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// ClampUint64 returns a value restricted between lo and hi. +func ClampUint64(v, lo, hi uint64) uint64 { + return MinUint64(MaxUint64(v, lo), hi) +} + +// MaxInt64 returns the larger of a and b. +func MaxInt64(a, b int64) int64 { + if a > b { + return a + } + + return b +} + +// MinInt64 returns the smaller of a and b. +func MinInt64(a, b int64) int64 { + if a < b { + return a + } + + return b +} + +// MaxInt64Ptr returns a pointer to the larger of a and b, or nil. +func MaxInt64Ptr(a, b *int64) *int64 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a > *b { + return a + } + + return b +} + +// MinInt64Ptr returns a pointer to the smaller of a and b, or nil. +func MinInt64Ptr(a, b *int64) *int64 { + if a == nil { + return b + } + if b == nil { + return a + } + if *a < *b { + return a + } + + return b +} + +// MaxInt64Val returns the largest argument passed. +func MaxInt64Val(val int64, vals ...int64) int64 { + res := val + for _, v := range vals { + if v > res { + res = v + } + } + return res +} + +// MinInt64Val returns the smallest argument passed. +func MinInt64Val(val int64, vals ...int64) int64 { + res := val + for _, v := range vals { + if v < res { + res = v + } + } + return res +} + +// ClampInt64 returns a value restricted between lo and hi. +func ClampInt64(v, lo, hi int64) int64 { + return MinInt64(MaxInt64(v, lo), hi) +} + +// ToBase produces n in base b. For example +// +// ToBase(2047, 22) -> [1, 5, 4] +// +// 1 * 22^0 1 +// 5 * 22^1 110 +// 4 * 22^2 1936 +// ---- +// 2047 +// +// ToBase panics for bases < 2. +func ToBase(n *big.Int, b int) []int { + var nn big.Int + nn.Set(n) + if b < 2 { + panic("invalid base") + } + + k := 1 + switch nn.Sign() { + case -1: + nn.Neg(&nn) + k = -1 + case 0: + return []int{0} + } + + bb := big.NewInt(int64(b)) + var r []int + rem := big.NewInt(0) + for nn.Sign() != 0 { + nn.QuoRem(&nn, bb, rem) + r = append(r, k*int(rem.Int64())) + } + return r +} + +// CheckAddInt64 returns the a+b and an indicator that the result is greater +// than math.MaxInt64. +func CheckAddInt64(a, b int64) (sum int64, gt bool) { + return a + b, a > 0 && b > math.MaxInt64-a || a < 0 && b < math.MinInt64-a +} + +// CheckSubInt64 returns a-b and an indicator that the result is less than than +// math.MinInt64. +func CheckSubInt64(a, b int64) (sum int64, lt bool) { + return a - b, a > 0 && a-math.MaxInt64 > b || a < 0 && a-math.MinInt64 < b +} + +// AddOverflowInt8 returns a + b and an indication whether the addition +// overflowed the int8 range. +func AddOverflowInt8(a, b int8) (r int8, ovf bool) { + r = a + b + if a > 0 && b > 0 { + return r, uint8(r) > math.MaxInt8 + } + + if a < 0 && b < 0 { + return r, uint8(r) <= math.MaxInt8 + } + + return r, false +} + +// AddOverflowInt16 returns a + b and an indication whether the addition +// overflowed the int16 range. +func AddOverflowInt16(a, b int16) (r int16, ovf bool) { + r = a + b + if a > 0 && b > 0 { + return r, uint16(r) > math.MaxInt16 + } + + if a < 0 && b < 0 { + return r, uint16(r) <= math.MaxInt16 + } + + return r, false +} + +// AddOverflowInt32 returns a + b and an indication whether the addition +// overflowed the int32 range. +func AddOverflowInt32(a, b int32) (r int32, ovf bool) { + r = a + b + if a > 0 && b > 0 { + return r, uint32(r) > math.MaxInt32 + } + + if a < 0 && b < 0 { + return r, uint32(r) <= math.MaxInt32 + } + + return r, false +} + +// AddOverflowInt64 returns a + b and an indication whether the addition +// overflowed the int64 range. +func AddOverflowInt64(a, b int64) (r int64, ovf bool) { + r = a + b + if a > 0 && b > 0 { + return r, uint64(r) > math.MaxInt64 + } + + if a < 0 && b < 0 { + return r, uint64(r) <= math.MaxInt64 + } + + return r, false +} + +// SubOverflowInt8 returns a - b and an indication whether the subtraction +// overflowed the int8 range. +func SubOverflowInt8(a, b int8) (r int8, ovf bool) { + r = a - b + if a >= 0 && b < 0 { + return r, uint8(r) >= math.MaxInt8+1 + } + + if a < 0 && b > 0 { + return r, uint8(r) <= math.MaxInt8 + } + + return r, false +} + +// SubOverflowInt16 returns a - b and an indication whether the subtraction +// overflowed the int16 range. +func SubOverflowInt16(a, b int16) (r int16, ovf bool) { + r = a - b + if a >= 0 && b < 0 { + return r, uint16(r) >= math.MaxInt16+1 + } + + if a < 0 && b > 0 { + return r, uint16(r) <= math.MaxInt16 + } + + return r, false +} + +// SubOverflowInt32 returns a - b and an indication whether the subtraction +// overflowed the int32 range. +func SubOverflowInt32(a, b int32) (r int32, ovf bool) { + r = a - b + if a >= 0 && b < 0 { + return r, uint32(r) >= math.MaxInt32+1 + } + + if a < 0 && b > 0 { + return r, uint32(r) <= math.MaxInt32 + } + + return r, false +} + +// SubOverflowInt64 returns a - b and an indication whether the subtraction +// overflowed the int64 range. +func SubOverflowInt64(a, b int64) (r int64, ovf bool) { + r = a - b + if a >= 0 && b < 0 { + return r, uint64(r) >= math.MaxInt64+1 + } + + if a < 0 && b > 0 { + return r, uint64(r) <= math.MaxInt64 + } + + return r, false +} + +// MulOverflowInt8 returns a * b and an indication whether the product +// overflowed the int8 range. +func MulOverflowInt8(a, b int8) (r int8, ovf bool) { + if a == 0 || b == 0 { + return 0, false + } + + z := int16(a) * int16(b) + return int8(z), z < math.MinInt8 || z > math.MaxInt8 +} + +// MulOverflowInt16 returns a * b and an indication whether the product +// overflowed the int16 range. +func MulOverflowInt16(a, b int16) (r int16, ovf bool) { + if a == 0 || b == 0 { + return 0, false + } + + z := int32(a) * int32(b) + return int16(z), z < math.MinInt16 || z > math.MaxInt16 +} + +// MulOverflowInt32 returns a * b and an indication whether the product +// overflowed the int32 range. +func MulOverflowInt32(a, b int32) (r int32, ovf bool) { + if a == 0 || b == 0 { + return 0, false + } + + z := int64(a) * int64(b) + return int32(z), z < math.MinInt32 || z > math.MaxInt32 +} + +// MulOverflowInt64 returns a * b and an indication whether the product +// overflowed the int64 range. +func MulOverflowInt64(a, b int64) (r int64, ovf bool) { + // https://groups.google.com/g/golang-nuts/c/h5oSN5t3Au4/m/KaNQREhZh0QJ + const mostPositive = 1<<63 - 1 + const mostNegative = -(mostPositive + 1) + r = a * b + if a == 0 || b == 0 || a == 1 || b == 1 { + return r, false + } + + if a == mostNegative || b == mostNegative { + return r, true + } + + return r, r/b != a +} diff --git a/internal/mathutil/permute.go b/internal/mathutil/permute.go new file mode 100644 index 0000000..7615906 --- /dev/null +++ b/internal/mathutil/permute.go @@ -0,0 +1,39 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "sort" +) + +// PermutationFirst generates the first permutation of data. +func PermutationFirst(data sort.Interface) { + sort.Sort(data) +} + +// PermutationNext generates the next permutation of data if possible and +// return true. Return false if there is no more permutation left. Based on +// the algorithm described here: +// http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order +func PermutationNext(data sort.Interface) bool { + var k, l int + for k = data.Len() - 2; ; k-- { // 1. + if k < 0 { + return false + } + + if data.Less(k, k+1) { + break + } + } + for l = data.Len() - 1; !data.Less(k, l); l-- { // 2. + } + data.Swap(k, l) // 3. + for i, j := k+1, data.Len()-1; i < j; i++ { // 4. + data.Swap(i, j) + j-- + } + return true +} diff --git a/internal/mathutil/poly.go b/internal/mathutil/poly.go new file mode 100644 index 0000000..7af2510 --- /dev/null +++ b/internal/mathutil/poly.go @@ -0,0 +1,248 @@ +// Copyright (c) 2016 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "fmt" + "math/big" +) + +func abs(n int) uint64 { + if n >= 0 { + return uint64(n) + } + + return uint64(-n) +} + +// QuadPolyDiscriminant returns the discriminant of a quadratic polynomial in +// one variable of the form a*x^2+b*x+c with integer coefficients a, b, c, or +// an error on overflow. +// +// ds is the square of the discriminant. If |ds| is a square number, d is set +// to sqrt(|ds|), otherwise d is < 0. +func QuadPolyDiscriminant(a, b, c int) (ds, d int, _ error) { + if 2*BitLenUint64(abs(b)) > IntBits-1 || + 2+BitLenUint64(abs(a))+BitLenUint64(abs(c)) > IntBits-1 { + return 0, 0, fmt.Errorf("overflow") + } + + ds = b*b - 4*a*c + s := ds + if s < 0 { + s = -s + } + d64 := SqrtUint64(uint64(s)) + if d64*d64 != uint64(s) { + return ds, -1, nil + } + + return ds, int(d64), nil +} + +// PolyFactor describes an irreducible factor of a polynomial in one variable +// with integer coefficients P, Q of the form P*x+Q. +type PolyFactor struct { + P, Q int +} + +// QuadPolyFactors returns the content and the irreducible factors of the +// primitive part of a quadratic polynomial in one variable with integer +// coefficients a, b, c of the form a*x^2+b*x+c in integers, or an error on +// overflow. +// +// If the factorization in integers does not exists, the return value is (0, +// nil, nil). +// +// See also: +// https://en.wikipedia.org/wiki/Factorization_of_polynomials#Primitive_part.E2.80.93content_factorization +func QuadPolyFactors(a, b, c int) (content int, primitivePart []PolyFactor, _ error) { + content = int(GCDUint64(abs(a), GCDUint64(abs(b), abs(c)))) + switch { + case content == 0: + content = 1 + case content > 0: + if a < 0 || a == 0 && b < 0 { + content = -content + } + } + a /= content + b /= content + c /= content + if a == 0 { + if b == 0 { + return content, []PolyFactor{{0, c}}, nil + } + + if b < 0 && c < 0 { + b = -b + c = -c + } + if b < 0 { + b = -b + c = -c + } + return content, []PolyFactor{{b, c}}, nil + } + + ds, d, err := QuadPolyDiscriminant(a, b, c) + if err != nil { + return 0, nil, err + } + + if ds < 0 || d < 0 { + return 0, nil, nil + } + + x1num := -b + d + x1denom := 2 * a + gcd := int(GCDUint64(abs(x1num), abs(x1denom))) + x1num /= gcd + x1denom /= gcd + + x2num := -b - d + x2denom := 2 * a + gcd = int(GCDUint64(abs(x2num), abs(x2denom))) + x2num /= gcd + x2denom /= gcd + + return content, []PolyFactor{{x1denom, -x1num}, {x2denom, -x2num}}, nil +} + +// QuadPolyDiscriminantBig returns the discriminant of a quadratic polynomial +// in one variable of the form a*x^2+b*x+c with integer coefficients a, b, c. +// +// ds is the square of the discriminant. If |ds| is a square number, d is set +// to sqrt(|ds|), otherwise d is nil. +func QuadPolyDiscriminantBig(a, b, c *big.Int) (ds, d *big.Int) { + ds = big.NewInt(0).Set(b) + ds.Mul(ds, b) + x := big.NewInt(4) + x.Mul(x, a) + x.Mul(x, c) + ds.Sub(ds, x) + + s := big.NewInt(0).Set(ds) + if s.Sign() < 0 { + s.Neg(s) + } + + if s.Bit(1) != 0 { // s is not a square number + return ds, nil + } + + d = SqrtBig(s) + x.Set(d) + x.Mul(x, x) + if x.Cmp(s) != 0 { // s is not a square number + d = nil + } + return ds, d +} + +// PolyFactorBig describes an irreducible factor of a polynomial in one +// variable with integer coefficients P, Q of the form P*x+Q. +type PolyFactorBig struct { + P, Q *big.Int +} + +// QuadPolyFactorsBig returns the content and the irreducible factors of the +// primitive part of a quadratic polynomial in one variable with integer +// coefficients a, b, c of the form a*x^2+b*x+c in integers. +// +// If the factorization in integers does not exists, the return value is (nil, +// nil). +// +// See also: +// https://en.wikipedia.org/wiki/Factorization_of_polynomials#Primitive_part.E2.80.93content_factorization +func QuadPolyFactorsBig(a, b, c *big.Int) (content *big.Int, primitivePart []PolyFactorBig) { + content = bigGCD(bigAbs(a), bigGCD(bigAbs(b), bigAbs(c))) + switch { + case content.Sign() == 0: + content.SetInt64(1) + case content.Sign() > 0: + if a.Sign() < 0 || a.Sign() == 0 && b.Sign() < 0 { + content = bigNeg(content) + } + } + a = bigDiv(a, content) + b = bigDiv(b, content) + c = bigDiv(c, content) + + if a.Sign() == 0 { + if b.Sign() == 0 { + return content, []PolyFactorBig{{big.NewInt(0), c}} + } + + if b.Sign() < 0 && c.Sign() < 0 { + b = bigNeg(b) + c = bigNeg(c) + } + if b.Sign() < 0 { + b = bigNeg(b) + c = bigNeg(c) + } + return content, []PolyFactorBig{{b, c}} + } + + ds, d := QuadPolyDiscriminantBig(a, b, c) + if ds.Sign() < 0 || d == nil { + return nil, nil + } + + x1num := bigAdd(bigNeg(b), d) + x1denom := bigMul(_2, a) + gcd := bigGCD(bigAbs(x1num), bigAbs(x1denom)) + x1num = bigDiv(x1num, gcd) + x1denom = bigDiv(x1denom, gcd) + + x2num := bigAdd(bigNeg(b), bigNeg(d)) + x2denom := bigMul(_2, a) + gcd = bigGCD(bigAbs(x2num), bigAbs(x2denom)) + x2num = bigDiv(x2num, gcd) + x2denom = bigDiv(x2denom, gcd) + + return content, []PolyFactorBig{{x1denom, bigNeg(x1num)}, {x2denom, bigNeg(x2num)}} +} + +func bigAbs(n *big.Int) *big.Int { + n = big.NewInt(0).Set(n) + if n.Sign() >= 0 { + return n + } + + return n.Neg(n) +} + +func bigDiv(a, b *big.Int) *big.Int { + a = big.NewInt(0).Set(a) + return a.Div(a, b) +} + +func bigGCD(a, b *big.Int) *big.Int { + a = big.NewInt(0).Set(a) + b = big.NewInt(0).Set(b) + for b.Sign() != 0 { + c := big.NewInt(0) + c.Mod(a, b) + a, b = b, c + } + return a +} + +func bigNeg(n *big.Int) *big.Int { + n = big.NewInt(0).Set(n) + return n.Neg(n) +} + +func bigMul(a, b *big.Int) *big.Int { + r := big.NewInt(0).Set(a) + return r.Mul(r, b) +} + +func bigAdd(a, b *big.Int) *big.Int { + r := big.NewInt(0).Set(a) + return r.Add(r, b) +} diff --git a/internal/mathutil/primes.go b/internal/mathutil/primes.go new file mode 100644 index 0000000..2457c9f --- /dev/null +++ b/internal/mathutil/primes.go @@ -0,0 +1,331 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "math" +) + +// IsPrimeUint16 returns true if n is prime. Typical run time is few ns. +func IsPrimeUint16(n uint16) bool { + return n > 0 && primes16[n-1] == 1 +} + +// NextPrimeUint16 returns first prime > n and true if successful or an +// undefined value and false if there is no next prime in the uint16 limits. +// Typical run time is few ns. +func NextPrimeUint16(n uint16) (p uint16, ok bool) { + return n + uint16(primes16[n]), n < 65521 +} + +// IsPrime returns true if n is prime. Typical run time is about 100 ns. +func IsPrime(n uint32) bool { + switch { + case n&1 == 0: + return n == 2 + case n%3 == 0: + return n == 3 + case n%5 == 0: + return n == 5 + case n%7 == 0: + return n == 7 + case n%11 == 0: + return n == 11 + case n%13 == 0: + return n == 13 + case n%17 == 0: + return n == 17 + case n%19 == 0: + return n == 19 + case n%23 == 0: + return n == 23 + case n%29 == 0: + return n == 29 + case n%31 == 0: + return n == 31 + case n%37 == 0: + return n == 37 + case n%41 == 0: + return n == 41 + case n%43 == 0: + return n == 43 + case n%47 == 0: + return n == 47 + case n%53 == 0: + return n == 53 // Benchmarked optimum + case n < 65536: + // use table data + return IsPrimeUint16(uint16(n)) + default: + mod := ModPowUint32(2, (n+1)/2, n) + if mod != 2 && mod != n-2 { + return false + } + blk := &lohi[n>>24] + lo, hi := blk.lo, blk.hi + for lo <= hi { + index := (lo + hi) >> 1 + liar := liars[index] + switch { + case n > liar: + lo = index + 1 + case n < liar: + hi = index - 1 + default: + return false + } + } + return true + } +} + +// IsPrimeUint64 returns true if n is prime. Typical run time is few tens of µs. +// +// SPRP bases: http://miller-rabin.appspot.com +func IsPrimeUint64(n uint64) bool { + switch { + case n%2 == 0: + return n == 2 + case n%3 == 0: + return n == 3 + case n%5 == 0: + return n == 5 + case n%7 == 0: + return n == 7 + case n%11 == 0: + return n == 11 + case n%13 == 0: + return n == 13 + case n%17 == 0: + return n == 17 + case n%19 == 0: + return n == 19 + case n%23 == 0: + return n == 23 + case n%29 == 0: + return n == 29 + case n%31 == 0: + return n == 31 + case n%37 == 0: + return n == 37 + case n%41 == 0: + return n == 41 + case n%43 == 0: + return n == 43 + case n%47 == 0: + return n == 47 + case n%53 == 0: + return n == 53 + case n%59 == 0: + return n == 59 + case n%61 == 0: + return n == 61 + case n%67 == 0: + return n == 67 + case n%71 == 0: + return n == 71 + case n%73 == 0: + return n == 73 + case n%79 == 0: + return n == 79 + case n%83 == 0: + return n == 83 + case n%89 == 0: + return n == 89 // Benchmarked optimum + case n <= math.MaxUint16: + return IsPrimeUint16(uint16(n)) + case n <= math.MaxUint32: + return ProbablyPrimeUint32(uint32(n), 11000544) && + ProbablyPrimeUint32(uint32(n), 31481107) + case n < 105936894253: + return ProbablyPrimeUint64_32(n, 2) && + ProbablyPrimeUint64_32(n, 1005905886) && + ProbablyPrimeUint64_32(n, 1340600841) + case n < 31858317218647: + return ProbablyPrimeUint64_32(n, 2) && + ProbablyPrimeUint64_32(n, 642735) && + ProbablyPrimeUint64_32(n, 553174392) && + ProbablyPrimeUint64_32(n, 3046413974) + case n < 3071837692357849: + return ProbablyPrimeUint64_32(n, 2) && + ProbablyPrimeUint64_32(n, 75088) && + ProbablyPrimeUint64_32(n, 642735) && + ProbablyPrimeUint64_32(n, 203659041) && + ProbablyPrimeUint64_32(n, 3613982119) + default: + return ProbablyPrimeUint64_32(n, 2) && + ProbablyPrimeUint64_32(n, 325) && + ProbablyPrimeUint64_32(n, 9375) && + ProbablyPrimeUint64_32(n, 28178) && + ProbablyPrimeUint64_32(n, 450775) && + ProbablyPrimeUint64_32(n, 9780504) && + ProbablyPrimeUint64_32(n, 1795265022) + } +} + +// NextPrime returns first prime > n and true if successful or an undefined value and false if there +// is no next prime in the uint32 limits. Typical run time is about 2 µs. +func NextPrime(n uint32) (p uint32, ok bool) { + switch { + case n < 65521: + p16, _ := NextPrimeUint16(uint16(n)) + return uint32(p16), true + case n >= math.MaxUint32-4: + return + } + + n++ + var d0, d uint32 + switch mod := n % 6; mod { + case 0: + d0, d = 1, 4 + case 1: + d = 4 + case 2, 3, 4: + d0, d = 5-mod, 2 + case 5: + d = 2 + } + + p = n + d0 + if p < n { // overflow + return + } + + for { + if IsPrime(p) { + return p, true + } + + p0 := p + p += d + if p < p0 { // overflow + break + } + + d ^= 6 + } + return +} + +// NextPrimeUint64 returns first prime > n and true if successful or an undefined value and false if there +// is no next prime in the uint64 limits. Typical run time is in hundreds of µs. +func NextPrimeUint64(n uint64) (p uint64, ok bool) { + switch { + case n < 65521: + p16, _ := NextPrimeUint16(uint16(n)) + return uint64(p16), true + case n >= 18446744073709551557: // last uint64 prime + return + } + + n++ + var d0, d uint64 + switch mod := n % 6; mod { + case 0: + d0, d = 1, 4 + case 1: + d = 4 + case 2, 3, 4: + d0, d = 5-mod, 2 + case 5: + d = 2 + } + + p = n + d0 + if p < n { // overflow + return + } + + for { + if ok = IsPrimeUint64(p); ok { + break + } + + p0 := p + p += d + if p < p0 { // overflow + break + } + + d ^= 6 + } + return +} + +// FactorTerm is one term of an integer factorization. +type FactorTerm struct { + Prime uint32 // The divisor + Power uint32 // Term == Prime^Power +} + +// FactorTerms represent a factorization of an integer +type FactorTerms []FactorTerm + +// FactorInt returns prime factorization of n > 1 or nil otherwise. +// Resulting factors are ordered by Prime. Typical run time is few µs. +func FactorInt(n uint32) (f FactorTerms) { + switch { + case n < 2: + return + case IsPrime(n): + return []FactorTerm{{n, 1}} + } + + f, w := make([]FactorTerm, 9), 0 + for p := 2; p < len(primes16); p += int(primes16[p]) { + if uint(p*p) > uint(n) { + break + } + + power := uint32(0) + for n%uint32(p) == 0 { + n /= uint32(p) + power++ + } + if power != 0 { + f[w] = FactorTerm{uint32(p), power} + w++ + } + if n == 1 { + break + } + } + if n != 1 { + f[w] = FactorTerm{n, 1} + w++ + } + return f[:w] +} + +// PrimorialProductsUint32 returns a slice of numbers in [lo, hi] which are a +// product of max 'max' primorials. The slice is not sorted. +// +// See also: http://en.wikipedia.org/wiki/Primorial +func PrimorialProductsUint32(lo, hi, max uint32) (r []uint32) { + lo64, hi64 := int64(lo), int64(hi) + if max > 31 { // N/A + max = 31 + } + + var f func(int64, int64, uint32) + f = func(n, p int64, emax uint32) { + e := uint32(1) + for n <= hi64 && e <= emax { + n *= p + if n >= lo64 && n <= hi64 { + r = append(r, uint32(n)) + } + if n < hi64 { + p, _ := NextPrime(uint32(p)) + f(n, int64(p), e) + } + e++ + } + } + + f(1, 2, max) + return +} diff --git a/internal/mathutil/rat.go b/internal/mathutil/rat.go new file mode 100644 index 0000000..45ad1a0 --- /dev/null +++ b/internal/mathutil/rat.go @@ -0,0 +1,26 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +// QCmpUint32 compares a/b and c/d and returns: +// +// -1 if a/b < c/d +// 0 if a/b == c/d +// +1 if a/b > c/d +func QCmpUint32(a, b, c, d uint32) int { + switch x, y := uint64(a)*uint64(d), uint64(b)*uint64(c); { + case x < y: + return -1 + case x == y: + return 0 + default: // x > y + return 1 + } +} + +// QScaleUint32 returns a such that a/b >= c/d. +func QScaleUint32(b, c, d uint32) (a uint64) { + return 1 + (uint64(b)*uint64(c))/uint64(d) +} diff --git a/internal/mathutil/rnd.go b/internal/mathutil/rnd.go new file mode 100644 index 0000000..590745f --- /dev/null +++ b/internal/mathutil/rnd.go @@ -0,0 +1,383 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +import ( + "fmt" + "math" + "math/big" +) + +// FC32 is a full cycle PRNG covering the 32 bit signed integer range. +// In contrast to full cycle generators shown at e.g. http://en.wikipedia.org/wiki/Full_cycle, +// this code doesn't produce values at constant delta (mod cycle length). +// The 32 bit limit is per this implementation, the algorithm used has no intrinsic limit on the cycle size. +// Properties include: +// - Adjustable limits on creation (hi, lo). +// - Positionable/randomly accessible (Pos, Seek). +// - Repeatable (deterministic). +// - Can run forward or backward (Next, Prev). +// - For a billion numbers cycle the Next/Prev PRN can be produced in cca 100-150ns. +// That's like 5-10 times slower compared to PRNs generated using the (non FC) rand package. +type FC32 struct { + cycle int64 // On average: 3 * delta / 2, (HQ: 2 * delta) + delta int64 // hi - lo + factors [][]int64 // This trades some space for hopefully a bit of speed (multiple adding vs multiplying). + lo int + mods []int // pos % set + pos int64 // Within cycle. + primes []int64 // Ordered. ∏ primes == cycle. + set []int64 // Reordered primes (magnitude order bases) according to seed. +} + +// NewFC32 returns a newly created FC32 adjusted for the closed interval [lo, hi] or an Error if any. +// If hq == true then trade some generation time for improved (pseudo)randomness. +func NewFC32(lo, hi int, hq bool) (r *FC32, err error) { + if lo > hi { + return nil, fmt.Errorf("invalid range %d > %d", lo, hi) + } + + if uint64(hi)-uint64(lo) > math.MaxUint32 { + return nil, fmt.Errorf("range out of int32 limits %d, %d", lo, hi) + } + + delta := int64(hi) - int64(lo) + // Find the primorial covering whole delta + n, set, p := int64(1), []int64{}, uint32(2) + if hq { + p++ + } + for { + set = append(set, int64(p)) + n *= int64(p) + if n > delta { + break + } + p, _ = NextPrime(p) + } + + // Adjust the set so n ∊ [delta, 2 * delta] (HQ: [delta, 3 * delta]) + // while keeping the cardinality of the set (correlates with the statistic "randomness quality") + // at max, i.e. discard atmost one member. + i := -1 // no candidate prime + if n > 2*(delta+1) { + for j, p := range set { + q := n / p + if q < delta+1 { + break + } + + i = j // mark the highest candidate prime set index + } + } + if i >= 0 { // shrink the inner cycle + n = n / set[i] + set = delete(set, i) + } + r = &FC32{ + cycle: n, + delta: delta, + factors: make([][]int64, len(set)), + lo: lo, + mods: make([]int, len(set)), + primes: set, + } + r.Seed(1) // the default seed should be always non zero + return +} + +// Cycle reports the length of the inner FCPRNG cycle. +// Cycle is atmost the double (HQ: triple) of the generator period (hi - lo + 1). +func (r *FC32) Cycle() int64 { + return r.cycle +} + +// Next returns the first PRN after Pos. +func (r *FC32) Next() int { + return r.step(1) +} + +// Pos reports the current position within the inner cycle. +func (r *FC32) Pos() int64 { + return r.pos +} + +// Prev return the first PRN before Pos. +func (r *FC32) Prev() int { + return r.step(-1) +} + +// Seed uses the provided seed value to initialize the generator to a deterministic state. +// A zero seed produces a "canonical" generator with worse randomness than for most non zero seeds. +// Still, the FC property holds for any seed value. +func (r *FC32) Seed(seed int64) { + u := uint64(seed) + r.set = mix(r.primes, &u) + n := int64(1) + for i, p := range r.set { + k := make([]int64, p) + v := int64(0) + for j := range k { + k[j] = v + v += n + } + n *= p + r.factors[i] = mix(k, &u) + } +} + +// Seek sets Pos to |pos| % Cycle. +func (r *FC32) Seek(pos int64) { //vet:ignore + if pos < 0 { + pos = -pos + } + pos %= r.cycle + r.pos = pos + for i, p := range r.set { + r.mods[i] = int(pos % p) + } +} + +func (r *FC32) step(dir int) int { + for { // avg loops per step: 3/2 (HQ: 2) + y := int64(0) + pos := r.pos + pos += int64(dir) + switch { + case pos < 0: + pos = r.cycle - 1 + case pos >= r.cycle: + pos = 0 + } + r.pos = pos + for i, mod := range r.mods { + mod += dir + p := int(r.set[i]) + switch { + case mod < 0: + mod = p - 1 + case mod >= p: + mod = 0 + } + r.mods[i] = mod + y += r.factors[i][mod] + } + if y <= r.delta { + return int(y) + r.lo + } + } +} + +func delete(set []int64, i int) (y []int64) { + for j, v := range set { + if j != i { + y = append(y, v) + } + } + return +} + +func mix(set []int64, seed *uint64) (y []int64) { + for len(set) != 0 { + *seed = rol(*seed) + i := int(*seed % uint64(len(set))) + y = append(y, set[i]) + set = delete(set, i) + } + return +} + +func rol(u uint64) (y uint64) { + y = u << 1 + if int64(u) < 0 { + y |= 1 + } + return +} + +// FCBig is a full cycle PRNG covering ranges outside of the int32 limits. +// For more info see the FC32 docs. +// Next/Prev PRN on a 1e15 cycle can be produced in about 2 µsec. +type FCBig struct { + cycle *big.Int // On average: 3 * delta / 2, (HQ: 2 * delta) + delta *big.Int // hi - lo + factors [][]*big.Int // This trades some space for hopefully a bit of speed (multiple adding vs multiplying). + lo *big.Int + mods []int // pos % set + pos *big.Int // Within cycle. + primes []int64 // Ordered. ∏ primes == cycle. + set []int64 // Reordered primes (magnitude order bases) according to seed. +} + +// NewFCBig returns a newly created FCBig adjusted for the closed interval [lo, hi] or an Error if any. +// If hq == true then trade some generation time for improved (pseudo)randomness. +func NewFCBig(lo, hi *big.Int, hq bool) (r *FCBig, err error) { + if lo.Cmp(hi) > 0 { + return nil, fmt.Errorf("invalid range %d > %d", lo, hi) + } + + delta := big.NewInt(0) + delta.Add(delta, hi).Sub(delta, lo) + + // Find the primorial covering whole delta + n, set, pp, p := big.NewInt(1), []int64{}, big.NewInt(0), uint32(2) + if hq { + p++ + } + for { + set = append(set, int64(p)) + pp.SetInt64(int64(p)) + n.Mul(n, pp) + if n.Cmp(delta) > 0 { + break + } + p, _ = NextPrime(p) + } + + // Adjust the set so n ∊ [delta, 2 * delta] (HQ: [delta, 3 * delta]) + // while keeping the cardinality of the set (correlates with the statistic "randomness quality") + // at max, i.e. discard atmost one member. + dd1 := big.NewInt(1) + dd1.Add(dd1, delta) + dd2 := big.NewInt(0) + dd2.Lsh(dd1, 1) + i := -1 // no candidate prime + if n.Cmp(dd2) > 0 { + q := big.NewInt(0) + for j, p := range set { + pp.SetInt64(p) + q.Set(n) + q.Div(q, pp) + if q.Cmp(dd1) < 0 { + break + } + + i = j // mark the highest candidate prime set index + } + } + if i >= 0 { // shrink the inner cycle + pp.SetInt64(set[i]) + n.Div(n, pp) + set = delete(set, i) + } + r = &FCBig{ + cycle: n, + delta: delta, + factors: make([][]*big.Int, len(set)), + lo: lo, + mods: make([]int, len(set)), + pos: big.NewInt(0), + primes: set, + } + r.Seed(1) // the default seed should be always non zero + return +} + +// Cycle reports the length of the inner FCPRNG cycle. +// Cycle is atmost the double (HQ: triple) of the generator period (hi - lo + 1). +func (r *FCBig) Cycle() *big.Int { + return r.cycle +} + +// Next returns the first PRN after Pos. +func (r *FCBig) Next() *big.Int { + return r.step(1) +} + +// Pos reports the current position within the inner cycle. +func (r *FCBig) Pos() *big.Int { + return r.pos +} + +// Prev return the first PRN before Pos. +func (r *FCBig) Prev() *big.Int { + return r.step(-1) +} + +// Seed uses the provided seed value to initialize the generator to a deterministic state. +// A zero seed produces a "canonical" generator with worse randomness than for most non zero seeds. +// Still, the FC property holds for any seed value. +func (r *FCBig) Seed(seed int64) { + u := uint64(seed) + r.set = mix(r.primes, &u) + n := big.NewInt(1) + v := big.NewInt(0) + pp := big.NewInt(0) + for i, p := range r.set { + k := make([]*big.Int, p) + v.SetInt64(0) + for j := range k { + k[j] = big.NewInt(0) + k[j].Set(v) + v.Add(v, n) + } + pp.SetInt64(p) + n.Mul(n, pp) + r.factors[i] = mixBig(k, &u) + } +} + +// Seek sets Pos to |pos| % Cycle. +func (r *FCBig) Seek(pos *big.Int) { + r.pos.Set(pos) + r.pos.Abs(r.pos) + r.pos.Mod(r.pos, r.cycle) + mod := big.NewInt(0) + pp := big.NewInt(0) + for i, p := range r.set { + pp.SetInt64(p) + r.mods[i] = int(mod.Mod(r.pos, pp).Int64()) + } +} + +func (r *FCBig) step(dir int) (y *big.Int) { + y = big.NewInt(0) + d := big.NewInt(int64(dir)) + for { // avg loops per step: 3/2 (HQ: 2) + r.pos.Add(r.pos, d) + switch { + case r.pos.Sign() < 0: + r.pos.Add(r.pos, r.cycle) + case r.pos.Cmp(r.cycle) >= 0: + r.pos.SetInt64(0) + } + for i, mod := range r.mods { + mod += dir + p := int(r.set[i]) + switch { + case mod < 0: + mod = p - 1 + case mod >= p: + mod = 0 + } + r.mods[i] = mod + y.Add(y, r.factors[i][mod]) + } + if y.Cmp(r.delta) <= 0 { + y.Add(y, r.lo) + return + } + y.SetInt64(0) + } +} + +func deleteBig(set []*big.Int, i int) (y []*big.Int) { + for j, v := range set { + if j != i { + y = append(y, v) + } + } + return +} + +func mixBig(set []*big.Int, seed *uint64) (y []*big.Int) { + for len(set) != 0 { + *seed = rol(*seed) + i := int(*seed % uint64(len(set))) + y = append(y, set[i]) + set = deleteBig(set, i) + } + return +} diff --git a/internal/mathutil/sqr.go b/internal/mathutil/sqr.go new file mode 100644 index 0000000..b7e15c9 --- /dev/null +++ b/internal/mathutil/sqr.go @@ -0,0 +1,12 @@ +//go:build !riscv64 && !loong64 +// +build !riscv64,!loong64 + +package mathutil + +import "github.com/remyoudompheng/bigfft" + +func (f *float) sqr() { + f.n = bigfft.Mul(f.n, f.n) + f.fracBits *= 2 + f.normalize() +} diff --git a/internal/mathutil/tables.go b/internal/mathutil/tables.go new file mode 100644 index 0000000..84bfc34 --- /dev/null +++ b/internal/mathutil/tables.go @@ -0,0 +1,6995 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// "Static" data + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +var ( + // Set bits count in a byte + popcnt = [256]byte{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, // 0 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 1 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 2 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 3 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 4 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 5 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 6 + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 7 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 8 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 9 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 10 + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 11 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 12 + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 13 + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 14 + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, // 15 + } + + // Highest set bit index in a byte + log2 = [256]int{ + -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 0 + + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 1 + + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 2 + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 3 + + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 4 + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 5 + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 6 + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 7 + + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 8 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 9 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 10 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 11 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 12 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 13 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 14 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 15 + } + + // "Predivisors": 2-53 + liars = [3660]uint32{ + 31621, 42799, 49141, 49981, 65077, 65281, 80581, 83333, 88357, 90751, + 104653, 130561, 164737, 188057, 194221, 196093, 215749, 219781, 220729, 253241, + 256999, 271951, 280601, 282133, 357761, 390937, 458989, 486737, 489997, 514447, + 580337, 587861, 611701, 647089, 653333, 657901, 665281, 665333, 688213, 710533, + 721801, 722261, 738541, 741751, 742813, 745889, 769757, 818201, 838861, 873181, + 877099, 916327, 976873, 983401, 1016801, 1018921, 1053761, 1064053, 1073021, 1082401, + 1109461, 1132657, 1145257, 1168513, 1194649, 1207361, 1251949, 1252697, 1302451, 1325843, + 1357441, 1373653, 1397419, 1441091, 1493857, 1507963, 1509709, 1530787, 1584133, 1678541, + 1690501, 1730977, 1735841, 1811573, 1876393, 1969417, 1987021, 2004403, 2081713, 2163001, + 2181961, 2205967, 2261953, 2264369, 2269093, 2284453, 2304167, 2387797, 2487941, 2510569, + 2670361, 2746477, 2748023, 2757241, 2811271, 2909197, 2944261, 2976487, 3048841, 3090091, + 3116107, 3125281, 3225601, 3363121, 3375041, 3400013, 3413533, 3429037, 3539101, 3542533, + 3567481, 3568661, 3605429, 3656449, 3763801, 3828001, 3898129, 3911197, 3985921, 4072729, + 4181921, 4188889, 4209661, 4360621, 4469471, 4480477, 4513841, 4835209, 4863127, 4869313, + 4877641, 4922413, 5016191, 5044033, 5095177, 5173169, 5173601, 5176153, 5256091, 5271841, + 5284333, 5351537, 5489641, 5590621, 5672041, 5919187, 6027193, 6118141, 6140161, 6159301, + 6189121, 6226193, 6233977, 6236257, 6278533, 6334351, 6368689, 6386993, 6631549, 6658669, + 6779137, 6787327, 6836233, 6952037, 6955541, 6998881, 7017193, 7232321, 7306261, 7306561, + 7429117, 7462001, 7674967, 7725901, 7759937, 7820201, 7883731, 8036033, 8095447, 8239477, + 8384513, 8534233, 8725753, 8727391, 8902741, 9006401, 9056501, 9073513, 9131401, 9345541, + 9371251, 9439201, 9480461, 9533701, 9564169, 9567673, 9588151, 9591661, 9729301, 9774181, + 9863461, 10024561, 10084177, 10323769, 10331141, 10386241, 10425511, 10610063, 10700761, 10712857, + 10763653, 10974881, 11081459, 11115037, 11335501, 11541307, 11585293, 11592397, 11777599, 12032021, + 12096613, 12263131, 12322133, 12327121, 12599233, 12854437, 13057787, 13338371, 13446253, 13500313, + 13635289, 13694761, 13747361, 13773061, 14026897, 14154337, 14179537, 14324473, 14469841, 14671801, + 14676481, 14709241, 14794081, 14796289, 14865121, 15101893, 15139199, 15162941, 15188557, 15220951, + 15247621, 15479777, 15525241, 15603391, 15621409, 15700301, 15802681, 15976747, 15978007, 16070429, + 16132321, 16149169, 16153633, 16324001, 16349477, 16360381, 16705021, 16773121, 16822081, 16843009, + 16853077, 16879501, 16973393, 17098369, 17116837, 17134043, 17208601, 17236801, 17327773, 17375249, + 17405537, 17585969, 17870561, 18067501, 18073817, 18366937, 18443701, 18454921, 18535177, 18653353, + 18740971, 19328653, 19384289, 19404139, 19471033, 19607561, 20261251, 20417311, 20647621, 20968501, + 21042001, 21303343, 21306157, 21359521, 21397381, 21400481, 21623659, 21654533, 22075579, 22087477, + 22369621, 22591301, 22669501, 22711873, 22849481, 22953673, 23247901, 23382529, 23464033, 23577497, + 23634181, 23734901, 23828017, 23872213, 23963869, 24214051, 24356377, 25080101, 25150501, 25276421, + 25326001, 25457833, 25629913, 25696133, 25768261, 25909453, 26280073, 26377921, 26821601, 26840269, + 26877421, 26886817, 27108397, 27118601, 27219697, 27271151, 27279409, 27331921, 27380831, 27392041, + 27409541, 27491237, 27509653, 27664033, 27798461, 27808463, 28325881, 28527049, 28572961, 29111881, + 29214541, 29581501, 30022129, 30090817, 30185569, 30219757, 30295141, 30338593, 30388753, 30418957, + 30576151, 30662497, 30740417, 30881551, 30894307, 31040833, 31166803, 31436123, 31735621, 31759121, + 32091781, 32095057, 32168117, 32285041, 32497921, 32676481, 33146717, 33298337, 33600533, 33627301, + 33704101, 33872593, 34003061, 34043101, 34124641, 34540801, 34856167, 34944001, 35576599, 35703361, + 35820937, 35851037, 36291193, 36307981, 36861901, 36919681, 36974341, 37109467, 37376509, 37439201, + 37964809, 37988497, 38010307, 38046817, 38118763, 38210323, 39465091, 39512773, 39655153, 39684157, + 40165093, 40238797, 40315441, 40361197, 40629601, 40782589, 40827473, 40987201, 41121433, 41568101, + 41604109, 41642681, 41662297, 41840809, 42009217, 42485119, 42623017, 42984589, 43224397, 43363601, + 43661257, 44070841, 44314129, 44465221, 44482901, 45100177, 45175201, 45219329, 45414433, 45819541, + 45879941, 46094401, 46325029, 46386589, 46469809, 46517857, 46679761, 46860001, 47220367, 47903701, + 47918581, 48064021, 48191653, 48269761, 48316969, 48400753, 48448661, 48551161, 48563089, 49075417, + 49303801, 49411801, 49459801, 50155733, 50201089, 50443201, 50523661, 51030601, 51129781, 51302353, + 51500521, 52072021, 52119289, 52204237, 53283169, 53399449, 53656021, 53675623, 53695721, 53711113, + 54029741, 54449431, 55109401, 55176097, 55318957, 55729957, 56052361, 56420033, 56479897, 56810137, + 57762433, 58003213, 58422409, 58449847, 58509977, 58679941, 58755877, 59631211, 59840537, 59913157, + 59953741, 60155201, 60352921, 60547831, 60566431, 60581401, 60696661, 60738257, 60957361, 61201009, + 61219789, 61377109, 61832377, 62756641, 63001801, 63002501, 63065281, 63167743, 63318169, 63328469, + 63346999, 63388033, 64148717, 64605041, 64735897, 65144501, 65254393, 65301013, 65350801, 65359477, + 66096253, 67194401, 67642513, 67928221, 68102641, 68154001, 68165761, 68512867, 68621701, 68839597, + 69030901, 69128641, 69176647, 69228967, 69231061, 69485281, 69612061, 69885649, 70149631, 70463489, + 70593931, 70728121, 71079661, 71734417, 72498253, 72543547, 73562833, 73645001, 74411131, 74927161, + 75140137, 75565873, 76725091, 76745101, 77533123, 77648941, 77812153, 77817979, 78939089, 79398901, + 79411201, 79417801, 79464533, 79786523, 80142761, 80146909, 80375707, 80556337, 80687881, 80891009, + 81433591, 81954133, 82273201, 82506439, 82870517, 82929001, 83083001, 83103329, 83204801, 84164033, + 84350561, 84421081, 84487457, 84998503, 85328717, 85519337, 85823401, 86027329, 86438857, 86530621, + 86999837, 87499651, 87694261, 88256449, 88368853, 88661861, 89308771, 89784581, 90270613, 90278161, + 90341197, 90665789, 90698401, 91433281, 91659283, 92438581, 92625121, 93431521, 93541537, 93571633, + 93643201, 93677761, 93926197, 94316401, 94502701, 95451361, 95452781, 96135601, 96618397, 96791881, + 96888641, 96895441, 96904081, 96925921, 97255801, 97496449, 97796953, 97863529, 97924217, 99036001, + 99115297, 99486889, 99789673, 99898801, 100463443, 100618933, 100943201, 101152133, 101218921, 101270251, + 101276579, 101649241, 102004421, 102678031, 102690677, 102690901, 103301633, 104078857, 104524421, 104988673, + 105305443, 105919633, 106485121, 106622353, 106743073, 107360641, 107543333, 108596953, 109231229, 109437751, + 109541461, 109879837, 110135821, 110139499, 110312773, 110413333, 110717861, 111370141, 111654401, 112032001, + 112402981, 112828801, 113589601, 113605201, 113730481, 113892589, 114305441, 114329881, 114701341, 114842677, + 114910489, 115039081, 115174681, 115497901, 115804501, 115873801, 116090081, 116321617, 116617289, 116682721, + 116696161, 116998669, 117987841, 118466401, 118901521, 119092801, 119204809, 119261113, 119327041, 119558011, + 119743537, 119940853, 120296677, 120517021, 120838609, 121062001, 121374241, 121472359, 121609489, 122166307, + 122396737, 122941981, 123481777, 123671671, 123877081, 123987793, 124145473, 124630273, 124818601, 125284141, + 125686241, 125848577, 126132553, 127050067, 128079409, 128124151, 128396921, 128468957, 128665319, 128987429, + 129205781, 129256273, 129357061, 129461617, 129524669, 130556329, 130693393, 130944133, 131023201, 131567929, + 131938561, 132332201, 132338881, 132440521, 132575071, 133216381, 133302781, 133467517, 133800661, 134696801, + 134767153, 134868029, 135263269, 135296053, 135308881, 135945853, 135969401, 136043641, 136661201, 136722433, + 137415821, 137763037, 138030721, 138403981, 138828821, 139295701, 139487041, 140197051, 142525333, 142922413, + 143106133, 143168581, 145348529, 146156617, 146272901, 146659801, 146843929, 146884393, 147028001, 147287141, + 148109473, 148171769, 148910653, 149389633, 150379693, 150960239, 150988753, 151533377, 151589881, 152716537, + 152922001, 152991841, 153369061, 153589801, 153754873, 153928133, 154287451, 154513633, 154944533, 155203361, + 156114061, 156532799, 157069189, 157368661, 157405249, 157725829, 158068153, 158192317, 158397247, 158496911, + 158544401, 158895281, 160348189, 160378861, 160491329, 160587841, 160672201, 160730389, 161184013, 161216021, + 161289649, 161304001, 161423377, 162026869, 162067441, 162690481, 162771337, 162776041, 163442551, 163954561, + 164111281, 165061909, 165224321, 165938653, 166082309, 166339057, 166406561, 166827943, 167579497, 167582377, + 167692141, 167881121, 168566501, 169655641, 170640961, 170782921, 170856533, 171454321, 172116181, 172436713, + 172947529, 173401621, 174479729, 176030977, 176597821, 176609441, 176977921, 177167233, 177254533, 177693521, + 177927641, 177951973, 178837201, 178956971, 179083601, 179285137, 179820257, 180115489, 180497633, 180703451, + 181285001, 181285537, 181542601, 181647497, 182383111, 183677341, 184411567, 185653333, 186183469, 186393481, + 186983521, 187050529, 187667969, 187761241, 188516329, 188985961, 189714193, 189738361, 189941761, 190212181, + 190382161, 190913297, 191233813, 191648161, 191981609, 192346153, 192857761, 193330237, 193638337, 193949641, + 194556451, 196035001, 196049701, 196231393, 198982759, 199674721, 200143351, 200753281, 201261061, 202130197, + 202156813, 202538857, 203505697, 204280501, 204582457, 204766381, 205057561, 206304961, 206453509, 206504033, + 206529737, 207008569, 207030541, 207132481, 207477001, 207618781, 208051201, 208969223, 209246701, 209404369, + 209990881, 210592873, 210842113, 213035761, 214038533, 214110541, 214852609, 214858717, 215436241, 216821881, + 217123069, 217875571, 218603617, 218642029, 218947121, 219621781, 220531501, 220883521, 221368153, 221415781, + 221884001, 222010721, 222630193, 223449463, 223625851, 223782263, 224074369, 224136013, 224769241, 224957893, + 225853633, 226359547, 226450297, 227132641, 227444101, 227475481, 228652201, 228842209, 228988033, 229589413, + 230357761, 231383461, 231405701, 231927781, 232114433, 232460821, 232771501, 233110081, 234869009, 235426913, + 235928071, 237791143, 238001653, 238833421, 240068041, 240371713, 240694513, 240785047, 241505377, 242067841, + 242650717, 242860069, 243583201, 243955141, 244883981, 245006623, 245950561, 246099317, 246282511, 246434761, + 246658441, 247318957, 247321301, 247416101, 249582481, 250436033, 250958401, 250988173, 251528401, 251663837, + 251855893, 252853921, 253610281, 253893397, 255416897, 256831433, 257590661, 258020473, 258043229, 258234401, + 258944401, 259763093, 259765747, 260156101, 260518801, 260736341, 260963389, 261186001, 261703417, 262979501, + 263428181, 264269449, 264384469, 265020001, 265584133, 265735969, 265836161, 266790481, 266925601, 270525737, + 271272569, 271763467, 271826629, 271950829, 273361789, 273480637, 274701913, 274810241, 274919401, 275283401, + 275619961, 276018913, 276131137, 276542401, 276638321, 277787141, 278943061, 279377281, 280885153, 282253141, + 282471853, 282769771, 283900961, 284166877, 284301751, 284736091, 284834299, 285820501, 286316801, 287160301, + 287449091, 287715121, 288099001, 288117721, 288735277, 290643601, 290706781, 290953921, 291088513, 291461633, + 292153681, 292290181, 292433321, 292902481, 293346637, 293847721, 293938261, 295419097, 295743017, 297624961, + 297798961, 298212601, 299367877, 299736181, 301413001, 302635351, 304080001, 307629401, 307694323, 307972801, + 308483209, 309666361, 310474249, 310978027, 311177213, 311411629, 311655829, 311671361, 312408113, 312614021, + 314184487, 315034513, 315351521, 317137969, 317365933, 317641171, 317796119, 319053281, 319374577, 319440769, + 319726177, 320326003, 321324589, 321850849, 322469701, 322941881, 324477697, 325028089, 325352101, 325546873, + 326266051, 326405713, 326469137, 326628721, 326694301, 326695141, 327073601, 327093409, 327398009, 328302901, + 329153653, 329769721, 330198331, 330759617, 331658081, 331934989, 337135501, 337420679, 337665901, 337783981, + 338125537, 338458807, 338914369, 339195097, 339492169, 339794641, 341958121, 341994131, 343017529, 343052833, + 344201441, 344255551, 344776301, 346080391, 348989101, 349752913, 350031973, 350244577, 351058753, 351177769, + 352802803, 352932337, 353815801, 353932801, 354062809, 356604421, 356836819, 357348601, 357872971, 358416577, + 359394751, 359727073, 360145633, 360375181, 360787771, 361307521, 361312337, 362569201, 363170837, 363430637, + 364550761, 365077373, 365231401, 366487201, 366532321, 366652201, 367559501, 367632301, 368016949, 368476501, + 369667561, 371011801, 371611153, 372167101, 373012777, 373533617, 373669453, 373906513, 374346361, 374988661, + 376957153, 377192353, 377334497, 377458849, 377806687, 377869031, 378792649, 379732501, 380137633, 382304161, + 384100001, 385175113, 385319089, 387072661, 388695301, 390609941, 390612221, 391014937, 392679737, 393611653, + 394723177, 396864469, 399156661, 399302581, 399647221, 400385701, 400557109, 401100881, 403095967, 403293313, + 405739681, 405782623, 407737201, 407889161, 409302001, 409458241, 410613809, 410680357, 411618241, 411851389, + 412836689, 413138881, 413429801, 413778817, 414216461, 414368641, 415200361, 415204501, 415476343, 416964241, + 417767201, 417779909, 418044563, 418226581, 418616161, 418617281, 418667401, 419184481, 420607441, 421942951, + 422429041, 422928101, 423384001, 423465001, 424175761, 424411501, 424431541, 425967301, 426174101, 426219649, + 426770437, 426783811, 427294141, 428180191, 428758201, 429135841, 429509837, 430046857, 430381921, 430646401, + 430733701, 432227449, 434042801, 435016187, 435358657, 435993301, 436465501, 437247841, 437462101, 437597101, + 437866087, 439309261, 441354497, 441650591, 441758461, 442050577, 442181291, 442543553, 444660421, 445429693, + 446414621, 446619617, 449501761, 450807481, 450866021, 450872573, 452990401, 453366029, 453967739, 454745773, + 455198563, 457274161, 457320533, 459785089, 460251733, 460585861, 461151121, 461272267, 461329601, 462587329, + 462639409, 462701513, 464012033, 464955857, 465505633, 466290949, 466758181, 467100937, 468410113, 468950021, + 470120257, 470268137, 470644021, 471535373, 471664513, 472814413, 473581057, 474892741, 474970501, 474983881, + 475723849, 478614067, 479962009, 480668347, 481153501, 481239361, 482488393, 482824669, 482921297, 483006889, + 483029821, 483945601, 484200289, 486063001, 486902929, 487896601, 488104681, 488169289, 488585521, 488656981, + 489994201, 490950461, 491738801, 493108481, 494288677, 495909871, 496109729, 496560349, 497148599, 497285713, + 498662561, 498706651, 498905189, 500747293, 501172241, 501472333, 502686713, 504870241, 505473263, 505532773, + 505798213, 506349421, 507142567, 507323521, 508606771, 509302873, 509551201, 510925609, 511098521, 511215521, + 511611673, 512330281, 514738981, 516045197, 516259657, 516764063, 517662001, 518216201, 518548801, 521501473, + 522390109, 522758233, 523756711, 526067821, 526359289, 526686889, 528013333, 528043753, 528220117, 530630701, + 531095029, 531681281, 532126801, 532758241, 532800133, 533429881, 534782293, 535252867, 535428577, 535517581, + 536003333, 536114197, 536342419, 536870911, 540207097, 540621181, 540654409, 540680141, 542497201, 542536457, + 544861633, 545550433, 545622401, 546102481, 546117301, 546322201, 548080513, 548989561, 549308761, 550132741, + 550230409, 550635373, 550853137, 551313001, 552573793, 553027201, 554487121, 554599051, 554964001, 555321007, + 555465601, 556001377, 556069849, 556095433, 556114609, 557165209, 558235109, 558900821, 558977761, 561448487, + 562367821, 563298061, 563947141, 564298489, 564689381, 565664761, 565707061, 567358513, 567596401, 568902001, + 568967221, 569332177, 569495809, 570941881, 572123521, 572228929, 572430769, 572567353, 572936869, 573817861, + 573862021, 574998841, 575326033, 576724219, 577210181, 577352641, 577613261, 579606301, 579956653, 581618143, + 582389641, 582799951, 585261637, 586706821, 587343541, 588049001, 591242653, 591822001, 592467451, 592468777, + 593682169, 593728489, 595405201, 595590841, 597537361, 597717121, 599135767, 599945293, 600893921, 601606487, + 602379181, 604584221, 605454917, 605961049, 606872449, 607148653, 607750681, 608421637, 608917753, 609361567, + 609813781, 611097401, 611374453, 611770513, 611812321, 611817421, 612006253, 613849601, 614742241, 615361183, + 615760133, 615895897, 616280897, 617087701, 619239457, 619365121, 619480601, 620169409, 620544961, 620755537, + 621769669, 622137601, 623735953, 624303241, 624732421, 625060801, 625482001, 626717471, 627886657, 628868467, + 629134081, 630496621, 630622753, 630811513, 631767943, 631974613, 633289807, 635155291, 635291077, 635319361, + 636287653, 636337073, 636936697, 638502913, 638837761, 639305921, 639807781, 640650931, 640977373, 643036321, + 643316461, 643552909, 644004817, 644453633, 644457551, 644731357, 644900257, 645556481, 648056449, 648328801, + 651011329, 651064681, 651151801, 651514753, 652469641, 653235841, 653260633, 655264369, 657732349, 659526601, + 659846021, 660095641, 660754117, 661122881, 661207177, 662134201, 663760681, 665462081, 668498321, 670976641, + 670987021, 671716921, 672103001, 672108193, 673778827, 675260477, 676359391, 678481693, 680983817, 681019921, + 681124207, 681303241, 682528687, 683316001, 683362681, 684350833, 686059921, 687741401, 689537441, 690035713, + 690562601, 691131349, 692535637, 693456521, 694116893, 696042901, 696321949, 696998251, 697821857, 698192041, + 698819711, 702683101, 705303457, 705351583, 706728377, 707691601, 709409993, 710382401, 710617861, 710721001, + 714490481, 717096641, 717653129, 717831211, 720767521, 722955773, 724160251, 724969087, 725508241, 731276521, + 732805681, 734166217, 736668013, 739444021, 739576801, 740988151, 741182401, 741214237, 742017181, 742550401, + 744500641, 745493761, 745745461, 746331041, 747406801, 748638001, 749172821, 749640161, 750632137, 751226401, + 751705597, 752186593, 753233717, 753574537, 753594001, 754020361, 754874257, 756205633, 756271909, 756980137, + 758581651, 758687581, 758901701, 759252367, 759266621, 759638881, 762699649, 763907741, 764033999, 764240611, + 765378241, 766303693, 766823797, 770201221, 770909107, 770937931, 771043201, 771337891, 772495777, 773131927, + 773807401, 775368901, 775896181, 776443769, 777218989, 781471001, 782823281, 784450393, 784777393, 784783477, + 784966297, 787085857, 787209277, 788046901, 788931361, 789082001, 790453049, 791118043, 792144161, 792145729, + 794201333, 794399041, 794937601, 795064909, 796072003, 796200901, 796560703, 797418997, 797834017, 799162561, + 799630753, 799898833, 799916101, 801093011, 801227269, 801866647, 804978721, 805505957, 805771501, 807115753, + 807218413, 808214161, 809790881, 810023881, 810455101, 811110301, 811478533, 811607777, 811730923, 815430533, + 815796413, 816024161, 816215401, 816549121, 817832329, 818401321, 819466201, 819743233, 822018961, 822531841, + 824389441, 826004467, 829512001, 830664451, 831933901, 832048447, 832127489, 832169857, 833610751, 837766217, + 839268139, 839280691, 839908217, 840749761, 841217653, 841660961, 842785841, 842824981, 842960981, 843161887, + 844545271, 845376533, 846961321, 848090377, 848755969, 849548671, 852432769, 854094781, 854868257, 855734401, + 857100421, 857902861, 858687103, 859096477, 860334301, 862082677, 862678081, 863196181, 863609113, 863984881, + 865242841, 867022747, 867110501, 867638201, 868088341, 868111597, 868691401, 870985223, 871157233, 871195561, + 871908481, 876850801, 877542481, 878492941, 878940833, 879995689, 880870513, 880922657, 883276549, 884304037, + 884952001, 886180429, 887795221, 888868441, 892740853, 893692819, 894264337, 896901461, 897087361, 897283213, + 899019353, 900736411, 901848301, 902566501, 903108821, 903390643, 905040953, 907378669, 907670501, 907711561, + 908005249, 910202509, 910867481, 911484421, 914348737, 914906539, 920375821, 920696653, 921858631, 922845241, + 923437213, 926756881, 927106561, 927877001, 929159941, 930530701, 932148253, 933729421, 935794081, 936421141, + 937675393, 938376181, 939947009, 940123801, 941056273, 941734657, 943271569, 944832533, 946034057, 946787377, + 947878081, 949317217, 949697233, 952893881, 954924013, 957600541, 957631249, 958131157, 958735681, 960269377, + 960946321, 962442001, 962489557, 962523169, 964412837, 965501857, 967266451, 967287751, 967790401, 968283247, + 968413217, 968751241, 969528337, 970586713, 971975071, 974113601, 974471243, 974774401, 975576281, 976396961, + 977483449, 979363153, 980056507, 980725201, 981484561, 983456377, 984133441, 984252001, 985052881, 985075681, + 987842101, 994133479, 995586373, 995650921, 997836841, 998489017, 998590601, 998596741, 998724481, 999828727, + 1002261781, 1003062061, 1005402133, 1005833971, 1006800829, 1008777001, 1008839999, 1009025263, 1009140161, 1011319501, + 1011333061, 1011570457, 1011909271, 1012438391, 1013833153, 1015339441, 1015626151, 1017748057, 1020515761, 1021281301, + 1022336611, 1024041853, 1024123501, 1024605121, 1025035129, 1026738161, 1027744453, 1028494429, 1034252929, 1034958601, + 1040234231, 1049584313, 1050102901, 1050535501, 1054999441, 1055009117, 1056121453, 1057426651, 1063212481, 1065508321, + 1065602281, 1066972301, 1069388497, 1070639389, 1070941987, 1071512749, 1071643249, 1072898711, 1073159281, 1073288581, + 1073484823, 1075100041, 1077133397, 1078467589, 1081798061, 1082472553, 1084241341, 1084444481, 1090858081, 1093150081, + 1093352833, 1093526353, 1094042321, 1097416321, 1098743563, 1100624857, 1101623381, 1101673501, 1102573501, 1102750013, + 1104194521, 1105038871, 1106529761, 1106580817, 1106595493, 1107138961, 1108135381, 1109304913, 1110582947, 1111205873, + 1111939201, 1112671603, 1114277221, 1116379301, 1117202557, 1117785881, 1117828001, 1117890019, 1119412321, 1120076281, + 1120981021, 1121176981, 1123406047, 1123625501, 1123727617, 1124396521, 1125038377, 1127040769, 1130933429, 1134367777, + 1138289041, 1138607233, 1139137057, 1140573601, 1142466151, 1147434289, 1148578201, 1150229761, 1151670001, 1153164097, + 1153440289, 1154343961, 1154691409, 1154987209, 1155939709, 1156761911, 1156993373, 1157839381, 1159421509, 1160844821, + 1163098249, 1163227759, 1164218641, 1165717129, 1166475601, 1166598217, 1168221121, 1168256953, 1168492417, 1173229201, + 1173545533, 1174300093, 1180970407, 1181566219, 1183338241, 1184554801, 1186325981, 1187235193, 1191153937, 1191216133, + 1192314817, 1192412033, 1192903531, 1193229577, 1193557093, 1195524181, 1196852273, 1198650961, 1198880261, 1200456577, + 1200778753, 1202142061, 1204205449, 1205606533, 1205772499, 1209998077, 1210393801, 1210562701, 1210653541, 1213619761, + 1217181061, 1217823517, 1217924159, 1219816261, 1219858921, 1220114377, 1221127013, 1222861271, 1223531677, 1223941657, + 1225128829, 1226230297, 1226855293, 1227220801, 1229491063, 1229751667, 1230446653, 1231362793, 1232445677, 1234125721, + 1234646533, 1235188597, 1235864033, 1236313501, 1236442421, 1238825569, 1242171349, 1242858317, 1249166881, 1249785941, + 1250656621, 1252236421, 1254277909, 1255665613, 1257102001, 1258903981, 1260332137, 1263293281, 1264145401, 1265477791, + 1266003461, 1266273793, 1266425101, 1267345081, 1269295201, 1269835201, 1270193401, 1270489621, 1270667353, 1272558739, + 1272866167, 1282447477, 1282568741, 1285636801, 1286298133, 1286298263, 1296613501, 1297443913, 1299072721, 1299784141, + 1299963601, 1301509249, 1301926081, 1302745481, 1306836001, 1307004641, 1307520469, 1307823661, 1308758533, 1308998741, + 1309723213, 1309983901, 1310329567, 1311255661, 1311616153, 1312332001, 1312573123, 1313396221, 1315858381, 1316169541, + 1318126321, 1318717531, 1319978701, 1319992181, 1320793813, 1321058213, 1323668917, 1325172421, 1325329297, 1328256247, + 1329174601, 1329431689, 1331973329, 1341010577, 1341926401, 1343575381, 1344597577, 1344975721, 1345514101, 1345523401, + 1347387361, 1348964401, 1350685001, 1351126261, 1352453257, 1353051517, 1356241321, 1356328121, 1357459183, 1362463807, + 1362515701, 1362742561, 1365662917, 1366587661, 1366608377, 1368769681, 1371908137, 1372681861, 1375322101, 1376799577, + 1378646179, 1379464633, 1382453333, 1383283129, 1385656829, 1386705433, 1388972353, 1389353941, 1389975149, 1391890033, + 1393851553, 1394640941, 1394746081, 1394942473, 1397357851, 1398883201, 1400859847, 1401840833, 1404008369, 1404253369, + 1406826241, 1406851249, 1409372779, 1413803197, 1414154827, 1414529533, 1415969101, 1417986901, 1421475031, 1424503849, + 1425860101, 1426319563, 1426534201, 1427771089, 1428966001, 1432354901, 1435091377, 1438648993, 1440231941, 1440922891, + 1441139641, 1441678411, 1442945689, 1443388481, 1443742273, 1446298309, 1446434677, 1446818651, 1448921633, 1451635201, + 1454282449, 1454445413, 1456527461, 1457378449, 1461307717, 1463065501, 1463178817, 1463992661, 1464568381, 1465908193, + 1465945417, 1468540477, 1468824787, 1469059481, 1469960377, 1470080501, 1470650851, 1471628401, 1472221921, 1473580001, + 1477289941, 1481626513, 1482274513, 1482876673, 1483873861, 1483918801, 1485061471, 1486564301, 1493114149, 1495190699, + 1497221281, 1497965713, 1499971457, 1499989177, 1500142001, 1501165097, 1502171117, 1502403121, 1503240559, 1503705601, + 1504139521, 1504832033, 1507746241, 1509156013, 1510870241, 1511558533, 1515175087, 1515785041, 1517039371, 1518014689, + 1518290707, 1520190341, 1521221473, 1522302121, 1526732803, 1529648231, 1529819971, 1530495289, 1532419099, 1532569681, + 1532755369, 1533343261, 1534063081, 1535020133, 1536112001, 1536251047, 1536883357, 1537433899, 1537641691, 1538012449, + 1539583921, 1539804001, 1540454761, 1540550413, 1541047813, 1541849761, 1541955409, 1544145121, 1545019813, 1545177581, + 1546106773, 1546340401, 1546508057, 1547140841, 1547543161, 1547712601, 1550924873, 1554270481, 1557118081, 1560312001, + 1560620041, 1561800833, 1565893201, 1566594551, 1567830241, 1568916311, 1574362441, 1574601601, 1577983489, 1578009401, + 1580449201, 1581576641, 1581714481, 1582783777, 1583230241, 1583658649, 1586436193, 1587650401, 1590394313, 1593706201, + 1595647351, 1595887921, 1598197201, 1602517949, 1603765021, 1603810561, 1603994701, 1609916491, 1609935913, 1612121473, + 1614508267, 1617795181, 1617921667, 1619447741, 1620646177, 1627103521, 1627898401, 1628692201, 1630062253, 1630307617, + 1631314609, 1632286673, 1632513601, 1633044241, 1636185601, 1637434657, 1637436457, 1637930893, 1638294661, 1639351981, + 1639846391, 1641971701, 1642814653, 1644637051, 1645413001, 1647225529, 1648076041, 1649430889, 1650265549, 1650682153, + 1654940509, 1655660761, 1656229921, 1656280033, 1656917377, 1659009601, 1661202113, 1668037621, 1668926629, 1669893661, + 1671603667, 1671714241, 1672125131, 1674091141, 1674658133, 1675978193, 1678274581, 1679130641, 1680901381, 1683174533, + 1685433413, 1686001861, 1687248001, 1691745821, 1692605041, 1694128129, 1695158921, 1696893101, 1698707377, 1699279441, + 1700250049, 1709909293, 1710753001, 1712392321, 1714322377, 1716160321, 1716714793, 1716774481, 1718013133, 1718088301, + 1719197621, 1721061497, 1721986313, 1722007169, 1722685777, 1725675451, 1726372441, 1731048937, 1731995497, 1732924001, + 1734059291, 1734285601, 1735071913, 1736481601, 1738687469, 1740214841, 1742288881, 1742815621, 1743166441, 1744605097, + 1746692641, 1746721681, 1749124829, 1750412161, 1754818561, 1757148121, 1760014561, 1766984389, 1767234613, 1769091241, + 1769267761, 1770236893, 1771303801, 1772267281, 1773582977, 1776439261, 1776820033, 1779649381, 1779892577, 1784306273, + 1784638309, 1785843547, 1786005521, 1787934881, 1790023861, 1791426787, 1792442737, 1792588813, 1794814103, 1801558201, + 1801774081, 1802510669, 1803768091, 1804906517, 1805947313, 1809888967, 1816408273, 1817067169, 1819829749, 1820306953, + 1821514633, 1828682101, 1828887061, 1831258601, 1835114401, 1837156049, 1837599769, 1839568981, 1841034961, 1841099261, + 1841479501, 1844028961, 1846171781, 1847811673, 1849964117, 1850233897, 1850598961, 1852496761, 1853926777, 1854084649, + 1854940231, 1856689453, 1857221281, 1858098497, 1858197961, 1860373241, 1861026133, 1861880689, 1862880401, 1866409861, + 1867906721, 1868682241, 1871987041, 1872937057, 1873177693, 1874634721, 1874849929, 1878691753, 1879111697, 1879623157, + 1879775501, 1883509633, 1883785681, 1885915841, 1894909141, 1894955311, 1897700113, 1899081757, 1899525601, 1900687381, + 1903447841, 1904658913, 1905958891, 1908088001, 1909566073, 1910134309, 1911197947, 1912950241, 1914303841, 1915391521, + 1916987593, 1917397637, 1920301951, 1921309633, 1922092567, 1922687293, 1923224689, 1923311317, 1923845801, 1924201501, + 1925042737, 1928903971, 1929862849, 1930403333, 1930447501, 1930534453, 1930915169, 1934350351, 1938264241, 1940048881, + 1943951041, 1944125633, 1945042181, 1950987193, 1952513369, 1952968753, 1957705177, 1959659857, 1960708261, 1963149553, + 1965007601, 1968002149, 1970065681, 1974474049, 1977257441, 1982123893, 1982826961, 1988071801, 1988713189, 1988835713, + 1988965861, 1989192277, 1991063449, 1995784961, 1995830761, 1996231189, 1996339649, 1997844157, 1998780001, 1999053601, + 1999111801, 1999743661, 2004299641, 2007646961, 2013554869, 2013834961, 2016481477, 2017021333, 2017509601, 2019564769, + 2021392369, 2021884343, 2027675701, 2028279793, 2028631361, 2028812399, 2029830409, 2030600833, 2036224321, 2043173273, + 2049293401, 2050617713, 2052149221, 2054711381, 2055634561, 2057267941, 2057835781, 2058072041, 2059739221, 2062612033, + 2068867841, 2070739441, 2072624761, 2076192007, 2081039297, 2081551753, 2082146617, 2083034113, 2083997441, 2085453649, + 2085882661, 2086645009, 2093300401, 2095627153, 2096046457, 2097317377, 2100292841, 2101470541, 2101744837, 2104994449, + 2106147457, 2107148761, 2114643217, 2115769633, 2115986557, 2116483027, 2116541221, 2117031263, 2117555641, 2118621097, + 2120096161, 2123601751, 2124078653, 2124691213, 2127197489, 2128104001, 2129304997, 2130134533, 2131004737, 2131811501, + 2140699681, 2140771609, 2141340833, 2144961253, 2147418113, 2147429509, 2152627801, 2154446641, 2155416251, 2156151313, + 2164282177, 2168431201, 2170282969, 2172155819, 2173499329, 2173540951, 2173579801, 2175126601, 2175406201, 2175646177, + 2177374321, 2177645557, 2178082901, 2178939221, 2180221201, 2182281601, 2182802689, 2185362233, 2187717761, 2193980881, + 2199617701, 2200115713, 2201924341, 2202101761, 2202205897, 2203649197, 2203856497, 2206095589, 2210578759, 2213431729, + 2216960929, 2217879901, 2219072017, 2224252801, 2229468697, 2231332357, 2233031701, 2240507821, 2241880033, 2241982009, + 2244932281, 2245519981, 2246762899, 2248354153, 2251732033, 2254314241, 2254757077, 2256197761, 2256748777, 2256751837, + 2262861901, 2269307587, 2274584089, 2283289681, 2284416181, 2289251669, 2289624793, 2290316377, 2290910257, 2291205461, + 2292068143, 2295209281, 2296995121, 2299190401, 2300628601, 2300795353, 2301745249, 2304120001, 2308966661, 2309241601, + 2309405617, 2311558021, 2311575001, 2315137261, 2320527613, 2323147201, 2324867399, 2329584217, 2330569541, 2331181621, + 2335341601, 2338157597, 2338728001, 2340460487, 2345907961, 2347597981, 2352371251, 2354453561, 2355230749, 2355320101, + 2355622721, 2355649921, 2355735089, 2358534361, 2360261989, 2370771181, 2370928337, 2371350101, 2372976563, 2374232977, + 2375415841, 2377166401, 2378309041, 2381782597, 2382678101, 2383164577, 2385574201, 2389072321, 2389544977, 2393708761, + 2394311233, 2398393661, 2404912501, 2411128441, 2412172153, 2412675721, 2413973071, 2422296241, 2423401681, 2425249601, + 2428648967, 2428870753, 2428986913, 2429407961, 2430697513, 2431136401, 2431144801, 2432761633, 2432860273, 2433791593, + 2434964321, 2434974433, 2435091221, 2436691321, 2437907779, 2438778413, 2442050353, 2442454561, 2443708961, 2444950561, + 2448039497, 2448374689, 2453473049, 2454285751, 2456536681, 2457846161, 2463713281, 2471205361, 2473120961, 2473189441, + 2473823353, 2474308069, 2474676949, 2476283239, 2477814193, 2478643907, 2480147521, 2480343553, 2482435981, 2482682131, + 2484408301, 2486017249, 2488420801, 2488591117, 2492480233, 2494660033, 2494984321, 2495834329, 2499327041, 2501012599, + 2501771329, 2502525637, 2504008609, 2506529257, 2506733189, 2507121037, 2508178843, 2513230891, 2516684801, 2519297089, + 2525070241, 2526566041, 2528291341, 2529410281, 2529827821, 2529854713, 2530351561, 2532630787, 2533465661, 2533797017, + 2535516173, 2537105761, 2539406281, 2539736257, 2540469901, 2541660367, 2542479481, 2544590161, 2545934077, 2548051801, + 2550139253, 2550780277, 2551365769, 2552418761, 2553272929, 2555391481, 2561945401, 2564536201, 2565186137, 2570087521, + 2571180247, 2575060949, 2575737361, 2577345541, 2582092189, 2582246701, 2582952769, 2583322381, 2584460701, 2588054401, + 2588582089, 2590663681, 2593065721, 2595276353, 2597289241, 2597294701, 2598933481, 2600611861, 2602343521, 2602378721, + 2604465013, 2604803701, 2611122229, 2611461529, 2613382201, 2614688801, 2616180821, 2617563031, 2621080741, 2621977627, + 2622993661, 2624549929, 2625903601, 2626783921, 2627284987, 2630643401, 2632605049, 2634284801, 2634804481, 2634820813, + 2638067881, 2639099233, 2642159809, 2642582251, 2646751249, 2646790033, 2648662777, 2649907201, 2650820329, 2651507713, + 2654716321, 2656494271, 2658630913, 2658696301, 2659265701, 2668095181, 2668469431, 2670972949, 2672605657, 2672651521, + 2676053333, 2677147201, 2677821121, 2678785621, 2681041843, 2682823681, 2683742491, 2684284441, 2687655169, 2688124001, + 2689427281, 2690408533, 2690867401, 2693739751, 2695115473, 2700818017, 2700891839, 2701878941, 2704957909, 2706863833, + 2707661501, 2716157989, 2716275007, 2717428033, 2719319513, 2721666817, 2721721939, 2723859001, 2725357249, 2733156029, + 2736316301, 2738184697, 2740336561, 2744329909, 2746021741, 2753333227, 2753538001, 2759392633, 2765323397, 2766006253, + 2767672189, 2769080161, 2769602333, 2774295577, 2777887297, 2778304273, 2779477741, 2781117721, 2781226477, 2786028337, + 2787998641, 2789218909, 2800352011, 2805762961, 2809635901, 2812672981, 2814748201, 2823570433, 2824256377, 2824804693, + 2824854913, 2828205397, 2832384133, 2832743713, 2837697773, 2837917633, 2840634109, 2840871041, 2841190381, 2847894377, + 2848466281, 2848722131, 2855046421, 2855071801, 2855512909, 2862066481, 2865483601, 2866005139, 2866527841, 2870377309, + 2871536561, 2872527733, 2872948321, 2874382853, 2877769501, 2881429741, 2882370481, 2885594497, 2887955533, 2890316801, + 2890414873, 2892426029, 2894667781, 2895004927, 2899294889, 2903776129, 2915953633, 2916247819, 2918295451, 2920691161, + 2923042141, 2924158001, 2929062533, 2929106753, 2930831641, 2931708097, 2932327549, 2936227603, 2936958181, 2941174897, + 2941343633, 2944555681, 2944677961, 2945208001, 2945549881, 2951136343, 2956724317, 2957320351, 2965700233, 2967053953, + 2968206601, 2974506841, 2975377429, 2976930001, 2978766341, 2980689601, 2986025677, 2987414977, 2990152901, 2993462713, + 2993495041, 2994098281, 2994415201, 2998202353, 2998919873, 3000688381, 3001561441, 3002647829, 3004443679, 3009628301, + 3011421841, 3014101261, 3015502181, 3016957381, 3017444761, 3018147217, 3018576689, 3019916461, 3025350343, 3026575553, + 3028586471, 3030393901, 3033332641, 3034402681, 3034817209, 3035375047, 3036079729, 3037295801, 3037781251, 3038880473, + 3039681457, 3041984353, 3042630533, 3048159841, 3050190163, 3056100623, 3056160929, 3057886591, 3058670677, 3059397793, + 3063685633, 3065998717, 3076505209, 3077122133, 3079496551, 3082054697, 3082068013, 3083053387, 3083537689, 3083884651, + 3088408429, 3089013313, 3091019777, 3094763851, 3099670657, 3103800701, 3112974481, 3114125071, 3115667521, 3120445697, + 3122287981, 3129914881, 3133899409, 3135040133, 3143282221, 3145410761, 3150972917, 3156599161, 3156643141, 3157579861, + 3163106953, 3166504273, 3167442721, 3170262409, 3172658653, 3175204531, 3175255717, 3178375201, 3181356263, 3181391641, + 3182606857, 3182655361, 3182891401, 3185472001, 3187035113, 3187421077, 3187939921, 3196397821, 3196431829, 3197565001, + 3197632441, 3197911001, 3197911741, 3199164901, 3205663921, 3207297773, 3208902491, 3212465437, 3215031751, 3217412881, + 3219808411, 3221580281, 3222693421, 3224143441, 3225081473, 3227082823, 3227209057, 3229131137, 3233558021, 3237992101, + 3242533897, 3248236309, 3250348417, 3250700737, 3252148621, 3257334541, 3258647809, 3258892801, 3261114601, 3263097641, + 3263568901, 3263626957, 3264820001, 3265122451, 3267417677, 3268506541, 3268841941, 3270933121, 3271999249, 3272030401, + 3272702497, 3274264033, 3275671969, 3276075709, 3277047649, 3278640289, 3280067129, 3282974857, 3287174129, 3288757249, + 3295362727, 3296403601, 3299246833, 3302322241, 3304307341, 3305829073, 3306686659, 3306957593, 3310858777, 3312489577, + 3312536569, 3313196881, 3315139717, 3320669437, 3323308501, 3323590463, 3323829169, 3328354801, 3332800021, 3334350781, + 3340214413, 3342005633, 3344191241, 3346172189, 3347908801, 3349218881, 3350993969, 3352091557, 3355382857, 3355953001, + 3357417181, 3359737921, 3360511981, 3369139201, 3371024521, 3371452921, 3371693063, 3372667121, 3373086601, 3381052177, + 3381901921, 3385842877, 3386603221, 3387014401, 3387487351, 3389030261, 3395091311, 3399205591, 3399890413, 3402234749, + 3407609221, 3407772817, 3407952169, 3408135121, 3409339393, 3411250081, 3411574801, 3411829693, 3412575097, 3415379701, + 3415832137, 3417522841, 3420143941, 3421845001, 3423222757, 3423580481, 3427050673, 3428133103, 3429457921, 3429982081, + 3430804297, 3432695921, 3432997537, 3433458073, 3434575327, 3435973837, 3440195713, 3443704261, 3449768513, 3450717901, + 3453900913, 3458257741, 3461861761, 3463907761, 3464236901, 3466158361, 3470716657, 3474335437, 3480174001, 3482161261, + 3485747521, 3489958697, 3491763493, 3492178873, 3492883081, 3493262761, 3497607433, 3504132113, 3512030497, 3512291021, + 3512369857, 3513604657, 3516565057, 3519318721, 3524086333, 3525088961, 3529119361, 3529864391, 3532687201, 3533662129, + 3533856913, 3538213381, 3542303047, 3543203333, 3548378341, 3549286001, 3549988261, 3552158521, 3553567057, 3557646401, + 3562963973, 3563340457, 3566428301, 3574891757, 3582711841, 3583249921, 3583604161, 3584800801, 3586833253, 3587553971, + 3589937261, 3590409439, 3593276353, 3594110081, 3596491907, 3596815169, 3598772761, 3602006101, 3605151241, 3611571121, + 3612298321, 3612825221, 3614770573, 3616574081, 3620631169, 3628526287, 3630596257, 3631828481, 3632452741, 3635993089, + 3649116277, 3649965281, 3650158849, 3651572609, 3656355841, 3658730893, 3662387977, 3662503093, 3663084541, 3668926801, + 3669587533, 3672754633, 3677180797, 3679657997, 3682471321, 3685647701, 3685775741, 3692307161, 3695628133, 3697278427, + 3700801861, 3705582073, 3705623281, 3708123301, 3708905341, 3709626961, 3712887289, 3713287801, 3713448769, 3718226401, + 3721486081, 3723410161, 3723699373, 3725016749, 3727828501, 3729097633, 3733761739, 3736293461, 3745192001, 3746101189, + 3749383681, 3751554581, 3751782737, 3754680403, 3756668401, 3759781369, 3760622689, 3760896133, 3762110881, 3767640601, + 3773061337, 3774337201, 3784123501, 3787491457, 3798040471, 3798626833, 3799111681, 3800084401, 3805699501, 3807112123, + 3807308269, 3807749821, 3809018947, 3813919453, 3817561777, 3817706621, 3821233121, 3827035237, 3832807681, 3833208961, + 3842941741, 3846174151, 3846532801, 3847106803, 3850058689, 3852800033, 3863326897, 3865604023, 3867183937, 3874471147, + 3874523017, 3875096893, 3875965417, 3886515361, 3886643801, 3887423437, 3887635753, 3891892421, 3891919417, 3894053311, + 3896079281, 3897241129, 3897869201, 3898906129, 3900327241, 3903711841, 3905533721, 3905876501, 3907577521, 3907752241, + 3912174421, 3914880337, 3914923211, 3915467341, 3915604421, 3915921241, 3918227437, 3922321561, 3926912669, 3929293061, + 3934940833, 3935864017, 3936123601, 3945165841, 3947233201, 3947383201, 3953408801, 3953949421, 3955572001, 3958597301, + 3958930441, 3959578801, 3960728641, 3962037061, 3966350203, 3967343161, 3971095301, 3973556837, 3979485931, 3982017601, + 3987528793, 3987960913, 3991124341, 3992697997, 3997536427, 4005660961, 4007365741, 4011996871, 4015548769, 4017684529, + 4018283501, 4020144133, 4026822577, 4027012021, 4027518961, 4028465873, 4028771849, 4031223841, 4034969401, 4034993269, + 4035498409, 4036395581, 4042538497, 4044601751, 4044884689, 4048493983, 4053267217, 4054039841, 4057195309, 4058433931, + 4059776533, 4060942381, 4061009971, 4064633821, 4067039461, 4067887501, 4068671881, 4071644893, 4075241633, 4075721921, + 4076009857, 4079665633, 4079682361, 4083376067, 4085074909, 4088147617, 4088838913, 4092929149, 4098258707, 4099180801, + 4100934241, 4103745689, 4105691393, 4108970251, 4109461709, 4109711581, 4110320663, 4113013141, 4115891893, 4117058221, + 4117447441, 4121286907, 4127050621, 4129914673, 4133928761, 4135847101, 4136916001, 4137262541, 4138838401, 4139015987, + 4150174393, 4155375349, 4157008813, 4162880401, 4166032873, 4183664101, 4185636781, 4186561633, 4187360341, 4191864013, + 4192060699, 4195843037, 4196323561, 4204344601, 4206006229, 4206295433, 4212105409, 4215885697, 4218900001, 4220122321, + 4232966251, 4234224601, 4237212061, 4243744201, 4244022301, 4244663651, 4247990917, 4250920459, 4251904273, 4255695013, + 4257003353, 4261352869, 4271267333, 4275011401, 4277526901, 4278305651, 4282867213, 4285148981, 4293088801, 4294901761, + } + + primes16 = [65536]byte{ + 2, 1, 1, 2, 1, 2, 1, 4, 3, 2, // 0-9 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 10-19 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 20-29 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30-39 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 40-49 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50-59 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60-69 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 70-79 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 80-89 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 90-99 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 100-109 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 110-119 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 120-129 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 130-139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 140-149 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 150-159 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 160-169 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 170-179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 180-189 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 190-199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 200-209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 210-219 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 220-229 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 230-239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 240-249 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 250-259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 260-269 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 270-279 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 280-289 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 290-299 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 300-309 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 310-319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 320-329 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 330-339 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 340-349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 350-359 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 360-369 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 370-379 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 380-389 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 390-399 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 400-409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 410-419 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 420-429 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 430-439 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 440-449 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 450-459 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 460-469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 470-479 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 480-489 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 490-499 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 500-509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 510-519 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 520-529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 530-539 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 540-549 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 550-559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 560-569 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 570-579 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 580-589 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 590-599 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 600-609 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 610-619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 620-629 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 630-639 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 640-649 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 650-659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 660-669 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 670-679 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 680-689 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 690-699 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 700-709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 710-719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 720-729 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 730-739 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 740-749 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 750-759 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 760-769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 770-779 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 780-789 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 790-799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 800-809 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 810-819 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 820-829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 830-839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 840-849 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 850-859 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 860-869 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 870-879 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 880-889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 890-899 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 900-909 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 910-919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 920-929 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 930-939 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 940-949 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 950-959 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 960-969 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 970-979 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 980-989 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 990-999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 1000-1009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1010-1019 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1020-1029 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 1030-1039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1040-1049 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1050-1059 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 1060-1069 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1070-1079 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1080-1089 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 1090-1099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1100-1109 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1110-1119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 1120-1129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 1130-1139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1140-1149 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 1150-1159 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1160-1169 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1170-1179 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1180-1189 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1190-1199 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1200-1209 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 1210-1219 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1220-1229 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 1230-1239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 1240-1249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 1250-1259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1260-1269 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 1270-1279 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1280-1289 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1290-1299 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 1300-1309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1310-1319 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 1320-1329 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 1330-1339 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 1340-1349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1350-1359 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1360-1369 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1370-1379 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 1380-1389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 1390-1399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 1400-1409 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1410-1419 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1420-1429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1430-1439 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1440-1449 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 1450-1459 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1460-1469 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1470-1479 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1480-1489 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 1490-1499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1500-1509 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1510-1519 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1520-1529 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1530-1539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 1540-1549 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1550-1559 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1560-1569 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 1570-1579 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 1580-1589 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1590-1599 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 1600-1609 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1610-1619 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 1620-1629 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 1630-1639 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1640-1649 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1650-1659 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 1660-1669 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 1670-1679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1680-1689 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 1690-1699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 1700-1709 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1710-1719 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 1720-1729 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1730-1739 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1740-1749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 1750-1759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1760-1769 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1770-1779 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 1780-1789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1790-1799 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1800-1809 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1810-1819 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1820-1829 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1830-1839 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 1840-1849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1850-1859 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1860-1869 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 1870-1879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 1880-1889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1890-1899 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1900-1909 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 1910-1919 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1920-1929 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 1930-1939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1940-1949 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 1950-1959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1960-1969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1970-1979 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1980-1989 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1990-1999 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2000-2009 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2010-2019 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 2020-2029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2030-2039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2040-2049 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 2050-2059 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 2060-2069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2070-2079 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 2080-2089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 2090-2099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2100-2109 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2110-2119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2120-2129 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2130-2139 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 2140-2149 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2150-2159 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2160-2169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 2170-2179 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2180-2189 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2190-2199 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2200-2209 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2210-2219 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 2220-2229 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2230-2239 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2240-2249 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 2250-2259 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2260-2269 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2270-2279 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2280-2289 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 2290-2299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2300-2309 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2310-2319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2320-2329 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2330-2339 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2340-2349 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 2350-2359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2360-2369 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2370-2379 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 2380-2389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 2390-2399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2400-2409 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2410-2419 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2420-2429 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2430-2439 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2440-2449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2450-2459 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2460-2469 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 2470-2479 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2480-2489 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2490-2499 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 2500-2509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2510-2519 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2520-2529 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 2530-2539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2540-2549 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 2550-2559 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2560-2569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 2570-2579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2580-2589 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2590-2599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2600-2609 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2610-2619 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2620-2629 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2630-2639 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2640-2649 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2650-2659 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2660-2669 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2670-2679 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 2680-2689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 2690-2699 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2700-2709 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 2710-2719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2720-2729 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2730-2739 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 2740-2749 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2750-2759 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2760-2769 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2770-2779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2780-2789 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2790-2799 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2800-2809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2810-2819 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2820-2829 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2830-2839 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2840-2849 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2850-2859 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2860-2869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2870-2879 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2880-2889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2890-2899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 2900-2909 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2910-2919 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2920-2929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2930-2939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2940-2949 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2950-2959 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2960-2969 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 2970-2979 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2980-2989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2990-2999 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3000-3009 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 3010-3019 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3020-3029 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3030-3039 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3040-3049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3050-3059 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 3060-3069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 3070-3079 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 3080-3089 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3090-3099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 3100-3109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3110-3119 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3120-3129 + 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 3130-3139 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 3140-3149 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3150-3159 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 3160-3169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3170-3179 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3180-3189 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3190-3199 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 3200-3209 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3210-3219 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 3220-3229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3230-3239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3240-3249 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 3250-3259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3260-3269 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 3270-3279 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3280-3289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3290-3299 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3300-3309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 3310-3319 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3320-3329 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3330-3339 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 3340-3349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3350-3359 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3360-3369 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3370-3379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3380-3389 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3390-3399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3400-3409 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 3410-3419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3420-3429 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3430-3439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 3440-3449 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3450-3459 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 3460-3469 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3470-3479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3480-3489 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3490-3499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3500-3509 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 3510-3519 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 3520-3529 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3530-3539 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 3540-3549 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 3550-3559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3560-3569 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3570-3579 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3580-3589 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3590-3599 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3600-3609 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 3610-3619 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 3620-3629 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3630-3639 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3640-3649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3650-3659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3660-3669 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 3670-3679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3680-3689 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3690-3699 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 3700-3709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 3710-3719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3720-3729 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 3730-3739 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3740-3749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3750-3759 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 3760-3769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 3770-3779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3780-3789 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 3790-3799 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 3800-3809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3810-3819 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3820-3829 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3830-3839 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3840-3849 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3850-3859 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3860-3869 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3870-3879 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 3880-3889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3890-3899 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3900-3909 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 3910-3919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3920-3929 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3930-3939 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 3940-3949 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3950-3959 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 3960-3969 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3970-3979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3980-3989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3990-3999 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 4000-4009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4010-4019 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 4020-4029 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 4030-4039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 4040-4049 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 4050-4059 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4060-4069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4070-4079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4080-4089 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4090-4099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4100-4109 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4110-4119 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4120-4129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 4130-4139 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4140-4149 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 4150-4159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4160-4169 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 4170-4179 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 4180-4189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4190-4199 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4200-4209 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 4210-4219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 4220-4229 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4230-4239 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4240-4249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4250-4259 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4260-4269 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4270-4279 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 4280-4289 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 4290-4299 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 4300-4309 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4310-4319 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 4320-4329 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 4330-4339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 4340-4349 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4350-4359 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4360-4369 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4370-4379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4380-4389 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 4390-4399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 4400-4409 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4410-4419 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4420-4429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4430-4439 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 4440-4449 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4450-4459 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4460-4469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4470-4479 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4480-4489 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 4490-4499 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4500-4509 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 4510-4519 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 4520-4529 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4530-4539 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 4540-4549 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4550-4559 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 4560-4569 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4570-4579 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 4580-4589 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4590-4599 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4600-4609 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4610-4619 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4620-4629 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4630-4639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4640-4649 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4650-4659 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4660-4669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4670-4679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4680-4689 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4690-4699 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4700-4709 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4710-4719 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 4720-4729 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4730-4739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4740-4749 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 4750-4759 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 4760-4769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4770-4779 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 4780-4789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4790-4799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4800-4809 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 4810-4819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4820-4829 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 4830-4839 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 4840-4849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4850-4859 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4860-4869 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 4870-4879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 4880-4889 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4890-4899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 4900-4909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 4910-4919 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4920-4929 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 4930-4939 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 4940-4949 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 4950-4959 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4960-4969 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 4970-4979 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4980-4989 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 4990-4999 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5000-5009 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5010-5019 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 5020-5029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 5030-5039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5040-5049 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 5050-5059 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5060-5069 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5070-5079 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5080-5089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5090-5099 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5100-5109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 5110-5119 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 5120-5129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5130-5139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5140-5149 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 5150-5159 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5160-5169 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 5170-5179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 5180-5189 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5190-5199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 5200-5209 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5210-5219 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5220-5229 + 1, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 5230-5239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5240-5249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5250-5259 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5260-5269 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5270-5279 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5280-5289 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5290-5299 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 5300-5309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5310-5319 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 5320-5329 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 5330-5339 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5340-5349 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 5350-5359 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5360-5369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5370-5379 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5380-5389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 5390-5399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5400-5409 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 5410-5419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5420-5429 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5430-5439 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 5440-5449 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5450-5459 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5460-5469 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 5470-5479 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 5480-5489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5490-5499 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 5500-5509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5510-5519 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5520-5529 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 5530-5539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5540-5549 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5550-5559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 5560-5569 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5570-5579 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5580-5589 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 5590-5599 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 5600-5609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5610-5619 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 5620-5629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5630-5639 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5640-5649 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 5650-5659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 5660-5669 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5670-5679 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 5680-5689 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5690-5699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5700-5709 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 5710-5719 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5720-5729 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5730-5739 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 5740-5749 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 5750-5759 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 5760-5769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 5770-5779 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5780-5789 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5790-5799 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5800-5809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5810-5819 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5820-5829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 5830-5839 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5840-5849 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5850-5859 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 5860-5869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5870-5879 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5880-5889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5890-5899 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 5900-5909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5910-5919 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 5920-5929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 5930-5939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5940-5949 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 5950-5959 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5960-5969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5970-5979 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 5980-5989 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5990-5999 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6000-6009 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6010-6019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6020-6029 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6030-6039 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 6040-6049 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 6050-6059 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6060-6069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6070-6079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6080-6089 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6090-6099 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6100-6109 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6110-6119 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6120-6129 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6130-6139 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6140-6149 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6150-6159 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6160-6169 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 6170-6179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6180-6189 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 6190-6199 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6200-6209 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6210-6219 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6220-6229 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6230-6239 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 6240-6249 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6250-6259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6260-6269 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 6270-6279 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 6280-6289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6290-6299 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6300-6309 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6310-6319 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 6320-6329 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6330-6339 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6340-6349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6350-6359 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6360-6369 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6370-6379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6380-6389 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 6390-6399 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6400-6409 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6410-6419 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 6420-6429 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6430-6439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6440-6449 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6450-6459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 6460-6469 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6470-6479 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6480-6489 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 6490-6499 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6500-6509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6510-6519 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6520-6529 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6530-6539 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6540-6549 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6550-6559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6560-6569 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6570-6579 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6580-6589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6590-6599 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 6600-6609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6610-6619 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6620-6629 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 6630-6639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6640-6649 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6650-6659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6660-6669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6670-6679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6680-6689 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6690-6699 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6700-6709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 6710-6719 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6720-6729 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 6730-6739 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6740-6749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6750-6759 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 6760-6769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6770-6779 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6780-6789 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6790-6799 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 6800-6809 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6810-6819 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 6820-6829 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6830-6839 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6840-6849 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6850-6859 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6860-6869 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6870-6879 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 6880-6889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6890-6899 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6900-6909 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 6910-6919 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 6920-6929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6930-6939 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 6940-6949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6950-6959 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6960-6969 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6970-6979 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6980-6989 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6990-6999 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7000-7009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 7010-7019 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7020-7029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7030-7039 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7040-7049 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7050-7059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 7060-7069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 7070-7079 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7080-7089 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7090-7099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 7100-7109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7110-7119 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 7120-7129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 7130-7139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7140-7149 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 7150-7159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7160-7169 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7170-7179 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7180-7189 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7190-7199 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7200-7209 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 7210-7219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7220-7229 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7230-7239 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 7240-7249 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 7250-7259 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7260-7269 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7270-7279 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7280-7289 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7290-7299 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 7300-7309 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7310-7319 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7320-7329 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 7330-7339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7340-7349 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7350-7359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 7360-7369 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7370-7379 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7380-7389 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7390-7399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7400-7409 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 7410-7419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7420-7429 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7430-7439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7440-7449 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 7450-7459 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7460-7469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7470-7479 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 7480-7489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7490-7499 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7500-7509 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7510-7519 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 7520-7529 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7530-7539 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 7540-7549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7550-7559 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7560-7569 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 7570-7579 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 7580-7589 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7590-7599 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 7600-7609 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7610-7619 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7620-7629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7630-7639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 7640-7649 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7650-7659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7660-7669 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 7670-7679 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7680-7689 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7690-7699 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7700-7709 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7710-7719 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 7720-7729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7730-7739 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7740-7749 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 7750-7759 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 7760-7769 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7770-7779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7780-7789 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 7790-7799 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7800-7809 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7810-7819 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 7820-7829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7830-7839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7840-7849 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7850-7859 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7860-7869 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 7870-7879 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7880-7889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7890-7899 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7900-7909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7910-7919 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7920-7929 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 7930-7939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7940-7949 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7950-7959 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 7960-7969 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7970-7979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7980-7989 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 7990-7999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8000-8009 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 8010-8019 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8020-8029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 8030-8039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8040-8049 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 8050-8059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8060-8069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8070-8079 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 8080-8089 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8090-8099 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8100-8109 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8110-8119 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 8120-8129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8130-8139 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 8140-8149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8150-8159 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8160-8169 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8170-8179 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8180-8189 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8190-8199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 8200-8209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8210-8219 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8220-8229 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 8230-8239 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8240-8249 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8250-8259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 8260-8269 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 8270-8279 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8280-8289 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 8290-8299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8300-8309 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 8310-8319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 8320-8329 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 8330-8339 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8340-8349 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 8350-8359 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8360-8369 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 8370-8379 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 8380-8389 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 8390-8399 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8400-8409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8410-8419 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 8420-8429 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8430-8439 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 8440-8449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8450-8459 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 8460-8469 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 8470-8479 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 8480-8489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8490-8499 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8500-8509 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8510-8519 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 8520-8529 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 8530-8539 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8540-8549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8550-8559 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 8560-8569 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8570-8579 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8580-8589 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 8590-8599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 8600-8609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8610-8619 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 8620-8629 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8630-8639 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 8640-8649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8650-8659 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8660-8669 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8670-8679 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8680-8689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8690-8699 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8700-8709 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 8710-8719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8720-8729 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8730-8739 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8740-8749 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8750-8759 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8760-8769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8770-8779 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8780-8789 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8790-8799 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 8800-8809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8810-8819 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8820-8829 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 8830-8839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8840-8849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8850-8859 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 8860-8869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8870-8879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8880-8889 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 8890-8899 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 8900-8909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8910-8919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 8920-8929 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8930-8939 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8940-8949 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8950-8959 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 8960-8969 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 8970-8979 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8980-8989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8990-8999 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9000-9009 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 9010-9019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 9020-9029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9030-9039 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 9040-9049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 9050-9059 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 9060-9069 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9070-9079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9080-9089 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9090-9099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 9100-9109 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9110-9119 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9120-9129 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 9130-9139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9140-9149 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9150-9159 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9160-9169 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 9170-9179 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9180-9189 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9190-9199 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9200-9209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9210-9219 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9220-9229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 9230-9239 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9240-9249 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 9250-9259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9260-9269 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9270-9279 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 9280-9289 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 9290-9299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9300-9309 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9310-9319 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 9320-9329 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9330-9339 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 9340-9349 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9350-9359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9360-9369 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9370-9379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9380-9389 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9390-9399 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 9400-9409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9410-9419 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9420-9429 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 9430-9439 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9440-9449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9450-9459 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 9460-9469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9470-9479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9480-9489 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9490-9499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9500-9509 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9510-9519 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9520-9529 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 9530-9539 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9540-9549 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 9550-9559 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 9560-9569 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9570-9579 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9580-9589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9590-9599 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9600-9609 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 9610-9619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9620-9629 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9630-9639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9640-9649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9650-9659 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9660-9669 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 9670-9679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 9680-9689 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 9690-9699 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 9700-9709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 9710-9719 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9720-9729 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 9730-9739 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 9740-9749 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9750-9759 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 9760-9769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9770-9779 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9780-9789 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9790-9799 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 9800-9809 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9810-9819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9820-9829 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9830-9839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9840-9849 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 9850-9859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9860-9869 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9870-9879 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 9880-9889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9890-9899 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 9900-9909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9910-9919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9920-9929 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9930-9939 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 9940-9949 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9950-9959 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9960-9969 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 9970-9979 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 9980-9989 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9990-9999 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 10000-10009 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10010-10019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10020-10029 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 10030-10039 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10040-10049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10050-10059 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 10060-10069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10070-10079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10080-10089 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 10090-10099 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 10100-10109 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 10110-10119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10120-10129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10130-10139 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10140-10149 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 10150-10159 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10160-10169 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10170-10179 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10180-10189 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 10190-10199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10200-10209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10210-10219 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 10220-10229 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10230-10239 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 10240-10249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10250-10259 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10260-10269 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 10270-10279 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10280-10289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10290-10299 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 10300-10309 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 10310-10319 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10320-10329 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 10330-10339 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10340-10349 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 10350-10359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 10360-10369 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10370-10379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10380-10389 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 10390-10399 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10400-10409 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10410-10419 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 10420-10429 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 10430-10439 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10440-10449 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 10450-10459 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10460-10469 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 10470-10479 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 10480-10489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10490-10499 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10500-10509 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 10510-10519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10520-10529 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 10530-10539 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10540-10549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10550-10559 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 10560-10569 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10570-10579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10580-10589 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10590-10599 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10600-10609 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10610-10619 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10620-10629 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10630-10639 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10640-10649 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10650-10659 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 10660-10669 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10670-10679 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10680-10689 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10690-10699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10700-10709 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10710-10719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 10720-10729 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 10730-10739 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10740-10749 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 10750-10759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10760-10769 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10770-10779 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 10780-10789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 10790-10799 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 10800-10809 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10810-10819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10820-10829 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 10830-10839 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10840-10849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10850-10859 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 10860-10869 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10870-10879 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10880-10889 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10890-10899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 10900-10909 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10910-10919 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10920-10929 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 10930-10939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10940-10949 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 10950-10959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10960-10969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10970-10979 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10980-10989 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 10990-10999 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 11000-11009 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11010-11019 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11020-11029 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11030-11039 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 11040-11049 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 11050-11059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11060-11069 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11070-11079 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 11080-11089 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 11090-11099 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11100-11109 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 11110-11119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11120-11129 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11130-11139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 11140-11149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11150-11159 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11160-11169 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11170-11179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11180-11189 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 11190-11199 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11200-11209 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 11210-11219 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11220-11229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 11230-11239 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 11240-11249 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11250-11259 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11260-11269 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 11270-11279 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 11280-11289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 11290-11299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11300-11309 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11310-11319 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 11320-11329 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 11330-11339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11340-11349 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 11350-11359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 11360-11369 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11370-11379 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 11380-11389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 11390-11399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11400-11409 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11410-11419 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 11420-11429 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11430-11439 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11440-11449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11450-11459 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11460-11469 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11470-11479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 11480-11489 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11490-11499 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 11500-11509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 11510-11519 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 11520-11529 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11530-11539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11540-11549 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 11550-11559 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11560-11569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 11570-11579 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11580-11589 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11590-11599 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11600-11609 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11610-11619 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11620-11629 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 11630-11639 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11640-11649 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11650-11659 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11660-11669 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11670-11679 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 11680-11689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11690-11699 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11700-11709 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 11710-11719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11720-11729 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11730-11739 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 11740-11749 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 11750-11759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11760-11769 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 11770-11779 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 11780-11789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11790-11799 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11800-11809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 11810-11819 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11820-11829 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 11830-11839 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 11840-11849 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11850-11859 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11860-11869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11870-11879 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 11880-11889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11890-11899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 11900-11909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11910-11919 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 11920-11929 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 11930-11939 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11940-11949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 11950-11959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11960-11969 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11970-11979 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11980-11989 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11990-11999 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12000-12009 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 12010-12019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12020-12029 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12030-12039 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 12040-12049 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 12050-12059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12060-12069 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 12070-12079 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12080-12089 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12090-12099 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 12100-12109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 12110-12119 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12120-12129 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12130-12139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12140-12149 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12150-12159 + 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 12160-12169 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 12170-12179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12180-12189 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12190-12199 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12200-12209 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12210-12219 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 12220-12229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 12230-12239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12240-12249 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 12250-12259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12260-12269 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12270-12279 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 12280-12289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12290-12299 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12300-12309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12310-12319 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 12320-12329 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12330-12339 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 12340-12349 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12350-12359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12360-12369 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 12370-12379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12380-12389 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12390-12399 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12400-12409 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12410-12419 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12420-12429 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 12430-12439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12440-12449 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 12450-12459 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12460-12469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12470-12479 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12480-12489 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12490-12499 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12500-12509 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 12510-12519 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 12520-12529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 12530-12539 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12540-12549 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 12550-12559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 12560-12569 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12570-12579 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12580-12589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12590-12599 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12600-12609 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 12610-12619 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12620-12629 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12630-12639 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12640-12649 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12650-12659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12660-12669 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12670-12679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 12680-12689 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12690-12699 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 12700-12709 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12710-12719 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12720-12729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12730-12739 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 12740-12749 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12750-12759 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12760-12769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12770-12779 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12780-12789 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 12790-12799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 12800-12809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12810-12819 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12820-12829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12830-12839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12840-12849 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 12850-12859 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 12860-12869 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12870-12879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12880-12889 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12890-12899 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12900-12909 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 12910-12919 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12920-12929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12930-12939 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12940-12949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12950-12959 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12960-12969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 12970-12979 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12980-12989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12990-12999 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 13000-13009 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13010-13019 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13020-13029 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 13030-13039 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 13040-13049 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13050-13059 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 13060-13069 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13070-13079 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13080-13089 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 13090-13099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 13100-13109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13110-13119 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 13120-13129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13130-13139 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13140-13149 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 13150-13159 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 13160-13169 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13170-13179 + 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 13180-13189 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13190-13199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13200-13209 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 13210-13219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 13220-13229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13230-13239 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13240-13249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 13250-13259 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 13260-13269 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13270-13279 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13280-13289 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 13290-13299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 13300-13309 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13310-13319 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13320-13329 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 13330-13339 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13340-13349 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13350-13359 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 13360-13369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13370-13379 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13380-13389 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 13390-13399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13400-13409 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13410-13419 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13420-13429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13430-13439 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13440-13449 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13450-13459 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 13460-13469 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 13470-13479 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 13480-13489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 13490-13499 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13500-13509 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 13510-13519 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13520-13529 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 13530-13539 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13540-13549 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13550-13559 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 13560-13569 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 13570-13579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13580-13589 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 13590-13599 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13600-13609 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 13610-13619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13620-13629 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 13630-13639 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 13640-13649 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13650-13659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13660-13669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13670-13679 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13680-13689 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 13690-13699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13700-13709 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13710-13719 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 13720-13729 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13730-13739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13740-13749 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 13750-13759 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 13760-13769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13770-13779 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13780-13789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 13790-13799 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 13800-13809 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13810-13819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13820-13829 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13830-13839 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13840-13849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 13850-13859 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13860-13869 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 13870-13879 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 13880-13889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13890-13899 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 13900-13909 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 13910-13919 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13920-13929 + 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 13930-13939 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13940-13949 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13950-13959 + 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 13960-13969 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13970-13979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13980-13989 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 13990-13999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 14000-14009 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14010-14019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14020-14029 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 14030-14039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14040-14049 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 14050-14059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14060-14069 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14070-14079 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 14080-14089 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14090-14099 + 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 14100-14109 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 14110-14119 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14120-14129 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14130-14139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 14140-14149 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 14150-14159 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14160-14169 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 14170-14179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14180-14189 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 14190-14199 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 14200-14209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14210-14219 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14220-14229 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14230-14239 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 14240-14249 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 14250-14259 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14260-14269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14270-14279 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14280-14289 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 14290-14299 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 14300-14309 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14310-14319 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 14320-14329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14330-14339 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 14340-14349 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14350-14359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 14360-14369 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14370-14379 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 14380-14389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14390-14399 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14400-14409 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14410-14419 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14420-14429 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 14430-14439 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 14440-14449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14450-14459 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14460-14469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 14470-14479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14480-14489 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14490-14499 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 14500-14509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14510-14519 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14520-14529 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 14530-14539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 14540-14549 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14550-14559 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 14560-14569 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14570-14579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14580-14589 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 14590-14599 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14600-14609 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14610-14619 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 14620-14629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 14630-14639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14640-14649 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 14650-14659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14660-14669 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14670-14679 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 14680-14689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14690-14699 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14700-14709 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 14710-14719 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14720-14729 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14730-14739 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 14740-14749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 14750-14759 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14760-14769 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14770-14779 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 14780-14789 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 14790-14799 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14800-14809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14810-14819 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14820-14829 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14830-14839 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14840-14849 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14850-14859 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 14860-14869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 14870-14879 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14880-14889 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 14890-14899 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14900-14909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14910-14919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 14920-14929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 14930-14939 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14940-14949 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 14950-14959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14960-14969 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14970-14979 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 14980-14989 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14990-14999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15000-15009 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 15010-15019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15020-15029 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 15030-15039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15040-15049 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15050-15059 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15060-15069 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 15070-15079 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15080-15089 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15090-15099 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 15100-15109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15110-15119 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15120-15129 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 15130-15139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15140-15149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15150-15159 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15160-15169 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15170-15179 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15180-15189 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 15190-15199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15200-15209 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 15210-15219 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15220-15229 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15230-15239 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15240-15249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15250-15259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 15260-15269 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 15270-15279 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 15280-15289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 15290-15299 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15300-15309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 15310-15319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 15320-15329 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15330-15339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15340-15349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 15350-15359 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15360-15369 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 15370-15379 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15380-15389 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15390-15399 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15400-15409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15410-15419 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 15420-15429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15430-15439 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15440-15449 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15450-15459 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15460-15469 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 15470-15479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15480-15489 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 15490-15499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15500-15509 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15510-15519 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 15520-15529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15530-15539 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15540-15549 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15550-15559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15560-15569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15570-15579 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 15580-15589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15590-15599 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 15600-15609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15610-15619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15620-15629 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15630-15639 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 15640-15649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15650-15659 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15660-15669 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15670-15679 + 3, 2, 1, 44, 43, 42, 41, 40, 39, 38, // 15680-15689 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 15690-15699 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 15700-15709 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15710-15719 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15720-15729 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 15730-15739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15740-15749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15750-15759 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15760-15769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15770-15779 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15780-15789 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15790-15799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 15800-15809 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15810-15819 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 15820-15829 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 15830-15839 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15840-15849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 15850-15859 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15860-15869 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15870-15879 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 15880-15889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15890-15899 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15900-15909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 15910-15919 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15920-15929 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 15930-15939 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15940-15949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15950-15959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15960-15969 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 15970-15979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15980-15989 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15990-15999 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 16000-16009 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16010-16019 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16020-16029 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16030-16039 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16040-16049 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16050-16059 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 16060-16069 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16070-16079 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16080-16089 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16090-16099 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 16100-16109 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16110-16119 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 16120-16129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16130-16139 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 16140-16149 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 16150-16159 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16160-16169 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16170-16179 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 16180-16189 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16190-16199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16200-16209 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16210-16219 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 16220-16229 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16230-16239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16240-16249 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16250-16259 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16260-16269 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 16270-16279 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16280-16289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16290-16299 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16300-16309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 16310-16319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16320-16329 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 16330-16339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16340-16349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16350-16359 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 16360-16369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16370-16379 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 16380-16389 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16390-16399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16400-16409 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16410-16419 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16420-16429 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16430-16439 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16440-16449 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16450-16459 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16460-16469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16470-16479 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16480-16489 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 16490-16499 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16500-16509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 16510-16519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 16520-16529 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16530-16539 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16540-16549 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 16550-16559 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16560-16569 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 16570-16579 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16580-16589 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16590-16599 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 16600-16609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16610-16619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16620-16629 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 16630-16639 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16640-16649 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16650-16659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16660-16669 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16670-16679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16680-16689 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 16690-16699 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 16700-16709 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16710-16719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16720-16729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16730-16739 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 16740-16749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16750-16759 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16760-16769 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16770-16779 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 16780-16789 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16790-16799 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16800-16809 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16810-16819 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 16820-16829 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16830-16839 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 16840-16849 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16850-16859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16860-16869 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16870-16879 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 16880-16889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16890-16899 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16900-16909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16910-16919 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16920-16929 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16930-16939 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 16940-16949 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16950-16959 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 16960-16969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16970-16979 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16980-16989 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16990-16999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17000-17009 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17010-17019 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 17020-17029 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17030-17039 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17040-17049 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 17050-17059 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17060-17069 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 17070-17079 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17080-17089 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 17090-17099 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17100-17109 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17110-17119 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 17120-17129 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 17130-17139 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17140-17149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 17150-17159 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 17160-17169 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17170-17179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17180-17189 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17190-17199 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 17200-17209 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 17210-17219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17220-17229 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17230-17239 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17240-17249 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 17250-17259 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 17260-17269 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 17270-17279 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17280-17289 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 17290-17299 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17300-17309 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17310-17319 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17320-17329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17330-17339 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17340-17349 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17350-17359 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17360-17369 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17370-17379 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 17380-17389 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17390-17399 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17400-17409 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17410-17419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17420-17429 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17430-17439 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 17440-17449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17450-17459 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17460-17469 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17470-17479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17480-17489 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 17490-17499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 17500-17509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 17510-17519 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17520-17529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 17530-17539 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17540-17549 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17550-17559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 17560-17569 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17570-17579 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17580-17589 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 17590-17599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 17600-17609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17610-17619 + 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 17620-17629 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 17630-17639 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17640-17649 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 17650-17659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 17660-17669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17670-17679 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 17680-17689 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17690-17699 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17700-17709 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 17710-17719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 17720-17729 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17730-17739 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17740-17749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17750-17759 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 17760-17769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17770-17779 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17780-17789 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17790-17799 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 17800-17809 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17810-17819 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17820-17829 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17830-17839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17840-17849 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17850-17859 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 17860-17869 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17870-17879 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17880-17889 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17890-17899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17900-17909 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17910-17919 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 17920-17929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17930-17939 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17940-17949 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17950-17959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17960-17969 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17970-17979 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 17980-17989 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 17990-17999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18000-18009 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 18010-18019 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18020-18029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18030-18039 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 18040-18049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18050-18059 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18060-18069 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 18070-18079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 18080-18089 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 18090-18099 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18100-18109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18110-18119 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18120-18129 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 18130-18139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 18140-18149 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18150-18159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18160-18169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18170-18179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18180-18189 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18190-18199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18200-18209 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18210-18219 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 18220-18229 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 18230-18239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18240-18249 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 18250-18259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 18260-18269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18270-18279 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 18280-18289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18290-18299 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18300-18309 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 18310-18319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18320-18329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18330-18339 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18340-18349 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18350-18359 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18360-18369 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 18370-18379 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18380-18389 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18390-18399 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18400-18409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18410-18419 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18420-18429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 18430-18439 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 18440-18449 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18450-18459 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18460-18469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18470-18479 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18480-18489 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 18490-18499 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18500-18509 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18510-18519 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 18520-18529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18530-18539 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18540-18549 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 18550-18559 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 18560-18569 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18570-18579 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 18580-18589 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 18590-18599 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18600-18609 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 18610-18619 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18620-18629 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 18630-18639 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18640-18649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18650-18659 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18660-18669 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18670-18679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18680-18689 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18690-18699 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18700-18709 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 18710-18719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18720-18729 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18730-18739 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 18740-18749 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 18750-18759 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18760-18769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18770-18779 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18780-18789 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 18790-18799 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 18800-18809 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 18810-18819 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18820-18829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 18830-18839 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18840-18849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 18850-18859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 18860-18869 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 18870-18879 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18880-18889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18890-18899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18900-18909 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 28, // 18910-18919 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 18920-18929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18930-18939 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 18940-18949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 18950-18959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18960-18969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 18970-18979 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18980-18989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18990-18999 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 19000-19009 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 19010-19019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19020-19029 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 19030-19039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19040-19049 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19050-19059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 19060-19069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19070-19079 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 19080-19089 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 19090-19099 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19100-19109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19110-19119 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19120-19129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 19130-19139 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 19140-19149 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19150-19159 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 19160-19169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19170-19179 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 19180-19189 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 19190-19199 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19200-19209 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19210-19219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19220-19229 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19230-19239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 19240-19249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 19250-19259 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19260-19269 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 19270-19279 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19280-19289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19290-19299 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 19300-19309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 19310-19319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19320-19329 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 19330-19339 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 19340-19349 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 19350-19359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19360-19369 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19370-19379 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19380-19389 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19390-19399 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19400-19409 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19410-19419 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 19420-19429 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19430-19439 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19440-19449 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19450-19459 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19460-19469 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19470-19479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19480-19489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19490-19499 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 19500-19509 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19510-19519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19520-19529 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19530-19539 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19540-19549 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19550-19559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19560-19569 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19570-19579 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19580-19589 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19590-19599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 52, // 19600-19609 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 19610-19619 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 19620-19629 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 19630-19639 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19640-19649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19650-19659 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19660-19669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19670-19679 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19680-19689 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 19690-19699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 19700-19709 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19710-19719 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19720-19729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19730-19739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19740-19749 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 19750-19759 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19760-19769 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 19770-19779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19780-19789 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19790-19799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19800-19809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 19810-19819 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19820-19829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19830-19839 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19840-19849 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19850-19859 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 19860-19869 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19870-19879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 19880-19889 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 19890-19899 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19900-19909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 19910-19919 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19920-19929 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19930-19939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19940-19949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19950-19959 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19960-19969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19970-19979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19980-19989 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 19990-19999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20000-20009 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20010-20019 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 20020-20029 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20030-20039 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 20040-20049 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20050-20059 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 20060-20069 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20070-20079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20080-20089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20090-20099 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 20100-20109 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20110-20119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 20120-20129 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20130-20139 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 20140-20149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20150-20159 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20160-20169 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20170-20179 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20180-20189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20190-20199 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20200-20209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20210-20219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20220-20229 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 20230-20239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20240-20249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20250-20259 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 20260-20269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20270-20279 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20280-20289 + 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 20290-20299 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20300-20309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20310-20319 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20320-20329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 20330-20339 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 20340-20349 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 20350-20359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 20360-20369 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20370-20379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 20380-20389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 20390-20399 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 20400-20409 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 20410-20419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20420-20429 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20430-20439 + 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 20440-20449 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 20450-20459 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20460-20469 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 20470-20479 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 20480-20489 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20490-20499 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 20500-20509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20510-20519 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20520-20529 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 20530-20539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 20540-20549 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20550-20559 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 20560-20569 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20570-20579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20580-20589 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 20590-20599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20600-20609 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20610-20619 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 20620-20629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 20630-20639 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20640-20649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20650-20659 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20660-20669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20670-20679 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20680-20689 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 20690-20699 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20700-20709 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 20710-20719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20720-20729 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20730-20739 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 20740-20749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 20750-20759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20760-20769 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 20770-20779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 20780-20789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20790-20799 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 40, // 20800-20809 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 20810-20819 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 20820-20829 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20830-20839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 20840-20849 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 20850-20859 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20860-20869 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 20870-20879 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20880-20889 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 20890-20899 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20900-20909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20910-20919 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 20920-20929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 20930-20939 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 20940-20949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 20950-20959 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20960-20969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20970-20979 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20980-20989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20990-20999 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21000-21009 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 21010-21019 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21020-21029 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 21030-21039 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21040-21049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21050-21059 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 21060-21069 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21070-21079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 21080-21089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21090-21099 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21100-21109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21110-21119 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21120-21129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21130-21139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 21140-21149 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21150-21159 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 21160-21169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21170-21179 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21180-21189 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21190-21199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21200-21209 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21210-21219 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 21220-21229 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21230-21239 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 21240-21249 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21250-21259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21260-21269 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21270-21279 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 21280-21289 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 21290-21299 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21300-21309 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 21310-21319 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21320-21329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21330-21339 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 21340-21349 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21350-21359 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21360-21369 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 21370-21379 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21380-21389 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21390-21399 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 21400-21409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 21410-21419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21420-21429 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 21430-21439 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21440-21449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21450-21459 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21460-21469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21470-21479 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21480-21489 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 21490-21499 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21500-21509 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21510-21519 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 21520-21529 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21530-21539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21540-21549 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 21550-21559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 21560-21569 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21570-21579 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 21580-21589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21590-21599 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21600-21609 + 1, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 21610-21619 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21620-21629 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21630-21639 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 21640-21649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21650-21659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21660-21669 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 21670-21679 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21680-21689 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21690-21699 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21700-21709 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21710-21719 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21720-21729 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 21730-21739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21740-21749 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21750-21759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21760-21769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21770-21779 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 21780-21789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21790-21799 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21800-21809 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21810-21819 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21820-21829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21830-21839 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21840-21849 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21850-21859 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21860-21869 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21870-21879 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21880-21889 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21890-21899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21900-21909 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21910-21919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21920-21929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21930-21939 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21940-21949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21950-21959 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21960-21969 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21970-21979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21980-21989 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21990-21999 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22000-22009 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 22010-22019 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22020-22029 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 22030-22039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22040-22049 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22050-22059 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 22060-22069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 22070-22079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22080-22089 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 22090-22099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 22100-22109 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22110-22119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 22120-22129 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 22130-22139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22140-22149 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 22150-22159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22160-22169 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22170-22179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 22180-22189 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 22190-22199 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 22200-22209 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22210-22219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 22220-22229 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22230-22239 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22240-22249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22250-22259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22260-22269 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 22270-22279 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22280-22289 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22290-22299 + 3, 2, 1, 4, 3, 2, 1, 36, 35, 34, // 22300-22309 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22310-22319 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22320-22329 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22330-22339 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 22340-22349 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22350-22359 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 22360-22369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22370-22379 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22380-22389 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22390-22399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 22400-22409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22410-22419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22420-22429 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22430-22439 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22440-22449 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 22450-22459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22460-22469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22470-22479 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 22480-22489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22490-22499 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22500-22509 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 22510-22519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22520-22529 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22530-22539 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 22540-22549 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22550-22559 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22560-22569 + 1, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 22570-22579 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22580-22589 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22590-22599 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22600-22609 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 22610-22619 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22620-22629 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 22630-22639 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22640-22649 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22650-22659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 22660-22669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22670-22679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22680-22689 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 22690-22699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 22700-22709 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22710-22719 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22720-22729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 22730-22739 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22740-22749 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22750-22759 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 22760-22769 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22770-22779 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 22780-22789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22790-22799 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22800-22809 + 1, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 22810-22819 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22820-22829 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22830-22839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22840-22849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 22850-22859 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22860-22869 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 22870-22879 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 22880-22889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22890-22899 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 22900-22909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22910-22919 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22920-22929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22930-22939 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 22940-22949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22950-22959 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22960-22969 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 22970-22979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22980-22989 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22990-22999 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23000-23009 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23010-23019 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 23020-23029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23030-23039 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23040-23049 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 23050-23059 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23060-23069 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23070-23079 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23080-23089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 23090-23099 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23100-23109 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23110-23119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23120-23129 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23130-23139 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23140-23149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23150-23159 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23160-23169 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23170-23179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23180-23189 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23190-23199 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 23200-23209 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23210-23219 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 23220-23229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23230-23239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23240-23249 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23250-23259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 23260-23269 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 23270-23279 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23280-23289 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 23290-23299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23300-23309 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23310-23319 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23320-23329 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 23330-23339 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23340-23349 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23350-23359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23360-23369 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 23370-23379 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23380-23389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 23390-23399 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23400-23409 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23410-23419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23420-23429 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23430-23439 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23440-23449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 23450-23459 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23460-23469 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 23470-23479 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23480-23489 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23490-23499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 23500-23509 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23510-23519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23520-23529 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 23530-23539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23540-23549 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23550-23559 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 23560-23569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23570-23579 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23580-23589 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 23590-23599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 23600-23609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23610-23619 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 23620-23629 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 23630-23639 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 23640-23649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23650-23659 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 23660-23669 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 23670-23679 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 23680-23689 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 23690-23699 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23700-23709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 23710-23719 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23720-23729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23730-23739 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 23740-23749 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23750-23759 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23760-23769 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23770-23779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 23780-23789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23790-23799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23800-23809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 23810-23819 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23820-23829 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 23830-23839 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23840-23849 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23850-23859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 23860-23869 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 23870-23879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23880-23889 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 23890-23899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23900-23909 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23910-23919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 23920-23929 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 23930-23939 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23940-23949 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23950-23959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23960-23969 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23970-23979 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23980-23989 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23990-23999 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24000-24009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24010-24019 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 24020-24029 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24030-24039 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 24040-24049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24050-24059 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24060-24069 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24070-24079 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24080-24089 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24090-24099 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 24100-24109 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24110-24119 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24120-24129 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 24130-24139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24140-24149 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24150-24159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 24160-24169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 24170-24179 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24180-24189 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24190-24199 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 24200-24209 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24210-24219 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 24220-24229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24230-24239 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24240-24249 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 24250-24259 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24260-24269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24270-24279 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 24280-24289 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 24290-24299 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24300-24309 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24310-24319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24320-24329 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 24330-24339 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24340-24349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24350-24359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24360-24369 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 24370-24379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24380-24389 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24390-24399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24400-24409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 24410-24419 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24420-24429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24430-24439 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 24440-24449 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24450-24459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24460-24469 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24470-24479 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24480-24489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 24490-24499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24500-24509 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 24510-24519 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24520-24529 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 24530-24539 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24540-24549 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24550-24559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24560-24569 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24570-24579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24580-24589 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 24590-24599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24600-24609 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24610-24619 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24620-24629 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 24630-24639 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24640-24649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24650-24659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24660-24669 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24670-24679 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24680-24689 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24690-24699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 24700-24709 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24710-24719 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24720-24729 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 24730-24739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 24740-24749 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24750-24759 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 24760-24769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24770-24779 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24780-24789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 24790-24799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24800-24809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24810-24819 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24820-24829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24830-24839 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24840-24849 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 24850-24859 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24860-24869 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24870-24879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 24880-24889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24890-24899 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 24900-24909 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 24910-24919 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 24920-24929 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24930-24939 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 24940-24949 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 24950-24959 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24960-24969 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 24970-24979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 24980-24989 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24990-24999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25000-25009 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 25010-25019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25020-25029 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 25030-25039 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25040-25049 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 25050-25059 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25060-25069 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25070-25079 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25080-25089 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 25090-25099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25100-25109 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 25110-25119 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 25120-25129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25130-25139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25140-25149 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25150-25159 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25160-25169 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25170-25179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 25180-25189 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 25190-25199 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25200-25209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 25210-25219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 25220-25229 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25230-25239 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 25240-25249 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25250-25259 + 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 25260-25269 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 25270-25279 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25280-25289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25290-25299 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 25300-25309 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25310-25319 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25320-25329 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 25330-25339 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 25340-25349 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25350-25359 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25360-25369 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 25370-25379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25380-25389 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25390-25399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 25400-25409 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25410-25419 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 25420-25429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 25430-25439 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25440-25449 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 25450-25459 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25460-25469 + 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 25470-25479 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 25480-25489 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 25490-25499 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 25500-25509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25510-25519 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25520-25529 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 25530-25539 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25540-25549 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25550-25559 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25560-25569 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 25570-25579 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25580-25589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25590-25599 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25600-25609 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25610-25619 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25620-25629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 25630-25639 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25640-25649 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25650-25659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25660-25669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 25670-25679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25680-25689 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25690-25699 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25700-25709 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 25710-25719 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25720-25729 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25730-25739 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 25740-25749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 25750-25759 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25760-25769 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 25770-25779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25780-25789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25790-25799 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25800-25809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 25810-25819 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25820-25829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25830-25839 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 25840-25849 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25850-25859 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25860-25869 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 25870-25879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 25880-25889 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25890-25899 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25900-25909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25910-25919 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25920-25929 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 25930-25939 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25940-25949 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25950-25959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 25960-25969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25970-25979 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25980-25989 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 25990-25999 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 26000-26009 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26010-26019 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26020-26029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26030-26039 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26040-26049 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 26050-26059 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 26060-26069 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26070-26079 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 26080-26089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26090-26099 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26100-26109 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 26110-26119 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 26120-26129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26130-26139 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26140-26149 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26150-26159 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26160-26169 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26170-26179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 26180-26189 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26190-26199 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 26200-26209 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26210-26219 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26220-26229 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 26230-26239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 26240-26249 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26250-26259 + 1, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 26260-26269 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 26270-26279 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26280-26289 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 26290-26299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26300-26309 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26310-26319 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26320-26329 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26330-26339 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26340-26349 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 26350-26359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26360-26369 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26370-26379 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26380-26389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 26390-26399 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26400-26409 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26410-26419 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26420-26429 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 26430-26439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 26440-26449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 26450-26459 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26460-26469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 26470-26479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26480-26489 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26490-26499 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26500-26509 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 26510-26519 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26520-26529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 26530-26539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26540-26549 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26550-26559 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26560-26569 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26570-26579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26580-26589 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 26590-26599 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 26600-26609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26610-26619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26620-26629 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26630-26639 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 26640-26649 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26650-26659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26660-26669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26670-26679 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 26680-26689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 26690-26699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26700-26709 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 26710-26719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 26720-26729 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 26730-26739 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26740-26749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 26750-26759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26760-26769 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26770-26779 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26780-26789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26790-26799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26800-26809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26810-26819 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26820-26829 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 26830-26839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26840-26849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26850-26859 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 26860-26869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 26870-26879 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26880-26889 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 26890-26899 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26900-26909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26910-26919 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 26920-26929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26930-26939 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26940-26949 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 26950-26959 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 26960-26969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26970-26979 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26980-26989 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26990-26999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27000-27009 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27010-27019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27020-27029 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27030-27039 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27040-27049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27050-27059 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27060-27069 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 27070-27079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27080-27089 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27090-27099 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 27100-27109 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27110-27119 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 27120-27129 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27130-27139 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 27140-27149 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27150-27159 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27160-27169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 27170-27179 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27180-27189 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27190-27199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27200-27209 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27210-27219 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27220-27229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27230-27239 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27240-27249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 27250-27259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27260-27269 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27270-27279 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27280-27289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 27290-27299 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27300-27309 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27310-27319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 27320-27329 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 27330-27339 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27340-27349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27350-27359 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 27360-27369 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 27370-27379 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27380-27389 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 27390-27399 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 27400-27409 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27410-27419 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27420-27429 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 27430-27439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 27440-27449 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 27450-27459 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27460-27469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27470-27479 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 27480-27489 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27490-27499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 27500-27509 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27510-27519 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 27520-27529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27530-27539 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27540-27549 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 27550-27559 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27560-27569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27570-27579 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 27580-27589 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27590-27599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27600-27609 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27610-27619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27620-27629 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27630-27639 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27640-27649 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 27650-27659 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27660-27669 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27670-27679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27680-27689 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27690-27699 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 27700-27709 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 27710-27719 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27720-27729 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 27730-27739 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 27740-27749 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27750-27759 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 27760-27769 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 27770-27779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27780-27789 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 27790-27799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 27800-27809 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27810-27819 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 27820-27829 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27830-27839 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27840-27849 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 27850-27859 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 27860-27869 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27870-27879 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 27880-27889 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 27890-27899 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27900-27909 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 27910-27919 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27920-27929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27930-27939 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 27940-27949 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 27950-27959 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 27960-27969 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27970-27979 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 27980-27989 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27990-27999 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28000-28009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 28010-28019 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28020-28029 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28030-28039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28040-28049 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 28050-28059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28060-28069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28070-28079 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28080-28089 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28090-28099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28100-28109 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28110-28119 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 28120-28129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28130-28139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28140-28149 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28150-28159 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 28160-28169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28170-28179 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 28180-28189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28190-28199 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28200-28209 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 28210-28219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 48, // 28220-28229 + 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, // 28230-28239 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 28240-28249 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 28250-28259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28260-28269 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 28270-28279 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28280-28289 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28290-28299 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28300-28309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 28310-28319 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 28320-28329 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28330-28339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28340-28349 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 28350-28359 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 28360-28369 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28370-28379 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28380-28389 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 28390-28399 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 28400-28409 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28410-28419 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 28420-28429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28430-28439 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 28440-28449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28450-28459 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 28460-28469 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 28470-28479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28480-28489 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 28490-28499 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28500-28509 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 28510-28519 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28520-28529 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28530-28539 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28540-28549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28550-28559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28560-28569 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 28570-28579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28580-28589 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28590-28599 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 28600-28609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28610-28619 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28620-28629 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28630-28639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28640-28649 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28650-28659 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 28660-28669 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28670-28679 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28680-28689 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28690-28699 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 28700-28709 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28710-28719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 28720-28729 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28730-28739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28740-28749 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 28750-28759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28760-28769 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28770-28779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 28780-28789 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 28790-28799 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28800-28809 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 28810-28819 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28820-28829 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28830-28839 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 28840-28849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 28850-28859 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28860-28869 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 28870-28879 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28880-28889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28890-28899 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28900-28909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28910-28919 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28920-28929 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 28930-28939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28940-28949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28950-28959 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28960-28969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 28970-28979 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 28980-28989 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28990-28999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 29000-29009 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29010-29019 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 29020-29029 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 29030-29039 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29040-29049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 29050-29059 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 29060-29069 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 29070-29079 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 29080-29089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29090-29099 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29100-29109 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29110-29119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29120-29129 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 29130-29139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29140-29149 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 29150-29159 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29160-29169 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 29170-29179 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29180-29189 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29190-29199 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 29200-29209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29210-29219 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29220-29229 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29230-29239 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29240-29249 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29250-29259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 29260-29269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29270-29279 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 29280-29289 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29290-29299 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29300-29309 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29310-29319 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29320-29329 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 29330-29339 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 29340-29349 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29350-29359 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 29360-29369 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29370-29379 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 29380-29389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 29390-29399 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29400-29409 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29410-29419 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 29420-29429 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29430-29439 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 29440-29449 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 29450-29459 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29460-29469 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 29470-29479 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 29480-29489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29490-29499 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29500-29509 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29510-29519 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29520-29529 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 29530-29539 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29540-29549 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29550-29559 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 29560-29569 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29570-29579 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 29580-29589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 29590-29599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29600-29609 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29610-29619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 29620-29629 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29630-29639 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29640-29649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29650-29659 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29660-29669 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29670-29679 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 29680-29689 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29690-29699 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29700-29709 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29710-29719 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 29720-29729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29730-29739 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29740-29749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29750-29759 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 29760-29769 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29770-29779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 29780-29789 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29790-29799 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 29800-29809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 29810-29819 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29820-29829 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 29830-29839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29840-29849 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29850-29859 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 29860-29869 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29870-29879 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 29880-29889 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29890-29899 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29900-29909 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29910-29919 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 29920-29929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29930-29939 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 29940-29949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 29950-29959 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29960-29969 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29970-29979 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 29980-29989 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 29990-29999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30000-30009 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 30010-30019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 30020-30029 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30030-30039 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30040-30049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 30050-30059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30060-30069 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30070-30079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30080-30089 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30090-30099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 30100-30109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 30110-30119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30120-30129 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 30130-30139 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30140-30149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30150-30159 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 30160-30169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30170-30179 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 30180-30189 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30190-30199 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 30200-30209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30210-30219 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30220-30229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30230-30239 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30240-30249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 30250-30259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30260-30269 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30270-30279 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30280-30289 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 30290-30299 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30300-30309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 30310-30319 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30320-30329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30330-30339 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 30340-30349 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30350-30359 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 30360-30369 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30370-30379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30380-30389 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30390-30399 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 30400-30409 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30410-30419 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30420-30429 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30430-30439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 30440-30449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30450-30459 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 30460-30469 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30470-30479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30480-30489 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 30490-30499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 30500-30509 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30510-30519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 30520-30529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 30530-30539 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30540-30549 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 30550-30559 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30560-30569 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 30570-30579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30580-30589 + 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 30590-30599 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 30600-30609 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30610-30619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30620-30629 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30630-30639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 30640-30649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30650-30659 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30660-30669 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30670-30679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 30680-30689 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30690-30699 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 30700-30709 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 30710-30719 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 30720-30729 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 30730-30739 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30740-30749 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30750-30759 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 30760-30769 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 30770-30779 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30780-30789 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30790-30799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 30800-30809 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30810-30819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 30820-30829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30830-30839 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30840-30849 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 30850-30859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30860-30869 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30870-30879 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30880-30889 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30890-30899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30900-30909 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30910-30919 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30920-30929 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30930-30939 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 30940-30949 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30950-30959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30960-30969 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30970-30979 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 30980-30989 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30990-30999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31000-31009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 31010-31019 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31020-31029 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 31030-31039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31040-31049 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31050-31059 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 31060-31069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31070-31079 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31080-31089 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 31090-31099 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31100-31109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31110-31119 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 31120-31129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31130-31139 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31140-31149 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 31150-31159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31160-31169 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31170-31179 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 31180-31189 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 31190-31199 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31200-31209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 31210-31219 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31220-31229 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 31230-31239 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 31240-31249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 31250-31259 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31260-31269 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 31270-31279 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31280-31289 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31290-31299 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 31300-31309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31310-31319 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31320-31329 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31330-31339 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31340-31349 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 31350-31359 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31360-31369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31370-31379 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31380-31389 + 1, 2, 1, 4, 3, 2, 1, 72, 71, 70, // 31390-31399 + 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, // 31400-31409 + 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, // 31410-31419 + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 31420-31429 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 31430-31439 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 31440-31449 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31450-31459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31460-31469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31470-31479 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 31480-31489 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31490-31499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31500-31509 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 31510-31519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31520-31529 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31530-31539 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31540-31549 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31550-31559 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31560-31569 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31570-31579 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 31580-31589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31590-31599 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 31600-31609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31610-31619 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 31620-31629 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31630-31639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 31640-31649 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31650-31659 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31660-31669 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31670-31679 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 31680-31689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 31690-31699 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31700-31709 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31710-31719 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 31720-31729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31730-31739 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31740-31749 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31750-31759 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31760-31769 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 31770-31779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31780-31789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 31790-31799 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31800-31809 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 31810-31819 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31820-31829 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31830-31839 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 31840-31849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 31850-31859 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31860-31869 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31870-31879 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31880-31889 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31890-31899 + 7, 6, 5, 4, 3, 2, 1, 50, 49, 48, // 31900-31909 + 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, // 31910-31919 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 31920-31929 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31930-31939 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31940-31949 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31950-31959 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31960-31969 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31970-31979 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31980-31989 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31990-31999 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 32000-32009 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32010-32019 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 32020-32029 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32030-32039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32040-32049 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 32050-32059 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32060-32069 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32070-32079 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 32080-32089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 32090-32099 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32100-32109 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 32110-32119 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32120-32129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32130-32139 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 32140-32149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 32150-32159 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32160-32169 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32170-32179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32180-32189 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32190-32199 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32200-32209 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 32210-32219 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32220-32229 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 32230-32239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32240-32249 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32250-32259 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 32260-32269 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 32270-32279 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32280-32289 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 32290-32299 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 32300-32309 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32310-32319 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 32320-32329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32330-32339 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32340-32349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32350-32359 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32360-32369 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32370-32379 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32380-32389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32390-32399 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32400-32409 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32410-32419 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 32420-32429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32430-32439 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 32440-32449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32450-32459 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 32460-32469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 32470-32479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32480-32489 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32490-32499 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 32500-32509 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32510-32519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32520-32529 + 1, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 32530-32539 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32540-32549 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32550-32559 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32560-32569 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32570-32579 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 32580-32589 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32590-32599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32600-32609 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32610-32619 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32620-32629 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 32630-32639 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32640-32649 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 32650-32659 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 32660-32669 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32670-32679 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32680-32689 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 32690-32699 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32700-32709 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 32710-32719 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 32720-32729 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32730-32739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 32740-32749 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32750-32759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32760-32769 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 32770-32779 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32780-32789 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32790-32799 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 32800-32809 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32810-32819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32820-32829 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32830-32839 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 32840-32849 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32850-32859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 32860-32869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32870-32879 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 32880-32889 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32890-32899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 32900-32909 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 32910-32919 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32920-32929 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32930-32939 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32940-32949 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 32950-32959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 32960-32969 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32970-32979 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 32980-32989 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 32990-32999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33000-33009 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33010-33019 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33020-33029 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33030-33039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33040-33049 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33050-33059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33060-33069 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33070-33079 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33080-33089 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33090-33099 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33100-33109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 33110-33119 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 33120-33129 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33130-33139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33140-33149 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33150-33159 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33160-33169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33170-33179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33180-33189 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33190-33199 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33200-33209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33210-33219 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 33220-33229 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33230-33239 + 7, 6, 5, 4, 3, 2, 1, 40, 39, 38, // 33240-33249 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 33250-33259 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33260-33269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33270-33279 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 33280-33289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33290-33299 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33300-33309 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33310-33319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33320-33329 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33330-33339 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 33340-33349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 33350-33359 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33360-33369 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 33370-33379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33380-33389 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33390-33399 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 33400-33409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 33410-33419 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 33420-33429 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33430-33439 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33440-33449 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33450-33459 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 33460-33469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 33470-33479 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33480-33489 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33490-33499 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33500-33509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33510-33519 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33520-33529 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 33530-33539 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 33540-33549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33550-33559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33560-33569 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33570-33579 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 33580-33589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33590-33599 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33600-33609 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 33610-33619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33620-33629 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33630-33639 + 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 33640-33649 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 33650-33659 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33660-33669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 33670-33679 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 33680-33689 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33690-33699 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33700-33709 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33710-33719 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33720-33729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 33730-33739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33740-33749 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 33750-33759 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 33760-33769 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33770-33779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33780-33789 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33790-33799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33800-33809 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33810-33819 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 33820-33829 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 33830-33839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33840-33849 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33850-33859 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33860-33869 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33870-33879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33880-33889 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33890-33899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33900-33909 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33910-33919 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33920-33929 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33930-33939 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 33940-33949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33950-33959 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 33960-33969 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33970-33979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33980-33989 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 33990-33999 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34000-34009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 34010-34019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34020-34029 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 34030-34039 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34040-34049 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 34050-34059 + 1, 62, 61, 60, 59, 58, 57, 56, 55, 54, // 34060-34069 + 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 34070-34079 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 34080-34089 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34090-34099 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34100-34109 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34110-34119 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 34120-34129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34130-34139 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34140-34149 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 34150-34159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34160-34169 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34170-34179 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 34180-34189 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34190-34199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34200-34209 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 34210-34219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34220-34229 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34230-34239 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34240-34249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 34250-34259 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34260-34269 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34270-34279 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 34280-34289 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 34290-34299 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34300-34309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 34310-34319 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34320-34329 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 34330-34339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34340-34349 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34350-34359 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 34360-34369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34370-34379 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34380-34389 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34390-34399 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34400-34409 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34410-34419 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34420-34429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 34430-34439 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34440-34449 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 34450-34459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34460-34469 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34470-34479 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 34480-34489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34490-34499 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34500-34509 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 34510-34519 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34520-34529 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34530-34539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 34, // 34540-34549 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34550-34559 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34560-34569 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34570-34579 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 34580-34589 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34590-34599 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 34600-34609 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34610-34619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34620-34629 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34630-34639 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34640-34649 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34650-34659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34660-34669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 34670-34679 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34680-34689 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34690-34699 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34700-34709 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34710-34719 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34720-34729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 34730-34739 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34740-34749 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 34750-34759 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34760-34769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34770-34779 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 34780-34789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34790-34799 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 34800-34809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 34810-34819 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34820-34829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34830-34839 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 34840-34849 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34850-34859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34860-34869 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34870-34879 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 34880-34889 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 34890-34899 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34900-34909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 34910-34919 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34920-34929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34930-34939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 34940-34949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34950-34959 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34960-34969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34970-34979 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 34980-34989 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34990-34999 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 35000-35009 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35010-35019 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 35020-35029 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35030-35039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35040-35049 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35050-35059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 35060-35069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35070-35079 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35080-35089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 35090-35099 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35100-35109 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35110-35119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 35120-35129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35130-35139 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35140-35149 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 35150-35159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35160-35169 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35170-35179 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35180-35189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35190-35199 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35200-35209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35210-35219 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 35220-35229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35230-35239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35240-35249 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 35250-35259 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35260-35269 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 35270-35279 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35280-35289 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35290-35299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35300-35309 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35310-35319 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 35320-35329 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 35330-35339 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35340-35349 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35350-35359 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35360-35369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35370-35379 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35380-35389 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 35390-35399 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35400-35409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35410-35419 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 35420-35429 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 35430-35439 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35440-35449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35450-35459 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35460-35469 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35470-35479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35480-35489 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35490-35499 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35500-35509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35510-35519 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35520-35529 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 35530-35539 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 35540-35549 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 35550-35559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35560-35569 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35570-35579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35580-35589 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 35590-35599 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 35600-35609 + 7, 6, 5, 4, 3, 2, 1, 54, 53, 52, // 35610-35619 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 35620-35629 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 35630-35639 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35640-35649 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35650-35659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35660-35669 + 1, 6, 5, 4, 3, 2, 1, 52, 51, 50, // 35670-35679 + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 35680-35689 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 35690-35699 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 35700-35709 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 35710-35719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 35720-35729 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35730-35739 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35740-35749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 35750-35759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35760-35769 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 35770-35779 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35780-35789 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35790-35799 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 35800-35809 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35810-35819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35820-35829 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35830-35839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35840-35849 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35850-35859 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35860-35869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 35870-35879 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35880-35889 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35890-35899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35900-35909 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35910-35919 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35920-35929 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35930-35939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35940-35949 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35950-35959 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 35960-35969 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35970-35979 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35980-35989 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 35990-35999 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36000-36009 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 36010-36019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36020-36029 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 36030-36039 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36040-36049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36050-36059 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36060-36069 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36070-36079 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 36080-36089 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36090-36099 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 36100-36109 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36110-36119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36120-36129 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 36130-36139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36140-36149 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36150-36159 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 36160-36169 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36170-36179 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36180-36189 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36190-36199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36200-36209 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36210-36219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36220-36229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36230-36239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36240-36249 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36250-36259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 36260-36269 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 36270-36279 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36280-36289 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 36290-36299 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36300-36309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 36310-36319 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36320-36329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36330-36339 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36340-36349 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 36350-36359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36360-36369 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36370-36379 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 44, // 36380-36389 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 36390-36399 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 36400-36409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36410-36419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36420-36429 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 36430-36439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36440-36449 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36450-36459 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 36460-36469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 36470-36479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36480-36489 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 36490-36499 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36500-36509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36510-36519 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 36520-36529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36530-36539 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36540-36549 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 36550-36559 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36560-36569 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36570-36579 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 36580-36589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36590-36599 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 36600-36609 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36610-36619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36620-36629 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36630-36639 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36640-36649 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 36650-36659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36660-36669 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36670-36679 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36680-36689 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36690-36699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 36700-36709 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36710-36719 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36720-36729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 36730-36739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36740-36749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36750-36759 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36760-36769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 36770-36779 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36780-36789 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 36790-36799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36800-36809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36810-36819 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36820-36829 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 36830-36839 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36840-36849 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 36850-36859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36860-36869 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36870-36879 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36880-36889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 36890-36899 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36900-36909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 36910-36919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 36920-36929 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36930-36939 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 36940-36949 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36950-36959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36960-36969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 36970-36979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36980-36989 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36990-36999 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37000-37009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 37010-37019 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 37020-37029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37030-37039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37040-37049 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37050-37059 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37060-37069 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37070-37079 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37080-37089 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 37090-37099 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37100-37109 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37110-37119 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 37120-37129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 37130-37139 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 37140-37149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 37150-37159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37160-37169 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37170-37179 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37180-37189 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 37190-37199 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37200-37209 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37210-37219 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37220-37229 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37230-37239 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37240-37249 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37250-37259 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37260-37269 + 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 37270-37279 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37280-37289 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37290-37299 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 37300-37309 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37310-37319 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37320-37329 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 37330-37339 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37340-37349 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37350-37359 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 37360-37369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 37370-37379 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37380-37389 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37390-37399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 37400-37409 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37410-37419 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 37420-37429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37430-37439 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 37440-37449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37450-37459 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37460-37469 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37470-37479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 37480-37489 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37490-37499 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37500-37509 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37510-37519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37520-37529 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37530-37539 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 37540-37549 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37550-37559 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37560-37569 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 37570-37579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 37580-37589 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37590-37599 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37600-37609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 37610-37619 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37620-37629 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37630-37639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 37640-37649 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37650-37659 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 37660-37669 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37670-37679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37680-37689 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 37690-37699 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37700-37709 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 37710-37719 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37720-37729 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37730-37739 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 37740-37749 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 37750-37759 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37760-37769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37770-37779 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 37780-37789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 37790-37799 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37800-37809 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 37810-37819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37820-37829 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37830-37839 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37840-37849 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37850-37859 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37860-37869 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37870-37879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37880-37889 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37890-37899 + 7, 6, 5, 4, 3, 2, 1, 44, 43, 42, // 37900-37909 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 37910-37919 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 37920-37929 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37930-37939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37940-37949 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37950-37959 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 37960-37969 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37970-37979 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37980-37989 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 37990-37999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38000-38009 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 38010-38019 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38020-38029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 38030-38039 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38040-38049 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 38050-38059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 38060-38069 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38070-38079 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 38080-38089 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38090-38099 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38100-38109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 38110-38119 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 38120-38129 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38130-38139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 38140-38149 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38150-38159 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 38160-38169 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38170-38179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38180-38189 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38190-38199 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38200-38209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 38210-38219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38220-38229 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 38230-38239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38240-38249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38250-38259 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38260-38269 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 38270-38279 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 38280-38289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 38290-38299 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38300-38309 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38310-38319 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 38320-38329 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38330-38339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38340-38349 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38350-38359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38360-38369 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38370-38379 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38380-38389 + 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 38390-38399 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 38400-38409 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38410-38419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38420-38429 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 38430-38439 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 38440-38449 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 38450-38459 + 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 38460-38469 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 38470-38479 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38480-38489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38490-38499 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 38500-38509 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 38510-38519 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38520-38529 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38530-38539 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38540-38549 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38550-38559 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 38560-38569 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38570-38579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38580-38589 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38590-38599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 38600-38609 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38610-38619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 38620-38629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 38630-38639 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38640-38649 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 38650-38659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 38660-38669 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38670-38679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38680-38689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38690-38699 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38700-38709 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38710-38719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38720-38729 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 38730-38739 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 38740-38749 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 38750-38759 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38760-38769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38770-38779 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 38780-38789 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38790-38799 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38800-38809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38810-38819 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38820-38829 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 38830-38839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38840-38849 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38850-38859 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38860-38869 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38870-38879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38880-38889 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38890-38899 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38900-38909 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38910-38919 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38920-38929 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 38930-38939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38940-38949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 38950-38959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38960-38969 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38970-38979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38980-38989 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 38990-38999 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39000-39009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39010-39019 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39020-39029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39030-39039 + 1, 2, 1, 4, 3, 2, 1, 32, 31, 30, // 39040-39049 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39050-39059 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39060-39069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39070-39079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39080-39089 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39090-39099 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 39100-39109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 39110-39119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39120-39129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 39130-39139 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 39140-39149 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39150-39159 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39160-39169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39170-39179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39180-39189 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39190-39199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39200-39209 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 39210-39219 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 39220-39229 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 39230-39239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39240-39249 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 39250-39259 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 39260-39269 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 39270-39279 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39280-39289 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39290-39299 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39300-39309 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 39310-39319 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39320-39329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39330-39339 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 39340-39349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39350-39359 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39360-39369 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 39370-39379 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 39380-39389 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 39390-39399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39400-39409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 39410-39419 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39420-39429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39430-39439 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39440-39449 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39450-39459 + 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 39460-39469 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39470-39479 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39480-39489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39490-39499 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 39500-39509 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39510-39519 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 39520-39529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39530-39539 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39540-39549 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39550-39559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 39560-39569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39570-39579 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 39580-39589 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 39590-39599 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 39600-39609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39610-39619 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39620-39629 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39630-39639 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39640-39649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39650-39659 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39660-39669 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 39670-39679 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 39680-39689 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39690-39699 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 39700-39709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39710-39719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39720-39729 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 39730-39739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 39740-39749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39750-39759 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39760-39769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 39770-39779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39780-39789 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 39790-39799 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 39800-39809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39810-39819 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 39820-39829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 39830-39839 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 39840-39849 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39850-39859 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 39860-39869 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39870-39879 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 39880-39889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39890-39899 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39900-39909 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39910-39919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39920-39929 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 39930-39939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39940-39949 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39950-39959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39960-39969 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39970-39979 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 39980-39989 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39990-39999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40000-40009 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40010-40019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40020-40029 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 40030-40039 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40040-40049 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40050-40059 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40060-40069 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40070-40079 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40080-40089 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 40090-40099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40100-40109 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40110-40119 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 40120-40129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 40130-40139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40140-40149 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 40150-40159 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 40160-40169 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40170-40179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40180-40189 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 40190-40199 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40200-40209 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40210-40219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40220-40229 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 40230-40239 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40240-40249 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40250-40259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40260-40269 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40270-40279 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 54, // 40280-40289 + 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 40290-40299 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 40300-40309 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40310-40319 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40320-40329 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40330-40339 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40340-40349 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 40350-40359 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 40360-40369 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40370-40379 + 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 40380-40389 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40390-40399 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40400-40409 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40410-40419 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 40420-40429 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 40430-40439 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 40440-40449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40450-40459 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40460-40469 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40470-40479 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 40480-40489 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 40490-40499 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40500-40509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 40510-40519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 40520-40529 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40530-40539 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 40540-40549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 40550-40559 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40560-40569 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40570-40579 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40580-40589 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40590-40599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 40600-40609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40610-40619 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 40620-40629 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 54, // 40630-40639 + 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 40640-40649 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 40650-40659 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40660-40669 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40670-40679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40680-40689 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 40690-40699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 40700-40709 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 40710-40719 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 40720-40729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40730-40739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40740-40749 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40750-40759 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40760-40769 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40770-40779 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 40780-40789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40790-40799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40800-40809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 40810-40819 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 40820-40829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40830-40839 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 40840-40849 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 40850-40859 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40860-40869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40870-40879 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 40880-40889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40890-40899 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40900-40909 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40910-40919 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40920-40929 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 40930-40939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40940-40949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40950-40959 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40960-40969 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 40970-40979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40980-40989 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40990-40999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41000-41009 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41010-41019 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41020-41029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41030-41039 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41040-41049 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 41050-41059 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41060-41069 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41070-41079 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 41080-41089 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41090-41099 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41100-41109 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 41110-41119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41120-41129 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41130-41139 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41140-41149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41150-41159 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41160-41169 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 41170-41179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41180-41189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41190-41199 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41200-41209 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41210-41219 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41220-41229 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41230-41239 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 41240-41249 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41250-41259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41260-41269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41270-41279 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41280-41289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 34, // 41290-41299 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 41300-41309 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41310-41319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41320-41329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41330-41339 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41340-41349 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 41350-41359 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 41360-41369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41370-41379 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 41380-41389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41390-41399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41400-41409 + 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 41410-41419 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41420-41429 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41430-41439 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41440-41449 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 41450-41459 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 41460-41469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41470-41479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41480-41489 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41490-41499 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41500-41509 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41510-41519 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41520-41529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 41530-41539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 41540-41549 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 41550-41559 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41560-41569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 41570-41579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41580-41589 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 41590-41599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41600-41609 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41610-41619 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 41620-41629 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41630-41639 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41640-41649 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 41650-41659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41660-41669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41670-41679 + 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 41680-41689 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 41690-41699 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41700-41709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 41710-41719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41720-41729 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 41730-41739 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41740-41749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 41750-41759 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41760-41769 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 41770-41779 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 41780-41789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41790-41799 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 41800-41809 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 41810-41819 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41820-41829 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41830-41839 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41840-41849 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41850-41859 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41860-41869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41870-41879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41880-41889 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 41890-41899 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41900-41909 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41910-41919 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 41920-41929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41930-41939 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41940-41949 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 41950-41959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41960-41969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41970-41979 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41980-41989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 41990-41999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42000-42009 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 42010-42019 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 42020-42029 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42030-42039 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 42040-42049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42050-42059 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42060-42069 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42070-42079 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 42080-42089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42090-42099 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 42100-42109 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42110-42119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42120-42129 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 42130-42139 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42140-42149 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42150-42159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42160-42169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42170-42179 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42180-42189 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 42190-42199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 42200-42209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42210-42219 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 42220-42229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 42230-42239 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42240-42249 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 42250-42259 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42260-42269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42270-42279 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42280-42289 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42290-42299 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 42300-42309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42310-42319 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42320-42329 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42330-42339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42340-42349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 42350-42359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42360-42369 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 42370-42379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42380-42389 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42390-42399 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 42400-42409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42410-42419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42420-42429 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 42430-42439 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42440-42449 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42450-42459 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 42460-42469 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 42470-42479 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42480-42489 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42490-42499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 42500-42509 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42510-42519 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42520-42529 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 42530-42539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42540-42549 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42550-42559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42560-42569 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42570-42579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 42580-42589 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42590-42599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42600-42609 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 42610-42619 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42620-42629 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42630-42639 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 42640-42649 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42650-42659 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 42660-42669 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42670-42679 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42680-42689 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42690-42699 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 42700-42709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 42710-42719 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 42720-42729 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42730-42739 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42740-42749 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42750-42759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42760-42769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 42770-42779 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42780-42789 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 42790-42799 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42800-42809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42810-42819 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42820-42829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42830-42839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42840-42849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 42850-42859 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 42860-42869 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 42870-42879 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 42880-42889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42890-42899 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42900-42909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42910-42919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42920-42929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42930-42939 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42940-42949 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42950-42959 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42960-42969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42970-42979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 42980-42989 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42990-42999 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43000-43009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 43010-43019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43020-43029 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43030-43039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43040-43049 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43050-43059 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 43060-43069 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43070-43079 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43080-43089 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43090-43099 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43100-43109 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 43110-43119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43120-43129 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 43130-43139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43140-43149 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 43150-43159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43160-43169 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43170-43179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 43180-43189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43190-43199 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 43200-43209 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43210-43219 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43220-43229 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43230-43239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43240-43249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43250-43259 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43260-43269 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43270-43279 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43280-43289 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43290-43299 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43300-43309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 43310-43319 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43320-43329 + 1, 60, 59, 58, 57, 56, 55, 54, 53, 52, // 43330-43339 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 43340-43349 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 43350-43359 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 43360-43369 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43370-43379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43380-43389 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 43390-43399 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43400-43409 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43410-43419 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 43420-43429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43430-43439 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43440-43449 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43450-43459 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43460-43469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43470-43479 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43480-43489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 43490-43499 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43500-43509 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43510-43519 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43520-43529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43530-43539 + 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 43540-43549 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43550-43559 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43560-43569 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 43570-43579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43580-43589 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 43590-43599 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 43600-43609 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43610-43619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 43620-43629 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 43630-43639 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43640-43649 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43650-43659 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 43660-43669 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43670-43679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43680-43689 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43690-43699 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43700-43709 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43710-43719 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 43720-43729 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43730-43739 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43740-43749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 43750-43759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43760-43769 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43770-43779 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 43780-43789 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43790-43799 + 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 43800-43809 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 43810-43819 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 43820-43829 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43830-43839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43840-43849 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43850-43859 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 43860-43869 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 43870-43879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43880-43889 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43890-43899 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43900-43909 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 43910-43919 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43920-43929 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43930-43939 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43940-43949 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43950-43959 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 43960-43969 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43970-43979 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43980-43989 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 43990-43999 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44000-44009 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44010-44019 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 44020-44029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44030-44039 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44040-44049 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 44050-44059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44060-44069 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44070-44079 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 44080-44089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44090-44099 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44100-44109 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44110-44119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 44120-44129 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44130-44139 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44140-44149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44150-44159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44160-44169 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 44170-44179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44180-44189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44190-44199 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 44200-44209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44210-44219 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44220-44229 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44230-44239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44240-44249 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 44250-44259 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 44260-44269 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 44270-44279 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44280-44289 + 3, 2, 1, 58, 57, 56, 55, 54, 53, 52, // 44290-44299 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 44300-44309 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 44310-44319 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 44320-44329 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 44330-44339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44340-44349 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 44350-44359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44360-44369 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44370-44379 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 44380-44389 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 44390-44399 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44400-44409 + 7, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 44410-44419 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44420-44429 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44430-44439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44440-44449 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 44450-44459 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 44460-44469 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44470-44479 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44480-44489 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44490-44499 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44500-44509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44510-44519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44520-44529 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 44530-44539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 44540-44549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44550-44559 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 44560-44569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44570-44579 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 44580-44589 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 44590-44599 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44600-44609 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44610-44619 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 44620-44629 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44630-44639 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44640-44649 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 44650-44659 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 44660-44669 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44670-44679 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 44680-44689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 44690-44699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44700-44709 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44710-44719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44720-44729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44730-44739 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44740-44749 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 44750-44759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44760-44769 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 44770-44779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44780-44789 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44790-44799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 44800-44809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 44810-44819 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44820-44829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44830-44839 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44840-44849 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44850-44859 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44860-44869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44870-44879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 44880-44889 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 44890-44899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44900-44909 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 44910-44919 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44920-44929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 44930-44939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44940-44949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 44950-44959 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44960-44969 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44970-44979 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 44980-44989 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44990-44999 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45000-45009 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 45010-45019 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45020-45029 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45030-45039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45040-45049 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45050-45059 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45060-45069 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45070-45079 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 45080-45089 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 45090-45099 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45100-45109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 45110-45119 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45120-45129 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 45130-45139 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 45140-45149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45150-45159 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45160-45169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 45170-45179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45180-45189 + 1, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 45190-45199 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45200-45209 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45210-45219 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45220-45229 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45230-45239 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 45240-45249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 45250-45259 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45260-45269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45270-45279 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 45280-45289 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45290-45299 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 45300-45309 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 45310-45319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 45320-45329 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45330-45339 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45340-45349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45350-45359 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45360-45369 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 45370-45379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 45380-45389 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45390-45399 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45400-45409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45410-45419 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45420-45429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 42, // 45430-45439 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 45440-45449 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 45450-45459 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 45460-45469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45470-45479 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45480-45489 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45490-45499 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 45500-45509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45510-45519 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45520-45529 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45530-45539 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45540-45549 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 45550-45559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 45560-45569 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45570-45579 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 45580-45589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 45590-45599 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45600-45609 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45610-45619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45620-45629 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45630-45639 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45640-45649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 45650-45659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45660-45669 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 45670-45679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45680-45689 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 45690-45699 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 45700-45709 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 45710-45719 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45720-45729 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 45730-45739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45740-45749 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45750-45759 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 45760-45769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 38, // 45770-45779 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 45780-45789 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 45790-45799 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45800-45809 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45810-45819 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 45820-45829 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45830-45839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45840-45849 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45850-45859 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 45860-45869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45870-45879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45880-45889 + 3, 2, 1, 50, 49, 48, 47, 46, 45, 44, // 45890-45899 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 45900-45909 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45910-45919 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45920-45929 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45930-45939 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 45940-45949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 45950-45959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45960-45969 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 45970-45979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 45980-45989 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 45990-45999 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46000-46009 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46010-46019 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 46020-46029 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46030-46039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46040-46049 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46050-46059 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46060-46069 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 46070-46079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46080-46089 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 46090-46099 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 46100-46109 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46110-46119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46120-46129 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 46130-46139 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 46140-46149 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 46150-46159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46160-46169 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46170-46179 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 46180-46189 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 46190-46199 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46200-46209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46210-46219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46220-46229 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 46230-46239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46240-46249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46250-46259 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46260-46269 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 46270-46279 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46280-46289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46290-46299 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 46300-46309 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46310-46319 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 46320-46329 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46330-46339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46340-46349 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 46350-46359 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46360-46369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46370-46379 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46380-46389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 46390-46399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46400-46409 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 46410-46419 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46420-46429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46430-46439 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46440-46449 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 46450-46459 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46460-46469 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46470-46479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46480-46489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46490-46499 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46500-46509 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46510-46519 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 46520-46529 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46530-46539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46540-46549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46550-46559 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 46560-46569 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 46570-46579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46580-46589 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46590-46599 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46600-46609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 46610-46619 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46620-46629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 46630-46639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 46640-46649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46650-46659 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 46660-46669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46670-46679 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46680-46689 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46690-46699 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 46700-46709 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46710-46719 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 46720-46729 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46730-46739 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46740-46749 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46750-46759 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46760-46769 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 46770-46779 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 46780-46789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46790-46799 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46800-46809 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 46810-46819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46820-46829 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46830-46839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46840-46849 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 46850-46859 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 46860-46869 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46870-46879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 46880-46889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46890-46899 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46900-46909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 46910-46919 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46920-46929 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 46930-46939 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46940-46949 + 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 46950-46959 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 46960-46969 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46970-46979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46980-46989 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 46990-46999 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47000-47009 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 47010-47019 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47020-47029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47030-47039 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47040-47049 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 47050-47059 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47060-47069 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47070-47079 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47080-47089 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 47090-47099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47100-47109 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 47110-47119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47120-47129 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47130-47139 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 47140-47149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47150-47159 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 47160-47169 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47170-47179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 47180-47189 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47190-47199 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 47200-47209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47210-47219 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47220-47229 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 47230-47239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47240-47249 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47250-47259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 47260-47269 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 47270-47279 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47280-47289 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 47290-47299 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47300-47309 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 47310-47319 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47320-47329 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 47330-47339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47340-47349 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 47350-47359 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 47360-47369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47370-47379 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 47380-47389 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47390-47399 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 47400-47409 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 47410-47419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47420-47429 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47430-47439 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47440-47449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 47450-47459 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 47460-47469 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47470-47479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47480-47489 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47490-47499 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47500-47509 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 47510-47519 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47520-47529 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 47530-47539 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 47540-47549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47550-47559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 47560-47569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47570-47579 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47580-47589 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 47590-47599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 47600-47609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47610-47619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 47620-47629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 47630-47639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47640-47649 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 47650-47659 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47660-47669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47670-47679 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47680-47689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 47690-47699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47700-47709 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 47710-47719 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47720-47729 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47730-47739 + 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 47740-47749 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47750-47759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47760-47769 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 47770-47779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47780-47789 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 47790-47799 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 47800-47809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 47810-47819 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47820-47829 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47830-47839 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 47840-47849 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 47850-47859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 47860-47869 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47870-47879 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 47880-47889 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47890-47899 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 47900-47909 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 47910-47919 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47920-47929 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47930-47939 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47940-47949 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47950-47959 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47960-47969 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47970-47979 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 47980-47989 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47990-47999 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48000-48009 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48010-48019 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 48020-48029 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48030-48039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 48040-48049 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48050-48059 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48060-48069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 48070-48079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48080-48089 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48090-48099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 48100-48109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48110-48119 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48120-48129 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 48130-48139 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48140-48149 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48150-48159 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 48160-48169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48170-48179 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48180-48189 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 48190-48199 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 48200-48209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48210-48219 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48220-48229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48230-48239 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48240-48249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 48250-48259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48260-48269 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48270-48279 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48280-48289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 48290-48299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48300-48309 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48310-48319 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48320-48329 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48330-48339 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48340-48349 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48350-48359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48360-48369 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48370-48379 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 48380-48389 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 48390-48399 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 48400-48409 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48410-48419 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48420-48429 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48430-48439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 48440-48449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48450-48459 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 48460-48469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 48470-48479 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48480-48489 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 48490-48499 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48500-48509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48510-48519 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 48520-48529 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 48530-48539 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48540-48549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48550-48559 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 48560-48569 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48570-48579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 48580-48589 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48590-48599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48600-48609 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 48610-48619 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48620-48629 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48630-48639 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 48640-48649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48650-48659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48660-48669 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 52, // 48670-48679 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 48680-48689 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 48690-48699 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 48700-48709 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 48710-48719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48720-48729 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48730-48739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48740-48749 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48750-48759 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48760-48769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48770-48779 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48780-48789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 48790-48799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48800-48809 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48810-48819 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48820-48829 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48830-48839 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 48840-48849 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 48850-48859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48860-48869 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48870-48879 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 48880-48889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48890-48899 + 7, 6, 5, 4, 3, 2, 1, 40, 39, 38, // 48900-48909 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 48910-48919 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 48920-48929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48930-48939 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48940-48949 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 48950-48959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48960-48969 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 48970-48979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48980-48989 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48990-48999 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 49000-49009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 49010-49019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49020-49029 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 49030-49039 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49040-49049 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49050-49059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 49060-49069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49070-49079 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49080-49089 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49090-49099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 49100-49109 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49110-49119 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 49120-49129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 49130-49139 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49140-49149 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49150-49159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49160-49169 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 49170-49179 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49180-49189 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 49190-49199 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49200-49209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49210-49219 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 49220-49229 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49230-49239 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49240-49249 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 49250-49259 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49260-49269 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 49270-49279 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49280-49289 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49290-49299 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 49300-49309 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49310-49319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49320-49329 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 49330-49339 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49340-49349 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49350-49359 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 49360-49369 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49370-49379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49380-49389 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 49390-49399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49400-49409 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49410-49419 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 49420-49429 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 49430-49439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49440-49449 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 49450-49459 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49460-49469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49470-49479 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 49480-49489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 49490-49499 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49500-49509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49510-49519 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 49520-49529 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49530-49539 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 49540-49549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 38, // 49550-49559 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 49560-49569 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 49570-49579 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49580-49589 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 49590-49599 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 49600-49609 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49610-49619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 49620-49629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 49630-49639 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49640-49649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49650-49659 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 49660-49669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49670-49679 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49680-49689 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 49690-49699 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49700-49709 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49710-49719 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49720-49729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49730-49739 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49740-49749 + 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 49750-49759 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49760-49769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49770-49779 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 49780-49789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49790-49799 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49800-49809 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49810-49819 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 49820-49829 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49830-49839 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 49840-49849 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 49850-49859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49860-49869 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 49870-49879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49880-49889 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 49890-49899 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 49900-49909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49910-49919 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49920-49929 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 49930-49939 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49940-49949 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 49950-49959 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 49960-49969 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49970-49979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49980-49989 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 49990-49999 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50000-50009 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50010-50019 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50020-50029 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50030-50039 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50040-50049 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 50050-50059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 50060-50069 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 50070-50079 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50080-50089 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50090-50099 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50100-50109 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50110-50119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50120-50129 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50130-50139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50140-50149 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 50150-50159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50160-50169 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 50170-50179 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50180-50189 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50190-50199 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 50200-50209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50210-50219 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50220-50229 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50230-50239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50240-50249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50250-50259 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50260-50269 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50270-50279 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50280-50289 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50290-50299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50300-50309 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50310-50319 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50320-50329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50330-50339 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50340-50349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50350-50359 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50360-50369 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50370-50379 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 50380-50389 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50390-50399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50400-50409 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50410-50419 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50420-50429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50430-50439 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50440-50449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 50450-50459 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 50460-50469 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50470-50479 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50480-50489 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50490-50499 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50500-50509 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50510-50519 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 50520-50529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50530-50539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50540-50549 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50550-50559 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50560-50569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50570-50579 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50580-50589 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 50590-50599 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50600-50609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50610-50619 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 50620-50629 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50630-50639 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50640-50649 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50650-50659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50660-50669 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50670-50679 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 50680-50689 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50690-50699 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 50700-50709 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50710-50719 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50720-50729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50730-50739 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50740-50749 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50750-50759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50760-50769 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 50770-50779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 50780-50789 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50790-50799 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50800-50809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50810-50819 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50820-50829 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 50830-50839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 50840-50849 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 50850-50859 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50860-50869 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50870-50879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50880-50889 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 50890-50899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 50900-50909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50910-50919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 50920-50929 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50930-50939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50940-50949 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 50950-50959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 50960-50969 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50970-50979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50980-50989 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50990-50999 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 51000-51009 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51010-51019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51020-51029 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51030-51039 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 51040-51049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51050-51059 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51060-51069 + 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 51070-51079 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 51080-51089 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51090-51099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 51100-51109 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51110-51119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51120-51129 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 51130-51139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51140-51149 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51150-51159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 51160-51169 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51170-51179 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51180-51189 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 51190-51199 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51200-51209 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51210-51219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 51220-51229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51230-51239 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51240-51249 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51250-51259 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 51260-51269 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51270-51279 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 51280-51289 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51290-51299 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 51300-51309 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51310-51319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51320-51329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51330-51339 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 51340-51349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51350-51359 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51360-51369 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51370-51379 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 51380-51389 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51390-51399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51400-51409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51410-51419 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51420-51429 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 51430-51439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51440-51449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51450-51459 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51460-51469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51470-51479 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 51480-51489 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51490-51499 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 51500-51509 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51510-51519 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51520-51529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51530-51539 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51540-51549 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51550-51559 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51560-51569 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51570-51579 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51580-51589 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 51590-51599 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51600-51609 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 51610-51619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51620-51629 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51630-51639 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51640-51649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 51650-51659 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51660-51669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 51670-51679 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 51680-51689 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51690-51699 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51700-51709 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51710-51719 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 51720-51729 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51730-51739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 51740-51749 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51750-51759 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 51760-51769 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51770-51779 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51780-51789 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51790-51799 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51800-51809 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51810-51819 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 51820-51829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 51830-51839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51840-51849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 51850-51859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51860-51869 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51870-51879 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51880-51889 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 51890-51899 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51900-51909 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 51910-51919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51920-51929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51930-51939 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 51940-51949 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51950-51959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51960-51969 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 51970-51979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51980-51989 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51990-51999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52000-52009 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52010-52019 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 52020-52029 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 52030-52039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52040-52049 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 52050-52059 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 52060-52069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52070-52079 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52080-52089 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52090-52099 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 52100-52109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52110-52119 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 52120-52129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52130-52139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52140-52149 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 52150-52159 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52160-52169 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52170-52179 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 52180-52189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52190-52199 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52200-52209 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52210-52219 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52220-52229 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52230-52239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52240-52249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 52250-52259 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 52260-52269 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52270-52279 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52280-52289 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52290-52299 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52300-52309 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52310-52319 + 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 52320-52329 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 52330-52339 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 52340-52349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52350-52359 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 52360-52369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 52370-52379 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52380-52389 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 52390-52399 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 52400-52409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52410-52419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52420-52429 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 52430-52439 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52440-52449 + 3, 2, 1, 4, 3, 2, 1, 32, 31, 30, // 52450-52459 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 52460-52469 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52470-52479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52480-52489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52490-52499 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52500-52509 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52510-52519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52520-52529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52530-52539 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 52540-52549 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52550-52559 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52560-52569 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52570-52579 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 52580-52589 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52590-52599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 52600-52609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52610-52619 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52620-52629 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 52630-52639 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 52640-52649 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52650-52659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52660-52669 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 52670-52679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52680-52689 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52690-52699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52700-52709 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52710-52719 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52720-52729 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52730-52739 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 52740-52749 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52750-52759 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 52760-52769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52770-52779 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 52780-52789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52790-52799 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52800-52809 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 52810-52819 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52820-52829 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 52830-52839 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52840-52849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52850-52859 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52860-52869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52870-52879 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 52880-52889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52890-52899 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 52900-52909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 52910-52919 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52920-52929 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 52930-52939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52940-52949 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52950-52959 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 52960-52969 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52970-52979 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52980-52989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52990-52999 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 53000-53009 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 53010-53019 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53020-53029 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53030-53039 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53040-53049 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53050-53059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53060-53069 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 53070-53079 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 53080-53089 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53090-53099 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53100-53109 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53110-53119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 53120-53129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53130-53139 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 53140-53149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53150-53159 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53160-53169 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 53170-53179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53180-53189 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53190-53199 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 53200-53209 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53210-53219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53220-53229 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 53230-53239 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53240-53249 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53250-53259 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 53260-53269 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53270-53279 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53280-53289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 53290-53299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 53300-53309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53310-53319 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 53320-53329 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53330-53339 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53340-53349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 53350-53359 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53360-53369 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53370-53379 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53380-53389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53390-53399 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53400-53409 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 53410-53419 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53420-53429 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53430-53439 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53440-53449 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 53450-53459 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53460-53469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 53470-53479 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53480-53489 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53490-53499 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 53500-53509 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53510-53519 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 53520-53529 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53530-53539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53540-53549 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53550-53559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 53560-53569 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53570-53579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53580-53589 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53590-53599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53600-53609 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53610-53619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 53620-53629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 53630-53639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53640-53649 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 53650-53659 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53660-53669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53670-53679 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53680-53689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 53690-53699 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53700-53709 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 53710-53719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53720-53729 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 53730-53739 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53740-53749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 53750-53759 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53760-53769 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 53770-53779 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53780-53789 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53790-53799 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53800-53809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 53810-53819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53820-53829 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53830-53839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53840-53849 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53850-53859 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53860-53869 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53870-53879 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53880-53889 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 53890-53899 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53900-53909 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53910-53919 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53920-53929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 53930-53939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53940-53949 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 53950-53959 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53960-53969 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53970-53979 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53980-53989 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53990-53999 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54000-54009 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 54010-54019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54020-54029 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54030-54039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 54040-54049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 54050-54059 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 54060-54069 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54070-54079 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54080-54089 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54090-54099 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54100-54109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54110-54119 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54120-54129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 54130-54139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54140-54149 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54150-54159 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 54160-54169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54170-54179 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54180-54189 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 54190-54199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54200-54209 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 54210-54219 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 54220-54229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54230-54239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54240-54249 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54250-54259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 54260-54269 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 54270-54279 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54280-54289 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54290-54299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54300-54309 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54310-54319 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54320-54329 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54330-54339 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 54340-54349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54350-54359 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54360-54369 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 54370-54379 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54380-54389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54390-54399 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 54400-54409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 54410-54419 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54420-54429 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54430-54439 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 54440-54449 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54450-54459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 54460-54469 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 54470-54479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54480-54489 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 54490-54499 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 54500-54509 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54510-54519 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54520-54529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 54530-54539 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54540-54549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54550-54559 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 54560-54569 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54570-54579 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54580-54589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54590-54599 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54600-54609 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54610-54619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 54620-54629 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54630-54639 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 54640-54649 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54650-54659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54660-54669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 54670-54679 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 54680-54689 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54690-54699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54700-54709 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54710-54719 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 54720-54729 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54730-54739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54740-54749 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54750-54759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54760-54769 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 54770-54779 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54780-54789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 54790-54799 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 54800-54809 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54810-54819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54820-54829 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54830-54839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54840-54849 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54850-54859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 54860-54869 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54870-54879 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 54880-54889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54890-54899 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 54900-54909 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 54910-54919 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54920-54929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54930-54939 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 54940-54949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 54950-54959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54960-54969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 54970-54979 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54980-54989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54990-54999 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55000-55009 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55010-55019 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55020-55029 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55030-55039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55040-55049 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55050-55059 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55060-55069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 55070-55079 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55080-55089 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55090-55099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55100-55109 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 55110-55119 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 55120-55129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55130-55139 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 55140-55149 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55150-55159 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55160-55169 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 55170-55179 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55180-55189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55190-55199 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55200-55209 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 55210-55219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 55220-55229 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55230-55239 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 55240-55249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 55250-55259 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 55260-55269 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55270-55279 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55280-55289 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55290-55299 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55300-55309 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 55310-55319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55320-55329 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 55330-55339 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55340-55349 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55350-55359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55360-55369 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55370-55379 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55380-55389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55390-55399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55400-55409 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55410-55419 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55420-55429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55430-55439 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55440-55449 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 55450-55459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 55460-55469 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55470-55479 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 55480-55489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55490-55499 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55500-55509 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55510-55519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55520-55529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55530-55539 + 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 55540-55549 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55550-55559 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55560-55569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 55570-55579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 55580-55589 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55590-55599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 55600-55609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55610-55619 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55620-55629 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 55630-55639 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55640-55649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55650-55659 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 55660-55669 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55670-55679 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55680-55689 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 55690-55699 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55700-55709 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55710-55719 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55720-55729 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 55730-55739 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55740-55749 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55750-55759 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 55760-55769 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55770-55779 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55780-55789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55790-55799 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55800-55809 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 55810-55819 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55820-55829 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55830-55839 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 55840-55849 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55850-55859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55860-55869 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55870-55879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 55880-55889 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55890-55899 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 55900-55909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55910-55919 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55920-55929 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 55930-55939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 55940-55949 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55950-55959 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 55960-55969 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55970-55979 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 55980-55989 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55990-55999 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 56000-56009 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 56010-56019 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56020-56029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 56030-56039 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56040-56049 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 56050-56059 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 56060-56069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56070-56079 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56080-56089 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 56090-56099 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56100-56109 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56110-56119 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56120-56129 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56130-56139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 56140-56149 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56150-56159 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 56160-56169 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 56170-56179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56180-56189 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 56190-56199 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 56200-56209 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 56210-56219 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56220-56229 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 56230-56239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 56240-56249 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56250-56259 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 56260-56269 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 56270-56279 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56280-56289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 56290-56299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56300-56309 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 56310-56319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56320-56329 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56330-56339 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56340-56349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 56350-56359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 56360-56369 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56370-56379 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56380-56389 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56390-56399 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56400-56409 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 56410-56419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56420-56429 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56430-56439 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56440-56449 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 56450-56459 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56460-56469 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 56470-56479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 56480-56489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56490-56499 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 56500-56509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 56510-56519 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 56520-56529 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56530-56539 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56540-56549 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56550-56559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 56560-56569 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 56570-56579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56580-56589 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 56590-56599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56600-56609 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56610-56619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 56620-56629 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56630-56639 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56640-56649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 56650-56659 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56660-56669 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56670-56679 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 56680-56689 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56690-56699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56700-56709 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 56710-56719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56720-56729 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 56730-56739 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 56740-56749 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56750-56759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56760-56769 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 56770-56779 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 56780-56789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56790-56799 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 56800-56809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56810-56819 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 56820-56829 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56830-56839 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 56840-56849 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 56850-56859 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56860-56869 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 56870-56879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56880-56889 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 56890-56899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 56900-56909 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56910-56919 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 56920-56929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56930-56939 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56940-56949 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56950-56959 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 56960-56969 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56970-56979 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 56980-56989 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 38, // 56990-56999 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 57000-57009 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57010-57019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57020-57029 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57030-57039 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57040-57049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 57050-57059 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57060-57069 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 57070-57079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57080-57089 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 57090-57099 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57100-57109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 57110-57119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57120-57129 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57130-57139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 57140-57149 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57150-57159 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57160-57169 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 57170-57179 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57180-57189 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57190-57199 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 57200-57209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57210-57219 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 57220-57229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57230-57239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57240-57249 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57250-57259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57260-57269 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57270-57279 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 57280-57289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57290-57299 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 57300-57309 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57310-57319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57320-57329 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57330-57339 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 57340-57349 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57350-57359 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57360-57369 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57370-57379 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 57380-57389 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 57390-57399 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57400-57409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 57410-57419 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 57420-57429 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57430-57439 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57440-57449 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 57450-57459 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 57460-57469 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57470-57479 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57480-57489 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57490-57499 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 57500-57509 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57510-57519 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 57520-57529 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57530-57539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57540-57549 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 57550-57559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57560-57569 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57570-57579 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57580-57589 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 57590-57599 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 57600-57609 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57610-57619 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57620-57629 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57630-57639 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57640-57649 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 57650-57659 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57660-57669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57670-57679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57680-57689 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57690-57699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57700-57709 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 57710-57719 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57720-57729 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 57730-57739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57740-57749 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57750-57759 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57760-57769 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 57770-57779 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57780-57789 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57790-57799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 57800-57809 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57810-57819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57820-57829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57830-57839 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57840-57849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 57850-57859 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 57860-57869 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57870-57879 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57880-57889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57890-57899 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57900-57909 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57910-57919 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 57920-57929 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57930-57939 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 57940-57949 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57950-57959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57960-57969 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 57970-57979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57980-57989 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57990-57999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58000-58009 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 58010-58019 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58020-58029 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58030-58039 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 58040-58049 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58050-58059 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58060-58069 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 58070-58079 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58080-58089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 58090-58099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58100-58109 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58110-58119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 58120-58129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58130-58139 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58140-58149 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 58150-58159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58160-58169 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58170-58179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 58180-58189 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 58190-58199 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58200-58209 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58210-58219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58220-58229 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58230-58239 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 58240-58249 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58250-58259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58260-58269 + 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 58270-58279 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 58280-58289 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58290-58299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 58300-58309 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58310-58319 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58320-58329 + 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 58330-58339 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 58340-58349 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58350-58359 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 58360-58369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 58370-58379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58380-58389 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 58390-58399 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58400-58409 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 58410-58419 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58420-58429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58430-58439 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58440-58449 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 58450-58459 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58460-58469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58470-58479 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 58480-58489 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58490-58499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58500-58509 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 58510-58519 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58520-58529 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58530-58539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 58540-58549 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58550-58559 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58560-58569 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 58570-58579 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58580-58589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58590-58599 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 58600-58609 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 58610-58619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58620-58629 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 58630-58639 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58640-58649 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58650-58659 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58660-58669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 58670-58679 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58680-58689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 58690-58699 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58700-58709 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58710-58719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58720-58729 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58730-58739 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58740-58749 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58750-58759 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58760-58769 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58770-58779 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 42, // 58780-58789 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 58790-58799 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 58800-58809 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58810-58819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58820-58829 + 1, 58, 57, 56, 55, 54, 53, 52, 51, 50, // 58830-58839 + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 58840-58849 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 58850-58859 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 58860-58869 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58870-58879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 58880-58889 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58890-58899 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 58900-58909 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58910-58919 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58920-58929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58930-58939 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 58940-58949 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58950-58959 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 58960-58969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 58970-58979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58980-58989 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58990-58999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 59000-59009 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59010-59019 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 59020-59029 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59030-59039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59040-59049 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59050-59059 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59060-59069 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59070-59079 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59080-59089 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59090-59099 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59100-59109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 59110-59119 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 59120-59129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59130-59139 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 59140-59149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59150-59159 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 59160-59169 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59170-59179 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59180-59189 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59190-59199 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 59200-59209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 59210-59219 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59220-59229 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 59230-59239 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 59240-59249 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59250-59259 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59260-59269 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 59270-59279 + 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 59280-59289 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 59290-59299 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 59300-59309 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59310-59319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59320-59329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 59330-59339 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59340-59349 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 59350-59359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59360-59369 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59370-59379 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59380-59389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59390-59399 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59400-59409 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 59410-59419 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59420-59429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59430-59439 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 59440-59449 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59450-59459 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59460-59469 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 59470-59479 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 59480-59489 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 59490-59499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 59500-59509 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 59510-59519 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 59520-59529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 59530-59539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 59540-59549 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59550-59559 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 59560-59569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59570-59579 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 59580-59589 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59590-59599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59600-59609 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59610-59619 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 59620-59629 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59630-59639 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59640-59649 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 59650-59659 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 59660-59669 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59670-59679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59680-59689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59690-59699 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 59700-59709 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59710-59719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 59720-59729 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59730-59739 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 59740-59749 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 59750-59759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59760-59769 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 59770-59779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59780-59789 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 59790-59799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 59800-59809 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59810-59819 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59820-59829 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 59830-59839 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59840-59849 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59850-59859 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 59860-59869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59870-59879 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 59880-59889 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 59890-59899 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59900-59909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59910-59919 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 59920-59929 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59930-59939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59940-59949 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 59950-59959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59960-59969 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59970-59979 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 59980-59989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 59990-59999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60000-60009 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 60010-60019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60020-60029 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60030-60039 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 60040-60049 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 60050-60059 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60060-60069 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60070-60079 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 60080-60089 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60090-60099 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 60100-60109 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60110-60119 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60120-60129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 60130-60139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60140-60149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60150-60159 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 40, // 60160-60169 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60170-60179 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60180-60189 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60190-60199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60200-60209 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60210-60219 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 60220-60229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 60230-60239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60240-60249 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 60250-60259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60260-60269 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60270-60279 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 60280-60289 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 60290-60299 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60300-60309 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 60310-60319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60320-60329 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60330-60339 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60340-60349 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 60350-60359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60360-60369 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60370-60379 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60380-60389 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 60390-60399 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60400-60409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60410-60419 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 60420-60429 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60430-60439 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 60440-60449 + 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 60450-60459 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 60460-60469 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 60470-60479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60480-60489 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 60490-60499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60500-60509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60510-60519 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 60520-60529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 50, // 60530-60539 + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 60540-60549 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60550-60559 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60560-60569 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60570-60579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60580-60589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60590-60599 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60600-60609 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60610-60619 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 60620-60629 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 60630-60639 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 60640-60649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 60650-60659 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60660-60669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 60670-60679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 60680-60689 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60690-60699 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 60700-60709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60710-60719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60720-60729 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 60730-60739 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60740-60749 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60750-60759 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60760-60769 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 60770-60779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60780-60789 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 60790-60799 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60800-60809 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60810-60819 + 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60820-60829 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60830-60839 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60840-60849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 60850-60859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 60860-60869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60870-60879 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 60880-60889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 60890-60899 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60900-60909 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 60910-60919 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60920-60929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60930-60939 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60940-60949 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 60950-60959 + 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 60960-60969 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 60970-60979 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 60980-60989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60990-60999 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 61000-61009 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61010-61019 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61020-61029 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61030-61039 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61040-61049 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 61050-61059 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61060-61069 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61070-61079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61080-61089 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 61090-61099 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61100-61109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61110-61119 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 61120-61129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61130-61139 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61140-61149 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61150-61159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 42, // 61160-61169 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 61170-61179 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61180-61189 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61190-61199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61200-61209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61210-61219 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61220-61229 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61230-61239 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61240-61249 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61250-61259 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61260-61269 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61270-61279 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61280-61289 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 61290-61299 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61300-61309 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61310-61319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61320-61329 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 61330-61339 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61340-61349 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61350-61359 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61360-61369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 61370-61379 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61380-61389 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61390-61399 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 61400-61409 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 61410-61419 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61420-61429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61430-61439 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61440-61449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61450-61459 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 61460-61469 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61470-61479 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 61480-61489 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61490-61499 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61500-61509 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 61510-61519 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61520-61529 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61530-61539 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 61540-61549 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 61550-61559 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61560-61569 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61570-61579 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 61580-61589 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61590-61599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 61600-61609 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61610-61619 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61620-61629 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61630-61639 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61640-61649 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 61650-61659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61660-61669 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61670-61679 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 61680-61689 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61690-61699 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61700-61709 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61710-61719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 61720-61729 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61730-61739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61740-61749 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 61750-61759 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61760-61769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61770-61779 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 61780-61789 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61790-61799 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61800-61809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 61810-61819 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61820-61829 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61830-61839 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 61840-61849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61850-61859 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61860-61869 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 61870-61879 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 61880-61889 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 61890-61899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 61900-61909 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61910-61919 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61920-61929 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61930-61939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 61940-61949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61950-61959 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 61960-61969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 61970-61979 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61980-61989 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61990-61999 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62000-62009 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 62010-62019 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62020-62029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62030-62039 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62040-62049 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 62050-62059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62060-62069 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62070-62079 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62080-62089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 62090-62099 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62100-62109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 62110-62119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62120-62129 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62130-62139 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 62140-62149 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 62150-62159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62160-62169 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62170-62179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62180-62189 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62190-62199 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62200-62209 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 62210-62219 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62220-62229 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 62230-62239 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 62240-62249 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62250-62259 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62260-62269 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 62270-62279 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62280-62289 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 62290-62299 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62300-62309 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62310-62319 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 62320-62329 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62330-62339 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62340-62349 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 62350-62359 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62360-62369 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62370-62379 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62380-62389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62390-62399 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62400-62409 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62410-62419 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 62420-62429 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 62430-62439 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62440-62449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62450-62459 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62460-62469 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 62470-62479 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 62480-62489 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62490-62499 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 62500-62509 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62510-62519 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62520-62529 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 62530-62539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 62540-62549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62550-62559 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62560-62569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62570-62579 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62580-62589 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62590-62599 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 62600-62609 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 62610-62619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62620-62629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 62630-62639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62640-62649 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 62650-62659 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62660-62669 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62670-62679 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 62680-62689 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62690-62699 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62700-62709 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62710-62719 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62720-62729 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62730-62739 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 62740-62749 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62750-62759 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62760-62769 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62770-62779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62780-62789 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62790-62799 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62800-62809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62810-62819 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 62820-62829 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 62830-62839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62840-62849 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62850-62859 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 62860-62869 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 62870-62879 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62880-62889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62890-62899 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62900-62909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62910-62919 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 62920-62929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 62930-62939 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 62940-62949 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62950-62959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62960-62969 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62970-62979 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 40, // 62980-62989 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 62990-62999 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63000-63009 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63010-63019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63020-63029 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63030-63039 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63040-63049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63050-63059 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63060-63069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 63070-63079 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63080-63089 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63090-63099 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 63100-63109 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 63110-63119 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63120-63129 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63130-63139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 63140-63149 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63150-63159 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63160-63169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63170-63179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63180-63189 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 63190-63199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63200-63209 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 63210-63219 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63220-63229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63230-63239 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 63240-63249 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 63250-63259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63260-63269 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63270-63279 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63280-63289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 63290-63299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63300-63309 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 63310-63319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63320-63329 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63330-63339 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63340-63349 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63350-63359 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63360-63369 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63370-63379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63380-63389 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63390-63399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 63400-63409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63410-63419 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63420-63429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 63430-63439 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 63440-63449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63450-63459 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 63460-63469 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 63470-63479 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63480-63489 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 63490-63499 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63500-63509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63510-63519 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63520-63529 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63530-63539 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63540-63549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63550-63559 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63560-63569 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63570-63579 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 63580-63589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63590-63599 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63600-63609 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63610-63619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63620-63629 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63630-63639 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 63640-63649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63650-63659 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63660-63669 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63670-63679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63680-63689 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63690-63699 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 63700-63709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63710-63719 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63720-63729 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63730-63739 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 63740-63749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63750-63759 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63760-63769 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63770-63779 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63780-63789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 63790-63799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 63800-63809 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63810-63819 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 63820-63829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63830-63839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63840-63849 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 63850-63859 + 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 63860-63869 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 63870-63879 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63880-63889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63890-63899 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63900-63909 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 63910-63919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 63920-63929 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63930-63939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 63940-63949 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 63950-63959 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63960-63969 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 63970-63979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63980-63989 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63990-63999 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64000-64009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 64010-64019 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64020-64029 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 64030-64039 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64040-64049 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64050-64059 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 64060-64069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64070-64079 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64080-64089 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64090-64099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64100-64109 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64110-64119 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 64120-64129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64130-64139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64140-64149 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 64150-64159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64160-64169 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64170-64179 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 64180-64189 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64190-64199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64200-64209 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64210-64219 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64220-64229 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 64230-64239 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 64240-64249 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64250-64259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64260-64269 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64270-64279 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64280-64289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64290-64299 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 64300-64309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 64310-64319 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64320-64329 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 64330-64339 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 64340-64349 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64350-64359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64360-64369 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64370-64379 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64380-64389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64390-64399 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 64400-64409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64410-64419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64420-64429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 64430-64439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64440-64449 + 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 64450-64459 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64460-64469 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64470-64479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 64480-64489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64490-64499 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64500-64509 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 64510-64519 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 64520-64529 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64530-64539 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64540-64549 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 64550-64559 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 64560-64569 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 64570-64579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64580-64589 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64590-64599 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64600-64609 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64610-64619 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64620-64629 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 64630-64639 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64640-64649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64650-64659 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 64660-64669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64670-64679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64680-64689 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 64690-64699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 64700-64709 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 64710-64719 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64720-64729 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64730-64739 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 64740-64749 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64750-64759 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64760-64769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64770-64779 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 64780-64789 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64790-64799 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64800-64809 + 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 64810-64819 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 64820-64829 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64830-64839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64840-64849 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64850-64859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64860-64869 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 64870-64879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64880-64889 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64890-64899 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64900-64909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 64910-64919 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 64920-64929 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 64930-64939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64940-64949 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64950-64959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 64960-64969 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64970-64979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64980-64989 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64990-64999 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 65000-65009 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65010-65019 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 65020-65029 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 65030-65039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65040-65049 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 65050-65059 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 65060-65069 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65070-65079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 65080-65089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 65090-65099 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65100-65109 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 65110-65119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 65120-65129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65130-65139 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 65140-65149 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65150-65159 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 65160-65169 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 65170-65179 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 65180-65189 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65190-65199 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 65200-65209 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 65210-65219 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65220-65229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 65230-65239 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65240-65249 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 65250-65259 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 65260-65269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65270-65279 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 65280-65289 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 65290-65299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 65300-65309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65310-65319 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 65320-65329 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 65330-65339 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65340-65349 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 65350-65359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65360-65369 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65370-65379 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65380-65389 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 65390-65399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 65400-65409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 65410-65419 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 65420-65429 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 65430-65439 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 65440-65449 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 65450-65459 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65460-65469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 65470-65479 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65480-65489 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 65490-65499 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65500-65509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 65510-65519 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 65520-65529 + 0, 0, 0, 0, 0, 0, + } + + lohi [256]struct{ lo, hi int } +) + +func init() { + for i, v := range liars { + blk := v >> 24 + x := &lohi[blk] + if x.lo == 0 || i < x.lo { + x.lo = i + } + if i > x.hi { + x.hi = i + } + } +} diff --git a/internal/mathutil/test_deps.go b/internal/mathutil/test_deps.go new file mode 100644 index 0000000..3d899a1 --- /dev/null +++ b/internal/mathutil/test_deps.go @@ -0,0 +1,11 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mathutil // import "github.com/hanzoai/sqlite/internal/mathutil" + +// Pull test dependencies too. +// Enables easy 'go test X' after 'go get X' +import ( +// nothing yet +) diff --git a/internal/memory/LICENSE b/internal/memory/LICENSE new file mode 100644 index 0000000..967339a --- /dev/null +++ b/internal/memory/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2017 The Memory Authors. 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 names of the authors nor the names of the +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. diff --git a/internal/memory/memory.go b/internal/memory/memory.go new file mode 100644 index 0000000..e65a4e7 --- /dev/null +++ b/internal/memory/memory.go @@ -0,0 +1,469 @@ +// Copyright 2017 The Memory Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package memory implements a memory allocator. +// +// # Build status +// +// available at https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fmemory +// +// # Changelog +// +// 2017-10-03 Added alternative, unsafe.Pointer-based API. +// +// Package memory implements a memory allocator. +// +// # Changelog +// +// 2017-10-03 Added alternative, unsafe.Pointer-based API. +// +// # Benchmarks +// +// jnml@3900x:~/src/github.com/hanzoai/sqlite/internal/memory$ date ; go version ; go test -run @ -bench . -benchmem |& tee log +// Mon Sep 25 16:02:02 CEST 2023 +// go version go1.21.1 linux/amd64 +// goos: linux +// goarch: amd64 +// pkg: github.com/hanzoai/sqlite/internal/memory +// cpu: AMD Ryzen 9 3900X 12-Core Processor +// BenchmarkFree16-24 123506772 9.802 ns/op 0 B/op 0 allocs/op +// BenchmarkFree32-24 73853230 15.08 ns/op 0 B/op 0 allocs/op +// BenchmarkFree64-24 43070334 25.15 ns/op 0 B/op 0 allocs/op +// BenchmarkCalloc16-24 59353304 18.92 ns/op 0 B/op 0 allocs/op +// BenchmarkCalloc32-24 39415004 29.00 ns/op 0 B/op 0 allocs/op +// BenchmarkCalloc64-24 35825725 32.02 ns/op 0 B/op 0 allocs/op +// BenchmarkGoCalloc16-24 38274313 26.99 ns/op 16 B/op 1 allocs/op +// BenchmarkGoCalloc32-24 44590477 33.06 ns/op 32 B/op 1 allocs/op +// BenchmarkGoCalloc64-24 44233016 37.20 ns/op 64 B/op 1 allocs/op +// BenchmarkMalloc16-24 145736911 7.720 ns/op 0 B/op 0 allocs/op +// BenchmarkMalloc32-24 128898334 7.887 ns/op 0 B/op 0 allocs/op +// BenchmarkMalloc64-24 149569483 7.994 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrFree16-24 117043012 9.205 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrFree32-24 77399617 14.20 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrFree64-24 48770785 25.04 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrCalloc16-24 79257636 15.44 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrCalloc32-24 49644562 23.62 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrCalloc64-24 39854710 28.22 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrMalloc16-24 252987727 4.525 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrMalloc32-24 241423840 4.433 ns/op 0 B/op 0 allocs/op +// BenchmarkUintptrMalloc64-24 256450324 4.669 ns/op 0 B/op 0 allocs/op +// PASS +// ok github.com/hanzoai/sqlite/internal/memory 93.178s +// jnml@3900x:~/src/github.com/hanzoai/sqlite/internal/memory$ +package memory // import "github.com/hanzoai/sqlite/internal/memory" + +import ( + "fmt" + "math/bits" + "os" + "unsafe" +) + +const ( + headerSize = unsafe.Sizeof(page{}) + mallocAllign = 2 * unsafe.Sizeof(uintptr(0)) + maxSlotSize = 1 << maxSlotSizeLog + maxSlotSizeLog = pageSizeLog - 2 + pageAvail = pageSize - headerSize + pageMask = pageSize - 1 + pageSize = 1 << pageSizeLog +) + +func init() { + if unsafe.Sizeof(page{})%mallocAllign != 0 { + panic("internal error") + } +} + +// if n%m != 0 { n += m-n%m }. m must be a power of 2. +func roundup(n, m int) int { return (n + m - 1) &^ (m - 1) } + +type node struct { + prev, next uintptr // *node +} + +type page struct { + brk int + log uint + size int + used int +} + +// Allocator allocates and frees memory. Its zero value is ready for use. The +// exported counters are updated only when build tag memory.counters is +// present. +type Allocator struct { + Allocs int // # of allocs. + Bytes int // Asked from OS. + cap [64]int + lists [64]uintptr // *node + Mmaps int // Asked from OS. + pages [64]uintptr // *page + regs map[uintptr]struct{} // map[*page]struct{} +} + +func (a *Allocator) mmap(size int) (uintptr /* *page */, error) { + p, size, err := mmap(size) + if err != nil { + return 0, err + } + + //TODO(jnml) The returned size may now be nearly as twice as large as we asked + //for. Use that extra capacity. For that we need to move the respective + //Allocator.cap item into the page struct so the page cap becomes dynamic. + // + // Related: This is a consequence of fixing the bigsort.test failures on + // linux/s390x, see: https://gitlab.com/cznic/sqlite/-/issues/207 + if counters { + a.Mmaps++ + a.Bytes += size + } + if a.regs == nil { + a.regs = map[uintptr]struct{}{} + } + (*page)(unsafe.Pointer(p)).size = size + a.regs[p] = struct{}{} + return p, nil +} + +func (a *Allocator) newPage(size int) (uintptr /* *page */, error) { + size += int(headerSize) + p, err := a.mmap(size) + if err != nil { + return 0, err + } + + (*page)(unsafe.Pointer(p)).log = 0 + return p, nil +} + +func (a *Allocator) newSharedPage(log uint) (uintptr /* *page */, error) { + if a.cap[log] == 0 { + a.cap[log] = int(pageAvail) / (1 << log) + } + size := int(headerSize) + a.cap[log]< maxSlotSizeLog { + p, err := a.newPage(size) + if err != nil { + return 0, err + } + + return p + headerSize, nil + } + + if a.lists[log] == 0 && a.pages[log] == 0 { + if _, err := a.newSharedPage(log); err != nil { + return 0, err + } + } + + if p := a.pages[log]; p != 0 { + (*page)(unsafe.Pointer(p)).used++ + (*page)(unsafe.Pointer(p)).brk++ + if (*page)(unsafe.Pointer(p)).brk == a.cap[log] { + a.pages[log] = 0 + } + return p + headerSize + uintptr((*page)(unsafe.Pointer(p)).brk-1)<= size { + return p, nil + } + + if r, err = a.UintptrMalloc(size); err != nil { + return 0, err + } + + if us < size { + size = us + } + copy((*rawmem)(unsafe.Pointer(r))[:size:size], (*rawmem)(unsafe.Pointer(p))[:size:size]) + return r, a.UintptrFree(p) +} + +// UintptrUsableSize is like UsableSize except its argument is an uintptr, +// which must have been returned from UintptrCalloc, UintptrMalloc or +// UintptrRealloc. +func UintptrUsableSize(p uintptr) (r int) { + if trace { + defer func() { + fmt.Fprintf(os.Stderr, "UsableSize(%#x) %#x\n", p, r) + }() + } + if p == 0 { + return 0 + } + + return usableSize(p) +} + +func usableSize(p uintptr) (r int) { + pg := p &^ uintptr(pageMask) + if log := (*page)(unsafe.Pointer(pg)).log; log != 0 { + return 1 << log + } + + return (*page)(unsafe.Pointer(pg)).size - int(headerSize) +} + +// Calloc is like Malloc except the allocated memory is zeroed. +func (a *Allocator) Calloc(size int) (r []byte, err error) { + p, err := a.UintptrCalloc(size) + if err != nil { + return nil, err + } + + return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil +} + +// Close releases all OS resources used by a and sets it to its zero value. +// +// It's not necessary to Close the Allocator when exiting a process. +func (a *Allocator) Close() (err error) { + for p := range a.regs { + if e := a.unmap(p); e != nil && err == nil { + err = e + } + } + *a = Allocator{} + return err +} + +// Free deallocates memory (as in C.free). The argument of Free must have been +// acquired from Calloc or Malloc or Realloc. +func (a *Allocator) Free(b []byte) (err error) { + if b = b[:cap(b)]; len(b) == 0 { + return nil + } + + return a.UintptrFree(uintptr(unsafe.Pointer(&b[0]))) +} + +// Malloc allocates size bytes and returns a byte slice of the allocated +// memory. The memory is not initialized. Malloc panics for size < 0 and +// returns (nil, nil) for zero size. +// +// It's ok to reslice the returned slice but the result of appending to it +// cannot be passed to Free or Realloc as it may refer to a different backing +// array afterwards. +func (a *Allocator) Malloc(size int) (r []byte, err error) { + p, err := a.UintptrMalloc(size) + if p == 0 || err != nil { + return nil, err + } + + return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil +} + +// Realloc changes the size of the backing array of b to size bytes or returns +// an error, if any. The contents will be unchanged in the range from the +// start of the region up to the minimum of the old and new sizes. If the +// new size is larger than the old size, the added memory will not be +// initialized. If b's backing array is of zero size, then the call is +// equivalent to Malloc(size), for all values of size; if size is equal to +// zero, and b's backing array is not of zero size, then the call is equivalent +// to Free(b). Unless b's backing array is of zero size, it must have been +// returned by an earlier call to Malloc, Calloc or Realloc. If the area +// pointed to was moved, a Free(b) is done. +func (a *Allocator) Realloc(b []byte, size int) (r []byte, err error) { + var p uintptr + if b = b[:cap(b)]; len(b) != 0 { + p = uintptr(unsafe.Pointer(&b[0])) + } + if p, err = a.UintptrRealloc(p, size); p == 0 || err != nil { + return nil, err + } + + return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil +} + +// UsableSize reports the size of the memory block allocated at p, which must +// point to the first byte of a slice returned from Calloc, Malloc or Realloc. +// The allocated memory block size can be larger than the size originally +// requested from Calloc, Malloc or Realloc. +func UsableSize(p *byte) (r int) { return UintptrUsableSize(uintptr(unsafe.Pointer(p))) } + +// UnsafeCalloc is like Calloc except it returns an unsafe.Pointer. +func (a *Allocator) UnsafeCalloc(size int) (r unsafe.Pointer, err error) { + p, err := a.UintptrCalloc(size) + if err != nil { + return nil, err + } + + return unsafe.Pointer(p), nil +} + +// UnsafeFree is like Free except its argument is an unsafe.Pointer, which must +// have been acquired from UnsafeCalloc or UnsafeMalloc or UnsafeRealloc. +func (a *Allocator) UnsafeFree(p unsafe.Pointer) (err error) { return a.UintptrFree(uintptr(p)) } + +// UnsafeMalloc is like Malloc except it returns an unsafe.Pointer. +func (a *Allocator) UnsafeMalloc(size int) (r unsafe.Pointer, err error) { + p, err := a.UintptrMalloc(size) + if err != nil { + return nil, err + } + + return unsafe.Pointer(p), nil +} + +// UnsafeRealloc is like Realloc except its first argument is an +// unsafe.Pointer, which must have been returned from UnsafeCalloc, +// UnsafeMalloc or UnsafeRealloc. +func (a *Allocator) UnsafeRealloc(p unsafe.Pointer, size int) (r unsafe.Pointer, err error) { + q, err := a.UintptrRealloc(uintptr(p), size) + if err != nil { + return nil, err + } + + return unsafe.Pointer(q), nil +} + +// UnsafeUsableSize is like UsableSize except its argument is an +// unsafe.Pointer, which must have been returned from UnsafeCalloc, +// UnsafeMalloc or UnsafeRealloc. +func UnsafeUsableSize(p unsafe.Pointer) (r int) { return UintptrUsableSize(uintptr(p)) } diff --git a/internal/memory/memory64.go b/internal/memory/memory64.go new file mode 100644 index 0000000..9bb5212 --- /dev/null +++ b/internal/memory/memory64.go @@ -0,0 +1,10 @@ +// Copyright 2018 The Memory Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build amd64 || amd64p32 || arm64 || arm64be || mips64 || mips64le || mips64p32 || mips64p32le || ppc64 || ppc64le || sparc64 || riscv64 || loong64 +// +build amd64 amd64p32 arm64 arm64be mips64 mips64le mips64p32 mips64p32le ppc64 ppc64le sparc64 riscv64 loong64 + +package memory // import "github.com/hanzoai/sqlite/internal/memory" + +type rawmem [1<<50 - 1]byte diff --git a/internal/memory/mmap_unix.go b/internal/memory/mmap_unix.go new file mode 100644 index 0000000..1a7eacb --- /dev/null +++ b/internal/memory/mmap_unix.go @@ -0,0 +1,70 @@ +// Copyright 2011 Evan Shaw. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE-MMAP-GO file. + +//go:build unix + +// Modifications (c) 2017 The Memory Authors. + +package memory // import "github.com/hanzoai/sqlite/internal/memory" + +import ( + "golang.org/x/sys/unix" + "os" + "unsafe" +) + +const pageSizeLog = 16 + +var ( + osPageMask = osPageSize - 1 + osPageSize = os.Getpagesize() +) + +func unmap(addr uintptr, size int) error { + return unix.MunmapPtr(unsafe.Pointer(addr), uintptr(size)) +} + +// pageSize aligned. +func mmap(size int) (uintptr, int, error) { + size = roundup(size, osPageSize) + // Ask for more so we can align the result at a pageSize boundary + n := size + pageSize + up, err := unix.MmapPtr(-1, 0, nil, uintptr(n), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_PRIVATE|unix.MAP_ANON) + if err != nil { + return 0, 0, err + } + + p := uintptr(up) + if p&uintptr(osPageMask) != 0 { + panic("internal error") + } + + mod := int(p) & pageMask + if mod != 0 { // Return the extra part before pageSize aligned block + m := pageSize - mod + if err := unmap(p, m); err != nil { + unmap(p, n) // Do not leak the first mmap + return 0, 0, err + } + + n -= m + p += uintptr(m) + } + + if p&uintptr(pageMask) != 0 { + panic("internal error") + } + + if n > size { // Return the extra part after pageSize aligned block + if err := unmap(p+uintptr(size), n-size); err != nil { + // Do not error when the kernel rejects the extra part after, just return the + // unexpectedly enlarged size. + // + // Fixes the bigsort.test failures on linux/s390x, see: https://gitlab.com/cznic/sqlite/-/issues/207 + size = n + } + } + + return p, size, nil +} diff --git a/internal/memory/nocounters.go b/internal/memory/nocounters.go new file mode 100644 index 0000000..8e01b84 --- /dev/null +++ b/internal/memory/nocounters.go @@ -0,0 +1,10 @@ +// Copyright 2017 The Memory Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !memory.counters +// +build !memory.counters + +package memory // import "github.com/hanzoai/sqlite/internal/memory" + +const counters = false diff --git a/internal/memory/trace_disabled.go b/internal/memory/trace_disabled.go new file mode 100644 index 0000000..4d9c260 --- /dev/null +++ b/internal/memory/trace_disabled.go @@ -0,0 +1,10 @@ +// Copyright 2017 The Memory Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !memory.trace +// +build !memory.trace + +package memory // import "github.com/hanzoai/sqlite/internal/memory" + +const trace = false diff --git a/sqlcipher_pure_test.go b/sqlcipher_pure_test.go new file mode 100644 index 0000000..5e426a9 --- /dev/null +++ b/sqlcipher_pure_test.go @@ -0,0 +1,161 @@ +package sqlite + +import ( + "bytes" + "encoding/hex" + "os" + "path/filepath" + "testing" + + "github.com/hanzoai/sqlcipher" +) + +// cKey is the raw 256-bit key that testdata/c-sqlcipher-4.5.6.db was written under +// by the real C SQLCipher library (copied from github.com/hanzoai/sqlcipher's +// testdata, where the byte-for-byte fixture originates). +var cKey = mustHexKey("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f") + +func mustHexKey(s string) []byte { b, _ := hex.DecodeString(s); return b } + +// TestOpensCWrittenSQLCipherDB proves byte-compatibility one way: a database +// written by the C SQLCipher library opens and reads through this driver. On a +// pure-Go build that is the codec VFS; on a linked cgo build it is libsqlcipher. +func TestOpensCWrittenSQLCipherDB(t *testing.T) { + if !CodecLinked() { + t.Skip("cgo build without libsqlcipher; byte-compat proven on the pure-Go build") + } + // Work on a copy: opening may convert it to WAL. + src, err := os.ReadFile("testdata/c-sqlcipher-4.5.6.db") + if err != nil { + t.Fatal(err) + } + p := filepath.Join(t.TempDir(), "c.db") + if err := os.WriteFile(p, src, 0o600); err != nil { + t.Fatal(err) + } + + db, err := Open(p, WithRawKey(cKey)) + if err != nil { + t.Fatalf("open C-written db: %v", err) + } + defer db.Close() + var n int + if err := db.QueryRow(`SELECT count(*) FROM sqlite_master`).Scan(&n); err != nil { + t.Fatalf("read C-written schema: %v", err) + } + if n == 0 { + t.Fatal("C-written db has an empty schema — decryption likely wrong") + } + t.Logf("opened C-written SQLCipher db, %d schema objects", n) + + // Wrong key must be rejected, not silently return garbage. + wrong := append([]byte(nil), cKey...) + wrong[0] ^= 0xFF + if bad, err := Open(p+"-nope", WithRawKey(wrong)); err == nil { + bad.Close() + } + db2, err := Open(p, WithRawKey(wrong)) + if err == nil { + err = db2.QueryRow(`SELECT count(*) FROM sqlite_master`).Scan(&n) + db2.Close() + } + if err == nil { + t.Fatal("wrong key opened the C-written db — key not enforced") + } +} + +// TestPureGoWALRoundTripAndByteCompat exercises the full encrypted lifecycle on a +// newly-created database: WAL writes, read-back before and after checkpoint, +// reopen persistence, no plaintext on disk, and byte-compatibility the OTHER way — +// a database this driver wrote decrypts with the standalone hanzoai/sqlcipher +// codec (which is itself gated byte-for-byte against C SQLCipher). +func TestPureGoWALRoundTripAndByteCompat(t *testing.T) { + if !CodecLinked() { + t.Skip("cgo build without libsqlcipher; run on the pure-Go build") + } + key := make([]byte, 32) + for i := range key { + key[i] = byte(i*11 + 3) + } + dir := t.TempDir() + p := filepath.Join(dir, "store.db") + + db, err := Open(p, WithRawKey(key)) + if err != nil { + t.Fatalf("open: %v", err) + } + if _, err := db.Exec(`CREATE TABLE t(id INTEGER PRIMARY KEY, v BLOB)`); err != nil { + t.Fatalf("create: %v", err) + } + blob := bytes.Repeat([]byte{0x5A}, 400) + tx, _ := db.Begin() + st, _ := tx.Prepare(`INSERT INTO t(v) VALUES(?)`) + for i := 0; i < 1500; i++ { // enough rows to spill many WAL frames + new pages + if _, err := st.Exec(blob); err != nil { + t.Fatalf("insert %d: %v", i, err) + } + } + st.Close() + if err := tx.Commit(); err != nil { + t.Fatalf("commit: %v", err) + } + + // Read back BEFORE checkpoint: served through the WAL via the codec. + var n int + if err := db.QueryRow(`SELECT count(*) FROM t`).Scan(&n); err != nil || n != 1500 { + t.Fatalf("read from WAL: n=%d err=%v (want 1500)", n, err) + } + var got []byte + if err := db.QueryRow(`SELECT v FROM t WHERE id=750`).Scan(&got); err != nil || !bytes.Equal(got, blob) { + t.Fatalf("WAL row 750 mismatch: err=%v", err) + } + if _, err := db.Exec(`PRAGMA wal_checkpoint(TRUNCATE)`); err != nil { + t.Fatalf("checkpoint: %v", err) + } + if err := db.Close(); err != nil { + t.Fatalf("close: %v", err) + } + + // Reopen: data persisted, decrypts from the main file. + db2, err := Open(p, WithRawKey(key)) + if err != nil { + t.Fatalf("reopen: %v", err) + } + if err := db2.QueryRow(`SELECT count(*) FROM t`).Scan(&n); err != nil || n != 1500 { + db2.Close() + t.Fatalf("after reopen: n=%d err=%v (want 1500)", n, err) + } + // Write MORE after reopen (WAL again on an existing db). + if _, err := db2.Exec(`INSERT INTO t(v) VALUES(?)`, blob); err != nil { + db2.Close() + t.Fatalf("post-reopen insert: %v", err) + } + db2.Exec(`PRAGMA wal_checkpoint(TRUNCATE)`) + db2.Close() + + // No plaintext on disk. + raw, _ := os.ReadFile(p) + if bytes.HasPrefix(raw, []byte("SQLite format 3\x00")) { + t.Fatal("main db has a plaintext SQLite header — not encrypted") + } + if bytes.Contains(raw, blob) { + t.Fatal("plaintext row blob found on disk — not encrypted") + } + + // Byte-compat (the other direction): the standalone codec decrypts what this + // driver wrote, yielding a valid plaintext SQLite database. + os.Remove(p + "-wal") + in, err := os.Open(p) + if err != nil { + t.Fatal(err) + } + defer in.Close() + var plain bytes.Buffer + if err := sqlcipher.DecryptFile(&plain, in, sqlcipher.RawKey(key), sqlcipher.Params{}); err != nil { + t.Fatalf("standalone codec could not decrypt driver-written db: %v", err) + } + if !bytes.HasPrefix(plain.Bytes(), []byte("SQLite format 3\x00")) { + t.Fatal("decrypted output is not a valid SQLite database — format mismatch with C SQLCipher") + } + t.Logf("OK: %d encrypted bytes on disk, WAL round-tripped, byte-compatible both ways", len(raw)) +} diff --git a/sqlite.go b/sqlite.go index 0ea2d45..82087ce 100644 --- a/sqlite.go +++ b/sqlite.go @@ -1,30 +1,34 @@ // Package sqlite provides an encrypted SQLite driver for Hanzo. // -// It is dual-backend and registers the database/sql driver name "sqlite" -// under BOTH build configurations, exposing the same public API either way: +// Both backends encrypt at rest, in the SAME SQLCipher-4 on-disk format, and a +// database written by one opens under the other. The driver registers the +// database/sql driver name "sqlite" under BOTH build configurations, exposing the +// same public API either way: // -// - CGO (//go:build cgo) → mattn/go-sqlite3 + SQLCipher: page-level -// AES-256 encryption at rest. This is the production engine. Build with: +// - !CGO (//go:build !cgo) → the vendored pure-Go SQLite engine +// (internal/engine) plus the hanzoai/sqlcipher codec VFS: page-level AES-256 +// encryption at rest, with NO cgo and NO external C library. This is what +// CGO-off CI, tests, lint, and pure-Go deployments run. Nothing to link, no +// amalgamation to build — it always encrypts. +// - CGO (//go:build cgo) → hanzoai/csqlite + libsqlcipher: the same page-level +// AES-256 format via the C codec, for builds that want the C engine's speed. +// Build with: // CGO_ENABLED=1 \ // CGO_CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_USE_URI=1 -I/include/sqlcipher" \ // CGO_LDFLAGS="-lsqlcipher" \ // go build -tags "libsqlite3 sqlite_fts5" -// NOTE: the `sqlcipher` tag is INERT in mainline mattn (ships PLAINTEXT); -// the real recipe is the `libsqlite3` tag linked against libsqlcipher with -// the codec + URI flags above. -// - !CGO (//go:build !cgo) → modernc.org/sqlite (pure Go): NO encryption. -// Used only for CGO-off CI (test + lint) and local dev. Demanding a key -// on this backend is a hard error — it never silently stores plaintext. +// A cgo build that forgets to link libsqlcipher silently writes plaintext; +// CodecLinked() proves the codec at runtime so such a build fails CI. // -// Because the "sqlite" driver name is registered under both tags, any code -// doing `_ "github.com/hanzoai/sqlite"` + `sql.Open("sqlite", dsn)` (e.g. Hanzo -// IAM's xorm engine) compiles and runs in CGO-off CI and runs encrypted in the -// CGO production build — one import, one driver name, two backends. +// Because the "sqlite" driver name is registered under both tags, any code doing +// `_ "github.com/hanzoai/sqlite"` + `sql.Open("sqlite", dsn)` (e.g. Hanzo IAM's +// xorm engine) compiles and runs encrypted under both — one import, one driver +// name, two backends, one format. // -// The encryption key, replication mode, threshold config, and per-principal -// CEK derivation (cek.go, threshold.go) are pure Go and live in tag-neutral -// files; only the database/sql driver registration and the connect-time pragma -// application differ by build tag (driver_cgo.go / driver_nocgo.go). +// The encryption key, replication mode, threshold config, and per-principal CEK +// derivation (cek.go, threshold.go) are pure Go and live in tag-neutral files; +// only the database/sql driver registration and the connect-time keying differ by +// build tag (driver_cgo.go / driver_nocgo.go). package sqlite import ( @@ -132,16 +136,17 @@ func (db *DB) Encrypted() bool { // CodecLinked reports whether at-rest encryption is ACTUALLY working in this // process — not merely advertised. EncryptionAvailable() is a backend-capability -// flag (true for any CGO build), but a CGO build that forgot to link +// flag (true under both build tags), but a CGO build that forgot to link // libsqlcipher silently writes PLAINTEXT. CodecLinked proves the codec at // runtime: it opens a temp DB under a key, writes a marker, and checks the // on-disk bytes are real ciphertext (no plaintext "SQLite format 3" header, // marker absent). // -// Use it to gate encryption assertions in tests: a properly-linked build runs -// them; a CGO-without-codec build SKIPS instead of failing on plaintext (the -// Dockerfile build, which links libsqlcipher, is where the hard ciphertext gate -// runs). Returns false on the pure-Go backend. +// The pure-Go backend always returns true — its codec VFS is compiled in, nothing +// to mis-link. On the CGO backend it returns true only when libsqlcipher is +// actually linked. Use it to gate encryption assertions in tests: the pure-Go +// build and a correctly-linked CGO build run them; a CGO-without-codec build SKIPS +// instead of failing on plaintext (the Dockerfile build is the hard gate there). func CodecLinked() bool { if !EncryptionAvailable() { return false diff --git a/testdata/c-sqlcipher-4.5.6.db b/testdata/c-sqlcipher-4.5.6.db new file mode 100644 index 0000000000000000000000000000000000000000..7aa95e82f7126d38c4a9407d262bea3a6ac0819a GIT binary patch literal 28672 zcmV(xKE4sd)<`O z?);`tA;vhpnXfd2_4)JBK~>T_)Og3TU*38mPbr9(x3gd*%z2NbjM)!>Gal_19B=)s z2qWe9X~7Llwjct?c!I*%N;_BhLwllxVxe&Q^D*C=;C#>Pvy1tRU=ao1rqOJWHb3T2 zC!1;}+hmPO!FNRjdr6xUQAs(_QdvO19Ohog&ay5qICaJYR_J5g0|UgnXLPSpl`oI; z=u*WSR_2H~`abQ}-joJjg!>6kvxy7LUkz_!B2grP;)ps5R^=V!pWqH~r5?LTm_Dt^ zxZlV56+vhoust-p0B8B3ew_0kLgp9s~ltf%mc6O^EMtr#M=z@-w#!ux5 z2HA@G9s5_d?|}Q(H1E10QD;X<2-sX=vAfV3-p!>kV(fGxJLe4@Q=$E9$k_Aqf-`t5 zGj^Hcwe`|f+`5qJpHYS{$;uBv^vx{3qMj3VHn~8Mfq$Q9dMr|oJAPG}k2N3E?H9RN z(>Z4%1ZkSV#238~m=w(-7&{8)#UKDZHpg69Qeu9a$;Zzzs zw)Er`k{dHRvg!TqrHB8CVjsdI0!G$TVdadLr%+S#hal+NwEVc}90*JTu0?MpnB5+1 zt>}j}>zY#*%c@dskuUQ37#W^q&$eIWsv6`RB^LbD_d6)Fb;iNHm)slBw?FMp@b zX=sYLkF@Uacqk!D@OO#bqiWk>UUa7n$?5V!z0!x~^4Hgym@kvEQ(Qfozzc<_m2lR$ zF+2tu`FKiPiS@9+Zl3Fz@~Fms)B^Wc-TFl**%%1nN!)#9a8y*E?n<}*?cx0(4EO}{ zkQ$pk=6yM%NHZ0E`j&GG$o2$K&VSY6OuR@q#~Vzm^w@eGa&Ky}zUBpmOZ3BL2JSCF zLQEB$TXlq~yH+%eV>T}#qcv>O+VL8tgvY|U#EH*e_Z+|-xDRN#c(yid?a^gbGFUdF z3ma@pp@YpgJT*ru`B;|`dgpK0`6w5-I|PmWCxzAGWFy65RS@><2XNvV%dY=)G(|=P zcto0i*sk0@9W%ye0&|4sRT-0*$n^Ii@$~eMp!w}iV%nYp%1vjVRRo&oXan26=F;&! zdT|wQ^9sLbaBL|6GL_3+?GxO_d)Dp6Dpd{vyN9*5)!YMB4Y)LcgE!waXXiH1)ToRP zpF=E4Yxu0ax-U=#maio=vn%G_c>^cQ7-X>QyDZX@JNd!E3WhTxwnr-s-^P98FK#%EmG#G%p*mR4wcX^nY#AF%_VNhw~yE^A}g5V7F`#5TMwmVo=%hr;` zK$gQEzjzLlxCX>s7Q3A4c6JK|Al~_e*?k>fE=Jo8{`*UhEELf0cy@IF&|-xJ84ym3 z)IeVLWqM-wJJ@=~Ign@c%Fgmm&FQqJ%lWU0>ii18D(8qJDlc0tTuk z8qx?j45GyZQL>LeHa54@V%@VN2q173h)6IpmmhvF*N@OV; zbCBwxkbUfI!OPrPnH3wRmWpQ2m?%)Z9v2fpl zfsE&8<_h@rOuAT2q(c)M7N3}N5D?G5)3X=G!i&~eahjLAfk=5-kk1fnEsNLsDXvPl zFAG2u(J_YCThbePY^#Kl{aJ|tHW61GMK`$ zA6vb7;NE*Vk{bgpL%hp&7o>yX%aabLG@On+6!@;(>MCmB)bTbiIx_rAm=E-DKh&He zW!5T`KvxTzTTIL$WOd{vFk~d~?_X~Xw%n;OUvWh@@`AHdys>z##chL}=-RzlQS|C& z@~%@`fR(XPYL8&87xjE_y{Y1X5p=62troRVinQnEYOr6N$bmBzUl1IiKKVFRF~4C1 zD};*e_-r5t0pVgh^sZUvzRlCrZR}ClklF?XCJf@{Db<5qan*Ihs8^5X3PJi?)xTxd z>FZ?KBU#8U3O_?E+E}d)@{m34GCNLWC162*{qa1+wH3tjYqP(*#tv_5HUPGbR__w3 zx~MFs3ZDjX^yG-f-V%{77pD{xH6~6`>v{;1btxIGRDGjs{P0?U?oJV&14K~XRC7@q zsl*N|b}XcV;)klvX}s6Ysrl%Y2pb5^@zwy~g6F(w^ynP+>qAIn1pM5tptX8W;k^-|# zb8Qpz8~8U6IE)5XXADt+e9hwCFM3*L*zY5Xa3NslgMmL(9}ypWeJiXE7YMxz`V7C??{>fYLL~{3Bq-(%&ao8 zCJYcAM{(=e9beTHq>~mIYY5SNVJ5UqHTW_5-_WS03N*28Sg?mJlxVlA7Dl*; zuZs~GnbibMWc*tw=!F~yjWarN9&bB9G*xjwPZrS~y()Yc3P87diw)HamkyYv9%X?H zD%)D8vFkzIYG<{_a=+LXKnI5l(rgT!Bk6!`&lTm=^bR(V$GZ>lxdPI+ty5)K>_8}$l&v_o zc?DoEPMt>IgW!bDun4+j5#02Azy=mO*mi0u#>l;Dl*zf;`;IJmqc;Bou`C^fmx2qc z;^7_8r~fJ#YRQt{Q;C#}U?Ad2$2h;uZPzim3jS*OkOzlx;)9nRO#s&x4r^Zf4WH!lTEKDJ2Sr%Iwx{d6A;*J=z@f%_ zttQ25tr93XkTCl#pRkfHUVC$zTHEYr z+EB?uW%rRs-)P`;85A1^Y_IUN7r6nsmryU;<*QuQ=4vH^X4i;WGl^q9U4K5X)^+xY zdOc(8n~$o0-=r8oe_-AjU>*PMJQ-Na`vZUjT4our1gt%zzUfaqs^j5C)}3-*GzkdV z!jF2ii@UR7ycuM0dr|4^oDD-Sfz};B`(6hhw=C+@?^g+f6NcrG4;Hi{FZ|-_(IX0H zVRzg%r)#rltJhbuTKAFRef?zds4ht`VMWoMvcfXcnNEd2O{eBR8*W^;L@Gdp=-y_E z&k}M7hwk$>dvjD_nRv&*-t^8&@ro+^<7Lkr8NpD6yGlW?40o4J#6vp<0Suc+1`Lee z)oY!q@T;`rwx}@qr0;viIxP_2B*j5n`G+JD8I_!CU{8Z4b-4cwLbr_zo<}@WVh3p8 zzgGQhpA(iS4J4EH5-nDO2NAFmW-3^fcz!B)jTnI zEKAaLiR#R@#I~NI^9_sdEOvh(RJ^0jD)cF3w~fsv)jh#olmCLywv2c9lgmj*Q^4~B z_j+`&wSQFUe8(1zd-g5C{}i&L81G+jLwlPNKi!$$ldmn2S)YyNh;_B`!f!#(9M0sM za9L>tjV5S6uPYiiMC`4S?US7Xn(vsB41w(qy9>WNpGggVi+0Zx3w`WC(8v>Lro30i z#CDM*A;ag$z2}F{t+W>Yb#@Mf4q^%pWCbtGKT7z2agkk7XnxO^VV03Pr?c**LUNaB zt1|H!?mV$_^zZBX41IjswZTC<0m);J;NB}~FVIT{9^Q-YA2iShzBNmYM03*7jaZBv zjKv}hE&$K`*A42O2+RF3pTt9@^nw#KSaUGl7#U>K_kZzEJuuc@k!xL*d*l-Ix%QFs z^^ayjCpeY(so9mEqC$9Hgrt1Mi??j`eO#`~%13d8LHYld5D(e%fXf^C>p9w1U zXhcWYm7iQ&wrd10Vw};ioPR6~$^tg=ZKxnZvT%^6NH_X~@7;2jiaO$jEEmghC@!I+ z0&oI}=YD9C8PMk@p!iIZj2zljDcYgSItEc4S~fu+;!38hg%XAT>X*S`_Kln-Wgc=* zhq=q|h=4V?l7J8cQw1$(`1A5&f=5avPX~Wo8<+q``9H^Y`9cZe5O^E9u#3-oR?gZE=VvX)=qXPdF zi-8@o@f(`iDgA5)h#e5|TlxO-#5eHur+++O9KFa9o?@EUcDaFNnOSt#f%fVCPS#tK zfoOGLBHt)m-? zHAXzeZq~6S8x%cmy0`y;a>WGY_DTge7jwtB#3>P^-1vqJ&1#Sf5c%BhFU3($CYT*i z?Gj}3Ig==raFRW(B+fc@Fs2S&?S6}T=u1I-y(1CW{+oeUTC4L$$=AQYXEw9LVFl1O?4{n;eMxGOm`kZ9Z^ z_x`HxcjU#r33sAK8WVNHXQOdr!*}wCR6JMXgqI99C2mVrX3{|M-TcK< zXN^LDZ`$O*&xz|dKOpR9G1Sd0er?8~u!&Rt8OB;LxX}CGkNb|T8%rw$!0({33;{Y{ z`||@#TSqoiA)o!usBw;#@Sr(3Q(bYyD(ExAc32qa{gok0=>`x*m7JZ$5=N91jB^cd_L_ zSqdG9(SV8;90qsm!ldVFQi?jGaiFSDN}NtUv9a=4f5`=ZAJfzluP5(na!x)LffLU} z5|Zggo*0znyw0fZd(6m4psi#xi3BEY&w2BBnOT`hQafb8Y@B$pUcLzQ4#VW2I4{k# zfTmb$G>3{F5NHz7QbHgP>PX)aHLTK*u%@R7!+Sa0v&<4gn(Pm8_>Y5uVon|Q;mbuq zFBm{U9)n5PV;Vtl2YQlYl7t>aeB36AU- zz3?+N6kQ~rgy9t$fj&(+W*Jd7yGr?}%S9k+k+eovsPkSt-?x6vrez&nIQW#UF(H!l zKg&PV*#SPUT#9OCsGwWE+SD_sso+BVu>y)HtZR^qf$}uMqFaF*GHOh+D7xvpFlryI z+p8r=8W{)ux6lYM(8kUHqsV)Ov-;DGiP;c>c^h=SY}wWj1`GFVywA;fY0U^!O&FW2 zrg(H^|QcsF=8N zSpqE_`BeyYbCS0g5Y`_K`!hTuW$P-6Ke&kjf&dBeSsIWbKUA*C=WuK!n6p!ziqKH< z)MH$>mL(-e=dr2pU{pg;pr=Pxx249B>#2-K=PVr#hW+!~h8MKZU#*ywkxmDrIzsef zGg%-=tfy0^O;dhRMbA#SAM<7E{6#f8qTMOg8h?Se_x+-d8_xvTeUMzGP+%_RhTmtx zYf^yvsV$Ku@Se0xE$IM=AQk#^s*_U#h~GjTvBp_6Rh(~Xk6szgjE|5Gaqk#Uoc8eL zb*w$SiHxb31s??AfE88UdUz^2eQn**Ebuq5s8jmh)*!4yI`76UN?^dHOyYi+L%w)wh9BYt+LA>n;&Y^so*6G=SC@24x{yfBfM;Q z4RiN_ZAXFljwaMLS!KRPK{@M&7D)$;6k-5!$Lq(L5ip0db)?$x;eY0#_{n1^j(N$@ zorhssDBm^Jd1&ptS6MZayziE9%}sS(Kvl^P7nArRw9CSY#R&&3 zbK&Z*K{z#c2792Bv=i{)UoPvHGKbP9sk}FjX2BL70J9_?B;!SsXQ4d(-cI*82*>*} z)#Bqs`KE(&x>!R@Lou^9J_Dm%h}~t`Pg0(LkO-!zi;yU;{Is!|AHR~(c&XZB;y2{P zDuBMLt*2YEZ)ZmR^rj_Az(e4w12K53P2-F=Fy%(i;f zA&&yTzuVh>zDyl;kcBl8a4aO$N@aL?DdGYHorL#VPz2r<1%1oUG+&RlfWrUm42U5& z|A9-M`Qs-fqYHrdUxgP?DGXjv2^4^B=fhabC8ueNwT>Fag%wyz{A+Mw#mu@YP>tTY zr!No@g7w(G;nS$V+dlNAn^i49=x!A+kBDvf%aM7UWu5z<{{Na`CaQ}A^wrz5{%3*e z71gDU;Ry%P1;pj_*|I$yzlT7hD4fWALBBjvuj%y}4T=xdAHx}-v_StlV7-~#)@B28 z0Bf{65VKH%RQgADvC7K2Jy=;k3z{I&(t zazgJevb6EVio3iU9uxDreMh2j5KNcmTrTe=c}BcqAybtsE3R5jBNy)FZ9q&l#09H9 zyXIff`veo|^>LW+_oHh!;?NBJJ_Mx-kbB|V`SD1(24Er=HdX~s__V|3bX7+S3x!ZR zJ7D`?6~?hVVIe(H3j?&ne0!lud_LtVego#fEJJ`|NNF-okKXB)1^UNa$0?~h@9cpS z58%3wRuM%-INK{r7{!f?3^I2!n4tW_59F?SVMp^3`^O05oVVineKB1oE6U#MPMkV+ zq@~g>!UIHY{wo${hP)m58293o(;s-p6I-s7`IcUCph(*j6UhkjI<}kMXTInH;=>%G z+`C_4M80T5FfUAzyfW7VXF0aA)ulxzQ0K;(>TD_H*`dPgwh^`Mp_c8ydg**TMOt2N7lE00`agt4xBkxPYJKQhH9VYz#-M7a1qd78Z zzX+8qX!j0@qFm8PGG;Dg^S`>17AB%Na3VU3F-M0{`Ze3cEulO^zGpKEl-QT=6Lt@k z?ag^NqN9(Go;~cL->gS&C*F(qDhEE*8KjpM%SpwN9C05AA8Y>|0vFn~JdlwVV=n~R zu|Py1JTj9mPYn+VHxr{$Gng8uAciKeJ){rSJ9I+H-DQJgQE@+(3hdL{QeC8g+%d=;pS?aOFsn(wdJL-++kvJ znT1J3rm3cRAWA(4^_2x4q?n7Tzd%Z@`=*V4EpqlHjG7kQX2=G^o?C#MRFiL<83#&$75e3n&d2o zSzpq@GZEIi6wUQT%KL7gWoHn0GX{9+P|-1cU|A(08}G5e+TxOZ{(Dj5dj z@zX~G@C(rI81eLY7vvvy+&lL23q^syVL^%04f3V8E=RGaT8B(td30e_CiV z6NKUj4RZL@u@{PKxPa*ON%jmxb>{2?^)$5`I6byA6mHA2K^Q2W(a8kbXrm|pLLtcj z4j2isw}EVh=dewgGmTDq2mIYY#XLKB#%W*x3igv1*_IKGg@8i(PCjUl8GdOu4I={H zjcotQeR!uK%am8T6%O%V7_>rVj6Ql+zjl$B#ULobtn{|w4h4swlB^m2!R_=&16@%` z00+{0AQGZ6+C_C|*^@E6?aj8)VlHJf_VX0#WzR1JtS180`T&BM>_s^k?43U!;4ht* zpcPQ?yhrnb6ZRY|uzU0o1;!jxTU;&3CjQxxHhL{sh9Oo&$&>s8pw>MYrw?fU`=bmks`Qo9w{iLf4ECB1o27)HtyQYCYc=s0( zkF4zif z=V~3sxB(*=L8#-0jISNMMAS7cJF32#ZX1~AdHFY?hioi_95Ur}-xm{PIxI_N%$Mtg zAQvq;oW>BFqFw4z`(gTR+8H)iOlSOx5bhr}9lF}au5j;XEA#zSJ%}%SKPtNJ&9(6J zRY?la=Rx+wvaS`p+#M5R|9@^!p$Kb`PaJc9(~v`KSChUXfTT^c==>qR{LyFH$E;ad z8x~YyK4RqjJFGv*Jb>g)(7F#v?z}N<*G1vis1UZ41Pmca2Y>z4)mW!AgZ~6q=DUL! z?ni;-m?k%69r;qVYHE4_`+#c8y8yc44)JBd-S(z4mq&pUf_L>VE;jyuY`qaVSr>_@laKj6ZuEoVl8wMy2YOc72L98)DLf@&TKr!z^$V$# z8fL8rBamOa3;7HfX>E*16HE~C3%(?yJ2;sZrQk4Q^tF2$k%u;yI~sVFk(33^v-(0@ z)+M2AaY?j@^2^L&IReJP@sT4;ShTxUE@)3DmCO9U~<2^#uD#Wk`yYy zu#th)kw?1BpbS7~pA_RTwQj)f`RsbYJ*?5yZdc4XWZT@t!9UVsLs zo=kZ^@k6U#inLbA_%)96CgpvauMTaMQ`AONp1$zQ&IxY;&X^-vIu$;neK_Pa+N|@t zW+lg=D*ldM$Smc2>Tg)et-vmn2u>_SY=;X#4*#>js@K~oGd|7Ey)uZRr$+p31|||B z_`Plvwh1F0BH<9sJ4r=$yMyako{>^5Gok)t}%=FcRXR*eDH}i;}D{ zUvDx2*tk=J@!q}HYBh4KWx%uAH|;w1OJ6eHGh-2HL@?1t!Y}MwwycGux2Q$v?@egb zWE>5cl#}vn7>*6(J%4ws(NpfvYA+ zsBdoKbEk&;Y*!f$jXHFUrMwj%pmcc%pI1T2hsMsdM<+ZHcE_>*9tUQU*L}o`b97bT z9y#GH1Os4xfJXCPB{Fz4!P&9!LzM@`knv44<>aDMq(JbFB|`6kKqL!Qa>Oo1fz3R# zatx*>WOA{Xc2BI4wK`jdLe2A#VNN6!#xEFl!J>1iY1u+;p)`5JC)y(e{pIhl&e1bf z98yf4svncrQV!%f6>|b^@C&t_ZB1+*8EAx70=|5n{u~XSsXC(^#(QeY$*kCHdOjff zfeLsKLXVptagR_MZ z7Ynm&zoIA;nO6j^c5!PC3N}uOOgXAa87o=*H^9mO$N)ZTRbKv2IOzX#7O&+}o2l!D z>^s2=p^<6U$WS&q5BuD*+Vy3=^Zp7LlfGwIS@HbV5~@v5SSvm)SS;uDW)YPclD}ZTh{HR@bvJcdV%dTQVXQH@=C&li;}*uB}=N8?G$E|IBv9t{T@zV^Xrg?-I7uI|3Fz9W+ zmwIcFOGQR)8Y{8+l*%+mIx+_oq8f9(!5foIcp**Emx9dr^Ytxs_}T5rMz>MX084rIP8-ei+AXwj%FW7dR&^mvx4c? zmG3cg&eU~Zut+%cm_aG?4ZG_|Og8X&p>0X`AWwH6ECcB%zHOMDwccWp^zXf}oys{8 zbt~)pdO8R8V6b@PB5xO0Vw=Fd4exwL2YpYsy;d-G1%o-m#uUJz~g04 ze}$k@_#c4N(A1zw9-GZVXa_Aj(#n69Qep*FA ztTP#DuJH@QOWp^MRFu_g^gZbXKND2q+J5+3JvzH)hyMf?VkK}quWfnNNbd{kT?BfH zfeipu8Tc7vW)++){!oWz0p98A0Bp=e zq#Hn!K>wR6h38f5(O-619oaIbD3?Z6hI?pTUPOBsjlTM#ddf?k%SBp0n?dSQ$G&!N z#yGoaOv93Q#{m}Z$w;0*_6HbV05m;2LhPty727WIIVtUPt)VkkCPd={OLm=a?jNe* zYKIAeXTig*8S!6HolX-L!q8Co^43OPS^;h8xc#-Rda()P5or(wN9+G+pi-X@Zs&~Bt2nR!<=;?o!vW>!GngZQaS>9$_2d z{t;pM^wCKieFhV}5(QvdW0xO+3*i}MS6*R(J;pe~6pOqx?OhlD_e6d~zRfj=ATlHt zR;F`0(|ydp&MqxhN4Rs_9jqpN1|{XP3FItS9tMeuz2nXP>g(eApWCwClj2cAnc;RW zE))_Rg)1BB#x_mT1UsGfR?Qt8RIec-yWW0(qy@n$8UY34W}o93!9NLUlj3w}e_p>< zI=xm=X4%PqY71?(q}xZx`(gNQvaLh23GWTu+-ThFTV=}HFKcfvG?S~8FSXgbgyOfJcs*;(-SkJ{V@W86UaUGzLnY_h_x zKMl=x5u7uAE~vsb0ydRI12qbZ$$|&35x2wtu|}ez6m7=cU~Q-|R8#;eMdTLIslFAg z4!pjBywpDm2~>iyf_>48=c(_Mo?<;t-sHsW`jiZ959wr#3;hNy!>2tRzb$j;4-wV{ z-RbRTJqHq0=)~X^I={g?C|5}o2A>!j-{`F=-y+Uwe_)O`zy=v={h=r0F{WkIv=#0P z?uhbOfb+5{RAtFk3i+IAEwr@<#{{u&e#3If_uT$fKN3~#H}SH&HJnKk;YO_bZOipc z&OmYU>gRn)G5CA+g;)q82vRFV?T(gc`afd)sy8X7NqX=v@*{a8wO=gz#yTOJ{>iZ4 zLpv4$JBTL_Iuz=Aarh*U1-oUB_E>mJZoeb`_c@;*J|A9> zX`*CMowo^d!gt-cSZO!jqwBtfUFR1b(%1)y`murNU;3DY>_Q<+83FL z*3EC>Vm@b`+tXkPZ3hg}V)m2d;x>JqHt$RU_jk?jwhRydJpv)5{%i#>2d#;^CAvPN zsCO~UD&0jD&X*KpgD(6^7YOBqKJD~itXp;{XZrtCLWKbi9$)S3(8`d}1fW{S>b@LS7 z6CCb9#$?uyl-07K3U@_WV+qd`cY>B_4|ops+2s22ZkWB&TT}+j%QIwV8c0gn-Dz{p z(wT~KCBoX&w%o2MXi)BQwGNOwf_0U zFRD?lC^H2>pcDzcc0GD+US^6a+I{X2NV9%CSr3qc+Z7?lBjL(>>Zxj2Z%*tT;}^y} z-}Egi?m}9ae2TNmX*|{7%myx3+Glj}P164e0maxuOc*CFlYt6Cs@j^3vRk*Jp<@Yc z85-cYpq-1fuu|&@LYvL?WJyV;y{R;Cl7BbctRn2P)uuQzFjCV!=sX0rsF?oS9{GI{@e`5EKRb~iuf z;`-yY-_svqa2j`4A7RI1SjQ1`y01*>(09GRmLsDUw;C;*3%cPP3gi)yZ)qfi9usR4 zj`Sm-v(_N9^0zH4>Z_TR3dp){@Mq)smcH13V~^LHsc{>*)sIU^OCn&??i3ihbN(Xv zydU9mhTOm?!zVJV&1-7);Fjp*J_j-%jLNlnv?8H(RlM!~Jv^)K3)plq8Mg#MA=#sT zJ5qWk;+6d^DgCS@jzILZkrK5uChcdQ*E|gQU*5ZtiAWu2#rE=Z38Sf&p=+5m@C=k9 z;~q4V+3TzM(I{Mv^cN5*z{vosBENm*y&q)DhA?AxcKS;m>iPIqW2ZJ`DMeg{QfYA^Lrn$$Ptvs`z=42pa>+ zS2>W#sDIj|h~4%h8@&QOnjG+ghWMf<$|EX%xLsVyCrZ3!6kou}tSj6K@jb6n*!ei! zFsy(c`qy|`8%lBz{`BR!70-gKK%s5~t%)7-?HL}%ib3y9 zJOFIjqJl*{Y&~I=X-xMzh&Tz!^(y}to*1ReUr`PA$dQM_i!DW}6nLk7BfgcU^078g zoY8F>qK ziwG2WJsv@1B_rilYc16;?j_92p0chDiXFUSV4-e9g8H0`z2Hc%b8>fvSlSa%N z9-ifRsG3K4I?~&6&svfBBkt@0kyst!|9D$CdxH^(M~U>noqoI}O#Mw^@Yw<*CYY@e zhlNnRiC2LkTYs@$3@w8XO|`ZxJ+bF(t{;oYHhrBANBquq8oZ*}jIdfv5}@0zqn4;;%6>ryOrvotnY&R9yKDsx&7Y!daZl;4YikoBV;Ry~g-`e@ zMpfSS5*2{MVI$rXmvEuV%nHXt@ntrKdCqOgm_B}CHIg94fc} zj=UwFwN!lwAY@ny({MyTY>h`!%Brd`Dx`#2%Zpb9F>s1YJ3kwz1@UKb@ zt|dAH^ZR(>qn|ZaH%TAu?kWB5WhN^@CKqX@@s+s0x5k$OF`35L`Dwq5VQ2y}-cl^B zrt0&{qY3LnwdVfb|2Ap(AfhU(o^2I1L7W>|{T_KT|NdS>cOB?9P(r`v`eFY zRo$3ehoK*Cj^Ts|F-~11vPOLlF8@F?tYStj>p;twi`2a>*PHmepTBRj#ymAq=&Hm} zrr5lWmkk%b%doN_lU2yEo^V@!wII5Ix%t$NwBoSHa2PtB4w3v0`zL|+4%zsLSuBP+ zFbmMI#zw<+W51`3MGzLLd?P+PFUdys)(oXN1frW)2;SEieMeJ2&`5RBmq3STA3fHw zvxpm=z>#0xo?)X8J_sKq+z38{?LsiJLn-)w$NkM|^L04F2~CO5puGpJO#uf-Xm@eFIT*thqgPo zMV~g(*%$BqcrzmnN`x0>floRfFa2&BD}$|dsDR1yu9sTKdlM6YKM^HFvpkVyw9WvW zlCCb6?CFN0X`oNyZ++sw6X&L9BQht!I=G8`9hRPE6RwwgwWuVO>r)0vV_}YA-rR#0 z6II7%hSGsU%XSM{%M2!iu>CpO54o$xE%KPtN4O~N(;33DI4H@8)6Da6njK(hrw3;- z0S`#qebf|Bh6UNYlc3QVo}Te1y<^rhSH;PVX!Vh9*`hXAM*nT0_ju02HT;*WQy<># z*!U{Jv_sSq*$A{+3cA7k15tZ3haGW?RjMJ{CW3+IP#~hY0$t8VrUY@6CWUDc{8L=e zfhd%8lfgm<*Hvz9x4|0WAG7t2R8RS(oaNbL5bxUV5JmSdNQ&R%ImpQ*Z(Q!e$WJF* z$052*pt$5?eKlZr%-1F1BCk1#XMJdhw(TPG`F9pS@*%b1zw;#2Tb`Qk=)G;rI!_!> zHCPyYobCd8^iDvn8Ljm}gMp5$ zkg}^=IWh+0?uoDhn)Mx=Kc6 zGA&MsH4AcKFkJ|?>};a_cnffIzMNkKGw7|PRQ<@tRtXB(dxg_x50xKWVvANVv`qpK zF#{`}sJbSc%$CiLFu!1CHW+@gFfQl;nHzB9O^p>#E=)r@kk>ZPv0xr(mo{zAi)A>N*6DvX0 zuc+9Z-(S*2AZfZ*QDGU+#zTYWYgx{($kF^I+R+a>SK>6pZ80?inc311LiEO7YqICG zOpwYmjQXkNbh=99g652KY$-@n0QlFy%~BZWfx@hyPQ;bl`%Sn_)ivlczMZzi15C0V zHdiJ+EigH@IA_e7jWW%PzL*G-K%mN*aSAId{ALYzw!c|3SDEqXmMj*>^pn$@k$Y1L zTPc7@+QZ(n%DEqK@p9ypK1+JpGDP-!5xmE*x|%z` zqGB5mwP9}Bw7LdhT7DB~SJ9qx`}-G$5Rcufb56lH1s*{UqmE7rcRIvQSnAS2TzQR` zb=H<@B174D(zjLV}Az29FQ){pt!7q=h;MAgz--H zBm6VcUo<=ZM&jzho?ASEkp+JHbKI|%;W$<8zTVP_n0%-AZpl*9G^-eIjJO$5LDG^k zcHPM}JelYKet^nZqa*>r4|S2+yJEHt|CX5F7C_1E?EKslLjX@F+B!sgH^^ zuzqg9vtErdpS7td1@OW|2ODJ!+%};$!oMHdpt|{(RFe+ttO6TJj$HQ-g^K&>F z%5IG%MbrRj9XNnJd7t3FyOcPh!%aPy)fb^b_Lj?*opaD2X!wTJH_cT$4Y<)-&^;*Q zW&EU9QA~lM%;k{qXPpxOl5ut zxO%LiQyvQdPb}-C_47)(5)Y-D!WF+s?hEDkx^t~E^^PDzGZ3j z>hjIMxiTrg z*sSni-`sBSf>@)E^iR?^$H&tvqQ3{NXJ6CLm7hs;R+D z0$57x9rEG6DOjyBdUB|%Z!RBNAH8g(#@KbYS1VmPb#^;6R${$b7sab|LpBLpU+ z#%L4}H{nx+EyJTEOqaiNoqa$Zk;ZCoO6D`1auXMc7xK5A0Uuj3L>FajVUN$a)ZPT0 zLxoK*gMw!!q!D8Jin=?=FLz_40tviIAfF*HEO}&{uIOJ^V2$sBOJ{6YHqJJZ=X4x_ zNay!JC6DMdWy#z`duL}#3S1@9ky(~AADdpMPw`Ol1zLF?&=kRbYu93@BEL68n%3s3 z-kVlrDT|hrq?~9(;&-?RXI@}6M;33lKM_9T6Tbf+Kd>{&+g#=24ObfHp6t~qv(@mO z(R=LGY0Xo{({af~OLc?*`eZSEA5?|Bx}$=e`Q&!HR9*tF6_@dt5_VnHa<|xOAS!l| z5+IvP$Ck37thmwsPU=^*9Qn?)H|sjf@?si76+!>qYQcKayj7ZZ)I5_Jf5V1O2rq|RH)z(KS!?9V{uM46fDZq?KeF5N%0#;0;{@4ig zn2F$08Jh~PMiL_FGEA{JC|8*t>*3P(N4^8c7)gS9#V}u)_cXS#6aU}z zRNyT=#;|6)gA}xoZ+c2rgej0T$~fzE2EID+d1CdrR7tP+_5oTF(Ce801o@>vr#{Nz zj3esItYye|D`y|8F5-H@v#h`8^a?DxkJOX)dgb8{Fad+$B;iCl)Bh1iQrx56aygLe z)7jxc{Xbufv3+c?T22-fpTxDX~QpMpEA&c`~qe)RMGTf6)G(A-^Z>yLqbTH(X1OZPz-w?BTVq^LjTme8uPq*TH}H9kc6$v0WP zjh>uFG`h1{mH)=Dm{IqPE6Ma79tHL;K7*jB_n%`_hCpC)zamW)t_YDj+-5@>uI1rH z)Oy&J*SboYgE8K2{DgNatmB>I=R=&oxBG8%(0Ig_P{TOUzAggOx@&3!WQy>~yd>vL zW|_OW6^OHl$hf)Y8Ur{wEZm%5ht-s2Ab2pI>g_j`=!iu8->bo-WwMGsHE_?0CQ@F@En=vrKh-TyMfxv))r`IlGcm~R9NiEpyK!a1snm#8!05mq;$K-q}^Hi=q?RHL5gKkp};tA9`qVPTGl`jU;0!zf9@?r?`C(Un2;i^i8=%5EtjeVRx! zzE_zR2RL?#jY)lN+XjMB$BC{3Nj8MvcNaXNU$CX|+*{67tk9+&{J4GR&Pv}4jSxo6GTaG;L zWmnk0JbK$%hqfp6CoLdt;D@ZGuN7hg&o@{Z8WWe8GA&viQ2AJn+GAeWBv$(+02;^{ zh1-0TiG#qQH0q$tYbtaU_565>{9KrMd)Lch3aenk zd&%HYh}?J0T|nzIk0%pe;hS(CXXbBXGKARFw&J&Z4%iQ?j~eQ zQxET!Jwi34AQyx=gM9~&l)UG?)%ri!SQXXQO?2`?h_IaURe^S!$5|mff43ng^72&H z&Z`+yChBJE$G|}(3OZiHpoO;q43i@J9s~>Z2ERpN-E>i5bk3l>qOZ4z00YvQZwK zu3V4IVy%{?G_U8?zke6N8}YW37w3A72S*jm8|z6O+f#vlAbEmRM}sOG3v}l1;FWvBSoC*ZDfY!9~XN{NBNc( zLoFfEff{lHSS+SXv`1Az?}IlvH)=S3P72=Qmahz;ZNT)5#Jl~@S53V0=wOs$`vdIS zEM^AE@6x9jmsx8MUiN@&ZXJDJB#qD*?P7;?7N++vTHM6BQJBA7o#ls#xP3okpisr$d=PWw>COkhsGYN6(O;bKZytAQp^^_3dKR-_19Zk{s zUse@-Gf3K=Y}z)*u>Rr0HCp0*R%lgFe1dN+WgGoqP!k>SHgyOmy-FqT<6GwvVYnlh#|ib zp(DfdRTJb|cEKApa#brDQAQEy0b}AfF?b*B5cX??@6W?K96ewHlo|Kn9=yk9WI ze46p|(=!B{J5(A;$cR5lls>g6{$7eDWcC?q!E@k!y4z5=^Fk=KYW&p8B$h;W{`{1( z_A0^VxCUC4OyylO?HESgazBq=0(Mlh0>J;$ZbwMF${u_ItqGXXMuhR5Q~p}rdEm?- zsM4ZkNs8R-BbFr_@(>vVE%Sy&pc32)3K1qTXf^gVGawWdwt6kiL;9RWWbNwU5f8pD zkz~3pfo#!IF!(+xWFK-&Baj6OwoJI?(qUNNRvFPZ79?b~f>gB1iOtv;>fheYniE2} zaoPg*Ih8=VJwy_(sLF(5)oNVjH(@uhCoOJsJZB&wsLr83nDlKkBmG%PjgbiDElVI& z;O+~v!ZF<0i4P5cN?$xUmHBGc;^@}20;4Vaz%0qVW*)uy1%1+k#6re5rgGOvqtT2; z1pW~f!n}aYbA$F?8`^sUn(X}KV{c;ZS5l-ntdNX5%Hz8-^^gG8aO<*0! zmkav9!RM$eg~W5$?^|QMmRHJA#yA9nt^$c9eVF1u1i0rw?@?2#(FtJlK=hGBRm(#EU|}ztoZWl9qA! ziaUNSdSNV$>0ELfh-UuaZXnz4l{J`V23hf)r(sBUOVKv>7N#M~`2FT(@-gK`;*0CB zyn_czkQF{*98Bs`ch%9uYd@o|&{+ZpAX)B6sf*N$UBJT@h8p)X7(7-3Md73R zd8c#c?_7N|GhBxj(80)MGQ8tS6cKG+Oi?xNc~2PY%vJ(0fmf;&hv5>>k@UA0?(i|iLPB&5=_<1?&4Mlg=3voquQ=1H~ zQxiX|qOqDP#=r|Il~fYxug$8U*9z3hG)-UIqFpJN6;R#q&Vaopd->v$C3{p(_xNh6 z=?5M{dzqe$Y~|*JCth6glyKBSUN&`jC^X?REox+$!I=yU2Z*d4sqrQWL?EOgaS_uh z;U(tlpisg@r-HJSVH>2*Rcp4?3Byk2FK`i4J9SlkSuqYY;3#FT+pr;ZlZ~hv*!8$k z4a5V+Wg250w4MA3tOl0>MjiWWIX82UHWMKy>Rz6plT*6YOs}c7(I;8=@SU*51bVRd ztnSMfh3L;b7^~vG^G{91-JdI~t9pq6YOB*Jub}3^n{T2wr_%Rjcp#-Y{%~v~o}(yy z{Lnek_3{qRhX7s_7I6FDjcFI?tnTvsg)4I`U;D{|*Mnx2E&>_%!AskrPCVgM`!cUo zs0v%tKE}K21g&oDRgjPM(q|skXb4r%TdiUCHtIOCHnMkcwG?yU!t(>T^m0_ zW%DX6lkLnT+&kAS3RgS-b&U>PQ~xcL`^Bg$EnrmQ0w{J(#wkws42NG#Xy1&%% zO4>j4+J>#W1Hk!{$zE&7Zv;YrQw*yh0+6e7w(Rr$thphKdXK}EEf81V-i6B(^Juhe zG*Glei0@eMgEvJ0QA4)lBA>Gze7hy|UJu0d7-Kn;w#HhmWeJ`UdWOzzuatw+wImEs?|m2l^Ae zJYxx7SLk`4KV4|IA+D3;wczAx+!YP8{8H`6({M6}on77w_H9RU8+uZr4A11IubW`h z2;61ZoF!_rbt-*=`Zg&27X}U7-9L2&GQw8AUjz!p4f6th`e~fkDYZH-f!`s5vHt$F zy=D%7n(2ugMNEu94lG^A~F$7JsYF`CWM3nPz zxx3VuC9KVqhSQ^E*xp5<%8Zcg*p*P1d3sx>#u{ zqmj1>O_QM84ay^4|7Iik05>w(+oCYF1O-nf@MW$R*g#Y_14ODS%kz?3Br5xi({-yf zYd=`^-`CzMOZYx{o!Sw@p_ZyZnCT&cHxf9;g;co&5$|8$nIeVb!jonCt1aH?DF7bE zIBl?(XYIq@JEfN3SH~ZF^?(a&4$SmqbruPVWzTDi^Mmle)Io`!p~50dfv8q(IayqI zE!RRFVYSFKJ}(-__6cKx@bq>V791~=WuRd+6Dx<&1h7Nnq=wj?%*HrsE)qP6+HfP* z=?1v>Qjqhl!?qT=*Q5q)vdScbLm&ldo%>LD2o>2~d||&*bUrV*xPw-c!c=)20mu^& zuRymsx^=5SfcIT?)X<6lD-(d&-SB_ZoPw zmi7HWiqAM}^cmM8tz$G!Qk4&^Swig33|t5gL0S7@qxI%BS^Z$)#%BGU&vYq!xr_di zEA)swOvozZSO3t%*r2fpyUxKbW!B7;$LYY7UHr8ha#%)2rxyGh-hNLFp|69*ibWVZ z!x+cJSA*t$B&OG=)?mvAK>(w%j6xqd@-Ay%W-c)ArFdp+GEO04AQmBvyLfpXRIZ2` z`4U%w=lGw5St*oExeLBT?yO)Kh0_Uf+YjVE|AUfocP-_Y{j@^T3)dtmsZl$q@^j1*cHm>K{)ZEO1mmT?uIzsQD67Lrr06;hN{#_F4)BQqTQp^fETYV zLt?$b6Re=%>qBOLzN!3zGy2s%>t&PF`c1aG<5m2z18R~1O1*~QBk%`Zs$>K`*Zx!| zuCxV-!k~HKf}pS`d_2(_$)tl5BBMsfakh5T^LIZTs@GH6FMp?%XFn~=K#oIHNIVrf z7ZU!R+zLN^Xy-UhTBjYST!$R~a(QDa! zIO*2IIgtCb%&r4kaXrNt&N3*Gr|E}QN4uzGMa}JK%Qc!;?8mAW2|s*q{%3I&G#ejI zbrpg}cVxlJQ(Cl0_jIE!q1JsPhyB@f_7Fl#@dCCy%P<$gkhh*2aY@lHM9Mf{ zo6gMi!QHJEEaa6}@;)#n%H6(#oL?o_q8nuwH0(xmp)N&XpXGFk6aiiwb@a+me|u4t#T zs@IoOG@Nge%?356#FZ-lu3xr#-fWj<`-M?V`Kvom&7j0aC}rPm@bL32ZH<2XhxhO4iIU8 z?{wb6M5YpsV%8^o#)e?3m4eWLCe-?zLjWSB!|}=%ovpREN)xR$Y>*#7V*rw>%vHuj zo-;@>ckhNsytNYZvP$aw7GJW{!J(h)1q+qUT2E3ceNu*H1u; z$kRSOPm&ef9p}H3NxB69buT&I$&AK`^KX|s5hr)scj9xsAdjY zB84vAd{yJYnT#X{Us=K$q>uYHK=>`*$`PaKwW+m#sLa$T%kYd<6fw6yf*aRx{U=gB zpCx7q@b%5(67Ox&T^MpPbUomdRkfj_fc2! z{o8SQoU*)3e|r!|d?w~+h`=3pxDy=F-1@{5col-Q*d}>E#Y=iK>EqBT>lMeI=))cG zt=B`K{GG#AEV+9}#|asYp%S#<_pAbF=KcVte^I$l7SLHFixydE8(zJIYNv^?#Emx% zZYB%8U%8huV^|xTe!n3&6T(DT>^|B@(|j1yP;~6@8Lpz1RcJfs=_17oqnNo)`G7Y3 zWbs%l5j^IQX=b0QWT0JqX85KdF*3MOSpF9l|AqD>ao!^s(vRsOe!1Xo%~fk~ zWj+0y#151AX5GM7g3lHU5^utk(19ghe)&I#0L!(eK!}c&)sDwT`3|P_qTSh7>9RqK zB6(N8$<9(b-~=JYE+Y^kH^@pyo;*skYn`Tw_2RCH;~Huk*b^|@f&#u|czpPiz-&8G zKF&(p^gA-VW`Yl`3mdw6X6o7*1BNNx=h1VPBB+lgM4@-+arRBSB?KNl%vp@nj45NE zUKSaW7kQ(BUtfE7470d2e;Y2Ry%)AH&3^sM%-auJjaT&^(6lO*L0;tj@JU z{<}8iwL7+h9ecrSXlQ2#*3?sn2(>omi?JtLK4+7NFULgpxnEOF4m$h&5Dr6QVWV$1 zOB86dk}{(#&6BW5O6C}~#EwgMW;wuzML<7BoV!t>=I%3=|Kxer)zM@k*+s0%(GrrH zcFG1_YCY6gC4h*xzoXJ6L-%mFt(b&qv-$IKfU7 zsL*2z1TdXVd)t6!xjZh5L?RjMYmo){W|W34cc3Zlor(?D#Yq6^h~MscsrWywazHqj z|0zP6g7wRw&_}T?r%^4@gQ@5|-H5_k*(CdeEC|MGZ4)CQIXTyp&ESz5M5T{Xq7eAi0rX;UCUFAwVmf;Ia@B1W*b&Ta@FJ3Gz%rT@B-4_QJF3T3n$D2wu#!YQM)AwKSx?lgm^}n^^=lv~= z3L5S|VJlL|<~7{ZXi2~aZf*;REpBV`2Yo+^2A4!&D!Jl7p^> zW)1Db!RB>&F;Gng+lEly@{P7ayI>9cp69iT+4SPq@Xna*$KQurQOzf_Gf7prHXNzL(7d; zf8dts&h$uBD6QTt+`PG*@~?~YUA#-Z)uQq1!AtGvC{>?*HF+|OiIprG-;CMNnsu-b zT-$88lGncPxIoxqYGhk|RqgW7g#221tCn%P1KJ>@>b|d4M$O`ND9i2{plV}peKB)_ z2`2{Xj~6-qG0`7V>^bO6up&w`-DXBq75O*N=%Ww~ z^k7DFq%EJH3}04D=6s_bD9d$7+oy_XBb)WS$(9I293tq!5xP&ug^m824>-1a{DA>N z$f*X}oGhsOu@tYA1Oj|!>6VkR*;t+m=X`WMTNln@$-mi2)f7i@rP&=~3vE86VRl?$VE-bX|vVCo&3YiC#T33HS z5td;9(Bk;}d5(H}Jh?w>aP(VbQAX%n+mltYWgnAQD&<8qx*)0uT1Bw1{D?*_K*|y1 zSL$5Db6)o+qHXFZEVpzb)6*2+Hb2ue{s;|Vo3I8ml`h6*HbNE``N%}SK0n7#>$C;M zk)pNawby^gw~o!+!K>rhT%MEorK7Y$jFU2B?+ekSONC>>K%! zXZt|rVwEg%ANZ{vaNjf4v}~n$83oDUFb^Yj1x!4kMGym_8Qq4sENk+P2ocVzOWAAZ zitQy&oJuuoKdlC|BxL@HW(FMgGve**g;V=KoZd-2SBVNF7tqzcNU>*un8Wfi^K9AU zZ=aFY5bhqn2Z^&^&k6z)9&hk`Z1pKn0Cs*>tJ^ zNmroD=e7qOgjom+l%*OmiXiS%^K;Wzs{SS_Yx_KK*T$25w!w4Y(YlBoy3PlAwW7wwhBYlWGd%CX_)t=ivP`Hv0 zd9mYT`MI`|u6c!QFY3maqRTEbr5JL|%8q+?wcYa^?#hxC3Dxg;cD zf@DW%VFEGu@HnT^XU#a$BCwezb5|?CL|y0+cnmOROl(;^?p|C-veVyb?;rcKEnVAk z`1>?Ck~j(Cy5(?HM?1QL!N#$$C-O)~`A;YxoQTauzPLP_QVoJK$-X%Lz4(qX->* zqN~>3TGB91qyH1wZi>Cl*B4?s%(8aZRAyBI#Pu7{9cFS0r=61g*7IfStv|@+?gC;a0#Qr#B&TglV|l}k75X}pHP^LiC&7($ zFq%j#4M`XddDh}Y8L2Z5AurXFWs~cQR@2w=LD{>p+F zi%{_DVBhgU(J!wI&`dbqi^-N0pbO}Mn8rfc zZBlnd9Ahvav4AZP-i`QfU0d6qy-i!^fnoGie>gaJU#LhaeM!^~5Ia^v6dSKcwbrW+ z7ixrUak)nUqc(5HgEeNuAwN$0kr*yiYjm|*xQXgVPKJU}8*+MlQOhkt7LthUS$ifF z9E#XoB#A*RbZCr1GXpHMo2q{$`SEc>4LCDyEfuX5u&L2z&Bf!sX*9lzy9m7&m(o}Z z*`=k1Rv8!*KwI*;Ea}7(5sCE*O8uUNbrw0J2z^+^EB^=5iC0y`X!VsxKNTSlWb0== zkByq9uZY9*U###;tU}t;HdwJ)xey2VSfN2R6H1Lf{{;m6HcCh9YK*7DtpmCC^N9Rs zuPMovZAw+{4Q_;cv1e$SK+$mB6SyZtsjcVJG>K&jvL=er!dQCY5c9%GW z$*v#Bn^Zb4+>(Xt%ky#~C6n;1;6H($ShZQ2S5Wxb7F0{bkGv;;C!=Oy9Qw!mcs zz5h%7ol5_>6<&CxW9o>2wpGV6&AtgYn3YWpj5pPUe`r~%H1;b)Em|Rh(~dfcS~x&~ z#-hRj8Vo%NC!o@k(_%{s(x18*kyfiG<(F}voND#ZGg10&bzWfhSnE=OzltM-?HxH} zrPXIO8=+9Z9mu#sQY6YWwy8;3zP+zHaogAxIfVFLDX03 z?mC1xLB%Nr9)!!WkcY$O2ww^4-yJe!fY$;fl#)$1Oi1Uzn(oJ2KxtlP>0n79W?Le@ zf}K0?Y*KS~IV%zi#souG$uD&?B4?;r!BH)XT{4qTt4!QFt$QxXCAXjF+cWP4tpGYC ziOAy5zD_*cInYaRpCrUitcZ8%Z5KzJ5%|7hpySsNs~GY1;rGFiUyy8&jp<0oo$;qP zZ}&*iv2RIjIr9Z$lDIU15QdlKxVGQR^{MY)(U9 zV};s*mGJ8O(9+X8+K)aD3iR5L=*iLYNp>13#deUZQ_lGbTgq{c1fT6;K@p;TG+? zN=(bU`R2FikZn1VwuY;=VAsAERV+x~2VnIj!73M%?VEC1EeJm!C}pZ}qC%7#YzeJ1 z%tw2UqV0#J*Wk_`nY3>1n*Z1>q`VjCPJrWsc~$*A7ul z1jDJ2(HY~U(YcmRaOB|WSm{L!k)+4%11=SvL*Ppan}=!L$BVcpz>hgG(+XovyK%E2 z>~~7~mLiU|*sEPM!m)szNqT&&R+|yKs|vLImFNfiK5|a0aT~H-_gEGtG7sN{wkZok zBGrujVe$X;R;dJ+fQ;EDn{(~@Qsy~)j`?Nzbq`UHy27GKdON0^yu7|@K_#^Qofr;P zdF>jiu=rgoxO)C*ccKn+;hepCDeq;D!8szbG=+vj&hBQy&%blFtwDc|o4E9fXNg@B zoX|WfP%>{21LML-sV#QU@QOcX6v?ZEPb`hVU!NfJh6y9Sg`2buZrJE?_1E-f@Nh}G zu>JUodGRe2}grS#J_wgVYYxxG&#u(Z1J*5l&)}COO}lA<)en@Mx8j3HB`& z5SY{`mcWSV9sC+ngnMZ>1i&tA*mMZ;e}aN*M_H28S`XD6FhvHE?`B;a1k{_wPgXjB z7c|2X-%QWa-pMQDFb;5G(*8f$lXCt9{CYx#XEk)&lJy^>h z5RsBWTKP5KscxzTr8zRz=Tf>;Yty?2^fcULe<31VSW2#V?bQhFA7Ome_hS}|W-)RD zJH};$oZ(M{%`~qp%<2R(DMeH)Ii$K(qYN!?X8p%58^g(bZE@zxE^=g>{!BU6n9_1^ezrM2G5_l zf=@L-uSoraH|fc%>IEFhWN|k`t<4{zYDg>un!br;d>&KSsygCC1T45Vu5S0Jf0Z)S zv<&Y=E=}IZAaV`76m(6i)71XqE~I5beWQE(b$t$3LzdD-+{fXQ%Jamzf(new#9Kz= ziv`%A!sd6AgMSM9cqeN|33WXvpCW5btP+a!Y7J1=~RvRFIk)@2bG8>Hb(N<)P zh)?^dUi(Gn7$nh3NtXq*THrtA7>)*}1PP%8l1?_`(b$67tv`)c6{)!wOefd-+X1bA zE(GM?#5{=vJAtq+E3=3P!~OH&pcRp0XB$Hqn)*WVMyYWaIu04Ck#LpuR%hB-9l7Ak zmuNWvb#U~?F|Qx{(CW?G(>t1)=*xUDd6G6*IbHHhP!;t@x66HnDm3uU(oTL!pUBzz zI@9ddCsrzzV7*O9={VH0Ag_$|Rr0P}F|XJNp-UYV*-HHoSGD2Ge~65L{^f7E`g-nj zMx0Kos1~VH*ggxM5Mm&+NYTwWc?htvOKJQDqfqo`+|_#X`B=&E==EYcU)HpAb-=!3 z3dQg~BLyB6T0(pSCeS7z?2M5f`_->Q_8MojYf#Ac@$MY?WK}+Q;z+c1L#UN2U~yYr z6=I+D&%Uus7zq>&{15H%chHmc%!=n5s@tsTY*Psl@I>cFy$1hajhU2{rV8!iBa`x? zg9((OS2j7;X|-~`#3aJlKVN+f#7Dua$QuXggqJ=W6quMH(%fTr=^7SrV%g$Yakz)| z^-1M>kU>LyMhzG(@o_ky^_O+Xq=bbg!=k_HcA-yePOpJGYISvT4e8r!Z&L#WcymJA z9TSQGnq2zcQ6E1Zk(sY6G7BcvlcxtZDcStOpXzQQi9yZ%Nw{1zJ*WM|G?!8N+V&=L zvh9Z}n{m1BzcuOTf-48FX2J|iWrOplakTU-KLOw}9D#p?+=w_tgO&<)A+;I>bD%h~ zZeIXg8*g~OrEQFuMW#wtV8G%NTq5oU1BeM@7ZUGRV}uopJ&{BM87ULLF`G=r^7T6C zG7{awD3FV!VFp@n8y1e#@_IKod`^GX!8DN`#5uW7tuSctcvlh98${v$;Tr;lop8foI=CLdvc=L!RGvcB`ep=2;Ls;71nB7Pna0dIb@ z!beW3S3r#&TSZ}sB3O*xluCR%ZR=O=8~@XxE(S@Qs=dBDzg3Srteyov>gHG7bC@k zsWcqRsQ`M>&lMIk;|fmE-w^f9F>htzMwEckrKYGkC#bS)fTBGflS-3N-uiTJ+pob@ zXGOS~vZ_cp>8FT$`#}CmMJs+I@#||Q-1e2$FQpfvG7vF9W(W;|0^3tKU+WD5Lt|Aa zpg=S|!W%aLl5_0Ai*O@1kRFVz=*hvy*Mo>8vWaPomA$lixT zdnOP%K&NbAB$Te@m6CPV@(F;6wAt<62$8oOrP#3>A3Lq1B=)0nTWLz0J+ox?it(|j z8UniO+_F-?+sxU-b-I9qinLbViH3^L7+BcWse4^R+@f=6xjXQD)Sv Date: Fri, 17 Jul 2026 23:45:31 -0700 Subject: [PATCH 2/2] feat: restore backend-neutral drop-in API + concurrent-checkpoint bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restores the named API removed on the self-containment branch so replicate, Base, and base-ha migrate off modernc.org/sqlite with zero code churn — each is one tag-neutral file + engine(!cgo)/csqlite(cgo) halves, so the same calls run under both backends: - OpenPragma / Pragma / PragmaDSN — per-connection pragmas (the only backend-neutral way to set wal_autocheckpoint=0; csqlite drops it from the DSN) - SetPersistWAL — SQLITE_FCNTL_PERSIST_WAL, WAL-shipping replication needs the -wal retained across close - HookRegisterer / CommitHookFn / CommitHookRegisterer — CommitHookFn ALIASES the engine's under !cgo, so a raw-conn driverConn.(sqlite.HookRegisterer) assertion (Hanzo Base) works with no bridge - Driver / ConnectionHookFn / ExecQuerierContext / RegisterConnectionHook — re-exports of the pure-Go engine's connection-hook feature so litesql/go-sqlite-ha (base-ha) migrates without importing internal packages - IsConstraint{Unique,PrimaryKey,ForeignKey} Adds TestConcurrentCheckpointUnderLoad as the verification bar for concurrent checkpoint locking. The vendored engine (SQLite 3.53.2) blocks correctly on busy_timeout (a checkpoint waits out a 700ms-held writer lock then truncates). replicate's flaky TestDB_CheckpointPageGapWithConcurrentWrites is a harness race (its writer has no busy_timeout and hammers), NOT a version regression: clean serial pass rate is fork 9/12 == modernc v1.44.3 9/12, > v1.48.0 7/12. Basing on v1.44.3 does not fix it and would downgrade the SQLite. Zero modernc.org/* in the module graph. Both backends build; full suite green. --- LLM.md | 42 ++++++++- checkpoint_concurrent_test.go | 161 ++++++++++++++++++++++++++++++++++ connector.go | 95 ++++++++++++++++++++ connhook_nocgo.go | 34 +++++++ driver_nocgo.go | 2 - errcodes.go | 37 ++++++++ errcodes_cgo.go | 29 ++++++ errcodes_nocgo.go | 31 +++++++ filecontrol_cgo.go | 33 +++++++ filecontrol_nocgo.go | 34 +++++++ hooks.go | 36 ++++++++ hooks_cgo.go | 35 ++++++++ hooks_nocgo.go | 32 +++++++ pragma.go | 34 +++++++ pragma_cgo.go | 24 +++++ pragma_nocgo.go | 22 +++++ sqlite.go | 8 +- 17 files changed, 681 insertions(+), 8 deletions(-) create mode 100644 checkpoint_concurrent_test.go create mode 100644 connector.go create mode 100644 connhook_nocgo.go create mode 100644 errcodes.go create mode 100644 errcodes_cgo.go create mode 100644 errcodes_nocgo.go create mode 100644 filecontrol_cgo.go create mode 100644 filecontrol_nocgo.go create mode 100644 hooks.go create mode 100644 hooks_cgo.go create mode 100644 hooks_nocgo.go create mode 100644 pragma.go create mode 100644 pragma_cgo.go create mode 100644 pragma_nocgo.go diff --git a/LLM.md b/LLM.md index bacb358..895e194 100644 --- a/LLM.md +++ b/LLM.md @@ -90,6 +90,33 @@ so the VFS (and the DEK) are torn down exactly when the `*sql.DB` closes. - `driver_cgo.go` (`//go:build cgo`) — registers `sqlite`→**hanzoai/csqlite**; keys via SQLCipher URI `key=x'HEX'`; path percent-escaped so `?`/`#` can't strip `key=`. - `internal/engine/**` — the vendored pure-Go SQLite engine (fork; see above). - `encryption_proof_test.go`, `sqlcipher_pure_test.go` — anti-silent-plaintext gate + pure-Go WAL round-trip + byte-compat both directions (opens a C-written fixture; decrypts driver-written bytes with the standalone codec). +- `checkpoint_concurrent_test.go` — the concurrent-checkpoint verification bar (below). + +### Drop-in named API (backend-neutral, restored on the self-contained fork) + +These are the surface consumers use beyond `sql.Open("sqlite",…)`; each is one +tag-neutral file + `_cgo`/`_nocgo` backend halves (engine under !cgo, csqlite +under cgo), so the SAME calls compile and run under both backends: + +- `pragma.go` — `Pragma{Name,Value}`, `DefaultPragmas`; `pragma_{cgo,nocgo}.go` — `PragmaDSN` (each backend's DSN pragma syntax). +- `connector.go` — `OpenPragma(dsn, pragmas)`: opens a `*sql.DB` that applies the pragmas on EVERY pooled connection (the only backend-neutral way to set `wal_autocheckpoint=0` — csqlite drops it from the DSN). Owns the tag-neutral `driverName`. +- `filecontrol_{cgo,nocgo}.go` — `SetPersistWAL(rawConn, on)` (SQLITE_FCNTL_PERSIST_WAL; replicate needs the `-wal` retained across close). +- `hooks.go` + `hooks_{cgo,nocgo}.go` — `HookRegisterer`, `CommitHookRegisterer(driverConn)`. `CommitHookFn` is a **type alias** for the engine's under !cgo, so the raw engine conn satisfies `HookRegisterer` directly (Hanzo Base asserts `driverConn.(sqlite.HookRegisterer)` on the raw conn — no bridge). +- `connhook_nocgo.go` — `Driver`, `ConnectionHookFn`, `ExecQuerierContext`, `RegisterConnectionHook`: re-exports of the pure-Go engine's connection-hook feature so external HA layers (`litesql/go-sqlite-ha`, used by base-ha) migrate off modernc without importing internal packages. !cgo only (no CGO analogue). +- `errcodes*.go` — `IsConstraint{Unique,PrimaryKey,ForeignKey}` (backend-neutral extended-code classification). + +## Concurrent checkpoint under load + +`TestConcurrentCheckpointUnderLoad` is the bar for the locking property WAL-shipping +replication (hanzoai/replicate) depends on: TRUNCATE-checkpoint on one connection +while writers hammer another, asserting no hard `SQLITE_BUSY`, the checkpoint +completes, and no committed frame is lost. The engine BLOCKS correctly on +`busy_timeout` (measured: a checkpoint waits out a 700ms-held writer lock then +truncates). Note: replicate's own `TestDB_CheckpointPageGapWithConcurrentWrites` +is a **flaky race** (its writer has no busy_timeout and hammers), not a version +regression — clean serial pass rate is fork(3.53.2) 9/12 == modernc v1.44.3 9/12 > +v1.48.0 7/12. Basing the engine on v1.44.3 does NOT fix it and would downgrade the +SQLite. A well-behaved writer (busy_timeout set, as in the bar test) is reliable. ## Envelope encryption — rotation-safe (read before touching key handling) @@ -131,6 +158,15 @@ Hanzo IAM / cloud (`cek/cek.go`, per-principal encrypted stores): ## Versioning -PATCH bumps only. Current: **v0.3.1** — pure-Go backend now ENCRYPTS via the -vendored engine + hanzoai/sqlcipher codec VFS (was: `ErrEncryptionUnavailable`); -zero `modernc.org/*` modules; CGO backend migrated mattn/go-sqlite3 → hanzoai/csqlite. +PATCH bumps only. + +- **v0.3.2** — restored the backend-neutral drop-in named API on the self-contained + fork (`OpenPragma`/`Pragma`/`PragmaDSN`, `SetPersistWAL`, `HookRegisterer`/ + `CommitHookFn`/`CommitHookRegisterer`, `IsConstraint*`, and `Driver`/ + `ConnectionHookFn`/`ExecQuerierContext`/`RegisterConnectionHook` re-exports) so + replicate + Base + base-ha migrate off modernc with zero code churn; `CommitHookFn` + aliases the engine's under !cgo so raw-conn `HookRegisterer` assertions work. Added + `TestConcurrentCheckpointUnderLoad`. No `modernc.org/*`. +- **v0.3.1** — pure-Go backend now ENCRYPTS via the vendored engine + hanzoai/sqlcipher + codec VFS (was: `ErrEncryptionUnavailable`); zero `modernc.org/*` modules; CGO backend + migrated mattn/go-sqlite3 → hanzoai/csqlite. diff --git a/checkpoint_concurrent_test.go b/checkpoint_concurrent_test.go new file mode 100644 index 0000000..0fedc58 --- /dev/null +++ b/checkpoint_concurrent_test.go @@ -0,0 +1,161 @@ +package sqlite + +import ( + "database/sql" + "path/filepath" + "strings" + "sync" + "sync/atomic" + "testing" + "time" +) + +// TestConcurrentCheckpointUnderLoad is the verification bar for concurrent- +// checkpoint locking — the property WAL-shipping replication (hanzoai/replicate) +// depends on. It runs a TRUNCATE-checkpoint loop on one connection while several +// writers hammer INSERTs on another, then asserts: +// +// - no wal_checkpoint(TRUNCATE) ever fails with a hard SQLITE_BUSY statement +// error (busy_timeout must make the checkpoint BLOCK for the writer lock, not +// bail — this is exactly what a broken/regressed blocking-lock path breaks); +// - the checkpoint actually completes (busy=0) at least once under load; +// - every committed row survives (TRUNCATE never truncates un-checkpointed +// frames out from under a writer — no data loss); +// - reopening the file reads every row back (durable, uncorrupted). +// +// It is backend-neutral: OpenPragma applies busy_timeout + wal_autocheckpoint=0 +// on every pooled connection under both the pure-Go and CGO backends, so the +// same bar guards both. busy_timeout is generous (10s) because the correctness +// claim is "the checkpoint blocks and then succeeds", not "it succeeds within an +// arbitrarily tight deadline". +func TestConcurrentCheckpointUnderLoad(t *testing.T) { + const ( + writers = 4 + perWriter = 150 + checkpoints = 40 + blobSize = 4000 + busyTimeout = "10000" + checkpointBT = "10000" + ) + dir := t.TempDir() + path := filepath.Join(dir, "ckpt.db") + + // Writers pool: busy_timeout so a writer BLOCKS on the checkpoint's lock + // instead of erroring; WAL so the checkpoint has something to reclaim. + w, err := OpenPragma("file:"+path, []Pragma{ + {Name: "busy_timeout", Value: busyTimeout}, + {Name: "journal_mode", Value: "WAL"}, + {Name: "synchronous", Value: "NORMAL"}, + }) + if err != nil { + t.Fatal(err) + } + defer w.Close() + w.SetMaxOpenConns(writers) + if _, err := w.Exec(`CREATE TABLE t (id INTEGER PRIMARY KEY, v BLOB)`); err != nil { + t.Fatal(err) + } + + // Checkpointer: single connection, busy_timeout, auto-checkpoint OFF so the + // only checkpoints are the explicit TRUNCATEs below (mirrors replicate). + c, err := OpenPragma("file:"+path, []Pragma{ + {Name: "busy_timeout", Value: checkpointBT}, + {Name: "wal_autocheckpoint", Value: "0"}, + {Name: "journal_mode", Value: "WAL"}, + }) + if err != nil { + t.Fatal(err) + } + defer c.Close() + c.SetMaxOpenConns(1) + + // Fire the writers. + var wrote int64 + var firstWrite sync.Once + started := make(chan struct{}) + var wg sync.WaitGroup + blob := make([]byte, blobSize) + for g := 0; g < writers; g++ { + wg.Add(1) + go func() { + defer wg.Done() + for i := 0; i < perWriter; i++ { + for { + _, err := w.Exec(`INSERT INTO t (v) VALUES (?)`, blob) + if err == nil { + break + } + if isBusy(err) { // a well-behaved writer retries; must never see this with busy_timeout, but be safe + time.Sleep(time.Millisecond) + continue + } + t.Errorf("writer insert: %v", err) + return + } + atomic.AddInt64(&wrote, 1) + firstWrite.Do(func() { close(started) }) + } + }() + } + <-started // don't checkpoint an empty WAL + + // Hammer TRUNCATE checkpoints concurrently with the writers. + var completed, incomplete int + for k := 0; k < checkpoints; k++ { + var busy, logN, ckN int + if err := c.QueryRow(`PRAGMA wal_checkpoint(TRUNCATE)`).Scan(&busy, &logN, &ckN); err != nil { + // The regression signature: TRUNCATE returns SQLITE_BUSY as a hard + // statement error instead of blocking on busy_timeout. + t.Fatalf("checkpoint %d hard-failed (blocking-lock regression): %v", k, err) + } + if busy == 0 { + completed++ + } else { + incomplete++ + } + time.Sleep(time.Millisecond) + } + wg.Wait() + + if completed == 0 { + t.Fatalf("no TRUNCATE checkpoint completed under load (%d incomplete) — checkpoint starved", incomplete) + } + t.Logf("checkpoints: %d completed, %d busy; rows written: %d", completed, incomplete, atomic.LoadInt64(&wrote)) + + // No data loss: every committed row is present. + want := int64(writers * perWriter) + if got := atomic.LoadInt64(&wrote); got != want { + t.Fatalf("writers wrote %d rows, want %d", got, want) + } + var n int64 + if err := c.QueryRow(`SELECT count(*) FROM t`).Scan(&n); err != nil { + t.Fatal(err) + } + if n != want { + t.Fatalf("row count %d after concurrent checkpoint, want %d (frames lost)", n, want) + } + + // Durable + uncorrupted: a fresh open reads every row back. + w.Close() + c.Close() + re, err := sql.Open("sqlite", "file:"+path) + if err != nil { + t.Fatal(err) + } + defer re.Close() + var n2 int64 + if err := re.QueryRow(`SELECT count(*) FROM t`).Scan(&n2); err != nil { + t.Fatal(err) + } + if n2 != want { + t.Fatalf("reopened DB has %d rows, want %d", n2, want) + } +} + +func isBusy(err error) bool { + if err == nil { + return false + } + s := err.Error() + return strings.Contains(s, "database is locked") || strings.Contains(s, "SQLITE_BUSY") || strings.Contains(s, "database table is locked") +} diff --git a/connector.go b/connector.go new file mode 100644 index 0000000..b6908f9 --- /dev/null +++ b/connector.go @@ -0,0 +1,95 @@ +package sqlite + +import ( + "context" + "database/sql" + "database/sql/driver" + "fmt" + "sync" +) + +// driverName is the database/sql driver name registered by BOTH backends +// (driver_nocgo.go registers the pure-Go engine under it; driver_cgo.go +// registers csqlite under it). Tag-neutral single source of truth. +const driverName = "sqlite" + +// OpenPragma opens a *sql.DB on the registered "sqlite" backend where EVERY +// pooled connection has the given pragmas applied, in order, via PRAGMA +// statements run at connect time. +// +// Use it for pragmas that must hold on every connection but that the two +// backends do NOT accept uniformly in the DSN. The load-bearing case is +// wal_autocheckpoint: the pure-Go engine honors `?_pragma=wal_autocheckpoint(0)` +// in the DSN, but csqlite silently DROPS it (its DSN grammar has no such param), +// so a binary built CGO=1 would re-enable auto-checkpoint and truncate the WAL +// out from under a WAL-shipping replicator — losing committed frames. Running +// the pragma per connection via ExecContext is backend-neutral (both conns +// implement driver.ExecerContext), so it takes effect either way. +// +// Order matters: put busy_timeout first so a connection blocks on a busy +// database before journal_mode=WAL is attempted (WAL can't be set while another +// connection holds the db). +// +// dsn is a plain (unencrypted) DSN — typically "file:"+path. Encrypted opens go +// through OpenDB (the key binds to the codec VFS, not the DSN). Do NOT also put +// these pragmas in the DSN; they're applied here. +func OpenPragma(dsn string, pragmas []Pragma) (*sql.DB, error) { + drv := backendDriver() + if drv == nil { + return nil, fmt.Errorf("sqlite: OpenPragma: no %q driver registered", driverName) + } + return sql.OpenDB(&pragmaConnector{driver: drv, dsn: dsn, pragmas: pragmas}), nil +} + +// pragmaConnector is a database/sql Connector that opens a backend connection +// and applies pragmas to it before handing it to the pool. Because the pool +// calls Connect for every new connection, the pragmas hold pool-wide. +type pragmaConnector struct { + driver driver.Driver + dsn string + pragmas []Pragma +} + +func (pc *pragmaConnector) Connect(ctx context.Context) (driver.Conn, error) { + conn, err := pc.driver.Open(pc.dsn) + if err != nil { + return nil, err + } + execer, ok := conn.(driver.ExecerContext) + if !ok { + _ = conn.Close() + return nil, fmt.Errorf("sqlite: OpenPragma: driver conn %T is not a driver.ExecerContext", conn) + } + for _, p := range pc.pragmas { + stmt := "PRAGMA " + p.Name + " = " + p.Value + if _, err := execer.ExecContext(ctx, stmt, nil); err != nil { + _ = conn.Close() + return nil, fmt.Errorf("sqlite: OpenPragma: apply %q: %w", stmt, err) + } + } + return conn, nil +} + +func (pc *pragmaConnector) Driver() driver.Driver { return pc.driver } + +var ( + backendDriverOnce sync.Once + backendDriverInst driver.Driver +) + +// backendDriver returns the driver.Driver registered under the name "sqlite" by +// this package (csqlite under cgo, the pure-Go engine otherwise). It is resolved +// once, via a throwaway in-memory sql.DB, so the connector stays tag-neutral — +// it needs no per-backend driver symbol and works whichever backend init() +// registered. +func backendDriver() driver.Driver { + backendDriverOnce.Do(func() { + db, err := sql.Open(driverName, "file::memory:") + if err != nil { + return + } + backendDriverInst = db.Driver() + _ = db.Close() + }) + return backendDriverInst +} diff --git a/connhook_nocgo.go b/connhook_nocgo.go new file mode 100644 index 0000000..9800d19 --- /dev/null +++ b/connhook_nocgo.go @@ -0,0 +1,34 @@ +//go:build !cgo + +package sqlite + +import engine "github.com/hanzoai/sqlite/internal/engine" + +// Connection-hook surface — re-exported from the vendored pure-Go engine so +// external HA/replication libraries (e.g. litesql/go-sqlite-ha, used by base-ha) +// can migrate off modernc.org/sqlite WITHOUT importing internal packages. These +// are the pure-Go engine's connection-hook feature; there is no CGO analogue +// (csqlite has a different hook model), so they exist only under !cgo — the +// backend base-ha and the HA layer run on. + +// Driver is the pure-Go SQLite driver type. A zero value is usable: register +// connection hooks on it, then hand &Driver to a database/sql connector. This is +// the same driver type registered under the "sqlite" name; go-sqlite-ha does +// `var drv sqlite.Driver; drv.RegisterConnectionHook(fn)` then opens through it. +type Driver = engine.Driver + +// ExecQuerierContext is the exec+query surface a ConnectionHookFn receives: the +// minimal handle a hook uses to run setup SQL on each new connection before it +// enters the pool. +type ExecQuerierContext = engine.ExecQuerierContext + +// ConnectionHookFn runs on every new connection the driver opens, after setup +// and before the connection enters the pool — the hook point HA/replication +// layers install their per-connection wiring on. +type ConnectionHookFn = engine.ConnectionHookFn + +// RegisterConnectionHook installs fn on the driver registered under the "sqlite" +// name; fn then runs for every new connection opened via sql.Open("sqlite", …). +// (A private Driver instance registers hooks via its own RegisterConnectionHook +// method — see Driver.) +func RegisterConnectionHook(fn ConnectionHookFn) { engine.RegisterConnectionHook(fn) } diff --git a/driver_nocgo.go b/driver_nocgo.go index 61f81f3..26b10e9 100644 --- a/driver_nocgo.go +++ b/driver_nocgo.go @@ -22,8 +22,6 @@ import ( "github.com/hanzoai/sqlite/internal/engine/vfs" ) -const driverName = "sqlite" - // ErrEncryptionUnavailable is retained for API symmetry with the CGO backend. It // is never returned now: the pure-Go backend encrypts via the vendored engine + // the hanzoai/sqlcipher codec VFS, so encryption is always available. diff --git a/errcodes.go b/errcodes.go new file mode 100644 index 0000000..e90805d --- /dev/null +++ b/errcodes.go @@ -0,0 +1,37 @@ +package sqlite + +// Backend-neutral classification of SQLite constraint-violation errors. +// +// SQLite's extended result codes (SQLITE_CONSTRAINT_UNIQUE = 2067, etc.) are the +// engine's own numbers and are IDENTICAL across both backends. Only the concrete +// error TYPE differs (csqlite Error value vs the pure-Go engine's *Error pointer) +// and only the source of the reference constants differs. So the three public +// predicates live here ONCE, tag-neutral; the per-backend error unwrap +// (extendedCode) and the constant values (codeConstraint*) are supplied by the +// build-tagged errcodes_cgo.go / errcodes_nocgo.go. +// +// Consumers replace direct backend-specific `Code() == SQLITE_...` checks with +// these, so no code outside this package imports a sqlite backend to classify +// errors. + +// IsConstraintUnique reports whether err is a UNIQUE-constraint violation from +// the active SQLite backend. It unwraps via errors.As, so a wrapped error is +// still classified. Returns false for a nil or non-sqlite error. +func IsConstraintUnique(err error) bool { + c, ok := extendedCode(err) + return ok && c == codeConstraintUnique +} + +// IsConstraintPrimaryKey reports whether err is a PRIMARY KEY-constraint +// violation from the active SQLite backend. +func IsConstraintPrimaryKey(err error) bool { + c, ok := extendedCode(err) + return ok && c == codeConstraintPrimaryKey +} + +// IsConstraintForeignKey reports whether err is a FOREIGN KEY-constraint +// violation from the active SQLite backend. +func IsConstraintForeignKey(err error) bool { + c, ok := extendedCode(err) + return ok && c == codeConstraintForeignKey +} diff --git a/errcodes_cgo.go b/errcodes_cgo.go new file mode 100644 index 0000000..70e305d --- /dev/null +++ b/errcodes_cgo.go @@ -0,0 +1,29 @@ +//go:build cgo + +package sqlite + +import ( + "errors" + + csqlite "github.com/hanzoai/csqlite" +) + +// Reference constraint codes and the error unwrap for the CGO/csqlite backend +// (same build condition as driver_cgo.go / hooks_cgo.go). The values are +// SQLite's own extended result codes, sourced here from csqlite's typed +// constants. +var ( + codeConstraintUnique = int(csqlite.ErrConstraintUnique) + codeConstraintPrimaryKey = int(csqlite.ErrConstraintPrimaryKey) + codeConstraintForeignKey = int(csqlite.ErrConstraintForeignKey) +) + +// extendedCode extracts SQLite's extended result code from a csqlite error. +// csqlite.Error is a VALUE type, so errors.As targets a value, not a pointer. +func extendedCode(err error) (int, bool) { + var e csqlite.Error + if errors.As(err, &e) { + return int(e.ExtendedCode), true + } + return 0, false +} diff --git a/errcodes_nocgo.go b/errcodes_nocgo.go new file mode 100644 index 0000000..3d35793 --- /dev/null +++ b/errcodes_nocgo.go @@ -0,0 +1,31 @@ +//go:build !cgo + +package sqlite + +import ( + "errors" + + engine "github.com/hanzoai/sqlite/internal/engine" + lib "github.com/hanzoai/sqlite/internal/engine/lib" +) + +// Reference constraint codes and the error unwrap for the pure-Go engine backend +// (same build condition as driver_nocgo.go / hooks_nocgo.go). The values come +// from the vendored engine's generated lib package and are the SQLite extended +// result codes. +var ( + codeConstraintUnique = lib.SQLITE_CONSTRAINT_UNIQUE + codeConstraintPrimaryKey = lib.SQLITE_CONSTRAINT_PRIMARYKEY + codeConstraintForeignKey = lib.SQLITE_CONSTRAINT_FOREIGNKEY +) + +// extendedCode extracts SQLite's extended result code from a pure-Go engine +// error. *engine.Error is a POINTER type with a Code() accessor that returns the +// extended code. +func extendedCode(err error) (int, bool) { + var e *engine.Error + if errors.As(err, &e) { + return e.Code(), true + } + return 0, false +} diff --git a/filecontrol_cgo.go b/filecontrol_cgo.go new file mode 100644 index 0000000..9b1c1dd --- /dev/null +++ b/filecontrol_cgo.go @@ -0,0 +1,33 @@ +//go:build cgo + +package sqlite + +import ( + "fmt" + + csqlite "github.com/hanzoai/csqlite" +) + +// SetPersistWAL sets SQLite's SQLITE_FCNTL_PERSIST_WAL file control on rawConn — +// the raw driver connection handed to the callback of (*sql.Conn).Raw. When on, +// the -wal file is kept across the last connection close (SQLite otherwise +// deletes it), which WAL-shipping replication (hanzoai/replicate) requires so a +// crash mid-sync doesn't lose committed frames. +// +// It is the one backend-neutral way to set PERSIST_WAL; consumers never touch +// the concrete conn type directly. Returns an error if rawConn is not this +// build's SQLite connection type. +// +// CGO backend: csqlite exposes SetFileControlInt; the op constant is csqlite's +// own SQLITE_FCNTL_PERSIST_WAL (= 10). +func SetPersistWAL(rawConn any, on bool) error { + c, ok := rawConn.(*csqlite.SQLiteConn) + if !ok { + return fmt.Errorf("sqlite: SetPersistWAL: driver conn is %T, want *csqlite.SQLiteConn", rawConn) + } + arg := 0 + if on { + arg = 1 + } + return c.SetFileControlInt("main", csqlite.SQLITE_FCNTL_PERSIST_WAL, arg) +} diff --git a/filecontrol_nocgo.go b/filecontrol_nocgo.go new file mode 100644 index 0000000..91e426c --- /dev/null +++ b/filecontrol_nocgo.go @@ -0,0 +1,34 @@ +//go:build !cgo + +package sqlite + +import ( + "fmt" + + engine "github.com/hanzoai/sqlite/internal/engine" +) + +// SetPersistWAL sets SQLite's SQLITE_FCNTL_PERSIST_WAL file control on rawConn — +// the raw driver connection handed to the callback of (*sql.Conn).Raw. When on, +// the -wal file is kept across the last connection close (SQLite otherwise +// deletes it), which WAL-shipping replication (hanzoai/replicate) requires so a +// crash mid-sync doesn't lose committed frames. +// +// It is the one backend-neutral way to set PERSIST_WAL; consumers never touch +// the concrete conn type directly. Returns an error if rawConn is not this +// build's SQLite connection type. +// +// Pure-Go backend: the vendored engine's *conn satisfies its exported +// FileControl interface; mode 1 enables, 0 disables (-1 would query). +func SetPersistWAL(rawConn any, on bool) error { + fc, ok := rawConn.(engine.FileControl) + if !ok { + return fmt.Errorf("sqlite: SetPersistWAL: driver conn is %T, want engine.FileControl", rawConn) + } + mode := 0 + if on { + mode = 1 + } + _, err := fc.FileControlPersistWAL("main", mode) + return err +} diff --git a/hooks.go b/hooks.go new file mode 100644 index 0000000..81c805f --- /dev/null +++ b/hooks.go @@ -0,0 +1,36 @@ +package sqlite + +// Commit-hook surface — one API, two backends (selected by build tag). +// +// A SQLite commit hook fires inside the engine at COMMIT time; returning a +// non-zero value aborts the transaction (SQLite rolls it back and surfaces +// SQLITE_BUSY). Hanzo Base uses it to capture per-transaction WAL frames for +// cross-pod replication + point-in-time recovery. +// +// The two backends expose DIFFERENT native callback signatures: +// +// pure-Go (!cgo): RegisterCommitHook(func() int32) +// cgo/csqlite: RegisterCommitHook(func() int) +// +// so a consumer cannot type-assert a raw driver connection against one shared +// interface (interface satisfaction needs identical method signatures, and each +// backend's method takes its OWN function type). CommitHookRegisterer bridges +// that: it type-asserts the concrete backend conn under the active build tag +// (hooks_cgo.go / hooks_nocgo.go) and returns an adapter speaking the single +// CommitHookFn shape below. Consumers import ONLY this package. + +// CommitHookFn is a commit-hook callback (func() int32). Returning a non-zero +// value ABORTS the commit (SQLite rolls back and reports SQLITE_BUSY); returning +// zero lets it proceed. It is defined per backend (hooks_cgo.go / hooks_nocgo.go): +// under !cgo it is a type ALIAS for the vendored engine's CommitHookFn, so the +// raw engine connection satisfies HookRegisterer directly (a consumer can +// `driverConn.(sqlite.HookRegisterer)` with no bridge); under cgo it is a +// distinct func() int32 that the CommitHookRegisterer bridge adapts to csqlite's +// func() int callback. + +// HookRegisterer installs a commit hook on a driver connection. Passing a nil +// CommitHookFn clears any installed hook. Under !cgo the raw engine conn +// satisfies this directly; under cgo, obtain one via CommitHookRegisterer. +type HookRegisterer interface { + RegisterCommitHook(CommitHookFn) +} diff --git a/hooks_cgo.go b/hooks_cgo.go new file mode 100644 index 0000000..ae2a3e5 --- /dev/null +++ b/hooks_cgo.go @@ -0,0 +1,35 @@ +//go:build cgo + +package sqlite + +import csqlite "github.com/hanzoai/csqlite" + +// CommitHookFn is the commit-hook callback under the CGO backend: a distinct +// func() int32 (csqlite has no matching exported type), adapted to csqlite's +// native func() int by CommitHookRegisterer. Consumers cannot assert the raw +// csqlite conn to HookRegisterer under cgo; they must use CommitHookRegisterer. +type CommitHookFn func() int32 + +// CommitHookRegisterer adapts a raw csqlite driver connection (obtained from +// (*sql.Conn).Raw) to HookRegisterer. csqlite's *SQLiteConn commit-hook type is +// `func() int` (not int32), so the adapter widens our CommitHookFn's int32 +// result to csqlite's int. This is the SAME engine driver_cgo.go registers as +// the "sqlite" driver name. Returns (nil, false) if driverConn is not a csqlite +// connection. +func CommitHookRegisterer(driverConn any) (HookRegisterer, bool) { + c, ok := driverConn.(*csqlite.SQLiteConn) + if !ok { + return nil, false + } + return csqliteHook{c}, true +} + +type csqliteHook struct{ c *csqlite.SQLiteConn } + +func (m csqliteHook) RegisterCommitHook(cb CommitHookFn) { + if cb == nil { + m.c.RegisterCommitHook(nil) + return + } + m.c.RegisterCommitHook(func() int { return int(cb()) }) +} diff --git a/hooks_nocgo.go b/hooks_nocgo.go new file mode 100644 index 0000000..4c41f1d --- /dev/null +++ b/hooks_nocgo.go @@ -0,0 +1,32 @@ +//go:build !cgo + +package sqlite + +import engine "github.com/hanzoai/sqlite/internal/engine" + +// CommitHookFn is a type ALIAS for the vendored engine's commit-hook callback +// type. Because it is the SAME type (not merely the same underlying func() +// int32), the engine's *conn — whose RegisterCommitHook takes engine.CommitHookFn +// — satisfies HookRegisterer directly, so consumers (Hanzo Base) can +// `driverConn.(sqlite.HookRegisterer)` on the raw conn with no bridge. +type CommitHookFn = engine.CommitHookFn + +// CommitHookRegisterer adapts a raw pure-Go engine driver connection (obtained +// from (*sql.Conn).Raw) to HookRegisterer. The engine's *conn satisfies +// engine.HookRegisterer; its native commit-hook type engine.CommitHookFn is +// `func() int32` — identical underlying shape to our CommitHookFn — so the +// bridge is a direct type conversion. Returns (nil, false) if driverConn is not +// an engine connection (wrong driver, or a wrapped conn). +func CommitHookRegisterer(driverConn any) (HookRegisterer, bool) { + c, ok := driverConn.(engine.HookRegisterer) + if !ok { + return nil, false + } + return engineHook{c}, true +} + +type engineHook struct{ c engine.HookRegisterer } + +// CommitHookFn IS engine.CommitHookFn (alias), so this is a direct call; a nil cb +// clears the hook. +func (m engineHook) RegisterCommitHook(cb CommitHookFn) { m.c.RegisterCommitHook(cb) } diff --git a/pragma.go b/pragma.go new file mode 100644 index 0000000..a166d61 --- /dev/null +++ b/pragma.go @@ -0,0 +1,34 @@ +package sqlite + +// Connection-tuning surface — one pragma set, encoded per backend. +// +// The two backends express connection pragmas with DIFFERENT DSN syntax: +// +// pure-Go (!cgo): ?_pragma=busy_timeout(10000)&_pragma=journal_mode(WAL)&... +// cgo/csqlite: ?_busy_timeout=10000&_journal_mode=WAL&... +// +// A DSN written for one backend is silently IGNORED by the other (csqlite drops +// unknown `_pragma=` params; the pure-Go engine drops unknown `_busy_timeout=` +// params), so a hardcoded single-form DSN loses its pragmas — no WAL, no +// busy_timeout — whenever the binary is built for the other backend (e.g. Base +// is CGO=0 but is embedded into commerce's CGO=1 build). PragmaDSN encodes the +// pragmas in the ACTIVE backend's syntax (pragma_cgo.go / pragma_nocgo.go) so +// the same pragma set applies under both. + +// Pragma is one SQLite PRAGMA (name + value) applied at connection-open time. +type Pragma struct{ Name, Value string } + +// DefaultPragmas is the canonical Hanzo embedded-SQLite connection tuning. Order +// matters: busy_timeout MUST lead so a connection blocks on a busy database +// before journal_mode=WAL is set (WAL cannot be enabled while another connection +// holds the database). This is the single source of truth for the unencrypted +// default-connect DSN used across Hanzo Base — treat it as read-only. +var DefaultPragmas = []Pragma{ + {Name: "busy_timeout", Value: "10000"}, + {Name: "journal_mode", Value: "WAL"}, + {Name: "journal_size_limit", Value: "200000000"}, + {Name: "synchronous", Value: "NORMAL"}, + {Name: "foreign_keys", Value: "ON"}, + {Name: "temp_store", Value: "MEMORY"}, + {Name: "cache_size", Value: "-32000"}, +} diff --git a/pragma_cgo.go b/pragma_cgo.go new file mode 100644 index 0000000..c7a2720 --- /dev/null +++ b/pragma_cgo.go @@ -0,0 +1,24 @@ +//go:build cgo + +package sqlite + +import ( + "fmt" + "strings" +) + +// PragmaDSN builds an unencrypted `file:` DSN for path that applies pragmas in +// csqlite's `_NAME=VALUE` syntax. csqlite recognises _busy_timeout, +// _journal_mode, _synchronous, _foreign_keys and _cache_size and silently +// ignores any other parameter — so pragmas it cannot express as a DSN param +// (journal_size_limit, temp_store) are inert here but harmless, while the +// correctness-critical ones (busy_timeout, WAL) DO apply. The path is +// percent-escaped (escapeDBPath) so a '?'/'#' in it cannot strip the query. No +// key is added — keyed/encrypted opens go through OpenDB/DSN. +func PragmaDSN(path string, pragmas []Pragma) string { + parts := make([]string, 0, len(pragmas)) + for _, p := range pragmas { + parts = append(parts, "_"+p.Name+"="+p.Value) + } + return fmt.Sprintf("file:%s?%s", escapeDBPath(path), strings.Join(parts, "&")) +} diff --git a/pragma_nocgo.go b/pragma_nocgo.go new file mode 100644 index 0000000..dafe361 --- /dev/null +++ b/pragma_nocgo.go @@ -0,0 +1,22 @@ +//go:build !cgo + +package sqlite + +import ( + "fmt" + "strings" +) + +// PragmaDSN builds an unencrypted `file:` DSN for path that applies pragmas in +// the pure-Go engine's `_pragma=NAME(VALUE)` syntax — the form it actually +// applies. The path is percent-escaped (escapeDBPath) so a '?' or '#' in it +// cannot terminate the path early and strip the query. This is the CGO-off +// default engine; keyed/encrypted opens go through OpenDB instead (the key binds +// to the codec VFS, never the DSN). +func PragmaDSN(path string, pragmas []Pragma) string { + parts := make([]string, 0, len(pragmas)) + for _, p := range pragmas { + parts = append(parts, "_pragma="+p.Name+"("+p.Value+")") + } + return fmt.Sprintf("file:%s?%s", escapeDBPath(path), strings.Join(parts, "&")) +} diff --git a/sqlite.go b/sqlite.go index 82087ce..02df299 100644 --- a/sqlite.go +++ b/sqlite.go @@ -192,9 +192,11 @@ func CodecLinked() bool { // Open opens an encrypted, optionally distributed SQLite database. // -// Under the !cgo backend, passing an encryption key (WithKey/WithRawKey/ -// WithPrincipalKey) is a hard error: the pure-Go engine cannot encrypt and we -// refuse to silently persist plaintext when a caller asked for encryption. +// A key (WithKey/WithRawKey/WithPrincipalKey) encrypts at rest under BOTH +// backends in the same SQLCipher-4 format: the pure-Go engine keys through the +// hanzoai/sqlcipher codec VFS, the CGO engine through libsqlcipher. A 32-byte +// key is required; EncryptionAvailable() is true either way, so the only reason +// Open rejects a key is a wrong length (never "no encryption on this backend"). func Open(path string, opts ...Option) (*DB, error) { cfg := Config{Mode: ModeSingle} for _, o := range opts {